text
stringlengths
157
7.64M
meta
dict
theory CFGExit_wf imports CFGExit CFG_wf begin subsection ‹New well-formedness lemmas using ‹(_Exit_)›› locale CFGExit_wf = CFG_wf sourcenode targetnode kind valid_edge Entry Def Use state_val + CFGExit sourcenode targetnode kind valid_edge Entry 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'_')") + assumes Exit_empty:"Def (_Exit_) = {} ∧ Use (_Exit_) = {}" begin lemma Exit_Use_empty [dest!]: "V ∈ Use (_Exit_) ⟹ False" by (simp add:Exit_empty (*‹(Def::'node ⇒ 'var set) (_Exit_) = {} ∧ (Use::'node ⇒ 'var set) (_Exit_) = {}›*)) lemma Exit_Def_empty [dest!]: "V ∈ Def (_Exit_) ⟹ False" by (simp add:Exit_empty (*‹Def (_Exit_) = {} ∧ Use (_Exit_) = {}›*)) end end
{ "path": "afp-2025-02-12/thys/Slicing/Basic/CFGExit_wf.thy", "repo": "afp-2025-02-12", "sha": "e4690f98287425f8277b126fc011a4a29d03de2ebbe9202ed0f2f77c58ca28be" }
subsection ‹Formulation of a subject-subject communication policy and an information flow policy, and showing both can be derived from subject-object configuration data› theory Step_policies imports Step_configuration begin subsubsection ‹Specification\label{sect:policy_specification}› text ‹In order to use CISK, we need an information flow policy @{term ifp} relation. We also express a static subject-subject @{term sp_spec_subj_obj} and subject-object @{term sp_spec_subj_subj} access control policy for the implementation of the model. The following locale summarizes all properties we need.› locale policy_axioms = fixes sp_spec_subj_obj :: "'a ⇒ obj_id_t ⇒ mode_t ⇒ bool" and sp_spec_subj_subj :: "'a ⇒ 'a ⇒ bool" and ifp :: "'a ⇒ 'a ⇒ bool" assumes sp_spec_file_provider: "∀ p1 p2 f m1 m2 . sp_spec_subj_obj p1 (FILEP f) m1 ∧ sp_spec_subj_obj p2 (FILEP f) m2 ⟶ sp_spec_subj_subj p1 p2" and sp_spec_no_wronly_pages: "∀ p x . sp_spec_subj_obj p (PAGE x) WRITE ⟶ sp_spec_subj_obj p (PAGE x) READ" and ifp_reflexive: "∀ p . ifp p p" and ifp_compatible_with_sp_spec: "∀ a b . sp_spec_subj_subj a b ⟶ ifp a b ∧ ifp b a" and ifp_compatible_with_ipc: "∀ a b c x . (sp_spec_subj_subj a b ∧ sp_spec_subj_obj b (PAGE x) WRITE ∧ sp_spec_subj_obj c (PAGE x) READ) ⟶ ifp a c" begin (* empty *) end subsubsection ‹Derivation› text ‹The configuration data only consists of a subject-object policy. We derive the subject-subject policy and the information flow policy from the configuration data and prove that properties we specified in Section~\ref{sect:policy_specification} are satisfied.› locale abstract_policy_derivation = fixes configuration_subj_obj :: "'a ⇒ obj_id_t ⇒ mode_t ⇒ bool" begin definition "sp_spec_subj_obj a x m ≡ configuration_subj_obj a x m ∨ (∃ y . x = PAGE y ∧ m = READ ∧ configuration_subj_obj a x WRITE)" definition "sp_spec_subj_subj a b ≡ ∃ f m1 m2 . sp_spec_subj_obj a (FILEP f) m1 ∧ sp_spec_subj_obj b (FILEP f) m2" definition "ifp a b ≡ sp_spec_subj_subj a b ∨ sp_spec_subj_subj b a ∨ (∃ c y . sp_spec_subj_subj a c ∧ sp_spec_subj_obj c (PAGE y) WRITE ∧ sp_spec_subj_obj b (PAGE y) READ) ∨ (a = b)" text ‹Show that the policies specified in Section~\ref{sect:policy_specification} can be derived from the configuration and their definitions.› lemma correct: shows "policy_axioms sp_spec_subj_obj sp_spec_subj_subj ifp" proof (unfold_locales) (*goals: 1. ‹∀(p1::'a::type) (p2::'a::type) (f::filep_t) (m1::mode_t) m2::mode_t. sp_spec_subj_obj p1 (FILEP f) m1 ∧ sp_spec_subj_obj p2 (FILEP f) m2 ⟶ sp_spec_subj_subj p1 p2› 2. ‹∀(p::'a::type) x::page_t. sp_spec_subj_obj p (PAGE x) WRITE ⟶ sp_spec_subj_obj p (PAGE x) READ› 3. ‹∀p::'a::type. ifp p p› 4. ‹∀(a::'a::type) b::'a::type. sp_spec_subj_subj a b ⟶ ifp a b ∧ ifp b a› 5. ‹∀(a::'a::type) (b::'a::type) (c::'a::type) x::page_t. sp_spec_subj_subj a b ∧ sp_spec_subj_obj b (PAGE x) WRITE ∧ sp_spec_subj_obj c (PAGE x) READ ⟶ ifp a c›*) show sp_spec_file_provider: "∀ p1 p2 f m1 m2 . sp_spec_subj_obj p1 (FILEP f) m1 ∧ sp_spec_subj_obj p2 (FILEP f) m2 ⟶ sp_spec_subj_subj p1 p2" unfolding sp_spec_subj_subj_def (*goal: ‹∀p1 p2 f m1 m2. sp_spec_subj_obj p1 (FILEP f) m1 ∧ sp_spec_subj_obj p2 (FILEP f) m2 ⟶ (∃f m1 m2. sp_spec_subj_obj p1 (FILEP f) m1 ∧ sp_spec_subj_obj p2 (FILEP f) m2)›*) by auto show sp_spec_no_wronly_pages: "∀ p x . sp_spec_subj_obj p (PAGE x) WRITE ⟶ sp_spec_subj_obj p (PAGE x) READ" unfolding sp_spec_subj_obj_def (*goal: ‹∀p x. configuration_subj_obj p (PAGE x) WRITE ∨ (∃y. PAGE x = PAGE y ∧ WRITE = READ ∧ configuration_subj_obj p (PAGE x) WRITE) ⟶ configuration_subj_obj p (PAGE x) READ ∨ (∃y. PAGE x = PAGE y ∧ READ = READ ∧ configuration_subj_obj p (PAGE x) WRITE)›*) by auto show ifp_reflexive: "∀ p . ifp p p" unfolding ifp_def (*goal: ‹∀p::'a. sp_spec_subj_subj p p ∨ sp_spec_subj_subj p p ∨ (∃(c::'a) y::page_t. sp_spec_subj_subj p c ∧ sp_spec_subj_obj c (PAGE y) WRITE ∧ sp_spec_subj_obj p (PAGE y) READ) ∨ p = p›*) by auto show ifp_compatible_with_sp_spec: "∀ a b . sp_spec_subj_subj a b ⟶ ifp a b ∧ ifp b a" unfolding ifp_def (*goal: ‹∀a b. sp_spec_subj_subj a b ⟶ (sp_spec_subj_subj a b ∨ sp_spec_subj_subj b a ∨ (∃c y. sp_spec_subj_subj a c ∧ sp_spec_subj_obj c (PAGE y) WRITE ∧ sp_spec_subj_obj b (PAGE y) READ) ∨ a = b) ∧ (sp_spec_subj_subj b a ∨ sp_spec_subj_subj a b ∨ (∃c y. sp_spec_subj_subj b c ∧ sp_spec_subj_obj c (PAGE y) WRITE ∧ sp_spec_subj_obj a (PAGE y) READ) ∨ b = a)›*) by auto show ifp_compatible_with_ipc: "∀ a b c x . (sp_spec_subj_subj a b ∧ sp_spec_subj_obj b (PAGE x) WRITE ∧ sp_spec_subj_obj c (PAGE x) READ) ⟶ ifp a c" unfolding ifp_def (*goal: ‹∀a b c x. sp_spec_subj_subj a b ∧ sp_spec_subj_obj b (PAGE x) WRITE ∧ sp_spec_subj_obj c (PAGE x) READ ⟶ sp_spec_subj_subj a c ∨ sp_spec_subj_subj c a ∨ (∃ca y. sp_spec_subj_subj a ca ∧ sp_spec_subj_obj ca (PAGE y) WRITE ∧ sp_spec_subj_obj c (PAGE y) READ) ∨ a = c›*) by auto qed end type_synonym sp_subj_subj_t = "partition_id_t ⇒ partition_id_t ⇒ bool" type_synonym sp_subj_obj_t = "partition_id_t ⇒ obj_id_t ⇒ mode_t ⇒ bool" interpretation Policy: abstract_policy_derivation "configured_subj_obj". interpretation Policy_properties: policy_axioms Policy.sp_spec_subj_obj Policy.sp_spec_subj_subj Policy.ifp using Policy.correct (*‹policy_axioms Policy.sp_spec_subj_obj Policy.sp_spec_subj_subj Policy.ifp›*) by auto lemma example_how_to_use_properties_in_proofs: shows "∀ p . Policy.ifp p p" using Policy_properties.ifp_reflexive (*‹∀p. Policy.ifp p p›*) by auto end
{ "path": "afp-2025-02-12/thys/CISC-Kernel/step/Step_policies.thy", "repo": "afp-2025-02-12", "sha": "7068dd63257fee546985eaf5592e6efe7318b0fb05aa1d728233bed450b7dbc6" }
(* File: Symmetric_Polynomials.thy Author: Manuel Eberl (TU München) The definition of symmetric polynomials and the elementary symmetric polynomials. Proof of the fundamental theorem of symmetric polynomials and its corollaries. *) section ‹Symmetric Polynomials› theory Symmetric_Polynomials imports Vieta "Polynomials.More_MPoly_Type" "HOL-Combinatorics.Permutations" begin subsection ‹Auxiliary facts› (* TODO: Many of these facts and definitions should be moved elsewhere, especially the ones on polynomials (leading monomial, mapping, insertion etc.) *) text ‹ An infinite set has infinitely many infinite subsets. › lemma infinite_infinite_subsets: assumes "infinite A" shows "infinite {X. X ⊆ A ∧ infinite X}" proof (-) (*goal: ‹infinite {X::'a::type set. X ⊆ (A::'a::type set) ∧ infinite X}›*) have "∀k. ∃X. X ⊆ A ∧ infinite X ∧ card (A - X) = k" for k :: nat proof (standard) (*goal: ‹⋀k::nat. ∃X⊆A::'a set. infinite X ∧ card (A - X) = k›*) fix k :: nat obtain Y where "finite Y" "card Y = k" "Y ⊆ A" (*goal: ‹(⋀Y. ⟦finite Y; card Y = k; Y ⊆ A⟧ ⟹ thesis) ⟹ thesis›*) using infinite_arbitrarily_large[of A k] (*‹infinite A ⟹ ∃B. finite B ∧ card B = k ∧ B ⊆ A›*) assms (*‹infinite A›*) by auto moreover from this (*‹finite Y› ‹card Y = k› ‹(Y::'a::type set) ⊆ (A::'a::type set)›*) have "A - (A - Y) = Y" by auto ultimately show "∃X. X ⊆ A ∧ infinite X ∧ card (A - X) = k" using assms (*‹infinite A›*) apply (intro exI[of _ "A - Y"] (*‹?P (A - Y) ⟹ ∃x. ?P x›*)) (*goal: ‹∃X⊆A::'a::type set. infinite X ∧ card (A - X) = (k::nat)›*) by auto qed from choice[OF this] (*‹∃f. ∀x. f x ⊆ A ∧ infinite (f x) ∧ card (A - f x) = x›*) obtain f where f: "⋀k. f k ⊆ A ∧ infinite (f k) ∧ card (A - f k) = k" (*goal: ‹(⋀f::nat ⇒ 'a set. (⋀k::nat. f k ⊆ (A::'a set) ∧ infinite (f k) ∧ card (A - f k) = k) ⟹ thesis::bool) ⟹ thesis›*) by blast have "k = l" if "f k = f l" for k and l proof (rule ccontr (*‹(¬ ?P ⟹ False) ⟹ ?P›*)) (*goal: ‹(k::nat) ≠ (l::nat) ⟹ False›*) assume "k ≠ l" (*‹(k::nat) ≠ (l::nat)›*) hence "card (A - f k) ≠ card (A - f l)" using f[of k] (*‹f k ⊆ A ∧ infinite (f k) ∧ card (A - f k) = k›*) f[of l] (*‹(f::nat ⇒ 'a set) (l::nat) ⊆ (A::'a set) ∧ infinite (f l) ∧ card (A - f l) = l›*) by auto with ‹f k = f l› (*‹f k = f l›*) show False by simp qed hence "inj f" by (auto intro: injI (*‹(⋀(x::?'a::type) y::?'a::type. (?f::?'a::type ⇒ ?'b::type) x = ?f y ⟹ x = y) ⟹ inj ?f›*)) moreover have "range f ⊆ {X. X ⊆ A ∧ infinite X}" using f (*‹f ?k ⊆ A ∧ infinite (f ?k) ∧ card (A - f ?k) = ?k›*) by auto ultimately show "?thesis" (*goal: ‹infinite {X::'a::type set. X ⊆ (A::'a::type set) ∧ infinite X}›*) apply (subst infinite_iff_countable_subset (*‹infinite ?S = (∃f. inj f ∧ range f ⊆ ?S)›*)) (*goal: ‹infinite {X. X ⊆ A ∧ infinite X}›*) by auto qed text ‹ An infinite set contains infinitely many finite subsets of any fixed nonzero cardinality. › lemma infinite_card_subsets: assumes "infinite A" "k > 0" shows "infinite {X. X ⊆ A ∧ finite X ∧ card X = k}" proof (-) (*goal: ‹infinite {X. X ⊆ A ∧ finite X ∧ card X = k}›*) obtain B where B: "B ⊆ A" "finite B" "card B = k - 1" (*goal: ‹(⋀B. ⟦B ⊆ A; finite B; card B = k - 1⟧ ⟹ thesis) ⟹ thesis›*) using infinite_arbitrarily_large[OF assms ( 1 ), of "k - 1"] (*‹∃B. finite B ∧ card B = k - 1 ∧ B ⊆ A›*) by blast define f where "f = (λx. insert x B)" have "f ` (A - B) ⊆ {X. X ⊆ A ∧ finite X ∧ card X = k}" using assms (*‹infinite (A::'a::type set)› ‹0 < k›*) B (*‹(B::'a set) ⊆ (A::'a set)› ‹finite B› ‹card B = k - 1›*) by (auto simp: f_def (*‹f = (λx. insert x B)›*)) moreover have "inj_on f (A - B)" by (auto intro!: inj_onI (*‹(⋀x y. ⟦x ∈ ?A; y ∈ ?A; ?f x = ?f y⟧ ⟹ x = y) ⟹ inj_on ?f ?A›*) simp: f_def (*‹f = (λx. insert x B)›*)) hence "infinite (f ` (A - B))" using assms (*‹infinite (A::'a set)› ‹(0::nat) < (k::nat)›*) B (*‹(B::'a set) ⊆ (A::'a set)› ‹finite B› ‹card (B::'a set) = (k::nat) - (1::nat)›*) apply (subst finite_image_iff (*‹inj_on ?f ?A ⟹ finite (?f ` ?A) = finite ?A›*)) (*goals: 1. ‹⟦inj_on f (A - B); infinite A; 0 < k; B ⊆ A; finite B; card B = k - 1⟧ ⟹ inj_on f (A - B)› 2. ‹⟦inj_on f (A - B); infinite A; 0 < k; B ⊆ A; finite B; card B = k - 1⟧ ⟹ infinite (A - B)› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . ultimately show "?thesis" (*goal: ‹infinite {X. X ⊆ A ∧ finite X ∧ card X = k}›*) by (rule infinite_super (*‹⟦?S ⊆ ?T; infinite ?S⟧ ⟹ infinite ?T›*)) qed lemma comp_bij_eq_iff: assumes "bij f" shows "g ∘ f = h ∘ f ⟷ g = h" proof (standard) (*goals: 1. ‹(g::'b ⇒ 'c) ∘ (f::'a ⇒ 'b) = (h::'b ⇒ 'c) ∘ f ⟹ g = h› 2. ‹(g::'b ⇒ 'c) = (h::'b ⇒ 'c) ⟹ g ∘ (f::'a ⇒ 'b) = h ∘ f›*) assume "*": "g ∘ f = h ∘ f" (*‹(g::'b ⇒ 'c) ∘ (f::'a ⇒ 'b) = (h::'b ⇒ 'c) ∘ f›*) show "g = h" proof (standard) (*goal: ‹⋀x. g x = h x›*) fix x obtain y where [simp]: "x = f y" (*goal: ‹(⋀y. x = f y ⟹ thesis) ⟹ thesis›*) using bij_is_surj[OF assms] (*‹surj f›*) by auto have "(g ∘ f) y = (h ∘ f) y" by (simp only: * (*‹(g::'b::type ⇒ 'c::type) ∘ (f::'a::type ⇒ 'b::type) = (h::'b::type ⇒ 'c::type) ∘ f›*)) thus "g x = h x" by simp qed qed (auto) (*solved the remaining goal: ‹g = h ⟹ g ∘ f = h ∘ f›*) lemma sum_list_replicate [simp]: "sum_list (replicate n x) = of_nat n * (x :: 'a :: semiring_1)" apply (induction n) (*goals: 1. ‹sum_list (replicate 0 x) = of_nat 0 * x› 2. ‹⋀n. sum_list (replicate n x) = of_nat n * x ⟹ sum_list (replicate (Suc n) x) = of_nat (Suc n) * x› 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]) (*proven 2 subgoals*) . lemma ex_subset_of_card: assumes "finite A" "card A ≥ k" shows "∃B. B ⊆ A ∧ card B = k" using assms (*‹finite A› ‹k ≤ card A›*) proof (induction arbitrary: k rule: finite_induct) (*goals: 1. ‹⋀k::nat. k ≤ card {} ⟹ ∃B⊆{}. card B = k› 2. ‹⋀(x::'a) (F::'a set) k::nat. ⟦finite F; x ∉ F; ⋀k::nat. k ≤ card F ⟹ ∃B⊆F. card B = k; k ≤ card (insert x F)⟧ ⟹ ∃B⊆insert x F. card B = k›*) case empty (*‹k ≤ card {}›*) thus "?case" (*goal: ‹∃B⊆{}. card B = k›*) by auto next (*goal: ‹⋀x F k. ⟦finite F; x ∉ F; ⋀k. k ≤ card F ⟹ ∃B⊆F. card B = k; k ≤ card (insert x F)⟧ ⟹ ∃B⊆insert x F. card B = k›*) case (insert x A k) (*‹finite A› ‹x ∉ A› ‹?k ≤ card A ⟹ ∃B⊆A. card B = ?k› ‹k ≤ card (insert x A)›*) show "?case" (*goal: ‹∃B⊆insert x A. card B = k›*) proof (cases "k = 0") (*goals: 1. ‹k = 0 ⟹ ∃B⊆insert x A. card B = k› 2. ‹k ≠ 0 ⟹ ∃B⊆insert x A. card B = k›*) case True (*‹k = 0›*) thus "?thesis" (*goal: ‹∃B⊆insert x A. card B = k›*) apply (intro exI[of _ "{}"] (*‹(?P::?'b1 set ⇒ bool) {} ⟹ ∃x::?'b1 set. ?P x›*)) (*goal: ‹∃B⊆insert x A. card B = k›*) by auto next (*goal: ‹(k::nat) ≠ (0::nat) ⟹ ∃B⊆insert (x::'a::type) (A::'a::type set). card B = k›*) case False (*‹k ≠ 0›*) from insert (*‹finite A› ‹x ∉ A› ‹?k ≤ card A ⟹ ∃B⊆A. card B = ?k› ‹k ≤ card (insert x A)›*) have "∃B⊆A. card B = k - 1" apply (intro insert.IH (*‹?k ≤ card A ⟹ ∃B⊆A. card B = ?k›*)) (*goal: ‹∃B⊆A. card B = k - 1›*) by auto then obtain B where B: "B ⊆ A" "card B = k - 1" (*goal: ‹(⋀B. ⟦B ⊆ A; card B = k - 1⟧ ⟹ thesis) ⟹ thesis›*) by auto with insert (*‹finite A› ‹(x::'a) ∉ (A::'a set)› ‹(?k::nat) ≤ card (A::'a set) ⟹ ∃B⊆A. card B = ?k› ‹k ≤ card (insert x A)›*) have [simp]: "x ∉ B" by auto have "insert x B ⊆ insert x A" using B (*‹B ⊆ A› ‹card B = k - 1›*) insert (*‹finite A› ‹x ∉ A› ‹(?k::nat) ≤ card (A::'a::type set) ⟹ ∃B⊆A. card B = ?k› ‹k ≤ card (insert x A)›*) by auto moreover have "card (insert x B) = k" using insert (*‹finite A› ‹x ∉ A› ‹(?k::nat) ≤ card (A::'a set) ⟹ ∃B⊆A. card B = ?k› ‹k ≤ card (insert x A)›*) B (*‹B ⊆ A› ‹card B = k - 1›*) finite_subset[of B A] (*‹⟦B ⊆ A; finite A⟧ ⟹ finite B›*) False (*‹k ≠ 0›*) apply (subst card.insert_remove (*‹finite ?A ⟹ card (insert ?x ?A) = Suc (card (?A - {?x}))›*)) (*goals: 1. ‹⟦finite A; x ∉ A; ⋀k. k ≤ card A ⟹ ∃B⊆A. card B = k; k ≤ card (insert x A); B ⊆ A; card B = k - 1; ⟦B ⊆ A; finite A⟧ ⟹ finite B; k ≠ 0⟧ ⟹ finite B› 2. ‹⟦finite A; x ∉ A; ⋀k. k ≤ card A ⟹ ∃B⊆A. card B = k; k ≤ card (insert x A); B ⊆ A; card B = k - 1; ⟦B ⊆ A; finite A⟧ ⟹ finite B; k ≠ 0⟧ ⟹ Suc (card (B - {x})) = k› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . ultimately show "?thesis" (*goal: ‹∃B⊆insert x A. card B = k›*) by blast qed qed lemma length_sorted_list_of_set [simp]: "length (sorted_list_of_set A) = card A" using distinct_card[of "sorted_list_of_set A"] (*‹distinct (sorted_list_of_set A) ⟹ card (set (sorted_list_of_set A)) = length (sorted_list_of_set A)›*) apply (cases "finite A") (*goals: 1. ‹⟦distinct (sorted_list_of_set A) ⟹ card (set (sorted_list_of_set A)) = length (sorted_list_of_set A); finite A⟧ ⟹ length (sorted_list_of_set A) = card A› 2. ‹⟦distinct (sorted_list_of_set A) ⟹ card (set (sorted_list_of_set A)) = length (sorted_list_of_set A); infinite A⟧ ⟹ length (sorted_list_of_set A) = card A› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) . lemma upt_add_eq_append': "i ≤ j ⟹ j ≤ k ⟹ [i..<k] = [i..<j] @ [j..<k]" using upt_add_eq_append[of i j "k - j"] (*‹i ≤ j ⟹ [i..<j + (k - j)] = [i..<j] @ [j..<j + (k - j)]›*) by simp subsection ‹Subrings and ring homomorphisms› locale ring_closed = fixes A :: "'a :: comm_ring_1 set" assumes zero_closed [simp]: "0 ∈ A" assumes one_closed [simp]: "1 ∈ A" assumes add_closed [simp]: "x ∈ A ⟹ y ∈ A ⟹ (x + y) ∈ A" assumes mult_closed [simp]: "x ∈ A ⟹ y ∈ A ⟹ (x * y) ∈ A" assumes uminus_closed [simp]: "x ∈ A ⟹ -x ∈ A" begin lemma minus_closed [simp]: "x ∈ A ⟹ y ∈ A ⟹ x - y ∈ A" using add_closed[of x "-y"] (*‹⟦x ∈ A; - y ∈ A⟧ ⟹ x + - y ∈ A›*) uminus_closed[of y] (*‹y ∈ A ⟹ - y ∈ A›*) by auto lemma sum_closed [intro]: "(⋀x. x ∈ X ⟹ f x ∈ A) ⟹ sum f X ∈ A" apply (induction X 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. ‹⋀Aa. ⟦infinite Aa; ⋀x. x ∈ Aa ⟹ f x ∈ A⟧ ⟹ sum f Aa ∈ A› 2. ‹(⋀x. x ∈ {} ⟹ f x ∈ A) ⟹ sum f {} ∈ A› 3. ‹⋀x F. ⟦finite F; x ∉ F; (⋀x. x ∈ F ⟹ f x ∈ A) ⟹ sum f F ∈ A; ⋀xa. xa ∈ insert x F ⟹ f xa ∈ A⟧ ⟹ sum f (insert x F) ∈ A› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*proven 3 subgoals*) . lemma power_closed [intro]: "x ∈ A ⟹ x ^ n ∈ A" apply (induction n) (*goals: 1. ‹(x::'a) ∈ (A::'a set) ⟹ x ^ (0::nat) ∈ A› 2. ‹⋀n::nat. ⟦(x::'a) ∈ (A::'a set) ⟹ x ^ n ∈ A; x ∈ A⟧ ⟹ x ^ Suc n ∈ A› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . lemma Sum_any_closed [intro]: "(⋀x. f x ∈ A) ⟹ Sum_any f ∈ A" unfolding Sum_any.expand_set (*goal: ‹(⋀x. f x ∈ A) ⟹ sum f {a. f a ≠ 0} ∈ A›*) by (rule sum_closed (*‹(⋀x::?'b. x ∈ (?X::?'b set) ⟹ (?f::?'b ⇒ 'a) x ∈ (A::'a set)) ⟹ sum ?f ?X ∈ A›*)) lemma prod_closed [intro]: "(⋀x. x ∈ X ⟹ f x ∈ A) ⟹ prod f X ∈ A" apply (induction X 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. ‹⋀Aa. ⟦infinite Aa; ⋀x. x ∈ Aa ⟹ f x ∈ A⟧ ⟹ prod f Aa ∈ A› 2. ‹(⋀x. x ∈ {} ⟹ f x ∈ A) ⟹ prod f {} ∈ A› 3. ‹⋀x F. ⟦finite F; x ∉ F; (⋀x. x ∈ F ⟹ f x ∈ A) ⟹ prod f F ∈ A; ⋀xa. xa ∈ insert x F ⟹ f xa ∈ A⟧ ⟹ prod f (insert x F) ∈ A› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*proven 3 subgoals*) . lemma Prod_any_closed [intro]: "(⋀x. f x ∈ A) ⟹ Prod_any f ∈ A" unfolding Prod_any.expand_set (*goal: ‹(⋀x. f x ∈ A) ⟹ prod f {a. f a ≠ 1} ∈ A›*) by (rule prod_closed (*‹(⋀x. x ∈ ?X ⟹ ?f x ∈ A) ⟹ prod ?f ?X ∈ A›*)) lemma prod_fun_closed [intro]: "(⋀x. f x ∈ A) ⟹ (⋀x. g x ∈ A) ⟹ prod_fun f g x ∈ A" by (auto simp: prod_fun_def (*‹prod_fun ?f1.0 ?f2.0 ?k = (∑l. ?f1.0 l * (∑q. ?f2.0 q when ?k = l + q))›*) when_def (*‹(?a when ?P) = (if ?P then ?a else 0)›*) intro!: Sum_any_closed (*‹(⋀x. ?f x ∈ A) ⟹ Sum_any ?f ∈ A›*) mult_closed (*‹⟦?x ∈ A; ?y ∈ A⟧ ⟹ ?x * ?y ∈ A›*)) lemma of_nat_closed [simp, intro]: "of_nat n ∈ A" sorry lemma of_int_closed [simp, intro]: "of_int n ∈ A" apply (induction n) (*goals: 1. ‹⋀n. of_int (int n) ∈ A› 2. ‹⋀n. of_int (- int (Suc n)) ∈ A› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . end locale ring_homomorphism = fixes f :: "'a :: comm_ring_1 ⇒ 'b :: comm_ring_1" assumes add[simp]: "f (x + y) = f x + f y" assumes uminus[simp]: "f (-x) = -f x" assumes mult[simp]: "f (x * y) = f x * f y" assumes zero[simp]: "f 0 = 0" assumes one [simp]: "f 1 = 1" begin lemma diff [simp]: "f (x - y) = f x - f y" using add[of x "-y"] (*‹f (x + - y) = f x + f (- y)›*) by (simp del: add (*‹f (?x + ?y) = f ?x + f ?y›*)) lemma power [simp]: "f (x ^ n) = f x ^ n" apply (induction n) (*goals: 1. ‹f (x ^ 0) = f x ^ 0› 2. ‹⋀n. f (x ^ n) = f x ^ n ⟹ f (x ^ Suc n) = f x ^ Suc n› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . lemma sum [simp]: "f (sum g A) = (∑x∈A. f (g x))" apply (induction 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::'c set. infinite A ⟹ (f::'a ⇒ 'b) (sum (g::'c ⇒ 'a) A) = (∑x::'c∈A. f (g x))› 2. ‹(f::'a ⇒ 'b) (sum (g::'c ⇒ 'a) {}) = (∑x::'c∈{}. f (g x))› 3. ‹⋀(x::'c) F::'c set. ⟦finite F; x ∉ F; (f::'a ⇒ 'b) (sum (g::'c ⇒ 'a) F) = (∑x::'c∈F. f (g x))⟧ ⟹ f (sum g (insert x F)) = (∑x::'c∈insert x F. f (g x))› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*proven 3 subgoals*) . lemma prod [simp]: "f (prod g A) = (∏x∈A. f (g x))" apply (induction 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::'c set. infinite A ⟹ (f::'a ⇒ 'b) (prod (g::'c ⇒ 'a) A) = (∏x::'c∈A. f (g x))› 2. ‹(f::'a ⇒ 'b) (prod (g::'c ⇒ 'a) {}) = (∏x::'c∈{}. f (g x))› 3. ‹⋀(x::'c) F::'c set. ⟦finite F; x ∉ F; (f::'a ⇒ 'b) (prod (g::'c ⇒ 'a) F) = (∏x::'c∈F. f (g x))⟧ ⟹ f (prod g (insert x F)) = (∏x::'c∈insert x F. f (g x))› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*proven 3 subgoals*) . end lemma ring_homomorphism_id [intro]: "ring_homomorphism id" apply standard (*goals: 1. ‹⋀x y. id (x + y) = id x + id y› 2. ‹⋀x. id (- x) = - id x› 3. ‹⋀x y. id (x * y) = id x * id y› 4. ‹id 0 = 0› 5. ‹id 1 = 1› 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 ring_homomorphism_id' [intro]: "ring_homomorphism (λx. x)" apply standard (*goals: 1. ‹⋀x y. x + y = x + y› 2. ‹⋀x. - x = - x› 3. ‹⋀x y. x * y = x * y› 4. ‹0 = 0› 5. ‹1 = 1› 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 ring_homomorphism_of_int [intro]: "ring_homomorphism of_int" apply standard (*goals: 1. ‹⋀x y. of_int (x + y) = of_int x + of_int y› 2. ‹⋀x. of_int (- x) = - of_int x› 3. ‹⋀x y. of_int (x * y) = of_int x * of_int y› 4. ‹of_int 0 = 0› 5. ‹of_int 1 = 1› 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*) . subsection ‹Various facts about multivariate polynomials› lemma poly_mapping_nat_ge_0 [simp]: "(m :: nat ⇒₀ nat) ≥ 0" proof (cases "m = 0") (*goals: 1. ‹m = 0 ⟹ 0 ≤ m› 2. ‹m ≠ 0 ⟹ 0 ≤ m›*) case False (*‹m ≠ 0›*) hence "Poly_Mapping.lookup m ≠ Poly_Mapping.lookup 0" apply transfer (*goal: ‹lookup m ≠ lookup 0›*) by auto hence "∃k. Poly_Mapping.lookup m k ≠ 0" by (auto simp: fun_eq_iff (*‹(?f = ?g) = (∀x. ?f x = ?g x)›*)) from LeastI_ex[OF this] (*‹lookup m (LEAST k. lookup m k ≠ 0) ≠ 0›*) Least_le[of "λk. Poly_Mapping.lookup m k ≠ 0"] (*‹lookup m ?k ≠ 0 ⟹ (LEAST x. lookup m x ≠ 0) ≤ ?k›*) show "?thesis" (*goal: ‹0 ≤ m›*) by (force simp: less_eq_poly_mapping_def (*‹(≤) ≡ map_fun lookup (map_fun lookup id) (λf g. less_fun f g ∨ f = g)›*) less_fun_def (*‹less_fun ?f ?g = (∃k. ?f k < ?g k ∧ (∀k'<k. ?f k' = ?g k'))›*)) qed (auto) (*solved the remaining goal: ‹m = 0 ⟹ 0 ≤ m›*) lemma poly_mapping_nat_le_0 [simp]: "(m :: nat ⇒₀ nat) ≤ 0 ⟷ m = 0" unfolding less_eq_poly_mapping_def poly_mapping_eq_iff less_fun_def (*goal: ‹map_fun lookup (map_fun lookup id) (λf g. (∃k. f k < g k ∧ (∀k'<k. f k' = g k')) ∨ f = g) m 0 = (lookup m = lookup 0)›*) by auto lemma of_nat_diff_poly_mapping_nat: assumes "m ≥ n" shows "of_nat (m - n) = (of_nat m - of_nat n :: 'a :: monoid_add ⇒₀ nat)" by (auto intro!: poly_mapping_eqI (*‹(⋀k. lookup ?f k = lookup ?g k) ⟹ ?f = ?g›*) simp: lookup_of_nat (*‹lookup (of_nat ?n) ?k = (of_nat ?n when ?k = 0)›*) lookup_minus (*‹lookup (?f - ?g) ?k = lookup ?f ?k - lookup ?g ?k›*) when_def (*‹(?a when ?P) = (if ?P then ?a else 0)›*)) lemma mpoly_coeff_transfer [transfer_rule]: "rel_fun cr_mpoly (=) poly_mapping.lookup MPoly_Type.coeff" unfolding MPoly_Type.coeff_def (*goal: ‹rel_fun cr_mpoly (=) lookup (λp. lookup (mapping_of p))›*) by transfer_prover lemma mapping_of_sum: "(∑x∈A. mapping_of (f x)) = mapping_of (sum f A)" apply (induction A 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 ⟹ (∑x∈A. mapping_of (f x)) = mapping_of (sum f A)› 2. ‹(∑x∈{}. mapping_of (f x)) = mapping_of (sum f {})› 3. ‹⋀x F. ⟦finite F; x ∉ F; (∑x∈F. mapping_of (f x)) = mapping_of (sum f F)⟧ ⟹ (∑x∈insert x F. mapping_of (f x)) = mapping_of (sum f (insert x F))› discuss goal 1*) apply ((auto simp: plus_mpoly.rep_eq (*‹mapping_of (?x + ?xa) = mapping_of ?x + mapping_of ?xa›*) zero_mpoly.rep_eq (*‹mapping_of 0 = 0›*))[1]) (*discuss goal 2*) apply ((auto simp: plus_mpoly.rep_eq (*‹mapping_of (?x + ?xa) = mapping_of ?x + mapping_of ?xa›*) zero_mpoly.rep_eq (*‹mapping_of 0 = 0›*))[1]) (*discuss goal 3*) apply ((auto simp: plus_mpoly.rep_eq (*‹mapping_of (?x + ?xa) = mapping_of ?x + mapping_of ?xa›*) zero_mpoly.rep_eq (*‹mapping_of 0 = 0›*))[1]) (*proven 3 subgoals*) . lemma mapping_of_eq_0_iff [simp]: "mapping_of p = 0 ⟷ p = 0" apply transfer (*goal: ‹(mapping_of p = 0) = (p = 0)›*) apply auto (*top goal: ‹⋀p::(nat ⇒₀ nat) ⇒₀ 'a. (?ab12::((nat ⇒₀ nat) ⇒₀ 'a) ⇒ ((nat ⇒₀ nat) ⇒ 'a) ⇒ bool) p (λk::nat ⇒₀ nat. 0::'a) = (p = (0::(nat ⇒₀ nat) ⇒₀ 'a))› and 1 goal remains*) by (msorry) lemma Sum_any_mapping_of: "Sum_any (λx. mapping_of (f x)) = mapping_of (Sum_any f)" by (simp add: Sum_any.expand_set (*‹Sum_any ?g = sum ?g {a. ?g a ≠ 0}›*) mapping_of_sum (*‹(∑x∈?A. mapping_of (?f x)) = mapping_of (sum ?f ?A)›*)) lemma Sum_any_parametric_cr_mpoly [transfer_rule]: "(rel_fun (rel_fun (=) cr_mpoly) cr_mpoly) Sum_any Sum_any" by (auto simp: rel_fun_def (*‹rel_fun ?A ?B = (λf g. ∀x y. ?A x y ⟶ ?B (f x) (g y))›*) cr_mpoly_def (*‹cr_mpoly ≡ λx y. x = mapping_of y›*) Sum_any_mapping_of (*‹(∑x. mapping_of (?f x)) = mapping_of (Sum_any ?f)›*)) lemma lookup_mult_of_nat [simp]: "lookup (of_nat n * m) k = n * lookup m k" proof (-) (*goal: ‹lookup (of_nat n * m) k = n * lookup m k›*) have "of_nat n * m = (∑i<n. m)" by simp also (*calculation: ‹of_nat (n::nat) * (m::'a ⇒₀ nat) = (∑i::nat<n. m)›*) have "lookup … k = (∑i<n. lookup m k)" by (simp only: lookup_sum (*‹lookup (sum (?pp::?'c ⇒ ?'b ⇒₀ ?'a) (?X::?'c set)) (?i::?'b) = (∑x::?'c∈?X. lookup (?pp x) ?i)›*)) also (*calculation: ‹lookup (of_nat n * m) k = (∑i<n. lookup m k)›*) have "… = n * lookup m k" by simp finally (*calculation: ‹lookup (of_nat n * m) k = n * lookup m k›*) show "?thesis" (*goal: ‹lookup (of_nat (n::nat) * (m::'a ⇒₀ nat)) (k::'a) = n * lookup m k›*) . qed lemma mpoly_eqI: assumes "⋀mon. MPoly_Type.coeff p mon = MPoly_Type.coeff q mon" shows "p = q" using assms (*‹MPoly_Type.coeff (p::'a mpoly) (?mon::nat ⇒₀ nat) = MPoly_Type.coeff (q::'a mpoly) ?mon›*) apply transfer (*goal: ‹(p::'a mpoly) = (q::'a mpoly)›*) apply transfer (*goal: ‹⋀p q. (⋀mon. lookup p mon = lookup q mon) ⟹ p = q›*) by (auto simp: fun_eq_iff (*‹(?f = ?g) = (∀x. ?f x = ?g x)›*)) lemma coeff_mpoly_times: "MPoly_Type.coeff (p * q) mon = prod_fun (MPoly_Type.coeff p) (MPoly_Type.coeff q) mon" apply transfer' (*goal: ‹MPoly_Type.coeff ((p::'a mpoly) * (q::'a mpoly)) (mon::nat ⇒₀ nat) = prod_fun (MPoly_Type.coeff p) (MPoly_Type.coeff q) mon›*) apply transfer' (*goal: ‹⋀p q mon. lookup (p * q) mon = prod_fun (lookup p) (lookup q) mon›*) by auto lemma (in ring_closed) coeff_mult_closed [intro]: "(⋀x. coeff p x ∈ A) ⟹ (⋀x. coeff q x ∈ A) ⟹ coeff (p * q) x ∈ A" by (auto simp: coeff_mpoly_times (*‹MPoly_Type.coeff ((?p::?'a::semiring_0 mpoly) * (?q::?'a::semiring_0 mpoly)) (?mon::nat ⇒₀ nat) = prod_fun (MPoly_Type.coeff ?p) (MPoly_Type.coeff ?q) ?mon›*) prod_fun_closed (*‹⟦⋀x::?'b::monoid_add. (?f::?'b::monoid_add ⇒ 'a::comm_ring_1) x ∈ (A::'a::comm_ring_1 set); ⋀x::?'b::monoid_add. (?g::?'b::monoid_add ⇒ 'a::comm_ring_1) x ∈ A⟧ ⟹ prod_fun ?f ?g (?x::?'b::monoid_add) ∈ A›*)) lemma coeff_notin_vars: assumes "¬(keys m ⊆ vars p)" shows "coeff p m = 0" using assms (*‹¬ keys m ⊆ vars p›*) unfolding vars_def (*goal: ‹MPoly_Type.coeff p m = 0›*) apply transfer' (*goal: ‹MPoly_Type.coeff (p::'a::zero mpoly) (m::nat ⇒₀ nat) = (0::'a::zero)›*) by (auto simp: in_keys_iff (*‹(?x ∈ keys ?s) = (lookup ?s ?x ≠ 0)›*)) lemma finite_coeff_support [intro]: "finite {m. coeff p m ≠ 0}" apply transfer (*goal: ‹finite {m::nat ⇒₀ nat. MPoly_Type.coeff (p::'a mpoly) m ≠ (0::'a)}›*) by simp lemma insertion_altdef: "insertion f p = Sum_any (λm. coeff p m * Prod_any (λi. f i ^ lookup m i))" apply transfer' (*goal: ‹insertion f p = (∑m. MPoly_Type.coeff p m * (∏i. f i ^ lookup m i))›*) apply transfer' (*goal: ‹⋀f p. insertion_aux f p = (∑m. lookup p m * (∏i. f i ^ lookup m i))›*) by (simp add: insertion_fun_def (*‹insertion_fun ?f ?p = (∑m. ?p m * (∏v. ?f v ^ lookup m v))›*)) lemma mpoly_coeff_uminus [simp]: "coeff (-p) m = -coeff p m" apply transfer (*goal: ‹MPoly_Type.coeff (- p) m = - MPoly_Type.coeff p m›*) by auto lemma Sum_any_uminus: "Sum_any (λx. -f x :: 'a :: ab_group_add) = -Sum_any f" by (simp add: Sum_any.expand_set (*‹Sum_any ?g = sum ?g {a. ?g a ≠ 0}›*) sum_negf (*‹(∑x∈?A. - ?f x) = - sum ?f ?A›*)) lemma insertion_uminus [simp]: "insertion f (-p :: 'a :: comm_ring_1 mpoly) = -insertion f p" by (simp add: insertion_altdef (*‹insertion ?f ?p = (∑m. MPoly_Type.coeff ?p m * (∏i. ?f i ^ lookup m i))›*) Sum_any_uminus (*‹(∑x. - ?f x) = - Sum_any ?f›*)) lemma Sum_any_lookup: "finite {x. g x ≠ 0} ⟹ Sum_any (λx. lookup (g x) y) = lookup (Sum_any g) y" by (auto simp: Sum_any.expand_set (*‹Sum_any ?g = sum ?g {a. ?g a ≠ 0}›*) lookup_sum (*‹lookup (sum ?pp ?X) ?i = (∑x∈?X. lookup (?pp x) ?i)›*) intro!: sum.mono_neutral_left (*‹⟦finite ?T; ?S ⊆ ?T; ∀i∈?T - ?S. ?g i = 0⟧ ⟹ sum ?g ?S = sum ?g ?T›*)) lemma Sum_any_diff: assumes "finite {x. f x ≠ 0}" assumes "finite {x. g x ≠ 0}" shows "Sum_any (λx. f x - g x :: 'a :: ab_group_add) = Sum_any f - Sum_any g" proof (-) (*goal: ‹(∑x. f x - g x) = Sum_any f - Sum_any g›*) have "{x. f x - g x ≠ 0} ⊆ {x. f x ≠ 0} ∪ {x. g x ≠ 0}" by auto moreover have "finite ({x. f x ≠ 0} ∪ {x. g x ≠ 0})" apply (subst finite_Un (*‹finite (?F ∪ ?G) = (finite ?F ∧ finite ?G)›*)) (*goal: ‹finite ({x. f x ≠ 0} ∪ {x. g x ≠ 0})›*) apply (insert assms (*‹finite {x. f x ≠ 0}› ‹finite {x. g x ≠ 0}›*)) (*goal: ‹finite {x::'b. (f::'b ⇒ 'a) x ≠ (0::'a)} ∧ finite {x::'b. (g::'b ⇒ 'a) x ≠ (0::'a)}›*) by auto ultimately have "finite {x. f x - g x ≠ 0}" by (rule finite_subset (*‹⟦?A ⊆ ?B; finite ?B⟧ ⟹ finite ?A›*)) with assms (*‹finite {x. f x ≠ 0}› ‹finite {x. g x ≠ 0}›*) show "?thesis" (*goal: ‹(∑x. f x - g x) = Sum_any f - Sum_any g›*) 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*) Sum_any.distrib [symmetric] (*‹⟦finite {a. ?g a ≠ 0}; finite {a. ?h a ≠ 0}⟧ ⟹ Sum_any ?g + Sum_any ?h = (∑a. ?g a + ?h a)›*)) qed lemma insertion_diff: "insertion f (p - q :: 'a :: comm_ring_1 mpoly) = insertion f p - insertion f q" apply transfer (*goal: ‹insertion f (p - q) = insertion f p - insertion f q›*) proof (transfer) (*goal: ‹⋀f p q. ⟦finite {x. p x ≠ 0}; finite {x. q x ≠ 0}⟧ ⟹ insertion_fun f (λk. p k - q k) = insertion_fun f p - insertion_fun f q›*) fix f :: "nat ⇒ 'a" and p :: "(nat ⇒₀ nat) ⇒ 'a" and q :: "(nat ⇒₀ nat) ⇒ 'a" assume fin: "finite {x. p x ≠ 0}" "finite {x. q x ≠ 0}" (*‹finite {x::nat ⇒₀ nat. (p::(nat ⇒₀ nat) ⇒ 'a) x ≠ (0::'a)}› ‹finite {x::nat ⇒₀ nat. (q::(nat ⇒₀ nat) ⇒ 'a) x ≠ (0::'a)}›*) have "insertion_fun f (λx. p x - q x) = (∑m. p m * (∏v. f v ^ lookup m v) - q m * (∏v. f v ^ lookup m v))" by (simp add: insertion_fun_def (*‹insertion_fun ?f ?p = (∑m. ?p m * (∏v. ?f v ^ lookup m v))›*) 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*) Sum_any_diff (*‹⟦finite {x. ?f x ≠ 0}; finite {x. ?g x ≠ 0}⟧ ⟹ (∑x. ?f x - ?g x) = Sum_any ?f - Sum_any ?g›*)) also (*calculation: ‹insertion_fun (f::nat ⇒ 'a) (λx::nat ⇒₀ nat. (p::(nat ⇒₀ nat) ⇒ 'a) x - (q::(nat ⇒₀ nat) ⇒ 'a) x) = (∑m::nat ⇒₀ nat. p m * (∏v::nat. f v ^ lookup m v) - q m * (∏v::nat. f v ^ lookup m v))›*) have "… = (∑m. p m * (∏v. f v ^ lookup m v)) - (∑m. q m * (∏v. f v ^ lookup m v))" apply (subst Sum_any_diff (*‹⟦finite {x. ?f x ≠ 0}; finite {x. ?g x ≠ 0}⟧ ⟹ (∑x. ?f x - ?g x) = Sum_any ?f - Sum_any ?g›*)) (*goals: 1. ‹finite {x. p x * (∏v. f v ^ lookup x v) ≠ 0}› 2. ‹finite {x. q x * (∏v. f v ^ lookup x v) ≠ 0}› 3. ‹(∑m. p m * (∏v. f v ^ lookup m v)) - (∑m. q m * (∏v. f v ^ lookup m v)) = (∑m. p m * (∏v. f v ^ lookup m v)) - (∑m. q m * (∏v. f v ^ lookup m v))› discuss goal 1*) apply ((auto intro: finite_subset[OF _ fin(1)] (*‹?A ⊆ {x. p x ≠ 0} ⟹ finite ?A›*) finite_subset[OF _ fin(2)] (*‹?A ⊆ {x. q x ≠ 0} ⟹ finite ?A›*))[1]) (*discuss goal 2*) apply ((auto intro: finite_subset[OF _ fin(1)] (*‹(?A::(nat ⇒₀ nat) set) ⊆ {x::nat ⇒₀ nat. (p::(nat ⇒₀ nat) ⇒ 'a) x ≠ (0::'a)} ⟹ finite ?A›*) finite_subset[OF _ fin(2)] (*‹(?A::(nat ⇒₀ nat) set) ⊆ {x::nat ⇒₀ nat. (q::(nat ⇒₀ nat) ⇒ 'a) x ≠ (0::'a)} ⟹ finite ?A›*))[1]) (*discuss goal 3*) apply ((auto intro: finite_subset[OF _ fin(1)] (*‹?A ⊆ {x. p x ≠ 0} ⟹ finite ?A›*) finite_subset[OF _ fin(2)] (*‹?A ⊆ {x. q x ≠ 0} ⟹ finite ?A›*))[1]) (*proven 3 subgoals*) . also (*calculation: ‹insertion_fun f (λx. p x - q x) = (∑m. p m * (∏v. f v ^ lookup m v)) - (∑m. q m * (∏v. f v ^ lookup m v))›*) have "… = insertion_fun f p - insertion_fun f q" by (simp add: insertion_fun_def (*‹insertion_fun ?f ?p = (∑m. ?p m * (∏v. ?f v ^ lookup m v))›*)) finally (*calculation: ‹insertion_fun f (λx. p x - q x) = insertion_fun f p - insertion_fun f q›*) show "insertion_fun f (λx. p x - q x) = …" . qed lemma insertion_power: "insertion f (p ^ n) = insertion f p ^ n" apply (induction n) (*goals: 1. ‹insertion (f::nat ⇒ 'a) ((p::'a mpoly) ^ (0::nat)) = insertion f p ^ (0::nat)› 2. ‹⋀n::nat. insertion (f::nat ⇒ 'a) ((p::'a mpoly) ^ n) = insertion f p ^ n ⟹ insertion f (p ^ Suc n) = insertion f p ^ Suc n› discuss goal 1*) apply (simp add: insertion_mult (*‹insertion ?f (?p * ?q) = insertion ?f ?p * insertion ?f ?q›*)) (*discuss goal 2*) apply (simp add: insertion_mult (*‹insertion ?f (?p * ?q) = insertion ?f ?p * insertion ?f ?q›*)) (*proven 2 subgoals*) . lemma insertion_sum: "insertion f (sum g A) = (∑x∈A. insertion f (g x))" apply (induction 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::'b set. infinite A ⟹ insertion (f::nat ⇒ 'a) (sum (g::'b ⇒ 'a mpoly) A) = (∑x::'b∈A. insertion f (g x))› 2. ‹insertion (f::nat ⇒ 'a) (sum (g::'b ⇒ 'a mpoly) {}) = (∑x::'b∈{}. insertion f (g x))› 3. ‹⋀(x::'b) F::'b set. ⟦finite F; x ∉ F; insertion (f::nat ⇒ 'a) (sum (g::'b ⇒ 'a mpoly) F) = (∑x::'b∈F. insertion f (g x))⟧ ⟹ insertion f (sum g (insert x F)) = (∑x::'b∈insert x F. insertion f (g x))› discuss goal 1*) apply ((auto simp: insertion_add (*‹insertion ?f (?p + ?q) = insertion ?f ?p + insertion ?f ?q›*))[1]) (*discuss goal 2*) apply ((auto simp: insertion_add (*‹insertion ?f (?p + ?q) = insertion ?f ?p + insertion ?f ?q›*))[1]) (*discuss goal 3*) apply ((auto simp: insertion_add (*‹insertion ?f (?p + ?q) = insertion ?f ?p + insertion ?f ?q›*))[1]) (*proven 3 subgoals*) . lemma insertion_prod: "insertion f (prod g A) = (∏x∈A. insertion f (g x))" apply (induction A rule: infinite_finite_induct (*‹⟦⋀A::?'a::type set. infinite A ⟹ (?P::?'a::type set ⇒ bool) A; ?P {}; ⋀(x::?'a::type) F::?'a::type set. ⟦finite F; x ∉ F; ?P F⟧ ⟹ ?P (insert x F)⟧ ⟹ ?P (?A::?'a::type set)›*)) (*goals: 1. ‹⋀A. infinite A ⟹ insertion f (prod g A) = (∏x∈A. insertion f (g x))› 2. ‹insertion f (prod g {}) = (∏x∈{}. insertion f (g x))› 3. ‹⋀x F. ⟦finite F; x ∉ F; insertion f (prod g F) = (∏x∈F. insertion f (g x))⟧ ⟹ insertion f (prod g (insert x F)) = (∏x∈insert x F. insertion f (g x))› discuss goal 1*) apply ((auto simp: insertion_mult (*‹insertion (?f::nat ⇒ ?'a) ((?p::?'a mpoly) * (?q::?'a mpoly)) = insertion ?f ?p * insertion ?f ?q›*))[1]) (*discuss goal 2*) apply ((auto simp: insertion_mult (*‹insertion ?f (?p * ?q) = insertion ?f ?p * insertion ?f ?q›*))[1]) (*discuss goal 3*) apply ((auto simp: insertion_mult (*‹insertion ?f (?p * ?q) = insertion ?f ?p * insertion ?f ?q›*))[1]) (*proven 3 subgoals*) . lemma coeff_Var: "coeff (Var i) m = (1 when m = Poly_Mapping.single i 1)" apply transfer' (*goal: ‹MPoly_Type.coeff (Var i) m = (1 when m = Poly_Mapping.single i 1)›*) by (auto simp: Var₀_def (*‹Var₀ ?n ≡ Poly_Mapping.single (Poly_Mapping.single ?n 1) 1›*) lookup_single (*‹lookup (Poly_Mapping.single ?k ?v) ?k' = (?v when ?k = ?k')›*) when_def (*‹(?a when ?P) = (if ?P then ?a else 0)›*)) lemma vars_Var: "vars (Var i :: 'a :: {one,zero} mpoly) = (if (0::'a) = 1 then {} else {i})" unfolding vars_def (*goal: ‹⋃ (keys ` keys (mapping_of (Var i))) = (if 0 = 1 then {} else {i})›*) by (auto simp: Var.rep_eq (*‹mapping_of (Var (?x::nat)) = Var₀ ?x›*) Var₀_def (*‹Var₀ (?n::?'a) ≡ Poly_Mapping.single (Poly_Mapping.single ?n (1::nat)) (1::?'b)›*)) lemma insertion_Var [simp]: "insertion f (Var i) = f i" proof (-) (*goal: ‹insertion (f::nat ⇒ 'a) (Var (i::nat)) = f i›*) have "insertion f (Var i) = (∑m. (1 when m = Poly_Mapping.single i 1) * (∏i. f i ^ lookup m i))" by (simp add: insertion_altdef (*‹insertion (?f::nat ⇒ ?'a) (?p::?'a mpoly) = (∑m::nat ⇒₀ nat. MPoly_Type.coeff ?p m * (∏i::nat. ?f i ^ lookup m i))›*) coeff_Var (*‹MPoly_Type.coeff (Var (?i::nat)) (?m::nat ⇒₀ nat) = ((1::?'a) when ?m = Poly_Mapping.single ?i (1::nat))›*)) also (*calculation: ‹insertion f (Var i) = (∑m. (1 when m = Poly_Mapping.single i 1) * (∏i. f i ^ lookup m i))›*) have "… = (∏j. f j ^ lookup (Poly_Mapping.single i 1) j)" apply (subst Sum_any.expand_superset[of "{Poly_Mapping.single i 1}"] (*‹⟦finite {Poly_Mapping.single i 1}; {a. ?g a ≠ 0} ⊆ {Poly_Mapping.single i 1}⟧ ⟹ Sum_any ?g = sum ?g {Poly_Mapping.single i 1}›*)) (*goals: 1. ‹finite {Poly_Mapping.single i 1}› 2. ‹{a. (1 when a = Poly_Mapping.single i 1) * (∏i. f i ^ lookup a i) ≠ 0} ⊆ {Poly_Mapping.single i 1}› 3. ‹(∑m∈{Poly_Mapping.single i 1}. (1 when m = Poly_Mapping.single i 1) * (∏i. f i ^ lookup m i)) = (∏j. f j ^ lookup (Poly_Mapping.single i 1) j)› discuss goal 1*) apply ((auto simp: when_def (*‹(?a when ?P) = (if ?P then ?a else 0)›*))[1]) (*discuss goal 2*) apply ((auto simp: when_def (*‹(?a when ?P) = (if ?P then ?a else 0)›*))[1]) (*discuss goal 3*) apply ((auto simp: when_def (*‹((?a::?'a) when (?P::bool)) = (if ?P then ?a else (0::?'a))›*))[1]) (*proven 3 subgoals*) . also (*calculation: ‹insertion f (Var i) = (∏j. f j ^ lookup (Poly_Mapping.single i 1) j)›*) have "… = f i" apply (subst Prod_any.expand_superset[of "{i}"] (*‹⟦finite {i}; {a. ?g a ≠ 1} ⊆ {i}⟧ ⟹ Prod_any ?g = prod ?g {i}›*)) (*goals: 1. ‹finite {i}› 2. ‹{a. f a ^ lookup (Poly_Mapping.single i 1) a ≠ 1} ⊆ {i}› 3. ‹(∏j∈{i}. f j ^ lookup (Poly_Mapping.single i 1) j) = f i› discuss goal 1*) apply ((auto simp: when_def (*‹(?a when ?P) = (if ?P then ?a else 0)›*) lookup_single (*‹lookup (Poly_Mapping.single ?k ?v) ?k' = (?v when ?k = ?k')›*))[1]) (*discuss goal 2*) apply ((auto simp: when_def (*‹(?a when ?P) = (if ?P then ?a else 0)›*) lookup_single (*‹lookup (Poly_Mapping.single ?k ?v) ?k' = (?v when ?k = ?k')›*))[1]) (*discuss goal 3*) apply ((auto simp: when_def (*‹(?a when ?P) = (if ?P then ?a else 0)›*) lookup_single (*‹lookup (Poly_Mapping.single ?k ?v) ?k' = (?v when ?k = ?k')›*))[1]) (*proven 3 subgoals*) . finally (*calculation: ‹insertion f (Var i) = f i›*) show "?thesis" (*goal: ‹insertion f (Var i) = f i›*) . qed lemma insertion_Sum_any: assumes "finite {x. g x ≠ 0}" shows "insertion f (Sum_any g) = Sum_any (λx. insertion f (g x))" unfolding Sum_any.expand_set insertion_sum (*goal: ‹(∑x::'a∈{a::'a. g a ≠ (0::'b mpoly)}. insertion (f::nat ⇒ 'b) ((g::'a ⇒ 'b mpoly) x)) = (∑x::'a∈{a::'a. insertion f (g a) ≠ (0::'b)}. insertion f (g x))›*) apply (intro sum.mono_neutral_right (*‹⟦finite ?T; ?S ⊆ ?T; ∀i∈?T - ?S. ?g i = 0⟧ ⟹ sum ?g ?T = sum ?g ?S›*)) (*goals: 1. ‹finite {a. g a ≠ 0}› 2. ‹{a. insertion f (g a) ≠ 0} ⊆ {a. g a ≠ 0}› 3. ‹∀i∈{a. g a ≠ 0} - {a. insertion f (g a) ≠ 0}. insertion f (g i) = 0› discuss goal 1*) apply ((auto intro!: finite_subset[OF _ assms] (*‹(?A::'a set) ⊆ {x::'a. (g::'a ⇒ 'b mpoly) x ≠ (0::'b mpoly)} ⟹ finite ?A›*))[1]) (*discuss goal 2*) apply ((auto intro!: finite_subset[OF _ assms] (*‹?A ⊆ {x. g x ≠ 0} ⟹ finite ?A›*))[1]) (*discuss goal 3*) apply ((auto intro!: finite_subset[OF _ assms] (*‹?A ⊆ {x. g x ≠ 0} ⟹ finite ?A›*))[1]) (*proven 3 subgoals*) . lemma keys_diff_subset: "keys (f - g) ⊆ keys f ∪ keys g" apply transfer (*goal: ‹keys (f - g) ⊆ keys f ∪ keys g›*) by auto lemma keys_empty_iff [simp]: "keys p = {} ⟷ p = 0" apply transfer (*goal: ‹(keys p = {}) = (p = 0)›*) by auto lemma mpoly_coeff_0 [simp]: "MPoly_Type.coeff 0 m = 0" apply transfer (*goal: ‹MPoly_Type.coeff 0 m = 0›*) by auto lemma lookup_1: "lookup 1 m = (if m = 0 then 1 else 0)" apply transfer (*goal: ‹lookup 1 m = (if m = 0 then 1 else 0)›*) by (simp add: when_def (*‹(?a when ?P) = (if ?P then ?a else 0)›*)) lemma mpoly_coeff_1: "MPoly_Type.coeff 1 m = (if m = 0 then 1 else 0)" by (simp add: MPoly_Type.coeff_def (*‹MPoly_Type.coeff ?p = lookup (mapping_of ?p)›*) one_mpoly.rep_eq (*‹mapping_of 1 = 1›*) lookup_1 (*‹lookup 1 ?m = (if ?m = 0 then 1 else 0)›*)) lemma lookup_Const₀: "lookup (Const₀ c) m = (if m = 0 then c else 0)" unfolding "Const₀_def" (*goal: ‹lookup (Poly_Mapping.single 0 c) m = (if m = 0 then c else 0)›*) by (simp add: lookup_single (*‹lookup (Poly_Mapping.single ?k ?v) ?k' = (?v when ?k = ?k')›*) when_def (*‹(?a when ?P) = (if ?P then ?a else 0)›*)) lemma mpoly_coeff_Const: "MPoly_Type.coeff (Const c) m = (if m = 0 then c else 0)" by (simp add: MPoly_Type.coeff_def (*‹MPoly_Type.coeff (?p::?'a mpoly) = lookup (mapping_of ?p)›*) Const.rep_eq (*‹mapping_of (Const (?x::?'b)) = Const₀ ?x›*) lookup_Const₀ (*‹lookup (Const₀ (?c::?'a)) (?m::?'b ⇒₀ nat) = (if ?m = (0::?'b ⇒₀ nat) then ?c else (0::?'a))›*)) lemma coeff_smult [simp]: "coeff (smult c p) m = (c :: 'a :: mult_zero) * coeff p m" apply transfer (*goal: ‹MPoly_Type.coeff (MPoly_Type.smult c p) m = c * MPoly_Type.coeff p m›*) by (auto simp: map_lookup (*‹?g 0 = 0 ⟹ lookup (Poly_Mapping.map ?g ?f) ?x = ?g (lookup ?f ?x)›*)) lemma in_keys_mapI: "x ∈ keys m ⟹ f (lookup m x) ≠ 0 ⟹ x ∈ keys (Poly_Mapping.map f m)" apply transfer (*goal: ‹⟦x ∈ keys m; f (lookup m x) ≠ 0⟧ ⟹ x ∈ keys (Poly_Mapping.map f m)›*) by auto lemma keys_uminus [simp]: "keys (-m) = keys m" sorry lemma vars_uminus [simp]: "vars (-p) = vars p" unfolding vars_def (*goal: ‹⋃ (keys ` keys (mapping_of (- (p::'a mpoly)))) = ⋃ (keys ` keys (mapping_of p))›*) apply transfer' (*goal: ‹⋃ (keys ` keys (mapping_of (- p))) = ⋃ (keys ` keys (mapping_of p))›*) by auto lemma vars_smult: "vars (smult c p) ⊆ vars p" unfolding vars_def (*goal: ‹⋃ (keys ` keys (mapping_of (MPoly_Type.smult c p))) ⊆ ⋃ (keys ` keys (mapping_of p))›*) apply transfer' (*goal: ‹⋃ (keys ` keys (mapping_of (MPoly_Type.smult c p))) ⊆ ⋃ (keys ` keys (mapping_of p))›*) apply transfer' (*goal: ‹⋀c p. ⋃ (keys ` keys (Poly_Mapping.map ((*) c) p)) ⊆ ⋃ (keys ` keys p)›*) by auto lemma vars_0 [simp]: "vars 0 = {}" unfolding vars_def (*goal: ‹⋃ (keys ` keys (mapping_of 0)) = {}›*) apply transfer' (*goal: ‹⋃ (keys ` keys (mapping_of 0)) = {}›*) by simp lemma vars_1 [simp]: "vars 1 = {}" sorry lemma vars_sum: "vars (sum f A) ⊆ (⋃x∈A. vars (f x))" using vars_add (*‹vars (?p1.0 + ?p2.0) ⊆ vars ?p1.0 ∪ vars ?p2.0›*) apply (induction 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::'b::type set. ⟦infinite A; ⋀(p1::?'a::monoid_add mpoly) p2::?'a::monoid_add mpoly. vars (p1 + p2) ⊆ vars p1 ∪ vars p2⟧ ⟹ vars (sum (f::'b::type ⇒ 'a::comm_monoid_add mpoly) A) ⊆ (⋃x::'b::type∈A. vars (f x))› 2. ‹(⋀(p1::?'a::monoid_add mpoly) p2::?'a::monoid_add mpoly. vars (p1 + p2) ⊆ vars p1 ∪ vars p2) ⟹ vars (sum (f::'b::type ⇒ 'a::comm_monoid_add mpoly) {}) ⊆ (⋃x::'b::type∈{}. vars (f x))› 3. ‹⋀(x::'b::type) F::'b::type set. ⟦finite F; x ∉ F; (⋀(p1::?'a::monoid_add mpoly) p2::?'a::monoid_add mpoly. vars (p1 + p2) ⊆ vars p1 ∪ vars p2) ⟹ vars (sum (f::'b::type ⇒ 'a::comm_monoid_add mpoly) F) ⊆ (⋃x::'b::type∈F. vars (f x)); ⋀(p1::?'a::monoid_add mpoly) p2::?'a::monoid_add mpoly. vars (p1 + p2) ⊆ vars p1 ∪ vars p2⟧ ⟹ vars (sum f (insert x F)) ⊆ (⋃x::'b::type∈insert x F. vars (f x))› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*proven 3 subgoals*) . lemma vars_prod: "vars (prod f A) ⊆ (⋃x∈A. vars (f x))" using vars_mult (*‹vars (?p * ?q) ⊆ vars ?p ∪ vars ?q›*) apply (induction 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::'b set. ⟦infinite A; ⋀(p::?'a mpoly) q::?'a mpoly. vars (p * q) ⊆ vars p ∪ vars q⟧ ⟹ vars (prod (f::'b ⇒ 'a mpoly) A) ⊆ (⋃x::'b∈A. vars (f x))› 2. ‹(⋀(p::?'a mpoly) q::?'a mpoly. vars (p * q) ⊆ vars p ∪ vars q) ⟹ vars (prod (f::'b ⇒ 'a mpoly) {}) ⊆ (⋃x::'b∈{}. vars (f x))› 3. ‹⋀(x::'b) F::'b set. ⟦finite F; x ∉ F; (⋀(p::?'a mpoly) q::?'a mpoly. vars (p * q) ⊆ vars p ∪ vars q) ⟹ vars (prod (f::'b ⇒ 'a mpoly) F) ⊆ (⋃x::'b∈F. vars (f x)); ⋀(p::?'a mpoly) q::?'a mpoly. vars (p * q) ⊆ vars p ∪ vars q⟧ ⟹ vars (prod f (insert x F)) ⊆ (⋃x::'b∈insert x F. vars (f x))› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*proven 3 subgoals*) . lemma vars_Sum_any: "vars (Sum_any h) ⊆ (⋃i. vars (h i))" unfolding Sum_any.expand_set (*goal: ‹vars (sum h {a. h a ≠ 0}) ⊆ (⋃i. vars (h i))›*) apply (intro order.trans[OF vars_sum] (*‹(⋃x∈?A1. vars (?f1 x)) ⊆ ?c ⟹ vars (sum ?f1 ?A1) ⊆ ?c›*)) (*goal: ‹vars (sum h {a. h a ≠ 0}) ⊆ (⋃i. vars (h i))›*) by auto lemma vars_Prod_any: "vars (Prod_any h) ⊆ (⋃i. vars (h i))" unfolding Prod_any.expand_set (*goal: ‹vars (prod h {a. h a ≠ 1}) ⊆ (⋃i. vars (h i))›*) apply (intro order.trans[OF vars_prod] (*‹(⋃x∈?A1. vars (?f1 x)) ⊆ ?c ⟹ vars (prod ?f1 ?A1) ⊆ ?c›*)) (*goal: ‹vars (prod h {a. h a ≠ 1}) ⊆ (⋃i. vars (h i))›*) by auto lemma vars_power: "vars (p ^ n) ⊆ vars p" using vars_mult (*‹vars (?p * ?q) ⊆ vars ?p ∪ vars ?q›*) apply (induction n) (*goals: 1. ‹(⋀p q. vars (p * q) ⊆ vars p ∪ vars q) ⟹ vars (p ^ 0) ⊆ vars p› 2. ‹⋀n. ⟦(⋀p q. vars (p * q) ⊆ vars p ∪ vars q) ⟹ vars (p ^ n) ⊆ vars p; ⋀p q. vars (p * q) ⊆ vars p ∪ vars q⟧ ⟹ vars (p ^ Suc n) ⊆ vars p› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . lemma vars_diff: "vars (p1 - p2) ⊆ vars p1 ∪ vars p2" unfolding vars_def (*goal: ‹⋃ (keys ` keys (mapping_of (p1 - p2))) ⊆ ⋃ (keys ` keys (mapping_of p1)) ∪ ⋃ (keys ` keys (mapping_of p2))›*) proof (transfer') (*goal: ‹⋀p1 p2. ⋃ (keys ` keys (p1 - p2)) ⊆ ⋃ (keys ` keys p1) ∪ ⋃ (keys ` keys p2)›*) fix p1 :: "(nat ⇒₀ nat) ⇒₀ 'a" and p2 :: "(nat ⇒₀ nat) ⇒₀ 'a" show "⋃ (keys ` keys (p1 - p2)) ⊆ ⋃(keys ` (keys p1)) ∪ ⋃(keys ` (keys p2))" using keys_diff_subset[of p1 p2] (*‹keys (p1 - p2) ⊆ keys p1 ∪ keys p2›*) by (auto simp flip: not_in_keys_iff_lookup_eq_zero (*‹(?k ∉ keys ?f) = (lookup ?f ?k = 0)›*)) qed lemma insertion_smult [simp]: "insertion f (smult c p) = c * insertion f p" unfolding insertion_altdef (*goal: ‹(∑m. MPoly_Type.coeff (MPoly_Type.smult c p) m * (∏i. f i ^ lookup m i)) = c * (∑m. MPoly_Type.coeff p m * (∏i. f i ^ lookup m i))›*) apply (subst Sum_any_right_distrib (*‹finite {a. ?g a ≠ 0} ⟹ ?r * Sum_any ?g = (∑n. ?r * ?g n)›*)) (*goals: 1. ‹finite {a. MPoly_Type.coeff p a * (∏i. f i ^ lookup a i) ≠ 0}› 2. ‹(∑m. MPoly_Type.coeff (MPoly_Type.smult c p) m * (∏i. f i ^ lookup m i)) = (∑n. c * (MPoly_Type.coeff p n * (∏i. f i ^ lookup n i)))› discuss goal 1*) apply ((auto intro: finite_subset[OF _ finite_coeff_support[of p]] (*‹?A ⊆ {m. MPoly_Type.coeff p m ≠ 0} ⟹ finite ?A›*) simp: mult.assoc (*‹?a * ?b * ?c = ?a * (?b * ?c)›*))[1]) (*discuss goal 2*) apply ((auto intro: finite_subset[OF _ finite_coeff_support[of p]] (*‹?A ⊆ {m. MPoly_Type.coeff p m ≠ 0} ⟹ finite ?A›*) simp: mult.assoc (*‹?a * ?b * ?c = ?a * (?b * ?c)›*))[1]) (*proven 2 subgoals*) . lemma coeff_add [simp]: "coeff (p + q) m = coeff p m + coeff q m" apply transfer' (*goal: ‹MPoly_Type.coeff ((p::'a mpoly) + (q::'a mpoly)) (m::nat ⇒₀ nat) = MPoly_Type.coeff p m + MPoly_Type.coeff q m›*) by (simp add: lookup_add (*‹lookup (?f + ?g) ?k = lookup ?f ?k + lookup ?g ?k›*)) lemma coeff_diff [simp]: "coeff (p - q) m = coeff p m - coeff q m" apply transfer' (*goal: ‹MPoly_Type.coeff (p - q) m = MPoly_Type.coeff p m - MPoly_Type.coeff q m›*) by (simp add: lookup_minus (*‹lookup (?f - ?g) ?k = lookup ?f ?k - lookup ?g ?k›*)) lemma insertion_monom [simp]: "insertion f (monom m c) = c * Prod_any (λx. f x ^ lookup m x)" proof (-) (*goal: ‹insertion f (MPoly_Type.monom m c) = c * (∏x. f x ^ lookup m x)›*) have "insertion f (monom m c) = (∑m'. (c when m = m') * (∏v. f v ^ lookup m' v))" by (simp add: insertion_def (*‹insertion ≡ map_fun id (map_fun mapping_of id) insertion_aux›*) insertion_aux_def (*‹insertion_aux ≡ map_fun id (map_fun lookup id) insertion_fun›*) insertion_fun_def (*‹insertion_fun ?f ?p = (∑m. ?p m * (∏v. ?f v ^ lookup m v))›*) lookup_single (*‹lookup (Poly_Mapping.single ?k ?v) ?k' = (?v when ?k = ?k')›*)) also (*calculation: ‹insertion f (MPoly_Type.monom m c) = (∑m'. (c when m = m') * (∏v. f v ^ lookup m' v))›*) have "… = c * (∏v. f v ^ lookup m v)" apply (subst Sum_any.expand_superset[of "{m}"] (*‹⟦finite {m}; {a. ?g a ≠ 0} ⊆ {m}⟧ ⟹ Sum_any ?g = sum ?g {m}›*)) (*goals: 1. ‹finite {m}› 2. ‹{a. (c when m = a) * (∏v. f v ^ lookup a v) ≠ 0} ⊆ {m}› 3. ‹(∑m'∈{m}. (c when m = m') * (∏v. f v ^ lookup m' v)) = c * (∏v. f v ^ lookup m v)› discuss goal 1*) apply ((auto simp: when_def (*‹((?a::?'a) when (?P::bool)) = (if ?P then ?a else (0::?'a))›*))[1]) (*discuss goal 2*) apply ((auto simp: when_def (*‹((?a::?'a) when (?P::bool)) = (if ?P then ?a else (0::?'a))›*))[1]) (*discuss goal 3*) apply ((auto simp: when_def (*‹(?a when ?P) = (if ?P then ?a else 0)›*))[1]) (*proven 3 subgoals*) . finally (*calculation: ‹insertion f (MPoly_Type.monom m c) = c * (∏v. f v ^ lookup m v)›*) show "?thesis" (*goal: ‹insertion f (MPoly_Type.monom m c) = c * (∏x. f x ^ lookup m x)›*) . qed lemma insertion_aux_Const₀ [simp]: "insertion_aux f (Const₀ c) = c" proof (-) (*goal: ‹insertion_aux (f::nat ⇒ 'a::comm_semiring_1) (Const₀ (c::'a::comm_semiring_1)) = c›*) have "insertion_aux f (Const₀ c) = (∑m. (c when m = 0) * (∏v. f v ^ lookup m v))" by (simp add: Const₀_def (*‹Const₀ ?c ≡ Poly_Mapping.single 0 ?c›*) insertion_aux_def (*‹insertion_aux ≡ map_fun id (map_fun lookup id) insertion_fun›*) insertion_fun_def (*‹insertion_fun ?f ?p = (∑m. ?p m * (∏v. ?f v ^ lookup m v))›*) lookup_single (*‹lookup (Poly_Mapping.single ?k ?v) ?k' = (?v when ?k = ?k')›*)) also (*calculation: ‹insertion_aux f (Const₀ c) = (∑m. (c when m = 0) * (∏v. f v ^ lookup m v))›*) have "… = (∑m∈{0}. (c when m = 0) * (∏v. f v ^ lookup m v))" apply (intro Sum_any.expand_superset (*‹⟦finite ?A; {a. ?g a ≠ 0} ⊆ ?A⟧ ⟹ Sum_any ?g = sum ?g ?A›*)) (*goals: 1. ‹finite {0}› 2. ‹{a. (c when a = 0) * (∏v. f v ^ lookup a v) ≠ 0} ⊆ {0}› discuss goal 1*) apply ((auto simp: when_def (*‹(?a when ?P) = (if ?P then ?a else 0)›*))[1]) (*discuss goal 2*) apply ((auto simp: when_def (*‹(?a when ?P) = (if ?P then ?a else 0)›*))[1]) (*proven 2 subgoals*) . also (*calculation: ‹insertion_aux f (Const₀ c) = (∑m∈{0}. (c when m = 0) * (∏v. f v ^ lookup m v))›*) have "… = c" by simp finally (*calculation: ‹insertion_aux f (Const₀ c) = c›*) show "?thesis" (*goal: ‹insertion_aux (f::nat ⇒ 'a) (Const₀ (c::'a)) = c›*) . qed lemma insertion_Const [simp]: "insertion f (Const c) = c" by (simp add: insertion_def (*‹insertion ≡ map_fun id (map_fun mapping_of id) insertion_aux›*) Const.rep_eq (*‹mapping_of (Const ?x) = Const₀ ?x›*)) lemma coeffs_0 [simp]: "coeffs 0 = {}" apply transfer (*goal: ‹MPoly_Type.coeffs 0 = {}›*) by auto lemma coeffs_1 [simp]: "coeffs 1 = {1}" apply transfer (*goal: ‹MPoly_Type.coeffs 1 = {1}›*) by auto lemma coeffs_Const: "coeffs (Const c) = (if c = 0 then {} else {c})" unfolding Const_def "Const₀_def" (*goal: ‹MPoly_Type.coeffs (map_fun id MPoly (Poly_Mapping.single 0) c) = (if c = 0 then {} else {c})›*) apply transfer' (*goal: ‹MPoly_Type.coeffs (map_fun id MPoly (Poly_Mapping.single (0::nat ⇒₀ nat)) (c::'a)) = (if c = (0::'a) then {} else {c})›*) by auto lemma coeffs_subset: "coeffs (Const c) ⊆ {c}" by (auto simp: coeffs_Const (*‹MPoly_Type.coeffs (Const ?c) = (if ?c = 0 then {} else {?c})›*)) lemma keys_Const₀: "keys (Const₀ c) = (if c = 0 then {} else {0})" unfolding "Const₀_def" (*goal: ‹keys (Poly_Mapping.single 0 c) = (if c = 0 then {} else {0})›*) apply transfer' (*goal: ‹keys (Poly_Mapping.single 0 c) = (if c = 0 then {} else {0})›*) by auto lemma vars_Const [simp]: "vars (Const c) = {}" unfolding vars_def (*goal: ‹⋃ (keys ` keys (mapping_of (Const c))) = {}›*) apply transfer' (*goal: ‹⋃ (keys ` keys (mapping_of (Const c))) = {}›*) by (auto simp: keys_Const₀ (*‹keys (Const₀ ?c) = (if ?c = 0 then {} else {0})›*)) lemma prod_fun_compose_bij: assumes "bij f" and f: "⋀x y. f (x + y) = f x + f y" shows "prod_fun m1 m2 (f x) = prod_fun (m1 ∘ f) (m2 ∘ f) x" proof (-) (*goal: ‹prod_fun (m1::'b::monoid_add ⇒ 'c::semiring_0) (m2::'b::monoid_add ⇒ 'c::semiring_0) ((f::'a::monoid_add ⇒ 'b::monoid_add) (x::'a::monoid_add)) = prod_fun (m1 ∘ f) (m2 ∘ f) x›*) have [simp]: "f x = f y ⟷ x = y" for x and y using ‹bij f› (*‹bij f›*) by (auto dest!: bij_is_inj (*‹bij (?f::?'a::type ⇒ ?'b::type) ⟹ inj ?f›*) inj_onD (*‹⟦inj_on (?f::?'a::type ⇒ ?'b::type) (?A::?'a::type set); ?f (?x::?'a::type) = ?f (?y::?'a::type); ?x ∈ ?A; ?y ∈ ?A⟧ ⟹ ?x = ?y›*)) have "prod_fun (m1 ∘ f) (m2 ∘ f) x = Sum_any ((λl. m1 l * Sum_any ((λq. m2 q when f x = l + q) ∘ f)) ∘ f)" by (simp add: prod_fun_def (*‹prod_fun (?f1.0::?'a ⇒ ?'b) (?f2.0::?'a ⇒ ?'b) (?k::?'a) = (∑l::?'a. ?f1.0 l * (∑q::?'a. ?f2.0 q when ?k = l + q))›*) f(1) [symmetric] (*‹(f::'a ⇒ 'b) (?x::'a) + f (?y::'a) = f (?x + ?y)›*) o_def (*‹(?f::?'b ⇒ ?'c) ∘ (?g::?'a ⇒ ?'b) = (λx::?'a. ?f (?g x))›*)) also (*calculation: ‹prod_fun ((m1::'b::monoid_add ⇒ 'c::semiring_0) ∘ (f::'a::monoid_add ⇒ 'b::monoid_add)) ((m2::'b::monoid_add ⇒ 'c::semiring_0) ∘ f) (x::'a::monoid_add) = Sum_any ((λl::'b::monoid_add. m1 l * Sum_any ((λq::'b::monoid_add. m2 q when f x = l + q) ∘ f)) ∘ f)›*) have "… = Sum_any ((λl. m1 l * Sum_any ((λq. m2 q when f x = l + q))))" by (simp only: Sum_any.reindex_cong[OF assms(1) refl, symmetric] (*‹Sum_any (?g ∘ f) = Sum_any ?g›*)) also (*calculation: ‹prod_fun (m1 ∘ f) (m2 ∘ f) x = (∑l. m1 l * (∑q. m2 q when f x = l + q))›*) have "… = prod_fun m1 m2 (f x)" by (simp add: prod_fun_def (*‹prod_fun ?f1.0 ?f2.0 ?k = (∑l. ?f1.0 l * (∑q. ?f2.0 q when ?k = l + q))›*)) finally (*calculation: ‹prod_fun (m1 ∘ f) (m2 ∘ f) x = prod_fun m1 m2 (f x)›*) show "?thesis" (*goal: ‹prod_fun m1 m2 (f x) = prod_fun (m1 ∘ f) (m2 ∘ f) x›*) by standard qed lemma add_nat_poly_mapping_zero_iff [simp]: "(a + b :: 'a ⇒₀ nat) = 0 ⟷ a = 0 ∧ b = 0" apply transfer (*goal: ‹(a + b = 0) = (a = 0 ∧ b = 0)›*) by (auto simp: fun_eq_iff (*‹((?f::?'a::type ⇒ ?'b::type) = (?g::?'a::type ⇒ ?'b::type)) = (∀x::?'a::type. ?f x = ?g x)›*)) lemma prod_fun_nat_0: fixes f g :: "('a ⇒₀ nat) ⇒ 'b::semiring_0" shows "prod_fun f g 0 = f 0 * g 0" proof (-) (*goal: ‹prod_fun f g 0 = f 0 * g 0›*) have "prod_fun f g 0 = (∑l. f l * (∑q. g q when 0 = l + q))" unfolding prod_fun_def (*goal: ‹(∑l. f l * (∑q. g q when 0 = l + q)) = (∑l. f l * (∑q. g q when 0 = l + q))›*) by standard also (*calculation: ‹prod_fun f g 0 = (∑l. f l * (∑q. g q when 0 = l + q))›*) have "(λl. ∑q. g q when 0 = l + q) = (λl. ∑q∈{0}. g q when 0 = l + q)" apply (intro ext (*‹(⋀x. ?f x = ?g x) ⟹ ?f = ?g›*) Sum_any.expand_superset (*‹⟦finite ?A; {a. ?g a ≠ 0} ⊆ ?A⟧ ⟹ Sum_any ?g = sum ?g ?A›*)) (*goals: 1. ‹⋀l. finite {0}› 2. ‹⋀l. {a. (g a when 0 = l + a) ≠ 0} ⊆ {0}› discuss goal 1*) apply ((auto simp: when_def (*‹(?a when ?P) = (if ?P then ?a else 0)›*))[1]) (*discuss goal 2*) apply ((auto simp: when_def (*‹(?a when ?P) = (if ?P then ?a else 0)›*))[1]) (*proven 2 subgoals*) . also (*calculation: ‹prod_fun (f::('a ⇒₀ nat) ⇒ 'b) (g::('a ⇒₀ nat) ⇒ 'b) (0::'a ⇒₀ nat) = (∑l::'a ⇒₀ nat. f l * (∑q::'a ⇒₀ nat∈{0::'a ⇒₀ nat}. g q when (0::'a ⇒₀ nat) = l + q))›*) have "(∑l. f l * … l) = (∑l∈{0}. f l * … l)" apply (intro ext (*‹(⋀x. ?f x = ?g x) ⟹ ?f = ?g›*) Sum_any.expand_superset (*‹⟦finite ?A; {a. ?g a ≠ 0} ⊆ ?A⟧ ⟹ Sum_any ?g = sum ?g ?A›*)) (*goals: 1. ‹finite {0::'a ⇒₀ nat}› 2. ‹{a::'a ⇒₀ nat. (f::('a ⇒₀ nat) ⇒ 'b) a * (∑q::'a ⇒₀ nat∈{0::'a ⇒₀ nat}. (g::('a ⇒₀ nat) ⇒ 'b) q when (0::'a ⇒₀ nat) = a + q) ≠ (0::'b)} ⊆ {0::'a ⇒₀ nat}› discuss goal 1*) apply ((auto simp: when_def (*‹(?a when ?P) = (if ?P then ?a else 0)›*))[1]) (*discuss goal 2*) apply ((auto simp: when_def (*‹(?a when ?P) = (if ?P then ?a else 0)›*))[1]) (*proven 2 subgoals*) . finally (*calculation: ‹prod_fun f g 0 = (∑l∈{0}. f l * (∑q∈{0}. g q when 0 = l + q))›*) show "?thesis" (*goal: ‹prod_fun (f::('a ⇒₀ nat) ⇒ 'b) (g::('a ⇒₀ nat) ⇒ 'b) (0::'a ⇒₀ nat) = f (0::'a ⇒₀ nat) * g (0::'a ⇒₀ nat)›*) by simp qed lemma mpoly_coeff_times_0: "coeff (p * q) 0 = coeff p 0 * coeff q 0" by (simp add: coeff_mpoly_times (*‹MPoly_Type.coeff (?p * ?q) ?mon = prod_fun (MPoly_Type.coeff ?p) (MPoly_Type.coeff ?q) ?mon›*) prod_fun_nat_0 (*‹prod_fun ?f ?g 0 = ?f 0 * ?g 0›*)) lemma mpoly_coeff_prod_0: "coeff (∏x∈A. f x) 0 = (∏x∈A. coeff (f x) 0)" apply (induction 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 ⟹ MPoly_Type.coeff (prod f A) 0 = (∏x∈A. MPoly_Type.coeff (f x) 0)› 2. ‹MPoly_Type.coeff (prod f {}) 0 = (∏x∈{}. MPoly_Type.coeff (f x) 0)› 3. ‹⋀x F. ⟦finite F; x ∉ F; MPoly_Type.coeff (prod f F) 0 = (∏x∈F. MPoly_Type.coeff (f x) 0)⟧ ⟹ MPoly_Type.coeff (prod f (insert x F)) 0 = (∏x∈insert x F. MPoly_Type.coeff (f x) 0)› discuss goal 1*) apply ((auto simp: mpoly_coeff_times_0 (*‹MPoly_Type.coeff (?p * ?q) 0 = MPoly_Type.coeff ?p 0 * MPoly_Type.coeff ?q 0›*) mpoly_coeff_1 (*‹MPoly_Type.coeff 1 ?m = (if ?m = 0 then 1 else 0)›*))[1]) (*discuss goal 2*) apply ((auto simp: mpoly_coeff_times_0 (*‹MPoly_Type.coeff (?p * ?q) 0 = MPoly_Type.coeff ?p 0 * MPoly_Type.coeff ?q 0›*) mpoly_coeff_1 (*‹MPoly_Type.coeff 1 ?m = (if ?m = 0 then 1 else 0)›*))[1]) (*discuss goal 3*) apply ((auto simp: mpoly_coeff_times_0 (*‹MPoly_Type.coeff (?p * ?q) 0 = MPoly_Type.coeff ?p 0 * MPoly_Type.coeff ?q 0›*) mpoly_coeff_1 (*‹MPoly_Type.coeff 1 ?m = (if ?m = 0 then 1 else 0)›*))[1]) (*proven 3 subgoals*) . lemma mpoly_coeff_power_0: "coeff (p ^ n) 0 = coeff p 0 ^ n" apply (induction n) (*goals: 1. ‹MPoly_Type.coeff (p ^ 0) 0 = MPoly_Type.coeff p 0 ^ 0› 2. ‹⋀n. MPoly_Type.coeff (p ^ n) 0 = MPoly_Type.coeff p 0 ^ n ⟹ MPoly_Type.coeff (p ^ Suc n) 0 = MPoly_Type.coeff p 0 ^ Suc n› discuss goal 1*) apply ((auto simp: mpoly_coeff_times_0 (*‹MPoly_Type.coeff ((?p::?'a::semiring_0 mpoly) * (?q::?'a::semiring_0 mpoly)) (0::nat ⇒₀ nat) = MPoly_Type.coeff ?p (0::nat ⇒₀ nat) * MPoly_Type.coeff ?q (0::nat ⇒₀ nat)›*) mpoly_coeff_1 (*‹MPoly_Type.coeff (1::?'a::zero_neq_one mpoly) (?m::nat ⇒₀ nat) = (if ?m = (0::nat ⇒₀ nat) then 1::?'a::zero_neq_one else (0::?'a::zero_neq_one))›*))[1]) (*discuss goal 2*) apply ((auto simp: mpoly_coeff_times_0 (*‹MPoly_Type.coeff (?p * ?q) 0 = MPoly_Type.coeff ?p 0 * MPoly_Type.coeff ?q 0›*) mpoly_coeff_1 (*‹MPoly_Type.coeff 1 ?m = (if ?m = 0 then 1 else 0)›*))[1]) (*proven 2 subgoals*) . lemma prod_fun_max: fixes f g :: "'a::{linorder, ordered_cancel_comm_monoid_add} ⇒ 'b::semiring_0" assumes zero: "⋀m. m > a ⟹ f m = 0" "⋀m. m > b ⟹ g m = 0" assumes fin: "finite {m. f m ≠ 0}" "finite {m. g m ≠ 0}" shows "prod_fun f g (a + b) = f a * g b" proof (-) (*goal: ‹prod_fun f g (a + b) = f a * g b›*) note fin' = finite_subset[OF _ fin ( 1 )] (*‹?A ⊆ {m. f m ≠ 0} ⟹ finite ?A›*) finite_subset[OF _ fin ( 2 )] (*‹(?A::'a set) ⊆ {m::'a. (g::'a ⇒ 'b) m ≠ (0::'b)} ⟹ finite ?A›*) have "prod_fun f g (a + b) = (∑l. f l * (∑q. g q when a + b = l + q))" by (simp add: prod_fun_def (*‹prod_fun ?f1.0 ?f2.0 ?k = (∑l. ?f1.0 l * (∑q. ?f2.0 q when ?k = l + q))›*) Sum_any_right_distrib (*‹finite {a. ?g a ≠ 0} ⟹ ?r * Sum_any ?g = (∑n. ?r * ?g n)›*)) also (*calculation: ‹prod_fun (f::'a ⇒ 'b) (g::'a ⇒ 'b) ((a::'a) + (b::'a)) = (∑l::'a. f l * (∑q::'a. g q when a + b = l + q))›*) have "… = (∑l. ∑q. f l * g q when a + b = l + q)" apply (subst Sum_any_right_distrib (*‹finite {a. ?g a ≠ 0} ⟹ ?r * Sum_any ?g = (∑n. ?r * ?g n)›*)) (*goals: 1. ‹⋀l. finite {aa. (g aa when a + b = l + aa) ≠ 0}› 2. ‹(∑l. ∑n. f l * (g n when a + b = l + n)) = (∑l. ∑q. f l * g q when a + b = l + q)› discuss goal 1*) apply ((auto intro!: Sum_any.cong (*‹(⋀a. ?g a = ?h a) ⟹ Sum_any ?g = Sum_any ?h›*) fin'( (*‹?A ⊆ {m. g m ≠ 0} ⟹ finite ?A›*) 2) simp: when_def (*‹(?a when ?P) = (if ?P then ?a else 0)›*))[1]) (*discuss goal 2*) apply ((auto intro!: Sum_any.cong (*‹(⋀a::?'b::type. (?g::?'b::type ⇒ ?'a::comm_monoid_add) a = (?h::?'b::type ⇒ ?'a::comm_monoid_add) a) ⟹ Sum_any ?g = Sum_any ?h›*) fin'( (*‹(?A::'a::{ordered_cancel_comm_monoid_add,linorder} set) ⊆ {m::'a::{ordered_cancel_comm_monoid_add,linorder}. (g::'a::{ordered_cancel_comm_monoid_add,linorder} ⇒ 'b::semiring_0) m ≠ (0::'b::semiring_0)} ⟹ finite ?A›*) 2) simp: when_def (*‹((?a::?'a::zero) when (?P::bool)) = (if ?P then ?a else (0::?'a::zero))›*))[1]) (*proven 2 subgoals*) . also (*calculation: ‹prod_fun f g (a + b) = (∑l. ∑q. f l * g q when a + b = l + q)›*) { fix l and q assume lq: "a + b = l + q" "(a, b) ≠ (l, q)" and nz: "f l * g q ≠ 0" (*‹(a::'a) + (b::'a) = (l::'a) + (q::'a)› ‹(a::'a, b::'a) ≠ (l::'a, q::'a)› ‹(f::'a ⇒ 'b) (l::'a) * (g::'a ⇒ 'b) (q::'a) ≠ (0::'b)›*) from nz (*‹f l * g q ≠ 0›*) zero (*‹a < ?m ⟹ f ?m = 0› ‹(b::'a) < (?m::'a) ⟹ (g::'a ⇒ 'b) ?m = (0::'b)›*) have "l ≤ a" "q ≤ b" apply - (*goals: 1. ‹⟦f l * g q ≠ 0; ⋀m. a < m ⟹ f m = 0; ⋀m. b < m ⟹ g m = 0⟧ ⟹ l ≤ a› 2. ‹⟦f l * g q ≠ 0; ⋀m. a < m ⟹ f m = 0; ⋀m. b < m ⟹ g m = 0⟧ ⟹ q ≤ b› discuss goal 1*) apply ((auto intro: leI (*‹¬ ?x < ?y ⟹ ?y ≤ ?x›*))[1]) (*discuss goal 2*) apply ((auto intro: leI (*‹¬ ?x < ?y ⟹ ?y ≤ ?x›*))[1]) (*proven 2 subgoals*) . moreover from this (*‹l ≤ a› ‹q ≤ b›*) lq(2) (*‹(a, b) ≠ (l, q)›*) have "l < a ∨ q < b" by auto ultimately have "l + q < a + b" by (auto intro: add_less_le_mono (*‹⟦?a < ?b; ?c ≤ ?d⟧ ⟹ ?a + ?c < ?b + ?d›*) add_le_less_mono (*‹⟦?a ≤ ?b; ?c < ?d⟧ ⟹ ?a + ?c < ?b + ?d›*)) with lq(1) (*‹a + b = l + q›*) have False by simp } hence "(∑l. ∑q. f l * g q when a + b = l + q) = (∑l. ∑q. f l * g q when (a, b) = (l, q))" apply (intro Sum_any.cong (*‹(⋀a. ?g a = ?h a) ⟹ Sum_any ?g = Sum_any ?h›*) refl (*‹?t = ?t›*)) (*goal: ‹(∑l. ∑q. f l * g q when a + b = l + q) = (∑l. ∑q. f l * g q when (a, b) = (l, q))›*) by (auto simp: when_def (*‹(?a when ?P) = (if ?P then ?a else 0)›*)) also (*calculation: ‹prod_fun (f::'a ⇒ 'b) (g::'a ⇒ 'b) ((a::'a) + (b::'a)) = (∑l::'a. ∑q::'a. f l * g q when (a, b) = (l, q))›*) have "… = (∑(l,q). f l * g q when (a, b) = (l, q))" apply (intro Sum_any.cartesian_product[of "{(a, b)}"] (*‹⟦finite {(a, b)}; {a. ∃b. ?g a b ≠ 0} × {b. ∃a. ?g a b ≠ 0} ⊆ {(a, b)}⟧ ⟹ (∑a. Sum_any (?g a)) = (∑(a, b). ?g a b)›*)) (*goals: 1. ‹finite {(a, b)}› 2. ‹{l. ∃q. (f l * g q when (a, b) = (l, q)) ≠ 0} × {q. ∃l. (f l * g q when (a, b) = (l, q)) ≠ 0} ⊆ {(a, b)}› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . also (*calculation: ‹prod_fun f g (a + b) = (∑(l, q). f l * g q when (a, b) = (l, q))›*) have "… = (∑(l,q)∈{(a,b)}. f l * g q when (a, b) = (l, q))" apply (intro Sum_any.expand_superset (*‹⟦finite ?A; {a. ?g a ≠ 0} ⊆ ?A⟧ ⟹ Sum_any ?g = sum ?g ?A›*)) (*goals: 1. ‹finite {(a, b)}› 2. ‹{aa. (case aa of (l, q) ⇒ f l * g q when (a, b) = (l, q)) ≠ 0} ⊆ {(a, b)}› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . also (*calculation: ‹prod_fun f g (a + b) = (∑(l, q)∈{(a, b)}. f l * g q when (a, b) = (l, q))›*) have "… = f a * g b" by simp finally (*calculation: ‹prod_fun (f::'a ⇒ 'b) (g::'a ⇒ 'b) ((a::'a) + (b::'a)) = f a * g b›*) show "?thesis" (*goal: ‹prod_fun (f::'a ⇒ 'b) (g::'a ⇒ 'b) ((a::'a) + (b::'a)) = f a * g b›*) . qed lemma prod_fun_gt_max_eq_zero: fixes f g :: "'a::{linorder, ordered_cancel_comm_monoid_add} ⇒ 'b::semiring_0" assumes "m > a + b" assumes zero: "⋀m. m > a ⟹ f m = 0" "⋀m. m > b ⟹ g m = 0" assumes fin: "finite {m. f m ≠ 0}" "finite {m. g m ≠ 0}" shows "prod_fun f g m = 0" proof (-) (*goal: ‹prod_fun f g m = 0›*) note fin' = finite_subset[OF _ fin ( 1 )] (*‹?A ⊆ {m. f m ≠ 0} ⟹ finite ?A›*) finite_subset[OF _ fin ( 2 )] (*‹?A ⊆ {m. g m ≠ 0} ⟹ finite ?A›*) have "prod_fun f g m = (∑l. f l * (∑q. g q when m = l + q))" by (simp add: prod_fun_def (*‹prod_fun ?f1.0 ?f2.0 ?k = (∑l. ?f1.0 l * (∑q. ?f2.0 q when ?k = l + q))›*) Sum_any_right_distrib (*‹finite {a. ?g a ≠ 0} ⟹ ?r * Sum_any ?g = (∑n. ?r * ?g n)›*)) also (*calculation: ‹prod_fun f g m = (∑l. f l * (∑q. g q when m = l + q))›*) have "… = (∑l. ∑q. f l * g q when m = l + q)" apply (subst Sum_any_right_distrib (*‹finite {a. ?g a ≠ 0} ⟹ ?r * Sum_any ?g = (∑n. ?r * ?g n)›*)) (*goals: 1. ‹⋀l. finite {a. (g a when m = l + a) ≠ 0}› 2. ‹(∑l. ∑n. f l * (g n when m = l + n)) = (∑l. ∑q. f l * g q when m = l + q)› discuss goal 1*) apply ((auto intro!: Sum_any.cong (*‹(⋀a. ?g a = ?h a) ⟹ Sum_any ?g = Sum_any ?h›*) fin'( (*‹?A ⊆ {m. g m ≠ 0} ⟹ finite ?A›*) 2) simp: when_def (*‹(?a when ?P) = (if ?P then ?a else 0)›*))[1]) (*discuss goal 2*) apply ((auto intro!: Sum_any.cong (*‹(⋀a::?'b::type. (?g::?'b::type ⇒ ?'a::comm_monoid_add) a = (?h::?'b::type ⇒ ?'a::comm_monoid_add) a) ⟹ Sum_any ?g = Sum_any ?h›*) fin'( (*‹(?A::'a::{ordered_cancel_comm_monoid_add,linorder} set) ⊆ {m::'a::{ordered_cancel_comm_monoid_add,linorder}. (g::'a::{ordered_cancel_comm_monoid_add,linorder} ⇒ 'b::semiring_0) m ≠ (0::'b::semiring_0)} ⟹ finite ?A›*) 2) simp: when_def (*‹((?a::?'a::zero) when (?P::bool)) = (if ?P then ?a else (0::?'a::zero))›*))[1]) (*proven 2 subgoals*) . also (*calculation: ‹prod_fun f g m = (∑l. ∑q. f l * g q when m = l + q)›*) { fix l and q assume lq: "m = l + q" and nz: "f l * g q ≠ 0" (*‹(m::'a) = (l::'a) + (q::'a)› ‹(f::'a ⇒ 'b) (l::'a) * (g::'a ⇒ 'b) (q::'a) ≠ (0::'b)›*) from nz (*‹(f::'a ⇒ 'b) (l::'a) * (g::'a ⇒ 'b) (q::'a) ≠ (0::'b)›*) zero (*‹(a::'a) < (?m::'a) ⟹ (f::'a ⇒ 'b) ?m = (0::'b)› ‹b < ?m ⟹ g ?m = 0›*) have "l ≤ a" "q ≤ b" apply - (*goals: 1. ‹⟦(f::'a ⇒ 'b) (l::'a) * (g::'a ⇒ 'b) (q::'a) ≠ (0::'b); ⋀m::'a. (a::'a) < m ⟹ f m = (0::'b); ⋀m::'a. (b::'a) < m ⟹ g m = (0::'b)⟧ ⟹ l ≤ a› 2. ‹⟦(f::'a ⇒ 'b) (l::'a) * (g::'a ⇒ 'b) (q::'a) ≠ (0::'b); ⋀m::'a. (a::'a) < m ⟹ f m = (0::'b); ⋀m::'a. (b::'a) < m ⟹ g m = (0::'b)⟧ ⟹ q ≤ b› discuss goal 1*) apply ((auto intro: leI (*‹¬ ?x < ?y ⟹ ?y ≤ ?x›*))[1]) (*discuss goal 2*) apply ((auto intro: leI (*‹¬ ?x < ?y ⟹ ?y ≤ ?x›*))[1]) (*proven 2 subgoals*) . hence "l + q ≤ a + b" apply (intro add_mono (*‹⟦(?a::?'a) ≤ (?b::?'a); (?c::?'a) ≤ (?d::?'a)⟧ ⟹ ?a + ?c ≤ ?b + ?d›*)) (*goals: 1. ‹⟦l ≤ a; q ≤ b⟧ ⟹ l ≤ a› 2. ‹⟦l ≤ a; q ≤ b⟧ ⟹ q ≤ b› discuss goal 1*) apply ((assumption)[1]) (*discuss goal 2*) . (*proven 2 subgoals*) also (*calculation: ‹l + q ≤ a + b›*) have "… < m" by fact finally (*calculation: ‹(l::'a) + (q::'a) < (m::'a)›*) have "l + q < m" . } hence "(∑l. ∑q. f l * g q when m = l + q) = (∑l. ∑q. f l * g q when False)" apply (intro Sum_any.cong (*‹(⋀a. ?g a = ?h a) ⟹ Sum_any ?g = Sum_any ?h›*) refl (*‹?t = ?t›*)) (*goal: ‹(∑l. ∑q. f l * g q when m = l + q) = (∑l. ∑q. f l * g q when False)›*) by (auto simp: when_def (*‹(?a when ?P) = (if ?P then ?a else 0)›*)) also (*calculation: ‹prod_fun f g m = (∑l. ∑q. f l * g q when False)›*) have "… = 0" by simp finally (*calculation: ‹prod_fun f g m = 0›*) show "?thesis" (*goal: ‹prod_fun (f::'a ⇒ 'b) (g::'a ⇒ 'b) (m::'a) = (0::'b)›*) . qed subsection ‹Restricting a monomial to a subset of variables› lift_definition restrictpm :: "'a set ⇒ ('a ⇒₀ 'b :: zero) ⇒ ('a ⇒₀ 'b)" is "λA f x. if x ∈ A then f x else 0" by (erule finite_subset[rotated]) auto lemma lookup_restrictpm: "lookup (restrictpm A m) x = (if x ∈ A then lookup m x else 0)" apply transfer (*goal: ‹lookup (restrictpm A m) x = (if x ∈ A then lookup m x else 0)›*) by auto lemma lookup_restrictpm_in [simp]: "x ∈ A ⟹ lookup (restrictpm A m) x = lookup m x" and lookup_restrict_pm_not_in [simp]: "x ∉ A ⟹ lookup (restrictpm A m) x = 0" (*goals: 1. ‹x ∈ A ⟹ lookup (restrictpm A m) x = lookup m x› 2. ‹x ∉ A ⟹ lookup (restrictpm A m) x = 0› discuss goal 1*) apply (simp add: lookup_restrictpm (*‹lookup (restrictpm (?A::?'b set) (?m::?'b ⇒₀ ?'a)) (?x::?'b) = (if ?x ∈ ?A then lookup ?m ?x else (0::?'a))›*)) (*discuss goal 2*) apply (simp add: lookup_restrictpm (*‹lookup (restrictpm ?A ?m) ?x = (if ?x ∈ ?A then lookup ?m ?x else 0)›*)) (*proven 2 subgoals*) . lemma keys_restrictpm [simp]: "keys (restrictpm A m) = keys m ∩ A" apply transfer (*goal: ‹keys (restrictpm A m) = keys m ∩ A›*) by auto lemma restrictpm_add: "restrictpm X (m1 + m2) = restrictpm X m1 + restrictpm X m2" apply transfer (*goal: ‹restrictpm X (m1 + m2) = restrictpm X m1 + restrictpm X m2›*) by auto lemma restrictpm_id [simp]: "keys m ⊆ X ⟹ restrictpm X m = m" apply transfer (*goal: ‹keys m ⊆ X ⟹ restrictpm X m = m›*) by (auto simp: fun_eq_iff (*‹(?f = ?g) = (∀x. ?f x = ?g x)›*)) lemma restrictpm_orthogonal [simp]: "keys m ⊆ -X ⟹ restrictpm X m = 0" apply transfer (*goal: ‹keys m ⊆ - X ⟹ restrictpm X m = 0›*) by (auto simp: fun_eq_iff (*‹(?f = ?g) = (∀x. ?f x = ?g x)›*)) lemma restrictpm_add_disjoint: "X ∩ Y = {} ⟹ restrictpm X m + restrictpm Y m = restrictpm (X ∪ Y) m" apply transfer (*goal: ‹(X::'a set) ∩ (Y::'a set) = {} ⟹ restrictpm X (m::'a ⇒₀ 'b) + restrictpm Y m = restrictpm (X ∪ Y) m›*) by (auto simp: fun_eq_iff (*‹(?f = ?g) = (∀x. ?f x = ?g x)›*)) lemma restrictpm_add_complements: "restrictpm X m + restrictpm (-X) m = m" "restrictpm (-X) m + restrictpm X m = m" (*goals: 1. ‹restrictpm X m + restrictpm (- X) m = m› 2. ‹restrictpm (- X) m + restrictpm X m = m› discuss goal 1*) apply (subst restrictpm_add_disjoint (*‹?X ∩ ?Y = {} ⟹ restrictpm ?X ?m + restrictpm ?Y ?m = restrictpm (?X ∪ ?Y) ?m›*)) (*goals: 1. ‹(X::'a::type set) ∩ - X = {}› 2. ‹restrictpm ((X::'a::type set) ∪ - X) (m::'a::type ⇒₀ 'b::monoid_add) = m› discuss goal 1*) apply force (*discuss goal 2*) apply force (*proven 2 subgoals*) (*discuss goal 2*) apply (subst restrictpm_add_disjoint (*‹?X ∩ ?Y = {} ⟹ restrictpm ?X ?m + restrictpm ?Y ?m = restrictpm (?X ∪ ?Y) ?m›*)) (*goals: 1. ‹- X ∩ X = {}› 2. ‹restrictpm (- X ∪ X) m = m› discuss goal 1*) apply force (*discuss goal 2*) apply force (*proven 2 subgoals*) (*proven 2 subgoals*) . subsection ‹Mapping over a polynomial› lift_definition map_mpoly :: "('a :: zero ⇒ 'b :: zero) ⇒ 'a mpoly ⇒ 'b mpoly" is "λ(f :: 'a ⇒ 'b) (p :: (nat ⇒₀ nat) ⇒₀ 'a). Poly_Mapping.map f p" . lift_definition mapm_mpoly :: "((nat ⇒₀ nat) ⇒ 'a :: zero ⇒ 'b :: zero) ⇒ 'a mpoly ⇒ 'b mpoly" is "λ(f :: (nat ⇒₀ nat) ⇒ 'a ⇒ 'b) (p :: (nat ⇒₀ nat) ⇒₀ 'a). Poly_Mapping.mapp f p" . lemma poly_mapping_map_conv_mapp: "Poly_Mapping.map f = Poly_Mapping.mapp (λ_. f)" by (auto simp: Poly_Mapping.mapp_def (*‹Poly_Mapping.mapp ≡ map_fun id (map_fun id Abs_poly_mapping) (λf p k. if k ∈ keys p then f k (lookup p k) else 0)›*) Poly_Mapping.map_def (*‹Poly_Mapping.map ≡ map_fun id (map_fun lookup Abs_poly_mapping) (λg f k. g (f k) when f k ≠ 0)›*) map_fun_def (*‹map_fun ?f ?g ?h = ?g ∘ ?h ∘ ?f›*) o_def (*‹?f ∘ ?g = (λx. ?f (?g x))›*) fun_eq_iff (*‹(?f = ?g) = (∀x. ?f x = ?g x)›*) when_def (*‹(?a when ?P) = (if ?P then ?a else 0)›*) in_keys_iff (*‹(?x ∈ keys ?s) = (lookup ?s ?x ≠ 0)›*) cong: if_cong (*‹⟦?b = ?c; ?c ⟹ ?x = ?u; ¬ ?c ⟹ ?y = ?v⟧ ⟹ (if ?b then ?x else ?y) = (if ?c then ?u else ?v)›*)) lemma map_mpoly_conv_mapm_mpoly: "map_mpoly f = mapm_mpoly (λ_. f)" apply transfer' (*goal: ‹map_mpoly f = mapm_mpoly (λ_. f)›*) by (auto simp: poly_mapping_map_conv_mapp (*‹Poly_Mapping.map ?f = Poly_Mapping.mapp (λ_. ?f)›*)) lemma map_mpoly_comp: "f 0 = 0 ⟹ map_mpoly f (map_mpoly g p) = map_mpoly (f ∘ g) p" apply transfer' (*goal: ‹f 0 = 0 ⟹ map_mpoly f (map_mpoly g p) = map_mpoly (f ∘ g) p›*) apply transfer' (*goal: ‹⋀f g p. f 0 = 0 ⟹ Poly_Mapping.map f (Poly_Mapping.map g p) = Poly_Mapping.map (f ∘ g) p›*) by (auto simp: when_def (*‹((?a::?'a) when (?P::bool)) = (if ?P then ?a else (0::?'a))›*) fun_eq_iff (*‹((?f::?'a ⇒ ?'b) = (?g::?'a ⇒ ?'b)) = (∀x::?'a. ?f x = ?g x)›*)) lemma mapp_mapp: "(⋀x. f x 0 = 0) ⟹ Poly_Mapping.mapp f (Poly_Mapping.mapp g m) = Poly_Mapping.mapp (λx y. f x (g x y)) m" apply transfer' (*goal: ‹(⋀x::'a. (f::'a ⇒ 'c ⇒ 'b) x (0::'c) = (0::'b)) ⟹ Poly_Mapping.mapp f (Poly_Mapping.mapp (g::'a ⇒ 'd ⇒ 'c) (m::'a ⇒₀ 'd)) = Poly_Mapping.mapp (λ(x::'a) y::'d. f x (g x y)) m›*) by (auto simp: fun_eq_iff (*‹((?f::?'a::type ⇒ ?'b::type) = (?g::?'a::type ⇒ ?'b::type)) = (∀x::?'a::type. ?f x = ?g x)›*) lookup_mapp (*‹lookup (Poly_Mapping.mapp (?f::?'b::type ⇒ ?'c::zero ⇒ ?'a::zero) (?p::?'b::type ⇒₀ ?'c::zero)) (?k::?'b::type) = (?f ?k (lookup ?p ?k) when ?k ∈ keys ?p)›*) in_keys_iff (*‹((?x::?'a::type) ∈ keys (?s::?'a::type ⇒₀ ?'b::zero)) = (lookup ?s ?x ≠ (0::?'b::zero))›*)) lemma mapm_mpoly_comp: "(⋀x. f x 0 = 0) ⟹ mapm_mpoly f (mapm_mpoly g p) = mapm_mpoly (λm c. f m (g m c)) p" apply transfer' (*goal: ‹(⋀x. f x 0 = 0) ⟹ mapm_mpoly f (mapm_mpoly g p) = mapm_mpoly (λm c. f m (g m c)) p›*) by (simp add: mapp_mapp (*‹(⋀x. ?f x 0 = 0) ⟹ Poly_Mapping.mapp ?f (Poly_Mapping.mapp ?g ?m) = Poly_Mapping.mapp (λx y. ?f x (?g x y)) ?m›*)) lemma coeff_map_mpoly: "coeff (map_mpoly f p) m = (if coeff p m = 0 then 0 else f (coeff p m))" apply transfer (*goal: ‹MPoly_Type.coeff (map_mpoly f p) m = (if MPoly_Type.coeff p m = 0 then 0 else f (MPoly_Type.coeff p m))›*) apply transfer (*goal: ‹⋀(f::'b ⇒ 'a) (p::(nat ⇒₀ nat) ⇒₀ 'b) m::nat ⇒₀ nat. lookup (Poly_Mapping.map f p) m = (if lookup p m = (0::'b) then 0::'a else f (lookup p m))›*) by auto lemma coeff_map_mpoly' [simp]: "f 0 = 0 ⟹ coeff (map_mpoly f p) m = f (coeff p m)" apply (subst coeff_map_mpoly (*‹MPoly_Type.coeff (map_mpoly ?f ?p) ?m = (if MPoly_Type.coeff ?p ?m = 0 then 0 else ?f (MPoly_Type.coeff ?p ?m))›*)) (*goal: ‹f 0 = 0 ⟹ MPoly_Type.coeff (map_mpoly f p) m = f (MPoly_Type.coeff p m)›*) by auto lemma coeff_mapm_mpoly: "coeff (mapm_mpoly f p) m = (if coeff p m = 0 then 0 else f m (coeff p m))" sorry lemma coeff_mapm_mpoly' [simp]: "(⋀m. f m 0 = 0) ⟹ coeff (mapm_mpoly f p) m = f m (coeff p m)" apply (subst coeff_mapm_mpoly (*‹MPoly_Type.coeff (mapm_mpoly ?f ?p) ?m = (if MPoly_Type.coeff ?p ?m = 0 then 0 else ?f ?m (MPoly_Type.coeff ?p ?m))›*)) (*goal: ‹(⋀m. f m 0 = 0) ⟹ MPoly_Type.coeff (mapm_mpoly f p) m = f m (MPoly_Type.coeff p m)›*) by auto lemma vars_map_mpoly_subset: "vars (map_mpoly f p) ⊆ vars p" unfolding vars_def (*goal: ‹⋃ (keys ` keys (mapping_of (map_mpoly (f::'b ⇒ 'a) (p::'b mpoly)))) ⊆ ⋃ (keys ` keys (mapping_of p))›*) apply transfer' (*goal: ‹⋃ (keys ` keys (mapping_of (map_mpoly f p))) ⊆ ⋃ (keys ` keys (mapping_of p))›*) apply transfer' (*goal: ‹⋀f p. ⋃ (keys ` keys (Poly_Mapping.map f p)) ⊆ ⋃ (keys ` keys p)›*) by (auto simp: map_mpoly.rep_eq (*‹mapping_of (map_mpoly ?x ?xa) = Poly_Mapping.map ?x (mapping_of ?xa)›*)) lemma coeff_sum [simp]: "coeff (sum f A) m = (∑x∈A. coeff (f x) m)" apply (induction 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::'b set. infinite A ⟹ MPoly_Type.coeff (sum (f::'b ⇒ 'a mpoly) A) (m::nat ⇒₀ nat) = (∑x::'b∈A. MPoly_Type.coeff (f x) m)› 2. ‹MPoly_Type.coeff (sum (f::'b ⇒ 'a mpoly) {}) (m::nat ⇒₀ nat) = (∑x::'b∈{}. MPoly_Type.coeff (f x) m)› 3. ‹⋀(x::'b) F::'b set. ⟦finite F; x ∉ F; MPoly_Type.coeff (sum (f::'b ⇒ 'a mpoly) F) (m::nat ⇒₀ nat) = (∑x::'b∈F. MPoly_Type.coeff (f x) m)⟧ ⟹ MPoly_Type.coeff (sum f (insert x F)) m = (∑x::'b∈insert x F. MPoly_Type.coeff (f x) m)› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*proven 3 subgoals*) . lemma coeff_Sum_any: "finite {x. f x ≠ 0} ⟹ coeff (Sum_any f) m = Sum_any (λx. coeff (f x) m)" by (auto simp add: Sum_any.expand_set (*‹Sum_any ?g = sum ?g {a. ?g a ≠ 0}›*) intro!: sum.mono_neutral_right (*‹⟦finite ?T; ?S ⊆ ?T; ∀i∈?T - ?S. ?g i = 0⟧ ⟹ sum ?g ?T = sum ?g ?S›*)) lemma Sum_any_zeroI: "(⋀x. f x = 0) ⟹ Sum_any f = 0" by (auto simp: Sum_any.expand_set (*‹Sum_any (?g::?'b ⇒ ?'a) = sum ?g {a::?'b. ?g a ≠ (0::?'a)}›*)) lemma insertion_Prod_any: "finite {x. g x ≠ 1} ⟹ insertion f (Prod_any g) = Prod_any (λx. insertion f (g x))" by (auto simp: Prod_any.expand_set (*‹Prod_any ?g = prod ?g {a. ?g a ≠ 1}›*) insertion_prod (*‹insertion ?f (prod ?g ?A) = (∏x∈?A. insertion ?f (?g x))›*) intro!: prod.mono_neutral_right (*‹⟦finite ?T; ?S ⊆ ?T; ∀i∈?T - ?S. ?g i = 1⟧ ⟹ prod ?g ?T = prod ?g ?S›*)) lemma insertion_insertion: "insertion g (insertion k p) = insertion (λx. insertion g (k x)) (map_mpoly (insertion g) p)" (is "?lhs = ?rhs") proof (-) (*goal: ‹insertion g (insertion k p) = insertion (λx. insertion g (k x)) (map_mpoly (insertion g) p)›*) have "insertion g (insertion k p) = (∑x. insertion g (coeff p x) * insertion g (∏i. k i ^ lookup x i))" unfolding insertion_altdef[of k p] (*goal: ‹insertion g (∑m. MPoly_Type.coeff p m * (∏i. k i ^ lookup m i)) = (∑x. insertion g (MPoly_Type.coeff p x) * insertion g (∏i. k i ^ lookup x i))›*) apply (subst insertion_Sum_any (*‹finite {x::?'a. (?g::?'a ⇒ ?'b mpoly) x ≠ (0::?'b mpoly)} ⟹ insertion (?f::nat ⇒ ?'b) (Sum_any ?g) = (∑x::?'a. insertion ?f (?g x))›*)) (*goals: 1. ‹finite {x. MPoly_Type.coeff p x * (∏i. k i ^ lookup x i) ≠ 0}› 2. ‹(∑x. insertion g (MPoly_Type.coeff p x * (∏i. k i ^ lookup x i))) = (∑x. insertion g (MPoly_Type.coeff p x) * insertion g (∏i. k i ^ lookup x i))› discuss goal 1*) apply ((auto intro: finite_subset[OF _ finite_coeff_support[of p]] (*‹?A ⊆ {m. MPoly_Type.coeff p m ≠ 0} ⟹ finite ?A›*) simp: insertion_mult (*‹insertion ?f (?p * ?q) = insertion ?f ?p * insertion ?f ?q›*))[1]) (*discuss goal 2*) apply ((auto intro: finite_subset[OF _ finite_coeff_support[of p]] (*‹?A ⊆ {m. MPoly_Type.coeff p m ≠ 0} ⟹ finite ?A›*) simp: insertion_mult (*‹insertion ?f (?p * ?q) = insertion ?f ?p * insertion ?f ?q›*))[1]) (*proven 2 subgoals*) . also (*calculation: ‹insertion g (insertion k p) = (∑x. insertion g (MPoly_Type.coeff p x) * insertion g (∏i. k i ^ lookup x i))›*) have "… = (∑x. insertion g (coeff p x) * (∏i. insertion g (k i) ^ lookup x i))" proof (intro Sum_any.cong (*‹(⋀a. ?g a = ?h a) ⟹ Sum_any ?g = Sum_any ?h›*)) (*goal: ‹⋀a. insertion g (MPoly_Type.coeff p a) * insertion g (∏i. k i ^ lookup a i) = insertion g (MPoly_Type.coeff p a) * (∏i. insertion g (k i) ^ lookup a i)›*) fix x show "insertion g (coeff p x) * insertion g (∏i. k i ^ lookup x i) = insertion g (coeff p x) * (∏i. insertion g (k i) ^ lookup x i)" apply (subst insertion_Prod_any (*‹finite {x. ?g x ≠ 1} ⟹ insertion ?f (Prod_any ?g) = (∏x. insertion ?f (?g x))›*)) (*goals: 1. ‹finite {xa. k xa ^ lookup x xa ≠ 1}› 2. ‹insertion g (MPoly_Type.coeff p x) * (∏xa. insertion g (k xa ^ lookup x xa)) = insertion g (MPoly_Type.coeff p x) * (∏i. insertion g (k i) ^ lookup x i)› discuss goal 1*) apply ((auto simp: insertion_power (*‹insertion ?f (?p ^ ?n) = insertion ?f ?p ^ ?n›*) intro!: finite_subset[OF _ finite_lookup[of x]] (*‹?A ⊆ {k. lookup x k ≠ 0} ⟹ finite ?A›*) Nat.gr0I (*‹(?n = 0 ⟹ False) ⟹ 0 < ?n›*))[1]) (*discuss goal 2*) apply ((auto simp: insertion_power (*‹insertion ?f (?p ^ ?n) = insertion ?f ?p ^ ?n›*) intro!: finite_subset[OF _ finite_lookup[of x]] (*‹?A ⊆ {k. lookup x k ≠ 0} ⟹ finite ?A›*) Nat.gr0I (*‹(?n = 0 ⟹ False) ⟹ 0 < ?n›*))[1]) (*proven 2 subgoals*) . qed also (*calculation: ‹insertion g (insertion k p) = (∑x. insertion g (MPoly_Type.coeff p x) * (∏i. insertion g (k i) ^ lookup x i))›*) have "… = insertion (λx. insertion g (k x)) (map_mpoly (insertion g) p)" unfolding insertion_altdef[of _ "map_mpoly f p" for f] (*goal: ‹(∑x. insertion g (MPoly_Type.coeff p x) * (∏i. insertion g (k i) ^ lookup x i)) = (∑m. MPoly_Type.coeff (map_mpoly (insertion g) p) m * (∏i. insertion g (k i) ^ lookup m i))›*) by auto finally (*calculation: ‹insertion (g::nat ⇒ 'a::comm_semiring_1) (insertion (k::nat ⇒ 'a::comm_semiring_1 mpoly) (p::'a::comm_semiring_1 mpoly mpoly)) = insertion (λx::nat. insertion g (k x)) (map_mpoly (insertion g) p)›*) show "?thesis" (*goal: ‹insertion g (insertion k p) = insertion (λx. insertion g (k x)) (map_mpoly (insertion g) p)›*) . qed lemma insertion_substitute_linear: "insertion (λi. c i * f i) p = insertion f (mapm_mpoly (λm d. Prod_any (λi. c i ^ lookup m i) * d) p)" unfolding insertion_altdef (*goal: ‹(∑m. MPoly_Type.coeff p m * (∏i. (c i * f i) ^ lookup m i)) = (∑m. MPoly_Type.coeff (mapm_mpoly (λm. (*) (∏i. c i ^ lookup m i)) p) m * (∏i. f i ^ lookup m i))›*) apply (intro Sum_any.cong (*‹(⋀a. ?g a = ?h a) ⟹ Sum_any ?g = Sum_any ?h›*)) (*goal: ‹(∑m. MPoly_Type.coeff p m * (∏i. (c i * f i) ^ lookup m i)) = (∑m. MPoly_Type.coeff (mapm_mpoly (λm. (*) (∏i. c i ^ lookup m i)) p) m * (∏i. f i ^ lookup m i))›*) proof (goal_cases) (*goal: ‹⋀a::nat ⇒₀ nat. MPoly_Type.coeff (p::'a mpoly) a * (∏i::nat. ((c::nat ⇒ 'a) i * (f::nat ⇒ 'a) i) ^ lookup a i) = MPoly_Type.coeff (mapm_mpoly (λm::nat ⇒₀ nat. (*) (∏i::nat. c i ^ lookup m i)) p) a * (∏i::nat. f i ^ lookup a i)›*) case (1 m) (*no hyothesis introduced yet*) have "coeff (mapm_mpoly (λm. (*) (∏i. c i ^ lookup m i)) p) m * (∏i. f i ^ lookup m i) = MPoly_Type.coeff p m * ((∏i. c i ^ lookup m i) * (∏i. f i ^ lookup m i))" by (simp add: mult_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)›*)) also (*calculation: ‹MPoly_Type.coeff (mapm_mpoly (λm::nat ⇒₀ nat. (*) (∏i::nat. (c::nat ⇒ 'a) i ^ lookup m i)) (p::'a mpoly)) (m::nat ⇒₀ nat) * (∏i::nat. (f::nat ⇒ 'a) i ^ lookup m i) = MPoly_Type.coeff p m * ((∏i::nat. c i ^ lookup m i) * (∏i::nat. f i ^ lookup m i))›*) have "(∏i. c i ^ lookup m i) * (∏i. f i ^ lookup m i) = (∏i. (c i * f i) ^ lookup m i)" apply (subst Prod_any.distrib [symmetric] (*‹⟦finite {a. ?g a ≠ 1}; finite {a. ?h a ≠ 1}⟧ ⟹ Prod_any ?g * Prod_any ?h = (∏a. ?g a * ?h a)›*)) (*goals: 1. ‹finite {a::nat. (c::nat ⇒ 'a) a ^ lookup (m::nat ⇒₀ nat) a ≠ (1::'a)}› 2. ‹finite {a::nat. (f::nat ⇒ 'a) a ^ lookup (m::nat ⇒₀ nat) a ≠ (1::'a)}› 3. ‹(∏a::nat. (c::nat ⇒ 'a) a ^ lookup (m::nat ⇒₀ nat) a * (f::nat ⇒ 'a) a ^ lookup m a) = (∏i::nat. (c i * f i) ^ lookup m i)› discuss goal 1*) apply ((auto simp: power_mult_distrib (*‹(?a * ?b) ^ ?n = ?a ^ ?n * ?b ^ ?n›*) intro!: finite_subset[OF _ finite_lookup[of m]] (*‹?A ⊆ {k. lookup m k ≠ 0} ⟹ finite ?A›*) Nat.gr0I (*‹(?n = 0 ⟹ False) ⟹ 0 < ?n›*))[1]) (*discuss goal 2*) apply ((auto simp: power_mult_distrib (*‹(?a * ?b) ^ ?n = ?a ^ ?n * ?b ^ ?n›*) intro!: finite_subset[OF _ finite_lookup[of m]] (*‹?A ⊆ {k. lookup m k ≠ 0} ⟹ finite ?A›*) Nat.gr0I (*‹(?n = 0 ⟹ False) ⟹ 0 < ?n›*))[1]) (*discuss goal 3*) apply ((auto simp: power_mult_distrib (*‹(?a * ?b) ^ ?n = ?a ^ ?n * ?b ^ ?n›*) intro!: finite_subset[OF _ finite_lookup[of m]] (*‹?A ⊆ {k. lookup m k ≠ 0} ⟹ finite ?A›*) Nat.gr0I (*‹(?n = 0 ⟹ False) ⟹ 0 < ?n›*))[1]) (*proven 3 subgoals*) . finally (*calculation: ‹MPoly_Type.coeff (mapm_mpoly (λm. (*) (∏i. c i ^ lookup m i)) p) m * (∏i. f i ^ lookup m i) = MPoly_Type.coeff p m * (∏i. (c i * f i) ^ lookup m i)›*) show "?case" (*goal: ‹MPoly_Type.coeff p m * (∏i. (c i * f i) ^ lookup m i) = MPoly_Type.coeff (mapm_mpoly (λm. (*) (∏i. c i ^ lookup m i)) p) m * (∏i. f i ^ lookup m i)›*) by simp qed lemma vars_mapm_mpoly_subset: "vars (mapm_mpoly f p) ⊆ vars p" unfolding vars_def (*goal: ‹⋃ (keys ` keys (mapping_of (mapm_mpoly (f::(nat ⇒₀ nat) ⇒ 'b::zero ⇒ 'a::zero) (p::'b::zero mpoly)))) ⊆ ⋃ (keys ` keys (mapping_of p))›*) using keys_mapp_subset[of f] (*‹keys (Poly_Mapping.mapp (f::(nat ⇒₀ nat) ⇒ 'b ⇒ 'a) (?p::(nat ⇒₀ nat) ⇒₀ 'b)) ⊆ keys ?p›*) by (auto simp: mapm_mpoly.rep_eq (*‹mapping_of (mapm_mpoly ?x ?xa) = Poly_Mapping.mapp ?x (mapping_of ?xa)›*)) lemma map_mpoly_cong: assumes "⋀m. f (coeff p m) = g (coeff p m)" "p = q" shows "map_mpoly f p = map_mpoly g q" using assms (*‹f (MPoly_Type.coeff p ?m) = g (MPoly_Type.coeff p ?m)› ‹p = q›*) apply (intro mpoly_eqI (*‹(⋀mon. MPoly_Type.coeff ?p mon = MPoly_Type.coeff ?q mon) ⟹ ?p = ?q›*)) (*goal: ‹map_mpoly (f::'b ⇒ 'a) (p::'b mpoly) = map_mpoly (g::'b ⇒ 'a) (q::'b mpoly)›*) by (auto simp: coeff_map_mpoly (*‹MPoly_Type.coeff (map_mpoly ?f ?p) ?m = (if MPoly_Type.coeff ?p ?m = 0 then 0 else ?f (MPoly_Type.coeff ?p ?m))›*)) subsection ‹The leading monomial and leading coefficient› text ‹ The leading monomial of a multivariate polynomial is the one with the largest monomial w.\,r.\,t.\ the monomial ordering induced by the standard variable ordering. The leading coefficient is the coefficient of the leading monomial. As a convention, the leading monomial of the zero polynomial is defined to be the same as that of any non-constant zero polynomial, i.\,e.\ the monomial $X_1^0 \ldots X_n^0$. › lift_definition lead_monom :: "'a :: zero mpoly ⇒ (nat ⇒₀ nat)" is "λf :: (nat ⇒₀ nat) ⇒₀ 'a. Max (insert 0 (keys f))" . lemma lead_monom_geI [intro]: assumes "coeff p m ≠ 0" shows "m ≤ lead_monom p" using assms (*‹MPoly_Type.coeff p m ≠ 0›*) by (auto simp: lead_monom_def (*‹lead_monom ≡ map_fun mapping_of id (λf. Max (insert 0 (keys f)))›*) coeff_def (*‹MPoly_Type.coeff ?p = lookup (mapping_of ?p)›*) in_keys_iff (*‹(?x ∈ keys ?s) = (lookup ?s ?x ≠ 0)›*)) lemma coeff_gt_lead_monom_zero [simp]: assumes "m > lead_monom p" shows "coeff p m = 0" using lead_monom_geI[of p m] (*‹MPoly_Type.coeff p m ≠ 0 ⟹ m ≤ lead_monom p›*) assms (*‹lead_monom p < m›*) by force lemma lead_monom_nonzero_eq: assumes "p ≠ 0" shows "lead_monom p = Max (keys (mapping_of p))" using assms (*‹p ≠ 0›*) apply transfer (*goal: ‹lead_monom p = Max (keys (mapping_of p))›*) by (simp add: max_def (*‹max (?a::?'a::ord) (?b::?'a::ord) = (if ?a ≤ ?b then ?b else ?a)›*)) lemma lead_monom_0 [simp]: "lead_monom 0 = 0" by (simp add: lead_monom_def (*‹lead_monom ≡ map_fun mapping_of id (λf. Max (insert 0 (keys f)))›*) zero_mpoly.rep_eq (*‹mapping_of 0 = 0›*)) lemma lead_monom_1 [simp]: "lead_monom 1 = 0" by (simp add: lead_monom_def (*‹lead_monom ≡ map_fun mapping_of id (λf. Max (insert 0 (keys f)))›*) one_mpoly.rep_eq (*‹mapping_of 1 = 1›*)) lemma lead_monom_Const [simp]: "lead_monom (Const c) = 0" by (simp add: lead_monom_def (*‹lead_monom ≡ map_fun mapping_of id (λf::(nat ⇒₀ nat) ⇒₀ ?'a. Max (insert (0::nat ⇒₀ nat) (keys f)))›*) Const.rep_eq (*‹mapping_of (Const (?x::?'b)) = Const₀ ?x›*) Const₀_def (*‹Const₀ (?c::?'b) ≡ Poly_Mapping.single (0::?'a ⇒₀ nat) ?c›*)) lemma lead_monom_uminus [simp]: "lead_monom (-p) = lead_monom p" sorry lemma keys_mult_const [simp]: fixes c :: "'a :: {semiring_0, semiring_no_zero_divisors}" assumes "c ≠ 0" shows "keys (Poly_Mapping.map ((*) c) p) = keys p" using assms (*‹c ≠ 0›*) apply transfer (*goal: ‹keys (Poly_Mapping.map ((*) c) p) = keys p›*) by auto lemma lead_monom_eq_0_iff: "lead_monom p = 0 ⟷ vars p = {}" unfolding vars_def (*goal: ‹(lead_monom p = 0) = (⋃ (keys ` keys (mapping_of p)) = {})›*) apply transfer' (*goal: ‹(lead_monom p = 0) = (⋃ (keys ` keys (mapping_of p)) = {})›*) by (auto simp: Max_eq_iff (*‹⟦finite ?A; ?A ≠ {}⟧ ⟹ (Max ?A = ?m) = (?m ∈ ?A ∧ (∀a∈?A. a ≤ ?m))›*)) lemma lead_monom_monom: "lead_monom (monom m c) = (if c = 0 then 0 else m)" by (auto simp add: lead_monom_def (*‹lead_monom ≡ map_fun mapping_of id (λf. Max (insert 0 (keys f)))›*) monom.rep_eq (*‹mapping_of (MPoly_Type.monom ?x ?xa) = Poly_Mapping.single ?x ?xa›*) Const₀_def (*‹Const₀ ?c ≡ Poly_Mapping.single 0 ?c›*) max_def (*‹max ?a ?b = (if ?a ≤ ?b then ?b else ?a)›*)) lemma lead_monom_monom' [simp]: "c ≠ 0 ⟹ lead_monom (monom m c) = m" by (simp add: lead_monom_monom (*‹lead_monom (MPoly_Type.monom (?m::nat ⇒₀ nat) (?c::?'a)) = (if ?c = (0::?'a) then 0::nat ⇒₀ nat else ?m)›*)) lemma lead_monom_numeral [simp]: "lead_monom (numeral n) = 0" unfolding monom_numeral[symmetric] (*goal: ‹lead_monom (MPoly_Type.monom (0::nat ⇒₀ nat) (numeral (n::num))) = (0::nat ⇒₀ nat)›*) apply (subst lead_monom_monom (*‹lead_monom (MPoly_Type.monom ?m ?c) = (if ?c = 0 then 0 else ?m)›*)) (*goal: ‹lead_monom (MPoly_Type.monom 0 (numeral n)) = 0›*) by auto lemma lead_monom_add: "lead_monom (p + q) ≤ max (lead_monom p) (lead_monom q)" proof (transfer) (*goal: ‹⋀p q. Max (insert 0 (keys (p + q))) ≤ max (Max (insert 0 (keys p))) (Max (insert 0 (keys q)))›*) fix p :: "(nat ⇒₀ nat) ⇒₀ 'a" and q :: "(nat ⇒₀ nat) ⇒₀ 'a" show "Max (insert 0 (keys (p + q))) ≤ max (Max (insert 0 (keys p))) (Max (insert 0 (keys q)))" proof (rule Max.boundedI (*‹⟦finite ?A; ?A ≠ {}; ⋀a. a ∈ ?A ⟹ a ≤ ?x⟧ ⟹ Max ?A ≤ ?x›*)) (*goals: 1. ‹finite (insert 0 (keys (p + q)))› 2. ‹insert 0 (keys (p + q)) ≠ {}› 3. ‹⋀a. a ∈ insert 0 (keys (p + q)) ⟹ a ≤ max (Max (insert 0 (keys p))) (Max (insert 0 (keys q)))›*) fix m assume m: "m ∈ insert 0 (keys (p + q))" (*‹(m::nat ⇒₀ nat) ∈ insert (0::nat ⇒₀ nat) (keys ((p::(nat ⇒₀ nat) ⇒₀ 'a) + (q::(nat ⇒₀ nat) ⇒₀ 'a)))›*) thus "m ≤ max (Max (insert 0 (keys p))) (Max (insert 0 (keys q)))" proof (standard) (*goals: 1. ‹m = 0 ⟹ m ≤ max (Max (insert 0 (keys p))) (Max (insert 0 (keys q)))› 2. ‹m ∈ keys (p + q) ⟹ m ≤ max (Max (insert 0 (keys p))) (Max (insert 0 (keys q)))›*) assume "m ∈ keys (p + q)" (*‹(m::nat ⇒₀ nat) ∈ keys ((p::(nat ⇒₀ nat) ⇒₀ 'a) + (q::(nat ⇒₀ nat) ⇒₀ 'a))›*) with keys_add[of p q] (*‹keys p ∩ keys q = {} ⟹ keys p ∪ keys q = keys (p + q)›*) have "m ∈ keys p ∨ m ∈ keys q" by (auto simp: in_keys_iff (*‹(?x ∈ keys ?s) = (lookup ?s ?x ≠ 0)›*) plus_poly_mapping.rep_eq (*‹lookup (?x + ?xa) = (λk. lookup ?x k + lookup ?xa k)›*)) thus "?thesis" (*goal: ‹m ≤ max (Max (insert 0 (keys p))) (Max (insert 0 (keys q)))›*) by (auto simp: le_max_iff_disj (*‹((?z::?'a::linorder) ≤ max (?x::?'a::linorder) (?y::?'a::linorder)) = (?z ≤ ?x ∨ ?z ≤ ?y)›*)) qed (auto) (*solved the remaining goal: ‹m = 0 ⟹ m ≤ max (Max (insert 0 (keys p))) (Max (insert 0 (keys q)))›*) qed (auto) (*solves the remaining goals: 1. ‹finite (insert (0::nat ⇒₀ nat) (keys ((p::(nat ⇒₀ nat) ⇒₀ 'a) + (q::(nat ⇒₀ nat) ⇒₀ 'a))))› 2. ‹insert (0::nat ⇒₀ nat) (keys ((p::(nat ⇒₀ nat) ⇒₀ 'a) + (q::(nat ⇒₀ nat) ⇒₀ 'a))) ≠ {}›*) qed lemma lead_monom_diff: "lead_monom (p - q) ≤ max (lead_monom p) (lead_monom q)" sorry definition lead_coeff where "lead_coeff p = coeff p (lead_monom p)" lemma vars_empty_iff: "vars p = {} ⟷ p = Const (lead_coeff p)" proof (standard) (*goals: 1. ‹vars (p::'a::zero mpoly) = {} ⟹ p = Const (Symmetric_Polynomials.lead_coeff p)› 2. ‹(p::'a::zero mpoly) = Const (Symmetric_Polynomials.lead_coeff p) ⟹ vars p = {}›*) assume "vars p = {}" (*‹vars (p::'a mpoly) = {}›*) hence [simp]: "lead_monom p = 0" by (simp add: lead_monom_eq_0_iff (*‹(lead_monom (?p::?'a mpoly) = (0::nat ⇒₀ nat)) = (vars ?p = {})›*)) have [simp]: "mon ≠ 0 ⟷ (mon > (0 :: nat ⇒₀ nat))" for mon by (auto simp: order.strict_iff_order (*‹((?a::?'a) < (?b::?'a)) = (?a ≤ ?b ∧ ?a ≠ ?b)›*)) thus "p = Const (lead_coeff p)" apply (intro mpoly_eqI (*‹(⋀mon. MPoly_Type.coeff ?p mon = MPoly_Type.coeff ?q mon) ⟹ ?p = ?q›*)) (*goal: ‹p = Const (Symmetric_Polynomials.lead_coeff p)›*) by (auto simp: mpoly_coeff_Const (*‹MPoly_Type.coeff (Const (?c::?'a)) (?m::nat ⇒₀ nat) = (if ?m = (0::nat ⇒₀ nat) then ?c else (0::?'a))›*) lead_coeff_def (*‹Symmetric_Polynomials.lead_coeff (?p::?'a mpoly) = MPoly_Type.coeff ?p (lead_monom ?p)›*)) next (*goal: ‹(p::'a mpoly) = Const (Symmetric_Polynomials.lead_coeff p) ⟹ vars p = {}›*) assume "p = Const (lead_coeff p)" (*‹(p::'a mpoly) = Const (Symmetric_Polynomials.lead_coeff p)›*) also (*calculation: ‹p = Const (Symmetric_Polynomials.lead_coeff p)›*) have "vars … = {}" by simp finally (*calculation: ‹vars p = {}›*) show "vars p = {}" . qed lemma lead_coeff_0 [simp]: "lead_coeff 0 = 0" by (simp add: lead_coeff_def (*‹Symmetric_Polynomials.lead_coeff ?p = MPoly_Type.coeff ?p (lead_monom ?p)›*)) lemma lead_coeff_1 [simp]: "lead_coeff 1 = 1" by (simp add: lead_coeff_def (*‹Symmetric_Polynomials.lead_coeff ?p = MPoly_Type.coeff ?p (lead_monom ?p)›*) mpoly_coeff_1 (*‹MPoly_Type.coeff 1 ?m = (if ?m = 0 then 1 else 0)›*)) lemma lead_coeff_Const [simp]: "lead_coeff (Const c) = c" by (simp add: lead_coeff_def (*‹Symmetric_Polynomials.lead_coeff ?p = MPoly_Type.coeff ?p (lead_monom ?p)›*) mpoly_coeff_Const (*‹MPoly_Type.coeff (Const ?c) ?m = (if ?m = 0 then ?c else 0)›*)) lemma lead_coeff_monom [simp]: "lead_coeff (monom p c) = c" by (simp add: lead_coeff_def (*‹Symmetric_Polynomials.lead_coeff ?p = MPoly_Type.coeff ?p (lead_monom ?p)›*) coeff_monom (*‹MPoly_Type.coeff (MPoly_Type.monom ?m ?a) ?m' = (?a when ?m' = ?m)›*) when_def (*‹(?a when ?P) = (if ?P then ?a else 0)›*) lead_monom_monom (*‹lead_monom (MPoly_Type.monom ?m ?c) = (if ?c = 0 then 0 else ?m)›*)) lemma lead_coeff_nonzero [simp]: "p ≠ 0 ⟹ lead_coeff p ≠ 0" unfolding lead_coeff_def lead_monom_def (*goal: ‹p ≠ 0 ⟹ MPoly_Type.coeff p (map_fun mapping_of id (λf. Max (insert 0 (keys f))) p) ≠ 0›*) apply (cases "keys (mapping_of p) = {}") (*goals: 1. ‹⟦p ≠ 0; keys (mapping_of p) = {}⟧ ⟹ MPoly_Type.coeff p (map_fun mapping_of id (λf. Max (insert 0 (keys f))) p) ≠ 0› 2. ‹⟦p ≠ 0; keys (mapping_of p) ≠ {}⟧ ⟹ MPoly_Type.coeff p (map_fun mapping_of id (λf. Max (insert 0 (keys f))) p) ≠ 0› discuss goal 1*) apply ((auto simp: coeff_def (*‹MPoly_Type.coeff ?p = lookup (mapping_of ?p)›*) max_def (*‹max ?a ?b = (if ?a ≤ ?b then ?b else ?a)›*))[1]) (*discuss goal 2*) apply ((auto simp: coeff_def (*‹MPoly_Type.coeff ?p = lookup (mapping_of ?p)›*) max_def (*‹max ?a ?b = (if ?a ≤ ?b then ?b else ?a)›*))[1]) (*proven 2 subgoals*) . lemma fixes c :: "'a :: semiring_0" assumes "c * lead_coeff p ≠ 0" shows lead_monom_smult [simp]: "lead_monom (smult c p) = lead_monom p" and lead_coeff_smult [simp]: "lead_coeff (smult c p) = c * lead_coeff p" proof (-) (*goals: 1. ‹lead_monom (MPoly_Type.smult c p) = lead_monom p› 2. ‹Symmetric_Polynomials.lead_coeff (MPoly_Type.smult c p) = c * Symmetric_Polynomials.lead_coeff p›*) from assms (*‹(c::'a::semiring_0) * Symmetric_Polynomials.lead_coeff (p::'a::semiring_0 mpoly) ≠ (0::'a::semiring_0)›*) have "*": "keys (mapping_of p) ≠ {}" by auto from assms (*‹(c::'a) * Symmetric_Polynomials.lead_coeff (p::'a mpoly) ≠ (0::'a)›*) have "coeff (MPoly_Type.smult c p) (lead_monom p) ≠ 0" by (simp add: lead_coeff_def (*‹Symmetric_Polynomials.lead_coeff ?p = MPoly_Type.coeff ?p (lead_monom ?p)›*)) hence smult_nz: "MPoly_Type.smult c p ≠ 0" by (auto simp del: coeff_smult (*‹MPoly_Type.coeff (MPoly_Type.smult (?c::?'a) (?p::?'a mpoly)) (?m::nat ⇒₀ nat) = ?c * MPoly_Type.coeff ?p ?m›*)) with assms (*‹(c::'a::semiring_0) * Symmetric_Polynomials.lead_coeff (p::'a::semiring_0 mpoly) ≠ (0::'a::semiring_0)›*) have "**": "keys (mapping_of (smult c p)) ≠ {}" by simp have "Max (keys (mapping_of (smult c p))) = Max (keys (mapping_of p))" proof (safe intro!: antisym (*‹⟦?a ≤ ?b; ?b ≤ ?a⟧ ⟹ ?a = ?b›*) Max.coboundedI (*‹⟦finite ?A; ?a ∈ ?A⟧ ⟹ ?a ≤ Max ?A›*)) (*goals: 1. ‹finite (keys (mapping_of p))› 2. ‹Max (keys (mapping_of (MPoly_Type.smult c p))) ∈ keys (mapping_of p)› 3. ‹finite (keys (mapping_of (MPoly_Type.smult c p)))› 4. ‹Max (keys (mapping_of p)) ∈ keys (mapping_of (MPoly_Type.smult c p))›*) have "lookup (mapping_of p) (Max (keys (mapping_of p))) = lead_coeff p" using "*" (*‹keys (mapping_of (p::'a mpoly)) ≠ {}›*) by (simp add: lead_coeff_def (*‹Symmetric_Polynomials.lead_coeff ?p = MPoly_Type.coeff ?p (lead_monom ?p)›*) lead_monom_def (*‹lead_monom ≡ map_fun mapping_of id (λf. Max (insert 0 (keys f)))›*) max_def (*‹max ?a ?b = (if ?a ≤ ?b then ?b else ?a)›*) coeff_def (*‹MPoly_Type.coeff ?p = lookup (mapping_of ?p)›*)) with assms (*‹c * Symmetric_Polynomials.lead_coeff p ≠ 0›*) show "Max (keys (mapping_of p)) ∈ keys (mapping_of (smult c p))" using "*" (*‹keys (mapping_of p) ≠ {}›*) by (auto simp: smult.rep_eq (*‹mapping_of (MPoly_Type.smult ?x ?xa) = Poly_Mapping.map ((*) ?x) (mapping_of ?xa)›*) intro!: in_keys_mapI (*‹⟦?x ∈ keys ?m; ?f (lookup ?m ?x) ≠ 0⟧ ⟹ ?x ∈ keys (Poly_Mapping.map ?f ?m)›*)) from smult_nz (*‹MPoly_Type.smult c p ≠ 0›*) have "lead_coeff (smult c p) ≠ 0" apply (intro lead_coeff_nonzero (*‹?p ≠ 0 ⟹ Symmetric_Polynomials.lead_coeff ?p ≠ 0›*)) (*goal: ‹Symmetric_Polynomials.lead_coeff (MPoly_Type.smult (c::'a) (p::'a mpoly)) ≠ (0::'a)›*) by auto hence "coeff p (Max (keys (mapping_of (smult c p)))) ≠ 0" using assms (*‹c * Symmetric_Polynomials.lead_coeff p ≠ 0›*) "*" (*‹keys (mapping_of (p::'a mpoly)) ≠ {}›*) "**" (*‹keys (mapping_of (MPoly_Type.smult c p)) ≠ {}›*) by (auto simp: lead_coeff_def (*‹Symmetric_Polynomials.lead_coeff ?p = MPoly_Type.coeff ?p (lead_monom ?p)›*) lead_monom_def (*‹lead_monom ≡ map_fun mapping_of id (λf. Max (insert 0 (keys f)))›*) max_def (*‹max ?a ?b = (if ?a ≤ ?b then ?b else ?a)›*)) thus "Max (keys (mapping_of (smult c p))) ∈ keys (mapping_of p)" by (auto simp: smult.rep_eq (*‹mapping_of (MPoly_Type.smult ?x ?xa) = Poly_Mapping.map ((*) ?x) (mapping_of ?xa)›*) coeff_def (*‹MPoly_Type.coeff ?p = lookup (mapping_of ?p)›*) in_keys_iff (*‹(?x ∈ keys ?s) = (lookup ?s ?x ≠ 0)›*)) qed (auto) (*solves the remaining goals: 1. ‹finite (keys (mapping_of (p::'a mpoly)))› 2. ‹finite (keys (mapping_of (MPoly_Type.smult (c::'a) (p::'a mpoly))))›*) with "*" (*‹keys (mapping_of (p::'a mpoly)) ≠ {}›*) "**" (*‹keys (mapping_of (MPoly_Type.smult c p)) ≠ {}›*) show "lead_monom (smult c p) = lead_monom p" by (simp add: lead_monom_def (*‹lead_monom ≡ map_fun mapping_of id (λf. Max (insert 0 (keys f)))›*) max_def (*‹max ?a ?b = (if ?a ≤ ?b then ?b else ?a)›*)) thus "lead_coeff (smult c p) = c * lead_coeff p" by (simp add: lead_coeff_def (*‹Symmetric_Polynomials.lead_coeff ?p = MPoly_Type.coeff ?p (lead_monom ?p)›*)) qed lemma lead_coeff_mult_aux: "coeff (p * q) (lead_monom p + lead_monom q) = lead_coeff p * lead_coeff q" proof (cases "p = 0 ∨ q = 0") (*goals: 1. ‹p = 0 ∨ q = 0 ⟹ MPoly_Type.coeff (p * q) (lead_monom p + lead_monom q) = Symmetric_Polynomials.lead_coeff p * Symmetric_Polynomials.lead_coeff q› 2. ‹¬ (p = 0 ∨ q = 0) ⟹ MPoly_Type.coeff (p * q) (lead_monom p + lead_monom q) = Symmetric_Polynomials.lead_coeff p * Symmetric_Polynomials.lead_coeff q›*) case False (*‹¬ (p = 0 ∨ q = 0)›*) define a and b where "a = lead_monom p" and "b = lead_monom q" have "coeff (p * q) (a + b) = coeff p a * coeff q b" unfolding coeff_mpoly_times (*goal: ‹prod_fun (MPoly_Type.coeff p) (MPoly_Type.coeff q) (a + b) = MPoly_Type.coeff p a * MPoly_Type.coeff q b›*) apply (rule prod_fun_max (*‹⟦⋀m::?'a::{ordered_cancel_comm_monoid_add,linorder}. (?a::?'a::{ordered_cancel_comm_monoid_add,linorder}) < m ⟹ (?f::?'a::{ordered_cancel_comm_monoid_add,linorder} ⇒ ?'b::semiring_0) m = (0::?'b::semiring_0); ⋀m::?'a::{ordered_cancel_comm_monoid_add,linorder}. (?b::?'a::{ordered_cancel_comm_monoid_add,linorder}) < m ⟹ (?g::?'a::{ordered_cancel_comm_monoid_add,linorder} ⇒ ?'b::semiring_0) m = (0::?'b::semiring_0); finite {m::?'a::{ordered_cancel_comm_monoid_add,linorder}. ?f m ≠ (0::?'b::semiring_0)}; finite {m::?'a::{ordered_cancel_comm_monoid_add,linorder}. ?g m ≠ (0::?'b::semiring_0)}⟧ ⟹ prod_fun ?f ?g (?a + ?b) = ?f ?a * ?g ?b›*)) (*goals: 1. ‹⋀m. a < m ⟹ MPoly_Type.coeff p m = 0› 2. ‹⋀m. b < m ⟹ MPoly_Type.coeff q m = 0› 3. ‹finite {m. MPoly_Type.coeff p m ≠ 0}› 4. ‹finite {m. MPoly_Type.coeff q m ≠ 0}› discuss goal 1*) apply ((insert False (*‹¬ (p = 0 ∨ q = 0)›*))[1]) (*top goal: ‹⋀m::nat ⇒₀ nat. (a::nat ⇒₀ nat) < m ⟹ MPoly_Type.coeff (p::'a::semiring_0 mpoly) m = (0::'a::semiring_0)› and 3 goals remain*) apply ((auto simp: a_def (*‹a = lead_monom p›*) b_def (*‹b = lead_monom q›*))[1]) (*discuss goal 2*) apply ((insert False (*‹¬ (p = 0 ∨ q = 0)›*))[1]) (*top goal: ‹⋀m::nat ⇒₀ nat. (b::nat ⇒₀ nat) < m ⟹ MPoly_Type.coeff (q::'a mpoly) m = (0::'a)› and 2 goals remain*) apply ((auto simp: a_def (*‹(a::nat ⇒₀ nat) = lead_monom (p::'a mpoly)›*) b_def (*‹(b::nat ⇒₀ nat) = lead_monom (q::'a mpoly)›*))[1]) (*discuss goal 3*) apply ((insert False (*‹¬ (p = 0 ∨ q = 0)›*))[1]) (*top goal: ‹finite {m. MPoly_Type.coeff p m ≠ 0}› and 1 goal remains*) apply ((auto simp: a_def (*‹a = lead_monom p›*) b_def (*‹b = lead_monom q›*))[1]) (*discuss goal 4*) apply ((insert False (*‹¬ (p = 0 ∨ q = 0)›*))[1]) (*goal: ‹finite {m. MPoly_Type.coeff q m ≠ 0}›*) apply ((auto simp: a_def (*‹a = lead_monom p›*) b_def (*‹b = lead_monom q›*))[1]) (*proven 4 subgoals*) . thus "?thesis" (*goal: ‹MPoly_Type.coeff (p * q) (lead_monom p + lead_monom q) = Symmetric_Polynomials.lead_coeff p * Symmetric_Polynomials.lead_coeff q›*) by (simp add: a_def (*‹a = lead_monom p›*) b_def (*‹b = lead_monom q›*) lead_coeff_def (*‹Symmetric_Polynomials.lead_coeff ?p = MPoly_Type.coeff ?p (lead_monom ?p)›*)) qed (auto) (*solved the remaining goal: ‹(p::'a mpoly) = (0::'a mpoly) ∨ (q::'a mpoly) = (0::'a mpoly) ⟹ MPoly_Type.coeff (p * q) (lead_monom p + lead_monom q) = Symmetric_Polynomials.lead_coeff p * Symmetric_Polynomials.lead_coeff q›*) lemma lead_monom_mult_le: "lead_monom (p * q) ≤ lead_monom p + lead_monom q" proof (cases "p * q = 0") (*goals: 1. ‹p * q = 0 ⟹ lead_monom (p * q) ≤ lead_monom p + lead_monom q› 2. ‹p * q ≠ 0 ⟹ lead_monom (p * q) ≤ lead_monom p + lead_monom q›*) case False (*‹p * q ≠ 0›*) show "?thesis" (*goal: ‹lead_monom ((p::'a mpoly) * (q::'a mpoly)) ≤ lead_monom p + lead_monom q›*) proof (intro leI (*‹¬ (?x::?'a::linorder) < (?y::?'a::linorder) ⟹ ?y ≤ ?x›*) notI (*‹(?P::bool ⟹ False) ⟹ ¬ ?P›*)) (*goal: ‹lead_monom p + lead_monom q < lead_monom (p * q) ⟹ False›*) assume "lead_monom p + lead_monom q < lead_monom (p * q)" (*‹lead_monom (p::'a mpoly) + lead_monom (q::'a mpoly) < lead_monom (p * q)›*) hence "lead_coeff (p * q) = 0" unfolding lead_coeff_def coeff_mpoly_times (*goal: ‹prod_fun (MPoly_Type.coeff p) (MPoly_Type.coeff q) (lead_monom (p * q)) = 0›*) apply (rule prod_fun_gt_max_eq_zero (*‹⟦?a + ?b < ?m; ⋀m. ?a < m ⟹ ?f m = 0; ⋀m. ?b < m ⟹ ?g m = 0; finite {m. ?f m ≠ 0}; finite {m. ?g m ≠ 0}⟧ ⟹ prod_fun ?f ?g ?m = 0›*)) (*goals: 1. ‹⋀m. lead_monom p < m ⟹ MPoly_Type.coeff p m = 0› 2. ‹⋀m. lead_monom q < m ⟹ MPoly_Type.coeff q m = 0› 3. ‹finite {m. MPoly_Type.coeff p m ≠ 0}› 4. ‹finite {m. MPoly_Type.coeff q m ≠ 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*) . with False (*‹p * q ≠ 0›*) show False by simp qed qed (auto) (*solved the remaining goal: ‹p * q = 0 ⟹ lead_monom (p * q) ≤ lead_monom p + lead_monom q›*) lemma lead_monom_mult: assumes "lead_coeff p * lead_coeff q ≠ 0" shows "lead_monom (p * q) = lead_monom p + lead_monom q" apply (intro antisym (*‹⟦?a ≤ ?b; ?b ≤ ?a⟧ ⟹ ?a = ?b›*) lead_monom_mult_le (*‹lead_monom (?p * ?q) ≤ lead_monom ?p + lead_monom ?q›*) lead_monom_geI (*‹MPoly_Type.coeff ?p ?m ≠ 0 ⟹ ?m ≤ lead_monom ?p›*)) (*goal: ‹lead_monom (p * q) = lead_monom p + lead_monom q›*) apply (insert assms (*‹Symmetric_Polynomials.lead_coeff p * Symmetric_Polynomials.lead_coeff q ≠ 0›*)) (*goal: ‹MPoly_Type.coeff (p * q) (lead_monom p + lead_monom q) ≠ 0›*) by (auto simp: lead_coeff_mult_aux (*‹MPoly_Type.coeff (?p * ?q) (lead_monom ?p + lead_monom ?q) = Symmetric_Polynomials.lead_coeff ?p * Symmetric_Polynomials.lead_coeff ?q›*)) lemma lead_coeff_mult: assumes "lead_coeff p * lead_coeff q ≠ 0" shows "lead_coeff (p * q) = lead_coeff p * lead_coeff q" using assms (*‹Symmetric_Polynomials.lead_coeff p * Symmetric_Polynomials.lead_coeff q ≠ 0›*) by (simp add: lead_monom_mult (*‹Symmetric_Polynomials.lead_coeff ?p * Symmetric_Polynomials.lead_coeff ?q ≠ 0 ⟹ lead_monom (?p * ?q) = lead_monom ?p + lead_monom ?q›*) lead_coeff_mult_aux (*‹MPoly_Type.coeff (?p * ?q) (lead_monom ?p + lead_monom ?q) = Symmetric_Polynomials.lead_coeff ?p * Symmetric_Polynomials.lead_coeff ?q›*) lead_coeff_def (*‹Symmetric_Polynomials.lead_coeff ?p = MPoly_Type.coeff ?p (lead_monom ?p)›*)) lemma keys_lead_monom_subset: "keys (lead_monom p) ⊆ vars p" proof (cases "p = 0") (*goals: 1. ‹p = 0 ⟹ keys (lead_monom p) ⊆ vars p› 2. ‹p ≠ 0 ⟹ keys (lead_monom p) ⊆ vars p›*) case False (*‹(p::'a::zero mpoly) ≠ (0::'a::zero mpoly)›*) hence "lead_coeff p ≠ 0" by simp hence "coeff p (lead_monom p) ≠ 0" unfolding lead_coeff_def (*goal: ‹MPoly_Type.coeff (p::'a mpoly) (lead_monom p) ≠ (0::'a)›*) . thus "?thesis" (*goal: ‹keys (lead_monom p) ⊆ vars p›*) unfolding vars_def (*goal: ‹keys (lead_monom p) ⊆ ⋃ (keys ` keys (mapping_of p))›*) apply transfer' (*goal: ‹keys (lead_monom (p::'a mpoly)) ⊆ ⋃ (keys ` keys (mapping_of p))›*) by (auto simp: max_def (*‹max ?a ?b = (if ?a ≤ ?b then ?b else ?a)›*) in_keys_iff (*‹(?x ∈ keys ?s) = (lookup ?s ?x ≠ 0)›*)) qed (auto) (*solved the remaining goal: ‹p = 0 ⟹ keys (lead_monom p) ⊆ vars p›*) lemma assumes "(∏i∈A. lead_coeff (f i)) ≠ 0" shows lead_monom_prod: "lead_monom (∏i∈A. f i) = (∑i∈A. lead_monom (f i))" (is ?th1) and lead_coeff_prod: "lead_coeff (∏i∈A. f i) = (∏i∈A. lead_coeff (f i))" (is ?th2) proof (-) (*goals: 1. ‹lead_monom (prod f A) = (∑i∈A. lead_monom (f i))› 2. ‹Symmetric_Polynomials.lead_coeff (prod f A) = (∏i∈A. Symmetric_Polynomials.lead_coeff (f i))›*) have "?th1 ∧ ?th2" using assms (*‹(∏i∈A. Symmetric_Polynomials.lead_coeff (f i)) ≠ 0›*) proof (induction 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; (∏i∈A. Symmetric_Polynomials.lead_coeff (f i)) ≠ 0⟧ ⟹ lead_monom (prod f A) = (∑i∈A. lead_monom (f i)) ∧ Symmetric_Polynomials.lead_coeff (prod f A) = (∏i∈A. Symmetric_Polynomials.lead_coeff (f i))› 2. ‹(∏i∈{}. Symmetric_Polynomials.lead_coeff (f i)) ≠ 0 ⟹ lead_monom (prod f {}) = (∑i∈{}. lead_monom (f i)) ∧ Symmetric_Polynomials.lead_coeff (prod f {}) = (∏i∈{}. Symmetric_Polynomials.lead_coeff (f i))› 3. ‹⋀x F. ⟦finite F; x ∉ F; (∏i∈F. Symmetric_Polynomials.lead_coeff (f i)) ≠ 0 ⟹ lead_monom (prod f F) = (∑i∈F. lead_monom (f i)) ∧ Symmetric_Polynomials.lead_coeff (prod f F) = (∏i∈F. Symmetric_Polynomials.lead_coeff (f i)); (∏i∈insert x F. Symmetric_Polynomials.lead_coeff (f i)) ≠ 0⟧ ⟹ lead_monom (prod f (insert x F)) = (∑i∈insert x F. lead_monom (f i)) ∧ Symmetric_Polynomials.lead_coeff (prod f (insert x F)) = (∏i∈insert x F. Symmetric_Polynomials.lead_coeff (f i))›*) case (insert x A) (*‹finite A› ‹x ∉ A› ‹(∏i∈A. Symmetric_Polynomials.lead_coeff (f i)) ≠ 0 ⟹ lead_monom (prod f A) = (∑i∈A. lead_monom (f i)) ∧ Symmetric_Polynomials.lead_coeff (prod f A) = (∏i∈A. Symmetric_Polynomials.lead_coeff (f i))› ‹(∏i::'b::type∈insert (x::'b::type) (A::'b::type set). Symmetric_Polynomials.lead_coeff ((f::'b::type ⇒ 'a::comm_semiring_1 mpoly) i)) ≠ (0::'a::comm_semiring_1)›*) from insert (*‹finite A› ‹x ∉ A› ‹(∏i∈A. Symmetric_Polynomials.lead_coeff (f i)) ≠ 0 ⟹ lead_monom (prod f A) = (∑i∈A. lead_monom (f i)) ∧ Symmetric_Polynomials.lead_coeff (prod f A) = (∏i∈A. Symmetric_Polynomials.lead_coeff (f i))› ‹(∏i∈insert x A. Symmetric_Polynomials.lead_coeff (f i)) ≠ 0›*) have nz: "lead_coeff (f x) ≠ 0" "(∏i∈A. lead_coeff (f i)) ≠ 0" apply - (*goals: 1. ‹⟦finite A; x ∉ A; (∏i∈A. Symmetric_Polynomials.lead_coeff (f i)) ≠ 0 ⟹ lead_monom (prod f A) = (∑i∈A. lead_monom (f i)) ∧ Symmetric_Polynomials.lead_coeff (prod f A) = (∏i∈A. Symmetric_Polynomials.lead_coeff (f i)); (∏i∈insert x A. Symmetric_Polynomials.lead_coeff (f i)) ≠ 0⟧ ⟹ Symmetric_Polynomials.lead_coeff (f x) ≠ 0› 2. ‹⟦finite A; x ∉ A; (∏i∈A. Symmetric_Polynomials.lead_coeff (f i)) ≠ 0 ⟹ lead_monom (prod f A) = (∑i∈A. lead_monom (f i)) ∧ Symmetric_Polynomials.lead_coeff (prod f A) = (∏i∈A. Symmetric_Polynomials.lead_coeff (f i)); (∏i∈insert x A. Symmetric_Polynomials.lead_coeff (f i)) ≠ 0⟧ ⟹ (∏i∈A. Symmetric_Polynomials.lead_coeff (f i)) ≠ 0› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . note IH = insert.IH[OF this ( 2 )] (*‹lead_monom (prod f A) = (∑i∈A. lead_monom (f i)) ∧ Symmetric_Polynomials.lead_coeff (prod f A) = (∏i∈A. Symmetric_Polynomials.lead_coeff (f i))›*) from insert (*‹finite A› ‹x ∉ A› ‹(∏i∈A. Symmetric_Polynomials.lead_coeff (f i)) ≠ 0 ⟹ lead_monom (prod f A) = (∑i∈A. lead_monom (f i)) ∧ Symmetric_Polynomials.lead_coeff (prod f A) = (∏i∈A. Symmetric_Polynomials.lead_coeff (f i))› ‹(∏i::'b∈insert (x::'b) (A::'b set). Symmetric_Polynomials.lead_coeff ((f::'b ⇒ 'a mpoly) i)) ≠ (0::'a)›*) have nz': "lead_coeff (f x) * lead_coeff (∏i∈A. f i) ≠ 0" apply (subst IH (*‹lead_monom (prod (f::'b::type ⇒ 'a::comm_semiring_1 mpoly) (A::'b::type set)) = (∑i::'b::type∈A. lead_monom (f i)) ∧ Symmetric_Polynomials.lead_coeff (prod f A) = (∏i::'b::type∈A. Symmetric_Polynomials.lead_coeff (f i))›*)) (*goal: ‹Symmetric_Polynomials.lead_coeff (f x) * Symmetric_Polynomials.lead_coeff (prod f A) ≠ 0›*) by auto from insert.prems (*‹(∏i∈insert x A. Symmetric_Polynomials.lead_coeff (f i)) ≠ 0›*) insert.hyps (*‹finite A› ‹x ∉ A›*) nz (*‹Symmetric_Polynomials.lead_coeff (f x) ≠ 0› ‹(∏i∈A. Symmetric_Polynomials.lead_coeff (f i)) ≠ 0›*) nz' (*‹Symmetric_Polynomials.lead_coeff (f x) * Symmetric_Polynomials.lead_coeff (prod f A) ≠ 0›*) show "?case" (*goal: ‹lead_monom (prod (f::'b ⇒ 'a mpoly) (insert (x::'b) (A::'b set))) = (∑i::'b∈insert x A. lead_monom (f i)) ∧ Symmetric_Polynomials.lead_coeff (prod f (insert x A)) = (∏i::'b∈insert x A. Symmetric_Polynomials.lead_coeff (f i))›*) by (auto simp: lead_monom_mult (*‹Symmetric_Polynomials.lead_coeff ?p * Symmetric_Polynomials.lead_coeff ?q ≠ 0 ⟹ lead_monom (?p * ?q) = lead_monom ?p + lead_monom ?q›*) lead_coeff_mult (*‹Symmetric_Polynomials.lead_coeff ?p * Symmetric_Polynomials.lead_coeff ?q ≠ 0 ⟹ Symmetric_Polynomials.lead_coeff (?p * ?q) = Symmetric_Polynomials.lead_coeff ?p * Symmetric_Polynomials.lead_coeff ?q›*) IH (*‹lead_monom (prod f A) = (∑i∈A. lead_monom (f i)) ∧ Symmetric_Polynomials.lead_coeff (prod f A) = (∏i∈A. Symmetric_Polynomials.lead_coeff (f i))›*)) qed (auto) (*solves the remaining goals: 1. ‹⋀A. ⟦infinite A; (∏i∈A. Symmetric_Polynomials.lead_coeff (f i)) ≠ 0⟧ ⟹ lead_monom (prod f A) = (∑i∈A. lead_monom (f i)) ∧ Symmetric_Polynomials.lead_coeff (prod f A) = (∏i∈A. Symmetric_Polynomials.lead_coeff (f i))› 2. ‹(∏i∈{}. Symmetric_Polynomials.lead_coeff (f i)) ≠ 0 ⟹ lead_monom (prod f {}) = (∑i∈{}. lead_monom (f i)) ∧ Symmetric_Polynomials.lead_coeff (prod f {}) = (∏i∈{}. Symmetric_Polynomials.lead_coeff (f i))›*) thus "?th1" "?th2" apply - (*goals: 1. ‹lead_monom (prod f A) = (∑i∈A. lead_monom (f i)) ∧ Symmetric_Polynomials.lead_coeff (prod f A) = (∏i∈A. Symmetric_Polynomials.lead_coeff (f i)) ⟹ lead_monom (prod f A) = (∑i∈A. lead_monom (f i))› 2. ‹lead_monom (prod f A) = (∑i∈A. lead_monom (f i)) ∧ Symmetric_Polynomials.lead_coeff (prod f A) = (∏i∈A. Symmetric_Polynomials.lead_coeff (f i)) ⟹ Symmetric_Polynomials.lead_coeff (prod f A) = (∏i∈A. Symmetric_Polynomials.lead_coeff (f i))› discuss goal 1*) apply blast (*discuss goal 2*) apply blast (*proven 2 subgoals*) . qed lemma lead_monom_sum_le: "(⋀x. x ∈ X ⟹ lead_monom (h x) ≤ ub) ⟹ lead_monom (sum h X) ≤ ub" apply (induction X 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; ⋀x. x ∈ A ⟹ lead_monom (h x) ≤ ub⟧ ⟹ lead_monom (sum h A) ≤ ub› 2. ‹(⋀x. x ∈ {} ⟹ lead_monom (h x) ≤ ub) ⟹ lead_monom (sum h {}) ≤ ub› 3. ‹⋀x F. ⟦finite F; x ∉ F; (⋀x. x ∈ F ⟹ lead_monom (h x) ≤ ub) ⟹ lead_monom (sum h F) ≤ ub; ⋀xa. xa ∈ insert x F ⟹ lead_monom (h xa) ≤ ub⟧ ⟹ lead_monom (sum h (insert x F)) ≤ ub› discuss goal 1*) apply ((auto intro!: order.trans[OF lead_monom_add] (*‹max (lead_monom ?p1) (lead_monom ?q1) ≤ ?c ⟹ lead_monom (?p1 + ?q1) ≤ ?c›*))[1]) (*discuss goal 2*) apply ((auto intro!: order.trans[OF lead_monom_add] (*‹max (lead_monom ?p1) (lead_monom ?q1) ≤ ?c ⟹ lead_monom (?p1 + ?q1) ≤ ?c›*))[1]) (*discuss goal 3*) apply ((auto intro!: order.trans[OF lead_monom_add] (*‹max (lead_monom ?p1) (lead_monom ?q1) ≤ ?c ⟹ lead_monom (?p1 + ?q1) ≤ ?c›*))[1]) (*proven 3 subgoals*) . text ‹ The leading monomial of a sum where the leading monomial the summands are distinct is simply the maximum of the leading monomials. › lemma lead_monom_sum: assumes "inj_on (lead_monom ∘ h) X" and "finite X" and "X ≠ {}" and "⋀x. x ∈ X ⟹ h x ≠ 0" defines "m ≡ Max ((lead_monom ∘ h) ` X)" shows "lead_monom (∑x∈X. h x) = m" proof (rule antisym (*‹⟦?a ≤ ?b; ?b ≤ ?a⟧ ⟹ ?a = ?b›*)) (*goals: 1. ‹lead_monom (sum (h::'a ⇒ 'b mpoly) (X::'a set)) ≤ (m::nat ⇒₀ nat)› 2. ‹(m::nat ⇒₀ nat) ≤ lead_monom (sum (h::'a ⇒ 'b mpoly) (X::'a set))›*) show "lead_monom (sum h X) ≤ m" unfolding m_def (*goal: ‹lead_monom (sum (h::'a::type ⇒ 'b::comm_monoid_add mpoly) (X::'a::type set)) ≤ Max ((lead_monom ∘ h) ` X)›*) using assms (*‹inj_on (lead_monom ∘ h) X› ‹finite X› ‹X ≠ {}› ‹?x ∈ X ⟹ h ?x ≠ 0› ‹m ≡ Max ((lead_monom ∘ h) ` X)›*) apply (intro lead_monom_sum_le (*‹(⋀x::?'a::type. x ∈ (?X::?'a::type set) ⟹ lead_monom ((?h::?'a::type ⇒ ?'b::comm_monoid_add mpoly) x) ≤ (?ub::nat ⇒₀ nat)) ⟹ lead_monom (sum ?h ?X) ≤ ?ub›*) Max_ge (*‹⟦finite (?A::?'a::linorder set); (?x::?'a::linorder) ∈ ?A⟧ ⟹ ?x ≤ Max ?A›*) finite_imageI (*‹finite (?F::?'a::type set) ⟹ finite ((?h::?'a::type ⇒ ?'b::type) ` ?F)›*)) (*goals: 1. ‹⋀x::'a. ⟦inj_on (lead_monom ∘ (h::'a ⇒ 'b mpoly)) (X::'a set); finite X; X ≠ {}; ⋀x::'a. x ∈ X ⟹ h x ≠ (0::'b mpoly); m::nat ⇒₀ nat ≡ Max ((lead_monom ∘ h) ` X); x ∈ X⟧ ⟹ finite X› 2. ‹⋀x::'a. ⟦inj_on (lead_monom ∘ (h::'a ⇒ 'b mpoly)) (X::'a set); finite X; X ≠ {}; ⋀x::'a. x ∈ X ⟹ h x ≠ (0::'b mpoly); m::nat ⇒₀ nat ≡ Max ((lead_monom ∘ h) ` X); x ∈ X⟧ ⟹ lead_monom (h x) ∈ (lead_monom ∘ h) ` X› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . next (*goal: ‹m ≤ lead_monom (sum h X)›*) from assms (*‹inj_on (lead_monom ∘ h) X› ‹finite X› ‹X ≠ {}› ‹(?x::'a) ∈ (X::'a set) ⟹ (h::'a ⇒ 'b mpoly) ?x ≠ (0::'b mpoly)› ‹m ≡ Max ((lead_monom ∘ h) ` X)›*) have "m ∈ (lead_monom ∘ h) ` X" unfolding m_def (*goal: ‹Max ((lead_monom ∘ h) ` X) ∈ (lead_monom ∘ h) ` X›*) apply (intro Max_in (*‹⟦finite ?A; ?A ≠ {}⟧ ⟹ Max ?A ∈ ?A›*) finite_imageI (*‹finite ?F ⟹ finite (?h ` ?F)›*)) (*goals: 1. ‹⟦inj_on (lead_monom ∘ h) X; finite X; X ≠ {}; ⋀x. x ∈ X ⟹ h x ≠ 0; Max ((lead_monom ∘ h) ` X) ≡ Max ((lead_monom ∘ h) ` X)⟧ ⟹ finite X› 2. ‹⟦inj_on (lead_monom ∘ h) X; finite X; X ≠ {}; ⋀x. x ∈ X ⟹ h x ≠ 0; Max ((lead_monom ∘ h) ` X) ≡ Max ((lead_monom ∘ h) ` X)⟧ ⟹ (lead_monom ∘ h) ` X ≠ {}› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . then obtain x where x: "x ∈ X" "m = lead_monom (h x)" (*goal: ‹(⋀x. ⟦x ∈ X; m = lead_monom (h x)⟧ ⟹ thesis) ⟹ thesis›*) by auto have "coeff (∑x∈X. h x) m = (∑x∈X. coeff (h x) m)" by simp also (*calculation: ‹MPoly_Type.coeff (sum h X) m = (∑x∈X. MPoly_Type.coeff (h x) m)›*) have "… = (∑x∈{x}. coeff (h x) m)" proof (intro sum.mono_neutral_right (*‹⟦finite ?T; ?S ⊆ ?T; ∀i∈?T - ?S. ?g i = 0⟧ ⟹ sum ?g ?T = sum ?g ?S›*) ballI (*‹(⋀x. x ∈ ?A ⟹ ?P x) ⟹ ∀x∈?A. ?P x›*)) (*goals: 1. ‹finite X› 2. ‹{x} ⊆ X› 3. ‹⋀i. i ∈ X - {x} ⟹ MPoly_Type.coeff (h i) m = 0›*) fix y assume y: "y ∈ X - {x}" (*‹(y::'a) ∈ (X::'a set) - {x::'a}›*) hence "(lead_monom ∘ h) y ≤ m" using assms (*‹inj_on (lead_monom ∘ (h::'a ⇒ 'b mpoly)) (X::'a set)› ‹finite X› ‹X ≠ {}› ‹?x ∈ X ⟹ h ?x ≠ 0› ‹m ≡ Max ((lead_monom ∘ h) ` X)›*) unfolding m_def (*goal: ‹(lead_monom ∘ h) y ≤ Max ((lead_monom ∘ h) ` X)›*) apply (intro Max_ge (*‹⟦finite (?A::?'a::linorder set); (?x::?'a::linorder) ∈ ?A⟧ ⟹ ?x ≤ Max ?A›*) finite_imageI (*‹finite (?F::?'a::type set) ⟹ finite ((?h::?'a::type ⇒ ?'b::type) ` ?F)›*)) (*goals: 1. ‹⟦y ∈ X - {x}; inj_on (lead_monom ∘ h) X; finite X; X ≠ {}; ⋀x. x ∈ X ⟹ h x ≠ 0; Max ((lead_monom ∘ h) ` X) ≡ Max ((lead_monom ∘ h) ` X)⟧ ⟹ finite X› 2. ‹⟦y ∈ X - {x}; inj_on (lead_monom ∘ h) X; finite X; X ≠ {}; ⋀x. x ∈ X ⟹ h x ≠ 0; Max ((lead_monom ∘ h) ` X) ≡ Max ((lead_monom ∘ h) ` X)⟧ ⟹ (lead_monom ∘ h) y ∈ (lead_monom ∘ h) ` X› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . moreover have "(lead_monom ∘ h) y ≠ (lead_monom ∘ h) x" using ‹x ∈ X› (*‹x ∈ X›*) y (*‹y ∈ X - {x}›*) inj_onD[OF assms ( 1 ), of x y] (*‹⟦(lead_monom ∘ (h::'a::type ⇒ 'b::comm_monoid_add mpoly)) (x::'a::type) = (lead_monom ∘ h) (y::'a::type); x ∈ (X::'a::type set); y ∈ X⟧ ⟹ x = y›*) by auto ultimately have "lead_monom (h y) < m" using x (*‹x ∈ X› ‹m = lead_monom (h x)›*) by auto thus "coeff (h y) m = 0" by simp qed (insert x (*‹x ∈ X› ‹m = lead_monom (h x)›*) assms (*‹inj_on (lead_monom ∘ h) X› ‹finite X› ‹X ≠ {}› ‹?x ∈ X ⟹ h ?x ≠ 0› ‹m ≡ Max ((lead_monom ∘ h) ` X)›*), auto) (*solves the remaining goals: 1. ‹finite X› 2. ‹{x} ⊆ X›*) also (*calculation: ‹MPoly_Type.coeff (sum (h::'a::type ⇒ 'b::comm_monoid_add mpoly) (X::'a::type set)) (m::nat ⇒₀ nat) = (∑x::'a::type∈{x::'a::type}. MPoly_Type.coeff (h x) m)›*) have "… = coeff (h x) m" by simp also (*calculation: ‹MPoly_Type.coeff (sum h X) m = MPoly_Type.coeff (h x) m›*) have "… = lead_coeff (h x)" using x (*‹x ∈ X› ‹(m::nat ⇒₀ nat) = lead_monom ((h::'a::type ⇒ 'b::comm_monoid_add mpoly) (x::'a::type))›*) by (simp add: lead_coeff_def (*‹Symmetric_Polynomials.lead_coeff ?p = MPoly_Type.coeff ?p (lead_monom ?p)›*)) also (*calculation: ‹MPoly_Type.coeff (sum h X) m = Symmetric_Polynomials.lead_coeff (h x)›*) have "… ≠ 0" using assms (*‹inj_on (lead_monom ∘ h) X› ‹finite X› ‹X ≠ {}› ‹?x ∈ X ⟹ h ?x ≠ 0› ‹m ≡ Max ((lead_monom ∘ h) ` X)›*) x (*‹x ∈ X› ‹m = lead_monom (h x)›*) by auto finally (*calculation: ‹MPoly_Type.coeff (sum h X) m ≠ 0›*) show "lead_monom (sum h X) ≥ m" by (intro lead_monom_geI (*‹MPoly_Type.coeff (?p::?'a mpoly) (?m::nat ⇒₀ nat) ≠ (0::?'a) ⟹ ?m ≤ lead_monom ?p›*)) qed lemma lead_coeff_eq_0_iff [simp]: "lead_coeff p = 0 ⟷ p = 0" apply (cases "p = 0") (*goals: 1. ‹p = 0 ⟹ (Symmetric_Polynomials.lead_coeff p = 0) = (p = 0)› 2. ‹p ≠ 0 ⟹ (Symmetric_Polynomials.lead_coeff p = 0) = (p = 0)› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . lemma fixes f :: "_ ⇒ 'a :: semidom mpoly" assumes "⋀i. i ∈ A ⟹ f i ≠ 0" shows lead_monom_prod' [simp]: "lead_monom (∏i∈A. f i) = (∑i∈A. lead_monom (f i))" (is ?th1) and lead_coeff_prod' [simp]: "lead_coeff (∏i∈A. f i) = (∏i∈A. lead_coeff (f i))" (is ?th2) proof (-) (*goals: 1. ‹lead_monom (prod f A) = (∑i∈A. lead_monom (f i))› 2. ‹Symmetric_Polynomials.lead_coeff (prod f A) = (∏i∈A. Symmetric_Polynomials.lead_coeff (f i))›*) from assms (*‹?i ∈ A ⟹ f ?i ≠ 0›*) have "(∏i∈A. lead_coeff (f i)) ≠ 0" apply (cases "finite A") (*goals: 1. ‹⟦⋀i. i ∈ A ⟹ f i ≠ 0; finite A⟧ ⟹ (∏i∈A. Symmetric_Polynomials.lead_coeff (f i)) ≠ 0› 2. ‹⟦⋀i. i ∈ A ⟹ f i ≠ 0; infinite A⟧ ⟹ (∏i∈A. Symmetric_Polynomials.lead_coeff (f i)) ≠ 0› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . thus "?th1" "?th2" apply - (*goals: 1. ‹(∏i::'c∈(A::'c set). Symmetric_Polynomials.lead_coeff ((f::'c ⇒ 'a mpoly) i)) ≠ (0::'a) ⟹ lead_monom (prod f A) = (∑i::'c∈A. lead_monom (f i))› 2. ‹(∏i::'c∈(A::'c set). Symmetric_Polynomials.lead_coeff ((f::'c ⇒ 'a mpoly) i)) ≠ (0::'a) ⟹ Symmetric_Polynomials.lead_coeff (prod f A) = (∏i::'c∈A. Symmetric_Polynomials.lead_coeff (f i))› discuss goal 1*) apply (simp add: lead_monom_prod (*‹(∏i∈?A. Symmetric_Polynomials.lead_coeff (?f i)) ≠ 0 ⟹ lead_monom (prod ?f ?A) = (∑i∈?A. lead_monom (?f i))›*) lead_coeff_prod (*‹(∏i∈?A. Symmetric_Polynomials.lead_coeff (?f i)) ≠ 0 ⟹ Symmetric_Polynomials.lead_coeff (prod ?f ?A) = (∏i∈?A. Symmetric_Polynomials.lead_coeff (?f i))›*)) (*discuss goal 2*) apply (simp add: lead_monom_prod (*‹(∏i∈?A. Symmetric_Polynomials.lead_coeff (?f i)) ≠ 0 ⟹ lead_monom (prod ?f ?A) = (∑i∈?A. lead_monom (?f i))›*) lead_coeff_prod (*‹(∏i∈?A. Symmetric_Polynomials.lead_coeff (?f i)) ≠ 0 ⟹ Symmetric_Polynomials.lead_coeff (prod ?f ?A) = (∏i∈?A. Symmetric_Polynomials.lead_coeff (?f i))›*)) (*proven 2 subgoals*) . qed lemma fixes p :: "'a :: comm_semiring_1 mpoly" assumes "lead_coeff p ^ n ≠ 0" shows lead_monom_power: "lead_monom (p ^ n) = of_nat n * lead_monom p" and lead_coeff_power: "lead_coeff (p ^ n) = lead_coeff p ^ n" using assms (*‹Symmetric_Polynomials.lead_coeff p ^ n ≠ 0›*) lead_monom_prod[of "λ_. p" "{..<n}"] (*‹(∏i<n. Symmetric_Polynomials.lead_coeff p) ≠ 0 ⟹ lead_monom (∏i<n. p) = (∑i<n. lead_monom p)›*) lead_coeff_prod[of "λ_. p" "{..<n}"] (*‹(∏i::nat<n::nat. Symmetric_Polynomials.lead_coeff (p::'a mpoly)) ≠ (0::'a) ⟹ Symmetric_Polynomials.lead_coeff (∏i::nat<n. p) = (∏i::nat<n. Symmetric_Polynomials.lead_coeff p)›*) apply - (*goals: 1. ‹⟦Symmetric_Polynomials.lead_coeff p ^ n ≠ 0; (∏i<n. Symmetric_Polynomials.lead_coeff p) ≠ 0 ⟹ lead_monom (∏i<n. p) = (∑i<n. lead_monom p); (∏i<n. Symmetric_Polynomials.lead_coeff p) ≠ 0 ⟹ Symmetric_Polynomials.lead_coeff (∏i<n. p) = (∏i<n. Symmetric_Polynomials.lead_coeff p)⟧ ⟹ lead_monom (p ^ n) = of_nat n * lead_monom p› 2. ‹⟦Symmetric_Polynomials.lead_coeff p ^ n ≠ 0; (∏i<n. Symmetric_Polynomials.lead_coeff p) ≠ 0 ⟹ lead_monom (∏i<n. p) = (∑i<n. lead_monom p); (∏i<n. Symmetric_Polynomials.lead_coeff p) ≠ 0 ⟹ Symmetric_Polynomials.lead_coeff (∏i<n. p) = (∏i<n. Symmetric_Polynomials.lead_coeff p)⟧ ⟹ Symmetric_Polynomials.lead_coeff (p ^ n) = Symmetric_Polynomials.lead_coeff p ^ n› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) . lemma fixes p :: "'a :: semidom mpoly" assumes "p ≠ 0" shows lead_monom_power' [simp]: "lead_monom (p ^ n) = of_nat n * lead_monom p" and lead_coeff_power' [simp]: "lead_coeff (p ^ n) = lead_coeff p ^ n" using assms (*‹p ≠ 0›*) lead_monom_prod'[of "{..<n}" "λ_. p"] (*‹(⋀i. i ∈ {..<n} ⟹ p ≠ 0) ⟹ lead_monom (∏i<n. p) = (∑i<n. lead_monom p)›*) lead_coeff_prod'[of "{..<n}" "λ_. p"] (*‹(⋀i. i ∈ {..<n} ⟹ p ≠ 0) ⟹ Symmetric_Polynomials.lead_coeff (∏i<n. p) = (∏i<n. Symmetric_Polynomials.lead_coeff p)›*) apply - (*goals: 1. ‹⟦p ≠ 0; (⋀i. i ∈ {..<n} ⟹ p ≠ 0) ⟹ lead_monom (∏i<n. p) = (∑i<n. lead_monom p); (⋀i. i ∈ {..<n} ⟹ p ≠ 0) ⟹ Symmetric_Polynomials.lead_coeff (∏i<n. p) = (∏i<n. Symmetric_Polynomials.lead_coeff p)⟧ ⟹ lead_monom (p ^ n) = of_nat n * lead_monom p› 2. ‹⟦p ≠ 0; (⋀i. i ∈ {..<n} ⟹ p ≠ 0) ⟹ lead_monom (∏i<n. p) = (∑i<n. lead_monom p); (⋀i. i ∈ {..<n} ⟹ p ≠ 0) ⟹ Symmetric_Polynomials.lead_coeff (∏i<n. p) = (∏i<n. Symmetric_Polynomials.lead_coeff p)⟧ ⟹ Symmetric_Polynomials.lead_coeff (p ^ n) = Symmetric_Polynomials.lead_coeff p ^ n› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) . subsection ‹Turning a set of variables into a monomial› text ‹ Given a finite set $\{X_1,\ldots,X_n\}$ of variables, the following is the monomial $X_1\ldots X_n$: › lift_definition monom_of_set :: "nat set ⇒ (nat ⇒₀ nat)" is "λX x. if finite X ∧ x ∈ X then 1 else 0" by auto lemma lookup_monom_of_set: "Poly_Mapping.lookup (monom_of_set X) i = (if finite X ∧ i ∈ X then 1 else 0)" apply transfer (*goal: ‹lookup (monom_of_set X) i = (if finite X ∧ i ∈ X then 1 else 0)›*) by auto lemma lookup_monom_of_set_1 [simp]: "finite X ⟹ i ∈ X ⟹ Poly_Mapping.lookup (monom_of_set X) i = 1" and lookup_monom_of_set_0 [simp]: "i ∉ X ⟹ Poly_Mapping.lookup (monom_of_set X) i = 0" (*goals: 1. ‹⟦finite X; i ∈ X⟧ ⟹ lookup (monom_of_set X) i = 1› 2. ‹i ∉ X ⟹ lookup (monom_of_set X) i = 0› discuss goal 1*) apply (simp add: lookup_monom_of_set (*‹lookup (monom_of_set (?X::nat set)) (?i::nat) = (if finite ?X ∧ ?i ∈ ?X then 1::nat else (0::nat))›*)) (*discuss goal 2*) apply (simp add: lookup_monom_of_set (*‹lookup (monom_of_set ?X) ?i = (if finite ?X ∧ ?i ∈ ?X then 1 else 0)›*)) (*proven 2 subgoals*) . lemma keys_monom_of_set: "keys (monom_of_set X) = (if finite X then X else {})" apply transfer (*goal: ‹keys (monom_of_set X) = (if finite X then X else {})›*) by auto lemma keys_monom_of_set_finite [simp]: "finite X ⟹ keys (monom_of_set X) = X" by (simp add: keys_monom_of_set (*‹keys (monom_of_set ?X) = (if finite ?X then ?X else {})›*)) lemma monom_of_set_eq_iff [simp]: "finite X ⟹ finite Y ⟹ monom_of_set X = monom_of_set Y ⟷ X = Y" apply transfer (*goal: ‹⟦finite (X::nat set); finite (Y::nat set)⟧ ⟹ (monom_of_set X = monom_of_set Y) = (X = Y)›*) by (auto simp: fun_eq_iff (*‹(?f = ?g) = (∀x. ?f x = ?g x)›*)) lemma monom_of_set_empty [simp]: "monom_of_set {} = 0" apply transfer (*goal: ‹monom_of_set {} = 0›*) by auto lemma monom_of_set_eq_zero_iff [simp]: "monom_of_set X = 0 ⟷ infinite X ∨ X = {}" apply transfer (*goal: ‹(monom_of_set X = 0) = (infinite X ∨ X = {})›*) by (auto simp: fun_eq_iff (*‹(?f = ?g) = (∀x. ?f x = ?g x)›*)) lemma zero_eq_monom_of_set_iff [simp]: "0 = monom_of_set X ⟷ infinite X ∨ X = {}" apply transfer (*goal: ‹(0 = monom_of_set X) = (infinite X ∨ X = {})›*) by (auto simp: fun_eq_iff (*‹(?f = ?g) = (∀x. ?f x = ?g x)›*)) subsection ‹Permuting the variables of a polynomial› text ‹ Next, we define the operation of permuting the variables of a monomial and polynomial. › lift_definition permutep :: "('a ⇒ 'a) ⇒ ('a ⇒₀ 'b) ⇒ ('a ⇒₀ 'b :: zero)" is "λf p. if bij f then p ∘ f else p" proof - fix f :: "'a ⇒ 'a" and g :: "'a ⇒ 'b" assume *: "finite {x. g x ≠ 0}" show "finite {x. (if bij f then g ∘ f else g) x ≠ 0}" proof (cases "bij f") case True with * have "finite (f -` {x. g x ≠ 0})" by (intro finite_vimageI) (auto dest: bij_is_inj) with True show ?thesis by auto qed (use * in auto) qed lift_definition mpoly_map_vars :: "(nat ⇒ nat) ⇒ 'a :: zero mpoly ⇒ 'a mpoly" is "λf p. permutep (permutep f) p" . lemma keys_permutep: "bij f ⟹ keys (permutep f m) = f -` keys m" apply transfer (*goal: ‹bij f ⟹ keys (permutep f m) = f -` keys m›*) by auto lemma permutep_id'' [simp]: "permutep id = id" apply transfer' (*goal: ‹permutep id = id›*) by (auto simp: fun_eq_iff (*‹(?f = ?g) = (∀x. ?f x = ?g x)›*)) lemma permutep_id''' [simp]: "permutep (λx. x) = id" apply transfer' (*goal: ‹permutep (λx::'a. x) = id›*) by (auto simp: fun_eq_iff (*‹(?f = ?g) = (∀x. ?f x = ?g x)›*)) lemma permutep_0 [simp]: "permutep f 0 = 0" apply transfer (*goal: ‹permutep f 0 = 0›*) by auto lemma permutep_single: "bij f ⟹ permutep f (Poly_Mapping.single a b) = Poly_Mapping.single (inv_into UNIV f a) b" apply transfer (*goal: ‹bij f ⟹ permutep f (Poly_Mapping.single a b) = Poly_Mapping.single (inv f a) b›*) by (auto simp: fun_eq_iff (*‹(?f = ?g) = (∀x. ?f x = ?g x)›*) when_def (*‹(?a when ?P) = (if ?P then ?a else 0)›*) inv_f_f (*‹inj ?f ⟹ inv ?f (?f ?x) = ?x›*) surj_f_inv_f (*‹surj ?f ⟹ ?f (inv ?f ?y) = ?y›*) bij_is_inj (*‹bij ?f ⟹ inj ?f›*) bij_is_surj (*‹bij ?f ⟹ surj ?f›*)) lemma mpoly_map_vars_id [simp]: "mpoly_map_vars id = id" apply transfer (*goal: ‹mpoly_map_vars id = id›*) by auto lemma mpoly_map_vars_id' [simp]: "mpoly_map_vars (λx. x) = id" apply transfer (*goal: ‹mpoly_map_vars (λx. x) = id›*) by auto lemma lookup_permutep: "Poly_Mapping.lookup (permutep f m) x = (if bij f then Poly_Mapping.lookup m (f x) else Poly_Mapping.lookup m x)" apply transfer (*goal: ‹lookup (permutep f m) x = (if bij f then lookup m (f x) else lookup m x)›*) by auto lemma inj_permutep [intro]: "inj (permutep (f :: 'a ⇒ 'a) :: _ ⇒ 'a ⇒₀ 'b :: zero)" unfolding inj_def (*goal: ‹∀x y. permutep f x = permutep f y ⟶ x = y›*) apply transfer (*goal: ‹∀x y. permutep f x = permutep f y ⟶ x = y›*) proof (safe) (*goal: ‹⋀(f::'a ⇒ 'a) (x::'a ⇒ 'b) y::'a ⇒ 'b. ⟦finite {xa::'a. x xa ≠ (0::'b)}; finite {x::'a. y x ≠ (0::'b)}; (if bij f then x ∘ f else x) = (if bij f then y ∘ f else y)⟧ ⟹ x = y›*) fix f :: "'a ⇒ 'a" and x :: "'a ⇒ 'b" and y :: "'a ⇒ 'b" assume eq: "(if bij f then x ∘ f else x) = (if bij f then y ∘ f else y)" (*‹(if bij (f::'a ⇒ 'a) then (x::'a ⇒ 'b) ∘ f else x) = (if bij f then (y::'a ⇒ 'b) ∘ f else y)›*) show "x = y" proof (cases "bij f") (*goals: 1. ‹bij f ⟹ x = y› 2. ‹¬ bij f ⟹ x = y›*) case True (*‹bij f›*) show "?thesis" (*goal: ‹x = y›*) proof (standard) (*goal: ‹⋀xa. x xa = y xa›*) fix t :: 'a from ‹bij f› (*‹bij (f::'a ⇒ 'a)›*) obtain s where "t = f s" (*goal: ‹(⋀s. t = f s ⟹ thesis) ⟹ thesis›*) by (auto dest!: bij_is_surj (*‹bij ?f ⟹ surj ?f›*)) with eq (*‹(if bij f then x ∘ f else x) = (if bij f then y ∘ f else y)›*) True (*‹bij f›*) show "x t = y t" by (auto simp: fun_eq_iff (*‹(?f = ?g) = (∀x. ?f x = ?g x)›*)) qed qed (use eq in auto) (*solved the remaining goal: ‹¬ bij f ⟹ x = y›*) qed lemma surj_permutep [intro]: "surj (permutep (f :: 'a ⇒ 'a) :: _ ⇒ 'a ⇒₀ 'b :: zero)" unfolding surj_def (*goal: ‹∀y. ∃x. y = permutep f x›*) apply transfer (*goal: ‹∀y. ∃x. y = permutep f x›*) proof (safe) (*goal: ‹⋀(f::'a ⇒ 'a) y::'a ⇒ 'b. finite {x::'a. y x ≠ (0::'b)} ⟹ ∃x::'a ⇒ 'b∈{f::'a ⇒ 'b. finite {x::'a. f x ≠ (0::'b)}}. y = (if bij f then x ∘ f else x)›*) fix f :: "'a ⇒ 'a" and y :: "'a ⇒ 'b" assume fin: "finite {t. y t ≠ 0}" (*‹finite {t::'a. (y::'a ⇒ 'b) t ≠ (0::'b)}›*) show "∃x∈{f. finite {x. f x ≠ 0}}. y = (if bij f then x ∘ f else x)" proof (cases "bij f") (*goals: 1. ‹bij f ⟹ ∃x∈{f. finite {x. f x ≠ 0}}. y = (if bij f then x ∘ f else x)› 2. ‹¬ bij f ⟹ ∃x∈{f. finite {x. f x ≠ 0}}. y = (if bij f then x ∘ f else x)›*) case True (*‹bij f›*) with fin (*‹finite {t. y t ≠ 0}›*) have "finite (the_inv f -` {t. y t ≠ 0})" apply (intro finite_vimageI (*‹⟦finite (?F::?'a::type set); inj (?h::?'b::type ⇒ ?'a::type)⟧ ⟹ finite (?h -` ?F)›*)) (*goals: 1. ‹⟦finite {t::'a. (y::'a ⇒ 'b) t ≠ (0::'b)}; bij (f::'a ⇒ 'a)⟧ ⟹ finite {t::'a. y t ≠ (0::'b)}› 2. ‹⟦finite {t::'a. (y::'a ⇒ 'b) t ≠ (0::'b)}; bij (f::'a ⇒ 'a)⟧ ⟹ inj (the_inv f)› discuss goal 1*) apply ((auto simp: bij_is_inj (*‹bij ?f ⟹ inj ?f›*) bij_betw_the_inv_into (*‹bij_betw ?f ?A ?B ⟹ bij_betw (the_inv_into ?A ?f) ?B ?A›*))[1]) (*discuss goal 2*) apply ((auto simp: bij_is_inj (*‹bij ?f ⟹ inj ?f›*) bij_betw_the_inv_into (*‹bij_betw ?f ?A ?B ⟹ bij_betw (the_inv_into ?A ?f) ?B ?A›*))[1]) (*proven 2 subgoals*) . moreover have "y ∘ the_inv f ∘ f = y" using True (*‹bij f›*) by (simp add: fun_eq_iff (*‹(?f = ?g) = (∀x. ?f x = ?g x)›*) the_inv_f_f (*‹inj ?f ⟹ the_inv ?f (?f ?x) = ?x›*) bij_is_inj (*‹bij ?f ⟹ inj ?f›*)) ultimately show "?thesis" (*goal: ‹∃x∈{f. finite {x. f x ≠ 0}}. y = (if bij f then x ∘ f else x)›*) apply (intro bexI[of _ "y ∘ the_inv f"] (*‹⟦?P (y ∘ the_inv f); y ∘ the_inv f ∈ ?A⟧ ⟹ ∃x∈?A. ?P x›*)) (*goals: 1. ‹⟦finite (the_inv f -` {t. y t ≠ 0}); y ∘ the_inv f ∘ f = y⟧ ⟹ y = (if bij f then y ∘ the_inv f ∘ f else y ∘ the_inv f)› 2. ‹⟦finite (the_inv f -` {t. y t ≠ 0}); y ∘ the_inv f ∘ f = y⟧ ⟹ y ∘ the_inv f ∈ {f. finite {x. f x ≠ 0}}› discuss goal 1*) apply ((auto simp: True (*‹bij f›*))[1]) (*discuss goal 2*) apply ((auto simp: True (*‹bij (f::'a ⇒ 'a)›*))[1]) (*proven 2 subgoals*) . qed (use fin in auto) (*solved the remaining goal: ‹¬ bij f ⟹ ∃x∈{f. finite {x. f x ≠ 0}}. y = (if bij f then x ∘ f else x)›*) qed lemma bij_permutep [intro]: "bij (permutep f)" using inj_permutep[of f] (*‹inj (permutep (f::'a ⇒ 'a))›*) surj_permutep[of f] (*‹surj (permutep f)›*) by (simp add: bij_def (*‹bij (?f::?'a::type ⇒ ?'b::type) = (inj ?f ∧ surj ?f)›*)) lemma mpoly_map_vars_map_mpoly: "mpoly_map_vars f (map_mpoly g p) = map_mpoly g (mpoly_map_vars f p)" sorry lemma coeff_mpoly_map_vars: fixes f :: "nat ⇒ nat" and p :: "'a :: zero mpoly" assumes "bij f" shows "MPoly_Type.coeff (mpoly_map_vars f p) mon = MPoly_Type.coeff p (permutep f mon)" using assms (*‹bij f›*) apply transfer' (*goal: ‹MPoly_Type.coeff (mpoly_map_vars f p) mon = MPoly_Type.coeff p (permutep f mon)›*) by (simp add: lookup_permutep (*‹lookup (permutep (?f::?'b ⇒ ?'b) (?m::?'b ⇒₀ ?'a)) (?x::?'b) = (if bij ?f then lookup ?m (?f ?x) else lookup ?m ?x)›*) bij_permutep (*‹bij (permutep (?f::?'a ⇒ ?'a))›*)) lemma permutep_monom_of_set: assumes "bij f" shows "permutep f (monom_of_set A) = monom_of_set (f -` A)" using assms (*‹bij f›*) apply transfer (*goal: ‹permutep f (monom_of_set A) = monom_of_set (f -` A)›*) by (auto simp: fun_eq_iff (*‹(?f = ?g) = (∀x. ?f x = ?g x)›*) bij_is_inj (*‹bij ?f ⟹ inj ?f›*) finite_vimage_iff (*‹bij ?h ⟹ finite (?h -` ?F) = finite ?F›*)) lemma permutep_comp: "bij f ⟹ bij g ⟹ permutep (f ∘ g) = permutep g ∘ permutep f" apply transfer' (*goal: ‹⟦bij f; bij g⟧ ⟹ permutep (f ∘ g) = permutep g ∘ permutep f›*) by (auto simp: fun_eq_iff (*‹(?f = ?g) = (∀x. ?f x = ?g x)›*) bij_comp (*‹⟦bij ?f; bij ?g⟧ ⟹ bij (?g ∘ ?f)›*)) lemma permutep_comp': "bij f ⟹ bij g ⟹ permutep (f ∘ g) mon = permutep g (permutep f mon)" apply transfer (*goal: ‹⟦bij f; bij g⟧ ⟹ permutep (f ∘ g) mon = permutep g (permutep f mon)›*) by (auto simp: fun_eq_iff (*‹((?f::?'a ⇒ ?'b) = (?g::?'a ⇒ ?'b)) = (∀x::?'a. ?f x = ?g x)›*) bij_comp (*‹⟦bij (?f::?'a ⇒ ?'b); bij (?g::?'b ⇒ ?'c)⟧ ⟹ bij (?g ∘ ?f)›*)) lemma mpoly_map_vars_comp: "bij f ⟹ bij g ⟹ mpoly_map_vars f (mpoly_map_vars g p) = mpoly_map_vars (f ∘ g) p" apply transfer (*goal: ‹⟦bij f; bij g⟧ ⟹ mpoly_map_vars f (mpoly_map_vars g p) = mpoly_map_vars (f ∘ g) p›*) by (auto simp: bij_permutep (*‹bij (permutep ?f)›*) permutep_comp (*‹⟦bij ?f; bij ?g⟧ ⟹ permutep (?f ∘ ?g) = permutep ?g ∘ permutep ?f›*)) lemma permutep_id [simp]: "permutep id mon = mon" apply transfer (*goal: ‹permutep id mon = mon›*) by auto lemma permutep_id' [simp]: "permutep (λx. x) mon = mon" apply transfer (*goal: ‹permutep (λx. x) mon = mon›*) by auto lemma inv_permutep [simp]: fixes f :: "'a ⇒ 'a" assumes "bij f" shows "inv_into UNIV (permutep f) = permutep (inv_into UNIV f)" proof (standard) (*goal: ‹⋀x. inv (permutep f) x = permutep (inv f) x›*) fix m :: "'a ⇒₀ 'b" show "inv_into UNIV (permutep f) m = permutep (inv_into UNIV f) m" using permutep_comp'[of "inv_into UNIV f" f m] (*‹⟦bij (inv (f::'a::type ⇒ 'a::type)); bij f⟧ ⟹ permutep (inv f ∘ f) (m::'a::type ⇒₀ 'b::zero) = permutep f (permutep (inv f) m)›*) assms (*‹bij f›*) inj_iff[of f] (*‹inj (f::'a::type ⇒ 'a::type) = (inv f ∘ f = id)›*) apply (intro inv_f_eq (*‹⟦inj (?f::?'a ⇒ ?'b); ?f (?x::?'a) = (?y::?'b)⟧ ⟹ inv ?f ?y = ?x›*)) (*goals: 1. ‹⟦⟦bij (inv f); bij f⟧ ⟹ permutep (inv f ∘ f) m = permutep f (permutep (inv f) m); bij f; inj f = (inv f ∘ f = id)⟧ ⟹ inj (permutep f)› 2. ‹⟦⟦bij (inv f); bij f⟧ ⟹ permutep (inv f ∘ f) m = permutep f (permutep (inv f) m); bij f; inj f = (inv f ∘ f = id)⟧ ⟹ permutep f (permutep (inv f) m) = m› discuss goal 1*) apply ((auto simp: bij_imp_bij_inv (*‹bij ?f ⟹ bij (inv ?f)›*) bij_is_inj (*‹bij ?f ⟹ inj ?f›*))[1]) (*discuss goal 2*) apply ((auto simp: bij_imp_bij_inv (*‹bij ?f ⟹ bij (inv ?f)›*) bij_is_inj (*‹bij ?f ⟹ inj ?f›*))[1]) (*proven 2 subgoals*) . qed lemma mpoly_map_vars_monom: "bij f ⟹ mpoly_map_vars f (monom m c) = monom (permutep (inv_into UNIV f) m) c" apply transfer' (*goal: ‹bij f ⟹ mpoly_map_vars f (MPoly_Type.monom m c) = MPoly_Type.monom (permutep (inv f) m) c›*) by (simp add: permutep_single (*‹bij ?f ⟹ permutep ?f (Poly_Mapping.single ?a ?b) = Poly_Mapping.single (inv ?f ?a) ?b›*) bij_permutep (*‹bij (permutep ?f)›*)) lemma vars_mpoly_map_vars: fixes f :: "nat ⇒ nat" and p :: "'a :: zero mpoly" assumes "bij f" shows "vars (mpoly_map_vars f p) = f ` vars p" using assms (*‹bij f›*) unfolding vars_def (*goal: ‹⋃ (keys ` keys (mapping_of (mpoly_map_vars (f::nat ⇒ nat) (p::'a mpoly)))) = f ` ⋃ (keys ` keys (mapping_of p))›*) proof (transfer') (*goal: ‹⋀f p. bij f ⟹ ⋃ (keys ` keys (permutep (permutep f) p)) = f ` ⋃ (keys ` keys p)›*) fix f :: "nat ⇒ nat" and p :: "(nat ⇒₀ nat) ⇒₀ 'a" assume f: "bij f" (*‹bij (f::nat ⇒ nat)›*) have eq: "f (inv_into UNIV f x) = x" for x using f (*‹bij f›*) apply (subst surj_f_inv_f[of f] (*‹surj f ⟹ f (inv f ?y) = ?y›*)) (*goals: 1. ‹bij f ⟹ surj f› 2. ‹bij f ⟹ x = x› discuss goal 1*) apply ((auto simp: bij_is_surj (*‹bij ?f ⟹ surj ?f›*))[1]) (*discuss goal 2*) apply ((auto simp: bij_is_surj (*‹bij ?f ⟹ surj ?f›*))[1]) (*proven 2 subgoals*) . show "⋃ (keys ` keys (permutep (permutep f) p)) = f ` ⋃ (keys ` keys p)" proof (safe) (*goals: 1. ‹⋀x xa. ⟦xa ∈ keys (permutep (permutep f) p); x ∈ keys xa⟧ ⟹ x ∈ f ` ⋃ (keys ` keys p)› 2. ‹⋀x xa xb. ⟦xb ∈ keys p; xa ∈ keys xb⟧ ⟹ f xa ∈ ⋃ (keys ` keys (permutep (permutep f) p))›*) fix m and x assume mx: "m ∈ keys (permutep (permutep f) p)" "x ∈ keys m" (*‹(m::nat ⇒₀ nat) ∈ keys (permutep (permutep (f::nat ⇒ nat)) (p::(nat ⇒₀ nat) ⇒₀ 'a))› ‹(x::nat) ∈ keys (m::nat ⇒₀ nat)›*) from mx (*‹m ∈ keys (permutep (permutep f) p)› ‹(x::nat) ∈ keys (m::nat ⇒₀ nat)›*) have "permutep f m ∈ keys p" by (auto simp: keys_permutep (*‹bij ?f ⟹ keys (permutep ?f ?m) = ?f -` keys ?m›*) bij_permutep (*‹bij (permutep ?f)›*) f (*‹bij f›*)) with mx (*‹m ∈ keys (permutep (permutep f) p)› ‹x ∈ keys m›*) have "f (inv_into UNIV f x) ∈ f ` (⋃m∈keys p. keys m)" apply (intro imageI (*‹?x ∈ ?A ⟹ ?f ?x ∈ ?f ` ?A›*)) (*goal: ‹f (inv f x) ∈ f ` ⋃ (keys ` keys p)›*) by (auto intro!: bexI[of _ "permutep f m"] (*‹⟦?P (permutep f m); permutep f m ∈ ?A⟧ ⟹ ∃x∈?A. ?P x›*) simp: keys_permutep (*‹bij ?f ⟹ keys (permutep ?f ?m) = ?f -` keys ?m›*) f (*‹bij f›*) eq (*‹f (inv f ?x) = ?x›*)) with eq (*‹f (inv f ?x) = ?x›*) show "x ∈ f ` (⋃m∈keys p. keys m)" by simp next (*goal: ‹⋀x xa xb. ⟦xb ∈ keys p; xa ∈ keys xb⟧ ⟹ f xa ∈ ⋃ (keys ` keys (permutep (permutep f) p))›*) fix m and x assume mx: "m ∈ keys p" "x ∈ keys m" (*‹(m::nat ⇒₀ nat) ∈ keys (p::(nat ⇒₀ nat) ⇒₀ 'a)› ‹(x::nat) ∈ keys (m::nat ⇒₀ nat)›*) from mx (*‹m ∈ keys p› ‹(x::nat) ∈ keys (m::nat ⇒₀ nat)›*) have "permutep id m ∈ keys p" by simp also (*calculation: ‹permutep id m ∈ keys p›*) have "id = inv_into UNIV f ∘ f" using f (*‹bij (f::nat ⇒ nat)›*) apply (intro ext (*‹(⋀x. ?f x = ?g x) ⟹ ?f = ?g›*)) (*goal: ‹id = inv (f::nat ⇒ nat) ∘ f›*) by (auto simp: bij_is_inj (*‹bij ?f ⟹ inj ?f›*) inv_f_f (*‹inj ?f ⟹ inv ?f (?f ?x) = ?x›*)) also (*calculation: ‹permutep (inv f ∘ f) m ∈ keys p›*) have "permutep … m = permutep f (permutep (inv_into UNIV f) m)" by (simp add: permutep_comp (*‹⟦bij ?f; bij ?g⟧ ⟹ permutep (?f ∘ ?g) = permutep ?g ∘ permutep ?f›*) f (*‹bij f›*) bij_imp_bij_inv (*‹bij ?f ⟹ bij (inv ?f)›*)) finally (*calculation: ‹permutep f (permutep (inv f) m) ∈ keys p›*) have "**": "permutep f (permutep (inv_into UNIV f) m) ∈ keys p" . moreover from f (*‹bij f›*) mx (*‹m ∈ keys p› ‹x ∈ keys m›*) have "f x ∈ keys (permutep (inv_into UNIV f) m)" by (auto simp: keys_permutep (*‹bij ?f ⟹ keys (permutep ?f ?m) = ?f -` keys ?m›*) bij_imp_bij_inv (*‹bij ?f ⟹ bij (inv ?f)›*) inv_f_f (*‹inj ?f ⟹ inv ?f (?f ?x) = ?x›*) bij_is_inj (*‹bij ?f ⟹ inj ?f›*)) ultimately show "f x ∈ ⋃ (keys ` keys (permutep (permutep f) p))" using f (*‹bij f›*) by (auto simp: keys_permutep (*‹bij ?f ⟹ keys (permutep ?f ?m) = ?f -` keys ?m›*) bij_permutep (*‹bij (permutep ?f)›*)) qed qed lemma permutep_eq_monom_of_set_iff [simp]: assumes "bij f" shows "permutep f mon = monom_of_set A ⟷ mon = monom_of_set (f ` A)" proof (standard) (*goals: 1. ‹permutep f mon = monom_of_set A ⟹ mon = monom_of_set (f ` A)› 2. ‹mon = monom_of_set (f ` A) ⟹ permutep f mon = monom_of_set A›*) assume eq: "permutep f mon = monom_of_set A" (*‹permutep (f::nat ⇒ nat) (mon::nat ⇒₀ nat) = monom_of_set (A::nat set)›*) have "permutep (inv_into UNIV f) (permutep f mon) = monom_of_set (inv_into UNIV f -` A)" using assms (*‹bij f›*) by (simp add: eq (*‹permutep f mon = monom_of_set A›*) bij_imp_bij_inv (*‹bij ?f ⟹ bij (inv ?f)›*) assms (*‹bij f›*) permutep_monom_of_set (*‹bij ?f ⟹ permutep ?f (monom_of_set ?A) = monom_of_set (?f -` ?A)›*)) also (*calculation: ‹permutep (inv (f::nat ⇒ nat)) (permutep f (mon::nat ⇒₀ nat)) = monom_of_set (inv f -` (A::nat set))›*) have "inv_into UNIV f -` A = f ` A" using assms (*‹bij f›*) by (force simp: bij_is_surj (*‹bij (?f::?'a::type ⇒ ?'b::type) ⟹ surj ?f›*) image_iff (*‹((?z::?'a::type) ∈ (?f::?'b::type ⇒ ?'a::type) ` (?A::?'b::type set)) = (∃x::?'b::type∈?A. ?z = ?f x)›*) inv_f_f (*‹inj (?f::?'a::type ⇒ ?'b::type) ⟹ inv ?f (?f (?x::?'a::type)) = ?x›*) bij_is_inj (*‹bij (?f::?'a::type ⇒ ?'b::type) ⟹ inj ?f›*) surj_f_inv_f (*‹surj (?f::?'b::type ⇒ ?'a::type) ⟹ ?f (inv ?f (?y::?'a::type)) = ?y›*)) also (*calculation: ‹permutep (inv (f::nat ⇒ nat)) (permutep f (mon::nat ⇒₀ nat)) = monom_of_set (f ` (A::nat set))›*) have "permutep (inv_into UNIV f) (permutep f mon) = permutep (f ∘ inv_into UNIV f) mon" using assms (*‹bij f›*) by (simp add: permutep_comp (*‹⟦bij (?f::?'a::type ⇒ ?'a::type); bij (?g::?'a::type ⇒ ?'a::type)⟧ ⟹ permutep (?f ∘ ?g) = permutep ?g ∘ permutep ?f›*) bij_imp_bij_inv (*‹bij (?f::?'a::type ⇒ ?'b::type) ⟹ bij (inv ?f)›*)) also (*calculation: ‹permutep (f ∘ inv f) mon = monom_of_set (f ` A)›*) have "f ∘ inv_into UNIV f = id" apply (subst surj_iff [symmetric] (*‹(?f ∘ inv ?f = id) = surj ?f›*)) (*goal: ‹f ∘ inv f = id›*) apply (insert assms (*‹bij f›*)) (*goal: ‹surj (f::nat ⇒ nat)›*) by (auto simp: bij_is_surj (*‹bij ?f ⟹ surj ?f›*)) finally (*calculation: ‹permutep id mon = monom_of_set (f ` A)›*) show "mon = monom_of_set (f ` A)" by simp qed (insert assms (*‹bij f›*), auto simp: permutep_monom_of_set (*‹bij ?f ⟹ permutep ?f (monom_of_set ?A) = monom_of_set (?f -` ?A)›*) inj_vimage_image_eq (*‹inj ?f ⟹ ?f -` ?f ` ?A = ?A›*) bij_is_inj (*‹bij ?f ⟹ inj ?f›*)) (*solved the remaining goal: ‹mon = monom_of_set (f ` A) ⟹ permutep f mon = monom_of_set A›*) lemma permutep_monom_of_set_permutes [simp]: assumes "π permutes A" shows "permutep π (monom_of_set A) = monom_of_set A" using assms (*‹π permutes A›*) apply transfer (*goal: ‹permutep π (monom_of_set A) = monom_of_set A›*) by (auto simp: 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))›*) fun_eq_iff (*‹(?f = ?g) = (∀x. ?f x = ?g x)›*) permutes_in_image (*‹?p permutes ?S ⟹ (?p ?x ∈ ?S) = (?x ∈ ?S)›*)) lemma mpoly_map_vars_0 [simp]: "mpoly_map_vars f 0 = 0" apply transfer (*goal: ‹mpoly_map_vars f 0 = 0›*) apply transfer' (*goal: ‹⋀f::nat ⇒ nat. permutep (permutep f) (0::(nat ⇒₀ nat) ⇒₀ 'a) = (0::(nat ⇒₀ nat) ⇒₀ 'a)›*) by (simp add: o_def (*‹?f ∘ ?g = (λx. ?f (?g x))›*)) lemma permutep_eq_0_iff [simp]: "permutep f m = 0 ⟷ m = 0" proof (transfer) (*goal: ‹⋀f m. finite {x. m x ≠ 0} ⟹ ((if bij f then m ∘ f else m) = (λk. 0)) = (m = (λk. 0))›*) fix f :: "'a ⇒ 'a" and m :: "'a ⇒ 'b" assume "finite {x. m x ≠ 0}" (*‹finite {x::'a. (m::'a ⇒ 'b) x ≠ (0::'b)}›*) show "((if bij f then m ∘ f else m) = (λk. 0)) = (m = (λk. 0))" proof (cases "bij f") (*goals: 1. ‹bij f ⟹ ((if bij f then m ∘ f else m) = (λk. 0)) = (m = (λk. 0))› 2. ‹¬ bij f ⟹ ((if bij f then m ∘ f else m) = (λk. 0)) = (m = (λk. 0))›*) case True (*‹bij f›*) hence "(∀x. m (f x) = 0) ⟷ (∀x. m x = 0)" using bij_iff[of f] (*‹bij f = (∀x. ∃!y. f y = x)›*) by metis with True (*‹bij f›*) show "?thesis" (*goal: ‹((if bij f then m ∘ f else m) = (λk. 0)) = (m = (λk. 0))›*) by (auto simp: fun_eq_iff (*‹(?f = ?g) = (∀x. ?f x = ?g x)›*)) qed (auto simp: fun_eq_iff (*‹(?f = ?g) = (∀x. ?f x = ?g x)›*)) (*solved the remaining goal: ‹¬ bij (f::'a ⇒ 'a) ⟹ ((if bij f then (m::'a ⇒ 'b) ∘ f else m) = (λk::'a. 0::'b)) = (m = (λk::'a. 0::'b))›*) qed lemma mpoly_map_vars_1 [simp]: "mpoly_map_vars f 1 = 1" apply transfer (*goal: ‹mpoly_map_vars f 1 = 1›*) apply transfer' (*goal: ‹⋀f::nat ⇒ nat. permutep (permutep f) (1::(nat ⇒₀ nat) ⇒₀ 'a) = (1::(nat ⇒₀ nat) ⇒₀ 'a)›*) by (auto simp: o_def (*‹?f ∘ ?g = (λx. ?f (?g x))›*) fun_eq_iff (*‹(?f = ?g) = (∀x. ?f x = ?g x)›*) when_def (*‹(?a when ?P) = (if ?P then ?a else 0)›*)) lemma permutep_Const₀ [simp]: "(⋀x. f x = 0 ⟷ x = 0) ⟹ permutep f (Const₀ c) = Const₀ c" unfolding "Const₀_def" (*goal: ‹(⋀x::'a::type ⇒₀ nat. ((f::('a::type ⇒₀ nat) ⇒ 'a::type ⇒₀ nat) x = (0::'a::type ⇒₀ nat)) = (x = (0::'a::type ⇒₀ nat))) ⟹ permutep f (Poly_Mapping.single (0::'a::type ⇒₀ nat) (c::'b::zero)) = Poly_Mapping.single (0::'a::type ⇒₀ nat) c›*) apply transfer' (*goal: ‹(⋀x. (f x = 0) = (x = 0)) ⟹ permutep f (Poly_Mapping.single 0 c) = Poly_Mapping.single 0 c›*) by (auto simp: when_def (*‹(?a when ?P) = (if ?P then ?a else 0)›*) fun_eq_iff (*‹(?f = ?g) = (∀x. ?f x = ?g x)›*)) lemma permutep_add [simp]: "permutep f (m1 + m2) = permutep f m1 + permutep f m2" unfolding "Const₀_def" (*goal: ‹permutep f (m1 + m2) = permutep f m1 + permutep f m2›*) apply transfer' (*goal: ‹permutep f (m1 + m2) = permutep f m1 + permutep f m2›*) by (auto simp: when_def (*‹(?a when ?P) = (if ?P then ?a else 0)›*) fun_eq_iff (*‹(?f = ?g) = (∀x. ?f x = ?g x)›*)) lemma permutep_diff [simp]: "permutep f (m1 - m2) = permutep f m1 - permutep f m2" unfolding "Const₀_def" (*goal: ‹permutep f (m1 - m2) = permutep f m1 - permutep f m2›*) apply transfer' (*goal: ‹permutep (f::'a ⇒ 'a) ((m1::'a ⇒₀ 'b) - (m2::'a ⇒₀ 'b)) = permutep f m1 - permutep f m2›*) by (auto simp: when_def (*‹(?a when ?P) = (if ?P then ?a else 0)›*) fun_eq_iff (*‹(?f = ?g) = (∀x. ?f x = ?g x)›*)) lemma permutep_uminus [simp]: "permutep f (-m) = -permutep f m" unfolding "Const₀_def" (*goal: ‹permutep f (- m) = - permutep f m›*) apply transfer' (*goal: ‹permutep f (- m) = - permutep f m›*) by (auto simp: when_def (*‹((?a::?'a) when (?P::bool)) = (if ?P then ?a else (0::?'a))›*) fun_eq_iff (*‹((?f::?'a ⇒ ?'b) = (?g::?'a ⇒ ?'b)) = (∀x::?'a. ?f x = ?g x)›*)) lemma permutep_mult [simp]: "(⋀x y. f (x + y) = f x + f y) ⟹ permutep f (m1 * m2) = permutep f m1 * permutep f m2" unfolding "Const₀_def" (*goal: ‹(⋀x y. f (x + y) = f x + f y) ⟹ permutep f (m1 * m2) = permutep f m1 * permutep f m2›*) apply transfer' (*goal: ‹(⋀x y. f (x + y) = f x + f y) ⟹ permutep f (m1 * m2) = permutep f m1 * permutep f m2›*) by (auto simp: when_def (*‹(?a when ?P) = (if ?P then ?a else 0)›*) fun_eq_iff (*‹(?f = ?g) = (∀x. ?f x = ?g x)›*) prod_fun_compose_bij (*‹⟦bij ?f; ⋀x y. ?f (x + y) = ?f x + ?f y⟧ ⟹ prod_fun ?m1.0 ?m2.0 (?f ?x) = prod_fun (?m1.0 ∘ ?f) (?m2.0 ∘ ?f) ?x›*)) lemma mpoly_map_vars_Const [simp]: "mpoly_map_vars f (Const c) = Const c" apply transfer (*goal: ‹mpoly_map_vars f (Const c) = Const c›*) by (auto simp: o_def (*‹?f ∘ ?g = (λx. ?f (?g x))›*) fun_eq_iff (*‹(?f = ?g) = (∀x. ?f x = ?g x)›*) when_def (*‹(?a when ?P) = (if ?P then ?a else 0)›*)) lemma mpoly_map_vars_add [simp]: "mpoly_map_vars f (p + q) = mpoly_map_vars f p + mpoly_map_vars f q" apply transfer (*goal: ‹mpoly_map_vars (f::nat ⇒ nat) ((p::'a mpoly) + (q::'a mpoly)) = mpoly_map_vars f p + mpoly_map_vars f q›*) by simp lemma mpoly_map_vars_diff [simp]: "mpoly_map_vars f (p - q) = mpoly_map_vars f p - mpoly_map_vars f q" apply transfer (*goal: ‹mpoly_map_vars f (p - q) = mpoly_map_vars f p - mpoly_map_vars f q›*) by simp lemma mpoly_map_vars_uminus [simp]: "mpoly_map_vars f (-p) = -mpoly_map_vars f p" apply transfer (*goal: ‹mpoly_map_vars f (- p) = - mpoly_map_vars f p›*) by simp lemma permutep_smult: "permutep (permutep f) (Poly_Mapping.map ((*) c) p) = Poly_Mapping.map ((*) c) (permutep (permutep f) p)" apply transfer' (*goal: ‹permutep (permutep (f::'a ⇒ 'a)) (Poly_Mapping.map ((*) (c::'c)) (p::('a ⇒₀ 'b) ⇒₀ 'c)) = Poly_Mapping.map ((*) c) (permutep (permutep f) p)›*) 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: fun_eq_iff (*‹(?f = ?g) = (∀x. ?f x = ?g x)›*)) lemma mpoly_map_vars_smult [simp]: "mpoly_map_vars f (smult c p) = smult c (mpoly_map_vars f p)" apply transfer (*goal: ‹mpoly_map_vars (f::nat ⇒ nat) (MPoly_Type.smult (c::'a::{times,zero}) (p::'a::{times,zero} mpoly)) = MPoly_Type.smult c (mpoly_map_vars f p)›*) by (simp add: permutep_smult (*‹permutep (permutep ?f) (Poly_Mapping.map ((*) ?c) ?p) = Poly_Mapping.map ((*) ?c) (permutep (permutep ?f) ?p)›*)) lemma mpoly_map_vars_mult [simp]: "mpoly_map_vars f (p * q) = mpoly_map_vars f p * mpoly_map_vars f q" apply transfer (*goal: ‹mpoly_map_vars (f::nat ⇒ nat) ((p::'a::semiring_0 mpoly) * (q::'a::semiring_0 mpoly)) = mpoly_map_vars f p * mpoly_map_vars f q›*) by simp lemma mpoly_map_vars_sum [simp]: "mpoly_map_vars f (sum g A) = (∑x∈A. mpoly_map_vars f (g x))" apply (induction 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 ⟹ mpoly_map_vars f (sum g A) = (∑x∈A. mpoly_map_vars f (g x))› 2. ‹mpoly_map_vars f (sum g {}) = (∑x∈{}. mpoly_map_vars f (g x))› 3. ‹⋀x F. ⟦finite F; x ∉ F; mpoly_map_vars f (sum g F) = (∑x∈F. mpoly_map_vars f (g x))⟧ ⟹ mpoly_map_vars f (sum g (insert x F)) = (∑x∈insert x F. mpoly_map_vars f (g x))› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*proven 3 subgoals*) . lemma mpoly_map_vars_prod [simp]: "mpoly_map_vars f (prod g A) = (∏x∈A. mpoly_map_vars f (g x))" apply (induction 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 ⟹ mpoly_map_vars f (prod g A) = (∏x∈A. mpoly_map_vars f (g x))› 2. ‹mpoly_map_vars f (prod g {}) = (∏x∈{}. mpoly_map_vars f (g x))› 3. ‹⋀x F. ⟦finite F; x ∉ F; mpoly_map_vars f (prod g F) = (∏x∈F. mpoly_map_vars f (g x))⟧ ⟹ mpoly_map_vars f (prod g (insert x F)) = (∏x∈insert x F. mpoly_map_vars f (g x))› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*proven 3 subgoals*) . lemma mpoly_map_vars_eq_0_iff [simp]: "mpoly_map_vars f p = 0 ⟷ p = 0" sorry lemma permutep_eq_iff [simp]: "permutep f p = permutep f q ⟷ p = q" apply transfer (*goal: ‹(permutep f p = permutep f q) = (p = q)›*) by (auto simp: comp_bij_eq_iff (*‹bij ?f ⟹ (?g ∘ ?f = ?h ∘ ?f) = (?g = ?h)›*)) lemma mpoly_map_vars_Sum_any [simp]: "mpoly_map_vars f (Sum_any g) = Sum_any (λx. mpoly_map_vars f (g x))" by (simp add: Sum_any.expand_set (*‹Sum_any ?g = sum ?g {a. ?g a ≠ 0}›*)) lemma mpoly_map_vars_power [simp]: "mpoly_map_vars f (p ^ n) = mpoly_map_vars f p ^ n" apply (induction n) (*goals: 1. ‹mpoly_map_vars f (p ^ 0) = mpoly_map_vars f p ^ 0› 2. ‹⋀n. mpoly_map_vars f (p ^ n) = mpoly_map_vars f p ^ n ⟹ mpoly_map_vars f (p ^ Suc n) = mpoly_map_vars f p ^ Suc n› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . lemma mpoly_map_vars_monom_single [simp]: assumes "bij f" shows "mpoly_map_vars f (monom (Poly_Mapping.single i n) c) = monom (Poly_Mapping.single (f i) n) c" using assms (*‹bij f›*) by (simp add: mpoly_map_vars_monom (*‹bij ?f ⟹ mpoly_map_vars ?f (MPoly_Type.monom ?m ?c) = MPoly_Type.monom (permutep (inv ?f) ?m) ?c›*) permutep_single (*‹bij ?f ⟹ permutep ?f (Poly_Mapping.single ?a ?b) = Poly_Mapping.single (inv ?f ?a) ?b›*) bij_imp_bij_inv (*‹bij ?f ⟹ bij (inv ?f)›*) inv_inv_eq (*‹bij ?f ⟹ inv (inv ?f) = ?f›*)) lemma insertion_mpoly_map_vars: assumes "bij f" shows "insertion g (mpoly_map_vars f p) = insertion (g ∘ f) p" proof (-) (*goal: ‹insertion (g::nat ⇒ 'a) (mpoly_map_vars (f::nat ⇒ nat) (p::'a mpoly)) = insertion (g ∘ f) p›*) have "insertion g (mpoly_map_vars f p) = (∑m. coeff p (permutep f m) * (∏i. g i ^ lookup m i))" using assms (*‹bij f›*) by (simp add: insertion_altdef (*‹insertion (?f::nat ⇒ ?'a::comm_semiring_1) (?p::?'a::comm_semiring_1 mpoly) = (∑m::nat ⇒₀ nat. MPoly_Type.coeff ?p m * (∏i::nat. ?f i ^ lookup m i))›*) coeff_mpoly_map_vars (*‹bij (?f::nat ⇒ nat) ⟹ MPoly_Type.coeff (mpoly_map_vars ?f (?p::?'a::zero mpoly)) (?mon::nat ⇒₀ nat) = MPoly_Type.coeff ?p (permutep ?f ?mon)›*)) also (*calculation: ‹insertion g (mpoly_map_vars f p) = (∑m. MPoly_Type.coeff p (permutep f m) * (∏i. g i ^ lookup m i))›*) have "… = Sum_any (λm. coeff p (permutep f m) * Prod_any (λi. g (f i) ^ lookup m (f i)))" apply (intro Sum_any.cong (*‹(⋀a. ?g a = ?h a) ⟹ Sum_any ?g = Sum_any ?h›*) arg_cong[where ?f = "λy. x * y" for x] (*‹?x = ?y ⟹ ?x4 * ?x = ?x4 * ?y›*) Prod_any.reindex_cong[OF assms] (*‹?g ∘ f = ?h ⟹ Prod_any ?g = Prod_any ?h›*)) (*goal: ‹(∑m::nat ⇒₀ nat. MPoly_Type.coeff (p::'a mpoly) (permutep (f::nat ⇒ nat) m) * (∏i::nat. (g::nat ⇒ 'a) i ^ lookup m i)) = (∑m::nat ⇒₀ nat. MPoly_Type.coeff p (permutep f m) * (∏i::nat. g (f i) ^ lookup m (f i)))›*) by (auto simp: o_def (*‹?f ∘ ?g = (λx. ?f (?g x))›*)) also (*calculation: ‹insertion (g::nat ⇒ 'a::comm_semiring_1) (mpoly_map_vars (f::nat ⇒ nat) (p::'a::comm_semiring_1 mpoly)) = (∑m::nat ⇒₀ nat. MPoly_Type.coeff p (permutep f m) * (∏i::nat. g (f i) ^ lookup m (f i)))›*) have "… = Sum_any (λm. coeff p m * (∏i. g (f i) ^ lookup m i))" apply (intro Sum_any.reindex_cong [OF bij_permutep[of f], symmetric] (*‹?g ∘ permutep f = ?h ⟹ Sum_any ?h = Sum_any ?g›*)) (*goal: ‹(∑m. MPoly_Type.coeff p (permutep f m) * (∏i. g (f i) ^ lookup m (f i))) = (∑m. MPoly_Type.coeff p m * (∏i. g (f i) ^ lookup m i))›*) by (auto simp: o_def (*‹?f ∘ ?g = (λx. ?f (?g x))›*) lookup_permutep (*‹lookup (permutep ?f ?m) ?x = (if bij ?f then lookup ?m (?f ?x) else lookup ?m ?x)›*) assms (*‹bij f›*)) also (*calculation: ‹insertion g (mpoly_map_vars f p) = (∑m. MPoly_Type.coeff p m * (∏i. g (f i) ^ lookup m i))›*) have "… = insertion (g ∘ f) p" by (simp add: insertion_altdef (*‹insertion (?f::nat ⇒ ?'a) (?p::?'a mpoly) = (∑m::nat ⇒₀ nat. MPoly_Type.coeff ?p m * (∏i::nat. ?f i ^ lookup m i))›*)) finally (*calculation: ‹insertion g (mpoly_map_vars f p) = insertion (g ∘ f) p›*) show "?thesis" (*goal: ‹insertion g (mpoly_map_vars f p) = insertion (g ∘ f) p›*) . qed lemma permutep_cong: assumes "f permutes (-keys p)" "g permutes (-keys p)" "p = q" shows "permutep f p = permutep g q" proof (intro poly_mapping_eqI (*‹(⋀k::?'a. lookup (?f::?'a ⇒₀ ?'b) k = lookup (?g::?'a ⇒₀ ?'b) k) ⟹ ?f = ?g›*)) (*goal: ‹⋀k. lookup (permutep f p) k = lookup (permutep g q) k›*) fix k :: 'a show "lookup (permutep f p) k = lookup (permutep g q) k" proof (cases "k ∈ keys p") (*goals: 1. ‹k ∈ keys p ⟹ lookup (permutep f p) k = lookup (permutep g q) k› 2. ‹k ∉ keys p ⟹ lookup (permutep f p) k = lookup (permutep g q) k›*) case False (*‹k ∉ keys p›*) with assms (*‹f permutes - keys p› ‹g permutes - keys p› ‹p = q›*) have "f k ∉ keys p" "g k ∉ keys p" using permutes_in_image[of _ "-keys p" k] (*‹?p permutes - keys p ⟹ (?p k ∈ - keys p) = (k ∈ - keys p)›*) apply - (*goals: 1. ‹⟦f permutes - keys p; g permutes - keys p; p = q; k ∉ keys p; ⋀pa. pa permutes - keys p ⟹ (pa k ∈ - keys p) = (k ∈ - keys p)⟧ ⟹ f k ∉ keys p› 2. ‹⟦f permutes - keys p; g permutes - keys p; p = q; k ∉ keys p; ⋀pa. pa permutes - keys p ⟹ (pa k ∈ - keys p) = (k ∈ - keys p)⟧ ⟹ g k ∉ keys p› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . thus "?thesis" (*goal: ‹lookup (permutep f p) k = lookup (permutep g q) k›*) using assms (*‹f permutes - keys p› ‹g permutes - keys p› ‹p = q›*) by (auto simp: lookup_permutep (*‹lookup (permutep ?f ?m) ?x = (if bij ?f then lookup ?m (?f ?x) else lookup ?m ?x)›*) permutes_bij (*‹?p permutes ?S ⟹ bij ?p›*) in_keys_iff (*‹(?x ∈ keys ?s) = (lookup ?s ?x ≠ 0)›*)) qed (insert assms (*‹f permutes - keys p› ‹g permutes - keys p› ‹p = q›*), auto simp: lookup_permutep (*‹lookup (permutep ?f ?m) ?x = (if bij ?f then lookup ?m (?f ?x) else lookup ?m ?x)›*) permutes_bij (*‹?p permutes ?S ⟹ bij ?p›*) permutes_not_in (*‹⟦?p permutes ?S; ?x ∉ ?S⟧ ⟹ ?p ?x = ?x›*)) (*solved the remaining goal: ‹k ∈ keys p ⟹ lookup (permutep f p) k = lookup (permutep g q) k›*) qed lemma mpoly_map_vars_cong: assumes "f permutes (-vars p)" "g permutes (-vars q)" "p = q" shows "mpoly_map_vars f p = mpoly_map_vars g (q :: 'a :: zero mpoly)" proof (intro mpoly_eqI (*‹(⋀mon. MPoly_Type.coeff ?p mon = MPoly_Type.coeff ?q mon) ⟹ ?p = ?q›*)) (*goal: ‹⋀mon::nat ⇒₀ nat. MPoly_Type.coeff (mpoly_map_vars (f::nat ⇒ nat) (p::'a mpoly)) mon = MPoly_Type.coeff (mpoly_map_vars (g::nat ⇒ nat) (q::'a mpoly)) mon›*) fix mon :: "nat ⇒₀ nat" show "coeff (mpoly_map_vars f p) mon = coeff (mpoly_map_vars g q) mon" proof (cases "keys mon ⊆ vars p") (*goals: 1. ‹keys mon ⊆ vars p ⟹ MPoly_Type.coeff (mpoly_map_vars f p) mon = MPoly_Type.coeff (mpoly_map_vars g q) mon› 2. ‹¬ keys mon ⊆ vars p ⟹ MPoly_Type.coeff (mpoly_map_vars f p) mon = MPoly_Type.coeff (mpoly_map_vars g q) mon›*) case True (*‹keys mon ⊆ vars p›*) with assms (*‹f permutes - vars p› ‹g permutes - vars q› ‹(p::'a mpoly) = (q::'a mpoly)›*) have "permutep f mon = permutep g mon" apply (intro permutep_cong (*‹⟦?f permutes - keys ?p; ?g permutes - keys ?p; ?p = ?q⟧ ⟹ permutep ?f ?p = permutep ?g ?q›*) assms(1,2)[THEN permutes_subset] (*‹- vars p ⊆ ?T ⟹ f permutes ?T› ‹- vars q ⊆ ?T ⟹ g permutes ?T›*)) (*goals: 1. ‹⟦f permutes - vars p; g permutes - vars q; p = q; keys mon ⊆ vars p⟧ ⟹ - vars p ⊆ - keys mon› 2. ‹⟦f permutes - vars p; g permutes - vars q; p = q; keys mon ⊆ vars p⟧ ⟹ - vars q ⊆ - keys mon› 3. ‹⟦f permutes - vars p; g permutes - vars q; p = q; keys mon ⊆ vars p⟧ ⟹ mon = mon› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*proven 3 subgoals*) . thus "?thesis" (*goal: ‹MPoly_Type.coeff (mpoly_map_vars f p) mon = MPoly_Type.coeff (mpoly_map_vars g q) mon›*) using assms (*‹f permutes - vars p› ‹g permutes - vars q› ‹p = q›*) by (simp add: coeff_mpoly_map_vars (*‹bij ?f ⟹ MPoly_Type.coeff (mpoly_map_vars ?f ?p) ?mon = MPoly_Type.coeff ?p (permutep ?f ?mon)›*) permutes_bij (*‹?p permutes ?S ⟹ bij ?p›*)) next (*goal: ‹¬ keys mon ⊆ vars p ⟹ MPoly_Type.coeff (mpoly_map_vars f p) mon = MPoly_Type.coeff (mpoly_map_vars g q) mon›*) case False (*‹¬ keys mon ⊆ vars p›*) hence "¬(keys mon ⊆ f ` vars q)" "¬(keys mon ⊆ g ` vars q)" using assms (*‹f permutes - vars p› ‹g permutes - vars q› ‹(p::'a mpoly) = (q::'a mpoly)›*) apply - (*goals: 1. ‹⟦¬ keys (mon::nat ⇒₀ nat) ⊆ vars (p::'a::zero mpoly); (f::nat ⇒ nat) permutes - vars p; (g::nat ⇒ nat) permutes - vars (q::'a::zero mpoly); p = q⟧ ⟹ ¬ keys mon ⊆ f ` vars q› 2. ‹⟦¬ keys (mon::nat ⇒₀ nat) ⊆ vars (p::'a::zero mpoly); (f::nat ⇒ nat) permutes - vars p; (g::nat ⇒ nat) permutes - vars (q::'a::zero mpoly); p = q⟧ ⟹ ¬ keys mon ⊆ g ` vars q› discuss goal 1*) apply ((auto simp: subset_iff (*‹(?A ⊆ ?B) = (∀t. t ∈ ?A ⟶ t ∈ ?B)›*) permutes_not_in (*‹⟦?p permutes ?S; ?x ∉ ?S⟧ ⟹ ?p ?x = ?x›*))[1]) (*discuss goal 2*) apply ((auto simp: subset_iff (*‹(?A ⊆ ?B) = (∀t. t ∈ ?A ⟶ t ∈ ?B)›*) permutes_not_in (*‹⟦?p permutes ?S; ?x ∉ ?S⟧ ⟹ ?p ?x = ?x›*))[1]) (*proven 2 subgoals*) . thus "?thesis" (*goal: ‹MPoly_Type.coeff (mpoly_map_vars f p) mon = MPoly_Type.coeff (mpoly_map_vars g q) mon›*) using assms (*‹f permutes - vars p› ‹(g::nat ⇒ nat) permutes - vars (q::'a mpoly)› ‹(p::'a::zero mpoly) = (q::'a::zero mpoly)›*) apply (subst (1 2) coeff_notin_vars (*‹¬ keys ?m ⊆ vars ?p ⟹ MPoly_Type.coeff ?p ?m = 0›*)) (*goals: 1. ‹⟦¬ keys mon ⊆ f ` vars q; ¬ keys mon ⊆ g ` vars q; f permutes - vars p; g permutes - vars q; p = q⟧ ⟹ ¬ keys mon ⊆ vars (mpoly_map_vars g q)› 2. ‹⟦¬ keys mon ⊆ f ` vars q; ¬ keys mon ⊆ g ` vars q; f permutes - vars p; g permutes - vars q; p = q⟧ ⟹ ¬ keys mon ⊆ vars (mpoly_map_vars f p)› 3. ‹⟦¬ keys mon ⊆ f ` vars q; ¬ keys mon ⊆ g ` vars q; f permutes - vars p; g permutes - vars q; p = q⟧ ⟹ 0 = 0› discuss goal 1*) apply ((auto simp: coeff_notin_vars (*‹¬ keys ?m ⊆ vars ?p ⟹ MPoly_Type.coeff ?p ?m = 0›*) vars_mpoly_map_vars (*‹bij ?f ⟹ vars (mpoly_map_vars ?f ?p) = ?f ` vars ?p›*) permutes_bij (*‹?p permutes ?S ⟹ bij ?p›*))[1]) (*discuss goal 2*) apply ((auto simp: coeff_notin_vars (*‹¬ keys ?m ⊆ vars ?p ⟹ MPoly_Type.coeff ?p ?m = 0›*) vars_mpoly_map_vars (*‹bij ?f ⟹ vars (mpoly_map_vars ?f ?p) = ?f ` vars ?p›*) permutes_bij (*‹?p permutes ?S ⟹ bij ?p›*))[1]) (*discuss goal 3*) apply ((auto simp: coeff_notin_vars (*‹¬ keys (?m::nat ⇒₀ nat) ⊆ vars (?p::?'a::zero mpoly) ⟹ MPoly_Type.coeff ?p ?m = (0::?'a::zero)›*) vars_mpoly_map_vars (*‹bij (?f::nat ⇒ nat) ⟹ vars (mpoly_map_vars ?f (?p::?'a::zero mpoly)) = ?f ` vars ?p›*) permutes_bij (*‹(?p::?'a::type ⇒ ?'a::type) permutes (?S::?'a::type set) ⟹ bij ?p›*))[1]) (*proven 3 subgoals*) . qed qed subsection ‹Symmetric polynomials› text ‹ A polynomial is symmetric on a set of variables if it is invariant under any permutation of that set. › definition symmetric_mpoly :: "nat set ⇒ 'a :: zero mpoly ⇒ bool" where "symmetric_mpoly A p = (∀π. π permutes A ⟶ mpoly_map_vars π p = p)" lemma symmetric_mpoly_empty [simp, intro]: "symmetric_mpoly {} p" by (simp add: symmetric_mpoly_def (*‹symmetric_mpoly ?A ?p = (∀π. π permutes ?A ⟶ mpoly_map_vars π ?p = ?p)›*)) text ‹ A polynomial is trivially symmetric on any set of variables that do not occur in it. › lemma symmetric_mpoly_orthogonal: assumes "vars p ∩ A = {}" shows "symmetric_mpoly A p" unfolding symmetric_mpoly_def (*goal: ‹∀π. π permutes A ⟶ mpoly_map_vars π p = p›*) proof (safe) (*goal: ‹⋀π::nat ⇒ nat. π permutes (A::nat set) ⟹ mpoly_map_vars π (p::'a mpoly) = p›*) fix π assume "π": "π permutes A" (*‹(π::nat ⇒ nat) permutes (A::nat set)›*) with assms (*‹vars p ∩ A = {}›*) have "π x = x" if "x ∈ vars p" for x using that (*‹(x::nat) ∈ vars (p::'a mpoly)›*) permutes_not_in[of π A x] (*‹⟦π permutes A; x ∉ A⟧ ⟹ π x = x›*) by auto from assms (*‹vars p ∩ A = {}›*) have "mpoly_map_vars π p = mpoly_map_vars id p" apply (intro mpoly_map_vars_cong (*‹⟦?f permutes - vars ?p; ?g permutes - vars ?q; ?p = ?q⟧ ⟹ mpoly_map_vars ?f ?p = mpoly_map_vars ?g ?q›*) permutes_subset[OF π] (*‹A ⊆ ?T ⟹ π permutes ?T›*) permutes_id (*‹id permutes ?S›*)) (*goals: 1. ‹vars p ∩ A = {} ⟹ A ⊆ - vars p› 2. ‹vars p ∩ A = {} ⟹ p = p› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . also (*calculation: ‹mpoly_map_vars π p = mpoly_map_vars id p›*) have "… = p" by simp finally (*calculation: ‹mpoly_map_vars π p = p›*) show "mpoly_map_vars π p = p" . qed lemma symmetric_mpoly_monom [intro]: assumes "keys m ∩ A = {}" shows "symmetric_mpoly A (monom m c)" using assms (*‹keys m ∩ A = {}›*) vars_monom_subset[of m c] (*‹vars (MPoly_Type.monom (m::nat ⇒₀ nat) (c::'a)) ⊆ keys m›*) apply (intro symmetric_mpoly_orthogonal (*‹vars ?p ∩ ?A = {} ⟹ symmetric_mpoly ?A ?p›*)) (*goal: ‹symmetric_mpoly A (MPoly_Type.monom m c)›*) by auto lemma symmetric_mpoly_subset: assumes "symmetric_mpoly A p" "B ⊆ A" shows "symmetric_mpoly B p" unfolding symmetric_mpoly_def (*goal: ‹∀π::nat ⇒ nat. π permutes (B::nat set) ⟶ mpoly_map_vars π (p::'a mpoly) = p›*) proof (safe) (*goal: ‹⋀π. π permutes B ⟹ mpoly_map_vars π p = p›*) fix π assume "π permutes B" (*‹(π::nat ⇒ nat) permutes (B::nat set)›*) with assms (*‹symmetric_mpoly A p› ‹B ⊆ A›*) have "π permutes A" using permutes_subset (*‹⟦?p permutes ?S; ?S ⊆ ?T⟧ ⟹ ?p permutes ?T›*) by blast with assms (*‹symmetric_mpoly A p› ‹(B::nat set) ⊆ (A::nat set)›*) show "mpoly_map_vars π p = p" by (auto simp: symmetric_mpoly_def (*‹symmetric_mpoly (?A::nat set) (?p::?'a::zero mpoly) = (∀π::nat ⇒ nat. π permutes ?A ⟶ mpoly_map_vars π ?p = ?p)›*)) qed text ‹ If a polynomial is symmetric over some set of variables, that set must either be a subset of the variables occurring in the polynomial or disjoint from it. › lemma symmetric_mpoly_imp_orthogonal_or_subset: assumes "symmetric_mpoly A p" shows "vars p ∩ A = {} ∨ A ⊆ vars p" proof (rule ccontr (*‹(¬ ?P ⟹ False) ⟹ ?P›*)) (*goal: ‹¬ (vars p ∩ A = {} ∨ A ⊆ vars p) ⟹ False›*) assume "¬(vars p ∩ A = {} ∨ A ⊆ vars p)" (*‹¬ (vars (p::'a mpoly) ∩ (A::nat set) = {} ∨ A ⊆ vars p)›*) then obtain x and y where xy: "x ∈ vars p ∩ A" "y ∈ A - vars p" (*goal: ‹(⋀x y. ⟦x ∈ vars p ∩ A; y ∈ A - vars p⟧ ⟹ thesis) ⟹ thesis›*) by auto define π where "π = transpose x y" from xy (*‹x ∈ vars p ∩ A› ‹y ∈ A - vars p›*) have "π": "π permutes A" unfolding "π_def" (*goal: ‹Transposition.transpose x y permutes A›*) apply (intro permutes_swap_id (*‹⟦(?a::?'a::type) ∈ (?S::?'a::type set); (?b::?'a::type) ∈ ?S⟧ ⟹ Transposition.transpose ?a ?b permutes ?S›*)) (*goals: 1. ‹⟦x ∈ vars p ∩ A; y ∈ A - vars p⟧ ⟹ x ∈ A› 2. ‹⟦x ∈ vars p ∩ A; y ∈ A - vars p⟧ ⟹ y ∈ A› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . from xy (*‹x ∈ vars p ∩ A› ‹y ∈ A - vars p›*) have "y ∈ π ` vars p" by (auto simp: π_def (*‹π = Transposition.transpose x y›*) transpose_def (*‹Transposition.transpose ?a ?b ?c = (if ?c = ?a then ?b else if ?c = ?b then ?a else ?c)›*)) also (*calculation: ‹y ∈ π ` vars p›*) from "π" (*‹π permutes A›*) have "π ` vars p = vars (mpoly_map_vars π p)" by (auto simp: vars_mpoly_map_vars (*‹bij ?f ⟹ vars (mpoly_map_vars ?f ?p) = ?f ` vars ?p›*) permutes_bij (*‹?p permutes ?S ⟹ bij ?p›*)) also (*calculation: ‹y ∈ vars (mpoly_map_vars π p)›*) have "mpoly_map_vars π p = p" using assms (*‹symmetric_mpoly A p›*) "π" (*‹π permutes A›*) by (simp add: symmetric_mpoly_def (*‹symmetric_mpoly ?A ?p = (∀π. π permutes ?A ⟶ mpoly_map_vars π ?p = ?p)›*)) finally (*calculation: ‹(y::nat) ∈ vars (p::'a mpoly)›*) show False using xy (*‹x ∈ vars p ∩ A› ‹(y::nat) ∈ (A::nat set) - vars (p::'a mpoly)›*) by auto qed text ‹ Symmetric polynomials are closed under ring operations. › lemma symmetric_mpoly_add [intro]: "symmetric_mpoly A p ⟹ symmetric_mpoly A q ⟹ symmetric_mpoly A (p + q)" unfolding symmetric_mpoly_def (*goal: ‹⟦∀π. π permutes A ⟶ mpoly_map_vars π p = p; ∀π. π permutes A ⟶ mpoly_map_vars π q = q⟧ ⟹ ∀π. π permutes A ⟶ mpoly_map_vars π (p + q) = p + q›*) by simp lemma symmetric_mpoly_diff [intro]: "symmetric_mpoly A p ⟹ symmetric_mpoly A q ⟹ symmetric_mpoly A (p - q)" unfolding symmetric_mpoly_def (*goal: ‹⟦∀π::nat ⇒ nat. π permutes (A::nat set) ⟶ mpoly_map_vars π (p::'a::cancel_comm_monoid_add mpoly) = p; ∀π::nat ⇒ nat. π permutes A ⟶ mpoly_map_vars π (q::'a::cancel_comm_monoid_add mpoly) = q⟧ ⟹ ∀π::nat ⇒ nat. π permutes A ⟶ mpoly_map_vars π (p - q) = p - q›*) by simp lemma symmetric_mpoly_uminus [intro]: "symmetric_mpoly A p ⟹ symmetric_mpoly A (-p)" unfolding symmetric_mpoly_def (*goal: ‹∀π. π permutes A ⟶ mpoly_map_vars π p = p ⟹ ∀π. π permutes A ⟶ mpoly_map_vars π (- p) = - p›*) by simp lemma symmetric_mpoly_uminus_iff [simp]: "symmetric_mpoly A (-p) ⟷ symmetric_mpoly A p" unfolding symmetric_mpoly_def (*goal: ‹(∀π::nat ⇒ nat. π permutes (A::nat set) ⟶ mpoly_map_vars π (- (p::'a::ab_group_add mpoly)) = - p) = (∀π::nat ⇒ nat. π permutes A ⟶ mpoly_map_vars π p = p)›*) by simp lemma symmetric_mpoly_smult [intro]: "symmetric_mpoly A p ⟹ symmetric_mpoly A (smult c p)" unfolding symmetric_mpoly_def (*goal: ‹∀π. π permutes A ⟶ mpoly_map_vars π p = p ⟹ ∀π. π permutes A ⟶ mpoly_map_vars π (MPoly_Type.smult c p) = MPoly_Type.smult c p›*) by simp lemma symmetric_mpoly_mult [intro]: "symmetric_mpoly A p ⟹ symmetric_mpoly A q ⟹ symmetric_mpoly A (p * q)" unfolding symmetric_mpoly_def (*goal: ‹⟦∀π. π permutes A ⟶ mpoly_map_vars π p = p; ∀π. π permutes A ⟶ mpoly_map_vars π q = q⟧ ⟹ ∀π. π permutes A ⟶ mpoly_map_vars π (p * q) = p * q›*) by simp lemma symmetric_mpoly_0 [simp, intro]: "symmetric_mpoly A 0" and symmetric_mpoly_1 [simp, intro]: "symmetric_mpoly A 1" and symmetric_mpoly_Const [simp, intro]: "symmetric_mpoly A (Const c)" (*goals: 1. ‹symmetric_mpoly A 0› 2. ‹symmetric_mpoly A 1› 3. ‹symmetric_mpoly A (Const c)› discuss goal 1*) apply (simp add: symmetric_mpoly_def (*‹symmetric_mpoly ?A ?p = (∀π. π permutes ?A ⟶ mpoly_map_vars π ?p = ?p)›*)) (*discuss goal 2*) apply (simp add: symmetric_mpoly_def (*‹symmetric_mpoly ?A ?p = (∀π. π permutes ?A ⟶ mpoly_map_vars π ?p = ?p)›*)) (*discuss goal 3*) apply (simp add: symmetric_mpoly_def (*‹symmetric_mpoly ?A ?p = (∀π. π permutes ?A ⟶ mpoly_map_vars π ?p = ?p)›*)) (*proven 3 subgoals*) . lemma symmetric_mpoly_power [intro]: "symmetric_mpoly A p ⟹ symmetric_mpoly A (p ^ n)" apply (induction n) (*goals: 1. ‹symmetric_mpoly A p ⟹ symmetric_mpoly A (p ^ 0)› 2. ‹⋀n. ⟦symmetric_mpoly A p ⟹ symmetric_mpoly A (p ^ n); symmetric_mpoly A p⟧ ⟹ symmetric_mpoly A (p ^ Suc n)› discuss goal 1*) apply ((auto intro!: symmetric_mpoly_mult (*‹⟦symmetric_mpoly ?A ?p; symmetric_mpoly ?A ?q⟧ ⟹ symmetric_mpoly ?A (?p * ?q)›*))[1]) (*discuss goal 2*) apply ((auto intro!: symmetric_mpoly_mult (*‹⟦symmetric_mpoly ?A ?p; symmetric_mpoly ?A ?q⟧ ⟹ symmetric_mpoly ?A (?p * ?q)›*))[1]) (*proven 2 subgoals*) . lemma symmetric_mpoly_sum [intro]: "(⋀i. i ∈ B ⟹ symmetric_mpoly A (f i)) ⟹ symmetric_mpoly A (sum f B)" apply (induction B 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. ‹⋀Aa. ⟦infinite Aa; ⋀i. i ∈ Aa ⟹ symmetric_mpoly A (f i)⟧ ⟹ symmetric_mpoly A (sum f Aa)› 2. ‹(⋀i. i ∈ {} ⟹ symmetric_mpoly A (f i)) ⟹ symmetric_mpoly A (sum f {})› 3. ‹⋀x F. ⟦finite F; x ∉ F; (⋀i. i ∈ F ⟹ symmetric_mpoly A (f i)) ⟹ symmetric_mpoly A (sum f F); ⋀i. i ∈ insert x F ⟹ symmetric_mpoly A (f i)⟧ ⟹ symmetric_mpoly A (sum f (insert x F))› discuss goal 1*) apply ((auto intro!: symmetric_mpoly_add (*‹⟦symmetric_mpoly (?A::nat set) (?p::?'a mpoly); symmetric_mpoly ?A (?q::?'a mpoly)⟧ ⟹ symmetric_mpoly ?A (?p + ?q)›*))[1]) (*discuss goal 2*) apply ((auto intro!: symmetric_mpoly_add (*‹⟦symmetric_mpoly (?A::nat set) (?p::?'a mpoly); symmetric_mpoly ?A (?q::?'a mpoly)⟧ ⟹ symmetric_mpoly ?A (?p + ?q)›*))[1]) (*discuss goal 3*) apply ((auto intro!: symmetric_mpoly_add (*‹⟦symmetric_mpoly ?A ?p; symmetric_mpoly ?A ?q⟧ ⟹ symmetric_mpoly ?A (?p + ?q)›*))[1]) (*proven 3 subgoals*) . lemma symmetric_mpoly_prod [intro]: "(⋀i. i ∈ B ⟹ symmetric_mpoly A (f i)) ⟹ symmetric_mpoly A (prod f B)" apply (induction B 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. ‹⋀Aa. ⟦infinite Aa; ⋀i. i ∈ Aa ⟹ symmetric_mpoly A (f i)⟧ ⟹ symmetric_mpoly A (prod f Aa)› 2. ‹(⋀i. i ∈ {} ⟹ symmetric_mpoly A (f i)) ⟹ symmetric_mpoly A (prod f {})› 3. ‹⋀x F. ⟦finite F; x ∉ F; (⋀i. i ∈ F ⟹ symmetric_mpoly A (f i)) ⟹ symmetric_mpoly A (prod f F); ⋀i. i ∈ insert x F ⟹ symmetric_mpoly A (f i)⟧ ⟹ symmetric_mpoly A (prod f (insert x F))› discuss goal 1*) apply ((auto intro!: symmetric_mpoly_mult (*‹⟦symmetric_mpoly ?A ?p; symmetric_mpoly ?A ?q⟧ ⟹ symmetric_mpoly ?A (?p * ?q)›*))[1]) (*discuss goal 2*) apply ((auto intro!: symmetric_mpoly_mult (*‹⟦symmetric_mpoly (?A::nat set) (?p::?'a::semiring_0 mpoly); symmetric_mpoly ?A (?q::?'a::semiring_0 mpoly)⟧ ⟹ symmetric_mpoly ?A (?p * ?q)›*))[1]) (*discuss goal 3*) apply ((auto intro!: symmetric_mpoly_mult (*‹⟦symmetric_mpoly ?A ?p; symmetric_mpoly ?A ?q⟧ ⟹ symmetric_mpoly ?A (?p * ?q)›*))[1]) (*proven 3 subgoals*) . text ‹ An symmetric sum or product over polynomials yields a symmetric polynomial: › lemma symmetric_mpoly_symmetric_sum: assumes "g permutes X" assumes "⋀x π. x ∈ X ⟹ π permutes A ⟹ mpoly_map_vars π (f x) = f (g x)" shows "symmetric_mpoly A (∑x∈X. f x)" unfolding symmetric_mpoly_def (*goal: ‹∀π. π permutes A ⟶ mpoly_map_vars π (sum f X) = sum f X›*) proof (safe) (*goal: ‹⋀π::nat ⇒ nat. π permutes (A::nat set) ⟹ mpoly_map_vars π (sum (f::'a ⇒ 'b mpoly) (X::'a set)) = sum f X›*) fix π assume "π": "π permutes A" (*‹(π::nat ⇒ nat) permutes (A::nat set)›*) have "mpoly_map_vars π (sum f X) = (∑x∈X. mpoly_map_vars π (f x))" by simp also (*calculation: ‹mpoly_map_vars π (sum f X) = (∑x∈X. mpoly_map_vars π (f x))›*) have "… = (∑x∈X. f (g x))" by (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›*) assms (*‹(g::'a::type ⇒ 'a::type) permutes (X::'a::type set)› ‹⟦(?x::'a::type) ∈ (X::'a::type set); (?π::nat ⇒ nat) permutes (A::nat set)⟧ ⟹ mpoly_map_vars ?π ((f::'a::type ⇒ 'b::comm_monoid_add mpoly) ?x) = f ((g::'a::type ⇒ 'a::type) ?x)›*) π (*‹(π::nat ⇒ nat) permutes (A::nat set)›*) refl (*‹(?t::?'a::type) = ?t›*)) also (*calculation: ‹mpoly_map_vars π (sum f X) = (∑x∈X. f (g x))›*) have "… = (∑x∈g`X. f x)" using assms (*‹g permutes X› ‹⟦?x ∈ X; ?π permutes A⟧ ⟹ mpoly_map_vars ?π (f ?x) = f (g ?x)›*) apply (subst sum.reindex (*‹inj_on ?h ?A ⟹ sum ?g (?h ` ?A) = sum (?g ∘ ?h) ?A›*)) (*goals: 1. ‹⟦g permutes X; ⋀x π. ⟦x ∈ X; π permutes A⟧ ⟹ mpoly_map_vars π (f x) = f (g x)⟧ ⟹ inj_on g X› 2. ‹⟦g permutes X; ⋀x π. ⟦x ∈ X; π permutes A⟧ ⟹ mpoly_map_vars π (f x) = f (g x)⟧ ⟹ (∑x∈X. f (g x)) = sum (f ∘ g) X› discuss goal 1*) apply ((auto simp: permutes_inj_on (*‹?p permutes ?S ⟹ inj_on ?p ?A›*))[1]) (*discuss goal 2*) apply ((auto simp: permutes_inj_on (*‹?p permutes ?S ⟹ inj_on ?p ?A›*))[1]) (*proven 2 subgoals*) . also (*calculation: ‹mpoly_map_vars π (sum f X) = sum f (g ` X)›*) have "g ` X = X" using assms (*‹g permutes X› ‹⟦?x ∈ X; ?π permutes A⟧ ⟹ mpoly_map_vars ?π (f ?x) = f (g ?x)›*) by (simp add: permutes_image (*‹?p permutes ?S ⟹ ?p ` ?S = ?S›*)) finally (*calculation: ‹mpoly_map_vars π (sum f X) = sum f X›*) show "mpoly_map_vars π (sum f X) = sum f X" . qed lemma symmetric_mpoly_symmetric_prod: assumes "g permutes X" assumes "⋀x π. x ∈ X ⟹ π permutes A ⟹ mpoly_map_vars π (f x) = f (g x)" shows "symmetric_mpoly A (∏x∈X. f x)" unfolding symmetric_mpoly_def (*goal: ‹∀π. π permutes A ⟶ mpoly_map_vars π (prod f X) = prod f X›*) proof (safe) (*goal: ‹⋀π. π permutes A ⟹ mpoly_map_vars π (prod f X) = prod f X›*) fix π assume "π": "π permutes A" (*‹(π::nat ⇒ nat) permutes (A::nat set)›*) have "mpoly_map_vars π (prod f X) = (∏x∈X. mpoly_map_vars π (f x))" by simp also (*calculation: ‹mpoly_map_vars π (prod f X) = (∏x∈X. mpoly_map_vars π (f x))›*) have "… = (∏x∈X. f (g x))" by (intro prod.cong (*‹⟦?A = ?B; ⋀x. x ∈ ?B ⟹ ?g x = ?h x⟧ ⟹ prod ?g ?A = prod ?h ?B›*) assms (*‹g permutes X› ‹⟦?x ∈ X; ?π permutes A⟧ ⟹ mpoly_map_vars ?π (f ?x) = f (g ?x)›*) π (*‹π permutes A›*) refl (*‹?t = ?t›*)) also (*calculation: ‹mpoly_map_vars π (prod f X) = (∏x∈X. f (g x))›*) have "… = (∏x∈g`X. f x)" using assms (*‹g permutes X› ‹⟦?x ∈ X; ?π permutes A⟧ ⟹ mpoly_map_vars ?π (f ?x) = f (g ?x)›*) apply (subst prod.reindex (*‹inj_on (?h::?'b ⇒ ?'c) (?A::?'b set) ⟹ prod (?g::?'c ⇒ ?'a) (?h ` ?A) = prod (?g ∘ ?h) ?A›*)) (*goals: 1. ‹⟦g permutes X; ⋀x π. ⟦x ∈ X; π permutes A⟧ ⟹ mpoly_map_vars π (f x) = f (g x)⟧ ⟹ inj_on g X› 2. ‹⟦g permutes X; ⋀x π. ⟦x ∈ X; π permutes A⟧ ⟹ mpoly_map_vars π (f x) = f (g x)⟧ ⟹ (∏x∈X. f (g x)) = prod (f ∘ g) X› discuss goal 1*) apply ((auto simp: permutes_inj_on (*‹?p permutes ?S ⟹ inj_on ?p ?A›*))[1]) (*discuss goal 2*) apply ((auto simp: permutes_inj_on (*‹?p permutes ?S ⟹ inj_on ?p ?A›*))[1]) (*proven 2 subgoals*) . also (*calculation: ‹mpoly_map_vars π (prod f X) = prod f (g ` X)›*) have "g ` X = X" using assms (*‹g permutes X› ‹⟦?x ∈ X; ?π permutes A⟧ ⟹ mpoly_map_vars ?π (f ?x) = f (g ?x)›*) by (simp add: permutes_image (*‹?p permutes ?S ⟹ ?p ` ?S = ?S›*)) finally (*calculation: ‹mpoly_map_vars π (prod f X) = prod f X›*) show "mpoly_map_vars π (prod f X) = prod f X" . qed text ‹ If $p$ is a polynomial that is symmetric on some subset of variables $A$, then for the leading monomial of $p$, the exponents of these variables are decreasing w.\,r.\,t.\ the variable ordering. › theorem lookup_lead_monom_decreasing: assumes "symmetric_mpoly A p" defines "m ≡ lead_monom p" assumes "i ∈ A" "j ∈ A" "i ≤ j" shows "lookup m i ≥ lookup m j" sorry subsection ‹The elementary symmetric polynomials› text ‹ The $k$-th elementary symmetric polynomial for a finite set of variables $A$, with $k$ ranging between 1 and $|A|$, is the sum of the product of all subsets of $A$ with cardinality $k$: › lift_definition sym_mpoly_aux :: "nat set ⇒ nat ⇒ (nat ⇒₀ nat) ⇒₀ 'a :: {zero_neq_one}" is "λX k mon. if finite X ∧ (∃Y. Y ⊆ X ∧ card Y = k ∧ mon = monom_of_set Y) then 1 else 0" proof - fix k :: nat and X :: "nat set" show "finite {x. (if finite X ∧ (∃Y⊆X. card Y = k ∧ x = monom_of_set Y) then 1 else 0) ≠ (0::'a)}" (is "finite ?A") proof (cases "finite X") case True have "?A ⊆ monom_of_set ` Pow X" by auto moreover from True have "finite (monom_of_set ` Pow X)" by simp ultimately show ?thesis by (rule finite_subset) qed auto qed lemma lookup_sym_mpoly_aux: "Poly_Mapping.lookup (sym_mpoly_aux X k) mon = (if finite X ∧ (∃Y. Y ⊆ X ∧ card Y = k ∧ mon = monom_of_set Y) then 1 else 0)" apply transfer' (*goal: ‹lookup (sym_mpoly_aux X k) mon = (if finite X ∧ (∃Y⊆X. card Y = k ∧ mon = monom_of_set Y) then 1 else 0)›*) by simp lemma lookup_sym_mpoly_aux_monom_of_set [simp]: assumes "finite X" "Y ⊆ X" "card Y = k" shows "Poly_Mapping.lookup (sym_mpoly_aux X k) (monom_of_set Y) = 1" using assms (*‹finite X› ‹Y ⊆ X› ‹card Y = k›*) by (auto simp: lookup_sym_mpoly_aux (*‹lookup (sym_mpoly_aux (?X::nat set) (?k::nat)) (?mon::nat ⇒₀ nat) = (if finite ?X ∧ (∃Y⊆?X. card Y = ?k ∧ ?mon = monom_of_set Y) then 1::?'a else (0::?'a))›*)) lemma keys_sym_mpoly_aux: "m ∈ keys (sym_mpoly_aux A k) ⟹ keys m ⊆ A" apply transfer' (*goal: ‹m ∈ keys (sym_mpoly_aux A k) ⟹ keys m ⊆ A›*) 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: keys_monom_of_set (*‹keys (monom_of_set ?X) = (if finite ?X then ?X else {})›*)) lift_definition sym_mpoly :: "nat set ⇒ nat ⇒ 'a :: {zero_neq_one} mpoly" is "sym_mpoly_aux" . lemma vars_sym_mpoly_subset: "vars (sym_mpoly A k) ⊆ A" using keys_sym_mpoly_aux (*‹?m ∈ keys (sym_mpoly_aux ?A ?k) ⟹ keys ?m ⊆ ?A›*) by (auto simp: vars_def (*‹vars ?p = ⋃ (keys ` keys (mapping_of ?p))›*) sym_mpoly.rep_eq (*‹mapping_of (sym_mpoly ?x ?xa) = sym_mpoly_aux ?x ?xa›*)) lemma coeff_sym_mpoly: "MPoly_Type.coeff (sym_mpoly X k) mon = (if finite X ∧ (∃Y. Y ⊆ X ∧ card Y = k ∧ mon = monom_of_set Y) then 1 else 0)" apply transfer' (*goal: ‹MPoly_Type.coeff (sym_mpoly X k) mon = (if finite X ∧ (∃Y⊆X. card Y = k ∧ mon = monom_of_set Y) then 1 else 0)›*) by (simp add: lookup_sym_mpoly_aux (*‹lookup (sym_mpoly_aux (?X::nat set) (?k::nat)) (?mon::nat ⇒₀ nat) = (if finite ?X ∧ (∃Y⊆?X. card Y = ?k ∧ ?mon = monom_of_set Y) then 1::?'a::zero_neq_one else (0::?'a::zero_neq_one))›*)) lemma sym_mpoly_infinite: "¬finite A ⟹ sym_mpoly A k = 0" apply transfer (*goal: ‹infinite A ⟹ sym_mpoly A k = 0›*) apply transfer (*goal: ‹⋀A k. infinite A ⟹ sym_mpoly_aux A k = 0›*) by auto lemma sym_mpoly_altdef: "sym_mpoly A k = (∑X | X ⊆ A ∧ card X = k. monom (monom_of_set X) 1)" proof (cases "finite A") (*goals: 1. ‹finite A ⟹ sym_mpoly A k = (∑X | X ⊆ A ∧ card X = k. MPoly_Type.monom (monom_of_set X) 1)› 2. ‹infinite A ⟹ sym_mpoly A k = (∑X | X ⊆ A ∧ card X = k. MPoly_Type.monom (monom_of_set X) 1)›*) case False (*‹infinite A›*) hence "*": "infinite {X. X ⊆ A ∧ infinite X}" by (rule infinite_infinite_subsets (*‹infinite ?A ⟹ infinite {X. X ⊆ ?A ∧ infinite X}›*)) have "infinite {X. X ⊆ A ∧ card X = 0}" apply (rule infinite_super[OF _ *] (*‹{X. X ⊆ A ∧ infinite X} ⊆ ?T ⟹ infinite ?T›*)) (*goal: ‹infinite {X. X ⊆ A ∧ card X = 0}›*) by auto moreover have "**": "infinite {X. X ⊆ A ∧ finite X ∧ card X = k}" if "k ≠ 0" using that (*‹k ≠ 0›*) infinite_card_subsets[of A k] (*‹⟦infinite A; 0 < k⟧ ⟹ infinite {X. X ⊆ A ∧ finite X ∧ card X = k}›*) False (*‹infinite A›*) by auto have "infinite {X. X ⊆ A ∧ card X = k}" if "k ≠ 0" apply (rule infinite_super[OF _ **[OF that]] (*‹{X. X ⊆ A ∧ finite X ∧ card X = k} ⊆ ?T ⟹ infinite ?T›*)) (*goal: ‹infinite {X. X ⊆ A ∧ card X = k}›*) by auto ultimately show "?thesis" (*goal: ‹sym_mpoly A k = (∑X | X ⊆ A ∧ card X = k. MPoly_Type.monom (monom_of_set X) 1)›*) using False (*‹infinite A›*) apply (cases "k = 0") (*goals: 1. ‹⟦infinite {X. X ⊆ A ∧ card X = 0}; k ≠ 0 ⟹ infinite {X. X ⊆ A ∧ card X = k}; infinite A; k = 0⟧ ⟹ sym_mpoly A k = (∑X | X ⊆ A ∧ card X = k. MPoly_Type.monom (monom_of_set X) 1)› 2. ‹⟦infinite {X. X ⊆ A ∧ card X = 0}; k ≠ 0 ⟹ infinite {X. X ⊆ A ∧ card X = k}; infinite A; k ≠ 0⟧ ⟹ sym_mpoly A k = (∑X | X ⊆ A ∧ card X = k. MPoly_Type.monom (monom_of_set X) 1)› discuss goal 1*) apply (simp add: sym_mpoly_infinite (*‹infinite (?A::nat set) ⟹ sym_mpoly ?A (?k::nat) = (0::?'a mpoly)›*)) (*discuss goal 2*) apply (simp add: sym_mpoly_infinite (*‹infinite ?A ⟹ sym_mpoly ?A ?k = 0›*)) (*proven 2 subgoals*) . next (*goal: ‹finite A ⟹ sym_mpoly A k = (∑X | X ⊆ A ∧ card X = k. MPoly_Type.monom (monom_of_set X) 1)›*) case True (*‹finite A›*) show "?thesis" (*goal: ‹sym_mpoly A k = (∑X | X ⊆ A ∧ card X = k. MPoly_Type.monom (monom_of_set X) 1)›*) apply (intro mpoly_eqI (*‹(⋀mon. MPoly_Type.coeff ?p mon = MPoly_Type.coeff ?q mon) ⟹ ?p = ?q›*)) (*goal: ‹sym_mpoly A k = (∑X | X ⊆ A ∧ card X = k. MPoly_Type.monom (monom_of_set X) 1)›*) proof (goal_cases) (*goal: ‹⋀mon::nat ⇒₀ nat. MPoly_Type.coeff (sym_mpoly (A::nat set) (k::nat)) mon = MPoly_Type.coeff (∑X::nat set | X ⊆ A ∧ card X = k. MPoly_Type.monom (monom_of_set X) (1::'a::{comm_monoid_add,zero_neq_one})) mon›*) case (1 m) (*no hyothesis introduced yet*) show "?case" (*goal: ‹MPoly_Type.coeff (sym_mpoly A k) m = MPoly_Type.coeff (∑X | X ⊆ A ∧ card X = k. MPoly_Type.monom (monom_of_set X) 1) m›*) proof (cases "∃X. X ⊆ A ∧ card X = k ∧ m = monom_of_set X") (*goals: 1. ‹∃X⊆A::nat set. card X = (k::nat) ∧ (m::nat ⇒₀ nat) = monom_of_set X ⟹ MPoly_Type.coeff (sym_mpoly A k) m = MPoly_Type.coeff (∑X::nat set | X ⊆ A ∧ card X = k. MPoly_Type.monom (monom_of_set X) (1::'a)) m› 2. ‹¬ (∃X⊆A::nat set. card X = (k::nat) ∧ (m::nat ⇒₀ nat) = monom_of_set X) ⟹ MPoly_Type.coeff (sym_mpoly A k) m = MPoly_Type.coeff (∑X::nat set | X ⊆ A ∧ card X = k. MPoly_Type.monom (monom_of_set X) (1::'a)) m›*) case False (*‹¬ (∃X⊆A. card X = k ∧ m = monom_of_set X)›*) thus "?thesis" (*goal: ‹MPoly_Type.coeff (sym_mpoly A k) m = MPoly_Type.coeff (∑X | X ⊆ A ∧ card X = k. MPoly_Type.monom (monom_of_set X) 1) m›*) by (auto simp: coeff_sym_mpoly (*‹MPoly_Type.coeff (sym_mpoly ?X ?k) ?mon = (if finite ?X ∧ (∃Y⊆?X. card Y = ?k ∧ ?mon = monom_of_set Y) then 1 else 0)›*) coeff_sum (*‹MPoly_Type.coeff (sum ?f ?A) ?m = (∑x∈?A. MPoly_Type.coeff (?f x) ?m)›*) coeff_monom (*‹MPoly_Type.coeff (MPoly_Type.monom ?m ?a) ?m' = (?a when ?m' = ?m)›*)) next (*goal: ‹∃X⊆A. card X = k ∧ m = monom_of_set X ⟹ MPoly_Type.coeff (sym_mpoly A k) m = MPoly_Type.coeff (∑X | X ⊆ A ∧ card X = k. MPoly_Type.monom (monom_of_set X) 1) m›*) case True (*‹∃X⊆A. card X = k ∧ m = monom_of_set X›*) then obtain X where X: "X ⊆ A" "card X = k" "m = monom_of_set X" (*goal: ‹(⋀X::nat set. ⟦X ⊆ (A::nat set); card X = (k::nat); (m::nat ⇒₀ nat) = monom_of_set X⟧ ⟹ thesis::bool) ⟹ thesis›*) by blast have "coeff (∑X | X ⊆ A ∧ card X = k. monom (monom_of_set X) 1) m = (∑X∈{X}. 1)" unfolding coeff_sum (*goal: ‹(∑x∈{X. X ⊆ A ∧ card X = k}. MPoly_Type.coeff (MPoly_Type.monom (monom_of_set x) 1) m) = (∑X∈{X}. 1)›*) proof (intro 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›*) ballI (*‹(⋀x. x ∈ ?A ⟹ ?P x) ⟹ ∀x∈?A. ?P x›*)) (*goals: 1. ‹finite {X. X ⊆ A ∧ card X = k}› 2. ‹{X} ⊆ {X. X ⊆ A ∧ card X = k}› 3. ‹⋀i. i ∈ {X. X ⊆ A ∧ card X = k} - {X} ⟹ MPoly_Type.coeff (MPoly_Type.monom (monom_of_set i) 1) m = 0› 4. ‹⋀x. x ∈ {X} ⟹ MPoly_Type.coeff (MPoly_Type.monom (monom_of_set x) 1) m = 1›*) fix Y assume Y: "Y ∈ {X. X ⊆ A ∧ card X = k} - {X}" (*‹(Y::nat set) ∈ {X::nat set. X ⊆ (A::nat set) ∧ card X = (k::nat)} - {X::nat set}›*) hence "X = Y" if "monom_of_set X = monom_of_set Y" using that (*‹monom_of_set X = monom_of_set Y›*) finite_subset[OF X ( 1 )] (*‹finite A ⟹ finite X›*) finite_subset[of Y A] (*‹⟦(Y::nat set) ⊆ (A::nat set); finite A⟧ ⟹ finite Y›*) ‹finite A› (*‹finite (A::nat set)›*) by auto thus "coeff (monom (monom_of_set Y) 1) m = 0" using X (*‹X ⊆ A› ‹card (X::nat set) = (k::nat)› ‹m = monom_of_set X›*) Y (*‹Y ∈ {X. X ⊆ A ∧ card X = k} - {X}›*) by (auto simp: coeff_monom (*‹MPoly_Type.coeff (MPoly_Type.monom ?m ?a) ?m' = (?a when ?m' = ?m)›*) when_def (*‹(?a when ?P) = (if ?P then ?a else 0)›*)) qed (insert X (*‹X ⊆ A› ‹card X = k› ‹m = monom_of_set X›*) ‹finite A›, auto simp: coeff_monom (*‹MPoly_Type.coeff (MPoly_Type.monom ?m ?a) ?m' = (?a when ?m' = ?m)›*)) (*solves the remaining goals: 1. ‹finite {X. X ⊆ A ∧ card X = k}› 2. ‹{X} ⊆ {X. X ⊆ A ∧ card X = k}› 3. ‹⋀x. x ∈ {X} ⟹ MPoly_Type.coeff (MPoly_Type.monom (monom_of_set x) 1) m = 1›*) thus "?thesis" (*goal: ‹MPoly_Type.coeff (sym_mpoly A k) m = MPoly_Type.coeff (∑X | X ⊆ A ∧ card X = k. MPoly_Type.monom (monom_of_set X) 1) m›*) using ‹finite A› (*‹finite A›*) by (auto simp: coeff_sym_mpoly (*‹MPoly_Type.coeff (sym_mpoly ?X ?k) ?mon = (if finite ?X ∧ (∃Y⊆?X. card Y = ?k ∧ ?mon = monom_of_set Y) then 1 else 0)›*) coeff_sum (*‹MPoly_Type.coeff (sum ?f ?A) ?m = (∑x∈?A. MPoly_Type.coeff (?f x) ?m)›*) coeff_monom (*‹MPoly_Type.coeff (MPoly_Type.monom ?m ?a) ?m' = (?a when ?m' = ?m)›*)) qed qed qed lemma coeff_sym_mpoly_monom_of_set [simp]: assumes "finite X" "Y ⊆ X" "card Y = k" shows "MPoly_Type.coeff (sym_mpoly X k) (monom_of_set Y) = 1" using assms (*‹finite X› ‹Y ⊆ X› ‹card (Y::nat set) = (k::nat)›*) by (auto simp: coeff_sym_mpoly (*‹MPoly_Type.coeff (sym_mpoly ?X ?k) ?mon = (if finite ?X ∧ (∃Y⊆?X. card Y = ?k ∧ ?mon = monom_of_set Y) then 1 else 0)›*)) lemma coeff_sym_mpoly_0: "coeff (sym_mpoly X k) 0 = (if finite X ∧ k = 0 then 1 else 0)" proof (-) (*goal: ‹MPoly_Type.coeff (sym_mpoly X k) 0 = (if finite X ∧ k = 0 then 1 else 0)›*) consider "finite X" and "k = 0" | "finite X" and "k ≠ 0" | "infinite X" (*goal: ‹⟦⟦finite (X::nat set); (k::nat) = (0::nat)⟧ ⟹ thesis::bool; ⟦finite X; k ≠ (0::nat)⟧ ⟹ thesis; infinite X ⟹ thesis⟧ ⟹ thesis›*) by blast thus "?thesis" (*goal: ‹MPoly_Type.coeff (sym_mpoly (X::nat set) (k::nat)) (0::nat ⇒₀ nat) = (if finite X ∧ k = (0::nat) then 1::'a else (0::'a))›*) proof (cases) (*goals: 1. ‹⟦finite X; k = 0⟧ ⟹ MPoly_Type.coeff (sym_mpoly X k) 0 = (if finite X ∧ k = 0 then 1 else 0)› 2. ‹⟦finite X; k ≠ 0⟧ ⟹ MPoly_Type.coeff (sym_mpoly X k) 0 = (if finite X ∧ k = 0 then 1 else 0)› 3. ‹infinite X ⟹ MPoly_Type.coeff (sym_mpoly X k) 0 = (if finite X ∧ k = 0 then 1 else 0)›*) assume "finite X" "k = 0" (*‹finite (X::nat set)› ‹(k::nat) = (0::nat)›*) hence "coeff (sym_mpoly X k) (monom_of_set {}) = 1" apply (subst coeff_sym_mpoly_monom_of_set (*‹⟦finite ?X; ?Y ⊆ ?X; card ?Y = ?k⟧ ⟹ MPoly_Type.coeff (sym_mpoly ?X ?k) (monom_of_set ?Y) = 1›*)) (*goals: 1. ‹⟦finite X; k = 0⟧ ⟹ finite X› 2. ‹⟦finite X; k = 0⟧ ⟹ {} ⊆ X› 3. ‹⟦finite X; k = 0⟧ ⟹ card {} = k› 4. ‹⟦finite X; k = 0⟧ ⟹ 1 = 1› 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: ‹MPoly_Type.coeff (sym_mpoly X k) 0 = (if finite X ∧ k = 0 then 1 else 0)›*) unfolding monom_of_set_empty (*goal: ‹MPoly_Type.coeff (sym_mpoly X k) 0 = (if finite X ∧ k = 0 then 1 else 0)›*) using ‹finite X› (*‹finite X›*) ‹k = 0› (*‹k = 0›*) by simp next (*goals: 1. ‹⟦finite X; k ≠ 0⟧ ⟹ MPoly_Type.coeff (sym_mpoly X k) 0 = (if finite X ∧ k = 0 then 1 else 0)› 2. ‹infinite X ⟹ MPoly_Type.coeff (sym_mpoly X k) 0 = (if finite X ∧ k = 0 then 1 else 0)›*) assume "finite X" "k ≠ 0" (*‹finite (X::nat set)› ‹(k::nat) ≠ (0::nat)›*) hence "¬(∃Y. finite Y ∧ Y ⊆ X ∧ card Y = k ∧ monom_of_set Y = 0)" by auto thus "?thesis" (*goal: ‹MPoly_Type.coeff (sym_mpoly (X::nat set) (k::nat)) (0::nat ⇒₀ nat) = (if finite X ∧ k = (0::nat) then 1::'a::zero_neq_one else (0::'a::zero_neq_one))›*) using ‹k ≠ 0› (*‹k ≠ 0›*) by (auto simp: coeff_sym_mpoly (*‹MPoly_Type.coeff (sym_mpoly ?X ?k) ?mon = (if finite ?X ∧ (∃Y⊆?X. card Y = ?k ∧ ?mon = monom_of_set Y) then 1 else 0)›*)) next (*goal: ‹infinite X ⟹ MPoly_Type.coeff (sym_mpoly X k) 0 = (if finite X ∧ k = 0 then 1 else 0)›*) assume "infinite X" (*‹infinite (X::nat set)›*) thus "?thesis" (*goal: ‹MPoly_Type.coeff (sym_mpoly X k) 0 = (if finite X ∧ k = 0 then 1 else 0)›*) by (simp add: coeff_sym_mpoly (*‹MPoly_Type.coeff (sym_mpoly ?X ?k) ?mon = (if finite ?X ∧ (∃Y⊆?X. card Y = ?k ∧ ?mon = monom_of_set Y) then 1 else 0)›*)) qed qed lemma symmetric_sym_mpoly [intro]: assumes "A ⊆ B" shows "symmetric_mpoly A (sym_mpoly B k :: 'a :: zero_neq_one mpoly)" unfolding symmetric_mpoly_def (*goal: ‹∀π. π permutes A ⟶ mpoly_map_vars π (sym_mpoly B k) = sym_mpoly B k›*) proof (safe intro!: mpoly_eqI (*‹(⋀mon. MPoly_Type.coeff ?p mon = MPoly_Type.coeff ?q mon) ⟹ ?p = ?q›*)) (*goal: ‹⋀π mon. π permutes A ⟹ MPoly_Type.coeff (mpoly_map_vars π (sym_mpoly B k)) mon = MPoly_Type.coeff (sym_mpoly B k) mon›*) fix π and mon :: "nat ⇒₀ nat" assume "π": "π permutes A" (*‹(π::nat ⇒ nat) permutes (A::nat set)›*) from "π" (*‹π permutes A›*) have "π'": "π permutes B" apply (rule permutes_subset (*‹⟦?p permutes ?S; ?S ⊆ ?T⟧ ⟹ ?p permutes ?T›*)) (*goal: ‹π permutes B›*) by fact from "π" (*‹π permutes A›*) have "MPoly_Type.coeff (mpoly_map_vars π (sym_mpoly B k :: 'a mpoly)) mon = MPoly_Type.coeff (sym_mpoly B k :: 'a mpoly) (permutep π mon)" by (simp add: coeff_mpoly_map_vars (*‹bij ?f ⟹ MPoly_Type.coeff (mpoly_map_vars ?f ?p) ?mon = MPoly_Type.coeff ?p (permutep ?f ?mon)›*) permutes_bij (*‹?p permutes ?S ⟹ bij ?p›*)) also (*calculation: ‹MPoly_Type.coeff (mpoly_map_vars π (sym_mpoly B k)) mon = MPoly_Type.coeff (sym_mpoly B k) (permutep π mon)›*) have "… = 1 ⟷ MPoly_Type.coeff (sym_mpoly B k :: 'a mpoly) mon = 1" (is "?lhs = 1 ⟷ ?rhs = 1") proof (standard) (*goals: 1. ‹MPoly_Type.coeff (sym_mpoly B k) (permutep π mon) = 1 ⟹ MPoly_Type.coeff (sym_mpoly B k) mon = 1› 2. ‹MPoly_Type.coeff (sym_mpoly B k) mon = 1 ⟹ MPoly_Type.coeff (sym_mpoly B k) (permutep π mon) = 1›*) assume "?rhs = 1" (*‹MPoly_Type.coeff (sym_mpoly (B::nat set) (k::nat)) (mon::nat ⇒₀ nat) = (1::'a)›*) then obtain Y where "finite B" and Y: "Y ⊆ B" "card Y = k" "mon = monom_of_set Y" (*goal: ‹(⋀Y. ⟦finite B; Y ⊆ B; card Y = k; mon = monom_of_set Y⟧ ⟹ thesis) ⟹ thesis›*) by (auto simp: coeff_sym_mpoly (*‹MPoly_Type.coeff (sym_mpoly ?X ?k) ?mon = (if finite ?X ∧ (∃Y⊆?X. card Y = ?k ∧ ?mon = monom_of_set Y) then 1 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))›*)) with "π'" (*‹π permutes B›*) have "π -` Y ⊆ B" "card (π -` Y) = k" "permutep π mon = monom_of_set (π -` Y)" apply - (*goals: 1. ‹⟦π permutes B; finite B; Y ⊆ B; card Y = k; mon = monom_of_set Y⟧ ⟹ π -` Y ⊆ B› 2. ‹⟦π permutes B; finite B; Y ⊆ B; card Y = k; mon = monom_of_set Y⟧ ⟹ card (π -` Y) = k› 3. ‹⟦π permutes B; finite B; Y ⊆ B; card Y = k; mon = monom_of_set Y⟧ ⟹ permutep π mon = monom_of_set (π -` Y)› discuss goal 1*) apply ((auto simp: permutes_in_image (*‹?p permutes ?S ⟹ (?p ?x ∈ ?S) = (?x ∈ ?S)›*) card_vimage_inj (*‹⟦inj ?f; ?A ⊆ range ?f⟧ ⟹ card (?f -` ?A) = card ?A›*) permutep_monom_of_set (*‹bij ?f ⟹ permutep ?f (monom_of_set ?A) = monom_of_set (?f -` ?A)›*) permutes_bij (*‹?p permutes ?S ⟹ bij ?p›*) permutes_inj (*‹?p permutes ?S ⟹ inj ?p›*) permutes_surj (*‹?p permutes ?S ⟹ surj ?p›*))[1]) (*discuss goal 2*) apply ((auto simp: permutes_in_image (*‹?p permutes ?S ⟹ (?p ?x ∈ ?S) = (?x ∈ ?S)›*) card_vimage_inj (*‹⟦inj ?f; ?A ⊆ range ?f⟧ ⟹ card (?f -` ?A) = card ?A›*) permutep_monom_of_set (*‹bij ?f ⟹ permutep ?f (monom_of_set ?A) = monom_of_set (?f -` ?A)›*) permutes_bij (*‹?p permutes ?S ⟹ bij ?p›*) permutes_inj (*‹?p permutes ?S ⟹ inj ?p›*) permutes_surj (*‹?p permutes ?S ⟹ surj ?p›*))[1]) (*discuss goal 3*) apply ((auto simp: permutes_in_image (*‹?p permutes ?S ⟹ (?p ?x ∈ ?S) = (?x ∈ ?S)›*) card_vimage_inj (*‹⟦inj ?f; ?A ⊆ range ?f⟧ ⟹ card (?f -` ?A) = card ?A›*) permutep_monom_of_set (*‹bij ?f ⟹ permutep ?f (monom_of_set ?A) = monom_of_set (?f -` ?A)›*) permutes_bij (*‹?p permutes ?S ⟹ bij ?p›*) permutes_inj (*‹?p permutes ?S ⟹ inj ?p›*) permutes_surj (*‹?p permutes ?S ⟹ surj ?p›*))[1]) (*proven 3 subgoals*) . thus "?lhs = 1" using ‹finite B› (*‹finite B›*) by (auto simp: coeff_sym_mpoly (*‹MPoly_Type.coeff (sym_mpoly (?X::nat set) (?k::nat)) (?mon::nat ⇒₀ nat) = (if finite ?X ∧ (∃Y⊆?X. card Y = ?k ∧ ?mon = monom_of_set Y) then 1::?'a else (0::?'a))›*)) next (*goal: ‹MPoly_Type.coeff (sym_mpoly B k) (permutep π mon) = 1 ⟹ MPoly_Type.coeff (sym_mpoly B k) mon = 1›*) assume "?lhs = 1" (*‹MPoly_Type.coeff (sym_mpoly (B::nat set) (k::nat)) (permutep (π::nat ⇒ nat) (mon::nat ⇒₀ nat)) = (1::'a)›*) then obtain Y where "finite B" and Y: "Y ⊆ B" "card Y = k" "permutep π mon = monom_of_set Y" (*goal: ‹(⋀Y::nat set. ⟦finite (B::nat set); Y ⊆ B; card Y = (k::nat); permutep (π::nat ⇒ nat) (mon::nat ⇒₀ nat) = monom_of_set Y⟧ ⟹ thesis::bool) ⟹ thesis›*) by (auto simp: coeff_sym_mpoly (*‹MPoly_Type.coeff (sym_mpoly ?X ?k) ?mon = (if finite ?X ∧ (∃Y⊆?X. card Y = ?k ∧ ?mon = monom_of_set Y) then 1 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))›*)) from Y(1) (*‹Y ⊆ B›*) have "inj_on π Y" using inj_on_subset[of π UNIV Y] (*‹⟦inj π; Y ⊆ UNIV⟧ ⟹ inj_on π Y›*) "π'" (*‹π permutes B›*) by (auto simp: permutes_inj (*‹?p permutes ?S ⟹ inj ?p›*)) with Y (*‹(Y::nat set) ⊆ (B::nat set)› ‹card Y = k› ‹permutep π mon = monom_of_set Y›*) "π'" (*‹π permutes B›*) have "π ` Y ⊆ B" "card (π ` Y) = k" "mon = monom_of_set (π ` Y)" apply - (*goals: 1. ‹⟦Y ⊆ B; card Y = k; permutep π mon = monom_of_set Y; π permutes B; inj_on π Y⟧ ⟹ π ` Y ⊆ B› 2. ‹⟦Y ⊆ B; card Y = k; permutep π mon = monom_of_set Y; π permutes B; inj_on π Y⟧ ⟹ card (π ` Y) = k› 3. ‹⟦Y ⊆ B; card Y = k; permutep π mon = monom_of_set Y; π permutes B; inj_on π Y⟧ ⟹ mon = monom_of_set (π ` Y)› discuss goal 1*) apply ((auto simp: permutes_in_image (*‹?p permutes ?S ⟹ (?p ?x ∈ ?S) = (?x ∈ ?S)›*) card_image (*‹inj_on ?f ?A ⟹ card (?f ` ?A) = card ?A›*) permutep_monom_of_set (*‹bij ?f ⟹ permutep ?f (monom_of_set ?A) = monom_of_set (?f -` ?A)›*) permutes_bij (*‹?p permutes ?S ⟹ bij ?p›*) permutes_inj (*‹?p permutes ?S ⟹ inj ?p›*) permutes_surj (*‹?p permutes ?S ⟹ surj ?p›*))[1]) (*discuss goal 2*) apply ((auto simp: permutes_in_image (*‹?p permutes ?S ⟹ (?p ?x ∈ ?S) = (?x ∈ ?S)›*) card_image (*‹inj_on ?f ?A ⟹ card (?f ` ?A) = card ?A›*) permutep_monom_of_set (*‹bij ?f ⟹ permutep ?f (monom_of_set ?A) = monom_of_set (?f -` ?A)›*) permutes_bij (*‹?p permutes ?S ⟹ bij ?p›*) permutes_inj (*‹?p permutes ?S ⟹ inj ?p›*) permutes_surj (*‹?p permutes ?S ⟹ surj ?p›*))[1]) (*discuss goal 3*) apply ((auto simp: permutes_in_image (*‹?p permutes ?S ⟹ (?p ?x ∈ ?S) = (?x ∈ ?S)›*) card_image (*‹inj_on ?f ?A ⟹ card (?f ` ?A) = card ?A›*) permutep_monom_of_set (*‹bij ?f ⟹ permutep ?f (monom_of_set ?A) = monom_of_set (?f -` ?A)›*) permutes_bij (*‹?p permutes ?S ⟹ bij ?p›*) permutes_inj (*‹?p permutes ?S ⟹ inj ?p›*) permutes_surj (*‹?p permutes ?S ⟹ surj ?p›*))[1]) (*proven 3 subgoals*) . thus "?rhs = 1" using ‹finite B› (*‹finite B›*) by (auto simp: coeff_sym_mpoly (*‹MPoly_Type.coeff (sym_mpoly ?X ?k) ?mon = (if finite ?X ∧ (∃Y⊆?X. card Y = ?k ∧ ?mon = monom_of_set Y) then 1 else 0)›*)) qed hence "?lhs = ?rhs" by (auto simp: coeff_sym_mpoly (*‹MPoly_Type.coeff (sym_mpoly ?X ?k) ?mon = (if finite ?X ∧ (∃Y⊆?X. card Y = ?k ∧ ?mon = monom_of_set Y) then 1 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))›*)) finally (*calculation: ‹MPoly_Type.coeff (mpoly_map_vars π (sym_mpoly B k)) mon = MPoly_Type.coeff (sym_mpoly B k) mon›*) show "MPoly_Type.coeff (mpoly_map_vars π (sym_mpoly B k :: 'a mpoly)) mon = MPoly_Type.coeff (sym_mpoly B k :: 'a mpoly) mon" . qed lemma insertion_sym_mpoly: assumes "finite X" shows "insertion f (sym_mpoly X k) = (∑Y | Y ⊆ X ∧ card Y = k. prod f Y)" using assms (*‹finite X›*) apply transfer (*goal: ‹insertion f (sym_mpoly X k) = (∑Y | Y ⊆ X ∧ card Y = k. prod f Y)›*) proof (transfer) (*goal: ‹⋀X f k. finite X ⟹ insertion_fun f (λmon. if finite X ∧ (∃Y⊆X. card Y = k ∧ mon = monom_of_set Y) then 1 else 0) = sum (prod f) {Y. Y ⊆ X ∧ card Y = k}›*) fix f :: "nat ⇒ 'a" and k :: nat and X :: "nat set" assume X: "finite X" (*‹finite (X::nat set)›*) have "insertion_fun f (λmon. if finite X ∧ (∃Y⊆X. card Y = k ∧ mon = monom_of_set Y) then 1 else 0) = (∑m. (∏v. f v ^ poly_mapping.lookup m v) when (∃Y⊆X. card Y = k ∧ m = monom_of_set Y))" by (auto simp add: insertion_fun_def (*‹insertion_fun ?f ?p = (∑m. ?p m * (∏v. ?f v ^ lookup m v))›*) X (*‹finite X›*) when_def (*‹(?a when ?P) = (if ?P then ?a else 0)›*) intro!: Sum_any.cong (*‹(⋀a. ?g a = ?h a) ⟹ Sum_any ?g = Sum_any ?h›*)) also (*calculation: ‹insertion_fun (f::nat ⇒ 'a) (λmon::nat ⇒₀ nat. if finite (X::nat set) ∧ (∃Y⊆X. card Y = (k::nat) ∧ mon = monom_of_set Y) then 1::'a else (0::'a)) = (∑m::nat ⇒₀ nat. (∏v::nat. f v ^ lookup m v) when (∃Y⊆X. card Y = k ∧ m = monom_of_set Y))›*) have "… = (∑m | ∃Y∈Pow X. card Y = k ∧ m = monom_of_set Y. (∏v. f v ^ poly_mapping.lookup m v) when (∃Y⊆X. card Y = k ∧ m = monom_of_set Y))" apply (rule Sum_any.expand_superset (*‹⟦finite (?A::?'b set); {a::?'b. (?g::?'b ⇒ ?'a) a ≠ (0::?'a)} ⊆ ?A⟧ ⟹ Sum_any ?g = sum ?g ?A›*)) (*goals: 1. ‹finite {m. ∃Y∈Pow X. card Y = k ∧ m = monom_of_set Y}› 2. ‹{a. ((∏v. f v ^ lookup a v) when (∃Y⊆X. card Y = k ∧ a = monom_of_set Y)) ≠ 0} ⊆ {m. ∃Y∈Pow X. card Y = k ∧ m = monom_of_set Y}› discuss goal 1*) apply ((use X in auto)[1]) (*discuss goal 2*) apply ((use X in auto)[1]) (*proven 2 subgoals*) . also (*calculation: ‹insertion_fun (f::nat ⇒ 'a) (λmon::nat ⇒₀ nat. if finite (X::nat set) ∧ (∃Y⊆X. card Y = (k::nat) ∧ mon = monom_of_set Y) then 1::'a else (0::'a)) = (∑m::nat ⇒₀ nat | ∃Y::nat set∈Pow X. card Y = k ∧ m = monom_of_set Y. (∏v::nat. f v ^ lookup m v) when (∃Y⊆X. card Y = k ∧ m = monom_of_set Y))›*) have "… = (∑m | ∃Y∈Pow X. card Y = k ∧ m = monom_of_set Y. (∏v. f v ^ poly_mapping.lookup m v))" apply (intro sum.cong (*‹⟦?A = ?B; ⋀x. x ∈ ?B ⟹ ?g x = ?h x⟧ ⟹ sum ?g ?A = sum ?h ?B›*)) (*goals: 1. ‹{m. ∃Y∈Pow X. card Y = k ∧ m = monom_of_set Y} = {m. ∃Y∈Pow X. card Y = k ∧ m = monom_of_set Y}› 2. ‹⋀x. x ∈ {m. ∃Y∈Pow X. card Y = k ∧ m = monom_of_set Y} ⟹ ((∏v. f v ^ lookup x v) when (∃Y⊆X. card Y = k ∧ x = monom_of_set Y)) = (∏v. f v ^ lookup x v)› discuss goal 1*) apply ((auto simp: when_def (*‹(?a when ?P) = (if ?P then ?a else 0)›*))[1]) (*discuss goal 2*) apply ((auto simp: when_def (*‹(?a when ?P) = (if ?P then ?a else 0)›*))[1]) (*proven 2 subgoals*) . also (*calculation: ‹insertion_fun f (λmon. if finite X ∧ (∃Y⊆X. card Y = k ∧ mon = monom_of_set Y) then 1 else 0) = (∑m | ∃Y∈Pow X. card Y = k ∧ m = monom_of_set Y. ∏v. f v ^ lookup m v)›*) have "… = (∑Y | Y ⊆ X ∧ card Y = k. (∏v. f v ^ poly_mapping.lookup (monom_of_set Y) v))" apply (rule sum.reindex_bij_witness[of _ monom_of_set keys] (*‹⟦⋀a. a ∈ ?S ⟹ monom_of_set (keys a) = a; ⋀a. a ∈ ?S ⟹ keys a ∈ ?T; ⋀b. b ∈ ?T ⟹ keys (monom_of_set b) = b; ⋀b. b ∈ ?T ⟹ monom_of_set b ∈ ?S; ⋀a. a ∈ ?S ⟹ ?h (keys a) = ?g a⟧ ⟹ sum ?g ?S = sum ?h ?T›*)) (*goals: 1. ‹⋀a::nat ⇒₀ nat. a ∈ {m::nat ⇒₀ nat. ∃Y::nat set∈Pow (X::nat set). card Y = (k::nat) ∧ m = monom_of_set Y} ⟹ monom_of_set (keys a) = a› 2. ‹⋀a::nat ⇒₀ nat. a ∈ {m::nat ⇒₀ nat. ∃Y::nat set∈Pow (X::nat set). card Y = (k::nat) ∧ m = monom_of_set Y} ⟹ keys a ∈ {Y::nat set. Y ⊆ X ∧ card Y = k}› 3. ‹⋀b::nat set. b ∈ {Y::nat set. Y ⊆ (X::nat set) ∧ card Y = (k::nat)} ⟹ keys (monom_of_set b) = b› 4. ‹⋀b::nat set. b ∈ {Y::nat set. Y ⊆ (X::nat set) ∧ card Y = (k::nat)} ⟹ monom_of_set b ∈ {m::nat ⇒₀ nat. ∃Y::nat set∈Pow X. card Y = k ∧ m = monom_of_set Y}› 5. ‹⋀a::nat ⇒₀ nat. a ∈ {m::nat ⇒₀ nat. ∃Y::nat set∈Pow (X::nat set). card Y = (k::nat) ∧ m = monom_of_set Y} ⟹ (∏v::nat. (f::nat ⇒ 'a) v ^ lookup (monom_of_set (keys a)) v) = (∏v::nat. f v ^ lookup a v)› discuss goal 1*) apply ((auto simp: finite_subset[OF _ X] (*‹?A ⊆ X ⟹ finite ?A›*))[1]) (*discuss goal 2*) apply ((auto simp: finite_subset[OF _ X] (*‹(?A::nat set) ⊆ (X::nat set) ⟹ finite ?A›*))[1]) (*discuss goal 3*) apply ((auto simp: finite_subset[OF _ X] (*‹(?A::nat set) ⊆ (X::nat set) ⟹ finite ?A›*))[1]) (*discuss goal 4*) apply ((auto simp: finite_subset[OF _ X] (*‹(?A::nat set) ⊆ (X::nat set) ⟹ finite ?A›*))[1]) (*discuss goal 5*) apply ((auto simp: finite_subset[OF _ X] (*‹?A ⊆ X ⟹ finite ?A›*))[1]) (*proven 5 subgoals*) . also (*calculation: ‹insertion_fun f (λmon. if finite X ∧ (∃Y⊆X. card Y = k ∧ mon = monom_of_set Y) then 1 else 0) = (∑Y | Y ⊆ X ∧ card Y = k. ∏v. f v ^ lookup (monom_of_set Y) v)›*) have "… = (∑Y | Y ⊆ X ∧ card Y = k. ∏v∈Y. f v)" apply (intro sum.cong (*‹⟦?A = ?B; ⋀x. x ∈ ?B ⟹ ?g x = ?h x⟧ ⟹ sum ?g ?A = sum ?h ?B›*) when_cong (*‹⟦?P = ?Q; ?Q ⟹ ?a = ?b⟧ ⟹ (?a when ?P) = (?b when ?Q)›*) refl (*‹?t = ?t›*)) (*goal: ‹(∑Y::nat set | Y ⊆ (X::nat set) ∧ card Y = (k::nat). ∏v::nat. (f::nat ⇒ 'a) v ^ lookup (monom_of_set Y) v) = (∑Y::nat set | Y ⊆ X ∧ card Y = k. prod f Y)›*) proof (goal_cases) (*goal: ‹⋀x. x ∈ {Y. Y ⊆ X ∧ card Y = k} ⟹ (∏v. f v ^ lookup (monom_of_set x) v) = prod f x›*) case (1 Y) (*‹Y ∈ {Y. Y ⊆ X ∧ card Y = k}›*) hence "finite Y" by (auto dest: finite_subset[OF _ X] (*‹?A ⊆ X ⟹ finite ?A›*)) with "1" (*‹Y ∈ {Y. Y ⊆ X ∧ card Y = k}›*) have "(∏v. f v ^ poly_mapping.lookup (monom_of_set Y) v) = (∏v::nat. if v ∈ Y then f v else 1)" apply (intro Prod_any.cong (*‹(⋀a. ?g a = ?h a) ⟹ Prod_any ?g = Prod_any ?h›*)) (*goal: ‹(∏v. f v ^ lookup (monom_of_set Y) v) = (∏v. if v ∈ Y then f v else 1)›*) by (auto simp: lookup_monom_of_set (*‹lookup (monom_of_set (?X::nat set)) (?i::nat) = (if finite ?X ∧ ?i ∈ ?X then 1::nat else (0::nat))›*)) also (*calculation: ‹(∏v. f v ^ lookup (monom_of_set Y) v) = (∏v. if v ∈ Y then f v else 1)›*) have "… = (∏v∈Y. f v)" apply (rule Prod_any.conditionalize [symmetric] (*‹finite ?A ⟹ (∏a. if a ∈ ?A then ?g a else 1) = prod ?g ?A›*)) (*goal: ‹(∏v::nat. if v ∈ (Y::nat set) then (f::nat ⇒ 'a) v else (1::'a)) = prod f Y›*) by fact finally (*calculation: ‹(∏v. f v ^ lookup (monom_of_set Y) v) = prod f Y›*) show "?case" (*goal: ‹(∏v. f v ^ lookup (monom_of_set Y) v) = prod f Y›*) . qed finally (*calculation: ‹insertion_fun f (λmon. if finite X ∧ (∃Y⊆X. card Y = k ∧ mon = monom_of_set Y) then 1 else 0) = (∑Y | Y ⊆ X ∧ card Y = k. prod f Y)›*) show "insertion_fun f (λmon. if finite X ∧ (∃Y⊆X. card Y = k ∧ mon = monom_of_set Y) then 1 else 0) = (∑Y | Y ⊆ X ∧ card Y = k. prod f Y)" . qed lemma sym_mpoly_nz [simp]: assumes "finite A" "k ≤ card A" shows "sym_mpoly A k ≠ (0 :: 'a :: zero_neq_one mpoly)" proof (-) (*goal: ‹sym_mpoly A k ≠ 0›*) from assms (*‹finite A› ‹k ≤ card A›*) obtain B where B: "B ⊆ A" "card B = k" (*goal: ‹(⋀B. ⟦B ⊆ A; card B = k⟧ ⟹ thesis) ⟹ thesis›*) using ex_subset_of_card (*‹⟦finite ?A; ?k ≤ card ?A⟧ ⟹ ∃B⊆?A. card B = ?k›*) by blast with assms (*‹finite A› ‹k ≤ card A›*) have "coeff (sym_mpoly A k :: 'a mpoly) (monom_of_set B) = 1" apply (intro coeff_sym_mpoly_monom_of_set (*‹⟦finite ?X; ?Y ⊆ ?X; card ?Y = ?k⟧ ⟹ MPoly_Type.coeff (sym_mpoly ?X ?k) (monom_of_set ?Y) = 1›*)) (*goals: 1. ‹⟦finite A; k ≤ card A; B ⊆ A; card B = k⟧ ⟹ finite A› 2. ‹⟦finite A; k ≤ card A; B ⊆ A; card B = k⟧ ⟹ B ⊆ A› 3. ‹⟦finite A; k ≤ card A; B ⊆ A; card B = k⟧ ⟹ card B = k› discuss goal 1*) apply ((assumption)[1]) (*discuss goal 2*) apply ((assumption)[1]) (*discuss goal 3*) . (*proven 3 subgoals*) thus "?thesis" (*goal: ‹sym_mpoly A k ≠ 0›*) by auto qed lemma coeff_sym_mpoly_0_or_1: "coeff (sym_mpoly A k) m ∈ {0, 1}" apply transfer (*goal: ‹MPoly_Type.coeff (sym_mpoly (A::nat set) (k::nat)) (m::nat ⇒₀ nat) ∈ {0::'a, 1::'a}›*) apply transfer (*goal: ‹⋀A k m. lookup (sym_mpoly_aux A k) m ∈ {0, 1}›*) by auto lemma lead_coeff_sym_mpoly [simp]: assumes "finite A" "k ≤ card A" shows "lead_coeff (sym_mpoly A k) = 1" proof (-) (*goal: ‹Symmetric_Polynomials.lead_coeff (sym_mpoly (A::nat set) (k::nat)) = (1::'a)›*) from assms (*‹finite A› ‹k ≤ card A›*) have "lead_coeff (sym_mpoly A k) ≠ 0" by simp thus "?thesis" (*goal: ‹Symmetric_Polynomials.lead_coeff (sym_mpoly (A::nat set) (k::nat)) = (1::'a::zero_neq_one)›*) using coeff_sym_mpoly_0_or_1[of A k "lead_monom (sym_mpoly A k)"] (*‹MPoly_Type.coeff (sym_mpoly A k) (lead_monom (sym_mpoly A k)) ∈ {0, 1}›*) unfolding lead_coeff_def (*goal: ‹MPoly_Type.coeff (sym_mpoly A k) (lead_monom (sym_mpoly A k)) = 1›*) by blast qed lemma lead_monom_sym_mpoly: assumes "sorted xs" "distinct xs" "k ≤ length xs" shows "lead_monom (sym_mpoly (set xs) k :: 'a :: zero_neq_one mpoly) = monom_of_set (set (take k xs))" (is "lead_monom ?p = _") sorry subsection ‹Induction on the leading monomial› text ‹ We show that the monomial ordering for a fixed set of variables is well-founded, so we can perform induction on the leading monomial of a polynomial. › definition monom_less_on where "monom_less_on A = {(m1, m2). m1 < m2 ∧ keys m1 ⊆ A ∧ keys m2 ⊆ A}" lemma wf_monom_less_on: assumes "finite A" shows "wf (monom_less_on A :: ((nat ⇒₀ 'b :: {zero, wellorder}) × _) set)" proof (rule wf_subset (*‹⟦wf (?r::(?'a::type × ?'a::type) set); (?p::(?'a::type × ?'a::type) set) ⊆ ?r⟧ ⟹ wf ?p›*)) (*goals: 1. ‹wf ?r› 2. ‹monom_less_on A ⊆ ?r›*) define n where "n = Suc (Max (insert 0 A))" have less_n: "k < n" if "k ∈ A" for k using that (*‹k ∈ A›*) assms (*‹finite A›*) by (auto simp: n_def (*‹n = Suc (Max (insert 0 A))›*) less_Suc_eq_le (*‹(?m < Suc ?n) = (?m ≤ ?n)›*) Max_ge_iff (*‹⟦finite ?A; ?A ≠ {}⟧ ⟹ (?x ≤ Max ?A) = (∃a∈?A. ?x ≤ a)›*)) define f :: "(nat ⇒₀ 'b) ⇒ 'b list" where "f = (λm. map (lookup m) [0..<n])" show "wf (inv_image (lexn {(x,y). x < y} n) f)" by (intro wf_inv_image (*‹wf ?r ⟹ wf (inv_image ?r ?f)›*) wf_lexn (*‹wf ?r ⟹ wf (lexn ?r ?n)›*) wellorder_class.wf (*‹wf {(x, y). x < y}›*)) show "monom_less_on A ⊆ inv_image (lexn {(x, y). x < y} n) f" proof (safe) (*goal: ‹⋀a b. (a, b) ∈ monom_less_on A ⟹ (a, b) ∈ inv_image (lexn {(x, y). x < y} n) f›*) fix m1 :: "nat ⇒₀ 'b" and m2 :: "nat ⇒₀ 'b" assume "(m1, m2) ∈ monom_less_on A" (*‹(m1::nat ⇒₀ 'b, m2::nat ⇒₀ 'b) ∈ monom_less_on (A::nat set)›*) hence m12: "m1 < m2" "keys m1 ⊆ A" "keys m2 ⊆ A" apply - (*goals: 1. ‹(m1, m2) ∈ monom_less_on A ⟹ m1 < m2› 2. ‹(m1, m2) ∈ monom_less_on A ⟹ keys m1 ⊆ A› 3. ‹(m1, m2) ∈ monom_less_on A ⟹ keys m2 ⊆ A› discuss goal 1*) apply ((auto simp: monom_less_on_def (*‹monom_less_on (?A::?'a set) = {(m1::?'a ⇒₀ ?'b, m2::?'a ⇒₀ ?'b). m1 < m2 ∧ keys m1 ⊆ ?A ∧ keys m2 ⊆ ?A}›*))[1]) (*discuss goal 2*) apply ((auto simp: monom_less_on_def (*‹monom_less_on (?A::?'a set) = {(m1::?'a ⇒₀ ?'b, m2::?'a ⇒₀ ?'b). m1 < m2 ∧ keys m1 ⊆ ?A ∧ keys m2 ⊆ ?A}›*))[1]) (*discuss goal 3*) apply ((auto simp: monom_less_on_def (*‹monom_less_on ?A = {(m1, m2). m1 < m2 ∧ keys m1 ⊆ ?A ∧ keys m2 ⊆ ?A}›*))[1]) (*proven 3 subgoals*) . then obtain k where k: "lookup m1 k < lookup m2 k" "∀i<k. lookup m1 i = lookup m2 i" (*goal: ‹(⋀k. ⟦lookup m1 k < lookup m2 k; ∀i<k. lookup m1 i = lookup m2 i⟧ ⟹ thesis) ⟹ thesis›*) by (auto simp: less_poly_mapping_def (*‹(<) ≡ map_fun lookup (map_fun lookup id) less_fun›*) less_fun_def (*‹less_fun (?f::?'a ⇒ ?'b) (?g::?'a ⇒ ?'b) = (∃k::?'a. ?f k < ?g k ∧ (∀k'<k. ?f k' = ?g k'))›*)) have "¬(lookup m1 k = 0 ∧ lookup m2 k = 0)" proof (intro notI (*‹(?P::bool ⟹ False) ⟹ ¬ ?P›*)) (*goal: ‹lookup m1 k = 0 ∧ lookup m2 k = 0 ⟹ False›*) assume "lookup m1 k = 0 ∧ lookup m2 k = 0" (*‹lookup (m1::nat ⇒₀ 'b) (k::nat) = (0::'b) ∧ lookup (m2::nat ⇒₀ 'b) k = (0::'b)›*) hence [simp]: "lookup m1 k = 0" "lookup m2 k = 0" apply - (*goals: 1. ‹lookup m1 k = 0 ∧ lookup m2 k = 0 ⟹ lookup m1 k = 0› 2. ‹lookup m1 k = 0 ∧ lookup m2 k = 0 ⟹ lookup m2 k = 0› discuss goal 1*) apply blast (*discuss goal 2*) apply blast (*proven 2 subgoals*) . from k(1) (*‹lookup m1 k < lookup m2 k›*) show False by simp qed hence "k ∈ A" using m12 (*‹(m1::nat ⇒₀ 'b::{zero,wellorder}) < (m2::nat ⇒₀ 'b::{zero,wellorder})› ‹keys m1 ⊆ A› ‹keys m2 ⊆ A›*) by (auto simp: in_keys_iff (*‹(?x ∈ keys ?s) = (lookup ?s ?x ≠ 0)›*)) hence "k < n" by (simp add: less_n (*‹?k ∈ A ⟹ ?k < n›*)) define as where "as = map (lookup m1) [0..<k]" define bs1 where "bs1 = map (lookup m1) [Suc k..<n]" define bs2 where "bs2 = map (lookup m2) [Suc k..<n]" have decomp: "[0..<n] = [0..<k] @ [k] @ drop (Suc k) [0..<n]" using ‹k < n› (*‹(k::nat) < (n::nat)›*) by (simp flip: upt_conv_Cons (*‹(?i::nat) < (?j::nat) ⟹ [?i..<?j] = ?i # [Suc ?i..<?j]›*) upt_add_eq_append' (*‹⟦(?i::nat) ≤ (?j::nat); ?j ≤ (?k::nat)⟧ ⟹ [?i..<?k] = [?i..<?j] @ [?j..<?k]›*)) have [simp]: "length as = k" "length bs1 = n - Suc k" "length bs2 = n - Suc k" (*goals: 1. ‹length (as::'b::{zero,wellorder} list) = (k::nat)› 2. ‹length (bs1::'b::{zero,wellorder} list) = (n::nat) - Suc (k::nat)› 3. ‹length (bs2::'b::{zero,wellorder} list) = (n::nat) - Suc (k::nat)› discuss goal 1*) apply (simp add: as_def (*‹as = map (lookup m1) [0..<k]›*) bs1_def (*‹bs1 = map (lookup m1) [Suc k..<n]›*) bs2_def (*‹bs2 = map (lookup m2) [Suc k..<n]›*)) (*discuss goal 2*) apply (simp add: as_def (*‹as = map (lookup m1) [0..<k]›*) bs1_def (*‹bs1 = map (lookup m1) [Suc k..<n]›*) bs2_def (*‹bs2 = map (lookup m2) [Suc k..<n]›*)) (*discuss goal 3*) apply (simp add: as_def (*‹as = map (lookup m1) [0..<k]›*) bs1_def (*‹bs1 = map (lookup m1) [Suc k..<n]›*) bs2_def (*‹bs2 = map (lookup m2) [Suc k..<n]›*)) (*proven 3 subgoals*) . have "f m1 = as @ [lookup m1 k] @ bs1" unfolding f_def (*goal: ‹map (lookup m1) [0..<n] = as @ [lookup m1 k] @ bs1›*) apply (subst decomp (*‹[0..<n] = [0..<k] @ [k] @ drop (Suc k) [0..<n]›*)) (*goal: ‹map (lookup m1) [0..<n] = as @ [lookup m1 k] @ bs1›*) by (simp add: as_def (*‹(as::'b::{zero,wellorder} list) = map (lookup (m1::nat ⇒₀ 'b::{zero,wellorder})) [0::nat..<k::nat]›*) bs1_def (*‹(bs1::'b::{zero,wellorder} list) = map (lookup (m1::nat ⇒₀ 'b::{zero,wellorder})) [Suc (k::nat)..<n::nat]›*)) moreover have "f m2 = as @ [lookup m2 k] @ bs2" unfolding f_def (*goal: ‹map (lookup m2) [0..<n] = as @ [lookup m2 k] @ bs2›*) using k (*‹lookup m1 k < lookup m2 k› ‹∀i<k::nat. lookup (m1::nat ⇒₀ 'b) i = lookup (m2::nat ⇒₀ 'b) i›*) apply (subst decomp (*‹[0..<n] = [0..<k] @ [k] @ drop (Suc k) [0..<n]›*)) (*goal: ‹map (lookup m2) [0..<n] = as @ [lookup m2 k] @ bs2›*) by (simp add: as_def (*‹as = map (lookup m1) [0..<k]›*) bs2_def (*‹bs2 = map (lookup m2) [Suc k..<n]›*)) ultimately show "(m1, m2) ∈ inv_image (lexn {(x,y). x < y} n) f" using k(1) (*‹lookup (m1::nat ⇒₀ 'b) (k::nat) < lookup (m2::nat ⇒₀ 'b) k›*) ‹k < n› (*‹(k::nat) < (n::nat)›*) unfolding lexn_conv (*goal: ‹(m1, m2) ∈ inv_image {(xs, ys). length xs = n ∧ length ys = n ∧ (∃xys x y xs' ys'. xs = xys @ x # xs' ∧ ys = xys @ y # ys' ∧ (x, y) ∈ {(x, y). x < y})} f›*) by fastforce qed qed lemma lead_monom_induct [consumes 2, case_names less]: fixes p :: "'a :: zero mpoly" assumes fin: "finite A" and vars: "vars p ⊆ A" assumes IH: "⋀p. vars p ⊆ A ⟹ (⋀p'. vars p' ⊆ A ⟹ lead_monom p' < lead_monom p ⟹ P p') ⟹ P p" shows "P p" using assms(2) (*‹vars p ⊆ A›*) proof (induct m ≡ "lead_monom p" arbitrary: p rule: wf_induct_rule[OF wf_monom_less_on[OF fin]]) (*goal: ‹⋀p. ⟦⋀pa. ⟦(lead_monom pa, lead_monom p) ∈ monom_less_on A; vars pa ⊆ A⟧ ⟹ P pa; vars p ⊆ A⟧ ⟹ P p›*) case (1 p) (*‹⟦(lead_monom (?p::'a::zero mpoly), lead_monom (p::'a::zero mpoly)) ∈ monom_less_on (A::nat set); vars ?p ⊆ A⟧ ⟹ (P::'a::zero mpoly ⇒ bool) ?p› ‹vars p ⊆ A›*) show "?case" (*goal: ‹P p›*) proof (rule IH (*‹⟦vars (?p::'a mpoly) ⊆ (A::nat set); ⋀p'::'a mpoly. ⟦vars p' ⊆ A; lead_monom p' < lead_monom ?p⟧ ⟹ (P::'a mpoly ⇒ bool) p'⟧ ⟹ P ?p›*)) (*goals: 1. ‹vars (p::'a mpoly) ⊆ (A::nat set)› 2. ‹⋀p'::'a mpoly. ⟦vars p' ⊆ (A::nat set); lead_monom p' < lead_monom (p::'a mpoly)⟧ ⟹ (P::'a mpoly ⇒ bool) p'›*) fix p' :: "'a mpoly" assume "*": "vars p' ⊆ A" "lead_monom p' < lead_monom p" (*‹vars (p'::'a mpoly) ⊆ (A::nat set)› ‹lead_monom (p'::'a mpoly) < lead_monom (p::'a mpoly)›*) show "P p'" apply (rule 1 (*‹⟦(lead_monom ?p, lead_monom p) ∈ monom_less_on A; vars ?p ⊆ A⟧ ⟹ P ?p› ‹vars p ⊆ A›*)) (*goals: 1. ‹(lead_monom p', lead_monom p) ∈ monom_less_on A› 2. ‹vars p' ⊆ A› discuss goal 1*) apply ((insert * (*‹vars p' ⊆ A› ‹lead_monom p' < lead_monom p›*) "1.prems" (*‹vars p ⊆ A›*) keys_lead_monom_subset (*‹keys (lead_monom ?p) ⊆ vars ?p›*))[1]) (*top goal: ‹(lead_monom (p'::'a mpoly), lead_monom (p::'a mpoly)) ∈ monom_less_on (A::nat set)› and 1 goal remains*) apply ((auto simp: monom_less_on_def (*‹monom_less_on ?A = {(m1, m2). m1 < m2 ∧ keys m1 ⊆ ?A ∧ keys m2 ⊆ ?A}›*))[1]) (*discuss goal 2*) apply ((insert * (*‹vars p' ⊆ A› ‹lead_monom p' < lead_monom p›*) "1.prems" (*‹vars p ⊆ A›*) keys_lead_monom_subset (*‹keys (lead_monom ?p) ⊆ vars ?p›*))[1]) (*goal: ‹vars p' ⊆ A›*) apply ((auto simp: monom_less_on_def (*‹monom_less_on (?A::?'a::linorder set) = {(m1::?'a::linorder ⇒₀ ?'b::{zero,linorder}, m2::?'a::linorder ⇒₀ ?'b::{zero,linorder}). m1 < m2 ∧ keys m1 ⊆ ?A ∧ keys m2 ⊆ ?A}›*))[1]) (*proven 2 subgoals*) . qed (insert 1 (*‹⟦(lead_monom ?p, lead_monom p) ∈ monom_less_on A; vars ?p ⊆ A⟧ ⟹ P ?p› ‹vars p ⊆ A›*), auto) (*solved the remaining goal: ‹vars p ⊆ A›*) qed lemma lead_monom_induct' [case_names less]: fixes p :: "'a :: zero mpoly" assumes IH: "⋀p. (⋀p'. vars p' ⊆ vars p ⟹ lead_monom p' < lead_monom p ⟹ P p') ⟹ P p" shows "P p" proof (-) (*goal: ‹P p›*) have "finite (vars p)" "vars p ⊆ vars p" (*goals: 1. ‹finite (vars (p::'a mpoly))› 2. ‹vars (p::'a mpoly) ⊆ vars p› discuss goal 1*) apply ((auto simp: vars_finite (*‹finite (vars ?p)›*))[1]) (*discuss goal 2*) apply ((auto simp: vars_finite (*‹finite (vars ?p)›*))[1]) (*proven 2 subgoals*) . thus "?thesis" (*goal: ‹P p›*) apply (induction rule: lead_monom_induct (*‹⟦finite (?A::nat set); vars (?p::?'a::zero mpoly) ⊆ ?A; ⋀p::?'a::zero mpoly. ⟦vars p ⊆ ?A; ⋀p'::?'a::zero mpoly. ⟦vars p' ⊆ ?A; lead_monom p' < lead_monom p⟧ ⟹ (?P::?'a::zero mpoly ⇒ bool) p'⟧ ⟹ ?P p⟧ ⟹ ?P ?p›*)) (*goal: ‹(P::'a mpoly ⇒ bool) (p::'a mpoly)›*) by (use IH in blast) qed subsection ‹The fundamental theorem of symmetric polynomials› lemma lead_coeff_sym_mpoly_powerprod: assumes "finite A" "⋀x. x ∈ X ⟹ f x ∈ {1..card A}" shows "lead_coeff (∏x∈X. sym_mpoly A (f (x::'a)) ^ g x) = 1" proof (-) (*goal: ‹Symmetric_Polynomials.lead_coeff (∏x∈X. sym_mpoly A (f x) ^ g x) = 1›*) have eq: "lead_coeff (sym_mpoly A (f x) ^ g x :: 'b mpoly) = 1" if "x ∈ X" for x using that (*‹x ∈ X›*) assms (*‹finite A› ‹(?x::'a) ∈ (X::'a set) ⟹ (f::'a ⇒ nat) ?x ∈ {1::nat..card (A::nat set)}›*) apply (subst lead_coeff_power (*‹Symmetric_Polynomials.lead_coeff ?p ^ ?n ≠ 0 ⟹ Symmetric_Polynomials.lead_coeff (?p ^ ?n) = Symmetric_Polynomials.lead_coeff ?p ^ ?n›*)) (*goals: 1. ‹⟦x ∈ X; finite A; ⋀x. x ∈ X ⟹ f x ∈ {1..card A}⟧ ⟹ Symmetric_Polynomials.lead_coeff (sym_mpoly A (f x)) ^ g x ≠ 0› 2. ‹⟦x ∈ X; finite A; ⋀x. x ∈ X ⟹ f x ∈ {1..card A}⟧ ⟹ Symmetric_Polynomials.lead_coeff (sym_mpoly A (f x)) ^ g x = 1› discuss goal 1*) apply ((auto simp: lead_coeff_sym_mpoly (*‹⟦finite ?A; ?k ≤ card ?A⟧ ⟹ Symmetric_Polynomials.lead_coeff (sym_mpoly ?A ?k) = 1›*) assms (*‹finite A› ‹?x ∈ X ⟹ f ?x ∈ {1..card A}›*))[1]) (*discuss goal 2*) apply ((auto simp: lead_coeff_sym_mpoly (*‹⟦finite ?A; ?k ≤ card ?A⟧ ⟹ Symmetric_Polynomials.lead_coeff (sym_mpoly ?A ?k) = 1›*) assms (*‹finite A› ‹?x ∈ X ⟹ f ?x ∈ {1..card A}›*))[1]) (*proven 2 subgoals*) . hence "(∏x∈X. lead_coeff (sym_mpoly A (f x) ^ g x :: 'b mpoly)) = (∏x∈X. 1)" by (intro prod.cong (*‹⟦?A = ?B; ⋀x. x ∈ ?B ⟹ ?g x = ?h x⟧ ⟹ prod ?g ?A = prod ?h ?B›*) eq (*‹?x ∈ X ⟹ Symmetric_Polynomials.lead_coeff (sym_mpoly A (f ?x) ^ g ?x) = 1›*) refl (*‹?t = ?t›*)) also (*calculation: ‹(∏x∈X. Symmetric_Polynomials.lead_coeff (sym_mpoly A (f x) ^ g x)) = (∏x∈X. 1)›*) have "… = 1" by simp finally (*calculation: ‹(∏x∈X. Symmetric_Polynomials.lead_coeff (sym_mpoly A (f x) ^ g x)) = 1›*) have eq': "(∏x∈X. lead_coeff (sym_mpoly A (f x) ^ g x :: 'b mpoly)) = 1" . show "?thesis" (*goal: ‹Symmetric_Polynomials.lead_coeff (∏x∈X. sym_mpoly A (f x) ^ g x) = 1›*) apply (subst lead_coeff_prod (*‹(∏i∈?A. Symmetric_Polynomials.lead_coeff (?f i)) ≠ 0 ⟹ Symmetric_Polynomials.lead_coeff (prod ?f ?A) = (∏i∈?A. Symmetric_Polynomials.lead_coeff (?f i))›*)) (*goals: 1. ‹(∏i::'a∈(X::'a set). Symmetric_Polynomials.lead_coeff (sym_mpoly (A::nat set) ((f::'a ⇒ nat) i) ^ (g::'a ⇒ nat) i)) ≠ (0::'b)› 2. ‹(∏i::'a∈(X::'a set). Symmetric_Polynomials.lead_coeff (sym_mpoly (A::nat set) ((f::'a ⇒ nat) i) ^ (g::'a ⇒ nat) i)) = (1::'b)› discuss goal 1*) apply ((auto simp: eq (*‹(?x::'a) ∈ (X::'a set) ⟹ Symmetric_Polynomials.lead_coeff (sym_mpoly (A::nat set) ((f::'a ⇒ nat) ?x) ^ (g::'a ⇒ nat) ?x) = (1::'b)›*) eq' (*‹(∏x::'a∈(X::'a set). Symmetric_Polynomials.lead_coeff (sym_mpoly (A::nat set) ((f::'a ⇒ nat) x) ^ (g::'a ⇒ nat) x)) = (1::'b)›*))[1]) (*discuss goal 2*) apply ((auto simp: eq (*‹?x ∈ X ⟹ Symmetric_Polynomials.lead_coeff (sym_mpoly A (f ?x) ^ g ?x) = 1›*) eq' (*‹(∏x∈X. Symmetric_Polynomials.lead_coeff (sym_mpoly A (f x) ^ g x)) = 1›*))[1]) (*proven 2 subgoals*) . qed context fixes A :: "nat set" and xs n f and decr :: "'a :: comm_ring_1 mpoly ⇒ bool" defines "xs ≡ sorted_list_of_set A" defines "n ≡ card A" defines "f ≡ (λi. if i < n then xs ! i else 0)" defines "decr ≡ (λp. ∀i∈A. ∀j∈A. i ≤ j ⟶ lookup (lead_monom p) i ≥ lookup (lead_monom p) j)" begin text ‹ The computation of the witness for the fundamental theorem works like this: Given some polynomial $p$ (that is assumed to be symmetric in the variables in $A$), we inspect its leading monomial, which is of the form $c X_1^{i_1}\ldots X_n{i_n}$ where the $A = \{X_1,\ldots, X_n\}$, $c$ contains only variables not in $A$, and the sequence $i_j$ is decreasing. The latter holds because $p$ is symmetric. Now, we form the polynomial $q := c e_1^{i_1 - i_2} e_2^{i_2 - i_3} \ldots e_n^{i_n}$, which has the same leading term as $p$. Then $p - q$ has a smaller leading monomial, so by induction, we can assume it to be of the required form and obtain a witness for $p - q$. Now, we only need to add $c Y_1^{i_1 - i_2} \ldots Y_n^{i_n}$ to that witness and we obtain a witness for $p$. › definition fund_sym_step_coeff :: "'a mpoly ⇒ 'a mpoly" where "fund_sym_step_coeff p = monom (restrictpm (-A) (lead_monom p)) (lead_coeff p)" definition fund_sym_step_monom :: "'a mpoly ⇒ (nat ⇒₀ nat)" where "fund_sym_step_monom p = ( let g = (λi. if i < n then lookup (lead_monom p) (f i) else 0) in (∑i<n. Poly_Mapping.single (Suc i) (g i - g (Suc i))))" definition fund_sym_step_poly :: "'a mpoly ⇒ 'a mpoly" where "fund_sym_step_poly p = ( let g = (λi. if i < n then lookup (lead_monom p) (f i) else 0) in fund_sym_step_coeff p * (∏i<n. sym_mpoly A (Suc i) ^ (g i - g (Suc i))))" text ‹ The following function computes the witness, with the convention that it returns a constant polynomial if the input was not symmetric: › function (domintros) fund_sym_poly_wit :: "'a :: comm_ring_1 mpoly ⇒ 'a mpoly mpoly" where "fund_sym_poly_wit p = (if ¬symmetric_mpoly A p ∨ lead_monom p = 0 ∨ vars p ∩ A = {} then Const p else fund_sym_poly_wit (p - fund_sym_step_poly p) + monom (fund_sym_step_monom p) (fund_sym_step_coeff p))" by auto lemma coeff_fund_sym_step_coeff: "coeff (fund_sym_step_coeff p) m ∈ {lead_coeff p, 0}" by (auto simp: fund_sym_step_coeff_def (*‹local.fund_sym_step_coeff ?p = MPoly_Type.monom (restrictpm (- A) (lead_monom ?p)) (Symmetric_Polynomials.lead_coeff ?p)›*) coeff_monom (*‹MPoly_Type.coeff (MPoly_Type.monom ?m ?a) ?m' = (?a when ?m' = ?m)›*) when_def (*‹(?a when ?P) = (if ?P then ?a else 0)›*)) lemma vars_fund_sym_step_coeff: "vars (fund_sym_step_coeff p) ⊆ vars p - A" unfolding fund_sym_step_coeff_def (*goal: ‹vars (MPoly_Type.monom (restrictpm (- (A::nat set)) (lead_monom (p::'a mpoly))) (Symmetric_Polynomials.lead_coeff p)) ⊆ vars p - A›*) using keys_lead_monom_subset[of p] (*‹keys (lead_monom p) ⊆ vars p›*) apply (intro order.trans[OF vars_monom_subset] (*‹keys ?m1 ⊆ ?c ⟹ vars (MPoly_Type.monom ?m1 ?a1) ⊆ ?c›*)) (*goal: ‹vars (MPoly_Type.monom (restrictpm (- (A::nat set)) (lead_monom (p::'a mpoly))) (Symmetric_Polynomials.lead_coeff p)) ⊆ vars p - A›*) by auto lemma keys_fund_sym_step_monom: "keys (fund_sym_step_monom p) ⊆ {1..n}" unfolding fund_sym_step_monom_def Let_def (*goal: ‹keys (∑i<n. Poly_Mapping.single (Suc i) ((if i < n then lookup (lead_monom p) (f i) else 0) - (if Suc i < n then lookup (lead_monom p) (f (Suc i)) else 0))) ⊆ {1..n}›*) apply (intro order.trans[OF keys_sum] (*‹(⋃i∈?I1. keys (?b1 i)) ⊆ ?c ⟹ keys (sum ?b1 ?I1) ⊆ ?c›*) UN_least (*‹(⋀x. x ∈ ?A ⟹ ?B x ⊆ ?C) ⟹ ⋃ (?B ` ?A) ⊆ ?C›*)) (*goal: ‹keys (∑i<n. Poly_Mapping.single (Suc i) ((if i < n then lookup (lead_monom p) (f i) else 0) - (if Suc i < n then lookup (lead_monom p) (f (Suc i)) else 0))) ⊆ {1..n}›*) apply (subst keys_single (*‹keys (Poly_Mapping.single ?k ?v) = (if ?v = 0 then {} else {?k})›*)) (*goal: ‹⋀i::nat. i ∈ {..<n::nat} ⟹ keys (Poly_Mapping.single (Suc i) ((if i < n then lookup (lead_monom (p::'a mpoly)) ((f::nat ⇒ nat) i) else (0::nat)) - (if Suc i < n then lookup (lead_monom p) (f (Suc i)) else (0::nat)))) ⊆ {1::nat..n}›*) by auto lemma coeff_fund_sym_step_poly: assumes C: "∀m. coeff p m ∈ C" and "ring_closed C" shows "coeff (fund_sym_step_poly p) m ∈ C" proof (-) (*goal: ‹MPoly_Type.coeff (local.fund_sym_step_poly p) m ∈ C›*) interpret ring_closed C by fact have "*": "⋀m. coeff (p ^ x) m ∈ C" if "⋀m. coeff p m ∈ C" for p and x using that (*‹MPoly_Type.coeff p ?m ∈ C›*) apply (induction x) (*goals: 1. ‹⋀m. (⋀m. MPoly_Type.coeff p m ∈ C) ⟹ MPoly_Type.coeff (p ^ 0) m ∈ C› 2. ‹⋀x m. ⟦⋀m. (⋀m. MPoly_Type.coeff p m ∈ C) ⟹ MPoly_Type.coeff (p ^ x) m ∈ C; ⋀m. MPoly_Type.coeff p m ∈ C⟧ ⟹ MPoly_Type.coeff (p ^ Suc x) m ∈ C› discuss goal 1*) apply ((auto simp: coeff_mpoly_times (*‹MPoly_Type.coeff ((?p::?'a mpoly) * (?q::?'a mpoly)) (?mon::nat ⇒₀ nat) = prod_fun (MPoly_Type.coeff ?p) (MPoly_Type.coeff ?q) ?mon›*) mpoly_coeff_1 (*‹MPoly_Type.coeff (1::?'a mpoly) (?m::nat ⇒₀ nat) = (if ?m = (0::nat ⇒₀ nat) then 1::?'a else (0::?'a))›*) intro!: prod_fun_closed (*‹⟦⋀x::?'b. (?f::?'b ⇒ 'a) x ∈ (C::'a set); ⋀x::?'b. (?g::?'b ⇒ 'a) x ∈ C⟧ ⟹ prod_fun ?f ?g (?x::?'b) ∈ C›*))[1]) (*discuss goal 2*) apply ((auto simp: coeff_mpoly_times (*‹MPoly_Type.coeff (?p * ?q) ?mon = prod_fun (MPoly_Type.coeff ?p) (MPoly_Type.coeff ?q) ?mon›*) mpoly_coeff_1 (*‹MPoly_Type.coeff 1 ?m = (if ?m = 0 then 1 else 0)›*) intro!: prod_fun_closed (*‹⟦⋀x. ?f x ∈ C; ⋀x. ?g x ∈ C⟧ ⟹ prod_fun ?f ?g ?x ∈ C›*))[1]) (*proven 2 subgoals*) . have "**": "⋀m. coeff (prod f X) m ∈ C" if "⋀i m. i ∈ X ⟹ coeff (f i) m ∈ C" for X and f :: "nat ⇒ _" using that (*‹?i ∈ X ⟹ MPoly_Type.coeff (f ?i) ?m ∈ C›*) apply (induction X 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::nat set) m::nat ⇒₀ nat. ⟦infinite A; ⋀(i::nat) m::nat ⇒₀ nat. i ∈ A ⟹ MPoly_Type.coeff ((f::nat ⇒ 'a mpoly) i) m ∈ (C::'a set)⟧ ⟹ MPoly_Type.coeff (prod f A) m ∈ C› 2. ‹⋀m::nat ⇒₀ nat. (⋀(i::nat) m::nat ⇒₀ nat. i ∈ {} ⟹ MPoly_Type.coeff ((f::nat ⇒ 'a mpoly) i) m ∈ (C::'a set)) ⟹ MPoly_Type.coeff (prod f {}) m ∈ C› 3. ‹⋀(x::nat) (F::nat set) m::nat ⇒₀ nat. ⟦finite F; x ∉ F; ⋀m::nat ⇒₀ nat. (⋀(i::nat) m::nat ⇒₀ nat. i ∈ F ⟹ MPoly_Type.coeff ((f::nat ⇒ 'a mpoly) i) m ∈ (C::'a set)) ⟹ MPoly_Type.coeff (prod f F) m ∈ C; ⋀(i::nat) m::nat ⇒₀ nat. i ∈ insert x F ⟹ MPoly_Type.coeff (f i) m ∈ C⟧ ⟹ MPoly_Type.coeff (prod f (insert x F)) m ∈ C› discuss goal 1*) apply ((auto simp: coeff_mpoly_times (*‹MPoly_Type.coeff ((?p::?'a mpoly) * (?q::?'a mpoly)) (?mon::nat ⇒₀ nat) = prod_fun (MPoly_Type.coeff ?p) (MPoly_Type.coeff ?q) ?mon›*) mpoly_coeff_1 (*‹MPoly_Type.coeff (1::?'a mpoly) (?m::nat ⇒₀ nat) = (if ?m = (0::nat ⇒₀ nat) then 1::?'a else (0::?'a))›*) intro!: prod_fun_closed (*‹⟦⋀x::?'b. (?f::?'b ⇒ 'a) x ∈ (C::'a set); ⋀x::?'b. (?g::?'b ⇒ 'a) x ∈ C⟧ ⟹ prod_fun ?f ?g (?x::?'b) ∈ C›*))[1]) (*discuss goal 2*) apply ((auto simp: coeff_mpoly_times (*‹MPoly_Type.coeff (?p * ?q) ?mon = prod_fun (MPoly_Type.coeff ?p) (MPoly_Type.coeff ?q) ?mon›*) mpoly_coeff_1 (*‹MPoly_Type.coeff 1 ?m = (if ?m = 0 then 1 else 0)›*) intro!: prod_fun_closed (*‹⟦⋀x. ?f x ∈ C; ⋀x. ?g x ∈ C⟧ ⟹ prod_fun ?f ?g ?x ∈ C›*))[1]) (*discuss goal 3*) apply ((auto simp: coeff_mpoly_times (*‹MPoly_Type.coeff (?p * ?q) ?mon = prod_fun (MPoly_Type.coeff ?p) (MPoly_Type.coeff ?q) ?mon›*) mpoly_coeff_1 (*‹MPoly_Type.coeff 1 ?m = (if ?m = 0 then 1 else 0)›*) intro!: prod_fun_closed (*‹⟦⋀x. ?f x ∈ C; ⋀x. ?g x ∈ C⟧ ⟹ prod_fun ?f ?g ?x ∈ C›*))[1]) (*proven 3 subgoals*) . show "?thesis" (*goal: ‹MPoly_Type.coeff (local.fund_sym_step_poly p) m ∈ C›*) using C (*‹∀m. MPoly_Type.coeff p m ∈ C›*) unfolding fund_sym_step_poly_def Let_def fund_sym_step_coeff_def coeff_mpoly_times (*goal: ‹prod_fun (MPoly_Type.coeff (MPoly_Type.monom (restrictpm (- A) (lead_monom p)) (Symmetric_Polynomials.lead_coeff p))) (MPoly_Type.coeff (∏i<n. sym_mpoly A (Suc i) ^ ((if i < n then lookup (lead_monom p) (f i) else 0) - (if Suc i < n then lookup (lead_monom p) (f (Suc i)) else 0)))) m ∈ C›*) apply (intro prod_fun_closed (*‹⟦⋀x. ?f x ∈ C; ⋀x. ?g x ∈ C⟧ ⟹ prod_fun ?f ?g ?x ∈ C›*)) (*goals: 1. ‹⋀x::nat ⇒₀ nat. ∀m::nat ⇒₀ nat. MPoly_Type.coeff (p::'a::comm_ring_1 mpoly) m ∈ (C::'a::comm_ring_1 set) ⟹ MPoly_Type.coeff (MPoly_Type.monom (restrictpm (- (A::nat set)) (lead_monom p)) (Symmetric_Polynomials.lead_coeff p)) x ∈ C› 2. ‹⋀x::nat ⇒₀ nat. ∀m::nat ⇒₀ nat. MPoly_Type.coeff (p::'a::comm_ring_1 mpoly) m ∈ (C::'a::comm_ring_1 set) ⟹ MPoly_Type.coeff (∏i::nat<n. sym_mpoly (A::nat set) (Suc i) ^ ((if i < (n::nat) then lookup (lead_monom p) ((f::nat ⇒ nat) i) else (0::nat)) - (if Suc i < n then lookup (lead_monom p) (f (Suc i)) else (0::nat)))) x ∈ C› discuss goal 1*) apply ((auto simp: coeff_monom (*‹MPoly_Type.coeff (MPoly_Type.monom ?m ?a) ?m' = (?a when ?m' = ?m)›*) when_def (*‹(?a when ?P) = (if ?P then ?a else 0)›*) lead_coeff_def (*‹Symmetric_Polynomials.lead_coeff ?p = MPoly_Type.coeff ?p (lead_monom ?p)›*) coeff_sym_mpoly (*‹MPoly_Type.coeff (sym_mpoly ?X ?k) ?mon = (if finite ?X ∧ (∃Y⊆?X. card Y = ?k ∧ ?mon = monom_of_set Y) then 1 else 0)›*) intro!: * (*‹(⋀m. MPoly_Type.coeff ?p1 m ∈ C) ⟹ MPoly_Type.coeff (?p1 ^ ?x1) ?m ∈ C›*) ** (*‹(⋀i m. i ∈ ?X1 ⟹ MPoly_Type.coeff (?f1 i) m ∈ C) ⟹ MPoly_Type.coeff (prod ?f1 ?X1) ?m ∈ C›*))[1]) (*discuss goal 2*) apply ((auto simp: coeff_monom (*‹MPoly_Type.coeff (MPoly_Type.monom (?m::nat ⇒₀ nat) (?a::?'a)) (?m'::nat ⇒₀ nat) = (?a when ?m' = ?m)›*) when_def (*‹((?a::?'a) when (?P::bool)) = (if ?P then ?a else (0::?'a))›*) lead_coeff_def (*‹Symmetric_Polynomials.lead_coeff (?p::?'a mpoly) = MPoly_Type.coeff ?p (lead_monom ?p)›*) coeff_sym_mpoly (*‹MPoly_Type.coeff (sym_mpoly (?X::nat set) (?k::nat)) (?mon::nat ⇒₀ nat) = (if finite ?X ∧ (∃Y⊆?X. card Y = ?k ∧ ?mon = monom_of_set Y) then 1::?'a else (0::?'a))›*) intro!: * (*‹(⋀m::nat ⇒₀ nat. MPoly_Type.coeff (?p1::'a mpoly) m ∈ (C::'a set)) ⟹ MPoly_Type.coeff (?p1 ^ (?x1::nat)) (?m::nat ⇒₀ nat) ∈ C›*) ** (*‹(⋀(i::nat) m::nat ⇒₀ nat. i ∈ (?X1::nat set) ⟹ MPoly_Type.coeff ((?f1::nat ⇒ 'a mpoly) i) m ∈ (C::'a set)) ⟹ MPoly_Type.coeff (prod ?f1 ?X1) (?m::nat ⇒₀ nat) ∈ C›*))[1]) (*proven 2 subgoals*) . qed text ‹ We now show various relevant properties of the subtracted polynomial: ▸ Its leading term is the same as that of the input polynomial. ▸ It contains now new variables. ▸ It is symmetric in the variables in ‹A›. › lemma fund_sym_step_poly: shows "finite A ⟹ p ≠ 0 ⟹ decr p ⟹ lead_monom (fund_sym_step_poly p) = lead_monom p" and "finite A ⟹ p ≠ 0 ⟹ decr p ⟹ lead_coeff (fund_sym_step_poly p) = lead_coeff p" and "finite A ⟹ p ≠ 0 ⟹ decr p ⟹ fund_sym_step_poly p = fund_sym_step_coeff p * (∏x. sym_mpoly A x ^ lookup (fund_sym_step_monom p) x)" and "vars (fund_sym_step_poly p) ⊆ vars p ∪ A" and "symmetric_mpoly A (fund_sym_step_poly p)" proof (-) (*goals: 1. ‹⟦finite A; p ≠ 0; decr p⟧ ⟹ lead_monom (local.fund_sym_step_poly p) = lead_monom p› 2. ‹⟦finite A; p ≠ 0; decr p⟧ ⟹ Symmetric_Polynomials.lead_coeff (local.fund_sym_step_poly p) = Symmetric_Polynomials.lead_coeff p› 3. ‹⟦finite A; p ≠ 0; decr p⟧ ⟹ local.fund_sym_step_poly p = local.fund_sym_step_coeff p * (∏x. sym_mpoly A x ^ lookup (local.fund_sym_step_monom p) x)› 4. ‹vars (local.fund_sym_step_poly p) ⊆ vars p ∪ A› 5. ‹symmetric_mpoly A (local.fund_sym_step_poly p)›*) define g where "g = (λi. if i < n then lookup (lead_monom p) (f i) else 0)" define q where "q = (∏i<n. sym_mpoly A (Suc i) ^ (g i - g (Suc i)) :: 'a mpoly)" define c where "c = monom (restrictpm (-A) (lead_monom p)) (lead_coeff p)" have [simp]: "fund_sym_step_poly p = c * q" by (simp add: fund_sym_step_poly_def (*‹local.fund_sym_step_poly ?p = (let g = λi. if i < n then lookup (lead_monom ?p) (f i) else 0 in local.fund_sym_step_coeff ?p * (∏i<n. sym_mpoly A (Suc i) ^ (g i - g (Suc i))))›*) fund_sym_step_coeff_def (*‹local.fund_sym_step_coeff ?p = MPoly_Type.monom (restrictpm (- A) (lead_monom ?p)) (Symmetric_Polynomials.lead_coeff ?p)›*) c_def (*‹c = MPoly_Type.monom (restrictpm (- A) (lead_monom p)) (Symmetric_Polynomials.lead_coeff p)›*) q_def (*‹q = (∏i<n. sym_mpoly A (Suc i) ^ (g i - g (Suc i)))›*) f_def (*‹f ≡ λi. if i < n then xs ! i else 0›*) g_def (*‹g = (λi. if i < n then lookup (lead_monom p) (f i) else 0)›*)) have "vars (c * q) ⊆ vars p ∪ A" using keys_lead_monom_subset[of p] (*‹keys (lead_monom (p::'a mpoly)) ⊆ vars p›*) vars_monom_subset[of "restrictpm (-A) (lead_monom p)" "lead_coeff p"] (*‹vars (MPoly_Type.monom (restrictpm (- A) (lead_monom p)) (Symmetric_Polynomials.lead_coeff p)) ⊆ keys (restrictpm (- A) (lead_monom p))›*) unfolding c_def q_def (*goal: ‹vars (MPoly_Type.monom (restrictpm (- A) (lead_monom p)) (Symmetric_Polynomials.lead_coeff p) * (∏i<n. sym_mpoly A (Suc i) ^ (g i - g (Suc i)))) ⊆ vars p ∪ A›*) apply (intro order.trans[OF vars_mult] (*‹vars ?p1 ∪ vars ?q1 ⊆ ?c ⟹ vars (?p1 * ?q1) ⊆ ?c›*) order.trans[OF vars_prod] (*‹(⋃x∈?A1. vars (?f1 x)) ⊆ ?c ⟹ vars (prod ?f1 ?A1) ⊆ ?c›*) order.trans[OF vars_power] (*‹vars ?p1 ⊆ ?c ⟹ vars (?p1 ^ ?n1) ⊆ ?c›*) Un_least (*‹⟦?A ⊆ ?C; ?B ⊆ ?C⟧ ⟹ ?A ∪ ?B ⊆ ?C›*) UN_least (*‹(⋀x. x ∈ ?A ⟹ ?B x ⊆ ?C) ⟹ ⋃ (?B ` ?A) ⊆ ?C›*) order.trans[OF vars_sym_mpoly_subset] (*‹?b ⊆ ?c ⟹ vars (sym_mpoly ?b ?k1) ⊆ ?c›*)) (*goals: 1. ‹⟦keys (lead_monom p) ⊆ vars p; vars (MPoly_Type.monom (restrictpm (- A) (lead_monom p)) (Symmetric_Polynomials.lead_coeff p)) ⊆ keys (restrictpm (- A) (lead_monom p))⟧ ⟹ vars (MPoly_Type.monom (restrictpm (- A) (lead_monom p)) (Symmetric_Polynomials.lead_coeff p)) ⊆ vars p ∪ A› 2. ‹⋀x. ⟦keys (lead_monom p) ⊆ vars p; vars (MPoly_Type.monom (restrictpm (- A) (lead_monom p)) (Symmetric_Polynomials.lead_coeff p)) ⊆ keys (restrictpm (- A) (lead_monom p)); x ∈ {..<n}⟧ ⟹ A ⊆ vars p ∪ A› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . thus "vars (fund_sym_step_poly p) ⊆ vars p ∪ A" by simp have "symmetric_mpoly A (c * q)" unfolding c_def q_def (*goal: ‹symmetric_mpoly (A::nat set) (MPoly_Type.monom (restrictpm (- A) (lead_monom (p::'a::comm_ring_1 mpoly))) (Symmetric_Polynomials.lead_coeff p) * (∏i::nat<n::nat. sym_mpoly A (Suc i) ^ ((g::nat ⇒ nat) i - g (Suc i))))›*) apply (intro symmetric_mpoly_mult (*‹⟦symmetric_mpoly (?A::nat set) (?p::?'a mpoly); symmetric_mpoly ?A (?q::?'a mpoly)⟧ ⟹ symmetric_mpoly ?A (?p * ?q)›*) symmetric_mpoly_monom (*‹keys (?m::nat ⇒₀ nat) ∩ (?A::nat set) = {} ⟹ symmetric_mpoly ?A (MPoly_Type.monom ?m (?c::?'a))›*) symmetric_mpoly_prod (*‹(⋀i::?'a. i ∈ (?B::?'a set) ⟹ symmetric_mpoly (?A::nat set) ((?f::?'a ⇒ ?'b mpoly) i)) ⟹ symmetric_mpoly ?A (prod ?f ?B)›*) symmetric_mpoly_power (*‹symmetric_mpoly (?A::nat set) (?p::?'a mpoly) ⟹ symmetric_mpoly ?A (?p ^ (?n::nat))›*) symmetric_sym_mpoly (*‹(?A::nat set) ⊆ (?B::nat set) ⟹ symmetric_mpoly ?A (sym_mpoly ?B (?k::nat))›*)) (*goals: 1. ‹keys (restrictpm (- A) (lead_monom p)) ∩ A = {}› 2. ‹⋀i. i ∈ {..<n} ⟹ A ⊆ A› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . thus "symmetric_mpoly A (fund_sym_step_poly p)" by simp assume finite: "finite A" and [simp]: "p ≠ 0" and "decr p" (*‹finite (A::nat set)› ‹(p::'a mpoly) ≠ (0::'a mpoly)› ‹(decr::'a mpoly ⇒ bool) (p::'a mpoly)›*) have "set xs = A" "distinct xs" and [simp]: "length xs = n" using finite (*‹finite A›*) apply - (*goals: 1. ‹finite A ⟹ set xs = A› 2. ‹finite A ⟹ distinct xs› 3. ‹finite A ⟹ length xs = n› discuss goal 1*) apply ((auto simp: xs_def (*‹xs ≡ sorted_list_of_set A›*) n_def (*‹n ≡ card A›*))[1]) (*discuss goal 2*) apply ((auto simp: xs_def (*‹xs ≡ sorted_list_of_set A›*) n_def (*‹n ≡ card A›*))[1]) (*discuss goal 3*) apply ((auto simp: xs_def (*‹xs ≡ sorted_list_of_set A›*) n_def (*‹n ≡ card A›*))[1]) (*proven 3 subgoals*) . have [simp]: "lead_coeff c = lead_coeff p" "lead_monom c = restrictpm (- A) (lead_monom p)" (*goals: 1. ‹Symmetric_Polynomials.lead_coeff (c::'a mpoly) = Symmetric_Polynomials.lead_coeff (p::'a mpoly)› 2. ‹lead_monom (c::'a mpoly) = restrictpm (- (A::nat set)) (lead_monom (p::'a mpoly))› discuss goal 1*) apply (simp add: c_def (*‹c = MPoly_Type.monom (restrictpm (- A) (lead_monom p)) (Symmetric_Polynomials.lead_coeff p)›*) lead_monom_monom (*‹lead_monom (MPoly_Type.monom ?m ?c) = (if ?c = 0 then 0 else ?m)›*)) (*discuss goal 2*) apply (simp add: c_def (*‹c = MPoly_Type.monom (restrictpm (- A) (lead_monom p)) (Symmetric_Polynomials.lead_coeff p)›*) lead_monom_monom (*‹lead_monom (MPoly_Type.monom ?m ?c) = (if ?c = 0 then 0 else ?m)›*)) (*proven 2 subgoals*) . hence f_range[simp]: "f i ∈ A" if "i < n" for i using that (*‹i < n›*) ‹set xs = A› (*‹set xs = A›*) by (auto simp: f_def (*‹f ≡ λi. if i < n then xs ! i else 0›*) set_conv_nth (*‹set ?xs = {?xs ! i |i. i < length ?xs}›*)) have "sorted xs" by (simp add: xs_def (*‹xs ≡ sorted_list_of_set A›*)) hence f_mono: "f i ≤ f j" if "i ≤ j" "j < n" for i and j using that (*‹(i::nat) ≤ (j::nat)› ‹(j::nat) < (n::nat)›*) by (auto simp: f_def (*‹f ≡ λi. if i < n then xs ! i else 0›*) n_def (*‹n ≡ card A›*) intro: sorted_nth_mono (*‹⟦sorted ?xs; ?i ≤ ?j; ?j < length ?xs⟧ ⟹ ?xs ! ?i ≤ ?xs ! ?j›*)) hence g_mono: "g i ≥ g j" if "i ≤ j" for i and j unfolding g_def (*goal: ‹(if j < n then lookup (lead_monom p) (f j) else 0) ≤ (if i < n then lookup (lead_monom p) (f i) else 0)›*) using that (*‹i ≤ j›*) using ‹decr p› (*‹decr p›*) by (auto simp: decr_def (*‹decr ≡ λp. ∀i∈A. ∀j∈A. i ≤ j ⟶ lookup (lead_monom p) j ≤ lookup (lead_monom p) i›*)) have "*": "(∏i<n. lead_coeff (sym_mpoly A (Suc i) ^ (g i - g (Suc i)) :: 'a mpoly)) = (∏i<card A. 1)" using ‹finite A› (*‹finite A›*) apply (intro prod.cong (*‹⟦?A = ?B; ⋀x. x ∈ ?B ⟹ ?g x = ?h x⟧ ⟹ prod ?g ?A = prod ?h ?B›*)) (*goals: 1. ‹finite A ⟹ {..<n} = {..<card A}› 2. ‹⋀x. ⟦finite A; x ∈ {..<card A}⟧ ⟹ Symmetric_Polynomials.lead_coeff (sym_mpoly A (Suc x) ^ (g x - g (Suc x))) = 1› discuss goal 1*) apply ((auto simp: n_def (*‹n ≡ card A›*) lead_coeff_power (*‹Symmetric_Polynomials.lead_coeff ?p ^ ?n ≠ 0 ⟹ Symmetric_Polynomials.lead_coeff (?p ^ ?n) = Symmetric_Polynomials.lead_coeff ?p ^ ?n›*))[1]) (*discuss goal 2*) apply ((auto simp: n_def (*‹n ≡ card A›*) lead_coeff_power (*‹Symmetric_Polynomials.lead_coeff ?p ^ ?n ≠ 0 ⟹ Symmetric_Polynomials.lead_coeff (?p ^ ?n) = Symmetric_Polynomials.lead_coeff ?p ^ ?n›*))[1]) (*proven 2 subgoals*) . hence "lead_coeff q = (∏i<n. lead_coeff (sym_mpoly A (Suc i) ^ (g i - g (Suc i)) :: 'a mpoly))" by (simp add: lead_coeff_prod (*‹(∏i∈?A. Symmetric_Polynomials.lead_coeff (?f i)) ≠ 0 ⟹ Symmetric_Polynomials.lead_coeff (prod ?f ?A) = (∏i∈?A. Symmetric_Polynomials.lead_coeff (?f i))›*) lead_coeff_power (*‹Symmetric_Polynomials.lead_coeff ?p ^ ?n ≠ 0 ⟹ Symmetric_Polynomials.lead_coeff (?p ^ ?n) = Symmetric_Polynomials.lead_coeff ?p ^ ?n›*) n_def (*‹n ≡ card A›*) q_def (*‹q = (∏i<n. sym_mpoly A (Suc i) ^ (g i - g (Suc i)))›*)) also (*calculation: ‹Symmetric_Polynomials.lead_coeff q = (∏i<n. Symmetric_Polynomials.lead_coeff (sym_mpoly A (Suc i) ^ (g i - g (Suc i))))›*) have "… = (∏i<n. 1)" using ‹finite A› (*‹finite A›*) apply (intro prod.cong (*‹⟦?A = ?B; ⋀x. x ∈ ?B ⟹ ?g x = ?h x⟧ ⟹ prod ?g ?A = prod ?h ?B›*)) (*goals: 1. ‹finite (A::nat set) ⟹ {..<n::nat} = {..<n}› 2. ‹⋀x::nat. ⟦finite (A::nat set); x ∈ {..<n::nat}⟧ ⟹ Symmetric_Polynomials.lead_coeff (sym_mpoly A (Suc x) ^ ((g::nat ⇒ nat) x - g (Suc x))) = (1::'a::comm_ring_1)› discuss goal 1*) apply ((auto simp: lead_coeff_power (*‹Symmetric_Polynomials.lead_coeff ?p ^ ?n ≠ 0 ⟹ Symmetric_Polynomials.lead_coeff (?p ^ ?n) = Symmetric_Polynomials.lead_coeff ?p ^ ?n›*) n_def (*‹n ≡ card A›*))[1]) (*discuss goal 2*) apply ((auto simp: lead_coeff_power (*‹Symmetric_Polynomials.lead_coeff ?p ^ ?n ≠ 0 ⟹ Symmetric_Polynomials.lead_coeff (?p ^ ?n) = Symmetric_Polynomials.lead_coeff ?p ^ ?n›*) n_def (*‹n ≡ card A›*))[1]) (*proven 2 subgoals*) . finally (*calculation: ‹Symmetric_Polynomials.lead_coeff q = (∏i<n. 1)›*) have [simp]: "lead_coeff q = 1" by simp have "lead_monom q = (∑i<n. lead_monom (sym_mpoly A (Suc i) ^ (g i - g (Suc i)) :: 'a mpoly))" using "*" (*‹(∏i<n. Symmetric_Polynomials.lead_coeff (sym_mpoly A (Suc i) ^ (g i - g (Suc i)))) = (∏i<card A. 1)›*) by (simp add: q_def (*‹q = (∏i<n. sym_mpoly A (Suc i) ^ (g i - g (Suc i)))›*) lead_monom_prod (*‹(∏i∈?A. Symmetric_Polynomials.lead_coeff (?f i)) ≠ 0 ⟹ lead_monom (prod ?f ?A) = (∑i∈?A. lead_monom (?f i))›*) lead_coeff_power (*‹Symmetric_Polynomials.lead_coeff ?p ^ ?n ≠ 0 ⟹ Symmetric_Polynomials.lead_coeff (?p ^ ?n) = Symmetric_Polynomials.lead_coeff ?p ^ ?n›*) n_def (*‹n ≡ card A›*)) also (*calculation: ‹lead_monom q = (∑i<n. lead_monom (sym_mpoly A (Suc i) ^ (g i - g (Suc i))))›*) have "… = (∑i<n. of_nat (g i - g (Suc i)) * lead_monom (sym_mpoly A (Suc i) :: 'a mpoly))" using ‹finite A› (*‹finite A›*) apply (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›*)) (*goals: 1. ‹finite A ⟹ {..<n} = {..<n}› 2. ‹⋀x. ⟦finite A; x ∈ {..<n}⟧ ⟹ lead_monom (sym_mpoly A (Suc x) ^ (g x - g (Suc x))) = of_nat (g x - g (Suc x)) * lead_monom (sym_mpoly A (Suc x))› discuss goal 1*) apply ((auto simp: lead_monom_power (*‹Symmetric_Polynomials.lead_coeff ?p ^ ?n ≠ 0 ⟹ lead_monom (?p ^ ?n) = of_nat ?n * lead_monom ?p›*) n_def (*‹n ≡ card A›*))[1]) (*discuss goal 2*) apply ((auto simp: lead_monom_power (*‹Symmetric_Polynomials.lead_coeff ?p ^ ?n ≠ 0 ⟹ lead_monom (?p ^ ?n) = of_nat ?n * lead_monom ?p›*) n_def (*‹n ≡ card A›*))[1]) (*proven 2 subgoals*) . also (*calculation: ‹lead_monom q = (∑i<n. of_nat (g i - g (Suc i)) * lead_monom (sym_mpoly A (Suc i)))›*) have "… = (∑i<n. of_nat (g i - g (Suc i)) * monom_of_set (set (take (Suc i) xs)))" apply (intro sum.cong (*‹⟦?A = ?B; ⋀x. x ∈ ?B ⟹ ?g x = ?h x⟧ ⟹ sum ?g ?A = sum ?h ?B›*) refl (*‹?t = ?t›*)) (*goal: ‹(∑i<n. of_nat (g i - g (Suc i)) * lead_monom (sym_mpoly A (Suc i))) = (∑i<n. of_nat (g i - g (Suc i)) * monom_of_set (set (take (Suc i) xs)))›*) proof (goal_cases) (*goal: ‹⋀x::nat. x ∈ {..<n::nat} ⟹ of_nat ((g::nat ⇒ nat) x - g (Suc x)) * lead_monom (sym_mpoly (A::nat set) (Suc x)) = of_nat (g x - g (Suc x)) * monom_of_set (set (take (Suc x) (xs::nat list)))›*) case (1 i) (*‹i ∈ {..<n}›*) have "lead_monom (sym_mpoly A (Suc i) :: 'a mpoly) = lead_monom (sym_mpoly (set xs) (Suc i) :: 'a mpoly)" by (simp add: ‹set xs = A›) also (*calculation: ‹lead_monom (sym_mpoly A (Suc i)) = lead_monom (sym_mpoly (set xs) (Suc i))›*) from "1" (*‹i ∈ {..<n}›*) have "… = monom_of_set (set (take (Suc i) xs))" apply (subst lead_monom_sym_mpoly (*‹⟦sorted ?xs; distinct ?xs; ?k ≤ length ?xs⟧ ⟹ lead_monom (sym_mpoly (set ?xs) ?k) = monom_of_set (set (take ?k ?xs))›*)) (*goals: 1. ‹i ∈ {..<n} ⟹ sorted xs› 2. ‹i ∈ {..<n} ⟹ distinct xs› 3. ‹i ∈ {..<n} ⟹ Suc i ≤ length xs› 4. ‹i ∈ {..<n} ⟹ monom_of_set (set (take (Suc i) xs)) = monom_of_set (set (take (Suc i) xs))› discuss goal 1*) apply ((auto simp: xs_def (*‹xs::nat list ≡ sorted_list_of_set (A::nat set)›*) n_def (*‹n::nat ≡ card (A::nat set)›*))[1]) (*discuss goal 2*) apply ((auto simp: xs_def (*‹xs ≡ sorted_list_of_set A›*) n_def (*‹n ≡ card A›*))[1]) (*discuss goal 3*) apply ((auto simp: xs_def (*‹xs::nat list ≡ sorted_list_of_set (A::nat set)›*) n_def (*‹n::nat ≡ card (A::nat set)›*))[1]) (*discuss goal 4*) apply ((auto simp: xs_def (*‹xs::nat list ≡ sorted_list_of_set (A::nat set)›*) n_def (*‹n::nat ≡ card (A::nat set)›*))[1]) (*proven 4 subgoals*) . finally (*calculation: ‹lead_monom (sym_mpoly (A::nat set) (Suc (i::nat))) = monom_of_set (set (take (Suc i) (xs::nat list)))›*) show "?case" (*goal: ‹of_nat ((g::nat ⇒ nat) (i::nat) - g (Suc i)) * lead_monom (sym_mpoly (A::nat set) (Suc i)) = of_nat (g i - g (Suc i)) * monom_of_set (set (take (Suc i) (xs::nat list)))›*) by simp qed finally (*calculation: ‹lead_monom q = (∑i<n. of_nat (g i - g (Suc i)) * monom_of_set (set (take (Suc i) xs)))›*) have lead_monom_q: "lead_monom q = (∑i<n. of_nat (g i - g (Suc i)) * monom_of_set (set (take (Suc i) xs)))" . have "lead_monom (c * q) = lead_monom c + lead_monom q" by (simp add: lead_monom_mult (*‹Symmetric_Polynomials.lead_coeff ?p * Symmetric_Polynomials.lead_coeff ?q ≠ 0 ⟹ lead_monom (?p * ?q) = lead_monom ?p + lead_monom ?q›*)) also (*calculation: ‹lead_monom (c * q) = lead_monom c + lead_monom q›*) have "… = lead_monom p" (is "?S = _") proof (intro poly_mapping_eqI (*‹(⋀k. lookup ?f k = lookup ?g k) ⟹ ?f = ?g›*)) (*goal: ‹⋀k. lookup (lead_monom c + lead_monom q) k = lookup (lead_monom p) k›*) fix i :: nat show "lookup (lead_monom c + lead_monom q) i = lookup (lead_monom p) i" proof (cases "i ∈ A") (*goals: 1. ‹(i::nat) ∈ (A::nat set) ⟹ lookup (lead_monom (c::'a::comm_ring_1 mpoly) + lead_monom (q::'a::comm_ring_1 mpoly)) i = lookup (lead_monom (p::'a::comm_ring_1 mpoly)) i› 2. ‹(i::nat) ∉ (A::nat set) ⟹ lookup (lead_monom (c::'a::comm_ring_1 mpoly) + lead_monom (q::'a::comm_ring_1 mpoly)) i = lookup (lead_monom (p::'a::comm_ring_1 mpoly)) i›*) case False (*‹i ∉ A›*) hence "lookup (lead_monom c + lead_monom q) i = lookup (lead_monom p) i + (∑j<n. (g j - g (Suc j)) * lookup (monom_of_set (set (take (Suc j) xs))) i)" (is "_ = _ + ?S") by (simp add: lookup_add (*‹lookup (?f + ?g) ?k = lookup ?f ?k + lookup ?g ?k›*) lead_monom_q (*‹lead_monom q = (∑i<n. of_nat (g i - g (Suc i)) * monom_of_set (set (take (Suc i) xs)))›*) lookup_sum (*‹lookup (sum ?pp ?X) ?i = (∑x∈?X. lookup (?pp x) ?i)›*)) also (*calculation: ‹lookup (lead_monom c + lead_monom q) i = lookup (lead_monom p) i + (∑j<n. (g j - g (Suc j)) * lookup (monom_of_set (set (take (Suc j) xs))) i)›*) from False (*‹i ∉ A›*) have "?S = 0" apply (intro sum.neutral (*‹∀x∈?A. ?g x = 0 ⟹ sum ?g ?A = 0›*)) (*goal: ‹(∑j<n. (g j - g (Suc j)) * lookup (monom_of_set (set (take (Suc j) xs))) i) = 0›*) by (auto simp: lookup_monom_of_set (*‹lookup (monom_of_set (?X::nat set)) (?i::nat) = (if finite ?X ∧ ?i ∈ ?X then 1::nat else (0::nat))›*) ‹set xs = A› dest!: in_set_takeD (*‹(?x::?'a) ∈ set (take (?n::nat) (?xs::?'a list)) ⟹ ?x ∈ set ?xs›*)) finally (*calculation: ‹lookup (lead_monom c + lead_monom q) i = lookup (lead_monom p) i + 0›*) show "?thesis" (*goal: ‹lookup (lead_monom c + lead_monom q) i = lookup (lead_monom p) i›*) by simp next (*goal: ‹i ∈ A ⟹ lookup (lead_monom c + lead_monom q) i = lookup (lead_monom p) i›*) case True (*‹i ∈ A›*) with ‹set xs = A› (*‹set xs = A›*) obtain m where m: "i = xs ! m" "m < n" (*goal: ‹(⋀m. ⟦i = xs ! m; m < n⟧ ⟹ thesis) ⟹ thesis›*) by (auto simp: set_conv_nth (*‹set ?xs = {?xs ! i |i. i < length ?xs}›*)) have "lookup (lead_monom c + lead_monom q) i = (∑j<n. (g j - g (Suc j)) * lookup (monom_of_set (set (take (Suc j) xs))) i)" using True (*‹(i::nat) ∈ (A::nat set)›*) by (simp add: lookup_add (*‹lookup (?f + ?g) ?k = lookup ?f ?k + lookup ?g ?k›*) lookup_sum (*‹lookup (sum ?pp ?X) ?i = (∑x∈?X. lookup (?pp x) ?i)›*) lead_monom_q (*‹lead_monom q = (∑i<n. of_nat (g i - g (Suc i)) * monom_of_set (set (take (Suc i) xs)))›*)) also (*calculation: ‹lookup (lead_monom c + lead_monom q) i = (∑j<n. (g j - g (Suc j)) * lookup (monom_of_set (set (take (Suc j) xs))) i)›*) have "… = (∑j | j < n ∧ i ∈ set (take (Suc j) xs). g j - g (Suc j))" apply (intro sum.mono_neutral_cong_right (*‹⟦finite (?T::?'b::type set); (?S::?'b::type set) ⊆ ?T; ∀i::?'b::type∈?T - ?S. (?g::?'b::type ⇒ ?'a::comm_monoid_add) i = (0::?'a::comm_monoid_add); ⋀x::?'b::type. x ∈ ?S ⟹ ?g x = (?h::?'b::type ⇒ ?'a::comm_monoid_add) x⟧ ⟹ sum ?g ?T = sum ?h ?S›*)) (*goals: 1. ‹finite {..<n}› 2. ‹{j. j < n ∧ i ∈ set (take (Suc j) xs)} ⊆ {..<n}› 3. ‹∀ia∈{..<n} - {j. j < n ∧ i ∈ set (take (Suc j) xs)}. (g ia - g (Suc ia)) * lookup (monom_of_set (set (take (Suc ia) xs))) i = 0› 4. ‹⋀x. x ∈ {j. j < n ∧ i ∈ set (take (Suc j) xs)} ⟹ (g x - g (Suc x)) * lookup (monom_of_set (set (take (Suc x) xs))) i = g x - g (Suc 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]) (*proven 4 subgoals*) . also (*calculation: ‹lookup (lead_monom c + lead_monom q) i = (∑j | j < n ∧ i ∈ set (take (Suc j) xs). g j - g (Suc j))›*) have "{j. j < n ∧ i ∈ set (take (Suc j) xs)} = {m..<n}" using m (*‹i = xs ! m› ‹m < n›*) ‹distinct xs› (*‹distinct xs›*) by (force simp: set_conv_nth (*‹set ?xs = {?xs ! i |i. i < length ?xs}›*) nth_eq_iff_index_eq (*‹⟦distinct ?xs; ?i < length ?xs; ?j < length ?xs⟧ ⟹ (?xs ! ?i = ?xs ! ?j) = (?i = ?j)›*)) also (*calculation: ‹lookup (lead_monom c + lead_monom q) i = (∑j = m..<n. g j - g (Suc j))›*) have "(∑j∈…. g j - g (Suc j)) = (∑j∈…. g j) - (∑j∈…. g (Suc j))" apply (subst sum_subtractf_nat (*‹(⋀x. x ∈ ?A ⟹ ?g x ≤ ?f x) ⟹ (∑x∈?A. ?f x - ?g x) = sum ?f ?A - sum ?g ?A›*)) (*goals: 1. ‹⋀x. x ∈ {m..<n} ⟹ g (Suc x) ≤ g x› 2. ‹sum g {m..<n} - (∑x = m..<n. g (Suc x)) = sum g {m..<n} - (∑j = m..<n. g (Suc j))› discuss goal 1*) apply ((auto intro!: g_mono (*‹(?i::nat) ≤ (?j::nat) ⟹ (g::nat ⇒ nat) ?j ≤ g ?i›*))[1]) (*discuss goal 2*) apply ((auto intro!: g_mono (*‹(?i::nat) ≤ (?j::nat) ⟹ (g::nat ⇒ nat) ?j ≤ g ?i›*))[1]) (*proven 2 subgoals*) . also (*calculation: ‹lookup (lead_monom c + lead_monom q) i = sum g {m..<n} - (∑j = m..<n. g (Suc j))›*) have "(∑j∈{m..<n}. g (Suc j)) = (∑j∈{m<..n}. g j)" apply (intro sum.reindex_bij_witness[of _ "λj. j - 1" Suc] (*‹⟦⋀a::nat. a ∈ (?S::nat set) ⟹ Suc a - (1::nat) = a; ⋀a::nat. a ∈ ?S ⟹ Suc a ∈ (?T::nat set); ⋀b::nat. b ∈ ?T ⟹ Suc (b - (1::nat)) = b; ⋀b::nat. b ∈ ?T ⟹ b - (1::nat) ∈ ?S; ⋀a::nat. a ∈ ?S ⟹ (?h::nat ⇒ ?'a) (Suc a) = (?g::nat ⇒ ?'a) a⟧ ⟹ sum ?g ?S = sum ?h ?T›*)) (*goals: 1. ‹⋀a::nat. a ∈ {m::nat..<n::nat} ⟹ Suc a - (1::nat) = a› 2. ‹⋀a::nat. a ∈ {m::nat..<n::nat} ⟹ Suc a ∈ {m<..n}› 3. ‹⋀b::nat. b ∈ {m::nat<..n::nat} ⟹ Suc (b - (1::nat)) = b› 4. ‹⋀b::nat. b ∈ {m::nat<..n::nat} ⟹ b - (1::nat) ∈ {m..<n}› 5. ‹⋀a::nat. a ∈ {m::nat..<n::nat} ⟹ (g::nat ⇒ nat) (Suc a) = g (Suc 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*) . also (*calculation: ‹lookup (lead_monom c + lead_monom q) i = sum g {m..<n} - sum g {m<..n}›*) have "… = (∑j∈{m<..<n}. g j)" apply (intro sum.mono_neutral_right (*‹⟦finite (?T::?'b::type set); (?S::?'b::type set) ⊆ ?T; ∀i::?'b::type∈?T - ?S. (?g::?'b::type ⇒ ?'a::comm_monoid_add) i = (0::?'a::comm_monoid_add)⟧ ⟹ sum ?g ?T = sum ?g ?S›*)) (*goals: 1. ‹finite {m<..n}› 2. ‹{m<..<n} ⊆ {m<..n}› 3. ‹∀i∈{m<..n} - {m<..<n}. g i = 0› discuss goal 1*) apply ((auto simp: g_def (*‹g = (λi. if i < n then lookup (lead_monom p) (f i) else 0)›*))[1]) (*discuss goal 2*) apply ((auto simp: g_def (*‹g = (λi. if i < n then lookup (lead_monom p) (f i) else 0)›*))[1]) (*discuss goal 3*) apply ((auto simp: g_def (*‹g = (λi. if i < n then lookup (lead_monom p) (f i) else 0)›*))[1]) (*proven 3 subgoals*) . also (*calculation: ‹lookup (lead_monom c + lead_monom q) i = sum g {m..<n} - sum g {m<..<n}›*) have "(∑j∈{m..<n}. g j) - … = (∑j∈{m..<n}-{m<..<n}. g j)" apply (intro sum_diff_nat [symmetric] (*‹⟦finite ?B; ?B ⊆ ?A⟧ ⟹ sum ?f ?A - sum ?f ?B = sum ?f (?A - ?B)›*)) (*goals: 1. ‹finite {m<..<n}› 2. ‹{m<..<n} ⊆ {m..<n}› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . also (*calculation: ‹lookup (lead_monom (c::'a mpoly) + lead_monom (q::'a mpoly)) (i::nat) = sum (g::nat ⇒ nat) ({m::nat..<n::nat} - {m<..<n})›*) have "{m..<n}-{m<..<n} = {m}" using m (*‹i = xs ! m› ‹m < n›*) by auto also (*calculation: ‹lookup (lead_monom c + lead_monom q) i = sum g {m}›*) have "(∑j∈…. g j) = lookup (lead_monom p) i" using m (*‹i = xs ! m› ‹m < n›*) by (auto simp: g_def (*‹g = (λi. if i < n then lookup (lead_monom p) (f i) else 0)›*) not_less (*‹(¬ ?x < ?y) = (?y ≤ ?x)›*) le_Suc_eq (*‹(?m ≤ Suc ?n) = (?m ≤ ?n ∨ ?m = Suc ?n)›*) f_def (*‹f ≡ λi. if i < n then xs ! i else 0›*)) finally (*calculation: ‹lookup (lead_monom (c::'a mpoly) + lead_monom (q::'a mpoly)) (i::nat) = lookup (lead_monom (p::'a mpoly)) i›*) show "?thesis" (*goal: ‹lookup (lead_monom c + lead_monom q) i = lookup (lead_monom p) i›*) . qed qed finally (*calculation: ‹lead_monom (c * q) = lead_monom p›*) show "lead_monom (fund_sym_step_poly p) = lead_monom p" by simp show "lead_coeff (fund_sym_step_poly p) = lead_coeff p" by (simp add: lead_coeff_mult (*‹Symmetric_Polynomials.lead_coeff ?p * Symmetric_Polynomials.lead_coeff ?q ≠ 0 ⟹ Symmetric_Polynomials.lead_coeff (?p * ?q) = Symmetric_Polynomials.lead_coeff ?p * Symmetric_Polynomials.lead_coeff ?q›*)) have "*": "lookup (fund_sym_step_monom p) k = (if k ∈ {1..n} then g (k - 1) - g k else 0)" for k proof (-) (*goal: ‹lookup (local.fund_sym_step_monom p) k = (if k ∈ {1..n} then g (k - 1) - g k else 0)›*) have "lookup (fund_sym_step_monom p) k = (∑x∈(if k ∈ {1..n} then {k - 1} else {}). g (k - 1) - g k)" unfolding fund_sym_step_monom_def lookup_sum Let_def (*goal: ‹(∑x<n. lookup (Poly_Mapping.single (Suc x) ((if x < n then lookup (lead_monom p) (f x) else 0) - (if Suc x < n then lookup (lead_monom p) (f (Suc x)) else 0))) k) = (∑x∈(if k ∈ {1..n} then {k - 1} else {}). g (k - 1) - g k)›*) apply (intro 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. ‹finite {..<n}› 2. ‹(if k ∈ {1..n} then {k - 1} else {}) ⊆ {..<n}› 3. ‹∀i∈{..<n} - (if k ∈ {1..n} then {k - 1} else {}). lookup (Poly_Mapping.single (Suc i) ((if i < n then lookup (lead_monom p) (f i) else 0) - (if Suc i < n then lookup (lead_monom p) (f (Suc i)) else 0))) k = 0› 4. ‹⋀x. x ∈ (if k ∈ {1..n} then {k - 1} else {}) ⟹ lookup (Poly_Mapping.single (Suc x) ((if x < n then lookup (lead_monom p) (f x) else 0) - (if Suc x < n then lookup (lead_monom p) (f (Suc x)) else 0))) k = g (k - 1) - g k› discuss goal 1*) apply ((auto simp: g_def (*‹g = (λi. if i < n then lookup (lead_monom p) (f i) else 0)›*) lookup_single (*‹lookup (Poly_Mapping.single ?k ?v) ?k' = (?v when ?k = ?k')›*) when_def (*‹(?a when ?P) = (if ?P then ?a 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: g_def (*‹g = (λi. if i < n then lookup (lead_monom p) (f i) else 0)›*) lookup_single (*‹lookup (Poly_Mapping.single ?k ?v) ?k' = (?v when ?k = ?k')›*) when_def (*‹(?a when ?P) = (if ?P then ?a 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 3*) apply ((auto simp: g_def (*‹g = (λi. if i < n then lookup (lead_monom p) (f i) else 0)›*) lookup_single (*‹lookup (Poly_Mapping.single ?k ?v) ?k' = (?v when ?k = ?k')›*) when_def (*‹(?a when ?P) = (if ?P then ?a 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 4*) apply ((auto simp: g_def (*‹g = (λi. if i < n then lookup (lead_monom p) (f i) else 0)›*) lookup_single (*‹lookup (Poly_Mapping.single ?k ?v) ?k' = (?v when ?k = ?k')›*) when_def (*‹(?a when ?P) = (if ?P then ?a 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]) (*proven 4 subgoals*) . thus "?thesis" (*goal: ‹lookup (local.fund_sym_step_monom p) k = (if k ∈ {1..n} then g (k - 1) - g k else 0)›*) by simp qed hence "(∏x. sym_mpoly A x ^ lookup (fund_sym_step_monom p) x :: 'a mpoly) = (∏x∈{1..n}. sym_mpoly A x ^ lookup (fund_sym_step_monom p) x)" apply (intro Prod_any.expand_superset (*‹⟦finite ?A; {a. ?g a ≠ 1} ⊆ ?A⟧ ⟹ Prod_any ?g = prod ?g ?A›*)) (*goals: 1. ‹(⋀k. lookup (local.fund_sym_step_monom p) k = (if k ∈ {1..n} then g (k - 1) - g k else 0)) ⟹ finite {1..n}› 2. ‹(⋀k. lookup (local.fund_sym_step_monom p) k = (if k ∈ {1..n} then g (k - 1) - g k else 0)) ⟹ {a. sym_mpoly A a ^ lookup (local.fund_sym_step_monom p) a ≠ 1} ⊆ {1..n}› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . also (*calculation: ‹(∏x::nat. sym_mpoly (A::nat set) x ^ lookup (local.fund_sym_step_monom (p::'a mpoly)) x) = (∏x::nat = 1::nat..n::nat. sym_mpoly A x ^ lookup (local.fund_sym_step_monom p) x)›*) have "… = (∏x<n. sym_mpoly A (Suc x) ^ lookup (fund_sym_step_monom p) (Suc x))" apply (intro prod.reindex_bij_witness[of _ Suc "λi. i - 1"] (*‹⟦⋀a::nat. a ∈ (?S::nat set) ⟹ Suc (a - (1::nat)) = a; ⋀a::nat. a ∈ ?S ⟹ a - (1::nat) ∈ (?T::nat set); ⋀b::nat. b ∈ ?T ⟹ Suc b - (1::nat) = b; ⋀b::nat. b ∈ ?T ⟹ Suc b ∈ ?S; ⋀a::nat. a ∈ ?S ⟹ (?h::nat ⇒ ?'a) (a - (1::nat)) = (?g::nat ⇒ ?'a) a⟧ ⟹ prod ?g ?S = prod ?h ?T›*)) (*goals: 1. ‹⋀a. a ∈ {1..n} ⟹ Suc (a - 1) = a› 2. ‹⋀a. a ∈ {1..n} ⟹ a - 1 ∈ {..<n}› 3. ‹⋀b. b ∈ {..<n} ⟹ Suc b - 1 = b› 4. ‹⋀b. b ∈ {..<n} ⟹ Suc b ∈ {1..n}› 5. ‹⋀a. a ∈ {1..n} ⟹ sym_mpoly A (Suc (a - 1)) ^ lookup (local.fund_sym_step_monom p) (Suc (a - 1)) = sym_mpoly A a ^ lookup (local.fund_sym_step_monom p) 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*) . also (*calculation: ‹(∏x. sym_mpoly A x ^ lookup (local.fund_sym_step_monom p) x) = (∏x<n. sym_mpoly A (Suc x) ^ lookup (local.fund_sym_step_monom p) (Suc x))›*) have "… = q" unfolding q_def (*goal: ‹(∏x::nat<n::nat. sym_mpoly (A::nat set) (Suc x) ^ lookup (local.fund_sym_step_monom (p::'a mpoly)) (Suc x)) = (∏i::nat<n. sym_mpoly A (Suc i) ^ ((g::nat ⇒ nat) i - g (Suc i)))›*) apply (intro prod.cong (*‹⟦(?A::?'b::type set) = (?B::?'b::type set); ⋀x::?'b::type. x ∈ ?B ⟹ (?g::?'b::type ⇒ ?'a::comm_monoid_mult) x = (?h::?'b::type ⇒ ?'a::comm_monoid_mult) x⟧ ⟹ prod ?g ?A = prod ?h ?B›*)) (*goals: 1. ‹{..<n::nat} = {..<n}› 2. ‹⋀x::nat. x ∈ {..<n::nat} ⟹ sym_mpoly (A::nat set) (Suc x) ^ lookup (local.fund_sym_step_monom (p::'a mpoly)) (Suc x) = sym_mpoly A (Suc x) ^ ((g::nat ⇒ nat) x - g (Suc x))› discuss goal 1*) apply ((auto simp: * (*‹lookup (local.fund_sym_step_monom p) ?k = (if ?k ∈ {1..n} then g (?k - 1) - g ?k else 0)›*))[1]) (*discuss goal 2*) apply ((auto simp: * (*‹lookup (local.fund_sym_step_monom p) ?k = (if ?k ∈ {1..n} then g (?k - 1) - g ?k else 0)›*))[1]) (*proven 2 subgoals*) . finally (*calculation: ‹(∏x. sym_mpoly A x ^ lookup (local.fund_sym_step_monom p) x) = q›*) show "fund_sym_step_poly p = fund_sym_step_coeff p * (∏x. sym_mpoly A x ^ lookup (fund_sym_step_monom p) x)" by (simp add: c_def (*‹(c::'a mpoly) = MPoly_Type.monom (restrictpm (- (A::nat set)) (lead_monom (p::'a mpoly))) (Symmetric_Polynomials.lead_coeff p)›*) q_def (*‹(q::'a mpoly) = (∏i::nat<n::nat. sym_mpoly (A::nat set) (Suc i) ^ ((g::nat ⇒ nat) i - g (Suc i)))›*) f_def (*‹f::nat ⇒ nat ≡ λi::nat. if i < (n::nat) then (xs::nat list) ! i else (0::nat)›*) g_def (*‹(g::nat ⇒ nat) = (λi::nat. if i < (n::nat) then lookup (lead_monom (p::'a mpoly)) ((f::nat ⇒ nat) i) else (0::nat))›*) fund_sym_step_monom_def (*‹local.fund_sym_step_monom (?p::'a mpoly) = (let g::nat ⇒ nat = λi::nat. if i < (n::nat) then lookup (lead_monom ?p) ((f::nat ⇒ nat) i) else (0::nat) in ∑i::nat<n. Poly_Mapping.single (Suc i) (g i - g (Suc i)))›*) fund_sym_step_coeff_def (*‹local.fund_sym_step_coeff (?p::'a mpoly) = MPoly_Type.monom (restrictpm (- (A::nat set)) (lead_monom ?p)) (Symmetric_Polynomials.lead_coeff ?p)›*)) qed text ‹ If the input is well-formed, a single step of the procedure always decreases the leading monomial. › lemma lead_monom_fund_sym_step_poly_less: assumes "finite A" and "lead_monom p ≠ 0" and "decr p" shows "lead_monom (p - fund_sym_step_poly p) < lead_monom p" proof (cases "p = fund_sym_step_poly p") (*goals: 1. ‹p = local.fund_sym_step_poly p ⟹ lead_monom (p - local.fund_sym_step_poly p) < lead_monom p› 2. ‹p ≠ local.fund_sym_step_poly p ⟹ lead_monom (p - local.fund_sym_step_poly p) < lead_monom p›*) case True (*‹p = local.fund_sym_step_poly p›*) thus "?thesis" (*goal: ‹lead_monom ((p::'a mpoly) - local.fund_sym_step_poly p) < lead_monom p›*) using assms (*‹finite (A::nat set)› ‹lead_monom p ≠ 0› ‹(decr::'a mpoly ⇒ bool) (p::'a mpoly)›*) by (auto simp: order.strict_iff_order (*‹(?a < ?b) = (?a ≤ ?b ∧ ?a ≠ ?b)›*)) next (*goal: ‹p ≠ local.fund_sym_step_poly p ⟹ lead_monom (p - local.fund_sym_step_poly p) < lead_monom p›*) case False (*‹p ≠ local.fund_sym_step_poly p›*) from assms (*‹finite A› ‹lead_monom (p::'a::comm_ring_1 mpoly) ≠ (0::nat ⇒₀ nat)› ‹decr p›*) have [simp]: "p ≠ 0" by auto let ?q = "fund_sym_step_poly p" and ?m = "lead_monom p" have "coeff (p - ?q) ?m = 0" using fund_sym_step_poly[of p] (*‹⟦finite A; p ≠ 0; decr p⟧ ⟹ lead_monom (local.fund_sym_step_poly p) = lead_monom p› ‹⟦finite A; p ≠ 0; decr p⟧ ⟹ Symmetric_Polynomials.lead_coeff (local.fund_sym_step_poly p) = Symmetric_Polynomials.lead_coeff p› ‹⟦finite A; p ≠ 0; decr p⟧ ⟹ local.fund_sym_step_poly p = local.fund_sym_step_coeff p * (∏x. sym_mpoly A x ^ lookup (local.fund_sym_step_monom p) x)› ‹vars (local.fund_sym_step_poly p) ⊆ vars p ∪ A› ‹symmetric_mpoly A (local.fund_sym_step_poly p)›*) assms (*‹finite A› ‹lead_monom p ≠ 0› ‹decr p›*) by (simp add: lead_coeff_def (*‹Symmetric_Polynomials.lead_coeff (?p::?'a mpoly) = MPoly_Type.coeff ?p (lead_monom ?p)›*)) moreover have "lead_coeff (p - ?q) ≠ 0" using False (*‹(p::'a mpoly) ≠ local.fund_sym_step_poly p›*) by auto ultimately have "lead_monom (p - ?q) ≠ ?m" unfolding lead_coeff_def (*goal: ‹lead_monom ((p::'a mpoly) - local.fund_sym_step_poly p) ≠ lead_monom p›*) by auto moreover have "lead_monom (p - ?q) ≤ ?m" using fund_sym_step_poly[of p] (*‹⟦finite A; p ≠ 0; decr p⟧ ⟹ lead_monom (local.fund_sym_step_poly p) = lead_monom p› ‹⟦finite A; p ≠ 0; decr p⟧ ⟹ Symmetric_Polynomials.lead_coeff (local.fund_sym_step_poly p) = Symmetric_Polynomials.lead_coeff p› ‹⟦finite A; p ≠ 0; decr p⟧ ⟹ local.fund_sym_step_poly p = local.fund_sym_step_coeff p * (∏x. sym_mpoly A x ^ lookup (local.fund_sym_step_monom p) x)› ‹vars (local.fund_sym_step_poly p) ⊆ vars p ∪ A› ‹symmetric_mpoly A (local.fund_sym_step_poly p)›*) assms (*‹finite A› ‹lead_monom p ≠ 0› ‹(decr::'a mpoly ⇒ bool) (p::'a mpoly)›*) apply (intro order.trans[OF lead_monom_diff] (*‹max (lead_monom ?p1) (lead_monom ?q1) ≤ ?c ⟹ lead_monom (?p1 - ?q1) ≤ ?c›*) max.boundedI (*‹⟦?b ≤ ?a; ?c ≤ ?a⟧ ⟹ max ?b ?c ≤ ?a›*)) (*goals: 1. ‹⟦⟦finite A; p ≠ 0; decr p⟧ ⟹ lead_monom (local.fund_sym_step_poly p) = lead_monom p; ⟦finite A; p ≠ 0; decr p⟧ ⟹ Symmetric_Polynomials.lead_coeff (local.fund_sym_step_poly p) = Symmetric_Polynomials.lead_coeff p; ⟦finite A; p ≠ 0; decr p⟧ ⟹ local.fund_sym_step_poly p = local.fund_sym_step_coeff p * (∏x. sym_mpoly A x ^ lookup (local.fund_sym_step_monom p) x); vars (local.fund_sym_step_poly p) ⊆ vars p ∪ A; symmetric_mpoly A (local.fund_sym_step_poly p); finite A; lead_monom p ≠ 0; decr p⟧ ⟹ lead_monom p ≤ lead_monom p› 2. ‹⟦⟦finite A; p ≠ 0; decr p⟧ ⟹ lead_monom (local.fund_sym_step_poly p) = lead_monom p; ⟦finite A; p ≠ 0; decr p⟧ ⟹ Symmetric_Polynomials.lead_coeff (local.fund_sym_step_poly p) = Symmetric_Polynomials.lead_coeff p; ⟦finite A; p ≠ 0; decr p⟧ ⟹ local.fund_sym_step_poly p = local.fund_sym_step_coeff p * (∏x. sym_mpoly A x ^ lookup (local.fund_sym_step_monom p) x); vars (local.fund_sym_step_poly p) ⊆ vars p ∪ A; symmetric_mpoly A (local.fund_sym_step_poly p); finite A; lead_monom p ≠ 0; decr p⟧ ⟹ lead_monom (local.fund_sym_step_poly p) ≤ lead_monom p› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . ultimately show "?thesis" (*goal: ‹lead_monom (p - local.fund_sym_step_poly p) < lead_monom p›*) by (auto simp: order.strict_iff_order (*‹(?a < ?b) = (?a ≤ ?b ∧ ?a ≠ ?b)›*)) qed text ‹ Finally, we prove that the witness is indeed well-defined for all inputs. › lemma fund_sym_poly_wit_dom_aux: assumes "finite B" "vars p ⊆ B" "A ⊆ B" shows "fund_sym_poly_wit_dom p" using assms(1-3) (*‹finite B› ‹vars p ⊆ B› ‹A ⊆ B›*) proof (induction p rule: lead_monom_induct (*‹⟦finite ?A; vars ?p ⊆ ?A; ⋀p. ⟦vars p ⊆ ?A; ⋀p'. ⟦vars p' ⊆ ?A; lead_monom p' < lead_monom p⟧ ⟹ ?P p'⟧ ⟹ ?P p⟧ ⟹ ?P ?p›*)) (*goal: ‹⋀p. ⟦vars p ⊆ B; ⋀p'. ⟦vars p' ⊆ B; lead_monom p' < lead_monom p; A ⊆ B⟧ ⟹ local.fund_sym_poly_wit_dom p'; A ⊆ B⟧ ⟹ local.fund_sym_poly_wit_dom p›*) case (less p) (*‹vars p ⊆ B› ‹⟦vars ?p' ⊆ B; lead_monom ?p' < lead_monom p; A ⊆ B⟧ ⟹ local.fund_sym_poly_wit_dom ?p'› ‹A ⊆ B›*) have [simp]: "finite A" apply (rule finite_subset[of _ B] (*‹⟦(?A::nat set) ⊆ (B::nat set); finite B⟧ ⟹ finite ?A›*)) (*goals: 1. ‹A ⊆ B› 2. ‹finite B› discuss goal 1*) apply fact (*discuss goal 2*) apply fact (*proven 2 subgoals*) . show "?case" (*goal: ‹local.fund_sym_poly_wit_dom (p::'a mpoly)›*) proof (cases "lead_monom p = 0 ∨ ¬symmetric_mpoly A p") (*goals: 1. ‹lead_monom p = 0 ∨ ¬ symmetric_mpoly A p ⟹ local.fund_sym_poly_wit_dom p› 2. ‹¬ (lead_monom p = 0 ∨ ¬ symmetric_mpoly A p) ⟹ local.fund_sym_poly_wit_dom p›*) case False (*‹¬ (lead_monom (p::'a::comm_ring_1 mpoly) = (0::nat ⇒₀ nat) ∨ ¬ symmetric_mpoly (A::nat set) p)›*) hence [simp]: "p ≠ 0" by auto note decr = lookup_lead_monom_decreasing[of A p] (*‹⟦symmetric_mpoly (A::nat set) (p::'a::comm_ring_1 mpoly); (?i::nat) ∈ A; (?j::nat) ∈ A; ?i ≤ ?j⟧ ⟹ lookup (lead_monom p) ?j ≤ lookup (lead_monom p) ?i›*) have "vars (p - fund_sym_step_poly p) ⊆ B" using fund_sym_step_poly[of p] (*‹⟦finite A; p ≠ 0; decr p⟧ ⟹ lead_monom (local.fund_sym_step_poly p) = lead_monom p› ‹⟦finite A; p ≠ 0; decr p⟧ ⟹ Symmetric_Polynomials.lead_coeff (local.fund_sym_step_poly p) = Symmetric_Polynomials.lead_coeff p› ‹⟦finite (A::nat set); (p::'a mpoly) ≠ (0::'a mpoly); (decr::'a mpoly ⇒ bool) p⟧ ⟹ local.fund_sym_step_poly p = local.fund_sym_step_coeff p * (∏x::nat. sym_mpoly A x ^ lookup (local.fund_sym_step_monom p) x)› ‹vars (local.fund_sym_step_poly (p::'a mpoly)) ⊆ vars p ∪ (A::nat set)› ‹symmetric_mpoly (A::nat set) (local.fund_sym_step_poly (p::'a mpoly))›*) decr (*‹⟦symmetric_mpoly A p; ?i ∈ A; ?j ∈ A; ?i ≤ ?j⟧ ⟹ lookup (lead_monom p) ?j ≤ lookup (lead_monom p) ?i›*) False (*‹¬ (lead_monom p = 0 ∨ ¬ symmetric_mpoly A p)›*) less.prems (*‹A ⊆ B›*) less.hyps (*‹vars p ⊆ B›*) ‹A ⊆ B› (*‹A ⊆ B›*) apply (intro order.trans[OF vars_diff] (*‹vars ?p1.1 ∪ vars ?p2.1 ⊆ ?c ⟹ vars (?p1.1 - ?p2.1) ⊆ ?c›*)) (*goal: ‹vars (p - local.fund_sym_step_poly p) ⊆ B›*) by auto hence "fund_sym_poly_wit_dom (p - local.fund_sym_step_poly p)" using False (*‹¬ (lead_monom p = 0 ∨ ¬ symmetric_mpoly A p)›*) less.prems (*‹A ⊆ B›*) less.hyps (*‹vars p ⊆ B›*) decr (*‹⟦symmetric_mpoly A p; ?i ∈ A; ?j ∈ A; ?i ≤ ?j⟧ ⟹ lookup (lead_monom p) ?j ≤ lookup (lead_monom p) ?i›*) apply (intro less.IH (*‹⟦vars ?p' ⊆ B; lead_monom ?p' < lead_monom p; A ⊆ B⟧ ⟹ local.fund_sym_poly_wit_dom ?p'›*) fund_sym_step_poly (*‹⟦finite A; ?p ≠ 0; decr ?p⟧ ⟹ lead_monom (local.fund_sym_step_poly ?p) = lead_monom ?p› ‹⟦finite A; ?p ≠ 0; decr ?p⟧ ⟹ Symmetric_Polynomials.lead_coeff (local.fund_sym_step_poly ?p) = Symmetric_Polynomials.lead_coeff ?p› ‹⟦finite A; ?p ≠ 0; decr ?p⟧ ⟹ local.fund_sym_step_poly ?p = local.fund_sym_step_coeff ?p * (∏x. sym_mpoly A x ^ lookup (local.fund_sym_step_monom ?p) x)› ‹vars (local.fund_sym_step_poly ?p) ⊆ vars ?p ∪ A› ‹symmetric_mpoly A (local.fund_sym_step_poly ?p)›*) symmetric_mpoly_diff (*‹⟦symmetric_mpoly ?A ?p; symmetric_mpoly ?A ?q⟧ ⟹ symmetric_mpoly ?A (?p - ?q)›*) lead_monom_fund_sym_step_poly_less (*‹⟦finite A; lead_monom ?p ≠ 0; decr ?p⟧ ⟹ lead_monom (?p - local.fund_sym_step_poly ?p) < lead_monom ?p›*)) (*goals: 1. ‹⟦vars (p - local.fund_sym_step_poly p) ⊆ B; ¬ (lead_monom p = 0 ∨ ¬ symmetric_mpoly A p); A ⊆ B; vars p ⊆ B; ⋀i j. ⟦symmetric_mpoly A p; i ∈ A; j ∈ A; i ≤ j⟧ ⟹ lookup (lead_monom p) j ≤ lookup (lead_monom p) i⟧ ⟹ vars (p - local.fund_sym_step_poly p) ⊆ B› 2. ‹⟦vars (p - local.fund_sym_step_poly p) ⊆ B; ¬ (lead_monom p = 0 ∨ ¬ symmetric_mpoly A p); A ⊆ B; vars p ⊆ B; ⋀i j. ⟦symmetric_mpoly A p; i ∈ A; j ∈ A; i ≤ j⟧ ⟹ lookup (lead_monom p) j ≤ lookup (lead_monom p) i⟧ ⟹ finite A› 3. ‹⟦vars (p - local.fund_sym_step_poly p) ⊆ B; ¬ (lead_monom p = 0 ∨ ¬ symmetric_mpoly A p); A ⊆ B; vars p ⊆ B; ⋀i j. ⟦symmetric_mpoly A p; i ∈ A; j ∈ A; i ≤ j⟧ ⟹ lookup (lead_monom p) j ≤ lookup (lead_monom p) i⟧ ⟹ lead_monom p ≠ 0› 4. ‹⟦vars (p - local.fund_sym_step_poly p) ⊆ B; ¬ (lead_monom p = 0 ∨ ¬ symmetric_mpoly A p); A ⊆ B; vars p ⊆ B; ⋀i j. ⟦symmetric_mpoly A p; i ∈ A; j ∈ A; i ≤ j⟧ ⟹ lookup (lead_monom p) j ≤ lookup (lead_monom p) i⟧ ⟹ decr p› 5. ‹⟦vars (p - local.fund_sym_step_poly p) ⊆ B; ¬ (lead_monom p = 0 ∨ ¬ symmetric_mpoly A p); A ⊆ B; vars p ⊆ B; ⋀i j. ⟦symmetric_mpoly A p; i ∈ A; j ∈ A; i ≤ j⟧ ⟹ lookup (lead_monom p) j ≤ lookup (lead_monom p) i⟧ ⟹ A ⊆ B› discuss goal 1*) apply ((auto simp: decr_def (*‹decr ≡ λp. ∀i∈A. ∀j∈A. i ≤ j ⟶ lookup (lead_monom p) j ≤ lookup (lead_monom p) i›*))[1]) (*discuss goal 2*) apply ((auto simp: decr_def (*‹decr ≡ λp. ∀i∈A. ∀j∈A. i ≤ j ⟶ lookup (lead_monom p) j ≤ lookup (lead_monom p) i›*))[1]) (*discuss goal 3*) apply ((auto simp: decr_def (*‹decr ≡ λp. ∀i∈A. ∀j∈A. i ≤ j ⟶ lookup (lead_monom p) j ≤ lookup (lead_monom p) i›*))[1]) (*discuss goal 4*) apply ((auto simp: decr_def (*‹decr ≡ λp. ∀i∈A. ∀j∈A. i ≤ j ⟶ lookup (lead_monom p) j ≤ lookup (lead_monom p) i›*))[1]) (*discuss goal 5*) apply ((auto simp: decr_def (*‹decr ≡ λp. ∀i∈A. ∀j∈A. i ≤ j ⟶ lookup (lead_monom p) j ≤ lookup (lead_monom p) i›*))[1]) (*proven 5 subgoals*) . thus "?thesis" (*goal: ‹local.fund_sym_poly_wit_dom p›*) using fund_sym_poly_wit.domintros (*‹(⋀x::nat. ⟦symmetric_mpoly (A::nat set) (?p::'a mpoly); lead_monom ?p ≠ (0::nat ⇒₀ nat); ¬ local.fund_sym_poly_wit_dom (?p - local.fund_sym_step_poly ?p); x ∈ vars ?p; x ∈ A⟧ ⟹ False) ⟹ local.fund_sym_poly_wit_dom ?p›*) by blast qed (auto intro: fund_sym_poly_wit.domintros (*‹(⋀x. ⟦symmetric_mpoly A ?p; lead_monom ?p ≠ 0; ¬ local.fund_sym_poly_wit_dom (?p - local.fund_sym_step_poly ?p); x ∈ vars ?p; x ∈ A⟧ ⟹ False) ⟹ local.fund_sym_poly_wit_dom ?p›*)) (*solved the remaining goal: ‹lead_monom p = 0 ∨ ¬ symmetric_mpoly A p ⟹ local.fund_sym_poly_wit_dom p›*) qed lemma fund_sym_poly_wit_dom [intro]: "fund_sym_poly_wit_dom p" proof (-) (*goal: ‹local.fund_sym_poly_wit_dom p›*) consider "¬symmetric_mpoly A p" | "vars p ∩ A = {}" | "symmetric_mpoly A p" and "A ⊆ vars p" (*goal: ‹⟦¬ symmetric_mpoly A p ⟹ thesis; vars p ∩ A = {} ⟹ thesis; ⟦symmetric_mpoly A p; A ⊆ vars p⟧ ⟹ thesis⟧ ⟹ thesis›*) using symmetric_mpoly_imp_orthogonal_or_subset[of A p] (*‹symmetric_mpoly (A::nat set) (p::'a::comm_ring_1 mpoly) ⟹ vars p ∩ A = {} ∨ A ⊆ vars p›*) by blast thus "?thesis" (*goal: ‹local.fund_sym_poly_wit_dom p›*) proof (cases) (*goals: 1. ‹¬ symmetric_mpoly A p ⟹ local.fund_sym_poly_wit_dom p› 2. ‹vars p ∩ A = {} ⟹ local.fund_sym_poly_wit_dom p› 3. ‹⟦symmetric_mpoly A p; A ⊆ vars p⟧ ⟹ local.fund_sym_poly_wit_dom p›*) assume "symmetric_mpoly A p" "A ⊆ vars p" (*‹symmetric_mpoly (A::nat set) (p::'a mpoly)› ‹(A::nat set) ⊆ vars (p::'a mpoly)›*) thus "?thesis" (*goal: ‹local.fund_sym_poly_wit_dom p›*) using fund_sym_poly_wit_dom_aux[of "vars p" p] (*‹⟦finite (vars (p::'a mpoly)); vars p ⊆ vars p; (A::nat set) ⊆ vars p⟧ ⟹ local.fund_sym_poly_wit_dom p›*) by (auto simp: vars_finite (*‹finite (vars ?p)›*)) qed (auto intro: fund_sym_poly_wit.domintros (*‹(⋀x::nat. ⟦symmetric_mpoly (A::nat set) (?p::'a::comm_ring_1 mpoly); lead_monom ?p ≠ (0::nat ⇒₀ nat); ¬ local.fund_sym_poly_wit_dom (?p - local.fund_sym_step_poly ?p); x ∈ vars ?p; x ∈ A⟧ ⟹ False) ⟹ local.fund_sym_poly_wit_dom ?p›*)) (*solves the remaining goals: 1. ‹¬ symmetric_mpoly A p ⟹ local.fund_sym_poly_wit_dom p› 2. ‹vars p ∩ A = {} ⟹ local.fund_sym_poly_wit_dom p›*) qed termination fund_sym_poly_wit by (intro allI fund_sym_poly_wit_dom) (*<*) lemmas [simp del] = fund_sym_poly_wit.simps (*>*) text ‹ Next, we prove that our witness indeed fulfils all the properties stated by the fundamental theorem: ▸ If the original polynomial was in $R[X_1,\ldots,X_n,\ldots, X_m]$ where the $X_1$ to $X_n$ are the symmetric variables, then the witness is a polynomial in $R[X_{n+1},\ldots,X_m][Y_1,\ldots,Y_n]$. This means that its coefficients are polynomials in the variables of the original polynomial, minus the symmetric ones, and the (new and independent) variables of the witness polynomial range from $1$ to $n$. ▸ Substituting the ‹i›-th symmetric polynomial $e_i(X_1,\ldots,X_n)$ for the $Y_i$ variable for every ‹i› yields the original polynomial. ▸ The coefficient ring $R$ need not be the entire type; if the coefficients of the original polynomial are in some subring, then the coefficients of the coefficients of the witness also do. › lemma fund_sym_poly_wit_coeffs_aux: assumes "finite B" "vars p ⊆ B" "symmetric_mpoly A p" "A ⊆ B" shows "vars (coeff (fund_sym_poly_wit p) m) ⊆ B - A" using assms (*‹finite B› ‹vars (p::'a mpoly) ⊆ (B::nat set)› ‹symmetric_mpoly A p› ‹(A::nat set) ⊆ (B::nat set)›*) proof (induction p rule: fund_sym_poly_wit.induct (*‹(⋀p. (¬ (¬ symmetric_mpoly A p ∨ lead_monom p = 0 ∨ vars p ∩ A = {}) ⟹ ?P (p - local.fund_sym_step_poly p)) ⟹ ?P p) ⟹ ?P ?a0.0›*)) (*goal: ‹⋀p. ⟦⟦¬ (¬ symmetric_mpoly A p ∨ lead_monom p = 0 ∨ vars p ∩ A = {}); finite B; vars (p - local.fund_sym_step_poly p) ⊆ B; symmetric_mpoly A (p - local.fund_sym_step_poly p); A ⊆ B⟧ ⟹ vars (MPoly_Type.coeff (local.fund_sym_poly_wit (p - local.fund_sym_step_poly p)) m) ⊆ B - A; finite B; vars p ⊆ B; symmetric_mpoly A p; A ⊆ B⟧ ⟹ vars (MPoly_Type.coeff (local.fund_sym_poly_wit p) m) ⊆ B - A›*) case (1 p) (*‹⟦¬ (¬ symmetric_mpoly A p ∨ lead_monom p = 0 ∨ vars p ∩ A = {}); finite B; vars (p - local.fund_sym_step_poly p) ⊆ B; symmetric_mpoly A (p - local.fund_sym_step_poly p); A ⊆ B⟧ ⟹ vars (MPoly_Type.coeff (local.fund_sym_poly_wit (p - local.fund_sym_step_poly p)) m) ⊆ B - A› ‹finite (B::nat set)› ‹vars p ⊆ B› ‹symmetric_mpoly A p› ‹A ⊆ B›*) show "?case" (*goal: ‹vars (MPoly_Type.coeff (local.fund_sym_poly_wit p) m) ⊆ B - A›*) proof (cases "lead_monom p = 0 ∨ vars p ∩ A = {}") (*goals: 1. ‹lead_monom p = 0 ∨ vars p ∩ A = {} ⟹ vars (MPoly_Type.coeff (local.fund_sym_poly_wit p) m) ⊆ B - A› 2. ‹¬ (lead_monom p = 0 ∨ vars p ∩ A = {}) ⟹ vars (MPoly_Type.coeff (local.fund_sym_poly_wit p) m) ⊆ B - A›*) case False (*‹¬ (lead_monom p = 0 ∨ vars p ∩ A = {})›*) have "vars (p - fund_sym_step_poly p) ⊆ B" using "1.prems" (*‹finite (B::nat set)› ‹vars p ⊆ B› ‹symmetric_mpoly A p› ‹A ⊆ B›*) fund_sym_step_poly[of p] (*‹⟦finite A; p ≠ 0; decr p⟧ ⟹ lead_monom (local.fund_sym_step_poly p) = lead_monom p› ‹⟦finite (A::nat set); (p::'a mpoly) ≠ (0::'a mpoly); (decr::'a mpoly ⇒ bool) p⟧ ⟹ Symmetric_Polynomials.lead_coeff (local.fund_sym_step_poly p) = Symmetric_Polynomials.lead_coeff p› ‹⟦finite A; p ≠ 0; decr p⟧ ⟹ local.fund_sym_step_poly p = local.fund_sym_step_coeff p * (∏x. sym_mpoly A x ^ lookup (local.fund_sym_step_monom p) x)› ‹vars (local.fund_sym_step_poly p) ⊆ vars p ∪ A› ‹symmetric_mpoly A (local.fund_sym_step_poly p)›*) apply (intro order.trans[OF vars_diff] (*‹vars (?p1.1::?'a1 mpoly) ∪ vars (?p2.1::?'a1 mpoly) ⊆ (?c::nat set) ⟹ vars (?p1.1 - ?p2.1) ⊆ ?c›*)) (*goal: ‹vars (p - local.fund_sym_step_poly p) ⊆ B›*) by auto with "1" (*‹⟦¬ (¬ symmetric_mpoly A p ∨ lead_monom p = 0 ∨ vars p ∩ A = {}); finite B; vars (p - local.fund_sym_step_poly p) ⊆ B; symmetric_mpoly A (p - local.fund_sym_step_poly p); A ⊆ B⟧ ⟹ vars (MPoly_Type.coeff (local.fund_sym_poly_wit (p - local.fund_sym_step_poly p)) m) ⊆ B - A› ‹finite B› ‹vars p ⊆ B› ‹symmetric_mpoly A p› ‹A ⊆ B›*) False (*‹¬ (lead_monom (p::'a::comm_ring_1 mpoly) = (0::nat ⇒₀ nat) ∨ vars p ∩ (A::nat set) = {})›*) have "vars (coeff (fund_sym_poly_wit (p - fund_sym_step_poly p)) m) ⊆ B - A" apply (intro 1 (*‹⟦¬ (¬ symmetric_mpoly A p ∨ lead_monom p = 0 ∨ vars p ∩ A = {}); finite B; vars (p - local.fund_sym_step_poly p) ⊆ B; symmetric_mpoly A (p - local.fund_sym_step_poly p); A ⊆ B⟧ ⟹ vars (MPoly_Type.coeff (local.fund_sym_poly_wit (p - local.fund_sym_step_poly p)) m) ⊆ B - A› ‹finite B› ‹vars p ⊆ B› ‹symmetric_mpoly A p› ‹A ⊆ B›*) symmetric_mpoly_diff (*‹⟦symmetric_mpoly ?A ?p; symmetric_mpoly ?A ?q⟧ ⟹ symmetric_mpoly ?A (?p - ?q)›*) fund_sym_step_poly (*‹⟦finite A; ?p ≠ 0; decr ?p⟧ ⟹ lead_monom (local.fund_sym_step_poly ?p) = lead_monom ?p› ‹⟦finite A; ?p ≠ 0; decr ?p⟧ ⟹ Symmetric_Polynomials.lead_coeff (local.fund_sym_step_poly ?p) = Symmetric_Polynomials.lead_coeff ?p› ‹⟦finite A; ?p ≠ 0; decr ?p⟧ ⟹ local.fund_sym_step_poly ?p = local.fund_sym_step_coeff ?p * (∏x. sym_mpoly A x ^ lookup (local.fund_sym_step_monom ?p) x)› ‹vars (local.fund_sym_step_poly ?p) ⊆ vars ?p ∪ A› ‹symmetric_mpoly A (local.fund_sym_step_poly ?p)›*)) (*goals: 1. ‹⟦⟦¬ (¬ symmetric_mpoly A p ∨ lead_monom p = 0 ∨ vars p ∩ A = {}); finite B; vars (p - local.fund_sym_step_poly p) ⊆ B; symmetric_mpoly A (p - local.fund_sym_step_poly p); A ⊆ B⟧ ⟹ vars (MPoly_Type.coeff (local.fund_sym_poly_wit (p - local.fund_sym_step_poly p)) m) ⊆ B - A; finite B; vars p ⊆ B; symmetric_mpoly A p; A ⊆ B; ¬ (lead_monom p = 0 ∨ vars p ∩ A = {}); vars (p - local.fund_sym_step_poly p) ⊆ B⟧ ⟹ ¬ (¬ symmetric_mpoly A p ∨ lead_monom p = 0 ∨ vars p ∩ A = {})› 2. ‹⟦⟦¬ (¬ symmetric_mpoly A p ∨ lead_monom p = 0 ∨ vars p ∩ A = {}); finite B; vars (p - local.fund_sym_step_poly p) ⊆ B; symmetric_mpoly A (p - local.fund_sym_step_poly p); A ⊆ B⟧ ⟹ vars (MPoly_Type.coeff (local.fund_sym_poly_wit (p - local.fund_sym_step_poly p)) m) ⊆ B - A; finite B; vars p ⊆ B; symmetric_mpoly A p; A ⊆ B; ¬ (lead_monom p = 0 ∨ vars p ∩ A = {}); vars (p - local.fund_sym_step_poly p) ⊆ B⟧ ⟹ vars (p - local.fund_sym_step_poly p) ⊆ B› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . hence "vars (coeff (fund_sym_poly_wit (p - fund_sym_step_poly p) + monom (fund_sym_step_monom p) (fund_sym_step_coeff p)) m) ⊆ B - A" unfolding coeff_add coeff_monom (*goal: ‹vars (MPoly_Type.coeff (local.fund_sym_poly_wit (p - local.fund_sym_step_poly p)) m + (local.fund_sym_step_coeff p when m = local.fund_sym_step_monom p)) ⊆ B - A›*) using vars_fund_sym_step_coeff[of p] (*‹vars (local.fund_sym_step_coeff (p::'a::comm_ring_1 mpoly)) ⊆ vars p - (A::nat set)›*) "1.prems" (*‹finite B› ‹vars p ⊆ B› ‹symmetric_mpoly A p› ‹A ⊆ B›*) apply (intro order.trans[OF vars_add] (*‹vars ?p1.1 ∪ vars ?p2.1 ⊆ ?c ⟹ vars (?p1.1 + ?p2.1) ⊆ ?c›*) Un_least (*‹⟦?A ⊆ ?C; ?B ⊆ ?C⟧ ⟹ ?A ∪ ?B ⊆ ?C›*) order.trans[OF vars_monom_subset] (*‹keys ?m1 ⊆ ?c ⟹ vars (MPoly_Type.monom ?m1 ?a1) ⊆ ?c›*)) (*goals: 1. ‹⟦vars (MPoly_Type.coeff (local.fund_sym_poly_wit (p - local.fund_sym_step_poly p)) m) ⊆ B - A; vars (local.fund_sym_step_coeff p) ⊆ vars p - A; finite B; vars p ⊆ B; symmetric_mpoly A p; A ⊆ B⟧ ⟹ vars (MPoly_Type.coeff (local.fund_sym_poly_wit (p - local.fund_sym_step_poly p)) m) ⊆ B - A› 2. ‹⟦vars (MPoly_Type.coeff (local.fund_sym_poly_wit (p - local.fund_sym_step_poly p)) m) ⊆ B - A; vars (local.fund_sym_step_coeff p) ⊆ vars p - A; finite B; vars p ⊆ B; symmetric_mpoly A p; A ⊆ B⟧ ⟹ vars (local.fund_sym_step_coeff p when m = local.fund_sym_step_monom p) ⊆ B - A› discuss goal 1*) apply ((auto simp: when_def (*‹(?a when ?P) = (if ?P then ?a else 0)›*))[1]) (*discuss goal 2*) apply ((auto simp: when_def (*‹(?a when ?P) = (if ?P then ?a else 0)›*))[1]) (*proven 2 subgoals*) . thus "?thesis" (*goal: ‹vars (MPoly_Type.coeff (local.fund_sym_poly_wit p) m) ⊆ B - A›*) using "1.prems" (*‹finite B› ‹vars p ⊆ B› ‹symmetric_mpoly A p› ‹A ⊆ B›*) False (*‹¬ (lead_monom p = 0 ∨ vars p ∩ A = {})›*) unfolding fund_sym_poly_wit.simps[of p] (*goal: ‹vars (MPoly_Type.coeff (if ¬ symmetric_mpoly A p ∨ lead_monom p = 0 ∨ vars p ∩ A = {} then Const p else local.fund_sym_poly_wit (p - local.fund_sym_step_poly p) + MPoly_Type.monom (local.fund_sym_step_monom p) (local.fund_sym_step_coeff p)) m) ⊆ B - A›*) by simp qed (insert "1.prems" (*‹finite B› ‹vars p ⊆ B› ‹symmetric_mpoly A p› ‹A ⊆ B›*), auto simp: fund_sym_poly_wit.simps[of p] (*‹local.fund_sym_poly_wit p = (if ¬ symmetric_mpoly A p ∨ lead_monom p = 0 ∨ vars p ∩ A = {} then Const p else local.fund_sym_poly_wit (p - local.fund_sym_step_poly p) + MPoly_Type.monom (local.fund_sym_step_monom p) (local.fund_sym_step_coeff p))›*) mpoly_coeff_Const (*‹MPoly_Type.coeff (Const ?c) ?m = (if ?m = 0 then ?c else 0)›*) lead_monom_eq_0_iff (*‹(lead_monom ?p = 0) = (vars ?p = {})›*)) (*solved the remaining goal: ‹lead_monom p = 0 ∨ vars p ∩ A = {} ⟹ vars (MPoly_Type.coeff (local.fund_sym_poly_wit p) m) ⊆ B - A›*) qed lemma fund_sym_poly_wit_coeffs: assumes "symmetric_mpoly A p" shows "vars (coeff (fund_sym_poly_wit p) m) ⊆ vars p - A" proof (cases "A ⊆ vars p") (*goals: 1. ‹A ⊆ vars p ⟹ vars (MPoly_Type.coeff (local.fund_sym_poly_wit p) m) ⊆ vars p - A› 2. ‹¬ A ⊆ vars p ⟹ vars (MPoly_Type.coeff (local.fund_sym_poly_wit p) m) ⊆ vars p - A›*) case True (*‹A ⊆ vars p›*) with fund_sym_poly_wit_coeffs_aux[of "vars p" p m] (*‹⟦finite (vars (p::'a mpoly)); vars p ⊆ vars p; symmetric_mpoly (A::nat set) p; A ⊆ vars p⟧ ⟹ vars (MPoly_Type.coeff (local.fund_sym_poly_wit p) (m::nat ⇒₀ nat)) ⊆ vars p - A›*) assms (*‹symmetric_mpoly (A::nat set) (p::'a::comm_ring_1 mpoly)›*) show "?thesis" (*goal: ‹vars (MPoly_Type.coeff (local.fund_sym_poly_wit p) m) ⊆ vars p - A›*) by (auto simp: vars_finite (*‹finite (vars (?p::?'a::zero mpoly))›*)) next (*goal: ‹¬ A ⊆ vars p ⟹ vars (MPoly_Type.coeff (local.fund_sym_poly_wit p) m) ⊆ vars p - A›*) case False (*‹¬ A ⊆ vars p›*) hence "vars p ∩ A = {}" using symmetric_mpoly_imp_orthogonal_or_subset[OF assms] (*‹vars p ∩ A = {} ∨ A ⊆ vars p›*) by auto thus "?thesis" (*goal: ‹vars (MPoly_Type.coeff (local.fund_sym_poly_wit p) m) ⊆ vars p - A›*) by (auto simp: fund_sym_poly_wit.simps[of p] (*‹local.fund_sym_poly_wit p = (if ¬ symmetric_mpoly A p ∨ lead_monom p = 0 ∨ vars p ∩ A = {} then Const p else local.fund_sym_poly_wit (p - local.fund_sym_step_poly p) + MPoly_Type.monom (local.fund_sym_step_monom p) (local.fund_sym_step_coeff p))›*) mpoly_coeff_Const (*‹MPoly_Type.coeff (Const ?c) ?m = (if ?m = 0 then ?c else 0)›*)) qed lemma fund_sym_poly_wit_vars: "vars (fund_sym_poly_wit p) ⊆ {1..n}" proof (cases "symmetric_mpoly A p ∧ A ⊆ vars p") (*goals: 1. ‹symmetric_mpoly A p ∧ A ⊆ vars p ⟹ vars (local.fund_sym_poly_wit p) ⊆ {1..n}› 2. ‹¬ (symmetric_mpoly A p ∧ A ⊆ vars p) ⟹ vars (local.fund_sym_poly_wit p) ⊆ {1..n}›*) case True (*‹symmetric_mpoly A p ∧ A ⊆ vars p›*) define B where "B = vars p" have "finite B" "vars p ⊆ B" "symmetric_mpoly A p" "A ⊆ B" using True (*‹symmetric_mpoly A p ∧ A ⊆ vars p›*) unfolding B_def (*goals: 1. ‹finite (vars p)› 2. ‹vars p ⊆ vars p› 3. ‹symmetric_mpoly A p› 4. ‹A ⊆ vars p›*) apply - (*goals: 1. ‹symmetric_mpoly A p ∧ A ⊆ vars p ⟹ finite (vars p)› 2. ‹symmetric_mpoly A p ∧ A ⊆ vars p ⟹ vars p ⊆ vars p› 3. ‹symmetric_mpoly A p ∧ A ⊆ vars p ⟹ symmetric_mpoly A p› 4. ‹symmetric_mpoly A p ∧ A ⊆ vars p ⟹ A ⊆ vars p› discuss goal 1*) apply ((auto simp: vars_finite (*‹finite (vars ?p)›*))[1]) (*discuss goal 2*) apply ((auto simp: vars_finite (*‹finite (vars ?p)›*))[1]) (*discuss goal 3*) apply ((auto simp: vars_finite (*‹finite (vars ?p)›*))[1]) (*discuss goal 4*) apply ((auto simp: vars_finite (*‹finite (vars ?p)›*))[1]) (*proven 4 subgoals*) . thus "?thesis" (*goal: ‹vars (local.fund_sym_poly_wit p) ⊆ {1..n}›*) proof (induction p rule: fund_sym_poly_wit.induct (*‹(⋀p::'a mpoly. (¬ (¬ symmetric_mpoly (A::nat set) p ∨ lead_monom p = (0::nat ⇒₀ nat) ∨ vars p ∩ A = {}) ⟹ (?P::'a mpoly ⇒ bool) (p - local.fund_sym_step_poly p)) ⟹ ?P p) ⟹ ?P (?a0.0::'a mpoly)›*)) (*goal: ‹⋀p. ⟦⟦¬ (¬ symmetric_mpoly A p ∨ lead_monom p = 0 ∨ vars p ∩ A = {}); finite B; vars (p - local.fund_sym_step_poly p) ⊆ B; symmetric_mpoly A (p - local.fund_sym_step_poly p); A ⊆ B⟧ ⟹ vars (local.fund_sym_poly_wit (p - local.fund_sym_step_poly p)) ⊆ {1..n}; finite B; vars p ⊆ B; symmetric_mpoly A p; A ⊆ B⟧ ⟹ vars (local.fund_sym_poly_wit p) ⊆ {1..n}›*) case (1 p) (*‹⟦¬ (¬ symmetric_mpoly (A::nat set) (p::'a mpoly) ∨ lead_monom p = (0::nat ⇒₀ nat) ∨ vars p ∩ A = {}); finite (B::nat set); vars (p - local.fund_sym_step_poly p) ⊆ B; symmetric_mpoly A (p - local.fund_sym_step_poly p); A ⊆ B⟧ ⟹ vars (local.fund_sym_poly_wit (p - local.fund_sym_step_poly p)) ⊆ {1::nat..n::nat}› ‹finite B› ‹vars p ⊆ B› ‹symmetric_mpoly A p› ‹A ⊆ B›*) show "?case" (*goal: ‹vars (local.fund_sym_poly_wit p) ⊆ {1..n}›*) proof (cases "lead_monom p = 0 ∨ vars p ∩ A = {}") (*goals: 1. ‹lead_monom p = 0 ∨ vars p ∩ A = {} ⟹ vars (local.fund_sym_poly_wit p) ⊆ {1..n}› 2. ‹¬ (lead_monom p = 0 ∨ vars p ∩ A = {}) ⟹ vars (local.fund_sym_poly_wit p) ⊆ {1..n}›*) case False (*‹¬ (lead_monom p = 0 ∨ vars p ∩ A = {})›*) have "vars (p - fund_sym_step_poly p) ⊆ B" using "1.prems" (*‹finite B› ‹vars p ⊆ B› ‹symmetric_mpoly A p› ‹(A::nat set) ⊆ (B::nat set)›*) fund_sym_step_poly[of p] (*‹⟦finite A; p ≠ 0; decr p⟧ ⟹ lead_monom (local.fund_sym_step_poly p) = lead_monom p› ‹⟦finite A; p ≠ 0; decr p⟧ ⟹ Symmetric_Polynomials.lead_coeff (local.fund_sym_step_poly p) = Symmetric_Polynomials.lead_coeff p› ‹⟦finite A; p ≠ 0; decr p⟧ ⟹ local.fund_sym_step_poly p = local.fund_sym_step_coeff p * (∏x. sym_mpoly A x ^ lookup (local.fund_sym_step_monom p) x)› ‹vars (local.fund_sym_step_poly p) ⊆ vars p ∪ A› ‹symmetric_mpoly A (local.fund_sym_step_poly p)›*) apply (intro order.trans[OF vars_diff] (*‹vars (?p1.1::?'a1 mpoly) ∪ vars (?p2.1::?'a1 mpoly) ⊆ (?c::nat set) ⟹ vars (?p1.1 - ?p2.1) ⊆ ?c›*)) (*goal: ‹vars (p - local.fund_sym_step_poly p) ⊆ B›*) by auto hence "vars (local.fund_sym_poly_wit (p - local.fund_sym_step_poly p)) ⊆ {1..n}" using False (*‹¬ (lead_monom p = 0 ∨ vars p ∩ A = {})›*) "1.prems" (*‹finite B› ‹vars p ⊆ B› ‹symmetric_mpoly A p› ‹(A::nat set) ⊆ (B::nat set)›*) apply (intro 1 (*‹⟦¬ (¬ symmetric_mpoly (A::nat set) (p::'a mpoly) ∨ lead_monom p = (0::nat ⇒₀ nat) ∨ vars p ∩ A = {}); finite (B::nat set); vars (p - local.fund_sym_step_poly p) ⊆ B; symmetric_mpoly A (p - local.fund_sym_step_poly p); A ⊆ B⟧ ⟹ vars (local.fund_sym_poly_wit (p - local.fund_sym_step_poly p)) ⊆ {1::nat..n::nat}› ‹finite (B::nat set)› ‹vars (p::'a mpoly) ⊆ (B::nat set)› ‹symmetric_mpoly (A::nat set) (p::'a mpoly)› ‹(A::nat set) ⊆ (B::nat set)›*) symmetric_mpoly_diff (*‹⟦symmetric_mpoly (?A::nat set) (?p::?'a mpoly); symmetric_mpoly ?A (?q::?'a mpoly)⟧ ⟹ symmetric_mpoly ?A (?p - ?q)›*) fund_sym_step_poly (*‹⟦finite (A::nat set); (?p::'a mpoly) ≠ (0::'a mpoly); (decr::'a mpoly ⇒ bool) ?p⟧ ⟹ lead_monom (local.fund_sym_step_poly ?p) = lead_monom ?p› ‹⟦finite (A::nat set); (?p::'a mpoly) ≠ (0::'a mpoly); (decr::'a mpoly ⇒ bool) ?p⟧ ⟹ Symmetric_Polynomials.lead_coeff (local.fund_sym_step_poly ?p) = Symmetric_Polynomials.lead_coeff ?p› ‹⟦finite (A::nat set); (?p::'a mpoly) ≠ (0::'a mpoly); (decr::'a mpoly ⇒ bool) ?p⟧ ⟹ local.fund_sym_step_poly ?p = local.fund_sym_step_coeff ?p * (∏x::nat. sym_mpoly A x ^ lookup (local.fund_sym_step_monom ?p) x)› ‹vars (local.fund_sym_step_poly (?p::'a mpoly)) ⊆ vars ?p ∪ (A::nat set)› ‹symmetric_mpoly (A::nat set) (local.fund_sym_step_poly (?p::'a mpoly))›*)) (*goals: 1. ‹⟦vars (p - local.fund_sym_step_poly p) ⊆ B; ¬ (lead_monom p = 0 ∨ vars p ∩ A = {}); finite B; vars p ⊆ B; symmetric_mpoly A p; A ⊆ B⟧ ⟹ ¬ (¬ symmetric_mpoly A p ∨ lead_monom p = 0 ∨ vars p ∩ A = {})› 2. ‹⟦vars (p - local.fund_sym_step_poly p) ⊆ B; ¬ (lead_monom p = 0 ∨ vars p ∩ A = {}); finite B; vars p ⊆ B; symmetric_mpoly A p; A ⊆ B⟧ ⟹ vars (p - local.fund_sym_step_poly p) ⊆ B› discuss goal 1*) apply ((auto simp: lead_monom_eq_0_iff (*‹(lead_monom ?p = 0) = (vars ?p = {})›*))[1]) (*discuss goal 2*) apply ((auto simp: lead_monom_eq_0_iff (*‹(lead_monom (?p::?'a mpoly) = (0::nat ⇒₀ nat)) = (vars ?p = {})›*))[1]) (*proven 2 subgoals*) . hence "vars (fund_sym_poly_wit (p - fund_sym_step_poly p) + monom (fund_sym_step_monom p) (local.fund_sym_step_coeff p)) ⊆ {1..n}" apply (intro order.trans[OF vars_add] (*‹vars (?p1.1::?'a1 mpoly) ∪ vars (?p2.1::?'a1 mpoly) ⊆ (?c::nat set) ⟹ vars (?p1.1 + ?p2.1) ⊆ ?c›*) Un_least (*‹⟦(?A::?'a set) ⊆ (?C::?'a set); (?B::?'a set) ⊆ ?C⟧ ⟹ ?A ∪ ?B ⊆ ?C›*) order.trans[OF vars_monom_subset] (*‹keys (?m1::nat ⇒₀ nat) ⊆ (?c::nat set) ⟹ vars (MPoly_Type.monom ?m1 (?a1::?'a1)) ⊆ ?c›*) keys_fund_sym_step_monom (*‹keys (local.fund_sym_step_monom (?p::'a mpoly)) ⊆ {1::nat..n::nat}›*)) (*goal: ‹vars (local.fund_sym_poly_wit ((p::'a mpoly) - local.fund_sym_step_poly p) + MPoly_Type.monom (local.fund_sym_step_monom p) (local.fund_sym_step_coeff p)) ⊆ {1::nat..n::nat}›*) by auto thus "?thesis" (*goal: ‹vars (local.fund_sym_poly_wit p) ⊆ {1..n}›*) using "1.prems" (*‹finite B› ‹vars (p::'a mpoly) ⊆ (B::nat set)› ‹symmetric_mpoly (A::nat set) (p::'a::comm_ring_1 mpoly)› ‹A ⊆ B›*) False (*‹¬ (lead_monom p = 0 ∨ vars p ∩ A = {})›*) unfolding fund_sym_poly_wit.simps[of p] (*goal: ‹vars (if ¬ symmetric_mpoly A p ∨ lead_monom p = 0 ∨ vars p ∩ A = {} then Const p else local.fund_sym_poly_wit (p - local.fund_sym_step_poly p) + MPoly_Type.monom (local.fund_sym_step_monom p) (local.fund_sym_step_coeff p)) ⊆ {1..n}›*) by simp qed (insert "1.prems" (*‹finite B› ‹vars p ⊆ B› ‹symmetric_mpoly A p› ‹A ⊆ B›*), auto simp: fund_sym_poly_wit.simps[of p] (*‹local.fund_sym_poly_wit p = (if ¬ symmetric_mpoly A p ∨ lead_monom p = 0 ∨ vars p ∩ A = {} then Const p else local.fund_sym_poly_wit (p - local.fund_sym_step_poly p) + MPoly_Type.monom (local.fund_sym_step_monom p) (local.fund_sym_step_coeff p))›*) mpoly_coeff_Const (*‹MPoly_Type.coeff (Const ?c) ?m = (if ?m = 0 then ?c else 0)›*) lead_monom_eq_0_iff (*‹(lead_monom ?p = 0) = (vars ?p = {})›*)) (*solved the remaining goal: ‹lead_monom p = 0 ∨ vars p ∩ A = {} ⟹ vars (local.fund_sym_poly_wit p) ⊆ {1..n}›*) qed next (*goal: ‹¬ (symmetric_mpoly A p ∧ A ⊆ vars p) ⟹ vars (local.fund_sym_poly_wit p) ⊆ {1..n}›*) case False (*‹¬ (symmetric_mpoly A p ∧ A ⊆ vars p)›*) then consider "¬symmetric_mpoly A p" | "symmetric_mpoly A p" and "vars p ∩ A = {}" (*goal: ‹⟦¬ symmetric_mpoly A p ⟹ thesis; ⟦symmetric_mpoly A p; vars p ∩ A = {}⟧ ⟹ thesis⟧ ⟹ thesis›*) using symmetric_mpoly_imp_orthogonal_or_subset[of A p] (*‹symmetric_mpoly A p ⟹ vars p ∩ A = {} ∨ A ⊆ vars p›*) by auto thus "?thesis" (*goal: ‹vars (local.fund_sym_poly_wit p) ⊆ {1..n}›*) apply cases (*goals: 1. ‹¬ symmetric_mpoly A p ⟹ vars (local.fund_sym_poly_wit p) ⊆ {1..n}› 2. ‹⟦symmetric_mpoly A p; vars p ∩ A = {}⟧ ⟹ vars (local.fund_sym_poly_wit p) ⊆ {1..n}› discuss goal 1*) apply ((auto simp: fund_sym_poly_wit.simps[of p] (*‹local.fund_sym_poly_wit p = (if ¬ symmetric_mpoly A p ∨ lead_monom p = 0 ∨ vars p ∩ A = {} then Const p else local.fund_sym_poly_wit (p - local.fund_sym_step_poly p) + MPoly_Type.monom (local.fund_sym_step_monom p) (local.fund_sym_step_coeff p))›*))[1]) (*discuss goal 2*) apply ((auto simp: fund_sym_poly_wit.simps[of p] (*‹local.fund_sym_poly_wit p = (if ¬ symmetric_mpoly A p ∨ lead_monom p = 0 ∨ vars p ∩ A = {} then Const p else local.fund_sym_poly_wit (p - local.fund_sym_step_poly p) + MPoly_Type.monom (local.fund_sym_step_monom p) (local.fund_sym_step_coeff p))›*))[1]) (*proven 2 subgoals*) . qed lemma fund_sym_poly_wit_insertion_aux: assumes "finite B" "vars p ⊆ B" "symmetric_mpoly A p" "A ⊆ B" shows "insertion (sym_mpoly A) (fund_sym_poly_wit p) = p" using assms (*‹finite (B::nat set)› ‹vars p ⊆ B› ‹symmetric_mpoly A p› ‹A ⊆ B›*) proof (induction p rule: fund_sym_poly_wit.induct (*‹(⋀p. (¬ (¬ symmetric_mpoly A p ∨ lead_monom p = 0 ∨ vars p ∩ A = {}) ⟹ ?P (p - local.fund_sym_step_poly p)) ⟹ ?P p) ⟹ ?P ?a0.0›*)) (*goal: ‹⋀p. ⟦⟦¬ (¬ symmetric_mpoly A p ∨ lead_monom p = 0 ∨ vars p ∩ A = {}); finite B; vars (p - local.fund_sym_step_poly p) ⊆ B; symmetric_mpoly A (p - local.fund_sym_step_poly p); A ⊆ B⟧ ⟹ insertion (sym_mpoly A) (local.fund_sym_poly_wit (p - local.fund_sym_step_poly p)) = p - local.fund_sym_step_poly p; finite B; vars p ⊆ B; symmetric_mpoly A p; A ⊆ B⟧ ⟹ insertion (sym_mpoly A) (local.fund_sym_poly_wit p) = p›*) case (1 p) (*‹⟦¬ (¬ symmetric_mpoly A p ∨ lead_monom p = 0 ∨ vars p ∩ A = {}); finite B; vars (p - local.fund_sym_step_poly p) ⊆ B; symmetric_mpoly A (p - local.fund_sym_step_poly p); A ⊆ B⟧ ⟹ insertion (sym_mpoly A) (local.fund_sym_poly_wit (p - local.fund_sym_step_poly p)) = p - local.fund_sym_step_poly p› ‹finite (B::nat set)› ‹vars p ⊆ B› ‹symmetric_mpoly A p› ‹(A::nat set) ⊆ (B::nat set)›*) from "1.prems" (*‹finite B› ‹vars p ⊆ B› ‹symmetric_mpoly A p› ‹A ⊆ B›*) have "decr p" using lookup_lead_monom_decreasing[of A p] (*‹⟦symmetric_mpoly A p; ?i ∈ A; ?j ∈ A; ?i ≤ ?j⟧ ⟹ lookup (lead_monom p) ?j ≤ lookup (lead_monom p) ?i›*) by (auto simp: decr_def (*‹decr::'a mpoly ⇒ bool ≡ λp::'a mpoly. ∀i::nat∈A::nat set. ∀j::nat∈A. i ≤ j ⟶ lookup (lead_monom p) j ≤ lookup (lead_monom p) i›*)) show "?case" (*goal: ‹insertion (sym_mpoly (A::nat set)) (local.fund_sym_poly_wit (p::'a mpoly)) = p›*) proof (cases "lead_monom p = 0 ∨ vars p ∩ A = {}") (*goals: 1. ‹lead_monom (p::'a mpoly) = (0::nat ⇒₀ nat) ∨ vars p ∩ (A::nat set) = {} ⟹ insertion (sym_mpoly A) (local.fund_sym_poly_wit p) = p› 2. ‹¬ (lead_monom (p::'a mpoly) = (0::nat ⇒₀ nat) ∨ vars p ∩ (A::nat set) = {}) ⟹ insertion (sym_mpoly A) (local.fund_sym_poly_wit p) = p›*) case False (*‹¬ (lead_monom p = 0 ∨ vars p ∩ A = {})›*) have "vars (p - fund_sym_step_poly p) ⊆ B" using "1.prems" (*‹finite B› ‹vars p ⊆ B› ‹symmetric_mpoly A p› ‹A ⊆ B›*) fund_sym_step_poly[of p] (*‹⟦finite A; p ≠ 0; decr p⟧ ⟹ lead_monom (local.fund_sym_step_poly p) = lead_monom p› ‹⟦finite A; p ≠ 0; decr p⟧ ⟹ Symmetric_Polynomials.lead_coeff (local.fund_sym_step_poly p) = Symmetric_Polynomials.lead_coeff p› ‹⟦finite (A::nat set); (p::'a mpoly) ≠ (0::'a mpoly); (decr::'a mpoly ⇒ bool) p⟧ ⟹ local.fund_sym_step_poly p = local.fund_sym_step_coeff p * (∏x::nat. sym_mpoly A x ^ lookup (local.fund_sym_step_monom p) x)› ‹vars (local.fund_sym_step_poly p) ⊆ vars p ∪ A› ‹symmetric_mpoly A (local.fund_sym_step_poly p)›*) apply (intro order.trans[OF vars_diff] (*‹vars ?p1.1 ∪ vars ?p2.1 ⊆ ?c ⟹ vars (?p1.1 - ?p2.1) ⊆ ?c›*)) (*goal: ‹vars ((p::'a mpoly) - local.fund_sym_step_poly p) ⊆ (B::nat set)›*) by auto hence "insertion (sym_mpoly A) (fund_sym_poly_wit (p - fund_sym_step_poly p)) = p - fund_sym_step_poly p" using "1" (*‹⟦¬ (¬ symmetric_mpoly A p ∨ lead_monom p = 0 ∨ vars p ∩ A = {}); finite B; vars (p - local.fund_sym_step_poly p) ⊆ B; symmetric_mpoly A (p - local.fund_sym_step_poly p); A ⊆ B⟧ ⟹ insertion (sym_mpoly A) (local.fund_sym_poly_wit (p - local.fund_sym_step_poly p)) = p - local.fund_sym_step_poly p› ‹finite B› ‹vars (p::'a mpoly) ⊆ (B::nat set)› ‹symmetric_mpoly A p› ‹A ⊆ B›*) False (*‹¬ (lead_monom p = 0 ∨ vars p ∩ A = {})›*) apply (intro 1 (*‹⟦¬ (¬ symmetric_mpoly (A::nat set) (p::'a::comm_ring_1 mpoly) ∨ lead_monom p = (0::nat ⇒₀ nat) ∨ vars p ∩ A = {}); finite (B::nat set); vars (p - local.fund_sym_step_poly p) ⊆ B; symmetric_mpoly A (p - local.fund_sym_step_poly p); A ⊆ B⟧ ⟹ insertion (sym_mpoly A) (local.fund_sym_poly_wit (p - local.fund_sym_step_poly p)) = p - local.fund_sym_step_poly p› ‹finite (B::nat set)› ‹vars (p::'a::comm_ring_1 mpoly) ⊆ (B::nat set)› ‹symmetric_mpoly (A::nat set) (p::'a::comm_ring_1 mpoly)› ‹(A::nat set) ⊆ (B::nat set)›*) symmetric_mpoly_diff (*‹⟦symmetric_mpoly (?A::nat set) (?p::?'a::cancel_comm_monoid_add mpoly); symmetric_mpoly ?A (?q::?'a::cancel_comm_monoid_add mpoly)⟧ ⟹ symmetric_mpoly ?A (?p - ?q)›*) fund_sym_step_poly (*‹⟦finite (A::nat set); (?p::'a::comm_ring_1 mpoly) ≠ (0::'a::comm_ring_1 mpoly); (decr::'a::comm_ring_1 mpoly ⇒ bool) ?p⟧ ⟹ lead_monom (local.fund_sym_step_poly ?p) = lead_monom ?p› ‹⟦finite (A::nat set); (?p::'a::comm_ring_1 mpoly) ≠ (0::'a::comm_ring_1 mpoly); (decr::'a::comm_ring_1 mpoly ⇒ bool) ?p⟧ ⟹ Symmetric_Polynomials.lead_coeff (local.fund_sym_step_poly ?p) = Symmetric_Polynomials.lead_coeff ?p› ‹⟦finite (A::nat set); (?p::'a::comm_ring_1 mpoly) ≠ (0::'a::comm_ring_1 mpoly); (decr::'a::comm_ring_1 mpoly ⇒ bool) ?p⟧ ⟹ local.fund_sym_step_poly ?p = local.fund_sym_step_coeff ?p * (∏x::nat. sym_mpoly A x ^ lookup (local.fund_sym_step_monom ?p) x)› ‹vars (local.fund_sym_step_poly (?p::'a::comm_ring_1 mpoly)) ⊆ vars ?p ∪ (A::nat set)› ‹symmetric_mpoly (A::nat set) (local.fund_sym_step_poly (?p::'a::comm_ring_1 mpoly))›*)) (*goals: 1. ‹⟦vars (p - local.fund_sym_step_poly p) ⊆ B; ⟦¬ (¬ symmetric_mpoly A p ∨ lead_monom p = 0 ∨ vars p ∩ A = {}); finite B; vars (p - local.fund_sym_step_poly p) ⊆ B; symmetric_mpoly A (p - local.fund_sym_step_poly p); A ⊆ B⟧ ⟹ insertion (sym_mpoly A) (local.fund_sym_poly_wit (p - local.fund_sym_step_poly p)) = p - local.fund_sym_step_poly p; finite B; vars p ⊆ B; symmetric_mpoly A p; A ⊆ B; ¬ (lead_monom p = 0 ∨ vars p ∩ A = {})⟧ ⟹ ¬ (¬ symmetric_mpoly A p ∨ lead_monom p = 0 ∨ vars p ∩ A = {})› 2. ‹⟦vars (p - local.fund_sym_step_poly p) ⊆ B; ⟦¬ (¬ symmetric_mpoly A p ∨ lead_monom p = 0 ∨ vars p ∩ A = {}); finite B; vars (p - local.fund_sym_step_poly p) ⊆ B; symmetric_mpoly A (p - local.fund_sym_step_poly p); A ⊆ B⟧ ⟹ insertion (sym_mpoly A) (local.fund_sym_poly_wit (p - local.fund_sym_step_poly p)) = p - local.fund_sym_step_poly p; finite B; vars p ⊆ B; symmetric_mpoly A p; A ⊆ B; ¬ (lead_monom p = 0 ∨ vars p ∩ A = {})⟧ ⟹ vars (p - local.fund_sym_step_poly p) ⊆ B› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . moreover have "fund_sym_step_poly p = fund_sym_step_coeff p * (∏x. sym_mpoly A x ^ lookup (fund_sym_step_monom p) x)" using "1.prems" (*‹finite B› ‹vars p ⊆ B› ‹symmetric_mpoly A p› ‹A ⊆ B›*) finite_subset[of A B] (*‹⟦A ⊆ B; finite B⟧ ⟹ finite A›*) False (*‹¬ (lead_monom p = 0 ∨ vars p ∩ A = {})›*) ‹decr p› (*‹decr p›*) apply (intro fund_sym_step_poly (*‹⟦finite A; ?p ≠ 0; decr ?p⟧ ⟹ lead_monom (local.fund_sym_step_poly ?p) = lead_monom ?p› ‹⟦finite A; ?p ≠ 0; decr ?p⟧ ⟹ Symmetric_Polynomials.lead_coeff (local.fund_sym_step_poly ?p) = Symmetric_Polynomials.lead_coeff ?p› ‹⟦finite A; ?p ≠ 0; decr ?p⟧ ⟹ local.fund_sym_step_poly ?p = local.fund_sym_step_coeff ?p * (∏x. sym_mpoly A x ^ lookup (local.fund_sym_step_monom ?p) x)› ‹vars (local.fund_sym_step_poly ?p) ⊆ vars ?p ∪ A› ‹symmetric_mpoly A (local.fund_sym_step_poly ?p)›*)) (*goals: 1. ‹⟦finite B; vars p ⊆ B; symmetric_mpoly A p; A ⊆ B; ⟦A ⊆ B; finite B⟧ ⟹ finite A; ¬ (lead_monom p = 0 ∨ vars p ∩ A = {}); decr p⟧ ⟹ finite A› 2. ‹⟦finite B; vars p ⊆ B; symmetric_mpoly A p; A ⊆ B; ⟦A ⊆ B; finite B⟧ ⟹ finite A; ¬ (lead_monom p = 0 ∨ vars p ∩ A = {}); decr p⟧ ⟹ p ≠ 0› 3. ‹⟦finite B; vars p ⊆ B; symmetric_mpoly A p; A ⊆ B; ⟦A ⊆ B; finite B⟧ ⟹ finite A; ¬ (lead_monom p = 0 ∨ vars p ∩ A = {}); decr p⟧ ⟹ decr p› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*proven 3 subgoals*) . ultimately show "?thesis" (*goal: ‹insertion (sym_mpoly A) (local.fund_sym_poly_wit p) = p›*) unfolding fund_sym_poly_wit.simps[of p] (*goal: ‹insertion (sym_mpoly A) (if ¬ symmetric_mpoly A p ∨ lead_monom p = 0 ∨ vars p ∩ A = {} then Const p else local.fund_sym_poly_wit (p - local.fund_sym_step_poly p) + MPoly_Type.monom (local.fund_sym_step_monom p) (local.fund_sym_step_coeff p)) = p›*) by (auto simp: insertion_add (*‹insertion ?f (?p + ?q) = insertion ?f ?p + insertion ?f ?q›*)) qed (auto simp: fund_sym_poly_wit.simps[of p] (*‹local.fund_sym_poly_wit p = (if ¬ symmetric_mpoly A p ∨ lead_monom p = 0 ∨ vars p ∩ A = {} then Const p else local.fund_sym_poly_wit (p - local.fund_sym_step_poly p) + MPoly_Type.monom (local.fund_sym_step_monom p) (local.fund_sym_step_coeff p))›*)) (*solved the remaining goal: ‹lead_monom p = 0 ∨ vars p ∩ A = {} ⟹ insertion (sym_mpoly A) (local.fund_sym_poly_wit p) = p›*) qed lemma fund_sym_poly_wit_insertion: assumes "symmetric_mpoly A p" shows "insertion (sym_mpoly A) (fund_sym_poly_wit p) = p" proof (cases "A ⊆ vars p") (*goals: 1. ‹(A::nat set) ⊆ vars (p::'a::comm_ring_1 mpoly) ⟹ insertion (sym_mpoly A) (local.fund_sym_poly_wit p) = p› 2. ‹¬ (A::nat set) ⊆ vars (p::'a::comm_ring_1 mpoly) ⟹ insertion (sym_mpoly A) (local.fund_sym_poly_wit p) = p›*) case False (*‹¬ A ⊆ vars p›*) hence "vars p ∩ A = {}" using symmetric_mpoly_imp_orthogonal_or_subset[OF assms] (*‹vars p ∩ A = {} ∨ A ⊆ vars p›*) by auto thus "?thesis" (*goal: ‹insertion (sym_mpoly A) (local.fund_sym_poly_wit p) = p›*) by (auto simp: fund_sym_poly_wit.simps[of p] (*‹local.fund_sym_poly_wit (p::'a::comm_ring_1 mpoly) = (if ¬ symmetric_mpoly (A::nat set) p ∨ lead_monom p = (0::nat ⇒₀ nat) ∨ vars p ∩ A = {} then Const p else local.fund_sym_poly_wit (p - local.fund_sym_step_poly p) + MPoly_Type.monom (local.fund_sym_step_monom p) (local.fund_sym_step_coeff p))›*)) next (*goal: ‹A ⊆ vars p ⟹ insertion (sym_mpoly A) (local.fund_sym_poly_wit p) = p›*) case True (*‹A ⊆ vars p›*) with fund_sym_poly_wit_insertion_aux[of "vars p" p] (*‹⟦finite (vars p); vars p ⊆ vars p; symmetric_mpoly A p; A ⊆ vars p⟧ ⟹ insertion (sym_mpoly A) (local.fund_sym_poly_wit p) = p›*) assms (*‹symmetric_mpoly A p›*) show "?thesis" (*goal: ‹insertion (sym_mpoly A) (local.fund_sym_poly_wit p) = p›*) by (auto simp: vars_finite (*‹finite (vars (?p::?'a::zero mpoly))›*)) qed lemma fund_sym_poly_wit_coeff: assumes "∀m. coeff p m ∈ C" "ring_closed C" shows "∀m m'. coeff (coeff (fund_sym_poly_wit p) m) m' ∈ C" using assms(1) (*‹∀m::nat ⇒₀ nat. MPoly_Type.coeff (p::'a mpoly) m ∈ (C::'a set)›*) proof (induction p rule: fund_sym_poly_wit.induct (*‹(⋀p. (¬ (¬ symmetric_mpoly A p ∨ lead_monom p = 0 ∨ vars p ∩ A = {}) ⟹ ?P (p - local.fund_sym_step_poly p)) ⟹ ?P p) ⟹ ?P ?a0.0›*)) (*goal: ‹⋀p. ⟦⟦¬ (¬ symmetric_mpoly A p ∨ lead_monom p = 0 ∨ vars p ∩ A = {}); ∀m. MPoly_Type.coeff (p - local.fund_sym_step_poly p) m ∈ C⟧ ⟹ ∀m m'. MPoly_Type.coeff (MPoly_Type.coeff (local.fund_sym_poly_wit (p - local.fund_sym_step_poly p)) m) m' ∈ C; ∀m. MPoly_Type.coeff p m ∈ C⟧ ⟹ ∀m m'. MPoly_Type.coeff (MPoly_Type.coeff (local.fund_sym_poly_wit p) m) m' ∈ C›*) case (1 p) (*‹⟦¬ (¬ symmetric_mpoly A p ∨ lead_monom p = 0 ∨ vars p ∩ A = {}); ∀m. MPoly_Type.coeff (p - local.fund_sym_step_poly p) m ∈ C⟧ ⟹ ∀m m'. MPoly_Type.coeff (MPoly_Type.coeff (local.fund_sym_poly_wit (p - local.fund_sym_step_poly p)) m) m' ∈ C› ‹∀m. MPoly_Type.coeff p m ∈ C›*) interpret ring_closed C by fact show "?case" (*goal: ‹∀(m::nat ⇒₀ nat) m'::nat ⇒₀ nat. MPoly_Type.coeff (MPoly_Type.coeff (local.fund_sym_poly_wit (p::'a::comm_ring_1 mpoly)) m) m' ∈ (C::'a::comm_ring_1 set)›*) proof (cases "¬symmetric_mpoly A p ∨ lead_monom p = 0 ∨ vars p ∩ A = {}") (*goals: 1. ‹¬ symmetric_mpoly A p ∨ lead_monom p = 0 ∨ vars p ∩ A = {} ⟹ ∀m m'. MPoly_Type.coeff (MPoly_Type.coeff (local.fund_sym_poly_wit p) m) m' ∈ C› 2. ‹¬ (¬ symmetric_mpoly A p ∨ lead_monom p = 0 ∨ vars p ∩ A = {}) ⟹ ∀m m'. MPoly_Type.coeff (MPoly_Type.coeff (local.fund_sym_poly_wit p) m) m' ∈ C›*) case True (*‹¬ symmetric_mpoly A p ∨ lead_monom p = 0 ∨ vars p ∩ A = {}›*) thus "?thesis" (*goal: ‹∀m m'. MPoly_Type.coeff (MPoly_Type.coeff (local.fund_sym_poly_wit p) m) m' ∈ C›*) using "1.prems" (*‹∀m. MPoly_Type.coeff p m ∈ C›*) by (auto simp: fund_sym_poly_wit.simps[of p] (*‹local.fund_sym_poly_wit p = (if ¬ symmetric_mpoly A p ∨ lead_monom p = 0 ∨ vars p ∩ A = {} then Const p else local.fund_sym_poly_wit (p - local.fund_sym_step_poly p) + MPoly_Type.monom (local.fund_sym_step_monom p) (local.fund_sym_step_coeff p))›*) mpoly_coeff_Const (*‹MPoly_Type.coeff (Const ?c) ?m = (if ?m = 0 then ?c else 0)›*)) next (*goal: ‹¬ (¬ symmetric_mpoly A p ∨ lead_monom p = 0 ∨ vars p ∩ A = {}) ⟹ ∀m m'. MPoly_Type.coeff (MPoly_Type.coeff (local.fund_sym_poly_wit p) m) m' ∈ C›*) case False (*‹¬ (¬ symmetric_mpoly (A::nat set) (p::'a mpoly) ∨ lead_monom p = (0::nat ⇒₀ nat) ∨ vars p ∩ A = {})›*) have "*": "∀m m'. coeff (coeff (fund_sym_poly_wit (p - fund_sym_step_poly p)) m) m' ∈ C" using False (*‹¬ (¬ symmetric_mpoly A p ∨ lead_monom p = 0 ∨ vars p ∩ A = {})›*) "1.prems" (*‹∀m. MPoly_Type.coeff p m ∈ C›*) assms (*‹∀m::nat ⇒₀ nat. MPoly_Type.coeff (p::'a mpoly) m ∈ (C::'a set)› ‹ring_closed C›*) coeff_fund_sym_step_poly[of p] (*‹⟦∀m. MPoly_Type.coeff p m ∈ ?C; ring_closed ?C⟧ ⟹ MPoly_Type.coeff (local.fund_sym_step_poly p) ?m ∈ ?C›*) apply (intro 1 (*‹⟦¬ (¬ symmetric_mpoly A p ∨ lead_monom p = 0 ∨ vars p ∩ A = {}); ∀m. MPoly_Type.coeff (p - local.fund_sym_step_poly p) m ∈ C⟧ ⟹ ∀m m'. MPoly_Type.coeff (MPoly_Type.coeff (local.fund_sym_poly_wit (p - local.fund_sym_step_poly p)) m) m' ∈ C› ‹∀m. MPoly_Type.coeff p m ∈ C›*)) (*goals: 1. ‹⟦¬ (¬ symmetric_mpoly A p ∨ lead_monom p = 0 ∨ vars p ∩ A = {}); ∀m. MPoly_Type.coeff p m ∈ C; ∀m. MPoly_Type.coeff p m ∈ C; ring_closed C; ⋀C m. ⟦∀m. MPoly_Type.coeff p m ∈ C; ring_closed C⟧ ⟹ MPoly_Type.coeff (local.fund_sym_step_poly p) m ∈ C⟧ ⟹ ¬ (¬ symmetric_mpoly A p ∨ lead_monom p = 0 ∨ vars p ∩ A = {})› 2. ‹⟦¬ (¬ symmetric_mpoly A p ∨ lead_monom p = 0 ∨ vars p ∩ A = {}); ∀m. MPoly_Type.coeff p m ∈ C; ∀m. MPoly_Type.coeff p m ∈ C; ring_closed C; ⋀C m. ⟦∀m. MPoly_Type.coeff p m ∈ C; ring_closed C⟧ ⟹ MPoly_Type.coeff (local.fund_sym_step_poly p) m ∈ C⟧ ⟹ ∀m. MPoly_Type.coeff (p - local.fund_sym_step_poly p) m ∈ C› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . show "?thesis" (*goal: ‹∀m m'. MPoly_Type.coeff (MPoly_Type.coeff (local.fund_sym_poly_wit p) m) m' ∈ C›*) apply (intro allI (*‹(⋀x. ?P x) ⟹ ∀x. ?P x›*)) (*goal: ‹∀m m'. MPoly_Type.coeff (MPoly_Type.coeff (local.fund_sym_poly_wit p) m) m' ∈ C›*) proof (goal_cases) (*goal: ‹⋀m m'. MPoly_Type.coeff (MPoly_Type.coeff (local.fund_sym_poly_wit p) m) m' ∈ C›*) case (1 m m') (*no hyothesis introduced yet*) thus "?case" (*goal: ‹MPoly_Type.coeff (MPoly_Type.coeff (local.fund_sym_poly_wit p) m) m' ∈ C›*) using "*" (*‹∀m m'. MPoly_Type.coeff (MPoly_Type.coeff (local.fund_sym_poly_wit (p - local.fund_sym_step_poly p)) m) m' ∈ C›*) False (*‹¬ (¬ symmetric_mpoly A p ∨ lead_monom p = 0 ∨ vars p ∩ A = {})›*) coeff_fund_sym_step_coeff[of p m'] (*‹MPoly_Type.coeff (local.fund_sym_step_coeff (p::'a mpoly)) (m'::nat ⇒₀ nat) ∈ {Symmetric_Polynomials.lead_coeff p, 0::'a}›*) "1.prems" (*‹∀m. MPoly_Type.coeff p m ∈ C›*) by (auto simp: fund_sym_poly_wit.simps[of p] (*‹local.fund_sym_poly_wit p = (if ¬ symmetric_mpoly A p ∨ lead_monom p = 0 ∨ vars p ∩ A = {} then Const p else local.fund_sym_poly_wit (p - local.fund_sym_step_poly p) + MPoly_Type.monom (local.fund_sym_step_monom p) (local.fund_sym_step_coeff p))›*) coeff_monom (*‹MPoly_Type.coeff (MPoly_Type.monom ?m ?a) ?m' = (?a when ?m' = ?m)›*) lead_coeff_def (*‹Symmetric_Polynomials.lead_coeff ?p = MPoly_Type.coeff ?p (lead_monom ?p)›*) when_def (*‹(?a when ?P) = (if ?P then ?a else 0)›*)) qed qed qed subsection ‹Uniqueness› text ‹ Next, we show that the polynomial representation of a symmetric polynomial in terms of the elementary symmetric polynomials not only exists, but is unique. The key property here is that products of powers of elementary symmetric polynomials uniquely determine the exponent vectors, i.\,e.\ if $e_1, \ldots, e_n$ are the elementary symmetric polynomials, $a = (a_1,\ldots, a_n)$ and $b = (b_1,\ldots,b_n)$ are vectors of natural numbers, then: \[e_1^{a_1}\ldots e_n^{a_n} = e_1^{b_1}\ldots e_n^{b_n} \longleftrightarrow a = b\] We show this now. › lemma lead_monom_sym_mpoly_prod: assumes "finite A" shows "lead_monom (∏i = 1..n. sym_mpoly A i ^ h i :: 'a mpoly) = (∑i = 1..n. of_nat (h i) * lead_monom (sym_mpoly A i :: 'a mpoly))" proof (-) (*goal: ‹lead_monom (∏i = 1..n. sym_mpoly A i ^ h i) = (∑i = 1..n. of_nat (h i) * lead_monom (sym_mpoly A i))›*) have "(∏i=1..n. lead_coeff (sym_mpoly A i ^ h i :: 'a mpoly)) = 1" using assms (*‹finite A›*) unfolding n_def (*goal: ‹(∏i::nat = 1::nat..card A. Symmetric_Polynomials.lead_coeff (sym_mpoly (A::nat set) i ^ (h::nat ⇒ nat) i)) = (1::'a)›*) apply (intro prod.neutral (*‹∀x∈?A. ?g x = 1 ⟹ prod ?g ?A = 1›*) allI (*‹(⋀x. ?P x) ⟹ ∀x. ?P x›*)) (*goal: ‹(∏i = 1..card A. Symmetric_Polynomials.lead_coeff (sym_mpoly A i ^ h i)) = 1›*) by (auto simp: lead_coeff_power (*‹Symmetric_Polynomials.lead_coeff ?p ^ ?n ≠ 0 ⟹ Symmetric_Polynomials.lead_coeff (?p ^ ?n) = Symmetric_Polynomials.lead_coeff ?p ^ ?n›*)) hence "lead_monom (∏i=1..n. sym_mpoly A i ^ h i :: 'a mpoly) = (∑i=1..n. lead_monom (sym_mpoly A i ^ h i :: 'a mpoly))" apply (subst lead_monom_prod (*‹(∏i∈?A. Symmetric_Polynomials.lead_coeff (?f i)) ≠ 0 ⟹ lead_monom (prod ?f ?A) = (∑i∈?A. lead_monom (?f i))›*)) (*goals: 1. ‹(∏i = 1..n. Symmetric_Polynomials.lead_coeff (sym_mpoly A i ^ h i)) = 1 ⟹ (∏i = 1..n. Symmetric_Polynomials.lead_coeff (sym_mpoly A i ^ h i)) ≠ 0› 2. ‹(∏i = 1..n. Symmetric_Polynomials.lead_coeff (sym_mpoly A i ^ h i)) = 1 ⟹ (∑i = 1..n. lead_monom (sym_mpoly A i ^ h i)) = (∑i = 1..n. lead_monom (sym_mpoly A i ^ h i))› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . also (*calculation: ‹lead_monom (∏i = 1..n. sym_mpoly A i ^ h i) = (∑i = 1..n. lead_monom (sym_mpoly A i ^ h i))›*) have "… = (∑i=1..n. of_nat (h i) * lead_monom (sym_mpoly A i :: 'a mpoly))" apply (intro sum.cong (*‹⟦?A = ?B; ⋀x. x ∈ ?B ⟹ ?g x = ?h x⟧ ⟹ sum ?g ?A = sum ?h ?B›*) refl (*‹?t = ?t›*)) (*goal: ‹(∑i = 1..n. lead_monom (sym_mpoly A i ^ h i)) = (∑i = 1..n. of_nat (h i) * lead_monom (sym_mpoly A i))›*) apply (subst lead_monom_power (*‹Symmetric_Polynomials.lead_coeff ?p ^ ?n ≠ 0 ⟹ lead_monom (?p ^ ?n) = of_nat ?n * lead_monom ?p›*)) (*goals: 1. ‹⋀x. x ∈ {1..n} ⟹ Symmetric_Polynomials.lead_coeff (sym_mpoly A x) ^ h x ≠ 0› 2. ‹⋀x. x ∈ {1..n} ⟹ of_nat (h x) * lead_monom (sym_mpoly A x) = of_nat (h x) * lead_monom (sym_mpoly A x)› discuss goal 1*) apply ((auto simp: lead_coeff_power (*‹Symmetric_Polynomials.lead_coeff ?p ^ ?n ≠ 0 ⟹ Symmetric_Polynomials.lead_coeff (?p ^ ?n) = Symmetric_Polynomials.lead_coeff ?p ^ ?n›*) assms (*‹finite A›*) n_def (*‹n ≡ card A›*))[1]) (*discuss goal 2*) apply ((auto simp: lead_coeff_power (*‹Symmetric_Polynomials.lead_coeff ?p ^ ?n ≠ 0 ⟹ Symmetric_Polynomials.lead_coeff (?p ^ ?n) = Symmetric_Polynomials.lead_coeff ?p ^ ?n›*) assms (*‹finite A›*) n_def (*‹n ≡ card A›*))[1]) (*proven 2 subgoals*) . finally (*calculation: ‹lead_monom (∏i = 1..n. sym_mpoly A i ^ h i) = (∑i = 1..n. of_nat (h i) * lead_monom (sym_mpoly A i))›*) show "?thesis" (*goal: ‹lead_monom (∏i = 1..n. sym_mpoly A i ^ h i) = (∑i = 1..n. of_nat (h i) * lead_monom (sym_mpoly A i))›*) . qed lemma lead_monom_sym_mpoly_prod_notin: assumes "finite A" "k ∉ A" shows "lookup (lead_monom (∏i=1..n. sym_mpoly A i ^ h i :: 'a mpoly)) k = 0" sorry lemma lead_monom_sym_mpoly_prod_in: assumes "finite A" "k < n" shows "lookup (lead_monom (∏i=1..n. sym_mpoly A i ^ h i :: 'a mpoly)) (xs ! k) = (∑i=k+1..n. h i)" proof (-) (*goal: ‹lookup (lead_monom (∏i = 1..n. sym_mpoly A i ^ h i)) (xs ! k) = sum h {k + 1..n}›*) have xs: "set xs = A" "distinct xs" "sorted xs" and [simp]: "length xs = n" using assms (*‹finite (A::nat set)› ‹k < n›*) apply - (*goals: 1. ‹⟦finite (A::nat set); (k::nat) < (n::nat)⟧ ⟹ set (xs::nat list) = A› 2. ‹⟦finite (A::nat set); (k::nat) < (n::nat)⟧ ⟹ distinct (xs::nat list)› 3. ‹⟦finite (A::nat set); (k::nat) < (n::nat)⟧ ⟹ sorted (xs::nat list)› 4. ‹⟦finite (A::nat set); (k::nat) < (n::nat)⟧ ⟹ length (xs::nat list) = n› discuss goal 1*) apply ((auto simp: xs_def (*‹xs ≡ sorted_list_of_set A›*) n_def (*‹n ≡ card A›*))[1]) (*discuss goal 2*) apply ((auto simp: xs_def (*‹xs ≡ sorted_list_of_set A›*) n_def (*‹n ≡ card A›*))[1]) (*discuss goal 3*) apply ((auto simp: xs_def (*‹xs ≡ sorted_list_of_set A›*) n_def (*‹n ≡ card A›*))[1]) (*discuss goal 4*) apply ((auto simp: xs_def (*‹xs ≡ sorted_list_of_set A›*) n_def (*‹n ≡ card A›*))[1]) (*proven 4 subgoals*) . have "lead_monom (∏i = 1..n. sym_mpoly A i ^ h i :: 'a mpoly) = (∑i = 1..n. of_nat (h i) * lead_monom (sym_mpoly (set xs) i :: 'a mpoly))" apply (subst lead_monom_sym_mpoly_prod (*‹finite (A::nat set) ⟹ lead_monom (∏i::nat = 1::nat..n::nat. sym_mpoly A i ^ (?h::nat ⇒ nat) i) = (∑i::nat = 1::nat..n. of_nat (?h i) * lead_monom (sym_mpoly A i))›*)) (*goals: 1. ‹finite (A::nat set)› 2. ‹(∑i::nat = 1::nat..n::nat. of_nat ((h::nat ⇒ nat) i) * lead_monom (sym_mpoly (A::nat set) i)) = (∑i::nat = 1::nat..n. of_nat (h i) * lead_monom (sym_mpoly (set (xs::nat list)) i))› discuss goal 1*) apply ((use xs assms in simp_all)[1]) (*discuss goal 2*) apply ((use xs assms in simp_all)[1]) (*proven 2 subgoals*) . also (*calculation: ‹lead_monom (∏i = 1..n. sym_mpoly A i ^ h i) = (∑i = 1..n. of_nat (h i) * lead_monom (sym_mpoly (set xs) i))›*) have "… = (∑i=1..n. of_nat (h i) * monom_of_set (set (take i xs)))" using xs (*‹set (xs::nat list) = (A::nat set)› ‹distinct xs› ‹sorted xs›*) apply (intro sum.cong (*‹⟦?A = ?B; ⋀x. x ∈ ?B ⟹ ?g x = ?h x⟧ ⟹ sum ?g ?A = sum ?h ?B›*) refl (*‹?t = ?t›*)) (*goal: ‹(∑i = 1..n. of_nat (h i) * lead_monom (sym_mpoly (set xs) i)) = (∑i = 1..n. of_nat (h i) * monom_of_set (set (take i xs)))›*) apply (subst lead_monom_sym_mpoly (*‹⟦sorted ?xs; distinct ?xs; ?k ≤ length ?xs⟧ ⟹ lead_monom (sym_mpoly (set ?xs) ?k) = monom_of_set (set (take ?k ?xs))›*)) (*goals: 1. ‹⋀x::nat. ⟦set (xs::nat list) = (A::nat set); distinct xs; sorted xs; x ∈ {1::nat..n::nat}⟧ ⟹ sorted xs› 2. ‹⋀x::nat. ⟦set (xs::nat list) = (A::nat set); distinct xs; sorted xs; x ∈ {1::nat..n::nat}⟧ ⟹ distinct xs› 3. ‹⋀x::nat. ⟦set (xs::nat list) = (A::nat set); distinct xs; sorted xs; x ∈ {1::nat..n::nat}⟧ ⟹ x ≤ length xs› 4. ‹⋀x::nat. ⟦set (xs::nat list) = (A::nat set); distinct xs; sorted xs; x ∈ {1::nat..n::nat}⟧ ⟹ of_nat ((h::nat ⇒ nat) x) * monom_of_set (set (take x xs)) = of_nat (h x) * monom_of_set (set (take x xs))› 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*) . also (*calculation: ‹lead_monom (∏i = 1..n. sym_mpoly A i ^ h i) = (∑i = 1..n. of_nat (h i) * monom_of_set (set (take i xs)))›*) have "lookup … (xs ! k) = (∑i | i ∈ {1..n} ∧ xs ! k ∈ set (take i xs). h i)" unfolding lookup_sum lookup_monom_of_set (*goal: ‹(∑x::nat = 1::nat..n::nat. lookup (of_nat ((h::nat ⇒ nat) x) * monom_of_set (set (take x (xs::nat list)))) (xs ! (k::nat))) = (∑i::nat | i ∈ {1::nat..n} ∧ xs ! k ∈ set (take i xs). h i)›*) apply (intro sum.mono_neutral_cong_right (*‹⟦finite (?T::?'b::type set); (?S::?'b::type set) ⊆ ?T; ∀i::?'b::type∈?T - ?S. (?g::?'b::type ⇒ ?'a::comm_monoid_add) i = (0::?'a::comm_monoid_add); ⋀x::?'b::type. x ∈ ?S ⟹ ?g x = (?h::?'b::type ⇒ ?'a::comm_monoid_add) x⟧ ⟹ sum ?g ?T = sum ?h ?S›*)) (*goals: 1. ‹finite {1::nat..n::nat}› 2. ‹{i::nat ∈ {1::nat..n::nat}. (xs::nat list) ! (k::nat) ∈ set (take i xs)} ⊆ {1::nat..n}› 3. ‹∀i::nat∈{1::nat..n::nat} - {i::nat ∈ {1::nat..n}. (xs::nat list) ! (k::nat) ∈ set (take i xs)}. lookup (of_nat ((h::nat ⇒ nat) i) * monom_of_set (set (take i xs))) (xs ! k) = (0::nat)› 4. ‹⋀x::nat. x ∈ {i::nat ∈ {1::nat..n::nat}. (xs::nat list) ! (k::nat) ∈ set (take i xs)} ⟹ lookup (of_nat ((h::nat ⇒ nat) x) * monom_of_set (set (take x xs))) (xs ! k) = h 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]) (*proven 4 subgoals*) . also (*calculation: ‹lookup (lead_monom (∏i = 1..n. sym_mpoly A i ^ h i)) (xs ! k) = (∑i | i ∈ {1..n} ∧ xs ! k ∈ set (take i xs). h i)›*) have "{i. i ∈ {1..n} ∧ xs ! k ∈ set (take i xs)} = {k+1..n}" proof (intro equalityI (*‹⟦?A ⊆ ?B; ?B ⊆ ?A⟧ ⟹ ?A = ?B›*) subsetI (*‹(⋀x. x ∈ ?A ⟹ x ∈ ?B) ⟹ ?A ⊆ ?B›*)) (*goals: 1. ‹⋀x::nat. x ∈ {i::nat ∈ {1::nat..n::nat}. (xs::nat list) ! (k::nat) ∈ set (take i xs)} ⟹ x ∈ {k + (1::nat)..n}› 2. ‹⋀x::nat. x ∈ {(k::nat) + (1::nat)..n::nat} ⟹ x ∈ {i::nat ∈ {1::nat..n}. (xs::nat list) ! k ∈ set (take i xs)}›*) fix i assume i: "i ∈ {k+1..n}" (*‹(i::nat) ∈ {(k::nat) + (1::nat)..n::nat}›*) hence "take i xs ! k = xs ! k" "k < n" "k < i" using assms (*‹finite A› ‹(k::nat) < (n::nat)›*) apply - (*goals: 1. ‹⟦(i::nat) ∈ {(k::nat) + (1::nat)..n::nat}; finite (A::nat set); k < n⟧ ⟹ take i (xs::nat list) ! k = xs ! k› 2. ‹⟦(i::nat) ∈ {(k::nat) + (1::nat)..n::nat}; finite (A::nat set); k < n⟧ ⟹ k < n› 3. ‹⟦(i::nat) ∈ {(k::nat) + (1::nat)..n::nat}; finite (A::nat set); k < n⟧ ⟹ k < i› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*proven 3 subgoals*) . with i (*‹i ∈ {k + 1..n}›*) show "i ∈ {i. i ∈ {1..n} ∧ xs ! k ∈ set (take i xs)}" by (force simp: set_conv_nth (*‹set (?xs::?'a list) = {?xs ! i |i::nat. i < length ?xs}›*)) qed (insert assms (*‹finite A› ‹k < n›*) xs (*‹set xs = A› ‹distinct xs› ‹sorted xs›*), auto simp: set_conv_nth (*‹set ?xs = {?xs ! i |i. i < length ?xs}›*) Suc_le_eq (*‹(Suc ?m ≤ ?n) = (?m < ?n)›*) nth_eq_iff_index_eq (*‹⟦distinct ?xs; ?i < length ?xs; ?j < length ?xs⟧ ⟹ (?xs ! ?i = ?xs ! ?j) = (?i = ?j)›*)) (*solved the remaining goal: ‹⋀x. x ∈ {i ∈ {1..n}. xs ! k ∈ set (take i xs)} ⟹ x ∈ {k + 1..n}›*) finally (*calculation: ‹lookup (lead_monom (∏i = 1..n. sym_mpoly A i ^ h i)) (xs ! k) = sum h {k + 1..n}›*) show "?thesis" (*goal: ‹lookup (lead_monom (∏i = 1..n. sym_mpoly A i ^ h i)) (xs ! k) = sum h {k + 1..n}›*) . qed lemma lead_monom_sym_poly_powerprod_inj: assumes "lead_monom (∏i. sym_mpoly A i ^ lookup m1 i :: 'a mpoly) = lead_monom (∏i. sym_mpoly A i ^ lookup m2 i :: 'a mpoly)" assumes "finite A" "keys m1 ⊆ {1..n}" "keys m2 ⊆ {1..n}" shows "m1 = m2" proof (rule poly_mapping_eqI (*‹(⋀k. lookup ?f k = lookup ?g k) ⟹ ?f = ?g›*)) (*goal: ‹⋀k. lookup m1 k = lookup m2 k›*) fix k :: nat have xs: "set xs = A" "distinct xs" "sorted xs" and [simp]: "length xs = n" using assms (*‹lead_monom (∏i. sym_mpoly A i ^ lookup m1 i) = lead_monom (∏i. sym_mpoly A i ^ lookup m2 i)› ‹finite (A::nat set)› ‹keys (m1::nat ⇒₀ nat) ⊆ {1::nat..n::nat}› ‹keys m2 ⊆ {1..n}›*) apply - (*goals: 1. ‹⟦lead_monom (∏i. sym_mpoly A i ^ lookup m1 i) = lead_monom (∏i. sym_mpoly A i ^ lookup m2 i); finite A; keys m1 ⊆ {1..n}; keys m2 ⊆ {1..n}⟧ ⟹ set xs = A› 2. ‹⟦lead_monom (∏i. sym_mpoly A i ^ lookup m1 i) = lead_monom (∏i. sym_mpoly A i ^ lookup m2 i); finite A; keys m1 ⊆ {1..n}; keys m2 ⊆ {1..n}⟧ ⟹ distinct xs› 3. ‹⟦lead_monom (∏i. sym_mpoly A i ^ lookup m1 i) = lead_monom (∏i. sym_mpoly A i ^ lookup m2 i); finite A; keys m1 ⊆ {1..n}; keys m2 ⊆ {1..n}⟧ ⟹ sorted xs› 4. ‹⟦lead_monom (∏i. sym_mpoly A i ^ lookup m1 i) = lead_monom (∏i. sym_mpoly A i ^ lookup m2 i); finite A; keys m1 ⊆ {1..n}; keys m2 ⊆ {1..n}⟧ ⟹ length xs = n› discuss goal 1*) apply ((auto simp: xs_def (*‹xs ≡ sorted_list_of_set A›*) n_def (*‹n ≡ card A›*))[1]) (*discuss goal 2*) apply ((auto simp: xs_def (*‹xs ≡ sorted_list_of_set A›*) n_def (*‹n ≡ card A›*))[1]) (*discuss goal 3*) apply ((auto simp: xs_def (*‹xs ≡ sorted_list_of_set A›*) n_def (*‹n ≡ card A›*))[1]) (*discuss goal 4*) apply ((auto simp: xs_def (*‹xs ≡ sorted_list_of_set A›*) n_def (*‹n ≡ card A›*))[1]) (*proven 4 subgoals*) . from assms(3,4) (*‹keys m1 ⊆ {1..n}› ‹keys m2 ⊆ {1..n}›*) have "*": "i ∈ {1..n}" if "lookup m1 i ≠ 0 ∨ lookup m2 i ≠ 0" for i using that (*‹lookup m1 i ≠ 0 ∨ lookup m2 i ≠ 0›*) by (auto simp: subset_iff (*‹(?A ⊆ ?B) = (∀t. t ∈ ?A ⟶ t ∈ ?B)›*) in_keys_iff (*‹(?x ∈ keys ?s) = (lookup ?s ?x ≠ 0)›*)) have "**": "(∏i. sym_mpoly A i ^ lookup m i :: 'a mpoly) = (∏i=1..n. sym_mpoly A i ^ lookup m i :: 'a mpoly)" if "m ∈ {m1, m2}" for m using that (*‹m ∈ {m1, m2}›*) "*" (*‹lookup m1 ?i ≠ 0 ∨ lookup m2 ?i ≠ 0 ⟹ ?i ∈ {1..n}›*) apply (intro Prod_any.expand_superset (*‹⟦finite ?A; {a. ?g a ≠ 1} ⊆ ?A⟧ ⟹ Prod_any ?g = prod ?g ?A›*) subsetI (*‹(⋀x. x ∈ ?A ⟹ x ∈ ?B) ⟹ ?A ⊆ ?B›*) * (*‹lookup m1 ?i ≠ 0 ∨ lookup m2 ?i ≠ 0 ⟹ ?i ∈ {1..n}›*)) (*goals: 1. ‹⟦m ∈ {m1, m2}; ⋀i. lookup m1 i ≠ 0 ∨ lookup m2 i ≠ 0 ⟹ i ∈ {1..n}⟧ ⟹ finite {1..n}› 2. ‹⋀x. ⟦m ∈ {m1, m2}; ⋀i. lookup m1 i ≠ 0 ∨ lookup m2 i ≠ 0 ⟹ i ∈ {1..n}; x ∈ {a. sym_mpoly A a ^ lookup m a ≠ 1}⟧ ⟹ lookup m1 x ≠ 0 ∨ lookup m2 x ≠ 0› discuss goal 1*) apply ((auto intro!: Nat.gr0I (*‹(?n = 0 ⟹ False) ⟹ 0 < ?n›*))[1]) (*discuss goal 2*) apply ((auto intro!: Nat.gr0I (*‹(?n = 0 ⟹ False) ⟹ 0 < ?n›*))[1]) (*proven 2 subgoals*) . have "***": "lead_monom (∏i=1..n. sym_mpoly A i ^ lookup m1 i :: 'a mpoly) = lead_monom (∏i=1..n. sym_mpoly A i ^ lookup m2 i :: 'a mpoly)" using assms (*‹lead_monom (∏i. sym_mpoly A i ^ lookup m1 i) = lead_monom (∏i. sym_mpoly A i ^ lookup m2 i)› ‹finite A› ‹keys m1 ⊆ {1..n}› ‹keys (m2::nat ⇒₀ nat) ⊆ {1::nat..n::nat}›*) by (simp add: ** (*‹?m ∈ {m1, m2} ⟹ (∏i. sym_mpoly A i ^ lookup ?m i) = (∏i = 1..n. sym_mpoly A i ^ lookup ?m i)›*)) have sum_eq: "sum (lookup m1) {Suc k..n} = sum (lookup m2) {Suc k..n}" if "k < n" for k using arg_cong[OF ***, of "λm. lookup m (xs ! k)"] (*‹lookup (lead_monom (∏i = 1..n. sym_mpoly A i ^ lookup m1 i)) (xs ! k) = lookup (lead_monom (∏i = 1..n. sym_mpoly A i ^ lookup m2 i)) (xs ! k)›*) ‹finite A› (*‹finite A›*) that (*‹k < n›*) apply (subst (asm) (1 2) lead_monom_sym_mpoly_prod_in (*‹⟦finite (A::nat set); (?k::nat) < (n::nat)⟧ ⟹ lookup (lead_monom (∏i::nat = 1::nat..n. sym_mpoly A i ^ (?h::nat ⇒ nat) i)) ((xs::nat list) ! ?k) = sum ?h {?k + (1::nat)..n}›*)) (*goals: 1. ‹⟦finite A; k < n⟧ ⟹ finite A› 2. ‹⟦finite A; k < n⟧ ⟹ k < n› 3. ‹⟦sum (lookup m1) {k + 1..n} = sum (lookup m2) {k + 1..n}; finite A; k < n⟧ ⟹ sum (lookup m1) {Suc k..n} = sum (lookup m2) {Suc k..n}› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*proven 3 subgoals*) . show "lookup m1 k = lookup m2 k" proof (cases "k ∈ {1..n}") (*goals: 1. ‹(k::nat) ∈ {1::nat..n::nat} ⟹ lookup (m1::nat ⇒₀ nat) k = lookup (m2::nat ⇒₀ nat) k› 2. ‹(k::nat) ∉ {1::nat..n::nat} ⟹ lookup (m1::nat ⇒₀ nat) k = lookup (m2::nat ⇒₀ nat) k›*) case False (*‹(k::nat) ∉ {1::nat..n::nat}›*) hence "lookup m1 k = 0" "lookup m2 k = 0" using assms (*‹lead_monom (∏i. sym_mpoly A i ^ lookup m1 i) = lead_monom (∏i. sym_mpoly A i ^ lookup m2 i)› ‹finite (A::nat set)› ‹keys m1 ⊆ {1..n}› ‹keys m2 ⊆ {1..n}›*) apply - (*goals: 1. ‹⟦k ∉ {1..n}; lead_monom (∏i. sym_mpoly A i ^ lookup m1 i) = lead_monom (∏i. sym_mpoly A i ^ lookup m2 i); finite A; keys m1 ⊆ {1..n}; keys m2 ⊆ {1..n}⟧ ⟹ lookup m1 k = 0› 2. ‹⟦k ∉ {1..n}; lead_monom (∏i. sym_mpoly A i ^ lookup m1 i) = lead_monom (∏i. sym_mpoly A i ^ lookup m2 i); finite A; keys m1 ⊆ {1..n}; keys m2 ⊆ {1..n}⟧ ⟹ lookup m2 k = 0› discuss goal 1*) apply ((auto simp: in_keys_iff (*‹(?x ∈ keys ?s) = (lookup ?s ?x ≠ 0)›*))[1]) (*discuss goal 2*) apply ((auto simp: in_keys_iff (*‹((?x::?'a) ∈ keys (?s::?'a ⇒₀ ?'b)) = (lookup ?s ?x ≠ (0::?'b))›*))[1]) (*proven 2 subgoals*) . thus "?thesis" (*goal: ‹lookup m1 k = lookup m2 k›*) by simp next (*goal: ‹k ∈ {1..n} ⟹ lookup m1 k = lookup m2 k›*) case True (*‹k ∈ {1..n}›*) thus "?thesis" (*goal: ‹lookup m1 k = lookup m2 k›*) proof (induction "n - k" arbitrary: k rule: less_induct) (*goal: ‹⋀k. ⟦⋀ka. ⟦n - ka < n - k; ka ∈ {1..n}⟧ ⟹ lookup m1 ka = lookup m2 ka; k ∈ {1..n}⟧ ⟹ lookup m1 k = lookup m2 k›*) case (less l) (*‹⟦n - ?k < n - l; ?k ∈ {1..n}⟧ ⟹ lookup m1 ?k = lookup m2 ?k› ‹l ∈ {1..n}›*) have "sum (lookup m1) {Suc (l - 1)..n} = sum (lookup m2) {Suc (l - 1)..n}" using less (*‹⟦n - ?k < n - l; ?k ∈ {1..n}⟧ ⟹ lookup m1 ?k = lookup m2 ?k› ‹l ∈ {1..n}›*) apply (intro sum_eq (*‹(?k::nat) < (n::nat) ⟹ sum (lookup (m1::nat ⇒₀ nat)) {Suc ?k..n} = sum (lookup (m2::nat ⇒₀ nat)) {Suc ?k..n}›*)) (*goal: ‹sum (lookup m1) {Suc (l - 1)..n} = sum (lookup m2) {Suc (l - 1)..n}›*) by auto also (*calculation: ‹sum (lookup m1) {Suc (l - 1)..n} = sum (lookup m2) {Suc (l - 1)..n}›*) have "{Suc (l - 1)..n} = insert l {Suc l..n}" using less (*‹⟦n - ?k < n - l; ?k ∈ {1..n}⟧ ⟹ lookup m1 ?k = lookup m2 ?k› ‹l ∈ {1..n}›*) by auto also (*calculation: ‹sum (lookup m1) (insert l {Suc l..n}) = sum (lookup m2) (insert l {Suc l..n})›*) have "sum (lookup m1) … = lookup m1 l + (∑i=Suc l..n. lookup m1 i)" apply (subst sum.insert (*‹⟦finite ?A; ?x ∉ ?A⟧ ⟹ sum ?g (insert ?x ?A) = ?g ?x + sum ?g ?A›*)) (*goals: 1. ‹finite {Suc (l::nat)..n::nat}› 2. ‹(l::nat) ∉ {Suc l..n::nat}› 3. ‹lookup (m1::nat ⇒₀ nat) (l::nat) + sum (lookup m1) {Suc l..n::nat} = lookup m1 l + sum (lookup m1) {Suc l..n}› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*proven 3 subgoals*) . also (*calculation: ‹lookup m1 l + sum (lookup m1) {Suc l..n} = sum (lookup m2) (insert l {Suc l..n})›*) have "(∑i=Suc l..n. lookup m1 i) = (∑i=Suc l..n. lookup m2 i)" apply (intro sum.cong (*‹⟦?A = ?B; ⋀x. x ∈ ?B ⟹ ?g x = ?h x⟧ ⟹ sum ?g ?A = sum ?h ?B›*) less (*‹⟦n - ?k < n - l; ?k ∈ {1..n}⟧ ⟹ lookup m1 ?k = lookup m2 ?k› ‹l ∈ {1..n}›*)) (*goals: 1. ‹{Suc l..n} = {Suc l..n}› 2. ‹⋀x. x ∈ {Suc l..n} ⟹ n - x < n - l› 3. ‹⋀x. x ∈ {Suc l..n} ⟹ x ∈ {1..n}› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*proven 3 subgoals*) . also (*calculation: ‹lookup m1 l + sum (lookup m2) {Suc l..n} = sum (lookup m2) (insert l {Suc l..n})›*) have "sum (lookup m2) (insert l {Suc l..n}) = lookup m2 l + (∑i=Suc l..n. lookup m2 i)" apply (subst sum.insert (*‹⟦finite (?A::?'b set); (?x::?'b) ∉ ?A⟧ ⟹ sum (?g::?'b ⇒ ?'a) (insert ?x ?A) = ?g ?x + sum ?g ?A›*)) (*goals: 1. ‹finite {Suc l..n}› 2. ‹l ∉ {Suc l..n}› 3. ‹lookup m2 l + sum (lookup m2) {Suc l..n} = lookup m2 l + sum (lookup m2) {Suc l..n}› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*proven 3 subgoals*) . finally (*calculation: ‹lookup m1 l + sum (lookup m2) {Suc l..n} = lookup m2 l + sum (lookup m2) {Suc l..n}›*) show "lookup m1 l = lookup m2 l" by simp qed qed qed text ‹ We now show uniqueness by first showing that the zero polynomial has a unique representation. We fix some polynomial $p$ with $p(e_1,\ldots, e_n) = 0$ and then show, by contradiction, that $p = 0$. We have \[p(e_1,\ldots,e_n) = \sum c_{a_1,\ldots,a_n} e_1^{a_1}\ldots e_n^{a_n}\] and due to the injectivity of products of powers of elementary symmetric polynomials, the leading term of that sum is precisely the leading term of the summand with the biggest leading monomial, since summands cannot cancel each other. However, we also know that $p(e_1,\ldots,e_n) = 0$, so it follows that all summands must have leading term 0, and it is then easy to see that they must all be identically 0. › lemma sym_mpoly_representation_unique_aux: fixes p :: "'a mpoly mpoly" assumes "finite A" "insertion (sym_mpoly A) p = 0" "⋀m. vars (coeff p m) ∩ A = {}" "vars p ⊆ {1..n}" shows "p = 0" proof (rule ccontr (*‹(¬ ?P ⟹ False) ⟹ ?P›*)) (*goal: ‹p ≠ 0 ⟹ False›*) assume p: "p ≠ 0" (*‹(p::'a mpoly mpoly) ≠ (0::'a mpoly mpoly)›*) have xs: "set xs = A" "distinct xs" "sorted xs" and [simp]: "length xs = n" using assms (*‹finite A› ‹insertion (sym_mpoly A) p = 0› ‹vars (MPoly_Type.coeff p ?m) ∩ A = {}› ‹vars p ⊆ {1..n}›*) apply - (*goals: 1. ‹⟦finite (A::nat set); insertion (sym_mpoly A) (p::'a mpoly mpoly) = (0::'a mpoly); ⋀m::nat ⇒₀ nat. vars (MPoly_Type.coeff p m) ∩ A = {}; vars p ⊆ {1::nat..n::nat}⟧ ⟹ set (xs::nat list) = A› 2. ‹⟦finite (A::nat set); insertion (sym_mpoly A) (p::'a mpoly mpoly) = (0::'a mpoly); ⋀m::nat ⇒₀ nat. vars (MPoly_Type.coeff p m) ∩ A = {}; vars p ⊆ {1::nat..n::nat}⟧ ⟹ distinct (xs::nat list)› 3. ‹⟦finite (A::nat set); insertion (sym_mpoly A) (p::'a mpoly mpoly) = (0::'a mpoly); ⋀m::nat ⇒₀ nat. vars (MPoly_Type.coeff p m) ∩ A = {}; vars p ⊆ {1::nat..n::nat}⟧ ⟹ sorted (xs::nat list)› 4. ‹⟦finite (A::nat set); insertion (sym_mpoly A) (p::'a mpoly mpoly) = (0::'a mpoly); ⋀m::nat ⇒₀ nat. vars (MPoly_Type.coeff p m) ∩ A = {}; vars p ⊆ {1::nat..n::nat}⟧ ⟹ length (xs::nat list) = n› discuss goal 1*) apply ((auto simp: xs_def (*‹xs ≡ sorted_list_of_set A›*) n_def (*‹n ≡ card A›*))[1]) (*discuss goal 2*) apply ((auto simp: xs_def (*‹xs ≡ sorted_list_of_set A›*) n_def (*‹n ≡ card A›*))[1]) (*discuss goal 3*) apply ((auto simp: xs_def (*‹xs ≡ sorted_list_of_set A›*) n_def (*‹n ≡ card A›*))[1]) (*discuss goal 4*) apply ((auto simp: xs_def (*‹xs::nat list ≡ sorted_list_of_set (A::nat set)›*) n_def (*‹n::nat ≡ card (A::nat set)›*))[1]) (*proven 4 subgoals*) . define h where "h = (λm. coeff p m * (∏i. sym_mpoly A i ^ lookup m i))" define M where "M = {m. coeff p m ≠ 0}" define maxm where "maxm = Max ((lead_monom ∘ h) ` M)" have "finite M" by (auto intro!: finite_subset[OF _ finite_coeff_support[of p]] (*‹?A ⊆ {m. MPoly_Type.coeff p m ≠ 0} ⟹ finite ?A›*) simp: h_def (*‹h = (λm. MPoly_Type.coeff p m * (∏i. sym_mpoly A i ^ lookup m i))›*) M_def (*‹M = {m. MPoly_Type.coeff p m ≠ 0}›*)) have keys_subset: "keys m ⊆ {1..n}" if "coeff p m ≠ 0" for m using that (*‹MPoly_Type.coeff p m ≠ 0›*) assms (*‹finite (A::nat set)› ‹insertion (sym_mpoly (A::nat set)) (p::'a mpoly mpoly) = (0::'a mpoly)› ‹vars (MPoly_Type.coeff p ?m) ∩ A = {}› ‹vars p ⊆ {1..n}›*) coeff_notin_vars[of m p] (*‹¬ keys m ⊆ vars p ⟹ MPoly_Type.coeff p m = 0›*) by blast have lead_coeff: "lead_coeff (h m) = lead_coeff (coeff p m)" (is "?th1") and lead_monom: "lead_monom (h m) = lead_monom (coeff p m) + lead_monom (∏i. sym_mpoly A i ^ lookup m i :: 'a mpoly)" (is "?th2") if [simp]: "coeff p m ≠ 0" for m proof (-) (*goals: 1. ‹Symmetric_Polynomials.lead_coeff (h m) = Symmetric_Polynomials.lead_coeff (MPoly_Type.coeff p m)› 2. ‹lead_monom (h m) = lead_monom (MPoly_Type.coeff p m) + lead_monom (∏i. sym_mpoly A i ^ lookup m i)›*) have "(∏i. sym_mpoly A i ^ lookup m i :: 'a mpoly) = (∏i | lookup m i ≠ 0. sym_mpoly A i ^ lookup m i :: 'a mpoly)" apply (intro Prod_any.expand_superset (*‹⟦finite (?A::?'b set); {a::?'b. (?g::?'b ⇒ ?'a) a ≠ (1::?'a)} ⊆ ?A⟧ ⟹ Prod_any ?g = prod ?g ?A›*)) (*goals: 1. ‹finite {i::nat. lookup (m::nat ⇒₀ nat) i ≠ (0::nat)}› 2. ‹{a::nat. sym_mpoly (A::nat set) a ^ lookup (m::nat ⇒₀ nat) a ≠ (1::'a mpoly)} ⊆ {i::nat. lookup m i ≠ (0::nat)}› discuss goal 1*) apply ((auto intro!: Nat.gr0I (*‹(?n = 0 ⟹ False) ⟹ 0 < ?n›*))[1]) (*discuss goal 2*) apply ((auto intro!: Nat.gr0I (*‹(?n = 0 ⟹ False) ⟹ 0 < ?n›*))[1]) (*proven 2 subgoals*) . also (*calculation: ‹(∏i. sym_mpoly A i ^ lookup m i) = (∏i∈{i. lookup m i ≠ 0}. sym_mpoly A i ^ lookup m i)›*) have "lead_coeff … = 1" using assms (*‹finite A› ‹insertion (sym_mpoly (A::nat set)) (p::'a::comm_ring_1 mpoly mpoly) = (0::'a::comm_ring_1 mpoly)› ‹vars (MPoly_Type.coeff p ?m) ∩ A = {}› ‹vars (p::'a mpoly mpoly) ⊆ {1::nat..n::nat}›*) keys_subset[of m] (*‹MPoly_Type.coeff (p::'a::comm_ring_1 mpoly mpoly) (m::nat ⇒₀ nat) ≠ (0::'a::comm_ring_1 mpoly) ⟹ keys m ⊆ {1::nat..n::nat}›*) apply (intro lead_coeff_sym_mpoly_powerprod (*‹⟦finite ?A; ⋀x. x ∈ ?X ⟹ ?f x ∈ {1..card ?A}⟧ ⟹ Symmetric_Polynomials.lead_coeff (∏x∈?X. sym_mpoly ?A (?f x) ^ ?g x) = 1›*)) (*goals: 1. ‹⟦finite A; insertion (sym_mpoly A) p = 0; ⋀m. vars (MPoly_Type.coeff p m) ∩ A = {}; vars p ⊆ {1..n}; MPoly_Type.coeff p m ≠ 0 ⟹ keys m ⊆ {1..n}⟧ ⟹ finite A› 2. ‹⋀i. ⟦finite A; insertion (sym_mpoly A) p = 0; ⋀m. vars (MPoly_Type.coeff p m) ∩ A = {}; vars p ⊆ {1..n}; MPoly_Type.coeff p m ≠ 0 ⟹ keys m ⊆ {1..n}; i ∈ {i. lookup m i ≠ 0}⟧ ⟹ i ∈ {1..card A}› discuss goal 1*) apply ((auto simp: in_keys_iff (*‹((?x::?'a) ∈ keys (?s::?'a ⇒₀ ?'b)) = (lookup ?s ?x ≠ (0::?'b))›*) subset_iff (*‹((?A::?'a set) ⊆ (?B::?'a set)) = (∀t::?'a. t ∈ ?A ⟶ t ∈ ?B)›*) n_def (*‹n::nat ≡ card (A::nat set)›*))[1]) (*discuss goal 2*) apply ((auto simp: in_keys_iff (*‹(?x ∈ keys ?s) = (lookup ?s ?x ≠ 0)›*) subset_iff (*‹(?A ⊆ ?B) = (∀t. t ∈ ?A ⟶ t ∈ ?B)›*) n_def (*‹n ≡ card A›*))[1]) (*proven 2 subgoals*) . finally (*calculation: ‹Symmetric_Polynomials.lead_coeff (∏i. sym_mpoly A i ^ lookup m i) = 1›*) have eq: "lead_coeff (∏i. sym_mpoly A i ^ lookup m i :: 'a mpoly) = 1" . thus "?th1" unfolding h_def (*goal: ‹Symmetric_Polynomials.lead_coeff (MPoly_Type.coeff p m * (∏i. sym_mpoly A i ^ lookup m i)) = Symmetric_Polynomials.lead_coeff (MPoly_Type.coeff p m)›*) using ‹coeff p m ≠ 0› (*‹MPoly_Type.coeff p m ≠ 0›*) apply (subst lead_coeff_mult (*‹Symmetric_Polynomials.lead_coeff ?p * Symmetric_Polynomials.lead_coeff ?q ≠ 0 ⟹ Symmetric_Polynomials.lead_coeff (?p * ?q) = Symmetric_Polynomials.lead_coeff ?p * Symmetric_Polynomials.lead_coeff ?q›*)) (*goals: 1. ‹⟦Symmetric_Polynomials.lead_coeff (∏i. sym_mpoly A i ^ lookup m i) = 1; MPoly_Type.coeff p m ≠ 0⟧ ⟹ Symmetric_Polynomials.lead_coeff (MPoly_Type.coeff p m) * Symmetric_Polynomials.lead_coeff (∏i. sym_mpoly A i ^ lookup m i) ≠ 0› 2. ‹⟦Symmetric_Polynomials.lead_coeff (∏i. sym_mpoly A i ^ lookup m i) = 1; MPoly_Type.coeff p m ≠ 0⟧ ⟹ Symmetric_Polynomials.lead_coeff (MPoly_Type.coeff p m) * Symmetric_Polynomials.lead_coeff (∏i. sym_mpoly A i ^ lookup m i) = Symmetric_Polynomials.lead_coeff (MPoly_Type.coeff p m)› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . show "?th2" unfolding h_def (*goal: ‹lead_monom (MPoly_Type.coeff p m * (∏i. sym_mpoly A i ^ lookup m i)) = lead_monom (MPoly_Type.coeff p m) + lead_monom (∏i. sym_mpoly A i ^ lookup m i)›*) apply (subst lead_monom_mult (*‹Symmetric_Polynomials.lead_coeff ?p * Symmetric_Polynomials.lead_coeff ?q ≠ 0 ⟹ lead_monom (?p * ?q) = lead_monom ?p + lead_monom ?q›*)) (*goals: 1. ‹Symmetric_Polynomials.lead_coeff (MPoly_Type.coeff (p::'a::comm_ring_1 mpoly mpoly) (m::nat ⇒₀ nat)) * Symmetric_Polynomials.lead_coeff (∏i::nat. sym_mpoly (A::nat set) i ^ lookup m i) ≠ (0::'a::comm_ring_1)› 2. ‹lead_monom (MPoly_Type.coeff (p::'a::comm_ring_1 mpoly mpoly) (m::nat ⇒₀ nat)) + lead_monom (∏i::nat. sym_mpoly (A::nat set) i ^ lookup m i) = lead_monom (MPoly_Type.coeff p m) + lead_monom (∏i::nat. sym_mpoly A i ^ lookup m i)› discuss goal 1*) apply ((auto simp: eq (*‹Symmetric_Polynomials.lead_coeff (∏i. sym_mpoly A i ^ lookup m i) = 1›*))[1]) (*discuss goal 2*) apply ((auto simp: eq (*‹Symmetric_Polynomials.lead_coeff (∏i. sym_mpoly A i ^ lookup m i) = 1›*))[1]) (*proven 2 subgoals*) . qed have "insertion (sym_mpoly A) p = (∑m∈M. h m)" unfolding insertion_altdef h_def M_def (*goal: ‹(∑m. MPoly_Type.coeff p m * (∏i. sym_mpoly A i ^ lookup m i)) = (∑m | MPoly_Type.coeff p m ≠ 0. MPoly_Type.coeff p m * (∏i. sym_mpoly A i ^ lookup m i))›*) apply (intro Sum_any.expand_superset (*‹⟦finite ?A; {a. ?g a ≠ 0} ⊆ ?A⟧ ⟹ Sum_any ?g = sum ?g ?A›*)) (*goals: 1. ‹finite {m. MPoly_Type.coeff p m ≠ 0}› 2. ‹{a. MPoly_Type.coeff p a * (∏i. sym_mpoly A i ^ lookup a i) ≠ 0} ⊆ {m. MPoly_Type.coeff p m ≠ 0}› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . also (*calculation: ‹insertion (sym_mpoly A) p = sum h M›*) have "lead_monom … = maxm" unfolding maxm_def (*goal: ‹lead_monom (sum h M) = Max ((lead_monom ∘ h) ` M)›*) proof (rule lead_monom_sum (*‹⟦inj_on (lead_monom ∘ ?h) ?X; finite ?X; ?X ≠ {}; ⋀x. x ∈ ?X ⟹ ?h x ≠ 0⟧ ⟹ lead_monom (sum ?h ?X) = Max ((lead_monom ∘ ?h) ` ?X)›*)) (*goals: 1. ‹inj_on (lead_monom ∘ h) M› 2. ‹finite M› 3. ‹M ≠ {}› 4. ‹⋀m. m ∈ M ⟹ h m ≠ 0›*) from p (*‹p ≠ 0›*) obtain m where "coeff p m ≠ 0" (*goal: ‹(⋀m::nat ⇒₀ nat. MPoly_Type.coeff (p::'a mpoly mpoly) m ≠ (0::'a mpoly) ⟹ thesis::bool) ⟹ thesis›*) using mpoly_eqI[of p 0] (*‹(⋀mon. MPoly_Type.coeff p mon = MPoly_Type.coeff 0 mon) ⟹ p = 0›*) by auto hence "m ∈ M" using ‹coeff p m ≠ 0› (*‹MPoly_Type.coeff p m ≠ 0›*) lead_coeff[of m] (*‹MPoly_Type.coeff p m ≠ 0 ⟹ Symmetric_Polynomials.lead_coeff (h m) = Symmetric_Polynomials.lead_coeff (MPoly_Type.coeff p m)›*) by (auto simp: M_def (*‹(M::(nat ⇒₀ nat) set) = {m::nat ⇒₀ nat. MPoly_Type.coeff (p::'a mpoly mpoly) m ≠ (0::'a mpoly)}›*)) thus "M ≠ {}" by auto next (*goals: 1. ‹inj_on (lead_monom ∘ h) M› 2. ‹finite M› 3. ‹⋀m. m ∈ M ⟹ h m ≠ 0›*) have restrict_lead_monom: "restrictpm A (lead_monom (h m)) = lead_monom (∏i. sym_mpoly A i ^ lookup m i :: 'a mpoly)" if [simp]: "coeff p m ≠ 0" for m proof (-) (*goal: ‹restrictpm (A::nat set) (lead_monom ((h::(nat ⇒₀ nat) ⇒ 'a::comm_ring_1 mpoly) (m::nat ⇒₀ nat))) = lead_monom (∏i::nat. sym_mpoly A i ^ lookup m i)›*) have "restrictpm A (lead_monom (h m)) = restrictpm A (lead_monom (coeff p m)) + restrictpm A (lead_monom (∏i. sym_mpoly A i ^ lookup m i :: 'a mpoly))" by (auto simp: lead_monom (*‹MPoly_Type.coeff (p::'a mpoly mpoly) (?m::nat ⇒₀ nat) ≠ (0::'a mpoly) ⟹ lead_monom ((h::(nat ⇒₀ nat) ⇒ 'a mpoly) ?m) = lead_monom (MPoly_Type.coeff p ?m) + lead_monom (∏i::nat. sym_mpoly (A::nat set) i ^ lookup ?m i)›*) restrictpm_add (*‹restrictpm (?X::?'a set) ((?m1.0::?'a ⇒₀ ?'b) + (?m2.0::?'a ⇒₀ ?'b)) = restrictpm ?X ?m1.0 + restrictpm ?X ?m2.0›*)) also (*calculation: ‹restrictpm A (lead_monom (h m)) = restrictpm A (lead_monom (MPoly_Type.coeff p m)) + restrictpm A (lead_monom (∏i. sym_mpoly A i ^ lookup m i))›*) have "restrictpm A (lead_monom (coeff p m)) = 0" using assms (*‹finite A› ‹insertion (sym_mpoly A) p = 0› ‹vars (MPoly_Type.coeff p ?m) ∩ A = {}› ‹vars p ⊆ {1..n}›*) apply (intro restrictpm_orthogonal (*‹keys ?m ⊆ - ?X ⟹ restrictpm ?X ?m = 0›*) order.trans[OF keys_lead_monom_subset] (*‹vars ?p1 ⊆ ?c ⟹ keys (lead_monom ?p1) ⊆ ?c›*)) (*goal: ‹restrictpm A (lead_monom (MPoly_Type.coeff p m)) = 0›*) by auto also (*calculation: ‹restrictpm A (lead_monom (h m)) = 0 + restrictpm A (lead_monom (∏i. sym_mpoly A i ^ lookup m i))›*) have "restrictpm A (lead_monom (∏i. sym_mpoly A i ^ lookup m i :: 'a mpoly)) = lead_monom (∏i. sym_mpoly A i ^ lookup m i :: 'a mpoly)" by (intro restrictpm_id (*‹keys ?m ⊆ ?X ⟹ restrictpm ?X ?m = ?m›*) order.trans[OF keys_lead_monom_subset] (*‹vars ?p1 ⊆ ?c ⟹ keys (lead_monom ?p1) ⊆ ?c›*) order.trans[OF vars_Prod_any] (*‹(⋃i. vars (?h1 i)) ⊆ ?c ⟹ vars (Prod_any ?h1) ⊆ ?c›*) UN_least (*‹(⋀x. x ∈ ?A ⟹ ?B x ⊆ ?C) ⟹ ⋃ (?B ` ?A) ⊆ ?C›*) order.trans[OF vars_power] (*‹vars ?p1 ⊆ ?c ⟹ vars (?p1 ^ ?n1) ⊆ ?c›*) vars_sym_mpoly_subset (*‹vars (sym_mpoly ?A ?k) ⊆ ?A›*)) finally (*calculation: ‹restrictpm A (lead_monom (h m)) = 0 + lead_monom (∏i. sym_mpoly A i ^ lookup m i)›*) show "?thesis" (*goal: ‹restrictpm (A::nat set) (lead_monom ((h::(nat ⇒₀ nat) ⇒ 'a mpoly) (m::nat ⇒₀ nat))) = lead_monom (∏i::nat. sym_mpoly A i ^ lookup m i)›*) by simp qed show "inj_on (lead_monom ∘ h) M" proof (standard) (*goal: ‹⋀x y. ⟦x ∈ M; y ∈ M; (lead_monom ∘ h) x = (lead_monom ∘ h) y⟧ ⟹ x = y›*) fix m1 and m2 assume m12: "m1 ∈ M" "m2 ∈ M" "(lead_monom ∘ h) m1 = (lead_monom ∘ h) m2" (*‹(m1::nat ⇒₀ nat) ∈ (M::(nat ⇒₀ nat) set)› ‹(m2::nat ⇒₀ nat) ∈ (M::(nat ⇒₀ nat) set)› ‹(lead_monom ∘ (h::(nat ⇒₀ nat) ⇒ 'a mpoly)) (m1::nat ⇒₀ nat) = (lead_monom ∘ h) (m2::nat ⇒₀ nat)›*) hence [simp]: "coeff p m1 ≠ 0" "coeff p m2 ≠ 0" apply - (*goals: 1. ‹⟦m1 ∈ M; m2 ∈ M; (lead_monom ∘ h) m1 = (lead_monom ∘ h) m2⟧ ⟹ MPoly_Type.coeff p m1 ≠ 0› 2. ‹⟦m1 ∈ M; m2 ∈ M; (lead_monom ∘ h) m1 = (lead_monom ∘ h) m2⟧ ⟹ MPoly_Type.coeff p m2 ≠ 0› discuss goal 1*) apply ((auto simp: M_def (*‹M = {m. MPoly_Type.coeff p m ≠ 0}›*) h_def (*‹h = (λm. MPoly_Type.coeff p m * (∏i. sym_mpoly A i ^ lookup m i))›*))[1]) (*discuss goal 2*) apply ((auto simp: M_def (*‹M = {m. MPoly_Type.coeff p m ≠ 0}›*) h_def (*‹h = (λm. MPoly_Type.coeff p m * (∏i. sym_mpoly A i ^ lookup m i))›*))[1]) (*proven 2 subgoals*) . have "restrictpm A (lead_monom (h m1)) = restrictpm A (lead_monom (h m2))" using m12 (*‹m1 ∈ M› ‹m2 ∈ M› ‹(lead_monom ∘ (h::(nat ⇒₀ nat) ⇒ 'a::comm_ring_1 mpoly)) (m1::nat ⇒₀ nat) = (lead_monom ∘ h) (m2::nat ⇒₀ nat)›*) by simp hence "lead_monom (∏i. sym_mpoly A i ^ lookup m1 i :: 'a mpoly) = lead_monom (∏i. sym_mpoly A i ^ lookup m2 i :: 'a mpoly)" by (simp add: restrict_lead_monom (*‹MPoly_Type.coeff p ?m ≠ 0 ⟹ restrictpm A (lead_monom (h ?m)) = lead_monom (∏i. sym_mpoly A i ^ lookup ?m i)›*)) thus "m1 = m2" apply (rule lead_monom_sym_poly_powerprod_inj (*‹⟦lead_monom (∏i::nat. sym_mpoly (A::nat set) i ^ lookup (?m1.0::nat ⇒₀ nat) i) = lead_monom (∏i::nat. sym_mpoly A i ^ lookup (?m2.0::nat ⇒₀ nat) i); finite A; keys ?m1.0 ⊆ {1::nat..n::nat}; keys ?m2.0 ⊆ {1::nat..n}⟧ ⟹ ?m1.0 = ?m2.0›*)) (*goals: 1. ‹finite A› 2. ‹keys m1 ⊆ {1..n}› 3. ‹keys m2 ⊆ {1..n}› discuss goal 1*) apply ((use ‹finite A› keys_subset[of m1] keys_subset[of m2] in auto)[1]) (*discuss goal 2*) apply ((use ‹finite A› keys_subset[of m1] keys_subset[of m2] in auto)[1]) (*discuss goal 3*) apply ((use ‹finite A› keys_subset[of m1] keys_subset[of m2] in auto)[1]) (*proven 3 subgoals*) . qed next (*goals: 1. ‹finite M› 2. ‹⋀m. m ∈ M ⟹ h m ≠ 0›*) fix m assume "m ∈ M" (*‹(m::nat ⇒₀ nat) ∈ (M::(nat ⇒₀ nat) set)›*) hence "lead_coeff (h m) = lead_coeff (coeff p m)" by (simp add: lead_coeff (*‹MPoly_Type.coeff (p::'a mpoly mpoly) (?m::nat ⇒₀ nat) ≠ (0::'a mpoly) ⟹ Symmetric_Polynomials.lead_coeff ((h::(nat ⇒₀ nat) ⇒ 'a mpoly) ?m) = Symmetric_Polynomials.lead_coeff (MPoly_Type.coeff p ?m)›*) M_def (*‹(M::(nat ⇒₀ nat) set) = {m::nat ⇒₀ nat. MPoly_Type.coeff (p::'a mpoly mpoly) m ≠ (0::'a mpoly)}›*)) with ‹m ∈ M› (*‹m ∈ M›*) show "h m ≠ 0" by (auto simp: M_def (*‹M = {m. MPoly_Type.coeff p m ≠ 0}›*)) qed ((fact)+) (*solved the remaining goal: ‹finite M›*) finally (*calculation: ‹lead_monom (insertion (sym_mpoly A) p) = maxm›*) have "maxm = 0" by (simp add: assms (*‹finite A› ‹insertion (sym_mpoly A) p = 0› ‹vars (MPoly_Type.coeff p ?m) ∩ A = {}› ‹vars p ⊆ {1..n}›*)) have only_zero: "m = 0" if "m ∈ M" for m proof (-) (*goal: ‹m = 0›*) from that (*‹m ∈ M›*) have nz[simp]: "coeff p m ≠ 0" by (auto simp: M_def (*‹M = {m. MPoly_Type.coeff p m ≠ 0}›*) h_def (*‹h = (λm. MPoly_Type.coeff p m * (∏i. sym_mpoly A i ^ lookup m i))›*)) from that (*‹m ∈ M›*) have "(lead_monom ∘ h) m ≤ maxm" using ‹finite M› (*‹finite M›*) unfolding maxm_def (*goal: ‹(lead_monom ∘ (h::(nat ⇒₀ nat) ⇒ 'a mpoly)) (m::nat ⇒₀ nat) ≤ Max ((lead_monom ∘ h) ` (M::(nat ⇒₀ nat) set))›*) apply (intro Max_ge (*‹⟦finite (?A::?'a::linorder set); (?x::?'a::linorder) ∈ ?A⟧ ⟹ ?x ≤ Max ?A›*) imageI (*‹(?x::?'a::type) ∈ (?A::?'a::type set) ⟹ (?f::?'a::type ⇒ ?'b::type) ?x ∈ ?f ` ?A›*) finite_imageI (*‹finite (?F::?'a::type set) ⟹ finite ((?h::?'a::type ⇒ ?'b::type) ` ?F)›*)) (*goals: 1. ‹⟦m ∈ M; finite M⟧ ⟹ finite M› 2. ‹⟦m ∈ M; finite M⟧ ⟹ m ∈ M› discuss goal 1*) apply ((assumption)[1]) (*discuss goal 2*) . (*proven 2 subgoals*) with ‹maxm = 0› (*‹(maxm::nat ⇒₀ nat) = (0::nat ⇒₀ nat)›*) have [simp]: "lead_monom (h m) = 0" by simp have lookup_nzD: "k ∈ {1..n}" if "lookup m k ≠ 0" for k using keys_subset[of m] (*‹MPoly_Type.coeff p m ≠ 0 ⟹ keys m ⊆ {1..n}›*) that (*‹lookup m k ≠ 0›*) by (auto simp: in_keys_iff (*‹(?x ∈ keys ?s) = (lookup ?s ?x ≠ 0)›*) subset_iff (*‹(?A ⊆ ?B) = (∀t. t ∈ ?A ⟶ t ∈ ?B)›*)) have "lead_monom (coeff p m) + 0 ≤ lead_monom (h m)" unfolding lead_monom[OF nz] (*goal: ‹lead_monom (MPoly_Type.coeff p m) + 0 ≤ lead_monom (MPoly_Type.coeff p m) + lead_monom (∏i. sym_mpoly A i ^ lookup m i)›*) apply (intro add_left_mono (*‹?a ≤ ?b ⟹ ?c + ?a ≤ ?c + ?b›*)) (*goal: ‹lead_monom (MPoly_Type.coeff p m) + 0 ≤ lead_monom (MPoly_Type.coeff p m) + lead_monom (∏i. sym_mpoly A i ^ lookup m i)›*) by auto also (*calculation: ‹lead_monom (MPoly_Type.coeff (p::'a::comm_ring_1 mpoly mpoly) (m::nat ⇒₀ nat)) + (0::nat ⇒₀ nat) ≤ lead_monom ((h::(nat ⇒₀ nat) ⇒ 'a::comm_ring_1 mpoly) m)›*) have "… = 0" by simp finally (*calculation: ‹lead_monom (MPoly_Type.coeff p m) + 0 ≤ 0›*) have lead_monom_0: "lead_monom (coeff p m) = 0" by simp have "sum (lookup m) {1..n} = 0" proof (rule ccontr (*‹(¬ ?P ⟹ False) ⟹ ?P›*)) (*goal: ‹sum (lookup (m::nat ⇒₀ nat)) {1::nat..n::nat} ≠ (0::nat) ⟹ False›*) assume "sum (lookup m) {1..n} ≠ 0" (*‹sum (lookup (m::nat ⇒₀ nat)) {1::nat..n::nat} ≠ (0::nat)›*) hence "sum (lookup m) {1..n} > 0" by presburger have "0 ≠ lead_coeff (MPoly_Type.coeff p m)" by auto also (*calculation: ‹(0::'a) ≠ Symmetric_Polynomials.lead_coeff (MPoly_Type.coeff (p::'a mpoly mpoly) (m::nat ⇒₀ nat))›*) have "lead_coeff (MPoly_Type.coeff p m) = lead_coeff (h m)" by (simp add: lead_coeff (*‹MPoly_Type.coeff (p::'a mpoly mpoly) (?m::nat ⇒₀ nat) ≠ (0::'a mpoly) ⟹ Symmetric_Polynomials.lead_coeff ((h::(nat ⇒₀ nat) ⇒ 'a mpoly) ?m) = Symmetric_Polynomials.lead_coeff (MPoly_Type.coeff p ?m)›*)) also (*calculation: ‹0 ≠ Symmetric_Polynomials.lead_coeff (h m)›*) have "lead_coeff (h m) = coeff (h m) 0" by (simp add: lead_coeff_def (*‹Symmetric_Polynomials.lead_coeff ?p = MPoly_Type.coeff ?p (lead_monom ?p)›*)) also (*calculation: ‹0 ≠ MPoly_Type.coeff (h m) 0›*) have "… = coeff (coeff p m) 0 * coeff (∏i. sym_mpoly A i ^ lookup m i) 0" by (simp add: h_def (*‹h = (λm. MPoly_Type.coeff p m * (∏i. sym_mpoly A i ^ lookup m i))›*) mpoly_coeff_times_0 (*‹MPoly_Type.coeff (?p * ?q) 0 = MPoly_Type.coeff ?p 0 * MPoly_Type.coeff ?q 0›*)) also (*calculation: ‹0 ≠ MPoly_Type.coeff (MPoly_Type.coeff p m) 0 * MPoly_Type.coeff (∏i. sym_mpoly A i ^ lookup m i) 0›*) have "(∏i. sym_mpoly A i ^ lookup m i) = (∏i=1..n. sym_mpoly A i ^ lookup m i)" apply (intro Prod_any.expand_superset (*‹⟦finite (?A::?'b set); {a::?'b. (?g::?'b ⇒ ?'a) a ≠ (1::?'a)} ⊆ ?A⟧ ⟹ Prod_any ?g = prod ?g ?A›*) subsetI (*‹(⋀x::?'a. x ∈ (?A::?'a set) ⟹ x ∈ (?B::?'a set)) ⟹ ?A ⊆ ?B›*) lookup_nzD (*‹lookup (m::nat ⇒₀ nat) (?k::nat) ≠ (0::nat) ⟹ ?k ∈ {1::nat..n::nat}›*)) (*goals: 1. ‹finite {1..n}› 2. ‹⋀x. x ∈ {a. sym_mpoly A a ^ lookup m a ≠ 1} ⟹ lookup m x ≠ 0› discuss goal 1*) apply ((auto intro!: Nat.gr0I (*‹((?n::nat) = (0::nat) ⟹ False) ⟹ (0::nat) < ?n›*))[1]) (*discuss goal 2*) apply ((auto intro!: Nat.gr0I (*‹(?n = 0 ⟹ False) ⟹ 0 < ?n›*))[1]) (*proven 2 subgoals*) . also (*calculation: ‹0 ≠ MPoly_Type.coeff (MPoly_Type.coeff p m) 0 * MPoly_Type.coeff (∏i = 1..n. sym_mpoly A i ^ lookup m i) 0›*) have "coeff … 0 = (∏i=1..n. 0 ^ lookup m i)" unfolding mpoly_coeff_prod_0 mpoly_coeff_power_0 (*goal: ‹(∏x = 1..n. MPoly_Type.coeff (sym_mpoly A x) 0 ^ lookup m x) = (∏i = 1..n. 0 ^ lookup m i)›*) apply (intro prod.cong (*‹⟦?A = ?B; ⋀x. x ∈ ?B ⟹ ?g x = ?h x⟧ ⟹ prod ?g ?A = prod ?h ?B›*)) (*goals: 1. ‹{1..n} = {1..n}› 2. ‹⋀x. x ∈ {1..n} ⟹ MPoly_Type.coeff (sym_mpoly A x) 0 ^ lookup m x = 0 ^ lookup m x› discuss goal 1*) apply ((auto simp: coeff_sym_mpoly_0 (*‹MPoly_Type.coeff (sym_mpoly ?X ?k) 0 = (if finite ?X ∧ ?k = 0 then 1 else 0)›*))[1]) (*discuss goal 2*) apply ((auto simp: coeff_sym_mpoly_0 (*‹MPoly_Type.coeff (sym_mpoly (?X::nat set) (?k::nat)) (0::nat ⇒₀ nat) = (if finite ?X ∧ ?k = (0::nat) then 1::?'a else (0::?'a))›*))[1]) (*proven 2 subgoals*) . also (*calculation: ‹0 ≠ MPoly_Type.coeff (MPoly_Type.coeff p m) 0 * (∏i = 1..n. 0 ^ lookup m i)›*) have "… = 0 ^ (∑i=1..n. lookup m i)" by (simp add: power_sum (*‹?c ^ sum ?f ?A = (∏a∈?A. ?c ^ ?f a)›*)) also (*calculation: ‹(0::'a) ≠ MPoly_Type.coeff (MPoly_Type.coeff (p::'a mpoly mpoly) (m::nat ⇒₀ nat)) (0::nat ⇒₀ nat) * (0::'a) ^ sum (lookup m) {1::nat..n::nat}›*) have "… = 0" using zero_power[OF ‹sum (lookup m) {1..n} > 0›] (*‹0 ^ sum (lookup m) {1..n} = 0›*) by simp finally (*calculation: ‹0 ≠ MPoly_Type.coeff (MPoly_Type.coeff p m) 0 * 0›*) show False by auto qed hence "lookup m k = 0" for k using keys_subset[of m] (*‹MPoly_Type.coeff p m ≠ 0 ⟹ keys m ⊆ {1..n}›*) apply (cases "k ∈ {1..n}") (*goals: 1. ‹⟦sum (lookup m) {1..n} = 0; MPoly_Type.coeff p m ≠ 0 ⟹ keys m ⊆ {1..n}; k ∈ {1..n}⟧ ⟹ lookup m k = 0› 2. ‹⟦sum (lookup m) {1..n} = 0; MPoly_Type.coeff p m ≠ 0 ⟹ keys m ⊆ {1..n}; k ∉ {1..n}⟧ ⟹ lookup m k = 0› discuss goal 1*) apply ((auto simp: in_keys_iff (*‹((?x::?'a::type) ∈ keys (?s::?'a::type ⇒₀ ?'b::zero)) = (lookup ?s ?x ≠ (0::?'b::zero))›*))[1]) (*discuss goal 2*) apply ((auto simp: in_keys_iff (*‹(?x ∈ keys ?s) = (lookup ?s ?x ≠ 0)›*))[1]) (*proven 2 subgoals*) . thus "m = 0" apply (intro poly_mapping_eqI (*‹(⋀k. lookup ?f k = lookup ?g k) ⟹ ?f = ?g›*)) (*goal: ‹m = 0›*) by auto qed have "0 = insertion (sym_mpoly A) p" using assms (*‹finite A› ‹insertion (sym_mpoly A) p = 0› ‹vars (MPoly_Type.coeff (p::'a mpoly mpoly) (?m::nat ⇒₀ nat)) ∩ (A::nat set) = {}› ‹vars p ⊆ {1..n}›*) by simp also (*calculation: ‹0 = insertion (sym_mpoly A) p›*) have "insertion (sym_mpoly A) p = (∑m∈M. h m)" by fact also (*calculation: ‹0 = sum h M›*) have "… = (∑m∈{0}. h m)" using only_zero (*‹?m ∈ M ⟹ ?m = 0›*) apply (intro sum.mono_neutral_left (*‹⟦finite ?T; ?S ⊆ ?T; ∀i∈?T - ?S. ?g i = 0⟧ ⟹ sum ?g ?S = sum ?g ?T›*)) (*goals: 1. ‹(⋀m. m ∈ M ⟹ m = 0) ⟹ finite {0}› 2. ‹(⋀m. m ∈ M ⟹ m = 0) ⟹ M ⊆ {0}› 3. ‹(⋀m. m ∈ M ⟹ m = 0) ⟹ ∀i∈{0} - M. h i = 0› discuss goal 1*) apply ((auto simp: h_def (*‹h = (λm. MPoly_Type.coeff p m * (∏i. sym_mpoly A i ^ lookup m i))›*) M_def (*‹M = {m. MPoly_Type.coeff p m ≠ 0}›*))[1]) (*discuss goal 2*) apply ((auto simp: h_def (*‹h = (λm. MPoly_Type.coeff p m * (∏i. sym_mpoly A i ^ lookup m i))›*) M_def (*‹M = {m. MPoly_Type.coeff p m ≠ 0}›*))[1]) (*discuss goal 3*) apply ((auto simp: h_def (*‹h = (λm. MPoly_Type.coeff p m * (∏i. sym_mpoly A i ^ lookup m i))›*) M_def (*‹M = {m. MPoly_Type.coeff p m ≠ 0}›*))[1]) (*proven 3 subgoals*) . also (*calculation: ‹0 = sum h {0}›*) have "… = coeff p 0" by (simp add: h_def (*‹h = (λm. MPoly_Type.coeff p m * (∏i. sym_mpoly A i ^ lookup m i))›*)) finally (*calculation: ‹0 = MPoly_Type.coeff p 0›*) have "0 ∉ M" by (auto simp: M_def (*‹(M::(nat ⇒₀ nat) set) = {m::nat ⇒₀ nat. MPoly_Type.coeff (p::'a::comm_ring_1 mpoly mpoly) m ≠ (0::'a::comm_ring_1 mpoly)}›*)) with only_zero (*‹?m ∈ M ⟹ ?m = 0›*) have "M = {}" by auto hence "p = 0" apply (intro mpoly_eqI (*‹(⋀mon. MPoly_Type.coeff ?p mon = MPoly_Type.coeff ?q mon) ⟹ ?p = ?q›*)) (*goal: ‹(p::'a::comm_ring_1 mpoly mpoly) = (0::'a::comm_ring_1 mpoly mpoly)›*) by (auto simp: M_def (*‹M = {m. MPoly_Type.coeff p m ≠ 0}›*)) with ‹p ≠ 0› (*‹p ≠ 0›*) show False by contradiction qed text ‹ The general uniqueness theorem now follows easily. This essentially shows that the substitution $Y_i \mapsto e_i(X_1,\ldots,X_n)$ is an isomorphism between the ring $R[Y_1,\ldots, Y_n]$ and the ring $R[X_1,\ldots,X_n]^{S_n}$ of symmetric polynomials. › theorem sym_mpoly_representation_unique: fixes p :: "'a mpoly mpoly" assumes "finite A" "insertion (sym_mpoly A) p = insertion (sym_mpoly A) q" "⋀m. vars (coeff p m) ∩ A = {}" "⋀m. vars (coeff q m) ∩ A = {}" "vars p ⊆ {1..n}" "vars q ⊆ {1..n}" shows "p = q" proof (-) (*goal: ‹(p::'a::comm_ring_1 mpoly mpoly) = (q::'a::comm_ring_1 mpoly mpoly)›*) have "p - q = 0" proof (rule sym_mpoly_representation_unique_aux (*‹⟦finite A; insertion (sym_mpoly A) ?p = 0; ⋀m. vars (MPoly_Type.coeff ?p m) ∩ A = {}; vars ?p ⊆ {1..n}⟧ ⟹ ?p = 0›*)) (*goals: 1. ‹finite (A::nat set)› 2. ‹insertion (sym_mpoly (A::nat set)) ((p::'a mpoly mpoly) - (q::'a mpoly mpoly)) = (0::'a mpoly)› 3. ‹⋀m::nat ⇒₀ nat. vars (MPoly_Type.coeff ((p::'a mpoly mpoly) - (q::'a mpoly mpoly)) m) ∩ (A::nat set) = {}› 4. ‹vars ((p::'a mpoly mpoly) - (q::'a mpoly mpoly)) ⊆ {1::nat..n::nat}›*) fix m show "vars (coeff (p - q) m) ∩ A = {}" using vars_diff[of "coeff p m" "coeff q m"] (*‹vars (MPoly_Type.coeff (p::'a mpoly mpoly) (m::nat ⇒₀ nat) - MPoly_Type.coeff (q::'a mpoly mpoly) m) ⊆ vars (MPoly_Type.coeff p m) ∪ vars (MPoly_Type.coeff q m)›*) assms(3,4)[of m] (*‹vars (MPoly_Type.coeff p m) ∩ A = {}› ‹vars (MPoly_Type.coeff q m) ∩ A = {}›*) by auto qed (insert assms (*‹finite A› ‹insertion (sym_mpoly A) p = insertion (sym_mpoly A) q› ‹vars (MPoly_Type.coeff p ?m) ∩ A = {}› ‹vars (MPoly_Type.coeff q ?m) ∩ A = {}› ‹vars p ⊆ {1..n}› ‹vars q ⊆ {1..n}›*) vars_diff[of p q] (*‹vars (p - q) ⊆ vars p ∪ vars q›*), auto simp: insertion_diff (*‹insertion (?f::nat ⇒ ?'a) ((?p::?'a mpoly) - (?q::?'a mpoly)) = insertion ?f ?p - insertion ?f ?q›*)) (*solves the remaining goals: 1. ‹finite A› 2. ‹insertion (sym_mpoly A) (p - q) = 0› 3. ‹vars (p - q) ⊆ {1..n}›*) thus "?thesis" (*goal: ‹p = q›*) by simp qed theorem eq_fund_sym_poly_witI: fixes p :: "'a mpoly" and q :: "'a mpoly mpoly" assumes "finite A" "symmetric_mpoly A p" "insertion (sym_mpoly A) q = p" "⋀m. vars (coeff q m) ∩ A = {}" "vars q ⊆ {1..n}" shows "q = fund_sym_poly_wit p" using fund_sym_poly_wit_insertion[of p] (*‹symmetric_mpoly (A::nat set) (p::'a::comm_ring_1 mpoly) ⟹ insertion (sym_mpoly A) (local.fund_sym_poly_wit p) = p›*) fund_sym_poly_wit_vars[of p] (*‹vars (local.fund_sym_poly_wit p) ⊆ {1..n}›*) fund_sym_poly_wit_coeffs[of p] (*‹symmetric_mpoly A p ⟹ vars (MPoly_Type.coeff (local.fund_sym_poly_wit p) ?m) ⊆ vars p - A›*) apply (intro sym_mpoly_representation_unique (*‹⟦finite A; insertion (sym_mpoly A) ?p = insertion (sym_mpoly A) ?q; ⋀m. vars (MPoly_Type.coeff ?p m) ∩ A = {}; ⋀m. vars (MPoly_Type.coeff ?q m) ∩ A = {}; vars ?p ⊆ {1..n}; vars ?q ⊆ {1..n}⟧ ⟹ ?p = ?q›*)) (*goals: 1. ‹⟦symmetric_mpoly A p ⟹ insertion (sym_mpoly A) (local.fund_sym_poly_wit p) = p; vars (local.fund_sym_poly_wit p) ⊆ {1..n}; ⋀m. symmetric_mpoly A p ⟹ vars (MPoly_Type.coeff (local.fund_sym_poly_wit p) m) ⊆ vars p - A⟧ ⟹ finite A› 2. ‹⟦symmetric_mpoly A p ⟹ insertion (sym_mpoly A) (local.fund_sym_poly_wit p) = p; vars (local.fund_sym_poly_wit p) ⊆ {1..n}; ⋀m. symmetric_mpoly A p ⟹ vars (MPoly_Type.coeff (local.fund_sym_poly_wit p) m) ⊆ vars p - A⟧ ⟹ insertion (sym_mpoly A) q = insertion (sym_mpoly A) (local.fund_sym_poly_wit p)› 3. ‹⋀m. ⟦symmetric_mpoly A p ⟹ insertion (sym_mpoly A) (local.fund_sym_poly_wit p) = p; vars (local.fund_sym_poly_wit p) ⊆ {1..n}; ⋀m. symmetric_mpoly A p ⟹ vars (MPoly_Type.coeff (local.fund_sym_poly_wit p) m) ⊆ vars p - A⟧ ⟹ vars (MPoly_Type.coeff q m) ∩ A = {}› 4. ‹⋀m. ⟦symmetric_mpoly A p ⟹ insertion (sym_mpoly A) (local.fund_sym_poly_wit p) = p; vars (local.fund_sym_poly_wit p) ⊆ {1..n}; ⋀m. symmetric_mpoly A p ⟹ vars (MPoly_Type.coeff (local.fund_sym_poly_wit p) m) ⊆ vars p - A⟧ ⟹ vars (MPoly_Type.coeff (local.fund_sym_poly_wit p) m) ∩ A = {}› 5. ‹⟦symmetric_mpoly A p ⟹ insertion (sym_mpoly A) (local.fund_sym_poly_wit p) = p; vars (local.fund_sym_poly_wit p) ⊆ {1..n}; ⋀m. symmetric_mpoly A p ⟹ vars (MPoly_Type.coeff (local.fund_sym_poly_wit p) m) ⊆ vars p - A⟧ ⟹ vars q ⊆ {1..n}› 6. ‹⟦symmetric_mpoly A p ⟹ insertion (sym_mpoly A) (local.fund_sym_poly_wit p) = p; vars (local.fund_sym_poly_wit p) ⊆ {1..n}; ⋀m. symmetric_mpoly A p ⟹ vars (MPoly_Type.coeff (local.fund_sym_poly_wit p) m) ⊆ vars p - A⟧ ⟹ vars (local.fund_sym_poly_wit p) ⊆ {1..n}› discuss goal 1*) apply ((insert assms (*‹finite (A::nat set)› ‹symmetric_mpoly (A::nat set) (p::'a::comm_ring_1 mpoly)› ‹insertion (sym_mpoly (A::nat set)) (q::'a::comm_ring_1 mpoly mpoly) = (p::'a::comm_ring_1 mpoly)› ‹vars (MPoly_Type.coeff (q::'a::comm_ring_1 mpoly mpoly) (?m::nat ⇒₀ nat)) ∩ (A::nat set) = {}› ‹vars (q::'a::comm_ring_1 mpoly mpoly) ⊆ {1::nat..n::nat}›*))[1]) (*top goal: ‹⟦symmetric_mpoly (A::nat set) (p::'a::comm_ring_1 mpoly) ⟹ insertion (sym_mpoly A) (local.fund_sym_poly_wit p) = p; vars (local.fund_sym_poly_wit p) ⊆ {1::nat..n::nat}; ⋀m::nat ⇒₀ nat. symmetric_mpoly A p ⟹ vars (MPoly_Type.coeff (local.fund_sym_poly_wit p) m) ⊆ vars p - A⟧ ⟹ finite A› and 5 goals remain*) apply ((auto simp: fund_sym_poly_wit_insertion (*‹symmetric_mpoly A ?p ⟹ insertion (sym_mpoly A) (local.fund_sym_poly_wit ?p) = ?p›*))[1]) (*discuss goal 2*) apply ((insert assms (*‹finite (A::nat set)› ‹symmetric_mpoly (A::nat set) (p::'a::comm_ring_1 mpoly)› ‹insertion (sym_mpoly (A::nat set)) (q::'a::comm_ring_1 mpoly mpoly) = (p::'a::comm_ring_1 mpoly)› ‹vars (MPoly_Type.coeff (q::'a::comm_ring_1 mpoly mpoly) (?m::nat ⇒₀ nat)) ∩ (A::nat set) = {}› ‹vars (q::'a::comm_ring_1 mpoly mpoly) ⊆ {1::nat..n::nat}›*))[1]) (*top goal: ‹⟦symmetric_mpoly (A::nat set) (p::'a mpoly) ⟹ insertion (sym_mpoly A) (local.fund_sym_poly_wit p) = p; vars (local.fund_sym_poly_wit p) ⊆ {1::nat..n::nat}; ⋀m::nat ⇒₀ nat. symmetric_mpoly A p ⟹ vars (MPoly_Type.coeff (local.fund_sym_poly_wit p) m) ⊆ vars p - A⟧ ⟹ insertion (sym_mpoly A) (q::'a mpoly mpoly) = insertion (sym_mpoly A) (local.fund_sym_poly_wit p)› and 4 goals remain*) apply ((auto simp: fund_sym_poly_wit_insertion (*‹symmetric_mpoly A ?p ⟹ insertion (sym_mpoly A) (local.fund_sym_poly_wit ?p) = ?p›*))[1]) (*discuss goal 3*) apply ((insert assms (*‹finite A› ‹symmetric_mpoly A p› ‹insertion (sym_mpoly A) q = p› ‹vars (MPoly_Type.coeff q ?m) ∩ A = {}› ‹vars q ⊆ {1..n}›*))[1]) (*top goal: ‹⋀m. ⟦symmetric_mpoly A p ⟹ insertion (sym_mpoly A) (local.fund_sym_poly_wit p) = p; vars (local.fund_sym_poly_wit p) ⊆ {1..n}; ⋀m. symmetric_mpoly A p ⟹ vars (MPoly_Type.coeff (local.fund_sym_poly_wit p) m) ⊆ vars p - A⟧ ⟹ vars (MPoly_Type.coeff q m) ∩ A = {}› and 3 goals remain*) apply ((auto simp: fund_sym_poly_wit_insertion (*‹symmetric_mpoly A ?p ⟹ insertion (sym_mpoly A) (local.fund_sym_poly_wit ?p) = ?p›*))[1]) (*discuss goal 4*) apply ((insert assms (*‹finite A› ‹symmetric_mpoly A p› ‹insertion (sym_mpoly A) q = p› ‹vars (MPoly_Type.coeff q ?m) ∩ A = {}› ‹vars q ⊆ {1..n}›*))[1]) (*top goal: ‹⋀m. ⟦symmetric_mpoly A p ⟹ insertion (sym_mpoly A) (local.fund_sym_poly_wit p) = p; vars (local.fund_sym_poly_wit p) ⊆ {1..n}; ⋀m. symmetric_mpoly A p ⟹ vars (MPoly_Type.coeff (local.fund_sym_poly_wit p) m) ⊆ vars p - A⟧ ⟹ vars (MPoly_Type.coeff (local.fund_sym_poly_wit p) m) ∩ A = {}› and 2 goals remain*) apply ((auto simp: fund_sym_poly_wit_insertion (*‹symmetric_mpoly A ?p ⟹ insertion (sym_mpoly A) (local.fund_sym_poly_wit ?p) = ?p›*))[1]) (*discuss goal 5*) apply ((insert assms (*‹finite (A::nat set)› ‹symmetric_mpoly (A::nat set) (p::'a mpoly)› ‹insertion (sym_mpoly (A::nat set)) (q::'a mpoly mpoly) = (p::'a mpoly)› ‹vars (MPoly_Type.coeff (q::'a mpoly mpoly) (?m::nat ⇒₀ nat)) ∩ (A::nat set) = {}› ‹vars (q::'a mpoly mpoly) ⊆ {1::nat..n::nat}›*))[1]) (*top goal: ‹⟦symmetric_mpoly (A::nat set) (p::'a mpoly) ⟹ insertion (sym_mpoly A) (local.fund_sym_poly_wit p) = p; vars (local.fund_sym_poly_wit p) ⊆ {1::nat..n::nat}; ⋀m::nat ⇒₀ nat. symmetric_mpoly A p ⟹ vars (MPoly_Type.coeff (local.fund_sym_poly_wit p) m) ⊆ vars p - A⟧ ⟹ vars (q::'a mpoly mpoly) ⊆ {1::nat..n}› and 1 goal remains*) apply ((auto simp: fund_sym_poly_wit_insertion (*‹symmetric_mpoly A ?p ⟹ insertion (sym_mpoly A) (local.fund_sym_poly_wit ?p) = ?p›*))[1]) (*discuss goal 6*) apply ((insert assms (*‹finite A› ‹symmetric_mpoly A p› ‹insertion (sym_mpoly A) q = p› ‹vars (MPoly_Type.coeff q ?m) ∩ A = {}› ‹vars q ⊆ {1..n}›*))[1]) (*goal: ‹⟦symmetric_mpoly (A::nat set) (p::'a::comm_ring_1 mpoly) ⟹ insertion (sym_mpoly A) (local.fund_sym_poly_wit p) = p; vars (local.fund_sym_poly_wit p) ⊆ {1::nat..n::nat}; ⋀m::nat ⇒₀ nat. symmetric_mpoly A p ⟹ vars (MPoly_Type.coeff (local.fund_sym_poly_wit p) m) ⊆ vars p - A⟧ ⟹ vars (local.fund_sym_poly_wit p) ⊆ {1::nat..n}›*) apply ((auto simp: fund_sym_poly_wit_insertion (*‹symmetric_mpoly A ?p ⟹ insertion (sym_mpoly A) (local.fund_sym_poly_wit ?p) = ?p›*))[1]) (*proven 6 subgoals*) . subsection ‹A recursive characterisation of symmetry› text ‹ In a similar spirit to the proof of the fundamental theorem, we obtain a nice recursive and executable characterisation of symmetry. › (*<*) lemmas [fundef_cong] = disj_cong conj_cong (*>*) function (domintros) check_symmetric_mpoly where "check_symmetric_mpoly p ⟷ (vars p ∩ A = {} ∨ A ⊆ vars p ∧ decr p ∧ check_symmetric_mpoly (p - fund_sym_step_poly p))" by auto lemma check_symmetric_mpoly_dom_aux: assumes "finite B" "vars p ⊆ B" "A ⊆ B" shows "check_symmetric_mpoly_dom p" using assms(1-3) (*‹finite B› ‹vars p ⊆ B› ‹A ⊆ B›*) proof (induction p rule: lead_monom_induct (*‹⟦finite ?A; vars ?p ⊆ ?A; ⋀p. ⟦vars p ⊆ ?A; ⋀p'. ⟦vars p' ⊆ ?A; lead_monom p' < lead_monom p⟧ ⟹ ?P p'⟧ ⟹ ?P p⟧ ⟹ ?P ?p›*)) (*goal: ‹⋀p. ⟦vars p ⊆ B; ⋀p'. ⟦vars p' ⊆ B; lead_monom p' < lead_monom p; A ⊆ B⟧ ⟹ local.check_symmetric_mpoly_dom p'; A ⊆ B⟧ ⟹ local.check_symmetric_mpoly_dom p›*) case (less p) (*‹vars p ⊆ B› ‹⟦vars (?p'::'a::comm_ring_1 mpoly) ⊆ (B::nat set); lead_monom ?p' < lead_monom (p::'a::comm_ring_1 mpoly); (A::nat set) ⊆ B⟧ ⟹ local.check_symmetric_mpoly_dom ?p'› ‹A ⊆ B›*) have [simp]: "finite A" apply (rule finite_subset[of _ B] (*‹⟦(?A::nat set) ⊆ (B::nat set); finite B⟧ ⟹ finite ?A›*)) (*goals: 1. ‹A ⊆ B› 2. ‹finite B› discuss goal 1*) apply fact (*discuss goal 2*) apply fact (*proven 2 subgoals*) . show "?case" (*goal: ‹local.check_symmetric_mpoly_dom p›*) proof (cases "lead_monom p = 0 ∨ ¬decr p") (*goals: 1. ‹lead_monom p = 0 ∨ ¬ decr p ⟹ local.check_symmetric_mpoly_dom p› 2. ‹¬ (lead_monom p = 0 ∨ ¬ decr p) ⟹ local.check_symmetric_mpoly_dom p›*) case False (*‹¬ (lead_monom (p::'a mpoly) = (0::nat ⇒₀ nat) ∨ ¬ (decr::'a mpoly ⇒ bool) p)›*) hence [simp]: "p ≠ 0" by auto have "vars (p - fund_sym_step_poly p) ⊆ B" using fund_sym_step_poly[of p] (*‹⟦finite A; p ≠ 0; decr p⟧ ⟹ lead_monom (local.fund_sym_step_poly p) = lead_monom p› ‹⟦finite A; p ≠ 0; decr p⟧ ⟹ Symmetric_Polynomials.lead_coeff (local.fund_sym_step_poly p) = Symmetric_Polynomials.lead_coeff p› ‹⟦finite (A::nat set); (p::'a::comm_ring_1 mpoly) ≠ (0::'a::comm_ring_1 mpoly); (decr::'a::comm_ring_1 mpoly ⇒ bool) p⟧ ⟹ local.fund_sym_step_poly p = local.fund_sym_step_coeff p * (∏x::nat. sym_mpoly A x ^ lookup (local.fund_sym_step_monom p) x)› ‹vars (local.fund_sym_step_poly p) ⊆ vars p ∪ A› ‹symmetric_mpoly (A::nat set) (local.fund_sym_step_poly (p::'a mpoly))›*) False (*‹¬ (lead_monom p = 0 ∨ ¬ decr p)›*) less.prems (*‹A ⊆ B›*) less.hyps (*‹vars p ⊆ B›*) ‹A ⊆ B› (*‹A ⊆ B›*) apply (intro order.trans[OF vars_diff] (*‹vars ?p1.1 ∪ vars ?p2.1 ⊆ ?c ⟹ vars (?p1.1 - ?p2.1) ⊆ ?c›*)) (*goal: ‹vars (p - local.fund_sym_step_poly p) ⊆ B›*) by auto hence "check_symmetric_mpoly_dom (p - local.fund_sym_step_poly p)" using False (*‹¬ (lead_monom p = 0 ∨ ¬ decr p)›*) less.prems (*‹(A::nat set) ⊆ (B::nat set)›*) less.hyps (*‹vars p ⊆ B›*) apply (intro less.IH (*‹⟦vars ?p' ⊆ B; lead_monom ?p' < lead_monom p; A ⊆ B⟧ ⟹ local.check_symmetric_mpoly_dom ?p'›*) fund_sym_step_poly (*‹⟦finite A; ?p ≠ 0; decr ?p⟧ ⟹ lead_monom (local.fund_sym_step_poly ?p) = lead_monom ?p› ‹⟦finite A; ?p ≠ 0; decr ?p⟧ ⟹ Symmetric_Polynomials.lead_coeff (local.fund_sym_step_poly ?p) = Symmetric_Polynomials.lead_coeff ?p› ‹⟦finite A; ?p ≠ 0; decr ?p⟧ ⟹ local.fund_sym_step_poly ?p = local.fund_sym_step_coeff ?p * (∏x. sym_mpoly A x ^ lookup (local.fund_sym_step_monom ?p) x)› ‹vars (local.fund_sym_step_poly ?p) ⊆ vars ?p ∪ A› ‹symmetric_mpoly A (local.fund_sym_step_poly ?p)›*) symmetric_mpoly_diff (*‹⟦symmetric_mpoly ?A ?p; symmetric_mpoly ?A ?q⟧ ⟹ symmetric_mpoly ?A (?p - ?q)›*) lead_monom_fund_sym_step_poly_less (*‹⟦finite A; lead_monom ?p ≠ 0; decr ?p⟧ ⟹ lead_monom (?p - local.fund_sym_step_poly ?p) < lead_monom ?p›*)) (*goals: 1. ‹⟦vars (p - local.fund_sym_step_poly p) ⊆ B; ¬ (lead_monom p = 0 ∨ ¬ decr p); A ⊆ B; vars p ⊆ B⟧ ⟹ vars (p - local.fund_sym_step_poly p) ⊆ B› 2. ‹⟦vars (p - local.fund_sym_step_poly p) ⊆ B; ¬ (lead_monom p = 0 ∨ ¬ decr p); A ⊆ B; vars p ⊆ B⟧ ⟹ finite A› 3. ‹⟦vars (p - local.fund_sym_step_poly p) ⊆ B; ¬ (lead_monom p = 0 ∨ ¬ decr p); A ⊆ B; vars p ⊆ B⟧ ⟹ lead_monom p ≠ 0› 4. ‹⟦vars (p - local.fund_sym_step_poly p) ⊆ B; ¬ (lead_monom p = 0 ∨ ¬ decr p); A ⊆ B; vars p ⊆ B⟧ ⟹ decr p› 5. ‹⟦vars (p - local.fund_sym_step_poly p) ⊆ B; ¬ (lead_monom p = 0 ∨ ¬ decr p); A ⊆ B; vars p ⊆ B⟧ ⟹ A ⊆ B› discuss goal 1*) apply ((auto simp: decr_def (*‹decr ≡ λp. ∀i∈A. ∀j∈A. i ≤ j ⟶ lookup (lead_monom p) j ≤ lookup (lead_monom p) i›*))[1]) (*discuss goal 2*) apply ((auto simp: decr_def (*‹decr ≡ λp. ∀i∈A. ∀j∈A. i ≤ j ⟶ lookup (lead_monom p) j ≤ lookup (lead_monom p) i›*))[1]) (*discuss goal 3*) apply ((auto simp: decr_def (*‹decr::'a::comm_ring_1 mpoly ⇒ bool ≡ λp::'a::comm_ring_1 mpoly. ∀i::nat∈A::nat set. ∀j::nat∈A. i ≤ j ⟶ lookup (lead_monom p) j ≤ lookup (lead_monom p) i›*))[1]) (*discuss goal 4*) apply ((auto simp: decr_def (*‹decr::'a::comm_ring_1 mpoly ⇒ bool ≡ λp::'a::comm_ring_1 mpoly. ∀i::nat∈A::nat set. ∀j::nat∈A. i ≤ j ⟶ lookup (lead_monom p) j ≤ lookup (lead_monom p) i›*))[1]) (*discuss goal 5*) apply ((auto simp: decr_def (*‹decr ≡ λp. ∀i∈A. ∀j∈A. i ≤ j ⟶ lookup (lead_monom p) j ≤ lookup (lead_monom p) i›*))[1]) (*proven 5 subgoals*) . thus "?thesis" (*goal: ‹local.check_symmetric_mpoly_dom p›*) using check_symmetric_mpoly.domintros (*‹(⋀x. ⟦A ⊆ vars ?p; decr ?p; ¬ local.check_symmetric_mpoly_dom (?p - local.fund_sym_step_poly ?p); x ∈ vars ?p; x ∈ A⟧ ⟹ False) ⟹ local.check_symmetric_mpoly_dom ?p›*) by blast qed (auto intro: check_symmetric_mpoly.domintros (*‹(⋀x. ⟦A ⊆ vars ?p; decr ?p; ¬ local.check_symmetric_mpoly_dom (?p - local.fund_sym_step_poly ?p); x ∈ vars ?p; x ∈ A⟧ ⟹ False) ⟹ local.check_symmetric_mpoly_dom ?p›*) simp: lead_monom_eq_0_iff (*‹(lead_monom ?p = 0) = (vars ?p = {})›*)) (*solved the remaining goal: ‹lead_monom p = 0 ∨ ¬ decr p ⟹ local.check_symmetric_mpoly_dom p›*) qed lemma check_symmetric_mpoly_dom [intro]: "check_symmetric_mpoly_dom p" proof (-) (*goal: ‹local.check_symmetric_mpoly_dom p›*) show "?thesis" (*goal: ‹local.check_symmetric_mpoly_dom p›*) proof (cases "A ⊆ vars p") (*goals: 1. ‹A ⊆ vars p ⟹ local.check_symmetric_mpoly_dom p› 2. ‹¬ A ⊆ vars p ⟹ local.check_symmetric_mpoly_dom p›*) assume "A ⊆ vars p" (*‹(A::nat set) ⊆ vars (p::'a mpoly)›*) thus "?thesis" (*goal: ‹local.check_symmetric_mpoly_dom p›*) using check_symmetric_mpoly_dom_aux[of "vars p" p] (*‹⟦finite (vars p); vars p ⊆ vars p; A ⊆ vars p⟧ ⟹ local.check_symmetric_mpoly_dom p›*) by (auto simp: vars_finite (*‹finite (vars ?p)›*)) qed (auto intro: check_symmetric_mpoly.domintros (*‹(⋀x. ⟦A ⊆ vars ?p; decr ?p; ¬ local.check_symmetric_mpoly_dom (?p - local.fund_sym_step_poly ?p); x ∈ vars ?p; x ∈ A⟧ ⟹ False) ⟹ local.check_symmetric_mpoly_dom ?p›*)) (*solved the remaining goal: ‹¬ A ⊆ vars p ⟹ local.check_symmetric_mpoly_dom p›*) qed termination check_symmetric_mpoly by (intro allI check_symmetric_mpoly_dom) lemmas [simp del] = check_symmetric_mpoly.simps lemma check_symmetric_mpoly_correct: "check_symmetric_mpoly p ⟷ symmetric_mpoly A p" proof (induction p rule: check_symmetric_mpoly.induct (*‹(⋀p::'a mpoly. (⟦vars p ∩ (A::nat set) ≠ {}; A ⊆ vars p; (decr::'a mpoly ⇒ bool) p⟧ ⟹ (?P::'a mpoly ⇒ bool) (p - local.fund_sym_step_poly p)) ⟹ ?P p) ⟹ ?P (?a0.0::'a mpoly)›*)) (*goal: ‹⋀p. (⟦vars p ∩ A ≠ {}; A ⊆ vars p; decr p⟧ ⟹ local.check_symmetric_mpoly (p - local.fund_sym_step_poly p) = symmetric_mpoly A (p - local.fund_sym_step_poly p)) ⟹ local.check_symmetric_mpoly p = symmetric_mpoly A p›*) case (1 p) (*‹⟦vars p ∩ A ≠ {}; A ⊆ vars p; decr p⟧ ⟹ local.check_symmetric_mpoly (p - local.fund_sym_step_poly p) = symmetric_mpoly A (p - local.fund_sym_step_poly p)›*) have "symmetric_mpoly A (p - fund_sym_step_poly p) ⟷ symmetric_mpoly A p" (is "?lhs = ?rhs") proof (standard) (*goals: 1. ‹symmetric_mpoly A (p - local.fund_sym_step_poly p) ⟹ symmetric_mpoly A p› 2. ‹symmetric_mpoly A p ⟹ symmetric_mpoly A (p - local.fund_sym_step_poly p)›*) assume "?rhs" (*‹symmetric_mpoly (A::nat set) (p::'a mpoly)›*) thus "?lhs" by (intro symmetric_mpoly_diff (*‹⟦symmetric_mpoly ?A ?p; symmetric_mpoly ?A ?q⟧ ⟹ symmetric_mpoly ?A (?p - ?q)›*) fund_sym_step_poly (*‹⟦finite A; ?p ≠ 0; decr ?p⟧ ⟹ lead_monom (local.fund_sym_step_poly ?p) = lead_monom ?p› ‹⟦finite A; ?p ≠ 0; decr ?p⟧ ⟹ Symmetric_Polynomials.lead_coeff (local.fund_sym_step_poly ?p) = Symmetric_Polynomials.lead_coeff ?p› ‹⟦finite A; ?p ≠ 0; decr ?p⟧ ⟹ local.fund_sym_step_poly ?p = local.fund_sym_step_coeff ?p * (∏x. sym_mpoly A x ^ lookup (local.fund_sym_step_monom ?p) x)› ‹vars (local.fund_sym_step_poly ?p) ⊆ vars ?p ∪ A› ‹symmetric_mpoly A (local.fund_sym_step_poly ?p)›*)) next (*goal: ‹symmetric_mpoly (A::nat set) ((p::'a::comm_ring_1 mpoly) - local.fund_sym_step_poly p) ⟹ symmetric_mpoly A p›*) assume "?lhs" (*‹symmetric_mpoly (A::nat set) ((p::'a mpoly) - local.fund_sym_step_poly p)›*) hence "symmetric_mpoly A (p - fund_sym_step_poly p + fund_sym_step_poly p)" by (intro symmetric_mpoly_add (*‹⟦symmetric_mpoly (?A::nat set) (?p::?'a mpoly); symmetric_mpoly ?A (?q::?'a mpoly)⟧ ⟹ symmetric_mpoly ?A (?p + ?q)›*) fund_sym_step_poly (*‹⟦finite (A::nat set); (?p::'a mpoly) ≠ (0::'a mpoly); (decr::'a mpoly ⇒ bool) ?p⟧ ⟹ lead_monom (local.fund_sym_step_poly ?p) = lead_monom ?p› ‹⟦finite (A::nat set); (?p::'a mpoly) ≠ (0::'a mpoly); (decr::'a mpoly ⇒ bool) ?p⟧ ⟹ Symmetric_Polynomials.lead_coeff (local.fund_sym_step_poly ?p) = Symmetric_Polynomials.lead_coeff ?p› ‹⟦finite (A::nat set); (?p::'a mpoly) ≠ (0::'a mpoly); (decr::'a mpoly ⇒ bool) ?p⟧ ⟹ local.fund_sym_step_poly ?p = local.fund_sym_step_coeff ?p * (∏x::nat. sym_mpoly A x ^ lookup (local.fund_sym_step_monom ?p) x)› ‹vars (local.fund_sym_step_poly (?p::'a mpoly)) ⊆ vars ?p ∪ (A::nat set)› ‹symmetric_mpoly (A::nat set) (local.fund_sym_step_poly (?p::'a mpoly))›*)) thus "?rhs" by simp qed moreover have "decr p" if "symmetric_mpoly A p" using lookup_lead_monom_decreasing[of A p] (*‹⟦symmetric_mpoly A p; ?i ∈ A; ?j ∈ A; ?i ≤ ?j⟧ ⟹ lookup (lead_monom p) ?j ≤ lookup (lead_monom p) ?i›*) that (*‹symmetric_mpoly A p›*) by (auto simp: decr_def (*‹decr ≡ λp. ∀i∈A. ∀j∈A. i ≤ j ⟶ lookup (lead_monom p) j ≤ lookup (lead_monom p) i›*)) ultimately show "check_symmetric_mpoly p ⟷ symmetric_mpoly A p" using "1" (*‹⟦vars p ∩ A ≠ {}; A ⊆ vars p; decr p⟧ ⟹ local.check_symmetric_mpoly (p - local.fund_sym_step_poly p) = symmetric_mpoly A (p - local.fund_sym_step_poly p)›*) symmetric_mpoly_imp_orthogonal_or_subset[of A p] (*‹symmetric_mpoly A p ⟹ vars p ∩ A = {} ∨ A ⊆ vars p›*) by (auto simp: Let_def (*‹Let (?s::?'a) (?f::?'a ⇒ ?'b) ≡ ?f ?s›*) check_symmetric_mpoly.simps[of p] (*‹local.check_symmetric_mpoly (p::'a mpoly) = (vars p ∩ (A::nat set) = {} ∨ A ⊆ vars p ∧ (decr::'a mpoly ⇒ bool) p ∧ local.check_symmetric_mpoly (p - local.fund_sym_step_poly p))›*) intro: symmetric_mpoly_orthogonal (*‹vars (?p::?'a mpoly) ∩ (?A::nat set) = {} ⟹ symmetric_mpoly ?A ?p›*)) qed end subsection ‹Symmetric functions of roots of a univariate polynomial› text ‹ Consider a factored polynomial \[p(X) = c_n X^n + c_{n-1} X^{n-1} + \ldots + c_1X + c_0 = (X - x_1)\ldots(X - x_n)\ .\] where $c_n$ is a unit. Then any symmetric polynomial expression $q(x_1, \ldots, x_n)$ in the roots $x_i$ can be written as a polynomial expression $q'(c_0,\ldots, c_{n-1})$ in the $c_i$. Moreover, if the coefficients of $q$ and the inverse of $c_n$ all lie in some subring, the coefficients of $q'$ do as well. › context fixes C :: "'b :: comm_ring_1 set" and A :: "nat set" and root :: "nat ⇒ 'a :: comm_ring_1" and l :: "'a ⇒ 'b" and q :: "'b mpoly" and n :: nat defines "n ≡ card A" assumes C: "ring_closed C" "∀m. coeff q m ∈ C" assumes l: "ring_homomorphism l" assumes finite: "finite A" assumes sym: "symmetric_mpoly A q" and vars: "vars q ⊆ A" begin interpretation ring_closed C by fact interpretation ring_homomorphism l by fact theorem symmetric_poly_of_roots_conv_poly_of_coeffs: assumes c: "cinv * l c = 1" "cinv ∈ C" assumes "p = Polynomial.smult c (∏i∈A. [:-root i, 1:])" obtains q' where "vars q' ⊆ {0..<n}" and "⋀m. coeff q' m ∈ C" and "insertion (l ∘ poly.coeff p) q' = insertion (l ∘ root) q" proof (-) (*goal: ‹(⋀q'. ⟦vars q' ⊆ {0..<n}; ⋀m. MPoly_Type.coeff q' m ∈ C; insertion (l ∘ poly.coeff p) q' = insertion (l ∘ root) q⟧ ⟹ thesis) ⟹ thesis›*) define q' where "q' = fund_sym_poly_wit A q" define q'' where "q'' = mapm_mpoly (λm x. (∏i. (cinv * l (- 1) ^ i) ^ lookup m i) * insertion (λ_. 0) x) q'" define reindex where "reindex = (λi. if i ≤ n then n - i else i)" have "bij reindex" apply (intro bij_betwI[of reindex _ _ reindex] (*‹⟦reindex ∈ ?A → ?B; reindex ∈ ?B → ?A; ⋀x. x ∈ ?A ⟹ reindex (reindex x) = x; ⋀y. y ∈ ?B ⟹ reindex (reindex y) = y⟧ ⟹ bij_betw reindex ?A ?B›*)) (*goals: 1. ‹reindex ∈ UNIV → UNIV› 2. ‹reindex ∈ UNIV → UNIV› 3. ‹⋀x. x ∈ UNIV ⟹ reindex (reindex x) = x› 4. ‹⋀y. y ∈ UNIV ⟹ reindex (reindex y) = y› discuss goal 1*) apply ((auto simp: reindex_def (*‹reindex = (λi. if i ≤ n then n - i else i)›*))[1]) (*discuss goal 2*) apply ((auto simp: reindex_def (*‹reindex = (λi. if i ≤ n then n - i else i)›*))[1]) (*discuss goal 3*) apply ((auto simp: reindex_def (*‹reindex = (λi. if i ≤ n then n - i else i)›*))[1]) (*discuss goal 4*) apply ((auto simp: reindex_def (*‹reindex = (λi. if i ≤ n then n - i else i)›*))[1]) (*proven 4 subgoals*) . have "vars q' ⊆ {1..n}" unfolding q'_def n_def (*goal: ‹vars (fund_sym_poly_wit A q) ⊆ {1..card A}›*) by (intro fund_sym_poly_wit_vars (*‹vars (fund_sym_poly_wit ?A ?p) ⊆ {1..card ?A}›*)) hence "vars q'' ⊆ {1..n}" unfolding q''_def (*goal: ‹vars (mapm_mpoly (λ(m::nat ⇒₀ nat) x::'b mpoly. (∏i::nat. ((cinv::'b) * (l::'a ⇒ 'b) (- (1::'a)) ^ i) ^ lookup m i) * insertion (λ_::nat. 0::'b) x) (q'::'b mpoly mpoly)) ⊆ {1::nat..n::nat}›*) using vars_mapm_mpoly_subset (*‹vars (mapm_mpoly ?f ?p) ⊆ vars ?p›*) by auto have "insertion (l ∘ root) (insertion (sym_mpoly A) q') = insertion (λn. insertion (l ∘ root) (sym_mpoly A n)) (map_mpoly (insertion (l ∘ root)) q')" by (rule insertion_insertion (*‹insertion ?g (insertion ?k ?p) = insertion (λx. insertion ?g (?k x)) (map_mpoly (insertion ?g) ?p)›*)) also (*calculation: ‹insertion ((l::'a ⇒ 'b) ∘ (root::nat ⇒ 'a)) (insertion (sym_mpoly (A::nat set)) (q'::'b mpoly mpoly)) = insertion (λn::nat. insertion (l ∘ root) (sym_mpoly A n)) (map_mpoly (insertion (l ∘ root)) q')›*) have "insertion (sym_mpoly A) q' = q" unfolding q'_def (*goal: ‹insertion (sym_mpoly A) (fund_sym_poly_wit A q) = q›*) by (intro fund_sym_poly_wit_insertion (*‹symmetric_mpoly ?A ?p ⟹ insertion (sym_mpoly ?A) (fund_sym_poly_wit ?A ?p) = ?p›*) sym (*‹symmetric_mpoly A q›*)) also (*calculation: ‹insertion (l ∘ root) q = insertion (λn. insertion (l ∘ root) (sym_mpoly A n)) (map_mpoly (insertion (l ∘ root)) q')›*) have "insertion (λi. insertion (l ∘ root) (sym_mpoly A i)) (map_mpoly (insertion (l ∘ root)) q') = insertion (λi. cinv * l ((- 1) ^ i) * l (poly.coeff p (n - i))) (map_mpoly (insertion (l ∘ root)) q')" apply (intro insertion_irrelevant_vars (*‹(⋀v. v ∈ vars ?p ⟹ ?f v = ?g v) ⟹ insertion ?f ?p = insertion ?g ?p›*)) (*goal: ‹insertion (λi. insertion (l ∘ root) (sym_mpoly A i)) (map_mpoly (insertion (l ∘ root)) q') = insertion (λi. cinv * l ((- 1) ^ i) * l (poly.coeff p (n - i))) (map_mpoly (insertion (l ∘ root)) q')›*) proof (goal_cases) (*goal: ‹⋀v. v ∈ vars (map_mpoly (insertion (l ∘ root)) q') ⟹ insertion (l ∘ root) (sym_mpoly A v) = cinv * l ((- 1) ^ v) * l (poly.coeff p (n - v))›*) case (1 i) (*‹i ∈ vars (map_mpoly (insertion (l ∘ root)) q')›*) hence "i ∈ vars q'" using vars_map_mpoly_subset (*‹vars (map_mpoly ?f ?p) ⊆ vars ?p›*) by auto also (*calculation: ‹(i::nat) ∈ vars (q'::'b mpoly mpoly)›*) have "… ⊆ {1..n}" unfolding q'_def n_def (*goal: ‹vars (fund_sym_poly_wit A q) ⊆ {1..card A}›*) by (intro fund_sym_poly_wit_vars (*‹vars (fund_sym_poly_wit ?A ?p) ⊆ {1..card ?A}›*)) finally (*calculation: ‹i ∈ {1..n}›*) have i: "i ∈ {1..n}" . have "insertion (l ∘ root) (sym_mpoly A i) = l (∑Y | Y ⊆ A ∧ card Y = i. prod root Y)" using ‹finite A› (*‹finite A›*) by (simp add: insertion_sym_mpoly (*‹finite ?X ⟹ insertion ?f (sym_mpoly ?X ?k) = (∑Y | Y ⊆ ?X ∧ card Y = ?k. prod ?f Y)›*)) also (*calculation: ‹insertion (l ∘ root) (sym_mpoly A i) = l (∑Y | Y ⊆ A ∧ card Y = i. prod root Y)›*) have "… = cinv * l (c * (∑Y | Y ⊆ A ∧ card Y = i. prod root Y))" unfolding mult mult.assoc[symmetric] ‹cinv * l c = 1› (*goal: ‹l (∑Y | Y ⊆ A ∧ card Y = i. prod root Y) = 1 * l (sum (prod root) {Y. Y ⊆ A ∧ card Y = i})›*) by simp also (*calculation: ‹insertion (l ∘ root) (sym_mpoly A i) = cinv * l (c * (∑Y | Y ⊆ A ∧ card Y = i. prod root Y))›*) have "c * (∑Y | Y ⊆ A ∧ card Y = i. prod root Y) = ((-1) ^ i * poly.coeff p (n - i))" using coeff_poly_from_roots[of A "n - i" root] (*‹⟦finite (A::nat set); (n::nat) - (i::nat) ≤ card A⟧ ⟹ poly.coeff (∏x::nat∈A. [:- (root::nat ⇒ 'a) x, 1::'a:]) (n - i) = (- (1::'a)) ^ (card A - (n - i)) * (∑X::nat set | X ⊆ A ∧ card X = card A - (n - i). prod root X)›*) i (*‹(i::nat) ∈ {1::nat..n::nat}›*) assms (*‹cinv * l c = 1› ‹cinv ∈ C› ‹(p::'a::comm_ring_1 poly) = Polynomial.smult (c::'a::comm_ring_1) (∏i::nat∈(A::nat set). [:- (root::nat ⇒ 'a::comm_ring_1) i, 1::'a::comm_ring_1:])›*) finite (*‹finite A›*) by (auto simp: n_def (*‹n ≡ card A›*) minus_one_power_iff (*‹(- 1) ^ ?n = (if even ?n then 1 else - 1)›*)) finally (*calculation: ‹insertion ((l::'a::comm_ring_1 ⇒ 'b::comm_ring_1) ∘ (root::nat ⇒ 'a::comm_ring_1)) (sym_mpoly (A::nat set) (i::nat)) = (cinv::'b::comm_ring_1) * l ((- (1::'a::comm_ring_1)) ^ i * poly.coeff (p::'a::comm_ring_1 poly) ((n::nat) - i))›*) show "?case" (*goal: ‹insertion (l ∘ root) (sym_mpoly A i) = cinv * l ((- 1) ^ i) * l (poly.coeff p (n - i))›*) by (simp add: o_def (*‹?f ∘ ?g = (λx. ?f (?g x))›*)) qed also (*calculation: ‹insertion (l ∘ root) q = insertion (λi. cinv * l ((- 1) ^ i) * l (poly.coeff p (n - i))) (map_mpoly (insertion (l ∘ root)) q')›*) have "map_mpoly (insertion (l ∘ root)) q' = map_mpoly (insertion (λ_. 0)) q'" using fund_sym_poly_wit_coeffs[OF sym] (*‹vars (MPoly_Type.coeff (fund_sym_poly_wit A q) ?m) ⊆ vars q - A›*) vars (*‹vars (q::'b::comm_ring_1 mpoly) ⊆ (A::nat set)›*) apply (intro map_mpoly_cong (*‹⟦⋀m. ?f (MPoly_Type.coeff ?p m) = ?g (MPoly_Type.coeff ?p m); ?p = ?q⟧ ⟹ map_mpoly ?f ?p = map_mpoly ?g ?q›*) insertion_irrelevant_vars (*‹(⋀v. v ∈ vars ?p ⟹ ?f v = ?g v) ⟹ insertion ?f ?p = insertion ?g ?p›*)) (*goals: 1. ‹⋀m v. ⟦⋀m. vars (MPoly_Type.coeff (fund_sym_poly_wit A q) m) ⊆ vars q - A; vars q ⊆ A; v ∈ vars (MPoly_Type.coeff q' m)⟧ ⟹ (l ∘ root) v = 0› 2. ‹⟦⋀m. vars (MPoly_Type.coeff (fund_sym_poly_wit A q) m) ⊆ vars q - A; vars q ⊆ A⟧ ⟹ q' = q'› discuss goal 1*) apply ((auto simp: q'_def (*‹q' = fund_sym_poly_wit A q›*))[1]) (*discuss goal 2*) apply ((auto simp: q'_def (*‹(q'::'b::comm_ring_1 mpoly mpoly) = fund_sym_poly_wit (A::nat set) (q::'b::comm_ring_1 mpoly)›*))[1]) (*proven 2 subgoals*) . also (*calculation: ‹insertion ((l::'a ⇒ 'b) ∘ (root::nat ⇒ 'a)) (q::'b mpoly) = insertion (λi::nat. (cinv::'b) * l ((- (1::'a)) ^ i) * l (poly.coeff (p::'a poly) ((n::nat) - i))) (map_mpoly (insertion (λ_::nat. 0::'b)) (q'::'b mpoly mpoly))›*) have "insertion (λi. cinv * l ((- 1) ^ i) * l (poly.coeff p (n - i))) … = insertion (λi. l (poly.coeff p (n - i))) q''" unfolding insertion_substitute_linear map_mpoly_conv_mapm_mpoly q''_def (*goal: ‹insertion (λi. l (poly.coeff p (n - i))) (mapm_mpoly (λm. (*) (∏i. (cinv * l ((- 1) ^ i)) ^ lookup m i)) (mapm_mpoly (λ_. insertion (λ_. 0)) q')) = insertion (λi. l (poly.coeff p (n - i))) (mapm_mpoly (λm x. (∏i. (cinv * l (- 1) ^ i) ^ lookup m i) * insertion (λ_. 0) x) q')›*) apply (subst mapm_mpoly_comp (*‹(⋀x. ?f x 0 = 0) ⟹ mapm_mpoly ?f (mapm_mpoly ?g ?p) = mapm_mpoly (λm c. ?f m (?g m c)) ?p›*)) (*goals: 1. ‹⋀x. (∏i. (cinv * l ((- 1) ^ i)) ^ lookup x i) * 0 = 0› 2. ‹insertion (λi. l (poly.coeff p (n - i))) (mapm_mpoly (λm c. (∏i. (cinv * l ((- 1) ^ i)) ^ lookup m i) * insertion (λ_. 0) c) q') = insertion (λi. l (poly.coeff p (n - i))) (mapm_mpoly (λm x. (∏i. (cinv * l (- 1) ^ i) ^ lookup m i) * insertion (λ_. 0) x) q')› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . also (*calculation: ‹insertion (l ∘ root) q = insertion (λi. l (poly.coeff p (n - i))) q''›*) have "… = insertion (l ∘ poly.coeff p) (mpoly_map_vars reindex q'')" using ‹bij reindex› (*‹bij reindex›*) ‹vars q'' ⊆ {1..n}› (*‹vars (q''::'b::comm_ring_1 mpoly) ⊆ {1::nat..n::nat}›*) apply (subst insertion_mpoly_map_vars (*‹bij (?f::nat ⇒ nat) ⟹ insertion (?g::nat ⇒ ?'a) (mpoly_map_vars ?f (?p::?'a mpoly)) = insertion (?g ∘ ?f) ?p›*)) (*goals: 1. ‹⟦bij reindex; vars q'' ⊆ {1..n}⟧ ⟹ bij reindex› 2. ‹⟦bij reindex; vars q'' ⊆ {1..n}⟧ ⟹ insertion (λi. l (poly.coeff p (n - i))) q'' = insertion (l ∘ poly.coeff p ∘ reindex) q''› discuss goal 1*) apply ((auto simp: o_def (*‹?f ∘ ?g = (λx. ?f (?g x))›*) reindex_def (*‹reindex = (λi. if i ≤ n then n - i else i)›*) intro!: insertion_irrelevant_vars (*‹(⋀v. v ∈ vars ?p ⟹ ?f v = ?g v) ⟹ insertion ?f ?p = insertion ?g ?p›*))[1]) (*discuss goal 2*) apply ((auto simp: o_def (*‹?f ∘ ?g = (λx. ?f (?g x))›*) reindex_def (*‹reindex = (λi. if i ≤ n then n - i else i)›*) intro!: insertion_irrelevant_vars (*‹(⋀v. v ∈ vars ?p ⟹ ?f v = ?g v) ⟹ insertion ?f ?p = insertion ?g ?p›*))[1]) (*proven 2 subgoals*) . finally (*calculation: ‹insertion (l ∘ root) q = insertion (l ∘ poly.coeff p) (mpoly_map_vars reindex q'')›*) have "insertion (l ∘ root) q = insertion (l ∘ poly.coeff p) (mpoly_map_vars reindex q'')" . moreover have "coeff (mpoly_map_vars reindex q'') m ∈ C" for m unfolding q''_def q'_def (*goal: ‹MPoly_Type.coeff (mpoly_map_vars reindex (mapm_mpoly (λm x. (∏i. (cinv * l (- 1) ^ i) ^ lookup m i) * insertion (λ_. 0) x) (fund_sym_poly_wit A q))) m ∈ C›*) using ‹bij reindex› (*‹bij reindex›*) fund_sym_poly_wit_coeff[of q C A] (*‹⟦∀m. MPoly_Type.coeff q m ∈ C; ring_closed C⟧ ⟹ ∀m m'. MPoly_Type.coeff (MPoly_Type.coeff (fund_sym_poly_wit A q) m) m' ∈ C›*) C (*‹ring_closed C› ‹∀m::nat ⇒₀ nat. MPoly_Type.coeff (q::'b mpoly) m ∈ (C::'b set)›*) ‹cinv ∈ C› (*‹cinv ∈ C›*) by (auto simp: coeff_mpoly_map_vars (*‹bij ?f ⟹ MPoly_Type.coeff (mpoly_map_vars ?f ?p) ?mon = MPoly_Type.coeff ?p (permutep ?f ?mon)›*) intro!: mult_closed (*‹⟦?x ∈ C; ?y ∈ C⟧ ⟹ ?x * ?y ∈ C›*) Prod_any_closed (*‹(⋀x. ?f x ∈ C) ⟹ Prod_any ?f ∈ C›*) power_closed (*‹?x ∈ C ⟹ ?x ^ ?n ∈ C›*) Sum_any_closed (*‹(⋀x. ?f x ∈ C) ⟹ Sum_any ?f ∈ C›*)) moreover have "vars (mpoly_map_vars reindex q'') ⊆ {0..<n}" using ‹bij reindex› (*‹bij reindex›*) ‹vars q'' ⊆ {1..n}› (*‹vars q'' ⊆ {1..n}›*) apply (subst vars_mpoly_map_vars (*‹bij ?f ⟹ vars (mpoly_map_vars ?f ?p) = ?f ` vars ?p›*)) (*goals: 1. ‹⟦bij (reindex::nat ⇒ nat); vars (q''::'b mpoly) ⊆ {1::nat..n::nat}⟧ ⟹ bij reindex› 2. ‹⟦bij (reindex::nat ⇒ nat); vars (q''::'b mpoly) ⊆ {1::nat..n::nat}⟧ ⟹ reindex ` vars q'' ⊆ {0::nat..<n}› discuss goal 1*) apply ((auto simp: reindex_def (*‹reindex = (λi. if i ≤ n then n - i else i)›*) subset_iff (*‹(?A ⊆ ?B) = (∀t. t ∈ ?A ⟶ t ∈ ?B)›*))[1]) (*discuss goal 2*) apply ((auto simp: reindex_def (*‹reindex = (λi. if i ≤ n then n - i else i)›*) subset_iff (*‹(?A ⊆ ?B) = (∀t. t ∈ ?A ⟶ t ∈ ?B)›*))[1]) (*proven 2 subgoals*) . ultimately show "?thesis" (*goal: ‹thesis›*) using that[of "mpoly_map_vars reindex q''"] (*‹⟦vars (mpoly_map_vars reindex q'') ⊆ {0..<n}; ⋀m. MPoly_Type.coeff (mpoly_map_vars reindex q'') m ∈ C; insertion (l ∘ poly.coeff p) (mpoly_map_vars reindex q'') = insertion (l ∘ root) q⟧ ⟹ thesis›*) by auto qed corollary symmetric_poly_of_roots_conv_poly_of_coeffs_monic: assumes "p = (∏i∈A. [:-root i, 1:])" obtains q' where "vars q' ⊆ {0..<n}" and "⋀m. coeff q' m ∈ C" and "insertion (l ∘ poly.coeff p) q' = insertion (l ∘ root) q" proof (-) (*goal: ‹(⋀q'::'b mpoly. ⟦vars q' ⊆ {0::nat..<n::nat}; ⋀m::nat ⇒₀ nat. MPoly_Type.coeff q' m ∈ (C::'b set); insertion ((l::'a ⇒ 'b) ∘ poly.coeff (p::'a poly)) q' = insertion (l ∘ (root::nat ⇒ 'a)) (q::'b mpoly)⟧ ⟹ thesis::bool) ⟹ thesis›*) obtain q' where "vars q' ⊆ {0..<n}" and "⋀m. coeff q' m ∈ C" and "insertion (l ∘ poly.coeff p) q' = insertion (l ∘ root) q" (*goal: ‹(⋀q'::'b mpoly. ⟦vars q' ⊆ {0::nat..<n::nat}; ⋀m::nat ⇒₀ nat. MPoly_Type.coeff q' m ∈ (C::'b set); insertion ((l::'a ⇒ 'b) ∘ poly.coeff (p::'a poly)) q' = insertion (l ∘ (root::nat ⇒ 'a)) (q::'b mpoly)⟧ ⟹ thesis::bool) ⟹ thesis›*) apply (rule symmetric_poly_of_roots_conv_poly_of_coeffs[of 1 1 p] (*‹⟦1 * l 1 = 1; 1 ∈ C; p = Polynomial.smult 1 (∏i∈A. [:- root i, 1:]); ⋀q'. ⟦vars q' ⊆ {0..<n}; ⋀m. MPoly_Type.coeff q' m ∈ C; insertion (l ∘ poly.coeff p) q' = insertion (l ∘ root) q⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*)) (*goals: 1. ‹(⋀q'. ⟦vars q' ⊆ {0..<n}; ⋀m. MPoly_Type.coeff q' m ∈ C; insertion (l ∘ poly.coeff p) q' = insertion (l ∘ root) q⟧ ⟹ thesis) ⟹ 1 * l 1 = 1› 2. ‹(⋀q'. ⟦vars q' ⊆ {0..<n}; ⋀m. MPoly_Type.coeff q' m ∈ C; insertion (l ∘ poly.coeff p) q' = insertion (l ∘ root) q⟧ ⟹ thesis) ⟹ 1 ∈ C› 3. ‹(⋀q'. ⟦vars q' ⊆ {0..<n}; ⋀m. MPoly_Type.coeff q' m ∈ C; insertion (l ∘ poly.coeff p) q' = insertion (l ∘ root) q⟧ ⟹ thesis) ⟹ p = Polynomial.smult 1 (∏i∈A. [:- root i, 1:])› 4. ‹⋀q'. ⟦⋀q'. ⟦vars q' ⊆ {0..<n}; ⋀m. MPoly_Type.coeff q' m ∈ C; insertion (l ∘ poly.coeff p) q' = insertion (l ∘ root) q⟧ ⟹ thesis; vars q' ⊆ {0..<n}; ⋀m. MPoly_Type.coeff q' m ∈ C; insertion (l ∘ poly.coeff p) q' = insertion (l ∘ root) q⟧ ⟹ thesis› discuss goal 1*) apply ((use assms in auto)[1]) (*discuss goal 2*) apply ((use assms in auto)[1]) (*discuss goal 3*) apply ((use assms in auto)[1]) (*discuss goal 4*) apply ((use assms in auto)[1]) (*proven 4 subgoals*) . thus "?thesis" (*goal: ‹thesis›*) apply (intro that[of q'] (*‹⟦vars q' ⊆ {0..<n}; ⋀m. MPoly_Type.coeff q' m ∈ C; insertion (l ∘ poly.coeff p) q' = insertion (l ∘ root) q⟧ ⟹ thesis›*)) (*goals: 1. ‹⟦vars q' ⊆ {0..<n}; ⋀m. MPoly_Type.coeff q' m ∈ C; insertion (l ∘ poly.coeff p) q' = insertion (l ∘ root) q⟧ ⟹ vars q' ⊆ {0..<n}› 2. ‹⋀m. ⟦vars q' ⊆ {0..<n}; ⋀m. MPoly_Type.coeff q' m ∈ C; insertion (l ∘ poly.coeff p) q' = insertion (l ∘ root) q⟧ ⟹ MPoly_Type.coeff q' m ∈ C› 3. ‹⟦vars q' ⊆ {0..<n}; ⋀m. MPoly_Type.coeff q' m ∈ C; insertion (l ∘ poly.coeff p) q' = insertion (l ∘ root) q⟧ ⟹ insertion (l ∘ poly.coeff p) q' = insertion (l ∘ root) q› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*proven 3 subgoals*) . qed text ‹ As a corollary, we obtain the following: Let $R, S$ be rings with $R\subseteq S$. Consider a polynomial $p\in R[X]$ whose leading coefficient $c$ is a unit in $R$ and that has a full set of roots $x_1,\ldots, x_n \in S$, i.\,e.\ $p(X) = c(X - x_1) \ldots (X - x_n)$. Let $q \in R[X_1,\ldots, X_n]$ be some symmetric polynomial expression in the roots. Then $q(x_1, \ldots, x_n) \in R$. A typical use case is $R = \mathbb{Q}$ and $S = \mathbb{C}$, i.\,e.\ any symmetric polynomial expression with rational coefficients in the roots of a rational polynomial is again rational. Similarly, any symmetric polynomial expression with integer coefficients in the roots of a monic integer polynomial is agan an integer. This is remarkable, since the roots themselves are usually not rational (possibly not even real). This particular fact is a key ingredient used in the standard proof that $\pi$ is transcendental. › corollary symmetric_poly_of_roots_in_subring: assumes "cinv * l c = 1" "cinv ∈ C" assumes "p = Polynomial.smult c (∏i∈A. [:-root i, 1:])" assumes "∀i. l (poly.coeff p i) ∈ C" shows "insertion (λx. l (root x)) q ∈ C" proof (-) (*goal: ‹insertion (λx. l (root x)) q ∈ C›*) obtain q' where q': "vars q' ⊆ {0..<n}" "⋀m. coeff q' m ∈ C" "insertion (l ∘ poly.coeff p) q' = insertion (l ∘ root) q" (*goal: ‹(⋀q'::'b mpoly. ⟦vars q' ⊆ {0::nat..<n::nat}; ⋀m::nat ⇒₀ nat. MPoly_Type.coeff q' m ∈ (C::'b set); insertion ((l::'a ⇒ 'b) ∘ poly.coeff (p::'a poly)) q' = insertion (l ∘ (root::nat ⇒ 'a)) (q::'b mpoly)⟧ ⟹ thesis::bool) ⟹ thesis›*) apply (rule symmetric_poly_of_roots_conv_poly_of_coeffs[of cinv c p] (*‹⟦cinv * l c = 1; cinv ∈ C; p = Polynomial.smult c (∏i∈A. [:- root i, 1:]); ⋀q'. ⟦vars q' ⊆ {0..<n}; ⋀m. MPoly_Type.coeff q' m ∈ C; insertion (l ∘ poly.coeff p) q' = insertion (l ∘ root) q⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*)) (*goals: 1. ‹(⋀q'. ⟦vars q' ⊆ {0..<n}; ⋀m. MPoly_Type.coeff q' m ∈ C; insertion (l ∘ poly.coeff p) q' = insertion (l ∘ root) q⟧ ⟹ thesis) ⟹ cinv * l c = 1› 2. ‹(⋀q'. ⟦vars q' ⊆ {0..<n}; ⋀m. MPoly_Type.coeff q' m ∈ C; insertion (l ∘ poly.coeff p) q' = insertion (l ∘ root) q⟧ ⟹ thesis) ⟹ cinv ∈ C› 3. ‹(⋀q'. ⟦vars q' ⊆ {0..<n}; ⋀m. MPoly_Type.coeff q' m ∈ C; insertion (l ∘ poly.coeff p) q' = insertion (l ∘ root) q⟧ ⟹ thesis) ⟹ p = Polynomial.smult c (∏i∈A. [:- root i, 1:])› 4. ‹⋀q'. ⟦⋀q'. ⟦vars q' ⊆ {0..<n}; ⋀m. MPoly_Type.coeff q' m ∈ C; insertion (l ∘ poly.coeff p) q' = insertion (l ∘ root) q⟧ ⟹ thesis; vars q' ⊆ {0..<n}; ⋀m. MPoly_Type.coeff q' m ∈ C; insertion (l ∘ poly.coeff p) q' = insertion (l ∘ root) q⟧ ⟹ thesis› discuss goal 1*) apply ((use assms in simp_all)[1]) (*discuss goal 2*) apply ((use assms in simp_all)[1]) (*discuss goal 3*) apply ((use assms in simp_all)[1]) (*discuss goal 4*) apply ((use assms in simp_all)[1]) (*proven 4 subgoals*) . have "insertion (l ∘ poly.coeff p) q' ∈ C" using C (*‹ring_closed C› ‹∀m. MPoly_Type.coeff q m ∈ C›*) assms (*‹cinv * l c = 1› ‹cinv ∈ C› ‹(p::'a poly) = Polynomial.smult (c::'a) (∏i::nat∈(A::nat set). [:- (root::nat ⇒ 'a) i, 1::'a:])› ‹∀i. l (poly.coeff p i) ∈ C›*) unfolding insertion_altdef (*goal: ‹(∑m::nat ⇒₀ nat. MPoly_Type.coeff (q'::'b mpoly) m * (∏i::nat. ((l::'a ⇒ 'b) ∘ poly.coeff (p::'a poly)) i ^ lookup m i)) ∈ (C::'b set)›*) apply (intro Sum_any_closed (*‹(⋀x. ?f x ∈ C) ⟹ Sum_any ?f ∈ C›*) mult_closed (*‹⟦?x ∈ C; ?y ∈ C⟧ ⟹ ?x * ?y ∈ C›*) q' (*‹vars q' ⊆ {0..<n}› ‹MPoly_Type.coeff q' ?m ∈ C› ‹insertion (l ∘ poly.coeff p) q' = insertion (l ∘ root) q›*) Prod_any_closed (*‹(⋀x. ?f x ∈ C) ⟹ Prod_any ?f ∈ C›*) power_closed (*‹?x ∈ C ⟹ ?x ^ ?n ∈ C›*)) (*goal: ‹(∑m. MPoly_Type.coeff q' m * (∏i. (l ∘ poly.coeff p) i ^ lookup m i)) ∈ C›*) by auto also (*calculation: ‹insertion (l ∘ poly.coeff p) q' ∈ C›*) have "insertion (l ∘ poly.coeff p) q' = insertion (l ∘ root) q" by fact finally (*calculation: ‹insertion (l ∘ root) q ∈ C›*) show "?thesis" (*goal: ‹insertion (λx. l (root x)) q ∈ C›*) by (simp add: o_def (*‹?f ∘ ?g = (λx. ?f (?g x))›*)) qed corollary symmetric_poly_of_roots_in_subring_monic: assumes "p = (∏i∈A. [:-root i, 1:])" assumes "∀i. l (poly.coeff p i) ∈ C" shows "insertion (λx. l (root x)) q ∈ C" proof (-) (*goal: ‹insertion (λx. l (root x)) q ∈ C›*) interpret ring_closed C by fact interpret ring_homomorphism l by fact show "?thesis" (*goal: ‹insertion (λx. l (root x)) q ∈ C›*) apply (rule symmetric_poly_of_roots_in_subring[of 1 1 p] (*‹⟦(1::'b::comm_ring_1) * (l::'a::comm_ring_1 ⇒ 'b::comm_ring_1) (1::'a::comm_ring_1) = (1::'b::comm_ring_1); (1::'b::comm_ring_1) ∈ (C::'b::comm_ring_1 set); (p::'a::comm_ring_1 poly) = Polynomial.smult (1::'a::comm_ring_1) (∏i::nat∈(A::nat set). [:- (root::nat ⇒ 'a::comm_ring_1) i, 1::'a::comm_ring_1:]); ∀i::nat. l (poly.coeff p i) ∈ C⟧ ⟹ insertion (λx::nat. l (root x)) (q::'b::comm_ring_1 mpoly) ∈ C›*)) (*goals: 1. ‹(1::'b::comm_ring_1) * (l::'a::comm_ring_1 ⇒ 'b::comm_ring_1) (1::'a::comm_ring_1) = (1::'b::comm_ring_1)› 2. ‹(1::'b::comm_ring_1) ∈ (C::'b::comm_ring_1 set)› 3. ‹(p::'a::comm_ring_1 poly) = Polynomial.smult (1::'a::comm_ring_1) (∏i::nat∈(A::nat set). [:- (root::nat ⇒ 'a::comm_ring_1) i, 1::'a::comm_ring_1:])› 4. ‹∀i::nat. (l::'a::comm_ring_1 ⇒ 'b::comm_ring_1) (poly.coeff (p::'a::comm_ring_1 poly) i) ∈ (C::'b::comm_ring_1 set)› discuss goal 1*) apply ((use assms in auto)[1]) (*discuss goal 2*) apply ((use assms in auto)[1]) (*discuss goal 3*) apply ((use assms in auto)[1]) (*discuss goal 4*) apply ((use assms in auto)[1]) (*proven 4 subgoals*) . qed end end
{ "path": "afp-2025-02-12/thys/Symmetric_Polynomials/Symmetric_Polynomials.thy", "repo": "afp-2025-02-12", "sha": "3d2d077f57ab8891f66e9c66ed6398987e606e75dc9e6dcbf8f007005abff0f7" }
section ‹Trees› theory Tree imports Main begin text ‹Sometimes it is nice to think of @{typ bool}s as directions in a binary tree› hide_const (open) Left Right type_synonym dir = bool definition Left :: bool where "Left = True" definition Right :: bool where "Right = False" declare Left_def [simp] declare Right_def [simp] datatype tree = Leaf | Branching (ltree: tree) (rtree: tree) subsection ‹Sizes› fun treesize :: "tree ⇒ nat" where "treesize Leaf = 0" | "treesize (Branching l r) = 1 + treesize l + treesize r" lemma treesize_Leaf: assumes "treesize T = 0" shows "T = Leaf" using assms (*‹treesize T = 0›*) apply (cases T) (*goals: 1. ‹⟦treesize T = 0; T = Leaf⟧ ⟹ T = Leaf› 2. ‹⋀x21 x22. ⟦treesize T = 0; T = Branching x21 x22⟧ ⟹ T = Leaf› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . lemma treesize_Branching: assumes "treesize T = Suc n" shows "∃l r. T = Branching l r" using assms (*‹treesize T = Suc n›*) apply (cases T) (*goals: 1. ‹⟦treesize T = Suc n; T = Leaf⟧ ⟹ ∃l r. T = Branching l r› 2. ‹⋀x21 x22. ⟦treesize T = Suc n; T = Branching x21 x22⟧ ⟹ ∃l r. T = Branching l r› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . subsection ‹Paths› fun path :: "dir list ⇒ tree ⇒ bool" where "path [] T ⟷ True" | "path (d#ds) (Branching T1 T2) ⟷ (if d then path ds T1 else path ds T2)" | "path _ _ ⟷ False" lemma path_inv_Leaf: "path p Leaf ⟷ p = []" apply (induction p) (*goals: 1. ‹path [] Leaf = ([] = [])› 2. ‹⋀a p. path p Leaf = (p = []) ⟹ path (a # p) Leaf = (a # p = [])› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . lemma path_inv_Cons: "path (a#ds) T ⟶ (∃l r. T=Branching l r)" apply (cases T) (*goals: 1. ‹T = Leaf ⟹ path (a # ds) T ⟶ (∃l r. T = Branching l r)› 2. ‹⋀x21 x22. T = Branching x21 x22 ⟹ path (a # ds) T ⟶ (∃l r. T = Branching l r)› discuss goal 1*) apply ((auto simp add: path_inv_Leaf (*‹path ?p Leaf = (?p = [])›*))[1]) (*discuss goal 2*) apply ((auto simp add: path_inv_Leaf (*‹path ?p Leaf = (?p = [])›*))[1]) (*proven 2 subgoals*) . lemma path_inv_Branching_Left: "path (Left#p) (Branching l r) ⟷ path p l" using Left_def (*‹Left = True›*) Right_def (*‹Right = False›*) path.cases (*‹⟦⋀T. ?x = ([], T) ⟹ ?P; ⋀d ds T1 T2. ?x = (d # ds, Branching T1 T2) ⟹ ?P; ⋀v va. ?x = (v # va, Leaf) ⟹ ?P⟧ ⟹ ?P›*) apply (induction p) (*goals: 1. ‹⟦Left = True; Right = False; ⋀x P. ⟦⋀T. x = ([], T) ⟹ P; ⋀d ds T1 T2. x = (d # ds, Branching T1 T2) ⟹ P; ⋀v va. x = (v # va, Leaf) ⟹ P⟧ ⟹ P⟧ ⟹ path [Left] (Branching l r) = path [] l› 2. ‹⋀a p. ⟦⟦Left = True; Right = False; ⋀x P. ⟦⋀T. x = ([], T) ⟹ P; ⋀d ds T1 T2. x = (d # ds, Branching T1 T2) ⟹ P; ⋀v va. x = (v # va, Leaf) ⟹ P⟧ ⟹ P⟧ ⟹ path (Left # p) (Branching l r) = path p l; Left = True; Right = False; ⋀x P. ⟦⋀T. x = ([], T) ⟹ P; ⋀d ds T1 T2. x = (d # ds, Branching T1 T2) ⟹ P; ⋀v va. x = (v # va, Leaf) ⟹ P⟧ ⟹ P⟧ ⟹ path (Left # a # p) (Branching l r) = path (a # p) l› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . lemma path_inv_Branching_Right: "path (Right#p) (Branching l r) ⟷ path p r" using Left_def (*‹Left = True›*) Right_def (*‹Right = False›*) path.cases (*‹⟦⋀T. ?x = ([], T) ⟹ ?P; ⋀d ds T1 T2. ?x = (d # ds, Branching T1 T2) ⟹ ?P; ⋀v va. ?x = (v # va, Leaf) ⟹ ?P⟧ ⟹ ?P›*) apply (induction p) (*goals: 1. ‹⟦Left = True; Right = False; ⋀(x::bool list × tree) P::bool. ⟦⋀T::tree. x = ([], T) ⟹ P; ⋀(d::bool) (ds::bool list) (T1::tree) T2::tree. x = (d # ds, Branching T1 T2) ⟹ P; ⋀(v::bool) va::bool list. x = (v # va, Leaf) ⟹ P⟧ ⟹ P⟧ ⟹ path [Right] (Branching (l::tree) (r::tree)) = path [] r› 2. ‹⋀(a::bool) p::bool list. ⟦⟦Left = True; Right = False; ⋀(x::bool list × tree) P::bool. ⟦⋀T::tree. x = ([], T) ⟹ P; ⋀(d::bool) (ds::bool list) (T1::tree) T2::tree. x = (d # ds, Branching T1 T2) ⟹ P; ⋀(v::bool) va::bool list. x = (v # va, Leaf) ⟹ P⟧ ⟹ P⟧ ⟹ path (Right # p) (Branching (l::tree) (r::tree)) = path p r; Left = True; Right = False; ⋀(x::bool list × tree) P::bool. ⟦⋀T::tree. x = ([], T) ⟹ P; ⋀(d::bool) (ds::bool list) (T1::tree) T2::tree. x = (d # ds, Branching T1 T2) ⟹ P; ⋀(v::bool) va::bool list. x = (v # va, Leaf) ⟹ P⟧ ⟹ P⟧ ⟹ path (Right # a # p) (Branching l r) = path (a # p) r› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . lemma path_inv_Branching: "path p (Branching l r) ⟷ (p=[] ∨ (∃a p'. p=a#p'∧ (a ⟶ path p' l) ∧ (¬a ⟶ path p' r)))" (is "?L ⟷ ?R") proof (standard) (*goals: 1. ‹path p (Branching l r) ⟹ p = [] ∨ (∃a p'. p = a # p' ∧ (a ⟶ path p' l) ∧ (¬ a ⟶ path p' r))› 2. ‹p = [] ∨ (∃a p'. p = a # p' ∧ (a ⟶ path p' l) ∧ (¬ a ⟶ path p' r)) ⟹ path p (Branching l r)›*) assume "?L" (*‹path (p::bool list) (Branching (l::tree) (r::tree))›*) then show "?R" apply (induction p) (*goals: 1. ‹path [] (Branching l r) ⟹ [] = [] ∨ (∃a p'. [] = a # p' ∧ (a ⟶ path p' l) ∧ (¬ a ⟶ path p' r))› 2. ‹⋀a p. ⟦path p (Branching l r) ⟹ p = [] ∨ (∃a p'. p = a # p' ∧ (a ⟶ path p' l) ∧ (¬ a ⟶ path p' r)); path (a # p) (Branching l r)⟧ ⟹ a # p = [] ∨ (∃aa p'. a # p = aa # p' ∧ (aa ⟶ path p' l) ∧ (¬ aa ⟶ path p' r))› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . next (*goal: ‹p = [] ∨ (∃a p'. p = a # p' ∧ (a ⟶ path p' l) ∧ (¬ a ⟶ path p' r)) ⟹ path p (Branching l r)›*) assume r: "?R" (*‹(p::bool list) = [] ∨ (∃(a::bool) p'::bool list. p = a # p' ∧ (a ⟶ path p' (l::tree)) ∧ (¬ a ⟶ path p' (r::tree)))›*) then show "?L" proof (standard) (*goals: 1. ‹p = [] ⟹ path p (Branching l r)› 2. ‹∃a p'. p = a # p' ∧ (a ⟶ path p' l) ∧ (¬ a ⟶ path p' r) ⟹ path p (Branching l r)›*) assume "p = []" (*‹(p::bool list) = []›*) then show "?L" by auto next (*goal: ‹∃a p'. p = a # p' ∧ (a ⟶ path p' l) ∧ (¬ a ⟶ path p' r) ⟹ path p (Branching l r)›*) assume "∃a p'. p=a#p'∧ (a ⟶ path p' l) ∧ (¬a ⟶ path p' r)" (*‹∃(a::bool) p'::bool list. (p::bool list) = a # p' ∧ (a ⟶ path p' (l::tree)) ∧ (¬ a ⟶ path p' (r::tree))›*) then obtain a and p' where "p=a#p'∧ (a ⟶ path p' l) ∧ (¬a ⟶ path p' r)" (*goal: ‹(⋀a p'. p = a # p' ∧ (a ⟶ path p' l) ∧ (¬ a ⟶ path p' r) ⟹ thesis) ⟹ thesis›*) by auto then show "?L" apply (cases a) (*goals: 1. ‹⟦(p::bool list) = (a::bool) # (p'::bool list) ∧ (a ⟶ path p' (l::tree)) ∧ (¬ a ⟶ path p' (r::tree)); a⟧ ⟹ path p (Branching l r)› 2. ‹⟦(p::bool list) = (a::bool) # (p'::bool list) ∧ (a ⟶ path p' (l::tree)) ∧ (¬ a ⟶ path p' (r::tree)); ¬ a⟧ ⟹ path p (Branching l r)› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . qed qed lemma path_prefix: assumes "path (ds1@ds2) T" shows "path ds1 T" using assms (*‹path (ds1 @ ds2) T›*) proof (induction ds1 arbitrary: T) (*goals: 1. ‹⋀T. path ([] @ ds2) T ⟹ path [] T› 2. ‹⋀a ds1 T. ⟦⋀T. path (ds1 @ ds2) T ⟹ path ds1 T; path ((a # ds1) @ ds2) T⟧ ⟹ path (a # ds1) T›*) case (Cons a ds1) (*‹path ((ds1::bool list) @ (ds2::bool list)) (?T::tree) ⟹ path ds1 ?T› ‹path ((a # ds1) @ ds2) T›*) then have "∃l r. T = Branching l r" using path_inv_Leaf (*‹path ?p Leaf = (?p = [])›*) apply (cases T) (*goals: 1. ‹⟦⋀T::tree. path ((ds1::bool list) @ (ds2::bool list)) T ⟹ path ds1 T; path (((a::bool) # ds1) @ ds2) (T::tree); ⋀p::bool list. path p Leaf = (p = []); T = Leaf⟧ ⟹ ∃(l::tree) r::tree. T = Branching l r› 2. ‹⋀(x21::tree) x22::tree. ⟦⋀T::tree. path ((ds1::bool list) @ (ds2::bool list)) T ⟹ path ds1 T; path (((a::bool) # ds1) @ ds2) (T::tree); ⋀p::bool list. path p Leaf = (p = []); T = Branching x21 x22⟧ ⟹ ∃(l::tree) r::tree. T = Branching l r› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . then obtain l and r where p_lr: "T = Branching l r" (*goal: ‹(⋀l r. T = Branching l r ⟹ thesis) ⟹ thesis›*) by auto show "?case" (*goal: ‹path ((a::bool) # (ds1::bool list)) (T::tree)›*) proof (cases a) (*goals: 1. ‹a::bool ⟹ path (a # (ds1::bool list)) (T::tree)› 2. ‹¬ (a::bool) ⟹ path (a # (ds1::bool list)) (T::tree)›*) assume atrue: a (*‹a::bool›*) then have "path ((ds1) @ ds2) l" using p_lr (*‹T = Branching l r›*) Cons(2) (*‹path ((a # ds1) @ ds2) T›*) path_inv_Branching (*‹path ?p (Branching ?l ?r) = (?p = [] ∨ (∃a p'. ?p = a # p' ∧ (a ⟶ path p' ?l) ∧ (¬ a ⟶ path p' ?r)))›*) by auto then have "path ds1 l" using Cons(1) (*‹path (ds1 @ ds2) ?T ⟹ path ds1 ?T›*) by auto then show "path (a # ds1) T" using p_lr (*‹T = Branching l r›*) atrue (*‹a::bool›*) by auto next (*goal: ‹¬ a ⟹ path (a # ds1) T›*) assume afalse: "¬a" (*‹¬ (a::bool)›*) then have "path ((ds1) @ ds2) r" using p_lr (*‹T = Branching l r›*) Cons(2) (*‹path (((a::bool) # (ds1::bool list)) @ (ds2::bool list)) (T::tree)›*) path_inv_Branching (*‹path ?p (Branching ?l ?r) = (?p = [] ∨ (∃a p'. ?p = a # p' ∧ (a ⟶ path p' ?l) ∧ (¬ a ⟶ path p' ?r)))›*) by auto then have "path ds1 r" using Cons(1) (*‹path (ds1 @ ds2) ?T ⟹ path ds1 ?T›*) by auto then show "path (a # ds1) T" using p_lr (*‹T = Branching l r›*) afalse (*‹¬ (a::bool)›*) by auto qed next (*goal: ‹⋀T. path ([] @ ds2) T ⟹ path [] T›*) case Nil (*‹path ([] @ ds2) T›*) then show "?case" (*goal: ‹path [] (T::tree)›*) by auto qed subsection ‹Branches› fun branch :: "dir list ⇒ tree ⇒ bool" where "branch [] Leaf ⟷ True" | "branch (d # ds) (Branching l r) ⟷ (if d then branch ds l else branch ds r)" | "branch _ _ ⟷ False" lemma has_branch: "∃b. branch b T" proof (induction T) (*goals: 1. ‹∃b::bool list. branch b Leaf› 2. ‹⋀(T1::tree) T2::tree. ⟦∃b::bool list. branch b T1; ∃b::bool list. branch b T2⟧ ⟹ ∃b::bool list. branch b (Branching T1 T2)›*) case Leaf (*no hyothesis introduced yet*) have "branch [] Leaf" by auto then show "?case" (*goal: ‹∃b. branch b Leaf›*) by blast next (*goal: ‹⋀T1 T2. ⟦∃b. branch b T1; ∃b. branch b T2⟧ ⟹ ∃b. branch b (Branching T1 T2)›*) case (Branching T₁ T₂) (*‹∃b. branch b T₁› ‹∃b. branch b T₂›*) then obtain b where "branch b T₁" (*goal: ‹(⋀b. branch b T₁ ⟹ thesis) ⟹ thesis›*) by auto then have "branch (Left#b) (Branching T₁ T₂)" by auto then show "?case" (*goal: ‹∃b. branch b (Branching T₁ T₂)›*) by blast qed lemma branch_inv_Leaf: "branch b Leaf ⟷ b = []" apply (cases b) (*goals: 1. ‹(b::bool list) = [] ⟹ branch b Leaf = (b = [])› 2. ‹⋀(a::bool) list::bool list. (b::bool list) = a # list ⟹ branch b Leaf = (b = [])› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . lemma branch_inv_Branching_Left: "branch (Left#b) (Branching l r) ⟷ branch b l" by auto lemma branch_inv_Branching_Right: "branch (Right#b) (Branching l r) ⟷ branch b r" sorry lemma branch_inv_Branching: "branch b (Branching l r) ⟷ (∃a b'. b=a#b'∧ (a ⟶ branch b' l) ∧ (¬a ⟶ branch b' r))" apply (induction b) (*goals: 1. ‹branch [] (Branching l r) = (∃a b'. [] = a # b' ∧ (a ⟶ branch b' l) ∧ (¬ a ⟶ branch b' r))› 2. ‹⋀a b. branch b (Branching l r) = (∃a b'. b = a # b' ∧ (a ⟶ branch b' l) ∧ (¬ a ⟶ branch b' r)) ⟹ branch (a # b) (Branching l r) = (∃aa b'. a # b = aa # b' ∧ (aa ⟶ branch b' l) ∧ (¬ aa ⟶ branch b' r))› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . lemma branch_inv_Leaf2: "T = Leaf ⟷ (∀b. branch b T ⟶ b = [])" proof (-) (*goal: ‹((T::tree) = Leaf) = (∀b::bool list. branch b T ⟶ b = [])›*) { assume "T=Leaf" (*‹(T::tree) = Leaf›*) then have "∀b. branch b T ⟶ b = []" using branch_inv_Leaf (*‹branch ?b Leaf = (?b = [])›*) by auto } moreover { assume "∀b. branch b T ⟶ b = []" (*‹∀b::bool list. branch b (T::tree) ⟶ b = []›*) then have "∀b. branch b T ⟶ ¬(∃a b'. b = a # b')" by auto then have "∀b. branch b T ⟶ ¬(∃l r. branch b (Branching l r))" using branch_inv_Branching (*‹branch ?b (Branching ?l ?r) = (∃a b'. ?b = a # b' ∧ (a ⟶ branch b' ?l) ∧ (¬ a ⟶ branch b' ?r))›*) by auto then have "T=Leaf" using has_branch[of T] (*‹∃b. branch b T›*) by (metis branch.elims( (*‹⟦branch (?x::bool list) (?xa::tree); ⟦?x = []; ?xa = Leaf⟧ ⟹ ?P::bool; ⋀(d::bool) (ds::bool list) (l::tree) r::tree. ⟦?x = d # ds; ?xa = Branching l r; if d then branch ds l else branch ds r⟧ ⟹ ?P⟧ ⟹ ?P›*) 2)) } ultimately show "T = Leaf ⟷ (∀b. branch b T ⟶ b = [])" by auto qed lemma branch_is_path: assumes"branch ds T" shows "path ds T" using assms (*‹branch ds T›*) proof (induction T arbitrary: ds) (*goals: 1. ‹⋀ds. branch ds Leaf ⟹ path ds Leaf› 2. ‹⋀T1 T2 ds. ⟦⋀ds. branch ds T1 ⟹ path ds T1; ⋀ds. branch ds T2 ⟹ path ds T2; branch ds (Branching T1 T2)⟧ ⟹ path ds (Branching T1 T2)›*) case Leaf (*‹branch ds Leaf›*) then have "ds = []" using branch_inv_Leaf (*‹branch ?b Leaf = (?b = [])›*) by auto then show "?case" (*goal: ‹path ds Leaf›*) by auto next (*goal: ‹⋀T1 T2 ds. ⟦⋀ds. branch ds T1 ⟹ path ds T1; ⋀ds. branch ds T2 ⟹ path ds T2; branch ds (Branching T1 T2)⟧ ⟹ path ds (Branching T1 T2)›*) case (Branching T₁ T₂) (*‹branch ?ds T₁ ⟹ path ?ds T₁› ‹branch ?ds T₂ ⟹ path ?ds T₂› ‹branch ds (Branching T₁ T₂)›*) then obtain a and b where ds_p: "ds = a # b ∧ (a ⟶ branch b T₁) ∧ (¬ a ⟶ branch b T₂)" (*goal: ‹(⋀a b. ds = a # b ∧ (a ⟶ branch b T₁) ∧ (¬ a ⟶ branch b T₂) ⟹ thesis) ⟹ thesis›*) using branch_inv_Branching[of ds] (*‹branch (ds::bool list) (Branching (?l::tree) (?r::tree)) = (∃(a::bool) b'::bool list. ds = a # b' ∧ (a ⟶ branch b' ?l) ∧ (¬ a ⟶ branch b' ?r))›*) by blast then have "(a ⟶ path b T₁) ∧ (¬a ⟶ path b T₂)" using Branching (*‹branch (?ds::bool list) (T₁::tree) ⟹ path ?ds T₁› ‹branch ?ds T₂ ⟹ path ?ds T₂› ‹branch ds (Branching T₁ T₂)›*) by auto then show "?case" (*goal: ‹path ds (Branching T₁ T₂)›*) using ds_p (*‹(ds::bool list) = (a::bool) # (b::bool list) ∧ (a ⟶ branch b (T₁::tree)) ∧ (¬ a ⟶ branch b (T₂::tree))›*) apply (cases a) (*goals: 1. ‹⟦(a ⟶ path b T₁) ∧ (¬ a ⟶ path b T₂); ds = a # b ∧ (a ⟶ branch b T₁) ∧ (¬ a ⟶ branch b T₂); a⟧ ⟹ path ds (Branching T₁ T₂)› 2. ‹⟦(a ⟶ path b T₁) ∧ (¬ a ⟶ path b T₂); ds = a # b ∧ (a ⟶ branch b T₁) ∧ (¬ a ⟶ branch b T₂); ¬ a⟧ ⟹ path ds (Branching T₁ T₂)› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . qed lemma Branching_Leaf_Leaf_Tree: assumes "T = Branching T1 T2" shows "(∃B. branch (B@[True]) T ∧ branch (B@[False]) T)" using assms (*‹T = Branching T1 T2›*) proof (induction T arbitrary: T1 T2) (*goals: 1. ‹⋀T1 T2. Leaf = Branching T1 T2 ⟹ ∃B. branch (B @ [True]) Leaf ∧ branch (B @ [False]) Leaf› 2. ‹⋀T1 T2 T1a T2a. ⟦⋀T1a T2. T1 = Branching T1a T2 ⟹ ∃B. branch (B @ [True]) T1 ∧ branch (B @ [False]) T1; ⋀T1 T2a. T2 = Branching T1 T2a ⟹ ∃B. branch (B @ [True]) T2 ∧ branch (B @ [False]) T2; Branching T1 T2 = Branching T1a T2a⟧ ⟹ ∃B. branch (B @ [True]) (Branching T1 T2) ∧ branch (B @ [False]) (Branching T1 T2)›*) case Leaf (*‹Leaf = Branching T1 T2›*) then show "?case" (*goal: ‹∃B. branch (B @ [True]) Leaf ∧ branch (B @ [False]) Leaf›*) by auto next (*goal: ‹⋀T1 T2 T1a T2a. ⟦⋀T1a T2. T1 = Branching T1a T2 ⟹ ∃B. branch (B @ [True]) T1 ∧ branch (B @ [False]) T1; ⋀T1 T2a. T2 = Branching T1 T2a ⟹ ∃B. branch (B @ [True]) T2 ∧ branch (B @ [False]) T2; Branching T1 T2 = Branching T1a T2a⟧ ⟹ ∃B. branch (B @ [True]) (Branching T1 T2) ∧ branch (B @ [False]) (Branching T1 T2)›*) case (Branching T1' T2') (*‹(T1'::tree) = Branching (?T1.0::tree) (?T2.0::tree) ⟹ ∃B::bool list. branch (B @ [True]) T1' ∧ branch (B @ [False]) T1'› ‹T2' = Branching ?T1.0 ?T2.0 ⟹ ∃B. branch (B @ [True]) T2' ∧ branch (B @ [False]) T2'› ‹Branching T1' T2' = Branching T1 T2›*) { assume "T1'=Leaf ∧ T2'=Leaf" (*‹(T1'::tree) = Leaf ∧ (T2'::tree) = Leaf›*) then have "branch ([] @ [True]) (Branching T1' T2') ∧ branch ([] @ [False]) (Branching T1' T2')" by auto then have "?case" by metis } moreover { fix T11 and T12 assume "T1' = Branching T11 T12" (*‹(T1'::tree) = Branching (T11::tree) (T12::tree)›*) then obtain B where "branch (B @ [True]) T1' ∧ branch (B @ [False]) T1'" (*goal: ‹(⋀B. branch (B @ [True]) T1' ∧ branch (B @ [False]) T1' ⟹ thesis) ⟹ thesis›*) using Branching (*‹T1' = Branching ?T1.0 ?T2.0 ⟹ ∃B. branch (B @ [True]) T1' ∧ branch (B @ [False]) T1'› ‹T2' = Branching ?T1.0 ?T2.0 ⟹ ∃B. branch (B @ [True]) T2' ∧ branch (B @ [False]) T2'› ‹Branching T1' T2' = Branching T1 T2›*) by blast then have "branch (([True] @ B) @ [True]) (Branching T1' T2') ∧ branch (([True] @ B) @ [False]) (Branching T1' T2')" by auto then have "?case" by blast } moreover { fix T11 and T12 assume "T2' = Branching T11 T12" (*‹(T2'::tree) = Branching (T11::tree) (T12::tree)›*) then obtain B where "branch (B @ [True]) T2' ∧ branch (B @ [False]) T2'" (*goal: ‹(⋀B. branch (B @ [True]) T2' ∧ branch (B @ [False]) T2' ⟹ thesis) ⟹ thesis›*) using Branching (*‹T1' = Branching ?T1.0 ?T2.0 ⟹ ∃B. branch (B @ [True]) T1' ∧ branch (B @ [False]) T1'› ‹T2' = Branching ?T1.0 ?T2.0 ⟹ ∃B. branch (B @ [True]) T2' ∧ branch (B @ [False]) T2'› ‹Branching (T1'::tree) (T2'::tree) = Branching (T1::tree) (T2::tree)›*) by blast then have "branch (([False] @ B) @ [True]) (Branching T1' T2') ∧ branch (([False] @ B) @ [False]) (Branching T1' T2')" by auto then have "?case" by blast } ultimately show "?case" (*goal: ‹∃B::bool list. branch (B @ [True]) (Branching (T1'::tree) (T2'::tree)) ∧ branch (B @ [False]) (Branching T1' T2')›*) using tree.exhaust (*‹⟦?y = Leaf ⟹ ?P; ⋀x21 x22. ?y = Branching x21 x22 ⟹ ?P⟧ ⟹ ?P›*) by blast qed subsection ‹Internal Paths› fun internal :: "dir list ⇒ tree ⇒ bool" where "internal [] (Branching l r) ⟷ True" | "internal (d#ds) (Branching l r) ⟷ (if d then internal ds l else internal ds r)" | "internal _ _ ⟷ False" lemma internal_inv_Leaf: "¬internal b Leaf" using internal.simps (*‹internal [] (Branching (?l::tree) (?r::tree)) = True› ‹internal (?d # ?ds) (Branching ?l ?r) = (if ?d then internal ?ds ?l else internal ?ds ?r)› ‹internal (?v # ?va) Leaf = False› ‹internal ?uu Leaf = False›*) by blast lemma internal_inv_Branching_Left: "internal (Left#b) (Branching l r) ⟷ internal b l" by auto lemma internal_inv_Branching_Right: "internal (Right#b) (Branching l r) ⟷ internal b r" by auto lemma internal_inv_Branching: "internal p (Branching l r) ⟷ (p=[] ∨ (∃a p'. p=a#p'∧ (a ⟶ internal p' l) ∧ (¬a ⟶ internal p' r)))" (is "?L ⟷ ?R") proof (standard) (*goals: 1. ‹internal p (Branching l r) ⟹ p = [] ∨ (∃a p'. p = a # p' ∧ (a ⟶ internal p' l) ∧ (¬ a ⟶ internal p' r))› 2. ‹p = [] ∨ (∃a p'. p = a # p' ∧ (a ⟶ internal p' l) ∧ (¬ a ⟶ internal p' r)) ⟹ internal p (Branching l r)›*) assume "?L" (*‹internal (p::bool list) (Branching (l::tree) (r::tree))›*) then show "?R" by (metis internal.simps( (*‹internal ((?d::bool) # (?ds::bool list)) (Branching (?l::tree) (?r::tree)) = (if ?d then internal ?ds ?l else internal ?ds ?r)›*) 2) neq_Nil_conv (*‹((?xs::?'a list) ≠ []) = (∃(y::?'a) ys::?'a list. ?xs = y # ys)›*)) next (*goal: ‹p = [] ∨ (∃a p'. p = a # p' ∧ (a ⟶ internal p' l) ∧ (¬ a ⟶ internal p' r)) ⟹ internal p (Branching l r)›*) assume r: "?R" (*‹(p::bool list) = [] ∨ (∃(a::bool) p'::bool list. p = a # p' ∧ (a ⟶ internal p' (l::tree)) ∧ (¬ a ⟶ internal p' (r::tree)))›*) then show "?L" proof (standard) (*goals: 1. ‹p = [] ⟹ internal p (Branching l r)› 2. ‹∃a p'. p = a # p' ∧ (a ⟶ internal p' l) ∧ (¬ a ⟶ internal p' r) ⟹ internal p (Branching l r)›*) assume "p = []" (*‹(p::bool list) = []›*) then show "?L" by auto next (*goal: ‹∃(a::bool) p'::bool list. (p::bool list) = a # p' ∧ (a ⟶ internal p' (l::tree)) ∧ (¬ a ⟶ internal p' (r::tree)) ⟹ internal p (Branching l r)›*) assume "∃a p'. p=a#p'∧ (a ⟶ internal p' l) ∧ (¬a ⟶ internal p' r)" (*‹∃(a::bool) p'::bool list. (p::bool list) = a # p' ∧ (a ⟶ internal p' (l::tree)) ∧ (¬ a ⟶ internal p' (r::tree))›*) then obtain a and p' where "p=a#p'∧ (a ⟶ internal p' l) ∧ (¬a ⟶ internal p' r)" (*goal: ‹(⋀a p'. p = a # p' ∧ (a ⟶ internal p' l) ∧ (¬ a ⟶ internal p' r) ⟹ thesis) ⟹ thesis›*) by auto then show "?L" apply (cases a) (*goals: 1. ‹⟦p = a # p' ∧ (a ⟶ internal p' l) ∧ (¬ a ⟶ internal p' r); a⟧ ⟹ internal p (Branching l r)› 2. ‹⟦p = a # p' ∧ (a ⟶ internal p' l) ∧ (¬ a ⟶ internal p' r); ¬ a⟧ ⟹ internal p (Branching l r)› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . qed qed lemma internal_is_path: assumes "internal ds T" shows "path ds T" using assms (*‹internal ds T›*) proof (induction T arbitrary: ds) (*goals: 1. ‹⋀ds. internal ds Leaf ⟹ path ds Leaf› 2. ‹⋀T1 T2 ds. ⟦⋀ds. internal ds T1 ⟹ path ds T1; ⋀ds. internal ds T2 ⟹ path ds T2; internal ds (Branching T1 T2)⟧ ⟹ path ds (Branching T1 T2)›*) case Leaf (*‹internal ds Leaf›*) then have False using internal_inv_Leaf (*‹¬ internal ?b Leaf›*) by auto then show "?case" (*goal: ‹path (ds::bool list) Leaf›*) by auto next (*goal: ‹⋀T1 T2 ds. ⟦⋀ds. internal ds T1 ⟹ path ds T1; ⋀ds. internal ds T2 ⟹ path ds T2; internal ds (Branching T1 T2)⟧ ⟹ path ds (Branching T1 T2)›*) case (Branching T₁ T₂) (*‹internal ?ds T₁ ⟹ path ?ds T₁› ‹internal ?ds T₂ ⟹ path ?ds T₂› ‹internal (ds::bool list) (Branching (T₁::tree) (T₂::tree))›*) then obtain a and b where ds_p: "ds=[] ∨ ds = a # b ∧ (a ⟶ internal b T₁) ∧ (¬ a ⟶ internal b T₂)" (*goal: ‹(⋀a b. ds = [] ∨ ds = a # b ∧ (a ⟶ internal b T₁) ∧ (¬ a ⟶ internal b T₂) ⟹ thesis) ⟹ thesis›*) using internal_inv_Branching (*‹internal ?p (Branching ?l ?r) = (?p = [] ∨ (∃a p'. ?p = a # p' ∧ (a ⟶ internal p' ?l) ∧ (¬ a ⟶ internal p' ?r)))›*) by blast then have "ds = [] ∨ (a ⟶ path b T₁) ∧ (¬a ⟶ path b T₂)" using Branching (*‹internal ?ds T₁ ⟹ path ?ds T₁› ‹internal (?ds::bool list) (T₂::tree) ⟹ path ?ds T₂› ‹internal ds (Branching T₁ T₂)›*) by auto then show "?case" (*goal: ‹path (ds::bool list) (Branching (T₁::tree) (T₂::tree))›*) using ds_p (*‹ds = [] ∨ ds = a # b ∧ (a ⟶ internal b T₁) ∧ (¬ a ⟶ internal b T₂)›*) apply (cases a) (*goals: 1. ‹⟦ds = [] ∨ (a ⟶ path b T₁) ∧ (¬ a ⟶ path b T₂); ds = [] ∨ ds = a # b ∧ (a ⟶ internal b T₁) ∧ (¬ a ⟶ internal b T₂); a⟧ ⟹ path ds (Branching T₁ T₂)› 2. ‹⟦ds = [] ∨ (a ⟶ path b T₁) ∧ (¬ a ⟶ path b T₂); ds = [] ∨ ds = a # b ∧ (a ⟶ internal b T₁) ∧ (¬ a ⟶ internal b T₂); ¬ a⟧ ⟹ path ds (Branching T₁ T₂)› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . qed lemma internal_prefix: assumes "internal (ds1@ds2@[d]) T" shows "internal ds1 T" (* more or less copy paste of path_prefix *) using assms (*‹internal ((ds1::bool list) @ (ds2::bool list) @ [d::bool]) (T::tree)›*) proof (induction ds1 arbitrary: T) (*goals: 1. ‹⋀T. internal ([] @ ds2 @ [d]) T ⟹ internal [] T› 2. ‹⋀a ds1 T. ⟦⋀T. internal (ds1 @ ds2 @ [d]) T ⟹ internal ds1 T; internal ((a # ds1) @ ds2 @ [d]) T⟧ ⟹ internal (a # ds1) T›*) case (Cons a ds1) (*‹internal (ds1 @ ds2 @ [d]) ?T ⟹ internal ds1 ?T› ‹internal ((a # ds1) @ ds2 @ [d]) T›*) then have "∃l r. T = Branching l r" using internal_inv_Leaf (*‹¬ internal ?b Leaf›*) apply (cases T) (*goals: 1. ‹⟦⋀T. internal (ds1 @ ds2 @ [d]) T ⟹ internal ds1 T; internal ((a # ds1) @ ds2 @ [d]) T; ⋀b. ¬ internal b Leaf; T = Leaf⟧ ⟹ ∃l r. T = Branching l r› 2. ‹⋀x21 x22. ⟦⋀T. internal (ds1 @ ds2 @ [d]) T ⟹ internal ds1 T; internal ((a # ds1) @ ds2 @ [d]) T; ⋀b. ¬ internal b Leaf; T = Branching x21 x22⟧ ⟹ ∃l r. T = Branching l r› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . then obtain l and r where p_lr: "T = Branching l r" (*goal: ‹(⋀l r. T = Branching l r ⟹ thesis) ⟹ thesis›*) by auto show "?case" (*goal: ‹internal (a # ds1) T›*) proof (cases a) (*goals: 1. ‹a ⟹ internal (a # ds1) T› 2. ‹¬ a ⟹ internal (a # ds1) T›*) assume atrue: a (*‹a::bool›*) then have "internal ((ds1) @ ds2 @[d]) l" using p_lr (*‹T = Branching l r›*) Cons(2) (*‹internal (((a::bool) # (ds1::bool list)) @ (ds2::bool list) @ [d::bool]) (T::tree)›*) internal_inv_Branching (*‹internal ?p (Branching ?l ?r) = (?p = [] ∨ (∃a p'. ?p = a # p' ∧ (a ⟶ internal p' ?l) ∧ (¬ a ⟶ internal p' ?r)))›*) by auto then have "internal ds1 l" using Cons(1) (*‹internal (ds1 @ ds2 @ [d]) ?T ⟹ internal ds1 ?T›*) by auto then show "internal (a # ds1) T" using p_lr (*‹(T::tree) = Branching (l::tree) (r::tree)›*) atrue (*‹a›*) by auto next (*goal: ‹¬ (a::bool) ⟹ internal (a # (ds1::bool list)) (T::tree)›*) assume afalse: "~a" (*‹¬ (a::bool)›*) then have "internal ((ds1) @ ds2 @[d]) r" using p_lr (*‹(T::tree) = Branching (l::tree) (r::tree)›*) Cons(2) (*‹internal ((a # ds1) @ ds2 @ [d]) T›*) internal_inv_Branching (*‹internal ?p (Branching ?l ?r) = (?p = [] ∨ (∃a p'. ?p = a # p' ∧ (a ⟶ internal p' ?l) ∧ (¬ a ⟶ internal p' ?r)))›*) by auto then have "internal ds1 r" using Cons(1) (*‹internal (ds1 @ ds2 @ [d]) ?T ⟹ internal ds1 ?T›*) by auto then show "internal (a # ds1) T" using p_lr (*‹T = Branching l r›*) afalse (*‹¬ a›*) by auto qed next (*goal: ‹⋀T. internal ([] @ ds2 @ [d]) T ⟹ internal [] T›*) case Nil (*‹internal ([] @ ds2 @ [d]) T›*) then have "∃l r. T = Branching l r" using internal_inv_Leaf (*‹¬ internal ?b Leaf›*) apply (cases T) (*goals: 1. ‹⟦internal ([] @ ds2 @ [d]) T; ⋀b. ¬ internal b Leaf; T = Leaf⟧ ⟹ ∃l r. T = Branching l r› 2. ‹⋀x21 x22. ⟦internal ([] @ ds2 @ [d]) T; ⋀b. ¬ internal b Leaf; T = Branching x21 x22⟧ ⟹ ∃l r. T = Branching l r› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . then show "?case" (*goal: ‹internal [] (T::tree)›*) by auto qed lemma internal_branch: assumes "branch (ds1@ds2@[d]) T" shows "internal ds1 T" (* more or less copy paste of path_prefix *) using assms (*‹branch (ds1 @ ds2 @ [d]) T›*) proof (induction ds1 arbitrary: T) (*goals: 1. ‹⋀T. branch ([] @ ds2 @ [d]) T ⟹ internal [] T› 2. ‹⋀a ds1 T. ⟦⋀T. branch (ds1 @ ds2 @ [d]) T ⟹ internal ds1 T; branch ((a # ds1) @ ds2 @ [d]) T⟧ ⟹ internal (a # ds1) T›*) case (Cons a ds1) (*‹branch (ds1 @ ds2 @ [d]) ?T ⟹ internal ds1 ?T› ‹branch ((a # ds1) @ ds2 @ [d]) T›*) then have "∃l r. T = Branching l r" using branch_inv_Leaf (*‹branch ?b Leaf = (?b = [])›*) apply (cases T) (*goals: 1. ‹⟦⋀T. branch (ds1 @ ds2 @ [d]) T ⟹ internal ds1 T; branch ((a # ds1) @ ds2 @ [d]) T; ⋀b. branch b Leaf = (b = []); T = Leaf⟧ ⟹ ∃l r. T = Branching l r› 2. ‹⋀x21 x22. ⟦⋀T. branch (ds1 @ ds2 @ [d]) T ⟹ internal ds1 T; branch ((a # ds1) @ ds2 @ [d]) T; ⋀b. branch b Leaf = (b = []); T = Branching x21 x22⟧ ⟹ ∃l r. T = Branching l r› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . then obtain l and r where p_lr: "T = Branching l r" (*goal: ‹(⋀(l::tree) r::tree. (T::tree) = Branching l r ⟹ thesis::bool) ⟹ thesis›*) by auto show "?case" (*goal: ‹internal (a # ds1) T›*) proof (cases a) (*goals: 1. ‹a ⟹ internal (a # ds1) T› 2. ‹¬ a ⟹ internal (a # ds1) T›*) assume atrue: a (*‹a::bool›*) then have "branch (ds1 @ ds2 @ [d]) l" using p_lr (*‹(T::tree) = Branching (l::tree) (r::tree)›*) Cons(2) (*‹branch ((a # ds1) @ ds2 @ [d]) T›*) branch_inv_Branching (*‹branch ?b (Branching ?l ?r) = (∃a b'. ?b = a # b' ∧ (a ⟶ branch b' ?l) ∧ (¬ a ⟶ branch b' ?r))›*) by auto then have "internal ds1 l" using Cons(1) (*‹branch (ds1 @ ds2 @ [d]) ?T ⟹ internal ds1 ?T›*) by auto then show "internal (a # ds1) T" using p_lr (*‹T = Branching l r›*) atrue (*‹a›*) by auto next (*goal: ‹¬ a ⟹ internal (a # ds1) T›*) assume afalse: "~a" (*‹¬ (a::bool)›*) then have "branch ((ds1) @ ds2 @[d]) r" using p_lr (*‹T = Branching l r›*) Cons(2) (*‹branch ((a # ds1) @ ds2 @ [d]) T›*) branch_inv_Branching (*‹branch ?b (Branching ?l ?r) = (∃a b'. ?b = a # b' ∧ (a ⟶ branch b' ?l) ∧ (¬ a ⟶ branch b' ?r))›*) by auto then have "internal ds1 r" using Cons(1) (*‹branch (ds1 @ ds2 @ [d]) ?T ⟹ internal ds1 ?T›*) by auto then show "internal (a # ds1) T" using p_lr (*‹T = Branching l r›*) afalse (*‹¬ a›*) by auto qed next (*goal: ‹⋀T. branch ([] @ ds2 @ [d]) T ⟹ internal [] T›*) case Nil (*‹branch ([] @ ds2 @ [d]) T›*) then have "∃l r. T = Branching l r" using branch_inv_Leaf (*‹branch ?b Leaf = (?b = [])›*) apply (cases T) (*goals: 1. ‹⟦branch ([] @ ds2 @ [d]) T; ⋀b. branch b Leaf = (b = []); T = Leaf⟧ ⟹ ∃l r. T = Branching l r› 2. ‹⋀x21 x22. ⟦branch ([] @ ds2 @ [d]) T; ⋀b. branch b Leaf = (b = []); T = Branching x21 x22⟧ ⟹ ∃l r. T = Branching l r› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . then show "?case" (*goal: ‹internal [] T›*) by auto qed fun parent :: "dir list ⇒ dir list" where "parent ds = tl ds" subsection ‹Deleting Nodes› fun delete :: "dir list ⇒ tree ⇒ tree" where "delete [] T = Leaf" | "delete (True#ds) (Branching T₁ T₂) = Branching (delete ds T₁) T₂" | "delete (False#ds) (Branching T₁ T₂) = Branching T₁ (delete ds T₂)" | "delete (a#ds) Leaf = Leaf" lemma delete_Leaf: "delete T Leaf = Leaf" apply (cases T) (*goals: 1. ‹T = [] ⟹ delete T Leaf = Leaf› 2. ‹⋀a list. T = a # list ⟹ delete T Leaf = Leaf› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . lemma path_delete: assumes "path p (delete ds T)" shows "path p T " (* What a huge proof... But the four cases can be proven shorter *) using assms (*‹path p (delete ds T)›*) proof (induction p arbitrary: T ds) (*goals: 1. ‹⋀T ds. path [] (delete ds T) ⟹ path [] T› 2. ‹⋀a p T ds. ⟦⋀T ds. path p (delete ds T) ⟹ path p T; path (a # p) (delete ds T)⟧ ⟹ path (a # p) T›*) case Nil (*‹path [] (delete (ds::bool list) (T::tree))›*) then show "?case" (*goal: ‹path [] T›*) by simp next (*goal: ‹⋀a p T ds. ⟦⋀T ds. path p (delete ds T) ⟹ path p T; path (a # p) (delete ds T)⟧ ⟹ path (a # p) T›*) case (Cons a p) (*‹path p (delete ?ds ?T) ⟹ path p ?T› ‹path (a # p) (delete ds T)›*) then obtain b and ds' where bds'_p: "ds=b#ds'" (*goal: ‹(⋀b ds'. ds = b # ds' ⟹ thesis) ⟹ thesis›*) apply (cases ds) (*goals: 1. ‹⟦⋀b ds'. ds = b # ds' ⟹ thesis; ⋀ds T. path p (delete ds T) ⟹ path p T; path (a # p) (delete ds T); ds = []⟧ ⟹ thesis› 2. ‹⋀aa list. ⟦⋀b ds'. ds = b # ds' ⟹ thesis; ⋀ds T. path p (delete ds T) ⟹ path p T; path (a # p) (delete ds T); ds = aa # list⟧ ⟹ thesis› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . have "∃dT1 dT2. delete ds T = Branching dT1 dT2" using Cons (*‹path p (delete ?ds ?T) ⟹ path p ?T› ‹path (a # p) (delete ds T)›*) path_inv_Cons (*‹path (?a # ?ds) ?T ⟶ (∃l r. ?T = Branching l r)›*) by auto then obtain dT1 and dT2 where "delete ds T = Branching dT1 dT2" (*goal: ‹(⋀dT1 dT2. delete ds T = Branching dT1 dT2 ⟹ thesis) ⟹ thesis›*) by auto then have "∃T1 T2. T=Branching T1 T2" apply (cases T) (*goals: 1. ‹⟦delete (ds::bool list) (T::tree) = Branching (dT1::tree) (dT2::tree); T = Leaf⟧ ⟹ ∃(T1::tree) T2::tree. T = Branching T1 T2› 2. ‹⋀(x21::tree) x22::tree. ⟦delete (ds::bool list) (T::tree) = Branching (dT1::tree) (dT2::tree); T = Branching x21 x22⟧ ⟹ ∃(T1::tree) T2::tree. T = Branching T1 T2› discuss goal 1*) apply (cases ds) (*goals: 1. ‹⟦delete ds T = Branching dT1 dT2; T = Leaf; ds = []⟧ ⟹ ∃T1 T2. T = Branching T1 T2› 2. ‹⋀a list. ⟦delete ds T = Branching dT1 dT2; T = Leaf; ds = a # list⟧ ⟹ ∃T1 T2. T = Branching T1 T2› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) (*discuss goal 2*) apply (cases ds) (*goals: 1. ‹⋀x21 x22. ⟦delete ds T = Branching dT1 dT2; T = Branching x21 x22; ds = []⟧ ⟹ ∃T1 T2. T = Branching T1 T2› 2. ‹⋀x21 x22 a list. ⟦delete ds T = Branching dT1 dT2; T = Branching x21 x22; ds = a # list⟧ ⟹ ∃T1 T2. T = Branching T1 T2› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) (*proven 2 subgoals*) . then obtain T1 and T2 where T1T2_p: "T=Branching T1 T2" (*goal: ‹(⋀(T1::tree) T2::tree. (T::tree) = Branching T1 T2 ⟹ thesis::bool) ⟹ thesis›*) by auto { assume a_p: a (*‹a::bool›*) assume b_p: "¬b" (*‹¬ (b::bool)›*) have "path (a # p) (delete ds T)" using Cons (*‹path p (delete ?ds ?T) ⟹ path p ?T› ‹path (a # p) (delete ds T)›*) by - then have "path (a # p) (Branching (T1) (delete ds' T2))" using b_p (*‹¬ b›*) bds'_p (*‹ds = b # ds'›*) T1T2_p (*‹(T::tree) = Branching (T1::tree) (T2::tree)›*) by auto then have "path p T1" using a_p (*‹a›*) by auto then have "?case" using T1T2_p (*‹(T::tree) = Branching (T1::tree) (T2::tree)›*) a_p (*‹a›*) by auto } moreover { assume a_p: "¬a" (*‹¬ (a::bool)›*) assume b_p: b (*‹b::bool›*) have "path (a # p) (delete ds T)" using Cons (*‹path p (delete ?ds ?T) ⟹ path p ?T› ‹path (a # p) (delete ds T)›*) by - then have "path (a # p) (Branching (delete ds' T1) T2)" using b_p (*‹b›*) bds'_p (*‹ds = b # ds'›*) T1T2_p (*‹(T::tree) = Branching (T1::tree) (T2::tree)›*) by auto then have "path p T2" using a_p (*‹¬ a›*) by auto then have "?case" using T1T2_p (*‹T = Branching T1 T2›*) a_p (*‹¬ a›*) by auto } moreover { assume a_p: a (*‹a::bool›*) assume b_p: b (*‹b::bool›*) have "path (a # p) (delete ds T)" using Cons (*‹path p (delete ?ds ?T) ⟹ path p ?T› ‹path (a # p) (delete ds T)›*) by - then have "path (a # p) (Branching (delete ds' T1) T2)" using b_p (*‹b›*) bds'_p (*‹(ds::bool list) = (b::bool) # (ds'::bool list)›*) T1T2_p (*‹(T::tree) = Branching (T1::tree) (T2::tree)›*) by auto then have "path p (delete ds' T1)" using a_p (*‹a›*) by auto then have "path p T1" using Cons (*‹path p (delete ?ds ?T) ⟹ path p ?T› ‹path ((a::bool) # (p::bool list)) (delete (ds::bool list) (T::tree))›*) by auto then have "?case" using T1T2_p (*‹T = Branching T1 T2›*) a_p (*‹a›*) by auto } moreover { assume a_p: "¬a" (*‹¬ (a::bool)›*) assume b_p: "¬b" (*‹¬ (b::bool)›*) have "path (a # p) (delete ds T)" using Cons (*‹path p (delete ?ds ?T) ⟹ path p ?T› ‹path (a # p) (delete ds T)›*) by - then have "path (a # p) (Branching T1 (delete ds' T2))" using b_p (*‹¬ (b::bool)›*) bds'_p (*‹ds = b # ds'›*) T1T2_p (*‹T = Branching T1 T2›*) by auto then have "path p (delete ds' T2)" using a_p (*‹¬ (a::bool)›*) by auto then have "path p T2" using Cons (*‹path (p::bool list) (delete (?ds::bool list) (?T::tree)) ⟹ path p ?T› ‹path (a # p) (delete ds T)›*) by auto then have "?case" using T1T2_p (*‹(T::tree) = Branching (T1::tree) (T2::tree)›*) a_p (*‹¬ a›*) by auto } ultimately show "?case" (*goal: ‹path (a # p) T›*) by blast qed lemma branch_delete: assumes "branch p (delete ds T)" shows "branch p T ∨ p=ds" (* Adapted from above *) using assms (*‹branch p (delete ds T)›*) proof (induction p arbitrary: T ds) (*goals: 1. ‹⋀T ds. branch [] (delete ds T) ⟹ branch [] T ∨ [] = ds› 2. ‹⋀a p T ds. ⟦⋀T ds. branch p (delete ds T) ⟹ branch p T ∨ p = ds; branch (a # p) (delete ds T)⟧ ⟹ branch (a # p) T ∨ a # p = ds›*) case Nil (*‹branch [] (delete ds T)›*) then have "delete ds T = Leaf" apply (cases "delete ds T") (*goals: 1. ‹⟦branch [] (delete ds T); delete ds T = Leaf⟧ ⟹ delete ds T = Leaf› 2. ‹⋀x21 x22. ⟦branch [] (delete ds T); delete ds T = Branching x21 x22⟧ ⟹ delete ds T = Leaf› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . then have "ds = [] ∨ T = Leaf" using delete.elims (*‹⟦delete ?x ?xa = ?y; ⋀T. ⟦?x = []; ?xa = T; ?y = Leaf⟧ ⟹ ?P; ⋀ds T₁ T₂. ⟦?x = True # ds; ?xa = Branching T₁ T₂; ?y = Branching (delete ds T₁) T₂⟧ ⟹ ?P; ⋀ds T₁ T₂. ⟦?x = False # ds; ?xa = Branching T₁ T₂; ?y = Branching T₁ (delete ds T₂)⟧ ⟹ ?P; ⋀a ds. ⟦?x = a # ds; ?xa = Leaf; ?y = Leaf⟧ ⟹ ?P⟧ ⟹ ?P›*) by blast then show "?case" (*goal: ‹branch [] T ∨ [] = ds›*) by auto next (*goal: ‹⋀a p T ds. ⟦⋀T ds. branch p (delete ds T) ⟹ branch p T ∨ p = ds; branch (a # p) (delete ds T)⟧ ⟹ branch (a # p) T ∨ a # p = ds›*) case (Cons a p) (*‹branch p (delete ?ds ?T) ⟹ branch p ?T ∨ p = ?ds› ‹branch (a # p) (delete ds T)›*) then obtain b and ds' where bds'_p: "ds=b#ds'" (*goal: ‹(⋀b ds'. ds = b # ds' ⟹ thesis) ⟹ thesis›*) apply (cases ds) (*goals: 1. ‹⟦⋀b ds'. ds = b # ds' ⟹ thesis; ⋀ds T. branch p (delete ds T) ⟹ branch p T ∨ p = ds; branch (a # p) (delete ds T); ds = []⟧ ⟹ thesis› 2. ‹⋀aa list. ⟦⋀b ds'. ds = b # ds' ⟹ thesis; ⋀ds T. branch p (delete ds T) ⟹ branch p T ∨ p = ds; branch (a # p) (delete ds T); ds = aa # list⟧ ⟹ thesis› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . have "∃dT1 dT2. delete ds T = Branching dT1 dT2" using Cons (*‹branch (p::bool list) (delete (?ds::bool list) (?T::tree)) ⟹ branch p ?T ∨ p = ?ds› ‹branch (a # p) (delete ds T)›*) path_inv_Cons (*‹path (?a # ?ds) ?T ⟶ (∃l r. ?T = Branching l r)›*) branch_is_path (*‹branch ?ds ?T ⟹ path ?ds ?T›*) by blast then obtain dT1 and dT2 where "delete ds T = Branching dT1 dT2" (*goal: ‹(⋀dT1 dT2. delete ds T = Branching dT1 dT2 ⟹ thesis) ⟹ thesis›*) by auto then have "∃T1 T2. T=Branching T1 T2" apply (cases T) (*goals: 1. ‹⟦delete ds T = Branching dT1 dT2; T = Leaf⟧ ⟹ ∃T1 T2. T = Branching T1 T2› 2. ‹⋀x21 x22. ⟦delete ds T = Branching dT1 dT2; T = Branching x21 x22⟧ ⟹ ∃T1 T2. T = Branching T1 T2› discuss goal 1*) apply (cases ds) (*goals: 1. ‹⟦delete ds T = Branching dT1 dT2; T = Leaf; ds = []⟧ ⟹ ∃T1 T2. T = Branching T1 T2› 2. ‹⋀a list. ⟦delete ds T = Branching dT1 dT2; T = Leaf; ds = a # list⟧ ⟹ ∃T1 T2. T = Branching T1 T2› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) (*discuss goal 2*) apply (cases ds) (*goals: 1. ‹⋀x21 x22. ⟦delete ds T = Branching dT1 dT2; T = Branching x21 x22; ds = []⟧ ⟹ ∃T1 T2. T = Branching T1 T2› 2. ‹⋀x21 x22 a list. ⟦delete ds T = Branching dT1 dT2; T = Branching x21 x22; ds = a # list⟧ ⟹ ∃T1 T2. T = Branching T1 T2› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) (*proven 2 subgoals*) . then obtain T1 and T2 where T1T2_p: "T=Branching T1 T2" (*goal: ‹(⋀T1 T2. T = Branching T1 T2 ⟹ thesis) ⟹ thesis›*) by auto { assume a_p: a (*‹a::bool›*) assume b_p: "¬b" (*‹¬ (b::bool)›*) have "branch (a # p) (delete ds T)" using Cons (*‹branch p (delete ?ds ?T) ⟹ branch p ?T ∨ p = ?ds› ‹branch (a # p) (delete ds T)›*) by - then have "branch (a # p) (Branching (T1) (delete ds' T2))" using b_p (*‹¬ (b::bool)›*) bds'_p (*‹ds = b # ds'›*) T1T2_p (*‹T = Branching T1 T2›*) by auto then have "branch p T1" using a_p (*‹a›*) by auto then have "?case" using T1T2_p (*‹T = Branching T1 T2›*) a_p (*‹a›*) by auto } moreover { assume a_p: "¬a" (*‹¬ (a::bool)›*) assume b_p: b (*‹b::bool›*) have "branch (a # p) (delete ds T)" using Cons (*‹branch p (delete ?ds ?T) ⟹ branch p ?T ∨ p = ?ds› ‹branch (a # p) (delete ds T)›*) by - then have "branch (a # p) (Branching (delete ds' T1) T2)" using b_p (*‹b›*) bds'_p (*‹ds = b # ds'›*) T1T2_p (*‹T = Branching T1 T2›*) by auto then have "branch p T2" using a_p (*‹¬ (a::bool)›*) by auto then have "?case" using T1T2_p (*‹(T::tree) = Branching (T1::tree) (T2::tree)›*) a_p (*‹¬ a›*) by auto } moreover { assume a_p: a (*‹a::bool›*) assume b_p: b (*‹b::bool›*) have "branch (a # p) (delete ds T)" using Cons (*‹branch p (delete ?ds ?T) ⟹ branch p ?T ∨ p = ?ds› ‹branch (a # p) (delete ds T)›*) by - then have "branch (a # p) (Branching (delete ds' T1) T2)" using b_p (*‹b›*) bds'_p (*‹ds = b # ds'›*) T1T2_p (*‹(T::tree) = Branching (T1::tree) (T2::tree)›*) by auto then have "branch p (delete ds' T1)" using a_p (*‹a›*) by auto then have "branch p T1 ∨ p = ds'" using Cons (*‹branch p (delete ?ds ?T) ⟹ branch p ?T ∨ p = ?ds› ‹branch (a # p) (delete ds T)›*) by metis then have "?case" using T1T2_p (*‹T = Branching T1 T2›*) a_p (*‹a›*) using bds'_p (*‹ds = b # ds'›*) a_p (*‹a›*) b_p (*‹b›*) by auto } moreover { assume a_p: "¬a" (*‹¬ (a::bool)›*) assume b_p: "¬b" (*‹¬ (b::bool)›*) have "branch (a # p) (delete ds T)" using Cons (*‹branch (p::bool list) (delete (?ds::bool list) (?T::tree)) ⟹ branch p ?T ∨ p = ?ds› ‹branch ((a::bool) # (p::bool list)) (delete (ds::bool list) (T::tree))›*) by - then have "branch (a # p) (Branching T1 (delete ds' T2))" using b_p (*‹¬ (b::bool)›*) bds'_p (*‹ds = b # ds'›*) T1T2_p (*‹T = Branching T1 T2›*) by auto then have "branch p (delete ds' T2)" using a_p (*‹¬ a›*) by auto then have "branch p T2 ∨ p = ds'" using Cons (*‹branch (p::bool list) (delete (?ds::bool list) (?T::tree)) ⟹ branch p ?T ∨ p = ?ds› ‹branch ((a::bool) # (p::bool list)) (delete (ds::bool list) (T::tree))›*) by metis then have "?case" using T1T2_p (*‹T = Branching T1 T2›*) a_p (*‹¬ a›*) using bds'_p (*‹ds = b # ds'›*) a_p (*‹¬ a›*) b_p (*‹¬ (b::bool)›*) by auto } ultimately show "?case" (*goal: ‹branch (a # p) T ∨ a # p = ds›*) by blast qed lemma branch_delete_postfix: assumes "path p (delete ds T)" shows "¬(∃c cs. p = ds @ c#cs)" (* Adapted from previous proof *) using assms (*‹path p (delete ds T)›*) proof (induction p arbitrary: T ds) (*goals: 1. ‹⋀T ds. path [] (delete ds T) ⟹ ∄c cs. [] = ds @ c # cs› 2. ‹⋀a p T ds. ⟦⋀T ds. path p (delete ds T) ⟹ ∄c cs. p = ds @ c # cs; path (a # p) (delete ds T)⟧ ⟹ ∄c cs. a # p = ds @ c # cs›*) case Nil (*‹path [] (delete ds T)›*) then show "?case" (*goal: ‹∄(c::bool) cs::bool list. [] = (ds::bool list) @ c # cs›*) by simp next (*goal: ‹⋀a p T ds. ⟦⋀T ds. path p (delete ds T) ⟹ ∄c cs. p = ds @ c # cs; path (a # p) (delete ds T)⟧ ⟹ ∄c cs. a # p = ds @ c # cs›*) case (Cons a p) (*‹path p (delete ?ds ?T) ⟹ ∄c cs. p = ?ds @ c # cs› ‹path (a # p) (delete ds T)›*) then obtain b and ds' where bds'_p: "ds=b#ds'" (*goal: ‹(⋀b ds'. ds = b # ds' ⟹ thesis) ⟹ thesis›*) apply (cases ds) (*goals: 1. ‹⟦⋀b ds'. ds = b # ds' ⟹ thesis; ⋀ds T. path p (delete ds T) ⟹ ∄c cs. p = ds @ c # cs; path (a # p) (delete ds T); ds = []⟧ ⟹ thesis› 2. ‹⋀aa list. ⟦⋀b ds'. ds = b # ds' ⟹ thesis; ⋀ds T. path p (delete ds T) ⟹ ∄c cs. p = ds @ c # cs; path (a # p) (delete ds T); ds = aa # list⟧ ⟹ thesis› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . have "∃dT1 dT2. delete ds T = Branching dT1 dT2" using Cons (*‹path p (delete ?ds ?T) ⟹ ∄c cs. p = ?ds @ c # cs› ‹path (a # p) (delete ds T)›*) path_inv_Cons (*‹path (?a # ?ds) ?T ⟶ (∃l r. ?T = Branching l r)›*) by auto then obtain dT1 and dT2 where "delete ds T = Branching dT1 dT2" (*goal: ‹(⋀(dT1::tree) dT2::tree. delete (ds::bool list) (T::tree) = Branching dT1 dT2 ⟹ thesis::bool) ⟹ thesis›*) by auto then have "∃T1 T2. T=Branching T1 T2" apply (cases T) (*goals: 1. ‹⟦delete ds T = Branching dT1 dT2; T = Leaf⟧ ⟹ ∃T1 T2. T = Branching T1 T2› 2. ‹⋀x21 x22. ⟦delete ds T = Branching dT1 dT2; T = Branching x21 x22⟧ ⟹ ∃T1 T2. T = Branching T1 T2› discuss goal 1*) apply (cases ds) (*goals: 1. ‹⟦delete ds T = Branching dT1 dT2; T = Leaf; ds = []⟧ ⟹ ∃T1 T2. T = Branching T1 T2› 2. ‹⋀a list. ⟦delete ds T = Branching dT1 dT2; T = Leaf; ds = a # list⟧ ⟹ ∃T1 T2. T = Branching T1 T2› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) (*discuss goal 2*) apply (cases ds) (*goals: 1. ‹⋀x21 x22. ⟦delete ds T = Branching dT1 dT2; T = Branching x21 x22; ds = []⟧ ⟹ ∃T1 T2. T = Branching T1 T2› 2. ‹⋀x21 x22 a list. ⟦delete ds T = Branching dT1 dT2; T = Branching x21 x22; ds = a # list⟧ ⟹ ∃T1 T2. T = Branching T1 T2› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) (*proven 2 subgoals*) . then obtain T1 and T2 where T1T2_p: "T=Branching T1 T2" (*goal: ‹(⋀T1 T2. T = Branching T1 T2 ⟹ thesis) ⟹ thesis›*) by auto { assume a_p: a (*‹a::bool›*) assume b_p: "¬b" (*‹¬ (b::bool)›*) then have "?case" using T1T2_p (*‹(T::tree) = Branching (T1::tree) (T2::tree)›*) a_p (*‹a›*) b_p (*‹¬ b›*) bds'_p (*‹ds = b # ds'›*) by auto } moreover { assume a_p: "¬a" (*‹¬ (a::bool)›*) assume b_p: b (*‹b::bool›*) then have "?case" using T1T2_p (*‹(T::tree) = Branching (T1::tree) (T2::tree)›*) a_p (*‹¬ a›*) b_p (*‹b›*) bds'_p (*‹ds = b # ds'›*) by auto } moreover { assume a_p: a (*‹a::bool›*) assume b_p: b (*‹b::bool›*) have "path (a # p) (delete ds T)" using Cons (*‹path p (delete ?ds ?T) ⟹ ∄c cs. p = ?ds @ c # cs› ‹path (a # p) (delete ds T)›*) by - then have "path (a # p) (Branching (delete ds' T1) T2)" using b_p (*‹b›*) bds'_p (*‹ds = b # ds'›*) T1T2_p (*‹T = Branching T1 T2›*) by auto then have "path p (delete ds' T1)" using a_p (*‹a›*) by auto then have "¬ (∃c cs. p = ds' @ c # cs)" using Cons (*‹path p (delete ?ds ?T) ⟹ ∄c cs. p = ?ds @ c # cs› ‹path (a # p) (delete ds T)›*) by auto then have "?case" using T1T2_p (*‹T = Branching T1 T2›*) a_p (*‹a›*) b_p (*‹b::bool›*) bds'_p (*‹ds = b # ds'›*) by auto } moreover { assume a_p: "¬a" (*‹¬ (a::bool)›*) assume b_p: "¬b" (*‹¬ (b::bool)›*) have "path (a # p) (delete ds T)" using Cons (*‹path p (delete ?ds ?T) ⟹ ∄c cs. p = ?ds @ c # cs› ‹path (a # p) (delete ds T)›*) by - then have "path (a # p) (Branching T1 (delete ds' T2))" using b_p (*‹¬ b›*) bds'_p (*‹ds = b # ds'›*) T1T2_p (*‹T = Branching T1 T2›*) by auto then have "path p (delete ds' T2)" using a_p (*‹¬ a›*) by auto then have "¬ (∃c cs. p = ds' @ c # cs)" using Cons (*‹path p (delete ?ds ?T) ⟹ ∄c cs. p = ?ds @ c # cs› ‹path ((a::bool) # (p::bool list)) (delete (ds::bool list) (T::tree))›*) by auto then have "?case" using T1T2_p (*‹T = Branching T1 T2›*) a_p (*‹¬ (a::bool)›*) b_p (*‹¬ b›*) bds'_p (*‹ds = b # ds'›*) by auto } ultimately show "?case" (*goal: ‹∄(c::bool) cs::bool list. (a::bool) # (p::bool list) = (ds::bool list) @ c # cs›*) by blast qed lemma treezise_delete: assumes "internal p T" shows "treesize (delete p T) < treesize T" using assms (*‹internal p T›*) proof (induction p arbitrary: T) (*goals: 1. ‹⋀T. internal [] T ⟹ treesize (delete [] T) < treesize T› 2. ‹⋀a p T. ⟦⋀T. internal p T ⟹ treesize (delete p T) < treesize T; internal (a # p) T⟧ ⟹ treesize (delete (a # p) T) < treesize T›*) case Nil (*‹internal [] (T::tree)›*) then have "∃T1 T2. T = Branching T1 T2" apply (cases T) (*goals: 1. ‹⟦internal [] T; T = Leaf⟧ ⟹ ∃T1 T2. T = Branching T1 T2› 2. ‹⋀x21 x22. ⟦internal [] T; T = Branching x21 x22⟧ ⟹ ∃T1 T2. T = Branching T1 T2› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . then obtain T1 and T2 where T1T2_p: "T = Branching T1 T2" (*goal: ‹(⋀T1 T2. T = Branching T1 T2 ⟹ thesis) ⟹ thesis›*) by auto then show "?case" (*goal: ‹treesize (delete [] T) < treesize T›*) by auto next (*goal: ‹⋀a p T. ⟦⋀T. internal p T ⟹ treesize (delete p T) < treesize T; internal (a # p) T⟧ ⟹ treesize (delete (a # p) T) < treesize T›*) case (Cons a p) (*‹internal p ?T ⟹ treesize (delete p ?T) < treesize ?T› ‹internal (a # p) T›*) then have "∃T1 T2. T = Branching T1 T2" using path_inv_Cons (*‹path (?a # ?ds) ?T ⟶ (∃l r. ?T = Branching l r)›*) internal_is_path (*‹internal ?ds ?T ⟹ path ?ds ?T›*) by blast then obtain T1 and T2 where T1T2_p: "T = Branching T1 T2" (*goal: ‹(⋀T1 T2. T = Branching T1 T2 ⟹ thesis) ⟹ thesis›*) by auto show "?case" (*goal: ‹treesize (delete (a # p) T) < treesize T›*) proof (cases a) (*goals: 1. ‹a ⟹ treesize (delete (a # p) T) < treesize T› 2. ‹¬ a ⟹ treesize (delete (a # p) T) < treesize T›*) assume a_p: a (*‹a::bool›*) from a_p (*‹a›*) have "delete (a#p) T = (Branching (delete p T1) T2)" using T1T2_p (*‹T = Branching T1 T2›*) by auto moreover from a_p (*‹a::bool›*) have "internal p T1" using T1T2_p (*‹T = Branching T1 T2›*) Cons (*‹internal (p::bool list) (?T::tree) ⟹ treesize (delete p ?T) < treesize ?T› ‹internal (a # p) T›*) by auto then have "treesize (delete p T1) < treesize T1" using Cons (*‹internal p ?T ⟹ treesize (delete p ?T) < treesize ?T› ‹internal (a # p) T›*) by auto ultimately show "?thesis" (*goal: ‹treesize (delete ((a::bool) # (p::bool list)) (T::tree)) < treesize T›*) using T1T2_p (*‹(T::tree) = Branching (T1::tree) (T2::tree)›*) by auto next (*goal: ‹¬ a ⟹ treesize (delete (a # p) T) < treesize T›*) assume a_p: "¬a" (*‹¬ (a::bool)›*) from a_p (*‹¬ (a::bool)›*) have "delete (a#p) T = (Branching T1 (delete p T2))" using T1T2_p (*‹T = Branching T1 T2›*) by auto moreover from a_p (*‹¬ a›*) have "internal p T2" using T1T2_p (*‹T = Branching T1 T2›*) Cons (*‹internal p ?T ⟹ treesize (delete p ?T) < treesize ?T› ‹internal (a # p) T›*) by auto then have "treesize (delete p T2) < treesize T2" using Cons (*‹internal (p::bool list) (?T::tree) ⟹ treesize (delete p ?T) < treesize ?T› ‹internal (a # p) T›*) by auto ultimately show "?thesis" (*goal: ‹treesize (delete (a # p) T) < treesize T›*) using T1T2_p (*‹T = Branching T1 T2›*) by auto qed qed fun cutoff :: "(dir list ⇒ bool) ⇒ dir list ⇒ tree ⇒ tree" where "cutoff red ds (Branching T₁ T₂) = (if red ds then Leaf else Branching (cutoff red (ds@[Left]) T₁) (cutoff red (ds@[Right]) T₂))" | "cutoff red ds Leaf = Leaf" text ‹Initially you should call @{const cutoff} with @{term "ds = []"}. If all branches are red, then @{const cutoff} gives a subtree. If all branches are red, then so are the ones in @{const cutoff}. The internal paths of @{const cutoff} are not red.› lemma treesize_cutoff: "treesize (cutoff red ds T) ≤ treesize T" proof (induction T arbitrary: ds) (*goals: 1. ‹⋀ds. treesize (cutoff red ds Leaf) ≤ treesize Leaf› 2. ‹⋀T1 T2 ds. ⟦⋀ds. treesize (cutoff red ds T1) ≤ treesize T1; ⋀ds. treesize (cutoff red ds T2) ≤ treesize T2⟧ ⟹ treesize (cutoff red ds (Branching T1 T2)) ≤ treesize (Branching T1 T2)›*) case Leaf (*no hyothesis introduced yet*) then show "?case" (*goal: ‹treesize (cutoff red ds Leaf) ≤ treesize Leaf›*) by auto next (*goal: ‹⋀T1 T2 ds. ⟦⋀ds. treesize (cutoff red ds T1) ≤ treesize T1; ⋀ds. treesize (cutoff red ds T2) ≤ treesize T2⟧ ⟹ treesize (cutoff red ds (Branching T1 T2)) ≤ treesize (Branching T1 T2)›*) case (Branching T1 T2) (*‹treesize (cutoff red ?ds T1) ≤ treesize T1› ‹treesize (cutoff red ?ds T2) ≤ treesize T2›*) then have "treesize (cutoff red (ds@[Left]) T1) + treesize (cutoff red (ds@[Right]) T2) ≤ treesize T1 + treesize T2" using add_mono (*‹⟦?a ≤ ?b; ?c ≤ ?d⟧ ⟹ ?a + ?c ≤ ?b + ?d›*) by blast then show "?case" (*goal: ‹treesize (cutoff red ds (Branching T1 T2)) ≤ treesize (Branching T1 T2)›*) by auto qed abbreviation anypath :: "tree ⇒ (dir list ⇒ bool) ⇒ bool" where "anypath T P ≡ ∀p. path p T ⟶ P p" abbreviation anybranch :: "tree ⇒ (dir list ⇒ bool) ⇒ bool" where "anybranch T P ≡ ∀p. branch p T ⟶ P p" abbreviation anyinternal :: "tree ⇒ (dir list ⇒ bool) ⇒ bool" where "anyinternal T P ≡ ∀p. internal p T ⟶ P p" lemma cutoff_branch': assumes "anybranch T (λb. red(ds@b))" shows "anybranch (cutoff red ds T) (λb. red(ds@b))" sorry lemma cutoff_branch: assumes "anybranch T (λp. red p)" shows "anybranch (cutoff red [] T) (λp. red p)" using assms (*‹anybranch T red›*) cutoff_branch'[of T red "[]"] (*‹anybranch T (λp. red ([] @ p)) ⟹ anybranch (cutoff red [] T) (λp. red ([] @ p))›*) by auto lemma cutoff_internal': assumes "anybranch T (λb. red(ds@b))" shows "anyinternal (cutoff red ds T) (λb. ¬red(ds@b))" using assms (*‹anybranch T (λp. red (ds @ p))›*) proof (induction T arbitrary: ds) (*goals: 1. ‹⋀ds. anybranch Leaf (λp. red (ds @ p)) ⟹ anyinternal (cutoff red ds Leaf) (λp. ¬ red (ds @ p))› 2. ‹⋀T1 T2 ds. ⟦⋀ds. anybranch T1 (λp. red (ds @ p)) ⟹ anyinternal (cutoff red ds T1) (λp. ¬ red (ds @ p)); ⋀ds. anybranch T2 (λp. red (ds @ p)) ⟹ anyinternal (cutoff red ds T2) (λp. ¬ red (ds @ p)); anybranch (Branching T1 T2) (λp. red (ds @ p))⟧ ⟹ anyinternal (cutoff red ds (Branching T1 T2)) (λp. ¬ red (ds @ p))›*) case Leaf (*‹anybranch Leaf (λp. red (ds @ p))›*) then show "?case" (*goal: ‹anyinternal (cutoff red ds Leaf) (λp. ¬ red (ds @ p))›*) using internal_inv_Leaf (*‹¬ internal ?b Leaf›*) by simp next (*goal: ‹⋀T1 T2 ds. ⟦⋀ds. anybranch T1 (λp. red (ds @ p)) ⟹ anyinternal (cutoff red ds T1) (λp. ¬ red (ds @ p)); ⋀ds. anybranch T2 (λp. red (ds @ p)) ⟹ anyinternal (cutoff red ds T2) (λp. ¬ red (ds @ p)); anybranch (Branching T1 T2) (λp. red (ds @ p))⟧ ⟹ anyinternal (cutoff red ds (Branching T1 T2)) (λp. ¬ red (ds @ p))›*) case (Branching T₁ T₂) (*‹anybranch T₁ (λp. red (?ds @ p)) ⟹ anyinternal (cutoff red ?ds T₁) (λp. ¬ red (?ds @ p))› ‹anybranch T₂ (λp. red (?ds @ p)) ⟹ anyinternal (cutoff red ?ds T₂) (λp. ¬ red (?ds @ p))› ‹anybranch (Branching T₁ T₂) (λp. red (ds @ p))›*) let ?T = "cutoff red ds (Branching T₁ T₂)" from Branching (*‹anybranch T₁ (λp. red (?ds @ p)) ⟹ anyinternal (cutoff red ?ds T₁) (λp. ¬ red (?ds @ p))› ‹anybranch T₂ (λp. red (?ds @ p)) ⟹ anyinternal (cutoff red ?ds T₂) (λp. ¬ red (?ds @ p))› ‹anybranch (Branching T₁ T₂) (λp. red (ds @ p))›*) have "∀p. branch (Left#p) (Branching T₁ T₂) ⟶ red (ds @ (Left#p))" by blast then have "∀p. branch p T₁ ⟶ red (ds @ (Left#p))" by auto then have "anybranch T₁ (λp. red ((ds @ [Left]) @ p))" by auto then have aa: "anyinternal (cutoff red (ds @ [Left]) T₁) (λp. ¬ red ((ds @ [Left]) @ p))" using Branching (*‹anybranch T₁ (λp. red (?ds @ p)) ⟹ anyinternal (cutoff red ?ds T₁) (λp. ¬ red (?ds @ p))› ‹anybranch T₂ (λp. red (?ds @ p)) ⟹ anyinternal (cutoff red ?ds T₂) (λp. ¬ red (?ds @ p))› ‹anybranch (Branching T₁ T₂) (λp. red (ds @ p))›*) by blast from Branching (*‹anybranch T₁ (λp. red (?ds @ p)) ⟹ anyinternal (cutoff red ?ds T₁) (λp. ¬ red (?ds @ p))› ‹anybranch T₂ (λp. red (?ds @ p)) ⟹ anyinternal (cutoff red ?ds T₂) (λp. ¬ red (?ds @ p))› ‹anybranch (Branching T₁ T₂) (λp. red (ds @ p))›*) have "∀p. branch (Right#p) (Branching T₁ T₂) ⟶ red (ds @ (Right#p))" by blast then have "∀p. branch p T₂ ⟶ red (ds @ (Right#p))" by auto then have "anybranch T₂ (λp. red ((ds @ [Right]) @ p))" by auto then have bb: "anyinternal (cutoff red (ds @ [Right]) T₂) (λp. ¬ red ((ds @ [Right]) @ p))" using Branching (*‹anybranch T₁ (λp. red (?ds @ p)) ⟹ anyinternal (cutoff red ?ds T₁) (λp. ¬ red (?ds @ p))› ‹anybranch T₂ (λp. red (?ds @ p)) ⟹ anyinternal (cutoff red ?ds T₂) (λp. ¬ red (?ds @ p))› ‹anybranch (Branching T₁ T₂) (λp. red (ds @ p))›*) by blast { fix p assume b_p: "internal p ?T" (*‹internal (p::bool list) (cutoff (red::bool list ⇒ bool) (ds::bool list) (Branching (T₁::tree) (T₂::tree)))›*) then have ds_p: "¬red ds" using internal_inv_Leaf (*‹¬ internal (?b::bool list) Leaf›*) by auto have "p=[] ∨ p≠[]" by auto then have "¬red(ds@p)" proof (standard) (*goals: 1. ‹p = [] ⟹ ¬ red (ds @ p)› 2. ‹p ≠ [] ⟹ ¬ red (ds @ p)›*) assume "p=[]" (*‹(p::bool list) = []›*) then show "¬red(ds@p)" using ds_p (*‹¬ red ds›*) by auto next (*goal: ‹p ≠ [] ⟹ ¬ red (ds @ p)›*) let ?T₁' = "cutoff red (ds@[Left]) T₁" let ?T₂' = "cutoff red (ds@[Right]) T₂" assume "p≠[]" (*‹(p::bool list) ≠ []›*) moreover have "?T = Branching ?T₁' ?T₂'" using ds_p (*‹¬ red ds›*) by auto ultimately obtain a and p' where b_p: "p = a # p' ∧ (a ⟶ internal p' (cutoff red (ds @ [Left]) T₁)) ∧ (¬ a ⟶ internal p' (cutoff red (ds @ [Right]) T₂))" (*goal: ‹(⋀a p'. p = a # p' ∧ (a ⟶ internal p' (cutoff red (ds @ [Left]) T₁)) ∧ (¬ a ⟶ internal p' (cutoff red (ds @ [Right]) T₂)) ⟹ thesis) ⟹ thesis›*) using b_p (*‹internal p (cutoff red ds (Branching T₁ T₂))›*) internal_inv_Branching[of p ?T₁' ?T₂'] (*‹internal p (Branching (cutoff red (ds @ [Left]) T₁) (cutoff red (ds @ [Right]) T₂)) = (p = [] ∨ (∃a p'. p = a # p' ∧ (a ⟶ internal p' (cutoff red (ds @ [Left]) T₁)) ∧ (¬ a ⟶ internal p' (cutoff red (ds @ [Right]) T₂))))›*) by auto then have "¬red(ds @ [a] @ p')" using aa (*‹anyinternal (cutoff red (ds @ [Left]) T₁) (λp. ¬ red ((ds @ [Left]) @ p))›*) bb (*‹anyinternal (cutoff red (ds @ [Right]) T₂) (λp. ¬ red ((ds @ [Right]) @ p))›*) apply (cases a) (*goals: 1. ‹⟦(p::bool list) = (a::bool) # (p'::bool list) ∧ (a ⟶ internal p' (cutoff (red::bool list ⇒ bool) ((ds::bool list) @ [Left]) (T₁::tree))) ∧ (¬ a ⟶ internal p' (cutoff red (ds @ [Right]) (T₂::tree))); anyinternal (cutoff red (ds @ [Left]) T₁) (λp::bool list. ¬ red ((ds @ [Left]) @ p)); anyinternal (cutoff red (ds @ [Right]) T₂) (λp::bool list. ¬ red ((ds @ [Right]) @ p)); a⟧ ⟹ ¬ red (ds @ [a] @ p')› 2. ‹⟦(p::bool list) = (a::bool) # (p'::bool list) ∧ (a ⟶ internal p' (cutoff (red::bool list ⇒ bool) ((ds::bool list) @ [Left]) (T₁::tree))) ∧ (¬ a ⟶ internal p' (cutoff red (ds @ [Right]) (T₂::tree))); anyinternal (cutoff red (ds @ [Left]) T₁) (λp::bool list. ¬ red ((ds @ [Left]) @ p)); anyinternal (cutoff red (ds @ [Right]) T₂) (λp::bool list. ¬ red ((ds @ [Right]) @ p)); ¬ a⟧ ⟹ ¬ red (ds @ [a] @ p')› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . then show "¬red(ds @ p)" using b_p (*‹(p::bool list) = (a::bool) # (p'::bool list) ∧ (a ⟶ internal p' (cutoff (red::bool list ⇒ bool) ((ds::bool list) @ [Left]) (T₁::tree))) ∧ (¬ a ⟶ internal p' (cutoff red (ds @ [Right]) (T₂::tree)))›*) by simp qed } then show "?case" (*goal: ‹anyinternal (cutoff red ds (Branching T₁ T₂)) (λp. ¬ red (ds @ p))›*) by blast qed lemma cutoff_internal: assumes "anybranch T red" shows "anyinternal (cutoff red [] T) (λp. ¬red p)" using assms (*‹anybranch T red›*) cutoff_internal'[of T red "[]"] (*‹anybranch T (λp. red ([] @ p)) ⟹ anyinternal (cutoff red [] T) (λp. ¬ red ([] @ p))›*) by auto lemma cutoff_branch_internal': assumes "anybranch T red" shows "anyinternal (cutoff red [] T) (λp. ¬red p) ∧ anybranch (cutoff red [] T) (λp. red p)" using assms (*‹anybranch T red›*) cutoff_internal[of T] (*‹anybranch (T::tree) (?red::bool list ⇒ bool) ⟹ anyinternal (cutoff ?red [] T) (λp::bool list. ¬ ?red p)›*) cutoff_branch[of T] (*‹anybranch T ?red ⟹ anybranch (cutoff ?red [] T) ?red›*) by blast lemma cutoff_branch_internal: assumes "anybranch T red" shows "∃T'. anyinternal T' (λp. ¬red p) ∧ anybranch T' (λp. red p)" using assms (*‹anybranch T red›*) cutoff_branch_internal' (*‹anybranch ?T ?red ⟹ anyinternal (cutoff ?red [] ?T) (λp. ¬ ?red p) ∧ anybranch (cutoff ?red [] ?T) ?red›*) by blast section ‹Possibly Infinite Trees› text ‹Possibly infinite trees are of type @{typ "dir list set"}.› abbreviation wf_tree :: "dir list set ⇒ bool" where "wf_tree T ≡ (∀ds d. (ds @ d) ∈ T ⟶ ds ∈ T)" text ‹The subtree in with root r› fun subtree :: "dir list set ⇒ dir list ⇒ dir list set" where "subtree T r = {ds ∈ T. ∃ds'. ds = r @ ds'}" text ‹A subtree of a tree is either in the left branch, the right branch, or is the tree itself› lemma subtree_pos: "subtree T ds ⊆ subtree T (ds @ [Left]) ∪ subtree T (ds @ [Right]) ∪ {ds}" apply (rule subsetI (*‹(⋀x::?'a. x ∈ (?A::?'a set) ⟹ x ∈ (?B::?'a set)) ⟹ ?A ⊆ ?B›*)) (*goal: ‹subtree T ds ⊆ subtree T (ds @ [Left]) ∪ subtree T (ds @ [Right]) ∪ {ds}›*) proof (rule Set.UnCI (*‹(?c ∉ ?B ⟹ ?c ∈ ?A) ⟹ ?c ∈ ?A ∪ ?B›*)) (*goal: ‹⋀x. ⟦x ∈ subtree T ds; x ∉ {ds}⟧ ⟹ x ∈ subtree T (ds @ [Left]) ∪ subtree T (ds @ [Right])›*) let ?subtree = "subtree T" fix x assume asm: "x ∈ ?subtree ds" (*‹(x::bool list) ∈ subtree (T::bool list set) (ds::bool list)›*) assume "x ∉ {ds}" (*‹(x::bool list) ∉ {ds::bool list}›*) then have "x ≠ ds" by simp then have "∃e d. x = ds @ [d] @ e" using asm (*‹x ∈ subtree T ds›*) list.exhaust (*‹⟦?y = [] ⟹ ?P; ⋀x21 x22. ?y = x21 # x22 ⟹ ?P⟧ ⟹ ?P›*) by auto then have "(∃e. x = ds @ [Left] @ e) ∨ (∃e. x = ds @ [Right] @ e)" using bool.exhaust (*‹⟦?y = True ⟹ ?P; ?y = False ⟹ ?P⟧ ⟹ ?P›*) by auto then show "x ∈ ?subtree (ds @ [Left]) ∪ ?subtree (ds @ [Right])" using asm (*‹x ∈ subtree T ds›*) by auto qed subsection ‹Infinite Paths› abbreviation wf_infpath :: "(nat ⇒ 'a list) ⇒ bool" where "wf_infpath f ≡ (f 0 = []) ∧ (∀n. ∃a. f (Suc n) = (f n) @ [a])" lemma infpath_length: assumes "wf_infpath f" shows "length (f n) = n" sorry lemma chain_prefix: assumes "wf_infpath f" assumes "n₁ ≤ n₂" shows "∃a. (f n₁) @ a = (f n₂)" using assms (*‹wf_infpath f› ‹(n₁::nat) ≤ (n₂::nat)›*) proof (induction n₂) (*goals: 1. ‹⟦wf_infpath f; n₁ ≤ 0⟧ ⟹ ∃a. f n₁ @ a = f 0› 2. ‹⋀n₂. ⟦⟦wf_infpath f; n₁ ≤ n₂⟧ ⟹ ∃a. f n₁ @ a = f n₂; wf_infpath f; n₁ ≤ Suc n₂⟧ ⟹ ∃a. f n₁ @ a = f (Suc n₂)›*) case (Suc n₂) (*‹⟦wf_infpath f; n₁ ≤ n₂⟧ ⟹ ∃a. f n₁ @ a = f n₂› ‹wf_infpath f› ‹n₁ ≤ Suc n₂›*) then have "n₁ ≤ n₂ ∨ n₁ = Suc n₂" by auto then show "?case" (*goal: ‹∃a. f n₁ @ a = f (Suc n₂)›*) proof (standard) (*goals: 1. ‹(n₁::nat) ≤ (n₂::nat) ⟹ ∃a::'a::type list. (f::nat ⇒ 'a::type list) n₁ @ a = f (Suc n₂)› 2. ‹(n₁::nat) = Suc (n₂::nat) ⟹ ∃a::'a::type list. (f::nat ⇒ 'a::type list) n₁ @ a = f (Suc n₂)›*) assume "n₁ ≤ n₂" (*‹(n₁::nat) ≤ (n₂::nat)›*) then obtain a where a: "f n₁ @ a = f n₂" (*goal: ‹(⋀a::'a list. (f::nat ⇒ 'a list) (n₁::nat) @ a = f (n₂::nat) ⟹ thesis::bool) ⟹ thesis›*) using Suc (*‹⟦wf_infpath (f::nat ⇒ 'a::type list); (n₁::nat) ≤ (n₂::nat)⟧ ⟹ ∃a::'a::type list. f n₁ @ a = f n₂› ‹wf_infpath f› ‹n₁ ≤ Suc n₂›*) by auto have b: "∃b. f (Suc n₂) = f n₂ @ [b]" using Suc (*‹⟦wf_infpath f; n₁ ≤ n₂⟧ ⟹ ∃a. f n₁ @ a = f n₂› ‹wf_infpath f› ‹n₁ ≤ Suc n₂›*) by auto from a (*‹f n₁ @ a = f n₂›*) b (*‹∃b. f (Suc n₂) = f n₂ @ [b]›*) have "∃b. f n₁ @ (a @ [b]) = f (Suc n₂)" by auto then show "∃c. f n₁ @ c = f (Suc n₂)" by blast next (*goal: ‹n₁ = Suc n₂ ⟹ ∃a. f n₁ @ a = f (Suc n₂)›*) assume "n₁ = Suc n₂" (*‹(n₁::nat) = Suc (n₂::nat)›*) then have "f n₁ @ [] = f (Suc n₂)" by auto then show "∃a. f n₁ @ a = f (Suc n₂)" by auto qed qed (auto) (*solved the remaining goal: ‹⟦wf_infpath (f::nat ⇒ 'a::type list); (n₁::nat) ≤ (0::nat)⟧ ⟹ ∃a::'a::type list. f n₁ @ a = f (0::nat)›*) text ‹If we make a lookup in a list, then looking up in an extension gives us the same value.› lemma ith_in_extension: assumes chain: "wf_infpath f" assumes smalli: "i < length (f n₁)" assumes n₁n₂: "n₁ ≤ n₂" shows "f n₁ ! i = f n₂ ! i" proof (-) (*goal: ‹f n₁ ! i = f n₂ ! i›*) from chain (*‹wf_infpath f›*) "n₁n₂" (*‹(n₁::nat) ≤ (n₂::nat)›*) have "∃a. f n₁ @ a = f n₂" using chain_prefix (*‹⟦wf_infpath ?f; ?n₁ ≤ ?n₂⟧ ⟹ ∃a. ?f ?n₁ @ a = ?f ?n₂›*) by blast then obtain a where a_p: "f n₁ @ a = f n₂" (*goal: ‹(⋀a. f n₁ @ a = f n₂ ⟹ thesis) ⟹ thesis›*) by auto have "(f n₁ @ a) ! i = f n₁ ! i" using smalli (*‹i < length (f n₁)›*) by (simp add: nth_append (*‹(?xs @ ?ys) ! ?n = (if ?n < length ?xs then ?xs ! ?n else ?ys ! (?n - length ?xs))›*)) then show "?thesis" (*goal: ‹f n₁ ! i = f n₂ ! i›*) using a_p (*‹f n₁ @ a = f n₂›*) by auto qed section ‹König's Lemma› lemma inf_subs: assumes inf: "¬finite(subtree T ds)" shows "¬finite(subtree T (ds @ [Left])) ∨ ¬finite(subtree T (ds @ [Right]))" proof (-) (*goal: ‹infinite (subtree T (ds @ [Left])) ∨ infinite (subtree T (ds @ [Right]))›*) let ?subtree = "subtree T" { assume asms: "finite(?subtree(ds @ [Left]))" "finite(?subtree(ds @ [Right]))" (*‹finite (subtree (T::bool list set) ((ds::bool list) @ [Left]))› ‹finite (subtree (T::bool list set) ((ds::bool list) @ [Right]))›*) have "?subtree ds ⊆ ?subtree (ds @ [Left] ) ∪ ?subtree (ds @ [Right]) ∪ {ds} " using subtree_pos (*‹subtree ?T ?ds ⊆ subtree ?T (?ds @ [Left]) ∪ subtree ?T (?ds @ [Right]) ∪ {?ds}›*) by auto then have "finite(?subtree (ds))" using asms (*‹finite (subtree T (ds @ [Left]))› ‹finite (subtree (T::bool list set) ((ds::bool list) @ [Right]))›*) by (simp add: finite_subset (*‹⟦?A ⊆ ?B; finite ?B⟧ ⟹ finite ?A›*)) } then show "¬finite(?subtree (ds @ [Left])) ∨ ¬finite(?subtree (ds @ [Right]))" using inf (*‹infinite (subtree (T::bool list set) (ds::bool list))›*) by auto qed fun buildchain :: "(dir list ⇒ dir list) ⇒ nat ⇒ dir list" where "buildchain next 0 = []" | "buildchain next (Suc n) = next (buildchain next n)" lemma konig: assumes inf: "¬finite T" assumes wellformed: "wf_tree T" shows "∃c. wf_infpath c ∧ (∀n. (c n) ∈ T)" proof (standard) (*goal: ‹wf_infpath ?c ∧ (∀n. ?c n ∈ T)›*) let ?subtree = "subtree T" let ?nextnode = "λds. (if ¬finite (?subtree (ds @ [Left])) then ds @ [Left] else ds @ [Right])" let ?c = "buildchain ?nextnode" have is_chain: "wf_infpath ?c" by auto from wellformed (*‹wf_tree (T::bool list set)›*) have prefix: "∀ds d. (ds @ d) ∈ T ⟶ ds ∈ T" by blast { fix n have "(?c n) ∈ T ∧ ¬finite (?subtree (?c n))" proof (induction n) (*goals: 1. ‹buildchain (λds. if infinite (subtree T (ds @ [Left])) then ds @ [Left] else ds @ [Right]) 0 ∈ T ∧ infinite (subtree T (buildchain (λds. if infinite (subtree T (ds @ [Left])) then ds @ [Left] else ds @ [Right]) 0))› 2. ‹⋀n. buildchain (λds. if infinite (subtree T (ds @ [Left])) then ds @ [Left] else ds @ [Right]) n ∈ T ∧ infinite (subtree T (buildchain (λds. if infinite (subtree T (ds @ [Left])) then ds @ [Left] else ds @ [Right]) n)) ⟹ buildchain (λds. if infinite (subtree T (ds @ [Left])) then ds @ [Left] else ds @ [Right]) (Suc n) ∈ T ∧ infinite (subtree T (buildchain (λds. if infinite (subtree T (ds @ [Left])) then ds @ [Left] else ds @ [Right]) (Suc n)))›*) case 0 (*no hyothesis introduced yet*) have "∃ds. ds ∈ T" using inf (*‹infinite T›*) by (simp add: not_finite_existsD (*‹infinite {a. ?P a} ⟹ ∃a. ?P a›*)) then obtain ds where "ds ∈ T" (*goal: ‹(⋀ds. ds ∈ T ⟹ thesis) ⟹ thesis›*) by auto then have "([]@ds) ∈ T" by auto then have "[] ∈ T" using prefix (*‹wf_tree T›*) by blast then show "?case" (*goal: ‹buildchain (λds. if infinite (subtree T (ds @ [Left])) then ds @ [Left] else ds @ [Right]) 0 ∈ T ∧ infinite (subtree T (buildchain (λds. if infinite (subtree T (ds @ [Left])) then ds @ [Left] else ds @ [Right]) 0))›*) using inf (*‹infinite T›*) by auto next (*goal: ‹⋀n. buildchain (λds. if infinite (subtree T (ds @ [Left])) then ds @ [Left] else ds @ [Right]) n ∈ T ∧ infinite (subtree T (buildchain (λds. if infinite (subtree T (ds @ [Left])) then ds @ [Left] else ds @ [Right]) n)) ⟹ buildchain (λds. if infinite (subtree T (ds @ [Left])) then ds @ [Left] else ds @ [Right]) (Suc n) ∈ T ∧ infinite (subtree T (buildchain (λds. if infinite (subtree T (ds @ [Left])) then ds @ [Left] else ds @ [Right]) (Suc n)))›*) case (Suc n) (*‹buildchain (λds. if infinite (subtree T (ds @ [Left])) then ds @ [Left] else ds @ [Right]) n ∈ T ∧ infinite (subtree T (buildchain (λds. if infinite (subtree T (ds @ [Left])) then ds @ [Left] else ds @ [Right]) n))›*) from Suc (*‹buildchain (λds. if infinite (subtree T (ds @ [Left])) then ds @ [Left] else ds @ [Right]) n ∈ T ∧ infinite (subtree T (buildchain (λds. if infinite (subtree T (ds @ [Left])) then ds @ [Left] else ds @ [Right]) n))›*) have next_in: "(?c n) ∈ T" by auto from Suc (*‹buildchain (λds::bool list. if infinite (subtree (T::bool list set) (ds @ [Left])) then ds @ [Left] else ds @ [Right]) (n::nat) ∈ T ∧ infinite (subtree T (buildchain (λds::bool list. if infinite (subtree T (ds @ [Left])) then ds @ [Left] else ds @ [Right]) n))›*) have next_inf: "¬finite (?subtree (?c n))" by auto from next_inf (*‹infinite (subtree T (buildchain (λds. if infinite (subtree T (ds @ [Left])) then ds @ [Left] else ds @ [Right]) n))›*) have next_next_inf: "¬finite (?subtree (?nextnode (?c n)))" using inf_subs (*‹infinite (subtree ?T ?ds) ⟹ infinite (subtree ?T (?ds @ [Left])) ∨ infinite (subtree ?T (?ds @ [Right]))›*) by auto then have "∃ds. ds ∈ ?subtree (?nextnode (?c n))" by (simp add: not_finite_existsD (*‹infinite {a::?'a::type. (?P::?'a::type ⇒ bool) a} ⟹ ∃a::?'a::type. ?P a›*)) then obtain ds where dss: "ds ∈ ?subtree (?nextnode (?c n))" (*goal: ‹(⋀ds::bool list. ds ∈ subtree (T::bool list set) (if infinite (subtree T (buildchain (λds::bool list. if infinite (subtree T (ds @ [Left])) then ds @ [Left] else ds @ [Right]) (n::nat) @ [Left])) then buildchain (λds::bool list. if infinite (subtree T (ds @ [Left])) then ds @ [Left] else ds @ [Right]) n @ [Left] else buildchain (λds::bool list. if infinite (subtree T (ds @ [Left])) then ds @ [Left] else ds @ [Right]) n @ [Right]) ⟹ thesis::bool) ⟹ thesis›*) by auto then have "ds ∈ T" "∃suf. ds = (?nextnode (?c n)) @ suf" apply - (*goals: 1. ‹ds ∈ subtree T (if infinite (subtree T (buildchain (λds. if infinite (subtree T (ds @ [Left])) then ds @ [Left] else ds @ [Right]) n @ [Left])) then buildchain (λds. if infinite (subtree T (ds @ [Left])) then ds @ [Left] else ds @ [Right]) n @ [Left] else buildchain (λds. if infinite (subtree T (ds @ [Left])) then ds @ [Left] else ds @ [Right]) n @ [Right]) ⟹ ds ∈ T› 2. ‹ds ∈ subtree T (if infinite (subtree T (buildchain (λds. if infinite (subtree T (ds @ [Left])) then ds @ [Left] else ds @ [Right]) n @ [Left])) then buildchain (λds. if infinite (subtree T (ds @ [Left])) then ds @ [Left] else ds @ [Right]) n @ [Left] else buildchain (λds. if infinite (subtree T (ds @ [Left])) then ds @ [Left] else ds @ [Right]) n @ [Right]) ⟹ ∃suf. ds = (if infinite (subtree T (buildchain (λds. if infinite (subtree T (ds @ [Left])) then ds @ [Left] else ds @ [Right]) n @ [Left])) then buildchain (λds. if infinite (subtree T (ds @ [Left])) then ds @ [Left] else ds @ [Right]) n @ [Left] else buildchain (λds. if infinite (subtree T (ds @ [Left])) then ds @ [Left] else ds @ [Right]) n @ [Right]) @ suf› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . then obtain suf where "ds ∈ T ∧ ds = (?nextnode (?c n)) @ suf" (*goal: ‹(⋀suf::bool list. (ds::bool list) ∈ (T::bool list set) ∧ ds = (if infinite (subtree T (buildchain (λds::bool list. if infinite (subtree T (ds @ [Left])) then ds @ [Left] else ds @ [Right]) (n::nat) @ [Left])) then buildchain (λds::bool list. if infinite (subtree T (ds @ [Left])) then ds @ [Left] else ds @ [Right]) n @ [Left] else buildchain (λds::bool list. if infinite (subtree T (ds @ [Left])) then ds @ [Left] else ds @ [Right]) n @ [Right]) @ suf ⟹ thesis::bool) ⟹ thesis›*) by auto then have "(?nextnode (?c n)) ∈ T" using prefix (*‹wf_tree T›*) by blast then have "(?c (Suc n)) ∈ T" by auto then show "?case" (*goal: ‹buildchain (λds. if infinite (subtree T (ds @ [Left])) then ds @ [Left] else ds @ [Right]) (Suc n) ∈ T ∧ infinite (subtree T (buildchain (λds. if infinite (subtree T (ds @ [Left])) then ds @ [Left] else ds @ [Right]) (Suc n)))›*) using next_next_inf (*‹infinite (subtree T (if infinite (subtree T (buildchain (λds. if infinite (subtree T (ds @ [Left])) then ds @ [Left] else ds @ [Right]) n @ [Left])) then buildchain (λds. if infinite (subtree T (ds @ [Left])) then ds @ [Left] else ds @ [Right]) n @ [Left] else buildchain (λds. if infinite (subtree T (ds @ [Left])) then ds @ [Left] else ds @ [Right]) n @ [Right]))›*) by auto qed } then show "wf_infpath ?c ∧ (∀n. (?c n)∈ T) " using is_chain (*‹wf_infpath (buildchain (λds. if infinite (subtree T (ds @ [Left])) then ds @ [Left] else ds @ [Right]))›*) by auto qed end
{ "path": "afp-2025-02-12/thys/Resolution_FOL/Tree.thy", "repo": "afp-2025-02-12", "sha": "5d5c8c86fc59af4f31425ca0ba8bc804784f7770901204414c36a82a0fec1e0b" }
section ‹Examples for the WS1S/Presburger Mixture› (*<*) theory WS1S_Presburger_Examples imports Formula_Derivatives.WS1S_Presburger_Equivalence begin (*>*) lemma "check_eqv (Abs_idx (0, 0)) 0 (FEx SO (FBase (Eq_Presb None 0 42))) (FEx () (FBase (Eq [1] 42 0)))" by (msorry) lemma "check_eqv (Abs_idx (0, 1)) 1 (FBase (Eq_Presb None 0 42)) (FBase (Eq [1] 42 0))" by (msorry) lemma "check_eqv (Abs_idx (0, 2)) 2 (FBase (Suc_SO False False 1 0)) (FBase (Eq [2, -1] 0 0))" by (msorry) lemma "check_eqv (Abs_idx (0, 1)) 1 (FBase (Empty 0)) (FBase (Eq [1] 0 0))" by (msorry) lemma "check_eqv (Abs_idx (0, 1)) 1 (FBase (Empty 0)) (FBase (Eq [-1] 0 0))" by (msorry) lemma "check_eqv (Abs_idx (0, 0)) 0 (FNot (FEx SO (FAll FO (FBase (In False 0 0))))) (FAll () (FEx () (FEx () (FBase (Eq [3, 5, -1] 8 0)))))" by (msorry) (*<*) end (*>*)
{ "path": "afp-2025-02-12/thys/Formula_Derivatives/Examples/WS1S_Presburger_Examples.thy", "repo": "afp-2025-02-12", "sha": "6488e5556ddde6e6efedf1a591322dd3de976ac0121be474d65b09e878c81375" }
(* Copyright 2021 (C) Mihails Milehins *) section‹Subsemicategory› theory CZH_SMC_Subsemicategory imports CZH_DG_Subdigraph CZH_SMC_Semifunctor begin subsection‹Background› named_theorems smc_sub_cs_intros named_theorems smc_sub_bw_cs_intros named_theorems smc_sub_fw_cs_intros named_theorems smc_sub_bw_cs_simps subsection‹Simple subsemicategory› subsubsection‹Definition and elementary properties› text‹See Chapter I-3 in \<^cite>‹"mac_lane_categories_2010"›.› locale subsemicategory = sdg: semicategory α 𝔅 + dg: semicategory α ℭ for α 𝔅 ℭ + assumes subsmc_subdigraph[slicing_intros]: "smc_dg 𝔅 ⊆⇩D⇩G⇘α⇙ smc_dg ℭ" and subsmc_Comp[smc_sub_fw_cs_intros]: "⟦ g : b ↦⇘𝔅⇙ c; f : a ↦⇘𝔅⇙ b ⟧ ⟹ g ∘⇩A⇘𝔅⇙ f = g ∘⇩A⇘ℭ⇙ f" abbreviation is_subsemicategory ("(_/ ⊆⇩S⇩M⇩Cı _)" [51, 51] 50) where "𝔅 ⊆⇩S⇩M⇩C⇘α⇙ ℭ ≡ subsemicategory α 𝔅 ℭ" lemmas [smc_sub_fw_cs_intros] = subsemicategory.subsmc_Comp text‹Rules.› lemma (in subsemicategory) subsemicategory_axioms'[smc_cs_intros]: assumes "α' = α" and "𝔅' = 𝔅" shows "𝔅' ⊆⇩S⇩M⇩C⇘α'⇙ ℭ" unfolding assms (*goal: ‹𝔅 ⊆⇩S⇩M⇩C⇘α⇙ ℭ›*) by (rule subsemicategory_axioms (*‹𝔅 ⊆⇩S⇩M⇩C⇘α⇙ ℭ›*)) lemma (in subsemicategory) subsemicategory_axioms''[smc_cs_intros]: assumes "α' = α" and "ℭ' = ℭ" shows "𝔅 ⊆⇩S⇩M⇩C⇘α'⇙ ℭ'" unfolding assms (*goal: ‹𝔅 ⊆⇩S⇩M⇩C⇘α⇙ ℭ›*) by (rule subsemicategory_axioms (*‹𝔅 ⊆⇩S⇩M⇩C⇘α⇙ ℭ›*)) mk_ide rf subsemicategory_def[unfolded subsemicategory_axioms_def] |intro subsemicategoryI| |dest subsemicategoryD[dest]| |elim subsemicategoryE[elim!]| lemmas [smc_sub_cs_intros] = subsemicategoryD(1,2) lemma subsemicategoryI': assumes "semicategory α 𝔅" and "semicategory α ℭ" and "⋀a. a ∈⇩∘ 𝔅⦇Obj⦈ ⟹ a ∈⇩∘ ℭ⦇Obj⦈" and "⋀a b f. f : a ↦⇘𝔅⇙ b ⟹ f : a ↦⇘ℭ⇙ b" and "⋀b c g a f. ⟦ g : b ↦⇘𝔅⇙ c; f : a ↦⇘𝔅⇙ b ⟧ ⟹ g ∘⇩A⇘𝔅⇙ f = g ∘⇩A⇘ℭ⇙ f" shows "𝔅 ⊆⇩S⇩M⇩C⇘α⇙ ℭ" proof (-) (*goal: ‹𝔅 ⊆⇩S⇩M⇩C⇘α⇙ ℭ›*) interpret 𝔅: semicategory "α" "𝔅" by (rule assms( (*‹semicategory α 𝔅›*) 1)) interpret ℭ: semicategory "α" "ℭ" by (rule assms( (*‹semicategory (α::V) (ℭ::V)›*) 2)) show "?thesis" (*goal: ‹(𝔅::V) ⊆⇩S⇩M⇩C⇘α::V⇙ (ℭ::V)›*) apply (intro subsemicategoryI (*‹⟦semicategory ?α ?𝔅; semicategory ?α ?ℭ; smc_dg ?𝔅 ⊆⇩D⇩G⇘?α⇙ smc_dg ?ℭ; ⋀b c g a f. ⟦g : b ↦⇘?𝔅⇙ c; f : a ↦⇘?𝔅⇙ b⟧ ⟹ g ∘⇩A⇘?𝔅⇙ f = g ∘⇩A⇘?ℭ⇙ f⟧ ⟹ ?𝔅 ⊆⇩S⇩M⇩C⇘?α⇙ ?ℭ›*) subdigraphI (*‹⟦digraph ?α ?𝔅; digraph ?α ?ℭ; ⋀a. a ∈⇩∘ ?𝔅⦇Obj⦈ ⟹ a ∈⇩∘ ?ℭ⦇Obj⦈; ⋀a b f. f : a ↦⇘?𝔅⇙ b ⟹ f : a ↦⇘?ℭ⇙ b⟧ ⟹ ?𝔅 ⊆⇩D⇩G⇘?α⇙ ?ℭ›*)) (*goals: 1. ‹semicategory α 𝔅› 2. ‹semicategory α ℭ› 3. ‹digraph α (smc_dg 𝔅)› 4. ‹digraph α (smc_dg ℭ)› 5. ‹⋀a. a ∈⇩∘ smc_dg 𝔅⦇Obj⦈ ⟹ a ∈⇩∘ smc_dg ℭ⦇Obj⦈› 6. ‹⋀a b f. f : a ↦⇘smc_dg 𝔅⇙ b ⟹ f : a ↦⇘smc_dg ℭ⇙ b› 7. ‹⋀b c g a f. ⟦g : b ↦⇘𝔅⇙ c; f : a ↦⇘𝔅⇙ b⟧ ⟹ g ∘⇩A⇘𝔅⇙ f = g ∘⇩A⇘ℭ⇙ f› discuss goal 1*) apply (intro 𝔅.smc_digraph (*‹digraph α (smc_dg 𝔅)›*) ℭ.smc_digraph (*‹digraph α (smc_dg ℭ)›*) assms (*‹semicategory α 𝔅› ‹semicategory α ℭ› ‹?a ∈⇩∘ 𝔅⦇Obj⦈ ⟹ ?a ∈⇩∘ ℭ⦇Obj⦈› ‹?f : ?a ↦⇘𝔅⇙ ?b ⟹ ?f : ?a ↦⇘ℭ⇙ ?b› ‹⟦?g : ?b ↦⇘𝔅⇙ ?c; ?f : ?a ↦⇘𝔅⇙ ?b⟧ ⟹ ?g ∘⇩A⇘𝔅⇙ ?f = ?g ∘⇩A⇘ℭ⇙ ?f›*)) (*discuss goal 2*) apply (intro 𝔅.smc_digraph (*‹digraph α (smc_dg 𝔅)›*) ℭ.smc_digraph (*‹digraph α (smc_dg ℭ)›*) assms (*‹semicategory α 𝔅› ‹semicategory α ℭ› ‹?a ∈⇩∘ 𝔅⦇Obj⦈ ⟹ ?a ∈⇩∘ ℭ⦇Obj⦈› ‹?f : ?a ↦⇘𝔅⇙ ?b ⟹ ?f : ?a ↦⇘ℭ⇙ ?b› ‹⟦?g : ?b ↦⇘𝔅⇙ ?c; ?f : ?a ↦⇘𝔅⇙ ?b⟧ ⟹ ?g ∘⇩A⇘𝔅⇙ ?f = ?g ∘⇩A⇘ℭ⇙ ?f›*)) (*discuss goal 3*) apply (intro 𝔅.smc_digraph (*‹digraph α (smc_dg 𝔅)›*) ℭ.smc_digraph (*‹digraph α (smc_dg ℭ)›*) assms (*‹semicategory α 𝔅› ‹semicategory α ℭ› ‹?a ∈⇩∘ 𝔅⦇Obj⦈ ⟹ ?a ∈⇩∘ ℭ⦇Obj⦈› ‹?f : ?a ↦⇘𝔅⇙ ?b ⟹ ?f : ?a ↦⇘ℭ⇙ ?b› ‹⟦?g : ?b ↦⇘𝔅⇙ ?c; ?f : ?a ↦⇘𝔅⇙ ?b⟧ ⟹ ?g ∘⇩A⇘𝔅⇙ ?f = ?g ∘⇩A⇘ℭ⇙ ?f›*)) (*discuss goal 4*) apply (intro 𝔅.smc_digraph (*‹digraph (α::V) (smc_dg (𝔅::V))›*) ℭ.smc_digraph (*‹digraph (α::V) (smc_dg (ℭ::V))›*) assms (*‹semicategory (α::V) (𝔅::V)› ‹semicategory (α::V) (ℭ::V)› ‹(?a::V) ∈⇩∘ (𝔅::V)⦇Obj⦈ ⟹ ?a ∈⇩∘ (ℭ::V)⦇Obj⦈› ‹(?f::V) : (?a::V) ↦⇘𝔅::V⇙ (?b::V) ⟹ ?f : ?a ↦⇘ℭ::V⇙ ?b› ‹⟦(?g::V) : (?b::V) ↦⇘𝔅::V⇙ (?c::V); (?f::V) : (?a::V) ↦⇘𝔅⇙ ?b⟧ ⟹ ?g ∘⇩A⇘𝔅⇙ ?f = ?g ∘⇩A⇘ℭ::V⇙ ?f›*)) (*discuss goal 5*) apply ((unfold slicing_simps (*‹smc_dg ?ℭ⦇Obj⦈ = ?ℭ⦇Obj⦈› ‹smc_dg ?ℭ⦇Arr⦈ = ?ℭ⦇Arr⦈› ‹smc_dg ?ℭ⦇Dom⦈ = ?ℭ⦇Dom⦈› ‹smc_dg ?ℭ⦇Cod⦈ = ?ℭ⦇Cod⦈› ‹?f : ?a ↦⇘smc_dg ?ℭ⇙ ?b = ?f : ?a ↦⇘?ℭ⇙ ?b› ‹smcf_dghm ?𝔉⦇ObjMap⦈ = ?𝔉⦇ObjMap⦈› ‹smcf_dghm ?𝔉⦇ArrMap⦈ = ?𝔉⦇ArrMap⦈›*))[1]) (*top goal: ‹⋀a. a ∈⇩∘ smc_dg 𝔅⦇Obj⦈ ⟹ a ∈⇩∘ smc_dg ℭ⦇Obj⦈› and 2 goals remain*) apply (intro 𝔅.smc_digraph (*‹digraph α (smc_dg 𝔅)›*) ℭ.smc_digraph (*‹digraph α (smc_dg ℭ)›*) assms (*‹semicategory α 𝔅› ‹semicategory α ℭ› ‹?a ∈⇩∘ 𝔅⦇Obj⦈ ⟹ ?a ∈⇩∘ ℭ⦇Obj⦈› ‹?f : ?a ↦⇘𝔅⇙ ?b ⟹ ?f : ?a ↦⇘ℭ⇙ ?b› ‹⟦?g : ?b ↦⇘𝔅⇙ ?c; ?f : ?a ↦⇘𝔅⇙ ?b⟧ ⟹ ?g ∘⇩A⇘𝔅⇙ ?f = ?g ∘⇩A⇘ℭ⇙ ?f›*)) (*top goal: ‹⋀a. a ∈⇩∘ 𝔅⦇Obj⦈ ⟹ a ∈⇩∘ ℭ⦇Obj⦈› and 2 goals remain*) apply ((assumption)[1]) (*discuss goal 6*) apply ((unfold slicing_simps (*‹smc_dg (?ℭ::V)⦇Obj⦈ = ?ℭ⦇Obj⦈› ‹smc_dg (?ℭ::V)⦇Arr⦈ = ?ℭ⦇Arr⦈› ‹smc_dg (?ℭ::V)⦇Dom⦈ = ?ℭ⦇Dom⦈› ‹smc_dg (?ℭ::V)⦇Cod⦈ = ?ℭ⦇Cod⦈› ‹(?f::V) : (?a::V) ↦⇘smc_dg (?ℭ::V)⇙ (?b::V) = ?f : ?a ↦⇘?ℭ⇙ ?b› ‹smcf_dghm (?𝔉::V)⦇ObjMap⦈ = ?𝔉⦇ObjMap⦈› ‹smcf_dghm (?𝔉::V)⦇ArrMap⦈ = ?𝔉⦇ArrMap⦈›*))[1]) (*top goal: ‹⋀a b f. f : a ↦⇘smc_dg 𝔅⇙ b ⟹ f : a ↦⇘smc_dg ℭ⇙ b› and 1 goal remains*) apply (intro 𝔅.smc_digraph (*‹digraph (α::V) (smc_dg (𝔅::V))›*) ℭ.smc_digraph (*‹digraph (α::V) (smc_dg (ℭ::V))›*) assms (*‹semicategory (α::V) (𝔅::V)› ‹semicategory (α::V) (ℭ::V)› ‹(?a::V) ∈⇩∘ (𝔅::V)⦇Obj⦈ ⟹ ?a ∈⇩∘ (ℭ::V)⦇Obj⦈› ‹(?f::V) : (?a::V) ↦⇘𝔅::V⇙ (?b::V) ⟹ ?f : ?a ↦⇘ℭ::V⇙ ?b› ‹⟦(?g::V) : (?b::V) ↦⇘𝔅::V⇙ (?c::V); (?f::V) : (?a::V) ↦⇘𝔅⇙ ?b⟧ ⟹ ?g ∘⇩A⇘𝔅⇙ ?f = ?g ∘⇩A⇘ℭ::V⇙ ?f›*)) (*top goal: ‹⋀a b f. f : a ↦⇘𝔅⇙ b ⟹ f : a ↦⇘ℭ⇙ b› and 1 goal remains*) apply ((assumption)[1]) (*discuss goal 7*) apply (intro 𝔅.smc_digraph (*‹digraph α (smc_dg 𝔅)›*) ℭ.smc_digraph (*‹digraph α (smc_dg ℭ)›*) assms (*‹semicategory α 𝔅› ‹semicategory α ℭ› ‹?a ∈⇩∘ 𝔅⦇Obj⦈ ⟹ ?a ∈⇩∘ ℭ⦇Obj⦈› ‹?f : ?a ↦⇘𝔅⇙ ?b ⟹ ?f : ?a ↦⇘ℭ⇙ ?b› ‹⟦?g : ?b ↦⇘𝔅⇙ ?c; ?f : ?a ↦⇘𝔅⇙ ?b⟧ ⟹ ?g ∘⇩A⇘𝔅⇙ ?f = ?g ∘⇩A⇘ℭ⇙ ?f›*)) (*goals: 1. ‹⋀(b::V) (c::V) (g::V) (a::V) f::V. ⟦g : b ↦⇘𝔅::V⇙ c; f : a ↦⇘𝔅⇙ b⟧ ⟹ g : (?b12::V ⇒ V ⇒ V ⇒ V ⇒ V ⇒ V) b c g a f ↦⇘𝔅⇙ (?c12::V ⇒ V ⇒ V ⇒ V ⇒ V ⇒ V) b c g a f› 2. ‹⋀(b::V) (c::V) (g::V) (a::V) f::V. ⟦g : b ↦⇘𝔅::V⇙ c; f : a ↦⇘𝔅⇙ b⟧ ⟹ f : (?a12::V ⇒ V ⇒ V ⇒ V ⇒ V ⇒ V) b c g a f ↦⇘𝔅⇙ (?b12::V ⇒ V ⇒ V ⇒ V ⇒ V ⇒ V) b c g a f› discuss goal 1*) apply ((assumption)[1]) (*discuss goal 2*) . (*proven 2 subgoals*) (*proven 7 subgoals*) qed text‹Subsemicategory is a subdigraph.› context subsemicategory begin interpretation subdg: subdigraph α ‹smc_dg 𝔅› ‹smc_dg ℭ› by (rule subsmc_subdigraph (*‹smc_dg 𝔅 ⊆⇩D⇩G⇘α⇙ smc_dg ℭ›*)) lemmas_with [unfolded slicing_simps]: subsmc_Obj_vsubset = subdg.subdg_Obj_vsubset and subsmc_is_arr_vsubset = subdg.subdg_is_arr_vsubset and subsmc_subdigraph_op_dg_op_dg = subdg.subdg_subdigraph_op_dg_op_dg and subsmc_objD = subdg.subdg_objD and subsmc_arrD = subdg.subdg_arrD and subsmc_dom_simp = subdg.subdg_dom_simp and subsmc_cod_simp = subdg.subdg_cod_simp and subsmc_is_arrD = subdg.subdg_is_arrD and subsmc_dghm_inc_op_dg_is_dghm = subdg.subdg_dghm_inc_op_dg_is_dghm and subsmc_op_dg_dghm_inc = subdg.subdg_op_dg_dghm_inc and subsmc_inc_is_ft_dghm_axioms = subdg.inc.is_ft_dghm_axioms end lemmas subsmc_subdigraph_op_dg_op_dg[intro] = subsemicategory.subsmc_subdigraph_op_dg_op_dg lemmas [smc_sub_fw_cs_intros] = subsemicategory.subsmc_Obj_vsubset subsemicategory.subsmc_is_arr_vsubset subsemicategory.subsmc_objD subsemicategory.subsmc_arrD subsemicategory.subsmc_is_arrD lemmas [smc_sub_bw_cs_simps] = subsemicategory.subsmc_dom_simp subsemicategory.subsmc_cod_simp text‹The opposite subsemicategory.› lemma (in subsemicategory) subsmc_subsemicategory_op_smc: "op_smc 𝔅 ⊆⇩S⇩M⇩C⇘α⇙ op_smc ℭ" proof (rule subsemicategoryI (*‹⟦semicategory (?α::V) (?𝔅::V); semicategory ?α (?ℭ::V); smc_dg ?𝔅 ⊆⇩D⇩G⇘?α⇙ smc_dg ?ℭ; ⋀(b::V) (c::V) (g::V) (a::V) f::V. ⟦g : b ↦⇘?𝔅⇙ c; f : a ↦⇘?𝔅⇙ b⟧ ⟹ g ∘⇩A⇘?𝔅⇙ f = g ∘⇩A⇘?ℭ⇙ f⟧ ⟹ ?𝔅 ⊆⇩S⇩M⇩C⇘?α⇙ ?ℭ›*)) (*goals: 1. ‹semicategory (α::V) (op_smc (𝔅::V))› 2. ‹semicategory (α::V) (op_smc (ℭ::V))› 3. ‹smc_dg (op_smc (𝔅::V)) ⊆⇩D⇩G⇘α::V⇙ smc_dg (op_smc (ℭ::V))› 4. ‹⋀(b::V) (c::V) (g::V) (a::V) f::V. ⟦g : b ↦⇘op_smc (𝔅::V)⇙ c; f : a ↦⇘op_smc 𝔅⇙ b⟧ ⟹ g ∘⇩A⇘op_smc 𝔅⇙ f = g ∘⇩A⇘op_smc (ℭ::V)⇙ f›*) fix g and b and c and f and a assume prems: "g : b ↦⇘op_smc 𝔅⇙ c" "f : a ↦⇘op_smc 𝔅⇙ b" (*‹(g::V) : (b::V) ↦⇘op_smc (𝔅::V)⇙ (c::V)› ‹(f::V) : (a::V) ↦⇘op_smc (𝔅::V)⇙ (b::V)›*) then have "g : c ↦⇘𝔅⇙ b" and "f : b ↦⇘𝔅⇙ a" apply - (*goals: 1. ‹⟦g : b ↦⇘op_smc 𝔅⇙ c; f : a ↦⇘op_smc 𝔅⇙ b⟧ ⟹ g : c ↦⇘𝔅⇙ b› 2. ‹⟦g : b ↦⇘op_smc 𝔅⇙ c; f : a ↦⇘op_smc 𝔅⇙ b⟧ ⟹ f : b ↦⇘𝔅⇙ a› discuss goal 1*) apply (simp add: smc_op_simps (*‹op_smc ?ℭ⦇Obj⦈ = ?ℭ⦇Obj⦈› ‹op_smc ?ℭ⦇Arr⦈ = ?ℭ⦇Arr⦈› ‹op_smc ?ℭ⦇Dom⦈ = ?ℭ⦇Cod⦈› ‹op_smc ?ℭ⦇Cod⦈ = ?ℭ⦇Dom⦈› ‹𝒟⇩∘ (op_smc ?ℭ⦇Comp⦈) = (𝒟⇩∘ (?ℭ⦇Comp⦈))¯⇩∙› ‹?f : ?b ↦⇘op_smc ?ℭ⇙ ?a = ?f : ?a ↦⇘?ℭ⇙ ?b› ‹semicategory ?α ?ℭ ⟹ ℛ⇩∘ (op_smc ?ℭ⦇Comp⦈) = ℛ⇩∘ (?ℭ⦇Comp⦈)› ‹⟦semicategory ?α ?ℭ; ?f : ?b ↦⇘?ℭ⇙ ?c; ?g : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?g ∘⇩A⇘op_smc ?ℭ⇙ ?f = ?f ∘⇩A⇘?ℭ⇙ ?g› ‹Hom (op_smc ?ℭ) ?a ?b = Hom ?ℭ ?b ?a› ‹semicategory ?α ?ℭ ⟹ op_smc (op_smc ?ℭ) = ?ℭ› ‹⟦semicategory ?α ?𝔄; semicategory ?α ?𝔅⟧ ⟹ (op_smc ?𝔄 = op_smc ?𝔅) = (?𝔄 = ?𝔅)› ‹obj_initial (op_smc ?ℭ) = obj_terminal ?ℭ› and more 26 facts*)) (*discuss goal 2*) apply (simp add: smc_op_simps (*‹op_smc ?ℭ⦇Obj⦈ = ?ℭ⦇Obj⦈› ‹op_smc ?ℭ⦇Arr⦈ = ?ℭ⦇Arr⦈› ‹op_smc ?ℭ⦇Dom⦈ = ?ℭ⦇Cod⦈› ‹op_smc ?ℭ⦇Cod⦈ = ?ℭ⦇Dom⦈› ‹𝒟⇩∘ (op_smc ?ℭ⦇Comp⦈) = (𝒟⇩∘ (?ℭ⦇Comp⦈))¯⇩∙› ‹?f : ?b ↦⇘op_smc ?ℭ⇙ ?a = ?f : ?a ↦⇘?ℭ⇙ ?b› ‹semicategory ?α ?ℭ ⟹ ℛ⇩∘ (op_smc ?ℭ⦇Comp⦈) = ℛ⇩∘ (?ℭ⦇Comp⦈)› ‹⟦semicategory ?α ?ℭ; ?f : ?b ↦⇘?ℭ⇙ ?c; ?g : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?g ∘⇩A⇘op_smc ?ℭ⇙ ?f = ?f ∘⇩A⇘?ℭ⇙ ?g› ‹Hom (op_smc ?ℭ) ?a ?b = Hom ?ℭ ?b ?a› ‹semicategory ?α ?ℭ ⟹ op_smc (op_smc ?ℭ) = ?ℭ› ‹⟦semicategory ?α ?𝔄; semicategory ?α ?𝔅⟧ ⟹ (op_smc ?𝔄 = op_smc ?𝔅) = (?𝔄 = ?𝔅)› ‹obj_initial (op_smc ?ℭ) = obj_terminal ?ℭ› and more 26 facts*)) (*proven 2 subgoals*) . with subsemicategory_axioms (*‹𝔅 ⊆⇩S⇩M⇩C⇘α⇙ ℭ›*) have g: "g : c ↦⇘ℭ⇙ b" and f: "f : b ↦⇘ℭ⇙ a" apply - (*goals: 1. ‹⟦𝔅 ⊆⇩S⇩M⇩C⇘α⇙ ℭ; g : c ↦⇘𝔅⇙ b; f : b ↦⇘𝔅⇙ a⟧ ⟹ g : c ↦⇘ℭ⇙ b› 2. ‹⟦𝔅 ⊆⇩S⇩M⇩C⇘α⇙ ℭ; g : c ↦⇘𝔅⇙ b; f : b ↦⇘𝔅⇙ a⟧ ⟹ f : b ↦⇘ℭ⇙ a› discuss goal 1*) apply (cs_concl cs_shallow cs_intro: smc_sub_fw_cs_intros) (*discuss goal 2*) apply (cs_concl cs_shallow cs_intro: smc_sub_fw_cs_intros) (*proven 2 subgoals*) . from dg.op_smc_Comp[OF this ( 2 , 1 )] (*‹(g::V) ∘⇩A⇘op_smc (ℭ::V)⇙ (f::V) = f ∘⇩A⇘ℭ⇙ g›*) have "g ∘⇩A⇘op_smc ℭ⇙ f = f ∘⇩A⇘ℭ⇙ g" . with prems (*‹g : b ↦⇘op_smc 𝔅⇙ c› ‹(f::V) : (a::V) ↦⇘op_smc (𝔅::V)⇙ (b::V)›*) show "g ∘⇩A⇘op_smc 𝔅⇙ f = g ∘⇩A⇘op_smc ℭ⇙ f" by (simp add: smc_op_simps (*‹op_smc ?ℭ⦇Obj⦈ = ?ℭ⦇Obj⦈› ‹op_smc ?ℭ⦇Arr⦈ = ?ℭ⦇Arr⦈› ‹op_smc ?ℭ⦇Dom⦈ = ?ℭ⦇Cod⦈› ‹op_smc ?ℭ⦇Cod⦈ = ?ℭ⦇Dom⦈› ‹𝒟⇩∘ (op_smc ?ℭ⦇Comp⦈) = (𝒟⇩∘ (?ℭ⦇Comp⦈))¯⇩∙› ‹?f : ?b ↦⇘op_smc ?ℭ⇙ ?a = ?f : ?a ↦⇘?ℭ⇙ ?b› ‹semicategory ?α ?ℭ ⟹ ℛ⇩∘ (op_smc ?ℭ⦇Comp⦈) = ℛ⇩∘ (?ℭ⦇Comp⦈)› ‹⟦semicategory ?α ?ℭ; ?f : ?b ↦⇘?ℭ⇙ ?c; ?g : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?g ∘⇩A⇘op_smc ?ℭ⇙ ?f = ?f ∘⇩A⇘?ℭ⇙ ?g› ‹Hom (op_smc ?ℭ) ?a ?b = Hom ?ℭ ?b ?a› ‹semicategory ?α ?ℭ ⟹ op_smc (op_smc ?ℭ) = ?ℭ› ‹⟦semicategory ?α ?𝔄; semicategory ?α ?𝔅⟧ ⟹ (op_smc ?𝔄 = op_smc ?𝔅) = (?𝔄 = ?𝔅)› ‹obj_initial (op_smc ?ℭ) = obj_terminal ?ℭ› and more 26 facts*) subsmc_Comp (*‹⟦?g : ?b ↦⇘𝔅⇙ ?c; ?f : ?a ↦⇘𝔅⇙ ?b⟧ ⟹ ?g ∘⇩A⇘𝔅⇙ ?f = ?g ∘⇩A⇘ℭ⇙ ?f›*)) qed (auto simp: smc_op_simps (*‹op_smc (?ℭ::V)⦇Obj⦈ = ?ℭ⦇Obj⦈› ‹op_smc (?ℭ::V)⦇Arr⦈ = ?ℭ⦇Arr⦈› ‹op_smc (?ℭ::V)⦇Dom⦈ = ?ℭ⦇Cod⦈› ‹op_smc (?ℭ::V)⦇Cod⦈ = ?ℭ⦇Dom⦈› ‹𝒟⇩∘ (op_smc (?ℭ::V)⦇Comp⦈) = (𝒟⇩∘ (?ℭ⦇Comp⦈))¯⇩∙› ‹(?f::V) : (?b::V) ↦⇘op_smc (?ℭ::V)⇙ (?a::V) = ?f : ?a ↦⇘?ℭ⇙ ?b› ‹semicategory (?α::V) (?ℭ::V) ⟹ ℛ⇩∘ (op_smc ?ℭ⦇Comp⦈) = ℛ⇩∘ (?ℭ⦇Comp⦈)› ‹⟦semicategory (?α::V) (?ℭ::V); (?f::V) : (?b::V) ↦⇘?ℭ⇙ (?c::V); (?g::V) : (?a::V) ↦⇘?ℭ⇙ ?b⟧ ⟹ ?g ∘⇩A⇘op_smc ?ℭ⇙ ?f = ?f ∘⇩A⇘?ℭ⇙ ?g› ‹Hom (op_smc (?ℭ::V)) (?a::V) (?b::V) = Hom ?ℭ ?b ?a› ‹semicategory (?α::V) (?ℭ::V) ⟹ op_smc (op_smc ?ℭ) = ?ℭ› ‹⟦semicategory (?α::V) (?𝔄::V); semicategory ?α (?𝔅::V)⟧ ⟹ (op_smc ?𝔄 = op_smc ?𝔅) = (?𝔄 = ?𝔅)› ‹obj_initial (op_smc (?ℭ::V)) = obj_terminal ?ℭ› and more 26 facts*) slicing_commute[symmetric] (*‹smc_dg (op_smc (?ℭ::V)) = op_dg (smc_dg ?ℭ)› ‹smc_dg ((?𝔉::V)⦇HomDom⦈) = smcf_dghm ?𝔉⦇HomDom⦈› ‹smc_dg ((?𝔉::V)⦇HomCod⦈) = smcf_dghm ?𝔉⦇HomCod⦈› ‹smcf_dghm (op_smcf (?𝔉::V)) = op_dghm (smcf_dghm ?𝔉)› ‹smcf_dghm ((?𝔊::V) ∘⇩D⇩G⇩H⇩M (?𝔉::V)) = smcf_dghm ?𝔊 ∘⇩D⇩G⇩H⇩M smcf_dghm ?𝔉› ‹smcf_dghm ((?𝔊::V) ⇩S⇩M⇩C⇩F∘ (?𝔉::V)) = smcf_dghm ?𝔊 ⇩D⇩G⇩H⇩M∘ smcf_dghm ?𝔉› ‹smcf_dghm (dghm_id (?ℭ::V)) = dghm_id (smc_dg ?ℭ)› ‹smcf_dghm (dghm_const (?ℭ::V) (?𝔇::V) (?a::V) (?f::V)) = dghm_const (smc_dg ?ℭ) (smc_dg ?𝔇) ?a ?f› ‹smcf_dghm (inv_dghm (?𝔉::V)) = inv_dghm (smcf_dghm ?𝔉)›*) subsmc_subdigraph_op_dg_op_dg (*‹op_dg (smc_dg (𝔅::V)) ⊆⇩D⇩G⇘α::V⇙ op_dg (smc_dg (ℭ::V))›*) intro: smc_op_intros (*‹(?a::V) ∈⇩∘ (?ℭ::V)⦇Obj⦈ ⟹ ?a ∈⇩∘ op_smc ?ℭ⦇Obj⦈› ‹(?f::V) ∈⇩∘ (?ℭ::V)⦇Arr⦈ ⟹ ?f ∈⇩∘ op_smc ?ℭ⦇Arr⦈› ‹(?f::V) : (?a::V) ↦⇘?ℭ::V⇙ (?b::V) ⟹ ?f : ?b ↦⇘op_smc ?ℭ⇙ ?a› ‹semicategory (?α::V) (?ℭ::V) ⟹ semicategory ?α (op_smc ?ℭ)› ‹⟦(?𝔉::V) : (?𝔄::V) ↦↦⇩S⇩M⇩C⇘?α::V⇙ (?𝔅::V); (?𝔄'::V) = op_smc ?𝔄; (?𝔅'::V) = op_smc ?𝔅; (?α'::V) = ?α⟧ ⟹ op_smcf ?𝔉 : ?𝔄' ↦↦⇩S⇩M⇩C⇘?α'⇙ ?𝔅'› ‹⟦(?𝔉::V) : (?𝔄::V) ↦↦⇩S⇩M⇩C⇩.⇩f⇩a⇩i⇩t⇩h⇩f⇩u⇩l⇘?α::V⇙ (?𝔅::V); (?𝔄'::V) = op_smc ?𝔄; (?𝔅'::V) = op_smc ?𝔅⟧ ⟹ op_smcf ?𝔉 : ?𝔄' ↦↦⇩S⇩M⇩C⇩.⇩f⇩a⇩i⇩t⇩h⇩f⇩u⇩l⇘?α⇙ ?𝔅'› ‹(?𝔉::V) : (?𝔄::V) ↦↦⇩S⇩M⇩C⇩.⇩f⇩u⇩l⇩l⇘?α::V⇙ (?𝔅::V) ⟹ op_smcf ?𝔉 : op_smc ?𝔄 ↦↦⇩S⇩M⇩C⇩.⇩f⇩u⇩l⇩l⇘?α⇙ op_smc ?𝔅› ‹⟦(?𝔉::V) : (?𝔄::V) ↦↦⇩S⇩M⇩C⇩.⇩f⇩f⇘?α::V⇙ (?𝔅::V); (?𝔄'::V) = op_smc ?𝔄; (?𝔅'::V) = op_smc ?𝔅⟧ ⟹ op_smcf ?𝔉 : ?𝔄' ↦↦⇩S⇩M⇩C⇩.⇩f⇩f⇘?α⇙ ?𝔅'› ‹(?𝔉::V) : (?𝔄::V) ↦↦⇩S⇩M⇩C⇩.⇩i⇩s⇩o⇘?α::V⇙ (?𝔅::V) ⟹ op_smcf ?𝔉 : op_smc ?𝔄 ↦↦⇩S⇩M⇩C⇩.⇩i⇩s⇩o⇘?α⇙ op_smc ?𝔅› ‹semicategory (α::V) (op_smc (𝔅::V))› ‹semicategory (α::V) (op_smc (ℭ::V))›*)) (*solves the remaining goals: 1. ‹semicategory α (op_smc 𝔅)› 2. ‹semicategory α (op_smc ℭ)› 3. ‹smc_dg (op_smc 𝔅) ⊆⇩D⇩G⇘α⇙ smc_dg (op_smc ℭ)›*) lemmas subsmc_subsemicategory_op_smc[intro, smc_op_intros] = subsemicategory.subsmc_subsemicategory_op_smc text‹Further rules.› lemma (in subsemicategory) subsmc_Comp_simp: assumes "g : b ↦⇘𝔅⇙ c" and "f : a ↦⇘𝔅⇙ b" shows "g ∘⇩A⇘𝔅⇙ f = g ∘⇩A⇘ℭ⇙ f" using assms (*‹g : b ↦⇘𝔅⇙ c› ‹f : a ↦⇘𝔅⇙ b›*) subsmc_Comp (*‹⟦?g : ?b ↦⇘𝔅⇙ ?c; ?f : ?a ↦⇘𝔅⇙ ?b⟧ ⟹ ?g ∘⇩A⇘𝔅⇙ ?f = ?g ∘⇩A⇘ℭ⇙ ?f›*) by auto lemmas [smc_sub_bw_cs_simps] = subsemicategory.subsmc_Comp_simp lemma (in subsemicategory) subsmc_is_idem_arrD: assumes "f : ↦⇩i⇩d⇩e⇘𝔅⇙ b" shows "f : ↦⇩i⇩d⇩e⇘ℭ⇙ b" using assms (*‹f : ↦⇩i⇩d⇩e⇘𝔅⇙ b›*) subsemicategory_axioms (*‹𝔅 ⊆⇩S⇩M⇩C⇘α⇙ ℭ›*) apply - (*goal: ‹f : ↦⇩i⇩d⇩e⇘ℭ⇙ b›*) apply (intro is_idem_arrI (*‹⟦?f : ?b ↦⇘?ℭ⇙ ?b; ?f ∘⇩A⇘?ℭ⇙ ?f = ?f⟧ ⟹ ?f : ↦⇩i⇩d⇩e⇘?ℭ⇙ ?b›*)) (*goals: 1. ‹⟦f : ↦⇩i⇩d⇩e⇘𝔅⇙ b; 𝔅 ⊆⇩S⇩M⇩C⇘α⇙ ℭ⟧ ⟹ f : b ↦⇘ℭ⇙ b› 2. ‹⟦f : ↦⇩i⇩d⇩e⇘𝔅⇙ b; 𝔅 ⊆⇩S⇩M⇩C⇘α⇙ ℭ⟧ ⟹ f ∘⇩A⇘ℭ⇙ f = f› discuss goal 1*) apply (elim is_idem_arrE (*‹⟦?f : ↦⇩i⇩d⇩e⇘?ℭ⇙ ?b; ⟦?f : ?b ↦⇘?ℭ⇙ ?b; ?f ∘⇩A⇘?ℭ⇙ ?f = ?f⟧ ⟹ ?W⟧ ⟹ ?W›*)) (*top goal: ‹⟦(f::V) : ↦⇩i⇩d⇩e⇘𝔅::V⇙ (b::V); 𝔅 ⊆⇩S⇩M⇩C⇘α::V⇙ (ℭ::V)⟧ ⟹ f : b ↦⇘ℭ⇙ b› and 1 goal remains*) apply (cs_concl cs_shallow cs_simp: smc_sub_bw_cs_simps[symmetric] cs_intro: smc_sub_fw_cs_intros) (*discuss goal 2*) apply (elim is_idem_arrE (*‹⟦(?f::V) : ↦⇩i⇩d⇩e⇘?ℭ::V⇙ (?b::V); ⟦?f : ?b ↦⇘?ℭ⇙ ?b; ?f ∘⇩A⇘?ℭ⇙ ?f = ?f⟧ ⟹ ?W::bool⟧ ⟹ ?W›*)) (*goal: ‹⟦f : ↦⇩i⇩d⇩e⇘𝔅⇙ b; 𝔅 ⊆⇩S⇩M⇩C⇘α⇙ ℭ⟧ ⟹ f ∘⇩A⇘ℭ⇙ f = f›*) apply (msorry) (*proven 2 subgoals*) . lemmas [smc_sub_fw_cs_intros] = subsemicategory.subsmc_is_idem_arrD subsubsection‹Subsemicategory relation is a partial order› lemma subsmc_refl: assumes "semicategory α 𝔄" shows "𝔄 ⊆⇩S⇩M⇩C⇘α⇙ 𝔄" proof (-) (*goal: ‹𝔄 ⊆⇩S⇩M⇩C⇘α⇙ 𝔄›*) interpret semicategory "α" "𝔄" by (rule assms (*‹semicategory α 𝔄›*)) show "?thesis" (*goal: ‹𝔄 ⊆⇩S⇩M⇩C⇘α⇙ 𝔄›*) by (auto intro: smc_cs_intros (*‹⟦(?gf::V) = [?g::V, ?f::V]⇩∘; ?g : (?b::V) ↦⇘?ℭ::V⇙ (?c::V); ?f : (?a::V) ↦⇘?ℭ⇙ ?b⟧ ⟹ ?gf ∈⇩∘ composable_arrs ?ℭ› ‹⟦semicategory (?α::V) (?ℭ::V); (?g::V) : (?b::V) ↦⇘?ℭ⇙ (?c::V); (?f::V) : (?a::V) ↦⇘?ℭ⇙ ?b; (?ℭ'::V) = ?ℭ⟧ ⟹ ?g ∘⇩A⇘?ℭ⇙ ?f : ?a ↦⇘?ℭ'⇙ ?c› ‹⟦semicategory (?α::V) (?ℭ::V); (?g::V) : (?b::V) ↦⇘?ℭ⇙ (?c::V); (?f::V) : (?a::V) ↦⇘?ℭ⇙ ?b⟧ ⟹ ?g ∘⇩A⇘?ℭ⇙ ?f : ?a ↦⇘?ℭ⇙ ?c› ‹⟦semicategory (?α::V) (?ℭ::V); (?f::V) : (?a::V) ↦⇘?ℭ⇙ (?b::V)⟧ ⟹ ?f ∈⇩∘ ?ℭ⦇Arr⦈› ‹⟦semicategory (?α::V) (?ℭ::V); (?f::V) : (?a::V) ↦⇘?ℭ⇙ (?b::V)⟧ ⟹ ?a ∈⇩∘ ?ℭ⦇Obj⦈› ‹⟦semicategory (?α::V) (?ℭ::V); (?f::V) : (?a::V) ↦⇘?ℭ⇙ (?b::V)⟧ ⟹ ?b ∈⇩∘ ?ℭ⦇Obj⦈› ‹⟦semicategory (?α::V) (?ℭ::V); (?a::V) ∈⇩∘ ?ℭ⦇Obj⦈; (?b::V) ∈⇩∘ ?ℭ⦇Obj⦈⟧ ⟹ Hom ?ℭ ?a ?b ∈⇩∘ Vset ?α› ‹⟦semicategory (?α::V) (?ℭ::V); (?g::V) : (?b::V) ↦⇘?ℭ⇙ (?c::V); (?f::V) : (?a::V) ↦⇘?ℭ⇙ ?b; (?gf::V) = [?g, ?f]⇩∘⟧ ⟹ ?gf ∈⇩∘ 𝒟⇩∘ (?ℭ⦇Comp⦈)› ‹(?f::V) : (?a::V) ↦⇘?ℭ::V⇙ (?b::V) ⟹ ?f ∈⇩∘ ?ℭ⦇Arr⦈› ‹(?f::V) : (?a::V) ↦⇘?ℭ::V⇙ (?b::V) ⟹ ?f ∈⇩∘ Hom ?ℭ ?a ?b› ‹vsv (dghm_id (?ℭ::V)⦇ObjMap⦈)› ‹vsv (dghm_id (?ℭ::V)⦇ArrMap⦈)› and more 21 facts*) slicing_intros (*‹(?f::V) : (?a::V) ↦⇘?ℭ::V⇙ (?b::V) ⟹ ?f : ?a ↦⇘smc_dg ?ℭ⇙ ?b› ‹semicategory (?α::V) (?ℭ::V) ⟹ digraph ?α (smc_dg ?ℭ)› ‹⟦(?𝔉::V) : (?𝔄::V) ↦↦⇩S⇩M⇩C⇘?α::V⇙ (?𝔅::V); (?𝔄'::V) = smc_dg ?𝔄; (?𝔅'::V) = smc_dg ?𝔅⟧ ⟹ smcf_dghm ?𝔉 : ?𝔄' ↦↦⇩D⇩G⇘?α⇙ ?𝔅'› ‹⟦(?𝔉::V) : op_smc (?𝔄::V) ↦↦⇩S⇩M⇩C⇘?α::V⇙ (?𝔅::V); (?𝔄'::V) = op_dg (smc_dg ?𝔄); (?𝔅'::V) = smc_dg ?𝔅⟧ ⟹ smcf_dghm ?𝔉 : ?𝔄' ↦↦⇩D⇩G⇘?α⇙ ?𝔅'› ‹⟦(?𝔉::V) : (?𝔄::V) ↦↦⇩S⇩M⇩C⇩.⇩f⇩a⇩i⇩t⇩h⇩f⇩u⇩l⇘?α::V⇙ (?𝔅::V); (?𝔄'::V) = smc_dg ?𝔄; (?𝔅'::V) = smc_dg ?𝔅⟧ ⟹ smcf_dghm ?𝔉 : ?𝔄' ↦↦⇩D⇩G⇩.⇩f⇩a⇩i⇩t⇩h⇩f⇩u⇩l⇘?α⇙ ?𝔅'› ‹⟦(?𝔉::V) : (?𝔄::V) ↦↦⇩S⇩M⇩C⇩.⇩f⇩u⇩l⇩l⇘?α::V⇙ (?𝔅::V); (?𝔄'::V) = smc_dg ?𝔄; (?𝔅'::V) = smc_dg ?𝔅⟧ ⟹ smcf_dghm ?𝔉 : ?𝔄' ↦↦⇩D⇩G⇩.⇩f⇩u⇩l⇩l⇘?α⇙ ?𝔅'› ‹⟦(?𝔉::V) : (?𝔄::V) ↦↦⇩S⇩M⇩C⇩.⇩f⇩f⇘?α::V⇙ (?𝔅::V); (?𝔄'::V) = smc_dg ?𝔄; (?𝔅'::V) = smc_dg ?𝔅⟧ ⟹ smcf_dghm ?𝔉 : ?𝔄' ↦↦⇩D⇩G⇩.⇩f⇩f⇘?α⇙ ?𝔅'› ‹⟦(?𝔉::V) : (?𝔄::V) ↦↦⇩S⇩M⇩C⇩.⇩i⇩s⇩o⇘?α::V⇙ (?𝔅::V); (?𝔄'::V) = smc_dg ?𝔄; (?𝔅'::V) = smc_dg ?𝔅⟧ ⟹ smcf_dghm ?𝔉 : ?𝔄' ↦↦⇩D⇩G⇩.⇩i⇩s⇩o⇘?α⇙ ?𝔅'› ‹digraph (α::V) (smc_dg (𝔄::V))›*) subdg_refl (*‹digraph (?α::V) (?𝔄::V) ⟹ ?𝔄 ⊆⇩D⇩G⇘?α⇙ ?𝔄›*) subsemicategoryI (*‹⟦semicategory (?α::V) (?𝔅::V); semicategory ?α (?ℭ::V); smc_dg ?𝔅 ⊆⇩D⇩G⇘?α⇙ smc_dg ?ℭ; ⋀(b::V) (c::V) (g::V) (a::V) f::V. ⟦g : b ↦⇘?𝔅⇙ c; f : a ↦⇘?𝔅⇙ b⟧ ⟹ g ∘⇩A⇘?𝔅⇙ f = g ∘⇩A⇘?ℭ⇙ f⟧ ⟹ ?𝔅 ⊆⇩S⇩M⇩C⇘?α⇙ ?ℭ›*)) qed lemma subsmc_trans[trans]: assumes "𝔄 ⊆⇩S⇩M⇩C⇘α⇙ 𝔅" and "𝔅 ⊆⇩S⇩M⇩C⇘α⇙ ℭ" shows "𝔄 ⊆⇩S⇩M⇩C⇘α⇙ ℭ" proof (-) (*goal: ‹𝔄 ⊆⇩S⇩M⇩C⇘α⇙ ℭ›*) interpret 𝔄𝔅: subsemicategory "α" "𝔄" "𝔅" by (rule assms( (*‹𝔄 ⊆⇩S⇩M⇩C⇘α⇙ 𝔅›*) 1)) interpret 𝔅ℭ: subsemicategory "α" "𝔅" "ℭ" by (rule assms( (*‹𝔅 ⊆⇩S⇩M⇩C⇘α⇙ ℭ›*) 2)) show "?thesis" (*goal: ‹𝔄 ⊆⇩S⇩M⇩C⇘α⇙ ℭ›*) proof (rule subsemicategoryI (*‹⟦semicategory ?α ?𝔅; semicategory ?α ?ℭ; smc_dg ?𝔅 ⊆⇩D⇩G⇘?α⇙ smc_dg ?ℭ; ⋀b c g a f. ⟦g : b ↦⇘?𝔅⇙ c; f : a ↦⇘?𝔅⇙ b⟧ ⟹ g ∘⇩A⇘?𝔅⇙ f = g ∘⇩A⇘?ℭ⇙ f⟧ ⟹ ?𝔅 ⊆⇩S⇩M⇩C⇘?α⇙ ?ℭ›*)) (*goals: 1. ‹semicategory (α::V) (𝔄::V)› 2. ‹semicategory (α::V) (ℭ::V)› 3. ‹smc_dg (𝔄::V) ⊆⇩D⇩G⇘α::V⇙ smc_dg (ℭ::V)› 4. ‹⋀(b::V) (c::V) (g::V) (a::V) f::V. ⟦g : b ↦⇘𝔄::V⇙ c; f : a ↦⇘𝔄⇙ b⟧ ⟹ g ∘⇩A⇘𝔄⇙ f = g ∘⇩A⇘ℭ::V⇙ f›*) from "𝔄𝔅.subsmc_subdigraph" (*‹smc_dg 𝔄 ⊆⇩D⇩G⇘α⇙ smc_dg 𝔅›*) "𝔅ℭ.subsmc_subdigraph" (*‹smc_dg (𝔅::V) ⊆⇩D⇩G⇘α::V⇙ smc_dg (ℭ::V)›*) show "smc_dg 𝔄 ⊆⇩D⇩G⇘α⇙ smc_dg ℭ" by (meson subdg_trans (*‹⟦?𝔄 ⊆⇩D⇩G⇘?α⇙ ?𝔅; ?𝔅 ⊆⇩D⇩G⇘?α⇙ ?ℭ⟧ ⟹ ?𝔄 ⊆⇩D⇩G⇘?α⇙ ?ℭ›*)) show "g ∘⇩A⇘𝔄⇙ f = g ∘⇩A⇘ℭ⇙ f" if "g : b ↦⇘𝔄⇙ c" and "f : a ↦⇘𝔄⇙ b" for g and b and c and f and a by (metis that (*‹g : b ↦⇘𝔄⇙ c› ‹f : a ↦⇘𝔄⇙ b›*) 𝔄𝔅.subsmc_is_arr_vsubset (*‹?f : ?a ↦⇘𝔄⇙ ?b ⟹ ?f : ?a ↦⇘𝔅⇙ ?b›*) 𝔄𝔅.subsmc_Comp_simp (*‹⟦?g : ?b ↦⇘𝔄⇙ ?c; ?f : ?a ↦⇘𝔄⇙ ?b⟧ ⟹ ?g ∘⇩A⇘𝔄⇙ ?f = ?g ∘⇩A⇘𝔅⇙ ?f›*) 𝔅ℭ.subsmc_Comp_simp (*‹⟦?g : ?b ↦⇘𝔅⇙ ?c; ?f : ?a ↦⇘𝔅⇙ ?b⟧ ⟹ ?g ∘⇩A⇘𝔅⇙ ?f = ?g ∘⇩A⇘ℭ⇙ ?f›*)) qed (auto intro: smc_cs_intros (*‹⟦?gf = [?g, ?f]⇩∘; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?gf ∈⇩∘ composable_arrs ?ℭ› ‹⟦semicategory ?α ?ℭ; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b; ?ℭ' = ?ℭ⟧ ⟹ ?g ∘⇩A⇘?ℭ⇙ ?f : ?a ↦⇘?ℭ'⇙ ?c› ‹⟦semicategory ?α ?ℭ; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?g ∘⇩A⇘?ℭ⇙ ?f : ?a ↦⇘?ℭ⇙ ?c› ‹⟦semicategory ?α ?ℭ; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?f ∈⇩∘ ?ℭ⦇Arr⦈› ‹⟦semicategory ?α ?ℭ; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?a ∈⇩∘ ?ℭ⦇Obj⦈› ‹⟦semicategory ?α ?ℭ; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?b ∈⇩∘ ?ℭ⦇Obj⦈› ‹⟦semicategory ?α ?ℭ; ?a ∈⇩∘ ?ℭ⦇Obj⦈; ?b ∈⇩∘ ?ℭ⦇Obj⦈⟧ ⟹ Hom ?ℭ ?a ?b ∈⇩∘ Vset ?α› ‹⟦semicategory ?α ?ℭ; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b; ?gf = [?g, ?f]⇩∘⟧ ⟹ ?gf ∈⇩∘ 𝒟⇩∘ (?ℭ⦇Comp⦈)› ‹?f : ?a ↦⇘?ℭ⇙ ?b ⟹ ?f ∈⇩∘ ?ℭ⦇Arr⦈› ‹?f : ?a ↦⇘?ℭ⇙ ?b ⟹ ?f ∈⇩∘ Hom ?ℭ ?a ?b› ‹vsv (dghm_id ?ℭ⦇ObjMap⦈)› ‹vsv (dghm_id ?ℭ⦇ArrMap⦈)› and more 39 facts*)) (*solves the remaining goals: 1. ‹semicategory (α::V) (𝔄::V)› 2. ‹semicategory (α::V) (ℭ::V)›*) qed lemma subsmc_antisym: assumes "𝔄 ⊆⇩S⇩M⇩C⇘α⇙ 𝔅" and "𝔅 ⊆⇩S⇩M⇩C⇘α⇙ 𝔄" shows "𝔄 = 𝔅" proof (-) (*goal: ‹𝔄 = 𝔅›*) interpret 𝔄𝔅: subsemicategory "α" "𝔄" "𝔅" by (rule assms( (*‹𝔄 ⊆⇩S⇩M⇩C⇘α⇙ 𝔅›*) 1)) interpret 𝔅𝔄: subsemicategory "α" "𝔅" "𝔄" by (rule assms( (*‹𝔅 ⊆⇩S⇩M⇩C⇘α⇙ 𝔄›*) 2)) show "?thesis" (*goal: ‹𝔄 = 𝔅›*) proof (rule smc_eqI (*‹⟦semicategory ?α ?𝔄; semicategory ?α ?𝔅; ?𝔄⦇Obj⦈ = ?𝔅⦇Obj⦈; ?𝔄⦇Arr⦈ = ?𝔅⦇Arr⦈; ?𝔄⦇Dom⦈ = ?𝔅⦇Dom⦈; ?𝔄⦇Cod⦈ = ?𝔅⦇Cod⦈; ?𝔄⦇Comp⦈ = ?𝔅⦇Comp⦈⟧ ⟹ ?𝔄 = ?𝔅›*)) (*goals: 1. ‹semicategory ?α 𝔄› 2. ‹semicategory ?α 𝔅› 3. ‹𝔄⦇Obj⦈ = 𝔅⦇Obj⦈› 4. ‹𝔄⦇Arr⦈ = 𝔅⦇Arr⦈› 5. ‹𝔄⦇Dom⦈ = 𝔅⦇Dom⦈› 6. ‹𝔄⦇Cod⦈ = 𝔅⦇Cod⦈› 7. ‹𝔄⦇Comp⦈ = 𝔅⦇Comp⦈›*) from subdg_antisym[OF 𝔄𝔅.subsmc_subdigraph 𝔅𝔄.subsmc_subdigraph] (*‹smc_dg 𝔄 = smc_dg 𝔅›*) have "smc_dg 𝔄⦇Obj⦈ = smc_dg 𝔅⦇Obj⦈" "smc_dg 𝔄⦇Arr⦈ = smc_dg 𝔅⦇Arr⦈" apply - (*goals: 1. ‹smc_dg 𝔄 = smc_dg 𝔅 ⟹ smc_dg 𝔄⦇Obj⦈ = smc_dg 𝔅⦇Obj⦈› 2. ‹smc_dg 𝔄 = smc_dg 𝔅 ⟹ smc_dg 𝔄⦇Arr⦈ = smc_dg 𝔅⦇Arr⦈› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) . then show "𝔄⦇Obj⦈ = 𝔅⦇Obj⦈" and Arr: "𝔄⦇Arr⦈ = 𝔅⦇Arr⦈" unfolding slicing_simps (*goals: 1. ‹𝔄⦇Obj⦈ = 𝔅⦇Obj⦈› 2. ‹𝔄⦇Arr⦈ = 𝔅⦇Arr⦈›*) apply - (*goals: 1. ‹⟦𝔄⦇Obj⦈ = 𝔅⦇Obj⦈; 𝔄⦇Arr⦈ = 𝔅⦇Arr⦈⟧ ⟹ 𝔄⦇Obj⦈ = 𝔅⦇Obj⦈› 2. ‹⟦𝔄⦇Obj⦈ = 𝔅⦇Obj⦈; 𝔄⦇Arr⦈ = 𝔅⦇Arr⦈⟧ ⟹ 𝔄⦇Arr⦈ = 𝔅⦇Arr⦈› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) . show "𝔄⦇Dom⦈ = 𝔅⦇Dom⦈" apply (rule vsv_eqI (*‹⟦vsv ?r; vsv ?s; 𝒟⇩∘ ?r = 𝒟⇩∘ ?s; ⋀a. a ∈⇩∘ 𝒟⇩∘ ?r ⟹ ?r⦇a⦈ = ?s⦇a⦈⟧ ⟹ ?r = ?s›*)) (*goals: 1. ‹vsv (𝔄⦇Dom⦈)› 2. ‹vsv (𝔅⦇Dom⦈)› 3. ‹𝒟⇩∘ (𝔄⦇Dom⦈) = 𝒟⇩∘ (𝔅⦇Dom⦈)› 4. ‹⋀a. a ∈⇩∘ 𝒟⇩∘ (𝔄⦇Dom⦈) ⟹ 𝔄⦇Dom⦈⦇a⦈ = 𝔅⦇Dom⦈⦇a⦈› discuss goal 1*) apply ((auto simp: smc_cs_simps (*‹semicategory ?α ?ℭ ⟹ vcard ?ℭ = 5⇩ℕ› ‹⟦semicategory ?α ?ℭ; ?h : ?c ↦⇘?ℭ⇙ ?d; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?h ∘⇩A⇘?ℭ⇙ ?g ∘⇩A⇘?ℭ⇙ ?f = ?h ∘⇩A⇘?ℭ⇙ (?g ∘⇩A⇘?ℭ⇙ ?f)› ‹?f : ↦⇩i⇩d⇩e⇘?ℭ⇙ ?b ⟹ ?f ∘⇩A⇘?ℭ⇙ ?f = ?f› ‹?f : ?a ↦⇘?ℭ⇙ ?b ⟹ ?ℭ⦇Dom⦈⦇?f⦈ = ?a› ‹?f : ?a ↦⇘?ℭ⇙ ?b ⟹ ?ℭ⦇Cod⦈⦇?f⦈ = ?b› ‹(?f ∈⇩∘ Hom ?ℭ ?a ?b) = ?f : ?a ↦⇘?ℭ⇙ ?b› ‹(?𝔊 ∘⇩D⇩G⇩H⇩M ?𝔉)⦇HomDom⦈ = ?𝔉⦇HomDom⦈› ‹(?𝔊 ∘⇩D⇩G⇩H⇩M ?𝔉)⦇HomCod⦈ = ?𝔊⦇HomCod⦈› ‹dghm_id ?ℭ⦇HomDom⦈ = ?ℭ› ‹dghm_id ?ℭ⦇HomCod⦈ = ?ℭ› ‹𝒟⇩∘ (dghm_id ?ℭ⦇ObjMap⦈) = ?ℭ⦇Obj⦈› ‹ℛ⇩∘ (dghm_id ?ℭ⦇ObjMap⦈) = ?ℭ⦇Obj⦈› and more 34 facts*) 𝔄𝔅.subsmc_dom_simp (*‹?f ∈⇩∘ 𝔄⦇Arr⦈ ⟹ 𝔄⦇Dom⦈⦇?f⦈ = 𝔅⦇Dom⦈⦇?f⦈›*) Arr (*‹𝔄⦇Arr⦈ = 𝔅⦇Arr⦈›*))[1]) (*discuss goal 2*) apply ((auto simp: smc_cs_simps (*‹semicategory (?α::V) (?ℭ::V) ⟹ vcard ?ℭ = (5::nat)⇩ℕ› ‹⟦semicategory (?α::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)› ‹(?f::V) : ↦⇩i⇩d⇩e⇘?ℭ::V⇙ (?b::V) ⟹ ?f ∘⇩A⇘?ℭ⇙ ?f = ?f› ‹(?f::V) : (?a::V) ↦⇘?ℭ::V⇙ (?b::V) ⟹ ?ℭ⦇Dom⦈⦇?f⦈ = ?a› ‹(?f::V) : (?a::V) ↦⇘?ℭ::V⇙ (?b::V) ⟹ ?ℭ⦇Cod⦈⦇?f⦈ = ?b› ‹((?f::V) ∈⇩∘ Hom (?ℭ::V) (?a::V) (?b::V)) = ?f : ?a ↦⇘?ℭ⇙ ?b› ‹((?𝔊::V) ∘⇩D⇩G⇩H⇩M (?𝔉::V))⦇HomDom⦈ = ?𝔉⦇HomDom⦈› ‹((?𝔊::V) ∘⇩D⇩G⇩H⇩M (?𝔉::V))⦇HomCod⦈ = ?𝔊⦇HomCod⦈› ‹dghm_id (?ℭ::V)⦇HomDom⦈ = ?ℭ› ‹dghm_id (?ℭ::V)⦇HomCod⦈ = ?ℭ› ‹𝒟⇩∘ (dghm_id (?ℭ::V)⦇ObjMap⦈) = ?ℭ⦇Obj⦈› ‹ℛ⇩∘ (dghm_id (?ℭ::V)⦇ObjMap⦈) = ?ℭ⦇Obj⦈› and more 34 facts*) 𝔄𝔅.subsmc_dom_simp (*‹(?f::V) ∈⇩∘ (𝔄::V)⦇Arr⦈ ⟹ 𝔄⦇Dom⦈⦇?f⦈ = (𝔅::V)⦇Dom⦈⦇?f⦈›*) Arr (*‹(𝔄::V)⦇Arr⦈ = (𝔅::V)⦇Arr⦈›*))[1]) (*discuss goal 3*) apply ((auto simp: smc_cs_simps (*‹semicategory ?α ?ℭ ⟹ vcard ?ℭ = 5⇩ℕ› ‹⟦semicategory ?α ?ℭ; ?h : ?c ↦⇘?ℭ⇙ ?d; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?h ∘⇩A⇘?ℭ⇙ ?g ∘⇩A⇘?ℭ⇙ ?f = ?h ∘⇩A⇘?ℭ⇙ (?g ∘⇩A⇘?ℭ⇙ ?f)› ‹?f : ↦⇩i⇩d⇩e⇘?ℭ⇙ ?b ⟹ ?f ∘⇩A⇘?ℭ⇙ ?f = ?f› ‹?f : ?a ↦⇘?ℭ⇙ ?b ⟹ ?ℭ⦇Dom⦈⦇?f⦈ = ?a› ‹?f : ?a ↦⇘?ℭ⇙ ?b ⟹ ?ℭ⦇Cod⦈⦇?f⦈ = ?b› ‹(?f ∈⇩∘ Hom ?ℭ ?a ?b) = ?f : ?a ↦⇘?ℭ⇙ ?b› ‹(?𝔊 ∘⇩D⇩G⇩H⇩M ?𝔉)⦇HomDom⦈ = ?𝔉⦇HomDom⦈› ‹(?𝔊 ∘⇩D⇩G⇩H⇩M ?𝔉)⦇HomCod⦈ = ?𝔊⦇HomCod⦈› ‹dghm_id ?ℭ⦇HomDom⦈ = ?ℭ› ‹dghm_id ?ℭ⦇HomCod⦈ = ?ℭ› ‹𝒟⇩∘ (dghm_id ?ℭ⦇ObjMap⦈) = ?ℭ⦇Obj⦈› ‹ℛ⇩∘ (dghm_id ?ℭ⦇ObjMap⦈) = ?ℭ⦇Obj⦈› and more 34 facts*) 𝔄𝔅.subsmc_dom_simp (*‹?f ∈⇩∘ 𝔄⦇Arr⦈ ⟹ 𝔄⦇Dom⦈⦇?f⦈ = 𝔅⦇Dom⦈⦇?f⦈›*) Arr (*‹𝔄⦇Arr⦈ = 𝔅⦇Arr⦈›*))[1]) (*discuss goal 4*) apply ((auto simp: smc_cs_simps (*‹semicategory ?α ?ℭ ⟹ vcard ?ℭ = 5⇩ℕ› ‹⟦semicategory ?α ?ℭ; ?h : ?c ↦⇘?ℭ⇙ ?d; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?h ∘⇩A⇘?ℭ⇙ ?g ∘⇩A⇘?ℭ⇙ ?f = ?h ∘⇩A⇘?ℭ⇙ (?g ∘⇩A⇘?ℭ⇙ ?f)› ‹?f : ↦⇩i⇩d⇩e⇘?ℭ⇙ ?b ⟹ ?f ∘⇩A⇘?ℭ⇙ ?f = ?f› ‹?f : ?a ↦⇘?ℭ⇙ ?b ⟹ ?ℭ⦇Dom⦈⦇?f⦈ = ?a› ‹?f : ?a ↦⇘?ℭ⇙ ?b ⟹ ?ℭ⦇Cod⦈⦇?f⦈ = ?b› ‹(?f ∈⇩∘ Hom ?ℭ ?a ?b) = ?f : ?a ↦⇘?ℭ⇙ ?b› ‹(?𝔊 ∘⇩D⇩G⇩H⇩M ?𝔉)⦇HomDom⦈ = ?𝔉⦇HomDom⦈› ‹(?𝔊 ∘⇩D⇩G⇩H⇩M ?𝔉)⦇HomCod⦈ = ?𝔊⦇HomCod⦈› ‹dghm_id ?ℭ⦇HomDom⦈ = ?ℭ› ‹dghm_id ?ℭ⦇HomCod⦈ = ?ℭ› ‹𝒟⇩∘ (dghm_id ?ℭ⦇ObjMap⦈) = ?ℭ⦇Obj⦈› ‹ℛ⇩∘ (dghm_id ?ℭ⦇ObjMap⦈) = ?ℭ⦇Obj⦈› and more 34 facts*) 𝔄𝔅.subsmc_dom_simp (*‹?f ∈⇩∘ 𝔄⦇Arr⦈ ⟹ 𝔄⦇Dom⦈⦇?f⦈ = 𝔅⦇Dom⦈⦇?f⦈›*) Arr (*‹𝔄⦇Arr⦈ = 𝔅⦇Arr⦈›*))[1]) (*proven 4 subgoals*) . show "𝔄⦇Cod⦈ = 𝔅⦇Cod⦈" apply (rule vsv_eqI (*‹⟦vsv (?r::V); vsv (?s::V); 𝒟⇩∘ ?r = 𝒟⇩∘ ?s; ⋀a::V. a ∈⇩∘ 𝒟⇩∘ ?r ⟹ ?r⦇a⦈ = ?s⦇a⦈⟧ ⟹ ?r = ?s›*)) (*goals: 1. ‹vsv (𝔄⦇Cod⦈)› 2. ‹vsv (𝔅⦇Cod⦈)› 3. ‹𝒟⇩∘ (𝔄⦇Cod⦈) = 𝒟⇩∘ (𝔅⦇Cod⦈)› 4. ‹⋀a. a ∈⇩∘ 𝒟⇩∘ (𝔄⦇Cod⦈) ⟹ 𝔄⦇Cod⦈⦇a⦈ = 𝔅⦇Cod⦈⦇a⦈› discuss goal 1*) apply ((auto simp: smc_cs_simps (*‹semicategory ?α ?ℭ ⟹ vcard ?ℭ = 5⇩ℕ› ‹⟦semicategory ?α ?ℭ; ?h : ?c ↦⇘?ℭ⇙ ?d; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?h ∘⇩A⇘?ℭ⇙ ?g ∘⇩A⇘?ℭ⇙ ?f = ?h ∘⇩A⇘?ℭ⇙ (?g ∘⇩A⇘?ℭ⇙ ?f)› ‹?f : ↦⇩i⇩d⇩e⇘?ℭ⇙ ?b ⟹ ?f ∘⇩A⇘?ℭ⇙ ?f = ?f› ‹?f : ?a ↦⇘?ℭ⇙ ?b ⟹ ?ℭ⦇Dom⦈⦇?f⦈ = ?a› ‹?f : ?a ↦⇘?ℭ⇙ ?b ⟹ ?ℭ⦇Cod⦈⦇?f⦈ = ?b› ‹(?f ∈⇩∘ Hom ?ℭ ?a ?b) = ?f : ?a ↦⇘?ℭ⇙ ?b› ‹(?𝔊 ∘⇩D⇩G⇩H⇩M ?𝔉)⦇HomDom⦈ = ?𝔉⦇HomDom⦈› ‹(?𝔊 ∘⇩D⇩G⇩H⇩M ?𝔉)⦇HomCod⦈ = ?𝔊⦇HomCod⦈› ‹dghm_id ?ℭ⦇HomDom⦈ = ?ℭ› ‹dghm_id ?ℭ⦇HomCod⦈ = ?ℭ› ‹𝒟⇩∘ (dghm_id ?ℭ⦇ObjMap⦈) = ?ℭ⦇Obj⦈› ‹ℛ⇩∘ (dghm_id ?ℭ⦇ObjMap⦈) = ?ℭ⦇Obj⦈› and more 34 facts*) 𝔅𝔄.subsmc_cod_simp (*‹?f ∈⇩∘ 𝔅⦇Arr⦈ ⟹ 𝔅⦇Cod⦈⦇?f⦈ = 𝔄⦇Cod⦈⦇?f⦈›*) Arr (*‹𝔄⦇Arr⦈ = 𝔅⦇Arr⦈›*))[1]) (*discuss goal 2*) apply ((auto simp: smc_cs_simps (*‹semicategory ?α ?ℭ ⟹ vcard ?ℭ = 5⇩ℕ› ‹⟦semicategory ?α ?ℭ; ?h : ?c ↦⇘?ℭ⇙ ?d; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?h ∘⇩A⇘?ℭ⇙ ?g ∘⇩A⇘?ℭ⇙ ?f = ?h ∘⇩A⇘?ℭ⇙ (?g ∘⇩A⇘?ℭ⇙ ?f)› ‹?f : ↦⇩i⇩d⇩e⇘?ℭ⇙ ?b ⟹ ?f ∘⇩A⇘?ℭ⇙ ?f = ?f› ‹?f : ?a ↦⇘?ℭ⇙ ?b ⟹ ?ℭ⦇Dom⦈⦇?f⦈ = ?a› ‹?f : ?a ↦⇘?ℭ⇙ ?b ⟹ ?ℭ⦇Cod⦈⦇?f⦈ = ?b› ‹(?f ∈⇩∘ Hom ?ℭ ?a ?b) = ?f : ?a ↦⇘?ℭ⇙ ?b› ‹(?𝔊 ∘⇩D⇩G⇩H⇩M ?𝔉)⦇HomDom⦈ = ?𝔉⦇HomDom⦈› ‹(?𝔊 ∘⇩D⇩G⇩H⇩M ?𝔉)⦇HomCod⦈ = ?𝔊⦇HomCod⦈› ‹dghm_id ?ℭ⦇HomDom⦈ = ?ℭ› ‹dghm_id ?ℭ⦇HomCod⦈ = ?ℭ› ‹𝒟⇩∘ (dghm_id ?ℭ⦇ObjMap⦈) = ?ℭ⦇Obj⦈› ‹ℛ⇩∘ (dghm_id ?ℭ⦇ObjMap⦈) = ?ℭ⦇Obj⦈› and more 34 facts*) 𝔅𝔄.subsmc_cod_simp (*‹?f ∈⇩∘ 𝔅⦇Arr⦈ ⟹ 𝔅⦇Cod⦈⦇?f⦈ = 𝔄⦇Cod⦈⦇?f⦈›*) Arr (*‹𝔄⦇Arr⦈ = 𝔅⦇Arr⦈›*))[1]) (*discuss goal 3*) apply ((auto simp: smc_cs_simps (*‹semicategory ?α ?ℭ ⟹ vcard ?ℭ = 5⇩ℕ› ‹⟦semicategory ?α ?ℭ; ?h : ?c ↦⇘?ℭ⇙ ?d; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?h ∘⇩A⇘?ℭ⇙ ?g ∘⇩A⇘?ℭ⇙ ?f = ?h ∘⇩A⇘?ℭ⇙ (?g ∘⇩A⇘?ℭ⇙ ?f)› ‹?f : ↦⇩i⇩d⇩e⇘?ℭ⇙ ?b ⟹ ?f ∘⇩A⇘?ℭ⇙ ?f = ?f› ‹?f : ?a ↦⇘?ℭ⇙ ?b ⟹ ?ℭ⦇Dom⦈⦇?f⦈ = ?a› ‹?f : ?a ↦⇘?ℭ⇙ ?b ⟹ ?ℭ⦇Cod⦈⦇?f⦈ = ?b› ‹(?f ∈⇩∘ Hom ?ℭ ?a ?b) = ?f : ?a ↦⇘?ℭ⇙ ?b› ‹(?𝔊 ∘⇩D⇩G⇩H⇩M ?𝔉)⦇HomDom⦈ = ?𝔉⦇HomDom⦈› ‹(?𝔊 ∘⇩D⇩G⇩H⇩M ?𝔉)⦇HomCod⦈ = ?𝔊⦇HomCod⦈› ‹dghm_id ?ℭ⦇HomDom⦈ = ?ℭ› ‹dghm_id ?ℭ⦇HomCod⦈ = ?ℭ› ‹𝒟⇩∘ (dghm_id ?ℭ⦇ObjMap⦈) = ?ℭ⦇Obj⦈› ‹ℛ⇩∘ (dghm_id ?ℭ⦇ObjMap⦈) = ?ℭ⦇Obj⦈› and more 34 facts*) 𝔅𝔄.subsmc_cod_simp (*‹?f ∈⇩∘ 𝔅⦇Arr⦈ ⟹ 𝔅⦇Cod⦈⦇?f⦈ = 𝔄⦇Cod⦈⦇?f⦈›*) Arr (*‹𝔄⦇Arr⦈ = 𝔅⦇Arr⦈›*))[1]) (*discuss goal 4*) apply ((auto simp: smc_cs_simps (*‹semicategory ?α ?ℭ ⟹ vcard ?ℭ = 5⇩ℕ› ‹⟦semicategory ?α ?ℭ; ?h : ?c ↦⇘?ℭ⇙ ?d; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?h ∘⇩A⇘?ℭ⇙ ?g ∘⇩A⇘?ℭ⇙ ?f = ?h ∘⇩A⇘?ℭ⇙ (?g ∘⇩A⇘?ℭ⇙ ?f)› ‹?f : ↦⇩i⇩d⇩e⇘?ℭ⇙ ?b ⟹ ?f ∘⇩A⇘?ℭ⇙ ?f = ?f› ‹?f : ?a ↦⇘?ℭ⇙ ?b ⟹ ?ℭ⦇Dom⦈⦇?f⦈ = ?a› ‹?f : ?a ↦⇘?ℭ⇙ ?b ⟹ ?ℭ⦇Cod⦈⦇?f⦈ = ?b› ‹(?f ∈⇩∘ Hom ?ℭ ?a ?b) = ?f : ?a ↦⇘?ℭ⇙ ?b› ‹(?𝔊 ∘⇩D⇩G⇩H⇩M ?𝔉)⦇HomDom⦈ = ?𝔉⦇HomDom⦈› ‹(?𝔊 ∘⇩D⇩G⇩H⇩M ?𝔉)⦇HomCod⦈ = ?𝔊⦇HomCod⦈› ‹dghm_id ?ℭ⦇HomDom⦈ = ?ℭ› ‹dghm_id ?ℭ⦇HomCod⦈ = ?ℭ› ‹𝒟⇩∘ (dghm_id ?ℭ⦇ObjMap⦈) = ?ℭ⦇Obj⦈› ‹ℛ⇩∘ (dghm_id ?ℭ⦇ObjMap⦈) = ?ℭ⦇Obj⦈› and more 34 facts*) 𝔅𝔄.subsmc_cod_simp (*‹?f ∈⇩∘ 𝔅⦇Arr⦈ ⟹ 𝔅⦇Cod⦈⦇?f⦈ = 𝔄⦇Cod⦈⦇?f⦈›*) Arr (*‹𝔄⦇Arr⦈ = 𝔅⦇Arr⦈›*))[1]) (*proven 4 subgoals*) . show "𝔄⦇Comp⦈ = 𝔅⦇Comp⦈" proof (rule vsv_eqI (*‹⟦vsv ?r; vsv ?s; 𝒟⇩∘ ?r = 𝒟⇩∘ ?s; ⋀a. a ∈⇩∘ 𝒟⇩∘ ?r ⟹ ?r⦇a⦈ = ?s⦇a⦈⟧ ⟹ ?r = ?s›*)) (*goals: 1. ‹vsv (𝔄⦇Comp⦈)› 2. ‹vsv (𝔅⦇Comp⦈)› 3. ‹𝒟⇩∘ (𝔄⦇Comp⦈) = 𝒟⇩∘ (𝔅⦇Comp⦈)› 4. ‹⋀a. a ∈⇩∘ 𝒟⇩∘ (𝔄⦇Comp⦈) ⟹ 𝔄⦇Comp⦈⦇a⦈ = 𝔅⦇Comp⦈⦇a⦈›*) show "𝒟⇩∘ (𝔄⦇Comp⦈) = 𝒟⇩∘ (𝔅⦇Comp⦈)" proof (intro vsubset_antisym (*‹⟦?A ⊆⇩∘ ?B; ?B ⊆⇩∘ ?A⟧ ⟹ ?A = ?B›*) vsubsetI (*‹(⋀x. x ∈⇩∘ ?A ⟹ x ∈⇩∘ ?B) ⟹ ?A ⊆⇩∘ ?B›*)) (*goals: 1. ‹⋀x. x ∈⇩∘ 𝒟⇩∘ (𝔄⦇Comp⦈) ⟹ x ∈⇩∘ 𝒟⇩∘ (𝔅⦇Comp⦈)› 2. ‹⋀x. x ∈⇩∘ 𝒟⇩∘ (𝔅⦇Comp⦈) ⟹ x ∈⇩∘ 𝒟⇩∘ (𝔄⦇Comp⦈)›*) fix gf assume "gf ∈⇩∘ 𝒟⇩∘ (𝔄⦇Comp⦈)" (*‹(gf::V) ∈⇩∘ 𝒟⇩∘ ((𝔄::V)⦇Comp⦈)›*) then obtain g and f and b and c and a where gf_def: "gf = [g, f]⇩∘" and g: "g : b ↦⇘𝔄⇙ c" and f: "f : a ↦⇘𝔄⇙ b" (*goal: ‹(⋀g f b c a. ⟦gf = [g, f]⇩∘; g : b ↦⇘𝔄⇙ c; f : a ↦⇘𝔄⇙ b⟧ ⟹ thesis) ⟹ thesis›*) by (auto simp: 𝔄𝔅.sdg.smc_Comp_vdomain (*‹(?gf ∈⇩∘ 𝒟⇩∘ (𝔄⦇Comp⦈)) = (∃g f b c a. ?gf = [g, f]⇩∘ ∧ g : b ↦⇘𝔄⇙ c ∧ f : a ↦⇘𝔄⇙ b)›*)) from g (*‹g : b ↦⇘𝔄⇙ c›*) f (*‹f : a ↦⇘𝔄⇙ b›*) show "gf ∈⇩∘ 𝒟⇩∘ (𝔅⦇Comp⦈)" unfolding gf_def (*goal: ‹[g, f]⇩∘ ∈⇩∘ 𝒟⇩∘ (𝔅⦇Comp⦈)›*) by (meson 𝔄𝔅.dg.smc_Comp_vdomainI (*‹⟦?g : ?b ↦⇘𝔅⇙ ?c; ?f : ?a ↦⇘𝔅⇙ ?b; ?gf = [?g, ?f]⇩∘⟧ ⟹ ?gf ∈⇩∘ 𝒟⇩∘ (𝔅⦇Comp⦈)›*) 𝔄𝔅.subsmc_is_arrD (*‹?f : ?a ↦⇘𝔄⇙ ?b ⟹ ?f : ?a ↦⇘𝔅⇙ ?b›*)) next (*goal: ‹⋀x. x ∈⇩∘ 𝒟⇩∘ (𝔅⦇Comp⦈) ⟹ x ∈⇩∘ 𝒟⇩∘ (𝔄⦇Comp⦈)›*) fix gf assume "gf ∈⇩∘ 𝒟⇩∘ (𝔅⦇Comp⦈)" (*‹(gf::V) ∈⇩∘ 𝒟⇩∘ ((𝔅::V)⦇Comp⦈)›*) then obtain g and f and b and c and a where gf_def: "gf = [g, f]⇩∘" and g: "g : b ↦⇘𝔅⇙ c" and f: "f : a ↦⇘𝔅⇙ b" (*goal: ‹(⋀g f b c a. ⟦gf = [g, f]⇩∘; g : b ↦⇘𝔅⇙ c; f : a ↦⇘𝔅⇙ b⟧ ⟹ thesis) ⟹ thesis›*) by (auto simp: 𝔄𝔅.dg.smc_Comp_vdomain (*‹((?gf::V) ∈⇩∘ 𝒟⇩∘ ((𝔅::V)⦇Comp⦈)) = (∃(g::V) (f::V) (b::V) (c::V) a::V. ?gf = [g, f]⇩∘ ∧ g : b ↦⇘𝔅⇙ c ∧ f : a ↦⇘𝔅⇙ b)›*)) from g (*‹g : b ↦⇘𝔅⇙ c›*) f (*‹f : a ↦⇘𝔅⇙ b›*) show "gf ∈⇩∘ 𝒟⇩∘ (𝔄⦇Comp⦈)" unfolding gf_def (*goal: ‹[g, f]⇩∘ ∈⇩∘ 𝒟⇩∘ (𝔄⦇Comp⦈)›*) by (meson 𝔄𝔅.sdg.smc_Comp_vdomainI (*‹⟦?g : ?b ↦⇘𝔄⇙ ?c; ?f : ?a ↦⇘𝔄⇙ ?b; ?gf = [?g, ?f]⇩∘⟧ ⟹ ?gf ∈⇩∘ 𝒟⇩∘ (𝔄⦇Comp⦈)›*) 𝔅𝔄.subsmc_is_arrD (*‹?f : ?a ↦⇘𝔅⇙ ?b ⟹ ?f : ?a ↦⇘𝔄⇙ ?b›*)) qed show "a ∈⇩∘ 𝒟⇩∘ (𝔄⦇Comp⦈) ⟹ 𝔄⦇Comp⦈⦇a⦈ = 𝔅⦇Comp⦈⦇a⦈" for a by (metis 𝔄𝔅.sdg.smc_Comp_vdomain (*‹(?gf ∈⇩∘ 𝒟⇩∘ (𝔄⦇Comp⦈)) = (∃g f b c a. ?gf = [g, f]⇩∘ ∧ g : b ↦⇘𝔄⇙ c ∧ f : a ↦⇘𝔄⇙ b)›*) 𝔄𝔅.subsmc_Comp_simp (*‹⟦?g : ?b ↦⇘𝔄⇙ ?c; ?f : ?a ↦⇘𝔄⇙ ?b⟧ ⟹ ?g ∘⇩A⇘𝔄⇙ ?f = ?g ∘⇩A⇘𝔅⇙ ?f›*)) qed (auto) (*solves the remaining goals: 1. ‹vsv (𝔄⦇Comp⦈)› 2. ‹vsv (𝔅⦇Comp⦈)›*) qed (auto intro: smc_cs_intros (*‹⟦?gf = [?g, ?f]⇩∘; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?gf ∈⇩∘ composable_arrs ?ℭ› ‹⟦semicategory ?α ?ℭ; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b; ?ℭ' = ?ℭ⟧ ⟹ ?g ∘⇩A⇘?ℭ⇙ ?f : ?a ↦⇘?ℭ'⇙ ?c› ‹⟦semicategory ?α ?ℭ; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?g ∘⇩A⇘?ℭ⇙ ?f : ?a ↦⇘?ℭ⇙ ?c› ‹⟦semicategory ?α ?ℭ; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?f ∈⇩∘ ?ℭ⦇Arr⦈› ‹⟦semicategory ?α ?ℭ; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?a ∈⇩∘ ?ℭ⦇Obj⦈› ‹⟦semicategory ?α ?ℭ; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?b ∈⇩∘ ?ℭ⦇Obj⦈› ‹⟦semicategory ?α ?ℭ; ?a ∈⇩∘ ?ℭ⦇Obj⦈; ?b ∈⇩∘ ?ℭ⦇Obj⦈⟧ ⟹ Hom ?ℭ ?a ?b ∈⇩∘ Vset ?α› ‹⟦semicategory ?α ?ℭ; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b; ?gf = [?g, ?f]⇩∘⟧ ⟹ ?gf ∈⇩∘ 𝒟⇩∘ (?ℭ⦇Comp⦈)› ‹?f : ?a ↦⇘?ℭ⇙ ?b ⟹ ?f ∈⇩∘ ?ℭ⦇Arr⦈› ‹?f : ?a ↦⇘?ℭ⇙ ?b ⟹ ?f ∈⇩∘ Hom ?ℭ ?a ?b› ‹vsv (dghm_id ?ℭ⦇ObjMap⦈)› ‹vsv (dghm_id ?ℭ⦇ArrMap⦈)› and more 32 facts*)) (*solves the remaining goals: 1. ‹semicategory (?α::V) (𝔄::V)› 2. ‹semicategory (?α::V) (𝔅::V)›*) qed subsection‹Inclusion semifunctor› subsubsection‹Definition and elementary properties› text‹See Chapter I-3 in \<^cite>‹"mac_lane_categories_2010"›.› abbreviation (input) smcf_inc :: "V ⇒ V ⇒ V" where "smcf_inc ≡ dghm_inc" text‹Slicing.› lemma dghm_smcf_inc[slicing_commute]: "dghm_inc (smc_dg 𝔅) (smc_dg ℭ) = smcf_dghm (smcf_inc 𝔅 ℭ)" unfolding smcf_dghm_def dghm_inc_def smc_dg_def dg_field_simps dghm_field_simps (*goal: ‹[vid_on ([𝔅⦇[]⇩∘⦈, 𝔅⦇1⇩ℕ⦈, 𝔅⦇2⇩ℕ⦈, 𝔅⦇3⇩ℕ⦈]⇩∘⦇[]⇩∘⦈), vid_on ([𝔅⦇[]⇩∘⦈, 𝔅⦇1⇩ℕ⦈, 𝔅⦇2⇩ℕ⦈, 𝔅⦇3⇩ℕ⦈]⇩∘⦇1⇩ℕ⦈), [𝔅⦇[]⇩∘⦈, 𝔅⦇1⇩ℕ⦈, 𝔅⦇2⇩ℕ⦈, 𝔅⦇3⇩ℕ⦈]⇩∘, [ℭ⦇[]⇩∘⦈, ℭ⦇1⇩ℕ⦈, ℭ⦇2⇩ℕ⦈, ℭ⦇3⇩ℕ⦈]⇩∘]⇩∘ = [[vid_on (𝔅⦇[]⇩∘⦈), vid_on (𝔅⦇1⇩ℕ⦈), 𝔅, ℭ]⇩∘⦇[]⇩∘⦈, [vid_on (𝔅⦇[]⇩∘⦈), vid_on (𝔅⦇1⇩ℕ⦈), 𝔅, ℭ]⇩∘⦇1⇩ℕ⦈, [[vid_on (𝔅⦇[]⇩∘⦈), vid_on (𝔅⦇1⇩ℕ⦈), 𝔅, ℭ]⇩∘⦇2⇩ℕ⦈⦇[]⇩∘⦈, [vid_on (𝔅⦇[]⇩∘⦈), vid_on (𝔅⦇1⇩ℕ⦈), 𝔅, ℭ]⇩∘⦇2⇩ℕ⦈⦇1⇩ℕ⦈, [vid_on (𝔅⦇[]⇩∘⦈), vid_on (𝔅⦇1⇩ℕ⦈), 𝔅, ℭ]⇩∘⦇2⇩ℕ⦈⦇2⇩ℕ⦈, [vid_on (𝔅⦇[]⇩∘⦈), vid_on (𝔅⦇1⇩ℕ⦈), 𝔅, ℭ]⇩∘⦇2⇩ℕ⦈⦇3⇩ℕ⦈]⇩∘, [[vid_on (𝔅⦇[]⇩∘⦈), vid_on (𝔅⦇1⇩ℕ⦈), 𝔅, ℭ]⇩∘⦇3⇩ℕ⦈⦇[]⇩∘⦈, [vid_on (𝔅⦇[]⇩∘⦈), vid_on (𝔅⦇1⇩ℕ⦈), 𝔅, ℭ]⇩∘⦇3⇩ℕ⦈⦇1⇩ℕ⦈, [vid_on (𝔅⦇[]⇩∘⦈), vid_on (𝔅⦇1⇩ℕ⦈), 𝔅, ℭ]⇩∘⦇3⇩ℕ⦈⦇2⇩ℕ⦈, [vid_on (𝔅⦇[]⇩∘⦈), vid_on (𝔅⦇1⇩ℕ⦈), 𝔅, ℭ]⇩∘⦇3⇩ℕ⦈⦇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⇩ℕ›*)) text‹Elementary properties.› lemmas [smc_cs_simps] = dghm_inc_ObjMap_app dghm_inc_ArrMap_app subsubsection‹Canonical inclusion semifunctor associated with a subsemicategory› sublocale subsemicategory ⊆ inc: is_ft_semifunctor α 𝔅 ℭ ‹smcf_inc 𝔅 ℭ› proof (rule is_ft_semifunctorI (*‹⟦?𝔉 : ?𝔄 ↦↦⇩S⇩M⇩C⇘?α⇙ ?𝔅; smcf_dghm ?𝔉 : smc_dg ?𝔄 ↦↦⇩D⇩G⇩.⇩f⇩a⇩i⇩t⇩h⇩f⇩u⇩l⇘?α⇙ smc_dg ?𝔅⟧ ⟹ ?𝔉 : ?𝔄 ↦↦⇩S⇩M⇩C⇩.⇩f⇩a⇩i⇩t⇩h⇩f⇩u⇩l⇘?α⇙ ?𝔅›*)) (*goals: 1. ‹dghm_inc 𝔅 ℭ : (𝔅::V) ↦↦⇩S⇩M⇩C⇘α::V⇙ (ℭ::V)› 2. ‹smcf_dghm (dghm_inc 𝔅 ℭ) : smc_dg (𝔅::V) ↦↦⇩D⇩G⇩.⇩f⇩a⇩i⇩t⇩h⇩f⇩u⇩l⇘α::V⇙ smc_dg (ℭ::V)›*) show "smcf_inc 𝔅 ℭ : 𝔅 ↦↦⇩S⇩M⇩C⇘α⇙ ℭ" proof (rule is_semifunctorI (*‹⟦𝒵 ?α; vfsequence ?𝔉; semicategory ?α ?𝔄; semicategory ?α ?𝔅; vcard ?𝔉 = 4⇩ℕ; smcf_dghm ?𝔉 : smc_dg ?𝔄 ↦↦⇩D⇩G⇘?α⇙ smc_dg ?𝔅; ?𝔉⦇HomDom⦈ = ?𝔄; ?𝔉⦇HomCod⦈ = ?𝔅; ⋀b c g a f. ⟦g : b ↦⇘?𝔄⇙ c; f : a ↦⇘?𝔄⇙ b⟧ ⟹ ?𝔉⦇ArrMap⦈⦇g ∘⇩A⇘?𝔄⇙ f⦈ = ?𝔉⦇ArrMap⦈⦇g⦈ ∘⇩A⇘?𝔅⇙ ?𝔉⦇ArrMap⦈⦇f⦈⟧ ⟹ ?𝔉 : ?𝔄 ↦↦⇩S⇩M⇩C⇘?α⇙ ?𝔅›*)) (*goals: 1. ‹𝒵 α› 2. ‹vfsequence (dghm_inc 𝔅 ℭ)› 3. ‹semicategory α 𝔅› 4. ‹semicategory α ℭ› 5. ‹vcard (dghm_inc 𝔅 ℭ) = 4⇩ℕ› 6. ‹smcf_dghm (dghm_inc 𝔅 ℭ) : smc_dg 𝔅 ↦↦⇩D⇩G⇘α⇙ smc_dg ℭ› 7. ‹dghm_inc 𝔅 ℭ⦇HomDom⦈ = 𝔅› 8. ‹dghm_inc 𝔅 ℭ⦇HomCod⦈ = ℭ› 9. ‹⋀b c g a f. ⟦g : b ↦⇘𝔅⇙ c; f : a ↦⇘𝔅⇙ b⟧ ⟹ dghm_inc 𝔅 ℭ⦇ArrMap⦈⦇g ∘⇩A⇘𝔅⇙ f⦈ = dghm_inc 𝔅 ℭ⦇ArrMap⦈⦇g⦈ ∘⇩A⇘ℭ⇙ dghm_inc 𝔅 ℭ⦇ArrMap⦈⦇f⦈›*) show "vfsequence (dghm_inc 𝔅 ℭ)" unfolding dghm_inc_def (*goal: ‹vfsequence [vid_on (𝔅⦇Obj⦈), vid_on (𝔅⦇Arr⦈), 𝔅, ℭ]⇩∘›*) by auto show "vcard (dghm_inc 𝔅 ℭ) = 4⇩ℕ" unfolding dghm_inc_def (*goal: ‹vcard [vid_on (𝔅⦇Obj⦈), vid_on (𝔅⦇Arr⦈), 𝔅, ℭ]⇩∘ = 4⇩ℕ›*) 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)⇩ℕ›*)) fix g and b and c and f and a assume prems: "g : b ↦⇘𝔅⇙ c" "f : a ↦⇘𝔅⇙ b" (*‹(g::V) : (b::V) ↦⇘𝔅::V⇙ (c::V)› ‹(f::V) : (a::V) ↦⇘𝔅::V⇙ (b::V)›*) then have "g ∘⇩A⇘𝔅⇙ f : a ↦⇘𝔅⇙ c" by (simp add: smc_cs_intros (*‹⟦?gf = [?g, ?f]⇩∘; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?gf ∈⇩∘ composable_arrs ?ℭ› ‹⟦semicategory ?α ?ℭ; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b; ?ℭ' = ?ℭ⟧ ⟹ ?g ∘⇩A⇘?ℭ⇙ ?f : ?a ↦⇘?ℭ'⇙ ?c› ‹⟦semicategory ?α ?ℭ; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?g ∘⇩A⇘?ℭ⇙ ?f : ?a ↦⇘?ℭ⇙ ?c› ‹⟦semicategory ?α ?ℭ; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?f ∈⇩∘ ?ℭ⦇Arr⦈› ‹⟦semicategory ?α ?ℭ; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?a ∈⇩∘ ?ℭ⦇Obj⦈› ‹⟦semicategory ?α ?ℭ; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?b ∈⇩∘ ?ℭ⦇Obj⦈› ‹⟦semicategory ?α ?ℭ; ?a ∈⇩∘ ?ℭ⦇Obj⦈; ?b ∈⇩∘ ?ℭ⦇Obj⦈⟧ ⟹ Hom ?ℭ ?a ?b ∈⇩∘ Vset ?α› ‹⟦semicategory ?α ?ℭ; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b; ?gf = [?g, ?f]⇩∘⟧ ⟹ ?gf ∈⇩∘ 𝒟⇩∘ (?ℭ⦇Comp⦈)› ‹?f : ?a ↦⇘?ℭ⇙ ?b ⟹ ?f ∈⇩∘ ?ℭ⦇Arr⦈› ‹?f : ?a ↦⇘?ℭ⇙ ?b ⟹ ?f ∈⇩∘ Hom ?ℭ ?a ?b› ‹vsv (dghm_id ?ℭ⦇ObjMap⦈)› ‹vsv (dghm_id ?ℭ⦇ArrMap⦈)› and more 30 facts*)) with subsemicategory_axioms (*‹𝔅 ⊆⇩S⇩M⇩C⇘α⇙ ℭ›*) prems (*‹g : b ↦⇘𝔅⇙ c› ‹f : a ↦⇘𝔅⇙ b›*) have [simp]: "vid_on (𝔅⦇Arr⦈)⦇g ∘⇩A⇘𝔅⇙ f⦈ = g ∘⇩A⇘ℭ⇙ f" by (auto simp: smc_sub_bw_cs_simps (*‹⟦(?𝔅::V) ⊆⇩S⇩M⇩C⇘?α::V⇙ (?ℭ::V); (?f::V) ∈⇩∘ ?𝔅⦇Arr⦈⟧ ⟹ ?𝔅⦇Dom⦈⦇?f⦈ = ?ℭ⦇Dom⦈⦇?f⦈› ‹⟦(?𝔅::V) ⊆⇩S⇩M⇩C⇘?α::V⇙ (?ℭ::V); (?f::V) ∈⇩∘ ?𝔅⦇Arr⦈⟧ ⟹ ?𝔅⦇Cod⦈⦇?f⦈ = ?ℭ⦇Cod⦈⦇?f⦈› ‹⟦(?𝔅::V) ⊆⇩S⇩M⇩C⇘?α::V⇙ (?ℭ::V); (?g::V) : (?b::V) ↦⇘?𝔅⇙ (?c::V); (?f::V) : (?a::V) ↦⇘?𝔅⇙ ?b⟧ ⟹ ?g ∘⇩A⇘?𝔅⇙ ?f = ?g ∘⇩A⇘?ℭ⇙ ?f›*)) from prems (*‹g : b ↦⇘𝔅⇙ c› ‹f : a ↦⇘𝔅⇙ b›*) show "dghm_inc 𝔅 ℭ⦇ArrMap⦈⦇g ∘⇩A⇘𝔅⇙ f⦈ = dghm_inc 𝔅 ℭ⦇ArrMap⦈⦇g⦈ ∘⇩A⇘ℭ⇙ dghm_inc 𝔅 ℭ⦇ArrMap⦈⦇f⦈" by (cs_concl cs_simp: smc_cs_simps cs_intro: smc_cs_intros smc_sub_fw_cs_intros) qed (insert subsmc_inc_is_ft_dghm_axioms (*‹dghm_inc (smc_dg 𝔅) (smc_dg ℭ) : smc_dg 𝔅 ↦↦⇩D⇩G⇩.⇩f⇩a⇩i⇩t⇩h⇩f⇩u⇩l⇘α⇙ smc_dg ℭ›*), auto simp: slicing_commute[symmetric] (*‹smc_dg (op_smc (?ℭ::V)) = op_dg (smc_dg ?ℭ)› ‹smc_dg ((?𝔉::V)⦇HomDom⦈) = smcf_dghm ?𝔉⦇HomDom⦈› ‹smc_dg ((?𝔉::V)⦇HomCod⦈) = smcf_dghm ?𝔉⦇HomCod⦈› ‹smcf_dghm (op_smcf (?𝔉::V)) = op_dghm (smcf_dghm ?𝔉)› ‹smcf_dghm ((?𝔊::V) ∘⇩D⇩G⇩H⇩M (?𝔉::V)) = smcf_dghm ?𝔊 ∘⇩D⇩G⇩H⇩M smcf_dghm ?𝔉› ‹smcf_dghm ((?𝔊::V) ⇩S⇩M⇩C⇩F∘ (?𝔉::V)) = smcf_dghm ?𝔊 ⇩D⇩G⇩H⇩M∘ smcf_dghm ?𝔉› ‹smcf_dghm (dghm_id (?ℭ::V)) = dghm_id (smc_dg ?ℭ)› ‹smcf_dghm (dghm_const (?ℭ::V) (?𝔇::V) (?a::V) (?f::V)) = dghm_const (smc_dg ?ℭ) (smc_dg ?𝔇) ?a ?f› ‹smcf_dghm (inv_dghm (?𝔉::V)) = inv_dghm (smcf_dghm ?𝔉)› ‹smcf_dghm (dghm_inc (?𝔅::V) (?ℭ::V)) = dghm_inc (smc_dg ?𝔅) (smc_dg ?ℭ)›*) dghm_inc_components (*‹dghm_inc (?𝔅::V) (?ℭ::V)⦇ObjMap⦈ = vid_on (?𝔅⦇Obj⦈)› ‹dghm_inc (?𝔅::V) (?ℭ::V)⦇ArrMap⦈ = vid_on (?𝔅⦇Arr⦈)› ‹dghm_inc (?𝔅::V) (?ℭ::V)⦇HomDom⦈ = ?𝔅› ‹dghm_inc (?𝔅::V) (?ℭ::V)⦇HomCod⦈ = ?ℭ›*) smc_cs_intros (*‹⟦(?gf::V) = [?g::V, ?f::V]⇩∘; ?g : (?b::V) ↦⇘?ℭ::V⇙ (?c::V); ?f : (?a::V) ↦⇘?ℭ⇙ ?b⟧ ⟹ ?gf ∈⇩∘ composable_arrs ?ℭ› ‹⟦semicategory (?α::V) (?ℭ::V); (?g::V) : (?b::V) ↦⇘?ℭ⇙ (?c::V); (?f::V) : (?a::V) ↦⇘?ℭ⇙ ?b; (?ℭ'::V) = ?ℭ⟧ ⟹ ?g ∘⇩A⇘?ℭ⇙ ?f : ?a ↦⇘?ℭ'⇙ ?c› ‹⟦semicategory (?α::V) (?ℭ::V); (?g::V) : (?b::V) ↦⇘?ℭ⇙ (?c::V); (?f::V) : (?a::V) ↦⇘?ℭ⇙ ?b⟧ ⟹ ?g ∘⇩A⇘?ℭ⇙ ?f : ?a ↦⇘?ℭ⇙ ?c› ‹⟦semicategory (?α::V) (?ℭ::V); (?f::V) : (?a::V) ↦⇘?ℭ⇙ (?b::V)⟧ ⟹ ?f ∈⇩∘ ?ℭ⦇Arr⦈› ‹⟦semicategory (?α::V) (?ℭ::V); (?f::V) : (?a::V) ↦⇘?ℭ⇙ (?b::V)⟧ ⟹ ?a ∈⇩∘ ?ℭ⦇Obj⦈› ‹⟦semicategory (?α::V) (?ℭ::V); (?f::V) : (?a::V) ↦⇘?ℭ⇙ (?b::V)⟧ ⟹ ?b ∈⇩∘ ?ℭ⦇Obj⦈› ‹⟦semicategory (?α::V) (?ℭ::V); (?a::V) ∈⇩∘ ?ℭ⦇Obj⦈; (?b::V) ∈⇩∘ ?ℭ⦇Obj⦈⟧ ⟹ Hom ?ℭ ?a ?b ∈⇩∘ Vset ?α› ‹⟦semicategory (?α::V) (?ℭ::V); (?g::V) : (?b::V) ↦⇘?ℭ⇙ (?c::V); (?f::V) : (?a::V) ↦⇘?ℭ⇙ ?b; (?gf::V) = [?g, ?f]⇩∘⟧ ⟹ ?gf ∈⇩∘ 𝒟⇩∘ (?ℭ⦇Comp⦈)› ‹(?f::V) : (?a::V) ↦⇘?ℭ::V⇙ (?b::V) ⟹ ?f ∈⇩∘ ?ℭ⦇Arr⦈› ‹(?f::V) : (?a::V) ↦⇘?ℭ::V⇙ (?b::V) ⟹ ?f ∈⇩∘ Hom ?ℭ ?a ?b› ‹vsv (dghm_id (?ℭ::V)⦇ObjMap⦈)› ‹vsv (dghm_id (?ℭ::V)⦇ArrMap⦈)› and more 30 facts*)) (*solves the remaining goals: 1. ‹𝒵 α› 2. ‹semicategory α 𝔅› 3. ‹semicategory α ℭ› 4. ‹smcf_dghm (dghm_inc 𝔅 ℭ) : smc_dg 𝔅 ↦↦⇩D⇩G⇘α⇙ smc_dg ℭ› 5. ‹dghm_inc 𝔅 ℭ⦇HomDom⦈ = 𝔅› 6. ‹dghm_inc 𝔅 ℭ⦇HomCod⦈ = ℭ›*) qed (auto simp: slicing_commute[symmetric] (*‹smc_dg (op_smc ?ℭ) = op_dg (smc_dg ?ℭ)› ‹smc_dg (?𝔉⦇HomDom⦈) = smcf_dghm ?𝔉⦇HomDom⦈› ‹smc_dg (?𝔉⦇HomCod⦈) = smcf_dghm ?𝔉⦇HomCod⦈› ‹smcf_dghm (op_smcf ?𝔉) = op_dghm (smcf_dghm ?𝔉)› ‹smcf_dghm (?𝔊 ∘⇩D⇩G⇩H⇩M ?𝔉) = smcf_dghm ?𝔊 ∘⇩D⇩G⇩H⇩M smcf_dghm ?𝔉› ‹smcf_dghm (?𝔊 ⇩S⇩M⇩C⇩F∘ ?𝔉) = smcf_dghm ?𝔊 ⇩D⇩G⇩H⇩M∘ smcf_dghm ?𝔉› ‹smcf_dghm (dghm_id ?ℭ) = dghm_id (smc_dg ?ℭ)› ‹smcf_dghm (dghm_const ?ℭ ?𝔇 ?a ?f) = dghm_const (smc_dg ?ℭ) (smc_dg ?𝔇) ?a ?f› ‹smcf_dghm (inv_dghm ?𝔉) = inv_dghm (smcf_dghm ?𝔉)› ‹smcf_dghm (dghm_inc ?𝔅 ?ℭ) = dghm_inc (smc_dg ?𝔅) (smc_dg ?ℭ)›*) subsmc_inc_is_ft_dghm_axioms (*‹dghm_inc (smc_dg 𝔅) (smc_dg ℭ) : smc_dg 𝔅 ↦↦⇩D⇩G⇩.⇩f⇩a⇩i⇩t⇩h⇩f⇩u⇩l⇘α⇙ smc_dg ℭ›*)) (*solved the remaining goal: ‹smcf_dghm (dghm_inc 𝔅 ℭ) : smc_dg 𝔅 ↦↦⇩D⇩G⇩.⇩f⇩a⇩i⇩t⇩h⇩f⇩u⇩l⇘α⇙ smc_dg ℭ›*) lemmas (in subsemicategory) subsmc_smcf_inc_is_ft_semifunctor = inc.is_ft_semifunctor_axioms subsubsection‹Inclusion semifunctor for the opposite semicategories› lemma (in subsemicategory) subsemicategory_smcf_inc_op_smc_is_semifunctor[smc_sub_cs_intros]: "smcf_inc (op_smc 𝔅) (op_smc ℭ) : op_smc 𝔅 ↦↦⇩S⇩M⇩C⇩.⇩f⇩a⇩i⇩t⇩h⇩f⇩u⇩l⇘α⇙ op_smc ℭ" by (intro subsemicategory.subsmc_smcf_inc_is_ft_semifunctor (*‹?𝔅 ⊆⇩S⇩M⇩C⇘?α⇙ ?ℭ ⟹ dghm_inc ?𝔅 ?ℭ : ?𝔅 ↦↦⇩S⇩M⇩C⇩.⇩f⇩a⇩i⇩t⇩h⇩f⇩u⇩l⇘?α⇙ ?ℭ›*) subsmc_subsemicategory_op_smc (*‹op_smc 𝔅 ⊆⇩S⇩M⇩C⇘α⇙ op_smc ℭ›*)) lemmas [smc_sub_cs_intros] = subsemicategory.subsemicategory_smcf_inc_op_smc_is_semifunctor lemma (in subsemicategory) subdg_op_smc_smcf_inc[smc_op_simps]: "op_smcf (smcf_inc 𝔅 ℭ) = smcf_inc (op_smc 𝔅) (op_smc ℭ)" apply (rule smcf_eqI[of α ‹op_smc 𝔅› ‹op_smc ℭ›] (*‹⟦?𝔊 : op_smc 𝔅 ↦↦⇩S⇩M⇩C⇘α⇙ op_smc ℭ; ?𝔉 : ?ℭ ↦↦⇩S⇩M⇩C⇘α⇙ ?𝔇; ?𝔊⦇ObjMap⦈ = ?𝔉⦇ObjMap⦈; ?𝔊⦇ArrMap⦈ = ?𝔉⦇ArrMap⦈; op_smc 𝔅 = ?ℭ; op_smc ℭ = ?𝔇⟧ ⟹ ?𝔊 = ?𝔉›*), unfold smc_op_simps (*‹op_smc ?ℭ⦇Obj⦈ = ?ℭ⦇Obj⦈› ‹op_smc ?ℭ⦇Arr⦈ = ?ℭ⦇Arr⦈› ‹op_smc ?ℭ⦇Dom⦈ = ?ℭ⦇Cod⦈› ‹op_smc ?ℭ⦇Cod⦈ = ?ℭ⦇Dom⦈› ‹𝒟⇩∘ (op_smc ?ℭ⦇Comp⦈) = (𝒟⇩∘ (?ℭ⦇Comp⦈))¯⇩∙› ‹?f : ?b ↦⇘op_smc ?ℭ⇙ ?a = ?f : ?a ↦⇘?ℭ⇙ ?b› ‹semicategory ?α ?ℭ ⟹ ℛ⇩∘ (op_smc ?ℭ⦇Comp⦈) = ℛ⇩∘ (?ℭ⦇Comp⦈)› ‹⟦semicategory ?α ?ℭ; ?f : ?b ↦⇘?ℭ⇙ ?c; ?g : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?g ∘⇩A⇘op_smc ?ℭ⇙ ?f = ?f ∘⇩A⇘?ℭ⇙ ?g› ‹Hom (op_smc ?ℭ) ?a ?b = Hom ?ℭ ?b ?a› ‹semicategory ?α ?ℭ ⟹ op_smc (op_smc ?ℭ) = ?ℭ› ‹⟦semicategory ?α ?𝔄; semicategory ?α ?𝔅⟧ ⟹ (op_smc ?𝔄 = op_smc ?𝔅) = (?𝔄 = ?𝔅)› ‹obj_initial (op_smc ?ℭ) = obj_terminal ?ℭ› and more 27 facts*) dghm_inc_components (*‹dghm_inc ?𝔅 ?ℭ⦇ObjMap⦈ = vid_on (?𝔅⦇Obj⦈)› ‹dghm_inc ?𝔅 ?ℭ⦇ArrMap⦈ = vid_on (?𝔅⦇Arr⦈)› ‹dghm_inc ?𝔅 ?ℭ⦇HomDom⦈ = ?𝔅› ‹dghm_inc ?𝔅 ?ℭ⦇HomCod⦈ = ?ℭ›*)) (*goal: ‹op_smcf (dghm_inc 𝔅 ℭ) = dghm_inc (op_smc 𝔅) (op_smc ℭ)›*) by (auto simp: is_ft_semifunctorD (*‹?𝔉 : ?𝔄 ↦↦⇩S⇩M⇩C⇩.⇩f⇩a⇩i⇩t⇩h⇩f⇩u⇩l⇘?α⇙ ?𝔅 ⟹ ?𝔉 : ?𝔄 ↦↦⇩S⇩M⇩C⇘?α⇙ ?𝔅› ‹?𝔉 : ?𝔄 ↦↦⇩S⇩M⇩C⇩.⇩f⇩a⇩i⇩t⇩h⇩f⇩u⇩l⇘?α⇙ ?𝔅 ⟹ smcf_dghm ?𝔉 : smc_dg ?𝔄 ↦↦⇩D⇩G⇩.⇩f⇩a⇩i⇩t⇩h⇩f⇩u⇩l⇘?α⇙ smc_dg ?𝔅›*) subsemicategory_smcf_inc_op_smc_is_semifunctor (*‹dghm_inc (op_smc 𝔅) (op_smc ℭ) : op_smc 𝔅 ↦↦⇩S⇩M⇩C⇩.⇩f⇩a⇩i⇩t⇩h⇩f⇩u⇩l⇘α⇙ op_smc ℭ›*) inc.is_semifunctor_op (*‹op_smcf (dghm_inc 𝔅 ℭ) : op_smc 𝔅 ↦↦⇩S⇩M⇩C⇘α⇙ op_smc ℭ›*)) lemmas [smc_op_simps] = subsemicategory.subdg_op_smc_smcf_inc subsection‹Full subsemicategory› text‹See Chapter I-3 in \<^cite>‹"mac_lane_categories_2010"›.› locale fl_subsemicategory = subsemicategory + assumes fl_subsemicategory_fl_subdigraph: "smc_dg 𝔅 ⊆⇩D⇩G⇩.⇩f⇩u⇩l⇩l⇘α⇙ smc_dg ℭ" abbreviation is_fl_subsemicategory ("(_/ ⊆⇩S⇩M⇩C⇩.⇩f⇩u⇩l⇩lı _)" [51, 51] 50) where "𝔅 ⊆⇩S⇩M⇩C⇩.⇩f⇩u⇩l⇩l⇘α⇙ ℭ ≡ fl_subsemicategory α 𝔅 ℭ" text‹Rules.› lemma (in fl_subsemicategory) fl_subsemicategory_axioms'[smc_cs_intros]: assumes "α' = α" and "𝔅' = 𝔅" shows "𝔅' ⊆⇩S⇩M⇩C⇩.⇩f⇩u⇩l⇩l⇘α'⇙ ℭ" unfolding assms (*goal: ‹(𝔅::V) ⊆⇩S⇩M⇩C⇩.⇩f⇩u⇩l⇩l⇘α::V⇙ (ℭ::V)›*) by (rule fl_subsemicategory_axioms (*‹(𝔅::V) ⊆⇩S⇩M⇩C⇩.⇩f⇩u⇩l⇩l⇘α::V⇙ (ℭ::V)›*)) lemma (in fl_subsemicategory) fl_subsemicategory_axioms''[smc_cs_intros]: assumes "α' = α" and "ℭ' = ℭ" shows "𝔅 ⊆⇩S⇩M⇩C⇩.⇩f⇩u⇩l⇩l⇘α'⇙ ℭ'" unfolding assms (*goal: ‹𝔅 ⊆⇩S⇩M⇩C⇩.⇩f⇩u⇩l⇩l⇘α⇙ ℭ›*) by (rule fl_subsemicategory_axioms (*‹𝔅 ⊆⇩S⇩M⇩C⇩.⇩f⇩u⇩l⇩l⇘α⇙ ℭ›*)) mk_ide rf fl_subsemicategory_def[unfolded fl_subsemicategory_axioms_def] |intro fl_subsemicategoryI| |dest fl_subsemicategoryD[dest]| |elim fl_subsemicategoryE[elim!]| lemmas [smc_sub_cs_intros] = fl_subsemicategoryD(1) text‹Full subsemicategory.› sublocale fl_subsemicategory ⊆ inc: is_fl_semifunctor α 𝔅 ℭ ‹smcf_inc 𝔅 ℭ› using fl_subsemicategory_fl_subdigraph (*‹smc_dg 𝔅 ⊆⇩D⇩G⇩.⇩f⇩u⇩l⇩l⇘α⇙ smc_dg ℭ›*) inc.is_semifunctor_axioms (*‹dghm_inc 𝔅 ℭ : 𝔅 ↦↦⇩S⇩M⇩C⇘α⇙ ℭ›*) apply (intro is_fl_semifunctorI (*‹⟦?𝔉 : ?𝔄 ↦↦⇩S⇩M⇩C⇘?α⇙ ?𝔅; smcf_dghm ?𝔉 : smc_dg ?𝔄 ↦↦⇩D⇩G⇩.⇩f⇩u⇩l⇩l⇘?α⇙ smc_dg ?𝔅⟧ ⟹ ?𝔉 : ?𝔄 ↦↦⇩S⇩M⇩C⇩.⇩f⇩u⇩l⇩l⇘?α⇙ ?𝔅›*)) (*goals: 1. ‹⟦smc_dg (𝔅::V) ⊆⇩D⇩G⇩.⇩f⇩u⇩l⇩l⇘α::V⇙ smc_dg (ℭ::V); dghm_inc 𝔅 ℭ : 𝔅 ↦↦⇩S⇩M⇩C⇘α⇙ ℭ⟧ ⟹ dghm_inc 𝔅 ℭ : 𝔅 ↦↦⇩S⇩M⇩C⇘α⇙ ℭ› 2. ‹⟦smc_dg (𝔅::V) ⊆⇩D⇩G⇩.⇩f⇩u⇩l⇩l⇘α::V⇙ smc_dg (ℭ::V); dghm_inc 𝔅 ℭ : 𝔅 ↦↦⇩S⇩M⇩C⇘α⇙ ℭ⟧ ⟹ smcf_dghm (dghm_inc 𝔅 ℭ) : smc_dg 𝔅 ↦↦⇩D⇩G⇩.⇩f⇩u⇩l⇩l⇘α⇙ smc_dg ℭ› discuss goal 1*) apply ((auto simp: slicing_commute[symmetric] (*‹smc_dg (op_smc ?ℭ) = op_dg (smc_dg ?ℭ)› ‹smc_dg (?𝔉⦇HomDom⦈) = smcf_dghm ?𝔉⦇HomDom⦈› ‹smc_dg (?𝔉⦇HomCod⦈) = smcf_dghm ?𝔉⦇HomCod⦈› ‹smcf_dghm (op_smcf ?𝔉) = op_dghm (smcf_dghm ?𝔉)› ‹smcf_dghm (?𝔊 ∘⇩D⇩G⇩H⇩M ?𝔉) = smcf_dghm ?𝔊 ∘⇩D⇩G⇩H⇩M smcf_dghm ?𝔉› ‹smcf_dghm (?𝔊 ⇩S⇩M⇩C⇩F∘ ?𝔉) = smcf_dghm ?𝔊 ⇩D⇩G⇩H⇩M∘ smcf_dghm ?𝔉› ‹smcf_dghm (dghm_id ?ℭ) = dghm_id (smc_dg ?ℭ)› ‹smcf_dghm (dghm_const ?ℭ ?𝔇 ?a ?f) = dghm_const (smc_dg ?ℭ) (smc_dg ?𝔇) ?a ?f› ‹smcf_dghm (inv_dghm ?𝔉) = inv_dghm (smcf_dghm ?𝔉)› ‹smcf_dghm (dghm_inc ?𝔅 ?ℭ) = dghm_inc (smc_dg ?𝔅) (smc_dg ?ℭ)›*))[1]) (*discuss goal 2*) apply ((auto simp: slicing_commute[symmetric] (*‹smc_dg (op_smc ?ℭ) = op_dg (smc_dg ?ℭ)› ‹smc_dg (?𝔉⦇HomDom⦈) = smcf_dghm ?𝔉⦇HomDom⦈› ‹smc_dg (?𝔉⦇HomCod⦈) = smcf_dghm ?𝔉⦇HomCod⦈› ‹smcf_dghm (op_smcf ?𝔉) = op_dghm (smcf_dghm ?𝔉)› ‹smcf_dghm (?𝔊 ∘⇩D⇩G⇩H⇩M ?𝔉) = smcf_dghm ?𝔊 ∘⇩D⇩G⇩H⇩M smcf_dghm ?𝔉› ‹smcf_dghm (?𝔊 ⇩S⇩M⇩C⇩F∘ ?𝔉) = smcf_dghm ?𝔊 ⇩D⇩G⇩H⇩M∘ smcf_dghm ?𝔉› ‹smcf_dghm (dghm_id ?ℭ) = dghm_id (smc_dg ?ℭ)› ‹smcf_dghm (dghm_const ?ℭ ?𝔇 ?a ?f) = dghm_const (smc_dg ?ℭ) (smc_dg ?𝔇) ?a ?f› ‹smcf_dghm (inv_dghm ?𝔉) = inv_dghm (smcf_dghm ?𝔉)› ‹smcf_dghm (dghm_inc ?𝔅 ?ℭ) = dghm_inc (smc_dg ?𝔅) (smc_dg ?ℭ)›*))[1]) (*proven 2 subgoals*) . subsection‹Wide subsemicategory› subsubsection‹Definition and elementary properties› text‹ See \<^cite>‹"noauthor_nlab_nodate"›\footnote{ \url{https://ncatlab.org/nlab/show/wide+subcategory} }). › locale wide_subsemicategory = subsemicategory + assumes wide_subsmc_wide_subdigraph: "smc_dg 𝔅 ⊆⇩D⇩G⇩.⇩w⇩i⇩d⇩e⇘α⇙ smc_dg ℭ" abbreviation is_wide_subsemicategory ("(_/ ⊆⇩S⇩M⇩C⇩.⇩w⇩i⇩d⇩eı _)" [51, 51] 50) where "𝔅 ⊆⇩S⇩M⇩C⇩.⇩w⇩i⇩d⇩e⇘α⇙ ℭ ≡ wide_subsemicategory α 𝔅 ℭ" text‹Rules.› lemma (in wide_subsemicategory) wide_subsemicategory_axioms'[smc_cs_intros]: assumes "α' = α" and "𝔅' = 𝔅" shows "𝔅' ⊆⇩S⇩M⇩C⇩.⇩w⇩i⇩d⇩e⇘α'⇙ ℭ" unfolding assms (*goal: ‹𝔅 ⊆⇩S⇩M⇩C⇩.⇩w⇩i⇩d⇩e⇘α⇙ ℭ›*) by (rule wide_subsemicategory_axioms (*‹𝔅 ⊆⇩S⇩M⇩C⇩.⇩w⇩i⇩d⇩e⇘α⇙ ℭ›*)) lemma (in wide_subsemicategory) wide_subsemicategory_axioms''[smc_cs_intros]: assumes "α' = α" and "ℭ' = ℭ" shows "𝔅 ⊆⇩S⇩M⇩C⇩.⇩w⇩i⇩d⇩e⇘α'⇙ ℭ'" unfolding assms (*goal: ‹𝔅 ⊆⇩S⇩M⇩C⇩.⇩w⇩i⇩d⇩e⇘α⇙ ℭ›*) by (rule wide_subsemicategory_axioms (*‹𝔅 ⊆⇩S⇩M⇩C⇩.⇩w⇩i⇩d⇩e⇘α⇙ ℭ›*)) mk_ide rf wide_subsemicategory_def[unfolded wide_subsemicategory_axioms_def] |intro wide_subsemicategoryI| |dest wide_subsemicategoryD[dest]| |elim wide_subsemicategoryE[elim!]| lemmas [smc_sub_cs_intros] = wide_subsemicategoryD(1) text‹Wide subsemicategory is wide subdigraph.› context wide_subsemicategory begin interpretation wide_subdg: wide_subdigraph α ‹smc_dg 𝔅› ‹smc_dg ℭ› by (rule wide_subsmc_wide_subdigraph (*‹smc_dg 𝔅 ⊆⇩D⇩G⇩.⇩w⇩i⇩d⇩e⇘α⇙ smc_dg ℭ›*)) lemmas_with [unfolded slicing_simps]: wide_subsmc_Obj[dg_sub_bw_cs_intros] = wide_subdg.wide_subdg_Obj and wide_subsmc_obj_eq[dg_sub_bw_cs_simps] = wide_subdg.wide_subdg_obj_eq end lemmas [dg_sub_bw_cs_intros] = wide_subsemicategory.wide_subsmc_Obj lemmas [dg_sub_bw_cs_simps] = wide_subsemicategory.wide_subsmc_obj_eq subsubsection‹The wide subsemicategory relation is a partial order› lemma wide_subsmc_refl: assumes "semicategory α 𝔄" shows "𝔄 ⊆⇩S⇩M⇩C⇩.⇩w⇩i⇩d⇩e⇘α⇙ 𝔄" proof (-) (*goal: ‹𝔄 ⊆⇩S⇩M⇩C⇩.⇩w⇩i⇩d⇩e⇘α⇙ 𝔄›*) interpret semicategory "α" "𝔄" by (rule assms (*‹semicategory α 𝔄›*)) show "?thesis" (*goal: ‹𝔄 ⊆⇩S⇩M⇩C⇩.⇩w⇩i⇩d⇩e⇘α⇙ 𝔄›*) by (auto intro: assms (*‹semicategory (α::V) (𝔄::V)›*) slicing_intros (*‹(?f::V) : (?a::V) ↦⇘?ℭ::V⇙ (?b::V) ⟹ ?f : ?a ↦⇘smc_dg ?ℭ⇙ ?b› ‹semicategory (?α::V) (?ℭ::V) ⟹ digraph ?α (smc_dg ?ℭ)› ‹⟦(?𝔉::V) : (?𝔄::V) ↦↦⇩S⇩M⇩C⇘?α::V⇙ (?𝔅::V); (?𝔄'::V) = smc_dg ?𝔄; (?𝔅'::V) = smc_dg ?𝔅⟧ ⟹ smcf_dghm ?𝔉 : ?𝔄' ↦↦⇩D⇩G⇘?α⇙ ?𝔅'› ‹⟦(?𝔉::V) : op_smc (?𝔄::V) ↦↦⇩S⇩M⇩C⇘?α::V⇙ (?𝔅::V); (?𝔄'::V) = op_dg (smc_dg ?𝔄); (?𝔅'::V) = smc_dg ?𝔅⟧ ⟹ smcf_dghm ?𝔉 : ?𝔄' ↦↦⇩D⇩G⇘?α⇙ ?𝔅'› ‹⟦(?𝔉::V) : (?𝔄::V) ↦↦⇩S⇩M⇩C⇩.⇩f⇩a⇩i⇩t⇩h⇩f⇩u⇩l⇘?α::V⇙ (?𝔅::V); (?𝔄'::V) = smc_dg ?𝔄; (?𝔅'::V) = smc_dg ?𝔅⟧ ⟹ smcf_dghm ?𝔉 : ?𝔄' ↦↦⇩D⇩G⇩.⇩f⇩a⇩i⇩t⇩h⇩f⇩u⇩l⇘?α⇙ ?𝔅'› ‹⟦(?𝔉::V) : (?𝔄::V) ↦↦⇩S⇩M⇩C⇩.⇩f⇩u⇩l⇩l⇘?α::V⇙ (?𝔅::V); (?𝔄'::V) = smc_dg ?𝔄; (?𝔅'::V) = smc_dg ?𝔅⟧ ⟹ smcf_dghm ?𝔉 : ?𝔄' ↦↦⇩D⇩G⇩.⇩f⇩u⇩l⇩l⇘?α⇙ ?𝔅'› ‹⟦(?𝔉::V) : (?𝔄::V) ↦↦⇩S⇩M⇩C⇩.⇩f⇩f⇘?α::V⇙ (?𝔅::V); (?𝔄'::V) = smc_dg ?𝔄; (?𝔅'::V) = smc_dg ?𝔅⟧ ⟹ smcf_dghm ?𝔉 : ?𝔄' ↦↦⇩D⇩G⇩.⇩f⇩f⇘?α⇙ ?𝔅'› ‹⟦(?𝔉::V) : (?𝔄::V) ↦↦⇩S⇩M⇩C⇩.⇩i⇩s⇩o⇘?α::V⇙ (?𝔅::V); (?𝔄'::V) = smc_dg ?𝔄; (?𝔅'::V) = smc_dg ?𝔅⟧ ⟹ smcf_dghm ?𝔉 : ?𝔄' ↦↦⇩D⇩G⇩.⇩i⇩s⇩o⇘?α⇙ ?𝔅'› ‹digraph (α::V) (smc_dg (𝔄::V))›*) wide_subdg_refl (*‹digraph (?α::V) (?𝔄::V) ⟹ ?𝔄 ⊆⇩D⇩G⇩.⇩w⇩i⇩d⇩e⇘?α⇙ ?𝔄›*) wide_subsemicategoryI (*‹⟦(?𝔅::V) ⊆⇩S⇩M⇩C⇘?α::V⇙ (?ℭ::V); smc_dg ?𝔅 ⊆⇩D⇩G⇩.⇩w⇩i⇩d⇩e⇘?α⇙ smc_dg ?ℭ⟧ ⟹ ?𝔅 ⊆⇩S⇩M⇩C⇩.⇩w⇩i⇩d⇩e⇘?α⇙ ?ℭ›*) subsmc_refl (*‹semicategory (?α::V) (?𝔄::V) ⟹ ?𝔄 ⊆⇩S⇩M⇩C⇘?α⇙ ?𝔄›*)) qed lemma wide_subsmc_trans[trans]: assumes "𝔄 ⊆⇩S⇩M⇩C⇩.⇩w⇩i⇩d⇩e⇘α⇙ 𝔅" and "𝔅 ⊆⇩S⇩M⇩C⇩.⇩w⇩i⇩d⇩e⇘α⇙ ℭ" shows "𝔄 ⊆⇩S⇩M⇩C⇩.⇩w⇩i⇩d⇩e⇘α⇙ ℭ" proof (-) (*goal: ‹𝔄 ⊆⇩S⇩M⇩C⇩.⇩w⇩i⇩d⇩e⇘α⇙ ℭ›*) interpret 𝔄𝔅: wide_subsemicategory "α" "𝔄" "𝔅" by (rule assms( (*‹𝔄 ⊆⇩S⇩M⇩C⇩.⇩w⇩i⇩d⇩e⇘α⇙ 𝔅›*) 1)) interpret 𝔅ℭ: wide_subsemicategory "α" "𝔅" "ℭ" by (rule assms( (*‹𝔅 ⊆⇩S⇩M⇩C⇩.⇩w⇩i⇩d⇩e⇘α⇙ ℭ›*) 2)) show "?thesis" (*goal: ‹(𝔄::V) ⊆⇩S⇩M⇩C⇩.⇩w⇩i⇩d⇩e⇘α::V⇙ (ℭ::V)›*) apply (intro wide_subsemicategoryI (*‹⟦?𝔅 ⊆⇩S⇩M⇩C⇘?α⇙ ?ℭ; smc_dg ?𝔅 ⊆⇩D⇩G⇩.⇩w⇩i⇩d⇩e⇘?α⇙ smc_dg ?ℭ⟧ ⟹ ?𝔅 ⊆⇩S⇩M⇩C⇩.⇩w⇩i⇩d⇩e⇘?α⇙ ?ℭ›*) subsmc_trans[ OF 𝔄𝔅.subsemicategory_axioms 𝔅ℭ.subsemicategory_axioms (*‹𝔄 ⊆⇩S⇩M⇩C⇘α⇙ ℭ›*) ]) (*goal: ‹𝔄 ⊆⇩S⇩M⇩C⇩.⇩w⇩i⇩d⇩e⇘α⇙ ℭ›*) apply (rule wide_subdg_trans (*‹⟦?𝔄 ⊆⇩D⇩G⇩.⇩w⇩i⇩d⇩e⇘?α⇙ ?𝔅; ?𝔅 ⊆⇩D⇩G⇩.⇩w⇩i⇩d⇩e⇘?α⇙ ?ℭ⟧ ⟹ ?𝔄 ⊆⇩D⇩G⇩.⇩w⇩i⇩d⇩e⇘?α⇙ ?ℭ›*)) (*goals: 1. ‹smc_dg 𝔄 ⊆⇩D⇩G⇩.⇩w⇩i⇩d⇩e⇘α⇙ ?𝔅2› 2. ‹?𝔅2 ⊆⇩D⇩G⇩.⇩w⇩i⇩d⇩e⇘α⇙ smc_dg ℭ› discuss goal 1*) apply (rule 𝔄𝔅.wide_subsmc_wide_subdigraph (*‹smc_dg 𝔄 ⊆⇩D⇩G⇩.⇩w⇩i⇩d⇩e⇘α⇙ smc_dg 𝔅›*)) (*discuss goal 2*) apply (rule 𝔅ℭ.wide_subsmc_wide_subdigraph (*‹smc_dg 𝔅 ⊆⇩D⇩G⇩.⇩w⇩i⇩d⇩e⇘α⇙ smc_dg ℭ›*)) (*proven 2 subgoals*) . qed lemma wide_subsmc_antisym: assumes "𝔄 ⊆⇩S⇩M⇩C⇩.⇩w⇩i⇩d⇩e⇘α⇙ 𝔅" and "𝔅 ⊆⇩S⇩M⇩C⇩.⇩w⇩i⇩d⇩e⇘α⇙ 𝔄" shows "𝔄 = 𝔅" proof (-) (*goal: ‹(𝔄::V) = (𝔅::V)›*) interpret 𝔄𝔅: wide_subsemicategory "α" "𝔄" "𝔅" by (rule assms( (*‹𝔄 ⊆⇩S⇩M⇩C⇩.⇩w⇩i⇩d⇩e⇘α⇙ 𝔅›*) 1)) interpret 𝔅𝔄: wide_subsemicategory "α" "𝔅" "𝔄" by (rule assms( (*‹𝔅 ⊆⇩S⇩M⇩C⇩.⇩w⇩i⇩d⇩e⇘α⇙ 𝔄›*) 2)) show "?thesis" (*goal: ‹𝔄 = 𝔅›*) by (rule subsmc_antisym[ OF 𝔄𝔅.subsemicategory_axioms 𝔅𝔄.subsemicategory_axioms (*‹𝔄 = 𝔅›*) ]) qed text‹\newpage› end
{ "path": "afp-2025-02-12/thys/CZH_Foundations/czh_semicategories/CZH_SMC_Subsemicategory.thy", "repo": "afp-2025-02-12", "sha": "3e1cef5168a1e82a2968c54dd58156f5dfc7e1e0c3a9805d8b9fc220216dfd36" }
section ‹Helpers› theory Helpers imports Main begin text ‹ First, we will prove a few lemmas unrelated to graphs or Menger's Theorem. These lemmas will simplify some of the other proof steps. › text ‹ If two finite sets have different cardinality, then there exists an element in the larger set that is not in the smaller set. › lemma card_finite_less_ex: assumes finite_A: "finite A" and finite_B: "finite B" and card_AB: "card A < card B" shows "∃b ∈ B. b ∉ A" proof (-) (*goal: ‹∃b∈B. b ∉ A›*) have "card (B - A) > 0" using finite_A (*‹finite (A::'a set)›*) finite_B (*‹finite (B::'a set)›*) card_AB (*‹card A < card B›*) by (meson Diff_eq_empty_iff (*‹((?A::?'a set) - (?B::?'a set) = {}) = (?A ⊆ ?B)›*) card_eq_0_iff (*‹(card (?A::?'a set) = (0::nat)) = (?A = {} ∨ infinite ?A)›*) card_mono (*‹⟦finite (?B::?'a set); (?A::?'a set) ⊆ ?B⟧ ⟹ card ?A ≤ card ?B›*) finite_Diff (*‹finite (?A::?'a set) ⟹ finite (?A - (?B::?'a set))›*) gr0I (*‹((?n::nat) = (0::nat) ⟹ False) ⟹ (0::nat) < ?n›*) leD (*‹(?y::?'a) ≤ (?x::?'a) ⟹ ¬ ?x < ?y›*)) then show "?thesis" (*goal: ‹∃b∈B. b ∉ A›*) using finite_B (*‹finite B›*) by (metis Diff_eq_empty_iff (*‹(?A - ?B = {}) = (?A ⊆ ?B)›*) card_0_eq (*‹finite ?A ⟹ (card ?A = 0) = (?A = {})›*) finite_Diff (*‹finite ?A ⟹ finite (?A - ?B)›*) neq_iff (*‹(?x ≠ ?y) = (?x < ?y ∨ ?y < ?x)›*) subsetI (*‹(⋀x. x ∈ ?A ⟹ x ∈ ?B) ⟹ ?A ⊆ ?B›*)) qed text ‹ The cardinality of the union of two disjoint finite sets is the sum of their cardinalities even if we intersect everything with a fixed set @{term X}. › lemma card_intersect_sum_disjoint: assumes "finite B" "finite C" "A = B ∪ C" "B ∩ C = {}" shows "card (A ∩ X) = card (B ∩ X) + card (C ∩ X)" by (metis (no_types, lifting) Un_Diff_Int (*‹?A - ?B ∪ ?A ∩ ?B = ?A›*) assms (*‹finite B› ‹finite C› ‹A = B ∪ C› ‹B ∩ C = {}›*) card_Un_disjoint (*‹⟦finite ?A; finite ?B; ?A ∩ ?B = {}⟧ ⟹ card (?A ∪ ?B) = card ?A + card ?B›*) finite_Int (*‹finite ?F ∨ finite ?G ⟹ finite (?F ∩ ?G)›*) inf.commute (*‹inf ?a ?b = inf ?b ?a›*) inf_sup_distrib2 (*‹inf (sup ?y ?z) ?x = sup (inf ?y ?x) (inf ?z ?x)›*) sup_eq_bot_iff (*‹(sup ?x ?y = bot) = (?x = bot ∧ ?y = bot)›*)) text ‹ If @{term x} is in a list @{term xs} but is not its last element, then it is also in @{term "butlast xs"}. › lemma set_butlast: "⟦ x ∈ set xs; x ≠ last xs ⟧ ⟹ x ∈ set (butlast xs)" by (metis butlast.simps( (*‹butlast (?x # ?xs) = (if ?xs = [] then [] else ?x # butlast ?xs)›*) 2) in_set_butlast_appendI (*‹?x ∈ set (butlast ?xs) ∨ ?x ∈ set (butlast ?ys) ⟹ ?x ∈ set (butlast (?xs @ ?ys))›*) last.simps (*‹last (?x # ?xs) = (if ?xs = [] then ?x else last ?xs)›*) last_appendR (*‹?ys ≠ [] ⟹ last (?xs @ ?ys) = last ?ys›*) list.set_intros( (*‹?x21.0 ∈ set (?x21.0 # ?x22.0)›*) 1) split_list_first (*‹?x ∈ set ?xs ⟹ ∃ys zs. ?xs = ys @ ?x # zs ∧ ?x ∉ set ys›*)) text ‹ If a property @{term P} is satisfiable and if we have a weight measure mapping into the natural numbers, then there exists an element of minimum weight satisfying @{term P} because the natural numbers are well-ordered. › lemma arg_min_ex: fixes P :: "'a ⇒ bool" and weight :: "'a ⇒ nat" assumes "∃x. P x" obtains x where "P x" "⋀y. P y ⟹ weight x ≤ weight y" proof (cases "∃x. P x ∧ weight x = 0") (*goals: 1. ‹⟦⋀x. ⟦P x; ⋀y. P y ⟹ weight x ≤ weight y⟧ ⟹ thesis; ∃x. P x ∧ weight x = 0⟧ ⟹ thesis› 2. ‹⟦⋀x. ⟦P x; ⋀y. P y ⟹ weight x ≤ weight y⟧ ⟹ thesis; ∄x. P x ∧ weight x = 0⟧ ⟹ thesis›*) case True (*‹∃x. P x ∧ weight x = 0›*) then show "?thesis" (*goal: ‹thesis›*) using that (*‹⟦P ?x; ⋀y. P y ⟹ weight ?x ≤ weight y⟧ ⟹ thesis›*) by auto next (*goal: ‹⟦⋀x. ⟦P x; ⋀y. P y ⟹ weight x ≤ weight y⟧ ⟹ thesis; ∄x. P x ∧ weight x = 0⟧ ⟹ thesis›*) case False (*‹∄x. P x ∧ weight x = 0›*) then show "?thesis" (*goal: ‹thesis›*) using that (*‹⟦P ?x; ⋀y. P y ⟹ weight ?x ≤ weight y⟧ ⟹ thesis›*) ex_least_nat_le[of "λn. ∃x. P x ∧ weight x = n"] (*‹⟦∃x. P x ∧ weight x = ?n; ∄x. P x ∧ weight x = 0⟧ ⟹ ∃k≤?n. (∀i<k. ∄x. P x ∧ weight x = i) ∧ (∃x. P x ∧ weight x = k)›*) assms (*‹∃x. P x›*) by (metis not_le_imp_less (*‹¬ ?y ≤ ?x ⟹ ?x < ?y›*)) qed end
{ "path": "afp-2025-02-12/thys/Menger/Helpers.thy", "repo": "afp-2025-02-12", "sha": "1d0853fdf6a1407f18a421681f9ef19f49bded774fa3a58451aa163322285a19" }
(******************************************************************************* Project: IsaNet Author: Tobias Klenze, ETH Zurich <tobias.klenze@inf.ethz.ch> Version: JCSPaper.1.0 Isabelle Version: Isabelle2021-1 Copyright (c) 2022 Tobias Klenze Licence: Mozilla Public License 2.0 (MPL) / BSD-3-Clause (dual license) *******************************************************************************) section ‹SCION Variant› text‹This is a slightly variant version of SCION, in which the successor's hop information is not embedded in the MAC of a hop field. This difference shows up in the definition of @{term "hf_valid"}.› section ‹SCION› theory SCION_variant imports "../Parametrized_Dataplane_3_directed" "../infrastructure/Keys" begin locale scion_defs = network_assums_direct _ _ _ auth_seg0 for auth_seg0 :: "(msgterm × ahi list) set" begin (******************************************************************************) subsection ‹Hop validation check and extract functions› (******************************************************************************) type_synonym SCION_HF = "(unit, unit) HF" text‹The predicate @{term "hf_valid"} is given to the concrete parametrized model as a parameter. It ensures the authenticity of the hop authenticator in the hop field. The predicate takes an authenticated info field (in this model always a numeric value, hence the matching on Num ts), the hop field to be validated and in some cases the next hop field. We distinguish if there is a next hop field (this yields the two cases below). If there is not, then the hvf simply consists of a MAC over the authenticated info field and the local routing information of the hop, using the key of the hop to which the hop field belongs. If on the other hand, there is a subsequent hop field, then the hvf of that hop field is also included in the MAC computation.› fun hf_valid :: "msgterm ⇒ msgterm ⇒ SCION_HF ⇒ SCION_HF option ⇒ bool" where "hf_valid (Num ts) uinfo ⦇AHI = ahi, UHI = _, HVF = x⦈ (Some ⦇AHI = ahi2, UHI = _, HVF = x2⦈) ⟷ (∃upif downif. x = Mac[macKey (ASID ahi)] (L [Num ts, upif, downif, x2]) ∧ ASIF (DownIF ahi) downif ∧ ASIF (UpIF ahi) upif ∧ uinfo = ε)" | "hf_valid (Num ts) uinfo ⦇AHI = ahi, UHI = _, HVF = x⦈ None ⟷ (∃upif downif. x = Mac[macKey (ASID ahi)] (L [Num ts, upif, downif]) ∧ ASIF (DownIF ahi) downif ∧ ASIF (UpIF ahi) upif ∧ uinfo = ε)" | "hf_valid _ _ _ _ = False" definition upd_uinfo :: "msgterm ⇒ SCION_HF ⇒ msgterm" where "upd_uinfo uinfo hf ≡ uinfo" text‹We can extract the entire path from the hvf field, which includes the local forwarding of the current hop, the local forwarding information of the next hop (if existant) and, recursively, all upstream hvf fields and their hop information.› fun extr :: "msgterm ⇒ ahi list" where "extr (Mac[macKey asid] (L [ts, upif, downif, x2])) = ⦇UpIF = term2if upif, DownIF = term2if downif, ASID = asid⦈ # extr x2" | "extr (Mac[macKey asid] (L [ts, upif, downif])) = [⦇UpIF = term2if upif, DownIF = term2if downif, ASID = asid⦈]" | "extr _ = []" text‹Extract the authenticated info field from a hop validation field.› fun extr_ainfo :: "msgterm ⇒ msgterm" where "extr_ainfo (Mac[macKey asid] (L (Num ts # xs))) = Num ts" | "extr_ainfo _ = ε" abbreviation term_ainfo :: "msgterm ⇒ msgterm" where "term_ainfo ≡ id" text‹When observing a hop field, an attacker learns the HVF. UHI is empty and the AHI only contains public information that are not terms.› fun terms_hf :: "SCION_HF ⇒ msgterm set" where "terms_hf hf = {HVF hf}" abbreviation terms_uinfo :: "msgterm ⇒ msgterm set" where "terms_uinfo x ≡ {x}" text‹An authenticated info field is always a number (corresponding to a timestamp). The unauthenticated info field is set to the empty term @{term "ε"}.› definition auth_restrict where "auth_restrict ainfo uinfo l ≡ (∃ts. ainfo = Num ts) ∧ (uinfo = ε)" abbreviation no_oracle where "no_oracle ≡ (λ _ _. True)" text‹We now define useful properties of the above definition.› lemma hf_valid_invert: "hf_valid tsn uinfo hf mo ⟷ ((∃ahi ahi2 ts upif downif asid x x2. hf = ⦇AHI = ahi, UHI = (), HVF = x⦈ ∧ ASID ahi = asid ∧ ASIF (DownIF ahi) downif ∧ ASIF (UpIF ahi) upif ∧ mo = Some ⦇AHI = ahi2, UHI = (), HVF = x2⦈ ∧ x = Mac[macKey asid] (L [tsn, upif, downif, x2]) ∧ tsn = Num ts ∧ uinfo = ε) ∨ (∃ahi ts upif downif asid x. hf = ⦇AHI = ahi, UHI = (), HVF = x⦈ ∧ ASID ahi = asid ∧ ASIF (DownIF ahi) downif ∧ ASIF (UpIF ahi) upif ∧ mo = None ∧ x = Mac[macKey asid] (L [tsn, upif, downif]) ∧ tsn = Num ts ∧ uinfo = ε) )" by (auto elim!: hf_valid.elims (*‹⟦hf_valid ?x ?xa ?xb ?xc = ?y; ⋀ts uinfo ahi uu_ x ahi2 uv_ x2. ⟦?x = Num ts; ?xa = uinfo; ?xb = ⦇AHI = ahi, UHI = uu_, HVF = x⦈; ?xc = Some ⦇AHI = ahi2, UHI = uv_, HVF = x2⦈; ?y = (∃upif downif. x = Mac[macKey (ASID ahi)] (L [Num ts, upif, downif, x2]) ∧ ASIF (DownIF ahi) downif ∧ ASIF (UpIF ahi) upif ∧ uinfo = ε)⟧ ⟹ ?P; ⋀ts uinfo ahi uw_ x. ⟦?x = Num ts; ?xa = uinfo; ?xb = ⦇AHI = ahi, UHI = uw_, HVF = x⦈; ?xc = None; ?y = (∃upif downif. x = Mac[macKey (ASID ahi)] (L [Num ts, upif, downif]) ∧ ASIF (DownIF ahi) downif ∧ ASIF (UpIF ahi) upif ∧ uinfo = ε)⟧ ⟹ ?P; ⋀uy_ uz_ va_. ⟦?x = ε; ?xa = uy_; ?xb = uz_; ?xc = va_; ¬ ?y⟧ ⟹ ?P; ⋀v uy_ uz_ va_. ⟦?x = AS v; ?xa = uy_; ?xb = uz_; ?xc = va_; ¬ ?y⟧ ⟹ ?P; ⋀v uy_ uz_ va_. ⟦?x = Key v; ?xa = uy_; ?xb = uz_; ?xc = va_; ¬ ?y⟧ ⟹ ?P; ⋀v uy_ uz_ va_. ⟦?x = Nonce v; ?xa = uy_; ?xb = uz_; ?xc = va_; ¬ ?y⟧ ⟹ ?P; ⋀v uy_ uz_ va_. ⟦?x = L v; ?xa = uy_; ?xb = uz_; ?xc = va_; ¬ ?y⟧ ⟹ ?P; ⋀v uy_ uz_ va_. ⟦?x = FS v; ?xa = uy_; ?xb = uz_; ?xc = va_; ¬ ?y⟧ ⟹ ?P; ⋀v vb uy_ uz_ va_. ⟦?x = ⟨v, vb⟩; ?xa = uy_; ?xb = uz_; ?xc = va_; ¬ ?y⟧ ⟹ ?P; ⋀v uy_ uz_ va_. ⟦?x = Hash v; ?xa = uy_; ?xb = uz_; ?xc = va_; ¬ ?y⟧ ⟹ ?P; ⋀v vb uy_ uz_ va_. ⟦?x = Crypt v vb; ?xa = uy_; ?xb = uz_; ?xc = va_; ¬ ?y⟧ ⟹ ?P; ⋀uy_ uz_. ⟦?x = ε; ?xa = uy_; ?xb = uz_; ?xc = None; ¬ ?y⟧ ⟹ ?P; ⋀v uy_ uz_. ⟦?x = AS v; ?xa = uy_; ?xb = uz_; ?xc = None; ¬ ?y⟧ ⟹ ?P; ⋀v uy_ uz_. ⟦?x = Key v; ?xa = uy_; ?xb = uz_; ?xc = None; ¬ ?y⟧ ⟹ ?P; ⋀v uy_ uz_. ⟦?x = Nonce v; ?xa = uy_; ?xb = uz_; ?xc = None; ¬ ?y⟧ ⟹ ?P; ⋀v uy_ uz_. ⟦?x = L v; ?xa = uy_; ?xb = uz_; ?xc = None; ¬ ?y⟧ ⟹ ?P; ⋀v uy_ uz_. ⟦?x = FS v; ?xa = uy_; ?xb = uz_; ?xc = None; ¬ ?y⟧ ⟹ ?P; ⋀v va uy_ uz_. ⟦?x = ⟨v, va⟩; ?xa = uy_; ?xb = uz_; ?xc = None; ¬ ?y⟧ ⟹ ?P; ⋀v uy_ uz_. ⟦?x = Hash v; ?xa = uy_; ?xb = uz_; ?xc = None; ¬ ?y⟧ ⟹ ?P; ⋀v va uy_ uz_. ⟦?x = Crypt v va; ?xa = uy_; ?xb = uz_; ?xc = None; ¬ ?y⟧ ⟹ ?P⟧ ⟹ ?P› ‹⟦hf_valid ?x ?xa ?xb ?xc; ⋀ts uinfo ahi uu_ x ahi2 uv_ x2. ⟦?x = Num ts; ?xa = uinfo; ?xb = ⦇AHI = ahi, UHI = uu_, HVF = x⦈; ?xc = Some ⦇AHI = ahi2, UHI = uv_, HVF = x2⦈; ∃upif downif. x = Mac[macKey (ASID ahi)] (L [Num ts, upif, downif, x2]) ∧ ASIF (DownIF ahi) downif ∧ ASIF (UpIF ahi) upif ∧ uinfo = ε⟧ ⟹ ?P; ⋀ts uinfo ahi uw_ x. ⟦?x = Num ts; ?xa = uinfo; ?xb = ⦇AHI = ahi, UHI = uw_, HVF = x⦈; ?xc = None; ∃upif downif. x = Mac[macKey (ASID ahi)] (L [Num ts, upif, downif]) ∧ ASIF (DownIF ahi) downif ∧ ASIF (UpIF ahi) upif ∧ uinfo = ε⟧ ⟹ ?P⟧ ⟹ ?P› ‹⟦¬ hf_valid ?x ?xa ?xb ?xc; ⋀ts uinfo ahi uu_ x ahi2 uv_ x2. ⟦?x = Num ts; ?xa = uinfo; ?xb = ⦇AHI = ahi, UHI = uu_, HVF = x⦈; ?xc = Some ⦇AHI = ahi2, UHI = uv_, HVF = x2⦈; ∄upif downif. x = Mac[macKey (ASID ahi)] (L [Num ts, upif, downif, x2]) ∧ ASIF (DownIF ahi) downif ∧ ASIF (UpIF ahi) upif ∧ uinfo = ε⟧ ⟹ ?P; ⋀ts uinfo ahi uw_ x. ⟦?x = Num ts; ?xa = uinfo; ?xb = ⦇AHI = ahi, UHI = uw_, HVF = x⦈; ?xc = None; ∄upif downif. x = Mac[macKey (ASID ahi)] (L [Num ts, upif, downif]) ∧ ASIF (DownIF ahi) downif ∧ ASIF (UpIF ahi) upif ∧ uinfo = ε⟧ ⟹ ?P; ⋀uy_ uz_ va_. ⟦?x = ε; ?xa = uy_; ?xb = uz_; ?xc = va_⟧ ⟹ ?P; ⋀v uy_ uz_ va_. ⟦?x = AS v; ?xa = uy_; ?xb = uz_; ?xc = va_⟧ ⟹ ?P; ⋀v uy_ uz_ va_. ⟦?x = Key v; ?xa = uy_; ?xb = uz_; ?xc = va_⟧ ⟹ ?P; ⋀v uy_ uz_ va_. ⟦?x = Nonce v; ?xa = uy_; ?xb = uz_; ?xc = va_⟧ ⟹ ?P; ⋀v uy_ uz_ va_. ⟦?x = L v; ?xa = uy_; ?xb = uz_; ?xc = va_⟧ ⟹ ?P; ⋀v uy_ uz_ va_. ⟦?x = FS v; ?xa = uy_; ?xb = uz_; ?xc = va_⟧ ⟹ ?P; ⋀v vb uy_ uz_ va_. ⟦?x = ⟨v, vb⟩; ?xa = uy_; ?xb = uz_; ?xc = va_⟧ ⟹ ?P; ⋀v uy_ uz_ va_. ⟦?x = Hash v; ?xa = uy_; ?xb = uz_; ?xc = va_⟧ ⟹ ?P; ⋀v vb uy_ uz_ va_. ⟦?x = Crypt v vb; ?xa = uy_; ?xb = uz_; ?xc = va_⟧ ⟹ ?P; ⋀uy_ uz_. ⟦?x = ε; ?xa = uy_; ?xb = uz_; ?xc = None⟧ ⟹ ?P; ⋀v uy_ uz_. ⟦?x = AS v; ?xa = uy_; ?xb = uz_; ?xc = None⟧ ⟹ ?P; ⋀v uy_ uz_. ⟦?x = Key v; ?xa = uy_; ?xb = uz_; ?xc = None⟧ ⟹ ?P; ⋀v uy_ uz_. ⟦?x = Nonce v; ?xa = uy_; ?xb = uz_; ?xc = None⟧ ⟹ ?P; ⋀v uy_ uz_. ⟦?x = L v; ?xa = uy_; ?xb = uz_; ?xc = None⟧ ⟹ ?P; ⋀v uy_ uz_. ⟦?x = FS v; ?xa = uy_; ?xb = uz_; ?xc = None⟧ ⟹ ?P; ⋀v va uy_ uz_. ⟦?x = ⟨v, va⟩; ?xa = uy_; ?xb = uz_; ?xc = None⟧ ⟹ ?P; ⋀v uy_ uz_. ⟦?x = Hash v; ?xa = uy_; ?xb = uz_; ?xc = None⟧ ⟹ ?P; ⋀v va uy_ uz_. ⟦?x = Crypt v va; ?xa = uy_; ?xb = uz_; ?xc = None⟧ ⟹ ?P⟧ ⟹ ?P›*)) lemma hf_valid_auth_restrict[dest]: "hf_valid ainfo uinfo hf z ⟹ auth_restrict ainfo uinfo l" by (auto simp add: hf_valid_invert (*‹hf_valid ?tsn ?uinfo ?hf ?mo = ((∃ahi ahi2 ts upif downif asid x x2. ?hf = ⦇AHI = ahi, UHI = (), HVF = x⦈ ∧ ASID ahi = asid ∧ ASIF (DownIF ahi) downif ∧ ASIF (UpIF ahi) upif ∧ ?mo = Some ⦇AHI = ahi2, UHI = (), HVF = x2⦈ ∧ x = Mac[macKey asid] (L [?tsn, upif, downif, x2]) ∧ ?tsn = Num ts ∧ ?uinfo = ε) ∨ (∃ahi ts upif downif asid x. ?hf = ⦇AHI = ahi, UHI = (), HVF = x⦈ ∧ ASID ahi = asid ∧ ASIF (DownIF ahi) downif ∧ ASIF (UpIF ahi) upif ∧ ?mo = None ∧ x = Mac[macKey asid] (L [?tsn, upif, downif]) ∧ ?tsn = Num ts ∧ ?uinfo = ε))›*) auth_restrict_def (*‹auth_restrict ?ainfo ?uinfo ?l ≡ (∃ts. ?ainfo = Num ts) ∧ ?uinfo = ε›*)) lemma info_hvf: assumes "hf_valid ainfo uinfo m z" "hf_valid ainfo' uinfo' m' z'" "HVF m = HVF m'" shows "ainfo' = ainfo" "m' = m" using assms (*‹hf_valid ainfo uinfo m z› ‹hf_valid ainfo' uinfo' m' z'› ‹HVF m = HVF m'›*) apply - (*goals: 1. ‹⟦hf_valid ainfo uinfo m z; hf_valid ainfo' uinfo' m' z'; HVF m = HVF m'⟧ ⟹ ainfo' = ainfo› 2. ‹⟦hf_valid ainfo uinfo m z; hf_valid ainfo' uinfo' m' z'; HVF m = HVF m'⟧ ⟹ m' = m› discuss goal 1*) apply ((auto simp add: hf_valid_invert (*‹hf_valid (?tsn::msgterm) (?uinfo::msgterm) (?hf::(unit, unit) HF) (?mo::(unit, unit) HF option) = ((∃(ahi::ahi) (ahi2::ahi) (ts::nat) (upif::msgterm) (downif::msgterm) (asid::nat) (x::msgterm) x2::msgterm. ?hf = ⦇AHI = ahi, UHI = (), HVF = x⦈ ∧ ASID ahi = asid ∧ ASIF (DownIF ahi) downif ∧ ASIF (UpIF ahi) upif ∧ ?mo = Some ⦇AHI = ahi2, UHI = (), HVF = x2⦈ ∧ x = Mac[macKey asid] (L [?tsn, upif, downif, x2]) ∧ ?tsn = Num ts ∧ ?uinfo = ε) ∨ (∃(ahi::ahi) (ts::nat) (upif::msgterm) (downif::msgterm) (asid::nat) x::msgterm. ?hf = ⦇AHI = ahi, UHI = (), HVF = x⦈ ∧ ASID ahi = asid ∧ ASIF (DownIF ahi) downif ∧ ASIF (UpIF ahi) upif ∧ ?mo = None ∧ x = Mac[macKey asid] (L [?tsn, upif, downif]) ∧ ?tsn = Num ts ∧ ?uinfo = ε))›*) intro: ahi_eq (*‹⟦ASID (?ahi'::ahi) = ASID (?ahi::ahi); ASIF (DownIF ?ahi') (?downif::msgterm); ASIF (UpIF ?ahi') (?upif::msgterm); ASIF (DownIF ?ahi) ?downif; ASIF (UpIF ?ahi) ?upif⟧ ⟹ ?ahi = ?ahi'›*))[1]) (*discuss goal 2*) apply ((auto simp add: hf_valid_invert (*‹hf_valid (?tsn::msgterm) (?uinfo::msgterm) (?hf::(unit, unit) HF) (?mo::(unit, unit) HF option) = ((∃(ahi::ahi) (ahi2::ahi) (ts::nat) (upif::msgterm) (downif::msgterm) (asid::nat) (x::msgterm) x2::msgterm. ?hf = ⦇AHI = ahi, UHI = (), HVF = x⦈ ∧ ASID ahi = asid ∧ ASIF (DownIF ahi) downif ∧ ASIF (UpIF ahi) upif ∧ ?mo = Some ⦇AHI = ahi2, UHI = (), HVF = x2⦈ ∧ x = Mac[macKey asid] (L [?tsn, upif, downif, x2]) ∧ ?tsn = Num ts ∧ ?uinfo = ε) ∨ (∃(ahi::ahi) (ts::nat) (upif::msgterm) (downif::msgterm) (asid::nat) x::msgterm. ?hf = ⦇AHI = ahi, UHI = (), HVF = x⦈ ∧ ASID ahi = asid ∧ ASIF (DownIF ahi) downif ∧ ASIF (UpIF ahi) upif ∧ ?mo = None ∧ x = Mac[macKey asid] (L [?tsn, upif, downif]) ∧ ?tsn = Num ts ∧ ?uinfo = ε))›*) intro: ahi_eq (*‹⟦ASID (?ahi'::ahi) = ASID (?ahi::ahi); ASIF (DownIF ?ahi') (?downif::msgterm); ASIF (UpIF ?ahi') (?upif::msgterm); ASIF (DownIF ?ahi) ?downif; ASIF (UpIF ?ahi) ?upif⟧ ⟹ ?ahi = ?ahi'›*))[1]) (*proven 2 subgoals*) . (******************************************************************************) subsection‹Definitions and properties of the added intruder knowledge› (******************************************************************************) text‹Here we define a @{text "ik_add"} and @{text "ik_oracle"} as being empty, as these features are not used in this instance model.› print_locale dataplane_3_directed_defs sublocale dataplane_3_directed_defs _ _ _ auth_seg0 hf_valid auth_restrict extr extr_ainfo term_ainfo terms_hf terms_uinfo upd_uinfo no_oracle by unfold_locales declare TWu.holds_set_list[dest] declare TWu.holds_takeW_is_identity[simp] declare parts_singleton[dest] abbreviation ik_add :: "msgterm set" where "ik_add ≡ {}" abbreviation ik_oracle :: "msgterm set" where "ik_oracle ≡ {}" (******************************************************************************) subsection‹Properties of the intruder knowledge, including @{text "ik_add"} and @{text "ik_oracle"}› (******************************************************************************) text‹We now instantiate the parametrized model's definition of the intruder knowledge, using the definitions of @{text "ik_add"} and @{text "ik_oracle"} from above. We then prove the properties that we need to instantiate the @{text "dataplane_3_directed"} locale.› sublocale dataplane_3_directed_ik_defs _ _ _ auth_seg0 terms_uinfo no_oracle hf_valid auth_restrict extr extr_ainfo term_ainfo terms_hf upd_uinfo ik_add ik_oracle by unfold_locales lemma auth_ainfo[dest]: "⟦(ainfo, hfs) ∈ auth_seg2 uinfo⟧ ⟹ ∃ ts . ainfo = Num ts" by (auto simp add: auth_seg2_def (*‹auth_seg2 ?uinfo ≡ {(ainfo, l) |ainfo l. hfs_valid_prefix_generic ainfo ?uinfo [] None l None = l ∧ auth_restrict ainfo ?uinfo l ∧ True ∧ (ainfo, AHIS l) ∈ auth_seg0}›*) auth_restrict_def (*‹auth_restrict ?ainfo ?uinfo ?l ≡ (∃ts. ?ainfo = Num ts) ∧ ?uinfo = ε›*)) lemma auth_uinfo[dest]: "⟦(ainfo, hfs) ∈ auth_seg2 uinfo⟧ ⟹ uinfo = ε" by (auto simp add: auth_seg2_def (*‹auth_seg2 ?uinfo ≡ {(ainfo, l) |ainfo l. hfs_valid_prefix_generic ainfo ?uinfo [] None l None = l ∧ auth_restrict ainfo ?uinfo l ∧ True ∧ (ainfo, AHIS l) ∈ auth_seg0}›*) auth_restrict_def (*‹auth_restrict ?ainfo ?uinfo ?l ≡ (∃ts. ?ainfo = Num ts) ∧ ?uinfo = ε›*)) lemma upds_simp[simp]: "TWu.upds upd_uinfo uinfo hfs = uinfo" apply (induction hfs) (*goals: 1. ‹upds_uinfo uinfo [] = uinfo› 2. ‹⋀a hfs. upds_uinfo uinfo hfs = uinfo ⟹ upds_uinfo uinfo (a # hfs) = uinfo› discuss goal 1*) apply ((auto simp add: upd_uinfo_def (*‹upd_uinfo (?uinfo::msgterm) (?hf::(unit, unit) HF) ≡ ?uinfo›*))[1]) (*discuss goal 2*) apply ((auto simp add: upd_uinfo_def (*‹upd_uinfo ?uinfo ?hf ≡ ?uinfo›*))[1]) (*proven 2 subgoals*) . lemma upd_shifted_simp[simp]: "TWu.upd_shifted upd_uinfo uinfo hfs nxt = uinfo" apply (induction hfs) (*goals: 1. ‹upds_uinfo_shifted uinfo [] nxt = uinfo› 2. ‹⋀a hfs. upds_uinfo_shifted uinfo hfs nxt = uinfo ⟹ upds_uinfo_shifted uinfo (a # hfs) nxt = uinfo› discuss goal 1*) apply ((auto simp only: TWu.upd_shifted.simps (*‹TWu.upd_shifted ?upd ?uinfo (?x # ?xs) ?nxt = foldl ?upd ?uinfo (?xs @ [?nxt])› ‹TWu.upd_shifted ?upd ?uinfo [] ?nxt = ?uinfo›*) upds_simp (*‹upds_uinfo ?uinfo ?hfs = ?uinfo›*))[1]) (*discuss goal 2*) apply ((auto simp only: TWu.upd_shifted.simps (*‹TWu.upd_shifted ?upd ?uinfo (?x # ?xs) ?nxt = foldl ?upd ?uinfo (?xs @ [?nxt])› ‹TWu.upd_shifted ?upd ?uinfo [] ?nxt = ?uinfo›*) upds_simp (*‹upds_uinfo ?uinfo ?hfs = ?uinfo›*))[1]) (*proven 2 subgoals*) . lemma ik_hfs_form: "t ∈ parts ik_hfs ⟹ ∃ t' . t = Hash t'" by (auto 3 4 simp add: auth_seg2_def (*‹auth_seg2 ?uinfo ≡ {(ainfo, l) |ainfo l. hfs_valid_prefix_generic ainfo ?uinfo [] None l None = l ∧ auth_restrict ainfo ?uinfo l ∧ True ∧ (ainfo, AHIS l) ∈ auth_seg0}›*) hf_valid_invert (*‹hf_valid ?tsn ?uinfo ?hf ?mo = ((∃ahi ahi2 ts upif downif asid x x2. ?hf = ⦇AHI = ahi, UHI = (), HVF = x⦈ ∧ ASID ahi = asid ∧ ASIF (DownIF ahi) downif ∧ ASIF (UpIF ahi) upif ∧ ?mo = Some ⦇AHI = ahi2, UHI = (), HVF = x2⦈ ∧ x = Mac[macKey asid] (L [?tsn, upif, downif, x2]) ∧ ?tsn = Num ts ∧ ?uinfo = ε) ∨ (∃ahi ts upif downif asid x. ?hf = ⦇AHI = ahi, UHI = (), HVF = x⦈ ∧ ASID ahi = asid ∧ ASIF (DownIF ahi) downif ∧ ASIF (UpIF ahi) upif ∧ ?mo = None ∧ x = Mac[macKey asid] (L [?tsn, upif, downif]) ∧ ?tsn = Num ts ∧ ?uinfo = ε))›*)) declare ik_hfs_def[simp del] lemma parts_ik_hfs[simp]: "parts ik_hfs = ik_hfs" by (auto intro!: parts_Hash (*‹(⋀t::msgterm. t ∈ (?H::msgterm set) ⟹ ∃t'::msgterm. t = Hash t') ⟹ parts ?H = ?H›*) ik_hfs_form (*‹(?t::msgterm) ∈ parts ik_hfs ⟹ ∃t'::msgterm. ?t = Hash t'›*)) text‹This lemma allows us not only to expand the definition of @{term "ik_hfs"}, but also to obtain useful properties, such as a term being a Hash, and it being part of a valid hop field.› lemma ik_hfs_simp: "t ∈ ik_hfs ⟷ (∃t' . t = Hash t') ∧ (∃hf . t = HVF hf ∧ (∃hfs. hf ∈ set hfs ∧ (∃ainfo . (ainfo, hfs) ∈ (auth_seg2 ε) ∧ (∃ nxt. hf_valid ainfo ε hf nxt))))" (is "?lhs ⟷ ?rhs") proof (standard) (*goals: 1. ‹t ∈ ik_hfs ⟹ (∃t'. t = Hash t') ∧ (∃hf. t = HVF hf ∧ (∃hfs. hf ∈ set hfs ∧ (∃ainfo. (ainfo, hfs) ∈ auth_seg2 ε ∧ (∃nxt. hf_valid ainfo ε hf nxt))))› 2. ‹(∃t'. t = Hash t') ∧ (∃hf. t = HVF hf ∧ (∃hfs. hf ∈ set hfs ∧ (∃ainfo. (ainfo, hfs) ∈ auth_seg2 ε ∧ (∃nxt. hf_valid ainfo ε hf nxt)))) ⟹ t ∈ ik_hfs›*) assume asm: "?lhs" (*‹(t::msgterm) ∈ ik_hfs›*) then obtain ainfo and uinfo and hf and hfs where dfs: "hf ∈ set hfs" "(ainfo, hfs) ∈ auth_seg2 uinfo" "t = HVF hf" (*goal: ‹(⋀hf hfs ainfo uinfo. ⟦hf ∈ set hfs; (ainfo, hfs) ∈ auth_seg2 uinfo; t = HVF hf⟧ ⟹ thesis) ⟹ thesis›*) by (auto simp add: ik_hfs_def (*‹ik_hfs = {uu_. ∃t hf hfs ainfo uinfo. uu_ = t ∧ t ∈ terms_hf hf ∧ hf ∈ set hfs ∧ (ainfo, hfs) ∈ auth_seg2 uinfo}›*)) then have dfs_prop: "hfs_valid_None ainfo ε hfs" "(ainfo, AHIS hfs) ∈ auth_seg0" using auth_uinfo (*‹(?ainfo, ?hfs) ∈ auth_seg2 ?uinfo ⟹ ?uinfo = ε›*) apply - (*goals: 1. ‹⟦hf ∈ set hfs; (ainfo, hfs) ∈ auth_seg2 uinfo; t = HVF hf; ⋀ainfo hfs uinfo. (ainfo, hfs) ∈ auth_seg2 uinfo ⟹ uinfo = ε⟧ ⟹ hfs_valid_None ainfo ε hfs› 2. ‹⟦hf ∈ set hfs; (ainfo, hfs) ∈ auth_seg2 uinfo; t = HVF hf; ⋀ainfo hfs uinfo. (ainfo, hfs) ∈ auth_seg2 uinfo ⟹ uinfo = ε⟧ ⟹ (ainfo, AHIS hfs) ∈ auth_seg0› discuss goal 1*) apply ((auto simp add: auth_seg2_def (*‹auth_seg2 ?uinfo ≡ {(ainfo, l) |ainfo l. hfs_valid_prefix_generic ainfo ?uinfo [] None l None = l ∧ auth_restrict ainfo ?uinfo l ∧ True ∧ (ainfo, AHIS l) ∈ auth_seg0}›*))[1]) (*discuss goal 2*) apply ((auto simp add: auth_seg2_def (*‹auth_seg2 ?uinfo ≡ {(ainfo, l) |ainfo l. hfs_valid_prefix_generic ainfo ?uinfo [] None l None = l ∧ auth_restrict ainfo ?uinfo l ∧ True ∧ (ainfo, AHIS l) ∈ auth_seg0}›*))[1]) (*proven 2 subgoals*) . then obtain nxt where hf_val: "hf_valid ainfo ε hf nxt" (*goal: ‹(⋀nxt. hf_valid ainfo ε hf nxt ⟹ thesis) ⟹ thesis›*) using dfs (*‹hf ∈ set hfs› ‹(ainfo, hfs) ∈ auth_seg2 uinfo› ‹(t::msgterm) = HVF (hf::(unit, unit) HF)›*) apply auto (*goal: ‹(⋀nxt. hf_valid ainfo ε hf nxt ⟹ thesis) ⟹ thesis›*) by (auto dest: TWu.holds_set_list_no_update (*‹⟦TWu.holds (?P::?'b::type ⇒ ?'a::type ⇒ ?'a::type option ⇒ bool) (?upd::?'b::type ⇒ ?'a::type ⇒ ?'b::type) (?info::?'b::type) (?l::?'a::type list) (?nxt::?'a::type option); (?x::?'a::type) ∈ set ?l; ⋀(a::?'b::type) b::?'a::type. ?upd a b = a⟧ ⟹ ∃y::?'a::type option. ?P ?info ?x y›*) simp add: upd_uinfo_def (*‹upd_uinfo (?uinfo::msgterm) (?hf::(unit, unit) HF) ≡ ?uinfo›*)) then show "?rhs" using asm (*‹t ∈ ik_hfs›*) dfs (*‹hf ∈ set hfs› ‹(ainfo, hfs) ∈ auth_seg2 uinfo› ‹t = HVF hf›*) dfs_prop (*‹hfs_valid_None (ainfo::msgterm) ε (hfs::(unit, unit) HF list)› ‹(ainfo, AHIS hfs) ∈ auth_seg0›*) hf_val (*‹hf_valid ainfo ε hf nxt›*) by (auto intro: ik_hfs_form (*‹?t ∈ parts ik_hfs ⟹ ∃t'. ?t = Hash t'›*)) qed (auto simp add: ik_hfs_def (*‹ik_hfs = {uu_::msgterm. ∃(t::msgterm) (hf::(unit, unit) HF) (hfs::(unit, unit) HF list) (ainfo::msgterm) uinfo::msgterm. uu_ = t ∧ t ∈ terms_hf hf ∧ hf ∈ set hfs ∧ (ainfo, hfs) ∈ auth_seg2 uinfo}›*)) (*solved the remaining goal: ‹(∃t'. t = Hash t') ∧ (∃hf. t = HVF hf ∧ (∃hfs. hf ∈ set hfs ∧ (∃ainfo. (ainfo, hfs) ∈ auth_seg2 ε ∧ (∃nxt. hf_valid ainfo ε hf nxt)))) ⟹ t ∈ ik_hfs›*) (******************************************************************************) subsubsection ‹Properties of Intruder Knowledge› (******************************************************************************) lemma Num_ik[intro]: "Num ts ∈ ik" apply (auto simp add: ik_def (*‹ik = ik_hfs ∪ {uu_. ∃ainfo hfs uinfo. uu_ = id ainfo ∧ (ainfo, hfs) ∈ auth_seg2 uinfo} ∪ ik_uinfo ∪ Key ` macK ` bad ∪ {} ∪ {}›*)) (*goal: ‹Num ts ∈ ik›*) by (auto simp add: auth_seg2_def (*‹auth_seg2 ?uinfo ≡ {(ainfo, l) |ainfo l. hfs_valid_prefix_generic ainfo ?uinfo [] None l None = l ∧ auth_restrict ainfo ?uinfo l ∧ True ∧ (ainfo, AHIS l) ∈ auth_seg0}›*) auth_restrict_def (*‹auth_restrict ?ainfo ?uinfo ?l ≡ (∃ts. ?ainfo = Num ts) ∧ ?uinfo = ε›*) TWu.holds.simps (*‹TWu.holds ?P ?upd ?info (?x # ?y # ?ys) ?nxt = (?P ?info ?x (Some ?y) ∧ TWu.holds ?P ?upd (?upd ?info ?y) (?y # ?ys) ?nxt)› ‹TWu.holds ?P ?upd ?info [?x] ?nxt = ?P ?info ?x ?nxt› ‹TWu.holds ?P ?upd ?info [] ?nxt = True›*) intro!: exI[of _ "[]"] (*‹?P [] ⟹ ∃x. ?P x›*) exI[of _ "ε"] (*‹?P ε ⟹ ∃x. ?P x›*)) (*elim!: allE[of _ "[]"]) *) text ‹There are no ciphertexts (or signatures) in @{term "parts ik"}. Thus, @{term "analz ik"} and @{term "parts ik"} are identical.› lemma analz_parts_ik[simp]: "analz ik = parts ik" apply (rule no_crypt_analz_is_parts (*‹∄(K::key) X::msgterm. Crypt K X ∈ parts (?A::msgterm set) ⟹ analz ?A = parts ?A›*)) (*goal: ‹analz ik = parts ik›*) by (auto simp add: ik_def (*‹ik = ik_hfs ∪ {uu_. ∃ainfo hfs uinfo. uu_ = id ainfo ∧ (ainfo, hfs) ∈ auth_seg2 uinfo} ∪ ik_uinfo ∪ Key ` macK ` bad ∪ {} ∪ {}›*) auth_seg2_def (*‹auth_seg2 ?uinfo ≡ {(ainfo, l) |ainfo l. hfs_valid_prefix_generic ainfo ?uinfo [] None l None = l ∧ auth_restrict ainfo ?uinfo l ∧ True ∧ (ainfo, AHIS l) ∈ auth_seg0}›*) ik_hfs_simp (*‹(?t ∈ ik_hfs) = ((∃t'. ?t = Hash t') ∧ (∃hf. ?t = HVF hf ∧ (∃hfs. hf ∈ set hfs ∧ (∃ainfo. (ainfo, hfs) ∈ auth_seg2 ε ∧ (∃nxt. hf_valid ainfo ε hf nxt)))))›*) auth_restrict_def (*‹auth_restrict ?ainfo ?uinfo ?l ≡ (∃ts. ?ainfo = Num ts) ∧ ?uinfo = ε›*)) lemma parts_ik[simp]: "parts ik = ik" by (fastforce simp add: ik_def (*‹ik = ik_hfs ∪ {uu_. ∃ainfo hfs uinfo. uu_ = id ainfo ∧ (ainfo, hfs) ∈ auth_seg2 uinfo} ∪ ik_uinfo ∪ Key ` macK ` bad ∪ {} ∪ {}›*) auth_seg2_def (*‹auth_seg2 ?uinfo ≡ {(ainfo, l) |ainfo l. hfs_valid_prefix_generic ainfo ?uinfo [] None l None = l ∧ auth_restrict ainfo ?uinfo l ∧ True ∧ (ainfo, AHIS l) ∈ auth_seg0}›*) auth_restrict_def (*‹auth_restrict ?ainfo ?uinfo ?l ≡ (∃ts. ?ainfo = Num ts) ∧ ?uinfo = ε›*)) lemma key_ik_bad: "Key (macK asid) ∈ ik ⟹ asid ∈ bad" apply (auto simp add: ik_def (*‹ik = ik_hfs ∪ {uu_. ∃ainfo hfs uinfo. uu_ = id ainfo ∧ (ainfo, hfs) ∈ auth_seg2 uinfo} ∪ ik_uinfo ∪ Key ` macK ` bad ∪ {} ∪ {}›*) hf_valid_invert (*‹hf_valid ?tsn ?uinfo ?hf ?mo = ((∃ahi ahi2 ts upif downif asid x x2. ?hf = ⦇AHI = ahi, UHI = (), HVF = x⦈ ∧ ASID ahi = asid ∧ ASIF (DownIF ahi) downif ∧ ASIF (UpIF ahi) upif ∧ ?mo = Some ⦇AHI = ahi2, UHI = (), HVF = x2⦈ ∧ x = Mac[macKey asid] (L [?tsn, upif, downif, x2]) ∧ ?tsn = Num ts ∧ ?uinfo = ε) ∨ (∃ahi ts upif downif asid x. ?hf = ⦇AHI = ahi, UHI = (), HVF = x⦈ ∧ ASID ahi = asid ∧ ASIF (DownIF ahi) downif ∧ ASIF (UpIF ahi) upif ∧ ?mo = None ∧ x = Mac[macKey asid] (L [?tsn, upif, downif]) ∧ ?tsn = Num ts ∧ ?uinfo = ε))›*)) (*goal: ‹macKey asid ∈ ik ⟹ asid ∈ bad›*) by (auto 3 4 simp add: auth_seg2_def (*‹auth_seg2 ?uinfo ≡ {(ainfo, l) |ainfo l. hfs_valid_prefix_generic ainfo ?uinfo [] None l None = l ∧ auth_restrict ainfo ?uinfo l ∧ True ∧ (ainfo, AHIS l) ∈ auth_seg0}›*) ik_hfs_simp (*‹(?t ∈ ik_hfs) = ((∃t'. ?t = Hash t') ∧ (∃hf. ?t = HVF hf ∧ (∃hfs. hf ∈ set hfs ∧ (∃ainfo. (ainfo, hfs) ∈ auth_seg2 ε ∧ (∃nxt. hf_valid ainfo ε hf nxt)))))›*) hf_valid_invert (*‹hf_valid ?tsn ?uinfo ?hf ?mo = ((∃ahi ahi2 ts upif downif asid x x2. ?hf = ⦇AHI = ahi, UHI = (), HVF = x⦈ ∧ ASID ahi = asid ∧ ASIF (DownIF ahi) downif ∧ ASIF (UpIF ahi) upif ∧ ?mo = Some ⦇AHI = ahi2, UHI = (), HVF = x2⦈ ∧ x = Mac[macKey asid] (L [?tsn, upif, downif, x2]) ∧ ?tsn = Num ts ∧ ?uinfo = ε) ∨ (∃ahi ts upif downif asid x. ?hf = ⦇AHI = ahi, UHI = (), HVF = x⦈ ∧ ASID ahi = asid ∧ ASIF (DownIF ahi) downif ∧ ASIF (UpIF ahi) upif ∧ ?mo = None ∧ x = Mac[macKey asid] (L [?tsn, upif, downif]) ∧ ?tsn = Num ts ∧ ?uinfo = ε))›*)) lemma MAC_synth_helper: assumes "hf_valid ainfo uinfo m z" "HVF m = Mac[Key (macK asid)] j" "HVF m ∈ ik" shows "∃hfs. m ∈ set hfs ∧ (∃uinfo'. (ainfo, hfs) ∈ auth_seg2 uinfo')" proof (-) (*goal: ‹∃hfs. m ∈ set hfs ∧ (∃uinfo'. (ainfo, hfs) ∈ auth_seg2 uinfo')›*) from assms(2-3) (*‹HVF m = Mac[macKey asid] j› ‹HVF m ∈ ik›*) obtain ainfo' and uinfo' and m' and hfs' and nxt' where dfs: "m' ∈ set hfs'" "(ainfo', hfs') ∈ auth_seg2 uinfo'" "hf_valid ainfo' uinfo' m' nxt'" "HVF m = HVF m'" (*goal: ‹(⋀m' hfs' ainfo' uinfo' nxt'. ⟦m' ∈ set hfs'; (ainfo', hfs') ∈ auth_seg2 uinfo'; hf_valid ainfo' uinfo' m' nxt'; HVF m = HVF m'⟧ ⟹ thesis) ⟹ thesis›*) by (auto simp add: ik_def (*‹ik = ik_hfs ∪ {uu_. ∃ainfo hfs uinfo. uu_ = id ainfo ∧ (ainfo, hfs) ∈ auth_seg2 uinfo} ∪ ik_uinfo ∪ Key ` macK ` bad ∪ {} ∪ {}›*) ik_hfs_simp (*‹(?t ∈ ik_hfs) = ((∃t'. ?t = Hash t') ∧ (∃hf. ?t = HVF hf ∧ (∃hfs. hf ∈ set hfs ∧ (∃ainfo. (ainfo, hfs) ∈ auth_seg2 ε ∧ (∃nxt. hf_valid ainfo ε hf nxt)))))›*)) then have "ainfo' = ainfo" "m' = m" using assms(1) (*‹hf_valid (ainfo::msgterm) (uinfo::msgterm) (m::(unit, unit) HF) (z::(unit, unit) HF option)›*) apply - (*goals: 1. ‹⟦(m'::(unit, unit) HF) ∈ set (hfs'::(unit, unit) HF list); (ainfo'::msgterm, hfs') ∈ auth_seg2 (uinfo'::msgterm); hf_valid ainfo' uinfo' m' (nxt'::(unit, unit) HF option); HVF (m::(unit, unit) HF) = HVF m'; hf_valid (ainfo::msgterm) (uinfo::msgterm) m (z::(unit, unit) HF option)⟧ ⟹ ainfo' = ainfo› 2. ‹⟦(m'::(unit, unit) HF) ∈ set (hfs'::(unit, unit) HF list); (ainfo'::msgterm, hfs') ∈ auth_seg2 (uinfo'::msgterm); hf_valid ainfo' uinfo' m' (nxt'::(unit, unit) HF option); HVF (m::(unit, unit) HF) = HVF m'; hf_valid (ainfo::msgterm) (uinfo::msgterm) m (z::(unit, unit) HF option)⟧ ⟹ m' = m› discuss goal 1*) apply ((auto elim!: info_hvf (*‹⟦hf_valid ?ainfo ?uinfo ?m ?z; hf_valid ?ainfo' ?uinfo' ?m' ?z'; HVF ?m = HVF ?m'⟧ ⟹ ?ainfo' = ?ainfo› ‹⟦hf_valid ?ainfo ?uinfo ?m ?z; hf_valid ?ainfo' ?uinfo' ?m' ?z'; HVF ?m = HVF ?m'⟧ ⟹ ?m' = ?m›*))[1]) (*discuss goal 2*) apply ((auto elim!: info_hvf (*‹⟦hf_valid ?ainfo ?uinfo ?m ?z; hf_valid ?ainfo' ?uinfo' ?m' ?z'; HVF ?m = HVF ?m'⟧ ⟹ ?ainfo' = ?ainfo› ‹⟦hf_valid ?ainfo ?uinfo ?m ?z; hf_valid ?ainfo' ?uinfo' ?m' ?z'; HVF ?m = HVF ?m'⟧ ⟹ ?m' = ?m›*))[1]) (*proven 2 subgoals*) . then show "?thesis" (*goal: ‹∃hfs. m ∈ set hfs ∧ (∃uinfo'. (ainfo, hfs) ∈ auth_seg2 uinfo')›*) using dfs (*‹m' ∈ set hfs'› ‹(ainfo'::msgterm, hfs'::(unit, unit) HF list) ∈ auth_seg2 (uinfo'::msgterm)› ‹hf_valid ainfo' uinfo' m' nxt'› ‹HVF m = HVF m'›*) assms (*‹hf_valid ainfo uinfo m z› ‹HVF m = Mac[macKey asid] j› ‹HVF m ∈ ik›*) by auto qed text‹This definition helps with the limiting the number of cases generated. We don't require it, but it is convenient. Given a hop validation field and an asid, return if the hvf has the expected format.› definition mac_format :: "msgterm ⇒ as ⇒ bool" where "mac_format m asid ≡ ∃ j . m = Mac[macKey asid] j" text‹If a valid hop field is derivable by the attacker, but does not belong to the attacker, then the hop field is already contained in the set of authorized segments.› lemma MAC_synth: assumes "hf_valid ainfo uinfo m z" "HVF m ∈ synth ik" "mac_format (HVF m) asid" "asid ∉ bad" "checkInfo ainfo" shows "∃hfs . m ∈ set hfs ∧ (∃uinfo'. (ainfo, hfs) ∈ auth_seg2 uinfo')" using assms (*‹hf_valid (ainfo::msgterm) (uinfo::msgterm) (m::(unit, unit) HF) (z::(unit, unit) HF option)› ‹HVF m ∈ synth ik› ‹mac_format (HVF m) asid› ‹asid ∉ bad› ‹checkInfo ainfo›*) apply (auto simp add: mac_format_def (*‹mac_format ?m ?asid ≡ ∃j. ?m = Mac[macKey ?asid] j›*) elim!: MAC_synth_helper (*‹⟦hf_valid ?ainfo ?uinfo ?m ?z; HVF ?m = Mac[macKey ?asid] ?j; HVF ?m ∈ ik⟧ ⟹ ∃hfs. ?m ∈ set hfs ∧ (∃uinfo'. (?ainfo, hfs) ∈ auth_seg2 uinfo')›*) dest!: key_ik_bad (*‹macKey ?asid ∈ ik ⟹ ?asid ∈ bad›*)) (*goal: ‹∃hfs. m ∈ set hfs ∧ (∃uinfo'. (ainfo, hfs) ∈ auth_seg2 uinfo')›*) by (auto simp add: ik_def (*‹ik = ik_hfs ∪ {uu_. ∃ainfo hfs uinfo. uu_ = id ainfo ∧ (ainfo, hfs) ∈ auth_seg2 uinfo} ∪ ik_uinfo ∪ Key ` macK ` bad ∪ {} ∪ {}›*) ik_hfs_simp (*‹(?t ∈ ik_hfs) = ((∃t'. ?t = Hash t') ∧ (∃hf. ?t = HVF hf ∧ (∃hfs. hf ∈ set hfs ∧ (∃ainfo. (ainfo, hfs) ∈ auth_seg2 ε ∧ (∃nxt. hf_valid ainfo ε hf nxt)))))›*)) (******************************************************************************) subsection‹Direct proof goals for interpretation of @{text "dataplane_3_directed"}› (******************************************************************************) lemma COND_honest_hf_analz: assumes "ASID (AHI hf) ∉ bad" "hf_valid ainfo uinfo hf nxt" "terms_hf hf ⊆ synth (analz ik)" "no_oracle ainfo uinfo" shows "terms_hf hf ⊆ analz ik" proof (-) (*goal: ‹terms_hf (hf::(unit, unit) HF) ⊆ analz ik›*) let ?asid = "ASID (AHI hf)" from assms(3) (*‹terms_hf hf ⊆ synth (analz ik)›*) have hf_synth_ik: "HVF hf ∈ synth ik" by auto from assms(2) (*‹hf_valid ainfo uinfo hf nxt›*) have "mac_format (HVF hf) ?asid" by (auto simp add: mac_format_def (*‹mac_format ?m ?asid ≡ ∃j. ?m = Mac[macKey ?asid] j›*) hf_valid_invert (*‹hf_valid ?tsn ?uinfo ?hf ?mo = ((∃ahi ahi2 ts upif downif asid x x2. ?hf = ⦇AHI = ahi, UHI = (), HVF = x⦈ ∧ ASID ahi = asid ∧ ASIF (DownIF ahi) downif ∧ ASIF (UpIF ahi) upif ∧ ?mo = Some ⦇AHI = ahi2, UHI = (), HVF = x2⦈ ∧ x = Mac[macKey asid] (L [?tsn, upif, downif, x2]) ∧ ?tsn = Num ts ∧ ?uinfo = ε) ∨ (∃ahi ts upif downif asid x. ?hf = ⦇AHI = ahi, UHI = (), HVF = x⦈ ∧ ASID ahi = asid ∧ ASIF (DownIF ahi) downif ∧ ASIF (UpIF ahi) upif ∧ ?mo = None ∧ x = Mac[macKey asid] (L [?tsn, upif, downif]) ∧ ?tsn = Num ts ∧ ?uinfo = ε))›*)) then obtain hfs and uinfo' where "hf ∈ set hfs" "(ainfo, hfs) ∈ auth_seg2 uinfo'" (*goal: ‹(⋀hfs uinfo'. ⟦hf ∈ set hfs; (ainfo, hfs) ∈ auth_seg2 uinfo'⟧ ⟹ thesis) ⟹ thesis›*) using assms(1,2) (*‹ASID (AHI hf) ∉ bad› ‹hf_valid (ainfo::msgterm) (uinfo::msgterm) (hf::(unit, unit) HF) (nxt::(unit, unit) HF option)›*) hf_synth_ik (*‹HVF (hf::(unit, unit) HF) ∈ synth ik›*) by (auto dest!: MAC_synth (*‹⟦hf_valid ?ainfo ?uinfo ?m ?z; HVF ?m ∈ synth ik; mac_format (HVF ?m) ?asid; ?asid ∉ bad; ?checkInfo ?ainfo⟧ ⟹ ∃hfs. ?m ∈ set hfs ∧ (∃uinfo'. (?ainfo, hfs) ∈ auth_seg2 uinfo')›*)) then have "HVF hf ∈ ik" using assms(2) (*‹hf_valid ainfo uinfo hf nxt›*) by (auto simp add: ik_hfs_def (*‹ik_hfs = {uu_. ∃t hf hfs ainfo uinfo. uu_ = t ∧ t ∈ terms_hf hf ∧ hf ∈ set hfs ∧ (ainfo, hfs) ∈ auth_seg2 uinfo}›*) intro!: ik_ik_hfs (*‹?t ∈ ik_hfs ⟹ ?t ∈ ik›*) intro!: exI (*‹?P ?x ⟹ ∃x. ?P x›*)) then show "?thesis" (*goal: ‹terms_hf hf ⊆ analz ik›*) by auto qed lemma COND_terms_hf: assumes "hf_valid ainfo uinfo hf z" and "terms_hf hf ⊆ analz ik" and "no_oracle ainfo uinfo" shows "∃hfs. hf ∈ set hfs ∧ (∃uinfo' . (ainfo, hfs) ∈ auth_seg2 uinfo')" proof (-) (*goal: ‹∃hfs. hf ∈ set hfs ∧ (∃uinfo'. (ainfo, hfs) ∈ auth_seg2 uinfo')›*) obtain hfs and ainfo and uinfo where hfs_def: "hf ∈ set hfs" "(ainfo, hfs) ∈ auth_seg2 uinfo" (*goal: ‹(⋀hfs ainfo uinfo. ⟦hf ∈ set hfs; (ainfo, hfs) ∈ auth_seg2 uinfo⟧ ⟹ thesis) ⟹ thesis›*) using assms (*‹hf_valid ainfo uinfo hf z› ‹terms_hf hf ⊆ analz ik› ‹True›*) using assms (*‹hf_valid (ainfo::msgterm) (uinfo::msgterm) (hf::(unit, unit) HF) (z::(unit, unit) HF option)› ‹terms_hf hf ⊆ analz ik› ‹True›*) apply simp (*goal: ‹(⋀hfs ainfo uinfo. ⟦hf ∈ set hfs; (ainfo, hfs) ∈ auth_seg2 uinfo⟧ ⟹ thesis) ⟹ thesis›*) by (auto 3 4 simp add: hf_valid_invert (*‹hf_valid ?tsn ?uinfo ?hf ?mo = ((∃ahi ahi2 ts upif downif asid x x2. ?hf = ⦇AHI = ahi, UHI = (), HVF = x⦈ ∧ ASID ahi = asid ∧ ASIF (DownIF ahi) downif ∧ ASIF (UpIF ahi) upif ∧ ?mo = Some ⦇AHI = ahi2, UHI = (), HVF = x2⦈ ∧ x = Mac[macKey asid] (L [?tsn, upif, downif, x2]) ∧ ?tsn = Num ts ∧ ?uinfo = ε) ∨ (∃ahi ts upif downif asid x. ?hf = ⦇AHI = ahi, UHI = (), HVF = x⦈ ∧ ASID ahi = asid ∧ ASIF (DownIF ahi) downif ∧ ASIF (UpIF ahi) upif ∧ ?mo = None ∧ x = Mac[macKey asid] (L [?tsn, upif, downif]) ∧ ?tsn = Num ts ∧ ?uinfo = ε))›*) ik_hfs_simp (*‹(?t ∈ ik_hfs) = ((∃t'. ?t = Hash t') ∧ (∃hf. ?t = HVF hf ∧ (∃hfs. hf ∈ set hfs ∧ (∃ainfo. (ainfo, hfs) ∈ auth_seg2 ε ∧ (∃nxt. hf_valid ainfo ε hf nxt)))))›*) ik_def (*‹ik = ik_hfs ∪ {uu_. ∃ainfo hfs uinfo. uu_ = id ainfo ∧ (ainfo, hfs) ∈ auth_seg2 uinfo} ∪ ik_uinfo ∪ Key ` macK ` bad ∪ {} ∪ {}›*) dest: ahi_eq (*‹⟦ASID ?ahi' = ASID ?ahi; ASIF (DownIF ?ahi') ?downif; ASIF (UpIF ?ahi') ?upif; ASIF (DownIF ?ahi) ?downif; ASIF (UpIF ?ahi) ?upif⟧ ⟹ ?ahi = ?ahi'›*)) show "?thesis" (*goal: ‹∃hfs::(unit, unit) HF list. (hf::(unit, unit) HF) ∈ set hfs ∧ (∃uinfo'::msgterm. (ainfo::msgterm, hfs) ∈ auth_seg2 uinfo')›*) using hfs_def (*‹hf ∈ set hfs› ‹(ainfo, hfs) ∈ auth_seg2 uinfo›*) apply (auto simp add: auth_seg2_def (*‹auth_seg2 ?uinfo ≡ {(ainfo, l) |ainfo l. hfs_valid_prefix_generic ainfo ?uinfo [] None l None = l ∧ auth_restrict ainfo ?uinfo l ∧ True ∧ (ainfo, AHIS l) ∈ auth_seg0}›*) dest!: TWu.holds_set_list (*‹⟦TWu.holds ?P ?upd ?info ?l ?nxt; ?x ∈ set ?l⟧ ⟹ ∃p y. ?P p ?x y›*)) (*goal: ‹∃hfs. hf ∈ set hfs ∧ (∃uinfo'. (ainfo, hfs) ∈ auth_seg2 uinfo')›*) using hfs_def (*‹hf ∈ set hfs› ‹(ainfo, hfs) ∈ auth_seg2 uinfo›*) assms(1) (*‹hf_valid ainfo uinfo hf z›*) by (auto simp add: auth_seg2_def (*‹auth_seg2 ?uinfo ≡ {(ainfo, l) |ainfo l. hfs_valid_prefix_generic ainfo ?uinfo [] None l None = l ∧ auth_restrict ainfo ?uinfo l ∧ True ∧ (ainfo, AHIS l) ∈ auth_seg0}›*) dest: info_hvf (*‹⟦hf_valid ?ainfo ?uinfo ?m ?z; hf_valid ?ainfo' ?uinfo' ?m' ?z'; HVF ?m = HVF ?m'⟧ ⟹ ?ainfo' = ?ainfo› ‹⟦hf_valid ?ainfo ?uinfo ?m ?z; hf_valid ?ainfo' ?uinfo' ?m' ?z'; HVF ?m = HVF ?m'⟧ ⟹ ?m' = ?m›*)) qed lemma COND_extr_prefix_path: "⟦hfs_valid ainfo uinfo l nxt; nxt = None⟧ ⟹ prefix (extr_from_hd l) (AHIS l)" apply (induction l nxt rule: TWu.holds.induct[where ?upd=upd_uinfo] (*‹⟦⋀info x y ys nxt. ?P (upd_uinfo info y) (y # ys) nxt ⟹ ?P info (x # y # ys) nxt; ⋀info x nxt. ?P info [x] nxt; ⋀info nxt. ?P info [] nxt⟧ ⟹ ?P ?a0.0 ?a1.0 ?a2.0›*)) (*goals: 1. ‹⋀(info::msgterm) (x::(unit, unit) HF) (y::(unit, unit) HF) (ys::(unit, unit) HF list) nxt::(unit, unit) HF option. ⟦⟦hfs_valid (ainfo::msgterm) (upd_uinfo info y) (y # ys) nxt; nxt = None⟧ ⟹ prefix (extr_from_hd (y # ys)) (AHIS (y # ys)); hfs_valid ainfo info (x # y # ys) nxt; nxt = None⟧ ⟹ prefix (extr_from_hd (x # y # ys)) (AHIS (x # y # ys))› 2. ‹⋀(info::msgterm) (x::(unit, unit) HF) nxt::(unit, unit) HF option. ⟦hfs_valid (ainfo::msgterm) info [x] nxt; nxt = None⟧ ⟹ prefix (extr_from_hd [x]) (AHIS [x])› 3. ‹⋀(info::msgterm) nxt::(unit, unit) HF option. ⟦hfs_valid (ainfo::msgterm) info [] nxt; nxt = None⟧ ⟹ prefix (extr_from_hd []) (AHIS [])› discuss goal 1*) apply ((auto simp add: TWu.holds_split_tail (*‹TWu.holds ?P ?upd ?info (?x # ?xs) ?nxt = (case ?xs of [] ⇒ ?P ?info ?x ?nxt | y # ys ⇒ ?P ?info ?x (Some y) ∧ TWu.holds ?P ?upd (?upd ?info y) (y # ys) ?nxt)›*) TWu.holds.simps( (*‹TWu.holds ?P ?upd ?info (?x # ?y # ?ys) ?nxt = (?P ?info ?x (Some ?y) ∧ TWu.holds ?P ?upd (?upd ?info ?y) (?y # ?ys) ?nxt)›*) 1) hf_valid_invert (*‹hf_valid ?tsn ?uinfo ?hf ?mo = ((∃ahi ahi2 ts upif downif asid x x2. ?hf = ⦇AHI = ahi, UHI = (), HVF = x⦈ ∧ ASID ahi = asid ∧ ASIF (DownIF ahi) downif ∧ ASIF (UpIF ahi) upif ∧ ?mo = Some ⦇AHI = ahi2, UHI = (), HVF = x2⦈ ∧ x = Mac[macKey asid] (L [?tsn, upif, downif, x2]) ∧ ?tsn = Num ts ∧ ?uinfo = ε) ∨ (∃ahi ts upif downif asid x. ?hf = ⦇AHI = ahi, UHI = (), HVF = x⦈ ∧ ASID ahi = asid ∧ ASIF (DownIF ahi) downif ∧ ASIF (UpIF ahi) upif ∧ ?mo = None ∧ x = Mac[macKey asid] (L [?tsn, upif, downif]) ∧ ?tsn = Num ts ∧ ?uinfo = ε))›*))[1]) (*top goal: ‹⋀(info::msgterm) (x::(unit, unit) HF) (y::(unit, unit) HF) (ys::(unit, unit) HF list) nxt::(unit, unit) HF option. ⟦⟦hfs_valid (ainfo::msgterm) (upd_uinfo info y) (y # ys) nxt; nxt = None⟧ ⟹ prefix (extr_from_hd (y # ys)) (AHIS (y # ys)); hfs_valid ainfo info (x # y # ys) nxt; nxt = None⟧ ⟹ prefix (extr_from_hd (x # y # ys)) (AHIS (x # y # ys))› and 2 goals remain*) apply ((auto split: list.split_asm (*‹?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))))›*) simp add: hf_valid_invert (*‹hf_valid ?tsn ?uinfo ?hf ?mo = ((∃ahi ahi2 ts upif downif asid x x2. ?hf = ⦇AHI = ahi, UHI = (), HVF = x⦈ ∧ ASID ahi = asid ∧ ASIF (DownIF ahi) downif ∧ ASIF (UpIF ahi) upif ∧ ?mo = Some ⦇AHI = ahi2, UHI = (), HVF = x2⦈ ∧ x = Mac[macKey asid] (L [?tsn, upif, downif, x2]) ∧ ?tsn = Num ts ∧ ?uinfo = ε) ∨ (∃ahi ts upif downif asid x. ?hf = ⦇AHI = ahi, UHI = (), HVF = x⦈ ∧ ASID ahi = asid ∧ ASIF (DownIF ahi) downif ∧ ASIF (UpIF ahi) upif ∧ ?mo = None ∧ x = Mac[macKey asid] (L [?tsn, upif, downif]) ∧ ?tsn = Num ts ∧ ?uinfo = ε))›*) intro!: ahi_eq (*‹⟦ASID ?ahi' = ASID ?ahi; ASIF (DownIF ?ahi') ?downif; ASIF (UpIF ?ahi') ?upif; ASIF (DownIF ?ahi) ?downif; ASIF (UpIF ?ahi) ?upif⟧ ⟹ ?ahi = ?ahi'›*) elim: ASIF.elims (*‹⟦ASIF ?x ?xa = ?y; ⋀a a'. ⟦?x = Some a; ?xa = AS a'; ?y = (a = a')⟧ ⟹ ?P; ⟦?x = None; ?xa = ε; ?y⟧ ⟹ ?P; ⋀v. ⟦?x = None; ?xa = AS v; ¬ ?y⟧ ⟹ ?P; ⋀v. ⟦?x = None; ?xa = Num v; ¬ ?y⟧ ⟹ ?P; ⋀v. ⟦?x = None; ?xa = Key v; ¬ ?y⟧ ⟹ ?P; ⋀v. ⟦?x = None; ?xa = Nonce v; ¬ ?y⟧ ⟹ ?P; ⋀v. ⟦?x = None; ?xa = L v; ¬ ?y⟧ ⟹ ?P; ⋀v. ⟦?x = None; ?xa = FS v; ¬ ?y⟧ ⟹ ?P; ⋀v va. ⟦?x = None; ?xa = ⟨v, va⟩; ¬ ?y⟧ ⟹ ?P; ⋀v. ⟦?x = None; ?xa = Hash v; ¬ ?y⟧ ⟹ ?P; ⋀v va. ⟦?x = None; ?xa = Crypt v va; ¬ ?y⟧ ⟹ ?P; ⋀v. ⟦?x = Some v; ?xa = ε; ¬ ?y⟧ ⟹ ?P; ⋀uu_ v. ⟦?x = uu_; ?xa = Num v; ¬ ?y⟧ ⟹ ?P; ⋀uu_ v. ⟦?x = uu_; ?xa = Key v; ¬ ?y⟧ ⟹ ?P; ⋀uu_ v. ⟦?x = uu_; ?xa = Nonce v; ¬ ?y⟧ ⟹ ?P; ⋀uu_ v. ⟦?x = uu_; ?xa = L v; ¬ ?y⟧ ⟹ ?P; ⋀uu_ v. ⟦?x = uu_; ?xa = FS v; ¬ ?y⟧ ⟹ ?P; ⋀uu_ v va. ⟦?x = uu_; ?xa = ⟨v, va⟩; ¬ ?y⟧ ⟹ ?P; ⋀uu_ v. ⟦?x = uu_; ?xa = Hash v; ¬ ?y⟧ ⟹ ?P; ⋀uu_ v va. ⟦?x = uu_; ?xa = Crypt v va; ¬ ?y⟧ ⟹ ?P⟧ ⟹ ?P› ‹⟦ASIF ?x ?xa; ⋀a a'. ⟦?x = Some a; ?xa = AS a'; a = a'⟧ ⟹ ?P; ⟦?x = None; ?xa = ε⟧ ⟹ ?P⟧ ⟹ ?P› ‹⟦¬ ASIF ?x ?xa; ⋀a a'. ⟦?x = Some a; ?xa = AS a'; a ≠ a'⟧ ⟹ ?P; ⋀v. ⟦?x = None; ?xa = AS v⟧ ⟹ ?P; ⋀v. ⟦?x = None; ?xa = Num v⟧ ⟹ ?P; ⋀v. ⟦?x = None; ?xa = Key v⟧ ⟹ ?P; ⋀v. ⟦?x = None; ?xa = Nonce v⟧ ⟹ ?P; ⋀v. ⟦?x = None; ?xa = L v⟧ ⟹ ?P; ⋀v. ⟦?x = None; ?xa = FS v⟧ ⟹ ?P; ⋀v va. ⟦?x = None; ?xa = ⟨v, va⟩⟧ ⟹ ?P; ⋀v. ⟦?x = None; ?xa = Hash v⟧ ⟹ ?P; ⋀v va. ⟦?x = None; ?xa = Crypt v va⟧ ⟹ ?P; ⋀v. ⟦?x = Some v; ?xa = ε⟧ ⟹ ?P; ⋀uu_ v. ⟦?x = uu_; ?xa = Num v⟧ ⟹ ?P; ⋀uu_ v. ⟦?x = uu_; ?xa = Key v⟧ ⟹ ?P; ⋀uu_ v. ⟦?x = uu_; ?xa = Nonce v⟧ ⟹ ?P; ⋀uu_ v. ⟦?x = uu_; ?xa = L v⟧ ⟹ ?P; ⋀uu_ v. ⟦?x = uu_; ?xa = FS v⟧ ⟹ ?P; ⋀uu_ v va. ⟦?x = uu_; ?xa = ⟨v, va⟩⟧ ⟹ ?P; ⋀uu_ v. ⟦?x = uu_; ?xa = Hash v⟧ ⟹ ?P; ⋀uu_ v va. ⟦?x = uu_; ?xa = Crypt v va⟧ ⟹ ?P⟧ ⟹ ?P›*))[1]) (*discuss goal 2*) apply ((auto simp add: TWu.holds_split_tail (*‹TWu.holds ?P ?upd ?info (?x # ?xs) ?nxt = (case ?xs of [] ⇒ ?P ?info ?x ?nxt | y # ys ⇒ ?P ?info ?x (Some y) ∧ TWu.holds ?P ?upd (?upd ?info y) (y # ys) ?nxt)›*) TWu.holds.simps( (*‹TWu.holds ?P ?upd ?info (?x # ?y # ?ys) ?nxt = (?P ?info ?x (Some ?y) ∧ TWu.holds ?P ?upd (?upd ?info ?y) (?y # ?ys) ?nxt)›*) 1) hf_valid_invert (*‹hf_valid ?tsn ?uinfo ?hf ?mo = ((∃ahi ahi2 ts upif downif asid x x2. ?hf = ⦇AHI = ahi, UHI = (), HVF = x⦈ ∧ ASID ahi = asid ∧ ASIF (DownIF ahi) downif ∧ ASIF (UpIF ahi) upif ∧ ?mo = Some ⦇AHI = ahi2, UHI = (), HVF = x2⦈ ∧ x = Mac[macKey asid] (L [?tsn, upif, downif, x2]) ∧ ?tsn = Num ts ∧ ?uinfo = ε) ∨ (∃ahi ts upif downif asid x. ?hf = ⦇AHI = ahi, UHI = (), HVF = x⦈ ∧ ASID ahi = asid ∧ ASIF (DownIF ahi) downif ∧ ASIF (UpIF ahi) upif ∧ ?mo = None ∧ x = Mac[macKey asid] (L [?tsn, upif, downif]) ∧ ?tsn = Num ts ∧ ?uinfo = ε))›*))[1]) (*top goal: ‹⋀(info::msgterm) (x::(unit, unit) HF) nxt::(unit, unit) HF option. ⟦hfs_valid (ainfo::msgterm) info [x] nxt; nxt = None⟧ ⟹ prefix (extr_from_hd [x]) (AHIS [x])› and 1 goal remains*) apply ((auto split: list.split_asm (*‹(?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))))›*) simp add: hf_valid_invert (*‹hf_valid (?tsn::msgterm) (?uinfo::msgterm) (?hf::(unit, unit) HF) (?mo::(unit, unit) HF option) = ((∃(ahi::ahi) (ahi2::ahi) (ts::nat) (upif::msgterm) (downif::msgterm) (asid::nat) (x::msgterm) x2::msgterm. ?hf = ⦇AHI = ahi, UHI = (), HVF = x⦈ ∧ ASID ahi = asid ∧ ASIF (DownIF ahi) downif ∧ ASIF (UpIF ahi) upif ∧ ?mo = Some ⦇AHI = ahi2, UHI = (), HVF = x2⦈ ∧ x = Mac[macKey asid] (L [?tsn, upif, downif, x2]) ∧ ?tsn = Num ts ∧ ?uinfo = ε) ∨ (∃(ahi::ahi) (ts::nat) (upif::msgterm) (downif::msgterm) (asid::nat) x::msgterm. ?hf = ⦇AHI = ahi, UHI = (), HVF = x⦈ ∧ ASID ahi = asid ∧ ASIF (DownIF ahi) downif ∧ ASIF (UpIF ahi) upif ∧ ?mo = None ∧ x = Mac[macKey asid] (L [?tsn, upif, downif]) ∧ ?tsn = Num ts ∧ ?uinfo = ε))›*) intro!: ahi_eq (*‹⟦ASID (?ahi'::ahi) = ASID (?ahi::ahi); ASIF (DownIF ?ahi') (?downif::msgterm); ASIF (UpIF ?ahi') (?upif::msgterm); ASIF (DownIF ?ahi) ?downif; ASIF (UpIF ?ahi) ?upif⟧ ⟹ ?ahi = ?ahi'›*) elim: ASIF.elims (*‹⟦ASIF (?x::nat option) (?xa::msgterm) = (?y::bool); ⋀(a::nat) a'::nat. ⟦?x = Some a; ?xa = AS a'; ?y = (a = a')⟧ ⟹ ?P::bool; ⟦?x = None; ?xa = ε; ?y⟧ ⟹ ?P; ⋀v::nat. ⟦?x = None; ?xa = AS v; ¬ ?y⟧ ⟹ ?P; ⋀v::nat. ⟦?x = None; ?xa = Num v; ¬ ?y⟧ ⟹ ?P; ⋀v::key. ⟦?x = None; ?xa = Key v; ¬ ?y⟧ ⟹ ?P; ⋀v::fresh_t. ⟦?x = None; ?xa = Nonce v; ¬ ?y⟧ ⟹ ?P; ⋀v::msgterm list. ⟦?x = None; ?xa = L v; ¬ ?y⟧ ⟹ ?P; ⋀v::msgterm fset. ⟦?x = None; ?xa = FS v; ¬ ?y⟧ ⟹ ?P; ⋀(v::msgterm) va::msgterm. ⟦?x = None; ?xa = ⟨v, va⟩; ¬ ?y⟧ ⟹ ?P; ⋀v::msgterm. ⟦?x = None; ?xa = Hash v; ¬ ?y⟧ ⟹ ?P; ⋀(v::key) va::msgterm. ⟦?x = None; ?xa = Crypt v va; ¬ ?y⟧ ⟹ ?P; ⋀v::nat. ⟦?x = Some v; ?xa = ε; ¬ ?y⟧ ⟹ ?P; ⋀(uu_::nat option) v::nat. ⟦?x = uu_; ?xa = Num v; ¬ ?y⟧ ⟹ ?P; ⋀(uu_::nat option) v::key. ⟦?x = uu_; ?xa = Key v; ¬ ?y⟧ ⟹ ?P; ⋀(uu_::nat option) v::fresh_t. ⟦?x = uu_; ?xa = Nonce v; ¬ ?y⟧ ⟹ ?P; ⋀(uu_::nat option) v::msgterm list. ⟦?x = uu_; ?xa = L v; ¬ ?y⟧ ⟹ ?P; ⋀(uu_::nat option) v::msgterm fset. ⟦?x = uu_; ?xa = FS v; ¬ ?y⟧ ⟹ ?P; ⋀(uu_::nat option) (v::msgterm) va::msgterm. ⟦?x = uu_; ?xa = ⟨v, va⟩; ¬ ?y⟧ ⟹ ?P; ⋀(uu_::nat option) v::msgterm. ⟦?x = uu_; ?xa = Hash v; ¬ ?y⟧ ⟹ ?P; ⋀(uu_::nat option) (v::key) va::msgterm. ⟦?x = uu_; ?xa = Crypt v va; ¬ ?y⟧ ⟹ ?P⟧ ⟹ ?P› ‹⟦ASIF (?x::nat option) (?xa::msgterm); ⋀(a::nat) a'::nat. ⟦?x = Some a; ?xa = AS a'; a = a'⟧ ⟹ ?P::bool; ⟦?x = None; ?xa = ε⟧ ⟹ ?P⟧ ⟹ ?P› ‹⟦¬ ASIF (?x::nat option) (?xa::msgterm); ⋀(a::nat) a'::nat. ⟦?x = Some a; ?xa = AS a'; a ≠ a'⟧ ⟹ ?P::bool; ⋀v::nat. ⟦?x = None; ?xa = AS v⟧ ⟹ ?P; ⋀v::nat. ⟦?x = None; ?xa = Num v⟧ ⟹ ?P; ⋀v::key. ⟦?x = None; ?xa = Key v⟧ ⟹ ?P; ⋀v::fresh_t. ⟦?x = None; ?xa = Nonce v⟧ ⟹ ?P; ⋀v::msgterm list. ⟦?x = None; ?xa = L v⟧ ⟹ ?P; ⋀v::msgterm fset. ⟦?x = None; ?xa = FS v⟧ ⟹ ?P; ⋀(v::msgterm) va::msgterm. ⟦?x = None; ?xa = ⟨v, va⟩⟧ ⟹ ?P; ⋀v::msgterm. ⟦?x = None; ?xa = Hash v⟧ ⟹ ?P; ⋀(v::key) va::msgterm. ⟦?x = None; ?xa = Crypt v va⟧ ⟹ ?P; ⋀v::nat. ⟦?x = Some v; ?xa = ε⟧ ⟹ ?P; ⋀(uu_::nat option) v::nat. ⟦?x = uu_; ?xa = Num v⟧ ⟹ ?P; ⋀(uu_::nat option) v::key. ⟦?x = uu_; ?xa = Key v⟧ ⟹ ?P; ⋀(uu_::nat option) v::fresh_t. ⟦?x = uu_; ?xa = Nonce v⟧ ⟹ ?P; ⋀(uu_::nat option) v::msgterm list. ⟦?x = uu_; ?xa = L v⟧ ⟹ ?P; ⋀(uu_::nat option) v::msgterm fset. ⟦?x = uu_; ?xa = FS v⟧ ⟹ ?P; ⋀(uu_::nat option) (v::msgterm) va::msgterm. ⟦?x = uu_; ?xa = ⟨v, va⟩⟧ ⟹ ?P; ⋀(uu_::nat option) v::msgterm. ⟦?x = uu_; ?xa = Hash v⟧ ⟹ ?P; ⋀(uu_::nat option) (v::key) va::msgterm. ⟦?x = uu_; ?xa = Crypt v va⟧ ⟹ ?P⟧ ⟹ ?P›*))[1]) (*discuss goal 3*) apply ((auto simp add: TWu.holds_split_tail (*‹TWu.holds ?P ?upd ?info (?x # ?xs) ?nxt = (case ?xs of [] ⇒ ?P ?info ?x ?nxt | y # ys ⇒ ?P ?info ?x (Some y) ∧ TWu.holds ?P ?upd (?upd ?info y) (y # ys) ?nxt)›*) TWu.holds.simps( (*‹TWu.holds ?P ?upd ?info (?x # ?y # ?ys) ?nxt = (?P ?info ?x (Some ?y) ∧ TWu.holds ?P ?upd (?upd ?info ?y) (?y # ?ys) ?nxt)›*) 1) hf_valid_invert (*‹hf_valid ?tsn ?uinfo ?hf ?mo = ((∃ahi ahi2 ts upif downif asid x x2. ?hf = ⦇AHI = ahi, UHI = (), HVF = x⦈ ∧ ASID ahi = asid ∧ ASIF (DownIF ahi) downif ∧ ASIF (UpIF ahi) upif ∧ ?mo = Some ⦇AHI = ahi2, UHI = (), HVF = x2⦈ ∧ x = Mac[macKey asid] (L [?tsn, upif, downif, x2]) ∧ ?tsn = Num ts ∧ ?uinfo = ε) ∨ (∃ahi ts upif downif asid x. ?hf = ⦇AHI = ahi, UHI = (), HVF = x⦈ ∧ ASID ahi = asid ∧ ASIF (DownIF ahi) downif ∧ ASIF (UpIF ahi) upif ∧ ?mo = None ∧ x = Mac[macKey asid] (L [?tsn, upif, downif]) ∧ ?tsn = Num ts ∧ ?uinfo = ε))›*))[1]) (*proven 3 subgoals*) . lemma COND_path_prefix_extr: "prefix (AHIS (hfs_valid_prefix ainfo uinfo l nxt)) (extr_from_hd l)" apply (induction l nxt rule: TWu.takeW.induct[where ?Pa="hf_valid ainfo",where ?upd=upd_uinfo] (*‹⟦⋀uu_ uv_. ?P uu_ [] uv_; ⋀info x xo. hf_valid ainfo info x xo ⟹ ?P info [x] xo; ⋀info x xo. ¬ hf_valid ainfo info x xo ⟹ ?P info [x] xo; ⋀info x y xs xo. ⟦hf_valid ainfo info x (Some y); ?P (upd_uinfo info y) (y # xs) xo⟧ ⟹ ?P info (x # y # xs) xo; ⋀info x y xs xo. ¬ hf_valid ainfo info x (Some y) ⟹ ?P info (x # y # xs) xo⟧ ⟹ ?P ?a0.0 ?a1.0 ?a2.0›*)) (*goals: 1. ‹⋀(uu_::msgterm) uv_::(unit, unit) HF option. prefix (AHIS (hfs_valid_prefix (ainfo::msgterm) uu_ [] uv_)) (extr_from_hd [])› 2. ‹⋀(info::msgterm) (x::(unit, unit) HF) xo::(unit, unit) HF option. hf_valid (ainfo::msgterm) info x xo ⟹ prefix (AHIS (hfs_valid_prefix ainfo info [x] xo)) (extr_from_hd [x])› 3. ‹⋀(info::msgterm) (x::(unit, unit) HF) xo::(unit, unit) HF option. ¬ hf_valid (ainfo::msgterm) info x xo ⟹ prefix (AHIS (hfs_valid_prefix ainfo info [x] xo)) (extr_from_hd [x])› 4. ‹⋀(info::msgterm) (x::(unit, unit) HF) (y::(unit, unit) HF) (xs::(unit, unit) HF list) xo::(unit, unit) HF option. ⟦hf_valid (ainfo::msgterm) info x (Some y); prefix (AHIS (hfs_valid_prefix ainfo (upd_uinfo info y) (y # xs) xo)) (extr_from_hd (y # xs))⟧ ⟹ prefix (AHIS (hfs_valid_prefix ainfo info (x # y # xs) xo)) (extr_from_hd (x # y # xs))› 5. ‹⋀(info::msgterm) (x::(unit, unit) HF) (y::(unit, unit) HF) (xs::(unit, unit) HF list) xo::(unit, unit) HF option. ¬ hf_valid (ainfo::msgterm) info x (Some y) ⟹ prefix (AHIS (hfs_valid_prefix ainfo info (x # y # xs) xo)) (extr_from_hd (x # y # xs))› discuss goal 1*) apply ((auto simp add: TWu.takeW_split_tail (*‹TWu.takeW ?P ?upd ?info (?x # ?xs) ?nxt = (if ?xs = [] then if ?P ?info ?x ?nxt then [?x] else [] else if ?P ?info ?x (Some (hd ?xs)) then ?x # TWu.takeW ?P ?upd (?upd ?info (hd ?xs)) ?xs ?nxt else [])›*) TWu.takeW.simps( (*‹TWu.takeW ?P ?upd ?uu [] ?uv = []›*) 1))[1]) (*discuss goal 2*) apply ((auto simp add: TWu.takeW_split_tail (*‹TWu.takeW ?P ?upd ?info (?x # ?xs) ?nxt = (if ?xs = [] then if ?P ?info ?x ?nxt then [?x] else [] else if ?P ?info ?x (Some (hd ?xs)) then ?x # TWu.takeW ?P ?upd (?upd ?info (hd ?xs)) ?xs ?nxt else [])›*) TWu.takeW.simps( (*‹TWu.takeW ?P ?upd ?uu [] ?uv = []›*) 1))[1]) (*top goal: ‹⋀info x xo. hf_valid ainfo info x xo ⟹ prefix (AHIS (hfs_valid_prefix ainfo info [x] xo)) (extr_from_hd [x])› and 3 goals remain*) apply ((auto 3 4 simp add: hf_valid_invert (*‹hf_valid ?tsn ?uinfo ?hf ?mo = ((∃ahi ahi2 ts upif downif asid x x2. ?hf = ⦇AHI = ahi, UHI = (), HVF = x⦈ ∧ ASID ahi = asid ∧ ASIF (DownIF ahi) downif ∧ ASIF (UpIF ahi) upif ∧ ?mo = Some ⦇AHI = ahi2, UHI = (), HVF = x2⦈ ∧ x = Mac[macKey asid] (L [?tsn, upif, downif, x2]) ∧ ?tsn = Num ts ∧ ?uinfo = ε) ∨ (∃ahi ts upif downif asid x. ?hf = ⦇AHI = ahi, UHI = (), HVF = x⦈ ∧ ASID ahi = asid ∧ ASIF (DownIF ahi) downif ∧ ASIF (UpIF ahi) upif ∧ ?mo = None ∧ x = Mac[macKey asid] (L [?tsn, upif, downif]) ∧ ?tsn = Num ts ∧ ?uinfo = ε))›*) intro!: ahi_eq (*‹⟦ASID ?ahi' = ASID ?ahi; ASIF (DownIF ?ahi') ?downif; ASIF (UpIF ?ahi') ?upif; ASIF (DownIF ?ahi) ?downif; ASIF (UpIF ?ahi) ?upif⟧ ⟹ ?ahi = ?ahi'›*) elim: ASIF.elims (*‹⟦ASIF ?x ?xa = ?y; ⋀a a'. ⟦?x = Some a; ?xa = AS a'; ?y = (a = a')⟧ ⟹ ?P; ⟦?x = None; ?xa = ε; ?y⟧ ⟹ ?P; ⋀v. ⟦?x = None; ?xa = AS v; ¬ ?y⟧ ⟹ ?P; ⋀v. ⟦?x = None; ?xa = Num v; ¬ ?y⟧ ⟹ ?P; ⋀v. ⟦?x = None; ?xa = Key v; ¬ ?y⟧ ⟹ ?P; ⋀v. ⟦?x = None; ?xa = Nonce v; ¬ ?y⟧ ⟹ ?P; ⋀v. ⟦?x = None; ?xa = L v; ¬ ?y⟧ ⟹ ?P; ⋀v. ⟦?x = None; ?xa = FS v; ¬ ?y⟧ ⟹ ?P; ⋀v va. ⟦?x = None; ?xa = ⟨v, va⟩; ¬ ?y⟧ ⟹ ?P; ⋀v. ⟦?x = None; ?xa = Hash v; ¬ ?y⟧ ⟹ ?P; ⋀v va. ⟦?x = None; ?xa = Crypt v va; ¬ ?y⟧ ⟹ ?P; ⋀v. ⟦?x = Some v; ?xa = ε; ¬ ?y⟧ ⟹ ?P; ⋀uu_ v. ⟦?x = uu_; ?xa = Num v; ¬ ?y⟧ ⟹ ?P; ⋀uu_ v. ⟦?x = uu_; ?xa = Key v; ¬ ?y⟧ ⟹ ?P; ⋀uu_ v. ⟦?x = uu_; ?xa = Nonce v; ¬ ?y⟧ ⟹ ?P; ⋀uu_ v. ⟦?x = uu_; ?xa = L v; ¬ ?y⟧ ⟹ ?P; ⋀uu_ v. ⟦?x = uu_; ?xa = FS v; ¬ ?y⟧ ⟹ ?P; ⋀uu_ v va. ⟦?x = uu_; ?xa = ⟨v, va⟩; ¬ ?y⟧ ⟹ ?P; ⋀uu_ v. ⟦?x = uu_; ?xa = Hash v; ¬ ?y⟧ ⟹ ?P; ⋀uu_ v va. ⟦?x = uu_; ?xa = Crypt v va; ¬ ?y⟧ ⟹ ?P⟧ ⟹ ?P› ‹⟦ASIF ?x ?xa; ⋀a a'. ⟦?x = Some a; ?xa = AS a'; a = a'⟧ ⟹ ?P; ⟦?x = None; ?xa = ε⟧ ⟹ ?P⟧ ⟹ ?P› ‹⟦¬ ASIF ?x ?xa; ⋀a a'. ⟦?x = Some a; ?xa = AS a'; a ≠ a'⟧ ⟹ ?P; ⋀v. ⟦?x = None; ?xa = AS v⟧ ⟹ ?P; ⋀v. ⟦?x = None; ?xa = Num v⟧ ⟹ ?P; ⋀v. ⟦?x = None; ?xa = Key v⟧ ⟹ ?P; ⋀v. ⟦?x = None; ?xa = Nonce v⟧ ⟹ ?P; ⋀v. ⟦?x = None; ?xa = L v⟧ ⟹ ?P; ⋀v. ⟦?x = None; ?xa = FS v⟧ ⟹ ?P; ⋀v va. ⟦?x = None; ?xa = ⟨v, va⟩⟧ ⟹ ?P; ⋀v. ⟦?x = None; ?xa = Hash v⟧ ⟹ ?P; ⋀v va. ⟦?x = None; ?xa = Crypt v va⟧ ⟹ ?P; ⋀v. ⟦?x = Some v; ?xa = ε⟧ ⟹ ?P; ⋀uu_ v. ⟦?x = uu_; ?xa = Num v⟧ ⟹ ?P; ⋀uu_ v. ⟦?x = uu_; ?xa = Key v⟧ ⟹ ?P; ⋀uu_ v. ⟦?x = uu_; ?xa = Nonce v⟧ ⟹ ?P; ⋀uu_ v. ⟦?x = uu_; ?xa = L v⟧ ⟹ ?P; ⋀uu_ v. ⟦?x = uu_; ?xa = FS v⟧ ⟹ ?P; ⋀uu_ v va. ⟦?x = uu_; ?xa = ⟨v, va⟩⟧ ⟹ ?P; ⋀uu_ v. ⟦?x = uu_; ?xa = Hash v⟧ ⟹ ?P; ⋀uu_ v va. ⟦?x = uu_; ?xa = Crypt v va⟧ ⟹ ?P⟧ ⟹ ?P›*))[1]) (*discuss goal 3*) apply ((auto simp add: TWu.takeW_split_tail (*‹TWu.takeW ?P ?upd ?info (?x # ?xs) ?nxt = (if ?xs = [] then if ?P ?info ?x ?nxt then [?x] else [] else if ?P ?info ?x (Some (hd ?xs)) then ?x # TWu.takeW ?P ?upd (?upd ?info (hd ?xs)) ?xs ?nxt else [])›*) TWu.takeW.simps( (*‹TWu.takeW ?P ?upd ?uu [] ?uv = []›*) 1))[1]) (*discuss goal 4*) apply ((auto simp add: TWu.takeW_split_tail (*‹TWu.takeW ?P ?upd ?info (?x # ?xs) ?nxt = (if ?xs = [] then if ?P ?info ?x ?nxt then [?x] else [] else if ?P ?info ?x (Some (hd ?xs)) then ?x # TWu.takeW ?P ?upd (?upd ?info (hd ?xs)) ?xs ?nxt else [])›*) TWu.takeW.simps( (*‹TWu.takeW ?P ?upd ?uu [] ?uv = []›*) 1))[1]) (*goals: 1. ‹⋀info x y xo. ⟦hf_valid ainfo info x (Some y); hf_valid ainfo (upd_uinfo info y) y xo; prefix [AHI y] (extr (HVF y))⟧ ⟹ prefix [AHI x, AHI y] (extr (HVF x))› 2. ‹⋀info x y xo. ⟦hf_valid ainfo info x (Some y); ¬ hf_valid ainfo (upd_uinfo info y) y xo⟧ ⟹ prefix [AHI x] (extr (HVF x))› 3. ‹⋀info x y xs xo. ⟦hf_valid ainfo info x (Some y); xs ≠ []; hf_valid ainfo (upd_uinfo info y) y (Some (hd xs)); prefix (AHI y # map AHI (hfs_valid_prefix ainfo (upd_uinfo (upd_uinfo info y) (hd xs)) xs xo)) (extr (HVF y))⟧ ⟹ prefix (AHI x # AHI y # map AHI (hfs_valid_prefix ainfo (upd_uinfo (upd_uinfo info y) (hd xs)) xs xo)) (extr (HVF x))› 4. ‹⋀info x y xs. ⟦hf_valid ainfo info x (Some y); xs ≠ []; ¬ hf_valid ainfo (upd_uinfo info y) y (Some (hd xs))⟧ ⟹ prefix [AHI x] (extr (HVF x))› discuss goal 1*) apply ((auto 3 4 simp add: hf_valid_invert (*‹hf_valid (?tsn::msgterm) (?uinfo::msgterm) (?hf::(unit, unit) HF) (?mo::(unit, unit) HF option) = ((∃(ahi::ahi) (ahi2::ahi) (ts::nat) (upif::msgterm) (downif::msgterm) (asid::nat) (x::msgterm) x2::msgterm. ?hf = ⦇AHI = ahi, UHI = (), HVF = x⦈ ∧ ASID ahi = asid ∧ ASIF (DownIF ahi) downif ∧ ASIF (UpIF ahi) upif ∧ ?mo = Some ⦇AHI = ahi2, UHI = (), HVF = x2⦈ ∧ x = Mac[macKey asid] (L [?tsn, upif, downif, x2]) ∧ ?tsn = Num ts ∧ ?uinfo = ε) ∨ (∃(ahi::ahi) (ts::nat) (upif::msgterm) (downif::msgterm) (asid::nat) x::msgterm. ?hf = ⦇AHI = ahi, UHI = (), HVF = x⦈ ∧ ASID ahi = asid ∧ ASIF (DownIF ahi) downif ∧ ASIF (UpIF ahi) upif ∧ ?mo = None ∧ x = Mac[macKey asid] (L [?tsn, upif, downif]) ∧ ?tsn = Num ts ∧ ?uinfo = ε))›*) intro!: ahi_eq (*‹⟦ASID (?ahi'::ahi) = ASID (?ahi::ahi); ASIF (DownIF ?ahi') (?downif::msgterm); ASIF (UpIF ?ahi') (?upif::msgterm); ASIF (DownIF ?ahi) ?downif; ASIF (UpIF ?ahi) ?upif⟧ ⟹ ?ahi = ?ahi'›*) elim: ASIF.elims (*‹⟦ASIF (?x::nat option) (?xa::msgterm) = (?y::bool); ⋀(a::nat) a'::nat. ⟦?x = Some a; ?xa = AS a'; ?y = (a = a')⟧ ⟹ ?P::bool; ⟦?x = None; ?xa = ε; ?y⟧ ⟹ ?P; ⋀v::nat. ⟦?x = None; ?xa = AS v; ¬ ?y⟧ ⟹ ?P; ⋀v::nat. ⟦?x = None; ?xa = Num v; ¬ ?y⟧ ⟹ ?P; ⋀v::key. ⟦?x = None; ?xa = Key v; ¬ ?y⟧ ⟹ ?P; ⋀v::fresh_t. ⟦?x = None; ?xa = Nonce v; ¬ ?y⟧ ⟹ ?P; ⋀v::msgterm list. ⟦?x = None; ?xa = L v; ¬ ?y⟧ ⟹ ?P; ⋀v::msgterm fset. ⟦?x = None; ?xa = FS v; ¬ ?y⟧ ⟹ ?P; ⋀(v::msgterm) va::msgterm. ⟦?x = None; ?xa = ⟨v, va⟩; ¬ ?y⟧ ⟹ ?P; ⋀v::msgterm. ⟦?x = None; ?xa = Hash v; ¬ ?y⟧ ⟹ ?P; ⋀(v::key) va::msgterm. ⟦?x = None; ?xa = Crypt v va; ¬ ?y⟧ ⟹ ?P; ⋀v::nat. ⟦?x = Some v; ?xa = ε; ¬ ?y⟧ ⟹ ?P; ⋀(uu_::nat option) v::nat. ⟦?x = uu_; ?xa = Num v; ¬ ?y⟧ ⟹ ?P; ⋀(uu_::nat option) v::key. ⟦?x = uu_; ?xa = Key v; ¬ ?y⟧ ⟹ ?P; ⋀(uu_::nat option) v::fresh_t. ⟦?x = uu_; ?xa = Nonce v; ¬ ?y⟧ ⟹ ?P; ⋀(uu_::nat option) v::msgterm list. ⟦?x = uu_; ?xa = L v; ¬ ?y⟧ ⟹ ?P; ⋀(uu_::nat option) v::msgterm fset. ⟦?x = uu_; ?xa = FS v; ¬ ?y⟧ ⟹ ?P; ⋀(uu_::nat option) (v::msgterm) va::msgterm. ⟦?x = uu_; ?xa = ⟨v, va⟩; ¬ ?y⟧ ⟹ ?P; ⋀(uu_::nat option) v::msgterm. ⟦?x = uu_; ?xa = Hash v; ¬ ?y⟧ ⟹ ?P; ⋀(uu_::nat option) (v::key) va::msgterm. ⟦?x = uu_; ?xa = Crypt v va; ¬ ?y⟧ ⟹ ?P⟧ ⟹ ?P› ‹⟦ASIF (?x::nat option) (?xa::msgterm); ⋀(a::nat) a'::nat. ⟦?x = Some a; ?xa = AS a'; a = a'⟧ ⟹ ?P::bool; ⟦?x = None; ?xa = ε⟧ ⟹ ?P⟧ ⟹ ?P› ‹⟦¬ ASIF (?x::nat option) (?xa::msgterm); ⋀(a::nat) a'::nat. ⟦?x = Some a; ?xa = AS a'; a ≠ a'⟧ ⟹ ?P::bool; ⋀v::nat. ⟦?x = None; ?xa = AS v⟧ ⟹ ?P; ⋀v::nat. ⟦?x = None; ?xa = Num v⟧ ⟹ ?P; ⋀v::key. ⟦?x = None; ?xa = Key v⟧ ⟹ ?P; ⋀v::fresh_t. ⟦?x = None; ?xa = Nonce v⟧ ⟹ ?P; ⋀v::msgterm list. ⟦?x = None; ?xa = L v⟧ ⟹ ?P; ⋀v::msgterm fset. ⟦?x = None; ?xa = FS v⟧ ⟹ ?P; ⋀(v::msgterm) va::msgterm. ⟦?x = None; ?xa = ⟨v, va⟩⟧ ⟹ ?P; ⋀v::msgterm. ⟦?x = None; ?xa = Hash v⟧ ⟹ ?P; ⋀(v::key) va::msgterm. ⟦?x = None; ?xa = Crypt v va⟧ ⟹ ?P; ⋀v::nat. ⟦?x = Some v; ?xa = ε⟧ ⟹ ?P; ⋀(uu_::nat option) v::nat. ⟦?x = uu_; ?xa = Num v⟧ ⟹ ?P; ⋀(uu_::nat option) v::key. ⟦?x = uu_; ?xa = Key v⟧ ⟹ ?P; ⋀(uu_::nat option) v::fresh_t. ⟦?x = uu_; ?xa = Nonce v⟧ ⟹ ?P; ⋀(uu_::nat option) v::msgterm list. ⟦?x = uu_; ?xa = L v⟧ ⟹ ?P; ⋀(uu_::nat option) v::msgterm fset. ⟦?x = uu_; ?xa = FS v⟧ ⟹ ?P; ⋀(uu_::nat option) (v::msgterm) va::msgterm. ⟦?x = uu_; ?xa = ⟨v, va⟩⟧ ⟹ ?P; ⋀(uu_::nat option) v::msgterm. ⟦?x = uu_; ?xa = Hash v⟧ ⟹ ?P; ⋀(uu_::nat option) (v::key) va::msgterm. ⟦?x = uu_; ?xa = Crypt v va⟧ ⟹ ?P⟧ ⟹ ?P›*))[1]) (*discuss goal 2*) apply ((auto 3 4 simp add: hf_valid_invert (*‹hf_valid (?tsn::msgterm) (?uinfo::msgterm) (?hf::(unit, unit) HF) (?mo::(unit, unit) HF option) = ((∃(ahi::ahi) (ahi2::ahi) (ts::nat) (upif::msgterm) (downif::msgterm) (asid::nat) (x::msgterm) x2::msgterm. ?hf = ⦇AHI = ahi, UHI = (), HVF = x⦈ ∧ ASID ahi = asid ∧ ASIF (DownIF ahi) downif ∧ ASIF (UpIF ahi) upif ∧ ?mo = Some ⦇AHI = ahi2, UHI = (), HVF = x2⦈ ∧ x = Mac[macKey asid] (L [?tsn, upif, downif, x2]) ∧ ?tsn = Num ts ∧ ?uinfo = ε) ∨ (∃(ahi::ahi) (ts::nat) (upif::msgterm) (downif::msgterm) (asid::nat) x::msgterm. ?hf = ⦇AHI = ahi, UHI = (), HVF = x⦈ ∧ ASID ahi = asid ∧ ASIF (DownIF ahi) downif ∧ ASIF (UpIF ahi) upif ∧ ?mo = None ∧ x = Mac[macKey asid] (L [?tsn, upif, downif]) ∧ ?tsn = Num ts ∧ ?uinfo = ε))›*) intro!: ahi_eq (*‹⟦ASID (?ahi'::ahi) = ASID (?ahi::ahi); ASIF (DownIF ?ahi') (?downif::msgterm); ASIF (UpIF ?ahi') (?upif::msgterm); ASIF (DownIF ?ahi) ?downif; ASIF (UpIF ?ahi) ?upif⟧ ⟹ ?ahi = ?ahi'›*) elim: ASIF.elims (*‹⟦ASIF (?x::nat option) (?xa::msgterm) = (?y::bool); ⋀(a::nat) a'::nat. ⟦?x = Some a; ?xa = AS a'; ?y = (a = a')⟧ ⟹ ?P::bool; ⟦?x = None; ?xa = ε; ?y⟧ ⟹ ?P; ⋀v::nat. ⟦?x = None; ?xa = AS v; ¬ ?y⟧ ⟹ ?P; ⋀v::nat. ⟦?x = None; ?xa = Num v; ¬ ?y⟧ ⟹ ?P; ⋀v::key. ⟦?x = None; ?xa = Key v; ¬ ?y⟧ ⟹ ?P; ⋀v::fresh_t. ⟦?x = None; ?xa = Nonce v; ¬ ?y⟧ ⟹ ?P; ⋀v::msgterm list. ⟦?x = None; ?xa = L v; ¬ ?y⟧ ⟹ ?P; ⋀v::msgterm fset. ⟦?x = None; ?xa = FS v; ¬ ?y⟧ ⟹ ?P; ⋀(v::msgterm) va::msgterm. ⟦?x = None; ?xa = ⟨v, va⟩; ¬ ?y⟧ ⟹ ?P; ⋀v::msgterm. ⟦?x = None; ?xa = Hash v; ¬ ?y⟧ ⟹ ?P; ⋀(v::key) va::msgterm. ⟦?x = None; ?xa = Crypt v va; ¬ ?y⟧ ⟹ ?P; ⋀v::nat. ⟦?x = Some v; ?xa = ε; ¬ ?y⟧ ⟹ ?P; ⋀(uu_::nat option) v::nat. ⟦?x = uu_; ?xa = Num v; ¬ ?y⟧ ⟹ ?P; ⋀(uu_::nat option) v::key. ⟦?x = uu_; ?xa = Key v; ¬ ?y⟧ ⟹ ?P; ⋀(uu_::nat option) v::fresh_t. ⟦?x = uu_; ?xa = Nonce v; ¬ ?y⟧ ⟹ ?P; ⋀(uu_::nat option) v::msgterm list. ⟦?x = uu_; ?xa = L v; ¬ ?y⟧ ⟹ ?P; ⋀(uu_::nat option) v::msgterm fset. ⟦?x = uu_; ?xa = FS v; ¬ ?y⟧ ⟹ ?P; ⋀(uu_::nat option) (v::msgterm) va::msgterm. ⟦?x = uu_; ?xa = ⟨v, va⟩; ¬ ?y⟧ ⟹ ?P; ⋀(uu_::nat option) v::msgterm. ⟦?x = uu_; ?xa = Hash v; ¬ ?y⟧ ⟹ ?P; ⋀(uu_::nat option) (v::key) va::msgterm. ⟦?x = uu_; ?xa = Crypt v va; ¬ ?y⟧ ⟹ ?P⟧ ⟹ ?P› ‹⟦ASIF (?x::nat option) (?xa::msgterm); ⋀(a::nat) a'::nat. ⟦?x = Some a; ?xa = AS a'; a = a'⟧ ⟹ ?P::bool; ⟦?x = None; ?xa = ε⟧ ⟹ ?P⟧ ⟹ ?P› ‹⟦¬ ASIF (?x::nat option) (?xa::msgterm); ⋀(a::nat) a'::nat. ⟦?x = Some a; ?xa = AS a'; a ≠ a'⟧ ⟹ ?P::bool; ⋀v::nat. ⟦?x = None; ?xa = AS v⟧ ⟹ ?P; ⋀v::nat. ⟦?x = None; ?xa = Num v⟧ ⟹ ?P; ⋀v::key. ⟦?x = None; ?xa = Key v⟧ ⟹ ?P; ⋀v::fresh_t. ⟦?x = None; ?xa = Nonce v⟧ ⟹ ?P; ⋀v::msgterm list. ⟦?x = None; ?xa = L v⟧ ⟹ ?P; ⋀v::msgterm fset. ⟦?x = None; ?xa = FS v⟧ ⟹ ?P; ⋀(v::msgterm) va::msgterm. ⟦?x = None; ?xa = ⟨v, va⟩⟧ ⟹ ?P; ⋀v::msgterm. ⟦?x = None; ?xa = Hash v⟧ ⟹ ?P; ⋀(v::key) va::msgterm. ⟦?x = None; ?xa = Crypt v va⟧ ⟹ ?P; ⋀v::nat. ⟦?x = Some v; ?xa = ε⟧ ⟹ ?P; ⋀(uu_::nat option) v::nat. ⟦?x = uu_; ?xa = Num v⟧ ⟹ ?P; ⋀(uu_::nat option) v::key. ⟦?x = uu_; ?xa = Key v⟧ ⟹ ?P; ⋀(uu_::nat option) v::fresh_t. ⟦?x = uu_; ?xa = Nonce v⟧ ⟹ ?P; ⋀(uu_::nat option) v::msgterm list. ⟦?x = uu_; ?xa = L v⟧ ⟹ ?P; ⋀(uu_::nat option) v::msgterm fset. ⟦?x = uu_; ?xa = FS v⟧ ⟹ ?P; ⋀(uu_::nat option) (v::msgterm) va::msgterm. ⟦?x = uu_; ?xa = ⟨v, va⟩⟧ ⟹ ?P; ⋀(uu_::nat option) v::msgterm. ⟦?x = uu_; ?xa = Hash v⟧ ⟹ ?P; ⋀(uu_::nat option) (v::key) va::msgterm. ⟦?x = uu_; ?xa = Crypt v va⟧ ⟹ ?P⟧ ⟹ ?P›*))[1]) (*discuss goal 3*) apply ((auto 3 4 simp add: hf_valid_invert (*‹hf_valid (?tsn::msgterm) (?uinfo::msgterm) (?hf::(unit, unit) HF) (?mo::(unit, unit) HF option) = ((∃(ahi::ahi) (ahi2::ahi) (ts::nat) (upif::msgterm) (downif::msgterm) (asid::nat) (x::msgterm) x2::msgterm. ?hf = ⦇AHI = ahi, UHI = (), HVF = x⦈ ∧ ASID ahi = asid ∧ ASIF (DownIF ahi) downif ∧ ASIF (UpIF ahi) upif ∧ ?mo = Some ⦇AHI = ahi2, UHI = (), HVF = x2⦈ ∧ x = Mac[macKey asid] (L [?tsn, upif, downif, x2]) ∧ ?tsn = Num ts ∧ ?uinfo = ε) ∨ (∃(ahi::ahi) (ts::nat) (upif::msgterm) (downif::msgterm) (asid::nat) x::msgterm. ?hf = ⦇AHI = ahi, UHI = (), HVF = x⦈ ∧ ASID ahi = asid ∧ ASIF (DownIF ahi) downif ∧ ASIF (UpIF ahi) upif ∧ ?mo = None ∧ x = Mac[macKey asid] (L [?tsn, upif, downif]) ∧ ?tsn = Num ts ∧ ?uinfo = ε))›*) intro!: ahi_eq (*‹⟦ASID (?ahi'::ahi) = ASID (?ahi::ahi); ASIF (DownIF ?ahi') (?downif::msgterm); ASIF (UpIF ?ahi') (?upif::msgterm); ASIF (DownIF ?ahi) ?downif; ASIF (UpIF ?ahi) ?upif⟧ ⟹ ?ahi = ?ahi'›*) elim: ASIF.elims (*‹⟦ASIF (?x::nat option) (?xa::msgterm) = (?y::bool); ⋀(a::nat) a'::nat. ⟦?x = Some a; ?xa = AS a'; ?y = (a = a')⟧ ⟹ ?P::bool; ⟦?x = None; ?xa = ε; ?y⟧ ⟹ ?P; ⋀v::nat. ⟦?x = None; ?xa = AS v; ¬ ?y⟧ ⟹ ?P; ⋀v::nat. ⟦?x = None; ?xa = Num v; ¬ ?y⟧ ⟹ ?P; ⋀v::key. ⟦?x = None; ?xa = Key v; ¬ ?y⟧ ⟹ ?P; ⋀v::fresh_t. ⟦?x = None; ?xa = Nonce v; ¬ ?y⟧ ⟹ ?P; ⋀v::msgterm list. ⟦?x = None; ?xa = L v; ¬ ?y⟧ ⟹ ?P; ⋀v::msgterm fset. ⟦?x = None; ?xa = FS v; ¬ ?y⟧ ⟹ ?P; ⋀(v::msgterm) va::msgterm. ⟦?x = None; ?xa = ⟨v, va⟩; ¬ ?y⟧ ⟹ ?P; ⋀v::msgterm. ⟦?x = None; ?xa = Hash v; ¬ ?y⟧ ⟹ ?P; ⋀(v::key) va::msgterm. ⟦?x = None; ?xa = Crypt v va; ¬ ?y⟧ ⟹ ?P; ⋀v::nat. ⟦?x = Some v; ?xa = ε; ¬ ?y⟧ ⟹ ?P; ⋀(uu_::nat option) v::nat. ⟦?x = uu_; ?xa = Num v; ¬ ?y⟧ ⟹ ?P; ⋀(uu_::nat option) v::key. ⟦?x = uu_; ?xa = Key v; ¬ ?y⟧ ⟹ ?P; ⋀(uu_::nat option) v::fresh_t. ⟦?x = uu_; ?xa = Nonce v; ¬ ?y⟧ ⟹ ?P; ⋀(uu_::nat option) v::msgterm list. ⟦?x = uu_; ?xa = L v; ¬ ?y⟧ ⟹ ?P; ⋀(uu_::nat option) v::msgterm fset. ⟦?x = uu_; ?xa = FS v; ¬ ?y⟧ ⟹ ?P; ⋀(uu_::nat option) (v::msgterm) va::msgterm. ⟦?x = uu_; ?xa = ⟨v, va⟩; ¬ ?y⟧ ⟹ ?P; ⋀(uu_::nat option) v::msgterm. ⟦?x = uu_; ?xa = Hash v; ¬ ?y⟧ ⟹ ?P; ⋀(uu_::nat option) (v::key) va::msgterm. ⟦?x = uu_; ?xa = Crypt v va; ¬ ?y⟧ ⟹ ?P⟧ ⟹ ?P› ‹⟦ASIF (?x::nat option) (?xa::msgterm); ⋀(a::nat) a'::nat. ⟦?x = Some a; ?xa = AS a'; a = a'⟧ ⟹ ?P::bool; ⟦?x = None; ?xa = ε⟧ ⟹ ?P⟧ ⟹ ?P› ‹⟦¬ ASIF (?x::nat option) (?xa::msgterm); ⋀(a::nat) a'::nat. ⟦?x = Some a; ?xa = AS a'; a ≠ a'⟧ ⟹ ?P::bool; ⋀v::nat. ⟦?x = None; ?xa = AS v⟧ ⟹ ?P; ⋀v::nat. ⟦?x = None; ?xa = Num v⟧ ⟹ ?P; ⋀v::key. ⟦?x = None; ?xa = Key v⟧ ⟹ ?P; ⋀v::fresh_t. ⟦?x = None; ?xa = Nonce v⟧ ⟹ ?P; ⋀v::msgterm list. ⟦?x = None; ?xa = L v⟧ ⟹ ?P; ⋀v::msgterm fset. ⟦?x = None; ?xa = FS v⟧ ⟹ ?P; ⋀(v::msgterm) va::msgterm. ⟦?x = None; ?xa = ⟨v, va⟩⟧ ⟹ ?P; ⋀v::msgterm. ⟦?x = None; ?xa = Hash v⟧ ⟹ ?P; ⋀(v::key) va::msgterm. ⟦?x = None; ?xa = Crypt v va⟧ ⟹ ?P; ⋀v::nat. ⟦?x = Some v; ?xa = ε⟧ ⟹ ?P; ⋀(uu_::nat option) v::nat. ⟦?x = uu_; ?xa = Num v⟧ ⟹ ?P; ⋀(uu_::nat option) v::key. ⟦?x = uu_; ?xa = Key v⟧ ⟹ ?P; ⋀(uu_::nat option) v::fresh_t. ⟦?x = uu_; ?xa = Nonce v⟧ ⟹ ?P; ⋀(uu_::nat option) v::msgterm list. ⟦?x = uu_; ?xa = L v⟧ ⟹ ?P; ⋀(uu_::nat option) v::msgterm fset. ⟦?x = uu_; ?xa = FS v⟧ ⟹ ?P; ⋀(uu_::nat option) (v::msgterm) va::msgterm. ⟦?x = uu_; ?xa = ⟨v, va⟩⟧ ⟹ ?P; ⋀(uu_::nat option) v::msgterm. ⟦?x = uu_; ?xa = Hash v⟧ ⟹ ?P; ⋀(uu_::nat option) (v::key) va::msgterm. ⟦?x = uu_; ?xa = Crypt v va⟧ ⟹ ?P⟧ ⟹ ?P›*))[1]) (*discuss goal 4*) apply ((auto 3 4 simp add: hf_valid_invert (*‹hf_valid (?tsn::msgterm) (?uinfo::msgterm) (?hf::(unit, unit) HF) (?mo::(unit, unit) HF option) = ((∃(ahi::ahi) (ahi2::ahi) (ts::nat) (upif::msgterm) (downif::msgterm) (asid::nat) (x::msgterm) x2::msgterm. ?hf = ⦇AHI = ahi, UHI = (), HVF = x⦈ ∧ ASID ahi = asid ∧ ASIF (DownIF ahi) downif ∧ ASIF (UpIF ahi) upif ∧ ?mo = Some ⦇AHI = ahi2, UHI = (), HVF = x2⦈ ∧ x = Mac[macKey asid] (L [?tsn, upif, downif, x2]) ∧ ?tsn = Num ts ∧ ?uinfo = ε) ∨ (∃(ahi::ahi) (ts::nat) (upif::msgterm) (downif::msgterm) (asid::nat) x::msgterm. ?hf = ⦇AHI = ahi, UHI = (), HVF = x⦈ ∧ ASID ahi = asid ∧ ASIF (DownIF ahi) downif ∧ ASIF (UpIF ahi) upif ∧ ?mo = None ∧ x = Mac[macKey asid] (L [?tsn, upif, downif]) ∧ ?tsn = Num ts ∧ ?uinfo = ε))›*) intro!: ahi_eq (*‹⟦ASID (?ahi'::ahi) = ASID (?ahi::ahi); ASIF (DownIF ?ahi') (?downif::msgterm); ASIF (UpIF ?ahi') (?upif::msgterm); ASIF (DownIF ?ahi) ?downif; ASIF (UpIF ?ahi) ?upif⟧ ⟹ ?ahi = ?ahi'›*) elim: ASIF.elims (*‹⟦ASIF (?x::nat option) (?xa::msgterm) = (?y::bool); ⋀(a::nat) a'::nat. ⟦?x = Some a; ?xa = AS a'; ?y = (a = a')⟧ ⟹ ?P::bool; ⟦?x = None; ?xa = ε; ?y⟧ ⟹ ?P; ⋀v::nat. ⟦?x = None; ?xa = AS v; ¬ ?y⟧ ⟹ ?P; ⋀v::nat. ⟦?x = None; ?xa = Num v; ¬ ?y⟧ ⟹ ?P; ⋀v::key. ⟦?x = None; ?xa = Key v; ¬ ?y⟧ ⟹ ?P; ⋀v::fresh_t. ⟦?x = None; ?xa = Nonce v; ¬ ?y⟧ ⟹ ?P; ⋀v::msgterm list. ⟦?x = None; ?xa = L v; ¬ ?y⟧ ⟹ ?P; ⋀v::msgterm fset. ⟦?x = None; ?xa = FS v; ¬ ?y⟧ ⟹ ?P; ⋀(v::msgterm) va::msgterm. ⟦?x = None; ?xa = ⟨v, va⟩; ¬ ?y⟧ ⟹ ?P; ⋀v::msgterm. ⟦?x = None; ?xa = Hash v; ¬ ?y⟧ ⟹ ?P; ⋀(v::key) va::msgterm. ⟦?x = None; ?xa = Crypt v va; ¬ ?y⟧ ⟹ ?P; ⋀v::nat. ⟦?x = Some v; ?xa = ε; ¬ ?y⟧ ⟹ ?P; ⋀(uu_::nat option) v::nat. ⟦?x = uu_; ?xa = Num v; ¬ ?y⟧ ⟹ ?P; ⋀(uu_::nat option) v::key. ⟦?x = uu_; ?xa = Key v; ¬ ?y⟧ ⟹ ?P; ⋀(uu_::nat option) v::fresh_t. ⟦?x = uu_; ?xa = Nonce v; ¬ ?y⟧ ⟹ ?P; ⋀(uu_::nat option) v::msgterm list. ⟦?x = uu_; ?xa = L v; ¬ ?y⟧ ⟹ ?P; ⋀(uu_::nat option) v::msgterm fset. ⟦?x = uu_; ?xa = FS v; ¬ ?y⟧ ⟹ ?P; ⋀(uu_::nat option) (v::msgterm) va::msgterm. ⟦?x = uu_; ?xa = ⟨v, va⟩; ¬ ?y⟧ ⟹ ?P; ⋀(uu_::nat option) v::msgterm. ⟦?x = uu_; ?xa = Hash v; ¬ ?y⟧ ⟹ ?P; ⋀(uu_::nat option) (v::key) va::msgterm. ⟦?x = uu_; ?xa = Crypt v va; ¬ ?y⟧ ⟹ ?P⟧ ⟹ ?P› ‹⟦ASIF (?x::nat option) (?xa::msgterm); ⋀(a::nat) a'::nat. ⟦?x = Some a; ?xa = AS a'; a = a'⟧ ⟹ ?P::bool; ⟦?x = None; ?xa = ε⟧ ⟹ ?P⟧ ⟹ ?P› ‹⟦¬ ASIF (?x::nat option) (?xa::msgterm); ⋀(a::nat) a'::nat. ⟦?x = Some a; ?xa = AS a'; a ≠ a'⟧ ⟹ ?P::bool; ⋀v::nat. ⟦?x = None; ?xa = AS v⟧ ⟹ ?P; ⋀v::nat. ⟦?x = None; ?xa = Num v⟧ ⟹ ?P; ⋀v::key. ⟦?x = None; ?xa = Key v⟧ ⟹ ?P; ⋀v::fresh_t. ⟦?x = None; ?xa = Nonce v⟧ ⟹ ?P; ⋀v::msgterm list. ⟦?x = None; ?xa = L v⟧ ⟹ ?P; ⋀v::msgterm fset. ⟦?x = None; ?xa = FS v⟧ ⟹ ?P; ⋀(v::msgterm) va::msgterm. ⟦?x = None; ?xa = ⟨v, va⟩⟧ ⟹ ?P; ⋀v::msgterm. ⟦?x = None; ?xa = Hash v⟧ ⟹ ?P; ⋀(v::key) va::msgterm. ⟦?x = None; ?xa = Crypt v va⟧ ⟹ ?P; ⋀v::nat. ⟦?x = Some v; ?xa = ε⟧ ⟹ ?P; ⋀(uu_::nat option) v::nat. ⟦?x = uu_; ?xa = Num v⟧ ⟹ ?P; ⋀(uu_::nat option) v::key. ⟦?x = uu_; ?xa = Key v⟧ ⟹ ?P; ⋀(uu_::nat option) v::fresh_t. ⟦?x = uu_; ?xa = Nonce v⟧ ⟹ ?P; ⋀(uu_::nat option) v::msgterm list. ⟦?x = uu_; ?xa = L v⟧ ⟹ ?P; ⋀(uu_::nat option) v::msgterm fset. ⟦?x = uu_; ?xa = FS v⟧ ⟹ ?P; ⋀(uu_::nat option) (v::msgterm) va::msgterm. ⟦?x = uu_; ?xa = ⟨v, va⟩⟧ ⟹ ?P; ⋀(uu_::nat option) v::msgterm. ⟦?x = uu_; ?xa = Hash v⟧ ⟹ ?P; ⋀(uu_::nat option) (v::key) va::msgterm. ⟦?x = uu_; ?xa = Crypt v va⟧ ⟹ ?P⟧ ⟹ ?P›*))[1]) (*proven 4 subgoals*) (*discuss goal 5*) apply ((auto simp add: TWu.takeW_split_tail (*‹TWu.takeW (?P::?'b ⇒ ?'a ⇒ ?'a option ⇒ bool) (?upd::?'b ⇒ ?'a ⇒ ?'b) (?info::?'b) ((?x::?'a) # (?xs::?'a list)) (?nxt::?'a option) = (if ?xs = [] then if ?P ?info ?x ?nxt then [?x] else [] else if ?P ?info ?x (Some (hd ?xs)) then ?x # TWu.takeW ?P ?upd (?upd ?info (hd ?xs)) ?xs ?nxt else [])›*) TWu.takeW.simps( (*‹TWu.takeW (?P::?'b ⇒ ?'a ⇒ ?'a option ⇒ bool) (?upd::?'b ⇒ ?'a ⇒ ?'b) (?uu::?'b) [] (?uv::?'a option) = []›*) 1))[1]) (*proven 5 subgoals*) . lemma COND_hf_valid_uinfo: "⟦hf_valid ainfo uinfo hf nxt; hf_valid ainfo' uinfo' hf nxt'⟧ ⟹ uinfo' = uinfo" by (auto simp add: hf_valid_invert (*‹hf_valid ?tsn ?uinfo ?hf ?mo = ((∃ahi ahi2 ts upif downif asid x x2. ?hf = ⦇AHI = ahi, UHI = (), HVF = x⦈ ∧ ASID ahi = asid ∧ ASIF (DownIF ahi) downif ∧ ASIF (UpIF ahi) upif ∧ ?mo = Some ⦇AHI = ahi2, UHI = (), HVF = x2⦈ ∧ x = Mac[macKey asid] (L [?tsn, upif, downif, x2]) ∧ ?tsn = Num ts ∧ ?uinfo = ε) ∨ (∃ahi ts upif downif asid x. ?hf = ⦇AHI = ahi, UHI = (), HVF = x⦈ ∧ ASID ahi = asid ∧ ASIF (DownIF ahi) downif ∧ ASIF (UpIF ahi) upif ∧ ?mo = None ∧ x = Mac[macKey asid] (L [?tsn, upif, downif]) ∧ ?tsn = Num ts ∧ ?uinfo = ε))›*)) lemma COND_upd_uinfo_ik: "⟦terms_uinfo uinfo ⊆ synth (analz ik); terms_hf hf ⊆ synth (analz ik)⟧ ⟹ terms_uinfo (upd_uinfo uinfo hf) ⊆ synth (analz ik)" by (auto simp add: upd_uinfo_def (*‹upd_uinfo ?uinfo ?hf ≡ ?uinfo›*)) lemma COND_upd_uinfo_no_oracle: "no_oracle ainfo uinfo ⟹ no_oracle ainfo (upd_uinfo_pkt m)" by simp lemma COND_auth_restrict_upd: "auth_restrict ainfo uinfo (x#y#hfs) ⟹ auth_restrict ainfo (upd_uinfo uinfo y) (y#hfs)" by (auto simp add: auth_restrict_def (*‹auth_restrict ?ainfo ?uinfo ?l ≡ (∃ts. ?ainfo = Num ts) ∧ ?uinfo = ε›*) upd_uinfo_def (*‹upd_uinfo ?uinfo ?hf ≡ ?uinfo›*)) (******************************************************************************) subsection‹Instantiation of @{text "dataplane_3_directed"} locale› (******************************************************************************) print_locale dataplane_3_directed sublocale dataplane_3_directed _ _ _ auth_seg0 terms_uinfo terms_hf hf_valid auth_restrict extr extr_ainfo term_ainfo upd_uinfo ik_add ik_oracle no_oracle apply unfold_locales (*goal: ‹dataplane_3_directed bad tgtas tgtif auth_seg0 (λx. {x}) terms_hf hf_valid auth_restrict extr id upd_uinfo {} {} (λ_ _. True)›*) using COND_terms_hf (*‹⟦hf_valid ?ainfo ?uinfo ?hf ?z; terms_hf ?hf ⊆ analz ik; True⟧ ⟹ ∃hfs. ?hf ∈ set hfs ∧ (∃uinfo'. (?ainfo, hfs) ∈ auth_seg2 uinfo')›*) COND_honest_hf_analz (*‹⟦ASID (AHI (?hf::(unit, unit) HF)) ∉ (bad::nat set); hf_valid (?ainfo::msgterm) (?uinfo::msgterm) ?hf (?nxt::(unit, unit) HF option); terms_hf ?hf ⊆ synth (analz ik); True⟧ ⟹ terms_hf ?hf ⊆ analz ik›*) COND_extr_prefix_path (*‹⟦hfs_valid ?ainfo ?uinfo ?l ?nxt; ?nxt = None⟧ ⟹ prefix (extr_from_hd ?l) (AHIS ?l)›*) COND_path_prefix_extr (*‹prefix (AHIS (hfs_valid_prefix (?ainfo::msgterm) (?uinfo::msgterm) (?l::(unit, unit) HF list) (?nxt::(unit, unit) HF option))) (extr_from_hd ?l)›*) COND_hf_valid_uinfo (*‹⟦hf_valid (?ainfo::msgterm) (?uinfo::msgterm) (?hf::(unit, unit) HF) (?nxt::(unit, unit) HF option); hf_valid (?ainfo'::msgterm) (?uinfo'::msgterm) ?hf (?nxt'::(unit, unit) HF option)⟧ ⟹ ?uinfo' = ?uinfo›*) COND_upd_uinfo_ik (*‹⟦{?uinfo} ⊆ synth (analz ik); terms_hf ?hf ⊆ synth (analz ik)⟧ ⟹ {upd_uinfo ?uinfo ?hf} ⊆ synth (analz ik)›*) COND_upd_uinfo_no_oracle (*‹True ⟹ True›*) COND_auth_restrict_upd (*‹auth_restrict ?ainfo ?uinfo (?x # ?y # ?hfs) ⟹ auth_restrict ?ainfo (upd_uinfo ?uinfo ?y) (?y # ?hfs)›*) apply - (*goals: 1. ‹⋀ainfo uinfo hf nxt. ⟦hf_valid ainfo uinfo hf nxt; terms_hf hf ⊆ analz ik; True; ⋀ainfo uinfo hf z. ⟦hf_valid ainfo uinfo hf z; terms_hf hf ⊆ analz ik; True⟧ ⟹ ∃hfs. hf ∈ set hfs ∧ (∃uinfo'. (ainfo, hfs) ∈ auth_seg2 uinfo'); ⋀hf ainfo uinfo nxt. ⟦ASID (AHI hf) ∉ bad; hf_valid ainfo uinfo hf nxt; terms_hf hf ⊆ synth (analz ik); True⟧ ⟹ terms_hf hf ⊆ analz ik; ⋀ainfo uinfo l nxt. ⟦hfs_valid ainfo uinfo l nxt; nxt = None⟧ ⟹ prefix (extr_from_hd l) (AHIS l); ⋀ainfo uinfo l nxt. prefix (AHIS (hfs_valid_prefix ainfo uinfo l nxt)) (extr_from_hd l); ⋀ainfo uinfo hf nxt ainfo' uinfo' nxt'. ⟦hf_valid ainfo uinfo hf nxt; hf_valid ainfo' uinfo' hf nxt'⟧ ⟹ uinfo' = uinfo; ⋀uinfo hf. ⟦{uinfo} ⊆ synth (analz ik); terms_hf hf ⊆ synth (analz ik)⟧ ⟹ {upd_uinfo uinfo hf} ⊆ synth (analz ik); True ⟹ True; ⋀ainfo uinfo x y hfs. auth_restrict ainfo uinfo (x # y # hfs) ⟹ auth_restrict ainfo (upd_uinfo uinfo y) (y # hfs)⟧ ⟹ ∃hfs. hf ∈ set hfs ∧ (∃uinfo'. (ainfo, hfs) ∈ auth_seg2 uinfo')› 2. ‹⋀hf ainfo uinfo nxt. ⟦ASID (AHI hf) ∉ bad; hf_valid ainfo uinfo hf nxt; terms_hf hf ⊆ synth (analz ik); True; ⋀ainfo uinfo hf z. ⟦hf_valid ainfo uinfo hf z; terms_hf hf ⊆ analz ik; True⟧ ⟹ ∃hfs. hf ∈ set hfs ∧ (∃uinfo'. (ainfo, hfs) ∈ auth_seg2 uinfo'); ⋀hf ainfo uinfo nxt. ⟦ASID (AHI hf) ∉ bad; hf_valid ainfo uinfo hf nxt; terms_hf hf ⊆ synth (analz ik); True⟧ ⟹ terms_hf hf ⊆ analz ik; ⋀ainfo uinfo l nxt. ⟦hfs_valid ainfo uinfo l nxt; nxt = None⟧ ⟹ prefix (extr_from_hd l) (AHIS l); ⋀ainfo uinfo l nxt. prefix (AHIS (hfs_valid_prefix ainfo uinfo l nxt)) (extr_from_hd l); ⋀ainfo uinfo hf nxt ainfo' uinfo' nxt'. ⟦hf_valid ainfo uinfo hf nxt; hf_valid ainfo' uinfo' hf nxt'⟧ ⟹ uinfo' = uinfo; ⋀uinfo hf. ⟦{uinfo} ⊆ synth (analz ik); terms_hf hf ⊆ synth (analz ik)⟧ ⟹ {upd_uinfo uinfo hf} ⊆ synth (analz ik); True ⟹ True; ⋀ainfo uinfo x y hfs. auth_restrict ainfo uinfo (x # y # hfs) ⟹ auth_restrict ainfo (upd_uinfo uinfo y) (y # hfs)⟧ ⟹ terms_hf hf ⊆ analz ik› 3. ‹⋀ainfo uinfo l nxt. ⟦⋀ainfo uinfo hf z. ⟦hf_valid ainfo uinfo hf z; terms_hf hf ⊆ analz ik; True⟧ ⟹ ∃hfs. hf ∈ set hfs ∧ (∃uinfo'. (ainfo, hfs) ∈ auth_seg2 uinfo'); ⋀hf ainfo uinfo nxt. ⟦ASID (AHI hf) ∉ bad; hf_valid ainfo uinfo hf nxt; terms_hf hf ⊆ synth (analz ik); True⟧ ⟹ terms_hf hf ⊆ analz ik; ⋀ainfo uinfo l nxt. ⟦hfs_valid ainfo uinfo l nxt; nxt = None⟧ ⟹ prefix (extr_from_hd l) (AHIS l); ⋀ainfo uinfo l nxt. prefix (AHIS (hfs_valid_prefix ainfo uinfo l nxt)) (extr_from_hd l); ⋀ainfo uinfo hf nxt ainfo' uinfo' nxt'. ⟦hf_valid ainfo uinfo hf nxt; hf_valid ainfo' uinfo' hf nxt'⟧ ⟹ uinfo' = uinfo; ⋀uinfo hf. ⟦{uinfo} ⊆ synth (analz ik); terms_hf hf ⊆ synth (analz ik)⟧ ⟹ {upd_uinfo uinfo hf} ⊆ synth (analz ik); True ⟹ True; ⋀ainfo uinfo x y hfs. auth_restrict ainfo uinfo (x # y # hfs) ⟹ auth_restrict ainfo (upd_uinfo uinfo y) (y # hfs)⟧ ⟹ prefix (AHIS (hfs_valid_prefix ainfo uinfo l nxt)) (extr_from_hd l)› 4. ‹⋀ainfo uinfo l nxt. ⟦hfs_valid ainfo uinfo l nxt; auth_restrict ainfo uinfo l; nxt = None; ⋀ainfo uinfo hf z. ⟦hf_valid ainfo uinfo hf z; terms_hf hf ⊆ analz ik; True⟧ ⟹ ∃hfs. hf ∈ set hfs ∧ (∃uinfo'. (ainfo, hfs) ∈ auth_seg2 uinfo'); ⋀hf ainfo uinfo nxt. ⟦ASID (AHI hf) ∉ bad; hf_valid ainfo uinfo hf nxt; terms_hf hf ⊆ synth (analz ik); True⟧ ⟹ terms_hf hf ⊆ analz ik; ⋀ainfo uinfo l nxt. ⟦hfs_valid ainfo uinfo l nxt; nxt = None⟧ ⟹ prefix (extr_from_hd l) (AHIS l); ⋀ainfo uinfo l nxt. prefix (AHIS (hfs_valid_prefix ainfo uinfo l nxt)) (extr_from_hd l); ⋀ainfo uinfo hf nxt ainfo' uinfo' nxt'. ⟦hf_valid ainfo uinfo hf nxt; hf_valid ainfo' uinfo' hf nxt'⟧ ⟹ uinfo' = uinfo; ⋀uinfo hf. ⟦{uinfo} ⊆ synth (analz ik); terms_hf hf ⊆ synth (analz ik)⟧ ⟹ {upd_uinfo uinfo hf} ⊆ synth (analz ik); True ⟹ True; ⋀ainfo uinfo x y hfs. auth_restrict ainfo uinfo (x # y # hfs) ⟹ auth_restrict ainfo (upd_uinfo uinfo y) (y # hfs)⟧ ⟹ prefix (extr_from_hd l) (AHIS l)› 5. ‹⋀ainfo uinfo hf nxt ainfo' uinfo' nxt'. ⟦hf_valid ainfo uinfo hf nxt; hf_valid ainfo' uinfo' hf nxt'; ⋀ainfo uinfo hf z. ⟦hf_valid ainfo uinfo hf z; terms_hf hf ⊆ analz ik; True⟧ ⟹ ∃hfs. hf ∈ set hfs ∧ (∃uinfo'. (ainfo, hfs) ∈ auth_seg2 uinfo'); ⋀hf ainfo uinfo nxt. ⟦ASID (AHI hf) ∉ bad; hf_valid ainfo uinfo hf nxt; terms_hf hf ⊆ synth (analz ik); True⟧ ⟹ terms_hf hf ⊆ analz ik; ⋀ainfo uinfo l nxt. ⟦hfs_valid ainfo uinfo l nxt; nxt = None⟧ ⟹ prefix (extr_from_hd l) (AHIS l); ⋀ainfo uinfo l nxt. prefix (AHIS (hfs_valid_prefix ainfo uinfo l nxt)) (extr_from_hd l); ⋀ainfo uinfo hf nxt ainfo' uinfo' nxt'. ⟦hf_valid ainfo uinfo hf nxt; hf_valid ainfo' uinfo' hf nxt'⟧ ⟹ uinfo' = uinfo; ⋀uinfo hf. ⟦{uinfo} ⊆ synth (analz ik); terms_hf hf ⊆ synth (analz ik)⟧ ⟹ {upd_uinfo uinfo hf} ⊆ synth (analz ik); True ⟹ True; ⋀ainfo uinfo x y hfs. auth_restrict ainfo uinfo (x # y # hfs) ⟹ auth_restrict ainfo (upd_uinfo uinfo y) (y # hfs)⟧ ⟹ uinfo' = uinfo› 6. ‹⋀uinfo hf. ⟦{uinfo} ⊆ synth (analz ik); terms_hf hf ⊆ synth (analz ik); ⋀ainfo uinfo hf z. ⟦hf_valid ainfo uinfo hf z; terms_hf hf ⊆ analz ik; True⟧ ⟹ ∃hfs. hf ∈ set hfs ∧ (∃uinfo'. (ainfo, hfs) ∈ auth_seg2 uinfo'); ⋀hf ainfo uinfo nxt. ⟦ASID (AHI hf) ∉ bad; hf_valid ainfo uinfo hf nxt; terms_hf hf ⊆ synth (analz ik); True⟧ ⟹ terms_hf hf ⊆ analz ik; ⋀ainfo uinfo l nxt. ⟦hfs_valid ainfo uinfo l nxt; nxt = None⟧ ⟹ prefix (extr_from_hd l) (AHIS l); ⋀ainfo uinfo l nxt. prefix (AHIS (hfs_valid_prefix ainfo uinfo l nxt)) (extr_from_hd l); ⋀ainfo uinfo hf nxt ainfo' uinfo' nxt'. ⟦hf_valid ainfo uinfo hf nxt; hf_valid ainfo' uinfo' hf nxt'⟧ ⟹ uinfo' = uinfo; ⋀uinfo hf. ⟦{uinfo} ⊆ synth (analz ik); terms_hf hf ⊆ synth (analz ik)⟧ ⟹ {upd_uinfo uinfo hf} ⊆ synth (analz ik); True ⟹ True; ⋀ainfo uinfo x y hfs. auth_restrict ainfo uinfo (x # y # hfs) ⟹ auth_restrict ainfo (upd_uinfo uinfo y) (y # hfs)⟧ ⟹ {upd_uinfo uinfo hf} ⊆ synth (analz ik)› 7. ‹⋀ainfo uinfo fld. ⟦True; ⋀ainfo uinfo hf z. ⟦hf_valid ainfo uinfo hf z; terms_hf hf ⊆ analz ik; True⟧ ⟹ ∃hfs. hf ∈ set hfs ∧ (∃uinfo'. (ainfo, hfs) ∈ auth_seg2 uinfo'); ⋀hf ainfo uinfo nxt. ⟦ASID (AHI hf) ∉ bad; hf_valid ainfo uinfo hf nxt; terms_hf hf ⊆ synth (analz ik); True⟧ ⟹ terms_hf hf ⊆ analz ik; ⋀ainfo uinfo l nxt. ⟦hfs_valid ainfo uinfo l nxt; nxt = None⟧ ⟹ prefix (extr_from_hd l) (AHIS l); ⋀ainfo uinfo l nxt. prefix (AHIS (hfs_valid_prefix ainfo uinfo l nxt)) (extr_from_hd l); ⋀ainfo uinfo hf nxt ainfo' uinfo' nxt'. ⟦hf_valid ainfo uinfo hf nxt; hf_valid ainfo' uinfo' hf nxt'⟧ ⟹ uinfo' = uinfo; ⋀uinfo hf. ⟦{uinfo} ⊆ synth (analz ik); terms_hf hf ⊆ synth (analz ik)⟧ ⟹ {upd_uinfo uinfo hf} ⊆ synth (analz ik); True ⟹ True; ⋀ainfo uinfo x y hfs. auth_restrict ainfo uinfo (x # y # hfs) ⟹ auth_restrict ainfo (upd_uinfo uinfo y) (y # hfs)⟧ ⟹ True› 8. ‹⋀ainfo uinfo hf1 hf2 xs. ⟦auth_restrict ainfo uinfo (hf1 # hf2 # xs); ⋀ainfo uinfo hf z. ⟦hf_valid ainfo uinfo hf z; terms_hf hf ⊆ analz ik; True⟧ ⟹ ∃hfs. hf ∈ set hfs ∧ (∃uinfo'. (ainfo, hfs) ∈ auth_seg2 uinfo'); ⋀hf ainfo uinfo nxt. ⟦ASID (AHI hf) ∉ bad; hf_valid ainfo uinfo hf nxt; terms_hf hf ⊆ synth (analz ik); True⟧ ⟹ terms_hf hf ⊆ analz ik; ⋀ainfo uinfo l nxt. ⟦hfs_valid ainfo uinfo l nxt; nxt = None⟧ ⟹ prefix (extr_from_hd l) (AHIS l); ⋀ainfo uinfo l nxt. prefix (AHIS (hfs_valid_prefix ainfo uinfo l nxt)) (extr_from_hd l); ⋀ainfo uinfo hf nxt ainfo' uinfo' nxt'. ⟦hf_valid ainfo uinfo hf nxt; hf_valid ainfo' uinfo' hf nxt'⟧ ⟹ uinfo' = uinfo; ⋀uinfo hf. ⟦{uinfo} ⊆ synth (analz ik); terms_hf hf ⊆ synth (analz ik)⟧ ⟹ {upd_uinfo uinfo hf} ⊆ synth (analz ik); True ⟹ True; ⋀ainfo uinfo x y hfs. auth_restrict ainfo uinfo (x # y # hfs) ⟹ auth_restrict ainfo (upd_uinfo uinfo y) (y # hfs)⟧ ⟹ auth_restrict ainfo (upd_uinfo uinfo hf2) (hf2 # xs)› 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]) (*proven 8 subgoals*) . end end
{ "path": "afp-2025-02-12/thys/IsaNet/instances/SCION_variant.thy", "repo": "afp-2025-02-12", "sha": "16e6f88b93cd1cf4e887ef9931521051d9debcc4089e68ae36f27364cc00a2a4" }
section ‹Lazy list monad› theory Lazy_List_Monad imports Monad_Zero_Plus begin text ‹To illustrate the general process of defining a new type constructor, we formalize the datatype of lazy lists. Below are the Haskell datatype definition and class instances.› text_raw ‹ \begin{verbatim} data List a = Nil | Cons a (List a) instance Functor List where fmap f Nil = Nil fmap f (Cons x xs) = Cons (f x) (fmap f xs) instance Monad List where return x = Cons x Nil Nil >>= k = Nil Cons x xs >>= k = mplus (k x) (xs >>= k) instance MonadZero List where mzero = Nil instance MonadPlus List where mplus Nil ys = ys mplus (Cons x xs) ys = Cons x (mplus xs ys) \end{verbatim} › subsection ‹Type definition› text ‹The first step is to register the datatype definition with ‹tycondef›.› tycondef 'a⋅llist = LNil | LCons (lazy "'a") (lazy "'a⋅llist") text ‹The ‹tycondef› command generates lots of theorems automatically, but there are a few more involving ‹coerce› and ‹fmapU› that we still need to prove manually. These proofs could be automated in a later version of ‹tycondef›.› lemma coerce_llist_abs [simp]: "coerce⋅(llist_abs⋅x) = llist_abs⋅(coerce⋅x)" apply (simp add: llist_abs_def (*‹llist_abs ≡ PRJ(?'a⋅llist) oo EMB(one ⊕ ?'a⇩⊥ ⊗ (?'a⋅llist)⇩⊥)›*) coerce_def (*‹COERCE(?'a, ?'b) ≡ PRJ(?'b) oo EMB(?'a)›*)) (*goal: ‹COERCE('b⋅llist, 'a⋅llist)⋅(llist_abs⋅x) = llist_abs⋅(COERCE(one ⊕ 'b⇩⊥ ⊗ ('b⋅llist)⇩⊥, one ⊕ 'a⇩⊥ ⊗ ('a⋅llist)⇩⊥)⋅x)›*) by (simp add: emb_prj_emb (*‹DEFL(?'a) ⊑ DEFL(?'b) ⟹ EMB(?'b)⋅(PRJ(?'b)⋅(EMB(?'a)⋅?x)) = EMB(?'a)⋅?x›*) prj_emb_prj (*‹DEFL(?'a) ⊑ DEFL(?'b) ⟹ PRJ(?'a)⋅(EMB(?'b)⋅(PRJ(?'b)⋅?x)) = PRJ(?'a)⋅?x›*) DEFL_eq_llist (*‹DEFL(?'a⋅llist) = DEFL(one ⊕ ?'a⇩⊥ ⊗ (?'a⋅llist)⇩⊥)›*)) lemma coerce_LNil [simp]: "coerce⋅LNil = LNil" unfolding LNil_def (*goal: ‹COERCE('b⋅llist, 'a⋅llist)⋅(llist_abs⋅(sinl⋅ONE)) = llist_abs⋅(sinl⋅ONE)›*) by simp lemma coerce_LCons [simp]: "coerce⋅(LCons⋅x⋅xs) = LCons⋅(coerce⋅x)⋅(coerce⋅xs)" unfolding LCons_def (*goal: ‹COERCE('b⋅llist, 'a⋅llist)⋅((Λ a app. llist_abs⋅(sinr⋅(:up⋅a, up⋅app:)))⋅x⋅xs) = (Λ a app. llist_abs⋅(sinr⋅(:up⋅a, up⋅app:)))⋅(COERCE('b, 'a)⋅x)⋅(COERCE('b⋅llist, 'a⋅llist)⋅xs)›*) by simp lemma fmapU_llist_simps [simp]: "fmapU⋅f⋅(⊥::udom⋅llist) = ⊥" "fmapU⋅f⋅LNil = LNil" "fmapU⋅f⋅(LCons⋅x⋅xs) = LCons⋅(f⋅x)⋅(fmapU⋅f⋅xs)" unfolding fmapU_llist_def llist_map_def (*goals: 1. ‹(Λ a. μ uu. llist_abs oo ssum_map⋅ID⋅(sprod_map⋅(u_map⋅a)⋅(u_map⋅uu)) oo llist_rep)⋅f⋅⊥ = ⊥› 2. ‹(Λ a. μ uu. llist_abs oo ssum_map⋅ID⋅(sprod_map⋅(u_map⋅a)⋅(u_map⋅uu)) oo llist_rep)⋅f⋅LNil = LNil› 3. ‹(Λ a. μ uu. llist_abs oo ssum_map⋅ID⋅(sprod_map⋅(u_map⋅a)⋅(u_map⋅uu)) oo llist_rep)⋅f⋅(LCons⋅x⋅xs) = LCons⋅(f⋅x)⋅((Λ a. μ uu. llist_abs oo ssum_map⋅ID⋅(sprod_map⋅(u_map⋅a)⋅(u_map⋅uu)) oo llist_rep)⋅f⋅xs)›*) (*goals: 1. ‹(Λ a. μ uu. llist_abs oo ssum_map⋅ID⋅(sprod_map⋅(u_map⋅a)⋅(u_map⋅uu)) oo llist_rep)⋅f⋅⊥ = ⊥› 2. ‹(Λ a. μ uu. llist_abs oo ssum_map⋅ID⋅(sprod_map⋅(u_map⋅a)⋅(u_map⋅uu)) oo llist_rep)⋅f⋅LNil = LNil› 3. ‹(Λ a. μ uu. llist_abs oo ssum_map⋅ID⋅(sprod_map⋅(u_map⋅a)⋅(u_map⋅uu)) oo llist_rep)⋅f⋅(LCons⋅x⋅xs) = LCons⋅(f⋅x)⋅((Λ a. μ uu. llist_abs oo ssum_map⋅ID⋅(sprod_map⋅(u_map⋅a)⋅(u_map⋅uu)) oo llist_rep)⋅f⋅xs)› discuss goal 1*) apply (subst fix_eq (*‹fix⋅?F = ?F⋅(fix⋅?F)›*)) (*top goal: ‹(Λ a. μ uu. llist_abs oo ssum_map⋅ID⋅(sprod_map⋅(u_map⋅a)⋅(u_map⋅uu)) oo llist_rep)⋅f⋅⊥ = ⊥› and 2 goals remain*) apply simp (*discuss goal 2*) apply (subst fix_eq (*‹fix⋅?F = ?F⋅(fix⋅?F)›*)) (*top goal: ‹(Λ a. μ uu. llist_abs oo ssum_map⋅ID⋅(sprod_map⋅(u_map⋅a)⋅(u_map⋅uu)) oo llist_rep)⋅f⋅LNil = LNil› and 1 goal remains*) apply (simp add: LNil_def (*‹LNil ≡ llist_abs⋅(sinl⋅ONE)›*)) (*discuss goal 3*) apply (subst fix_eq (*‹fix⋅?F = ?F⋅(fix⋅?F)›*)) (*goal: ‹(Λ a. μ uu. llist_abs oo ssum_map⋅ID⋅(sprod_map⋅(u_map⋅a)⋅(u_map⋅uu)) oo llist_rep)⋅f⋅(LCons⋅x⋅xs) = LCons⋅(f⋅x)⋅((Λ a. μ uu. llist_abs oo ssum_map⋅ID⋅(sprod_map⋅(u_map⋅a)⋅(u_map⋅uu)) oo llist_rep)⋅f⋅xs)›*) apply (simp add: LCons_def (*‹LCons ≡ Λ a app. llist_abs⋅(sinr⋅(:up⋅a, up⋅app:))›*)) (*proven 3 subgoals*) . subsection ‹Class instances› text ‹The ‹tycondef› command defines ‹fmapU› for us and proves a ‹prefunctor› class instance automatically. For the ‹functor› instance we only need to prove the composition law, which we can do by induction.› instance llist :: "functor" proof fix f g and xs :: "udom⋅llist" show "fmapU⋅f⋅(fmapU⋅g⋅xs) = fmapU⋅(Λ x. f⋅(g⋅x))⋅xs" by (induct xs rule: llist.induct) simp_all qed text ‹For the other class instances, we need to provide definitions for a few constants: ‹returnU›, ‹bindU› ‹zeroU›, and ‹plusU›. We can use ordinary commands like ‹definition› and ‹fixrec› for this purpose. Finally we prove the class axioms, along with a few helper lemmas, using ordinary proof procedures like induction.› instantiation llist :: monad_zero_plus begin fixrec plusU_llist :: "udom⋅llist → udom⋅llist → udom⋅llist" where "plusU_llist⋅LNil⋅ys = ys" | "plusU_llist⋅(LCons⋅x⋅xs)⋅ys = LCons⋅x⋅(plusU_llist⋅xs⋅ys)" lemma plusU_llist_strict [simp]: "plusU⋅⊥⋅ys = (⊥::udom⋅llist)" by fixrec_simp fixrec bindU_llist :: "udom⋅llist → (udom → udom⋅llist) → udom⋅llist" where "bindU_llist⋅LNil⋅k = LNil" | "bindU_llist⋅(LCons⋅x⋅xs)⋅k = plusU⋅(k⋅x)⋅(bindU_llist⋅xs⋅k)" lemma bindU_llist_strict [simp]: "bindU⋅⊥⋅k = (⊥::udom⋅llist)" by fixrec_simp definition zeroU_llist_def: "zeroU = LNil" definition returnU_llist_def: "returnU = (Λ x. LCons⋅x⋅LNil)" lemma plusU_LNil_right: "plusU⋅xs⋅LNil = xs" apply (induct xs rule: llist.induct (*‹⟦adm ?P; ?P ⊥; ?P LNil; ⋀a app. ?P app ⟹ ?P (LCons⋅a⋅app)⟧ ⟹ ?P ?x›*)) (*goals: 1. ‹adm (λa. plusU⋅a⋅LNil = a)› 2. ‹plusU⋅⊥⋅LNil = ⊥› 3. ‹plusU⋅LNil⋅LNil = LNil› 4. ‹⋀a app. plusU⋅app⋅LNil = app ⟹ plusU⋅(LCons⋅a⋅app)⋅LNil = LCons⋅a⋅app› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*discuss goal 3*) apply simp (*discuss goal 4*) apply simp (*proven 4 subgoals*) . lemma plusU_llist_assoc: fixes xs ys zs :: "udom⋅llist" shows "plusU⋅(plusU⋅xs⋅ys)⋅zs = plusU⋅xs⋅(plusU⋅ys⋅zs)" apply (induct xs rule: llist.induct (*‹⟦adm ?P; ?P ⊥; ?P LNil; ⋀a app. ?P app ⟹ ?P (LCons⋅a⋅app)⟧ ⟹ ?P ?x›*)) (*goals: 1. ‹adm (λa. plusU⋅(plusU⋅a⋅ys)⋅zs = plusU⋅a⋅(plusU⋅ys⋅zs))› 2. ‹plusU⋅(plusU⋅⊥⋅ys)⋅zs = plusU⋅⊥⋅(plusU⋅ys⋅zs)› 3. ‹plusU⋅(plusU⋅LNil⋅ys)⋅zs = plusU⋅LNil⋅(plusU⋅ys⋅zs)› 4. ‹⋀a app. plusU⋅(plusU⋅app⋅ys)⋅zs = plusU⋅app⋅(plusU⋅ys⋅zs) ⟹ plusU⋅(plusU⋅(LCons⋅a⋅app)⋅ys)⋅zs = plusU⋅(LCons⋅a⋅app)⋅(plusU⋅ys⋅zs)› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*discuss goal 3*) apply simp (*discuss goal 4*) apply simp (*proven 4 subgoals*) . lemma bindU_plusU_llist: fixes xs ys :: "udom⋅llist" shows "bindU⋅(plusU⋅xs⋅ys)⋅f = plusU⋅(bindU⋅xs⋅f)⋅(bindU⋅ys⋅f)" apply (induct xs rule: llist.induct (*‹⟦adm ?P; ?P ⊥; ?P LNil; ⋀a app. ?P app ⟹ ?P (LCons⋅a⋅app)⟧ ⟹ ?P ?x›*)) (*goals: 1. ‹adm (λa. bindU⋅(plusU⋅a⋅ys)⋅f = plusU⋅(bindU⋅a⋅f)⋅(bindU⋅ys⋅f))› 2. ‹bindU⋅(plusU⋅⊥⋅ys)⋅f = plusU⋅(bindU⋅⊥⋅f)⋅(bindU⋅ys⋅f)› 3. ‹bindU⋅(plusU⋅LNil⋅ys)⋅f = plusU⋅(bindU⋅LNil⋅f)⋅(bindU⋅ys⋅f)› 4. ‹⋀a app. bindU⋅(plusU⋅app⋅ys)⋅f = plusU⋅(bindU⋅app⋅f)⋅(bindU⋅ys⋅f) ⟹ bindU⋅(plusU⋅(LCons⋅a⋅app)⋅ys)⋅f = plusU⋅(bindU⋅(LCons⋅a⋅app)⋅f)⋅(bindU⋅ys⋅f)› discuss goal 1*) apply (simp add: plusU_llist_assoc (*‹plusU⋅(plusU⋅?xs⋅?ys)⋅?zs = plusU⋅?xs⋅(plusU⋅?ys⋅?zs)›*)) (*discuss goal 2*) apply (simp add: plusU_llist_assoc (*‹plusU⋅(plusU⋅?xs⋅?ys)⋅?zs = plusU⋅?xs⋅(plusU⋅?ys⋅?zs)›*)) (*discuss goal 3*) apply (simp add: plusU_llist_assoc (*‹plusU⋅(plusU⋅?xs⋅?ys)⋅?zs = plusU⋅?xs⋅(plusU⋅?ys⋅?zs)›*)) (*discuss goal 4*) apply (simp add: plusU_llist_assoc (*‹plusU⋅(plusU⋅?xs⋅?ys)⋅?zs = plusU⋅?xs⋅(plusU⋅?ys⋅?zs)›*)) (*proven 4 subgoals*) . instance proof fix x :: "udom" fix f :: "udom → udom" fix h k :: "udom → udom⋅llist" fix xs ys zs :: "udom⋅llist" show "fmapU⋅f⋅xs = bindU⋅xs⋅(Λ x. returnU⋅(f⋅x))" by (induct xs rule: llist.induct, simp_all add: returnU_llist_def) show "bindU⋅(returnU⋅x)⋅k = k⋅x" by (simp add: returnU_llist_def plusU_LNil_right) show "bindU⋅(bindU⋅xs⋅h)⋅k = bindU⋅xs⋅(Λ x. bindU⋅(h⋅x)⋅k)" by (induct xs rule: llist.induct) (simp_all add: bindU_plusU_llist) show "bindU⋅(plusU⋅xs⋅ys)⋅k = plusU⋅(bindU⋅xs⋅k)⋅(bindU⋅ys⋅k)" by (induct xs rule: llist.induct) (simp_all add: plusU_llist_assoc) show "plusU⋅(plusU⋅xs⋅ys)⋅zs = plusU⋅xs⋅(plusU⋅ys⋅zs)" by (rule plusU_llist_assoc) show "bindU⋅zeroU⋅k = zeroU" by (simp add: zeroU_llist_def) show "fmapU⋅f⋅(plusU⋅xs⋅ys) = plusU⋅(fmapU⋅f⋅xs)⋅(fmapU⋅f⋅ys)" by (induct xs rule: llist.induct) simp_all show "fmapU⋅f⋅zeroU = (zeroU :: udom⋅llist)" by (simp add: zeroU_llist_def) show "plusU⋅zeroU⋅xs = xs" by (simp add: zeroU_llist_def) show "plusU⋅xs⋅zeroU = xs" by (simp add: zeroU_llist_def plusU_LNil_right) qed end subsection ‹Transfer properties to polymorphic versions› text ‹After proving the class instances, there is still one more step: We must transfer all the list-specific lemmas about the monomorphic constants (e.g., ‹fmapU› and ‹bindU›) to the corresponding polymorphic constants (‹fmap› and ‹bind›). These lemmas primarily consist of the defining equations for each constant. The polymorphic constants are defined using ‹coerce›, so the proofs proceed by unfolding the definitions and simplifying with the ‹coerce_simp› rules.› lemma fmap_llist_simps [simp]: "fmap⋅f⋅(⊥::'a⋅llist) = ⊥" "fmap⋅f⋅LNil = LNil" "fmap⋅f⋅(LCons⋅x⋅xs) = LCons⋅(f⋅x)⋅(fmap⋅f⋅xs)" unfolding fmap_def (*goals: 1. ‹COERCE((udom → udom) → udom⋅llist → udom⋅llist, ('a → 'b) → 'a⋅llist → 'b⋅llist)⋅fmapU⋅f⋅⊥ = ⊥› 2. ‹COERCE((udom → udom) → udom⋅llist → udom⋅llist, ('a → 'b) → 'a⋅llist → 'b⋅llist)⋅fmapU⋅f⋅LNil = LNil› 3. ‹COERCE((udom → udom) → udom⋅llist → udom⋅llist, ('a → 'b) → 'a⋅llist → 'b⋅llist)⋅fmapU⋅f⋅(LCons⋅x⋅xs) = LCons⋅(f⋅x)⋅(COERCE((udom → udom) → udom⋅llist → udom⋅llist, ('a → 'b) → 'a⋅llist → 'b⋅llist)⋅fmapU⋅f⋅xs)›*) (*goals: 1. ‹COERCE((udom → udom) → udom⋅llist → udom⋅llist, ('a → 'b) → 'a⋅llist → 'b⋅llist)⋅fmapU⋅f⋅⊥ = ⊥› 2. ‹COERCE((udom → udom) → udom⋅llist → udom⋅llist, ('a → 'b) → 'a⋅llist → 'b⋅llist)⋅fmapU⋅f⋅LNil = LNil› 3. ‹COERCE((udom → udom) → udom⋅llist → udom⋅llist, ('a → 'b) → 'a⋅llist → 'b⋅llist)⋅fmapU⋅f⋅(LCons⋅x⋅xs) = LCons⋅(f⋅x)⋅(COERCE((udom → udom) → udom⋅llist → udom⋅llist, ('a → 'b) → 'a⋅llist → 'b⋅llist)⋅fmapU⋅f⋅xs)› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*discuss goal 3*) apply simp (*proven 3 subgoals*) . lemma mplus_llist_simps [simp]: "mplus⋅(⊥::'a⋅llist)⋅ys = ⊥" "mplus⋅LNil⋅ys = ys" "mplus⋅(LCons⋅x⋅xs)⋅ys = LCons⋅x⋅(mplus⋅xs⋅ys)" unfolding mplus_def (*goals: 1. ‹COERCE(udom⋅llist → udom⋅llist → udom⋅llist, 'a⋅llist → 'a⋅llist → 'a⋅llist)⋅plusU⋅⊥⋅ys = ⊥› 2. ‹COERCE(udom⋅llist → udom⋅llist → udom⋅llist, 'a⋅llist → 'a⋅llist → 'a⋅llist)⋅plusU⋅LNil⋅ys = ys› 3. ‹COERCE(udom⋅llist → udom⋅llist → udom⋅llist, 'a⋅llist → 'a⋅llist → 'a⋅llist)⋅plusU⋅(LCons⋅x⋅xs)⋅ys = LCons⋅x⋅(COERCE(udom⋅llist → udom⋅llist → udom⋅llist, 'a⋅llist → 'a⋅llist → 'a⋅llist)⋅plusU⋅xs⋅ys)›*) (*goals: 1. ‹COERCE(udom⋅llist → udom⋅llist → udom⋅llist, 'a⋅llist → 'a⋅llist → 'a⋅llist)⋅plusU⋅⊥⋅(ys::'a⋅llist) = ⊥› 2. ‹COERCE(udom⋅llist → udom⋅llist → udom⋅llist, 'a⋅llist → 'a⋅llist → 'a⋅llist)⋅plusU⋅LNil⋅(ys::'a⋅llist) = ys› 3. ‹COERCE(udom⋅llist → udom⋅llist → udom⋅llist, 'a⋅llist → 'a⋅llist → 'a⋅llist)⋅plusU⋅(LCons⋅(x::'a)⋅(xs::'a⋅llist))⋅(ys::'a⋅llist) = LCons⋅x⋅(COERCE(udom⋅llist → udom⋅llist → udom⋅llist, 'a⋅llist → 'a⋅llist → 'a⋅llist)⋅plusU⋅xs⋅ys)› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*discuss goal 3*) apply simp (*proven 3 subgoals*) . lemma bind_llist_simps [simp]: "bind⋅(⊥::'a⋅llist)⋅f = ⊥" "bind⋅LNil⋅f = LNil" "bind⋅(LCons⋅x⋅xs)⋅f = mplus⋅(f⋅x)⋅(bind⋅xs⋅f)" unfolding bind_def mplus_def (*goals: 1. ‹COERCE(udom⋅llist → (udom → udom⋅llist) → udom⋅llist, 'a⋅llist → ('a → 'b⋅llist) → 'b⋅llist)⋅bindU⋅⊥⋅f = ⊥› 2. ‹COERCE(udom⋅llist → (udom → udom⋅llist) → udom⋅llist, 'a⋅llist → ('a → 'b⋅llist) → 'b⋅llist)⋅bindU⋅LNil⋅f = LNil› 3. ‹COERCE(udom⋅llist → (udom → udom⋅llist) → udom⋅llist, 'a⋅llist → ('a → 'b⋅llist) → 'b⋅llist)⋅bindU⋅(LCons⋅x⋅xs)⋅f = COERCE(udom⋅llist → udom⋅llist → udom⋅llist, 'b⋅llist → 'b⋅llist → 'b⋅llist)⋅plusU⋅(f⋅x)⋅(COERCE(udom⋅llist → (udom → udom⋅llist) → udom⋅llist, 'a⋅llist → ('a → 'b⋅llist) → 'b⋅llist)⋅bindU⋅xs⋅f)›*) (*goals: 1. ‹COERCE(udom⋅llist → (udom → udom⋅llist) → udom⋅llist, 'a⋅llist → ('a → 'b⋅llist) → 'b⋅llist)⋅bindU⋅⊥⋅(f::'a → 'b⋅llist) = ⊥› 2. ‹COERCE(udom⋅llist → (udom → udom⋅llist) → udom⋅llist, 'a⋅llist → ('a → 'b⋅llist) → 'b⋅llist)⋅bindU⋅LNil⋅(f::'a → 'b⋅llist) = LNil› 3. ‹COERCE(udom⋅llist → (udom → udom⋅llist) → udom⋅llist, 'a⋅llist → ('a → 'b⋅llist) → 'b⋅llist)⋅bindU⋅(LCons⋅(x::'a)⋅(xs::'a⋅llist))⋅(f::'a → 'b⋅llist) = COERCE(udom⋅llist → udom⋅llist → udom⋅llist, 'b⋅llist → 'b⋅llist → 'b⋅llist)⋅plusU⋅(f⋅x)⋅(COERCE(udom⋅llist → (udom → udom⋅llist) → udom⋅llist, 'a⋅llist → ('a → 'b⋅llist) → 'b⋅llist)⋅bindU⋅xs⋅f)› discuss goal 1*) apply (simp add: coerce_simp (*‹COERCE(?'c → ?'d, ?'a → ?'b)⋅(?f::?'c → ?'d) = (Λ (x::?'a). COERCE(?'d, ?'b)⋅(?f⋅(COERCE(?'a, ?'c)⋅x)))› ‹fmapU⋅(?f::udom → udom)⋅(fmapU⋅(?g::udom → udom)⋅(?xs::udom⋅?'a)) = fmapU⋅(Λ (x::udom). ?f⋅(?g⋅x))⋅?xs› ‹COERCE(?'a⋅?'f, udom⋅?'f)⋅(COERCE(udom⋅?'f, ?'a⋅?'f)⋅(?xs::udom⋅?'f)) = fmapU⋅(cast⋅DEFL(?'a))⋅?xs› ‹fmapU⋅(cast⋅DEFL(?'a))⋅(COERCE(?'a⋅?'f, udom⋅?'f)⋅(?m::?'a⋅?'f)) = COERCE(?'a⋅?'f, udom⋅?'f)⋅?m› ‹COERCE(?'b⋅?'f, ?'c⋅?'f)⋅(fmap⋅(?f::?'a → ?'b)⋅(?xs::?'a⋅?'f)) = fmap⋅(Λ (x::?'a). COERCE(?'b, ?'c)⋅(?f⋅x))⋅?xs› ‹fmap⋅(?f::?'b → ?'c)⋅(COERCE(?'a⋅?'f, ?'b⋅?'f)⋅(?xs::?'a⋅?'f)) = fmap⋅(Λ (x::?'a). ?f⋅(COERCE(?'a, ?'b)⋅x))⋅?xs› ‹fmapU⋅(?f::udom → udom)⋅(returnU⋅(?x::udom)) = returnU⋅(?f⋅?x)› ‹fmapU⋅(?f::udom → udom)⋅(bindU⋅(?m::udom⋅?'a)⋅(?k::udom → udom⋅?'a)) = bindU⋅?m⋅(Λ (x::udom). fmapU⋅?f⋅(?k⋅x))› ‹COERCE(?'a⋅?'m, ?'b⋅?'m)⋅(return⋅(?x::?'a)) = return⋅(COERCE(?'a, ?'b)⋅?x)› ‹COERCE(?'b⋅?'m, ?'c⋅?'m)⋅((?m::?'a⋅?'m) ⤜ (?k::?'a → ?'b⋅?'m)) = ?m ⤜ (Λ (x::?'a). COERCE(?'b⋅?'m, ?'c⋅?'m)⋅(?k⋅x))› ‹COERCE(?'a⋅?'m, ?'b⋅?'m)⋅(?m::?'a⋅?'m) ⤜ (?k::?'b → ?'c⋅?'m) = ?m ⤜ (Λ (x::?'a). ?k⋅(COERCE(?'a, ?'b)⋅x))› ‹fmapU⋅(?f::udom → udom)⋅zeroU = zeroU› and more 1 facts*)) (*discuss goal 2*) apply (simp add: coerce_simp (*‹COERCE(?'c → ?'d, ?'a → ?'b)⋅?f = (Λ x. COERCE(?'d, ?'b)⋅(?f⋅(COERCE(?'a, ?'c)⋅x)))› ‹fmapU⋅?f⋅(fmapU⋅?g⋅?xs) = fmapU⋅(Λ x. ?f⋅(?g⋅x))⋅?xs› ‹COERCE(?'a⋅?'f, udom⋅?'f)⋅(COERCE(udom⋅?'f, ?'a⋅?'f)⋅?xs) = fmapU⋅(cast⋅DEFL(?'a))⋅?xs› ‹fmapU⋅(cast⋅DEFL(?'a))⋅(COERCE(?'a⋅?'f, udom⋅?'f)⋅?m) = COERCE(?'a⋅?'f, udom⋅?'f)⋅?m› ‹COERCE(?'b⋅?'f, ?'c⋅?'f)⋅(fmap⋅?f⋅?xs) = fmap⋅(Λ x. COERCE(?'b, ?'c)⋅(?f⋅x))⋅?xs› ‹fmap⋅?f⋅(COERCE(?'a⋅?'f, ?'b⋅?'f)⋅?xs) = fmap⋅(Λ x. ?f⋅(COERCE(?'a, ?'b)⋅x))⋅?xs› ‹fmapU⋅?f⋅(returnU⋅?x) = returnU⋅(?f⋅?x)› ‹fmapU⋅?f⋅(bindU⋅?m⋅?k) = bindU⋅?m⋅(Λ x. fmapU⋅?f⋅(?k⋅x))› ‹COERCE(?'a⋅?'m, ?'b⋅?'m)⋅(return⋅?x) = return⋅(COERCE(?'a, ?'b)⋅?x)› ‹COERCE(?'b⋅?'m, ?'c⋅?'m)⋅(?m ⤜ ?k) = ?m ⤜ (Λ x. COERCE(?'b⋅?'m, ?'c⋅?'m)⋅(?k⋅x))› ‹COERCE(?'a⋅?'m, ?'b⋅?'m)⋅?m ⤜ ?k = ?m ⤜ (Λ x. ?k⋅(COERCE(?'a, ?'b)⋅x))› ‹fmapU⋅?f⋅zeroU = zeroU› and more 1 facts*)) (*discuss goal 3*) apply (simp add: coerce_simp (*‹COERCE(?'c → ?'d, ?'a → ?'b)⋅?f = (Λ x. COERCE(?'d, ?'b)⋅(?f⋅(COERCE(?'a, ?'c)⋅x)))› ‹fmapU⋅?f⋅(fmapU⋅?g⋅?xs) = fmapU⋅(Λ x. ?f⋅(?g⋅x))⋅?xs› ‹COERCE(?'a⋅?'f, udom⋅?'f)⋅(COERCE(udom⋅?'f, ?'a⋅?'f)⋅?xs) = fmapU⋅(cast⋅DEFL(?'a))⋅?xs› ‹fmapU⋅(cast⋅DEFL(?'a))⋅(COERCE(?'a⋅?'f, udom⋅?'f)⋅?m) = COERCE(?'a⋅?'f, udom⋅?'f)⋅?m› ‹COERCE(?'b⋅?'f, ?'c⋅?'f)⋅(fmap⋅?f⋅?xs) = fmap⋅(Λ x. COERCE(?'b, ?'c)⋅(?f⋅x))⋅?xs› ‹fmap⋅?f⋅(COERCE(?'a⋅?'f, ?'b⋅?'f)⋅?xs) = fmap⋅(Λ x. ?f⋅(COERCE(?'a, ?'b)⋅x))⋅?xs› ‹fmapU⋅?f⋅(returnU⋅?x) = returnU⋅(?f⋅?x)› ‹fmapU⋅?f⋅(bindU⋅?m⋅?k) = bindU⋅?m⋅(Λ x. fmapU⋅?f⋅(?k⋅x))› ‹COERCE(?'a⋅?'m, ?'b⋅?'m)⋅(return⋅?x) = return⋅(COERCE(?'a, ?'b)⋅?x)› ‹COERCE(?'b⋅?'m, ?'c⋅?'m)⋅(?m ⤜ ?k) = ?m ⤜ (Λ x. COERCE(?'b⋅?'m, ?'c⋅?'m)⋅(?k⋅x))› ‹COERCE(?'a⋅?'m, ?'b⋅?'m)⋅?m ⤜ ?k = ?m ⤜ (Λ x. ?k⋅(COERCE(?'a, ?'b)⋅x))› ‹fmapU⋅?f⋅zeroU = zeroU› and more 1 facts*)) (*proven 3 subgoals*) . lemma return_llist_def: "return = (Λ x. LCons⋅x⋅LNil)" unfolding return_def returnU_llist_def (*goal: ‹COERCE(udom → udom⋅llist, 'a → 'a⋅llist)⋅(Λ x. LCons⋅x⋅LNil) = (Λ x. LCons⋅x⋅LNil)›*) by (simp add: coerce_simp (*‹COERCE(?'c → ?'d, ?'a → ?'b)⋅?f = (Λ x. COERCE(?'d, ?'b)⋅(?f⋅(COERCE(?'a, ?'c)⋅x)))› ‹fmapU⋅?f⋅(fmapU⋅?g⋅?xs) = fmapU⋅(Λ x. ?f⋅(?g⋅x))⋅?xs› ‹COERCE(?'a⋅?'f, udom⋅?'f)⋅(COERCE(udom⋅?'f, ?'a⋅?'f)⋅?xs) = fmapU⋅(cast⋅DEFL(?'a))⋅?xs› ‹fmapU⋅(cast⋅DEFL(?'a))⋅(COERCE(?'a⋅?'f, udom⋅?'f)⋅?m) = COERCE(?'a⋅?'f, udom⋅?'f)⋅?m› ‹COERCE(?'b⋅?'f, ?'c⋅?'f)⋅(fmap⋅?f⋅?xs) = fmap⋅(Λ x. COERCE(?'b, ?'c)⋅(?f⋅x))⋅?xs› ‹fmap⋅?f⋅(COERCE(?'a⋅?'f, ?'b⋅?'f)⋅?xs) = fmap⋅(Λ x. ?f⋅(COERCE(?'a, ?'b)⋅x))⋅?xs› ‹fmapU⋅?f⋅(returnU⋅?x) = returnU⋅(?f⋅?x)› ‹fmapU⋅?f⋅(bindU⋅?m⋅?k) = bindU⋅?m⋅(Λ x. fmapU⋅?f⋅(?k⋅x))› ‹COERCE(?'a⋅?'m, ?'b⋅?'m)⋅(return⋅?x) = return⋅(COERCE(?'a, ?'b)⋅?x)› ‹COERCE(?'b⋅?'m, ?'c⋅?'m)⋅(?m ⤜ ?k) = ?m ⤜ (Λ x. COERCE(?'b⋅?'m, ?'c⋅?'m)⋅(?k⋅x))› ‹COERCE(?'a⋅?'m, ?'b⋅?'m)⋅?m ⤜ ?k = ?m ⤜ (Λ x. ?k⋅(COERCE(?'a, ?'b)⋅x))› ‹fmapU⋅?f⋅zeroU = zeroU› and more 1 facts*)) lemma mzero_llist_def: "mzero = LNil" unfolding mzero_def zeroU_llist_def (*goal: ‹COERCE(udom⋅llist, 'a⋅llist)⋅LNil = LNil›*) by simp lemma join_llist_simps [simp]: "join⋅(⊥::'a⋅llist⋅llist) = ⊥" "join⋅LNil = LNil" "join⋅(LCons⋅xs⋅xss) = mplus⋅xs⋅(join⋅xss)" unfolding join_def (*goals: 1. ‹(Λ m. m ⤜ (Λ x. x))⋅⊥ = ⊥› 2. ‹(Λ m. m ⤜ (Λ x. x))⋅LNil = LNil› 3. ‹(Λ m. m ⤜ (Λ x. x))⋅(LCons⋅xs⋅xss) = mplus⋅xs⋅((Λ m. m ⤜ (Λ x. x))⋅xss)›*) (*goals: 1. ‹(Λ m. m ⤜ (Λ x. x))⋅⊥ = ⊥› 2. ‹(Λ m. m ⤜ (Λ x. x))⋅LNil = LNil› 3. ‹(Λ m. m ⤜ (Λ x. x))⋅(LCons⋅xs⋅xss) = mplus⋅xs⋅((Λ m. m ⤜ (Λ x. x))⋅xss)› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*discuss goal 3*) apply simp (*proven 3 subgoals*) . end
{ "path": "afp-2025-02-12/thys/Tycon/Lazy_List_Monad.thy", "repo": "afp-2025-02-12", "sha": "c7a8d39d00ddc9a18b58ce1df18e6241a548b7e562f6734c7bed9dd2a54fbe2a" }
(* Author: Alexander Bentkamp, Universität des Saarlandes *) section ‹Alternative Lebesgue Measure Definition› theory Lebesgue_Functional imports "HOL-Analysis.Lebesgue_Measure" begin text ‹Lebesgue\_Measure.lborel is defined on the typeclass euclidean\_space, which does not allow the space dimension to be dependent on a variable. As the Lebesgue measure of higher dimensions is the product measure of the one dimensional Lebesgue measure, we can easily define a more flexible version of the Lebesgue measure as follows. This version of the Lebesgue measure measures sets of functions from nat to real whose values are undefined for arguments higher than n. These "Extensional Function Spaces" are defined in HOL/FuncSet. › definition lborel_f :: "nat ⇒ (nat ⇒ real) measure" where "lborel_f n = (Π⇩M b∈{..<n}. lborel)" lemma product_sigma_finite_interval: "product_sigma_finite (λb. interval_measure (λx. x))" unfolding product_sigma_finite_def (*goal: ‹∀i. sigma_finite_measure (interval_measure (λx. x))›*) using sigma_finite_interval_measure (*‹⟦⋀x y. x ≤ y ⟹ ?F x ≤ ?F y; ⋀a. continuous (at_right a) ?F⟧ ⟹ sigma_finite_measure (interval_measure ?F)›*) by auto lemma l_borel_f_1: "distr (lborel_f 1) lborel (λx. x 0) = lborel" unfolding lborel_f_def (*goal: ‹distr (Pi⇩M {..<1::nat} (λb::nat. lborel)) lborel (λx::nat ⇒ real. x (0::nat)) = lborel›*) using product_sigma_finite.distr_singleton[OF product_sigma_finite_interval, of 0] (*‹distr (Pi⇩M {0} (λb. interval_measure (λx. x))) (interval_measure (λx. x)) (λx. x 0) = interval_measure (λx. x)›*) lborel_eq_real (*‹lborel = interval_measure (λx. x)›*) lessThan_Suc (*‹{..<Suc (?k::nat)} = insert ?k {..<?k}›*) by auto lemma space_lborel_f: "space (lborel_f n) = Pi⇩E {..<n} (λ_. UNIV)" unfolding lborel_f_def (*goal: ‹space (Pi⇩M {..<n} (λb. lborel)) = {..<n} →⇩E UNIV›*) unfolding space_PiM space_lborel space_borel (*goal: ‹{..<n} →⇩E UNIV = {..<n} →⇩E UNIV›*) by metis lemma space_lborel_f_subset: "space (lborel_f n) ⊆ space (lborel_f (Suc n))" unfolding space_lborel_f (*goal: ‹{..<n::nat} →⇩E UNIV ⊆ {..<Suc n} →⇩E UNIV›*) apply (rule subsetI (*‹(⋀x. x ∈ ?A ⟹ x ∈ ?B) ⟹ ?A ⊆ ?B›*)) (*goal: ‹{..<n} →⇩E UNIV ⊆ {..<Suc n} →⇩E UNIV›*) apply (rule PiE_I (*‹⟦⋀x. x ∈ ?A ⟹ ?f x ∈ ?B x; ⋀x. x ∉ ?A ⟹ ?f x = undefined⟧ ⟹ ?f ∈ Pi⇩E ?A ?B›*)) (*goals: 1. ‹⋀x xa. ⟦x ∈ {..<n} →⇩E UNIV; xa ∈ {..<Suc n}⟧ ⟹ x xa ∈ UNIV› 2. ‹⋀x xa. ⟦x ∈ {..<n} →⇩E UNIV; xa ∉ {..<Suc n}⟧ ⟹ x xa = undefined› discuss goal 1*) apply blast (*discuss goal 2*) apply (metis PiE_E (*‹⟦?f ∈ Pi⇩E ?A ?B; ⟦?x ∈ ?A; ?f ?x ∈ ?B ?x⟧ ⟹ ?thesis; ⟦?x ∉ ?A; ?f ?x = undefined⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*) Suc_n_not_le_n (*‹¬ Suc ?n ≤ ?n›*) le_cases (*‹⟦?x ≤ ?y ⟹ ?P; ?y ≤ ?x ⟹ ?P⟧ ⟹ ?P›*) lessThan_subset_iff (*‹({..<?x} ⊆ {..<?y}) = (?x ≤ ?y)›*) subsetCE (*‹⟦?A ⊆ ?B; ?c ∉ ?A ⟹ ?P; ?c ∈ ?B ⟹ ?P⟧ ⟹ ?P›*)) (*proven 2 subgoals*) . lemma space_lborel_add_dim: assumes "f ∈ space (lborel_f n)" shows "f(n:=x) ∈ space (lborel_f (Suc n))" unfolding space_lborel_f (*goal: ‹f(n := x) ∈ {..<Suc n} →⇩E UNIV›*) using assms (*‹f ∈ space (lborel_f n)›*) lessThan_Suc (*‹{..<Suc ?k} = insert ?k {..<?k}›*) space_lborel_f (*‹space (lborel_f ?n) = {..<?n} →⇩E UNIV›*) by auto lemma integral_lborel_f: assumes "f ∈ borel_measurable (lborel_f (Suc n))" shows "integral⇧N (lborel_f (Suc n)) f = ∫⁺ y. ∫⁺ x. f (x(n := y)) ∂lborel_f n ∂lborel" unfolding lborel_f_def (*goal: ‹integral⇧N (Pi⇩M {..<Suc n} (λb. lborel)) f = ∫⁺ y. ∫⁺ x. f (x(n := y)) ∂Pi⇩M {..<n} (λb. lborel) ∂lborel›*) using product_sigma_finite.product_nn_integral_insert_rev[OF product_sigma_finite_interval, of "{..<n}", OF finite_lessThan _] (*‹⟦?i ∉ {..<n}; ?f ∈ borel_measurable (Pi⇩M (insert ?i {..<n}) (λb. interval_measure (λx. x)))⟧ ⟹ integral⇧N (Pi⇩M (insert ?i {..<n}) (λb. interval_measure (λx. x))) ?f = ∫⁺ y. ∫⁺ x. ?f (x(?i := y)) ∂Pi⇩M {..<n} (λb. interval_measure (λx. x)) ∂interval_measure (λx. x)›*) assms[unfolded lborel_f_def] (*‹f ∈ borel_measurable (Pi⇩M {..<Suc n} (λb. lborel))›*) lborel_eq_real (*‹lborel = interval_measure (λx. x)›*) by (simp add: lessThan_Suc (*‹{..<Suc ?k} = insert ?k {..<?k}›*)) lemma emeasure_lborel_f_Suc: assumes "A ∈ sets (lborel_f (Suc n))" assumes "⋀y. {x∈space (lborel_f n). x(n := y) ∈ A} ∈ sets (lborel_f n)" shows "emeasure (lborel_f (Suc n)) A = ∫⁺ y. emeasure (lborel_f n) {x∈space (lborel_f n). x(n := y) ∈ A} ∂lborel" proof (-) (*goal: ‹emeasure (lborel_f (Suc n)) A = ∫⁺ y. emeasure (lborel_f n) {x ∈ space (lborel_f n). x(n := y) ∈ A} ∂lborel›*) { fix x and y assume "x∈space (lborel_f n)" (*‹(x::nat ⇒ real) ∈ space (lborel_f (n::nat))›*) then have "(indicator A) (x(n := y)) = (indicator {x∈space (lborel_f n). x(n := y) ∈ A}) x" by (simp add: indicator_def (*‹indicator ?S ?x = of_bool (?x ∈ ?S)›*)) } then show "?thesis" (*goal: ‹emeasure (lborel_f (Suc n)) A = ∫⁺ y. emeasure (lborel_f n) {x ∈ space (lborel_f n). x(n := y) ∈ A} ∂lborel›*) unfolding nn_integral_indicator[OF assms ( 1 ), symmetric] nn_integral_indicator[OF assms ( 2 ), symmetric] integral_lborel_f[OF borel_measurable_indicator, OF assms ( 1 )] (*goal: ‹∫⁺ y. ∫⁺ x. indicator A (x(n := y)) ∂lborel_f n ∂lborel = ∫⁺ y. integral⇧N (lborel_f n) (indicator {x ∈ space (lborel_f n). x(n := y) ∈ A}) ∂lborel›*) using nn_integral_cong (*‹(⋀x. x ∈ space ?M ⟹ ?u x = ?v x) ⟹ integral⇧N ?M ?u = integral⇧N ?M ?v›*) by (metis (no_types, lifting)) qed lemma lborel_f_measurable_add_dim: "(λf. f(n := x)) ∈ measurable (lborel_f n) (lborel_f (Suc n))" proof (-) (*goal: ‹(λf::nat ⇒ real. f(n::nat := x::real)) ∈ lborel_f n →⇩M lborel_f (Suc n)›*) have "x ∈ space lborel" by simp have 0: "(λ(f, y). f(n := y)) ∘ (λxa. (xa, x)) = (λf. f(n := x))" unfolding comp_def (*goal: ‹(λxa. case (xa, x) of (f, x) ⇒ f(n := x)) = (λf. f(n := x))›*) using case_prod_conv (*‹(case (?a, ?b) of (c, d) ⇒ ?f c d) = ?f ?a ?b›*) by fast show "?thesis" (*goal: ‹(λf. f(n := x)) ∈ lborel_f n →⇩M lborel_f (Suc n)›*) unfolding lborel_f_def (*goal: ‹(λf. f(n := x)) ∈ Pi⇩M {..<n} (λb. lborel) →⇩M Pi⇩M {..<Suc n} (λb. lborel)›*) using measurable_comp[OF measurable_Pair2' [ of x lborel "Pi⇩M {..<n} (λb. lborel)" , OF ‹x ∈ space lborel› ] measurable_add_dim [ of n "{..<n}" "λb. lborel" ], unfolded 0] (*‹(λf. f(n := x)) ∈ Pi⇩M {..<n} (λb. lborel) →⇩M Pi⇩M (insert n {..<n}) (λb. lborel)›*) lessThan_Suc (*‹{..<Suc ?k} = insert ?k {..<?k}›*) by auto qed lemma sets_lborel_f_sub_dim: assumes "A ∈ sets (lborel_f (Suc n))" shows "{x. x(n := y) ∈ A} ∩ space (lborel_f n) ∈ sets (lborel_f n)" proof (-) (*goal: ‹{x::nat ⇒ real. x(n::nat := y::real) ∈ (A::(nat ⇒ real) set)} ∩ space (lborel_f n) ∈ sets (lborel_f n)›*) have "(λf. f(n := y)) -` A ∩ space (lborel_f n) ∈ sets (lborel_f n)" using measurable_sets[OF lborel_f_measurable_add_dim assms] (*‹(λf::nat ⇒ real. f(n::nat := ?x1::real)) -` (A::(nat ⇒ real) set) ∩ space (lborel_f n) ∈ sets (lborel_f n)›*) by auto moreover have "(λf. f(n := y)) -` A = {x. x(n := y) ∈ A}" by auto finally (*calculation: ‹{x. x(n := y) ∈ A} ∩ space (lborel_f n) ∈ sets (lborel_f n)›*) show "?thesis" (*goal: ‹{x. x(n := y) ∈ A} ∩ space (lborel_f n) ∈ sets (lborel_f n)›*) by metis qed lemma lborel_f_measurable_restrict: assumes "m ≤ n" shows "(λf. restrict f {..<m}) ∈ measurable (lborel_f n) (lborel_f m)" using measurable_restrict_subset (*‹?J ⊆ ?L ⟹ (λf. restrict f ?J) ∈ Pi⇩M ?L ?M →⇩M Pi⇩M ?J ?M›*) lborel_f_def (*‹lborel_f (?n::nat) = Pi⇩M {..<?n} (λb::nat. lborel)›*) assms (*‹(m::nat) ≤ (n::nat)›*) by auto lemma lborel_measurable_sub_dim: "(λf. restrict f {..<n}) ∈ measurable (lborel_f (Suc n)) (lborel_f n)" using lborel_f_measurable_restrict[of "n" "Suc n"] (*‹n ≤ Suc n ⟹ (λf. restrict f {..<n}) ∈ lborel_f (Suc n) →⇩M lborel_f n›*) by linarith lemma measurable_lborel_component [measurable]: assumes "k<n" shows "(λx. x k) ∈ borel_measurable (lborel_f n)" unfolding lborel_f_def (*goal: ‹(λx. x k) ∈ borel_measurable (Pi⇩M {..<n} (λb. lborel))›*) using assms (*‹k < n›*) measurable_PiM_component_rev (*‹⟦?i ∈ ?I; ?f ∈ ?M ?i →⇩M ?N⟧ ⟹ (λx. ?f (x ?i)) ∈ Pi⇩M ?I ?M →⇩M ?N›*) by simp end
{ "path": "afp-2025-02-12/thys/Deep_Learning/Lebesgue_Functional.thy", "repo": "afp-2025-02-12", "sha": "49570adf912a3050daa21c75156b8fe32738c3c4233119a473ef9689e7654b5e" }
subsection‹GoedelVariantHOML2possInS4.thy› text‹The same as GoedelVariantHOML2poss, but now in logic S4, where the proof of theorem Th3 fails.› theory GoedelVariantHOML2possInS4 imports HOMLinHOLonlyS4 begin consts PositiveProperty::"(e⇒σ)⇒σ" ("P") axiomatization where Ax1: "⌊P φ ❙∧ P ψ ❙⊃ P (φ ❙. ψ)⌋" abbreviation "PosProps Φ ≡ ❙∀φ. Φ φ ❙⊃ P φ" abbreviation "ConjOfPropsFrom φ Φ ≡ ❙□(❙∀z. φ z ❙↔ (❙∀ψ. Φ ψ ❙⊃ ψ z))" axiomatization where Ax1Gen: "⌊(PosProps Φ ❙∧ ConjOfPropsFrom φ Φ) ❙⊃ P φ⌋" axiomatization where Ax2a: "⌊P φ ❙∨⇧e P ❙~φ⌋" definition God ("G") where "G x ≡ ❙∀φ. P φ ❙⊃ φ x" abbreviation PropertyInclusion ("_❙⊃⇩N_") where "φ ❙⊃⇩N ψ ≡ ❙□(❙∀y::e. φ y ❙⊃ ψ y)" definition Essence ("_Ess._") where "φ Ess. x ≡ φ x ❙∧ (❙∀ψ. ψ x ❙⊃ (φ ❙⊃⇩N ψ))" axiomatization where Ax2b: "⌊P φ ❙⊃ ❙□ P φ⌋" lemma Ax2b': "⌊❙¬P φ ❙⊃ ❙□(❙¬P φ)⌋" using Ax2a (*‹⌊P ?φ ❙∨⇧e P ❙~?φ⌋›*) Ax2b (*‹⌊P (?φ::e ⇒ i ⇒ bool) ❙⊃ ❙□P ?φ⌋›*) by blast theorem Th1: "⌊G x ❙⊃ G Ess. x⌋" using Ax2a (*‹⌊P ?φ ❙∨⇧e P ❙~?φ⌋›*) Ax2b (*‹⌊P ?φ ❙⊃ ❙□P ?φ⌋›*) Essence_def (*‹?φEss.?x ≡ λw. ?φ ?x w ∧ (∀x. (x ?x ❙⊃ ❙□(λv. ∀xa. (?φ xa ❙⊃ x xa) v)) w)›*) God_def (*‹G ?x ≡ λw. ∀x. (P x ❙⊃ x ?x) w›*) by (smt (verit)) definition NecExist ("E") where "E x ≡ ❙∀φ. φ Ess. x ❙⊃ ❙□(❙∃x. φ x)" axiomatization where Ax3: "⌊P E⌋" axiomatization where Ax4: "⌊P φ ❙∧ (φ ❙⊃⇩N ψ) ❙⊃ P ψ⌋" theorem Th2: "⌊G x ❙⊃ ❙□(❙∃y. G y)⌋" using Ax3 (*‹⌊P E⌋›*) Th1 (*‹⌊G ?x ❙⊃ GEss.?x⌋›*) God_def (*‹G ?x ≡ λw. ∀x. (P x ❙⊃ x ?x) w›*) NecExist_def (*‹E ?x ≡ λw. ∀x. (xEss.?x ❙⊃ ❙□Mexipossb x) w›*) by smt theorem Th3: "⌊❙◇(❙∃x. G x) ❙⊃ ❙□(❙∃y. G y)⌋" ―‹nitpick sledgehammer› oops ―‹Open problem› end
{ "path": "afp-2025-02-12/thys/Notes_On_Goedels_Ontological_Argument/GoedelVariantHOML2possInS4.thy", "repo": "afp-2025-02-12", "sha": "9ef4c67545e29be1efd290a9d2440a4b6392a2535ec9d5235b512110f3757d29" }
(* Title: JinjaThreads/J/WellType.thy Author: Tobias Nipkow, Andreas Lochbihler *) section ‹Well-typedness of Jinja expressions› theory WellType imports Expr State "../Common/ExternalCallWF" "../Common/WellForm" "../Common/SemiType" begin declare Listn.lesub_list_impl_same_size[simp del] declare listE_length [simp del] type_synonym env = "vname ⇀ ty" inductive WT :: "(ty ⇒ ty ⇒ ty ⇒ bool) ⇒ 'addr J_prog ⇒ env ⇒ 'addr expr ⇒ ty ⇒ bool" ("_,_,_ ⊢ _ :: _" [51,51,51,51]50) and WTs :: "(ty ⇒ ty ⇒ ty ⇒ bool) ⇒ 'addr J_prog ⇒ env ⇒ 'addr expr list ⇒ ty list ⇒ bool" ("_,_,_ ⊢ _ [::] _" [51,51,51,51]50) for is_lub :: "ty ⇒ ty ⇒ ty ⇒ bool" ("⊢ lub'((_,/ _)') = _" [51,51,51] 50) and P :: "'addr J_prog" where WTNew: "is_class P C ⟹ is_lub,P,E ⊢ new C :: Class C" | WTNewArray: "⟦ is_lub,P,E ⊢ e :: Integer; is_type P (T⌊⌉) ⟧ ⟹ is_lub,P,E ⊢ newA T⌊e⌉ :: T⌊⌉" | WTCast: "⟦ is_lub,P,E ⊢ e :: T; P ⊢ U ≤ T ∨ P ⊢ T ≤ U; is_type P U ⟧ ⟹ is_lub,P,E ⊢ Cast U e :: U" | WTInstanceOf: "⟦ is_lub,P,E ⊢ e :: T; P ⊢ U ≤ T ∨ P ⊢ T ≤ U; is_type P U; is_refT U ⟧ ⟹ is_lub,P,E ⊢ e instanceof U :: Boolean" | WTVal: "typeof v = Some T ⟹ is_lub,P,E ⊢ Val v :: T" | WTVar: "E V = Some T ⟹ is_lub,P,E ⊢ Var V :: T" | WTBinOp: "⟦ is_lub,P,E ⊢ e1 :: T1; is_lub,P,E ⊢ e2 :: T2; P ⊢ T1«bop»T2 :: T ⟧ ⟹ is_lub,P,E ⊢ e1«bop»e2 :: T" | WTLAss: "⟦ E V = Some T; is_lub,P,E ⊢ e :: T'; P ⊢ T' ≤ T; V ≠ this ⟧ ⟹ is_lub,P,E ⊢ V:=e :: Void" | WTAAcc: "⟦ is_lub,P,E ⊢ a :: T⌊⌉; is_lub,P,E ⊢ i :: Integer ⟧ ⟹ is_lub,P,E ⊢ a⌊i⌉ :: T" | WTAAss: "⟦ is_lub,P,E ⊢ a :: T⌊⌉; is_lub,P,E ⊢ i :: Integer; is_lub,P,E ⊢ e :: T'; P ⊢ T' ≤ T ⟧ ⟹ is_lub,P,E ⊢ a⌊i⌉ := e :: Void" | WTALength: "is_lub,P,E ⊢ a :: T⌊⌉ ⟹ is_lub,P,E ⊢ a∙length :: Integer" | WTFAcc: "⟦ is_lub,P,E ⊢ e :: U; class_type_of' U = ⌊C⌋; P ⊢ C sees F:T (fm) in D ⟧ ⟹ is_lub,P,E ⊢ e∙F{D} :: T" | WTFAss: "⟦ is_lub,P,E ⊢ e₁ :: U; class_type_of' U = ⌊C⌋; P ⊢ C sees F:T (fm) in D; is_lub,P,E ⊢ e₂ :: T'; P ⊢ T' ≤ T ⟧ ⟹ is_lub,P,E ⊢ e₁∙F{D}:=e₂ :: Void" | WTCAS: "⟦ is_lub,P,E ⊢ e1 :: U; class_type_of' U = ⌊C⌋; P ⊢ C sees F:T (fm) in D; volatile fm; is_lub,P,E ⊢ e2 :: T'; P ⊢ T' ≤ T; is_lub,P,E ⊢ e3 :: T''; P ⊢ T'' ≤ T ⟧ ⟹ is_lub,P,E ⊢ e1∙compareAndSwap(D∙F, e2, e3) :: Boolean" | WTCall: "⟦ is_lub,P,E ⊢ e :: U; class_type_of' U = ⌊C⌋; P ⊢ C sees M:Ts → T = meth in D; is_lub,P,E ⊢ es [::] Ts'; P ⊢ Ts' [≤] Ts ⟧ ⟹ is_lub,P,E ⊢ e∙M(es) :: T" | WTBlock: "⟦ is_type P T; is_lub,P,E(V ↦ T) ⊢ e :: T'; case vo of None ⇒ True | ⌊v⌋ ⇒ ∃T'. typeof v = ⌊T'⌋ ∧ P ⊢ T' ≤ T ⟧ ⟹ is_lub,P,E ⊢ {V:T=vo; e} :: T'" | WTSynchronized: "⟦ is_lub,P,E ⊢ o' :: T; is_refT T; T ≠ NT; is_lub,P,E ⊢ e :: T' ⟧ ⟹ is_lub,P,E ⊢ sync(o') e :: T'" ― ‹Note that insync is not statically typable.› | WTSeq: "⟦ is_lub,P,E ⊢ e₁::T₁; is_lub,P,E ⊢ e₂::T₂ ⟧ ⟹ is_lub,P,E ⊢ e₁;;e₂ :: T₂" | WTCond: "⟦ is_lub,P,E ⊢ e :: Boolean; is_lub,P,E ⊢ e₁::T₁; is_lub,P,E ⊢ e₂::T₂; ⊢ lub(T₁, T₂) = T ⟧ ⟹ is_lub,P,E ⊢ if (e) e₁ else e₂ :: T" | WTWhile: "⟦ is_lub,P,E ⊢ e :: Boolean; is_lub,P,E ⊢ c::T ⟧ ⟹ is_lub,P,E ⊢ while (e) c :: Void" | WTThrow: "⟦ is_lub,P,E ⊢ e :: Class C; P ⊢ C ≼⇧* Throwable ⟧ ⟹ is_lub,P,E ⊢ throw e :: Void" | WTTry: "⟦ is_lub,P,E ⊢ e₁ :: T; is_lub,P,E(V ↦ Class C) ⊢ e₂ :: T; P ⊢ C ≼⇧* Throwable ⟧ ⟹ is_lub,P,E ⊢ try e₁ catch(C V) e₂ :: T" | WTNil: "is_lub,P,E ⊢ [] [::] []" | WTCons: "⟦ is_lub,P,E ⊢ e :: T; is_lub,P,E ⊢ es [::] Ts ⟧ ⟹ is_lub,P,E ⊢ e#es [::] T#Ts" abbreviation WT' :: "'addr J_prog ⇒ env ⇒ 'addr expr ⇒ ty ⇒ bool" ("_,_ ⊢ _ :: _" [51,51,51] 50) where "WT' P ≡ WT (TypeRel.is_lub P) P" abbreviation WTs' :: "'addr J_prog ⇒ env ⇒ 'addr expr list ⇒ ty list ⇒ bool" ("_,_ ⊢ _ [::] _" [51,51,51] 50) where "WTs' P ≡ WTs (TypeRel.is_lub P) P" declare WT_WTs.intros[intro!] inductive_simps WTs_iffs [iff]: "is_lub',P,E ⊢ [] [::] Ts" "is_lub',P,E ⊢ e#es [::] T#Ts" "is_lub',P,E ⊢ e#es [::] Ts" lemma WTs_conv_list_all2: fixes is_lub shows "is_lub,P,E ⊢ es [::] Ts = list_all2 (WT is_lub P E) es Ts" apply (induct es arbitrary: Ts) (*goals: 1. ‹⋀Ts. (is_lub,P,E ⊢ [] [::] Ts) = list_all2 (WT is_lub P E) [] Ts› 2. ‹⋀a es Ts. (⋀Ts. (is_lub,P,E ⊢ es [::] Ts) = list_all2 (WT is_lub P E) es Ts) ⟹ (is_lub,P,E ⊢ a # es [::] Ts) = list_all2 (WT is_lub P E) (a # es) Ts› discuss goal 1*) apply ((auto simp add: list_all2_Cons1 (*‹list_all2 ?P (?x # ?xs) ?ys = (∃z zs. ?ys = z # zs ∧ ?P ?x z ∧ list_all2 ?P ?xs zs)›*) elim: WTs.cases (*‹⟦?is_lub,?P,?a1.0 ⊢ ?a2.0 [::] ?a3.0; ⋀E. ⟦?a1.0 = E; ?a2.0 = []; ?a3.0 = []⟧ ⟹ ?Pa; ⋀E e T es Ts. ⟦?a1.0 = E; ?a2.0 = e # es; ?a3.0 = T # Ts; ?is_lub,?P,E ⊢ e :: T; ?is_lub,?P,E ⊢ es [::] Ts⟧ ⟹ ?Pa⟧ ⟹ ?Pa›*))[1]) (*discuss goal 2*) apply ((auto simp add: list_all2_Cons1 (*‹list_all2 ?P (?x # ?xs) ?ys = (∃z zs. ?ys = z # zs ∧ ?P ?x z ∧ list_all2 ?P ?xs zs)›*) elim: WTs.cases (*‹⟦?is_lub,?P,?a1.0 ⊢ ?a2.0 [::] ?a3.0; ⋀E. ⟦?a1.0 = E; ?a2.0 = []; ?a3.0 = []⟧ ⟹ ?Pa; ⋀E e T es Ts. ⟦?a1.0 = E; ?a2.0 = e # es; ?a3.0 = T # Ts; ?is_lub,?P,E ⊢ e :: T; ?is_lub,?P,E ⊢ es [::] Ts⟧ ⟹ ?Pa⟧ ⟹ ?Pa›*))[1]) (*proven 2 subgoals*) . lemma WTs_append [iff]: "⋀is_lub Ts. (is_lub,P,E ⊢ es₁ @ es₂ [::] Ts) = (∃Ts₁ Ts₂. Ts = Ts₁ @ Ts₂ ∧ is_lub,P,E ⊢ es₁ [::] Ts₁ ∧ is_lub,P,E ⊢ es₂[::]Ts₂)" by (auto simp add: WTs_conv_list_all2 (*‹(?is_lub,?P,?E ⊢ ?es [::] ?Ts) = list_all2 (WT ?is_lub ?P ?E) ?es ?Ts›*) list_all2_append1 (*‹list_all2 ?P (?xs @ ?ys) ?zs = (∃us vs. ?zs = us @ vs ∧ length us = length ?xs ∧ length vs = length ?ys ∧ list_all2 ?P ?xs us ∧ list_all2 ?P ?ys vs)›*) dest: list_all2_lengthD[symmetric] (*‹list_all2 ?P ?xs ?ys ⟹ length ?ys = length ?xs›*)) inductive_simps WT_iffs [iff]: "is_lub',P,E ⊢ Val v :: T" "is_lub',P,E ⊢ Var V :: T" "is_lub',P,E ⊢ e₁;;e₂ :: T₂" "is_lub',P,E ⊢ {V:T=vo; e} :: T'" inductive_cases WT_elim_cases[elim!]: "is_lub',P,E ⊢ V :=e :: T" "is_lub',P,E ⊢ sync(o') e :: T" "is_lub',P,E ⊢ if (e) e₁ else e₂ :: T" "is_lub',P,E ⊢ while (e) c :: T" "is_lub',P,E ⊢ throw e :: T" "is_lub',P,E ⊢ try e₁ catch(C V) e₂ :: T" "is_lub',P,E ⊢ Cast D e :: T" "is_lub',P,E ⊢ e instanceof U :: T" "is_lub',P,E ⊢ a∙F{D} :: T" "is_lub',P,E ⊢ a∙F{D} := v :: T" "is_lub',P,E ⊢ e∙compareAndSwap(D∙F, e', e'') :: T" "is_lub',P,E ⊢ e₁ «bop» e₂ :: T" "is_lub',P,E ⊢ new C :: T" "is_lub',P,E ⊢ newA T⌊e⌉ :: T'" "is_lub',P,E ⊢ a⌊i⌉ := e :: T" "is_lub',P,E ⊢ a⌊i⌉ :: T" "is_lub',P,E ⊢ a∙length :: T" "is_lub',P,E ⊢ e∙M(ps) :: T" "is_lub',P,E ⊢ sync(o') e :: T" "is_lub',P,E ⊢ insync(a) e :: T" lemma fixes is_lub :: "ty ⇒ ty ⇒ ty ⇒ bool" ("⊢ lub'((_,/ _)') = _" [51,51,51] 50) assumes is_lub_unique: "⋀T1 T2 T3 T4. ⟦ ⊢ lub(T1, T2) = T3; ⊢ lub(T1, T2) = T4 ⟧ ⟹ T3 = T4" shows WT_unique: "⟦ is_lub,P,E ⊢ e :: T; is_lub,P,E ⊢ e :: T' ⟧ ⟹ T = T'" and WTs_unique: "⟦ is_lub,P,E ⊢ es [::] Ts; is_lub,P,E ⊢ es [::] Ts' ⟧ ⟹ Ts = Ts'" apply (induct arbitrary: T' and Ts' rule: WT_WTs.inducts) (*goals: 1. ‹⋀(C::String.literal) (E::String.literal ⇒ ty option) T'::ty. ⟦is_class (P::'a J_prog) C; is_lub,P,E ⊢ new C :: T'⟧ ⟹ Class C = T'› 2. ‹⋀(E::String.literal ⇒ ty option) (e::'a expr) (T::ty) T'::ty. ⟦is_lub,(P::'a J_prog),E ⊢ e :: Integer; ⋀T'::ty. is_lub,P,E ⊢ e :: T' ⟹ Integer = T'; is_type P (T⌊⌉); is_lub,P,E ⊢ newA T⌊e⌉ :: T'⟧ ⟹ T⌊⌉ = T'› 3. ‹⋀(E::String.literal ⇒ ty option) (e::'a expr) (T::ty) (U::ty) T'::ty. ⟦is_lub,(P::'a J_prog),E ⊢ e :: T; ⋀T'::ty. is_lub,P,E ⊢ e :: T' ⟹ T = T'; P ⊢ U ≤ T ∨ P ⊢ T ≤ U; is_type P U; is_lub,P,E ⊢ Cast U e :: T'⟧ ⟹ U = T'› 4. ‹⋀(E::String.literal ⇒ ty option) (e::'a expr) (T::ty) (U::ty) T'::ty. ⟦is_lub,(P::'a J_prog),E ⊢ e :: T; ⋀T'::ty. is_lub,P,E ⊢ e :: T' ⟹ T = T'; P ⊢ U ≤ T ∨ P ⊢ T ≤ U; is_type P U; is_refT U; is_lub,P,E ⊢ e instanceof U :: T'⟧ ⟹ Boolean = T'› 5. ‹⋀(v::'a val) (T::ty) (E::String.literal ⇒ ty option) T'::ty. ⟦typeof v = ⌊T⌋; is_lub,(P::'a J_prog),E ⊢ Val v :: T'⟧ ⟹ T = T'› 6. ‹⋀(E::String.literal ⇒ ty option) (V::String.literal) (T::ty) T'::ty. ⟦E V = ⌊T⌋; is_lub,(P::'a J_prog),E ⊢ Var V :: T'⟧ ⟹ T = T'› 7. ‹⋀(E::String.literal ⇒ ty option) (e1::'a expr) (T1::ty) (e2::'a expr) (T2::ty) (bop::bop) (T::ty) T'::ty. ⟦is_lub,(P::'a J_prog),E ⊢ e1 :: T1; ⋀T'::ty. is_lub,P,E ⊢ e1 :: T' ⟹ T1 = T'; is_lub,P,E ⊢ e2 :: T2; ⋀T'::ty. is_lub,P,E ⊢ e2 :: T' ⟹ T2 = T'; P ⊢ T1«bop»T2 :: T; is_lub,P,E ⊢ e1 «bop» e2 :: T'⟧ ⟹ T = T'› 8. ‹⋀(E::String.literal ⇒ ty option) (V::String.literal) (T::ty) (e::'a expr) (T'::ty) T'a::ty. ⟦E V = ⌊T⌋; is_lub,(P::'a J_prog),E ⊢ e :: T'; ⋀T'a::ty. is_lub,P,E ⊢ e :: T'a ⟹ T' = T'a; P ⊢ T' ≤ T; V ≠ this; is_lub,P,E ⊢ V:=e :: T'a⟧ ⟹ Void = T'a› 9. ‹⋀(E::String.literal ⇒ ty option) (a::'a expr) (T::ty) (i::'a expr) T'::ty. ⟦is_lub,(P::'a J_prog),E ⊢ a :: T⌊⌉; ⋀T'::ty. is_lub,P,E ⊢ a :: T' ⟹ T⌊⌉ = T'; is_lub,P,E ⊢ i :: Integer; ⋀T'::ty. is_lub,P,E ⊢ i :: T' ⟹ Integer = T'; is_lub,P,E ⊢ a⌊i⌉ :: T'⟧ ⟹ T = T'› 10. ‹⋀(E::String.literal ⇒ ty option) (a::'a expr) (T::ty) (i::'a expr) (e::'a expr) (T'::ty) T'a::ty. ⟦is_lub,(P::'a J_prog),E ⊢ a :: T⌊⌉; ⋀T'::ty. is_lub,P,E ⊢ a :: T' ⟹ T⌊⌉ = T'; is_lub,P,E ⊢ i :: Integer; ⋀T'::ty. is_lub,P,E ⊢ i :: T' ⟹ Integer = T'; is_lub,P,E ⊢ e :: T'; ⋀T'a::ty. is_lub,P,E ⊢ e :: T'a ⟹ T' = T'a; P ⊢ T' ≤ T; is_lub,P,E ⊢ a⌊i⌉ := e :: T'a⟧ ⟹ Void = T'a› 11. ‹⋀(E::String.literal ⇒ ty option) (a::'a expr) (T::ty) T'::ty. ⟦is_lub,(P::'a J_prog),E ⊢ a :: T⌊⌉; ⋀T'::ty. is_lub,P,E ⊢ a :: T' ⟹ T⌊⌉ = T'; is_lub,P,E ⊢ a∙length :: T'⟧ ⟹ Integer = T'› 12. ‹⋀(E::String.literal ⇒ ty option) (e::'a expr) (U::ty) (C::String.literal) (F::String.literal) (T::ty) (fm::fmod) (D::String.literal) T'::ty. ⟦is_lub,(P::'a J_prog),E ⊢ e :: U; ⋀T'::ty. is_lub,P,E ⊢ e :: T' ⟹ U = T'; class_type_of' U = ⌊C⌋; P ⊢ C sees F:T (fm) in D; is_lub,P,E ⊢ e∙F{D} :: T'⟧ ⟹ T = T'› 13. ‹⋀(E::String.literal ⇒ ty option) (e₁::'a expr) (U::ty) (C::String.literal) (F::String.literal) (T::ty) (fm::fmod) (D::String.literal) (e₂::'a expr) (T'::ty) T'a::ty. ⟦is_lub,(P::'a J_prog),E ⊢ e₁ :: U; ⋀T'::ty. is_lub,P,E ⊢ e₁ :: T' ⟹ U = T'; class_type_of' U = ⌊C⌋; P ⊢ C sees F:T (fm) in D; is_lub,P,E ⊢ e₂ :: T'; ⋀T'a::ty. is_lub,P,E ⊢ e₂ :: T'a ⟹ T' = T'a; P ⊢ T' ≤ T; is_lub,P,E ⊢ e₁∙F{D} := e₂ :: T'a⟧ ⟹ Void = T'a› 14. ‹⋀(E::String.literal ⇒ ty option) (e1::'a expr) (U::ty) (C::String.literal) (F::String.literal) (T::ty) (fm::fmod) (D::String.literal) (e2::'a expr) (T'::ty) (e3::'a expr) (T''::ty) T'a::ty. ⟦is_lub,(P::'a J_prog),E ⊢ e1 :: U; ⋀T'::ty. is_lub,P,E ⊢ e1 :: T' ⟹ U = T'; class_type_of' U = ⌊C⌋; P ⊢ C sees F:T (fm) in D; volatile fm; is_lub,P,E ⊢ e2 :: T'; ⋀T'a::ty. is_lub,P,E ⊢ e2 :: T'a ⟹ T' = T'a; P ⊢ T' ≤ T; is_lub,P,E ⊢ e3 :: T''; ⋀T'::ty. is_lub,P,E ⊢ e3 :: T' ⟹ T'' = T'; P ⊢ T'' ≤ T; is_lub,P,E ⊢ e1∙compareAndSwap(D∙F, e2, e3) :: T'a⟧ ⟹ Boolean = T'a› 15. ‹⋀(E::String.literal ⇒ ty option) (e::'a expr) (U::ty) (C::String.literal) (M::String.literal) (Ts::ty list) (T::ty) (meth::(String.literal list × 'a expr) option) (D::String.literal) (es::'a expr list) (Ts'::ty list) T'::ty. ⟦is_lub,(P::'a J_prog),E ⊢ e :: U; ⋀T'::ty. is_lub,P,E ⊢ e :: T' ⟹ U = T'; class_type_of' U = ⌊C⌋; P ⊢ C sees M: Ts→T = meth in D; is_lub,P,E ⊢ es [::] Ts'; ⋀Ts'a::ty list. is_lub,P,E ⊢ es [::] Ts'a ⟹ Ts' = Ts'a; P ⊢ Ts' [≤] Ts; is_lub,P,E ⊢ e∙M(es) :: T'⟧ ⟹ T = T'› 16. ‹⋀(T::ty) (E::String.literal ⇒ ty option) (V::String.literal) (e::'a expr) (T'::ty) (vo::'a val option) T'a::ty. ⟦is_type (P::'a J_prog) T; is_lub,P,E(V ↦ T) ⊢ e :: T'; ⋀T'a::ty. is_lub,P,E(V ↦ T) ⊢ e :: T'a ⟹ T' = T'a; case vo of None ⇒ True | ⌊v::'a val⌋ ⇒ ∃T'::ty. typeof v = ⌊T'⌋ ∧ P ⊢ T' ≤ T; is_lub,P,E ⊢ {V:T=vo; e} :: T'a⟧ ⟹ T' = T'a› 17. ‹⋀(E::String.literal ⇒ ty option) (o'::'a expr) (T::ty) (e::'a expr) (T'::ty) T'a::ty. ⟦is_lub,(P::'a J_prog),E ⊢ o' :: T; ⋀T'::ty. is_lub,P,E ⊢ o' :: T' ⟹ T = T'; is_refT T; T ≠ NT; is_lub,P,E ⊢ e :: T'; ⋀T'a::ty. is_lub,P,E ⊢ e :: T'a ⟹ T' = T'a; is_lub,P,E ⊢ sync(o') e :: T'a⟧ ⟹ T' = T'a› 18. ‹⋀(E::String.literal ⇒ ty option) (e₁::'a expr) (T₁::ty) (e₂::'a expr) (T₂::ty) T'::ty. ⟦is_lub,(P::'a J_prog),E ⊢ e₁ :: T₁; ⋀T'::ty. is_lub,P,E ⊢ e₁ :: T' ⟹ T₁ = T'; is_lub,P,E ⊢ e₂ :: T₂; ⋀T'::ty. is_lub,P,E ⊢ e₂ :: T' ⟹ T₂ = T'; is_lub,P,E ⊢ e₁;; e₂ :: T'⟧ ⟹ T₂ = T'› 19. ‹⋀(E::String.literal ⇒ ty option) (e::'a expr) (e₁::'a expr) (T₁::ty) (e₂::'a expr) (T₂::ty) (T::ty) T'::ty. ⟦is_lub,(P::'a J_prog),E ⊢ e :: Boolean; ⋀T'::ty. is_lub,P,E ⊢ e :: T' ⟹ Boolean = T'; is_lub,P,E ⊢ e₁ :: T₁; ⋀T'::ty. is_lub,P,E ⊢ e₁ :: T' ⟹ T₁ = T'; is_lub,P,E ⊢ e₂ :: T₂; ⋀T'::ty. is_lub,P,E ⊢ e₂ :: T' ⟹ T₂ = T'; ⊢ lub(T₁, T₂) = T; is_lub,P,E ⊢ if (e) e₁ else e₂ :: T'⟧ ⟹ T = T'› 20. ‹⋀(E::String.literal ⇒ ty option) (e::'a expr) (c::'a expr) (T::ty) T'::ty. ⟦is_lub,(P::'a J_prog),E ⊢ e :: Boolean; ⋀T'::ty. is_lub,P,E ⊢ e :: T' ⟹ Boolean = T'; is_lub,P,E ⊢ c :: T; ⋀T'::ty. is_lub,P,E ⊢ c :: T' ⟹ T = T'; is_lub,P,E ⊢ while (e) c :: T'⟧ ⟹ Void = T'› 21. ‹⋀(E::String.literal ⇒ ty option) (e::'a expr) (C::String.literal) T'::ty. ⟦is_lub,(P::'a J_prog),E ⊢ e :: Class C; ⋀T'::ty. is_lub,P,E ⊢ e :: T' ⟹ Class C = T'; P ⊢ C ≼⇧* Throwable; is_lub,P,E ⊢ throw e :: T'⟧ ⟹ Void = T'› 22. ‹⋀(E::String.literal ⇒ ty option) (e₁::'a expr) (T::ty) (V::String.literal) (C::String.literal) (e₂::'a expr) T'::ty. ⟦is_lub,(P::'a J_prog),E ⊢ e₁ :: T; ⋀T'::ty. is_lub,P,E ⊢ e₁ :: T' ⟹ T = T'; is_lub,P,E(V ↦ Class C) ⊢ e₂ :: T; ⋀T'::ty. is_lub,P,E(V ↦ Class C) ⊢ e₂ :: T' ⟹ T = T'; P ⊢ C ≼⇧* Throwable; is_lub,P,E ⊢ try e₁ catch(C V) e₂ :: T'⟧ ⟹ T = T'› 23. ‹⋀(E::String.literal ⇒ ty option) Ts'::ty list. is_lub,(P::'a J_prog),E ⊢ [] [::] Ts' ⟹ [] = Ts'› 24. ‹⋀(E::String.literal ⇒ ty option) (e::'a expr) (T::ty) (es::'a expr list) (Ts::ty list) Ts'::ty list. ⟦is_lub,(P::'a J_prog),E ⊢ e :: T; ⋀T'::ty. is_lub,P,E ⊢ e :: T' ⟹ T = T'; is_lub,P,E ⊢ es [::] Ts; ⋀Ts'::ty list. is_lub,P,E ⊢ es [::] Ts' ⟹ Ts = Ts'; is_lub,P,E ⊢ e # es [::] Ts'⟧ ⟹ T # Ts = Ts'› discuss goal 1*) apply blast (*discuss goal 2*) apply blast (*discuss goal 3*) apply blast (*discuss goal 4*) apply blast (*discuss goal 5*) apply fastforce (*discuss goal 6*) apply fastforce (*discuss goal 7*) apply (fastforce dest: WT_binop_fun (*‹⟦?P ⊢ ?T1.0«?bop»?T2.0 :: ?T; ?P ⊢ ?T1.0«?bop»?T2.0 :: ?T'⟧ ⟹ ?T = ?T'›*)) (*discuss goal 8*) apply fastforce (*discuss goal 9*) apply fastforce (*discuss goal 10*) apply fastforce (*discuss goal 11*) apply fastforce (*discuss goal 12*) apply (fastforce dest: sees_field_fun (*‹⟦?P ⊢ ?C sees ?F:?T (?fm) in ?D; ?P ⊢ ?C sees ?F:?T' (?fm') in ?D'⟧ ⟹ ?T' = ?T ∧ ?D' = ?D ∧ ?fm = ?fm'›*)) (*discuss goal 13*) apply (fastforce dest: sees_field_fun (*‹⟦?P ⊢ ?C sees ?F:?T (?fm) in ?D; ?P ⊢ ?C sees ?F:?T' (?fm') in ?D'⟧ ⟹ ?T' = ?T ∧ ?D' = ?D ∧ ?fm = ?fm'›*)) (*discuss goal 14*) apply blast (*discuss goal 15*) apply (fastforce 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›*)) (*discuss goal 16*) apply fastforce (*discuss goal 17*) apply fastforce (*discuss goal 18*) apply fastforce (*discuss goal 19*) apply (blast dest: is_lub_unique (*‹⟦⊢ lub(?T1.0, ?T2.0) = ?T3.0; ⊢ lub(?T1.0, ?T2.0) = ?T4.0⟧ ⟹ ?T3.0 = ?T4.0›*)) (*discuss goal 20*) apply fastforce (*discuss goal 21*) apply fastforce (*discuss goal 22*) apply blast (*discuss goal 23*) apply fastforce (*discuss goal 24*) apply fastforce (*proven 24 subgoals*) . lemma fixes is_lub shows wt_env_mono: "is_lub,P,E ⊢ e :: T ⟹ (⋀E'. E ⊆⇩m E' ⟹ is_lub,P,E' ⊢ e :: T)" and wts_env_mono: "is_lub,P,E ⊢ es [::] Ts ⟹ (⋀E'. E ⊆⇩m E' ⟹ is_lub,P,E' ⊢ es [::] Ts)" apply (induct rule: WT_WTs.inducts (*‹⟦(?is_lub::ty ⇒ ty ⇒ ty ⇒ bool),(?P::?'addr J_prog),(?x1.0::String.literal ⇒ ty option) ⊢ (?x2.0::?'addr expr) :: ?x3.0::ty; ⋀(C::String.literal) E::String.literal ⇒ ty option. is_class ?P C ⟹ (?P1.0::(String.literal ⇒ ty option) ⇒ ?'addr expr ⇒ ty ⇒ bool) E (new C) (Class C); ⋀(E::String.literal ⇒ ty option) (e::?'addr expr) T::ty. ⟦?is_lub,?P,E ⊢ e :: Integer; ?P1.0 E e Integer; is_type ?P (T⌊⌉)⟧ ⟹ ?P1.0 E (newA T⌊e⌉) (T⌊⌉); ⋀(E::String.literal ⇒ ty option) (e::?'addr expr) (T::ty) U::ty. ⟦?is_lub,?P,E ⊢ e :: T; ?P1.0 E e T; ?P ⊢ U ≤ T ∨ ?P ⊢ T ≤ U; is_type ?P U⟧ ⟹ ?P1.0 E (Cast U e) U; ⋀(E::String.literal ⇒ ty option) (e::?'addr expr) (T::ty) U::ty. ⟦?is_lub,?P,E ⊢ e :: T; ?P1.0 E e T; ?P ⊢ U ≤ T ∨ ?P ⊢ T ≤ U; is_type ?P U; is_refT U⟧ ⟹ ?P1.0 E (e instanceof U) Boolean; ⋀(v::?'addr val) (T::ty) E::String.literal ⇒ ty option. typeof v = ⌊T⌋ ⟹ ?P1.0 E (Val v) T; ⋀(E::String.literal ⇒ ty option) (V::String.literal) T::ty. E V = ⌊T⌋ ⟹ ?P1.0 E (Var V) T; ⋀(E::String.literal ⇒ ty option) (e1::?'addr expr) (T1::ty) (e2::?'addr expr) (T2::ty) (bop::bop) T::ty. ⟦?is_lub,?P,E ⊢ e1 :: T1; ?P1.0 E e1 T1; ?is_lub,?P,E ⊢ e2 :: T2; ?P1.0 E e2 T2; ?P ⊢ T1«bop»T2 :: T⟧ ⟹ ?P1.0 E (e1 «bop» e2) T; ⋀(E::String.literal ⇒ ty option) (V::String.literal) (T::ty) (e::?'addr expr) T'::ty. ⟦E V = ⌊T⌋; ?is_lub,?P,E ⊢ e :: T'; ?P1.0 E e T'; ?P ⊢ T' ≤ T; V ≠ this⟧ ⟹ ?P1.0 E (V:=e) Void; ⋀(E::String.literal ⇒ ty option) (a::?'addr expr) (T::ty) i::?'addr expr. ⟦?is_lub,?P,E ⊢ a :: T⌊⌉; ?P1.0 E a (T⌊⌉); ?is_lub,?P,E ⊢ i :: Integer; ?P1.0 E i Integer⟧ ⟹ ?P1.0 E (a⌊i⌉) T; ⋀(E::String.literal ⇒ ty option) (a::?'addr expr) (T::ty) (i::?'addr expr) (e::?'addr expr) T'::ty. ⟦?is_lub,?P,E ⊢ a :: T⌊⌉; ?P1.0 E a (T⌊⌉); ?is_lub,?P,E ⊢ i :: Integer; ?P1.0 E i Integer; ?is_lub,?P,E ⊢ e :: T'; ?P1.0 E e T'; ?P ⊢ T' ≤ T⟧ ⟹ ?P1.0 E (a⌊i⌉ := e) Void; ⋀(E::String.literal ⇒ ty option) (a::?'addr expr) T::ty. ⟦?is_lub,?P,E ⊢ a :: T⌊⌉; ?P1.0 E a (T⌊⌉)⟧ ⟹ ?P1.0 E (a∙length) Integer; ⋀(E::String.literal ⇒ ty option) (e::?'addr expr) (U::ty) (C::String.literal) (F::String.literal) (T::ty) (fm::fmod) D::String.literal. ⟦?is_lub,?P,E ⊢ e :: U; ?P1.0 E e U; class_type_of' U = ⌊C⌋; ?P ⊢ C sees F:T (fm) in D⟧ ⟹ ?P1.0 E (e∙F{D}) T; ⋀(E::String.literal ⇒ ty option) (e₁::?'addr expr) (U::ty) (C::String.literal) (F::String.literal) (T::ty) (fm::fmod) (D::String.literal) (e₂::?'addr expr) T'::ty. ⟦?is_lub,?P,E ⊢ e₁ :: U; ?P1.0 E e₁ U; class_type_of' U = ⌊C⌋; ?P ⊢ C sees F:T (fm) in D; ?is_lub,?P,E ⊢ e₂ :: T'; ?P1.0 E e₂ T'; ?P ⊢ T' ≤ T⟧ ⟹ ?P1.0 E (e₁∙F{D} := e₂) Void; ⋀(E::String.literal ⇒ ty option) (e1::?'addr expr) (U::ty) (C::String.literal) (F::String.literal) (T::ty) (fm::fmod) (D::String.literal) (e2::?'addr expr) (T'::ty) (e3::?'addr expr) T''::ty. ⟦?is_lub,?P,E ⊢ e1 :: U; ?P1.0 E e1 U; class_type_of' U = ⌊C⌋; ?P ⊢ C sees F:T (fm) in D; volatile fm; ?is_lub,?P,E ⊢ e2 :: T'; ?P1.0 E e2 T'; ?P ⊢ T' ≤ T; ?is_lub,?P,E ⊢ e3 :: T''; ?P1.0 E e3 T''; ?P ⊢ T'' ≤ T⟧ ⟹ ?P1.0 E (e1∙compareAndSwap(D∙F, e2, e3)) Boolean; ⋀(E::String.literal ⇒ ty option) (e::?'addr expr) (U::ty) (C::String.literal) (M::String.literal) (Ts::ty list) (T::ty) (meth::(String.literal list × ?'addr expr) option) (D::String.literal) (es::?'addr expr list) Ts'::ty list. ⟦?is_lub,?P,E ⊢ e :: U; ?P1.0 E e U; class_type_of' U = ⌊C⌋; ?P ⊢ C sees M: Ts→T = meth in D; ?is_lub,?P,E ⊢ es [::] Ts'; (?P2.0::(String.literal ⇒ ty option) ⇒ ?'addr expr list ⇒ ty list ⇒ bool) E es Ts'; ?P ⊢ Ts' [≤] Ts⟧ ⟹ ?P1.0 E (e∙M(es)) T; ⋀(T::ty) (E::String.literal ⇒ ty option) (V::String.literal) (e::?'addr expr) (T'::ty) vo::?'addr val option. ⟦is_type ?P T; ?is_lub,?P,E(V ↦ T) ⊢ e :: T'; ?P1.0 (E(V ↦ T)) e T'; case vo of None ⇒ True | ⌊v::?'addr val⌋ ⇒ ∃T'::ty. typeof v = ⌊T'⌋ ∧ ?P ⊢ T' ≤ T⟧ ⟹ ?P1.0 E {V:T=vo; e} T'; ⋀(E::String.literal ⇒ ty option) (o'::?'addr expr) (T::ty) (e::?'addr expr) T'::ty. ⟦?is_lub,?P,E ⊢ o' :: T; ?P1.0 E o' T; is_refT T; T ≠ NT; ?is_lub,?P,E ⊢ e :: T'; ?P1.0 E e T'⟧ ⟹ ?P1.0 E (sync(o') e) T'; ⋀(E::String.literal ⇒ ty option) (e₁::?'addr expr) (T₁::ty) (e₂::?'addr expr) T₂::ty. ⟦?is_lub,?P,E ⊢ e₁ :: T₁; ?P1.0 E e₁ T₁; ?is_lub,?P,E ⊢ e₂ :: T₂; ?P1.0 E e₂ T₂⟧ ⟹ ?P1.0 E (e₁;; e₂) T₂; ⋀(E::String.literal ⇒ ty option) (e::?'addr expr) (e₁::?'addr expr) (T₁::ty) (e₂::?'addr expr) (T₂::ty) T::ty. ⟦?is_lub,?P,E ⊢ e :: Boolean; ?P1.0 E e Boolean; ?is_lub,?P,E ⊢ e₁ :: T₁; ?P1.0 E e₁ T₁; ?is_lub,?P,E ⊢ e₂ :: T₂; ?P1.0 E e₂ T₂; ?is_lub T₁ T₂ T⟧ ⟹ ?P1.0 E (if (e) e₁ else e₂) T; ⋀(E::String.literal ⇒ ty option) (e::?'addr expr) (c::?'addr expr) T::ty. ⟦?is_lub,?P,E ⊢ e :: Boolean; ?P1.0 E e Boolean; ?is_lub,?P,E ⊢ c :: T; ?P1.0 E c T⟧ ⟹ ?P1.0 E (while (e) c) Void; ⋀(E::String.literal ⇒ ty option) (e::?'addr expr) C::String.literal. ⟦?is_lub,?P,E ⊢ e :: Class C; ?P1.0 E e (Class C); ?P ⊢ C ≼⇧* Throwable⟧ ⟹ ?P1.0 E (throw e) Void; ⋀(E::String.literal ⇒ ty option) (e₁::?'addr expr) (T::ty) (V::String.literal) (C::String.literal) e₂::?'addr expr. ⟦?is_lub,?P,E ⊢ e₁ :: T; ?P1.0 E e₁ T; ?is_lub,?P,E(V ↦ Class C) ⊢ e₂ :: T; ?P1.0 (E(V ↦ Class C)) e₂ T; ?P ⊢ C ≼⇧* Throwable⟧ ⟹ ?P1.0 E (try e₁ catch(C V) e₂) T; ⋀E::String.literal ⇒ ty option. ?P2.0 E [] []; ⋀(E::String.literal ⇒ ty option) (e::?'addr expr) (T::ty) (es::?'addr expr list) Ts::ty list. ⟦?is_lub,?P,E ⊢ e :: T; ?P1.0 E e T; ?is_lub,?P,E ⊢ es [::] Ts; ?P2.0 E es Ts⟧ ⟹ ?P2.0 E (e # es) (T # Ts)⟧ ⟹ ?P1.0 ?x1.0 ?x2.0 ?x3.0› ‹⟦(?is_lub::ty ⇒ ty ⇒ ty ⇒ bool),(?P::?'addr J_prog),(?x4.0::String.literal ⇒ ty option) ⊢ (?x5.0::?'addr expr list) [::] ?x6.0::ty list; ⋀(C::String.literal) E::String.literal ⇒ ty option. is_class ?P C ⟹ (?P1.0::(String.literal ⇒ ty option) ⇒ ?'addr expr ⇒ ty ⇒ bool) E (new C) (Class C); ⋀(E::String.literal ⇒ ty option) (e::?'addr expr) T::ty. ⟦?is_lub,?P,E ⊢ e :: Integer; ?P1.0 E e Integer; is_type ?P (T⌊⌉)⟧ ⟹ ?P1.0 E (newA T⌊e⌉) (T⌊⌉); ⋀(E::String.literal ⇒ ty option) (e::?'addr expr) (T::ty) U::ty. ⟦?is_lub,?P,E ⊢ e :: T; ?P1.0 E e T; ?P ⊢ U ≤ T ∨ ?P ⊢ T ≤ U; is_type ?P U⟧ ⟹ ?P1.0 E (Cast U e) U; ⋀(E::String.literal ⇒ ty option) (e::?'addr expr) (T::ty) U::ty. ⟦?is_lub,?P,E ⊢ e :: T; ?P1.0 E e T; ?P ⊢ U ≤ T ∨ ?P ⊢ T ≤ U; is_type ?P U; is_refT U⟧ ⟹ ?P1.0 E (e instanceof U) Boolean; ⋀(v::?'addr val) (T::ty) E::String.literal ⇒ ty option. typeof v = ⌊T⌋ ⟹ ?P1.0 E (Val v) T; ⋀(E::String.literal ⇒ ty option) (V::String.literal) T::ty. E V = ⌊T⌋ ⟹ ?P1.0 E (Var V) T; ⋀(E::String.literal ⇒ ty option) (e1::?'addr expr) (T1::ty) (e2::?'addr expr) (T2::ty) (bop::bop) T::ty. ⟦?is_lub,?P,E ⊢ e1 :: T1; ?P1.0 E e1 T1; ?is_lub,?P,E ⊢ e2 :: T2; ?P1.0 E e2 T2; ?P ⊢ T1«bop»T2 :: T⟧ ⟹ ?P1.0 E (e1 «bop» e2) T; ⋀(E::String.literal ⇒ ty option) (V::String.literal) (T::ty) (e::?'addr expr) T'::ty. ⟦E V = ⌊T⌋; ?is_lub,?P,E ⊢ e :: T'; ?P1.0 E e T'; ?P ⊢ T' ≤ T; V ≠ this⟧ ⟹ ?P1.0 E (V:=e) Void; ⋀(E::String.literal ⇒ ty option) (a::?'addr expr) (T::ty) i::?'addr expr. ⟦?is_lub,?P,E ⊢ a :: T⌊⌉; ?P1.0 E a (T⌊⌉); ?is_lub,?P,E ⊢ i :: Integer; ?P1.0 E i Integer⟧ ⟹ ?P1.0 E (a⌊i⌉) T; ⋀(E::String.literal ⇒ ty option) (a::?'addr expr) (T::ty) (i::?'addr expr) (e::?'addr expr) T'::ty. ⟦?is_lub,?P,E ⊢ a :: T⌊⌉; ?P1.0 E a (T⌊⌉); ?is_lub,?P,E ⊢ i :: Integer; ?P1.0 E i Integer; ?is_lub,?P,E ⊢ e :: T'; ?P1.0 E e T'; ?P ⊢ T' ≤ T⟧ ⟹ ?P1.0 E (a⌊i⌉ := e) Void; ⋀(E::String.literal ⇒ ty option) (a::?'addr expr) T::ty. ⟦?is_lub,?P,E ⊢ a :: T⌊⌉; ?P1.0 E a (T⌊⌉)⟧ ⟹ ?P1.0 E (a∙length) Integer; ⋀(E::String.literal ⇒ ty option) (e::?'addr expr) (U::ty) (C::String.literal) (F::String.literal) (T::ty) (fm::fmod) D::String.literal. ⟦?is_lub,?P,E ⊢ e :: U; ?P1.0 E e U; class_type_of' U = ⌊C⌋; ?P ⊢ C sees F:T (fm) in D⟧ ⟹ ?P1.0 E (e∙F{D}) T; ⋀(E::String.literal ⇒ ty option) (e₁::?'addr expr) (U::ty) (C::String.literal) (F::String.literal) (T::ty) (fm::fmod) (D::String.literal) (e₂::?'addr expr) T'::ty. ⟦?is_lub,?P,E ⊢ e₁ :: U; ?P1.0 E e₁ U; class_type_of' U = ⌊C⌋; ?P ⊢ C sees F:T (fm) in D; ?is_lub,?P,E ⊢ e₂ :: T'; ?P1.0 E e₂ T'; ?P ⊢ T' ≤ T⟧ ⟹ ?P1.0 E (e₁∙F{D} := e₂) Void; ⋀(E::String.literal ⇒ ty option) (e1::?'addr expr) (U::ty) (C::String.literal) (F::String.literal) (T::ty) (fm::fmod) (D::String.literal) (e2::?'addr expr) (T'::ty) (e3::?'addr expr) T''::ty. ⟦?is_lub,?P,E ⊢ e1 :: U; ?P1.0 E e1 U; class_type_of' U = ⌊C⌋; ?P ⊢ C sees F:T (fm) in D; volatile fm; ?is_lub,?P,E ⊢ e2 :: T'; ?P1.0 E e2 T'; ?P ⊢ T' ≤ T; ?is_lub,?P,E ⊢ e3 :: T''; ?P1.0 E e3 T''; ?P ⊢ T'' ≤ T⟧ ⟹ ?P1.0 E (e1∙compareAndSwap(D∙F, e2, e3)) Boolean; ⋀(E::String.literal ⇒ ty option) (e::?'addr expr) (U::ty) (C::String.literal) (M::String.literal) (Ts::ty list) (T::ty) (meth::(String.literal list × ?'addr expr) option) (D::String.literal) (es::?'addr expr list) Ts'::ty list. ⟦?is_lub,?P,E ⊢ e :: U; ?P1.0 E e U; class_type_of' U = ⌊C⌋; ?P ⊢ C sees M: Ts→T = meth in D; ?is_lub,?P,E ⊢ es [::] Ts'; (?P2.0::(String.literal ⇒ ty option) ⇒ ?'addr expr list ⇒ ty list ⇒ bool) E es Ts'; ?P ⊢ Ts' [≤] Ts⟧ ⟹ ?P1.0 E (e∙M(es)) T; ⋀(T::ty) (E::String.literal ⇒ ty option) (V::String.literal) (e::?'addr expr) (T'::ty) vo::?'addr val option. ⟦is_type ?P T; ?is_lub,?P,E(V ↦ T) ⊢ e :: T'; ?P1.0 (E(V ↦ T)) e T'; case vo of None ⇒ True | ⌊v::?'addr val⌋ ⇒ ∃T'::ty. typeof v = ⌊T'⌋ ∧ ?P ⊢ T' ≤ T⟧ ⟹ ?P1.0 E {V:T=vo; e} T'; ⋀(E::String.literal ⇒ ty option) (o'::?'addr expr) (T::ty) (e::?'addr expr) T'::ty. ⟦?is_lub,?P,E ⊢ o' :: T; ?P1.0 E o' T; is_refT T; T ≠ NT; ?is_lub,?P,E ⊢ e :: T'; ?P1.0 E e T'⟧ ⟹ ?P1.0 E (sync(o') e) T'; ⋀(E::String.literal ⇒ ty option) (e₁::?'addr expr) (T₁::ty) (e₂::?'addr expr) T₂::ty. ⟦?is_lub,?P,E ⊢ e₁ :: T₁; ?P1.0 E e₁ T₁; ?is_lub,?P,E ⊢ e₂ :: T₂; ?P1.0 E e₂ T₂⟧ ⟹ ?P1.0 E (e₁;; e₂) T₂; ⋀(E::String.literal ⇒ ty option) (e::?'addr expr) (e₁::?'addr expr) (T₁::ty) (e₂::?'addr expr) (T₂::ty) T::ty. ⟦?is_lub,?P,E ⊢ e :: Boolean; ?P1.0 E e Boolean; ?is_lub,?P,E ⊢ e₁ :: T₁; ?P1.0 E e₁ T₁; ?is_lub,?P,E ⊢ e₂ :: T₂; ?P1.0 E e₂ T₂; ?is_lub T₁ T₂ T⟧ ⟹ ?P1.0 E (if (e) e₁ else e₂) T; ⋀(E::String.literal ⇒ ty option) (e::?'addr expr) (c::?'addr expr) T::ty. ⟦?is_lub,?P,E ⊢ e :: Boolean; ?P1.0 E e Boolean; ?is_lub,?P,E ⊢ c :: T; ?P1.0 E c T⟧ ⟹ ?P1.0 E (while (e) c) Void; ⋀(E::String.literal ⇒ ty option) (e::?'addr expr) C::String.literal. ⟦?is_lub,?P,E ⊢ e :: Class C; ?P1.0 E e (Class C); ?P ⊢ C ≼⇧* Throwable⟧ ⟹ ?P1.0 E (throw e) Void; ⋀(E::String.literal ⇒ ty option) (e₁::?'addr expr) (T::ty) (V::String.literal) (C::String.literal) e₂::?'addr expr. ⟦?is_lub,?P,E ⊢ e₁ :: T; ?P1.0 E e₁ T; ?is_lub,?P,E(V ↦ Class C) ⊢ e₂ :: T; ?P1.0 (E(V ↦ Class C)) e₂ T; ?P ⊢ C ≼⇧* Throwable⟧ ⟹ ?P1.0 E (try e₁ catch(C V) e₂) T; ⋀E::String.literal ⇒ ty option. ?P2.0 E [] []; ⋀(E::String.literal ⇒ ty option) (e::?'addr expr) (T::ty) (es::?'addr expr list) Ts::ty list. ⟦?is_lub,?P,E ⊢ e :: T; ?P1.0 E e T; ?is_lub,?P,E ⊢ es [::] Ts; ?P2.0 E es Ts⟧ ⟹ ?P2.0 E (e # es) (T # Ts)⟧ ⟹ ?P2.0 ?x4.0 ?x5.0 ?x6.0›*)) (*goals: 1. ‹⋀C E E'. ⟦is_class P C; E ⊆⇩m E'⟧ ⟹ is_lub,P,E' ⊢ new C :: Class C› 2. ‹⋀E e T E'. ⟦is_lub,P,E ⊢ e :: Integer; ⋀E'. E ⊆⇩m E' ⟹ is_lub,P,E' ⊢ e :: Integer; is_type P (T⌊⌉); E ⊆⇩m E'⟧ ⟹ is_lub,P,E' ⊢ newA T⌊e⌉ :: T⌊⌉› 3. ‹⋀E e T U E'. ⟦is_lub,P,E ⊢ e :: T; ⋀E'. E ⊆⇩m E' ⟹ is_lub,P,E' ⊢ e :: T; P ⊢ U ≤ T ∨ P ⊢ T ≤ U; is_type P U; E ⊆⇩m E'⟧ ⟹ is_lub,P,E' ⊢ Cast U e :: U› 4. ‹⋀E e T U E'. ⟦is_lub,P,E ⊢ e :: T; ⋀E'. E ⊆⇩m E' ⟹ is_lub,P,E' ⊢ e :: T; P ⊢ U ≤ T ∨ P ⊢ T ≤ U; is_type P U; is_refT U; E ⊆⇩m E'⟧ ⟹ is_lub,P,E' ⊢ e instanceof U :: Boolean› 5. ‹⋀v T E E'. ⟦typeof v = ⌊T⌋; E ⊆⇩m E'⟧ ⟹ is_lub,P,E' ⊢ Val v :: T› 6. ‹⋀E V T E'. ⟦E V = ⌊T⌋; E ⊆⇩m E'⟧ ⟹ is_lub,P,E' ⊢ Var V :: T› 7. ‹⋀E e1 T1 e2 T2 bop T E'. ⟦is_lub,P,E ⊢ e1 :: T1; ⋀E'. E ⊆⇩m E' ⟹ is_lub,P,E' ⊢ e1 :: T1; is_lub,P,E ⊢ e2 :: T2; ⋀E'. E ⊆⇩m E' ⟹ is_lub,P,E' ⊢ e2 :: T2; P ⊢ T1«bop»T2 :: T; E ⊆⇩m E'⟧ ⟹ is_lub,P,E' ⊢ e1 «bop» e2 :: T› 8. ‹⋀E V T e T' E'. ⟦E V = ⌊T⌋; is_lub,P,E ⊢ e :: T'; ⋀E'. E ⊆⇩m E' ⟹ is_lub,P,E' ⊢ e :: T'; P ⊢ T' ≤ T; V ≠ this; E ⊆⇩m E'⟧ ⟹ is_lub,P,E' ⊢ V:=e :: Void› 9. ‹⋀E a T i E'. ⟦is_lub,P,E ⊢ a :: T⌊⌉; ⋀E'. E ⊆⇩m E' ⟹ is_lub,P,E' ⊢ a :: T⌊⌉; is_lub,P,E ⊢ i :: Integer; ⋀E'. E ⊆⇩m E' ⟹ is_lub,P,E' ⊢ i :: Integer; E ⊆⇩m E'⟧ ⟹ is_lub,P,E' ⊢ a⌊i⌉ :: T› 10. ‹⋀E a T i e T' E'. ⟦is_lub,P,E ⊢ a :: T⌊⌉; ⋀E'. E ⊆⇩m E' ⟹ is_lub,P,E' ⊢ a :: T⌊⌉; is_lub,P,E ⊢ i :: Integer; ⋀E'. E ⊆⇩m E' ⟹ is_lub,P,E' ⊢ i :: Integer; is_lub,P,E ⊢ e :: T'; ⋀E'. E ⊆⇩m E' ⟹ is_lub,P,E' ⊢ e :: T'; P ⊢ T' ≤ T; E ⊆⇩m E'⟧ ⟹ is_lub,P,E' ⊢ a⌊i⌉ := e :: Void› 11. ‹⋀E a T E'. ⟦is_lub,P,E ⊢ a :: T⌊⌉; ⋀E'. E ⊆⇩m E' ⟹ is_lub,P,E' ⊢ a :: T⌊⌉; E ⊆⇩m E'⟧ ⟹ is_lub,P,E' ⊢ a∙length :: Integer› 12. ‹⋀E e U C F T fm D E'. ⟦is_lub,P,E ⊢ e :: U; ⋀E'. E ⊆⇩m E' ⟹ is_lub,P,E' ⊢ e :: U; class_type_of' U = ⌊C⌋; P ⊢ C sees F:T (fm) in D; E ⊆⇩m E'⟧ ⟹ is_lub,P,E' ⊢ e∙F{D} :: T› 13. ‹⋀E e₁ U C F T fm D e₂ T' E'. ⟦is_lub,P,E ⊢ e₁ :: U; ⋀E'. E ⊆⇩m E' ⟹ is_lub,P,E' ⊢ e₁ :: U; class_type_of' U = ⌊C⌋; P ⊢ C sees F:T (fm) in D; is_lub,P,E ⊢ e₂ :: T'; ⋀E'. E ⊆⇩m E' ⟹ is_lub,P,E' ⊢ e₂ :: T'; P ⊢ T' ≤ T; E ⊆⇩m E'⟧ ⟹ is_lub,P,E' ⊢ e₁∙F{D} := e₂ :: Void› 14. ‹⋀E e1 U C F T fm D e2 T' e3 T'' E'. ⟦is_lub,P,E ⊢ e1 :: U; ⋀E'. E ⊆⇩m E' ⟹ is_lub,P,E' ⊢ e1 :: U; class_type_of' U = ⌊C⌋; P ⊢ C sees F:T (fm) in D; volatile fm; is_lub,P,E ⊢ e2 :: T'; ⋀E'. E ⊆⇩m E' ⟹ is_lub,P,E' ⊢ e2 :: T'; P ⊢ T' ≤ T; is_lub,P,E ⊢ e3 :: T''; ⋀E'. E ⊆⇩m E' ⟹ is_lub,P,E' ⊢ e3 :: T''; P ⊢ T'' ≤ T; E ⊆⇩m E'⟧ ⟹ is_lub,P,E' ⊢ e1∙compareAndSwap(D∙F, e2, e3) :: Boolean› 15. ‹⋀E e U C M Ts T meth D es Ts' E'. ⟦is_lub,P,E ⊢ e :: U; ⋀E'. E ⊆⇩m E' ⟹ is_lub,P,E' ⊢ e :: U; class_type_of' U = ⌊C⌋; P ⊢ C sees M: Ts→T = meth in D; is_lub,P,E ⊢ es [::] Ts'; ⋀E'. E ⊆⇩m E' ⟹ is_lub,P,E' ⊢ es [::] Ts'; P ⊢ Ts' [≤] Ts; E ⊆⇩m E'⟧ ⟹ is_lub,P,E' ⊢ e∙M(es) :: T› 16. ‹⋀T E V e T' vo E'. ⟦is_type P T; is_lub,P,E(V ↦ T) ⊢ e :: T'; ⋀E'. E(V ↦ T) ⊆⇩m E' ⟹ is_lub,P,E' ⊢ e :: T'; case vo of None ⇒ True | ⌊v⌋ ⇒ ∃T'. typeof v = ⌊T'⌋ ∧ P ⊢ T' ≤ T; E ⊆⇩m E'⟧ ⟹ is_lub,P,E' ⊢ {V:T=vo; e} :: T'› 17. ‹⋀E o' T e T' E'. ⟦is_lub,P,E ⊢ o' :: T; ⋀E'. E ⊆⇩m E' ⟹ is_lub,P,E' ⊢ o' :: T; is_refT T; T ≠ NT; is_lub,P,E ⊢ e :: T'; ⋀E'. E ⊆⇩m E' ⟹ is_lub,P,E' ⊢ e :: T'; E ⊆⇩m E'⟧ ⟹ is_lub,P,E' ⊢ sync(o') e :: T'› 18. ‹⋀E e₁ T₁ e₂ T₂ E'. ⟦is_lub,P,E ⊢ e₁ :: T₁; ⋀E'. E ⊆⇩m E' ⟹ is_lub,P,E' ⊢ e₁ :: T₁; is_lub,P,E ⊢ e₂ :: T₂; ⋀E'. E ⊆⇩m E' ⟹ is_lub,P,E' ⊢ e₂ :: T₂; E ⊆⇩m E'⟧ ⟹ is_lub,P,E' ⊢ e₁;; e₂ :: T₂› 19. ‹⋀E e e₁ T₁ e₂ T₂ T E'. ⟦is_lub,P,E ⊢ e :: Boolean; ⋀E'. E ⊆⇩m E' ⟹ is_lub,P,E' ⊢ e :: Boolean; is_lub,P,E ⊢ e₁ :: T₁; ⋀E'. E ⊆⇩m E' ⟹ is_lub,P,E' ⊢ e₁ :: T₁; is_lub,P,E ⊢ e₂ :: T₂; ⋀E'. E ⊆⇩m E' ⟹ is_lub,P,E' ⊢ e₂ :: T₂; is_lub T₁ T₂ T; E ⊆⇩m E'⟧ ⟹ is_lub,P,E' ⊢ if (e) e₁ else e₂ :: T› 20. ‹⋀E e c T E'. ⟦is_lub,P,E ⊢ e :: Boolean; ⋀E'. E ⊆⇩m E' ⟹ is_lub,P,E' ⊢ e :: Boolean; is_lub,P,E ⊢ c :: T; ⋀E'. E ⊆⇩m E' ⟹ is_lub,P,E' ⊢ c :: T; E ⊆⇩m E'⟧ ⟹ is_lub,P,E' ⊢ while (e) c :: Void› 21. ‹⋀E e C E'. ⟦is_lub,P,E ⊢ e :: Class C; ⋀E'. E ⊆⇩m E' ⟹ is_lub,P,E' ⊢ e :: Class C; P ⊢ C ≼⇧* Throwable; E ⊆⇩m E'⟧ ⟹ is_lub,P,E' ⊢ throw e :: Void› 22. ‹⋀E e₁ T V C e₂ E'. ⟦is_lub,P,E ⊢ e₁ :: T; ⋀E'. E ⊆⇩m E' ⟹ is_lub,P,E' ⊢ e₁ :: T; is_lub,P,E(V ↦ Class C) ⊢ e₂ :: T; ⋀E'. E(V ↦ Class C) ⊆⇩m E' ⟹ is_lub,P,E' ⊢ e₂ :: T; P ⊢ C ≼⇧* Throwable; E ⊆⇩m E'⟧ ⟹ is_lub,P,E' ⊢ try e₁ catch(C V) e₂ :: T› 23. ‹⋀E E'. E ⊆⇩m E' ⟹ is_lub,P,E' ⊢ [] [::] []› 24. ‹⋀E e T es Ts E'. ⟦is_lub,P,E ⊢ e :: T; ⋀E'. E ⊆⇩m E' ⟹ is_lub,P,E' ⊢ e :: T; is_lub,P,E ⊢ es [::] Ts; ⋀E'. E ⊆⇩m E' ⟹ is_lub,P,E' ⊢ es [::] Ts; E ⊆⇩m E'⟧ ⟹ is_lub,P,E' ⊢ e # es [::] T # Ts› discuss goal 1*) apply (simp add: WTNew (*‹is_class ?P ?C ⟹ ?is_lub,?P,?E ⊢ new ?C :: Class ?C›*)) (*discuss goal 2*) apply (simp add: WTNewArray (*‹⟦?is_lub,?P,?E ⊢ ?e :: Integer; is_type ?P (?T⌊⌉)⟧ ⟹ ?is_lub,?P,?E ⊢ newA ?T⌊?e⌉ :: ?T⌊⌉›*)) (*discuss goal 3*) apply (fastforce simp: WTCast (*‹⟦?is_lub,?P,?E ⊢ ?e :: ?T; ?P ⊢ ?U ≤ ?T ∨ ?P ⊢ ?T ≤ ?U; is_type ?P ?U⟧ ⟹ ?is_lub,?P,?E ⊢ Cast ?U ?e :: ?U›*)) (*discuss goal 4*) apply (fastforce simp: WTInstanceOf (*‹⟦?is_lub,?P,?E ⊢ ?e :: ?T; ?P ⊢ ?U ≤ ?T ∨ ?P ⊢ ?T ≤ ?U; is_type ?P ?U; is_refT ?U⟧ ⟹ ?is_lub,?P,?E ⊢ ?e instanceof ?U :: Boolean›*)) (*discuss goal 5*) apply (fastforce simp: WTVal (*‹typeof ?v = ⌊?T⌋ ⟹ ?is_lub,?P,?E ⊢ Val ?v :: ?T›*)) (*discuss goal 6*) apply (simp add: WTVar (*‹?E ?V = ⌊?T⌋ ⟹ ?is_lub,?P,?E ⊢ Var ?V :: ?T›*) map_le_def (*‹(?m₁ ⊆⇩m ?m₂) = (∀a∈dom ?m₁. ?m₁ a = ?m₂ a)›*) dom_def (*‹dom ?m = {a. ?m a ≠ None}›*)) (*discuss goal 7*) apply (fastforce simp: WTBinOp (*‹⟦(?is_lub::ty ⇒ ty ⇒ ty ⇒ bool),(?P::?'addr J_prog),(?E::String.literal ⇒ ty option) ⊢ (?e1.0::?'addr expr) :: ?T1.0::ty; ?is_lub,?P,?E ⊢ (?e2.0::?'addr expr) :: ?T2.0::ty; ?P ⊢ ?T1.0«?bop::bop»?T2.0 :: (?T::ty)⟧ ⟹ ?is_lub,?P,?E ⊢ ?e1.0 «?bop» ?e2.0 :: ?T›*)) (*discuss goal 8*) apply (force simp:map_le_def (*‹(?m₁ ⊆⇩m ?m₂) = (∀a∈dom ?m₁. ?m₁ a = ?m₂ a)›*)) (*discuss goal 9*) apply (simp add: WTAAcc (*‹⟦(?is_lub::ty ⇒ ty ⇒ ty ⇒ bool),(?P::?'addr J_prog),(?E::String.literal ⇒ ty option) ⊢ (?a::?'addr expr) :: ?T::ty⌊⌉; ?is_lub,?P,?E ⊢ (?i::?'addr expr) :: Integer⟧ ⟹ ?is_lub,?P,?E ⊢ ?a⌊?i⌉ :: ?T›*)) (*discuss goal 10*) apply (simp add: WTAAss (*‹⟦?is_lub,?P,?E ⊢ ?a :: ?T⌊⌉; ?is_lub,?P,?E ⊢ ?i :: Integer; ?is_lub,?P,?E ⊢ ?e :: ?T'; ?P ⊢ ?T' ≤ ?T⟧ ⟹ ?is_lub,?P,?E ⊢ ?a⌊?i⌉ := ?e :: Void›*)) (*top goal: ‹⋀E a T i e T' E'. ⟦is_lub,P,E ⊢ a :: T⌊⌉; ⋀E'. E ⊆⇩m E' ⟹ is_lub,P,E' ⊢ a :: T⌊⌉; is_lub,P,E ⊢ i :: Integer; ⋀E'. E ⊆⇩m E' ⟹ is_lub,P,E' ⊢ i :: Integer; is_lub,P,E ⊢ e :: T'; ⋀E'. E ⊆⇩m E' ⟹ is_lub,P,E' ⊢ e :: T'; P ⊢ T' ≤ T; E ⊆⇩m E'⟧ ⟹ is_lub,P,E' ⊢ a⌊i⌉ := e :: Void› and 14 goals remain*) apply fastforce (*discuss goal 11*) apply (simp add: WTALength (*‹?is_lub,?P,?E ⊢ ?a :: ?T⌊⌉ ⟹ ?is_lub,?P,?E ⊢ ?a∙length :: Integer›*)) (*top goal: ‹⋀(E::String.literal ⇒ ty option) (a::'a expr) (T::ty) E'::String.literal ⇒ ty option. ⟦(is_lub::ty ⇒ ty ⇒ ty ⇒ bool),(P::'a J_prog),E ⊢ a :: T⌊⌉; ⋀E'::String.literal ⇒ ty option. E ⊆⇩m E' ⟹ is_lub,P,E' ⊢ a :: T⌊⌉; E ⊆⇩m E'⟧ ⟹ is_lub,P,E' ⊢ a∙length :: Integer› and 13 goals remain*) apply fastforce (*discuss goal 12*) apply (fastforce simp: WTFAcc (*‹⟦?is_lub,?P,?E ⊢ ?e :: ?U; class_type_of' ?U = ⌊?C⌋; ?P ⊢ ?C sees ?F:?T (?fm) in ?D⟧ ⟹ ?is_lub,?P,?E ⊢ ?e∙?F{?D} :: ?T›*)) (*discuss goal 13*) apply (fastforce simp: WTFAss (*‹⟦?is_lub,?P,?E ⊢ ?e₁ :: ?U; class_type_of' ?U = ⌊?C⌋; ?P ⊢ ?C sees ?F:?T (?fm) in ?D; ?is_lub,?P,?E ⊢ ?e₂ :: ?T'; ?P ⊢ ?T' ≤ ?T⟧ ⟹ ?is_lub,?P,?E ⊢ ?e₁∙?F{?D} := ?e₂ :: Void›*) del:WT_WTs.intros (*‹is_class ?P ?C ⟹ ?is_lub,?P,?E ⊢ new ?C :: Class ?C› ‹⟦?is_lub,?P,?E ⊢ ?e :: Integer; is_type ?P (?T⌊⌉)⟧ ⟹ ?is_lub,?P,?E ⊢ newA ?T⌊?e⌉ :: ?T⌊⌉› ‹⟦?is_lub,?P,?E ⊢ ?e :: ?T; ?P ⊢ ?U ≤ ?T ∨ ?P ⊢ ?T ≤ ?U; is_type ?P ?U⟧ ⟹ ?is_lub,?P,?E ⊢ Cast ?U ?e :: ?U› ‹⟦?is_lub,?P,?E ⊢ ?e :: ?T; ?P ⊢ ?U ≤ ?T ∨ ?P ⊢ ?T ≤ ?U; is_type ?P ?U; is_refT ?U⟧ ⟹ ?is_lub,?P,?E ⊢ ?e instanceof ?U :: Boolean› ‹typeof ?v = ⌊?T⌋ ⟹ ?is_lub,?P,?E ⊢ Val ?v :: ?T› ‹?E ?V = ⌊?T⌋ ⟹ ?is_lub,?P,?E ⊢ Var ?V :: ?T› ‹⟦?is_lub,?P,?E ⊢ ?e1.0 :: ?T1.0; ?is_lub,?P,?E ⊢ ?e2.0 :: ?T2.0; ?P ⊢ ?T1.0«?bop»?T2.0 :: ?T⟧ ⟹ ?is_lub,?P,?E ⊢ ?e1.0 «?bop» ?e2.0 :: ?T› ‹⟦?E ?V = ⌊?T⌋; ?is_lub,?P,?E ⊢ ?e :: ?T'; ?P ⊢ ?T' ≤ ?T; ?V ≠ this⟧ ⟹ ?is_lub,?P,?E ⊢ ?V:=?e :: Void› ‹⟦?is_lub,?P,?E ⊢ ?a :: ?T⌊⌉; ?is_lub,?P,?E ⊢ ?i :: Integer⟧ ⟹ ?is_lub,?P,?E ⊢ ?a⌊?i⌉ :: ?T› ‹⟦?is_lub,?P,?E ⊢ ?a :: ?T⌊⌉; ?is_lub,?P,?E ⊢ ?i :: Integer; ?is_lub,?P,?E ⊢ ?e :: ?T'; ?P ⊢ ?T' ≤ ?T⟧ ⟹ ?is_lub,?P,?E ⊢ ?a⌊?i⌉ := ?e :: Void› ‹?is_lub,?P,?E ⊢ ?a :: ?T⌊⌉ ⟹ ?is_lub,?P,?E ⊢ ?a∙length :: Integer› ‹⟦?is_lub,?P,?E ⊢ ?e :: ?U; class_type_of' ?U = ⌊?C⌋; ?P ⊢ ?C sees ?F:?T (?fm) in ?D⟧ ⟹ ?is_lub,?P,?E ⊢ ?e∙?F{?D} :: ?T› and more 12 facts*) WT_elim_cases (*‹⟦?is_lub',?P,?E ⊢ ?V:=?e :: ?T; ⋀T T'. ⟦?T = Void; ?E ?V = ⌊T⌋; ?is_lub',?P,?E ⊢ ?e :: T'; ?P ⊢ T' ≤ T; ?V ≠ this⟧ ⟹ ?Pa⟧ ⟹ ?Pa› ‹⟦?is_lub',?P,?E ⊢ sync(?o') ?e :: ?T; ⋀T. ⟦?is_lub',?P,?E ⊢ ?o' :: T; is_refT T; T ≠ NT; ?is_lub',?P,?E ⊢ ?e :: ?T⟧ ⟹ ?Pa⟧ ⟹ ?Pa› ‹⟦?is_lub',?P,?E ⊢ if (?e) ?e₁ else ?e₂ :: ?T; ⋀T₁ T₂. ⟦?is_lub',?P,?E ⊢ ?e :: Boolean; ?is_lub',?P,?E ⊢ ?e₁ :: T₁; ?is_lub',?P,?E ⊢ ?e₂ :: T₂; ?is_lub' T₁ T₂ ?T⟧ ⟹ ?Pa⟧ ⟹ ?Pa› ‹⟦?is_lub',?P,?E ⊢ while (?e) ?c :: ?T; ⋀T. ⟦?T = Void; ?is_lub',?P,?E ⊢ ?e :: Boolean; ?is_lub',?P,?E ⊢ ?c :: T⟧ ⟹ ?Pa⟧ ⟹ ?Pa› ‹⟦?is_lub',?P,?E ⊢ throw ?e :: ?T; ⋀C. ⟦?T = Void; ?is_lub',?P,?E ⊢ ?e :: Class C; ?P ⊢ C ≼⇧* Throwable⟧ ⟹ ?Pa⟧ ⟹ ?Pa› ‹⟦?is_lub',?P,?E ⊢ try ?e₁ catch(?C ?V) ?e₂ :: ?T; ⟦?is_lub',?P,?E ⊢ ?e₁ :: ?T; ?is_lub',?P,?E(?V ↦ Class ?C) ⊢ ?e₂ :: ?T; ?P ⊢ ?C ≼⇧* Throwable⟧ ⟹ ?Pa⟧ ⟹ ?Pa› ‹⟦?is_lub',?P,?E ⊢ Cast ?D ?e :: ?T; ⋀T. ⟦?T = ?D; ?is_lub',?P,?E ⊢ ?e :: T; ?P ⊢ ?D ≤ T ∨ ?P ⊢ T ≤ ?D; is_type ?P ?D⟧ ⟹ ?Pa⟧ ⟹ ?Pa› ‹⟦?is_lub',?P,?E ⊢ ?e instanceof ?U :: ?T; ⋀T. ⟦?T = Boolean; ?is_lub',?P,?E ⊢ ?e :: T; ?P ⊢ ?U ≤ T ∨ ?P ⊢ T ≤ ?U; is_type ?P ?U; is_refT ?U⟧ ⟹ ?Pa⟧ ⟹ ?Pa› ‹⟦?is_lub',?P,?E ⊢ ?a∙?F{?D} :: ?T; ⋀U C fm. ⟦?is_lub',?P,?E ⊢ ?a :: U; class_type_of' U = ⌊C⌋; ?P ⊢ C sees ?F:?T (fm) in ?D⟧ ⟹ ?Pa⟧ ⟹ ?Pa› ‹⟦?is_lub',?P,?E ⊢ ?a∙?F{?D} := ?v :: ?T; ⋀U C T fm T'. ⟦?T = Void; ?is_lub',?P,?E ⊢ ?a :: U; class_type_of' U = ⌊C⌋; ?P ⊢ C sees ?F:T (fm) in ?D; ?is_lub',?P,?E ⊢ ?v :: T'; ?P ⊢ T' ≤ T⟧ ⟹ ?Pa⟧ ⟹ ?Pa› ‹⟦?is_lub',?P,?E ⊢ ?e∙compareAndSwap(?D∙?F, ?e', ?e'') :: ?T; ⋀U C T fm T' T''. ⟦?T = Boolean; ?is_lub',?P,?E ⊢ ?e :: U; class_type_of' U = ⌊C⌋; ?P ⊢ C sees ?F:T (fm) in ?D; volatile fm; ?is_lub',?P,?E ⊢ ?e' :: T'; ?P ⊢ T' ≤ T; ?is_lub',?P,?E ⊢ ?e'' :: T''; ?P ⊢ T'' ≤ T⟧ ⟹ ?Pa⟧ ⟹ ?Pa› ‹⟦?is_lub',?P,?E ⊢ ?e₁ «?bop» ?e₂ :: ?T; ⋀T1 T2. ⟦?is_lub',?P,?E ⊢ ?e₁ :: T1; ?is_lub',?P,?E ⊢ ?e₂ :: T2; ?P ⊢ T1«?bop»T2 :: ?T⟧ ⟹ ?Pa⟧ ⟹ ?Pa› and more 8 facts*)) (*discuss goal 14*) apply blast (*discuss goal 15*) apply fastforce (*discuss goal 16*) apply (fastforce simp: map_le_def (*‹((?m₁::?'a ⇒ ?'b option) ⊆⇩m (?m₂::?'a ⇒ ?'b option)) = (∀a::?'a∈dom ?m₁. ?m₁ a = ?m₂ a)›*) WTBlock (*‹⟦is_type (?P::?'addr J_prog) (?T::ty); (?is_lub::ty ⇒ ty ⇒ ty ⇒ bool),?P,(?E::String.literal ⇒ ty option)(?V::String.literal ↦ ?T) ⊢ (?e::?'addr expr) :: ?T'::ty; case ?vo::?'addr val option of None ⇒ True | ⌊v::?'addr val⌋ ⇒ ∃T'::ty. typeof v = ⌊T'⌋ ∧ ?P ⊢ T' ≤ ?T⟧ ⟹ ?is_lub,?P,?E ⊢ {?V:?T=?vo; ?e} :: ?T'›*)) (*discuss goal 17*) apply (fastforce simp: WTSynchronized (*‹⟦?is_lub,?P,?E ⊢ ?o' :: ?T; is_refT ?T; ?T ≠ NT; ?is_lub,?P,?E ⊢ ?e :: ?T'⟧ ⟹ ?is_lub,?P,?E ⊢ sync(?o') ?e :: ?T'›*)) (*discuss goal 18*) apply (fastforce simp: WTSeq (*‹⟦?is_lub,?P,?E ⊢ ?e₁ :: ?T₁; ?is_lub,?P,?E ⊢ ?e₂ :: ?T₂⟧ ⟹ ?is_lub,?P,?E ⊢ ?e₁;; ?e₂ :: ?T₂›*)) (*discuss goal 19*) apply (fastforce simp: WTCond (*‹⟦?is_lub,?P,?E ⊢ ?e :: Boolean; ?is_lub,?P,?E ⊢ ?e₁ :: ?T₁; ?is_lub,?P,?E ⊢ ?e₂ :: ?T₂; ?is_lub ?T₁ ?T₂ ?T⟧ ⟹ ?is_lub,?P,?E ⊢ if (?e) ?e₁ else ?e₂ :: ?T›*)) (*discuss goal 20*) apply (fastforce simp: WTWhile (*‹⟦?is_lub,?P,?E ⊢ ?e :: Boolean; ?is_lub,?P,?E ⊢ ?c :: ?T⟧ ⟹ ?is_lub,?P,?E ⊢ while (?e) ?c :: Void›*)) (*discuss goal 21*) apply (fastforce simp: WTThrow (*‹⟦?is_lub,?P,?E ⊢ ?e :: Class ?C; ?P ⊢ ?C ≼⇧* Throwable⟧ ⟹ ?is_lub,?P,?E ⊢ throw ?e :: Void›*)) (*discuss goal 22*) apply (fastforce simp: WTTry (*‹⟦?is_lub,?P,?E ⊢ ?e₁ :: ?T; ?is_lub,?P,?E(?V ↦ Class ?C) ⊢ ?e₂ :: ?T; ?P ⊢ ?C ≼⇧* Throwable⟧ ⟹ ?is_lub,?P,?E ⊢ try ?e₁ catch(?C ?V) ?e₂ :: ?T›*) map_le_def (*‹(?m₁ ⊆⇩m ?m₂) = (∀a∈dom ?m₁. ?m₁ a = ?m₂ a)›*) dom_def (*‹dom ?m = {a. ?m a ≠ None}›*)) (*discuss goal 23*) apply fastforce (*discuss goal 24*) apply fastforce (*proven 24 subgoals*) . lemma fixes is_lub shows WT_fv: "is_lub,P,E ⊢ e :: T ⟹ fv e ⊆ dom E" and WT_fvs: "is_lub,P,E ⊢ es [::] Ts ⟹ fvs es ⊆ dom E" sorry lemma fixes is_lub shows WT_expr_locks: "is_lub,P,E ⊢ e :: T ⟹ expr_locks e = (λad. 0)" and WTs_expr_lockss: "is_lub,P,E ⊢ es [::] Ts ⟹ expr_lockss es = (λad. 0)" apply (induct rule: WT_WTs.inducts (*‹⟦(?is_lub::ty ⇒ ty ⇒ ty ⇒ bool),(?P::?'addr J_prog),(?x1.0::String.literal ⇒ ty option) ⊢ (?x2.0::?'addr expr) :: ?x3.0::ty; ⋀(C::String.literal) E::String.literal ⇒ ty option. is_class ?P C ⟹ (?P1.0::(String.literal ⇒ ty option) ⇒ ?'addr expr ⇒ ty ⇒ bool) E (new C) (Class C); ⋀(E::String.literal ⇒ ty option) (e::?'addr expr) T::ty. ⟦?is_lub,?P,E ⊢ e :: Integer; ?P1.0 E e Integer; is_type ?P (T⌊⌉)⟧ ⟹ ?P1.0 E (newA T⌊e⌉) (T⌊⌉); ⋀(E::String.literal ⇒ ty option) (e::?'addr expr) (T::ty) U::ty. ⟦?is_lub,?P,E ⊢ e :: T; ?P1.0 E e T; ?P ⊢ U ≤ T ∨ ?P ⊢ T ≤ U; is_type ?P U⟧ ⟹ ?P1.0 E (Cast U e) U; ⋀(E::String.literal ⇒ ty option) (e::?'addr expr) (T::ty) U::ty. ⟦?is_lub,?P,E ⊢ e :: T; ?P1.0 E e T; ?P ⊢ U ≤ T ∨ ?P ⊢ T ≤ U; is_type ?P U; is_refT U⟧ ⟹ ?P1.0 E (e instanceof U) Boolean; ⋀(v::?'addr val) (T::ty) E::String.literal ⇒ ty option. typeof v = ⌊T⌋ ⟹ ?P1.0 E (Val v) T; ⋀(E::String.literal ⇒ ty option) (V::String.literal) T::ty. E V = ⌊T⌋ ⟹ ?P1.0 E (Var V) T; ⋀(E::String.literal ⇒ ty option) (e1::?'addr expr) (T1::ty) (e2::?'addr expr) (T2::ty) (bop::bop) T::ty. ⟦?is_lub,?P,E ⊢ e1 :: T1; ?P1.0 E e1 T1; ?is_lub,?P,E ⊢ e2 :: T2; ?P1.0 E e2 T2; ?P ⊢ T1«bop»T2 :: T⟧ ⟹ ?P1.0 E (e1 «bop» e2) T; ⋀(E::String.literal ⇒ ty option) (V::String.literal) (T::ty) (e::?'addr expr) T'::ty. ⟦E V = ⌊T⌋; ?is_lub,?P,E ⊢ e :: T'; ?P1.0 E e T'; ?P ⊢ T' ≤ T; V ≠ this⟧ ⟹ ?P1.0 E (V:=e) Void; ⋀(E::String.literal ⇒ ty option) (a::?'addr expr) (T::ty) i::?'addr expr. ⟦?is_lub,?P,E ⊢ a :: T⌊⌉; ?P1.0 E a (T⌊⌉); ?is_lub,?P,E ⊢ i :: Integer; ?P1.0 E i Integer⟧ ⟹ ?P1.0 E (a⌊i⌉) T; ⋀(E::String.literal ⇒ ty option) (a::?'addr expr) (T::ty) (i::?'addr expr) (e::?'addr expr) T'::ty. ⟦?is_lub,?P,E ⊢ a :: T⌊⌉; ?P1.0 E a (T⌊⌉); ?is_lub,?P,E ⊢ i :: Integer; ?P1.0 E i Integer; ?is_lub,?P,E ⊢ e :: T'; ?P1.0 E e T'; ?P ⊢ T' ≤ T⟧ ⟹ ?P1.0 E (a⌊i⌉ := e) Void; ⋀(E::String.literal ⇒ ty option) (a::?'addr expr) T::ty. ⟦?is_lub,?P,E ⊢ a :: T⌊⌉; ?P1.0 E a (T⌊⌉)⟧ ⟹ ?P1.0 E (a∙length) Integer; ⋀(E::String.literal ⇒ ty option) (e::?'addr expr) (U::ty) (C::String.literal) (F::String.literal) (T::ty) (fm::fmod) D::String.literal. ⟦?is_lub,?P,E ⊢ e :: U; ?P1.0 E e U; class_type_of' U = ⌊C⌋; ?P ⊢ C sees F:T (fm) in D⟧ ⟹ ?P1.0 E (e∙F{D}) T; ⋀(E::String.literal ⇒ ty option) (e₁::?'addr expr) (U::ty) (C::String.literal) (F::String.literal) (T::ty) (fm::fmod) (D::String.literal) (e₂::?'addr expr) T'::ty. ⟦?is_lub,?P,E ⊢ e₁ :: U; ?P1.0 E e₁ U; class_type_of' U = ⌊C⌋; ?P ⊢ C sees F:T (fm) in D; ?is_lub,?P,E ⊢ e₂ :: T'; ?P1.0 E e₂ T'; ?P ⊢ T' ≤ T⟧ ⟹ ?P1.0 E (e₁∙F{D} := e₂) Void; ⋀(E::String.literal ⇒ ty option) (e1::?'addr expr) (U::ty) (C::String.literal) (F::String.literal) (T::ty) (fm::fmod) (D::String.literal) (e2::?'addr expr) (T'::ty) (e3::?'addr expr) T''::ty. ⟦?is_lub,?P,E ⊢ e1 :: U; ?P1.0 E e1 U; class_type_of' U = ⌊C⌋; ?P ⊢ C sees F:T (fm) in D; volatile fm; ?is_lub,?P,E ⊢ e2 :: T'; ?P1.0 E e2 T'; ?P ⊢ T' ≤ T; ?is_lub,?P,E ⊢ e3 :: T''; ?P1.0 E e3 T''; ?P ⊢ T'' ≤ T⟧ ⟹ ?P1.0 E (e1∙compareAndSwap(D∙F, e2, e3)) Boolean; ⋀(E::String.literal ⇒ ty option) (e::?'addr expr) (U::ty) (C::String.literal) (M::String.literal) (Ts::ty list) (T::ty) (meth::(String.literal list × ?'addr expr) option) (D::String.literal) (es::?'addr expr list) Ts'::ty list. ⟦?is_lub,?P,E ⊢ e :: U; ?P1.0 E e U; class_type_of' U = ⌊C⌋; ?P ⊢ C sees M: Ts→T = meth in D; ?is_lub,?P,E ⊢ es [::] Ts'; (?P2.0::(String.literal ⇒ ty option) ⇒ ?'addr expr list ⇒ ty list ⇒ bool) E es Ts'; ?P ⊢ Ts' [≤] Ts⟧ ⟹ ?P1.0 E (e∙M(es)) T; ⋀(T::ty) (E::String.literal ⇒ ty option) (V::String.literal) (e::?'addr expr) (T'::ty) vo::?'addr val option. ⟦is_type ?P T; ?is_lub,?P,E(V ↦ T) ⊢ e :: T'; ?P1.0 (E(V ↦ T)) e T'; case vo of None ⇒ True | ⌊v::?'addr val⌋ ⇒ ∃T'::ty. typeof v = ⌊T'⌋ ∧ ?P ⊢ T' ≤ T⟧ ⟹ ?P1.0 E {V:T=vo; e} T'; ⋀(E::String.literal ⇒ ty option) (o'::?'addr expr) (T::ty) (e::?'addr expr) T'::ty. ⟦?is_lub,?P,E ⊢ o' :: T; ?P1.0 E o' T; is_refT T; T ≠ NT; ?is_lub,?P,E ⊢ e :: T'; ?P1.0 E e T'⟧ ⟹ ?P1.0 E (sync(o') e) T'; ⋀(E::String.literal ⇒ ty option) (e₁::?'addr expr) (T₁::ty) (e₂::?'addr expr) T₂::ty. ⟦?is_lub,?P,E ⊢ e₁ :: T₁; ?P1.0 E e₁ T₁; ?is_lub,?P,E ⊢ e₂ :: T₂; ?P1.0 E e₂ T₂⟧ ⟹ ?P1.0 E (e₁;; e₂) T₂; ⋀(E::String.literal ⇒ ty option) (e::?'addr expr) (e₁::?'addr expr) (T₁::ty) (e₂::?'addr expr) (T₂::ty) T::ty. ⟦?is_lub,?P,E ⊢ e :: Boolean; ?P1.0 E e Boolean; ?is_lub,?P,E ⊢ e₁ :: T₁; ?P1.0 E e₁ T₁; ?is_lub,?P,E ⊢ e₂ :: T₂; ?P1.0 E e₂ T₂; ?is_lub T₁ T₂ T⟧ ⟹ ?P1.0 E (if (e) e₁ else e₂) T; ⋀(E::String.literal ⇒ ty option) (e::?'addr expr) (c::?'addr expr) T::ty. ⟦?is_lub,?P,E ⊢ e :: Boolean; ?P1.0 E e Boolean; ?is_lub,?P,E ⊢ c :: T; ?P1.0 E c T⟧ ⟹ ?P1.0 E (while (e) c) Void; ⋀(E::String.literal ⇒ ty option) (e::?'addr expr) C::String.literal. ⟦?is_lub,?P,E ⊢ e :: Class C; ?P1.0 E e (Class C); ?P ⊢ C ≼⇧* Throwable⟧ ⟹ ?P1.0 E (throw e) Void; ⋀(E::String.literal ⇒ ty option) (e₁::?'addr expr) (T::ty) (V::String.literal) (C::String.literal) e₂::?'addr expr. ⟦?is_lub,?P,E ⊢ e₁ :: T; ?P1.0 E e₁ T; ?is_lub,?P,E(V ↦ Class C) ⊢ e₂ :: T; ?P1.0 (E(V ↦ Class C)) e₂ T; ?P ⊢ C ≼⇧* Throwable⟧ ⟹ ?P1.0 E (try e₁ catch(C V) e₂) T; ⋀E::String.literal ⇒ ty option. ?P2.0 E [] []; ⋀(E::String.literal ⇒ ty option) (e::?'addr expr) (T::ty) (es::?'addr expr list) Ts::ty list. ⟦?is_lub,?P,E ⊢ e :: T; ?P1.0 E e T; ?is_lub,?P,E ⊢ es [::] Ts; ?P2.0 E es Ts⟧ ⟹ ?P2.0 E (e # es) (T # Ts)⟧ ⟹ ?P1.0 ?x1.0 ?x2.0 ?x3.0› ‹⟦(?is_lub::ty ⇒ ty ⇒ ty ⇒ bool),(?P::?'addr J_prog),(?x4.0::String.literal ⇒ ty option) ⊢ (?x5.0::?'addr expr list) [::] ?x6.0::ty list; ⋀(C::String.literal) E::String.literal ⇒ ty option. is_class ?P C ⟹ (?P1.0::(String.literal ⇒ ty option) ⇒ ?'addr expr ⇒ ty ⇒ bool) E (new C) (Class C); ⋀(E::String.literal ⇒ ty option) (e::?'addr expr) T::ty. ⟦?is_lub,?P,E ⊢ e :: Integer; ?P1.0 E e Integer; is_type ?P (T⌊⌉)⟧ ⟹ ?P1.0 E (newA T⌊e⌉) (T⌊⌉); ⋀(E::String.literal ⇒ ty option) (e::?'addr expr) (T::ty) U::ty. ⟦?is_lub,?P,E ⊢ e :: T; ?P1.0 E e T; ?P ⊢ U ≤ T ∨ ?P ⊢ T ≤ U; is_type ?P U⟧ ⟹ ?P1.0 E (Cast U e) U; ⋀(E::String.literal ⇒ ty option) (e::?'addr expr) (T::ty) U::ty. ⟦?is_lub,?P,E ⊢ e :: T; ?P1.0 E e T; ?P ⊢ U ≤ T ∨ ?P ⊢ T ≤ U; is_type ?P U; is_refT U⟧ ⟹ ?P1.0 E (e instanceof U) Boolean; ⋀(v::?'addr val) (T::ty) E::String.literal ⇒ ty option. typeof v = ⌊T⌋ ⟹ ?P1.0 E (Val v) T; ⋀(E::String.literal ⇒ ty option) (V::String.literal) T::ty. E V = ⌊T⌋ ⟹ ?P1.0 E (Var V) T; ⋀(E::String.literal ⇒ ty option) (e1::?'addr expr) (T1::ty) (e2::?'addr expr) (T2::ty) (bop::bop) T::ty. ⟦?is_lub,?P,E ⊢ e1 :: T1; ?P1.0 E e1 T1; ?is_lub,?P,E ⊢ e2 :: T2; ?P1.0 E e2 T2; ?P ⊢ T1«bop»T2 :: T⟧ ⟹ ?P1.0 E (e1 «bop» e2) T; ⋀(E::String.literal ⇒ ty option) (V::String.literal) (T::ty) (e::?'addr expr) T'::ty. ⟦E V = ⌊T⌋; ?is_lub,?P,E ⊢ e :: T'; ?P1.0 E e T'; ?P ⊢ T' ≤ T; V ≠ this⟧ ⟹ ?P1.0 E (V:=e) Void; ⋀(E::String.literal ⇒ ty option) (a::?'addr expr) (T::ty) i::?'addr expr. ⟦?is_lub,?P,E ⊢ a :: T⌊⌉; ?P1.0 E a (T⌊⌉); ?is_lub,?P,E ⊢ i :: Integer; ?P1.0 E i Integer⟧ ⟹ ?P1.0 E (a⌊i⌉) T; ⋀(E::String.literal ⇒ ty option) (a::?'addr expr) (T::ty) (i::?'addr expr) (e::?'addr expr) T'::ty. ⟦?is_lub,?P,E ⊢ a :: T⌊⌉; ?P1.0 E a (T⌊⌉); ?is_lub,?P,E ⊢ i :: Integer; ?P1.0 E i Integer; ?is_lub,?P,E ⊢ e :: T'; ?P1.0 E e T'; ?P ⊢ T' ≤ T⟧ ⟹ ?P1.0 E (a⌊i⌉ := e) Void; ⋀(E::String.literal ⇒ ty option) (a::?'addr expr) T::ty. ⟦?is_lub,?P,E ⊢ a :: T⌊⌉; ?P1.0 E a (T⌊⌉)⟧ ⟹ ?P1.0 E (a∙length) Integer; ⋀(E::String.literal ⇒ ty option) (e::?'addr expr) (U::ty) (C::String.literal) (F::String.literal) (T::ty) (fm::fmod) D::String.literal. ⟦?is_lub,?P,E ⊢ e :: U; ?P1.0 E e U; class_type_of' U = ⌊C⌋; ?P ⊢ C sees F:T (fm) in D⟧ ⟹ ?P1.0 E (e∙F{D}) T; ⋀(E::String.literal ⇒ ty option) (e₁::?'addr expr) (U::ty) (C::String.literal) (F::String.literal) (T::ty) (fm::fmod) (D::String.literal) (e₂::?'addr expr) T'::ty. ⟦?is_lub,?P,E ⊢ e₁ :: U; ?P1.0 E e₁ U; class_type_of' U = ⌊C⌋; ?P ⊢ C sees F:T (fm) in D; ?is_lub,?P,E ⊢ e₂ :: T'; ?P1.0 E e₂ T'; ?P ⊢ T' ≤ T⟧ ⟹ ?P1.0 E (e₁∙F{D} := e₂) Void; ⋀(E::String.literal ⇒ ty option) (e1::?'addr expr) (U::ty) (C::String.literal) (F::String.literal) (T::ty) (fm::fmod) (D::String.literal) (e2::?'addr expr) (T'::ty) (e3::?'addr expr) T''::ty. ⟦?is_lub,?P,E ⊢ e1 :: U; ?P1.0 E e1 U; class_type_of' U = ⌊C⌋; ?P ⊢ C sees F:T (fm) in D; volatile fm; ?is_lub,?P,E ⊢ e2 :: T'; ?P1.0 E e2 T'; ?P ⊢ T' ≤ T; ?is_lub,?P,E ⊢ e3 :: T''; ?P1.0 E e3 T''; ?P ⊢ T'' ≤ T⟧ ⟹ ?P1.0 E (e1∙compareAndSwap(D∙F, e2, e3)) Boolean; ⋀(E::String.literal ⇒ ty option) (e::?'addr expr) (U::ty) (C::String.literal) (M::String.literal) (Ts::ty list) (T::ty) (meth::(String.literal list × ?'addr expr) option) (D::String.literal) (es::?'addr expr list) Ts'::ty list. ⟦?is_lub,?P,E ⊢ e :: U; ?P1.0 E e U; class_type_of' U = ⌊C⌋; ?P ⊢ C sees M: Ts→T = meth in D; ?is_lub,?P,E ⊢ es [::] Ts'; (?P2.0::(String.literal ⇒ ty option) ⇒ ?'addr expr list ⇒ ty list ⇒ bool) E es Ts'; ?P ⊢ Ts' [≤] Ts⟧ ⟹ ?P1.0 E (e∙M(es)) T; ⋀(T::ty) (E::String.literal ⇒ ty option) (V::String.literal) (e::?'addr expr) (T'::ty) vo::?'addr val option. ⟦is_type ?P T; ?is_lub,?P,E(V ↦ T) ⊢ e :: T'; ?P1.0 (E(V ↦ T)) e T'; case vo of None ⇒ True | ⌊v::?'addr val⌋ ⇒ ∃T'::ty. typeof v = ⌊T'⌋ ∧ ?P ⊢ T' ≤ T⟧ ⟹ ?P1.0 E {V:T=vo; e} T'; ⋀(E::String.literal ⇒ ty option) (o'::?'addr expr) (T::ty) (e::?'addr expr) T'::ty. ⟦?is_lub,?P,E ⊢ o' :: T; ?P1.0 E o' T; is_refT T; T ≠ NT; ?is_lub,?P,E ⊢ e :: T'; ?P1.0 E e T'⟧ ⟹ ?P1.0 E (sync(o') e) T'; ⋀(E::String.literal ⇒ ty option) (e₁::?'addr expr) (T₁::ty) (e₂::?'addr expr) T₂::ty. ⟦?is_lub,?P,E ⊢ e₁ :: T₁; ?P1.0 E e₁ T₁; ?is_lub,?P,E ⊢ e₂ :: T₂; ?P1.0 E e₂ T₂⟧ ⟹ ?P1.0 E (e₁;; e₂) T₂; ⋀(E::String.literal ⇒ ty option) (e::?'addr expr) (e₁::?'addr expr) (T₁::ty) (e₂::?'addr expr) (T₂::ty) T::ty. ⟦?is_lub,?P,E ⊢ e :: Boolean; ?P1.0 E e Boolean; ?is_lub,?P,E ⊢ e₁ :: T₁; ?P1.0 E e₁ T₁; ?is_lub,?P,E ⊢ e₂ :: T₂; ?P1.0 E e₂ T₂; ?is_lub T₁ T₂ T⟧ ⟹ ?P1.0 E (if (e) e₁ else e₂) T; ⋀(E::String.literal ⇒ ty option) (e::?'addr expr) (c::?'addr expr) T::ty. ⟦?is_lub,?P,E ⊢ e :: Boolean; ?P1.0 E e Boolean; ?is_lub,?P,E ⊢ c :: T; ?P1.0 E c T⟧ ⟹ ?P1.0 E (while (e) c) Void; ⋀(E::String.literal ⇒ ty option) (e::?'addr expr) C::String.literal. ⟦?is_lub,?P,E ⊢ e :: Class C; ?P1.0 E e (Class C); ?P ⊢ C ≼⇧* Throwable⟧ ⟹ ?P1.0 E (throw e) Void; ⋀(E::String.literal ⇒ ty option) (e₁::?'addr expr) (T::ty) (V::String.literal) (C::String.literal) e₂::?'addr expr. ⟦?is_lub,?P,E ⊢ e₁ :: T; ?P1.0 E e₁ T; ?is_lub,?P,E(V ↦ Class C) ⊢ e₂ :: T; ?P1.0 (E(V ↦ Class C)) e₂ T; ?P ⊢ C ≼⇧* Throwable⟧ ⟹ ?P1.0 E (try e₁ catch(C V) e₂) T; ⋀E::String.literal ⇒ ty option. ?P2.0 E [] []; ⋀(E::String.literal ⇒ ty option) (e::?'addr expr) (T::ty) (es::?'addr expr list) Ts::ty list. ⟦?is_lub,?P,E ⊢ e :: T; ?P1.0 E e T; ?is_lub,?P,E ⊢ es [::] Ts; ?P2.0 E es Ts⟧ ⟹ ?P2.0 E (e # es) (T # Ts)⟧ ⟹ ?P2.0 ?x4.0 ?x5.0 ?x6.0›*)) (*goals: 1. ‹⋀C E. is_class P C ⟹ expr_locks (new C) = (λad. 0)› 2. ‹⋀E e T. ⟦is_lub,P,E ⊢ e :: Integer; expr_locks e = (λad. 0); is_type P (T⌊⌉)⟧ ⟹ expr_locks (newA T⌊e⌉) = (λad. 0)› 3. ‹⋀E e T U. ⟦is_lub,P,E ⊢ e :: T; expr_locks e = (λad. 0); P ⊢ U ≤ T ∨ P ⊢ T ≤ U; is_type P U⟧ ⟹ expr_locks (Cast U e) = (λad. 0)› 4. ‹⋀E e T U. ⟦is_lub,P,E ⊢ e :: T; expr_locks e = (λad. 0); P ⊢ U ≤ T ∨ P ⊢ T ≤ U; is_type P U; is_refT U⟧ ⟹ expr_locks (e instanceof U) = (λad. 0)› 5. ‹⋀v T E. typeof v = ⌊T⌋ ⟹ expr_locks (Val v) = (λad. 0)› 6. ‹⋀E V T. E V = ⌊T⌋ ⟹ expr_locks (Var V) = (λad. 0)› 7. ‹⋀E e1 T1 e2 T2 bop T. ⟦is_lub,P,E ⊢ e1 :: T1; expr_locks e1 = (λad. 0); is_lub,P,E ⊢ e2 :: T2; expr_locks e2 = (λad. 0); P ⊢ T1«bop»T2 :: T⟧ ⟹ expr_locks (e1 «bop» e2) = (λad. 0)› 8. ‹⋀E V T e T'. ⟦E V = ⌊T⌋; is_lub,P,E ⊢ e :: T'; expr_locks e = (λad. 0); P ⊢ T' ≤ T; V ≠ this⟧ ⟹ expr_locks (V:=e) = (λad. 0)› 9. ‹⋀E a T i. ⟦is_lub,P,E ⊢ a :: T⌊⌉; expr_locks a = (λad. 0); is_lub,P,E ⊢ i :: Integer; expr_locks i = (λad. 0)⟧ ⟹ expr_locks (a⌊i⌉) = (λad. 0)› 10. ‹⋀E a T i e T'. ⟦is_lub,P,E ⊢ a :: T⌊⌉; expr_locks a = (λad. 0); is_lub,P,E ⊢ i :: Integer; expr_locks i = (λad. 0); is_lub,P,E ⊢ e :: T'; expr_locks e = (λad. 0); P ⊢ T' ≤ T⟧ ⟹ expr_locks (a⌊i⌉ := e) = (λad. 0)› 11. ‹⋀E a T. ⟦is_lub,P,E ⊢ a :: T⌊⌉; expr_locks a = (λad. 0)⟧ ⟹ expr_locks (a∙length) = (λad. 0)› 12. ‹⋀E e U C F T fm D. ⟦is_lub,P,E ⊢ e :: U; expr_locks e = (λad. 0); class_type_of' U = ⌊C⌋; P ⊢ C sees F:T (fm) in D⟧ ⟹ expr_locks (e∙F{D}) = (λad. 0)› 13. ‹⋀E e₁ U C F T fm D e₂ T'. ⟦is_lub,P,E ⊢ e₁ :: U; expr_locks e₁ = (λad. 0); class_type_of' U = ⌊C⌋; P ⊢ C sees F:T (fm) in D; is_lub,P,E ⊢ e₂ :: T'; expr_locks e₂ = (λad. 0); P ⊢ T' ≤ T⟧ ⟹ expr_locks (e₁∙F{D} := e₂) = (λad. 0)› 14. ‹⋀E e1 U C F T fm D e2 T' e3 T''. ⟦is_lub,P,E ⊢ e1 :: U; expr_locks e1 = (λad. 0); class_type_of' U = ⌊C⌋; P ⊢ C sees F:T (fm) in D; volatile fm; is_lub,P,E ⊢ e2 :: T'; expr_locks e2 = (λad. 0); P ⊢ T' ≤ T; is_lub,P,E ⊢ e3 :: T''; expr_locks e3 = (λad. 0); P ⊢ T'' ≤ T⟧ ⟹ expr_locks (e1∙compareAndSwap(D∙F, e2, e3)) = (λad. 0)› 15. ‹⋀E e U C M Ts T meth D es Ts'. ⟦is_lub,P,E ⊢ e :: U; expr_locks e = (λad. 0); class_type_of' U = ⌊C⌋; P ⊢ C sees M: Ts→T = meth in D; is_lub,P,E ⊢ es [::] Ts'; expr_lockss es = (λad. 0); P ⊢ Ts' [≤] Ts⟧ ⟹ expr_locks (e∙M(es)) = (λad. 0)› 16. ‹⋀T E V e T' vo. ⟦is_type P T; is_lub,P,E(V ↦ T) ⊢ e :: T'; expr_locks e = (λad. 0); case vo of None ⇒ True | ⌊v⌋ ⇒ ∃T'. typeof v = ⌊T'⌋ ∧ P ⊢ T' ≤ T⟧ ⟹ expr_locks {V:T=vo; e} = (λad. 0)› 17. ‹⋀E o' T e T'. ⟦is_lub,P,E ⊢ o' :: T; expr_locks o' = (λad. 0); is_refT T; T ≠ NT; is_lub,P,E ⊢ e :: T'; expr_locks e = (λad. 0)⟧ ⟹ expr_locks (sync(o') e) = (λad. 0)› 18. ‹⋀E e₁ T₁ e₂ T₂. ⟦is_lub,P,E ⊢ e₁ :: T₁; expr_locks e₁ = (λad. 0); is_lub,P,E ⊢ e₂ :: T₂; expr_locks e₂ = (λad. 0)⟧ ⟹ expr_locks (e₁;; e₂) = (λad. 0)› 19. ‹⋀E e e₁ T₁ e₂ T₂ T. ⟦is_lub,P,E ⊢ e :: Boolean; expr_locks e = (λad. 0); is_lub,P,E ⊢ e₁ :: T₁; expr_locks e₁ = (λad. 0); is_lub,P,E ⊢ e₂ :: T₂; expr_locks e₂ = (λad. 0); is_lub T₁ T₂ T⟧ ⟹ expr_locks (if (e) e₁ else e₂) = (λad. 0)› 20. ‹⋀E e c T. ⟦is_lub,P,E ⊢ e :: Boolean; expr_locks e = (λad. 0); is_lub,P,E ⊢ c :: T; expr_locks c = (λad. 0)⟧ ⟹ expr_locks (while (e) c) = (λad. 0)› 21. ‹⋀E e C. ⟦is_lub,P,E ⊢ e :: Class C; expr_locks e = (λad. 0); P ⊢ C ≼⇧* Throwable⟧ ⟹ expr_locks (throw e) = (λad. 0)› 22. ‹⋀E e₁ T V C e₂. ⟦is_lub,P,E ⊢ e₁ :: T; expr_locks e₁ = (λad. 0); is_lub,P,E(V ↦ Class C) ⊢ e₂ :: T; expr_locks e₂ = (λad. 0); P ⊢ C ≼⇧* Throwable⟧ ⟹ expr_locks (try e₁ catch(C V) e₂) = (λad. 0)› 23. ‹⋀E. expr_lockss [] = (λad. 0)› 24. ‹⋀E e T es Ts. ⟦is_lub,P,E ⊢ e :: T; expr_locks e = (λad. 0); is_lub,P,E ⊢ es [::] Ts; expr_lockss es = (λad. 0)⟧ ⟹ expr_lockss (e # es) = (λad. 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]) (*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 fixes is_lub :: "ty ⇒ ty ⇒ ty ⇒ bool" ("⊢ lub'((_,/ _)') = _" [51,51,51] 50) assumes is_lub_is_type: "⋀T1 T2 T3. ⟦ ⊢ lub(T1, T2) = T3; is_type P T1; is_type P T2 ⟧ ⟹ is_type P T3" and wf: "wf_prog wf_md P" shows WT_is_type: "⟦ is_lub,P,E ⊢ e :: T; ran E ⊆ types P ⟧ ⟹ is_type P T" and WTs_is_type: "⟦ is_lub,P,E ⊢ es [::] Ts; ran E ⊆ types P ⟧ ⟹ set Ts ⊆ types P" apply (induct rule: WT_WTs.inducts (*‹⟦?is_lub,?P,?x1.0 ⊢ ?x2.0 :: ?x3.0; ⋀C E. is_class ?P C ⟹ ?P1.0 E (new C) (Class C); ⋀E e T. ⟦?is_lub,?P,E ⊢ e :: Integer; ?P1.0 E e Integer; is_type ?P (T⌊⌉)⟧ ⟹ ?P1.0 E (newA T⌊e⌉) (T⌊⌉); ⋀E e T U. ⟦?is_lub,?P,E ⊢ e :: T; ?P1.0 E e T; ?P ⊢ U ≤ T ∨ ?P ⊢ T ≤ U; is_type ?P U⟧ ⟹ ?P1.0 E (Cast U e) U; ⋀E e T U. ⟦?is_lub,?P,E ⊢ e :: T; ?P1.0 E e T; ?P ⊢ U ≤ T ∨ ?P ⊢ T ≤ U; is_type ?P U; is_refT U⟧ ⟹ ?P1.0 E (e instanceof U) Boolean; ⋀v T E. typeof v = ⌊T⌋ ⟹ ?P1.0 E (Val v) T; ⋀E V T. E V = ⌊T⌋ ⟹ ?P1.0 E (Var V) T; ⋀E e1 T1 e2 T2 bop T. ⟦?is_lub,?P,E ⊢ e1 :: T1; ?P1.0 E e1 T1; ?is_lub,?P,E ⊢ e2 :: T2; ?P1.0 E e2 T2; ?P ⊢ T1«bop»T2 :: T⟧ ⟹ ?P1.0 E (e1 «bop» e2) T; ⋀E V T e T'. ⟦E V = ⌊T⌋; ?is_lub,?P,E ⊢ e :: T'; ?P1.0 E e T'; ?P ⊢ T' ≤ T; V ≠ this⟧ ⟹ ?P1.0 E (V:=e) Void; ⋀E a T i. ⟦?is_lub,?P,E ⊢ a :: T⌊⌉; ?P1.0 E a (T⌊⌉); ?is_lub,?P,E ⊢ i :: Integer; ?P1.0 E i Integer⟧ ⟹ ?P1.0 E (a⌊i⌉) T; ⋀E a T i e T'. ⟦?is_lub,?P,E ⊢ a :: T⌊⌉; ?P1.0 E a (T⌊⌉); ?is_lub,?P,E ⊢ i :: Integer; ?P1.0 E i Integer; ?is_lub,?P,E ⊢ e :: T'; ?P1.0 E e T'; ?P ⊢ T' ≤ T⟧ ⟹ ?P1.0 E (a⌊i⌉ := e) Void; ⋀E a T. ⟦?is_lub,?P,E ⊢ a :: T⌊⌉; ?P1.0 E a (T⌊⌉)⟧ ⟹ ?P1.0 E (a∙length) Integer; ⋀E e U C F T fm D. ⟦?is_lub,?P,E ⊢ e :: U; ?P1.0 E e U; class_type_of' U = ⌊C⌋; ?P ⊢ C sees F:T (fm) in D⟧ ⟹ ?P1.0 E (e∙F{D}) T; ⋀E e₁ U C F T fm D e₂ T'. ⟦?is_lub,?P,E ⊢ e₁ :: U; ?P1.0 E e₁ U; class_type_of' U = ⌊C⌋; ?P ⊢ C sees F:T (fm) in D; ?is_lub,?P,E ⊢ e₂ :: T'; ?P1.0 E e₂ T'; ?P ⊢ T' ≤ T⟧ ⟹ ?P1.0 E (e₁∙F{D} := e₂) Void; ⋀E e1 U C F T fm D e2 T' e3 T''. ⟦?is_lub,?P,E ⊢ e1 :: U; ?P1.0 E e1 U; class_type_of' U = ⌊C⌋; ?P ⊢ C sees F:T (fm) in D; volatile fm; ?is_lub,?P,E ⊢ e2 :: T'; ?P1.0 E e2 T'; ?P ⊢ T' ≤ T; ?is_lub,?P,E ⊢ e3 :: T''; ?P1.0 E e3 T''; ?P ⊢ T'' ≤ T⟧ ⟹ ?P1.0 E (e1∙compareAndSwap(D∙F, e2, e3)) Boolean; ⋀E e U C M Ts T meth D es Ts'. ⟦?is_lub,?P,E ⊢ e :: U; ?P1.0 E e U; class_type_of' U = ⌊C⌋; ?P ⊢ C sees M: Ts→T = meth in D; ?is_lub,?P,E ⊢ es [::] Ts'; ?P2.0 E es Ts'; ?P ⊢ Ts' [≤] Ts⟧ ⟹ ?P1.0 E (e∙M(es)) T; ⋀T E V e T' vo. ⟦is_type ?P T; ?is_lub,?P,E(V ↦ T) ⊢ e :: T'; ?P1.0 (E(V ↦ T)) e T'; case vo of None ⇒ True | ⌊v⌋ ⇒ ∃T'. typeof v = ⌊T'⌋ ∧ ?P ⊢ T' ≤ T⟧ ⟹ ?P1.0 E {V:T=vo; e} T'; ⋀E o' T e T'. ⟦?is_lub,?P,E ⊢ o' :: T; ?P1.0 E o' T; is_refT T; T ≠ NT; ?is_lub,?P,E ⊢ e :: T'; ?P1.0 E e T'⟧ ⟹ ?P1.0 E (sync(o') e) T'; ⋀E e₁ T₁ e₂ T₂. ⟦?is_lub,?P,E ⊢ e₁ :: T₁; ?P1.0 E e₁ T₁; ?is_lub,?P,E ⊢ e₂ :: T₂; ?P1.0 E e₂ T₂⟧ ⟹ ?P1.0 E (e₁;; e₂) T₂; ⋀E e e₁ T₁ e₂ T₂ T. ⟦?is_lub,?P,E ⊢ e :: Boolean; ?P1.0 E e Boolean; ?is_lub,?P,E ⊢ e₁ :: T₁; ?P1.0 E e₁ T₁; ?is_lub,?P,E ⊢ e₂ :: T₂; ?P1.0 E e₂ T₂; ?is_lub T₁ T₂ T⟧ ⟹ ?P1.0 E (if (e) e₁ else e₂) T; ⋀E e c T. ⟦?is_lub,?P,E ⊢ e :: Boolean; ?P1.0 E e Boolean; ?is_lub,?P,E ⊢ c :: T; ?P1.0 E c T⟧ ⟹ ?P1.0 E (while (e) c) Void; ⋀E e C. ⟦?is_lub,?P,E ⊢ e :: Class C; ?P1.0 E e (Class C); ?P ⊢ C ≼⇧* Throwable⟧ ⟹ ?P1.0 E (throw e) Void; ⋀E e₁ T V C e₂. ⟦?is_lub,?P,E ⊢ e₁ :: T; ?P1.0 E e₁ T; ?is_lub,?P,E(V ↦ Class C) ⊢ e₂ :: T; ?P1.0 (E(V ↦ Class C)) e₂ T; ?P ⊢ C ≼⇧* Throwable⟧ ⟹ ?P1.0 E (try e₁ catch(C V) e₂) T; ⋀E. ?P2.0 E [] []; ⋀E e T es Ts. ⟦?is_lub,?P,E ⊢ e :: T; ?P1.0 E e T; ?is_lub,?P,E ⊢ es [::] Ts; ?P2.0 E es Ts⟧ ⟹ ?P2.0 E (e # es) (T # Ts)⟧ ⟹ ?P1.0 ?x1.0 ?x2.0 ?x3.0› ‹⟦?is_lub,?P,?x4.0 ⊢ ?x5.0 [::] ?x6.0; ⋀C E. is_class ?P C ⟹ ?P1.0 E (new C) (Class C); ⋀E e T. ⟦?is_lub,?P,E ⊢ e :: Integer; ?P1.0 E e Integer; is_type ?P (T⌊⌉)⟧ ⟹ ?P1.0 E (newA T⌊e⌉) (T⌊⌉); ⋀E e T U. ⟦?is_lub,?P,E ⊢ e :: T; ?P1.0 E e T; ?P ⊢ U ≤ T ∨ ?P ⊢ T ≤ U; is_type ?P U⟧ ⟹ ?P1.0 E (Cast U e) U; ⋀E e T U. ⟦?is_lub,?P,E ⊢ e :: T; ?P1.0 E e T; ?P ⊢ U ≤ T ∨ ?P ⊢ T ≤ U; is_type ?P U; is_refT U⟧ ⟹ ?P1.0 E (e instanceof U) Boolean; ⋀v T E. typeof v = ⌊T⌋ ⟹ ?P1.0 E (Val v) T; ⋀E V T. E V = ⌊T⌋ ⟹ ?P1.0 E (Var V) T; ⋀E e1 T1 e2 T2 bop T. ⟦?is_lub,?P,E ⊢ e1 :: T1; ?P1.0 E e1 T1; ?is_lub,?P,E ⊢ e2 :: T2; ?P1.0 E e2 T2; ?P ⊢ T1«bop»T2 :: T⟧ ⟹ ?P1.0 E (e1 «bop» e2) T; ⋀E V T e T'. ⟦E V = ⌊T⌋; ?is_lub,?P,E ⊢ e :: T'; ?P1.0 E e T'; ?P ⊢ T' ≤ T; V ≠ this⟧ ⟹ ?P1.0 E (V:=e) Void; ⋀E a T i. ⟦?is_lub,?P,E ⊢ a :: T⌊⌉; ?P1.0 E a (T⌊⌉); ?is_lub,?P,E ⊢ i :: Integer; ?P1.0 E i Integer⟧ ⟹ ?P1.0 E (a⌊i⌉) T; ⋀E a T i e T'. ⟦?is_lub,?P,E ⊢ a :: T⌊⌉; ?P1.0 E a (T⌊⌉); ?is_lub,?P,E ⊢ i :: Integer; ?P1.0 E i Integer; ?is_lub,?P,E ⊢ e :: T'; ?P1.0 E e T'; ?P ⊢ T' ≤ T⟧ ⟹ ?P1.0 E (a⌊i⌉ := e) Void; ⋀E a T. ⟦?is_lub,?P,E ⊢ a :: T⌊⌉; ?P1.0 E a (T⌊⌉)⟧ ⟹ ?P1.0 E (a∙length) Integer; ⋀E e U C F T fm D. ⟦?is_lub,?P,E ⊢ e :: U; ?P1.0 E e U; class_type_of' U = ⌊C⌋; ?P ⊢ C sees F:T (fm) in D⟧ ⟹ ?P1.0 E (e∙F{D}) T; ⋀E e₁ U C F T fm D e₂ T'. ⟦?is_lub,?P,E ⊢ e₁ :: U; ?P1.0 E e₁ U; class_type_of' U = ⌊C⌋; ?P ⊢ C sees F:T (fm) in D; ?is_lub,?P,E ⊢ e₂ :: T'; ?P1.0 E e₂ T'; ?P ⊢ T' ≤ T⟧ ⟹ ?P1.0 E (e₁∙F{D} := e₂) Void; ⋀E e1 U C F T fm D e2 T' e3 T''. ⟦?is_lub,?P,E ⊢ e1 :: U; ?P1.0 E e1 U; class_type_of' U = ⌊C⌋; ?P ⊢ C sees F:T (fm) in D; volatile fm; ?is_lub,?P,E ⊢ e2 :: T'; ?P1.0 E e2 T'; ?P ⊢ T' ≤ T; ?is_lub,?P,E ⊢ e3 :: T''; ?P1.0 E e3 T''; ?P ⊢ T'' ≤ T⟧ ⟹ ?P1.0 E (e1∙compareAndSwap(D∙F, e2, e3)) Boolean; ⋀E e U C M Ts T meth D es Ts'. ⟦?is_lub,?P,E ⊢ e :: U; ?P1.0 E e U; class_type_of' U = ⌊C⌋; ?P ⊢ C sees M: Ts→T = meth in D; ?is_lub,?P,E ⊢ es [::] Ts'; ?P2.0 E es Ts'; ?P ⊢ Ts' [≤] Ts⟧ ⟹ ?P1.0 E (e∙M(es)) T; ⋀T E V e T' vo. ⟦is_type ?P T; ?is_lub,?P,E(V ↦ T) ⊢ e :: T'; ?P1.0 (E(V ↦ T)) e T'; case vo of None ⇒ True | ⌊v⌋ ⇒ ∃T'. typeof v = ⌊T'⌋ ∧ ?P ⊢ T' ≤ T⟧ ⟹ ?P1.0 E {V:T=vo; e} T'; ⋀E o' T e T'. ⟦?is_lub,?P,E ⊢ o' :: T; ?P1.0 E o' T; is_refT T; T ≠ NT; ?is_lub,?P,E ⊢ e :: T'; ?P1.0 E e T'⟧ ⟹ ?P1.0 E (sync(o') e) T'; ⋀E e₁ T₁ e₂ T₂. ⟦?is_lub,?P,E ⊢ e₁ :: T₁; ?P1.0 E e₁ T₁; ?is_lub,?P,E ⊢ e₂ :: T₂; ?P1.0 E e₂ T₂⟧ ⟹ ?P1.0 E (e₁;; e₂) T₂; ⋀E e e₁ T₁ e₂ T₂ T. ⟦?is_lub,?P,E ⊢ e :: Boolean; ?P1.0 E e Boolean; ?is_lub,?P,E ⊢ e₁ :: T₁; ?P1.0 E e₁ T₁; ?is_lub,?P,E ⊢ e₂ :: T₂; ?P1.0 E e₂ T₂; ?is_lub T₁ T₂ T⟧ ⟹ ?P1.0 E (if (e) e₁ else e₂) T; ⋀E e c T. ⟦?is_lub,?P,E ⊢ e :: Boolean; ?P1.0 E e Boolean; ?is_lub,?P,E ⊢ c :: T; ?P1.0 E c T⟧ ⟹ ?P1.0 E (while (e) c) Void; ⋀E e C. ⟦?is_lub,?P,E ⊢ e :: Class C; ?P1.0 E e (Class C); ?P ⊢ C ≼⇧* Throwable⟧ ⟹ ?P1.0 E (throw e) Void; ⋀E e₁ T V C e₂. ⟦?is_lub,?P,E ⊢ e₁ :: T; ?P1.0 E e₁ T; ?is_lub,?P,E(V ↦ Class C) ⊢ e₂ :: T; ?P1.0 (E(V ↦ Class C)) e₂ T; ?P ⊢ C ≼⇧* Throwable⟧ ⟹ ?P1.0 E (try e₁ catch(C V) e₂) T; ⋀E. ?P2.0 E [] []; ⋀E e T es Ts. ⟦?is_lub,?P,E ⊢ e :: T; ?P1.0 E e T; ?is_lub,?P,E ⊢ es [::] Ts; ?P2.0 E es Ts⟧ ⟹ ?P2.0 E (e # es) (T # Ts)⟧ ⟹ ?P2.0 ?x4.0 ?x5.0 ?x6.0›*)) (*goals: 1. ‹⋀C E. ⟦is_class P C; ran E ⊆ types P⟧ ⟹ is_type P (Class C)› 2. ‹⋀E e T. ⟦is_lub,P,E ⊢ e :: Integer; ran E ⊆ types P ⟹ is_type P Integer; is_type P (T⌊⌉); ran E ⊆ types P⟧ ⟹ is_type P (T⌊⌉)› 3. ‹⋀E e T U. ⟦is_lub,P,E ⊢ e :: T; ran E ⊆ types P ⟹ is_type P T; P ⊢ U ≤ T ∨ P ⊢ T ≤ U; is_type P U; ran E ⊆ types P⟧ ⟹ is_type P U› 4. ‹⋀E e T U. ⟦is_lub,P,E ⊢ e :: T; ran E ⊆ types P ⟹ is_type P T; P ⊢ U ≤ T ∨ P ⊢ T ≤ U; is_type P U; is_refT U; ran E ⊆ types P⟧ ⟹ is_type P Boolean› 5. ‹⋀v T E. ⟦typeof v = ⌊T⌋; ran E ⊆ types P⟧ ⟹ is_type P T› 6. ‹⋀E V T. ⟦E V = ⌊T⌋; ran E ⊆ types P⟧ ⟹ is_type P T› 7. ‹⋀E e1 T1 e2 T2 bop T. ⟦is_lub,P,E ⊢ e1 :: T1; ran E ⊆ types P ⟹ is_type P T1; is_lub,P,E ⊢ e2 :: T2; ran E ⊆ types P ⟹ is_type P T2; P ⊢ T1«bop»T2 :: T; ran E ⊆ types P⟧ ⟹ is_type P T› 8. ‹⋀E V T e T'. ⟦E V = ⌊T⌋; is_lub,P,E ⊢ e :: T'; ran E ⊆ types P ⟹ is_type P T'; P ⊢ T' ≤ T; V ≠ this; ran E ⊆ types P⟧ ⟹ is_type P Void› 9. ‹⋀E a T i. ⟦is_lub,P,E ⊢ a :: T⌊⌉; ran E ⊆ types P ⟹ is_type P (T⌊⌉); is_lub,P,E ⊢ i :: Integer; ran E ⊆ types P ⟹ is_type P Integer; ran E ⊆ types P⟧ ⟹ is_type P T› 10. ‹⋀E a T i e T'. ⟦is_lub,P,E ⊢ a :: T⌊⌉; ran E ⊆ types P ⟹ is_type P (T⌊⌉); is_lub,P,E ⊢ i :: Integer; ran E ⊆ types P ⟹ is_type P Integer; is_lub,P,E ⊢ e :: T'; ran E ⊆ types P ⟹ is_type P T'; P ⊢ T' ≤ T; ran E ⊆ types P⟧ ⟹ is_type P Void› 11. ‹⋀E a T. ⟦is_lub,P,E ⊢ a :: T⌊⌉; ran E ⊆ types P ⟹ is_type P (T⌊⌉); ran E ⊆ types P⟧ ⟹ is_type P Integer› 12. ‹⋀E e U C F T fm D. ⟦is_lub,P,E ⊢ e :: U; ran E ⊆ types P ⟹ is_type P U; class_type_of' U = ⌊C⌋; P ⊢ C sees F:T (fm) in D; ran E ⊆ types P⟧ ⟹ is_type P T› 13. ‹⋀E e₁ U C F T fm D e₂ T'. ⟦is_lub,P,E ⊢ e₁ :: U; ran E ⊆ types P ⟹ is_type P U; class_type_of' U = ⌊C⌋; P ⊢ C sees F:T (fm) in D; is_lub,P,E ⊢ e₂ :: T'; ran E ⊆ types P ⟹ is_type P T'; P ⊢ T' ≤ T; ran E ⊆ types P⟧ ⟹ is_type P Void› 14. ‹⋀E e1 U C F T fm D e2 T' e3 T''. ⟦is_lub,P,E ⊢ e1 :: U; ran E ⊆ types P ⟹ is_type P U; class_type_of' U = ⌊C⌋; P ⊢ C sees F:T (fm) in D; volatile fm; is_lub,P,E ⊢ e2 :: T'; ran E ⊆ types P ⟹ is_type P T'; P ⊢ T' ≤ T; is_lub,P,E ⊢ e3 :: T''; ran E ⊆ types P ⟹ is_type P T''; P ⊢ T'' ≤ T; ran E ⊆ types P⟧ ⟹ is_type P Boolean› 15. ‹⋀E e U C M Ts T meth D es Ts'. ⟦is_lub,P,E ⊢ e :: U; ran E ⊆ types P ⟹ is_type P U; class_type_of' U = ⌊C⌋; P ⊢ C sees M: Ts→T = meth in D; is_lub,P,E ⊢ es [::] Ts'; ran E ⊆ types P ⟹ set Ts' ⊆ types P; P ⊢ Ts' [≤] Ts; ran E ⊆ types P⟧ ⟹ is_type P T› 16. ‹⋀T E V e T' vo. ⟦is_type P T; is_lub,P,E(V ↦ T) ⊢ e :: T'; ran (E(V ↦ T)) ⊆ types P ⟹ is_type P T'; case vo of None ⇒ True | ⌊v⌋ ⇒ ∃T'. typeof v = ⌊T'⌋ ∧ P ⊢ T' ≤ T; ran E ⊆ types P⟧ ⟹ is_type P T'› 17. ‹⋀E o' T e T'. ⟦is_lub,P,E ⊢ o' :: T; ran E ⊆ types P ⟹ is_type P T; is_refT T; T ≠ NT; is_lub,P,E ⊢ e :: T'; ran E ⊆ types P ⟹ is_type P T'; ran E ⊆ types P⟧ ⟹ is_type P T'› 18. ‹⋀E e₁ T₁ e₂ T₂. ⟦is_lub,P,E ⊢ e₁ :: T₁; ran E ⊆ types P ⟹ is_type P T₁; is_lub,P,E ⊢ e₂ :: T₂; ran E ⊆ types P ⟹ is_type P T₂; ran E ⊆ types P⟧ ⟹ is_type P T₂› 19. ‹⋀E e e₁ T₁ e₂ T₂ T. ⟦is_lub,P,E ⊢ e :: Boolean; ran E ⊆ types P ⟹ is_type P Boolean; is_lub,P,E ⊢ e₁ :: T₁; ran E ⊆ types P ⟹ is_type P T₁; is_lub,P,E ⊢ e₂ :: T₂; ran E ⊆ types P ⟹ is_type P T₂; ⊢ lub(T₁, T₂) = T; ran E ⊆ types P⟧ ⟹ is_type P T› 20. ‹⋀E e c T. ⟦is_lub,P,E ⊢ e :: Boolean; ran E ⊆ types P ⟹ is_type P Boolean; is_lub,P,E ⊢ c :: T; ran E ⊆ types P ⟹ is_type P T; ran E ⊆ types P⟧ ⟹ is_type P Void› 21. ‹⋀E e C. ⟦is_lub,P,E ⊢ e :: Class C; ran E ⊆ types P ⟹ is_type P (Class C); P ⊢ C ≼⇧* Throwable; ran E ⊆ types P⟧ ⟹ is_type P Void› 22. ‹⋀E e₁ T V C e₂. ⟦is_lub,P,E ⊢ e₁ :: T; ran E ⊆ types P ⟹ is_type P T; is_lub,P,E(V ↦ Class C) ⊢ e₂ :: T; ran (E(V ↦ Class C)) ⊆ types P ⟹ is_type P T; P ⊢ C ≼⇧* Throwable; ran E ⊆ types P⟧ ⟹ is_type P T› 23. ‹⋀E. ran E ⊆ types P ⟹ set [] ⊆ types P› 24. ‹⋀E e T es Ts. ⟦is_lub,P,E ⊢ e :: T; ran E ⊆ types P ⟹ is_type P T; is_lub,P,E ⊢ es [::] Ts; ran E ⊆ types P ⟹ set Ts ⊆ types P; ran E ⊆ types P⟧ ⟹ set (T # Ts) ⊆ types P› 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 add:typeof_lit_is_type (*‹typeof ?v = ⌊?T⌋ ⟹ is_type ?P ?T›*)) (*discuss goal 6*) apply (fastforce intro:nth_mem (*‹?n < length ?xs ⟹ ?xs ! ?n ∈ set ?xs›*) simp add: ran_def (*‹ran ?m = {b. ∃a. ?m a = ⌊b⌋}›*)) (*discuss goal 7*) apply (simp add: WT_binop_is_type (*‹⟦?P ⊢ ?T1.0«?bop»?T2.0 :: ?T; is_type ?P ?T1.0; is_type ?P ?T2.0⟧ ⟹ is_type ?P ?T›*)) (*discuss goal 8*) apply simp (*discuss goal 9*) apply (simp del: is_type_array (*‹is_type ?P (?A⌊⌉) = (case ground_type ?A of NT ⇒ False | Class C ⇒ is_class ?P C | _ ⇒ True)›*) add: is_type_ArrayD (*‹is_type ?P (?T⌊⌉) ⟹ is_type ?P ?T›*)) (*discuss goal 10*) apply simp (*discuss goal 11*) apply simp (*discuss goal 12*) apply (simp add:sees_field_is_type[OF _ wf] (*‹P ⊢ ?C sees ?F:?T (?fm) in ?D ⟹ is_type P ?T›*)) (*discuss goal 13*) apply simp (*discuss goal 14*) apply simp (*discuss goal 15*) apply (fastforce dest: sees_wf_mdecl[OF wf] (*‹P ⊢ ?C sees ?M: ?Ts→?T = ?m in ?D ⟹ wf_mdecl wf_md P ?D (?M, ?Ts, ?T, ?m)›*) simp:wf_mdecl_def (*‹wf_mdecl ?wf_md ?P ?C ≡ λ(M, Ts, T, m). (∀T∈set Ts. is_type ?P T) ∧ is_type ?P T ∧ (case m of None ⇒ ?C∙M(Ts) :: T | ⌊mb⌋ ⇒ ?wf_md ?P ?C (M, Ts, T, mb))›*)) (*discuss goal 16*) apply (fastforce simp add: ran_def (*‹ran ?m = {b. ∃a. ?m a = ⌊b⌋}›*) split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*)) (*discuss goal 17*) apply (simp add: is_class_Object[OF wf] (*‹is_class P Object›*)) (*discuss goal 18*) apply simp (*discuss goal 19*) apply simp (*top goal: ‹⋀E e e₁ T₁ e₂ T₂ T. ⟦is_lub,P,E ⊢ e :: Boolean; ran E ⊆ types P ⟹ is_type P Boolean; is_lub,P,E ⊢ e₁ :: T₁; ran E ⊆ types P ⟹ is_type P T₁; is_lub,P,E ⊢ e₂ :: T₂; ran E ⊆ types P ⟹ is_type P T₂; ⊢ lub(T₁, T₂) = T; ran E ⊆ types P⟧ ⟹ is_type P T› and 5 goals remain*) apply (fastforce intro: is_lub_is_type (*‹⟦⊢ lub(?T1.0, ?T2.0) = ?T3.0; is_type P ?T1.0; is_type P ?T2.0⟧ ⟹ is_type P ?T3.0›*)) (*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 (*proven 24 subgoals*) . lemma fixes is_lub1 :: "ty ⇒ ty ⇒ ty ⇒ bool" ("⊢1 lub'((_,/ _)') = _" [51,51,51] 50) and is_lub2 :: "ty ⇒ ty ⇒ ty ⇒ bool" ("⊢2 lub'((_,/ _)') = _" [51,51,51] 50) assumes wf: "wf_prog wf_md P" and is_lub1_into_is_lub2: "⋀T1 T2 T3. ⟦ ⊢1 lub(T1, T2) = T3; is_type P T1; is_type P T2 ⟧ ⟹ ⊢2 lub(T1, T2) = T3" and is_lub2_is_type: "⋀T1 T2 T3. ⟦ ⊢2 lub(T1, T2) = T3; is_type P T1; is_type P T2 ⟧ ⟹ is_type P T3" shows WT_change_is_lub: "⟦ is_lub1,P,E ⊢ e :: T; ran E ⊆ types P ⟧ ⟹ is_lub2,P,E ⊢ e :: T" and WTs_change_is_lub: "⟦ is_lub1,P,E ⊢ es [::] Ts; ran E ⊆ types P ⟧ ⟹ is_lub2,P,E ⊢ es [::] Ts" proof (induct rule: WT_WTs.inducts (*‹⟦?is_lub,?P,?x1.0 ⊢ ?x2.0 :: ?x3.0; ⋀C E. is_class ?P C ⟹ ?P1.0 E (new C) (Class C); ⋀E e T. ⟦?is_lub,?P,E ⊢ e :: Integer; ?P1.0 E e Integer; is_type ?P (T⌊⌉)⟧ ⟹ ?P1.0 E (newA T⌊e⌉) (T⌊⌉); ⋀E e T U. ⟦?is_lub,?P,E ⊢ e :: T; ?P1.0 E e T; ?P ⊢ U ≤ T ∨ ?P ⊢ T ≤ U; is_type ?P U⟧ ⟹ ?P1.0 E (Cast U e) U; ⋀E e T U. ⟦?is_lub,?P,E ⊢ e :: T; ?P1.0 E e T; ?P ⊢ U ≤ T ∨ ?P ⊢ T ≤ U; is_type ?P U; is_refT U⟧ ⟹ ?P1.0 E (e instanceof U) Boolean; ⋀v T E. typeof v = ⌊T⌋ ⟹ ?P1.0 E (Val v) T; ⋀E V T. E V = ⌊T⌋ ⟹ ?P1.0 E (Var V) T; ⋀E e1 T1 e2 T2 bop T. ⟦?is_lub,?P,E ⊢ e1 :: T1; ?P1.0 E e1 T1; ?is_lub,?P,E ⊢ e2 :: T2; ?P1.0 E e2 T2; ?P ⊢ T1«bop»T2 :: T⟧ ⟹ ?P1.0 E (e1 «bop» e2) T; ⋀E V T e T'. ⟦E V = ⌊T⌋; ?is_lub,?P,E ⊢ e :: T'; ?P1.0 E e T'; ?P ⊢ T' ≤ T; V ≠ this⟧ ⟹ ?P1.0 E (V:=e) Void; ⋀E a T i. ⟦?is_lub,?P,E ⊢ a :: T⌊⌉; ?P1.0 E a (T⌊⌉); ?is_lub,?P,E ⊢ i :: Integer; ?P1.0 E i Integer⟧ ⟹ ?P1.0 E (a⌊i⌉) T; ⋀E a T i e T'. ⟦?is_lub,?P,E ⊢ a :: T⌊⌉; ?P1.0 E a (T⌊⌉); ?is_lub,?P,E ⊢ i :: Integer; ?P1.0 E i Integer; ?is_lub,?P,E ⊢ e :: T'; ?P1.0 E e T'; ?P ⊢ T' ≤ T⟧ ⟹ ?P1.0 E (a⌊i⌉ := e) Void; ⋀E a T. ⟦?is_lub,?P,E ⊢ a :: T⌊⌉; ?P1.0 E a (T⌊⌉)⟧ ⟹ ?P1.0 E (a∙length) Integer; ⋀E e U C F T fm D. ⟦?is_lub,?P,E ⊢ e :: U; ?P1.0 E e U; class_type_of' U = ⌊C⌋; ?P ⊢ C sees F:T (fm) in D⟧ ⟹ ?P1.0 E (e∙F{D}) T; ⋀E e₁ U C F T fm D e₂ T'. ⟦?is_lub,?P,E ⊢ e₁ :: U; ?P1.0 E e₁ U; class_type_of' U = ⌊C⌋; ?P ⊢ C sees F:T (fm) in D; ?is_lub,?P,E ⊢ e₂ :: T'; ?P1.0 E e₂ T'; ?P ⊢ T' ≤ T⟧ ⟹ ?P1.0 E (e₁∙F{D} := e₂) Void; ⋀E e1 U C F T fm D e2 T' e3 T''. ⟦?is_lub,?P,E ⊢ e1 :: U; ?P1.0 E e1 U; class_type_of' U = ⌊C⌋; ?P ⊢ C sees F:T (fm) in D; volatile fm; ?is_lub,?P,E ⊢ e2 :: T'; ?P1.0 E e2 T'; ?P ⊢ T' ≤ T; ?is_lub,?P,E ⊢ e3 :: T''; ?P1.0 E e3 T''; ?P ⊢ T'' ≤ T⟧ ⟹ ?P1.0 E (e1∙compareAndSwap(D∙F, e2, e3)) Boolean; ⋀E e U C M Ts T meth D es Ts'. ⟦?is_lub,?P,E ⊢ e :: U; ?P1.0 E e U; class_type_of' U = ⌊C⌋; ?P ⊢ C sees M: Ts→T = meth in D; ?is_lub,?P,E ⊢ es [::] Ts'; ?P2.0 E es Ts'; ?P ⊢ Ts' [≤] Ts⟧ ⟹ ?P1.0 E (e∙M(es)) T; ⋀T E V e T' vo. ⟦is_type ?P T; ?is_lub,?P,E(V ↦ T) ⊢ e :: T'; ?P1.0 (E(V ↦ T)) e T'; case vo of None ⇒ True | ⌊v⌋ ⇒ ∃T'. typeof v = ⌊T'⌋ ∧ ?P ⊢ T' ≤ T⟧ ⟹ ?P1.0 E {V:T=vo; e} T'; ⋀E o' T e T'. ⟦?is_lub,?P,E ⊢ o' :: T; ?P1.0 E o' T; is_refT T; T ≠ NT; ?is_lub,?P,E ⊢ e :: T'; ?P1.0 E e T'⟧ ⟹ ?P1.0 E (sync(o') e) T'; ⋀E e₁ T₁ e₂ T₂. ⟦?is_lub,?P,E ⊢ e₁ :: T₁; ?P1.0 E e₁ T₁; ?is_lub,?P,E ⊢ e₂ :: T₂; ?P1.0 E e₂ T₂⟧ ⟹ ?P1.0 E (e₁;; e₂) T₂; ⋀E e e₁ T₁ e₂ T₂ T. ⟦?is_lub,?P,E ⊢ e :: Boolean; ?P1.0 E e Boolean; ?is_lub,?P,E ⊢ e₁ :: T₁; ?P1.0 E e₁ T₁; ?is_lub,?P,E ⊢ e₂ :: T₂; ?P1.0 E e₂ T₂; ?is_lub T₁ T₂ T⟧ ⟹ ?P1.0 E (if (e) e₁ else e₂) T; ⋀E e c T. ⟦?is_lub,?P,E ⊢ e :: Boolean; ?P1.0 E e Boolean; ?is_lub,?P,E ⊢ c :: T; ?P1.0 E c T⟧ ⟹ ?P1.0 E (while (e) c) Void; ⋀E e C. ⟦?is_lub,?P,E ⊢ e :: Class C; ?P1.0 E e (Class C); ?P ⊢ C ≼⇧* Throwable⟧ ⟹ ?P1.0 E (throw e) Void; ⋀E e₁ T V C e₂. ⟦?is_lub,?P,E ⊢ e₁ :: T; ?P1.0 E e₁ T; ?is_lub,?P,E(V ↦ Class C) ⊢ e₂ :: T; ?P1.0 (E(V ↦ Class C)) e₂ T; ?P ⊢ C ≼⇧* Throwable⟧ ⟹ ?P1.0 E (try e₁ catch(C V) e₂) T; ⋀E. ?P2.0 E [] []; ⋀E e T es Ts. ⟦?is_lub,?P,E ⊢ e :: T; ?P1.0 E e T; ?is_lub,?P,E ⊢ es [::] Ts; ?P2.0 E es Ts⟧ ⟹ ?P2.0 E (e # es) (T # Ts)⟧ ⟹ ?P1.0 ?x1.0 ?x2.0 ?x3.0› ‹⟦?is_lub,?P,?x4.0 ⊢ ?x5.0 [::] ?x6.0; ⋀C E. is_class ?P C ⟹ ?P1.0 E (new C) (Class C); ⋀E e T. ⟦?is_lub,?P,E ⊢ e :: Integer; ?P1.0 E e Integer; is_type ?P (T⌊⌉)⟧ ⟹ ?P1.0 E (newA T⌊e⌉) (T⌊⌉); ⋀E e T U. ⟦?is_lub,?P,E ⊢ e :: T; ?P1.0 E e T; ?P ⊢ U ≤ T ∨ ?P ⊢ T ≤ U; is_type ?P U⟧ ⟹ ?P1.0 E (Cast U e) U; ⋀E e T U. ⟦?is_lub,?P,E ⊢ e :: T; ?P1.0 E e T; ?P ⊢ U ≤ T ∨ ?P ⊢ T ≤ U; is_type ?P U; is_refT U⟧ ⟹ ?P1.0 E (e instanceof U) Boolean; ⋀v T E. typeof v = ⌊T⌋ ⟹ ?P1.0 E (Val v) T; ⋀E V T. E V = ⌊T⌋ ⟹ ?P1.0 E (Var V) T; ⋀E e1 T1 e2 T2 bop T. ⟦?is_lub,?P,E ⊢ e1 :: T1; ?P1.0 E e1 T1; ?is_lub,?P,E ⊢ e2 :: T2; ?P1.0 E e2 T2; ?P ⊢ T1«bop»T2 :: T⟧ ⟹ ?P1.0 E (e1 «bop» e2) T; ⋀E V T e T'. ⟦E V = ⌊T⌋; ?is_lub,?P,E ⊢ e :: T'; ?P1.0 E e T'; ?P ⊢ T' ≤ T; V ≠ this⟧ ⟹ ?P1.0 E (V:=e) Void; ⋀E a T i. ⟦?is_lub,?P,E ⊢ a :: T⌊⌉; ?P1.0 E a (T⌊⌉); ?is_lub,?P,E ⊢ i :: Integer; ?P1.0 E i Integer⟧ ⟹ ?P1.0 E (a⌊i⌉) T; ⋀E a T i e T'. ⟦?is_lub,?P,E ⊢ a :: T⌊⌉; ?P1.0 E a (T⌊⌉); ?is_lub,?P,E ⊢ i :: Integer; ?P1.0 E i Integer; ?is_lub,?P,E ⊢ e :: T'; ?P1.0 E e T'; ?P ⊢ T' ≤ T⟧ ⟹ ?P1.0 E (a⌊i⌉ := e) Void; ⋀E a T. ⟦?is_lub,?P,E ⊢ a :: T⌊⌉; ?P1.0 E a (T⌊⌉)⟧ ⟹ ?P1.0 E (a∙length) Integer; ⋀E e U C F T fm D. ⟦?is_lub,?P,E ⊢ e :: U; ?P1.0 E e U; class_type_of' U = ⌊C⌋; ?P ⊢ C sees F:T (fm) in D⟧ ⟹ ?P1.0 E (e∙F{D}) T; ⋀E e₁ U C F T fm D e₂ T'. ⟦?is_lub,?P,E ⊢ e₁ :: U; ?P1.0 E e₁ U; class_type_of' U = ⌊C⌋; ?P ⊢ C sees F:T (fm) in D; ?is_lub,?P,E ⊢ e₂ :: T'; ?P1.0 E e₂ T'; ?P ⊢ T' ≤ T⟧ ⟹ ?P1.0 E (e₁∙F{D} := e₂) Void; ⋀E e1 U C F T fm D e2 T' e3 T''. ⟦?is_lub,?P,E ⊢ e1 :: U; ?P1.0 E e1 U; class_type_of' U = ⌊C⌋; ?P ⊢ C sees F:T (fm) in D; volatile fm; ?is_lub,?P,E ⊢ e2 :: T'; ?P1.0 E e2 T'; ?P ⊢ T' ≤ T; ?is_lub,?P,E ⊢ e3 :: T''; ?P1.0 E e3 T''; ?P ⊢ T'' ≤ T⟧ ⟹ ?P1.0 E (e1∙compareAndSwap(D∙F, e2, e3)) Boolean; ⋀E e U C M Ts T meth D es Ts'. ⟦?is_lub,?P,E ⊢ e :: U; ?P1.0 E e U; class_type_of' U = ⌊C⌋; ?P ⊢ C sees M: Ts→T = meth in D; ?is_lub,?P,E ⊢ es [::] Ts'; ?P2.0 E es Ts'; ?P ⊢ Ts' [≤] Ts⟧ ⟹ ?P1.0 E (e∙M(es)) T; ⋀T E V e T' vo. ⟦is_type ?P T; ?is_lub,?P,E(V ↦ T) ⊢ e :: T'; ?P1.0 (E(V ↦ T)) e T'; case vo of None ⇒ True | ⌊v⌋ ⇒ ∃T'. typeof v = ⌊T'⌋ ∧ ?P ⊢ T' ≤ T⟧ ⟹ ?P1.0 E {V:T=vo; e} T'; ⋀E o' T e T'. ⟦?is_lub,?P,E ⊢ o' :: T; ?P1.0 E o' T; is_refT T; T ≠ NT; ?is_lub,?P,E ⊢ e :: T'; ?P1.0 E e T'⟧ ⟹ ?P1.0 E (sync(o') e) T'; ⋀E e₁ T₁ e₂ T₂. ⟦?is_lub,?P,E ⊢ e₁ :: T₁; ?P1.0 E e₁ T₁; ?is_lub,?P,E ⊢ e₂ :: T₂; ?P1.0 E e₂ T₂⟧ ⟹ ?P1.0 E (e₁;; e₂) T₂; ⋀E e e₁ T₁ e₂ T₂ T. ⟦?is_lub,?P,E ⊢ e :: Boolean; ?P1.0 E e Boolean; ?is_lub,?P,E ⊢ e₁ :: T₁; ?P1.0 E e₁ T₁; ?is_lub,?P,E ⊢ e₂ :: T₂; ?P1.0 E e₂ T₂; ?is_lub T₁ T₂ T⟧ ⟹ ?P1.0 E (if (e) e₁ else e₂) T; ⋀E e c T. ⟦?is_lub,?P,E ⊢ e :: Boolean; ?P1.0 E e Boolean; ?is_lub,?P,E ⊢ c :: T; ?P1.0 E c T⟧ ⟹ ?P1.0 E (while (e) c) Void; ⋀E e C. ⟦?is_lub,?P,E ⊢ e :: Class C; ?P1.0 E e (Class C); ?P ⊢ C ≼⇧* Throwable⟧ ⟹ ?P1.0 E (throw e) Void; ⋀E e₁ T V C e₂. ⟦?is_lub,?P,E ⊢ e₁ :: T; ?P1.0 E e₁ T; ?is_lub,?P,E(V ↦ Class C) ⊢ e₂ :: T; ?P1.0 (E(V ↦ Class C)) e₂ T; ?P ⊢ C ≼⇧* Throwable⟧ ⟹ ?P1.0 E (try e₁ catch(C V) e₂) T; ⋀E. ?P2.0 E [] []; ⋀E e T es Ts. ⟦?is_lub,?P,E ⊢ e :: T; ?P1.0 E e T; ?is_lub,?P,E ⊢ es [::] Ts; ?P2.0 E es Ts⟧ ⟹ ?P2.0 E (e # es) (T # Ts)⟧ ⟹ ?P2.0 ?x4.0 ?x5.0 ?x6.0›*)) (*goals: 1. ‹⋀C E. ⟦is_class P C; ran E ⊆ types P⟧ ⟹ is_lub2,P,E ⊢ new C :: Class C› 2. ‹⋀E e T. ⟦is_lub1,P,E ⊢ e :: Integer; ran E ⊆ types P ⟹ is_lub2,P,E ⊢ e :: Integer; is_type P (T⌊⌉); ran E ⊆ types P⟧ ⟹ is_lub2,P,E ⊢ newA T⌊e⌉ :: T⌊⌉› 3. ‹⋀E e T U. ⟦is_lub1,P,E ⊢ e :: T; ran E ⊆ types P ⟹ is_lub2,P,E ⊢ e :: T; P ⊢ U ≤ T ∨ P ⊢ T ≤ U; is_type P U; ran E ⊆ types P⟧ ⟹ is_lub2,P,E ⊢ Cast U e :: U› 4. ‹⋀E e T U. ⟦is_lub1,P,E ⊢ e :: T; ran E ⊆ types P ⟹ is_lub2,P,E ⊢ e :: T; P ⊢ U ≤ T ∨ P ⊢ T ≤ U; is_type P U; is_refT U; ran E ⊆ types P⟧ ⟹ is_lub2,P,E ⊢ e instanceof U :: Boolean› 5. ‹⋀v T E. ⟦typeof v = ⌊T⌋; ran E ⊆ types P⟧ ⟹ is_lub2,P,E ⊢ Val v :: T› 6. ‹⋀E V T. ⟦E V = ⌊T⌋; ran E ⊆ types P⟧ ⟹ is_lub2,P,E ⊢ Var V :: T› 7. ‹⋀E e1 T1 e2 T2 bop T. ⟦is_lub1,P,E ⊢ e1 :: T1; ran E ⊆ types P ⟹ is_lub2,P,E ⊢ e1 :: T1; is_lub1,P,E ⊢ e2 :: T2; ran E ⊆ types P ⟹ is_lub2,P,E ⊢ e2 :: T2; P ⊢ T1«bop»T2 :: T; ran E ⊆ types P⟧ ⟹ is_lub2,P,E ⊢ e1 «bop» e2 :: T› 8. ‹⋀E V T e T'. ⟦E V = ⌊T⌋; is_lub1,P,E ⊢ e :: T'; ran E ⊆ types P ⟹ is_lub2,P,E ⊢ e :: T'; P ⊢ T' ≤ T; V ≠ this; ran E ⊆ types P⟧ ⟹ is_lub2,P,E ⊢ V:=e :: Void› 9. ‹⋀E a T i. ⟦is_lub1,P,E ⊢ a :: T⌊⌉; ran E ⊆ types P ⟹ is_lub2,P,E ⊢ a :: T⌊⌉; is_lub1,P,E ⊢ i :: Integer; ran E ⊆ types P ⟹ is_lub2,P,E ⊢ i :: Integer; ran E ⊆ types P⟧ ⟹ is_lub2,P,E ⊢ a⌊i⌉ :: T› 10. ‹⋀E a T i e T'. ⟦is_lub1,P,E ⊢ a :: T⌊⌉; ran E ⊆ types P ⟹ is_lub2,P,E ⊢ a :: T⌊⌉; is_lub1,P,E ⊢ i :: Integer; ran E ⊆ types P ⟹ is_lub2,P,E ⊢ i :: Integer; is_lub1,P,E ⊢ e :: T'; ran E ⊆ types P ⟹ is_lub2,P,E ⊢ e :: T'; P ⊢ T' ≤ T; ran E ⊆ types P⟧ ⟹ is_lub2,P,E ⊢ a⌊i⌉ := e :: Void› 11. ‹⋀E a T. ⟦is_lub1,P,E ⊢ a :: T⌊⌉; ran E ⊆ types P ⟹ is_lub2,P,E ⊢ a :: T⌊⌉; ran E ⊆ types P⟧ ⟹ is_lub2,P,E ⊢ a∙length :: Integer› 12. ‹⋀E e U C F T fm D. ⟦is_lub1,P,E ⊢ e :: U; ran E ⊆ types P ⟹ is_lub2,P,E ⊢ e :: U; class_type_of' U = ⌊C⌋; P ⊢ C sees F:T (fm) in D; ran E ⊆ types P⟧ ⟹ is_lub2,P,E ⊢ e∙F{D} :: T› 13. ‹⋀E e₁ U C F T fm D e₂ T'. ⟦is_lub1,P,E ⊢ e₁ :: U; ran E ⊆ types P ⟹ is_lub2,P,E ⊢ e₁ :: U; class_type_of' U = ⌊C⌋; P ⊢ C sees F:T (fm) in D; is_lub1,P,E ⊢ e₂ :: T'; ran E ⊆ types P ⟹ is_lub2,P,E ⊢ e₂ :: T'; P ⊢ T' ≤ T; ran E ⊆ types P⟧ ⟹ is_lub2,P,E ⊢ e₁∙F{D} := e₂ :: Void› 14. ‹⋀E e1 U C F T fm D e2 T' e3 T''. ⟦is_lub1,P,E ⊢ e1 :: U; ran E ⊆ types P ⟹ is_lub2,P,E ⊢ e1 :: U; class_type_of' U = ⌊C⌋; P ⊢ C sees F:T (fm) in D; volatile fm; is_lub1,P,E ⊢ e2 :: T'; ran E ⊆ types P ⟹ is_lub2,P,E ⊢ e2 :: T'; P ⊢ T' ≤ T; is_lub1,P,E ⊢ e3 :: T''; ran E ⊆ types P ⟹ is_lub2,P,E ⊢ e3 :: T''; P ⊢ T'' ≤ T; ran E ⊆ types P⟧ ⟹ is_lub2,P,E ⊢ e1∙compareAndSwap(D∙F, e2, e3) :: Boolean› 15. ‹⋀E e U C M Ts T meth D es Ts'. ⟦is_lub1,P,E ⊢ e :: U; ran E ⊆ types P ⟹ is_lub2,P,E ⊢ e :: U; class_type_of' U = ⌊C⌋; P ⊢ C sees M: Ts→T = meth in D; is_lub1,P,E ⊢ es [::] Ts'; ran E ⊆ types P ⟹ is_lub2,P,E ⊢ es [::] Ts'; P ⊢ Ts' [≤] Ts; ran E ⊆ types P⟧ ⟹ is_lub2,P,E ⊢ e∙M(es) :: T› 16. ‹⋀T E V e T' vo. ⟦is_type P T; is_lub1,P,E(V ↦ T) ⊢ e :: T'; ran (E(V ↦ T)) ⊆ types P ⟹ is_lub2,P,E(V ↦ T) ⊢ e :: T'; case vo of None ⇒ True | ⌊v⌋ ⇒ ∃T'. typeof v = ⌊T'⌋ ∧ P ⊢ T' ≤ T; ran E ⊆ types P⟧ ⟹ is_lub2,P,E ⊢ {V:T=vo; e} :: T'› 17. ‹⋀E o' T e T'. ⟦is_lub1,P,E ⊢ o' :: T; ran E ⊆ types P ⟹ is_lub2,P,E ⊢ o' :: T; is_refT T; T ≠ NT; is_lub1,P,E ⊢ e :: T'; ran E ⊆ types P ⟹ is_lub2,P,E ⊢ e :: T'; ran E ⊆ types P⟧ ⟹ is_lub2,P,E ⊢ sync(o') e :: T'› 18. ‹⋀E e₁ T₁ e₂ T₂. ⟦is_lub1,P,E ⊢ e₁ :: T₁; ran E ⊆ types P ⟹ is_lub2,P,E ⊢ e₁ :: T₁; is_lub1,P,E ⊢ e₂ :: T₂; ran E ⊆ types P ⟹ is_lub2,P,E ⊢ e₂ :: T₂; ran E ⊆ types P⟧ ⟹ is_lub2,P,E ⊢ e₁;; e₂ :: T₂› 19. ‹⋀E e e₁ T₁ e₂ T₂ T. ⟦is_lub1,P,E ⊢ e :: Boolean; ran E ⊆ types P ⟹ is_lub2,P,E ⊢ e :: Boolean; is_lub1,P,E ⊢ e₁ :: T₁; ran E ⊆ types P ⟹ is_lub2,P,E ⊢ e₁ :: T₁; is_lub1,P,E ⊢ e₂ :: T₂; ran E ⊆ types P ⟹ is_lub2,P,E ⊢ e₂ :: T₂; ⊢1 lub(T₁, T₂) = T; ran E ⊆ types P⟧ ⟹ is_lub2,P,E ⊢ if (e) e₁ else e₂ :: T› 20. ‹⋀E e c T. ⟦is_lub1,P,E ⊢ e :: Boolean; ran E ⊆ types P ⟹ is_lub2,P,E ⊢ e :: Boolean; is_lub1,P,E ⊢ c :: T; ran E ⊆ types P ⟹ is_lub2,P,E ⊢ c :: T; ran E ⊆ types P⟧ ⟹ is_lub2,P,E ⊢ while (e) c :: Void› 21. ‹⋀E e C. ⟦is_lub1,P,E ⊢ e :: Class C; ran E ⊆ types P ⟹ is_lub2,P,E ⊢ e :: Class C; P ⊢ C ≼⇧* Throwable; ran E ⊆ types P⟧ ⟹ is_lub2,P,E ⊢ throw e :: Void› 22. ‹⋀E e₁ T V C e₂. ⟦is_lub1,P,E ⊢ e₁ :: T; ran E ⊆ types P ⟹ is_lub2,P,E ⊢ e₁ :: T; is_lub1,P,E(V ↦ Class C) ⊢ e₂ :: T; ran (E(V ↦ Class C)) ⊆ types P ⟹ is_lub2,P,E(V ↦ Class C) ⊢ e₂ :: T; P ⊢ C ≼⇧* Throwable; ran E ⊆ types P⟧ ⟹ is_lub2,P,E ⊢ try e₁ catch(C V) e₂ :: T› 23. ‹⋀E. ran E ⊆ types P ⟹ is_lub2,P,E ⊢ [] [::] []› 24. ‹⋀E e T es Ts. ⟦is_lub1,P,E ⊢ e :: T; ran E ⊆ types P ⟹ is_lub2,P,E ⊢ e :: T; is_lub1,P,E ⊢ es [::] Ts; ran E ⊆ types P ⟹ is_lub2,P,E ⊢ es [::] Ts; ran E ⊆ types P⟧ ⟹ is_lub2,P,E ⊢ e # es [::] T # Ts›*) case (WTBlock U E V e' T vo) (*‹is_type (P::'a J_prog) (U::ty)› ‹is_lub1,(P::'a J_prog),(E::String.literal ⇒ ty option)(V::String.literal ↦ U::ty) ⊢ (e'::'a expr) :: T::ty› ‹ran (E(V ↦ U)) ⊆ types P ⟹ is_lub2,P,E(V ↦ U) ⊢ e' :: T› ‹case vo of None ⇒ True | ⌊v⌋ ⇒ ∃T'. typeof v = ⌊T'⌋ ∧ P ⊢ T' ≤ U› ‹ran E ⊆ types P›*) from ‹is_type P U› (*‹is_type (P::'a J_prog) (U::ty)›*) ‹ran E ⊆ types P› (*‹ran E ⊆ types P›*) have "ran (E(V ↦ U)) ⊆ types P" by (auto simp add: ran_def (*‹ran ?m = {b. ∃a. ?m a = ⌊b⌋}›*)) hence "is_lub2,P,E(V ↦ U) ⊢ e' :: T" by (rule WTBlock (*‹is_type P U› ‹is_lub1,P,E(V ↦ U) ⊢ e' :: T› ‹ran (E(V ↦ U)) ⊆ types P ⟹ is_lub2,P,E(V ↦ U) ⊢ e' :: T› ‹case vo of None ⇒ True | ⌊v⌋ ⇒ ∃T'. typeof v = ⌊T'⌋ ∧ P ⊢ T' ≤ U› ‹ran E ⊆ types P›*)) with ‹is_type P U› (*‹is_type P U›*) show "?case" (*goal: ‹is_lub2,(P::'a J_prog),(E::String.literal ⇒ ty option) ⊢ {V::String.literal:U::ty=vo::'a val option; e'::'a expr} :: T::ty›*) using ‹case vo of None ⇒ True | ⌊v⌋ ⇒ ∃T'. typeof v = ⌊T'⌋ ∧ P ⊢ T' ≤ U› (*‹case vo of None ⇒ True | ⌊v⌋ ⇒ ∃T'. typeof v = ⌊T'⌋ ∧ P ⊢ T' ≤ U›*) by auto next (*goals: 1. ‹⋀C E. ⟦is_class P C; ran E ⊆ types P⟧ ⟹ is_lub2,P,E ⊢ new C :: Class C› 2. ‹⋀E e T. ⟦is_lub1,P,E ⊢ e :: Integer; ran E ⊆ types P ⟹ is_lub2,P,E ⊢ e :: Integer; is_type P (T⌊⌉); ran E ⊆ types P⟧ ⟹ is_lub2,P,E ⊢ newA T⌊e⌉ :: T⌊⌉› 3. ‹⋀E e T U. ⟦is_lub1,P,E ⊢ e :: T; ran E ⊆ types P ⟹ is_lub2,P,E ⊢ e :: T; P ⊢ U ≤ T ∨ P ⊢ T ≤ U; is_type P U; ran E ⊆ types P⟧ ⟹ is_lub2,P,E ⊢ Cast U e :: U› 4. ‹⋀E e T U. ⟦is_lub1,P,E ⊢ e :: T; ran E ⊆ types P ⟹ is_lub2,P,E ⊢ e :: T; P ⊢ U ≤ T ∨ P ⊢ T ≤ U; is_type P U; is_refT U; ran E ⊆ types P⟧ ⟹ is_lub2,P,E ⊢ e instanceof U :: Boolean› 5. ‹⋀v T E. ⟦typeof v = ⌊T⌋; ran E ⊆ types P⟧ ⟹ is_lub2,P,E ⊢ Val v :: T› 6. ‹⋀E V T. ⟦E V = ⌊T⌋; ran E ⊆ types P⟧ ⟹ is_lub2,P,E ⊢ Var V :: T› 7. ‹⋀E e1 T1 e2 T2 bop T. ⟦is_lub1,P,E ⊢ e1 :: T1; ran E ⊆ types P ⟹ is_lub2,P,E ⊢ e1 :: T1; is_lub1,P,E ⊢ e2 :: T2; ran E ⊆ types P ⟹ is_lub2,P,E ⊢ e2 :: T2; P ⊢ T1«bop»T2 :: T; ran E ⊆ types P⟧ ⟹ is_lub2,P,E ⊢ e1 «bop» e2 :: T› 8. ‹⋀E V T e T'. ⟦E V = ⌊T⌋; is_lub1,P,E ⊢ e :: T'; ran E ⊆ types P ⟹ is_lub2,P,E ⊢ e :: T'; P ⊢ T' ≤ T; V ≠ this; ran E ⊆ types P⟧ ⟹ is_lub2,P,E ⊢ V:=e :: Void› 9. ‹⋀E a T i. ⟦is_lub1,P,E ⊢ a :: T⌊⌉; ran E ⊆ types P ⟹ is_lub2,P,E ⊢ a :: T⌊⌉; is_lub1,P,E ⊢ i :: Integer; ran E ⊆ types P ⟹ is_lub2,P,E ⊢ i :: Integer; ran E ⊆ types P⟧ ⟹ is_lub2,P,E ⊢ a⌊i⌉ :: T› 10. ‹⋀E a T i e T'. ⟦is_lub1,P,E ⊢ a :: T⌊⌉; ran E ⊆ types P ⟹ is_lub2,P,E ⊢ a :: T⌊⌉; is_lub1,P,E ⊢ i :: Integer; ran E ⊆ types P ⟹ is_lub2,P,E ⊢ i :: Integer; is_lub1,P,E ⊢ e :: T'; ran E ⊆ types P ⟹ is_lub2,P,E ⊢ e :: T'; P ⊢ T' ≤ T; ran E ⊆ types P⟧ ⟹ is_lub2,P,E ⊢ a⌊i⌉ := e :: Void› 11. ‹⋀E a T. ⟦is_lub1,P,E ⊢ a :: T⌊⌉; ran E ⊆ types P ⟹ is_lub2,P,E ⊢ a :: T⌊⌉; ran E ⊆ types P⟧ ⟹ is_lub2,P,E ⊢ a∙length :: Integer› 12. ‹⋀E e U C F T fm D. ⟦is_lub1,P,E ⊢ e :: U; ran E ⊆ types P ⟹ is_lub2,P,E ⊢ e :: U; class_type_of' U = ⌊C⌋; P ⊢ C sees F:T (fm) in D; ran E ⊆ types P⟧ ⟹ is_lub2,P,E ⊢ e∙F{D} :: T› 13. ‹⋀E e₁ U C F T fm D e₂ T'. ⟦is_lub1,P,E ⊢ e₁ :: U; ran E ⊆ types P ⟹ is_lub2,P,E ⊢ e₁ :: U; class_type_of' U = ⌊C⌋; P ⊢ C sees F:T (fm) in D; is_lub1,P,E ⊢ e₂ :: T'; ran E ⊆ types P ⟹ is_lub2,P,E ⊢ e₂ :: T'; P ⊢ T' ≤ T; ran E ⊆ types P⟧ ⟹ is_lub2,P,E ⊢ e₁∙F{D} := e₂ :: Void› 14. ‹⋀E e1 U C F T fm D e2 T' e3 T''. ⟦is_lub1,P,E ⊢ e1 :: U; ran E ⊆ types P ⟹ is_lub2,P,E ⊢ e1 :: U; class_type_of' U = ⌊C⌋; P ⊢ C sees F:T (fm) in D; volatile fm; is_lub1,P,E ⊢ e2 :: T'; ran E ⊆ types P ⟹ is_lub2,P,E ⊢ e2 :: T'; P ⊢ T' ≤ T; is_lub1,P,E ⊢ e3 :: T''; ran E ⊆ types P ⟹ is_lub2,P,E ⊢ e3 :: T''; P ⊢ T'' ≤ T; ran E ⊆ types P⟧ ⟹ is_lub2,P,E ⊢ e1∙compareAndSwap(D∙F, e2, e3) :: Boolean› 15. ‹⋀E e U C M Ts T meth D es Ts'. ⟦is_lub1,P,E ⊢ e :: U; ran E ⊆ types P ⟹ is_lub2,P,E ⊢ e :: U; class_type_of' U = ⌊C⌋; P ⊢ C sees M: Ts→T = meth in D; is_lub1,P,E ⊢ es [::] Ts'; ran E ⊆ types P ⟹ is_lub2,P,E ⊢ es [::] Ts'; P ⊢ Ts' [≤] Ts; ran E ⊆ types P⟧ ⟹ is_lub2,P,E ⊢ e∙M(es) :: T› 16. ‹⋀E o' T e T'. ⟦is_lub1,P,E ⊢ o' :: T; ran E ⊆ types P ⟹ is_lub2,P,E ⊢ o' :: T; is_refT T; T ≠ NT; is_lub1,P,E ⊢ e :: T'; ran E ⊆ types P ⟹ is_lub2,P,E ⊢ e :: T'; ran E ⊆ types P⟧ ⟹ is_lub2,P,E ⊢ sync(o') e :: T'› 17. ‹⋀E e₁ T₁ e₂ T₂. ⟦is_lub1,P,E ⊢ e₁ :: T₁; ran E ⊆ types P ⟹ is_lub2,P,E ⊢ e₁ :: T₁; is_lub1,P,E ⊢ e₂ :: T₂; ran E ⊆ types P ⟹ is_lub2,P,E ⊢ e₂ :: T₂; ran E ⊆ types P⟧ ⟹ is_lub2,P,E ⊢ e₁;; e₂ :: T₂› 18. ‹⋀E e e₁ T₁ e₂ T₂ T. ⟦is_lub1,P,E ⊢ e :: Boolean; ran E ⊆ types P ⟹ is_lub2,P,E ⊢ e :: Boolean; is_lub1,P,E ⊢ e₁ :: T₁; ran E ⊆ types P ⟹ is_lub2,P,E ⊢ e₁ :: T₁; is_lub1,P,E ⊢ e₂ :: T₂; ran E ⊆ types P ⟹ is_lub2,P,E ⊢ e₂ :: T₂; ⊢1 lub(T₁, T₂) = T; ran E ⊆ types P⟧ ⟹ is_lub2,P,E ⊢ if (e) e₁ else e₂ :: T› 19. ‹⋀E e c T. ⟦is_lub1,P,E ⊢ e :: Boolean; ran E ⊆ types P ⟹ is_lub2,P,E ⊢ e :: Boolean; is_lub1,P,E ⊢ c :: T; ran E ⊆ types P ⟹ is_lub2,P,E ⊢ c :: T; ran E ⊆ types P⟧ ⟹ is_lub2,P,E ⊢ while (e) c :: Void› 20. ‹⋀E e C. ⟦is_lub1,P,E ⊢ e :: Class C; ran E ⊆ types P ⟹ is_lub2,P,E ⊢ e :: Class C; P ⊢ C ≼⇧* Throwable; ran E ⊆ types P⟧ ⟹ is_lub2,P,E ⊢ throw e :: Void› 21. ‹⋀E e₁ T V C e₂. ⟦is_lub1,P,E ⊢ e₁ :: T; ran E ⊆ types P ⟹ is_lub2,P,E ⊢ e₁ :: T; is_lub1,P,E(V ↦ Class C) ⊢ e₂ :: T; ran (E(V ↦ Class C)) ⊆ types P ⟹ is_lub2,P,E(V ↦ Class C) ⊢ e₂ :: T; P ⊢ C ≼⇧* Throwable; ran E ⊆ types P⟧ ⟹ is_lub2,P,E ⊢ try e₁ catch(C V) e₂ :: T› 22. ‹⋀E. ran E ⊆ types P ⟹ is_lub2,P,E ⊢ [] [::] []› 23. ‹⋀E e T es Ts. ⟦is_lub1,P,E ⊢ e :: T; ran E ⊆ types P ⟹ is_lub2,P,E ⊢ e :: T; is_lub1,P,E ⊢ es [::] Ts; ran E ⊆ types P ⟹ is_lub2,P,E ⊢ es [::] Ts; ran E ⊆ types P⟧ ⟹ is_lub2,P,E ⊢ e # es [::] T # Ts›*) case (WTCond E e e1 T1 e2 T2 T) (*‹is_lub1,P,E ⊢ e :: Boolean› ‹ran E ⊆ types P ⟹ is_lub2,P,E ⊢ e :: Boolean› ‹is_lub1,P,E ⊢ e1 :: T1› ‹ran E ⊆ types P ⟹ is_lub2,P,E ⊢ e1 :: T1› ‹is_lub1,P,E ⊢ e2 :: T2› ‹ran E ⊆ types P ⟹ is_lub2,P,E ⊢ e2 :: T2› ‹⊢1 lub((T1::ty), (T2::ty)) = (T::ty)› ‹ran (E::String.literal ⇒ ty option) ⊆ types (P::'a J_prog)›*) from ‹ran E ⊆ types P› (*‹ran (E::String.literal ⇒ ty option) ⊆ types (P::'a J_prog)›*) have "is_lub2,P,E ⊢ e :: Boolean" "is_lub2,P,E ⊢ e1 :: T1" "is_lub2,P,E ⊢ e2 :: T2" (*goals: 1. ‹is_lub2,P,E ⊢ e :: Boolean› 2. ‹is_lub2,P,E ⊢ e1 :: T1› 3. ‹is_lub2,P,E ⊢ e2 :: T2› discuss goal 1*) apply (rule WTCond (*‹is_lub1,(P::'a J_prog),(E::String.literal ⇒ ty option) ⊢ (e::'a expr) :: Boolean› ‹ran (E::String.literal ⇒ ty option) ⊆ types (P::'a J_prog) ⟹ is_lub2,P,E ⊢ (e::'a expr) :: Boolean› ‹is_lub1,(P::'a J_prog),(E::String.literal ⇒ ty option) ⊢ (e1::'a expr) :: T1::ty› ‹ran (E::String.literal ⇒ ty option) ⊆ types (P::'a J_prog) ⟹ is_lub2,P,E ⊢ (e1::'a expr) :: T1::ty› ‹is_lub1,(P::'a J_prog),(E::String.literal ⇒ ty option) ⊢ (e2::'a expr) :: T2::ty› ‹ran (E::String.literal ⇒ ty option) ⊆ types (P::'a J_prog) ⟹ is_lub2,P,E ⊢ (e2::'a expr) :: T2::ty› ‹⊢1 lub((T1::ty), (T2::ty)) = (T::ty)› ‹ran (E::String.literal ⇒ ty option) ⊆ types (P::'a J_prog)›*)) (*discuss goal 2*) apply (rule WTCond (*‹is_lub1,P,E ⊢ e :: Boolean› ‹ran E ⊆ types P ⟹ is_lub2,P,E ⊢ e :: Boolean› ‹is_lub1,P,E ⊢ e1 :: T1› ‹ran E ⊆ types P ⟹ is_lub2,P,E ⊢ e1 :: T1› ‹is_lub1,P,E ⊢ e2 :: T2› ‹ran E ⊆ types P ⟹ is_lub2,P,E ⊢ e2 :: T2› ‹⊢1 lub(T1, T2) = T› ‹ran E ⊆ types P›*)) (*top goal: ‹is_lub2,P,E ⊢ e1 :: T1› and 1 goal remains*) apply (rule WTCond (*‹is_lub1,P,E ⊢ e :: Boolean› ‹ran E ⊆ types P ⟹ is_lub2,P,E ⊢ e :: Boolean› ‹is_lub1,P,E ⊢ e1 :: T1› ‹ran E ⊆ types P ⟹ is_lub2,P,E ⊢ e1 :: T1› ‹is_lub1,P,E ⊢ e2 :: T2› ‹ran E ⊆ types P ⟹ is_lub2,P,E ⊢ e2 :: T2› ‹⊢1 lub(T1, T2) = T› ‹ran E ⊆ types P›*)) (*discuss goal 3*) apply (rule WTCond (*‹is_lub1,P,E ⊢ e :: Boolean› ‹ran E ⊆ types P ⟹ is_lub2,P,E ⊢ e :: Boolean› ‹is_lub1,P,E ⊢ e1 :: T1› ‹ran E ⊆ types P ⟹ is_lub2,P,E ⊢ e1 :: T1› ‹is_lub1,P,E ⊢ e2 :: T2› ‹ran E ⊆ types P ⟹ is_lub2,P,E ⊢ e2 :: T2› ‹⊢1 lub(T1, T2) = T› ‹ran E ⊆ types P›*)) (*goal: ‹is_lub2,P,E ⊢ e2 :: T2›*) apply (rule WTCond (*‹is_lub1,P,E ⊢ e :: Boolean› ‹ran E ⊆ types P ⟹ is_lub2,P,E ⊢ e :: Boolean› ‹is_lub1,P,E ⊢ e1 :: T1› ‹ran E ⊆ types P ⟹ is_lub2,P,E ⊢ e1 :: T1› ‹is_lub1,P,E ⊢ e2 :: T2› ‹ran E ⊆ types P ⟹ is_lub2,P,E ⊢ e2 :: T2› ‹⊢1 lub(T1, T2) = T› ‹ran E ⊆ types P›*)) (*proven 3 subgoals*) . moreover from is_lub2_is_type (*‹⟦⊢2 lub(?T1.0, ?T2.0) = ?T3.0; is_type P ?T1.0; is_type P ?T2.0⟧ ⟹ is_type P ?T3.0›*) wf (*‹wf_prog wf_md P›*) ‹is_lub2,P,E ⊢ e1 :: T1› (*‹is_lub2,P,E ⊢ e1 :: T1›*) ‹ran E ⊆ types P› (*‹ran E ⊆ types P›*) have "is_type P T1" apply (rule WT_is_type (*‹⟦⋀T1 T2 T3. ⟦?is_lub T1 T2 T3; is_type ?P T1; is_type ?P T2⟧ ⟹ is_type ?P T3; wf_prog ?wf_md ?P; ?is_lub,?P,?E ⊢ ?e :: ?T; ran ?E ⊆ types ?P⟧ ⟹ is_type ?P ?T›*)) (*goals: 1. ‹⋀T1 T2 T3. ⟦⊢2 lub(T1, T2) = T3; is_type P T1; is_type P T2⟧ ⟹ ⊢2 lub(?T1.1 T1 T2 T3, ?T2.1 T1 T2 T3) = T3› 2. ‹⋀T1 T2 T3. ⟦⊢2 lub(T1, T2) = T3; is_type P T1; is_type P T2⟧ ⟹ is_type P (?T1.1 T1 T2 T3)› 3. ‹⋀T1 T2 T3. ⟦⊢2 lub(T1, T2) = T3; is_type P T1; is_type P T2⟧ ⟹ is_type P (?T2.1 T1 T2 T3)› discuss goal 1*) apply ((assumption)[1]) (*discuss goal 2*) apply ((assumption)[1]) (*discuss goal 3*) . (*proven 3 subgoals*) from is_lub2_is_type (*‹⟦⊢2 lub(?T1.0, ?T2.0) = ?T3.0; is_type P ?T1.0; is_type P ?T2.0⟧ ⟹ is_type P ?T3.0›*) wf (*‹wf_prog wf_md P›*) ‹is_lub2,P,E ⊢ e2 :: T2› (*‹is_lub2,(P::'a J_prog),(E::String.literal ⇒ ty option) ⊢ (e2::'a expr) :: T2::ty›*) ‹ran E ⊆ types P› (*‹ran E ⊆ types P›*) have "is_type P T2" apply (rule WT_is_type (*‹⟦⋀T1 T2 T3. ⟦?is_lub T1 T2 T3; is_type ?P T1; is_type ?P T2⟧ ⟹ is_type ?P T3; wf_prog ?wf_md ?P; ?is_lub,?P,?E ⊢ ?e :: ?T; ran ?E ⊆ types ?P⟧ ⟹ is_type ?P ?T›*)) (*goals: 1. ‹⋀T1 T2 T3. ⟦⊢2 lub(T1, T2) = T3; is_type P T1; is_type P T2⟧ ⟹ ⊢2 lub(?T1.1 T1 T2 T3, ?T2.1 T1 T2 T3) = T3› 2. ‹⋀T1 T2 T3. ⟦⊢2 lub(T1, T2) = T3; is_type P T1; is_type P T2⟧ ⟹ is_type P (?T1.1 T1 T2 T3)› 3. ‹⋀T1 T2 T3. ⟦⊢2 lub(T1, T2) = T3; is_type P T1; is_type P T2⟧ ⟹ is_type P (?T2.1 T1 T2 T3)› discuss goal 1*) apply ((assumption)[1]) (*discuss goal 2*) apply ((assumption)[1]) (*discuss goal 3*) . (*proven 3 subgoals*) with ‹⊢1 lub(T1, T2) = T› (*‹⊢1 lub(T1, T2) = T›*) ‹is_type P T1› (*‹is_type P T1›*) have "⊢2 lub(T1, T2) = T" by (rule is_lub1_into_is_lub2 (*‹⟦⊢1 lub(?T1.0, ?T2.0) = ?T3.0; is_type P ?T1.0; is_type P ?T2.0⟧ ⟹ ⊢2 lub(?T1.0, ?T2.0) = ?T3.0›*)) ultimately show "?case" (*goal: ‹is_lub2,P,E ⊢ if (e) e1 else e2 :: T›*) by standard next (*goals: 1. ‹⋀C E. ⟦is_class P C; ran E ⊆ types P⟧ ⟹ is_lub2,P,E ⊢ new C :: Class C› 2. ‹⋀E e T. ⟦is_lub1,P,E ⊢ e :: Integer; ran E ⊆ types P ⟹ is_lub2,P,E ⊢ e :: Integer; is_type P (T⌊⌉); ran E ⊆ types P⟧ ⟹ is_lub2,P,E ⊢ newA T⌊e⌉ :: T⌊⌉› 3. ‹⋀E e T U. ⟦is_lub1,P,E ⊢ e :: T; ran E ⊆ types P ⟹ is_lub2,P,E ⊢ e :: T; P ⊢ U ≤ T ∨ P ⊢ T ≤ U; is_type P U; ran E ⊆ types P⟧ ⟹ is_lub2,P,E ⊢ Cast U e :: U› 4. ‹⋀E e T U. ⟦is_lub1,P,E ⊢ e :: T; ran E ⊆ types P ⟹ is_lub2,P,E ⊢ e :: T; P ⊢ U ≤ T ∨ P ⊢ T ≤ U; is_type P U; is_refT U; ran E ⊆ types P⟧ ⟹ is_lub2,P,E ⊢ e instanceof U :: Boolean› 5. ‹⋀v T E. ⟦typeof v = ⌊T⌋; ran E ⊆ types P⟧ ⟹ is_lub2,P,E ⊢ Val v :: T› 6. ‹⋀E V T. ⟦E V = ⌊T⌋; ran E ⊆ types P⟧ ⟹ is_lub2,P,E ⊢ Var V :: T› 7. ‹⋀E e1 T1 e2 T2 bop T. ⟦is_lub1,P,E ⊢ e1 :: T1; ran E ⊆ types P ⟹ is_lub2,P,E ⊢ e1 :: T1; is_lub1,P,E ⊢ e2 :: T2; ran E ⊆ types P ⟹ is_lub2,P,E ⊢ e2 :: T2; P ⊢ T1«bop»T2 :: T; ran E ⊆ types P⟧ ⟹ is_lub2,P,E ⊢ e1 «bop» e2 :: T› 8. ‹⋀E V T e T'. ⟦E V = ⌊T⌋; is_lub1,P,E ⊢ e :: T'; ran E ⊆ types P ⟹ is_lub2,P,E ⊢ e :: T'; P ⊢ T' ≤ T; V ≠ this; ran E ⊆ types P⟧ ⟹ is_lub2,P,E ⊢ V:=e :: Void› 9. ‹⋀E a T i. ⟦is_lub1,P,E ⊢ a :: T⌊⌉; ran E ⊆ types P ⟹ is_lub2,P,E ⊢ a :: T⌊⌉; is_lub1,P,E ⊢ i :: Integer; ran E ⊆ types P ⟹ is_lub2,P,E ⊢ i :: Integer; ran E ⊆ types P⟧ ⟹ is_lub2,P,E ⊢ a⌊i⌉ :: T› 10. ‹⋀E a T i e T'. ⟦is_lub1,P,E ⊢ a :: T⌊⌉; ran E ⊆ types P ⟹ is_lub2,P,E ⊢ a :: T⌊⌉; is_lub1,P,E ⊢ i :: Integer; ran E ⊆ types P ⟹ is_lub2,P,E ⊢ i :: Integer; is_lub1,P,E ⊢ e :: T'; ran E ⊆ types P ⟹ is_lub2,P,E ⊢ e :: T'; P ⊢ T' ≤ T; ran E ⊆ types P⟧ ⟹ is_lub2,P,E ⊢ a⌊i⌉ := e :: Void› 11. ‹⋀E a T. ⟦is_lub1,P,E ⊢ a :: T⌊⌉; ran E ⊆ types P ⟹ is_lub2,P,E ⊢ a :: T⌊⌉; ran E ⊆ types P⟧ ⟹ is_lub2,P,E ⊢ a∙length :: Integer› 12. ‹⋀E e U C F T fm D. ⟦is_lub1,P,E ⊢ e :: U; ran E ⊆ types P ⟹ is_lub2,P,E ⊢ e :: U; class_type_of' U = ⌊C⌋; P ⊢ C sees F:T (fm) in D; ran E ⊆ types P⟧ ⟹ is_lub2,P,E ⊢ e∙F{D} :: T› 13. ‹⋀E e₁ U C F T fm D e₂ T'. ⟦is_lub1,P,E ⊢ e₁ :: U; ran E ⊆ types P ⟹ is_lub2,P,E ⊢ e₁ :: U; class_type_of' U = ⌊C⌋; P ⊢ C sees F:T (fm) in D; is_lub1,P,E ⊢ e₂ :: T'; ran E ⊆ types P ⟹ is_lub2,P,E ⊢ e₂ :: T'; P ⊢ T' ≤ T; ran E ⊆ types P⟧ ⟹ is_lub2,P,E ⊢ e₁∙F{D} := e₂ :: Void› 14. ‹⋀E e1 U C F T fm D e2 T' e3 T''. ⟦is_lub1,P,E ⊢ e1 :: U; ran E ⊆ types P ⟹ is_lub2,P,E ⊢ e1 :: U; class_type_of' U = ⌊C⌋; P ⊢ C sees F:T (fm) in D; volatile fm; is_lub1,P,E ⊢ e2 :: T'; ran E ⊆ types P ⟹ is_lub2,P,E ⊢ e2 :: T'; P ⊢ T' ≤ T; is_lub1,P,E ⊢ e3 :: T''; ran E ⊆ types P ⟹ is_lub2,P,E ⊢ e3 :: T''; P ⊢ T'' ≤ T; ran E ⊆ types P⟧ ⟹ is_lub2,P,E ⊢ e1∙compareAndSwap(D∙F, e2, e3) :: Boolean› 15. ‹⋀E e U C M Ts T meth D es Ts'. ⟦is_lub1,P,E ⊢ e :: U; ran E ⊆ types P ⟹ is_lub2,P,E ⊢ e :: U; class_type_of' U = ⌊C⌋; P ⊢ C sees M: Ts→T = meth in D; is_lub1,P,E ⊢ es [::] Ts'; ran E ⊆ types P ⟹ is_lub2,P,E ⊢ es [::] Ts'; P ⊢ Ts' [≤] Ts; ran E ⊆ types P⟧ ⟹ is_lub2,P,E ⊢ e∙M(es) :: T› 16. ‹⋀E o' T e T'. ⟦is_lub1,P,E ⊢ o' :: T; ran E ⊆ types P ⟹ is_lub2,P,E ⊢ o' :: T; is_refT T; T ≠ NT; is_lub1,P,E ⊢ e :: T'; ran E ⊆ types P ⟹ is_lub2,P,E ⊢ e :: T'; ran E ⊆ types P⟧ ⟹ is_lub2,P,E ⊢ sync(o') e :: T'› 17. ‹⋀E e₁ T₁ e₂ T₂. ⟦is_lub1,P,E ⊢ e₁ :: T₁; ran E ⊆ types P ⟹ is_lub2,P,E ⊢ e₁ :: T₁; is_lub1,P,E ⊢ e₂ :: T₂; ran E ⊆ types P ⟹ is_lub2,P,E ⊢ e₂ :: T₂; ran E ⊆ types P⟧ ⟹ is_lub2,P,E ⊢ e₁;; e₂ :: T₂› 18. ‹⋀E e c T. ⟦is_lub1,P,E ⊢ e :: Boolean; ran E ⊆ types P ⟹ is_lub2,P,E ⊢ e :: Boolean; is_lub1,P,E ⊢ c :: T; ran E ⊆ types P ⟹ is_lub2,P,E ⊢ c :: T; ran E ⊆ types P⟧ ⟹ is_lub2,P,E ⊢ while (e) c :: Void› 19. ‹⋀E e C. ⟦is_lub1,P,E ⊢ e :: Class C; ran E ⊆ types P ⟹ is_lub2,P,E ⊢ e :: Class C; P ⊢ C ≼⇧* Throwable; ran E ⊆ types P⟧ ⟹ is_lub2,P,E ⊢ throw e :: Void› 20. ‹⋀E e₁ T V C e₂. ⟦is_lub1,P,E ⊢ e₁ :: T; ran E ⊆ types P ⟹ is_lub2,P,E ⊢ e₁ :: T; is_lub1,P,E(V ↦ Class C) ⊢ e₂ :: T; ran (E(V ↦ Class C)) ⊆ types P ⟹ is_lub2,P,E(V ↦ Class C) ⊢ e₂ :: T; P ⊢ C ≼⇧* Throwable; ran E ⊆ types P⟧ ⟹ is_lub2,P,E ⊢ try e₁ catch(C V) e₂ :: T› 21. ‹⋀E. ran E ⊆ types P ⟹ is_lub2,P,E ⊢ [] [::] []› 22. ‹⋀E e T es Ts. ⟦is_lub1,P,E ⊢ e :: T; ran E ⊆ types P ⟹ is_lub2,P,E ⊢ e :: T; is_lub1,P,E ⊢ es [::] Ts; ran E ⊆ types P ⟹ is_lub2,P,E ⊢ es [::] Ts; ran E ⊆ types P⟧ ⟹ is_lub2,P,E ⊢ e # es [::] T # Ts›*) case (WTTry E e1 T V C e2) (*‹is_lub1,P,E ⊢ e1 :: T› ‹ran (E::String.literal ⇒ ty option) ⊆ types (P::'a J_prog) ⟹ is_lub2,P,E ⊢ (e1::'a expr) :: T::ty› ‹is_lub1,P,E(V ↦ Class C) ⊢ e2 :: T› ‹ran (E(V ↦ Class C)) ⊆ types P ⟹ is_lub2,P,E(V ↦ Class C) ⊢ e2 :: T› ‹P ⊢ C ≼⇧* Throwable› ‹ran E ⊆ types P›*) from ‹ran E ⊆ types P› (*‹ran E ⊆ types P›*) have "is_lub2,P,E ⊢ e1 :: T" by (rule WTTry (*‹is_lub1,P,E ⊢ e1 :: T› ‹ran E ⊆ types P ⟹ is_lub2,P,E ⊢ e1 :: T› ‹is_lub1,P,E(V ↦ Class C) ⊢ e2 :: T› ‹ran (E(V ↦ Class C)) ⊆ types P ⟹ is_lub2,P,E(V ↦ Class C) ⊢ e2 :: T› ‹P ⊢ C ≼⇧* Throwable› ‹ran E ⊆ types P›*)) moreover from ‹P ⊢ C ≼⇧* Throwable› (*‹P ⊢ C ≼⇧* Throwable›*) have "is_class P C" by (rule is_class_sub_Throwable[OF wf] (*‹P ⊢ ?C ≼⇧* Throwable ⟹ is_class P ?C›*)) with ‹ran E ⊆ types P› (*‹ran E ⊆ types P›*) have "ran (E(V ↦ Class C)) ⊆ types P" by (auto simp add: ran_def (*‹ran ?m = {b. ∃a. ?m a = ⌊b⌋}›*)) hence "is_lub2,P,E(V ↦ Class C) ⊢ e2 :: T" by (rule WTTry (*‹is_lub1,P,E ⊢ e1 :: T› ‹ran E ⊆ types P ⟹ is_lub2,P,E ⊢ e1 :: T› ‹is_lub1,P,E(V ↦ Class C) ⊢ e2 :: T› ‹ran (E(V ↦ Class C)) ⊆ types P ⟹ is_lub2,P,E(V ↦ Class C) ⊢ e2 :: T› ‹P ⊢ C ≼⇧* Throwable› ‹ran E ⊆ types P›*)) ultimately show "?case" (*goal: ‹is_lub2,P,E ⊢ try e1 catch(C V) e2 :: T›*) using ‹P ⊢ C ≼⇧* Throwable› (*‹P ⊢ C ≼⇧* Throwable›*) by standard qed (auto) (*solves the remaining goals: 1. ‹⋀C E. ⟦is_class P C; ran E ⊆ types P⟧ ⟹ is_lub2,P,E ⊢ new C :: Class C› 2. ‹⋀E e T. ⟦is_lub1,P,E ⊢ e :: Integer; ran E ⊆ types P ⟹ is_lub2,P,E ⊢ e :: Integer; is_type P (T⌊⌉); ran E ⊆ types P⟧ ⟹ is_lub2,P,E ⊢ newA T⌊e⌉ :: T⌊⌉› 3. ‹⋀E e T U. ⟦is_lub1,P,E ⊢ e :: T; ran E ⊆ types P ⟹ is_lub2,P,E ⊢ e :: T; P ⊢ U ≤ T ∨ P ⊢ T ≤ U; is_type P U; ran E ⊆ types P⟧ ⟹ is_lub2,P,E ⊢ Cast U e :: U› 4. ‹⋀E e T U. ⟦is_lub1,P,E ⊢ e :: T; ran E ⊆ types P ⟹ is_lub2,P,E ⊢ e :: T; P ⊢ U ≤ T ∨ P ⊢ T ≤ U; is_type P U; is_refT U; ran E ⊆ types P⟧ ⟹ is_lub2,P,E ⊢ e instanceof U :: Boolean› 5. ‹⋀v T E. ⟦typeof v = ⌊T⌋; ran E ⊆ types P⟧ ⟹ is_lub2,P,E ⊢ Val v :: T› 6. ‹⋀E V T. ⟦E V = ⌊T⌋; ran E ⊆ types P⟧ ⟹ is_lub2,P,E ⊢ Var V :: T› 7. ‹⋀E e1 T1 e2 T2 bop T. ⟦is_lub1,P,E ⊢ e1 :: T1; ran E ⊆ types P ⟹ is_lub2,P,E ⊢ e1 :: T1; is_lub1,P,E ⊢ e2 :: T2; ran E ⊆ types P ⟹ is_lub2,P,E ⊢ e2 :: T2; P ⊢ T1«bop»T2 :: T; ran E ⊆ types P⟧ ⟹ is_lub2,P,E ⊢ e1 «bop» e2 :: T› 8. ‹⋀E V T e T'. ⟦E V = ⌊T⌋; is_lub1,P,E ⊢ e :: T'; ran E ⊆ types P ⟹ is_lub2,P,E ⊢ e :: T'; P ⊢ T' ≤ T; V ≠ this; ran E ⊆ types P⟧ ⟹ is_lub2,P,E ⊢ V:=e :: Void› 9. ‹⋀E a T i. ⟦is_lub1,P,E ⊢ a :: T⌊⌉; ran E ⊆ types P ⟹ is_lub2,P,E ⊢ a :: T⌊⌉; is_lub1,P,E ⊢ i :: Integer; ran E ⊆ types P ⟹ is_lub2,P,E ⊢ i :: Integer; ran E ⊆ types P⟧ ⟹ is_lub2,P,E ⊢ a⌊i⌉ :: T› 10. ‹⋀E a T i e T'. ⟦is_lub1,P,E ⊢ a :: T⌊⌉; ran E ⊆ types P ⟹ is_lub2,P,E ⊢ a :: T⌊⌉; is_lub1,P,E ⊢ i :: Integer; ran E ⊆ types P ⟹ is_lub2,P,E ⊢ i :: Integer; is_lub1,P,E ⊢ e :: T'; ran E ⊆ types P ⟹ is_lub2,P,E ⊢ e :: T'; P ⊢ T' ≤ T; ran E ⊆ types P⟧ ⟹ is_lub2,P,E ⊢ a⌊i⌉ := e :: Void› 11. ‹⋀E a T. ⟦is_lub1,P,E ⊢ a :: T⌊⌉; ran E ⊆ types P ⟹ is_lub2,P,E ⊢ a :: T⌊⌉; ran E ⊆ types P⟧ ⟹ is_lub2,P,E ⊢ a∙length :: Integer› 12. ‹⋀E e U C F T fm D. ⟦is_lub1,P,E ⊢ e :: U; ran E ⊆ types P ⟹ is_lub2,P,E ⊢ e :: U; class_type_of' U = ⌊C⌋; P ⊢ C sees F:T (fm) in D; ran E ⊆ types P⟧ ⟹ is_lub2,P,E ⊢ e∙F{D} :: T› 13. ‹⋀E e₁ U C F T fm D e₂ T'. ⟦is_lub1,P,E ⊢ e₁ :: U; ran E ⊆ types P ⟹ is_lub2,P,E ⊢ e₁ :: U; class_type_of' U = ⌊C⌋; P ⊢ C sees F:T (fm) in D; is_lub1,P,E ⊢ e₂ :: T'; ran E ⊆ types P ⟹ is_lub2,P,E ⊢ e₂ :: T'; P ⊢ T' ≤ T; ran E ⊆ types P⟧ ⟹ is_lub2,P,E ⊢ e₁∙F{D} := e₂ :: Void› 14. ‹⋀E e1 U C F T fm D e2 T' e3 T''. ⟦is_lub1,P,E ⊢ e1 :: U; ran E ⊆ types P ⟹ is_lub2,P,E ⊢ e1 :: U; class_type_of' U = ⌊C⌋; P ⊢ C sees F:T (fm) in D; volatile fm; is_lub1,P,E ⊢ e2 :: T'; ran E ⊆ types P ⟹ is_lub2,P,E ⊢ e2 :: T'; P ⊢ T' ≤ T; is_lub1,P,E ⊢ e3 :: T''; ran E ⊆ types P ⟹ is_lub2,P,E ⊢ e3 :: T''; P ⊢ T'' ≤ T; ran E ⊆ types P⟧ ⟹ is_lub2,P,E ⊢ e1∙compareAndSwap(D∙F, e2, e3) :: Boolean› 15. ‹⋀E e U C M Ts T meth D es Ts'. ⟦is_lub1,P,E ⊢ e :: U; ran E ⊆ types P ⟹ is_lub2,P,E ⊢ e :: U; class_type_of' U = ⌊C⌋; P ⊢ C sees M: Ts→T = meth in D; is_lub1,P,E ⊢ es [::] Ts'; ran E ⊆ types P ⟹ is_lub2,P,E ⊢ es [::] Ts'; P ⊢ Ts' [≤] Ts; ran E ⊆ types P⟧ ⟹ is_lub2,P,E ⊢ e∙M(es) :: T› 16. ‹⋀E o' T e T'. ⟦is_lub1,P,E ⊢ o' :: T; ran E ⊆ types P ⟹ is_lub2,P,E ⊢ o' :: T; is_refT T; T ≠ NT; is_lub1,P,E ⊢ e :: T'; ran E ⊆ types P ⟹ is_lub2,P,E ⊢ e :: T'; ran E ⊆ types P⟧ ⟹ is_lub2,P,E ⊢ sync(o') e :: T'› 17. ‹⋀E e₁ T₁ e₂ T₂. ⟦is_lub1,P,E ⊢ e₁ :: T₁; ran E ⊆ types P ⟹ is_lub2,P,E ⊢ e₁ :: T₁; is_lub1,P,E ⊢ e₂ :: T₂; ran E ⊆ types P ⟹ is_lub2,P,E ⊢ e₂ :: T₂; ran E ⊆ types P⟧ ⟹ is_lub2,P,E ⊢ e₁;; e₂ :: T₂› 18. ‹⋀E e c T. ⟦is_lub1,P,E ⊢ e :: Boolean; ran E ⊆ types P ⟹ is_lub2,P,E ⊢ e :: Boolean; is_lub1,P,E ⊢ c :: T; ran E ⊆ types P ⟹ is_lub2,P,E ⊢ c :: T; ran E ⊆ types P⟧ ⟹ is_lub2,P,E ⊢ while (e) c :: Void› 19. ‹⋀E e C. ⟦is_lub1,P,E ⊢ e :: Class C; ran E ⊆ types P ⟹ is_lub2,P,E ⊢ e :: Class C; P ⊢ C ≼⇧* Throwable; ran E ⊆ types P⟧ ⟹ is_lub2,P,E ⊢ throw e :: Void› 20. ‹⋀E. ran E ⊆ types P ⟹ is_lub2,P,E ⊢ [] [::] []› 21. ‹⋀E e T es Ts. ⟦is_lub1,P,E ⊢ e :: T; ran E ⊆ types P ⟹ is_lub2,P,E ⊢ e :: T; is_lub1,P,E ⊢ es [::] Ts; ran E ⊆ types P ⟹ is_lub2,P,E ⊢ es [::] Ts; ran E ⊆ types P⟧ ⟹ is_lub2,P,E ⊢ e # es [::] T # Ts›*) subsection ‹Code generator setup› lemma WTBlock_code: "⋀is_lub. ⟦ is_type P T; is_lub,P,E(V ↦ T) ⊢ e :: T'; case vo of None ⇒ True | ⌊v⌋ ⇒ case typeof v of None ⇒ False | Some T' ⇒ P ⊢ T' ≤ T ⟧ ⟹ is_lub,P,E ⊢ {V:T=vo; e} :: T'" by auto lemmas [code_pred_intro] = WTNew WTNewArray WTCast WTInstanceOf WTVal WTVar WTBinOp WTLAss WTAAcc WTAAss WTALength WTFAcc WTFAss WTCAS WTCall declare WTBlock_code [code_pred_intro WTBlock'] lemmas [code_pred_intro] = WTSynchronized WTSeq WTCond WTWhile WTThrow WTTry WTNil WTCons code_pred (modes: (i ⇒ i ⇒ o ⇒ bool) ⇒ i ⇒ i ⇒ i ⇒ o ⇒ bool, (i ⇒ i ⇒ o ⇒ bool) ⇒ i ⇒ i ⇒ i ⇒ i ⇒ bool) [detect_switches, skip_proof] WT proof - case WT from WT.prems show thesis proof cases case (WTBlock T V e vo) thus thesis using WT.WTBlock'[OF refl refl refl, of V T vo e] by(auto) qed(assumption|erule WT.that[OF refl refl refl]|rule refl)+ next case WTs from WTs.prems WTs.that show thesis by cases blast+ qed inductive is_lub_sup :: "'m prog ⇒ ty ⇒ ty ⇒ ty ⇒ bool" for P T1 T2 T3 where "sup P T1 T2 = OK T3 ⟹ is_lub_sup P T1 T2 T3" code_pred (modes: i ⇒ i ⇒ i ⇒ o ⇒ bool, i ⇒ i ⇒ i ⇒ i ⇒ bool) is_lub_sup . definition WT_code :: "'addr J_prog ⇒ env ⇒ 'addr expr ⇒ ty ⇒ bool" ("_,_ ⊢ _ ::'' _" [51,51,51] 50) where "WT_code P ≡ WT (is_lub_sup P) P" definition WTs_code :: "'addr J_prog ⇒ env ⇒ 'addr expr list ⇒ ty list ⇒ bool" ("_,_ ⊢ _ [::''] _" [51,51,51] 50) where "WTs_code P ≡ WTs (is_lub_sup P) P" lemma assumes wf: "wf_prog wf_md P" shows WT_code_into_WT: "⟦ P,E ⊢ e ::' T; ran E ⊆ types P ⟧ ⟹ P,E ⊢ e :: T" and WTs_code_into_WTs: "⟦ P,E ⊢ es [::'] Ts; ran E ⊆ types P ⟧ ⟹ P,E ⊢ es [::] Ts" proof (-) (*goals: 1. ‹⟦(P::'a J_prog),(E::String.literal ⇒ ty option) ⊢ (e::'a expr) ::' T::ty; ran E ⊆ types P⟧ ⟹ P,E ⊢ e :: T› 2. ‹⟦(P::'a J_prog),(E::String.literal ⇒ ty option) ⊢ (es::'a expr list) [::'] Ts::ty list; ran E ⊆ types P⟧ ⟹ P,E ⊢ es [::] Ts›*) assume ran: "ran E ⊆ types P" (*‹ran (E::String.literal ⇒ ty option) ⊆ types (P::'a J_prog)›*) { assume wt: "P,E ⊢ e ::' T" (*‹(P::'a J_prog),(E::String.literal ⇒ ty option) ⊢ (e::'a expr) ::' T::ty›*) show "P,E ⊢ e :: T" apply (rule WT_change_is_lub[OF wf _ _ wt[unfolded WT_code_def] ran] (*‹⟦⋀T1 T2 T3. ⟦is_lub_sup P T1 T2 T3; is_type P T1; is_type P T2⟧ ⟹ ?is_lub2.0 T1 T2 T3; ⋀T1 T2 T3. ⟦?is_lub2.0 T1 T2 T3; is_type P T1; is_type P T2⟧ ⟹ is_type P T3⟧ ⟹ ?is_lub2.0,P,E ⊢ e :: T›*)) (*goals: 1. ‹⋀T1 T2 T3. ⟦is_lub_sup P T1 T2 T3; is_type P T1; is_type P T2⟧ ⟹ P ⊢ lub(T1, T2) = T3› 2. ‹⋀T1 T2 T3. ⟦P ⊢ lub(T1, T2) = T3; is_type P T1; is_type P T2⟧ ⟹ is_type P T3› discuss goal 1*) apply (blast elim!: is_lub_sup.cases (*‹⟦is_lub_sup ?P ?T1.0 ?T2.0 ?T3.0; SemiType.sup ?P ?T1.0 ?T2.0 = OK ?T3.0 ⟹ ?Pa⟧ ⟹ ?Pa›*) intro: sup_is_lubI[OF wf] (*‹⟦is_type P ?T; is_type P ?U; SemiType.sup P ?T ?U = OK ?V⟧ ⟹ P ⊢ lub(?T, ?U) = ?V›*) is_lub_is_type[OF wf] (*‹⟦is_type P ?T; is_type P ?U; P ⊢ lub(?T, ?U) = ?V⟧ ⟹ is_type P ?V›*)) (*discuss goal 2*) apply (blast elim!: is_lub_sup.cases (*‹⟦is_lub_sup ?P ?T1.0 ?T2.0 ?T3.0; SemiType.sup ?P ?T1.0 ?T2.0 = OK ?T3.0 ⟹ ?Pa⟧ ⟹ ?Pa›*) intro: sup_is_lubI[OF wf] (*‹⟦is_type P ?T; is_type P ?U; SemiType.sup P ?T ?U = OK ?V⟧ ⟹ P ⊢ lub(?T, ?U) = ?V›*) is_lub_is_type[OF wf] (*‹⟦is_type P ?T; is_type P ?U; P ⊢ lub(?T, ?U) = ?V⟧ ⟹ is_type P ?V›*)) (*proven 2 subgoals*) . } { assume wts: "P,E ⊢ es [::'] Ts" (*‹(P::'a J_prog),(E::String.literal ⇒ ty option) ⊢ (es::'a expr list) [::'] Ts::ty list›*) show "P,E ⊢ es [::] Ts" apply (rule WTs_change_is_lub[OF wf _ _ wts[unfolded WTs_code_def] ran] (*‹⟦⋀T1 T2 T3. ⟦is_lub_sup P T1 T2 T3; is_type P T1; is_type P T2⟧ ⟹ ?is_lub2.0 T1 T2 T3; ⋀T1 T2 T3. ⟦?is_lub2.0 T1 T2 T3; is_type P T1; is_type P T2⟧ ⟹ is_type P T3⟧ ⟹ ?is_lub2.0,P,E ⊢ es [::] Ts›*)) (*goals: 1. ‹⋀T1 T2 T3. ⟦is_lub_sup P T1 T2 T3; is_type P T1; is_type P T2⟧ ⟹ P ⊢ lub(T1, T2) = T3› 2. ‹⋀T1 T2 T3. ⟦P ⊢ lub(T1, T2) = T3; is_type P T1; is_type P T2⟧ ⟹ is_type P T3› discuss goal 1*) apply (blast elim!: is_lub_sup.cases (*‹⟦is_lub_sup ?P ?T1.0 ?T2.0 ?T3.0; SemiType.sup ?P ?T1.0 ?T2.0 = OK ?T3.0 ⟹ ?Pa⟧ ⟹ ?Pa›*) intro: sup_is_lubI[OF wf] (*‹⟦is_type P ?T; is_type P ?U; SemiType.sup P ?T ?U = OK ?V⟧ ⟹ P ⊢ lub(?T, ?U) = ?V›*) is_lub_is_type[OF wf] (*‹⟦is_type P ?T; is_type P ?U; P ⊢ lub(?T, ?U) = ?V⟧ ⟹ is_type P ?V›*)) (*discuss goal 2*) apply (blast elim!: is_lub_sup.cases (*‹⟦is_lub_sup ?P ?T1.0 ?T2.0 ?T3.0; SemiType.sup ?P ?T1.0 ?T2.0 = OK ?T3.0 ⟹ ?Pa⟧ ⟹ ?Pa›*) intro: sup_is_lubI[OF wf] (*‹⟦is_type P ?T; is_type P ?U; SemiType.sup P ?T ?U = OK ?V⟧ ⟹ P ⊢ lub(?T, ?U) = ?V›*) is_lub_is_type[OF wf] (*‹⟦is_type P ?T; is_type P ?U; P ⊢ lub(?T, ?U) = ?V⟧ ⟹ is_type P ?V›*)) (*proven 2 subgoals*) . } qed lemma assumes wf: "wf_prog wf_md P" shows WT_into_WT_code: "⟦ P,E ⊢ e :: T; ran E ⊆ types P ⟧ ⟹ P,E ⊢ e ::' T" and WT_into_WTs_code_OK: "⟦ P,E ⊢ es [::] Ts; ran E ⊆ types P ⟧ ⟹ P,E ⊢ es [::'] Ts" proof (-) (*goals: 1. ‹⟦P,E ⊢ e :: T; ran E ⊆ types P⟧ ⟹ P,E ⊢ e ::' T› 2. ‹⟦P,E ⊢ es [::] Ts; ran E ⊆ types P⟧ ⟹ P,E ⊢ es [::'] Ts›*) assume ran: "ran E ⊆ types P" (*‹ran (E::String.literal ⇒ ty option) ⊆ types (P::'a J_prog)›*) { assume wt: "P,E ⊢ e :: T" (*‹(P::'a J_prog),(E::String.literal ⇒ ty option) ⊢ (e::'a expr) :: T::ty›*) show "P,E ⊢ e ::' T" unfolding WT_code_def (*goal: ‹is_lub_sup P,P,E ⊢ e :: T›*) apply (rule WT_change_is_lub[OF wf _ _ wt ran] (*‹⟦⋀(T1::ty) (T2::ty) T3::ty. ⟦(P::'a::type J_prog) ⊢ lub(T1, T2) = T3; is_type P T1; is_type P T2⟧ ⟹ (?is_lub2.0::ty ⇒ ty ⇒ ty ⇒ bool) T1 T2 T3; ⋀(T1::ty) (T2::ty) T3::ty. ⟦?is_lub2.0 T1 T2 T3; is_type P T1; is_type P T2⟧ ⟹ is_type P T3⟧ ⟹ ?is_lub2.0,P,(E::String.literal ⇒ ty option) ⊢ (e::'a::type expr) :: T::ty›*)) (*goals: 1. ‹⋀T1 T2 T3. ⟦P ⊢ lub(T1, T2) = T3; is_type P T1; is_type P T2⟧ ⟹ is_lub_sup P T1 T2 T3› 2. ‹⋀T1 T2 T3. ⟦is_lub_sup P T1 T2 T3; is_type P T1; is_type P T2⟧ ⟹ is_type P T3› discuss goal 1*) apply (blast intro!: is_lub_sup.intros (*‹SemiType.sup (?P::?'m::type prog) (?T1.0::ty) (?T2.0::ty) = OK (?T3.0::ty) ⟹ is_lub_sup ?P ?T1.0 ?T2.0 ?T3.0›*) intro: is_lub_subD[OF wf] (*‹⟦is_type (P::'a::type J_prog) (?T::ty); is_type P (?U::ty); P ⊢ lub(?T, ?U) = (?V::ty)⟧ ⟹ SemiType.sup P ?T ?U = OK ?V›*) sup_is_type[OF wf] (*‹⟦is_type (P::'a::type J_prog) (?A::ty); is_type P (?B::ty); SemiType.sup P ?A ?B = OK (?T::ty)⟧ ⟹ is_type P ?T›*) elim!: is_lub_sup.cases (*‹⟦is_lub_sup (?P::?'m::type prog) (?T1.0::ty) (?T2.0::ty) (?T3.0::ty); SemiType.sup ?P ?T1.0 ?T2.0 = OK ?T3.0 ⟹ ?Pa::bool⟧ ⟹ ?Pa›*)) (*discuss goal 2*) apply (blast intro!: is_lub_sup.intros (*‹SemiType.sup ?P ?T1.0 ?T2.0 = OK ?T3.0 ⟹ is_lub_sup ?P ?T1.0 ?T2.0 ?T3.0›*) intro: is_lub_subD[OF wf] (*‹⟦is_type P ?T; is_type P ?U; P ⊢ lub(?T, ?U) = ?V⟧ ⟹ SemiType.sup P ?T ?U = OK ?V›*) sup_is_type[OF wf] (*‹⟦is_type P ?A; is_type P ?B; SemiType.sup P ?A ?B = OK ?T⟧ ⟹ is_type P ?T›*) elim!: is_lub_sup.cases (*‹⟦is_lub_sup ?P ?T1.0 ?T2.0 ?T3.0; SemiType.sup ?P ?T1.0 ?T2.0 = OK ?T3.0 ⟹ ?Pa⟧ ⟹ ?Pa›*)) (*proven 2 subgoals*) . } { assume wts: "P,E ⊢ es [::] Ts" (*‹(P::'a J_prog),(E::String.literal ⇒ ty option) ⊢ (es::'a expr list) [::] Ts::ty list›*) show "P,E ⊢ es [::'] Ts" unfolding WTs_code_def (*goal: ‹is_lub_sup P,P,E ⊢ es [::] Ts›*) apply (rule WTs_change_is_lub[OF wf _ _ wts ran] (*‹⟦⋀T1 T2 T3. ⟦P ⊢ lub(T1, T2) = T3; is_type P T1; is_type P T2⟧ ⟹ ?is_lub2.0 T1 T2 T3; ⋀T1 T2 T3. ⟦?is_lub2.0 T1 T2 T3; is_type P T1; is_type P T2⟧ ⟹ is_type P T3⟧ ⟹ ?is_lub2.0,P,E ⊢ es [::] Ts›*)) (*goals: 1. ‹⋀(T1::ty) (T2::ty) T3::ty. ⟦(P::'a::type J_prog) ⊢ lub(T1, T2) = T3; is_type P T1; is_type P T2⟧ ⟹ is_lub_sup P T1 T2 T3› 2. ‹⋀(T1::ty) (T2::ty) T3::ty. ⟦is_lub_sup (P::'a::type J_prog) T1 T2 T3; is_type P T1; is_type P T2⟧ ⟹ is_type P T3› discuss goal 1*) apply (blast intro!: is_lub_sup.intros (*‹SemiType.sup ?P ?T1.0 ?T2.0 = OK ?T3.0 ⟹ is_lub_sup ?P ?T1.0 ?T2.0 ?T3.0›*) intro: is_lub_subD[OF wf] (*‹⟦is_type P ?T; is_type P ?U; P ⊢ lub(?T, ?U) = ?V⟧ ⟹ SemiType.sup P ?T ?U = OK ?V›*) sup_is_type[OF wf] (*‹⟦is_type P ?A; is_type P ?B; SemiType.sup P ?A ?B = OK ?T⟧ ⟹ is_type P ?T›*) elim!: is_lub_sup.cases (*‹⟦is_lub_sup ?P ?T1.0 ?T2.0 ?T3.0; SemiType.sup ?P ?T1.0 ?T2.0 = OK ?T3.0 ⟹ ?Pa⟧ ⟹ ?Pa›*)) (*discuss goal 2*) apply (blast intro!: is_lub_sup.intros (*‹SemiType.sup ?P ?T1.0 ?T2.0 = OK ?T3.0 ⟹ is_lub_sup ?P ?T1.0 ?T2.0 ?T3.0›*) intro: is_lub_subD[OF wf] (*‹⟦is_type P ?T; is_type P ?U; P ⊢ lub(?T, ?U) = ?V⟧ ⟹ SemiType.sup P ?T ?U = OK ?V›*) sup_is_type[OF wf] (*‹⟦is_type P ?A; is_type P ?B; SemiType.sup P ?A ?B = OK ?T⟧ ⟹ is_type P ?T›*) elim!: is_lub_sup.cases (*‹⟦is_lub_sup ?P ?T1.0 ?T2.0 ?T3.0; SemiType.sup ?P ?T1.0 ?T2.0 = OK ?T3.0 ⟹ ?Pa⟧ ⟹ ?Pa›*)) (*proven 2 subgoals*) . } qed theorem WT_eq_WT_code: assumes "wf_prog wf_md P" and "ran E ⊆ types P" shows "P,E ⊢ e :: T ⟷ P,E ⊢ e ::' T" using assms (*‹wf_prog wf_md P› ‹ran E ⊆ types P›*) by (blast intro: WT_code_into_WT (*‹⟦wf_prog ?wf_md ?P; ?P,?E ⊢ ?e ::' ?T; ran ?E ⊆ types ?P⟧ ⟹ ?P,?E ⊢ ?e :: ?T›*) WT_into_WT_code (*‹⟦wf_prog ?wf_md ?P; ?P,?E ⊢ ?e :: ?T; ran ?E ⊆ types ?P⟧ ⟹ ?P,?E ⊢ ?e ::' ?T›*)) code_pred (modes: i ⇒ i ⇒ i ⇒ i ⇒ bool, i ⇒ i ⇒ i ⇒ o ⇒ bool) [inductify] WT_code . code_pred (modes: i ⇒ i ⇒ i ⇒ i ⇒ bool, i ⇒ i ⇒ i ⇒ o ⇒ bool) [inductify] WTs_code . end
{ "path": "afp-2025-02-12/thys/JinjaThreads/J/WellType.thy", "repo": "afp-2025-02-12", "sha": "9feab26bdfce2bd533e11a7e93efe5064a7a36fc520f46ea2d34155d960f4e9d" }
(* Title: HOL/Computational_Algebra/Factorial_Ring.thy Author: Manuel Eberl, TU Muenchen Author: Florian Haftmann, TU Muenchen *) section ‹Factorial (semi)rings› theory Factorial_Ring imports Main "HOL-Library.Multiset" begin unbundle multiset.lifting subsection ‹Irreducible and prime elements› context comm_semiring_1 begin definition irreducible :: "'a ⇒ bool" where "irreducible p ⟷ p ≠ 0 ∧ ¬p dvd 1 ∧ (∀a b. p = a * b ⟶ a dvd 1 ∨ b dvd 1)" lemma not_irreducible_zero [simp]: "¬irreducible 0" by (simp add: irreducible_def (*‹irreducible ?p = (?p ≠ 0 ∧ ¬ ?p dvd 1 ∧ (∀a b. ?p = a * b ⟶ a dvd 1 ∨ b dvd 1))›*)) lemma irreducible_not_unit: "irreducible p ⟹ ¬p dvd 1" by (simp add: irreducible_def (*‹irreducible ?p = (?p ≠ 0 ∧ ¬ ?p dvd 1 ∧ (∀a b. ?p = a * b ⟶ a dvd 1 ∨ b dvd 1))›*)) lemma not_irreducible_one [simp]: "¬irreducible 1" by (simp add: irreducible_def (*‹irreducible ?p = (?p ≠ 0 ∧ ¬ ?p dvd 1 ∧ (∀a b. ?p = a * b ⟶ a dvd 1 ∨ b dvd 1))›*)) lemma irreducibleI: "p ≠ 0 ⟹ ¬p dvd 1 ⟹ (⋀a b. p = a * b ⟹ a dvd 1 ∨ b dvd 1) ⟹ irreducible p" by (simp add: irreducible_def (*‹irreducible ?p = (?p ≠ 0 ∧ ¬ ?p dvd 1 ∧ (∀a b. ?p = a * b ⟶ a dvd 1 ∨ b dvd 1))›*)) lemma irreducibleD: "irreducible p ⟹ p = a * b ⟹ a dvd 1 ∨ b dvd 1" by (simp add: irreducible_def (*‹irreducible (?p::'a) = (?p ≠ (0::'a) ∧ ¬ ?p dvd (1::'a) ∧ (∀(a::'a) b::'a. ?p = a * b ⟶ a dvd (1::'a) ∨ b dvd (1::'a)))›*)) lemma irreducible_mono: assumes irr: "irreducible b" and "a dvd b" "¬a dvd 1" shows "irreducible a" proof (rule irreducibleI (*‹⟦?p ≠ 0; ¬ ?p dvd 1; ⋀a b. ?p = a * b ⟹ a dvd 1 ∨ b dvd 1⟧ ⟹ irreducible ?p›*)) (*goals: 1. ‹a ≠ 0› 2. ‹¬ a dvd 1› 3. ‹⋀aa b. a = aa * b ⟹ aa dvd 1 ∨ b dvd 1›*) fix c and d assume "a = c * d" (*‹(a::'a) = (c::'a) * (d::'a)›*) from assms (*‹irreducible b› ‹a dvd b› ‹¬ (a::'a) dvd (1::'a)›*) obtain k where [simp]: "b = a * k" (*goal: ‹(⋀k. b = a * k ⟹ thesis) ⟹ thesis›*) by auto from ‹a = c * d› (*‹a = c * d›*) have "b = c * d * k" by simp hence "c dvd 1 ∨ (d * k) dvd 1" using irreducibleD[OF irr, of c "d * k"] (*‹(b::'a) = (c::'a) * ((d::'a) * (k::'a)) ⟹ c dvd (1::'a) ∨ d * k dvd (1::'a)›*) by (auto simp: mult.assoc (*‹(?a::'a) * (?b::'a) * (?c::'a) = ?a * (?b * ?c)›*)) thus "c dvd 1 ∨ d dvd 1" by auto qed (use assms in ‹auto simp: irreducible_def›) (*solves the remaining goals: 1. ‹(a::'a) ≠ (0::'a)› 2. ‹¬ (a::'a) dvd (1::'a)›*) lemma irreducible_multD: assumes l: "irreducible (a*b)" shows "a dvd 1 ∧ irreducible b ∨ b dvd 1 ∧ irreducible a" proof (-) (*goal: ‹a dvd 1 ∧ irreducible b ∨ b dvd 1 ∧ irreducible a›*) have "*": "irreducible b" if l: "irreducible (a*b)" and a: "a dvd 1" for a :: 'a and b :: 'a proof (rule irreducibleI (*‹⟦?p ≠ 0; ¬ ?p dvd 1; ⋀a b. ?p = a * b ⟹ a dvd 1 ∨ b dvd 1⟧ ⟹ irreducible ?p›*)) (*goals: 1. ‹b ≠ 0› 2. ‹¬ b dvd 1› 3. ‹⋀a b. b = a * b ⟹ a dvd 1 ∨ b dvd 1›*) show "¬(b dvd 1)" proof (standard) (*goal: ‹b dvd 1 ⟹ False›*) assume "b dvd 1" (*‹(b::'a) dvd (1::'a)›*) hence "a * b dvd 1 * 1" using ‹a dvd 1› (*‹a dvd 1›*) apply (intro mult_dvd_mono (*‹⟦?a dvd ?b; ?c dvd ?d⟧ ⟹ ?a * ?c dvd ?b * ?d›*)) (*goals: 1. ‹⟦b dvd 1; a dvd 1⟧ ⟹ a dvd 1› 2. ‹⟦b dvd 1; a dvd 1⟧ ⟹ b dvd 1› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . with l (*‹irreducible ((a::'a) * (b::'a))›*) show False by (auto simp: irreducible_def (*‹irreducible ?p = (?p ≠ 0 ∧ ¬ ?p dvd 1 ∧ (∀a b. ?p = a * b ⟶ a dvd 1 ∨ b dvd 1))›*)) qed next (*goals: 1. ‹(b::'a) ≠ (0::'a)› 2. ‹⋀(a::'a) b::'a. (b::'a) = a * b ⟹ a dvd (1::'a) ∨ b dvd (1::'a)›*) fix x and y assume "b = x * y" (*‹(b::'a) = (x::'a) * (y::'a)›*) have "a * x dvd 1 ∨ y dvd 1" using l (*‹irreducible ((a::'a) * (b::'a))›*) apply (rule irreducibleD (*‹⟦irreducible ?p; ?p = ?a * ?b⟧ ⟹ ?a dvd 1 ∨ ?b dvd 1›*)) (*goal: ‹(a::'a) * (x::'a) dvd (1::'a) ∨ (y::'a) dvd (1::'a)›*) by (use ‹b = x * y› in ‹auto simp: mult_ac›) thus "x dvd 1 ∨ y dvd 1" by auto qed (use l a in auto) (*solved the remaining goal: ‹b ≠ 0›*) from irreducibleD[OF assms refl] (*‹a dvd 1 ∨ b dvd 1›*) have "a dvd 1 ∨ b dvd 1" by (auto simp: irreducible_def (*‹irreducible ?p = (?p ≠ 0 ∧ ¬ ?p dvd 1 ∧ (∀a b. ?p = a * b ⟶ a dvd 1 ∨ b dvd 1))›*)) with "*"[of a b] (*‹⟦irreducible (a * b); a dvd 1⟧ ⟹ irreducible b›*) "*"[of b a] (*‹⟦irreducible (b * a); b dvd 1⟧ ⟹ irreducible a›*) l (*‹irreducible (a * b)›*) show "?thesis" (*goal: ‹a dvd 1 ∧ irreducible b ∨ b dvd 1 ∧ irreducible a›*) by (auto simp: mult.commute (*‹?a * ?b = ?b * ?a›*)) qed lemma irreducible_power_iff [simp]: "irreducible (p ^ n) ⟷ irreducible p ∧ n = 1" proof (standard) (*goals: 1. ‹irreducible (p ^ n) ⟹ irreducible p ∧ n = 1› 2. ‹irreducible p ∧ n = 1 ⟹ irreducible (p ^ n)›*) assume "*": "irreducible (p ^ n)" (*‹irreducible ((p::'a) ^ (n::nat))›*) have "irreducible p" using "*" (*‹irreducible ((p::'a) ^ (n::nat))›*) apply (induction n) (*goals: 1. ‹irreducible (p ^ 0) ⟹ irreducible p› 2. ‹⋀n. ⟦irreducible (p ^ n) ⟹ irreducible p; irreducible (p ^ Suc n)⟧ ⟹ irreducible p› discuss goal 1*) apply ((auto dest!: irreducible_multD (*‹irreducible (?a * ?b) ⟹ ?a dvd 1 ∧ irreducible ?b ∨ ?b dvd 1 ∧ irreducible ?a›*))[1]) (*discuss goal 2*) apply ((auto dest!: irreducible_multD (*‹irreducible (?a * ?b) ⟹ ?a dvd 1 ∧ irreducible ?b ∨ ?b dvd 1 ∧ irreducible ?a›*))[1]) (*proven 2 subgoals*) . hence [simp]: "¬p dvd 1" using "*" (*‹irreducible (p ^ n)›*) by (auto simp: irreducible_def (*‹irreducible (?p::'a::type) = (?p ≠ (0::'a::type) ∧ ¬ ?p dvd (1::'a::type) ∧ (∀(a::'a::type) b::'a::type. ?p = a * b ⟶ a dvd (1::'a::type) ∨ b dvd (1::'a::type)))›*)) consider "n = 0" | "n = 1" | "n > 1" (*goal: ‹⟦n = 0 ⟹ thesis; n = 1 ⟹ thesis; 1 < n ⟹ thesis⟧ ⟹ thesis›*) by linarith thus "irreducible p ∧ n = 1" proof (cases) (*goals: 1. ‹(n::nat) = (0::nat) ⟹ irreducible (p::'a) ∧ n = (1::nat)› 2. ‹(n::nat) = (1::nat) ⟹ irreducible (p::'a) ∧ n = (1::nat)› 3. ‹(1::nat) < (n::nat) ⟹ irreducible (p::'a) ∧ n = (1::nat)›*) assume "n > 1" (*‹(1::nat) < (n::nat)›*) hence "p ^ n = p * p ^ (n - 1)" apply (cases n) (*goals: 1. ‹⟦1 < n; n = 0⟧ ⟹ p ^ n = p * p ^ (n - 1)› 2. ‹⋀nat. ⟦1 < n; n = Suc nat⟧ ⟹ p ^ n = p * p ^ (n - 1)› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . with "*" (*‹irreducible (p ^ n)›*) ‹¬ p dvd 1› (*‹¬ p dvd 1›*) have "p ^ (n - 1) dvd 1" using irreducible_multD[of p "p ^ (n - 1)"] (*‹irreducible (p * p ^ (n - 1)) ⟹ p dvd 1 ∧ irreducible (p ^ (n - 1)) ∨ p ^ (n - 1) dvd 1 ∧ irreducible p›*) by auto with ‹¬p dvd 1› (*‹¬ p dvd 1›*) ‹n > 1› (*‹1 < n›*) have False by (meson dvd_power (*‹0 < ?n ∨ ?x = 1 ⟹ ?x dvd ?x ^ ?n›*) dvd_trans (*‹⟦?a dvd ?b; ?b dvd ?c⟧ ⟹ ?a dvd ?c›*) zero_less_diff (*‹(0 < ?n - ?m) = (?m < ?n)›*)) thus "?thesis" (*goal: ‹irreducible p ∧ n = 1›*) by standard qed (use * in auto) (*solves the remaining goals: 1. ‹n = 0 ⟹ irreducible p ∧ n = 1› 2. ‹n = 1 ⟹ irreducible p ∧ n = 1›*) qed (auto) (*solved the remaining goal: ‹irreducible (p::'a) ∧ (n::nat) = (1::nat) ⟹ irreducible (p ^ n)›*) definition prime_elem :: "'a ⇒ bool" where "prime_elem p ⟷ p ≠ 0 ∧ ¬p dvd 1 ∧ (∀a b. p dvd (a * b) ⟶ p dvd a ∨ p dvd b)" lemma not_prime_elem_zero [simp]: "¬prime_elem 0" by (simp add: prime_elem_def (*‹prime_elem ?p = (?p ≠ 0 ∧ ¬ ?p dvd 1 ∧ (∀a b. ?p dvd a * b ⟶ ?p dvd a ∨ ?p dvd b))›*)) lemma prime_elem_not_unit: "prime_elem p ⟹ ¬p dvd 1" by (simp add: prime_elem_def (*‹prime_elem ?p = (?p ≠ 0 ∧ ¬ ?p dvd 1 ∧ (∀a b. ?p dvd a * b ⟶ ?p dvd a ∨ ?p dvd b))›*)) lemma prime_elemI: "p ≠ 0 ⟹ ¬p dvd 1 ⟹ (⋀a b. p dvd (a * b) ⟹ p dvd a ∨ p dvd b) ⟹ prime_elem p" by (simp add: prime_elem_def (*‹prime_elem ?p = (?p ≠ 0 ∧ ¬ ?p dvd 1 ∧ (∀a b. ?p dvd a * b ⟶ ?p dvd a ∨ ?p dvd b))›*)) lemma prime_elem_dvd_multD: "prime_elem p ⟹ p dvd (a * b) ⟹ p dvd a ∨ p dvd b" by (simp add: prime_elem_def (*‹prime_elem ?p = (?p ≠ 0 ∧ ¬ ?p dvd 1 ∧ (∀a b. ?p dvd a * b ⟶ ?p dvd a ∨ ?p dvd b))›*)) lemma prime_elem_dvd_mult_iff: "prime_elem p ⟹ p dvd (a * b) ⟷ p dvd a ∨ p dvd b" by (auto simp: prime_elem_def (*‹prime_elem ?p = (?p ≠ 0 ∧ ¬ ?p dvd 1 ∧ (∀a b. ?p dvd a * b ⟶ ?p dvd a ∨ ?p dvd b))›*)) lemma not_prime_elem_one [simp]: "¬ prime_elem 1" by (auto dest: prime_elem_not_unit (*‹prime_elem ?p ⟹ ¬ ?p dvd 1›*)) lemma prime_elem_not_zeroI: assumes "prime_elem p" shows "p ≠ 0" using assms (*‹prime_elem p›*) by (auto intro: ccontr (*‹(¬ ?P ⟹ False) ⟹ ?P›*)) lemma prime_elem_dvd_power: "prime_elem p ⟹ p dvd x ^ n ⟹ p dvd x" apply (induction n) (*goals: 1. ‹⟦prime_elem p; p dvd x ^ 0⟧ ⟹ p dvd x› 2. ‹⋀n. ⟦⟦prime_elem p; p dvd x ^ n⟧ ⟹ p dvd x; prime_elem p; p dvd x ^ Suc n⟧ ⟹ p dvd x› discuss goal 1*) apply ((auto dest: prime_elem_dvd_multD (*‹⟦prime_elem ?p; ?p dvd ?a * ?b⟧ ⟹ ?p dvd ?a ∨ ?p dvd ?b›*) intro: dvd_trans[of _ 1] (*‹⟦?a dvd 1; 1 dvd ?c⟧ ⟹ ?a dvd ?c›*))[1]) (*discuss goal 2*) apply ((auto dest: prime_elem_dvd_multD (*‹⟦prime_elem ?p; ?p dvd ?a * ?b⟧ ⟹ ?p dvd ?a ∨ ?p dvd ?b›*) intro: dvd_trans[of _ 1] (*‹⟦?a dvd 1; 1 dvd ?c⟧ ⟹ ?a dvd ?c›*))[1]) (*proven 2 subgoals*) . lemma prime_elem_dvd_power_iff: "prime_elem p ⟹ n > 0 ⟹ p dvd x ^ n ⟷ p dvd x" by (auto dest: prime_elem_dvd_power (*‹⟦prime_elem ?p; ?p dvd ?x ^ ?n⟧ ⟹ ?p dvd ?x›*) intro: dvd_trans (*‹⟦?a dvd ?b; ?b dvd ?c⟧ ⟹ ?a dvd ?c›*)) lemma prime_elem_imp_nonzero [simp]: "ASSUMPTION (prime_elem x) ⟹ x ≠ 0" unfolding ASSUMPTION_def (*goal: ‹prime_elem x ⟹ x ≠ 0›*) by (rule prime_elem_not_zeroI (*‹prime_elem ?p ⟹ ?p ≠ 0›*)) lemma prime_elem_imp_not_one [simp]: "ASSUMPTION (prime_elem x) ⟹ x ≠ 1" unfolding ASSUMPTION_def (*goal: ‹prime_elem x ⟹ x ≠ 1›*) by auto end lemma (in normalization_semidom) irreducible_cong: assumes "normalize a = normalize b" shows "irreducible a ⟷ irreducible b" proof (cases "a = 0 ∨ a dvd 1") (*goals: 1. ‹a = 0 ∨ is_unit a ⟹ irreducible a = irreducible b› 2. ‹¬ (a = 0 ∨ is_unit a) ⟹ irreducible a = irreducible b›*) case True (*‹a = 0 ∨ is_unit a›*) hence "¬irreducible a" by (auto simp: irreducible_def (*‹irreducible ?p = (?p ≠ 0 ∧ ¬ is_unit ?p ∧ (∀a b. ?p = a * b ⟶ is_unit a ∨ is_unit b))›*)) from True (*‹a = 0 ∨ is_unit a›*) have "normalize a = 0 ∨ normalize a dvd 1" by auto also (*calculation: ‹normalize a = 0 ∨ is_unit (normalize a)›*) note assms (*‹normalize a = normalize b›*) finally (*calculation: ‹normalize (b::'a::type) = (0::'a::type) ∨ is_unit (normalize b)›*) have "b = 0 ∨ b dvd 1" by simp hence "¬irreducible b" by (auto simp: irreducible_def (*‹irreducible (?p::'a) = (?p ≠ (0::'a) ∧ ¬ is_unit ?p ∧ (∀(a::'a) b::'a. ?p = a * b ⟶ is_unit a ∨ is_unit b))›*)) with ‹¬irreducible a› (*‹¬ irreducible (a::'a)›*) show "?thesis" (*goal: ‹irreducible (a::'a) = irreducible (b::'a)›*) by simp next (*goal: ‹¬ (a = 0 ∨ is_unit a) ⟹ irreducible a = irreducible b›*) case False (*‹¬ ((a::'a) = (0::'a) ∨ is_unit a)›*) hence b: "b ≠ 0" "¬is_unit b" using assms (*‹normalize a = normalize b›*) apply - (*goals: 1. ‹⟦¬ (a = 0 ∨ is_unit a); normalize a = normalize b⟧ ⟹ b ≠ 0› 2. ‹⟦¬ (a = 0 ∨ is_unit a); normalize a = normalize b⟧ ⟹ ¬ is_unit b› discuss goal 1*) apply ((auto simp: is_unit_normalize[of b] (*‹is_unit (b::'a) ⟹ normalize b = (1::'a)›*))[1]) (*discuss goal 2*) apply ((auto simp: is_unit_normalize[of b] (*‹is_unit b ⟹ normalize b = 1›*))[1]) (*proven 2 subgoals*) . show "?thesis" (*goal: ‹irreducible a = irreducible b›*) proof (standard) (*goals: 1. ‹irreducible a ⟹ irreducible b› 2. ‹irreducible b ⟹ irreducible a›*) assume "irreducible a" (*‹irreducible (a::'a)›*) thus "irreducible b" apply (rule irreducible_mono (*‹⟦irreducible ?b; ?a dvd ?b; ¬ is_unit ?a⟧ ⟹ irreducible ?a›*)) (*goals: 1. ‹b dvd a› 2. ‹¬ is_unit b› discuss goal 1*) apply ((use assms False b in ‹auto dest: associatedD2›)[1]) (*discuss goal 2*) apply ((use assms False b in ‹auto dest: associatedD2›)[1]) (*proven 2 subgoals*) . next (*goal: ‹irreducible b ⟹ irreducible a›*) assume "irreducible b" (*‹irreducible (b::'a)›*) thus "irreducible a" apply (rule irreducible_mono (*‹⟦irreducible ?b; ?a dvd ?b; ¬ is_unit ?a⟧ ⟹ irreducible ?a›*)) (*goals: 1. ‹a dvd b› 2. ‹¬ is_unit a› discuss goal 1*) apply ((use assms False b in ‹auto dest: associatedD1›)[1]) (*discuss goal 2*) apply ((use assms False b in ‹auto dest: associatedD1›)[1]) (*proven 2 subgoals*) . qed qed lemma (in normalization_semidom) associatedE1: assumes "normalize a = normalize b" obtains u where "is_unit u" "a = u * b" proof (cases "a = 0") (*goals: 1. ‹⟦⋀u. ⟦is_unit u; a = u * b⟧ ⟹ thesis; a = 0⟧ ⟹ thesis› 2. ‹⟦⋀u. ⟦is_unit u; a = u * b⟧ ⟹ thesis; a ≠ 0⟧ ⟹ thesis›*) case [simp]: False (*‹a ≠ 0›*) from assms (*‹normalize a = normalize b›*) have [simp]: "b ≠ 0" by auto show "?thesis" (*goal: ‹thesis::bool›*) proof (rule that (*‹⟦is_unit ?u1; a = ?u1 * b⟧ ⟹ thesis›*)) (*goals: 1. ‹is_unit ?u1› 2. ‹a = ?u1 * b›*) show "is_unit (unit_factor a div unit_factor b)" by auto have "unit_factor a div unit_factor b * b = unit_factor a * (b div unit_factor b)" using ‹b ≠ 0› (*‹b ≠ 0›*) unit_div_commute (*‹is_unit ?b ⟹ ?a div ?b * ?c = ?a * ?c div ?b›*) unit_div_mult_swap (*‹is_unit ?c ⟹ ?a * (?b div ?c) = ?a * ?b div ?c›*) unit_factor_is_unit (*‹(?a::'a::type) ≠ (0::'a::type) ⟹ is_unit (unit_factor ?a)›*) by metis also (*calculation: ‹unit_factor a div unit_factor b * b = unit_factor a * (b div unit_factor b)›*) have "b div unit_factor b = normalize b" by simp finally (*calculation: ‹unit_factor a div unit_factor b * b = unit_factor a * normalize b›*) show "a = unit_factor a div unit_factor b * b" by (metis assms (*‹normalize a = normalize b›*) unit_factor_mult_normalize (*‹unit_factor ?a * normalize ?a = ?a›*)) qed next (*goal: ‹⟦⋀u. ⟦is_unit u; a = u * b⟧ ⟹ thesis; a = 0⟧ ⟹ thesis›*) case [simp]: True (*‹a = 0›*) hence [simp]: "b = 0" using assms[symmetric] (*‹normalize b = normalize a›*) by auto show "?thesis" (*goal: ‹thesis›*) apply (intro that[of 1] (*‹⟦is_unit 1; a = 1 * b⟧ ⟹ thesis›*)) (*goals: 1. ‹is_unit 1› 2. ‹a = 1 * b› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . qed lemma (in normalization_semidom) associatedE2: assumes "normalize a = normalize b" obtains u where "is_unit u" "b = u * a" proof (-) (*goal: ‹(⋀u. ⟦is_unit u; b = u * a⟧ ⟹ thesis) ⟹ thesis›*) from assms (*‹normalize (a::'a) = normalize (b::'a)›*) have "normalize b = normalize a" by simp then obtain u where "is_unit u" "b = u * a" (*goal: ‹(⋀u. ⟦is_unit u; b = u * a⟧ ⟹ thesis) ⟹ thesis›*) by (elim associatedE1 (*‹⟦normalize (?a::'a) = normalize (?b::'a); ⋀u::'a. ⟦is_unit u; ?a = u * ?b⟧ ⟹ ?thesis::bool⟧ ⟹ ?thesis›*)) thus "?thesis" (*goal: ‹thesis::bool›*) using that (*‹⟦is_unit ?u1; b = ?u1 * a⟧ ⟹ thesis›*) by blast qed (* TODO Move *) lemma (in normalization_semidom) normalize_power_normalize: "normalize (normalize x ^ n) = normalize (x ^ n)" proof (induction n) (*goals: 1. ‹normalize (normalize (x::'a) ^ (0::nat)) = normalize (x ^ (0::nat))› 2. ‹⋀n::nat. normalize (normalize (x::'a) ^ n) = normalize (x ^ n) ⟹ normalize (normalize x ^ Suc n) = normalize (x ^ Suc n)›*) case (Suc n) (*‹normalize (normalize x ^ n) = normalize (x ^ n)›*) have "normalize (normalize x ^ Suc n) = normalize (x * normalize (normalize x ^ n))" by simp also (*calculation: ‹normalize (normalize (x::'a) ^ Suc (n::nat)) = normalize (x * normalize (normalize x ^ n))›*) note Suc.IH (*‹normalize (normalize x ^ n) = normalize (x ^ n)›*) finally (*calculation: ‹normalize (normalize x ^ Suc n) = normalize (x * normalize (x ^ n))›*) show "?case" (*goal: ‹normalize (normalize x ^ Suc n) = normalize (x ^ Suc n)›*) by simp qed (auto) (*solved the remaining goal: ‹normalize (normalize x ^ 0) = normalize (x ^ 0)›*) context algebraic_semidom begin lemma prime_elem_imp_irreducible: assumes "prime_elem p" shows "irreducible p" proof (rule irreducibleI (*‹⟦?p ≠ 0; ¬ is_unit ?p; ⋀a b. ?p = a * b ⟹ is_unit a ∨ is_unit b⟧ ⟹ irreducible ?p›*)) (*goals: 1. ‹p ≠ 0› 2. ‹¬ is_unit p› 3. ‹⋀a b. p = a * b ⟹ is_unit a ∨ is_unit b›*) fix a and b assume p_eq: "p = a * b" (*‹(p::'a) = (a::'a) * (b::'a)›*) with assms (*‹prime_elem p›*) have nz: "a ≠ 0" "b ≠ 0" apply - (*goals: 1. ‹⟦prime_elem (p::'a::type); p = (a::'a::type) * (b::'a::type)⟧ ⟹ a ≠ (0::'a::type)› 2. ‹⟦prime_elem (p::'a::type); p = (a::'a::type) * (b::'a::type)⟧ ⟹ b ≠ (0::'a::type)› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . from p_eq (*‹p = a * b›*) have "p dvd a * b" by simp with ‹prime_elem p› (*‹prime_elem p›*) have "p dvd a ∨ p dvd b" by (rule prime_elem_dvd_multD (*‹⟦prime_elem ?p; ?p dvd ?a * ?b⟧ ⟹ ?p dvd ?a ∨ ?p dvd ?b›*)) with ‹p = a * b› (*‹p = a * b›*) have "a * b dvd 1 * b ∨ a * b dvd a * 1" by auto thus "a dvd 1 ∨ b dvd 1" by (simp only: dvd_times_left_cancel_iff[OF nz(1)] (*‹(a * ?b dvd a * ?c) = (?b dvd ?c)›*) dvd_times_right_cancel_iff[OF nz(2)] (*‹(?b * b dvd ?c * b) = (?b dvd ?c)›*)) qed (insert assms (*‹prime_elem p›*), simp_all add: prime_elem_def) (*solves the remaining goals: 1. ‹p ≠ 0› 2. ‹¬ is_unit p›*) lemma (in algebraic_semidom) unit_imp_no_irreducible_divisors: assumes "is_unit x" "irreducible p" shows "¬p dvd x" proof (rule notI (*‹(?P ⟹ False) ⟹ ¬ ?P›*)) (*goal: ‹p dvd x ⟹ False›*) assume "p dvd x" (*‹(p::'a) dvd (x::'a)›*) with ‹is_unit x› (*‹is_unit x›*) have "is_unit p" by (auto intro: dvd_trans (*‹⟦?a dvd ?b; ?b dvd ?c⟧ ⟹ ?a dvd ?c›*)) with ‹irreducible p› (*‹irreducible p›*) show False by (simp add: irreducible_not_unit (*‹irreducible (?p::'a) ⟹ ¬ is_unit ?p›*)) qed lemma unit_imp_no_prime_divisors: assumes "is_unit x" "prime_elem p" shows "¬p dvd x" using unit_imp_no_irreducible_divisors[OF assms ( 1 ) prime_elem_imp_irreducible [ OF assms ( 2 ) ]] (*‹¬ p dvd x›*) . lemma prime_elem_mono: assumes "prime_elem p" "¬q dvd 1" "q dvd p" shows "prime_elem q" proof (-) (*goal: ‹prime_elem q›*) from ‹q dvd p› (*‹q dvd p›*) obtain r where r: "p = q * r" (*goal: ‹(⋀r. p = q * r ⟹ thesis) ⟹ thesis›*) by (elim dvdE (*‹⟦?b dvd ?a; ⋀k. ?a = ?b * k ⟹ ?P⟧ ⟹ ?P›*)) hence "p dvd q * r" by simp with ‹prime_elem p› (*‹prime_elem (p::'a)›*) have "p dvd q ∨ p dvd r" by (rule prime_elem_dvd_multD (*‹⟦prime_elem ?p; ?p dvd ?a * ?b⟧ ⟹ ?p dvd ?a ∨ ?p dvd ?b›*)) hence "p dvd q" proof (standard) (*goals: 1. ‹p dvd q ⟹ p dvd q› 2. ‹p dvd r ⟹ p dvd q›*) assume "p dvd r" (*‹(p::'a) dvd (r::'a)›*) then obtain s where s: "r = p * s" (*goal: ‹(⋀s. r = p * s ⟹ thesis) ⟹ thesis›*) by (elim dvdE (*‹⟦?b dvd ?a; ⋀k. ?a = ?b * k ⟹ ?P⟧ ⟹ ?P›*)) from r (*‹p = q * r›*) have "p * 1 = p * (q * s)" apply (subst (asm) s (*‹r = p * s›*)) (*goal: ‹p * 1 = p * (q * s)›*) by (simp add: mult_ac (*‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)›*)) with ‹prime_elem p› (*‹prime_elem p›*) have "q dvd 1" apply (subst (asm) mult_cancel_left (*‹((?c::'a::type) * (?a::'a::type) = ?c * (?b::'a::type)) = (?c = (0::'a::type) ∨ ?a = ?b)›*)) (*goal: ‹is_unit q›*) by auto with ‹¬q dvd 1› (*‹¬ is_unit q›*) show "?thesis" (*goal: ‹p dvd q›*) by contradiction qed show "?thesis" (*goal: ‹prime_elem q›*) proof (rule prime_elemI (*‹⟦?p ≠ 0; ¬ is_unit ?p; ⋀a b. ?p dvd a * b ⟹ ?p dvd a ∨ ?p dvd b⟧ ⟹ prime_elem ?p›*)) (*goals: 1. ‹(q::'a::type) ≠ (0::'a::type)› 2. ‹¬ is_unit (q::'a::type)› 3. ‹⋀(a::'a::type) b::'a::type. (q::'a::type) dvd a * b ⟹ q dvd a ∨ q dvd b›*) fix a and b assume "q dvd (a * b)" (*‹(q::'a) dvd (a::'a) * (b::'a)›*) with ‹p dvd q› (*‹(p::'a) dvd (q::'a)›*) have "p dvd (a * b)" by (rule dvd_trans (*‹⟦?a dvd ?b; ?b dvd ?c⟧ ⟹ ?a dvd ?c›*)) with ‹prime_elem p› (*‹prime_elem p›*) have "p dvd a ∨ p dvd b" by (rule prime_elem_dvd_multD (*‹⟦prime_elem ?p; ?p dvd ?a * ?b⟧ ⟹ ?p dvd ?a ∨ ?p dvd ?b›*)) with ‹q dvd p› (*‹q dvd p›*) show "q dvd a ∨ q dvd b" by (blast intro: dvd_trans (*‹⟦?a dvd ?b; ?b dvd ?c⟧ ⟹ ?a dvd ?c›*)) qed (insert assms (*‹prime_elem p› ‹¬ is_unit q› ‹q dvd p›*), auto) (*solves the remaining goals: 1. ‹q ≠ 0› 2. ‹¬ is_unit q›*) qed lemma irreducibleD': assumes "irreducible a" "b dvd a" shows "a dvd b ∨ is_unit b" proof (-) (*goal: ‹a dvd b ∨ is_unit b›*) from assms (*‹irreducible a› ‹b dvd a›*) obtain c where c: "a = b * c" (*goal: ‹(⋀c. a = b * c ⟹ thesis) ⟹ thesis›*) by (elim dvdE (*‹⟦?b dvd ?a; ⋀k. ?a = ?b * k ⟹ ?P⟧ ⟹ ?P›*)) from irreducibleD[OF assms ( 1 ) this] (*‹is_unit (b::'a) ∨ is_unit (c::'a)›*) have "is_unit b ∨ is_unit c" . thus "?thesis" (*goal: ‹(a::'a) dvd (b::'a) ∨ is_unit b›*) by (auto simp: c (*‹a = b * c›*) mult_unit_dvd_iff (*‹is_unit ?b ⟹ (?a * ?b dvd ?c) = (?a dvd ?c)›*)) qed lemma irreducibleI': assumes "a ≠ 0" "¬is_unit a" "⋀b. b dvd a ⟹ a dvd b ∨ is_unit b" shows "irreducible a" proof (rule irreducibleI (*‹⟦?p ≠ 0; ¬ is_unit ?p; ⋀a b. ?p = a * b ⟹ is_unit a ∨ is_unit b⟧ ⟹ irreducible ?p›*)) (*goals: 1. ‹a ≠ 0› 2. ‹¬ is_unit a› 3. ‹⋀aa b. a = aa * b ⟹ is_unit aa ∨ is_unit b›*) fix b and c assume a_eq: "a = b * c" (*‹(a::'a) = (b::'a) * (c::'a)›*) hence "a dvd b ∨ is_unit b" apply (intro assms (*‹a ≠ 0› ‹¬ is_unit a› ‹?b1 dvd a ⟹ a dvd ?b1 ∨ is_unit ?b1›*)) (*goal: ‹(a::'a) dvd (b::'a) ∨ is_unit b›*) by simp thus "is_unit b ∨ is_unit c" proof (standard) (*goals: 1. ‹(a::'a) dvd (b::'a) ⟹ is_unit b ∨ is_unit (c::'a)› 2. ‹is_unit (b::'a) ⟹ is_unit b ∨ is_unit (c::'a)›*) assume "a dvd b" (*‹(a::'a) dvd (b::'a)›*) hence "b * c dvd b * 1" by (simp add: a_eq (*‹a = b * c›*)) moreover from ‹a ≠ 0› (*‹a ≠ 0›*) a_eq (*‹a = b * c›*) have "b ≠ 0" by auto ultimately show "?thesis" (*goal: ‹is_unit (b::'a) ∨ is_unit (c::'a)›*) apply (subst (asm) dvd_times_left_cancel_iff (*‹?a ≠ 0 ⟹ (?a * ?b dvd ?a * ?c) = (?b dvd ?c)›*)) (*goals: 1. ‹(b::'a::type) ≠ (0::'a::type) ⟹ b ≠ (0::'a::type)› 2. ‹⟦is_unit (c::'a::type); (b::'a::type) ≠ (0::'a::type)⟧ ⟹ is_unit b ∨ is_unit c› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . qed (blast) (*solved the remaining goal: ‹is_unit b ⟹ is_unit b ∨ is_unit c›*) qed (simp_all add: assms(1,2)) (*solves the remaining goals: 1. ‹a ≠ 0› 2. ‹¬ is_unit a›*) lemma irreducible_altdef: "irreducible x ⟷ x ≠ 0 ∧ ¬is_unit x ∧ (∀b. b dvd x ⟶ x dvd b ∨ is_unit b)" using irreducibleI'[of x] (*‹⟦x ≠ 0; ¬ is_unit x; ⋀b. b dvd x ⟹ x dvd b ∨ is_unit b⟧ ⟹ irreducible x›*) irreducibleD'[of x] (*‹⟦irreducible x; ?b dvd x⟧ ⟹ x dvd ?b ∨ is_unit ?b›*) irreducible_not_unit[of x] (*‹irreducible x ⟹ ¬ is_unit x›*) by auto lemma prime_elem_multD: assumes "prime_elem (a * b)" shows "is_unit a ∨ is_unit b" proof (-) (*goal: ‹is_unit a ∨ is_unit b›*) from assms (*‹prime_elem ((a::'a::type) * (b::'a::type))›*) have "a ≠ 0" "b ≠ 0" apply - (*goals: 1. ‹prime_elem (a * b) ⟹ a ≠ 0› 2. ‹prime_elem (a * b) ⟹ b ≠ 0› discuss goal 1*) apply ((auto dest!: prime_elem_not_zeroI (*‹prime_elem ?p ⟹ ?p ≠ 0›*))[1]) (*discuss goal 2*) apply ((auto dest!: prime_elem_not_zeroI (*‹prime_elem ?p ⟹ ?p ≠ 0›*))[1]) (*proven 2 subgoals*) . moreover from assms (*‹prime_elem ((a::'a) * (b::'a))›*) prime_elem_dvd_multD[of "a * b"] (*‹⟦prime_elem (a * b); a * b dvd ?a * ?b⟧ ⟹ a * b dvd ?a ∨ a * b dvd ?b›*) have "a * b dvd a ∨ a * b dvd b" by auto ultimately show "?thesis" (*goal: ‹is_unit (a::'a) ∨ is_unit (b::'a)›*) using dvd_times_left_cancel_iff[of a b 1] (*‹a ≠ 0 ⟹ (a * b dvd a * 1) = is_unit b›*) dvd_times_right_cancel_iff[of b a 1] (*‹b ≠ 0 ⟹ (a * b dvd 1 * b) = is_unit a›*) by auto qed lemma prime_elemD2: assumes "prime_elem p" and "a dvd p" and "¬ is_unit a" shows "p dvd a" proof (-) (*goal: ‹p dvd a›*) from ‹a dvd p› (*‹a dvd p›*) obtain b where "p = a * b" (*goal: ‹(⋀b. p = a * b ⟹ thesis) ⟹ thesis›*) by standard with ‹prime_elem p› (*‹prime_elem p›*) prime_elem_multD (*‹prime_elem (?a * ?b) ⟹ is_unit ?a ∨ is_unit ?b›*) ‹¬ is_unit a› (*‹¬ is_unit a›*) have "is_unit b" by auto with ‹p = a * b› (*‹p = a * b›*) show "?thesis" (*goal: ‹(p::'a::type) dvd (a::'a::type)›*) by (auto simp add: mult_unit_dvd_iff (*‹is_unit (?b::'a) ⟹ ((?a::'a) * ?b dvd (?c::'a)) = (?a dvd ?c)›*)) qed lemma prime_elem_dvd_prod_msetE: assumes "prime_elem p" assumes dvd: "p dvd prod_mset A" obtains a where "a ∈# A" and "p dvd a" proof - from dvd have "∃a. a ∈# A ∧ p dvd a" proof (induct A) case empty then show ?case using ‹prime_elem p› by (simp add: prime_elem_not_unit) next case (add a A) then have "p dvd a * prod_mset A" by simp with ‹prime_elem p› consider (A) "p dvd prod_mset A" | (B) "p dvd a" by (blast dest: prime_elem_dvd_multD) then show ?case proof cases case B then show ?thesis by auto next case A with add.hyps obtain b where "b ∈# A" "p dvd b" by auto then show ?thesis by auto qed qed with that show thesis by blast qed context begin lemma prime_elem_powerD: assumes "prime_elem (p ^ n)" shows "prime_elem p ∧ n = 1" proof (cases n) (*goals: 1. ‹(n::nat) = (0::nat) ⟹ prime_elem (p::'a::type) ∧ n = (1::nat)› 2. ‹⋀nat::nat. (n::nat) = Suc nat ⟹ prime_elem (p::'a::type) ∧ n = (1::nat)›*) case (Suc m) (*‹n = Suc m›*) note assms (*‹prime_elem (p ^ n)›*) also (*calculation: ‹prime_elem (p ^ n)›*) from Suc (*‹n = Suc m›*) have "p ^ n = p * p^m" by simp finally (*calculation: ‹prime_elem (p * p ^ m)›*) have "is_unit p ∨ is_unit (p^m)" by (rule prime_elem_multD (*‹prime_elem (?a * ?b) ⟹ is_unit ?a ∨ is_unit ?b›*)) moreover from assms (*‹prime_elem (p ^ n)›*) have "¬is_unit p" by (simp add: prime_elem_def (*‹prime_elem ?p = (?p ≠ 0 ∧ ¬ is_unit ?p ∧ (∀a b. ?p dvd a * b ⟶ ?p dvd a ∨ ?p dvd b))›*) is_unit_power_iff (*‹is_unit (?a ^ ?n) = (is_unit ?a ∨ ?n = 0)›*)) ultimately have "is_unit (p ^ m)" by simp with ‹¬is_unit p› (*‹¬ is_unit p›*) have "m = 0" by (simp add: is_unit_power_iff (*‹is_unit ((?a::'a) ^ (?n::nat)) = (is_unit ?a ∨ ?n = (0::nat))›*)) with Suc (*‹n = Suc m›*) assms (*‹prime_elem (p ^ n)›*) show "?thesis" (*goal: ‹prime_elem p ∧ n = 1›*) by simp qed (insert assms (*‹prime_elem (p ^ n)›*), simp_all) (*solved the remaining goal: ‹n = 0 ⟹ prime_elem p ∧ n = 1›*) lemma prime_elem_power_iff: "prime_elem (p ^ n) ⟷ prime_elem p ∧ n = 1" by (auto dest: prime_elem_powerD (*‹prime_elem (?p ^ ?n) ⟹ prime_elem ?p ∧ ?n = 1›*)) end lemma irreducible_mult_unit_left: "is_unit a ⟹ irreducible (a * p) ⟷ irreducible p" by (auto simp: irreducible_altdef (*‹irreducible ?x = (?x ≠ 0 ∧ ¬ is_unit ?x ∧ (∀b. b dvd ?x ⟶ ?x dvd b ∨ is_unit b))›*) mult.commute[of a] (*‹a * ?b = ?b * a›*) is_unit_mult_iff (*‹is_unit (?a * ?b) = (is_unit ?a ∧ is_unit ?b)›*) mult_unit_dvd_iff (*‹is_unit ?b ⟹ (?a * ?b dvd ?c) = (?a dvd ?c)›*) dvd_mult_unit_iff (*‹is_unit ?b ⟹ (?a dvd ?c * ?b) = (?a dvd ?c)›*)) lemma prime_elem_mult_unit_left: "is_unit a ⟹ prime_elem (a * p) ⟷ prime_elem p" by (auto simp: prime_elem_def (*‹prime_elem ?p = (?p ≠ 0 ∧ ¬ is_unit ?p ∧ (∀a b. ?p dvd a * b ⟶ ?p dvd a ∨ ?p dvd b))›*) mult.commute[of a] (*‹a * ?b = ?b * a›*) is_unit_mult_iff (*‹is_unit (?a * ?b) = (is_unit ?a ∧ is_unit ?b)›*) mult_unit_dvd_iff (*‹is_unit ?b ⟹ (?a * ?b dvd ?c) = (?a dvd ?c)›*)) lemma prime_elem_dvd_cases: assumes pk: "p*k dvd m*n" and p: "prime_elem p" shows "(∃x. k dvd x*n ∧ m = p*x) ∨ (∃y. k dvd m*y ∧ n = p*y)" proof (-) (*goal: ‹(∃x. k dvd x * n ∧ m = p * x) ∨ (∃y. k dvd m * y ∧ n = p * y)›*) have "p dvd m*n" using dvd_mult_left (*‹(?a::'a::type) * (?b::'a::type) dvd (?c::'a::type) ⟹ ?a dvd ?c›*) pk (*‹p * k dvd m * n›*) by blast then consider "p dvd m" | "p dvd n" (*goal: ‹⟦p dvd m ⟹ thesis; p dvd n ⟹ thesis⟧ ⟹ thesis›*) using p (*‹prime_elem p›*) prime_elem_dvd_mult_iff (*‹prime_elem ?p ⟹ (?p dvd ?a * ?b) = (?p dvd ?a ∨ ?p dvd ?b)›*) by blast then show "?thesis" (*goal: ‹(∃x. k dvd x * n ∧ m = p * x) ∨ (∃y. k dvd m * y ∧ n = p * y)›*) proof (cases) (*goals: 1. ‹(p::'a) dvd (m::'a) ⟹ (∃x::'a. (k::'a) dvd x * (n::'a) ∧ m = p * x) ∨ (∃y::'a. k dvd m * y ∧ n = p * y)› 2. ‹(p::'a) dvd (n::'a) ⟹ (∃x::'a. (k::'a) dvd x * n ∧ (m::'a) = p * x) ∨ (∃y::'a. k dvd m * y ∧ n = p * y)›*) case 1 (*‹p dvd m›*) then obtain a where "m = p * a" (*goal: ‹(⋀a. m = p * a ⟹ thesis) ⟹ thesis›*) by (metis dvd_mult_div_cancel (*‹?a dvd ?b ⟹ ?a * (?b div ?a) = ?b›*)) then have "∃x. k dvd x * n ∧ m = p * x" using p (*‹prime_elem p›*) pk (*‹(p::'a) * (k::'a) dvd (m::'a) * (n::'a)›*) by (auto simp: mult.assoc (*‹?a * ?b * ?c = ?a * (?b * ?c)›*)) then show "?thesis" (*goal: ‹(∃x. k dvd x * n ∧ m = p * x) ∨ (∃y. k dvd m * y ∧ n = p * y)›*) apply - (*goal: ‹(∃x. k dvd x * n ∧ m = p * x) ∨ (∃y. k dvd m * y ∧ n = p * y)›*) by standard next (*goal: ‹(p::'a) dvd (n::'a) ⟹ (∃x::'a. (k::'a) dvd x * n ∧ (m::'a) = p * x) ∨ (∃y::'a. k dvd m * y ∧ n = p * y)›*) case 2 (*‹p dvd n›*) then obtain b where "n = p * b" (*goal: ‹(⋀b. n = p * b ⟹ thesis) ⟹ thesis›*) by (metis dvd_mult_div_cancel (*‹?a dvd ?b ⟹ ?a * (?b div ?a) = ?b›*)) with p (*‹prime_elem (p::'a)›*) pk (*‹p * k dvd m * n›*) have "∃y. k dvd m*y ∧ n = p*y" by (metis dvd_mult_right (*‹(?a::'a::type) * (?b::'a::type) dvd (?c::'a::type) ⟹ ?b dvd ?c›*) dvd_times_left_cancel_iff (*‹(?a::'a::type) ≠ (0::'a::type) ⟹ (?a * (?b::'a::type) dvd ?a * (?c::'a::type)) = (?b dvd ?c)›*) mult.left_commute (*‹(?b::'a::type) * ((?a::'a::type) * (?c::'a::type)) = ?a * (?b * ?c)›*) mult_zero_left (*‹(0::'a::type) * (?a::'a::type) = (0::'a::type)›*)) then show "?thesis" (*goal: ‹(∃x. k dvd x * n ∧ m = p * x) ∨ (∃y. k dvd m * y ∧ n = p * y)›*) apply - (*goal: ‹(∃x::'a. (k::'a) dvd x * (n::'a) ∧ (m::'a) = (p::'a) * x) ∨ (∃y::'a. k dvd m * y ∧ n = p * y)›*) apply standard (*goal: ‹∃y. k dvd m * y ∧ n = p * y ⟹ (∃x. k dvd x * n ∧ m = p * x) ∨ (∃y. k dvd m * y ∧ n = p * y)›*) by (msorry) qed qed lemma prime_elem_power_dvd_prod: assumes pc: "p^c dvd m*n" and p: "prime_elem p" shows "∃a b. a+b = c ∧ p^a dvd m ∧ p^b dvd n" using pc (*‹p ^ c dvd m * n›*) proof (induct c arbitrary: m n) (*goals: 1. ‹⋀m n. p ^ 0 dvd m * n ⟹ ∃a b. a + b = 0 ∧ p ^ a dvd m ∧ p ^ b dvd n› 2. ‹⋀c m n. ⟦⋀m n. p ^ c dvd m * n ⟹ ∃a b. a + b = c ∧ p ^ a dvd m ∧ p ^ b dvd n; p ^ Suc c dvd m * n⟧ ⟹ ∃a b. a + b = Suc c ∧ p ^ a dvd m ∧ p ^ b dvd n›*) case 0 (*‹p ^ 0 dvd m * n›*) show "?case" (*goal: ‹∃a b. a + b = 0 ∧ p ^ a dvd m ∧ p ^ b dvd n›*) by simp next (*goal: ‹⋀c m n. ⟦⋀m n. p ^ c dvd m * n ⟹ ∃a b. a + b = c ∧ p ^ a dvd m ∧ p ^ b dvd n; p ^ Suc c dvd m * n⟧ ⟹ ∃a b. a + b = Suc c ∧ p ^ a dvd m ∧ p ^ b dvd n›*) case (Suc c) (*‹p ^ c dvd ?m1 * ?n1 ⟹ ∃a b. a + b = c ∧ p ^ a dvd ?m1 ∧ p ^ b dvd ?n1› ‹p ^ Suc c dvd m * n›*) consider x where "p^c dvd x*n" and "m = p*x" | y where "p^c dvd m*y" and "n = p*y" (*goal: ‹⟦⋀x. ⟦p ^ c dvd x * n; m = p * x⟧ ⟹ thesis; ⋀y. ⟦p ^ c dvd m * y; n = p * y⟧ ⟹ thesis⟧ ⟹ thesis›*) using prime_elem_dvd_cases[of _ "p^c", OF _ p] (*‹p * p ^ c dvd ?m * ?n ⟹ (∃x. p ^ c dvd x * ?n ∧ ?m = p * x) ∨ (∃y. p ^ c dvd ?m * y ∧ ?n = p * y)›*) Suc.prems (*‹p ^ Suc c dvd m * n›*) by force then show "?case" (*goal: ‹∃a b. a + b = Suc c ∧ p ^ a dvd m ∧ p ^ b dvd n›*) proof (cases) (*goals: 1. ‹⋀x. ⟦p ^ c dvd x * n; m = p * x⟧ ⟹ ∃a b. a + b = Suc c ∧ p ^ a dvd m ∧ p ^ b dvd n› 2. ‹⋀y. ⟦p ^ c dvd m * y; n = p * y⟧ ⟹ ∃a b. a + b = Suc c ∧ p ^ a dvd m ∧ p ^ b dvd n›*) case (1 x) (*‹p ^ c dvd x * n› ‹m = p * x›*) with Suc.hyps[of x n] (*‹p ^ c dvd x * n ⟹ ∃a b. a + b = c ∧ p ^ a dvd x ∧ p ^ b dvd n›*) obtain a and b where "a + b = c ∧ p ^ a dvd x ∧ p ^ b dvd n" (*goal: ‹(⋀a b. a + b = c ∧ p ^ a dvd x ∧ p ^ b dvd n ⟹ thesis) ⟹ thesis›*) by blast with "1" (*‹p ^ c dvd x * n› ‹m = p * x›*) have "Suc a + b = Suc c ∧ p ^ Suc a dvd m ∧ p ^ b dvd n" by (auto intro: mult_dvd_mono (*‹⟦(?a::'a) dvd (?b::'a); (?c::'a) dvd (?d::'a)⟧ ⟹ ?a * ?c dvd ?b * ?d›*)) thus "?thesis" (*goal: ‹∃(a::nat) b::nat. a + b = Suc (c::nat) ∧ (p::'a::type) ^ a dvd (m::'a::type) ∧ p ^ b dvd (n::'a::type)›*) by blast next (*goal: ‹⋀y. ⟦p ^ c dvd m * y; n = p * y⟧ ⟹ ∃a b. a + b = Suc c ∧ p ^ a dvd m ∧ p ^ b dvd n›*) case (2 y) (*‹(p::'a) ^ (c::nat) dvd (m::'a) * (y::'a)› ‹(n::'a::type) = (p::'a::type) * (y::'a::type)›*) with Suc.hyps[of m y] (*‹p ^ c dvd m * y ⟹ ∃a b. a + b = c ∧ p ^ a dvd m ∧ p ^ b dvd y›*) obtain a and b where "a + b = c ∧ p ^ a dvd m ∧ p ^ b dvd y" (*goal: ‹(⋀(a::nat) b::nat. a + b = (c::nat) ∧ (p::'a) ^ a dvd (m::'a) ∧ p ^ b dvd (y::'a) ⟹ thesis::bool) ⟹ thesis›*) by blast with "2" (*‹p ^ c dvd m * y› ‹n = p * y›*) have "a + Suc b = Suc c ∧ p ^ a dvd m ∧ p ^ Suc b dvd n" by (auto intro: mult_dvd_mono (*‹⟦(?a::'a) dvd (?b::'a); (?c::'a) dvd (?d::'a)⟧ ⟹ ?a * ?c dvd ?b * ?d›*)) with Suc.hyps[of m y] (*‹p ^ c dvd m * y ⟹ ∃a b. a + b = c ∧ p ^ a dvd m ∧ p ^ b dvd y›*) show "∃a b. a + b = Suc c ∧ p ^ a dvd m ∧ p ^ b dvd n" by blast qed qed lemma prime_elem_power_dvd_cases: assumes "p ^ c dvd m * n" and "a + b = Suc c" and "prime_elem p" shows "p ^ a dvd m ∨ p ^ b dvd n" proof (-) (*goal: ‹p ^ a dvd m ∨ p ^ b dvd n›*) from assms (*‹p ^ c dvd m * n› ‹a + b = Suc c› ‹prime_elem p›*) obtain r and s where "r + s = c ∧ p ^ r dvd m ∧ p ^ s dvd n" (*goal: ‹(⋀r s. r + s = c ∧ p ^ r dvd m ∧ p ^ s dvd n ⟹ thesis) ⟹ thesis›*) by (blast dest: prime_elem_power_dvd_prod (*‹⟦(?p::'a) ^ (?c::nat) dvd (?m::'a) * (?n::'a); prime_elem ?p⟧ ⟹ ∃(a::nat) b::nat. a + b = ?c ∧ ?p ^ a dvd ?m ∧ ?p ^ b dvd ?n›*)) moreover with assms (*‹p ^ c dvd m * n› ‹a + b = Suc c› ‹prime_elem (p::'a)›*) have "a ≤ r ∨ b ≤ s" by arith ultimately show "?thesis" (*goal: ‹p ^ a dvd m ∨ p ^ b dvd n›*) by (auto intro: power_le_dvd (*‹⟦?a ^ ?n dvd ?b; ?m ≤ ?n⟧ ⟹ ?a ^ ?m dvd ?b›*)) qed lemma prime_elem_not_unit' [simp]: "ASSUMPTION (prime_elem x) ⟹ ¬is_unit x" unfolding ASSUMPTION_def (*goal: ‹prime_elem (x::'a) ⟹ ¬ is_unit x›*) by (rule prime_elem_not_unit (*‹prime_elem (?p::'a) ⟹ ¬ is_unit ?p›*)) lemma prime_elem_dvd_power_iff: assumes "prime_elem p" shows "p dvd a ^ n ⟷ p dvd a ∧ n > 0" using assms (*‹prime_elem p›*) apply (induct n) (*goals: 1. ‹prime_elem (p::'a) ⟹ (p dvd (a::'a) ^ (0::nat)) = (p dvd a ∧ (0::nat) < (0::nat))› 2. ‹⋀n::nat. ⟦prime_elem (p::'a) ⟹ (p dvd (a::'a) ^ n) = (p dvd a ∧ (0::nat) < n); prime_elem p⟧ ⟹ (p dvd a ^ Suc n) = (p dvd a ∧ (0::nat) < Suc n)› discuss goal 1*) apply ((auto dest: prime_elem_not_unit (*‹prime_elem (?p::'a::type) ⟹ ¬ is_unit ?p›*) prime_elem_dvd_multD (*‹⟦prime_elem (?p::'a::type); ?p dvd (?a::'a::type) * (?b::'a::type)⟧ ⟹ ?p dvd ?a ∨ ?p dvd ?b›*))[1]) (*discuss goal 2*) apply ((auto dest: prime_elem_not_unit (*‹prime_elem ?p ⟹ ¬ is_unit ?p›*) prime_elem_dvd_multD (*‹⟦prime_elem ?p; ?p dvd ?a * ?b⟧ ⟹ ?p dvd ?a ∨ ?p dvd ?b›*))[1]) (*proven 2 subgoals*) . lemma prime_power_dvd_multD: assumes "prime_elem p" assumes "p ^ n dvd a * b" and "n > 0" and "¬ p dvd a" shows "p ^ n dvd b" using ‹p ^ n dvd a * b› (*‹p ^ n dvd a * b›*) ‹n > 0› (*‹0 < n›*) proof (induct n arbitrary: b) (*goals: 1. ‹⋀b. ⟦p ^ 0 dvd a * b; 0 < 0⟧ ⟹ p ^ 0 dvd b› 2. ‹⋀n b. ⟦⋀b. ⟦p ^ n dvd a * b; 0 < n⟧ ⟹ p ^ n dvd b; p ^ Suc n dvd a * b; 0 < Suc n⟧ ⟹ p ^ Suc n dvd b›*) case 0 (*‹p ^ 0 dvd a * b› ‹0 < 0›*) then show "?case" (*goal: ‹p ^ 0 dvd b›*) by simp next (*goal: ‹⋀n b. ⟦⋀b. ⟦p ^ n dvd a * b; 0 < n⟧ ⟹ p ^ n dvd b; p ^ Suc n dvd a * b; 0 < Suc n⟧ ⟹ p ^ Suc n dvd b›*) case (Suc n) (*‹⟦p ^ n dvd a * ?b1; 0 < n⟧ ⟹ p ^ n dvd ?b1› ‹(p::'a::type) ^ Suc (n::nat) dvd (a::'a::type) * (b::'a::type)› ‹0 < Suc n›*) show "?case" (*goal: ‹p ^ Suc n dvd b›*) proof (cases "n = 0") (*goals: 1. ‹n = 0 ⟹ p ^ Suc n dvd b› 2. ‹n ≠ 0 ⟹ p ^ Suc n dvd b›*) case True (*‹n = 0›*) with Suc (*‹⟦p ^ n dvd a * ?b1; 0 < n⟧ ⟹ p ^ n dvd ?b1› ‹(p::'a) ^ Suc (n::nat) dvd (a::'a) * (b::'a)› ‹(0::nat) < Suc (n::nat)›*) ‹prime_elem p› (*‹prime_elem p›*) ‹¬ p dvd a› (*‹¬ p dvd a›*) show "?thesis" (*goal: ‹p ^ Suc n dvd b›*) by (simp add: prime_elem_dvd_mult_iff (*‹prime_elem ?p ⟹ (?p dvd ?a * ?b) = (?p dvd ?a ∨ ?p dvd ?b)›*)) next (*goal: ‹n ≠ 0 ⟹ p ^ Suc n dvd b›*) case False (*‹n ≠ 0›*) then have "n > 0" by simp from ‹prime_elem p› (*‹prime_elem (p::'a::type)›*) have "p ≠ 0" by auto from Suc.prems (*‹p ^ Suc n dvd a * b› ‹0 < Suc n›*) have "*": "p * p ^ n dvd a * b" by simp then have "p dvd a * b" by (rule dvd_mult_left (*‹?a * ?b dvd ?c ⟹ ?a dvd ?c›*)) with Suc (*‹⟦p ^ n dvd a * ?b1; 0 < n⟧ ⟹ p ^ n dvd ?b1› ‹p ^ Suc n dvd a * b› ‹0 < Suc n›*) ‹prime_elem p› (*‹prime_elem p›*) ‹¬ p dvd a› (*‹¬ (p::'a) dvd (a::'a)›*) have "p dvd b" by (simp add: prime_elem_dvd_mult_iff (*‹prime_elem ?p ⟹ (?p dvd ?a * ?b) = (?p dvd ?a ∨ ?p dvd ?b)›*)) moreover define c where "c = b div p" ultimately have b: "b = p * c" by simp with "*" (*‹p * p ^ n dvd a * b›*) have "p * p ^ n dvd p * (a * c)" by (simp add: 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 43 facts*)) with ‹p ≠ 0› (*‹p ≠ 0›*) have "p ^ n dvd a * c" by simp with Suc.hyps (*‹⟦p ^ n dvd a * ?b1; 0 < n⟧ ⟹ p ^ n dvd ?b1›*) ‹n > 0› (*‹0 < n›*) have "p ^ n dvd c" by blast with ‹p ≠ 0› (*‹p ≠ 0›*) show "?thesis" (*goal: ‹p ^ Suc n dvd b›*) by (simp add: b (*‹(b::'a) = (p::'a) * (c::'a)›*)) qed qed end subsection ‹Generalized primes: normalized prime elements› context normalization_semidom begin lemma irreducible_normalized_divisors: assumes "irreducible x" "y dvd x" "normalize y = y" shows "y = 1 ∨ y = normalize x" proof (-) (*goal: ‹(y::'a) = (1::'a) ∨ y = normalize (x::'a)›*) from assms (*‹irreducible x› ‹(y::'a::type) dvd (x::'a::type)› ‹normalize y = y›*) have "is_unit y ∨ x dvd y" by (auto simp: irreducible_altdef (*‹irreducible (?x::'a) = (?x ≠ (0::'a) ∧ ¬ is_unit ?x ∧ (∀b::'a. b dvd ?x ⟶ ?x dvd b ∨ is_unit b))›*)) thus "?thesis" (*goal: ‹(y::'a) = (1::'a) ∨ y = normalize (x::'a)›*) proof (elim disjE (*‹⟦?P ∨ ?Q; ?P ⟹ ?R; ?Q ⟹ ?R⟧ ⟹ ?R›*)) (*goals: 1. ‹is_unit y ⟹ y = 1 ∨ y = normalize x› 2. ‹x dvd y ⟹ y = 1 ∨ y = normalize x›*) assume "is_unit y" (*‹is_unit (y::'a)›*) hence "normalize y = 1" by (simp add: is_unit_normalize (*‹is_unit ?a ⟹ normalize ?a = 1›*)) with assms (*‹irreducible (x::'a)› ‹y dvd x› ‹normalize (y::'a) = y›*) show "?thesis" (*goal: ‹y = 1 ∨ y = normalize x›*) by simp next (*goal: ‹(x::'a::type) dvd (y::'a::type) ⟹ y = (1::'a::type) ∨ y = normalize x›*) assume "x dvd y" (*‹(x::'a) dvd (y::'a)›*) with ‹y dvd x› (*‹y dvd x›*) have "normalize y = normalize x" by (rule associatedI (*‹⟦?a dvd ?b; ?b dvd ?a⟧ ⟹ normalize ?a = normalize ?b›*)) with assms (*‹irreducible x› ‹y dvd x› ‹normalize y = y›*) show "?thesis" (*goal: ‹y = 1 ∨ y = normalize x›*) by simp qed qed lemma irreducible_normalize_iff [simp]: "irreducible (normalize x) = irreducible x" using irreducible_mult_unit_left[of "1 div unit_factor x" x] (*‹is_unit (1 div unit_factor x) ⟹ irreducible (1 div unit_factor x * x) = irreducible x›*) apply (cases "x = 0") (*goals: 1. ‹⟦is_unit ((1::'a) div unit_factor (x::'a)) ⟹ irreducible ((1::'a) div unit_factor x * x) = irreducible x; x = (0::'a)⟧ ⟹ irreducible (normalize x) = irreducible x› 2. ‹⟦is_unit ((1::'a) div unit_factor (x::'a)) ⟹ irreducible ((1::'a) div unit_factor x * x) = irreducible x; x ≠ (0::'a)⟧ ⟹ irreducible (normalize x) = irreducible x› discuss goal 1*) apply (simp add: unit_div_commute (*‹is_unit ?b ⟹ ?a div ?b * ?c = ?a * ?c div ?b›*)) (*discuss goal 2*) apply (simp add: unit_div_commute (*‹is_unit ?b ⟹ ?a div ?b * ?c = ?a * ?c div ?b›*)) (*proven 2 subgoals*) . lemma prime_elem_normalize_iff [simp]: "prime_elem (normalize x) = prime_elem x" using prime_elem_mult_unit_left[of "1 div unit_factor x" x] (*‹is_unit (1 div unit_factor x) ⟹ prime_elem (1 div unit_factor x * x) = prime_elem x›*) apply (cases "x = 0") (*goals: 1. ‹⟦is_unit (1 div unit_factor x) ⟹ prime_elem (1 div unit_factor x * x) = prime_elem x; x = 0⟧ ⟹ prime_elem (normalize x) = prime_elem x› 2. ‹⟦is_unit (1 div unit_factor x) ⟹ prime_elem (1 div unit_factor x * x) = prime_elem x; x ≠ 0⟧ ⟹ prime_elem (normalize x) = prime_elem x› discuss goal 1*) apply (simp add: unit_div_commute (*‹is_unit ?b ⟹ ?a div ?b * ?c = ?a * ?c div ?b›*)) (*discuss goal 2*) apply (simp add: unit_div_commute (*‹is_unit ?b ⟹ ?a div ?b * ?c = ?a * ?c div ?b›*)) (*proven 2 subgoals*) . lemma prime_elem_associated: assumes "prime_elem p" and "prime_elem q" and "q dvd p" shows "normalize q = normalize p" using ‹q dvd p› (*‹q dvd p›*) proof (rule associatedI (*‹⟦?a dvd ?b; ?b dvd ?a⟧ ⟹ normalize ?a = normalize ?b›*)) (*goal: ‹p dvd q›*) from ‹prime_elem q› (*‹prime_elem q›*) have "¬ is_unit q" by (auto simp add: prime_elem_not_unit (*‹prime_elem ?p ⟹ ¬ is_unit ?p›*)) with ‹prime_elem p› (*‹prime_elem p›*) ‹q dvd p› (*‹q dvd p›*) show "p dvd q" by (blast intro: prime_elemD2 (*‹⟦prime_elem (?p::'a); (?a::'a) dvd ?p; ¬ is_unit ?a⟧ ⟹ ?p dvd ?a›*)) qed definition prime :: "'a ⇒ bool" where "prime p ⟷ prime_elem p ∧ normalize p = p" lemma not_prime_0 [simp]: "¬prime 0" by (simp add: prime_def (*‹prime (?p::'a::type) = (prime_elem ?p ∧ normalize ?p = ?p)›*)) lemma not_prime_unit: "is_unit x ⟹ ¬prime x" using prime_elem_not_unit[of x] (*‹prime_elem x ⟹ ¬ is_unit x›*) by (auto simp add: prime_def (*‹prime ?p = (prime_elem ?p ∧ normalize ?p = ?p)›*)) lemma not_prime_1 [simp]: "¬prime 1" by (simp add: not_prime_unit (*‹is_unit ?x ⟹ ¬ prime ?x›*)) lemma primeI: "prime_elem x ⟹ normalize x = x ⟹ prime x" by (simp add: prime_def (*‹prime ?p = (prime_elem ?p ∧ normalize ?p = ?p)›*)) lemma prime_imp_prime_elem [dest]: "prime p ⟹ prime_elem p" by (simp add: prime_def (*‹prime ?p = (prime_elem ?p ∧ normalize ?p = ?p)›*)) lemma normalize_prime: "prime p ⟹ normalize p = p" by (simp add: prime_def (*‹prime ?p = (prime_elem ?p ∧ normalize ?p = ?p)›*)) lemma prime_normalize_iff [simp]: "prime (normalize p) ⟷ prime_elem p" by (auto simp add: prime_def (*‹prime (?p::'a) = (prime_elem ?p ∧ normalize ?p = ?p)›*)) lemma prime_power_iff: "prime (p ^ n) ⟷ prime p ∧ n = 1" by (auto simp: prime_def (*‹prime ?p = (prime_elem ?p ∧ normalize ?p = ?p)›*) prime_elem_power_iff (*‹prime_elem (?p ^ ?n) = (prime_elem ?p ∧ ?n = 1)›*)) lemma prime_imp_nonzero [simp]: "ASSUMPTION (prime x) ⟹ x ≠ 0" unfolding ASSUMPTION_def prime_def (*goal: ‹prime_elem x ∧ normalize x = x ⟹ x ≠ 0›*) by auto lemma prime_imp_not_one [simp]: "ASSUMPTION (prime x) ⟹ x ≠ 1" unfolding ASSUMPTION_def (*goal: ‹prime x ⟹ x ≠ 1›*) by auto lemma prime_not_unit' [simp]: "ASSUMPTION (prime x) ⟹ ¬is_unit x" unfolding ASSUMPTION_def prime_def (*goal: ‹prime_elem x ∧ normalize x = x ⟹ ¬ is_unit x›*) by auto lemma prime_normalize' [simp]: "ASSUMPTION (prime x) ⟹ normalize x = x" unfolding ASSUMPTION_def prime_def (*goal: ‹prime_elem x ∧ normalize x = x ⟹ normalize x = x›*) by simp lemma unit_factor_prime: "prime x ⟹ unit_factor x = 1" using unit_factor_normalize[of x] (*‹x ≠ 0 ⟹ unit_factor (normalize x) = 1›*) unfolding prime_def (*goal: ‹prime_elem (x::'a) ∧ normalize x = x ⟹ unit_factor x = (1::'a)›*) by auto lemma unit_factor_prime' [simp]: "ASSUMPTION (prime x) ⟹ unit_factor x = 1" unfolding ASSUMPTION_def (*goal: ‹prime x ⟹ unit_factor x = 1›*) by (rule unit_factor_prime (*‹prime (?x::'a::type) ⟹ unit_factor ?x = (1::'a::type)›*)) lemma prime_imp_prime_elem' [simp]: "ASSUMPTION (prime x) ⟹ prime_elem x" by (simp add: prime_def (*‹prime ?p = (prime_elem ?p ∧ normalize ?p = ?p)›*) ASSUMPTION_def (*‹ASSUMPTION ?A ≡ ?A›*)) lemma prime_dvd_multD: "prime p ⟹ p dvd a * b ⟹ p dvd a ∨ p dvd b" apply (intro prime_elem_dvd_multD (*‹⟦prime_elem ?p; ?p dvd ?a * ?b⟧ ⟹ ?p dvd ?a ∨ ?p dvd ?b›*)) (*goals: 1. ‹⟦prime p; p dvd a * b⟧ ⟹ prime_elem p› 2. ‹⟦prime p; p dvd a * b⟧ ⟹ p dvd a * b› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) . lemma prime_dvd_mult_iff: "prime p ⟹ p dvd a * b ⟷ p dvd a ∨ p dvd b" by (auto dest: prime_dvd_multD (*‹⟦prime ?p; ?p dvd ?a * ?b⟧ ⟹ ?p dvd ?a ∨ ?p dvd ?b›*)) lemma prime_dvd_power: "prime p ⟹ p dvd x ^ n ⟹ p dvd x" by (auto dest!: prime_elem_dvd_power (*‹⟦prime_elem ?p; ?p dvd ?x ^ ?n⟧ ⟹ ?p dvd ?x›*) simp: prime_def (*‹prime ?p = (prime_elem ?p ∧ normalize ?p = ?p)›*)) lemma prime_dvd_power_iff: "prime p ⟹ n > 0 ⟹ p dvd x ^ n ⟷ p dvd x" apply (subst prime_elem_dvd_power_iff (*‹prime_elem ?p ⟹ (?p dvd ?a ^ ?n) = (?p dvd ?a ∧ 0 < ?n)›*)) (*goals: 1. ‹⟦prime p; 0 < n⟧ ⟹ prime_elem p› 2. ‹⟦prime p; 0 < n⟧ ⟹ (p dvd x ∧ 0 < n) = (p dvd x)› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) . lemma prime_dvd_prod_mset_iff: "prime p ⟹ p dvd prod_mset A ⟷ (∃x. x ∈# A ∧ p dvd x)" apply (induction A) (*goals: 1. ‹prime p ⟹ (p dvd ∏⇩# {#}) = (∃x. x ∈# {#} ∧ p dvd x)› 2. ‹⋀x A. ⟦prime p ⟹ (p dvd ∏⇩# A) = (∃x. x ∈# A ∧ p dvd x); prime p⟧ ⟹ (p dvd ∏⇩# (add_mset x A)) = (∃xa. xa ∈# add_mset x A ∧ p dvd xa)› discuss goal 1*) apply (simp add: prime_elem_dvd_mult_iff (*‹prime_elem ?p ⟹ (?p dvd ?a * ?b) = (?p dvd ?a ∨ ?p dvd ?b)›*) prime_imp_prime_elem (*‹prime ?p ⟹ prime_elem ?p›*)) (*discuss goal 2*) apply (simp add: prime_elem_dvd_mult_iff (*‹prime_elem (?p::'a) ⟹ (?p dvd (?a::'a) * (?b::'a)) = (?p dvd ?a ∨ ?p dvd ?b)›*) prime_imp_prime_elem (*‹prime (?p::'a) ⟹ prime_elem ?p›*)) (*goal: ‹⋀x A. ⟦prime p ⟹ (p dvd ∏⇩# A) = (∃x. x ∈# A ∧ p dvd x); prime p⟧ ⟹ (p dvd ∏⇩# (add_mset x A)) = (∃xa. xa ∈# add_mset x A ∧ p dvd xa)›*) apply blast (*proven 2 subgoals*) . lemma prime_dvd_prod_iff: "finite A ⟹ prime p ⟹ p dvd prod f A ⟷ (∃x∈A. p dvd f x)" by (auto simp: prime_dvd_prod_mset_iff (*‹prime ?p ⟹ (?p dvd ∏⇩# ?A) = (∃x. x ∈# ?A ∧ ?p dvd x)›*) prod_unfold_prod_mset (*‹prod ?f ?A = ∏⇩# (image_mset ?f (mset_set ?A))›*)) lemma primes_dvd_imp_eq: assumes "prime p" "prime q" "p dvd q" shows "p = q" proof (-) (*goal: ‹p = q›*) from assms (*‹prime p› ‹prime (q::'a::type)› ‹p dvd q›*) have "irreducible q" by (simp add: prime_elem_imp_irreducible (*‹prime_elem ?p ⟹ irreducible ?p›*) prime_def (*‹prime ?p = (prime_elem ?p ∧ normalize ?p = ?p)›*)) from irreducibleD'[OF this ‹p dvd q›] (*‹q dvd p ∨ is_unit p›*) assms (*‹prime p› ‹prime q› ‹p dvd q›*) have "q dvd p" by simp with ‹p dvd q› (*‹p dvd q›*) have "normalize p = normalize q" by (rule associatedI (*‹⟦?a dvd ?b; ?b dvd ?a⟧ ⟹ normalize ?a = normalize ?b›*)) with assms (*‹prime p› ‹prime q› ‹p dvd q›*) show "p = q" by simp qed lemma prime_dvd_prod_mset_primes_iff: assumes "prime p" "⋀q. q ∈# A ⟹ prime q" shows "p dvd prod_mset A ⟷ p ∈# A" proof (-) (*goal: ‹(p dvd ∏⇩# A) = (p ∈# A)›*) from assms(1) (*‹prime p›*) have "p dvd prod_mset A ⟷ (∃x. x ∈# A ∧ p dvd x)" by (rule prime_dvd_prod_mset_iff (*‹prime ?p ⟹ (?p dvd ∏⇩# ?A) = (∃x. x ∈# ?A ∧ ?p dvd x)›*)) also (*calculation: ‹(p dvd ∏⇩# A) = (∃x. x ∈# A ∧ p dvd x)›*) from assms (*‹prime p› ‹?q1 ∈# A ⟹ prime ?q1›*) have "… ⟷ p ∈# A" by (auto dest: primes_dvd_imp_eq (*‹⟦prime ?p; prime ?q; ?p dvd ?q⟧ ⟹ ?p = ?q›*)) finally (*calculation: ‹((p::'a) dvd ∏⇩# (A::'a multiset)) = (p ∈# A)›*) show "?thesis" (*goal: ‹(p dvd ∏⇩# A) = (p ∈# A)›*) . qed lemma prod_mset_primes_dvd_imp_subset: assumes "prod_mset A dvd prod_mset B" "⋀p. p ∈# A ⟹ prime p" "⋀p. p ∈# B ⟹ prime p" shows "A ⊆# B" using assms (*‹∏⇩# A dvd ∏⇩# B› ‹?p1 ∈# A ⟹ prime ?p1› ‹?p1 ∈# B ⟹ prime ?p1›*) proof (induction A arbitrary: B) (*goals: 1. ‹⋀B. ⟦∏⇩# {#} dvd ∏⇩# B; ⋀p. p ∈# {#} ⟹ prime p; ⋀p. p ∈# B ⟹ prime p⟧ ⟹ {#} ⊆# B› 2. ‹⋀x A B. ⟦⋀B. ⟦∏⇩# A dvd ∏⇩# B; ⋀p. p ∈# A ⟹ prime p; ⋀p. p ∈# B ⟹ prime p⟧ ⟹ A ⊆# B; ∏⇩# (add_mset x A) dvd ∏⇩# B; ⋀p. p ∈# add_mset x A ⟹ prime p; ⋀p. p ∈# B ⟹ prime p⟧ ⟹ add_mset x A ⊆# B›*) case empty (*‹∏⇩# {#} dvd ∏⇩# B› ‹?p1 ∈# {#} ⟹ prime ?p1› ‹?p1 ∈# B ⟹ prime ?p1›*) thus "?case" (*goal: ‹{#} ⊆# B›*) by simp next (*goal: ‹⋀(x::'a) (A::'a multiset) B::'a multiset. ⟦⋀B::'a multiset. ⟦∏⇩# A dvd ∏⇩# B; ⋀p::'a. p ∈# A ⟹ prime p; ⋀p::'a. p ∈# B ⟹ prime p⟧ ⟹ A ⊆# B; ∏⇩# (add_mset x A) dvd ∏⇩# B; ⋀p::'a. p ∈# add_mset x A ⟹ prime p; ⋀p::'a. p ∈# B ⟹ prime p⟧ ⟹ add_mset x A ⊆# B›*) case (add p A B) (*‹⟦∏⇩# A dvd ∏⇩# ?B1; ⋀p. p ∈# A ⟹ prime p; ⋀p. p ∈# ?B1 ⟹ prime p⟧ ⟹ A ⊆# ?B1› ‹∏⇩# (add_mset p A) dvd ∏⇩# B› ‹?p1 ∈# add_mset p A ⟹ prime ?p1› ‹?p1 ∈# B ⟹ prime ?p1›*) hence p: "prime p" by simp define B' where "B' = B - {#p#}" from add.prems (*‹∏⇩# (add_mset p A) dvd ∏⇩# B› ‹?p1 ∈# add_mset p A ⟹ prime ?p1› ‹?p1 ∈# B ⟹ prime ?p1›*) have "p dvd prod_mset B" by (simp add: dvd_mult_left (*‹?a * ?b dvd ?c ⟹ ?a dvd ?c›*)) with add.prems (*‹∏⇩# (add_mset p A) dvd ∏⇩# B› ‹?p1 ∈# add_mset p A ⟹ prime ?p1› ‹?p1 ∈# B ⟹ prime ?p1›*) have "p ∈# B" apply (subst (asm) (2) prime_dvd_prod_mset_primes_iff (*‹⟦prime (?p::'a::type); ⋀q::'a::type. q ∈# (?A::'a::type multiset) ⟹ prime q⟧ ⟹ (?p dvd ∏⇩# ?A) = (?p ∈# ?A)›*)) (*goals: 1. ‹⟦∏⇩# (add_mset (p::'a) (A::'a multiset)) dvd ∏⇩# (B::'a multiset); ⋀pa::'a. pa ∈# add_mset p A ⟹ prime pa; ⋀p::'a. p ∈# B ⟹ prime p⟧ ⟹ prime p› 2. ‹⋀q::'a. ⟦∏⇩# (add_mset (p::'a) (A::'a multiset)) dvd ∏⇩# (B::'a multiset); ⋀pa::'a. pa ∈# add_mset p A ⟹ prime pa; ⋀p::'a. p ∈# B ⟹ prime p; q ∈# B⟧ ⟹ prime q› 3. ‹⟦∏⇩# (add_mset (p::'a) (A::'a multiset)) dvd ∏⇩# (B::'a multiset); ⋀pa::'a. pa ∈# add_mset p A ⟹ prime pa; ⋀p::'a. p ∈# B ⟹ prime p; p ∈# B⟧ ⟹ p ∈# B› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*discuss goal 3*) apply simp (*proven 3 subgoals*) . hence B: "B = B' + {#p#}" by (simp add: B'_def (*‹(B'::'a multiset) = (B::'a multiset) - {#p::'a#}›*)) from add.prems (*‹∏⇩# (add_mset p A) dvd ∏⇩# B› ‹?p1 ∈# add_mset p A ⟹ prime ?p1› ‹?p1 ∈# B ⟹ prime ?p1›*) p (*‹prime p›*) have "A ⊆# B'" apply (intro add.IH (*‹⟦∏⇩# A dvd ∏⇩# ?B1; ⋀p. p ∈# A ⟹ prime p; ⋀p. p ∈# ?B1 ⟹ prime p⟧ ⟹ A ⊆# ?B1›*)) (*goals: 1. ‹⟦∏⇩# (add_mset p A) dvd ∏⇩# B; ⋀pa. pa ∈# add_mset p A ⟹ prime pa; ⋀p. p ∈# B ⟹ prime p; prime p⟧ ⟹ ∏⇩# A dvd ∏⇩# B'› 2. ‹⋀pa. ⟦∏⇩# (add_mset p A) dvd ∏⇩# B; ⋀pa. pa ∈# add_mset p A ⟹ prime pa; ⋀p. p ∈# B ⟹ prime p; prime p; pa ∈# A⟧ ⟹ prime pa› 3. ‹⋀pa. ⟦∏⇩# (add_mset p A) dvd ∏⇩# B; ⋀pa. pa ∈# add_mset p A ⟹ prime pa; ⋀p. p ∈# B ⟹ prime p; prime p; pa ∈# B'⟧ ⟹ prime pa› discuss goal 1*) apply (simp add: B (*‹B = B' + {#p#}›*)) (*discuss goal 2*) apply (simp add: B (*‹B = B' + {#p#}›*)) (*discuss goal 3*) apply (simp add: B (*‹B = B' + {#p#}›*)) (*proven 3 subgoals*) . thus "?case" (*goal: ‹add_mset p A ⊆# B›*) by (simp add: B (*‹B = B' + {#p#}›*)) qed lemma prod_mset_dvd_prod_mset_primes_iff: assumes "⋀x. x ∈# A ⟹ prime x" "⋀x. x ∈# B ⟹ prime x" shows "prod_mset A dvd prod_mset B ⟷ A ⊆# B" using assms (*‹?x1 ∈# A ⟹ prime ?x1› ‹?x1 ∈# B ⟹ prime ?x1›*) by (auto intro: prod_mset_subset_imp_dvd (*‹(?A::'a multiset) ⊆# (?B::'a multiset) ⟹ ∏⇩# ?A dvd ∏⇩# ?B›*) prod_mset_primes_dvd_imp_subset (*‹⟦∏⇩# (?A::'a multiset) dvd ∏⇩# (?B::'a multiset); ⋀p::'a. p ∈# ?A ⟹ prime p; ⋀p::'a. p ∈# ?B ⟹ prime p⟧ ⟹ ?A ⊆# ?B›*)) lemma is_unit_prod_mset_primes_iff: assumes "⋀x. x ∈# A ⟹ prime x" shows "is_unit (prod_mset A) ⟷ A = {#}" apply (auto simp add: is_unit_prod_mset_iff (*‹is_unit (∏⇩# (?A::'a multiset)) = (∀x::'a∈#?A. is_unit x)›*)) (*goal: ‹is_unit (∏⇩# A) = (A = {#})›*) by (meson all_not_in_conv (*‹(∀x::?'a. x ∉ (?A::?'a set)) = (?A = {})›*) assms (*‹(?x1::'a) ∈# (A::'a multiset) ⟹ prime ?x1›*) not_prime_unit (*‹is_unit (?x::'a) ⟹ ¬ prime ?x›*) set_mset_eq_empty_iff (*‹(set_mset (?M::?'a multiset) = {}) = (?M = {#})›*)) lemma prod_mset_primes_irreducible_imp_prime: assumes irred: "irreducible (prod_mset A)" assumes A: "⋀x. x ∈# A ⟹ prime x" assumes B: "⋀x. x ∈# B ⟹ prime x" assumes C: "⋀x. x ∈# C ⟹ prime x" assumes dvd: "prod_mset A dvd prod_mset B * prod_mset C" shows "prod_mset A dvd prod_mset B ∨ prod_mset A dvd prod_mset C" proof (-) (*goal: ‹∏⇩# A dvd ∏⇩# B ∨ ∏⇩# A dvd ∏⇩# C›*) from dvd (*‹∏⇩# A dvd ∏⇩# B * ∏⇩# C›*) have "prod_mset A dvd prod_mset (B + C)" by simp with A (*‹?x1 ∈# A ⟹ prime ?x1›*) B (*‹?x1 ∈# B ⟹ prime ?x1›*) C (*‹?x1 ∈# C ⟹ prime ?x1›*) have subset: "A ⊆# B + C" apply (subst (asm) prod_mset_dvd_prod_mset_primes_iff (*‹⟦⋀x. x ∈# ?A ⟹ prime x; ⋀x. x ∈# ?B ⟹ prime x⟧ ⟹ (∏⇩# ?A dvd ∏⇩# ?B) = (?A ⊆# ?B)›*)) (*goals: 1. ‹⋀x. ⟦⋀x. x ∈# A ⟹ prime x; ⋀x. x ∈# B ⟹ prime x; ⋀x. x ∈# C ⟹ prime x; x ∈# A⟧ ⟹ prime x› 2. ‹⋀x. ⟦⋀x. x ∈# A ⟹ prime x; ⋀x. x ∈# B ⟹ prime x; ⋀x. x ∈# C ⟹ prime x; x ∈# B + C⟧ ⟹ prime x› 3. ‹⟦⋀x. x ∈# A ⟹ prime x; ⋀x. x ∈# B ⟹ prime x; ⋀x. x ∈# C ⟹ prime x; A ⊆# B + C⟧ ⟹ A ⊆# B + C› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*proven 3 subgoals*) . define A1 and A2 where "A1 = A ∩# B" and "A2 = A - A1" have "A = A1 + A2" unfolding A1_def A2_def (*goal: ‹A = A ∩# B + (A - A ∩# B)›*) apply (rule sym (*‹(?s::?'a::type) = (?t::?'a::type) ⟹ ?t = ?s›*)) (*goal: ‹A = A ∩# B + (A - A ∩# B)›*) apply (intro subset_mset.add_diff_inverse (*‹?a ⊆# ?b ⟹ ?a + (?b - ?a) = ?b›*)) (*goal: ‹A ∩# B + (A - A ∩# B) = A›*) by simp from subset (*‹(A::'a multiset) ⊆# (B::'a multiset) + (C::'a multiset)›*) have "A1 ⊆# B" "A2 ⊆# C" apply - (*goals: 1. ‹A ⊆# B + C ⟹ A1 ⊆# B› 2. ‹A ⊆# B + C ⟹ A2 ⊆# C› discuss goal 1*) apply ((auto simp: A1_def (*‹A1 = A ∩# B›*) A2_def (*‹A2 = A - A1›*) Multiset.subset_eq_diff_conv (*‹(?A - ?C ⊆# ?B) = (?A ⊆# ?B + ?C)›*) Multiset.union_commute (*‹?M + ?N = ?N + ?M›*))[1]) (*discuss goal 2*) apply ((auto simp: A1_def (*‹(A1::'a multiset) = (A::'a multiset) ∩# (B::'a multiset)›*) A2_def (*‹(A2::'a multiset) = (A::'a multiset) - (A1::'a multiset)›*) Multiset.subset_eq_diff_conv (*‹((?A::?'a multiset) - (?C::?'a multiset) ⊆# (?B::?'a multiset)) = (?A ⊆# ?B + ?C)›*) Multiset.union_commute (*‹(?M::?'a multiset) + (?N::?'a multiset) = ?N + ?M›*))[1]) (*proven 2 subgoals*) . from ‹A = A1 + A2› (*‹A = A1 + A2›*) have "prod_mset A = prod_mset A1 * prod_mset A2" by simp from irred (*‹irreducible (∏⇩# A)›*) this (*‹∏⇩# A = ∏⇩# A1 * ∏⇩# A2›*) have "is_unit (prod_mset A1) ∨ is_unit (prod_mset A2)" by (rule irreducibleD (*‹⟦irreducible ?p; ?p = ?a * ?b⟧ ⟹ is_unit ?a ∨ is_unit ?b›*)) with A (*‹?x1 ∈# A ⟹ prime ?x1›*) have "A1 = {#} ∨ A2 = {#}" unfolding A1_def A2_def (*goal: ‹A ∩# B = {#} ∨ A - A ∩# B = {#}›*) apply (subst (asm) (1 2) is_unit_prod_mset_primes_iff (*‹(⋀x. x ∈# ?A ⟹ prime x) ⟹ is_unit (∏⇩# ?A) = (?A = {#})›*)) (*goals: 1. ‹⋀x. ⟦⋀x. x ∈# A ⟹ prime x; x ∈# A - A ∩# B⟧ ⟹ prime x› 2. ‹⋀x. ⟦⋀x. x ∈# A ⟹ prime x; x ∈# A ∩# B⟧ ⟹ prime x› 3. ‹⟦⋀x. x ∈# A ⟹ prime x; A ∩# B = {#} ∨ A - A ∩# B = {#}⟧ ⟹ A ∩# B = {#} ∨ A - A ∩# B = {#}› discuss goal 1*) apply ((auto dest: Multiset.in_diffD (*‹?a ∈# ?M - ?N ⟹ ?a ∈# ?M›*))[1]) (*discuss goal 2*) apply ((auto dest: Multiset.in_diffD (*‹?a ∈# ?M - ?N ⟹ ?a ∈# ?M›*))[1]) (*discuss goal 3*) apply ((auto dest: Multiset.in_diffD (*‹?a ∈# ?M - ?N ⟹ ?a ∈# ?M›*))[1]) (*proven 3 subgoals*) . with dvd (*‹∏⇩# (A::'a multiset) dvd ∏⇩# (B::'a multiset) * ∏⇩# (C::'a multiset)›*) ‹A = A1 + A2› (*‹A = A1 + A2›*) ‹A1 ⊆# B› (*‹A1 ⊆# B›*) ‹A2 ⊆# C› (*‹(A2::'a multiset) ⊆# (C::'a multiset)›*) show "?thesis" (*goal: ‹∏⇩# (A::'a multiset) dvd ∏⇩# (B::'a multiset) ∨ ∏⇩# A dvd ∏⇩# (C::'a multiset)›*) by (auto intro: prod_mset_subset_imp_dvd (*‹?A ⊆# ?B ⟹ ∏⇩# ?A dvd ∏⇩# ?B›*)) qed lemma prod_mset_primes_finite_divisor_powers: assumes A: "⋀x. x ∈# A ⟹ prime x" assumes B: "⋀x. x ∈# B ⟹ prime x" assumes "A ≠ {#}" shows "finite {n. prod_mset A ^ n dvd prod_mset B}" proof (-) (*goal: ‹finite {n. ∏⇩# A ^ n dvd ∏⇩# B}›*) from ‹A ≠ {#}› (*‹A ≠ {#}›*) obtain x where x: "x ∈# A" (*goal: ‹(⋀x. x ∈# A ⟹ thesis) ⟹ thesis›*) by blast define m where "m = count B x" have "{n. prod_mset A ^ n dvd prod_mset B} ⊆ {..m}" proof (safe) (*goal: ‹⋀x. ∏⇩# A ^ x dvd ∏⇩# B ⟹ x ≤ m›*) fix n assume dvd: "prod_mset A ^ n dvd prod_mset B" (*‹∏⇩# (A::'a multiset) ^ (n::nat) dvd ∏⇩# (B::'a multiset)›*) from x (*‹x ∈# A›*) have "x ^ n dvd prod_mset A ^ n" by (intro dvd_power_same (*‹?x dvd ?y ⟹ ?x ^ ?n dvd ?y ^ ?n›*) dvd_prod_mset (*‹?x ∈# ?A ⟹ ?x dvd ∏⇩# ?A›*)) also (*calculation: ‹x ^ n dvd ∏⇩# A ^ n›*) note dvd (*‹∏⇩# A ^ n dvd ∏⇩# B›*) also (*calculation: ‹x ^ n dvd ∏⇩# B›*) have "x ^ n = prod_mset (replicate_mset n x)" by simp finally (*calculation: ‹∏⇩# (replicate_mset n x) dvd ∏⇩# B›*) have "replicate_mset n x ⊆# B" apply (rule prod_mset_primes_dvd_imp_subset (*‹⟦∏⇩# ?A dvd ∏⇩# ?B; ⋀p. p ∈# ?A ⟹ prime p; ⋀p. p ∈# ?B ⟹ prime p⟧ ⟹ ?A ⊆# ?B›*)) (*goals: 1. ‹⋀p. p ∈# replicate_mset n x ⟹ prime p› 2. ‹⋀p. p ∈# B ⟹ prime p› discuss goal 1*) apply ((insert A (*‹?x1 ∈# A ⟹ prime ?x1›*) B (*‹?x1 ∈# B ⟹ prime ?x1›*) x (*‹x ∈# A›*))[1]) (*top goal: ‹⋀p. p ∈# replicate_mset n x ⟹ prime p› and 1 goal remains*) apply (simp 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))›*)) (*discuss goal 2*) apply ((insert A (*‹?x1 ∈# A ⟹ prime ?x1›*) B (*‹?x1 ∈# B ⟹ prime ?x1›*) x (*‹x ∈# A›*))[1]) (*goal: ‹⋀p. p ∈# B ⟹ prime p›*) apply (simp 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))›*)) (*proven 2 subgoals*) . thus "n ≤ m" by (simp add: count_le_replicate_mset_subset_eq (*‹((?n::nat) ≤ count (?M::?'a multiset) (?x::?'a)) = (replicate_mset ?n ?x ⊆# ?M)›*) m_def (*‹(m::nat) = count (B::'a multiset) (x::'a)›*)) qed moreover have "finite {..m}" by simp ultimately show "?thesis" (*goal: ‹finite {n. ∏⇩# A ^ n dvd ∏⇩# B}›*) by (rule finite_subset (*‹⟦?A ⊆ ?B; finite ?B⟧ ⟹ finite ?A›*)) qed end subsection ‹In a semiring with GCD, each irreducible element is a prime element› context semiring_gcd begin lemma irreducible_imp_prime_elem_gcd: assumes "irreducible x" shows "prime_elem x" proof (rule prime_elemI (*‹⟦(?p::'a) ≠ (0::'a); ¬ is_unit ?p; ⋀(a::'a) b::'a. ?p dvd a * b ⟹ ?p dvd a ∨ ?p dvd b⟧ ⟹ prime_elem ?p›*)) (*goals: 1. ‹x ≠ 0› 2. ‹¬ is_unit x› 3. ‹⋀a b. x dvd a * b ⟹ x dvd a ∨ x dvd b›*) fix a and b assume "x dvd a * b" (*‹(x::'a) dvd (a::'a) * (b::'a)›*) from dvd_productE[OF this] (*‹(⋀xa y. ⟦x = xa * y; xa dvd a; y dvd b⟧ ⟹ ?thesis) ⟹ ?thesis›*) obtain y and z where yz: "x = y * z" "y dvd a" "z dvd b" (*goal: ‹(⋀y z. ⟦x = y * z; y dvd a; z dvd b⟧ ⟹ thesis) ⟹ thesis›*) . from ‹irreducible x› (*‹irreducible x›*) ‹x = y * z› (*‹(x::'a::type) = (y::'a::type) * (z::'a::type)›*) have "is_unit y ∨ is_unit z" by (rule irreducibleD (*‹⟦irreducible (?p::'a::type); ?p = (?a::'a::type) * (?b::'a::type)⟧ ⟹ is_unit ?a ∨ is_unit ?b›*)) with yz (*‹x = y * z› ‹y dvd a› ‹z dvd b›*) show "x dvd a ∨ x dvd b" by (auto simp: mult_unit_dvd_iff (*‹is_unit ?b ⟹ (?a * ?b dvd ?c) = (?a dvd ?c)›*) mult_unit_dvd_iff' (*‹is_unit ?a ⟹ (?a * ?b dvd ?c) = (?b dvd ?c)›*)) qed (insert assms (*‹irreducible x›*), auto simp: irreducible_not_unit (*‹irreducible ?p ⟹ ¬ is_unit ?p›*)) (*solves the remaining goals: 1. ‹x ≠ 0› 2. ‹¬ is_unit x›*) lemma prime_elem_imp_coprime: assumes "prime_elem p" "¬p dvd n" shows "coprime p n" proof (rule coprimeI (*‹(⋀c::'a. ⟦c dvd (?a::'a); c dvd (?b::'a)⟧ ⟹ is_unit c) ⟹ coprime ?a ?b›*)) (*goal: ‹⋀c. ⟦c dvd p; c dvd n⟧ ⟹ is_unit c›*) fix d assume "d dvd p" "d dvd n" (*‹(d::'a) dvd (p::'a)› ‹(d::'a) dvd (n::'a)›*) show "is_unit d" proof (rule ccontr (*‹(¬ ?P ⟹ False) ⟹ ?P›*)) (*goal: ‹¬ is_unit (d::'a) ⟹ False›*) assume "¬is_unit d" (*‹¬ is_unit (d::'a)›*) from ‹prime_elem p› (*‹prime_elem p›*) ‹d dvd p› (*‹(d::'a::type) dvd (p::'a::type)›*) this (*‹¬ is_unit d›*) have "p dvd d" by (rule prime_elemD2 (*‹⟦prime_elem (?p::'a); (?a::'a) dvd ?p; ¬ is_unit ?a⟧ ⟹ ?p dvd ?a›*)) from this (*‹p dvd d›*) ‹d dvd n› (*‹d dvd n›*) have "p dvd n" by (rule dvd_trans (*‹⟦?a dvd ?b; ?b dvd ?c⟧ ⟹ ?a dvd ?c›*)) with ‹¬p dvd n› (*‹¬ p dvd n›*) show False by contradiction qed qed lemma prime_imp_coprime: assumes "prime p" "¬p dvd n" shows "coprime p n" using assms (*‹prime (p::'a)› ‹¬ p dvd n›*) by (simp add: prime_elem_imp_coprime (*‹⟦prime_elem (?p::'a::type); ¬ ?p dvd (?n::'a::type)⟧ ⟹ coprime ?p ?n›*)) lemma prime_elem_imp_power_coprime: "prime_elem p ⟹ ¬ p dvd a ⟹ coprime a (p ^ m)" apply (cases "m > 0") (*goals: 1. ‹⟦prime_elem p; ¬ p dvd a; 0 < m⟧ ⟹ coprime a (p ^ m)› 2. ‹⟦prime_elem p; ¬ p dvd a; ¬ 0 < m⟧ ⟹ coprime a (p ^ m)› discuss goal 1*) apply ((auto dest: prime_elem_imp_coprime (*‹⟦prime_elem ?p; ¬ ?p dvd ?n⟧ ⟹ coprime ?p ?n›*) simp add: 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*))[1]) (*discuss goal 2*) apply ((auto dest: prime_elem_imp_coprime (*‹⟦prime_elem ?p; ¬ ?p dvd ?n⟧ ⟹ coprime ?p ?n›*) simp add: 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*))[1]) (*proven 2 subgoals*) . lemma prime_imp_power_coprime: "prime p ⟹ ¬ p dvd a ⟹ coprime a (p ^ m)" apply (rule prime_elem_imp_power_coprime (*‹⟦prime_elem (?p::'a); ¬ ?p dvd (?a::'a)⟧ ⟹ coprime ?a (?p ^ (?m::nat))›*)) (*goals: 1. ‹⟦prime p; ¬ p dvd a⟧ ⟹ prime_elem p› 2. ‹⟦prime p; ¬ p dvd a⟧ ⟹ ¬ p dvd a› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) . lemma prime_elem_divprod_pow: assumes p: "prime_elem p" and ab: "coprime a b" and pab: "p^n dvd a * b" shows "p^n dvd a ∨ p^n dvd b" using assms (*‹prime_elem p› ‹coprime a b› ‹p ^ n dvd a * b›*) proof (-) (*goal: ‹⟦prime_elem p; coprime a b; p ^ n dvd a * b⟧ ⟹ p ^ n dvd a ∨ p ^ n dvd b›*) from p (*‹prime_elem p›*) have "¬ is_unit p" by simp with ab (*‹coprime a b›*) p (*‹prime_elem p›*) have "¬ p dvd a ∨ ¬ p dvd b" using not_coprimeI (*‹⟦?c dvd ?a; ?c dvd ?b; ¬ is_unit ?c⟧ ⟹ ¬ coprime ?a ?b›*) by blast with p (*‹prime_elem (p::'a::type)›*) have "coprime (p ^ n) a ∨ coprime (p ^ n) b" by (auto dest: prime_elem_imp_power_coprime (*‹⟦prime_elem ?p; ¬ ?p dvd ?a⟧ ⟹ coprime ?a (?p ^ ?m)›*) simp add: 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*)) with pab (*‹p ^ n dvd a * b›*) show "?thesis" (*goal: ‹(p::'a::type) ^ (n::nat) dvd (a::'a::type) ∨ p ^ n dvd (b::'a::type)›*) by (auto simp add: coprime_dvd_mult_left_iff (*‹coprime ?a ?c ⟹ (?a dvd ?b * ?c) = (?a dvd ?b)›*) coprime_dvd_mult_right_iff (*‹coprime ?a ?c ⟹ (?a dvd ?c * ?b) = (?a dvd ?b)›*)) qed lemma primes_coprime: "prime p ⟹ prime q ⟹ p ≠ q ⟹ coprime p q" using prime_imp_coprime (*‹⟦prime ?p; ¬ ?p dvd ?n⟧ ⟹ coprime ?p ?n›*) primes_dvd_imp_eq (*‹⟦prime (?p::'a::type); prime (?q::'a::type); ?p dvd ?q⟧ ⟹ ?p = ?q›*) by blast end subsection ‹Factorial semirings: algebraic structures with unique prime factorizations› class factorial_semiring = normalization_semidom + assumes prime_factorization_exists: "x ≠ 0 ⟹ ∃A. (∀x. x ∈# A ⟶ prime_elem x) ∧ normalize (prod_mset A) = normalize x" text ‹Alternative characterization› lemma (in normalization_semidom) factorial_semiring_altI_aux: assumes finite_divisors: "⋀x. x ≠ 0 ⟹ finite {y. y dvd x ∧ normalize y = y}" assumes irreducible_imp_prime_elem: "⋀x. irreducible x ⟹ prime_elem x" assumes "x ≠ 0" shows "∃A. (∀x. x ∈# A ⟶ prime_elem x) ∧ normalize (prod_mset A) = normalize x" using ‹x ≠ 0› (*‹x ≠ 0›*) proof (induction "card {b. b dvd x ∧ normalize b = b}" arbitrary: x rule: less_induct) (*goal: ‹⋀x. ⟦⋀xa. ⟦card {b. b dvd xa ∧ normalize b = b} < card {b. b dvd x ∧ normalize b = b}; xa ≠ 0⟧ ⟹ ∃A. (∀x. x ∈# A ⟶ prime_elem x) ∧ normalize (∏⇩# A) = normalize xa; x ≠ 0⟧ ⟹ ∃A. (∀x. x ∈# A ⟶ prime_elem x) ∧ normalize (∏⇩# A) = normalize x›*) case (less a) (*‹⟦card {b::'a. b dvd (?x1::'a) ∧ normalize b = b} < card {b::'a. b dvd (a::'a) ∧ normalize b = b}; ?x1 ≠ (0::'a)⟧ ⟹ ∃A::'a multiset. (∀x::'a. x ∈# A ⟶ prime_elem x) ∧ normalize (∏⇩# A) = normalize ?x1› ‹a ≠ 0›*) let ?fctrs = "λa. {b. b dvd a ∧ normalize b = b}" show "?case" (*goal: ‹∃A. (∀x. x ∈# A ⟶ prime_elem x) ∧ normalize (∏⇩# A) = normalize a›*) proof (cases "is_unit a") (*goals: 1. ‹is_unit a ⟹ ∃A. (∀x. x ∈# A ⟶ prime_elem x) ∧ normalize (∏⇩# A) = normalize a› 2. ‹¬ is_unit a ⟹ ∃A. (∀x. x ∈# A ⟶ prime_elem x) ∧ normalize (∏⇩# A) = normalize a›*) case True (*‹is_unit a›*) thus "?thesis" (*goal: ‹∃A::'a multiset. (∀x::'a. x ∈# A ⟶ prime_elem x) ∧ normalize (∏⇩# A) = normalize (a::'a)›*) apply (intro exI[of _ "{#}"] (*‹?P {#} ⟹ ∃x. ?P x›*)) (*goal: ‹∃A. (∀x. x ∈# A ⟶ prime_elem x) ∧ normalize (∏⇩# A) = normalize a›*) by (auto simp: is_unit_normalize (*‹is_unit ?a ⟹ normalize ?a = 1›*)) next (*goal: ‹¬ is_unit (a::'a::type) ⟹ ∃A::'a::type multiset. (∀x::'a::type. x ∈# A ⟶ prime_elem x) ∧ normalize (∏⇩# A) = normalize a›*) case False (*‹¬ is_unit a›*) show "?thesis" (*goal: ‹∃A::'a::type multiset. (∀x::'a::type. x ∈# A ⟶ prime_elem x) ∧ normalize (∏⇩# A) = normalize (a::'a::type)›*) proof (cases "∃b. b dvd a ∧ ¬is_unit b ∧ ¬a dvd b") (*goals: 1. ‹∃b. b dvd a ∧ ¬ is_unit b ∧ ¬ a dvd b ⟹ ∃A. (∀x. x ∈# A ⟶ prime_elem x) ∧ normalize (∏⇩# A) = normalize a› 2. ‹∄b. b dvd a ∧ ¬ is_unit b ∧ ¬ a dvd b ⟹ ∃A. (∀x. x ∈# A ⟶ prime_elem x) ∧ normalize (∏⇩# A) = normalize a›*) case False (*‹∄b::'a. b dvd (a::'a) ∧ ¬ is_unit b ∧ ¬ a dvd b›*) with ‹¬is_unit a› (*‹¬ is_unit a›*) less.prems (*‹a ≠ 0›*) have "irreducible a" by (auto simp: irreducible_altdef (*‹irreducible ?x = (?x ≠ 0 ∧ ¬ is_unit ?x ∧ (∀b. b dvd ?x ⟶ ?x dvd b ∨ is_unit b))›*)) hence "prime_elem a" by (rule irreducible_imp_prime_elem (*‹irreducible ?x1 ⟹ prime_elem ?x1›*)) thus "?thesis" (*goal: ‹∃A. (∀x. x ∈# A ⟶ prime_elem x) ∧ normalize (∏⇩# A) = normalize a›*) apply (intro exI[of _ "{#normalize a#}"] (*‹?P {#normalize a#} ⟹ ∃x. ?P x›*)) (*goal: ‹∃A. (∀x. x ∈# A ⟶ prime_elem x) ∧ normalize (∏⇩# A) = normalize a›*) by auto next (*goal: ‹∃b. b dvd a ∧ ¬ is_unit b ∧ ¬ a dvd b ⟹ ∃A. (∀x. x ∈# A ⟶ prime_elem x) ∧ normalize (∏⇩# A) = normalize a›*) case True (*‹∃b::'a. b dvd (a::'a) ∧ ¬ is_unit b ∧ ¬ a dvd b›*) then obtain b where b: "b dvd a" "¬ is_unit b" "¬ a dvd b" (*goal: ‹(⋀b. ⟦b dvd a; ¬ is_unit b; ¬ a dvd b⟧ ⟹ thesis) ⟹ thesis›*) by auto from b (*‹b dvd a› ‹¬ is_unit b› ‹¬ a dvd b›*) have "?fctrs b ⊆ ?fctrs a" by (auto intro: dvd_trans (*‹⟦?a dvd ?b; ?b dvd ?c⟧ ⟹ ?a dvd ?c›*)) moreover from b (*‹b dvd a› ‹¬ is_unit b› ‹¬ (a::'a::type) dvd (b::'a::type)›*) have "normalize a ∉ ?fctrs b" "normalize a ∈ ?fctrs a" apply - (*goals: 1. ‹⟦(b::'a) dvd (a::'a); ¬ is_unit b; ¬ a dvd b⟧ ⟹ normalize a ∉ {ba::'a. ba dvd b ∧ normalize ba = ba}› 2. ‹⟦(b::'a) dvd (a::'a); ¬ is_unit b; ¬ a dvd b⟧ ⟹ normalize a ∈ {b::'a. b dvd a ∧ normalize b = b}› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) . hence "?fctrs b ≠ ?fctrs a" by blast ultimately have "?fctrs b ⊂ ?fctrs a" apply (subst subset_not_subset_eq (*‹((?A::?'a set) ⊂ (?B::?'a set)) = (?A ⊆ ?B ∧ ¬ ?B ⊆ ?A)›*)) (*goal: ‹{ba. ba dvd b ∧ normalize ba = ba} ⊂ {b. b dvd a ∧ normalize b = b}›*) by blast with finite_divisors[OF ‹a ≠ 0›] (*‹finite {y. y dvd a ∧ normalize y = y}›*) have "card (?fctrs b) < card (?fctrs a)" by (rule psubset_card_mono (*‹⟦finite ?B; ?A ⊂ ?B⟧ ⟹ card ?A < card ?B›*)) moreover from ‹a ≠ 0› (*‹a ≠ 0›*) b (*‹b dvd a› ‹¬ is_unit b› ‹¬ a dvd b›*) have "b ≠ 0" by auto ultimately have "∃A. (∀x. x ∈# A ⟶ prime_elem x) ∧ normalize (prod_mset A) = normalize b" apply (intro less (*‹⟦card {b::'a::type. b dvd (?x1::'a::type) ∧ normalize b = b} < card {b::'a::type. b dvd (a::'a::type) ∧ normalize b = b}; ?x1 ≠ (0::'a::type)⟧ ⟹ ∃A::'a::type multiset. (∀x::'a::type. x ∈# A ⟶ prime_elem x) ∧ normalize (∏⇩# A) = normalize ?x1› ‹(a::'a::type) ≠ (0::'a::type)›*)) (*goals: 1. ‹⟦card {ba. ba dvd b ∧ normalize ba = ba} < card {b. b dvd a ∧ normalize b = b}; b ≠ 0⟧ ⟹ card {ba. ba dvd b ∧ normalize ba = ba} < card {b. b dvd a ∧ normalize b = b}› 2. ‹⟦card {ba. ba dvd b ∧ normalize ba = ba} < card {b. b dvd a ∧ normalize b = b}; b ≠ 0⟧ ⟹ b ≠ 0› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . then obtain A where A: "(∀x. x ∈# A ⟶ prime_elem x) ∧ normalize (∏⇩# A) = normalize b" (*goal: ‹(⋀A::'a multiset. (∀x::'a. x ∈# A ⟶ prime_elem x) ∧ normalize (∏⇩# A) = normalize (b::'a) ⟹ thesis::bool) ⟹ thesis›*) by auto define c where "c = a div b" from b (*‹b dvd a› ‹¬ is_unit b› ‹¬ a dvd b›*) have c: "a = b * c" by (simp add: c_def (*‹c = a div b›*)) from less.prems (*‹a ≠ 0›*) c (*‹a = b * c›*) have "c ≠ 0" by auto from b (*‹(b::'a) dvd (a::'a)› ‹¬ is_unit b› ‹¬ a dvd b›*) c (*‹(a::'a) = (b::'a) * (c::'a)›*) have "?fctrs c ⊆ ?fctrs a" by (auto intro: dvd_trans (*‹⟦?a dvd ?b; ?b dvd ?c⟧ ⟹ ?a dvd ?c›*)) moreover have "normalize a ∉ ?fctrs c" proof (safe) (*goal: ‹⟦normalize a dvd c; normalize (normalize a) = normalize a⟧ ⟹ False›*) assume "normalize a dvd c" (*‹normalize (a::'a) dvd (c::'a)›*) hence "b * c dvd 1 * c" by (simp add: c (*‹a = b * c›*)) hence "b dvd 1" apply (subst (asm) dvd_times_right_cancel_iff (*‹(?a::'a) ≠ (0::'a) ⟹ ((?b::'a) * ?a dvd (?c::'a) * ?a) = (?b dvd ?c)›*)) (*goals: 1. ‹c ≠ 0› 2. ‹is_unit b ⟹ is_unit b› discuss goal 1*) apply fact (*discuss goal 2*) . (*proven 2 subgoals*) with b (*‹b dvd a› ‹¬ is_unit b› ‹¬ a dvd b›*) show False by simp qed with ‹normalize a ∈ ?fctrs a› (*‹normalize a ∈ {b. b dvd a ∧ normalize b = b}›*) have "?fctrs a ≠ ?fctrs c" by blast ultimately have "?fctrs c ⊂ ?fctrs a" apply (subst subset_not_subset_eq (*‹(?A ⊂ ?B) = (?A ⊆ ?B ∧ ¬ ?B ⊆ ?A)›*)) (*goal: ‹{b. b dvd c ∧ normalize b = b} ⊂ {b. b dvd a ∧ normalize b = b}›*) by blast with finite_divisors[OF ‹a ≠ 0›] (*‹finite {y. y dvd a ∧ normalize y = y}›*) have "card (?fctrs c) < card (?fctrs a)" by (rule psubset_card_mono (*‹⟦finite (?B::?'a::type set); (?A::?'a::type set) ⊂ ?B⟧ ⟹ card ?A < card ?B›*)) with ‹c ≠ 0› (*‹c ≠ 0›*) have "∃A. (∀x. x ∈# A ⟶ prime_elem x) ∧ normalize (prod_mset A) = normalize c" apply (intro less (*‹⟦card {b. b dvd ?x1 ∧ normalize b = b} < card {b. b dvd a ∧ normalize b = b}; ?x1 ≠ 0⟧ ⟹ ∃A. (∀x. x ∈# A ⟶ prime_elem x) ∧ normalize (∏⇩# A) = normalize ?x1› ‹a ≠ 0›*)) (*goals: 1. ‹⟦c ≠ 0; card {b. b dvd c ∧ normalize b = b} < card {b. b dvd a ∧ normalize b = b}⟧ ⟹ card {b. b dvd c ∧ normalize b = b} < card {b. b dvd a ∧ normalize b = b}› 2. ‹⟦c ≠ 0; card {b. b dvd c ∧ normalize b = b} < card {b. b dvd a ∧ normalize b = b}⟧ ⟹ c ≠ 0› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . then obtain B where B: "(∀x. x ∈# B ⟶ prime_elem x) ∧ normalize (∏⇩# B) = normalize c" (*goal: ‹(⋀B. (∀x. x ∈# B ⟶ prime_elem x) ∧ normalize (∏⇩# B) = normalize c ⟹ thesis) ⟹ thesis›*) by auto show "?thesis" (*goal: ‹∃A. (∀x. x ∈# A ⟶ prime_elem x) ∧ normalize (∏⇩# A) = normalize a›*) proof (rule exI[of _ "A + B"] (*‹?P (A + B) ⟹ ∃x. ?P x›*); safe) (*goals: 1. ‹⋀x. x ∈# A + B ⟹ prime_elem x› 2. ‹normalize (∏⇩# (A + B)) = normalize a›*) have "normalize (prod_mset (A + B)) = normalize (normalize (prod_mset A) * normalize (prod_mset B))" by simp also (*calculation: ‹normalize (∏⇩# (A + B)) = normalize (normalize (∏⇩# A) * normalize (∏⇩# B))›*) have "… = normalize (b * c)" apply (simp only: A (*‹(∀x. x ∈# A ⟶ prime_elem x) ∧ normalize (∏⇩# A) = normalize b›*) B (*‹(∀x. x ∈# B ⟶ prime_elem x) ∧ normalize (∏⇩# B) = normalize c›*)) (*goal: ‹normalize (normalize (∏⇩# A) * normalize (∏⇩# B)) = normalize (b * c)›*) by auto also (*calculation: ‹normalize (∏⇩# ((A::'a multiset) + (B::'a multiset))) = normalize ((b::'a) * (c::'a))›*) have "b * c = a" using c (*‹(a::'a::type) = (b::'a::type) * (c::'a::type)›*) by simp finally (*calculation: ‹normalize (∏⇩# (A + B)) = normalize a›*) show "normalize (prod_mset (A + B)) = normalize a" . next (*goal: ‹⋀x. x ∈# A + B ⟹ prime_elem x›*) qed (use A B in auto) (*solved the remaining goal: ‹⋀x. x ∈# A + B ⟹ prime_elem x›*) qed qed qed lemma factorial_semiring_altI: assumes finite_divisors: "⋀x::'a. x ≠ 0 ⟹ finite {y. y dvd x ∧ normalize y = y}" assumes irreducible_imp_prime: "⋀x::'a. irreducible x ⟹ prime_elem x" shows "OFCLASS('a :: normalization_semidom, factorial_semiring_class)" apply intro_classes (*goal: ‹OFCLASS('a::normalization_semidom, factorial_semiring_class)›*) apply (rule factorial_semiring_altI_aux[OF assms] (*‹⟦⋀x. x ≠ 0 ⟹ x ≠ 0; ⋀x. irreducible x ⟹ irreducible x; ?x ≠ 0⟧ ⟹ ∃A. (∀x. x ∈# A ⟶ prime_elem x) ∧ normalize (∏⇩# A) = normalize ?x›*)) (*goals: 1. ‹⋀(x::'a) xa::'a. ⟦x ≠ (0::'a); xa ≠ (0::'a)⟧ ⟹ xa ≠ (0::'a)› 2. ‹⋀(x::'a) xa::'a. ⟦x ≠ (0::'a); irreducible xa⟧ ⟹ irreducible xa› 3. ‹⋀x::'a. x ≠ (0::'a) ⟹ x ≠ (0::'a)› discuss goal 1*) apply ((assumption)[1]) (*discuss goal 2*) apply ((assumption)[1]) (*discuss goal 3*) . (*proven 3 subgoals*) text ‹Properties› context factorial_semiring begin lemma prime_factorization_exists': assumes "x ≠ 0" obtains A where "⋀x. x ∈# A ⟹ prime x" "normalize (prod_mset A) = normalize x" proof (-) (*goal: ‹(⋀A::'a::type multiset. ⟦⋀x::'a::type. x ∈# A ⟹ prime x; normalize (∏⇩# A) = normalize (x::'a::type)⟧ ⟹ thesis::bool) ⟹ thesis›*) from prime_factorization_exists[OF assms] (*‹∃A. (∀x. x ∈# A ⟶ prime_elem x) ∧ normalize (∏⇩# A) = normalize x›*) obtain A where A: "⋀x. x ∈# A ⟹ prime_elem x" "normalize (prod_mset A) = normalize x" (*goal: ‹(⋀A. ⟦⋀x. x ∈# A ⟹ prime_elem x; normalize (∏⇩# A) = normalize x⟧ ⟹ thesis) ⟹ thesis›*) by blast define A' where "A' = image_mset normalize A" have "normalize (prod_mset A') = normalize (prod_mset A)" by (simp add: A'_def (*‹(A'::'a multiset) = image_mset normalize (A::'a multiset)›*) normalize_prod_mset_normalize (*‹normalize (∏⇩# (image_mset normalize (?A::'a multiset))) = normalize (∏⇩# ?A)›*)) also (*calculation: ‹normalize (∏⇩# A') = normalize (∏⇩# A)›*) note A(2) (*‹normalize (∏⇩# A) = normalize x›*) finally (*calculation: ‹normalize (∏⇩# A') = normalize x›*) have "normalize (prod_mset A') = normalize x" by simp moreover from A(1) (*‹?x1 ∈# A ⟹ prime_elem ?x1›*) have "∀x. x ∈# A' ⟶ prime x" by (auto simp: prime_def (*‹prime (?p::'a) = (prime_elem ?p ∧ normalize ?p = ?p)›*) A'_def (*‹(A'::'a multiset) = image_mset normalize (A::'a multiset)›*)) ultimately show "?thesis" (*goal: ‹thesis::bool›*) apply (intro that[of A'] (*‹⟦⋀x. x ∈# A' ⟹ prime x; normalize (∏⇩# A') = normalize x⟧ ⟹ thesis›*)) (*goals: 1. ‹⋀xa::'a::type. ⟦normalize (∏⇩# (A'::'a::type multiset)) = normalize (x::'a::type); ∀x::'a::type. x ∈# A' ⟶ prime x; xa ∈# A'⟧ ⟹ prime xa› 2. ‹⟦normalize (∏⇩# (A'::'a::type multiset)) = normalize (x::'a::type); ∀x::'a::type. x ∈# A' ⟶ prime x⟧ ⟹ normalize (∏⇩# A') = normalize x› discuss goal 1*) apply blast (*discuss goal 2*) . (*proven 2 subgoals*) qed lemma irreducible_imp_prime_elem: assumes "irreducible x" shows "prime_elem x" proof (rule prime_elemI (*‹⟦?p ≠ 0; ¬ is_unit ?p; ⋀a b. ?p dvd a * b ⟹ ?p dvd a ∨ ?p dvd b⟧ ⟹ prime_elem ?p›*)) (*goals: 1. ‹x ≠ 0› 2. ‹¬ is_unit x› 3. ‹⋀a b. x dvd a * b ⟹ x dvd a ∨ x dvd b›*) fix a and b assume dvd: "x dvd a * b" (*‹(x::'a) dvd (a::'a) * (b::'a)›*) from assms (*‹irreducible x›*) have "x ≠ 0" by auto show "x dvd a ∨ x dvd b" proof (cases "a = 0 ∨ b = 0") (*goals: 1. ‹(a::'a) = (0::'a) ∨ (b::'a) = (0::'a) ⟹ (x::'a) dvd a ∨ x dvd b› 2. ‹¬ ((a::'a) = (0::'a) ∨ (b::'a) = (0::'a)) ⟹ (x::'a) dvd a ∨ x dvd b›*) case False (*‹¬ ((a::'a::type) = (0::'a::type) ∨ (b::'a::type) = (0::'a::type))›*) hence "a ≠ 0" "b ≠ 0" apply - (*goals: 1. ‹¬ ((a::'a::type) = (0::'a::type) ∨ (b::'a::type) = (0::'a::type)) ⟹ a ≠ (0::'a::type)› 2. ‹¬ ((a::'a::type) = (0::'a::type) ∨ (b::'a::type) = (0::'a::type)) ⟹ b ≠ (0::'a::type)› discuss goal 1*) apply blast (*discuss goal 2*) apply blast (*proven 2 subgoals*) . note nz = ‹x ≠ 0› (*‹x ≠ 0›*) this (*‹a ≠ 0› ‹b ≠ 0›*) from nz[THEN prime_factorization_exists'] (*‹(⋀A. ⟦⋀x. x ∈# A ⟹ prime x; normalize (∏⇩# A) = normalize x⟧ ⟹ ?thesis) ⟹ ?thesis› ‹(⋀A. ⟦⋀x. x ∈# A ⟹ prime x; normalize (∏⇩# A) = normalize a⟧ ⟹ ?thesis) ⟹ ?thesis› ‹(⋀A::'a multiset. ⟦⋀x::'a. x ∈# A ⟹ prime x; normalize (∏⇩# A) = normalize (b::'a)⟧ ⟹ ?thesis::bool) ⟹ ?thesis›*) obtain A and B and C where ABC: "⋀z. z ∈# A ⟹ prime z" "normalize (∏⇩# A) = normalize x" "⋀z. z ∈# B ⟹ prime z" "normalize (∏⇩# B) = normalize a" "⋀z. z ∈# C ⟹ prime z" "normalize (∏⇩# C) = normalize b" (*goal: ‹(⋀(A::'a::type multiset) (B::'a::type multiset) C::'a::type multiset. ⟦⋀z::'a::type. z ∈# A ⟹ prime z; normalize (∏⇩# A) = normalize (x::'a::type); ⋀z::'a::type. z ∈# B ⟹ prime z; normalize (∏⇩# B) = normalize (a::'a::type); ⋀z::'a::type. z ∈# C ⟹ prime z; normalize (∏⇩# C) = normalize (b::'a::type)⟧ ⟹ thesis::bool) ⟹ thesis›*) apply this (*goal: ‹(⋀A B C. ⟦⋀z. z ∈# A ⟹ prime z; normalize (∏⇩# A) = normalize x; ⋀z. z ∈# B ⟹ prime z; normalize (∏⇩# B) = normalize a; ⋀z. z ∈# C ⟹ prime z; normalize (∏⇩# C) = normalize b⟧ ⟹ thesis) ⟹ thesis›*) by blast have "irreducible (prod_mset A)" apply (subst irreducible_cong[OF ABC(2)] (*‹irreducible (∏⇩# A) = irreducible x›*)) (*goal: ‹irreducible (∏⇩# (A::'a::type multiset))›*) by fact moreover have "normalize (prod_mset A) dvd normalize (normalize (prod_mset B) * normalize (prod_mset C))" unfolding ABC (*goal: ‹normalize x dvd normalize (normalize a * normalize b)›*) using dvd (*‹x dvd a * b›*) by simp hence "prod_mset A dvd prod_mset B * prod_mset C" unfolding normalize_mult_normalize_left normalize_mult_normalize_right (*goal: ‹∏⇩# A dvd ∏⇩# B * ∏⇩# C›*) by simp ultimately have "prod_mset A dvd prod_mset B ∨ prod_mset A dvd prod_mset C" apply (intro prod_mset_primes_irreducible_imp_prime (*‹⟦irreducible (∏⇩# ?A); ⋀x. x ∈# ?A ⟹ prime x; ⋀x. x ∈# ?B ⟹ prime x; ⋀x. x ∈# ?C ⟹ prime x; ∏⇩# ?A dvd ∏⇩# ?B * ∏⇩# ?C⟧ ⟹ ∏⇩# ?A dvd ∏⇩# ?B ∨ ∏⇩# ?A dvd ∏⇩# ?C›*)) (*goals: 1. ‹⟦irreducible (∏⇩# (A::'a multiset)); ∏⇩# A dvd ∏⇩# (B::'a multiset) * ∏⇩# (C::'a multiset)⟧ ⟹ irreducible (∏⇩# A)› 2. ‹⋀x::'a. ⟦irreducible (∏⇩# (A::'a multiset)); ∏⇩# A dvd ∏⇩# (B::'a multiset) * ∏⇩# (C::'a multiset); x ∈# A⟧ ⟹ prime x› 3. ‹⋀x::'a. ⟦irreducible (∏⇩# (A::'a multiset)); ∏⇩# A dvd ∏⇩# (B::'a multiset) * ∏⇩# (C::'a multiset); x ∈# B⟧ ⟹ prime x› 4. ‹⋀x::'a. ⟦irreducible (∏⇩# (A::'a multiset)); ∏⇩# A dvd ∏⇩# (B::'a multiset) * ∏⇩# (C::'a multiset); x ∈# C⟧ ⟹ prime x› 5. ‹⟦irreducible (∏⇩# (A::'a multiset)); ∏⇩# A dvd ∏⇩# (B::'a multiset) * ∏⇩# (C::'a multiset)⟧ ⟹ ∏⇩# A dvd ∏⇩# B * ∏⇩# C› discuss goal 1*) apply ((use ABC in auto)[1]) (*discuss goal 2*) apply ((use ABC in auto)[1]) (*discuss goal 3*) apply ((use ABC in auto)[1]) (*discuss goal 4*) apply ((use ABC in auto)[1]) (*discuss goal 5*) apply ((use ABC in auto)[1]) (*proven 5 subgoals*) . hence "normalize (prod_mset A) dvd normalize (prod_mset B) ∨ normalize (prod_mset A) dvd normalize (prod_mset C)" by simp thus "?thesis" (*goal: ‹x dvd a ∨ x dvd b›*) unfolding ABC (*goal: ‹x dvd a ∨ x dvd b›*) by simp qed (auto) (*solved the remaining goal: ‹a = 0 ∨ b = 0 ⟹ x dvd a ∨ x dvd b›*) qed (use assms in ‹simp_all add: irreducible_def›) (*solves the remaining goals: 1. ‹x ≠ 0› 2. ‹¬ is_unit x›*) lemma finite_divisor_powers: assumes "y ≠ 0" "¬is_unit x" shows "finite {n. x ^ n dvd y}" proof (cases "x = 0") (*goals: 1. ‹x = 0 ⟹ finite {n. x ^ n dvd y}› 2. ‹x ≠ 0 ⟹ finite {n. x ^ n dvd y}›*) case True (*‹(x::'a::type) = (0::'a::type)›*) with assms (*‹(y::'a::type) ≠ (0::'a::type)› ‹¬ is_unit x›*) have "{n. x ^ n dvd y} = {0}" by (auto simp: power_0_left (*‹(0::'a) ^ (?n::nat) = (if ?n = (0::nat) then 1::'a else (0::'a))›*)) thus "?thesis" (*goal: ‹finite {n::nat. (x::'a) ^ n dvd (y::'a)}›*) by simp next (*goal: ‹x ≠ 0 ⟹ finite {n. x ^ n dvd y}›*) case False (*‹x ≠ 0›*) note nz = this (*‹x ≠ 0›*) ‹y ≠ 0› (*‹y ≠ 0›*) from nz[THEN prime_factorization_exists'] (*‹(⋀A. ⟦⋀x. x ∈# A ⟹ prime x; normalize (∏⇩# A) = normalize x⟧ ⟹ ?thesis) ⟹ ?thesis› ‹(⋀A. ⟦⋀x. x ∈# A ⟹ prime x; normalize (∏⇩# A) = normalize y⟧ ⟹ ?thesis) ⟹ ?thesis›*) obtain A and B where AB: "⋀z. z ∈# A ⟹ prime z" "normalize (∏⇩# A) = normalize x" "⋀z. z ∈# B ⟹ prime z" "normalize (∏⇩# B) = normalize y" (*goal: ‹(⋀A B. ⟦⋀z. z ∈# A ⟹ prime z; normalize (∏⇩# A) = normalize x; ⋀z. z ∈# B ⟹ prime z; normalize (∏⇩# B) = normalize y⟧ ⟹ thesis) ⟹ thesis›*) apply this (*goal: ‹(⋀A B. ⟦⋀z. z ∈# A ⟹ prime z; normalize (∏⇩# A) = normalize x; ⋀z. z ∈# B ⟹ prime z; normalize (∏⇩# B) = normalize y⟧ ⟹ thesis) ⟹ thesis›*) by blast from AB (*‹?z1 ∈# A ⟹ prime ?z1› ‹normalize (∏⇩# A) = normalize x› ‹?z1 ∈# B ⟹ prime ?z1› ‹normalize (∏⇩# B) = normalize y›*) assms (*‹(y::'a) ≠ (0::'a)› ‹¬ is_unit x›*) have "A ≠ {#}" by (auto simp: normalize_1_iff (*‹(normalize ?a = 1) = is_unit ?a›*)) from AB(2,4) (*‹normalize (∏⇩# A) = normalize x› ‹normalize (∏⇩# (B::'a multiset)) = normalize (y::'a)›*) prod_mset_primes_finite_divisor_powers[of A B, OF AB ( 1 , 3 ) this] (*‹⟦⋀x. x ∈# A ⟹ x ∈# A; ⋀x. x ∈# B ⟹ x ∈# B⟧ ⟹ finite {n. ∏⇩# A ^ n dvd ∏⇩# B}›*) have "finite {n. prod_mset A ^ n dvd prod_mset B}" by simp also (*calculation: ‹finite {n. ∏⇩# A ^ n dvd ∏⇩# B}›*) have "{n. prod_mset A ^ n dvd prod_mset B} = {n. normalize (normalize (prod_mset A) ^ n) dvd normalize (prod_mset B)}" unfolding normalize_power_normalize (*goal: ‹{n::nat. ∏⇩# (A::'a multiset) ^ n dvd ∏⇩# (B::'a multiset)} = {n::nat. normalize (∏⇩# A ^ n) dvd normalize (∏⇩# B)}›*) by simp also (*calculation: ‹finite {n. normalize (normalize (∏⇩# A) ^ n) dvd normalize (∏⇩# B)}›*) have "… = {n. x ^ n dvd y}" unfolding AB (*goal: ‹{n. normalize (normalize x ^ n) dvd normalize y} = {n. x ^ n dvd y}›*) unfolding normalize_power_normalize (*goal: ‹{n. normalize (x ^ n) dvd normalize y} = {n. x ^ n dvd y}›*) by simp finally (*calculation: ‹finite {n. x ^ n dvd y}›*) show "?thesis" (*goal: ‹finite {n. x ^ n dvd y}›*) . qed lemma finite_prime_divisors: assumes "x ≠ 0" shows "finite {p. prime p ∧ p dvd x}" proof (-) (*goal: ‹finite {p. prime p ∧ p dvd x}›*) from prime_factorization_exists'[OF assms] (*‹(⋀A. ⟦⋀x. x ∈# A ⟹ prime x; normalize (∏⇩# A) = normalize x⟧ ⟹ ?thesis) ⟹ ?thesis›*) obtain A where A: "⋀z. z ∈# A ⟹ prime z" "normalize (∏⇩# A) = normalize x" (*goal: ‹(⋀A. ⟦⋀z. z ∈# A ⟹ prime z; normalize (∏⇩# A) = normalize x⟧ ⟹ thesis) ⟹ thesis›*) apply this (*goal: ‹(⋀A. ⟦⋀z. z ∈# A ⟹ prime z; normalize (∏⇩# A) = normalize x⟧ ⟹ thesis) ⟹ thesis›*) by blast have "{p. prime p ∧ p dvd x} ⊆ set_mset A" proof (safe) (*goal: ‹⋀xa. ⟦prime xa; xa dvd x⟧ ⟹ xa ∈# A›*) fix p assume p: "prime p" and dvd: "p dvd x" (*‹prime (p::'a)› ‹(p::'a) dvd (x::'a)›*) from dvd (*‹p dvd x›*) have "p dvd normalize x" by simp also (*calculation: ‹(p::'a) dvd normalize (x::'a)›*) from A (*‹?z1 ∈# A ⟹ prime ?z1› ‹normalize (∏⇩# A) = normalize x›*) have "normalize x = normalize (prod_mset A)" by simp finally (*calculation: ‹p dvd normalize (∏⇩# A)›*) have "p dvd prod_mset A" by simp thus "p ∈# A" using p (*‹prime p›*) A (*‹?z1 ∈# A ⟹ prime ?z1› ‹normalize (∏⇩# A) = normalize x›*) apply (subst (asm) prime_dvd_prod_mset_primes_iff (*‹⟦prime ?p; ⋀q. q ∈# ?A ⟹ prime q⟧ ⟹ (?p dvd ∏⇩# ?A) = (?p ∈# ?A)›*)) (*goals: 1. ‹⟦prime p; ⋀z. z ∈# A ⟹ prime z; normalize (∏⇩# A) = normalize x⟧ ⟹ prime p› 2. ‹⋀q. ⟦prime p; ⋀z. z ∈# A ⟹ prime z; normalize (∏⇩# A) = normalize x; q ∈# A⟧ ⟹ prime q› 3. ‹⟦p ∈# A; prime p; ⋀z. z ∈# A ⟹ prime z; normalize (∏⇩# A) = normalize x⟧ ⟹ p ∈# A› discuss goal 1*) apply ((assumption)[1]) (*discuss goal 2*) apply ((assumption)[1]) (*discuss goal 3*) . (*proven 3 subgoals*) qed moreover have "finite (set_mset A)" by simp ultimately show "?thesis" (*goal: ‹finite {p::'a::type. prime p ∧ p dvd (x::'a::type)}›*) by (rule finite_subset (*‹⟦?A ⊆ ?B; finite ?B⟧ ⟹ finite ?A›*)) qed lemma infinite_unit_divisor_powers: assumes "y ≠ 0" assumes "is_unit x" shows "infinite {n. x^n dvd y}" proof (-) (*goal: ‹infinite {n::nat. (x::'a::type) ^ n dvd (y::'a::type)}›*) from ‹is_unit x› (*‹is_unit x›*) have "is_unit (x^n)" for n using is_unit_power_iff (*‹is_unit (?a ^ ?n) = (is_unit ?a ∨ ?n = 0)›*) by auto hence "x^n dvd y" for n by auto hence "{n. x^n dvd y} = UNIV" by auto thus "?thesis" (*goal: ‹infinite {n. x ^ n dvd y}›*) by auto qed corollary is_unit_iff_infinite_divisor_powers: assumes "y ≠ 0" shows "is_unit x ⟷ infinite {n. x^n dvd y}" using infinite_unit_divisor_powers (*‹⟦?y ≠ 0; is_unit ?x⟧ ⟹ infinite {n. ?x ^ n dvd ?y}›*) finite_divisor_powers (*‹⟦?y ≠ 0; ¬ is_unit ?x⟧ ⟹ finite {n. ?x ^ n dvd ?y}›*) assms (*‹y ≠ 0›*) by auto lemma prime_elem_iff_irreducible: "prime_elem x ⟷ irreducible x" by (blast intro: irreducible_imp_prime_elem (*‹irreducible ?x ⟹ prime_elem ?x›*) prime_elem_imp_irreducible (*‹prime_elem ?p ⟹ irreducible ?p›*)) lemma prime_divisor_exists: assumes "a ≠ 0" "¬is_unit a" shows "∃b. b dvd a ∧ prime b" proof (-) (*goal: ‹∃b::'a. b dvd (a::'a) ∧ prime b›*) from prime_factorization_exists'[OF assms ( 1 )] (*‹(⋀A::'a multiset. ⟦⋀x::'a. x ∈# A ⟹ prime x; normalize (∏⇩# A) = normalize (a::'a)⟧ ⟹ ?thesis::bool) ⟹ ?thesis›*) obtain A where A: "⋀z. z ∈# A ⟹ prime z" "normalize (∏⇩# A) = normalize a" (*goal: ‹(⋀A. ⟦⋀z. z ∈# A ⟹ prime z; normalize (∏⇩# A) = normalize a⟧ ⟹ thesis) ⟹ thesis›*) apply this (*goal: ‹(⋀A. ⟦⋀z. z ∈# A ⟹ prime z; normalize (∏⇩# A) = normalize a⟧ ⟹ thesis) ⟹ thesis›*) by blast with assms (*‹a ≠ 0› ‹¬ is_unit a›*) have "A ≠ {#}" by auto then obtain x where "x ∈# A" (*goal: ‹(⋀x. x ∈# A ⟹ thesis) ⟹ thesis›*) by blast with A(1) (*‹?z1 ∈# A ⟹ prime ?z1›*) have "*": "x dvd normalize (prod_mset A)" "prime x" apply - (*goals: 1. ‹⟦⋀z::'a. z ∈# (A::'a multiset) ⟹ prime z; (x::'a) ∈# A⟧ ⟹ x dvd normalize (∏⇩# A)› 2. ‹⟦⋀z::'a. z ∈# (A::'a multiset) ⟹ prime z; (x::'a) ∈# A⟧ ⟹ prime x› discuss goal 1*) apply ((auto simp: dvd_prod_mset (*‹?x ∈# ?A ⟹ ?x dvd ∏⇩# ?A›*))[1]) (*discuss goal 2*) apply ((auto simp: dvd_prod_mset (*‹?x ∈# ?A ⟹ ?x dvd ∏⇩# ?A›*))[1]) (*proven 2 subgoals*) . hence "x dvd a" by (simp add: A( (*‹normalize (∏⇩# A) = normalize a›*) 2)) with "*" (*‹x dvd normalize (∏⇩# A)› ‹prime x›*) show "?thesis" (*goal: ‹∃b. b dvd a ∧ prime b›*) by blast qed lemma prime_divisors_induct [case_names zero unit factor]: assumes "P 0" "⋀x. is_unit x ⟹ P x" "⋀p x. prime p ⟹ P x ⟹ P (p * x)" shows "P x" proof (cases "x = 0") (*goals: 1. ‹x = 0 ⟹ P x› 2. ‹x ≠ 0 ⟹ P x›*) case False (*‹x ≠ 0›*) from prime_factorization_exists'[OF this] (*‹(⋀A. ⟦⋀x. x ∈# A ⟹ prime x; normalize (∏⇩# A) = normalize x⟧ ⟹ ?thesis) ⟹ ?thesis›*) obtain A where A: "⋀z. z ∈# A ⟹ prime z" "normalize (∏⇩# A) = normalize x" (*goal: ‹(⋀A::'a multiset. ⟦⋀z::'a. z ∈# A ⟹ prime z; normalize (∏⇩# A) = normalize (x::'a)⟧ ⟹ thesis::bool) ⟹ thesis›*) apply this (*goal: ‹(⋀A. ⟦⋀z. z ∈# A ⟹ prime z; normalize (∏⇩# A) = normalize x⟧ ⟹ thesis) ⟹ thesis›*) by blast from A (*‹?z1 ∈# A ⟹ prime ?z1› ‹normalize (∏⇩# A) = normalize x›*) obtain u where u: "is_unit u" "x = u * prod_mset A" (*goal: ‹(⋀u. ⟦is_unit u; x = u * ∏⇩# A⟧ ⟹ thesis) ⟹ thesis›*) by (elim associatedE2 (*‹⟦normalize (?a::'a::type) = normalize (?b::'a::type); ⋀u::'a::type. ⟦is_unit u; ?b = u * ?a⟧ ⟹ ?thesis::bool⟧ ⟹ ?thesis›*)) from A(1) (*‹?z1 ∈# A ⟹ prime ?z1›*) have "P (u * prod_mset A)" proof (induction A) (*goals: 1. ‹(⋀z. z ∈# {#} ⟹ prime z) ⟹ P (u * ∏⇩# {#})› 2. ‹⋀x A. ⟦(⋀z. z ∈# A ⟹ prime z) ⟹ P (u * ∏⇩# A); ⋀z. z ∈# add_mset x A ⟹ prime z⟧ ⟹ P (u * ∏⇩# (add_mset x A))›*) case (add p A) (*‹(⋀z. z ∈# A ⟹ prime z) ⟹ P (u * ∏⇩# A)› ‹?z1 ∈# add_mset p A ⟹ prime ?z1›*) from add.prems (*‹?z1 ∈# add_mset p A ⟹ prime ?z1›*) have "prime p" by simp moreover from add.prems (*‹?z1 ∈# add_mset p A ⟹ prime ?z1›*) have "P (u * prod_mset A)" apply (intro add.IH (*‹(⋀z::'a::type. z ∈# (A::'a::type multiset) ⟹ prime z) ⟹ (P::'a::type ⇒ bool) ((u::'a::type) * ∏⇩# A)›*)) (*goal: ‹P (u * ∏⇩# A)›*) by simp ultimately have "P (p * (u * prod_mset A))" by (rule assms( (*‹⟦prime (?p1::'a); (P::'a ⇒ bool) (?x1::'a)⟧ ⟹ P (?p1 * ?x1)›*) 3)) thus "?case" (*goal: ‹P (u * ∏⇩# (add_mset p A))›*) by (simp add: mult_ac (*‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)›*)) qed (simp_all add: assms False u) (*solved the remaining goal: ‹(⋀z. z ∈# {#} ⟹ prime z) ⟹ P (u * ∏⇩# {#})›*) with A (*‹?z1 ∈# A ⟹ prime ?z1› ‹normalize (∏⇩# A) = normalize x›*) u (*‹is_unit (u::'a::type)› ‹x = u * ∏⇩# A›*) show "?thesis" (*goal: ‹P x›*) by simp qed (simp_all add: assms(1)) (*solved the remaining goal: ‹x = 0 ⟹ P x›*) lemma no_prime_divisors_imp_unit: assumes "a ≠ 0" "⋀b. b dvd a ⟹ normalize b = b ⟹ ¬ prime_elem b" shows "is_unit a" proof (rule ccontr (*‹(¬ ?P ⟹ False) ⟹ ?P›*)) (*goal: ‹¬ is_unit a ⟹ False›*) assume "¬is_unit a" (*‹¬ is_unit (a::'a)›*) from prime_divisor_exists[OF assms ( 1 ) this] (*‹∃b. b dvd a ∧ prime b›*) obtain b where "b dvd a" "prime b" (*goal: ‹(⋀b. ⟦b dvd a; prime b⟧ ⟹ thesis) ⟹ thesis›*) by auto with assms(2)[of b] (*‹⟦b dvd a; normalize b = b⟧ ⟹ ¬ prime_elem b›*) show False by (simp add: prime_def (*‹prime ?p = (prime_elem ?p ∧ normalize ?p = ?p)›*)) qed lemma prime_divisorE: assumes "a ≠ 0" and "¬ is_unit a" obtains p where "prime p" and "p dvd a" using assms (*‹a ≠ 0› ‹¬ is_unit a›*) no_prime_divisors_imp_unit (*‹⟦(?a::'a) ≠ (0::'a); ⋀b::'a. ⟦b dvd ?a; normalize b = b⟧ ⟹ ¬ prime_elem b⟧ ⟹ is_unit ?a›*) unfolding prime_def (*goal: ‹(⋀p. ⟦prime_elem p ∧ normalize p = p; p dvd a⟧ ⟹ thesis) ⟹ thesis›*) by blast definition multiplicity :: "'a ⇒ 'a ⇒ nat" where "multiplicity p x = (if finite {n. p ^ n dvd x} then Max {n. p ^ n dvd x} else 0)" lemma multiplicity_dvd: "p ^ multiplicity p x dvd x" proof (cases "finite {n. p ^ n dvd x}") (*goals: 1. ‹finite {n. p ^ n dvd x} ⟹ p ^ multiplicity p x dvd x› 2. ‹infinite {n. p ^ n dvd x} ⟹ p ^ multiplicity p x dvd x›*) case True (*‹finite {n. p ^ n dvd x}›*) hence "multiplicity p x = Max {n. p ^ n dvd x}" by (simp add: multiplicity_def (*‹multiplicity ?p ?x = (if finite {n. ?p ^ n dvd ?x} then Max {n. ?p ^ n dvd ?x} else 0)›*)) also (*calculation: ‹multiplicity p x = Max {n. p ^ n dvd x}›*) have "… ∈ {n. p ^ n dvd x}" apply (rule Max_in (*‹⟦finite ?A; ?A ≠ {}⟧ ⟹ Max ?A ∈ ?A›*)) (*goals: 1. ‹finite {n. p ^ n dvd x}› 2. ‹{n. p ^ n dvd x} ≠ {}› discuss goal 1*) apply ((auto intro!: True (*‹finite {n. p ^ n dvd x}›*) exI[of _ "0::nat"] (*‹?P 0 ⟹ ∃x. ?P x›*))[1]) (*discuss goal 2*) apply ((auto intro!: True (*‹finite {n::nat. (p::'a) ^ n dvd (x::'a)}›*) exI[of _ "0::nat"] (*‹(?P::nat ⇒ bool) (0::nat) ⟹ ∃x::nat. ?P x›*))[1]) (*proven 2 subgoals*) . finally (*calculation: ‹multiplicity p x ∈ {n. p ^ n dvd x}›*) show "?thesis" (*goal: ‹p ^ multiplicity p x dvd x›*) by simp qed (simp add: multiplicity_def (*‹multiplicity ?p ?x = (if finite {n. ?p ^ n dvd ?x} then Max {n. ?p ^ n dvd ?x} else 0)›*)) (*solved the remaining goal: ‹infinite {n. p ^ n dvd x} ⟹ p ^ multiplicity p x dvd x›*) lemma multiplicity_dvd': "n ≤ multiplicity p x ⟹ p ^ n dvd x" by (rule dvd_trans[OF le_imp_power_dvd multiplicity_dvd] (*‹?m2 ≤ multiplicity ?p1 ?c ⟹ ?p1 ^ ?m2 dvd ?c›*)) context fixes x p :: 'a assumes xp: "x ≠ 0" "¬is_unit p" begin lemma multiplicity_eq_Max: "multiplicity p x = Max {n. p ^ n dvd x}" using finite_divisor_powers[OF xp] (*‹finite {n. p ^ n dvd x}›*) by (simp add: multiplicity_def (*‹multiplicity ?p ?x = (if finite {n. ?p ^ n dvd ?x} then Max {n. ?p ^ n dvd ?x} else 0)›*)) lemma multiplicity_geI: assumes "p ^ n dvd x" shows "multiplicity p x ≥ n" proof (-) (*goal: ‹n ≤ multiplicity p x›*) from assms (*‹p ^ n dvd x›*) have "n ≤ Max {n. p ^ n dvd x}" apply (intro Max_ge (*‹⟦finite ?A; ?x ∈ ?A⟧ ⟹ ?x ≤ Max ?A›*) finite_divisor_powers (*‹⟦?y ≠ 0; ¬ is_unit ?x⟧ ⟹ finite {n. ?x ^ n dvd ?y}›*) xp (*‹x ≠ 0› ‹¬ is_unit p›*)) (*goal: ‹n ≤ Max {n. p ^ n dvd x}›*) by simp thus "?thesis" (*goal: ‹n ≤ multiplicity p x›*) by (subst multiplicity_eq_Max (*‹multiplicity (p::'a::type) (x::'a::type) = Max {n::nat. p ^ n dvd x}›*)) qed lemma multiplicity_lessI: assumes "¬p ^ n dvd x" shows "multiplicity p x < n" proof (rule ccontr (*‹(¬ ?P ⟹ False) ⟹ ?P›*)) (*goal: ‹¬ multiplicity p x < n ⟹ False›*) assume "¬(n > multiplicity p x)" (*‹¬ multiplicity (p::'a) (x::'a) < (n::nat)›*) hence "p ^ n dvd x" apply (intro multiplicity_dvd' (*‹?n ≤ multiplicity ?p ?x ⟹ ?p ^ ?n dvd ?x›*)) (*goal: ‹p ^ n dvd x›*) by simp with assms (*‹¬ p ^ n dvd x›*) show False by contradiction qed lemma power_dvd_iff_le_multiplicity: "p ^ n dvd x ⟷ n ≤ multiplicity p x" using multiplicity_geI[of n] (*‹p ^ n dvd x ⟹ n ≤ multiplicity p x›*) multiplicity_lessI[of n] (*‹¬ (p::'a) ^ (n::nat) dvd (x::'a) ⟹ multiplicity p x < n›*) apply (cases "p ^ n dvd x") (*goals: 1. ‹⟦p ^ n dvd x ⟹ n ≤ multiplicity p x; ¬ p ^ n dvd x ⟹ multiplicity p x < n; p ^ n dvd x⟧ ⟹ (p ^ n dvd x) = (n ≤ multiplicity p x)› 2. ‹⟦p ^ n dvd x ⟹ n ≤ multiplicity p x; ¬ p ^ n dvd x ⟹ multiplicity p x < n; ¬ p ^ n dvd x⟧ ⟹ (p ^ n dvd x) = (n ≤ multiplicity p x)› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . lemma multiplicity_eq_zero_iff: shows "multiplicity p x = 0 ⟷ ¬p dvd x" using power_dvd_iff_le_multiplicity[of 1] (*‹(p ^ 1 dvd x) = (1 ≤ multiplicity p x)›*) by auto lemma multiplicity_gt_zero_iff: shows "multiplicity p x > 0 ⟷ p dvd x" using power_dvd_iff_le_multiplicity[of 1] (*‹(p ^ 1 dvd x) = (1 ≤ multiplicity p x)›*) by auto lemma multiplicity_decompose: "¬p dvd (x div p ^ multiplicity p x)" proof (standard) (*goal: ‹p dvd x div p ^ multiplicity p x ⟹ False›*) assume "*": "p dvd x div p ^ multiplicity p x" (*‹(p::'a) dvd (x::'a) div p ^ multiplicity p x›*) have "x = x div p ^ multiplicity p x * (p ^ multiplicity p x)" using multiplicity_dvd[of p x] (*‹p ^ multiplicity p x dvd x›*) by simp also (*calculation: ‹x = x div p ^ multiplicity p x * p ^ multiplicity p x›*) from "*" (*‹(p::'a) dvd (x::'a) div p ^ multiplicity p x›*) have "x div p ^ multiplicity p x = (x div p ^ multiplicity p x div p) * p" by simp also (*calculation: ‹(x::'a::type) = x div (p::'a::type) ^ multiplicity p x div p * p * p ^ multiplicity p x›*) have "x div p ^ multiplicity p x div p * p * p ^ multiplicity p x = x div p ^ multiplicity p x div p * p ^ Suc (multiplicity p x)" by (simp add: mult_assoc (*‹?a * ?b * ?c = ?a * (?b * ?c)›*)) also (*calculation: ‹x = x div p ^ multiplicity p x div p * p ^ Suc (multiplicity p x)›*) have "p ^ Suc (multiplicity p x) dvd …" by (rule dvd_triv_right (*‹?a dvd ?b * ?a›*)) finally (*calculation: ‹p ^ Suc (multiplicity p x) dvd x›*) show False apply (subst (asm) power_dvd_iff_le_multiplicity (*‹((p::'a) ^ (?n::nat) dvd (x::'a)) = (?n ≤ multiplicity p x)›*)) (*goal: ‹False›*) by simp qed lemma multiplicity_decompose': obtains y where "x = p ^ multiplicity p x * y" "¬p dvd y" using that[of "x div p ^ multiplicity p x"] (*‹⟦x = p ^ multiplicity p x * (x div p ^ multiplicity p x); ¬ p dvd x div p ^ multiplicity p x⟧ ⟹ thesis›*) by (simp add: multiplicity_decompose (*‹¬ p dvd x div p ^ multiplicity p x›*) multiplicity_dvd (*‹?p ^ multiplicity ?p ?x dvd ?x›*)) end lemma multiplicity_zero [simp]: "multiplicity p 0 = 0" by (simp add: multiplicity_def (*‹multiplicity ?p ?x = (if finite {n. ?p ^ n dvd ?x} then Max {n. ?p ^ n dvd ?x} else 0)›*)) lemma prime_elem_multiplicity_eq_zero_iff: "prime_elem p ⟹ x ≠ 0 ⟹ multiplicity p x = 0 ⟷ ¬p dvd x" apply (rule multiplicity_eq_zero_iff (*‹⟦?x ≠ 0; ¬ is_unit ?p⟧ ⟹ (multiplicity ?p ?x = 0) = (¬ ?p dvd ?x)›*)) (*goals: 1. ‹⟦prime_elem (p::'a::type); (x::'a::type) ≠ (0::'a::type)⟧ ⟹ x ≠ (0::'a::type)› 2. ‹⟦prime_elem (p::'a::type); (x::'a::type) ≠ (0::'a::type)⟧ ⟹ ¬ is_unit p› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) . lemma prime_multiplicity_other: assumes "prime p" "prime q" "p ≠ q" shows "multiplicity p q = 0" using assms (*‹prime p› ‹prime q› ‹p ≠ q›*) apply (subst prime_elem_multiplicity_eq_zero_iff (*‹⟦prime_elem ?p; ?x ≠ 0⟧ ⟹ (multiplicity ?p ?x = 0) = (¬ ?p dvd ?x)›*)) (*goals: 1. ‹⟦prime p; prime q; p ≠ q⟧ ⟹ prime_elem p› 2. ‹⟦prime p; prime q; p ≠ q⟧ ⟹ q ≠ 0› 3. ‹⟦prime p; prime q; p ≠ q⟧ ⟹ ¬ p dvd q› discuss goal 1*) apply ((auto dest: primes_dvd_imp_eq (*‹⟦prime (?p::'a); prime (?q::'a); ?p dvd ?q⟧ ⟹ ?p = ?q›*))[1]) (*discuss goal 2*) apply ((auto dest: primes_dvd_imp_eq (*‹⟦prime ?p; prime ?q; ?p dvd ?q⟧ ⟹ ?p = ?q›*))[1]) (*discuss goal 3*) apply ((auto dest: primes_dvd_imp_eq (*‹⟦prime ?p; prime ?q; ?p dvd ?q⟧ ⟹ ?p = ?q›*))[1]) (*proven 3 subgoals*) . lemma prime_multiplicity_gt_zero_iff: "prime_elem p ⟹ x ≠ 0 ⟹ multiplicity p x > 0 ⟷ p dvd x" apply (rule multiplicity_gt_zero_iff (*‹⟦?x ≠ 0; ¬ is_unit ?p⟧ ⟹ (0 < multiplicity ?p ?x) = (?p dvd ?x)›*)) (*goals: 1. ‹⟦prime_elem p; x ≠ 0⟧ ⟹ x ≠ 0› 2. ‹⟦prime_elem p; x ≠ 0⟧ ⟹ ¬ is_unit p› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) . lemma multiplicity_unit_left: "is_unit p ⟹ multiplicity p x = 0" by (simp add: multiplicity_def (*‹multiplicity ?p ?x = (if finite {n. ?p ^ n dvd ?x} then Max {n. ?p ^ n dvd ?x} else 0)›*) is_unit_power_iff (*‹is_unit (?a ^ ?n) = (is_unit ?a ∨ ?n = 0)›*) unit_imp_dvd (*‹is_unit ?b ⟹ ?b dvd ?a›*)) lemma multiplicity_unit_right: assumes "is_unit x" shows "multiplicity p x = 0" proof (cases "is_unit p ∨ x = 0") (*goals: 1. ‹is_unit p ∨ x = 0 ⟹ multiplicity p x = 0› 2. ‹¬ (is_unit p ∨ x = 0) ⟹ multiplicity p x = 0›*) case False (*‹¬ (is_unit p ∨ x = 0)›*) with multiplicity_lessI[of x p 1] (*‹⟦x ≠ 0; ¬ is_unit p; ¬ p ^ 1 dvd x⟧ ⟹ multiplicity p x < 1›*) this (*‹¬ (is_unit (p::'a) ∨ (x::'a) = (0::'a))›*) assms (*‹is_unit x›*) show "?thesis" (*goal: ‹multiplicity p x = 0›*) by (auto dest: dvd_unit_imp_unit (*‹⟦?a dvd ?b; is_unit ?b⟧ ⟹ is_unit ?a›*)) qed (auto simp: multiplicity_unit_left (*‹is_unit ?p ⟹ multiplicity ?p ?x = 0›*)) (*solved the remaining goal: ‹is_unit p ∨ x = 0 ⟹ multiplicity p x = 0›*) lemma multiplicity_one [simp]: "multiplicity p 1 = 0" apply (rule multiplicity_unit_right (*‹is_unit ?x ⟹ multiplicity ?p ?x = 0›*)) (*goal: ‹multiplicity p 1 = 0›*) by simp lemma multiplicity_eqI: assumes "p ^ n dvd x" "¬p ^ Suc n dvd x" shows "multiplicity p x = n" proof (-) (*goal: ‹multiplicity (p::'a) (x::'a) = (n::nat)›*) consider "x = 0" | "is_unit p" | "x ≠ 0" and "¬is_unit p" (*goal: ‹⟦x = 0 ⟹ thesis; is_unit p ⟹ thesis; ⟦x ≠ 0; ¬ is_unit p⟧ ⟹ thesis⟧ ⟹ thesis›*) by blast thus "?thesis" (*goal: ‹multiplicity p x = n›*) proof (cases) (*goals: 1. ‹(x::'a) = (0::'a) ⟹ multiplicity (p::'a) x = (n::nat)› 2. ‹is_unit (p::'a) ⟹ multiplicity p (x::'a) = (n::nat)› 3. ‹⟦(x::'a) ≠ (0::'a); ¬ is_unit (p::'a)⟧ ⟹ multiplicity p x = (n::nat)›*) assume xp: "x ≠ 0" "¬is_unit p" (*‹(x::'a) ≠ (0::'a)› ‹¬ is_unit (p::'a)›*) from xp (*‹x ≠ 0› ‹¬ is_unit p›*) assms(1) (*‹(p::'a) ^ (n::nat) dvd (x::'a)›*) have "multiplicity p x ≥ n" apply (intro multiplicity_geI (*‹⟦?x ≠ 0; ¬ is_unit ?p; ?p ^ ?n dvd ?x⟧ ⟹ ?n ≤ multiplicity ?p ?x›*)) (*goals: 1. ‹⟦x ≠ 0; ¬ is_unit p; p ^ n dvd x⟧ ⟹ x ≠ 0› 2. ‹⟦x ≠ 0; ¬ is_unit p; p ^ n dvd x⟧ ⟹ ¬ is_unit p› 3. ‹⟦x ≠ 0; ¬ is_unit p; p ^ n dvd x⟧ ⟹ p ^ n dvd x› discuss goal 1*) apply ((assumption)[1]) (*discuss goal 2*) apply ((assumption)[1]) (*discuss goal 3*) . (*proven 3 subgoals*) moreover from assms(2) (*‹¬ p ^ Suc n dvd x›*) xp (*‹x ≠ 0› ‹¬ is_unit (p::'a)›*) have "multiplicity p x < Suc n" apply (intro multiplicity_lessI (*‹⟦?x ≠ 0; ¬ is_unit ?p; ¬ ?p ^ ?n dvd ?x⟧ ⟹ multiplicity ?p ?x < ?n›*)) (*goals: 1. ‹⟦¬ (p::'a::type) ^ Suc (n::nat) dvd (x::'a::type); x ≠ (0::'a::type); ¬ is_unit p⟧ ⟹ x ≠ (0::'a::type)› 2. ‹⟦¬ (p::'a::type) ^ Suc (n::nat) dvd (x::'a::type); x ≠ (0::'a::type); ¬ is_unit p⟧ ⟹ ¬ is_unit p› 3. ‹⟦¬ (p::'a::type) ^ Suc (n::nat) dvd (x::'a::type); x ≠ (0::'a::type); ¬ is_unit p⟧ ⟹ ¬ p ^ Suc n dvd x› discuss goal 1*) apply ((assumption)[1]) (*discuss goal 2*) apply ((assumption)[1]) (*discuss goal 3*) . (*proven 3 subgoals*) ultimately show "?thesis" (*goal: ‹multiplicity (p::'a) (x::'a) = (n::nat)›*) by simp next (*goals: 1. ‹x = 0 ⟹ multiplicity p x = n› 2. ‹is_unit p ⟹ multiplicity p x = n›*) assume "is_unit p" (*‹is_unit (p::'a)›*) hence "is_unit (p ^ Suc n)" by (simp add: is_unit_power_iff (*‹is_unit (?a ^ ?n) = (is_unit ?a ∨ ?n = 0)›*) del: power_Suc (*‹?a ^ Suc ?n = ?a * ?a ^ ?n›*)) hence "p ^ Suc n dvd x" by (rule unit_imp_dvd (*‹is_unit ?b ⟹ ?b dvd ?a›*)) with ‹¬p ^ Suc n dvd x› (*‹¬ p ^ Suc n dvd x›*) show "?thesis" (*goal: ‹multiplicity p x = n›*) by contradiction qed (insert assms (*‹(p::'a::type) ^ (n::nat) dvd (x::'a::type)› ‹¬ (p::'a::type) ^ Suc (n::nat) dvd (x::'a::type)›*), simp_all) (*solved the remaining goal: ‹x = 0 ⟹ multiplicity p x = n›*) qed context fixes x p :: 'a assumes xp: "x ≠ 0" "¬is_unit p" begin lemma multiplicity_times_same: assumes "p ≠ 0" shows "multiplicity p (p * x) = Suc (multiplicity p x)" proof (rule multiplicity_eqI (*‹⟦(?p::'a::type) ^ (?n::nat) dvd (?x::'a::type); ¬ ?p ^ Suc ?n dvd ?x⟧ ⟹ multiplicity ?p ?x = ?n›*)) (*goals: 1. ‹p ^ Suc (multiplicity p x) dvd p * x› 2. ‹¬ p ^ Suc (Suc (multiplicity p x)) dvd p * x›*) show "p ^ Suc (multiplicity p x) dvd p * x" by (auto intro!: mult_dvd_mono (*‹⟦?a dvd ?b; ?c dvd ?d⟧ ⟹ ?a * ?c dvd ?b * ?d›*) multiplicity_dvd (*‹?p ^ multiplicity ?p ?x dvd ?x›*)) from xp (*‹x ≠ 0› ‹¬ is_unit (p::'a::type)›*) assms (*‹p ≠ 0›*) show "¬ p ^ Suc (Suc (multiplicity p x)) dvd p * x" using power_dvd_iff_le_multiplicity[OF xp, of "Suc (multiplicity p x)"] (*‹((p::'a) ^ Suc (multiplicity p (x::'a)) dvd x) = (Suc (multiplicity p x) ≤ multiplicity p x)›*) by simp qed end lemma multiplicity_same_power': "multiplicity p (p ^ n) = (if p = 0 ∨ is_unit p then 0 else n)" proof (-) (*goal: ‹multiplicity p (p ^ n) = (if p = 0 ∨ is_unit p then 0 else n)›*) consider "p = 0" | "is_unit p" | "p ≠ 0" and "¬is_unit p" (*goal: ‹⟦p = 0 ⟹ thesis; is_unit p ⟹ thesis; ⟦p ≠ 0; ¬ is_unit p⟧ ⟹ thesis⟧ ⟹ thesis›*) by blast thus "?thesis" (*goal: ‹multiplicity p (p ^ n) = (if p = 0 ∨ is_unit p then 0 else n)›*) proof (cases) (*goals: 1. ‹p = 0 ⟹ multiplicity p (p ^ n) = (if p = 0 ∨ is_unit p then 0 else n)› 2. ‹is_unit p ⟹ multiplicity p (p ^ n) = (if p = 0 ∨ is_unit p then 0 else n)› 3. ‹⟦p ≠ 0; ¬ is_unit p⟧ ⟹ multiplicity p (p ^ n) = (if p = 0 ∨ is_unit p then 0 else n)›*) assume "p ≠ 0" "¬is_unit p" (*‹(p::'a) ≠ (0::'a)› ‹¬ is_unit (p::'a)›*) thus "?thesis" (*goal: ‹multiplicity p (p ^ n) = (if p = 0 ∨ is_unit p then 0 else n)›*) apply (induction n) (*goals: 1. ‹⟦p ≠ 0; ¬ is_unit p⟧ ⟹ multiplicity p (p ^ 0) = (if p = 0 ∨ is_unit p then 0 else 0)› 2. ‹⋀n. ⟦⟦p ≠ 0; ¬ is_unit p⟧ ⟹ multiplicity p (p ^ n) = (if p = 0 ∨ is_unit p then 0 else n); p ≠ 0; ¬ is_unit p⟧ ⟹ multiplicity p (p ^ Suc n) = (if p = 0 ∨ is_unit p then 0 else Suc n)› discuss goal 1*) apply (simp add: multiplicity_times_same (*‹⟦?x ≠ 0; ¬ is_unit ?p; ?p ≠ 0⟧ ⟹ multiplicity ?p (?p * ?x) = Suc (multiplicity ?p ?x)›*)) (*discuss goal 2*) apply (simp add: multiplicity_times_same (*‹⟦?x ≠ 0; ¬ is_unit ?p; ?p ≠ 0⟧ ⟹ multiplicity ?p (?p * ?x) = Suc (multiplicity ?p ?x)›*)) (*proven 2 subgoals*) . qed (simp_all add: power_0_left multiplicity_unit_left) (*solves the remaining goals: 1. ‹p = 0 ⟹ multiplicity p (p ^ n) = (if p = 0 ∨ is_unit p then 0 else n)› 2. ‹is_unit p ⟹ multiplicity p (p ^ n) = (if p = 0 ∨ is_unit p then 0 else n)›*) qed lemma multiplicity_same_power: "p ≠ 0 ⟹ ¬is_unit p ⟹ multiplicity p (p ^ n) = n" by (simp add: multiplicity_same_power' (*‹multiplicity ?p (?p ^ ?n) = (if ?p = 0 ∨ is_unit ?p then 0 else ?n)›*)) lemma multiplicity_prime_elem_times_other: assumes "prime_elem p" "¬p dvd q" shows "multiplicity p (q * x) = multiplicity p x" proof (cases "x = 0") (*goals: 1. ‹x = 0 ⟹ multiplicity p (q * x) = multiplicity p x› 2. ‹x ≠ 0 ⟹ multiplicity p (q * x) = multiplicity p x›*) case False (*‹x ≠ 0›*) show "?thesis" (*goal: ‹multiplicity p (q * x) = multiplicity p x›*) proof (rule multiplicity_eqI (*‹⟦(?p::'a) ^ (?n::nat) dvd (?x::'a); ¬ ?p ^ Suc ?n dvd ?x⟧ ⟹ multiplicity ?p ?x = ?n›*)) (*goals: 1. ‹(p::'a::type) ^ multiplicity p (x::'a::type) dvd (q::'a::type) * x› 2. ‹¬ (p::'a::type) ^ Suc (multiplicity p (x::'a::type)) dvd (q::'a::type) * x›*) have "1 * p ^ multiplicity p x dvd q * x" apply (intro mult_dvd_mono (*‹⟦?a dvd ?b; ?c dvd ?d⟧ ⟹ ?a * ?c dvd ?b * ?d›*) multiplicity_dvd (*‹?p ^ multiplicity ?p ?x dvd ?x›*)) (*goal: ‹1 * p ^ multiplicity p x dvd q * x›*) by simp thus "p ^ multiplicity p x dvd q * x" by simp next (*goal: ‹¬ p ^ Suc (multiplicity p x) dvd q * x›*) define n where "n = multiplicity p x" from assms (*‹prime_elem p› ‹¬ p dvd q›*) have "¬is_unit p" by simp from multiplicity_decompose'[OF False this] (*‹(⋀y. ⟦x = p ^ multiplicity p x * y; ¬ p dvd y⟧ ⟹ ?thesis) ⟹ ?thesis›*) obtain y where y[folded n_def]: "x = p ^ multiplicity p x * y" "¬ p dvd y" (*goal: ‹(⋀y::'a::type. ⟦(x::'a::type) = (p::'a::type) ^ multiplicity p x * y; ¬ p dvd y⟧ ⟹ thesis::bool) ⟹ thesis›*) . from y (*‹x = p ^ n * y› ‹¬ p dvd y›*) have "p ^ Suc n dvd q * x ⟷ p ^ n * p dvd p ^ n * (q * y)" by (simp add: mult_ac (*‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)›*)) also (*calculation: ‹((p::'a::type) ^ Suc (n::nat) dvd (q::'a::type) * (x::'a::type)) = (p ^ n * p dvd p ^ n * (q * (y::'a::type)))›*) from assms (*‹prime_elem p› ‹¬ (p::'a) dvd (q::'a)›*) have "… ⟷ p dvd q * y" by simp also (*calculation: ‹(p ^ Suc n dvd q * x) = (p dvd q * y)›*) have "… ⟷ p dvd q ∨ p dvd y" apply (rule prime_elem_dvd_mult_iff (*‹prime_elem (?p::'a) ⟹ (?p dvd (?a::'a) * (?b::'a)) = (?p dvd ?a ∨ ?p dvd ?b)›*)) (*goal: ‹(p dvd q * y) = (p dvd q ∨ p dvd y)›*) by fact also (*calculation: ‹(p ^ Suc n dvd q * x) = (p dvd q ∨ p dvd y)›*) from assms (*‹prime_elem p› ‹¬ p dvd q›*) y (*‹(x::'a::type) = (p::'a::type) ^ (n::nat) * (y::'a::type)› ‹¬ (p::'a) dvd (y::'a)›*) have "… ⟷ False" by simp finally (*calculation: ‹(p ^ Suc n dvd q * x) = False›*) show "¬(p ^ Suc n dvd q * x)" by blast qed qed (simp_all) (*solved the remaining goal: ‹x = 0 ⟹ multiplicity p (q * x) = multiplicity p x›*) lemma multiplicity_self: assumes "p ≠ 0" "¬is_unit p" shows "multiplicity p p = 1" proof (-) (*goal: ‹multiplicity (p::'a::type) p = (1::nat)›*) from assms (*‹(p::'a) ≠ (0::'a)› ‹¬ is_unit p›*) have "multiplicity p p = Max {n. p ^ n dvd p}" by (simp add: multiplicity_eq_Max (*‹⟦?x ≠ 0; ¬ is_unit ?p⟧ ⟹ multiplicity ?p ?x = Max {n. ?p ^ n dvd ?x}›*)) also (*calculation: ‹multiplicity p p = Max {n. p ^ n dvd p}›*) from assms (*‹p ≠ 0› ‹¬ is_unit p›*) have "p ^ n dvd p ⟷ n ≤ 1" for n using dvd_power_iff[of p n 1] (*‹p ≠ 0 ⟹ (p ^ n dvd p ^ 1) = (is_unit p ∨ n ≤ 1)›*) by auto hence "{n. p ^ n dvd p} = {..1}" by auto also (*calculation: ‹multiplicity p p = Max {..1}›*) have "… = {0,1}" by auto finally (*calculation: ‹multiplicity (p::'a) p = Max {0::nat, 1::nat}›*) show "?thesis" (*goal: ‹multiplicity p p = 1›*) by simp qed lemma multiplicity_times_unit_left: assumes "is_unit c" shows "multiplicity (c * p) x = multiplicity p x" proof (-) (*goal: ‹multiplicity (c * p) x = multiplicity p x›*) from assms (*‹is_unit (c::'a::type)›*) have "{n. (c * p) ^ n dvd x} = {n. p ^ n dvd x}" apply (subst mult.commute (*‹(?a::'a) * (?b::'a) = ?b * ?a›*)) (*goal: ‹{n. (c * p) ^ n dvd x} = {n. p ^ n dvd x}›*) by (simp add: mult_unit_dvd_iff (*‹is_unit ?b ⟹ (?a * ?b dvd ?c) = (?a dvd ?c)›*) power_mult_distrib (*‹(?a * ?b) ^ ?n = ?a ^ ?n * ?b ^ ?n›*) is_unit_power_iff (*‹is_unit (?a ^ ?n) = (is_unit ?a ∨ ?n = 0)›*)) thus "?thesis" (*goal: ‹multiplicity (c * p) x = multiplicity p x›*) by (simp add: multiplicity_def (*‹multiplicity ?p ?x = (if finite {n. ?p ^ n dvd ?x} then Max {n. ?p ^ n dvd ?x} else 0)›*)) qed lemma multiplicity_times_unit_right: assumes "is_unit c" shows "multiplicity p (c * x) = multiplicity p x" proof (-) (*goal: ‹multiplicity p (c * x) = multiplicity p x›*) from assms (*‹is_unit c›*) have "{n. p ^ n dvd c * x} = {n. p ^ n dvd x}" apply (subst mult.commute (*‹?a * ?b = ?b * ?a›*)) (*goal: ‹{n::nat. (p::'a) ^ n dvd (c::'a) * (x::'a)} = {n::nat. p ^ n dvd x}›*) by (simp add: dvd_mult_unit_iff (*‹is_unit ?b ⟹ (?a dvd ?c * ?b) = (?a dvd ?c)›*)) thus "?thesis" (*goal: ‹multiplicity p (c * x) = multiplicity p x›*) by (simp add: multiplicity_def (*‹multiplicity ?p ?x = (if finite {n. ?p ^ n dvd ?x} then Max {n. ?p ^ n dvd ?x} else 0)›*)) qed lemma multiplicity_normalize_left [simp]: "multiplicity (normalize p) x = multiplicity p x" proof (cases "p = 0") (*goals: 1. ‹(p::'a) = (0::'a) ⟹ multiplicity (normalize p) (x::'a) = multiplicity p x› 2. ‹(p::'a) ≠ (0::'a) ⟹ multiplicity (normalize p) (x::'a) = multiplicity p x›*) case [simp]: False (*‹p ≠ 0›*) have "normalize p = (1 div unit_factor p) * p" by (simp add: unit_div_commute (*‹is_unit ?b ⟹ ?a div ?b * ?c = ?a * ?c div ?b›*) is_unit_unit_factor (*‹is_unit ?a ⟹ unit_factor ?a = ?a›*)) also (*calculation: ‹normalize p = 1 div unit_factor p * p›*) have "multiplicity … x = multiplicity p x" apply (rule multiplicity_times_unit_left (*‹is_unit (?c::'a) ⟹ multiplicity (?c * (?p::'a)) (?x::'a) = multiplicity ?p ?x›*)) (*goal: ‹multiplicity (1 div unit_factor p * p) x = multiplicity p x›*) by (simp add: is_unit_unit_factor (*‹is_unit ?a ⟹ unit_factor ?a = ?a›*)) finally (*calculation: ‹multiplicity (normalize p) x = multiplicity p x›*) show "?thesis" (*goal: ‹multiplicity (normalize p) x = multiplicity p x›*) . qed (simp_all) (*solved the remaining goal: ‹p = 0 ⟹ multiplicity (normalize p) x = multiplicity p x›*) lemma multiplicity_normalize_right [simp]: "multiplicity p (normalize x) = multiplicity p x" proof (cases "x = 0") (*goals: 1. ‹x = 0 ⟹ multiplicity p (normalize x) = multiplicity p x› 2. ‹x ≠ 0 ⟹ multiplicity p (normalize x) = multiplicity p x›*) case [simp]: False (*‹(x::'a) ≠ (0::'a)›*) have "normalize x = (1 div unit_factor x) * x" by (simp add: unit_div_commute (*‹is_unit ?b ⟹ ?a div ?b * ?c = ?a * ?c div ?b›*) is_unit_unit_factor (*‹is_unit ?a ⟹ unit_factor ?a = ?a›*)) also (*calculation: ‹normalize (x::'a) = (1::'a) div unit_factor x * x›*) have "multiplicity p … = multiplicity p x" apply (rule multiplicity_times_unit_right (*‹is_unit ?c ⟹ multiplicity ?p (?c * ?x) = multiplicity ?p ?x›*)) (*goal: ‹multiplicity (p::'a) ((1::'a) div unit_factor (x::'a) * x) = multiplicity p x›*) by (simp add: is_unit_unit_factor (*‹is_unit ?a ⟹ unit_factor ?a = ?a›*)) finally (*calculation: ‹multiplicity p (normalize x) = multiplicity p x›*) show "?thesis" (*goal: ‹multiplicity p (normalize x) = multiplicity p x›*) . qed (simp_all) (*solved the remaining goal: ‹x = 0 ⟹ multiplicity p (normalize x) = multiplicity p x›*) lemma multiplicity_prime [simp]: "prime_elem p ⟹ multiplicity p p = 1" apply (rule multiplicity_self (*‹⟦?p ≠ 0; ¬ is_unit ?p⟧ ⟹ multiplicity ?p ?p = 1›*)) (*goals: 1. ‹prime_elem p ⟹ p ≠ 0› 2. ‹prime_elem p ⟹ ¬ is_unit p› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . lemma multiplicity_prime_power [simp]: "prime_elem p ⟹ multiplicity p (p ^ n) = n" apply (subst multiplicity_same_power' (*‹multiplicity ?p (?p ^ ?n) = (if ?p = 0 ∨ is_unit ?p then 0 else ?n)›*)) (*goal: ‹prime_elem p ⟹ multiplicity p (p ^ n) = n›*) by auto lift_definition prime_factorization :: "'a ⇒ 'a multiset" is "λx p. if prime p then multiplicity p x else 0" proof - fix x :: 'a show "finite {p. 0 < (if prime p then multiplicity p x else 0)}" (is "finite ?A") proof (cases "x = 0") case False from False have "?A ⊆ {p. prime p ∧ p dvd x}" by (auto simp: multiplicity_gt_zero_iff) moreover from False have "finite {p. prime p ∧ p dvd x}" by (rule finite_prime_divisors) ultimately show ?thesis by (rule finite_subset) qed simp_all qed abbreviation prime_factors :: "'a ⇒ 'a set" where "prime_factors a ≡ set_mset (prime_factorization a)" lemma count_prime_factorization_nonprime: "¬prime p ⟹ count (prime_factorization x) p = 0" apply transfer (*goal: ‹¬ prime (p::'a) ⟹ count (prime_factorization (x::'a)) p = (0::nat)›*) by simp lemma count_prime_factorization_prime: "prime p ⟹ count (prime_factorization x) p = multiplicity p x" apply transfer (*goal: ‹prime p ⟹ count (prime_factorization x) p = multiplicity p x›*) by simp lemma count_prime_factorization: "count (prime_factorization x) p = (if prime p then multiplicity p x else 0)" apply transfer (*goal: ‹count (prime_factorization x) p = (if prime p then multiplicity p x else 0)›*) by simp lemma dvd_imp_multiplicity_le: assumes "a dvd b" "b ≠ 0" shows "multiplicity p a ≤ multiplicity p b" proof (cases "is_unit p") (*goals: 1. ‹is_unit (p::'a::type) ⟹ multiplicity p (a::'a::type) ≤ multiplicity p (b::'a::type)› 2. ‹¬ is_unit (p::'a::type) ⟹ multiplicity p (a::'a::type) ≤ multiplicity p (b::'a::type)›*) case False (*‹¬ is_unit p›*) with assms (*‹a dvd b› ‹(b::'a) ≠ (0::'a)›*) show "?thesis" (*goal: ‹multiplicity p a ≤ multiplicity p b›*) apply (intro multiplicity_geI (*‹⟦(?x::'a) ≠ (0::'a); ¬ is_unit (?p::'a); ?p ^ (?n::nat) dvd ?x⟧ ⟹ ?n ≤ multiplicity ?p ?x›*)) (*goals: 1. ‹⟦a dvd b; b ≠ 0; ¬ is_unit p⟧ ⟹ b ≠ 0› 2. ‹⟦a dvd b; b ≠ 0; ¬ is_unit p⟧ ⟹ ¬ is_unit p› 3. ‹⟦a dvd b; b ≠ 0; ¬ is_unit p⟧ ⟹ p ^ multiplicity p a dvd b› discuss goal 1*) apply ((auto intro: dvd_trans[OF multiplicity_dvd' assms(1)] (*‹?n1 ≤ multiplicity ?p1 a ⟹ ?p1 ^ ?n1 dvd b›*))[1]) (*discuss goal 2*) apply ((auto intro: dvd_trans[OF multiplicity_dvd' assms(1)] (*‹?n1 ≤ multiplicity ?p1 a ⟹ ?p1 ^ ?n1 dvd b›*))[1]) (*discuss goal 3*) apply ((auto intro: dvd_trans[OF multiplicity_dvd' assms(1)] (*‹?n1 ≤ multiplicity ?p1 a ⟹ ?p1 ^ ?n1 dvd b›*))[1]) (*proven 3 subgoals*) . qed (insert assms (*‹(a::'a::type) dvd (b::'a::type)› ‹(b::'a::type) ≠ (0::'a::type)›*), auto simp: multiplicity_unit_left (*‹is_unit ?p ⟹ multiplicity ?p ?x = 0›*)) (*solved the remaining goal: ‹is_unit p ⟹ multiplicity p a ≤ multiplicity p b›*) lemma prime_power_inj: assumes "prime a" "a ^ m = a ^ n" shows "m = n" proof (-) (*goal: ‹m = n›*) have "multiplicity a (a ^ m) = multiplicity a (a ^ n)" by (simp only: assms (*‹prime a› ‹a ^ m = a ^ n›*)) thus "?thesis" (*goal: ‹m = n›*) using assms (*‹prime (a::'a)› ‹a ^ m = a ^ n›*) apply (subst (asm) (1 2) multiplicity_prime_power (*‹prime_elem ?p ⟹ multiplicity ?p (?p ^ ?n) = ?n›*)) (*goals: 1. ‹⟦prime a; a ^ m = a ^ n⟧ ⟹ prime_elem a› 2. ‹⟦m = n; prime a; a ^ m = a ^ n⟧ ⟹ m = n› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) . qed lemma prime_power_inj': assumes "prime p" "prime q" assumes "p ^ m = q ^ n" "m > 0" "n > 0" shows "p = q" "m = n" proof (-) (*goals: 1. ‹p = q› 2. ‹m = n›*) from assms (*‹prime p› ‹prime q› ‹p ^ m = q ^ n› ‹0 < m› ‹(0::nat) < (n::nat)›*) have "p ^ 1 dvd p ^ m" apply (intro le_imp_power_dvd (*‹?m ≤ ?n ⟹ ?a ^ ?m dvd ?a ^ ?n›*)) (*goal: ‹p ^ 1 dvd p ^ m›*) by simp also (*calculation: ‹p ^ 1 dvd p ^ m›*) have "p ^ m = q ^ n" by fact finally (*calculation: ‹p ^ 1 dvd q ^ n›*) have "p dvd q ^ n" by simp with assms (*‹prime p› ‹prime q› ‹p ^ m = q ^ n› ‹(0::nat) < (m::nat)› ‹(0::nat) < (n::nat)›*) have "p dvd q" using prime_dvd_power[of p q] (*‹⟦prime (p::'a); p dvd (q::'a) ^ (?n::nat)⟧ ⟹ p dvd q›*) by simp with assms (*‹prime p› ‹prime q› ‹p ^ m = q ^ n› ‹0 < m› ‹0 < n›*) show "p = q" by (simp add: primes_dvd_imp_eq (*‹⟦prime ?p; prime ?q; ?p dvd ?q⟧ ⟹ ?p = ?q›*)) with assms (*‹prime p› ‹prime (q::'a)› ‹p ^ m = q ^ n› ‹(0::nat) < (m::nat)› ‹0 < n›*) show "m = n" by (simp add: prime_power_inj (*‹⟦prime ?a; ?a ^ ?m = ?a ^ ?n⟧ ⟹ ?m = ?n›*)) qed lemma prime_power_eq_one_iff [simp]: "prime p ⟹ p ^ n = 1 ⟷ n = 0" using prime_power_inj[of p n 0] (*‹⟦prime p; p ^ n = p ^ 0⟧ ⟹ n = 0›*) by auto lemma one_eq_prime_power_iff [simp]: "prime p ⟹ 1 = p ^ n ⟷ n = 0" using prime_power_inj[of p 0 n] (*‹⟦prime p; p ^ 0 = p ^ n⟧ ⟹ 0 = n›*) by auto lemma prime_power_inj'': assumes "prime p" "prime q" shows "p ^ m = q ^ n ⟷ (m = 0 ∧ n = 0) ∨ (p = q ∧ m = n)" using assms (*‹prime p› ‹prime q›*) apply (cases "m = 0") (*goals: 1. ‹⟦prime (p::'a::type); prime (q::'a::type); (m::nat) = (0::nat)⟧ ⟹ (p ^ m = q ^ (n::nat)) = (m = (0::nat) ∧ n = (0::nat) ∨ p = q ∧ m = n)› 2. ‹⟦prime (p::'a::type); prime (q::'a::type); (m::nat) ≠ (0::nat)⟧ ⟹ (p ^ m = q ^ (n::nat)) = (m = (0::nat) ∧ n = (0::nat) ∨ p = q ∧ m = n)› discuss goal 1*) apply (cases "n = 0") (*goals: 1. ‹⟦prime (p::'a); prime (q::'a); (m::nat) = (0::nat); (n::nat) = (0::nat)⟧ ⟹ (p ^ m = q ^ n) = (m = (0::nat) ∧ n = (0::nat) ∨ p = q ∧ m = n)› 2. ‹⟦prime (p::'a); prime (q::'a); (m::nat) = (0::nat); (n::nat) ≠ (0::nat)⟧ ⟹ (p ^ m = q ^ n) = (m = (0::nat) ∧ n = (0::nat) ∨ p = q ∧ m = n)› discuss goal 1*) apply ((auto dest: prime_power_inj'[OF assms] (*‹⟦(p::'a) ^ (?m::nat) = (q::'a) ^ (?n::nat); (0::nat) < ?m; (0::nat) < ?n⟧ ⟹ p = q› ‹⟦(p::'a) ^ (?m::nat) = (q::'a) ^ (?n::nat); (0::nat) < ?m; (0::nat) < ?n⟧ ⟹ ?m = ?n›*))[1]) (*discuss goal 2*) apply ((auto dest: prime_power_inj'[OF assms] (*‹⟦p ^ ?m = q ^ ?n; 0 < ?m; 0 < ?n⟧ ⟹ p = q› ‹⟦p ^ ?m = q ^ ?n; 0 < ?m; 0 < ?n⟧ ⟹ ?m = ?n›*))[1]) (*proven 2 subgoals*) (*discuss goal 2*) apply (cases "n = 0") (*goals: 1. ‹⟦prime p; prime q; m ≠ 0; n = 0⟧ ⟹ (p ^ m = q ^ n) = (m = 0 ∧ n = 0 ∨ p = q ∧ m = n)› 2. ‹⟦prime p; prime q; m ≠ 0; n ≠ 0⟧ ⟹ (p ^ m = q ^ n) = (m = 0 ∧ n = 0 ∨ p = q ∧ m = n)› discuss goal 1*) apply ((auto dest: prime_power_inj'[OF assms] (*‹⟦p ^ ?m = q ^ ?n; 0 < ?m; 0 < ?n⟧ ⟹ p = q› ‹⟦p ^ ?m = q ^ ?n; 0 < ?m; 0 < ?n⟧ ⟹ ?m = ?n›*))[1]) (*discuss goal 2*) apply ((auto dest: prime_power_inj'[OF assms] (*‹⟦p ^ ?m = q ^ ?n; 0 < ?m; 0 < ?n⟧ ⟹ p = q› ‹⟦p ^ ?m = q ^ ?n; 0 < ?m; 0 < ?n⟧ ⟹ ?m = ?n›*))[1]) (*proven 2 subgoals*) (*proven 2 subgoals*) . lemma prime_factorization_0 [simp]: "prime_factorization 0 = {#}" by (simp add: multiset_eq_iff (*‹(?M = ?N) = (∀a. count ?M a = count ?N a)›*) count_prime_factorization (*‹count (prime_factorization ?x) ?p = (if prime ?p then multiplicity ?p ?x else 0)›*)) lemma prime_factorization_empty_iff: "prime_factorization x = {#} ⟷ x = 0 ∨ is_unit x" proof (standard) (*goals: 1. ‹prime_factorization x = {#} ⟹ x = 0 ∨ is_unit x› 2. ‹x = 0 ∨ is_unit x ⟹ prime_factorization x = {#}›*) assume "*": "prime_factorization x = {#}" (*‹prime_factorization (x::'a) = {#}›*) { assume x: "x ≠ 0" "¬is_unit x" (*‹(x::'a) ≠ (0::'a)› ‹¬ is_unit (x::'a)›*) { fix p assume p: "prime p" (*‹prime (p::'a)›*) have "count (prime_factorization x) p = 0" by (simp add: * (*‹prime_factorization x = {#}›*)) also (*calculation: ‹count (prime_factorization x) p = 0›*) from p (*‹prime (p::'a)›*) have "count (prime_factorization x) p = multiplicity p x" by (rule count_prime_factorization_prime (*‹prime (?p::'a) ⟹ count (prime_factorization (?x::'a)) ?p = multiplicity ?p ?x›*)) also (*calculation: ‹multiplicity p x = 0›*) from x (*‹x ≠ 0› ‹¬ is_unit x›*) p (*‹prime p›*) have "… = 0 ⟷ ¬p dvd x" by (simp add: multiplicity_eq_zero_iff (*‹⟦?x ≠ 0; ¬ is_unit ?p⟧ ⟹ (multiplicity ?p ?x = 0) = (¬ ?p dvd ?x)›*)) finally (*calculation: ‹¬ (p::'a) dvd (x::'a)›*) have "¬p dvd x" . } with prime_divisor_exists[OF x] (*‹∃b. b dvd x ∧ prime b›*) have False by blast } thus "x = 0 ∨ is_unit x" by blast next (*goal: ‹x = 0 ∨ is_unit x ⟹ prime_factorization x = {#}›*) assume "x = 0 ∨ is_unit x" (*‹(x::'a) = (0::'a) ∨ is_unit x›*) thus "prime_factorization x = {#}" proof (standard) (*goals: 1. ‹x = 0 ⟹ prime_factorization x = {#}› 2. ‹is_unit x ⟹ prime_factorization x = {#}›*) assume x: "is_unit x" (*‹is_unit (x::'a)›*) { fix p assume p: "prime p" (*‹prime (p::'a)›*) from p (*‹prime p›*) x (*‹is_unit x›*) have "multiplicity p x = 0" apply (subst multiplicity_eq_zero_iff (*‹⟦?x ≠ 0; ¬ is_unit ?p⟧ ⟹ (multiplicity ?p ?x = 0) = (¬ ?p dvd ?x)›*)) (*goals: 1. ‹⟦prime p; is_unit x⟧ ⟹ x ≠ 0› 2. ‹⟦prime p; is_unit x⟧ ⟹ ¬ is_unit p› 3. ‹⟦prime p; is_unit x⟧ ⟹ ¬ p dvd x› discuss goal 1*) apply ((auto simp: multiplicity_eq_zero_iff (*‹⟦(?x::'a) ≠ (0::'a); ¬ is_unit (?p::'a)⟧ ⟹ (multiplicity ?p ?x = (0::nat)) = (¬ ?p dvd ?x)›*) dest: unit_imp_no_prime_divisors (*‹⟦is_unit (?x::'a); prime_elem (?p::'a)⟧ ⟹ ¬ ?p dvd ?x›*))[1]) (*discuss goal 2*) apply ((auto simp: multiplicity_eq_zero_iff (*‹⟦?x ≠ 0; ¬ is_unit ?p⟧ ⟹ (multiplicity ?p ?x = 0) = (¬ ?p dvd ?x)›*) dest: unit_imp_no_prime_divisors (*‹⟦is_unit ?x; prime_elem ?p⟧ ⟹ ¬ ?p dvd ?x›*))[1]) (*discuss goal 3*) apply ((auto simp: multiplicity_eq_zero_iff (*‹⟦?x ≠ 0; ¬ is_unit ?p⟧ ⟹ (multiplicity ?p ?x = 0) = (¬ ?p dvd ?x)›*) dest: unit_imp_no_prime_divisors (*‹⟦is_unit ?x; prime_elem ?p⟧ ⟹ ¬ ?p dvd ?x›*))[1]) (*proven 3 subgoals*) . } thus "?thesis" (*goal: ‹prime_factorization x = {#}›*) by (simp add: multiset_eq_iff (*‹(?M = ?N) = (∀a. count ?M a = count ?N a)›*) count_prime_factorization (*‹count (prime_factorization ?x) ?p = (if prime ?p then multiplicity ?p ?x else 0)›*)) qed (simp_all) (*solved the remaining goal: ‹x = 0 ⟹ prime_factorization x = {#}›*) qed lemma prime_factorization_unit: assumes "is_unit x" shows "prime_factorization x = {#}" proof (rule multiset_eqI (*‹(⋀x. count ?A x = count ?B x) ⟹ ?A = ?B›*)) (*goal: ‹⋀xa::'a::type. count (prime_factorization (x::'a::type)) xa = count {#} xa›*) fix p :: 'a show "count (prime_factorization x) p = count {#} p" proof (cases "prime p") (*goals: 1. ‹prime p ⟹ count (prime_factorization x) p = count {#} p› 2. ‹¬ prime p ⟹ count (prime_factorization x) p = count {#} p›*) case True (*‹prime p›*) with assms (*‹is_unit x›*) have "multiplicity p x = 0" apply (subst multiplicity_eq_zero_iff (*‹⟦?x ≠ 0; ¬ is_unit ?p⟧ ⟹ (multiplicity ?p ?x = 0) = (¬ ?p dvd ?x)›*)) (*goals: 1. ‹⟦is_unit (x::'a::type); prime (p::'a::type)⟧ ⟹ x ≠ (0::'a::type)› 2. ‹⟦is_unit (x::'a::type); prime (p::'a::type)⟧ ⟹ ¬ is_unit p› 3. ‹⟦is_unit (x::'a::type); prime (p::'a::type)⟧ ⟹ ¬ p dvd x› discuss goal 1*) apply ((auto simp: multiplicity_eq_zero_iff (*‹⟦?x ≠ 0; ¬ is_unit ?p⟧ ⟹ (multiplicity ?p ?x = 0) = (¬ ?p dvd ?x)›*) dest: unit_imp_no_prime_divisors (*‹⟦is_unit ?x; prime_elem ?p⟧ ⟹ ¬ ?p dvd ?x›*))[1]) (*discuss goal 2*) apply ((auto simp: multiplicity_eq_zero_iff (*‹⟦?x ≠ 0; ¬ is_unit ?p⟧ ⟹ (multiplicity ?p ?x = 0) = (¬ ?p dvd ?x)›*) dest: unit_imp_no_prime_divisors (*‹⟦is_unit ?x; prime_elem ?p⟧ ⟹ ¬ ?p dvd ?x›*))[1]) (*discuss goal 3*) apply ((auto simp: multiplicity_eq_zero_iff (*‹⟦?x ≠ 0; ¬ is_unit ?p⟧ ⟹ (multiplicity ?p ?x = 0) = (¬ ?p dvd ?x)›*) dest: unit_imp_no_prime_divisors (*‹⟦is_unit ?x; prime_elem ?p⟧ ⟹ ¬ ?p dvd ?x›*))[1]) (*proven 3 subgoals*) . with True (*‹prime p›*) show "?thesis" (*goal: ‹count (prime_factorization x) p = count {#} p›*) by (simp add: count_prime_factorization_prime (*‹prime (?p::'a::type) ⟹ count (prime_factorization (?x::'a::type)) ?p = multiplicity ?p ?x›*)) qed (simp_all add: count_prime_factorization_nonprime) (*solved the remaining goal: ‹¬ prime p ⟹ count (prime_factorization x) p = count {#} p›*) qed lemma prime_factorization_1 [simp]: "prime_factorization 1 = {#}" by (simp add: prime_factorization_unit (*‹is_unit ?x ⟹ prime_factorization ?x = {#}›*)) lemma prime_factorization_times_prime: assumes "x ≠ 0" "prime p" shows "prime_factorization (p * x) = {#p#} + prime_factorization x" proof (rule multiset_eqI (*‹(⋀x. count ?A x = count ?B x) ⟹ ?A = ?B›*)) (*goal: ‹⋀xa. count (prime_factorization (p * x)) xa = count ({#p#} + prime_factorization x) xa›*) fix q :: 'a consider "¬prime q" | "p = q" | "prime q" and "p ≠ q" (*goal: ‹⟦¬ prime q ⟹ thesis; p = q ⟹ thesis; ⟦prime q; p ≠ q⟧ ⟹ thesis⟧ ⟹ thesis›*) by blast thus "count (prime_factorization (p * x)) q = count ({#p#} + prime_factorization x) q" proof (cases) (*goals: 1. ‹¬ prime q ⟹ count (prime_factorization (p * x)) q = count ({#p#} + prime_factorization x) q› 2. ‹p = q ⟹ count (prime_factorization (p * x)) q = count ({#p#} + prime_factorization x) q› 3. ‹⟦prime q; p ≠ q⟧ ⟹ count (prime_factorization (p * x)) q = count ({#p#} + prime_factorization x) q›*) assume q: "prime q" "p ≠ q" (*‹prime (q::'a)› ‹(p::'a) ≠ (q::'a)›*) with assms (*‹x ≠ 0› ‹prime p›*) primes_dvd_imp_eq[of q p] (*‹⟦prime (q::'a); prime (p::'a); q dvd p⟧ ⟹ q = p›*) have "¬q dvd p" by auto with q (*‹prime q› ‹(p::'a) ≠ (q::'a)›*) assms (*‹x ≠ 0› ‹prime p›*) show "?thesis" (*goal: ‹count (prime_factorization (p * x)) q = count ({#p#} + prime_factorization x) q›*) by (simp add: multiplicity_prime_elem_times_other (*‹⟦prime_elem ?p; ¬ ?p dvd ?q⟧ ⟹ multiplicity ?p (?q * ?x) = multiplicity ?p ?x›*) count_prime_factorization (*‹count (prime_factorization ?x) ?p = (if prime ?p then multiplicity ?p ?x else 0)›*)) qed (insert assms (*‹x ≠ 0› ‹prime p›*), auto simp: count_prime_factorization (*‹count (prime_factorization (?x::'a)) (?p::'a) = (if prime ?p then multiplicity ?p ?x else (0::nat))›*) multiplicity_times_same (*‹⟦(?x::'a) ≠ (0::'a); ¬ is_unit (?p::'a); ?p ≠ (0::'a)⟧ ⟹ multiplicity ?p (?p * ?x) = Suc (multiplicity ?p ?x)›*)) (*solves the remaining goals: 1. ‹¬ prime q ⟹ count (prime_factorization (p * x)) q = count ({#p#} + prime_factorization x) q› 2. ‹p = q ⟹ count (prime_factorization (p * x)) q = count ({#p#} + prime_factorization x) q›*) qed lemma prod_mset_prime_factorization_weak: assumes "x ≠ 0" shows "normalize (prod_mset (prime_factorization x)) = normalize x" using assms (*‹x ≠ 0›*) proof (induction x rule: prime_divisors_induct (*‹⟦?P 0; ⋀x. is_unit x ⟹ ?P x; ⋀p x. ⟦prime p; ?P x⟧ ⟹ ?P (p * x)⟧ ⟹ ?P ?x›*)) (*goals: 1. ‹0 ≠ 0 ⟹ normalize (∏⇩# (prime_factorization 0)) = normalize 0› 2. ‹⋀x. ⟦is_unit x; x ≠ 0⟧ ⟹ normalize (∏⇩# (prime_factorization x)) = normalize x› 3. ‹⋀p x. ⟦prime p; x ≠ 0 ⟹ normalize (∏⇩# (prime_factorization x)) = normalize x; p * x ≠ 0⟧ ⟹ normalize (∏⇩# (prime_factorization (p * x))) = normalize (p * x)›*) case (factor p x) (*‹prime p› ‹x ≠ 0 ⟹ normalize (∏⇩# (prime_factorization x)) = normalize x› ‹p * x ≠ 0›*) have "normalize (prod_mset (prime_factorization (p * x))) = normalize (p * normalize (prod_mset (prime_factorization x)))" using factor.prems (*‹p * x ≠ 0›*) factor.hyps (*‹prime p›*) by (simp add: prime_factorization_times_prime (*‹⟦?x ≠ 0; prime ?p⟧ ⟹ prime_factorization (?p * ?x) = {#?p#} + prime_factorization ?x›*)) also (*calculation: ‹normalize (∏⇩# (prime_factorization (p * x))) = normalize (p * normalize (∏⇩# (prime_factorization x)))›*) have "normalize (prod_mset (prime_factorization x)) = normalize x" apply (rule factor.IH (*‹x ≠ 0 ⟹ normalize (∏⇩# (prime_factorization x)) = normalize x›*)) (*goal: ‹normalize (∏⇩# (prime_factorization x)) = normalize x›*) by (use factor in auto) finally (*calculation: ‹normalize (∏⇩# (prime_factorization (p * x))) = normalize (p * normalize x)›*) show "?case" (*goal: ‹normalize (∏⇩# (prime_factorization (p * x))) = normalize (p * x)›*) by simp qed (auto simp: prime_factorization_unit (*‹is_unit (?x::'a::type) ⟹ prime_factorization ?x = {#}›*) is_unit_normalize (*‹is_unit (?a::'a::type) ⟹ normalize ?a = (1::'a::type)›*)) (*solves the remaining goals: 1. ‹0 ≠ 0 ⟹ normalize (∏⇩# (prime_factorization 0)) = normalize 0› 2. ‹⋀x. ⟦is_unit x; x ≠ 0⟧ ⟹ normalize (∏⇩# (prime_factorization x)) = normalize x›*) lemma in_prime_factors_iff: "p ∈ prime_factors x ⟷ x ≠ 0 ∧ p dvd x ∧ prime p" proof (-) (*goal: ‹(p ∈ prime_factors x) = (x ≠ 0 ∧ p dvd x ∧ prime p)›*) have "p ∈ prime_factors x ⟷ count (prime_factorization x) p > 0" by simp also (*calculation: ‹(p ∈ prime_factors x) = (0 < count (prime_factorization x) p)›*) have "… ⟷ x ≠ 0 ∧ p dvd x ∧ prime p" apply (subst count_prime_factorization (*‹count (prime_factorization ?x) ?p = (if prime ?p then multiplicity ?p ?x else 0)›*)) (*goal: ‹(0 < count (prime_factorization x) p) = (x ≠ 0 ∧ p dvd x ∧ prime p)›*) apply (cases "x = 0") (*goals: 1. ‹x = 0 ⟹ (0 < (if prime p then multiplicity p x else 0)) = (x ≠ 0 ∧ p dvd x ∧ prime p)› 2. ‹x ≠ 0 ⟹ (0 < (if prime p then multiplicity p x else 0)) = (x ≠ 0 ∧ p dvd x ∧ prime p)› discuss goal 1*) apply ((auto simp: multiplicity_eq_zero_iff (*‹⟦?x ≠ 0; ¬ is_unit ?p⟧ ⟹ (multiplicity ?p ?x = 0) = (¬ ?p dvd ?x)›*) multiplicity_gt_zero_iff (*‹⟦?x ≠ 0; ¬ is_unit ?p⟧ ⟹ (0 < multiplicity ?p ?x) = (?p dvd ?x)›*))[1]) (*discuss goal 2*) apply ((auto simp: multiplicity_eq_zero_iff (*‹⟦(?x::'a) ≠ (0::'a); ¬ is_unit (?p::'a)⟧ ⟹ (multiplicity ?p ?x = (0::nat)) = (¬ ?p dvd ?x)›*) multiplicity_gt_zero_iff (*‹⟦(?x::'a) ≠ (0::'a); ¬ is_unit (?p::'a)⟧ ⟹ ((0::nat) < multiplicity ?p ?x) = (?p dvd ?x)›*))[1]) (*proven 2 subgoals*) . finally (*calculation: ‹(p ∈ prime_factors x) = (x ≠ 0 ∧ p dvd x ∧ prime p)›*) show "?thesis" (*goal: ‹(p ∈ prime_factors x) = (x ≠ 0 ∧ p dvd x ∧ prime p)›*) . qed lemma in_prime_factors_imp_prime [intro]: "p ∈ prime_factors x ⟹ prime p" by (simp add: in_prime_factors_iff (*‹(?p ∈ prime_factors ?x) = (?x ≠ 0 ∧ ?p dvd ?x ∧ prime ?p)›*)) lemma in_prime_factors_imp_dvd [dest]: "p ∈ prime_factors x ⟹ p dvd x" by (simp add: in_prime_factors_iff (*‹(?p ∈ prime_factors ?x) = (?x ≠ 0 ∧ ?p dvd ?x ∧ prime ?p)›*)) lemma prime_factorsI: "x ≠ 0 ⟹ prime p ⟹ p dvd x ⟹ p ∈ prime_factors x" by (auto simp: in_prime_factors_iff (*‹(?p ∈ prime_factors ?x) = (?x ≠ 0 ∧ ?p dvd ?x ∧ prime ?p)›*)) lemma prime_factors_dvd: "x ≠ 0 ⟹ prime_factors x = {p. prime p ∧ p dvd x}" by (auto intro: prime_factorsI (*‹⟦?x ≠ 0; prime ?p; ?p dvd ?x⟧ ⟹ ?p ∈ prime_factors ?x›*)) lemma prime_factors_multiplicity: "prime_factors n = {p. prime p ∧ multiplicity p n > 0}" apply (cases "n = 0") (*goals: 1. ‹n = 0 ⟹ prime_factors n = {p. prime p ∧ 0 < multiplicity p n}› 2. ‹n ≠ 0 ⟹ prime_factors n = {p. prime p ∧ 0 < multiplicity p n}› discuss goal 1*) apply ((auto simp add: prime_factors_dvd (*‹?x ≠ 0 ⟹ prime_factors ?x = {p. prime p ∧ p dvd ?x}›*) prime_multiplicity_gt_zero_iff (*‹⟦prime_elem ?p; ?x ≠ 0⟧ ⟹ (0 < multiplicity ?p ?x) = (?p dvd ?x)›*))[1]) (*discuss goal 2*) apply ((auto simp add: prime_factors_dvd (*‹?x ≠ 0 ⟹ prime_factors ?x = {p. prime p ∧ p dvd ?x}›*) prime_multiplicity_gt_zero_iff (*‹⟦prime_elem ?p; ?x ≠ 0⟧ ⟹ (0 < multiplicity ?p ?x) = (?p dvd ?x)›*))[1]) (*proven 2 subgoals*) . lemma prime_factorization_prime: assumes "prime p" shows "prime_factorization p = {#p#}" proof (rule multiset_eqI (*‹(⋀x::?'a. count (?A::?'a multiset) x = count (?B::?'a multiset) x) ⟹ ?A = ?B›*)) (*goal: ‹⋀x. count (prime_factorization p) x = count {#p#} x›*) fix q :: 'a consider "¬prime q" | "q = p" | "prime q" and "q ≠ p" (*goal: ‹⟦¬ prime q ⟹ thesis; q = p ⟹ thesis; ⟦prime q; q ≠ p⟧ ⟹ thesis⟧ ⟹ thesis›*) by blast thus "count (prime_factorization p) q = count {#p#} q" apply cases (*goals: 1. ‹¬ prime (q::'a::type) ⟹ count (prime_factorization (p::'a::type)) q = count {#p#} q› 2. ‹(q::'a::type) = (p::'a::type) ⟹ count (prime_factorization p) q = count {#p#} q› 3. ‹⟦prime (q::'a::type); q ≠ (p::'a::type)⟧ ⟹ count (prime_factorization p) q = count {#p#} q› discuss goal 1*) apply ((insert assms (*‹prime p›*))[1]) (*top goal: ‹¬ prime q ⟹ count (prime_factorization p) q = count {#p#} q› and 2 goals remain*) apply ((auto dest: primes_dvd_imp_eq (*‹⟦prime ?p; prime ?q; ?p dvd ?q⟧ ⟹ ?p = ?q›*) simp: count_prime_factorization (*‹count (prime_factorization ?x) ?p = (if prime ?p then multiplicity ?p ?x else 0)›*) multiplicity_self (*‹⟦?p ≠ 0; ¬ is_unit ?p⟧ ⟹ multiplicity ?p ?p = 1›*) multiplicity_eq_zero_iff (*‹⟦?x ≠ 0; ¬ is_unit ?p⟧ ⟹ (multiplicity ?p ?x = 0) = (¬ ?p dvd ?x)›*))[1]) (*discuss goal 2*) apply ((insert assms (*‹prime (p::'a)›*))[1]) (*top goal: ‹q = p ⟹ count (prime_factorization p) q = count {#p#} q› and 1 goal remains*) apply ((auto dest: primes_dvd_imp_eq (*‹⟦prime ?p; prime ?q; ?p dvd ?q⟧ ⟹ ?p = ?q›*) simp: count_prime_factorization (*‹count (prime_factorization ?x) ?p = (if prime ?p then multiplicity ?p ?x else 0)›*) multiplicity_self (*‹⟦?p ≠ 0; ¬ is_unit ?p⟧ ⟹ multiplicity ?p ?p = 1›*) multiplicity_eq_zero_iff (*‹⟦?x ≠ 0; ¬ is_unit ?p⟧ ⟹ (multiplicity ?p ?x = 0) = (¬ ?p dvd ?x)›*))[1]) (*discuss goal 3*) apply ((insert assms (*‹prime (p::'a::type)›*))[1]) (*goal: ‹⟦prime q; q ≠ p⟧ ⟹ count (prime_factorization p) q = count {#p#} q›*) apply ((auto dest: primes_dvd_imp_eq (*‹⟦prime (?p::'a::type); prime (?q::'a::type); ?p dvd ?q⟧ ⟹ ?p = ?q›*) simp: count_prime_factorization (*‹count (prime_factorization (?x::'a::type)) (?p::'a::type) = (if prime ?p then multiplicity ?p ?x else (0::nat))›*) multiplicity_self (*‹⟦(?p::'a::type) ≠ (0::'a::type); ¬ is_unit ?p⟧ ⟹ multiplicity ?p ?p = (1::nat)›*) multiplicity_eq_zero_iff (*‹⟦(?x::'a::type) ≠ (0::'a::type); ¬ is_unit (?p::'a::type)⟧ ⟹ (multiplicity ?p ?x = (0::nat)) = (¬ ?p dvd ?x)›*))[1]) (*proven 3 subgoals*) . qed lemma prime_factorization_prod_mset_primes: assumes "⋀p. p ∈# A ⟹ prime p" shows "prime_factorization (prod_mset A) = A" using assms (*‹?p1 ∈# A ⟹ prime ?p1›*) proof (induction A) (*goals: 1. ‹(⋀p. p ∈# {#} ⟹ prime p) ⟹ prime_factorization (∏⇩# {#}) = {#}› 2. ‹⋀x A. ⟦(⋀p. p ∈# A ⟹ prime p) ⟹ prime_factorization (∏⇩# A) = A; ⋀p. p ∈# add_mset x A ⟹ prime p⟧ ⟹ prime_factorization (∏⇩# (add_mset x A)) = add_mset x A›*) case (add p A) (*‹(⋀p::'a. p ∈# (A::'a multiset) ⟹ prime p) ⟹ prime_factorization (∏⇩# A) = A› ‹?p1 ∈# add_mset p A ⟹ prime ?p1›*) from add.prems[of 0] (*‹(0::'a) ∈# add_mset (p::'a) (A::'a multiset) ⟹ prime (0::'a)›*) have "0 ∉# A" by auto hence "prod_mset A ≠ 0" by auto with add (*‹(⋀p. p ∈# A ⟹ prime p) ⟹ prime_factorization (∏⇩# A) = A› ‹(?p1::'a) ∈# add_mset (p::'a) (A::'a multiset) ⟹ prime ?p1›*) show "?case" (*goal: ‹prime_factorization (∏⇩# (add_mset p A)) = add_mset p A›*) by (simp add: mult_ac (*‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)›*) prime_factorization_times_prime (*‹⟦?x ≠ 0; prime ?p⟧ ⟹ prime_factorization (?p * ?x) = {#?p#} + prime_factorization ?x›*) Multiset.union_commute (*‹?M + ?N = ?N + ?M›*)) qed (simp_all) (*solved the remaining goal: ‹(⋀p::'a. p ∈# {#} ⟹ prime p) ⟹ prime_factorization (∏⇩# {#}) = {#}›*) lemma prime_factorization_cong: "normalize x = normalize y ⟹ prime_factorization x = prime_factorization y" by (simp add: multiset_eq_iff (*‹(?M = ?N) = (∀a. count ?M a = count ?N a)›*) count_prime_factorization (*‹count (prime_factorization ?x) ?p = (if prime ?p then multiplicity ?p ?x else 0)›*) multiplicity_normalize_right [of _ x, symmetric] (*‹multiplicity ?p x = multiplicity ?p (normalize x)›*) multiplicity_normalize_right [of _ y, symmetric] (*‹multiplicity ?p y = multiplicity ?p (normalize y)›*) del: multiplicity_normalize_right (*‹multiplicity ?p (normalize ?x) = multiplicity ?p ?x›*)) lemma prime_factorization_unique: assumes "x ≠ 0" "y ≠ 0" shows "prime_factorization x = prime_factorization y ⟷ normalize x = normalize y" proof (standard) (*goals: 1. ‹prime_factorization x = prime_factorization y ⟹ normalize x = normalize y› 2. ‹normalize x = normalize y ⟹ prime_factorization x = prime_factorization y›*) assume "prime_factorization x = prime_factorization y" (*‹prime_factorization (x::'a) = prime_factorization (y::'a)›*) hence "prod_mset (prime_factorization x) = prod_mset (prime_factorization y)" by simp hence "normalize (prod_mset (prime_factorization x)) = normalize (prod_mset (prime_factorization y))" by (simp only:) with assms (*‹x ≠ 0› ‹y ≠ 0›*) show "normalize x = normalize y" by (simp add: prod_mset_prime_factorization_weak (*‹?x ≠ 0 ⟹ normalize (∏⇩# (prime_factorization ?x)) = normalize ?x›*)) qed (rule prime_factorization_cong (*‹normalize ?x = normalize ?y ⟹ prime_factorization ?x = prime_factorization ?y›*)) (*solved the remaining goal: ‹normalize x = normalize y ⟹ prime_factorization x = prime_factorization y›*) lemma prime_factorization_normalize [simp]: "prime_factorization (normalize x) = prime_factorization x" apply (cases "x = 0") (*goals: 1. ‹x = 0 ⟹ prime_factorization (normalize x) = prime_factorization x› 2. ‹x ≠ 0 ⟹ prime_factorization (normalize x) = prime_factorization x› discuss goal 1*) apply simp (*discuss goal 2*) apply (subst prime_factorization_unique (*‹⟦?x ≠ 0; ?y ≠ 0⟧ ⟹ (prime_factorization ?x = prime_factorization ?y) = (normalize ?x = normalize ?y)›*)) (*goals: 1. ‹x ≠ 0 ⟹ normalize x ≠ 0› 2. ‹x ≠ 0 ⟹ x ≠ 0› 3. ‹x ≠ 0 ⟹ normalize (normalize x) = normalize x› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*proven 3 subgoals*) (*proven 2 subgoals*) . lemma prime_factorization_eqI_strong: assumes "⋀p. p ∈# P ⟹ prime p" "prod_mset P = n" shows "prime_factorization n = P" using prime_factorization_prod_mset_primes[of P] (*‹(⋀p. p ∈# P ⟹ prime p) ⟹ prime_factorization (∏⇩# P) = P›*) assms (*‹?p1 ∈# P ⟹ prime ?p1› ‹∏⇩# P = n›*) by simp lemma prime_factorization_eqI: assumes "⋀p. p ∈# P ⟹ prime p" "normalize (prod_mset P) = normalize n" shows "prime_factorization n = P" proof (-) (*goal: ‹prime_factorization n = P›*) have "P = prime_factorization (normalize (prod_mset P))" using prime_factorization_prod_mset_primes[of P] (*‹(⋀p::'a::type. p ∈# (P::'a::type multiset) ⟹ prime p) ⟹ prime_factorization (∏⇩# P) = P›*) assms(1) (*‹?p1 ∈# P ⟹ prime ?p1›*) by simp with assms(2) (*‹normalize (∏⇩# P) = normalize n›*) show "?thesis" (*goal: ‹prime_factorization n = P›*) by simp qed lemma prime_factorization_mult: assumes "x ≠ 0" "y ≠ 0" shows "prime_factorization (x * y) = prime_factorization x + prime_factorization y" proof (-) (*goal: ‹prime_factorization (x * y) = prime_factorization x + prime_factorization y›*) have "normalize (prod_mset (prime_factorization x) * prod_mset (prime_factorization y)) = normalize (normalize (prod_mset (prime_factorization x)) * normalize (prod_mset (prime_factorization y)))" by (simp only: normalize_mult_normalize_left (*‹normalize (normalize (?a::'a::type) * (?b::'a::type)) = normalize (?a * ?b)›*) normalize_mult_normalize_right (*‹normalize ((?a::'a::type) * normalize (?b::'a::type)) = normalize (?a * ?b)›*)) also (*calculation: ‹normalize (∏⇩# (prime_factorization x) * ∏⇩# (prime_factorization y)) = normalize (normalize (∏⇩# (prime_factorization x)) * normalize (∏⇩# (prime_factorization y)))›*) have "… = normalize (x * y)" apply (subst (1 2) prod_mset_prime_factorization_weak (*‹?x ≠ 0 ⟹ normalize (∏⇩# (prime_factorization ?x)) = normalize ?x›*)) (*goals: 1. ‹y ≠ 0› 2. ‹x ≠ 0› 3. ‹normalize (normalize x * normalize y) = normalize (x * y)› discuss goal 1*) apply ((use assms in auto)[1]) (*discuss goal 2*) apply ((use assms in auto)[1]) (*discuss goal 3*) apply ((use assms in auto)[1]) (*proven 3 subgoals*) . finally (*calculation: ‹normalize (∏⇩# (prime_factorization x) * ∏⇩# (prime_factorization y)) = normalize (x * y)›*) show "?thesis" (*goal: ‹prime_factorization (x * y) = prime_factorization x + prime_factorization y›*) apply (intro prime_factorization_eqI (*‹⟦⋀p. p ∈# ?P ⟹ prime p; normalize (∏⇩# ?P) = normalize ?n⟧ ⟹ prime_factorization ?n = ?P›*)) (*goals: 1. ‹⋀p::'a. ⟦normalize (∏⇩# (prime_factorization (x::'a)) * ∏⇩# (prime_factorization (y::'a))) = normalize (x * y); p ∈# prime_factorization x + prime_factorization y⟧ ⟹ prime p› 2. ‹normalize (∏⇩# (prime_factorization (x::'a)) * ∏⇩# (prime_factorization (y::'a))) = normalize (x * y) ⟹ normalize (∏⇩# (prime_factorization x + prime_factorization y)) = normalize (x * y)› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . qed lemma prime_factorization_prod: assumes "finite A" "⋀x. x ∈ A ⟹ f x ≠ 0" shows "prime_factorization (prod f A) = (∑n∈A. prime_factorization (f n))" using assms (*‹finite A› ‹?x1 ∈ A ⟹ f ?x1 ≠ 0›*) apply (induction A rule: finite_induct (*‹⟦finite ?F; ?P {}; ⋀x F. ⟦finite F; x ∉ F; ?P F⟧ ⟹ ?P (insert x F)⟧ ⟹ ?P ?F›*)) (*goals: 1. ‹(⋀x::'b::type. x ∈ {} ⟹ (f::'b::type ⇒ 'a::type) x ≠ (0::'a::type)) ⟹ prime_factorization (prod f {}) = (∑n::'b::type∈{}. prime_factorization (f n))› 2. ‹⋀(x::'b::type) F::'b::type set. ⟦finite F; x ∉ F; (⋀x::'b::type. x ∈ F ⟹ (f::'b::type ⇒ 'a::type) x ≠ (0::'a::type)) ⟹ prime_factorization (prod f F) = (∑n::'b::type∈F. prime_factorization (f n)); ⋀xa::'b::type. xa ∈ insert x F ⟹ f xa ≠ (0::'a::type)⟧ ⟹ prime_factorization (prod f (insert x F)) = (∑n::'b::type∈insert x F. prime_factorization (f n))› discuss goal 1*) apply ((auto simp: Sup_multiset_empty (*‹Sup {} = {#}›*) prime_factorization_mult (*‹⟦?x ≠ 0; ?y ≠ 0⟧ ⟹ prime_factorization (?x * ?y) = prime_factorization ?x + prime_factorization ?y›*))[1]) (*discuss goal 2*) apply ((auto simp: Sup_multiset_empty (*‹Sup {} = {#}›*) prime_factorization_mult (*‹⟦?x ≠ 0; ?y ≠ 0⟧ ⟹ prime_factorization (?x * ?y) = prime_factorization ?x + prime_factorization ?y›*))[1]) (*proven 2 subgoals*) . lemma prime_elem_multiplicity_mult_distrib: assumes "prime_elem p" "x ≠ 0" "y ≠ 0" shows "multiplicity p (x * y) = multiplicity p x + multiplicity p y" proof (-) (*goal: ‹multiplicity (p::'a::type) ((x::'a::type) * (y::'a::type)) = multiplicity p x + multiplicity p y›*) have "multiplicity p (x * y) = count (prime_factorization (x * y)) (normalize p)" apply (subst count_prime_factorization_prime (*‹prime ?p ⟹ count (prime_factorization ?x) ?p = multiplicity ?p ?x›*)) (*goals: 1. ‹prime (normalize p)› 2. ‹multiplicity p (x * y) = multiplicity (normalize p) (x * y)› discuss goal 1*) apply (simp add: assms (*‹prime_elem p› ‹x ≠ 0› ‹y ≠ 0›*)) (*discuss goal 2*) apply (simp add: assms (*‹prime_elem p› ‹x ≠ 0› ‹y ≠ 0›*)) (*proven 2 subgoals*) . also (*calculation: ‹multiplicity p (x * y) = count (prime_factorization (x * y)) (normalize p)›*) from assms (*‹prime_elem p› ‹x ≠ 0› ‹y ≠ 0›*) have "prime_factorization (x * y) = prime_factorization x + prime_factorization y" apply (intro prime_factorization_mult (*‹⟦?x ≠ 0; ?y ≠ 0⟧ ⟹ prime_factorization (?x * ?y) = prime_factorization ?x + prime_factorization ?y›*)) (*goals: 1. ‹⟦prime_elem p; x ≠ 0; y ≠ 0⟧ ⟹ x ≠ 0› 2. ‹⟦prime_elem p; x ≠ 0; y ≠ 0⟧ ⟹ y ≠ 0› discuss goal 1*) apply ((assumption)[1]) (*discuss goal 2*) . (*proven 2 subgoals*) also (*calculation: ‹multiplicity p (x * y) = count (prime_factorization x + prime_factorization y) (normalize p)›*) have "count … (normalize p) = count (prime_factorization x) (normalize p) + count (prime_factorization y) (normalize p)" by simp also (*calculation: ‹multiplicity (p::'a) ((x::'a) * (y::'a)) = count (prime_factorization x) (normalize p) + count (prime_factorization y) (normalize p)›*) have "… = multiplicity p x + multiplicity p y" apply (subst (1 2) count_prime_factorization_prime (*‹prime ?p ⟹ count (prime_factorization ?x) ?p = multiplicity ?p ?x›*)) (*goals: 1. ‹prime (normalize p)› 2. ‹multiplicity (normalize p) x + multiplicity (normalize p) y = multiplicity p x + multiplicity p y› discuss goal 1*) apply (simp add: assms (*‹prime_elem (p::'a::type)› ‹(x::'a::type) ≠ (0::'a::type)› ‹(y::'a::type) ≠ (0::'a::type)›*)) (*discuss goal 2*) apply (simp add: assms (*‹prime_elem (p::'a::type)› ‹(x::'a::type) ≠ (0::'a::type)› ‹(y::'a::type) ≠ (0::'a::type)›*)) (*proven 2 subgoals*) . finally (*calculation: ‹multiplicity p (x * y) = multiplicity p x + multiplicity p y›*) show "?thesis" (*goal: ‹multiplicity p (x * y) = multiplicity p x + multiplicity p y›*) . qed lemma prime_elem_multiplicity_prod_mset_distrib: assumes "prime_elem p" "0 ∉# A" shows "multiplicity p (prod_mset A) = sum_mset (image_mset (multiplicity p) A)" using assms (*‹prime_elem p› ‹0 ∉# A›*) apply (induction A) (*goals: 1. ‹⟦prime_elem p; 0 ∉# {#}⟧ ⟹ multiplicity p (∏⇩# {#}) = ∑⇩# (image_mset (multiplicity p) {#})› 2. ‹⋀x A. ⟦⟦prime_elem p; 0 ∉# A⟧ ⟹ multiplicity p (∏⇩# A) = ∑⇩# (image_mset (multiplicity p) A); prime_elem p; 0 ∉# add_mset x A⟧ ⟹ multiplicity p (∏⇩# (add_mset x A)) = ∑⇩# (image_mset (multiplicity p) (add_mset x A))› discuss goal 1*) apply ((auto simp: prime_elem_multiplicity_mult_distrib (*‹⟦prime_elem (?p::'a::type); (?x::'a::type) ≠ (0::'a::type); (?y::'a::type) ≠ (0::'a::type)⟧ ⟹ multiplicity ?p (?x * ?y) = multiplicity ?p ?x + multiplicity ?p ?y›*))[1]) (*discuss goal 2*) apply ((auto simp: prime_elem_multiplicity_mult_distrib (*‹⟦prime_elem ?p; ?x ≠ 0; ?y ≠ 0⟧ ⟹ multiplicity ?p (?x * ?y) = multiplicity ?p ?x + multiplicity ?p ?y›*))[1]) (*proven 2 subgoals*) . lemma prime_elem_multiplicity_power_distrib: assumes "prime_elem p" "x ≠ 0" shows "multiplicity p (x ^ n) = n * multiplicity p x" using assms (*‹prime_elem p› ‹x ≠ 0›*) prime_elem_multiplicity_prod_mset_distrib[of p "replicate_mset n x"] (*‹⟦prime_elem p; 0 ∉# replicate_mset n x⟧ ⟹ multiplicity p (∏⇩# (replicate_mset n x)) = ∑⇩# (image_mset (multiplicity p) (replicate_mset n x))›*) by simp lemma prime_elem_multiplicity_prod_distrib: assumes "prime_elem p" "0 ∉ f ` A" "finite A" shows "multiplicity p (prod f A) = (∑x∈A. multiplicity p (f x))" proof (-) (*goal: ‹multiplicity p (prod f A) = (∑x∈A. multiplicity p (f x))›*) have "multiplicity p (prod f A) = (∑x∈#mset_set A. multiplicity p (f x))" using assms (*‹prime_elem p› ‹0 ∉ f ` A› ‹finite A›*) apply (subst prod_unfold_prod_mset (*‹prod ?f ?A = ∏⇩# (image_mset ?f (mset_set ?A))›*)) (*goal: ‹multiplicity (p::'a) (prod (f::'b ⇒ 'a) (A::'b set)) = (∑x::'b∈#mset_set A. multiplicity p (f x))›*) by (simp add: prime_elem_multiplicity_prod_mset_distrib (*‹⟦prime_elem ?p; 0 ∉# ?A⟧ ⟹ multiplicity ?p (∏⇩# ?A) = ∑⇩# (image_mset (multiplicity ?p) ?A)›*) sum_unfold_sum_mset (*‹sum ?f ?A = ∑⇩# (image_mset ?f (mset_set ?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: ‹multiplicity p (prod f A) = (∑x∈#mset_set A. multiplicity p (f x))›*) from ‹finite A› (*‹finite (A::'b set)›*) have "… = (∑x∈A. multiplicity p (f x))" apply (induction A rule: finite_induct (*‹⟦finite ?F; ?P {}; ⋀x F. ⟦finite F; x ∉ F; ?P F⟧ ⟹ ?P (insert x F)⟧ ⟹ ?P ?F›*)) (*goals: 1. ‹(∑x∈#mset_set {}. multiplicity p (f x)) = (∑x∈{}. multiplicity p (f x))› 2. ‹⋀x F. ⟦finite F; x ∉ F; (∑x∈#mset_set F. multiplicity p (f x)) = (∑x∈F. multiplicity p (f x))⟧ ⟹ (∑x∈#mset_set (insert x F). multiplicity p (f x)) = (∑x∈insert x F. multiplicity p (f x))› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) . finally (*calculation: ‹multiplicity p (prod f A) = (∑x∈A. multiplicity p (f x))›*) show "?thesis" (*goal: ‹multiplicity p (prod f A) = (∑x∈A. multiplicity p (f x))›*) . qed lemma multiplicity_distinct_prime_power: "prime p ⟹ prime q ⟹ p ≠ q ⟹ multiplicity p (q ^ n) = 0" apply (subst prime_elem_multiplicity_power_distrib (*‹⟦prime_elem ?p; ?x ≠ 0⟧ ⟹ multiplicity ?p (?x ^ ?n) = ?n * multiplicity ?p ?x›*)) (*goals: 1. ‹⟦prime p; prime q; p ≠ q⟧ ⟹ prime_elem p› 2. ‹⟦prime p; prime q; p ≠ q⟧ ⟹ q ≠ 0› 3. ‹⟦prime p; prime q; p ≠ q⟧ ⟹ n * multiplicity p q = 0› discuss goal 1*) apply ((auto simp: prime_multiplicity_other (*‹⟦prime (?p::'a); prime (?q::'a); ?p ≠ ?q⟧ ⟹ multiplicity ?p ?q = (0::nat)›*))[1]) (*discuss goal 2*) apply ((auto simp: prime_multiplicity_other (*‹⟦prime ?p; prime ?q; ?p ≠ ?q⟧ ⟹ multiplicity ?p ?q = 0›*))[1]) (*discuss goal 3*) apply ((auto simp: prime_multiplicity_other (*‹⟦prime (?p::'a::type); prime (?q::'a::type); ?p ≠ ?q⟧ ⟹ multiplicity ?p ?q = (0::nat)›*))[1]) (*proven 3 subgoals*) . lemma prime_factorization_prime_power: "prime p ⟹ prime_factorization (p ^ n) = replicate_mset n p" apply (induction n) (*goals: 1. ‹prime p ⟹ prime_factorization (p ^ 0) = replicate_mset 0 p› 2. ‹⋀n. ⟦prime p ⟹ prime_factorization (p ^ n) = replicate_mset n p; prime p⟧ ⟹ prime_factorization (p ^ Suc n) = replicate_mset (Suc n) p› discuss goal 1*) apply (simp add: prime_factorization_mult (*‹⟦?x ≠ 0; ?y ≠ 0⟧ ⟹ prime_factorization (?x * ?y) = prime_factorization ?x + prime_factorization ?y›*) prime_factorization_prime (*‹prime ?p ⟹ prime_factorization ?p = {#?p#}›*) Multiset.union_commute (*‹?M + ?N = ?N + ?M›*)) (*discuss goal 2*) apply (simp add: prime_factorization_mult (*‹⟦(?x::'a::type) ≠ (0::'a::type); (?y::'a::type) ≠ (0::'a::type)⟧ ⟹ prime_factorization (?x * ?y) = prime_factorization ?x + prime_factorization ?y›*) prime_factorization_prime (*‹prime (?p::'a::type) ⟹ prime_factorization ?p = {#?p#}›*) Multiset.union_commute (*‹(?M::?'a::type multiset) + (?N::?'a::type multiset) = ?N + ?M›*)) (*proven 2 subgoals*) . lemma prime_factorization_subset_iff_dvd: assumes [simp]: "x ≠ 0" "y ≠ 0" shows "prime_factorization x ⊆# prime_factorization y ⟷ x dvd y" proof (-) (*goal: ‹(prime_factorization x ⊆# prime_factorization y) = (x dvd y)›*) have "x dvd y ⟷ normalize (prod_mset (prime_factorization x)) dvd normalize (prod_mset (prime_factorization y))" using assms (*‹(x::'a) ≠ (0::'a)› ‹y ≠ 0›*) apply (subst (1 2) prod_mset_prime_factorization_weak (*‹?x ≠ 0 ⟹ normalize (∏⇩# (prime_factorization ?x)) = normalize ?x›*)) (*goals: 1. ‹⟦x ≠ 0; y ≠ 0⟧ ⟹ y ≠ 0› 2. ‹⟦x ≠ 0; y ≠ 0⟧ ⟹ x ≠ 0› 3. ‹⟦x ≠ 0; y ≠ 0⟧ ⟹ (x dvd y) = (normalize x dvd normalize y)› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*proven 3 subgoals*) . also (*calculation: ‹(x dvd y) = (normalize (∏⇩# (prime_factorization x)) dvd normalize (∏⇩# (prime_factorization y)))›*) have "… ⟷ prime_factorization x ⊆# prime_factorization y" by (auto intro!: prod_mset_primes_dvd_imp_subset (*‹⟦∏⇩# (?A::'a multiset) dvd ∏⇩# (?B::'a multiset); ⋀p::'a. p ∈# ?A ⟹ prime p; ⋀p::'a. p ∈# ?B ⟹ prime p⟧ ⟹ ?A ⊆# ?B›*) prod_mset_subset_imp_dvd (*‹(?A::'a multiset) ⊆# (?B::'a multiset) ⟹ ∏⇩# ?A dvd ∏⇩# ?B›*)) finally (*calculation: ‹(x dvd y) = (prime_factorization x ⊆# prime_factorization y)›*) show "?thesis" (*goal: ‹(prime_factorization x ⊆# prime_factorization y) = (x dvd y)›*) apply - (*goal: ‹(prime_factorization x ⊆# prime_factorization y) = (x dvd y)›*) apply standard (*goals: 1. ‹⟦((x::'a) dvd (y::'a)) = (prime_factorization x ⊆# prime_factorization y); prime_factorization x ⊆# prime_factorization y⟧ ⟹ x dvd y› 2. ‹⟦((x::'a) dvd (y::'a)) = (prime_factorization x ⊆# prime_factorization y); x dvd y⟧ ⟹ prime_factorization x ⊆# prime_factorization y› discuss goal 1*) apply ((msorry)[1]) (*discuss goal 2*) apply ((msorry)[1]) (*proven 2 subgoals*) . qed lemma prime_factorization_subset_imp_dvd: "x ≠ 0 ⟹ (prime_factorization x ⊆# prime_factorization y) ⟹ x dvd y" apply (cases "y = 0") (*goals: 1. ‹⟦x ≠ 0; prime_factorization x ⊆# prime_factorization y; y = 0⟧ ⟹ x dvd y› 2. ‹⟦x ≠ 0; prime_factorization x ⊆# prime_factorization y; y ≠ 0⟧ ⟹ x dvd y› discuss goal 1*) apply (simp add: prime_factorization_subset_iff_dvd (*‹⟦?x ≠ 0; ?y ≠ 0⟧ ⟹ (prime_factorization ?x ⊆# prime_factorization ?y) = (?x dvd ?y)›*)) (*discuss goal 2*) apply (simp add: prime_factorization_subset_iff_dvd (*‹⟦?x ≠ 0; ?y ≠ 0⟧ ⟹ (prime_factorization ?x ⊆# prime_factorization ?y) = (?x dvd ?y)›*)) (*proven 2 subgoals*) . lemma prime_factorization_divide: assumes "b dvd a" shows "prime_factorization (a div b) = prime_factorization a - prime_factorization b" proof (cases "a = 0") (*goals: 1. ‹(a::'a) = (0::'a) ⟹ prime_factorization (a div (b::'a)) = prime_factorization a - prime_factorization b› 2. ‹(a::'a) ≠ (0::'a) ⟹ prime_factorization (a div (b::'a)) = prime_factorization a - prime_factorization b›*) case [simp]: False (*‹a ≠ 0›*) from assms (*‹b dvd a›*) have [simp]: "b ≠ 0" by auto have "prime_factorization ((a div b) * b) = prime_factorization (a div b) + prime_factorization b" apply (intro prime_factorization_mult (*‹⟦?x ≠ 0; ?y ≠ 0⟧ ⟹ prime_factorization (?x * ?y) = prime_factorization ?x + prime_factorization ?y›*)) (*goals: 1. ‹a div b ≠ 0› 2. ‹b ≠ 0› discuss goal 1*) apply ((insert assms (*‹b dvd a›*))[1]) (*top goal: ‹a div b ≠ 0› and 1 goal remains*) apply ((auto elim!: dvdE (*‹⟦?b dvd ?a; ⋀k. ?a = ?b * k ⟹ ?P⟧ ⟹ ?P›*))[1]) (*discuss goal 2*) apply ((insert assms (*‹(b::'a::type) dvd (a::'a::type)›*))[1]) (*goal: ‹b ≠ 0›*) apply ((auto elim!: dvdE (*‹⟦(?b::'a) dvd (?a::'a); ⋀k::'a. ?a = ?b * k ⟹ ?P::bool⟧ ⟹ ?P›*))[1]) (*proven 2 subgoals*) . with assms (*‹b dvd a›*) show "?thesis" (*goal: ‹prime_factorization (a div b) = prime_factorization a - prime_factorization b›*) by simp qed (simp_all) (*solved the remaining goal: ‹a = 0 ⟹ prime_factorization (a div b) = prime_factorization a - prime_factorization b›*) lemma zero_not_in_prime_factors [simp]: "0 ∉ prime_factors x" by (auto dest: in_prime_factors_imp_prime (*‹?p ∈ prime_factors ?x ⟹ prime ?p›*)) lemma prime_prime_factors: "prime p ⟹ prime_factors p = {p}" apply (drule prime_factorization_prime (*‹prime ?p ⟹ prime_factorization ?p = {#?p#}›*)) (*goal: ‹prime p ⟹ prime_factors p = {p}›*) by simp lemma prime_factors_product: "x ≠ 0 ⟹ y ≠ 0 ⟹ prime_factors (x * y) = prime_factors x ∪ prime_factors y" by (simp add: prime_factorization_mult (*‹⟦?x ≠ 0; ?y ≠ 0⟧ ⟹ prime_factorization (?x * ?y) = prime_factorization ?x + prime_factorization ?y›*)) lemma dvd_prime_factors [intro]: "y ≠ 0 ⟹ x dvd y ⟹ prime_factors x ⊆ prime_factors y" apply (intro set_mset_mono (*‹?A ⊆# ?B ⟹ set_mset ?A ⊆ set_mset ?B›*)) (*goal: ‹⟦y ≠ 0; x dvd y⟧ ⟹ prime_factors x ⊆ prime_factors y›*) apply (subst prime_factorization_subset_iff_dvd (*‹⟦?x ≠ 0; ?y ≠ 0⟧ ⟹ (prime_factorization ?x ⊆# prime_factorization ?y) = (?x dvd ?y)›*)) (*goals: 1. ‹⟦y ≠ 0; x dvd y⟧ ⟹ x ≠ 0› 2. ‹⟦y ≠ 0; x dvd y⟧ ⟹ y ≠ 0› 3. ‹⟦y ≠ 0; x dvd y⟧ ⟹ x dvd y› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*proven 3 subgoals*) . (* RENAMED multiplicity_dvd *) lemma multiplicity_le_imp_dvd: assumes "x ≠ 0" "⋀p. prime p ⟹ multiplicity p x ≤ multiplicity p y" shows "x dvd y" proof (cases "y = 0") (*goals: 1. ‹y = 0 ⟹ x dvd y› 2. ‹y ≠ 0 ⟹ x dvd y›*) case False (*‹y ≠ 0›*) from assms (*‹x ≠ 0› ‹prime ?p1 ⟹ multiplicity ?p1 x ≤ multiplicity ?p1 y›*) this (*‹y ≠ 0›*) have "prime_factorization x ⊆# prime_factorization y" apply (intro mset_subset_eqI (*‹(⋀a::?'a. count (?A::?'a multiset) a ≤ count (?B::?'a multiset) a) ⟹ ?A ⊆# ?B›*)) (*goal: ‹prime_factorization (x::'a::type) ⊆# prime_factorization (y::'a::type)›*) by (auto simp: count_prime_factorization (*‹count (prime_factorization (?x::'a)) (?p::'a) = (if prime ?p then multiplicity ?p ?x else (0::nat))›*)) with assms (*‹x ≠ 0› ‹prime ?p1 ⟹ multiplicity ?p1 x ≤ multiplicity ?p1 y›*) False (*‹y ≠ 0›*) show "?thesis" (*goal: ‹x dvd y›*) apply (subst (asm) prime_factorization_subset_iff_dvd (*‹⟦?x ≠ 0; ?y ≠ 0⟧ ⟹ (prime_factorization ?x ⊆# prime_factorization ?y) = (?x dvd ?y)›*)) (*goals: 1. ‹⟦x ≠ 0; ⋀p. prime p ⟹ multiplicity p x ≤ multiplicity p y; y ≠ 0⟧ ⟹ x ≠ 0› 2. ‹⟦x ≠ 0; ⋀p. prime p ⟹ multiplicity p x ≤ multiplicity p y; y ≠ 0⟧ ⟹ y ≠ 0› 3. ‹⟦x ≠ 0; ⋀p. prime p ⟹ multiplicity p x ≤ multiplicity p y; y ≠ 0; x dvd y⟧ ⟹ x dvd y› discuss goal 1*) apply ((assumption)[1]) (*discuss goal 2*) apply ((assumption)[1]) (*discuss goal 3*) . (*proven 3 subgoals*) qed (auto) (*solved the remaining goal: ‹y = 0 ⟹ x dvd y›*) lemma dvd_multiplicity_eq: "x ≠ 0 ⟹ y ≠ 0 ⟹ x dvd y ⟷ (∀p. multiplicity p x ≤ multiplicity p y)" by (auto intro: dvd_imp_multiplicity_le (*‹⟦?a dvd ?b; ?b ≠ 0⟧ ⟹ multiplicity ?p ?a ≤ multiplicity ?p ?b›*) multiplicity_le_imp_dvd (*‹⟦?x ≠ 0; ⋀p. prime p ⟹ multiplicity p ?x ≤ multiplicity p ?y⟧ ⟹ ?x dvd ?y›*)) lemma multiplicity_eq_imp_eq: assumes "x ≠ 0" "y ≠ 0" assumes "⋀p. prime p ⟹ multiplicity p x = multiplicity p y" shows "normalize x = normalize y" using assms (*‹x ≠ 0› ‹y ≠ 0› ‹prime ?p1 ⟹ multiplicity ?p1 x = multiplicity ?p1 y›*) apply (intro associatedI (*‹⟦?a dvd ?b; ?b dvd ?a⟧ ⟹ normalize ?a = normalize ?b›*) multiplicity_le_imp_dvd (*‹⟦?x ≠ 0; ⋀p. prime p ⟹ multiplicity p ?x ≤ multiplicity p ?y⟧ ⟹ ?x dvd ?y›*)) (*goals: 1. ‹⟦x ≠ 0; y ≠ 0; ⋀p. prime p ⟹ multiplicity p x = multiplicity p y⟧ ⟹ x ≠ 0› 2. ‹⋀p. ⟦x ≠ 0; y ≠ 0; ⋀p. prime p ⟹ multiplicity p x = multiplicity p y; prime p⟧ ⟹ multiplicity p x ≤ multiplicity p y› 3. ‹⟦x ≠ 0; y ≠ 0; ⋀p. prime p ⟹ multiplicity p x = multiplicity p y⟧ ⟹ y ≠ 0› 4. ‹⋀p. ⟦x ≠ 0; y ≠ 0; ⋀p. prime p ⟹ multiplicity p x = multiplicity p y; prime p⟧ ⟹ multiplicity p y ≤ multiplicity p 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 prime_factorization_unique': assumes "∀p ∈# M. prime p" "∀p ∈# N. prime p" "(∏i ∈# M. i) = (∏i ∈# N. i)" shows "M = N" proof (-) (*goal: ‹M = N›*) have "prime_factorization (∏i ∈# M. i) = prime_factorization (∏i ∈# N. i)" by (simp only: assms (*‹∀p∈#M. prime p› ‹∀p∈#N. prime p› ‹(∏i∈#M. i) = (∏i∈#N. i)›*)) also (*calculation: ‹prime_factorization (∏i∈#M. i) = prime_factorization (∏i∈#N. i)›*) from assms (*‹∀p∈#M. prime p› ‹∀p::'a∈#N::'a multiset. prime p› ‹(∏i∈#M. i) = (∏i∈#N. i)›*) have "prime_factorization (∏i ∈# M. i) = M" apply (subst prime_factorization_prod_mset_primes (*‹(⋀p. p ∈# ?A ⟹ prime p) ⟹ prime_factorization (∏⇩# ?A) = ?A›*)) (*goals: 1. ‹⋀p. ⟦∀p∈#M. prime p; ∀p∈#N. prime p; (∏i∈#M. i) = (∏i∈#N. i); p ∈# {#i. i ∈# M#}⟧ ⟹ prime p› 2. ‹⟦∀p∈#M. prime p; ∀p∈#N. prime p; (∏i∈#M. i) = (∏i∈#N. i)⟧ ⟹ {#i. i ∈# M#} = M› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) . also (*calculation: ‹M = prime_factorization (∏i∈#N. i)›*) from assms (*‹∀p∈#M. prime p› ‹∀p∈#N. prime p› ‹(∏i∈#M. i) = (∏i∈#N. i)›*) have "prime_factorization (∏i ∈# N. i) = N" apply (subst prime_factorization_prod_mset_primes (*‹(⋀p. p ∈# ?A ⟹ prime p) ⟹ prime_factorization (∏⇩# ?A) = ?A›*)) (*goals: 1. ‹⋀p. ⟦∀p∈#M. prime p; ∀p∈#N. prime p; (∏i∈#M. i) = (∏i∈#N. i); p ∈# {#i. i ∈# N#}⟧ ⟹ prime p› 2. ‹⟦∀p∈#M. prime p; ∀p∈#N. prime p; (∏i∈#M. i) = (∏i∈#N. i)⟧ ⟹ {#i. i ∈# N#} = N› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) . finally (*calculation: ‹M = N›*) show "?thesis" (*goal: ‹M = N›*) . qed lemma prime_factorization_unique'': assumes "∀p ∈# M. prime p" "∀p ∈# N. prime p" "normalize (∏i ∈# M. i) = normalize (∏i ∈# N. i)" shows "M = N" proof (-) (*goal: ‹M = N›*) have "prime_factorization (normalize (∏i ∈# M. i)) = prime_factorization (normalize (∏i ∈# N. i))" by (simp only: assms (*‹∀p∈#M. prime p› ‹∀p∈#N. prime p› ‹normalize (∏i∈#M. i) = normalize (∏i∈#N. i)›*)) also (*calculation: ‹prime_factorization (normalize (∏i∈#M. i)) = prime_factorization (normalize (∏i∈#N. i))›*) from assms (*‹∀p∈#M. prime p› ‹∀p∈#N. prime p› ‹normalize (∏i∈#M. i) = normalize (∏i∈#N. i)›*) have "prime_factorization (normalize (∏i ∈# M. i)) = M" apply (subst prime_factorization_normalize (*‹prime_factorization (normalize ?x) = prime_factorization ?x›*)) (*goal: ‹prime_factorization (normalize (∏i::'a∈#(M::'a multiset). i)) = M›*) apply (subst prime_factorization_prod_mset_primes (*‹(⋀p. p ∈# ?A ⟹ prime p) ⟹ prime_factorization (∏⇩# ?A) = ?A›*)) (*goals: 1. ‹⋀p. ⟦∀p∈#M. prime p; ∀p∈#N. prime p; normalize (∏i∈#M. i) = normalize (∏i∈#N. i); p ∈# {#i. i ∈# M#}⟧ ⟹ prime p› 2. ‹⟦∀p∈#M. prime p; ∀p∈#N. prime p; normalize (∏i∈#M. i) = normalize (∏i∈#N. i)⟧ ⟹ {#i. i ∈# M#} = M› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) . also (*calculation: ‹M = prime_factorization (normalize (∏i∈#N. i))›*) from assms (*‹∀p∈#M. prime p› ‹∀p::'a∈#N::'a multiset. prime p› ‹normalize (∏i::'a∈#(M::'a multiset). i) = normalize (∏i::'a∈#(N::'a multiset). i)›*) have "prime_factorization (normalize (∏i ∈# N. i)) = N" apply (subst prime_factorization_normalize (*‹prime_factorization (normalize ?x) = prime_factorization ?x›*)) (*goal: ‹prime_factorization (normalize (∏i∈#N. i)) = N›*) apply (subst prime_factorization_prod_mset_primes (*‹(⋀p. p ∈# ?A ⟹ prime p) ⟹ prime_factorization (∏⇩# ?A) = ?A›*)) (*goals: 1. ‹⋀p. ⟦∀p∈#M. prime p; ∀p∈#N. prime p; normalize (∏i∈#M. i) = normalize (∏i∈#N. i); p ∈# {#i. i ∈# N#}⟧ ⟹ prime p› 2. ‹⟦∀p∈#M. prime p; ∀p∈#N. prime p; normalize (∏i∈#M. i) = normalize (∏i∈#N. i)⟧ ⟹ {#i. i ∈# N#} = N› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) . finally (*calculation: ‹M = N›*) show "?thesis" (*goal: ‹M = N›*) . qed lemma multiplicity_cong: "(⋀r. p ^ r dvd a ⟷ p ^ r dvd b) ⟹ multiplicity p a = multiplicity p b" by (simp add: multiplicity_def (*‹multiplicity ?p ?x = (if finite {n. ?p ^ n dvd ?x} then Max {n. ?p ^ n dvd ?x} else 0)›*)) lemma not_dvd_imp_multiplicity_0: assumes "¬p dvd x" shows "multiplicity p x = 0" proof (-) (*goal: ‹multiplicity p x = 0›*) from assms (*‹¬ p dvd x›*) have "multiplicity p x < 1" apply (intro multiplicity_lessI (*‹⟦?x ≠ 0; ¬ is_unit ?p; ¬ ?p ^ ?n dvd ?x⟧ ⟹ multiplicity ?p ?x < ?n›*)) (*goals: 1. ‹¬ p dvd x ⟹ x ≠ 0› 2. ‹¬ p dvd x ⟹ ¬ is_unit p› 3. ‹¬ p dvd x ⟹ ¬ p ^ 1 dvd x› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*proven 3 subgoals*) . thus "?thesis" (*goal: ‹multiplicity p x = 0›*) by simp qed lemma multiplicity_zero_left [simp]: "multiplicity 0 x = 0" apply (cases "x = 0") (*goals: 1. ‹x = 0 ⟹ multiplicity 0 x = 0› 2. ‹x ≠ 0 ⟹ multiplicity 0 x = 0› discuss goal 1*) apply ((auto intro: not_dvd_imp_multiplicity_0 (*‹¬ ?p dvd ?x ⟹ multiplicity ?p ?x = 0›*))[1]) (*discuss goal 2*) apply ((auto intro: not_dvd_imp_multiplicity_0 (*‹¬ ?p dvd ?x ⟹ multiplicity ?p ?x = 0›*))[1]) (*proven 2 subgoals*) . lemma inj_on_Prod_primes: assumes "⋀P p. P ∈ A ⟹ p ∈ P ⟹ prime p" assumes "⋀P. P ∈ A ⟹ finite P" shows "inj_on Prod A" proof (rule inj_onI (*‹(⋀x y. ⟦x ∈ ?A; y ∈ ?A; ?f x = ?f y⟧ ⟹ x = y) ⟹ inj_on ?f ?A›*)) (*goal: ‹⋀x y. ⟦x ∈ A; y ∈ A; ∏x = ∏y⟧ ⟹ x = y›*) fix P and Q assume PQ: "P ∈ A" "Q ∈ A" "∏P = ∏Q" (*‹(P::'a set) ∈ (A::'a set set)› ‹(Q::'a set) ∈ (A::'a set set)› ‹∏(P::'a set) = ∏(Q::'a set)›*) with prime_factorization_unique'[of "mset_set P" "mset_set Q"] (*‹⟦∀p∈#mset_set P. prime p; ∀p∈#mset_set Q. prime p; (∏i∈#mset_set P. i) = (∏i∈#mset_set Q. i)⟧ ⟹ mset_set P = mset_set Q›*) assms[of P] (*‹⟦P ∈ A; ?p1 ∈ P⟧ ⟹ prime ?p1› ‹P ∈ A ⟹ finite P›*) assms[of Q] (*‹⟦Q ∈ A; ?p1 ∈ Q⟧ ⟹ prime ?p1› ‹(Q::'a set) ∈ (A::'a set set) ⟹ finite Q›*) have "mset_set P = mset_set Q" by (auto simp: prod_unfold_prod_mset (*‹prod ?f ?A = ∏⇩# (image_mset ?f (mset_set ?A))›*)) with assms[of P] (*‹⟦P ∈ A; ?p1 ∈ P⟧ ⟹ prime ?p1› ‹P ∈ A ⟹ finite P›*) assms[of Q] (*‹⟦Q ∈ A; ?p1 ∈ Q⟧ ⟹ prime ?p1› ‹Q ∈ A ⟹ finite Q›*) PQ (*‹P ∈ A› ‹Q ∈ A› ‹∏(P::'a set) = ∏(Q::'a set)›*) show "P = Q" by simp qed lemma divides_primepow_weak: assumes "prime p" and "a dvd p ^ n" obtains m where "m ≤ n" and "normalize a = normalize (p ^ m)" proof (-) (*goal: ‹(⋀m. ⟦m ≤ n; normalize a = normalize (p ^ m)⟧ ⟹ thesis) ⟹ thesis›*) from assms (*‹prime p› ‹a dvd p ^ n›*) have "a ≠ 0" by auto with assms (*‹prime p› ‹a dvd p ^ n›*) have "normalize (prod_mset (prime_factorization a)) dvd normalize (prod_mset (prime_factorization (p ^ n)))" apply (subst (1 2) prod_mset_prime_factorization_weak (*‹?x ≠ 0 ⟹ normalize (∏⇩# (prime_factorization ?x)) = normalize ?x›*)) (*goals: 1. ‹⟦prime p; a dvd p ^ n; a ≠ 0⟧ ⟹ p ^ n ≠ 0› 2. ‹⟦prime p; a dvd p ^ n; a ≠ 0⟧ ⟹ a ≠ 0› 3. ‹⟦prime p; a dvd p ^ n; a ≠ 0⟧ ⟹ normalize a dvd normalize (p ^ n)› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*proven 3 subgoals*) . then have "prime_factorization a ⊆# prime_factorization (p ^ n)" by (simp add: in_prime_factors_imp_prime (*‹?p ∈ prime_factors ?x ⟹ prime ?p›*) prod_mset_dvd_prod_mset_primes_iff (*‹⟦⋀x. x ∈# ?A ⟹ prime x; ⋀x. x ∈# ?B ⟹ prime x⟧ ⟹ (∏⇩# ?A dvd ∏⇩# ?B) = (?A ⊆# ?B)›*)) with assms (*‹prime (p::'a)› ‹a dvd p ^ n›*) have "prime_factorization a ⊆# replicate_mset n p" by (simp add: prime_factorization_prime_power (*‹prime (?p::'a) ⟹ prime_factorization (?p ^ (?n::nat)) = replicate_mset ?n ?p›*)) then obtain m where "m ≤ n" and "prime_factorization a = replicate_mset m p" (*goal: ‹(⋀m. ⟦m ≤ n; prime_factorization a = replicate_mset m p⟧ ⟹ thesis) ⟹ thesis›*) by (rule msubseteq_replicate_msetE (*‹⟦?A ⊆# replicate_mset ?n ?a; ⋀m. ⟦m ≤ ?n; ?A = replicate_mset m ?a⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*)) then have "*": "normalize (prod_mset (prime_factorization a)) = normalize (prod_mset (replicate_mset m p))" by metis also (*calculation: ‹normalize (∏⇩# (prime_factorization a)) = normalize (∏⇩# (replicate_mset m p))›*) have "normalize (prod_mset (prime_factorization a)) = normalize a" using ‹a ≠ 0› (*‹a ≠ 0›*) by (simp add: prod_mset_prime_factorization_weak (*‹?x ≠ 0 ⟹ normalize (∏⇩# (prime_factorization ?x)) = normalize ?x›*)) also (*calculation: ‹normalize (a::'a::type) = normalize (∏⇩# (replicate_mset (m::nat) (p::'a::type)))›*) have "prod_mset (replicate_mset m p) = p ^ m" by simp finally (*calculation: ‹normalize a = normalize (p ^ m)›*) show "?thesis" (*goal: ‹thesis›*) using ‹m ≤ n› (*‹m ≤ n›*) apply (intro that[of m] (*‹⟦m ≤ n; normalize a = normalize (p ^ m)⟧ ⟹ thesis›*)) (*goals: 1. ‹⟦normalize a = normalize (p ^ m); m ≤ n⟧ ⟹ m ≤ n› 2. ‹⟦normalize a = normalize (p ^ m); m ≤ n⟧ ⟹ normalize a = normalize (p ^ m)› discuss goal 1*) apply ((assumption)[1]) (*discuss goal 2*) . (*proven 2 subgoals*) qed lemma divide_out_primepow_ex: assumes "n ≠ 0" "∃p∈prime_factors n. P p" obtains p k n' where "P p" "prime p" "p dvd n" "¬p dvd n'" "k > 0" "n = p ^ k * n'" proof (-) (*goal: ‹(⋀(p::'a) (n'::'a) k::nat. ⟦(P::'a ⇒ bool) p; prime p; p dvd (n::'a); ¬ p dvd n'; (0::nat) < k; n = p ^ k * n'⟧ ⟹ thesis::bool) ⟹ thesis›*) from assms (*‹n ≠ 0› ‹∃p∈prime_factors n. P p›*) obtain p where p: "P p" "prime p" "p dvd n" (*goal: ‹(⋀p. ⟦P p; prime p; p dvd n⟧ ⟹ thesis) ⟹ thesis›*) by auto define k where "k = multiplicity p n" define n' where "n' = n div p ^ k" have n': "n = p ^ k * n'" "¬p dvd n'" using assms (*‹n ≠ 0› ‹∃p∈prime_factors n. P p›*) p (*‹P p› ‹prime p› ‹p dvd n›*) multiplicity_decompose[of n p] (*‹⟦n ≠ 0; ¬ is_unit p⟧ ⟹ ¬ p dvd n div p ^ multiplicity p n›*) apply - (*goals: 1. ‹⟦n ≠ 0; ∃p∈prime_factors n. P p; P p; prime p; p dvd n; ⟦n ≠ 0; ¬ is_unit p⟧ ⟹ ¬ p dvd n div p ^ multiplicity p n⟧ ⟹ n = p ^ k * n'› 2. ‹⟦n ≠ 0; ∃p∈prime_factors n. P p; P p; prime p; p dvd n; ⟦n ≠ 0; ¬ is_unit p⟧ ⟹ ¬ p dvd n div p ^ multiplicity p n⟧ ⟹ ¬ p dvd n'› discuss goal 1*) apply ((auto simp: n'_def (*‹(n'::'a) = (n::'a) div (p::'a) ^ (k::nat)›*) k_def (*‹(k::nat) = multiplicity (p::'a) (n::'a)›*) multiplicity_dvd (*‹(?p::'a) ^ multiplicity ?p (?x::'a) dvd ?x›*))[1]) (*discuss goal 2*) apply ((auto simp: n'_def (*‹n' = n div p ^ k›*) k_def (*‹k = multiplicity p n›*) multiplicity_dvd (*‹?p ^ multiplicity ?p ?x dvd ?x›*))[1]) (*proven 2 subgoals*) . from n' (*‹n = p ^ k * n'› ‹¬ p dvd n'›*) p (*‹P p› ‹prime (p::'a)› ‹(p::'a) dvd (n::'a)›*) have "k > 0" apply (intro Nat.gr0I (*‹(?n = 0 ⟹ False) ⟹ 0 < ?n›*)) (*goal: ‹0 < k›*) by auto with n' (*‹n = p ^ k * n'› ‹¬ p dvd n'›*) p (*‹P p› ‹prime p› ‹p dvd n›*) that[of p n' k] (*‹⟦P p; prime p; p dvd n; ¬ p dvd n'; 0 < k; n = p ^ k * n'⟧ ⟹ thesis›*) show "?thesis" (*goal: ‹thesis›*) by auto qed lemma divide_out_primepow: assumes "n ≠ 0" "¬is_unit n" obtains p k n' where "prime p" "p dvd n" "¬p dvd n'" "k > 0" "n = p ^ k * n'" using divide_out_primepow_ex[OF assms ( 1 ), of "λ_. True"] (*‹⟦∃p∈prime_factors n. True; ⋀p k n'. ⟦True; prime p; p dvd n; ¬ p dvd n'; 0 < k; n = p ^ k * n'⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*) prime_divisor_exists[OF assms] (*‹∃b. b dvd n ∧ prime b›*) assms (*‹n ≠ 0› ‹¬ is_unit n›*) prime_factorsI (*‹⟦?x ≠ 0; prime ?p; ?p dvd ?x⟧ ⟹ ?p ∈ prime_factors ?x›*) by metis subsection ‹GCD and LCM computation with unique factorizations› definition "gcd_factorial a b = (if a = 0 then normalize b else if b = 0 then normalize a else normalize (prod_mset (prime_factorization a ∩# prime_factorization b)))" definition "lcm_factorial a b = (if a = 0 ∨ b = 0 then 0 else normalize (prod_mset (prime_factorization a ∪# prime_factorization b)))" definition "Gcd_factorial A = (if A ⊆ {0} then 0 else normalize (prod_mset (Inf (prime_factorization ` (A - {0})))))" definition "Lcm_factorial A = (if A = {} then 1 else if 0 ∉ A ∧ subset_mset.bdd_above (prime_factorization ` (A - {0})) then normalize (prod_mset (Sup (prime_factorization ` A))) else 0)" lemma prime_factorization_gcd_factorial: assumes [simp]: "a ≠ 0" "b ≠ 0" shows "prime_factorization (gcd_factorial a b) = prime_factorization a ∩# prime_factorization b" proof (-) (*goal: ‹prime_factorization (gcd_factorial a b) = prime_factorization a ∩# prime_factorization b›*) have "prime_factorization (gcd_factorial a b) = prime_factorization (prod_mset (prime_factorization a ∩# prime_factorization b))" by (simp add: gcd_factorial_def (*‹gcd_factorial (?a::'a) (?b::'a) = (if ?a = (0::'a) then normalize ?b else if ?b = (0::'a) then normalize ?a else normalize (∏⇩# (prime_factorization ?a ∩# prime_factorization ?b)))›*)) also (*calculation: ‹prime_factorization (gcd_factorial a b) = prime_factorization (∏⇩# (prime_factorization a ∩# prime_factorization b))›*) have "… = prime_factorization a ∩# prime_factorization b" apply (subst prime_factorization_prod_mset_primes (*‹(⋀p. p ∈# ?A ⟹ prime p) ⟹ prime_factorization (∏⇩# ?A) = ?A›*)) (*goals: 1. ‹⋀p. p ∈# prime_factorization a ∩# prime_factorization b ⟹ prime p› 2. ‹prime_factorization a ∩# prime_factorization b = prime_factorization a ∩# prime_factorization b› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . finally (*calculation: ‹prime_factorization (gcd_factorial a b) = prime_factorization a ∩# prime_factorization b›*) show "?thesis" (*goal: ‹prime_factorization (gcd_factorial a b) = prime_factorization a ∩# prime_factorization b›*) . qed lemma prime_factorization_lcm_factorial: assumes [simp]: "a ≠ 0" "b ≠ 0" shows "prime_factorization (lcm_factorial a b) = prime_factorization a ∪# prime_factorization b" proof (-) (*goal: ‹prime_factorization (lcm_factorial a b) = prime_factorization a ∪# prime_factorization b›*) have "prime_factorization (lcm_factorial a b) = prime_factorization (prod_mset (prime_factorization a ∪# prime_factorization b))" by (simp add: lcm_factorial_def (*‹lcm_factorial ?a ?b = (if ?a = 0 ∨ ?b = 0 then 0 else normalize (∏⇩# (prime_factorization ?a ∪# prime_factorization ?b)))›*)) also (*calculation: ‹prime_factorization (lcm_factorial a b) = prime_factorization (∏⇩# (prime_factorization a ∪# prime_factorization b))›*) have "… = prime_factorization a ∪# prime_factorization b" apply (subst prime_factorization_prod_mset_primes (*‹(⋀p. p ∈# ?A ⟹ prime p) ⟹ prime_factorization (∏⇩# ?A) = ?A›*)) (*goals: 1. ‹⋀p::'a::type. p ∈# prime_factorization (a::'a::type) ∪# prime_factorization (b::'a::type) ⟹ prime p› 2. ‹prime_factorization (a::'a::type) ∪# prime_factorization (b::'a::type) = prime_factorization a ∪# prime_factorization b› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . finally (*calculation: ‹prime_factorization (lcm_factorial a b) = prime_factorization a ∪# prime_factorization b›*) show "?thesis" (*goal: ‹prime_factorization (lcm_factorial a b) = prime_factorization a ∪# prime_factorization b›*) . qed lemma prime_factorization_Gcd_factorial: assumes "¬A ⊆ {0}" shows "prime_factorization (Gcd_factorial A) = Inf (prime_factorization ` (A - {0}))" proof (-) (*goal: ‹prime_factorization (Gcd_factorial A) = Inf (prime_factorization ` (A - {0}))›*) from assms (*‹¬ A ⊆ {0}›*) obtain x where x: "x ∈ A - {0}" (*goal: ‹(⋀x. x ∈ A - {0} ⟹ thesis) ⟹ thesis›*) by auto hence "Inf (prime_factorization ` (A - {0})) ⊆# prime_factorization x" apply (intro subset_mset.cInf_lower (*‹⟦?x ∈ ?X; subset_mset.bdd_below ?X⟧ ⟹ Inf ?X ⊆# ?x›*)) (*goals: 1. ‹x ∈ A - {0} ⟹ prime_factorization x ∈ prime_factorization ` (A - {0})› 2. ‹x ∈ A - {0} ⟹ subset_mset.bdd_below (prime_factorization ` (A - {0}))› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) . hence "∀y. y ∈# Inf (prime_factorization ` (A - {0})) ⟶ y ∈ prime_factors x" by (auto dest: mset_subset_eqD (*‹⟦?A ⊆# ?B; ?x ∈# ?A⟧ ⟹ ?x ∈# ?B›*)) with in_prime_factors_imp_prime[of _ x] (*‹?p ∈ prime_factors x ⟹ prime ?p›*) have "∀p. p ∈# Inf (prime_factorization ` (A - {0})) ⟶ prime p" by blast with assms (*‹¬ A ⊆ {0}›*) show "?thesis" (*goal: ‹prime_factorization (Gcd_factorial A) = Inf (prime_factorization ` (A - {0}))›*) by (simp add: Gcd_factorial_def (*‹Gcd_factorial ?A = (if ?A ⊆ {0} then 0 else normalize (∏⇩# (Inf (prime_factorization ` (?A - {0})))))›*) prime_factorization_prod_mset_primes (*‹(⋀p. p ∈# ?A ⟹ prime p) ⟹ prime_factorization (∏⇩# ?A) = ?A›*)) qed lemma prime_factorization_Lcm_factorial: assumes "0 ∉ A" "subset_mset.bdd_above (prime_factorization ` A)" shows "prime_factorization (Lcm_factorial A) = Sup (prime_factorization ` A)" proof (cases "A = {}") (*goals: 1. ‹A = {} ⟹ prime_factorization (Lcm_factorial A) = Sup (prime_factorization ` A)› 2. ‹A ≠ {} ⟹ prime_factorization (Lcm_factorial A) = Sup (prime_factorization ` A)›*) case True (*‹A = {}›*) hence "prime_factorization ` A = {}" by auto also (*calculation: ‹prime_factorization ` A = {}›*) have "Sup … = {#}" by (simp add: Sup_multiset_empty (*‹Sup {} = {#}›*)) finally (*calculation: ‹Sup (prime_factorization ` A) = {#}›*) show "?thesis" (*goal: ‹prime_factorization (Lcm_factorial A) = Sup (prime_factorization ` A)›*) by (simp add: Lcm_factorial_def (*‹Lcm_factorial ?A = (if ?A = {} then 1 else if 0 ∉ ?A ∧ subset_mset.bdd_above (prime_factorization ` (?A - {0})) then normalize (∏⇩# (Sup (prime_factorization ` ?A))) else 0)›*)) next (*goal: ‹A ≠ {} ⟹ prime_factorization (Lcm_factorial A) = Sup (prime_factorization ` A)›*) case False (*‹A ≠ {}›*) have "∀y. y ∈# Sup (prime_factorization ` A) ⟶ prime y" by (auto simp: in_Sup_multiset_iff (*‹subset_mset.bdd_above ?A ⟹ (?x ∈# Sup ?A) = (∃X∈?A. ?x ∈# X)›*) assms (*‹0 ∉ A› ‹subset_mset.bdd_above (prime_factorization ` A)›*)) with assms (*‹0 ∉ A› ‹subset_mset.bdd_above (prime_factorization ` A)›*) False (*‹A ≠ {}›*) show "?thesis" (*goal: ‹prime_factorization (Lcm_factorial A) = Sup (prime_factorization ` A)›*) by (simp add: Lcm_factorial_def (*‹Lcm_factorial (?A::'a set) = (if ?A = {} then 1::'a else if (0::'a) ∉ ?A ∧ subset_mset.bdd_above (prime_factorization ` (?A - {0::'a})) then normalize (∏⇩# (Sup (prime_factorization ` ?A))) else (0::'a))›*) prime_factorization_prod_mset_primes (*‹(⋀p::'a. p ∈# (?A::'a multiset) ⟹ prime p) ⟹ prime_factorization (∏⇩# ?A) = ?A›*)) qed lemma gcd_factorial_commute: "gcd_factorial a b = gcd_factorial b a" by (simp add: gcd_factorial_def (*‹gcd_factorial ?a ?b = (if ?a = 0 then normalize ?b else if ?b = 0 then normalize ?a else normalize (∏⇩# (prime_factorization ?a ∩# prime_factorization ?b)))›*) multiset_inter_commute (*‹?A ∩# ?B = ?B ∩# ?A›*)) lemma gcd_factorial_dvd1: "gcd_factorial a b dvd a" proof (cases "a = 0 ∨ b = 0") (*goals: 1. ‹a = 0 ∨ b = 0 ⟹ gcd_factorial a b dvd a› 2. ‹¬ (a = 0 ∨ b = 0) ⟹ gcd_factorial a b dvd a›*) case False (*‹¬ (a = 0 ∨ b = 0)›*) hence "gcd_factorial a b ≠ 0" by (auto simp: gcd_factorial_def (*‹gcd_factorial ?a ?b = (if ?a = 0 then normalize ?b else if ?b = 0 then normalize ?a else normalize (∏⇩# (prime_factorization ?a ∩# prime_factorization ?b)))›*)) with False (*‹¬ (a = 0 ∨ b = 0)›*) show "?thesis" (*goal: ‹gcd_factorial a b dvd a›*) apply (subst prime_factorization_subset_iff_dvd [symmetric] (*‹⟦?x ≠ 0; ?y ≠ 0⟧ ⟹ (?x dvd ?y) = (prime_factorization ?x ⊆# prime_factorization ?y)›*)) (*goals: 1. ‹⟦¬ (a = 0 ∨ b = 0); gcd_factorial a b ≠ 0⟧ ⟹ gcd_factorial a b ≠ 0› 2. ‹⟦¬ (a = 0 ∨ b = 0); gcd_factorial a b ≠ 0⟧ ⟹ a ≠ 0› 3. ‹⟦¬ (a = 0 ∨ b = 0); gcd_factorial a b ≠ 0⟧ ⟹ prime_factorization (gcd_factorial a b) ⊆# prime_factorization a› discuss goal 1*) apply ((auto simp: prime_factorization_gcd_factorial (*‹⟦?a ≠ 0; ?b ≠ 0⟧ ⟹ prime_factorization (gcd_factorial ?a ?b) = prime_factorization ?a ∩# prime_factorization ?b›*))[1]) (*discuss goal 2*) apply ((auto simp: prime_factorization_gcd_factorial (*‹⟦?a ≠ 0; ?b ≠ 0⟧ ⟹ prime_factorization (gcd_factorial ?a ?b) = prime_factorization ?a ∩# prime_factorization ?b›*))[1]) (*discuss goal 3*) apply ((auto simp: prime_factorization_gcd_factorial (*‹⟦(?a::'a) ≠ (0::'a); (?b::'a) ≠ (0::'a)⟧ ⟹ prime_factorization (gcd_factorial ?a ?b) = prime_factorization ?a ∩# prime_factorization ?b›*))[1]) (*proven 3 subgoals*) . qed (auto simp: gcd_factorial_def (*‹gcd_factorial ?a ?b = (if ?a = 0 then normalize ?b else if ?b = 0 then normalize ?a else normalize (∏⇩# (prime_factorization ?a ∩# prime_factorization ?b)))›*)) (*solved the remaining goal: ‹(a::'a) = (0::'a) ∨ (b::'a) = (0::'a) ⟹ gcd_factorial a b dvd a›*) lemma gcd_factorial_dvd2: "gcd_factorial a b dvd b" apply (subst gcd_factorial_commute (*‹gcd_factorial ?a ?b = gcd_factorial ?b ?a›*)) (*goal: ‹gcd_factorial a b dvd b›*) by (rule gcd_factorial_dvd1 (*‹gcd_factorial ?a ?b dvd ?a›*)) lemma normalize_gcd_factorial [simp]: "normalize (gcd_factorial a b) = gcd_factorial a b" by (simp add: gcd_factorial_def (*‹gcd_factorial ?a ?b = (if ?a = 0 then normalize ?b else if ?b = 0 then normalize ?a else normalize (∏⇩# (prime_factorization ?a ∩# prime_factorization ?b)))›*)) lemma normalize_lcm_factorial [simp]: "normalize (lcm_factorial a b) = lcm_factorial a b" by (simp add: lcm_factorial_def (*‹lcm_factorial (?a::'a::type) (?b::'a::type) = (if ?a = (0::'a::type) ∨ ?b = (0::'a::type) then 0::'a::type else normalize (∏⇩# (prime_factorization ?a ∪# prime_factorization ?b)))›*)) lemma gcd_factorial_greatest: "c dvd gcd_factorial a b" if "c dvd a" "c dvd b" for a b c proof (cases "a = 0 ∨ b = 0") (*goals: 1. ‹a = 0 ∨ b = 0 ⟹ c dvd gcd_factorial a b› 2. ‹¬ (a = 0 ∨ b = 0) ⟹ c dvd gcd_factorial a b›*) case False (*‹¬ (a = 0 ∨ b = 0)›*) with that (*‹c dvd a› ‹c dvd b›*) have [simp]: "c ≠ 0" by auto let ?p = prime_factorization from that (*‹c dvd a› ‹(c::'a) dvd (b::'a)›*) False (*‹¬ (a = 0 ∨ b = 0)›*) have "?p c ⊆# ?p a" "?p c ⊆# ?p b" apply - (*goals: 1. ‹⟦(c::'a) dvd (a::'a); c dvd (b::'a); ¬ (a = (0::'a) ∨ b = (0::'a))⟧ ⟹ prime_factorization c ⊆# prime_factorization a› 2. ‹⟦(c::'a) dvd (a::'a); c dvd (b::'a); ¬ (a = (0::'a) ∨ b = (0::'a))⟧ ⟹ prime_factorization c ⊆# prime_factorization b› discuss goal 1*) apply (simp add: prime_factorization_subset_iff_dvd (*‹⟦?x ≠ 0; ?y ≠ 0⟧ ⟹ (prime_factorization ?x ⊆# prime_factorization ?y) = (?x dvd ?y)›*)) (*discuss goal 2*) apply (simp add: prime_factorization_subset_iff_dvd (*‹⟦?x ≠ 0; ?y ≠ 0⟧ ⟹ (prime_factorization ?x ⊆# prime_factorization ?y) = (?x dvd ?y)›*)) (*proven 2 subgoals*) . hence "prime_factorization c ⊆# prime_factorization (prod_mset (prime_factorization a ∩# prime_factorization b))" using False (*‹¬ ((a::'a) = (0::'a) ∨ (b::'a) = (0::'a))›*) apply (subst prime_factorization_prod_mset_primes (*‹(⋀p. p ∈# ?A ⟹ prime p) ⟹ prime_factorization (∏⇩# ?A) = ?A›*)) (*goals: 1. ‹⋀p. ⟦prime_factorization c ⊆# prime_factorization a; prime_factorization c ⊆# prime_factorization b; ¬ (a = 0 ∨ b = 0); p ∈# prime_factorization a ∩# prime_factorization b⟧ ⟹ prime p› 2. ‹⟦prime_factorization c ⊆# prime_factorization a; prime_factorization c ⊆# prime_factorization b; ¬ (a = 0 ∨ b = 0)⟧ ⟹ prime_factorization c ⊆# prime_factorization a ∩# prime_factorization b› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . with False (*‹¬ (a = 0 ∨ b = 0)›*) show "?thesis" (*goal: ‹(c::'a::type) dvd gcd_factorial (a::'a::type) (b::'a::type)›*) by (auto simp: gcd_factorial_def (*‹gcd_factorial ?a ?b = (if ?a = 0 then normalize ?b else if ?b = 0 then normalize ?a else normalize (∏⇩# (prime_factorization ?a ∩# prime_factorization ?b)))›*) prime_factorization_subset_iff_dvd [symmetric] (*‹⟦?x ≠ 0; ?y ≠ 0⟧ ⟹ (?x dvd ?y) = (prime_factorization ?x ⊆# prime_factorization ?y)›*)) qed (auto simp: gcd_factorial_def (*‹gcd_factorial ?a ?b = (if ?a = 0 then normalize ?b else if ?b = 0 then normalize ?a else normalize (∏⇩# (prime_factorization ?a ∩# prime_factorization ?b)))›*) that (*‹c dvd a› ‹c dvd b›*)) (*solved the remaining goal: ‹a = 0 ∨ b = 0 ⟹ c dvd gcd_factorial a b›*) lemma lcm_factorial_gcd_factorial: "lcm_factorial a b = normalize (a * b div gcd_factorial a b)" for a b proof (cases "a = 0 ∨ b = 0") (*goals: 1. ‹a = 0 ∨ b = 0 ⟹ lcm_factorial a b = normalize (a * b div gcd_factorial a b)› 2. ‹¬ (a = 0 ∨ b = 0) ⟹ lcm_factorial a b = normalize (a * b div gcd_factorial a b)›*) case False (*‹¬ (a = 0 ∨ b = 0)›*) let ?p = prime_factorization have 1: "normalize x * normalize y dvd z ⟷ x * y dvd z" for x :: 'a and y :: 'a and z :: 'a proof (-) (*goal: ‹(normalize x * normalize y dvd z) = (x * y dvd z)›*) have "normalize (normalize x * normalize y) dvd z ⟷ x * y dvd z" unfolding normalize_mult_normalize_left normalize_mult_normalize_right (*goal: ‹(normalize ((x::'a::type) * (y::'a::type)) dvd (z::'a::type)) = (x * y dvd z)›*) by simp thus "?thesis" (*goal: ‹(normalize x * normalize y dvd z) = (x * y dvd z)›*) unfolding normalize_dvd_iff (*goal: ‹(normalize x * normalize y dvd z) = (x * y dvd z)›*) by simp qed have "?p (a * b) = (?p a ∪# ?p b) + (?p a ∩# ?p b)" using False (*‹¬ (a = 0 ∨ b = 0)›*) apply (subst prime_factorization_mult (*‹⟦?x ≠ 0; ?y ≠ 0⟧ ⟹ prime_factorization (?x * ?y) = prime_factorization ?x + prime_factorization ?y›*)) (*goals: 1. ‹¬ (a = 0 ∨ b = 0) ⟹ a ≠ 0› 2. ‹¬ (a = 0 ∨ b = 0) ⟹ b ≠ 0› 3. ‹¬ (a = 0 ∨ b = 0) ⟹ prime_factorization a + prime_factorization b = prime_factorization a ∪# prime_factorization b + prime_factorization a ∩# prime_factorization b› discuss goal 1*) apply ((auto intro!: multiset_eqI (*‹(⋀x::?'a. count (?A::?'a multiset) x = count (?B::?'a multiset) x) ⟹ ?A = ?B›*))[1]) (*discuss goal 2*) apply ((auto intro!: multiset_eqI (*‹(⋀x::?'a::type. count (?A::?'a::type multiset) x = count (?B::?'a::type multiset) x) ⟹ ?A = ?B›*))[1]) (*discuss goal 3*) apply ((auto intro!: multiset_eqI (*‹(⋀x. count ?A x = count ?B x) ⟹ ?A = ?B›*))[1]) (*proven 3 subgoals*) . hence "normalize (prod_mset (?p (a * b))) = normalize (prod_mset ((?p a ∪# ?p b) + (?p a ∩# ?p b)))" by (simp only:) hence "*": "normalize (a * b) = normalize (lcm_factorial a b * gcd_factorial a b)" using False (*‹¬ (a = 0 ∨ b = 0)›*) apply (subst (asm) prod_mset_prime_factorization_weak (*‹?x ≠ 0 ⟹ normalize (∏⇩# (prime_factorization ?x)) = normalize ?x›*)) (*goals: 1. ‹¬ (a = 0 ∨ b = 0) ⟹ a * b ≠ 0› 2. ‹⟦normalize (a * b) = normalize (∏⇩# (prime_factorization a ∪# prime_factorization b + prime_factorization a ∩# prime_factorization b)); ¬ (a = 0 ∨ b = 0)⟧ ⟹ normalize (a * b) = normalize (lcm_factorial a b * gcd_factorial a b)› discuss goal 1*) apply ((auto simp: lcm_factorial_def (*‹lcm_factorial (?a::'a) (?b::'a) = (if ?a = (0::'a) ∨ ?b = (0::'a) then 0::'a else normalize (∏⇩# (prime_factorization ?a ∪# prime_factorization ?b)))›*) gcd_factorial_def (*‹gcd_factorial (?a::'a) (?b::'a) = (if ?a = (0::'a) then normalize ?b else if ?b = (0::'a) then normalize ?a else normalize (∏⇩# (prime_factorization ?a ∩# prime_factorization ?b)))›*))[1]) (*discuss goal 2*) apply ((auto simp: lcm_factorial_def (*‹lcm_factorial ?a ?b = (if ?a = 0 ∨ ?b = 0 then 0 else normalize (∏⇩# (prime_factorization ?a ∪# prime_factorization ?b)))›*) gcd_factorial_def (*‹gcd_factorial ?a ?b = (if ?a = 0 then normalize ?b else if ?b = 0 then normalize ?a else normalize (∏⇩# (prime_factorization ?a ∩# prime_factorization ?b)))›*))[1]) (*proven 2 subgoals*) . have [simp]: "gcd_factorial a b dvd a * b" "lcm_factorial a b dvd a * b" using associatedD2[OF *] (*‹lcm_factorial a b * gcd_factorial a b dvd a * b›*) apply - (*goals: 1. ‹lcm_factorial (a::'a::type) (b::'a::type) * gcd_factorial a b dvd a * b ⟹ gcd_factorial a b dvd a * b› 2. ‹lcm_factorial (a::'a::type) (b::'a::type) * gcd_factorial a b dvd a * b ⟹ lcm_factorial a b dvd a * b› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . from False (*‹¬ (a = 0 ∨ b = 0)›*) have [simp]: "gcd_factorial a b ≠ 0" "lcm_factorial a b ≠ 0" apply - (*goals: 1. ‹¬ ((a::'a::type) = (0::'a::type) ∨ (b::'a::type) = (0::'a::type)) ⟹ gcd_factorial a b ≠ (0::'a::type)› 2. ‹¬ ((a::'a::type) = (0::'a::type) ∨ (b::'a::type) = (0::'a::type)) ⟹ lcm_factorial a b ≠ (0::'a::type)› discuss goal 1*) apply ((auto simp: gcd_factorial_def (*‹gcd_factorial ?a ?b = (if ?a = 0 then normalize ?b else if ?b = 0 then normalize ?a else normalize (∏⇩# (prime_factorization ?a ∩# prime_factorization ?b)))›*) lcm_factorial_def (*‹lcm_factorial ?a ?b = (if ?a = 0 ∨ ?b = 0 then 0 else normalize (∏⇩# (prime_factorization ?a ∪# prime_factorization ?b)))›*))[1]) (*discuss goal 2*) apply ((auto simp: gcd_factorial_def (*‹gcd_factorial ?a ?b = (if ?a = 0 then normalize ?b else if ?b = 0 then normalize ?a else normalize (∏⇩# (prime_factorization ?a ∩# prime_factorization ?b)))›*) lcm_factorial_def (*‹lcm_factorial ?a ?b = (if ?a = 0 ∨ ?b = 0 then 0 else normalize (∏⇩# (prime_factorization ?a ∪# prime_factorization ?b)))›*))[1]) (*proven 2 subgoals*) . show "?thesis" (*goal: ‹lcm_factorial a b = normalize (a * b div gcd_factorial a b)›*) apply (rule associated_eqI (*‹⟦?a dvd ?b; ?b dvd ?a; normalize ?a = ?a; normalize ?b = ?b⟧ ⟹ ?a = ?b›*)) (*goals: 1. ‹lcm_factorial (a::'a::type) (b::'a::type) dvd normalize (a * b div gcd_factorial a b)› 2. ‹normalize ((a::'a::type) * (b::'a::type) div gcd_factorial a b) dvd lcm_factorial a b› 3. ‹normalize (lcm_factorial (a::'a::type) (b::'a::type)) = lcm_factorial a b› 4. ‹normalize (normalize ((a::'a::type) * (b::'a::type) div gcd_factorial a b)) = normalize (a * b div gcd_factorial a b)› discuss goal 1*) apply ((use * in ‹auto simp: dvd_div_iff_mult div_dvd_iff_mult dest: associatedD1 associatedD2›)[1]) (*discuss goal 2*) apply ((use * in ‹auto simp: dvd_div_iff_mult div_dvd_iff_mult dest: associatedD1 associatedD2›)[1]) (*discuss goal 3*) apply ((use * in ‹auto simp: dvd_div_iff_mult div_dvd_iff_mult dest: associatedD1 associatedD2›)[1]) (*discuss goal 4*) apply ((use * in ‹auto simp: dvd_div_iff_mult div_dvd_iff_mult dest: associatedD1 associatedD2›)[1]) (*proven 4 subgoals*) . qed (auto simp: lcm_factorial_def (*‹lcm_factorial (?a::'a::type) (?b::'a::type) = (if ?a = (0::'a::type) ∨ ?b = (0::'a::type) then 0::'a::type else normalize (∏⇩# (prime_factorization ?a ∪# prime_factorization ?b)))›*)) (*solved the remaining goal: ‹a = 0 ∨ b = 0 ⟹ lcm_factorial a b = normalize (a * b div gcd_factorial a b)›*) lemma normalize_Gcd_factorial: "normalize (Gcd_factorial A) = Gcd_factorial A" by (simp add: Gcd_factorial_def (*‹Gcd_factorial ?A = (if ?A ⊆ {0} then 0 else normalize (∏⇩# (Inf (prime_factorization ` (?A - {0})))))›*)) lemma Gcd_factorial_eq_0_iff: "Gcd_factorial A = 0 ⟷ A ⊆ {0}" by (auto simp: Gcd_factorial_def (*‹Gcd_factorial ?A = (if ?A ⊆ {0} then 0 else normalize (∏⇩# (Inf (prime_factorization ` (?A - {0})))))›*) in_Inf_multiset_iff (*‹?A ≠ {} ⟹ (?x ∈# Inf ?A) = (∀X∈?A. ?x ∈# 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))›*)) lemma Gcd_factorial_dvd: assumes "x ∈ A" shows "Gcd_factorial A dvd x" proof (cases "x = 0") (*goals: 1. ‹x = 0 ⟹ Gcd_factorial A dvd x› 2. ‹x ≠ 0 ⟹ Gcd_factorial A dvd x›*) case False (*‹x ≠ 0›*) with assms (*‹x ∈ A›*) have "prime_factorization (Gcd_factorial A) = Inf (prime_factorization ` (A - {0}))" apply (intro prime_factorization_Gcd_factorial (*‹¬ (?A::'a set) ⊆ {0::'a} ⟹ prime_factorization (Gcd_factorial ?A) = Inf (prime_factorization ` (?A - {0::'a}))›*)) (*goal: ‹prime_factorization (Gcd_factorial A) = Inf (prime_factorization ` (A - {0}))›*) by auto also (*calculation: ‹prime_factorization (Gcd_factorial (A::'a::type set)) = Inf (prime_factorization ` (A - {0::'a::type}))›*) from False (*‹x ≠ 0›*) assms (*‹x ∈ A›*) have "… ⊆# prime_factorization x" apply (intro subset_mset.cInf_lower (*‹⟦?x ∈ ?X; subset_mset.bdd_below ?X⟧ ⟹ Inf ?X ⊆# ?x›*)) (*goals: 1. ‹⟦x ≠ 0; x ∈ A⟧ ⟹ prime_factorization x ∈ prime_factorization ` (A - {0})› 2. ‹⟦x ≠ 0; x ∈ A⟧ ⟹ subset_mset.bdd_below (prime_factorization ` (A - {0}))› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . finally (*calculation: ‹prime_factorization (Gcd_factorial (A::'a set)) ⊆# prime_factorization (x::'a)›*) show "?thesis" (*goal: ‹Gcd_factorial A dvd x›*) apply (subst (asm) prime_factorization_subset_iff_dvd (*‹⟦?x ≠ 0; ?y ≠ 0⟧ ⟹ (prime_factorization ?x ⊆# prime_factorization ?y) = (?x dvd ?y)›*)) (*goals: 1. ‹Gcd_factorial A ≠ 0› 2. ‹x ≠ 0› 3. ‹Gcd_factorial A dvd x ⟹ Gcd_factorial A dvd x› discuss goal 1*) apply ((insert assms (*‹x ∈ A›*) False (*‹x ≠ 0›*))[1]) (*top goal: ‹Gcd_factorial (A::'a::type set) ≠ (0::'a::type)› and 2 goals remain*) apply ((auto simp: Gcd_factorial_eq_0_iff (*‹(Gcd_factorial ?A = 0) = (?A ⊆ {0})›*))[1]) (*discuss goal 2*) apply ((insert assms (*‹(x::'a::type) ∈ (A::'a::type set)›*) False (*‹(x::'a::type) ≠ (0::'a::type)›*))[1]) (*top goal: ‹x ≠ 0› and 1 goal remains*) apply ((auto simp: Gcd_factorial_eq_0_iff (*‹(Gcd_factorial ?A = 0) = (?A ⊆ {0})›*))[1]) (*discuss goal 3*) apply ((insert assms (*‹(x::'a) ∈ (A::'a set)›*) False (*‹(x::'a) ≠ (0::'a)›*))[1]) (*goal: ‹Gcd_factorial A dvd x ⟹ Gcd_factorial A dvd x›*) apply ((auto simp: Gcd_factorial_eq_0_iff (*‹(Gcd_factorial (?A::'a::type set) = (0::'a::type)) = (?A ⊆ {0::'a::type})›*))[1]) (*proven 3 subgoals*) . qed (simp_all) (*solved the remaining goal: ‹x = 0 ⟹ Gcd_factorial A dvd x›*) lemma Gcd_factorial_greatest: assumes "⋀y. y ∈ A ⟹ x dvd y" shows "x dvd Gcd_factorial A" proof (cases "A ⊆ {0}") (*goals: 1. ‹A ⊆ {0} ⟹ x dvd Gcd_factorial A› 2. ‹¬ A ⊆ {0} ⟹ x dvd Gcd_factorial A›*) case False (*‹¬ A ⊆ {0}›*) from False (*‹¬ A ⊆ {0}›*) obtain y where "y ∈ A" "y ≠ 0" (*goal: ‹(⋀y. ⟦y ∈ A; y ≠ 0⟧ ⟹ thesis) ⟹ thesis›*) by auto with assms[of y] (*‹y ∈ A ⟹ x dvd y›*) have nz: "x ≠ 0" by auto from nz (*‹(x::'a) ≠ (0::'a)›*) assms (*‹?y1 ∈ A ⟹ x dvd ?y1›*) have "prime_factorization x ⊆# prime_factorization y" if "y ∈ A - {0}" for y using that (*‹y ∈ A - {0}›*) apply (subst prime_factorization_subset_iff_dvd (*‹⟦(?x::'a) ≠ (0::'a); (?y::'a) ≠ (0::'a)⟧ ⟹ (prime_factorization ?x ⊆# prime_factorization ?y) = (?x dvd ?y)›*)) (*goals: 1. ‹⟦(x::'a) ≠ (0::'a); ⋀y::'a. y ∈ (A::'a set) ⟹ x dvd y; (y::'a) ∈ A - {0::'a}⟧ ⟹ x ≠ (0::'a)› 2. ‹⟦(x::'a) ≠ (0::'a); ⋀y::'a. y ∈ (A::'a set) ⟹ x dvd y; (y::'a) ∈ A - {0::'a}⟧ ⟹ y ≠ (0::'a)› 3. ‹⟦(x::'a) ≠ (0::'a); ⋀y::'a. y ∈ (A::'a set) ⟹ x dvd y; (y::'a) ∈ A - {0::'a}⟧ ⟹ x dvd y› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*proven 3 subgoals*) . with False (*‹¬ A ⊆ {0}›*) have "prime_factorization x ⊆# Inf (prime_factorization ` (A - {0}))" apply (intro subset_mset.cInf_greatest (*‹⟦(?X::?'a multiset set) ≠ {}; ⋀x::?'a multiset. x ∈ ?X ⟹ (?z::?'a multiset) ⊆# x⟧ ⟹ ?z ⊆# Inf ?X›*)) (*goals: 1. ‹⟦¬ A ⊆ {0}; ⋀y. y ∈ A - {0} ⟹ prime_factorization x ⊆# prime_factorization y⟧ ⟹ prime_factorization ` (A - {0}) ≠ {}› 2. ‹⋀xa. ⟦¬ A ⊆ {0}; ⋀y. y ∈ A - {0} ⟹ prime_factorization x ⊆# prime_factorization y; xa ∈ prime_factorization ` (A - {0})⟧ ⟹ prime_factorization x ⊆# xa› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . also (*calculation: ‹prime_factorization x ⊆# Inf (prime_factorization ` (A - {0}))›*) from False (*‹¬ A ⊆ {0}›*) have "… = prime_factorization (Gcd_factorial A)" by (rule prime_factorization_Gcd_factorial [symmetric] (*‹¬ ?A ⊆ {0} ⟹ Inf (prime_factorization ` (?A - {0})) = prime_factorization (Gcd_factorial ?A)›*)) finally (*calculation: ‹prime_factorization x ⊆# prime_factorization (Gcd_factorial A)›*) show "?thesis" (*goal: ‹x dvd Gcd_factorial A›*) apply (subst (asm) prime_factorization_subset_iff_dvd (*‹⟦?x ≠ 0; ?y ≠ 0⟧ ⟹ (prime_factorization ?x ⊆# prime_factorization ?y) = (?x dvd ?y)›*)) (*goals: 1. ‹x ≠ 0› 2. ‹Gcd_factorial A ≠ 0› 3. ‹x dvd Gcd_factorial A ⟹ x dvd Gcd_factorial A› discuss goal 1*) apply ((insert nz (*‹x ≠ 0›*) False (*‹¬ A ⊆ {0}›*))[1]) (*top goal: ‹x ≠ 0› and 2 goals remain*) apply ((auto simp: Gcd_factorial_eq_0_iff (*‹(Gcd_factorial ?A = 0) = (?A ⊆ {0})›*))[1]) (*discuss goal 2*) apply ((insert nz (*‹(x::'a) ≠ (0::'a)›*) False (*‹¬ (A::'a set) ⊆ {0::'a}›*))[1]) (*top goal: ‹Gcd_factorial A ≠ 0› and 1 goal remains*) apply ((auto simp: Gcd_factorial_eq_0_iff (*‹(Gcd_factorial ?A = 0) = (?A ⊆ {0})›*))[1]) (*discuss goal 3*) apply ((insert nz (*‹x ≠ 0›*) False (*‹¬ A ⊆ {0}›*))[1]) (*goal: ‹(x::'a) dvd Gcd_factorial (A::'a set) ⟹ x dvd Gcd_factorial A›*) apply ((auto simp: Gcd_factorial_eq_0_iff (*‹(Gcd_factorial ?A = 0) = (?A ⊆ {0})›*))[1]) (*proven 3 subgoals*) . qed (simp_all add: Gcd_factorial_def) (*solved the remaining goal: ‹(A::'a set) ⊆ {0::'a} ⟹ (x::'a) dvd Gcd_factorial A›*) lemma normalize_Lcm_factorial: "normalize (Lcm_factorial A) = Lcm_factorial A" by (simp add: Lcm_factorial_def (*‹Lcm_factorial ?A = (if ?A = {} then 1 else if 0 ∉ ?A ∧ subset_mset.bdd_above (prime_factorization ` (?A - {0})) then normalize (∏⇩# (Sup (prime_factorization ` ?A))) else 0)›*)) lemma Lcm_factorial_eq_0_iff: "Lcm_factorial A = 0 ⟷ 0 ∈ A ∨ ¬subset_mset.bdd_above (prime_factorization ` A)" by (auto simp: Lcm_factorial_def (*‹Lcm_factorial ?A = (if ?A = {} then 1 else if 0 ∉ ?A ∧ subset_mset.bdd_above (prime_factorization ` (?A - {0})) then normalize (∏⇩# (Sup (prime_factorization ` ?A))) else 0)›*) in_Sup_multiset_iff (*‹subset_mset.bdd_above ?A ⟹ (?x ∈# Sup ?A) = (∃X∈?A. ?x ∈# X)›*)) lemma dvd_Lcm_factorial: assumes "x ∈ A" shows "x dvd Lcm_factorial A" proof (cases "0 ∉ A ∧ subset_mset.bdd_above (prime_factorization ` A)") (*goals: 1. ‹0 ∉ A ∧ subset_mset.bdd_above (prime_factorization ` A) ⟹ x dvd Lcm_factorial A› 2. ‹¬ (0 ∉ A ∧ subset_mset.bdd_above (prime_factorization ` A)) ⟹ x dvd Lcm_factorial A›*) case True (*‹(0::'a) ∉ (A::'a set) ∧ subset_mset.bdd_above (prime_factorization ` A)›*) with assms (*‹x ∈ A›*) have [simp]: "0 ∉ A" "x ≠ 0" "A ≠ {}" apply - (*goals: 1. ‹⟦x ∈ A; 0 ∉ A ∧ subset_mset.bdd_above (prime_factorization ` A)⟧ ⟹ 0 ∉ A› 2. ‹⟦x ∈ A; 0 ∉ A ∧ subset_mset.bdd_above (prime_factorization ` A)⟧ ⟹ x ≠ 0› 3. ‹⟦x ∈ A; 0 ∉ A ∧ subset_mset.bdd_above (prime_factorization ` A)⟧ ⟹ A ≠ {}› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*proven 3 subgoals*) . from assms (*‹x ∈ A›*) True (*‹0 ∉ A ∧ subset_mset.bdd_above (prime_factorization ` A)›*) have "prime_factorization x ⊆# Sup (prime_factorization ` A)" apply (intro subset_mset.cSup_upper (*‹⟦?x ∈ ?X; subset_mset.bdd_above ?X⟧ ⟹ ?x ⊆# Sup ?X›*)) (*goals: 1. ‹⟦x ∈ A; 0 ∉ A ∧ subset_mset.bdd_above (prime_factorization ` A)⟧ ⟹ prime_factorization x ∈ prime_factorization ` A› 2. ‹⟦x ∈ A; 0 ∉ A ∧ subset_mset.bdd_above (prime_factorization ` A)⟧ ⟹ subset_mset.bdd_above (prime_factorization ` A)› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . also (*calculation: ‹prime_factorization x ⊆# Sup (prime_factorization ` A)›*) have "… = prime_factorization (Lcm_factorial A)" apply (rule prime_factorization_Lcm_factorial [symmetric] (*‹⟦0 ∉ ?A; subset_mset.bdd_above (prime_factorization ` ?A)⟧ ⟹ Sup (prime_factorization ` ?A) = prime_factorization (Lcm_factorial ?A)›*)) (*goals: 1. ‹0 ∉ A› 2. ‹subset_mset.bdd_above (prime_factorization ` A)› discuss goal 1*) apply ((insert True (*‹0 ∉ A ∧ subset_mset.bdd_above (prime_factorization ` A)›*))[1]) (*top goal: ‹0 ∉ A› and 1 goal remains*) apply simp (*discuss goal 2*) apply ((insert True (*‹(0::'a::type) ∉ (A::'a::type set) ∧ subset_mset.bdd_above (prime_factorization ` A)›*))[1]) (*goal: ‹subset_mset.bdd_above (prime_factorization ` A)›*) apply simp (*proven 2 subgoals*) . finally (*calculation: ‹prime_factorization x ⊆# prime_factorization (Lcm_factorial A)›*) show "?thesis" (*goal: ‹x dvd Lcm_factorial A›*) apply (subst (asm) prime_factorization_subset_iff_dvd (*‹⟦(?x::'a) ≠ (0::'a); (?y::'a) ≠ (0::'a)⟧ ⟹ (prime_factorization ?x ⊆# prime_factorization ?y) = (?x dvd ?y)›*)) (*goals: 1. ‹x ≠ 0› 2. ‹Lcm_factorial A ≠ 0› 3. ‹x dvd Lcm_factorial A ⟹ x dvd Lcm_factorial A› discuss goal 1*) apply ((insert True (*‹(0::'a) ∉ (A::'a set) ∧ subset_mset.bdd_above (prime_factorization ` A)›*))[1]) (*top goal: ‹x ≠ 0› and 2 goals remain*) apply ((auto simp: Lcm_factorial_eq_0_iff (*‹(Lcm_factorial ?A = 0) = (0 ∈ ?A ∨ ¬ subset_mset.bdd_above (prime_factorization ` ?A))›*))[1]) (*discuss goal 2*) apply ((insert True (*‹0 ∉ A ∧ subset_mset.bdd_above (prime_factorization ` A)›*))[1]) (*top goal: ‹Lcm_factorial A ≠ 0› and 1 goal remains*) apply ((auto simp: Lcm_factorial_eq_0_iff (*‹(Lcm_factorial ?A = 0) = (0 ∈ ?A ∨ ¬ subset_mset.bdd_above (prime_factorization ` ?A))›*))[1]) (*discuss goal 3*) apply ((insert True (*‹0 ∉ A ∧ subset_mset.bdd_above (prime_factorization ` A)›*))[1]) (*goal: ‹x dvd Lcm_factorial A ⟹ x dvd Lcm_factorial A›*) apply ((auto simp: Lcm_factorial_eq_0_iff (*‹(Lcm_factorial ?A = 0) = (0 ∈ ?A ∨ ¬ subset_mset.bdd_above (prime_factorization ` ?A))›*))[1]) (*proven 3 subgoals*) . qed (insert assms (*‹(x::'a) ∈ (A::'a set)›*), auto simp: Lcm_factorial_def (*‹Lcm_factorial (?A::'a set) = (if ?A = {} then 1::'a else if (0::'a) ∉ ?A ∧ subset_mset.bdd_above (prime_factorization ` (?A - {0::'a})) then normalize (∏⇩# (Sup (prime_factorization ` ?A))) else (0::'a))›*)) (*solved the remaining goal: ‹¬ (0 ∉ A ∧ subset_mset.bdd_above (prime_factorization ` A)) ⟹ x dvd Lcm_factorial A›*) lemma Lcm_factorial_least: assumes "⋀y. y ∈ A ⟹ y dvd x" shows "Lcm_factorial A dvd x" proof (-) (*goal: ‹Lcm_factorial A dvd x›*) consider "A = {}" | "0 ∈ A" | "x = 0" | "A ≠ {}" and "0 ∉ A" and "x ≠ 0" (*goal: ‹⟦A = {} ⟹ thesis; 0 ∈ A ⟹ thesis; x = 0 ⟹ thesis; ⟦A ≠ {}; 0 ∉ A; x ≠ 0⟧ ⟹ thesis⟧ ⟹ thesis›*) by blast thus "?thesis" (*goal: ‹Lcm_factorial A dvd x›*) proof (cases) (*goals: 1. ‹A = {} ⟹ Lcm_factorial A dvd x› 2. ‹0 ∈ A ⟹ Lcm_factorial A dvd x› 3. ‹x = 0 ⟹ Lcm_factorial A dvd x› 4. ‹⟦A ≠ {}; 0 ∉ A; x ≠ 0⟧ ⟹ Lcm_factorial A dvd x›*) assume "*": "A ≠ {}" "0 ∉ A" "x ≠ 0" (*‹(A::'a set) ≠ {}› ‹(0::'a) ∉ (A::'a set)› ‹(x::'a) ≠ (0::'a)›*) hence nz: "x ≠ 0" if "x ∈ A" for x using that (*‹(x::'a::type) ∈ (A::'a::type set)›*) by auto from "*" (*‹A ≠ {}› ‹0 ∉ A› ‹x ≠ 0›*) have bdd: "subset_mset.bdd_above (prime_factorization ` A)" apply (intro subset_mset.bdd_aboveI[of _ "prime_factorization x"] (*‹(⋀xa. xa ∈ ?A ⟹ xa ⊆# prime_factorization x) ⟹ subset_mset.bdd_above ?A›*)) (*goal: ‹subset_mset.bdd_above (prime_factorization ` A)›*) by (auto simp: prime_factorization_subset_iff_dvd (*‹⟦(?x::'a) ≠ (0::'a); (?y::'a) ≠ (0::'a)⟧ ⟹ (prime_factorization ?x ⊆# prime_factorization ?y) = (?x dvd ?y)›*) nz (*‹(?x1::'a) ∈ (A::'a set) ⟹ ?x1 ≠ (0::'a)›*) dest: assms (*‹(?y1::'a) ∈ (A::'a set) ⟹ ?y1 dvd (x::'a)›*)) have "prime_factorization (Lcm_factorial A) = Sup (prime_factorization ` A)" apply (rule prime_factorization_Lcm_factorial (*‹⟦(0::'a::type) ∉ (?A::'a::type set); subset_mset.bdd_above (prime_factorization ` ?A)⟧ ⟹ prime_factorization (Lcm_factorial ?A) = Sup (prime_factorization ` ?A)›*)) (*goals: 1. ‹0 ∉ A› 2. ‹subset_mset.bdd_above (prime_factorization ` A)› discuss goal 1*) apply fact (*discuss goal 2*) apply fact (*proven 2 subgoals*) . also (*calculation: ‹prime_factorization (Lcm_factorial A) = Sup (prime_factorization ` A)›*) from "*" (*‹A ≠ {}› ‹(0::'a::type) ∉ (A::'a::type set)› ‹x ≠ 0›*) have "… ⊆# prime_factorization x" apply (intro subset_mset.cSup_least (*‹⟦(?X::?'a multiset set) ≠ {}; ⋀x::?'a multiset. x ∈ ?X ⟹ x ⊆# (?z::?'a multiset)⟧ ⟹ Sup ?X ⊆# ?z›*)) (*goals: 1. ‹⟦A ≠ {}; 0 ∉ A; x ≠ 0⟧ ⟹ prime_factorization ` A ≠ {}› 2. ‹⋀xa. ⟦A ≠ {}; 0 ∉ A; x ≠ 0; xa ∈ prime_factorization ` A⟧ ⟹ xa ⊆# prime_factorization x› discuss goal 1*) apply ((auto simp: prime_factorization_subset_iff_dvd (*‹⟦(?x::'a) ≠ (0::'a); (?y::'a) ≠ (0::'a)⟧ ⟹ (prime_factorization ?x ⊆# prime_factorization ?y) = (?x dvd ?y)›*) nz (*‹(?x1::'a) ∈ (A::'a set) ⟹ ?x1 ≠ (0::'a)›*) dest: assms (*‹(?y1::'a) ∈ (A::'a set) ⟹ ?y1 dvd (x::'a)›*))[1]) (*discuss goal 2*) apply ((auto simp: prime_factorization_subset_iff_dvd (*‹⟦?x ≠ 0; ?y ≠ 0⟧ ⟹ (prime_factorization ?x ⊆# prime_factorization ?y) = (?x dvd ?y)›*) nz (*‹?x1 ∈ A ⟹ ?x1 ≠ 0›*) dest: assms (*‹?y1 ∈ A ⟹ ?y1 dvd x›*))[1]) (*proven 2 subgoals*) . finally (*calculation: ‹prime_factorization (Lcm_factorial A) ⊆# prime_factorization x›*) show "?thesis" (*goal: ‹Lcm_factorial A dvd x›*) apply (subst (asm) prime_factorization_subset_iff_dvd (*‹⟦?x ≠ 0; ?y ≠ 0⟧ ⟹ (prime_factorization ?x ⊆# prime_factorization ?y) = (?x dvd ?y)›*)) (*goals: 1. ‹Lcm_factorial A ≠ 0› 2. ‹x ≠ 0› 3. ‹Lcm_factorial A dvd x ⟹ Lcm_factorial A dvd x› discuss goal 1*) apply ((insert * (*‹A ≠ {}› ‹0 ∉ A› ‹x ≠ 0›*) bdd (*‹subset_mset.bdd_above (prime_factorization ` A)›*))[1]) (*top goal: ‹Lcm_factorial A ≠ 0› and 2 goals remain*) apply ((auto simp: Lcm_factorial_eq_0_iff (*‹(Lcm_factorial ?A = 0) = (0 ∈ ?A ∨ ¬ subset_mset.bdd_above (prime_factorization ` ?A))›*))[1]) (*discuss goal 2*) apply ((insert * (*‹A ≠ {}› ‹0 ∉ A› ‹x ≠ 0›*) bdd (*‹subset_mset.bdd_above (prime_factorization ` A)›*))[1]) (*top goal: ‹x ≠ 0› and 1 goal remains*) apply ((auto simp: Lcm_factorial_eq_0_iff (*‹(Lcm_factorial (?A::'a::type set) = (0::'a::type)) = ((0::'a::type) ∈ ?A ∨ ¬ subset_mset.bdd_above (prime_factorization ` ?A))›*))[1]) (*discuss goal 3*) apply ((insert * (*‹A ≠ {}› ‹0 ∉ A› ‹x ≠ 0›*) bdd (*‹subset_mset.bdd_above (prime_factorization ` A)›*))[1]) (*goal: ‹Lcm_factorial A dvd x ⟹ Lcm_factorial A dvd x›*) apply ((auto simp: Lcm_factorial_eq_0_iff (*‹(Lcm_factorial ?A = 0) = (0 ∈ ?A ∨ ¬ subset_mset.bdd_above (prime_factorization ` ?A))›*))[1]) (*proven 3 subgoals*) . qed (auto simp: Lcm_factorial_def (*‹Lcm_factorial ?A = (if ?A = {} then 1 else if 0 ∉ ?A ∧ subset_mset.bdd_above (prime_factorization ` (?A - {0})) then normalize (∏⇩# (Sup (prime_factorization ` ?A))) else 0)›*) dest: assms (*‹?y1 ∈ A ⟹ ?y1 dvd x›*)) (*solves the remaining goals: 1. ‹A = {} ⟹ Lcm_factorial A dvd x› 2. ‹0 ∈ A ⟹ Lcm_factorial A dvd x› 3. ‹x = 0 ⟹ Lcm_factorial A dvd x›*) qed lemmas gcd_lcm_factorial = gcd_factorial_dvd1 gcd_factorial_dvd2 gcd_factorial_greatest normalize_gcd_factorial lcm_factorial_gcd_factorial normalize_Gcd_factorial Gcd_factorial_dvd Gcd_factorial_greatest normalize_Lcm_factorial dvd_Lcm_factorial Lcm_factorial_least end class factorial_semiring_gcd = factorial_semiring + gcd + Gcd + assumes gcd_eq_gcd_factorial: "gcd a b = gcd_factorial a b" and lcm_eq_lcm_factorial: "lcm a b = lcm_factorial a b" and Gcd_eq_Gcd_factorial: "Gcd A = Gcd_factorial A" and Lcm_eq_Lcm_factorial: "Lcm A = Lcm_factorial A" begin lemma prime_factorization_gcd: assumes [simp]: "a ≠ 0" "b ≠ 0" shows "prime_factorization (gcd a b) = prime_factorization a ∩# prime_factorization b" by (simp add: gcd_eq_gcd_factorial (*‹gcd (?a::'a) (?b::'a) = gcd_factorial ?a ?b›*) prime_factorization_gcd_factorial (*‹⟦(?a::'a) ≠ (0::'a); (?b::'a) ≠ (0::'a)⟧ ⟹ prime_factorization (gcd_factorial ?a ?b) = prime_factorization ?a ∩# prime_factorization ?b›*)) lemma prime_factorization_lcm: assumes [simp]: "a ≠ 0" "b ≠ 0" shows "prime_factorization (lcm a b) = prime_factorization a ∪# prime_factorization b" by (simp add: lcm_eq_lcm_factorial (*‹lcm ?a ?b = lcm_factorial ?a ?b›*) prime_factorization_lcm_factorial (*‹⟦?a ≠ 0; ?b ≠ 0⟧ ⟹ prime_factorization (lcm_factorial ?a ?b) = prime_factorization ?a ∪# prime_factorization ?b›*)) lemma prime_factorization_Gcd: assumes "Gcd A ≠ 0" shows "prime_factorization (Gcd A) = Inf (prime_factorization ` (A - {0}))" using assms (*‹Gcd A ≠ 0›*) by (simp add: prime_factorization_Gcd_factorial (*‹¬ ?A ⊆ {0} ⟹ prime_factorization (Gcd_factorial ?A) = Inf (prime_factorization ` (?A - {0}))›*) Gcd_eq_Gcd_factorial (*‹Gcd ?A = Gcd_factorial ?A›*) Gcd_factorial_eq_0_iff (*‹(Gcd_factorial ?A = 0) = (?A ⊆ {0})›*)) lemma prime_factorization_Lcm: assumes "Lcm A ≠ 0" shows "prime_factorization (Lcm A) = Sup (prime_factorization ` A)" using assms (*‹Lcm A ≠ 0›*) by (simp add: prime_factorization_Lcm_factorial (*‹⟦(0::'a) ∉ (?A::'a set); subset_mset.bdd_above (prime_factorization ` ?A)⟧ ⟹ prime_factorization (Lcm_factorial ?A) = Sup (prime_factorization ` ?A)›*) Lcm_eq_Lcm_factorial (*‹Lcm (?A::'a set) = Lcm_factorial ?A›*) Lcm_factorial_eq_0_iff (*‹(Lcm_factorial (?A::'a set) = (0::'a)) = ((0::'a) ∈ ?A ∨ ¬ subset_mset.bdd_above (prime_factorization ` ?A))›*)) lemma prime_factors_gcd [simp]: "a ≠ 0 ⟹ b ≠ 0 ⟹ prime_factors (gcd a b) = prime_factors a ∩ prime_factors b" apply (subst prime_factorization_gcd (*‹⟦(?a::'a::type) ≠ (0::'a::type); (?b::'a::type) ≠ (0::'a::type)⟧ ⟹ prime_factorization (gcd ?a ?b) = prime_factorization ?a ∩# prime_factorization ?b›*)) (*goals: 1. ‹⟦(a::'a::type) ≠ (0::'a::type); (b::'a::type) ≠ (0::'a::type)⟧ ⟹ a ≠ (0::'a::type)› 2. ‹⟦(a::'a::type) ≠ (0::'a::type); (b::'a::type) ≠ (0::'a::type)⟧ ⟹ b ≠ (0::'a::type)› 3. ‹⟦(a::'a::type) ≠ (0::'a::type); (b::'a::type) ≠ (0::'a::type)⟧ ⟹ set_mset (prime_factorization a ∩# prime_factorization b) = prime_factors a ∩ prime_factors b› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*proven 3 subgoals*) . lemma prime_factors_lcm [simp]: "a ≠ 0 ⟹ b ≠ 0 ⟹ prime_factors (lcm a b) = prime_factors a ∪ prime_factors b" apply (subst prime_factorization_lcm (*‹⟦?a ≠ 0; ?b ≠ 0⟧ ⟹ prime_factorization (lcm ?a ?b) = prime_factorization ?a ∪# prime_factorization ?b›*)) (*goals: 1. ‹⟦a ≠ 0; b ≠ 0⟧ ⟹ a ≠ 0› 2. ‹⟦a ≠ 0; b ≠ 0⟧ ⟹ b ≠ 0› 3. ‹⟦a ≠ 0; b ≠ 0⟧ ⟹ set_mset (prime_factorization a ∪# prime_factorization b) = prime_factors a ∪ prime_factors b› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*proven 3 subgoals*) . subclass semiring_gcd by (standard, unfold gcd_eq_gcd_factorial lcm_eq_lcm_factorial) (rule gcd_lcm_factorial; assumption)+ subclass semiring_Gcd by (standard, unfold Gcd_eq_Gcd_factorial Lcm_eq_Lcm_factorial) (rule gcd_lcm_factorial; assumption)+ lemma assumes "x ≠ 0" "y ≠ 0" shows gcd_eq_factorial': "gcd x y = normalize (∏p ∈ prime_factors x ∩ prime_factors y. p ^ min (multiplicity p x) (multiplicity p y))" (is "_ = ?rhs1") and lcm_eq_factorial': "lcm x y = normalize (∏p ∈ prime_factors x ∪ prime_factors y. p ^ max (multiplicity p x) (multiplicity p y))" (is "_ = ?rhs2") proof (-) (*goals: 1. ‹gcd (x::'a) (y::'a) = normalize (∏p::'a∈prime_factors x ∩ prime_factors y. p ^ min (multiplicity p x) (multiplicity p y))› 2. ‹lcm (x::'a) (y::'a) = normalize (∏p::'a∈prime_factors x ∪ prime_factors y. p ^ max (multiplicity p x) (multiplicity p y))›*) have "gcd x y = gcd_factorial x y" by (rule gcd_eq_gcd_factorial (*‹gcd ?a ?b = gcd_factorial ?a ?b›*)) also (*calculation: ‹gcd x y = gcd_factorial x y›*) have "… = ?rhs1" by (auto simp: gcd_factorial_def (*‹gcd_factorial ?a ?b = (if ?a = 0 then normalize ?b else if ?b = 0 then normalize ?a else normalize (∏⇩# (prime_factorization ?a ∩# prime_factorization ?b)))›*) assms (*‹x ≠ 0› ‹y ≠ 0›*) prod_mset_multiplicity (*‹∏⇩# ?M = (∏x∈set_mset ?M. x ^ count ?M x)›*) count_prime_factorization_prime (*‹prime ?p ⟹ count (prime_factorization ?x) ?p = multiplicity ?p ?x›*) intro!: arg_cong[of _ _ normalize] (*‹?x = ?y ⟹ normalize ?x = normalize ?y›*) dest: in_prime_factors_imp_prime (*‹?p ∈ prime_factors ?x ⟹ prime ?p›*) intro!: prod.cong (*‹⟦?A = ?B; ⋀x. x ∈ ?B ⟹ ?g x = ?h x⟧ ⟹ prod ?g ?A = prod ?h ?B›*)) finally (*calculation: ‹gcd (x::'a) (y::'a) = normalize (∏p::'a∈prime_factors x ∩ prime_factors y. p ^ min (multiplicity p x) (multiplicity p y))›*) show "gcd x y = ?rhs1" . have "lcm x y = lcm_factorial x y" by (rule lcm_eq_lcm_factorial (*‹lcm ?a ?b = lcm_factorial ?a ?b›*)) also (*calculation: ‹lcm (x::'a) (y::'a) = lcm_factorial x y›*) have "… = ?rhs2" by (auto simp: lcm_factorial_def (*‹lcm_factorial ?a ?b = (if ?a = 0 ∨ ?b = 0 then 0 else normalize (∏⇩# (prime_factorization ?a ∪# prime_factorization ?b)))›*) assms (*‹x ≠ 0› ‹y ≠ 0›*) prod_mset_multiplicity (*‹∏⇩# ?M = (∏x∈set_mset ?M. x ^ count ?M x)›*) count_prime_factorization_prime (*‹prime ?p ⟹ count (prime_factorization ?x) ?p = multiplicity ?p ?x›*) intro!: arg_cong[of _ _ normalize] (*‹?x = ?y ⟹ normalize ?x = normalize ?y›*) dest: in_prime_factors_imp_prime (*‹?p ∈ prime_factors ?x ⟹ prime ?p›*) intro!: prod.cong (*‹⟦?A = ?B; ⋀x. x ∈ ?B ⟹ ?g x = ?h x⟧ ⟹ prod ?g ?A = prod ?h ?B›*)) finally (*calculation: ‹lcm x y = normalize (∏p∈prime_factors x ∪ prime_factors y. p ^ max (multiplicity p x) (multiplicity p y))›*) show "lcm x y = ?rhs2" . qed lemma assumes "x ≠ 0" "y ≠ 0" "prime p" shows multiplicity_gcd: "multiplicity p (gcd x y) = min (multiplicity p x) (multiplicity p y)" and multiplicity_lcm: "multiplicity p (lcm x y) = max (multiplicity p x) (multiplicity p y)" proof (-) (*goals: 1. ‹multiplicity p (gcd x y) = min (multiplicity p x) (multiplicity p y)› 2. ‹multiplicity p (lcm x y) = max (multiplicity p x) (multiplicity p y)›*) have "gcd x y = gcd_factorial x y" by (rule gcd_eq_gcd_factorial (*‹gcd ?a ?b = gcd_factorial ?a ?b›*)) also (*calculation: ‹gcd x y = gcd_factorial x y›*) from assms (*‹x ≠ 0› ‹y ≠ 0› ‹prime p›*) have "multiplicity p … = min (multiplicity p x) (multiplicity p y)" by (simp add: count_prime_factorization_prime [symmetric] (*‹prime ?p ⟹ multiplicity ?p ?x = count (prime_factorization ?x) ?p›*) prime_factorization_gcd_factorial (*‹⟦?a ≠ 0; ?b ≠ 0⟧ ⟹ prime_factorization (gcd_factorial ?a ?b) = prime_factorization ?a ∩# prime_factorization ?b›*)) finally (*calculation: ‹multiplicity p (gcd x y) = min (multiplicity p x) (multiplicity p y)›*) show "multiplicity p (gcd x y) = min (multiplicity p x) (multiplicity p y)" . have "lcm x y = lcm_factorial x y" by (rule lcm_eq_lcm_factorial (*‹lcm (?a::'a::type) (?b::'a::type) = lcm_factorial ?a ?b›*)) also (*calculation: ‹lcm x y = lcm_factorial x y›*) from assms (*‹x ≠ 0› ‹(y::'a::type) ≠ (0::'a::type)› ‹prime p›*) have "multiplicity p … = max (multiplicity p x) (multiplicity p y)" by (simp add: count_prime_factorization_prime [symmetric] (*‹prime ?p ⟹ multiplicity ?p ?x = count (prime_factorization ?x) ?p›*) prime_factorization_lcm_factorial (*‹⟦?a ≠ 0; ?b ≠ 0⟧ ⟹ prime_factorization (lcm_factorial ?a ?b) = prime_factorization ?a ∪# prime_factorization ?b›*)) finally (*calculation: ‹multiplicity p (lcm x y) = max (multiplicity p x) (multiplicity p y)›*) show "multiplicity p (lcm x y) = max (multiplicity p x) (multiplicity p y)" . qed lemma gcd_lcm_distrib: "gcd x (lcm y z) = lcm (gcd x y) (gcd x z)" proof (cases "x = 0 ∨ y = 0 ∨ z = 0") (*goals: 1. ‹x = 0 ∨ y = 0 ∨ z = 0 ⟹ gcd x (lcm y z) = lcm (gcd x y) (gcd x z)› 2. ‹¬ (x = 0 ∨ y = 0 ∨ z = 0) ⟹ gcd x (lcm y z) = lcm (gcd x y) (gcd x z)›*) case True (*‹x = 0 ∨ y = 0 ∨ z = 0›*) thus "?thesis" (*goal: ‹gcd x (lcm y z) = lcm (gcd x y) (gcd x z)›*) by (auto simp: lcm_proj1_if_dvd (*‹?b dvd ?a ⟹ lcm ?a ?b = normalize ?a›*) lcm_proj2_if_dvd (*‹?a dvd ?b ⟹ lcm ?a ?b = normalize ?b›*)) next (*goal: ‹¬ (x = 0 ∨ y = 0 ∨ z = 0) ⟹ gcd x (lcm y z) = lcm (gcd x y) (gcd x z)›*) case False (*‹¬ (x = 0 ∨ y = 0 ∨ z = 0)›*) hence "normalize (gcd x (lcm y z)) = normalize (lcm (gcd x y) (gcd x z))" apply (intro associatedI (*‹⟦?a dvd ?b; ?b dvd ?a⟧ ⟹ normalize ?a = normalize ?b›*) prime_factorization_subset_imp_dvd (*‹⟦?x ≠ 0; prime_factorization ?x ⊆# prime_factorization ?y⟧ ⟹ ?x dvd ?y›*)) (*goals: 1. ‹¬ (x = 0 ∨ y = 0 ∨ z = 0) ⟹ gcd x (lcm y z) ≠ 0› 2. ‹¬ (x = 0 ∨ y = 0 ∨ z = 0) ⟹ prime_factorization (gcd x (lcm y z)) ⊆# prime_factorization (lcm (gcd x y) (gcd x z))› 3. ‹¬ (x = 0 ∨ y = 0 ∨ z = 0) ⟹ lcm (gcd x y) (gcd x z) ≠ 0› 4. ‹¬ (x = 0 ∨ y = 0 ∨ z = 0) ⟹ prime_factorization (lcm (gcd x y) (gcd x z)) ⊆# prime_factorization (gcd x (lcm y z))› discuss goal 1*) apply ((auto simp: lcm_eq_0_iff (*‹(lcm ?a ?b = 0) = (?a = 0 ∨ ?b = 0)›*) prime_factorization_gcd (*‹⟦?a ≠ 0; ?b ≠ 0⟧ ⟹ prime_factorization (gcd ?a ?b) = prime_factorization ?a ∩# prime_factorization ?b›*) prime_factorization_lcm (*‹⟦?a ≠ 0; ?b ≠ 0⟧ ⟹ prime_factorization (lcm ?a ?b) = prime_factorization ?a ∪# prime_factorization ?b›*) subset_mset.inf_sup_distrib1 (*‹?x ∩# (?y ∪# ?z) = ?x ∩# ?y ∪# (?x ∩# ?z)›*))[1]) (*discuss goal 2*) apply ((auto simp: lcm_eq_0_iff (*‹(lcm ?a ?b = 0) = (?a = 0 ∨ ?b = 0)›*) prime_factorization_gcd (*‹⟦?a ≠ 0; ?b ≠ 0⟧ ⟹ prime_factorization (gcd ?a ?b) = prime_factorization ?a ∩# prime_factorization ?b›*) prime_factorization_lcm (*‹⟦?a ≠ 0; ?b ≠ 0⟧ ⟹ prime_factorization (lcm ?a ?b) = prime_factorization ?a ∪# prime_factorization ?b›*) subset_mset.inf_sup_distrib1 (*‹?x ∩# (?y ∪# ?z) = ?x ∩# ?y ∪# (?x ∩# ?z)›*))[1]) (*discuss goal 3*) apply ((auto simp: lcm_eq_0_iff (*‹(lcm ?a ?b = 0) = (?a = 0 ∨ ?b = 0)›*) prime_factorization_gcd (*‹⟦?a ≠ 0; ?b ≠ 0⟧ ⟹ prime_factorization (gcd ?a ?b) = prime_factorization ?a ∩# prime_factorization ?b›*) prime_factorization_lcm (*‹⟦?a ≠ 0; ?b ≠ 0⟧ ⟹ prime_factorization (lcm ?a ?b) = prime_factorization ?a ∪# prime_factorization ?b›*) subset_mset.inf_sup_distrib1 (*‹?x ∩# (?y ∪# ?z) = ?x ∩# ?y ∪# (?x ∩# ?z)›*))[1]) (*discuss goal 4*) apply ((auto simp: lcm_eq_0_iff (*‹(lcm (?a::'a::type) (?b::'a::type) = (0::'a::type)) = (?a = (0::'a::type) ∨ ?b = (0::'a::type))›*) prime_factorization_gcd (*‹⟦(?a::'a::type) ≠ (0::'a::type); (?b::'a::type) ≠ (0::'a::type)⟧ ⟹ prime_factorization (gcd ?a ?b) = prime_factorization ?a ∩# prime_factorization ?b›*) prime_factorization_lcm (*‹⟦(?a::'a::type) ≠ (0::'a::type); (?b::'a::type) ≠ (0::'a::type)⟧ ⟹ prime_factorization (lcm ?a ?b) = prime_factorization ?a ∪# prime_factorization ?b›*) subset_mset.inf_sup_distrib1 (*‹(?x::?'a::type multiset) ∩# ((?y::?'a::type multiset) ∪# (?z::?'a::type multiset)) = ?x ∩# ?y ∪# (?x ∩# ?z)›*))[1]) (*proven 4 subgoals*) . thus "?thesis" (*goal: ‹gcd x (lcm y z) = lcm (gcd x y) (gcd x z)›*) by simp qed lemma lcm_gcd_distrib: "lcm x (gcd y z) = gcd (lcm x y) (lcm x z)" proof (cases "x = 0 ∨ y = 0 ∨ z = 0") (*goals: 1. ‹(x::'a) = (0::'a) ∨ (y::'a) = (0::'a) ∨ (z::'a) = (0::'a) ⟹ lcm x (gcd y z) = gcd (lcm x y) (lcm x z)› 2. ‹¬ ((x::'a) = (0::'a) ∨ (y::'a) = (0::'a) ∨ (z::'a) = (0::'a)) ⟹ lcm x (gcd y z) = gcd (lcm x y) (lcm x z)›*) case True (*‹(x::'a) = (0::'a) ∨ (y::'a) = (0::'a) ∨ (z::'a) = (0::'a)›*) thus "?thesis" (*goal: ‹lcm x (gcd y z) = gcd (lcm x y) (lcm x z)›*) by (auto simp: lcm_proj1_if_dvd (*‹?b dvd ?a ⟹ lcm ?a ?b = normalize ?a›*) lcm_proj2_if_dvd (*‹?a dvd ?b ⟹ lcm ?a ?b = normalize ?b›*)) next (*goal: ‹¬ (x = 0 ∨ y = 0 ∨ z = 0) ⟹ lcm x (gcd y z) = gcd (lcm x y) (lcm x z)›*) case False (*‹¬ (x = 0 ∨ y = 0 ∨ z = 0)›*) hence "normalize (lcm x (gcd y z)) = normalize (gcd (lcm x y) (lcm x z))" apply (intro associatedI (*‹⟦?a dvd ?b; ?b dvd ?a⟧ ⟹ normalize ?a = normalize ?b›*) prime_factorization_subset_imp_dvd (*‹⟦?x ≠ 0; prime_factorization ?x ⊆# prime_factorization ?y⟧ ⟹ ?x dvd ?y›*)) (*goals: 1. ‹¬ (x = 0 ∨ y = 0 ∨ z = 0) ⟹ lcm x (gcd y z) ≠ 0› 2. ‹¬ (x = 0 ∨ y = 0 ∨ z = 0) ⟹ prime_factorization (lcm x (gcd y z)) ⊆# prime_factorization (gcd (lcm x y) (lcm x z))› 3. ‹¬ (x = 0 ∨ y = 0 ∨ z = 0) ⟹ gcd (lcm x y) (lcm x z) ≠ 0› 4. ‹¬ (x = 0 ∨ y = 0 ∨ z = 0) ⟹ prime_factorization (gcd (lcm x y) (lcm x z)) ⊆# prime_factorization (lcm x (gcd y z))› discuss goal 1*) apply ((auto simp: lcm_eq_0_iff (*‹(lcm (?a::'a) (?b::'a) = (0::'a)) = (?a = (0::'a) ∨ ?b = (0::'a))›*) prime_factorization_gcd (*‹⟦(?a::'a) ≠ (0::'a); (?b::'a) ≠ (0::'a)⟧ ⟹ prime_factorization (gcd ?a ?b) = prime_factorization ?a ∩# prime_factorization ?b›*) prime_factorization_lcm (*‹⟦(?a::'a) ≠ (0::'a); (?b::'a) ≠ (0::'a)⟧ ⟹ prime_factorization (lcm ?a ?b) = prime_factorization ?a ∪# prime_factorization ?b›*) subset_mset.sup_inf_distrib1 (*‹(?x::?'a multiset) ∪# ((?y::?'a multiset) ∩# (?z::?'a multiset)) = ?x ∪# ?y ∩# (?x ∪# ?z)›*))[1]) (*discuss goal 2*) apply ((auto simp: lcm_eq_0_iff (*‹(lcm ?a ?b = 0) = (?a = 0 ∨ ?b = 0)›*) prime_factorization_gcd (*‹⟦?a ≠ 0; ?b ≠ 0⟧ ⟹ prime_factorization (gcd ?a ?b) = prime_factorization ?a ∩# prime_factorization ?b›*) prime_factorization_lcm (*‹⟦?a ≠ 0; ?b ≠ 0⟧ ⟹ prime_factorization (lcm ?a ?b) = prime_factorization ?a ∪# prime_factorization ?b›*) subset_mset.sup_inf_distrib1 (*‹?x ∪# (?y ∩# ?z) = ?x ∪# ?y ∩# (?x ∪# ?z)›*))[1]) (*discuss goal 3*) apply ((auto simp: lcm_eq_0_iff (*‹(lcm ?a ?b = 0) = (?a = 0 ∨ ?b = 0)›*) prime_factorization_gcd (*‹⟦?a ≠ 0; ?b ≠ 0⟧ ⟹ prime_factorization (gcd ?a ?b) = prime_factorization ?a ∩# prime_factorization ?b›*) prime_factorization_lcm (*‹⟦?a ≠ 0; ?b ≠ 0⟧ ⟹ prime_factorization (lcm ?a ?b) = prime_factorization ?a ∪# prime_factorization ?b›*) subset_mset.sup_inf_distrib1 (*‹?x ∪# (?y ∩# ?z) = ?x ∪# ?y ∩# (?x ∪# ?z)›*))[1]) (*discuss goal 4*) apply ((auto simp: lcm_eq_0_iff (*‹(lcm ?a ?b = 0) = (?a = 0 ∨ ?b = 0)›*) prime_factorization_gcd (*‹⟦?a ≠ 0; ?b ≠ 0⟧ ⟹ prime_factorization (gcd ?a ?b) = prime_factorization ?a ∩# prime_factorization ?b›*) prime_factorization_lcm (*‹⟦?a ≠ 0; ?b ≠ 0⟧ ⟹ prime_factorization (lcm ?a ?b) = prime_factorization ?a ∪# prime_factorization ?b›*) subset_mset.sup_inf_distrib1 (*‹?x ∪# (?y ∩# ?z) = ?x ∪# ?y ∩# (?x ∪# ?z)›*))[1]) (*proven 4 subgoals*) . thus "?thesis" (*goal: ‹lcm x (gcd y z) = gcd (lcm x y) (lcm x z)›*) by simp qed end class factorial_ring_gcd = factorial_semiring_gcd + idom begin subclass ring_gcd .. subclass idom_divide .. end class factorial_semiring_multiplicative = factorial_semiring + normalization_semidom_multiplicative begin lemma normalize_prod_mset_primes: "(⋀p. p ∈# A ⟹ prime p) ⟹ normalize (prod_mset A) = prod_mset A" proof (induction A) (*goals: 1. ‹(⋀p::'a::type. p ∈# {#} ⟹ prime p) ⟹ normalize (∏⇩# {#}) = ∏⇩# {#}› 2. ‹⋀(x::'a::type) A::'a::type multiset. ⟦(⋀p::'a::type. p ∈# A ⟹ prime p) ⟹ normalize (∏⇩# A) = ∏⇩# A; ⋀p::'a::type. p ∈# add_mset x A ⟹ prime p⟧ ⟹ normalize (∏⇩# (add_mset x A)) = ∏⇩# (add_mset x A)›*) case (add p A) (*‹(⋀p::'a::type. p ∈# (A::'a::type multiset) ⟹ prime p) ⟹ normalize (∏⇩# A) = ∏⇩# A› ‹?p1 ∈# add_mset p A ⟹ prime ?p1›*) hence "prime p" by simp hence "normalize p = p" by simp with add (*‹(⋀p::'a. p ∈# (A::'a multiset) ⟹ prime p) ⟹ normalize (∏⇩# A) = ∏⇩# A› ‹(?p1::'a) ∈# add_mset (p::'a) (A::'a multiset) ⟹ prime ?p1›*) show "?case" (*goal: ‹normalize (∏⇩# (add_mset p A)) = ∏⇩# (add_mset p A)›*) by (simp add: normalize_mult (*‹normalize (?a * ?b) = normalize ?a * normalize ?b›*)) qed (simp_all) (*solved the remaining goal: ‹(⋀p. p ∈# {#} ⟹ prime p) ⟹ normalize (∏⇩# {#}) = ∏⇩# {#}›*) lemma prod_mset_prime_factorization: assumes "x ≠ 0" shows "prod_mset (prime_factorization x) = normalize x" using assms (*‹x ≠ 0›*) apply (induction x rule: prime_divisors_induct (*‹⟦?P 0; ⋀x. is_unit x ⟹ ?P x; ⋀p x. ⟦prime p; ?P x⟧ ⟹ ?P (p * x)⟧ ⟹ ?P ?x›*)) (*goals: 1. ‹(0::'a) ≠ (0::'a) ⟹ ∏⇩# (prime_factorization (0::'a)) = normalize (0::'a)› 2. ‹⋀x::'a. ⟦is_unit x; x ≠ (0::'a)⟧ ⟹ ∏⇩# (prime_factorization x) = normalize x› 3. ‹⋀(p::'a) x::'a. ⟦prime p; x ≠ (0::'a) ⟹ ∏⇩# (prime_factorization x) = normalize x; p * x ≠ (0::'a)⟧ ⟹ ∏⇩# (prime_factorization (p * x)) = normalize (p * x)› discuss goal 1*) apply (simp add: prime_factorization_unit (*‹is_unit ?x ⟹ prime_factorization ?x = {#}›*) prime_factorization_times_prime (*‹⟦?x ≠ 0; prime ?p⟧ ⟹ prime_factorization (?p * ?x) = {#?p#} + prime_factorization ?x›*) is_unit_normalize (*‹is_unit ?a ⟹ normalize ?a = 1›*) normalize_mult (*‹normalize (?a * ?b) = normalize ?a * normalize ?b›*)) (*discuss goal 2*) apply (simp add: prime_factorization_unit (*‹is_unit ?x ⟹ prime_factorization ?x = {#}›*) prime_factorization_times_prime (*‹⟦?x ≠ 0; prime ?p⟧ ⟹ prime_factorization (?p * ?x) = {#?p#} + prime_factorization ?x›*) is_unit_normalize (*‹is_unit ?a ⟹ normalize ?a = 1›*) normalize_mult (*‹normalize (?a * ?b) = normalize ?a * normalize ?b›*)) (*discuss goal 3*) apply (simp add: prime_factorization_unit (*‹is_unit ?x ⟹ prime_factorization ?x = {#}›*) prime_factorization_times_prime (*‹⟦?x ≠ 0; prime ?p⟧ ⟹ prime_factorization (?p * ?x) = {#?p#} + prime_factorization ?x›*) is_unit_normalize (*‹is_unit ?a ⟹ normalize ?a = 1›*) normalize_mult (*‹normalize (?a * ?b) = normalize ?a * normalize ?b›*)) (*proven 3 subgoals*) . lemma prime_decomposition: "unit_factor x * prod_mset (prime_factorization x) = x" apply (cases "x = 0") (*goals: 1. ‹x = 0 ⟹ unit_factor x * ∏⇩# (prime_factorization x) = x› 2. ‹x ≠ 0 ⟹ unit_factor x * ∏⇩# (prime_factorization x) = x› discuss goal 1*) apply (simp add: prod_mset_prime_factorization (*‹(?x::'a) ≠ (0::'a) ⟹ ∏⇩# (prime_factorization ?x) = normalize ?x›*)) (*discuss goal 2*) apply (simp add: prod_mset_prime_factorization (*‹?x ≠ 0 ⟹ ∏⇩# (prime_factorization ?x) = normalize ?x›*)) (*proven 2 subgoals*) . lemma prod_prime_factors: assumes "x ≠ 0" shows "(∏p ∈ prime_factors x. p ^ multiplicity p x) = normalize x" proof (-) (*goal: ‹(∏p∈prime_factors x. p ^ multiplicity p x) = normalize x›*) have "normalize x = prod_mset (prime_factorization x)" by (simp add: prod_mset_prime_factorization (*‹?x ≠ 0 ⟹ ∏⇩# (prime_factorization ?x) = normalize ?x›*) assms (*‹x ≠ 0›*)) also (*calculation: ‹normalize x = ∏⇩# (prime_factorization x)›*) have "… = (∏p ∈ prime_factors x. p ^ count (prime_factorization x) p)" apply (subst prod_mset_multiplicity (*‹∏⇩# ?M = (∏x∈set_mset ?M. x ^ count ?M x)›*)) (*goal: ‹∏⇩# (prime_factorization (x::'a)) = (∏p::'a∈prime_factors x. p ^ count (prime_factorization x) p)›*) by simp also (*calculation: ‹normalize x = (∏p∈prime_factors x. p ^ count (prime_factorization x) p)›*) have "… = (∏p ∈ prime_factors x. p ^ multiplicity p x)" apply (intro prod.cong (*‹⟦?A = ?B; ⋀x. x ∈ ?B ⟹ ?g x = ?h x⟧ ⟹ prod ?g ?A = prod ?h ?B›*)) (*goals: 1. ‹prime_factors x = prime_factors x› 2. ‹⋀xa. xa ∈ prime_factors x ⟹ xa ^ count (prime_factorization x) xa = xa ^ multiplicity xa x› discuss goal 1*) apply (simp add: assms (*‹x ≠ 0›*) count_prime_factorization_prime (*‹prime ?p ⟹ count (prime_factorization ?x) ?p = multiplicity ?p ?x›*) in_prime_factors_imp_prime (*‹?p ∈ prime_factors ?x ⟹ prime ?p›*)) (*discuss goal 2*) apply (simp add: assms (*‹x ≠ 0›*) count_prime_factorization_prime (*‹prime ?p ⟹ count (prime_factorization ?x) ?p = multiplicity ?p ?x›*) in_prime_factors_imp_prime (*‹?p ∈ prime_factors ?x ⟹ prime ?p›*)) (*proven 2 subgoals*) . finally (*calculation: ‹normalize x = (∏p∈prime_factors x. p ^ multiplicity p x)›*) show "?thesis" (*goal: ‹(∏p∈prime_factors x. p ^ multiplicity p x) = normalize x›*) by standard qed lemma prime_factorization_unique'': assumes S_eq: "S = {p. 0 < f p}" and "finite S" and S: "∀p∈S. prime p" "normalize n = (∏p∈S. p ^ f p)" shows "S = prime_factors n ∧ (∀p. prime p ⟶ f p = multiplicity p n)" proof (standard) (*goals: 1. ‹S = prime_factors n› 2. ‹∀p. prime p ⟶ f p = multiplicity p n›*) define A where "A = Abs_multiset f" from ‹finite S› (*‹finite (S::'a set)›*) S(1) (*‹∀p∈S. prime p›*) have "(∏p∈S. p ^ f p) ≠ 0" by auto with S(2) (*‹normalize n = (∏p∈S. p ^ f p)›*) have nz: "n ≠ 0" by auto from S_eq (*‹S = {p. 0 < f p}›*) ‹finite S› (*‹finite S›*) have count_A: "count A = f" unfolding A_def (*goal: ‹count (Abs_multiset (f::'a ⇒ nat)) = f›*) apply (subst multiset.Abs_multiset_inverse (*‹?y ∈ {f. finite {x. 0 < f x}} ⟹ count (Abs_multiset ?y) = ?y›*)) (*goals: 1. ‹⟦(S::'a set) = {p::'a. (0::nat) < (f::'a ⇒ nat) p}; finite S⟧ ⟹ f ∈ {f::'a ⇒ nat. finite {x::'a. (0::nat) < f x}}› 2. ‹⟦(S::'a set) = {p::'a. (0::nat) < (f::'a ⇒ nat) p}; finite S⟧ ⟹ f = f› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) . from S_eq (*‹S = {p. 0 < f p}›*) count_A (*‹count A = f›*) have set_mset_A: "set_mset A = S" by (simp only: set_mset_def (*‹set_mset ?M = {x. 0 < count ?M x}›*)) from S(2) (*‹normalize n = (∏p∈S. p ^ f p)›*) have "normalize n = (∏p∈S. p ^ f p)" . also (*calculation: ‹normalize n = (∏p∈S. p ^ f p)›*) have "… = prod_mset A" by (simp add: prod_mset_multiplicity (*‹∏⇩# ?M = (∏x∈set_mset ?M. x ^ count ?M x)›*) S_eq (*‹S = {p. 0 < f p}›*) set_mset_A (*‹set_mset A = S›*) count_A (*‹count A = f›*)) also (*calculation: ‹normalize n = ∏⇩# A›*) from nz (*‹n ≠ 0›*) have "normalize n = prod_mset (prime_factorization n)" by (simp add: prod_mset_prime_factorization (*‹?x ≠ 0 ⟹ ∏⇩# (prime_factorization ?x) = normalize ?x›*)) finally (*calculation: ‹∏⇩# (prime_factorization n) = ∏⇩# A›*) have "prime_factorization (prod_mset A) = prime_factorization (prod_mset (prime_factorization n))" by simp also (*calculation: ‹prime_factorization (∏⇩# A) = prime_factorization (∏⇩# (prime_factorization n))›*) from S(1) (*‹∀p::'a∈S::'a set. prime p›*) have "prime_factorization (prod_mset A) = A" apply (intro prime_factorization_prod_mset_primes (*‹(⋀p. p ∈# ?A ⟹ prime p) ⟹ prime_factorization (∏⇩# ?A) = ?A›*)) (*goal: ‹prime_factorization (∏⇩# A) = A›*) by (auto simp: set_mset_A (*‹set_mset A = S›*)) also (*calculation: ‹A = prime_factorization (∏⇩# (prime_factorization n))›*) have "prime_factorization (prod_mset (prime_factorization n)) = prime_factorization n" apply (intro prime_factorization_prod_mset_primes (*‹(⋀p. p ∈# ?A ⟹ prime p) ⟹ prime_factorization (∏⇩# ?A) = ?A›*)) (*goal: ‹prime_factorization (∏⇩# (prime_factorization (n::'a))) = prime_factorization n›*) by auto finally (*calculation: ‹A = prime_factorization n›*) show "S = prime_factors n" by (simp add: set_mset_A [symmetric] (*‹(S::'a set) = set_mset (A::'a multiset)›*)) show "(∀p. prime p ⟶ f p = multiplicity p n)" proof (safe) (*goal: ‹⋀p. prime p ⟹ f p = multiplicity p n›*) fix p :: 'a assume p: "prime p" (*‹prime (p::'a)›*) have "multiplicity p n = multiplicity p (normalize n)" by simp also (*calculation: ‹multiplicity p n = multiplicity p (normalize n)›*) have "normalize n = prod_mset A" by (simp add: prod_mset_multiplicity (*‹∏⇩# (?M::'a::type multiset) = (∏x::'a::type∈set_mset ?M. x ^ count ?M x)›*) S_eq (*‹(S::'a::type set) = {p::'a::type. (0::nat) < (f::'a::type ⇒ nat) p}›*) set_mset_A (*‹set_mset (A::'a::type multiset) = (S::'a::type set)›*) count_A (*‹count (A::'a::type multiset) = (f::'a::type ⇒ nat)›*) S (*‹∀p::'a::type∈S::'a::type set. prime p› ‹normalize (n::'a::type) = (∏p::'a::type∈(S::'a::type set). p ^ (f::'a::type ⇒ nat) p)›*)) also (*calculation: ‹multiplicity (p::'a) (n::'a) = multiplicity p (∏⇩# (A::'a multiset))›*) from p (*‹prime p›*) set_mset_A (*‹set_mset A = S›*) S(1) (*‹∀p∈S. prime p›*) have "multiplicity p … = sum_mset (image_mset (multiplicity p) A)" apply (intro prime_elem_multiplicity_prod_mset_distrib (*‹⟦prime_elem (?p::'a); (0::'a) ∉# (?A::'a multiset)⟧ ⟹ multiplicity ?p (∏⇩# ?A) = ∑⇩# (image_mset (multiplicity ?p) ?A)›*)) (*goals: 1. ‹⟦prime p; set_mset A = S; ∀p∈S. prime p⟧ ⟹ prime_elem p› 2. ‹⟦prime p; set_mset A = S; ∀p∈S. prime p⟧ ⟹ 0 ∉# A› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . also (*calculation: ‹multiplicity p n = ∑⇩# (image_mset (multiplicity p) A)›*) from S(1) (*‹∀p∈S. prime p›*) p (*‹prime p›*) have "image_mset (multiplicity p) A = image_mset (λq. if p = q then 1 else 0) A" apply (intro image_mset_cong (*‹(⋀x::?'a. x ∈# (?M::?'a multiset) ⟹ (?f::?'a ⇒ ?'b) x = (?g::?'a ⇒ ?'b) x) ⟹ image_mset ?f ?M = image_mset ?g ?M›*)) (*goal: ‹image_mset (multiplicity p) A = {#if p = q then 1 else 0. q ∈# A#}›*) by (auto simp: set_mset_A (*‹set_mset A = S›*) multiplicity_self (*‹⟦?p ≠ 0; ¬ is_unit ?p⟧ ⟹ multiplicity ?p ?p = 1›*) prime_multiplicity_other (*‹⟦prime ?p; prime ?q; ?p ≠ ?q⟧ ⟹ multiplicity ?p ?q = 0›*)) also (*calculation: ‹multiplicity p n = (∑q∈#A. if p = q then 1 else 0)›*) have "sum_mset … = f p" by (simp add: semiring_1_class.sum_mset_delta' (*‹(∑x∈#?A. if ?y = x then ?c else 0) = ?c * of_nat (count ?A ?y)›*) count_A (*‹count A = f›*)) finally (*calculation: ‹multiplicity p n = f p›*) show "f p = multiplicity p n" by standard qed qed lemma divides_primepow: assumes "prime p" and "a dvd p ^ n" obtains m where "m ≤ n" and "normalize a = p ^ m" using divides_primepow_weak[OF assms] (*‹(⋀m::nat. ⟦m ≤ (n::nat); normalize (a::'a::type) = normalize ((p::'a::type) ^ m)⟧ ⟹ ?thesis::bool) ⟹ ?thesis›*) that (*‹⟦?m1 ≤ n; normalize a = p ^ ?m1⟧ ⟹ thesis›*) assms (*‹prime (p::'a::type)› ‹(a::'a::type) dvd (p::'a::type) ^ (n::nat)›*) by (auto simp add: normalize_power (*‹normalize (?a ^ ?n) = normalize ?a ^ ?n›*)) lemma Ex_other_prime_factor: assumes "n ≠ 0" and "¬(∃k. normalize n = p ^ k)" "prime p" shows "∃q∈prime_factors n. q ≠ p" proof (rule ccontr (*‹(¬ ?P ⟹ False) ⟹ ?P›*)) (*goal: ‹¬ (∃q∈prime_factors n. q ≠ p) ⟹ False›*) assume "*": "¬(∃q∈prime_factors n. q ≠ p)" (*‹¬ (∃q::'a∈prime_factors (n::'a). q ≠ (p::'a))›*) have "normalize n = (∏p∈prime_factors n. p ^ multiplicity p n)" using assms(1) (*‹n ≠ 0›*) apply (intro prod_prime_factors [symmetric] (*‹?x ≠ 0 ⟹ normalize ?x = (∏p∈prime_factors ?x. p ^ multiplicity p ?x)›*)) (*goal: ‹normalize n = (∏p∈prime_factors n. p ^ multiplicity p n)›*) by auto also (*calculation: ‹normalize n = (∏p∈prime_factors n. p ^ multiplicity p n)›*) from "*" (*‹¬ (∃q∈prime_factors n. q ≠ p)›*) have "… = (∏p∈{p}. p ^ multiplicity p n)" using assms(3) (*‹prime p›*) apply (intro prod.mono_neutral_left (*‹⟦finite ?T; ?S ⊆ ?T; ∀i∈?T - ?S. ?g i = 1⟧ ⟹ prod ?g ?S = prod ?g ?T›*)) (*goals: 1. ‹⟦¬ (∃q::'a∈prime_factors (n::'a). q ≠ (p::'a)); prime p⟧ ⟹ finite {p}› 2. ‹⟦¬ (∃q::'a∈prime_factors (n::'a). q ≠ (p::'a)); prime p⟧ ⟹ prime_factors n ⊆ {p}› 3. ‹⟦¬ (∃q::'a∈prime_factors (n::'a). q ≠ (p::'a)); prime p⟧ ⟹ ∀i::'a∈{p} - prime_factors n. i ^ multiplicity i n = (1::'a)› discuss goal 1*) apply ((auto simp: prime_factors_multiplicity (*‹prime_factors ?n = {p. prime p ∧ 0 < multiplicity p ?n}›*))[1]) (*discuss goal 2*) apply ((auto simp: prime_factors_multiplicity (*‹prime_factors ?n = {p. prime p ∧ 0 < multiplicity p ?n}›*))[1]) (*discuss goal 3*) apply ((auto simp: prime_factors_multiplicity (*‹prime_factors (?n::'a) = {p::'a. prime p ∧ (0::nat) < multiplicity p ?n}›*))[1]) (*proven 3 subgoals*) . finally (*calculation: ‹normalize n = (∏p∈{p}. p ^ multiplicity p n)›*) have "normalize n = p ^ multiplicity p n" by auto with assms (*‹n ≠ 0› ‹∄k. normalize n = p ^ k› ‹prime p›*) show False by auto qed text ‹Now a string of results due to Maya Kądziołka› lemma multiplicity_dvd_iff_dvd: assumes "x ≠ 0" shows "p^k dvd x ⟷ p^k dvd p^multiplicity p x" proof (cases "is_unit p") (*goals: 1. ‹is_unit p ⟹ (p ^ k dvd x) = (p ^ k dvd p ^ multiplicity p x)› 2. ‹¬ is_unit p ⟹ (p ^ k dvd x) = (p ^ k dvd p ^ multiplicity p x)›*) case True (*‹is_unit (p::'a)›*) then have "is_unit (p^k)" using is_unit_power_iff (*‹is_unit (?a ^ ?n) = (is_unit ?a ∨ ?n = 0)›*) by simp hence "p^k dvd x" by auto moreover from ‹is_unit p› (*‹is_unit p›*) have "p^k dvd p^multiplicity p x" using multiplicity_unit_left (*‹is_unit ?p ⟹ multiplicity ?p ?x = 0›*) is_unit_power_iff (*‹is_unit (?a ^ ?n) = (is_unit ?a ∨ ?n = 0)›*) by simp ultimately show "?thesis" (*goal: ‹(p ^ k dvd x) = (p ^ k dvd p ^ multiplicity p x)›*) by simp next (*goal: ‹¬ is_unit p ⟹ (p ^ k dvd x) = (p ^ k dvd p ^ multiplicity p x)›*) case False (*‹¬ is_unit p›*) show "?thesis" (*goal: ‹((p::'a) ^ (k::nat) dvd (x::'a)) = (p ^ k dvd p ^ multiplicity p x)›*) proof (cases "p = 0") (*goals: 1. ‹p = 0 ⟹ (p ^ k dvd x) = (p ^ k dvd p ^ multiplicity p x)› 2. ‹p ≠ 0 ⟹ (p ^ k dvd x) = (p ^ k dvd p ^ multiplicity p x)›*) case True (*‹p = 0›*) then have "p^multiplicity p x = 1" by simp moreover have "p^k dvd x ⟹ k = 0" proof (rule ccontr (*‹(¬ ?P ⟹ False) ⟹ ?P›*)) (*goal: ‹⟦p ^ k dvd x; k ≠ 0⟧ ⟹ False›*) assume "p^k dvd x" and "k ≠ 0" (*‹(p::'a) ^ (k::nat) dvd (x::'a)› ‹(k::nat) ≠ (0::nat)›*) with ‹p = 0› (*‹p = 0›*) have "p^k = 0" by auto with ‹p^k dvd x› (*‹(p::'a) ^ (k::nat) dvd (x::'a)›*) have "0 dvd x" by auto hence "x = 0" by auto with ‹x ≠ 0› (*‹x ≠ 0›*) show False by auto qed ultimately show "?thesis" (*goal: ‹(p ^ k dvd x) = (p ^ k dvd p ^ multiplicity p x)›*) by (auto simp add: is_unit_power_iff (*‹is_unit (?a ^ ?n) = (is_unit ?a ∨ ?n = 0)›*) ‹¬ is_unit p›) next (*goal: ‹p ≠ 0 ⟹ (p ^ k dvd x) = (p ^ k dvd p ^ multiplicity p x)›*) case False (*‹p ≠ 0›*) with ‹x ≠ 0› (*‹x ≠ 0›*) ‹¬ is_unit p› (*‹¬ is_unit p›*) show "?thesis" (*goal: ‹(p ^ k dvd x) = (p ^ k dvd p ^ multiplicity p x)›*) by (simp add: power_dvd_iff_le_multiplicity (*‹⟦?x ≠ 0; ¬ is_unit ?p⟧ ⟹ (?p ^ ?n dvd ?x) = (?n ≤ multiplicity ?p ?x)›*) dvd_power_iff (*‹?x ≠ 0 ⟹ (?x ^ ?m dvd ?x ^ ?n) = (is_unit ?x ∨ ?m ≤ ?n)›*) multiplicity_same_power (*‹⟦?p ≠ 0; ¬ is_unit ?p⟧ ⟹ multiplicity ?p (?p ^ ?n) = ?n›*)) qed qed lemma multiplicity_decomposeI: assumes "x = p^k * x'" and "¬ p dvd x'" and "p ≠ 0" shows "multiplicity p x = k" using assms (*‹x = p ^ k * x'› ‹¬ p dvd x'› ‹p ≠ 0›*) local.multiplicity_eqI (*‹⟦(?p::'a::type) ^ (?n::nat) dvd (?x::'a::type); ¬ ?p ^ Suc ?n dvd ?x⟧ ⟹ multiplicity ?p ?x = ?n›*) local.power_Suc2 (*‹?a ^ Suc ?n = ?a ^ ?n * ?a›*) by force lemma multiplicity_sum_lt: assumes "multiplicity p a < multiplicity p b" "a ≠ 0" "b ≠ 0" shows "multiplicity p (a + b) = multiplicity p a" proof (-) (*goal: ‹multiplicity p (a + b) = multiplicity p a›*) let ?vp = "multiplicity p" have unit: "¬ is_unit p" proof (standard) (*goal: ‹is_unit p ⟹ False›*) assume "is_unit p" (*‹is_unit (p::'a)›*) then have "?vp a = 0" and "?vp b = 0" using multiplicity_unit_left (*‹is_unit ?p ⟹ multiplicity ?p ?x = 0›*) apply - (*goals: 1. ‹⟦is_unit p; ⋀p x. is_unit p ⟹ multiplicity p x = 0⟧ ⟹ multiplicity p a = 0› 2. ‹⟦is_unit p; ⋀p x. is_unit p ⟹ multiplicity p x = 0⟧ ⟹ multiplicity p b = 0› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . with assms (*‹multiplicity p a < multiplicity p b› ‹a ≠ 0› ‹b ≠ 0›*) show False by auto qed from multiplicity_decompose' (*‹⟦(?x::'a) ≠ (0::'a); ¬ is_unit (?p::'a); ⋀y::'a. ⟦?x = ?p ^ multiplicity ?p ?x * y; ¬ ?p dvd y⟧ ⟹ ?thesis::bool⟧ ⟹ ?thesis›*) obtain a' where a': "a = p^?vp a * a'" "¬ p dvd a'" (*goal: ‹(⋀a'. ⟦a = p ^ multiplicity p a * a'; ¬ p dvd a'⟧ ⟹ thesis) ⟹ thesis›*) using unit (*‹¬ is_unit p›*) assms (*‹multiplicity (p::'a::type) (a::'a::type) < multiplicity p (b::'a::type)› ‹a ≠ 0› ‹b ≠ 0›*) by metis from multiplicity_decompose' (*‹⟦?x ≠ 0; ¬ is_unit ?p; ⋀y. ⟦?x = ?p ^ multiplicity ?p ?x * y; ¬ ?p dvd y⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*) obtain b' where b': "b = p^?vp b * b'" (*goal: ‹(⋀b'. b = p ^ multiplicity p b * b' ⟹ thesis) ⟹ thesis›*) using unit (*‹¬ is_unit p›*) assms (*‹multiplicity p a < multiplicity p b› ‹(a::'a) ≠ (0::'a)› ‹b ≠ 0›*) by metis show "?vp (a + b) = ?vp a" proof (rule multiplicity_decomposeI (*‹⟦?x = ?p ^ ?k * ?x'; ¬ ?p dvd ?x'; ?p ≠ 0⟧ ⟹ multiplicity ?p ?x = ?k›*)) (*goals: 1. ‹a + b = p ^ multiplicity p a * ?x'› 2. ‹¬ p dvd ?x'› 3. ‹p ≠ 0›*) let ?k = "?vp b - ?vp a" from assms (*‹multiplicity p a < multiplicity p b› ‹a ≠ 0› ‹b ≠ 0›*) have k: "?k > 0" by simp with b' (*‹(b::'a) = (p::'a) ^ multiplicity p b * (b'::'a)›*) have "b = p^?vp a * p^?k * b'" by (simp flip: power_add (*‹?a ^ (?m + ?n) = ?a ^ ?m * ?a ^ ?n›*)) with a' (*‹(a::'a::type) = (p::'a::type) ^ multiplicity p a * (a'::'a::type)› ‹¬ p dvd a'›*) show "*": "a + b = p^?vp a * (a' + p^?k * b')" by (simp add: 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 43 facts*) distrib_left (*‹?a * (?b + ?c) = ?a * ?b + ?a * ?c›*)) moreover show "¬ p dvd a' + p^?k * b'" using a' (*‹a = p ^ multiplicity p a * a'› ‹¬ p dvd a'›*) k (*‹0 < multiplicity p b - multiplicity p a›*) dvd_add_left_iff (*‹?a dvd ?c ⟹ (?a dvd ?b + ?c) = (?a dvd ?b)›*) by auto show "p ≠ 0" using assms (*‹multiplicity p a < multiplicity p b› ‹a ≠ 0› ‹b ≠ 0›*) by auto qed qed corollary multiplicity_sum_min: assumes "multiplicity p a ≠ multiplicity p b" "a ≠ 0" "b ≠ 0" shows "multiplicity p (a + b) = min (multiplicity p a) (multiplicity p b)" proof (-) (*goal: ‹multiplicity p (a + b) = min (multiplicity p a) (multiplicity p b)›*) let ?vp = "multiplicity p" from assms (*‹multiplicity p a ≠ multiplicity p b› ‹a ≠ 0› ‹b ≠ 0›*) have "?vp a < ?vp b ∨ ?vp a > ?vp b" by auto then show "?thesis" (*goal: ‹multiplicity p (a + b) = min (multiplicity p a) (multiplicity p b)›*) by (metis assms (*‹multiplicity p a ≠ multiplicity p b› ‹a ≠ 0› ‹b ≠ 0›*) multiplicity_sum_lt (*‹⟦multiplicity ?p ?a < multiplicity ?p ?b; ?a ≠ 0; ?b ≠ 0⟧ ⟹ multiplicity ?p (?a + ?b) = multiplicity ?p ?a›*) min.commute (*‹min ?a ?b = min ?b ?a›*) add_commute (*‹?a + ?b = ?b + ?a›*) min.strict_order_iff (*‹(?a < ?b) = (?a = min ?a ?b ∧ ?a ≠ ?b)›*)) qed end lifting_update multiset.lifting lifting_forget multiset.lifting end
{ "path": "Isabelle2024/src/HOL/Computational_Algebra/Factorial_Ring.thy", "repo": "Isabelle2024", "sha": "0e2a08d88de5f807be7af6ca82e75aa7b9ba83c290b5ada4030cb0816471b95f" }
section ‹K-dimensional Region Trees - Nested Trees› (* Nested trees: Each level of the k-d tree (kdt) is encapsulated in a separate splitting tree (tree1). Experimental. *) theory KD_Region_Nested imports "HOL-Library.NList" begin (* TODO: In Isabelle after 2023 - remove *) lemma nlists_Suc: "nlists (Suc n) A = (⋃a∈A. (#) a ` nlists n A)" by (auto simp: 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)›*) in_nlists_Suc_iff (*‹((?xs::?'a list) ∈ nlists (Suc (?n::nat)) (?A::?'a set)) = (∃y::?'a∈?A. ∃ys::?'a list∈nlists ?n ?A. ?xs = y # ys)›*)) lemma nlists_singleton: "nlists n {a} = {replicate n a}" unfolding nlists_def (*goal: ‹{xs. length xs = n ∧ set xs ⊆ {a}} = {replicate n a}›*) by (auto simp: replicate_length_same (*‹∀y∈set ?xs. y = ?x ⟹ replicate (length ?xs) ?x = ?xs›*) dest!: subset_singletonD (*‹?A ⊆ {?x} ⟹ ?A = {} ∨ ?A = {?x}›*)) fun cube :: "nat ⇒ nat ⇒ nat list set" where "cube k n = nlists k {0..<2^n}" datatype 'a tree1 = Lf 'a | Br "'a tree1" "'a tree1" datatype 'a kdt = Cube 'a | Dims "'a kdt tree1" (* For quickcheck: *) datatype_compat tree1 datatype_compat kdt type_synonym kdtb = "bool kdt" lemma set_tree1_finite_ne: "finite (set_tree1 t) ∧ set_tree1 t ≠ {}" apply (induction t) (*goals: 1. ‹⋀x. finite (set_tree1 (Lf x)) ∧ set_tree1 (Lf x) ≠ {}› 2. ‹⋀t1 t2. ⟦finite (set_tree1 t1) ∧ set_tree1 t1 ≠ {}; finite (set_tree1 t2) ∧ set_tree1 t2 ≠ {}⟧ ⟹ finite (set_tree1 (Br t1 t2)) ∧ set_tree1 (Br t1 t2) ≠ {}› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . lemma kdt_tree1_term[termination_simp]: "x ∈ set_tree1 t ⟹ size_kdt f x < Suc (size_tree1 (size_kdt f) t)" apply (induction t) (*goals: 1. ‹⋀xa::'a kdt. (x::'a kdt) ∈ set_tree1 (Lf xa) ⟹ size_kdt (f::'a ⇒ nat) x < Suc (size_tree1 (size_kdt f) (Lf xa))› 2. ‹⋀(t1::'a kdt tree1) t2::'a kdt tree1. ⟦(x::'a kdt) ∈ set_tree1 t1 ⟹ size_kdt (f::'a ⇒ nat) x < Suc (size_tree1 (size_kdt f) t1); x ∈ set_tree1 t2 ⟹ size_kdt f x < Suc (size_tree1 (size_kdt f) t2); x ∈ set_tree1 (Br t1 t2)⟧ ⟹ size_kdt f x < Suc (size_tree1 (size_kdt f) (Br t1 t2))› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . fun h_tree1 :: "'a tree1 ⇒ nat" where "h_tree1 (Lf _) = 0" | "h_tree1 (Br l r) = max (h_tree1 l) (h_tree1 r) + 1" function (sequential) h_kdt :: "'a kdt ⇒ nat" where "h_kdt (Cube _) = 0" | "h_kdt (Dims t) = Max (h_kdt ` (set_tree1 t)) + 1" by pat_completeness auto termination by(relation "measure (size_kdt (λ_. 1))") (auto simp add: wf_lex_prod kdt_tree1_term) function (sequential) inv_kdt :: "nat ⇒ 'a kdt ⇒ bool" where "inv_kdt k (Cube b) = True" | "inv_kdt k (Dims t) = (h_tree1 t ≤ k ∧ (∀kt ∈ set_tree1 t. inv_kdt k kt))" by pat_completeness auto termination by(relation "{} <*lex*> measure (size_kdt (λ_. 1))") (auto simp add: wf_lex_prod kdt_tree1_term) definition bits :: "nat ⇒ bool list set" where "bits n = nlists n UNIV" lemma bits_0[code]: "bits 0 = {[]}" by (auto simp: bits_def (*‹bits ?n = nlists ?n UNIV›*)) lemma bits_Suc[code]: "bits (Suc n) = (let B = bits n in (#) True ` B ∪ (#) False ` B)" unfolding bits_def nlists_Suc UN_bool_eq (*goal: ‹(#) True ` nlists n UNIV ∪ (#) False ` nlists n UNIV = (let B = nlists n UNIV in (#) True ` B ∪ (#) False ` B)›*) by metis fun leaf :: "'a tree1 ⇒ bool list ⇒ 'a" where "leaf (Lf x) _ = x" | "leaf (Br l r) (b#bs) = leaf (if b then r else l) bs" | "leaf (Br l r) [] = leaf l []" (* to avoid undefinedness *) definition mv :: "bool list ⇒ nat list ⇒ nat list" where "mv = map2 (λb x. 2*x + (if b then 0 else 1))" fun points :: "nat ⇒ nat ⇒ kdtb ⇒ nat list set" where "points k n (Cube b) = (if b then cube k n else {})" | "points k (Suc n) (Dims t) = (⋃bs ∈ bits k. mv bs ` points k n (leaf t bs))" lemma bits_nonempty: "bits n ≠ {}" by (auto simp: bits_def (*‹bits ?n = nlists ?n UNIV›*) Ex_list_of_length (*‹∃xs. length xs = ?n›*)) lemma finite_bits: "finite (bits n)" by (metis List.finite_set (*‹finite (set ?xs)›*) List.set_insert (*‹set (List.insert ?x ?xs) = insert ?x (set ?xs)›*) UNIV_bool (*‹UNIV = {False, True}›*) bits_def (*‹bits ?n = nlists ?n UNIV›*) empty_set (*‹{} = set []›*) nlists_set (*‹nlists ?n (set ?xs) = set (List.n_lists ?n ?xs)›*)) lemma mv_in_nlists: "⟦ p ∈ nlists k {0..<2 ^ n}; bs ∈ bits k ⟧ ⟹ mv bs p ∈ nlists k {0..<2 * 2 ^ n}" unfolding mv_def nlists_def bits_def (*goal: ‹⟦p ∈ {xs. length xs = k ∧ set xs ⊆ {0..<2 ^ n}}; bs ∈ {xs. length xs = k ∧ set xs ⊆ UNIV}⟧ ⟹ map2 (λx y. 2 * y + (if x then 0 else 1)) bs p ∈ {xs. length xs = k ∧ set xs ⊆ {0..<2 * 2 ^ n}}›*) by (fastforce dest: set_zip_rightD (*‹(?x, ?y) ∈ set (zip ?xs ?ys) ⟹ ?y ∈ set ?ys›*)) lemma leaf_append: "length bs ≥ h_tree1 t ⟹ leaf t (bs@bs') = leaf t bs" apply (induction t bs arbitrary: bs' rule: leaf.induct) (*goals: 1. ‹⋀x uu_ bs'. h_tree1 (Lf x) ≤ length uu_ ⟹ leaf (Lf x) (uu_ @ bs') = leaf (Lf x) uu_› 2. ‹⋀l r b bs bs'. ⟦⋀bs'. h_tree1 (if b then r else l) ≤ length bs ⟹ leaf (if b then r else l) (bs @ bs') = leaf (if b then r else l) bs; h_tree1 (Br l r) ≤ length (b # bs)⟧ ⟹ leaf (Br l r) ((b # bs) @ bs') = leaf (Br l r) (b # bs)› 3. ‹⋀l r bs'. ⟦⋀bs'. h_tree1 l ≤ length [] ⟹ leaf l ([] @ bs') = leaf l []; h_tree1 (Br l r) ≤ length []⟧ ⟹ leaf (Br l r) ([] @ bs') = leaf (Br l r) []› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*proven 3 subgoals*) . lemma leaf_take: "length bs ≥ h_tree1 t ⟹ leaf t (bs) = leaf t (take (h_tree1 t) bs)" by (metis append_take_drop_id (*‹take ?n ?xs @ drop ?n ?xs = ?xs›*) leaf_append (*‹h_tree1 ?t ≤ length ?bs ⟹ leaf ?t (?bs @ ?bs') = leaf ?t ?bs›*) length_take (*‹length (take ?n ?xs) = min (length ?xs) ?n›*) min.absorb2 (*‹?b ≤ ?a ⟹ min ?a ?b = ?b›*) order_refl (*‹?x ≤ ?x›*)) lemma Union_bits_le: "h_tree1 t ≤ n ⟹ (⋃bs∈bits n. {leaf t bs}) = (⋃bs∈bits (h_tree1 t). {leaf t bs})" unfolding bits_def nlists_def (*goal: ‹h_tree1 t ≤ n ⟹ (⋃bs∈{xs. length xs = n ∧ set xs ⊆ UNIV}. {leaf t bs}) = (⋃bs∈{xs. length xs = h_tree1 t ∧ set xs ⊆ UNIV}. {leaf t bs})›*) apply rule (*goal: ‹h_tree1 t ≤ n ⟹ (⋃bs∈{xs. length xs = n ∧ set xs ⊆ UNIV}. {leaf t bs}) = (⋃bs∈{xs. length xs = h_tree1 t ∧ set xs ⊆ UNIV}. {leaf t bs})›*) using leaf_take (*‹h_tree1 ?t ≤ length ?bs ⟹ leaf ?t ?bs = leaf ?t (take (h_tree1 ?t) ?bs)›*) (*goals: 1. ‹h_tree1 t ≤ n ⟹ (⋃bs∈{xs. length xs = n ∧ set xs ⊆ UNIV}. {leaf t bs}) ⊆ (⋃bs∈{xs. length xs = h_tree1 t ∧ set xs ⊆ UNIV}. {leaf t bs})› 2. ‹h_tree1 t ≤ n ⟹ (⋃bs∈{xs. length xs = h_tree1 t ∧ set xs ⊆ UNIV}. {leaf t bs}) ⊆ (⋃bs∈{xs. length xs = n ∧ set xs ⊆ UNIV}. {leaf t bs})› discuss goal 1*) apply force (*discuss goal 2*) apply auto (*goal: ‹h_tree1 t ≤ n ⟹ (⋃bs∈{xs. length xs = h_tree1 t ∧ set xs ⊆ UNIV}. {leaf t bs}) ⊆ (⋃bs∈{xs. length xs = n ∧ set xs ⊆ UNIV}. {leaf t bs})›*) apply (metis Ex_list_of_length (*‹∃xs::?'a list. length xs = (?n::nat)›*) order.refl (*‹(?a::?'a) ≤ ?a›*) le_add_diff_inverse (*‹(?b::?'a) ≤ (?a::?'a) ⟹ ?b + (?a - ?b) = ?a›*) leaf_append (*‹h_tree1 (?t::?'a tree1) ≤ length (?bs::bool list) ⟹ leaf ?t (?bs @ (?bs'::bool list)) = leaf ?t ?bs›*) length_append (*‹length ((?xs::?'a list) @ (?ys::?'a list)) = length ?xs + length ?ys›*)) (*proven 2 subgoals*) . lemma set_tree1_leafs: "set_tree1 t = (⋃bs ∈ bits (h_tree1 t). {leaf t bs})" proof (induction t) (*goals: 1. ‹⋀x. set_tree1 (Lf x) = (⋃bs∈bits (h_tree1 (Lf x)). {leaf (Lf x) bs})› 2. ‹⋀t1 t2. ⟦set_tree1 t1 = (⋃bs∈bits (h_tree1 t1). {leaf t1 bs}); set_tree1 t2 = (⋃bs∈bits (h_tree1 t2). {leaf t2 bs})⟧ ⟹ set_tree1 (Br t1 t2) = (⋃bs∈bits (h_tree1 (Br t1 t2)). {leaf (Br t1 t2) bs})›*) case (Lf x) (*no hyothesis introduced yet*) then show "?case" (*goal: ‹set_tree1 (Lf x) = (⋃bs∈bits (h_tree1 (Lf x)). {leaf (Lf x) bs})›*) by (simp add: bits_nonempty (*‹bits ?n ≠ {}›*)) next (*goal: ‹⋀t1 t2. ⟦set_tree1 t1 = (⋃bs∈bits (h_tree1 t1). {leaf t1 bs}); set_tree1 t2 = (⋃bs∈bits (h_tree1 t2). {leaf t2 bs})⟧ ⟹ set_tree1 (Br t1 t2) = (⋃bs∈bits (h_tree1 (Br t1 t2)). {leaf (Br t1 t2) bs})›*) case (Br t1 t2) (*‹set_tree1 (t1::'a tree1) = (⋃bs::bool list∈bits (h_tree1 t1). {leaf t1 bs})› ‹set_tree1 (t2::'a::type tree1) = (⋃bs::bool list∈bits (h_tree1 t2). {leaf t2 bs})›*) then show "?case" (*goal: ‹set_tree1 (Br t1 t2) = (⋃bs∈bits (h_tree1 (Br t1 t2)). {leaf (Br t1 t2) bs})›*) using Union_bits_le[of t1 "h_tree1 t2"] (*‹h_tree1 t1 ≤ h_tree1 t2 ⟹ (⋃bs∈bits (h_tree1 t2). {leaf t1 bs}) = (⋃bs∈bits (h_tree1 t1). {leaf t1 bs})›*) Union_bits_le[of t2 "h_tree1 t1"] (*‹h_tree1 t2 ≤ h_tree1 t1 ⟹ (⋃bs∈bits (h_tree1 t1). {leaf t2 bs}) = (⋃bs∈bits (h_tree1 t2). {leaf t2 bs})›*) by (auto simp add: Let_def (*‹Let ?s ?f ≡ ?f ?s›*) bits_Suc (*‹bits (Suc ?n) = (let B = bits ?n in (#) True ` B ∪ (#) False ` B)›*) max_def (*‹max ?a ?b = (if ?a ≤ ?b then ?b else ?a)›*)) qed lemma points_subset: "inv_kdt k t ⟹ h_kdt t ≤ n ⟹ points k n t ⊆ nlists k {0..<2^n}" proof (induction k n t rule: points.induct (*‹⟦⋀k n b. ?P k n (Cube b); ⋀k n t. (⋀x. x ∈ bits k ⟹ ?P k n (leaf t x)) ⟹ ?P k (Suc n) (Dims t); ⋀a v. ?P a 0 (Dims v)⟧ ⟹ ?P ?a0.0 ?a1.0 ?a2.0›*)) (*goals: 1. ‹⋀k n b. ⟦inv_kdt k (Cube b); h_kdt (Cube b) ≤ n⟧ ⟹ points k n (Cube b) ⊆ nlists k {0..<2 ^ n}› 2. ‹⋀k n t. ⟦⋀x. ⟦x ∈ bits k; inv_kdt k (leaf t x); h_kdt (leaf t x) ≤ n⟧ ⟹ points k n (leaf t x) ⊆ nlists k {0..<2 ^ n}; inv_kdt k (Dims t); h_kdt (Dims t) ≤ Suc n⟧ ⟹ points k (Suc n) (Dims t) ⊆ nlists k {0..<2 ^ Suc n}› 3. ‹⋀a v. ⟦inv_kdt a (Dims v); h_kdt (Dims v) ≤ 0⟧ ⟹ points a 0 (Dims v) ⊆ nlists a {0..<2 ^ 0}›*) case (2 k n t) (*‹⟦?x ∈ bits k; inv_kdt k (leaf t ?x); h_kdt (leaf t ?x) ≤ n⟧ ⟹ points k n (leaf t ?x) ⊆ nlists k {0..<2 ^ n}› ‹inv_kdt k (Dims t)› ‹h_kdt (Dims (t::bool kdt tree1)) ≤ Suc (n::nat)›*) have "mv bs ps ∈ nlists k {0..<2 * 2 ^ n}" if "*": "bs ∈ bits k" "ps ∈ points k n (leaf t bs)" for bs and ps proof (-) (*goal: ‹mv bs ps ∈ nlists k {0..<2 * 2 ^ n}›*) have "inv_kdt k (leaf t bs)" using "*"(1) (*‹bs ∈ bits k›*) "2.prems"(1) (*‹inv_kdt k (Dims t)›*) apply (auto simp: set_tree1_leafs (*‹set_tree1 (?t::?'a::type tree1) = (⋃bs::bool list∈bits (h_tree1 ?t). {leaf ?t bs})›*)) (*goal: ‹inv_kdt (k::nat) (leaf (t::bool kdt tree1) (bs::bool list))›*) by (metis bits_def (*‹bits ?n = nlists ?n UNIV›*) leaf_take (*‹h_tree1 ?t ≤ length ?bs ⟹ leaf ?t ?bs = leaf ?t (take (h_tree1 ?t) ?bs)›*) length_take (*‹length (take ?n ?xs) = min (length ?xs) ?n›*) min.absorb2 (*‹?b ≤ ?a ⟹ min ?a ?b = ?b›*) nlistsE_length (*‹?xs ∈ nlists ?n ?A ⟹ length ?xs = ?n›*) nlistsI (*‹⟦length ?xs = ?n; set ?xs ⊆ ?A⟧ ⟹ ?xs ∈ nlists ?n ?A›*) subset_UNIV (*‹?A ⊆ UNIV›*)) moreover have "h_kdt (leaf t bs) ≤ n" using "*"(1) (*‹bs ∈ bits k›*) "2.prems" (*‹inv_kdt k (Dims t)› ‹h_kdt (Dims t) ≤ Suc n›*) apply (auto simp add: set_tree1_leafs (*‹set_tree1 (?t::?'a tree1) = (⋃bs::bool list∈bits (h_tree1 ?t). {leaf ?t bs})›*) bits_nonempty (*‹bits (?n::nat) ≠ {}›*) finite_bits (*‹finite (bits (?n::nat))›*)) (*goal: ‹h_kdt (leaf t bs) ≤ n›*) by (metis bits_def (*‹bits (?n::nat) = nlists ?n UNIV›*) leaf_take (*‹h_tree1 (?t::?'a tree1) ≤ length (?bs::bool list) ⟹ leaf ?t ?bs = leaf ?t (take (h_tree1 ?t) ?bs)›*) length_take (*‹length (take (?n::nat) (?xs::?'a list)) = min (length ?xs) ?n›*) min.absorb2 (*‹(?b::?'a) ≤ (?a::?'a) ⟹ min ?a ?b = ?b›*) nlistsE_length (*‹(?xs::?'a list) ∈ nlists (?n::nat) (?A::?'a set) ⟹ length ?xs = ?n›*) nlistsI (*‹⟦length (?xs::?'a list) = (?n::nat); set ?xs ⊆ (?A::?'a set)⟧ ⟹ ?xs ∈ nlists ?n ?A›*) subset_UNIV (*‹(?A::?'a set) ⊆ UNIV›*)) ultimately show "?thesis" (*goal: ‹mv (bs::bool list) (ps::nat list) ∈ nlists (k::nat) {0::nat..<(2::nat) * (2::nat) ^ (n::nat)}›*) using "*" (*‹bs ∈ bits k› ‹ps ∈ points k n (leaf t bs)›*) "2.IH"[of bs] (*‹⟦(bs::bool list) ∈ bits (k::nat); inv_kdt k (leaf (t::bool kdt tree1) bs); h_kdt (leaf t bs) ≤ (n::nat)⟧ ⟹ points k n (leaf t bs) ⊆ nlists k {0::nat..<(2::nat) ^ n}›*) mv_in_nlists (*‹⟦?p ∈ nlists ?k {0..<2 ^ ?n}; ?bs ∈ bits ?k⟧ ⟹ mv ?bs ?p ∈ nlists ?k {0..<2 * 2 ^ ?n}›*) by auto qed thus "?case" (*goal: ‹points k (Suc n) (Dims t) ⊆ nlists k {0..<2 ^ Suc n}›*) by auto qed (auto) (*solves the remaining goals: 1. ‹⋀(k::nat) (n::nat) b::bool. ⟦inv_kdt k (Cube b); h_kdt (Cube b) ≤ n⟧ ⟹ points k n (Cube b) ⊆ nlists k {0::nat..<(2::nat) ^ n}› 2. ‹⋀(a::nat) v::bool kdt tree1. ⟦inv_kdt a (Dims v); h_kdt (Dims v) ≤ (0::nat)⟧ ⟹ points a (0::nat) (Dims v) ⊆ nlists a {0::nat..<(2::nat) ^ (0::nat)}›*) fun comb1 :: "('a ⇒ 'a ⇒ 'a) ⇒ 'a tree1 ⇒ 'a tree1 ⇒ 'a tree1" where "comb1 f (Lf x1) (Lf x2) = Lf (f x1 x2)" | "comb1 f (Br l1 r1) (Br l2 r2) = Br (comb1 f l1 l2) (comb1 f r1 r2)" | "comb1 f (Br l1 r1) (Lf x) = Br (comb1 f l1 (Lf x)) (comb1 f r1 (Lf x))" | "comb1 f (Lf x) (Br l2 r2) = Br (comb1 f (Lf x) l2) (comb1 f (Lf x) r2)" text ‹The last two equations cover cases that do not arise but are needed to prove that @{const comb1} only applies ‹f› to elements of the two trees, which implies this congruence lemma:› lemma comb1_cong[fundef_cong]: "⟦s1 = t1; s2 = t2; ⋀x y. x ∈ set_tree1 t1 ⟹ y ∈ set_tree1 t2 ⟹ f x y = g x y⟧ ⟹ comb1 f s1 s2 = comb1 g t1 t2" apply (induction f t1 t2 arbitrary: s1 s2 rule: comb1.induct) (*goals: 1. ‹⋀f x1 x2 s1 s2. ⟦s1 = Lf x1; s2 = Lf x2; ⋀x y. ⟦x ∈ set_tree1 (Lf x1); y ∈ set_tree1 (Lf x2)⟧ ⟹ f x y = g x y⟧ ⟹ comb1 f s1 s2 = comb1 g (Lf x1) (Lf x2)› 2. ‹⋀f l1 r1 l2 r2 s1 s2. ⟦⋀s1 s2. ⟦s1 = l1; s2 = l2; ⋀x y. ⟦x ∈ set_tree1 l1; y ∈ set_tree1 l2⟧ ⟹ f x y = g x y⟧ ⟹ comb1 f s1 s2 = comb1 g l1 l2; ⋀s1 s2. ⟦s1 = r1; s2 = r2; ⋀x y. ⟦x ∈ set_tree1 r1; y ∈ set_tree1 r2⟧ ⟹ f x y = g x y⟧ ⟹ comb1 f s1 s2 = comb1 g r1 r2; s1 = Br l1 r1; s2 = Br l2 r2; ⋀x y. ⟦x ∈ set_tree1 (Br l1 r1); y ∈ set_tree1 (Br l2 r2)⟧ ⟹ f x y = g x y⟧ ⟹ comb1 f s1 s2 = comb1 g (Br l1 r1) (Br l2 r2)› 3. ‹⋀f l1 r1 x s1 s2. ⟦⋀s1 s2. ⟦s1 = l1; s2 = Lf x; ⋀xa y. ⟦xa ∈ set_tree1 l1; y ∈ set_tree1 (Lf x)⟧ ⟹ f xa y = g xa y⟧ ⟹ comb1 f s1 s2 = comb1 g l1 (Lf x); ⋀s1 s2. ⟦s1 = r1; s2 = Lf x; ⋀xa y. ⟦xa ∈ set_tree1 r1; y ∈ set_tree1 (Lf x)⟧ ⟹ f xa y = g xa y⟧ ⟹ comb1 f s1 s2 = comb1 g r1 (Lf x); s1 = Br l1 r1; s2 = Lf x; ⋀xa y. ⟦xa ∈ set_tree1 (Br l1 r1); y ∈ set_tree1 (Lf x)⟧ ⟹ f xa y = g xa y⟧ ⟹ comb1 f s1 s2 = comb1 g (Br l1 r1) (Lf x)› 4. ‹⋀f x l2 r2 s1 s2. ⟦⋀s1 s2. ⟦s1 = Lf x; s2 = l2; ⋀xa y. ⟦xa ∈ set_tree1 (Lf x); y ∈ set_tree1 l2⟧ ⟹ f xa y = g xa y⟧ ⟹ comb1 f s1 s2 = comb1 g (Lf x) l2; ⋀s1 s2. ⟦s1 = Lf x; s2 = r2; ⋀xa y. ⟦xa ∈ set_tree1 (Lf x); y ∈ set_tree1 r2⟧ ⟹ f xa y = g xa y⟧ ⟹ comb1 f s1 s2 = comb1 g (Lf x) r2; s1 = Lf x; s2 = Br l2 r2; ⋀xa y. ⟦xa ∈ set_tree1 (Lf x); y ∈ set_tree1 (Br l2 r2)⟧ ⟹ f xa y = g xa y⟧ ⟹ comb1 f s1 s2 = comb1 g (Lf x) (Br l2 r2)› 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*) . text ‹This congruence lemma in turn implies that ‹union› terminates because the recursive calls of ‹union› via @{const comb1} only involve elements from the two trees, which are smaller.› function (sequential) union :: "kdtb ⇒ kdtb ⇒ kdtb" where "union (Cube b) t = (if b then Cube True else t)" | "union t (Cube b) = (if b then Cube True else t)" | "union (Dims t1) (Dims t2) = Dims (comb1 union t1 t2)" by pat_completeness auto termination by(relation "measure (size_kdt (λ_. 1)) <*lex*> {}") (auto simp add: wf_lex_prod kdt_tree1_term) lemma leaf_comb1: "⟦ length bs ≥ max (h_tree1 t1) (h_tree1 t2) ⟧ ⟹ leaf (comb1 f t1 t2) bs = f (leaf t1 bs) (leaf t2 bs)" apply (induction f t1 t2 arbitrary: bs rule: comb1.induct) (*goals: 1. ‹⋀f x1 x2 bs. max (h_tree1 (Lf x1)) (h_tree1 (Lf x2)) ≤ length bs ⟹ leaf (comb1 f (Lf x1) (Lf x2)) bs = f (leaf (Lf x1) bs) (leaf (Lf x2) bs)› 2. ‹⋀f l1 r1 l2 r2 bs. ⟦⋀bs. max (h_tree1 l1) (h_tree1 l2) ≤ length bs ⟹ leaf (comb1 f l1 l2) bs = f (leaf l1 bs) (leaf l2 bs); ⋀bs. max (h_tree1 r1) (h_tree1 r2) ≤ length bs ⟹ leaf (comb1 f r1 r2) bs = f (leaf r1 bs) (leaf r2 bs); max (h_tree1 (Br l1 r1)) (h_tree1 (Br l2 r2)) ≤ length bs⟧ ⟹ leaf (comb1 f (Br l1 r1) (Br l2 r2)) bs = f (leaf (Br l1 r1) bs) (leaf (Br l2 r2) bs)› 3. ‹⋀f l1 r1 x bs. ⟦⋀bs. max (h_tree1 l1) (h_tree1 (Lf x)) ≤ length bs ⟹ leaf (comb1 f l1 (Lf x)) bs = f (leaf l1 bs) (leaf (Lf x) bs); ⋀bs. max (h_tree1 r1) (h_tree1 (Lf x)) ≤ length bs ⟹ leaf (comb1 f r1 (Lf x)) bs = f (leaf r1 bs) (leaf (Lf x) bs); max (h_tree1 (Br l1 r1)) (h_tree1 (Lf x)) ≤ length bs⟧ ⟹ leaf (comb1 f (Br l1 r1) (Lf x)) bs = f (leaf (Br l1 r1) bs) (leaf (Lf x) bs)› 4. ‹⋀f x l2 r2 bs. ⟦⋀bs. max (h_tree1 (Lf x)) (h_tree1 l2) ≤ length bs ⟹ leaf (comb1 f (Lf x) l2) bs = f (leaf (Lf x) bs) (leaf l2 bs); ⋀bs. max (h_tree1 (Lf x)) (h_tree1 r2) ≤ length bs ⟹ leaf (comb1 f (Lf x) r2) bs = f (leaf (Lf x) bs) (leaf r2 bs); max (h_tree1 (Lf x)) (h_tree1 (Br l2 r2)) ≤ length bs⟧ ⟹ leaf (comb1 f (Lf x) (Br l2 r2)) bs = f (leaf (Lf x) bs) (leaf (Br l2 r2) bs)› discuss goal 1*) apply ((auto simp: Suc_le_length_iff (*‹(Suc ?n ≤ length ?xs) = (∃x ys. ?xs = x # ys ∧ ?n ≤ length 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))›*))[1]) (*discuss goal 2*) apply ((auto simp: Suc_le_length_iff (*‹(Suc ?n ≤ length ?xs) = (∃x ys. ?xs = x # ys ∧ ?n ≤ length 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))›*))[1]) (*discuss goal 3*) apply ((auto simp: Suc_le_length_iff (*‹(Suc ?n ≤ length ?xs) = (∃x ys. ?xs = x # ys ∧ ?n ≤ length 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))›*))[1]) (*discuss goal 4*) apply ((auto simp: Suc_le_length_iff (*‹(Suc ?n ≤ length ?xs) = (∃x ys. ?xs = x # ys ∧ ?n ≤ length 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))›*))[1]) (*proven 4 subgoals*) . lemma leaf_in_set_tree1: "⟦ length bs ≥ h_tree1 t ⟧ ⟹ leaf t bs ∈ set_tree1 t" apply (auto simp add: set_tree1_leafs (*‹set_tree1 ?t = (⋃bs∈bits (h_tree1 ?t). {leaf ?t bs})›*) bits_def (*‹bits ?n = nlists ?n UNIV›*) intro: nlistsI (*‹⟦length ?xs = ?n; set ?xs ⊆ ?A⟧ ⟹ ?xs ∈ nlists ?n ?A›*)) (*goal: ‹h_tree1 t ≤ length bs ⟹ leaf t bs ∈ set_tree1 t›*) by (metis leaf_take (*‹h_tree1 (?t::?'a tree1) ≤ length (?bs::bool list) ⟹ leaf ?t ?bs = leaf ?t (take (h_tree1 ?t) ?bs)›*) length_take (*‹length (take (?n::nat) (?xs::?'a list)) = min (length ?xs) ?n›*) min.absorb2 (*‹(?b::?'a) ≤ (?a::?'a) ⟹ min ?a ?b = ?b›*) nlistsI (*‹⟦length (?xs::?'a list) = (?n::nat); set ?xs ⊆ (?A::?'a set)⟧ ⟹ ?xs ∈ nlists ?n ?A›*) subset_UNIV (*‹(?A::?'a set) ⊆ UNIV›*)) (* which one is used? both? *) lemma leaf_in_set_tree2: "⟦x ∈ nlists k UNIV; h_tree1 t1 ≤ k⟧ ⟹ leaf t1 x ∈ set_tree1 t1" by (metis leaf_in_set_tree1 (*‹h_tree1 ?t ≤ length ?bs ⟹ leaf ?t ?bs ∈ set_tree1 ?t›*) leaf_take (*‹h_tree1 ?t ≤ length ?bs ⟹ leaf ?t ?bs = leaf ?t (take (h_tree1 ?t) ?bs)›*) length_take (*‹length (take ?n ?xs) = min (length ?xs) ?n›*) min.absorb2 (*‹?b ≤ ?a ⟹ min ?a ?b = ?b›*) nlistsE_length (*‹?xs ∈ nlists ?n ?A ⟹ length ?xs = ?n›*)) lemma points_union: "⟦ inv_kdt k t1; inv_kdt k t2; n ≥ max (h_kdt t1) (h_kdt t2) ⟧ ⟹ points k n (union t1 t2) = points k n t1 ∪ points k n t2" proof (induction t1 t2 arbitrary: n rule: union.induct) (*goals: 1. ‹⋀b t n. ⟦inv_kdt k (Cube b); inv_kdt k t; max (h_kdt (Cube b)) (h_kdt t) ≤ n⟧ ⟹ points k n (KD_Region_Nested.union (Cube b) t) = points k n (Cube b) ∪ points k n t› 2. ‹⋀v b n. ⟦inv_kdt k (Dims v); inv_kdt k (Cube b); max (h_kdt (Dims v)) (h_kdt (Cube b)) ≤ n⟧ ⟹ points k n (KD_Region_Nested.union (Dims v) (Cube b)) = points k n (Dims v) ∪ points k n (Cube b)› 3. ‹⋀t1 t2 n. ⟦⋀x y n. ⟦x ∈ set_tree1 t1; y ∈ set_tree1 t2; inv_kdt k x; inv_kdt k y; max (h_kdt x) (h_kdt y) ≤ n⟧ ⟹ points k n (KD_Region_Nested.union x y) = points k n x ∪ points k n y; inv_kdt k (Dims t1); inv_kdt k (Dims t2); max (h_kdt (Dims t1)) (h_kdt (Dims t2)) ≤ n⟧ ⟹ points k n (KD_Region_Nested.union (Dims t1) (Dims t2)) = points k n (Dims t1) ∪ points k n (Dims t2)›*) case 1 (*‹inv_kdt k (Cube b_)› ‹inv_kdt k t_› ‹max (h_kdt (Cube (b_::bool))) (h_kdt (t_::bool kdt)) ≤ (n::nat)›*) thus "?case" (*goal: ‹points k n (KD_Region_Nested.union (Cube b_) t_) = points k n (Cube b_) ∪ points k n t_›*) using Un_absorb2[OF points_subset] (*‹⟦inv_kdt ?k1 ?t1; h_kdt ?t1 ≤ ?n1⟧ ⟹ nlists ?k1 {0..<2 ^ ?n1} ∪ points ?k1 ?n1 ?t1 = nlists ?k1 {0..<2 ^ ?n1}›*) by simp next (*goals: 1. ‹⋀v b n. ⟦inv_kdt k (Dims v); inv_kdt k (Cube b); max (h_kdt (Dims v)) (h_kdt (Cube b)) ≤ n⟧ ⟹ points k n (KD_Region_Nested.union (Dims v) (Cube b)) = points k n (Dims v) ∪ points k n (Cube b)› 2. ‹⋀t1 t2 n. ⟦⋀x y n. ⟦x ∈ set_tree1 t1; y ∈ set_tree1 t2; inv_kdt k x; inv_kdt k y; max (h_kdt x) (h_kdt y) ≤ n⟧ ⟹ points k n (KD_Region_Nested.union x y) = points k n x ∪ points k n y; inv_kdt k (Dims t1); inv_kdt k (Dims t2); max (h_kdt (Dims t1)) (h_kdt (Dims t2)) ≤ n⟧ ⟹ points k n (KD_Region_Nested.union (Dims t1) (Dims t2)) = points k n (Dims t1) ∪ points k n (Dims t2)›*) case 2 (*‹inv_kdt (k::nat) (Dims (v_::bool kdt tree1))› ‹inv_kdt k (Cube b_)› ‹max (h_kdt (Dims (v_::bool kdt tree1))) (h_kdt (Cube (b_::bool))) ≤ (n::nat)›*) thus "?case" (*goal: ‹points k n (KD_Region_Nested.union (Dims v_) (Cube b_)) = points k n (Dims v_) ∪ points k n (Cube b_)›*) using Un_absorb1[OF points_subset] (*‹⟦inv_kdt ?k1 ?t1; h_kdt ?t1 ≤ ?n1⟧ ⟹ points ?k1 ?n1 ?t1 ∪ nlists ?k1 {0..<2 ^ ?n1} = nlists ?k1 {0..<2 ^ ?n1}›*) by simp next (*goal: ‹⋀t1 t2 n. ⟦⋀x y n. ⟦x ∈ set_tree1 t1; y ∈ set_tree1 t2; inv_kdt k x; inv_kdt k y; max (h_kdt x) (h_kdt y) ≤ n⟧ ⟹ points k n (KD_Region_Nested.union x y) = points k n x ∪ points k n y; inv_kdt k (Dims t1); inv_kdt k (Dims t2); max (h_kdt (Dims t1)) (h_kdt (Dims t2)) ≤ n⟧ ⟹ points k n (KD_Region_Nested.union (Dims t1) (Dims t2)) = points k n (Dims t1) ∪ points k n (Dims t2)›*) case (3 t1 t2) (*‹⟦(?x::bool kdt) ∈ set_tree1 (t1::bool kdt tree1); (?y::bool kdt) ∈ set_tree1 (t2::bool kdt tree1); inv_kdt (k::nat) ?x; inv_kdt k ?y; max (h_kdt ?x) (h_kdt ?y) ≤ (?n::nat)⟧ ⟹ points k ?n (KD_Region_Nested.union ?x ?y) = points k ?n ?x ∪ points k ?n ?y› ‹inv_kdt k (Dims t1)› ‹inv_kdt k (Dims t2)› ‹max (h_kdt (Dims (t1::bool kdt tree1))) (h_kdt (Dims (t2::bool kdt tree1))) ≤ (n::nat)›*) from "3.prems" (*‹inv_kdt (k::nat) (Dims (t1::bool kdt tree1))› ‹inv_kdt k (Dims t2)› ‹max (h_kdt (Dims t1)) (h_kdt (Dims t2)) ≤ n›*) obtain m where "n = Suc m" (*goal: ‹(⋀m. n = Suc m ⟹ thesis) ⟹ thesis›*) by (auto dest: Suc_le_D (*‹Suc ?n ≤ ?m' ⟹ ∃m. ?m' = Suc m›*)) with "3" (*‹⟦?x ∈ set_tree1 t1; ?y ∈ set_tree1 t2; inv_kdt k ?x; inv_kdt k ?y; max (h_kdt ?x) (h_kdt ?y) ≤ ?n⟧ ⟹ points k ?n (KD_Region_Nested.union ?x ?y) = points k ?n ?x ∪ points k ?n ?y› ‹inv_kdt k (Dims t1)› ‹inv_kdt k (Dims t2)› ‹max (h_kdt (Dims t1)) (h_kdt (Dims t2)) ≤ n›*) show "?case" (*goal: ‹points k n (KD_Region_Nested.union (Dims t1) (Dims t2)) = points k n (Dims t1) ∪ points k n (Dims t2)›*) by (simp add: leaf_comb1 (*‹max (h_tree1 ?t1.0) (h_tree1 ?t2.0) ≤ length ?bs ⟹ leaf (comb1 ?f ?t1.0 ?t2.0) ?bs = ?f (leaf ?t1.0 ?bs) (leaf ?t2.0 ?bs)›*) bits_def (*‹bits ?n = nlists ?n UNIV›*) leaf_in_set_tree2 (*‹⟦?x ∈ nlists ?k UNIV; h_tree1 ?t1.0 ≤ ?k⟧ ⟹ leaf ?t1.0 ?x ∈ set_tree1 ?t1.0›*) set_tree1_finite_ne (*‹finite (set_tree1 ?t) ∧ set_tree1 ?t ≠ {}›*) image_Un (*‹?f ` (?A ∪ ?B) = ?f ` ?A ∪ ?f ` ?B›*) UN_Un_distrib (*‹(⋃i∈?I. ?A i ∪ ?B i) = ⋃ (?A ` ?I) ∪ ⋃ (?B ` ?I)›*)) qed lemma size_leaf[termination_simp]: "size (leaf t (map f ps)) < Suc (size_tree1 size t)" apply (induction t "map f ps" arbitrary: ps rule: leaf.induct) (*goals: 1. ‹⋀x ps. size (leaf (Lf x) (map f ps)) < Suc (size_tree1 size (Lf x))› 2. ‹⋀l r b bs ps. ⟦⋀ps. bs = map f ps ⟹ size (leaf (if b then r else l) (map f ps)) < Suc (size_tree1 size (if b then r else l)); b # bs = map f ps⟧ ⟹ size (leaf (Br l r) (map f ps)) < Suc (size_tree1 size (Br l r))› 3. ‹⋀l r ps. ⟦⋀ps. [] = map f ps ⟹ size (leaf l (map f ps)) < Suc (size_tree1 size l); [] = map f ps⟧ ⟹ size (leaf (Br l r) (map f ps)) < Suc (size_tree1 size (Br l r))› discuss goal 1*) apply simp (*discuss goal 2*) apply fastforce (*discuss goal 3*) apply fastforce (*proven 3 subgoals*) . fun get :: "'a kdt ⇒ nat list ⇒ 'a" where "get (Cube b) _ = b" | "get (Dims t) ps = get (leaf t (map even ps)) (map (λx. x div 2) ps)" lemma map_zip1: "⟦ length xs = length ys; ∀p ∈ set(zip xs ys). f p = fst p ⟧ ⟹ map f (zip xs ys) = xs" by (metis (no_types, lifting) map_eq_conv (*‹(map ?f ?xs = map ?g ?xs) = (∀x∈set ?xs. ?f x = ?g x)›*) map_fst_zip (*‹length ?xs = length ?ys ⟹ map fst (zip ?xs ?ys) = ?xs›*)) lemma map_mv1: "⟦ length ps = length bs ⟧ ⟹ map even (mv bs ps) = bs" unfolding nlists_def mv_def (*goal: ‹length ps = length bs ⟹ map even (map2 (λx y. 2 * y + (if x then 0 else 1)) bs ps) = bs›*) by (auto intro!: map_zip1 (*‹⟦length ?xs = length ?ys; ∀p∈set (zip ?xs ?ys). ?f p = fst p⟧ ⟹ map ?f (zip ?xs ?ys) = ?xs›*) 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 map_zip2: "⟦ length xs = length ys; ∀p ∈ set(zip xs ys). f p = snd p ⟧ ⟹ map f (zip xs ys) = ys" by (metis (no_types, lifting) map_eq_conv (*‹(map ?f ?xs = map ?g ?xs) = (∀x∈set ?xs. ?f x = ?g x)›*) map_snd_zip (*‹length ?xs = length ?ys ⟹ map snd (zip ?xs ?ys) = ?ys›*)) lemma map_mv2: "⟦ length ps = length bs ⟧ ⟹ map (λx. x div 2) (mv bs ps) = ps" unfolding nlists_def mv_def (*goal: ‹length ps = length bs ⟹ map (λx. x div 2) (map2 (λx y. 2 * y + (if x then 0 else 1)) bs ps) = ps›*) by (auto intro!: map_zip2 (*‹⟦length ?xs = length ?ys; ∀p∈set (zip ?xs ?ys). ?f p = snd p⟧ ⟹ map ?f (zip ?xs ?ys) = ?ys›*)) lemma mv_map_map: "mv (map even ps) (map (λx. x div 2) ps) = ps" unfolding nlists_def mv_def (*goal: ‹map2 (λ(x::bool) y::nat. (2::nat) * y + (if x then 0::nat else (1::nat))) (map even (ps::nat list)) (map (λx::nat. x div (2::nat)) ps) = ps›*) by (auto simp add: map_eq_conv[where xs=ps and g=id,simplified] (*‹(map ?f ps = ps) = (∀x∈set ps. ?f x = x)›*) map2_map_map (*‹map2 ?h (map ?f ?xs) (map ?g ?xs) = map (λx. ?h (?f x) (?g x)) ?xs›*)) lemma in_mv_image: "⟦ ps ∈ nlists k {0..<2*2^n}; Ps ⊆ nlists k {0..<2^n}; bs ∈ bits k ⟧ ⟹ ps ∈ mv bs ` Ps ⟷ map (λx. x div 2) ps ∈ Ps ∧ (bs = map even ps)" by (auto simp: map_mv1 (*‹length ?ps = length ?bs ⟹ map even (mv ?bs ?ps) = ?bs›*) map_mv2 (*‹length ?ps = length ?bs ⟹ map (λx. x div 2) (mv ?bs ?ps) = ?ps›*) mv_map_map (*‹mv (map even ?ps) (map (λx. x div 2) ?ps) = ?ps›*) bits_def (*‹bits ?n = nlists ?n UNIV›*) intro!: image_eqI (*‹⟦?b = ?f ?x; ?x ∈ ?A⟧ ⟹ ?b ∈ ?f ` ?A›*)) lemma get_points: "⟦ inv_kdt k t; h_kdt t ≤ n; ps ∈ nlists k {0..<2^n} ⟧ ⟹ get t ps = (ps ∈ points k n t)" proof (induction t ps arbitrary: n rule: get.induct) (*goals: 1. ‹⋀(b::bool) (uu_::nat list) n::nat. ⟦inv_kdt (k::nat) (Cube b); h_kdt (Cube b) ≤ n; uu_ ∈ nlists k {0::nat..<(2::nat) ^ n}⟧ ⟹ get (Cube b) uu_ = (uu_ ∈ points k n (Cube b))› 2. ‹⋀(t::bool kdt tree1) (ps::nat list) n::nat. ⟦⋀n::nat. ⟦inv_kdt (k::nat) (leaf t (map even ps)); h_kdt (leaf t (map even ps)) ≤ n; map (λx::nat. x div (2::nat)) ps ∈ nlists k {0::nat..<(2::nat) ^ n}⟧ ⟹ get (leaf t (map even ps)) (map (λx::nat. x div (2::nat)) ps) = (map (λx::nat. x div (2::nat)) ps ∈ points k n (leaf t (map even ps))); inv_kdt k (Dims t); h_kdt (Dims t) ≤ n; ps ∈ nlists k {0::nat..<(2::nat) ^ n}⟧ ⟹ get (Dims t) ps = (ps ∈ points k n (Dims t))›*) case (2 t ps) (*‹⟦inv_kdt k (leaf t (map even ps)); h_kdt (leaf t (map even ps)) ≤ ?n; map (λx. x div 2) ps ∈ nlists k {0..<2 ^ ?n}⟧ ⟹ get (leaf t (map even ps)) (map (λx. x div 2) ps) = (map (λx. x div 2) ps ∈ points k ?n (leaf t (map even ps)))› ‹inv_kdt k (Dims t)› ‹h_kdt (Dims t) ≤ n› ‹(ps::nat list) ∈ nlists (k::nat) {0::nat..<(2::nat) ^ (n::nat)}›*) obtain m where [simp]: "n = Suc m" (*goal: ‹(⋀m::nat. (n::nat) = Suc m ⟹ thesis::bool) ⟹ thesis›*) using ‹h_kdt (Dims t) ≤ n› (*‹h_kdt (Dims t) ≤ n›*) by (auto dest: Suc_le_D (*‹Suc ?n ≤ ?m' ⟹ ∃m. ?m' = Suc m›*)) have "∀bs. length bs = k ⟶ inv_kdt k (leaf t bs) ∧ h_kdt (leaf t bs) ≤ m" using "2.prems" (*‹inv_kdt (k::nat) (Dims (t::bool kdt tree1))› ‹h_kdt (Dims t) ≤ n› ‹ps ∈ nlists k {0..<2 ^ n}›*) by (auto simp add: leaf_in_set_tree1 (*‹h_tree1 ?t ≤ length ?bs ⟹ leaf ?t ?bs ∈ set_tree1 ?t›*) set_tree1_finite_ne (*‹finite (set_tree1 ?t) ∧ set_tree1 ?t ≠ {}›*)) moreover have "map (λx. x div 2) ps ∈ nlists k {0..<2 ^ m}" using "2.prems"(3) (*‹ps ∈ nlists k {0..<2 ^ n}›*) by (fastforce intro!: nlistsI (*‹⟦length ?xs = ?n; set ?xs ⊆ ?A⟧ ⟹ ?xs ∈ nlists ?n ?A›*) dest: nlistsE_set (*‹?xs ∈ nlists ?n ?A ⟹ set ?xs ⊆ ?A›*)) ultimately show "?case" (*goal: ‹get (Dims t) ps = (ps ∈ points k n (Dims t))›*) using "2.prems" (*‹inv_kdt k (Dims t)› ‹h_kdt (Dims t) ≤ n› ‹ps ∈ nlists k {0..<2 ^ n}›*) "2.IH"[of m] (*‹⟦inv_kdt k (leaf t (map even ps)); h_kdt (leaf t (map even ps)) ≤ m; map (λx. x div 2) ps ∈ nlists k {0..<2 ^ m}⟧ ⟹ get (leaf t (map even ps)) (map (λx. x div 2) ps) = (map (λx. x div 2) ps ∈ points k m (leaf t (map even ps)))›*) points_subset[of k _ m] (*‹⟦inv_kdt k ?t; h_kdt ?t ≤ m⟧ ⟹ points k m ?t ⊆ nlists k {0..<2 ^ m}›*) by (auto simp add: in_mv_image (*‹⟦?ps ∈ nlists ?k {0..<2 * 2 ^ ?n}; ?Ps ⊆ nlists ?k {0..<2 ^ ?n}; ?bs ∈ bits ?k⟧ ⟹ (?ps ∈ mv ?bs ` ?Ps) = (map (λx. x div 2) ?ps ∈ ?Ps ∧ ?bs = map even ?ps)›*) bits_def (*‹bits ?n = nlists ?n UNIV›*) intro: nlistsI (*‹⟦length ?xs = ?n; set ?xs ⊆ ?A⟧ ⟹ ?xs ∈ nlists ?n ?A›*)) qed (auto) (*solved the remaining goal: ‹⋀(b::bool) (uu_::nat list) n::nat. ⟦inv_kdt (k::nat) (Cube b); h_kdt (Cube b) ≤ n; uu_ ∈ nlists k {0::nat..<(2::nat) ^ n}⟧ ⟹ get (Cube b) uu_ = (uu_ ∈ points k n (Cube b))›*) fun modify :: "('a ⇒ 'a) ⇒ bool list ⇒ 'a tree1 ⇒ 'a tree1" where "modify f [] (Lf x) = Lf (f x)" | "modify f (b#bs) (Lf x) = (if b then Br (Lf x) (modify f bs (Lf x)) else Br (modify f bs (Lf x)) (Lf x))" | "modify f (b#bs) (Br l r) = (if b then Br l (modify f bs r) else Br (modify f bs l) r)" (* not yet compressed *) fun put :: "'a ⇒ nat ⇒ nat list ⇒ 'a kdt ⇒ 'a kdt" where "put b' 0 ps (Cube _) = Cube b'" | "put b' (Suc n) ps t = Dims (modify (put b' n (map (λi. i div 2) ps)) (map even ps) (case t of Cube b ⇒ Lf (Cube b) | Dims t ⇒ t))" lemma leaf_modify: "⟦ h_tree1 t ≤ length bs; length bs' = length bs ⟧ ⟹ leaf (modify f bs t) bs' = (if bs' = bs then f(leaf t bs) else leaf t bs')" apply (induction f bs t arbitrary: bs' rule: modify.induct) (*goals: 1. ‹⋀f x bs'. ⟦h_tree1 (Lf x) ≤ length []; length bs' = length []⟧ ⟹ leaf (modify f [] (Lf x)) bs' = (if bs' = [] then f (leaf (Lf x) []) else leaf (Lf x) bs')› 2. ‹⋀f b bs x bs'. ⟦⋀bs'. ⟦b; h_tree1 (Lf x) ≤ length bs; length bs' = length bs⟧ ⟹ leaf (modify f bs (Lf x)) bs' = (if bs' = bs then f (leaf (Lf x) bs) else leaf (Lf x) bs'); ⋀bs'. ⟦¬ b; h_tree1 (Lf x) ≤ length bs; length bs' = length bs⟧ ⟹ leaf (modify f bs (Lf x)) bs' = (if bs' = bs then f (leaf (Lf x) bs) else leaf (Lf x) bs'); h_tree1 (Lf x) ≤ length (b # bs); length bs' = length (b # bs)⟧ ⟹ leaf (modify f (b # bs) (Lf x)) bs' = (if bs' = b # bs then f (leaf (Lf x) (b # bs)) else leaf (Lf x) bs')› 3. ‹⋀f b bs l r bs'. ⟦⋀bs'. ⟦b; h_tree1 r ≤ length bs; length bs' = length bs⟧ ⟹ leaf (modify f bs r) bs' = (if bs' = bs then f (leaf r bs) else leaf r bs'); ⋀bs'. ⟦¬ b; h_tree1 l ≤ length bs; length bs' = length bs⟧ ⟹ leaf (modify f bs l) bs' = (if bs' = bs then f (leaf l bs) else leaf l bs'); h_tree1 (Br l r) ≤ length (b # bs); length bs' = length (b # bs)⟧ ⟹ leaf (modify f (b # bs) (Br l r)) bs' = (if bs' = b # bs then f (leaf (Br l r) (b # bs)) else leaf (Br l r) bs')› 4. ‹⋀a v va bs'. ⟦h_tree1 (Br v va) ≤ length []; length bs' = length []⟧ ⟹ leaf (modify a [] (Br v va)) bs' = (if bs' = [] then a (leaf (Br v va) []) else leaf (Br v va) bs')› discuss goal 1*) apply ((auto simp: length_Suc_conv (*‹(length ?xs = Suc ?n) = (∃y ys. ?xs = y # ys ∧ length ys = ?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))›*))[1]) (*discuss goal 2*) apply ((auto simp: length_Suc_conv (*‹(length ?xs = Suc ?n) = (∃y ys. ?xs = y # ys ∧ length ys = ?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))›*))[1]) (*discuss goal 3*) apply ((auto simp: length_Suc_conv (*‹(length (?xs::?'a list) = Suc (?n::nat)) = (∃(y::?'a) ys::?'a list. ?xs = y # ys ∧ length ys = ?n)›*) 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 4*) apply ((auto simp: length_Suc_conv (*‹(length ?xs = Suc ?n) = (∃y ys. ?xs = y # ys ∧ length ys = ?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))›*))[1]) (*proven 4 subgoals*) . lemma in_nlists2D: "xs ∈ nlists k {0..<2 * 2 ^ n} ⟹ ∃bs∈nlists k UNIV. xs ∈ mv bs ` nlists k {0..<2 ^ n}" unfolding nlists_def (*goal: ‹xs ∈ {xs. length xs = k ∧ set xs ⊆ {0..<2 * 2 ^ n}} ⟹ ∃bs∈{xs. length xs = k ∧ set xs ⊆ UNIV}. xs ∈ mv bs ` {xs. length xs = k ∧ set xs ⊆ {0..<2 ^ n}}›*) apply (rule bexI[where x = "map even xs"] (*‹⟦(?P::bool list ⇒ bool) (map even (xs::nat list)); map even xs ∈ (?A::bool list set)⟧ ⟹ ∃x::bool list∈?A. ?P x›*)) (*goals: 1. ‹xs ∈ {xs. length xs = k ∧ set xs ⊆ {0..<2 * 2 ^ n}} ⟹ xs ∈ mv (map even xs) ` {xs. length xs = k ∧ set xs ⊆ {0..<2 ^ n}}› 2. ‹xs ∈ {xs. length xs = k ∧ set xs ⊆ {0..<2 * 2 ^ n}} ⟹ map even xs ∈ {xs. length xs = k ∧ set xs ⊆ UNIV}› discuss goal 1*) apply ((auto simp: image_def (*‹?f ` ?A = {y. ∃x∈?A. y = ?f x}›*))[1]) (*top goal: ‹(xs::nat list) ∈ {xs::nat list. length xs = (k::nat) ∧ set xs ⊆ {0::nat..<(2::nat) * (2::nat) ^ (n::nat)}} ⟹ xs ∈ mv (map even xs) ` {xs::nat list. length xs = k ∧ set xs ⊆ {0::nat..<(2::nat) ^ n}}› and 1 goal remains*) apply (rule exI[where x = "map (λi. i div 2) xs"] (*‹?P (map (λi. i div 2) xs) ⟹ ∃x. ?P x›*)) (*top goal: ‹⟦set (xs::nat list) ⊆ {0::nat..<(2::nat) * (2::nat) ^ (n::nat)}; (k::nat) = length xs⟧ ⟹ ∃x::nat list. length x = length xs ∧ set x ⊆ {0::nat..<(2::nat) ^ n} ∧ xs = mv (map even xs) x› and 1 goal remains*) apply ((auto simp add: mv_map_map (*‹mv (map even ?ps) (map (λx. x div 2) ?ps) = ?ps›*))[1]) (*discuss goal 2*) apply ((auto simp add: mv_map_map (*‹mv (map even ?ps) (map (λx. x div 2) ?ps) = ?ps›*))[1]) (*proven 2 subgoals*) . lemma nlists2_simp: "nlists k {0..<2 * 2 ^ n} = (⋃bs∈nlists k UNIV. mv bs ` nlists k {0..<2 ^ n})" by (auto simp: mv_in_nlists (*‹⟦?p ∈ nlists ?k {0..<2 ^ ?n}; ?bs ∈ bits ?k⟧ ⟹ mv ?bs ?p ∈ nlists ?k {0..<2 * 2 ^ ?n}›*) bits_def (*‹bits ?n = nlists ?n UNIV›*) in_nlists2D (*‹?xs ∈ nlists ?k {0..<2 * 2 ^ ?n} ⟹ ∃bs∈nlists ?k UNIV. ?xs ∈ mv bs ` nlists ?k {0..<2 ^ ?n}›*)) lemma mv_diff: "⟦ length qs = length bs; ∀as ∈ A. length as = length bs ⟧ ⟹ mv bs ` (A - {qs}) = mv bs ` A - {mv bs qs}" apply auto (*goal: ‹⟦length qs = length bs; ∀as∈A. length as = length bs⟧ ⟹ mv bs ` (A - {qs}) = mv bs ` A - {mv bs qs}›*) by (metis map_mv2 (*‹length ?ps = length ?bs ⟹ map (λx. x div 2) (mv ?bs ?ps) = ?ps›*)) lemma put_points: "⟦ inv_kdt k t; h_kdt t ≤ n; ps ∈ nlists k {0..<2^n} ⟧ ⟹ points k n (put b n ps t) = (if b then points k n t ∪ {ps} else points k n t - {ps})" proof (induction b n ps t rule: put.induct (*‹⟦⋀b' ps uu_. ?P b' 0 ps (Cube uu_); ⋀b' n ps t. (⋀x. ?P b' n (map (λi. i div 2) ps) x) ⟹ ?P b' (Suc n) ps t; ⋀a c v. ?P a 0 c (Dims v)⟧ ⟹ ?P ?a0.0 ?a1.0 ?a2.0 ?a3.0›*)) (*goals: 1. ‹⋀b' ps uu_. ⟦inv_kdt k (Cube uu_); h_kdt (Cube uu_) ≤ 0; ps ∈ nlists k {0..<2 ^ 0}⟧ ⟹ points k 0 (put b' 0 ps (Cube uu_)) = (if b' then points k 0 (Cube uu_) ∪ {ps} else points k 0 (Cube uu_) - {ps})› 2. ‹⋀b' n ps t. ⟦⋀x. ⟦inv_kdt k x; h_kdt x ≤ n; map (λi. i div 2) ps ∈ nlists k {0..<2 ^ n}⟧ ⟹ points k n (put b' n (map (λi. i div 2) ps) x) = (if b' then points k n x ∪ {map (λi. i div 2) ps} else points k n x - {map (λi. i div 2) ps}); inv_kdt k t; h_kdt t ≤ Suc n; ps ∈ nlists k {0..<2 ^ Suc n}⟧ ⟹ points k (Suc n) (put b' (Suc n) ps t) = (if b' then points k (Suc n) t ∪ {ps} else points k (Suc n) t - {ps})› 3. ‹⋀a c v. ⟦inv_kdt k (Dims v); h_kdt (Dims v) ≤ 0; c ∈ nlists k {0..<2 ^ 0}⟧ ⟹ points k 0 (put a 0 c (Dims v)) = (if a then points k 0 (Dims v) ∪ {c} else points k 0 (Dims v) - {c})›*) case 1 (*‹inv_kdt k (Cube uu_)› ‹h_kdt (Cube uu_) ≤ 0› ‹ps_ ∈ nlists k {0..<2 ^ 0}›*) thus "?case" (*goal: ‹points k 0 (put b'_ 0 ps_ (Cube uu_)) = (if b'_ then points k 0 (Cube uu_) ∪ {ps_} else points k 0 (Cube uu_) - {ps_})›*) by (simp add: nlists_singleton (*‹nlists ?n {?a} = {replicate ?n ?a}›*)) next (*goals: 1. ‹⋀b' n ps t. ⟦⋀x. ⟦inv_kdt k x; h_kdt x ≤ n; map (λi. i div 2) ps ∈ nlists k {0..<2 ^ n}⟧ ⟹ points k n (put b' n (map (λi. i div 2) ps) x) = (if b' then points k n x ∪ {map (λi. i div 2) ps} else points k n x - {map (λi. i div 2) ps}); inv_kdt k t; h_kdt t ≤ Suc n; ps ∈ nlists k {0..<2 ^ Suc n}⟧ ⟹ points k (Suc n) (put b' (Suc n) ps t) = (if b' then points k (Suc n) t ∪ {ps} else points k (Suc n) t - {ps})› 2. ‹⋀a c v. ⟦inv_kdt k (Dims v); h_kdt (Dims v) ≤ 0; c ∈ nlists k {0..<2 ^ 0}⟧ ⟹ points k 0 (put a 0 c (Dims v)) = (if a then points k 0 (Dims v) ∪ {c} else points k 0 (Dims v) - {c})›*) case (2 b' n ps t) (*‹⟦inv_kdt (k::nat) (?x::bool kdt); h_kdt ?x ≤ (n::nat); map (λi::nat. i div (2::nat)) (ps::nat list) ∈ nlists k {0::nat..<(2::nat) ^ n}⟧ ⟹ points k n (put (b'::bool) n (map (λi::nat. i div (2::nat)) ps) ?x) = (if b' then points k n ?x ∪ {map (λi::nat. i div (2::nat)) ps} else points k n ?x - {map (λi::nat. i div (2::nat)) ps})› ‹inv_kdt k t› ‹h_kdt t ≤ Suc n› ‹(ps::nat list) ∈ nlists (k::nat) {0::nat..<(2::nat) ^ Suc (n::nat)}›*) have "*": "∀x bs. t = Dims x ⟶ length bs = length ps ⟶ inv_kdt k (leaf x bs)" using "2.prems"(1,3) (*‹inv_kdt k t› ‹ps ∈ nlists k {0..<2 ^ Suc n}›*) leaf_in_set_tree1 (*‹h_tree1 ?t ≤ length ?bs ⟹ leaf ?t ?bs ∈ set_tree1 ?t›*) by fastforce have "**": "t = Dims x ⟹ length bs = length ps ⟹ h_kdt (leaf x bs) ≤ n" for x and bs using leaf_in_set_tree1[of x] (*‹h_tree1 (x::bool kdt tree1) ≤ length (?bs::bool list) ⟹ leaf x ?bs ∈ set_tree1 x›*) "2.prems" (*‹inv_kdt (k::nat) (t::bool kdt)› ‹h_kdt (t::bool kdt) ≤ Suc (n::nat)› ‹ps ∈ nlists k {0..<2 ^ Suc n}›*) set_tree1_finite_ne[of x] (*‹finite (set_tree1 x) ∧ set_tree1 x ≠ {}›*) by auto have "***": "⟦ t = Dims x; length bs = length ps ⟧ ⟹ (∀qs ∈ points (length ps) n (leaf x bs). length qs = length ps) = True" for x and bs using "2.prems"(3) (*‹ps ∈ nlists k {0..<2 ^ Suc n}›*) by (metis * (*‹∀x bs. t = Dims x ⟶ length bs = length ps ⟶ inv_kdt k (leaf x bs)›*) ** (*‹⟦t = Dims ?x; length ?bs = length ps⟧ ⟹ h_kdt (leaf ?x ?bs) ≤ n›*) nlistsE_length (*‹?xs ∈ nlists ?n ?A ⟹ length ?xs = ?n›*) points_subset (*‹⟦inv_kdt ?k ?t; h_kdt ?t ≤ ?n⟧ ⟹ points ?k ?n ?t ⊆ nlists ?k {0..<2 ^ ?n}›*) subset_iff (*‹(?A ⊆ ?B) = (∀t. t ∈ ?A ⟶ t ∈ ?B)›*)) have Union_diff_aux: "a ∈ A ⟹ (⋃x ∈ A. F x) = F a ∪ (⋃x ∈ A - {a}. F x)" for a and A and F by blast have notin_aux: "∀x∈nlists (length ps) UNIV - {map even ps}.∀qs ∈ A x. length qs = length ps ⟹ ps ∉ (⋃x∈nlists (length ps) UNIV - {map even ps}. mv x ` A x)" for A by (smt (verit) DiffE (*‹⟦?c ∈ ?A - ?B; ⟦?c ∈ ?A; ?c ∉ ?B⟧ ⟹ ?P⟧ ⟹ ?P›*) UN_E (*‹⟦?b ∈ ⋃ (?B ` ?A); ⋀x. ⟦x ∈ ?A; ?b ∈ ?B x⟧ ⟹ ?R⟧ ⟹ ?R›*) image_iff (*‹(?z ∈ ?f ` ?A) = (∃x∈?A. ?z = ?f x)›*) insert_iff (*‹(?a ∈ insert ?b ?A) = (?a = ?b ∨ ?a ∈ ?A)›*) map_mv1 (*‹length ?ps = length ?bs ⟹ map even (mv ?bs ?ps) = ?bs›*) nlistsE_length (*‹?xs ∈ nlists ?n ?A ⟹ length ?xs = ?n›*)) have set1: "⋀x y. {x. x ≠ y} = UNIV - {y}" by blast have nlists_map: "⋀n xs f A. n = size xs ⟹ (map f xs ∈ nlists n A) = (f ` set xs ⊆ A)" by simp have "(λi. i div 2) ` set ps ⊆ {0..<2 ^ n}" using nlistsE_set[OF "2.prems" ( 3 )] (*‹set ps ⊆ {0..<2 ^ Suc n}›*) by auto moreover have "∀x. t = Dims x ⟶ inv_kdt k (Dims x)" using "2.prems"(1) (*‹inv_kdt k t›*) by blast moreover have "t = Dims x ⟹ length bs = length ps ⟹ points (length ps) n (leaf x bs) ⊆ nlists (length ps) {0..<2 ^ n}" for x and bs using "2.prems"(3) (*‹ps ∈ nlists k {0..<2 ^ Suc n}›*) by (metis * (*‹∀x bs. t = Dims x ⟶ length bs = length ps ⟶ inv_kdt k (leaf x bs)›*) ** (*‹⟦t = Dims ?x; length ?bs = length ps⟧ ⟹ h_kdt (leaf ?x ?bs) ≤ n›*) nlistsE_length (*‹?xs ∈ nlists ?n ?A ⟹ length ?xs = ?n›*) points_subset (*‹⟦inv_kdt ?k ?t; h_kdt ?t ≤ ?n⟧ ⟹ points ?k ?n ?t ⊆ nlists ?k {0..<2 ^ ?n}›*)) moreover have "length ps = k" using "2.prems"(3) (*‹(ps::nat list) ∈ nlists (k::nat) {0::nat..<(2::nat) ^ Suc (n::nat)}›*) by simp moreover from "2" (*‹⟦inv_kdt k ?x; h_kdt ?x ≤ n; map (λi. i div 2) ps ∈ nlists k {0..<2 ^ n}⟧ ⟹ points k n (put b' n (map (λi. i div 2) ps) ?x) = (if b' then points k n ?x ∪ {map (λi. i div 2) ps} else points k n ?x - {map (λi. i div 2) ps})› ‹inv_kdt k t› ‹h_kdt t ≤ Suc n› ‹(ps::nat list) ∈ nlists (k::nat) {0::nat..<(2::nat) ^ Suc (n::nat)}›*) "*" (*‹∀x bs. t = Dims x ⟶ length bs = length ps ⟶ inv_kdt k (leaf x bs)›*) "**" (*‹⟦t = Dims ?x; length ?bs = length ps⟧ ⟹ h_kdt (leaf ?x ?bs) ≤ n›*) calculation (*‹(λi. i div 2) ` set ps ⊆ {0..<2 ^ n}› ‹∀x. t = Dims x ⟶ inv_kdt k (Dims x)› ‹⟦t = Dims ?x3; length ?bs3 = length ps⟧ ⟹ points (length ps) n (leaf ?x3 ?bs3) ⊆ nlists (length ps) {0..<2 ^ n}› ‹length ps = k›*) show "?case" (*goal: ‹points k (Suc n) (put b' (Suc n) ps t) = (if b' then points k (Suc n) t ∪ {ps} else points k (Suc n) t - {ps})›*) by (clarsimp simp: leaf_modify[of _ "map even ps"] (*‹⟦h_tree1 ?t ≤ length (map even ps); length ?bs' = length (map even ps)⟧ ⟹ leaf (modify ?f (map even ps) ?t) ?bs' = (if ?bs' = map even ps then ?f (leaf ?t (map even ps)) else leaf ?t ?bs')›*) mv_map_map (*‹mv (map even ?ps) (map (λx. x div 2) ?ps) = ?ps›*) nlists_map (*‹?n2 = length ?xs2 ⟹ (map ?f2 ?xs2 ∈ nlists ?n2 ?A2) = (?f2 ` set ?xs2 ⊆ ?A2)›*) bits_def (*‹bits ?n = nlists ?n UNIV›*) nlistsE_length[of "_::bool list" k UNIV] (*‹?uu6 ∈ nlists k UNIV ⟹ length ?uu6 = k›*) nlists2_simp (*‹nlists ?k {0..<2 * 2 ^ ?n} = (⋃bs∈nlists ?k UNIV. mv bs ` nlists ?k {0..<2 ^ ?n})›*) Union_diff_aux[of "map even ps"] (*‹map even ps ∈ ?A1 ⟹ ⋃ (?F1 ` ?A1) = ?F1 (map even ps) ∪ ⋃ (?F1 ` (?A1 - {map even ps}))›*) mv_diff (*‹⟦length ?qs = length ?bs; ∀as∈?A. length as = length ?bs⟧ ⟹ mv ?bs ` (?A - {?qs}) = mv ?bs ` ?A - {mv ?bs ?qs}›*) *** (*‹⟦t = Dims ?x; length ?bs = length ps⟧ ⟹ (∀qs∈points (length ps) n (leaf ?x ?bs). length qs = length ps) = True›*) Diff_insert0[OF notin_aux] (*‹∀x∈nlists (length ps) UNIV - {map even ps}. ∀qs∈?A2 x. length qs = length ps ⟹ (⋃x∈nlists (length ps) UNIV - {map even ps}. mv x ` ?A2 x) - insert ps ?B = (⋃x∈nlists (length ps) UNIV - {map even ps}. mv x ` ?A2 x) - ?B›*) insert_absorb (*‹?a ∈ ?A ⟹ insert ?a ?A = ?A›*) Diff_insert_absorb (*‹?x ∉ ?A ⟹ insert ?x ?A - {?x} = ?A›*) Int_absorb1 (*‹?B ⊆ ?A ⟹ ?A ∩ ?B = ?B›*) set1 (*‹{x. x ≠ ?y1} = UNIV - {?y1}›*) Diff_Int_distrib (*‹?C ∩ (?A - ?B) = ?C ∩ ?A - ?C ∩ ?B›*) Un_Diff (*‹?A ∪ ?B - ?C = ?A - ?C ∪ (?B - ?C)›*) split: kdt.split (*‹?P (case ?kdt of Cube x ⇒ ?f1.0 x | Dims x ⇒ ?f2.0 x) = ((∀x1. ?kdt = Cube x1 ⟶ ?P (?f1.0 x1)) ∧ (∀x2. ?kdt = Dims x2 ⟶ ?P (?f2.0 x2)))›*)) qed (simp) (*solved the remaining goal: ‹⋀a c v. ⟦inv_kdt k (Dims v); h_kdt (Dims v) ≤ 0; c ∈ nlists k {0..<2 ^ 0}⟧ ⟹ points k 0 (put a 0 c (Dims v)) = (if a then points k 0 (Dims v) ∪ {c} else points k 0 (Dims v) - {c})›*) end
{ "path": "afp-2025-02-12/thys/Region_Quadtrees/KD_Region_Nested.thy", "repo": "afp-2025-02-12", "sha": "28383d013450f511aadcf003c2575c2444849d3452b3f333dd3459bc0ed8de6c" }
(* Title: JinjaDCI/J/SmallStep.thy Author: Tobias Nipkow, Susannah Mansky Copyright 2003 Technische Universitaet Muenchen, 2019-20 UIUC Based on the Jinja theory J/SmallStep.thy by Tobias Nipkow *) section ‹ Small Step Semantics › theory SmallStep imports Expr State WWellForm begin fun blocks :: "vname list * ty list * val list * expr ⇒ expr" where "blocks(V#Vs, T#Ts, v#vs, e) = {V:T := Val v; blocks(Vs,Ts,vs,e)}" |"blocks([],[],[],e) = e" lemmas blocks_induct = blocks.induct[split_format (complete)] lemma [simp]: "⟦ size vs = size Vs; size Ts = size Vs ⟧ ⟹ fv(blocks(Vs,Ts,vs,e)) = fv e - set Vs" (*<*) apply (induct rule:blocks_induct (*‹⟦⋀V Vs T Ts v vs e. ?P Vs Ts vs e ⟹ ?P (V # Vs) (T # Ts) (v # vs) e; ⋀e. ?P [] [] [] e; ⋀vc vd a b. ?P [] (vc # vd) a b; ⋀v ve vf vd. ?P [] v (ve # vf) vd; ⋀va vb a b. ?P (va # vb) [] a b; ⋀v vd ve vb. ?P v [] (vd # ve) vb; ⋀va vc vb ve. ?P (va # vc) vb [] ve; ⋀v va vc ve. ?P v (va # vc) [] ve⟧ ⟹ ?P ?a0a ?a0b ?a0c ?a0d›*)) (*goals: 1. ‹⋀V Vs T Ts v vs e. ⟦⟦length vs = length Vs; length Ts = length Vs⟧ ⟹ fv (blocks (Vs, Ts, vs, e)) = fv e - set Vs; length (v # vs) = length (V # Vs); length (T # Ts) = length (V # Vs)⟧ ⟹ fv (blocks (V # Vs, T # Ts, v # vs, e)) = fv e - set (V # Vs)› 2. ‹⋀e. ⟦length [] = length []; length [] = length []⟧ ⟹ fv (blocks ([], [], [], e)) = fv e - set []› 3. ‹⋀vc vd a b. ⟦length a = length []; length (vc # vd) = length []⟧ ⟹ fv (blocks ([], vc # vd, a, b)) = fv b - set []› 4. ‹⋀v ve vf vd. ⟦length (ve # vf) = length []; length v = length []⟧ ⟹ fv (blocks ([], v, ve # vf, vd)) = fv vd - set []› 5. ‹⋀va vb a b. ⟦length a = length (va # vb); length [] = length (va # vb)⟧ ⟹ fv (blocks (va # vb, [], a, b)) = fv b - set (va # vb)› 6. ‹⋀v vd ve vb. ⟦length (vd # ve) = length v; length [] = length v⟧ ⟹ fv (blocks (v, [], vd # ve, vb)) = fv vb - set v› 7. ‹⋀va vc vb ve. ⟦length [] = length (va # vc); length vb = length (va # vc)⟧ ⟹ fv (blocks (va # vc, vb, [], ve)) = fv ve - set (va # vc)› 8. ‹⋀v va vc ve. ⟦length [] = length v; length (va # vc) = length v⟧ ⟹ fv (blocks (v, va # vc, [], ve)) = fv ve - set v› 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]) (*proven 8 subgoals*) . (*>*) lemma sub_RI_blocks_body[iff]: "length vs = length pns ⟹ length Ts = length pns ⟹ sub_RI (blocks (pns, Ts, vs, body)) ⟷ sub_RI body" proof (induct pns arbitrary: Ts vs) (*goals: 1. ‹⋀Ts vs. ⟦length vs = length []; length Ts = length []⟧ ⟹ sub_RI (blocks ([], Ts, vs, body)) = sub_RI body› 2. ‹⋀a pns Ts vs. ⟦⋀Ts vs. ⟦length vs = length pns; length Ts = length pns⟧ ⟹ sub_RI (blocks (pns, Ts, vs, body)) = sub_RI body; length vs = length (a # pns); length Ts = length (a # pns)⟧ ⟹ sub_RI (blocks (a # pns, Ts, vs, body)) = sub_RI body›*) case Nil (*‹length vs = length []› ‹length (Ts::ty list) = length []›*) then show "?case" (*goal: ‹sub_RI (blocks ([], Ts, vs, body)) = sub_RI body›*) by simp next (*goal: ‹⋀a pns Ts vs. ⟦⋀Ts vs. ⟦length vs = length pns; length Ts = length pns⟧ ⟹ sub_RI (blocks (pns, Ts, vs, body)) = sub_RI body; length vs = length (a # pns); length Ts = length (a # pns)⟧ ⟹ sub_RI (blocks (a # pns, Ts, vs, body)) = sub_RI body›*) case Cons (*‹⟦length (?vs::val list) = length (pns_::char list list); length (?Ts::ty list) = length pns_⟧ ⟹ sub_RI (blocks (pns_, ?Ts, ?vs, body::char list exp)) = sub_RI body› ‹length vs = length (a_ # pns_)› ‹length Ts = length (a_ # pns_)›*) then show "?case" (*goal: ‹sub_RI (blocks (a_ # pns_, Ts, vs, body)) = sub_RI body›*) apply (cases vs) (*goals: 1. ‹⟦⋀vs Ts. ⟦length vs = length pns_; length Ts = length pns_⟧ ⟹ sub_RI (blocks (pns_, Ts, vs, body)) = sub_RI body; length vs = length (a_ # pns_); length Ts = length (a_ # pns_); vs = []⟧ ⟹ sub_RI (blocks (a_ # pns_, Ts, vs, body)) = sub_RI body› 2. ‹⋀aa list. ⟦⋀vs Ts. ⟦length vs = length pns_; length Ts = length pns_⟧ ⟹ sub_RI (blocks (pns_, Ts, vs, body)) = sub_RI body; length vs = length (a_ # pns_); length Ts = length (a_ # pns_); vs = aa # list⟧ ⟹ sub_RI (blocks (a_ # pns_, Ts, vs, body)) = sub_RI body› discuss goal 1*) apply (cases Ts) (*goals: 1. ‹⟦⋀vs Ts. ⟦length vs = length pns_; length Ts = length pns_⟧ ⟹ sub_RI (blocks (pns_, Ts, vs, body)) = sub_RI body; length vs = length (a_ # pns_); length Ts = length (a_ # pns_); vs = []; Ts = []⟧ ⟹ sub_RI (blocks (a_ # pns_, Ts, vs, body)) = sub_RI body› 2. ‹⋀aa list. ⟦⋀vs Ts. ⟦length vs = length pns_; length Ts = length pns_⟧ ⟹ sub_RI (blocks (pns_, Ts, vs, body)) = sub_RI body; length vs = length (a_ # pns_); length Ts = length (a_ # pns_); vs = []; Ts = aa # list⟧ ⟹ sub_RI (blocks (a_ # pns_, Ts, vs, body)) = sub_RI body› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) (*discuss goal 2*) apply (cases Ts) (*goals: 1. ‹⋀aa list. ⟦⋀vs Ts. ⟦length vs = length pns_; length Ts = length pns_⟧ ⟹ sub_RI (blocks (pns_, Ts, vs, body)) = sub_RI body; length vs = length (a_ # pns_); length Ts = length (a_ # pns_); vs = aa # list; Ts = []⟧ ⟹ sub_RI (blocks (a_ # pns_, Ts, vs, body)) = sub_RI body› 2. ‹⋀aa list aaa lista. ⟦⋀vs Ts. ⟦length vs = length pns_; length Ts = length pns_⟧ ⟹ sub_RI (blocks (pns_, Ts, vs, body)) = sub_RI body; length vs = length (a_ # pns_); length Ts = length (a_ # pns_); vs = aa # list; Ts = aaa # lista⟧ ⟹ sub_RI (blocks (a_ # pns_, Ts, vs, body)) = sub_RI body› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) (*proven 2 subgoals*) . qed definition assigned :: "'a ⇒ 'a exp ⇒ bool" where "assigned V e ≡ ∃v e'. e = (V := Val v;; e')" ― ‹ expression is okay to go the right side of @{text INIT} or @{text "RI ←"} or to have indicator Boolean be True (in latter case, given that class is also verified initialized) › fun icheck :: "'m prog ⇒ cname ⇒ 'a exp ⇒ bool" where "icheck P C' (new C) = (C' = C)" | "icheck P D' (C∙⇩sF{D}) = ((D' = D) ∧ (∃T. P ⊢ C has F,Static:T in D))" | "icheck P D' (C∙⇩sF{D}:=(Val v)) = ((D' = D) ∧ (∃T. P ⊢ C has F,Static:T in D))" | "icheck P D (C∙⇩sM(es)) = ((∃vs. es = map Val vs) ∧ (∃Ts T m. P ⊢ C sees M,Static:Ts→T = m in D))" | "icheck P _ _ = False" lemma nicheck_SFAss_nonVal: "val_of e₂ = None ⟹ ¬icheck P C' (C∙⇩sF{D} := (e₂::'a exp))" apply (rule notI (*‹(?P ⟹ False) ⟹ ¬ ?P›*)) (*goal: ‹val_of e₂ = None ⟹ ¬ icheck P C' (C∙⇩sF{D} := e₂)›*) apply (cases e₂) (*goals: 1. ‹⋀x1. ⟦val_of e₂ = None; icheck P C' (C∙⇩sF{D} := e₂); e₂ = new x1⟧ ⟹ False› 2. ‹⋀x21 x22. ⟦val_of e₂ = None; icheck P C' (C∙⇩sF{D} := e₂); e₂ = Cast x21 x22⟧ ⟹ False› 3. ‹⋀x3. ⟦val_of e₂ = None; icheck P C' (C∙⇩sF{D} := e₂); e₂ = Val x3⟧ ⟹ False› 4. ‹⋀x41 x42 x43. ⟦val_of e₂ = None; icheck P C' (C∙⇩sF{D} := e₂); e₂ = x41 «x42» x43⟧ ⟹ False› 5. ‹⋀x5. ⟦val_of e₂ = None; icheck P C' (C∙⇩sF{D} := e₂); e₂ = Var x5⟧ ⟹ False› 6. ‹⋀x61 x62. ⟦val_of e₂ = None; icheck P C' (C∙⇩sF{D} := e₂); e₂ = x61:=x62⟧ ⟹ False› 7. ‹⋀x71 x72 x73. ⟦val_of e₂ = None; icheck P C' (C∙⇩sF{D} := e₂); e₂ = x71∙x72{x73}⟧ ⟹ False› 8. ‹⋀x81 x82 x83. ⟦val_of e₂ = None; icheck P C' (C∙⇩sF{D} := e₂); e₂ = x81∙⇩sx82{x83}⟧ ⟹ False› 9. ‹⋀x91 x92 x93 x94. ⟦val_of e₂ = None; icheck P C' (C∙⇩sF{D} := e₂); e₂ = x91∙x92{x93} := x94⟧ ⟹ False› 10. ‹⋀x101 x102 x103 x104. ⟦val_of e₂ = None; icheck P C' (C∙⇩sF{D} := e₂); e₂ = x101∙⇩sx102{x103} := x104⟧ ⟹ False› 11. ‹⋀x111 x112 x113. ⟦val_of e₂ = None; icheck P C' (C∙⇩sF{D} := e₂); e₂ = x111∙x112(x113)⟧ ⟹ False› 12. ‹⋀x121 x122 x123. ⟦val_of e₂ = None; icheck P C' (C∙⇩sF{D} := e₂); e₂ = x121∙⇩sx122(x123)⟧ ⟹ False› 13. ‹⋀x131 x132 x133. ⟦val_of e₂ = None; icheck P C' (C∙⇩sF{D} := e₂); e₂ = {x131:x132; x133}⟧ ⟹ False› 14. ‹⋀x141 x142. ⟦val_of e₂ = None; icheck P C' (C∙⇩sF{D} := e₂); e₂ = x141;; x142⟧ ⟹ False› 15. ‹⋀x151 x152 x153. ⟦val_of e₂ = None; icheck P C' (C∙⇩sF{D} := e₂); e₂ = if (x151) x152 else x153⟧ ⟹ False› 16. ‹⋀x161 x162. ⟦val_of e₂ = None; icheck P C' (C∙⇩sF{D} := e₂); e₂ = while (x161) x162⟧ ⟹ False› 17. ‹⋀x17. ⟦val_of e₂ = None; icheck P C' (C∙⇩sF{D} := e₂); e₂ = throw x17⟧ ⟹ False› 18. ‹⋀x181 x182 x183 x184. ⟦val_of e₂ = None; icheck P C' (C∙⇩sF{D} := e₂); e₂ = try x181 catch(x182 x183) x184⟧ ⟹ False› 19. ‹⋀x191 x192 x193 x194. ⟦val_of e₂ = None; icheck P C' (C∙⇩sF{D} := e₂); e₂ = INIT x191 (x192,x193) ← x194⟧ ⟹ False› 20. ‹⋀x201 x202 x203 x204. ⟦val_of e₂ = None; icheck P C' (C∙⇩sF{D} := e₂); e₂ = RI (x201,x202) ; x203 ← x204⟧ ⟹ 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]) (*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]) (*proven 20 subgoals*) . inductive_set red :: "J_prog ⇒ ((expr × state × bool) × (expr × state × bool)) set" and reds :: "J_prog ⇒ ((expr list × state × bool) × (expr list × state × bool)) set" and red' :: "J_prog ⇒ expr ⇒ state ⇒ bool ⇒ expr ⇒ state ⇒ bool ⇒ bool" ("_ ⊢ ((1⟨_,/_,/_⟩) →/ (1⟨_,/_,/_⟩))" [51,0,0,0,0,0,0] 81) and reds' :: "J_prog ⇒ expr list ⇒ state ⇒ bool ⇒ expr list ⇒ state ⇒ bool ⇒ bool" ("_ ⊢ ((1⟨_,/_,/_⟩) [→]/ (1⟨_,/_,/_⟩))" [51,0,0,0,0,0,0] 81) for P :: J_prog where "P ⊢ ⟨e,s,b⟩ → ⟨e',s',b'⟩ ≡ ((e,s,b), e',s',b') ∈ red P" | "P ⊢ ⟨es,s,b⟩ [→] ⟨es',s',b'⟩ ≡ ((es,s,b), es',s',b') ∈ reds P" | RedNew: "⟦ new_Addr h = Some a; P ⊢ C has_fields FDTs; h' = h(a↦blank P C) ⟧ ⟹ P ⊢ ⟨new C, (h,l,sh), True⟩ → ⟨addr a, (h',l,sh), False⟩" | RedNewFail: "⟦ new_Addr h = None; is_class P C ⟧ ⟹ P ⊢ ⟨new C, (h,l,sh), True⟩ → ⟨THROW OutOfMemory, (h,l,sh), False⟩" | NewInitDoneRed: "sh C = Some (sfs, Done) ⟹ P ⊢ ⟨new C, (h,l,sh), False⟩ → ⟨new C, (h,l,sh), True⟩" | NewInitRed: "⟦ ∄sfs. sh C = Some (sfs, Done); is_class P C ⟧ ⟹ P ⊢ ⟨new C,(h,l,sh),False⟩ → ⟨INIT C ([C],False) ← new C,(h,l,sh),False⟩" | CastRed: "P ⊢ ⟨e,s,b⟩ → ⟨e',s',b'⟩ ⟹ P ⊢ ⟨Cast C e, s, b⟩ → ⟨Cast C e', s', b'⟩" | RedCastNull: "P ⊢ ⟨Cast C null, s, b⟩ → ⟨null,s,b⟩" | RedCast: "⟦ h a = Some(D,fs); P ⊢ D ≼⇧* C ⟧ ⟹ P ⊢ ⟨Cast C (addr a), (h,l,sh), b⟩ → ⟨addr a, (h,l,sh), b⟩" | RedCastFail: "⟦ h a = Some(D,fs); ¬ P ⊢ D ≼⇧* C ⟧ ⟹ P ⊢ ⟨Cast C (addr a), (h,l,sh), b⟩ → ⟨THROW ClassCast, (h,l,sh), b⟩" | BinOpRed1: "P ⊢ ⟨e,s,b⟩ → ⟨e',s',b'⟩ ⟹ P ⊢ ⟨e «bop» e₂, s, b⟩ → ⟨e' «bop» e₂, s', b'⟩" | BinOpRed2: "P ⊢ ⟨e,s,b⟩ → ⟨e',s',b'⟩ ⟹ P ⊢ ⟨(Val v₁) «bop» e, s, b⟩ → ⟨(Val v₁) «bop» e', s', b'⟩" | RedBinOp: "binop(bop,v₁,v₂) = Some v ⟹ P ⊢ ⟨(Val v₁) «bop» (Val v₂), s, b⟩ → ⟨Val v,s,b⟩" | RedVar: "l V = Some v ⟹ P ⊢ ⟨Var V,(h,l,sh),b⟩ → ⟨Val v,(h,l,sh),b⟩" | LAssRed: "P ⊢ ⟨e,s,b⟩ → ⟨e',s',b'⟩ ⟹ P ⊢ ⟨V:=e,s,b⟩ → ⟨V:=e',s',b'⟩" | RedLAss: "P ⊢ ⟨V:=(Val v), (h,l,sh), b⟩ → ⟨unit, (h,l(V↦v),sh), b⟩" | FAccRed: "P ⊢ ⟨e,s,b⟩ → ⟨e',s',b'⟩ ⟹ P ⊢ ⟨e∙F{D}, s, b⟩ → ⟨e'∙F{D}, s', b'⟩" | RedFAcc: "⟦ h a = Some(C,fs); fs(F,D) = Some v; P ⊢ C has F,NonStatic:t in D ⟧ ⟹ P ⊢ ⟨(addr a)∙F{D}, (h,l,sh), b⟩ → ⟨Val v,(h,l,sh),b⟩" | RedFAccNull: "P ⊢ ⟨null∙F{D}, s, b⟩ → ⟨THROW NullPointer, s, b⟩" | RedFAccNone: "⟦ h a = Some(C,fs); ¬(∃b t. P ⊢ C has F,b:t in D) ⟧ ⟹ P ⊢ ⟨(addr a)∙F{D},(h,l,sh),b⟩ → ⟨THROW NoSuchFieldError,(h,l,sh),b⟩" | RedFAccStatic: "⟦ h a = Some(C,fs); P ⊢ C has F,Static:t in D ⟧ ⟹ P ⊢ ⟨(addr a)∙F{D},(h,l,sh),b⟩ → ⟨THROW IncompatibleClassChangeError,(h,l,sh),b⟩" | RedSFAcc: "⟦ P ⊢ C has F,Static:t in D; sh D = Some (sfs,i); sfs F = Some v ⟧ ⟹ P ⊢ ⟨C∙⇩sF{D},(h,l,sh),True⟩ → ⟨Val v,(h,l,sh),False⟩" | SFAccInitDoneRed: "⟦ P ⊢ C has F,Static:t in D; sh D = Some (sfs,Done) ⟧ ⟹ P ⊢ ⟨C∙⇩sF{D},(h,l,sh),False⟩ → ⟨C∙⇩sF{D},(h,l,sh),True⟩" | SFAccInitRed: "⟦ P ⊢ C has F,Static:t in D; ∄sfs. sh D = Some (sfs,Done) ⟧ ⟹ P ⊢ ⟨C∙⇩sF{D},(h,l,sh),False⟩ → ⟨INIT D ([D],False) ← C∙⇩sF{D},(h,l,sh),False⟩" | RedSFAccNone: "¬(∃b t. P ⊢ C has F,b:t in D) ⟹ P ⊢ ⟨C∙⇩sF{D},(h,l,sh),b⟩ → ⟨THROW NoSuchFieldError,(h,l,sh),False⟩" | RedSFAccNonStatic: "P ⊢ C has F,NonStatic:t in D ⟹ P ⊢ ⟨C∙⇩sF{D},(h,l,sh),b⟩ → ⟨THROW IncompatibleClassChangeError,(h,l,sh),False⟩" | FAssRed1: "P ⊢ ⟨e,s,b⟩ → ⟨e',s',b'⟩ ⟹ P ⊢ ⟨e∙F{D}:=e₂, s, b⟩ → ⟨e'∙F{D}:=e₂, s', b'⟩" | FAssRed2: "P ⊢ ⟨e,s,b⟩ → ⟨e',s',b'⟩ ⟹ P ⊢ ⟨Val v∙F{D}:=e, s, b⟩ → ⟨Val v∙F{D}:=e', s', b'⟩" | RedFAss: "⟦ P ⊢ C has F,NonStatic:t in D; h a = Some(C,fs) ⟧ ⟹ P ⊢ ⟨(addr a)∙F{D}:=(Val v), (h,l,sh), b⟩ → ⟨unit, (h(a ↦ (C,fs((F,D) ↦ v))),l,sh), b⟩" | RedFAssNull: "P ⊢ ⟨null∙F{D}:=Val v, s, b⟩ → ⟨THROW NullPointer, s, b⟩" | RedFAssNone: "⟦ h a = Some(C,fs); ¬(∃b t. P ⊢ C has F,b:t in D) ⟧ ⟹ P ⊢ ⟨(addr a)∙F{D}:=(Val v),(h,l,sh),b⟩ → ⟨THROW NoSuchFieldError,(h,l,sh),b⟩" | RedFAssStatic: "⟦ h a = Some(C,fs); P ⊢ C has F,Static:t in D ⟧ ⟹ P ⊢ ⟨(addr a)∙F{D}:=(Val v),(h,l,sh),b⟩ → ⟨THROW IncompatibleClassChangeError,(h,l,sh),b⟩" | SFAssRed: "P ⊢ ⟨e,s,b⟩ → ⟨e',s',b'⟩ ⟹ P ⊢ ⟨C∙⇩sF{D}:=e, s, b⟩ → ⟨C∙⇩sF{D}:=e', s', b'⟩" | RedSFAss: "⟦ P ⊢ C has F,Static:t in D; sh D = Some(sfs,i); sfs' = sfs(F↦v); sh' = sh(D↦(sfs',i)) ⟧ ⟹ P ⊢ ⟨C∙⇩sF{D}:=(Val v),(h,l,sh),True⟩ → ⟨unit,(h,l,sh'),False⟩" | SFAssInitDoneRed: "⟦ P ⊢ C has F,Static:t in D; sh D = Some(sfs,Done) ⟧ ⟹ P ⊢ ⟨C∙⇩sF{D}:=(Val v),(h,l,sh),False⟩ → ⟨C∙⇩sF{D}:=(Val v),(h,l,sh),True⟩" | SFAssInitRed: "⟦ P ⊢ C has F,Static:t in D; ∄sfs. sh D = Some(sfs,Done) ⟧ ⟹ P ⊢ ⟨C∙⇩sF{D}:=(Val v),(h,l,sh),False⟩ → ⟨INIT D ([D],False)← C∙⇩sF{D}:=(Val v),(h,l,sh),False⟩" | RedSFAssNone: "¬(∃b t. P ⊢ C has F,b:t in D) ⟹ P ⊢ ⟨C∙⇩sF{D}:=(Val v),s,b⟩ → ⟨THROW NoSuchFieldError,s,False⟩" | RedSFAssNonStatic: "P ⊢ C has F,NonStatic:t in D ⟹ P ⊢ ⟨C∙⇩sF{D}:=(Val v),s,b⟩ → ⟨THROW IncompatibleClassChangeError,s,False⟩" | CallObj: "P ⊢ ⟨e,s,b⟩ → ⟨e',s',b'⟩ ⟹ P ⊢ ⟨e∙M(es),s,b⟩ → ⟨e'∙M(es),s',b'⟩" | CallParams: "P ⊢ ⟨es,s,b⟩ [→] ⟨es',s',b'⟩ ⟹ P ⊢ ⟨(Val v)∙M(es),s,b⟩ → ⟨(Val v)∙M(es'),s',b'⟩" | RedCall: "⟦ h a = Some(C,fs); P ⊢ C sees M,NonStatic:Ts→T = (pns,body) in D; size vs = size pns; size Ts = size pns ⟧ ⟹ P ⊢ ⟨(addr a)∙M(map Val vs), (h,l,sh), b⟩ → ⟨blocks(this#pns, Class D#Ts, Addr a#vs, body), (h,l,sh), b⟩" | RedCallNull: "P ⊢ ⟨null∙M(map Val vs),s,b⟩ → ⟨THROW NullPointer,s,b⟩" | RedCallNone: "⟦ h a = Some(C,fs); ¬(∃b Ts T m D. P ⊢ C sees M,b:Ts→T = m in D) ⟧ ⟹ P ⊢ ⟨(addr a)∙M(map Val vs),(h,l,sh),b⟩ → ⟨THROW NoSuchMethodError,(h,l,sh),b⟩" | RedCallStatic: "⟦ h a = Some(C,fs); P ⊢ C sees M,Static:Ts→T = m in D ⟧ ⟹ P ⊢ ⟨(addr a)∙M(map Val vs),(h,l,sh),b⟩ → ⟨THROW IncompatibleClassChangeError,(h,l,sh),b⟩" | SCallParams: "P ⊢ ⟨es,s,b⟩ [→] ⟨es',s',b'⟩ ⟹ P ⊢ ⟨C∙⇩sM(es),s,b⟩ → ⟨C∙⇩sM(es'),s',b'⟩" | RedSCall: "⟦ P ⊢ C sees M,Static:Ts→T = (pns,body) in D; length vs = length pns; size Ts = size pns ⟧ ⟹ P ⊢ ⟨C∙⇩sM(map Val vs),s,True⟩ → ⟨blocks(pns, Ts, vs, body), s, False⟩" | SCallInitDoneRed: "⟦ P ⊢ C sees M,Static:Ts→T = (pns,body) in D; sh D = Some(sfs,Done) ∨ (M = clinit ∧ sh D = Some(sfs,Processing)) ⟧ ⟹ P ⊢ ⟨C∙⇩sM(map Val vs),(h,l,sh), False⟩ → ⟨C∙⇩sM(map Val vs),(h,l,sh), True⟩" | SCallInitRed: "⟦ P ⊢ C sees M,Static:Ts→T = (pns,body) in D; ∄sfs. sh D = Some(sfs,Done); M ≠ clinit ⟧ ⟹ P ⊢ ⟨C∙⇩sM(map Val vs),(h,l,sh), False⟩ → ⟨INIT D ([D],False) ← C∙⇩sM(map Val vs),(h,l,sh),False⟩" | RedSCallNone: "⟦ ¬(∃b Ts T m D. P ⊢ C sees M,b:Ts→T = m in D) ⟧ ⟹ P ⊢ ⟨C∙⇩sM(map Val vs),s,b⟩ → ⟨THROW NoSuchMethodError,s,False⟩" | RedSCallNonStatic: "⟦ P ⊢ C sees M,NonStatic:Ts→T = m in D ⟧ ⟹ P ⊢ ⟨C∙⇩sM(map Val vs),s,b⟩ → ⟨THROW IncompatibleClassChangeError,s,False⟩" | BlockRedNone: "⟦ P ⊢ ⟨e, (h,l(V:=None),sh), b⟩ → ⟨e', (h',l',sh'), b'⟩; l' V = None; ¬ assigned V e ⟧ ⟹ P ⊢ ⟨{V:T; e}, (h,l,sh), b⟩ → ⟨{V:T; e'}, (h',l'(V := l V),sh'), b'⟩" | BlockRedSome: "⟦ P ⊢ ⟨e, (h,l(V:=None),sh), b⟩ → ⟨e', (h',l',sh'), b'⟩; l' V = Some v;¬ assigned V e ⟧ ⟹ P ⊢ ⟨{V:T; e}, (h,l,sh), b⟩ → ⟨{V:T := Val v; e'}, (h',l'(V := l V),sh'), b'⟩" | InitBlockRed: "⟦ P ⊢ ⟨e, (h,l(V↦v),sh), b⟩ → ⟨e', (h',l',sh'), b'⟩; l' V = Some v' ⟧ ⟹ P ⊢ ⟨{V:T := Val v; e}, (h,l,sh), b⟩ → ⟨{V:T := Val v'; e'}, (h',l'(V := l V),sh'), b'⟩" | RedBlock: "P ⊢ ⟨{V:T; Val u}, s, b⟩ → ⟨Val u, s, b⟩" | RedInitBlock: "P ⊢ ⟨{V:T := Val v; Val u}, s, b⟩ → ⟨Val u, s, b⟩" | SeqRed: "P ⊢ ⟨e,s,b⟩ → ⟨e',s',b'⟩ ⟹ P ⊢ ⟨e;;e₂, s, b⟩ → ⟨e';;e₂, s', b'⟩" | RedSeq: "P ⊢ ⟨(Val v);;e₂, s, b⟩ → ⟨e₂, s, b⟩" | CondRed: "P ⊢ ⟨e,s,b⟩ → ⟨e',s',b'⟩ ⟹ P ⊢ ⟨if (e) e₁ else e₂, s, b⟩ → ⟨if (e') e₁ else e₂, s', b'⟩" | RedCondT: "P ⊢ ⟨if (true) e₁ else e₂, s, b⟩ → ⟨e₁, s, b⟩" | RedCondF: "P ⊢ ⟨if (false) e₁ else e₂, s, b⟩ → ⟨e₂, s, b⟩" | RedWhile: "P ⊢ ⟨while(b) c, s, b'⟩ → ⟨if(b) (c;;while(b) c) else unit, s, b'⟩" | ThrowRed: "P ⊢ ⟨e,s,b⟩ → ⟨e',s',b'⟩ ⟹ P ⊢ ⟨throw e, s, b⟩ → ⟨throw e', s', b'⟩" | RedThrowNull: "P ⊢ ⟨throw null, s, b⟩ → ⟨THROW NullPointer, s, b⟩" | TryRed: "P ⊢ ⟨e,s,b⟩ → ⟨e',s',b'⟩ ⟹ P ⊢ ⟨try e catch(C V) e₂, s, b⟩ → ⟨try e' catch(C V) e₂, s', b'⟩" | RedTry: "P ⊢ ⟨try (Val v) catch(C V) e₂, s, b⟩ → ⟨Val v, s, b⟩" | RedTryCatch: "⟦ hp s a = Some(D,fs); P ⊢ D ≼⇧* C ⟧ ⟹ P ⊢ ⟨try (Throw a) catch(C V) e₂, s, b⟩ → ⟨{V:Class C := addr a; e₂}, s, b⟩" | RedTryFail: "⟦ hp s a = Some(D,fs); ¬ P ⊢ D ≼⇧* C ⟧ ⟹ P ⊢ ⟨try (Throw a) catch(C V) e₂, s, b⟩ → ⟨Throw a, s, b⟩" | ListRed1: "P ⊢ ⟨e,s,b⟩ → ⟨e',s',b'⟩ ⟹ P ⊢ ⟨e#es,s,b⟩ [→] ⟨e'#es,s',b'⟩" | ListRed2: "P ⊢ ⟨es,s,b⟩ [→] ⟨es',s',b'⟩ ⟹ P ⊢ ⟨Val v # es,s,b⟩ [→] ⟨Val v # es',s',b'⟩" ― ‹Initialization procedure› | RedInit: "¬sub_RI e ⟹ P ⊢ ⟨INIT C (Nil,b) ← e,s,b'⟩ → ⟨e,s,icheck P C e⟩" | InitNoneRed: "sh C = None ⟹ P ⊢ ⟨INIT C' (C#Cs,False) ← e,(h,l,sh),b⟩ → ⟨INIT C' (C#Cs,False) ← e,(h,l,sh(C ↦ (sblank P C, Prepared))),b⟩" | RedInitDone: "sh C = Some(sfs,Done) ⟹ P ⊢ ⟨INIT C' (C#Cs,False) ← e,(h,l,sh),b⟩ → ⟨INIT C' (Cs,True) ← e,(h,l,sh),b⟩" | RedInitProcessing: "sh C = Some(sfs,Processing) ⟹ P ⊢ ⟨INIT C' (C#Cs,False) ← e,(h,l,sh),b⟩ → ⟨INIT C' (Cs,True) ← e,(h,l,sh),b⟩" | RedInitError: "sh C = Some(sfs,Error) ⟹ P ⊢ ⟨INIT C' (C#Cs,False) ← e,(h,l,sh),b⟩ → ⟨RI (C,THROW NoClassDefFoundError);Cs ← e,(h,l,sh),b⟩" | InitObjectRed: "⟦ sh C = Some(sfs,Prepared); C = Object; sh' = sh(C ↦ (sfs,Processing)) ⟧ ⟹ P ⊢ ⟨INIT C' (C#Cs,False) ← e,(h,l,sh),b⟩ → ⟨INIT C' (C#Cs,True) ← e,(h,l,sh'),b⟩" | InitNonObjectSuperRed: "⟦ sh C = Some(sfs,Prepared); C ≠ Object; class P C = Some (D,r); sh' = sh(C ↦ (sfs,Processing)) ⟧ ⟹ P ⊢ ⟨INIT C' (C#Cs,False) ← e,(h,l,sh),b⟩ → ⟨INIT C' (D#C#Cs,False) ← e,(h,l,sh'),b⟩" | RedInitRInit: "P ⊢ ⟨INIT C' (C#Cs,True) ← e,(h,l,sh),b⟩ → ⟨RI (C,C∙⇩sclinit([]));Cs ← e,(h,l,sh),b⟩" | RInitRed: "P ⊢ ⟨e,s,b⟩ → ⟨e',s',b'⟩ ⟹ P ⊢ ⟨RI (C,e);Cs ← e₀, s, b⟩ → ⟨RI (C,e');Cs ← e₀, s', b'⟩" | RedRInit: "⟦ sh C = Some (sfs, i); sh' = sh(C ↦ (sfs,Done)); C' = last(C#Cs) ⟧ ⟹ P ⊢ ⟨RI (C, Val v);Cs ← e, (h,l,sh), b⟩ → ⟨INIT C' (Cs,True) ← e, (h,l,sh'), b⟩" ― ‹Exception propagation› | CastThrow: "P ⊢ ⟨Cast C (throw e), s, b⟩ → ⟨throw e, s, b⟩" | BinOpThrow1: "P ⊢ ⟨(throw e) «bop» e₂, s, b⟩ → ⟨throw e, s, b⟩" | BinOpThrow2: "P ⊢ ⟨(Val v₁) «bop» (throw e), s, b⟩ → ⟨throw e, s, b⟩" | LAssThrow: "P ⊢ ⟨V:=(throw e), s, b⟩ → ⟨throw e, s, b⟩" | FAccThrow: "P ⊢ ⟨(throw e)∙F{D}, s, b⟩ → ⟨throw e, s, b⟩" | FAssThrow1: "P ⊢ ⟨(throw e)∙F{D}:=e₂, s, b⟩ → ⟨throw e, s, b⟩" | FAssThrow2: "P ⊢ ⟨Val v∙F{D}:=(throw e), s, b⟩ → ⟨throw e, s, b⟩" | SFAssThrow: "P ⊢ ⟨C∙⇩sF{D}:=(throw e), s, b⟩ → ⟨throw e, s, b⟩" | CallThrowObj: "P ⊢ ⟨(throw e)∙M(es), s, b⟩ → ⟨throw e, s, b⟩" | CallThrowParams: "⟦ es = map Val vs @ throw e # es' ⟧ ⟹ P ⊢ ⟨(Val v)∙M(es), s, b⟩ → ⟨throw e, s, b⟩" | SCallThrowParams: "⟦ es = map Val vs @ throw e # es' ⟧ ⟹ P ⊢ ⟨C∙⇩sM(es), s, b⟩ → ⟨throw e, s, b⟩" | BlockThrow: "P ⊢ ⟨{V:T; Throw a}, s, b⟩ → ⟨Throw a, s, b⟩" | InitBlockThrow: "P ⊢ ⟨{V:T := Val v; Throw a}, s, b⟩ → ⟨Throw a, s, b⟩" | SeqThrow: "P ⊢ ⟨(throw e);;e₂, s, b⟩ → ⟨throw e, s, b⟩" | CondThrow: "P ⊢ ⟨if (throw e) e₁ else e₂, s, b⟩ → ⟨throw e, s, b⟩" | ThrowThrow: "P ⊢ ⟨throw(throw e), s, b⟩ → ⟨throw e, s, b⟩" | RInitInitThrow: "⟦ sh C = Some(sfs,i); sh' = sh(C ↦ (sfs,Error)) ⟧ ⟹ P ⊢ ⟨RI (C,Throw a);D#Cs ← e,(h,l,sh),b⟩ → ⟨RI (D,Throw a);Cs ← e,(h,l,sh'),b⟩" | RInitThrow: "⟦ sh C = Some(sfs, i); sh' = sh(C ↦ (sfs,Error)) ⟧ ⟹ P ⊢ ⟨RI (C,Throw a);Nil ← e,(h,l,sh),b⟩ → ⟨Throw a,(h,l,sh'),b⟩" (*<*) lemmas red_reds_induct = red_reds.induct [split_format (complete)] and red_reds_inducts = red_reds.inducts [split_format (complete)] inductive_cases [elim!]: "P ⊢ ⟨V:=e,s,b⟩ → ⟨e',s',b'⟩" "P ⊢ ⟨e1;;e2,s,b⟩ → ⟨e',s',b'⟩" (*>*) subsection‹ The reflexive transitive closure › abbreviation Step :: "J_prog ⇒ expr ⇒ state ⇒ bool ⇒ expr ⇒ state ⇒ bool ⇒ bool" ("_ ⊢ ((1⟨_,/_,/_⟩) →*/ (1⟨_,/_,/_⟩))" [51,0,0,0,0,0,0] 81) where "P ⊢ ⟨e,s,b⟩ →* ⟨e',s',b'⟩ ≡ ((e,s,b), e',s',b') ∈ (red P)⇧*" abbreviation Steps :: "J_prog ⇒ expr list ⇒ state ⇒ bool ⇒ expr list ⇒ state ⇒ bool ⇒ bool" ("_ ⊢ ((1⟨_,/_,/_⟩) [→]*/ (1⟨_,/_,/_⟩))" [51,0,0,0,0,0,0] 81) where "P ⊢ ⟨es,s,b⟩ [→]* ⟨es',s',b'⟩ ≡ ((es,s,b), es',s',b') ∈ (reds P)⇧*" lemmas converse_rtrancl_induct3 = converse_rtrancl_induct [of "(ax, ay, az)" "(bx, by, bz)", split_format (complete), consumes 1, case_names refl step] lemma converse_rtrancl_induct_red[consumes 1]: assumes "P ⊢ ⟨e,(h,l,sh),b⟩ →* ⟨e',(h',l',sh'),b'⟩" and "⋀e h l sh b. R e h l sh b e h l sh b" and "⋀e₀ h₀ l₀ sh₀ b₀ e₁ h₁ l₁ sh₁ b₁ e' h' l' sh' b'. ⟦ P ⊢ ⟨e₀,(h₀,l₀,sh₀),b₀⟩ → ⟨e₁,(h₁,l₁,sh₁),b₁⟩; R e₁ h₁ l₁ sh₁ b₁ e' h' l' sh' b' ⟧ ⟹ R e₀ h₀ l₀ sh₀ b₀ e' h' l' sh' b'" shows "R e h l sh b e' h' l' sh' b'" (*<*) proof (-) (*goal: ‹R e h l sh b e' h' l' sh' b'›*) { fix s and s' assume reds: "P ⊢ ⟨e,s,b⟩ →* ⟨e',s',b'⟩" and base: "⋀e s b. R e (hp s) (lcl s) (shp s) b e (hp s) (lcl s) (shp s) b" and "red₁": "⋀e₀ s₀ b₀ e₁ s₁ b₁ e' s' b'. ⟦ P ⊢ ⟨e₀,s₀,b₀⟩ → ⟨e₁,s₁,b₁⟩; R e₁ (hp s₁) (lcl s₁) (shp s₁) b₁ e' (hp s') (lcl s') (shp s') b' ⟧ ⟹ R e₀ (hp s₀) (lcl s₀) (shp s₀) b₀ e' (hp s') (lcl s') (shp s') b'" (*‹(P::(char list list × char list exp) prog) ⊢ ⟨e::char list exp,s::heap × sfields × sheap,b::bool⟩ →* ⟨e'::char list exp,s'::heap × sfields × sheap,b'::bool⟩› ‹(R::char list exp ⇒ heap ⇒ sfields ⇒ sheap ⇒ bool ⇒ char list exp ⇒ heap ⇒ sfields ⇒ sheap ⇒ bool ⇒ bool) (?e::char list exp) (hp (?s::heap × sfields × sheap)) (lcl ?s) (shp ?s) (?b::bool) ?e (hp ?s) (lcl ?s) (shp ?s) ?b› ‹⟦(P::(char list list × char list exp) prog) ⊢ ⟨?e₀::char list exp,?s₀::heap × sfields × sheap,?b₀::bool⟩ → ⟨?e₁::char list exp,?s₁::heap × sfields × sheap,?b₁::bool⟩; (R::char list exp ⇒ heap ⇒ sfields ⇒ sheap ⇒ bool ⇒ char list exp ⇒ heap ⇒ sfields ⇒ sheap ⇒ bool ⇒ bool) ?e₁ (hp ?s₁) (lcl ?s₁) (shp ?s₁) ?b₁ (?e'::char list exp) (hp (?s'::heap × sfields × sheap)) (lcl ?s') (shp ?s') (?b'::bool)⟧ ⟹ R ?e₀ (hp ?s₀) (lcl ?s₀) (shp ?s₀) ?b₀ ?e' (hp ?s') (lcl ?s') (shp ?s') ?b'›*) from reds (*‹P ⊢ ⟨e,s,b⟩ →* ⟨e',s',b'⟩›*) have "R e (hp s) (lcl s) (shp s) b e' (hp s') (lcl s') (shp s') b'" proof (induct rule:converse_rtrancl_induct3 (*‹⟦((?ax, ?ay, ?az), ?bx, ?by, ?bz) ∈ ?r⇧*; ?P ?bx ?by ?bz; ⋀a aa b ab ac ba. ⟦((a, aa, b), ab, ac, ba) ∈ ?r; ((ab, ac, ba), ?bx, ?by, ?bz) ∈ ?r⇧*; ?P ab ac ba⟧ ⟹ ?P a aa b⟧ ⟹ ?P ?ax ?ay ?az›*)) (*goals: 1. ‹R e' (hp s') (lcl s') (shp s') b' e' (hp s') (lcl s') (shp s') b'› 2. ‹⋀a aa b ab ac ba. ⟦P ⊢ ⟨a,aa,b⟩ → ⟨ab,ac,ba⟩; P ⊢ ⟨ab,ac,ba⟩ →* ⟨e',s',b'⟩; R ab (hp ac) (lcl ac) (shp ac) ba e' (hp s') (lcl s') (shp s') b'⟧ ⟹ R a (hp aa) (lcl aa) (shp aa) b e' (hp s') (lcl s') (shp s') b'›*) case refl (*no hyothesis introduced yet*) show "?case" (*goal: ‹R e' (hp s') (lcl s') (shp s') b' e' (hp s') (lcl s') (shp s') b'›*) by (rule base (*‹R ?e (hp ?s) (lcl ?s) (shp ?s) ?b ?e (hp ?s) (lcl ?s) (shp ?s) ?b›*)) next (*goal: ‹⋀a aa b ab ac ba. ⟦P ⊢ ⟨a,aa,b⟩ → ⟨ab,ac,ba⟩; P ⊢ ⟨ab,ac,ba⟩ →* ⟨e',s',b'⟩; R ab (hp ac) (lcl ac) (shp ac) ba e' (hp s') (lcl s') (shp s') b'⟧ ⟹ R a (hp aa) (lcl aa) (shp aa) b e' (hp s') (lcl s') (shp s') b'›*) case step (*‹(P::(char list list × char list exp) prog) ⊢ ⟨a___::char list exp,aa___::heap × sfields × sheap,ba___::bool⟩ → ⟨ab___::char list exp,a_::heap × sfields × sheap,b_::bool⟩› ‹P ⊢ ⟨ab___,a_,b_⟩ →* ⟨e',s',b'⟩› ‹R ab___ (hp a_) (lcl a_) (shp a_) b_ e' (hp s') (lcl s') (shp s') b'›*) thus "?case" (*goal: ‹(R::char list exp ⇒ heap ⇒ sfields ⇒ sheap ⇒ bool ⇒ char list exp ⇒ heap ⇒ sfields ⇒ sheap ⇒ bool ⇒ bool) (a___::char list exp) (hp (aa___::heap × sfields × sheap)) (lcl aa___) (shp aa___) (ba___::bool) (e'::char list exp) (hp (s'::heap × sfields × sheap)) (lcl s') (shp s') (b'::bool)›*) by (blast intro:red₁ (*‹⟦P ⊢ ⟨?e₀,?s₀,?b₀⟩ → ⟨?e₁,?s₁,?b₁⟩; R ?e₁ (hp ?s₁) (lcl ?s₁) (shp ?s₁) ?b₁ ?e' (hp ?s') (lcl ?s') (shp ?s') ?b'⟧ ⟹ R ?e₀ (hp ?s₀) (lcl ?s₀) (shp ?s₀) ?b₀ ?e' (hp ?s') (lcl ?s') (shp ?s') ?b'›*)) qed } with assms (*‹P ⊢ ⟨e,(h, l, sh),b⟩ →* ⟨e',(h', l', sh'),b'⟩› ‹R ?e ?h ?l ?sh ?b ?e ?h ?l ?sh ?b› ‹⟦P ⊢ ⟨?e₀,(?h₀, ?l₀, ?sh₀),?b₀⟩ → ⟨?e₁,(?h₁, ?l₁, ?sh₁),?b₁⟩; R ?e₁ ?h₁ ?l₁ ?sh₁ ?b₁ ?e' ?h' ?l' ?sh' ?b'⟧ ⟹ R ?e₀ ?h₀ ?l₀ ?sh₀ ?b₀ ?e' ?h' ?l' ?sh' ?b'›*) show "?thesis" (*goal: ‹R e h l sh b e' h' l' sh' b'›*) by fastforce qed (*>*) subsection‹Some easy lemmas› lemma [iff]: "¬ P ⊢ ⟨[],s,b⟩ [→] ⟨es',s',b'⟩" (*<*)by (blast elim: reds.cases (*‹⟦(?P::(char list list × char list exp) prog) ⊢ ⟨?a1.0::char list exp list,?a2.0::heap × sfields × sheap,?a3.0::bool⟩ [→] ⟨?a4.0::char list exp list,?a5.0::heap × sfields × sheap,?a6.0::bool⟩; ⋀(e::char list exp) (s::heap × sfields × sheap) (b::bool) (e'::char list exp) (s'::heap × sfields × sheap) (b'::bool) es::char list exp list. ⟦?a1.0 = e # es; ?a2.0 = s; ?a3.0 = b; ?a4.0 = e' # es; ?a5.0 = s'; ?a6.0 = b'; ?P ⊢ ⟨e,s,b⟩ → ⟨e',s',b'⟩⟧ ⟹ ?Pa::bool; ⋀(es::char list exp list) (s::heap × sfields × sheap) (b::bool) (es'::char list exp list) (s'::heap × sfields × sheap) (b'::bool) v::val. ⟦?a1.0 = Val v # es; ?a2.0 = s; ?a3.0 = b; ?a4.0 = Val v # es'; ?a5.0 = s'; ?a6.0 = b'; ?P ⊢ ⟨es,s,b⟩ [→] ⟨es',s',b'⟩⟧ ⟹ ?Pa⟧ ⟹ ?Pa›*))(*>*) lemma [iff]: "¬ P ⊢ ⟨Val v,s,b⟩ → ⟨e',s',b'⟩" (*<*)by (fastforce elim: red.cases (*‹⟦?P ⊢ ⟨?a1.0,?a2.0,?a3.0⟩ → ⟨?a4.0,?a5.0,?a6.0⟩; ⋀h a C FDTs h' l sh. ⟦?a1.0 = new C; ?a2.0 = (h, l, sh); ?a3.0 = True; ?a4.0 = addr a; ?a5.0 = (h', l, sh); ?a6.0 = False; new_Addr h = ⌊a⌋; ?P ⊢ C has_fields FDTs; h' = h(a ↦ blank ?P C)⟧ ⟹ ?Pa; ⋀h C l sh. ⟦?a1.0 = new C; ?a2.0 = (h, l, sh); ?a3.0 = True; ?a4.0 = THROW OutOfMemory; ?a5.0 = (h, l, sh); ?a6.0 = False; new_Addr h = None; is_class ?P C⟧ ⟹ ?Pa; ⋀sh C sfs h l. ⟦?a1.0 = new C; ?a2.0 = (h, l, sh); ?a3.0 = False; ?a4.0 = new C; ?a5.0 = (h, l, sh); ?a6.0 = True; sh C = ⌊(sfs, Done)⌋⟧ ⟹ ?Pa; ⋀sh C h l. ⟦?a1.0 = new C; ?a2.0 = (h, l, sh); ?a3.0 = False; ?a4.0 = INIT C ([C],False) ← new C; ?a5.0 = (h, l, sh); ?a6.0 = False; ∄sfs. sh C = ⌊(sfs, Done)⌋; is_class ?P C⟧ ⟹ ?Pa; ⋀e s b e' s' b' C. ⟦?a1.0 = Cast C e; ?a2.0 = s; ?a3.0 = b; ?a4.0 = Cast C e'; ?a5.0 = s'; ?a6.0 = b'; ?P ⊢ ⟨e,s,b⟩ → ⟨e',s',b'⟩⟧ ⟹ ?Pa; ⋀C s b. ⟦?a1.0 = Cast C null; ?a2.0 = s; ?a3.0 = b; ?a4.0 = null; ?a5.0 = s; ?a6.0 = b⟧ ⟹ ?Pa; ⋀h a D fs C l sh b. ⟦?a1.0 = Cast C (addr a); ?a2.0 = (h, l, sh); ?a3.0 = b; ?a4.0 = addr a; ?a5.0 = (h, l, sh); ?a6.0 = b; h a = ⌊(D, fs)⌋; ?P ⊢ D ≼⇧* C⟧ ⟹ ?Pa; ⋀h a D fs C l sh b. ⟦?a1.0 = Cast C (addr a); ?a2.0 = (h, l, sh); ?a3.0 = b; ?a4.0 = THROW ClassCast; ?a5.0 = (h, l, sh); ?a6.0 = b; h a = ⌊(D, fs)⌋; (D, C) ∉ (subcls1 ?P)⇧*⟧ ⟹ ?Pa; ⋀e s b e' s' b' bop e₂. ⟦?a1.0 = e «bop» e₂; ?a2.0 = s; ?a3.0 = b; ?a4.0 = e' «bop» e₂; ?a5.0 = s'; ?a6.0 = b'; ?P ⊢ ⟨e,s,b⟩ → ⟨e',s',b'⟩⟧ ⟹ ?Pa; ⋀e s b e' s' b' v₁ bop. ⟦?a1.0 = Val v₁ «bop» e; ?a2.0 = s; ?a3.0 = b; ?a4.0 = Val v₁ «bop» e'; ?a5.0 = s'; ?a6.0 = b'; ?P ⊢ ⟨e,s,b⟩ → ⟨e',s',b'⟩⟧ ⟹ ?Pa; ⋀bop v₁ v₂ v s b. ⟦?a1.0 = Val v₁ «bop» Val v₂; ?a2.0 = s; ?a3.0 = b; ?a4.0 = Val v; ?a5.0 = s; ?a6.0 = b; binop (bop, v₁, v₂) = ⌊v⌋⟧ ⟹ ?Pa; ⋀l V v h sh b. ⟦?a1.0 = Var V; ?a2.0 = (h, l, sh); ?a3.0 = b; ?a4.0 = Val v; ?a5.0 = (h, l, sh); ?a6.0 = b; l V = ⌊v⌋⟧ ⟹ ?Pa; ⋀e s b e' s' b' V. ⟦?a1.0 = V:=e; ?a2.0 = s; ?a3.0 = b; ?a4.0 = V:=e'; ?a5.0 = s'; ?a6.0 = b'; ?P ⊢ ⟨e,s,b⟩ → ⟨e',s',b'⟩⟧ ⟹ ?Pa; ⋀V v h l sh b. ⟦?a1.0 = V:=Val v; ?a2.0 = (h, l, sh); ?a3.0 = b; ?a4.0 = unit; ?a5.0 = (h, l(V ↦ v), sh); ?a6.0 = b⟧ ⟹ ?Pa; ⋀e s b e' s' b' F D. ⟦?a1.0 = e∙F{D}; ?a2.0 = s; ?a3.0 = b; ?a4.0 = e'∙F{D}; ?a5.0 = s'; ?a6.0 = b'; ?P ⊢ ⟨e,s,b⟩ → ⟨e',s',b'⟩⟧ ⟹ ?Pa; ⋀h a C fs F D v t l sh b. ⟦?a1.0 = addr a∙F{D}; ?a2.0 = (h, l, sh); ?a3.0 = b; ?a4.0 = Val v; ?a5.0 = (h, l, sh); ?a6.0 = b; h a = ⌊(C, fs)⌋; fs (F, D) = ⌊v⌋; ?P ⊢ C has F,NonStatic:t in D⟧ ⟹ ?Pa; ⋀F D s b. ⟦?a1.0 = null∙F{D}; ?a2.0 = s; ?a3.0 = b; ?a4.0 = THROW NullPointer; ?a5.0 = s; ?a6.0 = b⟧ ⟹ ?Pa; ⋀h a C fs F D l sh b. ⟦?a1.0 = addr a∙F{D}; ?a2.0 = (h, l, sh); ?a3.0 = b; ?a4.0 = THROW NoSuchFieldError; ?a5.0 = (h, l, sh); ?a6.0 = b; h a = ⌊(C, fs)⌋; ∄b t. ?P ⊢ C has F,b:t in D⟧ ⟹ ?Pa; ⋀h a C fs F t D l sh b. ⟦?a1.0 = addr a∙F{D}; ?a2.0 = (h, l, sh); ?a3.0 = b; ?a4.0 = THROW IncompatibleClassChangeError; ?a5.0 = (h, l, sh); ?a6.0 = b; h a = ⌊(C, fs)⌋; ?P ⊢ C has F,Static:t in D⟧ ⟹ ?Pa; ⋀C F t D sh sfs i v h l. ⟦?a1.0 = C∙⇩sF{D}; ?a2.0 = (h, l, sh); ?a3.0 = True; ?a4.0 = Val v; ?a5.0 = (h, l, sh); ?a6.0 = False; ?P ⊢ C has F,Static:t in D; sh D = ⌊(sfs, i)⌋; sfs F = ⌊v⌋⟧ ⟹ ?Pa; ⋀C F t D sh sfs h l. ⟦?a1.0 = C∙⇩sF{D}; ?a2.0 = (h, l, sh); ?a3.0 = False; ?a4.0 = C∙⇩sF{D}; ?a5.0 = (h, l, sh); ?a6.0 = True; ?P ⊢ C has F,Static:t in D; sh D = ⌊(sfs, Done)⌋⟧ ⟹ ?Pa; ⋀C F t D sh h l. ⟦?a1.0 = C∙⇩sF{D}; ?a2.0 = (h, l, sh); ?a3.0 = False; ?a4.0 = INIT D ([D],False) ← C∙⇩sF{D}; ?a5.0 = (h, l, sh); ?a6.0 = False; ?P ⊢ C has F,Static:t in D; ∄sfs. sh D = ⌊(sfs, Done)⌋⟧ ⟹ ?Pa; ⋀C F D h l sh b. ⟦?a1.0 = C∙⇩sF{D}; ?a2.0 = (h, l, sh); ?a3.0 = b; ?a4.0 = THROW NoSuchFieldError; ?a5.0 = (h, l, sh); ?a6.0 = False; ∄b t. ?P ⊢ C has F,b:t in D⟧ ⟹ ?Pa; ⋀C F t D h l sh b. ⟦?a1.0 = C∙⇩sF{D}; ?a2.0 = (h, l, sh); ?a3.0 = b; ?a4.0 = THROW IncompatibleClassChangeError; ?a5.0 = (h, l, sh); ?a6.0 = False; ?P ⊢ C has F,NonStatic:t in D⟧ ⟹ ?Pa; ⋀e s b e' s' b' F D e₂. ⟦?a1.0 = e∙F{D} := e₂; ?a2.0 = s; ?a3.0 = b; ?a4.0 = e'∙F{D} := e₂; ?a5.0 = s'; ?a6.0 = b'; ?P ⊢ ⟨e,s,b⟩ → ⟨e',s',b'⟩⟧ ⟹ ?Pa; ⋀e s b e' s' b' v F D. ⟦?a1.0 = Val v∙F{D} := e; ?a2.0 = s; ?a3.0 = b; ?a4.0 = Val v∙F{D} := e'; ?a5.0 = s'; ?a6.0 = b'; ?P ⊢ ⟨e,s,b⟩ → ⟨e',s',b'⟩⟧ ⟹ ?Pa; ⋀C F t D h a fs v l sh b. ⟦?a1.0 = addr a∙F{D} := Val v; ?a2.0 = (h, l, sh); ?a3.0 = b; ?a4.0 = unit; ?a5.0 = (h(a ↦ (C, fs((F, D) ↦ v))), l, sh); ?a6.0 = b; ?P ⊢ C has F,NonStatic:t in D; h a = ⌊(C, fs)⌋⟧ ⟹ ?Pa; ⋀F D v s b. ⟦?a1.0 = null∙F{D} := Val v; ?a2.0 = s; ?a3.0 = b; ?a4.0 = THROW NullPointer; ?a5.0 = s; ?a6.0 = b⟧ ⟹ ?Pa; ⋀h a C fs F D v l sh b. ⟦?a1.0 = addr a∙F{D} := Val v; ?a2.0 = (h, l, sh); ?a3.0 = b; ?a4.0 = THROW NoSuchFieldError; ?a5.0 = (h, l, sh); ?a6.0 = b; h a = ⌊(C, fs)⌋; ∄b t. ?P ⊢ C has F,b:t in D⟧ ⟹ ?Pa; ⋀h a C fs F t D v l sh b. ⟦?a1.0 = addr a∙F{D} := Val v; ?a2.0 = (h, l, sh); ?a3.0 = b; ?a4.0 = THROW IncompatibleClassChangeError; ?a5.0 = (h, l, sh); ?a6.0 = b; h a = ⌊(C, fs)⌋; ?P ⊢ C has F,Static:t in D⟧ ⟹ ?Pa; ⋀e s b e' s' b' C F D. ⟦?a1.0 = C∙⇩sF{D} := e; ?a2.0 = s; ?a3.0 = b; ?a4.0 = C∙⇩sF{D} := e'; ?a5.0 = s'; ?a6.0 = b'; ?P ⊢ ⟨e,s,b⟩ → ⟨e',s',b'⟩⟧ ⟹ ?Pa; ⋀C F t D sh sfs i sfs' v sh' h l. ⟦?a1.0 = C∙⇩sF{D} := Val v; ?a2.0 = (h, l, sh); ?a3.0 = True; ?a4.0 = unit; ?a5.0 = (h, l, sh'); ?a6.0 = False; ?P ⊢ C has F,Static:t in D; sh D = ⌊(sfs, i)⌋; sfs' = sfs(F ↦ v); sh' = sh(D ↦ (sfs', i))⟧ ⟹ ?Pa; ⋀C F t D sh sfs v h l. ⟦?a1.0 = C∙⇩sF{D} := Val v; ?a2.0 = (h, l, sh); ?a3.0 = False; ?a4.0 = C∙⇩sF{D} := Val v; ?a5.0 = (h, l, sh); ?a6.0 = True; ?P ⊢ C has F,Static:t in D; sh D = ⌊(sfs, Done)⌋⟧ ⟹ ?Pa; ⋀C F t D sh v h l. ⟦?a1.0 = C∙⇩sF{D} := Val v; ?a2.0 = (h, l, sh); ?a3.0 = False; ?a4.0 = INIT D ([D],False) ← C∙⇩sF{D} := Val v; ?a5.0 = (h, l, sh); ?a6.0 = False; ?P ⊢ C has F,Static:t in D; ∄sfs. sh D = ⌊(sfs, Done)⌋⟧ ⟹ ?Pa; ⋀C F D v s b. ⟦?a1.0 = C∙⇩sF{D} := Val v; ?a2.0 = s; ?a3.0 = b; ?a4.0 = THROW NoSuchFieldError; ?a5.0 = s; ?a6.0 = False; ∄b t. ?P ⊢ C has F,b:t in D⟧ ⟹ ?Pa; ⋀C F t D v s b. ⟦?a1.0 = C∙⇩sF{D} := Val v; ?a2.0 = s; ?a3.0 = b; ?a4.0 = THROW IncompatibleClassChangeError; ?a5.0 = s; ?a6.0 = False; ?P ⊢ C has F,NonStatic:t in D⟧ ⟹ ?Pa; ⋀e s b e' s' b' M es. ⟦?a1.0 = e∙M(es); ?a2.0 = s; ?a3.0 = b; ?a4.0 = e'∙M(es); ?a5.0 = s'; ?a6.0 = b'; ?P ⊢ ⟨e,s,b⟩ → ⟨e',s',b'⟩⟧ ⟹ ?Pa; ⋀es s b es' s' b' v M. ⟦?a1.0 = Val v∙M(es); ?a2.0 = s; ?a3.0 = b; ?a4.0 = Val v∙M(es'); ?a5.0 = s'; ?a6.0 = b'; ?P ⊢ ⟨es,s,b⟩ [→] ⟨es',s',b'⟩⟧ ⟹ ?Pa; ⋀h a C fs M Ts T pns body D vs l sh b. ⟦?a1.0 = addr a∙M(map Val vs); ?a2.0 = (h, l, sh); ?a3.0 = b; ?a4.0 = blocks (this # pns, Class D # Ts, Addr a # vs, body); ?a5.0 = (h, l, sh); ?a6.0 = b; h a = ⌊(C, fs)⌋; ?P ⊢ C sees M, NonStatic : Ts→T = (pns, body) in D; length vs = length pns; length Ts = length pns⟧ ⟹ ?Pa; ⋀M vs s b. ⟦?a1.0 = null∙M(map Val vs); ?a2.0 = s; ?a3.0 = b; ?a4.0 = THROW NullPointer; ?a5.0 = s; ?a6.0 = b⟧ ⟹ ?Pa; ⋀h a C fs M vs l sh b. ⟦?a1.0 = addr a∙M(map Val vs); ?a2.0 = (h, l, sh); ?a3.0 = b; ?a4.0 = THROW NoSuchMethodError; ?a5.0 = (h, l, sh); ?a6.0 = b; h a = ⌊(C, fs)⌋; ∄b Ts T m D. ?P ⊢ C sees M, b : Ts→T = m in D⟧ ⟹ ?Pa; ⋀h a C fs M Ts T m D vs l sh b. ⟦?a1.0 = addr a∙M(map Val vs); ?a2.0 = (h, l, sh); ?a3.0 = b; ?a4.0 = THROW IncompatibleClassChangeError; ?a5.0 = (h, l, sh); ?a6.0 = b; h a = ⌊(C, fs)⌋; ?P ⊢ C sees M, Static : Ts→T = m in D⟧ ⟹ ?Pa; ⋀es s b es' s' b' C M. ⟦?a1.0 = C∙⇩sM(es); ?a2.0 = s; ?a3.0 = b; ?a4.0 = C∙⇩sM(es'); ?a5.0 = s'; ?a6.0 = b'; ?P ⊢ ⟨es,s,b⟩ [→] ⟨es',s',b'⟩⟧ ⟹ ?Pa; ⋀C M Ts T pns body D vs s. ⟦?a1.0 = C∙⇩sM(map Val vs); ?a2.0 = s; ?a3.0 = True; ?a4.0 = blocks (pns, Ts, vs, body); ?a5.0 = s; ?a6.0 = False; ?P ⊢ C sees M, Static : Ts→T = (pns, body) in D; length vs = length pns; length Ts = length pns⟧ ⟹ ?Pa; ⋀C M Ts T pns body D sh sfs vs h l. ⟦?a1.0 = C∙⇩sM(map Val vs); ?a2.0 = (h, l, sh); ?a3.0 = False; ?a4.0 = C∙⇩sM(map Val vs); ?a5.0 = (h, l, sh); ?a6.0 = True; ?P ⊢ C sees M, Static : Ts→T = (pns, body) in D; sh D = ⌊(sfs, Done)⌋ ∨ M = clinit ∧ sh D = ⌊(sfs, Processing)⌋⟧ ⟹ ?Pa; ⋀C M Ts T pns body D sh vs h l. ⟦?a1.0 = C∙⇩sM(map Val vs); ?a2.0 = (h, l, sh); ?a3.0 = False; ?a4.0 = INIT D ([D],False) ← C∙⇩sM(map Val vs); ?a5.0 = (h, l, sh); ?a6.0 = False; ?P ⊢ C sees M, Static : Ts→T = (pns, body) in D; ∄sfs. sh D = ⌊(sfs, Done)⌋; M ≠ clinit⟧ ⟹ ?Pa; ⋀C M vs s b. ⟦?a1.0 = C∙⇩sM(map Val vs); ?a2.0 = s; ?a3.0 = b; ?a4.0 = THROW NoSuchMethodError; ?a5.0 = s; ?a6.0 = False; ∄b Ts T m D. ?P ⊢ C sees M, b : Ts→T = m in D⟧ ⟹ ?Pa; ⋀C M Ts T m D vs s b. ⟦?a1.0 = C∙⇩sM(map Val vs); ?a2.0 = s; ?a3.0 = b; ?a4.0 = THROW IncompatibleClassChangeError; ?a5.0 = s; ?a6.0 = False; ?P ⊢ C sees M, NonStatic : Ts→T = m in D⟧ ⟹ ?Pa; ⋀e h l V sh b e' h' l' sh' b' T. ⟦?a1.0 = {V:T; e}; ?a2.0 = (h, l, sh); ?a3.0 = b; ?a4.0 = {V:T; e'}; ?a5.0 = (h', l'(V := l V), sh'); ?a6.0 = b'; ?P ⊢ ⟨e,(h, l(V := None), sh),b⟩ → ⟨e',(h', l', sh'),b'⟩; l' V = None; ¬ assigned V e⟧ ⟹ ?Pa; ⋀e h l V sh b e' h' l' sh' b' v T. ⟦?a1.0 = {V:T; e}; ?a2.0 = (h, l, sh); ?a3.0 = b; ?a4.0 = {V:T; V:=Val v;; e'}; ?a5.0 = (h', l'(V := l V), sh'); ?a6.0 = b'; ?P ⊢ ⟨e,(h, l(V := None), sh),b⟩ → ⟨e',(h', l', sh'),b'⟩; l' V = ⌊v⌋; ¬ assigned V e⟧ ⟹ ?Pa; ⋀e h l V v sh b e' h' l' sh' b' v' T. ⟦?a1.0 = {V:T; V:=Val v;; e}; ?a2.0 = (h, l, sh); ?a3.0 = b; ?a4.0 = {V:T; V:=Val v';; e'}; ?a5.0 = (h', l'(V := l V), sh'); ?a6.0 = b'; ?P ⊢ ⟨e,(h, l(V ↦ v), sh),b⟩ → ⟨e',(h', l', sh'),b'⟩; l' V = ⌊v'⌋⟧ ⟹ ?Pa; ⋀V T u s b. ⟦?a1.0 = {V:T; Val u}; ?a2.0 = s; ?a3.0 = b; ?a4.0 = Val u; ?a5.0 = s; ?a6.0 = b⟧ ⟹ ?Pa; ⋀V T v u s b. ⟦?a1.0 = {V:T; V:=Val v;; Val u}; ?a2.0 = s; ?a3.0 = b; ?a4.0 = Val u; ?a5.0 = s; ?a6.0 = b⟧ ⟹ ?Pa; ⋀e s b e' s' b' e₂. ⟦?a1.0 = e;; e₂; ?a2.0 = s; ?a3.0 = b; ?a4.0 = e';; e₂; ?a5.0 = s'; ?a6.0 = b'; ?P ⊢ ⟨e,s,b⟩ → ⟨e',s',b'⟩⟧ ⟹ ?Pa; ⋀v e₂ s b. ⟦?a1.0 = Val v;; e₂; ?a2.0 = s; ?a3.0 = b; ?a4.0 = e₂; ?a5.0 = s; ?a6.0 = b⟧ ⟹ ?Pa; ⋀e s b e' s' b' e₁ e₂. ⟦?a1.0 = if (e) e₁ else e₂; ?a2.0 = s; ?a3.0 = b; ?a4.0 = if (e') e₁ else e₂; ?a5.0 = s'; ?a6.0 = b'; ?P ⊢ ⟨e,s,b⟩ → ⟨e',s',b'⟩⟧ ⟹ ?Pa; ⋀e₁ e₂ s b. ⟦?a1.0 = if (true) e₁ else e₂; ?a2.0 = s; ?a3.0 = b; ?a4.0 = e₁; ?a5.0 = s; ?a6.0 = b⟧ ⟹ ?Pa; ⋀e₁ e₂ s b. ⟦?a1.0 = if (false) e₁ else e₂; ?a2.0 = s; ?a3.0 = b; ?a4.0 = e₂; ?a5.0 = s; ?a6.0 = b⟧ ⟹ ?Pa; ⋀b c s b'. ⟦?a1.0 = while (b) c; ?a2.0 = s; ?a3.0 = b'; ?a4.0 = if (b) (c;; while (b) c) else unit; ?a5.0 = s; ?a6.0 = b'⟧ ⟹ ?Pa; ⋀e s b e' s' b'. ⟦?a1.0 = throw e; ?a2.0 = s; ?a3.0 = b; ?a4.0 = throw e'; ?a5.0 = s'; ?a6.0 = b'; ?P ⊢ ⟨e,s,b⟩ → ⟨e',s',b'⟩⟧ ⟹ ?Pa; ⋀s b. ⟦?a1.0 = throw null; ?a2.0 = s; ?a3.0 = b; ?a4.0 = THROW NullPointer; ?a5.0 = s; ?a6.0 = b⟧ ⟹ ?Pa; ⋀e s b e' s' b' C V e₂. ⟦?a1.0 = try e catch(C V) e₂; ?a2.0 = s; ?a3.0 = b; ?a4.0 = try e' catch(C V) e₂; ?a5.0 = s'; ?a6.0 = b'; ?P ⊢ ⟨e,s,b⟩ → ⟨e',s',b'⟩⟧ ⟹ ?Pa; ⋀v C V e₂ s b. ⟦?a1.0 = try Val v catch(C V) e₂; ?a2.0 = s; ?a3.0 = b; ?a4.0 = Val v; ?a5.0 = s; ?a6.0 = b⟧ ⟹ ?Pa; ⋀s a D fs C V e₂ b. ⟦?a1.0 = try Throw a catch(C V) e₂; ?a2.0 = s; ?a3.0 = b; ?a4.0 = {V:Class C; V:=addr a;; e₂}; ?a5.0 = s; ?a6.0 = b; hp s a = ⌊(D, fs)⌋; ?P ⊢ D ≼⇧* C⟧ ⟹ ?Pa; ⋀s a D fs C V e₂ b. ⟦?a1.0 = try Throw a catch(C V) e₂; ?a2.0 = s; ?a3.0 = b; ?a4.0 = Throw a; ?a5.0 = s; ?a6.0 = b; hp s a = ⌊(D, fs)⌋; (D, C) ∉ (subcls1 ?P)⇧*⟧ ⟹ ?Pa; ⋀e C b s b'. ⟦?a1.0 = INIT C ([],b) ← e; ?a2.0 = s; ?a3.0 = b'; ?a4.0 = e; ?a5.0 = s; ?a6.0 = icheck ?P C e; ¬ sub_RI e⟧ ⟹ ?Pa; ⋀sh C C' Cs e h l b. ⟦?a1.0 = INIT C' (C # Cs,False) ← e; ?a2.0 = (h, l, sh); ?a3.0 = b; ?a4.0 = INIT C' (C # Cs,False) ← e; ?a5.0 = (h, l, sh(C ↦ (sblank ?P C, Prepared))); ?a6.0 = b; sh C = None⟧ ⟹ ?Pa; ⋀sh C sfs C' Cs e h l b. ⟦?a1.0 = INIT C' (C # Cs,False) ← e; ?a2.0 = (h, l, sh); ?a3.0 = b; ?a4.0 = INIT C' (Cs,True) ← e; ?a5.0 = (h, l, sh); ?a6.0 = b; sh C = ⌊(sfs, Done)⌋⟧ ⟹ ?Pa; ⋀sh C sfs C' Cs e h l b. ⟦?a1.0 = INIT C' (C # Cs,False) ← e; ?a2.0 = (h, l, sh); ?a3.0 = b; ?a4.0 = INIT C' (Cs,True) ← e; ?a5.0 = (h, l, sh); ?a6.0 = b; sh C = ⌊(sfs, Processing)⌋⟧ ⟹ ?Pa; ⋀sh C sfs C' Cs e h l b. ⟦?a1.0 = INIT C' (C # Cs,False) ← e; ?a2.0 = (h, l, sh); ?a3.0 = b; ?a4.0 = RI (C,THROW NoClassDefFoundError) ; Cs ← e; ?a5.0 = (h, l, sh); ?a6.0 = b; sh C = ⌊(sfs, Error)⌋⟧ ⟹ ?Pa; ⋀sh C sfs sh' C' Cs e h l b. ⟦?a1.0 = INIT C' (C # Cs,False) ← e; ?a2.0 = (h, l, sh); ?a3.0 = b; ?a4.0 = INIT C' (C # Cs,True) ← e; ?a5.0 = (h, l, sh'); ?a6.0 = b; sh C = ⌊(sfs, Prepared)⌋; C = Object; sh' = sh(C ↦ (sfs, Processing))⟧ ⟹ ?Pa; ⋀sh C sfs D r sh' C' Cs e h l b. ⟦?a1.0 = INIT C' (C # Cs,False) ← e; ?a2.0 = (h, l, sh); ?a3.0 = b; ?a4.0 = INIT C' (D # C # Cs,False) ← e; ?a5.0 = (h, l, sh'); ?a6.0 = b; sh C = ⌊(sfs, Prepared)⌋; C ≠ Object; class ?P C = ⌊(D, r)⌋; sh' = sh(C ↦ (sfs, Processing))⟧ ⟹ ?Pa; ⋀C' C Cs e h l sh b. ⟦?a1.0 = INIT C' (C # Cs,True) ← e; ?a2.0 = (h, l, sh); ?a3.0 = b; ?a4.0 = RI (C,C∙⇩sclinit([])) ; Cs ← e; ?a5.0 = (h, l, sh); ?a6.0 = b⟧ ⟹ ?Pa; ⋀e s b e' s' b' C Cs e₀. ⟦?a1.0 = RI (C,e) ; Cs ← e₀; ?a2.0 = s; ?a3.0 = b; ?a4.0 = RI (C,e') ; Cs ← e₀; ?a5.0 = s'; ?a6.0 = b'; ?P ⊢ ⟨e,s,b⟩ → ⟨e',s',b'⟩⟧ ⟹ ?Pa; ⋀sh C sfs i sh' C' Cs v e h l b. ⟦?a1.0 = RI (C,Val v) ; Cs ← e; ?a2.0 = (h, l, sh); ?a3.0 = b; ?a4.0 = INIT C' (Cs,True) ← e; ?a5.0 = (h, l, sh'); ?a6.0 = b; sh C = ⌊(sfs, i)⌋; sh' = sh(C ↦ (sfs, Done)); C' = last (C # Cs)⟧ ⟹ ?Pa; ⋀C e s b. ⟦?a1.0 = Cast C (throw e); ?a2.0 = s; ?a3.0 = b; ?a4.0 = throw e; ?a5.0 = s; ?a6.0 = b⟧ ⟹ ?Pa; ⋀e bop e₂ s b. ⟦?a1.0 = throw e «bop» e₂; ?a2.0 = s; ?a3.0 = b; ?a4.0 = throw e; ?a5.0 = s; ?a6.0 = b⟧ ⟹ ?Pa; ⋀v₁ bop e s b. ⟦?a1.0 = Val v₁ «bop» throw e; ?a2.0 = s; ?a3.0 = b; ?a4.0 = throw e; ?a5.0 = s; ?a6.0 = b⟧ ⟹ ?Pa; ⋀V e s b. ⟦?a1.0 = V:=throw e; ?a2.0 = s; ?a3.0 = b; ?a4.0 = throw e; ?a5.0 = s; ?a6.0 = b⟧ ⟹ ?Pa; ⋀e F D s b. ⟦?a1.0 = throw e∙F{D}; ?a2.0 = s; ?a3.0 = b; ?a4.0 = throw e; ?a5.0 = s; ?a6.0 = b⟧ ⟹ ?Pa; ⋀e F D e₂ s b. ⟦?a1.0 = throw e∙F{D} := e₂; ?a2.0 = s; ?a3.0 = b; ?a4.0 = throw e; ?a5.0 = s; ?a6.0 = b⟧ ⟹ ?Pa; ⋀v F D e s b. ⟦?a1.0 = Val v∙F{D} := throw e; ?a2.0 = s; ?a3.0 = b; ?a4.0 = throw e; ?a5.0 = s; ?a6.0 = b⟧ ⟹ ?Pa; ⋀C F D e s b. ⟦?a1.0 = C∙⇩sF{D} := throw e; ?a2.0 = s; ?a3.0 = b; ?a4.0 = throw e; ?a5.0 = s; ?a6.0 = b⟧ ⟹ ?Pa; ⋀e M es s b. ⟦?a1.0 = throw e∙M(es); ?a2.0 = s; ?a3.0 = b; ?a4.0 = throw e; ?a5.0 = s; ?a6.0 = b⟧ ⟹ ?Pa; ⋀es vs e es' v M s b. ⟦?a1.0 = Val v∙M(es); ?a2.0 = s; ?a3.0 = b; ?a4.0 = throw e; ?a5.0 = s; ?a6.0 = b; es = map Val vs @ throw e # es'⟧ ⟹ ?Pa; ⋀es vs e es' C M s b. ⟦?a1.0 = C∙⇩sM(es); ?a2.0 = s; ?a3.0 = b; ?a4.0 = throw e; ?a5.0 = s; ?a6.0 = b; es = map Val vs @ throw e # es'⟧ ⟹ ?Pa; ⋀V T a s b. ⟦?a1.0 = {V:T; Throw a}; ?a2.0 = s; ?a3.0 = b; ?a4.0 = Throw a; ?a5.0 = s; ?a6.0 = b⟧ ⟹ ?Pa; ⋀V T v a s b. ⟦?a1.0 = {V:T; V:=Val v;; Throw a}; ?a2.0 = s; ?a3.0 = b; ?a4.0 = Throw a; ?a5.0 = s; ?a6.0 = b⟧ ⟹ ?Pa; ⋀e e₂ s b. ⟦?a1.0 = throw e;; e₂; ?a2.0 = s; ?a3.0 = b; ?a4.0 = throw e; ?a5.0 = s; ?a6.0 = b⟧ ⟹ ?Pa; ⋀e e₁ e₂ s b. ⟦?a1.0 = if (throw e) e₁ else e₂; ?a2.0 = s; ?a3.0 = b; ?a4.0 = throw e; ?a5.0 = s; ?a6.0 = b⟧ ⟹ ?Pa; ⋀e s b. ⟦?a1.0 = throw (throw e); ?a2.0 = s; ?a3.0 = b; ?a4.0 = throw e; ?a5.0 = s; ?a6.0 = b⟧ ⟹ ?Pa; ⋀sh C sfs i sh' a D Cs e h l b. ⟦?a1.0 = RI (C,Throw a) ; D # Cs ← e; ?a2.0 = (h, l, sh); ?a3.0 = b; ?a4.0 = RI (D,Throw a) ; Cs ← e; ?a5.0 = (h, l, sh'); ?a6.0 = b; sh C = ⌊(sfs, i)⌋; sh' = sh(C ↦ (sfs, Error))⟧ ⟹ ?Pa; ⋀sh C sfs i sh' a e h l b. ⟦?a1.0 = RI (C,Throw a) ; [] ← e; ?a2.0 = (h, l, sh); ?a3.0 = b; ?a4.0 = Throw a; ?a5.0 = (h, l, sh'); ?a6.0 = b; sh C = ⌊(sfs, i)⌋; sh' = sh(C ↦ (sfs, Error))⟧ ⟹ ?Pa⟧ ⟹ ?Pa›*))(*>*) lemma val_no_step: "val_of e = ⌊v⌋ ⟹ ¬ P ⊢ ⟨e,s,b⟩ → ⟨e',s',b'⟩" (*<*)apply (drule val_of_spec (*‹val_of ?e = ⌊?v⌋ ⟹ ?e = Val ?v›*)) (*goal: ‹val_of e = ⌊v⌋ ⟹ ((e, s, b), e', s', b') ∉ red P›*) by simp(*>*) lemma [iff]: "¬ P ⊢ ⟨Throw a,s,b⟩ → ⟨e',s',b'⟩" (*<*)by (fastforce elim: red.cases (*‹⟦?P ⊢ ⟨?a1.0,?a2.0,?a3.0⟩ → ⟨?a4.0,?a5.0,?a6.0⟩; ⋀h a C FDTs h' l sh. ⟦?a1.0 = new C; ?a2.0 = (h, l, sh); ?a3.0 = True; ?a4.0 = addr a; ?a5.0 = (h', l, sh); ?a6.0 = False; new_Addr h = ⌊a⌋; ?P ⊢ C has_fields FDTs; h' = h(a ↦ blank ?P C)⟧ ⟹ ?Pa; ⋀h C l sh. ⟦?a1.0 = new C; ?a2.0 = (h, l, sh); ?a3.0 = True; ?a4.0 = THROW OutOfMemory; ?a5.0 = (h, l, sh); ?a6.0 = False; new_Addr h = None; is_class ?P C⟧ ⟹ ?Pa; ⋀sh C sfs h l. ⟦?a1.0 = new C; ?a2.0 = (h, l, sh); ?a3.0 = False; ?a4.0 = new C; ?a5.0 = (h, l, sh); ?a6.0 = True; sh C = ⌊(sfs, Done)⌋⟧ ⟹ ?Pa; ⋀sh C h l. ⟦?a1.0 = new C; ?a2.0 = (h, l, sh); ?a3.0 = False; ?a4.0 = INIT C ([C],False) ← new C; ?a5.0 = (h, l, sh); ?a6.0 = False; ∄sfs. sh C = ⌊(sfs, Done)⌋; is_class ?P C⟧ ⟹ ?Pa; ⋀e s b e' s' b' C. ⟦?a1.0 = Cast C e; ?a2.0 = s; ?a3.0 = b; ?a4.0 = Cast C e'; ?a5.0 = s'; ?a6.0 = b'; ?P ⊢ ⟨e,s,b⟩ → ⟨e',s',b'⟩⟧ ⟹ ?Pa; ⋀C s b. ⟦?a1.0 = Cast C null; ?a2.0 = s; ?a3.0 = b; ?a4.0 = null; ?a5.0 = s; ?a6.0 = b⟧ ⟹ ?Pa; ⋀h a D fs C l sh b. ⟦?a1.0 = Cast C (addr a); ?a2.0 = (h, l, sh); ?a3.0 = b; ?a4.0 = addr a; ?a5.0 = (h, l, sh); ?a6.0 = b; h a = ⌊(D, fs)⌋; ?P ⊢ D ≼⇧* C⟧ ⟹ ?Pa; ⋀h a D fs C l sh b. ⟦?a1.0 = Cast C (addr a); ?a2.0 = (h, l, sh); ?a3.0 = b; ?a4.0 = THROW ClassCast; ?a5.0 = (h, l, sh); ?a6.0 = b; h a = ⌊(D, fs)⌋; (D, C) ∉ (subcls1 ?P)⇧*⟧ ⟹ ?Pa; ⋀e s b e' s' b' bop e₂. ⟦?a1.0 = e «bop» e₂; ?a2.0 = s; ?a3.0 = b; ?a4.0 = e' «bop» e₂; ?a5.0 = s'; ?a6.0 = b'; ?P ⊢ ⟨e,s,b⟩ → ⟨e',s',b'⟩⟧ ⟹ ?Pa; ⋀e s b e' s' b' v₁ bop. ⟦?a1.0 = Val v₁ «bop» e; ?a2.0 = s; ?a3.0 = b; ?a4.0 = Val v₁ «bop» e'; ?a5.0 = s'; ?a6.0 = b'; ?P ⊢ ⟨e,s,b⟩ → ⟨e',s',b'⟩⟧ ⟹ ?Pa; ⋀bop v₁ v₂ v s b. ⟦?a1.0 = Val v₁ «bop» Val v₂; ?a2.0 = s; ?a3.0 = b; ?a4.0 = Val v; ?a5.0 = s; ?a6.0 = b; binop (bop, v₁, v₂) = ⌊v⌋⟧ ⟹ ?Pa; ⋀l V v h sh b. ⟦?a1.0 = Var V; ?a2.0 = (h, l, sh); ?a3.0 = b; ?a4.0 = Val v; ?a5.0 = (h, l, sh); ?a6.0 = b; l V = ⌊v⌋⟧ ⟹ ?Pa; ⋀e s b e' s' b' V. ⟦?a1.0 = V:=e; ?a2.0 = s; ?a3.0 = b; ?a4.0 = V:=e'; ?a5.0 = s'; ?a6.0 = b'; ?P ⊢ ⟨e,s,b⟩ → ⟨e',s',b'⟩⟧ ⟹ ?Pa; ⋀V v h l sh b. ⟦?a1.0 = V:=Val v; ?a2.0 = (h, l, sh); ?a3.0 = b; ?a4.0 = unit; ?a5.0 = (h, l(V ↦ v), sh); ?a6.0 = b⟧ ⟹ ?Pa; ⋀e s b e' s' b' F D. ⟦?a1.0 = e∙F{D}; ?a2.0 = s; ?a3.0 = b; ?a4.0 = e'∙F{D}; ?a5.0 = s'; ?a6.0 = b'; ?P ⊢ ⟨e,s,b⟩ → ⟨e',s',b'⟩⟧ ⟹ ?Pa; ⋀h a C fs F D v t l sh b. ⟦?a1.0 = addr a∙F{D}; ?a2.0 = (h, l, sh); ?a3.0 = b; ?a4.0 = Val v; ?a5.0 = (h, l, sh); ?a6.0 = b; h a = ⌊(C, fs)⌋; fs (F, D) = ⌊v⌋; ?P ⊢ C has F,NonStatic:t in D⟧ ⟹ ?Pa; ⋀F D s b. ⟦?a1.0 = null∙F{D}; ?a2.0 = s; ?a3.0 = b; ?a4.0 = THROW NullPointer; ?a5.0 = s; ?a6.0 = b⟧ ⟹ ?Pa; ⋀h a C fs F D l sh b. ⟦?a1.0 = addr a∙F{D}; ?a2.0 = (h, l, sh); ?a3.0 = b; ?a4.0 = THROW NoSuchFieldError; ?a5.0 = (h, l, sh); ?a6.0 = b; h a = ⌊(C, fs)⌋; ∄b t. ?P ⊢ C has F,b:t in D⟧ ⟹ ?Pa; ⋀h a C fs F t D l sh b. ⟦?a1.0 = addr a∙F{D}; ?a2.0 = (h, l, sh); ?a3.0 = b; ?a4.0 = THROW IncompatibleClassChangeError; ?a5.0 = (h, l, sh); ?a6.0 = b; h a = ⌊(C, fs)⌋; ?P ⊢ C has F,Static:t in D⟧ ⟹ ?Pa; ⋀C F t D sh sfs i v h l. ⟦?a1.0 = C∙⇩sF{D}; ?a2.0 = (h, l, sh); ?a3.0 = True; ?a4.0 = Val v; ?a5.0 = (h, l, sh); ?a6.0 = False; ?P ⊢ C has F,Static:t in D; sh D = ⌊(sfs, i)⌋; sfs F = ⌊v⌋⟧ ⟹ ?Pa; ⋀C F t D sh sfs h l. ⟦?a1.0 = C∙⇩sF{D}; ?a2.0 = (h, l, sh); ?a3.0 = False; ?a4.0 = C∙⇩sF{D}; ?a5.0 = (h, l, sh); ?a6.0 = True; ?P ⊢ C has F,Static:t in D; sh D = ⌊(sfs, Done)⌋⟧ ⟹ ?Pa; ⋀C F t D sh h l. ⟦?a1.0 = C∙⇩sF{D}; ?a2.0 = (h, l, sh); ?a3.0 = False; ?a4.0 = INIT D ([D],False) ← C∙⇩sF{D}; ?a5.0 = (h, l, sh); ?a6.0 = False; ?P ⊢ C has F,Static:t in D; ∄sfs. sh D = ⌊(sfs, Done)⌋⟧ ⟹ ?Pa; ⋀C F D h l sh b. ⟦?a1.0 = C∙⇩sF{D}; ?a2.0 = (h, l, sh); ?a3.0 = b; ?a4.0 = THROW NoSuchFieldError; ?a5.0 = (h, l, sh); ?a6.0 = False; ∄b t. ?P ⊢ C has F,b:t in D⟧ ⟹ ?Pa; ⋀C F t D h l sh b. ⟦?a1.0 = C∙⇩sF{D}; ?a2.0 = (h, l, sh); ?a3.0 = b; ?a4.0 = THROW IncompatibleClassChangeError; ?a5.0 = (h, l, sh); ?a6.0 = False; ?P ⊢ C has F,NonStatic:t in D⟧ ⟹ ?Pa; ⋀e s b e' s' b' F D e₂. ⟦?a1.0 = e∙F{D} := e₂; ?a2.0 = s; ?a3.0 = b; ?a4.0 = e'∙F{D} := e₂; ?a5.0 = s'; ?a6.0 = b'; ?P ⊢ ⟨e,s,b⟩ → ⟨e',s',b'⟩⟧ ⟹ ?Pa; ⋀e s b e' s' b' v F D. ⟦?a1.0 = Val v∙F{D} := e; ?a2.0 = s; ?a3.0 = b; ?a4.0 = Val v∙F{D} := e'; ?a5.0 = s'; ?a6.0 = b'; ?P ⊢ ⟨e,s,b⟩ → ⟨e',s',b'⟩⟧ ⟹ ?Pa; ⋀C F t D h a fs v l sh b. ⟦?a1.0 = addr a∙F{D} := Val v; ?a2.0 = (h, l, sh); ?a3.0 = b; ?a4.0 = unit; ?a5.0 = (h(a ↦ (C, fs((F, D) ↦ v))), l, sh); ?a6.0 = b; ?P ⊢ C has F,NonStatic:t in D; h a = ⌊(C, fs)⌋⟧ ⟹ ?Pa; ⋀F D v s b. ⟦?a1.0 = null∙F{D} := Val v; ?a2.0 = s; ?a3.0 = b; ?a4.0 = THROW NullPointer; ?a5.0 = s; ?a6.0 = b⟧ ⟹ ?Pa; ⋀h a C fs F D v l sh b. ⟦?a1.0 = addr a∙F{D} := Val v; ?a2.0 = (h, l, sh); ?a3.0 = b; ?a4.0 = THROW NoSuchFieldError; ?a5.0 = (h, l, sh); ?a6.0 = b; h a = ⌊(C, fs)⌋; ∄b t. ?P ⊢ C has F,b:t in D⟧ ⟹ ?Pa; ⋀h a C fs F t D v l sh b. ⟦?a1.0 = addr a∙F{D} := Val v; ?a2.0 = (h, l, sh); ?a3.0 = b; ?a4.0 = THROW IncompatibleClassChangeError; ?a5.0 = (h, l, sh); ?a6.0 = b; h a = ⌊(C, fs)⌋; ?P ⊢ C has F,Static:t in D⟧ ⟹ ?Pa; ⋀e s b e' s' b' C F D. ⟦?a1.0 = C∙⇩sF{D} := e; ?a2.0 = s; ?a3.0 = b; ?a4.0 = C∙⇩sF{D} := e'; ?a5.0 = s'; ?a6.0 = b'; ?P ⊢ ⟨e,s,b⟩ → ⟨e',s',b'⟩⟧ ⟹ ?Pa; ⋀C F t D sh sfs i sfs' v sh' h l. ⟦?a1.0 = C∙⇩sF{D} := Val v; ?a2.0 = (h, l, sh); ?a3.0 = True; ?a4.0 = unit; ?a5.0 = (h, l, sh'); ?a6.0 = False; ?P ⊢ C has F,Static:t in D; sh D = ⌊(sfs, i)⌋; sfs' = sfs(F ↦ v); sh' = sh(D ↦ (sfs', i))⟧ ⟹ ?Pa; ⋀C F t D sh sfs v h l. ⟦?a1.0 = C∙⇩sF{D} := Val v; ?a2.0 = (h, l, sh); ?a3.0 = False; ?a4.0 = C∙⇩sF{D} := Val v; ?a5.0 = (h, l, sh); ?a6.0 = True; ?P ⊢ C has F,Static:t in D; sh D = ⌊(sfs, Done)⌋⟧ ⟹ ?Pa; ⋀C F t D sh v h l. ⟦?a1.0 = C∙⇩sF{D} := Val v; ?a2.0 = (h, l, sh); ?a3.0 = False; ?a4.0 = INIT D ([D],False) ← C∙⇩sF{D} := Val v; ?a5.0 = (h, l, sh); ?a6.0 = False; ?P ⊢ C has F,Static:t in D; ∄sfs. sh D = ⌊(sfs, Done)⌋⟧ ⟹ ?Pa; ⋀C F D v s b. ⟦?a1.0 = C∙⇩sF{D} := Val v; ?a2.0 = s; ?a3.0 = b; ?a4.0 = THROW NoSuchFieldError; ?a5.0 = s; ?a6.0 = False; ∄b t. ?P ⊢ C has F,b:t in D⟧ ⟹ ?Pa; ⋀C F t D v s b. ⟦?a1.0 = C∙⇩sF{D} := Val v; ?a2.0 = s; ?a3.0 = b; ?a4.0 = THROW IncompatibleClassChangeError; ?a5.0 = s; ?a6.0 = False; ?P ⊢ C has F,NonStatic:t in D⟧ ⟹ ?Pa; ⋀e s b e' s' b' M es. ⟦?a1.0 = e∙M(es); ?a2.0 = s; ?a3.0 = b; ?a4.0 = e'∙M(es); ?a5.0 = s'; ?a6.0 = b'; ?P ⊢ ⟨e,s,b⟩ → ⟨e',s',b'⟩⟧ ⟹ ?Pa; ⋀es s b es' s' b' v M. ⟦?a1.0 = Val v∙M(es); ?a2.0 = s; ?a3.0 = b; ?a4.0 = Val v∙M(es'); ?a5.0 = s'; ?a6.0 = b'; ?P ⊢ ⟨es,s,b⟩ [→] ⟨es',s',b'⟩⟧ ⟹ ?Pa; ⋀h a C fs M Ts T pns body D vs l sh b. ⟦?a1.0 = addr a∙M(map Val vs); ?a2.0 = (h, l, sh); ?a3.0 = b; ?a4.0 = blocks (this # pns, Class D # Ts, Addr a # vs, body); ?a5.0 = (h, l, sh); ?a6.0 = b; h a = ⌊(C, fs)⌋; ?P ⊢ C sees M, NonStatic : Ts→T = (pns, body) in D; length vs = length pns; length Ts = length pns⟧ ⟹ ?Pa; ⋀M vs s b. ⟦?a1.0 = null∙M(map Val vs); ?a2.0 = s; ?a3.0 = b; ?a4.0 = THROW NullPointer; ?a5.0 = s; ?a6.0 = b⟧ ⟹ ?Pa; ⋀h a C fs M vs l sh b. ⟦?a1.0 = addr a∙M(map Val vs); ?a2.0 = (h, l, sh); ?a3.0 = b; ?a4.0 = THROW NoSuchMethodError; ?a5.0 = (h, l, sh); ?a6.0 = b; h a = ⌊(C, fs)⌋; ∄b Ts T m D. ?P ⊢ C sees M, b : Ts→T = m in D⟧ ⟹ ?Pa; ⋀h a C fs M Ts T m D vs l sh b. ⟦?a1.0 = addr a∙M(map Val vs); ?a2.0 = (h, l, sh); ?a3.0 = b; ?a4.0 = THROW IncompatibleClassChangeError; ?a5.0 = (h, l, sh); ?a6.0 = b; h a = ⌊(C, fs)⌋; ?P ⊢ C sees M, Static : Ts→T = m in D⟧ ⟹ ?Pa; ⋀es s b es' s' b' C M. ⟦?a1.0 = C∙⇩sM(es); ?a2.0 = s; ?a3.0 = b; ?a4.0 = C∙⇩sM(es'); ?a5.0 = s'; ?a6.0 = b'; ?P ⊢ ⟨es,s,b⟩ [→] ⟨es',s',b'⟩⟧ ⟹ ?Pa; ⋀C M Ts T pns body D vs s. ⟦?a1.0 = C∙⇩sM(map Val vs); ?a2.0 = s; ?a3.0 = True; ?a4.0 = blocks (pns, Ts, vs, body); ?a5.0 = s; ?a6.0 = False; ?P ⊢ C sees M, Static : Ts→T = (pns, body) in D; length vs = length pns; length Ts = length pns⟧ ⟹ ?Pa; ⋀C M Ts T pns body D sh sfs vs h l. ⟦?a1.0 = C∙⇩sM(map Val vs); ?a2.0 = (h, l, sh); ?a3.0 = False; ?a4.0 = C∙⇩sM(map Val vs); ?a5.0 = (h, l, sh); ?a6.0 = True; ?P ⊢ C sees M, Static : Ts→T = (pns, body) in D; sh D = ⌊(sfs, Done)⌋ ∨ M = clinit ∧ sh D = ⌊(sfs, Processing)⌋⟧ ⟹ ?Pa; ⋀C M Ts T pns body D sh vs h l. ⟦?a1.0 = C∙⇩sM(map Val vs); ?a2.0 = (h, l, sh); ?a3.0 = False; ?a4.0 = INIT D ([D],False) ← C∙⇩sM(map Val vs); ?a5.0 = (h, l, sh); ?a6.0 = False; ?P ⊢ C sees M, Static : Ts→T = (pns, body) in D; ∄sfs. sh D = ⌊(sfs, Done)⌋; M ≠ clinit⟧ ⟹ ?Pa; ⋀C M vs s b. ⟦?a1.0 = C∙⇩sM(map Val vs); ?a2.0 = s; ?a3.0 = b; ?a4.0 = THROW NoSuchMethodError; ?a5.0 = s; ?a6.0 = False; ∄b Ts T m D. ?P ⊢ C sees M, b : Ts→T = m in D⟧ ⟹ ?Pa; ⋀C M Ts T m D vs s b. ⟦?a1.0 = C∙⇩sM(map Val vs); ?a2.0 = s; ?a3.0 = b; ?a4.0 = THROW IncompatibleClassChangeError; ?a5.0 = s; ?a6.0 = False; ?P ⊢ C sees M, NonStatic : Ts→T = m in D⟧ ⟹ ?Pa; ⋀e h l V sh b e' h' l' sh' b' T. ⟦?a1.0 = {V:T; e}; ?a2.0 = (h, l, sh); ?a3.0 = b; ?a4.0 = {V:T; e'}; ?a5.0 = (h', l'(V := l V), sh'); ?a6.0 = b'; ?P ⊢ ⟨e,(h, l(V := None), sh),b⟩ → ⟨e',(h', l', sh'),b'⟩; l' V = None; ¬ assigned V e⟧ ⟹ ?Pa; ⋀e h l V sh b e' h' l' sh' b' v T. ⟦?a1.0 = {V:T; e}; ?a2.0 = (h, l, sh); ?a3.0 = b; ?a4.0 = {V:T; V:=Val v;; e'}; ?a5.0 = (h', l'(V := l V), sh'); ?a6.0 = b'; ?P ⊢ ⟨e,(h, l(V := None), sh),b⟩ → ⟨e',(h', l', sh'),b'⟩; l' V = ⌊v⌋; ¬ assigned V e⟧ ⟹ ?Pa; ⋀e h l V v sh b e' h' l' sh' b' v' T. ⟦?a1.0 = {V:T; V:=Val v;; e}; ?a2.0 = (h, l, sh); ?a3.0 = b; ?a4.0 = {V:T; V:=Val v';; e'}; ?a5.0 = (h', l'(V := l V), sh'); ?a6.0 = b'; ?P ⊢ ⟨e,(h, l(V ↦ v), sh),b⟩ → ⟨e',(h', l', sh'),b'⟩; l' V = ⌊v'⌋⟧ ⟹ ?Pa; ⋀V T u s b. ⟦?a1.0 = {V:T; Val u}; ?a2.0 = s; ?a3.0 = b; ?a4.0 = Val u; ?a5.0 = s; ?a6.0 = b⟧ ⟹ ?Pa; ⋀V T v u s b. ⟦?a1.0 = {V:T; V:=Val v;; Val u}; ?a2.0 = s; ?a3.0 = b; ?a4.0 = Val u; ?a5.0 = s; ?a6.0 = b⟧ ⟹ ?Pa; ⋀e s b e' s' b' e₂. ⟦?a1.0 = e;; e₂; ?a2.0 = s; ?a3.0 = b; ?a4.0 = e';; e₂; ?a5.0 = s'; ?a6.0 = b'; ?P ⊢ ⟨e,s,b⟩ → ⟨e',s',b'⟩⟧ ⟹ ?Pa; ⋀v e₂ s b. ⟦?a1.0 = Val v;; e₂; ?a2.0 = s; ?a3.0 = b; ?a4.0 = e₂; ?a5.0 = s; ?a6.0 = b⟧ ⟹ ?Pa; ⋀e s b e' s' b' e₁ e₂. ⟦?a1.0 = if (e) e₁ else e₂; ?a2.0 = s; ?a3.0 = b; ?a4.0 = if (e') e₁ else e₂; ?a5.0 = s'; ?a6.0 = b'; ?P ⊢ ⟨e,s,b⟩ → ⟨e',s',b'⟩⟧ ⟹ ?Pa; ⋀e₁ e₂ s b. ⟦?a1.0 = if (true) e₁ else e₂; ?a2.0 = s; ?a3.0 = b; ?a4.0 = e₁; ?a5.0 = s; ?a6.0 = b⟧ ⟹ ?Pa; ⋀e₁ e₂ s b. ⟦?a1.0 = if (false) e₁ else e₂; ?a2.0 = s; ?a3.0 = b; ?a4.0 = e₂; ?a5.0 = s; ?a6.0 = b⟧ ⟹ ?Pa; ⋀b c s b'. ⟦?a1.0 = while (b) c; ?a2.0 = s; ?a3.0 = b'; ?a4.0 = if (b) (c;; while (b) c) else unit; ?a5.0 = s; ?a6.0 = b'⟧ ⟹ ?Pa; ⋀e s b e' s' b'. ⟦?a1.0 = throw e; ?a2.0 = s; ?a3.0 = b; ?a4.0 = throw e'; ?a5.0 = s'; ?a6.0 = b'; ?P ⊢ ⟨e,s,b⟩ → ⟨e',s',b'⟩⟧ ⟹ ?Pa; ⋀s b. ⟦?a1.0 = throw null; ?a2.0 = s; ?a3.0 = b; ?a4.0 = THROW NullPointer; ?a5.0 = s; ?a6.0 = b⟧ ⟹ ?Pa; ⋀e s b e' s' b' C V e₂. ⟦?a1.0 = try e catch(C V) e₂; ?a2.0 = s; ?a3.0 = b; ?a4.0 = try e' catch(C V) e₂; ?a5.0 = s'; ?a6.0 = b'; ?P ⊢ ⟨e,s,b⟩ → ⟨e',s',b'⟩⟧ ⟹ ?Pa; ⋀v C V e₂ s b. ⟦?a1.0 = try Val v catch(C V) e₂; ?a2.0 = s; ?a3.0 = b; ?a4.0 = Val v; ?a5.0 = s; ?a6.0 = b⟧ ⟹ ?Pa; ⋀s a D fs C V e₂ b. ⟦?a1.0 = try Throw a catch(C V) e₂; ?a2.0 = s; ?a3.0 = b; ?a4.0 = {V:Class C; V:=addr a;; e₂}; ?a5.0 = s; ?a6.0 = b; hp s a = ⌊(D, fs)⌋; ?P ⊢ D ≼⇧* C⟧ ⟹ ?Pa; ⋀s a D fs C V e₂ b. ⟦?a1.0 = try Throw a catch(C V) e₂; ?a2.0 = s; ?a3.0 = b; ?a4.0 = Throw a; ?a5.0 = s; ?a6.0 = b; hp s a = ⌊(D, fs)⌋; (D, C) ∉ (subcls1 ?P)⇧*⟧ ⟹ ?Pa; ⋀e C b s b'. ⟦?a1.0 = INIT C ([],b) ← e; ?a2.0 = s; ?a3.0 = b'; ?a4.0 = e; ?a5.0 = s; ?a6.0 = icheck ?P C e; ¬ sub_RI e⟧ ⟹ ?Pa; ⋀sh C C' Cs e h l b. ⟦?a1.0 = INIT C' (C # Cs,False) ← e; ?a2.0 = (h, l, sh); ?a3.0 = b; ?a4.0 = INIT C' (C # Cs,False) ← e; ?a5.0 = (h, l, sh(C ↦ (sblank ?P C, Prepared))); ?a6.0 = b; sh C = None⟧ ⟹ ?Pa; ⋀sh C sfs C' Cs e h l b. ⟦?a1.0 = INIT C' (C # Cs,False) ← e; ?a2.0 = (h, l, sh); ?a3.0 = b; ?a4.0 = INIT C' (Cs,True) ← e; ?a5.0 = (h, l, sh); ?a6.0 = b; sh C = ⌊(sfs, Done)⌋⟧ ⟹ ?Pa; ⋀sh C sfs C' Cs e h l b. ⟦?a1.0 = INIT C' (C # Cs,False) ← e; ?a2.0 = (h, l, sh); ?a3.0 = b; ?a4.0 = INIT C' (Cs,True) ← e; ?a5.0 = (h, l, sh); ?a6.0 = b; sh C = ⌊(sfs, Processing)⌋⟧ ⟹ ?Pa; ⋀sh C sfs C' Cs e h l b. ⟦?a1.0 = INIT C' (C # Cs,False) ← e; ?a2.0 = (h, l, sh); ?a3.0 = b; ?a4.0 = RI (C,THROW NoClassDefFoundError) ; Cs ← e; ?a5.0 = (h, l, sh); ?a6.0 = b; sh C = ⌊(sfs, Error)⌋⟧ ⟹ ?Pa; ⋀sh C sfs sh' C' Cs e h l b. ⟦?a1.0 = INIT C' (C # Cs,False) ← e; ?a2.0 = (h, l, sh); ?a3.0 = b; ?a4.0 = INIT C' (C # Cs,True) ← e; ?a5.0 = (h, l, sh'); ?a6.0 = b; sh C = ⌊(sfs, Prepared)⌋; C = Object; sh' = sh(C ↦ (sfs, Processing))⟧ ⟹ ?Pa; ⋀sh C sfs D r sh' C' Cs e h l b. ⟦?a1.0 = INIT C' (C # Cs,False) ← e; ?a2.0 = (h, l, sh); ?a3.0 = b; ?a4.0 = INIT C' (D # C # Cs,False) ← e; ?a5.0 = (h, l, sh'); ?a6.0 = b; sh C = ⌊(sfs, Prepared)⌋; C ≠ Object; class ?P C = ⌊(D, r)⌋; sh' = sh(C ↦ (sfs, Processing))⟧ ⟹ ?Pa; ⋀C' C Cs e h l sh b. ⟦?a1.0 = INIT C' (C # Cs,True) ← e; ?a2.0 = (h, l, sh); ?a3.0 = b; ?a4.0 = RI (C,C∙⇩sclinit([])) ; Cs ← e; ?a5.0 = (h, l, sh); ?a6.0 = b⟧ ⟹ ?Pa; ⋀e s b e' s' b' C Cs e₀. ⟦?a1.0 = RI (C,e) ; Cs ← e₀; ?a2.0 = s; ?a3.0 = b; ?a4.0 = RI (C,e') ; Cs ← e₀; ?a5.0 = s'; ?a6.0 = b'; ?P ⊢ ⟨e,s,b⟩ → ⟨e',s',b'⟩⟧ ⟹ ?Pa; ⋀sh C sfs i sh' C' Cs v e h l b. ⟦?a1.0 = RI (C,Val v) ; Cs ← e; ?a2.0 = (h, l, sh); ?a3.0 = b; ?a4.0 = INIT C' (Cs,True) ← e; ?a5.0 = (h, l, sh'); ?a6.0 = b; sh C = ⌊(sfs, i)⌋; sh' = sh(C ↦ (sfs, Done)); C' = last (C # Cs)⟧ ⟹ ?Pa; ⋀C e s b. ⟦?a1.0 = Cast C (throw e); ?a2.0 = s; ?a3.0 = b; ?a4.0 = throw e; ?a5.0 = s; ?a6.0 = b⟧ ⟹ ?Pa; ⋀e bop e₂ s b. ⟦?a1.0 = throw e «bop» e₂; ?a2.0 = s; ?a3.0 = b; ?a4.0 = throw e; ?a5.0 = s; ?a6.0 = b⟧ ⟹ ?Pa; ⋀v₁ bop e s b. ⟦?a1.0 = Val v₁ «bop» throw e; ?a2.0 = s; ?a3.0 = b; ?a4.0 = throw e; ?a5.0 = s; ?a6.0 = b⟧ ⟹ ?Pa; ⋀V e s b. ⟦?a1.0 = V:=throw e; ?a2.0 = s; ?a3.0 = b; ?a4.0 = throw e; ?a5.0 = s; ?a6.0 = b⟧ ⟹ ?Pa; ⋀e F D s b. ⟦?a1.0 = throw e∙F{D}; ?a2.0 = s; ?a3.0 = b; ?a4.0 = throw e; ?a5.0 = s; ?a6.0 = b⟧ ⟹ ?Pa; ⋀e F D e₂ s b. ⟦?a1.0 = throw e∙F{D} := e₂; ?a2.0 = s; ?a3.0 = b; ?a4.0 = throw e; ?a5.0 = s; ?a6.0 = b⟧ ⟹ ?Pa; ⋀v F D e s b. ⟦?a1.0 = Val v∙F{D} := throw e; ?a2.0 = s; ?a3.0 = b; ?a4.0 = throw e; ?a5.0 = s; ?a6.0 = b⟧ ⟹ ?Pa; ⋀C F D e s b. ⟦?a1.0 = C∙⇩sF{D} := throw e; ?a2.0 = s; ?a3.0 = b; ?a4.0 = throw e; ?a5.0 = s; ?a6.0 = b⟧ ⟹ ?Pa; ⋀e M es s b. ⟦?a1.0 = throw e∙M(es); ?a2.0 = s; ?a3.0 = b; ?a4.0 = throw e; ?a5.0 = s; ?a6.0 = b⟧ ⟹ ?Pa; ⋀es vs e es' v M s b. ⟦?a1.0 = Val v∙M(es); ?a2.0 = s; ?a3.0 = b; ?a4.0 = throw e; ?a5.0 = s; ?a6.0 = b; es = map Val vs @ throw e # es'⟧ ⟹ ?Pa; ⋀es vs e es' C M s b. ⟦?a1.0 = C∙⇩sM(es); ?a2.0 = s; ?a3.0 = b; ?a4.0 = throw e; ?a5.0 = s; ?a6.0 = b; es = map Val vs @ throw e # es'⟧ ⟹ ?Pa; ⋀V T a s b. ⟦?a1.0 = {V:T; Throw a}; ?a2.0 = s; ?a3.0 = b; ?a4.0 = Throw a; ?a5.0 = s; ?a6.0 = b⟧ ⟹ ?Pa; ⋀V T v a s b. ⟦?a1.0 = {V:T; V:=Val v;; Throw a}; ?a2.0 = s; ?a3.0 = b; ?a4.0 = Throw a; ?a5.0 = s; ?a6.0 = b⟧ ⟹ ?Pa; ⋀e e₂ s b. ⟦?a1.0 = throw e;; e₂; ?a2.0 = s; ?a3.0 = b; ?a4.0 = throw e; ?a5.0 = s; ?a6.0 = b⟧ ⟹ ?Pa; ⋀e e₁ e₂ s b. ⟦?a1.0 = if (throw e) e₁ else e₂; ?a2.0 = s; ?a3.0 = b; ?a4.0 = throw e; ?a5.0 = s; ?a6.0 = b⟧ ⟹ ?Pa; ⋀e s b. ⟦?a1.0 = throw (throw e); ?a2.0 = s; ?a3.0 = b; ?a4.0 = throw e; ?a5.0 = s; ?a6.0 = b⟧ ⟹ ?Pa; ⋀sh C sfs i sh' a D Cs e h l b. ⟦?a1.0 = RI (C,Throw a) ; D # Cs ← e; ?a2.0 = (h, l, sh); ?a3.0 = b; ?a4.0 = RI (D,Throw a) ; Cs ← e; ?a5.0 = (h, l, sh'); ?a6.0 = b; sh C = ⌊(sfs, i)⌋; sh' = sh(C ↦ (sfs, Error))⟧ ⟹ ?Pa; ⋀sh C sfs i sh' a e h l b. ⟦?a1.0 = RI (C,Throw a) ; [] ← e; ?a2.0 = (h, l, sh); ?a3.0 = b; ?a4.0 = Throw a; ?a5.0 = (h, l, sh'); ?a6.0 = b; sh C = ⌊(sfs, i)⌋; sh' = sh(C ↦ (sfs, Error))⟧ ⟹ ?Pa⟧ ⟹ ?Pa›*))(*>*) lemma map_Vals_no_step [iff]: "¬ P ⊢ ⟨map Val vs,s,b⟩ [→] ⟨es',s',b'⟩" (*<*) proof (induct vs arbitrary: es') (*goals: 1. ‹⋀es'. ((map Val [], s, b), es', s', b') ∉ reds P› 2. ‹⋀a vs es'. (⋀es'. ((map Val vs, s, b), es', s', b') ∉ reds P) ⟹ ((map Val (a # vs), s, b), es', s', b') ∉ reds P›*) case (Cons a vs) (*‹((map Val (vs::val list), s::heap × sfields × sheap, b::bool), ?es'::char list exp list, s'::heap × sfields × sheap, b'::bool) ∉ reds (P::(char list list × char list exp) prog)›*) { assume "P ⊢ ⟨map Val (a # vs),s,b⟩ [→] ⟨es',s',b'⟩" (*‹(P::(char list list × char list exp) prog) ⊢ ⟨map Val ((a::val) # (vs::val list)),s::heap × sfields × sheap,b::bool⟩ [→] ⟨es'::char list exp list,s'::heap × sfields × sheap,b'::bool⟩›*) then have False apply (rule reds.cases (*‹⟦?P ⊢ ⟨?a1.0,?a2.0,?a3.0⟩ [→] ⟨?a4.0,?a5.0,?a6.0⟩; ⋀e s b e' s' b' es. ⟦?a1.0 = e # es; ?a2.0 = s; ?a3.0 = b; ?a4.0 = e' # es; ?a5.0 = s'; ?a6.0 = b'; ?P ⊢ ⟨e,s,b⟩ → ⟨e',s',b'⟩⟧ ⟹ ?Pa; ⋀es s b es' s' b' v. ⟦?a1.0 = Val v # es; ?a2.0 = s; ?a3.0 = b; ?a4.0 = Val v # es'; ?a5.0 = s'; ?a6.0 = b'; ?P ⊢ ⟨es,s,b⟩ [→] ⟨es',s',b'⟩⟧ ⟹ ?Pa⟧ ⟹ ?Pa›*)) (*goals: 1. ‹⋀e sa ba e' s'a b'a es. ⟦map Val (a # vs) = e # es; s = sa; b = ba; es' = e' # es; s' = s'a; b' = b'a; P ⊢ ⟨e,sa,ba⟩ → ⟨e',s'a,b'a⟩⟧ ⟹ False› 2. ‹⋀es sa ba es' s'a b'a v. ⟦map Val (a # vs) = Val v # es; s = sa; b = ba; es' = Val v # es'; s' = s'a; b' = b'a; P ⊢ ⟨es,sa,ba⟩ [→] ⟨es',s'a,b'a⟩⟧ ⟹ False› discuss goal 1*) apply ((insert Cons (*‹((map Val vs, s, b), ?es', s', b') ∉ reds P›*))[1]) (*top goal: ‹⋀e sa ba e' s'a b'a es. ⟦map Val (a # vs) = e # es; s = sa; b = ba; es' = e' # es; s' = s'a; b' = b'a; P ⊢ ⟨e,sa,ba⟩ → ⟨e',s'a,b'a⟩⟧ ⟹ False› and 1 goal remains*) apply ((auto)[1]) (*discuss goal 2*) apply ((insert Cons (*‹((map Val (vs::val list), s::heap × sfields × sheap, b::bool), ?es'::char list exp list, s'::heap × sfields × sheap, b'::bool) ∉ reds (P::(char list list × char list exp) prog)›*))[1]) (*goal: ‹⋀(es::char list exp list) (sa::heap × sfields × sheap) (ba::bool) (es'::char list exp list) (s'a::heap × sfields × sheap) (b'a::bool) v::val. ⟦map Val ((a::val) # (vs::val list)) = Val v # es; (s::heap × sfields × sheap) = sa; (b::bool) = ba; (es'::char list exp list) = Val v # es'; (s'::heap × sfields × sheap) = s'a; (b'::bool) = b'a; (P::(char list list × char list exp) prog) ⊢ ⟨es,sa,ba⟩ [→] ⟨es',s'a,b'a⟩⟧ ⟹ False›*) apply ((auto)[1]) (*proven 2 subgoals*) . } then show "?case" (*goal: ‹((map Val (a # vs), s, b), es', s', b') ∉ reds P›*) by clarsimp qed (simp) (*solved the remaining goal: ‹⋀es'. ((map Val [], s, b), es', s', b') ∉ reds P›*) (*>*) lemma vals_no_step: "map_vals_of es = ⌊vs⌋ ⟹ ¬ P ⊢ ⟨es,s,b⟩ [→] ⟨es',s',b'⟩" (*<*)apply (drule map_vals_of_spec (*‹map_vals_of ?es = ⌊?vs⌋ ⟹ ?es = map Val ?vs›*)) (*goal: ‹map_vals_of es = ⌊vs⌋ ⟹ ((es, s, b), es', s', b') ∉ reds P›*) by simp(*>*) lemma vals_throw_no_step [iff]: "¬ P ⊢ ⟨map Val vs @ Throw a # es,s,b⟩ [→] ⟨es',s',b'⟩" (*<*) proof (induct vs arbitrary: es') (*goals: 1. ‹⋀es'::char list exp list. ((map Val [] @ Throw (a::nat) # (es::char list exp list), s::heap × sfields × sheap, b::bool), es', s'::heap × sfields × sheap, b'::bool) ∉ reds (P::(char list list × char list exp) prog)› 2. ‹⋀(aa::val) (vs::val list) es'::char list exp list. (⋀es'::char list exp list. ((map Val vs @ Throw (a::nat) # (es::char list exp list), s::heap × sfields × sheap, b::bool), es', s'::heap × sfields × sheap, b'::bool) ∉ reds (P::(char list list × char list exp) prog)) ⟹ ((map Val (aa # vs) @ Throw a # es, s, b), es', s', b') ∉ reds P›*) case Nil (*no hyothesis introduced yet*) { assume "P ⊢ ⟨Throw a # es,s,b⟩ [→] ⟨es',s',b'⟩" (*‹(P::(char list list × char list exp) prog) ⊢ ⟨Throw (a::nat) # (es::char list exp list),s::heap × sfields × sheap,b::bool⟩ [→] ⟨es'::char list exp list,s'::heap × sfields × sheap,b'::bool⟩›*) then have False apply (rule reds.cases (*‹⟦?P ⊢ ⟨?a1.0,?a2.0,?a3.0⟩ [→] ⟨?a4.0,?a5.0,?a6.0⟩; ⋀e s b e' s' b' es. ⟦?a1.0 = e # es; ?a2.0 = s; ?a3.0 = b; ?a4.0 = e' # es; ?a5.0 = s'; ?a6.0 = b'; ?P ⊢ ⟨e,s,b⟩ → ⟨e',s',b'⟩⟧ ⟹ ?Pa; ⋀es s b es' s' b' v. ⟦?a1.0 = Val v # es; ?a2.0 = s; ?a3.0 = b; ?a4.0 = Val v # es'; ?a5.0 = s'; ?a6.0 = b'; ?P ⊢ ⟨es,s,b⟩ [→] ⟨es',s',b'⟩⟧ ⟹ ?Pa⟧ ⟹ ?Pa›*)) (*goals: 1. ‹⋀e sa ba e' s'a b'a esa. ⟦Throw a # es = e # esa; s = sa; b = ba; es' = e' # esa; s' = s'a; b' = b'a; P ⊢ ⟨e,sa,ba⟩ → ⟨e',s'a,b'a⟩⟧ ⟹ False› 2. ‹⋀esa sa ba es' s'a b'a v. ⟦Throw a # es = Val v # esa; s = sa; b = ba; es' = Val v # es'; s' = s'a; b' = b'a; P ⊢ ⟨esa,sa,ba⟩ [→] ⟨es',s'a,b'a⟩⟧ ⟹ False› discuss goal 1*) apply ((insert Cons (*‹⟦(?x, ?y) ∈ ?r; (?xs, ?ys) ∈ listrel ?r⟧ ⟹ (?x # ?xs, ?y # ?ys) ∈ listrel ?r›*))[1]) (*top goal: ‹⋀e sa ba e' s'a b'a esa. ⟦Throw a # es = e # esa; s = sa; b = ba; es' = e' # esa; s' = s'a; b' = b'a; P ⊢ ⟨e,sa,ba⟩ → ⟨e',s'a,b'a⟩⟧ ⟹ False› and 1 goal remains*) apply ((auto)[1]) (*discuss goal 2*) apply ((insert Cons (*‹⟦(?x, ?y) ∈ ?r; (?xs, ?ys) ∈ listrel ?r⟧ ⟹ (?x # ?xs, ?y # ?ys) ∈ listrel ?r›*))[1]) (*goal: ‹⋀esa sa ba es' s'a b'a v. ⟦Throw a # es = Val v # esa; s = sa; b = ba; es' = Val v # es'; s' = s'a; b' = b'a; P ⊢ ⟨esa,sa,ba⟩ [→] ⟨es',s'a,b'a⟩⟧ ⟹ False›*) apply ((auto)[1]) (*proven 2 subgoals*) . } then show "?case" (*goal: ‹((map Val [] @ Throw a # es, s, b), es', s', b') ∉ reds P›*) by clarsimp next (*goal: ‹⋀(aa::val) (vs::val list) es'::char list exp list. (⋀es'::char list exp list. ((map Val vs @ Throw (a::nat) # (es::char list exp list), s::heap × sfields × sheap, b::bool), es', s'::heap × sfields × sheap, b'::bool) ∉ reds (P::(char list list × char list exp) prog)) ⟹ ((map Val (aa # vs) @ Throw a # es, s, b), es', s', b') ∉ reds P›*) case (Cons a' vs') (*‹((map Val vs' @ Throw a # es, s, b), ?es', s', b') ∉ reds P›*) { assume "P ⊢ ⟨map Val (a'#vs') @ Throw a # es,s,b⟩ [→] ⟨es',s',b'⟩" (*‹(P::(char list list × char list exp) prog) ⊢ ⟨map Val ((a'::val) # (vs'::val list)) @ Throw (a::nat) # (es::char list exp list),s::heap × sfields × sheap,b::bool⟩ [→] ⟨es'::char list exp list,s'::heap × sfields × sheap,b'::bool⟩›*) then have False apply (rule reds.cases (*‹⟦?P ⊢ ⟨?a1.0,?a2.0,?a3.0⟩ [→] ⟨?a4.0,?a5.0,?a6.0⟩; ⋀e s b e' s' b' es. ⟦?a1.0 = e # es; ?a2.0 = s; ?a3.0 = b; ?a4.0 = e' # es; ?a5.0 = s'; ?a6.0 = b'; ?P ⊢ ⟨e,s,b⟩ → ⟨e',s',b'⟩⟧ ⟹ ?Pa; ⋀es s b es' s' b' v. ⟦?a1.0 = Val v # es; ?a2.0 = s; ?a3.0 = b; ?a4.0 = Val v # es'; ?a5.0 = s'; ?a6.0 = b'; ?P ⊢ ⟨es,s,b⟩ [→] ⟨es',s',b'⟩⟧ ⟹ ?Pa⟧ ⟹ ?Pa›*)) (*goals: 1. ‹⋀e sa ba e' s'a b'a esa. ⟦map Val (a' # vs') @ Throw a # es = e # esa; s = sa; b = ba; es' = e' # esa; s' = s'a; b' = b'a; P ⊢ ⟨e,sa,ba⟩ → ⟨e',s'a,b'a⟩⟧ ⟹ False› 2. ‹⋀esa sa ba es' s'a b'a v. ⟦map Val (a' # vs') @ Throw a # es = Val v # esa; s = sa; b = ba; es' = Val v # es'; s' = s'a; b' = b'a; P ⊢ ⟨esa,sa,ba⟩ [→] ⟨es',s'a,b'a⟩⟧ ⟹ False› discuss goal 1*) apply ((insert Cons (*‹((map Val vs' @ Throw a # es, s, b), ?es', s', b') ∉ reds P›*))[1]) (*top goal: ‹⋀e sa ba e' s'a b'a esa. ⟦map Val (a' # vs') @ Throw a # es = e # esa; s = sa; b = ba; es' = e' # esa; s' = s'a; b' = b'a; P ⊢ ⟨e,sa,ba⟩ → ⟨e',s'a,b'a⟩⟧ ⟹ False› and 1 goal remains*) apply ((auto)[1]) (*discuss goal 2*) apply ((insert Cons (*‹((map Val vs' @ Throw a # es, s, b), ?es', s', b') ∉ reds P›*))[1]) (*goal: ‹⋀esa sa ba es' s'a b'a v. ⟦map Val (a' # vs') @ Throw a # es = Val v # esa; s = sa; b = ba; es' = Val v # es'; s' = s'a; b' = b'a; P ⊢ ⟨esa,sa,ba⟩ [→] ⟨es',s'a,b'a⟩⟧ ⟹ False›*) apply ((auto)[1]) (*proven 2 subgoals*) . } then show "?case" (*goal: ‹((map Val (a' # vs') @ Throw a # es, s, b), es', s', b') ∉ reds P›*) by clarsimp qed (*>*) lemma lass_val_of_red: "⟦ lass_val_of e = ⌊a⌋; P ⊢ ⟨e,(h, l, sh),b⟩ → ⟨e',(h', l', sh'),b'⟩ ⟧ ⟹ e' = unit ∧ h' = h ∧ l' = l(fst a↦snd a) ∧ sh' = sh ∧ b = b'" (*<*)apply (drule lass_val_of_spec (*‹lass_val_of ?e = ⌊?a⌋ ⟹ ?e = fst ?a:=Val (snd ?a)›*)) (*goal: ‹⟦lass_val_of e = ⌊a⌋; P ⊢ ⟨e,(h, l, sh),b⟩ → ⟨e',(h', l', sh'),b'⟩⟧ ⟹ e' = unit ∧ h' = h ∧ l' = l(fst a ↦ snd a) ∧ sh' = sh ∧ b = b'›*) by auto(*>*) lemma final_no_step [iff]: "final e ⟹ ¬ P ⊢ ⟨e,s,b⟩ → ⟨e',s',b'⟩" (*<*)apply (erule finalE (*‹⟦final ?e; ⋀v. ?e = Val v ⟹ ?R; ⋀a. ?e = Throw a ⟹ ?R⟧ ⟹ ?R›*)) (*goals: 1. ‹⋀v. e = Val v ⟹ ((e, s, b), e', s', b') ∉ red P› 2. ‹⋀a. e = Throw a ⟹ ((e, s, b), e', s', b') ∉ red P› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) .(*>*) lemma finals_no_step [iff]: "finals es ⟹ ¬ P ⊢ ⟨es,s,b⟩ [→] ⟨es',s',b'⟩" (*<*)apply (erule finalsE (*‹⟦finals ?es; ⋀vs. ?es = map Val vs ⟹ ?R; ⋀vs a es'. ?es = map Val vs @ Throw a # es' ⟹ ?R⟧ ⟹ ?R›*)) (*goals: 1. ‹⋀vs. es = map Val vs ⟹ ((es, s, b), es', s', b') ∉ reds P› 2. ‹⋀vs a es'a. es = map Val vs @ Throw a # es'a ⟹ ((es, s, b), es', s', b') ∉ reds P› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) .(*>*) lemma reds_final_same: "P ⊢ ⟨e,s,b⟩ →* ⟨e',s',b'⟩ ⟹ final e ⟹ e = e' ∧ s = s' ∧ b = b'" proof (induct rule:converse_rtrancl_induct3 (*‹⟦((?ax::?'a::type, ?ay::?'b::type, ?az::?'c::type), ?bx::?'a::type, ?by::?'b::type, ?bz::?'c::type) ∈ (?r::((?'a::type × ?'b::type × ?'c::type) × ?'a::type × ?'b::type × ?'c::type) set)⇧*; (?P::?'a::type ⇒ ?'b::type ⇒ ?'c::type ⇒ bool) ?bx ?by ?bz; ⋀(a::?'a::type) (aa::?'b::type) (b::?'c::type) (ab::?'a::type) (ac::?'b::type) ba::?'c::type. ⟦((a, aa, b), ab, ac, ba) ∈ ?r; ((ab, ac, ba), ?bx, ?by, ?bz) ∈ ?r⇧*; ?P ab ac ba⟧ ⟹ ?P a aa b⟧ ⟹ ?P ?ax ?ay ?az›*)) (*goals: 1. ‹final (e'::char list exp) ⟹ e' = e' ∧ (s'::heap × sfields × sheap) = s' ∧ (b'::bool) = b'› 2. ‹⋀(a::char list exp) (aa::heap × sfields × sheap) (b::bool) (ab::char list exp) (ac::heap × sfields × sheap) ba::bool. ⟦(P::(char list list × char list exp) prog) ⊢ ⟨a,aa,b⟩ → ⟨ab,ac,ba⟩; P ⊢ ⟨ab,ac,ba⟩ →* ⟨e'::char list exp,s'::heap × sfields × sheap,b'::bool⟩; final ab ⟹ ab = e' ∧ ac = s' ∧ ba = b'; final a⟧ ⟹ a = e' ∧ aa = s' ∧ b = b'›*) case refl (*‹final (e'::char list exp)›*) show "?case" (*goal: ‹e' = e' ∧ s' = s' ∧ b' = b'›*) by simp next (*goal: ‹⋀a aa b ab ac ba. ⟦P ⊢ ⟨a,aa,b⟩ → ⟨ab,ac,ba⟩; P ⊢ ⟨ab,ac,ba⟩ →* ⟨e',s',b'⟩; final ab ⟹ ab = e' ∧ ac = s' ∧ ba = b'; final a⟧ ⟹ a = e' ∧ aa = s' ∧ b = b'›*) case (step e0 s0 b0 e1 s1 b1) (*‹P ⊢ ⟨e0,s0,b0⟩ → ⟨e1,s1,b1⟩› ‹P ⊢ ⟨e1,s1,b1⟩ →* ⟨e',s',b'⟩› ‹final e1 ⟹ e1 = e' ∧ s1 = s' ∧ b1 = b'› ‹final e0›*) show "?case" (*goal: ‹e0 = e' ∧ s0 = s' ∧ b0 = b'›*) proof (rule finalE[OF step.prems(1)] (*‹⟦⋀v::val. (e0::char list exp) = Val v ⟹ ?R::bool; ⋀a::nat. e0 = Throw a ⟹ ?R⟧ ⟹ ?R›*)) (*goals: 1. ‹⋀v. e0 = Val v ⟹ e0 = e' ∧ s0 = s' ∧ b0 = b'› 2. ‹⋀a. e0 = Throw a ⟹ e0 = e' ∧ s0 = s' ∧ b0 = b'›*) fix v assume "e0 = Val v" (*‹(e0::char list exp) = Val (v::val)›*) then show "?thesis" (*goal: ‹(e0::char list exp) = (e'::char list exp) ∧ (s0::heap × sfields × sheap) = (s'::heap × sfields × sheap) ∧ (b0::bool) = (b'::bool)›*) using step (*‹(P::(char list list × char list exp) prog) ⊢ ⟨e0::char list exp,s0::heap × sfields × sheap,b0::bool⟩ → ⟨e1::char list exp,s1::heap × sfields × sheap,b1::bool⟩› ‹P ⊢ ⟨e1,s1,b1⟩ →* ⟨e',s',b'⟩› ‹final e1 ⟹ e1 = e' ∧ s1 = s' ∧ b1 = b'› ‹final e0›*) by simp next (*goal: ‹⋀a. e0 = Throw a ⟹ e0 = e' ∧ s0 = s' ∧ b0 = b'›*) fix a assume "e0 = Throw a" (*‹(e0::char list exp) = Throw (a::nat)›*) then show "?thesis" (*goal: ‹e0 = e' ∧ s0 = s' ∧ b0 = b'›*) using step (*‹P ⊢ ⟨e0,s0,b0⟩ → ⟨e1,s1,b1⟩› ‹(P::(char list list × char list exp) prog) ⊢ ⟨e1::char list exp,s1::heap × sfields × sheap,b1::bool⟩ →* ⟨e'::char list exp,s'::heap × sfields × sheap,b'::bool⟩› ‹final e1 ⟹ e1 = e' ∧ s1 = s' ∧ b1 = b'› ‹final (e0::char list exp)›*) by simp qed qed lemma reds_throw: "P ⊢ ⟨e,s,b⟩ →* ⟨e',s',b'⟩ ⟹ (⋀e⇩t. throw_of e = ⌊e⇩t⌋ ⟹ ∃e⇩t'. throw_of e' = ⌊e⇩t'⌋)" proof (induct rule:converse_rtrancl_induct3 (*‹⟦((?ax, ?ay, ?az), ?bx, ?by, ?bz) ∈ ?r⇧*; ?P ?bx ?by ?bz; ⋀a aa b ab ac ba. ⟦((a, aa, b), ab, ac, ba) ∈ ?r; ((ab, ac, ba), ?bx, ?by, ?bz) ∈ ?r⇧*; ?P ab ac ba⟧ ⟹ ?P a aa b⟧ ⟹ ?P ?ax ?ay ?az›*)) (*goals: 1. ‹⋀e⇩t. throw_of e' = ⌊e⇩t⌋ ⟹ ∃e⇩t'. throw_of e' = ⌊e⇩t'⌋› 2. ‹⋀a aa b ab ac ba e⇩t. ⟦P ⊢ ⟨a,aa,b⟩ → ⟨ab,ac,ba⟩; P ⊢ ⟨ab,ac,ba⟩ →* ⟨e',s',b'⟩; ⋀e⇩t. throw_of ab = ⌊e⇩t⌋ ⟹ ∃e⇩t'. throw_of e' = ⌊e⇩t'⌋; throw_of a = ⌊e⇩t⌋⟧ ⟹ ∃e⇩t'. throw_of e' = ⌊e⇩t'⌋›*) case refl (*‹throw_of e' = ⌊e⇩t⌋›*) then show "?case" (*goal: ‹∃e⇩t'. throw_of e' = ⌊e⇩t'⌋›*) by simp next (*goal: ‹⋀a aa b ab ac ba e⇩t. ⟦P ⊢ ⟨a,aa,b⟩ → ⟨ab,ac,ba⟩; P ⊢ ⟨ab,ac,ba⟩ →* ⟨e',s',b'⟩; ⋀e⇩t. throw_of ab = ⌊e⇩t⌋ ⟹ ∃e⇩t'. throw_of e' = ⌊e⇩t'⌋; throw_of a = ⌊e⇩t⌋⟧ ⟹ ∃e⇩t'. throw_of e' = ⌊e⇩t'⌋›*) case (step e0 s0 b0 e1 s1 b1) (*‹P ⊢ ⟨e0,s0,b0⟩ → ⟨e1,s1,b1⟩› ‹P ⊢ ⟨e1,s1,b1⟩ →* ⟨e',s',b'⟩› ‹throw_of e1 = ⌊?e⇩t⌋ ⟹ ∃e⇩t'. throw_of e' = ⌊e⇩t'⌋› ‹throw_of e0 = ⌊e⇩t⌋›*) then show "?case" (*goal: ‹∃e⇩t'. throw_of e' = ⌊e⇩t'⌋›*) by (auto elim: red.cases (*‹⟦?P ⊢ ⟨?a1.0,?a2.0,?a3.0⟩ → ⟨?a4.0,?a5.0,?a6.0⟩; ⋀h a C FDTs h' l sh. ⟦?a1.0 = new C; ?a2.0 = (h, l, sh); ?a3.0 = True; ?a4.0 = addr a; ?a5.0 = (h', l, sh); ?a6.0 = False; new_Addr h = ⌊a⌋; ?P ⊢ C has_fields FDTs; h' = h(a ↦ blank ?P C)⟧ ⟹ ?Pa; ⋀h C l sh. ⟦?a1.0 = new C; ?a2.0 = (h, l, sh); ?a3.0 = True; ?a4.0 = THROW OutOfMemory; ?a5.0 = (h, l, sh); ?a6.0 = False; new_Addr h = None; is_class ?P C⟧ ⟹ ?Pa; ⋀sh C sfs h l. ⟦?a1.0 = new C; ?a2.0 = (h, l, sh); ?a3.0 = False; ?a4.0 = new C; ?a5.0 = (h, l, sh); ?a6.0 = True; sh C = ⌊(sfs, Done)⌋⟧ ⟹ ?Pa; ⋀sh C h l. ⟦?a1.0 = new C; ?a2.0 = (h, l, sh); ?a3.0 = False; ?a4.0 = INIT C ([C],False) ← new C; ?a5.0 = (h, l, sh); ?a6.0 = False; ∄sfs. sh C = ⌊(sfs, Done)⌋; is_class ?P C⟧ ⟹ ?Pa; ⋀e s b e' s' b' C. ⟦?a1.0 = Cast C e; ?a2.0 = s; ?a3.0 = b; ?a4.0 = Cast C e'; ?a5.0 = s'; ?a6.0 = b'; ?P ⊢ ⟨e,s,b⟩ → ⟨e',s',b'⟩⟧ ⟹ ?Pa; ⋀C s b. ⟦?a1.0 = Cast C null; ?a2.0 = s; ?a3.0 = b; ?a4.0 = null; ?a5.0 = s; ?a6.0 = b⟧ ⟹ ?Pa; ⋀h a D fs C l sh b. ⟦?a1.0 = Cast C (addr a); ?a2.0 = (h, l, sh); ?a3.0 = b; ?a4.0 = addr a; ?a5.0 = (h, l, sh); ?a6.0 = b; h a = ⌊(D, fs)⌋; ?P ⊢ D ≼⇧* C⟧ ⟹ ?Pa; ⋀h a D fs C l sh b. ⟦?a1.0 = Cast C (addr a); ?a2.0 = (h, l, sh); ?a3.0 = b; ?a4.0 = THROW ClassCast; ?a5.0 = (h, l, sh); ?a6.0 = b; h a = ⌊(D, fs)⌋; (D, C) ∉ (subcls1 ?P)⇧*⟧ ⟹ ?Pa; ⋀e s b e' s' b' bop e₂. ⟦?a1.0 = e «bop» e₂; ?a2.0 = s; ?a3.0 = b; ?a4.0 = e' «bop» e₂; ?a5.0 = s'; ?a6.0 = b'; ?P ⊢ ⟨e,s,b⟩ → ⟨e',s',b'⟩⟧ ⟹ ?Pa; ⋀e s b e' s' b' v₁ bop. ⟦?a1.0 = Val v₁ «bop» e; ?a2.0 = s; ?a3.0 = b; ?a4.0 = Val v₁ «bop» e'; ?a5.0 = s'; ?a6.0 = b'; ?P ⊢ ⟨e,s,b⟩ → ⟨e',s',b'⟩⟧ ⟹ ?Pa; ⋀bop v₁ v₂ v s b. ⟦?a1.0 = Val v₁ «bop» Val v₂; ?a2.0 = s; ?a3.0 = b; ?a4.0 = Val v; ?a5.0 = s; ?a6.0 = b; binop (bop, v₁, v₂) = ⌊v⌋⟧ ⟹ ?Pa; ⋀l V v h sh b. ⟦?a1.0 = Var V; ?a2.0 = (h, l, sh); ?a3.0 = b; ?a4.0 = Val v; ?a5.0 = (h, l, sh); ?a6.0 = b; l V = ⌊v⌋⟧ ⟹ ?Pa; ⋀e s b e' s' b' V. ⟦?a1.0 = V:=e; ?a2.0 = s; ?a3.0 = b; ?a4.0 = V:=e'; ?a5.0 = s'; ?a6.0 = b'; ?P ⊢ ⟨e,s,b⟩ → ⟨e',s',b'⟩⟧ ⟹ ?Pa; ⋀V v h l sh b. ⟦?a1.0 = V:=Val v; ?a2.0 = (h, l, sh); ?a3.0 = b; ?a4.0 = unit; ?a5.0 = (h, l(V ↦ v), sh); ?a6.0 = b⟧ ⟹ ?Pa; ⋀e s b e' s' b' F D. ⟦?a1.0 = e∙F{D}; ?a2.0 = s; ?a3.0 = b; ?a4.0 = e'∙F{D}; ?a5.0 = s'; ?a6.0 = b'; ?P ⊢ ⟨e,s,b⟩ → ⟨e',s',b'⟩⟧ ⟹ ?Pa; ⋀h a C fs F D v t l sh b. ⟦?a1.0 = addr a∙F{D}; ?a2.0 = (h, l, sh); ?a3.0 = b; ?a4.0 = Val v; ?a5.0 = (h, l, sh); ?a6.0 = b; h a = ⌊(C, fs)⌋; fs (F, D) = ⌊v⌋; ?P ⊢ C has F,NonStatic:t in D⟧ ⟹ ?Pa; ⋀F D s b. ⟦?a1.0 = null∙F{D}; ?a2.0 = s; ?a3.0 = b; ?a4.0 = THROW NullPointer; ?a5.0 = s; ?a6.0 = b⟧ ⟹ ?Pa; ⋀h a C fs F D l sh b. ⟦?a1.0 = addr a∙F{D}; ?a2.0 = (h, l, sh); ?a3.0 = b; ?a4.0 = THROW NoSuchFieldError; ?a5.0 = (h, l, sh); ?a6.0 = b; h a = ⌊(C, fs)⌋; ∄b t. ?P ⊢ C has F,b:t in D⟧ ⟹ ?Pa; ⋀h a C fs F t D l sh b. ⟦?a1.0 = addr a∙F{D}; ?a2.0 = (h, l, sh); ?a3.0 = b; ?a4.0 = THROW IncompatibleClassChangeError; ?a5.0 = (h, l, sh); ?a6.0 = b; h a = ⌊(C, fs)⌋; ?P ⊢ C has F,Static:t in D⟧ ⟹ ?Pa; ⋀C F t D sh sfs i v h l. ⟦?a1.0 = C∙⇩sF{D}; ?a2.0 = (h, l, sh); ?a3.0 = True; ?a4.0 = Val v; ?a5.0 = (h, l, sh); ?a6.0 = False; ?P ⊢ C has F,Static:t in D; sh D = ⌊(sfs, i)⌋; sfs F = ⌊v⌋⟧ ⟹ ?Pa; ⋀C F t D sh sfs h l. ⟦?a1.0 = C∙⇩sF{D}; ?a2.0 = (h, l, sh); ?a3.0 = False; ?a4.0 = C∙⇩sF{D}; ?a5.0 = (h, l, sh); ?a6.0 = True; ?P ⊢ C has F,Static:t in D; sh D = ⌊(sfs, Done)⌋⟧ ⟹ ?Pa; ⋀C F t D sh h l. ⟦?a1.0 = C∙⇩sF{D}; ?a2.0 = (h, l, sh); ?a3.0 = False; ?a4.0 = INIT D ([D],False) ← C∙⇩sF{D}; ?a5.0 = (h, l, sh); ?a6.0 = False; ?P ⊢ C has F,Static:t in D; ∄sfs. sh D = ⌊(sfs, Done)⌋⟧ ⟹ ?Pa; ⋀C F D h l sh b. ⟦?a1.0 = C∙⇩sF{D}; ?a2.0 = (h, l, sh); ?a3.0 = b; ?a4.0 = THROW NoSuchFieldError; ?a5.0 = (h, l, sh); ?a6.0 = False; ∄b t. ?P ⊢ C has F,b:t in D⟧ ⟹ ?Pa; ⋀C F t D h l sh b. ⟦?a1.0 = C∙⇩sF{D}; ?a2.0 = (h, l, sh); ?a3.0 = b; ?a4.0 = THROW IncompatibleClassChangeError; ?a5.0 = (h, l, sh); ?a6.0 = False; ?P ⊢ C has F,NonStatic:t in D⟧ ⟹ ?Pa; ⋀e s b e' s' b' F D e₂. ⟦?a1.0 = e∙F{D} := e₂; ?a2.0 = s; ?a3.0 = b; ?a4.0 = e'∙F{D} := e₂; ?a5.0 = s'; ?a6.0 = b'; ?P ⊢ ⟨e,s,b⟩ → ⟨e',s',b'⟩⟧ ⟹ ?Pa; ⋀e s b e' s' b' v F D. ⟦?a1.0 = Val v∙F{D} := e; ?a2.0 = s; ?a3.0 = b; ?a4.0 = Val v∙F{D} := e'; ?a5.0 = s'; ?a6.0 = b'; ?P ⊢ ⟨e,s,b⟩ → ⟨e',s',b'⟩⟧ ⟹ ?Pa; ⋀C F t D h a fs v l sh b. ⟦?a1.0 = addr a∙F{D} := Val v; ?a2.0 = (h, l, sh); ?a3.0 = b; ?a4.0 = unit; ?a5.0 = (h(a ↦ (C, fs((F, D) ↦ v))), l, sh); ?a6.0 = b; ?P ⊢ C has F,NonStatic:t in D; h a = ⌊(C, fs)⌋⟧ ⟹ ?Pa; ⋀F D v s b. ⟦?a1.0 = null∙F{D} := Val v; ?a2.0 = s; ?a3.0 = b; ?a4.0 = THROW NullPointer; ?a5.0 = s; ?a6.0 = b⟧ ⟹ ?Pa; ⋀h a C fs F D v l sh b. ⟦?a1.0 = addr a∙F{D} := Val v; ?a2.0 = (h, l, sh); ?a3.0 = b; ?a4.0 = THROW NoSuchFieldError; ?a5.0 = (h, l, sh); ?a6.0 = b; h a = ⌊(C, fs)⌋; ∄b t. ?P ⊢ C has F,b:t in D⟧ ⟹ ?Pa; ⋀h a C fs F t D v l sh b. ⟦?a1.0 = addr a∙F{D} := Val v; ?a2.0 = (h, l, sh); ?a3.0 = b; ?a4.0 = THROW IncompatibleClassChangeError; ?a5.0 = (h, l, sh); ?a6.0 = b; h a = ⌊(C, fs)⌋; ?P ⊢ C has F,Static:t in D⟧ ⟹ ?Pa; ⋀e s b e' s' b' C F D. ⟦?a1.0 = C∙⇩sF{D} := e; ?a2.0 = s; ?a3.0 = b; ?a4.0 = C∙⇩sF{D} := e'; ?a5.0 = s'; ?a6.0 = b'; ?P ⊢ ⟨e,s,b⟩ → ⟨e',s',b'⟩⟧ ⟹ ?Pa; ⋀C F t D sh sfs i sfs' v sh' h l. ⟦?a1.0 = C∙⇩sF{D} := Val v; ?a2.0 = (h, l, sh); ?a3.0 = True; ?a4.0 = unit; ?a5.0 = (h, l, sh'); ?a6.0 = False; ?P ⊢ C has F,Static:t in D; sh D = ⌊(sfs, i)⌋; sfs' = sfs(F ↦ v); sh' = sh(D ↦ (sfs', i))⟧ ⟹ ?Pa; ⋀C F t D sh sfs v h l. ⟦?a1.0 = C∙⇩sF{D} := Val v; ?a2.0 = (h, l, sh); ?a3.0 = False; ?a4.0 = C∙⇩sF{D} := Val v; ?a5.0 = (h, l, sh); ?a6.0 = True; ?P ⊢ C has F,Static:t in D; sh D = ⌊(sfs, Done)⌋⟧ ⟹ ?Pa; ⋀C F t D sh v h l. ⟦?a1.0 = C∙⇩sF{D} := Val v; ?a2.0 = (h, l, sh); ?a3.0 = False; ?a4.0 = INIT D ([D],False) ← C∙⇩sF{D} := Val v; ?a5.0 = (h, l, sh); ?a6.0 = False; ?P ⊢ C has F,Static:t in D; ∄sfs. sh D = ⌊(sfs, Done)⌋⟧ ⟹ ?Pa; ⋀C F D v s b. ⟦?a1.0 = C∙⇩sF{D} := Val v; ?a2.0 = s; ?a3.0 = b; ?a4.0 = THROW NoSuchFieldError; ?a5.0 = s; ?a6.0 = False; ∄b t. ?P ⊢ C has F,b:t in D⟧ ⟹ ?Pa; ⋀C F t D v s b. ⟦?a1.0 = C∙⇩sF{D} := Val v; ?a2.0 = s; ?a3.0 = b; ?a4.0 = THROW IncompatibleClassChangeError; ?a5.0 = s; ?a6.0 = False; ?P ⊢ C has F,NonStatic:t in D⟧ ⟹ ?Pa; ⋀e s b e' s' b' M es. ⟦?a1.0 = e∙M(es); ?a2.0 = s; ?a3.0 = b; ?a4.0 = e'∙M(es); ?a5.0 = s'; ?a6.0 = b'; ?P ⊢ ⟨e,s,b⟩ → ⟨e',s',b'⟩⟧ ⟹ ?Pa; ⋀es s b es' s' b' v M. ⟦?a1.0 = Val v∙M(es); ?a2.0 = s; ?a3.0 = b; ?a4.0 = Val v∙M(es'); ?a5.0 = s'; ?a6.0 = b'; ?P ⊢ ⟨es,s,b⟩ [→] ⟨es',s',b'⟩⟧ ⟹ ?Pa; ⋀h a C fs M Ts T pns body D vs l sh b. ⟦?a1.0 = addr a∙M(map Val vs); ?a2.0 = (h, l, sh); ?a3.0 = b; ?a4.0 = blocks (this # pns, Class D # Ts, Addr a # vs, body); ?a5.0 = (h, l, sh); ?a6.0 = b; h a = ⌊(C, fs)⌋; ?P ⊢ C sees M, NonStatic : Ts→T = (pns, body) in D; length vs = length pns; length Ts = length pns⟧ ⟹ ?Pa; ⋀M vs s b. ⟦?a1.0 = null∙M(map Val vs); ?a2.0 = s; ?a3.0 = b; ?a4.0 = THROW NullPointer; ?a5.0 = s; ?a6.0 = b⟧ ⟹ ?Pa; ⋀h a C fs M vs l sh b. ⟦?a1.0 = addr a∙M(map Val vs); ?a2.0 = (h, l, sh); ?a3.0 = b; ?a4.0 = THROW NoSuchMethodError; ?a5.0 = (h, l, sh); ?a6.0 = b; h a = ⌊(C, fs)⌋; ∄b Ts T m D. ?P ⊢ C sees M, b : Ts→T = m in D⟧ ⟹ ?Pa; ⋀h a C fs M Ts T m D vs l sh b. ⟦?a1.0 = addr a∙M(map Val vs); ?a2.0 = (h, l, sh); ?a3.0 = b; ?a4.0 = THROW IncompatibleClassChangeError; ?a5.0 = (h, l, sh); ?a6.0 = b; h a = ⌊(C, fs)⌋; ?P ⊢ C sees M, Static : Ts→T = m in D⟧ ⟹ ?Pa; ⋀es s b es' s' b' C M. ⟦?a1.0 = C∙⇩sM(es); ?a2.0 = s; ?a3.0 = b; ?a4.0 = C∙⇩sM(es'); ?a5.0 = s'; ?a6.0 = b'; ?P ⊢ ⟨es,s,b⟩ [→] ⟨es',s',b'⟩⟧ ⟹ ?Pa; ⋀C M Ts T pns body D vs s. ⟦?a1.0 = C∙⇩sM(map Val vs); ?a2.0 = s; ?a3.0 = True; ?a4.0 = blocks (pns, Ts, vs, body); ?a5.0 = s; ?a6.0 = False; ?P ⊢ C sees M, Static : Ts→T = (pns, body) in D; length vs = length pns; length Ts = length pns⟧ ⟹ ?Pa; ⋀C M Ts T pns body D sh sfs vs h l. ⟦?a1.0 = C∙⇩sM(map Val vs); ?a2.0 = (h, l, sh); ?a3.0 = False; ?a4.0 = C∙⇩sM(map Val vs); ?a5.0 = (h, l, sh); ?a6.0 = True; ?P ⊢ C sees M, Static : Ts→T = (pns, body) in D; sh D = ⌊(sfs, Done)⌋ ∨ M = clinit ∧ sh D = ⌊(sfs, Processing)⌋⟧ ⟹ ?Pa; ⋀C M Ts T pns body D sh vs h l. ⟦?a1.0 = C∙⇩sM(map Val vs); ?a2.0 = (h, l, sh); ?a3.0 = False; ?a4.0 = INIT D ([D],False) ← C∙⇩sM(map Val vs); ?a5.0 = (h, l, sh); ?a6.0 = False; ?P ⊢ C sees M, Static : Ts→T = (pns, body) in D; ∄sfs. sh D = ⌊(sfs, Done)⌋; M ≠ clinit⟧ ⟹ ?Pa; ⋀C M vs s b. ⟦?a1.0 = C∙⇩sM(map Val vs); ?a2.0 = s; ?a3.0 = b; ?a4.0 = THROW NoSuchMethodError; ?a5.0 = s; ?a6.0 = False; ∄b Ts T m D. ?P ⊢ C sees M, b : Ts→T = m in D⟧ ⟹ ?Pa; ⋀C M Ts T m D vs s b. ⟦?a1.0 = C∙⇩sM(map Val vs); ?a2.0 = s; ?a3.0 = b; ?a4.0 = THROW IncompatibleClassChangeError; ?a5.0 = s; ?a6.0 = False; ?P ⊢ C sees M, NonStatic : Ts→T = m in D⟧ ⟹ ?Pa; ⋀e h l V sh b e' h' l' sh' b' T. ⟦?a1.0 = {V:T; e}; ?a2.0 = (h, l, sh); ?a3.0 = b; ?a4.0 = {V:T; e'}; ?a5.0 = (h', l'(V := l V), sh'); ?a6.0 = b'; ?P ⊢ ⟨e,(h, l(V := None), sh),b⟩ → ⟨e',(h', l', sh'),b'⟩; l' V = None; ¬ assigned V e⟧ ⟹ ?Pa; ⋀e h l V sh b e' h' l' sh' b' v T. ⟦?a1.0 = {V:T; e}; ?a2.0 = (h, l, sh); ?a3.0 = b; ?a4.0 = {V:T; V:=Val v;; e'}; ?a5.0 = (h', l'(V := l V), sh'); ?a6.0 = b'; ?P ⊢ ⟨e,(h, l(V := None), sh),b⟩ → ⟨e',(h', l', sh'),b'⟩; l' V = ⌊v⌋; ¬ assigned V e⟧ ⟹ ?Pa; ⋀e h l V v sh b e' h' l' sh' b' v' T. ⟦?a1.0 = {V:T; V:=Val v;; e}; ?a2.0 = (h, l, sh); ?a3.0 = b; ?a4.0 = {V:T; V:=Val v';; e'}; ?a5.0 = (h', l'(V := l V), sh'); ?a6.0 = b'; ?P ⊢ ⟨e,(h, l(V ↦ v), sh),b⟩ → ⟨e',(h', l', sh'),b'⟩; l' V = ⌊v'⌋⟧ ⟹ ?Pa; ⋀V T u s b. ⟦?a1.0 = {V:T; Val u}; ?a2.0 = s; ?a3.0 = b; ?a4.0 = Val u; ?a5.0 = s; ?a6.0 = b⟧ ⟹ ?Pa; ⋀V T v u s b. ⟦?a1.0 = {V:T; V:=Val v;; Val u}; ?a2.0 = s; ?a3.0 = b; ?a4.0 = Val u; ?a5.0 = s; ?a6.0 = b⟧ ⟹ ?Pa; ⋀e s b e' s' b' e₂. ⟦?a1.0 = e;; e₂; ?a2.0 = s; ?a3.0 = b; ?a4.0 = e';; e₂; ?a5.0 = s'; ?a6.0 = b'; ?P ⊢ ⟨e,s,b⟩ → ⟨e',s',b'⟩⟧ ⟹ ?Pa; ⋀v e₂ s b. ⟦?a1.0 = Val v;; e₂; ?a2.0 = s; ?a3.0 = b; ?a4.0 = e₂; ?a5.0 = s; ?a6.0 = b⟧ ⟹ ?Pa; ⋀e s b e' s' b' e₁ e₂. ⟦?a1.0 = if (e) e₁ else e₂; ?a2.0 = s; ?a3.0 = b; ?a4.0 = if (e') e₁ else e₂; ?a5.0 = s'; ?a6.0 = b'; ?P ⊢ ⟨e,s,b⟩ → ⟨e',s',b'⟩⟧ ⟹ ?Pa; ⋀e₁ e₂ s b. ⟦?a1.0 = if (true) e₁ else e₂; ?a2.0 = s; ?a3.0 = b; ?a4.0 = e₁; ?a5.0 = s; ?a6.0 = b⟧ ⟹ ?Pa; ⋀e₁ e₂ s b. ⟦?a1.0 = if (false) e₁ else e₂; ?a2.0 = s; ?a3.0 = b; ?a4.0 = e₂; ?a5.0 = s; ?a6.0 = b⟧ ⟹ ?Pa; ⋀b c s b'. ⟦?a1.0 = while (b) c; ?a2.0 = s; ?a3.0 = b'; ?a4.0 = if (b) (c;; while (b) c) else unit; ?a5.0 = s; ?a6.0 = b'⟧ ⟹ ?Pa; ⋀e s b e' s' b'. ⟦?a1.0 = throw e; ?a2.0 = s; ?a3.0 = b; ?a4.0 = throw e'; ?a5.0 = s'; ?a6.0 = b'; ?P ⊢ ⟨e,s,b⟩ → ⟨e',s',b'⟩⟧ ⟹ ?Pa; ⋀s b. ⟦?a1.0 = throw null; ?a2.0 = s; ?a3.0 = b; ?a4.0 = THROW NullPointer; ?a5.0 = s; ?a6.0 = b⟧ ⟹ ?Pa; ⋀e s b e' s' b' C V e₂. ⟦?a1.0 = try e catch(C V) e₂; ?a2.0 = s; ?a3.0 = b; ?a4.0 = try e' catch(C V) e₂; ?a5.0 = s'; ?a6.0 = b'; ?P ⊢ ⟨e,s,b⟩ → ⟨e',s',b'⟩⟧ ⟹ ?Pa; ⋀v C V e₂ s b. ⟦?a1.0 = try Val v catch(C V) e₂; ?a2.0 = s; ?a3.0 = b; ?a4.0 = Val v; ?a5.0 = s; ?a6.0 = b⟧ ⟹ ?Pa; ⋀s a D fs C V e₂ b. ⟦?a1.0 = try Throw a catch(C V) e₂; ?a2.0 = s; ?a3.0 = b; ?a4.0 = {V:Class C; V:=addr a;; e₂}; ?a5.0 = s; ?a6.0 = b; hp s a = ⌊(D, fs)⌋; ?P ⊢ D ≼⇧* C⟧ ⟹ ?Pa; ⋀s a D fs C V e₂ b. ⟦?a1.0 = try Throw a catch(C V) e₂; ?a2.0 = s; ?a3.0 = b; ?a4.0 = Throw a; ?a5.0 = s; ?a6.0 = b; hp s a = ⌊(D, fs)⌋; (D, C) ∉ (subcls1 ?P)⇧*⟧ ⟹ ?Pa; ⋀e C b s b'. ⟦?a1.0 = INIT C ([],b) ← e; ?a2.0 = s; ?a3.0 = b'; ?a4.0 = e; ?a5.0 = s; ?a6.0 = icheck ?P C e; ¬ sub_RI e⟧ ⟹ ?Pa; ⋀sh C C' Cs e h l b. ⟦?a1.0 = INIT C' (C # Cs,False) ← e; ?a2.0 = (h, l, sh); ?a3.0 = b; ?a4.0 = INIT C' (C # Cs,False) ← e; ?a5.0 = (h, l, sh(C ↦ (sblank ?P C, Prepared))); ?a6.0 = b; sh C = None⟧ ⟹ ?Pa; ⋀sh C sfs C' Cs e h l b. ⟦?a1.0 = INIT C' (C # Cs,False) ← e; ?a2.0 = (h, l, sh); ?a3.0 = b; ?a4.0 = INIT C' (Cs,True) ← e; ?a5.0 = (h, l, sh); ?a6.0 = b; sh C = ⌊(sfs, Done)⌋⟧ ⟹ ?Pa; ⋀sh C sfs C' Cs e h l b. ⟦?a1.0 = INIT C' (C # Cs,False) ← e; ?a2.0 = (h, l, sh); ?a3.0 = b; ?a4.0 = INIT C' (Cs,True) ← e; ?a5.0 = (h, l, sh); ?a6.0 = b; sh C = ⌊(sfs, Processing)⌋⟧ ⟹ ?Pa; ⋀sh C sfs C' Cs e h l b. ⟦?a1.0 = INIT C' (C # Cs,False) ← e; ?a2.0 = (h, l, sh); ?a3.0 = b; ?a4.0 = RI (C,THROW NoClassDefFoundError) ; Cs ← e; ?a5.0 = (h, l, sh); ?a6.0 = b; sh C = ⌊(sfs, Error)⌋⟧ ⟹ ?Pa; ⋀sh C sfs sh' C' Cs e h l b. ⟦?a1.0 = INIT C' (C # Cs,False) ← e; ?a2.0 = (h, l, sh); ?a3.0 = b; ?a4.0 = INIT C' (C # Cs,True) ← e; ?a5.0 = (h, l, sh'); ?a6.0 = b; sh C = ⌊(sfs, Prepared)⌋; C = Object; sh' = sh(C ↦ (sfs, Processing))⟧ ⟹ ?Pa; ⋀sh C sfs D r sh' C' Cs e h l b. ⟦?a1.0 = INIT C' (C # Cs,False) ← e; ?a2.0 = (h, l, sh); ?a3.0 = b; ?a4.0 = INIT C' (D # C # Cs,False) ← e; ?a5.0 = (h, l, sh'); ?a6.0 = b; sh C = ⌊(sfs, Prepared)⌋; C ≠ Object; class ?P C = ⌊(D, r)⌋; sh' = sh(C ↦ (sfs, Processing))⟧ ⟹ ?Pa; ⋀C' C Cs e h l sh b. ⟦?a1.0 = INIT C' (C # Cs,True) ← e; ?a2.0 = (h, l, sh); ?a3.0 = b; ?a4.0 = RI (C,C∙⇩sclinit([])) ; Cs ← e; ?a5.0 = (h, l, sh); ?a6.0 = b⟧ ⟹ ?Pa; ⋀e s b e' s' b' C Cs e₀. ⟦?a1.0 = RI (C,e) ; Cs ← e₀; ?a2.0 = s; ?a3.0 = b; ?a4.0 = RI (C,e') ; Cs ← e₀; ?a5.0 = s'; ?a6.0 = b'; ?P ⊢ ⟨e,s,b⟩ → ⟨e',s',b'⟩⟧ ⟹ ?Pa; ⋀sh C sfs i sh' C' Cs v e h l b. ⟦?a1.0 = RI (C,Val v) ; Cs ← e; ?a2.0 = (h, l, sh); ?a3.0 = b; ?a4.0 = INIT C' (Cs,True) ← e; ?a5.0 = (h, l, sh'); ?a6.0 = b; sh C = ⌊(sfs, i)⌋; sh' = sh(C ↦ (sfs, Done)); C' = last (C # Cs)⟧ ⟹ ?Pa; ⋀C e s b. ⟦?a1.0 = Cast C (throw e); ?a2.0 = s; ?a3.0 = b; ?a4.0 = throw e; ?a5.0 = s; ?a6.0 = b⟧ ⟹ ?Pa; ⋀e bop e₂ s b. ⟦?a1.0 = throw e «bop» e₂; ?a2.0 = s; ?a3.0 = b; ?a4.0 = throw e; ?a5.0 = s; ?a6.0 = b⟧ ⟹ ?Pa; ⋀v₁ bop e s b. ⟦?a1.0 = Val v₁ «bop» throw e; ?a2.0 = s; ?a3.0 = b; ?a4.0 = throw e; ?a5.0 = s; ?a6.0 = b⟧ ⟹ ?Pa; ⋀V e s b. ⟦?a1.0 = V:=throw e; ?a2.0 = s; ?a3.0 = b; ?a4.0 = throw e; ?a5.0 = s; ?a6.0 = b⟧ ⟹ ?Pa; ⋀e F D s b. ⟦?a1.0 = throw e∙F{D}; ?a2.0 = s; ?a3.0 = b; ?a4.0 = throw e; ?a5.0 = s; ?a6.0 = b⟧ ⟹ ?Pa; ⋀e F D e₂ s b. ⟦?a1.0 = throw e∙F{D} := e₂; ?a2.0 = s; ?a3.0 = b; ?a4.0 = throw e; ?a5.0 = s; ?a6.0 = b⟧ ⟹ ?Pa; ⋀v F D e s b. ⟦?a1.0 = Val v∙F{D} := throw e; ?a2.0 = s; ?a3.0 = b; ?a4.0 = throw e; ?a5.0 = s; ?a6.0 = b⟧ ⟹ ?Pa; ⋀C F D e s b. ⟦?a1.0 = C∙⇩sF{D} := throw e; ?a2.0 = s; ?a3.0 = b; ?a4.0 = throw e; ?a5.0 = s; ?a6.0 = b⟧ ⟹ ?Pa; ⋀e M es s b. ⟦?a1.0 = throw e∙M(es); ?a2.0 = s; ?a3.0 = b; ?a4.0 = throw e; ?a5.0 = s; ?a6.0 = b⟧ ⟹ ?Pa; ⋀es vs e es' v M s b. ⟦?a1.0 = Val v∙M(es); ?a2.0 = s; ?a3.0 = b; ?a4.0 = throw e; ?a5.0 = s; ?a6.0 = b; es = map Val vs @ throw e # es'⟧ ⟹ ?Pa; ⋀es vs e es' C M s b. ⟦?a1.0 = C∙⇩sM(es); ?a2.0 = s; ?a3.0 = b; ?a4.0 = throw e; ?a5.0 = s; ?a6.0 = b; es = map Val vs @ throw e # es'⟧ ⟹ ?Pa; ⋀V T a s b. ⟦?a1.0 = {V:T; Throw a}; ?a2.0 = s; ?a3.0 = b; ?a4.0 = Throw a; ?a5.0 = s; ?a6.0 = b⟧ ⟹ ?Pa; ⋀V T v a s b. ⟦?a1.0 = {V:T; V:=Val v;; Throw a}; ?a2.0 = s; ?a3.0 = b; ?a4.0 = Throw a; ?a5.0 = s; ?a6.0 = b⟧ ⟹ ?Pa; ⋀e e₂ s b. ⟦?a1.0 = throw e;; e₂; ?a2.0 = s; ?a3.0 = b; ?a4.0 = throw e; ?a5.0 = s; ?a6.0 = b⟧ ⟹ ?Pa; ⋀e e₁ e₂ s b. ⟦?a1.0 = if (throw e) e₁ else e₂; ?a2.0 = s; ?a3.0 = b; ?a4.0 = throw e; ?a5.0 = s; ?a6.0 = b⟧ ⟹ ?Pa; ⋀e s b. ⟦?a1.0 = throw (throw e); ?a2.0 = s; ?a3.0 = b; ?a4.0 = throw e; ?a5.0 = s; ?a6.0 = b⟧ ⟹ ?Pa; ⋀sh C sfs i sh' a D Cs e h l b. ⟦?a1.0 = RI (C,Throw a) ; D # Cs ← e; ?a2.0 = (h, l, sh); ?a3.0 = b; ?a4.0 = RI (D,Throw a) ; Cs ← e; ?a5.0 = (h, l, sh'); ?a6.0 = b; sh C = ⌊(sfs, i)⌋; sh' = sh(C ↦ (sfs, Error))⟧ ⟹ ?Pa; ⋀sh C sfs i sh' a e h l b. ⟦?a1.0 = RI (C,Throw a) ; [] ← e; ?a2.0 = (h, l, sh); ?a3.0 = b; ?a4.0 = Throw a; ?a5.0 = (h, l, sh'); ?a6.0 = b; sh C = ⌊(sfs, i)⌋; sh' = sh(C ↦ (sfs, Error))⟧ ⟹ ?Pa⟧ ⟹ ?Pa›*)) qed lemma red_hext_incr: "P ⊢ ⟨e,(h,l,sh),b⟩ → ⟨e',(h',l',sh'),b'⟩ ⟹ h ⊴ h'" and reds_hext_incr: "P ⊢ ⟨es,(h,l,sh),b⟩ [→] ⟨es',(h',l',sh'),b'⟩ ⟹ h ⊴ h'" (*<*) proof (induct rule:red_reds_inducts (*‹⟦?P ⊢ ⟨?x1a,(?x2a, ?x2b, ?x2c),?x3a⟩ → ⟨?x4a,(?x5a, ?x5b, ?x5c),?x6a⟩; ⋀h a C FDTs h' l sh. ⟦new_Addr h = ⌊a⌋; ?P ⊢ C has_fields FDTs; h' = h(a ↦ blank ?P C)⟧ ⟹ ?P1.0 (new C) h l sh True (addr a) h' l sh False; ⋀h C l sh. ⟦new_Addr h = None; is_class ?P C⟧ ⟹ ?P1.0 (new C) h l sh True (THROW OutOfMemory) h l sh False; ⋀sh C sfs h l. sh C = ⌊(sfs, Done)⌋ ⟹ ?P1.0 (new C) h l sh False (new C) h l sh True; ⋀sh C h l. ⟦∄sfs. sh C = ⌊(sfs, Done)⌋; is_class ?P C⟧ ⟹ ?P1.0 (new C) h l sh False (INIT C ([C],False) ← new C) h l sh False; ⋀e a aa b ba e' ab ac bb b' C. ⟦?P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ?P1.0 e a aa b ba e' ab ac bb b'⟧ ⟹ ?P1.0 (Cast C e) a aa b ba (Cast C e') ab ac bb b'; ⋀C a aa b ba. ?P1.0 (Cast C null) a aa b ba null a aa b ba; ⋀h a D fs C l sh b. ⟦h a = ⌊(D, fs)⌋; ?P ⊢ D ≼⇧* C⟧ ⟹ ?P1.0 (Cast C (addr a)) h l sh b (addr a) h l sh b; ⋀h a D fs C l sh b. ⟦h a = ⌊(D, fs)⌋; (D, C) ∉ (subcls1 ?P)⇧*⟧ ⟹ ?P1.0 (Cast C (addr a)) h l sh b (THROW ClassCast) h l sh b; ⋀e a aa b ba e' ab ac bb b' bop e₂. ⟦?P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ?P1.0 e a aa b ba e' ab ac bb b'⟧ ⟹ ?P1.0 (e «bop» e₂) a aa b ba (e' «bop» e₂) ab ac bb b'; ⋀e a aa b ba e' ab ac bb b' v₁ bop. ⟦?P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ?P1.0 e a aa b ba e' ab ac bb b'⟧ ⟹ ?P1.0 (Val v₁ «bop» e) a aa b ba (Val v₁ «bop» e') ab ac bb b'; ⋀bop v₁ v₂ v a aa b ba. binop (bop, v₁, v₂) = ⌊v⌋ ⟹ ?P1.0 (Val v₁ «bop» Val v₂) a aa b ba (Val v) a aa b ba; ⋀l V v h sh b. l V = ⌊v⌋ ⟹ ?P1.0 (Var V) h l sh b (Val v) h l sh b; ⋀e a aa b ba e' ab ac bb b' V. ⟦?P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ?P1.0 e a aa b ba e' ab ac bb b'⟧ ⟹ ?P1.0 (V:=e) a aa b ba (V:=e') ab ac bb b'; ⋀V v h l sh b. ?P1.0 (V:=Val v) h l sh b unit h (l(V ↦ v)) sh b; ⋀e a aa b ba e' ab ac bb b' F D. ⟦?P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ?P1.0 e a aa b ba e' ab ac bb b'⟧ ⟹ ?P1.0 (e∙F{D}) a aa b ba (e'∙F{D}) ab ac bb b'; ⋀h a C fs F D v t l sh b. ⟦h a = ⌊(C, fs)⌋; fs (F, D) = ⌊v⌋; ?P ⊢ C has F,NonStatic:t in D⟧ ⟹ ?P1.0 (addr a∙F{D}) h l sh b (Val v) h l sh b; ⋀F D a aa b ba. ?P1.0 (null∙F{D}) a aa b ba (THROW NullPointer) a aa b ba; ⋀h a C fs F D l sh b. ⟦h a = ⌊(C, fs)⌋; ∄b t. ?P ⊢ C has F,b:t in D⟧ ⟹ ?P1.0 (addr a∙F{D}) h l sh b (THROW NoSuchFieldError) h l sh b; ⋀h a C fs F t D l sh b. ⟦h a = ⌊(C, fs)⌋; ?P ⊢ C has F,Static:t in D⟧ ⟹ ?P1.0 (addr a∙F{D}) h l sh b (THROW IncompatibleClassChangeError) h l sh b; ⋀C F t D sh sfs i v h l. ⟦?P ⊢ C has F,Static:t in D; sh D = ⌊(sfs, i)⌋; sfs F = ⌊v⌋⟧ ⟹ ?P1.0 (C∙⇩sF{D}) h l sh True (Val v) h l sh False; ⋀C F t D sh sfs h l. ⟦?P ⊢ C has F,Static:t in D; sh D = ⌊(sfs, Done)⌋⟧ ⟹ ?P1.0 (C∙⇩sF{D}) h l sh False (C∙⇩sF{D}) h l sh True; ⋀C F t D sh h l. ⟦?P ⊢ C has F,Static:t in D; ∄sfs. sh D = ⌊(sfs, Done)⌋⟧ ⟹ ?P1.0 (C∙⇩sF{D}) h l sh False (INIT D ([D],False) ← C∙⇩sF{D}) h l sh False; ⋀C F D h l sh b. ∄b t. ?P ⊢ C has F,b:t in D ⟹ ?P1.0 (C∙⇩sF{D}) h l sh b (THROW NoSuchFieldError) h l sh False; ⋀C F t D h l sh b. ?P ⊢ C has F,NonStatic:t in D ⟹ ?P1.0 (C∙⇩sF{D}) h l sh b (THROW IncompatibleClassChangeError) h l sh False; ⋀e a aa b ba e' ab ac bb b' F D e₂. ⟦?P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ?P1.0 e a aa b ba e' ab ac bb b'⟧ ⟹ ?P1.0 (e∙F{D} := e₂) a aa b ba (e'∙F{D} := e₂) ab ac bb b'; ⋀e a aa b ba e' ab ac bb b' v F D. ⟦?P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ?P1.0 e a aa b ba e' ab ac bb b'⟧ ⟹ ?P1.0 (Val v∙F{D} := e) a aa b ba (Val v∙F{D} := e') ab ac bb b'; ⋀C F t D h a fs v l sh b. ⟦?P ⊢ C has F,NonStatic:t in D; h a = ⌊(C, fs)⌋⟧ ⟹ ?P1.0 (addr a∙F{D} := Val v) h l sh b unit (h(a ↦ (C, fs((F, D) ↦ v)))) l sh b; ⋀F D v a aa b ba. ?P1.0 (null∙F{D} := Val v) a aa b ba (THROW NullPointer) a aa b ba; ⋀h a C fs F D v l sh b. ⟦h a = ⌊(C, fs)⌋; ∄b t. ?P ⊢ C has F,b:t in D⟧ ⟹ ?P1.0 (addr a∙F{D} := Val v) h l sh b (THROW NoSuchFieldError) h l sh b; ⋀h a C fs F t D v l sh b. ⟦h a = ⌊(C, fs)⌋; ?P ⊢ C has F,Static:t in D⟧ ⟹ ?P1.0 (addr a∙F{D} := Val v) h l sh b (THROW IncompatibleClassChangeError) h l sh b; ⋀e a aa b ba e' ab ac bb b' C F D. ⟦?P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ?P1.0 e a aa b ba e' ab ac bb b'⟧ ⟹ ?P1.0 (C∙⇩sF{D} := e) a aa b ba (C∙⇩sF{D} := e') ab ac bb b'; ⋀C F t D sh sfs i sfs' v sh' h l. ⟦?P ⊢ C has F,Static:t in D; sh D = ⌊(sfs, i)⌋; sfs' = sfs(F ↦ v); sh' = sh(D ↦ (sfs', i))⟧ ⟹ ?P1.0 (C∙⇩sF{D} := Val v) h l sh True unit h l sh' False; ⋀C F t D sh sfs v h l. ⟦?P ⊢ C has F,Static:t in D; sh D = ⌊(sfs, Done)⌋⟧ ⟹ ?P1.0 (C∙⇩sF{D} := Val v) h l sh False (C∙⇩sF{D} := Val v) h l sh True; ⋀C F t D sh v h l. ⟦?P ⊢ C has F,Static:t in D; ∄sfs. sh D = ⌊(sfs, Done)⌋⟧ ⟹ ?P1.0 (C∙⇩sF{D} := Val v) h l sh False (INIT D ([D],False) ← C∙⇩sF{D} := Val v) h l sh False; ⋀C F D v a aa b ba. ∄b t. ?P ⊢ C has F,b:t in D ⟹ ?P1.0 (C∙⇩sF{D} := Val v) a aa b ba (THROW NoSuchFieldError) a aa b False; ⋀C F t D v a aa b ba. ?P ⊢ C has F,NonStatic:t in D ⟹ ?P1.0 (C∙⇩sF{D} := Val v) a aa b ba (THROW IncompatibleClassChangeError) a aa b False; ⋀e a aa b ba e' ab ac bb b' M es. ⟦?P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ?P1.0 e a aa b ba e' ab ac bb b'⟧ ⟹ ?P1.0 (e∙M(es)) a aa b ba (e'∙M(es)) ab ac bb b'; ⋀es a aa b ba es' ab ac bb b' v M. ⟦?P ⊢ ⟨es,(a, aa, b),ba⟩ [→] ⟨es',(ab, ac, bb),b'⟩; ?P2.0 es a aa b ba es' ab ac bb b'⟧ ⟹ ?P1.0 (Val v∙M(es)) a aa b ba (Val v∙M(es')) ab ac bb b'; ⋀h a C fs M Ts T pns body D vs l sh b. ⟦h a = ⌊(C, fs)⌋; ?P ⊢ C sees M, NonStatic : Ts→T = (pns, body) in D; length vs = length pns; length Ts = length pns⟧ ⟹ ?P1.0 (addr a∙M(map Val vs)) h l sh b (blocks (this # pns, Class D # Ts, Addr a # vs, body)) h l sh b; ⋀M vs a aa b ba. ?P1.0 (null∙M(map Val vs)) a aa b ba (THROW NullPointer) a aa b ba; ⋀h a C fs M vs l sh b. ⟦h a = ⌊(C, fs)⌋; ∄b Ts T m D. ?P ⊢ C sees M, b : Ts→T = m in D⟧ ⟹ ?P1.0 (addr a∙M(map Val vs)) h l sh b (THROW NoSuchMethodError) h l sh b; ⋀h a C fs M Ts T aa b D vs l sh ba. ⟦h a = ⌊(C, fs)⌋; ?P ⊢ C sees M, Static : Ts→T = (aa, b) in D⟧ ⟹ ?P1.0 (addr a∙M(map Val vs)) h l sh ba (THROW IncompatibleClassChangeError) h l sh ba; ⋀es a aa b ba es' ab ac bb b' C M. ⟦?P ⊢ ⟨es,(a, aa, b),ba⟩ [→] ⟨es',(ab, ac, bb),b'⟩; ?P2.0 es a aa b ba es' ab ac bb b'⟧ ⟹ ?P1.0 (C∙⇩sM(es)) a aa b ba (C∙⇩sM(es')) ab ac bb b'; ⋀C M Ts T pns body D vs a aa b. ⟦?P ⊢ C sees M, Static : Ts→T = (pns, body) in D; length vs = length pns; length Ts = length pns⟧ ⟹ ?P1.0 (C∙⇩sM(map Val vs)) a aa b True (blocks (pns, Ts, vs, body)) a aa b False; ⋀C M Ts T pns body D sh sfs vs h l. ⟦?P ⊢ C sees M, Static : Ts→T = (pns, body) in D; sh D = ⌊(sfs, Done)⌋ ∨ M = clinit ∧ sh D = ⌊(sfs, Processing)⌋⟧ ⟹ ?P1.0 (C∙⇩sM(map Val vs)) h l sh False (C∙⇩sM(map Val vs)) h l sh True; ⋀C M Ts T pns body D sh vs h l. ⟦?P ⊢ C sees M, Static : Ts→T = (pns, body) in D; ∄sfs. sh D = ⌊(sfs, Done)⌋; M ≠ clinit⟧ ⟹ ?P1.0 (C∙⇩sM(map Val vs)) h l sh False (INIT D ([D],False) ← C∙⇩sM(map Val vs)) h l sh False; ⋀C M vs a aa b ba. ∄b Ts T m. Ex (Method ?P C M b Ts T m) ⟹ ?P1.0 (C∙⇩sM(map Val vs)) a aa b ba (THROW NoSuchMethodError) a aa b False; ⋀C M Ts T a b D vs aa ab ba bb. ?P ⊢ C sees M, NonStatic : Ts→T = (a, b) in D ⟹ ?P1.0 (C∙⇩sM(map Val vs)) aa ab ba bb (THROW IncompatibleClassChangeError) aa ab ba False; ⋀e h l V sh b e' h' l' sh' b' T. ⟦?P ⊢ ⟨e,(h, l(V := None), sh),b⟩ → ⟨e',(h', l', sh'),b'⟩; ?P1.0 e h (l(V := None)) sh b e' h' l' sh' b'; l' V = None; ¬ assigned V e⟧ ⟹ ?P1.0 {V:T; e} h l sh b {V:T; e'} h' (l'(V := l V)) sh' b'; ⋀e h l V sh b e' h' l' sh' b' v T. ⟦?P ⊢ ⟨e,(h, l(V := None), sh),b⟩ → ⟨e',(h', l', sh'),b'⟩; ?P1.0 e h (l(V := None)) sh b e' h' l' sh' b'; l' V = ⌊v⌋; ¬ assigned V e⟧ ⟹ ?P1.0 {V:T; e} h l sh b {V:T; V:=Val v;; e'} h' (l'(V := l V)) sh' b'; ⋀e h l V v sh b e' h' l' sh' b' v' T. ⟦?P ⊢ ⟨e,(h, l(V ↦ v), sh),b⟩ → ⟨e',(h', l', sh'),b'⟩; ?P1.0 e h (l(V ↦ v)) sh b e' h' l' sh' b'; l' V = ⌊v'⌋⟧ ⟹ ?P1.0 {V:T; V:=Val v;; e} h l sh b {V:T; V:=Val v';; e'} h' (l'(V := l V)) sh' b'; ⋀V T u a aa b ba. ?P1.0 {V:T; Val u} a aa b ba (Val u) a aa b ba; ⋀V T v u a aa b ba. ?P1.0 {V:T; V:=Val v;; Val u} a aa b ba (Val u) a aa b ba; ⋀e a aa b ba e' ab ac bb b' e₂. ⟦?P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ?P1.0 e a aa b ba e' ab ac bb b'⟧ ⟹ ?P1.0 (e;; e₂) a aa b ba (e';; e₂) ab ac bb b'; ⋀v e₂ a aa b ba. ?P1.0 (Val v;; e₂) a aa b ba e₂ a aa b ba; ⋀e a aa b ba e' ab ac bb b' e₁ e₂. ⟦?P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ?P1.0 e a aa b ba e' ab ac bb b'⟧ ⟹ ?P1.0 (if (e) e₁ else e₂) a aa b ba (if (e') e₁ else e₂) ab ac bb b'; ⋀e₁ e₂ a aa b ba. ?P1.0 (if (true) e₁ else e₂) a aa b ba e₁ a aa b ba; ⋀e₁ e₂ a aa b ba. ?P1.0 (if (false) e₁ else e₂) a aa b ba e₂ a aa b ba; ⋀b c a aa ba b'. ?P1.0 (while (b) c) a aa ba b' (if (b) (c;; while (b) c) else unit) a aa ba b'; ⋀e a aa b ba e' ab ac bb b'. ⟦?P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ?P1.0 e a aa b ba e' ab ac bb b'⟧ ⟹ ?P1.0 (throw e) a aa b ba (throw e') ab ac bb b'; ⋀a aa b ba. ?P1.0 (throw null) a aa b ba (THROW NullPointer) a aa b ba; ⋀e a aa b ba e' ab ac bb b' C V e₂. ⟦?P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ?P1.0 e a aa b ba e' ab ac bb b'⟧ ⟹ ?P1.0 (try e catch(C V) e₂) a aa b ba (try e' catch(C V) e₂) ab ac bb b'; ⋀v C V e₂ a aa b ba. ?P1.0 (try Val v catch(C V) e₂) a aa b ba (Val v) a aa b ba; ⋀a aa b ab D fs C V e₂ ba. ⟦hp (a, aa, b) ab = ⌊(D, fs)⌋; ?P ⊢ D ≼⇧* C⟧ ⟹ ?P1.0 (try Throw ab catch(C V) e₂) a aa b ba {V:Class C; V:=addr ab;; e₂} a aa b ba; ⋀a aa b ab D fs C V e₂ ba. ⟦hp (a, aa, b) ab = ⌊(D, fs)⌋; (D, C) ∉ (subcls1 ?P)⇧*⟧ ⟹ ?P1.0 (try Throw ab catch(C V) e₂) a aa b ba (Throw ab) a aa b ba; ⋀e a aa b ba e' ab ac bb b' es. ⟦?P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ?P1.0 e a aa b ba e' ab ac bb b'⟧ ⟹ ?P2.0 (e # es) a aa b ba (e' # es) ab ac bb b'; ⋀es a aa b ba es' ab ac bb b' v. ⟦?P ⊢ ⟨es,(a, aa, b),ba⟩ [→] ⟨es',(ab, ac, bb),b'⟩; ?P2.0 es a aa b ba es' ab ac bb b'⟧ ⟹ ?P2.0 (Val v # es) a aa b ba (Val v # es') ab ac bb b'; ⋀e C b a aa ba b'. ¬ sub_RI e ⟹ ?P1.0 (INIT C ([],b) ← e) a aa ba b' e a aa ba (icheck ?P C e); ⋀sh C C' Cs e h l b. sh C = None ⟹ ?P1.0 (INIT C' (C # Cs,False) ← e) h l sh b (INIT C' (C # Cs,False) ← e) h l (sh(C ↦ (sblank ?P C, Prepared))) b; ⋀sh C sfs C' Cs e h l b. sh C = ⌊(sfs, Done)⌋ ⟹ ?P1.0 (INIT C' (C # Cs,False) ← e) h l sh b (INIT C' (Cs,True) ← e) h l sh b; ⋀sh C sfs C' Cs e h l b. sh C = ⌊(sfs, Processing)⌋ ⟹ ?P1.0 (INIT C' (C # Cs,False) ← e) h l sh b (INIT C' (Cs,True) ← e) h l sh b; ⋀sh C sfs C' Cs e h l b. sh C = ⌊(sfs, Error)⌋ ⟹ ?P1.0 (INIT C' (C # Cs,False) ← e) h l sh b (RI (C,THROW NoClassDefFoundError) ; Cs ← e) h l sh b; ⋀sh C sfs sh' C' Cs e h l b. ⟦sh C = ⌊(sfs, Prepared)⌋; C = Object; sh' = sh(C ↦ (sfs, Processing))⟧ ⟹ ?P1.0 (INIT C' (C # Cs,False) ← e) h l sh b (INIT C' (C # Cs,True) ← e) h l sh' b; ⋀sh C sfs D a b sh' C' Cs e h l ba. ⟦sh C = ⌊(sfs, Prepared)⌋; C ≠ Object; class ?P C = ⌊(D, a, b)⌋; sh' = sh(C ↦ (sfs, Processing))⟧ ⟹ ?P1.0 (INIT C' (C # Cs,False) ← e) h l sh ba (INIT C' (D # C # Cs,False) ← e) h l sh' ba; ⋀C' C Cs e h l sh b. ?P1.0 (INIT C' (C # Cs,True) ← e) h l sh b (RI (C,C∙⇩sclinit([])) ; Cs ← e) h l sh b; ⋀e a aa b ba e' ab ac bb b' C Cs e₀. ⟦?P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ?P1.0 e a aa b ba e' ab ac bb b'⟧ ⟹ ?P1.0 (RI (C,e) ; Cs ← e₀) a aa b ba (RI (C,e') ; Cs ← e₀) ab ac bb b'; ⋀sh C sfs i sh' C' Cs v e h l b. ⟦sh C = ⌊(sfs, i)⌋; sh' = sh(C ↦ (sfs, Done)); C' = last (C # Cs)⟧ ⟹ ?P1.0 (RI (C,Val v) ; Cs ← e) h l sh b (INIT C' (Cs,True) ← e) h l sh' b; ⋀C e a aa b ba. ?P1.0 (Cast C (throw e)) a aa b ba (throw e) a aa b ba; ⋀e bop e₂ a aa b ba. ?P1.0 (throw e «bop» e₂) a aa b ba (throw e) a aa b ba; ⋀v₁ bop e a aa b ba. ?P1.0 (Val v₁ «bop» throw e) a aa b ba (throw e) a aa b ba; ⋀V e a aa b ba. ?P1.0 (V:=throw e) a aa b ba (throw e) a aa b ba; ⋀e F D a aa b ba. ?P1.0 (throw e∙F{D}) a aa b ba (throw e) a aa b ba; ⋀e F D e₂ a aa b ba. ?P1.0 (throw e∙F{D} := e₂) a aa b ba (throw e) a aa b ba; ⋀v F D e a aa b ba. ?P1.0 (Val v∙F{D} := throw e) a aa b ba (throw e) a aa b ba; ⋀C F D e a aa b ba. ?P1.0 (C∙⇩sF{D} := throw e) a aa b ba (throw e) a aa b ba; ⋀e M es a aa b ba. ?P1.0 (throw e∙M(es)) a aa b ba (throw e) a aa b ba; ⋀es vs e es' v M a aa b ba. es = map Val vs @ throw e # es' ⟹ ?P1.0 (Val v∙M(es)) a aa b ba (throw e) a aa b ba; ⋀es vs e es' C M a aa b ba. es = map Val vs @ throw e # es' ⟹ ?P1.0 (C∙⇩sM(es)) a aa b ba (throw e) a aa b ba; ⋀V T a aa ab b ba. ?P1.0 {V:T; Throw a} aa ab b ba (Throw a) aa ab b ba; ⋀V T v a aa ab b ba. ?P1.0 {V:T; V:=Val v;; Throw a} aa ab b ba (Throw a) aa ab b ba; ⋀e e₂ a aa b ba. ?P1.0 (throw e;; e₂) a aa b ba (throw e) a aa b ba; ⋀e e₁ e₂ a aa b ba. ?P1.0 (if (throw e) e₁ else e₂) a aa b ba (throw e) a aa b ba; ⋀e a aa b ba. ?P1.0 (throw (throw e)) a aa b ba (throw e) a aa b ba; ⋀sh C sfs i sh' a D Cs e h l b. ⟦sh C = ⌊(sfs, i)⌋; sh' = sh(C ↦ (sfs, Error))⟧ ⟹ ?P1.0 (RI (C,Throw a) ; D # Cs ← e) h l sh b (RI (D,Throw a) ; Cs ← e) h l sh' b; ⋀sh C sfs i sh' a e h l b. ⟦sh C = ⌊(sfs, i)⌋; sh' = sh(C ↦ (sfs, Error))⟧ ⟹ ?P1.0 (RI (C,Throw a) ; [] ← e) h l sh b (Throw a) h l sh' b⟧ ⟹ ?P1.0 ?x1a ?x2a ?x2b ?x2c ?x3a ?x4a ?x5a ?x5b ?x5c ?x6a› ‹⟦?P ⊢ ⟨?x7a,(?x8a, ?x8b, ?x8c),?x9a⟩ [→] ⟨?x10a,(?x11a, ?x11b, ?x11c),?x12a⟩; ⋀h a C FDTs h' l sh. ⟦new_Addr h = ⌊a⌋; ?P ⊢ C has_fields FDTs; h' = h(a ↦ blank ?P C)⟧ ⟹ ?P1.0 (new C) h l sh True (addr a) h' l sh False; ⋀h C l sh. ⟦new_Addr h = None; is_class ?P C⟧ ⟹ ?P1.0 (new C) h l sh True (THROW OutOfMemory) h l sh False; ⋀sh C sfs h l. sh C = ⌊(sfs, Done)⌋ ⟹ ?P1.0 (new C) h l sh False (new C) h l sh True; ⋀sh C h l. ⟦∄sfs. sh C = ⌊(sfs, Done)⌋; is_class ?P C⟧ ⟹ ?P1.0 (new C) h l sh False (INIT C ([C],False) ← new C) h l sh False; ⋀e a aa b ba e' ab ac bb b' C. ⟦?P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ?P1.0 e a aa b ba e' ab ac bb b'⟧ ⟹ ?P1.0 (Cast C e) a aa b ba (Cast C e') ab ac bb b'; ⋀C a aa b ba. ?P1.0 (Cast C null) a aa b ba null a aa b ba; ⋀h a D fs C l sh b. ⟦h a = ⌊(D, fs)⌋; ?P ⊢ D ≼⇧* C⟧ ⟹ ?P1.0 (Cast C (addr a)) h l sh b (addr a) h l sh b; ⋀h a D fs C l sh b. ⟦h a = ⌊(D, fs)⌋; (D, C) ∉ (subcls1 ?P)⇧*⟧ ⟹ ?P1.0 (Cast C (addr a)) h l sh b (THROW ClassCast) h l sh b; ⋀e a aa b ba e' ab ac bb b' bop e₂. ⟦?P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ?P1.0 e a aa b ba e' ab ac bb b'⟧ ⟹ ?P1.0 (e «bop» e₂) a aa b ba (e' «bop» e₂) ab ac bb b'; ⋀e a aa b ba e' ab ac bb b' v₁ bop. ⟦?P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ?P1.0 e a aa b ba e' ab ac bb b'⟧ ⟹ ?P1.0 (Val v₁ «bop» e) a aa b ba (Val v₁ «bop» e') ab ac bb b'; ⋀bop v₁ v₂ v a aa b ba. binop (bop, v₁, v₂) = ⌊v⌋ ⟹ ?P1.0 (Val v₁ «bop» Val v₂) a aa b ba (Val v) a aa b ba; ⋀l V v h sh b. l V = ⌊v⌋ ⟹ ?P1.0 (Var V) h l sh b (Val v) h l sh b; ⋀e a aa b ba e' ab ac bb b' V. ⟦?P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ?P1.0 e a aa b ba e' ab ac bb b'⟧ ⟹ ?P1.0 (V:=e) a aa b ba (V:=e') ab ac bb b'; ⋀V v h l sh b. ?P1.0 (V:=Val v) h l sh b unit h (l(V ↦ v)) sh b; ⋀e a aa b ba e' ab ac bb b' F D. ⟦?P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ?P1.0 e a aa b ba e' ab ac bb b'⟧ ⟹ ?P1.0 (e∙F{D}) a aa b ba (e'∙F{D}) ab ac bb b'; ⋀h a C fs F D v t l sh b. ⟦h a = ⌊(C, fs)⌋; fs (F, D) = ⌊v⌋; ?P ⊢ C has F,NonStatic:t in D⟧ ⟹ ?P1.0 (addr a∙F{D}) h l sh b (Val v) h l sh b; ⋀F D a aa b ba. ?P1.0 (null∙F{D}) a aa b ba (THROW NullPointer) a aa b ba; ⋀h a C fs F D l sh b. ⟦h a = ⌊(C, fs)⌋; ∄b t. ?P ⊢ C has F,b:t in D⟧ ⟹ ?P1.0 (addr a∙F{D}) h l sh b (THROW NoSuchFieldError) h l sh b; ⋀h a C fs F t D l sh b. ⟦h a = ⌊(C, fs)⌋; ?P ⊢ C has F,Static:t in D⟧ ⟹ ?P1.0 (addr a∙F{D}) h l sh b (THROW IncompatibleClassChangeError) h l sh b; ⋀C F t D sh sfs i v h l. ⟦?P ⊢ C has F,Static:t in D; sh D = ⌊(sfs, i)⌋; sfs F = ⌊v⌋⟧ ⟹ ?P1.0 (C∙⇩sF{D}) h l sh True (Val v) h l sh False; ⋀C F t D sh sfs h l. ⟦?P ⊢ C has F,Static:t in D; sh D = ⌊(sfs, Done)⌋⟧ ⟹ ?P1.0 (C∙⇩sF{D}) h l sh False (C∙⇩sF{D}) h l sh True; ⋀C F t D sh h l. ⟦?P ⊢ C has F,Static:t in D; ∄sfs. sh D = ⌊(sfs, Done)⌋⟧ ⟹ ?P1.0 (C∙⇩sF{D}) h l sh False (INIT D ([D],False) ← C∙⇩sF{D}) h l sh False; ⋀C F D h l sh b. ∄b t. ?P ⊢ C has F,b:t in D ⟹ ?P1.0 (C∙⇩sF{D}) h l sh b (THROW NoSuchFieldError) h l sh False; ⋀C F t D h l sh b. ?P ⊢ C has F,NonStatic:t in D ⟹ ?P1.0 (C∙⇩sF{D}) h l sh b (THROW IncompatibleClassChangeError) h l sh False; ⋀e a aa b ba e' ab ac bb b' F D e₂. ⟦?P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ?P1.0 e a aa b ba e' ab ac bb b'⟧ ⟹ ?P1.0 (e∙F{D} := e₂) a aa b ba (e'∙F{D} := e₂) ab ac bb b'; ⋀e a aa b ba e' ab ac bb b' v F D. ⟦?P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ?P1.0 e a aa b ba e' ab ac bb b'⟧ ⟹ ?P1.0 (Val v∙F{D} := e) a aa b ba (Val v∙F{D} := e') ab ac bb b'; ⋀C F t D h a fs v l sh b. ⟦?P ⊢ C has F,NonStatic:t in D; h a = ⌊(C, fs)⌋⟧ ⟹ ?P1.0 (addr a∙F{D} := Val v) h l sh b unit (h(a ↦ (C, fs((F, D) ↦ v)))) l sh b; ⋀F D v a aa b ba. ?P1.0 (null∙F{D} := Val v) a aa b ba (THROW NullPointer) a aa b ba; ⋀h a C fs F D v l sh b. ⟦h a = ⌊(C, fs)⌋; ∄b t. ?P ⊢ C has F,b:t in D⟧ ⟹ ?P1.0 (addr a∙F{D} := Val v) h l sh b (THROW NoSuchFieldError) h l sh b; ⋀h a C fs F t D v l sh b. ⟦h a = ⌊(C, fs)⌋; ?P ⊢ C has F,Static:t in D⟧ ⟹ ?P1.0 (addr a∙F{D} := Val v) h l sh b (THROW IncompatibleClassChangeError) h l sh b; ⋀e a aa b ba e' ab ac bb b' C F D. ⟦?P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ?P1.0 e a aa b ba e' ab ac bb b'⟧ ⟹ ?P1.0 (C∙⇩sF{D} := e) a aa b ba (C∙⇩sF{D} := e') ab ac bb b'; ⋀C F t D sh sfs i sfs' v sh' h l. ⟦?P ⊢ C has F,Static:t in D; sh D = ⌊(sfs, i)⌋; sfs' = sfs(F ↦ v); sh' = sh(D ↦ (sfs', i))⟧ ⟹ ?P1.0 (C∙⇩sF{D} := Val v) h l sh True unit h l sh' False; ⋀C F t D sh sfs v h l. ⟦?P ⊢ C has F,Static:t in D; sh D = ⌊(sfs, Done)⌋⟧ ⟹ ?P1.0 (C∙⇩sF{D} := Val v) h l sh False (C∙⇩sF{D} := Val v) h l sh True; ⋀C F t D sh v h l. ⟦?P ⊢ C has F,Static:t in D; ∄sfs. sh D = ⌊(sfs, Done)⌋⟧ ⟹ ?P1.0 (C∙⇩sF{D} := Val v) h l sh False (INIT D ([D],False) ← C∙⇩sF{D} := Val v) h l sh False; ⋀C F D v a aa b ba. ∄b t. ?P ⊢ C has F,b:t in D ⟹ ?P1.0 (C∙⇩sF{D} := Val v) a aa b ba (THROW NoSuchFieldError) a aa b False; ⋀C F t D v a aa b ba. ?P ⊢ C has F,NonStatic:t in D ⟹ ?P1.0 (C∙⇩sF{D} := Val v) a aa b ba (THROW IncompatibleClassChangeError) a aa b False; ⋀e a aa b ba e' ab ac bb b' M es. ⟦?P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ?P1.0 e a aa b ba e' ab ac bb b'⟧ ⟹ ?P1.0 (e∙M(es)) a aa b ba (e'∙M(es)) ab ac bb b'; ⋀es a aa b ba es' ab ac bb b' v M. ⟦?P ⊢ ⟨es,(a, aa, b),ba⟩ [→] ⟨es',(ab, ac, bb),b'⟩; ?P2.0 es a aa b ba es' ab ac bb b'⟧ ⟹ ?P1.0 (Val v∙M(es)) a aa b ba (Val v∙M(es')) ab ac bb b'; ⋀h a C fs M Ts T pns body D vs l sh b. ⟦h a = ⌊(C, fs)⌋; ?P ⊢ C sees M, NonStatic : Ts→T = (pns, body) in D; length vs = length pns; length Ts = length pns⟧ ⟹ ?P1.0 (addr a∙M(map Val vs)) h l sh b (blocks (this # pns, Class D # Ts, Addr a # vs, body)) h l sh b; ⋀M vs a aa b ba. ?P1.0 (null∙M(map Val vs)) a aa b ba (THROW NullPointer) a aa b ba; ⋀h a C fs M vs l sh b. ⟦h a = ⌊(C, fs)⌋; ∄b Ts T m D. ?P ⊢ C sees M, b : Ts→T = m in D⟧ ⟹ ?P1.0 (addr a∙M(map Val vs)) h l sh b (THROW NoSuchMethodError) h l sh b; ⋀h a C fs M Ts T aa b D vs l sh ba. ⟦h a = ⌊(C, fs)⌋; ?P ⊢ C sees M, Static : Ts→T = (aa, b) in D⟧ ⟹ ?P1.0 (addr a∙M(map Val vs)) h l sh ba (THROW IncompatibleClassChangeError) h l sh ba; ⋀es a aa b ba es' ab ac bb b' C M. ⟦?P ⊢ ⟨es,(a, aa, b),ba⟩ [→] ⟨es',(ab, ac, bb),b'⟩; ?P2.0 es a aa b ba es' ab ac bb b'⟧ ⟹ ?P1.0 (C∙⇩sM(es)) a aa b ba (C∙⇩sM(es')) ab ac bb b'; ⋀C M Ts T pns body D vs a aa b. ⟦?P ⊢ C sees M, Static : Ts→T = (pns, body) in D; length vs = length pns; length Ts = length pns⟧ ⟹ ?P1.0 (C∙⇩sM(map Val vs)) a aa b True (blocks (pns, Ts, vs, body)) a aa b False; ⋀C M Ts T pns body D sh sfs vs h l. ⟦?P ⊢ C sees M, Static : Ts→T = (pns, body) in D; sh D = ⌊(sfs, Done)⌋ ∨ M = clinit ∧ sh D = ⌊(sfs, Processing)⌋⟧ ⟹ ?P1.0 (C∙⇩sM(map Val vs)) h l sh False (C∙⇩sM(map Val vs)) h l sh True; ⋀C M Ts T pns body D sh vs h l. ⟦?P ⊢ C sees M, Static : Ts→T = (pns, body) in D; ∄sfs. sh D = ⌊(sfs, Done)⌋; M ≠ clinit⟧ ⟹ ?P1.0 (C∙⇩sM(map Val vs)) h l sh False (INIT D ([D],False) ← C∙⇩sM(map Val vs)) h l sh False; ⋀C M vs a aa b ba. ∄b Ts T m. Ex (Method ?P C M b Ts T m) ⟹ ?P1.0 (C∙⇩sM(map Val vs)) a aa b ba (THROW NoSuchMethodError) a aa b False; ⋀C M Ts T a b D vs aa ab ba bb. ?P ⊢ C sees M, NonStatic : Ts→T = (a, b) in D ⟹ ?P1.0 (C∙⇩sM(map Val vs)) aa ab ba bb (THROW IncompatibleClassChangeError) aa ab ba False; ⋀e h l V sh b e' h' l' sh' b' T. ⟦?P ⊢ ⟨e,(h, l(V := None), sh),b⟩ → ⟨e',(h', l', sh'),b'⟩; ?P1.0 e h (l(V := None)) sh b e' h' l' sh' b'; l' V = None; ¬ assigned V e⟧ ⟹ ?P1.0 {V:T; e} h l sh b {V:T; e'} h' (l'(V := l V)) sh' b'; ⋀e h l V sh b e' h' l' sh' b' v T. ⟦?P ⊢ ⟨e,(h, l(V := None), sh),b⟩ → ⟨e',(h', l', sh'),b'⟩; ?P1.0 e h (l(V := None)) sh b e' h' l' sh' b'; l' V = ⌊v⌋; ¬ assigned V e⟧ ⟹ ?P1.0 {V:T; e} h l sh b {V:T; V:=Val v;; e'} h' (l'(V := l V)) sh' b'; ⋀e h l V v sh b e' h' l' sh' b' v' T. ⟦?P ⊢ ⟨e,(h, l(V ↦ v), sh),b⟩ → ⟨e',(h', l', sh'),b'⟩; ?P1.0 e h (l(V ↦ v)) sh b e' h' l' sh' b'; l' V = ⌊v'⌋⟧ ⟹ ?P1.0 {V:T; V:=Val v;; e} h l sh b {V:T; V:=Val v';; e'} h' (l'(V := l V)) sh' b'; ⋀V T u a aa b ba. ?P1.0 {V:T; Val u} a aa b ba (Val u) a aa b ba; ⋀V T v u a aa b ba. ?P1.0 {V:T; V:=Val v;; Val u} a aa b ba (Val u) a aa b ba; ⋀e a aa b ba e' ab ac bb b' e₂. ⟦?P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ?P1.0 e a aa b ba e' ab ac bb b'⟧ ⟹ ?P1.0 (e;; e₂) a aa b ba (e';; e₂) ab ac bb b'; ⋀v e₂ a aa b ba. ?P1.0 (Val v;; e₂) a aa b ba e₂ a aa b ba; ⋀e a aa b ba e' ab ac bb b' e₁ e₂. ⟦?P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ?P1.0 e a aa b ba e' ab ac bb b'⟧ ⟹ ?P1.0 (if (e) e₁ else e₂) a aa b ba (if (e') e₁ else e₂) ab ac bb b'; ⋀e₁ e₂ a aa b ba. ?P1.0 (if (true) e₁ else e₂) a aa b ba e₁ a aa b ba; ⋀e₁ e₂ a aa b ba. ?P1.0 (if (false) e₁ else e₂) a aa b ba e₂ a aa b ba; ⋀b c a aa ba b'. ?P1.0 (while (b) c) a aa ba b' (if (b) (c;; while (b) c) else unit) a aa ba b'; ⋀e a aa b ba e' ab ac bb b'. ⟦?P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ?P1.0 e a aa b ba e' ab ac bb b'⟧ ⟹ ?P1.0 (throw e) a aa b ba (throw e') ab ac bb b'; ⋀a aa b ba. ?P1.0 (throw null) a aa b ba (THROW NullPointer) a aa b ba; ⋀e a aa b ba e' ab ac bb b' C V e₂. ⟦?P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ?P1.0 e a aa b ba e' ab ac bb b'⟧ ⟹ ?P1.0 (try e catch(C V) e₂) a aa b ba (try e' catch(C V) e₂) ab ac bb b'; ⋀v C V e₂ a aa b ba. ?P1.0 (try Val v catch(C V) e₂) a aa b ba (Val v) a aa b ba; ⋀a aa b ab D fs C V e₂ ba. ⟦hp (a, aa, b) ab = ⌊(D, fs)⌋; ?P ⊢ D ≼⇧* C⟧ ⟹ ?P1.0 (try Throw ab catch(C V) e₂) a aa b ba {V:Class C; V:=addr ab;; e₂} a aa b ba; ⋀a aa b ab D fs C V e₂ ba. ⟦hp (a, aa, b) ab = ⌊(D, fs)⌋; (D, C) ∉ (subcls1 ?P)⇧*⟧ ⟹ ?P1.0 (try Throw ab catch(C V) e₂) a aa b ba (Throw ab) a aa b ba; ⋀e a aa b ba e' ab ac bb b' es. ⟦?P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ?P1.0 e a aa b ba e' ab ac bb b'⟧ ⟹ ?P2.0 (e # es) a aa b ba (e' # es) ab ac bb b'; ⋀es a aa b ba es' ab ac bb b' v. ⟦?P ⊢ ⟨es,(a, aa, b),ba⟩ [→] ⟨es',(ab, ac, bb),b'⟩; ?P2.0 es a aa b ba es' ab ac bb b'⟧ ⟹ ?P2.0 (Val v # es) a aa b ba (Val v # es') ab ac bb b'; ⋀e C b a aa ba b'. ¬ sub_RI e ⟹ ?P1.0 (INIT C ([],b) ← e) a aa ba b' e a aa ba (icheck ?P C e); ⋀sh C C' Cs e h l b. sh C = None ⟹ ?P1.0 (INIT C' (C # Cs,False) ← e) h l sh b (INIT C' (C # Cs,False) ← e) h l (sh(C ↦ (sblank ?P C, Prepared))) b; ⋀sh C sfs C' Cs e h l b. sh C = ⌊(sfs, Done)⌋ ⟹ ?P1.0 (INIT C' (C # Cs,False) ← e) h l sh b (INIT C' (Cs,True) ← e) h l sh b; ⋀sh C sfs C' Cs e h l b. sh C = ⌊(sfs, Processing)⌋ ⟹ ?P1.0 (INIT C' (C # Cs,False) ← e) h l sh b (INIT C' (Cs,True) ← e) h l sh b; ⋀sh C sfs C' Cs e h l b. sh C = ⌊(sfs, Error)⌋ ⟹ ?P1.0 (INIT C' (C # Cs,False) ← e) h l sh b (RI (C,THROW NoClassDefFoundError) ; Cs ← e) h l sh b; ⋀sh C sfs sh' C' Cs e h l b. ⟦sh C = ⌊(sfs, Prepared)⌋; C = Object; sh' = sh(C ↦ (sfs, Processing))⟧ ⟹ ?P1.0 (INIT C' (C # Cs,False) ← e) h l sh b (INIT C' (C # Cs,True) ← e) h l sh' b; ⋀sh C sfs D a b sh' C' Cs e h l ba. ⟦sh C = ⌊(sfs, Prepared)⌋; C ≠ Object; class ?P C = ⌊(D, a, b)⌋; sh' = sh(C ↦ (sfs, Processing))⟧ ⟹ ?P1.0 (INIT C' (C # Cs,False) ← e) h l sh ba (INIT C' (D # C # Cs,False) ← e) h l sh' ba; ⋀C' C Cs e h l sh b. ?P1.0 (INIT C' (C # Cs,True) ← e) h l sh b (RI (C,C∙⇩sclinit([])) ; Cs ← e) h l sh b; ⋀e a aa b ba e' ab ac bb b' C Cs e₀. ⟦?P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ?P1.0 e a aa b ba e' ab ac bb b'⟧ ⟹ ?P1.0 (RI (C,e) ; Cs ← e₀) a aa b ba (RI (C,e') ; Cs ← e₀) ab ac bb b'; ⋀sh C sfs i sh' C' Cs v e h l b. ⟦sh C = ⌊(sfs, i)⌋; sh' = sh(C ↦ (sfs, Done)); C' = last (C # Cs)⟧ ⟹ ?P1.0 (RI (C,Val v) ; Cs ← e) h l sh b (INIT C' (Cs,True) ← e) h l sh' b; ⋀C e a aa b ba. ?P1.0 (Cast C (throw e)) a aa b ba (throw e) a aa b ba; ⋀e bop e₂ a aa b ba. ?P1.0 (throw e «bop» e₂) a aa b ba (throw e) a aa b ba; ⋀v₁ bop e a aa b ba. ?P1.0 (Val v₁ «bop» throw e) a aa b ba (throw e) a aa b ba; ⋀V e a aa b ba. ?P1.0 (V:=throw e) a aa b ba (throw e) a aa b ba; ⋀e F D a aa b ba. ?P1.0 (throw e∙F{D}) a aa b ba (throw e) a aa b ba; ⋀e F D e₂ a aa b ba. ?P1.0 (throw e∙F{D} := e₂) a aa b ba (throw e) a aa b ba; ⋀v F D e a aa b ba. ?P1.0 (Val v∙F{D} := throw e) a aa b ba (throw e) a aa b ba; ⋀C F D e a aa b ba. ?P1.0 (C∙⇩sF{D} := throw e) a aa b ba (throw e) a aa b ba; ⋀e M es a aa b ba. ?P1.0 (throw e∙M(es)) a aa b ba (throw e) a aa b ba; ⋀es vs e es' v M a aa b ba. es = map Val vs @ throw e # es' ⟹ ?P1.0 (Val v∙M(es)) a aa b ba (throw e) a aa b ba; ⋀es vs e es' C M a aa b ba. es = map Val vs @ throw e # es' ⟹ ?P1.0 (C∙⇩sM(es)) a aa b ba (throw e) a aa b ba; ⋀V T a aa ab b ba. ?P1.0 {V:T; Throw a} aa ab b ba (Throw a) aa ab b ba; ⋀V T v a aa ab b ba. ?P1.0 {V:T; V:=Val v;; Throw a} aa ab b ba (Throw a) aa ab b ba; ⋀e e₂ a aa b ba. ?P1.0 (throw e;; e₂) a aa b ba (throw e) a aa b ba; ⋀e e₁ e₂ a aa b ba. ?P1.0 (if (throw e) e₁ else e₂) a aa b ba (throw e) a aa b ba; ⋀e a aa b ba. ?P1.0 (throw (throw e)) a aa b ba (throw e) a aa b ba; ⋀sh C sfs i sh' a D Cs e h l b. ⟦sh C = ⌊(sfs, i)⌋; sh' = sh(C ↦ (sfs, Error))⟧ ⟹ ?P1.0 (RI (C,Throw a) ; D # Cs ← e) h l sh b (RI (D,Throw a) ; Cs ← e) h l sh' b; ⋀sh C sfs i sh' a e h l b. ⟦sh C = ⌊(sfs, i)⌋; sh' = sh(C ↦ (sfs, Error))⟧ ⟹ ?P1.0 (RI (C,Throw a) ; [] ← e) h l sh b (Throw a) h l sh' b⟧ ⟹ ?P2.0 ?x7a ?x8a ?x8b ?x8c ?x9a ?x10a ?x11a ?x11b ?x11c ?x12a›*)) (*goals: 1. ‹⋀h a C FDTs h' l sh. ⟦new_Addr h = ⌊a⌋; P ⊢ C has_fields FDTs; h' = h(a ↦ blank P C)⟧ ⟹ h ⊴ h'› 2. ‹⋀h C l sh. ⟦new_Addr h = None; is_class P C⟧ ⟹ h ⊴ h› 3. ‹⋀sh C sfs h l. sh C = ⌊(sfs, Done)⌋ ⟹ h ⊴ h› 4. ‹⋀sh C h l. ⟦∄sfs. sh C = ⌊(sfs, Done)⌋; is_class P C⟧ ⟹ h ⊴ h› 5. ‹⋀e a aa b ba e' ab ac bb b' C. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; a ⊴ ab⟧ ⟹ a ⊴ ab› 6. ‹⋀C a aa b ba. a ⊴ a› 7. ‹⋀h a D fs C l sh b. ⟦h a = ⌊(D, fs)⌋; P ⊢ D ≼⇧* C⟧ ⟹ h ⊴ h› 8. ‹⋀h a D fs C l sh b. ⟦h a = ⌊(D, fs)⌋; (D, C) ∉ (subcls1 P)⇧*⟧ ⟹ h ⊴ h› 9. ‹⋀e a aa b ba e' ab ac bb b' bop e₂. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; a ⊴ ab⟧ ⟹ a ⊴ ab› 10. ‹⋀e a aa b ba e' ab ac bb b' v₁ bop. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; a ⊴ ab⟧ ⟹ a ⊴ ab› 11. ‹⋀bop v₁ v₂ v a aa b ba. binop (bop, v₁, v₂) = ⌊v⌋ ⟹ a ⊴ a› 12. ‹⋀l V v h sh b. l V = ⌊v⌋ ⟹ h ⊴ h› 13. ‹⋀e a aa b ba e' ab ac bb b' V. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; a ⊴ ab⟧ ⟹ a ⊴ ab› 14. ‹⋀V v h l sh b. h ⊴ h› 15. ‹⋀e a aa b ba e' ab ac bb b' F D. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; a ⊴ ab⟧ ⟹ a ⊴ ab› 16. ‹⋀h a C fs F D v t l sh b. ⟦h a = ⌊(C, fs)⌋; fs (F, D) = ⌊v⌋; P ⊢ C has F,NonStatic:t in D⟧ ⟹ h ⊴ h› 17. ‹⋀F D a aa b ba. a ⊴ a› 18. ‹⋀h a C fs F D l sh b. ⟦h a = ⌊(C, fs)⌋; ∄b t. P ⊢ C has F,b:t in D⟧ ⟹ h ⊴ h› 19. ‹⋀h a C fs F t D l sh b. ⟦h a = ⌊(C, fs)⌋; P ⊢ C has F,Static:t in D⟧ ⟹ h ⊴ h› 20. ‹⋀C F t D sh sfs i v h l. ⟦P ⊢ C has F,Static:t in D; sh D = ⌊(sfs, i)⌋; sfs F = ⌊v⌋⟧ ⟹ h ⊴ h› 21. ‹⋀C F t D sh sfs h l. ⟦P ⊢ C has F,Static:t in D; sh D = ⌊(sfs, Done)⌋⟧ ⟹ h ⊴ h› 22. ‹⋀C F t D sh h l. ⟦P ⊢ C has F,Static:t in D; ∄sfs. sh D = ⌊(sfs, Done)⌋⟧ ⟹ h ⊴ h› 23. ‹⋀C F D h l sh b. ∄b t. P ⊢ C has F,b:t in D ⟹ h ⊴ h› 24. ‹⋀C F t D h l sh b. P ⊢ C has F,NonStatic:t in D ⟹ h ⊴ h› 25. ‹⋀e a aa b ba e' ab ac bb b' F D e₂. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; a ⊴ ab⟧ ⟹ a ⊴ ab› 26. ‹⋀e a aa b ba e' ab ac bb b' v F D. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; a ⊴ ab⟧ ⟹ a ⊴ ab› 27. ‹⋀C F t D h a fs v l sh b. ⟦P ⊢ C has F,NonStatic:t in D; h a = ⌊(C, fs)⌋⟧ ⟹ h ⊴ h(a ↦ (C, fs((F, D) ↦ v)))› 28. ‹⋀F D v a aa b ba. a ⊴ a› 29. ‹⋀h a C fs F D v l sh b. ⟦h a = ⌊(C, fs)⌋; ∄b t. P ⊢ C has F,b:t in D⟧ ⟹ h ⊴ h› 30. ‹⋀h a C fs F t D v l sh b. ⟦h a = ⌊(C, fs)⌋; P ⊢ C has F,Static:t in D⟧ ⟹ h ⊴ h› 31. ‹⋀e a aa b ba e' ab ac bb b' C F D. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; a ⊴ ab⟧ ⟹ a ⊴ ab› 32. ‹⋀C F t D sh sfs i sfs' v sh' h l. ⟦P ⊢ C has F,Static:t in D; sh D = ⌊(sfs, i)⌋; sfs' = sfs(F ↦ v); sh' = sh(D ↦ (sfs', i))⟧ ⟹ h ⊴ h› 33. ‹⋀C F t D sh sfs v h l. ⟦P ⊢ C has F,Static:t in D; sh D = ⌊(sfs, Done)⌋⟧ ⟹ h ⊴ h› 34. ‹⋀C F t D sh v h l. ⟦P ⊢ C has F,Static:t in D; ∄sfs. sh D = ⌊(sfs, Done)⌋⟧ ⟹ h ⊴ h› 35. ‹⋀C F D v a aa b ba. ∄b t. P ⊢ C has F,b:t in D ⟹ a ⊴ a› 36. ‹⋀C F t D v a aa b ba. P ⊢ C has F,NonStatic:t in D ⟹ a ⊴ a› 37. ‹⋀e a aa b ba e' ab ac bb b' M es. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; a ⊴ ab⟧ ⟹ a ⊴ ab› 38. ‹⋀es a aa b ba es' ab ac bb b' v M. ⟦P ⊢ ⟨es,(a, aa, b),ba⟩ [→] ⟨es',(ab, ac, bb),b'⟩; a ⊴ ab⟧ ⟹ a ⊴ ab› 39. ‹⋀h a C fs M Ts T pns body D vs l sh b. ⟦h a = ⌊(C, fs)⌋; P ⊢ C sees M, NonStatic : Ts→T = (pns, body) in D; length vs = length pns; length Ts = length pns⟧ ⟹ h ⊴ h› 40. ‹⋀M vs a aa b ba. a ⊴ a› 41. ‹⋀h a C fs M vs l sh b. ⟦h a = ⌊(C, fs)⌋; ∄b Ts T m D. P ⊢ C sees M, b : Ts→T = m in D⟧ ⟹ h ⊴ h› 42. ‹⋀h a C fs M Ts T aa b D vs l sh ba. ⟦h a = ⌊(C, fs)⌋; P ⊢ C sees M, Static : Ts→T = (aa, b) in D⟧ ⟹ h ⊴ h› 43. ‹⋀es a aa b ba es' ab ac bb b' C M. ⟦P ⊢ ⟨es,(a, aa, b),ba⟩ [→] ⟨es',(ab, ac, bb),b'⟩; a ⊴ ab⟧ ⟹ a ⊴ ab› 44. ‹⋀C M Ts T pns body D vs a aa b. ⟦P ⊢ C sees M, Static : Ts→T = (pns, body) in D; length vs = length pns; length Ts = length pns⟧ ⟹ a ⊴ a› 45. ‹⋀C M Ts T pns body D sh sfs vs h l. ⟦P ⊢ C sees M, Static : Ts→T = (pns, body) in D; sh D = ⌊(sfs, Done)⌋ ∨ M = clinit ∧ sh D = ⌊(sfs, Processing)⌋⟧ ⟹ h ⊴ h› 46. ‹⋀C M Ts T pns body D sh vs h l. ⟦P ⊢ C sees M, Static : Ts→T = (pns, body) in D; ∄sfs. sh D = ⌊(sfs, Done)⌋; M ≠ clinit⟧ ⟹ h ⊴ h› 47. ‹⋀C M vs a aa b ba. ∄b Ts T m. Ex (Method P C M b Ts T m) ⟹ a ⊴ a› 48. ‹⋀C M Ts T a b D vs aa ab ba bb. P ⊢ C sees M, NonStatic : Ts→T = (a, b) in D ⟹ aa ⊴ aa› 49. ‹⋀e h l V sh b e' h' l' sh' b' T. ⟦P ⊢ ⟨e,(h, l(V := None), sh),b⟩ → ⟨e',(h', l', sh'),b'⟩; h ⊴ h'; l' V = None; ¬ assigned V e⟧ ⟹ h ⊴ h'› 50. ‹⋀e h l V sh b e' h' l' sh' b' v T. ⟦P ⊢ ⟨e,(h, l(V := None), sh),b⟩ → ⟨e',(h', l', sh'),b'⟩; h ⊴ h'; l' V = ⌊v⌋; ¬ assigned V e⟧ ⟹ h ⊴ h'› 51. ‹⋀e h l V v sh b e' h' l' sh' b' v' T. ⟦P ⊢ ⟨e,(h, l(V ↦ v), sh),b⟩ → ⟨e',(h', l', sh'),b'⟩; h ⊴ h'; l' V = ⌊v'⌋⟧ ⟹ h ⊴ h'› 52. ‹⋀V T u a aa b ba. a ⊴ a› 53. ‹⋀V T v u a aa b ba. a ⊴ a› 54. ‹⋀e a aa b ba e' ab ac bb b' e₂. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; a ⊴ ab⟧ ⟹ a ⊴ ab› 55. ‹⋀v e₂ a aa b ba. a ⊴ a› 56. ‹⋀e a aa b ba e' ab ac bb b' e₁ e₂. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; a ⊴ ab⟧ ⟹ a ⊴ ab› 57. ‹⋀e₁ e₂ a aa b ba. a ⊴ a› 58. ‹⋀e₁ e₂ a aa b ba. a ⊴ a› 59. ‹⋀b c a aa ba b'. a ⊴ a› 60. ‹⋀e a aa b ba e' ab ac bb b'. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; a ⊴ ab⟧ ⟹ a ⊴ ab› 61. ‹⋀a aa b ba. a ⊴ a› 62. ‹⋀e a aa b ba e' ab ac bb b' C V e₂. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; a ⊴ ab⟧ ⟹ a ⊴ ab› 63. ‹⋀v C V e₂ a aa b ba. a ⊴ a› 64. ‹⋀a aa b ab D fs C V e₂ ba. ⟦hp (a, aa, b) ab = ⌊(D, fs)⌋; P ⊢ D ≼⇧* C⟧ ⟹ a ⊴ a› 65. ‹⋀a aa b ab D fs C V e₂ ba. ⟦hp (a, aa, b) ab = ⌊(D, fs)⌋; (D, C) ∉ (subcls1 P)⇧*⟧ ⟹ a ⊴ a› 66. ‹⋀e a aa b ba e' ab ac bb b' es. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; a ⊴ ab⟧ ⟹ a ⊴ ab› 67. ‹⋀es a aa b ba es' ab ac bb b' v. ⟦P ⊢ ⟨es,(a, aa, b),ba⟩ [→] ⟨es',(ab, ac, bb),b'⟩; a ⊴ ab⟧ ⟹ a ⊴ ab› 68. ‹⋀e C b a aa ba b'. ¬ sub_RI e ⟹ a ⊴ a› 69. ‹⋀sh C C' Cs e h l b. sh C = None ⟹ h ⊴ h› 70. ‹⋀sh C sfs C' Cs e h l b. sh C = ⌊(sfs, Done)⌋ ⟹ h ⊴ h› 71. ‹⋀sh C sfs C' Cs e h l b. sh C = ⌊(sfs, Processing)⌋ ⟹ h ⊴ h› 72. ‹⋀sh C sfs C' Cs e h l b. sh C = ⌊(sfs, Error)⌋ ⟹ h ⊴ h› 73. ‹⋀sh C sfs sh' C' Cs e h l b. ⟦sh C = ⌊(sfs, Prepared)⌋; C = Object; sh' = sh(C ↦ (sfs, Processing))⟧ ⟹ h ⊴ h› 74. ‹⋀sh C sfs D a b sh' C' Cs e h l ba. ⟦sh C = ⌊(sfs, Prepared)⌋; C ≠ Object; class P C = ⌊(D, a, b)⌋; sh' = sh(C ↦ (sfs, Processing))⟧ ⟹ h ⊴ h› 75. ‹⋀C' C Cs e h l sh b. h ⊴ h› 76. ‹⋀e a aa b ba e' ab ac bb b' C Cs e₀. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; a ⊴ ab⟧ ⟹ a ⊴ ab› 77. ‹⋀sh C sfs i sh' C' Cs v e h l b. ⟦sh C = ⌊(sfs, i)⌋; sh' = sh(C ↦ (sfs, Done)); C' = last (C # Cs)⟧ ⟹ h ⊴ h› 78. ‹⋀C e a aa b ba. a ⊴ a› 79. ‹⋀e bop e₂ a aa b ba. a ⊴ a› 80. ‹⋀v₁ bop e a aa b ba. a ⊴ a› 81. ‹⋀V e a aa b ba. a ⊴ a› 82. ‹⋀e F D a aa b ba. a ⊴ a› 83. ‹⋀e F D e₂ a aa b ba. a ⊴ a› 84. ‹⋀v F D e a aa b ba. a ⊴ a› 85. ‹⋀C F D e a aa b ba. a ⊴ a› 86. ‹⋀e M es a aa b ba. a ⊴ a› 87. ‹⋀es vs e es' v M a aa b ba. es = map Val vs @ throw e # es' ⟹ a ⊴ a› 88. ‹⋀es vs e es' C M a aa b ba. es = map Val vs @ throw e # es' ⟹ a ⊴ a› 89. ‹⋀V T a aa ab b ba. aa ⊴ aa› 90. ‹⋀V T v a aa ab b ba. aa ⊴ aa› 91. ‹⋀e e₂ a aa b ba. a ⊴ a› 92. ‹⋀e e₁ e₂ a aa b ba. a ⊴ a› 93. ‹⋀e a aa b ba. a ⊴ a› 94. ‹⋀sh C sfs i sh' a D Cs e h l b. ⟦sh C = ⌊(sfs, i)⌋; sh' = sh(C ↦ (sfs, Error))⟧ ⟹ h ⊴ h› 95. ‹⋀sh C sfs i sh' a e h l b. ⟦sh C = ⌊(sfs, i)⌋; sh' = sh(C ↦ (sfs, Error))⟧ ⟹ h ⊴ h›*) case RedNew (*‹new_Addr (h_::heap) = ⌊a_::nat⌋› ‹P ⊢ C_ has_fields FDTs_› ‹h'_ = h_(a_ ↦ blank P C_)›*) thus "?case" (*goal: ‹h_ ⊴ h'_›*) by (fastforce dest:new_Addr_SomeD (*‹new_Addr (?h::heap) = ⌊?a::nat⌋ ⟹ ?h ?a = None›*) simp:hext_def (*‹(?h::heap) ⊴ (?h'::heap) ≡ ∀(a::nat) (C::char list) fs::Objects.fields. ?h a = ⌊(C, fs)⌋ ⟶ (∃fs'::Objects.fields. ?h' a = ⌊(C, fs')⌋)›*) 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. ‹⋀h C l sh. ⟦new_Addr h = None; is_class P C⟧ ⟹ h ⊴ h› 2. ‹⋀sh C sfs h l. sh C = ⌊(sfs, Done)⌋ ⟹ h ⊴ h› 3. ‹⋀sh C h l. ⟦∄sfs. sh C = ⌊(sfs, Done)⌋; is_class P C⟧ ⟹ h ⊴ h› 4. ‹⋀e a aa b ba e' ab ac bb b' C. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; a ⊴ ab⟧ ⟹ a ⊴ ab› 5. ‹⋀C a aa b ba. a ⊴ a› 6. ‹⋀h a D fs C l sh b. ⟦h a = ⌊(D, fs)⌋; P ⊢ D ≼⇧* C⟧ ⟹ h ⊴ h› 7. ‹⋀h a D fs C l sh b. ⟦h a = ⌊(D, fs)⌋; (D, C) ∉ (subcls1 P)⇧*⟧ ⟹ h ⊴ h› 8. ‹⋀e a aa b ba e' ab ac bb b' bop e₂. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; a ⊴ ab⟧ ⟹ a ⊴ ab› 9. ‹⋀e a aa b ba e' ab ac bb b' v₁ bop. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; a ⊴ ab⟧ ⟹ a ⊴ ab› 10. ‹⋀bop v₁ v₂ v a aa b ba. binop (bop, v₁, v₂) = ⌊v⌋ ⟹ a ⊴ a› 11. ‹⋀l V v h sh b. l V = ⌊v⌋ ⟹ h ⊴ h› 12. ‹⋀e a aa b ba e' ab ac bb b' V. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; a ⊴ ab⟧ ⟹ a ⊴ ab› 13. ‹⋀V v h l sh b. h ⊴ h› 14. ‹⋀e a aa b ba e' ab ac bb b' F D. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; a ⊴ ab⟧ ⟹ a ⊴ ab› 15. ‹⋀h a C fs F D v t l sh b. ⟦h a = ⌊(C, fs)⌋; fs (F, D) = ⌊v⌋; P ⊢ C has F,NonStatic:t in D⟧ ⟹ h ⊴ h› 16. ‹⋀F D a aa b ba. a ⊴ a› 17. ‹⋀h a C fs F D l sh b. ⟦h a = ⌊(C, fs)⌋; ∄b t. P ⊢ C has F,b:t in D⟧ ⟹ h ⊴ h› 18. ‹⋀h a C fs F t D l sh b. ⟦h a = ⌊(C, fs)⌋; P ⊢ C has F,Static:t in D⟧ ⟹ h ⊴ h› 19. ‹⋀C F t D sh sfs i v h l. ⟦P ⊢ C has F,Static:t in D; sh D = ⌊(sfs, i)⌋; sfs F = ⌊v⌋⟧ ⟹ h ⊴ h› 20. ‹⋀C F t D sh sfs h l. ⟦P ⊢ C has F,Static:t in D; sh D = ⌊(sfs, Done)⌋⟧ ⟹ h ⊴ h› 21. ‹⋀C F t D sh h l. ⟦P ⊢ C has F,Static:t in D; ∄sfs. sh D = ⌊(sfs, Done)⌋⟧ ⟹ h ⊴ h› 22. ‹⋀C F D h l sh b. ∄b t. P ⊢ C has F,b:t in D ⟹ h ⊴ h› 23. ‹⋀C F t D h l sh b. P ⊢ C has F,NonStatic:t in D ⟹ h ⊴ h› 24. ‹⋀e a aa b ba e' ab ac bb b' F D e₂. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; a ⊴ ab⟧ ⟹ a ⊴ ab› 25. ‹⋀e a aa b ba e' ab ac bb b' v F D. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; a ⊴ ab⟧ ⟹ a ⊴ ab› 26. ‹⋀C F t D h a fs v l sh b. ⟦P ⊢ C has F,NonStatic:t in D; h a = ⌊(C, fs)⌋⟧ ⟹ h ⊴ h(a ↦ (C, fs((F, D) ↦ v)))› 27. ‹⋀F D v a aa b ba. a ⊴ a› 28. ‹⋀h a C fs F D v l sh b. ⟦h a = ⌊(C, fs)⌋; ∄b t. P ⊢ C has F,b:t in D⟧ ⟹ h ⊴ h› 29. ‹⋀h a C fs F t D v l sh b. ⟦h a = ⌊(C, fs)⌋; P ⊢ C has F,Static:t in D⟧ ⟹ h ⊴ h› 30. ‹⋀e a aa b ba e' ab ac bb b' C F D. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; a ⊴ ab⟧ ⟹ a ⊴ ab› 31. ‹⋀C F t D sh sfs i sfs' v sh' h l. ⟦P ⊢ C has F,Static:t in D; sh D = ⌊(sfs, i)⌋; sfs' = sfs(F ↦ v); sh' = sh(D ↦ (sfs', i))⟧ ⟹ h ⊴ h› 32. ‹⋀C F t D sh sfs v h l. ⟦P ⊢ C has F,Static:t in D; sh D = ⌊(sfs, Done)⌋⟧ ⟹ h ⊴ h› 33. ‹⋀C F t D sh v h l. ⟦P ⊢ C has F,Static:t in D; ∄sfs. sh D = ⌊(sfs, Done)⌋⟧ ⟹ h ⊴ h› 34. ‹⋀C F D v a aa b ba. ∄b t. P ⊢ C has F,b:t in D ⟹ a ⊴ a› 35. ‹⋀C F t D v a aa b ba. P ⊢ C has F,NonStatic:t in D ⟹ a ⊴ a› 36. ‹⋀e a aa b ba e' ab ac bb b' M es. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; a ⊴ ab⟧ ⟹ a ⊴ ab› 37. ‹⋀es a aa b ba es' ab ac bb b' v M. ⟦P ⊢ ⟨es,(a, aa, b),ba⟩ [→] ⟨es',(ab, ac, bb),b'⟩; a ⊴ ab⟧ ⟹ a ⊴ ab› 38. ‹⋀h a C fs M Ts T pns body D vs l sh b. ⟦h a = ⌊(C, fs)⌋; P ⊢ C sees M, NonStatic : Ts→T = (pns, body) in D; length vs = length pns; length Ts = length pns⟧ ⟹ h ⊴ h› 39. ‹⋀M vs a aa b ba. a ⊴ a› 40. ‹⋀h a C fs M vs l sh b. ⟦h a = ⌊(C, fs)⌋; ∄b Ts T m D. P ⊢ C sees M, b : Ts→T = m in D⟧ ⟹ h ⊴ h› 41. ‹⋀h a C fs M Ts T aa b D vs l sh ba. ⟦h a = ⌊(C, fs)⌋; P ⊢ C sees M, Static : Ts→T = (aa, b) in D⟧ ⟹ h ⊴ h› 42. ‹⋀es a aa b ba es' ab ac bb b' C M. ⟦P ⊢ ⟨es,(a, aa, b),ba⟩ [→] ⟨es',(ab, ac, bb),b'⟩; a ⊴ ab⟧ ⟹ a ⊴ ab› 43. ‹⋀C M Ts T pns body D vs a aa b. ⟦P ⊢ C sees M, Static : Ts→T = (pns, body) in D; length vs = length pns; length Ts = length pns⟧ ⟹ a ⊴ a› 44. ‹⋀C M Ts T pns body D sh sfs vs h l. ⟦P ⊢ C sees M, Static : Ts→T = (pns, body) in D; sh D = ⌊(sfs, Done)⌋ ∨ M = clinit ∧ sh D = ⌊(sfs, Processing)⌋⟧ ⟹ h ⊴ h› 45. ‹⋀C M Ts T pns body D sh vs h l. ⟦P ⊢ C sees M, Static : Ts→T = (pns, body) in D; ∄sfs. sh D = ⌊(sfs, Done)⌋; M ≠ clinit⟧ ⟹ h ⊴ h› 46. ‹⋀C M vs a aa b ba. ∄b Ts T m. Ex (Method P C M b Ts T m) ⟹ a ⊴ a› 47. ‹⋀C M Ts T a b D vs aa ab ba bb. P ⊢ C sees M, NonStatic : Ts→T = (a, b) in D ⟹ aa ⊴ aa› 48. ‹⋀e h l V sh b e' h' l' sh' b' T. ⟦P ⊢ ⟨e,(h, l(V := None), sh),b⟩ → ⟨e',(h', l', sh'),b'⟩; h ⊴ h'; l' V = None; ¬ assigned V e⟧ ⟹ h ⊴ h'› 49. ‹⋀e h l V sh b e' h' l' sh' b' v T. ⟦P ⊢ ⟨e,(h, l(V := None), sh),b⟩ → ⟨e',(h', l', sh'),b'⟩; h ⊴ h'; l' V = ⌊v⌋; ¬ assigned V e⟧ ⟹ h ⊴ h'› 50. ‹⋀e h l V v sh b e' h' l' sh' b' v' T. ⟦P ⊢ ⟨e,(h, l(V ↦ v), sh),b⟩ → ⟨e',(h', l', sh'),b'⟩; h ⊴ h'; l' V = ⌊v'⌋⟧ ⟹ h ⊴ h'› 51. ‹⋀V T u a aa b ba. a ⊴ a› 52. ‹⋀V T v u a aa b ba. a ⊴ a› 53. ‹⋀e a aa b ba e' ab ac bb b' e₂. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; a ⊴ ab⟧ ⟹ a ⊴ ab› 54. ‹⋀v e₂ a aa b ba. a ⊴ a› 55. ‹⋀e a aa b ba e' ab ac bb b' e₁ e₂. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; a ⊴ ab⟧ ⟹ a ⊴ ab› 56. ‹⋀e₁ e₂ a aa b ba. a ⊴ a› 57. ‹⋀e₁ e₂ a aa b ba. a ⊴ a› 58. ‹⋀b c a aa ba b'. a ⊴ a› 59. ‹⋀e a aa b ba e' ab ac bb b'. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; a ⊴ ab⟧ ⟹ a ⊴ ab› 60. ‹⋀a aa b ba. a ⊴ a› 61. ‹⋀e a aa b ba e' ab ac bb b' C V e₂. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; a ⊴ ab⟧ ⟹ a ⊴ ab› 62. ‹⋀v C V e₂ a aa b ba. a ⊴ a› 63. ‹⋀a aa b ab D fs C V e₂ ba. ⟦hp (a, aa, b) ab = ⌊(D, fs)⌋; P ⊢ D ≼⇧* C⟧ ⟹ a ⊴ a› 64. ‹⋀a aa b ab D fs C V e₂ ba. ⟦hp (a, aa, b) ab = ⌊(D, fs)⌋; (D, C) ∉ (subcls1 P)⇧*⟧ ⟹ a ⊴ a› 65. ‹⋀e a aa b ba e' ab ac bb b' es. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; a ⊴ ab⟧ ⟹ a ⊴ ab› 66. ‹⋀es a aa b ba es' ab ac bb b' v. ⟦P ⊢ ⟨es,(a, aa, b),ba⟩ [→] ⟨es',(ab, ac, bb),b'⟩; a ⊴ ab⟧ ⟹ a ⊴ ab› 67. ‹⋀e C b a aa ba b'. ¬ sub_RI e ⟹ a ⊴ a› 68. ‹⋀sh C C' Cs e h l b. sh C = None ⟹ h ⊴ h› 69. ‹⋀sh C sfs C' Cs e h l b. sh C = ⌊(sfs, Done)⌋ ⟹ h ⊴ h› 70. ‹⋀sh C sfs C' Cs e h l b. sh C = ⌊(sfs, Processing)⌋ ⟹ h ⊴ h› 71. ‹⋀sh C sfs C' Cs e h l b. sh C = ⌊(sfs, Error)⌋ ⟹ h ⊴ h› 72. ‹⋀sh C sfs sh' C' Cs e h l b. ⟦sh C = ⌊(sfs, Prepared)⌋; C = Object; sh' = sh(C ↦ (sfs, Processing))⟧ ⟹ h ⊴ h› 73. ‹⋀sh C sfs D a b sh' C' Cs e h l ba. ⟦sh C = ⌊(sfs, Prepared)⌋; C ≠ Object; class P C = ⌊(D, a, b)⌋; sh' = sh(C ↦ (sfs, Processing))⟧ ⟹ h ⊴ h› 74. ‹⋀C' C Cs e h l sh b. h ⊴ h› 75. ‹⋀e a aa b ba e' ab ac bb b' C Cs e₀. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; a ⊴ ab⟧ ⟹ a ⊴ ab› 76. ‹⋀sh C sfs i sh' C' Cs v e h l b. ⟦sh C = ⌊(sfs, i)⌋; sh' = sh(C ↦ (sfs, Done)); C' = last (C # Cs)⟧ ⟹ h ⊴ h› 77. ‹⋀C e a aa b ba. a ⊴ a› 78. ‹⋀e bop e₂ a aa b ba. a ⊴ a› 79. ‹⋀v₁ bop e a aa b ba. a ⊴ a› 80. ‹⋀V e a aa b ba. a ⊴ a› 81. ‹⋀e F D a aa b ba. a ⊴ a› 82. ‹⋀e F D e₂ a aa b ba. a ⊴ a› 83. ‹⋀v F D e a aa b ba. a ⊴ a› 84. ‹⋀C F D e a aa b ba. a ⊴ a› 85. ‹⋀e M es a aa b ba. a ⊴ a› 86. ‹⋀es vs e es' v M a aa b ba. es = map Val vs @ throw e # es' ⟹ a ⊴ a› 87. ‹⋀es vs e es' C M a aa b ba. es = map Val vs @ throw e # es' ⟹ a ⊴ a› 88. ‹⋀V T a aa ab b ba. aa ⊴ aa› 89. ‹⋀V T v a aa ab b ba. aa ⊴ aa› 90. ‹⋀e e₂ a aa b ba. a ⊴ a› 91. ‹⋀e e₁ e₂ a aa b ba. a ⊴ a› 92. ‹⋀e a aa b ba. a ⊴ a› 93. ‹⋀sh C sfs i sh' a D Cs e h l b. ⟦sh C = ⌊(sfs, i)⌋; sh' = sh(C ↦ (sfs, Error))⟧ ⟹ h ⊴ h› 94. ‹⋀sh C sfs i sh' a e h l b. ⟦sh C = ⌊(sfs, i)⌋; sh' = sh(C ↦ (sfs, Error))⟧ ⟹ h ⊴ h›*) case RedFAss (*‹P ⊢ C_ has F_,NonStatic:t_ in D_› ‹h_ a_ = ⌊(C_, fs_)⌋›*) thus "?case" (*goal: ‹h_ ⊴ h_(a_ ↦ (C_, fs_((F_, D_) ↦ v_)))›*) by (simp add:hext_def (*‹?h ⊴ ?h' ≡ ∀a C fs. ?h a = ⌊(C, fs)⌋ ⟶ (∃fs'. ?h' a = ⌊(C, fs')⌋)›*) 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 (simp_all) (*solves the remaining goals: 1. ‹⋀(h::heap) (C::char list) (l::sfields) sh::sheap. ⟦new_Addr h = None; is_class (P::(char list list × char list exp) prog) C⟧ ⟹ h ⊴ h› 2. ‹⋀(sh::sheap) (C::char list) (sfs::sfields) (h::heap) l::sfields. sh C = ⌊(sfs, Done)⌋ ⟹ h ⊴ h› 3. ‹⋀(sh::sheap) (C::char list) (h::heap) l::sfields. ⟦∄sfs::sfields. sh C = ⌊(sfs, Done)⌋; is_class (P::(char list list × char list exp) prog) C⟧ ⟹ h ⊴ h› 4. ‹⋀(e::char list exp) (a::heap) (aa::sfields) (b::sheap) (ba::bool) (e'::char list exp) (ab::heap) (ac::sfields) (bb::sheap) (b'::bool) C::char list. ⟦(P::(char list list × char list exp) prog) ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; a ⊴ ab⟧ ⟹ a ⊴ ab› 5. ‹⋀(C::char list) (a::heap) (aa::sfields) (b::sheap) ba::bool. a ⊴ a› 6. ‹⋀(h::heap) (a::nat) (D::char list) (fs::Objects.fields) (C::char list) (l::sfields) (sh::sheap) b::bool. ⟦h a = ⌊(D, fs)⌋; (P::(char list list × char list exp) prog) ⊢ D ≼⇧* C⟧ ⟹ h ⊴ h› 7. ‹⋀(h::heap) (a::nat) (D::char list) (fs::Objects.fields) (C::char list) (l::sfields) (sh::sheap) b::bool. ⟦h a = ⌊(D, fs)⌋; (D, C) ∉ (subcls1 (P::(char list list × char list exp) prog))⇧*⟧ ⟹ h ⊴ h› 8. ‹⋀(e::char list exp) (a::heap) (aa::sfields) (b::sheap) (ba::bool) (e'::char list exp) (ab::heap) (ac::sfields) (bb::sheap) (b'::bool) (bop::bop) e₂::char list exp. ⟦(P::(char list list × char list exp) prog) ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; a ⊴ ab⟧ ⟹ a ⊴ ab› 9. ‹⋀(e::char list exp) (a::heap) (aa::sfields) (b::sheap) (ba::bool) (e'::char list exp) (ab::heap) (ac::sfields) (bb::sheap) (b'::bool) (v₁::val) bop::bop. ⟦(P::(char list list × char list exp) prog) ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; a ⊴ ab⟧ ⟹ a ⊴ ab› 10. ‹⋀(bop::bop) (v₁::val) (v₂::val) (v::val) (a::heap) (aa::sfields) (b::sheap) ba::bool. binop (bop, v₁, v₂) = ⌊v⌋ ⟹ a ⊴ a› 11. ‹⋀(l::sfields) (V::char list) (v::val) (h::heap) (sh::sheap) b::bool. l V = ⌊v⌋ ⟹ h ⊴ h› 12. ‹⋀(e::char list exp) (a::heap) (aa::sfields) (b::sheap) (ba::bool) (e'::char list exp) (ab::heap) (ac::sfields) (bb::sheap) (b'::bool) V::char list. ⟦(P::(char list list × char list exp) prog) ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; a ⊴ ab⟧ ⟹ a ⊴ ab› 13. ‹⋀(V::char list) (v::val) (h::heap) (l::sfields) (sh::sheap) b::bool. h ⊴ h› 14. ‹⋀(e::char list exp) (a::heap) (aa::sfields) (b::sheap) (ba::bool) (e'::char list exp) (ab::heap) (ac::sfields) (bb::sheap) (b'::bool) (F::char list) D::char list. ⟦(P::(char list list × char list exp) prog) ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; a ⊴ ab⟧ ⟹ a ⊴ ab› 15. ‹⋀(h::heap) (a::nat) (C::char list) (fs::Objects.fields) (F::char list) (D::char list) (v::val) (t::ty) (l::sfields) (sh::sheap) b::bool. ⟦h a = ⌊(C, fs)⌋; fs (F, D) = ⌊v⌋; (P::(char list list × char list exp) prog) ⊢ C has F,NonStatic:t in D⟧ ⟹ h ⊴ h› 16. ‹⋀(F::char list) (D::char list) (a::heap) (aa::sfields) (b::sheap) ba::bool. a ⊴ a› 17. ‹⋀(h::heap) (a::nat) (C::char list) (fs::Objects.fields) (F::char list) (D::char list) (l::sfields) (sh::sheap) b::bool. ⟦h a = ⌊(C, fs)⌋; ∄(b::staticb) t::ty. (P::(char list list × char list exp) prog) ⊢ C has F,b:t in D⟧ ⟹ h ⊴ h› 18. ‹⋀(h::heap) (a::nat) (C::char list) (fs::Objects.fields) (F::char list) (t::ty) (D::char list) (l::sfields) (sh::sheap) b::bool. ⟦h a = ⌊(C, fs)⌋; (P::(char list list × char list exp) prog) ⊢ C has F,Static:t in D⟧ ⟹ h ⊴ h› 19. ‹⋀(C::char list) (F::char list) (t::ty) (D::char list) (sh::sheap) (sfs::sfields) (i::init_state) (v::val) (h::heap) l::sfields. ⟦(P::(char list list × char list exp) prog) ⊢ C has F,Static:t in D; sh D = ⌊(sfs, i)⌋; sfs F = ⌊v⌋⟧ ⟹ h ⊴ h› 20. ‹⋀(C::char list) (F::char list) (t::ty) (D::char list) (sh::sheap) (sfs::sfields) (h::heap) l::sfields. ⟦(P::(char list list × char list exp) prog) ⊢ C has F,Static:t in D; sh D = ⌊(sfs, Done)⌋⟧ ⟹ h ⊴ h› 21. ‹⋀(C::char list) (F::char list) (t::ty) (D::char list) (sh::sheap) (h::heap) l::sfields. ⟦(P::(char list list × char list exp) prog) ⊢ C has F,Static:t in D; ∄sfs::sfields. sh D = ⌊(sfs, Done)⌋⟧ ⟹ h ⊴ h› 22. ‹⋀(C::char list) (F::char list) (D::char list) (h::heap) (l::sfields) (sh::sheap) b::bool. ∄(b::staticb) t::ty. (P::(char list list × char list exp) prog) ⊢ C has F,b:t in D ⟹ h ⊴ h› 23. ‹⋀(C::char list) (F::char list) (t::ty) (D::char list) (h::heap) (l::sfields) (sh::sheap) b::bool. (P::(char list list × char list exp) prog) ⊢ C has F,NonStatic:t in D ⟹ h ⊴ h› 24. ‹⋀(e::char list exp) (a::heap) (aa::sfields) (b::sheap) (ba::bool) (e'::char list exp) (ab::heap) (ac::sfields) (bb::sheap) (b'::bool) (F::char list) (D::char list) e₂::char list exp. ⟦(P::(char list list × char list exp) prog) ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; a ⊴ ab⟧ ⟹ a ⊴ ab› 25. ‹⋀(e::char list exp) (a::heap) (aa::sfields) (b::sheap) (ba::bool) (e'::char list exp) (ab::heap) (ac::sfields) (bb::sheap) (b'::bool) (v::val) (F::char list) D::char list. ⟦(P::(char list list × char list exp) prog) ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; a ⊴ ab⟧ ⟹ a ⊴ ab› 26. ‹⋀(F::char list) (D::char list) (v::val) (a::heap) (aa::sfields) (b::sheap) ba::bool. a ⊴ a› 27. ‹⋀(h::heap) (a::nat) (C::char list) (fs::Objects.fields) (F::char list) (D::char list) (v::val) (l::sfields) (sh::sheap) b::bool. ⟦h a = ⌊(C, fs)⌋; ∄(b::staticb) t::ty. (P::(char list list × char list exp) prog) ⊢ C has F,b:t in D⟧ ⟹ h ⊴ h› 28. ‹⋀(h::heap) (a::nat) (C::char list) (fs::Objects.fields) (F::char list) (t::ty) (D::char list) (v::val) (l::sfields) (sh::sheap) b::bool. ⟦h a = ⌊(C, fs)⌋; (P::(char list list × char list exp) prog) ⊢ C has F,Static:t in D⟧ ⟹ h ⊴ h› 29. ‹⋀(e::char list exp) (a::heap) (aa::sfields) (b::sheap) (ba::bool) (e'::char list exp) (ab::heap) (ac::sfields) (bb::sheap) (b'::bool) (C::char list) (F::char list) D::char list. ⟦(P::(char list list × char list exp) prog) ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; a ⊴ ab⟧ ⟹ a ⊴ ab› 30. ‹⋀(C::char list) (F::char list) (t::ty) (D::char list) (sh::sheap) (sfs::sfields) (i::init_state) (sfs'::sfields) (v::val) (sh'::sheap) (h::heap) l::sfields. ⟦(P::(char list list × char list exp) prog) ⊢ C has F,Static:t in D; sh D = ⌊(sfs, i)⌋; sfs' = sfs(F ↦ v); sh' = sh(D ↦ (sfs', i))⟧ ⟹ h ⊴ h› 31. ‹⋀(C::char list) (F::char list) (t::ty) (D::char list) (sh::sheap) (sfs::sfields) (v::val) (h::heap) l::sfields. ⟦(P::(char list list × char list exp) prog) ⊢ C has F,Static:t in D; sh D = ⌊(sfs, Done)⌋⟧ ⟹ h ⊴ h› 32. ‹⋀(C::char list) (F::char list) (t::ty) (D::char list) (sh::sheap) (v::val) (h::heap) l::sfields. ⟦(P::(char list list × char list exp) prog) ⊢ C has F,Static:t in D; ∄sfs::sfields. sh D = ⌊(sfs, Done)⌋⟧ ⟹ h ⊴ h› 33. ‹⋀(C::char list) (F::char list) (D::char list) (v::val) (a::heap) (aa::sfields) (b::sheap) ba::bool. ∄(b::staticb) t::ty. (P::(char list list × char list exp) prog) ⊢ C has F,b:t in D ⟹ a ⊴ a› 34. ‹⋀(C::char list) (F::char list) (t::ty) (D::char list) (v::val) (a::heap) (aa::sfields) (b::sheap) ba::bool. (P::(char list list × char list exp) prog) ⊢ C has F,NonStatic:t in D ⟹ a ⊴ a› 35. ‹⋀(e::char list exp) (a::heap) (aa::sfields) (b::sheap) (ba::bool) (e'::char list exp) (ab::heap) (ac::sfields) (bb::sheap) (b'::bool) (M::char list) es::char list exp list. ⟦(P::(char list list × char list exp) prog) ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; a ⊴ ab⟧ ⟹ a ⊴ ab› 36. ‹⋀(es::char list exp list) (a::heap) (aa::sfields) (b::sheap) (ba::bool) (es'::char list exp list) (ab::heap) (ac::sfields) (bb::sheap) (b'::bool) (v::val) M::char list. ⟦(P::(char list list × char list exp) prog) ⊢ ⟨es,(a, aa, b),ba⟩ [→] ⟨es',(ab, ac, bb),b'⟩; a ⊴ ab⟧ ⟹ a ⊴ ab› 37. ‹⋀(h::heap) (a::nat) (C::char list) (fs::Objects.fields) (M::char list) (Ts::ty list) (T::ty) (pns::char list list) (body::char list exp) (D::char list) (vs::val list) (l::sfields) (sh::sheap) b::bool. ⟦h a = ⌊(C, fs)⌋; (P::(char list list × char list exp) prog) ⊢ C sees M, NonStatic : Ts→T = (pns, body) in D; length vs = length pns; length Ts = length pns⟧ ⟹ h ⊴ h› 38. ‹⋀(M::char list) (vs::val list) (a::heap) (aa::sfields) (b::sheap) ba::bool. a ⊴ a› 39. ‹⋀(h::heap) (a::nat) (C::char list) (fs::Objects.fields) (M::char list) (vs::val list) (l::sfields) (sh::sheap) b::bool. ⟦h a = ⌊(C, fs)⌋; ∄(b::staticb) (Ts::ty list) (T::ty) (m::char list list × char list exp) D::char list. (P::(char list list × char list exp) prog) ⊢ C sees M, b : Ts→T = m in D⟧ ⟹ h ⊴ h› 40. ‹⋀(h::heap) (a::nat) (C::char list) (fs::Objects.fields) (M::char list) (Ts::ty list) (T::ty) (aa::char list list) (b::char list exp) (D::char list) (vs::val list) (l::sfields) (sh::sheap) ba::bool. ⟦h a = ⌊(C, fs)⌋; (P::(char list list × char list exp) prog) ⊢ C sees M, Static : Ts→T = (aa, b) in D⟧ ⟹ h ⊴ h› 41. ‹⋀(es::char list exp list) (a::heap) (aa::sfields) (b::sheap) (ba::bool) (es'::char list exp list) (ab::heap) (ac::sfields) (bb::sheap) (b'::bool) (C::char list) M::char list. ⟦(P::(char list list × char list exp) prog) ⊢ ⟨es,(a, aa, b),ba⟩ [→] ⟨es',(ab, ac, bb),b'⟩; a ⊴ ab⟧ ⟹ a ⊴ ab› 42. ‹⋀(C::char list) (M::char list) (Ts::ty list) (T::ty) (pns::char list list) (body::char list exp) (D::char list) (vs::val list) (a::heap) (aa::sfields) b::sheap. ⟦(P::(char list list × char list exp) prog) ⊢ C sees M, Static : Ts→T = (pns, body) in D; length vs = length pns; length Ts = length pns⟧ ⟹ a ⊴ a› 43. ‹⋀(C::char list) (M::char list) (Ts::ty list) (T::ty) (pns::char list list) (body::char list exp) (D::char list) (sh::sheap) (sfs::sfields) (vs::val list) (h::heap) l::sfields. ⟦(P::(char list list × char list exp) prog) ⊢ C sees M, Static : Ts→T = (pns, body) in D; sh D = ⌊(sfs, Done)⌋ ∨ M = clinit ∧ sh D = ⌊(sfs, Processing)⌋⟧ ⟹ h ⊴ h› 44. ‹⋀(C::char list) (M::char list) (Ts::ty list) (T::ty) (pns::char list list) (body::char list exp) (D::char list) (sh::sheap) (vs::val list) (h::heap) l::sfields. ⟦(P::(char list list × char list exp) prog) ⊢ C sees M, Static : Ts→T = (pns, body) in D; ∄sfs::sfields. sh D = ⌊(sfs, Done)⌋; M ≠ clinit⟧ ⟹ h ⊴ h› 45. ‹⋀(C::char list) (M::char list) (vs::val list) (a::heap) (aa::sfields) (b::sheap) ba::bool. ∄(b::staticb) (Ts::ty list) (T::ty) m::char list list × char list exp. Ex (Method (P::(char list list × char list exp) prog) C M b Ts T m) ⟹ a ⊴ a› 46. ‹⋀(C::char list) (M::char list) (Ts::ty list) (T::ty) (a::char list list) (b::char list exp) (D::char list) (vs::val list) (aa::heap) (ab::sfields) (ba::sheap) bb::bool. (P::(char list list × char list exp) prog) ⊢ C sees M, NonStatic : Ts→T = (a, b) in D ⟹ aa ⊴ aa› 47. ‹⋀(e::char list exp) (h::heap) (l::sfields) (V::char list) (sh::sheap) (b::bool) (e'::char list exp) (h'::heap) (l'::sfields) (sh'::sheap) (b'::bool) T::ty. ⟦(P::(char list list × char list exp) prog) ⊢ ⟨e,(h, l(V := None), sh),b⟩ → ⟨e',(h', l', sh'),b'⟩; h ⊴ h'; l' V = None; ¬ assigned V e⟧ ⟹ h ⊴ h'› 48. ‹⋀(e::char list exp) (h::heap) (l::sfields) (V::char list) (sh::sheap) (b::bool) (e'::char list exp) (h'::heap) (l'::sfields) (sh'::sheap) (b'::bool) (v::val) T::ty. ⟦(P::(char list list × char list exp) prog) ⊢ ⟨e,(h, l(V := None), sh),b⟩ → ⟨e',(h', l', sh'),b'⟩; h ⊴ h'; l' V = ⌊v⌋; ¬ assigned V e⟧ ⟹ h ⊴ h'› 49. ‹⋀(e::char list exp) (h::heap) (l::sfields) (V::char list) (v::val) (sh::sheap) (b::bool) (e'::char list exp) (h'::heap) (l'::sfields) (sh'::sheap) (b'::bool) (v'::val) T::ty. ⟦(P::(char list list × char list exp) prog) ⊢ ⟨e,(h, l(V ↦ v), sh),b⟩ → ⟨e',(h', l', sh'),b'⟩; h ⊴ h'; l' V = ⌊v'⌋⟧ ⟹ h ⊴ h'› 50. ‹⋀(V::char list) (T::ty) (u::val) (a::heap) (aa::sfields) (b::sheap) ba::bool. a ⊴ a› 51. ‹⋀(V::char list) (T::ty) (v::val) (u::val) (a::heap) (aa::sfields) (b::sheap) ba::bool. a ⊴ a› 52. ‹⋀(e::char list exp) (a::heap) (aa::sfields) (b::sheap) (ba::bool) (e'::char list exp) (ab::heap) (ac::sfields) (bb::sheap) (b'::bool) e₂::char list exp. ⟦(P::(char list list × char list exp) prog) ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; a ⊴ ab⟧ ⟹ a ⊴ ab› 53. ‹⋀(v::val) (e₂::char list exp) (a::heap) (aa::sfields) (b::sheap) ba::bool. a ⊴ a› 54. ‹⋀(e::char list exp) (a::heap) (aa::sfields) (b::sheap) (ba::bool) (e'::char list exp) (ab::heap) (ac::sfields) (bb::sheap) (b'::bool) (e₁::char list exp) e₂::char list exp. ⟦(P::(char list list × char list exp) prog) ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; a ⊴ ab⟧ ⟹ a ⊴ ab› 55. ‹⋀(e₁::char list exp) (e₂::char list exp) (a::heap) (aa::sfields) (b::sheap) ba::bool. a ⊴ a› 56. ‹⋀(e₁::char list exp) (e₂::char list exp) (a::heap) (aa::sfields) (b::sheap) ba::bool. a ⊴ a› 57. ‹⋀(b::char list exp) (c::char list exp) (a::heap) (aa::sfields) (ba::sheap) b'::bool. a ⊴ a› 58. ‹⋀(e::char list exp) (a::heap) (aa::sfields) (b::sheap) (ba::bool) (e'::char list exp) (ab::heap) (ac::sfields) (bb::sheap) b'::bool. ⟦(P::(char list list × char list exp) prog) ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; a ⊴ ab⟧ ⟹ a ⊴ ab› 59. ‹⋀(a::heap) (aa::sfields) (b::sheap) ba::bool. a ⊴ a› 60. ‹⋀(e::char list exp) (a::heap) (aa::sfields) (b::sheap) (ba::bool) (e'::char list exp) (ab::heap) (ac::sfields) (bb::sheap) (b'::bool) (C::char list) (V::char list) e₂::char list exp. ⟦(P::(char list list × char list exp) prog) ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; a ⊴ ab⟧ ⟹ a ⊴ ab› 61. ‹⋀(v::val) (C::char list) (V::char list) (e₂::char list exp) (a::heap) (aa::sfields) (b::sheap) ba::bool. a ⊴ a› 62. ‹⋀(a::heap) (aa::sfields) (b::sheap) (ab::nat) (D::char list) (fs::Objects.fields) (C::char list) (V::char list) (e₂::char list exp) ba::bool. ⟦hp (a, aa, b) ab = ⌊(D, fs)⌋; (P::(char list list × char list exp) prog) ⊢ D ≼⇧* C⟧ ⟹ a ⊴ a› 63. ‹⋀(a::heap) (aa::sfields) (b::sheap) (ab::nat) (D::char list) (fs::Objects.fields) (C::char list) (V::char list) (e₂::char list exp) ba::bool. ⟦hp (a, aa, b) ab = ⌊(D, fs)⌋; (D, C) ∉ (subcls1 (P::(char list list × char list exp) prog))⇧*⟧ ⟹ a ⊴ a› 64. ‹⋀(e::char list exp) (a::heap) (aa::sfields) (b::sheap) (ba::bool) (e'::char list exp) (ab::heap) (ac::sfields) (bb::sheap) (b'::bool) es::char list exp list. ⟦(P::(char list list × char list exp) prog) ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; a ⊴ ab⟧ ⟹ a ⊴ ab› 65. ‹⋀(es::char list exp list) (a::heap) (aa::sfields) (b::sheap) (ba::bool) (es'::char list exp list) (ab::heap) (ac::sfields) (bb::sheap) (b'::bool) v::val. ⟦(P::(char list list × char list exp) prog) ⊢ ⟨es,(a, aa, b),ba⟩ [→] ⟨es',(ab, ac, bb),b'⟩; a ⊴ ab⟧ ⟹ a ⊴ ab› 66. ‹⋀(e::char list exp) (C::char list) (b::bool) (a::heap) (aa::sfields) (ba::sheap) b'::bool. ¬ sub_RI e ⟹ a ⊴ a› 67. ‹⋀(sh::sheap) (C::char list) (C'::char list) (Cs::char list list) (e::char list exp) (h::heap) (l::sfields) b::bool. sh C = None ⟹ h ⊴ h› 68. ‹⋀(sh::sheap) (C::char list) (sfs::sfields) (C'::char list) (Cs::char list list) (e::char list exp) (h::heap) (l::sfields) b::bool. sh C = ⌊(sfs, Done)⌋ ⟹ h ⊴ h› 69. ‹⋀(sh::sheap) (C::char list) (sfs::sfields) (C'::char list) (Cs::char list list) (e::char list exp) (h::heap) (l::sfields) b::bool. sh C = ⌊(sfs, Processing)⌋ ⟹ h ⊴ h› 70. ‹⋀(sh::sheap) (C::char list) (sfs::sfields) (C'::char list) (Cs::char list list) (e::char list exp) (h::heap) (l::sfields) b::bool. sh C = ⌊(sfs, Error)⌋ ⟹ h ⊴ h› 71. ‹⋀(sh::sheap) (C::char list) (sfs::sfields) (sh'::sheap) (C'::char list) (Cs::char list list) (e::char list exp) (h::heap) (l::sfields) b::bool. ⟦sh C = ⌊(sfs, Prepared)⌋; C = Object; sh' = sh(C ↦ (sfs, Processing))⟧ ⟹ h ⊴ h› 72. ‹⋀(sh::sheap) (C::char list) (sfs::sfields) (D::char list) (a::fdecl list) (b::(char list list × char list exp) mdecl list) (sh'::sheap) (C'::char list) (Cs::char list list) (e::char list exp) (h::heap) (l::sfields) ba::bool. ⟦sh C = ⌊(sfs, Prepared)⌋; C ≠ Object; class (P::(char list list × char list exp) prog) C = ⌊(D, a, b)⌋; sh' = sh(C ↦ (sfs, Processing))⟧ ⟹ h ⊴ h› 73. ‹⋀(C'::char list) (C::char list) (Cs::char list list) (e::char list exp) (h::heap) (l::sfields) (sh::sheap) b::bool. h ⊴ h› 74. ‹⋀(e::char list exp) (a::heap) (aa::sfields) (b::sheap) (ba::bool) (e'::char list exp) (ab::heap) (ac::sfields) (bb::sheap) (b'::bool) (C::char list) (Cs::char list list) e₀::char list exp. ⟦(P::(char list list × char list exp) prog) ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; a ⊴ ab⟧ ⟹ a ⊴ ab› 75. ‹⋀(sh::sheap) (C::char list) (sfs::sfields) (i::init_state) (sh'::sheap) (C'::char list) (Cs::char list list) (v::val) (e::char list exp) (h::heap) (l::sfields) b::bool. ⟦sh C = ⌊(sfs, i)⌋; sh' = sh(C ↦ (sfs, Done)); C' = last (C # Cs)⟧ ⟹ h ⊴ h› 76. ‹⋀(C::char list) (e::char list exp) (a::heap) (aa::sfields) (b::sheap) ba::bool. a ⊴ a› 77. ‹⋀(e::char list exp) (bop::bop) (e₂::char list exp) (a::heap) (aa::sfields) (b::sheap) ba::bool. a ⊴ a› 78. ‹⋀(v₁::val) (bop::bop) (e::char list exp) (a::heap) (aa::sfields) (b::sheap) ba::bool. a ⊴ a› 79. ‹⋀(V::char list) (e::char list exp) (a::heap) (aa::sfields) (b::sheap) ba::bool. a ⊴ a› 80. ‹⋀(e::char list exp) (F::char list) (D::char list) (a::heap) (aa::sfields) (b::sheap) ba::bool. a ⊴ a› 81. ‹⋀(e::char list exp) (F::char list) (D::char list) (e₂::char list exp) (a::heap) (aa::sfields) (b::sheap) ba::bool. a ⊴ a› 82. ‹⋀(v::val) (F::char list) (D::char list) (e::char list exp) (a::heap) (aa::sfields) (b::sheap) ba::bool. a ⊴ a› 83. ‹⋀(C::char list) (F::char list) (D::char list) (e::char list exp) (a::heap) (aa::sfields) (b::sheap) ba::bool. a ⊴ a› 84. ‹⋀(e::char list exp) (M::char list) (es::char list exp list) (a::heap) (aa::sfields) (b::sheap) ba::bool. a ⊴ a› 85. ‹⋀(es::char list exp list) (vs::val list) (e::char list exp) (es'::char list exp list) (v::val) (M::char list) (a::heap) (aa::sfields) (b::sheap) ba::bool. es = map Val vs @ throw e # es' ⟹ a ⊴ a› 86. ‹⋀(es::char list exp list) (vs::val list) (e::char list exp) (es'::char list exp list) (C::char list) (M::char list) (a::heap) (aa::sfields) (b::sheap) ba::bool. es = map Val vs @ throw e # es' ⟹ a ⊴ a› 87. ‹⋀(V::char list) (T::ty) (a::nat) (aa::heap) (ab::sfields) (b::sheap) ba::bool. aa ⊴ aa› 88. ‹⋀(V::char list) (T::ty) (v::val) (a::nat) (aa::heap) (ab::sfields) (b::sheap) ba::bool. aa ⊴ aa› 89. ‹⋀(e::char list exp) (e₂::char list exp) (a::heap) (aa::sfields) (b::sheap) ba::bool. a ⊴ a› 90. ‹⋀(e::char list exp) (e₁::char list exp) (e₂::char list exp) (a::heap) (aa::sfields) (b::sheap) ba::bool. a ⊴ a› 91. ‹⋀(e::char list exp) (a::heap) (aa::sfields) (b::sheap) ba::bool. a ⊴ a› 92. ‹⋀(sh::sheap) (C::char list) (sfs::sfields) (i::init_state) (sh'::sheap) (a::nat) (D::char list) (Cs::char list list) (e::char list exp) (h::heap) (l::sfields) b::bool. ⟦sh C = ⌊(sfs, i)⌋; sh' = sh(C ↦ (sfs, Error))⟧ ⟹ h ⊴ h› 93. ‹⋀(sh::sheap) (C::char list) (sfs::sfields) (i::init_state) (sh'::sheap) (a::nat) (e::char list exp) (h::heap) (l::sfields) b::bool. ⟦sh C = ⌊(sfs, i)⌋; sh' = sh(C ↦ (sfs, Error))⟧ ⟹ h ⊴ h›*) (*>*) lemma red_lcl_incr: "P ⊢ ⟨e,(h₀,l₀,sh₀),b⟩ → ⟨e',(h₁,l₁,sh₁),b'⟩ ⟹ dom l₀ ⊆ dom l₁" and reds_lcl_incr: "P ⊢ ⟨es,(h₀,l₀,sh₀),b⟩ [→] ⟨es',(h₁,l₁,sh₁),b'⟩ ⟹ dom l₀ ⊆ dom l₁" (*<*)apply (induct rule: red_reds_inducts (*‹⟦?P ⊢ ⟨?x1a,(?x2a, ?x2b, ?x2c),?x3a⟩ → ⟨?x4a,(?x5a, ?x5b, ?x5c),?x6a⟩; ⋀h a C FDTs h' l sh. ⟦new_Addr h = ⌊a⌋; ?P ⊢ C has_fields FDTs; h' = h(a ↦ blank ?P C)⟧ ⟹ ?P1.0 (new C) h l sh True (addr a) h' l sh False; ⋀h C l sh. ⟦new_Addr h = None; is_class ?P C⟧ ⟹ ?P1.0 (new C) h l sh True (THROW OutOfMemory) h l sh False; ⋀sh C sfs h l. sh C = ⌊(sfs, Done)⌋ ⟹ ?P1.0 (new C) h l sh False (new C) h l sh True; ⋀sh C h l. ⟦∄sfs. sh C = ⌊(sfs, Done)⌋; is_class ?P C⟧ ⟹ ?P1.0 (new C) h l sh False (INIT C ([C],False) ← new C) h l sh False; ⋀e a aa b ba e' ab ac bb b' C. ⟦?P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ?P1.0 e a aa b ba e' ab ac bb b'⟧ ⟹ ?P1.0 (Cast C e) a aa b ba (Cast C e') ab ac bb b'; ⋀C a aa b ba. ?P1.0 (Cast C null) a aa b ba null a aa b ba; ⋀h a D fs C l sh b. ⟦h a = ⌊(D, fs)⌋; ?P ⊢ D ≼⇧* C⟧ ⟹ ?P1.0 (Cast C (addr a)) h l sh b (addr a) h l sh b; ⋀h a D fs C l sh b. ⟦h a = ⌊(D, fs)⌋; (D, C) ∉ (subcls1 ?P)⇧*⟧ ⟹ ?P1.0 (Cast C (addr a)) h l sh b (THROW ClassCast) h l sh b; ⋀e a aa b ba e' ab ac bb b' bop e₂. ⟦?P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ?P1.0 e a aa b ba e' ab ac bb b'⟧ ⟹ ?P1.0 (e «bop» e₂) a aa b ba (e' «bop» e₂) ab ac bb b'; ⋀e a aa b ba e' ab ac bb b' v₁ bop. ⟦?P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ?P1.0 e a aa b ba e' ab ac bb b'⟧ ⟹ ?P1.0 (Val v₁ «bop» e) a aa b ba (Val v₁ «bop» e') ab ac bb b'; ⋀bop v₁ v₂ v a aa b ba. binop (bop, v₁, v₂) = ⌊v⌋ ⟹ ?P1.0 (Val v₁ «bop» Val v₂) a aa b ba (Val v) a aa b ba; ⋀l V v h sh b. l V = ⌊v⌋ ⟹ ?P1.0 (Var V) h l sh b (Val v) h l sh b; ⋀e a aa b ba e' ab ac bb b' V. ⟦?P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ?P1.0 e a aa b ba e' ab ac bb b'⟧ ⟹ ?P1.0 (V:=e) a aa b ba (V:=e') ab ac bb b'; ⋀V v h l sh b. ?P1.0 (V:=Val v) h l sh b unit h (l(V ↦ v)) sh b; ⋀e a aa b ba e' ab ac bb b' F D. ⟦?P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ?P1.0 e a aa b ba e' ab ac bb b'⟧ ⟹ ?P1.0 (e∙F{D}) a aa b ba (e'∙F{D}) ab ac bb b'; ⋀h a C fs F D v t l sh b. ⟦h a = ⌊(C, fs)⌋; fs (F, D) = ⌊v⌋; ?P ⊢ C has F,NonStatic:t in D⟧ ⟹ ?P1.0 (addr a∙F{D}) h l sh b (Val v) h l sh b; ⋀F D a aa b ba. ?P1.0 (null∙F{D}) a aa b ba (THROW NullPointer) a aa b ba; ⋀h a C fs F D l sh b. ⟦h a = ⌊(C, fs)⌋; ∄b t. ?P ⊢ C has F,b:t in D⟧ ⟹ ?P1.0 (addr a∙F{D}) h l sh b (THROW NoSuchFieldError) h l sh b; ⋀h a C fs F t D l sh b. ⟦h a = ⌊(C, fs)⌋; ?P ⊢ C has F,Static:t in D⟧ ⟹ ?P1.0 (addr a∙F{D}) h l sh b (THROW IncompatibleClassChangeError) h l sh b; ⋀C F t D sh sfs i v h l. ⟦?P ⊢ C has F,Static:t in D; sh D = ⌊(sfs, i)⌋; sfs F = ⌊v⌋⟧ ⟹ ?P1.0 (C∙⇩sF{D}) h l sh True (Val v) h l sh False; ⋀C F t D sh sfs h l. ⟦?P ⊢ C has F,Static:t in D; sh D = ⌊(sfs, Done)⌋⟧ ⟹ ?P1.0 (C∙⇩sF{D}) h l sh False (C∙⇩sF{D}) h l sh True; ⋀C F t D sh h l. ⟦?P ⊢ C has F,Static:t in D; ∄sfs. sh D = ⌊(sfs, Done)⌋⟧ ⟹ ?P1.0 (C∙⇩sF{D}) h l sh False (INIT D ([D],False) ← C∙⇩sF{D}) h l sh False; ⋀C F D h l sh b. ∄b t. ?P ⊢ C has F,b:t in D ⟹ ?P1.0 (C∙⇩sF{D}) h l sh b (THROW NoSuchFieldError) h l sh False; ⋀C F t D h l sh b. ?P ⊢ C has F,NonStatic:t in D ⟹ ?P1.0 (C∙⇩sF{D}) h l sh b (THROW IncompatibleClassChangeError) h l sh False; ⋀e a aa b ba e' ab ac bb b' F D e₂. ⟦?P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ?P1.0 e a aa b ba e' ab ac bb b'⟧ ⟹ ?P1.0 (e∙F{D} := e₂) a aa b ba (e'∙F{D} := e₂) ab ac bb b'; ⋀e a aa b ba e' ab ac bb b' v F D. ⟦?P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ?P1.0 e a aa b ba e' ab ac bb b'⟧ ⟹ ?P1.0 (Val v∙F{D} := e) a aa b ba (Val v∙F{D} := e') ab ac bb b'; ⋀C F t D h a fs v l sh b. ⟦?P ⊢ C has F,NonStatic:t in D; h a = ⌊(C, fs)⌋⟧ ⟹ ?P1.0 (addr a∙F{D} := Val v) h l sh b unit (h(a ↦ (C, fs((F, D) ↦ v)))) l sh b; ⋀F D v a aa b ba. ?P1.0 (null∙F{D} := Val v) a aa b ba (THROW NullPointer) a aa b ba; ⋀h a C fs F D v l sh b. ⟦h a = ⌊(C, fs)⌋; ∄b t. ?P ⊢ C has F,b:t in D⟧ ⟹ ?P1.0 (addr a∙F{D} := Val v) h l sh b (THROW NoSuchFieldError) h l sh b; ⋀h a C fs F t D v l sh b. ⟦h a = ⌊(C, fs)⌋; ?P ⊢ C has F,Static:t in D⟧ ⟹ ?P1.0 (addr a∙F{D} := Val v) h l sh b (THROW IncompatibleClassChangeError) h l sh b; ⋀e a aa b ba e' ab ac bb b' C F D. ⟦?P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ?P1.0 e a aa b ba e' ab ac bb b'⟧ ⟹ ?P1.0 (C∙⇩sF{D} := e) a aa b ba (C∙⇩sF{D} := e') ab ac bb b'; ⋀C F t D sh sfs i sfs' v sh' h l. ⟦?P ⊢ C has F,Static:t in D; sh D = ⌊(sfs, i)⌋; sfs' = sfs(F ↦ v); sh' = sh(D ↦ (sfs', i))⟧ ⟹ ?P1.0 (C∙⇩sF{D} := Val v) h l sh True unit h l sh' False; ⋀C F t D sh sfs v h l. ⟦?P ⊢ C has F,Static:t in D; sh D = ⌊(sfs, Done)⌋⟧ ⟹ ?P1.0 (C∙⇩sF{D} := Val v) h l sh False (C∙⇩sF{D} := Val v) h l sh True; ⋀C F t D sh v h l. ⟦?P ⊢ C has F,Static:t in D; ∄sfs. sh D = ⌊(sfs, Done)⌋⟧ ⟹ ?P1.0 (C∙⇩sF{D} := Val v) h l sh False (INIT D ([D],False) ← C∙⇩sF{D} := Val v) h l sh False; ⋀C F D v a aa b ba. ∄b t. ?P ⊢ C has F,b:t in D ⟹ ?P1.0 (C∙⇩sF{D} := Val v) a aa b ba (THROW NoSuchFieldError) a aa b False; ⋀C F t D v a aa b ba. ?P ⊢ C has F,NonStatic:t in D ⟹ ?P1.0 (C∙⇩sF{D} := Val v) a aa b ba (THROW IncompatibleClassChangeError) a aa b False; ⋀e a aa b ba e' ab ac bb b' M es. ⟦?P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ?P1.0 e a aa b ba e' ab ac bb b'⟧ ⟹ ?P1.0 (e∙M(es)) a aa b ba (e'∙M(es)) ab ac bb b'; ⋀es a aa b ba es' ab ac bb b' v M. ⟦?P ⊢ ⟨es,(a, aa, b),ba⟩ [→] ⟨es',(ab, ac, bb),b'⟩; ?P2.0 es a aa b ba es' ab ac bb b'⟧ ⟹ ?P1.0 (Val v∙M(es)) a aa b ba (Val v∙M(es')) ab ac bb b'; ⋀h a C fs M Ts T pns body D vs l sh b. ⟦h a = ⌊(C, fs)⌋; ?P ⊢ C sees M, NonStatic : Ts→T = (pns, body) in D; length vs = length pns; length Ts = length pns⟧ ⟹ ?P1.0 (addr a∙M(map Val vs)) h l sh b (blocks (this # pns, Class D # Ts, Addr a # vs, body)) h l sh b; ⋀M vs a aa b ba. ?P1.0 (null∙M(map Val vs)) a aa b ba (THROW NullPointer) a aa b ba; ⋀h a C fs M vs l sh b. ⟦h a = ⌊(C, fs)⌋; ∄b Ts T m D. ?P ⊢ C sees M, b : Ts→T = m in D⟧ ⟹ ?P1.0 (addr a∙M(map Val vs)) h l sh b (THROW NoSuchMethodError) h l sh b; ⋀h a C fs M Ts T aa b D vs l sh ba. ⟦h a = ⌊(C, fs)⌋; ?P ⊢ C sees M, Static : Ts→T = (aa, b) in D⟧ ⟹ ?P1.0 (addr a∙M(map Val vs)) h l sh ba (THROW IncompatibleClassChangeError) h l sh ba; ⋀es a aa b ba es' ab ac bb b' C M. ⟦?P ⊢ ⟨es,(a, aa, b),ba⟩ [→] ⟨es',(ab, ac, bb),b'⟩; ?P2.0 es a aa b ba es' ab ac bb b'⟧ ⟹ ?P1.0 (C∙⇩sM(es)) a aa b ba (C∙⇩sM(es')) ab ac bb b'; ⋀C M Ts T pns body D vs a aa b. ⟦?P ⊢ C sees M, Static : Ts→T = (pns, body) in D; length vs = length pns; length Ts = length pns⟧ ⟹ ?P1.0 (C∙⇩sM(map Val vs)) a aa b True (blocks (pns, Ts, vs, body)) a aa b False; ⋀C M Ts T pns body D sh sfs vs h l. ⟦?P ⊢ C sees M, Static : Ts→T = (pns, body) in D; sh D = ⌊(sfs, Done)⌋ ∨ M = clinit ∧ sh D = ⌊(sfs, Processing)⌋⟧ ⟹ ?P1.0 (C∙⇩sM(map Val vs)) h l sh False (C∙⇩sM(map Val vs)) h l sh True; ⋀C M Ts T pns body D sh vs h l. ⟦?P ⊢ C sees M, Static : Ts→T = (pns, body) in D; ∄sfs. sh D = ⌊(sfs, Done)⌋; M ≠ clinit⟧ ⟹ ?P1.0 (C∙⇩sM(map Val vs)) h l sh False (INIT D ([D],False) ← C∙⇩sM(map Val vs)) h l sh False; ⋀C M vs a aa b ba. ∄b Ts T m. Ex (Method ?P C M b Ts T m) ⟹ ?P1.0 (C∙⇩sM(map Val vs)) a aa b ba (THROW NoSuchMethodError) a aa b False; ⋀C M Ts T a b D vs aa ab ba bb. ?P ⊢ C sees M, NonStatic : Ts→T = (a, b) in D ⟹ ?P1.0 (C∙⇩sM(map Val vs)) aa ab ba bb (THROW IncompatibleClassChangeError) aa ab ba False; ⋀e h l V sh b e' h' l' sh' b' T. ⟦?P ⊢ ⟨e,(h, l(V := None), sh),b⟩ → ⟨e',(h', l', sh'),b'⟩; ?P1.0 e h (l(V := None)) sh b e' h' l' sh' b'; l' V = None; ¬ assigned V e⟧ ⟹ ?P1.0 {V:T; e} h l sh b {V:T; e'} h' (l'(V := l V)) sh' b'; ⋀e h l V sh b e' h' l' sh' b' v T. ⟦?P ⊢ ⟨e,(h, l(V := None), sh),b⟩ → ⟨e',(h', l', sh'),b'⟩; ?P1.0 e h (l(V := None)) sh b e' h' l' sh' b'; l' V = ⌊v⌋; ¬ assigned V e⟧ ⟹ ?P1.0 {V:T; e} h l sh b {V:T; V:=Val v;; e'} h' (l'(V := l V)) sh' b'; ⋀e h l V v sh b e' h' l' sh' b' v' T. ⟦?P ⊢ ⟨e,(h, l(V ↦ v), sh),b⟩ → ⟨e',(h', l', sh'),b'⟩; ?P1.0 e h (l(V ↦ v)) sh b e' h' l' sh' b'; l' V = ⌊v'⌋⟧ ⟹ ?P1.0 {V:T; V:=Val v;; e} h l sh b {V:T; V:=Val v';; e'} h' (l'(V := l V)) sh' b'; ⋀V T u a aa b ba. ?P1.0 {V:T; Val u} a aa b ba (Val u) a aa b ba; ⋀V T v u a aa b ba. ?P1.0 {V:T; V:=Val v;; Val u} a aa b ba (Val u) a aa b ba; ⋀e a aa b ba e' ab ac bb b' e₂. ⟦?P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ?P1.0 e a aa b ba e' ab ac bb b'⟧ ⟹ ?P1.0 (e;; e₂) a aa b ba (e';; e₂) ab ac bb b'; ⋀v e₂ a aa b ba. ?P1.0 (Val v;; e₂) a aa b ba e₂ a aa b ba; ⋀e a aa b ba e' ab ac bb b' e₁ e₂. ⟦?P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ?P1.0 e a aa b ba e' ab ac bb b'⟧ ⟹ ?P1.0 (if (e) e₁ else e₂) a aa b ba (if (e') e₁ else e₂) ab ac bb b'; ⋀e₁ e₂ a aa b ba. ?P1.0 (if (true) e₁ else e₂) a aa b ba e₁ a aa b ba; ⋀e₁ e₂ a aa b ba. ?P1.0 (if (false) e₁ else e₂) a aa b ba e₂ a aa b ba; ⋀b c a aa ba b'. ?P1.0 (while (b) c) a aa ba b' (if (b) (c;; while (b) c) else unit) a aa ba b'; ⋀e a aa b ba e' ab ac bb b'. ⟦?P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ?P1.0 e a aa b ba e' ab ac bb b'⟧ ⟹ ?P1.0 (throw e) a aa b ba (throw e') ab ac bb b'; ⋀a aa b ba. ?P1.0 (throw null) a aa b ba (THROW NullPointer) a aa b ba; ⋀e a aa b ba e' ab ac bb b' C V e₂. ⟦?P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ?P1.0 e a aa b ba e' ab ac bb b'⟧ ⟹ ?P1.0 (try e catch(C V) e₂) a aa b ba (try e' catch(C V) e₂) ab ac bb b'; ⋀v C V e₂ a aa b ba. ?P1.0 (try Val v catch(C V) e₂) a aa b ba (Val v) a aa b ba; ⋀a aa b ab D fs C V e₂ ba. ⟦hp (a, aa, b) ab = ⌊(D, fs)⌋; ?P ⊢ D ≼⇧* C⟧ ⟹ ?P1.0 (try Throw ab catch(C V) e₂) a aa b ba {V:Class C; V:=addr ab;; e₂} a aa b ba; ⋀a aa b ab D fs C V e₂ ba. ⟦hp (a, aa, b) ab = ⌊(D, fs)⌋; (D, C) ∉ (subcls1 ?P)⇧*⟧ ⟹ ?P1.0 (try Throw ab catch(C V) e₂) a aa b ba (Throw ab) a aa b ba; ⋀e a aa b ba e' ab ac bb b' es. ⟦?P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ?P1.0 e a aa b ba e' ab ac bb b'⟧ ⟹ ?P2.0 (e # es) a aa b ba (e' # es) ab ac bb b'; ⋀es a aa b ba es' ab ac bb b' v. ⟦?P ⊢ ⟨es,(a, aa, b),ba⟩ [→] ⟨es',(ab, ac, bb),b'⟩; ?P2.0 es a aa b ba es' ab ac bb b'⟧ ⟹ ?P2.0 (Val v # es) a aa b ba (Val v # es') ab ac bb b'; ⋀e C b a aa ba b'. ¬ sub_RI e ⟹ ?P1.0 (INIT C ([],b) ← e) a aa ba b' e a aa ba (icheck ?P C e); ⋀sh C C' Cs e h l b. sh C = None ⟹ ?P1.0 (INIT C' (C # Cs,False) ← e) h l sh b (INIT C' (C # Cs,False) ← e) h l (sh(C ↦ (sblank ?P C, Prepared))) b; ⋀sh C sfs C' Cs e h l b. sh C = ⌊(sfs, Done)⌋ ⟹ ?P1.0 (INIT C' (C # Cs,False) ← e) h l sh b (INIT C' (Cs,True) ← e) h l sh b; ⋀sh C sfs C' Cs e h l b. sh C = ⌊(sfs, Processing)⌋ ⟹ ?P1.0 (INIT C' (C # Cs,False) ← e) h l sh b (INIT C' (Cs,True) ← e) h l sh b; ⋀sh C sfs C' Cs e h l b. sh C = ⌊(sfs, Error)⌋ ⟹ ?P1.0 (INIT C' (C # Cs,False) ← e) h l sh b (RI (C,THROW NoClassDefFoundError) ; Cs ← e) h l sh b; ⋀sh C sfs sh' C' Cs e h l b. ⟦sh C = ⌊(sfs, Prepared)⌋; C = Object; sh' = sh(C ↦ (sfs, Processing))⟧ ⟹ ?P1.0 (INIT C' (C # Cs,False) ← e) h l sh b (INIT C' (C # Cs,True) ← e) h l sh' b; ⋀sh C sfs D a b sh' C' Cs e h l ba. ⟦sh C = ⌊(sfs, Prepared)⌋; C ≠ Object; class ?P C = ⌊(D, a, b)⌋; sh' = sh(C ↦ (sfs, Processing))⟧ ⟹ ?P1.0 (INIT C' (C # Cs,False) ← e) h l sh ba (INIT C' (D # C # Cs,False) ← e) h l sh' ba; ⋀C' C Cs e h l sh b. ?P1.0 (INIT C' (C # Cs,True) ← e) h l sh b (RI (C,C∙⇩sclinit([])) ; Cs ← e) h l sh b; ⋀e a aa b ba e' ab ac bb b' C Cs e₀. ⟦?P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ?P1.0 e a aa b ba e' ab ac bb b'⟧ ⟹ ?P1.0 (RI (C,e) ; Cs ← e₀) a aa b ba (RI (C,e') ; Cs ← e₀) ab ac bb b'; ⋀sh C sfs i sh' C' Cs v e h l b. ⟦sh C = ⌊(sfs, i)⌋; sh' = sh(C ↦ (sfs, Done)); C' = last (C # Cs)⟧ ⟹ ?P1.0 (RI (C,Val v) ; Cs ← e) h l sh b (INIT C' (Cs,True) ← e) h l sh' b; ⋀C e a aa b ba. ?P1.0 (Cast C (throw e)) a aa b ba (throw e) a aa b ba; ⋀e bop e₂ a aa b ba. ?P1.0 (throw e «bop» e₂) a aa b ba (throw e) a aa b ba; ⋀v₁ bop e a aa b ba. ?P1.0 (Val v₁ «bop» throw e) a aa b ba (throw e) a aa b ba; ⋀V e a aa b ba. ?P1.0 (V:=throw e) a aa b ba (throw e) a aa b ba; ⋀e F D a aa b ba. ?P1.0 (throw e∙F{D}) a aa b ba (throw e) a aa b ba; ⋀e F D e₂ a aa b ba. ?P1.0 (throw e∙F{D} := e₂) a aa b ba (throw e) a aa b ba; ⋀v F D e a aa b ba. ?P1.0 (Val v∙F{D} := throw e) a aa b ba (throw e) a aa b ba; ⋀C F D e a aa b ba. ?P1.0 (C∙⇩sF{D} := throw e) a aa b ba (throw e) a aa b ba; ⋀e M es a aa b ba. ?P1.0 (throw e∙M(es)) a aa b ba (throw e) a aa b ba; ⋀es vs e es' v M a aa b ba. es = map Val vs @ throw e # es' ⟹ ?P1.0 (Val v∙M(es)) a aa b ba (throw e) a aa b ba; ⋀es vs e es' C M a aa b ba. es = map Val vs @ throw e # es' ⟹ ?P1.0 (C∙⇩sM(es)) a aa b ba (throw e) a aa b ba; ⋀V T a aa ab b ba. ?P1.0 {V:T; Throw a} aa ab b ba (Throw a) aa ab b ba; ⋀V T v a aa ab b ba. ?P1.0 {V:T; V:=Val v;; Throw a} aa ab b ba (Throw a) aa ab b ba; ⋀e e₂ a aa b ba. ?P1.0 (throw e;; e₂) a aa b ba (throw e) a aa b ba; ⋀e e₁ e₂ a aa b ba. ?P1.0 (if (throw e) e₁ else e₂) a aa b ba (throw e) a aa b ba; ⋀e a aa b ba. ?P1.0 (throw (throw e)) a aa b ba (throw e) a aa b ba; ⋀sh C sfs i sh' a D Cs e h l b. ⟦sh C = ⌊(sfs, i)⌋; sh' = sh(C ↦ (sfs, Error))⟧ ⟹ ?P1.0 (RI (C,Throw a) ; D # Cs ← e) h l sh b (RI (D,Throw a) ; Cs ← e) h l sh' b; ⋀sh C sfs i sh' a e h l b. ⟦sh C = ⌊(sfs, i)⌋; sh' = sh(C ↦ (sfs, Error))⟧ ⟹ ?P1.0 (RI (C,Throw a) ; [] ← e) h l sh b (Throw a) h l sh' b⟧ ⟹ ?P1.0 ?x1a ?x2a ?x2b ?x2c ?x3a ?x4a ?x5a ?x5b ?x5c ?x6a› ‹⟦?P ⊢ ⟨?x7a,(?x8a, ?x8b, ?x8c),?x9a⟩ [→] ⟨?x10a,(?x11a, ?x11b, ?x11c),?x12a⟩; ⋀h a C FDTs h' l sh. ⟦new_Addr h = ⌊a⌋; ?P ⊢ C has_fields FDTs; h' = h(a ↦ blank ?P C)⟧ ⟹ ?P1.0 (new C) h l sh True (addr a) h' l sh False; ⋀h C l sh. ⟦new_Addr h = None; is_class ?P C⟧ ⟹ ?P1.0 (new C) h l sh True (THROW OutOfMemory) h l sh False; ⋀sh C sfs h l. sh C = ⌊(sfs, Done)⌋ ⟹ ?P1.0 (new C) h l sh False (new C) h l sh True; ⋀sh C h l. ⟦∄sfs. sh C = ⌊(sfs, Done)⌋; is_class ?P C⟧ ⟹ ?P1.0 (new C) h l sh False (INIT C ([C],False) ← new C) h l sh False; ⋀e a aa b ba e' ab ac bb b' C. ⟦?P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ?P1.0 e a aa b ba e' ab ac bb b'⟧ ⟹ ?P1.0 (Cast C e) a aa b ba (Cast C e') ab ac bb b'; ⋀C a aa b ba. ?P1.0 (Cast C null) a aa b ba null a aa b ba; ⋀h a D fs C l sh b. ⟦h a = ⌊(D, fs)⌋; ?P ⊢ D ≼⇧* C⟧ ⟹ ?P1.0 (Cast C (addr a)) h l sh b (addr a) h l sh b; ⋀h a D fs C l sh b. ⟦h a = ⌊(D, fs)⌋; (D, C) ∉ (subcls1 ?P)⇧*⟧ ⟹ ?P1.0 (Cast C (addr a)) h l sh b (THROW ClassCast) h l sh b; ⋀e a aa b ba e' ab ac bb b' bop e₂. ⟦?P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ?P1.0 e a aa b ba e' ab ac bb b'⟧ ⟹ ?P1.0 (e «bop» e₂) a aa b ba (e' «bop» e₂) ab ac bb b'; ⋀e a aa b ba e' ab ac bb b' v₁ bop. ⟦?P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ?P1.0 e a aa b ba e' ab ac bb b'⟧ ⟹ ?P1.0 (Val v₁ «bop» e) a aa b ba (Val v₁ «bop» e') ab ac bb b'; ⋀bop v₁ v₂ v a aa b ba. binop (bop, v₁, v₂) = ⌊v⌋ ⟹ ?P1.0 (Val v₁ «bop» Val v₂) a aa b ba (Val v) a aa b ba; ⋀l V v h sh b. l V = ⌊v⌋ ⟹ ?P1.0 (Var V) h l sh b (Val v) h l sh b; ⋀e a aa b ba e' ab ac bb b' V. ⟦?P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ?P1.0 e a aa b ba e' ab ac bb b'⟧ ⟹ ?P1.0 (V:=e) a aa b ba (V:=e') ab ac bb b'; ⋀V v h l sh b. ?P1.0 (V:=Val v) h l sh b unit h (l(V ↦ v)) sh b; ⋀e a aa b ba e' ab ac bb b' F D. ⟦?P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ?P1.0 e a aa b ba e' ab ac bb b'⟧ ⟹ ?P1.0 (e∙F{D}) a aa b ba (e'∙F{D}) ab ac bb b'; ⋀h a C fs F D v t l sh b. ⟦h a = ⌊(C, fs)⌋; fs (F, D) = ⌊v⌋; ?P ⊢ C has F,NonStatic:t in D⟧ ⟹ ?P1.0 (addr a∙F{D}) h l sh b (Val v) h l sh b; ⋀F D a aa b ba. ?P1.0 (null∙F{D}) a aa b ba (THROW NullPointer) a aa b ba; ⋀h a C fs F D l sh b. ⟦h a = ⌊(C, fs)⌋; ∄b t. ?P ⊢ C has F,b:t in D⟧ ⟹ ?P1.0 (addr a∙F{D}) h l sh b (THROW NoSuchFieldError) h l sh b; ⋀h a C fs F t D l sh b. ⟦h a = ⌊(C, fs)⌋; ?P ⊢ C has F,Static:t in D⟧ ⟹ ?P1.0 (addr a∙F{D}) h l sh b (THROW IncompatibleClassChangeError) h l sh b; ⋀C F t D sh sfs i v h l. ⟦?P ⊢ C has F,Static:t in D; sh D = ⌊(sfs, i)⌋; sfs F = ⌊v⌋⟧ ⟹ ?P1.0 (C∙⇩sF{D}) h l sh True (Val v) h l sh False; ⋀C F t D sh sfs h l. ⟦?P ⊢ C has F,Static:t in D; sh D = ⌊(sfs, Done)⌋⟧ ⟹ ?P1.0 (C∙⇩sF{D}) h l sh False (C∙⇩sF{D}) h l sh True; ⋀C F t D sh h l. ⟦?P ⊢ C has F,Static:t in D; ∄sfs. sh D = ⌊(sfs, Done)⌋⟧ ⟹ ?P1.0 (C∙⇩sF{D}) h l sh False (INIT D ([D],False) ← C∙⇩sF{D}) h l sh False; ⋀C F D h l sh b. ∄b t. ?P ⊢ C has F,b:t in D ⟹ ?P1.0 (C∙⇩sF{D}) h l sh b (THROW NoSuchFieldError) h l sh False; ⋀C F t D h l sh b. ?P ⊢ C has F,NonStatic:t in D ⟹ ?P1.0 (C∙⇩sF{D}) h l sh b (THROW IncompatibleClassChangeError) h l sh False; ⋀e a aa b ba e' ab ac bb b' F D e₂. ⟦?P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ?P1.0 e a aa b ba e' ab ac bb b'⟧ ⟹ ?P1.0 (e∙F{D} := e₂) a aa b ba (e'∙F{D} := e₂) ab ac bb b'; ⋀e a aa b ba e' ab ac bb b' v F D. ⟦?P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ?P1.0 e a aa b ba e' ab ac bb b'⟧ ⟹ ?P1.0 (Val v∙F{D} := e) a aa b ba (Val v∙F{D} := e') ab ac bb b'; ⋀C F t D h a fs v l sh b. ⟦?P ⊢ C has F,NonStatic:t in D; h a = ⌊(C, fs)⌋⟧ ⟹ ?P1.0 (addr a∙F{D} := Val v) h l sh b unit (h(a ↦ (C, fs((F, D) ↦ v)))) l sh b; ⋀F D v a aa b ba. ?P1.0 (null∙F{D} := Val v) a aa b ba (THROW NullPointer) a aa b ba; ⋀h a C fs F D v l sh b. ⟦h a = ⌊(C, fs)⌋; ∄b t. ?P ⊢ C has F,b:t in D⟧ ⟹ ?P1.0 (addr a∙F{D} := Val v) h l sh b (THROW NoSuchFieldError) h l sh b; ⋀h a C fs F t D v l sh b. ⟦h a = ⌊(C, fs)⌋; ?P ⊢ C has F,Static:t in D⟧ ⟹ ?P1.0 (addr a∙F{D} := Val v) h l sh b (THROW IncompatibleClassChangeError) h l sh b; ⋀e a aa b ba e' ab ac bb b' C F D. ⟦?P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ?P1.0 e a aa b ba e' ab ac bb b'⟧ ⟹ ?P1.0 (C∙⇩sF{D} := e) a aa b ba (C∙⇩sF{D} := e') ab ac bb b'; ⋀C F t D sh sfs i sfs' v sh' h l. ⟦?P ⊢ C has F,Static:t in D; sh D = ⌊(sfs, i)⌋; sfs' = sfs(F ↦ v); sh' = sh(D ↦ (sfs', i))⟧ ⟹ ?P1.0 (C∙⇩sF{D} := Val v) h l sh True unit h l sh' False; ⋀C F t D sh sfs v h l. ⟦?P ⊢ C has F,Static:t in D; sh D = ⌊(sfs, Done)⌋⟧ ⟹ ?P1.0 (C∙⇩sF{D} := Val v) h l sh False (C∙⇩sF{D} := Val v) h l sh True; ⋀C F t D sh v h l. ⟦?P ⊢ C has F,Static:t in D; ∄sfs. sh D = ⌊(sfs, Done)⌋⟧ ⟹ ?P1.0 (C∙⇩sF{D} := Val v) h l sh False (INIT D ([D],False) ← C∙⇩sF{D} := Val v) h l sh False; ⋀C F D v a aa b ba. ∄b t. ?P ⊢ C has F,b:t in D ⟹ ?P1.0 (C∙⇩sF{D} := Val v) a aa b ba (THROW NoSuchFieldError) a aa b False; ⋀C F t D v a aa b ba. ?P ⊢ C has F,NonStatic:t in D ⟹ ?P1.0 (C∙⇩sF{D} := Val v) a aa b ba (THROW IncompatibleClassChangeError) a aa b False; ⋀e a aa b ba e' ab ac bb b' M es. ⟦?P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ?P1.0 e a aa b ba e' ab ac bb b'⟧ ⟹ ?P1.0 (e∙M(es)) a aa b ba (e'∙M(es)) ab ac bb b'; ⋀es a aa b ba es' ab ac bb b' v M. ⟦?P ⊢ ⟨es,(a, aa, b),ba⟩ [→] ⟨es',(ab, ac, bb),b'⟩; ?P2.0 es a aa b ba es' ab ac bb b'⟧ ⟹ ?P1.0 (Val v∙M(es)) a aa b ba (Val v∙M(es')) ab ac bb b'; ⋀h a C fs M Ts T pns body D vs l sh b. ⟦h a = ⌊(C, fs)⌋; ?P ⊢ C sees M, NonStatic : Ts→T = (pns, body) in D; length vs = length pns; length Ts = length pns⟧ ⟹ ?P1.0 (addr a∙M(map Val vs)) h l sh b (blocks (this # pns, Class D # Ts, Addr a # vs, body)) h l sh b; ⋀M vs a aa b ba. ?P1.0 (null∙M(map Val vs)) a aa b ba (THROW NullPointer) a aa b ba; ⋀h a C fs M vs l sh b. ⟦h a = ⌊(C, fs)⌋; ∄b Ts T m D. ?P ⊢ C sees M, b : Ts→T = m in D⟧ ⟹ ?P1.0 (addr a∙M(map Val vs)) h l sh b (THROW NoSuchMethodError) h l sh b; ⋀h a C fs M Ts T aa b D vs l sh ba. ⟦h a = ⌊(C, fs)⌋; ?P ⊢ C sees M, Static : Ts→T = (aa, b) in D⟧ ⟹ ?P1.0 (addr a∙M(map Val vs)) h l sh ba (THROW IncompatibleClassChangeError) h l sh ba; ⋀es a aa b ba es' ab ac bb b' C M. ⟦?P ⊢ ⟨es,(a, aa, b),ba⟩ [→] ⟨es',(ab, ac, bb),b'⟩; ?P2.0 es a aa b ba es' ab ac bb b'⟧ ⟹ ?P1.0 (C∙⇩sM(es)) a aa b ba (C∙⇩sM(es')) ab ac bb b'; ⋀C M Ts T pns body D vs a aa b. ⟦?P ⊢ C sees M, Static : Ts→T = (pns, body) in D; length vs = length pns; length Ts = length pns⟧ ⟹ ?P1.0 (C∙⇩sM(map Val vs)) a aa b True (blocks (pns, Ts, vs, body)) a aa b False; ⋀C M Ts T pns body D sh sfs vs h l. ⟦?P ⊢ C sees M, Static : Ts→T = (pns, body) in D; sh D = ⌊(sfs, Done)⌋ ∨ M = clinit ∧ sh D = ⌊(sfs, Processing)⌋⟧ ⟹ ?P1.0 (C∙⇩sM(map Val vs)) h l sh False (C∙⇩sM(map Val vs)) h l sh True; ⋀C M Ts T pns body D sh vs h l. ⟦?P ⊢ C sees M, Static : Ts→T = (pns, body) in D; ∄sfs. sh D = ⌊(sfs, Done)⌋; M ≠ clinit⟧ ⟹ ?P1.0 (C∙⇩sM(map Val vs)) h l sh False (INIT D ([D],False) ← C∙⇩sM(map Val vs)) h l sh False; ⋀C M vs a aa b ba. ∄b Ts T m. Ex (Method ?P C M b Ts T m) ⟹ ?P1.0 (C∙⇩sM(map Val vs)) a aa b ba (THROW NoSuchMethodError) a aa b False; ⋀C M Ts T a b D vs aa ab ba bb. ?P ⊢ C sees M, NonStatic : Ts→T = (a, b) in D ⟹ ?P1.0 (C∙⇩sM(map Val vs)) aa ab ba bb (THROW IncompatibleClassChangeError) aa ab ba False; ⋀e h l V sh b e' h' l' sh' b' T. ⟦?P ⊢ ⟨e,(h, l(V := None), sh),b⟩ → ⟨e',(h', l', sh'),b'⟩; ?P1.0 e h (l(V := None)) sh b e' h' l' sh' b'; l' V = None; ¬ assigned V e⟧ ⟹ ?P1.0 {V:T; e} h l sh b {V:T; e'} h' (l'(V := l V)) sh' b'; ⋀e h l V sh b e' h' l' sh' b' v T. ⟦?P ⊢ ⟨e,(h, l(V := None), sh),b⟩ → ⟨e',(h', l', sh'),b'⟩; ?P1.0 e h (l(V := None)) sh b e' h' l' sh' b'; l' V = ⌊v⌋; ¬ assigned V e⟧ ⟹ ?P1.0 {V:T; e} h l sh b {V:T; V:=Val v;; e'} h' (l'(V := l V)) sh' b'; ⋀e h l V v sh b e' h' l' sh' b' v' T. ⟦?P ⊢ ⟨e,(h, l(V ↦ v), sh),b⟩ → ⟨e',(h', l', sh'),b'⟩; ?P1.0 e h (l(V ↦ v)) sh b e' h' l' sh' b'; l' V = ⌊v'⌋⟧ ⟹ ?P1.0 {V:T; V:=Val v;; e} h l sh b {V:T; V:=Val v';; e'} h' (l'(V := l V)) sh' b'; ⋀V T u a aa b ba. ?P1.0 {V:T; Val u} a aa b ba (Val u) a aa b ba; ⋀V T v u a aa b ba. ?P1.0 {V:T; V:=Val v;; Val u} a aa b ba (Val u) a aa b ba; ⋀e a aa b ba e' ab ac bb b' e₂. ⟦?P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ?P1.0 e a aa b ba e' ab ac bb b'⟧ ⟹ ?P1.0 (e;; e₂) a aa b ba (e';; e₂) ab ac bb b'; ⋀v e₂ a aa b ba. ?P1.0 (Val v;; e₂) a aa b ba e₂ a aa b ba; ⋀e a aa b ba e' ab ac bb b' e₁ e₂. ⟦?P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ?P1.0 e a aa b ba e' ab ac bb b'⟧ ⟹ ?P1.0 (if (e) e₁ else e₂) a aa b ba (if (e') e₁ else e₂) ab ac bb b'; ⋀e₁ e₂ a aa b ba. ?P1.0 (if (true) e₁ else e₂) a aa b ba e₁ a aa b ba; ⋀e₁ e₂ a aa b ba. ?P1.0 (if (false) e₁ else e₂) a aa b ba e₂ a aa b ba; ⋀b c a aa ba b'. ?P1.0 (while (b) c) a aa ba b' (if (b) (c;; while (b) c) else unit) a aa ba b'; ⋀e a aa b ba e' ab ac bb b'. ⟦?P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ?P1.0 e a aa b ba e' ab ac bb b'⟧ ⟹ ?P1.0 (throw e) a aa b ba (throw e') ab ac bb b'; ⋀a aa b ba. ?P1.0 (throw null) a aa b ba (THROW NullPointer) a aa b ba; ⋀e a aa b ba e' ab ac bb b' C V e₂. ⟦?P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ?P1.0 e a aa b ba e' ab ac bb b'⟧ ⟹ ?P1.0 (try e catch(C V) e₂) a aa b ba (try e' catch(C V) e₂) ab ac bb b'; ⋀v C V e₂ a aa b ba. ?P1.0 (try Val v catch(C V) e₂) a aa b ba (Val v) a aa b ba; ⋀a aa b ab D fs C V e₂ ba. ⟦hp (a, aa, b) ab = ⌊(D, fs)⌋; ?P ⊢ D ≼⇧* C⟧ ⟹ ?P1.0 (try Throw ab catch(C V) e₂) a aa b ba {V:Class C; V:=addr ab;; e₂} a aa b ba; ⋀a aa b ab D fs C V e₂ ba. ⟦hp (a, aa, b) ab = ⌊(D, fs)⌋; (D, C) ∉ (subcls1 ?P)⇧*⟧ ⟹ ?P1.0 (try Throw ab catch(C V) e₂) a aa b ba (Throw ab) a aa b ba; ⋀e a aa b ba e' ab ac bb b' es. ⟦?P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ?P1.0 e a aa b ba e' ab ac bb b'⟧ ⟹ ?P2.0 (e # es) a aa b ba (e' # es) ab ac bb b'; ⋀es a aa b ba es' ab ac bb b' v. ⟦?P ⊢ ⟨es,(a, aa, b),ba⟩ [→] ⟨es',(ab, ac, bb),b'⟩; ?P2.0 es a aa b ba es' ab ac bb b'⟧ ⟹ ?P2.0 (Val v # es) a aa b ba (Val v # es') ab ac bb b'; ⋀e C b a aa ba b'. ¬ sub_RI e ⟹ ?P1.0 (INIT C ([],b) ← e) a aa ba b' e a aa ba (icheck ?P C e); ⋀sh C C' Cs e h l b. sh C = None ⟹ ?P1.0 (INIT C' (C # Cs,False) ← e) h l sh b (INIT C' (C # Cs,False) ← e) h l (sh(C ↦ (sblank ?P C, Prepared))) b; ⋀sh C sfs C' Cs e h l b. sh C = ⌊(sfs, Done)⌋ ⟹ ?P1.0 (INIT C' (C # Cs,False) ← e) h l sh b (INIT C' (Cs,True) ← e) h l sh b; ⋀sh C sfs C' Cs e h l b. sh C = ⌊(sfs, Processing)⌋ ⟹ ?P1.0 (INIT C' (C # Cs,False) ← e) h l sh b (INIT C' (Cs,True) ← e) h l sh b; ⋀sh C sfs C' Cs e h l b. sh C = ⌊(sfs, Error)⌋ ⟹ ?P1.0 (INIT C' (C # Cs,False) ← e) h l sh b (RI (C,THROW NoClassDefFoundError) ; Cs ← e) h l sh b; ⋀sh C sfs sh' C' Cs e h l b. ⟦sh C = ⌊(sfs, Prepared)⌋; C = Object; sh' = sh(C ↦ (sfs, Processing))⟧ ⟹ ?P1.0 (INIT C' (C # Cs,False) ← e) h l sh b (INIT C' (C # Cs,True) ← e) h l sh' b; ⋀sh C sfs D a b sh' C' Cs e h l ba. ⟦sh C = ⌊(sfs, Prepared)⌋; C ≠ Object; class ?P C = ⌊(D, a, b)⌋; sh' = sh(C ↦ (sfs, Processing))⟧ ⟹ ?P1.0 (INIT C' (C # Cs,False) ← e) h l sh ba (INIT C' (D # C # Cs,False) ← e) h l sh' ba; ⋀C' C Cs e h l sh b. ?P1.0 (INIT C' (C # Cs,True) ← e) h l sh b (RI (C,C∙⇩sclinit([])) ; Cs ← e) h l sh b; ⋀e a aa b ba e' ab ac bb b' C Cs e₀. ⟦?P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ?P1.0 e a aa b ba e' ab ac bb b'⟧ ⟹ ?P1.0 (RI (C,e) ; Cs ← e₀) a aa b ba (RI (C,e') ; Cs ← e₀) ab ac bb b'; ⋀sh C sfs i sh' C' Cs v e h l b. ⟦sh C = ⌊(sfs, i)⌋; sh' = sh(C ↦ (sfs, Done)); C' = last (C # Cs)⟧ ⟹ ?P1.0 (RI (C,Val v) ; Cs ← e) h l sh b (INIT C' (Cs,True) ← e) h l sh' b; ⋀C e a aa b ba. ?P1.0 (Cast C (throw e)) a aa b ba (throw e) a aa b ba; ⋀e bop e₂ a aa b ba. ?P1.0 (throw e «bop» e₂) a aa b ba (throw e) a aa b ba; ⋀v₁ bop e a aa b ba. ?P1.0 (Val v₁ «bop» throw e) a aa b ba (throw e) a aa b ba; ⋀V e a aa b ba. ?P1.0 (V:=throw e) a aa b ba (throw e) a aa b ba; ⋀e F D a aa b ba. ?P1.0 (throw e∙F{D}) a aa b ba (throw e) a aa b ba; ⋀e F D e₂ a aa b ba. ?P1.0 (throw e∙F{D} := e₂) a aa b ba (throw e) a aa b ba; ⋀v F D e a aa b ba. ?P1.0 (Val v∙F{D} := throw e) a aa b ba (throw e) a aa b ba; ⋀C F D e a aa b ba. ?P1.0 (C∙⇩sF{D} := throw e) a aa b ba (throw e) a aa b ba; ⋀e M es a aa b ba. ?P1.0 (throw e∙M(es)) a aa b ba (throw e) a aa b ba; ⋀es vs e es' v M a aa b ba. es = map Val vs @ throw e # es' ⟹ ?P1.0 (Val v∙M(es)) a aa b ba (throw e) a aa b ba; ⋀es vs e es' C M a aa b ba. es = map Val vs @ throw e # es' ⟹ ?P1.0 (C∙⇩sM(es)) a aa b ba (throw e) a aa b ba; ⋀V T a aa ab b ba. ?P1.0 {V:T; Throw a} aa ab b ba (Throw a) aa ab b ba; ⋀V T v a aa ab b ba. ?P1.0 {V:T; V:=Val v;; Throw a} aa ab b ba (Throw a) aa ab b ba; ⋀e e₂ a aa b ba. ?P1.0 (throw e;; e₂) a aa b ba (throw e) a aa b ba; ⋀e e₁ e₂ a aa b ba. ?P1.0 (if (throw e) e₁ else e₂) a aa b ba (throw e) a aa b ba; ⋀e a aa b ba. ?P1.0 (throw (throw e)) a aa b ba (throw e) a aa b ba; ⋀sh C sfs i sh' a D Cs e h l b. ⟦sh C = ⌊(sfs, i)⌋; sh' = sh(C ↦ (sfs, Error))⟧ ⟹ ?P1.0 (RI (C,Throw a) ; D # Cs ← e) h l sh b (RI (D,Throw a) ; Cs ← e) h l sh' b; ⋀sh C sfs i sh' a e h l b. ⟦sh C = ⌊(sfs, i)⌋; sh' = sh(C ↦ (sfs, Error))⟧ ⟹ ?P1.0 (RI (C,Throw a) ; [] ← e) h l sh b (Throw a) h l sh' b⟧ ⟹ ?P2.0 ?x7a ?x8a ?x8b ?x8c ?x9a ?x10a ?x11a ?x11b ?x11c ?x12a›*)) (*goals: 1. ‹⋀h a C FDTs h' l sh. ⟦new_Addr h = ⌊a⌋; P ⊢ C has_fields FDTs; h' = h(a ↦ blank P C)⟧ ⟹ dom l ⊆ dom l› 2. ‹⋀h C l sh. ⟦new_Addr h = None; is_class P C⟧ ⟹ dom l ⊆ dom l› 3. ‹⋀sh C sfs h l. sh C = ⌊(sfs, Done)⌋ ⟹ dom l ⊆ dom l› 4. ‹⋀sh C h l. ⟦∄sfs. sh C = ⌊(sfs, Done)⌋; is_class P C⟧ ⟹ dom l ⊆ dom l› 5. ‹⋀e a aa b ba e' ab ac bb b' C. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; dom aa ⊆ dom ac⟧ ⟹ dom aa ⊆ dom ac› 6. ‹⋀C a aa b ba. dom aa ⊆ dom aa› 7. ‹⋀h a D fs C l sh b. ⟦h a = ⌊(D, fs)⌋; P ⊢ D ≼⇧* C⟧ ⟹ dom l ⊆ dom l› 8. ‹⋀h a D fs C l sh b. ⟦h a = ⌊(D, fs)⌋; (D, C) ∉ (subcls1 P)⇧*⟧ ⟹ dom l ⊆ dom l› 9. ‹⋀e a aa b ba e' ab ac bb b' bop e₂. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; dom aa ⊆ dom ac⟧ ⟹ dom aa ⊆ dom ac› 10. ‹⋀e a aa b ba e' ab ac bb b' v₁ bop. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; dom aa ⊆ dom ac⟧ ⟹ dom aa ⊆ dom ac› 11. ‹⋀bop v₁ v₂ v a aa b ba. binop (bop, v₁, v₂) = ⌊v⌋ ⟹ dom aa ⊆ dom aa› 12. ‹⋀l V v h sh b. l V = ⌊v⌋ ⟹ dom l ⊆ dom l› 13. ‹⋀e a aa b ba e' ab ac bb b' V. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; dom aa ⊆ dom ac⟧ ⟹ dom aa ⊆ dom ac› 14. ‹⋀V v h l sh b. dom l ⊆ dom (l(V ↦ v))› 15. ‹⋀e a aa b ba e' ab ac bb b' F D. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; dom aa ⊆ dom ac⟧ ⟹ dom aa ⊆ dom ac› 16. ‹⋀h a C fs F D v t l sh b. ⟦h a = ⌊(C, fs)⌋; fs (F, D) = ⌊v⌋; P ⊢ C has F,NonStatic:t in D⟧ ⟹ dom l ⊆ dom l› 17. ‹⋀F D a aa b ba. dom aa ⊆ dom aa› 18. ‹⋀h a C fs F D l sh b. ⟦h a = ⌊(C, fs)⌋; ∄b t. P ⊢ C has F,b:t in D⟧ ⟹ dom l ⊆ dom l› 19. ‹⋀h a C fs F t D l sh b. ⟦h a = ⌊(C, fs)⌋; P ⊢ C has F,Static:t in D⟧ ⟹ dom l ⊆ dom l› 20. ‹⋀C F t D sh sfs i v h l. ⟦P ⊢ C has F,Static:t in D; sh D = ⌊(sfs, i)⌋; sfs F = ⌊v⌋⟧ ⟹ dom l ⊆ dom l› 21. ‹⋀C F t D sh sfs h l. ⟦P ⊢ C has F,Static:t in D; sh D = ⌊(sfs, Done)⌋⟧ ⟹ dom l ⊆ dom l› 22. ‹⋀C F t D sh h l. ⟦P ⊢ C has F,Static:t in D; ∄sfs. sh D = ⌊(sfs, Done)⌋⟧ ⟹ dom l ⊆ dom l› 23. ‹⋀C F D h l sh b. ∄b t. P ⊢ C has F,b:t in D ⟹ dom l ⊆ dom l› 24. ‹⋀C F t D h l sh b. P ⊢ C has F,NonStatic:t in D ⟹ dom l ⊆ dom l› 25. ‹⋀e a aa b ba e' ab ac bb b' F D e₂. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; dom aa ⊆ dom ac⟧ ⟹ dom aa ⊆ dom ac› 26. ‹⋀e a aa b ba e' ab ac bb b' v F D. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; dom aa ⊆ dom ac⟧ ⟹ dom aa ⊆ dom ac› 27. ‹⋀C F t D h a fs v l sh b. ⟦P ⊢ C has F,NonStatic:t in D; h a = ⌊(C, fs)⌋⟧ ⟹ dom l ⊆ dom l› 28. ‹⋀F D v a aa b ba. dom aa ⊆ dom aa› 29. ‹⋀h a C fs F D v l sh b. ⟦h a = ⌊(C, fs)⌋; ∄b t. P ⊢ C has F,b:t in D⟧ ⟹ dom l ⊆ dom l› 30. ‹⋀h a C fs F t D v l sh b. ⟦h a = ⌊(C, fs)⌋; P ⊢ C has F,Static:t in D⟧ ⟹ dom l ⊆ dom l› 31. ‹⋀e a aa b ba e' ab ac bb b' C F D. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; dom aa ⊆ dom ac⟧ ⟹ dom aa ⊆ dom ac› 32. ‹⋀C F t D sh sfs i sfs' v sh' h l. ⟦P ⊢ C has F,Static:t in D; sh D = ⌊(sfs, i)⌋; sfs' = sfs(F ↦ v); sh' = sh(D ↦ (sfs', i))⟧ ⟹ dom l ⊆ dom l› 33. ‹⋀C F t D sh sfs v h l. ⟦P ⊢ C has F,Static:t in D; sh D = ⌊(sfs, Done)⌋⟧ ⟹ dom l ⊆ dom l› 34. ‹⋀C F t D sh v h l. ⟦P ⊢ C has F,Static:t in D; ∄sfs. sh D = ⌊(sfs, Done)⌋⟧ ⟹ dom l ⊆ dom l› 35. ‹⋀C F D v a aa b ba. ∄b t. P ⊢ C has F,b:t in D ⟹ dom aa ⊆ dom aa› 36. ‹⋀C F t D v a aa b ba. P ⊢ C has F,NonStatic:t in D ⟹ dom aa ⊆ dom aa› 37. ‹⋀e a aa b ba e' ab ac bb b' M es. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; dom aa ⊆ dom ac⟧ ⟹ dom aa ⊆ dom ac› 38. ‹⋀es a aa b ba es' ab ac bb b' v M. ⟦P ⊢ ⟨es,(a, aa, b),ba⟩ [→] ⟨es',(ab, ac, bb),b'⟩; dom aa ⊆ dom ac⟧ ⟹ dom aa ⊆ dom ac› 39. ‹⋀h a C fs M Ts T pns body D vs l sh b. ⟦h a = ⌊(C, fs)⌋; P ⊢ C sees M, NonStatic : Ts→T = (pns, body) in D; length vs = length pns; length Ts = length pns⟧ ⟹ dom l ⊆ dom l› 40. ‹⋀M vs a aa b ba. dom aa ⊆ dom aa› 41. ‹⋀h a C fs M vs l sh b. ⟦h a = ⌊(C, fs)⌋; ∄b Ts T m D. P ⊢ C sees M, b : Ts→T = m in D⟧ ⟹ dom l ⊆ dom l› 42. ‹⋀h a C fs M Ts T aa b D vs l sh ba. ⟦h a = ⌊(C, fs)⌋; P ⊢ C sees M, Static : Ts→T = (aa, b) in D⟧ ⟹ dom l ⊆ dom l› 43. ‹⋀es a aa b ba es' ab ac bb b' C M. ⟦P ⊢ ⟨es,(a, aa, b),ba⟩ [→] ⟨es',(ab, ac, bb),b'⟩; dom aa ⊆ dom ac⟧ ⟹ dom aa ⊆ dom ac› 44. ‹⋀C M Ts T pns body D vs a aa b. ⟦P ⊢ C sees M, Static : Ts→T = (pns, body) in D; length vs = length pns; length Ts = length pns⟧ ⟹ dom aa ⊆ dom aa› 45. ‹⋀C M Ts T pns body D sh sfs vs h l. ⟦P ⊢ C sees M, Static : Ts→T = (pns, body) in D; sh D = ⌊(sfs, Done)⌋ ∨ M = clinit ∧ sh D = ⌊(sfs, Processing)⌋⟧ ⟹ dom l ⊆ dom l› 46. ‹⋀C M Ts T pns body D sh vs h l. ⟦P ⊢ C sees M, Static : Ts→T = (pns, body) in D; ∄sfs. sh D = ⌊(sfs, Done)⌋; M ≠ clinit⟧ ⟹ dom l ⊆ dom l› 47. ‹⋀C M vs a aa b ba. ∄b Ts T m. Ex (Method P C M b Ts T m) ⟹ dom aa ⊆ dom aa› 48. ‹⋀C M Ts T a b D vs aa ab ba bb. P ⊢ C sees M, NonStatic : Ts→T = (a, b) in D ⟹ dom ab ⊆ dom ab› 49. ‹⋀e h l V sh b e' h' l' sh' b' T. ⟦P ⊢ ⟨e,(h, l(V := None), sh),b⟩ → ⟨e',(h', l', sh'),b'⟩; dom (l(V := None)) ⊆ dom l'; l' V = None; ¬ assigned V e⟧ ⟹ dom l ⊆ dom (l'(V := l V))› 50. ‹⋀e h l V sh b e' h' l' sh' b' v T. ⟦P ⊢ ⟨e,(h, l(V := None), sh),b⟩ → ⟨e',(h', l', sh'),b'⟩; dom (l(V := None)) ⊆ dom l'; l' V = ⌊v⌋; ¬ assigned V e⟧ ⟹ dom l ⊆ dom (l'(V := l V))› 51. ‹⋀e h l V v sh b e' h' l' sh' b' v' T. ⟦P ⊢ ⟨e,(h, l(V ↦ v), sh),b⟩ → ⟨e',(h', l', sh'),b'⟩; dom (l(V ↦ v)) ⊆ dom l'; l' V = ⌊v'⌋⟧ ⟹ dom l ⊆ dom (l'(V := l V))› 52. ‹⋀V T u a aa b ba. dom aa ⊆ dom aa› 53. ‹⋀V T v u a aa b ba. dom aa ⊆ dom aa› 54. ‹⋀e a aa b ba e' ab ac bb b' e₂. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; dom aa ⊆ dom ac⟧ ⟹ dom aa ⊆ dom ac› 55. ‹⋀v e₂ a aa b ba. dom aa ⊆ dom aa› 56. ‹⋀e a aa b ba e' ab ac bb b' e₁ e₂. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; dom aa ⊆ dom ac⟧ ⟹ dom aa ⊆ dom ac› 57. ‹⋀e₁ e₂ a aa b ba. dom aa ⊆ dom aa› 58. ‹⋀e₁ e₂ a aa b ba. dom aa ⊆ dom aa› 59. ‹⋀b c a aa ba b'. dom aa ⊆ dom aa› 60. ‹⋀e a aa b ba e' ab ac bb b'. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; dom aa ⊆ dom ac⟧ ⟹ dom aa ⊆ dom ac› 61. ‹⋀a aa b ba. dom aa ⊆ dom aa› 62. ‹⋀e a aa b ba e' ab ac bb b' C V e₂. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; dom aa ⊆ dom ac⟧ ⟹ dom aa ⊆ dom ac› 63. ‹⋀v C V e₂ a aa b ba. dom aa ⊆ dom aa› 64. ‹⋀a aa b ab D fs C V e₂ ba. ⟦hp (a, aa, b) ab = ⌊(D, fs)⌋; P ⊢ D ≼⇧* C⟧ ⟹ dom aa ⊆ dom aa› 65. ‹⋀a aa b ab D fs C V e₂ ba. ⟦hp (a, aa, b) ab = ⌊(D, fs)⌋; (D, C) ∉ (subcls1 P)⇧*⟧ ⟹ dom aa ⊆ dom aa› 66. ‹⋀e a aa b ba e' ab ac bb b' es. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; dom aa ⊆ dom ac⟧ ⟹ dom aa ⊆ dom ac› 67. ‹⋀es a aa b ba es' ab ac bb b' v. ⟦P ⊢ ⟨es,(a, aa, b),ba⟩ [→] ⟨es',(ab, ac, bb),b'⟩; dom aa ⊆ dom ac⟧ ⟹ dom aa ⊆ dom ac› 68. ‹⋀e C b a aa ba b'. ¬ sub_RI e ⟹ dom aa ⊆ dom aa› 69. ‹⋀sh C C' Cs e h l b. sh C = None ⟹ dom l ⊆ dom l› 70. ‹⋀sh C sfs C' Cs e h l b. sh C = ⌊(sfs, Done)⌋ ⟹ dom l ⊆ dom l› 71. ‹⋀sh C sfs C' Cs e h l b. sh C = ⌊(sfs, Processing)⌋ ⟹ dom l ⊆ dom l› 72. ‹⋀sh C sfs C' Cs e h l b. sh C = ⌊(sfs, Error)⌋ ⟹ dom l ⊆ dom l› 73. ‹⋀sh C sfs sh' C' Cs e h l b. ⟦sh C = ⌊(sfs, Prepared)⌋; C = Object; sh' = sh(C ↦ (sfs, Processing))⟧ ⟹ dom l ⊆ dom l› 74. ‹⋀sh C sfs D a b sh' C' Cs e h l ba. ⟦sh C = ⌊(sfs, Prepared)⌋; C ≠ Object; class P C = ⌊(D, a, b)⌋; sh' = sh(C ↦ (sfs, Processing))⟧ ⟹ dom l ⊆ dom l› 75. ‹⋀C' C Cs e h l sh b. dom l ⊆ dom l› 76. ‹⋀e a aa b ba e' ab ac bb b' C Cs e₀. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; dom aa ⊆ dom ac⟧ ⟹ dom aa ⊆ dom ac› 77. ‹⋀sh C sfs i sh' C' Cs v e h l b. ⟦sh C = ⌊(sfs, i)⌋; sh' = sh(C ↦ (sfs, Done)); C' = last (C # Cs)⟧ ⟹ dom l ⊆ dom l› 78. ‹⋀C e a aa b ba. dom aa ⊆ dom aa› 79. ‹⋀e bop e₂ a aa b ba. dom aa ⊆ dom aa› 80. ‹⋀v₁ bop e a aa b ba. dom aa ⊆ dom aa› 81. ‹⋀V e a aa b ba. dom aa ⊆ dom aa› 82. ‹⋀e F D a aa b ba. dom aa ⊆ dom aa› 83. ‹⋀e F D e₂ a aa b ba. dom aa ⊆ dom aa› 84. ‹⋀v F D e a aa b ba. dom aa ⊆ dom aa› 85. ‹⋀C F D e a aa b ba. dom aa ⊆ dom aa› 86. ‹⋀e M es a aa b ba. dom aa ⊆ dom aa› 87. ‹⋀es vs e es' v M a aa b ba. es = map Val vs @ throw e # es' ⟹ dom aa ⊆ dom aa› 88. ‹⋀es vs e es' C M a aa b ba. es = map Val vs @ throw e # es' ⟹ dom aa ⊆ dom aa› 89. ‹⋀V T a aa ab b ba. dom ab ⊆ dom ab› 90. ‹⋀V T v a aa ab b ba. dom ab ⊆ dom ab› 91. ‹⋀e e₂ a aa b ba. dom aa ⊆ dom aa› 92. ‹⋀e e₁ e₂ a aa b ba. dom aa ⊆ dom aa› 93. ‹⋀e a aa b ba. dom aa ⊆ dom aa› 94. ‹⋀sh C sfs i sh' a D Cs e h l b. ⟦sh C = ⌊(sfs, i)⌋; sh' = sh(C ↦ (sfs, Error))⟧ ⟹ dom l ⊆ dom l› 95. ‹⋀sh C sfs i sh' a e h l b. ⟦sh C = ⌊(sfs, i)⌋; sh' = sh(C ↦ (sfs, Error))⟧ ⟹ dom l ⊆ dom l› discuss goal 1*) apply ((auto simp del:fun_upd_apply (*‹(?f(?x := ?y)) ?z = (if ?z = ?x then ?y else ?f ?z)›*))[1]) (*discuss goal 2*) apply ((auto simp del:fun_upd_apply (*‹(?f(?x := ?y)) ?z = (if ?z = ?x then ?y else ?f ?z)›*))[1]) (*discuss goal 3*) apply ((auto simp del:fun_upd_apply (*‹(?f(?x := ?y)) ?z = (if ?z = ?x then ?y else ?f ?z)›*))[1]) (*discuss goal 4*) apply ((auto simp del:fun_upd_apply (*‹(?f(?x := ?y)) ?z = (if ?z = ?x then ?y else ?f ?z)›*))[1]) (*discuss goal 5*) apply ((auto simp del:fun_upd_apply (*‹(?f(?x := ?y)) ?z = (if ?z = ?x then ?y else ?f ?z)›*))[1]) (*discuss goal 6*) apply ((auto simp del:fun_upd_apply (*‹(?f(?x := ?y)) ?z = (if ?z = ?x then ?y else ?f ?z)›*))[1]) (*discuss goal 7*) apply ((auto simp del:fun_upd_apply (*‹(?f(?x := ?y)) ?z = (if ?z = ?x then ?y else ?f ?z)›*))[1]) (*discuss goal 8*) apply ((auto simp del:fun_upd_apply (*‹(?f(?x := ?y)) ?z = (if ?z = ?x then ?y else ?f ?z)›*))[1]) (*discuss goal 9*) apply ((auto simp del:fun_upd_apply (*‹(?f(?x := ?y)) ?z = (if ?z = ?x then ?y else ?f ?z)›*))[1]) (*discuss goal 10*) apply ((auto simp del:fun_upd_apply (*‹(?f(?x := ?y)) ?z = (if ?z = ?x then ?y else ?f ?z)›*))[1]) (*discuss goal 11*) apply ((auto simp del:fun_upd_apply (*‹(?f(?x := ?y)) ?z = (if ?z = ?x then ?y else ?f ?z)›*))[1]) (*discuss goal 12*) apply ((auto simp del:fun_upd_apply (*‹(?f(?x := ?y)) ?z = (if ?z = ?x then ?y else ?f ?z)›*))[1]) (*discuss goal 13*) apply ((auto simp del:fun_upd_apply (*‹(?f(?x := ?y)) ?z = (if ?z = ?x then ?y else ?f ?z)›*))[1]) (*discuss goal 14*) apply ((auto simp del:fun_upd_apply (*‹(?f(?x := ?y)) ?z = (if ?z = ?x then ?y else ?f ?z)›*))[1]) (*discuss goal 15*) apply ((auto simp del:fun_upd_apply (*‹(?f(?x := ?y)) ?z = (if ?z = ?x then ?y else ?f ?z)›*))[1]) (*discuss goal 16*) apply ((auto simp del:fun_upd_apply (*‹(?f(?x := ?y)) ?z = (if ?z = ?x then ?y else ?f ?z)›*))[1]) (*discuss goal 17*) apply ((auto simp del:fun_upd_apply (*‹(?f(?x := ?y)) ?z = (if ?z = ?x then ?y else ?f ?z)›*))[1]) (*discuss goal 18*) apply ((auto simp del:fun_upd_apply (*‹((?f::?'b ⇒ ?'a)(?x::?'b := ?y::?'a)) (?z::?'b) = (if ?z = ?x then ?y else ?f ?z)›*))[1]) (*discuss goal 19*) apply ((auto simp del:fun_upd_apply (*‹((?f::?'b ⇒ ?'a)(?x::?'b := ?y::?'a)) (?z::?'b) = (if ?z = ?x then ?y else ?f ?z)›*))[1]) (*discuss goal 20*) apply ((auto simp del:fun_upd_apply (*‹(?f(?x := ?y)) ?z = (if ?z = ?x then ?y else ?f ?z)›*))[1]) (*discuss goal 21*) apply ((auto simp del:fun_upd_apply (*‹(?f(?x := ?y)) ?z = (if ?z = ?x then ?y else ?f ?z)›*))[1]) (*discuss goal 22*) apply ((auto simp del:fun_upd_apply (*‹(?f(?x := ?y)) ?z = (if ?z = ?x then ?y else ?f ?z)›*))[1]) (*discuss goal 23*) apply ((auto simp del:fun_upd_apply (*‹((?f::?'b::type ⇒ ?'a::type)(?x::?'b::type := ?y::?'a::type)) (?z::?'b::type) = (if ?z = ?x then ?y else ?f ?z)›*))[1]) (*discuss goal 24*) apply ((auto simp del:fun_upd_apply (*‹(?f(?x := ?y)) ?z = (if ?z = ?x then ?y else ?f ?z)›*))[1]) (*discuss goal 25*) apply ((auto simp del:fun_upd_apply (*‹(?f(?x := ?y)) ?z = (if ?z = ?x then ?y else ?f ?z)›*))[1]) (*discuss goal 26*) apply ((auto simp del:fun_upd_apply (*‹(?f(?x := ?y)) ?z = (if ?z = ?x then ?y else ?f ?z)›*))[1]) (*discuss goal 27*) apply ((auto simp del:fun_upd_apply (*‹(?f(?x := ?y)) ?z = (if ?z = ?x then ?y else ?f ?z)›*))[1]) (*discuss goal 28*) apply ((auto simp del:fun_upd_apply (*‹(?f(?x := ?y)) ?z = (if ?z = ?x then ?y else ?f ?z)›*))[1]) (*discuss goal 29*) apply ((auto simp del:fun_upd_apply (*‹(?f(?x := ?y)) ?z = (if ?z = ?x then ?y else ?f ?z)›*))[1]) (*discuss goal 30*) apply ((auto simp del:fun_upd_apply (*‹(?f(?x := ?y)) ?z = (if ?z = ?x then ?y else ?f ?z)›*))[1]) (*discuss goal 31*) apply ((auto simp del:fun_upd_apply (*‹(?f(?x := ?y)) ?z = (if ?z = ?x then ?y else ?f ?z)›*))[1]) (*discuss goal 32*) apply ((auto simp del:fun_upd_apply (*‹(?f(?x := ?y)) ?z = (if ?z = ?x then ?y else ?f ?z)›*))[1]) (*discuss goal 33*) apply ((auto simp del:fun_upd_apply (*‹(?f(?x := ?y)) ?z = (if ?z = ?x then ?y else ?f ?z)›*))[1]) (*discuss goal 34*) apply ((auto simp del:fun_upd_apply (*‹(?f(?x := ?y)) ?z = (if ?z = ?x then ?y else ?f ?z)›*))[1]) (*discuss goal 35*) apply ((auto simp del:fun_upd_apply (*‹((?f::?'b ⇒ ?'a)(?x::?'b := ?y::?'a)) (?z::?'b) = (if ?z = ?x then ?y else ?f ?z)›*))[1]) (*discuss goal 36*) apply ((auto simp del:fun_upd_apply (*‹((?f::?'b ⇒ ?'a)(?x::?'b := ?y::?'a)) (?z::?'b) = (if ?z = ?x then ?y else ?f ?z)›*))[1]) (*discuss goal 37*) apply ((auto simp del:fun_upd_apply (*‹(?f(?x := ?y)) ?z = (if ?z = ?x then ?y else ?f ?z)›*))[1]) (*discuss goal 38*) apply ((auto simp del:fun_upd_apply (*‹(?f(?x := ?y)) ?z = (if ?z = ?x then ?y else ?f ?z)›*))[1]) (*discuss goal 39*) apply ((auto simp del:fun_upd_apply (*‹((?f::?'b::type ⇒ ?'a::type)(?x::?'b::type := ?y::?'a::type)) (?z::?'b::type) = (if ?z = ?x then ?y else ?f ?z)›*))[1]) (*discuss goal 40*) apply ((auto simp del:fun_upd_apply (*‹(?f(?x := ?y)) ?z = (if ?z = ?x then ?y else ?f ?z)›*))[1]) (*discuss goal 41*) apply ((auto simp del:fun_upd_apply (*‹(?f(?x := ?y)) ?z = (if ?z = ?x then ?y else ?f ?z)›*))[1]) (*discuss goal 42*) apply ((auto simp del:fun_upd_apply (*‹((?f::?'b::type ⇒ ?'a::type)(?x::?'b::type := ?y::?'a::type)) (?z::?'b::type) = (if ?z = ?x then ?y else ?f ?z)›*))[1]) (*discuss goal 43*) apply ((auto simp del:fun_upd_apply (*‹(?f(?x := ?y)) ?z = (if ?z = ?x then ?y else ?f ?z)›*))[1]) (*discuss goal 44*) apply ((auto simp del:fun_upd_apply (*‹(?f(?x := ?y)) ?z = (if ?z = ?x then ?y else ?f ?z)›*))[1]) (*discuss goal 45*) apply ((auto simp del:fun_upd_apply (*‹(?f(?x := ?y)) ?z = (if ?z = ?x then ?y else ?f ?z)›*))[1]) (*discuss goal 46*) apply ((auto simp del:fun_upd_apply (*‹(?f(?x := ?y)) ?z = (if ?z = ?x then ?y else ?f ?z)›*))[1]) (*discuss goal 47*) apply ((auto simp del:fun_upd_apply (*‹(?f(?x := ?y)) ?z = (if ?z = ?x then ?y else ?f ?z)›*))[1]) (*discuss goal 48*) apply ((auto simp del:fun_upd_apply (*‹(?f(?x := ?y)) ?z = (if ?z = ?x then ?y else ?f ?z)›*))[1]) (*discuss goal 49*) apply ((auto simp del:fun_upd_apply (*‹(?f(?x := ?y)) ?z = (if ?z = ?x then ?y else ?f ?z)›*))[1]) (*discuss goal 50*) apply ((auto simp del:fun_upd_apply (*‹(?f(?x := ?y)) ?z = (if ?z = ?x then ?y else ?f ?z)›*))[1]) (*discuss goal 51*) apply ((auto simp del:fun_upd_apply (*‹(?f(?x := ?y)) ?z = (if ?z = ?x then ?y else ?f ?z)›*))[1]) (*discuss goal 52*) apply ((auto simp del:fun_upd_apply (*‹(?f(?x := ?y)) ?z = (if ?z = ?x then ?y else ?f ?z)›*))[1]) (*discuss goal 53*) apply ((auto simp del:fun_upd_apply (*‹((?f::?'b ⇒ ?'a)(?x::?'b := ?y::?'a)) (?z::?'b) = (if ?z = ?x then ?y else ?f ?z)›*))[1]) (*discuss goal 54*) apply ((auto simp del:fun_upd_apply (*‹((?f::?'b ⇒ ?'a)(?x::?'b := ?y::?'a)) (?z::?'b) = (if ?z = ?x then ?y else ?f ?z)›*))[1]) (*discuss goal 55*) apply ((auto simp del:fun_upd_apply (*‹(?f(?x := ?y)) ?z = (if ?z = ?x then ?y else ?f ?z)›*))[1]) (*discuss goal 56*) apply ((auto simp del:fun_upd_apply (*‹(?f(?x := ?y)) ?z = (if ?z = ?x then ?y else ?f ?z)›*))[1]) (*discuss goal 57*) apply ((auto simp del:fun_upd_apply (*‹(?f(?x := ?y)) ?z = (if ?z = ?x then ?y else ?f ?z)›*))[1]) (*discuss goal 58*) apply ((auto simp del:fun_upd_apply (*‹(?f(?x := ?y)) ?z = (if ?z = ?x then ?y else ?f ?z)›*))[1]) (*discuss goal 59*) apply ((auto simp del:fun_upd_apply (*‹(?f(?x := ?y)) ?z = (if ?z = ?x then ?y else ?f ?z)›*))[1]) (*discuss goal 60*) apply ((auto simp del:fun_upd_apply (*‹(?f(?x := ?y)) ?z = (if ?z = ?x then ?y else ?f ?z)›*))[1]) (*discuss goal 61*) apply ((auto simp del:fun_upd_apply (*‹(?f(?x := ?y)) ?z = (if ?z = ?x then ?y else ?f ?z)›*))[1]) (*discuss goal 62*) apply ((auto simp del:fun_upd_apply (*‹((?f::?'b::type ⇒ ?'a::type)(?x::?'b::type := ?y::?'a::type)) (?z::?'b::type) = (if ?z = ?x then ?y else ?f ?z)›*))[1]) (*discuss goal 63*) apply ((auto simp del:fun_upd_apply (*‹(?f(?x := ?y)) ?z = (if ?z = ?x then ?y else ?f ?z)›*))[1]) (*discuss goal 64*) apply ((auto simp del:fun_upd_apply (*‹((?f::?'b ⇒ ?'a)(?x::?'b := ?y::?'a)) (?z::?'b) = (if ?z = ?x then ?y else ?f ?z)›*))[1]) (*discuss goal 65*) apply ((auto simp del:fun_upd_apply (*‹(?f(?x := ?y)) ?z = (if ?z = ?x then ?y else ?f ?z)›*))[1]) (*discuss goal 66*) apply ((auto simp del:fun_upd_apply (*‹(?f(?x := ?y)) ?z = (if ?z = ?x then ?y else ?f ?z)›*))[1]) (*discuss goal 67*) apply ((auto simp del:fun_upd_apply (*‹(?f(?x := ?y)) ?z = (if ?z = ?x then ?y else ?f ?z)›*))[1]) (*discuss goal 68*) apply ((auto simp del:fun_upd_apply (*‹((?f::?'b::type ⇒ ?'a::type)(?x::?'b::type := ?y::?'a::type)) (?z::?'b::type) = (if ?z = ?x then ?y else ?f ?z)›*))[1]) (*discuss goal 69*) apply ((auto simp del:fun_upd_apply (*‹(?f(?x := ?y)) ?z = (if ?z = ?x then ?y else ?f ?z)›*))[1]) (*discuss goal 70*) apply ((auto simp del:fun_upd_apply (*‹((?f::?'b ⇒ ?'a)(?x::?'b := ?y::?'a)) (?z::?'b) = (if ?z = ?x then ?y else ?f ?z)›*))[1]) (*discuss goal 71*) apply ((auto simp del:fun_upd_apply (*‹(?f(?x := ?y)) ?z = (if ?z = ?x then ?y else ?f ?z)›*))[1]) (*discuss goal 72*) apply ((auto simp del:fun_upd_apply (*‹((?f::?'b ⇒ ?'a)(?x::?'b := ?y::?'a)) (?z::?'b) = (if ?z = ?x then ?y else ?f ?z)›*))[1]) (*discuss goal 73*) apply ((auto simp del:fun_upd_apply (*‹((?f::?'b ⇒ ?'a)(?x::?'b := ?y::?'a)) (?z::?'b) = (if ?z = ?x then ?y else ?f ?z)›*))[1]) (*discuss goal 74*) apply ((auto simp del:fun_upd_apply (*‹(?f(?x := ?y)) ?z = (if ?z = ?x then ?y else ?f ?z)›*))[1]) (*discuss goal 75*) apply ((auto simp del:fun_upd_apply (*‹(?f(?x := ?y)) ?z = (if ?z = ?x then ?y else ?f ?z)›*))[1]) (*discuss goal 76*) apply ((auto simp del:fun_upd_apply (*‹((?f::?'b ⇒ ?'a)(?x::?'b := ?y::?'a)) (?z::?'b) = (if ?z = ?x then ?y else ?f ?z)›*))[1]) (*discuss goal 77*) apply ((auto simp del:fun_upd_apply (*‹(?f(?x := ?y)) ?z = (if ?z = ?x then ?y else ?f ?z)›*))[1]) (*discuss goal 78*) apply ((auto simp del:fun_upd_apply (*‹(?f(?x := ?y)) ?z = (if ?z = ?x then ?y else ?f ?z)›*))[1]) (*discuss goal 79*) apply ((auto simp del:fun_upd_apply (*‹((?f::?'b ⇒ ?'a)(?x::?'b := ?y::?'a)) (?z::?'b) = (if ?z = ?x then ?y else ?f ?z)›*))[1]) (*discuss goal 80*) apply ((auto simp del:fun_upd_apply (*‹(?f(?x := ?y)) ?z = (if ?z = ?x then ?y else ?f ?z)›*))[1]) (*discuss goal 81*) apply ((auto simp del:fun_upd_apply (*‹(?f(?x := ?y)) ?z = (if ?z = ?x then ?y else ?f ?z)›*))[1]) (*discuss goal 82*) apply ((auto simp del:fun_upd_apply (*‹(?f(?x := ?y)) ?z = (if ?z = ?x then ?y else ?f ?z)›*))[1]) (*discuss goal 83*) apply ((auto simp del:fun_upd_apply (*‹((?f::?'b ⇒ ?'a)(?x::?'b := ?y::?'a)) (?z::?'b) = (if ?z = ?x then ?y else ?f ?z)›*))[1]) (*discuss goal 84*) apply ((auto simp del:fun_upd_apply (*‹(?f(?x := ?y)) ?z = (if ?z = ?x then ?y else ?f ?z)›*))[1]) (*discuss goal 85*) apply ((auto simp del:fun_upd_apply (*‹(?f(?x := ?y)) ?z = (if ?z = ?x then ?y else ?f ?z)›*))[1]) (*discuss goal 86*) apply ((auto simp del:fun_upd_apply (*‹(?f(?x := ?y)) ?z = (if ?z = ?x then ?y else ?f ?z)›*))[1]) (*discuss goal 87*) apply ((auto simp del:fun_upd_apply (*‹(?f(?x := ?y)) ?z = (if ?z = ?x then ?y else ?f ?z)›*))[1]) (*discuss goal 88*) apply ((auto simp del:fun_upd_apply (*‹(?f(?x := ?y)) ?z = (if ?z = ?x then ?y else ?f ?z)›*))[1]) (*discuss goal 89*) apply ((auto simp del:fun_upd_apply (*‹((?f::?'b::type ⇒ ?'a::type)(?x::?'b::type := ?y::?'a::type)) (?z::?'b::type) = (if ?z = ?x then ?y else ?f ?z)›*))[1]) (*discuss goal 90*) apply ((auto simp del:fun_upd_apply (*‹((?f::?'b::type ⇒ ?'a::type)(?x::?'b::type := ?y::?'a::type)) (?z::?'b::type) = (if ?z = ?x then ?y else ?f ?z)›*))[1]) (*discuss goal 91*) apply ((auto simp del:fun_upd_apply (*‹(?f(?x := ?y)) ?z = (if ?z = ?x then ?y else ?f ?z)›*))[1]) (*discuss goal 92*) apply ((auto simp del:fun_upd_apply (*‹(?f(?x := ?y)) ?z = (if ?z = ?x then ?y else ?f ?z)›*))[1]) (*discuss goal 93*) apply ((auto simp del:fun_upd_apply (*‹(?f(?x := ?y)) ?z = (if ?z = ?x then ?y else ?f ?z)›*))[1]) (*discuss goal 94*) apply ((auto simp del:fun_upd_apply (*‹(?f(?x := ?y)) ?z = (if ?z = ?x then ?y else ?f ?z)›*))[1]) (*discuss goal 95*) apply ((auto simp del:fun_upd_apply (*‹(?f(?x := ?y)) ?z = (if ?z = ?x then ?y else ?f ?z)›*))[1]) (*proven 95 subgoals*) .(*>*) lemma red_lcl_add: "P ⊢ ⟨e,(h,l,sh),b⟩ → ⟨e',(h',l',sh'),b'⟩ ⟹ (⋀l₀. P ⊢ ⟨e,(h,l₀++l,sh),b⟩ → ⟨e',(h',l₀++l',sh'),b'⟩)" and reds_lcl_add: "P ⊢ ⟨es,(h,l,sh),b⟩ [→] ⟨es',(h',l',sh'),b'⟩ ⟹ (⋀l₀. P ⊢ ⟨es,(h,l₀++l,sh),b⟩ [→] ⟨es',(h',l₀++l',sh'),b'⟩)" (*<*) proof (induct rule:red_reds_inducts (*‹⟦?P ⊢ ⟨?x1a,(?x2a, ?x2b, ?x2c),?x3a⟩ → ⟨?x4a,(?x5a, ?x5b, ?x5c),?x6a⟩; ⋀h a C FDTs h' l sh. ⟦new_Addr h = ⌊a⌋; ?P ⊢ C has_fields FDTs; h' = h(a ↦ blank ?P C)⟧ ⟹ ?P1.0 (new C) h l sh True (addr a) h' l sh False; ⋀h C l sh. ⟦new_Addr h = None; is_class ?P C⟧ ⟹ ?P1.0 (new C) h l sh True (THROW OutOfMemory) h l sh False; ⋀sh C sfs h l. sh C = ⌊(sfs, Done)⌋ ⟹ ?P1.0 (new C) h l sh False (new C) h l sh True; ⋀sh C h l. ⟦∄sfs. sh C = ⌊(sfs, Done)⌋; is_class ?P C⟧ ⟹ ?P1.0 (new C) h l sh False (INIT C ([C],False) ← new C) h l sh False; ⋀e a aa b ba e' ab ac bb b' C. ⟦?P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ?P1.0 e a aa b ba e' ab ac bb b'⟧ ⟹ ?P1.0 (Cast C e) a aa b ba (Cast C e') ab ac bb b'; ⋀C a aa b ba. ?P1.0 (Cast C null) a aa b ba null a aa b ba; ⋀h a D fs C l sh b. ⟦h a = ⌊(D, fs)⌋; ?P ⊢ D ≼⇧* C⟧ ⟹ ?P1.0 (Cast C (addr a)) h l sh b (addr a) h l sh b; ⋀h a D fs C l sh b. ⟦h a = ⌊(D, fs)⌋; (D, C) ∉ (subcls1 ?P)⇧*⟧ ⟹ ?P1.0 (Cast C (addr a)) h l sh b (THROW ClassCast) h l sh b; ⋀e a aa b ba e' ab ac bb b' bop e₂. ⟦?P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ?P1.0 e a aa b ba e' ab ac bb b'⟧ ⟹ ?P1.0 (e «bop» e₂) a aa b ba (e' «bop» e₂) ab ac bb b'; ⋀e a aa b ba e' ab ac bb b' v₁ bop. ⟦?P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ?P1.0 e a aa b ba e' ab ac bb b'⟧ ⟹ ?P1.0 (Val v₁ «bop» e) a aa b ba (Val v₁ «bop» e') ab ac bb b'; ⋀bop v₁ v₂ v a aa b ba. binop (bop, v₁, v₂) = ⌊v⌋ ⟹ ?P1.0 (Val v₁ «bop» Val v₂) a aa b ba (Val v) a aa b ba; ⋀l V v h sh b. l V = ⌊v⌋ ⟹ ?P1.0 (Var V) h l sh b (Val v) h l sh b; ⋀e a aa b ba e' ab ac bb b' V. ⟦?P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ?P1.0 e a aa b ba e' ab ac bb b'⟧ ⟹ ?P1.0 (V:=e) a aa b ba (V:=e') ab ac bb b'; ⋀V v h l sh b. ?P1.0 (V:=Val v) h l sh b unit h (l(V ↦ v)) sh b; ⋀e a aa b ba e' ab ac bb b' F D. ⟦?P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ?P1.0 e a aa b ba e' ab ac bb b'⟧ ⟹ ?P1.0 (e∙F{D}) a aa b ba (e'∙F{D}) ab ac bb b'; ⋀h a C fs F D v t l sh b. ⟦h a = ⌊(C, fs)⌋; fs (F, D) = ⌊v⌋; ?P ⊢ C has F,NonStatic:t in D⟧ ⟹ ?P1.0 (addr a∙F{D}) h l sh b (Val v) h l sh b; ⋀F D a aa b ba. ?P1.0 (null∙F{D}) a aa b ba (THROW NullPointer) a aa b ba; ⋀h a C fs F D l sh b. ⟦h a = ⌊(C, fs)⌋; ∄b t. ?P ⊢ C has F,b:t in D⟧ ⟹ ?P1.0 (addr a∙F{D}) h l sh b (THROW NoSuchFieldError) h l sh b; ⋀h a C fs F t D l sh b. ⟦h a = ⌊(C, fs)⌋; ?P ⊢ C has F,Static:t in D⟧ ⟹ ?P1.0 (addr a∙F{D}) h l sh b (THROW IncompatibleClassChangeError) h l sh b; ⋀C F t D sh sfs i v h l. ⟦?P ⊢ C has F,Static:t in D; sh D = ⌊(sfs, i)⌋; sfs F = ⌊v⌋⟧ ⟹ ?P1.0 (C∙⇩sF{D}) h l sh True (Val v) h l sh False; ⋀C F t D sh sfs h l. ⟦?P ⊢ C has F,Static:t in D; sh D = ⌊(sfs, Done)⌋⟧ ⟹ ?P1.0 (C∙⇩sF{D}) h l sh False (C∙⇩sF{D}) h l sh True; ⋀C F t D sh h l. ⟦?P ⊢ C has F,Static:t in D; ∄sfs. sh D = ⌊(sfs, Done)⌋⟧ ⟹ ?P1.0 (C∙⇩sF{D}) h l sh False (INIT D ([D],False) ← C∙⇩sF{D}) h l sh False; ⋀C F D h l sh b. ∄b t. ?P ⊢ C has F,b:t in D ⟹ ?P1.0 (C∙⇩sF{D}) h l sh b (THROW NoSuchFieldError) h l sh False; ⋀C F t D h l sh b. ?P ⊢ C has F,NonStatic:t in D ⟹ ?P1.0 (C∙⇩sF{D}) h l sh b (THROW IncompatibleClassChangeError) h l sh False; ⋀e a aa b ba e' ab ac bb b' F D e₂. ⟦?P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ?P1.0 e a aa b ba e' ab ac bb b'⟧ ⟹ ?P1.0 (e∙F{D} := e₂) a aa b ba (e'∙F{D} := e₂) ab ac bb b'; ⋀e a aa b ba e' ab ac bb b' v F D. ⟦?P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ?P1.0 e a aa b ba e' ab ac bb b'⟧ ⟹ ?P1.0 (Val v∙F{D} := e) a aa b ba (Val v∙F{D} := e') ab ac bb b'; ⋀C F t D h a fs v l sh b. ⟦?P ⊢ C has F,NonStatic:t in D; h a = ⌊(C, fs)⌋⟧ ⟹ ?P1.0 (addr a∙F{D} := Val v) h l sh b unit (h(a ↦ (C, fs((F, D) ↦ v)))) l sh b; ⋀F D v a aa b ba. ?P1.0 (null∙F{D} := Val v) a aa b ba (THROW NullPointer) a aa b ba; ⋀h a C fs F D v l sh b. ⟦h a = ⌊(C, fs)⌋; ∄b t. ?P ⊢ C has F,b:t in D⟧ ⟹ ?P1.0 (addr a∙F{D} := Val v) h l sh b (THROW NoSuchFieldError) h l sh b; ⋀h a C fs F t D v l sh b. ⟦h a = ⌊(C, fs)⌋; ?P ⊢ C has F,Static:t in D⟧ ⟹ ?P1.0 (addr a∙F{D} := Val v) h l sh b (THROW IncompatibleClassChangeError) h l sh b; ⋀e a aa b ba e' ab ac bb b' C F D. ⟦?P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ?P1.0 e a aa b ba e' ab ac bb b'⟧ ⟹ ?P1.0 (C∙⇩sF{D} := e) a aa b ba (C∙⇩sF{D} := e') ab ac bb b'; ⋀C F t D sh sfs i sfs' v sh' h l. ⟦?P ⊢ C has F,Static:t in D; sh D = ⌊(sfs, i)⌋; sfs' = sfs(F ↦ v); sh' = sh(D ↦ (sfs', i))⟧ ⟹ ?P1.0 (C∙⇩sF{D} := Val v) h l sh True unit h l sh' False; ⋀C F t D sh sfs v h l. ⟦?P ⊢ C has F,Static:t in D; sh D = ⌊(sfs, Done)⌋⟧ ⟹ ?P1.0 (C∙⇩sF{D} := Val v) h l sh False (C∙⇩sF{D} := Val v) h l sh True; ⋀C F t D sh v h l. ⟦?P ⊢ C has F,Static:t in D; ∄sfs. sh D = ⌊(sfs, Done)⌋⟧ ⟹ ?P1.0 (C∙⇩sF{D} := Val v) h l sh False (INIT D ([D],False) ← C∙⇩sF{D} := Val v) h l sh False; ⋀C F D v a aa b ba. ∄b t. ?P ⊢ C has F,b:t in D ⟹ ?P1.0 (C∙⇩sF{D} := Val v) a aa b ba (THROW NoSuchFieldError) a aa b False; ⋀C F t D v a aa b ba. ?P ⊢ C has F,NonStatic:t in D ⟹ ?P1.0 (C∙⇩sF{D} := Val v) a aa b ba (THROW IncompatibleClassChangeError) a aa b False; ⋀e a aa b ba e' ab ac bb b' M es. ⟦?P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ?P1.0 e a aa b ba e' ab ac bb b'⟧ ⟹ ?P1.0 (e∙M(es)) a aa b ba (e'∙M(es)) ab ac bb b'; ⋀es a aa b ba es' ab ac bb b' v M. ⟦?P ⊢ ⟨es,(a, aa, b),ba⟩ [→] ⟨es',(ab, ac, bb),b'⟩; ?P2.0 es a aa b ba es' ab ac bb b'⟧ ⟹ ?P1.0 (Val v∙M(es)) a aa b ba (Val v∙M(es')) ab ac bb b'; ⋀h a C fs M Ts T pns body D vs l sh b. ⟦h a = ⌊(C, fs)⌋; ?P ⊢ C sees M, NonStatic : Ts→T = (pns, body) in D; length vs = length pns; length Ts = length pns⟧ ⟹ ?P1.0 (addr a∙M(map Val vs)) h l sh b (blocks (this # pns, Class D # Ts, Addr a # vs, body)) h l sh b; ⋀M vs a aa b ba. ?P1.0 (null∙M(map Val vs)) a aa b ba (THROW NullPointer) a aa b ba; ⋀h a C fs M vs l sh b. ⟦h a = ⌊(C, fs)⌋; ∄b Ts T m D. ?P ⊢ C sees M, b : Ts→T = m in D⟧ ⟹ ?P1.0 (addr a∙M(map Val vs)) h l sh b (THROW NoSuchMethodError) h l sh b; ⋀h a C fs M Ts T aa b D vs l sh ba. ⟦h a = ⌊(C, fs)⌋; ?P ⊢ C sees M, Static : Ts→T = (aa, b) in D⟧ ⟹ ?P1.0 (addr a∙M(map Val vs)) h l sh ba (THROW IncompatibleClassChangeError) h l sh ba; ⋀es a aa b ba es' ab ac bb b' C M. ⟦?P ⊢ ⟨es,(a, aa, b),ba⟩ [→] ⟨es',(ab, ac, bb),b'⟩; ?P2.0 es a aa b ba es' ab ac bb b'⟧ ⟹ ?P1.0 (C∙⇩sM(es)) a aa b ba (C∙⇩sM(es')) ab ac bb b'; ⋀C M Ts T pns body D vs a aa b. ⟦?P ⊢ C sees M, Static : Ts→T = (pns, body) in D; length vs = length pns; length Ts = length pns⟧ ⟹ ?P1.0 (C∙⇩sM(map Val vs)) a aa b True (blocks (pns, Ts, vs, body)) a aa b False; ⋀C M Ts T pns body D sh sfs vs h l. ⟦?P ⊢ C sees M, Static : Ts→T = (pns, body) in D; sh D = ⌊(sfs, Done)⌋ ∨ M = clinit ∧ sh D = ⌊(sfs, Processing)⌋⟧ ⟹ ?P1.0 (C∙⇩sM(map Val vs)) h l sh False (C∙⇩sM(map Val vs)) h l sh True; ⋀C M Ts T pns body D sh vs h l. ⟦?P ⊢ C sees M, Static : Ts→T = (pns, body) in D; ∄sfs. sh D = ⌊(sfs, Done)⌋; M ≠ clinit⟧ ⟹ ?P1.0 (C∙⇩sM(map Val vs)) h l sh False (INIT D ([D],False) ← C∙⇩sM(map Val vs)) h l sh False; ⋀C M vs a aa b ba. ∄b Ts T m. Ex (Method ?P C M b Ts T m) ⟹ ?P1.0 (C∙⇩sM(map Val vs)) a aa b ba (THROW NoSuchMethodError) a aa b False; ⋀C M Ts T a b D vs aa ab ba bb. ?P ⊢ C sees M, NonStatic : Ts→T = (a, b) in D ⟹ ?P1.0 (C∙⇩sM(map Val vs)) aa ab ba bb (THROW IncompatibleClassChangeError) aa ab ba False; ⋀e h l V sh b e' h' l' sh' b' T. ⟦?P ⊢ ⟨e,(h, l(V := None), sh),b⟩ → ⟨e',(h', l', sh'),b'⟩; ?P1.0 e h (l(V := None)) sh b e' h' l' sh' b'; l' V = None; ¬ assigned V e⟧ ⟹ ?P1.0 {V:T; e} h l sh b {V:T; e'} h' (l'(V := l V)) sh' b'; ⋀e h l V sh b e' h' l' sh' b' v T. ⟦?P ⊢ ⟨e,(h, l(V := None), sh),b⟩ → ⟨e',(h', l', sh'),b'⟩; ?P1.0 e h (l(V := None)) sh b e' h' l' sh' b'; l' V = ⌊v⌋; ¬ assigned V e⟧ ⟹ ?P1.0 {V:T; e} h l sh b {V:T; V:=Val v;; e'} h' (l'(V := l V)) sh' b'; ⋀e h l V v sh b e' h' l' sh' b' v' T. ⟦?P ⊢ ⟨e,(h, l(V ↦ v), sh),b⟩ → ⟨e',(h', l', sh'),b'⟩; ?P1.0 e h (l(V ↦ v)) sh b e' h' l' sh' b'; l' V = ⌊v'⌋⟧ ⟹ ?P1.0 {V:T; V:=Val v;; e} h l sh b {V:T; V:=Val v';; e'} h' (l'(V := l V)) sh' b'; ⋀V T u a aa b ba. ?P1.0 {V:T; Val u} a aa b ba (Val u) a aa b ba; ⋀V T v u a aa b ba. ?P1.0 {V:T; V:=Val v;; Val u} a aa b ba (Val u) a aa b ba; ⋀e a aa b ba e' ab ac bb b' e₂. ⟦?P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ?P1.0 e a aa b ba e' ab ac bb b'⟧ ⟹ ?P1.0 (e;; e₂) a aa b ba (e';; e₂) ab ac bb b'; ⋀v e₂ a aa b ba. ?P1.0 (Val v;; e₂) a aa b ba e₂ a aa b ba; ⋀e a aa b ba e' ab ac bb b' e₁ e₂. ⟦?P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ?P1.0 e a aa b ba e' ab ac bb b'⟧ ⟹ ?P1.0 (if (e) e₁ else e₂) a aa b ba (if (e') e₁ else e₂) ab ac bb b'; ⋀e₁ e₂ a aa b ba. ?P1.0 (if (true) e₁ else e₂) a aa b ba e₁ a aa b ba; ⋀e₁ e₂ a aa b ba. ?P1.0 (if (false) e₁ else e₂) a aa b ba e₂ a aa b ba; ⋀b c a aa ba b'. ?P1.0 (while (b) c) a aa ba b' (if (b) (c;; while (b) c) else unit) a aa ba b'; ⋀e a aa b ba e' ab ac bb b'. ⟦?P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ?P1.0 e a aa b ba e' ab ac bb b'⟧ ⟹ ?P1.0 (throw e) a aa b ba (throw e') ab ac bb b'; ⋀a aa b ba. ?P1.0 (throw null) a aa b ba (THROW NullPointer) a aa b ba; ⋀e a aa b ba e' ab ac bb b' C V e₂. ⟦?P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ?P1.0 e a aa b ba e' ab ac bb b'⟧ ⟹ ?P1.0 (try e catch(C V) e₂) a aa b ba (try e' catch(C V) e₂) ab ac bb b'; ⋀v C V e₂ a aa b ba. ?P1.0 (try Val v catch(C V) e₂) a aa b ba (Val v) a aa b ba; ⋀a aa b ab D fs C V e₂ ba. ⟦hp (a, aa, b) ab = ⌊(D, fs)⌋; ?P ⊢ D ≼⇧* C⟧ ⟹ ?P1.0 (try Throw ab catch(C V) e₂) a aa b ba {V:Class C; V:=addr ab;; e₂} a aa b ba; ⋀a aa b ab D fs C V e₂ ba. ⟦hp (a, aa, b) ab = ⌊(D, fs)⌋; (D, C) ∉ (subcls1 ?P)⇧*⟧ ⟹ ?P1.0 (try Throw ab catch(C V) e₂) a aa b ba (Throw ab) a aa b ba; ⋀e a aa b ba e' ab ac bb b' es. ⟦?P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ?P1.0 e a aa b ba e' ab ac bb b'⟧ ⟹ ?P2.0 (e # es) a aa b ba (e' # es) ab ac bb b'; ⋀es a aa b ba es' ab ac bb b' v. ⟦?P ⊢ ⟨es,(a, aa, b),ba⟩ [→] ⟨es',(ab, ac, bb),b'⟩; ?P2.0 es a aa b ba es' ab ac bb b'⟧ ⟹ ?P2.0 (Val v # es) a aa b ba (Val v # es') ab ac bb b'; ⋀e C b a aa ba b'. ¬ sub_RI e ⟹ ?P1.0 (INIT C ([],b) ← e) a aa ba b' e a aa ba (icheck ?P C e); ⋀sh C C' Cs e h l b. sh C = None ⟹ ?P1.0 (INIT C' (C # Cs,False) ← e) h l sh b (INIT C' (C # Cs,False) ← e) h l (sh(C ↦ (sblank ?P C, Prepared))) b; ⋀sh C sfs C' Cs e h l b. sh C = ⌊(sfs, Done)⌋ ⟹ ?P1.0 (INIT C' (C # Cs,False) ← e) h l sh b (INIT C' (Cs,True) ← e) h l sh b; ⋀sh C sfs C' Cs e h l b. sh C = ⌊(sfs, Processing)⌋ ⟹ ?P1.0 (INIT C' (C # Cs,False) ← e) h l sh b (INIT C' (Cs,True) ← e) h l sh b; ⋀sh C sfs C' Cs e h l b. sh C = ⌊(sfs, Error)⌋ ⟹ ?P1.0 (INIT C' (C # Cs,False) ← e) h l sh b (RI (C,THROW NoClassDefFoundError) ; Cs ← e) h l sh b; ⋀sh C sfs sh' C' Cs e h l b. ⟦sh C = ⌊(sfs, Prepared)⌋; C = Object; sh' = sh(C ↦ (sfs, Processing))⟧ ⟹ ?P1.0 (INIT C' (C # Cs,False) ← e) h l sh b (INIT C' (C # Cs,True) ← e) h l sh' b; ⋀sh C sfs D a b sh' C' Cs e h l ba. ⟦sh C = ⌊(sfs, Prepared)⌋; C ≠ Object; class ?P C = ⌊(D, a, b)⌋; sh' = sh(C ↦ (sfs, Processing))⟧ ⟹ ?P1.0 (INIT C' (C # Cs,False) ← e) h l sh ba (INIT C' (D # C # Cs,False) ← e) h l sh' ba; ⋀C' C Cs e h l sh b. ?P1.0 (INIT C' (C # Cs,True) ← e) h l sh b (RI (C,C∙⇩sclinit([])) ; Cs ← e) h l sh b; ⋀e a aa b ba e' ab ac bb b' C Cs e₀. ⟦?P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ?P1.0 e a aa b ba e' ab ac bb b'⟧ ⟹ ?P1.0 (RI (C,e) ; Cs ← e₀) a aa b ba (RI (C,e') ; Cs ← e₀) ab ac bb b'; ⋀sh C sfs i sh' C' Cs v e h l b. ⟦sh C = ⌊(sfs, i)⌋; sh' = sh(C ↦ (sfs, Done)); C' = last (C # Cs)⟧ ⟹ ?P1.0 (RI (C,Val v) ; Cs ← e) h l sh b (INIT C' (Cs,True) ← e) h l sh' b; ⋀C e a aa b ba. ?P1.0 (Cast C (throw e)) a aa b ba (throw e) a aa b ba; ⋀e bop e₂ a aa b ba. ?P1.0 (throw e «bop» e₂) a aa b ba (throw e) a aa b ba; ⋀v₁ bop e a aa b ba. ?P1.0 (Val v₁ «bop» throw e) a aa b ba (throw e) a aa b ba; ⋀V e a aa b ba. ?P1.0 (V:=throw e) a aa b ba (throw e) a aa b ba; ⋀e F D a aa b ba. ?P1.0 (throw e∙F{D}) a aa b ba (throw e) a aa b ba; ⋀e F D e₂ a aa b ba. ?P1.0 (throw e∙F{D} := e₂) a aa b ba (throw e) a aa b ba; ⋀v F D e a aa b ba. ?P1.0 (Val v∙F{D} := throw e) a aa b ba (throw e) a aa b ba; ⋀C F D e a aa b ba. ?P1.0 (C∙⇩sF{D} := throw e) a aa b ba (throw e) a aa b ba; ⋀e M es a aa b ba. ?P1.0 (throw e∙M(es)) a aa b ba (throw e) a aa b ba; ⋀es vs e es' v M a aa b ba. es = map Val vs @ throw e # es' ⟹ ?P1.0 (Val v∙M(es)) a aa b ba (throw e) a aa b ba; ⋀es vs e es' C M a aa b ba. es = map Val vs @ throw e # es' ⟹ ?P1.0 (C∙⇩sM(es)) a aa b ba (throw e) a aa b ba; ⋀V T a aa ab b ba. ?P1.0 {V:T; Throw a} aa ab b ba (Throw a) aa ab b ba; ⋀V T v a aa ab b ba. ?P1.0 {V:T; V:=Val v;; Throw a} aa ab b ba (Throw a) aa ab b ba; ⋀e e₂ a aa b ba. ?P1.0 (throw e;; e₂) a aa b ba (throw e) a aa b ba; ⋀e e₁ e₂ a aa b ba. ?P1.0 (if (throw e) e₁ else e₂) a aa b ba (throw e) a aa b ba; ⋀e a aa b ba. ?P1.0 (throw (throw e)) a aa b ba (throw e) a aa b ba; ⋀sh C sfs i sh' a D Cs e h l b. ⟦sh C = ⌊(sfs, i)⌋; sh' = sh(C ↦ (sfs, Error))⟧ ⟹ ?P1.0 (RI (C,Throw a) ; D # Cs ← e) h l sh b (RI (D,Throw a) ; Cs ← e) h l sh' b; ⋀sh C sfs i sh' a e h l b. ⟦sh C = ⌊(sfs, i)⌋; sh' = sh(C ↦ (sfs, Error))⟧ ⟹ ?P1.0 (RI (C,Throw a) ; [] ← e) h l sh b (Throw a) h l sh' b⟧ ⟹ ?P1.0 ?x1a ?x2a ?x2b ?x2c ?x3a ?x4a ?x5a ?x5b ?x5c ?x6a› ‹⟦?P ⊢ ⟨?x7a,(?x8a, ?x8b, ?x8c),?x9a⟩ [→] ⟨?x10a,(?x11a, ?x11b, ?x11c),?x12a⟩; ⋀h a C FDTs h' l sh. ⟦new_Addr h = ⌊a⌋; ?P ⊢ C has_fields FDTs; h' = h(a ↦ blank ?P C)⟧ ⟹ ?P1.0 (new C) h l sh True (addr a) h' l sh False; ⋀h C l sh. ⟦new_Addr h = None; is_class ?P C⟧ ⟹ ?P1.0 (new C) h l sh True (THROW OutOfMemory) h l sh False; ⋀sh C sfs h l. sh C = ⌊(sfs, Done)⌋ ⟹ ?P1.0 (new C) h l sh False (new C) h l sh True; ⋀sh C h l. ⟦∄sfs. sh C = ⌊(sfs, Done)⌋; is_class ?P C⟧ ⟹ ?P1.0 (new C) h l sh False (INIT C ([C],False) ← new C) h l sh False; ⋀e a aa b ba e' ab ac bb b' C. ⟦?P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ?P1.0 e a aa b ba e' ab ac bb b'⟧ ⟹ ?P1.0 (Cast C e) a aa b ba (Cast C e') ab ac bb b'; ⋀C a aa b ba. ?P1.0 (Cast C null) a aa b ba null a aa b ba; ⋀h a D fs C l sh b. ⟦h a = ⌊(D, fs)⌋; ?P ⊢ D ≼⇧* C⟧ ⟹ ?P1.0 (Cast C (addr a)) h l sh b (addr a) h l sh b; ⋀h a D fs C l sh b. ⟦h a = ⌊(D, fs)⌋; (D, C) ∉ (subcls1 ?P)⇧*⟧ ⟹ ?P1.0 (Cast C (addr a)) h l sh b (THROW ClassCast) h l sh b; ⋀e a aa b ba e' ab ac bb b' bop e₂. ⟦?P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ?P1.0 e a aa b ba e' ab ac bb b'⟧ ⟹ ?P1.0 (e «bop» e₂) a aa b ba (e' «bop» e₂) ab ac bb b'; ⋀e a aa b ba e' ab ac bb b' v₁ bop. ⟦?P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ?P1.0 e a aa b ba e' ab ac bb b'⟧ ⟹ ?P1.0 (Val v₁ «bop» e) a aa b ba (Val v₁ «bop» e') ab ac bb b'; ⋀bop v₁ v₂ v a aa b ba. binop (bop, v₁, v₂) = ⌊v⌋ ⟹ ?P1.0 (Val v₁ «bop» Val v₂) a aa b ba (Val v) a aa b ba; ⋀l V v h sh b. l V = ⌊v⌋ ⟹ ?P1.0 (Var V) h l sh b (Val v) h l sh b; ⋀e a aa b ba e' ab ac bb b' V. ⟦?P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ?P1.0 e a aa b ba e' ab ac bb b'⟧ ⟹ ?P1.0 (V:=e) a aa b ba (V:=e') ab ac bb b'; ⋀V v h l sh b. ?P1.0 (V:=Val v) h l sh b unit h (l(V ↦ v)) sh b; ⋀e a aa b ba e' ab ac bb b' F D. ⟦?P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ?P1.0 e a aa b ba e' ab ac bb b'⟧ ⟹ ?P1.0 (e∙F{D}) a aa b ba (e'∙F{D}) ab ac bb b'; ⋀h a C fs F D v t l sh b. ⟦h a = ⌊(C, fs)⌋; fs (F, D) = ⌊v⌋; ?P ⊢ C has F,NonStatic:t in D⟧ ⟹ ?P1.0 (addr a∙F{D}) h l sh b (Val v) h l sh b; ⋀F D a aa b ba. ?P1.0 (null∙F{D}) a aa b ba (THROW NullPointer) a aa b ba; ⋀h a C fs F D l sh b. ⟦h a = ⌊(C, fs)⌋; ∄b t. ?P ⊢ C has F,b:t in D⟧ ⟹ ?P1.0 (addr a∙F{D}) h l sh b (THROW NoSuchFieldError) h l sh b; ⋀h a C fs F t D l sh b. ⟦h a = ⌊(C, fs)⌋; ?P ⊢ C has F,Static:t in D⟧ ⟹ ?P1.0 (addr a∙F{D}) h l sh b (THROW IncompatibleClassChangeError) h l sh b; ⋀C F t D sh sfs i v h l. ⟦?P ⊢ C has F,Static:t in D; sh D = ⌊(sfs, i)⌋; sfs F = ⌊v⌋⟧ ⟹ ?P1.0 (C∙⇩sF{D}) h l sh True (Val v) h l sh False; ⋀C F t D sh sfs h l. ⟦?P ⊢ C has F,Static:t in D; sh D = ⌊(sfs, Done)⌋⟧ ⟹ ?P1.0 (C∙⇩sF{D}) h l sh False (C∙⇩sF{D}) h l sh True; ⋀C F t D sh h l. ⟦?P ⊢ C has F,Static:t in D; ∄sfs. sh D = ⌊(sfs, Done)⌋⟧ ⟹ ?P1.0 (C∙⇩sF{D}) h l sh False (INIT D ([D],False) ← C∙⇩sF{D}) h l sh False; ⋀C F D h l sh b. ∄b t. ?P ⊢ C has F,b:t in D ⟹ ?P1.0 (C∙⇩sF{D}) h l sh b (THROW NoSuchFieldError) h l sh False; ⋀C F t D h l sh b. ?P ⊢ C has F,NonStatic:t in D ⟹ ?P1.0 (C∙⇩sF{D}) h l sh b (THROW IncompatibleClassChangeError) h l sh False; ⋀e a aa b ba e' ab ac bb b' F D e₂. ⟦?P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ?P1.0 e a aa b ba e' ab ac bb b'⟧ ⟹ ?P1.0 (e∙F{D} := e₂) a aa b ba (e'∙F{D} := e₂) ab ac bb b'; ⋀e a aa b ba e' ab ac bb b' v F D. ⟦?P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ?P1.0 e a aa b ba e' ab ac bb b'⟧ ⟹ ?P1.0 (Val v∙F{D} := e) a aa b ba (Val v∙F{D} := e') ab ac bb b'; ⋀C F t D h a fs v l sh b. ⟦?P ⊢ C has F,NonStatic:t in D; h a = ⌊(C, fs)⌋⟧ ⟹ ?P1.0 (addr a∙F{D} := Val v) h l sh b unit (h(a ↦ (C, fs((F, D) ↦ v)))) l sh b; ⋀F D v a aa b ba. ?P1.0 (null∙F{D} := Val v) a aa b ba (THROW NullPointer) a aa b ba; ⋀h a C fs F D v l sh b. ⟦h a = ⌊(C, fs)⌋; ∄b t. ?P ⊢ C has F,b:t in D⟧ ⟹ ?P1.0 (addr a∙F{D} := Val v) h l sh b (THROW NoSuchFieldError) h l sh b; ⋀h a C fs F t D v l sh b. ⟦h a = ⌊(C, fs)⌋; ?P ⊢ C has F,Static:t in D⟧ ⟹ ?P1.0 (addr a∙F{D} := Val v) h l sh b (THROW IncompatibleClassChangeError) h l sh b; ⋀e a aa b ba e' ab ac bb b' C F D. ⟦?P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ?P1.0 e a aa b ba e' ab ac bb b'⟧ ⟹ ?P1.0 (C∙⇩sF{D} := e) a aa b ba (C∙⇩sF{D} := e') ab ac bb b'; ⋀C F t D sh sfs i sfs' v sh' h l. ⟦?P ⊢ C has F,Static:t in D; sh D = ⌊(sfs, i)⌋; sfs' = sfs(F ↦ v); sh' = sh(D ↦ (sfs', i))⟧ ⟹ ?P1.0 (C∙⇩sF{D} := Val v) h l sh True unit h l sh' False; ⋀C F t D sh sfs v h l. ⟦?P ⊢ C has F,Static:t in D; sh D = ⌊(sfs, Done)⌋⟧ ⟹ ?P1.0 (C∙⇩sF{D} := Val v) h l sh False (C∙⇩sF{D} := Val v) h l sh True; ⋀C F t D sh v h l. ⟦?P ⊢ C has F,Static:t in D; ∄sfs. sh D = ⌊(sfs, Done)⌋⟧ ⟹ ?P1.0 (C∙⇩sF{D} := Val v) h l sh False (INIT D ([D],False) ← C∙⇩sF{D} := Val v) h l sh False; ⋀C F D v a aa b ba. ∄b t. ?P ⊢ C has F,b:t in D ⟹ ?P1.0 (C∙⇩sF{D} := Val v) a aa b ba (THROW NoSuchFieldError) a aa b False; ⋀C F t D v a aa b ba. ?P ⊢ C has F,NonStatic:t in D ⟹ ?P1.0 (C∙⇩sF{D} := Val v) a aa b ba (THROW IncompatibleClassChangeError) a aa b False; ⋀e a aa b ba e' ab ac bb b' M es. ⟦?P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ?P1.0 e a aa b ba e' ab ac bb b'⟧ ⟹ ?P1.0 (e∙M(es)) a aa b ba (e'∙M(es)) ab ac bb b'; ⋀es a aa b ba es' ab ac bb b' v M. ⟦?P ⊢ ⟨es,(a, aa, b),ba⟩ [→] ⟨es',(ab, ac, bb),b'⟩; ?P2.0 es a aa b ba es' ab ac bb b'⟧ ⟹ ?P1.0 (Val v∙M(es)) a aa b ba (Val v∙M(es')) ab ac bb b'; ⋀h a C fs M Ts T pns body D vs l sh b. ⟦h a = ⌊(C, fs)⌋; ?P ⊢ C sees M, NonStatic : Ts→T = (pns, body) in D; length vs = length pns; length Ts = length pns⟧ ⟹ ?P1.0 (addr a∙M(map Val vs)) h l sh b (blocks (this # pns, Class D # Ts, Addr a # vs, body)) h l sh b; ⋀M vs a aa b ba. ?P1.0 (null∙M(map Val vs)) a aa b ba (THROW NullPointer) a aa b ba; ⋀h a C fs M vs l sh b. ⟦h a = ⌊(C, fs)⌋; ∄b Ts T m D. ?P ⊢ C sees M, b : Ts→T = m in D⟧ ⟹ ?P1.0 (addr a∙M(map Val vs)) h l sh b (THROW NoSuchMethodError) h l sh b; ⋀h a C fs M Ts T aa b D vs l sh ba. ⟦h a = ⌊(C, fs)⌋; ?P ⊢ C sees M, Static : Ts→T = (aa, b) in D⟧ ⟹ ?P1.0 (addr a∙M(map Val vs)) h l sh ba (THROW IncompatibleClassChangeError) h l sh ba; ⋀es a aa b ba es' ab ac bb b' C M. ⟦?P ⊢ ⟨es,(a, aa, b),ba⟩ [→] ⟨es',(ab, ac, bb),b'⟩; ?P2.0 es a aa b ba es' ab ac bb b'⟧ ⟹ ?P1.0 (C∙⇩sM(es)) a aa b ba (C∙⇩sM(es')) ab ac bb b'; ⋀C M Ts T pns body D vs a aa b. ⟦?P ⊢ C sees M, Static : Ts→T = (pns, body) in D; length vs = length pns; length Ts = length pns⟧ ⟹ ?P1.0 (C∙⇩sM(map Val vs)) a aa b True (blocks (pns, Ts, vs, body)) a aa b False; ⋀C M Ts T pns body D sh sfs vs h l. ⟦?P ⊢ C sees M, Static : Ts→T = (pns, body) in D; sh D = ⌊(sfs, Done)⌋ ∨ M = clinit ∧ sh D = ⌊(sfs, Processing)⌋⟧ ⟹ ?P1.0 (C∙⇩sM(map Val vs)) h l sh False (C∙⇩sM(map Val vs)) h l sh True; ⋀C M Ts T pns body D sh vs h l. ⟦?P ⊢ C sees M, Static : Ts→T = (pns, body) in D; ∄sfs. sh D = ⌊(sfs, Done)⌋; M ≠ clinit⟧ ⟹ ?P1.0 (C∙⇩sM(map Val vs)) h l sh False (INIT D ([D],False) ← C∙⇩sM(map Val vs)) h l sh False; ⋀C M vs a aa b ba. ∄b Ts T m. Ex (Method ?P C M b Ts T m) ⟹ ?P1.0 (C∙⇩sM(map Val vs)) a aa b ba (THROW NoSuchMethodError) a aa b False; ⋀C M Ts T a b D vs aa ab ba bb. ?P ⊢ C sees M, NonStatic : Ts→T = (a, b) in D ⟹ ?P1.0 (C∙⇩sM(map Val vs)) aa ab ba bb (THROW IncompatibleClassChangeError) aa ab ba False; ⋀e h l V sh b e' h' l' sh' b' T. ⟦?P ⊢ ⟨e,(h, l(V := None), sh),b⟩ → ⟨e',(h', l', sh'),b'⟩; ?P1.0 e h (l(V := None)) sh b e' h' l' sh' b'; l' V = None; ¬ assigned V e⟧ ⟹ ?P1.0 {V:T; e} h l sh b {V:T; e'} h' (l'(V := l V)) sh' b'; ⋀e h l V sh b e' h' l' sh' b' v T. ⟦?P ⊢ ⟨e,(h, l(V := None), sh),b⟩ → ⟨e',(h', l', sh'),b'⟩; ?P1.0 e h (l(V := None)) sh b e' h' l' sh' b'; l' V = ⌊v⌋; ¬ assigned V e⟧ ⟹ ?P1.0 {V:T; e} h l sh b {V:T; V:=Val v;; e'} h' (l'(V := l V)) sh' b'; ⋀e h l V v sh b e' h' l' sh' b' v' T. ⟦?P ⊢ ⟨e,(h, l(V ↦ v), sh),b⟩ → ⟨e',(h', l', sh'),b'⟩; ?P1.0 e h (l(V ↦ v)) sh b e' h' l' sh' b'; l' V = ⌊v'⌋⟧ ⟹ ?P1.0 {V:T; V:=Val v;; e} h l sh b {V:T; V:=Val v';; e'} h' (l'(V := l V)) sh' b'; ⋀V T u a aa b ba. ?P1.0 {V:T; Val u} a aa b ba (Val u) a aa b ba; ⋀V T v u a aa b ba. ?P1.0 {V:T; V:=Val v;; Val u} a aa b ba (Val u) a aa b ba; ⋀e a aa b ba e' ab ac bb b' e₂. ⟦?P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ?P1.0 e a aa b ba e' ab ac bb b'⟧ ⟹ ?P1.0 (e;; e₂) a aa b ba (e';; e₂) ab ac bb b'; ⋀v e₂ a aa b ba. ?P1.0 (Val v;; e₂) a aa b ba e₂ a aa b ba; ⋀e a aa b ba e' ab ac bb b' e₁ e₂. ⟦?P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ?P1.0 e a aa b ba e' ab ac bb b'⟧ ⟹ ?P1.0 (if (e) e₁ else e₂) a aa b ba (if (e') e₁ else e₂) ab ac bb b'; ⋀e₁ e₂ a aa b ba. ?P1.0 (if (true) e₁ else e₂) a aa b ba e₁ a aa b ba; ⋀e₁ e₂ a aa b ba. ?P1.0 (if (false) e₁ else e₂) a aa b ba e₂ a aa b ba; ⋀b c a aa ba b'. ?P1.0 (while (b) c) a aa ba b' (if (b) (c;; while (b) c) else unit) a aa ba b'; ⋀e a aa b ba e' ab ac bb b'. ⟦?P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ?P1.0 e a aa b ba e' ab ac bb b'⟧ ⟹ ?P1.0 (throw e) a aa b ba (throw e') ab ac bb b'; ⋀a aa b ba. ?P1.0 (throw null) a aa b ba (THROW NullPointer) a aa b ba; ⋀e a aa b ba e' ab ac bb b' C V e₂. ⟦?P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ?P1.0 e a aa b ba e' ab ac bb b'⟧ ⟹ ?P1.0 (try e catch(C V) e₂) a aa b ba (try e' catch(C V) e₂) ab ac bb b'; ⋀v C V e₂ a aa b ba. ?P1.0 (try Val v catch(C V) e₂) a aa b ba (Val v) a aa b ba; ⋀a aa b ab D fs C V e₂ ba. ⟦hp (a, aa, b) ab = ⌊(D, fs)⌋; ?P ⊢ D ≼⇧* C⟧ ⟹ ?P1.0 (try Throw ab catch(C V) e₂) a aa b ba {V:Class C; V:=addr ab;; e₂} a aa b ba; ⋀a aa b ab D fs C V e₂ ba. ⟦hp (a, aa, b) ab = ⌊(D, fs)⌋; (D, C) ∉ (subcls1 ?P)⇧*⟧ ⟹ ?P1.0 (try Throw ab catch(C V) e₂) a aa b ba (Throw ab) a aa b ba; ⋀e a aa b ba e' ab ac bb b' es. ⟦?P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ?P1.0 e a aa b ba e' ab ac bb b'⟧ ⟹ ?P2.0 (e # es) a aa b ba (e' # es) ab ac bb b'; ⋀es a aa b ba es' ab ac bb b' v. ⟦?P ⊢ ⟨es,(a, aa, b),ba⟩ [→] ⟨es',(ab, ac, bb),b'⟩; ?P2.0 es a aa b ba es' ab ac bb b'⟧ ⟹ ?P2.0 (Val v # es) a aa b ba (Val v # es') ab ac bb b'; ⋀e C b a aa ba b'. ¬ sub_RI e ⟹ ?P1.0 (INIT C ([],b) ← e) a aa ba b' e a aa ba (icheck ?P C e); ⋀sh C C' Cs e h l b. sh C = None ⟹ ?P1.0 (INIT C' (C # Cs,False) ← e) h l sh b (INIT C' (C # Cs,False) ← e) h l (sh(C ↦ (sblank ?P C, Prepared))) b; ⋀sh C sfs C' Cs e h l b. sh C = ⌊(sfs, Done)⌋ ⟹ ?P1.0 (INIT C' (C # Cs,False) ← e) h l sh b (INIT C' (Cs,True) ← e) h l sh b; ⋀sh C sfs C' Cs e h l b. sh C = ⌊(sfs, Processing)⌋ ⟹ ?P1.0 (INIT C' (C # Cs,False) ← e) h l sh b (INIT C' (Cs,True) ← e) h l sh b; ⋀sh C sfs C' Cs e h l b. sh C = ⌊(sfs, Error)⌋ ⟹ ?P1.0 (INIT C' (C # Cs,False) ← e) h l sh b (RI (C,THROW NoClassDefFoundError) ; Cs ← e) h l sh b; ⋀sh C sfs sh' C' Cs e h l b. ⟦sh C = ⌊(sfs, Prepared)⌋; C = Object; sh' = sh(C ↦ (sfs, Processing))⟧ ⟹ ?P1.0 (INIT C' (C # Cs,False) ← e) h l sh b (INIT C' (C # Cs,True) ← e) h l sh' b; ⋀sh C sfs D a b sh' C' Cs e h l ba. ⟦sh C = ⌊(sfs, Prepared)⌋; C ≠ Object; class ?P C = ⌊(D, a, b)⌋; sh' = sh(C ↦ (sfs, Processing))⟧ ⟹ ?P1.0 (INIT C' (C # Cs,False) ← e) h l sh ba (INIT C' (D # C # Cs,False) ← e) h l sh' ba; ⋀C' C Cs e h l sh b. ?P1.0 (INIT C' (C # Cs,True) ← e) h l sh b (RI (C,C∙⇩sclinit([])) ; Cs ← e) h l sh b; ⋀e a aa b ba e' ab ac bb b' C Cs e₀. ⟦?P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ?P1.0 e a aa b ba e' ab ac bb b'⟧ ⟹ ?P1.0 (RI (C,e) ; Cs ← e₀) a aa b ba (RI (C,e') ; Cs ← e₀) ab ac bb b'; ⋀sh C sfs i sh' C' Cs v e h l b. ⟦sh C = ⌊(sfs, i)⌋; sh' = sh(C ↦ (sfs, Done)); C' = last (C # Cs)⟧ ⟹ ?P1.0 (RI (C,Val v) ; Cs ← e) h l sh b (INIT C' (Cs,True) ← e) h l sh' b; ⋀C e a aa b ba. ?P1.0 (Cast C (throw e)) a aa b ba (throw e) a aa b ba; ⋀e bop e₂ a aa b ba. ?P1.0 (throw e «bop» e₂) a aa b ba (throw e) a aa b ba; ⋀v₁ bop e a aa b ba. ?P1.0 (Val v₁ «bop» throw e) a aa b ba (throw e) a aa b ba; ⋀V e a aa b ba. ?P1.0 (V:=throw e) a aa b ba (throw e) a aa b ba; ⋀e F D a aa b ba. ?P1.0 (throw e∙F{D}) a aa b ba (throw e) a aa b ba; ⋀e F D e₂ a aa b ba. ?P1.0 (throw e∙F{D} := e₂) a aa b ba (throw e) a aa b ba; ⋀v F D e a aa b ba. ?P1.0 (Val v∙F{D} := throw e) a aa b ba (throw e) a aa b ba; ⋀C F D e a aa b ba. ?P1.0 (C∙⇩sF{D} := throw e) a aa b ba (throw e) a aa b ba; ⋀e M es a aa b ba. ?P1.0 (throw e∙M(es)) a aa b ba (throw e) a aa b ba; ⋀es vs e es' v M a aa b ba. es = map Val vs @ throw e # es' ⟹ ?P1.0 (Val v∙M(es)) a aa b ba (throw e) a aa b ba; ⋀es vs e es' C M a aa b ba. es = map Val vs @ throw e # es' ⟹ ?P1.0 (C∙⇩sM(es)) a aa b ba (throw e) a aa b ba; ⋀V T a aa ab b ba. ?P1.0 {V:T; Throw a} aa ab b ba (Throw a) aa ab b ba; ⋀V T v a aa ab b ba. ?P1.0 {V:T; V:=Val v;; Throw a} aa ab b ba (Throw a) aa ab b ba; ⋀e e₂ a aa b ba. ?P1.0 (throw e;; e₂) a aa b ba (throw e) a aa b ba; ⋀e e₁ e₂ a aa b ba. ?P1.0 (if (throw e) e₁ else e₂) a aa b ba (throw e) a aa b ba; ⋀e a aa b ba. ?P1.0 (throw (throw e)) a aa b ba (throw e) a aa b ba; ⋀sh C sfs i sh' a D Cs e h l b. ⟦sh C = ⌊(sfs, i)⌋; sh' = sh(C ↦ (sfs, Error))⟧ ⟹ ?P1.0 (RI (C,Throw a) ; D # Cs ← e) h l sh b (RI (D,Throw a) ; Cs ← e) h l sh' b; ⋀sh C sfs i sh' a e h l b. ⟦sh C = ⌊(sfs, i)⌋; sh' = sh(C ↦ (sfs, Error))⟧ ⟹ ?P1.0 (RI (C,Throw a) ; [] ← e) h l sh b (Throw a) h l sh' b⟧ ⟹ ?P2.0 ?x7a ?x8a ?x8b ?x8c ?x9a ?x10a ?x11a ?x11b ?x11c ?x12a›*)) (*goals: 1. ‹⋀(h::heap) (a::nat) (C::char list) (FDTs::((char list × char list) × staticb × ty) list) (h'::heap) (l::sfields) (sh::sheap) l₀::sfields. ⟦new_Addr h = ⌊a⌋; (P::(char list list × char list exp) prog) ⊢ C has_fields FDTs; h' = h(a ↦ blank P C)⟧ ⟹ P ⊢ ⟨new C,(h, l₀ ++ l, sh),True⟩ → ⟨addr a,(h', l₀ ++ l, sh),False⟩› 2. ‹⋀(h::heap) (C::char list) (l::sfields) (sh::sheap) l₀::sfields. ⟦new_Addr h = None; is_class (P::(char list list × char list exp) prog) C⟧ ⟹ P ⊢ ⟨new C,(h, l₀ ++ l, sh),True⟩ → ⟨THROW OutOfMemory,(h, l₀ ++ l, sh),False⟩› 3. ‹⋀(sh::sheap) (C::char list) (sfs::sfields) (h::heap) (l::sfields) l₀::sfields. sh C = ⌊(sfs, Done)⌋ ⟹ (P::(char list list × char list exp) prog) ⊢ ⟨new C,(h, l₀ ++ l, sh),False⟩ → ⟨new C,(h, l₀ ++ l, sh),True⟩› 4. ‹⋀(sh::sheap) (C::char list) (h::heap) (l::sfields) l₀::sfields. ⟦∄sfs::sfields. sh C = ⌊(sfs, Done)⌋; is_class (P::(char list list × char list exp) prog) C⟧ ⟹ P ⊢ ⟨new C,(h, l₀ ++ l, sh),False⟩ → ⟨INIT C ([C],False) ← new C,(h, l₀ ++ l, sh),False⟩› 5. ‹⋀(e::char list exp) (a::heap) (aa::sfields) (b::sheap) (ba::bool) (e'::char list exp) (ab::heap) (ac::sfields) (bb::sheap) (b'::bool) (C::char list) l₀::sfields. ⟦(P::(char list list × char list exp) prog) ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⋀l₀::sfields. P ⊢ ⟨e,(a, l₀ ++ aa, b),ba⟩ → ⟨e',(ab, l₀ ++ ac, bb),b'⟩⟧ ⟹ P ⊢ ⟨Cast C e,(a, l₀ ++ aa, b),ba⟩ → ⟨Cast C e',(ab, l₀ ++ ac, bb),b'⟩› 6. ‹⋀(C::char list) (a::heap) (aa::sfields) (b::sheap) (ba::bool) l₀::sfields. (P::(char list list × char list exp) prog) ⊢ ⟨Cast C null,(a, l₀ ++ aa, b),ba⟩ → ⟨null,(a, l₀ ++ aa, b),ba⟩› 7. ‹⋀(h::heap) (a::nat) (D::char list) (fs::Objects.fields) (C::char list) (l::sfields) (sh::sheap) (b::bool) l₀::sfields. ⟦h a = ⌊(D, fs)⌋; (P::(char list list × char list exp) prog) ⊢ D ≼⇧* C⟧ ⟹ P ⊢ ⟨Cast C (addr a),(h, l₀ ++ l, sh),b⟩ → ⟨addr a,(h, l₀ ++ l, sh),b⟩› 8. ‹⋀(h::heap) (a::nat) (D::char list) (fs::Objects.fields) (C::char list) (l::sfields) (sh::sheap) (b::bool) l₀::sfields. ⟦h a = ⌊(D, fs)⌋; (D, C) ∉ (subcls1 (P::(char list list × char list exp) prog))⇧*⟧ ⟹ P ⊢ ⟨Cast C (addr a),(h, l₀ ++ l, sh),b⟩ → ⟨THROW ClassCast,(h, l₀ ++ l, sh),b⟩› 9. ‹⋀(e::char list exp) (a::heap) (aa::sfields) (b::sheap) (ba::bool) (e'::char list exp) (ab::heap) (ac::sfields) (bb::sheap) (b'::bool) (bop::bop) (e₂::char list exp) l₀::sfields. ⟦(P::(char list list × char list exp) prog) ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⋀l₀::sfields. P ⊢ ⟨e,(a, l₀ ++ aa, b),ba⟩ → ⟨e',(ab, l₀ ++ ac, bb),b'⟩⟧ ⟹ P ⊢ ⟨e «bop» e₂,(a, l₀ ++ aa, b),ba⟩ → ⟨e' «bop» e₂,(ab, l₀ ++ ac, bb),b'⟩› 10. ‹⋀(e::char list exp) (a::heap) (aa::sfields) (b::sheap) (ba::bool) (e'::char list exp) (ab::heap) (ac::sfields) (bb::sheap) (b'::bool) (v₁::val) (bop::bop) l₀::sfields. ⟦(P::(char list list × char list exp) prog) ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⋀l₀::sfields. P ⊢ ⟨e,(a, l₀ ++ aa, b),ba⟩ → ⟨e',(ab, l₀ ++ ac, bb),b'⟩⟧ ⟹ P ⊢ ⟨Val v₁ «bop» e,(a, l₀ ++ aa, b),ba⟩ → ⟨Val v₁ «bop» e',(ab, l₀ ++ ac, bb),b'⟩› 11. ‹⋀(bop::bop) (v₁::val) (v₂::val) (v::val) (a::heap) (aa::sfields) (b::sheap) (ba::bool) l₀::sfields. binop (bop, v₁, v₂) = ⌊v⌋ ⟹ (P::(char list list × char list exp) prog) ⊢ ⟨Val v₁ «bop» Val v₂,(a, l₀ ++ aa, b),ba⟩ → ⟨Val v,(a, l₀ ++ aa, b),ba⟩› 12. ‹⋀(l::sfields) (V::char list) (v::val) (h::heap) (sh::sheap) (b::bool) l₀::sfields. l V = ⌊v⌋ ⟹ (P::(char list list × char list exp) prog) ⊢ ⟨Var V,(h, l₀ ++ l, sh),b⟩ → ⟨Val v,(h, l₀ ++ l, sh),b⟩› 13. ‹⋀(e::char list exp) (a::heap) (aa::sfields) (b::sheap) (ba::bool) (e'::char list exp) (ab::heap) (ac::sfields) (bb::sheap) (b'::bool) (V::char list) l₀::sfields. ⟦(P::(char list list × char list exp) prog) ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⋀l₀::sfields. P ⊢ ⟨e,(a, l₀ ++ aa, b),ba⟩ → ⟨e',(ab, l₀ ++ ac, bb),b'⟩⟧ ⟹ P ⊢ ⟨V:=e,(a, l₀ ++ aa, b),ba⟩ → ⟨V:=e',(ab, l₀ ++ ac, bb),b'⟩› 14. ‹⋀(V::char list) (v::val) (h::heap) (l::sfields) (sh::sheap) (b::bool) l₀::sfields. (P::(char list list × char list exp) prog) ⊢ ⟨V:=Val v,(h, l₀ ++ l, sh),b⟩ → ⟨unit,(h, l₀ ++ l(V ↦ v), sh),b⟩› 15. ‹⋀(e::char list exp) (a::heap) (aa::sfields) (b::sheap) (ba::bool) (e'::char list exp) (ab::heap) (ac::sfields) (bb::sheap) (b'::bool) (F::char list) (D::char list) l₀::sfields. ⟦(P::(char list list × char list exp) prog) ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⋀l₀::sfields. P ⊢ ⟨e,(a, l₀ ++ aa, b),ba⟩ → ⟨e',(ab, l₀ ++ ac, bb),b'⟩⟧ ⟹ P ⊢ ⟨e∙F{D},(a, l₀ ++ aa, b),ba⟩ → ⟨e'∙F{D},(ab, l₀ ++ ac, bb),b'⟩› 16. ‹⋀(h::heap) (a::nat) (C::char list) (fs::Objects.fields) (F::char list) (D::char list) (v::val) (t::ty) (l::sfields) (sh::sheap) (b::bool) l₀::sfields. ⟦h a = ⌊(C, fs)⌋; fs (F, D) = ⌊v⌋; (P::(char list list × char list exp) prog) ⊢ C has F,NonStatic:t in D⟧ ⟹ P ⊢ ⟨addr a∙F{D},(h, l₀ ++ l, sh),b⟩ → ⟨Val v,(h, l₀ ++ l, sh),b⟩› 17. ‹⋀(F::char list) (D::char list) (a::heap) (aa::sfields) (b::sheap) (ba::bool) l₀::sfields. (P::(char list list × char list exp) prog) ⊢ ⟨null∙F{D},(a, l₀ ++ aa, b),ba⟩ → ⟨THROW NullPointer,(a, l₀ ++ aa, b),ba⟩› 18. ‹⋀(h::heap) (a::nat) (C::char list) (fs::Objects.fields) (F::char list) (D::char list) (l::sfields) (sh::sheap) (b::bool) l₀::sfields. ⟦h a = ⌊(C, fs)⌋; ∄(b::staticb) t::ty. (P::(char list list × char list exp) prog) ⊢ C has F,b:t in D⟧ ⟹ P ⊢ ⟨addr a∙F{D},(h, l₀ ++ l, sh),b⟩ → ⟨THROW NoSuchFieldError,(h, l₀ ++ l, sh),b⟩› 19. ‹⋀(h::heap) (a::nat) (C::char list) (fs::Objects.fields) (F::char list) (t::ty) (D::char list) (l::sfields) (sh::sheap) (b::bool) l₀::sfields. ⟦h a = ⌊(C, fs)⌋; (P::(char list list × char list exp) prog) ⊢ C has F,Static:t in D⟧ ⟹ P ⊢ ⟨addr a∙F{D},(h, l₀ ++ l, sh),b⟩ → ⟨THROW IncompatibleClassChangeError,(h, l₀ ++ l, sh),b⟩› 20. ‹⋀(C::char list) (F::char list) (t::ty) (D::char list) (sh::sheap) (sfs::sfields) (i::init_state) (v::val) (h::heap) (l::sfields) l₀::sfields. ⟦(P::(char list list × char list exp) prog) ⊢ C has F,Static:t in D; sh D = ⌊(sfs, i)⌋; sfs F = ⌊v⌋⟧ ⟹ P ⊢ ⟨C∙⇩sF{D},(h, l₀ ++ l, sh),True⟩ → ⟨Val v,(h, l₀ ++ l, sh),False⟩› 21. ‹⋀(C::char list) (F::char list) (t::ty) (D::char list) (sh::sheap) (sfs::sfields) (h::heap) (l::sfields) l₀::sfields. ⟦(P::(char list list × char list exp) prog) ⊢ C has F,Static:t in D; sh D = ⌊(sfs, Done)⌋⟧ ⟹ P ⊢ ⟨C∙⇩sF{D},(h, l₀ ++ l, sh),False⟩ → ⟨C∙⇩sF{D},(h, l₀ ++ l, sh),True⟩› 22. ‹⋀(C::char list) (F::char list) (t::ty) (D::char list) (sh::sheap) (h::heap) (l::sfields) l₀::sfields. ⟦(P::(char list list × char list exp) prog) ⊢ C has F,Static:t in D; ∄sfs::sfields. sh D = ⌊(sfs, Done)⌋⟧ ⟹ P ⊢ ⟨C∙⇩sF{D},(h, l₀ ++ l, sh),False⟩ → ⟨INIT D ([D],False) ← C∙⇩sF{D},(h, l₀ ++ l, sh),False⟩› 23. ‹⋀(C::char list) (F::char list) (D::char list) (h::heap) (l::sfields) (sh::sheap) (b::bool) l₀::sfields. ∄(b::staticb) t::ty. (P::(char list list × char list exp) prog) ⊢ C has F,b:t in D ⟹ P ⊢ ⟨C∙⇩sF{D},(h, l₀ ++ l, sh),b⟩ → ⟨THROW NoSuchFieldError,(h, l₀ ++ l, sh),False⟩› 24. ‹⋀(C::char list) (F::char list) (t::ty) (D::char list) (h::heap) (l::sfields) (sh::sheap) (b::bool) l₀::sfields. (P::(char list list × char list exp) prog) ⊢ C has F,NonStatic:t in D ⟹ P ⊢ ⟨C∙⇩sF{D},(h, l₀ ++ l, sh),b⟩ → ⟨THROW IncompatibleClassChangeError,(h, l₀ ++ l, sh),False⟩› 25. ‹⋀(e::char list exp) (a::heap) (aa::sfields) (b::sheap) (ba::bool) (e'::char list exp) (ab::heap) (ac::sfields) (bb::sheap) (b'::bool) (F::char list) (D::char list) (e₂::char list exp) l₀::sfields. ⟦(P::(char list list × char list exp) prog) ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⋀l₀::sfields. P ⊢ ⟨e,(a, l₀ ++ aa, b),ba⟩ → ⟨e',(ab, l₀ ++ ac, bb),b'⟩⟧ ⟹ P ⊢ ⟨e∙F{D} := e₂,(a, l₀ ++ aa, b),ba⟩ → ⟨e'∙F{D} := e₂,(ab, l₀ ++ ac, bb),b'⟩› 26. ‹⋀(e::char list exp) (a::heap) (aa::sfields) (b::sheap) (ba::bool) (e'::char list exp) (ab::heap) (ac::sfields) (bb::sheap) (b'::bool) (v::val) (F::char list) (D::char list) l₀::sfields. ⟦(P::(char list list × char list exp) prog) ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⋀l₀::sfields. P ⊢ ⟨e,(a, l₀ ++ aa, b),ba⟩ → ⟨e',(ab, l₀ ++ ac, bb),b'⟩⟧ ⟹ P ⊢ ⟨Val v∙F{D} := e,(a, l₀ ++ aa, b),ba⟩ → ⟨Val v∙F{D} := e',(ab, l₀ ++ ac, bb),b'⟩› 27. ‹⋀(C::char list) (F::char list) (t::ty) (D::char list) (h::heap) (a::nat) (fs::Objects.fields) (v::val) (l::sfields) (sh::sheap) (b::bool) l₀::sfields. ⟦(P::(char list list × char list exp) prog) ⊢ C has F,NonStatic:t in D; h a = ⌊(C, fs)⌋⟧ ⟹ P ⊢ ⟨addr a∙F{D} := Val v,(h, l₀ ++ l, sh),b⟩ → ⟨unit,(h(a ↦ (C, fs((F, D) ↦ v))), l₀ ++ l, sh),b⟩› 28. ‹⋀(F::char list) (D::char list) (v::val) (a::heap) (aa::sfields) (b::sheap) (ba::bool) l₀::sfields. (P::(char list list × char list exp) prog) ⊢ ⟨null∙F{D} := Val v,(a, l₀ ++ aa, b),ba⟩ → ⟨THROW NullPointer,(a, l₀ ++ aa, b),ba⟩› 29. ‹⋀(h::heap) (a::nat) (C::char list) (fs::Objects.fields) (F::char list) (D::char list) (v::val) (l::sfields) (sh::sheap) (b::bool) l₀::sfields. ⟦h a = ⌊(C, fs)⌋; ∄(b::staticb) t::ty. (P::(char list list × char list exp) prog) ⊢ C has F,b:t in D⟧ ⟹ P ⊢ ⟨addr a∙F{D} := Val v,(h, l₀ ++ l, sh),b⟩ → ⟨THROW NoSuchFieldError,(h, l₀ ++ l, sh),b⟩› 30. ‹⋀(h::heap) (a::nat) (C::char list) (fs::Objects.fields) (F::char list) (t::ty) (D::char list) (v::val) (l::sfields) (sh::sheap) (b::bool) l₀::sfields. ⟦h a = ⌊(C, fs)⌋; (P::(char list list × char list exp) prog) ⊢ C has F,Static:t in D⟧ ⟹ P ⊢ ⟨addr a∙F{D} := Val v,(h, l₀ ++ l, sh),b⟩ → ⟨THROW IncompatibleClassChangeError,(h, l₀ ++ l, sh),b⟩› 31. ‹⋀(e::char list exp) (a::heap) (aa::sfields) (b::sheap) (ba::bool) (e'::char list exp) (ab::heap) (ac::sfields) (bb::sheap) (b'::bool) (C::char list) (F::char list) (D::char list) l₀::sfields. ⟦(P::(char list list × char list exp) prog) ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⋀l₀::sfields. P ⊢ ⟨e,(a, l₀ ++ aa, b),ba⟩ → ⟨e',(ab, l₀ ++ ac, bb),b'⟩⟧ ⟹ P ⊢ ⟨C∙⇩sF{D} := e,(a, l₀ ++ aa, b),ba⟩ → ⟨C∙⇩sF{D} := e',(ab, l₀ ++ ac, bb),b'⟩› 32. ‹⋀(C::char list) (F::char list) (t::ty) (D::char list) (sh::sheap) (sfs::sfields) (i::init_state) (sfs'::sfields) (v::val) (sh'::sheap) (h::heap) (l::sfields) l₀::sfields. ⟦(P::(char list list × char list exp) prog) ⊢ C has F,Static:t in D; sh D = ⌊(sfs, i)⌋; sfs' = sfs(F ↦ v); sh' = sh(D ↦ (sfs', i))⟧ ⟹ P ⊢ ⟨C∙⇩sF{D} := Val v,(h, l₀ ++ l, sh),True⟩ → ⟨unit,(h, l₀ ++ l, sh'),False⟩› 33. ‹⋀(C::char list) (F::char list) (t::ty) (D::char list) (sh::sheap) (sfs::sfields) (v::val) (h::heap) (l::sfields) l₀::sfields. ⟦(P::(char list list × char list exp) prog) ⊢ C has F,Static:t in D; sh D = ⌊(sfs, Done)⌋⟧ ⟹ P ⊢ ⟨C∙⇩sF{D} := Val v,(h, l₀ ++ l, sh),False⟩ → ⟨C∙⇩sF{D} := Val v,(h, l₀ ++ l, sh),True⟩› 34. ‹⋀(C::char list) (F::char list) (t::ty) (D::char list) (sh::sheap) (v::val) (h::heap) (l::sfields) l₀::sfields. ⟦(P::(char list list × char list exp) prog) ⊢ C has F,Static:t in D; ∄sfs::sfields. sh D = ⌊(sfs, Done)⌋⟧ ⟹ P ⊢ ⟨C∙⇩sF{D} := Val v,(h, l₀ ++ l, sh),False⟩ → ⟨INIT D ([D],False) ← C∙⇩sF{D} := Val v,(h, l₀ ++ l, sh),False⟩› 35. ‹⋀(C::char list) (F::char list) (D::char list) (v::val) (a::heap) (aa::sfields) (b::sheap) (ba::bool) l₀::sfields. ∄(b::staticb) t::ty. (P::(char list list × char list exp) prog) ⊢ C has F,b:t in D ⟹ P ⊢ ⟨C∙⇩sF{D} := Val v,(a, l₀ ++ aa, b),ba⟩ → ⟨THROW NoSuchFieldError,(a, l₀ ++ aa, b),False⟩› 36. ‹⋀(C::char list) (F::char list) (t::ty) (D::char list) (v::val) (a::heap) (aa::sfields) (b::sheap) (ba::bool) l₀::sfields. (P::(char list list × char list exp) prog) ⊢ C has F,NonStatic:t in D ⟹ P ⊢ ⟨C∙⇩sF{D} := Val v,(a, l₀ ++ aa, b),ba⟩ → ⟨THROW IncompatibleClassChangeError,(a, l₀ ++ aa, b),False⟩› 37. ‹⋀(e::char list exp) (a::heap) (aa::sfields) (b::sheap) (ba::bool) (e'::char list exp) (ab::heap) (ac::sfields) (bb::sheap) (b'::bool) (M::char list) (es::char list exp list) l₀::sfields. ⟦(P::(char list list × char list exp) prog) ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⋀l₀::sfields. P ⊢ ⟨e,(a, l₀ ++ aa, b),ba⟩ → ⟨e',(ab, l₀ ++ ac, bb),b'⟩⟧ ⟹ P ⊢ ⟨e∙M(es),(a, l₀ ++ aa, b),ba⟩ → ⟨e'∙M(es),(ab, l₀ ++ ac, bb),b'⟩› 38. ‹⋀(es::char list exp list) (a::heap) (aa::sfields) (b::sheap) (ba::bool) (es'::char list exp list) (ab::heap) (ac::sfields) (bb::sheap) (b'::bool) (v::val) (M::char list) l₀::sfields. ⟦(P::(char list list × char list exp) prog) ⊢ ⟨es,(a, aa, b),ba⟩ [→] ⟨es',(ab, ac, bb),b'⟩; ⋀l₀::sfields. P ⊢ ⟨es,(a, l₀ ++ aa, b),ba⟩ [→] ⟨es',(ab, l₀ ++ ac, bb),b'⟩⟧ ⟹ P ⊢ ⟨Val v∙M(es),(a, l₀ ++ aa, b),ba⟩ → ⟨Val v∙M(es'),(ab, l₀ ++ ac, bb),b'⟩› 39. ‹⋀(h::heap) (a::nat) (C::char list) (fs::Objects.fields) (M::char list) (Ts::ty list) (T::ty) (pns::char list list) (body::char list exp) (D::char list) (vs::val list) (l::sfields) (sh::sheap) (b::bool) l₀::sfields. ⟦h a = ⌊(C, fs)⌋; (P::(char list list × char list exp) prog) ⊢ C sees M, NonStatic : Ts→T = (pns, body) in D; length vs = length pns; length Ts = length pns⟧ ⟹ P ⊢ ⟨addr a∙M(map Val vs),(h, l₀ ++ l, sh),b⟩ → ⟨blocks (this # pns, Class D # Ts, Addr a # vs, body),(h, l₀ ++ l, sh),b⟩› 40. ‹⋀(M::char list) (vs::val list) (a::heap) (aa::sfields) (b::sheap) (ba::bool) l₀::sfields. (P::(char list list × char list exp) prog) ⊢ ⟨null∙M(map Val vs),(a, l₀ ++ aa, b),ba⟩ → ⟨THROW NullPointer,(a, l₀ ++ aa, b),ba⟩› 41. ‹⋀(h::heap) (a::nat) (C::char list) (fs::Objects.fields) (M::char list) (vs::val list) (l::sfields) (sh::sheap) (b::bool) l₀::sfields. ⟦h a = ⌊(C, fs)⌋; ∄(b::staticb) (Ts::ty list) (T::ty) (m::char list list × char list exp) D::char list. (P::(char list list × char list exp) prog) ⊢ C sees M, b : Ts→T = m in D⟧ ⟹ P ⊢ ⟨addr a∙M(map Val vs),(h, l₀ ++ l, sh),b⟩ → ⟨THROW NoSuchMethodError,(h, l₀ ++ l, sh),b⟩› 42. ‹⋀(h::heap) (a::nat) (C::char list) (fs::Objects.fields) (M::char list) (Ts::ty list) (T::ty) (aa::char list list) (b::char list exp) (D::char list) (vs::val list) (l::sfields) (sh::sheap) (ba::bool) l₀::sfields. ⟦h a = ⌊(C, fs)⌋; (P::(char list list × char list exp) prog) ⊢ C sees M, Static : Ts→T = (aa, b) in D⟧ ⟹ P ⊢ ⟨addr a∙M(map Val vs),(h, l₀ ++ l, sh),ba⟩ → ⟨THROW IncompatibleClassChangeError,(h, l₀ ++ l, sh),ba⟩› 43. ‹⋀(es::char list exp list) (a::heap) (aa::sfields) (b::sheap) (ba::bool) (es'::char list exp list) (ab::heap) (ac::sfields) (bb::sheap) (b'::bool) (C::char list) (M::char list) l₀::sfields. ⟦(P::(char list list × char list exp) prog) ⊢ ⟨es,(a, aa, b),ba⟩ [→] ⟨es',(ab, ac, bb),b'⟩; ⋀l₀::sfields. P ⊢ ⟨es,(a, l₀ ++ aa, b),ba⟩ [→] ⟨es',(ab, l₀ ++ ac, bb),b'⟩⟧ ⟹ P ⊢ ⟨C∙⇩sM(es),(a, l₀ ++ aa, b),ba⟩ → ⟨C∙⇩sM(es'),(ab, l₀ ++ ac, bb),b'⟩› 44. ‹⋀(C::char list) (M::char list) (Ts::ty list) (T::ty) (pns::char list list) (body::char list exp) (D::char list) (vs::val list) (a::heap) (aa::sfields) (b::sheap) l₀::sfields. ⟦(P::(char list list × char list exp) prog) ⊢ C sees M, Static : Ts→T = (pns, body) in D; length vs = length pns; length Ts = length pns⟧ ⟹ P ⊢ ⟨C∙⇩sM(map Val vs),(a, l₀ ++ aa, b),True⟩ → ⟨blocks (pns, Ts, vs, body),(a, l₀ ++ aa, b),False⟩› 45. ‹⋀(C::char list) (M::char list) (Ts::ty list) (T::ty) (pns::char list list) (body::char list exp) (D::char list) (sh::sheap) (sfs::sfields) (vs::val list) (h::heap) (l::sfields) l₀::sfields. ⟦(P::(char list list × char list exp) prog) ⊢ C sees M, Static : Ts→T = (pns, body) in D; sh D = ⌊(sfs, Done)⌋ ∨ M = clinit ∧ sh D = ⌊(sfs, Processing)⌋⟧ ⟹ P ⊢ ⟨C∙⇩sM(map Val vs),(h, l₀ ++ l, sh),False⟩ → ⟨C∙⇩sM(map Val vs),(h, l₀ ++ l, sh),True⟩› 46. ‹⋀(C::char list) (M::char list) (Ts::ty list) (T::ty) (pns::char list list) (body::char list exp) (D::char list) (sh::sheap) (vs::val list) (h::heap) (l::sfields) l₀::sfields. ⟦(P::(char list list × char list exp) prog) ⊢ C sees M, Static : Ts→T = (pns, body) in D; ∄sfs::sfields. sh D = ⌊(sfs, Done)⌋; M ≠ clinit⟧ ⟹ P ⊢ ⟨C∙⇩sM(map Val vs),(h, l₀ ++ l, sh),False⟩ → ⟨INIT D ([D],False) ← C∙⇩sM(map Val vs),(h, l₀ ++ l, sh),False⟩› 47. ‹⋀(C::char list) (M::char list) (vs::val list) (a::heap) (aa::sfields) (b::sheap) (ba::bool) l₀::sfields. ∄(b::staticb) (Ts::ty list) (T::ty) m::char list list × char list exp. Ex (Method (P::(char list list × char list exp) prog) C M b Ts T m) ⟹ P ⊢ ⟨C∙⇩sM(map Val vs),(a, l₀ ++ aa, b),ba⟩ → ⟨THROW NoSuchMethodError,(a, l₀ ++ aa, b),False⟩› 48. ‹⋀(C::char list) (M::char list) (Ts::ty list) (T::ty) (a::char list list) (b::char list exp) (D::char list) (vs::val list) (aa::heap) (ab::sfields) (ba::sheap) (bb::bool) l₀::sfields. (P::(char list list × char list exp) prog) ⊢ C sees M, NonStatic : Ts→T = (a, b) in D ⟹ P ⊢ ⟨C∙⇩sM(map Val vs),(aa, l₀ ++ ab, ba),bb⟩ → ⟨THROW IncompatibleClassChangeError,(aa, l₀ ++ ab, ba),False⟩› 49. ‹⋀(e::char list exp) (h::heap) (l::sfields) (V::char list) (sh::sheap) (b::bool) (e'::char list exp) (h'::heap) (l'::sfields) (sh'::sheap) (b'::bool) (T::ty) l₀::sfields. ⟦(P::(char list list × char list exp) prog) ⊢ ⟨e,(h, l(V := None), sh),b⟩ → ⟨e',(h', l', sh'),b'⟩; ⋀l₀::sfields. P ⊢ ⟨e,(h, l₀ ++ l(V := None), sh),b⟩ → ⟨e',(h', l₀ ++ l', sh'),b'⟩; l' V = None; ¬ assigned V e⟧ ⟹ P ⊢ ⟨{V:T; e},(h, l₀ ++ l, sh),b⟩ → ⟨{V:T; e'},(h', l₀ ++ l'(V := l V), sh'),b'⟩› 50. ‹⋀(e::char list exp) (h::heap) (l::sfields) (V::char list) (sh::sheap) (b::bool) (e'::char list exp) (h'::heap) (l'::sfields) (sh'::sheap) (b'::bool) (v::val) (T::ty) l₀::sfields. ⟦(P::(char list list × char list exp) prog) ⊢ ⟨e,(h, l(V := None), sh),b⟩ → ⟨e',(h', l', sh'),b'⟩; ⋀l₀::sfields. P ⊢ ⟨e,(h, l₀ ++ l(V := None), sh),b⟩ → ⟨e',(h', l₀ ++ l', sh'),b'⟩; l' V = ⌊v⌋; ¬ assigned V e⟧ ⟹ P ⊢ ⟨{V:T; e},(h, l₀ ++ l, sh),b⟩ → ⟨{V:T; V:=Val v;; e'},(h', l₀ ++ l'(V := l V), sh'),b'⟩› 51. ‹⋀(e::char list exp) (h::heap) (l::sfields) (V::char list) (v::val) (sh::sheap) (b::bool) (e'::char list exp) (h'::heap) (l'::sfields) (sh'::sheap) (b'::bool) (v'::val) (T::ty) l₀::sfields. ⟦(P::(char list list × char list exp) prog) ⊢ ⟨e,(h, l(V ↦ v), sh),b⟩ → ⟨e',(h', l', sh'),b'⟩; ⋀l₀::sfields. P ⊢ ⟨e,(h, l₀ ++ l(V ↦ v), sh),b⟩ → ⟨e',(h', l₀ ++ l', sh'),b'⟩; l' V = ⌊v'⌋⟧ ⟹ P ⊢ ⟨{V:T; V:=Val v;; e},(h, l₀ ++ l, sh),b⟩ → ⟨{V:T; V:=Val v';; e'},(h', l₀ ++ l'(V := l V), sh'),b'⟩› 52. ‹⋀(V::char list) (T::ty) (u::val) (a::heap) (aa::sfields) (b::sheap) (ba::bool) l₀::sfields. (P::(char list list × char list exp) prog) ⊢ ⟨{V:T; Val u},(a, l₀ ++ aa, b),ba⟩ → ⟨Val u,(a, l₀ ++ aa, b),ba⟩› 53. ‹⋀(V::char list) (T::ty) (v::val) (u::val) (a::heap) (aa::sfields) (b::sheap) (ba::bool) l₀::sfields. (P::(char list list × char list exp) prog) ⊢ ⟨{V:T; V:=Val v;; Val u},(a, l₀ ++ aa, b),ba⟩ → ⟨Val u,(a, l₀ ++ aa, b),ba⟩› 54. ‹⋀(e::char list exp) (a::heap) (aa::sfields) (b::sheap) (ba::bool) (e'::char list exp) (ab::heap) (ac::sfields) (bb::sheap) (b'::bool) (e₂::char list exp) l₀::sfields. ⟦(P::(char list list × char list exp) prog) ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⋀l₀::sfields. P ⊢ ⟨e,(a, l₀ ++ aa, b),ba⟩ → ⟨e',(ab, l₀ ++ ac, bb),b'⟩⟧ ⟹ P ⊢ ⟨e;; e₂,(a, l₀ ++ aa, b),ba⟩ → ⟨e';; e₂,(ab, l₀ ++ ac, bb),b'⟩› 55. ‹⋀(v::val) (e₂::char list exp) (a::heap) (aa::sfields) (b::sheap) (ba::bool) l₀::sfields. (P::(char list list × char list exp) prog) ⊢ ⟨Val v;; e₂,(a, l₀ ++ aa, b),ba⟩ → ⟨e₂,(a, l₀ ++ aa, b),ba⟩› 56. ‹⋀(e::char list exp) (a::heap) (aa::sfields) (b::sheap) (ba::bool) (e'::char list exp) (ab::heap) (ac::sfields) (bb::sheap) (b'::bool) (e₁::char list exp) (e₂::char list exp) l₀::sfields. ⟦(P::(char list list × char list exp) prog) ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⋀l₀::sfields. P ⊢ ⟨e,(a, l₀ ++ aa, b),ba⟩ → ⟨e',(ab, l₀ ++ ac, bb),b'⟩⟧ ⟹ P ⊢ ⟨if (e) e₁ else e₂,(a, l₀ ++ aa, b),ba⟩ → ⟨if (e') e₁ else e₂,(ab, l₀ ++ ac, bb),b'⟩› 57. ‹⋀(e₁::char list exp) (e₂::char list exp) (a::heap) (aa::sfields) (b::sheap) (ba::bool) l₀::sfields. (P::(char list list × char list exp) prog) ⊢ ⟨if (true) e₁ else e₂,(a, l₀ ++ aa, b),ba⟩ → ⟨e₁,(a, l₀ ++ aa, b),ba⟩› 58. ‹⋀(e₁::char list exp) (e₂::char list exp) (a::heap) (aa::sfields) (b::sheap) (ba::bool) l₀::sfields. (P::(char list list × char list exp) prog) ⊢ ⟨if (false) e₁ else e₂,(a, l₀ ++ aa, b),ba⟩ → ⟨e₂,(a, l₀ ++ aa, b),ba⟩› 59. ‹⋀(b::char list exp) (c::char list exp) (a::heap) (aa::sfields) (ba::sheap) (b'::bool) l₀::sfields. (P::(char list list × char list exp) prog) ⊢ ⟨while (b) c,(a, l₀ ++ aa, ba),b'⟩ → ⟨if (b) (c;; while (b) c) else unit,(a, l₀ ++ aa, ba),b'⟩› 60. ‹⋀(e::char list exp) (a::heap) (aa::sfields) (b::sheap) (ba::bool) (e'::char list exp) (ab::heap) (ac::sfields) (bb::sheap) (b'::bool) l₀::sfields. ⟦(P::(char list list × char list exp) prog) ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⋀l₀::sfields. P ⊢ ⟨e,(a, l₀ ++ aa, b),ba⟩ → ⟨e',(ab, l₀ ++ ac, bb),b'⟩⟧ ⟹ P ⊢ ⟨throw e,(a, l₀ ++ aa, b),ba⟩ → ⟨throw e',(ab, l₀ ++ ac, bb),b'⟩› 61. ‹⋀(a::heap) (aa::sfields) (b::sheap) (ba::bool) l₀::sfields. (P::(char list list × char list exp) prog) ⊢ ⟨throw null,(a, l₀ ++ aa, b),ba⟩ → ⟨THROW NullPointer,(a, l₀ ++ aa, b),ba⟩› 62. ‹⋀(e::char list exp) (a::heap) (aa::sfields) (b::sheap) (ba::bool) (e'::char list exp) (ab::heap) (ac::sfields) (bb::sheap) (b'::bool) (C::char list) (V::char list) (e₂::char list exp) l₀::sfields. ⟦(P::(char list list × char list exp) prog) ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⋀l₀::sfields. P ⊢ ⟨e,(a, l₀ ++ aa, b),ba⟩ → ⟨e',(ab, l₀ ++ ac, bb),b'⟩⟧ ⟹ P ⊢ ⟨try e catch(C V) e₂,(a, l₀ ++ aa, b),ba⟩ → ⟨try e' catch(C V) e₂,(ab, l₀ ++ ac, bb),b'⟩› 63. ‹⋀(v::val) (C::char list) (V::char list) (e₂::char list exp) (a::heap) (aa::sfields) (b::sheap) (ba::bool) l₀::sfields. (P::(char list list × char list exp) prog) ⊢ ⟨try Val v catch(C V) e₂,(a, l₀ ++ aa, b),ba⟩ → ⟨Val v,(a, l₀ ++ aa, b),ba⟩› 64. ‹⋀(a::heap) (aa::sfields) (b::sheap) (ab::nat) (D::char list) (fs::Objects.fields) (C::char list) (V::char list) (e₂::char list exp) (ba::bool) l₀::sfields. ⟦hp (a, aa, b) ab = ⌊(D, fs)⌋; (P::(char list list × char list exp) prog) ⊢ D ≼⇧* C⟧ ⟹ P ⊢ ⟨try Throw ab catch(C V) e₂,(a, l₀ ++ aa, b),ba⟩ → ⟨{V:Class C; V:=addr ab;; e₂},(a, l₀ ++ aa, b),ba⟩› 65. ‹⋀(a::heap) (aa::sfields) (b::sheap) (ab::nat) (D::char list) (fs::Objects.fields) (C::char list) (V::char list) (e₂::char list exp) (ba::bool) l₀::sfields. ⟦hp (a, aa, b) ab = ⌊(D, fs)⌋; (D, C) ∉ (subcls1 (P::(char list list × char list exp) prog))⇧*⟧ ⟹ P ⊢ ⟨try Throw ab catch(C V) e₂,(a, l₀ ++ aa, b),ba⟩ → ⟨Throw ab,(a, l₀ ++ aa, b),ba⟩› 66. ‹⋀(e::char list exp) (a::heap) (aa::sfields) (b::sheap) (ba::bool) (e'::char list exp) (ab::heap) (ac::sfields) (bb::sheap) (b'::bool) (es::char list exp list) l₀::sfields. ⟦(P::(char list list × char list exp) prog) ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⋀l₀::sfields. P ⊢ ⟨e,(a, l₀ ++ aa, b),ba⟩ → ⟨e',(ab, l₀ ++ ac, bb),b'⟩⟧ ⟹ P ⊢ ⟨e # es,(a, l₀ ++ aa, b),ba⟩ [→] ⟨e' # es,(ab, l₀ ++ ac, bb),b'⟩› 67. ‹⋀(es::char list exp list) (a::heap) (aa::sfields) (b::sheap) (ba::bool) (es'::char list exp list) (ab::heap) (ac::sfields) (bb::sheap) (b'::bool) (v::val) l₀::sfields. ⟦(P::(char list list × char list exp) prog) ⊢ ⟨es,(a, aa, b),ba⟩ [→] ⟨es',(ab, ac, bb),b'⟩; ⋀l₀::sfields. P ⊢ ⟨es,(a, l₀ ++ aa, b),ba⟩ [→] ⟨es',(ab, l₀ ++ ac, bb),b'⟩⟧ ⟹ P ⊢ ⟨Val v # es,(a, l₀ ++ aa, b),ba⟩ [→] ⟨Val v # es',(ab, l₀ ++ ac, bb),b'⟩› 68. ‹⋀(e::char list exp) (C::char list) (b::bool) (a::heap) (aa::sfields) (ba::sheap) (b'::bool) l₀::sfields. ¬ sub_RI e ⟹ (P::(char list list × char list exp) prog) ⊢ ⟨INIT C ([],b) ← e,(a, l₀ ++ aa, ba),b'⟩ → ⟨e,(a, l₀ ++ aa, ba),icheck P C e⟩› 69. ‹⋀(sh::sheap) (C::char list) (C'::char list) (Cs::char list list) (e::char list exp) (h::heap) (l::sfields) (b::bool) l₀::sfields. sh C = None ⟹ (P::(char list list × char list exp) prog) ⊢ ⟨INIT C' (C # Cs,False) ← e,(h, l₀ ++ l, sh),b⟩ → ⟨INIT C' (C # Cs,False) ← e,(h, l₀ ++ l, sh(C ↦ (sblank P C, Prepared))),b⟩› 70. ‹⋀(sh::sheap) (C::char list) (sfs::sfields) (C'::char list) (Cs::char list list) (e::char list exp) (h::heap) (l::sfields) (b::bool) l₀::sfields. sh C = ⌊(sfs, Done)⌋ ⟹ (P::(char list list × char list exp) prog) ⊢ ⟨INIT C' (C # Cs,False) ← e,(h, l₀ ++ l, sh),b⟩ → ⟨INIT C' (Cs,True) ← e,(h, l₀ ++ l, sh),b⟩› 71. ‹⋀(sh::sheap) (C::char list) (sfs::sfields) (C'::char list) (Cs::char list list) (e::char list exp) (h::heap) (l::sfields) (b::bool) l₀::sfields. sh C = ⌊(sfs, Processing)⌋ ⟹ (P::(char list list × char list exp) prog) ⊢ ⟨INIT C' (C # Cs,False) ← e,(h, l₀ ++ l, sh),b⟩ → ⟨INIT C' (Cs,True) ← e,(h, l₀ ++ l, sh),b⟩› 72. ‹⋀(sh::sheap) (C::char list) (sfs::sfields) (C'::char list) (Cs::char list list) (e::char list exp) (h::heap) (l::sfields) (b::bool) l₀::sfields. sh C = ⌊(sfs, Error)⌋ ⟹ (P::(char list list × char list exp) prog) ⊢ ⟨INIT C' (C # Cs,False) ← e,(h, l₀ ++ l, sh),b⟩ → ⟨RI (C,THROW NoClassDefFoundError) ; Cs ← e,(h, l₀ ++ l, sh),b⟩› 73. ‹⋀(sh::sheap) (C::char list) (sfs::sfields) (sh'::sheap) (C'::char list) (Cs::char list list) (e::char list exp) (h::heap) (l::sfields) (b::bool) l₀::sfields. ⟦sh C = ⌊(sfs, Prepared)⌋; C = Object; sh' = sh(C ↦ (sfs, Processing))⟧ ⟹ (P::(char list list × char list exp) prog) ⊢ ⟨INIT C' (C # Cs,False) ← e,(h, l₀ ++ l, sh),b⟩ → ⟨INIT C' (C # Cs,True) ← e,(h, l₀ ++ l, sh'),b⟩› 74. ‹⋀(sh::sheap) (C::char list) (sfs::sfields) (D::char list) (a::fdecl list) (b::(char list list × char list exp) mdecl list) (sh'::sheap) (C'::char list) (Cs::char list list) (e::char list exp) (h::heap) (l::sfields) (ba::bool) l₀::sfields. ⟦sh C = ⌊(sfs, Prepared)⌋; C ≠ Object; class (P::(char list list × char list exp) prog) C = ⌊(D, a, b)⌋; sh' = sh(C ↦ (sfs, Processing))⟧ ⟹ P ⊢ ⟨INIT C' (C # Cs,False) ← e,(h, l₀ ++ l, sh),ba⟩ → ⟨INIT C' (D # C # Cs,False) ← e,(h, l₀ ++ l, sh'),ba⟩› 75. ‹⋀(C'::char list) (C::char list) (Cs::char list list) (e::char list exp) (h::heap) (l::sfields) (sh::sheap) (b::bool) l₀::sfields. (P::(char list list × char list exp) prog) ⊢ ⟨INIT C' (C # Cs,True) ← e,(h, l₀ ++ l, sh),b⟩ → ⟨RI (C,C∙⇩sclinit([])) ; Cs ← e,(h, l₀ ++ l, sh),b⟩› 76. ‹⋀(e::char list exp) (a::heap) (aa::sfields) (b::sheap) (ba::bool) (e'::char list exp) (ab::heap) (ac::sfields) (bb::sheap) (b'::bool) (C::char list) (Cs::char list list) (e₀::char list exp) l₀::sfields. ⟦(P::(char list list × char list exp) prog) ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⋀l₀::sfields. P ⊢ ⟨e,(a, l₀ ++ aa, b),ba⟩ → ⟨e',(ab, l₀ ++ ac, bb),b'⟩⟧ ⟹ P ⊢ ⟨RI (C,e) ; Cs ← e₀,(a, l₀ ++ aa, b),ba⟩ → ⟨RI (C,e') ; Cs ← e₀,(ab, l₀ ++ ac, bb),b'⟩› 77. ‹⋀(sh::sheap) (C::char list) (sfs::sfields) (i::init_state) (sh'::sheap) (C'::char list) (Cs::char list list) (v::val) (e::char list exp) (h::heap) (l::sfields) (b::bool) l₀::sfields. ⟦sh C = ⌊(sfs, i)⌋; sh' = sh(C ↦ (sfs, Done)); C' = last (C # Cs)⟧ ⟹ (P::(char list list × char list exp) prog) ⊢ ⟨RI (C,Val v) ; Cs ← e,(h, l₀ ++ l, sh),b⟩ → ⟨INIT C' (Cs,True) ← e,(h, l₀ ++ l, sh'),b⟩› 78. ‹⋀(C::char list) (e::char list exp) (a::heap) (aa::sfields) (b::sheap) (ba::bool) l₀::sfields. (P::(char list list × char list exp) prog) ⊢ ⟨Cast C (throw e),(a, l₀ ++ aa, b),ba⟩ → ⟨throw e,(a, l₀ ++ aa, b),ba⟩› 79. ‹⋀(e::char list exp) (bop::bop) (e₂::char list exp) (a::heap) (aa::sfields) (b::sheap) (ba::bool) l₀::sfields. (P::(char list list × char list exp) prog) ⊢ ⟨throw e «bop» e₂,(a, l₀ ++ aa, b),ba⟩ → ⟨throw e,(a, l₀ ++ aa, b),ba⟩› 80. ‹⋀(v₁::val) (bop::bop) (e::char list exp) (a::heap) (aa::sfields) (b::sheap) (ba::bool) l₀::sfields. (P::(char list list × char list exp) prog) ⊢ ⟨Val v₁ «bop» throw e,(a, l₀ ++ aa, b),ba⟩ → ⟨throw e,(a, l₀ ++ aa, b),ba⟩› 81. ‹⋀(V::char list) (e::char list exp) (a::heap) (aa::sfields) (b::sheap) (ba::bool) l₀::sfields. (P::(char list list × char list exp) prog) ⊢ ⟨V:=throw e,(a, l₀ ++ aa, b),ba⟩ → ⟨throw e,(a, l₀ ++ aa, b),ba⟩› 82. ‹⋀(e::char list exp) (F::char list) (D::char list) (a::heap) (aa::sfields) (b::sheap) (ba::bool) l₀::sfields. (P::(char list list × char list exp) prog) ⊢ ⟨throw e∙F{D},(a, l₀ ++ aa, b),ba⟩ → ⟨throw e,(a, l₀ ++ aa, b),ba⟩› 83. ‹⋀(e::char list exp) (F::char list) (D::char list) (e₂::char list exp) (a::heap) (aa::sfields) (b::sheap) (ba::bool) l₀::sfields. (P::(char list list × char list exp) prog) ⊢ ⟨throw e∙F{D} := e₂,(a, l₀ ++ aa, b),ba⟩ → ⟨throw e,(a, l₀ ++ aa, b),ba⟩› 84. ‹⋀(v::val) (F::char list) (D::char list) (e::char list exp) (a::heap) (aa::sfields) (b::sheap) (ba::bool) l₀::sfields. (P::(char list list × char list exp) prog) ⊢ ⟨Val v∙F{D} := throw e,(a, l₀ ++ aa, b),ba⟩ → ⟨throw e,(a, l₀ ++ aa, b),ba⟩› 85. ‹⋀(C::char list) (F::char list) (D::char list) (e::char list exp) (a::heap) (aa::sfields) (b::sheap) (ba::bool) l₀::sfields. (P::(char list list × char list exp) prog) ⊢ ⟨C∙⇩sF{D} := throw e,(a, l₀ ++ aa, b),ba⟩ → ⟨throw e,(a, l₀ ++ aa, b),ba⟩› 86. ‹⋀(e::char list exp) (M::char list) (es::char list exp list) (a::heap) (aa::sfields) (b::sheap) (ba::bool) l₀::sfields. (P::(char list list × char list exp) prog) ⊢ ⟨throw e∙M(es),(a, l₀ ++ aa, b),ba⟩ → ⟨throw e,(a, l₀ ++ aa, b),ba⟩› 87. ‹⋀(es::char list exp list) (vs::val list) (e::char list exp) (es'::char list exp list) (v::val) (M::char list) (a::heap) (aa::sfields) (b::sheap) (ba::bool) l₀::sfields. es = map Val vs @ throw e # es' ⟹ (P::(char list list × char list exp) prog) ⊢ ⟨Val v∙M(es),(a, l₀ ++ aa, b),ba⟩ → ⟨throw e,(a, l₀ ++ aa, b),ba⟩› 88. ‹⋀(es::char list exp list) (vs::val list) (e::char list exp) (es'::char list exp list) (C::char list) (M::char list) (a::heap) (aa::sfields) (b::sheap) (ba::bool) l₀::sfields. es = map Val vs @ throw e # es' ⟹ (P::(char list list × char list exp) prog) ⊢ ⟨C∙⇩sM(es),(a, l₀ ++ aa, b),ba⟩ → ⟨throw e,(a, l₀ ++ aa, b),ba⟩› 89. ‹⋀(V::char list) (T::ty) (a::nat) (aa::heap) (ab::sfields) (b::sheap) (ba::bool) l₀::sfields. (P::(char list list × char list exp) prog) ⊢ ⟨{V:T; Throw a},(aa, l₀ ++ ab, b),ba⟩ → ⟨Throw a,(aa, l₀ ++ ab, b),ba⟩› 90. ‹⋀(V::char list) (T::ty) (v::val) (a::nat) (aa::heap) (ab::sfields) (b::sheap) (ba::bool) l₀::sfields. (P::(char list list × char list exp) prog) ⊢ ⟨{V:T; V:=Val v;; Throw a},(aa, l₀ ++ ab, b),ba⟩ → ⟨Throw a,(aa, l₀ ++ ab, b),ba⟩› 91. ‹⋀(e::char list exp) (e₂::char list exp) (a::heap) (aa::sfields) (b::sheap) (ba::bool) l₀::sfields. (P::(char list list × char list exp) prog) ⊢ ⟨throw e;; e₂,(a, l₀ ++ aa, b),ba⟩ → ⟨throw e,(a, l₀ ++ aa, b),ba⟩› 92. ‹⋀(e::char list exp) (e₁::char list exp) (e₂::char list exp) (a::heap) (aa::sfields) (b::sheap) (ba::bool) l₀::sfields. (P::(char list list × char list exp) prog) ⊢ ⟨if (throw e) e₁ else e₂,(a, l₀ ++ aa, b),ba⟩ → ⟨throw e,(a, l₀ ++ aa, b),ba⟩› 93. ‹⋀(e::char list exp) (a::heap) (aa::sfields) (b::sheap) (ba::bool) l₀::sfields. (P::(char list list × char list exp) prog) ⊢ ⟨throw (throw e),(a, l₀ ++ aa, b),ba⟩ → ⟨throw e,(a, l₀ ++ aa, b),ba⟩› 94. ‹⋀(sh::sheap) (C::char list) (sfs::sfields) (i::init_state) (sh'::sheap) (a::nat) (D::char list) (Cs::char list list) (e::char list exp) (h::heap) (l::sfields) (b::bool) l₀::sfields. ⟦sh C = ⌊(sfs, i)⌋; sh' = sh(C ↦ (sfs, Error))⟧ ⟹ (P::(char list list × char list exp) prog) ⊢ ⟨RI (C,Throw a) ; D # Cs ← e,(h, l₀ ++ l, sh),b⟩ → ⟨RI (D,Throw a) ; Cs ← e,(h, l₀ ++ l, sh'),b⟩› 95. ‹⋀(sh::sheap) (C::char list) (sfs::sfields) (i::init_state) (sh'::sheap) (a::nat) (e::char list exp) (h::heap) (l::sfields) (b::bool) l₀::sfields. ⟦sh C = ⌊(sfs, i)⌋; sh' = sh(C ↦ (sfs, Error))⟧ ⟹ (P::(char list list × char list exp) prog) ⊢ ⟨RI (C,Throw a) ; [] ← e,(h, l₀ ++ l, sh),b⟩ → ⟨Throw a,(h, l₀ ++ l, sh'),b⟩›*) case RedCast (*‹h_ a_ = ⌊(D_, fs_)⌋› ‹(P::(char list list × char list exp) prog) ⊢ (D_::char list) ≼⇧* (C_::char list)›*) thus "?case" (*goal: ‹P ⊢ ⟨Cast C_ (addr a_),(h_, l₀ ++ l_, sh_),b_⟩ → ⟨addr a_,(h_, l₀ ++ l_, sh_),b_⟩›*) by (fastforce intro:red_reds.intros (*‹⟦new_Addr ?h = ⌊?a⌋; ?P ⊢ ?C has_fields ?FDTs; ?h' = ?h(?a ↦ blank ?P ?C)⟧ ⟹ ?P ⊢ ⟨new ?C,(?h, ?l, ?sh),True⟩ → ⟨addr ?a,(?h', ?l, ?sh),False⟩› ‹⟦new_Addr ?h = None; is_class ?P ?C⟧ ⟹ ?P ⊢ ⟨new ?C,(?h, ?l, ?sh),True⟩ → ⟨THROW OutOfMemory,(?h, ?l, ?sh),False⟩› ‹?sh ?C = ⌊(?sfs, Done)⌋ ⟹ ?P ⊢ ⟨new ?C,(?h, ?l, ?sh),False⟩ → ⟨new ?C,(?h, ?l, ?sh),True⟩› ‹⟦∄sfs. ?sh ?C = ⌊(sfs, Done)⌋; is_class ?P ?C⟧ ⟹ ?P ⊢ ⟨new ?C,(?h, ?l, ?sh),False⟩ → ⟨INIT ?C ([?C],False) ← new ?C,(?h, ?l, ?sh),False⟩› ‹?P ⊢ ⟨?e,?s,?b⟩ → ⟨?e',?s',?b'⟩ ⟹ ?P ⊢ ⟨Cast ?C ?e,?s,?b⟩ → ⟨Cast ?C ?e',?s',?b'⟩› ‹?P ⊢ ⟨Cast ?C null,?s,?b⟩ → ⟨null,?s,?b⟩› ‹⟦?h ?a = ⌊(?D, ?fs)⌋; ?P ⊢ ?D ≼⇧* ?C⟧ ⟹ ?P ⊢ ⟨Cast ?C (addr ?a),(?h, ?l, ?sh),?b⟩ → ⟨addr ?a,(?h, ?l, ?sh),?b⟩› ‹⟦?h ?a = ⌊(?D, ?fs)⌋; (?D, ?C) ∉ (subcls1 ?P)⇧*⟧ ⟹ ?P ⊢ ⟨Cast ?C (addr ?a),(?h, ?l, ?sh),?b⟩ → ⟨THROW ClassCast,(?h, ?l, ?sh),?b⟩› ‹?P ⊢ ⟨?e,?s,?b⟩ → ⟨?e',?s',?b'⟩ ⟹ ?P ⊢ ⟨?e «?bop» ?e₂,?s,?b⟩ → ⟨?e' «?bop» ?e₂,?s',?b'⟩› ‹?P ⊢ ⟨?e,?s,?b⟩ → ⟨?e',?s',?b'⟩ ⟹ ?P ⊢ ⟨Val ?v₁ «?bop» ?e,?s,?b⟩ → ⟨Val ?v₁ «?bop» ?e',?s',?b'⟩› ‹binop (?bop, ?v₁, ?v₂) = ⌊?v⌋ ⟹ ?P ⊢ ⟨Val ?v₁ «?bop» Val ?v₂,?s,?b⟩ → ⟨Val ?v,?s,?b⟩› ‹?l ?V = ⌊?v⌋ ⟹ ?P ⊢ ⟨Var ?V,(?h, ?l, ?sh),?b⟩ → ⟨Val ?v,(?h, ?l, ?sh),?b⟩› and more 83 facts*)) next (*goals: 1. ‹⋀h a C FDTs h' l sh l₀. ⟦new_Addr h = ⌊a⌋; P ⊢ C has_fields FDTs; h' = h(a ↦ blank P C)⟧ ⟹ P ⊢ ⟨new C,(h, l₀ ++ l, sh),True⟩ → ⟨addr a,(h', l₀ ++ l, sh),False⟩› 2. ‹⋀h C l sh l₀. ⟦new_Addr h = None; is_class P C⟧ ⟹ P ⊢ ⟨new C,(h, l₀ ++ l, sh),True⟩ → ⟨THROW OutOfMemory,(h, l₀ ++ l, sh),False⟩› 3. ‹⋀sh C sfs h l l₀. sh C = ⌊(sfs, Done)⌋ ⟹ P ⊢ ⟨new C,(h, l₀ ++ l, sh),False⟩ → ⟨new C,(h, l₀ ++ l, sh),True⟩› 4. ‹⋀sh C h l l₀. ⟦∄sfs. sh C = ⌊(sfs, Done)⌋; is_class P C⟧ ⟹ P ⊢ ⟨new C,(h, l₀ ++ l, sh),False⟩ → ⟨INIT C ([C],False) ← new C,(h, l₀ ++ l, sh),False⟩› 5. ‹⋀e a aa b ba e' ab ac bb b' C l₀. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⋀l₀. P ⊢ ⟨e,(a, l₀ ++ aa, b),ba⟩ → ⟨e',(ab, l₀ ++ ac, bb),b'⟩⟧ ⟹ P ⊢ ⟨Cast C e,(a, l₀ ++ aa, b),ba⟩ → ⟨Cast C e',(ab, l₀ ++ ac, bb),b'⟩› 6. ‹⋀C a aa b ba l₀. P ⊢ ⟨Cast C null,(a, l₀ ++ aa, b),ba⟩ → ⟨null,(a, l₀ ++ aa, b),ba⟩› 7. ‹⋀h a D fs C l sh b l₀. ⟦h a = ⌊(D, fs)⌋; (D, C) ∉ (subcls1 P)⇧*⟧ ⟹ P ⊢ ⟨Cast C (addr a),(h, l₀ ++ l, sh),b⟩ → ⟨THROW ClassCast,(h, l₀ ++ l, sh),b⟩› 8. ‹⋀e a aa b ba e' ab ac bb b' bop e₂ l₀. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⋀l₀. P ⊢ ⟨e,(a, l₀ ++ aa, b),ba⟩ → ⟨e',(ab, l₀ ++ ac, bb),b'⟩⟧ ⟹ P ⊢ ⟨e «bop» e₂,(a, l₀ ++ aa, b),ba⟩ → ⟨e' «bop» e₂,(ab, l₀ ++ ac, bb),b'⟩› 9. ‹⋀e a aa b ba e' ab ac bb b' v₁ bop l₀. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⋀l₀. P ⊢ ⟨e,(a, l₀ ++ aa, b),ba⟩ → ⟨e',(ab, l₀ ++ ac, bb),b'⟩⟧ ⟹ P ⊢ ⟨Val v₁ «bop» e,(a, l₀ ++ aa, b),ba⟩ → ⟨Val v₁ «bop» e',(ab, l₀ ++ ac, bb),b'⟩› 10. ‹⋀bop v₁ v₂ v a aa b ba l₀. binop (bop, v₁, v₂) = ⌊v⌋ ⟹ P ⊢ ⟨Val v₁ «bop» Val v₂,(a, l₀ ++ aa, b),ba⟩ → ⟨Val v,(a, l₀ ++ aa, b),ba⟩› 11. ‹⋀l V v h sh b l₀. l V = ⌊v⌋ ⟹ P ⊢ ⟨Var V,(h, l₀ ++ l, sh),b⟩ → ⟨Val v,(h, l₀ ++ l, sh),b⟩› 12. ‹⋀e a aa b ba e' ab ac bb b' V l₀. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⋀l₀. P ⊢ ⟨e,(a, l₀ ++ aa, b),ba⟩ → ⟨e',(ab, l₀ ++ ac, bb),b'⟩⟧ ⟹ P ⊢ ⟨V:=e,(a, l₀ ++ aa, b),ba⟩ → ⟨V:=e',(ab, l₀ ++ ac, bb),b'⟩› 13. ‹⋀V v h l sh b l₀. P ⊢ ⟨V:=Val v,(h, l₀ ++ l, sh),b⟩ → ⟨unit,(h, l₀ ++ l(V ↦ v), sh),b⟩› 14. ‹⋀e a aa b ba e' ab ac bb b' F D l₀. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⋀l₀. P ⊢ ⟨e,(a, l₀ ++ aa, b),ba⟩ → ⟨e',(ab, l₀ ++ ac, bb),b'⟩⟧ ⟹ P ⊢ ⟨e∙F{D},(a, l₀ ++ aa, b),ba⟩ → ⟨e'∙F{D},(ab, l₀ ++ ac, bb),b'⟩› 15. ‹⋀h a C fs F D v t l sh b l₀. ⟦h a = ⌊(C, fs)⌋; fs (F, D) = ⌊v⌋; P ⊢ C has F,NonStatic:t in D⟧ ⟹ P ⊢ ⟨addr a∙F{D},(h, l₀ ++ l, sh),b⟩ → ⟨Val v,(h, l₀ ++ l, sh),b⟩› 16. ‹⋀F D a aa b ba l₀. P ⊢ ⟨null∙F{D},(a, l₀ ++ aa, b),ba⟩ → ⟨THROW NullPointer,(a, l₀ ++ aa, b),ba⟩› 17. ‹⋀h a C fs F D l sh b l₀. ⟦h a = ⌊(C, fs)⌋; ∄b t. P ⊢ C has F,b:t in D⟧ ⟹ P ⊢ ⟨addr a∙F{D},(h, l₀ ++ l, sh),b⟩ → ⟨THROW NoSuchFieldError,(h, l₀ ++ l, sh),b⟩› 18. ‹⋀h a C fs F t D l sh b l₀. ⟦h a = ⌊(C, fs)⌋; P ⊢ C has F,Static:t in D⟧ ⟹ P ⊢ ⟨addr a∙F{D},(h, l₀ ++ l, sh),b⟩ → ⟨THROW IncompatibleClassChangeError,(h, l₀ ++ l, sh),b⟩› 19. ‹⋀C F t D sh sfs i v h l l₀. ⟦P ⊢ C has F,Static:t in D; sh D = ⌊(sfs, i)⌋; sfs F = ⌊v⌋⟧ ⟹ P ⊢ ⟨C∙⇩sF{D},(h, l₀ ++ l, sh),True⟩ → ⟨Val v,(h, l₀ ++ l, sh),False⟩› 20. ‹⋀C F t D sh sfs h l l₀. ⟦P ⊢ C has F,Static:t in D; sh D = ⌊(sfs, Done)⌋⟧ ⟹ P ⊢ ⟨C∙⇩sF{D},(h, l₀ ++ l, sh),False⟩ → ⟨C∙⇩sF{D},(h, l₀ ++ l, sh),True⟩› 21. ‹⋀C F t D sh h l l₀. ⟦P ⊢ C has F,Static:t in D; ∄sfs. sh D = ⌊(sfs, Done)⌋⟧ ⟹ P ⊢ ⟨C∙⇩sF{D},(h, l₀ ++ l, sh),False⟩ → ⟨INIT D ([D],False) ← C∙⇩sF{D},(h, l₀ ++ l, sh),False⟩› 22. ‹⋀C F D h l sh b l₀. ∄b t. P ⊢ C has F,b:t in D ⟹ P ⊢ ⟨C∙⇩sF{D},(h, l₀ ++ l, sh),b⟩ → ⟨THROW NoSuchFieldError,(h, l₀ ++ l, sh),False⟩› 23. ‹⋀C F t D h l sh b l₀. P ⊢ C has F,NonStatic:t in D ⟹ P ⊢ ⟨C∙⇩sF{D},(h, l₀ ++ l, sh),b⟩ → ⟨THROW IncompatibleClassChangeError,(h, l₀ ++ l, sh),False⟩› 24. ‹⋀e a aa b ba e' ab ac bb b' F D e₂ l₀. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⋀l₀. P ⊢ ⟨e,(a, l₀ ++ aa, b),ba⟩ → ⟨e',(ab, l₀ ++ ac, bb),b'⟩⟧ ⟹ P ⊢ ⟨e∙F{D} := e₂,(a, l₀ ++ aa, b),ba⟩ → ⟨e'∙F{D} := e₂,(ab, l₀ ++ ac, bb),b'⟩› 25. ‹⋀e a aa b ba e' ab ac bb b' v F D l₀. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⋀l₀. P ⊢ ⟨e,(a, l₀ ++ aa, b),ba⟩ → ⟨e',(ab, l₀ ++ ac, bb),b'⟩⟧ ⟹ P ⊢ ⟨Val v∙F{D} := e,(a, l₀ ++ aa, b),ba⟩ → ⟨Val v∙F{D} := e',(ab, l₀ ++ ac, bb),b'⟩› 26. ‹⋀C F t D h a fs v l sh b l₀. ⟦P ⊢ C has F,NonStatic:t in D; h a = ⌊(C, fs)⌋⟧ ⟹ P ⊢ ⟨addr a∙F{D} := Val v,(h, l₀ ++ l, sh),b⟩ → ⟨unit,(h(a ↦ (C, fs((F, D) ↦ v))), l₀ ++ l, sh),b⟩› 27. ‹⋀F D v a aa b ba l₀. P ⊢ ⟨null∙F{D} := Val v,(a, l₀ ++ aa, b),ba⟩ → ⟨THROW NullPointer,(a, l₀ ++ aa, b),ba⟩› 28. ‹⋀h a C fs F D v l sh b l₀. ⟦h a = ⌊(C, fs)⌋; ∄b t. P ⊢ C has F,b:t in D⟧ ⟹ P ⊢ ⟨addr a∙F{D} := Val v,(h, l₀ ++ l, sh),b⟩ → ⟨THROW NoSuchFieldError,(h, l₀ ++ l, sh),b⟩› 29. ‹⋀h a C fs F t D v l sh b l₀. ⟦h a = ⌊(C, fs)⌋; P ⊢ C has F,Static:t in D⟧ ⟹ P ⊢ ⟨addr a∙F{D} := Val v,(h, l₀ ++ l, sh),b⟩ → ⟨THROW IncompatibleClassChangeError,(h, l₀ ++ l, sh),b⟩› 30. ‹⋀e a aa b ba e' ab ac bb b' C F D l₀. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⋀l₀. P ⊢ ⟨e,(a, l₀ ++ aa, b),ba⟩ → ⟨e',(ab, l₀ ++ ac, bb),b'⟩⟧ ⟹ P ⊢ ⟨C∙⇩sF{D} := e,(a, l₀ ++ aa, b),ba⟩ → ⟨C∙⇩sF{D} := e',(ab, l₀ ++ ac, bb),b'⟩› 31. ‹⋀C F t D sh sfs i sfs' v sh' h l l₀. ⟦P ⊢ C has F,Static:t in D; sh D = ⌊(sfs, i)⌋; sfs' = sfs(F ↦ v); sh' = sh(D ↦ (sfs', i))⟧ ⟹ P ⊢ ⟨C∙⇩sF{D} := Val v,(h, l₀ ++ l, sh),True⟩ → ⟨unit,(h, l₀ ++ l, sh'),False⟩› 32. ‹⋀C F t D sh sfs v h l l₀. ⟦P ⊢ C has F,Static:t in D; sh D = ⌊(sfs, Done)⌋⟧ ⟹ P ⊢ ⟨C∙⇩sF{D} := Val v,(h, l₀ ++ l, sh),False⟩ → ⟨C∙⇩sF{D} := Val v,(h, l₀ ++ l, sh),True⟩› 33. ‹⋀C F t D sh v h l l₀. ⟦P ⊢ C has F,Static:t in D; ∄sfs. sh D = ⌊(sfs, Done)⌋⟧ ⟹ P ⊢ ⟨C∙⇩sF{D} := Val v,(h, l₀ ++ l, sh),False⟩ → ⟨INIT D ([D],False) ← C∙⇩sF{D} := Val v,(h, l₀ ++ l, sh),False⟩› 34. ‹⋀C F D v a aa b ba l₀. ∄b t. P ⊢ C has F,b:t in D ⟹ P ⊢ ⟨C∙⇩sF{D} := Val v,(a, l₀ ++ aa, b),ba⟩ → ⟨THROW NoSuchFieldError,(a, l₀ ++ aa, b),False⟩› 35. ‹⋀C F t D v a aa b ba l₀. P ⊢ C has F,NonStatic:t in D ⟹ P ⊢ ⟨C∙⇩sF{D} := Val v,(a, l₀ ++ aa, b),ba⟩ → ⟨THROW IncompatibleClassChangeError,(a, l₀ ++ aa, b),False⟩› 36. ‹⋀e a aa b ba e' ab ac bb b' M es l₀. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⋀l₀. P ⊢ ⟨e,(a, l₀ ++ aa, b),ba⟩ → ⟨e',(ab, l₀ ++ ac, bb),b'⟩⟧ ⟹ P ⊢ ⟨e∙M(es),(a, l₀ ++ aa, b),ba⟩ → ⟨e'∙M(es),(ab, l₀ ++ ac, bb),b'⟩› 37. ‹⋀es a aa b ba es' ab ac bb b' v M l₀. ⟦P ⊢ ⟨es,(a, aa, b),ba⟩ [→] ⟨es',(ab, ac, bb),b'⟩; ⋀l₀. P ⊢ ⟨es,(a, l₀ ++ aa, b),ba⟩ [→] ⟨es',(ab, l₀ ++ ac, bb),b'⟩⟧ ⟹ P ⊢ ⟨Val v∙M(es),(a, l₀ ++ aa, b),ba⟩ → ⟨Val v∙M(es'),(ab, l₀ ++ ac, bb),b'⟩› 38. ‹⋀h a C fs M Ts T pns body D vs l sh b l₀. ⟦h a = ⌊(C, fs)⌋; P ⊢ C sees M, NonStatic : Ts→T = (pns, body) in D; length vs = length pns; length Ts = length pns⟧ ⟹ P ⊢ ⟨addr a∙M(map Val vs),(h, l₀ ++ l, sh),b⟩ → ⟨blocks (this # pns, Class D # Ts, Addr a # vs, body),(h, l₀ ++ l, sh),b⟩› 39. ‹⋀M vs a aa b ba l₀. P ⊢ ⟨null∙M(map Val vs),(a, l₀ ++ aa, b),ba⟩ → ⟨THROW NullPointer,(a, l₀ ++ aa, b),ba⟩› 40. ‹⋀h a C fs M vs l sh b l₀. ⟦h a = ⌊(C, fs)⌋; ∄b Ts T m D. P ⊢ C sees M, b : Ts→T = m in D⟧ ⟹ P ⊢ ⟨addr a∙M(map Val vs),(h, l₀ ++ l, sh),b⟩ → ⟨THROW NoSuchMethodError,(h, l₀ ++ l, sh),b⟩› 41. ‹⋀h a C fs M Ts T aa b D vs l sh ba l₀. ⟦h a = ⌊(C, fs)⌋; P ⊢ C sees M, Static : Ts→T = (aa, b) in D⟧ ⟹ P ⊢ ⟨addr a∙M(map Val vs),(h, l₀ ++ l, sh),ba⟩ → ⟨THROW IncompatibleClassChangeError,(h, l₀ ++ l, sh),ba⟩› 42. ‹⋀es a aa b ba es' ab ac bb b' C M l₀. ⟦P ⊢ ⟨es,(a, aa, b),ba⟩ [→] ⟨es',(ab, ac, bb),b'⟩; ⋀l₀. P ⊢ ⟨es,(a, l₀ ++ aa, b),ba⟩ [→] ⟨es',(ab, l₀ ++ ac, bb),b'⟩⟧ ⟹ P ⊢ ⟨C∙⇩sM(es),(a, l₀ ++ aa, b),ba⟩ → ⟨C∙⇩sM(es'),(ab, l₀ ++ ac, bb),b'⟩› 43. ‹⋀C M Ts T pns body D vs a aa b l₀. ⟦P ⊢ C sees M, Static : Ts→T = (pns, body) in D; length vs = length pns; length Ts = length pns⟧ ⟹ P ⊢ ⟨C∙⇩sM(map Val vs),(a, l₀ ++ aa, b),True⟩ → ⟨blocks (pns, Ts, vs, body),(a, l₀ ++ aa, b),False⟩› 44. ‹⋀C M Ts T pns body D sh sfs vs h l l₀. ⟦P ⊢ C sees M, Static : Ts→T = (pns, body) in D; sh D = ⌊(sfs, Done)⌋ ∨ M = clinit ∧ sh D = ⌊(sfs, Processing)⌋⟧ ⟹ P ⊢ ⟨C∙⇩sM(map Val vs),(h, l₀ ++ l, sh),False⟩ → ⟨C∙⇩sM(map Val vs),(h, l₀ ++ l, sh),True⟩› 45. ‹⋀C M Ts T pns body D sh vs h l l₀. ⟦P ⊢ C sees M, Static : Ts→T = (pns, body) in D; ∄sfs. sh D = ⌊(sfs, Done)⌋; M ≠ clinit⟧ ⟹ P ⊢ ⟨C∙⇩sM(map Val vs),(h, l₀ ++ l, sh),False⟩ → ⟨INIT D ([D],False) ← C∙⇩sM(map Val vs),(h, l₀ ++ l, sh),False⟩› 46. ‹⋀C M vs a aa b ba l₀. ∄b Ts T m. Ex (Method P C M b Ts T m) ⟹ P ⊢ ⟨C∙⇩sM(map Val vs),(a, l₀ ++ aa, b),ba⟩ → ⟨THROW NoSuchMethodError,(a, l₀ ++ aa, b),False⟩› 47. ‹⋀C M Ts T a b D vs aa ab ba bb l₀. P ⊢ C sees M, NonStatic : Ts→T = (a, b) in D ⟹ P ⊢ ⟨C∙⇩sM(map Val vs),(aa, l₀ ++ ab, ba),bb⟩ → ⟨THROW IncompatibleClassChangeError,(aa, l₀ ++ ab, ba),False⟩› 48. ‹⋀e h l V sh b e' h' l' sh' b' T l₀. ⟦P ⊢ ⟨e,(h, l(V := None), sh),b⟩ → ⟨e',(h', l', sh'),b'⟩; ⋀l₀. P ⊢ ⟨e,(h, l₀ ++ l(V := None), sh),b⟩ → ⟨e',(h', l₀ ++ l', sh'),b'⟩; l' V = None; ¬ assigned V e⟧ ⟹ P ⊢ ⟨{V:T; e},(h, l₀ ++ l, sh),b⟩ → ⟨{V:T; e'},(h', l₀ ++ l'(V := l V), sh'),b'⟩› 49. ‹⋀e h l V sh b e' h' l' sh' b' v T l₀. ⟦P ⊢ ⟨e,(h, l(V := None), sh),b⟩ → ⟨e',(h', l', sh'),b'⟩; ⋀l₀. P ⊢ ⟨e,(h, l₀ ++ l(V := None), sh),b⟩ → ⟨e',(h', l₀ ++ l', sh'),b'⟩; l' V = ⌊v⌋; ¬ assigned V e⟧ ⟹ P ⊢ ⟨{V:T; e},(h, l₀ ++ l, sh),b⟩ → ⟨{V:T; V:=Val v;; e'},(h', l₀ ++ l'(V := l V), sh'),b'⟩› 50. ‹⋀e h l V v sh b e' h' l' sh' b' v' T l₀. ⟦P ⊢ ⟨e,(h, l(V ↦ v), sh),b⟩ → ⟨e',(h', l', sh'),b'⟩; ⋀l₀. P ⊢ ⟨e,(h, l₀ ++ l(V ↦ v), sh),b⟩ → ⟨e',(h', l₀ ++ l', sh'),b'⟩; l' V = ⌊v'⌋⟧ ⟹ P ⊢ ⟨{V:T; V:=Val v;; e},(h, l₀ ++ l, sh),b⟩ → ⟨{V:T; V:=Val v';; e'},(h', l₀ ++ l'(V := l V), sh'),b'⟩› 51. ‹⋀V T u a aa b ba l₀. P ⊢ ⟨{V:T; Val u},(a, l₀ ++ aa, b),ba⟩ → ⟨Val u,(a, l₀ ++ aa, b),ba⟩› 52. ‹⋀V T v u a aa b ba l₀. P ⊢ ⟨{V:T; V:=Val v;; Val u},(a, l₀ ++ aa, b),ba⟩ → ⟨Val u,(a, l₀ ++ aa, b),ba⟩› 53. ‹⋀e a aa b ba e' ab ac bb b' e₂ l₀. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⋀l₀. P ⊢ ⟨e,(a, l₀ ++ aa, b),ba⟩ → ⟨e',(ab, l₀ ++ ac, bb),b'⟩⟧ ⟹ P ⊢ ⟨e;; e₂,(a, l₀ ++ aa, b),ba⟩ → ⟨e';; e₂,(ab, l₀ ++ ac, bb),b'⟩› 54. ‹⋀v e₂ a aa b ba l₀. P ⊢ ⟨Val v;; e₂,(a, l₀ ++ aa, b),ba⟩ → ⟨e₂,(a, l₀ ++ aa, b),ba⟩› 55. ‹⋀e a aa b ba e' ab ac bb b' e₁ e₂ l₀. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⋀l₀. P ⊢ ⟨e,(a, l₀ ++ aa, b),ba⟩ → ⟨e',(ab, l₀ ++ ac, bb),b'⟩⟧ ⟹ P ⊢ ⟨if (e) e₁ else e₂,(a, l₀ ++ aa, b),ba⟩ → ⟨if (e') e₁ else e₂,(ab, l₀ ++ ac, bb),b'⟩› 56. ‹⋀e₁ e₂ a aa b ba l₀. P ⊢ ⟨if (true) e₁ else e₂,(a, l₀ ++ aa, b),ba⟩ → ⟨e₁,(a, l₀ ++ aa, b),ba⟩› 57. ‹⋀e₁ e₂ a aa b ba l₀. P ⊢ ⟨if (false) e₁ else e₂,(a, l₀ ++ aa, b),ba⟩ → ⟨e₂,(a, l₀ ++ aa, b),ba⟩› 58. ‹⋀b c a aa ba b' l₀. P ⊢ ⟨while (b) c,(a, l₀ ++ aa, ba),b'⟩ → ⟨if (b) (c;; while (b) c) else unit,(a, l₀ ++ aa, ba),b'⟩› 59. ‹⋀e a aa b ba e' ab ac bb b' l₀. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⋀l₀. P ⊢ ⟨e,(a, l₀ ++ aa, b),ba⟩ → ⟨e',(ab, l₀ ++ ac, bb),b'⟩⟧ ⟹ P ⊢ ⟨throw e,(a, l₀ ++ aa, b),ba⟩ → ⟨throw e',(ab, l₀ ++ ac, bb),b'⟩› 60. ‹⋀a aa b ba l₀. P ⊢ ⟨throw null,(a, l₀ ++ aa, b),ba⟩ → ⟨THROW NullPointer,(a, l₀ ++ aa, b),ba⟩› 61. ‹⋀e a aa b ba e' ab ac bb b' C V e₂ l₀. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⋀l₀. P ⊢ ⟨e,(a, l₀ ++ aa, b),ba⟩ → ⟨e',(ab, l₀ ++ ac, bb),b'⟩⟧ ⟹ P ⊢ ⟨try e catch(C V) e₂,(a, l₀ ++ aa, b),ba⟩ → ⟨try e' catch(C V) e₂,(ab, l₀ ++ ac, bb),b'⟩› 62. ‹⋀v C V e₂ a aa b ba l₀. P ⊢ ⟨try Val v catch(C V) e₂,(a, l₀ ++ aa, b),ba⟩ → ⟨Val v,(a, l₀ ++ aa, b),ba⟩› 63. ‹⋀a aa b ab D fs C V e₂ ba l₀. ⟦hp (a, aa, b) ab = ⌊(D, fs)⌋; P ⊢ D ≼⇧* C⟧ ⟹ P ⊢ ⟨try Throw ab catch(C V) e₂,(a, l₀ ++ aa, b),ba⟩ → ⟨{V:Class C; V:=addr ab;; e₂},(a, l₀ ++ aa, b),ba⟩› 64. ‹⋀a aa b ab D fs C V e₂ ba l₀. ⟦hp (a, aa, b) ab = ⌊(D, fs)⌋; (D, C) ∉ (subcls1 P)⇧*⟧ ⟹ P ⊢ ⟨try Throw ab catch(C V) e₂,(a, l₀ ++ aa, b),ba⟩ → ⟨Throw ab,(a, l₀ ++ aa, b),ba⟩› 65. ‹⋀e a aa b ba e' ab ac bb b' es l₀. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⋀l₀. P ⊢ ⟨e,(a, l₀ ++ aa, b),ba⟩ → ⟨e',(ab, l₀ ++ ac, bb),b'⟩⟧ ⟹ P ⊢ ⟨e # es,(a, l₀ ++ aa, b),ba⟩ [→] ⟨e' # es,(ab, l₀ ++ ac, bb),b'⟩› 66. ‹⋀es a aa b ba es' ab ac bb b' v l₀. ⟦P ⊢ ⟨es,(a, aa, b),ba⟩ [→] ⟨es',(ab, ac, bb),b'⟩; ⋀l₀. P ⊢ ⟨es,(a, l₀ ++ aa, b),ba⟩ [→] ⟨es',(ab, l₀ ++ ac, bb),b'⟩⟧ ⟹ P ⊢ ⟨Val v # es,(a, l₀ ++ aa, b),ba⟩ [→] ⟨Val v # es',(ab, l₀ ++ ac, bb),b'⟩› 67. ‹⋀e C b a aa ba b' l₀. ¬ sub_RI e ⟹ P ⊢ ⟨INIT C ([],b) ← e,(a, l₀ ++ aa, ba),b'⟩ → ⟨e,(a, l₀ ++ aa, ba),icheck P C e⟩› 68. ‹⋀sh C C' Cs e h l b l₀. sh C = None ⟹ P ⊢ ⟨INIT C' (C # Cs,False) ← e,(h, l₀ ++ l, sh),b⟩ → ⟨INIT C' (C # Cs,False) ← e,(h, l₀ ++ l, sh(C ↦ (sblank P C, Prepared))),b⟩› 69. ‹⋀sh C sfs C' Cs e h l b l₀. sh C = ⌊(sfs, Done)⌋ ⟹ P ⊢ ⟨INIT C' (C # Cs,False) ← e,(h, l₀ ++ l, sh),b⟩ → ⟨INIT C' (Cs,True) ← e,(h, l₀ ++ l, sh),b⟩› 70. ‹⋀sh C sfs C' Cs e h l b l₀. sh C = ⌊(sfs, Processing)⌋ ⟹ P ⊢ ⟨INIT C' (C # Cs,False) ← e,(h, l₀ ++ l, sh),b⟩ → ⟨INIT C' (Cs,True) ← e,(h, l₀ ++ l, sh),b⟩› 71. ‹⋀sh C sfs C' Cs e h l b l₀. sh C = ⌊(sfs, Error)⌋ ⟹ P ⊢ ⟨INIT C' (C # Cs,False) ← e,(h, l₀ ++ l, sh),b⟩ → ⟨RI (C,THROW NoClassDefFoundError) ; Cs ← e,(h, l₀ ++ l, sh),b⟩› 72. ‹⋀sh C sfs sh' C' Cs e h l b l₀. ⟦sh C = ⌊(sfs, Prepared)⌋; C = Object; sh' = sh(C ↦ (sfs, Processing))⟧ ⟹ P ⊢ ⟨INIT C' (C # Cs,False) ← e,(h, l₀ ++ l, sh),b⟩ → ⟨INIT C' (C # Cs,True) ← e,(h, l₀ ++ l, sh'),b⟩› 73. ‹⋀sh C sfs D a b sh' C' Cs e h l ba l₀. ⟦sh C = ⌊(sfs, Prepared)⌋; C ≠ Object; class P C = ⌊(D, a, b)⌋; sh' = sh(C ↦ (sfs, Processing))⟧ ⟹ P ⊢ ⟨INIT C' (C # Cs,False) ← e,(h, l₀ ++ l, sh),ba⟩ → ⟨INIT C' (D # C # Cs,False) ← e,(h, l₀ ++ l, sh'),ba⟩› 74. ‹⋀C' C Cs e h l sh b l₀. P ⊢ ⟨INIT C' (C # Cs,True) ← e,(h, l₀ ++ l, sh),b⟩ → ⟨RI (C,C∙⇩sclinit([])) ; Cs ← e,(h, l₀ ++ l, sh),b⟩› 75. ‹⋀e a aa b ba e' ab ac bb b' C Cs e₀ l₀. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⋀l₀. P ⊢ ⟨e,(a, l₀ ++ aa, b),ba⟩ → ⟨e',(ab, l₀ ++ ac, bb),b'⟩⟧ ⟹ P ⊢ ⟨RI (C,e) ; Cs ← e₀,(a, l₀ ++ aa, b),ba⟩ → ⟨RI (C,e') ; Cs ← e₀,(ab, l₀ ++ ac, bb),b'⟩› 76. ‹⋀sh C sfs i sh' C' Cs v e h l b l₀. ⟦sh C = ⌊(sfs, i)⌋; sh' = sh(C ↦ (sfs, Done)); C' = last (C # Cs)⟧ ⟹ P ⊢ ⟨RI (C,Val v) ; Cs ← e,(h, l₀ ++ l, sh),b⟩ → ⟨INIT C' (Cs,True) ← e,(h, l₀ ++ l, sh'),b⟩› 77. ‹⋀C e a aa b ba l₀. P ⊢ ⟨Cast C (throw e),(a, l₀ ++ aa, b),ba⟩ → ⟨throw e,(a, l₀ ++ aa, b),ba⟩› 78. ‹⋀e bop e₂ a aa b ba l₀. P ⊢ ⟨throw e «bop» e₂,(a, l₀ ++ aa, b),ba⟩ → ⟨throw e,(a, l₀ ++ aa, b),ba⟩› 79. ‹⋀v₁ bop e a aa b ba l₀. P ⊢ ⟨Val v₁ «bop» throw e,(a, l₀ ++ aa, b),ba⟩ → ⟨throw e,(a, l₀ ++ aa, b),ba⟩› 80. ‹⋀V e a aa b ba l₀. P ⊢ ⟨V:=throw e,(a, l₀ ++ aa, b),ba⟩ → ⟨throw e,(a, l₀ ++ aa, b),ba⟩› 81. ‹⋀e F D a aa b ba l₀. P ⊢ ⟨throw e∙F{D},(a, l₀ ++ aa, b),ba⟩ → ⟨throw e,(a, l₀ ++ aa, b),ba⟩› 82. ‹⋀e F D e₂ a aa b ba l₀. P ⊢ ⟨throw e∙F{D} := e₂,(a, l₀ ++ aa, b),ba⟩ → ⟨throw e,(a, l₀ ++ aa, b),ba⟩› 83. ‹⋀v F D e a aa b ba l₀. P ⊢ ⟨Val v∙F{D} := throw e,(a, l₀ ++ aa, b),ba⟩ → ⟨throw e,(a, l₀ ++ aa, b),ba⟩› 84. ‹⋀C F D e a aa b ba l₀. P ⊢ ⟨C∙⇩sF{D} := throw e,(a, l₀ ++ aa, b),ba⟩ → ⟨throw e,(a, l₀ ++ aa, b),ba⟩› 85. ‹⋀e M es a aa b ba l₀. P ⊢ ⟨throw e∙M(es),(a, l₀ ++ aa, b),ba⟩ → ⟨throw e,(a, l₀ ++ aa, b),ba⟩› 86. ‹⋀es vs e es' v M a aa b ba l₀. es = map Val vs @ throw e # es' ⟹ P ⊢ ⟨Val v∙M(es),(a, l₀ ++ aa, b),ba⟩ → ⟨throw e,(a, l₀ ++ aa, b),ba⟩› 87. ‹⋀es vs e es' C M a aa b ba l₀. es = map Val vs @ throw e # es' ⟹ P ⊢ ⟨C∙⇩sM(es),(a, l₀ ++ aa, b),ba⟩ → ⟨throw e,(a, l₀ ++ aa, b),ba⟩› 88. ‹⋀V T a aa ab b ba l₀. P ⊢ ⟨{V:T; Throw a},(aa, l₀ ++ ab, b),ba⟩ → ⟨Throw a,(aa, l₀ ++ ab, b),ba⟩› 89. ‹⋀V T v a aa ab b ba l₀. P ⊢ ⟨{V:T; V:=Val v;; Throw a},(aa, l₀ ++ ab, b),ba⟩ → ⟨Throw a,(aa, l₀ ++ ab, b),ba⟩› 90. ‹⋀e e₂ a aa b ba l₀. P ⊢ ⟨throw e;; e₂,(a, l₀ ++ aa, b),ba⟩ → ⟨throw e,(a, l₀ ++ aa, b),ba⟩› 91. ‹⋀e e₁ e₂ a aa b ba l₀. P ⊢ ⟨if (throw e) e₁ else e₂,(a, l₀ ++ aa, b),ba⟩ → ⟨throw e,(a, l₀ ++ aa, b),ba⟩› 92. ‹⋀e a aa b ba l₀. P ⊢ ⟨throw (throw e),(a, l₀ ++ aa, b),ba⟩ → ⟨throw e,(a, l₀ ++ aa, b),ba⟩› 93. ‹⋀sh C sfs i sh' a D Cs e h l b l₀. ⟦sh C = ⌊(sfs, i)⌋; sh' = sh(C ↦ (sfs, Error))⟧ ⟹ P ⊢ ⟨RI (C,Throw a) ; D # Cs ← e,(h, l₀ ++ l, sh),b⟩ → ⟨RI (D,Throw a) ; Cs ← e,(h, l₀ ++ l, sh'),b⟩› 94. ‹⋀sh C sfs i sh' a e h l b l₀. ⟦sh C = ⌊(sfs, i)⌋; sh' = sh(C ↦ (sfs, Error))⟧ ⟹ P ⊢ ⟨RI (C,Throw a) ; [] ← e,(h, l₀ ++ l, sh),b⟩ → ⟨Throw a,(h, l₀ ++ l, sh'),b⟩›*) case RedCastFail (*‹h_ a_ = ⌊(D_, fs_)⌋› ‹(D_, C_) ∉ (subcls1 P)⇧*›*) thus "?case" (*goal: ‹P ⊢ ⟨Cast C_ (addr a_),(h_, l₀ ++ l_, sh_),b_⟩ → ⟨THROW ClassCast,(h_, l₀ ++ l_, sh_),b_⟩›*) by (force intro:red_reds.intros (*‹⟦new_Addr ?h = ⌊?a⌋; ?P ⊢ ?C has_fields ?FDTs; ?h' = ?h(?a ↦ blank ?P ?C)⟧ ⟹ ?P ⊢ ⟨new ?C,(?h, ?l, ?sh),True⟩ → ⟨addr ?a,(?h', ?l, ?sh),False⟩› ‹⟦new_Addr ?h = None; is_class ?P ?C⟧ ⟹ ?P ⊢ ⟨new ?C,(?h, ?l, ?sh),True⟩ → ⟨THROW OutOfMemory,(?h, ?l, ?sh),False⟩› ‹?sh ?C = ⌊(?sfs, Done)⌋ ⟹ ?P ⊢ ⟨new ?C,(?h, ?l, ?sh),False⟩ → ⟨new ?C,(?h, ?l, ?sh),True⟩› ‹⟦∄sfs. ?sh ?C = ⌊(sfs, Done)⌋; is_class ?P ?C⟧ ⟹ ?P ⊢ ⟨new ?C,(?h, ?l, ?sh),False⟩ → ⟨INIT ?C ([?C],False) ← new ?C,(?h, ?l, ?sh),False⟩› ‹?P ⊢ ⟨?e,?s,?b⟩ → ⟨?e',?s',?b'⟩ ⟹ ?P ⊢ ⟨Cast ?C ?e,?s,?b⟩ → ⟨Cast ?C ?e',?s',?b'⟩› ‹?P ⊢ ⟨Cast ?C null,?s,?b⟩ → ⟨null,?s,?b⟩› ‹⟦?h ?a = ⌊(?D, ?fs)⌋; ?P ⊢ ?D ≼⇧* ?C⟧ ⟹ ?P ⊢ ⟨Cast ?C (addr ?a),(?h, ?l, ?sh),?b⟩ → ⟨addr ?a,(?h, ?l, ?sh),?b⟩› ‹⟦?h ?a = ⌊(?D, ?fs)⌋; (?D, ?C) ∉ (subcls1 ?P)⇧*⟧ ⟹ ?P ⊢ ⟨Cast ?C (addr ?a),(?h, ?l, ?sh),?b⟩ → ⟨THROW ClassCast,(?h, ?l, ?sh),?b⟩› ‹?P ⊢ ⟨?e,?s,?b⟩ → ⟨?e',?s',?b'⟩ ⟹ ?P ⊢ ⟨?e «?bop» ?e₂,?s,?b⟩ → ⟨?e' «?bop» ?e₂,?s',?b'⟩› ‹?P ⊢ ⟨?e,?s,?b⟩ → ⟨?e',?s',?b'⟩ ⟹ ?P ⊢ ⟨Val ?v₁ «?bop» ?e,?s,?b⟩ → ⟨Val ?v₁ «?bop» ?e',?s',?b'⟩› ‹binop (?bop, ?v₁, ?v₂) = ⌊?v⌋ ⟹ ?P ⊢ ⟨Val ?v₁ «?bop» Val ?v₂,?s,?b⟩ → ⟨Val ?v,?s,?b⟩› ‹?l ?V = ⌊?v⌋ ⟹ ?P ⊢ ⟨Var ?V,(?h, ?l, ?sh),?b⟩ → ⟨Val ?v,(?h, ?l, ?sh),?b⟩› and more 83 facts*)) next (*goals: 1. ‹⋀h a C FDTs h' l sh l₀. ⟦new_Addr h = ⌊a⌋; P ⊢ C has_fields FDTs; h' = h(a ↦ blank P C)⟧ ⟹ P ⊢ ⟨new C,(h, l₀ ++ l, sh),True⟩ → ⟨addr a,(h', l₀ ++ l, sh),False⟩› 2. ‹⋀h C l sh l₀. ⟦new_Addr h = None; is_class P C⟧ ⟹ P ⊢ ⟨new C,(h, l₀ ++ l, sh),True⟩ → ⟨THROW OutOfMemory,(h, l₀ ++ l, sh),False⟩› 3. ‹⋀sh C sfs h l l₀. sh C = ⌊(sfs, Done)⌋ ⟹ P ⊢ ⟨new C,(h, l₀ ++ l, sh),False⟩ → ⟨new C,(h, l₀ ++ l, sh),True⟩› 4. ‹⋀sh C h l l₀. ⟦∄sfs. sh C = ⌊(sfs, Done)⌋; is_class P C⟧ ⟹ P ⊢ ⟨new C,(h, l₀ ++ l, sh),False⟩ → ⟨INIT C ([C],False) ← new C,(h, l₀ ++ l, sh),False⟩› 5. ‹⋀e a aa b ba e' ab ac bb b' C l₀. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⋀l₀. P ⊢ ⟨e,(a, l₀ ++ aa, b),ba⟩ → ⟨e',(ab, l₀ ++ ac, bb),b'⟩⟧ ⟹ P ⊢ ⟨Cast C e,(a, l₀ ++ aa, b),ba⟩ → ⟨Cast C e',(ab, l₀ ++ ac, bb),b'⟩› 6. ‹⋀C a aa b ba l₀. P ⊢ ⟨Cast C null,(a, l₀ ++ aa, b),ba⟩ → ⟨null,(a, l₀ ++ aa, b),ba⟩› 7. ‹⋀e a aa b ba e' ab ac bb b' bop e₂ l₀. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⋀l₀. P ⊢ ⟨e,(a, l₀ ++ aa, b),ba⟩ → ⟨e',(ab, l₀ ++ ac, bb),b'⟩⟧ ⟹ P ⊢ ⟨e «bop» e₂,(a, l₀ ++ aa, b),ba⟩ → ⟨e' «bop» e₂,(ab, l₀ ++ ac, bb),b'⟩› 8. ‹⋀e a aa b ba e' ab ac bb b' v₁ bop l₀. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⋀l₀. P ⊢ ⟨e,(a, l₀ ++ aa, b),ba⟩ → ⟨e',(ab, l₀ ++ ac, bb),b'⟩⟧ ⟹ P ⊢ ⟨Val v₁ «bop» e,(a, l₀ ++ aa, b),ba⟩ → ⟨Val v₁ «bop» e',(ab, l₀ ++ ac, bb),b'⟩› 9. ‹⋀bop v₁ v₂ v a aa b ba l₀. binop (bop, v₁, v₂) = ⌊v⌋ ⟹ P ⊢ ⟨Val v₁ «bop» Val v₂,(a, l₀ ++ aa, b),ba⟩ → ⟨Val v,(a, l₀ ++ aa, b),ba⟩› 10. ‹⋀l V v h sh b l₀. l V = ⌊v⌋ ⟹ P ⊢ ⟨Var V,(h, l₀ ++ l, sh),b⟩ → ⟨Val v,(h, l₀ ++ l, sh),b⟩› 11. ‹⋀e a aa b ba e' ab ac bb b' V l₀. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⋀l₀. P ⊢ ⟨e,(a, l₀ ++ aa, b),ba⟩ → ⟨e',(ab, l₀ ++ ac, bb),b'⟩⟧ ⟹ P ⊢ ⟨V:=e,(a, l₀ ++ aa, b),ba⟩ → ⟨V:=e',(ab, l₀ ++ ac, bb),b'⟩› 12. ‹⋀V v h l sh b l₀. P ⊢ ⟨V:=Val v,(h, l₀ ++ l, sh),b⟩ → ⟨unit,(h, l₀ ++ l(V ↦ v), sh),b⟩› 13. ‹⋀e a aa b ba e' ab ac bb b' F D l₀. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⋀l₀. P ⊢ ⟨e,(a, l₀ ++ aa, b),ba⟩ → ⟨e',(ab, l₀ ++ ac, bb),b'⟩⟧ ⟹ P ⊢ ⟨e∙F{D},(a, l₀ ++ aa, b),ba⟩ → ⟨e'∙F{D},(ab, l₀ ++ ac, bb),b'⟩› 14. ‹⋀h a C fs F D v t l sh b l₀. ⟦h a = ⌊(C, fs)⌋; fs (F, D) = ⌊v⌋; P ⊢ C has F,NonStatic:t in D⟧ ⟹ P ⊢ ⟨addr a∙F{D},(h, l₀ ++ l, sh),b⟩ → ⟨Val v,(h, l₀ ++ l, sh),b⟩› 15. ‹⋀F D a aa b ba l₀. P ⊢ ⟨null∙F{D},(a, l₀ ++ aa, b),ba⟩ → ⟨THROW NullPointer,(a, l₀ ++ aa, b),ba⟩› 16. ‹⋀h a C fs F D l sh b l₀. ⟦h a = ⌊(C, fs)⌋; ∄b t. P ⊢ C has F,b:t in D⟧ ⟹ P ⊢ ⟨addr a∙F{D},(h, l₀ ++ l, sh),b⟩ → ⟨THROW NoSuchFieldError,(h, l₀ ++ l, sh),b⟩› 17. ‹⋀h a C fs F t D l sh b l₀. ⟦h a = ⌊(C, fs)⌋; P ⊢ C has F,Static:t in D⟧ ⟹ P ⊢ ⟨addr a∙F{D},(h, l₀ ++ l, sh),b⟩ → ⟨THROW IncompatibleClassChangeError,(h, l₀ ++ l, sh),b⟩› 18. ‹⋀C F t D sh sfs i v h l l₀. ⟦P ⊢ C has F,Static:t in D; sh D = ⌊(sfs, i)⌋; sfs F = ⌊v⌋⟧ ⟹ P ⊢ ⟨C∙⇩sF{D},(h, l₀ ++ l, sh),True⟩ → ⟨Val v,(h, l₀ ++ l, sh),False⟩› 19. ‹⋀C F t D sh sfs h l l₀. ⟦P ⊢ C has F,Static:t in D; sh D = ⌊(sfs, Done)⌋⟧ ⟹ P ⊢ ⟨C∙⇩sF{D},(h, l₀ ++ l, sh),False⟩ → ⟨C∙⇩sF{D},(h, l₀ ++ l, sh),True⟩› 20. ‹⋀C F t D sh h l l₀. ⟦P ⊢ C has F,Static:t in D; ∄sfs. sh D = ⌊(sfs, Done)⌋⟧ ⟹ P ⊢ ⟨C∙⇩sF{D},(h, l₀ ++ l, sh),False⟩ → ⟨INIT D ([D],False) ← C∙⇩sF{D},(h, l₀ ++ l, sh),False⟩› 21. ‹⋀C F D h l sh b l₀. ∄b t. P ⊢ C has F,b:t in D ⟹ P ⊢ ⟨C∙⇩sF{D},(h, l₀ ++ l, sh),b⟩ → ⟨THROW NoSuchFieldError,(h, l₀ ++ l, sh),False⟩› 22. ‹⋀C F t D h l sh b l₀. P ⊢ C has F,NonStatic:t in D ⟹ P ⊢ ⟨C∙⇩sF{D},(h, l₀ ++ l, sh),b⟩ → ⟨THROW IncompatibleClassChangeError,(h, l₀ ++ l, sh),False⟩› 23. ‹⋀e a aa b ba e' ab ac bb b' F D e₂ l₀. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⋀l₀. P ⊢ ⟨e,(a, l₀ ++ aa, b),ba⟩ → ⟨e',(ab, l₀ ++ ac, bb),b'⟩⟧ ⟹ P ⊢ ⟨e∙F{D} := e₂,(a, l₀ ++ aa, b),ba⟩ → ⟨e'∙F{D} := e₂,(ab, l₀ ++ ac, bb),b'⟩› 24. ‹⋀e a aa b ba e' ab ac bb b' v F D l₀. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⋀l₀. P ⊢ ⟨e,(a, l₀ ++ aa, b),ba⟩ → ⟨e',(ab, l₀ ++ ac, bb),b'⟩⟧ ⟹ P ⊢ ⟨Val v∙F{D} := e,(a, l₀ ++ aa, b),ba⟩ → ⟨Val v∙F{D} := e',(ab, l₀ ++ ac, bb),b'⟩› 25. ‹⋀C F t D h a fs v l sh b l₀. ⟦P ⊢ C has F,NonStatic:t in D; h a = ⌊(C, fs)⌋⟧ ⟹ P ⊢ ⟨addr a∙F{D} := Val v,(h, l₀ ++ l, sh),b⟩ → ⟨unit,(h(a ↦ (C, fs((F, D) ↦ v))), l₀ ++ l, sh),b⟩› 26. ‹⋀F D v a aa b ba l₀. P ⊢ ⟨null∙F{D} := Val v,(a, l₀ ++ aa, b),ba⟩ → ⟨THROW NullPointer,(a, l₀ ++ aa, b),ba⟩› 27. ‹⋀h a C fs F D v l sh b l₀. ⟦h a = ⌊(C, fs)⌋; ∄b t. P ⊢ C has F,b:t in D⟧ ⟹ P ⊢ ⟨addr a∙F{D} := Val v,(h, l₀ ++ l, sh),b⟩ → ⟨THROW NoSuchFieldError,(h, l₀ ++ l, sh),b⟩› 28. ‹⋀h a C fs F t D v l sh b l₀. ⟦h a = ⌊(C, fs)⌋; P ⊢ C has F,Static:t in D⟧ ⟹ P ⊢ ⟨addr a∙F{D} := Val v,(h, l₀ ++ l, sh),b⟩ → ⟨THROW IncompatibleClassChangeError,(h, l₀ ++ l, sh),b⟩› 29. ‹⋀e a aa b ba e' ab ac bb b' C F D l₀. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⋀l₀. P ⊢ ⟨e,(a, l₀ ++ aa, b),ba⟩ → ⟨e',(ab, l₀ ++ ac, bb),b'⟩⟧ ⟹ P ⊢ ⟨C∙⇩sF{D} := e,(a, l₀ ++ aa, b),ba⟩ → ⟨C∙⇩sF{D} := e',(ab, l₀ ++ ac, bb),b'⟩› 30. ‹⋀C F t D sh sfs i sfs' v sh' h l l₀. ⟦P ⊢ C has F,Static:t in D; sh D = ⌊(sfs, i)⌋; sfs' = sfs(F ↦ v); sh' = sh(D ↦ (sfs', i))⟧ ⟹ P ⊢ ⟨C∙⇩sF{D} := Val v,(h, l₀ ++ l, sh),True⟩ → ⟨unit,(h, l₀ ++ l, sh'),False⟩› 31. ‹⋀C F t D sh sfs v h l l₀. ⟦P ⊢ C has F,Static:t in D; sh D = ⌊(sfs, Done)⌋⟧ ⟹ P ⊢ ⟨C∙⇩sF{D} := Val v,(h, l₀ ++ l, sh),False⟩ → ⟨C∙⇩sF{D} := Val v,(h, l₀ ++ l, sh),True⟩› 32. ‹⋀C F t D sh v h l l₀. ⟦P ⊢ C has F,Static:t in D; ∄sfs. sh D = ⌊(sfs, Done)⌋⟧ ⟹ P ⊢ ⟨C∙⇩sF{D} := Val v,(h, l₀ ++ l, sh),False⟩ → ⟨INIT D ([D],False) ← C∙⇩sF{D} := Val v,(h, l₀ ++ l, sh),False⟩› 33. ‹⋀C F D v a aa b ba l₀. ∄b t. P ⊢ C has F,b:t in D ⟹ P ⊢ ⟨C∙⇩sF{D} := Val v,(a, l₀ ++ aa, b),ba⟩ → ⟨THROW NoSuchFieldError,(a, l₀ ++ aa, b),False⟩› 34. ‹⋀C F t D v a aa b ba l₀. P ⊢ C has F,NonStatic:t in D ⟹ P ⊢ ⟨C∙⇩sF{D} := Val v,(a, l₀ ++ aa, b),ba⟩ → ⟨THROW IncompatibleClassChangeError,(a, l₀ ++ aa, b),False⟩› 35. ‹⋀e a aa b ba e' ab ac bb b' M es l₀. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⋀l₀. P ⊢ ⟨e,(a, l₀ ++ aa, b),ba⟩ → ⟨e',(ab, l₀ ++ ac, bb),b'⟩⟧ ⟹ P ⊢ ⟨e∙M(es),(a, l₀ ++ aa, b),ba⟩ → ⟨e'∙M(es),(ab, l₀ ++ ac, bb),b'⟩› 36. ‹⋀es a aa b ba es' ab ac bb b' v M l₀. ⟦P ⊢ ⟨es,(a, aa, b),ba⟩ [→] ⟨es',(ab, ac, bb),b'⟩; ⋀l₀. P ⊢ ⟨es,(a, l₀ ++ aa, b),ba⟩ [→] ⟨es',(ab, l₀ ++ ac, bb),b'⟩⟧ ⟹ P ⊢ ⟨Val v∙M(es),(a, l₀ ++ aa, b),ba⟩ → ⟨Val v∙M(es'),(ab, l₀ ++ ac, bb),b'⟩› 37. ‹⋀h a C fs M Ts T pns body D vs l sh b l₀. ⟦h a = ⌊(C, fs)⌋; P ⊢ C sees M, NonStatic : Ts→T = (pns, body) in D; length vs = length pns; length Ts = length pns⟧ ⟹ P ⊢ ⟨addr a∙M(map Val vs),(h, l₀ ++ l, sh),b⟩ → ⟨blocks (this # pns, Class D # Ts, Addr a # vs, body),(h, l₀ ++ l, sh),b⟩› 38. ‹⋀M vs a aa b ba l₀. P ⊢ ⟨null∙M(map Val vs),(a, l₀ ++ aa, b),ba⟩ → ⟨THROW NullPointer,(a, l₀ ++ aa, b),ba⟩› 39. ‹⋀h a C fs M vs l sh b l₀. ⟦h a = ⌊(C, fs)⌋; ∄b Ts T m D. P ⊢ C sees M, b : Ts→T = m in D⟧ ⟹ P ⊢ ⟨addr a∙M(map Val vs),(h, l₀ ++ l, sh),b⟩ → ⟨THROW NoSuchMethodError,(h, l₀ ++ l, sh),b⟩› 40. ‹⋀h a C fs M Ts T aa b D vs l sh ba l₀. ⟦h a = ⌊(C, fs)⌋; P ⊢ C sees M, Static : Ts→T = (aa, b) in D⟧ ⟹ P ⊢ ⟨addr a∙M(map Val vs),(h, l₀ ++ l, sh),ba⟩ → ⟨THROW IncompatibleClassChangeError,(h, l₀ ++ l, sh),ba⟩› 41. ‹⋀es a aa b ba es' ab ac bb b' C M l₀. ⟦P ⊢ ⟨es,(a, aa, b),ba⟩ [→] ⟨es',(ab, ac, bb),b'⟩; ⋀l₀. P ⊢ ⟨es,(a, l₀ ++ aa, b),ba⟩ [→] ⟨es',(ab, l₀ ++ ac, bb),b'⟩⟧ ⟹ P ⊢ ⟨C∙⇩sM(es),(a, l₀ ++ aa, b),ba⟩ → ⟨C∙⇩sM(es'),(ab, l₀ ++ ac, bb),b'⟩› 42. ‹⋀C M Ts T pns body D vs a aa b l₀. ⟦P ⊢ C sees M, Static : Ts→T = (pns, body) in D; length vs = length pns; length Ts = length pns⟧ ⟹ P ⊢ ⟨C∙⇩sM(map Val vs),(a, l₀ ++ aa, b),True⟩ → ⟨blocks (pns, Ts, vs, body),(a, l₀ ++ aa, b),False⟩› 43. ‹⋀C M Ts T pns body D sh sfs vs h l l₀. ⟦P ⊢ C sees M, Static : Ts→T = (pns, body) in D; sh D = ⌊(sfs, Done)⌋ ∨ M = clinit ∧ sh D = ⌊(sfs, Processing)⌋⟧ ⟹ P ⊢ ⟨C∙⇩sM(map Val vs),(h, l₀ ++ l, sh),False⟩ → ⟨C∙⇩sM(map Val vs),(h, l₀ ++ l, sh),True⟩› 44. ‹⋀C M Ts T pns body D sh vs h l l₀. ⟦P ⊢ C sees M, Static : Ts→T = (pns, body) in D; ∄sfs. sh D = ⌊(sfs, Done)⌋; M ≠ clinit⟧ ⟹ P ⊢ ⟨C∙⇩sM(map Val vs),(h, l₀ ++ l, sh),False⟩ → ⟨INIT D ([D],False) ← C∙⇩sM(map Val vs),(h, l₀ ++ l, sh),False⟩› 45. ‹⋀C M vs a aa b ba l₀. ∄b Ts T m. Ex (Method P C M b Ts T m) ⟹ P ⊢ ⟨C∙⇩sM(map Val vs),(a, l₀ ++ aa, b),ba⟩ → ⟨THROW NoSuchMethodError,(a, l₀ ++ aa, b),False⟩› 46. ‹⋀C M Ts T a b D vs aa ab ba bb l₀. P ⊢ C sees M, NonStatic : Ts→T = (a, b) in D ⟹ P ⊢ ⟨C∙⇩sM(map Val vs),(aa, l₀ ++ ab, ba),bb⟩ → ⟨THROW IncompatibleClassChangeError,(aa, l₀ ++ ab, ba),False⟩› 47. ‹⋀e h l V sh b e' h' l' sh' b' T l₀. ⟦P ⊢ ⟨e,(h, l(V := None), sh),b⟩ → ⟨e',(h', l', sh'),b'⟩; ⋀l₀. P ⊢ ⟨e,(h, l₀ ++ l(V := None), sh),b⟩ → ⟨e',(h', l₀ ++ l', sh'),b'⟩; l' V = None; ¬ assigned V e⟧ ⟹ P ⊢ ⟨{V:T; e},(h, l₀ ++ l, sh),b⟩ → ⟨{V:T; e'},(h', l₀ ++ l'(V := l V), sh'),b'⟩› 48. ‹⋀e h l V sh b e' h' l' sh' b' v T l₀. ⟦P ⊢ ⟨e,(h, l(V := None), sh),b⟩ → ⟨e',(h', l', sh'),b'⟩; ⋀l₀. P ⊢ ⟨e,(h, l₀ ++ l(V := None), sh),b⟩ → ⟨e',(h', l₀ ++ l', sh'),b'⟩; l' V = ⌊v⌋; ¬ assigned V e⟧ ⟹ P ⊢ ⟨{V:T; e},(h, l₀ ++ l, sh),b⟩ → ⟨{V:T; V:=Val v;; e'},(h', l₀ ++ l'(V := l V), sh'),b'⟩› 49. ‹⋀e h l V v sh b e' h' l' sh' b' v' T l₀. ⟦P ⊢ ⟨e,(h, l(V ↦ v), sh),b⟩ → ⟨e',(h', l', sh'),b'⟩; ⋀l₀. P ⊢ ⟨e,(h, l₀ ++ l(V ↦ v), sh),b⟩ → ⟨e',(h', l₀ ++ l', sh'),b'⟩; l' V = ⌊v'⌋⟧ ⟹ P ⊢ ⟨{V:T; V:=Val v;; e},(h, l₀ ++ l, sh),b⟩ → ⟨{V:T; V:=Val v';; e'},(h', l₀ ++ l'(V := l V), sh'),b'⟩› 50. ‹⋀V T u a aa b ba l₀. P ⊢ ⟨{V:T; Val u},(a, l₀ ++ aa, b),ba⟩ → ⟨Val u,(a, l₀ ++ aa, b),ba⟩› 51. ‹⋀V T v u a aa b ba l₀. P ⊢ ⟨{V:T; V:=Val v;; Val u},(a, l₀ ++ aa, b),ba⟩ → ⟨Val u,(a, l₀ ++ aa, b),ba⟩› 52. ‹⋀e a aa b ba e' ab ac bb b' e₂ l₀. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⋀l₀. P ⊢ ⟨e,(a, l₀ ++ aa, b),ba⟩ → ⟨e',(ab, l₀ ++ ac, bb),b'⟩⟧ ⟹ P ⊢ ⟨e;; e₂,(a, l₀ ++ aa, b),ba⟩ → ⟨e';; e₂,(ab, l₀ ++ ac, bb),b'⟩› 53. ‹⋀v e₂ a aa b ba l₀. P ⊢ ⟨Val v;; e₂,(a, l₀ ++ aa, b),ba⟩ → ⟨e₂,(a, l₀ ++ aa, b),ba⟩› 54. ‹⋀e a aa b ba e' ab ac bb b' e₁ e₂ l₀. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⋀l₀. P ⊢ ⟨e,(a, l₀ ++ aa, b),ba⟩ → ⟨e',(ab, l₀ ++ ac, bb),b'⟩⟧ ⟹ P ⊢ ⟨if (e) e₁ else e₂,(a, l₀ ++ aa, b),ba⟩ → ⟨if (e') e₁ else e₂,(ab, l₀ ++ ac, bb),b'⟩› 55. ‹⋀e₁ e₂ a aa b ba l₀. P ⊢ ⟨if (true) e₁ else e₂,(a, l₀ ++ aa, b),ba⟩ → ⟨e₁,(a, l₀ ++ aa, b),ba⟩› 56. ‹⋀e₁ e₂ a aa b ba l₀. P ⊢ ⟨if (false) e₁ else e₂,(a, l₀ ++ aa, b),ba⟩ → ⟨e₂,(a, l₀ ++ aa, b),ba⟩› 57. ‹⋀b c a aa ba b' l₀. P ⊢ ⟨while (b) c,(a, l₀ ++ aa, ba),b'⟩ → ⟨if (b) (c;; while (b) c) else unit,(a, l₀ ++ aa, ba),b'⟩› 58. ‹⋀e a aa b ba e' ab ac bb b' l₀. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⋀l₀. P ⊢ ⟨e,(a, l₀ ++ aa, b),ba⟩ → ⟨e',(ab, l₀ ++ ac, bb),b'⟩⟧ ⟹ P ⊢ ⟨throw e,(a, l₀ ++ aa, b),ba⟩ → ⟨throw e',(ab, l₀ ++ ac, bb),b'⟩› 59. ‹⋀a aa b ba l₀. P ⊢ ⟨throw null,(a, l₀ ++ aa, b),ba⟩ → ⟨THROW NullPointer,(a, l₀ ++ aa, b),ba⟩› 60. ‹⋀e a aa b ba e' ab ac bb b' C V e₂ l₀. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⋀l₀. P ⊢ ⟨e,(a, l₀ ++ aa, b),ba⟩ → ⟨e',(ab, l₀ ++ ac, bb),b'⟩⟧ ⟹ P ⊢ ⟨try e catch(C V) e₂,(a, l₀ ++ aa, b),ba⟩ → ⟨try e' catch(C V) e₂,(ab, l₀ ++ ac, bb),b'⟩› 61. ‹⋀v C V e₂ a aa b ba l₀. P ⊢ ⟨try Val v catch(C V) e₂,(a, l₀ ++ aa, b),ba⟩ → ⟨Val v,(a, l₀ ++ aa, b),ba⟩› 62. ‹⋀a aa b ab D fs C V e₂ ba l₀. ⟦hp (a, aa, b) ab = ⌊(D, fs)⌋; P ⊢ D ≼⇧* C⟧ ⟹ P ⊢ ⟨try Throw ab catch(C V) e₂,(a, l₀ ++ aa, b),ba⟩ → ⟨{V:Class C; V:=addr ab;; e₂},(a, l₀ ++ aa, b),ba⟩› 63. ‹⋀a aa b ab D fs C V e₂ ba l₀. ⟦hp (a, aa, b) ab = ⌊(D, fs)⌋; (D, C) ∉ (subcls1 P)⇧*⟧ ⟹ P ⊢ ⟨try Throw ab catch(C V) e₂,(a, l₀ ++ aa, b),ba⟩ → ⟨Throw ab,(a, l₀ ++ aa, b),ba⟩› 64. ‹⋀e a aa b ba e' ab ac bb b' es l₀. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⋀l₀. P ⊢ ⟨e,(a, l₀ ++ aa, b),ba⟩ → ⟨e',(ab, l₀ ++ ac, bb),b'⟩⟧ ⟹ P ⊢ ⟨e # es,(a, l₀ ++ aa, b),ba⟩ [→] ⟨e' # es,(ab, l₀ ++ ac, bb),b'⟩› 65. ‹⋀es a aa b ba es' ab ac bb b' v l₀. ⟦P ⊢ ⟨es,(a, aa, b),ba⟩ [→] ⟨es',(ab, ac, bb),b'⟩; ⋀l₀. P ⊢ ⟨es,(a, l₀ ++ aa, b),ba⟩ [→] ⟨es',(ab, l₀ ++ ac, bb),b'⟩⟧ ⟹ P ⊢ ⟨Val v # es,(a, l₀ ++ aa, b),ba⟩ [→] ⟨Val v # es',(ab, l₀ ++ ac, bb),b'⟩› 66. ‹⋀e C b a aa ba b' l₀. ¬ sub_RI e ⟹ P ⊢ ⟨INIT C ([],b) ← e,(a, l₀ ++ aa, ba),b'⟩ → ⟨e,(a, l₀ ++ aa, ba),icheck P C e⟩› 67. ‹⋀sh C C' Cs e h l b l₀. sh C = None ⟹ P ⊢ ⟨INIT C' (C # Cs,False) ← e,(h, l₀ ++ l, sh),b⟩ → ⟨INIT C' (C # Cs,False) ← e,(h, l₀ ++ l, sh(C ↦ (sblank P C, Prepared))),b⟩› 68. ‹⋀sh C sfs C' Cs e h l b l₀. sh C = ⌊(sfs, Done)⌋ ⟹ P ⊢ ⟨INIT C' (C # Cs,False) ← e,(h, l₀ ++ l, sh),b⟩ → ⟨INIT C' (Cs,True) ← e,(h, l₀ ++ l, sh),b⟩› 69. ‹⋀sh C sfs C' Cs e h l b l₀. sh C = ⌊(sfs, Processing)⌋ ⟹ P ⊢ ⟨INIT C' (C # Cs,False) ← e,(h, l₀ ++ l, sh),b⟩ → ⟨INIT C' (Cs,True) ← e,(h, l₀ ++ l, sh),b⟩› 70. ‹⋀sh C sfs C' Cs e h l b l₀. sh C = ⌊(sfs, Error)⌋ ⟹ P ⊢ ⟨INIT C' (C # Cs,False) ← e,(h, l₀ ++ l, sh),b⟩ → ⟨RI (C,THROW NoClassDefFoundError) ; Cs ← e,(h, l₀ ++ l, sh),b⟩› 71. ‹⋀sh C sfs sh' C' Cs e h l b l₀. ⟦sh C = ⌊(sfs, Prepared)⌋; C = Object; sh' = sh(C ↦ (sfs, Processing))⟧ ⟹ P ⊢ ⟨INIT C' (C # Cs,False) ← e,(h, l₀ ++ l, sh),b⟩ → ⟨INIT C' (C # Cs,True) ← e,(h, l₀ ++ l, sh'),b⟩› 72. ‹⋀sh C sfs D a b sh' C' Cs e h l ba l₀. ⟦sh C = ⌊(sfs, Prepared)⌋; C ≠ Object; class P C = ⌊(D, a, b)⌋; sh' = sh(C ↦ (sfs, Processing))⟧ ⟹ P ⊢ ⟨INIT C' (C # Cs,False) ← e,(h, l₀ ++ l, sh),ba⟩ → ⟨INIT C' (D # C # Cs,False) ← e,(h, l₀ ++ l, sh'),ba⟩› 73. ‹⋀C' C Cs e h l sh b l₀. P ⊢ ⟨INIT C' (C # Cs,True) ← e,(h, l₀ ++ l, sh),b⟩ → ⟨RI (C,C∙⇩sclinit([])) ; Cs ← e,(h, l₀ ++ l, sh),b⟩› 74. ‹⋀e a aa b ba e' ab ac bb b' C Cs e₀ l₀. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⋀l₀. P ⊢ ⟨e,(a, l₀ ++ aa, b),ba⟩ → ⟨e',(ab, l₀ ++ ac, bb),b'⟩⟧ ⟹ P ⊢ ⟨RI (C,e) ; Cs ← e₀,(a, l₀ ++ aa, b),ba⟩ → ⟨RI (C,e') ; Cs ← e₀,(ab, l₀ ++ ac, bb),b'⟩› 75. ‹⋀sh C sfs i sh' C' Cs v e h l b l₀. ⟦sh C = ⌊(sfs, i)⌋; sh' = sh(C ↦ (sfs, Done)); C' = last (C # Cs)⟧ ⟹ P ⊢ ⟨RI (C,Val v) ; Cs ← e,(h, l₀ ++ l, sh),b⟩ → ⟨INIT C' (Cs,True) ← e,(h, l₀ ++ l, sh'),b⟩› 76. ‹⋀C e a aa b ba l₀. P ⊢ ⟨Cast C (throw e),(a, l₀ ++ aa, b),ba⟩ → ⟨throw e,(a, l₀ ++ aa, b),ba⟩› 77. ‹⋀e bop e₂ a aa b ba l₀. P ⊢ ⟨throw e «bop» e₂,(a, l₀ ++ aa, b),ba⟩ → ⟨throw e,(a, l₀ ++ aa, b),ba⟩› 78. ‹⋀v₁ bop e a aa b ba l₀. P ⊢ ⟨Val v₁ «bop» throw e,(a, l₀ ++ aa, b),ba⟩ → ⟨throw e,(a, l₀ ++ aa, b),ba⟩› 79. ‹⋀V e a aa b ba l₀. P ⊢ ⟨V:=throw e,(a, l₀ ++ aa, b),ba⟩ → ⟨throw e,(a, l₀ ++ aa, b),ba⟩› 80. ‹⋀e F D a aa b ba l₀. P ⊢ ⟨throw e∙F{D},(a, l₀ ++ aa, b),ba⟩ → ⟨throw e,(a, l₀ ++ aa, b),ba⟩› 81. ‹⋀e F D e₂ a aa b ba l₀. P ⊢ ⟨throw e∙F{D} := e₂,(a, l₀ ++ aa, b),ba⟩ → ⟨throw e,(a, l₀ ++ aa, b),ba⟩› 82. ‹⋀v F D e a aa b ba l₀. P ⊢ ⟨Val v∙F{D} := throw e,(a, l₀ ++ aa, b),ba⟩ → ⟨throw e,(a, l₀ ++ aa, b),ba⟩› 83. ‹⋀C F D e a aa b ba l₀. P ⊢ ⟨C∙⇩sF{D} := throw e,(a, l₀ ++ aa, b),ba⟩ → ⟨throw e,(a, l₀ ++ aa, b),ba⟩› 84. ‹⋀e M es a aa b ba l₀. P ⊢ ⟨throw e∙M(es),(a, l₀ ++ aa, b),ba⟩ → ⟨throw e,(a, l₀ ++ aa, b),ba⟩› 85. ‹⋀es vs e es' v M a aa b ba l₀. es = map Val vs @ throw e # es' ⟹ P ⊢ ⟨Val v∙M(es),(a, l₀ ++ aa, b),ba⟩ → ⟨throw e,(a, l₀ ++ aa, b),ba⟩› 86. ‹⋀es vs e es' C M a aa b ba l₀. es = map Val vs @ throw e # es' ⟹ P ⊢ ⟨C∙⇩sM(es),(a, l₀ ++ aa, b),ba⟩ → ⟨throw e,(a, l₀ ++ aa, b),ba⟩› 87. ‹⋀V T a aa ab b ba l₀. P ⊢ ⟨{V:T; Throw a},(aa, l₀ ++ ab, b),ba⟩ → ⟨Throw a,(aa, l₀ ++ ab, b),ba⟩› 88. ‹⋀V T v a aa ab b ba l₀. P ⊢ ⟨{V:T; V:=Val v;; Throw a},(aa, l₀ ++ ab, b),ba⟩ → ⟨Throw a,(aa, l₀ ++ ab, b),ba⟩› 89. ‹⋀e e₂ a aa b ba l₀. P ⊢ ⟨throw e;; e₂,(a, l₀ ++ aa, b),ba⟩ → ⟨throw e,(a, l₀ ++ aa, b),ba⟩› 90. ‹⋀e e₁ e₂ a aa b ba l₀. P ⊢ ⟨if (throw e) e₁ else e₂,(a, l₀ ++ aa, b),ba⟩ → ⟨throw e,(a, l₀ ++ aa, b),ba⟩› 91. ‹⋀e a aa b ba l₀. P ⊢ ⟨throw (throw e),(a, l₀ ++ aa, b),ba⟩ → ⟨throw e,(a, l₀ ++ aa, b),ba⟩› 92. ‹⋀sh C sfs i sh' a D Cs e h l b l₀. ⟦sh C = ⌊(sfs, i)⌋; sh' = sh(C ↦ (sfs, Error))⟧ ⟹ P ⊢ ⟨RI (C,Throw a) ; D # Cs ← e,(h, l₀ ++ l, sh),b⟩ → ⟨RI (D,Throw a) ; Cs ← e,(h, l₀ ++ l, sh'),b⟩› 93. ‹⋀sh C sfs i sh' a e h l b l₀. ⟦sh C = ⌊(sfs, i)⌋; sh' = sh(C ↦ (sfs, Error))⟧ ⟹ P ⊢ ⟨RI (C,Throw a) ; [] ← e,(h, l₀ ++ l, sh),b⟩ → ⟨Throw a,(h, l₀ ++ l, sh'),b⟩›*) case RedFAcc (*‹h_ a_ = ⌊(C_, fs_)⌋› ‹fs_ (F_, D_) = ⌊v_⌋› ‹P ⊢ C_ has F_,NonStatic:t_ in D_›*) thus "?case" (*goal: ‹P ⊢ ⟨addr a_∙F_{D_},(h_, l₀ ++ l_, sh_),b_⟩ → ⟨Val v_,(h_, l₀ ++ l_, sh_),b_⟩›*) by (fastforce intro:red_reds.intros (*‹⟦new_Addr ?h = ⌊?a⌋; ?P ⊢ ?C has_fields ?FDTs; ?h' = ?h(?a ↦ blank ?P ?C)⟧ ⟹ ?P ⊢ ⟨new ?C,(?h, ?l, ?sh),True⟩ → ⟨addr ?a,(?h', ?l, ?sh),False⟩› ‹⟦new_Addr ?h = None; is_class ?P ?C⟧ ⟹ ?P ⊢ ⟨new ?C,(?h, ?l, ?sh),True⟩ → ⟨THROW OutOfMemory,(?h, ?l, ?sh),False⟩› ‹?sh ?C = ⌊(?sfs, Done)⌋ ⟹ ?P ⊢ ⟨new ?C,(?h, ?l, ?sh),False⟩ → ⟨new ?C,(?h, ?l, ?sh),True⟩› ‹⟦∄sfs. ?sh ?C = ⌊(sfs, Done)⌋; is_class ?P ?C⟧ ⟹ ?P ⊢ ⟨new ?C,(?h, ?l, ?sh),False⟩ → ⟨INIT ?C ([?C],False) ← new ?C,(?h, ?l, ?sh),False⟩› ‹?P ⊢ ⟨?e,?s,?b⟩ → ⟨?e',?s',?b'⟩ ⟹ ?P ⊢ ⟨Cast ?C ?e,?s,?b⟩ → ⟨Cast ?C ?e',?s',?b'⟩› ‹?P ⊢ ⟨Cast ?C null,?s,?b⟩ → ⟨null,?s,?b⟩› ‹⟦?h ?a = ⌊(?D, ?fs)⌋; ?P ⊢ ?D ≼⇧* ?C⟧ ⟹ ?P ⊢ ⟨Cast ?C (addr ?a),(?h, ?l, ?sh),?b⟩ → ⟨addr ?a,(?h, ?l, ?sh),?b⟩› ‹⟦?h ?a = ⌊(?D, ?fs)⌋; (?D, ?C) ∉ (subcls1 ?P)⇧*⟧ ⟹ ?P ⊢ ⟨Cast ?C (addr ?a),(?h, ?l, ?sh),?b⟩ → ⟨THROW ClassCast,(?h, ?l, ?sh),?b⟩› ‹?P ⊢ ⟨?e,?s,?b⟩ → ⟨?e',?s',?b'⟩ ⟹ ?P ⊢ ⟨?e «?bop» ?e₂,?s,?b⟩ → ⟨?e' «?bop» ?e₂,?s',?b'⟩› ‹?P ⊢ ⟨?e,?s,?b⟩ → ⟨?e',?s',?b'⟩ ⟹ ?P ⊢ ⟨Val ?v₁ «?bop» ?e,?s,?b⟩ → ⟨Val ?v₁ «?bop» ?e',?s',?b'⟩› ‹binop (?bop, ?v₁, ?v₂) = ⌊?v⌋ ⟹ ?P ⊢ ⟨Val ?v₁ «?bop» Val ?v₂,?s,?b⟩ → ⟨Val ?v,?s,?b⟩› ‹?l ?V = ⌊?v⌋ ⟹ ?P ⊢ ⟨Var ?V,(?h, ?l, ?sh),?b⟩ → ⟨Val ?v,(?h, ?l, ?sh),?b⟩› and more 83 facts*)) next (*goals: 1. ‹⋀h a C FDTs h' l sh l₀. ⟦new_Addr h = ⌊a⌋; P ⊢ C has_fields FDTs; h' = h(a ↦ blank P C)⟧ ⟹ P ⊢ ⟨new C,(h, l₀ ++ l, sh),True⟩ → ⟨addr a,(h', l₀ ++ l, sh),False⟩› 2. ‹⋀h C l sh l₀. ⟦new_Addr h = None; is_class P C⟧ ⟹ P ⊢ ⟨new C,(h, l₀ ++ l, sh),True⟩ → ⟨THROW OutOfMemory,(h, l₀ ++ l, sh),False⟩› 3. ‹⋀sh C sfs h l l₀. sh C = ⌊(sfs, Done)⌋ ⟹ P ⊢ ⟨new C,(h, l₀ ++ l, sh),False⟩ → ⟨new C,(h, l₀ ++ l, sh),True⟩› 4. ‹⋀sh C h l l₀. ⟦∄sfs. sh C = ⌊(sfs, Done)⌋; is_class P C⟧ ⟹ P ⊢ ⟨new C,(h, l₀ ++ l, sh),False⟩ → ⟨INIT C ([C],False) ← new C,(h, l₀ ++ l, sh),False⟩› 5. ‹⋀e a aa b ba e' ab ac bb b' C l₀. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⋀l₀. P ⊢ ⟨e,(a, l₀ ++ aa, b),ba⟩ → ⟨e',(ab, l₀ ++ ac, bb),b'⟩⟧ ⟹ P ⊢ ⟨Cast C e,(a, l₀ ++ aa, b),ba⟩ → ⟨Cast C e',(ab, l₀ ++ ac, bb),b'⟩› 6. ‹⋀C a aa b ba l₀. P ⊢ ⟨Cast C null,(a, l₀ ++ aa, b),ba⟩ → ⟨null,(a, l₀ ++ aa, b),ba⟩› 7. ‹⋀e a aa b ba e' ab ac bb b' bop e₂ l₀. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⋀l₀. P ⊢ ⟨e,(a, l₀ ++ aa, b),ba⟩ → ⟨e',(ab, l₀ ++ ac, bb),b'⟩⟧ ⟹ P ⊢ ⟨e «bop» e₂,(a, l₀ ++ aa, b),ba⟩ → ⟨e' «bop» e₂,(ab, l₀ ++ ac, bb),b'⟩› 8. ‹⋀e a aa b ba e' ab ac bb b' v₁ bop l₀. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⋀l₀. P ⊢ ⟨e,(a, l₀ ++ aa, b),ba⟩ → ⟨e',(ab, l₀ ++ ac, bb),b'⟩⟧ ⟹ P ⊢ ⟨Val v₁ «bop» e,(a, l₀ ++ aa, b),ba⟩ → ⟨Val v₁ «bop» e',(ab, l₀ ++ ac, bb),b'⟩› 9. ‹⋀bop v₁ v₂ v a aa b ba l₀. binop (bop, v₁, v₂) = ⌊v⌋ ⟹ P ⊢ ⟨Val v₁ «bop» Val v₂,(a, l₀ ++ aa, b),ba⟩ → ⟨Val v,(a, l₀ ++ aa, b),ba⟩› 10. ‹⋀l V v h sh b l₀. l V = ⌊v⌋ ⟹ P ⊢ ⟨Var V,(h, l₀ ++ l, sh),b⟩ → ⟨Val v,(h, l₀ ++ l, sh),b⟩› 11. ‹⋀e a aa b ba e' ab ac bb b' V l₀. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⋀l₀. P ⊢ ⟨e,(a, l₀ ++ aa, b),ba⟩ → ⟨e',(ab, l₀ ++ ac, bb),b'⟩⟧ ⟹ P ⊢ ⟨V:=e,(a, l₀ ++ aa, b),ba⟩ → ⟨V:=e',(ab, l₀ ++ ac, bb),b'⟩› 12. ‹⋀V v h l sh b l₀. P ⊢ ⟨V:=Val v,(h, l₀ ++ l, sh),b⟩ → ⟨unit,(h, l₀ ++ l(V ↦ v), sh),b⟩› 13. ‹⋀e a aa b ba e' ab ac bb b' F D l₀. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⋀l₀. P ⊢ ⟨e,(a, l₀ ++ aa, b),ba⟩ → ⟨e',(ab, l₀ ++ ac, bb),b'⟩⟧ ⟹ P ⊢ ⟨e∙F{D},(a, l₀ ++ aa, b),ba⟩ → ⟨e'∙F{D},(ab, l₀ ++ ac, bb),b'⟩› 14. ‹⋀F D a aa b ba l₀. P ⊢ ⟨null∙F{D},(a, l₀ ++ aa, b),ba⟩ → ⟨THROW NullPointer,(a, l₀ ++ aa, b),ba⟩› 15. ‹⋀h a C fs F D l sh b l₀. ⟦h a = ⌊(C, fs)⌋; ∄b t. P ⊢ C has F,b:t in D⟧ ⟹ P ⊢ ⟨addr a∙F{D},(h, l₀ ++ l, sh),b⟩ → ⟨THROW NoSuchFieldError,(h, l₀ ++ l, sh),b⟩› 16. ‹⋀h a C fs F t D l sh b l₀. ⟦h a = ⌊(C, fs)⌋; P ⊢ C has F,Static:t in D⟧ ⟹ P ⊢ ⟨addr a∙F{D},(h, l₀ ++ l, sh),b⟩ → ⟨THROW IncompatibleClassChangeError,(h, l₀ ++ l, sh),b⟩› 17. ‹⋀C F t D sh sfs i v h l l₀. ⟦P ⊢ C has F,Static:t in D; sh D = ⌊(sfs, i)⌋; sfs F = ⌊v⌋⟧ ⟹ P ⊢ ⟨C∙⇩sF{D},(h, l₀ ++ l, sh),True⟩ → ⟨Val v,(h, l₀ ++ l, sh),False⟩› 18. ‹⋀C F t D sh sfs h l l₀. ⟦P ⊢ C has F,Static:t in D; sh D = ⌊(sfs, Done)⌋⟧ ⟹ P ⊢ ⟨C∙⇩sF{D},(h, l₀ ++ l, sh),False⟩ → ⟨C∙⇩sF{D},(h, l₀ ++ l, sh),True⟩› 19. ‹⋀C F t D sh h l l₀. ⟦P ⊢ C has F,Static:t in D; ∄sfs. sh D = ⌊(sfs, Done)⌋⟧ ⟹ P ⊢ ⟨C∙⇩sF{D},(h, l₀ ++ l, sh),False⟩ → ⟨INIT D ([D],False) ← C∙⇩sF{D},(h, l₀ ++ l, sh),False⟩› 20. ‹⋀C F D h l sh b l₀. ∄b t. P ⊢ C has F,b:t in D ⟹ P ⊢ ⟨C∙⇩sF{D},(h, l₀ ++ l, sh),b⟩ → ⟨THROW NoSuchFieldError,(h, l₀ ++ l, sh),False⟩› 21. ‹⋀C F t D h l sh b l₀. P ⊢ C has F,NonStatic:t in D ⟹ P ⊢ ⟨C∙⇩sF{D},(h, l₀ ++ l, sh),b⟩ → ⟨THROW IncompatibleClassChangeError,(h, l₀ ++ l, sh),False⟩› 22. ‹⋀e a aa b ba e' ab ac bb b' F D e₂ l₀. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⋀l₀. P ⊢ ⟨e,(a, l₀ ++ aa, b),ba⟩ → ⟨e',(ab, l₀ ++ ac, bb),b'⟩⟧ ⟹ P ⊢ ⟨e∙F{D} := e₂,(a, l₀ ++ aa, b),ba⟩ → ⟨e'∙F{D} := e₂,(ab, l₀ ++ ac, bb),b'⟩› 23. ‹⋀e a aa b ba e' ab ac bb b' v F D l₀. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⋀l₀. P ⊢ ⟨e,(a, l₀ ++ aa, b),ba⟩ → ⟨e',(ab, l₀ ++ ac, bb),b'⟩⟧ ⟹ P ⊢ ⟨Val v∙F{D} := e,(a, l₀ ++ aa, b),ba⟩ → ⟨Val v∙F{D} := e',(ab, l₀ ++ ac, bb),b'⟩› 24. ‹⋀C F t D h a fs v l sh b l₀. ⟦P ⊢ C has F,NonStatic:t in D; h a = ⌊(C, fs)⌋⟧ ⟹ P ⊢ ⟨addr a∙F{D} := Val v,(h, l₀ ++ l, sh),b⟩ → ⟨unit,(h(a ↦ (C, fs((F, D) ↦ v))), l₀ ++ l, sh),b⟩› 25. ‹⋀F D v a aa b ba l₀. P ⊢ ⟨null∙F{D} := Val v,(a, l₀ ++ aa, b),ba⟩ → ⟨THROW NullPointer,(a, l₀ ++ aa, b),ba⟩› 26. ‹⋀h a C fs F D v l sh b l₀. ⟦h a = ⌊(C, fs)⌋; ∄b t. P ⊢ C has F,b:t in D⟧ ⟹ P ⊢ ⟨addr a∙F{D} := Val v,(h, l₀ ++ l, sh),b⟩ → ⟨THROW NoSuchFieldError,(h, l₀ ++ l, sh),b⟩› 27. ‹⋀h a C fs F t D v l sh b l₀. ⟦h a = ⌊(C, fs)⌋; P ⊢ C has F,Static:t in D⟧ ⟹ P ⊢ ⟨addr a∙F{D} := Val v,(h, l₀ ++ l, sh),b⟩ → ⟨THROW IncompatibleClassChangeError,(h, l₀ ++ l, sh),b⟩› 28. ‹⋀e a aa b ba e' ab ac bb b' C F D l₀. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⋀l₀. P ⊢ ⟨e,(a, l₀ ++ aa, b),ba⟩ → ⟨e',(ab, l₀ ++ ac, bb),b'⟩⟧ ⟹ P ⊢ ⟨C∙⇩sF{D} := e,(a, l₀ ++ aa, b),ba⟩ → ⟨C∙⇩sF{D} := e',(ab, l₀ ++ ac, bb),b'⟩› 29. ‹⋀C F t D sh sfs i sfs' v sh' h l l₀. ⟦P ⊢ C has F,Static:t in D; sh D = ⌊(sfs, i)⌋; sfs' = sfs(F ↦ v); sh' = sh(D ↦ (sfs', i))⟧ ⟹ P ⊢ ⟨C∙⇩sF{D} := Val v,(h, l₀ ++ l, sh),True⟩ → ⟨unit,(h, l₀ ++ l, sh'),False⟩› 30. ‹⋀C F t D sh sfs v h l l₀. ⟦P ⊢ C has F,Static:t in D; sh D = ⌊(sfs, Done)⌋⟧ ⟹ P ⊢ ⟨C∙⇩sF{D} := Val v,(h, l₀ ++ l, sh),False⟩ → ⟨C∙⇩sF{D} := Val v,(h, l₀ ++ l, sh),True⟩› 31. ‹⋀C F t D sh v h l l₀. ⟦P ⊢ C has F,Static:t in D; ∄sfs. sh D = ⌊(sfs, Done)⌋⟧ ⟹ P ⊢ ⟨C∙⇩sF{D} := Val v,(h, l₀ ++ l, sh),False⟩ → ⟨INIT D ([D],False) ← C∙⇩sF{D} := Val v,(h, l₀ ++ l, sh),False⟩› 32. ‹⋀C F D v a aa b ba l₀. ∄b t. P ⊢ C has F,b:t in D ⟹ P ⊢ ⟨C∙⇩sF{D} := Val v,(a, l₀ ++ aa, b),ba⟩ → ⟨THROW NoSuchFieldError,(a, l₀ ++ aa, b),False⟩› 33. ‹⋀C F t D v a aa b ba l₀. P ⊢ C has F,NonStatic:t in D ⟹ P ⊢ ⟨C∙⇩sF{D} := Val v,(a, l₀ ++ aa, b),ba⟩ → ⟨THROW IncompatibleClassChangeError,(a, l₀ ++ aa, b),False⟩› 34. ‹⋀e a aa b ba e' ab ac bb b' M es l₀. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⋀l₀. P ⊢ ⟨e,(a, l₀ ++ aa, b),ba⟩ → ⟨e',(ab, l₀ ++ ac, bb),b'⟩⟧ ⟹ P ⊢ ⟨e∙M(es),(a, l₀ ++ aa, b),ba⟩ → ⟨e'∙M(es),(ab, l₀ ++ ac, bb),b'⟩› 35. ‹⋀es a aa b ba es' ab ac bb b' v M l₀. ⟦P ⊢ ⟨es,(a, aa, b),ba⟩ [→] ⟨es',(ab, ac, bb),b'⟩; ⋀l₀. P ⊢ ⟨es,(a, l₀ ++ aa, b),ba⟩ [→] ⟨es',(ab, l₀ ++ ac, bb),b'⟩⟧ ⟹ P ⊢ ⟨Val v∙M(es),(a, l₀ ++ aa, b),ba⟩ → ⟨Val v∙M(es'),(ab, l₀ ++ ac, bb),b'⟩› 36. ‹⋀h a C fs M Ts T pns body D vs l sh b l₀. ⟦h a = ⌊(C, fs)⌋; P ⊢ C sees M, NonStatic : Ts→T = (pns, body) in D; length vs = length pns; length Ts = length pns⟧ ⟹ P ⊢ ⟨addr a∙M(map Val vs),(h, l₀ ++ l, sh),b⟩ → ⟨blocks (this # pns, Class D # Ts, Addr a # vs, body),(h, l₀ ++ l, sh),b⟩› 37. ‹⋀M vs a aa b ba l₀. P ⊢ ⟨null∙M(map Val vs),(a, l₀ ++ aa, b),ba⟩ → ⟨THROW NullPointer,(a, l₀ ++ aa, b),ba⟩› 38. ‹⋀h a C fs M vs l sh b l₀. ⟦h a = ⌊(C, fs)⌋; ∄b Ts T m D. P ⊢ C sees M, b : Ts→T = m in D⟧ ⟹ P ⊢ ⟨addr a∙M(map Val vs),(h, l₀ ++ l, sh),b⟩ → ⟨THROW NoSuchMethodError,(h, l₀ ++ l, sh),b⟩› 39. ‹⋀h a C fs M Ts T aa b D vs l sh ba l₀. ⟦h a = ⌊(C, fs)⌋; P ⊢ C sees M, Static : Ts→T = (aa, b) in D⟧ ⟹ P ⊢ ⟨addr a∙M(map Val vs),(h, l₀ ++ l, sh),ba⟩ → ⟨THROW IncompatibleClassChangeError,(h, l₀ ++ l, sh),ba⟩› 40. ‹⋀es a aa b ba es' ab ac bb b' C M l₀. ⟦P ⊢ ⟨es,(a, aa, b),ba⟩ [→] ⟨es',(ab, ac, bb),b'⟩; ⋀l₀. P ⊢ ⟨es,(a, l₀ ++ aa, b),ba⟩ [→] ⟨es',(ab, l₀ ++ ac, bb),b'⟩⟧ ⟹ P ⊢ ⟨C∙⇩sM(es),(a, l₀ ++ aa, b),ba⟩ → ⟨C∙⇩sM(es'),(ab, l₀ ++ ac, bb),b'⟩› 41. ‹⋀C M Ts T pns body D vs a aa b l₀. ⟦P ⊢ C sees M, Static : Ts→T = (pns, body) in D; length vs = length pns; length Ts = length pns⟧ ⟹ P ⊢ ⟨C∙⇩sM(map Val vs),(a, l₀ ++ aa, b),True⟩ → ⟨blocks (pns, Ts, vs, body),(a, l₀ ++ aa, b),False⟩› 42. ‹⋀C M Ts T pns body D sh sfs vs h l l₀. ⟦P ⊢ C sees M, Static : Ts→T = (pns, body) in D; sh D = ⌊(sfs, Done)⌋ ∨ M = clinit ∧ sh D = ⌊(sfs, Processing)⌋⟧ ⟹ P ⊢ ⟨C∙⇩sM(map Val vs),(h, l₀ ++ l, sh),False⟩ → ⟨C∙⇩sM(map Val vs),(h, l₀ ++ l, sh),True⟩› 43. ‹⋀C M Ts T pns body D sh vs h l l₀. ⟦P ⊢ C sees M, Static : Ts→T = (pns, body) in D; ∄sfs. sh D = ⌊(sfs, Done)⌋; M ≠ clinit⟧ ⟹ P ⊢ ⟨C∙⇩sM(map Val vs),(h, l₀ ++ l, sh),False⟩ → ⟨INIT D ([D],False) ← C∙⇩sM(map Val vs),(h, l₀ ++ l, sh),False⟩› 44. ‹⋀C M vs a aa b ba l₀. ∄b Ts T m. Ex (Method P C M b Ts T m) ⟹ P ⊢ ⟨C∙⇩sM(map Val vs),(a, l₀ ++ aa, b),ba⟩ → ⟨THROW NoSuchMethodError,(a, l₀ ++ aa, b),False⟩› 45. ‹⋀C M Ts T a b D vs aa ab ba bb l₀. P ⊢ C sees M, NonStatic : Ts→T = (a, b) in D ⟹ P ⊢ ⟨C∙⇩sM(map Val vs),(aa, l₀ ++ ab, ba),bb⟩ → ⟨THROW IncompatibleClassChangeError,(aa, l₀ ++ ab, ba),False⟩› 46. ‹⋀e h l V sh b e' h' l' sh' b' T l₀. ⟦P ⊢ ⟨e,(h, l(V := None), sh),b⟩ → ⟨e',(h', l', sh'),b'⟩; ⋀l₀. P ⊢ ⟨e,(h, l₀ ++ l(V := None), sh),b⟩ → ⟨e',(h', l₀ ++ l', sh'),b'⟩; l' V = None; ¬ assigned V e⟧ ⟹ P ⊢ ⟨{V:T; e},(h, l₀ ++ l, sh),b⟩ → ⟨{V:T; e'},(h', l₀ ++ l'(V := l V), sh'),b'⟩› 47. ‹⋀e h l V sh b e' h' l' sh' b' v T l₀. ⟦P ⊢ ⟨e,(h, l(V := None), sh),b⟩ → ⟨e',(h', l', sh'),b'⟩; ⋀l₀. P ⊢ ⟨e,(h, l₀ ++ l(V := None), sh),b⟩ → ⟨e',(h', l₀ ++ l', sh'),b'⟩; l' V = ⌊v⌋; ¬ assigned V e⟧ ⟹ P ⊢ ⟨{V:T; e},(h, l₀ ++ l, sh),b⟩ → ⟨{V:T; V:=Val v;; e'},(h', l₀ ++ l'(V := l V), sh'),b'⟩› 48. ‹⋀e h l V v sh b e' h' l' sh' b' v' T l₀. ⟦P ⊢ ⟨e,(h, l(V ↦ v), sh),b⟩ → ⟨e',(h', l', sh'),b'⟩; ⋀l₀. P ⊢ ⟨e,(h, l₀ ++ l(V ↦ v), sh),b⟩ → ⟨e',(h', l₀ ++ l', sh'),b'⟩; l' V = ⌊v'⌋⟧ ⟹ P ⊢ ⟨{V:T; V:=Val v;; e},(h, l₀ ++ l, sh),b⟩ → ⟨{V:T; V:=Val v';; e'},(h', l₀ ++ l'(V := l V), sh'),b'⟩› 49. ‹⋀V T u a aa b ba l₀. P ⊢ ⟨{V:T; Val u},(a, l₀ ++ aa, b),ba⟩ → ⟨Val u,(a, l₀ ++ aa, b),ba⟩› 50. ‹⋀V T v u a aa b ba l₀. P ⊢ ⟨{V:T; V:=Val v;; Val u},(a, l₀ ++ aa, b),ba⟩ → ⟨Val u,(a, l₀ ++ aa, b),ba⟩› 51. ‹⋀e a aa b ba e' ab ac bb b' e₂ l₀. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⋀l₀. P ⊢ ⟨e,(a, l₀ ++ aa, b),ba⟩ → ⟨e',(ab, l₀ ++ ac, bb),b'⟩⟧ ⟹ P ⊢ ⟨e;; e₂,(a, l₀ ++ aa, b),ba⟩ → ⟨e';; e₂,(ab, l₀ ++ ac, bb),b'⟩› 52. ‹⋀v e₂ a aa b ba l₀. P ⊢ ⟨Val v;; e₂,(a, l₀ ++ aa, b),ba⟩ → ⟨e₂,(a, l₀ ++ aa, b),ba⟩› 53. ‹⋀e a aa b ba e' ab ac bb b' e₁ e₂ l₀. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⋀l₀. P ⊢ ⟨e,(a, l₀ ++ aa, b),ba⟩ → ⟨e',(ab, l₀ ++ ac, bb),b'⟩⟧ ⟹ P ⊢ ⟨if (e) e₁ else e₂,(a, l₀ ++ aa, b),ba⟩ → ⟨if (e') e₁ else e₂,(ab, l₀ ++ ac, bb),b'⟩› 54. ‹⋀e₁ e₂ a aa b ba l₀. P ⊢ ⟨if (true) e₁ else e₂,(a, l₀ ++ aa, b),ba⟩ → ⟨e₁,(a, l₀ ++ aa, b),ba⟩› 55. ‹⋀e₁ e₂ a aa b ba l₀. P ⊢ ⟨if (false) e₁ else e₂,(a, l₀ ++ aa, b),ba⟩ → ⟨e₂,(a, l₀ ++ aa, b),ba⟩› 56. ‹⋀b c a aa ba b' l₀. P ⊢ ⟨while (b) c,(a, l₀ ++ aa, ba),b'⟩ → ⟨if (b) (c;; while (b) c) else unit,(a, l₀ ++ aa, ba),b'⟩› 57. ‹⋀e a aa b ba e' ab ac bb b' l₀. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⋀l₀. P ⊢ ⟨e,(a, l₀ ++ aa, b),ba⟩ → ⟨e',(ab, l₀ ++ ac, bb),b'⟩⟧ ⟹ P ⊢ ⟨throw e,(a, l₀ ++ aa, b),ba⟩ → ⟨throw e',(ab, l₀ ++ ac, bb),b'⟩› 58. ‹⋀a aa b ba l₀. P ⊢ ⟨throw null,(a, l₀ ++ aa, b),ba⟩ → ⟨THROW NullPointer,(a, l₀ ++ aa, b),ba⟩› 59. ‹⋀e a aa b ba e' ab ac bb b' C V e₂ l₀. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⋀l₀. P ⊢ ⟨e,(a, l₀ ++ aa, b),ba⟩ → ⟨e',(ab, l₀ ++ ac, bb),b'⟩⟧ ⟹ P ⊢ ⟨try e catch(C V) e₂,(a, l₀ ++ aa, b),ba⟩ → ⟨try e' catch(C V) e₂,(ab, l₀ ++ ac, bb),b'⟩› 60. ‹⋀v C V e₂ a aa b ba l₀. P ⊢ ⟨try Val v catch(C V) e₂,(a, l₀ ++ aa, b),ba⟩ → ⟨Val v,(a, l₀ ++ aa, b),ba⟩› 61. ‹⋀a aa b ab D fs C V e₂ ba l₀. ⟦hp (a, aa, b) ab = ⌊(D, fs)⌋; P ⊢ D ≼⇧* C⟧ ⟹ P ⊢ ⟨try Throw ab catch(C V) e₂,(a, l₀ ++ aa, b),ba⟩ → ⟨{V:Class C; V:=addr ab;; e₂},(a, l₀ ++ aa, b),ba⟩› 62. ‹⋀a aa b ab D fs C V e₂ ba l₀. ⟦hp (a, aa, b) ab = ⌊(D, fs)⌋; (D, C) ∉ (subcls1 P)⇧*⟧ ⟹ P ⊢ ⟨try Throw ab catch(C V) e₂,(a, l₀ ++ aa, b),ba⟩ → ⟨Throw ab,(a, l₀ ++ aa, b),ba⟩› 63. ‹⋀e a aa b ba e' ab ac bb b' es l₀. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⋀l₀. P ⊢ ⟨e,(a, l₀ ++ aa, b),ba⟩ → ⟨e',(ab, l₀ ++ ac, bb),b'⟩⟧ ⟹ P ⊢ ⟨e # es,(a, l₀ ++ aa, b),ba⟩ [→] ⟨e' # es,(ab, l₀ ++ ac, bb),b'⟩› 64. ‹⋀es a aa b ba es' ab ac bb b' v l₀. ⟦P ⊢ ⟨es,(a, aa, b),ba⟩ [→] ⟨es',(ab, ac, bb),b'⟩; ⋀l₀. P ⊢ ⟨es,(a, l₀ ++ aa, b),ba⟩ [→] ⟨es',(ab, l₀ ++ ac, bb),b'⟩⟧ ⟹ P ⊢ ⟨Val v # es,(a, l₀ ++ aa, b),ba⟩ [→] ⟨Val v # es',(ab, l₀ ++ ac, bb),b'⟩› 65. ‹⋀e C b a aa ba b' l₀. ¬ sub_RI e ⟹ P ⊢ ⟨INIT C ([],b) ← e,(a, l₀ ++ aa, ba),b'⟩ → ⟨e,(a, l₀ ++ aa, ba),icheck P C e⟩› 66. ‹⋀sh C C' Cs e h l b l₀. sh C = None ⟹ P ⊢ ⟨INIT C' (C # Cs,False) ← e,(h, l₀ ++ l, sh),b⟩ → ⟨INIT C' (C # Cs,False) ← e,(h, l₀ ++ l, sh(C ↦ (sblank P C, Prepared))),b⟩› 67. ‹⋀sh C sfs C' Cs e h l b l₀. sh C = ⌊(sfs, Done)⌋ ⟹ P ⊢ ⟨INIT C' (C # Cs,False) ← e,(h, l₀ ++ l, sh),b⟩ → ⟨INIT C' (Cs,True) ← e,(h, l₀ ++ l, sh),b⟩› 68. ‹⋀sh C sfs C' Cs e h l b l₀. sh C = ⌊(sfs, Processing)⌋ ⟹ P ⊢ ⟨INIT C' (C # Cs,False) ← e,(h, l₀ ++ l, sh),b⟩ → ⟨INIT C' (Cs,True) ← e,(h, l₀ ++ l, sh),b⟩› 69. ‹⋀sh C sfs C' Cs e h l b l₀. sh C = ⌊(sfs, Error)⌋ ⟹ P ⊢ ⟨INIT C' (C # Cs,False) ← e,(h, l₀ ++ l, sh),b⟩ → ⟨RI (C,THROW NoClassDefFoundError) ; Cs ← e,(h, l₀ ++ l, sh),b⟩› 70. ‹⋀sh C sfs sh' C' Cs e h l b l₀. ⟦sh C = ⌊(sfs, Prepared)⌋; C = Object; sh' = sh(C ↦ (sfs, Processing))⟧ ⟹ P ⊢ ⟨INIT C' (C # Cs,False) ← e,(h, l₀ ++ l, sh),b⟩ → ⟨INIT C' (C # Cs,True) ← e,(h, l₀ ++ l, sh'),b⟩› 71. ‹⋀sh C sfs D a b sh' C' Cs e h l ba l₀. ⟦sh C = ⌊(sfs, Prepared)⌋; C ≠ Object; class P C = ⌊(D, a, b)⌋; sh' = sh(C ↦ (sfs, Processing))⟧ ⟹ P ⊢ ⟨INIT C' (C # Cs,False) ← e,(h, l₀ ++ l, sh),ba⟩ → ⟨INIT C' (D # C # Cs,False) ← e,(h, l₀ ++ l, sh'),ba⟩› 72. ‹⋀C' C Cs e h l sh b l₀. P ⊢ ⟨INIT C' (C # Cs,True) ← e,(h, l₀ ++ l, sh),b⟩ → ⟨RI (C,C∙⇩sclinit([])) ; Cs ← e,(h, l₀ ++ l, sh),b⟩› 73. ‹⋀e a aa b ba e' ab ac bb b' C Cs e₀ l₀. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⋀l₀. P ⊢ ⟨e,(a, l₀ ++ aa, b),ba⟩ → ⟨e',(ab, l₀ ++ ac, bb),b'⟩⟧ ⟹ P ⊢ ⟨RI (C,e) ; Cs ← e₀,(a, l₀ ++ aa, b),ba⟩ → ⟨RI (C,e') ; Cs ← e₀,(ab, l₀ ++ ac, bb),b'⟩› 74. ‹⋀sh C sfs i sh' C' Cs v e h l b l₀. ⟦sh C = ⌊(sfs, i)⌋; sh' = sh(C ↦ (sfs, Done)); C' = last (C # Cs)⟧ ⟹ P ⊢ ⟨RI (C,Val v) ; Cs ← e,(h, l₀ ++ l, sh),b⟩ → ⟨INIT C' (Cs,True) ← e,(h, l₀ ++ l, sh'),b⟩› 75. ‹⋀C e a aa b ba l₀. P ⊢ ⟨Cast C (throw e),(a, l₀ ++ aa, b),ba⟩ → ⟨throw e,(a, l₀ ++ aa, b),ba⟩› 76. ‹⋀e bop e₂ a aa b ba l₀. P ⊢ ⟨throw e «bop» e₂,(a, l₀ ++ aa, b),ba⟩ → ⟨throw e,(a, l₀ ++ aa, b),ba⟩› 77. ‹⋀v₁ bop e a aa b ba l₀. P ⊢ ⟨Val v₁ «bop» throw e,(a, l₀ ++ aa, b),ba⟩ → ⟨throw e,(a, l₀ ++ aa, b),ba⟩› 78. ‹⋀V e a aa b ba l₀. P ⊢ ⟨V:=throw e,(a, l₀ ++ aa, b),ba⟩ → ⟨throw e,(a, l₀ ++ aa, b),ba⟩› 79. ‹⋀e F D a aa b ba l₀. P ⊢ ⟨throw e∙F{D},(a, l₀ ++ aa, b),ba⟩ → ⟨throw e,(a, l₀ ++ aa, b),ba⟩› 80. ‹⋀e F D e₂ a aa b ba l₀. P ⊢ ⟨throw e∙F{D} := e₂,(a, l₀ ++ aa, b),ba⟩ → ⟨throw e,(a, l₀ ++ aa, b),ba⟩› 81. ‹⋀v F D e a aa b ba l₀. P ⊢ ⟨Val v∙F{D} := throw e,(a, l₀ ++ aa, b),ba⟩ → ⟨throw e,(a, l₀ ++ aa, b),ba⟩› 82. ‹⋀C F D e a aa b ba l₀. P ⊢ ⟨C∙⇩sF{D} := throw e,(a, l₀ ++ aa, b),ba⟩ → ⟨throw e,(a, l₀ ++ aa, b),ba⟩› 83. ‹⋀e M es a aa b ba l₀. P ⊢ ⟨throw e∙M(es),(a, l₀ ++ aa, b),ba⟩ → ⟨throw e,(a, l₀ ++ aa, b),ba⟩› 84. ‹⋀es vs e es' v M a aa b ba l₀. es = map Val vs @ throw e # es' ⟹ P ⊢ ⟨Val v∙M(es),(a, l₀ ++ aa, b),ba⟩ → ⟨throw e,(a, l₀ ++ aa, b),ba⟩› 85. ‹⋀es vs e es' C M a aa b ba l₀. es = map Val vs @ throw e # es' ⟹ P ⊢ ⟨C∙⇩sM(es),(a, l₀ ++ aa, b),ba⟩ → ⟨throw e,(a, l₀ ++ aa, b),ba⟩› 86. ‹⋀V T a aa ab b ba l₀. P ⊢ ⟨{V:T; Throw a},(aa, l₀ ++ ab, b),ba⟩ → ⟨Throw a,(aa, l₀ ++ ab, b),ba⟩› 87. ‹⋀V T v a aa ab b ba l₀. P ⊢ ⟨{V:T; V:=Val v;; Throw a},(aa, l₀ ++ ab, b),ba⟩ → ⟨Throw a,(aa, l₀ ++ ab, b),ba⟩› 88. ‹⋀e e₂ a aa b ba l₀. P ⊢ ⟨throw e;; e₂,(a, l₀ ++ aa, b),ba⟩ → ⟨throw e,(a, l₀ ++ aa, b),ba⟩› 89. ‹⋀e e₁ e₂ a aa b ba l₀. P ⊢ ⟨if (throw e) e₁ else e₂,(a, l₀ ++ aa, b),ba⟩ → ⟨throw e,(a, l₀ ++ aa, b),ba⟩› 90. ‹⋀e a aa b ba l₀. P ⊢ ⟨throw (throw e),(a, l₀ ++ aa, b),ba⟩ → ⟨throw e,(a, l₀ ++ aa, b),ba⟩› 91. ‹⋀sh C sfs i sh' a D Cs e h l b l₀. ⟦sh C = ⌊(sfs, i)⌋; sh' = sh(C ↦ (sfs, Error))⟧ ⟹ P ⊢ ⟨RI (C,Throw a) ; D # Cs ← e,(h, l₀ ++ l, sh),b⟩ → ⟨RI (D,Throw a) ; Cs ← e,(h, l₀ ++ l, sh'),b⟩› 92. ‹⋀sh C sfs i sh' a e h l b l₀. ⟦sh C = ⌊(sfs, i)⌋; sh' = sh(C ↦ (sfs, Error))⟧ ⟹ P ⊢ ⟨RI (C,Throw a) ; [] ← e,(h, l₀ ++ l, sh),b⟩ → ⟨Throw a,(h, l₀ ++ l, sh'),b⟩›*) case RedCall (*‹(h_::heap) (a_::nat) = ⌊(C_::char list, fs_::Objects.fields)⌋› ‹P ⊢ C_ sees M_, NonStatic : Ts_→T_ = (pns_, body_) in D_› ‹length vs_ = length pns_› ‹length (Ts_::ty list) = length (pns_::char list list)›*) thus "?case" (*goal: ‹P ⊢ ⟨addr a_∙M_(map Val vs_),(h_, l₀ ++ l_, sh_),b_⟩ → ⟨blocks (this # pns_, Class D_ # Ts_, Addr a_ # vs_, body_),(h_, l₀ ++ l_, sh_),b_⟩›*) by (fastforce intro:red_reds.intros (*‹⟦new_Addr ?h = ⌊?a⌋; ?P ⊢ ?C has_fields ?FDTs; ?h' = ?h(?a ↦ blank ?P ?C)⟧ ⟹ ?P ⊢ ⟨new ?C,(?h, ?l, ?sh),True⟩ → ⟨addr ?a,(?h', ?l, ?sh),False⟩› ‹⟦new_Addr ?h = None; is_class ?P ?C⟧ ⟹ ?P ⊢ ⟨new ?C,(?h, ?l, ?sh),True⟩ → ⟨THROW OutOfMemory,(?h, ?l, ?sh),False⟩› ‹?sh ?C = ⌊(?sfs, Done)⌋ ⟹ ?P ⊢ ⟨new ?C,(?h, ?l, ?sh),False⟩ → ⟨new ?C,(?h, ?l, ?sh),True⟩› ‹⟦∄sfs. ?sh ?C = ⌊(sfs, Done)⌋; is_class ?P ?C⟧ ⟹ ?P ⊢ ⟨new ?C,(?h, ?l, ?sh),False⟩ → ⟨INIT ?C ([?C],False) ← new ?C,(?h, ?l, ?sh),False⟩› ‹?P ⊢ ⟨?e,?s,?b⟩ → ⟨?e',?s',?b'⟩ ⟹ ?P ⊢ ⟨Cast ?C ?e,?s,?b⟩ → ⟨Cast ?C ?e',?s',?b'⟩› ‹?P ⊢ ⟨Cast ?C null,?s,?b⟩ → ⟨null,?s,?b⟩› ‹⟦?h ?a = ⌊(?D, ?fs)⌋; ?P ⊢ ?D ≼⇧* ?C⟧ ⟹ ?P ⊢ ⟨Cast ?C (addr ?a),(?h, ?l, ?sh),?b⟩ → ⟨addr ?a,(?h, ?l, ?sh),?b⟩› ‹⟦?h ?a = ⌊(?D, ?fs)⌋; (?D, ?C) ∉ (subcls1 ?P)⇧*⟧ ⟹ ?P ⊢ ⟨Cast ?C (addr ?a),(?h, ?l, ?sh),?b⟩ → ⟨THROW ClassCast,(?h, ?l, ?sh),?b⟩› ‹?P ⊢ ⟨?e,?s,?b⟩ → ⟨?e',?s',?b'⟩ ⟹ ?P ⊢ ⟨?e «?bop» ?e₂,?s,?b⟩ → ⟨?e' «?bop» ?e₂,?s',?b'⟩› ‹?P ⊢ ⟨?e,?s,?b⟩ → ⟨?e',?s',?b'⟩ ⟹ ?P ⊢ ⟨Val ?v₁ «?bop» ?e,?s,?b⟩ → ⟨Val ?v₁ «?bop» ?e',?s',?b'⟩› ‹binop (?bop, ?v₁, ?v₂) = ⌊?v⌋ ⟹ ?P ⊢ ⟨Val ?v₁ «?bop» Val ?v₂,?s,?b⟩ → ⟨Val ?v,?s,?b⟩› ‹?l ?V = ⌊?v⌋ ⟹ ?P ⊢ ⟨Var ?V,(?h, ?l, ?sh),?b⟩ → ⟨Val ?v,(?h, ?l, ?sh),?b⟩› and more 83 facts*)) next (*goals: 1. ‹⋀h a C FDTs h' l sh l₀. ⟦new_Addr h = ⌊a⌋; P ⊢ C has_fields FDTs; h' = h(a ↦ blank P C)⟧ ⟹ P ⊢ ⟨new C,(h, l₀ ++ l, sh),True⟩ → ⟨addr a,(h', l₀ ++ l, sh),False⟩› 2. ‹⋀h C l sh l₀. ⟦new_Addr h = None; is_class P C⟧ ⟹ P ⊢ ⟨new C,(h, l₀ ++ l, sh),True⟩ → ⟨THROW OutOfMemory,(h, l₀ ++ l, sh),False⟩› 3. ‹⋀sh C sfs h l l₀. sh C = ⌊(sfs, Done)⌋ ⟹ P ⊢ ⟨new C,(h, l₀ ++ l, sh),False⟩ → ⟨new C,(h, l₀ ++ l, sh),True⟩› 4. ‹⋀sh C h l l₀. ⟦∄sfs. sh C = ⌊(sfs, Done)⌋; is_class P C⟧ ⟹ P ⊢ ⟨new C,(h, l₀ ++ l, sh),False⟩ → ⟨INIT C ([C],False) ← new C,(h, l₀ ++ l, sh),False⟩› 5. ‹⋀e a aa b ba e' ab ac bb b' C l₀. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⋀l₀. P ⊢ ⟨e,(a, l₀ ++ aa, b),ba⟩ → ⟨e',(ab, l₀ ++ ac, bb),b'⟩⟧ ⟹ P ⊢ ⟨Cast C e,(a, l₀ ++ aa, b),ba⟩ → ⟨Cast C e',(ab, l₀ ++ ac, bb),b'⟩› 6. ‹⋀C a aa b ba l₀. P ⊢ ⟨Cast C null,(a, l₀ ++ aa, b),ba⟩ → ⟨null,(a, l₀ ++ aa, b),ba⟩› 7. ‹⋀e a aa b ba e' ab ac bb b' bop e₂ l₀. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⋀l₀. P ⊢ ⟨e,(a, l₀ ++ aa, b),ba⟩ → ⟨e',(ab, l₀ ++ ac, bb),b'⟩⟧ ⟹ P ⊢ ⟨e «bop» e₂,(a, l₀ ++ aa, b),ba⟩ → ⟨e' «bop» e₂,(ab, l₀ ++ ac, bb),b'⟩› 8. ‹⋀e a aa b ba e' ab ac bb b' v₁ bop l₀. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⋀l₀. P ⊢ ⟨e,(a, l₀ ++ aa, b),ba⟩ → ⟨e',(ab, l₀ ++ ac, bb),b'⟩⟧ ⟹ P ⊢ ⟨Val v₁ «bop» e,(a, l₀ ++ aa, b),ba⟩ → ⟨Val v₁ «bop» e',(ab, l₀ ++ ac, bb),b'⟩› 9. ‹⋀bop v₁ v₂ v a aa b ba l₀. binop (bop, v₁, v₂) = ⌊v⌋ ⟹ P ⊢ ⟨Val v₁ «bop» Val v₂,(a, l₀ ++ aa, b),ba⟩ → ⟨Val v,(a, l₀ ++ aa, b),ba⟩› 10. ‹⋀l V v h sh b l₀. l V = ⌊v⌋ ⟹ P ⊢ ⟨Var V,(h, l₀ ++ l, sh),b⟩ → ⟨Val v,(h, l₀ ++ l, sh),b⟩› 11. ‹⋀e a aa b ba e' ab ac bb b' V l₀. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⋀l₀. P ⊢ ⟨e,(a, l₀ ++ aa, b),ba⟩ → ⟨e',(ab, l₀ ++ ac, bb),b'⟩⟧ ⟹ P ⊢ ⟨V:=e,(a, l₀ ++ aa, b),ba⟩ → ⟨V:=e',(ab, l₀ ++ ac, bb),b'⟩› 12. ‹⋀V v h l sh b l₀. P ⊢ ⟨V:=Val v,(h, l₀ ++ l, sh),b⟩ → ⟨unit,(h, l₀ ++ l(V ↦ v), sh),b⟩› 13. ‹⋀e a aa b ba e' ab ac bb b' F D l₀. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⋀l₀. P ⊢ ⟨e,(a, l₀ ++ aa, b),ba⟩ → ⟨e',(ab, l₀ ++ ac, bb),b'⟩⟧ ⟹ P ⊢ ⟨e∙F{D},(a, l₀ ++ aa, b),ba⟩ → ⟨e'∙F{D},(ab, l₀ ++ ac, bb),b'⟩› 14. ‹⋀F D a aa b ba l₀. P ⊢ ⟨null∙F{D},(a, l₀ ++ aa, b),ba⟩ → ⟨THROW NullPointer,(a, l₀ ++ aa, b),ba⟩› 15. ‹⋀h a C fs F D l sh b l₀. ⟦h a = ⌊(C, fs)⌋; ∄b t. P ⊢ C has F,b:t in D⟧ ⟹ P ⊢ ⟨addr a∙F{D},(h, l₀ ++ l, sh),b⟩ → ⟨THROW NoSuchFieldError,(h, l₀ ++ l, sh),b⟩› 16. ‹⋀h a C fs F t D l sh b l₀. ⟦h a = ⌊(C, fs)⌋; P ⊢ C has F,Static:t in D⟧ ⟹ P ⊢ ⟨addr a∙F{D},(h, l₀ ++ l, sh),b⟩ → ⟨THROW IncompatibleClassChangeError,(h, l₀ ++ l, sh),b⟩› 17. ‹⋀C F t D sh sfs i v h l l₀. ⟦P ⊢ C has F,Static:t in D; sh D = ⌊(sfs, i)⌋; sfs F = ⌊v⌋⟧ ⟹ P ⊢ ⟨C∙⇩sF{D},(h, l₀ ++ l, sh),True⟩ → ⟨Val v,(h, l₀ ++ l, sh),False⟩› 18. ‹⋀C F t D sh sfs h l l₀. ⟦P ⊢ C has F,Static:t in D; sh D = ⌊(sfs, Done)⌋⟧ ⟹ P ⊢ ⟨C∙⇩sF{D},(h, l₀ ++ l, sh),False⟩ → ⟨C∙⇩sF{D},(h, l₀ ++ l, sh),True⟩› 19. ‹⋀C F t D sh h l l₀. ⟦P ⊢ C has F,Static:t in D; ∄sfs. sh D = ⌊(sfs, Done)⌋⟧ ⟹ P ⊢ ⟨C∙⇩sF{D},(h, l₀ ++ l, sh),False⟩ → ⟨INIT D ([D],False) ← C∙⇩sF{D},(h, l₀ ++ l, sh),False⟩› 20. ‹⋀C F D h l sh b l₀. ∄b t. P ⊢ C has F,b:t in D ⟹ P ⊢ ⟨C∙⇩sF{D},(h, l₀ ++ l, sh),b⟩ → ⟨THROW NoSuchFieldError,(h, l₀ ++ l, sh),False⟩› 21. ‹⋀C F t D h l sh b l₀. P ⊢ C has F,NonStatic:t in D ⟹ P ⊢ ⟨C∙⇩sF{D},(h, l₀ ++ l, sh),b⟩ → ⟨THROW IncompatibleClassChangeError,(h, l₀ ++ l, sh),False⟩› 22. ‹⋀e a aa b ba e' ab ac bb b' F D e₂ l₀. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⋀l₀. P ⊢ ⟨e,(a, l₀ ++ aa, b),ba⟩ → ⟨e',(ab, l₀ ++ ac, bb),b'⟩⟧ ⟹ P ⊢ ⟨e∙F{D} := e₂,(a, l₀ ++ aa, b),ba⟩ → ⟨e'∙F{D} := e₂,(ab, l₀ ++ ac, bb),b'⟩› 23. ‹⋀e a aa b ba e' ab ac bb b' v F D l₀. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⋀l₀. P ⊢ ⟨e,(a, l₀ ++ aa, b),ba⟩ → ⟨e',(ab, l₀ ++ ac, bb),b'⟩⟧ ⟹ P ⊢ ⟨Val v∙F{D} := e,(a, l₀ ++ aa, b),ba⟩ → ⟨Val v∙F{D} := e',(ab, l₀ ++ ac, bb),b'⟩› 24. ‹⋀C F t D h a fs v l sh b l₀. ⟦P ⊢ C has F,NonStatic:t in D; h a = ⌊(C, fs)⌋⟧ ⟹ P ⊢ ⟨addr a∙F{D} := Val v,(h, l₀ ++ l, sh),b⟩ → ⟨unit,(h(a ↦ (C, fs((F, D) ↦ v))), l₀ ++ l, sh),b⟩› 25. ‹⋀F D v a aa b ba l₀. P ⊢ ⟨null∙F{D} := Val v,(a, l₀ ++ aa, b),ba⟩ → ⟨THROW NullPointer,(a, l₀ ++ aa, b),ba⟩› 26. ‹⋀h a C fs F D v l sh b l₀. ⟦h a = ⌊(C, fs)⌋; ∄b t. P ⊢ C has F,b:t in D⟧ ⟹ P ⊢ ⟨addr a∙F{D} := Val v,(h, l₀ ++ l, sh),b⟩ → ⟨THROW NoSuchFieldError,(h, l₀ ++ l, sh),b⟩› 27. ‹⋀h a C fs F t D v l sh b l₀. ⟦h a = ⌊(C, fs)⌋; P ⊢ C has F,Static:t in D⟧ ⟹ P ⊢ ⟨addr a∙F{D} := Val v,(h, l₀ ++ l, sh),b⟩ → ⟨THROW IncompatibleClassChangeError,(h, l₀ ++ l, sh),b⟩› 28. ‹⋀e a aa b ba e' ab ac bb b' C F D l₀. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⋀l₀. P ⊢ ⟨e,(a, l₀ ++ aa, b),ba⟩ → ⟨e',(ab, l₀ ++ ac, bb),b'⟩⟧ ⟹ P ⊢ ⟨C∙⇩sF{D} := e,(a, l₀ ++ aa, b),ba⟩ → ⟨C∙⇩sF{D} := e',(ab, l₀ ++ ac, bb),b'⟩› 29. ‹⋀C F t D sh sfs i sfs' v sh' h l l₀. ⟦P ⊢ C has F,Static:t in D; sh D = ⌊(sfs, i)⌋; sfs' = sfs(F ↦ v); sh' = sh(D ↦ (sfs', i))⟧ ⟹ P ⊢ ⟨C∙⇩sF{D} := Val v,(h, l₀ ++ l, sh),True⟩ → ⟨unit,(h, l₀ ++ l, sh'),False⟩› 30. ‹⋀C F t D sh sfs v h l l₀. ⟦P ⊢ C has F,Static:t in D; sh D = ⌊(sfs, Done)⌋⟧ ⟹ P ⊢ ⟨C∙⇩sF{D} := Val v,(h, l₀ ++ l, sh),False⟩ → ⟨C∙⇩sF{D} := Val v,(h, l₀ ++ l, sh),True⟩› 31. ‹⋀C F t D sh v h l l₀. ⟦P ⊢ C has F,Static:t in D; ∄sfs. sh D = ⌊(sfs, Done)⌋⟧ ⟹ P ⊢ ⟨C∙⇩sF{D} := Val v,(h, l₀ ++ l, sh),False⟩ → ⟨INIT D ([D],False) ← C∙⇩sF{D} := Val v,(h, l₀ ++ l, sh),False⟩› 32. ‹⋀C F D v a aa b ba l₀. ∄b t. P ⊢ C has F,b:t in D ⟹ P ⊢ ⟨C∙⇩sF{D} := Val v,(a, l₀ ++ aa, b),ba⟩ → ⟨THROW NoSuchFieldError,(a, l₀ ++ aa, b),False⟩› 33. ‹⋀C F t D v a aa b ba l₀. P ⊢ C has F,NonStatic:t in D ⟹ P ⊢ ⟨C∙⇩sF{D} := Val v,(a, l₀ ++ aa, b),ba⟩ → ⟨THROW IncompatibleClassChangeError,(a, l₀ ++ aa, b),False⟩› 34. ‹⋀e a aa b ba e' ab ac bb b' M es l₀. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⋀l₀. P ⊢ ⟨e,(a, l₀ ++ aa, b),ba⟩ → ⟨e',(ab, l₀ ++ ac, bb),b'⟩⟧ ⟹ P ⊢ ⟨e∙M(es),(a, l₀ ++ aa, b),ba⟩ → ⟨e'∙M(es),(ab, l₀ ++ ac, bb),b'⟩› 35. ‹⋀es a aa b ba es' ab ac bb b' v M l₀. ⟦P ⊢ ⟨es,(a, aa, b),ba⟩ [→] ⟨es',(ab, ac, bb),b'⟩; ⋀l₀. P ⊢ ⟨es,(a, l₀ ++ aa, b),ba⟩ [→] ⟨es',(ab, l₀ ++ ac, bb),b'⟩⟧ ⟹ P ⊢ ⟨Val v∙M(es),(a, l₀ ++ aa, b),ba⟩ → ⟨Val v∙M(es'),(ab, l₀ ++ ac, bb),b'⟩› 36. ‹⋀M vs a aa b ba l₀. P ⊢ ⟨null∙M(map Val vs),(a, l₀ ++ aa, b),ba⟩ → ⟨THROW NullPointer,(a, l₀ ++ aa, b),ba⟩› 37. ‹⋀h a C fs M vs l sh b l₀. ⟦h a = ⌊(C, fs)⌋; ∄b Ts T m D. P ⊢ C sees M, b : Ts→T = m in D⟧ ⟹ P ⊢ ⟨addr a∙M(map Val vs),(h, l₀ ++ l, sh),b⟩ → ⟨THROW NoSuchMethodError,(h, l₀ ++ l, sh),b⟩› 38. ‹⋀h a C fs M Ts T aa b D vs l sh ba l₀. ⟦h a = ⌊(C, fs)⌋; P ⊢ C sees M, Static : Ts→T = (aa, b) in D⟧ ⟹ P ⊢ ⟨addr a∙M(map Val vs),(h, l₀ ++ l, sh),ba⟩ → ⟨THROW IncompatibleClassChangeError,(h, l₀ ++ l, sh),ba⟩› 39. ‹⋀es a aa b ba es' ab ac bb b' C M l₀. ⟦P ⊢ ⟨es,(a, aa, b),ba⟩ [→] ⟨es',(ab, ac, bb),b'⟩; ⋀l₀. P ⊢ ⟨es,(a, l₀ ++ aa, b),ba⟩ [→] ⟨es',(ab, l₀ ++ ac, bb),b'⟩⟧ ⟹ P ⊢ ⟨C∙⇩sM(es),(a, l₀ ++ aa, b),ba⟩ → ⟨C∙⇩sM(es'),(ab, l₀ ++ ac, bb),b'⟩› 40. ‹⋀C M Ts T pns body D vs a aa b l₀. ⟦P ⊢ C sees M, Static : Ts→T = (pns, body) in D; length vs = length pns; length Ts = length pns⟧ ⟹ P ⊢ ⟨C∙⇩sM(map Val vs),(a, l₀ ++ aa, b),True⟩ → ⟨blocks (pns, Ts, vs, body),(a, l₀ ++ aa, b),False⟩› 41. ‹⋀C M Ts T pns body D sh sfs vs h l l₀. ⟦P ⊢ C sees M, Static : Ts→T = (pns, body) in D; sh D = ⌊(sfs, Done)⌋ ∨ M = clinit ∧ sh D = ⌊(sfs, Processing)⌋⟧ ⟹ P ⊢ ⟨C∙⇩sM(map Val vs),(h, l₀ ++ l, sh),False⟩ → ⟨C∙⇩sM(map Val vs),(h, l₀ ++ l, sh),True⟩› 42. ‹⋀C M Ts T pns body D sh vs h l l₀. ⟦P ⊢ C sees M, Static : Ts→T = (pns, body) in D; ∄sfs. sh D = ⌊(sfs, Done)⌋; M ≠ clinit⟧ ⟹ P ⊢ ⟨C∙⇩sM(map Val vs),(h, l₀ ++ l, sh),False⟩ → ⟨INIT D ([D],False) ← C∙⇩sM(map Val vs),(h, l₀ ++ l, sh),False⟩› 43. ‹⋀C M vs a aa b ba l₀. ∄b Ts T m. Ex (Method P C M b Ts T m) ⟹ P ⊢ ⟨C∙⇩sM(map Val vs),(a, l₀ ++ aa, b),ba⟩ → ⟨THROW NoSuchMethodError,(a, l₀ ++ aa, b),False⟩› 44. ‹⋀C M Ts T a b D vs aa ab ba bb l₀. P ⊢ C sees M, NonStatic : Ts→T = (a, b) in D ⟹ P ⊢ ⟨C∙⇩sM(map Val vs),(aa, l₀ ++ ab, ba),bb⟩ → ⟨THROW IncompatibleClassChangeError,(aa, l₀ ++ ab, ba),False⟩› 45. ‹⋀e h l V sh b e' h' l' sh' b' T l₀. ⟦P ⊢ ⟨e,(h, l(V := None), sh),b⟩ → ⟨e',(h', l', sh'),b'⟩; ⋀l₀. P ⊢ ⟨e,(h, l₀ ++ l(V := None), sh),b⟩ → ⟨e',(h', l₀ ++ l', sh'),b'⟩; l' V = None; ¬ assigned V e⟧ ⟹ P ⊢ ⟨{V:T; e},(h, l₀ ++ l, sh),b⟩ → ⟨{V:T; e'},(h', l₀ ++ l'(V := l V), sh'),b'⟩› 46. ‹⋀e h l V sh b e' h' l' sh' b' v T l₀. ⟦P ⊢ ⟨e,(h, l(V := None), sh),b⟩ → ⟨e',(h', l', sh'),b'⟩; ⋀l₀. P ⊢ ⟨e,(h, l₀ ++ l(V := None), sh),b⟩ → ⟨e',(h', l₀ ++ l', sh'),b'⟩; l' V = ⌊v⌋; ¬ assigned V e⟧ ⟹ P ⊢ ⟨{V:T; e},(h, l₀ ++ l, sh),b⟩ → ⟨{V:T; V:=Val v;; e'},(h', l₀ ++ l'(V := l V), sh'),b'⟩› 47. ‹⋀e h l V v sh b e' h' l' sh' b' v' T l₀. ⟦P ⊢ ⟨e,(h, l(V ↦ v), sh),b⟩ → ⟨e',(h', l', sh'),b'⟩; ⋀l₀. P ⊢ ⟨e,(h, l₀ ++ l(V ↦ v), sh),b⟩ → ⟨e',(h', l₀ ++ l', sh'),b'⟩; l' V = ⌊v'⌋⟧ ⟹ P ⊢ ⟨{V:T; V:=Val v;; e},(h, l₀ ++ l, sh),b⟩ → ⟨{V:T; V:=Val v';; e'},(h', l₀ ++ l'(V := l V), sh'),b'⟩› 48. ‹⋀V T u a aa b ba l₀. P ⊢ ⟨{V:T; Val u},(a, l₀ ++ aa, b),ba⟩ → ⟨Val u,(a, l₀ ++ aa, b),ba⟩› 49. ‹⋀V T v u a aa b ba l₀. P ⊢ ⟨{V:T; V:=Val v;; Val u},(a, l₀ ++ aa, b),ba⟩ → ⟨Val u,(a, l₀ ++ aa, b),ba⟩› 50. ‹⋀e a aa b ba e' ab ac bb b' e₂ l₀. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⋀l₀. P ⊢ ⟨e,(a, l₀ ++ aa, b),ba⟩ → ⟨e',(ab, l₀ ++ ac, bb),b'⟩⟧ ⟹ P ⊢ ⟨e;; e₂,(a, l₀ ++ aa, b),ba⟩ → ⟨e';; e₂,(ab, l₀ ++ ac, bb),b'⟩› 51. ‹⋀v e₂ a aa b ba l₀. P ⊢ ⟨Val v;; e₂,(a, l₀ ++ aa, b),ba⟩ → ⟨e₂,(a, l₀ ++ aa, b),ba⟩› 52. ‹⋀e a aa b ba e' ab ac bb b' e₁ e₂ l₀. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⋀l₀. P ⊢ ⟨e,(a, l₀ ++ aa, b),ba⟩ → ⟨e',(ab, l₀ ++ ac, bb),b'⟩⟧ ⟹ P ⊢ ⟨if (e) e₁ else e₂,(a, l₀ ++ aa, b),ba⟩ → ⟨if (e') e₁ else e₂,(ab, l₀ ++ ac, bb),b'⟩› 53. ‹⋀e₁ e₂ a aa b ba l₀. P ⊢ ⟨if (true) e₁ else e₂,(a, l₀ ++ aa, b),ba⟩ → ⟨e₁,(a, l₀ ++ aa, b),ba⟩› 54. ‹⋀e₁ e₂ a aa b ba l₀. P ⊢ ⟨if (false) e₁ else e₂,(a, l₀ ++ aa, b),ba⟩ → ⟨e₂,(a, l₀ ++ aa, b),ba⟩› 55. ‹⋀b c a aa ba b' l₀. P ⊢ ⟨while (b) c,(a, l₀ ++ aa, ba),b'⟩ → ⟨if (b) (c;; while (b) c) else unit,(a, l₀ ++ aa, ba),b'⟩› 56. ‹⋀e a aa b ba e' ab ac bb b' l₀. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⋀l₀. P ⊢ ⟨e,(a, l₀ ++ aa, b),ba⟩ → ⟨e',(ab, l₀ ++ ac, bb),b'⟩⟧ ⟹ P ⊢ ⟨throw e,(a, l₀ ++ aa, b),ba⟩ → ⟨throw e',(ab, l₀ ++ ac, bb),b'⟩› 57. ‹⋀a aa b ba l₀. P ⊢ ⟨throw null,(a, l₀ ++ aa, b),ba⟩ → ⟨THROW NullPointer,(a, l₀ ++ aa, b),ba⟩› 58. ‹⋀e a aa b ba e' ab ac bb b' C V e₂ l₀. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⋀l₀. P ⊢ ⟨e,(a, l₀ ++ aa, b),ba⟩ → ⟨e',(ab, l₀ ++ ac, bb),b'⟩⟧ ⟹ P ⊢ ⟨try e catch(C V) e₂,(a, l₀ ++ aa, b),ba⟩ → ⟨try e' catch(C V) e₂,(ab, l₀ ++ ac, bb),b'⟩› 59. ‹⋀v C V e₂ a aa b ba l₀. P ⊢ ⟨try Val v catch(C V) e₂,(a, l₀ ++ aa, b),ba⟩ → ⟨Val v,(a, l₀ ++ aa, b),ba⟩› 60. ‹⋀a aa b ab D fs C V e₂ ba l₀. ⟦hp (a, aa, b) ab = ⌊(D, fs)⌋; P ⊢ D ≼⇧* C⟧ ⟹ P ⊢ ⟨try Throw ab catch(C V) e₂,(a, l₀ ++ aa, b),ba⟩ → ⟨{V:Class C; V:=addr ab;; e₂},(a, l₀ ++ aa, b),ba⟩› 61. ‹⋀a aa b ab D fs C V e₂ ba l₀. ⟦hp (a, aa, b) ab = ⌊(D, fs)⌋; (D, C) ∉ (subcls1 P)⇧*⟧ ⟹ P ⊢ ⟨try Throw ab catch(C V) e₂,(a, l₀ ++ aa, b),ba⟩ → ⟨Throw ab,(a, l₀ ++ aa, b),ba⟩› 62. ‹⋀e a aa b ba e' ab ac bb b' es l₀. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⋀l₀. P ⊢ ⟨e,(a, l₀ ++ aa, b),ba⟩ → ⟨e',(ab, l₀ ++ ac, bb),b'⟩⟧ ⟹ P ⊢ ⟨e # es,(a, l₀ ++ aa, b),ba⟩ [→] ⟨e' # es,(ab, l₀ ++ ac, bb),b'⟩› 63. ‹⋀es a aa b ba es' ab ac bb b' v l₀. ⟦P ⊢ ⟨es,(a, aa, b),ba⟩ [→] ⟨es',(ab, ac, bb),b'⟩; ⋀l₀. P ⊢ ⟨es,(a, l₀ ++ aa, b),ba⟩ [→] ⟨es',(ab, l₀ ++ ac, bb),b'⟩⟧ ⟹ P ⊢ ⟨Val v # es,(a, l₀ ++ aa, b),ba⟩ [→] ⟨Val v # es',(ab, l₀ ++ ac, bb),b'⟩› 64. ‹⋀e C b a aa ba b' l₀. ¬ sub_RI e ⟹ P ⊢ ⟨INIT C ([],b) ← e,(a, l₀ ++ aa, ba),b'⟩ → ⟨e,(a, l₀ ++ aa, ba),icheck P C e⟩› 65. ‹⋀sh C C' Cs e h l b l₀. sh C = None ⟹ P ⊢ ⟨INIT C' (C # Cs,False) ← e,(h, l₀ ++ l, sh),b⟩ → ⟨INIT C' (C # Cs,False) ← e,(h, l₀ ++ l, sh(C ↦ (sblank P C, Prepared))),b⟩› 66. ‹⋀sh C sfs C' Cs e h l b l₀. sh C = ⌊(sfs, Done)⌋ ⟹ P ⊢ ⟨INIT C' (C # Cs,False) ← e,(h, l₀ ++ l, sh),b⟩ → ⟨INIT C' (Cs,True) ← e,(h, l₀ ++ l, sh),b⟩› 67. ‹⋀sh C sfs C' Cs e h l b l₀. sh C = ⌊(sfs, Processing)⌋ ⟹ P ⊢ ⟨INIT C' (C # Cs,False) ← e,(h, l₀ ++ l, sh),b⟩ → ⟨INIT C' (Cs,True) ← e,(h, l₀ ++ l, sh),b⟩› 68. ‹⋀sh C sfs C' Cs e h l b l₀. sh C = ⌊(sfs, Error)⌋ ⟹ P ⊢ ⟨INIT C' (C # Cs,False) ← e,(h, l₀ ++ l, sh),b⟩ → ⟨RI (C,THROW NoClassDefFoundError) ; Cs ← e,(h, l₀ ++ l, sh),b⟩› 69. ‹⋀sh C sfs sh' C' Cs e h l b l₀. ⟦sh C = ⌊(sfs, Prepared)⌋; C = Object; sh' = sh(C ↦ (sfs, Processing))⟧ ⟹ P ⊢ ⟨INIT C' (C # Cs,False) ← e,(h, l₀ ++ l, sh),b⟩ → ⟨INIT C' (C # Cs,True) ← e,(h, l₀ ++ l, sh'),b⟩› 70. ‹⋀sh C sfs D a b sh' C' Cs e h l ba l₀. ⟦sh C = ⌊(sfs, Prepared)⌋; C ≠ Object; class P C = ⌊(D, a, b)⌋; sh' = sh(C ↦ (sfs, Processing))⟧ ⟹ P ⊢ ⟨INIT C' (C # Cs,False) ← e,(h, l₀ ++ l, sh),ba⟩ → ⟨INIT C' (D # C # Cs,False) ← e,(h, l₀ ++ l, sh'),ba⟩› 71. ‹⋀C' C Cs e h l sh b l₀. P ⊢ ⟨INIT C' (C # Cs,True) ← e,(h, l₀ ++ l, sh),b⟩ → ⟨RI (C,C∙⇩sclinit([])) ; Cs ← e,(h, l₀ ++ l, sh),b⟩› 72. ‹⋀e a aa b ba e' ab ac bb b' C Cs e₀ l₀. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⋀l₀. P ⊢ ⟨e,(a, l₀ ++ aa, b),ba⟩ → ⟨e',(ab, l₀ ++ ac, bb),b'⟩⟧ ⟹ P ⊢ ⟨RI (C,e) ; Cs ← e₀,(a, l₀ ++ aa, b),ba⟩ → ⟨RI (C,e') ; Cs ← e₀,(ab, l₀ ++ ac, bb),b'⟩› 73. ‹⋀sh C sfs i sh' C' Cs v e h l b l₀. ⟦sh C = ⌊(sfs, i)⌋; sh' = sh(C ↦ (sfs, Done)); C' = last (C # Cs)⟧ ⟹ P ⊢ ⟨RI (C,Val v) ; Cs ← e,(h, l₀ ++ l, sh),b⟩ → ⟨INIT C' (Cs,True) ← e,(h, l₀ ++ l, sh'),b⟩› 74. ‹⋀C e a aa b ba l₀. P ⊢ ⟨Cast C (throw e),(a, l₀ ++ aa, b),ba⟩ → ⟨throw e,(a, l₀ ++ aa, b),ba⟩› 75. ‹⋀e bop e₂ a aa b ba l₀. P ⊢ ⟨throw e «bop» e₂,(a, l₀ ++ aa, b),ba⟩ → ⟨throw e,(a, l₀ ++ aa, b),ba⟩› 76. ‹⋀v₁ bop e a aa b ba l₀. P ⊢ ⟨Val v₁ «bop» throw e,(a, l₀ ++ aa, b),ba⟩ → ⟨throw e,(a, l₀ ++ aa, b),ba⟩› 77. ‹⋀V e a aa b ba l₀. P ⊢ ⟨V:=throw e,(a, l₀ ++ aa, b),ba⟩ → ⟨throw e,(a, l₀ ++ aa, b),ba⟩› 78. ‹⋀e F D a aa b ba l₀. P ⊢ ⟨throw e∙F{D},(a, l₀ ++ aa, b),ba⟩ → ⟨throw e,(a, l₀ ++ aa, b),ba⟩› 79. ‹⋀e F D e₂ a aa b ba l₀. P ⊢ ⟨throw e∙F{D} := e₂,(a, l₀ ++ aa, b),ba⟩ → ⟨throw e,(a, l₀ ++ aa, b),ba⟩› 80. ‹⋀v F D e a aa b ba l₀. P ⊢ ⟨Val v∙F{D} := throw e,(a, l₀ ++ aa, b),ba⟩ → ⟨throw e,(a, l₀ ++ aa, b),ba⟩› 81. ‹⋀C F D e a aa b ba l₀. P ⊢ ⟨C∙⇩sF{D} := throw e,(a, l₀ ++ aa, b),ba⟩ → ⟨throw e,(a, l₀ ++ aa, b),ba⟩› 82. ‹⋀e M es a aa b ba l₀. P ⊢ ⟨throw e∙M(es),(a, l₀ ++ aa, b),ba⟩ → ⟨throw e,(a, l₀ ++ aa, b),ba⟩› 83. ‹⋀es vs e es' v M a aa b ba l₀. es = map Val vs @ throw e # es' ⟹ P ⊢ ⟨Val v∙M(es),(a, l₀ ++ aa, b),ba⟩ → ⟨throw e,(a, l₀ ++ aa, b),ba⟩› 84. ‹⋀es vs e es' C M a aa b ba l₀. es = map Val vs @ throw e # es' ⟹ P ⊢ ⟨C∙⇩sM(es),(a, l₀ ++ aa, b),ba⟩ → ⟨throw e,(a, l₀ ++ aa, b),ba⟩› 85. ‹⋀V T a aa ab b ba l₀. P ⊢ ⟨{V:T; Throw a},(aa, l₀ ++ ab, b),ba⟩ → ⟨Throw a,(aa, l₀ ++ ab, b),ba⟩› 86. ‹⋀V T v a aa ab b ba l₀. P ⊢ ⟨{V:T; V:=Val v;; Throw a},(aa, l₀ ++ ab, b),ba⟩ → ⟨Throw a,(aa, l₀ ++ ab, b),ba⟩› 87. ‹⋀e e₂ a aa b ba l₀. P ⊢ ⟨throw e;; e₂,(a, l₀ ++ aa, b),ba⟩ → ⟨throw e,(a, l₀ ++ aa, b),ba⟩› 88. ‹⋀e e₁ e₂ a aa b ba l₀. P ⊢ ⟨if (throw e) e₁ else e₂,(a, l₀ ++ aa, b),ba⟩ → ⟨throw e,(a, l₀ ++ aa, b),ba⟩› 89. ‹⋀e a aa b ba l₀. P ⊢ ⟨throw (throw e),(a, l₀ ++ aa, b),ba⟩ → ⟨throw e,(a, l₀ ++ aa, b),ba⟩› 90. ‹⋀sh C sfs i sh' a D Cs e h l b l₀. ⟦sh C = ⌊(sfs, i)⌋; sh' = sh(C ↦ (sfs, Error))⟧ ⟹ P ⊢ ⟨RI (C,Throw a) ; D # Cs ← e,(h, l₀ ++ l, sh),b⟩ → ⟨RI (D,Throw a) ; Cs ← e,(h, l₀ ++ l, sh'),b⟩› 91. ‹⋀sh C sfs i sh' a e h l b l₀. ⟦sh C = ⌊(sfs, i)⌋; sh' = sh(C ↦ (sfs, Error))⟧ ⟹ P ⊢ ⟨RI (C,Throw a) ; [] ← e,(h, l₀ ++ l, sh),b⟩ → ⟨Throw a,(h, l₀ ++ l, sh'),b⟩›*) case (InitBlockRed e h l V v sh b e' h' l' sh' b' v' T l₀) (*‹P ⊢ ⟨e,(h, l(V ↦ v), sh),b⟩ → ⟨e',(h', l', sh'),b'⟩› ‹P ⊢ ⟨e,(h, ?l₀ ++ l(V ↦ v), sh),b⟩ → ⟨e',(h', ?l₀ ++ l', sh'),b'⟩› ‹l' V = ⌊v'⌋›*) have IH: "⋀l₀. P ⊢ ⟨e,(h, l₀ ++ l(V ↦ v), sh),b⟩ → ⟨e',(h', l₀ ++ l', sh'),b'⟩" and l'V: "l' V = Some v'" (*goals: 1. ‹⋀l₀. P ⊢ ⟨e,(h, l₀ ++ l(V ↦ v), sh),b⟩ → ⟨e',(h', l₀ ++ l', sh'),b'⟩› 2. ‹l' V = ⌊v'⌋› discuss goal 1*) apply fact (*discuss goal 2*) apply fact (*proven 2 subgoals*) . from IH (*‹P ⊢ ⟨e,(h, ?l₀ ++ l(V ↦ v), sh),b⟩ → ⟨e',(h', ?l₀ ++ l', sh'),b'⟩›*) have IH': "P ⊢ ⟨e,(h, (l₀ ++ l)(V ↦ v), sh),b⟩ → ⟨e',(h', l₀ ++ l', sh'),b'⟩" by simp have "(l₀ ++ l')(V := (l₀ ++ l) V) = l₀ ++ l'(V := l V)" apply (rule ext (*‹(⋀x. ?f x = ?g x) ⟹ ?f = ?g›*)) (*goal: ‹(l₀ ++ l')(V := (l₀ ++ l) V) = l₀ ++ l'(V := l V)›*) by (simp add:map_add_def (*‹(?m1.0::?'a ⇒ ?'b option) ++ (?m2.0::?'a ⇒ ?'b option) = (λx::?'a. case ?m2.0 x of None ⇒ ?m1.0 x | ⌊y::?'b⌋ ⇒ ⌊y⌋)›*)) with red_reds.InitBlockRed[OF IH'] (*‹(l₀ ++ l') V = ⌊?v'⌋ ⟹ P ⊢ ⟨{V:?T; V:=Val v;; e},(h, l₀ ++ l, sh),b⟩ → ⟨{V:?T; V:=Val ?v';; e'},(h', (l₀ ++ l')(V := (l₀ ++ l) V), sh'),b'⟩›*) l'V (*‹l' V = ⌊v'⌋›*) show "?case" (*goal: ‹P ⊢ ⟨{V:T; V:=Val v;; e},(h, l₀ ++ l, sh),b⟩ → ⟨{V:T; V:=Val v';; e'},(h', l₀ ++ l'(V := l V), sh'),b'⟩›*) by (simp del:fun_upd_apply (*‹(?f(?x := ?y)) ?z = (if ?z = ?x then ?y else ?f ?z)›*)) next (*goals: 1. ‹⋀(h::heap) (a::nat) (C::char list) (FDTs::((char list × char list) × staticb × ty) list) (h'::heap) (l::sfields) (sh::sheap) l₀::sfields. ⟦new_Addr h = ⌊a⌋; (P::(char list list × char list exp) prog) ⊢ C has_fields FDTs; h' = h(a ↦ blank P C)⟧ ⟹ P ⊢ ⟨new C,(h, l₀ ++ l, sh),True⟩ → ⟨addr a,(h', l₀ ++ l, sh),False⟩› 2. ‹⋀(h::heap) (C::char list) (l::sfields) (sh::sheap) l₀::sfields. ⟦new_Addr h = None; is_class (P::(char list list × char list exp) prog) C⟧ ⟹ P ⊢ ⟨new C,(h, l₀ ++ l, sh),True⟩ → ⟨THROW OutOfMemory,(h, l₀ ++ l, sh),False⟩› 3. ‹⋀(sh::sheap) (C::char list) (sfs::sfields) (h::heap) (l::sfields) l₀::sfields. sh C = ⌊(sfs, Done)⌋ ⟹ (P::(char list list × char list exp) prog) ⊢ ⟨new C,(h, l₀ ++ l, sh),False⟩ → ⟨new C,(h, l₀ ++ l, sh),True⟩› 4. ‹⋀(sh::sheap) (C::char list) (h::heap) (l::sfields) l₀::sfields. ⟦∄sfs::sfields. sh C = ⌊(sfs, Done)⌋; is_class (P::(char list list × char list exp) prog) C⟧ ⟹ P ⊢ ⟨new C,(h, l₀ ++ l, sh),False⟩ → ⟨INIT C ([C],False) ← new C,(h, l₀ ++ l, sh),False⟩› 5. ‹⋀(e::char list exp) (a::heap) (aa::sfields) (b::sheap) (ba::bool) (e'::char list exp) (ab::heap) (ac::sfields) (bb::sheap) (b'::bool) (C::char list) l₀::sfields. ⟦(P::(char list list × char list exp) prog) ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⋀l₀::sfields. P ⊢ ⟨e,(a, l₀ ++ aa, b),ba⟩ → ⟨e',(ab, l₀ ++ ac, bb),b'⟩⟧ ⟹ P ⊢ ⟨Cast C e,(a, l₀ ++ aa, b),ba⟩ → ⟨Cast C e',(ab, l₀ ++ ac, bb),b'⟩› 6. ‹⋀(C::char list) (a::heap) (aa::sfields) (b::sheap) (ba::bool) l₀::sfields. (P::(char list list × char list exp) prog) ⊢ ⟨Cast C null,(a, l₀ ++ aa, b),ba⟩ → ⟨null,(a, l₀ ++ aa, b),ba⟩› 7. ‹⋀(e::char list exp) (a::heap) (aa::sfields) (b::sheap) (ba::bool) (e'::char list exp) (ab::heap) (ac::sfields) (bb::sheap) (b'::bool) (bop::bop) (e₂::char list exp) l₀::sfields. ⟦(P::(char list list × char list exp) prog) ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⋀l₀::sfields. P ⊢ ⟨e,(a, l₀ ++ aa, b),ba⟩ → ⟨e',(ab, l₀ ++ ac, bb),b'⟩⟧ ⟹ P ⊢ ⟨e «bop» e₂,(a, l₀ ++ aa, b),ba⟩ → ⟨e' «bop» e₂,(ab, l₀ ++ ac, bb),b'⟩› 8. ‹⋀(e::char list exp) (a::heap) (aa::sfields) (b::sheap) (ba::bool) (e'::char list exp) (ab::heap) (ac::sfields) (bb::sheap) (b'::bool) (v₁::val) (bop::bop) l₀::sfields. ⟦(P::(char list list × char list exp) prog) ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⋀l₀::sfields. P ⊢ ⟨e,(a, l₀ ++ aa, b),ba⟩ → ⟨e',(ab, l₀ ++ ac, bb),b'⟩⟧ ⟹ P ⊢ ⟨Val v₁ «bop» e,(a, l₀ ++ aa, b),ba⟩ → ⟨Val v₁ «bop» e',(ab, l₀ ++ ac, bb),b'⟩› 9. ‹⋀(bop::bop) (v₁::val) (v₂::val) (v::val) (a::heap) (aa::sfields) (b::sheap) (ba::bool) l₀::sfields. binop (bop, v₁, v₂) = ⌊v⌋ ⟹ (P::(char list list × char list exp) prog) ⊢ ⟨Val v₁ «bop» Val v₂,(a, l₀ ++ aa, b),ba⟩ → ⟨Val v,(a, l₀ ++ aa, b),ba⟩› 10. ‹⋀(l::sfields) (V::char list) (v::val) (h::heap) (sh::sheap) (b::bool) l₀::sfields. l V = ⌊v⌋ ⟹ (P::(char list list × char list exp) prog) ⊢ ⟨Var V,(h, l₀ ++ l, sh),b⟩ → ⟨Val v,(h, l₀ ++ l, sh),b⟩› 11. ‹⋀(e::char list exp) (a::heap) (aa::sfields) (b::sheap) (ba::bool) (e'::char list exp) (ab::heap) (ac::sfields) (bb::sheap) (b'::bool) (V::char list) l₀::sfields. ⟦(P::(char list list × char list exp) prog) ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⋀l₀::sfields. P ⊢ ⟨e,(a, l₀ ++ aa, b),ba⟩ → ⟨e',(ab, l₀ ++ ac, bb),b'⟩⟧ ⟹ P ⊢ ⟨V:=e,(a, l₀ ++ aa, b),ba⟩ → ⟨V:=e',(ab, l₀ ++ ac, bb),b'⟩› 12. ‹⋀(V::char list) (v::val) (h::heap) (l::sfields) (sh::sheap) (b::bool) l₀::sfields. (P::(char list list × char list exp) prog) ⊢ ⟨V:=Val v,(h, l₀ ++ l, sh),b⟩ → ⟨unit,(h, l₀ ++ l(V ↦ v), sh),b⟩› 13. ‹⋀(e::char list exp) (a::heap) (aa::sfields) (b::sheap) (ba::bool) (e'::char list exp) (ab::heap) (ac::sfields) (bb::sheap) (b'::bool) (F::char list) (D::char list) l₀::sfields. ⟦(P::(char list list × char list exp) prog) ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⋀l₀::sfields. P ⊢ ⟨e,(a, l₀ ++ aa, b),ba⟩ → ⟨e',(ab, l₀ ++ ac, bb),b'⟩⟧ ⟹ P ⊢ ⟨e∙F{D},(a, l₀ ++ aa, b),ba⟩ → ⟨e'∙F{D},(ab, l₀ ++ ac, bb),b'⟩› 14. ‹⋀(F::char list) (D::char list) (a::heap) (aa::sfields) (b::sheap) (ba::bool) l₀::sfields. (P::(char list list × char list exp) prog) ⊢ ⟨null∙F{D},(a, l₀ ++ aa, b),ba⟩ → ⟨THROW NullPointer,(a, l₀ ++ aa, b),ba⟩› 15. ‹⋀(h::heap) (a::nat) (C::char list) (fs::Objects.fields) (F::char list) (D::char list) (l::sfields) (sh::sheap) (b::bool) l₀::sfields. ⟦h a = ⌊(C, fs)⌋; ∄(b::staticb) t::ty. (P::(char list list × char list exp) prog) ⊢ C has F,b:t in D⟧ ⟹ P ⊢ ⟨addr a∙F{D},(h, l₀ ++ l, sh),b⟩ → ⟨THROW NoSuchFieldError,(h, l₀ ++ l, sh),b⟩› 16. ‹⋀(h::heap) (a::nat) (C::char list) (fs::Objects.fields) (F::char list) (t::ty) (D::char list) (l::sfields) (sh::sheap) (b::bool) l₀::sfields. ⟦h a = ⌊(C, fs)⌋; (P::(char list list × char list exp) prog) ⊢ C has F,Static:t in D⟧ ⟹ P ⊢ ⟨addr a∙F{D},(h, l₀ ++ l, sh),b⟩ → ⟨THROW IncompatibleClassChangeError,(h, l₀ ++ l, sh),b⟩› 17. ‹⋀(C::char list) (F::char list) (t::ty) (D::char list) (sh::sheap) (sfs::sfields) (i::init_state) (v::val) (h::heap) (l::sfields) l₀::sfields. ⟦(P::(char list list × char list exp) prog) ⊢ C has F,Static:t in D; sh D = ⌊(sfs, i)⌋; sfs F = ⌊v⌋⟧ ⟹ P ⊢ ⟨C∙⇩sF{D},(h, l₀ ++ l, sh),True⟩ → ⟨Val v,(h, l₀ ++ l, sh),False⟩› 18. ‹⋀(C::char list) (F::char list) (t::ty) (D::char list) (sh::sheap) (sfs::sfields) (h::heap) (l::sfields) l₀::sfields. ⟦(P::(char list list × char list exp) prog) ⊢ C has F,Static:t in D; sh D = ⌊(sfs, Done)⌋⟧ ⟹ P ⊢ ⟨C∙⇩sF{D},(h, l₀ ++ l, sh),False⟩ → ⟨C∙⇩sF{D},(h, l₀ ++ l, sh),True⟩› 19. ‹⋀(C::char list) (F::char list) (t::ty) (D::char list) (sh::sheap) (h::heap) (l::sfields) l₀::sfields. ⟦(P::(char list list × char list exp) prog) ⊢ C has F,Static:t in D; ∄sfs::sfields. sh D = ⌊(sfs, Done)⌋⟧ ⟹ P ⊢ ⟨C∙⇩sF{D},(h, l₀ ++ l, sh),False⟩ → ⟨INIT D ([D],False) ← C∙⇩sF{D},(h, l₀ ++ l, sh),False⟩› 20. ‹⋀(C::char list) (F::char list) (D::char list) (h::heap) (l::sfields) (sh::sheap) (b::bool) l₀::sfields. ∄(b::staticb) t::ty. (P::(char list list × char list exp) prog) ⊢ C has F,b:t in D ⟹ P ⊢ ⟨C∙⇩sF{D},(h, l₀ ++ l, sh),b⟩ → ⟨THROW NoSuchFieldError,(h, l₀ ++ l, sh),False⟩› 21. ‹⋀(C::char list) (F::char list) (t::ty) (D::char list) (h::heap) (l::sfields) (sh::sheap) (b::bool) l₀::sfields. (P::(char list list × char list exp) prog) ⊢ C has F,NonStatic:t in D ⟹ P ⊢ ⟨C∙⇩sF{D},(h, l₀ ++ l, sh),b⟩ → ⟨THROW IncompatibleClassChangeError,(h, l₀ ++ l, sh),False⟩› 22. ‹⋀(e::char list exp) (a::heap) (aa::sfields) (b::sheap) (ba::bool) (e'::char list exp) (ab::heap) (ac::sfields) (bb::sheap) (b'::bool) (F::char list) (D::char list) (e₂::char list exp) l₀::sfields. ⟦(P::(char list list × char list exp) prog) ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⋀l₀::sfields. P ⊢ ⟨e,(a, l₀ ++ aa, b),ba⟩ → ⟨e',(ab, l₀ ++ ac, bb),b'⟩⟧ ⟹ P ⊢ ⟨e∙F{D} := e₂,(a, l₀ ++ aa, b),ba⟩ → ⟨e'∙F{D} := e₂,(ab, l₀ ++ ac, bb),b'⟩› 23. ‹⋀(e::char list exp) (a::heap) (aa::sfields) (b::sheap) (ba::bool) (e'::char list exp) (ab::heap) (ac::sfields) (bb::sheap) (b'::bool) (v::val) (F::char list) (D::char list) l₀::sfields. ⟦(P::(char list list × char list exp) prog) ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⋀l₀::sfields. P ⊢ ⟨e,(a, l₀ ++ aa, b),ba⟩ → ⟨e',(ab, l₀ ++ ac, bb),b'⟩⟧ ⟹ P ⊢ ⟨Val v∙F{D} := e,(a, l₀ ++ aa, b),ba⟩ → ⟨Val v∙F{D} := e',(ab, l₀ ++ ac, bb),b'⟩› 24. ‹⋀(C::char list) (F::char list) (t::ty) (D::char list) (h::heap) (a::nat) (fs::Objects.fields) (v::val) (l::sfields) (sh::sheap) (b::bool) l₀::sfields. ⟦(P::(char list list × char list exp) prog) ⊢ C has F,NonStatic:t in D; h a = ⌊(C, fs)⌋⟧ ⟹ P ⊢ ⟨addr a∙F{D} := Val v,(h, l₀ ++ l, sh),b⟩ → ⟨unit,(h(a ↦ (C, fs((F, D) ↦ v))), l₀ ++ l, sh),b⟩› 25. ‹⋀(F::char list) (D::char list) (v::val) (a::heap) (aa::sfields) (b::sheap) (ba::bool) l₀::sfields. (P::(char list list × char list exp) prog) ⊢ ⟨null∙F{D} := Val v,(a, l₀ ++ aa, b),ba⟩ → ⟨THROW NullPointer,(a, l₀ ++ aa, b),ba⟩› 26. ‹⋀(h::heap) (a::nat) (C::char list) (fs::Objects.fields) (F::char list) (D::char list) (v::val) (l::sfields) (sh::sheap) (b::bool) l₀::sfields. ⟦h a = ⌊(C, fs)⌋; ∄(b::staticb) t::ty. (P::(char list list × char list exp) prog) ⊢ C has F,b:t in D⟧ ⟹ P ⊢ ⟨addr a∙F{D} := Val v,(h, l₀ ++ l, sh),b⟩ → ⟨THROW NoSuchFieldError,(h, l₀ ++ l, sh),b⟩› 27. ‹⋀(h::heap) (a::nat) (C::char list) (fs::Objects.fields) (F::char list) (t::ty) (D::char list) (v::val) (l::sfields) (sh::sheap) (b::bool) l₀::sfields. ⟦h a = ⌊(C, fs)⌋; (P::(char list list × char list exp) prog) ⊢ C has F,Static:t in D⟧ ⟹ P ⊢ ⟨addr a∙F{D} := Val v,(h, l₀ ++ l, sh),b⟩ → ⟨THROW IncompatibleClassChangeError,(h, l₀ ++ l, sh),b⟩› 28. ‹⋀(e::char list exp) (a::heap) (aa::sfields) (b::sheap) (ba::bool) (e'::char list exp) (ab::heap) (ac::sfields) (bb::sheap) (b'::bool) (C::char list) (F::char list) (D::char list) l₀::sfields. ⟦(P::(char list list × char list exp) prog) ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⋀l₀::sfields. P ⊢ ⟨e,(a, l₀ ++ aa, b),ba⟩ → ⟨e',(ab, l₀ ++ ac, bb),b'⟩⟧ ⟹ P ⊢ ⟨C∙⇩sF{D} := e,(a, l₀ ++ aa, b),ba⟩ → ⟨C∙⇩sF{D} := e',(ab, l₀ ++ ac, bb),b'⟩› 29. ‹⋀(C::char list) (F::char list) (t::ty) (D::char list) (sh::sheap) (sfs::sfields) (i::init_state) (sfs'::sfields) (v::val) (sh'::sheap) (h::heap) (l::sfields) l₀::sfields. ⟦(P::(char list list × char list exp) prog) ⊢ C has F,Static:t in D; sh D = ⌊(sfs, i)⌋; sfs' = sfs(F ↦ v); sh' = sh(D ↦ (sfs', i))⟧ ⟹ P ⊢ ⟨C∙⇩sF{D} := Val v,(h, l₀ ++ l, sh),True⟩ → ⟨unit,(h, l₀ ++ l, sh'),False⟩› 30. ‹⋀(C::char list) (F::char list) (t::ty) (D::char list) (sh::sheap) (sfs::sfields) (v::val) (h::heap) (l::sfields) l₀::sfields. ⟦(P::(char list list × char list exp) prog) ⊢ C has F,Static:t in D; sh D = ⌊(sfs, Done)⌋⟧ ⟹ P ⊢ ⟨C∙⇩sF{D} := Val v,(h, l₀ ++ l, sh),False⟩ → ⟨C∙⇩sF{D} := Val v,(h, l₀ ++ l, sh),True⟩› 31. ‹⋀(C::char list) (F::char list) (t::ty) (D::char list) (sh::sheap) (v::val) (h::heap) (l::sfields) l₀::sfields. ⟦(P::(char list list × char list exp) prog) ⊢ C has F,Static:t in D; ∄sfs::sfields. sh D = ⌊(sfs, Done)⌋⟧ ⟹ P ⊢ ⟨C∙⇩sF{D} := Val v,(h, l₀ ++ l, sh),False⟩ → ⟨INIT D ([D],False) ← C∙⇩sF{D} := Val v,(h, l₀ ++ l, sh),False⟩› 32. ‹⋀(C::char list) (F::char list) (D::char list) (v::val) (a::heap) (aa::sfields) (b::sheap) (ba::bool) l₀::sfields. ∄(b::staticb) t::ty. (P::(char list list × char list exp) prog) ⊢ C has F,b:t in D ⟹ P ⊢ ⟨C∙⇩sF{D} := Val v,(a, l₀ ++ aa, b),ba⟩ → ⟨THROW NoSuchFieldError,(a, l₀ ++ aa, b),False⟩› 33. ‹⋀(C::char list) (F::char list) (t::ty) (D::char list) (v::val) (a::heap) (aa::sfields) (b::sheap) (ba::bool) l₀::sfields. (P::(char list list × char list exp) prog) ⊢ C has F,NonStatic:t in D ⟹ P ⊢ ⟨C∙⇩sF{D} := Val v,(a, l₀ ++ aa, b),ba⟩ → ⟨THROW IncompatibleClassChangeError,(a, l₀ ++ aa, b),False⟩› 34. ‹⋀(e::char list exp) (a::heap) (aa::sfields) (b::sheap) (ba::bool) (e'::char list exp) (ab::heap) (ac::sfields) (bb::sheap) (b'::bool) (M::char list) (es::char list exp list) l₀::sfields. ⟦(P::(char list list × char list exp) prog) ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⋀l₀::sfields. P ⊢ ⟨e,(a, l₀ ++ aa, b),ba⟩ → ⟨e',(ab, l₀ ++ ac, bb),b'⟩⟧ ⟹ P ⊢ ⟨e∙M(es),(a, l₀ ++ aa, b),ba⟩ → ⟨e'∙M(es),(ab, l₀ ++ ac, bb),b'⟩› 35. ‹⋀(es::char list exp list) (a::heap) (aa::sfields) (b::sheap) (ba::bool) (es'::char list exp list) (ab::heap) (ac::sfields) (bb::sheap) (b'::bool) (v::val) (M::char list) l₀::sfields. ⟦(P::(char list list × char list exp) prog) ⊢ ⟨es,(a, aa, b),ba⟩ [→] ⟨es',(ab, ac, bb),b'⟩; ⋀l₀::sfields. P ⊢ ⟨es,(a, l₀ ++ aa, b),ba⟩ [→] ⟨es',(ab, l₀ ++ ac, bb),b'⟩⟧ ⟹ P ⊢ ⟨Val v∙M(es),(a, l₀ ++ aa, b),ba⟩ → ⟨Val v∙M(es'),(ab, l₀ ++ ac, bb),b'⟩› 36. ‹⋀(M::char list) (vs::val list) (a::heap) (aa::sfields) (b::sheap) (ba::bool) l₀::sfields. (P::(char list list × char list exp) prog) ⊢ ⟨null∙M(map Val vs),(a, l₀ ++ aa, b),ba⟩ → ⟨THROW NullPointer,(a, l₀ ++ aa, b),ba⟩› 37. ‹⋀(h::heap) (a::nat) (C::char list) (fs::Objects.fields) (M::char list) (vs::val list) (l::sfields) (sh::sheap) (b::bool) l₀::sfields. ⟦h a = ⌊(C, fs)⌋; ∄(b::staticb) (Ts::ty list) (T::ty) (m::char list list × char list exp) D::char list. (P::(char list list × char list exp) prog) ⊢ C sees M, b : Ts→T = m in D⟧ ⟹ P ⊢ ⟨addr a∙M(map Val vs),(h, l₀ ++ l, sh),b⟩ → ⟨THROW NoSuchMethodError,(h, l₀ ++ l, sh),b⟩› 38. ‹⋀(h::heap) (a::nat) (C::char list) (fs::Objects.fields) (M::char list) (Ts::ty list) (T::ty) (aa::char list list) (b::char list exp) (D::char list) (vs::val list) (l::sfields) (sh::sheap) (ba::bool) l₀::sfields. ⟦h a = ⌊(C, fs)⌋; (P::(char list list × char list exp) prog) ⊢ C sees M, Static : Ts→T = (aa, b) in D⟧ ⟹ P ⊢ ⟨addr a∙M(map Val vs),(h, l₀ ++ l, sh),ba⟩ → ⟨THROW IncompatibleClassChangeError,(h, l₀ ++ l, sh),ba⟩› 39. ‹⋀(es::char list exp list) (a::heap) (aa::sfields) (b::sheap) (ba::bool) (es'::char list exp list) (ab::heap) (ac::sfields) (bb::sheap) (b'::bool) (C::char list) (M::char list) l₀::sfields. ⟦(P::(char list list × char list exp) prog) ⊢ ⟨es,(a, aa, b),ba⟩ [→] ⟨es',(ab, ac, bb),b'⟩; ⋀l₀::sfields. P ⊢ ⟨es,(a, l₀ ++ aa, b),ba⟩ [→] ⟨es',(ab, l₀ ++ ac, bb),b'⟩⟧ ⟹ P ⊢ ⟨C∙⇩sM(es),(a, l₀ ++ aa, b),ba⟩ → ⟨C∙⇩sM(es'),(ab, l₀ ++ ac, bb),b'⟩› 40. ‹⋀(C::char list) (M::char list) (Ts::ty list) (T::ty) (pns::char list list) (body::char list exp) (D::char list) (vs::val list) (a::heap) (aa::sfields) (b::sheap) l₀::sfields. ⟦(P::(char list list × char list exp) prog) ⊢ C sees M, Static : Ts→T = (pns, body) in D; length vs = length pns; length Ts = length pns⟧ ⟹ P ⊢ ⟨C∙⇩sM(map Val vs),(a, l₀ ++ aa, b),True⟩ → ⟨blocks (pns, Ts, vs, body),(a, l₀ ++ aa, b),False⟩› 41. ‹⋀(C::char list) (M::char list) (Ts::ty list) (T::ty) (pns::char list list) (body::char list exp) (D::char list) (sh::sheap) (sfs::sfields) (vs::val list) (h::heap) (l::sfields) l₀::sfields. ⟦(P::(char list list × char list exp) prog) ⊢ C sees M, Static : Ts→T = (pns, body) in D; sh D = ⌊(sfs, Done)⌋ ∨ M = clinit ∧ sh D = ⌊(sfs, Processing)⌋⟧ ⟹ P ⊢ ⟨C∙⇩sM(map Val vs),(h, l₀ ++ l, sh),False⟩ → ⟨C∙⇩sM(map Val vs),(h, l₀ ++ l, sh),True⟩› 42. ‹⋀(C::char list) (M::char list) (Ts::ty list) (T::ty) (pns::char list list) (body::char list exp) (D::char list) (sh::sheap) (vs::val list) (h::heap) (l::sfields) l₀::sfields. ⟦(P::(char list list × char list exp) prog) ⊢ C sees M, Static : Ts→T = (pns, body) in D; ∄sfs::sfields. sh D = ⌊(sfs, Done)⌋; M ≠ clinit⟧ ⟹ P ⊢ ⟨C∙⇩sM(map Val vs),(h, l₀ ++ l, sh),False⟩ → ⟨INIT D ([D],False) ← C∙⇩sM(map Val vs),(h, l₀ ++ l, sh),False⟩› 43. ‹⋀(C::char list) (M::char list) (vs::val list) (a::heap) (aa::sfields) (b::sheap) (ba::bool) l₀::sfields. ∄(b::staticb) (Ts::ty list) (T::ty) m::char list list × char list exp. Ex (Method (P::(char list list × char list exp) prog) C M b Ts T m) ⟹ P ⊢ ⟨C∙⇩sM(map Val vs),(a, l₀ ++ aa, b),ba⟩ → ⟨THROW NoSuchMethodError,(a, l₀ ++ aa, b),False⟩› 44. ‹⋀(C::char list) (M::char list) (Ts::ty list) (T::ty) (a::char list list) (b::char list exp) (D::char list) (vs::val list) (aa::heap) (ab::sfields) (ba::sheap) (bb::bool) l₀::sfields. (P::(char list list × char list exp) prog) ⊢ C sees M, NonStatic : Ts→T = (a, b) in D ⟹ P ⊢ ⟨C∙⇩sM(map Val vs),(aa, l₀ ++ ab, ba),bb⟩ → ⟨THROW IncompatibleClassChangeError,(aa, l₀ ++ ab, ba),False⟩› 45. ‹⋀(e::char list exp) (h::heap) (l::sfields) (V::char list) (sh::sheap) (b::bool) (e'::char list exp) (h'::heap) (l'::sfields) (sh'::sheap) (b'::bool) (T::ty) l₀::sfields. ⟦(P::(char list list × char list exp) prog) ⊢ ⟨e,(h, l(V := None), sh),b⟩ → ⟨e',(h', l', sh'),b'⟩; ⋀l₀::sfields. P ⊢ ⟨e,(h, l₀ ++ l(V := None), sh),b⟩ → ⟨e',(h', l₀ ++ l', sh'),b'⟩; l' V = None; ¬ assigned V e⟧ ⟹ P ⊢ ⟨{V:T; e},(h, l₀ ++ l, sh),b⟩ → ⟨{V:T; e'},(h', l₀ ++ l'(V := l V), sh'),b'⟩› 46. ‹⋀(e::char list exp) (h::heap) (l::sfields) (V::char list) (sh::sheap) (b::bool) (e'::char list exp) (h'::heap) (l'::sfields) (sh'::sheap) (b'::bool) (v::val) (T::ty) l₀::sfields. ⟦(P::(char list list × char list exp) prog) ⊢ ⟨e,(h, l(V := None), sh),b⟩ → ⟨e',(h', l', sh'),b'⟩; ⋀l₀::sfields. P ⊢ ⟨e,(h, l₀ ++ l(V := None), sh),b⟩ → ⟨e',(h', l₀ ++ l', sh'),b'⟩; l' V = ⌊v⌋; ¬ assigned V e⟧ ⟹ P ⊢ ⟨{V:T; e},(h, l₀ ++ l, sh),b⟩ → ⟨{V:T; V:=Val v;; e'},(h', l₀ ++ l'(V := l V), sh'),b'⟩› 47. ‹⋀(V::char list) (T::ty) (u::val) (a::heap) (aa::sfields) (b::sheap) (ba::bool) l₀::sfields. (P::(char list list × char list exp) prog) ⊢ ⟨{V:T; Val u},(a, l₀ ++ aa, b),ba⟩ → ⟨Val u,(a, l₀ ++ aa, b),ba⟩› 48. ‹⋀(V::char list) (T::ty) (v::val) (u::val) (a::heap) (aa::sfields) (b::sheap) (ba::bool) l₀::sfields. (P::(char list list × char list exp) prog) ⊢ ⟨{V:T; V:=Val v;; Val u},(a, l₀ ++ aa, b),ba⟩ → ⟨Val u,(a, l₀ ++ aa, b),ba⟩› 49. ‹⋀(e::char list exp) (a::heap) (aa::sfields) (b::sheap) (ba::bool) (e'::char list exp) (ab::heap) (ac::sfields) (bb::sheap) (b'::bool) (e₂::char list exp) l₀::sfields. ⟦(P::(char list list × char list exp) prog) ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⋀l₀::sfields. P ⊢ ⟨e,(a, l₀ ++ aa, b),ba⟩ → ⟨e',(ab, l₀ ++ ac, bb),b'⟩⟧ ⟹ P ⊢ ⟨e;; e₂,(a, l₀ ++ aa, b),ba⟩ → ⟨e';; e₂,(ab, l₀ ++ ac, bb),b'⟩› 50. ‹⋀(v::val) (e₂::char list exp) (a::heap) (aa::sfields) (b::sheap) (ba::bool) l₀::sfields. (P::(char list list × char list exp) prog) ⊢ ⟨Val v;; e₂,(a, l₀ ++ aa, b),ba⟩ → ⟨e₂,(a, l₀ ++ aa, b),ba⟩› 51. ‹⋀(e::char list exp) (a::heap) (aa::sfields) (b::sheap) (ba::bool) (e'::char list exp) (ab::heap) (ac::sfields) (bb::sheap) (b'::bool) (e₁::char list exp) (e₂::char list exp) l₀::sfields. ⟦(P::(char list list × char list exp) prog) ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⋀l₀::sfields. P ⊢ ⟨e,(a, l₀ ++ aa, b),ba⟩ → ⟨e',(ab, l₀ ++ ac, bb),b'⟩⟧ ⟹ P ⊢ ⟨if (e) e₁ else e₂,(a, l₀ ++ aa, b),ba⟩ → ⟨if (e') e₁ else e₂,(ab, l₀ ++ ac, bb),b'⟩› 52. ‹⋀(e₁::char list exp) (e₂::char list exp) (a::heap) (aa::sfields) (b::sheap) (ba::bool) l₀::sfields. (P::(char list list × char list exp) prog) ⊢ ⟨if (true) e₁ else e₂,(a, l₀ ++ aa, b),ba⟩ → ⟨e₁,(a, l₀ ++ aa, b),ba⟩› 53. ‹⋀(e₁::char list exp) (e₂::char list exp) (a::heap) (aa::sfields) (b::sheap) (ba::bool) l₀::sfields. (P::(char list list × char list exp) prog) ⊢ ⟨if (false) e₁ else e₂,(a, l₀ ++ aa, b),ba⟩ → ⟨e₂,(a, l₀ ++ aa, b),ba⟩› 54. ‹⋀(b::char list exp) (c::char list exp) (a::heap) (aa::sfields) (ba::sheap) (b'::bool) l₀::sfields. (P::(char list list × char list exp) prog) ⊢ ⟨while (b) c,(a, l₀ ++ aa, ba),b'⟩ → ⟨if (b) (c;; while (b) c) else unit,(a, l₀ ++ aa, ba),b'⟩› 55. ‹⋀(e::char list exp) (a::heap) (aa::sfields) (b::sheap) (ba::bool) (e'::char list exp) (ab::heap) (ac::sfields) (bb::sheap) (b'::bool) l₀::sfields. ⟦(P::(char list list × char list exp) prog) ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⋀l₀::sfields. P ⊢ ⟨e,(a, l₀ ++ aa, b),ba⟩ → ⟨e',(ab, l₀ ++ ac, bb),b'⟩⟧ ⟹ P ⊢ ⟨throw e,(a, l₀ ++ aa, b),ba⟩ → ⟨throw e',(ab, l₀ ++ ac, bb),b'⟩› 56. ‹⋀(a::heap) (aa::sfields) (b::sheap) (ba::bool) l₀::sfields. (P::(char list list × char list exp) prog) ⊢ ⟨throw null,(a, l₀ ++ aa, b),ba⟩ → ⟨THROW NullPointer,(a, l₀ ++ aa, b),ba⟩› 57. ‹⋀(e::char list exp) (a::heap) (aa::sfields) (b::sheap) (ba::bool) (e'::char list exp) (ab::heap) (ac::sfields) (bb::sheap) (b'::bool) (C::char list) (V::char list) (e₂::char list exp) l₀::sfields. ⟦(P::(char list list × char list exp) prog) ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⋀l₀::sfields. P ⊢ ⟨e,(a, l₀ ++ aa, b),ba⟩ → ⟨e',(ab, l₀ ++ ac, bb),b'⟩⟧ ⟹ P ⊢ ⟨try e catch(C V) e₂,(a, l₀ ++ aa, b),ba⟩ → ⟨try e' catch(C V) e₂,(ab, l₀ ++ ac, bb),b'⟩› 58. ‹⋀(v::val) (C::char list) (V::char list) (e₂::char list exp) (a::heap) (aa::sfields) (b::sheap) (ba::bool) l₀::sfields. (P::(char list list × char list exp) prog) ⊢ ⟨try Val v catch(C V) e₂,(a, l₀ ++ aa, b),ba⟩ → ⟨Val v,(a, l₀ ++ aa, b),ba⟩› 59. ‹⋀(a::heap) (aa::sfields) (b::sheap) (ab::nat) (D::char list) (fs::Objects.fields) (C::char list) (V::char list) (e₂::char list exp) (ba::bool) l₀::sfields. ⟦hp (a, aa, b) ab = ⌊(D, fs)⌋; (P::(char list list × char list exp) prog) ⊢ D ≼⇧* C⟧ ⟹ P ⊢ ⟨try Throw ab catch(C V) e₂,(a, l₀ ++ aa, b),ba⟩ → ⟨{V:Class C; V:=addr ab;; e₂},(a, l₀ ++ aa, b),ba⟩› 60. ‹⋀(a::heap) (aa::sfields) (b::sheap) (ab::nat) (D::char list) (fs::Objects.fields) (C::char list) (V::char list) (e₂::char list exp) (ba::bool) l₀::sfields. ⟦hp (a, aa, b) ab = ⌊(D, fs)⌋; (D, C) ∉ (subcls1 (P::(char list list × char list exp) prog))⇧*⟧ ⟹ P ⊢ ⟨try Throw ab catch(C V) e₂,(a, l₀ ++ aa, b),ba⟩ → ⟨Throw ab,(a, l₀ ++ aa, b),ba⟩› 61. ‹⋀(e::char list exp) (a::heap) (aa::sfields) (b::sheap) (ba::bool) (e'::char list exp) (ab::heap) (ac::sfields) (bb::sheap) (b'::bool) (es::char list exp list) l₀::sfields. ⟦(P::(char list list × char list exp) prog) ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⋀l₀::sfields. P ⊢ ⟨e,(a, l₀ ++ aa, b),ba⟩ → ⟨e',(ab, l₀ ++ ac, bb),b'⟩⟧ ⟹ P ⊢ ⟨e # es,(a, l₀ ++ aa, b),ba⟩ [→] ⟨e' # es,(ab, l₀ ++ ac, bb),b'⟩› 62. ‹⋀(es::char list exp list) (a::heap) (aa::sfields) (b::sheap) (ba::bool) (es'::char list exp list) (ab::heap) (ac::sfields) (bb::sheap) (b'::bool) (v::val) l₀::sfields. ⟦(P::(char list list × char list exp) prog) ⊢ ⟨es,(a, aa, b),ba⟩ [→] ⟨es',(ab, ac, bb),b'⟩; ⋀l₀::sfields. P ⊢ ⟨es,(a, l₀ ++ aa, b),ba⟩ [→] ⟨es',(ab, l₀ ++ ac, bb),b'⟩⟧ ⟹ P ⊢ ⟨Val v # es,(a, l₀ ++ aa, b),ba⟩ [→] ⟨Val v # es',(ab, l₀ ++ ac, bb),b'⟩› 63. ‹⋀(e::char list exp) (C::char list) (b::bool) (a::heap) (aa::sfields) (ba::sheap) (b'::bool) l₀::sfields. ¬ sub_RI e ⟹ (P::(char list list × char list exp) prog) ⊢ ⟨INIT C ([],b) ← e,(a, l₀ ++ aa, ba),b'⟩ → ⟨e,(a, l₀ ++ aa, ba),icheck P C e⟩› 64. ‹⋀(sh::sheap) (C::char list) (C'::char list) (Cs::char list list) (e::char list exp) (h::heap) (l::sfields) (b::bool) l₀::sfields. sh C = None ⟹ (P::(char list list × char list exp) prog) ⊢ ⟨INIT C' (C # Cs,False) ← e,(h, l₀ ++ l, sh),b⟩ → ⟨INIT C' (C # Cs,False) ← e,(h, l₀ ++ l, sh(C ↦ (sblank P C, Prepared))),b⟩› 65. ‹⋀(sh::sheap) (C::char list) (sfs::sfields) (C'::char list) (Cs::char list list) (e::char list exp) (h::heap) (l::sfields) (b::bool) l₀::sfields. sh C = ⌊(sfs, Done)⌋ ⟹ (P::(char list list × char list exp) prog) ⊢ ⟨INIT C' (C # Cs,False) ← e,(h, l₀ ++ l, sh),b⟩ → ⟨INIT C' (Cs,True) ← e,(h, l₀ ++ l, sh),b⟩› 66. ‹⋀(sh::sheap) (C::char list) (sfs::sfields) (C'::char list) (Cs::char list list) (e::char list exp) (h::heap) (l::sfields) (b::bool) l₀::sfields. sh C = ⌊(sfs, Processing)⌋ ⟹ (P::(char list list × char list exp) prog) ⊢ ⟨INIT C' (C # Cs,False) ← e,(h, l₀ ++ l, sh),b⟩ → ⟨INIT C' (Cs,True) ← e,(h, l₀ ++ l, sh),b⟩› 67. ‹⋀(sh::sheap) (C::char list) (sfs::sfields) (C'::char list) (Cs::char list list) (e::char list exp) (h::heap) (l::sfields) (b::bool) l₀::sfields. sh C = ⌊(sfs, Error)⌋ ⟹ (P::(char list list × char list exp) prog) ⊢ ⟨INIT C' (C # Cs,False) ← e,(h, l₀ ++ l, sh),b⟩ → ⟨RI (C,THROW NoClassDefFoundError) ; Cs ← e,(h, l₀ ++ l, sh),b⟩› 68. ‹⋀(sh::sheap) (C::char list) (sfs::sfields) (sh'::sheap) (C'::char list) (Cs::char list list) (e::char list exp) (h::heap) (l::sfields) (b::bool) l₀::sfields. ⟦sh C = ⌊(sfs, Prepared)⌋; C = Object; sh' = sh(C ↦ (sfs, Processing))⟧ ⟹ (P::(char list list × char list exp) prog) ⊢ ⟨INIT C' (C # Cs,False) ← e,(h, l₀ ++ l, sh),b⟩ → ⟨INIT C' (C # Cs,True) ← e,(h, l₀ ++ l, sh'),b⟩› 69. ‹⋀(sh::sheap) (C::char list) (sfs::sfields) (D::char list) (a::fdecl list) (b::(char list list × char list exp) mdecl list) (sh'::sheap) (C'::char list) (Cs::char list list) (e::char list exp) (h::heap) (l::sfields) (ba::bool) l₀::sfields. ⟦sh C = ⌊(sfs, Prepared)⌋; C ≠ Object; class (P::(char list list × char list exp) prog) C = ⌊(D, a, b)⌋; sh' = sh(C ↦ (sfs, Processing))⟧ ⟹ P ⊢ ⟨INIT C' (C # Cs,False) ← e,(h, l₀ ++ l, sh),ba⟩ → ⟨INIT C' (D # C # Cs,False) ← e,(h, l₀ ++ l, sh'),ba⟩› 70. ‹⋀(C'::char list) (C::char list) (Cs::char list list) (e::char list exp) (h::heap) (l::sfields) (sh::sheap) (b::bool) l₀::sfields. (P::(char list list × char list exp) prog) ⊢ ⟨INIT C' (C # Cs,True) ← e,(h, l₀ ++ l, sh),b⟩ → ⟨RI (C,C∙⇩sclinit([])) ; Cs ← e,(h, l₀ ++ l, sh),b⟩› 71. ‹⋀(e::char list exp) (a::heap) (aa::sfields) (b::sheap) (ba::bool) (e'::char list exp) (ab::heap) (ac::sfields) (bb::sheap) (b'::bool) (C::char list) (Cs::char list list) (e₀::char list exp) l₀::sfields. ⟦(P::(char list list × char list exp) prog) ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⋀l₀::sfields. P ⊢ ⟨e,(a, l₀ ++ aa, b),ba⟩ → ⟨e',(ab, l₀ ++ ac, bb),b'⟩⟧ ⟹ P ⊢ ⟨RI (C,e) ; Cs ← e₀,(a, l₀ ++ aa, b),ba⟩ → ⟨RI (C,e') ; Cs ← e₀,(ab, l₀ ++ ac, bb),b'⟩› 72. ‹⋀(sh::sheap) (C::char list) (sfs::sfields) (i::init_state) (sh'::sheap) (C'::char list) (Cs::char list list) (v::val) (e::char list exp) (h::heap) (l::sfields) (b::bool) l₀::sfields. ⟦sh C = ⌊(sfs, i)⌋; sh' = sh(C ↦ (sfs, Done)); C' = last (C # Cs)⟧ ⟹ (P::(char list list × char list exp) prog) ⊢ ⟨RI (C,Val v) ; Cs ← e,(h, l₀ ++ l, sh),b⟩ → ⟨INIT C' (Cs,True) ← e,(h, l₀ ++ l, sh'),b⟩› 73. ‹⋀(C::char list) (e::char list exp) (a::heap) (aa::sfields) (b::sheap) (ba::bool) l₀::sfields. (P::(char list list × char list exp) prog) ⊢ ⟨Cast C (throw e),(a, l₀ ++ aa, b),ba⟩ → ⟨throw e,(a, l₀ ++ aa, b),ba⟩› 74. ‹⋀(e::char list exp) (bop::bop) (e₂::char list exp) (a::heap) (aa::sfields) (b::sheap) (ba::bool) l₀::sfields. (P::(char list list × char list exp) prog) ⊢ ⟨throw e «bop» e₂,(a, l₀ ++ aa, b),ba⟩ → ⟨throw e,(a, l₀ ++ aa, b),ba⟩› 75. ‹⋀(v₁::val) (bop::bop) (e::char list exp) (a::heap) (aa::sfields) (b::sheap) (ba::bool) l₀::sfields. (P::(char list list × char list exp) prog) ⊢ ⟨Val v₁ «bop» throw e,(a, l₀ ++ aa, b),ba⟩ → ⟨throw e,(a, l₀ ++ aa, b),ba⟩› 76. ‹⋀(V::char list) (e::char list exp) (a::heap) (aa::sfields) (b::sheap) (ba::bool) l₀::sfields. (P::(char list list × char list exp) prog) ⊢ ⟨V:=throw e,(a, l₀ ++ aa, b),ba⟩ → ⟨throw e,(a, l₀ ++ aa, b),ba⟩› 77. ‹⋀(e::char list exp) (F::char list) (D::char list) (a::heap) (aa::sfields) (b::sheap) (ba::bool) l₀::sfields. (P::(char list list × char list exp) prog) ⊢ ⟨throw e∙F{D},(a, l₀ ++ aa, b),ba⟩ → ⟨throw e,(a, l₀ ++ aa, b),ba⟩› 78. ‹⋀(e::char list exp) (F::char list) (D::char list) (e₂::char list exp) (a::heap) (aa::sfields) (b::sheap) (ba::bool) l₀::sfields. (P::(char list list × char list exp) prog) ⊢ ⟨throw e∙F{D} := e₂,(a, l₀ ++ aa, b),ba⟩ → ⟨throw e,(a, l₀ ++ aa, b),ba⟩› 79. ‹⋀(v::val) (F::char list) (D::char list) (e::char list exp) (a::heap) (aa::sfields) (b::sheap) (ba::bool) l₀::sfields. (P::(char list list × char list exp) prog) ⊢ ⟨Val v∙F{D} := throw e,(a, l₀ ++ aa, b),ba⟩ → ⟨throw e,(a, l₀ ++ aa, b),ba⟩› 80. ‹⋀(C::char list) (F::char list) (D::char list) (e::char list exp) (a::heap) (aa::sfields) (b::sheap) (ba::bool) l₀::sfields. (P::(char list list × char list exp) prog) ⊢ ⟨C∙⇩sF{D} := throw e,(a, l₀ ++ aa, b),ba⟩ → ⟨throw e,(a, l₀ ++ aa, b),ba⟩› 81. ‹⋀(e::char list exp) (M::char list) (es::char list exp list) (a::heap) (aa::sfields) (b::sheap) (ba::bool) l₀::sfields. (P::(char list list × char list exp) prog) ⊢ ⟨throw e∙M(es),(a, l₀ ++ aa, b),ba⟩ → ⟨throw e,(a, l₀ ++ aa, b),ba⟩› 82. ‹⋀(es::char list exp list) (vs::val list) (e::char list exp) (es'::char list exp list) (v::val) (M::char list) (a::heap) (aa::sfields) (b::sheap) (ba::bool) l₀::sfields. es = map Val vs @ throw e # es' ⟹ (P::(char list list × char list exp) prog) ⊢ ⟨Val v∙M(es),(a, l₀ ++ aa, b),ba⟩ → ⟨throw e,(a, l₀ ++ aa, b),ba⟩› 83. ‹⋀(es::char list exp list) (vs::val list) (e::char list exp) (es'::char list exp list) (C::char list) (M::char list) (a::heap) (aa::sfields) (b::sheap) (ba::bool) l₀::sfields. es = map Val vs @ throw e # es' ⟹ (P::(char list list × char list exp) prog) ⊢ ⟨C∙⇩sM(es),(a, l₀ ++ aa, b),ba⟩ → ⟨throw e,(a, l₀ ++ aa, b),ba⟩› 84. ‹⋀(V::char list) (T::ty) (a::nat) (aa::heap) (ab::sfields) (b::sheap) (ba::bool) l₀::sfields. (P::(char list list × char list exp) prog) ⊢ ⟨{V:T; Throw a},(aa, l₀ ++ ab, b),ba⟩ → ⟨Throw a,(aa, l₀ ++ ab, b),ba⟩› 85. ‹⋀(V::char list) (T::ty) (v::val) (a::nat) (aa::heap) (ab::sfields) (b::sheap) (ba::bool) l₀::sfields. (P::(char list list × char list exp) prog) ⊢ ⟨{V:T; V:=Val v;; Throw a},(aa, l₀ ++ ab, b),ba⟩ → ⟨Throw a,(aa, l₀ ++ ab, b),ba⟩› 86. ‹⋀(e::char list exp) (e₂::char list exp) (a::heap) (aa::sfields) (b::sheap) (ba::bool) l₀::sfields. (P::(char list list × char list exp) prog) ⊢ ⟨throw e;; e₂,(a, l₀ ++ aa, b),ba⟩ → ⟨throw e,(a, l₀ ++ aa, b),ba⟩› 87. ‹⋀(e::char list exp) (e₁::char list exp) (e₂::char list exp) (a::heap) (aa::sfields) (b::sheap) (ba::bool) l₀::sfields. (P::(char list list × char list exp) prog) ⊢ ⟨if (throw e) e₁ else e₂,(a, l₀ ++ aa, b),ba⟩ → ⟨throw e,(a, l₀ ++ aa, b),ba⟩› 88. ‹⋀(e::char list exp) (a::heap) (aa::sfields) (b::sheap) (ba::bool) l₀::sfields. (P::(char list list × char list exp) prog) ⊢ ⟨throw (throw e),(a, l₀ ++ aa, b),ba⟩ → ⟨throw e,(a, l₀ ++ aa, b),ba⟩› 89. ‹⋀(sh::sheap) (C::char list) (sfs::sfields) (i::init_state) (sh'::sheap) (a::nat) (D::char list) (Cs::char list list) (e::char list exp) (h::heap) (l::sfields) (b::bool) l₀::sfields. ⟦sh C = ⌊(sfs, i)⌋; sh' = sh(C ↦ (sfs, Error))⟧ ⟹ (P::(char list list × char list exp) prog) ⊢ ⟨RI (C,Throw a) ; D # Cs ← e,(h, l₀ ++ l, sh),b⟩ → ⟨RI (D,Throw a) ; Cs ← e,(h, l₀ ++ l, sh'),b⟩› 90. ‹⋀(sh::sheap) (C::char list) (sfs::sfields) (i::init_state) (sh'::sheap) (a::nat) (e::char list exp) (h::heap) (l::sfields) (b::bool) l₀::sfields. ⟦sh C = ⌊(sfs, i)⌋; sh' = sh(C ↦ (sfs, Error))⟧ ⟹ (P::(char list list × char list exp) prog) ⊢ ⟨RI (C,Throw a) ; [] ← e,(h, l₀ ++ l, sh),b⟩ → ⟨Throw a,(h, l₀ ++ l, sh'),b⟩›*) case (BlockRedNone e h l V sh b e' h' l' sh' b' T l₀) (*‹P ⊢ ⟨e,(h, l(V := None), sh),b⟩ → ⟨e',(h', l', sh'),b'⟩› ‹P ⊢ ⟨e,(h, ?l₀ ++ l(V := None), sh),b⟩ → ⟨e',(h', ?l₀ ++ l', sh'),b'⟩› ‹l' V = None› ‹¬ assigned (V::char list) (e::char list exp)›*) have IH: "⋀l₀. P ⊢ ⟨e,(h, l₀ ++ l(V := None), sh),b⟩ → ⟨e',(h', l₀ ++ l', sh'),b'⟩" and l'V: "l' V = None" and unass: "¬ assigned V e" (*goals: 1. ‹⋀l₀. P ⊢ ⟨e,(h, l₀ ++ l(V := None), sh),b⟩ → ⟨e',(h', l₀ ++ l', sh'),b'⟩› 2. ‹l' V = None› 3. ‹¬ assigned V e› discuss goal 1*) apply fact (*discuss goal 2*) apply fact (*discuss goal 3*) apply fact (*proven 3 subgoals*) . have "l₀(V := None) ++ l(V := None) = (l₀ ++ l)(V := None)" by (simp add:fun_eq_iff (*‹(?f = ?g) = (∀x. ?f x = ?g x)›*) map_add_def (*‹?m1.0 ++ ?m2.0 = (λx. case ?m2.0 x of None ⇒ ?m1.0 x | ⌊y⌋ ⇒ ⌊y⌋)›*)) hence IH': "P ⊢ ⟨e,(h, (l₀++l)(V := None), sh),b⟩ → ⟨e',(h', l₀(V := None) ++ l', sh'),b'⟩" using IH[of "l₀(V := None)"] (*‹P ⊢ ⟨e,(h, l₀(V := None) ++ l(V := None), sh),b⟩ → ⟨e',(h', l₀(V := None) ++ l', sh'),b'⟩›*) by simp have "(l₀(V := None) ++ l')(V := (l₀ ++ l) V) = l₀ ++ l'(V := l V)" by (simp add:fun_eq_iff (*‹(?f = ?g) = (∀x. ?f x = ?g x)›*) map_add_def (*‹?m1.0 ++ ?m2.0 = (λx. case ?m2.0 x of None ⇒ ?m1.0 x | ⌊y⌋ ⇒ ⌊y⌋)›*)) with red_reds.BlockRedNone[OF IH' _ unass] (*‹(l₀(V := None) ++ l') V = None ⟹ P ⊢ ⟨{V:?T; e},(h, l₀ ++ l, sh),b⟩ → ⟨{V:?T; e'},(h', (l₀(V := None) ++ l')(V := (l₀ ++ l) V), sh'),b'⟩›*) l'V (*‹l' V = None›*) show "?case" (*goal: ‹P ⊢ ⟨{V:T; e},(h, l₀ ++ l, sh),b⟩ → ⟨{V:T; e'},(h', l₀ ++ l'(V := l V), sh'),b'⟩›*) by (simp add: map_add_def (*‹?m1.0 ++ ?m2.0 = (λx. case ?m2.0 x of None ⇒ ?m1.0 x | ⌊y⌋ ⇒ ⌊y⌋)›*)) next (*goals: 1. ‹⋀h a C FDTs h' l sh l₀. ⟦new_Addr h = ⌊a⌋; P ⊢ C has_fields FDTs; h' = h(a ↦ blank P C)⟧ ⟹ P ⊢ ⟨new C,(h, l₀ ++ l, sh),True⟩ → ⟨addr a,(h', l₀ ++ l, sh),False⟩› 2. ‹⋀h C l sh l₀. ⟦new_Addr h = None; is_class P C⟧ ⟹ P ⊢ ⟨new C,(h, l₀ ++ l, sh),True⟩ → ⟨THROW OutOfMemory,(h, l₀ ++ l, sh),False⟩› 3. ‹⋀sh C sfs h l l₀. sh C = ⌊(sfs, Done)⌋ ⟹ P ⊢ ⟨new C,(h, l₀ ++ l, sh),False⟩ → ⟨new C,(h, l₀ ++ l, sh),True⟩› 4. ‹⋀sh C h l l₀. ⟦∄sfs. sh C = ⌊(sfs, Done)⌋; is_class P C⟧ ⟹ P ⊢ ⟨new C,(h, l₀ ++ l, sh),False⟩ → ⟨INIT C ([C],False) ← new C,(h, l₀ ++ l, sh),False⟩› 5. ‹⋀e a aa b ba e' ab ac bb b' C l₀. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⋀l₀. P ⊢ ⟨e,(a, l₀ ++ aa, b),ba⟩ → ⟨e',(ab, l₀ ++ ac, bb),b'⟩⟧ ⟹ P ⊢ ⟨Cast C e,(a, l₀ ++ aa, b),ba⟩ → ⟨Cast C e',(ab, l₀ ++ ac, bb),b'⟩› 6. ‹⋀C a aa b ba l₀. P ⊢ ⟨Cast C null,(a, l₀ ++ aa, b),ba⟩ → ⟨null,(a, l₀ ++ aa, b),ba⟩› 7. ‹⋀e a aa b ba e' ab ac bb b' bop e₂ l₀. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⋀l₀. P ⊢ ⟨e,(a, l₀ ++ aa, b),ba⟩ → ⟨e',(ab, l₀ ++ ac, bb),b'⟩⟧ ⟹ P ⊢ ⟨e «bop» e₂,(a, l₀ ++ aa, b),ba⟩ → ⟨e' «bop» e₂,(ab, l₀ ++ ac, bb),b'⟩› 8. ‹⋀e a aa b ba e' ab ac bb b' v₁ bop l₀. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⋀l₀. P ⊢ ⟨e,(a, l₀ ++ aa, b),ba⟩ → ⟨e',(ab, l₀ ++ ac, bb),b'⟩⟧ ⟹ P ⊢ ⟨Val v₁ «bop» e,(a, l₀ ++ aa, b),ba⟩ → ⟨Val v₁ «bop» e',(ab, l₀ ++ ac, bb),b'⟩› 9. ‹⋀bop v₁ v₂ v a aa b ba l₀. binop (bop, v₁, v₂) = ⌊v⌋ ⟹ P ⊢ ⟨Val v₁ «bop» Val v₂,(a, l₀ ++ aa, b),ba⟩ → ⟨Val v,(a, l₀ ++ aa, b),ba⟩› 10. ‹⋀l V v h sh b l₀. l V = ⌊v⌋ ⟹ P ⊢ ⟨Var V,(h, l₀ ++ l, sh),b⟩ → ⟨Val v,(h, l₀ ++ l, sh),b⟩› 11. ‹⋀e a aa b ba e' ab ac bb b' V l₀. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⋀l₀. P ⊢ ⟨e,(a, l₀ ++ aa, b),ba⟩ → ⟨e',(ab, l₀ ++ ac, bb),b'⟩⟧ ⟹ P ⊢ ⟨V:=e,(a, l₀ ++ aa, b),ba⟩ → ⟨V:=e',(ab, l₀ ++ ac, bb),b'⟩› 12. ‹⋀V v h l sh b l₀. P ⊢ ⟨V:=Val v,(h, l₀ ++ l, sh),b⟩ → ⟨unit,(h, l₀ ++ l(V ↦ v), sh),b⟩› 13. ‹⋀e a aa b ba e' ab ac bb b' F D l₀. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⋀l₀. P ⊢ ⟨e,(a, l₀ ++ aa, b),ba⟩ → ⟨e',(ab, l₀ ++ ac, bb),b'⟩⟧ ⟹ P ⊢ ⟨e∙F{D},(a, l₀ ++ aa, b),ba⟩ → ⟨e'∙F{D},(ab, l₀ ++ ac, bb),b'⟩› 14. ‹⋀F D a aa b ba l₀. P ⊢ ⟨null∙F{D},(a, l₀ ++ aa, b),ba⟩ → ⟨THROW NullPointer,(a, l₀ ++ aa, b),ba⟩› 15. ‹⋀h a C fs F D l sh b l₀. ⟦h a = ⌊(C, fs)⌋; ∄b t. P ⊢ C has F,b:t in D⟧ ⟹ P ⊢ ⟨addr a∙F{D},(h, l₀ ++ l, sh),b⟩ → ⟨THROW NoSuchFieldError,(h, l₀ ++ l, sh),b⟩› 16. ‹⋀h a C fs F t D l sh b l₀. ⟦h a = ⌊(C, fs)⌋; P ⊢ C has F,Static:t in D⟧ ⟹ P ⊢ ⟨addr a∙F{D},(h, l₀ ++ l, sh),b⟩ → ⟨THROW IncompatibleClassChangeError,(h, l₀ ++ l, sh),b⟩› 17. ‹⋀C F t D sh sfs i v h l l₀. ⟦P ⊢ C has F,Static:t in D; sh D = ⌊(sfs, i)⌋; sfs F = ⌊v⌋⟧ ⟹ P ⊢ ⟨C∙⇩sF{D},(h, l₀ ++ l, sh),True⟩ → ⟨Val v,(h, l₀ ++ l, sh),False⟩› 18. ‹⋀C F t D sh sfs h l l₀. ⟦P ⊢ C has F,Static:t in D; sh D = ⌊(sfs, Done)⌋⟧ ⟹ P ⊢ ⟨C∙⇩sF{D},(h, l₀ ++ l, sh),False⟩ → ⟨C∙⇩sF{D},(h, l₀ ++ l, sh),True⟩› 19. ‹⋀C F t D sh h l l₀. ⟦P ⊢ C has F,Static:t in D; ∄sfs. sh D = ⌊(sfs, Done)⌋⟧ ⟹ P ⊢ ⟨C∙⇩sF{D},(h, l₀ ++ l, sh),False⟩ → ⟨INIT D ([D],False) ← C∙⇩sF{D},(h, l₀ ++ l, sh),False⟩› 20. ‹⋀C F D h l sh b l₀. ∄b t. P ⊢ C has F,b:t in D ⟹ P ⊢ ⟨C∙⇩sF{D},(h, l₀ ++ l, sh),b⟩ → ⟨THROW NoSuchFieldError,(h, l₀ ++ l, sh),False⟩› 21. ‹⋀C F t D h l sh b l₀. P ⊢ C has F,NonStatic:t in D ⟹ P ⊢ ⟨C∙⇩sF{D},(h, l₀ ++ l, sh),b⟩ → ⟨THROW IncompatibleClassChangeError,(h, l₀ ++ l, sh),False⟩› 22. ‹⋀e a aa b ba e' ab ac bb b' F D e₂ l₀. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⋀l₀. P ⊢ ⟨e,(a, l₀ ++ aa, b),ba⟩ → ⟨e',(ab, l₀ ++ ac, bb),b'⟩⟧ ⟹ P ⊢ ⟨e∙F{D} := e₂,(a, l₀ ++ aa, b),ba⟩ → ⟨e'∙F{D} := e₂,(ab, l₀ ++ ac, bb),b'⟩› 23. ‹⋀e a aa b ba e' ab ac bb b' v F D l₀. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⋀l₀. P ⊢ ⟨e,(a, l₀ ++ aa, b),ba⟩ → ⟨e',(ab, l₀ ++ ac, bb),b'⟩⟧ ⟹ P ⊢ ⟨Val v∙F{D} := e,(a, l₀ ++ aa, b),ba⟩ → ⟨Val v∙F{D} := e',(ab, l₀ ++ ac, bb),b'⟩› 24. ‹⋀C F t D h a fs v l sh b l₀. ⟦P ⊢ C has F,NonStatic:t in D; h a = ⌊(C, fs)⌋⟧ ⟹ P ⊢ ⟨addr a∙F{D} := Val v,(h, l₀ ++ l, sh),b⟩ → ⟨unit,(h(a ↦ (C, fs((F, D) ↦ v))), l₀ ++ l, sh),b⟩› 25. ‹⋀F D v a aa b ba l₀. P ⊢ ⟨null∙F{D} := Val v,(a, l₀ ++ aa, b),ba⟩ → ⟨THROW NullPointer,(a, l₀ ++ aa, b),ba⟩› 26. ‹⋀h a C fs F D v l sh b l₀. ⟦h a = ⌊(C, fs)⌋; ∄b t. P ⊢ C has F,b:t in D⟧ ⟹ P ⊢ ⟨addr a∙F{D} := Val v,(h, l₀ ++ l, sh),b⟩ → ⟨THROW NoSuchFieldError,(h, l₀ ++ l, sh),b⟩› 27. ‹⋀h a C fs F t D v l sh b l₀. ⟦h a = ⌊(C, fs)⌋; P ⊢ C has F,Static:t in D⟧ ⟹ P ⊢ ⟨addr a∙F{D} := Val v,(h, l₀ ++ l, sh),b⟩ → ⟨THROW IncompatibleClassChangeError,(h, l₀ ++ l, sh),b⟩› 28. ‹⋀e a aa b ba e' ab ac bb b' C F D l₀. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⋀l₀. P ⊢ ⟨e,(a, l₀ ++ aa, b),ba⟩ → ⟨e',(ab, l₀ ++ ac, bb),b'⟩⟧ ⟹ P ⊢ ⟨C∙⇩sF{D} := e,(a, l₀ ++ aa, b),ba⟩ → ⟨C∙⇩sF{D} := e',(ab, l₀ ++ ac, bb),b'⟩› 29. ‹⋀C F t D sh sfs i sfs' v sh' h l l₀. ⟦P ⊢ C has F,Static:t in D; sh D = ⌊(sfs, i)⌋; sfs' = sfs(F ↦ v); sh' = sh(D ↦ (sfs', i))⟧ ⟹ P ⊢ ⟨C∙⇩sF{D} := Val v,(h, l₀ ++ l, sh),True⟩ → ⟨unit,(h, l₀ ++ l, sh'),False⟩› 30. ‹⋀C F t D sh sfs v h l l₀. ⟦P ⊢ C has F,Static:t in D; sh D = ⌊(sfs, Done)⌋⟧ ⟹ P ⊢ ⟨C∙⇩sF{D} := Val v,(h, l₀ ++ l, sh),False⟩ → ⟨C∙⇩sF{D} := Val v,(h, l₀ ++ l, sh),True⟩› 31. ‹⋀C F t D sh v h l l₀. ⟦P ⊢ C has F,Static:t in D; ∄sfs. sh D = ⌊(sfs, Done)⌋⟧ ⟹ P ⊢ ⟨C∙⇩sF{D} := Val v,(h, l₀ ++ l, sh),False⟩ → ⟨INIT D ([D],False) ← C∙⇩sF{D} := Val v,(h, l₀ ++ l, sh),False⟩› 32. ‹⋀C F D v a aa b ba l₀. ∄b t. P ⊢ C has F,b:t in D ⟹ P ⊢ ⟨C∙⇩sF{D} := Val v,(a, l₀ ++ aa, b),ba⟩ → ⟨THROW NoSuchFieldError,(a, l₀ ++ aa, b),False⟩› 33. ‹⋀C F t D v a aa b ba l₀. P ⊢ C has F,NonStatic:t in D ⟹ P ⊢ ⟨C∙⇩sF{D} := Val v,(a, l₀ ++ aa, b),ba⟩ → ⟨THROW IncompatibleClassChangeError,(a, l₀ ++ aa, b),False⟩› 34. ‹⋀e a aa b ba e' ab ac bb b' M es l₀. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⋀l₀. P ⊢ ⟨e,(a, l₀ ++ aa, b),ba⟩ → ⟨e',(ab, l₀ ++ ac, bb),b'⟩⟧ ⟹ P ⊢ ⟨e∙M(es),(a, l₀ ++ aa, b),ba⟩ → ⟨e'∙M(es),(ab, l₀ ++ ac, bb),b'⟩› 35. ‹⋀es a aa b ba es' ab ac bb b' v M l₀. ⟦P ⊢ ⟨es,(a, aa, b),ba⟩ [→] ⟨es',(ab, ac, bb),b'⟩; ⋀l₀. P ⊢ ⟨es,(a, l₀ ++ aa, b),ba⟩ [→] ⟨es',(ab, l₀ ++ ac, bb),b'⟩⟧ ⟹ P ⊢ ⟨Val v∙M(es),(a, l₀ ++ aa, b),ba⟩ → ⟨Val v∙M(es'),(ab, l₀ ++ ac, bb),b'⟩› 36. ‹⋀M vs a aa b ba l₀. P ⊢ ⟨null∙M(map Val vs),(a, l₀ ++ aa, b),ba⟩ → ⟨THROW NullPointer,(a, l₀ ++ aa, b),ba⟩› 37. ‹⋀h a C fs M vs l sh b l₀. ⟦h a = ⌊(C, fs)⌋; ∄b Ts T m D. P ⊢ C sees M, b : Ts→T = m in D⟧ ⟹ P ⊢ ⟨addr a∙M(map Val vs),(h, l₀ ++ l, sh),b⟩ → ⟨THROW NoSuchMethodError,(h, l₀ ++ l, sh),b⟩› 38. ‹⋀h a C fs M Ts T aa b D vs l sh ba l₀. ⟦h a = ⌊(C, fs)⌋; P ⊢ C sees M, Static : Ts→T = (aa, b) in D⟧ ⟹ P ⊢ ⟨addr a∙M(map Val vs),(h, l₀ ++ l, sh),ba⟩ → ⟨THROW IncompatibleClassChangeError,(h, l₀ ++ l, sh),ba⟩› 39. ‹⋀es a aa b ba es' ab ac bb b' C M l₀. ⟦P ⊢ ⟨es,(a, aa, b),ba⟩ [→] ⟨es',(ab, ac, bb),b'⟩; ⋀l₀. P ⊢ ⟨es,(a, l₀ ++ aa, b),ba⟩ [→] ⟨es',(ab, l₀ ++ ac, bb),b'⟩⟧ ⟹ P ⊢ ⟨C∙⇩sM(es),(a, l₀ ++ aa, b),ba⟩ → ⟨C∙⇩sM(es'),(ab, l₀ ++ ac, bb),b'⟩› 40. ‹⋀C M Ts T pns body D vs a aa b l₀. ⟦P ⊢ C sees M, Static : Ts→T = (pns, body) in D; length vs = length pns; length Ts = length pns⟧ ⟹ P ⊢ ⟨C∙⇩sM(map Val vs),(a, l₀ ++ aa, b),True⟩ → ⟨blocks (pns, Ts, vs, body),(a, l₀ ++ aa, b),False⟩› 41. ‹⋀C M Ts T pns body D sh sfs vs h l l₀. ⟦P ⊢ C sees M, Static : Ts→T = (pns, body) in D; sh D = ⌊(sfs, Done)⌋ ∨ M = clinit ∧ sh D = ⌊(sfs, Processing)⌋⟧ ⟹ P ⊢ ⟨C∙⇩sM(map Val vs),(h, l₀ ++ l, sh),False⟩ → ⟨C∙⇩sM(map Val vs),(h, l₀ ++ l, sh),True⟩› 42. ‹⋀C M Ts T pns body D sh vs h l l₀. ⟦P ⊢ C sees M, Static : Ts→T = (pns, body) in D; ∄sfs. sh D = ⌊(sfs, Done)⌋; M ≠ clinit⟧ ⟹ P ⊢ ⟨C∙⇩sM(map Val vs),(h, l₀ ++ l, sh),False⟩ → ⟨INIT D ([D],False) ← C∙⇩sM(map Val vs),(h, l₀ ++ l, sh),False⟩› 43. ‹⋀C M vs a aa b ba l₀. ∄b Ts T m. Ex (Method P C M b Ts T m) ⟹ P ⊢ ⟨C∙⇩sM(map Val vs),(a, l₀ ++ aa, b),ba⟩ → ⟨THROW NoSuchMethodError,(a, l₀ ++ aa, b),False⟩› 44. ‹⋀C M Ts T a b D vs aa ab ba bb l₀. P ⊢ C sees M, NonStatic : Ts→T = (a, b) in D ⟹ P ⊢ ⟨C∙⇩sM(map Val vs),(aa, l₀ ++ ab, ba),bb⟩ → ⟨THROW IncompatibleClassChangeError,(aa, l₀ ++ ab, ba),False⟩› 45. ‹⋀e h l V sh b e' h' l' sh' b' v T l₀. ⟦P ⊢ ⟨e,(h, l(V := None), sh),b⟩ → ⟨e',(h', l', sh'),b'⟩; ⋀l₀. P ⊢ ⟨e,(h, l₀ ++ l(V := None), sh),b⟩ → ⟨e',(h', l₀ ++ l', sh'),b'⟩; l' V = ⌊v⌋; ¬ assigned V e⟧ ⟹ P ⊢ ⟨{V:T; e},(h, l₀ ++ l, sh),b⟩ → ⟨{V:T; V:=Val v;; e'},(h', l₀ ++ l'(V := l V), sh'),b'⟩› 46. ‹⋀V T u a aa b ba l₀. P ⊢ ⟨{V:T; Val u},(a, l₀ ++ aa, b),ba⟩ → ⟨Val u,(a, l₀ ++ aa, b),ba⟩› 47. ‹⋀V T v u a aa b ba l₀. P ⊢ ⟨{V:T; V:=Val v;; Val u},(a, l₀ ++ aa, b),ba⟩ → ⟨Val u,(a, l₀ ++ aa, b),ba⟩› 48. ‹⋀e a aa b ba e' ab ac bb b' e₂ l₀. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⋀l₀. P ⊢ ⟨e,(a, l₀ ++ aa, b),ba⟩ → ⟨e',(ab, l₀ ++ ac, bb),b'⟩⟧ ⟹ P ⊢ ⟨e;; e₂,(a, l₀ ++ aa, b),ba⟩ → ⟨e';; e₂,(ab, l₀ ++ ac, bb),b'⟩› 49. ‹⋀v e₂ a aa b ba l₀. P ⊢ ⟨Val v;; e₂,(a, l₀ ++ aa, b),ba⟩ → ⟨e₂,(a, l₀ ++ aa, b),ba⟩› 50. ‹⋀e a aa b ba e' ab ac bb b' e₁ e₂ l₀. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⋀l₀. P ⊢ ⟨e,(a, l₀ ++ aa, b),ba⟩ → ⟨e',(ab, l₀ ++ ac, bb),b'⟩⟧ ⟹ P ⊢ ⟨if (e) e₁ else e₂,(a, l₀ ++ aa, b),ba⟩ → ⟨if (e') e₁ else e₂,(ab, l₀ ++ ac, bb),b'⟩› 51. ‹⋀e₁ e₂ a aa b ba l₀. P ⊢ ⟨if (true) e₁ else e₂,(a, l₀ ++ aa, b),ba⟩ → ⟨e₁,(a, l₀ ++ aa, b),ba⟩› 52. ‹⋀e₁ e₂ a aa b ba l₀. P ⊢ ⟨if (false) e₁ else e₂,(a, l₀ ++ aa, b),ba⟩ → ⟨e₂,(a, l₀ ++ aa, b),ba⟩› 53. ‹⋀b c a aa ba b' l₀. P ⊢ ⟨while (b) c,(a, l₀ ++ aa, ba),b'⟩ → ⟨if (b) (c;; while (b) c) else unit,(a, l₀ ++ aa, ba),b'⟩› 54. ‹⋀e a aa b ba e' ab ac bb b' l₀. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⋀l₀. P ⊢ ⟨e,(a, l₀ ++ aa, b),ba⟩ → ⟨e',(ab, l₀ ++ ac, bb),b'⟩⟧ ⟹ P ⊢ ⟨throw e,(a, l₀ ++ aa, b),ba⟩ → ⟨throw e',(ab, l₀ ++ ac, bb),b'⟩› 55. ‹⋀a aa b ba l₀. P ⊢ ⟨throw null,(a, l₀ ++ aa, b),ba⟩ → ⟨THROW NullPointer,(a, l₀ ++ aa, b),ba⟩› 56. ‹⋀e a aa b ba e' ab ac bb b' C V e₂ l₀. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⋀l₀. P ⊢ ⟨e,(a, l₀ ++ aa, b),ba⟩ → ⟨e',(ab, l₀ ++ ac, bb),b'⟩⟧ ⟹ P ⊢ ⟨try e catch(C V) e₂,(a, l₀ ++ aa, b),ba⟩ → ⟨try e' catch(C V) e₂,(ab, l₀ ++ ac, bb),b'⟩› 57. ‹⋀v C V e₂ a aa b ba l₀. P ⊢ ⟨try Val v catch(C V) e₂,(a, l₀ ++ aa, b),ba⟩ → ⟨Val v,(a, l₀ ++ aa, b),ba⟩› 58. ‹⋀a aa b ab D fs C V e₂ ba l₀. ⟦hp (a, aa, b) ab = ⌊(D, fs)⌋; P ⊢ D ≼⇧* C⟧ ⟹ P ⊢ ⟨try Throw ab catch(C V) e₂,(a, l₀ ++ aa, b),ba⟩ → ⟨{V:Class C; V:=addr ab;; e₂},(a, l₀ ++ aa, b),ba⟩› 59. ‹⋀a aa b ab D fs C V e₂ ba l₀. ⟦hp (a, aa, b) ab = ⌊(D, fs)⌋; (D, C) ∉ (subcls1 P)⇧*⟧ ⟹ P ⊢ ⟨try Throw ab catch(C V) e₂,(a, l₀ ++ aa, b),ba⟩ → ⟨Throw ab,(a, l₀ ++ aa, b),ba⟩› 60. ‹⋀e a aa b ba e' ab ac bb b' es l₀. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⋀l₀. P ⊢ ⟨e,(a, l₀ ++ aa, b),ba⟩ → ⟨e',(ab, l₀ ++ ac, bb),b'⟩⟧ ⟹ P ⊢ ⟨e # es,(a, l₀ ++ aa, b),ba⟩ [→] ⟨e' # es,(ab, l₀ ++ ac, bb),b'⟩› 61. ‹⋀es a aa b ba es' ab ac bb b' v l₀. ⟦P ⊢ ⟨es,(a, aa, b),ba⟩ [→] ⟨es',(ab, ac, bb),b'⟩; ⋀l₀. P ⊢ ⟨es,(a, l₀ ++ aa, b),ba⟩ [→] ⟨es',(ab, l₀ ++ ac, bb),b'⟩⟧ ⟹ P ⊢ ⟨Val v # es,(a, l₀ ++ aa, b),ba⟩ [→] ⟨Val v # es',(ab, l₀ ++ ac, bb),b'⟩› 62. ‹⋀e C b a aa ba b' l₀. ¬ sub_RI e ⟹ P ⊢ ⟨INIT C ([],b) ← e,(a, l₀ ++ aa, ba),b'⟩ → ⟨e,(a, l₀ ++ aa, ba),icheck P C e⟩› 63. ‹⋀sh C C' Cs e h l b l₀. sh C = None ⟹ P ⊢ ⟨INIT C' (C # Cs,False) ← e,(h, l₀ ++ l, sh),b⟩ → ⟨INIT C' (C # Cs,False) ← e,(h, l₀ ++ l, sh(C ↦ (sblank P C, Prepared))),b⟩› 64. ‹⋀sh C sfs C' Cs e h l b l₀. sh C = ⌊(sfs, Done)⌋ ⟹ P ⊢ ⟨INIT C' (C # Cs,False) ← e,(h, l₀ ++ l, sh),b⟩ → ⟨INIT C' (Cs,True) ← e,(h, l₀ ++ l, sh),b⟩› 65. ‹⋀sh C sfs C' Cs e h l b l₀. sh C = ⌊(sfs, Processing)⌋ ⟹ P ⊢ ⟨INIT C' (C # Cs,False) ← e,(h, l₀ ++ l, sh),b⟩ → ⟨INIT C' (Cs,True) ← e,(h, l₀ ++ l, sh),b⟩› 66. ‹⋀sh C sfs C' Cs e h l b l₀. sh C = ⌊(sfs, Error)⌋ ⟹ P ⊢ ⟨INIT C' (C # Cs,False) ← e,(h, l₀ ++ l, sh),b⟩ → ⟨RI (C,THROW NoClassDefFoundError) ; Cs ← e,(h, l₀ ++ l, sh),b⟩› 67. ‹⋀sh C sfs sh' C' Cs e h l b l₀. ⟦sh C = ⌊(sfs, Prepared)⌋; C = Object; sh' = sh(C ↦ (sfs, Processing))⟧ ⟹ P ⊢ ⟨INIT C' (C # Cs,False) ← e,(h, l₀ ++ l, sh),b⟩ → ⟨INIT C' (C # Cs,True) ← e,(h, l₀ ++ l, sh'),b⟩› 68. ‹⋀sh C sfs D a b sh' C' Cs e h l ba l₀. ⟦sh C = ⌊(sfs, Prepared)⌋; C ≠ Object; class P C = ⌊(D, a, b)⌋; sh' = sh(C ↦ (sfs, Processing))⟧ ⟹ P ⊢ ⟨INIT C' (C # Cs,False) ← e,(h, l₀ ++ l, sh),ba⟩ → ⟨INIT C' (D # C # Cs,False) ← e,(h, l₀ ++ l, sh'),ba⟩› 69. ‹⋀C' C Cs e h l sh b l₀. P ⊢ ⟨INIT C' (C # Cs,True) ← e,(h, l₀ ++ l, sh),b⟩ → ⟨RI (C,C∙⇩sclinit([])) ; Cs ← e,(h, l₀ ++ l, sh),b⟩› 70. ‹⋀e a aa b ba e' ab ac bb b' C Cs e₀ l₀. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⋀l₀. P ⊢ ⟨e,(a, l₀ ++ aa, b),ba⟩ → ⟨e',(ab, l₀ ++ ac, bb),b'⟩⟧ ⟹ P ⊢ ⟨RI (C,e) ; Cs ← e₀,(a, l₀ ++ aa, b),ba⟩ → ⟨RI (C,e') ; Cs ← e₀,(ab, l₀ ++ ac, bb),b'⟩› 71. ‹⋀sh C sfs i sh' C' Cs v e h l b l₀. ⟦sh C = ⌊(sfs, i)⌋; sh' = sh(C ↦ (sfs, Done)); C' = last (C # Cs)⟧ ⟹ P ⊢ ⟨RI (C,Val v) ; Cs ← e,(h, l₀ ++ l, sh),b⟩ → ⟨INIT C' (Cs,True) ← e,(h, l₀ ++ l, sh'),b⟩› 72. ‹⋀C e a aa b ba l₀. P ⊢ ⟨Cast C (throw e),(a, l₀ ++ aa, b),ba⟩ → ⟨throw e,(a, l₀ ++ aa, b),ba⟩› 73. ‹⋀e bop e₂ a aa b ba l₀. P ⊢ ⟨throw e «bop» e₂,(a, l₀ ++ aa, b),ba⟩ → ⟨throw e,(a, l₀ ++ aa, b),ba⟩› 74. ‹⋀v₁ bop e a aa b ba l₀. P ⊢ ⟨Val v₁ «bop» throw e,(a, l₀ ++ aa, b),ba⟩ → ⟨throw e,(a, l₀ ++ aa, b),ba⟩› 75. ‹⋀V e a aa b ba l₀. P ⊢ ⟨V:=throw e,(a, l₀ ++ aa, b),ba⟩ → ⟨throw e,(a, l₀ ++ aa, b),ba⟩› 76. ‹⋀e F D a aa b ba l₀. P ⊢ ⟨throw e∙F{D},(a, l₀ ++ aa, b),ba⟩ → ⟨throw e,(a, l₀ ++ aa, b),ba⟩› 77. ‹⋀e F D e₂ a aa b ba l₀. P ⊢ ⟨throw e∙F{D} := e₂,(a, l₀ ++ aa, b),ba⟩ → ⟨throw e,(a, l₀ ++ aa, b),ba⟩› 78. ‹⋀v F D e a aa b ba l₀. P ⊢ ⟨Val v∙F{D} := throw e,(a, l₀ ++ aa, b),ba⟩ → ⟨throw e,(a, l₀ ++ aa, b),ba⟩› 79. ‹⋀C F D e a aa b ba l₀. P ⊢ ⟨C∙⇩sF{D} := throw e,(a, l₀ ++ aa, b),ba⟩ → ⟨throw e,(a, l₀ ++ aa, b),ba⟩› 80. ‹⋀e M es a aa b ba l₀. P ⊢ ⟨throw e∙M(es),(a, l₀ ++ aa, b),ba⟩ → ⟨throw e,(a, l₀ ++ aa, b),ba⟩› 81. ‹⋀es vs e es' v M a aa b ba l₀. es = map Val vs @ throw e # es' ⟹ P ⊢ ⟨Val v∙M(es),(a, l₀ ++ aa, b),ba⟩ → ⟨throw e,(a, l₀ ++ aa, b),ba⟩› 82. ‹⋀es vs e es' C M a aa b ba l₀. es = map Val vs @ throw e # es' ⟹ P ⊢ ⟨C∙⇩sM(es),(a, l₀ ++ aa, b),ba⟩ → ⟨throw e,(a, l₀ ++ aa, b),ba⟩› 83. ‹⋀V T a aa ab b ba l₀. P ⊢ ⟨{V:T; Throw a},(aa, l₀ ++ ab, b),ba⟩ → ⟨Throw a,(aa, l₀ ++ ab, b),ba⟩› 84. ‹⋀V T v a aa ab b ba l₀. P ⊢ ⟨{V:T; V:=Val v;; Throw a},(aa, l₀ ++ ab, b),ba⟩ → ⟨Throw a,(aa, l₀ ++ ab, b),ba⟩› 85. ‹⋀e e₂ a aa b ba l₀. P ⊢ ⟨throw e;; e₂,(a, l₀ ++ aa, b),ba⟩ → ⟨throw e,(a, l₀ ++ aa, b),ba⟩› 86. ‹⋀e e₁ e₂ a aa b ba l₀. P ⊢ ⟨if (throw e) e₁ else e₂,(a, l₀ ++ aa, b),ba⟩ → ⟨throw e,(a, l₀ ++ aa, b),ba⟩› 87. ‹⋀e a aa b ba l₀. P ⊢ ⟨throw (throw e),(a, l₀ ++ aa, b),ba⟩ → ⟨throw e,(a, l₀ ++ aa, b),ba⟩› 88. ‹⋀sh C sfs i sh' a D Cs e h l b l₀. ⟦sh C = ⌊(sfs, i)⌋; sh' = sh(C ↦ (sfs, Error))⟧ ⟹ P ⊢ ⟨RI (C,Throw a) ; D # Cs ← e,(h, l₀ ++ l, sh),b⟩ → ⟨RI (D,Throw a) ; Cs ← e,(h, l₀ ++ l, sh'),b⟩› 89. ‹⋀sh C sfs i sh' a e h l b l₀. ⟦sh C = ⌊(sfs, i)⌋; sh' = sh(C ↦ (sfs, Error))⟧ ⟹ P ⊢ ⟨RI (C,Throw a) ; [] ← e,(h, l₀ ++ l, sh),b⟩ → ⟨Throw a,(h, l₀ ++ l, sh'),b⟩›*) case (BlockRedSome e h l V sh b e' h' l' sh' b' v T l₀) (*‹P ⊢ ⟨e,(h, l(V := None), sh),b⟩ → ⟨e',(h', l', sh'),b'⟩› ‹P ⊢ ⟨e,(h, ?l₀ ++ l(V := None), sh),b⟩ → ⟨e',(h', ?l₀ ++ l', sh'),b'⟩› ‹l' V = ⌊v⌋› ‹¬ assigned V e›*) have IH: "⋀l₀. P ⊢ ⟨e,(h, l₀ ++ l(V := None), sh),b⟩ → ⟨e',(h', l₀ ++ l', sh'),b'⟩" and l'V: "l' V = Some v" and unass: "¬ assigned V e" (*goals: 1. ‹⋀l₀. P ⊢ ⟨e,(h, l₀ ++ l(V := None), sh),b⟩ → ⟨e',(h', l₀ ++ l', sh'),b'⟩› 2. ‹l' V = ⌊v⌋› 3. ‹¬ assigned V e› discuss goal 1*) apply fact (*discuss goal 2*) apply fact (*discuss goal 3*) apply fact (*proven 3 subgoals*) . have "l₀(V := None) ++ l(V := None) = (l₀ ++ l)(V := None)" by (simp add:fun_eq_iff (*‹(?f = ?g) = (∀x. ?f x = ?g x)›*) map_add_def (*‹?m1.0 ++ ?m2.0 = (λx. case ?m2.0 x of None ⇒ ?m1.0 x | ⌊y⌋ ⇒ ⌊y⌋)›*)) hence IH': "P ⊢ ⟨e,(h, (l₀++l)(V := None), sh),b⟩ → ⟨e',(h', l₀(V := None) ++ l', sh'),b'⟩" using IH[of "l₀(V := None)"] (*‹(P::(char list list × char list exp) prog) ⊢ ⟨e::char list exp,(h::heap, (l₀::sfields)(V::char list := None) ++ (l::sfields)(V := None), sh::sheap),b::bool⟩ → ⟨e'::char list exp,(h'::heap, l₀(V := None) ++ (l'::sfields), sh'::sheap),b'::bool⟩›*) by simp have "(l₀(V := None) ++ l')(V := (l₀ ++ l) V) = l₀ ++ l'(V := l V)" by (simp add:fun_eq_iff (*‹(?f = ?g) = (∀x. ?f x = ?g x)›*) map_add_def (*‹?m1.0 ++ ?m2.0 = (λx. case ?m2.0 x of None ⇒ ?m1.0 x | ⌊y⌋ ⇒ ⌊y⌋)›*)) with red_reds.BlockRedSome[OF IH' _ unass] (*‹(l₀(V := None) ++ l') V = ⌊?v⌋ ⟹ P ⊢ ⟨{V:?T; e},(h, l₀ ++ l, sh),b⟩ → ⟨{V:?T; V:=Val ?v;; e'},(h', (l₀(V := None) ++ l')(V := (l₀ ++ l) V), sh'),b'⟩›*) l'V (*‹l' V = ⌊v⌋›*) show "?case" (*goal: ‹P ⊢ ⟨{V:T; e},(h, l₀ ++ l, sh),b⟩ → ⟨{V:T; V:=Val v;; e'},(h', l₀ ++ l'(V := l V), sh'),b'⟩›*) by (simp add:map_add_def (*‹?m1.0 ++ ?m2.0 = (λx. case ?m2.0 x of None ⇒ ?m1.0 x | ⌊y⌋ ⇒ ⌊y⌋)›*)) next (*goals: 1. ‹⋀(h::heap) (a::nat) (C::char list) (FDTs::((char list × char list) × staticb × ty) list) (h'::heap) (l::sfields) (sh::sheap) l₀::sfields. ⟦new_Addr h = ⌊a⌋; (P::(char list list × char list exp) prog) ⊢ C has_fields FDTs; h' = h(a ↦ blank P C)⟧ ⟹ P ⊢ ⟨new C,(h, l₀ ++ l, sh),True⟩ → ⟨addr a,(h', l₀ ++ l, sh),False⟩› 2. ‹⋀(h::heap) (C::char list) (l::sfields) (sh::sheap) l₀::sfields. ⟦new_Addr h = None; is_class (P::(char list list × char list exp) prog) C⟧ ⟹ P ⊢ ⟨new C,(h, l₀ ++ l, sh),True⟩ → ⟨THROW OutOfMemory,(h, l₀ ++ l, sh),False⟩› 3. ‹⋀(sh::sheap) (C::char list) (sfs::sfields) (h::heap) (l::sfields) l₀::sfields. sh C = ⌊(sfs, Done)⌋ ⟹ (P::(char list list × char list exp) prog) ⊢ ⟨new C,(h, l₀ ++ l, sh),False⟩ → ⟨new C,(h, l₀ ++ l, sh),True⟩› 4. ‹⋀(sh::sheap) (C::char list) (h::heap) (l::sfields) l₀::sfields. ⟦∄sfs::sfields. sh C = ⌊(sfs, Done)⌋; is_class (P::(char list list × char list exp) prog) C⟧ ⟹ P ⊢ ⟨new C,(h, l₀ ++ l, sh),False⟩ → ⟨INIT C ([C],False) ← new C,(h, l₀ ++ l, sh),False⟩› 5. ‹⋀(e::char list exp) (a::heap) (aa::sfields) (b::sheap) (ba::bool) (e'::char list exp) (ab::heap) (ac::sfields) (bb::sheap) (b'::bool) (C::char list) l₀::sfields. ⟦(P::(char list list × char list exp) prog) ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⋀l₀::sfields. P ⊢ ⟨e,(a, l₀ ++ aa, b),ba⟩ → ⟨e',(ab, l₀ ++ ac, bb),b'⟩⟧ ⟹ P ⊢ ⟨Cast C e,(a, l₀ ++ aa, b),ba⟩ → ⟨Cast C e',(ab, l₀ ++ ac, bb),b'⟩› 6. ‹⋀(C::char list) (a::heap) (aa::sfields) (b::sheap) (ba::bool) l₀::sfields. (P::(char list list × char list exp) prog) ⊢ ⟨Cast C null,(a, l₀ ++ aa, b),ba⟩ → ⟨null,(a, l₀ ++ aa, b),ba⟩› 7. ‹⋀(e::char list exp) (a::heap) (aa::sfields) (b::sheap) (ba::bool) (e'::char list exp) (ab::heap) (ac::sfields) (bb::sheap) (b'::bool) (bop::bop) (e₂::char list exp) l₀::sfields. ⟦(P::(char list list × char list exp) prog) ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⋀l₀::sfields. P ⊢ ⟨e,(a, l₀ ++ aa, b),ba⟩ → ⟨e',(ab, l₀ ++ ac, bb),b'⟩⟧ ⟹ P ⊢ ⟨e «bop» e₂,(a, l₀ ++ aa, b),ba⟩ → ⟨e' «bop» e₂,(ab, l₀ ++ ac, bb),b'⟩› 8. ‹⋀(e::char list exp) (a::heap) (aa::sfields) (b::sheap) (ba::bool) (e'::char list exp) (ab::heap) (ac::sfields) (bb::sheap) (b'::bool) (v₁::val) (bop::bop) l₀::sfields. ⟦(P::(char list list × char list exp) prog) ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⋀l₀::sfields. P ⊢ ⟨e,(a, l₀ ++ aa, b),ba⟩ → ⟨e',(ab, l₀ ++ ac, bb),b'⟩⟧ ⟹ P ⊢ ⟨Val v₁ «bop» e,(a, l₀ ++ aa, b),ba⟩ → ⟨Val v₁ «bop» e',(ab, l₀ ++ ac, bb),b'⟩› 9. ‹⋀(bop::bop) (v₁::val) (v₂::val) (v::val) (a::heap) (aa::sfields) (b::sheap) (ba::bool) l₀::sfields. binop (bop, v₁, v₂) = ⌊v⌋ ⟹ (P::(char list list × char list exp) prog) ⊢ ⟨Val v₁ «bop» Val v₂,(a, l₀ ++ aa, b),ba⟩ → ⟨Val v,(a, l₀ ++ aa, b),ba⟩› 10. ‹⋀(l::sfields) (V::char list) (v::val) (h::heap) (sh::sheap) (b::bool) l₀::sfields. l V = ⌊v⌋ ⟹ (P::(char list list × char list exp) prog) ⊢ ⟨Var V,(h, l₀ ++ l, sh),b⟩ → ⟨Val v,(h, l₀ ++ l, sh),b⟩› 11. ‹⋀(e::char list exp) (a::heap) (aa::sfields) (b::sheap) (ba::bool) (e'::char list exp) (ab::heap) (ac::sfields) (bb::sheap) (b'::bool) (V::char list) l₀::sfields. ⟦(P::(char list list × char list exp) prog) ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⋀l₀::sfields. P ⊢ ⟨e,(a, l₀ ++ aa, b),ba⟩ → ⟨e',(ab, l₀ ++ ac, bb),b'⟩⟧ ⟹ P ⊢ ⟨V:=e,(a, l₀ ++ aa, b),ba⟩ → ⟨V:=e',(ab, l₀ ++ ac, bb),b'⟩› 12. ‹⋀(V::char list) (v::val) (h::heap) (l::sfields) (sh::sheap) (b::bool) l₀::sfields. (P::(char list list × char list exp) prog) ⊢ ⟨V:=Val v,(h, l₀ ++ l, sh),b⟩ → ⟨unit,(h, l₀ ++ l(V ↦ v), sh),b⟩› 13. ‹⋀(e::char list exp) (a::heap) (aa::sfields) (b::sheap) (ba::bool) (e'::char list exp) (ab::heap) (ac::sfields) (bb::sheap) (b'::bool) (F::char list) (D::char list) l₀::sfields. ⟦(P::(char list list × char list exp) prog) ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⋀l₀::sfields. P ⊢ ⟨e,(a, l₀ ++ aa, b),ba⟩ → ⟨e',(ab, l₀ ++ ac, bb),b'⟩⟧ ⟹ P ⊢ ⟨e∙F{D},(a, l₀ ++ aa, b),ba⟩ → ⟨e'∙F{D},(ab, l₀ ++ ac, bb),b'⟩› 14. ‹⋀(F::char list) (D::char list) (a::heap) (aa::sfields) (b::sheap) (ba::bool) l₀::sfields. (P::(char list list × char list exp) prog) ⊢ ⟨null∙F{D},(a, l₀ ++ aa, b),ba⟩ → ⟨THROW NullPointer,(a, l₀ ++ aa, b),ba⟩› 15. ‹⋀(h::heap) (a::nat) (C::char list) (fs::Objects.fields) (F::char list) (D::char list) (l::sfields) (sh::sheap) (b::bool) l₀::sfields. ⟦h a = ⌊(C, fs)⌋; ∄(b::staticb) t::ty. (P::(char list list × char list exp) prog) ⊢ C has F,b:t in D⟧ ⟹ P ⊢ ⟨addr a∙F{D},(h, l₀ ++ l, sh),b⟩ → ⟨THROW NoSuchFieldError,(h, l₀ ++ l, sh),b⟩› 16. ‹⋀(h::heap) (a::nat) (C::char list) (fs::Objects.fields) (F::char list) (t::ty) (D::char list) (l::sfields) (sh::sheap) (b::bool) l₀::sfields. ⟦h a = ⌊(C, fs)⌋; (P::(char list list × char list exp) prog) ⊢ C has F,Static:t in D⟧ ⟹ P ⊢ ⟨addr a∙F{D},(h, l₀ ++ l, sh),b⟩ → ⟨THROW IncompatibleClassChangeError,(h, l₀ ++ l, sh),b⟩› 17. ‹⋀(C::char list) (F::char list) (t::ty) (D::char list) (sh::sheap) (sfs::sfields) (i::init_state) (v::val) (h::heap) (l::sfields) l₀::sfields. ⟦(P::(char list list × char list exp) prog) ⊢ C has F,Static:t in D; sh D = ⌊(sfs, i)⌋; sfs F = ⌊v⌋⟧ ⟹ P ⊢ ⟨C∙⇩sF{D},(h, l₀ ++ l, sh),True⟩ → ⟨Val v,(h, l₀ ++ l, sh),False⟩› 18. ‹⋀(C::char list) (F::char list) (t::ty) (D::char list) (sh::sheap) (sfs::sfields) (h::heap) (l::sfields) l₀::sfields. ⟦(P::(char list list × char list exp) prog) ⊢ C has F,Static:t in D; sh D = ⌊(sfs, Done)⌋⟧ ⟹ P ⊢ ⟨C∙⇩sF{D},(h, l₀ ++ l, sh),False⟩ → ⟨C∙⇩sF{D},(h, l₀ ++ l, sh),True⟩› 19. ‹⋀(C::char list) (F::char list) (t::ty) (D::char list) (sh::sheap) (h::heap) (l::sfields) l₀::sfields. ⟦(P::(char list list × char list exp) prog) ⊢ C has F,Static:t in D; ∄sfs::sfields. sh D = ⌊(sfs, Done)⌋⟧ ⟹ P ⊢ ⟨C∙⇩sF{D},(h, l₀ ++ l, sh),False⟩ → ⟨INIT D ([D],False) ← C∙⇩sF{D},(h, l₀ ++ l, sh),False⟩› 20. ‹⋀(C::char list) (F::char list) (D::char list) (h::heap) (l::sfields) (sh::sheap) (b::bool) l₀::sfields. ∄(b::staticb) t::ty. (P::(char list list × char list exp) prog) ⊢ C has F,b:t in D ⟹ P ⊢ ⟨C∙⇩sF{D},(h, l₀ ++ l, sh),b⟩ → ⟨THROW NoSuchFieldError,(h, l₀ ++ l, sh),False⟩› 21. ‹⋀(C::char list) (F::char list) (t::ty) (D::char list) (h::heap) (l::sfields) (sh::sheap) (b::bool) l₀::sfields. (P::(char list list × char list exp) prog) ⊢ C has F,NonStatic:t in D ⟹ P ⊢ ⟨C∙⇩sF{D},(h, l₀ ++ l, sh),b⟩ → ⟨THROW IncompatibleClassChangeError,(h, l₀ ++ l, sh),False⟩› 22. ‹⋀(e::char list exp) (a::heap) (aa::sfields) (b::sheap) (ba::bool) (e'::char list exp) (ab::heap) (ac::sfields) (bb::sheap) (b'::bool) (F::char list) (D::char list) (e₂::char list exp) l₀::sfields. ⟦(P::(char list list × char list exp) prog) ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⋀l₀::sfields. P ⊢ ⟨e,(a, l₀ ++ aa, b),ba⟩ → ⟨e',(ab, l₀ ++ ac, bb),b'⟩⟧ ⟹ P ⊢ ⟨e∙F{D} := e₂,(a, l₀ ++ aa, b),ba⟩ → ⟨e'∙F{D} := e₂,(ab, l₀ ++ ac, bb),b'⟩› 23. ‹⋀(e::char list exp) (a::heap) (aa::sfields) (b::sheap) (ba::bool) (e'::char list exp) (ab::heap) (ac::sfields) (bb::sheap) (b'::bool) (v::val) (F::char list) (D::char list) l₀::sfields. ⟦(P::(char list list × char list exp) prog) ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⋀l₀::sfields. P ⊢ ⟨e,(a, l₀ ++ aa, b),ba⟩ → ⟨e',(ab, l₀ ++ ac, bb),b'⟩⟧ ⟹ P ⊢ ⟨Val v∙F{D} := e,(a, l₀ ++ aa, b),ba⟩ → ⟨Val v∙F{D} := e',(ab, l₀ ++ ac, bb),b'⟩› 24. ‹⋀(C::char list) (F::char list) (t::ty) (D::char list) (h::heap) (a::nat) (fs::Objects.fields) (v::val) (l::sfields) (sh::sheap) (b::bool) l₀::sfields. ⟦(P::(char list list × char list exp) prog) ⊢ C has F,NonStatic:t in D; h a = ⌊(C, fs)⌋⟧ ⟹ P ⊢ ⟨addr a∙F{D} := Val v,(h, l₀ ++ l, sh),b⟩ → ⟨unit,(h(a ↦ (C, fs((F, D) ↦ v))), l₀ ++ l, sh),b⟩› 25. ‹⋀(F::char list) (D::char list) (v::val) (a::heap) (aa::sfields) (b::sheap) (ba::bool) l₀::sfields. (P::(char list list × char list exp) prog) ⊢ ⟨null∙F{D} := Val v,(a, l₀ ++ aa, b),ba⟩ → ⟨THROW NullPointer,(a, l₀ ++ aa, b),ba⟩› 26. ‹⋀(h::heap) (a::nat) (C::char list) (fs::Objects.fields) (F::char list) (D::char list) (v::val) (l::sfields) (sh::sheap) (b::bool) l₀::sfields. ⟦h a = ⌊(C, fs)⌋; ∄(b::staticb) t::ty. (P::(char list list × char list exp) prog) ⊢ C has F,b:t in D⟧ ⟹ P ⊢ ⟨addr a∙F{D} := Val v,(h, l₀ ++ l, sh),b⟩ → ⟨THROW NoSuchFieldError,(h, l₀ ++ l, sh),b⟩› 27. ‹⋀(h::heap) (a::nat) (C::char list) (fs::Objects.fields) (F::char list) (t::ty) (D::char list) (v::val) (l::sfields) (sh::sheap) (b::bool) l₀::sfields. ⟦h a = ⌊(C, fs)⌋; (P::(char list list × char list exp) prog) ⊢ C has F,Static:t in D⟧ ⟹ P ⊢ ⟨addr a∙F{D} := Val v,(h, l₀ ++ l, sh),b⟩ → ⟨THROW IncompatibleClassChangeError,(h, l₀ ++ l, sh),b⟩› 28. ‹⋀(e::char list exp) (a::heap) (aa::sfields) (b::sheap) (ba::bool) (e'::char list exp) (ab::heap) (ac::sfields) (bb::sheap) (b'::bool) (C::char list) (F::char list) (D::char list) l₀::sfields. ⟦(P::(char list list × char list exp) prog) ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⋀l₀::sfields. P ⊢ ⟨e,(a, l₀ ++ aa, b),ba⟩ → ⟨e',(ab, l₀ ++ ac, bb),b'⟩⟧ ⟹ P ⊢ ⟨C∙⇩sF{D} := e,(a, l₀ ++ aa, b),ba⟩ → ⟨C∙⇩sF{D} := e',(ab, l₀ ++ ac, bb),b'⟩› 29. ‹⋀(C::char list) (F::char list) (t::ty) (D::char list) (sh::sheap) (sfs::sfields) (i::init_state) (sfs'::sfields) (v::val) (sh'::sheap) (h::heap) (l::sfields) l₀::sfields. ⟦(P::(char list list × char list exp) prog) ⊢ C has F,Static:t in D; sh D = ⌊(sfs, i)⌋; sfs' = sfs(F ↦ v); sh' = sh(D ↦ (sfs', i))⟧ ⟹ P ⊢ ⟨C∙⇩sF{D} := Val v,(h, l₀ ++ l, sh),True⟩ → ⟨unit,(h, l₀ ++ l, sh'),False⟩› 30. ‹⋀(C::char list) (F::char list) (t::ty) (D::char list) (sh::sheap) (sfs::sfields) (v::val) (h::heap) (l::sfields) l₀::sfields. ⟦(P::(char list list × char list exp) prog) ⊢ C has F,Static:t in D; sh D = ⌊(sfs, Done)⌋⟧ ⟹ P ⊢ ⟨C∙⇩sF{D} := Val v,(h, l₀ ++ l, sh),False⟩ → ⟨C∙⇩sF{D} := Val v,(h, l₀ ++ l, sh),True⟩› 31. ‹⋀(C::char list) (F::char list) (t::ty) (D::char list) (sh::sheap) (v::val) (h::heap) (l::sfields) l₀::sfields. ⟦(P::(char list list × char list exp) prog) ⊢ C has F,Static:t in D; ∄sfs::sfields. sh D = ⌊(sfs, Done)⌋⟧ ⟹ P ⊢ ⟨C∙⇩sF{D} := Val v,(h, l₀ ++ l, sh),False⟩ → ⟨INIT D ([D],False) ← C∙⇩sF{D} := Val v,(h, l₀ ++ l, sh),False⟩› 32. ‹⋀(C::char list) (F::char list) (D::char list) (v::val) (a::heap) (aa::sfields) (b::sheap) (ba::bool) l₀::sfields. ∄(b::staticb) t::ty. (P::(char list list × char list exp) prog) ⊢ C has F,b:t in D ⟹ P ⊢ ⟨C∙⇩sF{D} := Val v,(a, l₀ ++ aa, b),ba⟩ → ⟨THROW NoSuchFieldError,(a, l₀ ++ aa, b),False⟩› 33. ‹⋀(C::char list) (F::char list) (t::ty) (D::char list) (v::val) (a::heap) (aa::sfields) (b::sheap) (ba::bool) l₀::sfields. (P::(char list list × char list exp) prog) ⊢ C has F,NonStatic:t in D ⟹ P ⊢ ⟨C∙⇩sF{D} := Val v,(a, l₀ ++ aa, b),ba⟩ → ⟨THROW IncompatibleClassChangeError,(a, l₀ ++ aa, b),False⟩› 34. ‹⋀(e::char list exp) (a::heap) (aa::sfields) (b::sheap) (ba::bool) (e'::char list exp) (ab::heap) (ac::sfields) (bb::sheap) (b'::bool) (M::char list) (es::char list exp list) l₀::sfields. ⟦(P::(char list list × char list exp) prog) ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⋀l₀::sfields. P ⊢ ⟨e,(a, l₀ ++ aa, b),ba⟩ → ⟨e',(ab, l₀ ++ ac, bb),b'⟩⟧ ⟹ P ⊢ ⟨e∙M(es),(a, l₀ ++ aa, b),ba⟩ → ⟨e'∙M(es),(ab, l₀ ++ ac, bb),b'⟩› 35. ‹⋀(es::char list exp list) (a::heap) (aa::sfields) (b::sheap) (ba::bool) (es'::char list exp list) (ab::heap) (ac::sfields) (bb::sheap) (b'::bool) (v::val) (M::char list) l₀::sfields. ⟦(P::(char list list × char list exp) prog) ⊢ ⟨es,(a, aa, b),ba⟩ [→] ⟨es',(ab, ac, bb),b'⟩; ⋀l₀::sfields. P ⊢ ⟨es,(a, l₀ ++ aa, b),ba⟩ [→] ⟨es',(ab, l₀ ++ ac, bb),b'⟩⟧ ⟹ P ⊢ ⟨Val v∙M(es),(a, l₀ ++ aa, b),ba⟩ → ⟨Val v∙M(es'),(ab, l₀ ++ ac, bb),b'⟩› 36. ‹⋀(M::char list) (vs::val list) (a::heap) (aa::sfields) (b::sheap) (ba::bool) l₀::sfields. (P::(char list list × char list exp) prog) ⊢ ⟨null∙M(map Val vs),(a, l₀ ++ aa, b),ba⟩ → ⟨THROW NullPointer,(a, l₀ ++ aa, b),ba⟩› 37. ‹⋀(h::heap) (a::nat) (C::char list) (fs::Objects.fields) (M::char list) (vs::val list) (l::sfields) (sh::sheap) (b::bool) l₀::sfields. ⟦h a = ⌊(C, fs)⌋; ∄(b::staticb) (Ts::ty list) (T::ty) (m::char list list × char list exp) D::char list. (P::(char list list × char list exp) prog) ⊢ C sees M, b : Ts→T = m in D⟧ ⟹ P ⊢ ⟨addr a∙M(map Val vs),(h, l₀ ++ l, sh),b⟩ → ⟨THROW NoSuchMethodError,(h, l₀ ++ l, sh),b⟩› 38. ‹⋀(h::heap) (a::nat) (C::char list) (fs::Objects.fields) (M::char list) (Ts::ty list) (T::ty) (aa::char list list) (b::char list exp) (D::char list) (vs::val list) (l::sfields) (sh::sheap) (ba::bool) l₀::sfields. ⟦h a = ⌊(C, fs)⌋; (P::(char list list × char list exp) prog) ⊢ C sees M, Static : Ts→T = (aa, b) in D⟧ ⟹ P ⊢ ⟨addr a∙M(map Val vs),(h, l₀ ++ l, sh),ba⟩ → ⟨THROW IncompatibleClassChangeError,(h, l₀ ++ l, sh),ba⟩› 39. ‹⋀(es::char list exp list) (a::heap) (aa::sfields) (b::sheap) (ba::bool) (es'::char list exp list) (ab::heap) (ac::sfields) (bb::sheap) (b'::bool) (C::char list) (M::char list) l₀::sfields. ⟦(P::(char list list × char list exp) prog) ⊢ ⟨es,(a, aa, b),ba⟩ [→] ⟨es',(ab, ac, bb),b'⟩; ⋀l₀::sfields. P ⊢ ⟨es,(a, l₀ ++ aa, b),ba⟩ [→] ⟨es',(ab, l₀ ++ ac, bb),b'⟩⟧ ⟹ P ⊢ ⟨C∙⇩sM(es),(a, l₀ ++ aa, b),ba⟩ → ⟨C∙⇩sM(es'),(ab, l₀ ++ ac, bb),b'⟩› 40. ‹⋀(C::char list) (M::char list) (Ts::ty list) (T::ty) (pns::char list list) (body::char list exp) (D::char list) (vs::val list) (a::heap) (aa::sfields) (b::sheap) l₀::sfields. ⟦(P::(char list list × char list exp) prog) ⊢ C sees M, Static : Ts→T = (pns, body) in D; length vs = length pns; length Ts = length pns⟧ ⟹ P ⊢ ⟨C∙⇩sM(map Val vs),(a, l₀ ++ aa, b),True⟩ → ⟨blocks (pns, Ts, vs, body),(a, l₀ ++ aa, b),False⟩› 41. ‹⋀(C::char list) (M::char list) (Ts::ty list) (T::ty) (pns::char list list) (body::char list exp) (D::char list) (sh::sheap) (sfs::sfields) (vs::val list) (h::heap) (l::sfields) l₀::sfields. ⟦(P::(char list list × char list exp) prog) ⊢ C sees M, Static : Ts→T = (pns, body) in D; sh D = ⌊(sfs, Done)⌋ ∨ M = clinit ∧ sh D = ⌊(sfs, Processing)⌋⟧ ⟹ P ⊢ ⟨C∙⇩sM(map Val vs),(h, l₀ ++ l, sh),False⟩ → ⟨C∙⇩sM(map Val vs),(h, l₀ ++ l, sh),True⟩› 42. ‹⋀(C::char list) (M::char list) (Ts::ty list) (T::ty) (pns::char list list) (body::char list exp) (D::char list) (sh::sheap) (vs::val list) (h::heap) (l::sfields) l₀::sfields. ⟦(P::(char list list × char list exp) prog) ⊢ C sees M, Static : Ts→T = (pns, body) in D; ∄sfs::sfields. sh D = ⌊(sfs, Done)⌋; M ≠ clinit⟧ ⟹ P ⊢ ⟨C∙⇩sM(map Val vs),(h, l₀ ++ l, sh),False⟩ → ⟨INIT D ([D],False) ← C∙⇩sM(map Val vs),(h, l₀ ++ l, sh),False⟩› 43. ‹⋀(C::char list) (M::char list) (vs::val list) (a::heap) (aa::sfields) (b::sheap) (ba::bool) l₀::sfields. ∄(b::staticb) (Ts::ty list) (T::ty) m::char list list × char list exp. Ex (Method (P::(char list list × char list exp) prog) C M b Ts T m) ⟹ P ⊢ ⟨C∙⇩sM(map Val vs),(a, l₀ ++ aa, b),ba⟩ → ⟨THROW NoSuchMethodError,(a, l₀ ++ aa, b),False⟩› 44. ‹⋀(C::char list) (M::char list) (Ts::ty list) (T::ty) (a::char list list) (b::char list exp) (D::char list) (vs::val list) (aa::heap) (ab::sfields) (ba::sheap) (bb::bool) l₀::sfields. (P::(char list list × char list exp) prog) ⊢ C sees M, NonStatic : Ts→T = (a, b) in D ⟹ P ⊢ ⟨C∙⇩sM(map Val vs),(aa, l₀ ++ ab, ba),bb⟩ → ⟨THROW IncompatibleClassChangeError,(aa, l₀ ++ ab, ba),False⟩› 45. ‹⋀(V::char list) (T::ty) (u::val) (a::heap) (aa::sfields) (b::sheap) (ba::bool) l₀::sfields. (P::(char list list × char list exp) prog) ⊢ ⟨{V:T; Val u},(a, l₀ ++ aa, b),ba⟩ → ⟨Val u,(a, l₀ ++ aa, b),ba⟩› 46. ‹⋀(V::char list) (T::ty) (v::val) (u::val) (a::heap) (aa::sfields) (b::sheap) (ba::bool) l₀::sfields. (P::(char list list × char list exp) prog) ⊢ ⟨{V:T; V:=Val v;; Val u},(a, l₀ ++ aa, b),ba⟩ → ⟨Val u,(a, l₀ ++ aa, b),ba⟩› 47. ‹⋀(e::char list exp) (a::heap) (aa::sfields) (b::sheap) (ba::bool) (e'::char list exp) (ab::heap) (ac::sfields) (bb::sheap) (b'::bool) (e₂::char list exp) l₀::sfields. ⟦(P::(char list list × char list exp) prog) ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⋀l₀::sfields. P ⊢ ⟨e,(a, l₀ ++ aa, b),ba⟩ → ⟨e',(ab, l₀ ++ ac, bb),b'⟩⟧ ⟹ P ⊢ ⟨e;; e₂,(a, l₀ ++ aa, b),ba⟩ → ⟨e';; e₂,(ab, l₀ ++ ac, bb),b'⟩› 48. ‹⋀(v::val) (e₂::char list exp) (a::heap) (aa::sfields) (b::sheap) (ba::bool) l₀::sfields. (P::(char list list × char list exp) prog) ⊢ ⟨Val v;; e₂,(a, l₀ ++ aa, b),ba⟩ → ⟨e₂,(a, l₀ ++ aa, b),ba⟩› 49. ‹⋀(e::char list exp) (a::heap) (aa::sfields) (b::sheap) (ba::bool) (e'::char list exp) (ab::heap) (ac::sfields) (bb::sheap) (b'::bool) (e₁::char list exp) (e₂::char list exp) l₀::sfields. ⟦(P::(char list list × char list exp) prog) ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⋀l₀::sfields. P ⊢ ⟨e,(a, l₀ ++ aa, b),ba⟩ → ⟨e',(ab, l₀ ++ ac, bb),b'⟩⟧ ⟹ P ⊢ ⟨if (e) e₁ else e₂,(a, l₀ ++ aa, b),ba⟩ → ⟨if (e') e₁ else e₂,(ab, l₀ ++ ac, bb),b'⟩› 50. ‹⋀(e₁::char list exp) (e₂::char list exp) (a::heap) (aa::sfields) (b::sheap) (ba::bool) l₀::sfields. (P::(char list list × char list exp) prog) ⊢ ⟨if (true) e₁ else e₂,(a, l₀ ++ aa, b),ba⟩ → ⟨e₁,(a, l₀ ++ aa, b),ba⟩› 51. ‹⋀(e₁::char list exp) (e₂::char list exp) (a::heap) (aa::sfields) (b::sheap) (ba::bool) l₀::sfields. (P::(char list list × char list exp) prog) ⊢ ⟨if (false) e₁ else e₂,(a, l₀ ++ aa, b),ba⟩ → ⟨e₂,(a, l₀ ++ aa, b),ba⟩› 52. ‹⋀(b::char list exp) (c::char list exp) (a::heap) (aa::sfields) (ba::sheap) (b'::bool) l₀::sfields. (P::(char list list × char list exp) prog) ⊢ ⟨while (b) c,(a, l₀ ++ aa, ba),b'⟩ → ⟨if (b) (c;; while (b) c) else unit,(a, l₀ ++ aa, ba),b'⟩› 53. ‹⋀(e::char list exp) (a::heap) (aa::sfields) (b::sheap) (ba::bool) (e'::char list exp) (ab::heap) (ac::sfields) (bb::sheap) (b'::bool) l₀::sfields. ⟦(P::(char list list × char list exp) prog) ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⋀l₀::sfields. P ⊢ ⟨e,(a, l₀ ++ aa, b),ba⟩ → ⟨e',(ab, l₀ ++ ac, bb),b'⟩⟧ ⟹ P ⊢ ⟨throw e,(a, l₀ ++ aa, b),ba⟩ → ⟨throw e',(ab, l₀ ++ ac, bb),b'⟩› 54. ‹⋀(a::heap) (aa::sfields) (b::sheap) (ba::bool) l₀::sfields. (P::(char list list × char list exp) prog) ⊢ ⟨throw null,(a, l₀ ++ aa, b),ba⟩ → ⟨THROW NullPointer,(a, l₀ ++ aa, b),ba⟩› 55. ‹⋀(e::char list exp) (a::heap) (aa::sfields) (b::sheap) (ba::bool) (e'::char list exp) (ab::heap) (ac::sfields) (bb::sheap) (b'::bool) (C::char list) (V::char list) (e₂::char list exp) l₀::sfields. ⟦(P::(char list list × char list exp) prog) ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⋀l₀::sfields. P ⊢ ⟨e,(a, l₀ ++ aa, b),ba⟩ → ⟨e',(ab, l₀ ++ ac, bb),b'⟩⟧ ⟹ P ⊢ ⟨try e catch(C V) e₂,(a, l₀ ++ aa, b),ba⟩ → ⟨try e' catch(C V) e₂,(ab, l₀ ++ ac, bb),b'⟩› 56. ‹⋀(v::val) (C::char list) (V::char list) (e₂::char list exp) (a::heap) (aa::sfields) (b::sheap) (ba::bool) l₀::sfields. (P::(char list list × char list exp) prog) ⊢ ⟨try Val v catch(C V) e₂,(a, l₀ ++ aa, b),ba⟩ → ⟨Val v,(a, l₀ ++ aa, b),ba⟩› 57. ‹⋀(a::heap) (aa::sfields) (b::sheap) (ab::nat) (D::char list) (fs::Objects.fields) (C::char list) (V::char list) (e₂::char list exp) (ba::bool) l₀::sfields. ⟦hp (a, aa, b) ab = ⌊(D, fs)⌋; (P::(char list list × char list exp) prog) ⊢ D ≼⇧* C⟧ ⟹ P ⊢ ⟨try Throw ab catch(C V) e₂,(a, l₀ ++ aa, b),ba⟩ → ⟨{V:Class C; V:=addr ab;; e₂},(a, l₀ ++ aa, b),ba⟩› 58. ‹⋀(a::heap) (aa::sfields) (b::sheap) (ab::nat) (D::char list) (fs::Objects.fields) (C::char list) (V::char list) (e₂::char list exp) (ba::bool) l₀::sfields. ⟦hp (a, aa, b) ab = ⌊(D, fs)⌋; (D, C) ∉ (subcls1 (P::(char list list × char list exp) prog))⇧*⟧ ⟹ P ⊢ ⟨try Throw ab catch(C V) e₂,(a, l₀ ++ aa, b),ba⟩ → ⟨Throw ab,(a, l₀ ++ aa, b),ba⟩› 59. ‹⋀(e::char list exp) (a::heap) (aa::sfields) (b::sheap) (ba::bool) (e'::char list exp) (ab::heap) (ac::sfields) (bb::sheap) (b'::bool) (es::char list exp list) l₀::sfields. ⟦(P::(char list list × char list exp) prog) ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⋀l₀::sfields. P ⊢ ⟨e,(a, l₀ ++ aa, b),ba⟩ → ⟨e',(ab, l₀ ++ ac, bb),b'⟩⟧ ⟹ P ⊢ ⟨e # es,(a, l₀ ++ aa, b),ba⟩ [→] ⟨e' # es,(ab, l₀ ++ ac, bb),b'⟩› 60. ‹⋀(es::char list exp list) (a::heap) (aa::sfields) (b::sheap) (ba::bool) (es'::char list exp list) (ab::heap) (ac::sfields) (bb::sheap) (b'::bool) (v::val) l₀::sfields. ⟦(P::(char list list × char list exp) prog) ⊢ ⟨es,(a, aa, b),ba⟩ [→] ⟨es',(ab, ac, bb),b'⟩; ⋀l₀::sfields. P ⊢ ⟨es,(a, l₀ ++ aa, b),ba⟩ [→] ⟨es',(ab, l₀ ++ ac, bb),b'⟩⟧ ⟹ P ⊢ ⟨Val v # es,(a, l₀ ++ aa, b),ba⟩ [→] ⟨Val v # es',(ab, l₀ ++ ac, bb),b'⟩› 61. ‹⋀(e::char list exp) (C::char list) (b::bool) (a::heap) (aa::sfields) (ba::sheap) (b'::bool) l₀::sfields. ¬ sub_RI e ⟹ (P::(char list list × char list exp) prog) ⊢ ⟨INIT C ([],b) ← e,(a, l₀ ++ aa, ba),b'⟩ → ⟨e,(a, l₀ ++ aa, ba),icheck P C e⟩› 62. ‹⋀(sh::sheap) (C::char list) (C'::char list) (Cs::char list list) (e::char list exp) (h::heap) (l::sfields) (b::bool) l₀::sfields. sh C = None ⟹ (P::(char list list × char list exp) prog) ⊢ ⟨INIT C' (C # Cs,False) ← e,(h, l₀ ++ l, sh),b⟩ → ⟨INIT C' (C # Cs,False) ← e,(h, l₀ ++ l, sh(C ↦ (sblank P C, Prepared))),b⟩› 63. ‹⋀(sh::sheap) (C::char list) (sfs::sfields) (C'::char list) (Cs::char list list) (e::char list exp) (h::heap) (l::sfields) (b::bool) l₀::sfields. sh C = ⌊(sfs, Done)⌋ ⟹ (P::(char list list × char list exp) prog) ⊢ ⟨INIT C' (C # Cs,False) ← e,(h, l₀ ++ l, sh),b⟩ → ⟨INIT C' (Cs,True) ← e,(h, l₀ ++ l, sh),b⟩› 64. ‹⋀(sh::sheap) (C::char list) (sfs::sfields) (C'::char list) (Cs::char list list) (e::char list exp) (h::heap) (l::sfields) (b::bool) l₀::sfields. sh C = ⌊(sfs, Processing)⌋ ⟹ (P::(char list list × char list exp) prog) ⊢ ⟨INIT C' (C # Cs,False) ← e,(h, l₀ ++ l, sh),b⟩ → ⟨INIT C' (Cs,True) ← e,(h, l₀ ++ l, sh),b⟩› 65. ‹⋀(sh::sheap) (C::char list) (sfs::sfields) (C'::char list) (Cs::char list list) (e::char list exp) (h::heap) (l::sfields) (b::bool) l₀::sfields. sh C = ⌊(sfs, Error)⌋ ⟹ (P::(char list list × char list exp) prog) ⊢ ⟨INIT C' (C # Cs,False) ← e,(h, l₀ ++ l, sh),b⟩ → ⟨RI (C,THROW NoClassDefFoundError) ; Cs ← e,(h, l₀ ++ l, sh),b⟩› 66. ‹⋀(sh::sheap) (C::char list) (sfs::sfields) (sh'::sheap) (C'::char list) (Cs::char list list) (e::char list exp) (h::heap) (l::sfields) (b::bool) l₀::sfields. ⟦sh C = ⌊(sfs, Prepared)⌋; C = Object; sh' = sh(C ↦ (sfs, Processing))⟧ ⟹ (P::(char list list × char list exp) prog) ⊢ ⟨INIT C' (C # Cs,False) ← e,(h, l₀ ++ l, sh),b⟩ → ⟨INIT C' (C # Cs,True) ← e,(h, l₀ ++ l, sh'),b⟩› 67. ‹⋀(sh::sheap) (C::char list) (sfs::sfields) (D::char list) (a::fdecl list) (b::(char list list × char list exp) mdecl list) (sh'::sheap) (C'::char list) (Cs::char list list) (e::char list exp) (h::heap) (l::sfields) (ba::bool) l₀::sfields. ⟦sh C = ⌊(sfs, Prepared)⌋; C ≠ Object; class (P::(char list list × char list exp) prog) C = ⌊(D, a, b)⌋; sh' = sh(C ↦ (sfs, Processing))⟧ ⟹ P ⊢ ⟨INIT C' (C # Cs,False) ← e,(h, l₀ ++ l, sh),ba⟩ → ⟨INIT C' (D # C # Cs,False) ← e,(h, l₀ ++ l, sh'),ba⟩› 68. ‹⋀(C'::char list) (C::char list) (Cs::char list list) (e::char list exp) (h::heap) (l::sfields) (sh::sheap) (b::bool) l₀::sfields. (P::(char list list × char list exp) prog) ⊢ ⟨INIT C' (C # Cs,True) ← e,(h, l₀ ++ l, sh),b⟩ → ⟨RI (C,C∙⇩sclinit([])) ; Cs ← e,(h, l₀ ++ l, sh),b⟩› 69. ‹⋀(e::char list exp) (a::heap) (aa::sfields) (b::sheap) (ba::bool) (e'::char list exp) (ab::heap) (ac::sfields) (bb::sheap) (b'::bool) (C::char list) (Cs::char list list) (e₀::char list exp) l₀::sfields. ⟦(P::(char list list × char list exp) prog) ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⋀l₀::sfields. P ⊢ ⟨e,(a, l₀ ++ aa, b),ba⟩ → ⟨e',(ab, l₀ ++ ac, bb),b'⟩⟧ ⟹ P ⊢ ⟨RI (C,e) ; Cs ← e₀,(a, l₀ ++ aa, b),ba⟩ → ⟨RI (C,e') ; Cs ← e₀,(ab, l₀ ++ ac, bb),b'⟩› 70. ‹⋀(sh::sheap) (C::char list) (sfs::sfields) (i::init_state) (sh'::sheap) (C'::char list) (Cs::char list list) (v::val) (e::char list exp) (h::heap) (l::sfields) (b::bool) l₀::sfields. ⟦sh C = ⌊(sfs, i)⌋; sh' = sh(C ↦ (sfs, Done)); C' = last (C # Cs)⟧ ⟹ (P::(char list list × char list exp) prog) ⊢ ⟨RI (C,Val v) ; Cs ← e,(h, l₀ ++ l, sh),b⟩ → ⟨INIT C' (Cs,True) ← e,(h, l₀ ++ l, sh'),b⟩› 71. ‹⋀(C::char list) (e::char list exp) (a::heap) (aa::sfields) (b::sheap) (ba::bool) l₀::sfields. (P::(char list list × char list exp) prog) ⊢ ⟨Cast C (throw e),(a, l₀ ++ aa, b),ba⟩ → ⟨throw e,(a, l₀ ++ aa, b),ba⟩› 72. ‹⋀(e::char list exp) (bop::bop) (e₂::char list exp) (a::heap) (aa::sfields) (b::sheap) (ba::bool) l₀::sfields. (P::(char list list × char list exp) prog) ⊢ ⟨throw e «bop» e₂,(a, l₀ ++ aa, b),ba⟩ → ⟨throw e,(a, l₀ ++ aa, b),ba⟩› 73. ‹⋀(v₁::val) (bop::bop) (e::char list exp) (a::heap) (aa::sfields) (b::sheap) (ba::bool) l₀::sfields. (P::(char list list × char list exp) prog) ⊢ ⟨Val v₁ «bop» throw e,(a, l₀ ++ aa, b),ba⟩ → ⟨throw e,(a, l₀ ++ aa, b),ba⟩› 74. ‹⋀(V::char list) (e::char list exp) (a::heap) (aa::sfields) (b::sheap) (ba::bool) l₀::sfields. (P::(char list list × char list exp) prog) ⊢ ⟨V:=throw e,(a, l₀ ++ aa, b),ba⟩ → ⟨throw e,(a, l₀ ++ aa, b),ba⟩› 75. ‹⋀(e::char list exp) (F::char list) (D::char list) (a::heap) (aa::sfields) (b::sheap) (ba::bool) l₀::sfields. (P::(char list list × char list exp) prog) ⊢ ⟨throw e∙F{D},(a, l₀ ++ aa, b),ba⟩ → ⟨throw e,(a, l₀ ++ aa, b),ba⟩› 76. ‹⋀(e::char list exp) (F::char list) (D::char list) (e₂::char list exp) (a::heap) (aa::sfields) (b::sheap) (ba::bool) l₀::sfields. (P::(char list list × char list exp) prog) ⊢ ⟨throw e∙F{D} := e₂,(a, l₀ ++ aa, b),ba⟩ → ⟨throw e,(a, l₀ ++ aa, b),ba⟩› 77. ‹⋀(v::val) (F::char list) (D::char list) (e::char list exp) (a::heap) (aa::sfields) (b::sheap) (ba::bool) l₀::sfields. (P::(char list list × char list exp) prog) ⊢ ⟨Val v∙F{D} := throw e,(a, l₀ ++ aa, b),ba⟩ → ⟨throw e,(a, l₀ ++ aa, b),ba⟩› 78. ‹⋀(C::char list) (F::char list) (D::char list) (e::char list exp) (a::heap) (aa::sfields) (b::sheap) (ba::bool) l₀::sfields. (P::(char list list × char list exp) prog) ⊢ ⟨C∙⇩sF{D} := throw e,(a, l₀ ++ aa, b),ba⟩ → ⟨throw e,(a, l₀ ++ aa, b),ba⟩› 79. ‹⋀(e::char list exp) (M::char list) (es::char list exp list) (a::heap) (aa::sfields) (b::sheap) (ba::bool) l₀::sfields. (P::(char list list × char list exp) prog) ⊢ ⟨throw e∙M(es),(a, l₀ ++ aa, b),ba⟩ → ⟨throw e,(a, l₀ ++ aa, b),ba⟩› 80. ‹⋀(es::char list exp list) (vs::val list) (e::char list exp) (es'::char list exp list) (v::val) (M::char list) (a::heap) (aa::sfields) (b::sheap) (ba::bool) l₀::sfields. es = map Val vs @ throw e # es' ⟹ (P::(char list list × char list exp) prog) ⊢ ⟨Val v∙M(es),(a, l₀ ++ aa, b),ba⟩ → ⟨throw e,(a, l₀ ++ aa, b),ba⟩› 81. ‹⋀(es::char list exp list) (vs::val list) (e::char list exp) (es'::char list exp list) (C::char list) (M::char list) (a::heap) (aa::sfields) (b::sheap) (ba::bool) l₀::sfields. es = map Val vs @ throw e # es' ⟹ (P::(char list list × char list exp) prog) ⊢ ⟨C∙⇩sM(es),(a, l₀ ++ aa, b),ba⟩ → ⟨throw e,(a, l₀ ++ aa, b),ba⟩› 82. ‹⋀(V::char list) (T::ty) (a::nat) (aa::heap) (ab::sfields) (b::sheap) (ba::bool) l₀::sfields. (P::(char list list × char list exp) prog) ⊢ ⟨{V:T; Throw a},(aa, l₀ ++ ab, b),ba⟩ → ⟨Throw a,(aa, l₀ ++ ab, b),ba⟩› 83. ‹⋀(V::char list) (T::ty) (v::val) (a::nat) (aa::heap) (ab::sfields) (b::sheap) (ba::bool) l₀::sfields. (P::(char list list × char list exp) prog) ⊢ ⟨{V:T; V:=Val v;; Throw a},(aa, l₀ ++ ab, b),ba⟩ → ⟨Throw a,(aa, l₀ ++ ab, b),ba⟩› 84. ‹⋀(e::char list exp) (e₂::char list exp) (a::heap) (aa::sfields) (b::sheap) (ba::bool) l₀::sfields. (P::(char list list × char list exp) prog) ⊢ ⟨throw e;; e₂,(a, l₀ ++ aa, b),ba⟩ → ⟨throw e,(a, l₀ ++ aa, b),ba⟩› 85. ‹⋀(e::char list exp) (e₁::char list exp) (e₂::char list exp) (a::heap) (aa::sfields) (b::sheap) (ba::bool) l₀::sfields. (P::(char list list × char list exp) prog) ⊢ ⟨if (throw e) e₁ else e₂,(a, l₀ ++ aa, b),ba⟩ → ⟨throw e,(a, l₀ ++ aa, b),ba⟩› 86. ‹⋀(e::char list exp) (a::heap) (aa::sfields) (b::sheap) (ba::bool) l₀::sfields. (P::(char list list × char list exp) prog) ⊢ ⟨throw (throw e),(a, l₀ ++ aa, b),ba⟩ → ⟨throw e,(a, l₀ ++ aa, b),ba⟩› 87. ‹⋀(sh::sheap) (C::char list) (sfs::sfields) (i::init_state) (sh'::sheap) (a::nat) (D::char list) (Cs::char list list) (e::char list exp) (h::heap) (l::sfields) (b::bool) l₀::sfields. ⟦sh C = ⌊(sfs, i)⌋; sh' = sh(C ↦ (sfs, Error))⟧ ⟹ (P::(char list list × char list exp) prog) ⊢ ⟨RI (C,Throw a) ; D # Cs ← e,(h, l₀ ++ l, sh),b⟩ → ⟨RI (D,Throw a) ; Cs ← e,(h, l₀ ++ l, sh'),b⟩› 88. ‹⋀(sh::sheap) (C::char list) (sfs::sfields) (i::init_state) (sh'::sheap) (a::nat) (e::char list exp) (h::heap) (l::sfields) (b::bool) l₀::sfields. ⟦sh C = ⌊(sfs, i)⌋; sh' = sh(C ↦ (sfs, Error))⟧ ⟹ (P::(char list list × char list exp) prog) ⊢ ⟨RI (C,Throw a) ; [] ← e,(h, l₀ ++ l, sh),b⟩ → ⟨Throw a,(h, l₀ ++ l, sh'),b⟩›*) case RedTryCatch (*‹hp (a___, aa___, ba___) a_ = ⌊(D_, fs_)⌋› ‹(P::(char list list × char list exp) prog) ⊢ (D_::char list) ≼⇧* (C_::char list)›*) thus "?case" (*goal: ‹P ⊢ ⟨try Throw a_ catch(C_ V_) e₂_,(a___, l₀ ++ aa___, ba___),b_⟩ → ⟨{V_:Class C_; V_:=addr a_;; e₂_},(a___, l₀ ++ aa___, ba___),b_⟩›*) by (fastforce intro:red_reds.intros (*‹⟦new_Addr ?h = ⌊?a⌋; ?P ⊢ ?C has_fields ?FDTs; ?h' = ?h(?a ↦ blank ?P ?C)⟧ ⟹ ?P ⊢ ⟨new ?C,(?h, ?l, ?sh),True⟩ → ⟨addr ?a,(?h', ?l, ?sh),False⟩› ‹⟦new_Addr ?h = None; is_class ?P ?C⟧ ⟹ ?P ⊢ ⟨new ?C,(?h, ?l, ?sh),True⟩ → ⟨THROW OutOfMemory,(?h, ?l, ?sh),False⟩› ‹?sh ?C = ⌊(?sfs, Done)⌋ ⟹ ?P ⊢ ⟨new ?C,(?h, ?l, ?sh),False⟩ → ⟨new ?C,(?h, ?l, ?sh),True⟩› ‹⟦∄sfs. ?sh ?C = ⌊(sfs, Done)⌋; is_class ?P ?C⟧ ⟹ ?P ⊢ ⟨new ?C,(?h, ?l, ?sh),False⟩ → ⟨INIT ?C ([?C],False) ← new ?C,(?h, ?l, ?sh),False⟩› ‹?P ⊢ ⟨?e,?s,?b⟩ → ⟨?e',?s',?b'⟩ ⟹ ?P ⊢ ⟨Cast ?C ?e,?s,?b⟩ → ⟨Cast ?C ?e',?s',?b'⟩› ‹?P ⊢ ⟨Cast ?C null,?s,?b⟩ → ⟨null,?s,?b⟩› ‹⟦?h ?a = ⌊(?D, ?fs)⌋; ?P ⊢ ?D ≼⇧* ?C⟧ ⟹ ?P ⊢ ⟨Cast ?C (addr ?a),(?h, ?l, ?sh),?b⟩ → ⟨addr ?a,(?h, ?l, ?sh),?b⟩› ‹⟦?h ?a = ⌊(?D, ?fs)⌋; (?D, ?C) ∉ (subcls1 ?P)⇧*⟧ ⟹ ?P ⊢ ⟨Cast ?C (addr ?a),(?h, ?l, ?sh),?b⟩ → ⟨THROW ClassCast,(?h, ?l, ?sh),?b⟩› ‹?P ⊢ ⟨?e,?s,?b⟩ → ⟨?e',?s',?b'⟩ ⟹ ?P ⊢ ⟨?e «?bop» ?e₂,?s,?b⟩ → ⟨?e' «?bop» ?e₂,?s',?b'⟩› ‹?P ⊢ ⟨?e,?s,?b⟩ → ⟨?e',?s',?b'⟩ ⟹ ?P ⊢ ⟨Val ?v₁ «?bop» ?e,?s,?b⟩ → ⟨Val ?v₁ «?bop» ?e',?s',?b'⟩› ‹binop (?bop, ?v₁, ?v₂) = ⌊?v⌋ ⟹ ?P ⊢ ⟨Val ?v₁ «?bop» Val ?v₂,?s,?b⟩ → ⟨Val ?v,?s,?b⟩› ‹?l ?V = ⌊?v⌋ ⟹ ?P ⊢ ⟨Var ?V,(?h, ?l, ?sh),?b⟩ → ⟨Val ?v,(?h, ?l, ?sh),?b⟩› and more 83 facts*)) next (*goals: 1. ‹⋀h a C FDTs h' l sh l₀. ⟦new_Addr h = ⌊a⌋; P ⊢ C has_fields FDTs; h' = h(a ↦ blank P C)⟧ ⟹ P ⊢ ⟨new C,(h, l₀ ++ l, sh),True⟩ → ⟨addr a,(h', l₀ ++ l, sh),False⟩› 2. ‹⋀h C l sh l₀. ⟦new_Addr h = None; is_class P C⟧ ⟹ P ⊢ ⟨new C,(h, l₀ ++ l, sh),True⟩ → ⟨THROW OutOfMemory,(h, l₀ ++ l, sh),False⟩› 3. ‹⋀sh C sfs h l l₀. sh C = ⌊(sfs, Done)⌋ ⟹ P ⊢ ⟨new C,(h, l₀ ++ l, sh),False⟩ → ⟨new C,(h, l₀ ++ l, sh),True⟩› 4. ‹⋀sh C h l l₀. ⟦∄sfs. sh C = ⌊(sfs, Done)⌋; is_class P C⟧ ⟹ P ⊢ ⟨new C,(h, l₀ ++ l, sh),False⟩ → ⟨INIT C ([C],False) ← new C,(h, l₀ ++ l, sh),False⟩› 5. ‹⋀e a aa b ba e' ab ac bb b' C l₀. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⋀l₀. P ⊢ ⟨e,(a, l₀ ++ aa, b),ba⟩ → ⟨e',(ab, l₀ ++ ac, bb),b'⟩⟧ ⟹ P ⊢ ⟨Cast C e,(a, l₀ ++ aa, b),ba⟩ → ⟨Cast C e',(ab, l₀ ++ ac, bb),b'⟩› 6. ‹⋀C a aa b ba l₀. P ⊢ ⟨Cast C null,(a, l₀ ++ aa, b),ba⟩ → ⟨null,(a, l₀ ++ aa, b),ba⟩› 7. ‹⋀e a aa b ba e' ab ac bb b' bop e₂ l₀. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⋀l₀. P ⊢ ⟨e,(a, l₀ ++ aa, b),ba⟩ → ⟨e',(ab, l₀ ++ ac, bb),b'⟩⟧ ⟹ P ⊢ ⟨e «bop» e₂,(a, l₀ ++ aa, b),ba⟩ → ⟨e' «bop» e₂,(ab, l₀ ++ ac, bb),b'⟩› 8. ‹⋀e a aa b ba e' ab ac bb b' v₁ bop l₀. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⋀l₀. P ⊢ ⟨e,(a, l₀ ++ aa, b),ba⟩ → ⟨e',(ab, l₀ ++ ac, bb),b'⟩⟧ ⟹ P ⊢ ⟨Val v₁ «bop» e,(a, l₀ ++ aa, b),ba⟩ → ⟨Val v₁ «bop» e',(ab, l₀ ++ ac, bb),b'⟩› 9. ‹⋀bop v₁ v₂ v a aa b ba l₀. binop (bop, v₁, v₂) = ⌊v⌋ ⟹ P ⊢ ⟨Val v₁ «bop» Val v₂,(a, l₀ ++ aa, b),ba⟩ → ⟨Val v,(a, l₀ ++ aa, b),ba⟩› 10. ‹⋀l V v h sh b l₀. l V = ⌊v⌋ ⟹ P ⊢ ⟨Var V,(h, l₀ ++ l, sh),b⟩ → ⟨Val v,(h, l₀ ++ l, sh),b⟩› 11. ‹⋀e a aa b ba e' ab ac bb b' V l₀. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⋀l₀. P ⊢ ⟨e,(a, l₀ ++ aa, b),ba⟩ → ⟨e',(ab, l₀ ++ ac, bb),b'⟩⟧ ⟹ P ⊢ ⟨V:=e,(a, l₀ ++ aa, b),ba⟩ → ⟨V:=e',(ab, l₀ ++ ac, bb),b'⟩› 12. ‹⋀V v h l sh b l₀. P ⊢ ⟨V:=Val v,(h, l₀ ++ l, sh),b⟩ → ⟨unit,(h, l₀ ++ l(V ↦ v), sh),b⟩› 13. ‹⋀e a aa b ba e' ab ac bb b' F D l₀. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⋀l₀. P ⊢ ⟨e,(a, l₀ ++ aa, b),ba⟩ → ⟨e',(ab, l₀ ++ ac, bb),b'⟩⟧ ⟹ P ⊢ ⟨e∙F{D},(a, l₀ ++ aa, b),ba⟩ → ⟨e'∙F{D},(ab, l₀ ++ ac, bb),b'⟩› 14. ‹⋀F D a aa b ba l₀. P ⊢ ⟨null∙F{D},(a, l₀ ++ aa, b),ba⟩ → ⟨THROW NullPointer,(a, l₀ ++ aa, b),ba⟩› 15. ‹⋀h a C fs F D l sh b l₀. ⟦h a = ⌊(C, fs)⌋; ∄b t. P ⊢ C has F,b:t in D⟧ ⟹ P ⊢ ⟨addr a∙F{D},(h, l₀ ++ l, sh),b⟩ → ⟨THROW NoSuchFieldError,(h, l₀ ++ l, sh),b⟩› 16. ‹⋀h a C fs F t D l sh b l₀. ⟦h a = ⌊(C, fs)⌋; P ⊢ C has F,Static:t in D⟧ ⟹ P ⊢ ⟨addr a∙F{D},(h, l₀ ++ l, sh),b⟩ → ⟨THROW IncompatibleClassChangeError,(h, l₀ ++ l, sh),b⟩› 17. ‹⋀C F t D sh sfs i v h l l₀. ⟦P ⊢ C has F,Static:t in D; sh D = ⌊(sfs, i)⌋; sfs F = ⌊v⌋⟧ ⟹ P ⊢ ⟨C∙⇩sF{D},(h, l₀ ++ l, sh),True⟩ → ⟨Val v,(h, l₀ ++ l, sh),False⟩› 18. ‹⋀C F t D sh sfs h l l₀. ⟦P ⊢ C has F,Static:t in D; sh D = ⌊(sfs, Done)⌋⟧ ⟹ P ⊢ ⟨C∙⇩sF{D},(h, l₀ ++ l, sh),False⟩ → ⟨C∙⇩sF{D},(h, l₀ ++ l, sh),True⟩› 19. ‹⋀C F t D sh h l l₀. ⟦P ⊢ C has F,Static:t in D; ∄sfs. sh D = ⌊(sfs, Done)⌋⟧ ⟹ P ⊢ ⟨C∙⇩sF{D},(h, l₀ ++ l, sh),False⟩ → ⟨INIT D ([D],False) ← C∙⇩sF{D},(h, l₀ ++ l, sh),False⟩› 20. ‹⋀C F D h l sh b l₀. ∄b t. P ⊢ C has F,b:t in D ⟹ P ⊢ ⟨C∙⇩sF{D},(h, l₀ ++ l, sh),b⟩ → ⟨THROW NoSuchFieldError,(h, l₀ ++ l, sh),False⟩› 21. ‹⋀C F t D h l sh b l₀. P ⊢ C has F,NonStatic:t in D ⟹ P ⊢ ⟨C∙⇩sF{D},(h, l₀ ++ l, sh),b⟩ → ⟨THROW IncompatibleClassChangeError,(h, l₀ ++ l, sh),False⟩› 22. ‹⋀e a aa b ba e' ab ac bb b' F D e₂ l₀. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⋀l₀. P ⊢ ⟨e,(a, l₀ ++ aa, b),ba⟩ → ⟨e',(ab, l₀ ++ ac, bb),b'⟩⟧ ⟹ P ⊢ ⟨e∙F{D} := e₂,(a, l₀ ++ aa, b),ba⟩ → ⟨e'∙F{D} := e₂,(ab, l₀ ++ ac, bb),b'⟩› 23. ‹⋀e a aa b ba e' ab ac bb b' v F D l₀. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⋀l₀. P ⊢ ⟨e,(a, l₀ ++ aa, b),ba⟩ → ⟨e',(ab, l₀ ++ ac, bb),b'⟩⟧ ⟹ P ⊢ ⟨Val v∙F{D} := e,(a, l₀ ++ aa, b),ba⟩ → ⟨Val v∙F{D} := e',(ab, l₀ ++ ac, bb),b'⟩› 24. ‹⋀C F t D h a fs v l sh b l₀. ⟦P ⊢ C has F,NonStatic:t in D; h a = ⌊(C, fs)⌋⟧ ⟹ P ⊢ ⟨addr a∙F{D} := Val v,(h, l₀ ++ l, sh),b⟩ → ⟨unit,(h(a ↦ (C, fs((F, D) ↦ v))), l₀ ++ l, sh),b⟩› 25. ‹⋀F D v a aa b ba l₀. P ⊢ ⟨null∙F{D} := Val v,(a, l₀ ++ aa, b),ba⟩ → ⟨THROW NullPointer,(a, l₀ ++ aa, b),ba⟩› 26. ‹⋀h a C fs F D v l sh b l₀. ⟦h a = ⌊(C, fs)⌋; ∄b t. P ⊢ C has F,b:t in D⟧ ⟹ P ⊢ ⟨addr a∙F{D} := Val v,(h, l₀ ++ l, sh),b⟩ → ⟨THROW NoSuchFieldError,(h, l₀ ++ l, sh),b⟩› 27. ‹⋀h a C fs F t D v l sh b l₀. ⟦h a = ⌊(C, fs)⌋; P ⊢ C has F,Static:t in D⟧ ⟹ P ⊢ ⟨addr a∙F{D} := Val v,(h, l₀ ++ l, sh),b⟩ → ⟨THROW IncompatibleClassChangeError,(h, l₀ ++ l, sh),b⟩› 28. ‹⋀e a aa b ba e' ab ac bb b' C F D l₀. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⋀l₀. P ⊢ ⟨e,(a, l₀ ++ aa, b),ba⟩ → ⟨e',(ab, l₀ ++ ac, bb),b'⟩⟧ ⟹ P ⊢ ⟨C∙⇩sF{D} := e,(a, l₀ ++ aa, b),ba⟩ → ⟨C∙⇩sF{D} := e',(ab, l₀ ++ ac, bb),b'⟩› 29. ‹⋀C F t D sh sfs i sfs' v sh' h l l₀. ⟦P ⊢ C has F,Static:t in D; sh D = ⌊(sfs, i)⌋; sfs' = sfs(F ↦ v); sh' = sh(D ↦ (sfs', i))⟧ ⟹ P ⊢ ⟨C∙⇩sF{D} := Val v,(h, l₀ ++ l, sh),True⟩ → ⟨unit,(h, l₀ ++ l, sh'),False⟩› 30. ‹⋀C F t D sh sfs v h l l₀. ⟦P ⊢ C has F,Static:t in D; sh D = ⌊(sfs, Done)⌋⟧ ⟹ P ⊢ ⟨C∙⇩sF{D} := Val v,(h, l₀ ++ l, sh),False⟩ → ⟨C∙⇩sF{D} := Val v,(h, l₀ ++ l, sh),True⟩› 31. ‹⋀C F t D sh v h l l₀. ⟦P ⊢ C has F,Static:t in D; ∄sfs. sh D = ⌊(sfs, Done)⌋⟧ ⟹ P ⊢ ⟨C∙⇩sF{D} := Val v,(h, l₀ ++ l, sh),False⟩ → ⟨INIT D ([D],False) ← C∙⇩sF{D} := Val v,(h, l₀ ++ l, sh),False⟩› 32. ‹⋀C F D v a aa b ba l₀. ∄b t. P ⊢ C has F,b:t in D ⟹ P ⊢ ⟨C∙⇩sF{D} := Val v,(a, l₀ ++ aa, b),ba⟩ → ⟨THROW NoSuchFieldError,(a, l₀ ++ aa, b),False⟩› 33. ‹⋀C F t D v a aa b ba l₀. P ⊢ C has F,NonStatic:t in D ⟹ P ⊢ ⟨C∙⇩sF{D} := Val v,(a, l₀ ++ aa, b),ba⟩ → ⟨THROW IncompatibleClassChangeError,(a, l₀ ++ aa, b),False⟩› 34. ‹⋀e a aa b ba e' ab ac bb b' M es l₀. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⋀l₀. P ⊢ ⟨e,(a, l₀ ++ aa, b),ba⟩ → ⟨e',(ab, l₀ ++ ac, bb),b'⟩⟧ ⟹ P ⊢ ⟨e∙M(es),(a, l₀ ++ aa, b),ba⟩ → ⟨e'∙M(es),(ab, l₀ ++ ac, bb),b'⟩› 35. ‹⋀es a aa b ba es' ab ac bb b' v M l₀. ⟦P ⊢ ⟨es,(a, aa, b),ba⟩ [→] ⟨es',(ab, ac, bb),b'⟩; ⋀l₀. P ⊢ ⟨es,(a, l₀ ++ aa, b),ba⟩ [→] ⟨es',(ab, l₀ ++ ac, bb),b'⟩⟧ ⟹ P ⊢ ⟨Val v∙M(es),(a, l₀ ++ aa, b),ba⟩ → ⟨Val v∙M(es'),(ab, l₀ ++ ac, bb),b'⟩› 36. ‹⋀M vs a aa b ba l₀. P ⊢ ⟨null∙M(map Val vs),(a, l₀ ++ aa, b),ba⟩ → ⟨THROW NullPointer,(a, l₀ ++ aa, b),ba⟩› 37. ‹⋀h a C fs M vs l sh b l₀. ⟦h a = ⌊(C, fs)⌋; ∄b Ts T m D. P ⊢ C sees M, b : Ts→T = m in D⟧ ⟹ P ⊢ ⟨addr a∙M(map Val vs),(h, l₀ ++ l, sh),b⟩ → ⟨THROW NoSuchMethodError,(h, l₀ ++ l, sh),b⟩› 38. ‹⋀h a C fs M Ts T aa b D vs l sh ba l₀. ⟦h a = ⌊(C, fs)⌋; P ⊢ C sees M, Static : Ts→T = (aa, b) in D⟧ ⟹ P ⊢ ⟨addr a∙M(map Val vs),(h, l₀ ++ l, sh),ba⟩ → ⟨THROW IncompatibleClassChangeError,(h, l₀ ++ l, sh),ba⟩› 39. ‹⋀es a aa b ba es' ab ac bb b' C M l₀. ⟦P ⊢ ⟨es,(a, aa, b),ba⟩ [→] ⟨es',(ab, ac, bb),b'⟩; ⋀l₀. P ⊢ ⟨es,(a, l₀ ++ aa, b),ba⟩ [→] ⟨es',(ab, l₀ ++ ac, bb),b'⟩⟧ ⟹ P ⊢ ⟨C∙⇩sM(es),(a, l₀ ++ aa, b),ba⟩ → ⟨C∙⇩sM(es'),(ab, l₀ ++ ac, bb),b'⟩› 40. ‹⋀C M Ts T pns body D vs a aa b l₀. ⟦P ⊢ C sees M, Static : Ts→T = (pns, body) in D; length vs = length pns; length Ts = length pns⟧ ⟹ P ⊢ ⟨C∙⇩sM(map Val vs),(a, l₀ ++ aa, b),True⟩ → ⟨blocks (pns, Ts, vs, body),(a, l₀ ++ aa, b),False⟩› 41. ‹⋀C M Ts T pns body D sh sfs vs h l l₀. ⟦P ⊢ C sees M, Static : Ts→T = (pns, body) in D; sh D = ⌊(sfs, Done)⌋ ∨ M = clinit ∧ sh D = ⌊(sfs, Processing)⌋⟧ ⟹ P ⊢ ⟨C∙⇩sM(map Val vs),(h, l₀ ++ l, sh),False⟩ → ⟨C∙⇩sM(map Val vs),(h, l₀ ++ l, sh),True⟩› 42. ‹⋀C M Ts T pns body D sh vs h l l₀. ⟦P ⊢ C sees M, Static : Ts→T = (pns, body) in D; ∄sfs. sh D = ⌊(sfs, Done)⌋; M ≠ clinit⟧ ⟹ P ⊢ ⟨C∙⇩sM(map Val vs),(h, l₀ ++ l, sh),False⟩ → ⟨INIT D ([D],False) ← C∙⇩sM(map Val vs),(h, l₀ ++ l, sh),False⟩› 43. ‹⋀C M vs a aa b ba l₀. ∄b Ts T m. Ex (Method P C M b Ts T m) ⟹ P ⊢ ⟨C∙⇩sM(map Val vs),(a, l₀ ++ aa, b),ba⟩ → ⟨THROW NoSuchMethodError,(a, l₀ ++ aa, b),False⟩› 44. ‹⋀C M Ts T a b D vs aa ab ba bb l₀. P ⊢ C sees M, NonStatic : Ts→T = (a, b) in D ⟹ P ⊢ ⟨C∙⇩sM(map Val vs),(aa, l₀ ++ ab, ba),bb⟩ → ⟨THROW IncompatibleClassChangeError,(aa, l₀ ++ ab, ba),False⟩› 45. ‹⋀V T u a aa b ba l₀. P ⊢ ⟨{V:T; Val u},(a, l₀ ++ aa, b),ba⟩ → ⟨Val u,(a, l₀ ++ aa, b),ba⟩› 46. ‹⋀V T v u a aa b ba l₀. P ⊢ ⟨{V:T; V:=Val v;; Val u},(a, l₀ ++ aa, b),ba⟩ → ⟨Val u,(a, l₀ ++ aa, b),ba⟩› 47. ‹⋀e a aa b ba e' ab ac bb b' e₂ l₀. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⋀l₀. P ⊢ ⟨e,(a, l₀ ++ aa, b),ba⟩ → ⟨e',(ab, l₀ ++ ac, bb),b'⟩⟧ ⟹ P ⊢ ⟨e;; e₂,(a, l₀ ++ aa, b),ba⟩ → ⟨e';; e₂,(ab, l₀ ++ ac, bb),b'⟩› 48. ‹⋀v e₂ a aa b ba l₀. P ⊢ ⟨Val v;; e₂,(a, l₀ ++ aa, b),ba⟩ → ⟨e₂,(a, l₀ ++ aa, b),ba⟩› 49. ‹⋀e a aa b ba e' ab ac bb b' e₁ e₂ l₀. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⋀l₀. P ⊢ ⟨e,(a, l₀ ++ aa, b),ba⟩ → ⟨e',(ab, l₀ ++ ac, bb),b'⟩⟧ ⟹ P ⊢ ⟨if (e) e₁ else e₂,(a, l₀ ++ aa, b),ba⟩ → ⟨if (e') e₁ else e₂,(ab, l₀ ++ ac, bb),b'⟩› 50. ‹⋀e₁ e₂ a aa b ba l₀. P ⊢ ⟨if (true) e₁ else e₂,(a, l₀ ++ aa, b),ba⟩ → ⟨e₁,(a, l₀ ++ aa, b),ba⟩› 51. ‹⋀e₁ e₂ a aa b ba l₀. P ⊢ ⟨if (false) e₁ else e₂,(a, l₀ ++ aa, b),ba⟩ → ⟨e₂,(a, l₀ ++ aa, b),ba⟩› 52. ‹⋀b c a aa ba b' l₀. P ⊢ ⟨while (b) c,(a, l₀ ++ aa, ba),b'⟩ → ⟨if (b) (c;; while (b) c) else unit,(a, l₀ ++ aa, ba),b'⟩› 53. ‹⋀e a aa b ba e' ab ac bb b' l₀. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⋀l₀. P ⊢ ⟨e,(a, l₀ ++ aa, b),ba⟩ → ⟨e',(ab, l₀ ++ ac, bb),b'⟩⟧ ⟹ P ⊢ ⟨throw e,(a, l₀ ++ aa, b),ba⟩ → ⟨throw e',(ab, l₀ ++ ac, bb),b'⟩› 54. ‹⋀a aa b ba l₀. P ⊢ ⟨throw null,(a, l₀ ++ aa, b),ba⟩ → ⟨THROW NullPointer,(a, l₀ ++ aa, b),ba⟩› 55. ‹⋀e a aa b ba e' ab ac bb b' C V e₂ l₀. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⋀l₀. P ⊢ ⟨e,(a, l₀ ++ aa, b),ba⟩ → ⟨e',(ab, l₀ ++ ac, bb),b'⟩⟧ ⟹ P ⊢ ⟨try e catch(C V) e₂,(a, l₀ ++ aa, b),ba⟩ → ⟨try e' catch(C V) e₂,(ab, l₀ ++ ac, bb),b'⟩› 56. ‹⋀v C V e₂ a aa b ba l₀. P ⊢ ⟨try Val v catch(C V) e₂,(a, l₀ ++ aa, b),ba⟩ → ⟨Val v,(a, l₀ ++ aa, b),ba⟩› 57. ‹⋀a aa b ab D fs C V e₂ ba l₀. ⟦hp (a, aa, b) ab = ⌊(D, fs)⌋; (D, C) ∉ (subcls1 P)⇧*⟧ ⟹ P ⊢ ⟨try Throw ab catch(C V) e₂,(a, l₀ ++ aa, b),ba⟩ → ⟨Throw ab,(a, l₀ ++ aa, b),ba⟩› 58. ‹⋀e a aa b ba e' ab ac bb b' es l₀. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⋀l₀. P ⊢ ⟨e,(a, l₀ ++ aa, b),ba⟩ → ⟨e',(ab, l₀ ++ ac, bb),b'⟩⟧ ⟹ P ⊢ ⟨e # es,(a, l₀ ++ aa, b),ba⟩ [→] ⟨e' # es,(ab, l₀ ++ ac, bb),b'⟩› 59. ‹⋀es a aa b ba es' ab ac bb b' v l₀. ⟦P ⊢ ⟨es,(a, aa, b),ba⟩ [→] ⟨es',(ab, ac, bb),b'⟩; ⋀l₀. P ⊢ ⟨es,(a, l₀ ++ aa, b),ba⟩ [→] ⟨es',(ab, l₀ ++ ac, bb),b'⟩⟧ ⟹ P ⊢ ⟨Val v # es,(a, l₀ ++ aa, b),ba⟩ [→] ⟨Val v # es',(ab, l₀ ++ ac, bb),b'⟩› 60. ‹⋀e C b a aa ba b' l₀. ¬ sub_RI e ⟹ P ⊢ ⟨INIT C ([],b) ← e,(a, l₀ ++ aa, ba),b'⟩ → ⟨e,(a, l₀ ++ aa, ba),icheck P C e⟩› 61. ‹⋀sh C C' Cs e h l b l₀. sh C = None ⟹ P ⊢ ⟨INIT C' (C # Cs,False) ← e,(h, l₀ ++ l, sh),b⟩ → ⟨INIT C' (C # Cs,False) ← e,(h, l₀ ++ l, sh(C ↦ (sblank P C, Prepared))),b⟩› 62. ‹⋀sh C sfs C' Cs e h l b l₀. sh C = ⌊(sfs, Done)⌋ ⟹ P ⊢ ⟨INIT C' (C # Cs,False) ← e,(h, l₀ ++ l, sh),b⟩ → ⟨INIT C' (Cs,True) ← e,(h, l₀ ++ l, sh),b⟩› 63. ‹⋀sh C sfs C' Cs e h l b l₀. sh C = ⌊(sfs, Processing)⌋ ⟹ P ⊢ ⟨INIT C' (C # Cs,False) ← e,(h, l₀ ++ l, sh),b⟩ → ⟨INIT C' (Cs,True) ← e,(h, l₀ ++ l, sh),b⟩› 64. ‹⋀sh C sfs C' Cs e h l b l₀. sh C = ⌊(sfs, Error)⌋ ⟹ P ⊢ ⟨INIT C' (C # Cs,False) ← e,(h, l₀ ++ l, sh),b⟩ → ⟨RI (C,THROW NoClassDefFoundError) ; Cs ← e,(h, l₀ ++ l, sh),b⟩› 65. ‹⋀sh C sfs sh' C' Cs e h l b l₀. ⟦sh C = ⌊(sfs, Prepared)⌋; C = Object; sh' = sh(C ↦ (sfs, Processing))⟧ ⟹ P ⊢ ⟨INIT C' (C # Cs,False) ← e,(h, l₀ ++ l, sh),b⟩ → ⟨INIT C' (C # Cs,True) ← e,(h, l₀ ++ l, sh'),b⟩› 66. ‹⋀sh C sfs D a b sh' C' Cs e h l ba l₀. ⟦sh C = ⌊(sfs, Prepared)⌋; C ≠ Object; class P C = ⌊(D, a, b)⌋; sh' = sh(C ↦ (sfs, Processing))⟧ ⟹ P ⊢ ⟨INIT C' (C # Cs,False) ← e,(h, l₀ ++ l, sh),ba⟩ → ⟨INIT C' (D # C # Cs,False) ← e,(h, l₀ ++ l, sh'),ba⟩› 67. ‹⋀C' C Cs e h l sh b l₀. P ⊢ ⟨INIT C' (C # Cs,True) ← e,(h, l₀ ++ l, sh),b⟩ → ⟨RI (C,C∙⇩sclinit([])) ; Cs ← e,(h, l₀ ++ l, sh),b⟩› 68. ‹⋀e a aa b ba e' ab ac bb b' C Cs e₀ l₀. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⋀l₀. P ⊢ ⟨e,(a, l₀ ++ aa, b),ba⟩ → ⟨e',(ab, l₀ ++ ac, bb),b'⟩⟧ ⟹ P ⊢ ⟨RI (C,e) ; Cs ← e₀,(a, l₀ ++ aa, b),ba⟩ → ⟨RI (C,e') ; Cs ← e₀,(ab, l₀ ++ ac, bb),b'⟩› 69. ‹⋀sh C sfs i sh' C' Cs v e h l b l₀. ⟦sh C = ⌊(sfs, i)⌋; sh' = sh(C ↦ (sfs, Done)); C' = last (C # Cs)⟧ ⟹ P ⊢ ⟨RI (C,Val v) ; Cs ← e,(h, l₀ ++ l, sh),b⟩ → ⟨INIT C' (Cs,True) ← e,(h, l₀ ++ l, sh'),b⟩› 70. ‹⋀C e a aa b ba l₀. P ⊢ ⟨Cast C (throw e),(a, l₀ ++ aa, b),ba⟩ → ⟨throw e,(a, l₀ ++ aa, b),ba⟩› 71. ‹⋀e bop e₂ a aa b ba l₀. P ⊢ ⟨throw e «bop» e₂,(a, l₀ ++ aa, b),ba⟩ → ⟨throw e,(a, l₀ ++ aa, b),ba⟩› 72. ‹⋀v₁ bop e a aa b ba l₀. P ⊢ ⟨Val v₁ «bop» throw e,(a, l₀ ++ aa, b),ba⟩ → ⟨throw e,(a, l₀ ++ aa, b),ba⟩› 73. ‹⋀V e a aa b ba l₀. P ⊢ ⟨V:=throw e,(a, l₀ ++ aa, b),ba⟩ → ⟨throw e,(a, l₀ ++ aa, b),ba⟩› 74. ‹⋀e F D a aa b ba l₀. P ⊢ ⟨throw e∙F{D},(a, l₀ ++ aa, b),ba⟩ → ⟨throw e,(a, l₀ ++ aa, b),ba⟩› 75. ‹⋀e F D e₂ a aa b ba l₀. P ⊢ ⟨throw e∙F{D} := e₂,(a, l₀ ++ aa, b),ba⟩ → ⟨throw e,(a, l₀ ++ aa, b),ba⟩› 76. ‹⋀v F D e a aa b ba l₀. P ⊢ ⟨Val v∙F{D} := throw e,(a, l₀ ++ aa, b),ba⟩ → ⟨throw e,(a, l₀ ++ aa, b),ba⟩› 77. ‹⋀C F D e a aa b ba l₀. P ⊢ ⟨C∙⇩sF{D} := throw e,(a, l₀ ++ aa, b),ba⟩ → ⟨throw e,(a, l₀ ++ aa, b),ba⟩› 78. ‹⋀e M es a aa b ba l₀. P ⊢ ⟨throw e∙M(es),(a, l₀ ++ aa, b),ba⟩ → ⟨throw e,(a, l₀ ++ aa, b),ba⟩› 79. ‹⋀es vs e es' v M a aa b ba l₀. es = map Val vs @ throw e # es' ⟹ P ⊢ ⟨Val v∙M(es),(a, l₀ ++ aa, b),ba⟩ → ⟨throw e,(a, l₀ ++ aa, b),ba⟩› 80. ‹⋀es vs e es' C M a aa b ba l₀. es = map Val vs @ throw e # es' ⟹ P ⊢ ⟨C∙⇩sM(es),(a, l₀ ++ aa, b),ba⟩ → ⟨throw e,(a, l₀ ++ aa, b),ba⟩› 81. ‹⋀V T a aa ab b ba l₀. P ⊢ ⟨{V:T; Throw a},(aa, l₀ ++ ab, b),ba⟩ → ⟨Throw a,(aa, l₀ ++ ab, b),ba⟩› 82. ‹⋀V T v a aa ab b ba l₀. P ⊢ ⟨{V:T; V:=Val v;; Throw a},(aa, l₀ ++ ab, b),ba⟩ → ⟨Throw a,(aa, l₀ ++ ab, b),ba⟩› 83. ‹⋀e e₂ a aa b ba l₀. P ⊢ ⟨throw e;; e₂,(a, l₀ ++ aa, b),ba⟩ → ⟨throw e,(a, l₀ ++ aa, b),ba⟩› 84. ‹⋀e e₁ e₂ a aa b ba l₀. P ⊢ ⟨if (throw e) e₁ else e₂,(a, l₀ ++ aa, b),ba⟩ → ⟨throw e,(a, l₀ ++ aa, b),ba⟩› 85. ‹⋀e a aa b ba l₀. P ⊢ ⟨throw (throw e),(a, l₀ ++ aa, b),ba⟩ → ⟨throw e,(a, l₀ ++ aa, b),ba⟩› 86. ‹⋀sh C sfs i sh' a D Cs e h l b l₀. ⟦sh C = ⌊(sfs, i)⌋; sh' = sh(C ↦ (sfs, Error))⟧ ⟹ P ⊢ ⟨RI (C,Throw a) ; D # Cs ← e,(h, l₀ ++ l, sh),b⟩ → ⟨RI (D,Throw a) ; Cs ← e,(h, l₀ ++ l, sh'),b⟩› 87. ‹⋀sh C sfs i sh' a e h l b l₀. ⟦sh C = ⌊(sfs, i)⌋; sh' = sh(C ↦ (sfs, Error))⟧ ⟹ P ⊢ ⟨RI (C,Throw a) ; [] ← e,(h, l₀ ++ l, sh),b⟩ → ⟨Throw a,(h, l₀ ++ l, sh'),b⟩›*) case RedTryFail (*‹hp (a___::heap, aa___::sfields, ba___::sheap) (a_::nat) = ⌊(D_::char list, fs_::Objects.fields)⌋› ‹(D_::char list, C_::char list) ∉ (subcls1 (P::(char list list × char list exp) prog))⇧*›*) thus "?case" (*goal: ‹(P::(char list list × char list exp) prog) ⊢ ⟨try Throw (a_::nat) catch((C_::char list) (V_::char list)) (e₂_::char list exp),(a___::heap, (l₀::sfields) ++ (aa___::sfields), ba___::sheap),b_::bool⟩ → ⟨Throw a_,(a___, l₀ ++ aa___, ba___),b_⟩›*) by (force intro!:red_reds.intros (*‹⟦new_Addr ?h = ⌊?a⌋; ?P ⊢ ?C has_fields ?FDTs; ?h' = ?h(?a ↦ blank ?P ?C)⟧ ⟹ ?P ⊢ ⟨new ?C,(?h, ?l, ?sh),True⟩ → ⟨addr ?a,(?h', ?l, ?sh),False⟩› ‹⟦new_Addr ?h = None; is_class ?P ?C⟧ ⟹ ?P ⊢ ⟨new ?C,(?h, ?l, ?sh),True⟩ → ⟨THROW OutOfMemory,(?h, ?l, ?sh),False⟩› ‹?sh ?C = ⌊(?sfs, Done)⌋ ⟹ ?P ⊢ ⟨new ?C,(?h, ?l, ?sh),False⟩ → ⟨new ?C,(?h, ?l, ?sh),True⟩› ‹⟦∄sfs. ?sh ?C = ⌊(sfs, Done)⌋; is_class ?P ?C⟧ ⟹ ?P ⊢ ⟨new ?C,(?h, ?l, ?sh),False⟩ → ⟨INIT ?C ([?C],False) ← new ?C,(?h, ?l, ?sh),False⟩› ‹?P ⊢ ⟨?e,?s,?b⟩ → ⟨?e',?s',?b'⟩ ⟹ ?P ⊢ ⟨Cast ?C ?e,?s,?b⟩ → ⟨Cast ?C ?e',?s',?b'⟩› ‹?P ⊢ ⟨Cast ?C null,?s,?b⟩ → ⟨null,?s,?b⟩› ‹⟦?h ?a = ⌊(?D, ?fs)⌋; ?P ⊢ ?D ≼⇧* ?C⟧ ⟹ ?P ⊢ ⟨Cast ?C (addr ?a),(?h, ?l, ?sh),?b⟩ → ⟨addr ?a,(?h, ?l, ?sh),?b⟩› ‹⟦?h ?a = ⌊(?D, ?fs)⌋; (?D, ?C) ∉ (subcls1 ?P)⇧*⟧ ⟹ ?P ⊢ ⟨Cast ?C (addr ?a),(?h, ?l, ?sh),?b⟩ → ⟨THROW ClassCast,(?h, ?l, ?sh),?b⟩› ‹?P ⊢ ⟨?e,?s,?b⟩ → ⟨?e',?s',?b'⟩ ⟹ ?P ⊢ ⟨?e «?bop» ?e₂,?s,?b⟩ → ⟨?e' «?bop» ?e₂,?s',?b'⟩› ‹?P ⊢ ⟨?e,?s,?b⟩ → ⟨?e',?s',?b'⟩ ⟹ ?P ⊢ ⟨Val ?v₁ «?bop» ?e,?s,?b⟩ → ⟨Val ?v₁ «?bop» ?e',?s',?b'⟩› ‹binop (?bop, ?v₁, ?v₂) = ⌊?v⌋ ⟹ ?P ⊢ ⟨Val ?v₁ «?bop» Val ?v₂,?s,?b⟩ → ⟨Val ?v,?s,?b⟩› ‹?l ?V = ⌊?v⌋ ⟹ ?P ⊢ ⟨Var ?V,(?h, ?l, ?sh),?b⟩ → ⟨Val ?v,(?h, ?l, ?sh),?b⟩› and more 83 facts*)) qed (simp_all add:red_reds.intros) (*solves the remaining goals: 1. ‹⋀h a C FDTs h' l sh l₀. ⟦new_Addr h = ⌊a⌋; P ⊢ C has_fields FDTs; h' = h(a ↦ blank P C)⟧ ⟹ P ⊢ ⟨new C,(h, l₀ ++ l, sh),True⟩ → ⟨addr a,(h', l₀ ++ l, sh),False⟩› 2. ‹⋀h C l sh l₀. ⟦new_Addr h = None; is_class P C⟧ ⟹ P ⊢ ⟨new C,(h, l₀ ++ l, sh),True⟩ → ⟨THROW OutOfMemory,(h, l₀ ++ l, sh),False⟩› 3. ‹⋀sh C sfs h l l₀. sh C = ⌊(sfs, Done)⌋ ⟹ P ⊢ ⟨new C,(h, l₀ ++ l, sh),False⟩ → ⟨new C,(h, l₀ ++ l, sh),True⟩› 4. ‹⋀sh C h l l₀. ⟦∄sfs. sh C = ⌊(sfs, Done)⌋; is_class P C⟧ ⟹ P ⊢ ⟨new C,(h, l₀ ++ l, sh),False⟩ → ⟨INIT C ([C],False) ← new C,(h, l₀ ++ l, sh),False⟩› 5. ‹⋀e a aa b ba e' ab ac bb b' C l₀. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⋀l₀. P ⊢ ⟨e,(a, l₀ ++ aa, b),ba⟩ → ⟨e',(ab, l₀ ++ ac, bb),b'⟩⟧ ⟹ P ⊢ ⟨Cast C e,(a, l₀ ++ aa, b),ba⟩ → ⟨Cast C e',(ab, l₀ ++ ac, bb),b'⟩› 6. ‹⋀C a aa b ba l₀. P ⊢ ⟨Cast C null,(a, l₀ ++ aa, b),ba⟩ → ⟨null,(a, l₀ ++ aa, b),ba⟩› 7. ‹⋀e a aa b ba e' ab ac bb b' bop e₂ l₀. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⋀l₀. P ⊢ ⟨e,(a, l₀ ++ aa, b),ba⟩ → ⟨e',(ab, l₀ ++ ac, bb),b'⟩⟧ ⟹ P ⊢ ⟨e «bop» e₂,(a, l₀ ++ aa, b),ba⟩ → ⟨e' «bop» e₂,(ab, l₀ ++ ac, bb),b'⟩› 8. ‹⋀e a aa b ba e' ab ac bb b' v₁ bop l₀. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⋀l₀. P ⊢ ⟨e,(a, l₀ ++ aa, b),ba⟩ → ⟨e',(ab, l₀ ++ ac, bb),b'⟩⟧ ⟹ P ⊢ ⟨Val v₁ «bop» e,(a, l₀ ++ aa, b),ba⟩ → ⟨Val v₁ «bop» e',(ab, l₀ ++ ac, bb),b'⟩› 9. ‹⋀bop v₁ v₂ v a aa b ba l₀. binop (bop, v₁, v₂) = ⌊v⌋ ⟹ P ⊢ ⟨Val v₁ «bop» Val v₂,(a, l₀ ++ aa, b),ba⟩ → ⟨Val v,(a, l₀ ++ aa, b),ba⟩› 10. ‹⋀l V v h sh b l₀. l V = ⌊v⌋ ⟹ P ⊢ ⟨Var V,(h, l₀ ++ l, sh),b⟩ → ⟨Val v,(h, l₀ ++ l, sh),b⟩› 11. ‹⋀e a aa b ba e' ab ac bb b' V l₀. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⋀l₀. P ⊢ ⟨e,(a, l₀ ++ aa, b),ba⟩ → ⟨e',(ab, l₀ ++ ac, bb),b'⟩⟧ ⟹ P ⊢ ⟨V:=e,(a, l₀ ++ aa, b),ba⟩ → ⟨V:=e',(ab, l₀ ++ ac, bb),b'⟩› 12. ‹⋀V v h l sh b l₀. P ⊢ ⟨V:=Val v,(h, l₀ ++ l, sh),b⟩ → ⟨unit,(h, l₀ ++ l(V ↦ v), sh),b⟩› 13. ‹⋀e a aa b ba e' ab ac bb b' F D l₀. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⋀l₀. P ⊢ ⟨e,(a, l₀ ++ aa, b),ba⟩ → ⟨e',(ab, l₀ ++ ac, bb),b'⟩⟧ ⟹ P ⊢ ⟨e∙F{D},(a, l₀ ++ aa, b),ba⟩ → ⟨e'∙F{D},(ab, l₀ ++ ac, bb),b'⟩› 14. ‹⋀F D a aa b ba l₀. P ⊢ ⟨null∙F{D},(a, l₀ ++ aa, b),ba⟩ → ⟨THROW NullPointer,(a, l₀ ++ aa, b),ba⟩› 15. ‹⋀h a C fs F D l sh b l₀. ⟦h a = ⌊(C, fs)⌋; ∄b t. P ⊢ C has F,b:t in D⟧ ⟹ P ⊢ ⟨addr a∙F{D},(h, l₀ ++ l, sh),b⟩ → ⟨THROW NoSuchFieldError,(h, l₀ ++ l, sh),b⟩› 16. ‹⋀h a C fs F t D l sh b l₀. ⟦h a = ⌊(C, fs)⌋; P ⊢ C has F,Static:t in D⟧ ⟹ P ⊢ ⟨addr a∙F{D},(h, l₀ ++ l, sh),b⟩ → ⟨THROW IncompatibleClassChangeError,(h, l₀ ++ l, sh),b⟩› 17. ‹⋀C F t D sh sfs i v h l l₀. ⟦P ⊢ C has F,Static:t in D; sh D = ⌊(sfs, i)⌋; sfs F = ⌊v⌋⟧ ⟹ P ⊢ ⟨C∙⇩sF{D},(h, l₀ ++ l, sh),True⟩ → ⟨Val v,(h, l₀ ++ l, sh),False⟩› 18. ‹⋀C F t D sh sfs h l l₀. ⟦P ⊢ C has F,Static:t in D; sh D = ⌊(sfs, Done)⌋⟧ ⟹ P ⊢ ⟨C∙⇩sF{D},(h, l₀ ++ l, sh),False⟩ → ⟨C∙⇩sF{D},(h, l₀ ++ l, sh),True⟩› 19. ‹⋀C F t D sh h l l₀. ⟦P ⊢ C has F,Static:t in D; ∄sfs. sh D = ⌊(sfs, Done)⌋⟧ ⟹ P ⊢ ⟨C∙⇩sF{D},(h, l₀ ++ l, sh),False⟩ → ⟨INIT D ([D],False) ← C∙⇩sF{D},(h, l₀ ++ l, sh),False⟩› 20. ‹⋀C F D h l sh b l₀. ∄b t. P ⊢ C has F,b:t in D ⟹ P ⊢ ⟨C∙⇩sF{D},(h, l₀ ++ l, sh),b⟩ → ⟨THROW NoSuchFieldError,(h, l₀ ++ l, sh),False⟩› 21. ‹⋀C F t D h l sh b l₀. P ⊢ C has F,NonStatic:t in D ⟹ P ⊢ ⟨C∙⇩sF{D},(h, l₀ ++ l, sh),b⟩ → ⟨THROW IncompatibleClassChangeError,(h, l₀ ++ l, sh),False⟩› 22. ‹⋀e a aa b ba e' ab ac bb b' F D e₂ l₀. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⋀l₀. P ⊢ ⟨e,(a, l₀ ++ aa, b),ba⟩ → ⟨e',(ab, l₀ ++ ac, bb),b'⟩⟧ ⟹ P ⊢ ⟨e∙F{D} := e₂,(a, l₀ ++ aa, b),ba⟩ → ⟨e'∙F{D} := e₂,(ab, l₀ ++ ac, bb),b'⟩› 23. ‹⋀e a aa b ba e' ab ac bb b' v F D l₀. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⋀l₀. P ⊢ ⟨e,(a, l₀ ++ aa, b),ba⟩ → ⟨e',(ab, l₀ ++ ac, bb),b'⟩⟧ ⟹ P ⊢ ⟨Val v∙F{D} := e,(a, l₀ ++ aa, b),ba⟩ → ⟨Val v∙F{D} := e',(ab, l₀ ++ ac, bb),b'⟩› 24. ‹⋀C F t D h a fs v l sh b l₀. ⟦P ⊢ C has F,NonStatic:t in D; h a = ⌊(C, fs)⌋⟧ ⟹ P ⊢ ⟨addr a∙F{D} := Val v,(h, l₀ ++ l, sh),b⟩ → ⟨unit,(h(a ↦ (C, fs((F, D) ↦ v))), l₀ ++ l, sh),b⟩› 25. ‹⋀F D v a aa b ba l₀. P ⊢ ⟨null∙F{D} := Val v,(a, l₀ ++ aa, b),ba⟩ → ⟨THROW NullPointer,(a, l₀ ++ aa, b),ba⟩› 26. ‹⋀h a C fs F D v l sh b l₀. ⟦h a = ⌊(C, fs)⌋; ∄b t. P ⊢ C has F,b:t in D⟧ ⟹ P ⊢ ⟨addr a∙F{D} := Val v,(h, l₀ ++ l, sh),b⟩ → ⟨THROW NoSuchFieldError,(h, l₀ ++ l, sh),b⟩› 27. ‹⋀h a C fs F t D v l sh b l₀. ⟦h a = ⌊(C, fs)⌋; P ⊢ C has F,Static:t in D⟧ ⟹ P ⊢ ⟨addr a∙F{D} := Val v,(h, l₀ ++ l, sh),b⟩ → ⟨THROW IncompatibleClassChangeError,(h, l₀ ++ l, sh),b⟩› 28. ‹⋀e a aa b ba e' ab ac bb b' C F D l₀. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⋀l₀. P ⊢ ⟨e,(a, l₀ ++ aa, b),ba⟩ → ⟨e',(ab, l₀ ++ ac, bb),b'⟩⟧ ⟹ P ⊢ ⟨C∙⇩sF{D} := e,(a, l₀ ++ aa, b),ba⟩ → ⟨C∙⇩sF{D} := e',(ab, l₀ ++ ac, bb),b'⟩› 29. ‹⋀C F t D sh sfs i sfs' v sh' h l l₀. ⟦P ⊢ C has F,Static:t in D; sh D = ⌊(sfs, i)⌋; sfs' = sfs(F ↦ v); sh' = sh(D ↦ (sfs', i))⟧ ⟹ P ⊢ ⟨C∙⇩sF{D} := Val v,(h, l₀ ++ l, sh),True⟩ → ⟨unit,(h, l₀ ++ l, sh'),False⟩› 30. ‹⋀C F t D sh sfs v h l l₀. ⟦P ⊢ C has F,Static:t in D; sh D = ⌊(sfs, Done)⌋⟧ ⟹ P ⊢ ⟨C∙⇩sF{D} := Val v,(h, l₀ ++ l, sh),False⟩ → ⟨C∙⇩sF{D} := Val v,(h, l₀ ++ l, sh),True⟩› 31. ‹⋀C F t D sh v h l l₀. ⟦P ⊢ C has F,Static:t in D; ∄sfs. sh D = ⌊(sfs, Done)⌋⟧ ⟹ P ⊢ ⟨C∙⇩sF{D} := Val v,(h, l₀ ++ l, sh),False⟩ → ⟨INIT D ([D],False) ← C∙⇩sF{D} := Val v,(h, l₀ ++ l, sh),False⟩› 32. ‹⋀C F D v a aa b ba l₀. ∄b t. P ⊢ C has F,b:t in D ⟹ P ⊢ ⟨C∙⇩sF{D} := Val v,(a, l₀ ++ aa, b),ba⟩ → ⟨THROW NoSuchFieldError,(a, l₀ ++ aa, b),False⟩› 33. ‹⋀C F t D v a aa b ba l₀. P ⊢ C has F,NonStatic:t in D ⟹ P ⊢ ⟨C∙⇩sF{D} := Val v,(a, l₀ ++ aa, b),ba⟩ → ⟨THROW IncompatibleClassChangeError,(a, l₀ ++ aa, b),False⟩› 34. ‹⋀e a aa b ba e' ab ac bb b' M es l₀. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⋀l₀. P ⊢ ⟨e,(a, l₀ ++ aa, b),ba⟩ → ⟨e',(ab, l₀ ++ ac, bb),b'⟩⟧ ⟹ P ⊢ ⟨e∙M(es),(a, l₀ ++ aa, b),ba⟩ → ⟨e'∙M(es),(ab, l₀ ++ ac, bb),b'⟩› 35. ‹⋀es a aa b ba es' ab ac bb b' v M l₀. ⟦P ⊢ ⟨es,(a, aa, b),ba⟩ [→] ⟨es',(ab, ac, bb),b'⟩; ⋀l₀. P ⊢ ⟨es,(a, l₀ ++ aa, b),ba⟩ [→] ⟨es',(ab, l₀ ++ ac, bb),b'⟩⟧ ⟹ P ⊢ ⟨Val v∙M(es),(a, l₀ ++ aa, b),ba⟩ → ⟨Val v∙M(es'),(ab, l₀ ++ ac, bb),b'⟩› 36. ‹⋀M vs a aa b ba l₀. P ⊢ ⟨null∙M(map Val vs),(a, l₀ ++ aa, b),ba⟩ → ⟨THROW NullPointer,(a, l₀ ++ aa, b),ba⟩› 37. ‹⋀h a C fs M vs l sh b l₀. ⟦h a = ⌊(C, fs)⌋; ∄b Ts T m D. P ⊢ C sees M, b : Ts→T = m in D⟧ ⟹ P ⊢ ⟨addr a∙M(map Val vs),(h, l₀ ++ l, sh),b⟩ → ⟨THROW NoSuchMethodError,(h, l₀ ++ l, sh),b⟩› 38. ‹⋀h a C fs M Ts T aa b D vs l sh ba l₀. ⟦h a = ⌊(C, fs)⌋; P ⊢ C sees M, Static : Ts→T = (aa, b) in D⟧ ⟹ P ⊢ ⟨addr a∙M(map Val vs),(h, l₀ ++ l, sh),ba⟩ → ⟨THROW IncompatibleClassChangeError,(h, l₀ ++ l, sh),ba⟩› 39. ‹⋀es a aa b ba es' ab ac bb b' C M l₀. ⟦P ⊢ ⟨es,(a, aa, b),ba⟩ [→] ⟨es',(ab, ac, bb),b'⟩; ⋀l₀. P ⊢ ⟨es,(a, l₀ ++ aa, b),ba⟩ [→] ⟨es',(ab, l₀ ++ ac, bb),b'⟩⟧ ⟹ P ⊢ ⟨C∙⇩sM(es),(a, l₀ ++ aa, b),ba⟩ → ⟨C∙⇩sM(es'),(ab, l₀ ++ ac, bb),b'⟩› 40. ‹⋀C M Ts T pns body D vs a aa b l₀. ⟦P ⊢ C sees M, Static : Ts→T = (pns, body) in D; length vs = length pns; length Ts = length pns⟧ ⟹ P ⊢ ⟨C∙⇩sM(map Val vs),(a, l₀ ++ aa, b),True⟩ → ⟨blocks (pns, Ts, vs, body),(a, l₀ ++ aa, b),False⟩› 41. ‹⋀C M Ts T pns body D sh sfs vs h l l₀. ⟦P ⊢ C sees M, Static : Ts→T = (pns, body) in D; sh D = ⌊(sfs, Done)⌋ ∨ M = clinit ∧ sh D = ⌊(sfs, Processing)⌋⟧ ⟹ P ⊢ ⟨C∙⇩sM(map Val vs),(h, l₀ ++ l, sh),False⟩ → ⟨C∙⇩sM(map Val vs),(h, l₀ ++ l, sh),True⟩› 42. ‹⋀C M Ts T pns body D sh vs h l l₀. ⟦P ⊢ C sees M, Static : Ts→T = (pns, body) in D; ∄sfs. sh D = ⌊(sfs, Done)⌋; M ≠ clinit⟧ ⟹ P ⊢ ⟨C∙⇩sM(map Val vs),(h, l₀ ++ l, sh),False⟩ → ⟨INIT D ([D],False) ← C∙⇩sM(map Val vs),(h, l₀ ++ l, sh),False⟩› 43. ‹⋀C M vs a aa b ba l₀. ∄b Ts T m. Ex (Method P C M b Ts T m) ⟹ P ⊢ ⟨C∙⇩sM(map Val vs),(a, l₀ ++ aa, b),ba⟩ → ⟨THROW NoSuchMethodError,(a, l₀ ++ aa, b),False⟩› 44. ‹⋀C M Ts T a b D vs aa ab ba bb l₀. P ⊢ C sees M, NonStatic : Ts→T = (a, b) in D ⟹ P ⊢ ⟨C∙⇩sM(map Val vs),(aa, l₀ ++ ab, ba),bb⟩ → ⟨THROW IncompatibleClassChangeError,(aa, l₀ ++ ab, ba),False⟩› 45. ‹⋀V T u a aa b ba l₀. P ⊢ ⟨{V:T; Val u},(a, l₀ ++ aa, b),ba⟩ → ⟨Val u,(a, l₀ ++ aa, b),ba⟩› 46. ‹⋀V T v u a aa b ba l₀. P ⊢ ⟨{V:T; V:=Val v;; Val u},(a, l₀ ++ aa, b),ba⟩ → ⟨Val u,(a, l₀ ++ aa, b),ba⟩› 47. ‹⋀e a aa b ba e' ab ac bb b' e₂ l₀. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⋀l₀. P ⊢ ⟨e,(a, l₀ ++ aa, b),ba⟩ → ⟨e',(ab, l₀ ++ ac, bb),b'⟩⟧ ⟹ P ⊢ ⟨e;; e₂,(a, l₀ ++ aa, b),ba⟩ → ⟨e';; e₂,(ab, l₀ ++ ac, bb),b'⟩› 48. ‹⋀v e₂ a aa b ba l₀. P ⊢ ⟨Val v;; e₂,(a, l₀ ++ aa, b),ba⟩ → ⟨e₂,(a, l₀ ++ aa, b),ba⟩› 49. ‹⋀e a aa b ba e' ab ac bb b' e₁ e₂ l₀. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⋀l₀. P ⊢ ⟨e,(a, l₀ ++ aa, b),ba⟩ → ⟨e',(ab, l₀ ++ ac, bb),b'⟩⟧ ⟹ P ⊢ ⟨if (e) e₁ else e₂,(a, l₀ ++ aa, b),ba⟩ → ⟨if (e') e₁ else e₂,(ab, l₀ ++ ac, bb),b'⟩› 50. ‹⋀e₁ e₂ a aa b ba l₀. P ⊢ ⟨if (true) e₁ else e₂,(a, l₀ ++ aa, b),ba⟩ → ⟨e₁,(a, l₀ ++ aa, b),ba⟩› 51. ‹⋀e₁ e₂ a aa b ba l₀. P ⊢ ⟨if (false) e₁ else e₂,(a, l₀ ++ aa, b),ba⟩ → ⟨e₂,(a, l₀ ++ aa, b),ba⟩› 52. ‹⋀b c a aa ba b' l₀. P ⊢ ⟨while (b) c,(a, l₀ ++ aa, ba),b'⟩ → ⟨if (b) (c;; while (b) c) else unit,(a, l₀ ++ aa, ba),b'⟩› 53. ‹⋀e a aa b ba e' ab ac bb b' l₀. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⋀l₀. P ⊢ ⟨e,(a, l₀ ++ aa, b),ba⟩ → ⟨e',(ab, l₀ ++ ac, bb),b'⟩⟧ ⟹ P ⊢ ⟨throw e,(a, l₀ ++ aa, b),ba⟩ → ⟨throw e',(ab, l₀ ++ ac, bb),b'⟩› 54. ‹⋀a aa b ba l₀. P ⊢ ⟨throw null,(a, l₀ ++ aa, b),ba⟩ → ⟨THROW NullPointer,(a, l₀ ++ aa, b),ba⟩› 55. ‹⋀e a aa b ba e' ab ac bb b' C V e₂ l₀. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⋀l₀. P ⊢ ⟨e,(a, l₀ ++ aa, b),ba⟩ → ⟨e',(ab, l₀ ++ ac, bb),b'⟩⟧ ⟹ P ⊢ ⟨try e catch(C V) e₂,(a, l₀ ++ aa, b),ba⟩ → ⟨try e' catch(C V) e₂,(ab, l₀ ++ ac, bb),b'⟩› 56. ‹⋀v C V e₂ a aa b ba l₀. P ⊢ ⟨try Val v catch(C V) e₂,(a, l₀ ++ aa, b),ba⟩ → ⟨Val v,(a, l₀ ++ aa, b),ba⟩› 57. ‹⋀e a aa b ba e' ab ac bb b' es l₀. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⋀l₀. P ⊢ ⟨e,(a, l₀ ++ aa, b),ba⟩ → ⟨e',(ab, l₀ ++ ac, bb),b'⟩⟧ ⟹ P ⊢ ⟨e # es,(a, l₀ ++ aa, b),ba⟩ [→] ⟨e' # es,(ab, l₀ ++ ac, bb),b'⟩› 58. ‹⋀es a aa b ba es' ab ac bb b' v l₀. ⟦P ⊢ ⟨es,(a, aa, b),ba⟩ [→] ⟨es',(ab, ac, bb),b'⟩; ⋀l₀. P ⊢ ⟨es,(a, l₀ ++ aa, b),ba⟩ [→] ⟨es',(ab, l₀ ++ ac, bb),b'⟩⟧ ⟹ P ⊢ ⟨Val v # es,(a, l₀ ++ aa, b),ba⟩ [→] ⟨Val v # es',(ab, l₀ ++ ac, bb),b'⟩› 59. ‹⋀e C b a aa ba b' l₀. ¬ sub_RI e ⟹ P ⊢ ⟨INIT C ([],b) ← e,(a, l₀ ++ aa, ba),b'⟩ → ⟨e,(a, l₀ ++ aa, ba),icheck P C e⟩› 60. ‹⋀sh C C' Cs e h l b l₀. sh C = None ⟹ P ⊢ ⟨INIT C' (C # Cs,False) ← e,(h, l₀ ++ l, sh),b⟩ → ⟨INIT C' (C # Cs,False) ← e,(h, l₀ ++ l, sh(C ↦ (sblank P C, Prepared))),b⟩› 61. ‹⋀sh C sfs C' Cs e h l b l₀. sh C = ⌊(sfs, Done)⌋ ⟹ P ⊢ ⟨INIT C' (C # Cs,False) ← e,(h, l₀ ++ l, sh),b⟩ → ⟨INIT C' (Cs,True) ← e,(h, l₀ ++ l, sh),b⟩› 62. ‹⋀sh C sfs C' Cs e h l b l₀. sh C = ⌊(sfs, Processing)⌋ ⟹ P ⊢ ⟨INIT C' (C # Cs,False) ← e,(h, l₀ ++ l, sh),b⟩ → ⟨INIT C' (Cs,True) ← e,(h, l₀ ++ l, sh),b⟩› 63. ‹⋀sh C sfs C' Cs e h l b l₀. sh C = ⌊(sfs, Error)⌋ ⟹ P ⊢ ⟨INIT C' (C # Cs,False) ← e,(h, l₀ ++ l, sh),b⟩ → ⟨RI (C,THROW NoClassDefFoundError) ; Cs ← e,(h, l₀ ++ l, sh),b⟩› 64. ‹⋀sh C sfs sh' C' Cs e h l b l₀. ⟦sh C = ⌊(sfs, Prepared)⌋; C = Object; sh' = sh(C ↦ (sfs, Processing))⟧ ⟹ P ⊢ ⟨INIT C' (C # Cs,False) ← e,(h, l₀ ++ l, sh),b⟩ → ⟨INIT C' (C # Cs,True) ← e,(h, l₀ ++ l, sh'),b⟩› 65. ‹⋀sh C sfs D a b sh' C' Cs e h l ba l₀. ⟦sh C = ⌊(sfs, Prepared)⌋; C ≠ Object; class P C = ⌊(D, a, b)⌋; sh' = sh(C ↦ (sfs, Processing))⟧ ⟹ P ⊢ ⟨INIT C' (C # Cs,False) ← e,(h, l₀ ++ l, sh),ba⟩ → ⟨INIT C' (D # C # Cs,False) ← e,(h, l₀ ++ l, sh'),ba⟩› 66. ‹⋀C' C Cs e h l sh b l₀. P ⊢ ⟨INIT C' (C # Cs,True) ← e,(h, l₀ ++ l, sh),b⟩ → ⟨RI (C,C∙⇩sclinit([])) ; Cs ← e,(h, l₀ ++ l, sh),b⟩› 67. ‹⋀e a aa b ba e' ab ac bb b' C Cs e₀ l₀. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⋀l₀. P ⊢ ⟨e,(a, l₀ ++ aa, b),ba⟩ → ⟨e',(ab, l₀ ++ ac, bb),b'⟩⟧ ⟹ P ⊢ ⟨RI (C,e) ; Cs ← e₀,(a, l₀ ++ aa, b),ba⟩ → ⟨RI (C,e') ; Cs ← e₀,(ab, l₀ ++ ac, bb),b'⟩› 68. ‹⋀sh C sfs i sh' C' Cs v e h l b l₀. ⟦sh C = ⌊(sfs, i)⌋; sh' = sh(C ↦ (sfs, Done)); C' = last (C # Cs)⟧ ⟹ P ⊢ ⟨RI (C,Val v) ; Cs ← e,(h, l₀ ++ l, sh),b⟩ → ⟨INIT C' (Cs,True) ← e,(h, l₀ ++ l, sh'),b⟩› 69. ‹⋀C e a aa b ba l₀. P ⊢ ⟨Cast C (throw e),(a, l₀ ++ aa, b),ba⟩ → ⟨throw e,(a, l₀ ++ aa, b),ba⟩› 70. ‹⋀e bop e₂ a aa b ba l₀. P ⊢ ⟨throw e «bop» e₂,(a, l₀ ++ aa, b),ba⟩ → ⟨throw e,(a, l₀ ++ aa, b),ba⟩› 71. ‹⋀v₁ bop e a aa b ba l₀. P ⊢ ⟨Val v₁ «bop» throw e,(a, l₀ ++ aa, b),ba⟩ → ⟨throw e,(a, l₀ ++ aa, b),ba⟩› 72. ‹⋀V e a aa b ba l₀. P ⊢ ⟨V:=throw e,(a, l₀ ++ aa, b),ba⟩ → ⟨throw e,(a, l₀ ++ aa, b),ba⟩› 73. ‹⋀e F D a aa b ba l₀. P ⊢ ⟨throw e∙F{D},(a, l₀ ++ aa, b),ba⟩ → ⟨throw e,(a, l₀ ++ aa, b),ba⟩› 74. ‹⋀e F D e₂ a aa b ba l₀. P ⊢ ⟨throw e∙F{D} := e₂,(a, l₀ ++ aa, b),ba⟩ → ⟨throw e,(a, l₀ ++ aa, b),ba⟩› 75. ‹⋀v F D e a aa b ba l₀. P ⊢ ⟨Val v∙F{D} := throw e,(a, l₀ ++ aa, b),ba⟩ → ⟨throw e,(a, l₀ ++ aa, b),ba⟩› 76. ‹⋀C F D e a aa b ba l₀. P ⊢ ⟨C∙⇩sF{D} := throw e,(a, l₀ ++ aa, b),ba⟩ → ⟨throw e,(a, l₀ ++ aa, b),ba⟩› 77. ‹⋀e M es a aa b ba l₀. P ⊢ ⟨throw e∙M(es),(a, l₀ ++ aa, b),ba⟩ → ⟨throw e,(a, l₀ ++ aa, b),ba⟩› 78. ‹⋀es vs e es' v M a aa b ba l₀. es = map Val vs @ throw e # es' ⟹ P ⊢ ⟨Val v∙M(es),(a, l₀ ++ aa, b),ba⟩ → ⟨throw e,(a, l₀ ++ aa, b),ba⟩› 79. ‹⋀es vs e es' C M a aa b ba l₀. es = map Val vs @ throw e # es' ⟹ P ⊢ ⟨C∙⇩sM(es),(a, l₀ ++ aa, b),ba⟩ → ⟨throw e,(a, l₀ ++ aa, b),ba⟩› 80. ‹⋀V T a aa ab b ba l₀. P ⊢ ⟨{V:T; Throw a},(aa, l₀ ++ ab, b),ba⟩ → ⟨Throw a,(aa, l₀ ++ ab, b),ba⟩› 81. ‹⋀V T v a aa ab b ba l₀. P ⊢ ⟨{V:T; V:=Val v;; Throw a},(aa, l₀ ++ ab, b),ba⟩ → ⟨Throw a,(aa, l₀ ++ ab, b),ba⟩› 82. ‹⋀e e₂ a aa b ba l₀. P ⊢ ⟨throw e;; e₂,(a, l₀ ++ aa, b),ba⟩ → ⟨throw e,(a, l₀ ++ aa, b),ba⟩› 83. ‹⋀e e₁ e₂ a aa b ba l₀. P ⊢ ⟨if (throw e) e₁ else e₂,(a, l₀ ++ aa, b),ba⟩ → ⟨throw e,(a, l₀ ++ aa, b),ba⟩› 84. ‹⋀e a aa b ba l₀. P ⊢ ⟨throw (throw e),(a, l₀ ++ aa, b),ba⟩ → ⟨throw e,(a, l₀ ++ aa, b),ba⟩› 85. ‹⋀sh C sfs i sh' a D Cs e h l b l₀. ⟦sh C = ⌊(sfs, i)⌋; sh' = sh(C ↦ (sfs, Error))⟧ ⟹ P ⊢ ⟨RI (C,Throw a) ; D # Cs ← e,(h, l₀ ++ l, sh),b⟩ → ⟨RI (D,Throw a) ; Cs ← e,(h, l₀ ++ l, sh'),b⟩› 86. ‹⋀sh C sfs i sh' a e h l b l₀. ⟦sh C = ⌊(sfs, i)⌋; sh' = sh(C ↦ (sfs, Error))⟧ ⟹ P ⊢ ⟨RI (C,Throw a) ; [] ← e,(h, l₀ ++ l, sh),b⟩ → ⟨Throw a,(h, l₀ ++ l, sh'),b⟩›*) (*>*) lemma Red_lcl_add: assumes "P ⊢ ⟨e,(h,l,sh), b⟩ →* ⟨e',(h',l',sh'), b'⟩" shows "P ⊢ ⟨e,(h,l₀++l,sh),b⟩ →* ⟨e',(h',l₀++l',sh'),b'⟩" (*<*) using assms (*‹P ⊢ ⟨e,(h, l, sh),b⟩ →* ⟨e',(h', l', sh'),b'⟩›*) proof (induct rule:converse_rtrancl_induct_red (*‹⟦?P ⊢ ⟨?e,(?h, ?l, ?sh),?b⟩ →* ⟨?e',(?h', ?l', ?sh'),?b'⟩; ⋀e h l sh b. ?R e h l sh b e h l sh b; ⋀e₀ h₀ l₀ sh₀ b₀ e₁ h₁ l₁ sh₁ b₁ e' h' l' sh' b'. ⟦?P ⊢ ⟨e₀,(h₀, l₀, sh₀),b₀⟩ → ⟨e₁,(h₁, l₁, sh₁),b₁⟩; ?R e₁ h₁ l₁ sh₁ b₁ e' h' l' sh' b'⟧ ⟹ ?R e₀ h₀ l₀ sh₀ b₀ e' h' l' sh' b'⟧ ⟹ ?R ?e ?h ?l ?sh ?b ?e' ?h' ?l' ?sh' ?b'›*)) (*goals: 1. ‹⋀e h l sh b. P ⊢ ⟨e,(h, l₀ ++ l, sh),b⟩ →* ⟨e,(h, l₀ ++ l, sh),b⟩› 2. ‹⋀e₀ h₀ l₀' sh₀ b₀ e₁ h₁ l₁ sh₁ b₁ e' h' l' sh' b'. ⟦P ⊢ ⟨e₀,(h₀, l₀', sh₀),b₀⟩ → ⟨e₁,(h₁, l₁, sh₁),b₁⟩; P ⊢ ⟨e₁,(h₁, l₀ ++ l₁, sh₁),b₁⟩ →* ⟨e',(h', l₀ ++ l', sh'),b'⟩⟧ ⟹ P ⊢ ⟨e₀,(h₀, l₀ ++ l₀', sh₀),b₀⟩ →* ⟨e',(h', l₀ ++ l', sh'),b'⟩›*) case 1 (*no hyothesis introduced yet*) thus "?case" (*goal: ‹P ⊢ ⟨e_,(h_, l₀ ++ l_, sh_),b_⟩ →* ⟨e_,(h_, l₀ ++ l_, sh_),b_⟩›*) by simp next (*goal: ‹⋀e₀ h₀ l₀' sh₀ b₀ e₁ h₁ l₁ sh₁ b₁ e' h' l' sh' b'. ⟦P ⊢ ⟨e₀,(h₀, l₀', sh₀),b₀⟩ → ⟨e₁,(h₁, l₁, sh₁),b₁⟩; P ⊢ ⟨e₁,(h₁, l₀ ++ l₁, sh₁),b₁⟩ →* ⟨e',(h', l₀ ++ l', sh'),b'⟩⟧ ⟹ P ⊢ ⟨e₀,(h₀, l₀ ++ l₀', sh₀),b₀⟩ →* ⟨e',(h', l₀ ++ l', sh'),b'⟩›*) case 2 (*‹P ⊢ ⟨e₀_,(h₀_, l₀_, sh₀_),b₀_⟩ → ⟨e₁_,(h₁_, l₁_, sh₁_),b₁_⟩› ‹P ⊢ ⟨e₁_,(h₁_, l₀ ++ l₁_, sh₁_),b₁_⟩ →* ⟨e'_,(h'_, l₀ ++ l'_, sh'_),b'_⟩›*) thus "?case" (*goal: ‹P ⊢ ⟨e₀_,(h₀_, l₀ ++ l₀_, sh₀_),b₀_⟩ →* ⟨e'_,(h'_, l₀ ++ l'_, sh'_),b'_⟩›*) by (blast dest: red_lcl_add (*‹(?P::(char list list × char list exp) prog) ⊢ ⟨?e::char list exp,(?h::heap, ?l::sfields, ?sh::sheap),?b::bool⟩ → ⟨?e'::char list exp,(?h'::heap, ?l'::sfields, ?sh'::sheap),?b'::bool⟩ ⟹ ?P ⊢ ⟨?e,(?h, (?l₀::sfields) ++ ?l, ?sh),?b⟩ → ⟨?e',(?h', ?l₀ ++ ?l', ?sh'),?b'⟩›*) intro: converse_rtrancl_into_rtrancl (*‹⟦(?a::?'a::type, ?b::?'a::type) ∈ (?r::(?'a::type × ?'a::type) set); (?b, ?c::?'a::type) ∈ ?r⇧*⟧ ⟹ (?a, ?c) ∈ ?r⇧*›*)) qed (*>*) lemma assumes wf: "wwf_J_prog P" shows red_proc_pres: "P ⊢ ⟨e,(h,l,sh),b⟩ → ⟨e',(h',l',sh'),b'⟩ ⟹ not_init C e ⟹ sh C = ⌊(sfs, Processing)⌋ ⟹ not_init C e' ∧ (∃sfs'. sh' C = ⌊(sfs', Processing)⌋)" and reds_proc_pres: "P ⊢ ⟨es,(h,l,sh),b⟩ [→] ⟨es',(h',l',sh'),b'⟩ ⟹ not_inits C es ⟹ sh C = ⌊(sfs, Processing)⌋ ⟹ not_inits C es' ∧ (∃sfs'. sh' C = ⌊(sfs', Processing)⌋)" (*<*) proof (induct rule:red_reds_inducts (*‹⟦?P ⊢ ⟨?x1a,(?x2a, ?x2b, ?x2c),?x3a⟩ → ⟨?x4a,(?x5a, ?x5b, ?x5c),?x6a⟩; ⋀h a C FDTs h' l sh. ⟦new_Addr h = ⌊a⌋; ?P ⊢ C has_fields FDTs; h' = h(a ↦ blank ?P C)⟧ ⟹ ?P1.0 (new C) h l sh True (addr a) h' l sh False; ⋀h C l sh. ⟦new_Addr h = None; is_class ?P C⟧ ⟹ ?P1.0 (new C) h l sh True (THROW OutOfMemory) h l sh False; ⋀sh C sfs h l. sh C = ⌊(sfs, Done)⌋ ⟹ ?P1.0 (new C) h l sh False (new C) h l sh True; ⋀sh C h l. ⟦∄sfs. sh C = ⌊(sfs, Done)⌋; is_class ?P C⟧ ⟹ ?P1.0 (new C) h l sh False (INIT C ([C],False) ← new C) h l sh False; ⋀e a aa b ba e' ab ac bb b' C. ⟦?P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ?P1.0 e a aa b ba e' ab ac bb b'⟧ ⟹ ?P1.0 (Cast C e) a aa b ba (Cast C e') ab ac bb b'; ⋀C a aa b ba. ?P1.0 (Cast C null) a aa b ba null a aa b ba; ⋀h a D fs C l sh b. ⟦h a = ⌊(D, fs)⌋; ?P ⊢ D ≼⇧* C⟧ ⟹ ?P1.0 (Cast C (addr a)) h l sh b (addr a) h l sh b; ⋀h a D fs C l sh b. ⟦h a = ⌊(D, fs)⌋; (D, C) ∉ (subcls1 ?P)⇧*⟧ ⟹ ?P1.0 (Cast C (addr a)) h l sh b (THROW ClassCast) h l sh b; ⋀e a aa b ba e' ab ac bb b' bop e₂. ⟦?P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ?P1.0 e a aa b ba e' ab ac bb b'⟧ ⟹ ?P1.0 (e «bop» e₂) a aa b ba (e' «bop» e₂) ab ac bb b'; ⋀e a aa b ba e' ab ac bb b' v₁ bop. ⟦?P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ?P1.0 e a aa b ba e' ab ac bb b'⟧ ⟹ ?P1.0 (Val v₁ «bop» e) a aa b ba (Val v₁ «bop» e') ab ac bb b'; ⋀bop v₁ v₂ v a aa b ba. binop (bop, v₁, v₂) = ⌊v⌋ ⟹ ?P1.0 (Val v₁ «bop» Val v₂) a aa b ba (Val v) a aa b ba; ⋀l V v h sh b. l V = ⌊v⌋ ⟹ ?P1.0 (Var V) h l sh b (Val v) h l sh b; ⋀e a aa b ba e' ab ac bb b' V. ⟦?P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ?P1.0 e a aa b ba e' ab ac bb b'⟧ ⟹ ?P1.0 (V:=e) a aa b ba (V:=e') ab ac bb b'; ⋀V v h l sh b. ?P1.0 (V:=Val v) h l sh b unit h (l(V ↦ v)) sh b; ⋀e a aa b ba e' ab ac bb b' F D. ⟦?P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ?P1.0 e a aa b ba e' ab ac bb b'⟧ ⟹ ?P1.0 (e∙F{D}) a aa b ba (e'∙F{D}) ab ac bb b'; ⋀h a C fs F D v t l sh b. ⟦h a = ⌊(C, fs)⌋; fs (F, D) = ⌊v⌋; ?P ⊢ C has F,NonStatic:t in D⟧ ⟹ ?P1.0 (addr a∙F{D}) h l sh b (Val v) h l sh b; ⋀F D a aa b ba. ?P1.0 (null∙F{D}) a aa b ba (THROW NullPointer) a aa b ba; ⋀h a C fs F D l sh b. ⟦h a = ⌊(C, fs)⌋; ∄b t. ?P ⊢ C has F,b:t in D⟧ ⟹ ?P1.0 (addr a∙F{D}) h l sh b (THROW NoSuchFieldError) h l sh b; ⋀h a C fs F t D l sh b. ⟦h a = ⌊(C, fs)⌋; ?P ⊢ C has F,Static:t in D⟧ ⟹ ?P1.0 (addr a∙F{D}) h l sh b (THROW IncompatibleClassChangeError) h l sh b; ⋀C F t D sh sfs i v h l. ⟦?P ⊢ C has F,Static:t in D; sh D = ⌊(sfs, i)⌋; sfs F = ⌊v⌋⟧ ⟹ ?P1.0 (C∙⇩sF{D}) h l sh True (Val v) h l sh False; ⋀C F t D sh sfs h l. ⟦?P ⊢ C has F,Static:t in D; sh D = ⌊(sfs, Done)⌋⟧ ⟹ ?P1.0 (C∙⇩sF{D}) h l sh False (C∙⇩sF{D}) h l sh True; ⋀C F t D sh h l. ⟦?P ⊢ C has F,Static:t in D; ∄sfs. sh D = ⌊(sfs, Done)⌋⟧ ⟹ ?P1.0 (C∙⇩sF{D}) h l sh False (INIT D ([D],False) ← C∙⇩sF{D}) h l sh False; ⋀C F D h l sh b. ∄b t. ?P ⊢ C has F,b:t in D ⟹ ?P1.0 (C∙⇩sF{D}) h l sh b (THROW NoSuchFieldError) h l sh False; ⋀C F t D h l sh b. ?P ⊢ C has F,NonStatic:t in D ⟹ ?P1.0 (C∙⇩sF{D}) h l sh b (THROW IncompatibleClassChangeError) h l sh False; ⋀e a aa b ba e' ab ac bb b' F D e₂. ⟦?P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ?P1.0 e a aa b ba e' ab ac bb b'⟧ ⟹ ?P1.0 (e∙F{D} := e₂) a aa b ba (e'∙F{D} := e₂) ab ac bb b'; ⋀e a aa b ba e' ab ac bb b' v F D. ⟦?P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ?P1.0 e a aa b ba e' ab ac bb b'⟧ ⟹ ?P1.0 (Val v∙F{D} := e) a aa b ba (Val v∙F{D} := e') ab ac bb b'; ⋀C F t D h a fs v l sh b. ⟦?P ⊢ C has F,NonStatic:t in D; h a = ⌊(C, fs)⌋⟧ ⟹ ?P1.0 (addr a∙F{D} := Val v) h l sh b unit (h(a ↦ (C, fs((F, D) ↦ v)))) l sh b; ⋀F D v a aa b ba. ?P1.0 (null∙F{D} := Val v) a aa b ba (THROW NullPointer) a aa b ba; ⋀h a C fs F D v l sh b. ⟦h a = ⌊(C, fs)⌋; ∄b t. ?P ⊢ C has F,b:t in D⟧ ⟹ ?P1.0 (addr a∙F{D} := Val v) h l sh b (THROW NoSuchFieldError) h l sh b; ⋀h a C fs F t D v l sh b. ⟦h a = ⌊(C, fs)⌋; ?P ⊢ C has F,Static:t in D⟧ ⟹ ?P1.0 (addr a∙F{D} := Val v) h l sh b (THROW IncompatibleClassChangeError) h l sh b; ⋀e a aa b ba e' ab ac bb b' C F D. ⟦?P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ?P1.0 e a aa b ba e' ab ac bb b'⟧ ⟹ ?P1.0 (C∙⇩sF{D} := e) a aa b ba (C∙⇩sF{D} := e') ab ac bb b'; ⋀C F t D sh sfs i sfs' v sh' h l. ⟦?P ⊢ C has F,Static:t in D; sh D = ⌊(sfs, i)⌋; sfs' = sfs(F ↦ v); sh' = sh(D ↦ (sfs', i))⟧ ⟹ ?P1.0 (C∙⇩sF{D} := Val v) h l sh True unit h l sh' False; ⋀C F t D sh sfs v h l. ⟦?P ⊢ C has F,Static:t in D; sh D = ⌊(sfs, Done)⌋⟧ ⟹ ?P1.0 (C∙⇩sF{D} := Val v) h l sh False (C∙⇩sF{D} := Val v) h l sh True; ⋀C F t D sh v h l. ⟦?P ⊢ C has F,Static:t in D; ∄sfs. sh D = ⌊(sfs, Done)⌋⟧ ⟹ ?P1.0 (C∙⇩sF{D} := Val v) h l sh False (INIT D ([D],False) ← C∙⇩sF{D} := Val v) h l sh False; ⋀C F D v a aa b ba. ∄b t. ?P ⊢ C has F,b:t in D ⟹ ?P1.0 (C∙⇩sF{D} := Val v) a aa b ba (THROW NoSuchFieldError) a aa b False; ⋀C F t D v a aa b ba. ?P ⊢ C has F,NonStatic:t in D ⟹ ?P1.0 (C∙⇩sF{D} := Val v) a aa b ba (THROW IncompatibleClassChangeError) a aa b False; ⋀e a aa b ba e' ab ac bb b' M es. ⟦?P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ?P1.0 e a aa b ba e' ab ac bb b'⟧ ⟹ ?P1.0 (e∙M(es)) a aa b ba (e'∙M(es)) ab ac bb b'; ⋀es a aa b ba es' ab ac bb b' v M. ⟦?P ⊢ ⟨es,(a, aa, b),ba⟩ [→] ⟨es',(ab, ac, bb),b'⟩; ?P2.0 es a aa b ba es' ab ac bb b'⟧ ⟹ ?P1.0 (Val v∙M(es)) a aa b ba (Val v∙M(es')) ab ac bb b'; ⋀h a C fs M Ts T pns body D vs l sh b. ⟦h a = ⌊(C, fs)⌋; ?P ⊢ C sees M, NonStatic : Ts→T = (pns, body) in D; length vs = length pns; length Ts = length pns⟧ ⟹ ?P1.0 (addr a∙M(map Val vs)) h l sh b (blocks (this # pns, Class D # Ts, Addr a # vs, body)) h l sh b; ⋀M vs a aa b ba. ?P1.0 (null∙M(map Val vs)) a aa b ba (THROW NullPointer) a aa b ba; ⋀h a C fs M vs l sh b. ⟦h a = ⌊(C, fs)⌋; ∄b Ts T m D. ?P ⊢ C sees M, b : Ts→T = m in D⟧ ⟹ ?P1.0 (addr a∙M(map Val vs)) h l sh b (THROW NoSuchMethodError) h l sh b; ⋀h a C fs M Ts T aa b D vs l sh ba. ⟦h a = ⌊(C, fs)⌋; ?P ⊢ C sees M, Static : Ts→T = (aa, b) in D⟧ ⟹ ?P1.0 (addr a∙M(map Val vs)) h l sh ba (THROW IncompatibleClassChangeError) h l sh ba; ⋀es a aa b ba es' ab ac bb b' C M. ⟦?P ⊢ ⟨es,(a, aa, b),ba⟩ [→] ⟨es',(ab, ac, bb),b'⟩; ?P2.0 es a aa b ba es' ab ac bb b'⟧ ⟹ ?P1.0 (C∙⇩sM(es)) a aa b ba (C∙⇩sM(es')) ab ac bb b'; ⋀C M Ts T pns body D vs a aa b. ⟦?P ⊢ C sees M, Static : Ts→T = (pns, body) in D; length vs = length pns; length Ts = length pns⟧ ⟹ ?P1.0 (C∙⇩sM(map Val vs)) a aa b True (blocks (pns, Ts, vs, body)) a aa b False; ⋀C M Ts T pns body D sh sfs vs h l. ⟦?P ⊢ C sees M, Static : Ts→T = (pns, body) in D; sh D = ⌊(sfs, Done)⌋ ∨ M = clinit ∧ sh D = ⌊(sfs, Processing)⌋⟧ ⟹ ?P1.0 (C∙⇩sM(map Val vs)) h l sh False (C∙⇩sM(map Val vs)) h l sh True; ⋀C M Ts T pns body D sh vs h l. ⟦?P ⊢ C sees M, Static : Ts→T = (pns, body) in D; ∄sfs. sh D = ⌊(sfs, Done)⌋; M ≠ clinit⟧ ⟹ ?P1.0 (C∙⇩sM(map Val vs)) h l sh False (INIT D ([D],False) ← C∙⇩sM(map Val vs)) h l sh False; ⋀C M vs a aa b ba. ∄b Ts T m. Ex (Method ?P C M b Ts T m) ⟹ ?P1.0 (C∙⇩sM(map Val vs)) a aa b ba (THROW NoSuchMethodError) a aa b False; ⋀C M Ts T a b D vs aa ab ba bb. ?P ⊢ C sees M, NonStatic : Ts→T = (a, b) in D ⟹ ?P1.0 (C∙⇩sM(map Val vs)) aa ab ba bb (THROW IncompatibleClassChangeError) aa ab ba False; ⋀e h l V sh b e' h' l' sh' b' T. ⟦?P ⊢ ⟨e,(h, l(V := None), sh),b⟩ → ⟨e',(h', l', sh'),b'⟩; ?P1.0 e h (l(V := None)) sh b e' h' l' sh' b'; l' V = None; ¬ assigned V e⟧ ⟹ ?P1.0 {V:T; e} h l sh b {V:T; e'} h' (l'(V := l V)) sh' b'; ⋀e h l V sh b e' h' l' sh' b' v T. ⟦?P ⊢ ⟨e,(h, l(V := None), sh),b⟩ → ⟨e',(h', l', sh'),b'⟩; ?P1.0 e h (l(V := None)) sh b e' h' l' sh' b'; l' V = ⌊v⌋; ¬ assigned V e⟧ ⟹ ?P1.0 {V:T; e} h l sh b {V:T; V:=Val v;; e'} h' (l'(V := l V)) sh' b'; ⋀e h l V v sh b e' h' l' sh' b' v' T. ⟦?P ⊢ ⟨e,(h, l(V ↦ v), sh),b⟩ → ⟨e',(h', l', sh'),b'⟩; ?P1.0 e h (l(V ↦ v)) sh b e' h' l' sh' b'; l' V = ⌊v'⌋⟧ ⟹ ?P1.0 {V:T; V:=Val v;; e} h l sh b {V:T; V:=Val v';; e'} h' (l'(V := l V)) sh' b'; ⋀V T u a aa b ba. ?P1.0 {V:T; Val u} a aa b ba (Val u) a aa b ba; ⋀V T v u a aa b ba. ?P1.0 {V:T; V:=Val v;; Val u} a aa b ba (Val u) a aa b ba; ⋀e a aa b ba e' ab ac bb b' e₂. ⟦?P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ?P1.0 e a aa b ba e' ab ac bb b'⟧ ⟹ ?P1.0 (e;; e₂) a aa b ba (e';; e₂) ab ac bb b'; ⋀v e₂ a aa b ba. ?P1.0 (Val v;; e₂) a aa b ba e₂ a aa b ba; ⋀e a aa b ba e' ab ac bb b' e₁ e₂. ⟦?P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ?P1.0 e a aa b ba e' ab ac bb b'⟧ ⟹ ?P1.0 (if (e) e₁ else e₂) a aa b ba (if (e') e₁ else e₂) ab ac bb b'; ⋀e₁ e₂ a aa b ba. ?P1.0 (if (true) e₁ else e₂) a aa b ba e₁ a aa b ba; ⋀e₁ e₂ a aa b ba. ?P1.0 (if (false) e₁ else e₂) a aa b ba e₂ a aa b ba; ⋀b c a aa ba b'. ?P1.0 (while (b) c) a aa ba b' (if (b) (c;; while (b) c) else unit) a aa ba b'; ⋀e a aa b ba e' ab ac bb b'. ⟦?P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ?P1.0 e a aa b ba e' ab ac bb b'⟧ ⟹ ?P1.0 (throw e) a aa b ba (throw e') ab ac bb b'; ⋀a aa b ba. ?P1.0 (throw null) a aa b ba (THROW NullPointer) a aa b ba; ⋀e a aa b ba e' ab ac bb b' C V e₂. ⟦?P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ?P1.0 e a aa b ba e' ab ac bb b'⟧ ⟹ ?P1.0 (try e catch(C V) e₂) a aa b ba (try e' catch(C V) e₂) ab ac bb b'; ⋀v C V e₂ a aa b ba. ?P1.0 (try Val v catch(C V) e₂) a aa b ba (Val v) a aa b ba; ⋀a aa b ab D fs C V e₂ ba. ⟦hp (a, aa, b) ab = ⌊(D, fs)⌋; ?P ⊢ D ≼⇧* C⟧ ⟹ ?P1.0 (try Throw ab catch(C V) e₂) a aa b ba {V:Class C; V:=addr ab;; e₂} a aa b ba; ⋀a aa b ab D fs C V e₂ ba. ⟦hp (a, aa, b) ab = ⌊(D, fs)⌋; (D, C) ∉ (subcls1 ?P)⇧*⟧ ⟹ ?P1.0 (try Throw ab catch(C V) e₂) a aa b ba (Throw ab) a aa b ba; ⋀e a aa b ba e' ab ac bb b' es. ⟦?P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ?P1.0 e a aa b ba e' ab ac bb b'⟧ ⟹ ?P2.0 (e # es) a aa b ba (e' # es) ab ac bb b'; ⋀es a aa b ba es' ab ac bb b' v. ⟦?P ⊢ ⟨es,(a, aa, b),ba⟩ [→] ⟨es',(ab, ac, bb),b'⟩; ?P2.0 es a aa b ba es' ab ac bb b'⟧ ⟹ ?P2.0 (Val v # es) a aa b ba (Val v # es') ab ac bb b'; ⋀e C b a aa ba b'. ¬ sub_RI e ⟹ ?P1.0 (INIT C ([],b) ← e) a aa ba b' e a aa ba (icheck ?P C e); ⋀sh C C' Cs e h l b. sh C = None ⟹ ?P1.0 (INIT C' (C # Cs,False) ← e) h l sh b (INIT C' (C # Cs,False) ← e) h l (sh(C ↦ (sblank ?P C, Prepared))) b; ⋀sh C sfs C' Cs e h l b. sh C = ⌊(sfs, Done)⌋ ⟹ ?P1.0 (INIT C' (C # Cs,False) ← e) h l sh b (INIT C' (Cs,True) ← e) h l sh b; ⋀sh C sfs C' Cs e h l b. sh C = ⌊(sfs, Processing)⌋ ⟹ ?P1.0 (INIT C' (C # Cs,False) ← e) h l sh b (INIT C' (Cs,True) ← e) h l sh b; ⋀sh C sfs C' Cs e h l b. sh C = ⌊(sfs, Error)⌋ ⟹ ?P1.0 (INIT C' (C # Cs,False) ← e) h l sh b (RI (C,THROW NoClassDefFoundError) ; Cs ← e) h l sh b; ⋀sh C sfs sh' C' Cs e h l b. ⟦sh C = ⌊(sfs, Prepared)⌋; C = Object; sh' = sh(C ↦ (sfs, Processing))⟧ ⟹ ?P1.0 (INIT C' (C # Cs,False) ← e) h l sh b (INIT C' (C # Cs,True) ← e) h l sh' b; ⋀sh C sfs D a b sh' C' Cs e h l ba. ⟦sh C = ⌊(sfs, Prepared)⌋; C ≠ Object; class ?P C = ⌊(D, a, b)⌋; sh' = sh(C ↦ (sfs, Processing))⟧ ⟹ ?P1.0 (INIT C' (C # Cs,False) ← e) h l sh ba (INIT C' (D # C # Cs,False) ← e) h l sh' ba; ⋀C' C Cs e h l sh b. ?P1.0 (INIT C' (C # Cs,True) ← e) h l sh b (RI (C,C∙⇩sclinit([])) ; Cs ← e) h l sh b; ⋀e a aa b ba e' ab ac bb b' C Cs e₀. ⟦?P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ?P1.0 e a aa b ba e' ab ac bb b'⟧ ⟹ ?P1.0 (RI (C,e) ; Cs ← e₀) a aa b ba (RI (C,e') ; Cs ← e₀) ab ac bb b'; ⋀sh C sfs i sh' C' Cs v e h l b. ⟦sh C = ⌊(sfs, i)⌋; sh' = sh(C ↦ (sfs, Done)); C' = last (C # Cs)⟧ ⟹ ?P1.0 (RI (C,Val v) ; Cs ← e) h l sh b (INIT C' (Cs,True) ← e) h l sh' b; ⋀C e a aa b ba. ?P1.0 (Cast C (throw e)) a aa b ba (throw e) a aa b ba; ⋀e bop e₂ a aa b ba. ?P1.0 (throw e «bop» e₂) a aa b ba (throw e) a aa b ba; ⋀v₁ bop e a aa b ba. ?P1.0 (Val v₁ «bop» throw e) a aa b ba (throw e) a aa b ba; ⋀V e a aa b ba. ?P1.0 (V:=throw e) a aa b ba (throw e) a aa b ba; ⋀e F D a aa b ba. ?P1.0 (throw e∙F{D}) a aa b ba (throw e) a aa b ba; ⋀e F D e₂ a aa b ba. ?P1.0 (throw e∙F{D} := e₂) a aa b ba (throw e) a aa b ba; ⋀v F D e a aa b ba. ?P1.0 (Val v∙F{D} := throw e) a aa b ba (throw e) a aa b ba; ⋀C F D e a aa b ba. ?P1.0 (C∙⇩sF{D} := throw e) a aa b ba (throw e) a aa b ba; ⋀e M es a aa b ba. ?P1.0 (throw e∙M(es)) a aa b ba (throw e) a aa b ba; ⋀es vs e es' v M a aa b ba. es = map Val vs @ throw e # es' ⟹ ?P1.0 (Val v∙M(es)) a aa b ba (throw e) a aa b ba; ⋀es vs e es' C M a aa b ba. es = map Val vs @ throw e # es' ⟹ ?P1.0 (C∙⇩sM(es)) a aa b ba (throw e) a aa b ba; ⋀V T a aa ab b ba. ?P1.0 {V:T; Throw a} aa ab b ba (Throw a) aa ab b ba; ⋀V T v a aa ab b ba. ?P1.0 {V:T; V:=Val v;; Throw a} aa ab b ba (Throw a) aa ab b ba; ⋀e e₂ a aa b ba. ?P1.0 (throw e;; e₂) a aa b ba (throw e) a aa b ba; ⋀e e₁ e₂ a aa b ba. ?P1.0 (if (throw e) e₁ else e₂) a aa b ba (throw e) a aa b ba; ⋀e a aa b ba. ?P1.0 (throw (throw e)) a aa b ba (throw e) a aa b ba; ⋀sh C sfs i sh' a D Cs e h l b. ⟦sh C = ⌊(sfs, i)⌋; sh' = sh(C ↦ (sfs, Error))⟧ ⟹ ?P1.0 (RI (C,Throw a) ; D # Cs ← e) h l sh b (RI (D,Throw a) ; Cs ← e) h l sh' b; ⋀sh C sfs i sh' a e h l b. ⟦sh C = ⌊(sfs, i)⌋; sh' = sh(C ↦ (sfs, Error))⟧ ⟹ ?P1.0 (RI (C,Throw a) ; [] ← e) h l sh b (Throw a) h l sh' b⟧ ⟹ ?P1.0 ?x1a ?x2a ?x2b ?x2c ?x3a ?x4a ?x5a ?x5b ?x5c ?x6a› ‹⟦?P ⊢ ⟨?x7a,(?x8a, ?x8b, ?x8c),?x9a⟩ [→] ⟨?x10a,(?x11a, ?x11b, ?x11c),?x12a⟩; ⋀h a C FDTs h' l sh. ⟦new_Addr h = ⌊a⌋; ?P ⊢ C has_fields FDTs; h' = h(a ↦ blank ?P C)⟧ ⟹ ?P1.0 (new C) h l sh True (addr a) h' l sh False; ⋀h C l sh. ⟦new_Addr h = None; is_class ?P C⟧ ⟹ ?P1.0 (new C) h l sh True (THROW OutOfMemory) h l sh False; ⋀sh C sfs h l. sh C = ⌊(sfs, Done)⌋ ⟹ ?P1.0 (new C) h l sh False (new C) h l sh True; ⋀sh C h l. ⟦∄sfs. sh C = ⌊(sfs, Done)⌋; is_class ?P C⟧ ⟹ ?P1.0 (new C) h l sh False (INIT C ([C],False) ← new C) h l sh False; ⋀e a aa b ba e' ab ac bb b' C. ⟦?P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ?P1.0 e a aa b ba e' ab ac bb b'⟧ ⟹ ?P1.0 (Cast C e) a aa b ba (Cast C e') ab ac bb b'; ⋀C a aa b ba. ?P1.0 (Cast C null) a aa b ba null a aa b ba; ⋀h a D fs C l sh b. ⟦h a = ⌊(D, fs)⌋; ?P ⊢ D ≼⇧* C⟧ ⟹ ?P1.0 (Cast C (addr a)) h l sh b (addr a) h l sh b; ⋀h a D fs C l sh b. ⟦h a = ⌊(D, fs)⌋; (D, C) ∉ (subcls1 ?P)⇧*⟧ ⟹ ?P1.0 (Cast C (addr a)) h l sh b (THROW ClassCast) h l sh b; ⋀e a aa b ba e' ab ac bb b' bop e₂. ⟦?P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ?P1.0 e a aa b ba e' ab ac bb b'⟧ ⟹ ?P1.0 (e «bop» e₂) a aa b ba (e' «bop» e₂) ab ac bb b'; ⋀e a aa b ba e' ab ac bb b' v₁ bop. ⟦?P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ?P1.0 e a aa b ba e' ab ac bb b'⟧ ⟹ ?P1.0 (Val v₁ «bop» e) a aa b ba (Val v₁ «bop» e') ab ac bb b'; ⋀bop v₁ v₂ v a aa b ba. binop (bop, v₁, v₂) = ⌊v⌋ ⟹ ?P1.0 (Val v₁ «bop» Val v₂) a aa b ba (Val v) a aa b ba; ⋀l V v h sh b. l V = ⌊v⌋ ⟹ ?P1.0 (Var V) h l sh b (Val v) h l sh b; ⋀e a aa b ba e' ab ac bb b' V. ⟦?P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ?P1.0 e a aa b ba e' ab ac bb b'⟧ ⟹ ?P1.0 (V:=e) a aa b ba (V:=e') ab ac bb b'; ⋀V v h l sh b. ?P1.0 (V:=Val v) h l sh b unit h (l(V ↦ v)) sh b; ⋀e a aa b ba e' ab ac bb b' F D. ⟦?P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ?P1.0 e a aa b ba e' ab ac bb b'⟧ ⟹ ?P1.0 (e∙F{D}) a aa b ba (e'∙F{D}) ab ac bb b'; ⋀h a C fs F D v t l sh b. ⟦h a = ⌊(C, fs)⌋; fs (F, D) = ⌊v⌋; ?P ⊢ C has F,NonStatic:t in D⟧ ⟹ ?P1.0 (addr a∙F{D}) h l sh b (Val v) h l sh b; ⋀F D a aa b ba. ?P1.0 (null∙F{D}) a aa b ba (THROW NullPointer) a aa b ba; ⋀h a C fs F D l sh b. ⟦h a = ⌊(C, fs)⌋; ∄b t. ?P ⊢ C has F,b:t in D⟧ ⟹ ?P1.0 (addr a∙F{D}) h l sh b (THROW NoSuchFieldError) h l sh b; ⋀h a C fs F t D l sh b. ⟦h a = ⌊(C, fs)⌋; ?P ⊢ C has F,Static:t in D⟧ ⟹ ?P1.0 (addr a∙F{D}) h l sh b (THROW IncompatibleClassChangeError) h l sh b; ⋀C F t D sh sfs i v h l. ⟦?P ⊢ C has F,Static:t in D; sh D = ⌊(sfs, i)⌋; sfs F = ⌊v⌋⟧ ⟹ ?P1.0 (C∙⇩sF{D}) h l sh True (Val v) h l sh False; ⋀C F t D sh sfs h l. ⟦?P ⊢ C has F,Static:t in D; sh D = ⌊(sfs, Done)⌋⟧ ⟹ ?P1.0 (C∙⇩sF{D}) h l sh False (C∙⇩sF{D}) h l sh True; ⋀C F t D sh h l. ⟦?P ⊢ C has F,Static:t in D; ∄sfs. sh D = ⌊(sfs, Done)⌋⟧ ⟹ ?P1.0 (C∙⇩sF{D}) h l sh False (INIT D ([D],False) ← C∙⇩sF{D}) h l sh False; ⋀C F D h l sh b. ∄b t. ?P ⊢ C has F,b:t in D ⟹ ?P1.0 (C∙⇩sF{D}) h l sh b (THROW NoSuchFieldError) h l sh False; ⋀C F t D h l sh b. ?P ⊢ C has F,NonStatic:t in D ⟹ ?P1.0 (C∙⇩sF{D}) h l sh b (THROW IncompatibleClassChangeError) h l sh False; ⋀e a aa b ba e' ab ac bb b' F D e₂. ⟦?P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ?P1.0 e a aa b ba e' ab ac bb b'⟧ ⟹ ?P1.0 (e∙F{D} := e₂) a aa b ba (e'∙F{D} := e₂) ab ac bb b'; ⋀e a aa b ba e' ab ac bb b' v F D. ⟦?P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ?P1.0 e a aa b ba e' ab ac bb b'⟧ ⟹ ?P1.0 (Val v∙F{D} := e) a aa b ba (Val v∙F{D} := e') ab ac bb b'; ⋀C F t D h a fs v l sh b. ⟦?P ⊢ C has F,NonStatic:t in D; h a = ⌊(C, fs)⌋⟧ ⟹ ?P1.0 (addr a∙F{D} := Val v) h l sh b unit (h(a ↦ (C, fs((F, D) ↦ v)))) l sh b; ⋀F D v a aa b ba. ?P1.0 (null∙F{D} := Val v) a aa b ba (THROW NullPointer) a aa b ba; ⋀h a C fs F D v l sh b. ⟦h a = ⌊(C, fs)⌋; ∄b t. ?P ⊢ C has F,b:t in D⟧ ⟹ ?P1.0 (addr a∙F{D} := Val v) h l sh b (THROW NoSuchFieldError) h l sh b; ⋀h a C fs F t D v l sh b. ⟦h a = ⌊(C, fs)⌋; ?P ⊢ C has F,Static:t in D⟧ ⟹ ?P1.0 (addr a∙F{D} := Val v) h l sh b (THROW IncompatibleClassChangeError) h l sh b; ⋀e a aa b ba e' ab ac bb b' C F D. ⟦?P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ?P1.0 e a aa b ba e' ab ac bb b'⟧ ⟹ ?P1.0 (C∙⇩sF{D} := e) a aa b ba (C∙⇩sF{D} := e') ab ac bb b'; ⋀C F t D sh sfs i sfs' v sh' h l. ⟦?P ⊢ C has F,Static:t in D; sh D = ⌊(sfs, i)⌋; sfs' = sfs(F ↦ v); sh' = sh(D ↦ (sfs', i))⟧ ⟹ ?P1.0 (C∙⇩sF{D} := Val v) h l sh True unit h l sh' False; ⋀C F t D sh sfs v h l. ⟦?P ⊢ C has F,Static:t in D; sh D = ⌊(sfs, Done)⌋⟧ ⟹ ?P1.0 (C∙⇩sF{D} := Val v) h l sh False (C∙⇩sF{D} := Val v) h l sh True; ⋀C F t D sh v h l. ⟦?P ⊢ C has F,Static:t in D; ∄sfs. sh D = ⌊(sfs, Done)⌋⟧ ⟹ ?P1.0 (C∙⇩sF{D} := Val v) h l sh False (INIT D ([D],False) ← C∙⇩sF{D} := Val v) h l sh False; ⋀C F D v a aa b ba. ∄b t. ?P ⊢ C has F,b:t in D ⟹ ?P1.0 (C∙⇩sF{D} := Val v) a aa b ba (THROW NoSuchFieldError) a aa b False; ⋀C F t D v a aa b ba. ?P ⊢ C has F,NonStatic:t in D ⟹ ?P1.0 (C∙⇩sF{D} := Val v) a aa b ba (THROW IncompatibleClassChangeError) a aa b False; ⋀e a aa b ba e' ab ac bb b' M es. ⟦?P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ?P1.0 e a aa b ba e' ab ac bb b'⟧ ⟹ ?P1.0 (e∙M(es)) a aa b ba (e'∙M(es)) ab ac bb b'; ⋀es a aa b ba es' ab ac bb b' v M. ⟦?P ⊢ ⟨es,(a, aa, b),ba⟩ [→] ⟨es',(ab, ac, bb),b'⟩; ?P2.0 es a aa b ba es' ab ac bb b'⟧ ⟹ ?P1.0 (Val v∙M(es)) a aa b ba (Val v∙M(es')) ab ac bb b'; ⋀h a C fs M Ts T pns body D vs l sh b. ⟦h a = ⌊(C, fs)⌋; ?P ⊢ C sees M, NonStatic : Ts→T = (pns, body) in D; length vs = length pns; length Ts = length pns⟧ ⟹ ?P1.0 (addr a∙M(map Val vs)) h l sh b (blocks (this # pns, Class D # Ts, Addr a # vs, body)) h l sh b; ⋀M vs a aa b ba. ?P1.0 (null∙M(map Val vs)) a aa b ba (THROW NullPointer) a aa b ba; ⋀h a C fs M vs l sh b. ⟦h a = ⌊(C, fs)⌋; ∄b Ts T m D. ?P ⊢ C sees M, b : Ts→T = m in D⟧ ⟹ ?P1.0 (addr a∙M(map Val vs)) h l sh b (THROW NoSuchMethodError) h l sh b; ⋀h a C fs M Ts T aa b D vs l sh ba. ⟦h a = ⌊(C, fs)⌋; ?P ⊢ C sees M, Static : Ts→T = (aa, b) in D⟧ ⟹ ?P1.0 (addr a∙M(map Val vs)) h l sh ba (THROW IncompatibleClassChangeError) h l sh ba; ⋀es a aa b ba es' ab ac bb b' C M. ⟦?P ⊢ ⟨es,(a, aa, b),ba⟩ [→] ⟨es',(ab, ac, bb),b'⟩; ?P2.0 es a aa b ba es' ab ac bb b'⟧ ⟹ ?P1.0 (C∙⇩sM(es)) a aa b ba (C∙⇩sM(es')) ab ac bb b'; ⋀C M Ts T pns body D vs a aa b. ⟦?P ⊢ C sees M, Static : Ts→T = (pns, body) in D; length vs = length pns; length Ts = length pns⟧ ⟹ ?P1.0 (C∙⇩sM(map Val vs)) a aa b True (blocks (pns, Ts, vs, body)) a aa b False; ⋀C M Ts T pns body D sh sfs vs h l. ⟦?P ⊢ C sees M, Static : Ts→T = (pns, body) in D; sh D = ⌊(sfs, Done)⌋ ∨ M = clinit ∧ sh D = ⌊(sfs, Processing)⌋⟧ ⟹ ?P1.0 (C∙⇩sM(map Val vs)) h l sh False (C∙⇩sM(map Val vs)) h l sh True; ⋀C M Ts T pns body D sh vs h l. ⟦?P ⊢ C sees M, Static : Ts→T = (pns, body) in D; ∄sfs. sh D = ⌊(sfs, Done)⌋; M ≠ clinit⟧ ⟹ ?P1.0 (C∙⇩sM(map Val vs)) h l sh False (INIT D ([D],False) ← C∙⇩sM(map Val vs)) h l sh False; ⋀C M vs a aa b ba. ∄b Ts T m. Ex (Method ?P C M b Ts T m) ⟹ ?P1.0 (C∙⇩sM(map Val vs)) a aa b ba (THROW NoSuchMethodError) a aa b False; ⋀C M Ts T a b D vs aa ab ba bb. ?P ⊢ C sees M, NonStatic : Ts→T = (a, b) in D ⟹ ?P1.0 (C∙⇩sM(map Val vs)) aa ab ba bb (THROW IncompatibleClassChangeError) aa ab ba False; ⋀e h l V sh b e' h' l' sh' b' T. ⟦?P ⊢ ⟨e,(h, l(V := None), sh),b⟩ → ⟨e',(h', l', sh'),b'⟩; ?P1.0 e h (l(V := None)) sh b e' h' l' sh' b'; l' V = None; ¬ assigned V e⟧ ⟹ ?P1.0 {V:T; e} h l sh b {V:T; e'} h' (l'(V := l V)) sh' b'; ⋀e h l V sh b e' h' l' sh' b' v T. ⟦?P ⊢ ⟨e,(h, l(V := None), sh),b⟩ → ⟨e',(h', l', sh'),b'⟩; ?P1.0 e h (l(V := None)) sh b e' h' l' sh' b'; l' V = ⌊v⌋; ¬ assigned V e⟧ ⟹ ?P1.0 {V:T; e} h l sh b {V:T; V:=Val v;; e'} h' (l'(V := l V)) sh' b'; ⋀e h l V v sh b e' h' l' sh' b' v' T. ⟦?P ⊢ ⟨e,(h, l(V ↦ v), sh),b⟩ → ⟨e',(h', l', sh'),b'⟩; ?P1.0 e h (l(V ↦ v)) sh b e' h' l' sh' b'; l' V = ⌊v'⌋⟧ ⟹ ?P1.0 {V:T; V:=Val v;; e} h l sh b {V:T; V:=Val v';; e'} h' (l'(V := l V)) sh' b'; ⋀V T u a aa b ba. ?P1.0 {V:T; Val u} a aa b ba (Val u) a aa b ba; ⋀V T v u a aa b ba. ?P1.0 {V:T; V:=Val v;; Val u} a aa b ba (Val u) a aa b ba; ⋀e a aa b ba e' ab ac bb b' e₂. ⟦?P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ?P1.0 e a aa b ba e' ab ac bb b'⟧ ⟹ ?P1.0 (e;; e₂) a aa b ba (e';; e₂) ab ac bb b'; ⋀v e₂ a aa b ba. ?P1.0 (Val v;; e₂) a aa b ba e₂ a aa b ba; ⋀e a aa b ba e' ab ac bb b' e₁ e₂. ⟦?P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ?P1.0 e a aa b ba e' ab ac bb b'⟧ ⟹ ?P1.0 (if (e) e₁ else e₂) a aa b ba (if (e') e₁ else e₂) ab ac bb b'; ⋀e₁ e₂ a aa b ba. ?P1.0 (if (true) e₁ else e₂) a aa b ba e₁ a aa b ba; ⋀e₁ e₂ a aa b ba. ?P1.0 (if (false) e₁ else e₂) a aa b ba e₂ a aa b ba; ⋀b c a aa ba b'. ?P1.0 (while (b) c) a aa ba b' (if (b) (c;; while (b) c) else unit) a aa ba b'; ⋀e a aa b ba e' ab ac bb b'. ⟦?P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ?P1.0 e a aa b ba e' ab ac bb b'⟧ ⟹ ?P1.0 (throw e) a aa b ba (throw e') ab ac bb b'; ⋀a aa b ba. ?P1.0 (throw null) a aa b ba (THROW NullPointer) a aa b ba; ⋀e a aa b ba e' ab ac bb b' C V e₂. ⟦?P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ?P1.0 e a aa b ba e' ab ac bb b'⟧ ⟹ ?P1.0 (try e catch(C V) e₂) a aa b ba (try e' catch(C V) e₂) ab ac bb b'; ⋀v C V e₂ a aa b ba. ?P1.0 (try Val v catch(C V) e₂) a aa b ba (Val v) a aa b ba; ⋀a aa b ab D fs C V e₂ ba. ⟦hp (a, aa, b) ab = ⌊(D, fs)⌋; ?P ⊢ D ≼⇧* C⟧ ⟹ ?P1.0 (try Throw ab catch(C V) e₂) a aa b ba {V:Class C; V:=addr ab;; e₂} a aa b ba; ⋀a aa b ab D fs C V e₂ ba. ⟦hp (a, aa, b) ab = ⌊(D, fs)⌋; (D, C) ∉ (subcls1 ?P)⇧*⟧ ⟹ ?P1.0 (try Throw ab catch(C V) e₂) a aa b ba (Throw ab) a aa b ba; ⋀e a aa b ba e' ab ac bb b' es. ⟦?P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ?P1.0 e a aa b ba e' ab ac bb b'⟧ ⟹ ?P2.0 (e # es) a aa b ba (e' # es) ab ac bb b'; ⋀es a aa b ba es' ab ac bb b' v. ⟦?P ⊢ ⟨es,(a, aa, b),ba⟩ [→] ⟨es',(ab, ac, bb),b'⟩; ?P2.0 es a aa b ba es' ab ac bb b'⟧ ⟹ ?P2.0 (Val v # es) a aa b ba (Val v # es') ab ac bb b'; ⋀e C b a aa ba b'. ¬ sub_RI e ⟹ ?P1.0 (INIT C ([],b) ← e) a aa ba b' e a aa ba (icheck ?P C e); ⋀sh C C' Cs e h l b. sh C = None ⟹ ?P1.0 (INIT C' (C # Cs,False) ← e) h l sh b (INIT C' (C # Cs,False) ← e) h l (sh(C ↦ (sblank ?P C, Prepared))) b; ⋀sh C sfs C' Cs e h l b. sh C = ⌊(sfs, Done)⌋ ⟹ ?P1.0 (INIT C' (C # Cs,False) ← e) h l sh b (INIT C' (Cs,True) ← e) h l sh b; ⋀sh C sfs C' Cs e h l b. sh C = ⌊(sfs, Processing)⌋ ⟹ ?P1.0 (INIT C' (C # Cs,False) ← e) h l sh b (INIT C' (Cs,True) ← e) h l sh b; ⋀sh C sfs C' Cs e h l b. sh C = ⌊(sfs, Error)⌋ ⟹ ?P1.0 (INIT C' (C # Cs,False) ← e) h l sh b (RI (C,THROW NoClassDefFoundError) ; Cs ← e) h l sh b; ⋀sh C sfs sh' C' Cs e h l b. ⟦sh C = ⌊(sfs, Prepared)⌋; C = Object; sh' = sh(C ↦ (sfs, Processing))⟧ ⟹ ?P1.0 (INIT C' (C # Cs,False) ← e) h l sh b (INIT C' (C # Cs,True) ← e) h l sh' b; ⋀sh C sfs D a b sh' C' Cs e h l ba. ⟦sh C = ⌊(sfs, Prepared)⌋; C ≠ Object; class ?P C = ⌊(D, a, b)⌋; sh' = sh(C ↦ (sfs, Processing))⟧ ⟹ ?P1.0 (INIT C' (C # Cs,False) ← e) h l sh ba (INIT C' (D # C # Cs,False) ← e) h l sh' ba; ⋀C' C Cs e h l sh b. ?P1.0 (INIT C' (C # Cs,True) ← e) h l sh b (RI (C,C∙⇩sclinit([])) ; Cs ← e) h l sh b; ⋀e a aa b ba e' ab ac bb b' C Cs e₀. ⟦?P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ?P1.0 e a aa b ba e' ab ac bb b'⟧ ⟹ ?P1.0 (RI (C,e) ; Cs ← e₀) a aa b ba (RI (C,e') ; Cs ← e₀) ab ac bb b'; ⋀sh C sfs i sh' C' Cs v e h l b. ⟦sh C = ⌊(sfs, i)⌋; sh' = sh(C ↦ (sfs, Done)); C' = last (C # Cs)⟧ ⟹ ?P1.0 (RI (C,Val v) ; Cs ← e) h l sh b (INIT C' (Cs,True) ← e) h l sh' b; ⋀C e a aa b ba. ?P1.0 (Cast C (throw e)) a aa b ba (throw e) a aa b ba; ⋀e bop e₂ a aa b ba. ?P1.0 (throw e «bop» e₂) a aa b ba (throw e) a aa b ba; ⋀v₁ bop e a aa b ba. ?P1.0 (Val v₁ «bop» throw e) a aa b ba (throw e) a aa b ba; ⋀V e a aa b ba. ?P1.0 (V:=throw e) a aa b ba (throw e) a aa b ba; ⋀e F D a aa b ba. ?P1.0 (throw e∙F{D}) a aa b ba (throw e) a aa b ba; ⋀e F D e₂ a aa b ba. ?P1.0 (throw e∙F{D} := e₂) a aa b ba (throw e) a aa b ba; ⋀v F D e a aa b ba. ?P1.0 (Val v∙F{D} := throw e) a aa b ba (throw e) a aa b ba; ⋀C F D e a aa b ba. ?P1.0 (C∙⇩sF{D} := throw e) a aa b ba (throw e) a aa b ba; ⋀e M es a aa b ba. ?P1.0 (throw e∙M(es)) a aa b ba (throw e) a aa b ba; ⋀es vs e es' v M a aa b ba. es = map Val vs @ throw e # es' ⟹ ?P1.0 (Val v∙M(es)) a aa b ba (throw e) a aa b ba; ⋀es vs e es' C M a aa b ba. es = map Val vs @ throw e # es' ⟹ ?P1.0 (C∙⇩sM(es)) a aa b ba (throw e) a aa b ba; ⋀V T a aa ab b ba. ?P1.0 {V:T; Throw a} aa ab b ba (Throw a) aa ab b ba; ⋀V T v a aa ab b ba. ?P1.0 {V:T; V:=Val v;; Throw a} aa ab b ba (Throw a) aa ab b ba; ⋀e e₂ a aa b ba. ?P1.0 (throw e;; e₂) a aa b ba (throw e) a aa b ba; ⋀e e₁ e₂ a aa b ba. ?P1.0 (if (throw e) e₁ else e₂) a aa b ba (throw e) a aa b ba; ⋀e a aa b ba. ?P1.0 (throw (throw e)) a aa b ba (throw e) a aa b ba; ⋀sh C sfs i sh' a D Cs e h l b. ⟦sh C = ⌊(sfs, i)⌋; sh' = sh(C ↦ (sfs, Error))⟧ ⟹ ?P1.0 (RI (C,Throw a) ; D # Cs ← e) h l sh b (RI (D,Throw a) ; Cs ← e) h l sh' b; ⋀sh C sfs i sh' a e h l b. ⟦sh C = ⌊(sfs, i)⌋; sh' = sh(C ↦ (sfs, Error))⟧ ⟹ ?P1.0 (RI (C,Throw a) ; [] ← e) h l sh b (Throw a) h l sh' b⟧ ⟹ ?P2.0 ?x7a ?x8a ?x8b ?x8c ?x9a ?x10a ?x11a ?x11b ?x11c ?x12a›*)) (*goals: 1. ‹⋀(h::heap) (a::nat) (Ca::char list) (FDTs::((char list × char list) × staticb × ty) list) (h'::heap) (l::sfields) sh::sheap. ⟦new_Addr h = ⌊a⌋; (P::(char list list × char list exp) prog) ⊢ Ca has_fields FDTs; h' = h(a ↦ blank P Ca); not_init (C::char list) (new Ca); sh C = ⌊(sfs::sfields, Processing)⌋⟧ ⟹ not_init C (addr a) ∧ (∃sfs'::sfields. sh C = ⌊(sfs', Processing)⌋)› 2. ‹⋀(h::heap) (Ca::char list) (l::sfields) sh::sheap. ⟦new_Addr h = None; is_class (P::(char list list × char list exp) prog) Ca; not_init (C::char list) (new Ca); sh C = ⌊(sfs::sfields, Processing)⌋⟧ ⟹ not_init C (THROW OutOfMemory) ∧ (∃sfs'::sfields. sh C = ⌊(sfs', Processing)⌋)› 3. ‹⋀(sh::sheap) (Ca::char list) (sfsa::sfields) (h::heap) l::sfields. ⟦sh Ca = ⌊(sfsa, Done)⌋; not_init (C::char list) (new Ca); sh C = ⌊(sfs::sfields, Processing)⌋⟧ ⟹ not_init C (new Ca) ∧ (∃sfs'::sfields. sh C = ⌊(sfs', Processing)⌋)› 4. ‹⋀(sh::sheap) (Ca::char list) (h::heap) l::sfields. ⟦∄sfs::sfields. sh Ca = ⌊(sfs, Done)⌋; is_class (P::(char list list × char list exp) prog) Ca; not_init (C::char list) (new Ca); sh C = ⌊(sfs::sfields, Processing)⌋⟧ ⟹ not_init C (INIT Ca ([Ca],False) ← new Ca) ∧ (∃sfs'::sfields. sh C = ⌊(sfs', Processing)⌋)› 5. ‹⋀(e::char list exp) (a::heap) (aa::sfields) (b::sheap) (ba::bool) (e'::char list exp) (ab::heap) (ac::sfields) (bb::sheap) (b'::bool) Ca::char list. ⟦(P::(char list list × char list exp) prog) ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⟦not_init (C::char list) e; b C = ⌊(sfs::sfields, Processing)⌋⟧ ⟹ not_init C e' ∧ (∃sfs'::sfields. bb C = ⌊(sfs', Processing)⌋); not_init C (Cast Ca e); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (Cast Ca e') ∧ (∃sfs'::sfields. bb C = ⌊(sfs', Processing)⌋)› 6. ‹⋀(Ca::char list) (a::heap) (aa::sfields) (b::sheap) ba::bool. ⟦not_init (C::char list) (Cast Ca null); b C = ⌊(sfs::sfields, Processing)⌋⟧ ⟹ not_init C null ∧ (∃sfs'::sfields. b C = ⌊(sfs', Processing)⌋)› 7. ‹⋀(h::heap) (a::nat) (D::char list) (fs::Objects.fields) (Ca::char list) (l::sfields) (sh::sheap) b::bool. ⟦h a = ⌊(D, fs)⌋; (P::(char list list × char list exp) prog) ⊢ D ≼⇧* Ca; not_init (C::char list) (Cast Ca (addr a)); sh C = ⌊(sfs::sfields, Processing)⌋⟧ ⟹ not_init C (addr a) ∧ (∃sfs'::sfields. sh C = ⌊(sfs', Processing)⌋)› 8. ‹⋀(h::heap) (a::nat) (D::char list) (fs::Objects.fields) (Ca::char list) (l::sfields) (sh::sheap) b::bool. ⟦h a = ⌊(D, fs)⌋; (D, Ca) ∉ (subcls1 (P::(char list list × char list exp) prog))⇧*; not_init (C::char list) (Cast Ca (addr a)); sh C = ⌊(sfs::sfields, Processing)⌋⟧ ⟹ not_init C (THROW ClassCast) ∧ (∃sfs'::sfields. sh C = ⌊(sfs', Processing)⌋)› 9. ‹⋀(e::char list exp) (a::heap) (aa::sfields) (b::sheap) (ba::bool) (e'::char list exp) (ab::heap) (ac::sfields) (bb::sheap) (b'::bool) (bop::bop) e₂::char list exp. ⟦(P::(char list list × char list exp) prog) ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⟦not_init (C::char list) e; b C = ⌊(sfs::sfields, Processing)⌋⟧ ⟹ not_init C e' ∧ (∃sfs'::sfields. bb C = ⌊(sfs', Processing)⌋); not_init C (e «bop» e₂); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (e' «bop» e₂) ∧ (∃sfs'::sfields. bb C = ⌊(sfs', Processing)⌋)› 10. ‹⋀(e::char list exp) (a::heap) (aa::sfields) (b::sheap) (ba::bool) (e'::char list exp) (ab::heap) (ac::sfields) (bb::sheap) (b'::bool) (v₁::val) bop::bop. ⟦(P::(char list list × char list exp) prog) ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⟦not_init (C::char list) e; b C = ⌊(sfs::sfields, Processing)⌋⟧ ⟹ not_init C e' ∧ (∃sfs'::sfields. bb C = ⌊(sfs', Processing)⌋); not_init C (Val v₁ «bop» e); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (Val v₁ «bop» e') ∧ (∃sfs'::sfields. bb C = ⌊(sfs', Processing)⌋)› 11. ‹⋀(bop::bop) (v₁::val) (v₂::val) (v::val) (a::heap) (aa::sfields) (b::sheap) ba::bool. ⟦binop (bop, v₁, v₂) = ⌊v⌋; not_init (C::char list) (Val v₁ «bop» Val v₂); b C = ⌊(sfs::sfields, Processing)⌋⟧ ⟹ not_init C (Val v) ∧ (∃sfs'::sfields. b C = ⌊(sfs', Processing)⌋)› 12. ‹⋀(l::sfields) (V::char list) (v::val) (h::heap) (sh::sheap) b::bool. ⟦l V = ⌊v⌋; not_init (C::char list) (Var V); sh C = ⌊(sfs::sfields, Processing)⌋⟧ ⟹ not_init C (Val v) ∧ (∃sfs'::sfields. sh C = ⌊(sfs', Processing)⌋)› 13. ‹⋀(e::char list exp) (a::heap) (aa::sfields) (b::sheap) (ba::bool) (e'::char list exp) (ab::heap) (ac::sfields) (bb::sheap) (b'::bool) V::char list. ⟦(P::(char list list × char list exp) prog) ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⟦not_init (C::char list) e; b C = ⌊(sfs::sfields, Processing)⌋⟧ ⟹ not_init C e' ∧ (∃sfs'::sfields. bb C = ⌊(sfs', Processing)⌋); not_init C (V:=e); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (V:=e') ∧ (∃sfs'::sfields. bb C = ⌊(sfs', Processing)⌋)› 14. ‹⋀(V::char list) (v::val) (h::heap) (l::sfields) (sh::sheap) b::bool. ⟦not_init (C::char list) (V:=Val v); sh C = ⌊(sfs::sfields, Processing)⌋⟧ ⟹ not_init C unit ∧ (∃sfs'::sfields. sh C = ⌊(sfs', Processing)⌋)› 15. ‹⋀(e::char list exp) (a::heap) (aa::sfields) (b::sheap) (ba::bool) (e'::char list exp) (ab::heap) (ac::sfields) (bb::sheap) (b'::bool) (F::char list) D::char list. ⟦(P::(char list list × char list exp) prog) ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⟦not_init (C::char list) e; b C = ⌊(sfs::sfields, Processing)⌋⟧ ⟹ not_init C e' ∧ (∃sfs'::sfields. bb C = ⌊(sfs', Processing)⌋); not_init C (e∙F{D}); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (e'∙F{D}) ∧ (∃sfs'::sfields. bb C = ⌊(sfs', Processing)⌋)› 16. ‹⋀(h::heap) (a::nat) (Ca::char list) (fs::Objects.fields) (F::char list) (D::char list) (v::val) (t::ty) (l::sfields) (sh::sheap) b::bool. ⟦h a = ⌊(Ca, fs)⌋; fs (F, D) = ⌊v⌋; (P::(char list list × char list exp) prog) ⊢ Ca has F,NonStatic:t in D; not_init (C::char list) (addr a∙F{D}); sh C = ⌊(sfs::sfields, Processing)⌋⟧ ⟹ not_init C (Val v) ∧ (∃sfs'::sfields. sh C = ⌊(sfs', Processing)⌋)› 17. ‹⋀(F::char list) (D::char list) (a::heap) (aa::sfields) (b::sheap) ba::bool. ⟦not_init (C::char list) (null∙F{D}); b C = ⌊(sfs::sfields, Processing)⌋⟧ ⟹ not_init C (THROW NullPointer) ∧ (∃sfs'::sfields. b C = ⌊(sfs', Processing)⌋)› 18. ‹⋀(h::heap) (a::nat) (Ca::char list) (fs::Objects.fields) (F::char list) (D::char list) (l::sfields) (sh::sheap) b::bool. ⟦h a = ⌊(Ca, fs)⌋; ∄(b::staticb) t::ty. (P::(char list list × char list exp) prog) ⊢ Ca has F,b:t in D; not_init (C::char list) (addr a∙F{D}); sh C = ⌊(sfs::sfields, Processing)⌋⟧ ⟹ not_init C (THROW NoSuchFieldError) ∧ (∃sfs'::sfields. sh C = ⌊(sfs', Processing)⌋)› 19. ‹⋀(h::heap) (a::nat) (Ca::char list) (fs::Objects.fields) (F::char list) (t::ty) (D::char list) (l::sfields) (sh::sheap) b::bool. ⟦h a = ⌊(Ca, fs)⌋; (P::(char list list × char list exp) prog) ⊢ Ca has F,Static:t in D; not_init (C::char list) (addr a∙F{D}); sh C = ⌊(sfs::sfields, Processing)⌋⟧ ⟹ not_init C (THROW IncompatibleClassChangeError) ∧ (∃sfs'::sfields. sh C = ⌊(sfs', Processing)⌋)› 20. ‹⋀(Ca::char list) (F::char list) (t::ty) (D::char list) (sh::sheap) (sfsa::sfields) (i::init_state) (v::val) (h::heap) l::sfields. ⟦(P::(char list list × char list exp) prog) ⊢ Ca has F,Static:t in D; sh D = ⌊(sfsa, i)⌋; sfsa F = ⌊v⌋; not_init (C::char list) (Ca∙⇩sF{D}); sh C = ⌊(sfs::sfields, Processing)⌋⟧ ⟹ not_init C (Val v) ∧ (∃sfs'::sfields. sh C = ⌊(sfs', Processing)⌋)› 21. ‹⋀(Ca::char list) (F::char list) (t::ty) (D::char list) (sh::sheap) (sfsa::sfields) (h::heap) l::sfields. ⟦(P::(char list list × char list exp) prog) ⊢ Ca has F,Static:t in D; sh D = ⌊(sfsa, Done)⌋; not_init (C::char list) (Ca∙⇩sF{D}); sh C = ⌊(sfs::sfields, Processing)⌋⟧ ⟹ not_init C (Ca∙⇩sF{D}) ∧ (∃sfs'::sfields. sh C = ⌊(sfs', Processing)⌋)› 22. ‹⋀(Ca::char list) (F::char list) (t::ty) (D::char list) (sh::sheap) (h::heap) l::sfields. ⟦(P::(char list list × char list exp) prog) ⊢ Ca has F,Static:t in D; ∄sfs::sfields. sh D = ⌊(sfs, Done)⌋; not_init (C::char list) (Ca∙⇩sF{D}); sh C = ⌊(sfs::sfields, Processing)⌋⟧ ⟹ not_init C (INIT D ([D],False) ← Ca∙⇩sF{D}) ∧ (∃sfs'::sfields. sh C = ⌊(sfs', Processing)⌋)› 23. ‹⋀(Ca::char list) (F::char list) (D::char list) (h::heap) (l::sfields) (sh::sheap) b::bool. ⟦∄(b::staticb) t::ty. (P::(char list list × char list exp) prog) ⊢ Ca has F,b:t in D; not_init (C::char list) (Ca∙⇩sF{D}); sh C = ⌊(sfs::sfields, Processing)⌋⟧ ⟹ not_init C (THROW NoSuchFieldError) ∧ (∃sfs'::sfields. sh C = ⌊(sfs', Processing)⌋)› 24. ‹⋀(Ca::char list) (F::char list) (t::ty) (D::char list) (h::heap) (l::sfields) (sh::sheap) b::bool. ⟦(P::(char list list × char list exp) prog) ⊢ Ca has F,NonStatic:t in D; not_init (C::char list) (Ca∙⇩sF{D}); sh C = ⌊(sfs::sfields, Processing)⌋⟧ ⟹ not_init C (THROW IncompatibleClassChangeError) ∧ (∃sfs'::sfields. sh C = ⌊(sfs', Processing)⌋)› 25. ‹⋀(e::char list exp) (a::heap) (aa::sfields) (b::sheap) (ba::bool) (e'::char list exp) (ab::heap) (ac::sfields) (bb::sheap) (b'::bool) (F::char list) (D::char list) e₂::char list exp. ⟦(P::(char list list × char list exp) prog) ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⟦not_init (C::char list) e; b C = ⌊(sfs::sfields, Processing)⌋⟧ ⟹ not_init C e' ∧ (∃sfs'::sfields. bb C = ⌊(sfs', Processing)⌋); not_init C (e∙F{D} := e₂); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (e'∙F{D} := e₂) ∧ (∃sfs'::sfields. bb C = ⌊(sfs', Processing)⌋)› 26. ‹⋀(e::char list exp) (a::heap) (aa::sfields) (b::sheap) (ba::bool) (e'::char list exp) (ab::heap) (ac::sfields) (bb::sheap) (b'::bool) (v::val) (F::char list) D::char list. ⟦(P::(char list list × char list exp) prog) ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⟦not_init (C::char list) e; b C = ⌊(sfs::sfields, Processing)⌋⟧ ⟹ not_init C e' ∧ (∃sfs'::sfields. bb C = ⌊(sfs', Processing)⌋); not_init C (Val v∙F{D} := e); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (Val v∙F{D} := e') ∧ (∃sfs'::sfields. bb C = ⌊(sfs', Processing)⌋)› 27. ‹⋀(Ca::char list) (F::char list) (t::ty) (D::char list) (h::heap) (a::nat) (fs::Objects.fields) (v::val) (l::sfields) (sh::sheap) b::bool. ⟦(P::(char list list × char list exp) prog) ⊢ Ca has F,NonStatic:t in D; h a = ⌊(Ca, fs)⌋; not_init (C::char list) (addr a∙F{D} := Val v); sh C = ⌊(sfs::sfields, Processing)⌋⟧ ⟹ not_init C unit ∧ (∃sfs'::sfields. sh C = ⌊(sfs', Processing)⌋)› 28. ‹⋀(F::char list) (D::char list) (v::val) (a::heap) (aa::sfields) (b::sheap) ba::bool. ⟦not_init (C::char list) (null∙F{D} := Val v); b C = ⌊(sfs::sfields, Processing)⌋⟧ ⟹ not_init C (THROW NullPointer) ∧ (∃sfs'::sfields. b C = ⌊(sfs', Processing)⌋)› 29. ‹⋀(h::heap) (a::nat) (Ca::char list) (fs::Objects.fields) (F::char list) (D::char list) (v::val) (l::sfields) (sh::sheap) b::bool. ⟦h a = ⌊(Ca, fs)⌋; ∄(b::staticb) t::ty. (P::(char list list × char list exp) prog) ⊢ Ca has F,b:t in D; not_init (C::char list) (addr a∙F{D} := Val v); sh C = ⌊(sfs::sfields, Processing)⌋⟧ ⟹ not_init C (THROW NoSuchFieldError) ∧ (∃sfs'::sfields. sh C = ⌊(sfs', Processing)⌋)› 30. ‹⋀(h::heap) (a::nat) (Ca::char list) (fs::Objects.fields) (F::char list) (t::ty) (D::char list) (v::val) (l::sfields) (sh::sheap) b::bool. ⟦h a = ⌊(Ca, fs)⌋; (P::(char list list × char list exp) prog) ⊢ Ca has F,Static:t in D; not_init (C::char list) (addr a∙F{D} := Val v); sh C = ⌊(sfs::sfields, Processing)⌋⟧ ⟹ not_init C (THROW IncompatibleClassChangeError) ∧ (∃sfs'::sfields. sh C = ⌊(sfs', Processing)⌋)› 31. ‹⋀(e::char list exp) (a::heap) (aa::sfields) (b::sheap) (ba::bool) (e'::char list exp) (ab::heap) (ac::sfields) (bb::sheap) (b'::bool) (Ca::char list) (F::char list) D::char list. ⟦(P::(char list list × char list exp) prog) ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⟦not_init (C::char list) e; b C = ⌊(sfs::sfields, Processing)⌋⟧ ⟹ not_init C e' ∧ (∃sfs'::sfields. bb C = ⌊(sfs', Processing)⌋); not_init C (Ca∙⇩sF{D} := e); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (Ca∙⇩sF{D} := e') ∧ (∃sfs'::sfields. bb C = ⌊(sfs', Processing)⌋)› 32. ‹⋀(Ca::char list) (F::char list) (t::ty) (D::char list) (sh::sheap) (sfsa::sfields) (i::init_state) (sfs'::sfields) (v::val) (sh'::sheap) (h::heap) l::sfields. ⟦(P::(char list list × char list exp) prog) ⊢ Ca has F,Static:t in D; sh D = ⌊(sfsa, i)⌋; sfs' = sfsa(F ↦ v); sh' = sh(D ↦ (sfs', i)); not_init (C::char list) (Ca∙⇩sF{D} := Val v); sh C = ⌊(sfs::sfields, Processing)⌋⟧ ⟹ not_init C unit ∧ (∃sfs'::sfields. sh' C = ⌊(sfs', Processing)⌋)› 33. ‹⋀(Ca::char list) (F::char list) (t::ty) (D::char list) (sh::sheap) (sfsa::sfields) (v::val) (h::heap) l::sfields. ⟦(P::(char list list × char list exp) prog) ⊢ Ca has F,Static:t in D; sh D = ⌊(sfsa, Done)⌋; not_init (C::char list) (Ca∙⇩sF{D} := Val v); sh C = ⌊(sfs::sfields, Processing)⌋⟧ ⟹ not_init C (Ca∙⇩sF{D} := Val v) ∧ (∃sfs'::sfields. sh C = ⌊(sfs', Processing)⌋)› 34. ‹⋀(Ca::char list) (F::char list) (t::ty) (D::char list) (sh::sheap) (v::val) (h::heap) l::sfields. ⟦(P::(char list list × char list exp) prog) ⊢ Ca has F,Static:t in D; ∄sfs::sfields. sh D = ⌊(sfs, Done)⌋; not_init (C::char list) (Ca∙⇩sF{D} := Val v); sh C = ⌊(sfs::sfields, Processing)⌋⟧ ⟹ not_init C (INIT D ([D],False) ← Ca∙⇩sF{D} := Val v) ∧ (∃sfs'::sfields. sh C = ⌊(sfs', Processing)⌋)› 35. ‹⋀(Ca::char list) (F::char list) (D::char list) (v::val) (a::heap) (aa::sfields) (b::sheap) ba::bool. ⟦∄(b::staticb) t::ty. (P::(char list list × char list exp) prog) ⊢ Ca has F,b:t in D; not_init (C::char list) (Ca∙⇩sF{D} := Val v); b C = ⌊(sfs::sfields, Processing)⌋⟧ ⟹ not_init C (THROW NoSuchFieldError) ∧ (∃sfs'::sfields. b C = ⌊(sfs', Processing)⌋)› 36. ‹⋀(Ca::char list) (F::char list) (t::ty) (D::char list) (v::val) (a::heap) (aa::sfields) (b::sheap) ba::bool. ⟦(P::(char list list × char list exp) prog) ⊢ Ca has F,NonStatic:t in D; not_init (C::char list) (Ca∙⇩sF{D} := Val v); b C = ⌊(sfs::sfields, Processing)⌋⟧ ⟹ not_init C (THROW IncompatibleClassChangeError) ∧ (∃sfs'::sfields. b C = ⌊(sfs', Processing)⌋)› 37. ‹⋀(e::char list exp) (a::heap) (aa::sfields) (b::sheap) (ba::bool) (e'::char list exp) (ab::heap) (ac::sfields) (bb::sheap) (b'::bool) (M::char list) es::char list exp list. ⟦(P::(char list list × char list exp) prog) ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⟦not_init (C::char list) e; b C = ⌊(sfs::sfields, Processing)⌋⟧ ⟹ not_init C e' ∧ (∃sfs'::sfields. bb C = ⌊(sfs', Processing)⌋); not_init C (e∙M(es)); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (e'∙M(es)) ∧ (∃sfs'::sfields. bb C = ⌊(sfs', Processing)⌋)› 38. ‹⋀(es::char list exp list) (a::heap) (aa::sfields) (b::sheap) (ba::bool) (es'::char list exp list) (ab::heap) (ac::sfields) (bb::sheap) (b'::bool) (v::val) M::char list. ⟦(P::(char list list × char list exp) prog) ⊢ ⟨es,(a, aa, b),ba⟩ [→] ⟨es',(ab, ac, bb),b'⟩; ⟦not_inits (C::char list) es; b C = ⌊(sfs::sfields, Processing)⌋⟧ ⟹ not_inits C es' ∧ (∃sfs'::sfields. bb C = ⌊(sfs', Processing)⌋); not_init C (Val v∙M(es)); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (Val v∙M(es')) ∧ (∃sfs'::sfields. bb C = ⌊(sfs', Processing)⌋)› 39. ‹⋀(h::heap) (a::nat) (Ca::char list) (fs::Objects.fields) (M::char list) (Ts::ty list) (T::ty) (pns::char list list) (body::char list exp) (D::char list) (vs::val list) (l::sfields) (sh::sheap) b::bool. ⟦h a = ⌊(Ca, fs)⌋; (P::(char list list × char list exp) prog) ⊢ Ca sees M, NonStatic : Ts→T = (pns, body) in D; length vs = length pns; length Ts = length pns; not_init (C::char list) (addr a∙M(map Val vs)); sh C = ⌊(sfs::sfields, Processing)⌋⟧ ⟹ not_init C (blocks (this # pns, Class D # Ts, Addr a # vs, body)) ∧ (∃sfs'::sfields. sh C = ⌊(sfs', Processing)⌋)› 40. ‹⋀(M::char list) (vs::val list) (a::heap) (aa::sfields) (b::sheap) ba::bool. ⟦not_init (C::char list) (null∙M(map Val vs)); b C = ⌊(sfs::sfields, Processing)⌋⟧ ⟹ not_init C (THROW NullPointer) ∧ (∃sfs'::sfields. b C = ⌊(sfs', Processing)⌋)› 41. ‹⋀(h::heap) (a::nat) (Ca::char list) (fs::Objects.fields) (M::char list) (vs::val list) (l::sfields) (sh::sheap) b::bool. ⟦h a = ⌊(Ca, fs)⌋; ∄(b::staticb) (Ts::ty list) (T::ty) (m::char list list × char list exp) D::char list. (P::(char list list × char list exp) prog) ⊢ Ca sees M, b : Ts→T = m in D; not_init (C::char list) (addr a∙M(map Val vs)); sh C = ⌊(sfs::sfields, Processing)⌋⟧ ⟹ not_init C (THROW NoSuchMethodError) ∧ (∃sfs'::sfields. sh C = ⌊(sfs', Processing)⌋)› 42. ‹⋀(h::heap) (a::nat) (Ca::char list) (fs::Objects.fields) (M::char list) (Ts::ty list) (T::ty) (aa::char list list) (b::char list exp) (D::char list) (vs::val list) (l::sfields) (sh::sheap) ba::bool. ⟦h a = ⌊(Ca, fs)⌋; (P::(char list list × char list exp) prog) ⊢ Ca sees M, Static : Ts→T = (aa, b) in D; not_init (C::char list) (addr a∙M(map Val vs)); sh C = ⌊(sfs::sfields, Processing)⌋⟧ ⟹ not_init C (THROW IncompatibleClassChangeError) ∧ (∃sfs'::sfields. sh C = ⌊(sfs', Processing)⌋)› 43. ‹⋀(es::char list exp list) (a::heap) (aa::sfields) (b::sheap) (ba::bool) (es'::char list exp list) (ab::heap) (ac::sfields) (bb::sheap) (b'::bool) (Ca::char list) M::char list. ⟦(P::(char list list × char list exp) prog) ⊢ ⟨es,(a, aa, b),ba⟩ [→] ⟨es',(ab, ac, bb),b'⟩; ⟦not_inits (C::char list) es; b C = ⌊(sfs::sfields, Processing)⌋⟧ ⟹ not_inits C es' ∧ (∃sfs'::sfields. bb C = ⌊(sfs', Processing)⌋); not_init C (Ca∙⇩sM(es)); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (Ca∙⇩sM(es')) ∧ (∃sfs'::sfields. bb C = ⌊(sfs', Processing)⌋)› 44. ‹⋀(Ca::char list) (M::char list) (Ts::ty list) (T::ty) (pns::char list list) (body::char list exp) (D::char list) (vs::val list) (a::heap) (aa::sfields) b::sheap. ⟦(P::(char list list × char list exp) prog) ⊢ Ca sees M, Static : Ts→T = (pns, body) in D; length vs = length pns; length Ts = length pns; not_init (C::char list) (Ca∙⇩sM(map Val vs)); b C = ⌊(sfs::sfields, Processing)⌋⟧ ⟹ not_init C (blocks (pns, Ts, vs, body)) ∧ (∃sfs'::sfields. b C = ⌊(sfs', Processing)⌋)› 45. ‹⋀(Ca::char list) (M::char list) (Ts::ty list) (T::ty) (pns::char list list) (body::char list exp) (D::char list) (sh::sheap) (sfsa::sfields) (vs::val list) (h::heap) l::sfields. ⟦(P::(char list list × char list exp) prog) ⊢ Ca sees M, Static : Ts→T = (pns, body) in D; sh D = ⌊(sfsa, Done)⌋ ∨ M = clinit ∧ sh D = ⌊(sfsa, Processing)⌋; not_init (C::char list) (Ca∙⇩sM(map Val vs)); sh C = ⌊(sfs::sfields, Processing)⌋⟧ ⟹ not_init C (Ca∙⇩sM(map Val vs)) ∧ (∃sfs'::sfields. sh C = ⌊(sfs', Processing)⌋)› 46. ‹⋀(Ca::char list) (M::char list) (Ts::ty list) (T::ty) (pns::char list list) (body::char list exp) (D::char list) (sh::sheap) (vs::val list) (h::heap) l::sfields. ⟦(P::(char list list × char list exp) prog) ⊢ Ca sees M, Static : Ts→T = (pns, body) in D; ∄sfs::sfields. sh D = ⌊(sfs, Done)⌋; M ≠ clinit; not_init (C::char list) (Ca∙⇩sM(map Val vs)); sh C = ⌊(sfs::sfields, Processing)⌋⟧ ⟹ not_init C (INIT D ([D],False) ← Ca∙⇩sM(map Val vs)) ∧ (∃sfs'::sfields. sh C = ⌊(sfs', Processing)⌋)› 47. ‹⋀(Ca::char list) (M::char list) (vs::val list) (a::heap) (aa::sfields) (b::sheap) ba::bool. ⟦∄(b::staticb) (Ts::ty list) (T::ty) m::char list list × char list exp. Ex (Method (P::(char list list × char list exp) prog) Ca M b Ts T m); not_init (C::char list) (Ca∙⇩sM(map Val vs)); b C = ⌊(sfs::sfields, Processing)⌋⟧ ⟹ not_init C (THROW NoSuchMethodError) ∧ (∃sfs'::sfields. b C = ⌊(sfs', Processing)⌋)› 48. ‹⋀(Ca::char list) (M::char list) (Ts::ty list) (T::ty) (a::char list list) (b::char list exp) (D::char list) (vs::val list) (aa::heap) (ab::sfields) (ba::sheap) bb::bool. ⟦(P::(char list list × char list exp) prog) ⊢ Ca sees M, NonStatic : Ts→T = (a, b) in D; not_init (C::char list) (Ca∙⇩sM(map Val vs)); ba C = ⌊(sfs::sfields, Processing)⌋⟧ ⟹ not_init C (THROW IncompatibleClassChangeError) ∧ (∃sfs'::sfields. ba C = ⌊(sfs', Processing)⌋)› 49. ‹⋀(e::char list exp) (h::heap) (l::sfields) (V::char list) (sh::sheap) (b::bool) (e'::char list exp) (h'::heap) (l'::sfields) (sh'::sheap) (b'::bool) T::ty. ⟦(P::(char list list × char list exp) prog) ⊢ ⟨e,(h, l(V := None), sh),b⟩ → ⟨e',(h', l', sh'),b'⟩; ⟦not_init (C::char list) e; sh C = ⌊(sfs::sfields, Processing)⌋⟧ ⟹ not_init C e' ∧ (∃sfs'::sfields. sh' C = ⌊(sfs', Processing)⌋); l' V = None; ¬ assigned V e; not_init C {V:T; e}; sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C {V:T; e'} ∧ (∃sfs'::sfields. sh' C = ⌊(sfs', Processing)⌋)› 50. ‹⋀(e::char list exp) (h::heap) (l::sfields) (V::char list) (sh::sheap) (b::bool) (e'::char list exp) (h'::heap) (l'::sfields) (sh'::sheap) (b'::bool) (v::val) T::ty. ⟦(P::(char list list × char list exp) prog) ⊢ ⟨e,(h, l(V := None), sh),b⟩ → ⟨e',(h', l', sh'),b'⟩; ⟦not_init (C::char list) e; sh C = ⌊(sfs::sfields, Processing)⌋⟧ ⟹ not_init C e' ∧ (∃sfs'::sfields. sh' C = ⌊(sfs', Processing)⌋); l' V = ⌊v⌋; ¬ assigned V e; not_init C {V:T; e}; sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C {V:T; V:=Val v;; e'} ∧ (∃sfs'::sfields. sh' C = ⌊(sfs', Processing)⌋)› 51. ‹⋀(e::char list exp) (h::heap) (l::sfields) (V::char list) (v::val) (sh::sheap) (b::bool) (e'::char list exp) (h'::heap) (l'::sfields) (sh'::sheap) (b'::bool) (v'::val) T::ty. ⟦(P::(char list list × char list exp) prog) ⊢ ⟨e,(h, l(V ↦ v), sh),b⟩ → ⟨e',(h', l', sh'),b'⟩; ⟦not_init (C::char list) e; sh C = ⌊(sfs::sfields, Processing)⌋⟧ ⟹ not_init C e' ∧ (∃sfs'::sfields. sh' C = ⌊(sfs', Processing)⌋); l' V = ⌊v'⌋; not_init C {V:T; V:=Val v;; e}; sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C {V:T; V:=Val v';; e'} ∧ (∃sfs'::sfields. sh' C = ⌊(sfs', Processing)⌋)› 52. ‹⋀(V::char list) (T::ty) (u::val) (a::heap) (aa::sfields) (b::sheap) ba::bool. ⟦not_init (C::char list) {V:T; Val u}; b C = ⌊(sfs::sfields, Processing)⌋⟧ ⟹ not_init C (Val u) ∧ (∃sfs'::sfields. b C = ⌊(sfs', Processing)⌋)› 53. ‹⋀(V::char list) (T::ty) (v::val) (u::val) (a::heap) (aa::sfields) (b::sheap) ba::bool. ⟦not_init (C::char list) {V:T; V:=Val v;; Val u}; b C = ⌊(sfs::sfields, Processing)⌋⟧ ⟹ not_init C (Val u) ∧ (∃sfs'::sfields. b C = ⌊(sfs', Processing)⌋)› 54. ‹⋀(e::char list exp) (a::heap) (aa::sfields) (b::sheap) (ba::bool) (e'::char list exp) (ab::heap) (ac::sfields) (bb::sheap) (b'::bool) e₂::char list exp. ⟦(P::(char list list × char list exp) prog) ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⟦not_init (C::char list) e; b C = ⌊(sfs::sfields, Processing)⌋⟧ ⟹ not_init C e' ∧ (∃sfs'::sfields. bb C = ⌊(sfs', Processing)⌋); not_init C (e;; e₂); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (e';; e₂) ∧ (∃sfs'::sfields. bb C = ⌊(sfs', Processing)⌋)› 55. ‹⋀(v::val) (e₂::char list exp) (a::heap) (aa::sfields) (b::sheap) ba::bool. ⟦not_init (C::char list) (Val v;; e₂); b C = ⌊(sfs::sfields, Processing)⌋⟧ ⟹ not_init C e₂ ∧ (∃sfs'::sfields. b C = ⌊(sfs', Processing)⌋)› 56. ‹⋀(e::char list exp) (a::heap) (aa::sfields) (b::sheap) (ba::bool) (e'::char list exp) (ab::heap) (ac::sfields) (bb::sheap) (b'::bool) (e₁::char list exp) e₂::char list exp. ⟦(P::(char list list × char list exp) prog) ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⟦not_init (C::char list) e; b C = ⌊(sfs::sfields, Processing)⌋⟧ ⟹ not_init C e' ∧ (∃sfs'::sfields. bb C = ⌊(sfs', Processing)⌋); not_init C (if (e) e₁ else e₂); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (if (e') e₁ else e₂) ∧ (∃sfs'::sfields. bb C = ⌊(sfs', Processing)⌋)› 57. ‹⋀(e₁::char list exp) (e₂::char list exp) (a::heap) (aa::sfields) (b::sheap) ba::bool. ⟦not_init (C::char list) (if (true) e₁ else e₂); b C = ⌊(sfs::sfields, Processing)⌋⟧ ⟹ not_init C e₁ ∧ (∃sfs'::sfields. b C = ⌊(sfs', Processing)⌋)› 58. ‹⋀(e₁::char list exp) (e₂::char list exp) (a::heap) (aa::sfields) (b::sheap) ba::bool. ⟦not_init (C::char list) (if (false) e₁ else e₂); b C = ⌊(sfs::sfields, Processing)⌋⟧ ⟹ not_init C e₂ ∧ (∃sfs'::sfields. b C = ⌊(sfs', Processing)⌋)› 59. ‹⋀(b::char list exp) (c::char list exp) (a::heap) (aa::sfields) (ba::sheap) b'::bool. ⟦not_init (C::char list) (while (b) c); ba C = ⌊(sfs::sfields, Processing)⌋⟧ ⟹ not_init C (if (b) (c;; while (b) c) else unit) ∧ (∃sfs'::sfields. ba C = ⌊(sfs', Processing)⌋)› 60. ‹⋀(e::char list exp) (a::heap) (aa::sfields) (b::sheap) (ba::bool) (e'::char list exp) (ab::heap) (ac::sfields) (bb::sheap) b'::bool. ⟦(P::(char list list × char list exp) prog) ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⟦not_init (C::char list) e; b C = ⌊(sfs::sfields, Processing)⌋⟧ ⟹ not_init C e' ∧ (∃sfs'::sfields. bb C = ⌊(sfs', Processing)⌋); not_init C (throw e); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (throw e') ∧ (∃sfs'::sfields. bb C = ⌊(sfs', Processing)⌋)› 61. ‹⋀(a::heap) (aa::sfields) (b::sheap) ba::bool. ⟦not_init (C::char list) (throw null); b C = ⌊(sfs::sfields, Processing)⌋⟧ ⟹ not_init C (THROW NullPointer) ∧ (∃sfs'::sfields. b C = ⌊(sfs', Processing)⌋)› 62. ‹⋀(e::char list exp) (a::heap) (aa::sfields) (b::sheap) (ba::bool) (e'::char list exp) (ab::heap) (ac::sfields) (bb::sheap) (b'::bool) (Ca::char list) (V::char list) e₂::char list exp. ⟦(P::(char list list × char list exp) prog) ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⟦not_init (C::char list) e; b C = ⌊(sfs::sfields, Processing)⌋⟧ ⟹ not_init C e' ∧ (∃sfs'::sfields. bb C = ⌊(sfs', Processing)⌋); not_init C (try e catch(Ca V) e₂); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (try e' catch(Ca V) e₂) ∧ (∃sfs'::sfields. bb C = ⌊(sfs', Processing)⌋)› 63. ‹⋀(v::val) (Ca::char list) (V::char list) (e₂::char list exp) (a::heap) (aa::sfields) (b::sheap) ba::bool. ⟦not_init (C::char list) (try Val v catch(Ca V) e₂); b C = ⌊(sfs::sfields, Processing)⌋⟧ ⟹ not_init C (Val v) ∧ (∃sfs'::sfields. b C = ⌊(sfs', Processing)⌋)› 64. ‹⋀(a::heap) (aa::sfields) (b::sheap) (ab::nat) (D::char list) (fs::Objects.fields) (Ca::char list) (V::char list) (e₂::char list exp) ba::bool. ⟦hp (a, aa, b) ab = ⌊(D, fs)⌋; (P::(char list list × char list exp) prog) ⊢ D ≼⇧* Ca; not_init (C::char list) (try Throw ab catch(Ca V) e₂); b C = ⌊(sfs::sfields, Processing)⌋⟧ ⟹ not_init C {V:Class Ca; V:=addr ab;; e₂} ∧ (∃sfs'::sfields. b C = ⌊(sfs', Processing)⌋)› 65. ‹⋀(a::heap) (aa::sfields) (b::sheap) (ab::nat) (D::char list) (fs::Objects.fields) (Ca::char list) (V::char list) (e₂::char list exp) ba::bool. ⟦hp (a, aa, b) ab = ⌊(D, fs)⌋; (D, Ca) ∉ (subcls1 (P::(char list list × char list exp) prog))⇧*; not_init (C::char list) (try Throw ab catch(Ca V) e₂); b C = ⌊(sfs::sfields, Processing)⌋⟧ ⟹ not_init C (Throw ab) ∧ (∃sfs'::sfields. b C = ⌊(sfs', Processing)⌋)› 66. ‹⋀(e::char list exp) (a::heap) (aa::sfields) (b::sheap) (ba::bool) (e'::char list exp) (ab::heap) (ac::sfields) (bb::sheap) (b'::bool) es::char list exp list. ⟦(P::(char list list × char list exp) prog) ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⟦not_init (C::char list) e; b C = ⌊(sfs::sfields, Processing)⌋⟧ ⟹ not_init C e' ∧ (∃sfs'::sfields. bb C = ⌊(sfs', Processing)⌋); not_inits C (e # es); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_inits C (e' # es) ∧ (∃sfs'::sfields. bb C = ⌊(sfs', Processing)⌋)› 67. ‹⋀(es::char list exp list) (a::heap) (aa::sfields) (b::sheap) (ba::bool) (es'::char list exp list) (ab::heap) (ac::sfields) (bb::sheap) (b'::bool) v::val. ⟦(P::(char list list × char list exp) prog) ⊢ ⟨es,(a, aa, b),ba⟩ [→] ⟨es',(ab, ac, bb),b'⟩; ⟦not_inits (C::char list) es; b C = ⌊(sfs::sfields, Processing)⌋⟧ ⟹ not_inits C es' ∧ (∃sfs'::sfields. bb C = ⌊(sfs', Processing)⌋); not_inits C (Val v # es); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_inits C (Val v # es') ∧ (∃sfs'::sfields. bb C = ⌊(sfs', Processing)⌋)› 68. ‹⋀(e::char list exp) (Ca::char list) (b::bool) (a::heap) (aa::sfields) (ba::sheap) b'::bool. ⟦¬ sub_RI e; not_init (C::char list) (INIT Ca ([],b) ← e); ba C = ⌊(sfs::sfields, Processing)⌋⟧ ⟹ not_init C e ∧ (∃sfs'::sfields. ba C = ⌊(sfs', Processing)⌋)› 69. ‹⋀(sh::sheap) (Ca::char list) (C'::char list) (Cs::char list list) (e::char list exp) (h::heap) (l::sfields) b::bool. ⟦sh Ca = None; not_init (C::char list) (INIT C' (Ca # Cs,False) ← e); sh C = ⌊(sfs::sfields, Processing)⌋⟧ ⟹ not_init C (INIT C' (Ca # Cs,False) ← e) ∧ (∃sfs'::sfields. (sh(Ca ↦ (sblank (P::(char list list × char list exp) prog) Ca, Prepared))) C = ⌊(sfs', Processing)⌋)› 70. ‹⋀(sh::sheap) (Ca::char list) (sfsa::sfields) (C'::char list) (Cs::char list list) (e::char list exp) (h::heap) (l::sfields) b::bool. ⟦sh Ca = ⌊(sfsa, Done)⌋; not_init (C::char list) (INIT C' (Ca # Cs,False) ← e); sh C = ⌊(sfs::sfields, Processing)⌋⟧ ⟹ not_init C (INIT C' (Cs,True) ← e) ∧ (∃sfs'::sfields. sh C = ⌊(sfs', Processing)⌋)› 71. ‹⋀(sh::sheap) (Ca::char list) (sfsa::sfields) (C'::char list) (Cs::char list list) (e::char list exp) (h::heap) (l::sfields) b::bool. ⟦sh Ca = ⌊(sfsa, Processing)⌋; not_init (C::char list) (INIT C' (Ca # Cs,False) ← e); sh C = ⌊(sfs::sfields, Processing)⌋⟧ ⟹ not_init C (INIT C' (Cs,True) ← e) ∧ (∃sfs'::sfields. sh C = ⌊(sfs', Processing)⌋)› 72. ‹⋀(sh::sheap) (Ca::char list) (sfsa::sfields) (C'::char list) (Cs::char list list) (e::char list exp) (h::heap) (l::sfields) b::bool. ⟦sh Ca = ⌊(sfsa, Error)⌋; not_init (C::char list) (INIT C' (Ca # Cs,False) ← e); sh C = ⌊(sfs::sfields, Processing)⌋⟧ ⟹ not_init C (RI (Ca,THROW NoClassDefFoundError) ; Cs ← e) ∧ (∃sfs'::sfields. sh C = ⌊(sfs', Processing)⌋)› 73. ‹⋀(sh::sheap) (Ca::char list) (sfsa::sfields) (sh'::sheap) (C'::char list) (Cs::char list list) (e::char list exp) (h::heap) (l::sfields) b::bool. ⟦sh Ca = ⌊(sfsa, Prepared)⌋; Ca = Object; sh' = sh(Ca ↦ (sfsa, Processing)); not_init (C::char list) (INIT C' (Ca # Cs,False) ← e); sh C = ⌊(sfs::sfields, Processing)⌋⟧ ⟹ not_init C (INIT C' (Ca # Cs,True) ← e) ∧ (∃sfs'::sfields. sh' C = ⌊(sfs', Processing)⌋)› 74. ‹⋀(sh::sheap) (Ca::char list) (sfsa::sfields) (D::char list) (a::fdecl list) (b::(char list list × char list exp) mdecl list) (sh'::sheap) (C'::char list) (Cs::char list list) (e::char list exp) (h::heap) (l::sfields) ba::bool. ⟦sh Ca = ⌊(sfsa, Prepared)⌋; Ca ≠ Object; class (P::(char list list × char list exp) prog) Ca = ⌊(D, a, b)⌋; sh' = sh(Ca ↦ (sfsa, Processing)); not_init (C::char list) (INIT C' (Ca # Cs,False) ← e); sh C = ⌊(sfs::sfields, Processing)⌋⟧ ⟹ not_init C (INIT C' (D # Ca # Cs,False) ← e) ∧ (∃sfs'::sfields. sh' C = ⌊(sfs', Processing)⌋)› 75. ‹⋀(C'::char list) (Ca::char list) (Cs::char list list) (e::char list exp) (h::heap) (l::sfields) (sh::sheap) b::bool. ⟦not_init (C::char list) (INIT C' (Ca # Cs,True) ← e); sh C = ⌊(sfs::sfields, Processing)⌋⟧ ⟹ not_init C (RI (Ca,Ca∙⇩sclinit([])) ; Cs ← e) ∧ (∃sfs'::sfields. sh C = ⌊(sfs', Processing)⌋)› 76. ‹⋀(e::char list exp) (a::heap) (aa::sfields) (b::sheap) (ba::bool) (e'::char list exp) (ab::heap) (ac::sfields) (bb::sheap) (b'::bool) (Ca::char list) (Cs::char list list) e₀::char list exp. ⟦(P::(char list list × char list exp) prog) ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⟦not_init (C::char list) e; b C = ⌊(sfs::sfields, Processing)⌋⟧ ⟹ not_init C e' ∧ (∃sfs'::sfields. bb C = ⌊(sfs', Processing)⌋); not_init C (RI (Ca,e) ; Cs ← e₀); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (RI (Ca,e') ; Cs ← e₀) ∧ (∃sfs'::sfields. bb C = ⌊(sfs', Processing)⌋)› 77. ‹⋀(sh::sheap) (Ca::char list) (sfsa::sfields) (i::init_state) (sh'::sheap) (C'::char list) (Cs::char list list) (v::val) (e::char list exp) (h::heap) (l::sfields) b::bool. ⟦sh Ca = ⌊(sfsa, i)⌋; sh' = sh(Ca ↦ (sfsa, Done)); C' = last (Ca # Cs); not_init (C::char list) (RI (Ca,Val v) ; Cs ← e); sh C = ⌊(sfs::sfields, Processing)⌋⟧ ⟹ not_init C (INIT C' (Cs,True) ← e) ∧ (∃sfs'::sfields. sh' C = ⌊(sfs', Processing)⌋)› 78. ‹⋀(Ca::char list) (e::char list exp) (a::heap) (aa::sfields) (b::sheap) ba::bool. ⟦not_init (C::char list) (Cast Ca (throw e)); b C = ⌊(sfs::sfields, Processing)⌋⟧ ⟹ not_init C (throw e) ∧ (∃sfs'::sfields. b C = ⌊(sfs', Processing)⌋)› 79. ‹⋀(e::char list exp) (bop::bop) (e₂::char list exp) (a::heap) (aa::sfields) (b::sheap) ba::bool. ⟦not_init (C::char list) (throw e «bop» e₂); b C = ⌊(sfs::sfields, Processing)⌋⟧ ⟹ not_init C (throw e) ∧ (∃sfs'::sfields. b C = ⌊(sfs', Processing)⌋)› 80. ‹⋀(v₁::val) (bop::bop) (e::char list exp) (a::heap) (aa::sfields) (b::sheap) ba::bool. ⟦not_init (C::char list) (Val v₁ «bop» throw e); b C = ⌊(sfs::sfields, Processing)⌋⟧ ⟹ not_init C (throw e) ∧ (∃sfs'::sfields. b C = ⌊(sfs', Processing)⌋)› 81. ‹⋀(V::char list) (e::char list exp) (a::heap) (aa::sfields) (b::sheap) ba::bool. ⟦not_init (C::char list) (V:=throw e); b C = ⌊(sfs::sfields, Processing)⌋⟧ ⟹ not_init C (throw e) ∧ (∃sfs'::sfields. b C = ⌊(sfs', Processing)⌋)› 82. ‹⋀(e::char list exp) (F::char list) (D::char list) (a::heap) (aa::sfields) (b::sheap) ba::bool. ⟦not_init (C::char list) (throw e∙F{D}); b C = ⌊(sfs::sfields, Processing)⌋⟧ ⟹ not_init C (throw e) ∧ (∃sfs'::sfields. b C = ⌊(sfs', Processing)⌋)› 83. ‹⋀(e::char list exp) (F::char list) (D::char list) (e₂::char list exp) (a::heap) (aa::sfields) (b::sheap) ba::bool. ⟦not_init (C::char list) (throw e∙F{D} := e₂); b C = ⌊(sfs::sfields, Processing)⌋⟧ ⟹ not_init C (throw e) ∧ (∃sfs'::sfields. b C = ⌊(sfs', Processing)⌋)› 84. ‹⋀(v::val) (F::char list) (D::char list) (e::char list exp) (a::heap) (aa::sfields) (b::sheap) ba::bool. ⟦not_init (C::char list) (Val v∙F{D} := throw e); b C = ⌊(sfs::sfields, Processing)⌋⟧ ⟹ not_init C (throw e) ∧ (∃sfs'::sfields. b C = ⌊(sfs', Processing)⌋)› 85. ‹⋀(Ca::char list) (F::char list) (D::char list) (e::char list exp) (a::heap) (aa::sfields) (b::sheap) ba::bool. ⟦not_init (C::char list) (Ca∙⇩sF{D} := throw e); b C = ⌊(sfs::sfields, Processing)⌋⟧ ⟹ not_init C (throw e) ∧ (∃sfs'::sfields. b C = ⌊(sfs', Processing)⌋)› 86. ‹⋀(e::char list exp) (M::char list) (es::char list exp list) (a::heap) (aa::sfields) (b::sheap) ba::bool. ⟦not_init (C::char list) (throw e∙M(es)); b C = ⌊(sfs::sfields, Processing)⌋⟧ ⟹ not_init C (throw e) ∧ (∃sfs'::sfields. b C = ⌊(sfs', Processing)⌋)› 87. ‹⋀(es::char list exp list) (vs::val list) (e::char list exp) (es'::char list exp list) (v::val) (M::char list) (a::heap) (aa::sfields) (b::sheap) ba::bool. ⟦es = map Val vs @ throw e # es'; not_init (C::char list) (Val v∙M(es)); b C = ⌊(sfs::sfields, Processing)⌋⟧ ⟹ not_init C (throw e) ∧ (∃sfs'::sfields. b C = ⌊(sfs', Processing)⌋)› 88. ‹⋀(es::char list exp list) (vs::val list) (e::char list exp) (es'::char list exp list) (Ca::char list) (M::char list) (a::heap) (aa::sfields) (b::sheap) ba::bool. ⟦es = map Val vs @ throw e # es'; not_init (C::char list) (Ca∙⇩sM(es)); b C = ⌊(sfs::sfields, Processing)⌋⟧ ⟹ not_init C (throw e) ∧ (∃sfs'::sfields. b C = ⌊(sfs', Processing)⌋)› 89. ‹⋀(V::char list) (T::ty) (a::nat) (aa::heap) (ab::sfields) (b::sheap) ba::bool. ⟦not_init (C::char list) {V:T; Throw a}; b C = ⌊(sfs::sfields, Processing)⌋⟧ ⟹ not_init C (Throw a) ∧ (∃sfs'::sfields. b C = ⌊(sfs', Processing)⌋)› 90. ‹⋀(V::char list) (T::ty) (v::val) (a::nat) (aa::heap) (ab::sfields) (b::sheap) ba::bool. ⟦not_init (C::char list) {V:T; V:=Val v;; Throw a}; b C = ⌊(sfs::sfields, Processing)⌋⟧ ⟹ not_init C (Throw a) ∧ (∃sfs'::sfields. b C = ⌊(sfs', Processing)⌋)› 91. ‹⋀(e::char list exp) (e₂::char list exp) (a::heap) (aa::sfields) (b::sheap) ba::bool. ⟦not_init (C::char list) (throw e;; e₂); b C = ⌊(sfs::sfields, Processing)⌋⟧ ⟹ not_init C (throw e) ∧ (∃sfs'::sfields. b C = ⌊(sfs', Processing)⌋)› 92. ‹⋀(e::char list exp) (e₁::char list exp) (e₂::char list exp) (a::heap) (aa::sfields) (b::sheap) ba::bool. ⟦not_init (C::char list) (if (throw e) e₁ else e₂); b C = ⌊(sfs::sfields, Processing)⌋⟧ ⟹ not_init C (throw e) ∧ (∃sfs'::sfields. b C = ⌊(sfs', Processing)⌋)› 93. ‹⋀(e::char list exp) (a::heap) (aa::sfields) (b::sheap) ba::bool. ⟦not_init (C::char list) (throw (throw e)); b C = ⌊(sfs::sfields, Processing)⌋⟧ ⟹ not_init C (throw e) ∧ (∃sfs'::sfields. b C = ⌊(sfs', Processing)⌋)› 94. ‹⋀(sh::sheap) (Ca::char list) (sfsa::sfields) (i::init_state) (sh'::sheap) (a::nat) (D::char list) (Cs::char list list) (e::char list exp) (h::heap) (l::sfields) b::bool. ⟦sh Ca = ⌊(sfsa, i)⌋; sh' = sh(Ca ↦ (sfsa, Error)); not_init (C::char list) (RI (Ca,Throw a) ; D # Cs ← e); sh C = ⌊(sfs::sfields, Processing)⌋⟧ ⟹ not_init C (RI (D,Throw a) ; Cs ← e) ∧ (∃sfs'::sfields. sh' C = ⌊(sfs', Processing)⌋)› 95. ‹⋀(sh::sheap) (Ca::char list) (sfsa::sfields) (i::init_state) (sh'::sheap) (a::nat) (e::char list exp) (h::heap) (l::sfields) b::bool. ⟦sh Ca = ⌊(sfsa, i)⌋; sh' = sh(Ca ↦ (sfsa, Error)); not_init (C::char list) (RI (Ca,Throw a) ; [] ← e); sh C = ⌊(sfs::sfields, Processing)⌋⟧ ⟹ not_init C (Throw a) ∧ (∃sfs'::sfields. sh' C = ⌊(sfs', Processing)⌋)›*) case RedCall (*‹h_ a_ = ⌊(C_, fs_)⌋› ‹P ⊢ C_ sees M_, NonStatic : Ts_→T_ = (pns_, body_) in D_› ‹length vs_ = length pns_› ‹length (Ts_::ty list) = length (pns_::char list list)› ‹not_init (C::char list) (addr (a_::nat)∙(M_::char list)(map Val (vs_::val list)))› ‹sh_ C = ⌊(sfs, Processing)⌋›*) then show "?case" (*goal: ‹not_init C (blocks (this # pns_, Class D_ # Ts_, Addr a_ # vs_, body_)) ∧ (∃sfs'. sh_ C = ⌊(sfs', Processing)⌋)›*) using sees_wwf_nsub_RI[OF wf RedCall.hyps ( 2 )] (*‹¬ sub_RI body_›*) sub_RI_blocks_body (*‹⟦length ?vs = length ?pns; length ?Ts = length ?pns⟧ ⟹ sub_RI (blocks (?pns, ?Ts, ?vs, ?body)) = sub_RI ?body›*) nsub_RI_not_init (*‹¬ sub_RI ?e ⟹ not_init ?C ?e›*) by auto next (*goals: 1. ‹⋀h a Ca FDTs h' l sh. ⟦new_Addr h = ⌊a⌋; P ⊢ Ca has_fields FDTs; h' = h(a ↦ blank P Ca); not_init C (new Ca); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (addr a) ∧ (∃sfs'. sh C = ⌊(sfs', Processing)⌋)› 2. ‹⋀h Ca l sh. ⟦new_Addr h = None; is_class P Ca; not_init C (new Ca); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (THROW OutOfMemory) ∧ (∃sfs'. sh C = ⌊(sfs', Processing)⌋)› 3. ‹⋀sh Ca sfsa h l. ⟦sh Ca = ⌊(sfsa, Done)⌋; not_init C (new Ca); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (new Ca) ∧ (∃sfs'. sh C = ⌊(sfs', Processing)⌋)› 4. ‹⋀sh Ca h l. ⟦∄sfs. sh Ca = ⌊(sfs, Done)⌋; is_class P Ca; not_init C (new Ca); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (INIT Ca ([Ca],False) ← new Ca) ∧ (∃sfs'. sh C = ⌊(sfs', Processing)⌋)› 5. ‹⋀e a aa b ba e' ab ac bb b' Ca. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⟦not_init C e; b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C e' ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋); not_init C (Cast Ca e); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (Cast Ca e') ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋)› 6. ‹⋀Ca a aa b ba. ⟦not_init C (Cast Ca null); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C null ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 7. ‹⋀h a D fs Ca l sh b. ⟦h a = ⌊(D, fs)⌋; P ⊢ D ≼⇧* Ca; not_init C (Cast Ca (addr a)); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (addr a) ∧ (∃sfs'. sh C = ⌊(sfs', Processing)⌋)› 8. ‹⋀h a D fs Ca l sh b. ⟦h a = ⌊(D, fs)⌋; (D, Ca) ∉ (subcls1 P)⇧*; not_init C (Cast Ca (addr a)); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (THROW ClassCast) ∧ (∃sfs'. sh C = ⌊(sfs', Processing)⌋)› 9. ‹⋀e a aa b ba e' ab ac bb b' bop e₂. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⟦not_init C e; b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C e' ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋); not_init C (e «bop» e₂); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (e' «bop» e₂) ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋)› 10. ‹⋀e a aa b ba e' ab ac bb b' v₁ bop. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⟦not_init C e; b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C e' ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋); not_init C (Val v₁ «bop» e); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (Val v₁ «bop» e') ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋)› 11. ‹⋀bop v₁ v₂ v a aa b ba. ⟦binop (bop, v₁, v₂) = ⌊v⌋; not_init C (Val v₁ «bop» Val v₂); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (Val v) ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 12. ‹⋀l V v h sh b. ⟦l V = ⌊v⌋; not_init C (Var V); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (Val v) ∧ (∃sfs'. sh C = ⌊(sfs', Processing)⌋)› 13. ‹⋀e a aa b ba e' ab ac bb b' V. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⟦not_init C e; b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C e' ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋); not_init C (V:=e); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (V:=e') ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋)› 14. ‹⋀V v h l sh b. ⟦not_init C (V:=Val v); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C unit ∧ (∃sfs'. sh C = ⌊(sfs', Processing)⌋)› 15. ‹⋀e a aa b ba e' ab ac bb b' F D. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⟦not_init C e; b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C e' ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋); not_init C (e∙F{D}); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (e'∙F{D}) ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋)› 16. ‹⋀h a Ca fs F D v t l sh b. ⟦h a = ⌊(Ca, fs)⌋; fs (F, D) = ⌊v⌋; P ⊢ Ca has F,NonStatic:t in D; not_init C (addr a∙F{D}); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (Val v) ∧ (∃sfs'. sh C = ⌊(sfs', Processing)⌋)› 17. ‹⋀F D a aa b ba. ⟦not_init C (null∙F{D}); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (THROW NullPointer) ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 18. ‹⋀h a Ca fs F D l sh b. ⟦h a = ⌊(Ca, fs)⌋; ∄b t. P ⊢ Ca has F,b:t in D; not_init C (addr a∙F{D}); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (THROW NoSuchFieldError) ∧ (∃sfs'. sh C = ⌊(sfs', Processing)⌋)› 19. ‹⋀h a Ca fs F t D l sh b. ⟦h a = ⌊(Ca, fs)⌋; P ⊢ Ca has F,Static:t in D; not_init C (addr a∙F{D}); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (THROW IncompatibleClassChangeError) ∧ (∃sfs'. sh C = ⌊(sfs', Processing)⌋)› 20. ‹⋀Ca F t D sh sfsa i v h l. ⟦P ⊢ Ca has F,Static:t in D; sh D = ⌊(sfsa, i)⌋; sfsa F = ⌊v⌋; not_init C (Ca∙⇩sF{D}); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (Val v) ∧ (∃sfs'. sh C = ⌊(sfs', Processing)⌋)› 21. ‹⋀Ca F t D sh sfsa h l. ⟦P ⊢ Ca has F,Static:t in D; sh D = ⌊(sfsa, Done)⌋; not_init C (Ca∙⇩sF{D}); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (Ca∙⇩sF{D}) ∧ (∃sfs'. sh C = ⌊(sfs', Processing)⌋)› 22. ‹⋀Ca F t D sh h l. ⟦P ⊢ Ca has F,Static:t in D; ∄sfs. sh D = ⌊(sfs, Done)⌋; not_init C (Ca∙⇩sF{D}); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (INIT D ([D],False) ← Ca∙⇩sF{D}) ∧ (∃sfs'. sh C = ⌊(sfs', Processing)⌋)› 23. ‹⋀Ca F D h l sh b. ⟦∄b t. P ⊢ Ca has F,b:t in D; not_init C (Ca∙⇩sF{D}); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (THROW NoSuchFieldError) ∧ (∃sfs'. sh C = ⌊(sfs', Processing)⌋)› 24. ‹⋀Ca F t D h l sh b. ⟦P ⊢ Ca has F,NonStatic:t in D; not_init C (Ca∙⇩sF{D}); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (THROW IncompatibleClassChangeError) ∧ (∃sfs'. sh C = ⌊(sfs', Processing)⌋)› 25. ‹⋀e a aa b ba e' ab ac bb b' F D e₂. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⟦not_init C e; b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C e' ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋); not_init C (e∙F{D} := e₂); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (e'∙F{D} := e₂) ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋)› 26. ‹⋀e a aa b ba e' ab ac bb b' v F D. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⟦not_init C e; b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C e' ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋); not_init C (Val v∙F{D} := e); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (Val v∙F{D} := e') ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋)› 27. ‹⋀Ca F t D h a fs v l sh b. ⟦P ⊢ Ca has F,NonStatic:t in D; h a = ⌊(Ca, fs)⌋; not_init C (addr a∙F{D} := Val v); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C unit ∧ (∃sfs'. sh C = ⌊(sfs', Processing)⌋)› 28. ‹⋀F D v a aa b ba. ⟦not_init C (null∙F{D} := Val v); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (THROW NullPointer) ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 29. ‹⋀h a Ca fs F D v l sh b. ⟦h a = ⌊(Ca, fs)⌋; ∄b t. P ⊢ Ca has F,b:t in D; not_init C (addr a∙F{D} := Val v); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (THROW NoSuchFieldError) ∧ (∃sfs'. sh C = ⌊(sfs', Processing)⌋)› 30. ‹⋀h a Ca fs F t D v l sh b. ⟦h a = ⌊(Ca, fs)⌋; P ⊢ Ca has F,Static:t in D; not_init C (addr a∙F{D} := Val v); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (THROW IncompatibleClassChangeError) ∧ (∃sfs'. sh C = ⌊(sfs', Processing)⌋)› 31. ‹⋀e a aa b ba e' ab ac bb b' Ca F D. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⟦not_init C e; b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C e' ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋); not_init C (Ca∙⇩sF{D} := e); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (Ca∙⇩sF{D} := e') ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋)› 32. ‹⋀Ca F t D sh sfsa i sfs' v sh' h l. ⟦P ⊢ Ca has F,Static:t in D; sh D = ⌊(sfsa, i)⌋; sfs' = sfsa(F ↦ v); sh' = sh(D ↦ (sfs', i)); not_init C (Ca∙⇩sF{D} := Val v); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C unit ∧ (∃sfs'. sh' C = ⌊(sfs', Processing)⌋)› 33. ‹⋀Ca F t D sh sfsa v h l. ⟦P ⊢ Ca has F,Static:t in D; sh D = ⌊(sfsa, Done)⌋; not_init C (Ca∙⇩sF{D} := Val v); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (Ca∙⇩sF{D} := Val v) ∧ (∃sfs'. sh C = ⌊(sfs', Processing)⌋)› 34. ‹⋀Ca F t D sh v h l. ⟦P ⊢ Ca has F,Static:t in D; ∄sfs. sh D = ⌊(sfs, Done)⌋; not_init C (Ca∙⇩sF{D} := Val v); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (INIT D ([D],False) ← Ca∙⇩sF{D} := Val v) ∧ (∃sfs'. sh C = ⌊(sfs', Processing)⌋)› 35. ‹⋀Ca F D v a aa b ba. ⟦∄b t. P ⊢ Ca has F,b:t in D; not_init C (Ca∙⇩sF{D} := Val v); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (THROW NoSuchFieldError) ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 36. ‹⋀Ca F t D v a aa b ba. ⟦P ⊢ Ca has F,NonStatic:t in D; not_init C (Ca∙⇩sF{D} := Val v); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (THROW IncompatibleClassChangeError) ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 37. ‹⋀e a aa b ba e' ab ac bb b' M es. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⟦not_init C e; b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C e' ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋); not_init C (e∙M(es)); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (e'∙M(es)) ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋)› 38. ‹⋀es a aa b ba es' ab ac bb b' v M. ⟦P ⊢ ⟨es,(a, aa, b),ba⟩ [→] ⟨es',(ab, ac, bb),b'⟩; ⟦not_inits C es; b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_inits C es' ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋); not_init C (Val v∙M(es)); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (Val v∙M(es')) ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋)› 39. ‹⋀M vs a aa b ba. ⟦not_init C (null∙M(map Val vs)); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (THROW NullPointer) ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 40. ‹⋀h a Ca fs M vs l sh b. ⟦h a = ⌊(Ca, fs)⌋; ∄b Ts T m D. P ⊢ Ca sees M, b : Ts→T = m in D; not_init C (addr a∙M(map Val vs)); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (THROW NoSuchMethodError) ∧ (∃sfs'. sh C = ⌊(sfs', Processing)⌋)› 41. ‹⋀h a Ca fs M Ts T aa b D vs l sh ba. ⟦h a = ⌊(Ca, fs)⌋; P ⊢ Ca sees M, Static : Ts→T = (aa, b) in D; not_init C (addr a∙M(map Val vs)); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (THROW IncompatibleClassChangeError) ∧ (∃sfs'. sh C = ⌊(sfs', Processing)⌋)› 42. ‹⋀es a aa b ba es' ab ac bb b' Ca M. ⟦P ⊢ ⟨es,(a, aa, b),ba⟩ [→] ⟨es',(ab, ac, bb),b'⟩; ⟦not_inits C es; b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_inits C es' ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋); not_init C (Ca∙⇩sM(es)); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (Ca∙⇩sM(es')) ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋)› 43. ‹⋀Ca M Ts T pns body D vs a aa b. ⟦P ⊢ Ca sees M, Static : Ts→T = (pns, body) in D; length vs = length pns; length Ts = length pns; not_init C (Ca∙⇩sM(map Val vs)); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (blocks (pns, Ts, vs, body)) ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 44. ‹⋀Ca M Ts T pns body D sh sfsa vs h l. ⟦P ⊢ Ca sees M, Static : Ts→T = (pns, body) in D; sh D = ⌊(sfsa, Done)⌋ ∨ M = clinit ∧ sh D = ⌊(sfsa, Processing)⌋; not_init C (Ca∙⇩sM(map Val vs)); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (Ca∙⇩sM(map Val vs)) ∧ (∃sfs'. sh C = ⌊(sfs', Processing)⌋)› 45. ‹⋀Ca M Ts T pns body D sh vs h l. ⟦P ⊢ Ca sees M, Static : Ts→T = (pns, body) in D; ∄sfs. sh D = ⌊(sfs, Done)⌋; M ≠ clinit; not_init C (Ca∙⇩sM(map Val vs)); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (INIT D ([D],False) ← Ca∙⇩sM(map Val vs)) ∧ (∃sfs'. sh C = ⌊(sfs', Processing)⌋)› 46. ‹⋀Ca M vs a aa b ba. ⟦∄b Ts T m. Ex (Method P Ca M b Ts T m); not_init C (Ca∙⇩sM(map Val vs)); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (THROW NoSuchMethodError) ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 47. ‹⋀Ca M Ts T a b D vs aa ab ba bb. ⟦P ⊢ Ca sees M, NonStatic : Ts→T = (a, b) in D; not_init C (Ca∙⇩sM(map Val vs)); ba C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (THROW IncompatibleClassChangeError) ∧ (∃sfs'. ba C = ⌊(sfs', Processing)⌋)› 48. ‹⋀e h l V sh b e' h' l' sh' b' T. ⟦P ⊢ ⟨e,(h, l(V := None), sh),b⟩ → ⟨e',(h', l', sh'),b'⟩; ⟦not_init C e; sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C e' ∧ (∃sfs'. sh' C = ⌊(sfs', Processing)⌋); l' V = None; ¬ assigned V e; not_init C {V:T; e}; sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C {V:T; e'} ∧ (∃sfs'. sh' C = ⌊(sfs', Processing)⌋)› 49. ‹⋀e h l V sh b e' h' l' sh' b' v T. ⟦P ⊢ ⟨e,(h, l(V := None), sh),b⟩ → ⟨e',(h', l', sh'),b'⟩; ⟦not_init C e; sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C e' ∧ (∃sfs'. sh' C = ⌊(sfs', Processing)⌋); l' V = ⌊v⌋; ¬ assigned V e; not_init C {V:T; e}; sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C {V:T; V:=Val v;; e'} ∧ (∃sfs'. sh' C = ⌊(sfs', Processing)⌋)› 50. ‹⋀e h l V v sh b e' h' l' sh' b' v' T. ⟦P ⊢ ⟨e,(h, l(V ↦ v), sh),b⟩ → ⟨e',(h', l', sh'),b'⟩; ⟦not_init C e; sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C e' ∧ (∃sfs'. sh' C = ⌊(sfs', Processing)⌋); l' V = ⌊v'⌋; not_init C {V:T; V:=Val v;; e}; sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C {V:T; V:=Val v';; e'} ∧ (∃sfs'. sh' C = ⌊(sfs', Processing)⌋)› 51. ‹⋀V T u a aa b ba. ⟦not_init C {V:T; Val u}; b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (Val u) ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 52. ‹⋀V T v u a aa b ba. ⟦not_init C {V:T; V:=Val v;; Val u}; b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (Val u) ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 53. ‹⋀e a aa b ba e' ab ac bb b' e₂. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⟦not_init C e; b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C e' ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋); not_init C (e;; e₂); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (e';; e₂) ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋)› 54. ‹⋀v e₂ a aa b ba. ⟦not_init C (Val v;; e₂); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C e₂ ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 55. ‹⋀e a aa b ba e' ab ac bb b' e₁ e₂. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⟦not_init C e; b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C e' ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋); not_init C (if (e) e₁ else e₂); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (if (e') e₁ else e₂) ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋)› 56. ‹⋀e₁ e₂ a aa b ba. ⟦not_init C (if (true) e₁ else e₂); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C e₁ ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 57. ‹⋀e₁ e₂ a aa b ba. ⟦not_init C (if (false) e₁ else e₂); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C e₂ ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 58. ‹⋀b c a aa ba b'. ⟦not_init C (while (b) c); ba C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (if (b) (c;; while (b) c) else unit) ∧ (∃sfs'. ba C = ⌊(sfs', Processing)⌋)› 59. ‹⋀e a aa b ba e' ab ac bb b'. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⟦not_init C e; b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C e' ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋); not_init C (throw e); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (throw e') ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋)› 60. ‹⋀a aa b ba. ⟦not_init C (throw null); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (THROW NullPointer) ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 61. ‹⋀e a aa b ba e' ab ac bb b' Ca V e₂. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⟦not_init C e; b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C e' ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋); not_init C (try e catch(Ca V) e₂); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (try e' catch(Ca V) e₂) ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋)› 62. ‹⋀v Ca V e₂ a aa b ba. ⟦not_init C (try Val v catch(Ca V) e₂); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (Val v) ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 63. ‹⋀a aa b ab D fs Ca V e₂ ba. ⟦hp (a, aa, b) ab = ⌊(D, fs)⌋; P ⊢ D ≼⇧* Ca; not_init C (try Throw ab catch(Ca V) e₂); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C {V:Class Ca; V:=addr ab;; e₂} ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 64. ‹⋀a aa b ab D fs Ca V e₂ ba. ⟦hp (a, aa, b) ab = ⌊(D, fs)⌋; (D, Ca) ∉ (subcls1 P)⇧*; not_init C (try Throw ab catch(Ca V) e₂); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (Throw ab) ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 65. ‹⋀e a aa b ba e' ab ac bb b' es. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⟦not_init C e; b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C e' ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋); not_inits C (e # es); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_inits C (e' # es) ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋)› 66. ‹⋀es a aa b ba es' ab ac bb b' v. ⟦P ⊢ ⟨es,(a, aa, b),ba⟩ [→] ⟨es',(ab, ac, bb),b'⟩; ⟦not_inits C es; b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_inits C es' ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋); not_inits C (Val v # es); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_inits C (Val v # es') ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋)› 67. ‹⋀e Ca b a aa ba b'. ⟦¬ sub_RI e; not_init C (INIT Ca ([],b) ← e); ba C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C e ∧ (∃sfs'. ba C = ⌊(sfs', Processing)⌋)› 68. ‹⋀sh Ca C' Cs e h l b. ⟦sh Ca = None; not_init C (INIT C' (Ca # Cs,False) ← e); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (INIT C' (Ca # Cs,False) ← e) ∧ (∃sfs'. (sh(Ca ↦ (sblank P Ca, Prepared))) C = ⌊(sfs', Processing)⌋)› 69. ‹⋀sh Ca sfsa C' Cs e h l b. ⟦sh Ca = ⌊(sfsa, Done)⌋; not_init C (INIT C' (Ca # Cs,False) ← e); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (INIT C' (Cs,True) ← e) ∧ (∃sfs'. sh C = ⌊(sfs', Processing)⌋)› 70. ‹⋀sh Ca sfsa C' Cs e h l b. ⟦sh Ca = ⌊(sfsa, Processing)⌋; not_init C (INIT C' (Ca # Cs,False) ← e); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (INIT C' (Cs,True) ← e) ∧ (∃sfs'. sh C = ⌊(sfs', Processing)⌋)› 71. ‹⋀sh Ca sfsa C' Cs e h l b. ⟦sh Ca = ⌊(sfsa, Error)⌋; not_init C (INIT C' (Ca # Cs,False) ← e); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (RI (Ca,THROW NoClassDefFoundError) ; Cs ← e) ∧ (∃sfs'. sh C = ⌊(sfs', Processing)⌋)› 72. ‹⋀sh Ca sfsa sh' C' Cs e h l b. ⟦sh Ca = ⌊(sfsa, Prepared)⌋; Ca = Object; sh' = sh(Ca ↦ (sfsa, Processing)); not_init C (INIT C' (Ca # Cs,False) ← e); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (INIT C' (Ca # Cs,True) ← e) ∧ (∃sfs'. sh' C = ⌊(sfs', Processing)⌋)› 73. ‹⋀sh Ca sfsa D a b sh' C' Cs e h l ba. ⟦sh Ca = ⌊(sfsa, Prepared)⌋; Ca ≠ Object; class P Ca = ⌊(D, a, b)⌋; sh' = sh(Ca ↦ (sfsa, Processing)); not_init C (INIT C' (Ca # Cs,False) ← e); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (INIT C' (D # Ca # Cs,False) ← e) ∧ (∃sfs'. sh' C = ⌊(sfs', Processing)⌋)› 74. ‹⋀C' Ca Cs e h l sh b. ⟦not_init C (INIT C' (Ca # Cs,True) ← e); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (RI (Ca,Ca∙⇩sclinit([])) ; Cs ← e) ∧ (∃sfs'. sh C = ⌊(sfs', Processing)⌋)› 75. ‹⋀e a aa b ba e' ab ac bb b' Ca Cs e₀. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⟦not_init C e; b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C e' ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋); not_init C (RI (Ca,e) ; Cs ← e₀); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (RI (Ca,e') ; Cs ← e₀) ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋)› 76. ‹⋀sh Ca sfsa i sh' C' Cs v e h l b. ⟦sh Ca = ⌊(sfsa, i)⌋; sh' = sh(Ca ↦ (sfsa, Done)); C' = last (Ca # Cs); not_init C (RI (Ca,Val v) ; Cs ← e); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (INIT C' (Cs,True) ← e) ∧ (∃sfs'. sh' C = ⌊(sfs', Processing)⌋)› 77. ‹⋀Ca e a aa b ba. ⟦not_init C (Cast Ca (throw e)); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (throw e) ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 78. ‹⋀e bop e₂ a aa b ba. ⟦not_init C (throw e «bop» e₂); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (throw e) ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 79. ‹⋀v₁ bop e a aa b ba. ⟦not_init C (Val v₁ «bop» throw e); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (throw e) ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 80. ‹⋀V e a aa b ba. ⟦not_init C (V:=throw e); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (throw e) ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 81. ‹⋀e F D a aa b ba. ⟦not_init C (throw e∙F{D}); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (throw e) ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 82. ‹⋀e F D e₂ a aa b ba. ⟦not_init C (throw e∙F{D} := e₂); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (throw e) ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 83. ‹⋀v F D e a aa b ba. ⟦not_init C (Val v∙F{D} := throw e); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (throw e) ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 84. ‹⋀Ca F D e a aa b ba. ⟦not_init C (Ca∙⇩sF{D} := throw e); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (throw e) ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 85. ‹⋀e M es a aa b ba. ⟦not_init C (throw e∙M(es)); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (throw e) ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 86. ‹⋀es vs e es' v M a aa b ba. ⟦es = map Val vs @ throw e # es'; not_init C (Val v∙M(es)); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (throw e) ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 87. ‹⋀es vs e es' Ca M a aa b ba. ⟦es = map Val vs @ throw e # es'; not_init C (Ca∙⇩sM(es)); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (throw e) ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 88. ‹⋀V T a aa ab b ba. ⟦not_init C {V:T; Throw a}; b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (Throw a) ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 89. ‹⋀V T v a aa ab b ba. ⟦not_init C {V:T; V:=Val v;; Throw a}; b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (Throw a) ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 90. ‹⋀e e₂ a aa b ba. ⟦not_init C (throw e;; e₂); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (throw e) ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 91. ‹⋀e e₁ e₂ a aa b ba. ⟦not_init C (if (throw e) e₁ else e₂); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (throw e) ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 92. ‹⋀e a aa b ba. ⟦not_init C (throw (throw e)); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (throw e) ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 93. ‹⋀sh Ca sfsa i sh' a D Cs e h l b. ⟦sh Ca = ⌊(sfsa, i)⌋; sh' = sh(Ca ↦ (sfsa, Error)); not_init C (RI (Ca,Throw a) ; D # Cs ← e); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (RI (D,Throw a) ; Cs ← e) ∧ (∃sfs'. sh' C = ⌊(sfs', Processing)⌋)› 94. ‹⋀sh Ca sfsa i sh' a e h l b. ⟦sh Ca = ⌊(sfsa, i)⌋; sh' = sh(Ca ↦ (sfsa, Error)); not_init C (RI (Ca,Throw a) ; [] ← e); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (Throw a) ∧ (∃sfs'. sh' C = ⌊(sfs', Processing)⌋)›*) case RedSCall (*‹(P::(char list list × char list exp) prog) ⊢ (C_::char list) sees (M_::char list), Static : (Ts_::ty list)→(T_::ty) = (pns_::char list list, body_::char list exp) in (D_::char list)› ‹length vs_ = length pns_› ‹length Ts_ = length pns_› ‹not_init C (C_∙⇩sM_(map Val vs_))› ‹b_ C = ⌊(sfs, Processing)⌋›*) then show "?case" (*goal: ‹not_init C (blocks (pns_, Ts_, vs_, body_)) ∧ (∃sfs'. b_ C = ⌊(sfs', Processing)⌋)›*) using sees_wwf_nsub_RI[OF wf RedSCall.hyps ( 1 )] (*‹¬ sub_RI (body_::char list exp)›*) sub_RI_blocks_body (*‹⟦length ?vs = length ?pns; length ?Ts = length ?pns⟧ ⟹ sub_RI (blocks (?pns, ?Ts, ?vs, ?body)) = sub_RI ?body›*) nsub_RI_not_init (*‹¬ sub_RI ?e ⟹ not_init ?C ?e›*) by auto next (*goals: 1. ‹⋀h a Ca FDTs h' l sh. ⟦new_Addr h = ⌊a⌋; P ⊢ Ca has_fields FDTs; h' = h(a ↦ blank P Ca); not_init C (new Ca); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (addr a) ∧ (∃sfs'. sh C = ⌊(sfs', Processing)⌋)› 2. ‹⋀h Ca l sh. ⟦new_Addr h = None; is_class P Ca; not_init C (new Ca); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (THROW OutOfMemory) ∧ (∃sfs'. sh C = ⌊(sfs', Processing)⌋)› 3. ‹⋀sh Ca sfsa h l. ⟦sh Ca = ⌊(sfsa, Done)⌋; not_init C (new Ca); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (new Ca) ∧ (∃sfs'. sh C = ⌊(sfs', Processing)⌋)› 4. ‹⋀sh Ca h l. ⟦∄sfs. sh Ca = ⌊(sfs, Done)⌋; is_class P Ca; not_init C (new Ca); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (INIT Ca ([Ca],False) ← new Ca) ∧ (∃sfs'. sh C = ⌊(sfs', Processing)⌋)› 5. ‹⋀e a aa b ba e' ab ac bb b' Ca. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⟦not_init C e; b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C e' ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋); not_init C (Cast Ca e); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (Cast Ca e') ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋)› 6. ‹⋀Ca a aa b ba. ⟦not_init C (Cast Ca null); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C null ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 7. ‹⋀h a D fs Ca l sh b. ⟦h a = ⌊(D, fs)⌋; P ⊢ D ≼⇧* Ca; not_init C (Cast Ca (addr a)); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (addr a) ∧ (∃sfs'. sh C = ⌊(sfs', Processing)⌋)› 8. ‹⋀h a D fs Ca l sh b. ⟦h a = ⌊(D, fs)⌋; (D, Ca) ∉ (subcls1 P)⇧*; not_init C (Cast Ca (addr a)); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (THROW ClassCast) ∧ (∃sfs'. sh C = ⌊(sfs', Processing)⌋)› 9. ‹⋀e a aa b ba e' ab ac bb b' bop e₂. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⟦not_init C e; b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C e' ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋); not_init C (e «bop» e₂); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (e' «bop» e₂) ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋)› 10. ‹⋀e a aa b ba e' ab ac bb b' v₁ bop. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⟦not_init C e; b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C e' ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋); not_init C (Val v₁ «bop» e); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (Val v₁ «bop» e') ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋)› 11. ‹⋀bop v₁ v₂ v a aa b ba. ⟦binop (bop, v₁, v₂) = ⌊v⌋; not_init C (Val v₁ «bop» Val v₂); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (Val v) ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 12. ‹⋀l V v h sh b. ⟦l V = ⌊v⌋; not_init C (Var V); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (Val v) ∧ (∃sfs'. sh C = ⌊(sfs', Processing)⌋)› 13. ‹⋀e a aa b ba e' ab ac bb b' V. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⟦not_init C e; b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C e' ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋); not_init C (V:=e); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (V:=e') ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋)› 14. ‹⋀V v h l sh b. ⟦not_init C (V:=Val v); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C unit ∧ (∃sfs'. sh C = ⌊(sfs', Processing)⌋)› 15. ‹⋀e a aa b ba e' ab ac bb b' F D. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⟦not_init C e; b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C e' ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋); not_init C (e∙F{D}); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (e'∙F{D}) ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋)› 16. ‹⋀h a Ca fs F D v t l sh b. ⟦h a = ⌊(Ca, fs)⌋; fs (F, D) = ⌊v⌋; P ⊢ Ca has F,NonStatic:t in D; not_init C (addr a∙F{D}); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (Val v) ∧ (∃sfs'. sh C = ⌊(sfs', Processing)⌋)› 17. ‹⋀F D a aa b ba. ⟦not_init C (null∙F{D}); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (THROW NullPointer) ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 18. ‹⋀h a Ca fs F D l sh b. ⟦h a = ⌊(Ca, fs)⌋; ∄b t. P ⊢ Ca has F,b:t in D; not_init C (addr a∙F{D}); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (THROW NoSuchFieldError) ∧ (∃sfs'. sh C = ⌊(sfs', Processing)⌋)› 19. ‹⋀h a Ca fs F t D l sh b. ⟦h a = ⌊(Ca, fs)⌋; P ⊢ Ca has F,Static:t in D; not_init C (addr a∙F{D}); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (THROW IncompatibleClassChangeError) ∧ (∃sfs'. sh C = ⌊(sfs', Processing)⌋)› 20. ‹⋀Ca F t D sh sfsa i v h l. ⟦P ⊢ Ca has F,Static:t in D; sh D = ⌊(sfsa, i)⌋; sfsa F = ⌊v⌋; not_init C (Ca∙⇩sF{D}); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (Val v) ∧ (∃sfs'. sh C = ⌊(sfs', Processing)⌋)› 21. ‹⋀Ca F t D sh sfsa h l. ⟦P ⊢ Ca has F,Static:t in D; sh D = ⌊(sfsa, Done)⌋; not_init C (Ca∙⇩sF{D}); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (Ca∙⇩sF{D}) ∧ (∃sfs'. sh C = ⌊(sfs', Processing)⌋)› 22. ‹⋀Ca F t D sh h l. ⟦P ⊢ Ca has F,Static:t in D; ∄sfs. sh D = ⌊(sfs, Done)⌋; not_init C (Ca∙⇩sF{D}); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (INIT D ([D],False) ← Ca∙⇩sF{D}) ∧ (∃sfs'. sh C = ⌊(sfs', Processing)⌋)› 23. ‹⋀Ca F D h l sh b. ⟦∄b t. P ⊢ Ca has F,b:t in D; not_init C (Ca∙⇩sF{D}); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (THROW NoSuchFieldError) ∧ (∃sfs'. sh C = ⌊(sfs', Processing)⌋)› 24. ‹⋀Ca F t D h l sh b. ⟦P ⊢ Ca has F,NonStatic:t in D; not_init C (Ca∙⇩sF{D}); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (THROW IncompatibleClassChangeError) ∧ (∃sfs'. sh C = ⌊(sfs', Processing)⌋)› 25. ‹⋀e a aa b ba e' ab ac bb b' F D e₂. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⟦not_init C e; b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C e' ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋); not_init C (e∙F{D} := e₂); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (e'∙F{D} := e₂) ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋)› 26. ‹⋀e a aa b ba e' ab ac bb b' v F D. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⟦not_init C e; b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C e' ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋); not_init C (Val v∙F{D} := e); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (Val v∙F{D} := e') ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋)› 27. ‹⋀Ca F t D h a fs v l sh b. ⟦P ⊢ Ca has F,NonStatic:t in D; h a = ⌊(Ca, fs)⌋; not_init C (addr a∙F{D} := Val v); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C unit ∧ (∃sfs'. sh C = ⌊(sfs', Processing)⌋)› 28. ‹⋀F D v a aa b ba. ⟦not_init C (null∙F{D} := Val v); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (THROW NullPointer) ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 29. ‹⋀h a Ca fs F D v l sh b. ⟦h a = ⌊(Ca, fs)⌋; ∄b t. P ⊢ Ca has F,b:t in D; not_init C (addr a∙F{D} := Val v); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (THROW NoSuchFieldError) ∧ (∃sfs'. sh C = ⌊(sfs', Processing)⌋)› 30. ‹⋀h a Ca fs F t D v l sh b. ⟦h a = ⌊(Ca, fs)⌋; P ⊢ Ca has F,Static:t in D; not_init C (addr a∙F{D} := Val v); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (THROW IncompatibleClassChangeError) ∧ (∃sfs'. sh C = ⌊(sfs', Processing)⌋)› 31. ‹⋀e a aa b ba e' ab ac bb b' Ca F D. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⟦not_init C e; b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C e' ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋); not_init C (Ca∙⇩sF{D} := e); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (Ca∙⇩sF{D} := e') ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋)› 32. ‹⋀Ca F t D sh sfsa i sfs' v sh' h l. ⟦P ⊢ Ca has F,Static:t in D; sh D = ⌊(sfsa, i)⌋; sfs' = sfsa(F ↦ v); sh' = sh(D ↦ (sfs', i)); not_init C (Ca∙⇩sF{D} := Val v); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C unit ∧ (∃sfs'. sh' C = ⌊(sfs', Processing)⌋)› 33. ‹⋀Ca F t D sh sfsa v h l. ⟦P ⊢ Ca has F,Static:t in D; sh D = ⌊(sfsa, Done)⌋; not_init C (Ca∙⇩sF{D} := Val v); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (Ca∙⇩sF{D} := Val v) ∧ (∃sfs'. sh C = ⌊(sfs', Processing)⌋)› 34. ‹⋀Ca F t D sh v h l. ⟦P ⊢ Ca has F,Static:t in D; ∄sfs. sh D = ⌊(sfs, Done)⌋; not_init C (Ca∙⇩sF{D} := Val v); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (INIT D ([D],False) ← Ca∙⇩sF{D} := Val v) ∧ (∃sfs'. sh C = ⌊(sfs', Processing)⌋)› 35. ‹⋀Ca F D v a aa b ba. ⟦∄b t. P ⊢ Ca has F,b:t in D; not_init C (Ca∙⇩sF{D} := Val v); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (THROW NoSuchFieldError) ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 36. ‹⋀Ca F t D v a aa b ba. ⟦P ⊢ Ca has F,NonStatic:t in D; not_init C (Ca∙⇩sF{D} := Val v); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (THROW IncompatibleClassChangeError) ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 37. ‹⋀e a aa b ba e' ab ac bb b' M es. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⟦not_init C e; b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C e' ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋); not_init C (e∙M(es)); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (e'∙M(es)) ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋)› 38. ‹⋀es a aa b ba es' ab ac bb b' v M. ⟦P ⊢ ⟨es,(a, aa, b),ba⟩ [→] ⟨es',(ab, ac, bb),b'⟩; ⟦not_inits C es; b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_inits C es' ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋); not_init C (Val v∙M(es)); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (Val v∙M(es')) ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋)› 39. ‹⋀M vs a aa b ba. ⟦not_init C (null∙M(map Val vs)); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (THROW NullPointer) ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 40. ‹⋀h a Ca fs M vs l sh b. ⟦h a = ⌊(Ca, fs)⌋; ∄b Ts T m D. P ⊢ Ca sees M, b : Ts→T = m in D; not_init C (addr a∙M(map Val vs)); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (THROW NoSuchMethodError) ∧ (∃sfs'. sh C = ⌊(sfs', Processing)⌋)› 41. ‹⋀h a Ca fs M Ts T aa b D vs l sh ba. ⟦h a = ⌊(Ca, fs)⌋; P ⊢ Ca sees M, Static : Ts→T = (aa, b) in D; not_init C (addr a∙M(map Val vs)); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (THROW IncompatibleClassChangeError) ∧ (∃sfs'. sh C = ⌊(sfs', Processing)⌋)› 42. ‹⋀es a aa b ba es' ab ac bb b' Ca M. ⟦P ⊢ ⟨es,(a, aa, b),ba⟩ [→] ⟨es',(ab, ac, bb),b'⟩; ⟦not_inits C es; b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_inits C es' ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋); not_init C (Ca∙⇩sM(es)); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (Ca∙⇩sM(es')) ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋)› 43. ‹⋀Ca M Ts T pns body D sh sfsa vs h l. ⟦P ⊢ Ca sees M, Static : Ts→T = (pns, body) in D; sh D = ⌊(sfsa, Done)⌋ ∨ M = clinit ∧ sh D = ⌊(sfsa, Processing)⌋; not_init C (Ca∙⇩sM(map Val vs)); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (Ca∙⇩sM(map Val vs)) ∧ (∃sfs'. sh C = ⌊(sfs', Processing)⌋)› 44. ‹⋀Ca M Ts T pns body D sh vs h l. ⟦P ⊢ Ca sees M, Static : Ts→T = (pns, body) in D; ∄sfs. sh D = ⌊(sfs, Done)⌋; M ≠ clinit; not_init C (Ca∙⇩sM(map Val vs)); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (INIT D ([D],False) ← Ca∙⇩sM(map Val vs)) ∧ (∃sfs'. sh C = ⌊(sfs', Processing)⌋)› 45. ‹⋀Ca M vs a aa b ba. ⟦∄b Ts T m. Ex (Method P Ca M b Ts T m); not_init C (Ca∙⇩sM(map Val vs)); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (THROW NoSuchMethodError) ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 46. ‹⋀Ca M Ts T a b D vs aa ab ba bb. ⟦P ⊢ Ca sees M, NonStatic : Ts→T = (a, b) in D; not_init C (Ca∙⇩sM(map Val vs)); ba C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (THROW IncompatibleClassChangeError) ∧ (∃sfs'. ba C = ⌊(sfs', Processing)⌋)› 47. ‹⋀e h l V sh b e' h' l' sh' b' T. ⟦P ⊢ ⟨e,(h, l(V := None), sh),b⟩ → ⟨e',(h', l', sh'),b'⟩; ⟦not_init C e; sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C e' ∧ (∃sfs'. sh' C = ⌊(sfs', Processing)⌋); l' V = None; ¬ assigned V e; not_init C {V:T; e}; sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C {V:T; e'} ∧ (∃sfs'. sh' C = ⌊(sfs', Processing)⌋)› 48. ‹⋀e h l V sh b e' h' l' sh' b' v T. ⟦P ⊢ ⟨e,(h, l(V := None), sh),b⟩ → ⟨e',(h', l', sh'),b'⟩; ⟦not_init C e; sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C e' ∧ (∃sfs'. sh' C = ⌊(sfs', Processing)⌋); l' V = ⌊v⌋; ¬ assigned V e; not_init C {V:T; e}; sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C {V:T; V:=Val v;; e'} ∧ (∃sfs'. sh' C = ⌊(sfs', Processing)⌋)› 49. ‹⋀e h l V v sh b e' h' l' sh' b' v' T. ⟦P ⊢ ⟨e,(h, l(V ↦ v), sh),b⟩ → ⟨e',(h', l', sh'),b'⟩; ⟦not_init C e; sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C e' ∧ (∃sfs'. sh' C = ⌊(sfs', Processing)⌋); l' V = ⌊v'⌋; not_init C {V:T; V:=Val v;; e}; sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C {V:T; V:=Val v';; e'} ∧ (∃sfs'. sh' C = ⌊(sfs', Processing)⌋)› 50. ‹⋀V T u a aa b ba. ⟦not_init C {V:T; Val u}; b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (Val u) ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 51. ‹⋀V T v u a aa b ba. ⟦not_init C {V:T; V:=Val v;; Val u}; b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (Val u) ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 52. ‹⋀e a aa b ba e' ab ac bb b' e₂. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⟦not_init C e; b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C e' ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋); not_init C (e;; e₂); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (e';; e₂) ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋)› 53. ‹⋀v e₂ a aa b ba. ⟦not_init C (Val v;; e₂); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C e₂ ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 54. ‹⋀e a aa b ba e' ab ac bb b' e₁ e₂. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⟦not_init C e; b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C e' ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋); not_init C (if (e) e₁ else e₂); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (if (e') e₁ else e₂) ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋)› 55. ‹⋀e₁ e₂ a aa b ba. ⟦not_init C (if (true) e₁ else e₂); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C e₁ ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 56. ‹⋀e₁ e₂ a aa b ba. ⟦not_init C (if (false) e₁ else e₂); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C e₂ ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 57. ‹⋀b c a aa ba b'. ⟦not_init C (while (b) c); ba C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (if (b) (c;; while (b) c) else unit) ∧ (∃sfs'. ba C = ⌊(sfs', Processing)⌋)› 58. ‹⋀e a aa b ba e' ab ac bb b'. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⟦not_init C e; b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C e' ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋); not_init C (throw e); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (throw e') ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋)› 59. ‹⋀a aa b ba. ⟦not_init C (throw null); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (THROW NullPointer) ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 60. ‹⋀e a aa b ba e' ab ac bb b' Ca V e₂. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⟦not_init C e; b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C e' ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋); not_init C (try e catch(Ca V) e₂); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (try e' catch(Ca V) e₂) ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋)› 61. ‹⋀v Ca V e₂ a aa b ba. ⟦not_init C (try Val v catch(Ca V) e₂); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (Val v) ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 62. ‹⋀a aa b ab D fs Ca V e₂ ba. ⟦hp (a, aa, b) ab = ⌊(D, fs)⌋; P ⊢ D ≼⇧* Ca; not_init C (try Throw ab catch(Ca V) e₂); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C {V:Class Ca; V:=addr ab;; e₂} ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 63. ‹⋀a aa b ab D fs Ca V e₂ ba. ⟦hp (a, aa, b) ab = ⌊(D, fs)⌋; (D, Ca) ∉ (subcls1 P)⇧*; not_init C (try Throw ab catch(Ca V) e₂); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (Throw ab) ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 64. ‹⋀e a aa b ba e' ab ac bb b' es. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⟦not_init C e; b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C e' ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋); not_inits C (e # es); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_inits C (e' # es) ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋)› 65. ‹⋀es a aa b ba es' ab ac bb b' v. ⟦P ⊢ ⟨es,(a, aa, b),ba⟩ [→] ⟨es',(ab, ac, bb),b'⟩; ⟦not_inits C es; b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_inits C es' ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋); not_inits C (Val v # es); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_inits C (Val v # es') ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋)› 66. ‹⋀e Ca b a aa ba b'. ⟦¬ sub_RI e; not_init C (INIT Ca ([],b) ← e); ba C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C e ∧ (∃sfs'. ba C = ⌊(sfs', Processing)⌋)› 67. ‹⋀sh Ca C' Cs e h l b. ⟦sh Ca = None; not_init C (INIT C' (Ca # Cs,False) ← e); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (INIT C' (Ca # Cs,False) ← e) ∧ (∃sfs'. (sh(Ca ↦ (sblank P Ca, Prepared))) C = ⌊(sfs', Processing)⌋)› 68. ‹⋀sh Ca sfsa C' Cs e h l b. ⟦sh Ca = ⌊(sfsa, Done)⌋; not_init C (INIT C' (Ca # Cs,False) ← e); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (INIT C' (Cs,True) ← e) ∧ (∃sfs'. sh C = ⌊(sfs', Processing)⌋)› 69. ‹⋀sh Ca sfsa C' Cs e h l b. ⟦sh Ca = ⌊(sfsa, Processing)⌋; not_init C (INIT C' (Ca # Cs,False) ← e); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (INIT C' (Cs,True) ← e) ∧ (∃sfs'. sh C = ⌊(sfs', Processing)⌋)› 70. ‹⋀sh Ca sfsa C' Cs e h l b. ⟦sh Ca = ⌊(sfsa, Error)⌋; not_init C (INIT C' (Ca # Cs,False) ← e); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (RI (Ca,THROW NoClassDefFoundError) ; Cs ← e) ∧ (∃sfs'. sh C = ⌊(sfs', Processing)⌋)› 71. ‹⋀sh Ca sfsa sh' C' Cs e h l b. ⟦sh Ca = ⌊(sfsa, Prepared)⌋; Ca = Object; sh' = sh(Ca ↦ (sfsa, Processing)); not_init C (INIT C' (Ca # Cs,False) ← e); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (INIT C' (Ca # Cs,True) ← e) ∧ (∃sfs'. sh' C = ⌊(sfs', Processing)⌋)› 72. ‹⋀sh Ca sfsa D a b sh' C' Cs e h l ba. ⟦sh Ca = ⌊(sfsa, Prepared)⌋; Ca ≠ Object; class P Ca = ⌊(D, a, b)⌋; sh' = sh(Ca ↦ (sfsa, Processing)); not_init C (INIT C' (Ca # Cs,False) ← e); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (INIT C' (D # Ca # Cs,False) ← e) ∧ (∃sfs'. sh' C = ⌊(sfs', Processing)⌋)› 73. ‹⋀C' Ca Cs e h l sh b. ⟦not_init C (INIT C' (Ca # Cs,True) ← e); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (RI (Ca,Ca∙⇩sclinit([])) ; Cs ← e) ∧ (∃sfs'. sh C = ⌊(sfs', Processing)⌋)› 74. ‹⋀e a aa b ba e' ab ac bb b' Ca Cs e₀. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⟦not_init C e; b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C e' ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋); not_init C (RI (Ca,e) ; Cs ← e₀); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (RI (Ca,e') ; Cs ← e₀) ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋)› 75. ‹⋀sh Ca sfsa i sh' C' Cs v e h l b. ⟦sh Ca = ⌊(sfsa, i)⌋; sh' = sh(Ca ↦ (sfsa, Done)); C' = last (Ca # Cs); not_init C (RI (Ca,Val v) ; Cs ← e); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (INIT C' (Cs,True) ← e) ∧ (∃sfs'. sh' C = ⌊(sfs', Processing)⌋)› 76. ‹⋀Ca e a aa b ba. ⟦not_init C (Cast Ca (throw e)); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (throw e) ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 77. ‹⋀e bop e₂ a aa b ba. ⟦not_init C (throw e «bop» e₂); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (throw e) ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 78. ‹⋀v₁ bop e a aa b ba. ⟦not_init C (Val v₁ «bop» throw e); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (throw e) ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 79. ‹⋀V e a aa b ba. ⟦not_init C (V:=throw e); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (throw e) ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 80. ‹⋀e F D a aa b ba. ⟦not_init C (throw e∙F{D}); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (throw e) ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 81. ‹⋀e F D e₂ a aa b ba. ⟦not_init C (throw e∙F{D} := e₂); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (throw e) ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 82. ‹⋀v F D e a aa b ba. ⟦not_init C (Val v∙F{D} := throw e); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (throw e) ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 83. ‹⋀Ca F D e a aa b ba. ⟦not_init C (Ca∙⇩sF{D} := throw e); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (throw e) ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 84. ‹⋀e M es a aa b ba. ⟦not_init C (throw e∙M(es)); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (throw e) ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 85. ‹⋀es vs e es' v M a aa b ba. ⟦es = map Val vs @ throw e # es'; not_init C (Val v∙M(es)); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (throw e) ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 86. ‹⋀es vs e es' Ca M a aa b ba. ⟦es = map Val vs @ throw e # es'; not_init C (Ca∙⇩sM(es)); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (throw e) ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 87. ‹⋀V T a aa ab b ba. ⟦not_init C {V:T; Throw a}; b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (Throw a) ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 88. ‹⋀V T v a aa ab b ba. ⟦not_init C {V:T; V:=Val v;; Throw a}; b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (Throw a) ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 89. ‹⋀e e₂ a aa b ba. ⟦not_init C (throw e;; e₂); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (throw e) ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 90. ‹⋀e e₁ e₂ a aa b ba. ⟦not_init C (if (throw e) e₁ else e₂); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (throw e) ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 91. ‹⋀e a aa b ba. ⟦not_init C (throw (throw e)); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (throw e) ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 92. ‹⋀sh Ca sfsa i sh' a D Cs e h l b. ⟦sh Ca = ⌊(sfsa, i)⌋; sh' = sh(Ca ↦ (sfsa, Error)); not_init C (RI (Ca,Throw a) ; D # Cs ← e); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (RI (D,Throw a) ; Cs ← e) ∧ (∃sfs'. sh' C = ⌊(sfs', Processing)⌋)› 93. ‹⋀sh Ca sfsa i sh' a e h l b. ⟦sh Ca = ⌊(sfsa, i)⌋; sh' = sh(Ca ↦ (sfsa, Error)); not_init C (RI (Ca,Throw a) ; [] ← e); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (Throw a) ∧ (∃sfs'. sh' C = ⌊(sfs', Processing)⌋)›*) case (RedInitDone sh C sfs C' Cs e h l b) (*‹sh C = ⌊(sfs, Done)⌋› ‹not_init (C::char list) (INIT (C'::char list) ((C::char list) # (Cs::char list list),False) ← (e::char list exp))› ‹(sh::sheap) (C::char list) = ⌊(sfs::sfields, Processing)⌋›*) then show "?case" (*goal: ‹not_init C (INIT C' (Cs,True) ← e) ∧ (∃sfs'. sh C = ⌊(sfs', Processing)⌋)›*) apply (cases Cs) (*goals: 1. ‹⟦(sh::sheap) (C::char list) = ⌊(sfs::sfields, Done)⌋; not_init (C::char list) (INIT (C'::char list) (C # (Cs::char list list),False) ← (e::char list exp)); sh C = ⌊(sfs::sfields, Processing)⌋; Cs = []⟧ ⟹ not_init C (INIT C' (Cs,True) ← e) ∧ (∃sfs'::sfields. sh C = ⌊(sfs', Processing)⌋)› 2. ‹⋀(a::char list) list::char list list. ⟦(sh::sheap) (C::char list) = ⌊(sfs::sfields, Done)⌋; not_init (C::char list) (INIT (C'::char list) (C # (Cs::char list list),False) ← (e::char list exp)); sh C = ⌊(sfs::sfields, Processing)⌋; Cs = a # list⟧ ⟹ not_init C (INIT C' (Cs,True) ← e) ∧ (∃sfs'::sfields. sh C = ⌊(sfs', Processing)⌋)› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . next (*goals: 1. ‹⋀h a Ca FDTs h' l sh. ⟦new_Addr h = ⌊a⌋; P ⊢ Ca has_fields FDTs; h' = h(a ↦ blank P Ca); not_init C (new Ca); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (addr a) ∧ (∃sfs'. sh C = ⌊(sfs', Processing)⌋)› 2. ‹⋀h Ca l sh. ⟦new_Addr h = None; is_class P Ca; not_init C (new Ca); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (THROW OutOfMemory) ∧ (∃sfs'. sh C = ⌊(sfs', Processing)⌋)› 3. ‹⋀sh Ca sfsa h l. ⟦sh Ca = ⌊(sfsa, Done)⌋; not_init C (new Ca); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (new Ca) ∧ (∃sfs'. sh C = ⌊(sfs', Processing)⌋)› 4. ‹⋀sh Ca h l. ⟦∄sfs. sh Ca = ⌊(sfs, Done)⌋; is_class P Ca; not_init C (new Ca); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (INIT Ca ([Ca],False) ← new Ca) ∧ (∃sfs'. sh C = ⌊(sfs', Processing)⌋)› 5. ‹⋀e a aa b ba e' ab ac bb b' Ca. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⟦not_init C e; b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C e' ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋); not_init C (Cast Ca e); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (Cast Ca e') ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋)› 6. ‹⋀Ca a aa b ba. ⟦not_init C (Cast Ca null); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C null ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 7. ‹⋀h a D fs Ca l sh b. ⟦h a = ⌊(D, fs)⌋; P ⊢ D ≼⇧* Ca; not_init C (Cast Ca (addr a)); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (addr a) ∧ (∃sfs'. sh C = ⌊(sfs', Processing)⌋)› 8. ‹⋀h a D fs Ca l sh b. ⟦h a = ⌊(D, fs)⌋; (D, Ca) ∉ (subcls1 P)⇧*; not_init C (Cast Ca (addr a)); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (THROW ClassCast) ∧ (∃sfs'. sh C = ⌊(sfs', Processing)⌋)› 9. ‹⋀e a aa b ba e' ab ac bb b' bop e₂. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⟦not_init C e; b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C e' ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋); not_init C (e «bop» e₂); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (e' «bop» e₂) ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋)› 10. ‹⋀e a aa b ba e' ab ac bb b' v₁ bop. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⟦not_init C e; b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C e' ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋); not_init C (Val v₁ «bop» e); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (Val v₁ «bop» e') ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋)› 11. ‹⋀bop v₁ v₂ v a aa b ba. ⟦binop (bop, v₁, v₂) = ⌊v⌋; not_init C (Val v₁ «bop» Val v₂); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (Val v) ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 12. ‹⋀l V v h sh b. ⟦l V = ⌊v⌋; not_init C (Var V); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (Val v) ∧ (∃sfs'. sh C = ⌊(sfs', Processing)⌋)› 13. ‹⋀e a aa b ba e' ab ac bb b' V. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⟦not_init C e; b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C e' ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋); not_init C (V:=e); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (V:=e') ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋)› 14. ‹⋀V v h l sh b. ⟦not_init C (V:=Val v); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C unit ∧ (∃sfs'. sh C = ⌊(sfs', Processing)⌋)› 15. ‹⋀e a aa b ba e' ab ac bb b' F D. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⟦not_init C e; b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C e' ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋); not_init C (e∙F{D}); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (e'∙F{D}) ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋)› 16. ‹⋀h a Ca fs F D v t l sh b. ⟦h a = ⌊(Ca, fs)⌋; fs (F, D) = ⌊v⌋; P ⊢ Ca has F,NonStatic:t in D; not_init C (addr a∙F{D}); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (Val v) ∧ (∃sfs'. sh C = ⌊(sfs', Processing)⌋)› 17. ‹⋀F D a aa b ba. ⟦not_init C (null∙F{D}); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (THROW NullPointer) ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 18. ‹⋀h a Ca fs F D l sh b. ⟦h a = ⌊(Ca, fs)⌋; ∄b t. P ⊢ Ca has F,b:t in D; not_init C (addr a∙F{D}); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (THROW NoSuchFieldError) ∧ (∃sfs'. sh C = ⌊(sfs', Processing)⌋)› 19. ‹⋀h a Ca fs F t D l sh b. ⟦h a = ⌊(Ca, fs)⌋; P ⊢ Ca has F,Static:t in D; not_init C (addr a∙F{D}); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (THROW IncompatibleClassChangeError) ∧ (∃sfs'. sh C = ⌊(sfs', Processing)⌋)› 20. ‹⋀Ca F t D sh sfsa i v h l. ⟦P ⊢ Ca has F,Static:t in D; sh D = ⌊(sfsa, i)⌋; sfsa F = ⌊v⌋; not_init C (Ca∙⇩sF{D}); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (Val v) ∧ (∃sfs'. sh C = ⌊(sfs', Processing)⌋)› 21. ‹⋀Ca F t D sh sfsa h l. ⟦P ⊢ Ca has F,Static:t in D; sh D = ⌊(sfsa, Done)⌋; not_init C (Ca∙⇩sF{D}); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (Ca∙⇩sF{D}) ∧ (∃sfs'. sh C = ⌊(sfs', Processing)⌋)› 22. ‹⋀Ca F t D sh h l. ⟦P ⊢ Ca has F,Static:t in D; ∄sfs. sh D = ⌊(sfs, Done)⌋; not_init C (Ca∙⇩sF{D}); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (INIT D ([D],False) ← Ca∙⇩sF{D}) ∧ (∃sfs'. sh C = ⌊(sfs', Processing)⌋)› 23. ‹⋀Ca F D h l sh b. ⟦∄b t. P ⊢ Ca has F,b:t in D; not_init C (Ca∙⇩sF{D}); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (THROW NoSuchFieldError) ∧ (∃sfs'. sh C = ⌊(sfs', Processing)⌋)› 24. ‹⋀Ca F t D h l sh b. ⟦P ⊢ Ca has F,NonStatic:t in D; not_init C (Ca∙⇩sF{D}); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (THROW IncompatibleClassChangeError) ∧ (∃sfs'. sh C = ⌊(sfs', Processing)⌋)› 25. ‹⋀e a aa b ba e' ab ac bb b' F D e₂. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⟦not_init C e; b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C e' ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋); not_init C (e∙F{D} := e₂); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (e'∙F{D} := e₂) ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋)› 26. ‹⋀e a aa b ba e' ab ac bb b' v F D. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⟦not_init C e; b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C e' ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋); not_init C (Val v∙F{D} := e); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (Val v∙F{D} := e') ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋)› 27. ‹⋀Ca F t D h a fs v l sh b. ⟦P ⊢ Ca has F,NonStatic:t in D; h a = ⌊(Ca, fs)⌋; not_init C (addr a∙F{D} := Val v); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C unit ∧ (∃sfs'. sh C = ⌊(sfs', Processing)⌋)› 28. ‹⋀F D v a aa b ba. ⟦not_init C (null∙F{D} := Val v); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (THROW NullPointer) ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 29. ‹⋀h a Ca fs F D v l sh b. ⟦h a = ⌊(Ca, fs)⌋; ∄b t. P ⊢ Ca has F,b:t in D; not_init C (addr a∙F{D} := Val v); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (THROW NoSuchFieldError) ∧ (∃sfs'. sh C = ⌊(sfs', Processing)⌋)› 30. ‹⋀h a Ca fs F t D v l sh b. ⟦h a = ⌊(Ca, fs)⌋; P ⊢ Ca has F,Static:t in D; not_init C (addr a∙F{D} := Val v); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (THROW IncompatibleClassChangeError) ∧ (∃sfs'. sh C = ⌊(sfs', Processing)⌋)› 31. ‹⋀e a aa b ba e' ab ac bb b' Ca F D. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⟦not_init C e; b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C e' ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋); not_init C (Ca∙⇩sF{D} := e); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (Ca∙⇩sF{D} := e') ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋)› 32. ‹⋀Ca F t D sh sfsa i sfs' v sh' h l. ⟦P ⊢ Ca has F,Static:t in D; sh D = ⌊(sfsa, i)⌋; sfs' = sfsa(F ↦ v); sh' = sh(D ↦ (sfs', i)); not_init C (Ca∙⇩sF{D} := Val v); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C unit ∧ (∃sfs'. sh' C = ⌊(sfs', Processing)⌋)› 33. ‹⋀Ca F t D sh sfsa v h l. ⟦P ⊢ Ca has F,Static:t in D; sh D = ⌊(sfsa, Done)⌋; not_init C (Ca∙⇩sF{D} := Val v); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (Ca∙⇩sF{D} := Val v) ∧ (∃sfs'. sh C = ⌊(sfs', Processing)⌋)› 34. ‹⋀Ca F t D sh v h l. ⟦P ⊢ Ca has F,Static:t in D; ∄sfs. sh D = ⌊(sfs, Done)⌋; not_init C (Ca∙⇩sF{D} := Val v); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (INIT D ([D],False) ← Ca∙⇩sF{D} := Val v) ∧ (∃sfs'. sh C = ⌊(sfs', Processing)⌋)› 35. ‹⋀Ca F D v a aa b ba. ⟦∄b t. P ⊢ Ca has F,b:t in D; not_init C (Ca∙⇩sF{D} := Val v); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (THROW NoSuchFieldError) ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 36. ‹⋀Ca F t D v a aa b ba. ⟦P ⊢ Ca has F,NonStatic:t in D; not_init C (Ca∙⇩sF{D} := Val v); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (THROW IncompatibleClassChangeError) ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 37. ‹⋀e a aa b ba e' ab ac bb b' M es. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⟦not_init C e; b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C e' ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋); not_init C (e∙M(es)); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (e'∙M(es)) ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋)› 38. ‹⋀es a aa b ba es' ab ac bb b' v M. ⟦P ⊢ ⟨es,(a, aa, b),ba⟩ [→] ⟨es',(ab, ac, bb),b'⟩; ⟦not_inits C es; b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_inits C es' ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋); not_init C (Val v∙M(es)); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (Val v∙M(es')) ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋)› 39. ‹⋀M vs a aa b ba. ⟦not_init C (null∙M(map Val vs)); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (THROW NullPointer) ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 40. ‹⋀h a Ca fs M vs l sh b. ⟦h a = ⌊(Ca, fs)⌋; ∄b Ts T m D. P ⊢ Ca sees M, b : Ts→T = m in D; not_init C (addr a∙M(map Val vs)); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (THROW NoSuchMethodError) ∧ (∃sfs'. sh C = ⌊(sfs', Processing)⌋)› 41. ‹⋀h a Ca fs M Ts T aa b D vs l sh ba. ⟦h a = ⌊(Ca, fs)⌋; P ⊢ Ca sees M, Static : Ts→T = (aa, b) in D; not_init C (addr a∙M(map Val vs)); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (THROW IncompatibleClassChangeError) ∧ (∃sfs'. sh C = ⌊(sfs', Processing)⌋)› 42. ‹⋀es a aa b ba es' ab ac bb b' Ca M. ⟦P ⊢ ⟨es,(a, aa, b),ba⟩ [→] ⟨es',(ab, ac, bb),b'⟩; ⟦not_inits C es; b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_inits C es' ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋); not_init C (Ca∙⇩sM(es)); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (Ca∙⇩sM(es')) ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋)› 43. ‹⋀Ca M Ts T pns body D sh sfsa vs h l. ⟦P ⊢ Ca sees M, Static : Ts→T = (pns, body) in D; sh D = ⌊(sfsa, Done)⌋ ∨ M = clinit ∧ sh D = ⌊(sfsa, Processing)⌋; not_init C (Ca∙⇩sM(map Val vs)); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (Ca∙⇩sM(map Val vs)) ∧ (∃sfs'. sh C = ⌊(sfs', Processing)⌋)› 44. ‹⋀Ca M Ts T pns body D sh vs h l. ⟦P ⊢ Ca sees M, Static : Ts→T = (pns, body) in D; ∄sfs. sh D = ⌊(sfs, Done)⌋; M ≠ clinit; not_init C (Ca∙⇩sM(map Val vs)); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (INIT D ([D],False) ← Ca∙⇩sM(map Val vs)) ∧ (∃sfs'. sh C = ⌊(sfs', Processing)⌋)› 45. ‹⋀Ca M vs a aa b ba. ⟦∄b Ts T m. Ex (Method P Ca M b Ts T m); not_init C (Ca∙⇩sM(map Val vs)); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (THROW NoSuchMethodError) ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 46. ‹⋀Ca M Ts T a b D vs aa ab ba bb. ⟦P ⊢ Ca sees M, NonStatic : Ts→T = (a, b) in D; not_init C (Ca∙⇩sM(map Val vs)); ba C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (THROW IncompatibleClassChangeError) ∧ (∃sfs'. ba C = ⌊(sfs', Processing)⌋)› 47. ‹⋀e h l V sh b e' h' l' sh' b' T. ⟦P ⊢ ⟨e,(h, l(V := None), sh),b⟩ → ⟨e',(h', l', sh'),b'⟩; ⟦not_init C e; sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C e' ∧ (∃sfs'. sh' C = ⌊(sfs', Processing)⌋); l' V = None; ¬ assigned V e; not_init C {V:T; e}; sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C {V:T; e'} ∧ (∃sfs'. sh' C = ⌊(sfs', Processing)⌋)› 48. ‹⋀e h l V sh b e' h' l' sh' b' v T. ⟦P ⊢ ⟨e,(h, l(V := None), sh),b⟩ → ⟨e',(h', l', sh'),b'⟩; ⟦not_init C e; sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C e' ∧ (∃sfs'. sh' C = ⌊(sfs', Processing)⌋); l' V = ⌊v⌋; ¬ assigned V e; not_init C {V:T; e}; sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C {V:T; V:=Val v;; e'} ∧ (∃sfs'. sh' C = ⌊(sfs', Processing)⌋)› 49. ‹⋀e h l V v sh b e' h' l' sh' b' v' T. ⟦P ⊢ ⟨e,(h, l(V ↦ v), sh),b⟩ → ⟨e',(h', l', sh'),b'⟩; ⟦not_init C e; sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C e' ∧ (∃sfs'. sh' C = ⌊(sfs', Processing)⌋); l' V = ⌊v'⌋; not_init C {V:T; V:=Val v;; e}; sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C {V:T; V:=Val v';; e'} ∧ (∃sfs'. sh' C = ⌊(sfs', Processing)⌋)› 50. ‹⋀V T u a aa b ba. ⟦not_init C {V:T; Val u}; b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (Val u) ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 51. ‹⋀V T v u a aa b ba. ⟦not_init C {V:T; V:=Val v;; Val u}; b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (Val u) ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 52. ‹⋀e a aa b ba e' ab ac bb b' e₂. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⟦not_init C e; b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C e' ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋); not_init C (e;; e₂); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (e';; e₂) ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋)› 53. ‹⋀v e₂ a aa b ba. ⟦not_init C (Val v;; e₂); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C e₂ ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 54. ‹⋀e a aa b ba e' ab ac bb b' e₁ e₂. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⟦not_init C e; b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C e' ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋); not_init C (if (e) e₁ else e₂); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (if (e') e₁ else e₂) ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋)› 55. ‹⋀e₁ e₂ a aa b ba. ⟦not_init C (if (true) e₁ else e₂); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C e₁ ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 56. ‹⋀e₁ e₂ a aa b ba. ⟦not_init C (if (false) e₁ else e₂); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C e₂ ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 57. ‹⋀b c a aa ba b'. ⟦not_init C (while (b) c); ba C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (if (b) (c;; while (b) c) else unit) ∧ (∃sfs'. ba C = ⌊(sfs', Processing)⌋)› 58. ‹⋀e a aa b ba e' ab ac bb b'. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⟦not_init C e; b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C e' ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋); not_init C (throw e); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (throw e') ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋)› 59. ‹⋀a aa b ba. ⟦not_init C (throw null); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (THROW NullPointer) ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 60. ‹⋀e a aa b ba e' ab ac bb b' Ca V e₂. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⟦not_init C e; b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C e' ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋); not_init C (try e catch(Ca V) e₂); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (try e' catch(Ca V) e₂) ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋)› 61. ‹⋀v Ca V e₂ a aa b ba. ⟦not_init C (try Val v catch(Ca V) e₂); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (Val v) ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 62. ‹⋀a aa b ab D fs Ca V e₂ ba. ⟦hp (a, aa, b) ab = ⌊(D, fs)⌋; P ⊢ D ≼⇧* Ca; not_init C (try Throw ab catch(Ca V) e₂); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C {V:Class Ca; V:=addr ab;; e₂} ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 63. ‹⋀a aa b ab D fs Ca V e₂ ba. ⟦hp (a, aa, b) ab = ⌊(D, fs)⌋; (D, Ca) ∉ (subcls1 P)⇧*; not_init C (try Throw ab catch(Ca V) e₂); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (Throw ab) ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 64. ‹⋀e a aa b ba e' ab ac bb b' es. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⟦not_init C e; b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C e' ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋); not_inits C (e # es); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_inits C (e' # es) ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋)› 65. ‹⋀es a aa b ba es' ab ac bb b' v. ⟦P ⊢ ⟨es,(a, aa, b),ba⟩ [→] ⟨es',(ab, ac, bb),b'⟩; ⟦not_inits C es; b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_inits C es' ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋); not_inits C (Val v # es); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_inits C (Val v # es') ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋)› 66. ‹⋀e Ca b a aa ba b'. ⟦¬ sub_RI e; not_init C (INIT Ca ([],b) ← e); ba C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C e ∧ (∃sfs'. ba C = ⌊(sfs', Processing)⌋)› 67. ‹⋀sh Ca C' Cs e h l b. ⟦sh Ca = None; not_init C (INIT C' (Ca # Cs,False) ← e); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (INIT C' (Ca # Cs,False) ← e) ∧ (∃sfs'. (sh(Ca ↦ (sblank P Ca, Prepared))) C = ⌊(sfs', Processing)⌋)› 68. ‹⋀sh Ca sfsa C' Cs e h l b. ⟦sh Ca = ⌊(sfsa, Processing)⌋; not_init C (INIT C' (Ca # Cs,False) ← e); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (INIT C' (Cs,True) ← e) ∧ (∃sfs'. sh C = ⌊(sfs', Processing)⌋)› 69. ‹⋀sh Ca sfsa C' Cs e h l b. ⟦sh Ca = ⌊(sfsa, Error)⌋; not_init C (INIT C' (Ca # Cs,False) ← e); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (RI (Ca,THROW NoClassDefFoundError) ; Cs ← e) ∧ (∃sfs'. sh C = ⌊(sfs', Processing)⌋)› 70. ‹⋀sh Ca sfsa sh' C' Cs e h l b. ⟦sh Ca = ⌊(sfsa, Prepared)⌋; Ca = Object; sh' = sh(Ca ↦ (sfsa, Processing)); not_init C (INIT C' (Ca # Cs,False) ← e); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (INIT C' (Ca # Cs,True) ← e) ∧ (∃sfs'. sh' C = ⌊(sfs', Processing)⌋)› 71. ‹⋀sh Ca sfsa D a b sh' C' Cs e h l ba. ⟦sh Ca = ⌊(sfsa, Prepared)⌋; Ca ≠ Object; class P Ca = ⌊(D, a, b)⌋; sh' = sh(Ca ↦ (sfsa, Processing)); not_init C (INIT C' (Ca # Cs,False) ← e); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (INIT C' (D # Ca # Cs,False) ← e) ∧ (∃sfs'. sh' C = ⌊(sfs', Processing)⌋)› 72. ‹⋀C' Ca Cs e h l sh b. ⟦not_init C (INIT C' (Ca # Cs,True) ← e); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (RI (Ca,Ca∙⇩sclinit([])) ; Cs ← e) ∧ (∃sfs'. sh C = ⌊(sfs', Processing)⌋)› 73. ‹⋀e a aa b ba e' ab ac bb b' Ca Cs e₀. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⟦not_init C e; b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C e' ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋); not_init C (RI (Ca,e) ; Cs ← e₀); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (RI (Ca,e') ; Cs ← e₀) ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋)› 74. ‹⋀sh Ca sfsa i sh' C' Cs v e h l b. ⟦sh Ca = ⌊(sfsa, i)⌋; sh' = sh(Ca ↦ (sfsa, Done)); C' = last (Ca # Cs); not_init C (RI (Ca,Val v) ; Cs ← e); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (INIT C' (Cs,True) ← e) ∧ (∃sfs'. sh' C = ⌊(sfs', Processing)⌋)› 75. ‹⋀Ca e a aa b ba. ⟦not_init C (Cast Ca (throw e)); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (throw e) ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 76. ‹⋀e bop e₂ a aa b ba. ⟦not_init C (throw e «bop» e₂); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (throw e) ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 77. ‹⋀v₁ bop e a aa b ba. ⟦not_init C (Val v₁ «bop» throw e); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (throw e) ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 78. ‹⋀V e a aa b ba. ⟦not_init C (V:=throw e); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (throw e) ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 79. ‹⋀e F D a aa b ba. ⟦not_init C (throw e∙F{D}); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (throw e) ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 80. ‹⋀e F D e₂ a aa b ba. ⟦not_init C (throw e∙F{D} := e₂); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (throw e) ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 81. ‹⋀v F D e a aa b ba. ⟦not_init C (Val v∙F{D} := throw e); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (throw e) ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 82. ‹⋀Ca F D e a aa b ba. ⟦not_init C (Ca∙⇩sF{D} := throw e); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (throw e) ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 83. ‹⋀e M es a aa b ba. ⟦not_init C (throw e∙M(es)); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (throw e) ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 84. ‹⋀es vs e es' v M a aa b ba. ⟦es = map Val vs @ throw e # es'; not_init C (Val v∙M(es)); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (throw e) ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 85. ‹⋀es vs e es' Ca M a aa b ba. ⟦es = map Val vs @ throw e # es'; not_init C (Ca∙⇩sM(es)); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (throw e) ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 86. ‹⋀V T a aa ab b ba. ⟦not_init C {V:T; Throw a}; b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (Throw a) ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 87. ‹⋀V T v a aa ab b ba. ⟦not_init C {V:T; V:=Val v;; Throw a}; b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (Throw a) ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 88. ‹⋀e e₂ a aa b ba. ⟦not_init C (throw e;; e₂); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (throw e) ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 89. ‹⋀e e₁ e₂ a aa b ba. ⟦not_init C (if (throw e) e₁ else e₂); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (throw e) ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 90. ‹⋀e a aa b ba. ⟦not_init C (throw (throw e)); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (throw e) ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 91. ‹⋀sh Ca sfsa i sh' a D Cs e h l b. ⟦sh Ca = ⌊(sfsa, i)⌋; sh' = sh(Ca ↦ (sfsa, Error)); not_init C (RI (Ca,Throw a) ; D # Cs ← e); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (RI (D,Throw a) ; Cs ← e) ∧ (∃sfs'. sh' C = ⌊(sfs', Processing)⌋)› 92. ‹⋀sh Ca sfsa i sh' a e h l b. ⟦sh Ca = ⌊(sfsa, i)⌋; sh' = sh(Ca ↦ (sfsa, Error)); not_init C (RI (Ca,Throw a) ; [] ← e); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (Throw a) ∧ (∃sfs'. sh' C = ⌊(sfs', Processing)⌋)›*) case (RedInitProcessing sh C sfs C' Cs e h l b) (*‹sh C = ⌊(sfs, Processing)⌋› ‹not_init C (INIT C' (C # Cs,False) ← e)› ‹sh C = ⌊(sfs, Processing)⌋›*) then show "?case" (*goal: ‹not_init C (INIT C' (Cs,True) ← e) ∧ (∃sfs'. sh C = ⌊(sfs', Processing)⌋)›*) apply (cases Cs) (*goals: 1. ‹⟦sh C = ⌊(sfs, Processing)⌋; not_init C (INIT C' (C # Cs,False) ← e); sh C = ⌊(sfs, Processing)⌋; Cs = []⟧ ⟹ not_init C (INIT C' (Cs,True) ← e) ∧ (∃sfs'. sh C = ⌊(sfs', Processing)⌋)› 2. ‹⋀a list. ⟦sh C = ⌊(sfs, Processing)⌋; not_init C (INIT C' (C # Cs,False) ← e); sh C = ⌊(sfs, Processing)⌋; Cs = a # list⟧ ⟹ not_init C (INIT C' (Cs,True) ← e) ∧ (∃sfs'. sh C = ⌊(sfs', Processing)⌋)› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . next (*goals: 1. ‹⋀h a Ca FDTs h' l sh. ⟦new_Addr h = ⌊a⌋; P ⊢ Ca has_fields FDTs; h' = h(a ↦ blank P Ca); not_init C (new Ca); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (addr a) ∧ (∃sfs'. sh C = ⌊(sfs', Processing)⌋)› 2. ‹⋀h Ca l sh. ⟦new_Addr h = None; is_class P Ca; not_init C (new Ca); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (THROW OutOfMemory) ∧ (∃sfs'. sh C = ⌊(sfs', Processing)⌋)› 3. ‹⋀sh Ca sfsa h l. ⟦sh Ca = ⌊(sfsa, Done)⌋; not_init C (new Ca); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (new Ca) ∧ (∃sfs'. sh C = ⌊(sfs', Processing)⌋)› 4. ‹⋀sh Ca h l. ⟦∄sfs. sh Ca = ⌊(sfs, Done)⌋; is_class P Ca; not_init C (new Ca); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (INIT Ca ([Ca],False) ← new Ca) ∧ (∃sfs'. sh C = ⌊(sfs', Processing)⌋)› 5. ‹⋀e a aa b ba e' ab ac bb b' Ca. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⟦not_init C e; b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C e' ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋); not_init C (Cast Ca e); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (Cast Ca e') ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋)› 6. ‹⋀Ca a aa b ba. ⟦not_init C (Cast Ca null); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C null ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 7. ‹⋀h a D fs Ca l sh b. ⟦h a = ⌊(D, fs)⌋; P ⊢ D ≼⇧* Ca; not_init C (Cast Ca (addr a)); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (addr a) ∧ (∃sfs'. sh C = ⌊(sfs', Processing)⌋)› 8. ‹⋀h a D fs Ca l sh b. ⟦h a = ⌊(D, fs)⌋; (D, Ca) ∉ (subcls1 P)⇧*; not_init C (Cast Ca (addr a)); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (THROW ClassCast) ∧ (∃sfs'. sh C = ⌊(sfs', Processing)⌋)› 9. ‹⋀e a aa b ba e' ab ac bb b' bop e₂. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⟦not_init C e; b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C e' ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋); not_init C (e «bop» e₂); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (e' «bop» e₂) ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋)› 10. ‹⋀e a aa b ba e' ab ac bb b' v₁ bop. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⟦not_init C e; b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C e' ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋); not_init C (Val v₁ «bop» e); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (Val v₁ «bop» e') ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋)› 11. ‹⋀bop v₁ v₂ v a aa b ba. ⟦binop (bop, v₁, v₂) = ⌊v⌋; not_init C (Val v₁ «bop» Val v₂); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (Val v) ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 12. ‹⋀l V v h sh b. ⟦l V = ⌊v⌋; not_init C (Var V); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (Val v) ∧ (∃sfs'. sh C = ⌊(sfs', Processing)⌋)› 13. ‹⋀e a aa b ba e' ab ac bb b' V. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⟦not_init C e; b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C e' ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋); not_init C (V:=e); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (V:=e') ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋)› 14. ‹⋀V v h l sh b. ⟦not_init C (V:=Val v); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C unit ∧ (∃sfs'. sh C = ⌊(sfs', Processing)⌋)› 15. ‹⋀e a aa b ba e' ab ac bb b' F D. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⟦not_init C e; b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C e' ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋); not_init C (e∙F{D}); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (e'∙F{D}) ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋)› 16. ‹⋀h a Ca fs F D v t l sh b. ⟦h a = ⌊(Ca, fs)⌋; fs (F, D) = ⌊v⌋; P ⊢ Ca has F,NonStatic:t in D; not_init C (addr a∙F{D}); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (Val v) ∧ (∃sfs'. sh C = ⌊(sfs', Processing)⌋)› 17. ‹⋀F D a aa b ba. ⟦not_init C (null∙F{D}); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (THROW NullPointer) ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 18. ‹⋀h a Ca fs F D l sh b. ⟦h a = ⌊(Ca, fs)⌋; ∄b t. P ⊢ Ca has F,b:t in D; not_init C (addr a∙F{D}); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (THROW NoSuchFieldError) ∧ (∃sfs'. sh C = ⌊(sfs', Processing)⌋)› 19. ‹⋀h a Ca fs F t D l sh b. ⟦h a = ⌊(Ca, fs)⌋; P ⊢ Ca has F,Static:t in D; not_init C (addr a∙F{D}); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (THROW IncompatibleClassChangeError) ∧ (∃sfs'. sh C = ⌊(sfs', Processing)⌋)› 20. ‹⋀Ca F t D sh sfsa i v h l. ⟦P ⊢ Ca has F,Static:t in D; sh D = ⌊(sfsa, i)⌋; sfsa F = ⌊v⌋; not_init C (Ca∙⇩sF{D}); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (Val v) ∧ (∃sfs'. sh C = ⌊(sfs', Processing)⌋)› 21. ‹⋀Ca F t D sh sfsa h l. ⟦P ⊢ Ca has F,Static:t in D; sh D = ⌊(sfsa, Done)⌋; not_init C (Ca∙⇩sF{D}); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (Ca∙⇩sF{D}) ∧ (∃sfs'. sh C = ⌊(sfs', Processing)⌋)› 22. ‹⋀Ca F t D sh h l. ⟦P ⊢ Ca has F,Static:t in D; ∄sfs. sh D = ⌊(sfs, Done)⌋; not_init C (Ca∙⇩sF{D}); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (INIT D ([D],False) ← Ca∙⇩sF{D}) ∧ (∃sfs'. sh C = ⌊(sfs', Processing)⌋)› 23. ‹⋀Ca F D h l sh b. ⟦∄b t. P ⊢ Ca has F,b:t in D; not_init C (Ca∙⇩sF{D}); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (THROW NoSuchFieldError) ∧ (∃sfs'. sh C = ⌊(sfs', Processing)⌋)› 24. ‹⋀Ca F t D h l sh b. ⟦P ⊢ Ca has F,NonStatic:t in D; not_init C (Ca∙⇩sF{D}); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (THROW IncompatibleClassChangeError) ∧ (∃sfs'. sh C = ⌊(sfs', Processing)⌋)› 25. ‹⋀e a aa b ba e' ab ac bb b' F D e₂. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⟦not_init C e; b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C e' ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋); not_init C (e∙F{D} := e₂); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (e'∙F{D} := e₂) ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋)› 26. ‹⋀e a aa b ba e' ab ac bb b' v F D. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⟦not_init C e; b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C e' ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋); not_init C (Val v∙F{D} := e); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (Val v∙F{D} := e') ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋)› 27. ‹⋀Ca F t D h a fs v l sh b. ⟦P ⊢ Ca has F,NonStatic:t in D; h a = ⌊(Ca, fs)⌋; not_init C (addr a∙F{D} := Val v); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C unit ∧ (∃sfs'. sh C = ⌊(sfs', Processing)⌋)› 28. ‹⋀F D v a aa b ba. ⟦not_init C (null∙F{D} := Val v); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (THROW NullPointer) ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 29. ‹⋀h a Ca fs F D v l sh b. ⟦h a = ⌊(Ca, fs)⌋; ∄b t. P ⊢ Ca has F,b:t in D; not_init C (addr a∙F{D} := Val v); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (THROW NoSuchFieldError) ∧ (∃sfs'. sh C = ⌊(sfs', Processing)⌋)› 30. ‹⋀h a Ca fs F t D v l sh b. ⟦h a = ⌊(Ca, fs)⌋; P ⊢ Ca has F,Static:t in D; not_init C (addr a∙F{D} := Val v); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (THROW IncompatibleClassChangeError) ∧ (∃sfs'. sh C = ⌊(sfs', Processing)⌋)› 31. ‹⋀e a aa b ba e' ab ac bb b' Ca F D. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⟦not_init C e; b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C e' ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋); not_init C (Ca∙⇩sF{D} := e); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (Ca∙⇩sF{D} := e') ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋)› 32. ‹⋀Ca F t D sh sfsa i sfs' v sh' h l. ⟦P ⊢ Ca has F,Static:t in D; sh D = ⌊(sfsa, i)⌋; sfs' = sfsa(F ↦ v); sh' = sh(D ↦ (sfs', i)); not_init C (Ca∙⇩sF{D} := Val v); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C unit ∧ (∃sfs'. sh' C = ⌊(sfs', Processing)⌋)› 33. ‹⋀Ca F t D sh sfsa v h l. ⟦P ⊢ Ca has F,Static:t in D; sh D = ⌊(sfsa, Done)⌋; not_init C (Ca∙⇩sF{D} := Val v); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (Ca∙⇩sF{D} := Val v) ∧ (∃sfs'. sh C = ⌊(sfs', Processing)⌋)› 34. ‹⋀Ca F t D sh v h l. ⟦P ⊢ Ca has F,Static:t in D; ∄sfs. sh D = ⌊(sfs, Done)⌋; not_init C (Ca∙⇩sF{D} := Val v); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (INIT D ([D],False) ← Ca∙⇩sF{D} := Val v) ∧ (∃sfs'. sh C = ⌊(sfs', Processing)⌋)› 35. ‹⋀Ca F D v a aa b ba. ⟦∄b t. P ⊢ Ca has F,b:t in D; not_init C (Ca∙⇩sF{D} := Val v); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (THROW NoSuchFieldError) ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 36. ‹⋀Ca F t D v a aa b ba. ⟦P ⊢ Ca has F,NonStatic:t in D; not_init C (Ca∙⇩sF{D} := Val v); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (THROW IncompatibleClassChangeError) ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 37. ‹⋀e a aa b ba e' ab ac bb b' M es. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⟦not_init C e; b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C e' ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋); not_init C (e∙M(es)); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (e'∙M(es)) ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋)› 38. ‹⋀es a aa b ba es' ab ac bb b' v M. ⟦P ⊢ ⟨es,(a, aa, b),ba⟩ [→] ⟨es',(ab, ac, bb),b'⟩; ⟦not_inits C es; b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_inits C es' ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋); not_init C (Val v∙M(es)); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (Val v∙M(es')) ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋)› 39. ‹⋀M vs a aa b ba. ⟦not_init C (null∙M(map Val vs)); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (THROW NullPointer) ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 40. ‹⋀h a Ca fs M vs l sh b. ⟦h a = ⌊(Ca, fs)⌋; ∄b Ts T m D. P ⊢ Ca sees M, b : Ts→T = m in D; not_init C (addr a∙M(map Val vs)); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (THROW NoSuchMethodError) ∧ (∃sfs'. sh C = ⌊(sfs', Processing)⌋)› 41. ‹⋀h a Ca fs M Ts T aa b D vs l sh ba. ⟦h a = ⌊(Ca, fs)⌋; P ⊢ Ca sees M, Static : Ts→T = (aa, b) in D; not_init C (addr a∙M(map Val vs)); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (THROW IncompatibleClassChangeError) ∧ (∃sfs'. sh C = ⌊(sfs', Processing)⌋)› 42. ‹⋀es a aa b ba es' ab ac bb b' Ca M. ⟦P ⊢ ⟨es,(a, aa, b),ba⟩ [→] ⟨es',(ab, ac, bb),b'⟩; ⟦not_inits C es; b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_inits C es' ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋); not_init C (Ca∙⇩sM(es)); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (Ca∙⇩sM(es')) ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋)› 43. ‹⋀Ca M Ts T pns body D sh sfsa vs h l. ⟦P ⊢ Ca sees M, Static : Ts→T = (pns, body) in D; sh D = ⌊(sfsa, Done)⌋ ∨ M = clinit ∧ sh D = ⌊(sfsa, Processing)⌋; not_init C (Ca∙⇩sM(map Val vs)); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (Ca∙⇩sM(map Val vs)) ∧ (∃sfs'. sh C = ⌊(sfs', Processing)⌋)› 44. ‹⋀Ca M Ts T pns body D sh vs h l. ⟦P ⊢ Ca sees M, Static : Ts→T = (pns, body) in D; ∄sfs. sh D = ⌊(sfs, Done)⌋; M ≠ clinit; not_init C (Ca∙⇩sM(map Val vs)); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (INIT D ([D],False) ← Ca∙⇩sM(map Val vs)) ∧ (∃sfs'. sh C = ⌊(sfs', Processing)⌋)› 45. ‹⋀Ca M vs a aa b ba. ⟦∄b Ts T m. Ex (Method P Ca M b Ts T m); not_init C (Ca∙⇩sM(map Val vs)); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (THROW NoSuchMethodError) ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 46. ‹⋀Ca M Ts T a b D vs aa ab ba bb. ⟦P ⊢ Ca sees M, NonStatic : Ts→T = (a, b) in D; not_init C (Ca∙⇩sM(map Val vs)); ba C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (THROW IncompatibleClassChangeError) ∧ (∃sfs'. ba C = ⌊(sfs', Processing)⌋)› 47. ‹⋀e h l V sh b e' h' l' sh' b' T. ⟦P ⊢ ⟨e,(h, l(V := None), sh),b⟩ → ⟨e',(h', l', sh'),b'⟩; ⟦not_init C e; sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C e' ∧ (∃sfs'. sh' C = ⌊(sfs', Processing)⌋); l' V = None; ¬ assigned V e; not_init C {V:T; e}; sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C {V:T; e'} ∧ (∃sfs'. sh' C = ⌊(sfs', Processing)⌋)› 48. ‹⋀e h l V sh b e' h' l' sh' b' v T. ⟦P ⊢ ⟨e,(h, l(V := None), sh),b⟩ → ⟨e',(h', l', sh'),b'⟩; ⟦not_init C e; sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C e' ∧ (∃sfs'. sh' C = ⌊(sfs', Processing)⌋); l' V = ⌊v⌋; ¬ assigned V e; not_init C {V:T; e}; sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C {V:T; V:=Val v;; e'} ∧ (∃sfs'. sh' C = ⌊(sfs', Processing)⌋)› 49. ‹⋀e h l V v sh b e' h' l' sh' b' v' T. ⟦P ⊢ ⟨e,(h, l(V ↦ v), sh),b⟩ → ⟨e',(h', l', sh'),b'⟩; ⟦not_init C e; sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C e' ∧ (∃sfs'. sh' C = ⌊(sfs', Processing)⌋); l' V = ⌊v'⌋; not_init C {V:T; V:=Val v;; e}; sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C {V:T; V:=Val v';; e'} ∧ (∃sfs'. sh' C = ⌊(sfs', Processing)⌋)› 50. ‹⋀V T u a aa b ba. ⟦not_init C {V:T; Val u}; b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (Val u) ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 51. ‹⋀V T v u a aa b ba. ⟦not_init C {V:T; V:=Val v;; Val u}; b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (Val u) ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 52. ‹⋀e a aa b ba e' ab ac bb b' e₂. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⟦not_init C e; b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C e' ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋); not_init C (e;; e₂); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (e';; e₂) ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋)› 53. ‹⋀v e₂ a aa b ba. ⟦not_init C (Val v;; e₂); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C e₂ ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 54. ‹⋀e a aa b ba e' ab ac bb b' e₁ e₂. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⟦not_init C e; b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C e' ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋); not_init C (if (e) e₁ else e₂); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (if (e') e₁ else e₂) ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋)› 55. ‹⋀e₁ e₂ a aa b ba. ⟦not_init C (if (true) e₁ else e₂); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C e₁ ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 56. ‹⋀e₁ e₂ a aa b ba. ⟦not_init C (if (false) e₁ else e₂); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C e₂ ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 57. ‹⋀b c a aa ba b'. ⟦not_init C (while (b) c); ba C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (if (b) (c;; while (b) c) else unit) ∧ (∃sfs'. ba C = ⌊(sfs', Processing)⌋)› 58. ‹⋀e a aa b ba e' ab ac bb b'. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⟦not_init C e; b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C e' ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋); not_init C (throw e); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (throw e') ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋)› 59. ‹⋀a aa b ba. ⟦not_init C (throw null); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (THROW NullPointer) ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 60. ‹⋀e a aa b ba e' ab ac bb b' Ca V e₂. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⟦not_init C e; b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C e' ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋); not_init C (try e catch(Ca V) e₂); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (try e' catch(Ca V) e₂) ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋)› 61. ‹⋀v Ca V e₂ a aa b ba. ⟦not_init C (try Val v catch(Ca V) e₂); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (Val v) ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 62. ‹⋀a aa b ab D fs Ca V e₂ ba. ⟦hp (a, aa, b) ab = ⌊(D, fs)⌋; P ⊢ D ≼⇧* Ca; not_init C (try Throw ab catch(Ca V) e₂); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C {V:Class Ca; V:=addr ab;; e₂} ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 63. ‹⋀a aa b ab D fs Ca V e₂ ba. ⟦hp (a, aa, b) ab = ⌊(D, fs)⌋; (D, Ca) ∉ (subcls1 P)⇧*; not_init C (try Throw ab catch(Ca V) e₂); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (Throw ab) ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 64. ‹⋀e a aa b ba e' ab ac bb b' es. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⟦not_init C e; b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C e' ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋); not_inits C (e # es); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_inits C (e' # es) ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋)› 65. ‹⋀es a aa b ba es' ab ac bb b' v. ⟦P ⊢ ⟨es,(a, aa, b),ba⟩ [→] ⟨es',(ab, ac, bb),b'⟩; ⟦not_inits C es; b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_inits C es' ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋); not_inits C (Val v # es); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_inits C (Val v # es') ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋)› 66. ‹⋀e Ca b a aa ba b'. ⟦¬ sub_RI e; not_init C (INIT Ca ([],b) ← e); ba C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C e ∧ (∃sfs'. ba C = ⌊(sfs', Processing)⌋)› 67. ‹⋀sh Ca C' Cs e h l b. ⟦sh Ca = None; not_init C (INIT C' (Ca # Cs,False) ← e); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (INIT C' (Ca # Cs,False) ← e) ∧ (∃sfs'. (sh(Ca ↦ (sblank P Ca, Prepared))) C = ⌊(sfs', Processing)⌋)› 68. ‹⋀sh Ca sfsa C' Cs e h l b. ⟦sh Ca = ⌊(sfsa, Error)⌋; not_init C (INIT C' (Ca # Cs,False) ← e); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (RI (Ca,THROW NoClassDefFoundError) ; Cs ← e) ∧ (∃sfs'. sh C = ⌊(sfs', Processing)⌋)› 69. ‹⋀sh Ca sfsa sh' C' Cs e h l b. ⟦sh Ca = ⌊(sfsa, Prepared)⌋; Ca = Object; sh' = sh(Ca ↦ (sfsa, Processing)); not_init C (INIT C' (Ca # Cs,False) ← e); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (INIT C' (Ca # Cs,True) ← e) ∧ (∃sfs'. sh' C = ⌊(sfs', Processing)⌋)› 70. ‹⋀sh Ca sfsa D a b sh' C' Cs e h l ba. ⟦sh Ca = ⌊(sfsa, Prepared)⌋; Ca ≠ Object; class P Ca = ⌊(D, a, b)⌋; sh' = sh(Ca ↦ (sfsa, Processing)); not_init C (INIT C' (Ca # Cs,False) ← e); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (INIT C' (D # Ca # Cs,False) ← e) ∧ (∃sfs'. sh' C = ⌊(sfs', Processing)⌋)› 71. ‹⋀C' Ca Cs e h l sh b. ⟦not_init C (INIT C' (Ca # Cs,True) ← e); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (RI (Ca,Ca∙⇩sclinit([])) ; Cs ← e) ∧ (∃sfs'. sh C = ⌊(sfs', Processing)⌋)› 72. ‹⋀e a aa b ba e' ab ac bb b' Ca Cs e₀. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⟦not_init C e; b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C e' ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋); not_init C (RI (Ca,e) ; Cs ← e₀); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (RI (Ca,e') ; Cs ← e₀) ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋)› 73. ‹⋀sh Ca sfsa i sh' C' Cs v e h l b. ⟦sh Ca = ⌊(sfsa, i)⌋; sh' = sh(Ca ↦ (sfsa, Done)); C' = last (Ca # Cs); not_init C (RI (Ca,Val v) ; Cs ← e); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (INIT C' (Cs,True) ← e) ∧ (∃sfs'. sh' C = ⌊(sfs', Processing)⌋)› 74. ‹⋀Ca e a aa b ba. ⟦not_init C (Cast Ca (throw e)); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (throw e) ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 75. ‹⋀e bop e₂ a aa b ba. ⟦not_init C (throw e «bop» e₂); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (throw e) ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 76. ‹⋀v₁ bop e a aa b ba. ⟦not_init C (Val v₁ «bop» throw e); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (throw e) ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 77. ‹⋀V e a aa b ba. ⟦not_init C (V:=throw e); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (throw e) ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 78. ‹⋀e F D a aa b ba. ⟦not_init C (throw e∙F{D}); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (throw e) ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 79. ‹⋀e F D e₂ a aa b ba. ⟦not_init C (throw e∙F{D} := e₂); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (throw e) ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 80. ‹⋀v F D e a aa b ba. ⟦not_init C (Val v∙F{D} := throw e); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (throw e) ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 81. ‹⋀Ca F D e a aa b ba. ⟦not_init C (Ca∙⇩sF{D} := throw e); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (throw e) ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 82. ‹⋀e M es a aa b ba. ⟦not_init C (throw e∙M(es)); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (throw e) ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 83. ‹⋀es vs e es' v M a aa b ba. ⟦es = map Val vs @ throw e # es'; not_init C (Val v∙M(es)); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (throw e) ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 84. ‹⋀es vs e es' Ca M a aa b ba. ⟦es = map Val vs @ throw e # es'; not_init C (Ca∙⇩sM(es)); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (throw e) ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 85. ‹⋀V T a aa ab b ba. ⟦not_init C {V:T; Throw a}; b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (Throw a) ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 86. ‹⋀V T v a aa ab b ba. ⟦not_init C {V:T; V:=Val v;; Throw a}; b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (Throw a) ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 87. ‹⋀e e₂ a aa b ba. ⟦not_init C (throw e;; e₂); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (throw e) ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 88. ‹⋀e e₁ e₂ a aa b ba. ⟦not_init C (if (throw e) e₁ else e₂); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (throw e) ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 89. ‹⋀e a aa b ba. ⟦not_init C (throw (throw e)); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (throw e) ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 90. ‹⋀sh Ca sfsa i sh' a D Cs e h l b. ⟦sh Ca = ⌊(sfsa, i)⌋; sh' = sh(Ca ↦ (sfsa, Error)); not_init C (RI (Ca,Throw a) ; D # Cs ← e); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (RI (D,Throw a) ; Cs ← e) ∧ (∃sfs'. sh' C = ⌊(sfs', Processing)⌋)› 91. ‹⋀sh Ca sfsa i sh' a e h l b. ⟦sh Ca = ⌊(sfsa, i)⌋; sh' = sh(Ca ↦ (sfsa, Error)); not_init C (RI (Ca,Throw a) ; [] ← e); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (Throw a) ∧ (∃sfs'. sh' C = ⌊(sfs', Processing)⌋)›*) case (RedRInit sh C sfs i sh' C' Cs v e h l b) (*‹sh C = ⌊(sfs, i)⌋› ‹sh' = sh(C ↦ (sfs, Done))› ‹C' = last (C # Cs)› ‹not_init C (RI (C,Val v) ; Cs ← e)› ‹sh C = ⌊(sfs, Processing)⌋›*) then show "?case" (*goal: ‹not_init C (INIT C' (Cs,True) ← e) ∧ (∃sfs'. sh' C = ⌊(sfs', Processing)⌋)›*) apply (cases Cs) (*goals: 1. ‹⟦sh C = ⌊(sfs, i)⌋; sh' = sh(C ↦ (sfs, Done)); C' = last (C # Cs); not_init C (RI (C,Val v) ; Cs ← e); sh C = ⌊(sfs, Processing)⌋; Cs = []⟧ ⟹ not_init C (INIT C' (Cs,True) ← e) ∧ (∃sfs'. sh' C = ⌊(sfs', Processing)⌋)› 2. ‹⋀a list. ⟦sh C = ⌊(sfs, i)⌋; sh' = sh(C ↦ (sfs, Done)); C' = last (C # Cs); not_init C (RI (C,Val v) ; Cs ← e); sh C = ⌊(sfs, Processing)⌋; Cs = a # list⟧ ⟹ not_init C (INIT C' (Cs,True) ← e) ∧ (∃sfs'. sh' C = ⌊(sfs', Processing)⌋)› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . next (*goals: 1. ‹⋀h a Ca FDTs h' l sh. ⟦new_Addr h = ⌊a⌋; P ⊢ Ca has_fields FDTs; h' = h(a ↦ blank P Ca); not_init C (new Ca); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (addr a) ∧ (∃sfs'. sh C = ⌊(sfs', Processing)⌋)› 2. ‹⋀h Ca l sh. ⟦new_Addr h = None; is_class P Ca; not_init C (new Ca); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (THROW OutOfMemory) ∧ (∃sfs'. sh C = ⌊(sfs', Processing)⌋)› 3. ‹⋀sh Ca sfsa h l. ⟦sh Ca = ⌊(sfsa, Done)⌋; not_init C (new Ca); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (new Ca) ∧ (∃sfs'. sh C = ⌊(sfs', Processing)⌋)› 4. ‹⋀sh Ca h l. ⟦∄sfs. sh Ca = ⌊(sfs, Done)⌋; is_class P Ca; not_init C (new Ca); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (INIT Ca ([Ca],False) ← new Ca) ∧ (∃sfs'. sh C = ⌊(sfs', Processing)⌋)› 5. ‹⋀e a aa b ba e' ab ac bb b' Ca. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⟦not_init C e; b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C e' ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋); not_init C (Cast Ca e); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (Cast Ca e') ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋)› 6. ‹⋀Ca a aa b ba. ⟦not_init C (Cast Ca null); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C null ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 7. ‹⋀h a D fs Ca l sh b. ⟦h a = ⌊(D, fs)⌋; P ⊢ D ≼⇧* Ca; not_init C (Cast Ca (addr a)); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (addr a) ∧ (∃sfs'. sh C = ⌊(sfs', Processing)⌋)› 8. ‹⋀h a D fs Ca l sh b. ⟦h a = ⌊(D, fs)⌋; (D, Ca) ∉ (subcls1 P)⇧*; not_init C (Cast Ca (addr a)); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (THROW ClassCast) ∧ (∃sfs'. sh C = ⌊(sfs', Processing)⌋)› 9. ‹⋀e a aa b ba e' ab ac bb b' bop e₂. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⟦not_init C e; b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C e' ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋); not_init C (e «bop» e₂); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (e' «bop» e₂) ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋)› 10. ‹⋀e a aa b ba e' ab ac bb b' v₁ bop. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⟦not_init C e; b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C e' ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋); not_init C (Val v₁ «bop» e); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (Val v₁ «bop» e') ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋)› 11. ‹⋀bop v₁ v₂ v a aa b ba. ⟦binop (bop, v₁, v₂) = ⌊v⌋; not_init C (Val v₁ «bop» Val v₂); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (Val v) ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 12. ‹⋀l V v h sh b. ⟦l V = ⌊v⌋; not_init C (Var V); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (Val v) ∧ (∃sfs'. sh C = ⌊(sfs', Processing)⌋)› 13. ‹⋀e a aa b ba e' ab ac bb b' V. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⟦not_init C e; b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C e' ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋); not_init C (V:=e); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (V:=e') ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋)› 14. ‹⋀V v h l sh b. ⟦not_init C (V:=Val v); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C unit ∧ (∃sfs'. sh C = ⌊(sfs', Processing)⌋)› 15. ‹⋀e a aa b ba e' ab ac bb b' F D. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⟦not_init C e; b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C e' ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋); not_init C (e∙F{D}); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (e'∙F{D}) ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋)› 16. ‹⋀h a Ca fs F D v t l sh b. ⟦h a = ⌊(Ca, fs)⌋; fs (F, D) = ⌊v⌋; P ⊢ Ca has F,NonStatic:t in D; not_init C (addr a∙F{D}); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (Val v) ∧ (∃sfs'. sh C = ⌊(sfs', Processing)⌋)› 17. ‹⋀F D a aa b ba. ⟦not_init C (null∙F{D}); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (THROW NullPointer) ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 18. ‹⋀h a Ca fs F D l sh b. ⟦h a = ⌊(Ca, fs)⌋; ∄b t. P ⊢ Ca has F,b:t in D; not_init C (addr a∙F{D}); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (THROW NoSuchFieldError) ∧ (∃sfs'. sh C = ⌊(sfs', Processing)⌋)› 19. ‹⋀h a Ca fs F t D l sh b. ⟦h a = ⌊(Ca, fs)⌋; P ⊢ Ca has F,Static:t in D; not_init C (addr a∙F{D}); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (THROW IncompatibleClassChangeError) ∧ (∃sfs'. sh C = ⌊(sfs', Processing)⌋)› 20. ‹⋀Ca F t D sh sfsa i v h l. ⟦P ⊢ Ca has F,Static:t in D; sh D = ⌊(sfsa, i)⌋; sfsa F = ⌊v⌋; not_init C (Ca∙⇩sF{D}); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (Val v) ∧ (∃sfs'. sh C = ⌊(sfs', Processing)⌋)› 21. ‹⋀Ca F t D sh sfsa h l. ⟦P ⊢ Ca has F,Static:t in D; sh D = ⌊(sfsa, Done)⌋; not_init C (Ca∙⇩sF{D}); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (Ca∙⇩sF{D}) ∧ (∃sfs'. sh C = ⌊(sfs', Processing)⌋)› 22. ‹⋀Ca F t D sh h l. ⟦P ⊢ Ca has F,Static:t in D; ∄sfs. sh D = ⌊(sfs, Done)⌋; not_init C (Ca∙⇩sF{D}); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (INIT D ([D],False) ← Ca∙⇩sF{D}) ∧ (∃sfs'. sh C = ⌊(sfs', Processing)⌋)› 23. ‹⋀Ca F D h l sh b. ⟦∄b t. P ⊢ Ca has F,b:t in D; not_init C (Ca∙⇩sF{D}); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (THROW NoSuchFieldError) ∧ (∃sfs'. sh C = ⌊(sfs', Processing)⌋)› 24. ‹⋀Ca F t D h l sh b. ⟦P ⊢ Ca has F,NonStatic:t in D; not_init C (Ca∙⇩sF{D}); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (THROW IncompatibleClassChangeError) ∧ (∃sfs'. sh C = ⌊(sfs', Processing)⌋)› 25. ‹⋀e a aa b ba e' ab ac bb b' F D e₂. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⟦not_init C e; b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C e' ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋); not_init C (e∙F{D} := e₂); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (e'∙F{D} := e₂) ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋)› 26. ‹⋀e a aa b ba e' ab ac bb b' v F D. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⟦not_init C e; b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C e' ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋); not_init C (Val v∙F{D} := e); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (Val v∙F{D} := e') ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋)› 27. ‹⋀Ca F t D h a fs v l sh b. ⟦P ⊢ Ca has F,NonStatic:t in D; h a = ⌊(Ca, fs)⌋; not_init C (addr a∙F{D} := Val v); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C unit ∧ (∃sfs'. sh C = ⌊(sfs', Processing)⌋)› 28. ‹⋀F D v a aa b ba. ⟦not_init C (null∙F{D} := Val v); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (THROW NullPointer) ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 29. ‹⋀h a Ca fs F D v l sh b. ⟦h a = ⌊(Ca, fs)⌋; ∄b t. P ⊢ Ca has F,b:t in D; not_init C (addr a∙F{D} := Val v); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (THROW NoSuchFieldError) ∧ (∃sfs'. sh C = ⌊(sfs', Processing)⌋)› 30. ‹⋀h a Ca fs F t D v l sh b. ⟦h a = ⌊(Ca, fs)⌋; P ⊢ Ca has F,Static:t in D; not_init C (addr a∙F{D} := Val v); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (THROW IncompatibleClassChangeError) ∧ (∃sfs'. sh C = ⌊(sfs', Processing)⌋)› 31. ‹⋀e a aa b ba e' ab ac bb b' Ca F D. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⟦not_init C e; b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C e' ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋); not_init C (Ca∙⇩sF{D} := e); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (Ca∙⇩sF{D} := e') ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋)› 32. ‹⋀Ca F t D sh sfsa i sfs' v sh' h l. ⟦P ⊢ Ca has F,Static:t in D; sh D = ⌊(sfsa, i)⌋; sfs' = sfsa(F ↦ v); sh' = sh(D ↦ (sfs', i)); not_init C (Ca∙⇩sF{D} := Val v); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C unit ∧ (∃sfs'. sh' C = ⌊(sfs', Processing)⌋)› 33. ‹⋀Ca F t D sh sfsa v h l. ⟦P ⊢ Ca has F,Static:t in D; sh D = ⌊(sfsa, Done)⌋; not_init C (Ca∙⇩sF{D} := Val v); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (Ca∙⇩sF{D} := Val v) ∧ (∃sfs'. sh C = ⌊(sfs', Processing)⌋)› 34. ‹⋀Ca F t D sh v h l. ⟦P ⊢ Ca has F,Static:t in D; ∄sfs. sh D = ⌊(sfs, Done)⌋; not_init C (Ca∙⇩sF{D} := Val v); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (INIT D ([D],False) ← Ca∙⇩sF{D} := Val v) ∧ (∃sfs'. sh C = ⌊(sfs', Processing)⌋)› 35. ‹⋀Ca F D v a aa b ba. ⟦∄b t. P ⊢ Ca has F,b:t in D; not_init C (Ca∙⇩sF{D} := Val v); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (THROW NoSuchFieldError) ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 36. ‹⋀Ca F t D v a aa b ba. ⟦P ⊢ Ca has F,NonStatic:t in D; not_init C (Ca∙⇩sF{D} := Val v); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (THROW IncompatibleClassChangeError) ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 37. ‹⋀e a aa b ba e' ab ac bb b' M es. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⟦not_init C e; b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C e' ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋); not_init C (e∙M(es)); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (e'∙M(es)) ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋)› 38. ‹⋀es a aa b ba es' ab ac bb b' v M. ⟦P ⊢ ⟨es,(a, aa, b),ba⟩ [→] ⟨es',(ab, ac, bb),b'⟩; ⟦not_inits C es; b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_inits C es' ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋); not_init C (Val v∙M(es)); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (Val v∙M(es')) ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋)› 39. ‹⋀M vs a aa b ba. ⟦not_init C (null∙M(map Val vs)); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (THROW NullPointer) ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 40. ‹⋀h a Ca fs M vs l sh b. ⟦h a = ⌊(Ca, fs)⌋; ∄b Ts T m D. P ⊢ Ca sees M, b : Ts→T = m in D; not_init C (addr a∙M(map Val vs)); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (THROW NoSuchMethodError) ∧ (∃sfs'. sh C = ⌊(sfs', Processing)⌋)› 41. ‹⋀h a Ca fs M Ts T aa b D vs l sh ba. ⟦h a = ⌊(Ca, fs)⌋; P ⊢ Ca sees M, Static : Ts→T = (aa, b) in D; not_init C (addr a∙M(map Val vs)); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (THROW IncompatibleClassChangeError) ∧ (∃sfs'. sh C = ⌊(sfs', Processing)⌋)› 42. ‹⋀es a aa b ba es' ab ac bb b' Ca M. ⟦P ⊢ ⟨es,(a, aa, b),ba⟩ [→] ⟨es',(ab, ac, bb),b'⟩; ⟦not_inits C es; b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_inits C es' ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋); not_init C (Ca∙⇩sM(es)); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (Ca∙⇩sM(es')) ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋)› 43. ‹⋀Ca M Ts T pns body D sh sfsa vs h l. ⟦P ⊢ Ca sees M, Static : Ts→T = (pns, body) in D; sh D = ⌊(sfsa, Done)⌋ ∨ M = clinit ∧ sh D = ⌊(sfsa, Processing)⌋; not_init C (Ca∙⇩sM(map Val vs)); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (Ca∙⇩sM(map Val vs)) ∧ (∃sfs'. sh C = ⌊(sfs', Processing)⌋)› 44. ‹⋀Ca M Ts T pns body D sh vs h l. ⟦P ⊢ Ca sees M, Static : Ts→T = (pns, body) in D; ∄sfs. sh D = ⌊(sfs, Done)⌋; M ≠ clinit; not_init C (Ca∙⇩sM(map Val vs)); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (INIT D ([D],False) ← Ca∙⇩sM(map Val vs)) ∧ (∃sfs'. sh C = ⌊(sfs', Processing)⌋)› 45. ‹⋀Ca M vs a aa b ba. ⟦∄b Ts T m. Ex (Method P Ca M b Ts T m); not_init C (Ca∙⇩sM(map Val vs)); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (THROW NoSuchMethodError) ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 46. ‹⋀Ca M Ts T a b D vs aa ab ba bb. ⟦P ⊢ Ca sees M, NonStatic : Ts→T = (a, b) in D; not_init C (Ca∙⇩sM(map Val vs)); ba C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (THROW IncompatibleClassChangeError) ∧ (∃sfs'. ba C = ⌊(sfs', Processing)⌋)› 47. ‹⋀e h l V sh b e' h' l' sh' b' T. ⟦P ⊢ ⟨e,(h, l(V := None), sh),b⟩ → ⟨e',(h', l', sh'),b'⟩; ⟦not_init C e; sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C e' ∧ (∃sfs'. sh' C = ⌊(sfs', Processing)⌋); l' V = None; ¬ assigned V e; not_init C {V:T; e}; sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C {V:T; e'} ∧ (∃sfs'. sh' C = ⌊(sfs', Processing)⌋)› 48. ‹⋀e h l V sh b e' h' l' sh' b' v T. ⟦P ⊢ ⟨e,(h, l(V := None), sh),b⟩ → ⟨e',(h', l', sh'),b'⟩; ⟦not_init C e; sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C e' ∧ (∃sfs'. sh' C = ⌊(sfs', Processing)⌋); l' V = ⌊v⌋; ¬ assigned V e; not_init C {V:T; e}; sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C {V:T; V:=Val v;; e'} ∧ (∃sfs'. sh' C = ⌊(sfs', Processing)⌋)› 49. ‹⋀e h l V v sh b e' h' l' sh' b' v' T. ⟦P ⊢ ⟨e,(h, l(V ↦ v), sh),b⟩ → ⟨e',(h', l', sh'),b'⟩; ⟦not_init C e; sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C e' ∧ (∃sfs'. sh' C = ⌊(sfs', Processing)⌋); l' V = ⌊v'⌋; not_init C {V:T; V:=Val v;; e}; sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C {V:T; V:=Val v';; e'} ∧ (∃sfs'. sh' C = ⌊(sfs', Processing)⌋)› 50. ‹⋀V T u a aa b ba. ⟦not_init C {V:T; Val u}; b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (Val u) ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 51. ‹⋀V T v u a aa b ba. ⟦not_init C {V:T; V:=Val v;; Val u}; b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (Val u) ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 52. ‹⋀e a aa b ba e' ab ac bb b' e₂. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⟦not_init C e; b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C e' ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋); not_init C (e;; e₂); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (e';; e₂) ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋)› 53. ‹⋀v e₂ a aa b ba. ⟦not_init C (Val v;; e₂); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C e₂ ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 54. ‹⋀e a aa b ba e' ab ac bb b' e₁ e₂. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⟦not_init C e; b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C e' ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋); not_init C (if (e) e₁ else e₂); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (if (e') e₁ else e₂) ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋)› 55. ‹⋀e₁ e₂ a aa b ba. ⟦not_init C (if (true) e₁ else e₂); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C e₁ ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 56. ‹⋀e₁ e₂ a aa b ba. ⟦not_init C (if (false) e₁ else e₂); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C e₂ ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 57. ‹⋀b c a aa ba b'. ⟦not_init C (while (b) c); ba C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (if (b) (c;; while (b) c) else unit) ∧ (∃sfs'. ba C = ⌊(sfs', Processing)⌋)› 58. ‹⋀e a aa b ba e' ab ac bb b'. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⟦not_init C e; b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C e' ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋); not_init C (throw e); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (throw e') ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋)› 59. ‹⋀a aa b ba. ⟦not_init C (throw null); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (THROW NullPointer) ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 60. ‹⋀e a aa b ba e' ab ac bb b' Ca V e₂. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⟦not_init C e; b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C e' ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋); not_init C (try e catch(Ca V) e₂); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (try e' catch(Ca V) e₂) ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋)› 61. ‹⋀v Ca V e₂ a aa b ba. ⟦not_init C (try Val v catch(Ca V) e₂); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (Val v) ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 62. ‹⋀a aa b ab D fs Ca V e₂ ba. ⟦hp (a, aa, b) ab = ⌊(D, fs)⌋; P ⊢ D ≼⇧* Ca; not_init C (try Throw ab catch(Ca V) e₂); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C {V:Class Ca; V:=addr ab;; e₂} ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 63. ‹⋀a aa b ab D fs Ca V e₂ ba. ⟦hp (a, aa, b) ab = ⌊(D, fs)⌋; (D, Ca) ∉ (subcls1 P)⇧*; not_init C (try Throw ab catch(Ca V) e₂); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (Throw ab) ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 64. ‹⋀e a aa b ba e' ab ac bb b' es. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⟦not_init C e; b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C e' ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋); not_inits C (e # es); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_inits C (e' # es) ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋)› 65. ‹⋀es a aa b ba es' ab ac bb b' v. ⟦P ⊢ ⟨es,(a, aa, b),ba⟩ [→] ⟨es',(ab, ac, bb),b'⟩; ⟦not_inits C es; b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_inits C es' ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋); not_inits C (Val v # es); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_inits C (Val v # es') ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋)› 66. ‹⋀e Ca b a aa ba b'. ⟦¬ sub_RI e; not_init C (INIT Ca ([],b) ← e); ba C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C e ∧ (∃sfs'. ba C = ⌊(sfs', Processing)⌋)› 67. ‹⋀sh Ca C' Cs e h l b. ⟦sh Ca = None; not_init C (INIT C' (Ca # Cs,False) ← e); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (INIT C' (Ca # Cs,False) ← e) ∧ (∃sfs'. (sh(Ca ↦ (sblank P Ca, Prepared))) C = ⌊(sfs', Processing)⌋)› 68. ‹⋀sh Ca sfsa C' Cs e h l b. ⟦sh Ca = ⌊(sfsa, Error)⌋; not_init C (INIT C' (Ca # Cs,False) ← e); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (RI (Ca,THROW NoClassDefFoundError) ; Cs ← e) ∧ (∃sfs'. sh C = ⌊(sfs', Processing)⌋)› 69. ‹⋀sh Ca sfsa sh' C' Cs e h l b. ⟦sh Ca = ⌊(sfsa, Prepared)⌋; Ca = Object; sh' = sh(Ca ↦ (sfsa, Processing)); not_init C (INIT C' (Ca # Cs,False) ← e); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (INIT C' (Ca # Cs,True) ← e) ∧ (∃sfs'. sh' C = ⌊(sfs', Processing)⌋)› 70. ‹⋀sh Ca sfsa D a b sh' C' Cs e h l ba. ⟦sh Ca = ⌊(sfsa, Prepared)⌋; Ca ≠ Object; class P Ca = ⌊(D, a, b)⌋; sh' = sh(Ca ↦ (sfsa, Processing)); not_init C (INIT C' (Ca # Cs,False) ← e); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (INIT C' (D # Ca # Cs,False) ← e) ∧ (∃sfs'. sh' C = ⌊(sfs', Processing)⌋)› 71. ‹⋀C' Ca Cs e h l sh b. ⟦not_init C (INIT C' (Ca # Cs,True) ← e); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (RI (Ca,Ca∙⇩sclinit([])) ; Cs ← e) ∧ (∃sfs'. sh C = ⌊(sfs', Processing)⌋)› 72. ‹⋀e a aa b ba e' ab ac bb b' Ca Cs e₀. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⟦not_init C e; b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C e' ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋); not_init C (RI (Ca,e) ; Cs ← e₀); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (RI (Ca,e') ; Cs ← e₀) ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋)› 73. ‹⋀Ca e a aa b ba. ⟦not_init C (Cast Ca (throw e)); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (throw e) ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 74. ‹⋀e bop e₂ a aa b ba. ⟦not_init C (throw e «bop» e₂); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (throw e) ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 75. ‹⋀v₁ bop e a aa b ba. ⟦not_init C (Val v₁ «bop» throw e); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (throw e) ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 76. ‹⋀V e a aa b ba. ⟦not_init C (V:=throw e); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (throw e) ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 77. ‹⋀e F D a aa b ba. ⟦not_init C (throw e∙F{D}); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (throw e) ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 78. ‹⋀e F D e₂ a aa b ba. ⟦not_init C (throw e∙F{D} := e₂); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (throw e) ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 79. ‹⋀v F D e a aa b ba. ⟦not_init C (Val v∙F{D} := throw e); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (throw e) ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 80. ‹⋀Ca F D e a aa b ba. ⟦not_init C (Ca∙⇩sF{D} := throw e); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (throw e) ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 81. ‹⋀e M es a aa b ba. ⟦not_init C (throw e∙M(es)); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (throw e) ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 82. ‹⋀es vs e es' v M a aa b ba. ⟦es = map Val vs @ throw e # es'; not_init C (Val v∙M(es)); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (throw e) ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 83. ‹⋀es vs e es' Ca M a aa b ba. ⟦es = map Val vs @ throw e # es'; not_init C (Ca∙⇩sM(es)); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (throw e) ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 84. ‹⋀V T a aa ab b ba. ⟦not_init C {V:T; Throw a}; b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (Throw a) ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 85. ‹⋀V T v a aa ab b ba. ⟦not_init C {V:T; V:=Val v;; Throw a}; b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (Throw a) ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 86. ‹⋀e e₂ a aa b ba. ⟦not_init C (throw e;; e₂); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (throw e) ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 87. ‹⋀e e₁ e₂ a aa b ba. ⟦not_init C (if (throw e) e₁ else e₂); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (throw e) ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 88. ‹⋀e a aa b ba. ⟦not_init C (throw (throw e)); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (throw e) ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 89. ‹⋀sh Ca sfsa i sh' a D Cs e h l b. ⟦sh Ca = ⌊(sfsa, i)⌋; sh' = sh(Ca ↦ (sfsa, Error)); not_init C (RI (Ca,Throw a) ; D # Cs ← e); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (RI (D,Throw a) ; Cs ← e) ∧ (∃sfs'. sh' C = ⌊(sfs', Processing)⌋)› 90. ‹⋀sh Ca sfsa i sh' a e h l b. ⟦sh Ca = ⌊(sfsa, i)⌋; sh' = sh(Ca ↦ (sfsa, Error)); not_init C (RI (Ca,Throw a) ; [] ← e); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (Throw a) ∧ (∃sfs'. sh' C = ⌊(sfs', Processing)⌋)›*) case (CallThrowParams es vs e es' v M h l sh b) (*‹es = map Val vs @ throw e # es'› ‹not_init C (Val v∙M(es))› ‹sh C = ⌊(sfs, Processing)⌋›*) then show "?case" (*goal: ‹not_init C (throw e) ∧ (∃sfs'. sh C = ⌊(sfs', Processing)⌋)›*) by (auto dest: not_inits_def' (*‹not_inits ?C ?es ⟹ ∀e∈set ?es. not_init ?C e›*)) next (*goals: 1. ‹⋀(h::heap) (a::nat) (Ca::char list) (FDTs::((char list × char list) × staticb × ty) list) (h'::heap) (l::sfields) sh::sheap. ⟦new_Addr h = ⌊a⌋; (P::(char list list × char list exp) prog) ⊢ Ca has_fields FDTs; h' = h(a ↦ blank P Ca); not_init (C::char list) (new Ca); sh C = ⌊(sfs::sfields, Processing)⌋⟧ ⟹ not_init C (addr a) ∧ (∃sfs'::sfields. sh C = ⌊(sfs', Processing)⌋)› 2. ‹⋀(h::heap) (Ca::char list) (l::sfields) sh::sheap. ⟦new_Addr h = None; is_class (P::(char list list × char list exp) prog) Ca; not_init (C::char list) (new Ca); sh C = ⌊(sfs::sfields, Processing)⌋⟧ ⟹ not_init C (THROW OutOfMemory) ∧ (∃sfs'::sfields. sh C = ⌊(sfs', Processing)⌋)› 3. ‹⋀(sh::sheap) (Ca::char list) (sfsa::sfields) (h::heap) l::sfields. ⟦sh Ca = ⌊(sfsa, Done)⌋; not_init (C::char list) (new Ca); sh C = ⌊(sfs::sfields, Processing)⌋⟧ ⟹ not_init C (new Ca) ∧ (∃sfs'::sfields. sh C = ⌊(sfs', Processing)⌋)› 4. ‹⋀(sh::sheap) (Ca::char list) (h::heap) l::sfields. ⟦∄sfs::sfields. sh Ca = ⌊(sfs, Done)⌋; is_class (P::(char list list × char list exp) prog) Ca; not_init (C::char list) (new Ca); sh C = ⌊(sfs::sfields, Processing)⌋⟧ ⟹ not_init C (INIT Ca ([Ca],False) ← new Ca) ∧ (∃sfs'::sfields. sh C = ⌊(sfs', Processing)⌋)› 5. ‹⋀(e::char list exp) (a::heap) (aa::sfields) (b::sheap) (ba::bool) (e'::char list exp) (ab::heap) (ac::sfields) (bb::sheap) (b'::bool) Ca::char list. ⟦(P::(char list list × char list exp) prog) ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⟦not_init (C::char list) e; b C = ⌊(sfs::sfields, Processing)⌋⟧ ⟹ not_init C e' ∧ (∃sfs'::sfields. bb C = ⌊(sfs', Processing)⌋); not_init C (Cast Ca e); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (Cast Ca e') ∧ (∃sfs'::sfields. bb C = ⌊(sfs', Processing)⌋)› 6. ‹⋀(Ca::char list) (a::heap) (aa::sfields) (b::sheap) ba::bool. ⟦not_init (C::char list) (Cast Ca null); b C = ⌊(sfs::sfields, Processing)⌋⟧ ⟹ not_init C null ∧ (∃sfs'::sfields. b C = ⌊(sfs', Processing)⌋)› 7. ‹⋀(h::heap) (a::nat) (D::char list) (fs::Objects.fields) (Ca::char list) (l::sfields) (sh::sheap) b::bool. ⟦h a = ⌊(D, fs)⌋; (P::(char list list × char list exp) prog) ⊢ D ≼⇧* Ca; not_init (C::char list) (Cast Ca (addr a)); sh C = ⌊(sfs::sfields, Processing)⌋⟧ ⟹ not_init C (addr a) ∧ (∃sfs'::sfields. sh C = ⌊(sfs', Processing)⌋)› 8. ‹⋀(h::heap) (a::nat) (D::char list) (fs::Objects.fields) (Ca::char list) (l::sfields) (sh::sheap) b::bool. ⟦h a = ⌊(D, fs)⌋; (D, Ca) ∉ (subcls1 (P::(char list list × char list exp) prog))⇧*; not_init (C::char list) (Cast Ca (addr a)); sh C = ⌊(sfs::sfields, Processing)⌋⟧ ⟹ not_init C (THROW ClassCast) ∧ (∃sfs'::sfields. sh C = ⌊(sfs', Processing)⌋)› 9. ‹⋀(e::char list exp) (a::heap) (aa::sfields) (b::sheap) (ba::bool) (e'::char list exp) (ab::heap) (ac::sfields) (bb::sheap) (b'::bool) (bop::bop) e₂::char list exp. ⟦(P::(char list list × char list exp) prog) ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⟦not_init (C::char list) e; b C = ⌊(sfs::sfields, Processing)⌋⟧ ⟹ not_init C e' ∧ (∃sfs'::sfields. bb C = ⌊(sfs', Processing)⌋); not_init C (e «bop» e₂); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (e' «bop» e₂) ∧ (∃sfs'::sfields. bb C = ⌊(sfs', Processing)⌋)› 10. ‹⋀(e::char list exp) (a::heap) (aa::sfields) (b::sheap) (ba::bool) (e'::char list exp) (ab::heap) (ac::sfields) (bb::sheap) (b'::bool) (v₁::val) bop::bop. ⟦(P::(char list list × char list exp) prog) ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⟦not_init (C::char list) e; b C = ⌊(sfs::sfields, Processing)⌋⟧ ⟹ not_init C e' ∧ (∃sfs'::sfields. bb C = ⌊(sfs', Processing)⌋); not_init C (Val v₁ «bop» e); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (Val v₁ «bop» e') ∧ (∃sfs'::sfields. bb C = ⌊(sfs', Processing)⌋)› 11. ‹⋀(bop::bop) (v₁::val) (v₂::val) (v::val) (a::heap) (aa::sfields) (b::sheap) ba::bool. ⟦binop (bop, v₁, v₂) = ⌊v⌋; not_init (C::char list) (Val v₁ «bop» Val v₂); b C = ⌊(sfs::sfields, Processing)⌋⟧ ⟹ not_init C (Val v) ∧ (∃sfs'::sfields. b C = ⌊(sfs', Processing)⌋)› 12. ‹⋀(l::sfields) (V::char list) (v::val) (h::heap) (sh::sheap) b::bool. ⟦l V = ⌊v⌋; not_init (C::char list) (Var V); sh C = ⌊(sfs::sfields, Processing)⌋⟧ ⟹ not_init C (Val v) ∧ (∃sfs'::sfields. sh C = ⌊(sfs', Processing)⌋)› 13. ‹⋀(e::char list exp) (a::heap) (aa::sfields) (b::sheap) (ba::bool) (e'::char list exp) (ab::heap) (ac::sfields) (bb::sheap) (b'::bool) V::char list. ⟦(P::(char list list × char list exp) prog) ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⟦not_init (C::char list) e; b C = ⌊(sfs::sfields, Processing)⌋⟧ ⟹ not_init C e' ∧ (∃sfs'::sfields. bb C = ⌊(sfs', Processing)⌋); not_init C (V:=e); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (V:=e') ∧ (∃sfs'::sfields. bb C = ⌊(sfs', Processing)⌋)› 14. ‹⋀(V::char list) (v::val) (h::heap) (l::sfields) (sh::sheap) b::bool. ⟦not_init (C::char list) (V:=Val v); sh C = ⌊(sfs::sfields, Processing)⌋⟧ ⟹ not_init C unit ∧ (∃sfs'::sfields. sh C = ⌊(sfs', Processing)⌋)› 15. ‹⋀(e::char list exp) (a::heap) (aa::sfields) (b::sheap) (ba::bool) (e'::char list exp) (ab::heap) (ac::sfields) (bb::sheap) (b'::bool) (F::char list) D::char list. ⟦(P::(char list list × char list exp) prog) ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⟦not_init (C::char list) e; b C = ⌊(sfs::sfields, Processing)⌋⟧ ⟹ not_init C e' ∧ (∃sfs'::sfields. bb C = ⌊(sfs', Processing)⌋); not_init C (e∙F{D}); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (e'∙F{D}) ∧ (∃sfs'::sfields. bb C = ⌊(sfs', Processing)⌋)› 16. ‹⋀(h::heap) (a::nat) (Ca::char list) (fs::Objects.fields) (F::char list) (D::char list) (v::val) (t::ty) (l::sfields) (sh::sheap) b::bool. ⟦h a = ⌊(Ca, fs)⌋; fs (F, D) = ⌊v⌋; (P::(char list list × char list exp) prog) ⊢ Ca has F,NonStatic:t in D; not_init (C::char list) (addr a∙F{D}); sh C = ⌊(sfs::sfields, Processing)⌋⟧ ⟹ not_init C (Val v) ∧ (∃sfs'::sfields. sh C = ⌊(sfs', Processing)⌋)› 17. ‹⋀(F::char list) (D::char list) (a::heap) (aa::sfields) (b::sheap) ba::bool. ⟦not_init (C::char list) (null∙F{D}); b C = ⌊(sfs::sfields, Processing)⌋⟧ ⟹ not_init C (THROW NullPointer) ∧ (∃sfs'::sfields. b C = ⌊(sfs', Processing)⌋)› 18. ‹⋀(h::heap) (a::nat) (Ca::char list) (fs::Objects.fields) (F::char list) (D::char list) (l::sfields) (sh::sheap) b::bool. ⟦h a = ⌊(Ca, fs)⌋; ∄(b::staticb) t::ty. (P::(char list list × char list exp) prog) ⊢ Ca has F,b:t in D; not_init (C::char list) (addr a∙F{D}); sh C = ⌊(sfs::sfields, Processing)⌋⟧ ⟹ not_init C (THROW NoSuchFieldError) ∧ (∃sfs'::sfields. sh C = ⌊(sfs', Processing)⌋)› 19. ‹⋀(h::heap) (a::nat) (Ca::char list) (fs::Objects.fields) (F::char list) (t::ty) (D::char list) (l::sfields) (sh::sheap) b::bool. ⟦h a = ⌊(Ca, fs)⌋; (P::(char list list × char list exp) prog) ⊢ Ca has F,Static:t in D; not_init (C::char list) (addr a∙F{D}); sh C = ⌊(sfs::sfields, Processing)⌋⟧ ⟹ not_init C (THROW IncompatibleClassChangeError) ∧ (∃sfs'::sfields. sh C = ⌊(sfs', Processing)⌋)› 20. ‹⋀(Ca::char list) (F::char list) (t::ty) (D::char list) (sh::sheap) (sfsa::sfields) (i::init_state) (v::val) (h::heap) l::sfields. ⟦(P::(char list list × char list exp) prog) ⊢ Ca has F,Static:t in D; sh D = ⌊(sfsa, i)⌋; sfsa F = ⌊v⌋; not_init (C::char list) (Ca∙⇩sF{D}); sh C = ⌊(sfs::sfields, Processing)⌋⟧ ⟹ not_init C (Val v) ∧ (∃sfs'::sfields. sh C = ⌊(sfs', Processing)⌋)› 21. ‹⋀(Ca::char list) (F::char list) (t::ty) (D::char list) (sh::sheap) (sfsa::sfields) (h::heap) l::sfields. ⟦(P::(char list list × char list exp) prog) ⊢ Ca has F,Static:t in D; sh D = ⌊(sfsa, Done)⌋; not_init (C::char list) (Ca∙⇩sF{D}); sh C = ⌊(sfs::sfields, Processing)⌋⟧ ⟹ not_init C (Ca∙⇩sF{D}) ∧ (∃sfs'::sfields. sh C = ⌊(sfs', Processing)⌋)› 22. ‹⋀(Ca::char list) (F::char list) (t::ty) (D::char list) (sh::sheap) (h::heap) l::sfields. ⟦(P::(char list list × char list exp) prog) ⊢ Ca has F,Static:t in D; ∄sfs::sfields. sh D = ⌊(sfs, Done)⌋; not_init (C::char list) (Ca∙⇩sF{D}); sh C = ⌊(sfs::sfields, Processing)⌋⟧ ⟹ not_init C (INIT D ([D],False) ← Ca∙⇩sF{D}) ∧ (∃sfs'::sfields. sh C = ⌊(sfs', Processing)⌋)› 23. ‹⋀(Ca::char list) (F::char list) (D::char list) (h::heap) (l::sfields) (sh::sheap) b::bool. ⟦∄(b::staticb) t::ty. (P::(char list list × char list exp) prog) ⊢ Ca has F,b:t in D; not_init (C::char list) (Ca∙⇩sF{D}); sh C = ⌊(sfs::sfields, Processing)⌋⟧ ⟹ not_init C (THROW NoSuchFieldError) ∧ (∃sfs'::sfields. sh C = ⌊(sfs', Processing)⌋)› 24. ‹⋀(Ca::char list) (F::char list) (t::ty) (D::char list) (h::heap) (l::sfields) (sh::sheap) b::bool. ⟦(P::(char list list × char list exp) prog) ⊢ Ca has F,NonStatic:t in D; not_init (C::char list) (Ca∙⇩sF{D}); sh C = ⌊(sfs::sfields, Processing)⌋⟧ ⟹ not_init C (THROW IncompatibleClassChangeError) ∧ (∃sfs'::sfields. sh C = ⌊(sfs', Processing)⌋)› 25. ‹⋀(e::char list exp) (a::heap) (aa::sfields) (b::sheap) (ba::bool) (e'::char list exp) (ab::heap) (ac::sfields) (bb::sheap) (b'::bool) (F::char list) (D::char list) e₂::char list exp. ⟦(P::(char list list × char list exp) prog) ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⟦not_init (C::char list) e; b C = ⌊(sfs::sfields, Processing)⌋⟧ ⟹ not_init C e' ∧ (∃sfs'::sfields. bb C = ⌊(sfs', Processing)⌋); not_init C (e∙F{D} := e₂); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (e'∙F{D} := e₂) ∧ (∃sfs'::sfields. bb C = ⌊(sfs', Processing)⌋)› 26. ‹⋀(e::char list exp) (a::heap) (aa::sfields) (b::sheap) (ba::bool) (e'::char list exp) (ab::heap) (ac::sfields) (bb::sheap) (b'::bool) (v::val) (F::char list) D::char list. ⟦(P::(char list list × char list exp) prog) ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⟦not_init (C::char list) e; b C = ⌊(sfs::sfields, Processing)⌋⟧ ⟹ not_init C e' ∧ (∃sfs'::sfields. bb C = ⌊(sfs', Processing)⌋); not_init C (Val v∙F{D} := e); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (Val v∙F{D} := e') ∧ (∃sfs'::sfields. bb C = ⌊(sfs', Processing)⌋)› 27. ‹⋀(Ca::char list) (F::char list) (t::ty) (D::char list) (h::heap) (a::nat) (fs::Objects.fields) (v::val) (l::sfields) (sh::sheap) b::bool. ⟦(P::(char list list × char list exp) prog) ⊢ Ca has F,NonStatic:t in D; h a = ⌊(Ca, fs)⌋; not_init (C::char list) (addr a∙F{D} := Val v); sh C = ⌊(sfs::sfields, Processing)⌋⟧ ⟹ not_init C unit ∧ (∃sfs'::sfields. sh C = ⌊(sfs', Processing)⌋)› 28. ‹⋀(F::char list) (D::char list) (v::val) (a::heap) (aa::sfields) (b::sheap) ba::bool. ⟦not_init (C::char list) (null∙F{D} := Val v); b C = ⌊(sfs::sfields, Processing)⌋⟧ ⟹ not_init C (THROW NullPointer) ∧ (∃sfs'::sfields. b C = ⌊(sfs', Processing)⌋)› 29. ‹⋀(h::heap) (a::nat) (Ca::char list) (fs::Objects.fields) (F::char list) (D::char list) (v::val) (l::sfields) (sh::sheap) b::bool. ⟦h a = ⌊(Ca, fs)⌋; ∄(b::staticb) t::ty. (P::(char list list × char list exp) prog) ⊢ Ca has F,b:t in D; not_init (C::char list) (addr a∙F{D} := Val v); sh C = ⌊(sfs::sfields, Processing)⌋⟧ ⟹ not_init C (THROW NoSuchFieldError) ∧ (∃sfs'::sfields. sh C = ⌊(sfs', Processing)⌋)› 30. ‹⋀(h::heap) (a::nat) (Ca::char list) (fs::Objects.fields) (F::char list) (t::ty) (D::char list) (v::val) (l::sfields) (sh::sheap) b::bool. ⟦h a = ⌊(Ca, fs)⌋; (P::(char list list × char list exp) prog) ⊢ Ca has F,Static:t in D; not_init (C::char list) (addr a∙F{D} := Val v); sh C = ⌊(sfs::sfields, Processing)⌋⟧ ⟹ not_init C (THROW IncompatibleClassChangeError) ∧ (∃sfs'::sfields. sh C = ⌊(sfs', Processing)⌋)› 31. ‹⋀(e::char list exp) (a::heap) (aa::sfields) (b::sheap) (ba::bool) (e'::char list exp) (ab::heap) (ac::sfields) (bb::sheap) (b'::bool) (Ca::char list) (F::char list) D::char list. ⟦(P::(char list list × char list exp) prog) ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⟦not_init (C::char list) e; b C = ⌊(sfs::sfields, Processing)⌋⟧ ⟹ not_init C e' ∧ (∃sfs'::sfields. bb C = ⌊(sfs', Processing)⌋); not_init C (Ca∙⇩sF{D} := e); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (Ca∙⇩sF{D} := e') ∧ (∃sfs'::sfields. bb C = ⌊(sfs', Processing)⌋)› 32. ‹⋀(Ca::char list) (F::char list) (t::ty) (D::char list) (sh::sheap) (sfsa::sfields) (i::init_state) (sfs'::sfields) (v::val) (sh'::sheap) (h::heap) l::sfields. ⟦(P::(char list list × char list exp) prog) ⊢ Ca has F,Static:t in D; sh D = ⌊(sfsa, i)⌋; sfs' = sfsa(F ↦ v); sh' = sh(D ↦ (sfs', i)); not_init (C::char list) (Ca∙⇩sF{D} := Val v); sh C = ⌊(sfs::sfields, Processing)⌋⟧ ⟹ not_init C unit ∧ (∃sfs'::sfields. sh' C = ⌊(sfs', Processing)⌋)› 33. ‹⋀(Ca::char list) (F::char list) (t::ty) (D::char list) (sh::sheap) (sfsa::sfields) (v::val) (h::heap) l::sfields. ⟦(P::(char list list × char list exp) prog) ⊢ Ca has F,Static:t in D; sh D = ⌊(sfsa, Done)⌋; not_init (C::char list) (Ca∙⇩sF{D} := Val v); sh C = ⌊(sfs::sfields, Processing)⌋⟧ ⟹ not_init C (Ca∙⇩sF{D} := Val v) ∧ (∃sfs'::sfields. sh C = ⌊(sfs', Processing)⌋)› 34. ‹⋀(Ca::char list) (F::char list) (t::ty) (D::char list) (sh::sheap) (v::val) (h::heap) l::sfields. ⟦(P::(char list list × char list exp) prog) ⊢ Ca has F,Static:t in D; ∄sfs::sfields. sh D = ⌊(sfs, Done)⌋; not_init (C::char list) (Ca∙⇩sF{D} := Val v); sh C = ⌊(sfs::sfields, Processing)⌋⟧ ⟹ not_init C (INIT D ([D],False) ← Ca∙⇩sF{D} := Val v) ∧ (∃sfs'::sfields. sh C = ⌊(sfs', Processing)⌋)› 35. ‹⋀(Ca::char list) (F::char list) (D::char list) (v::val) (a::heap) (aa::sfields) (b::sheap) ba::bool. ⟦∄(b::staticb) t::ty. (P::(char list list × char list exp) prog) ⊢ Ca has F,b:t in D; not_init (C::char list) (Ca∙⇩sF{D} := Val v); b C = ⌊(sfs::sfields, Processing)⌋⟧ ⟹ not_init C (THROW NoSuchFieldError) ∧ (∃sfs'::sfields. b C = ⌊(sfs', Processing)⌋)› 36. ‹⋀(Ca::char list) (F::char list) (t::ty) (D::char list) (v::val) (a::heap) (aa::sfields) (b::sheap) ba::bool. ⟦(P::(char list list × char list exp) prog) ⊢ Ca has F,NonStatic:t in D; not_init (C::char list) (Ca∙⇩sF{D} := Val v); b C = ⌊(sfs::sfields, Processing)⌋⟧ ⟹ not_init C (THROW IncompatibleClassChangeError) ∧ (∃sfs'::sfields. b C = ⌊(sfs', Processing)⌋)› 37. ‹⋀(e::char list exp) (a::heap) (aa::sfields) (b::sheap) (ba::bool) (e'::char list exp) (ab::heap) (ac::sfields) (bb::sheap) (b'::bool) (M::char list) es::char list exp list. ⟦(P::(char list list × char list exp) prog) ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⟦not_init (C::char list) e; b C = ⌊(sfs::sfields, Processing)⌋⟧ ⟹ not_init C e' ∧ (∃sfs'::sfields. bb C = ⌊(sfs', Processing)⌋); not_init C (e∙M(es)); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (e'∙M(es)) ∧ (∃sfs'::sfields. bb C = ⌊(sfs', Processing)⌋)› 38. ‹⋀(es::char list exp list) (a::heap) (aa::sfields) (b::sheap) (ba::bool) (es'::char list exp list) (ab::heap) (ac::sfields) (bb::sheap) (b'::bool) (v::val) M::char list. ⟦(P::(char list list × char list exp) prog) ⊢ ⟨es,(a, aa, b),ba⟩ [→] ⟨es',(ab, ac, bb),b'⟩; ⟦not_inits (C::char list) es; b C = ⌊(sfs::sfields, Processing)⌋⟧ ⟹ not_inits C es' ∧ (∃sfs'::sfields. bb C = ⌊(sfs', Processing)⌋); not_init C (Val v∙M(es)); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (Val v∙M(es')) ∧ (∃sfs'::sfields. bb C = ⌊(sfs', Processing)⌋)› 39. ‹⋀(M::char list) (vs::val list) (a::heap) (aa::sfields) (b::sheap) ba::bool. ⟦not_init (C::char list) (null∙M(map Val vs)); b C = ⌊(sfs::sfields, Processing)⌋⟧ ⟹ not_init C (THROW NullPointer) ∧ (∃sfs'::sfields. b C = ⌊(sfs', Processing)⌋)› 40. ‹⋀(h::heap) (a::nat) (Ca::char list) (fs::Objects.fields) (M::char list) (vs::val list) (l::sfields) (sh::sheap) b::bool. ⟦h a = ⌊(Ca, fs)⌋; ∄(b::staticb) (Ts::ty list) (T::ty) (m::char list list × char list exp) D::char list. (P::(char list list × char list exp) prog) ⊢ Ca sees M, b : Ts→T = m in D; not_init (C::char list) (addr a∙M(map Val vs)); sh C = ⌊(sfs::sfields, Processing)⌋⟧ ⟹ not_init C (THROW NoSuchMethodError) ∧ (∃sfs'::sfields. sh C = ⌊(sfs', Processing)⌋)› 41. ‹⋀(h::heap) (a::nat) (Ca::char list) (fs::Objects.fields) (M::char list) (Ts::ty list) (T::ty) (aa::char list list) (b::char list exp) (D::char list) (vs::val list) (l::sfields) (sh::sheap) ba::bool. ⟦h a = ⌊(Ca, fs)⌋; (P::(char list list × char list exp) prog) ⊢ Ca sees M, Static : Ts→T = (aa, b) in D; not_init (C::char list) (addr a∙M(map Val vs)); sh C = ⌊(sfs::sfields, Processing)⌋⟧ ⟹ not_init C (THROW IncompatibleClassChangeError) ∧ (∃sfs'::sfields. sh C = ⌊(sfs', Processing)⌋)› 42. ‹⋀(es::char list exp list) (a::heap) (aa::sfields) (b::sheap) (ba::bool) (es'::char list exp list) (ab::heap) (ac::sfields) (bb::sheap) (b'::bool) (Ca::char list) M::char list. ⟦(P::(char list list × char list exp) prog) ⊢ ⟨es,(a, aa, b),ba⟩ [→] ⟨es',(ab, ac, bb),b'⟩; ⟦not_inits (C::char list) es; b C = ⌊(sfs::sfields, Processing)⌋⟧ ⟹ not_inits C es' ∧ (∃sfs'::sfields. bb C = ⌊(sfs', Processing)⌋); not_init C (Ca∙⇩sM(es)); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (Ca∙⇩sM(es')) ∧ (∃sfs'::sfields. bb C = ⌊(sfs', Processing)⌋)› 43. ‹⋀(Ca::char list) (M::char list) (Ts::ty list) (T::ty) (pns::char list list) (body::char list exp) (D::char list) (sh::sheap) (sfsa::sfields) (vs::val list) (h::heap) l::sfields. ⟦(P::(char list list × char list exp) prog) ⊢ Ca sees M, Static : Ts→T = (pns, body) in D; sh D = ⌊(sfsa, Done)⌋ ∨ M = clinit ∧ sh D = ⌊(sfsa, Processing)⌋; not_init (C::char list) (Ca∙⇩sM(map Val vs)); sh C = ⌊(sfs::sfields, Processing)⌋⟧ ⟹ not_init C (Ca∙⇩sM(map Val vs)) ∧ (∃sfs'::sfields. sh C = ⌊(sfs', Processing)⌋)› 44. ‹⋀(Ca::char list) (M::char list) (Ts::ty list) (T::ty) (pns::char list list) (body::char list exp) (D::char list) (sh::sheap) (vs::val list) (h::heap) l::sfields. ⟦(P::(char list list × char list exp) prog) ⊢ Ca sees M, Static : Ts→T = (pns, body) in D; ∄sfs::sfields. sh D = ⌊(sfs, Done)⌋; M ≠ clinit; not_init (C::char list) (Ca∙⇩sM(map Val vs)); sh C = ⌊(sfs::sfields, Processing)⌋⟧ ⟹ not_init C (INIT D ([D],False) ← Ca∙⇩sM(map Val vs)) ∧ (∃sfs'::sfields. sh C = ⌊(sfs', Processing)⌋)› 45. ‹⋀(Ca::char list) (M::char list) (vs::val list) (a::heap) (aa::sfields) (b::sheap) ba::bool. ⟦∄(b::staticb) (Ts::ty list) (T::ty) m::char list list × char list exp. Ex (Method (P::(char list list × char list exp) prog) Ca M b Ts T m); not_init (C::char list) (Ca∙⇩sM(map Val vs)); b C = ⌊(sfs::sfields, Processing)⌋⟧ ⟹ not_init C (THROW NoSuchMethodError) ∧ (∃sfs'::sfields. b C = ⌊(sfs', Processing)⌋)› 46. ‹⋀(Ca::char list) (M::char list) (Ts::ty list) (T::ty) (a::char list list) (b::char list exp) (D::char list) (vs::val list) (aa::heap) (ab::sfields) (ba::sheap) bb::bool. ⟦(P::(char list list × char list exp) prog) ⊢ Ca sees M, NonStatic : Ts→T = (a, b) in D; not_init (C::char list) (Ca∙⇩sM(map Val vs)); ba C = ⌊(sfs::sfields, Processing)⌋⟧ ⟹ not_init C (THROW IncompatibleClassChangeError) ∧ (∃sfs'::sfields. ba C = ⌊(sfs', Processing)⌋)› 47. ‹⋀(e::char list exp) (h::heap) (l::sfields) (V::char list) (sh::sheap) (b::bool) (e'::char list exp) (h'::heap) (l'::sfields) (sh'::sheap) (b'::bool) T::ty. ⟦(P::(char list list × char list exp) prog) ⊢ ⟨e,(h, l(V := None), sh),b⟩ → ⟨e',(h', l', sh'),b'⟩; ⟦not_init (C::char list) e; sh C = ⌊(sfs::sfields, Processing)⌋⟧ ⟹ not_init C e' ∧ (∃sfs'::sfields. sh' C = ⌊(sfs', Processing)⌋); l' V = None; ¬ assigned V e; not_init C {V:T; e}; sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C {V:T; e'} ∧ (∃sfs'::sfields. sh' C = ⌊(sfs', Processing)⌋)› 48. ‹⋀(e::char list exp) (h::heap) (l::sfields) (V::char list) (sh::sheap) (b::bool) (e'::char list exp) (h'::heap) (l'::sfields) (sh'::sheap) (b'::bool) (v::val) T::ty. ⟦(P::(char list list × char list exp) prog) ⊢ ⟨e,(h, l(V := None), sh),b⟩ → ⟨e',(h', l', sh'),b'⟩; ⟦not_init (C::char list) e; sh C = ⌊(sfs::sfields, Processing)⌋⟧ ⟹ not_init C e' ∧ (∃sfs'::sfields. sh' C = ⌊(sfs', Processing)⌋); l' V = ⌊v⌋; ¬ assigned V e; not_init C {V:T; e}; sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C {V:T; V:=Val v;; e'} ∧ (∃sfs'::sfields. sh' C = ⌊(sfs', Processing)⌋)› 49. ‹⋀(e::char list exp) (h::heap) (l::sfields) (V::char list) (v::val) (sh::sheap) (b::bool) (e'::char list exp) (h'::heap) (l'::sfields) (sh'::sheap) (b'::bool) (v'::val) T::ty. ⟦(P::(char list list × char list exp) prog) ⊢ ⟨e,(h, l(V ↦ v), sh),b⟩ → ⟨e',(h', l', sh'),b'⟩; ⟦not_init (C::char list) e; sh C = ⌊(sfs::sfields, Processing)⌋⟧ ⟹ not_init C e' ∧ (∃sfs'::sfields. sh' C = ⌊(sfs', Processing)⌋); l' V = ⌊v'⌋; not_init C {V:T; V:=Val v;; e}; sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C {V:T; V:=Val v';; e'} ∧ (∃sfs'::sfields. sh' C = ⌊(sfs', Processing)⌋)› 50. ‹⋀(V::char list) (T::ty) (u::val) (a::heap) (aa::sfields) (b::sheap) ba::bool. ⟦not_init (C::char list) {V:T; Val u}; b C = ⌊(sfs::sfields, Processing)⌋⟧ ⟹ not_init C (Val u) ∧ (∃sfs'::sfields. b C = ⌊(sfs', Processing)⌋)› 51. ‹⋀(V::char list) (T::ty) (v::val) (u::val) (a::heap) (aa::sfields) (b::sheap) ba::bool. ⟦not_init (C::char list) {V:T; V:=Val v;; Val u}; b C = ⌊(sfs::sfields, Processing)⌋⟧ ⟹ not_init C (Val u) ∧ (∃sfs'::sfields. b C = ⌊(sfs', Processing)⌋)› 52. ‹⋀(e::char list exp) (a::heap) (aa::sfields) (b::sheap) (ba::bool) (e'::char list exp) (ab::heap) (ac::sfields) (bb::sheap) (b'::bool) e₂::char list exp. ⟦(P::(char list list × char list exp) prog) ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⟦not_init (C::char list) e; b C = ⌊(sfs::sfields, Processing)⌋⟧ ⟹ not_init C e' ∧ (∃sfs'::sfields. bb C = ⌊(sfs', Processing)⌋); not_init C (e;; e₂); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (e';; e₂) ∧ (∃sfs'::sfields. bb C = ⌊(sfs', Processing)⌋)› 53. ‹⋀(v::val) (e₂::char list exp) (a::heap) (aa::sfields) (b::sheap) ba::bool. ⟦not_init (C::char list) (Val v;; e₂); b C = ⌊(sfs::sfields, Processing)⌋⟧ ⟹ not_init C e₂ ∧ (∃sfs'::sfields. b C = ⌊(sfs', Processing)⌋)› 54. ‹⋀(e::char list exp) (a::heap) (aa::sfields) (b::sheap) (ba::bool) (e'::char list exp) (ab::heap) (ac::sfields) (bb::sheap) (b'::bool) (e₁::char list exp) e₂::char list exp. ⟦(P::(char list list × char list exp) prog) ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⟦not_init (C::char list) e; b C = ⌊(sfs::sfields, Processing)⌋⟧ ⟹ not_init C e' ∧ (∃sfs'::sfields. bb C = ⌊(sfs', Processing)⌋); not_init C (if (e) e₁ else e₂); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (if (e') e₁ else e₂) ∧ (∃sfs'::sfields. bb C = ⌊(sfs', Processing)⌋)› 55. ‹⋀(e₁::char list exp) (e₂::char list exp) (a::heap) (aa::sfields) (b::sheap) ba::bool. ⟦not_init (C::char list) (if (true) e₁ else e₂); b C = ⌊(sfs::sfields, Processing)⌋⟧ ⟹ not_init C e₁ ∧ (∃sfs'::sfields. b C = ⌊(sfs', Processing)⌋)› 56. ‹⋀(e₁::char list exp) (e₂::char list exp) (a::heap) (aa::sfields) (b::sheap) ba::bool. ⟦not_init (C::char list) (if (false) e₁ else e₂); b C = ⌊(sfs::sfields, Processing)⌋⟧ ⟹ not_init C e₂ ∧ (∃sfs'::sfields. b C = ⌊(sfs', Processing)⌋)› 57. ‹⋀(b::char list exp) (c::char list exp) (a::heap) (aa::sfields) (ba::sheap) b'::bool. ⟦not_init (C::char list) (while (b) c); ba C = ⌊(sfs::sfields, Processing)⌋⟧ ⟹ not_init C (if (b) (c;; while (b) c) else unit) ∧ (∃sfs'::sfields. ba C = ⌊(sfs', Processing)⌋)› 58. ‹⋀(e::char list exp) (a::heap) (aa::sfields) (b::sheap) (ba::bool) (e'::char list exp) (ab::heap) (ac::sfields) (bb::sheap) b'::bool. ⟦(P::(char list list × char list exp) prog) ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⟦not_init (C::char list) e; b C = ⌊(sfs::sfields, Processing)⌋⟧ ⟹ not_init C e' ∧ (∃sfs'::sfields. bb C = ⌊(sfs', Processing)⌋); not_init C (throw e); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (throw e') ∧ (∃sfs'::sfields. bb C = ⌊(sfs', Processing)⌋)› 59. ‹⋀(a::heap) (aa::sfields) (b::sheap) ba::bool. ⟦not_init (C::char list) (throw null); b C = ⌊(sfs::sfields, Processing)⌋⟧ ⟹ not_init C (THROW NullPointer) ∧ (∃sfs'::sfields. b C = ⌊(sfs', Processing)⌋)› 60. ‹⋀(e::char list exp) (a::heap) (aa::sfields) (b::sheap) (ba::bool) (e'::char list exp) (ab::heap) (ac::sfields) (bb::sheap) (b'::bool) (Ca::char list) (V::char list) e₂::char list exp. ⟦(P::(char list list × char list exp) prog) ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⟦not_init (C::char list) e; b C = ⌊(sfs::sfields, Processing)⌋⟧ ⟹ not_init C e' ∧ (∃sfs'::sfields. bb C = ⌊(sfs', Processing)⌋); not_init C (try e catch(Ca V) e₂); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (try e' catch(Ca V) e₂) ∧ (∃sfs'::sfields. bb C = ⌊(sfs', Processing)⌋)› 61. ‹⋀(v::val) (Ca::char list) (V::char list) (e₂::char list exp) (a::heap) (aa::sfields) (b::sheap) ba::bool. ⟦not_init (C::char list) (try Val v catch(Ca V) e₂); b C = ⌊(sfs::sfields, Processing)⌋⟧ ⟹ not_init C (Val v) ∧ (∃sfs'::sfields. b C = ⌊(sfs', Processing)⌋)› 62. ‹⋀(a::heap) (aa::sfields) (b::sheap) (ab::nat) (D::char list) (fs::Objects.fields) (Ca::char list) (V::char list) (e₂::char list exp) ba::bool. ⟦hp (a, aa, b) ab = ⌊(D, fs)⌋; (P::(char list list × char list exp) prog) ⊢ D ≼⇧* Ca; not_init (C::char list) (try Throw ab catch(Ca V) e₂); b C = ⌊(sfs::sfields, Processing)⌋⟧ ⟹ not_init C {V:Class Ca; V:=addr ab;; e₂} ∧ (∃sfs'::sfields. b C = ⌊(sfs', Processing)⌋)› 63. ‹⋀(a::heap) (aa::sfields) (b::sheap) (ab::nat) (D::char list) (fs::Objects.fields) (Ca::char list) (V::char list) (e₂::char list exp) ba::bool. ⟦hp (a, aa, b) ab = ⌊(D, fs)⌋; (D, Ca) ∉ (subcls1 (P::(char list list × char list exp) prog))⇧*; not_init (C::char list) (try Throw ab catch(Ca V) e₂); b C = ⌊(sfs::sfields, Processing)⌋⟧ ⟹ not_init C (Throw ab) ∧ (∃sfs'::sfields. b C = ⌊(sfs', Processing)⌋)› 64. ‹⋀(e::char list exp) (a::heap) (aa::sfields) (b::sheap) (ba::bool) (e'::char list exp) (ab::heap) (ac::sfields) (bb::sheap) (b'::bool) es::char list exp list. ⟦(P::(char list list × char list exp) prog) ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⟦not_init (C::char list) e; b C = ⌊(sfs::sfields, Processing)⌋⟧ ⟹ not_init C e' ∧ (∃sfs'::sfields. bb C = ⌊(sfs', Processing)⌋); not_inits C (e # es); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_inits C (e' # es) ∧ (∃sfs'::sfields. bb C = ⌊(sfs', Processing)⌋)› 65. ‹⋀(es::char list exp list) (a::heap) (aa::sfields) (b::sheap) (ba::bool) (es'::char list exp list) (ab::heap) (ac::sfields) (bb::sheap) (b'::bool) v::val. ⟦(P::(char list list × char list exp) prog) ⊢ ⟨es,(a, aa, b),ba⟩ [→] ⟨es',(ab, ac, bb),b'⟩; ⟦not_inits (C::char list) es; b C = ⌊(sfs::sfields, Processing)⌋⟧ ⟹ not_inits C es' ∧ (∃sfs'::sfields. bb C = ⌊(sfs', Processing)⌋); not_inits C (Val v # es); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_inits C (Val v # es') ∧ (∃sfs'::sfields. bb C = ⌊(sfs', Processing)⌋)› 66. ‹⋀(e::char list exp) (Ca::char list) (b::bool) (a::heap) (aa::sfields) (ba::sheap) b'::bool. ⟦¬ sub_RI e; not_init (C::char list) (INIT Ca ([],b) ← e); ba C = ⌊(sfs::sfields, Processing)⌋⟧ ⟹ not_init C e ∧ (∃sfs'::sfields. ba C = ⌊(sfs', Processing)⌋)› 67. ‹⋀(sh::sheap) (Ca::char list) (C'::char list) (Cs::char list list) (e::char list exp) (h::heap) (l::sfields) b::bool. ⟦sh Ca = None; not_init (C::char list) (INIT C' (Ca # Cs,False) ← e); sh C = ⌊(sfs::sfields, Processing)⌋⟧ ⟹ not_init C (INIT C' (Ca # Cs,False) ← e) ∧ (∃sfs'::sfields. (sh(Ca ↦ (sblank (P::(char list list × char list exp) prog) Ca, Prepared))) C = ⌊(sfs', Processing)⌋)› 68. ‹⋀(sh::sheap) (Ca::char list) (sfsa::sfields) (C'::char list) (Cs::char list list) (e::char list exp) (h::heap) (l::sfields) b::bool. ⟦sh Ca = ⌊(sfsa, Error)⌋; not_init (C::char list) (INIT C' (Ca # Cs,False) ← e); sh C = ⌊(sfs::sfields, Processing)⌋⟧ ⟹ not_init C (RI (Ca,THROW NoClassDefFoundError) ; Cs ← e) ∧ (∃sfs'::sfields. sh C = ⌊(sfs', Processing)⌋)› 69. ‹⋀(sh::sheap) (Ca::char list) (sfsa::sfields) (sh'::sheap) (C'::char list) (Cs::char list list) (e::char list exp) (h::heap) (l::sfields) b::bool. ⟦sh Ca = ⌊(sfsa, Prepared)⌋; Ca = Object; sh' = sh(Ca ↦ (sfsa, Processing)); not_init (C::char list) (INIT C' (Ca # Cs,False) ← e); sh C = ⌊(sfs::sfields, Processing)⌋⟧ ⟹ not_init C (INIT C' (Ca # Cs,True) ← e) ∧ (∃sfs'::sfields. sh' C = ⌊(sfs', Processing)⌋)› 70. ‹⋀(sh::sheap) (Ca::char list) (sfsa::sfields) (D::char list) (a::fdecl list) (b::(char list list × char list exp) mdecl list) (sh'::sheap) (C'::char list) (Cs::char list list) (e::char list exp) (h::heap) (l::sfields) ba::bool. ⟦sh Ca = ⌊(sfsa, Prepared)⌋; Ca ≠ Object; class (P::(char list list × char list exp) prog) Ca = ⌊(D, a, b)⌋; sh' = sh(Ca ↦ (sfsa, Processing)); not_init (C::char list) (INIT C' (Ca # Cs,False) ← e); sh C = ⌊(sfs::sfields, Processing)⌋⟧ ⟹ not_init C (INIT C' (D # Ca # Cs,False) ← e) ∧ (∃sfs'::sfields. sh' C = ⌊(sfs', Processing)⌋)› 71. ‹⋀(C'::char list) (Ca::char list) (Cs::char list list) (e::char list exp) (h::heap) (l::sfields) (sh::sheap) b::bool. ⟦not_init (C::char list) (INIT C' (Ca # Cs,True) ← e); sh C = ⌊(sfs::sfields, Processing)⌋⟧ ⟹ not_init C (RI (Ca,Ca∙⇩sclinit([])) ; Cs ← e) ∧ (∃sfs'::sfields. sh C = ⌊(sfs', Processing)⌋)› 72. ‹⋀(e::char list exp) (a::heap) (aa::sfields) (b::sheap) (ba::bool) (e'::char list exp) (ab::heap) (ac::sfields) (bb::sheap) (b'::bool) (Ca::char list) (Cs::char list list) e₀::char list exp. ⟦(P::(char list list × char list exp) prog) ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⟦not_init (C::char list) e; b C = ⌊(sfs::sfields, Processing)⌋⟧ ⟹ not_init C e' ∧ (∃sfs'::sfields. bb C = ⌊(sfs', Processing)⌋); not_init C (RI (Ca,e) ; Cs ← e₀); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (RI (Ca,e') ; Cs ← e₀) ∧ (∃sfs'::sfields. bb C = ⌊(sfs', Processing)⌋)› 73. ‹⋀(Ca::char list) (e::char list exp) (a::heap) (aa::sfields) (b::sheap) ba::bool. ⟦not_init (C::char list) (Cast Ca (throw e)); b C = ⌊(sfs::sfields, Processing)⌋⟧ ⟹ not_init C (throw e) ∧ (∃sfs'::sfields. b C = ⌊(sfs', Processing)⌋)› 74. ‹⋀(e::char list exp) (bop::bop) (e₂::char list exp) (a::heap) (aa::sfields) (b::sheap) ba::bool. ⟦not_init (C::char list) (throw e «bop» e₂); b C = ⌊(sfs::sfields, Processing)⌋⟧ ⟹ not_init C (throw e) ∧ (∃sfs'::sfields. b C = ⌊(sfs', Processing)⌋)› 75. ‹⋀(v₁::val) (bop::bop) (e::char list exp) (a::heap) (aa::sfields) (b::sheap) ba::bool. ⟦not_init (C::char list) (Val v₁ «bop» throw e); b C = ⌊(sfs::sfields, Processing)⌋⟧ ⟹ not_init C (throw e) ∧ (∃sfs'::sfields. b C = ⌊(sfs', Processing)⌋)› 76. ‹⋀(V::char list) (e::char list exp) (a::heap) (aa::sfields) (b::sheap) ba::bool. ⟦not_init (C::char list) (V:=throw e); b C = ⌊(sfs::sfields, Processing)⌋⟧ ⟹ not_init C (throw e) ∧ (∃sfs'::sfields. b C = ⌊(sfs', Processing)⌋)› 77. ‹⋀(e::char list exp) (F::char list) (D::char list) (a::heap) (aa::sfields) (b::sheap) ba::bool. ⟦not_init (C::char list) (throw e∙F{D}); b C = ⌊(sfs::sfields, Processing)⌋⟧ ⟹ not_init C (throw e) ∧ (∃sfs'::sfields. b C = ⌊(sfs', Processing)⌋)› 78. ‹⋀(e::char list exp) (F::char list) (D::char list) (e₂::char list exp) (a::heap) (aa::sfields) (b::sheap) ba::bool. ⟦not_init (C::char list) (throw e∙F{D} := e₂); b C = ⌊(sfs::sfields, Processing)⌋⟧ ⟹ not_init C (throw e) ∧ (∃sfs'::sfields. b C = ⌊(sfs', Processing)⌋)› 79. ‹⋀(v::val) (F::char list) (D::char list) (e::char list exp) (a::heap) (aa::sfields) (b::sheap) ba::bool. ⟦not_init (C::char list) (Val v∙F{D} := throw e); b C = ⌊(sfs::sfields, Processing)⌋⟧ ⟹ not_init C (throw e) ∧ (∃sfs'::sfields. b C = ⌊(sfs', Processing)⌋)› 80. ‹⋀(Ca::char list) (F::char list) (D::char list) (e::char list exp) (a::heap) (aa::sfields) (b::sheap) ba::bool. ⟦not_init (C::char list) (Ca∙⇩sF{D} := throw e); b C = ⌊(sfs::sfields, Processing)⌋⟧ ⟹ not_init C (throw e) ∧ (∃sfs'::sfields. b C = ⌊(sfs', Processing)⌋)› 81. ‹⋀(e::char list exp) (M::char list) (es::char list exp list) (a::heap) (aa::sfields) (b::sheap) ba::bool. ⟦not_init (C::char list) (throw e∙M(es)); b C = ⌊(sfs::sfields, Processing)⌋⟧ ⟹ not_init C (throw e) ∧ (∃sfs'::sfields. b C = ⌊(sfs', Processing)⌋)› 82. ‹⋀(es::char list exp list) (vs::val list) (e::char list exp) (es'::char list exp list) (Ca::char list) (M::char list) (a::heap) (aa::sfields) (b::sheap) ba::bool. ⟦es = map Val vs @ throw e # es'; not_init (C::char list) (Ca∙⇩sM(es)); b C = ⌊(sfs::sfields, Processing)⌋⟧ ⟹ not_init C (throw e) ∧ (∃sfs'::sfields. b C = ⌊(sfs', Processing)⌋)› 83. ‹⋀(V::char list) (T::ty) (a::nat) (aa::heap) (ab::sfields) (b::sheap) ba::bool. ⟦not_init (C::char list) {V:T; Throw a}; b C = ⌊(sfs::sfields, Processing)⌋⟧ ⟹ not_init C (Throw a) ∧ (∃sfs'::sfields. b C = ⌊(sfs', Processing)⌋)› 84. ‹⋀(V::char list) (T::ty) (v::val) (a::nat) (aa::heap) (ab::sfields) (b::sheap) ba::bool. ⟦not_init (C::char list) {V:T; V:=Val v;; Throw a}; b C = ⌊(sfs::sfields, Processing)⌋⟧ ⟹ not_init C (Throw a) ∧ (∃sfs'::sfields. b C = ⌊(sfs', Processing)⌋)› 85. ‹⋀(e::char list exp) (e₂::char list exp) (a::heap) (aa::sfields) (b::sheap) ba::bool. ⟦not_init (C::char list) (throw e;; e₂); b C = ⌊(sfs::sfields, Processing)⌋⟧ ⟹ not_init C (throw e) ∧ (∃sfs'::sfields. b C = ⌊(sfs', Processing)⌋)› 86. ‹⋀(e::char list exp) (e₁::char list exp) (e₂::char list exp) (a::heap) (aa::sfields) (b::sheap) ba::bool. ⟦not_init (C::char list) (if (throw e) e₁ else e₂); b C = ⌊(sfs::sfields, Processing)⌋⟧ ⟹ not_init C (throw e) ∧ (∃sfs'::sfields. b C = ⌊(sfs', Processing)⌋)› 87. ‹⋀(e::char list exp) (a::heap) (aa::sfields) (b::sheap) ba::bool. ⟦not_init (C::char list) (throw (throw e)); b C = ⌊(sfs::sfields, Processing)⌋⟧ ⟹ not_init C (throw e) ∧ (∃sfs'::sfields. b C = ⌊(sfs', Processing)⌋)› 88. ‹⋀(sh::sheap) (Ca::char list) (sfsa::sfields) (i::init_state) (sh'::sheap) (a::nat) (D::char list) (Cs::char list list) (e::char list exp) (h::heap) (l::sfields) b::bool. ⟦sh Ca = ⌊(sfsa, i)⌋; sh' = sh(Ca ↦ (sfsa, Error)); not_init (C::char list) (RI (Ca,Throw a) ; D # Cs ← e); sh C = ⌊(sfs::sfields, Processing)⌋⟧ ⟹ not_init C (RI (D,Throw a) ; Cs ← e) ∧ (∃sfs'::sfields. sh' C = ⌊(sfs', Processing)⌋)› 89. ‹⋀(sh::sheap) (Ca::char list) (sfsa::sfields) (i::init_state) (sh'::sheap) (a::nat) (e::char list exp) (h::heap) (l::sfields) b::bool. ⟦sh Ca = ⌊(sfsa, i)⌋; sh' = sh(Ca ↦ (sfsa, Error)); not_init (C::char list) (RI (Ca,Throw a) ; [] ← e); sh C = ⌊(sfs::sfields, Processing)⌋⟧ ⟹ not_init C (Throw a) ∧ (∃sfs'::sfields. sh' C = ⌊(sfs', Processing)⌋)›*) case (SCallThrowParams es vs e es' C M h l sh b) (*‹es = map Val vs @ throw e # es'› ‹not_init (C::char list) ((C::char list)∙⇩s(M::char list)(es::char list exp list))› ‹sh C = ⌊(sfs, Processing)⌋›*) then show "?case" (*goal: ‹not_init C (throw e) ∧ (∃sfs'. sh C = ⌊(sfs', Processing)⌋)›*) by (auto dest: not_inits_def' (*‹not_inits (?C::char list) (?es::?'a exp list) ⟹ ∀e::?'a exp∈set ?es. not_init ?C e›*)) qed (auto) (*solves the remaining goals: 1. ‹⋀h a Ca FDTs h' l sh. ⟦new_Addr h = ⌊a⌋; P ⊢ Ca has_fields FDTs; h' = h(a ↦ blank P Ca); not_init C (new Ca); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (addr a) ∧ (∃sfs'. sh C = ⌊(sfs', Processing)⌋)› 2. ‹⋀h Ca l sh. ⟦new_Addr h = None; is_class P Ca; not_init C (new Ca); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (THROW OutOfMemory) ∧ (∃sfs'. sh C = ⌊(sfs', Processing)⌋)› 3. ‹⋀sh Ca sfsa h l. ⟦sh Ca = ⌊(sfsa, Done)⌋; not_init C (new Ca); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (new Ca) ∧ (∃sfs'. sh C = ⌊(sfs', Processing)⌋)› 4. ‹⋀sh Ca h l. ⟦∄sfs. sh Ca = ⌊(sfs, Done)⌋; is_class P Ca; not_init C (new Ca); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (INIT Ca ([Ca],False) ← new Ca) ∧ (∃sfs'. sh C = ⌊(sfs', Processing)⌋)› 5. ‹⋀e a aa b ba e' ab ac bb b' Ca. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⟦not_init C e; b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C e' ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋); not_init C (Cast Ca e); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (Cast Ca e') ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋)› 6. ‹⋀Ca a aa b ba. ⟦not_init C (Cast Ca null); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C null ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 7. ‹⋀h a D fs Ca l sh b. ⟦h a = ⌊(D, fs)⌋; P ⊢ D ≼⇧* Ca; not_init C (Cast Ca (addr a)); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (addr a) ∧ (∃sfs'. sh C = ⌊(sfs', Processing)⌋)› 8. ‹⋀h a D fs Ca l sh b. ⟦h a = ⌊(D, fs)⌋; (D, Ca) ∉ (subcls1 P)⇧*; not_init C (Cast Ca (addr a)); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (THROW ClassCast) ∧ (∃sfs'. sh C = ⌊(sfs', Processing)⌋)› 9. ‹⋀e a aa b ba e' ab ac bb b' bop e₂. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⟦not_init C e; b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C e' ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋); not_init C (e «bop» e₂); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (e' «bop» e₂) ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋)› 10. ‹⋀e a aa b ba e' ab ac bb b' v₁ bop. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⟦not_init C e; b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C e' ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋); not_init C (Val v₁ «bop» e); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (Val v₁ «bop» e') ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋)› 11. ‹⋀bop v₁ v₂ v a aa b ba. ⟦binop (bop, v₁, v₂) = ⌊v⌋; not_init C (Val v₁ «bop» Val v₂); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (Val v) ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 12. ‹⋀l V v h sh b. ⟦l V = ⌊v⌋; not_init C (Var V); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (Val v) ∧ (∃sfs'. sh C = ⌊(sfs', Processing)⌋)› 13. ‹⋀e a aa b ba e' ab ac bb b' V. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⟦not_init C e; b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C e' ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋); not_init C (V:=e); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (V:=e') ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋)› 14. ‹⋀V v h l sh b. ⟦not_init C (V:=Val v); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C unit ∧ (∃sfs'. sh C = ⌊(sfs', Processing)⌋)› 15. ‹⋀e a aa b ba e' ab ac bb b' F D. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⟦not_init C e; b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C e' ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋); not_init C (e∙F{D}); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (e'∙F{D}) ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋)› 16. ‹⋀h a Ca fs F D v t l sh b. ⟦h a = ⌊(Ca, fs)⌋; fs (F, D) = ⌊v⌋; P ⊢ Ca has F,NonStatic:t in D; not_init C (addr a∙F{D}); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (Val v) ∧ (∃sfs'. sh C = ⌊(sfs', Processing)⌋)› 17. ‹⋀F D a aa b ba. ⟦not_init C (null∙F{D}); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (THROW NullPointer) ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 18. ‹⋀h a Ca fs F D l sh b. ⟦h a = ⌊(Ca, fs)⌋; ∄b t. P ⊢ Ca has F,b:t in D; not_init C (addr a∙F{D}); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (THROW NoSuchFieldError) ∧ (∃sfs'. sh C = ⌊(sfs', Processing)⌋)› 19. ‹⋀h a Ca fs F t D l sh b. ⟦h a = ⌊(Ca, fs)⌋; P ⊢ Ca has F,Static:t in D; not_init C (addr a∙F{D}); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (THROW IncompatibleClassChangeError) ∧ (∃sfs'. sh C = ⌊(sfs', Processing)⌋)› 20. ‹⋀Ca F t D sh sfsa i v h l. ⟦P ⊢ Ca has F,Static:t in D; sh D = ⌊(sfsa, i)⌋; sfsa F = ⌊v⌋; not_init C (Ca∙⇩sF{D}); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (Val v) ∧ (∃sfs'. sh C = ⌊(sfs', Processing)⌋)› 21. ‹⋀Ca F t D sh sfsa h l. ⟦P ⊢ Ca has F,Static:t in D; sh D = ⌊(sfsa, Done)⌋; not_init C (Ca∙⇩sF{D}); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (Ca∙⇩sF{D}) ∧ (∃sfs'. sh C = ⌊(sfs', Processing)⌋)› 22. ‹⋀Ca F t D sh h l. ⟦P ⊢ Ca has F,Static:t in D; ∄sfs. sh D = ⌊(sfs, Done)⌋; not_init C (Ca∙⇩sF{D}); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (INIT D ([D],False) ← Ca∙⇩sF{D}) ∧ (∃sfs'. sh C = ⌊(sfs', Processing)⌋)› 23. ‹⋀Ca F D h l sh b. ⟦∄b t. P ⊢ Ca has F,b:t in D; not_init C (Ca∙⇩sF{D}); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (THROW NoSuchFieldError) ∧ (∃sfs'. sh C = ⌊(sfs', Processing)⌋)› 24. ‹⋀Ca F t D h l sh b. ⟦P ⊢ Ca has F,NonStatic:t in D; not_init C (Ca∙⇩sF{D}); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (THROW IncompatibleClassChangeError) ∧ (∃sfs'. sh C = ⌊(sfs', Processing)⌋)› 25. ‹⋀e a aa b ba e' ab ac bb b' F D e₂. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⟦not_init C e; b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C e' ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋); not_init C (e∙F{D} := e₂); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (e'∙F{D} := e₂) ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋)› 26. ‹⋀e a aa b ba e' ab ac bb b' v F D. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⟦not_init C e; b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C e' ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋); not_init C (Val v∙F{D} := e); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (Val v∙F{D} := e') ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋)› 27. ‹⋀Ca F t D h a fs v l sh b. ⟦P ⊢ Ca has F,NonStatic:t in D; h a = ⌊(Ca, fs)⌋; not_init C (addr a∙F{D} := Val v); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C unit ∧ (∃sfs'. sh C = ⌊(sfs', Processing)⌋)› 28. ‹⋀F D v a aa b ba. ⟦not_init C (null∙F{D} := Val v); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (THROW NullPointer) ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 29. ‹⋀h a Ca fs F D v l sh b. ⟦h a = ⌊(Ca, fs)⌋; ∄b t. P ⊢ Ca has F,b:t in D; not_init C (addr a∙F{D} := Val v); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (THROW NoSuchFieldError) ∧ (∃sfs'. sh C = ⌊(sfs', Processing)⌋)› 30. ‹⋀h a Ca fs F t D v l sh b. ⟦h a = ⌊(Ca, fs)⌋; P ⊢ Ca has F,Static:t in D; not_init C (addr a∙F{D} := Val v); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (THROW IncompatibleClassChangeError) ∧ (∃sfs'. sh C = ⌊(sfs', Processing)⌋)› 31. ‹⋀e a aa b ba e' ab ac bb b' Ca F D. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⟦not_init C e; b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C e' ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋); not_init C (Ca∙⇩sF{D} := e); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (Ca∙⇩sF{D} := e') ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋)› 32. ‹⋀Ca F t D sh sfsa i sfs' v sh' h l. ⟦P ⊢ Ca has F,Static:t in D; sh D = ⌊(sfsa, i)⌋; sfs' = sfsa(F ↦ v); sh' = sh(D ↦ (sfs', i)); not_init C (Ca∙⇩sF{D} := Val v); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C unit ∧ (∃sfs'. sh' C = ⌊(sfs', Processing)⌋)› 33. ‹⋀Ca F t D sh sfsa v h l. ⟦P ⊢ Ca has F,Static:t in D; sh D = ⌊(sfsa, Done)⌋; not_init C (Ca∙⇩sF{D} := Val v); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (Ca∙⇩sF{D} := Val v) ∧ (∃sfs'. sh C = ⌊(sfs', Processing)⌋)› 34. ‹⋀Ca F t D sh v h l. ⟦P ⊢ Ca has F,Static:t in D; ∄sfs. sh D = ⌊(sfs, Done)⌋; not_init C (Ca∙⇩sF{D} := Val v); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (INIT D ([D],False) ← Ca∙⇩sF{D} := Val v) ∧ (∃sfs'. sh C = ⌊(sfs', Processing)⌋)› 35. ‹⋀Ca F D v a aa b ba. ⟦∄b t. P ⊢ Ca has F,b:t in D; not_init C (Ca∙⇩sF{D} := Val v); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (THROW NoSuchFieldError) ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 36. ‹⋀Ca F t D v a aa b ba. ⟦P ⊢ Ca has F,NonStatic:t in D; not_init C (Ca∙⇩sF{D} := Val v); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (THROW IncompatibleClassChangeError) ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 37. ‹⋀e a aa b ba e' ab ac bb b' M es. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⟦not_init C e; b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C e' ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋); not_init C (e∙M(es)); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (e'∙M(es)) ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋)› 38. ‹⋀es a aa b ba es' ab ac bb b' v M. ⟦P ⊢ ⟨es,(a, aa, b),ba⟩ [→] ⟨es',(ab, ac, bb),b'⟩; ⟦not_inits C es; b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_inits C es' ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋); not_init C (Val v∙M(es)); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (Val v∙M(es')) ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋)› 39. ‹⋀M vs a aa b ba. ⟦not_init C (null∙M(map Val vs)); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (THROW NullPointer) ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 40. ‹⋀h a Ca fs M vs l sh b. ⟦h a = ⌊(Ca, fs)⌋; ∄b Ts T m D. P ⊢ Ca sees M, b : Ts→T = m in D; not_init C (addr a∙M(map Val vs)); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (THROW NoSuchMethodError) ∧ (∃sfs'. sh C = ⌊(sfs', Processing)⌋)› 41. ‹⋀h a Ca fs M Ts T aa b D vs l sh ba. ⟦h a = ⌊(Ca, fs)⌋; P ⊢ Ca sees M, Static : Ts→T = (aa, b) in D; not_init C (addr a∙M(map Val vs)); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (THROW IncompatibleClassChangeError) ∧ (∃sfs'. sh C = ⌊(sfs', Processing)⌋)› 42. ‹⋀es a aa b ba es' ab ac bb b' Ca M. ⟦P ⊢ ⟨es,(a, aa, b),ba⟩ [→] ⟨es',(ab, ac, bb),b'⟩; ⟦not_inits C es; b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_inits C es' ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋); not_init C (Ca∙⇩sM(es)); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (Ca∙⇩sM(es')) ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋)› 43. ‹⋀Ca M Ts T pns body D sh sfsa vs h l. ⟦P ⊢ Ca sees M, Static : Ts→T = (pns, body) in D; sh D = ⌊(sfsa, Done)⌋ ∨ M = clinit ∧ sh D = ⌊(sfsa, Processing)⌋; not_init C (Ca∙⇩sM(map Val vs)); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (Ca∙⇩sM(map Val vs)) ∧ (∃sfs'. sh C = ⌊(sfs', Processing)⌋)› 44. ‹⋀Ca M Ts T pns body D sh vs h l. ⟦P ⊢ Ca sees M, Static : Ts→T = (pns, body) in D; ∄sfs. sh D = ⌊(sfs, Done)⌋; M ≠ clinit; not_init C (Ca∙⇩sM(map Val vs)); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (INIT D ([D],False) ← Ca∙⇩sM(map Val vs)) ∧ (∃sfs'. sh C = ⌊(sfs', Processing)⌋)› 45. ‹⋀Ca M vs a aa b ba. ⟦∄b Ts T m. Ex (Method P Ca M b Ts T m); not_init C (Ca∙⇩sM(map Val vs)); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (THROW NoSuchMethodError) ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 46. ‹⋀Ca M Ts T a b D vs aa ab ba bb. ⟦P ⊢ Ca sees M, NonStatic : Ts→T = (a, b) in D; not_init C (Ca∙⇩sM(map Val vs)); ba C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (THROW IncompatibleClassChangeError) ∧ (∃sfs'. ba C = ⌊(sfs', Processing)⌋)› 47. ‹⋀e h l V sh b e' h' l' sh' b' T. ⟦P ⊢ ⟨e,(h, l(V := None), sh),b⟩ → ⟨e',(h', l', sh'),b'⟩; ⟦not_init C e; sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C e' ∧ (∃sfs'. sh' C = ⌊(sfs', Processing)⌋); l' V = None; ¬ assigned V e; not_init C {V:T; e}; sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C {V:T; e'} ∧ (∃sfs'. sh' C = ⌊(sfs', Processing)⌋)› 48. ‹⋀e h l V sh b e' h' l' sh' b' v T. ⟦P ⊢ ⟨e,(h, l(V := None), sh),b⟩ → ⟨e',(h', l', sh'),b'⟩; ⟦not_init C e; sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C e' ∧ (∃sfs'. sh' C = ⌊(sfs', Processing)⌋); l' V = ⌊v⌋; ¬ assigned V e; not_init C {V:T; e}; sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C {V:T; V:=Val v;; e'} ∧ (∃sfs'. sh' C = ⌊(sfs', Processing)⌋)› 49. ‹⋀e h l V v sh b e' h' l' sh' b' v' T. ⟦P ⊢ ⟨e,(h, l(V ↦ v), sh),b⟩ → ⟨e',(h', l', sh'),b'⟩; ⟦not_init C e; sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C e' ∧ (∃sfs'. sh' C = ⌊(sfs', Processing)⌋); l' V = ⌊v'⌋; not_init C {V:T; V:=Val v;; e}; sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C {V:T; V:=Val v';; e'} ∧ (∃sfs'. sh' C = ⌊(sfs', Processing)⌋)› 50. ‹⋀V T u a aa b ba. ⟦not_init C {V:T; Val u}; b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (Val u) ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 51. ‹⋀V T v u a aa b ba. ⟦not_init C {V:T; V:=Val v;; Val u}; b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (Val u) ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 52. ‹⋀e a aa b ba e' ab ac bb b' e₂. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⟦not_init C e; b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C e' ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋); not_init C (e;; e₂); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (e';; e₂) ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋)› 53. ‹⋀v e₂ a aa b ba. ⟦not_init C (Val v;; e₂); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C e₂ ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 54. ‹⋀e a aa b ba e' ab ac bb b' e₁ e₂. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⟦not_init C e; b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C e' ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋); not_init C (if (e) e₁ else e₂); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (if (e') e₁ else e₂) ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋)› 55. ‹⋀e₁ e₂ a aa b ba. ⟦not_init C (if (true) e₁ else e₂); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C e₁ ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 56. ‹⋀e₁ e₂ a aa b ba. ⟦not_init C (if (false) e₁ else e₂); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C e₂ ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 57. ‹⋀b c a aa ba b'. ⟦not_init C (while (b) c); ba C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (if (b) (c;; while (b) c) else unit) ∧ (∃sfs'. ba C = ⌊(sfs', Processing)⌋)› 58. ‹⋀e a aa b ba e' ab ac bb b'. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⟦not_init C e; b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C e' ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋); not_init C (throw e); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (throw e') ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋)› 59. ‹⋀a aa b ba. ⟦not_init C (throw null); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (THROW NullPointer) ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 60. ‹⋀e a aa b ba e' ab ac bb b' Ca V e₂. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⟦not_init C e; b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C e' ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋); not_init C (try e catch(Ca V) e₂); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (try e' catch(Ca V) e₂) ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋)› 61. ‹⋀v Ca V e₂ a aa b ba. ⟦not_init C (try Val v catch(Ca V) e₂); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (Val v) ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 62. ‹⋀a aa b ab D fs Ca V e₂ ba. ⟦hp (a, aa, b) ab = ⌊(D, fs)⌋; P ⊢ D ≼⇧* Ca; not_init C (try Throw ab catch(Ca V) e₂); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C {V:Class Ca; V:=addr ab;; e₂} ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 63. ‹⋀a aa b ab D fs Ca V e₂ ba. ⟦hp (a, aa, b) ab = ⌊(D, fs)⌋; (D, Ca) ∉ (subcls1 P)⇧*; not_init C (try Throw ab catch(Ca V) e₂); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (Throw ab) ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 64. ‹⋀e a aa b ba e' ab ac bb b' es. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⟦not_init C e; b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C e' ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋); not_inits C (e # es); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_inits C (e' # es) ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋)› 65. ‹⋀es a aa b ba es' ab ac bb b' v. ⟦P ⊢ ⟨es,(a, aa, b),ba⟩ [→] ⟨es',(ab, ac, bb),b'⟩; ⟦not_inits C es; b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_inits C es' ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋); not_inits C (Val v # es); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_inits C (Val v # es') ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋)› 66. ‹⋀e Ca b a aa ba b'. ⟦¬ sub_RI e; not_init C (INIT Ca ([],b) ← e); ba C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C e ∧ (∃sfs'. ba C = ⌊(sfs', Processing)⌋)› 67. ‹⋀sh Ca C' Cs e h l b. ⟦sh Ca = None; not_init C (INIT C' (Ca # Cs,False) ← e); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (INIT C' (Ca # Cs,False) ← e) ∧ (∃sfs'. (sh(Ca ↦ (sblank P Ca, Prepared))) C = ⌊(sfs', Processing)⌋)› 68. ‹⋀sh Ca sfsa C' Cs e h l b. ⟦sh Ca = ⌊(sfsa, Error)⌋; not_init C (INIT C' (Ca # Cs,False) ← e); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (RI (Ca,THROW NoClassDefFoundError) ; Cs ← e) ∧ (∃sfs'. sh C = ⌊(sfs', Processing)⌋)› 69. ‹⋀sh Ca sfsa sh' C' Cs e h l b. ⟦sh Ca = ⌊(sfsa, Prepared)⌋; Ca = Object; sh' = sh(Ca ↦ (sfsa, Processing)); not_init C (INIT C' (Ca # Cs,False) ← e); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (INIT C' (Ca # Cs,True) ← e) ∧ (∃sfs'. sh' C = ⌊(sfs', Processing)⌋)› 70. ‹⋀sh Ca sfsa D a b sh' C' Cs e h l ba. ⟦sh Ca = ⌊(sfsa, Prepared)⌋; Ca ≠ Object; class P Ca = ⌊(D, a, b)⌋; sh' = sh(Ca ↦ (sfsa, Processing)); not_init C (INIT C' (Ca # Cs,False) ← e); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (INIT C' (D # Ca # Cs,False) ← e) ∧ (∃sfs'. sh' C = ⌊(sfs', Processing)⌋)› 71. ‹⋀C' Ca Cs e h l sh b. ⟦not_init C (INIT C' (Ca # Cs,True) ← e); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (RI (Ca,Ca∙⇩sclinit([])) ; Cs ← e) ∧ (∃sfs'. sh C = ⌊(sfs', Processing)⌋)› 72. ‹⋀e a aa b ba e' ab ac bb b' Ca Cs e₀. ⟦P ⊢ ⟨e,(a, aa, b),ba⟩ → ⟨e',(ab, ac, bb),b'⟩; ⟦not_init C e; b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C e' ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋); not_init C (RI (Ca,e) ; Cs ← e₀); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (RI (Ca,e') ; Cs ← e₀) ∧ (∃sfs'. bb C = ⌊(sfs', Processing)⌋)› 73. ‹⋀Ca e a aa b ba. ⟦not_init C (Cast Ca (throw e)); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (throw e) ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 74. ‹⋀e bop e₂ a aa b ba. ⟦not_init C (throw e «bop» e₂); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (throw e) ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 75. ‹⋀v₁ bop e a aa b ba. ⟦not_init C (Val v₁ «bop» throw e); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (throw e) ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 76. ‹⋀V e a aa b ba. ⟦not_init C (V:=throw e); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (throw e) ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 77. ‹⋀e F D a aa b ba. ⟦not_init C (throw e∙F{D}); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (throw e) ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 78. ‹⋀e F D e₂ a aa b ba. ⟦not_init C (throw e∙F{D} := e₂); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (throw e) ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 79. ‹⋀v F D e a aa b ba. ⟦not_init C (Val v∙F{D} := throw e); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (throw e) ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 80. ‹⋀Ca F D e a aa b ba. ⟦not_init C (Ca∙⇩sF{D} := throw e); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (throw e) ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 81. ‹⋀e M es a aa b ba. ⟦not_init C (throw e∙M(es)); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (throw e) ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 82. ‹⋀V T a aa ab b ba. ⟦not_init C {V:T; Throw a}; b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (Throw a) ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 83. ‹⋀V T v a aa ab b ba. ⟦not_init C {V:T; V:=Val v;; Throw a}; b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (Throw a) ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 84. ‹⋀e e₂ a aa b ba. ⟦not_init C (throw e;; e₂); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (throw e) ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 85. ‹⋀e e₁ e₂ a aa b ba. ⟦not_init C (if (throw e) e₁ else e₂); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (throw e) ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 86. ‹⋀e a aa b ba. ⟦not_init C (throw (throw e)); b C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (throw e) ∧ (∃sfs'. b C = ⌊(sfs', Processing)⌋)› 87. ‹⋀sh Ca sfsa i sh' a D Cs e h l b. ⟦sh Ca = ⌊(sfsa, i)⌋; sh' = sh(Ca ↦ (sfsa, Error)); not_init C (RI (Ca,Throw a) ; D # Cs ← e); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (RI (D,Throw a) ; Cs ← e) ∧ (∃sfs'. sh' C = ⌊(sfs', Processing)⌋)› 88. ‹⋀sh Ca sfsa i sh' a e h l b. ⟦sh Ca = ⌊(sfsa, i)⌋; sh' = sh(Ca ↦ (sfsa, Error)); not_init C (RI (Ca,Throw a) ; [] ← e); sh C = ⌊(sfs, Processing)⌋⟧ ⟹ not_init C (Throw a) ∧ (∃sfs'. sh' C = ⌊(sfs', Processing)⌋)›*) end
{ "path": "afp-2025-02-12/thys/JinjaDCI/J/SmallStep.thy", "repo": "afp-2025-02-12", "sha": "009b38880d264a4a4372e3ef774602b1cb38afc76f12d2c2da01d172ca72f43e" }
(* * Copyright 2020, Data61, CSIRO (ABN 41 687 119 230) * Copyright (c) 2022 Apple Inc. All rights reserved. * * SPDX-License-Identifier: BSD-2-Clause *) theory WhileLoopVarsPreserved imports "AutoCorres2_Main.AutoCorres_Main" begin install_C_file "while_loop_vars_preserved.c" autocorres [ts_force nondet = loop] "while_loop_vars_preserved.c" lemmas runs_to_whileLoop5 = runs_to_whileLoop_res' [split_tuple C and B arity: 5] lemmas runs_to_partial_whileLoop5 = runs_to_partial_whileLoop_res [split_tuple C and B arity: 5] context while_loop_vars_preserved_all_impl begin lemma "loop' var1 var2 var3 var4 ∙ s ?⦃ λr s. r = Result (var1 + var2 + var3 + var4) ⦄" unfolding loop'_def (*goal: ‹do { (cat, dog, horse, iterations, mouse) ← whileLoop (λ(cat, dog, horse, iterations, mouse) s. 0 < dog ∨ 0 < cat ∨ 0 < mouse ∨ 0 < horse) (λ(cat, dog, horse, iterations, mouse). do { (cat, dog, horse, mouse) ← condition (λs. horse < dog) (return (cat, dog - 1, horse, mouse)) (condition (λs. mouse < horse) (return (cat, dog, horse - 1, mouse)) (condition (λs. 0 < cat) (return (cat - 1, dog, horse, mouse)) (do { (dog, horse, mouse) ← return (if 0 < mouse then (dog, horse, mouse - 1) else (dog, horse - 1, mouse)); return (cat, dog, horse, mouse) }))); return (cat, dog, horse, iterations + 1, mouse) }) (var2, var1, var4, 0, var3); return iterations } ∙ s ?⦃ λr s. r = Result (var1 + var2 + var3 + var4) ⦄›*) apply (runs_to_vcg (trace)) (*goal: ‹do { (cat, dog, horse, iterations, mouse) ← whileLoop (λ(cat, dog, horse, iterations, mouse) s. 0 < dog ∨ 0 < cat ∨ 0 < mouse ∨ 0 < horse) (λ(cat, dog, horse, iterations, mouse). do { (cat, dog, horse, mouse) ← condition (λs. horse < dog) (return (cat, dog - 1, horse, mouse)) (condition (λs. mouse < horse) (return (cat, dog, horse - 1, mouse)) (condition (λs. 0 < cat) (return (cat - 1, dog, horse, mouse)) (do { (dog, horse, mouse) ← return (if 0 < mouse then (dog, horse, mouse - 1) else (dog, horse - 1, mouse)); return (cat, dog, horse, mouse) }))); return (cat, dog, horse, iterations + 1, mouse) }) (var2, var1, var4, 0, var3); return iterations } ∙ s ?⦃ λr s. r = Result (var1 + var2 + var3 + var4) ⦄›*) apply (rule runs_to_partial_whileLoop5 [where I = "λ(meow, woof, neigh, ii, squeek) s. ii = (var1 + var2 + var3 + var4 - (meow + woof + neigh + squeek))" ] (*‹⟦(case ?a of (meow, woof, neigh, ii, squeek) ⇒ λs. ii = var1 + var2 + var3 + var4 - (meow + woof + neigh + squeek)) ?s; ⋀x1 x2 x3 x4 x5 s. ⟦¬ ?C x1 x2 x3 x4 x5 s; (case (x1, x2, x3, x4, x5) of (meow, woof, neigh, ii, squeek) ⇒ λs. ii = var1 + var2 + var3 + var4 - (meow + woof + neigh + squeek)) s⟧ ⟹ ?P (Result (x1, x2, x3, x4, x5)) s; ⋀x1 x2 x3 x4 x5 s. ⟦?C x1 x2 x3 x4 x5 s; (case (x1, x2, x3, x4, x5) of (meow, woof, neigh, ii, squeek) ⇒ λs. ii = var1 + var2 + var3 + var4 - (meow + woof + neigh + squeek)) s⟧ ⟹ ?B x1 x2 x3 x4 x5 ∙ s ?⦃ λr t. ∀b. r = Result b ⟶ (case b of (meow, woof, neigh, ii, squeek) ⇒ λs. ii = var1 + var2 + var3 + var4 - (meow + woof + neigh + squeek)) t ⦄⟧ ⟹ whileLoop (λ(x1, x2, x3, x4, x5). ?C x1 x2 x3 x4 x5) (λ(x1, x2, x3, x4, x5). ?B x1 x2 x3 x4 x5) ?a ∙ ?s ?⦃ ?P ⦄›*)) (*goal: ‹whileLoop (λ(cat, dog, horse, iterations, mouse) s. 0 < dog ∨ 0 < cat ∨ 0 < mouse ∨ 0 < horse) (λ(cat, dog, horse, iterations, mouse). do { (cat, dog, horse, mouse) ← condition (λs. horse < dog) (return (cat, dog - 1, horse, mouse)) (condition (λs. mouse < horse) (return (cat, dog, horse - 1, mouse)) (condition (λs. 0 < cat) (return (cat - 1, dog, horse, mouse)) (do { (dog, horse, mouse) ← return (if 0 < mouse then (dog, horse, mouse - 1) else (dog, horse - 1, mouse)); return (cat, dog, horse, mouse) }))); return (cat, dog, horse, iterations + 1, mouse) }) (var2, var1, var4, 0, var3) ∙ s ?⦃ λRes v t. (case v of (cat, dog, horse, iterations, mouse) ⇒ return iterations) ∙ t ?⦃ λr s. r = Result (var1 + var2 + var3 + var4) ⦄ ⦄›*) subgoal for by simp subgoal for by (simp add: word_gt_0 (*‹(0 < ?y) = (0 ≠ ?y)›*)) subgoal for apply runs_to_vcg (*goals: 1. ‹⟦iterations_ = var1 + var2 + var3 + var4 - (cat_ + dog_ + horse_ + mouse_); 0 < dog_; 0 < mouse_; horse_ < dog_⟧ ⟹ iterations_ = var1 + (var2 + (var3 + (var4 + (- horse_ - mouse_ - dog_ - cat_))))› 2. ‹⟦iterations_ = var1 + var2 + var3 + var4 - (cat_ + dog_ + horse_ + mouse_); 0 < dog_; 0 < mouse_; ¬ horse_ < dog_; mouse_ < horse_⟧ ⟹ iterations_ = var1 + (var2 + (var3 + (var4 + (- horse_ - mouse_ - dog_ - cat_))))› 3. ‹⟦iterations_ = var1 + var2 + var3 + var4 - (cat_ + dog_ + horse_ + mouse_); 0 < dog_; 0 < mouse_; ¬ horse_ < dog_; ¬ mouse_ < horse_; 0 < cat_⟧ ⟹ iterations_ = var1 + (var2 + (var3 + (var4 + (- horse_ - mouse_ - dog_ - cat_))))› 4. ‹⟦iterations_ = var1 + var2 + var3 + var4 - (cat_ + dog_ + horse_ + mouse_); 0 < dog_; 0 < mouse_; ¬ horse_ < dog_; ¬ mouse_ < horse_; ¬ 0 < cat_⟧ ⟹ iterations_ = var1 + (var2 + (var3 + (var4 + (- horse_ - mouse_ - dog_ - cat_))))› 5. ‹⟦iterations_ = var1 + var2 + var3 + var4 - (cat_ + dog_ + horse_ + mouse_); 0 < dog_; ¬ 0 < mouse_; horse_ < dog_⟧ ⟹ iterations_ = var1 + (var2 + (var3 + (var4 + (- horse_ - mouse_ - dog_ - cat_))))› 6. ‹⟦iterations_ = var1 + var2 + var3 + var4 - (cat_ + dog_ + horse_ + mouse_); 0 < dog_; ¬ 0 < mouse_; ¬ horse_ < dog_; mouse_ < horse_⟧ ⟹ iterations_ = var1 + (var2 + (var3 + (var4 + (- horse_ - mouse_ - dog_ - cat_))))› 7. ‹⟦iterations_ = var1 + var2 + var3 + var4 - (cat_ + dog_ + horse_ + mouse_); 0 < dog_; ¬ 0 < mouse_; ¬ horse_ < dog_; ¬ mouse_ < horse_; 0 < cat_⟧ ⟹ iterations_ = var1 + (var2 + (var3 + (var4 + (- horse_ - mouse_ - dog_ - cat_))))› 8. ‹⟦iterations_ = var1 + var2 + var3 + var4 - (cat_ + dog_ + horse_ + mouse_); 0 < dog_; ¬ 0 < mouse_; ¬ horse_ < dog_; ¬ mouse_ < horse_; ¬ 0 < cat_⟧ ⟹ iterations_ = var1 + (var2 + (var3 + (var4 + (- horse_ - mouse_ - dog_ - cat_))))› 9. ‹⟦iterations_ = var1 + var2 + var3 + var4 - (cat_ + dog_ + horse_ + mouse_); 0 < cat_; 0 < mouse_; horse_ < dog_⟧ ⟹ iterations_ = var1 + (var2 + (var3 + (var4 + (- horse_ - mouse_ - dog_ - cat_))))› 10. ‹⟦iterations_ = var1 + var2 + var3 + var4 - (cat_ + dog_ + horse_ + mouse_); 0 < cat_; 0 < mouse_; ¬ horse_ < dog_; mouse_ < horse_⟧ ⟹ iterations_ = var1 + (var2 + (var3 + (var4 + (- horse_ - mouse_ - dog_ - cat_))))› 11. ‹⟦iterations_ = var1 + var2 + var3 + var4 - (cat_ + dog_ + horse_ + mouse_); 0 < cat_; 0 < mouse_; ¬ horse_ < dog_; ¬ mouse_ < horse_; 0 < cat_⟧ ⟹ iterations_ = var1 + (var2 + (var3 + (var4 + (- horse_ - mouse_ - dog_ - cat_))))› 12. ‹⟦iterations_ = var1 + var2 + var3 + var4 - (cat_ + dog_ + horse_ + mouse_); 0 < cat_; 0 < mouse_; ¬ horse_ < dog_; ¬ mouse_ < horse_; ¬ 0 < cat_⟧ ⟹ iterations_ = var1 + (var2 + (var3 + (var4 + (- horse_ - mouse_ - dog_ - cat_))))› 13. ‹⟦iterations_ = var1 + var2 + var3 + var4 - (cat_ + dog_ + horse_ + mouse_); 0 < cat_; ¬ 0 < mouse_; horse_ < dog_⟧ ⟹ iterations_ = var1 + (var2 + (var3 + (var4 + (- horse_ - mouse_ - dog_ - cat_))))› 14. ‹⟦iterations_ = var1 + var2 + var3 + var4 - (cat_ + dog_ + horse_ + mouse_); 0 < cat_; ¬ 0 < mouse_; ¬ horse_ < dog_; mouse_ < horse_⟧ ⟹ iterations_ = var1 + (var2 + (var3 + (var4 + (- horse_ - mouse_ - dog_ - cat_))))› 15. ‹⟦iterations_ = var1 + var2 + var3 + var4 - (cat_ + dog_ + horse_ + mouse_); 0 < cat_; ¬ 0 < mouse_; ¬ horse_ < dog_; ¬ mouse_ < horse_; 0 < cat_⟧ ⟹ iterations_ = var1 + (var2 + (var3 + (var4 + (- horse_ - mouse_ - dog_ - cat_))))› 16. ‹⟦iterations_ = var1 + var2 + var3 + var4 - (cat_ + dog_ + horse_ + mouse_); 0 < cat_; ¬ 0 < mouse_; ¬ horse_ < dog_; ¬ mouse_ < horse_; ¬ 0 < cat_⟧ ⟹ iterations_ = var1 + (var2 + (var3 + (var4 + (- horse_ - mouse_ - dog_ - cat_))))› 17. ‹⟦iterations_ = var1 + var2 + var3 + var4 - (cat_ + dog_ + horse_ + mouse_); 0 < mouse_; 0 < mouse_; horse_ < dog_⟧ ⟹ iterations_ = var1 + (var2 + (var3 + (var4 + (- horse_ - mouse_ - dog_ - cat_))))› 18. ‹⟦iterations_ = var1 + var2 + var3 + var4 - (cat_ + dog_ + horse_ + mouse_); 0 < mouse_; 0 < mouse_; ¬ horse_ < dog_; mouse_ < horse_⟧ ⟹ iterations_ = var1 + (var2 + (var3 + (var4 + (- horse_ - mouse_ - dog_ - cat_))))› 19. ‹⟦iterations_ = var1 + var2 + var3 + var4 - (cat_ + dog_ + horse_ + mouse_); 0 < mouse_; 0 < mouse_; ¬ horse_ < dog_; ¬ mouse_ < horse_; 0 < cat_⟧ ⟹ iterations_ = var1 + (var2 + (var3 + (var4 + (- horse_ - mouse_ - dog_ - cat_))))› 20. ‹⟦iterations_ = var1 + var2 + var3 + var4 - (cat_ + dog_ + horse_ + mouse_); 0 < mouse_; 0 < mouse_; ¬ horse_ < dog_; ¬ mouse_ < horse_; ¬ 0 < cat_⟧ ⟹ iterations_ = var1 + (var2 + (var3 + (var4 + (- horse_ - mouse_ - dog_ - cat_))))› 21. ‹⟦iterations_ = var1 + var2 + var3 + var4 - (cat_ + dog_ + horse_ + mouse_); 0 < horse_; 0 < mouse_; horse_ < dog_⟧ ⟹ iterations_ = var1 + (var2 + (var3 + (var4 + (- horse_ - mouse_ - dog_ - cat_))))› 22. ‹⟦iterations_ = var1 + var2 + var3 + var4 - (cat_ + dog_ + horse_ + mouse_); 0 < horse_; 0 < mouse_; ¬ horse_ < dog_; mouse_ < horse_⟧ ⟹ iterations_ = var1 + (var2 + (var3 + (var4 + (- horse_ - mouse_ - dog_ - cat_))))› 23. ‹⟦iterations_ = var1 + var2 + var3 + var4 - (cat_ + dog_ + horse_ + mouse_); 0 < horse_; 0 < mouse_; ¬ horse_ < dog_; ¬ mouse_ < horse_; 0 < cat_⟧ ⟹ iterations_ = var1 + (var2 + (var3 + (var4 + (- horse_ - mouse_ - dog_ - cat_))))› 24. ‹⟦iterations_ = var1 + var2 + var3 + var4 - (cat_ + dog_ + horse_ + mouse_); 0 < horse_; 0 < mouse_; ¬ horse_ < dog_; ¬ mouse_ < horse_; ¬ 0 < cat_⟧ ⟹ iterations_ = var1 + (var2 + (var3 + (var4 + (- horse_ - mouse_ - dog_ - cat_))))› 25. ‹⟦iterations_ = var1 + var2 + var3 + var4 - (cat_ + dog_ + horse_ + mouse_); 0 < horse_; ¬ 0 < mouse_; horse_ < dog_⟧ ⟹ iterations_ = var1 + (var2 + (var3 + (var4 + (- horse_ - mouse_ - dog_ - cat_))))› 26. ‹⟦iterations_ = var1 + var2 + var3 + var4 - (cat_ + dog_ + horse_ + mouse_); 0 < horse_; ¬ 0 < mouse_; ¬ horse_ < dog_; mouse_ < horse_⟧ ⟹ iterations_ = var1 + (var2 + (var3 + (var4 + (- horse_ - mouse_ - dog_ - cat_))))› 27. ‹⟦iterations_ = var1 + var2 + var3 + var4 - (cat_ + dog_ + horse_ + mouse_); 0 < horse_; ¬ 0 < mouse_; ¬ horse_ < dog_; ¬ mouse_ < horse_; 0 < cat_⟧ ⟹ iterations_ = var1 + (var2 + (var3 + (var4 + (- horse_ - mouse_ - dog_ - cat_))))› 28. ‹⟦iterations_ = var1 + var2 + var3 + var4 - (cat_ + dog_ + horse_ + mouse_); 0 < horse_; ¬ 0 < mouse_; ¬ horse_ < dog_; ¬ mouse_ < horse_; ¬ 0 < cat_⟧ ⟹ iterations_ = var1 + (var2 + (var3 + (var4 + (- horse_ - mouse_ - dog_ - cat_))))› discuss goal 1*) apply ((auto simp: word_gt_0 (*‹(0 < ?y) = (0 ≠ ?y)›*) measure_unat (*‹?p ≠ 0 ⟹ unat (?p - 1) < unat ?p›*) split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*))[1]) (*discuss goal 2*) apply ((auto simp: word_gt_0 (*‹(0 < ?y) = (0 ≠ ?y)›*) measure_unat (*‹?p ≠ 0 ⟹ unat (?p - 1) < unat ?p›*) split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*))[1]) (*discuss goal 3*) apply ((auto simp: word_gt_0 (*‹(0 < ?y) = (0 ≠ ?y)›*) measure_unat (*‹?p ≠ 0 ⟹ unat (?p - 1) < unat ?p›*) split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*))[1]) (*discuss goal 4*) apply ((auto simp: word_gt_0 (*‹(0 < ?y) = (0 ≠ ?y)›*) measure_unat (*‹?p ≠ 0 ⟹ unat (?p - 1) < unat ?p›*) split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*))[1]) (*discuss goal 5*) apply ((auto simp: word_gt_0 (*‹((0::?'a word) < (?y::?'a word)) = ((0::?'a word) ≠ ?y)›*) measure_unat (*‹(?p::?'a word) ≠ (0::?'a word) ⟹ unat (?p - (1::?'a word)) < unat ?p›*) split: if_split_asm (*‹(?P::?'a ⇒ bool) (if ?Q::bool then ?x::?'a else (?y::?'a)) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*))[1]) (*discuss goal 6*) apply ((auto simp: word_gt_0 (*‹(0 < ?y) = (0 ≠ ?y)›*) measure_unat (*‹?p ≠ 0 ⟹ unat (?p - 1) < unat ?p›*) split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*))[1]) (*discuss goal 7*) apply ((auto simp: word_gt_0 (*‹(0 < ?y) = (0 ≠ ?y)›*) measure_unat (*‹?p ≠ 0 ⟹ unat (?p - 1) < unat ?p›*) split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*))[1]) (*discuss goal 8*) apply ((auto simp: word_gt_0 (*‹(0 < ?y) = (0 ≠ ?y)›*) measure_unat (*‹?p ≠ 0 ⟹ unat (?p - 1) < unat ?p›*) split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*))[1]) (*discuss goal 9*) apply ((auto simp: word_gt_0 (*‹(0 < ?y) = (0 ≠ ?y)›*) measure_unat (*‹?p ≠ 0 ⟹ unat (?p - 1) < unat ?p›*) split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*))[1]) (*discuss goal 10*) apply ((auto simp: word_gt_0 (*‹(0 < ?y) = (0 ≠ ?y)›*) measure_unat (*‹?p ≠ 0 ⟹ unat (?p - 1) < unat ?p›*) split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*))[1]) (*discuss goal 11*) apply ((auto simp: word_gt_0 (*‹(0 < ?y) = (0 ≠ ?y)›*) measure_unat (*‹?p ≠ 0 ⟹ unat (?p - 1) < unat ?p›*) split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*))[1]) (*discuss goal 12*) apply ((auto simp: word_gt_0 (*‹(0 < ?y) = (0 ≠ ?y)›*) measure_unat (*‹?p ≠ 0 ⟹ unat (?p - 1) < unat ?p›*) split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*))[1]) (*discuss goal 13*) apply ((auto simp: word_gt_0 (*‹((0::?'a word) < (?y::?'a word)) = ((0::?'a word) ≠ ?y)›*) measure_unat (*‹(?p::?'a word) ≠ (0::?'a word) ⟹ unat (?p - (1::?'a word)) < unat ?p›*) split: if_split_asm (*‹(?P::?'a ⇒ bool) (if ?Q::bool then ?x::?'a else (?y::?'a)) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*))[1]) (*discuss goal 14*) apply ((auto simp: word_gt_0 (*‹(0 < ?y) = (0 ≠ ?y)›*) measure_unat (*‹?p ≠ 0 ⟹ unat (?p - 1) < unat ?p›*) split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*))[1]) (*discuss goal 15*) apply ((auto simp: word_gt_0 (*‹(0 < ?y) = (0 ≠ ?y)›*) measure_unat (*‹?p ≠ 0 ⟹ unat (?p - 1) < unat ?p›*) split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*))[1]) (*discuss goal 16*) apply ((auto simp: word_gt_0 (*‹(0 < ?y) = (0 ≠ ?y)›*) measure_unat (*‹?p ≠ 0 ⟹ unat (?p - 1) < unat ?p›*) split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*))[1]) (*discuss goal 17*) apply ((auto simp: word_gt_0 (*‹(0 < ?y) = (0 ≠ ?y)›*) measure_unat (*‹?p ≠ 0 ⟹ unat (?p - 1) < unat ?p›*) split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*))[1]) (*discuss goal 18*) apply ((auto simp: word_gt_0 (*‹((0::?'a word) < (?y::?'a word)) = ((0::?'a word) ≠ ?y)›*) measure_unat (*‹(?p::?'a word) ≠ (0::?'a word) ⟹ unat (?p - (1::?'a word)) < unat ?p›*) split: if_split_asm (*‹(?P::?'a ⇒ bool) (if ?Q::bool then ?x::?'a else (?y::?'a)) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*))[1]) (*discuss goal 19*) apply ((auto simp: word_gt_0 (*‹((0::?'a::len word) < (?y::?'a::len word)) = ((0::?'a::len word) ≠ ?y)›*) measure_unat (*‹(?p::?'a::len word) ≠ (0::?'a::len word) ⟹ unat (?p - (1::?'a::len word)) < unat ?p›*) 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]) (*discuss goal 20*) apply ((auto simp: word_gt_0 (*‹(0 < ?y) = (0 ≠ ?y)›*) measure_unat (*‹?p ≠ 0 ⟹ unat (?p - 1) < unat ?p›*) split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*))[1]) (*discuss goal 21*) apply ((auto simp: word_gt_0 (*‹(0 < ?y) = (0 ≠ ?y)›*) measure_unat (*‹?p ≠ 0 ⟹ unat (?p - 1) < unat ?p›*) split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*))[1]) (*discuss goal 22*) apply ((auto simp: word_gt_0 (*‹(0 < ?y) = (0 ≠ ?y)›*) measure_unat (*‹?p ≠ 0 ⟹ unat (?p - 1) < unat ?p›*) split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*))[1]) (*discuss goal 23*) apply ((auto simp: word_gt_0 (*‹((0::?'a word) < (?y::?'a word)) = ((0::?'a word) ≠ ?y)›*) measure_unat (*‹(?p::?'a word) ≠ (0::?'a word) ⟹ unat (?p - (1::?'a word)) < unat ?p›*) split: if_split_asm (*‹(?P::?'a ⇒ bool) (if ?Q::bool then ?x::?'a else (?y::?'a)) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*))[1]) (*discuss goal 24*) apply ((auto simp: word_gt_0 (*‹((0::?'a::len word) < (?y::?'a::len word)) = ((0::?'a::len word) ≠ ?y)›*) measure_unat (*‹(?p::?'a::len word) ≠ (0::?'a::len word) ⟹ unat (?p - (1::?'a::len word)) < unat ?p›*) 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]) (*discuss goal 25*) apply ((auto simp: word_gt_0 (*‹((0::?'a word) < (?y::?'a word)) = ((0::?'a word) ≠ ?y)›*) measure_unat (*‹(?p::?'a word) ≠ (0::?'a word) ⟹ unat (?p - (1::?'a word)) < unat ?p›*) split: if_split_asm (*‹(?P::?'a ⇒ bool) (if ?Q::bool then ?x::?'a else (?y::?'a)) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*))[1]) (*discuss goal 26*) apply ((auto simp: word_gt_0 (*‹((0::?'a word) < (?y::?'a word)) = ((0::?'a word) ≠ ?y)›*) measure_unat (*‹(?p::?'a word) ≠ (0::?'a word) ⟹ unat (?p - (1::?'a word)) < unat ?p›*) split: if_split_asm (*‹(?P::?'a ⇒ bool) (if ?Q::bool then ?x::?'a else (?y::?'a)) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*))[1]) (*discuss goal 27*) apply ((auto simp: word_gt_0 (*‹(0 < ?y) = (0 ≠ ?y)›*) measure_unat (*‹?p ≠ 0 ⟹ unat (?p - 1) < unat ?p›*) split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*))[1]) (*discuss goal 28*) apply ((auto simp: word_gt_0 (*‹((0::?'a word) < (?y::?'a word)) = ((0::?'a word) ≠ ?y)›*) measure_unat (*‹(?p::?'a word) ≠ (0::?'a word) ⟹ unat (?p - (1::?'a word)) < unat ?p›*) split: if_split_asm (*‹(?P::?'a ⇒ bool) (if ?Q::bool then ?x::?'a else (?y::?'a)) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*))[1]) (*proven 28 subgoals*) . . lemma "loop' var1 var2 var3 var4 ∙ s ⦃ λr s. r = Result (var1 + var2 + var3 + var4) ⦄" unfolding loop'_def (*goal: ‹do { (cat::32 word, dog::32 word, horse::32 word, iterations::32 word, mouse::32 word) ← whileLoop (λ(cat::32 word, dog::32 word, horse::32 word, iterations::32 word, mouse::32 word) s::lifted_globals. (0::32 word) < dog ∨ (0::32 word) < cat ∨ (0::32 word) < mouse ∨ (0::32 word) < horse) (λ(cat::32 word, dog::32 word, horse::32 word, iterations::32 word, mouse::32 word). do { (cat::32 word, dog::32 word, horse::32 word, mouse::32 word) ← condition (λs::lifted_globals. horse < dog) (return (cat, dog - (1::32 word), horse, mouse)) (condition (λs::lifted_globals. mouse < horse) (return (cat, dog, horse - (1::32 word), mouse)) (condition (λs::lifted_globals. (0::32 word) < cat) (return (cat - (1::32 word), dog, horse, mouse)) (do { (dog::32 word, horse::32 word, mouse::32 word) ← return (if (0::32 word) < mouse then (dog, horse, mouse - (1::32 word)) else (dog, horse - (1::32 word), mouse)); return (cat, dog, horse, mouse) }))); return (cat, dog, horse, iterations + (1::32 word), mouse) }) (var2::32 word, var1::32 word, var4::32 word, 0::32 word, var3::32 word); return iterations } ∙ (s::lifted_globals) ⦃ λ(r::(unit, 32 word) exception_or_result) s::lifted_globals. r = Result (var1 + var2 + var3 + var4) ⦄›*) apply (runs_to_vcg (trace)) (*goal: ‹do { (cat::32 word, dog::32 word, horse::32 word, iterations::32 word, mouse::32 word) ← whileLoop (λ(cat::32 word, dog::32 word, horse::32 word, iterations::32 word, mouse::32 word) s::lifted_globals. (0::32 word) < dog ∨ (0::32 word) < cat ∨ (0::32 word) < mouse ∨ (0::32 word) < horse) (λ(cat::32 word, dog::32 word, horse::32 word, iterations::32 word, mouse::32 word). do { (cat::32 word, dog::32 word, horse::32 word, mouse::32 word) ← condition (λs::lifted_globals. horse < dog) (return (cat, dog - (1::32 word), horse, mouse)) (condition (λs::lifted_globals. mouse < horse) (return (cat, dog, horse - (1::32 word), mouse)) (condition (λs::lifted_globals. (0::32 word) < cat) (return (cat - (1::32 word), dog, horse, mouse)) (do { (dog::32 word, horse::32 word, mouse::32 word) ← return (if (0::32 word) < mouse then (dog, horse, mouse - (1::32 word)) else (dog, horse - (1::32 word), mouse)); return (cat, dog, horse, mouse) }))); return (cat, dog, horse, iterations + (1::32 word), mouse) }) (var2::32 word, var1::32 word, var4::32 word, 0::32 word, var3::32 word); return iterations } ∙ (s::lifted_globals) ⦃ λ(r::(unit, 32 word) exception_or_result) s::lifted_globals. r = Result (var1 + var2 + var3 + var4) ⦄›*) apply (rule runs_to_whileLoop5 [where I = "λ(meow, woof, neigh, ii, squeek) s. ii = (var1 + var2 + var3 + var4 - (meow + woof + neigh + squeek))" and R = "measure (λ((meow, woof, neigh, ii, squeek), s). unat meow + unat woof + unat neigh + unat squeek)" ] (*‹⟦wf (measure (λ((meow, woof, neigh, ii, squeek), s). unat meow + unat woof + unat neigh + unat squeek)); (case ?a of (meow, woof, neigh, ii, squeek) ⇒ λs. ii = var1 + var2 + var3 + var4 - (meow + woof + neigh + squeek)) ?s; ⋀x1 x2 x3 x4 x5 s. ⟦¬ ?C x1 x2 x3 x4 x5 s; (case (x1, x2, x3, x4, x5) of (meow, woof, neigh, ii, squeek) ⇒ λs. ii = var1 + var2 + var3 + var4 - (meow + woof + neigh + squeek)) s⟧ ⟹ ?P (Result (x1, x2, x3, x4, x5)) s; ⋀x1 x2 x3 x4 x5 s. ⟦?C x1 x2 x3 x4 x5 s; (case (x1, x2, x3, x4, x5) of (meow, woof, neigh, ii, squeek) ⇒ λs. ii = var1 + var2 + var3 + var4 - (meow + woof + neigh + squeek)) s⟧ ⟹ ?B x1 x2 x3 x4 x5 ∙ s ⦃ λr t. ∀b. r = Result b ⟶ (case b of (meow, woof, neigh, ii, squeek) ⇒ λs. ii = var1 + var2 + var3 + var4 - (meow + woof + neigh + squeek)) t ∧ ((b, t), (x1, x2, x3, x4, x5), s) ∈ measure (λ((meow, woof, neigh, ii, squeek), s). unat meow + unat woof + unat neigh + unat squeek) ⦄⟧ ⟹ whileLoop (λ(x1, x2, x3, x4, x5). ?C x1 x2 x3 x4 x5) (λ(x1, x2, x3, x4, x5). ?B x1 x2 x3 x4 x5) ?a ∙ ?s ⦃ ?P ⦄›*)) (*goal: ‹whileLoop (λ(cat, dog, horse, iterations, mouse) s. 0 < dog ∨ 0 < cat ∨ 0 < mouse ∨ 0 < horse) (λ(cat, dog, horse, iterations, mouse). do { (cat, dog, horse, mouse) ← condition (λs. horse < dog) (return (cat, dog - 1, horse, mouse)) (condition (λs. mouse < horse) (return (cat, dog, horse - 1, mouse)) (condition (λs. 0 < cat) (return (cat - 1, dog, horse, mouse)) (do { (dog, horse, mouse) ← return (if 0 < mouse then (dog, horse, mouse - 1) else (dog, horse - 1, mouse)); return (cat, dog, horse, mouse) }))); return (cat, dog, horse, iterations + 1, mouse) }) (var2, var1, var4, 0, var3) ∙ s ⦃ λRes v t. (case v of (cat, dog, horse, iterations, mouse) ⇒ return iterations) ∙ t ⦃ λr s. r = Result (var1 + var2 + var3 + var4) ⦄ ⦄›*) subgoal for by simp subgoal for by simp subgoal for by (clarsimp simp add: word_greater_zero_iff (*‹(0 < ?a) = (?a ≠ 0)›*)) subgoal for apply runs_to_vcg (*goals: 1. ‹⟦(iterations_::32 word) = (var1::32 word) + (var2::32 word) + (var3::32 word) + (var4::32 word) - ((cat_::32 word) + (dog_::32 word) + (horse_::32 word) + (mouse_::32 word)); (0::32 word) < dog_; (0::32 word) < mouse_; horse_ < dog_⟧ ⟹ iterations_ = var1 + (var2 + (var3 + (var4 + (- horse_ - mouse_ - dog_ - cat_))))› 2. ‹⟦(iterations_::32 word) = (var1::32 word) + (var2::32 word) + (var3::32 word) + (var4::32 word) - ((cat_::32 word) + (dog_::32 word) + (horse_::32 word) + (mouse_::32 word)); (0::32 word) < dog_; (0::32 word) < mouse_; horse_ < dog_⟧ ⟹ unat (dog_ - (1::32 word)) < unat dog_› 3. ‹⟦(iterations_::32 word) = (var1::32 word) + (var2::32 word) + (var3::32 word) + (var4::32 word) - ((cat_::32 word) + (dog_::32 word) + (horse_::32 word) + (mouse_::32 word)); (0::32 word) < dog_; (0::32 word) < mouse_; ¬ horse_ < dog_; mouse_ < horse_⟧ ⟹ iterations_ = var1 + (var2 + (var3 + (var4 + (- horse_ - mouse_ - dog_ - cat_))))› 4. ‹⟦(iterations_::32 word) = (var1::32 word) + (var2::32 word) + (var3::32 word) + (var4::32 word) - ((cat_::32 word) + (dog_::32 word) + (horse_::32 word) + (mouse_::32 word)); (0::32 word) < dog_; (0::32 word) < mouse_; ¬ horse_ < dog_; mouse_ < horse_⟧ ⟹ unat (horse_ - (1::32 word)) < unat horse_› 5. ‹⟦(iterations_::32 word) = (var1::32 word) + (var2::32 word) + (var3::32 word) + (var4::32 word) - ((cat_::32 word) + (dog_::32 word) + (horse_::32 word) + (mouse_::32 word)); (0::32 word) < dog_; (0::32 word) < mouse_; ¬ horse_ < dog_; ¬ mouse_ < horse_; (0::32 word) < cat_⟧ ⟹ iterations_ = var1 + (var2 + (var3 + (var4 + (- horse_ - mouse_ - dog_ - cat_))))› 6. ‹⟦(iterations_::32 word) = (var1::32 word) + (var2::32 word) + (var3::32 word) + (var4::32 word) - ((cat_::32 word) + (dog_::32 word) + (horse_::32 word) + (mouse_::32 word)); (0::32 word) < dog_; (0::32 word) < mouse_; ¬ horse_ < dog_; ¬ mouse_ < horse_; (0::32 word) < cat_⟧ ⟹ unat (cat_ - (1::32 word)) < unat cat_› 7. ‹⟦(iterations_::32 word) = (var1::32 word) + (var2::32 word) + (var3::32 word) + (var4::32 word) - ((cat_::32 word) + (dog_::32 word) + (horse_::32 word) + (mouse_::32 word)); (0::32 word) < dog_; (0::32 word) < mouse_; ¬ horse_ < dog_; ¬ mouse_ < horse_; ¬ (0::32 word) < cat_⟧ ⟹ iterations_ = var1 + (var2 + (var3 + (var4 + (- horse_ - mouse_ - dog_ - cat_))))› 8. ‹⟦(iterations_::32 word) = (var1::32 word) + (var2::32 word) + (var3::32 word) + (var4::32 word) - ((cat_::32 word) + (dog_::32 word) + (horse_::32 word) + (mouse_::32 word)); (0::32 word) < dog_; (0::32 word) < mouse_; ¬ horse_ < dog_; ¬ mouse_ < horse_; ¬ (0::32 word) < cat_⟧ ⟹ unat (mouse_ - (1::32 word)) < unat mouse_› 9. ‹⟦(iterations_::32 word) = (var1::32 word) + (var2::32 word) + (var3::32 word) + (var4::32 word) - ((cat_::32 word) + (dog_::32 word) + (horse_::32 word) + (mouse_::32 word)); (0::32 word) < dog_; ¬ (0::32 word) < mouse_; horse_ < dog_⟧ ⟹ iterations_ = var1 + (var2 + (var3 + (var4 + (- horse_ - mouse_ - dog_ - cat_))))› 10. ‹⟦(iterations_::32 word) = (var1::32 word) + (var2::32 word) + (var3::32 word) + (var4::32 word) - ((cat_::32 word) + (dog_::32 word) + (horse_::32 word) + (mouse_::32 word)); (0::32 word) < dog_; ¬ (0::32 word) < mouse_; horse_ < dog_⟧ ⟹ unat (dog_ - (1::32 word)) < unat dog_› 11. ‹⟦(iterations_::32 word) = (var1::32 word) + (var2::32 word) + (var3::32 word) + (var4::32 word) - ((cat_::32 word) + (dog_::32 word) + (horse_::32 word) + (mouse_::32 word)); (0::32 word) < dog_; ¬ (0::32 word) < mouse_; ¬ horse_ < dog_; mouse_ < horse_⟧ ⟹ iterations_ = var1 + (var2 + (var3 + (var4 + (- horse_ - mouse_ - dog_ - cat_))))› 12. ‹⟦(iterations_::32 word) = (var1::32 word) + (var2::32 word) + (var3::32 word) + (var4::32 word) - ((cat_::32 word) + (dog_::32 word) + (horse_::32 word) + (mouse_::32 word)); (0::32 word) < dog_; ¬ (0::32 word) < mouse_; ¬ horse_ < dog_; mouse_ < horse_⟧ ⟹ unat (horse_ - (1::32 word)) < unat horse_› 13. ‹⟦(iterations_::32 word) = (var1::32 word) + (var2::32 word) + (var3::32 word) + (var4::32 word) - ((cat_::32 word) + (dog_::32 word) + (horse_::32 word) + (mouse_::32 word)); (0::32 word) < dog_; ¬ (0::32 word) < mouse_; ¬ horse_ < dog_; ¬ mouse_ < horse_; (0::32 word) < cat_⟧ ⟹ iterations_ = var1 + (var2 + (var3 + (var4 + (- horse_ - mouse_ - dog_ - cat_))))› 14. ‹⟦(iterations_::32 word) = (var1::32 word) + (var2::32 word) + (var3::32 word) + (var4::32 word) - ((cat_::32 word) + (dog_::32 word) + (horse_::32 word) + (mouse_::32 word)); (0::32 word) < dog_; ¬ (0::32 word) < mouse_; ¬ horse_ < dog_; ¬ mouse_ < horse_; (0::32 word) < cat_⟧ ⟹ unat (cat_ - (1::32 word)) < unat cat_› 15. ‹⟦(iterations_::32 word) = (var1::32 word) + (var2::32 word) + (var3::32 word) + (var4::32 word) - ((cat_::32 word) + (dog_::32 word) + (horse_::32 word) + (mouse_::32 word)); (0::32 word) < dog_; ¬ (0::32 word) < mouse_; ¬ horse_ < dog_; ¬ mouse_ < horse_; ¬ (0::32 word) < cat_⟧ ⟹ iterations_ = var1 + (var2 + (var3 + (var4 + (- horse_ - mouse_ - dog_ - cat_))))› 16. ‹⟦(iterations_::32 word) = (var1::32 word) + (var2::32 word) + (var3::32 word) + (var4::32 word) - ((cat_::32 word) + (dog_::32 word) + (horse_::32 word) + (mouse_::32 word)); (0::32 word) < dog_; ¬ (0::32 word) < mouse_; ¬ horse_ < dog_; ¬ mouse_ < horse_; ¬ (0::32 word) < cat_⟧ ⟹ unat (horse_ - (1::32 word)) < unat horse_› 17. ‹⟦(iterations_::32 word) = (var1::32 word) + (var2::32 word) + (var3::32 word) + (var4::32 word) - ((cat_::32 word) + (dog_::32 word) + (horse_::32 word) + (mouse_::32 word)); (0::32 word) < cat_; (0::32 word) < mouse_; horse_ < dog_⟧ ⟹ iterations_ = var1 + (var2 + (var3 + (var4 + (- horse_ - mouse_ - dog_ - cat_))))› 18. ‹⟦(iterations_::32 word) = (var1::32 word) + (var2::32 word) + (var3::32 word) + (var4::32 word) - ((cat_::32 word) + (dog_::32 word) + (horse_::32 word) + (mouse_::32 word)); (0::32 word) < cat_; (0::32 word) < mouse_; horse_ < dog_⟧ ⟹ unat (dog_ - (1::32 word)) < unat dog_› 19. ‹⟦(iterations_::32 word) = (var1::32 word) + (var2::32 word) + (var3::32 word) + (var4::32 word) - ((cat_::32 word) + (dog_::32 word) + (horse_::32 word) + (mouse_::32 word)); (0::32 word) < cat_; (0::32 word) < mouse_; ¬ horse_ < dog_; mouse_ < horse_⟧ ⟹ iterations_ = var1 + (var2 + (var3 + (var4 + (- horse_ - mouse_ - dog_ - cat_))))› 20. ‹⟦(iterations_::32 word) = (var1::32 word) + (var2::32 word) + (var3::32 word) + (var4::32 word) - ((cat_::32 word) + (dog_::32 word) + (horse_::32 word) + (mouse_::32 word)); (0::32 word) < cat_; (0::32 word) < mouse_; ¬ horse_ < dog_; mouse_ < horse_⟧ ⟹ unat (horse_ - (1::32 word)) < unat horse_› 21. ‹⟦(iterations_::32 word) = (var1::32 word) + (var2::32 word) + (var3::32 word) + (var4::32 word) - ((cat_::32 word) + (dog_::32 word) + (horse_::32 word) + (mouse_::32 word)); (0::32 word) < cat_; (0::32 word) < mouse_; ¬ horse_ < dog_; ¬ mouse_ < horse_; (0::32 word) < cat_⟧ ⟹ iterations_ = var1 + (var2 + (var3 + (var4 + (- horse_ - mouse_ - dog_ - cat_))))› 22. ‹⟦(iterations_::32 word) = (var1::32 word) + (var2::32 word) + (var3::32 word) + (var4::32 word) - ((cat_::32 word) + (dog_::32 word) + (horse_::32 word) + (mouse_::32 word)); (0::32 word) < cat_; (0::32 word) < mouse_; ¬ horse_ < dog_; ¬ mouse_ < horse_; (0::32 word) < cat_⟧ ⟹ unat (cat_ - (1::32 word)) < unat cat_› 23. ‹⟦(iterations_::32 word) = (var1::32 word) + (var2::32 word) + (var3::32 word) + (var4::32 word) - ((cat_::32 word) + (dog_::32 word) + (horse_::32 word) + (mouse_::32 word)); (0::32 word) < cat_; (0::32 word) < mouse_; ¬ horse_ < dog_; ¬ mouse_ < horse_; ¬ (0::32 word) < cat_⟧ ⟹ iterations_ = var1 + (var2 + (var3 + (var4 + (- horse_ - mouse_ - dog_ - cat_))))› 24. ‹⟦(iterations_::32 word) = (var1::32 word) + (var2::32 word) + (var3::32 word) + (var4::32 word) - ((cat_::32 word) + (dog_::32 word) + (horse_::32 word) + (mouse_::32 word)); (0::32 word) < cat_; (0::32 word) < mouse_; ¬ horse_ < dog_; ¬ mouse_ < horse_; ¬ (0::32 word) < cat_⟧ ⟹ unat (mouse_ - (1::32 word)) < unat mouse_› 25. ‹⟦(iterations_::32 word) = (var1::32 word) + (var2::32 word) + (var3::32 word) + (var4::32 word) - ((cat_::32 word) + (dog_::32 word) + (horse_::32 word) + (mouse_::32 word)); (0::32 word) < cat_; ¬ (0::32 word) < mouse_; horse_ < dog_⟧ ⟹ iterations_ = var1 + (var2 + (var3 + (var4 + (- horse_ - mouse_ - dog_ - cat_))))› 26. ‹⟦(iterations_::32 word) = (var1::32 word) + (var2::32 word) + (var3::32 word) + (var4::32 word) - ((cat_::32 word) + (dog_::32 word) + (horse_::32 word) + (mouse_::32 word)); (0::32 word) < cat_; ¬ (0::32 word) < mouse_; horse_ < dog_⟧ ⟹ unat (dog_ - (1::32 word)) < unat dog_› 27. ‹⟦(iterations_::32 word) = (var1::32 word) + (var2::32 word) + (var3::32 word) + (var4::32 word) - ((cat_::32 word) + (dog_::32 word) + (horse_::32 word) + (mouse_::32 word)); (0::32 word) < cat_; ¬ (0::32 word) < mouse_; ¬ horse_ < dog_; mouse_ < horse_⟧ ⟹ iterations_ = var1 + (var2 + (var3 + (var4 + (- horse_ - mouse_ - dog_ - cat_))))› 28. ‹⟦(iterations_::32 word) = (var1::32 word) + (var2::32 word) + (var3::32 word) + (var4::32 word) - ((cat_::32 word) + (dog_::32 word) + (horse_::32 word) + (mouse_::32 word)); (0::32 word) < cat_; ¬ (0::32 word) < mouse_; ¬ horse_ < dog_; mouse_ < horse_⟧ ⟹ unat (horse_ - (1::32 word)) < unat horse_› 29. ‹⟦(iterations_::32 word) = (var1::32 word) + (var2::32 word) + (var3::32 word) + (var4::32 word) - ((cat_::32 word) + (dog_::32 word) + (horse_::32 word) + (mouse_::32 word)); (0::32 word) < cat_; ¬ (0::32 word) < mouse_; ¬ horse_ < dog_; ¬ mouse_ < horse_; (0::32 word) < cat_⟧ ⟹ iterations_ = var1 + (var2 + (var3 + (var4 + (- horse_ - mouse_ - dog_ - cat_))))› 30. ‹⟦(iterations_::32 word) = (var1::32 word) + (var2::32 word) + (var3::32 word) + (var4::32 word) - ((cat_::32 word) + (dog_::32 word) + (horse_::32 word) + (mouse_::32 word)); (0::32 word) < cat_; ¬ (0::32 word) < mouse_; ¬ horse_ < dog_; ¬ mouse_ < horse_; (0::32 word) < cat_⟧ ⟹ unat (cat_ - (1::32 word)) < unat cat_› 31. ‹⟦(iterations_::32 word) = (var1::32 word) + (var2::32 word) + (var3::32 word) + (var4::32 word) - ((cat_::32 word) + (dog_::32 word) + (horse_::32 word) + (mouse_::32 word)); (0::32 word) < cat_; ¬ (0::32 word) < mouse_; ¬ horse_ < dog_; ¬ mouse_ < horse_; ¬ (0::32 word) < cat_⟧ ⟹ iterations_ = var1 + (var2 + (var3 + (var4 + (- horse_ - mouse_ - dog_ - cat_))))› 32. ‹⟦(iterations_::32 word) = (var1::32 word) + (var2::32 word) + (var3::32 word) + (var4::32 word) - ((cat_::32 word) + (dog_::32 word) + (horse_::32 word) + (mouse_::32 word)); (0::32 word) < cat_; ¬ (0::32 word) < mouse_; ¬ horse_ < dog_; ¬ mouse_ < horse_; ¬ (0::32 word) < cat_⟧ ⟹ unat (horse_ - (1::32 word)) < unat horse_› 33. ‹⟦(iterations_::32 word) = (var1::32 word) + (var2::32 word) + (var3::32 word) + (var4::32 word) - ((cat_::32 word) + (dog_::32 word) + (horse_::32 word) + (mouse_::32 word)); (0::32 word) < mouse_; (0::32 word) < mouse_; horse_ < dog_⟧ ⟹ iterations_ = var1 + (var2 + (var3 + (var4 + (- horse_ - mouse_ - dog_ - cat_))))› 34. ‹⟦(iterations_::32 word) = (var1::32 word) + (var2::32 word) + (var3::32 word) + (var4::32 word) - ((cat_::32 word) + (dog_::32 word) + (horse_::32 word) + (mouse_::32 word)); (0::32 word) < mouse_; (0::32 word) < mouse_; horse_ < dog_⟧ ⟹ unat (dog_ - (1::32 word)) < unat dog_› 35. ‹⟦(iterations_::32 word) = (var1::32 word) + (var2::32 word) + (var3::32 word) + (var4::32 word) - ((cat_::32 word) + (dog_::32 word) + (horse_::32 word) + (mouse_::32 word)); (0::32 word) < mouse_; (0::32 word) < mouse_; ¬ horse_ < dog_; mouse_ < horse_⟧ ⟹ iterations_ = var1 + (var2 + (var3 + (var4 + (- horse_ - mouse_ - dog_ - cat_))))› 36. ‹⟦(iterations_::32 word) = (var1::32 word) + (var2::32 word) + (var3::32 word) + (var4::32 word) - ((cat_::32 word) + (dog_::32 word) + (horse_::32 word) + (mouse_::32 word)); (0::32 word) < mouse_; (0::32 word) < mouse_; ¬ horse_ < dog_; mouse_ < horse_⟧ ⟹ unat (horse_ - (1::32 word)) < unat horse_› 37. ‹⟦(iterations_::32 word) = (var1::32 word) + (var2::32 word) + (var3::32 word) + (var4::32 word) - ((cat_::32 word) + (dog_::32 word) + (horse_::32 word) + (mouse_::32 word)); (0::32 word) < mouse_; (0::32 word) < mouse_; ¬ horse_ < dog_; ¬ mouse_ < horse_; (0::32 word) < cat_⟧ ⟹ iterations_ = var1 + (var2 + (var3 + (var4 + (- horse_ - mouse_ - dog_ - cat_))))› 38. ‹⟦(iterations_::32 word) = (var1::32 word) + (var2::32 word) + (var3::32 word) + (var4::32 word) - ((cat_::32 word) + (dog_::32 word) + (horse_::32 word) + (mouse_::32 word)); (0::32 word) < mouse_; (0::32 word) < mouse_; ¬ horse_ < dog_; ¬ mouse_ < horse_; (0::32 word) < cat_⟧ ⟹ unat (cat_ - (1::32 word)) < unat cat_› 39. ‹⟦(iterations_::32 word) = (var1::32 word) + (var2::32 word) + (var3::32 word) + (var4::32 word) - ((cat_::32 word) + (dog_::32 word) + (horse_::32 word) + (mouse_::32 word)); (0::32 word) < mouse_; (0::32 word) < mouse_; ¬ horse_ < dog_; ¬ mouse_ < horse_; ¬ (0::32 word) < cat_⟧ ⟹ iterations_ = var1 + (var2 + (var3 + (var4 + (- horse_ - mouse_ - dog_ - cat_))))› 40. ‹⟦(iterations_::32 word) = (var1::32 word) + (var2::32 word) + (var3::32 word) + (var4::32 word) - ((cat_::32 word) + (dog_::32 word) + (horse_::32 word) + (mouse_::32 word)); (0::32 word) < mouse_; (0::32 word) < mouse_; ¬ horse_ < dog_; ¬ mouse_ < horse_; ¬ (0::32 word) < cat_⟧ ⟹ unat (mouse_ - (1::32 word)) < unat mouse_› 41. ‹⟦(iterations_::32 word) = (var1::32 word) + (var2::32 word) + (var3::32 word) + (var4::32 word) - ((cat_::32 word) + (dog_::32 word) + (horse_::32 word) + (mouse_::32 word)); (0::32 word) < horse_; (0::32 word) < mouse_; horse_ < dog_⟧ ⟹ iterations_ = var1 + (var2 + (var3 + (var4 + (- horse_ - mouse_ - dog_ - cat_))))› 42. ‹⟦(iterations_::32 word) = (var1::32 word) + (var2::32 word) + (var3::32 word) + (var4::32 word) - ((cat_::32 word) + (dog_::32 word) + (horse_::32 word) + (mouse_::32 word)); (0::32 word) < horse_; (0::32 word) < mouse_; horse_ < dog_⟧ ⟹ unat (dog_ - (1::32 word)) < unat dog_› 43. ‹⟦(iterations_::32 word) = (var1::32 word) + (var2::32 word) + (var3::32 word) + (var4::32 word) - ((cat_::32 word) + (dog_::32 word) + (horse_::32 word) + (mouse_::32 word)); (0::32 word) < horse_; (0::32 word) < mouse_; ¬ horse_ < dog_; mouse_ < horse_⟧ ⟹ iterations_ = var1 + (var2 + (var3 + (var4 + (- horse_ - mouse_ - dog_ - cat_))))› 44. ‹⟦(iterations_::32 word) = (var1::32 word) + (var2::32 word) + (var3::32 word) + (var4::32 word) - ((cat_::32 word) + (dog_::32 word) + (horse_::32 word) + (mouse_::32 word)); (0::32 word) < horse_; (0::32 word) < mouse_; ¬ horse_ < dog_; mouse_ < horse_⟧ ⟹ unat (horse_ - (1::32 word)) < unat horse_› 45. ‹⟦(iterations_::32 word) = (var1::32 word) + (var2::32 word) + (var3::32 word) + (var4::32 word) - ((cat_::32 word) + (dog_::32 word) + (horse_::32 word) + (mouse_::32 word)); (0::32 word) < horse_; (0::32 word) < mouse_; ¬ horse_ < dog_; ¬ mouse_ < horse_; (0::32 word) < cat_⟧ ⟹ iterations_ = var1 + (var2 + (var3 + (var4 + (- horse_ - mouse_ - dog_ - cat_))))› 46. ‹⟦(iterations_::32 word) = (var1::32 word) + (var2::32 word) + (var3::32 word) + (var4::32 word) - ((cat_::32 word) + (dog_::32 word) + (horse_::32 word) + (mouse_::32 word)); (0::32 word) < horse_; (0::32 word) < mouse_; ¬ horse_ < dog_; ¬ mouse_ < horse_; (0::32 word) < cat_⟧ ⟹ unat (cat_ - (1::32 word)) < unat cat_› 47. ‹⟦(iterations_::32 word) = (var1::32 word) + (var2::32 word) + (var3::32 word) + (var4::32 word) - ((cat_::32 word) + (dog_::32 word) + (horse_::32 word) + (mouse_::32 word)); (0::32 word) < horse_; (0::32 word) < mouse_; ¬ horse_ < dog_; ¬ mouse_ < horse_; ¬ (0::32 word) < cat_⟧ ⟹ iterations_ = var1 + (var2 + (var3 + (var4 + (- horse_ - mouse_ - dog_ - cat_))))› 48. ‹⟦(iterations_::32 word) = (var1::32 word) + (var2::32 word) + (var3::32 word) + (var4::32 word) - ((cat_::32 word) + (dog_::32 word) + (horse_::32 word) + (mouse_::32 word)); (0::32 word) < horse_; (0::32 word) < mouse_; ¬ horse_ < dog_; ¬ mouse_ < horse_; ¬ (0::32 word) < cat_⟧ ⟹ unat (mouse_ - (1::32 word)) < unat mouse_› 49. ‹⟦(iterations_::32 word) = (var1::32 word) + (var2::32 word) + (var3::32 word) + (var4::32 word) - ((cat_::32 word) + (dog_::32 word) + (horse_::32 word) + (mouse_::32 word)); (0::32 word) < horse_; ¬ (0::32 word) < mouse_; horse_ < dog_⟧ ⟹ iterations_ = var1 + (var2 + (var3 + (var4 + (- horse_ - mouse_ - dog_ - cat_))))› 50. ‹⟦(iterations_::32 word) = (var1::32 word) + (var2::32 word) + (var3::32 word) + (var4::32 word) - ((cat_::32 word) + (dog_::32 word) + (horse_::32 word) + (mouse_::32 word)); (0::32 word) < horse_; ¬ (0::32 word) < mouse_; horse_ < dog_⟧ ⟹ unat (dog_ - (1::32 word)) < unat dog_› 51. ‹⟦(iterations_::32 word) = (var1::32 word) + (var2::32 word) + (var3::32 word) + (var4::32 word) - ((cat_::32 word) + (dog_::32 word) + (horse_::32 word) + (mouse_::32 word)); (0::32 word) < horse_; ¬ (0::32 word) < mouse_; ¬ horse_ < dog_; mouse_ < horse_⟧ ⟹ iterations_ = var1 + (var2 + (var3 + (var4 + (- horse_ - mouse_ - dog_ - cat_))))› 52. ‹⟦(iterations_::32 word) = (var1::32 word) + (var2::32 word) + (var3::32 word) + (var4::32 word) - ((cat_::32 word) + (dog_::32 word) + (horse_::32 word) + (mouse_::32 word)); (0::32 word) < horse_; ¬ (0::32 word) < mouse_; ¬ horse_ < dog_; mouse_ < horse_⟧ ⟹ unat (horse_ - (1::32 word)) < unat horse_› 53. ‹⟦(iterations_::32 word) = (var1::32 word) + (var2::32 word) + (var3::32 word) + (var4::32 word) - ((cat_::32 word) + (dog_::32 word) + (horse_::32 word) + (mouse_::32 word)); (0::32 word) < horse_; ¬ (0::32 word) < mouse_; ¬ horse_ < dog_; ¬ mouse_ < horse_; (0::32 word) < cat_⟧ ⟹ iterations_ = var1 + (var2 + (var3 + (var4 + (- horse_ - mouse_ - dog_ - cat_))))› 54. ‹⟦(iterations_::32 word) = (var1::32 word) + (var2::32 word) + (var3::32 word) + (var4::32 word) - ((cat_::32 word) + (dog_::32 word) + (horse_::32 word) + (mouse_::32 word)); (0::32 word) < horse_; ¬ (0::32 word) < mouse_; ¬ horse_ < dog_; ¬ mouse_ < horse_; (0::32 word) < cat_⟧ ⟹ unat (cat_ - (1::32 word)) < unat cat_› 55. ‹⟦(iterations_::32 word) = (var1::32 word) + (var2::32 word) + (var3::32 word) + (var4::32 word) - ((cat_::32 word) + (dog_::32 word) + (horse_::32 word) + (mouse_::32 word)); (0::32 word) < horse_; ¬ (0::32 word) < mouse_; ¬ horse_ < dog_; ¬ mouse_ < horse_; ¬ (0::32 word) < cat_⟧ ⟹ iterations_ = var1 + (var2 + (var3 + (var4 + (- horse_ - mouse_ - dog_ - cat_))))› 56. ‹⟦(iterations_::32 word) = (var1::32 word) + (var2::32 word) + (var3::32 word) + (var4::32 word) - ((cat_::32 word) + (dog_::32 word) + (horse_::32 word) + (mouse_::32 word)); (0::32 word) < horse_; ¬ (0::32 word) < mouse_; ¬ horse_ < dog_; ¬ mouse_ < horse_; ¬ (0::32 word) < cat_⟧ ⟹ unat (horse_ - (1::32 word)) < unat horse_› discuss goal 1*) apply ((auto simp: measure_unat (*‹?p ≠ 0 ⟹ unat (?p - 1) < unat ?p›*))[1]) (*discuss goal 2*) apply ((auto simp: measure_unat (*‹?p ≠ 0 ⟹ unat (?p - 1) < unat ?p›*))[1]) (*discuss goal 3*) apply ((auto simp: measure_unat (*‹?p ≠ 0 ⟹ unat (?p - 1) < unat ?p›*))[1]) (*discuss goal 4*) apply ((auto simp: measure_unat (*‹?p ≠ 0 ⟹ unat (?p - 1) < unat ?p›*))[1]) (*discuss goal 5*) apply ((auto simp: measure_unat (*‹?p ≠ 0 ⟹ unat (?p - 1) < unat ?p›*))[1]) (*discuss goal 6*) apply ((auto simp: measure_unat (*‹(?p::?'a word) ≠ (0::?'a word) ⟹ unat (?p - (1::?'a word)) < unat ?p›*))[1]) (*discuss goal 7*) apply ((auto simp: measure_unat (*‹(?p::?'a word) ≠ (0::?'a word) ⟹ unat (?p - (1::?'a word)) < unat ?p›*))[1]) (*discuss goal 8*) apply ((auto simp: measure_unat (*‹?p ≠ 0 ⟹ unat (?p - 1) < unat ?p›*))[1]) (*discuss goal 9*) apply ((auto simp: measure_unat (*‹?p ≠ 0 ⟹ unat (?p - 1) < unat ?p›*))[1]) (*discuss goal 10*) apply ((auto simp: measure_unat (*‹(?p::?'a::len word) ≠ (0::?'a::len word) ⟹ unat (?p - (1::?'a::len word)) < unat ?p›*))[1]) (*discuss goal 11*) apply ((auto simp: measure_unat (*‹?p ≠ 0 ⟹ unat (?p - 1) < unat ?p›*))[1]) (*discuss goal 12*) apply ((auto simp: measure_unat (*‹?p ≠ 0 ⟹ unat (?p - 1) < unat ?p›*))[1]) (*discuss goal 13*) apply ((auto simp: measure_unat (*‹?p ≠ 0 ⟹ unat (?p - 1) < unat ?p›*))[1]) (*discuss goal 14*) apply ((auto simp: measure_unat (*‹?p ≠ 0 ⟹ unat (?p - 1) < unat ?p›*))[1]) (*discuss goal 15*) apply ((auto simp: measure_unat (*‹?p ≠ 0 ⟹ unat (?p - 1) < unat ?p›*))[1]) (*discuss goal 16*) apply ((auto simp: measure_unat (*‹?p ≠ 0 ⟹ unat (?p - 1) < unat ?p›*))[1]) (*discuss goal 17*) apply ((auto simp: measure_unat (*‹?p ≠ 0 ⟹ unat (?p - 1) < unat ?p›*))[1]) (*discuss goal 18*) apply (metis measure_unat (*‹?p ≠ 0 ⟹ unat (?p - 1) < unat ?p›*) word_not_simps( (*‹¬ ?x < 0›*) 1)) (*discuss goal 19*) apply ((auto simp: measure_unat (*‹?p ≠ 0 ⟹ unat (?p - 1) < unat ?p›*))[1]) (*discuss goal 20*) apply ((auto simp: measure_unat (*‹?p ≠ 0 ⟹ unat (?p - 1) < unat ?p›*))[1]) (*discuss goal 21*) apply ((auto simp: measure_unat (*‹?p ≠ 0 ⟹ unat (?p - 1) < unat ?p›*))[1]) (*discuss goal 22*) apply ((auto simp: measure_unat (*‹?p ≠ 0 ⟹ unat (?p - 1) < unat ?p›*))[1]) (*discuss goal 23*) apply ((auto simp: measure_unat (*‹?p ≠ 0 ⟹ unat (?p - 1) < unat ?p›*))[1]) (*discuss goal 24*) apply ((auto simp: measure_unat (*‹?p ≠ 0 ⟹ unat (?p - 1) < unat ?p›*))[1]) (*discuss goal 25*) apply ((auto simp: measure_unat (*‹?p ≠ 0 ⟹ unat (?p - 1) < unat ?p›*))[1]) (*discuss goal 26*) apply (metis measure_unat (*‹?p ≠ 0 ⟹ unat (?p - 1) < unat ?p›*) word_not_simps( (*‹¬ ?x < 0›*) 1)) (*discuss goal 27*) apply ((auto simp: measure_unat (*‹?p ≠ 0 ⟹ unat (?p - 1) < unat ?p›*))[1]) (*discuss goal 28*) apply (metis measure_unat (*‹?p ≠ 0 ⟹ unat (?p - 1) < unat ?p›*) word_not_simps( (*‹¬ ?x < 0›*) 1)) (*discuss goal 29*) apply ((auto simp: measure_unat (*‹?p ≠ 0 ⟹ unat (?p - 1) < unat ?p›*))[1]) (*discuss goal 30*) apply ((auto simp: measure_unat (*‹?p ≠ 0 ⟹ unat (?p - 1) < unat ?p›*))[1]) (*discuss goal 31*) apply ((auto simp: measure_unat (*‹?p ≠ 0 ⟹ unat (?p - 1) < unat ?p›*))[1]) (*discuss goal 32*) apply ((auto simp: measure_unat (*‹?p ≠ 0 ⟹ unat (?p - 1) < unat ?p›*))[1]) (*discuss goal 33*) apply ((auto simp: measure_unat (*‹(?p::?'a word) ≠ (0::?'a word) ⟹ unat (?p - (1::?'a word)) < unat ?p›*))[1]) (*discuss goal 34*) apply ((auto simp: measure_unat (*‹?p ≠ 0 ⟹ unat (?p - 1) < unat ?p›*))[1]) (*top goal: ‹⟦(iterations_::32 word) = (var1::32 word) + (var2::32 word) + (var3::32 word) + (var4::32 word) - ((cat_::32 word) + (dog_::32 word) + (horse_::32 word) + (mouse_::32 word)); (0::32 word) < mouse_; (0::32 word) < mouse_; horse_ < dog_⟧ ⟹ unat (dog_ - (1::32 word)) < unat dog_› and 22 goals remain*) apply (metis measure_unat (*‹?p ≠ 0 ⟹ unat (?p - 1) < unat ?p›*) word_not_simps( (*‹¬ ?x < 0›*) 1)) (*discuss goal 35*) apply ((auto simp: measure_unat (*‹(?p::?'a word) ≠ (0::?'a word) ⟹ unat (?p - (1::?'a word)) < unat ?p›*))[1]) (*discuss goal 36*) apply ((auto simp: measure_unat (*‹?p ≠ 0 ⟹ unat (?p - 1) < unat ?p›*))[1]) (*discuss goal 37*) apply ((auto simp: measure_unat (*‹?p ≠ 0 ⟹ unat (?p - 1) < unat ?p›*))[1]) (*discuss goal 38*) apply ((auto simp: measure_unat (*‹?p ≠ 0 ⟹ unat (?p - 1) < unat ?p›*))[1]) (*discuss goal 39*) apply ((auto simp: measure_unat (*‹?p ≠ 0 ⟹ unat (?p - 1) < unat ?p›*))[1]) (*discuss goal 40*) apply ((auto simp: measure_unat (*‹?p ≠ 0 ⟹ unat (?p - 1) < unat ?p›*))[1]) (*discuss goal 41*) apply ((auto simp: measure_unat (*‹(?p::?'a word) ≠ (0::?'a word) ⟹ unat (?p - (1::?'a word)) < unat ?p›*))[1]) (*discuss goal 42*) apply ((auto simp: measure_unat (*‹?p ≠ 0 ⟹ unat (?p - 1) < unat ?p›*))[1]) (*discuss goal 43*) apply ((auto simp: measure_unat (*‹?p ≠ 0 ⟹ unat (?p - 1) < unat ?p›*))[1]) (*discuss goal 44*) apply ((auto simp: measure_unat (*‹(?p::?'a word) ≠ (0::?'a word) ⟹ unat (?p - (1::?'a word)) < unat ?p›*))[1]) (*discuss goal 45*) apply ((auto simp: measure_unat (*‹?p ≠ 0 ⟹ unat (?p - 1) < unat ?p›*))[1]) (*discuss goal 46*) apply ((auto simp: measure_unat (*‹?p ≠ 0 ⟹ unat (?p - 1) < unat ?p›*))[1]) (*discuss goal 47*) apply ((auto simp: measure_unat (*‹(?p::?'a word) ≠ (0::?'a word) ⟹ unat (?p - (1::?'a word)) < unat ?p›*))[1]) (*discuss goal 48*) apply ((auto simp: measure_unat (*‹?p ≠ 0 ⟹ unat (?p - 1) < unat ?p›*))[1]) (*discuss goal 49*) apply ((auto simp: measure_unat (*‹?p ≠ 0 ⟹ unat (?p - 1) < unat ?p›*))[1]) (*discuss goal 50*) apply ((auto simp: measure_unat (*‹(?p::?'a word) ≠ (0::?'a word) ⟹ unat (?p - (1::?'a word)) < unat ?p›*))[1]) (*discuss goal 51*) apply ((auto simp: measure_unat (*‹(?p::?'a::len word) ≠ (0::?'a::len word) ⟹ unat (?p - (1::?'a::len word)) < unat ?p›*))[1]) (*discuss goal 52*) apply ((auto simp: measure_unat (*‹?p ≠ 0 ⟹ unat (?p - 1) < unat ?p›*))[1]) (*discuss goal 53*) apply ((auto simp: measure_unat (*‹?p ≠ 0 ⟹ unat (?p - 1) < unat ?p›*))[1]) (*discuss goal 54*) apply ((auto simp: measure_unat (*‹?p ≠ 0 ⟹ unat (?p - 1) < unat ?p›*))[1]) (*discuss goal 55*) apply ((auto simp: measure_unat (*‹(?p::?'a::len word) ≠ (0::?'a::len word) ⟹ unat (?p - (1::?'a::len word)) < unat ?p›*))[1]) (*discuss goal 56*) apply ((auto simp: measure_unat (*‹?p ≠ 0 ⟹ unat (?p - 1) < unat ?p›*))[1]) (*proven 56 subgoals*) . . end end
{ "path": "afp-2025-02-12/thys/AutoCorres2/tests/proof-tests/WhileLoopVarsPreserved.thy", "repo": "afp-2025-02-12", "sha": "a6ee078c9c8e8470f61525ae258ae6dbec830615a4d558a9c8418427812f3e6c" }
(* Title: Miscellanneous Definitions and Lemmas Author: Peter Lammich <peter.lammich@uni-muenster.de> Maintainer: Peter Lammich <peter.lammich@uni-muenster.de> *) section ‹Miscellanneous Definitions and Lemmas› theory Misc imports Main "HOL-Library.Multiset" "HOL-Library.Subseq_Order" begin text_raw ‹\label{thy:Misc}› text ‹Here we provide a collection of miscellaneous definitions and helper lemmas› subsection "Miscellanneous (1)" text ‹This stuff is used in this theory itself, and thus occurs in first place. There is another ,,Miscellaneous''-section at the end of this theory› subsubsection "AC-operators" text ‹Locale to declare AC-laws as simplification rules› locale AC = fixes f assumes commute[simp]: "f x y = f y x" assumes assoc[simp]: "f (f x y) z = f x (f y z)" lemma (in AC) left_commute[simp]: "f x (f y z) = f y (f x z)" apply (simp only: assoc[symmetric] (*‹f ?x (f ?y ?z) = f (f ?x ?y) ?z›*)) (*goal: ‹f x (f y z) = f y (f x z)›*) by simp text ‹Locale to define functions from surjective, unique relations› locale su_rel_fun = fixes F and f assumes unique: "⟦(A,B)∈F; (A,B')∈F⟧ ⟹ B=B'" assumes surjective: "⟦!!B. (A,B)∈F ⟹ P⟧ ⟹ P" assumes f_def: "f A == THE B. (A,B)∈F" lemma (in su_rel_fun) repr1: "(A,f A)∈F" proof (unfold f_def (*‹f ?A ≡ THE B. (?A, B) ∈ F›*)) (*goal: ‹(A, THE B. (A, B) ∈ F) ∈ F›*) obtain B where "(A,B)∈F" (*goal: ‹(⋀B::'b. (A::'a, B) ∈ (F::('a × 'b) set) ⟹ thesis::bool) ⟹ thesis›*) by (rule surjective (*‹(⋀B. (?A, B) ∈ F ⟹ ?P) ⟹ ?P›*)) with theI[where P = "λB. (A,B)∈F", OF this] (*‹(⋀x. (A, x) ∈ F ⟹ x = B) ⟹ (A, THE x. (A, x) ∈ F) ∈ F›*) show "(A, THE x. (A, x) ∈ F) ∈ F" by (blast intro: unique (*‹⟦(?A, ?B) ∈ F; (?A, ?B') ∈ F⟧ ⟹ ?B = ?B'›*)) qed lemma (in su_rel_fun) repr2: "(A,B)∈F ⟹ B=f A" using repr1 (*‹(?A, f ?A) ∈ F›*) by (blast intro: unique (*‹⟦(?A, ?B) ∈ F; (?A, ?B') ∈ F⟧ ⟹ ?B = ?B'›*)) lemma (in su_rel_fun) repr: "(f A = B) = ((A,B)∈F)" using repr1 (*‹(?A, f ?A) ∈ F›*) repr2 (*‹(?A::'a::type, ?B::'b::type) ∈ (F::('a::type × 'b::type) set) ⟹ ?B = (f::'a::type ⇒ 'b::type) ?A›*) by blast subsection ‹Abbreviations for list order› abbreviation ileq :: "'a list ⇒ 'a list ⇒ bool" (infix "≼" 50) where "(≼) ≡ (≤)" abbreviation ilt :: "'a list ⇒ 'a list ⇒ bool" (infix "≺" 50) where "(≺) ≡ (<)" subsection ‹Multisets› (* The following is a syntax extension for multisets. Unfortunately, it depends on a change in the Library/Multiset.thy, so it is commented out here, until it will be incorporated into Library/Multiset.thy by its maintainers. The required change in Library/Multiset.thy is removing the syntax for single: - single :: "'a => 'a multiset" ("{#_#}") + single :: "'a => 'a multiset" And adding the following translations instead: + syntax + "_multiset" :: "args ⇒ 'a multiset" ("{#(_)#}") + translations + "{#x, xs#}" == "{#x#} + {#xs#}" + "{# x #}" == "single x" This translates "{# … #}" into a sum of singletons, that is parenthesized to the right. ?? Can we also achieve left-parenthesizing ?? *) (* Let's try what happens if declaring AC-rules for multiset union as simp-rules *) (*declare union_ac[simp] -- don't do it !*) subsubsection ‹Case distinction› lemma multiset_induct'[case_names empty add]: "⟦P {#}; ⋀M x. P M ⟹ P ({#x#}+M)⟧ ⟹ P M" apply (induct rule: multiset_induct (*‹⟦?P {#}; ⋀x M. ?P M ⟹ ?P (add_mset x M)⟧ ⟹ ?P ?M›*)) (*goals: 1. ‹⟦P {#}; ⋀M x. P M ⟹ P ({#x#} + M)⟧ ⟹ P {#}› 2. ‹⋀x M. ⟦⟦P {#}; ⋀M x. P M ⟹ P ({#x#} + M)⟧ ⟹ P M; P {#}; ⋀M x. P M ⟹ P ({#x#} + M)⟧ ⟹ P (add_mset x M)› discuss goal 1*) apply ((auto simp add: union_commute (*‹(?M::?'a multiset) + (?N::?'a multiset) = ?N + ?M›*))[1]) (*discuss goal 2*) apply ((auto simp add: union_commute (*‹?M + ?N = ?N + ?M›*))[1]) (*proven 2 subgoals*) . subsubsection ‹Count› lemma count_ne_remove: "⟦ x ~= t⟧ ⟹ count S x = count (S-{#t#}) x" by auto lemma mset_empty_count[simp]: "(∀p. count M p = 0) = (M={#})" by (auto simp add: multiset_eq_iff (*‹((?M::?'a::type multiset) = (?N::?'a::type multiset)) = (∀a::?'a::type. count ?M a = count ?N a)›*)) subsubsection ‹Union, difference and intersection› lemma size_diff_se: "⟦t ∈# S⟧ ⟹ size S = size (S - {#t#}) + 1" proof (unfold size_multiset_overloaded_eq (*‹size ?x = sum (count ?x) (set_mset ?x)›*)) (*goal: ‹t ∈# S ⟹ sum (count S) (set_mset S) = sum (count (S - {#t#})) (set_mset (S - {#t#})) + 1›*) let ?SIZE = "sum (count S) (set_mset S)" assume A: "t ∈# S" (*‹(t::'a) ∈# (S::'a multiset)›*) from A (*‹t ∈# S›*) have SPLITPRE: "finite (set_mset S) & {t}⊆(set_mset S)" by auto hence "?SIZE = sum (count S) (set_mset S - {t}) + sum (count S) {t}" by (blast dest: sum.subset_diff (*‹⟦?B ⊆ ?A; finite ?A⟧ ⟹ sum ?g ?A = sum ?g (?A - ?B) + sum ?g ?B›*)) hence "?SIZE = sum (count S) (set_mset S - {t}) + count (S) t" by auto moreover with A (*‹t ∈# S›*) have "count S t = count (S-{#t#}) t + 1" by auto ultimately have D: "?SIZE = sum (count S) (set_mset S - {t}) + count (S-{#t#}) t + 1" by arith moreover have "sum (count S) (set_mset S - {t}) = sum (count (S-{#t#})) (set_mset S - {t})" proof (-) (*goal: ‹sum (count S) (set_mset S - {t}) = sum (count (S - {#t#})) (set_mset S - {t})›*) have "ALL x:(set_mset S - {t}) . count S x = count (S-{#t#}) x" by (auto iff add: count_ne_remove (*‹?x ≠ ?t ⟹ count ?S ?x = count (?S - {#?t#}) ?x›*)) thus "?thesis" (*goal: ‹sum (count S) (set_mset S - {t}) = sum (count (S - {#t#})) (set_mset S - {t})›*) by simp qed ultimately have D: "?SIZE = sum (count (S-{#t#})) (set_mset S - {t}) + count (S-{#t#}) t + 1" by simp moreover { assume CASE: "t ∉# S - {#t#}" (*‹(t::'a) ∉# (S::'a multiset) - {#t#}›*) from CASE (*‹t ∉# S - {#t#}›*) have "set_mset S - {t} = set_mset (S - {#t#})" by (simp add: at_most_one_mset_mset_diff (*‹(?a::?'a) ∉# (?M::?'a multiset) - {#?a#} ⟹ set_mset (?M - {#?a#}) = set_mset ?M - {?a}›*)) with CASE (*‹(t::'a) ∉# (S::'a multiset) - {#t#}›*) D (*‹sum (count S) (set_mset S) = sum (count (S - {#t#})) (set_mset S - {t}) + count (S - {#t#}) t + 1›*) have "?SIZE = sum (count (S-{#t#})) (set_mset (S - {#t#})) + 1" by (simp add: not_in_iff (*‹(?x ∉# ?M) = (count ?M ?x = 0)›*)) } moreover { assume CASE: "t ∈# S - {#t#}" (*‹(t::'a) ∈# (S::'a multiset) - {#t#}›*) from CASE (*‹t ∈# S - {#t#}›*) have 1: "set_mset S = set_mset (S-{#t#})" by (rule more_than_one_mset_mset_diff [symmetric] (*‹(?a::?'a) ∈# (?M::?'a multiset) - {#?a#} ⟹ set_mset ?M = set_mset (?M - {#?a#})›*)) moreover from D (*‹sum (count (S::'a::type multiset)) (set_mset S) = sum (count (S - {#t::'a::type#})) (set_mset S - {t}) + count (S - {#t#}) t + (1::nat)›*) have "?SIZE = sum (count (S-{#t#})) (set_mset S - {t}) + sum (count (S-{#t#})) {t} + 1" by simp moreover from SPLITPRE (*‹finite (set_mset S) ∧ {t} ⊆ set_mset S›*) sum.subset_diff (*‹⟦?B ⊆ ?A; finite ?A⟧ ⟹ sum ?g ?A = sum ?g (?A - ?B) + sum ?g ?B›*) have "sum (count (S-{#t#})) (set_mset S) = sum (count (S-{#t#})) (set_mset S - {t}) + sum (count (S-{#t#})) {t}" by blast ultimately have "?SIZE = sum (count (S-{#t#})) (set_mset (S-{#t#})) + 1" by simp } ultimately show "?SIZE = sum (count (S-{#t#})) (set_mset (S - {#t#})) + 1" by blast qed (* TODO: Check whether this proof can be done simpler *) lemma mset_union_diff_comm: "t ∈# S ⟹ T + (S - {#t#}) = (T + S) - {#t#}" proof (-) (*goal: ‹(t::'a) ∈# (S::'a multiset) ⟹ (T::'a multiset) + (S - {#t#}) = T + S - {#t#}›*) assume "t ∈# S" (*‹(t::'a) ∈# (S::'a multiset)›*) then obtain S' where S: "S = add_mset t S'" (*goal: ‹(⋀S'::'a multiset. (S::'a multiset) = add_mset (t::'a) S' ⟹ thesis::bool) ⟹ thesis›*) by (metis insert_DiffM (*‹?x ∈# ?M ⟹ add_mset ?x (?M - {#?x#}) = ?M›*)) then show "?thesis" (*goal: ‹T + (S - {#t#}) = T + S - {#t#}›*) by auto qed lemma mset_right_cancel_union: "⟦a ∈# A+B; ~(a ∈# B)⟧ ⟹ a∈#A" by simp lemma mset_left_cancel_union: "⟦a ∈# A+B; ~(a ∈# A)⟧ ⟹ a∈#B" by simp lemmas mset_cancel_union = mset_right_cancel_union mset_left_cancel_union lemma mset_right_cancel_elem: "⟦a ∈# A+{#b#}; a~=b⟧ ⟹ a∈#A" apply (subgoal_tac "~(a ∈# {#b#})") (*goals: 1. ‹⟦(a::'a) ∈# (A::'a multiset) + {#b::'a#}; a ≠ b; a ∉# {#b#}⟧ ⟹ a ∈# A› 2. ‹⟦(a::'a) ∈# (A::'a multiset) + {#b::'a#}; a ≠ b⟧ ⟹ a ∉# {#b#}› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . lemma mset_left_cancel_elem: "⟦a ∈# {#b#}+A; a~=b⟧ ⟹ a∈#A" apply (subgoal_tac "~(a ∈# {#b#})") (*goals: 1. ‹⟦a ∈# {#b#} + A; a ≠ b; a ∉# {#b#}⟧ ⟹ a ∈# A› 2. ‹⟦a ∈# {#b#} + A; a ≠ b⟧ ⟹ a ∉# {#b#}› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . lemmas mset_cancel_elem = mset_right_cancel_elem mset_left_cancel_elem lemma mset_diff_cancel1elem[simp]: "~(a ∈# B) ⟹ {#a#}-B = {#a#}" proof (-) (*goal: ‹a ∉# B ⟹ {#a#} - B = {#a#}›*) assume A: "~(a ∈# B)" (*‹(a::'a) ∉# (B::'a multiset)›*) hence "count ({#a#}-B) a = count ({#a#}) a" by (auto simp add: not_in_iff (*‹((?x::?'a::type) ∉# (?M::?'a::type multiset)) = (count ?M ?x = (0::nat))›*)) moreover have "ALL e . e~=a ⟶ count ({#a#}-B) e = count ({#a#}) e" by auto ultimately show "?thesis" (*goal: ‹{#a::'a#} - (B::'a multiset) = {#a#}›*) by (auto simp add: multiset_eq_iff (*‹(?M = ?N) = (∀a. count ?M a = count ?N a)›*)) qed (*lemma union_diff_assoc_se: "t ∈# B ⟹ (A+B)-{#t#} = A + (B-{#t#})" by (auto iff add: multiset_eq_iff) lemma union_diff_assoc_se2: "t ∈# A ⟹ (A+B)-{#t#} = (A-{#t#}) + B" by (auto iff add: multiset_eq_iff) lemmas union_diff_assoc_se = union_diff_assoc_se1 union_diff_assoc_se2*) lemma union_diff_assoc: "C-B={#} ⟹ (A+B)-C = A + (B-C)" by (simp add: multiset_eq_iff (*‹(?M = ?N) = (∀a. count ?M a = count ?N a)›*)) lemma mset_union_2_elem: "{#a#}+{#b#} = M + {#c#} ⟹ {#a#}=M & b=c | a=c & {#b#}=M" by (auto simp: add_eq_conv_diff (*‹(add_mset ?a ?M = add_mset ?b ?N) = (?M = ?N ∧ ?a = ?b ∨ ?M = add_mset ?b (?N - {#?a#}) ∧ ?N = add_mset ?a (?M - {#?b#}))›*)) lemma mset_un_cases[cases set, case_names left right]: "⟦a ∈# A + B; a∈#A ⟹ P; a∈#B ⟹ P⟧ ⟹ P" by auto lemma mset_unplusm_dist_cases[cases set, case_names left right]: assumes A: "add_mset s A = B+C" assumes L: "⟦B=add_mset s (B-{#s#}); A=(B-{#s#})+C⟧ ⟹ P" assumes R: "⟦C=add_mset s (C-{#s#}); A=B+(C-{#s#})⟧ ⟹ P" shows P proof (-) (*goal: ‹P::bool›*) from A[symmetric] (*‹B + C = add_mset s A›*) have "s ∈# B+C" by simp thus "?thesis" (*goal: ‹P›*) proof (cases rule: mset_un_cases (*‹⟦?a ∈# ?A + ?B; ?a ∈# ?A ⟹ ?P; ?a ∈# ?B ⟹ ?P⟧ ⟹ ?P›*)) (*goals: 1. ‹s ∈# B ⟹ P› 2. ‹s ∈# C ⟹ P›*) case left (*‹(s::'a) ∈# (B::'a multiset)›*) hence 1: "B=add_mset s (B-{#s#})" by simp with A (*‹add_mset s A = B + C›*) have "add_mset s A = add_mset s ((B-{#s#})+C)" by (simp add: union_ac (*‹?M + ?N + ?K = ?M + (?N + ?K)› ‹?M + ?N = ?N + ?M› ‹?M + (?N + ?K) = ?N + (?M + ?K)› ‹add_mset ?x (add_mset ?y ?M) = add_mset ?y (add_mset ?x ?M)›*)) hence 2: "A = (B-{#s#})+C" by simp from L[OF 1 2] (*‹P›*) show "?thesis" (*goal: ‹P::bool›*) . next (*goal: ‹s ∈# C ⟹ P›*) case right (*‹s ∈# C›*) hence 1: "C=add_mset s (C-{#s#})" by simp with A (*‹add_mset s A = B + C›*) have "add_mset s A = add_mset s (B+(C-{#s#}))" by (simp add: union_ac (*‹?M + ?N + ?K = ?M + (?N + ?K)› ‹?M + ?N = ?N + ?M› ‹?M + (?N + ?K) = ?N + (?M + ?K)› ‹add_mset ?x (add_mset ?y ?M) = add_mset ?y (add_mset ?x ?M)›*)) hence 2: "A = B+(C-{#s#})" by simp from R[OF 1 2] (*‹P›*) show "?thesis" (*goal: ‹P›*) . qed qed lemma mset_unplusm_dist_cases2[cases set, case_names left right]: assumes A: "B+C = add_mset s A" assumes L: "⟦B=add_mset s (B-{#s#}); A=(B-{#s#})+C⟧ ⟹ P" assumes R: "⟦C=add_mset s (C-{#s#}); A=B+(C-{#s#})⟧ ⟹ P" shows P using mset_unplusm_dist_cases[OF A [ symmetric ]] (*‹⟦⟦B = add_mset s (B - {#s#}); A = B - {#s#} + C⟧ ⟹ ?P; ⟦C = add_mset s (C - {#s#}); A = B + (C - {#s#})⟧ ⟹ ?P⟧ ⟹ ?P›*) L (*‹⟦B = add_mset s (B - {#s#}); A = B - {#s#} + C⟧ ⟹ P›*) R (*‹⟦C = add_mset s (C - {#s#}); A = B + (C - {#s#})⟧ ⟹ P›*) by blast lemma mset_single_cases[cases set, case_names loc env]: assumes A: "add_mset s c = add_mset r' c'" assumes CASES: "⟦s=r'; c=c'⟧ ⟹ P" "⟦c'={#s#}+(c'-{#s#}); c={#r'#}+(c-{#r'#}); c-{#r'#} = c'-{#s#} ⟧ ⟹ P" shows "P" proof (-) (*goal: ‹P::bool›*) { assume CASE: "s=r'" (*‹(s::'a) = (r'::'a)›*) with A (*‹add_mset s c = add_mset r' c'›*) have "c=c'" by simp with CASE (*‹s = r'›*) CASES (*‹⟦s = r'; c = c'⟧ ⟹ P› ‹⟦c' = {#s#} + (c' - {#s#}); c = {#r'#} + (c - {#r'#}); c - {#r'#} = c' - {#s#}⟧ ⟹ P›*) have "?thesis" by auto } moreover { assume CASE: "s≠r'" (*‹(s::'a) ≠ (r'::'a)›*) have "s∈#{#s#}+c" by simp with A (*‹add_mset (s::'a) (c::'a multiset) = add_mset (r'::'a) (c'::'a multiset)›*) have "s ∈# {#r'#} + c'" by simp with CASE (*‹s ≠ r'›*) have "s ∈# c'" by simp from insert_DiffM[OF this, symmetric] (*‹c' = add_mset s (c' - {#s#})›*) have 1: "c' = add_mset s (c' - {#s#})" . with A (*‹add_mset s c = add_mset r' c'›*) have "{#s#}+c = {#s#}+({#r'#}+(c' - {#s#}))" by (auto simp add: union_ac (*‹(?M::?'a multiset) + (?N::?'a multiset) + (?K::?'a multiset) = ?M + (?N + ?K)› ‹(?M::?'a multiset) + (?N::?'a multiset) = ?N + ?M› ‹(?M::?'a multiset) + ((?N::?'a multiset) + (?K::?'a multiset)) = ?N + (?M + ?K)› ‹add_mset (?x::?'a) (add_mset (?y::?'a) (?M::?'a multiset)) = add_mset ?y (add_mset ?x ?M)›*)) hence 2: "c={#r'#}+(c' - {#s#})" by auto hence 3: "c-{#r'#} = (c' - {#s#})" by auto from "1" (*‹c' = add_mset s (c' - {#s#})›*) "2" (*‹c = {#r'#} + (c' - {#s#})›*) "3" (*‹c - {#r'#} = c' - {#s#}›*) CASES (*‹⟦s = r'; c = c'⟧ ⟹ P› ‹⟦(c'::'a::type multiset) = {#s::'a::type#} + (c' - {#s#}); (c::'a::type multiset) = {#r'::'a::type#} + (c - {#r'#}); c - {#r'#} = c' - {#s#}⟧ ⟹ P::bool›*) have "?thesis" by auto } ultimately show "?thesis" (*goal: ‹P›*) by blast qed lemma mset_single_cases'[cases set, case_names loc env]: assumes A: "add_mset s c = add_mset r' c'" assumes CASES: "⟦s=r'; c=c'⟧ ⟹ P" "!!cc. ⟦c'={#s#}+cc; c={#r'#}+cc; c'-{#s#}=cc; c-{#r'#}=cc⟧ ⟹ P" shows "P" using A (*‹add_mset s c = add_mset r' c'›*) CASES (*‹⟦(s::'a::type) = (r'::'a::type); (c::'a::type multiset) = (c'::'a::type multiset)⟧ ⟹ P::bool› ‹⟦c' = {#s#} + ?cc; c = {#r'#} + ?cc; c' - {#s#} = ?cc; c - {#r'#} = ?cc⟧ ⟹ P›*) by (auto elim!: mset_single_cases (*‹⟦add_mset ?s ?c = add_mset ?r' ?c'; ⟦?s = ?r'; ?c = ?c'⟧ ⟹ ?P; ⟦?c' = {#?s#} + (?c' - {#?s#}); ?c = {#?r'#} + (?c - {#?r'#}); ?c - {#?r'#} = ?c' - {#?s#}⟧ ⟹ ?P⟧ ⟹ ?P›*)) lemma mset_single_cases2[cases set, case_names loc env]: assumes A: "add_mset s c = add_mset r' c'" assumes CASES: "⟦s=r'; c=c'⟧ ⟹ P" "⟦c'=(c'-{#s#})+{#s#}; c=(c-{#r'#})+{#r'#}; c-{#r'#} = c'-{#s#} ⟧ ⟹ P" shows "P" proof (-) (*goal: ‹P›*) from A (*‹add_mset (s::'a) (c::'a multiset) = add_mset (r'::'a) (c'::'a multiset)›*) have "add_mset s c = add_mset r' c'" by simp thus "?thesis" (*goal: ‹P::bool›*) proof (cases rule: mset_single_cases (*‹⟦add_mset ?s ?c = add_mset ?r' ?c'; ⟦?s = ?r'; ?c = ?c'⟧ ⟹ ?P; ⟦?c' = {#?s#} + (?c' - {#?s#}); ?c = {#?r'#} + (?c - {#?r'#}); ?c - {#?r'#} = ?c' - {#?s#}⟧ ⟹ ?P⟧ ⟹ ?P›*)) (*goals: 1. ‹⟦s = r'; c = c'⟧ ⟹ P› 2. ‹⟦c' = {#s#} + (c' - {#s#}); c = {#r'#} + (c - {#r'#}); c - {#r'#} = c' - {#s#}⟧ ⟹ P›*) case loc (*‹s = r'› ‹c = c'›*) with CASES (*‹⟦s = r'; c = c'⟧ ⟹ P› ‹⟦c' = c' - {#s#} + {#s#}; c = c - {#r'#} + {#r'#}; c - {#r'#} = c' - {#s#}⟧ ⟹ P›*) show "?thesis" (*goal: ‹P›*) by simp next (*goal: ‹⟦c' = {#s#} + (c' - {#s#}); c = {#r'#} + (c - {#r'#}); c - {#r'#} = c' - {#s#}⟧ ⟹ P›*) case env (*‹(c'::'a multiset) = {#s::'a#} + (c' - {#s#})› ‹(c::'a::type multiset) = {#r'::'a::type#} + (c - {#r'#})› ‹(c::'a::type multiset) - {#r'::'a::type#} = (c'::'a::type multiset) - {#s::'a::type#}›*) with CASES (*‹⟦s = r'; c = c'⟧ ⟹ P› ‹⟦c' = c' - {#s#} + {#s#}; c = c - {#r'#} + {#r'#}; c - {#r'#} = c' - {#s#}⟧ ⟹ P›*) show "?thesis" (*goal: ‹P›*) by (simp add: union_ac (*‹?M + ?N + ?K = ?M + (?N + ?K)› ‹?M + ?N = ?N + ?M› ‹?M + (?N + ?K) = ?N + (?M + ?K)› ‹add_mset ?x (add_mset ?y ?M) = add_mset ?y (add_mset ?x ?M)›*)) qed qed lemma mset_single_cases2'[cases set, case_names loc env]: assumes A: "add_mset s c = add_mset r' c'" assumes CASES: "⟦s=r'; c=c'⟧ ⟹ P" "!!cc. ⟦c'=cc+{#s#}; c=cc+{#r'#}; c'-{#s#}=cc; c-{#r'#}=cc⟧ ⟹ P" shows "P" using A (*‹add_mset s c = add_mset r' c'›*) CASES (*‹⟦s = r'; c = c'⟧ ⟹ P› ‹⟦c' = ?cc + {#s#}; c = ?cc + {#r'#}; c' - {#s#} = ?cc; c - {#r'#} = ?cc⟧ ⟹ P›*) by (auto elim!: mset_single_cases2 (*‹⟦add_mset ?s ?c = add_mset ?r' ?c'; ⟦?s = ?r'; ?c = ?c'⟧ ⟹ ?P; ⟦?c' = ?c' - {#?s#} + {#?s#}; ?c = ?c - {#?r'#} + {#?r'#}; ?c - {#?r'#} = ?c' - {#?s#}⟧ ⟹ ?P⟧ ⟹ ?P›*)) lemma mset_un_single_un_cases [consumes 1, case_names left right]: assumes A: "add_mset a A = B + C" and CASES: "a ∈# B ⟹ A = (B - {#a#}) + C ⟹ P" "a ∈# C ⟹ A = B + (C - {#a#}) ⟹ P" shows P proof (-) (*goal: ‹P›*) have "a ∈# A+{#a#}" by simp with A (*‹add_mset a A = B + C›*) have "a ∈# B+C" by auto thus "?thesis" (*goal: ‹P›*) proof (cases rule: mset_un_cases (*‹⟦?a ∈# ?A + ?B; ?a ∈# ?A ⟹ ?P; ?a ∈# ?B ⟹ ?P⟧ ⟹ ?P›*)) (*goals: 1. ‹a ∈# B ⟹ P› 2. ‹a ∈# C ⟹ P›*) case left (*‹a ∈# B›*) hence "B=B-{#a#}+{#a#}" by auto with A (*‹add_mset a A = B + C›*) have "A+{#a#} = (B-{#a#})+C+{#a#}" by (auto simp add: union_ac (*‹?M + ?N + ?K = ?M + (?N + ?K)› ‹?M + ?N = ?N + ?M› ‹?M + (?N + ?K) = ?N + (?M + ?K)› ‹add_mset ?x (add_mset ?y ?M) = add_mset ?y (add_mset ?x ?M)›*)) hence "A=(B-{#a#})+C" by simp with CASES(1)[OF left] (*‹A = B - {#a#} + C ⟹ P›*) show "?thesis" (*goal: ‹P›*) by blast next (*goal: ‹a ∈# C ⟹ P›*) case right (*‹a ∈# C›*) hence "C=C-{#a#}+{#a#}" by auto with A (*‹add_mset a A = B + C›*) have "A+{#a#} = B+(C-{#a#})+{#a#}" by (auto simp add: union_ac (*‹?M + ?N + ?K = ?M + (?N + ?K)› ‹?M + ?N = ?N + ?M› ‹?M + (?N + ?K) = ?N + (?M + ?K)› ‹add_mset ?x (add_mset ?y ?M) = add_mset ?y (add_mset ?x ?M)›*)) hence "A=B+(C-{#a#})" by simp with CASES(2)[OF right] (*‹A = B + (C - {#a#}) ⟹ P›*) show "?thesis" (*goal: ‹P›*) by blast qed qed (* TODO: Can this proof be done more automatically ? *) lemma mset_distrib[consumes 1, case_names dist]: assumes A: "(A::'a multiset)+B = M+N" "!!Am An Bm Bn. ⟦A=Am+An; B=Bm+Bn; M=Am+Bm; N=An+Bn⟧ ⟹ P" shows "P" proof (-) (*goal: ‹P›*) have BN_MA: "B - N = M - A" by (metis (no_types) add_diff_cancel_right (*‹?a + ?c - (?b + ?c) = ?a - ?b›*) assms( (*‹A + B = M + N›*) 1) union_commute (*‹?M + ?N = ?N + ?M›*)) have H: "A = A∩# C + (A - C) ∩# D" if "A + B = C + D" for A :: "'a multiset" and B :: "'a multiset" and C :: "'a multiset" and D :: "'a multiset" by (metis add.commute (*‹?a + ?b = ?b + ?a›*) diff_intersect_left_idem (*‹?M - ?M ∩# ?N = ?M - ?N›*) mset_subset_eq_add_left (*‹?A ⊆# ?A + ?B›*) subset_eq_diff_conv (*‹(?A - ?C ⊆# ?B) = (?A ⊆# ?B + ?C)›*) subset_mset.add_diff_inverse (*‹?a ⊆# ?b ⟹ ?a + (?b - ?a) = ?b›*) subset_mset.inf_absorb1 (*‹?x ⊆# ?y ⟹ ?x ∩# ?y = ?x›*) subset_mset.inf_le1 (*‹?x ∩# ?y ⊆# ?x›*) that (*‹A + B = C + D›*)) have A': "A = A∩# M + (A - M) ∩# N" using A(1) (*‹A + B = M + N›*) H (*‹(?A::'a multiset) + (?B::'a multiset) = (?C::'a multiset) + (?D::'a multiset) ⟹ ?A = ?A ∩# ?C + (?A - ?C) ∩# ?D›*) by blast moreover have B': "B = (B - N) ∩# M + B∩# N" using A(1) (*‹A + B = M + N›*) H[of B A N M] (*‹B + A = N + M ⟹ B = B ∩# N + (B - N) ∩# M›*) 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 36 facts*)) moreover have "M = A ∩# M + (B - N) ∩# M" using H[of M N A B] (*‹M + N = A + B ⟹ M = M ∩# A + (M - A) ∩# B›*) BN_MA[symmetric] (*‹M - A = B - N›*) A(1) (*‹A + B = M + N›*) by (metis (no_types) diff_intersect_left_idem (*‹?M - ?M ∩# ?N = ?M - ?N›*) diff_union_cancelR (*‹?M + ?N - ?N = ?M›*) multiset_inter_commute (*‹?A ∩# ?B = ?B ∩# ?A›*) subset_mset.diff_add (*‹?a ⊆# ?b ⟹ ?b - ?a + ?a = ?b›*) subset_mset.inf.cobounded1 (*‹?a ∩# ?b ⊆# ?a›*) union_commute (*‹?M + ?N = ?N + ?M›*)) moreover have "N = (A - M) ∩# N + B ∩# N" by (metis A' (*‹A = A ∩# M + (A - M) ∩# N›*) assms( (*‹A + B = M + N›*) 1) diff_union_cancelL (*‹?N + ?M - ?N = ?M›*) inter_union_distrib_left (*‹?A ∩# ?B + ?C = (?A + ?C) ∩# (?B + ?C)›*) inter_union_distrib_right (*‹?C + ?A ∩# ?B = (?C + ?A) ∩# (?C + ?B)›*) mset_subset_eq_multiset_union_diff_commute (*‹?B ⊆# ?A ⟹ ?A - ?B + ?C = ?A + ?C - ?B›*) subset_mset.inf.cobounded1 (*‹?a ∩# ?b ⊆# ?a›*) subset_mset.inf.commute (*‹?a ∩# ?b = ?b ∩# ?a›*)) ultimately show P using A(2) (*‹⟦(A::'a multiset) = (?Am::'a multiset) + (?An::'a multiset); (B::'a multiset) = (?Bm::'a multiset) + (?Bn::'a multiset); (M::'a multiset) = ?Am + ?Bm; (N::'a multiset) = ?An + ?Bn⟧ ⟹ P::bool›*) by blast qed subsubsection ‹Singleton multisets› lemma mset_size_le1_cases[case_names empty singleton,consumes 1]: "⟦ size M ≤ Suc 0; M={#} ⟹ P; !!m. M={#m#} ⟹ P ⟧ ⟹ P" apply (cases M) (*goals: 1. ‹⟦size M ≤ Suc 0; M = {#} ⟹ P; ⋀m. M = {#m#} ⟹ P; M = {#}⟧ ⟹ P› 2. ‹⋀x N. ⟦size M ≤ Suc 0; M = {#} ⟹ P; ⋀m. M = {#m#} ⟹ P; M = add_mset x N⟧ ⟹ P› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . lemma diff_union_single_conv2: "a ∈# J ⟹ J + I - {#a#} = (J - {#a#}) + I" using diff_union_single_conv[of a J I] (*‹a ∈# J ⟹ I + J - {#a#} = I + (J - {#a#})›*) by (simp add: union_ac (*‹?M + ?N + ?K = ?M + (?N + ?K)› ‹?M + ?N = ?N + ?M› ‹?M + (?N + ?K) = ?N + (?M + ?K)› ‹add_mset ?x (add_mset ?y ?M) = add_mset ?y (add_mset ?x ?M)›*)) lemmas diff_union_single_convs = diff_union_single_conv diff_union_single_conv2 lemma mset_contains_eq: "(m ∈# M) = ({#m#}+(M-{#m#})=M)" proof (auto) (*goal: ‹add_mset m (M - {#m#}) = M ⟹ m ∈# M›*) assume "add_mset m (M - {#m#}) = M" (*‹add_mset (m::'a) ((M::'a multiset) - {#m#}) = M›*) moreover have "m ∈# {#m#} + (M - {#m#})" by simp ultimately show "m ∈# M" by simp qed subsubsection ‹Pointwise ordering› lemma mset_le_incr_right1: "(a::'a multiset)⊆#b ⟹ a⊆#b+c" using mset_subset_eq_mono_add[of a b "{#}" c, simplified] (*‹a ⊆# b ⟹ a ⊆# b + c›*) . lemma mset_le_incr_right2: "(a::'a multiset)⊆#b ⟹ a⊆#c+b" using mset_le_incr_right1 (*‹?a ⊆# ?b ⟹ ?a ⊆# ?b + ?c›*) by (auto simp add: union_commute (*‹?M + ?N = ?N + ?M›*)) lemmas mset_le_incr_right = mset_le_incr_right1 mset_le_incr_right2 lemma mset_le_decr_left1: "(a::'a multiset)+c⊆#b ⟹ a⊆#b" using mset_le_incr_right1 (*‹?a ⊆# ?b ⟹ ?a ⊆# ?b + ?c›*) mset_subset_eq_mono_add_right_cancel (*‹((?A::?'a::type multiset) + (?C::?'a::type multiset) ⊆# (?B::?'a::type multiset) + ?C) = (?A ⊆# ?B)›*) by blast lemma mset_le_decr_left2: "c+(a::'a multiset)⊆#b ⟹ a⊆#b" using mset_le_decr_left1 (*‹(?a::?'a multiset) + (?c::?'a multiset) ⊆# (?b::?'a multiset) ⟹ ?a ⊆# ?b›*) by (auto simp add: union_ac (*‹?M + ?N + ?K = ?M + (?N + ?K)› ‹?M + ?N = ?N + ?M› ‹?M + (?N + ?K) = ?N + (?M + ?K)› ‹add_mset ?x (add_mset ?y ?M) = add_mset ?y (add_mset ?x ?M)›*)) lemma mset_le_add_mset_decr_left1: "add_mset c a⊆#(b::'a multiset) ⟹ a⊆#b" by (simp add: mset_subset_eq_insertD (*‹add_mset ?x ?A ⊆# ?B ⟹ ?x ∈# ?B ∧ ?A ⊂# ?B›*) subset_mset.dual_order.strict_implies_order (*‹?b ⊂# ?a ⟹ ?b ⊆# ?a›*)) lemma mset_le_add_mset_decr_left2: "add_mset c a⊆#(b::'a multiset) ⟹ {#c#}⊆#b" by (simp add: mset_subset_eq_insertD (*‹add_mset ?x ?A ⊆# ?B ⟹ ?x ∈# ?B ∧ ?A ⊂# ?B›*) subset_mset.dual_order.strict_implies_order (*‹?b ⊂# ?a ⟹ ?b ⊆# ?a›*)) lemmas mset_le_decr_left = mset_le_decr_left1 mset_le_decr_left2 mset_le_add_mset_decr_left1 mset_le_add_mset_decr_left2 lemma mset_le_subtract: "(A::'a multiset)⊆#B ⟹ A-C ⊆# B-C" sorry lemma mset_union_subset: "(A::'a multiset)+B ⊆# C ⟹ A⊆#C ∧ B⊆#C" by (auto dest: mset_le_decr_left (*‹?a + ?c ⊆# ?b ⟹ ?a ⊆# ?b› ‹?c + ?a ⊆# ?b ⟹ ?a ⊆# ?b› ‹add_mset ?c ?a ⊆# ?b ⟹ ?a ⊆# ?b› ‹add_mset ?c ?a ⊆# ?b ⟹ {#?c#} ⊆# ?b›*)) lemma mset_le_add_mset: "add_mset x B ⊆# C ⟹ {#x#}⊆#C ∧ B⊆#(C::'a multiset)" by (auto dest: mset_le_decr_left (*‹?a + ?c ⊆# ?b ⟹ ?a ⊆# ?b› ‹?c + ?a ⊆# ?b ⟹ ?a ⊆# ?b› ‹add_mset ?c ?a ⊆# ?b ⟹ ?a ⊆# ?b› ‹add_mset ?c ?a ⊆# ?b ⟹ {#?c#} ⊆# ?b›*)) lemma mset_le_subtract_left: "(A::'a multiset)+B ⊆# X ⟹ B ⊆# X-A ∧ A⊆#X" by (auto dest: mset_le_subtract[of "A+B" "X" "A"] (*‹A + B ⊆# X ⟹ A + B - A ⊆# X - A›*) mset_union_subset (*‹?A + ?B ⊆# ?C ⟹ ?A ⊆# ?C ∧ ?B ⊆# ?C›*)) lemma mset_le_subtract_right: "(A::'a multiset)+B ⊆# X ⟹ A ⊆# X-B ∧ B⊆#X" by (auto dest: mset_le_subtract[of "A+B" "X" "B"] (*‹(A::'a multiset) + (B::'a multiset) ⊆# (X::'a multiset) ⟹ A + B - B ⊆# X - B›*) mset_union_subset (*‹(?A::?'a multiset) + (?B::?'a multiset) ⊆# (?C::?'a multiset) ⟹ ?A ⊆# ?C ∧ ?B ⊆# ?C›*)) lemma mset_le_subtract_add_mset_left: "add_mset x B ⊆# (X::'a multiset) ⟹ B ⊆# X-{#x#} ∧ {#x#}⊆#X" by (auto dest: mset_le_subtract[of "add_mset x B" "X" "{#x#}"] (*‹add_mset x B ⊆# X ⟹ add_mset x B - {#x#} ⊆# X - {#x#}›*) mset_le_add_mset (*‹add_mset ?x ?B ⊆# ?C ⟹ {#?x#} ⊆# ?C ∧ ?B ⊆# ?C›*)) lemma mset_le_subtract_add_mset_right: "add_mset x B ⊆# (X::'a multiset) ⟹ {#x#} ⊆# X-B ∧ B⊆#X" by (auto dest: mset_le_subtract[of "add_mset x B" "X" "B"] (*‹add_mset x B ⊆# X ⟹ add_mset x B - B ⊆# X - B›*) mset_le_add_mset (*‹add_mset ?x ?B ⊆# ?C ⟹ {#?x#} ⊆# ?C ∧ ?B ⊆# ?C›*)) lemma mset_le_addE: "⟦ (xs::'a multiset) ⊆# ys; !!zs. ys=xs+zs ⟹ P ⟧ ⟹ P" using mset_subset_eq_exists_conv (*‹((?A::?'a multiset) ⊆# (?B::?'a multiset)) = (∃C::?'a multiset. ?B = ?A + C)›*) by blast declare subset_mset.diff_add[simp, intro] lemma mset_2dist2_cases: assumes A: "{#a, b#} ⊆# A + B" assumes CASES: "{#a, b#} ⊆# A ⟹ P" "{#a, b#} ⊆# B ⟹ P" "a ∈# A ⟹ b ∈# B ⟹ P" "a ∈# B ⟹ b ∈# A ⟹ P" shows "P" proof (-) (*goal: ‹P›*) from A (*‹{#a, b#} ⊆# A + B›*) have "count A a + count B a ≥ 1" "count A b + count B b ≥ 1" using mset_subset_eq_count[of "{#a, b#}" "A + B" a] (*‹{#a::'a, b::'a#} ⊆# (A::'a multiset) + (B::'a multiset) ⟹ count {#a, b#} a ≤ count (A + B) a›*) mset_subset_eq_count[of "{#a, b#}" "A + B" b] (*‹{#a, b#} ⊆# A + B ⟹ count {#a, b#} b ≤ count (A + B) b›*) apply - (*goals: 1. ‹⟦{#a, b#} ⊆# A + B; {#a, b#} ⊆# A + B ⟹ count {#a, b#} a ≤ count (A + B) a; {#a, b#} ⊆# A + B ⟹ count {#a, b#} b ≤ count (A + B) b⟧ ⟹ 1 ≤ count A a + count B a› 2. ‹⟦{#a, b#} ⊆# A + B; {#a, b#} ⊆# A + B ⟹ count {#a, b#} a ≤ count (A + B) a; {#a, b#} ⊆# A + B ⟹ count {#a, b#} b ≤ count (A + B) b⟧ ⟹ 1 ≤ count A b + count B b› 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 have B: "a ∈# A ∨ a ∈# B" "b ∈# A ∨ b ∈# B" apply - (*goals: 1. ‹⟦1 ≤ count A a + count B a; 1 ≤ count A b + count B b⟧ ⟹ a ∈# A ∨ a ∈# B› 2. ‹⟦1 ≤ count A a + count B a; 1 ≤ count A b + count B b⟧ ⟹ b ∈# A ∨ b ∈# B› discuss goal 1*) apply ((auto simp add: not_in_iff (*‹(?x ∉# ?M) = (count ?M ?x = 0)›*) Suc_le_eq (*‹(Suc ?m ≤ ?n) = (?m < ?n)›*))[1]) (*discuss goal 2*) apply ((auto simp add: not_in_iff (*‹(?x ∉# ?M) = (count ?M ?x = 0)›*) Suc_le_eq (*‹(Suc ?m ≤ ?n) = (?m < ?n)›*))[1]) (*proven 2 subgoals*) . { assume C: "a ∈# A" "b ∈# A - {#a#}" (*‹(a::'a) ∈# (A::'a multiset)› ‹(b::'a) ∈# (A::'a multiset) - {#a::'a#}›*) with mset_subset_eq_mono_add[of "{#a#}" "{#a#}" "{#b#}" "A-{#a#}"] (*‹⟦{#a::'a#} ⊆# {#a#}; {#b::'a#} ⊆# (A::'a multiset) - {#a#}⟧ ⟹ {#a#} + {#b#} ⊆# {#a#} + (A - {#a#})›*) have "{#a, b#} ⊆# A" by (auto simp: add_mset_commute (*‹add_mset ?x (add_mset ?y ?M) = add_mset ?y (add_mset ?x ?M)›*)) } moreover { assume C: "a ∈# A" "b ∉# A - {#a#}" (*‹(a::'a) ∈# (A::'a multiset)› ‹(b::'a) ∉# (A::'a multiset) - {#a::'a#}›*) with B (*‹(a::'a::type) ∈# (A::'a::type multiset) ∨ a ∈# (B::'a::type multiset)› ‹b ∈# A ∨ b ∈# B›*) A (*‹{#a, b#} ⊆# A + B›*) have "b ∈# B" by (auto simp: insert_subset_eq_iff (*‹(add_mset (?a::?'a::type) (?A::?'a::type multiset) ⊆# (?B::?'a::type multiset)) = (?a ∈# ?B ∧ ?A ⊆# ?B - {#?a#})›*) diff_union_single_convs (*‹(?a::?'a::type) ∈# (?J::?'a::type multiset) ⟹ (?I::?'a::type multiset) + ?J - {#?a#} = ?I + (?J - {#?a#})› ‹(?a::?'a::type) ∈# (?J::?'a::type multiset) ⟹ ?J + (?I::?'a::type multiset) - {#?a#} = ?J - {#?a#} + ?I›*) simp del: subset_mset.add_diff_assoc2 (*‹(?a::?'a::type multiset) ⊆# (?b::?'a::type multiset) ⟹ ?b - ?a + (?c::?'a::type multiset) = ?b + ?c - ?a›*)) } moreover { assume C: "a ∉# A" "b ∈# B - {#a#}" (*‹(a::'a) ∉# (A::'a multiset)› ‹(b::'a) ∈# (B::'a multiset) - {#a::'a#}›*) with A (*‹{#a, b#} ⊆# A + B›*) have "a ∈# B" using B (*‹a ∈# A ∨ a ∈# B› ‹b ∈# A ∨ b ∈# B›*) by blast with C (*‹a ∉# A› ‹b ∈# B - {#a#}›*) mset_subset_eq_mono_add[of "{#a#}" "{#a#}" "{#b#}" "B-{#a#}"] (*‹⟦{#a#} ⊆# {#a#}; {#b#} ⊆# B - {#a#}⟧ ⟹ {#a#} + {#b#} ⊆# {#a#} + (B - {#a#})›*) have "{#a, b#} ⊆# B" by (auto simp: add_mset_commute (*‹add_mset (?x::?'a) (add_mset (?y::?'a) (?M::?'a multiset)) = add_mset ?y (add_mset ?x ?M)›*)) } moreover { assume C: "a ∉# A" "b ∉# B - {#a#}" (*‹(a::'a) ∉# (A::'a multiset)› ‹(b::'a) ∉# (B::'a multiset) - {#a::'a#}›*) with A (*‹{#a::'a, b::'a#} ⊆# (A::'a multiset) + (B::'a multiset)›*) have "a ∈# B ∧ b ∈# A" apply ((intro conjI (*‹⟦?P; ?Q⟧ ⟹ ?P ∧ ?Q›*))[1]) (*goals: 1. ‹⟦{#a, b#} ⊆# A + B; a ∉# A; b ∉# B - {#a#}⟧ ⟹ a ∈# B› 2. ‹⟦{#a, b#} ⊆# A + B; a ∉# A; b ∉# B - {#a#}⟧ ⟹ b ∈# A› discuss goal 1*) apply ((auto dest!: mset_subset_eq_insertD (*‹add_mset ?x ?A ⊆# ?B ⟹ ?x ∈# ?B ∧ ?A ⊂# ?B›*) simp: insert_union_subset_iff (*‹(add_mset ?a ?A ⊂# ?B) = (?a ∈# ?B ∧ ?A ⊂# ?B - {#?a#})›*))[1]) (*discuss goal 2*) apply ((metis (no_types, lifting) B( (*‹a ∈# A ∨ a ∈# B›*) 1) add_mset_remove_trivial (*‹add_mset ?x ?M - {#?x#} = ?M›*) insert_DiffM2 (*‹?x ∈# ?M ⟹ ?M - {#?x#} + {#?x#} = ?M›*) mset_diff_cancel1elem (*‹?a ∉# ?B ⟹ {#?a#} - ?B = {#?a#}›*) single_subset_iff (*‹({#?a#} ⊆# ?M) = (?a ∈# ?M)›*) subset_eq_diff_conv (*‹(?A - ?C ⊆# ?B) = (?A ⊆# ?B + ?C)›*) subset_mset.diff_diff_right (*‹?a ⊆# ?b ⟹ ?c - (?b - ?a) = ?c + ?a - ?b›*) union_single_eq_member (*‹add_mset ?x ?M = ?N ⟹ ?x ∈# ?N›*))[1]) (*proven 2 subgoals*) . } ultimately show P using CASES (*‹{#a, b#} ⊆# A ⟹ P› ‹{#a::'a, b::'a#} ⊆# (B::'a multiset) ⟹ P::bool› ‹⟦a ∈# A; b ∈# B⟧ ⟹ P› ‹⟦a ∈# B; b ∈# A⟧ ⟹ P›*) by blast qed lemma mset_union_subset_s: "{#a#}+B ⊆# C ⟹ a ∈# C ∧ B ⊆# C" apply (drule mset_union_subset (*‹(?A::?'a multiset) + (?B::?'a multiset) ⊆# (?C::?'a multiset) ⟹ ?A ⊆# ?C ∧ ?B ⊆# ?C›*)) (*goal: ‹{#a#} + B ⊆# C ⟹ a ∈# C ∧ B ⊆# C›*) by simp lemma mset_le_single_cases[consumes 1, case_names empty singleton]: "⟦M⊆#{#a#}; M={#} ⟹ P; M={#a#} ⟹ P⟧ ⟹ P" apply (induct M) (*goals: 1. ‹⟦{#} ⊆# {#a#}; {#} = {#} ⟹ P; {#} = {#a#} ⟹ P⟧ ⟹ P› 2. ‹⋀x M. ⟦⟦M ⊆# {#a#}; M = {#} ⟹ P; M = {#a#} ⟹ P⟧ ⟹ P; add_mset x M ⊆# {#a#}; add_mset x M = {#} ⟹ P; add_mset x M = {#a#} ⟹ P⟧ ⟹ P› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . lemma mset_le_distrib[consumes 1, case_names dist]: "⟦X⊆#(A::'a multiset)+B; !!Xa Xb. ⟦X=Xa+Xb; Xa⊆#A; Xb⊆#B⟧ ⟹ P ⟧ ⟹ P" sorry lemma mset_le_mono_add_single: "⟦a ∈# ys; b ∈# ws⟧ ⟹ {#a, b#} ⊆# ys + ws" using mset_subset_eq_mono_add[of "{#a#}" _ "{#b#}", simplified] (*‹⟦a ∈# ?B; b ∈# ?D⟧ ⟹ {#b, a#} ⊆# ?B + ?D›*) by (simp add: add_mset_commute (*‹add_mset ?x (add_mset ?y ?M) = add_mset ?y (add_mset ?x ?M)›*)) lemma mset_size1elem: "⟦size P ≤ 1; q ∈# P⟧ ⟹ P={#q#}" by (auto elim: mset_size_le1_cases (*‹⟦size ?M ≤ Suc 0; ?M = {#} ⟹ ?P; ⋀m. ?M = {#m#} ⟹ ?P⟧ ⟹ ?P›*)) lemma mset_size2elem: "⟦size P ≤ 2; {#q#}+{#q'#} ⊆# P⟧ ⟹ P={#q#}+{#q'#}" by (auto elim: mset_le_addE (*‹⟦?xs ⊆# ?ys; ⋀zs. ?ys = ?xs + zs ⟹ ?P⟧ ⟹ ?P›*)) subsubsection ‹Image under function› notation image_mset (infixr "`#" 90) lemma mset_map_single_rightE[consumes 1, case_names orig]: "⟦f `# P = {#y#}; !!x. ⟦ P={#x#}; f x = y ⟧ ⟹ Q ⟧ ⟹ Q" apply (cases P) (*goals: 1. ‹⟦f `# P = {#y#}; ⋀x. ⟦P = {#x#}; f x = y⟧ ⟹ Q; P = {#}⟧ ⟹ Q› 2. ‹⋀x N. ⟦f `# P = {#y#}; ⋀x. ⟦P = {#x#}; f x = y⟧ ⟹ Q; P = add_mset x N⟧ ⟹ Q› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . lemma mset_map_split_orig: "!!M1 M2. ⟦f `# P = M1+M2; !!P1 P2. ⟦P=P1+P2; f `# P1 = M1; f `# P2 = M2⟧ ⟹ Q ⟧ ⟹ Q" apply (induct P) (*goals: 1. ‹⋀M1 M2. ⟦f `# {#} = M1 + M2; ⋀P1 P2. ⟦{#} = P1 + P2; f `# P1 = M1; f `# P2 = M2⟧ ⟹ Q⟧ ⟹ Q› 2. ‹⋀x P M1 M2. ⟦⋀M1 M2. ⟦f `# P = M1 + M2; ⋀P1 P2. ⟦P = P1 + P2; f `# P1 = M1; f `# P2 = M2⟧ ⟹ Q⟧ ⟹ Q; f `# add_mset x P = M1 + M2; ⋀P1 P2. ⟦add_mset x P = P1 + P2; f `# P1 = M1; f `# P2 = M2⟧ ⟹ Q⟧ ⟹ Q› discuss goal 1*) apply fastforce (*discuss goal 2*) apply (force elim!: mset_un_single_un_cases (*‹⟦add_mset (?a::?'a::type) (?A::?'a::type multiset) = (?B::?'a::type multiset) + (?C::?'a::type multiset); ⟦?a ∈# ?B; ?A = ?B - {#?a#} + ?C⟧ ⟹ ?P::bool; ⟦?a ∈# ?C; ?A = ?B + (?C - {#?a#})⟧ ⟹ ?P⟧ ⟹ ?P›*) simp add: union_ac (*‹(?M::?'a::type multiset) + (?N::?'a::type multiset) + (?K::?'a::type multiset) = ?M + (?N + ?K)› ‹(?M::?'a::type multiset) + (?N::?'a::type multiset) = ?N + ?M› ‹(?M::?'a::type multiset) + ((?N::?'a::type multiset) + (?K::?'a::type multiset)) = ?N + (?M + ?K)› ‹add_mset (?x::?'a::type) (add_mset (?y::?'a::type) (?M::?'a::type multiset)) = add_mset ?y (add_mset ?x ?M)›*)) (*proven 2 subgoals*) . lemma mset_map_id: "⟦!!x. f (g x) = x⟧ ⟹ f `# g `# X = X" apply (induct X) (*goals: 1. ‹(⋀x::'a. (f::'b ⇒ 'a) ((g::'a ⇒ 'b) x) = x) ⟹ f `# g `# {#} = {#}› 2. ‹⋀(x::'a) X::'a multiset. ⟦(⋀x::'a. (f::'b ⇒ 'a) ((g::'a ⇒ 'b) x) = x) ⟹ f `# g `# X = X; ⋀x::'a. f (g x) = x⟧ ⟹ f `# g `# add_mset x X = add_mset x X› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . text ‹The following is a very specialized lemma. Intuitively, it splits the original multiset› text ‹The following is a very specialized by a splitting of some pointwise supermultiset of its image. Application: This lemma came in handy when proving the correctness of a constraint system that collects at most k sized submultisets of the sets of spawned threads. › lemma mset_map_split_orig_le: assumes A: "f `# P ⊆# M1+M2" and EX: "!!P1 P2. ⟦P=P1+P2; f `# P1 ⊆# M1; f `# P2 ⊆# M2⟧ ⟹ Q" shows "Q" using A (*‹(f::'b ⇒ 'a) `# (P::'b multiset) ⊆# (M1::'a multiset) + (M2::'a multiset)›*) EX (*‹⟦(P::'b multiset) = (?P1.0::'b multiset) + (?P2.0::'b multiset); (f::'b ⇒ 'a) `# ?P1.0 ⊆# (M1::'a multiset); f `# ?P2.0 ⊆# (M2::'a multiset)⟧ ⟹ Q::bool›*) by (auto elim: mset_le_distrib (*‹⟦?X ⊆# ?A + ?B; ⋀Xa Xb. ⟦?X = Xa + Xb; Xa ⊆# ?A; Xb ⊆# ?B⟧ ⟹ ?P⟧ ⟹ ?P›*) mset_map_split_orig (*‹⟦?f `# ?P = ?M1.0 + ?M2.0; ⋀P1 P2. ⟦?P = P1 + P2; ?f `# P1 = ?M1.0; ?f `# P2 = ?M2.0⟧ ⟹ ?Q⟧ ⟹ ?Q›*)) subsection ‹Lists› subsubsection ‹Reverse lists› lemma list_rev_decomp[rule_format]: "l~=[] ⟶ (EX ll e . l = ll@[e])" apply (induct_tac l) (*goals: 1. ‹[] ≠ [] ⟶ (∃ll e. [] = ll @ [e])› 2. ‹⋀a list. list ≠ [] ⟶ (∃ll e. list = ll @ [e]) ⟹ a # list ≠ [] ⟶ (∃ll e. a # list = ll @ [e])› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . (* Was already there as rev_induct lemma list_rev_induct: "⟦P []; !! l e . P l ⟹ P (l@[e]) ⟧ ⟹ P l" by (blast intro: rev_induct) proof (induct l rule: measure_induct[of length]) fix x :: "'a list" assume A: "∀y. length y < length x ⟶ P [] ⟶ (∀x xa. P (x::'a list) ⟶ P (x @ [xa])) ⟶ P y" "P []" and IS: "⋀l e. P l ⟹ P (l @ [e])" show "P x" proof (cases "x=[]") assume "x=[]" with A show ?thesis by simp next assume CASE: "x~=[]" then obtain xx e where DECOMP: "x=xx@[e]" by (blast dest: list_rev_decomp) hence LEN: "length xx < length x" by auto with A IS have "P xx" by auto with IS have "P (xx@[e])" by auto with DECOMP show ?thesis by auto qed qed *) text ‹Caution: Same order of case variables in snoc-case as @{thm [source] rev_exhaust}, the other way round than @{thm [source] rev_induct} !› lemma length_compl_rev_induct[case_names Nil snoc]: "⟦P []; !! l e . ⟦!! ll . length ll <= length l ⟹ P ll⟧ ⟹ P (l@[e])⟧ ⟹ P l" apply (induct_tac l rule: length_induct) (*goal: ‹⟦P []; ⋀l e. (⋀ll. length ll ≤ length l ⟹ P ll) ⟹ P (l @ [e])⟧ ⟹ P l›*) apply (case_tac "xs" rule: rev_cases) (*goals: 1. ‹⋀xs::'a list. ⟦(P::'a list ⇒ bool) []; ⋀(l::'a list) e::'a. (⋀ll::'a list. length ll ≤ length l ⟹ P ll) ⟹ P (l @ [e]); ∀ys::'a list. length ys < length xs ⟶ P ys; xs = []⟧ ⟹ P xs› 2. ‹⋀(xs::'a list) (ys::'a list) y::'a. ⟦(P::'a list ⇒ bool) []; ⋀(l::'a list) e::'a. (⋀ll::'a list. length ll ≤ length l ⟹ P ll) ⟹ P (l @ [e]); ∀ys::'a list. length ys < length xs ⟶ P ys; xs = ys @ [y]⟧ ⟹ P xs› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . lemma list_append_eq_Cons_cases: "⟦ys@zs = x#xs; ⟦ys=[]; zs=x#xs⟧ ⟹ P; !!ys'. ⟦ ys=x#ys'; ys'@zs=xs ⟧ ⟹ P ⟧ ⟹ P" by (auto iff add: append_eq_Cons_conv (*‹(?ys @ ?zs = ?x # ?xs) = (?ys = [] ∧ ?zs = ?x # ?xs ∨ (∃ys'. ?ys = ?x # ys' ∧ ys' @ ?zs = ?xs))›*)) lemma list_Cons_eq_append_cases: "⟦x#xs = ys@zs; ⟦ys=[]; zs=x#xs⟧ ⟹ P; !!ys'. ⟦ ys=x#ys'; ys'@zs=xs ⟧ ⟹ P ⟧ ⟹ P" by (auto iff add: Cons_eq_append_conv (*‹(?x # ?xs = ?ys @ ?zs) = (?ys = [] ∧ ?x # ?xs = ?zs ∨ (∃ys'. ?x # ys' = ?ys ∧ ?xs = ys' @ ?zs))›*)) subsubsection "folding" text "Ugly lemma about foldl over associative operator with left and right neutral element" lemma foldl_A1_eq: "!!i. ⟦ !! e. f n e = e; !! e. f e n = e; !!a b c. f a (f b c) = f (f a b) c ⟧ ⟹ foldl f i ww = f i (foldl f n ww)" proof (induct ww) (*goals: 1. ‹⋀i. ⟦⋀e. f n e = e; ⋀e. f e n = e; ⋀a b c. f a (f b c) = f (f a b) c⟧ ⟹ foldl f i [] = f i (foldl f n [])› 2. ‹⋀a ww i. ⟦⋀i. ⟦⋀e. f n e = e; ⋀e. f e n = e; ⋀a b c. f a (f b c) = f (f a b) c⟧ ⟹ foldl f i ww = f i (foldl f n ww); ⋀e. f n e = e; ⋀e. f e n = e; ⋀a b c. f a (f b c) = f (f a b) c⟧ ⟹ foldl f i (a # ww) = f i (foldl f n (a # ww))›*) case Nil (*‹f n ?e = ?e› ‹f ?e n = ?e› ‹f ?a (f ?b ?c) = f (f ?a ?b) ?c›*) thus "?case" (*goal: ‹foldl f i [] = f i (foldl f n [])›*) by simp next (*goal: ‹⋀(a::'a::type) (ww::'a::type list) i::'a::type. ⟦⋀i::'a::type. ⟦⋀e::'a::type. (f::'a::type ⇒ 'a::type ⇒ 'a::type) (n::'a::type) e = e; ⋀e::'a::type. f e n = e; ⋀(a::'a::type) (b::'a::type) c::'a::type. f a (f b c) = f (f a b) c⟧ ⟹ foldl f i ww = f i (foldl f n ww); ⋀e::'a::type. f n e = e; ⋀e::'a::type. f e n = e; ⋀(a::'a::type) (b::'a::type) c::'a::type. f a (f b c) = f (f a b) c⟧ ⟹ foldl f i (a # ww) = f i (foldl f n (a # ww))›*) case (Cons a ww i) (*‹⟦⋀e. f n e = e; ⋀e. f e n = e; ⋀a b c. f a (f b c) = f (f a b) c⟧ ⟹ foldl f ?i ww = f ?i (foldl f n ww)› ‹f n ?e = ?e› ‹f ?e n = ?e› ‹f ?a (f ?b ?c) = f (f ?a ?b) ?c›*) note IHP[simplified] = this (*‹⟦⋀e. f n e = e; ⋀e. f e n = e; ⋀a b c. f a (f b c) = f (f a b) c⟧ ⟹ foldl f ?i ww = f ?i (foldl f n ww)› ‹f n ?e = ?e› ‹f ?e n = ?e› ‹f ?a (f ?b ?c) = f (f ?a ?b) ?c›*) have "foldl f i (a # ww) = foldl f (f i a) ww" by simp also (*calculation: ‹foldl f i (a # ww) = foldl f (f i a) ww›*) from IHP (*‹⟦⋀e. f n e = e; ⋀e. f e n = e; ⋀a b c. f a (f b c) = f (f a b) c⟧ ⟹ foldl f ?i ww = f ?i (foldl f n ww)› ‹f n ?e = ?e› ‹f ?e n = ?e› ‹(f::'a ⇒ 'a ⇒ 'a) (?a::'a) (f (?b::'a) (?c::'a)) = f (f ?a ?b) ?c›*) have "… = f (f i a) (foldl f n ww)" by blast also (*calculation: ‹foldl f i (a # ww) = f (f i a) (foldl f n ww)›*) from IHP(4) (*‹(f::'a ⇒ 'a ⇒ 'a) (?a::'a) (f (?b::'a) (?c::'a)) = f (f ?a ?b) ?c›*) have "… = f i (f a (foldl f n ww))" by simp also (*calculation: ‹foldl f i (a # ww) = f i (f a (foldl f n ww))›*) from IHP(1)[OF IHP ( 2 , 3 , 4 ), where i = a] (*‹foldl f a ww = f a (foldl f n ww)›*) have "… = f i (foldl f a ww)" by simp also (*calculation: ‹foldl (f::'a ⇒ 'a ⇒ 'a) (i::'a) ((a::'a) # (ww::'a list)) = f i (foldl f a ww)›*) from IHP(2)[of a] (*‹f n a = a›*) have "… = f i (foldl f (f n a) ww)" by simp also (*calculation: ‹foldl f i (a # ww) = f i (foldl f (f n a) ww)›*) have "… = f i (foldl f n (a#ww))" by simp finally (*calculation: ‹foldl f i (a # ww) = f i (foldl f n (a # ww))›*) show "?case" (*goal: ‹foldl f i (a # ww) = f i (foldl f n (a # ww))›*) . qed lemmas foldl_conc_empty_eq = foldl_A1_eq[of "(@)" "[]", simplified] lemmas foldl_un_empty_eq = foldl_A1_eq[of "(∪)" "{}", simplified, OF Un_assoc[symmetric]] lemma foldl_set: "foldl (∪) {} l = ⋃{x. x∈set l}" apply (induct l) (*goals: 1. ‹foldl (∪) {} [] = ⋃ {x. x ∈ set []}› 2. ‹⋀a l. foldl (∪) {} l = ⋃ {x. x ∈ set l} ⟹ foldl (∪) {} (a # l) = ⋃ {x. x ∈ set (a # l)}› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*goal: ‹⋀a l. foldl (∪) {} l = ⋃ {x. x ∈ set l} ⟹ foldl (∪) {} (a # l) = ⋃ {x. x ∈ set (a # l)}›*) apply (subst foldl_un_empty_eq (*‹foldl (∪) ?i ?ww = ?i ∪ foldl (∪) {} ?ww›*)) (*goal: ‹⋀a l. foldl (∪) {} l = ⋃ (set l) ⟹ foldl (∪) a l = ⋃ {x. x = a ∨ x ∈ set l}›*) apply auto (*proven 2 subgoals*) . subsubsection ‹Miscellaneous› lemma length_compl_induct[case_names Nil Cons]: "⟦P []; !! e l . ⟦!! ll . length ll <= length l ⟹ P ll⟧ ⟹ P (e#l)⟧ ⟹ P l" apply (induct_tac l rule: length_induct) (*goal: ‹⟦(P::'a list ⇒ bool) []; ⋀(e::'a) l::'a list. (⋀ll::'a list. length ll ≤ length l ⟹ P ll) ⟹ P (e # l)⟧ ⟹ P (l::'a list)›*) apply (case_tac "xs") (*goals: 1. ‹⋀xs. ⟦P []; ⋀e l. (⋀ll. length ll ≤ length l ⟹ P ll) ⟹ P (e # l); ∀ys. length ys < length xs ⟶ P ys; xs = []⟧ ⟹ P xs› 2. ‹⋀xs a list. ⟦P []; ⋀e l. (⋀ll. length ll ≤ length l ⟹ P ll) ⟹ P (e # l); ∀ys. length ys < length xs ⟶ P ys; xs = a # list⟧ ⟹ P xs› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . text ‹Simultaneous induction over two lists, prepending an element to one of the lists in each step› lemma list_2pre_induct[case_names base left right]: assumes BASE: "P [] []" and LEFT: "!!e w1' w2. P w1' w2 ⟹ P (e#w1') w2" and RIGHT: "!!e w1 w2'. P w1 w2' ⟹ P w1 (e#w2')" shows "P w1 w2" proof (-) (*goal: ‹P w1 w2›*) { fix n have "!!w1 w2. ⟦length w1 + length w2 = n; P [] []; !!e w1' w2. P w1' w2 ⟹ P (e#w1') w2; !!e w1 w2'. P w1 w2' ⟹ P w1 (e#w2') ⟧ ⟹ P w1 w2 " apply (induct n) (*goals: 1. ‹⋀w1 w2. ⟦length w1 + length w2 = 0; P [] []; ⋀e w1' w2. P w1' w2 ⟹ P (e # w1') w2; ⋀e w1 w2'. P w1 w2' ⟹ P w1 (e # w2')⟧ ⟹ P w1 w2› 2. ‹⋀n w1 w2. ⟦⋀w1 w2. ⟦length w1 + length w2 = n; P [] []; ⋀e w1' w2. P w1' w2 ⟹ P (e # w1') w2; ⋀e w1 w2'. P w1 w2' ⟹ P w1 (e # w2')⟧ ⟹ P w1 w2; length w1 + length w2 = Suc n; P [] []; ⋀e w1' w2. P w1' w2 ⟹ P (e # w1') w2; ⋀e w1 w2'. P w1 w2' ⟹ P w1 (e # w2')⟧ ⟹ P w1 w2› discuss goal 1*) apply simp (*discuss goal 2*) apply (case_tac w1) (*goals: 1. ‹⋀n w1 w2. ⟦⋀w1 w2. ⟦length w1 + length w2 = n; P [] []; ⋀e w1' w2. P w1' w2 ⟹ P (e # w1') w2; ⋀e w1 w2'. P w1 w2' ⟹ P w1 (e # w2')⟧ ⟹ P w1 w2; length w1 + length w2 = Suc n; P [] []; ⋀e w1' w2. P w1' w2 ⟹ P (e # w1') w2; ⋀e w1 w2'. P w1 w2' ⟹ P w1 (e # w2'); w1 = []⟧ ⟹ P w1 w2› 2. ‹⋀n w1 w2 a list. ⟦⋀w1 w2. ⟦length w1 + length w2 = n; P [] []; ⋀e w1' w2. P w1' w2 ⟹ P (e # w1') w2; ⋀e w1 w2'. P w1 w2' ⟹ P w1 (e # w2')⟧ ⟹ P w1 w2; length w1 + length w2 = Suc n; P [] []; ⋀e w1' w2. P w1' w2 ⟹ P (e # w1') w2; ⋀e w1 w2'. P w1 w2' ⟹ P w1 (e # w2'); w1 = a # list⟧ ⟹ P w1 w2› discuss goal 1*) apply ((auto)[1]) (*top goal: ‹⋀n w1 w2. ⟦⋀w1 w2. ⟦length w1 + length w2 = n; P [] []; ⋀e w1' w2. P w1' w2 ⟹ P (e # w1') w2; ⋀e w1 w2'. P w1 w2' ⟹ P w1 (e # w2')⟧ ⟹ P w1 w2; length w1 + length w2 = Suc n; P [] []; ⋀e w1' w2. P w1' w2 ⟹ P (e # w1') w2; ⋀e w1 w2'. P w1 w2' ⟹ P w1 (e # w2'); w1 = []⟧ ⟹ P w1 w2› and 1 goal remains*) apply (case_tac w2) (*goals: 1. ‹⋀n w2. ⟦⋀w1 w2. length w1 + length w2 = n ⟹ P w1 w2; length w2 = Suc n; P [] []; ⋀e w1' w2. P w1' w2 ⟹ P (e # w1') w2; ⋀e w1 w2'. P w1 w2' ⟹ P w1 (e # w2'); w2 = []⟧ ⟹ P [] w2› 2. ‹⋀n w2 a list. ⟦⋀w1 w2. length w1 + length w2 = n ⟹ P w1 w2; length w2 = Suc n; P [] []; ⋀e w1' w2. P w1' w2 ⟹ P (e # w1') w2; ⋀e w1 w2'. P w1 w2' ⟹ P w1 (e # w2'); w2 = a # list⟧ ⟹ P [] w2› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) (*proven 2 subgoals*) . } from this[OF _ BASE LEFT RIGHT] (*‹⟦length ?w1.0 + length ?w2.0 = ?n3; ⋀e w1' w2. P w1' w2 ⟹ P w1' w2; ⋀e w1 w2'. P w1 w2' ⟹ P w1 w2'⟧ ⟹ P ?w1.0 ?w2.0›*) show "?thesis" (*goal: ‹P w1 w2›*) by blast qed lemma list_decomp_1: "length l=1 ⟹ EX a . l=[a]" apply (case_tac l) (*goals: 1. ‹⟦length l = 1; l = []⟧ ⟹ ∃a. l = [a]› 2. ‹⋀a list. ⟦length l = 1; l = a # list⟧ ⟹ ∃a. l = [a]› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . lemma list_decomp_2: "length l=2 ⟹ EX a b . l=[a,b]" apply (case_tac l) (*goals: 1. ‹⟦length l = 2; l = []⟧ ⟹ ∃a b. l = [a, b]› 2. ‹⋀a list. ⟦length l = 2; l = a # list⟧ ⟹ ∃a b. l = [a, b]› discuss goal 1*) apply ((auto simp add: list_decomp_1 (*‹length ?l = 1 ⟹ ∃a. ?l = [a]›*))[1]) (*discuss goal 2*) apply ((auto simp add: list_decomp_1 (*‹length (?l::?'a::type list) = (1::nat) ⟹ ∃a::?'a::type. ?l = [a]›*))[1]) (*proven 2 subgoals*) . lemma drop_all_conc: "drop (length a) (a@b) = b" by simp lemma list_rest_coinc: "⟦length s2 <= length s1; s1@r1 = s2@r2⟧ ⟹ EX r1p . r2=r1p@r1" proof (-) (*goal: ‹⟦length s2 ≤ length s1; s1 @ r1 = s2 @ r2⟧ ⟹ ∃r1p. r2 = r1p @ r1›*) assume A: "length s2 <= length s1" "s1@r1 = s2@r2" (*‹length (s2::'a list) ≤ length (s1::'a list)› ‹(s1::'a list) @ (r1::'a list) = (s2::'a list) @ (r2::'a list)›*) hence "r1 = drop (length s1) (s2@r2)" by (auto simp only:drop_all_conc (*‹drop (length (?a::?'a::type list)) (?a @ (?b::?'a::type list)) = ?b›*) dest: sym (*‹(?s::?'a::type) = (?t::?'a::type) ⟹ ?t = ?s›*)) moreover from A (*‹length (s2::'a list) ≤ length (s1::'a list)› ‹s1 @ r1 = s2 @ r2›*) have "length s1 = length s1 - length s2 + length s2" by arith ultimately have "r1 = drop ((length s1 - length s2)) r2" by auto hence "r2 = take ((length s1 - length s2)) r2 @ r1" by auto thus "?thesis" (*goal: ‹∃r1p. r2 = r1p @ r1›*) by auto qed lemma list_tail_coinc: "n1#r1 = n2#r2 ⟹ n1=n2 & r1=r2" by auto lemma last_in_set[intro]: "⟦l≠[]⟧ ⟹ last l ∈ set l" apply (induct l) (*goals: 1. ‹[] ≠ [] ⟹ last [] ∈ set []› 2. ‹⋀a l. ⟦l ≠ [] ⟹ last l ∈ set l; a # l ≠ []⟧ ⟹ last (a # l) ∈ set (a # l)› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . subsection ‹Induction on nat› lemma nat_compl_induct[case_names 0 Suc]: "⟦P 0; !! n . ALL nn . nn <= n ⟶ P nn ⟹ P (Suc n)⟧ ⟹ P n" apply (induct_tac n rule: nat_less_induct) (*goal: ‹⟦P 0; ⋀n. ∀nn≤n. P nn ⟹ P (Suc n)⟧ ⟹ P n›*) apply (case_tac n) (*goals: 1. ‹⋀n::nat. ⟦(P::nat ⇒ bool) (0::nat); ⋀n::nat. ∀nn≤n. P nn ⟹ P (Suc n); ∀m<n. P m; n = (0::nat)⟧ ⟹ P n› 2. ‹⋀(n::nat) nat::nat. ⟦(P::nat ⇒ bool) (0::nat); ⋀n::nat. ∀nn≤n. P nn ⟹ P (Suc n); ∀m<n. P m; n = Suc nat⟧ ⟹ P n› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . subsection ‹Functions of type @{typ "bool⇒bool"}› lemma boolfun_cases_helper: "g=(λx. False) | g=(λx. x) | g=(λx. True) | g= (λx. ¬x)" proof (-) (*goal: ‹g = (λx. False) ∨ g = (λx. x) ∨ g = (λx. True) ∨ g = Not›*) { assume "g False" "g True" (*‹(g::bool ⇒ bool) False› ‹(g::bool ⇒ bool) True›*) hence "g = (λx. True)" apply (rule_tac ext (*‹(⋀x. ?f x = ?g x) ⟹ ?f = ?g›*)) (*goal: ‹g = (λx. True)›*) apply (case_tac x) (*goals: 1. ‹⋀x. ⟦g False; g True; x⟧ ⟹ g x = True› 2. ‹⋀x. ⟦g False; g True; ¬ x⟧ ⟹ g x = True› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . } moreover { assume "g False" "¬g True" (*‹(g::bool ⇒ bool) False› ‹¬ (g::bool ⇒ bool) True›*) hence "g = (λx. ¬x)" apply (rule_tac ext (*‹(⋀x. ?f x = ?g x) ⟹ ?f = ?g›*)) (*goal: ‹g = Not›*) apply (case_tac x) (*goals: 1. ‹⋀x. ⟦g False; ¬ g True; x⟧ ⟹ g x = (¬ x)› 2. ‹⋀x. ⟦g False; ¬ g True; ¬ x⟧ ⟹ g x = (¬ x)› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . } moreover { assume "¬g False" "g True" (*‹¬ (g::bool ⇒ bool) False› ‹(g::bool ⇒ bool) True›*) hence "g = (λx. x)" apply (rule_tac ext (*‹(⋀x. ?f x = ?g x) ⟹ ?f = ?g›*)) (*goal: ‹g = (λx. x)›*) apply (case_tac x) (*goals: 1. ‹⋀x::bool. ⟦¬ (g::bool ⇒ bool) False; g True; x⟧ ⟹ g x = x› 2. ‹⋀x::bool. ⟦¬ (g::bool ⇒ bool) False; g True; ¬ x⟧ ⟹ g x = x› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . } moreover { assume "¬g False" "¬g True" (*‹¬ (g::bool ⇒ bool) False› ‹¬ (g::bool ⇒ bool) True›*) hence "g = (λx. False)" apply (rule_tac ext (*‹(⋀x. ?f x = ?g x) ⟹ ?f = ?g›*)) (*goal: ‹(g::bool ⇒ bool) = (λx::bool. False)›*) apply (case_tac x) (*goals: 1. ‹⋀x. ⟦¬ g False; ¬ g True; x⟧ ⟹ g x = False› 2. ‹⋀x. ⟦¬ g False; ¬ g True; ¬ x⟧ ⟹ g x = False› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . } ultimately show "?thesis" (*goal: ‹g = (λx. False) ∨ g = (λx. x) ∨ g = (λx. True) ∨ g = Not›*) by fast qed lemma boolfun_cases[case_names False Id True Neg]: "⟦g=(λx. False) ⟹ P g; g=(λx. x) ⟹ P g; g=(λx. True) ⟹ P g; g=(λx. ¬x) ⟹ P g⟧ ⟹ P g" proof (-) (*goal: ‹⟦g = (λx. False) ⟹ P g; g = (λx. x) ⟹ P g; g = (λx. True) ⟹ P g; g = Not ⟹ P g⟧ ⟹ P g›*) note boolfun_cases_helper[of g] (*‹g = (λx. False) ∨ g = (λx. x) ∨ g = (λx. True) ∨ g = Not›*) moreover assume "g=(λx. False) ⟹ P g" "g=(λx. x) ⟹ P g" "g=(λx. True) ⟹ P g" "g=(λx. ¬x) ⟹ P g" (*‹(g::bool ⇒ bool) = (λx::bool. False) ⟹ (P::(bool ⇒ bool) ⇒ bool) g› ‹(g::bool ⇒ bool) = (λx::bool. x) ⟹ (P::(bool ⇒ bool) ⇒ bool) g› ‹(g::bool ⇒ bool) = (λx::bool. True) ⟹ (P::(bool ⇒ bool) ⇒ bool) g› ‹(g::bool ⇒ bool) = Not ⟹ (P::(bool ⇒ bool) ⇒ bool) g›*) ultimately show "?thesis" (*goal: ‹P g›*) by fast qed subsection ‹Definite and indefinite description› text "Combined definite and indefinite description for binary predicate" lemma some_theI: assumes EX: "∃a b . P a b" and BUN: "!! b1 b2 . ⟦∃a . P a b1; ∃a . P a b2⟧ ⟹ b1=b2" shows "P (SOME a . ∃b . P a b) (THE b . ∃a . P a b)" proof (-) (*goal: ‹P (SOME a. ∃b. P a b) (THE b. ∃a. P a b)›*) from EX (*‹∃a b. P a b›*) have "EX b . P (SOME a . EX b . P a b) b" by (rule someI_ex (*‹∃x. ?P x ⟹ ?P (SOME x. ?P x)›*)) moreover from EX (*‹∃(a::'a) b::'b. (P::'a ⇒ 'b ⇒ bool) a b›*) have "EX b . EX a . P a b" by blast with BUN (*‹⟦∃a. P a ?b1.0; ∃a. P a ?b2.0⟧ ⟹ ?b1.0 = ?b2.0›*) theI'[of "λb . EX a . P a b"] (*‹∃!x::'b::type. ∃a::'a::type. (P::'a::type ⇒ 'b::type ⇒ bool) a x ⟹ ∃a::'a::type. P a (THE x::'b::type. ∃a::'a::type. P a x)›*) have "EX a . P a (THE b . EX a . P a b)" apply (unfold Ex1_def (*‹Ex1 ?P ≡ ∃x. ?P x ∧ (∀y. ?P y ⟶ y = x)›*)) (*goal: ‹∃a. P a (THE b. ∃a. P a b)›*) by blast moreover note BUN (*‹⟦∃a. P a ?b1.0; ∃a. P a ?b2.0⟧ ⟹ ?b1.0 = ?b2.0›*) ultimately show "?thesis" (*goal: ‹P (SOME a. ∃b. P a b) (THE b. ∃a. P a b)›*) by fast qed end
{ "path": "afp-2025-02-12/thys/Program-Conflict-Analysis/Misc.thy", "repo": "afp-2025-02-12", "sha": "f0b526b9fb71dd8d8b2947a983130932a34aa282e07d93a8279a0ea50e403edf" }
theory Ground_Term_Extra imports "Regular_Tree_Relations.Ground_Terms" begin lemma gterm_is_fun: "is_Fun (term_of_gterm t)" apply (cases t) (*goal: ‹is_Fun (term_of_gterm t)›*) by simp end
{ "path": "afp-2025-02-12/thys/Superposition_Calculus/Ground_Term_Extra.thy", "repo": "afp-2025-02-12", "sha": "14245b375b6cc78630d31d93184d74d6ebd94e0aa2c4a65a9924da6bbfe51c3b" }
(* Title: HOL/MicroJava/BV/JVM.thy Author: Tobias Nipkow, Gerwin Klein Copyright 2000 TUM *) section ‹The Typing Framework for the JVM \label{sec:JVM}› theory TF_JVM imports "../DFA/Typing_Framework_err" EffectMono BVSpec begin definition exec :: "jvm_prog ⇒ nat ⇒ ty ⇒ ex_table ⇒ instr list ⇒ ty⇩i' err step_type" where "exec G maxs rT et bs ≡ err_step (size bs) (λpc. app (bs!pc) G maxs rT pc (size bs) et) (λpc. eff (bs!pc) G pc et)" locale JVM_sl = fixes P :: jvm_prog and mxs and mxl₀ and n fixes Ts :: "ty list" and "is" and xt and T⇩r fixes mxl and A and r and f and app and eff and step defines [simp]: "mxl ≡ 1+size Ts+mxl₀" defines [simp]: "A ≡ states P mxs mxl" defines [simp]: "r ≡ JVM_SemiType.le P mxs mxl" defines [simp]: "f ≡ JVM_SemiType.sup P mxs mxl" defines [simp]: "app ≡ λpc. Effect.app (is!pc) P mxs T⇩r pc (size is) xt" defines [simp]: "eff ≡ λpc. Effect.eff (is!pc) P pc xt" defines [simp]: "step ≡ err_step (size is) app eff" defines [simp]: "n ≡ size is" locale start_context = JVM_sl + fixes p and C assumes wf: "wf_prog p P" assumes C: "is_class P C" assumes Ts: "set Ts ⊆ types P" fixes first :: ty⇩i' and start defines [simp]: "first ≡ Some ([],OK (Class C) # map OK Ts @ replicate mxl₀ Err)" defines [simp]: "start ≡ OK first # replicate (size is - 1) (OK None)" subsection ‹Connecting JVM and Framework› lemma (in start_context) semi: "semilat (A, r, f)" apply (insert semilat_JVM[OF wf] (*‹semilat (JVM_SemiType.sl P ?mxs ?mxl)›*)) (*goal: ‹semilat (A, r, f)›*) apply (unfold A_def (*‹A ≡ states P mxs mxl›*) r_def (*‹r ≡ JVM_SemiType.le P mxs mxl›*) f_def (*‹f ≡ JVM_SemiType.sup P mxs mxl›*) JVM_SemiType.le_def (*‹JVM_SemiType.le ?P ?mxs ?mxl ≡ fst (snd (JVM_SemiType.sl ?P ?mxs ?mxl))›*) JVM_SemiType.sup_def (*‹JVM_SemiType.sup ?P ?mxs ?mxl ≡ snd (snd (JVM_SemiType.sl ?P ?mxs ?mxl))›*) states_def (*‹states ?P ?mxs ?mxl ≡ fst (JVM_SemiType.sl ?P ?mxs ?mxl)›*)) (*goal: ‹(⋀(mxs::nat) mxl::nat. semilat (JVM_SemiType.sl (P::(char list × char list × (char list × ty) list × (char list × ty list × ty × nat × nat × instr list × (nat × nat × char list × nat × nat) list) list) list) mxs mxl)) ⟹ semilat (A::(ty list × ty err list) option err set, r::(ty list × ty err list) option err ⇒ (ty list × ty err list) option err ⇒ bool, f::(ty list × ty err list) option err ⇒ (ty list × ty err list) option err ⇒ (ty list × ty err list) option err)›*) by auto lemma (in JVM_sl) step_def_exec: "step ≡ exec P mxs T⇩r xt is" by (simp add: exec_def (*‹exec ?G ?maxs ?rT ?et ?bs ≡ err_step (length ?bs) (λpc. app (?bs ! pc) ?G ?maxs ?rT pc (length ?bs) ?et) (λpc. eff (?bs ! pc) ?G pc ?et)›*)) lemma special_ex_swap_lemma [iff]: "(? X. (? n. X = A n & P n) & Q X) = (? n. Q(A n) & P n)" by blast lemma ex_in_nlists [iff]: "(∃n. ST ∈ nlists n A ∧ n ≤ mxs) = (set ST ⊆ A ∧ size ST ≤ mxs)" apply (unfold nlists_def (*‹nlists (?n::nat) (?A::?'a::type set) = {xs::?'a::type list. length xs = ?n ∧ set xs ⊆ ?A}›*)) (*goal: ‹(∃n. ST ∈ nlists n A ∧ n ≤ mxs) = (set ST ⊆ A ∧ length ST ≤ mxs)›*) by auto lemma singleton_nlists: "(∃n. [Class C] ∈ nlists n (types P) ∧ n ≤ mxs) = (is_class P C ∧ 0 < mxs)" by auto lemma set_drop_subset: "set xs ⊆ A ⟹ set (drop n xs) ⊆ A" by (auto dest: in_set_dropD (*‹?x ∈ set (drop ?n ?xs) ⟹ ?x ∈ set ?xs›*)) lemma Suc_minus_minus_le: "n < mxs ⟹ Suc (n - (n - b)) ≤ mxs" by arith lemma in_nlistsE: "⟦ xs ∈ nlists n A; ⟦size xs = n; set xs ⊆ A⟧ ⟹ P ⟧ ⟹ P" apply (unfold nlists_def (*‹nlists ?n ?A = {xs. length xs = ?n ∧ set xs ⊆ ?A}›*)) (*goal: ‹⟦xs ∈ nlists n A; ⟦length xs = n; set xs ⊆ A⟧ ⟹ P⟧ ⟹ P›*) by blast declare is_relevant_entry_def [simp] declare set_drop_subset [simp] theorem (in start_context) exec_pres_type: "pres_type step (size is) A" (*<*) apply (insert wf (*‹wf_prog p P›*)) (*goal: ‹pres_type step (length is) A›*) apply simp (*goal: ‹wf_prog (p::(char list × char list × (char list × ty) list × (char list × ty list × ty × nat × nat × instr list × (nat × nat × char list × nat × nat) list) list) list ⇒ char list ⇒ char list × ty list × ty × nat × nat × instr list × (nat × nat × char list × nat × nat) list ⇒ bool) (P::(char list × char list × (char list × ty) list × (char list × ty list × ty × nat × nat × instr list × (nat × nat × char list × nat × nat) list) list) list) ⟹ pres_type (step::nat ⇒ (ty list × ty err list) option err ⇒ (nat × (ty list × ty err list) option err) list) (length (is::instr list)) (A::(ty list × ty err list) option err set)›*) apply (unfold JVM_states_unfold (*‹states ?P ?mxs ?mxl ≡ err (opt (⋃ {nlists n (types ?P) |n. n ≤ ?mxs} × nlists ?mxl (err (types ?P))))›*)) (*goal: ‹wf_prog p P ⟹ pres_type (err_step (length is) (λpc. app (is ! pc) P mxs T⇩r pc (length is) xt) (λpc. eff (is ! pc) P pc xt)) (length is) (states P mxs (Suc (length Ts + mxl₀)))›*) apply (rule pres_type_lift (*‹∀s∈?A. ∀p<?n. ?app p s ⟶ (∀(q, s')∈set (?step p s). s' ∈ ?A) ⟹ pres_type (err_step ?n ?app ?step) ?n (err ?A)›*)) (*goal: ‹wf_prog p P ⟹ pres_type (err_step (length is) (λpc. app (is ! pc) P mxs T⇩r pc (length is) xt) (λpc. eff (is ! pc) P pc xt)) (length is) (err (opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists (Suc (length Ts + mxl₀)) (err (types P)))))›*) apply clarify (*goal: ‹wf_prog p P ⟹ ∀s∈opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists (Suc (length Ts + mxl₀)) (err (types P))). ∀p<length is. app (is ! p) P mxs T⇩r p (length is) xt s ⟶ (∀(q, s')∈set (eff (is ! p) P p xt s). s' ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists (Suc (length Ts + mxl₀)) (err (types P))))›*) apply (rename_tac s pc pc' s') (*goal: ‹⋀s pa a b. ⟦wf_prog p P; s ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists (Suc (length Ts + mxl₀)) (err (types P))); pa < length is; app (is ! pa) P mxs T⇩r pa (length is) xt s; (a, b) ∈ set (eff (is ! pa) P pa xt s)⟧ ⟹ b ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists (Suc (length Ts + mxl₀)) (err (types P)))›*) apply (case_tac s) (*goals: 1. ‹⋀s pc pc' s'. ⟦wf_prog p P; s ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists (Suc (length Ts + mxl₀)) (err (types P))); pc < length is; app (is ! pc) P mxs T⇩r pc (length is) xt s; (pc', s') ∈ set (eff (is ! pc) P pc xt s); s = None⟧ ⟹ s' ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists (Suc (length Ts + mxl₀)) (err (types P)))› 2. ‹⋀s pc pc' s' a. ⟦wf_prog p P; s ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists (Suc (length Ts + mxl₀)) (err (types P))); pc < length is; app (is ! pc) P mxs T⇩r pc (length is) xt s; (pc', s') ∈ set (eff (is ! pc) P pc xt s); s = ⌊a⌋⟧ ⟹ s' ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists (Suc (length Ts + mxl₀)) (err (types P)))› discuss goal 1*) apply simp (*top goal: ‹⋀s pc pc' s'. ⟦wf_prog p P; s ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists (Suc (length Ts + mxl₀)) (err (types P))); pc < length is; app (is ! pc) P mxs T⇩r pc (length is) xt s; (pc', s') ∈ set (eff (is ! pc) P pc xt s); s = None⟧ ⟹ s' ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists (Suc (length Ts + mxl₀)) (err (types P)))› and 1 goal remains*) apply (drule effNone (*‹(?pc', ?s') ∈ set (eff ?i ?P ?pc ?et None) ⟹ ?s' = None›*)) (*top goal: ‹⋀s pc pc' s'. ⟦wf_prog p P; pc < length is; (pc', s') ∈ set (eff (is ! pc) P pc xt None); s = None⟧ ⟹ s' ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists (Suc (length Ts + mxl₀)) (err (types P)))› and 1 goal remains*) apply simp (*discuss goal 2*) apply (simp add: Effect.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)›*) Effect.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)›*) relevant_entries_def (*‹relevant_entries ?P ?i ?pc = filter (is_relevant_entry ?P ?i ?pc)›*)) (*goal: ‹⋀s pc pc' s' a. ⟦wf_prog p P; s ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists (Suc (length Ts + mxl₀)) (err (types P))); pc < length is; app (is ! pc) P mxs T⇩r pc (length is) xt s; (pc', s') ∈ set (eff (is ! pc) P pc xt s); s = ⌊a⌋⟧ ⟹ s' ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists (Suc (length Ts + mxl₀)) (err (types P)))›*) apply (case_tac "is!pc") (*goals: 1. ‹⋀s pc pc' s' a x1. ⟦wf_prog p P; a ∈ ⋃ {nlists n (types P) |n. n ≤ mxs} × nlists (Suc (length Ts + mxl₀)) (err (types P)); pc < length is; app⇩i (is ! pc, P, pc, mxs, T⇩r, a) ∧ (∀aa ab ac ad b. (aa, ab, ac, ad, b) ∈ set xt ∧ is_relevant_class (is ! pc) P ac ∧ aa ≤ pc ∧ pc < ab ⟶ is_class P ac ∧ b ≤ length (fst a) ∧ b < mxs) ∧ (∀x∈(λpc'. (pc', ⌊eff⇩i (is ! pc, P, a)⌋)) ` set (succs (is ! pc) a pc) ∪ {x. ∃uu_ uua_. (uua_, uu_) = a ∧ x ∈ (λx. case x of (f, t, C, h, d) ⇒ (h, ⌊(Class C # drop (length uua_ - d) uua_, uu_)⌋)) ` {x ∈ set xt. case x of (f, t, C, ab) ⇒ is_relevant_class (is ! pc) P C ∧ f ≤ pc ∧ pc < t}}. case x of (pc', τ') ⇒ pc' < length is); (pc', s') ∈ (λpc'. (pc', ⌊eff⇩i (is ! pc, P, a)⌋)) ` set (succs (is ! pc) a pc) ∨ (∃uu_ uua_. (uua_, uu_) = a ∧ (pc', s') ∈ (λx. case x of (f, t, C, h, d) ⇒ (h, ⌊(Class C # drop (length uua_ - d) uua_, uu_)⌋)) ` {x ∈ set xt. case x of (f, t, C, ab) ⇒ is_relevant_class (is ! pc) P C ∧ f ≤ pc ∧ pc < t}); s = ⌊a⌋; is ! pc = Load x1⟧ ⟹ s' ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists (Suc (length Ts + mxl₀)) (err (types P)))› 2. ‹⋀s pc pc' s' a x2. ⟦wf_prog p P; a ∈ ⋃ {nlists n (types P) |n. n ≤ mxs} × nlists (Suc (length Ts + mxl₀)) (err (types P)); pc < length is; app⇩i (is ! pc, P, pc, mxs, T⇩r, a) ∧ (∀aa ab ac ad b. (aa, ab, ac, ad, b) ∈ set xt ∧ is_relevant_class (is ! pc) P ac ∧ aa ≤ pc ∧ pc < ab ⟶ is_class P ac ∧ b ≤ length (fst a) ∧ b < mxs) ∧ (∀x∈(λpc'. (pc', ⌊eff⇩i (is ! pc, P, a)⌋)) ` set (succs (is ! pc) a pc) ∪ {x. ∃uu_ uua_. (uua_, uu_) = a ∧ x ∈ (λx. case x of (f, t, C, h, d) ⇒ (h, ⌊(Class C # drop (length uua_ - d) uua_, uu_)⌋)) ` {x ∈ set xt. case x of (f, t, C, ab) ⇒ is_relevant_class (is ! pc) P C ∧ f ≤ pc ∧ pc < t}}. case x of (pc', τ') ⇒ pc' < length is); (pc', s') ∈ (λpc'. (pc', ⌊eff⇩i (is ! pc, P, a)⌋)) ` set (succs (is ! pc) a pc) ∨ (∃uu_ uua_. (uua_, uu_) = a ∧ (pc', s') ∈ (λx. case x of (f, t, C, h, d) ⇒ (h, ⌊(Class C # drop (length uua_ - d) uua_, uu_)⌋)) ` {x ∈ set xt. case x of (f, t, C, ab) ⇒ is_relevant_class (is ! pc) P C ∧ f ≤ pc ∧ pc < t}); s = ⌊a⌋; is ! pc = Store x2⟧ ⟹ s' ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists (Suc (length Ts + mxl₀)) (err (types P)))› 3. ‹⋀s pc pc' s' a x3. ⟦wf_prog p P; a ∈ ⋃ {nlists n (types P) |n. n ≤ mxs} × nlists (Suc (length Ts + mxl₀)) (err (types P)); pc < length is; app⇩i (is ! pc, P, pc, mxs, T⇩r, a) ∧ (∀aa ab ac ad b. (aa, ab, ac, ad, b) ∈ set xt ∧ is_relevant_class (is ! pc) P ac ∧ aa ≤ pc ∧ pc < ab ⟶ is_class P ac ∧ b ≤ length (fst a) ∧ b < mxs) ∧ (∀x∈(λpc'. (pc', ⌊eff⇩i (is ! pc, P, a)⌋)) ` set (succs (is ! pc) a pc) ∪ {x. ∃uu_ uua_. (uua_, uu_) = a ∧ x ∈ (λx. case x of (f, t, C, h, d) ⇒ (h, ⌊(Class C # drop (length uua_ - d) uua_, uu_)⌋)) ` {x ∈ set xt. case x of (f, t, C, ab) ⇒ is_relevant_class (is ! pc) P C ∧ f ≤ pc ∧ pc < t}}. case x of (pc', τ') ⇒ pc' < length is); (pc', s') ∈ (λpc'. (pc', ⌊eff⇩i (is ! pc, P, a)⌋)) ` set (succs (is ! pc) a pc) ∨ (∃uu_ uua_. (uua_, uu_) = a ∧ (pc', s') ∈ (λx. case x of (f, t, C, h, d) ⇒ (h, ⌊(Class C # drop (length uua_ - d) uua_, uu_)⌋)) ` {x ∈ set xt. case x of (f, t, C, ab) ⇒ is_relevant_class (is ! pc) P C ∧ f ≤ pc ∧ pc < t}); s = ⌊a⌋; is ! pc = Push x3⟧ ⟹ s' ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists (Suc (length Ts + mxl₀)) (err (types P)))› 4. ‹⋀s pc pc' s' a x4. ⟦wf_prog p P; a ∈ ⋃ {nlists n (types P) |n. n ≤ mxs} × nlists (Suc (length Ts + mxl₀)) (err (types P)); pc < length is; app⇩i (is ! pc, P, pc, mxs, T⇩r, a) ∧ (∀aa ab ac ad b. (aa, ab, ac, ad, b) ∈ set xt ∧ is_relevant_class (is ! pc) P ac ∧ aa ≤ pc ∧ pc < ab ⟶ is_class P ac ∧ b ≤ length (fst a) ∧ b < mxs) ∧ (∀x∈(λpc'. (pc', ⌊eff⇩i (is ! pc, P, a)⌋)) ` set (succs (is ! pc) a pc) ∪ {x. ∃uu_ uua_. (uua_, uu_) = a ∧ x ∈ (λx. case x of (f, t, C, h, d) ⇒ (h, ⌊(Class C # drop (length uua_ - d) uua_, uu_)⌋)) ` {x ∈ set xt. case x of (f, t, C, ab) ⇒ is_relevant_class (is ! pc) P C ∧ f ≤ pc ∧ pc < t}}. case x of (pc', τ') ⇒ pc' < length is); (pc', s') ∈ (λpc'. (pc', ⌊eff⇩i (is ! pc, P, a)⌋)) ` set (succs (is ! pc) a pc) ∨ (∃uu_ uua_. (uua_, uu_) = a ∧ (pc', s') ∈ (λx. case x of (f, t, C, h, d) ⇒ (h, ⌊(Class C # drop (length uua_ - d) uua_, uu_)⌋)) ` {x ∈ set xt. case x of (f, t, C, ab) ⇒ is_relevant_class (is ! pc) P C ∧ f ≤ pc ∧ pc < t}); s = ⌊a⌋; is ! pc = New x4⟧ ⟹ s' ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists (Suc (length Ts + mxl₀)) (err (types P)))› 5. ‹⋀s pc pc' s' a x51 x52. ⟦wf_prog p P; a ∈ ⋃ {nlists n (types P) |n. n ≤ mxs} × nlists (Suc (length Ts + mxl₀)) (err (types P)); pc < length is; app⇩i (is ! pc, P, pc, mxs, T⇩r, a) ∧ (∀aa ab ac ad b. (aa, ab, ac, ad, b) ∈ set xt ∧ is_relevant_class (is ! pc) P ac ∧ aa ≤ pc ∧ pc < ab ⟶ is_class P ac ∧ b ≤ length (fst a) ∧ b < mxs) ∧ (∀x∈(λpc'. (pc', ⌊eff⇩i (is ! pc, P, a)⌋)) ` set (succs (is ! pc) a pc) ∪ {x. ∃uu_ uua_. (uua_, uu_) = a ∧ x ∈ (λx. case x of (f, t, C, h, d) ⇒ (h, ⌊(Class C # drop (length uua_ - d) uua_, uu_)⌋)) ` {x ∈ set xt. case x of (f, t, C, ab) ⇒ is_relevant_class (is ! pc) P C ∧ f ≤ pc ∧ pc < t}}. case x of (pc', τ') ⇒ pc' < length is); (pc', s') ∈ (λpc'. (pc', ⌊eff⇩i (is ! pc, P, a)⌋)) ` set (succs (is ! pc) a pc) ∨ (∃uu_ uua_. (uua_, uu_) = a ∧ (pc', s') ∈ (λx. case x of (f, t, C, h, d) ⇒ (h, ⌊(Class C # drop (length uua_ - d) uua_, uu_)⌋)) ` {x ∈ set xt. case x of (f, t, C, ab) ⇒ is_relevant_class (is ! pc) P C ∧ f ≤ pc ∧ pc < t}); s = ⌊a⌋; is ! pc = Getfield x51 x52⟧ ⟹ s' ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists (Suc (length Ts + mxl₀)) (err (types P)))› 6. ‹⋀s pc pc' s' a x61 x62. ⟦wf_prog p P; a ∈ ⋃ {nlists n (types P) |n. n ≤ mxs} × nlists (Suc (length Ts + mxl₀)) (err (types P)); pc < length is; app⇩i (is ! pc, P, pc, mxs, T⇩r, a) ∧ (∀aa ab ac ad b. (aa, ab, ac, ad, b) ∈ set xt ∧ is_relevant_class (is ! pc) P ac ∧ aa ≤ pc ∧ pc < ab ⟶ is_class P ac ∧ b ≤ length (fst a) ∧ b < mxs) ∧ (∀x∈(λpc'. (pc', ⌊eff⇩i (is ! pc, P, a)⌋)) ` set (succs (is ! pc) a pc) ∪ {x. ∃uu_ uua_. (uua_, uu_) = a ∧ x ∈ (λx. case x of (f, t, C, h, d) ⇒ (h, ⌊(Class C # drop (length uua_ - d) uua_, uu_)⌋)) ` {x ∈ set xt. case x of (f, t, C, ab) ⇒ is_relevant_class (is ! pc) P C ∧ f ≤ pc ∧ pc < t}}. case x of (pc', τ') ⇒ pc' < length is); (pc', s') ∈ (λpc'. (pc', ⌊eff⇩i (is ! pc, P, a)⌋)) ` set (succs (is ! pc) a pc) ∨ (∃uu_ uua_. (uua_, uu_) = a ∧ (pc', s') ∈ (λx. case x of (f, t, C, h, d) ⇒ (h, ⌊(Class C # drop (length uua_ - d) uua_, uu_)⌋)) ` {x ∈ set xt. case x of (f, t, C, ab) ⇒ is_relevant_class (is ! pc) P C ∧ f ≤ pc ∧ pc < t}); s = ⌊a⌋; is ! pc = Putfield x61 x62⟧ ⟹ s' ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists (Suc (length Ts + mxl₀)) (err (types P)))› 7. ‹⋀s pc pc' s' a x7. ⟦wf_prog p P; a ∈ ⋃ {nlists n (types P) |n. n ≤ mxs} × nlists (Suc (length Ts + mxl₀)) (err (types P)); pc < length is; app⇩i (is ! pc, P, pc, mxs, T⇩r, a) ∧ (∀aa ab ac ad b. (aa, ab, ac, ad, b) ∈ set xt ∧ is_relevant_class (is ! pc) P ac ∧ aa ≤ pc ∧ pc < ab ⟶ is_class P ac ∧ b ≤ length (fst a) ∧ b < mxs) ∧ (∀x∈(λpc'. (pc', ⌊eff⇩i (is ! pc, P, a)⌋)) ` set (succs (is ! pc) a pc) ∪ {x. ∃uu_ uua_. (uua_, uu_) = a ∧ x ∈ (λx. case x of (f, t, C, h, d) ⇒ (h, ⌊(Class C # drop (length uua_ - d) uua_, uu_)⌋)) ` {x ∈ set xt. case x of (f, t, C, ab) ⇒ is_relevant_class (is ! pc) P C ∧ f ≤ pc ∧ pc < t}}. case x of (pc', τ') ⇒ pc' < length is); (pc', s') ∈ (λpc'. (pc', ⌊eff⇩i (is ! pc, P, a)⌋)) ` set (succs (is ! pc) a pc) ∨ (∃uu_ uua_. (uua_, uu_) = a ∧ (pc', s') ∈ (λx. case x of (f, t, C, h, d) ⇒ (h, ⌊(Class C # drop (length uua_ - d) uua_, uu_)⌋)) ` {x ∈ set xt. case x of (f, t, C, ab) ⇒ is_relevant_class (is ! pc) P C ∧ f ≤ pc ∧ pc < t}); s = ⌊a⌋; is ! pc = Checkcast x7⟧ ⟹ s' ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists (Suc (length Ts + mxl₀)) (err (types P)))› 8. ‹⋀s pc pc' s' a x81 x82. ⟦wf_prog p P; a ∈ ⋃ {nlists n (types P) |n. n ≤ mxs} × nlists (Suc (length Ts + mxl₀)) (err (types P)); pc < length is; app⇩i (is ! pc, P, pc, mxs, T⇩r, a) ∧ (∀aa ab ac ad b. (aa, ab, ac, ad, b) ∈ set xt ∧ is_relevant_class (is ! pc) P ac ∧ aa ≤ pc ∧ pc < ab ⟶ is_class P ac ∧ b ≤ length (fst a) ∧ b < mxs) ∧ (∀x∈(λpc'. (pc', ⌊eff⇩i (is ! pc, P, a)⌋)) ` set (succs (is ! pc) a pc) ∪ {x. ∃uu_ uua_. (uua_, uu_) = a ∧ x ∈ (λx. case x of (f, t, C, h, d) ⇒ (h, ⌊(Class C # drop (length uua_ - d) uua_, uu_)⌋)) ` {x ∈ set xt. case x of (f, t, C, ab) ⇒ is_relevant_class (is ! pc) P C ∧ f ≤ pc ∧ pc < t}}. case x of (pc', τ') ⇒ pc' < length is); (pc', s') ∈ (λpc'. (pc', ⌊eff⇩i (is ! pc, P, a)⌋)) ` set (succs (is ! pc) a pc) ∨ (∃uu_ uua_. (uua_, uu_) = a ∧ (pc', s') ∈ (λx. case x of (f, t, C, h, d) ⇒ (h, ⌊(Class C # drop (length uua_ - d) uua_, uu_)⌋)) ` {x ∈ set xt. case x of (f, t, C, ab) ⇒ is_relevant_class (is ! pc) P C ∧ f ≤ pc ∧ pc < t}); s = ⌊a⌋; is ! pc = Invoke x81 x82⟧ ⟹ s' ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists (Suc (length Ts + mxl₀)) (err (types P)))› 9. ‹⋀s pc pc' s' a. ⟦wf_prog p P; a ∈ ⋃ {nlists n (types P) |n. n ≤ mxs} × nlists (Suc (length Ts + mxl₀)) (err (types P)); pc < length is; app⇩i (is ! pc, P, pc, mxs, T⇩r, a) ∧ (∀aa ab ac ad b. (aa, ab, ac, ad, b) ∈ set xt ∧ is_relevant_class (is ! pc) P ac ∧ aa ≤ pc ∧ pc < ab ⟶ is_class P ac ∧ b ≤ length (fst a) ∧ b < mxs) ∧ (∀x∈(λpc'. (pc', ⌊eff⇩i (is ! pc, P, a)⌋)) ` set (succs (is ! pc) a pc) ∪ {x. ∃uu_ uua_. (uua_, uu_) = a ∧ x ∈ (λx. case x of (f, t, C, h, d) ⇒ (h, ⌊(Class C # drop (length uua_ - d) uua_, uu_)⌋)) ` {x ∈ set xt. case x of (f, t, C, ab) ⇒ is_relevant_class (is ! pc) P C ∧ f ≤ pc ∧ pc < t}}. case x of (pc', τ') ⇒ pc' < length is); (pc', s') ∈ (λpc'. (pc', ⌊eff⇩i (is ! pc, P, a)⌋)) ` set (succs (is ! pc) a pc) ∨ (∃uu_ uua_. (uua_, uu_) = a ∧ (pc', s') ∈ (λx. case x of (f, t, C, h, d) ⇒ (h, ⌊(Class C # drop (length uua_ - d) uua_, uu_)⌋)) ` {x ∈ set xt. case x of (f, t, C, ab) ⇒ is_relevant_class (is ! pc) P C ∧ f ≤ pc ∧ pc < t}); s = ⌊a⌋; is ! pc = Return⟧ ⟹ s' ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists (Suc (length Ts + mxl₀)) (err (types P)))› 10. ‹⋀s pc pc' s' a. ⟦wf_prog p P; a ∈ ⋃ {nlists n (types P) |n. n ≤ mxs} × nlists (Suc (length Ts + mxl₀)) (err (types P)); pc < length is; app⇩i (is ! pc, P, pc, mxs, T⇩r, a) ∧ (∀aa ab ac ad b. (aa, ab, ac, ad, b) ∈ set xt ∧ is_relevant_class (is ! pc) P ac ∧ aa ≤ pc ∧ pc < ab ⟶ is_class P ac ∧ b ≤ length (fst a) ∧ b < mxs) ∧ (∀x∈(λpc'. (pc', ⌊eff⇩i (is ! pc, P, a)⌋)) ` set (succs (is ! pc) a pc) ∪ {x. ∃uu_ uua_. (uua_, uu_) = a ∧ x ∈ (λx. case x of (f, t, C, h, d) ⇒ (h, ⌊(Class C # drop (length uua_ - d) uua_, uu_)⌋)) ` {x ∈ set xt. case x of (f, t, C, ab) ⇒ is_relevant_class (is ! pc) P C ∧ f ≤ pc ∧ pc < t}}. case x of (pc', τ') ⇒ pc' < length is); (pc', s') ∈ (λpc'. (pc', ⌊eff⇩i (is ! pc, P, a)⌋)) ` set (succs (is ! pc) a pc) ∨ (∃uu_ uua_. (uua_, uu_) = a ∧ (pc', s') ∈ (λx. case x of (f, t, C, h, d) ⇒ (h, ⌊(Class C # drop (length uua_ - d) uua_, uu_)⌋)) ` {x ∈ set xt. case x of (f, t, C, ab) ⇒ is_relevant_class (is ! pc) P C ∧ f ≤ pc ∧ pc < t}); s = ⌊a⌋; is ! pc = Pop⟧ ⟹ s' ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists (Suc (length Ts + mxl₀)) (err (types P)))› 11. ‹⋀s pc pc' s' a. ⟦wf_prog p P; a ∈ ⋃ {nlists n (types P) |n. n ≤ mxs} × nlists (Suc (length Ts + mxl₀)) (err (types P)); pc < length is; app⇩i (is ! pc, P, pc, mxs, T⇩r, a) ∧ (∀aa ab ac ad b. (aa, ab, ac, ad, b) ∈ set xt ∧ is_relevant_class (is ! pc) P ac ∧ aa ≤ pc ∧ pc < ab ⟶ is_class P ac ∧ b ≤ length (fst a) ∧ b < mxs) ∧ (∀x∈(λpc'. (pc', ⌊eff⇩i (is ! pc, P, a)⌋)) ` set (succs (is ! pc) a pc) ∪ {x. ∃uu_ uua_. (uua_, uu_) = a ∧ x ∈ (λx. case x of (f, t, C, h, d) ⇒ (h, ⌊(Class C # drop (length uua_ - d) uua_, uu_)⌋)) ` {x ∈ set xt. case x of (f, t, C, ab) ⇒ is_relevant_class (is ! pc) P C ∧ f ≤ pc ∧ pc < t}}. case x of (pc', τ') ⇒ pc' < length is); (pc', s') ∈ (λpc'. (pc', ⌊eff⇩i (is ! pc, P, a)⌋)) ` set (succs (is ! pc) a pc) ∨ (∃uu_ uua_. (uua_, uu_) = a ∧ (pc', s') ∈ (λx. case x of (f, t, C, h, d) ⇒ (h, ⌊(Class C # drop (length uua_ - d) uua_, uu_)⌋)) ` {x ∈ set xt. case x of (f, t, C, ab) ⇒ is_relevant_class (is ! pc) P C ∧ f ≤ pc ∧ pc < t}); s = ⌊a⌋; is ! pc = IAdd⟧ ⟹ s' ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists (Suc (length Ts + mxl₀)) (err (types P)))› 12. ‹⋀s pc pc' s' a x12. ⟦wf_prog p P; a ∈ ⋃ {nlists n (types P) |n. n ≤ mxs} × nlists (Suc (length Ts + mxl₀)) (err (types P)); pc < length is; app⇩i (is ! pc, P, pc, mxs, T⇩r, a) ∧ (∀aa ab ac ad b. (aa, ab, ac, ad, b) ∈ set xt ∧ is_relevant_class (is ! pc) P ac ∧ aa ≤ pc ∧ pc < ab ⟶ is_class P ac ∧ b ≤ length (fst a) ∧ b < mxs) ∧ (∀x∈(λpc'. (pc', ⌊eff⇩i (is ! pc, P, a)⌋)) ` set (succs (is ! pc) a pc) ∪ {x. ∃uu_ uua_. (uua_, uu_) = a ∧ x ∈ (λx. case x of (f, t, C, h, d) ⇒ (h, ⌊(Class C # drop (length uua_ - d) uua_, uu_)⌋)) ` {x ∈ set xt. case x of (f, t, C, ab) ⇒ is_relevant_class (is ! pc) P C ∧ f ≤ pc ∧ pc < t}}. case x of (pc', τ') ⇒ pc' < length is); (pc', s') ∈ (λpc'. (pc', ⌊eff⇩i (is ! pc, P, a)⌋)) ` set (succs (is ! pc) a pc) ∨ (∃uu_ uua_. (uua_, uu_) = a ∧ (pc', s') ∈ (λx. case x of (f, t, C, h, d) ⇒ (h, ⌊(Class C # drop (length uua_ - d) uua_, uu_)⌋)) ` {x ∈ set xt. case x of (f, t, C, ab) ⇒ is_relevant_class (is ! pc) P C ∧ f ≤ pc ∧ pc < t}); s = ⌊a⌋; is ! pc = Goto x12⟧ ⟹ s' ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists (Suc (length Ts + mxl₀)) (err (types P)))› 13. ‹⋀s pc pc' s' a. ⟦wf_prog p P; a ∈ ⋃ {nlists n (types P) |n. n ≤ mxs} × nlists (Suc (length Ts + mxl₀)) (err (types P)); pc < length is; app⇩i (is ! pc, P, pc, mxs, T⇩r, a) ∧ (∀aa ab ac ad b. (aa, ab, ac, ad, b) ∈ set xt ∧ is_relevant_class (is ! pc) P ac ∧ aa ≤ pc ∧ pc < ab ⟶ is_class P ac ∧ b ≤ length (fst a) ∧ b < mxs) ∧ (∀x∈(λpc'. (pc', ⌊eff⇩i (is ! pc, P, a)⌋)) ` set (succs (is ! pc) a pc) ∪ {x. ∃uu_ uua_. (uua_, uu_) = a ∧ x ∈ (λx. case x of (f, t, C, h, d) ⇒ (h, ⌊(Class C # drop (length uua_ - d) uua_, uu_)⌋)) ` {x ∈ set xt. case x of (f, t, C, ab) ⇒ is_relevant_class (is ! pc) P C ∧ f ≤ pc ∧ pc < t}}. case x of (pc', τ') ⇒ pc' < length is); (pc', s') ∈ (λpc'. (pc', ⌊eff⇩i (is ! pc, P, a)⌋)) ` set (succs (is ! pc) a pc) ∨ (∃uu_ uua_. (uua_, uu_) = a ∧ (pc', s') ∈ (λx. case x of (f, t, C, h, d) ⇒ (h, ⌊(Class C # drop (length uua_ - d) uua_, uu_)⌋)) ` {x ∈ set xt. case x of (f, t, C, ab) ⇒ is_relevant_class (is ! pc) P C ∧ f ≤ pc ∧ pc < t}); s = ⌊a⌋; is ! pc = CmpEq⟧ ⟹ s' ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists (Suc (length Ts + mxl₀)) (err (types P)))› 14. ‹⋀s pc pc' s' a x14. ⟦wf_prog p P; a ∈ ⋃ {nlists n (types P) |n. n ≤ mxs} × nlists (Suc (length Ts + mxl₀)) (err (types P)); pc < length is; app⇩i (is ! pc, P, pc, mxs, T⇩r, a) ∧ (∀aa ab ac ad b. (aa, ab, ac, ad, b) ∈ set xt ∧ is_relevant_class (is ! pc) P ac ∧ aa ≤ pc ∧ pc < ab ⟶ is_class P ac ∧ b ≤ length (fst a) ∧ b < mxs) ∧ (∀x∈(λpc'. (pc', ⌊eff⇩i (is ! pc, P, a)⌋)) ` set (succs (is ! pc) a pc) ∪ {x. ∃uu_ uua_. (uua_, uu_) = a ∧ x ∈ (λx. case x of (f, t, C, h, d) ⇒ (h, ⌊(Class C # drop (length uua_ - d) uua_, uu_)⌋)) ` {x ∈ set xt. case x of (f, t, C, ab) ⇒ is_relevant_class (is ! pc) P C ∧ f ≤ pc ∧ pc < t}}. case x of (pc', τ') ⇒ pc' < length is); (pc', s') ∈ (λpc'. (pc', ⌊eff⇩i (is ! pc, P, a)⌋)) ` set (succs (is ! pc) a pc) ∨ (∃uu_ uua_. (uua_, uu_) = a ∧ (pc', s') ∈ (λx. case x of (f, t, C, h, d) ⇒ (h, ⌊(Class C # drop (length uua_ - d) uua_, uu_)⌋)) ` {x ∈ set xt. case x of (f, t, C, ab) ⇒ is_relevant_class (is ! pc) P C ∧ f ≤ pc ∧ pc < t}); s = ⌊a⌋; is ! pc = IfFalse x14⟧ ⟹ s' ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists (Suc (length Ts + mxl₀)) (err (types P)))› 15. ‹⋀s pc pc' s' a. ⟦wf_prog p P; a ∈ ⋃ {nlists n (types P) |n. n ≤ mxs} × nlists (Suc (length Ts + mxl₀)) (err (types P)); pc < length is; app⇩i (is ! pc, P, pc, mxs, T⇩r, a) ∧ (∀aa ab ac ad b. (aa, ab, ac, ad, b) ∈ set xt ∧ is_relevant_class (is ! pc) P ac ∧ aa ≤ pc ∧ pc < ab ⟶ is_class P ac ∧ b ≤ length (fst a) ∧ b < mxs) ∧ (∀x∈(λpc'. (pc', ⌊eff⇩i (is ! pc, P, a)⌋)) ` set (succs (is ! pc) a pc) ∪ {x. ∃uu_ uua_. (uua_, uu_) = a ∧ x ∈ (λx. case x of (f, t, C, h, d) ⇒ (h, ⌊(Class C # drop (length uua_ - d) uua_, uu_)⌋)) ` {x ∈ set xt. case x of (f, t, C, ab) ⇒ is_relevant_class (is ! pc) P C ∧ f ≤ pc ∧ pc < t}}. case x of (pc', τ') ⇒ pc' < length is); (pc', s') ∈ (λpc'. (pc', ⌊eff⇩i (is ! pc, P, a)⌋)) ` set (succs (is ! pc) a pc) ∨ (∃uu_ uua_. (uua_, uu_) = a ∧ (pc', s') ∈ (λx. case x of (f, t, C, h, d) ⇒ (h, ⌊(Class C # drop (length uua_ - d) uua_, uu_)⌋)) ` {x ∈ set xt. case x of (f, t, C, ab) ⇒ is_relevant_class (is ! pc) P C ∧ f ≤ pc ∧ pc < t}); s = ⌊a⌋; is ! pc = Throw⟧ ⟹ s' ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists (Suc (length Ts + mxl₀)) (err (types P)))› discuss goal 1*) apply clarsimp (*top goal: ‹⋀s pc pc' s' a x1. ⟦wf_prog p P; a ∈ ⋃ {nlists n (types P) |n. n ≤ mxs} × nlists (Suc (length Ts + mxl₀)) (err (types P)); pc < length is; app⇩i (is ! pc, P, pc, mxs, T⇩r, a) ∧ (∀aa ab ac ad b. (aa, ab, ac, ad, b) ∈ set xt ∧ is_relevant_class (is ! pc) P ac ∧ aa ≤ pc ∧ pc < ab ⟶ is_class P ac ∧ b ≤ length (fst a) ∧ b < mxs) ∧ (∀x∈(λpc'. (pc', ⌊eff⇩i (is ! pc, P, a)⌋)) ` set (succs (is ! pc) a pc) ∪ {x. ∃uu_ uua_. (uua_, uu_) = a ∧ x ∈ (λx. case x of (f, t, C, h, d) ⇒ (h, ⌊(Class C # drop (length uua_ - d) uua_, uu_)⌋)) ` {x ∈ set xt. case x of (f, t, C, ab) ⇒ is_relevant_class (is ! pc) P C ∧ f ≤ pc ∧ pc < t}}. case x of (pc', τ') ⇒ pc' < length is); (pc', s') ∈ (λpc'. (pc', ⌊eff⇩i (is ! pc, P, a)⌋)) ` set (succs (is ! pc) a pc) ∨ (∃uu_ uua_. (uua_, uu_) = a ∧ (pc', s') ∈ (λx. case x of (f, t, C, h, d) ⇒ (h, ⌊(Class C # drop (length uua_ - d) uua_, uu_)⌋)) ` {x ∈ set xt. case x of (f, t, C, ab) ⇒ is_relevant_class (is ! pc) P C ∧ f ≤ pc ∧ pc < t}); s = ⌊a⌋; is ! pc = Load x1⟧ ⟹ s' ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists (Suc (length Ts + mxl₀)) (err (types P)))› and 14 goals remain*) apply (frule nlistsE_nth_in (*‹⟦?xs ∈ nlists ?n ?A; ?i < ?n⟧ ⟹ ?xs ! ?i ∈ ?A›*)) (*goals: 1. ‹⋀pc x1 ST LT n aa. ⟦wf_prog p P; is ! pc = Load x1; Suc pc < length is; LT ∈ nlists (Suc (length Ts + mxl₀)) (err (types P)); ST ∈ nlists n (types P); x1 < Suc (length Ts + mxl₀); n < mxs; LT ! x1 = OK aa⟧ ⟹ ?i39 pc x1 ST LT n aa < Suc (length Ts + mxl₀)› 2. ‹⋀pc x1 ST LT n aa. ⟦wf_prog p P; is ! pc = Load x1; Suc pc < length is; LT ∈ nlists (Suc (length Ts + mxl₀)) (err (types P)); ST ∈ nlists n (types P); x1 < Suc (length Ts + mxl₀); n < mxs; LT ! x1 = OK aa; LT ! ?i39 pc x1 ST LT n aa ∈ err (types P)⟧ ⟹ is_type P aa› discuss goal 1*) apply assumption (*discuss goal 2*) apply fastforce (*proven 2 subgoals*) (*discuss goal 2*) apply fastforce (*discuss goal 3*) apply (fastforce simp add: typeof_lit_is_type (*‹typeof⇘λx. None⇙ ?v = ⌊?T⌋ ⟹ is_type ?P ?T›*)) (*discuss goal 4*) apply clarsimp (*top goal: ‹⋀s pc pc' s' a x4. ⟦wf_prog p P; a ∈ ⋃ {nlists n (types P) |n. n ≤ mxs} × nlists (Suc (length Ts + mxl₀)) (err (types P)); pc < length is; app⇩i (is ! pc, P, pc, mxs, T⇩r, a) ∧ (∀aa ab ac ad b. (aa, ab, ac, ad, b) ∈ set xt ∧ is_relevant_class (is ! pc) P ac ∧ aa ≤ pc ∧ pc < ab ⟶ is_class P ac ∧ b ≤ length (fst a) ∧ b < mxs) ∧ (∀x∈(λpc'. (pc', ⌊eff⇩i (is ! pc, P, a)⌋)) ` set (succs (is ! pc) a pc) ∪ {x. ∃uu_ uua_. (uua_, uu_) = a ∧ x ∈ (λx. case x of (f, t, C, h, d) ⇒ (h, ⌊(Class C # drop (length uua_ - d) uua_, uu_)⌋)) ` {x ∈ set xt. case x of (f, t, C, ab) ⇒ is_relevant_class (is ! pc) P C ∧ f ≤ pc ∧ pc < t}}. case x of (pc', τ') ⇒ pc' < length is); (pc', s') ∈ (λpc'. (pc', ⌊eff⇩i (is ! pc, P, a)⌋)) ` set (succs (is ! pc) a pc) ∨ (∃uu_ uua_. (uua_, uu_) = a ∧ (pc', s') ∈ (λx. case x of (f, t, C, h, d) ⇒ (h, ⌊(Class C # drop (length uua_ - d) uua_, uu_)⌋)) ` {x ∈ set xt. case x of (f, t, C, ab) ⇒ is_relevant_class (is ! pc) P C ∧ f ≤ pc ∧ pc < t}); s = ⌊a⌋; is ! pc = New x4⟧ ⟹ s' ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists (Suc (length Ts + mxl₀)) (err (types P)))› and 11 goals remain*) apply fastforce (*discuss goal 5*) apply clarsimp (*top goal: ‹⋀s pc pc' s' a x51 x52. ⟦wf_prog p P; a ∈ ⋃ {nlists n (types P) |n. n ≤ mxs} × nlists (Suc (length Ts + mxl₀)) (err (types P)); pc < length is; app⇩i (is ! pc, P, pc, mxs, T⇩r, a) ∧ (∀aa ab ac ad b. (aa, ab, ac, ad, b) ∈ set xt ∧ is_relevant_class (is ! pc) P ac ∧ aa ≤ pc ∧ pc < ab ⟶ is_class P ac ∧ b ≤ length (fst a) ∧ b < mxs) ∧ (∀x∈(λpc'. (pc', ⌊eff⇩i (is ! pc, P, a)⌋)) ` set (succs (is ! pc) a pc) ∪ {x. ∃uu_ uua_. (uua_, uu_) = a ∧ x ∈ (λx. case x of (f, t, C, h, d) ⇒ (h, ⌊(Class C # drop (length uua_ - d) uua_, uu_)⌋)) ` {x ∈ set xt. case x of (f, t, C, ab) ⇒ is_relevant_class (is ! pc) P C ∧ f ≤ pc ∧ pc < t}}. case x of (pc', τ') ⇒ pc' < length is); (pc', s') ∈ (λpc'. (pc', ⌊eff⇩i (is ! pc, P, a)⌋)) ` set (succs (is ! pc) a pc) ∨ (∃uu_ uua_. (uua_, uu_) = a ∧ (pc', s') ∈ (λx. case x of (f, t, C, h, d) ⇒ (h, ⌊(Class C # drop (length uua_ - d) uua_, uu_)⌋)) ` {x ∈ set xt. case x of (f, t, C, ab) ⇒ is_relevant_class (is ! pc) P C ∧ f ≤ pc ∧ pc < t}); s = ⌊a⌋; is ! pc = Getfield x51 x52⟧ ⟹ s' ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists (Suc (length Ts + mxl₀)) (err (types P)))› and 10 goals remain*) apply (fastforce dest: sees_field_is_type (*‹⟦?P ⊢ ?C sees ?F:?T in ?D; wf_prog ?wf_md ?P⟧ ⟹ is_type ?P ?T›*)) (*discuss goal 6*) apply clarsimp (*top goal: ‹⋀(s::(ty list × ty err list) option) (pc::nat) (pc'::nat) (s'::(ty list × ty err list) option) (a::ty list × ty err list) (x61::char list) x62::char list. ⟦wf_prog (p::(char list × char list × (char list × ty) list × (char list × ty list × ty × nat × nat × instr list × (nat × nat × char list × nat × nat) list) list) list ⇒ char list ⇒ char list × ty list × ty × nat × nat × instr list × (nat × nat × char list × nat × nat) list ⇒ bool) (P::(char list × char list × (char list × ty) list × (char list × ty list × ty × nat × nat × instr list × (nat × nat × char list × nat × nat) list) list) list); a ∈ ⋃ {nlists n (types P) |n::nat. n ≤ (mxs::nat)} × nlists (Suc (length (Ts::ty list) + (mxl₀::nat))) (err (types P)); pc < length (is::instr list); app⇩i (is ! pc, P, pc, mxs, T⇩r::ty, a) ∧ (∀(aa::nat) (ab::nat) (ac::char list) (ad::nat) b::nat. (aa, ab, ac, ad, b) ∈ set (xt::(nat × nat × char list × nat × nat) list) ∧ is_relevant_class (is ! pc) P ac ∧ aa ≤ pc ∧ pc < ab ⟶ is_class P ac ∧ b ≤ length (fst a) ∧ b < mxs) ∧ (∀x::nat × (ty list × ty err list) option∈(λpc'::nat. (pc', ⌊eff⇩i (is ! pc, P, a)⌋)) ` set (succs (is ! pc) a pc) ∪ {x::nat × (ty list × ty err list) option. ∃(uu_::ty err list) uua_::ty list. (uua_, uu_) = a ∧ x ∈ (λx::nat × nat × char list × nat × nat. case x of (f::nat, t::nat, C::char list, h::nat, d::nat) ⇒ (h, ⌊(Class C # drop (length uua_ - d) uua_, uu_)⌋)) ` {x::nat × nat × char list × nat × nat ∈ set xt. case x of (f::nat, t::nat, C::char list, ab::nat × nat) ⇒ is_relevant_class (is ! pc) P C ∧ f ≤ pc ∧ pc < t}}. case x of (pc'::nat, τ'::(ty list × ty err list) option) ⇒ pc' < length is); (pc', s') ∈ (λpc'::nat. (pc', ⌊eff⇩i (is ! pc, P, a)⌋)) ` set (succs (is ! pc) a pc) ∨ (∃(uu_::ty err list) uua_::ty list. (uua_, uu_) = a ∧ (pc', s') ∈ (λx::nat × nat × char list × nat × nat. case x of (f::nat, t::nat, C::char list, h::nat, d::nat) ⇒ (h, ⌊(Class C # drop (length uua_ - d) uua_, uu_)⌋)) ` {x::nat × nat × char list × nat × nat ∈ set xt. case x of (f::nat, t::nat, C::char list, ab::nat × nat) ⇒ is_relevant_class (is ! pc) P C ∧ f ≤ pc ∧ pc < t}); s = ⌊a⌋; is ! pc = Putfield x61 x62⟧ ⟹ s' ∈ opt (⋃ {nlists n (types P) |n::nat. n ≤ mxs} × nlists (Suc (length Ts + mxl₀)) (err (types P)))› and 9 goals remain*) apply fastforce (*discuss goal 7*) apply clarsimp (*top goal: ‹⋀s pc pc' s' a x7. ⟦wf_prog p P; a ∈ ⋃ {nlists n (types P) |n. n ≤ mxs} × nlists (Suc (length Ts + mxl₀)) (err (types P)); pc < length is; app⇩i (is ! pc, P, pc, mxs, T⇩r, a) ∧ (∀aa ab ac ad b. (aa, ab, ac, ad, b) ∈ set xt ∧ is_relevant_class (is ! pc) P ac ∧ aa ≤ pc ∧ pc < ab ⟶ is_class P ac ∧ b ≤ length (fst a) ∧ b < mxs) ∧ (∀x∈(λpc'. (pc', ⌊eff⇩i (is ! pc, P, a)⌋)) ` set (succs (is ! pc) a pc) ∪ {x. ∃uu_ uua_. (uua_, uu_) = a ∧ x ∈ (λx. case x of (f, t, C, h, d) ⇒ (h, ⌊(Class C # drop (length uua_ - d) uua_, uu_)⌋)) ` {x ∈ set xt. case x of (f, t, C, ab) ⇒ is_relevant_class (is ! pc) P C ∧ f ≤ pc ∧ pc < t}}. case x of (pc', τ') ⇒ pc' < length is); (pc', s') ∈ (λpc'. (pc', ⌊eff⇩i (is ! pc, P, a)⌋)) ` set (succs (is ! pc) a pc) ∨ (∃uu_ uua_. (uua_, uu_) = a ∧ (pc', s') ∈ (λx. case x of (f, t, C, h, d) ⇒ (h, ⌊(Class C # drop (length uua_ - d) uua_, uu_)⌋)) ` {x ∈ set xt. case x of (f, t, C, ab) ⇒ is_relevant_class (is ! pc) P C ∧ f ≤ pc ∧ pc < t}); s = ⌊a⌋; is ! pc = Checkcast x7⟧ ⟹ s' ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists (Suc (length Ts + mxl₀)) (err (types P)))› and 8 goals remain*) apply fastforce (*discuss goal 8*) apply (clarsimp 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))›*)) (*goals: 1. ‹⋀pc a b x81 x82 n aa ab ac ad ba. ⟦is ! pc = Invoke x81 x82; wf_prog p P; pc < length is; a ! x82 = NT; x82 < n; b ∈ nlists (Suc (length Ts + mxl₀)) (err (types P)); a ∈ nlists n (types P); ∀a aa ab ac b. (a, aa, ab, ac, b) ∈ set xt ∧ a ≤ pc ∧ pc < aa ⟶ is_class P ab ∧ b ≤ n ∧ b < mxs; ∀aa. (∃ba. (aa, ba) ∈ (λx. case x of (f, t, C, h, d) ⇒ (h, ⌊(Class C # drop (n - d) a, b)⌋)) ` {x ∈ set xt. case x of (f, ab) ⇒ f ≤ pc ∧ (case ab of (t, ab) ⇒ pc < t)}) ⟶ aa < length is; n ≤ mxs; (aa, ab, ac, ad, ba) ∈ set xt; aa ≤ pc; pc < ab⟧ ⟹ Suc ba ≤ mxs› 2. ‹⋀pc pc' s' a b x81 x82 n C D Tsa T aa ab ac ba. ⟦pc' = Suc pc ∧ s' = ⌊(T # drop (Suc x82) a, b)⌋ ∨ (pc', s') ∈ (λx. case x of (f, t, C, h, d) ⇒ (h, ⌊(Class C # drop (n - d) a, b)⌋)) ` {x ∈ set xt. case x of (f, ab) ⇒ f ≤ pc ∧ (case ab of (t, ab) ⇒ pc < t)}; is ! pc = Invoke x81 x82; wf_prog p P; b ∈ nlists (Suc (length Ts + mxl₀)) (err (types P)); a ∈ nlists n (types P); ∀a aa ab ac b. (a, aa, ab, ac, b) ∈ set xt ∧ a ≤ pc ∧ pc < aa ⟶ is_class P ab ∧ b ≤ n ∧ b < mxs; n ≤ mxs; Suc pc < length is; ∀aa. (∃ba. (aa, ba) ∈ (λx. case x of (f, t, C, h, d) ⇒ (h, ⌊(Class C # drop (n - d) a, b)⌋)) ` {x ∈ set xt. case x of (f, ab) ⇒ f ≤ pc ∧ (case ab of (t, ab) ⇒ pc < t)}) ⟶ aa < length is; x82 < n; a ! x82 = Class C; P ⊢ rev (take x82 a) [≤] Tsa; P ⊢ C sees x81: Tsa→T = (aa, ab, ac, ba) in D⟧ ⟹ s' ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists (Suc (length Ts + mxl₀)) (err (types P)))› discuss goal 1*) apply fastforce (*discuss goal 2*) apply (erule disjE (*‹⟦?P ∨ ?Q; ?P ⟹ ?R; ?Q ⟹ ?R⟧ ⟹ ?R›*)) (*goals: 1. ‹⋀pc pc' s' a b x81 x82 n C D Tsa T aa ab ac ba. ⟦is ! pc = Invoke x81 x82; wf_prog p P; b ∈ nlists (Suc (length Ts + mxl₀)) (err (types P)); a ∈ nlists n (types P); ∀a aa ab ac b. (a, aa, ab, ac, b) ∈ set xt ∧ a ≤ pc ∧ pc < aa ⟶ is_class P ab ∧ b ≤ n ∧ b < mxs; n ≤ mxs; Suc pc < length is; ∀aa. (∃ba. (aa, ba) ∈ (λx. case x of (f, t, C, h, d) ⇒ (h, ⌊(Class C # drop (n - d) a, b)⌋)) ` {x ∈ set xt. case x of (f, ab) ⇒ f ≤ pc ∧ (case ab of (t, ab) ⇒ pc < t)}) ⟶ aa < length is; x82 < n; a ! x82 = Class C; P ⊢ rev (take x82 a) [≤] Tsa; P ⊢ C sees x81: Tsa→T = (aa, ab, ac, ba) in D; pc' = Suc pc ∧ s' = ⌊(T # drop (Suc x82) a, b)⌋⟧ ⟹ s' ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists (Suc (length Ts + mxl₀)) (err (types P)))› 2. ‹⋀pc pc' s' a b x81 x82 n C D Tsa T aa ab ac ba. ⟦is ! pc = Invoke x81 x82; wf_prog p P; b ∈ nlists (Suc (length Ts + mxl₀)) (err (types P)); a ∈ nlists n (types P); ∀a aa ab ac b. (a, aa, ab, ac, b) ∈ set xt ∧ a ≤ pc ∧ pc < aa ⟶ is_class P ab ∧ b ≤ n ∧ b < mxs; n ≤ mxs; Suc pc < length is; ∀aa. (∃ba. (aa, ba) ∈ (λx. case x of (f, t, C, h, d) ⇒ (h, ⌊(Class C # drop (n - d) a, b)⌋)) ` {x ∈ set xt. case x of (f, ab) ⇒ f ≤ pc ∧ (case ab of (t, ab) ⇒ pc < t)}) ⟶ aa < length is; x82 < n; a ! x82 = Class C; P ⊢ rev (take x82 a) [≤] Tsa; P ⊢ C sees x81: Tsa→T = (aa, ab, ac, ba) in D; (pc', s') ∈ (λx. case x of (f, t, C, h, d) ⇒ (h, ⌊(Class C # drop (n - d) a, b)⌋)) ` {x ∈ set xt. case x of (f, ab) ⇒ f ≤ pc ∧ (case ab of (t, ab) ⇒ pc < t)}⟧ ⟹ s' ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists (Suc (length Ts + mxl₀)) (err (types P)))› discuss goal 1*) apply clarsimp (*top goal: ‹⋀pc pc' s' a b x81 x82 n C D Tsa T aa ab ac ba. ⟦is ! pc = Invoke x81 x82; wf_prog p P; b ∈ nlists (Suc (length Ts + mxl₀)) (err (types P)); a ∈ nlists n (types P); ∀a aa ab ac b. (a, aa, ab, ac, b) ∈ set xt ∧ a ≤ pc ∧ pc < aa ⟶ is_class P ab ∧ b ≤ n ∧ b < mxs; n ≤ mxs; Suc pc < length is; ∀aa. (∃ba. (aa, ba) ∈ (λx. case x of (f, t, C, h, d) ⇒ (h, ⌊(Class C # drop (n - d) a, b)⌋)) ` {x ∈ set xt. case x of (f, ab) ⇒ f ≤ pc ∧ (case ab of (t, ab) ⇒ pc < t)}) ⟶ aa < length is; x82 < n; a ! x82 = Class C; P ⊢ rev (take x82 a) [≤] Tsa; P ⊢ C sees x81: Tsa→T = (aa, ab, ac, ba) in D; pc' = Suc pc ∧ s' = ⌊(T # drop (Suc x82) a, b)⌋⟧ ⟹ s' ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists (Suc (length Ts + mxl₀)) (err (types P)))› and 8 goals remain*) apply (rule conjI (*‹⟦?P; ?Q⟧ ⟹ ?P ∧ ?Q›*)) (*goals: 1. ‹⋀pc a b x81 x82 n C D Tsa T aa ab ac ba. ⟦is ! pc = Invoke x81 x82; wf_prog p P; b ∈ nlists (Suc (length Ts + mxl₀)) (err (types P)); a ∈ nlists n (types P); ∀a aa ab ac b. (a, aa, ab, ac, b) ∈ set xt ∧ a ≤ pc ∧ pc < aa ⟶ is_class P ab ∧ b ≤ n ∧ b < mxs; n ≤ mxs; Suc pc < length is; ∀aa. (∃ba. (aa, ba) ∈ (λx. case x of (f, t, C, h, d) ⇒ (h, ⌊(Class C # drop (n - d) a, b)⌋)) ` {x ∈ set xt. case x of (f, ab) ⇒ f ≤ pc ∧ (case ab of (t, ab) ⇒ pc < t)}) ⟶ aa < length is; x82 < n; a ! x82 = Class C; P ⊢ rev (take x82 a) [≤] Tsa; P ⊢ C sees x81: Tsa→T = (aa, ab, ac, ba) in D⟧ ⟹ is_type P T› 2. ‹⋀pc a b x81 x82 n C D Tsa T aa ab ac ba. ⟦is ! pc = Invoke x81 x82; wf_prog p P; b ∈ nlists (Suc (length Ts + mxl₀)) (err (types P)); a ∈ nlists n (types P); ∀a aa ab ac b. (a, aa, ab, ac, b) ∈ set xt ∧ a ≤ pc ∧ pc < aa ⟶ is_class P ab ∧ b ≤ n ∧ b < mxs; n ≤ mxs; Suc pc < length is; ∀aa. (∃ba. (aa, ba) ∈ (λx. case x of (f, t, C, h, d) ⇒ (h, ⌊(Class C # drop (n - d) a, b)⌋)) ` {x ∈ set xt. case x of (f, ab) ⇒ f ≤ pc ∧ (case ab of (t, ab) ⇒ pc < t)}) ⟶ aa < length is; x82 < n; a ! x82 = Class C; P ⊢ rev (take x82 a) [≤] Tsa; P ⊢ C sees x81: Tsa→T = (aa, ab, ac, ba) in D⟧ ⟹ Suc (n - Suc x82) ≤ mxs› discuss goal 1*) apply (drule (1) sees_wf_mdecl (*‹⟦wf_prog ?wf_md ?P; ?P ⊢ ?C sees ?M: ?Ts→?T = ?m in ?D⟧ ⟹ wf_mdecl ?wf_md ?P ?D (?M, ?Ts, ?T, ?m)›*)) (*top goal: ‹⋀pc a b x81 x82 n C D Tsa T aa ab ac ba. ⟦is ! pc = Invoke x81 x82; wf_prog p P; b ∈ nlists (Suc (length Ts + mxl₀)) (err (types P)); a ∈ nlists n (types P); ∀a aa ab ac b. (a, aa, ab, ac, b) ∈ set xt ∧ a ≤ pc ∧ pc < aa ⟶ is_class P ab ∧ b ≤ n ∧ b < mxs; n ≤ mxs; Suc pc < length is; ∀aa. (∃ba. (aa, ba) ∈ (λx. case x of (f, t, C, h, d) ⇒ (h, ⌊(Class C # drop (n - d) a, b)⌋)) ` {x ∈ set xt. case x of (f, ab) ⇒ f ≤ pc ∧ (case ab of (t, ab) ⇒ pc < t)}) ⟶ aa < length is; x82 < n; a ! x82 = Class C; P ⊢ rev (take x82 a) [≤] Tsa; P ⊢ C sees x81: Tsa→T = (aa, ab, ac, ba) in D⟧ ⟹ is_type P T› and 9 goals remain*) apply (clarsimp simp add: wf_mdecl_def (*‹wf_mdecl ?wf_md ?P ?C ≡ λ(M, Ts, T, mb). (∀T∈set Ts. is_type ?P T) ∧ is_type ?P T ∧ ?wf_md ?P ?C (M, Ts, T, mb)›*)) (*discuss goal 2*) apply arith (*proven 2 subgoals*) (*discuss goal 2*) apply fastforce (*proven 2 subgoals*) (*proven 2 subgoals*) (*discuss goal 9*) apply fastforce (*discuss goal 10*) apply fastforce (*discuss goal 11*) apply fastforce (*discuss goal 12*) apply fastforce (*discuss goal 13*) apply fastforce (*discuss goal 14*) apply fastforce (*discuss goal 15*) apply clarsimp (*goal: ‹⋀s pc pc' s' a. ⟦wf_prog p P; a ∈ ⋃ {nlists n (types P) |n. n ≤ mxs} × nlists (Suc (length Ts + mxl₀)) (err (types P)); pc < length is; app⇩i (is ! pc, P, pc, mxs, T⇩r, a) ∧ (∀aa ab ac ad b. (aa, ab, ac, ad, b) ∈ set xt ∧ is_relevant_class (is ! pc) P ac ∧ aa ≤ pc ∧ pc < ab ⟶ is_class P ac ∧ b ≤ length (fst a) ∧ b < mxs) ∧ (∀x∈(λpc'. (pc', ⌊eff⇩i (is ! pc, P, a)⌋)) ` set (succs (is ! pc) a pc) ∪ {x. ∃uu_ uua_. (uua_, uu_) = a ∧ x ∈ (λx. case x of (f, t, C, h, d) ⇒ (h, ⌊(Class C # drop (length uua_ - d) uua_, uu_)⌋)) ` {x ∈ set xt. case x of (f, t, C, ab) ⇒ is_relevant_class (is ! pc) P C ∧ f ≤ pc ∧ pc < t}}. case x of (pc', τ') ⇒ pc' < length is); (pc', s') ∈ (λpc'. (pc', ⌊eff⇩i (is ! pc, P, a)⌋)) ` set (succs (is ! pc) a pc) ∨ (∃uu_ uua_. (uua_, uu_) = a ∧ (pc', s') ∈ (λx. case x of (f, t, C, h, d) ⇒ (h, ⌊(Class C # drop (length uua_ - d) uua_, uu_)⌋)) ` {x ∈ set xt. case x of (f, t, C, ab) ⇒ is_relevant_class (is ! pc) P C ∧ f ≤ pc ∧ pc < t}); s = ⌊a⌋; is ! pc = Throw⟧ ⟹ s' ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists (Suc (length Ts + mxl₀)) (err (types P)))›*) apply fastforce (*proven 15 subgoals*) (*proven 2 subgoals*) . (*>*) declare is_relevant_entry_def [simp del] declare set_drop_subset [simp del] lemma lesubstep_type_simple: "xs [⊑⇘Product.le (=) r⇙] ys ⟹ set xs {⊑⇘r⇙} set ys" (*<*) apply (unfold lesubstep_type_def (*‹?A {⊑⇘?r⇙} ?B ≡ ∀(p, τ)∈?A. ∃τ'. (p, τ') ∈ ?B ∧ τ ⊑⇘?r⇙ τ'›*)) (*goal: ‹(xs::(nat × 'a) list) [⊑⇘Product.le (=) (r::'a ⇒ 'a ⇒ bool)⇙] (ys::(nat × 'a) list) ⟹ set xs {⊑⇘r⇙} set ys›*) apply clarify (*goal: ‹xs [⊑⇘Product.le (=) r⇙] ys ⟹ ∀(p, τ)∈set xs. ∃τ'. (p, τ') ∈ set ys ∧ τ ⊑⇘r⇙ τ'›*) apply (simp add: set_conv_nth (*‹set (?xs::?'a list) = {?xs ! i |i::nat. i < length ?xs}›*)) (*goal: ‹⋀(a::nat) b::'a::type. ⟦(xs::(nat × 'a::type) list) [⊑⇘Product.le (=) (r::'a::type ⇒ 'a::type ⇒ bool)⇙] (ys::(nat × 'a::type) list); (a, b) ∈ set xs⟧ ⟹ ∃τ'::'a::type. (a, τ') ∈ set ys ∧ b ⊑⇘r⇙ τ'›*) apply clarify (*goal: ‹⋀a b. ⟦xs [⊑⇘Product.le (=) r⇙] ys; ∃i. (a, b) = xs ! i ∧ i < length xs⟧ ⟹ ∃τ'. (∃i. (a, τ') = ys ! i ∧ i < length xs) ∧ b ⊑⇘r⇙ τ'›*) apply (drule le_listD (*‹⟦(?xs::?'a::type list) [⊑⇘?r::?'a::type ⇒ ?'a::type ⇒ bool⇙] (?ys::?'a::type list); (?p::nat) < length ?xs⟧ ⟹ ?xs ! ?p ⊑⇘?r⇙ ?ys ! ?p›*)) (*goals: 1. ‹⋀a b i. ⟦(a, b) = xs ! i; i < length xs⟧ ⟹ ?p4 a b i < length xs› 2. ‹⋀a b i. ⟦(a, b) = xs ! i; i < length xs; xs ! ?p4 a b i <=((=),r) ys ! ?p4 a b i⟧ ⟹ ∃τ'. (∃i. (a, τ') = ys ! i ∧ i < length xs) ∧ b ⊑⇘r⇙ τ'› discuss goal 1*) apply assumption (*discuss goal 2*) apply (clarsimp simp add: lesub_def (*‹((?x::?'a) ⊑⇘?r::?'a ⇒ ?'a ⇒ bool⇙ (?y::?'a)) = ?r ?x ?y›*) Product.le_def (*‹Product.le (?r⇩A::?'a ⇒ ?'a ⇒ bool) (?r⇩B::?'b ⇒ ?'b ⇒ bool) = (λ(a₁::?'a, b₁::?'b) (a₂::?'a, b₂::?'b). a₁ ⊑⇘?r⇩A⇙ a₂ ∧ b₁ ⊑⇘?r⇩B⇙ b₂)›*)) (*goal: ‹⋀a b i. ⟦(a, b) = xs ! i; i < length xs; xs ! i <=((=),r) ys ! i⟧ ⟹ ∃τ'. (∃i. (a, τ') = ys ! i ∧ i < length xs) ∧ b ⊑⇘r⇙ τ'›*) apply (rule exI (*‹?P ?x ⟹ ∃x. ?P x›*)) (*goal: ‹⋀a i y ya. ⟦i < length xs; xs ! i = (a, y); ys ! i = (a, ya); r y ya⟧ ⟹ ∃τ'. (∃i. (a, τ') = ys ! i ∧ i < length xs) ∧ r y τ'›*) apply (rule conjI (*‹⟦?P; ?Q⟧ ⟹ ?P ∧ ?Q›*)) (*goals: 1. ‹⋀a i y ya. ⟦i < length xs; xs ! i = (a, y); ys ! i = (a, ya); r y ya⟧ ⟹ ∃ia. (a, ?τ'12 a i y ya) = ys ! ia ∧ ia < length xs› 2. ‹⋀a i y ya. ⟦i < length xs; xs ! i = (a, y); ys ! i = (a, ya); r y ya⟧ ⟹ r y (?τ'12 a i y ya)› discuss goal 1*) apply (rule exI (*‹?P ?x ⟹ ∃x. ?P x›*)) (*top goal: ‹⋀(a::nat) (i::nat) (y::'a) ya::'a. ⟦i < length (xs::(nat × 'a) list); xs ! i = (a, y); (ys::(nat × 'a) list) ! i = (a, ya); (r::'a ⇒ 'a ⇒ bool) y ya⟧ ⟹ ∃ia::nat. (a, (?τ'12::nat ⇒ nat ⇒ 'a ⇒ 'a ⇒ 'a) a i y ya) = ys ! ia ∧ ia < length xs› and 1 goal remains*) apply (rule conjI (*‹⟦?P; ?Q⟧ ⟹ ?P ∧ ?Q›*)) (*goals: 1. ‹⋀a i y ya. ⟦i < length xs; xs ! i = (a, y); ys ! i = (a, ya); r y ya⟧ ⟹ (a, ?τ'12 a i y ya) = ys ! ?i17 a i y ya› 2. ‹⋀a i y ya. ⟦i < length xs; xs ! i = (a, y); ys ! i = (a, ya); r y ya⟧ ⟹ ?i17 a i y ya < length xs› discuss goal 1*) apply (rule sym (*‹?s = ?t ⟹ ?t = ?s›*)) (*top goal: ‹⋀(a::nat) (i::nat) (y::'a) ya::'a. ⟦i < length (xs::(nat × 'a) list); xs ! i = (a, y); (ys::(nat × 'a) list) ! i = (a, ya); (r::'a ⇒ 'a ⇒ bool) y ya⟧ ⟹ (a, (?τ'12::nat ⇒ nat ⇒ 'a ⇒ 'a ⇒ 'a) a i y ya) = ys ! (?i17::nat ⇒ nat ⇒ 'a ⇒ 'a ⇒ nat) a i y ya› and 2 goals remain*) apply assumption (*discuss goal 2*) apply assumption (*proven 2 subgoals*) (*discuss goal 2*) apply assumption (*proven 2 subgoals*) (*proven 2 subgoals*) . (*>*) declare is_relevant_entry_def [simp del] lemma conjI2: "⟦ A; A ⟹ B ⟧ ⟹ A ∧ B" by blast lemma (in JVM_sl) eff_mono: "⟦wf_prog p P; pc < length is; s ⊑⇘sup_state_opt P⇙ t; app pc t⟧ ⟹ set (eff pc s) {⊑⇘sup_state_opt P⇙} set (eff pc t)" (*<*) apply simp (*goal: ‹⟦wf_prog p P; pc < length is; s ⊑⇘sup_state_opt P⇙ t; app pc t⟧ ⟹ set (eff pc s) {⊑⇘sup_state_opt P⇙} set (eff pc t)›*) apply (unfold Effect.eff_def (*‹eff ?i ?P ?pc ?et ?t = (case ?t of None ⇒ [] | ⌊τ⌋ ⇒ norm_eff ?i ?P ?pc τ @ xcpt_eff ?i ?P ?pc τ ?et)›*)) (*goal: ‹⟦wf_prog p P; pc < length is; s ⊑⇘sup_state_opt P⇙ t; app (is ! pc) P mxs T⇩r pc (length is) xt t⟧ ⟹ set (eff (is ! pc) P pc xt s) {⊑⇘sup_state_opt P⇙} set (eff (is ! pc) P pc xt t)›*) apply (cases t) (*goals: 1. ‹⟦wf_prog p P; pc < length is; s ⊑⇘sup_state_opt P⇙ t; app (is ! pc) P mxs T⇩r pc (length is) xt t; t = None⟧ ⟹ set (case s of None ⇒ [] | ⌊τ⌋ ⇒ norm_eff (is ! pc) P pc τ @ xcpt_eff (is ! pc) P pc τ xt) {⊑⇘sup_state_opt P⇙} set (case t of None ⇒ [] | ⌊τ⌋ ⇒ norm_eff (is ! pc) P pc τ @ xcpt_eff (is ! pc) P pc τ xt)› 2. ‹⋀a. ⟦wf_prog p P; pc < length is; s ⊑⇘sup_state_opt P⇙ t; app (is ! pc) P mxs T⇩r pc (length is) xt t; t = ⌊a⌋⟧ ⟹ set (case s of None ⇒ [] | ⌊τ⌋ ⇒ norm_eff (is ! pc) P pc τ @ xcpt_eff (is ! pc) P pc τ xt) {⊑⇘sup_state_opt P⇙} set (case t of None ⇒ [] | ⌊τ⌋ ⇒ norm_eff (is ! pc) P pc τ @ xcpt_eff (is ! pc) P pc τ xt)› discuss goal 1*) apply (simp add: lesub_def (*‹(?x ⊑⇘?r⇙ ?y) = ?r ?x ?y›*)) (*discuss goal 2*) apply (rename_tac a) (*goal: ‹⋀a. ⟦wf_prog p P; pc < length is; s ⊑⇘sup_state_opt P⇙ t; app (is ! pc) P mxs T⇩r pc (length is) xt t; t = ⌊a⌋⟧ ⟹ set (case s of None ⇒ [] | ⌊τ⌋ ⇒ norm_eff (is ! pc) P pc τ @ xcpt_eff (is ! pc) P pc τ xt) {⊑⇘sup_state_opt P⇙} set (case t of None ⇒ [] | ⌊τ⌋ ⇒ norm_eff (is ! pc) P pc τ @ xcpt_eff (is ! pc) P pc τ xt)›*) apply (cases s) (*goals: 1. ‹⋀a. ⟦wf_prog p P; pc < length is; s ⊑⇘sup_state_opt P⇙ t; app (is ! pc) P mxs T⇩r pc (length is) xt t; t = ⌊a⌋; s = None⟧ ⟹ set (case s of None ⇒ [] | ⌊τ⌋ ⇒ norm_eff (is ! pc) P pc τ @ xcpt_eff (is ! pc) P pc τ xt) {⊑⇘sup_state_opt P⇙} set (case t of None ⇒ [] | ⌊τ⌋ ⇒ norm_eff (is ! pc) P pc τ @ xcpt_eff (is ! pc) P pc τ xt)› 2. ‹⋀a aa. ⟦wf_prog p P; pc < length is; s ⊑⇘sup_state_opt P⇙ t; app (is ! pc) P mxs T⇩r pc (length is) xt t; t = ⌊a⌋; s = ⌊aa⌋⟧ ⟹ set (case s of None ⇒ [] | ⌊τ⌋ ⇒ norm_eff (is ! pc) P pc τ @ xcpt_eff (is ! pc) P pc τ xt) {⊑⇘sup_state_opt P⇙} set (case t of None ⇒ [] | ⌊τ⌋ ⇒ norm_eff (is ! pc) P pc τ @ xcpt_eff (is ! pc) P pc τ xt)› discuss goal 1*) apply simp (*discuss goal 2*) apply (rename_tac b) (*goal: ‹⋀a aa. ⟦wf_prog p P; pc < length is; s ⊑⇘sup_state_opt P⇙ t; app (is ! pc) P mxs T⇩r pc (length is) xt t; t = ⌊a⌋; s = ⌊aa⌋⟧ ⟹ set (case s of None ⇒ [] | ⌊τ⌋ ⇒ norm_eff (is ! pc) P pc τ @ xcpt_eff (is ! pc) P pc τ xt) {⊑⇘sup_state_opt P⇙} set (case t of None ⇒ [] | ⌊τ⌋ ⇒ norm_eff (is ! pc) P pc τ @ xcpt_eff (is ! pc) P pc τ xt)›*) apply simp (*goal: ‹⋀(a::ty list × ty err list) b::ty list × ty err list. ⟦wf_prog (p::(char list × char list × (char list × ty) list × (char list × ty list × ty × nat × nat × instr list × (nat × nat × char list × nat × nat) list) list) list ⇒ char list ⇒ char list × ty list × ty × nat × nat × instr list × (nat × nat × char list × nat × nat) list ⇒ bool) (P::(char list × char list × (char list × ty) list × (char list × ty list × ty × nat × nat × instr list × (nat × nat × char list × nat × nat) list) list) list); (pc::nat) < length (is::instr list); (s::(ty list × ty err list) option) ⊑⇘sup_state_opt P⇙ (t::(ty list × ty err list) option); app (is ! pc) P (mxs::nat) (T⇩r::ty) pc (length is) (xt::(nat × nat × char list × nat × nat) list) t; t = ⌊a⌋; s = ⌊b⌋⟧ ⟹ set (case s of None ⇒ [] | ⌊τ::ty list × ty err list⌋ ⇒ norm_eff (is ! pc) P pc τ @ xcpt_eff (is ! pc) P pc τ xt) {⊑⇘sup_state_opt P⇙} set (case t of None ⇒ [] | ⌊τ::ty list × ty err list⌋ ⇒ norm_eff (is ! pc) P pc τ @ xcpt_eff (is ! pc) P pc τ xt)›*) apply (rule lesubstep_union (*‹⟦?A₁ {⊑⇘?r⇙} ?B₁; ?A₂ {⊑⇘?r⇙} ?B₂⟧ ⟹ ?A₁ ∪ ?A₂ {⊑⇘?r⇙} ?B₁ ∪ ?B₂›*)) (*goals: 1. ‹⋀a b. ⟦wf_prog p P; pc < length is; ⌊b⌋ ⊑⇘sup_state_opt P⇙ ⌊a⌋; app (is ! pc) P mxs T⇩r pc (length is) xt ⌊a⌋; t = ⌊a⌋; s = ⌊b⌋⟧ ⟹ set (norm_eff (is ! pc) P pc b) {⊑⇘sup_state_opt P⇙} set (norm_eff (is ! pc) P pc a)› 2. ‹⋀a b. ⟦wf_prog p P; pc < length is; ⌊b⌋ ⊑⇘sup_state_opt P⇙ ⌊a⌋; app (is ! pc) P mxs T⇩r pc (length is) xt ⌊a⌋; t = ⌊a⌋; s = ⌊b⌋⟧ ⟹ set (xcpt_eff (is ! pc) P pc b xt) {⊑⇘sup_state_opt P⇙} set (xcpt_eff (is ! pc) P pc a xt)› discuss goal 1*) apply (clarsimp simp add: norm_eff_def (*‹norm_eff ?i ?P ?pc ?τ = map (λpc'. (pc', ⌊eff⇩i (?i, ?P, ?τ)⌋)) (succs ?i ?τ ?pc)›*) lesubstep_type_def (*‹?A {⊑⇘?r⇙} ?B ≡ ∀(p, τ)∈?A. ∃τ'. (p, τ') ∈ ?B ∧ τ ⊑⇘?r⇙ τ'›*) lesub_def (*‹(?x ⊑⇘?r⇙ ?y) = ?r ?x ?y›*) iff del: sup_state_conv (*‹?P ⊢ (?ST, ?LT) ≤⇩i (?ST', ?LT') = (?P ⊢ ?ST [≤] ?ST' ∧ ?P ⊢ ?LT [≤⇩⊤] ?LT')›*)) (*top goal: ‹⋀a b. ⟦wf_prog p P; pc < length is; ⌊b⌋ ⊑⇘sup_state_opt P⇙ ⌊a⌋; app (is ! pc) P mxs T⇩r pc (length is) xt ⌊a⌋; t = ⌊a⌋; s = ⌊b⌋⟧ ⟹ set (norm_eff (is ! pc) P pc b) {⊑⇘sup_state_opt P⇙} set (norm_eff (is ! pc) P pc a)› and 1 goal remains*) apply (rule exI (*‹?P ?x ⟹ ∃x. ?P x›*)) (*top goal: ‹⋀a b aa ba x. ⟦wf_prog p P; pc < length is; P ⊢ (aa, ba) ≤⇩i (a, b); app (is ! pc) P mxs T⇩r pc (length is) xt ⌊(a, b)⌋; t = ⌊(a, b)⌋; s = ⌊(aa, ba)⌋; x ∈ set (succs (is ! pc) (aa, ba) pc)⟧ ⟹ ∃τ'. (x, τ') ∈ (λpc'. (pc', ⌊eff⇩i (is ! pc, P, a, b)⌋)) ` set (succs (is ! pc) (a, b) pc) ∧ P ⊢ ⌊eff⇩i (is ! pc, P, aa, ba)⌋ ≤' τ'› and 1 goal remains*) apply (rule conjI2 (*‹⟦?A; ?A ⟹ ?B⟧ ⟹ ?A ∧ ?B›*)) (*goals: 1. ‹⋀(a::ty list) (b::ty err list) (aa::ty list) (ba::ty err list) x::nat. ⟦wf_prog (p::(char list × char list × (char list × ty) list × (char list × ty list × ty × nat × nat × instr list × (nat × nat × char list × nat × nat) list) list) list ⇒ char list ⇒ char list × ty list × ty × nat × nat × instr list × (nat × nat × char list × nat × nat) list ⇒ bool) (P::(char list × char list × (char list × ty) list × (char list × ty list × ty × nat × nat × instr list × (nat × nat × char list × nat × nat) list) list) list); (pc::nat) < length (is::instr list); P ⊢ (aa, ba) ≤⇩i (a, b); app (is ! pc) P (mxs::nat) (T⇩r::ty) pc (length is) (xt::(nat × nat × char list × nat × nat) list) ⌊(a, b)⌋; (t::(ty list × ty err list) option) = ⌊(a, b)⌋; (s::(ty list × ty err list) option) = ⌊(aa, ba)⌋; x ∈ set (succs (is ! pc) (aa, ba) pc)⟧ ⟹ (x, (?τ'12::ty list ⇒ ty err list ⇒ ty list ⇒ ty err list ⇒ nat ⇒ (ty list × ty err list) option) a b aa ba x) ∈ (λpc'::nat. (pc', ⌊eff⇩i (is ! pc, P, a, b)⌋)) ` set (succs (is ! pc) (a, b) pc)› 2. ‹⋀(a::ty list) (b::ty err list) (aa::ty list) (ba::ty err list) x::nat. ⟦wf_prog (p::(char list × char list × (char list × ty) list × (char list × ty list × ty × nat × nat × instr list × (nat × nat × char list × nat × nat) list) list) list ⇒ char list ⇒ char list × ty list × ty × nat × nat × instr list × (nat × nat × char list × nat × nat) list ⇒ bool) (P::(char list × char list × (char list × ty) list × (char list × ty list × ty × nat × nat × instr list × (nat × nat × char list × nat × nat) list) list) list); (pc::nat) < length (is::instr list); P ⊢ (aa, ba) ≤⇩i (a, b); app (is ! pc) P (mxs::nat) (T⇩r::ty) pc (length is) (xt::(nat × nat × char list × nat × nat) list) ⌊(a, b)⌋; (t::(ty list × ty err list) option) = ⌊(a, b)⌋; (s::(ty list × ty err list) option) = ⌊(aa, ba)⌋; x ∈ set (succs (is ! pc) (aa, ba) pc); (x, (?τ'12::ty list ⇒ ty err list ⇒ ty list ⇒ ty err list ⇒ nat ⇒ (ty list × ty err list) option) a b aa ba x) ∈ (λpc'::nat. (pc', ⌊eff⇩i (is ! pc, P, a, b)⌋)) ` set (succs (is ! pc) (a, b) pc)⟧ ⟹ P ⊢ ⌊eff⇩i (is ! pc, P, aa, ba)⌋ ≤' ?τ'12 a b aa ba x› discuss goal 1*) apply (rule imageI (*‹?x ∈ ?A ⟹ ?f ?x ∈ ?f ` ?A›*)) (*top goal: ‹⋀(a::ty list) (b::ty err list) (aa::ty list) (ba::ty err list) x::nat. ⟦wf_prog (p::(char list × char list × (char list × ty) list × (char list × ty list × ty × nat × nat × instr list × (nat × nat × char list × nat × nat) list) list) list ⇒ char list ⇒ char list × ty list × ty × nat × nat × instr list × (nat × nat × char list × nat × nat) list ⇒ bool) (P::(char list × char list × (char list × ty) list × (char list × ty list × ty × nat × nat × instr list × (nat × nat × char list × nat × nat) list) list) list); (pc::nat) < length (is::instr list); P ⊢ (aa, ba) ≤⇩i (a, b); app (is ! pc) P (mxs::nat) (T⇩r::ty) pc (length is) (xt::(nat × nat × char list × nat × nat) list) ⌊(a, b)⌋; (t::(ty list × ty err list) option) = ⌊(a, b)⌋; (s::(ty list × ty err list) option) = ⌊(aa, ba)⌋; x ∈ set (succs (is ! pc) (aa, ba) pc)⟧ ⟹ (x, (?τ'12::ty list ⇒ ty err list ⇒ ty list ⇒ ty err list ⇒ nat ⇒ (ty list × ty err list) option) a b aa ba x) ∈ (λpc'::nat. (pc', ⌊eff⇩i (is ! pc, P, a, b)⌋)) ` set (succs (is ! pc) (a, b) pc)› and 2 goals remain*) apply (clarsimp simp add: Effect.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))›*) iff del: sup_state_conv (*‹?P ⊢ (?ST, ?LT) ≤⇩i (?ST', ?LT') = (?P ⊢ ?ST [≤] ?ST' ∧ ?P ⊢ ?LT [≤⇩⊤] ?LT')›*)) (*top goal: ‹⋀(a::ty list) (b::ty err list) (aa::ty list) (ba::ty err list) x::nat. ⟦wf_prog (p::(char list × char list × (char list × ty) list × (char list × ty list × ty × nat × nat × instr list × (nat × nat × char list × nat × nat) list) list) list ⇒ char list ⇒ char list × ty list × ty × nat × nat × instr list × (nat × nat × char list × nat × nat) list ⇒ bool) (P::(char list × char list × (char list × ty) list × (char list × ty list × ty × nat × nat × instr list × (nat × nat × char list × nat × nat) list) list) list); (pc::nat) < length (is::instr list); P ⊢ (aa, ba) ≤⇩i (a, b); app (is ! pc) P (mxs::nat) (T⇩r::ty) pc (length is) (xt::(nat × nat × char list × nat × nat) list) ⌊(a, b)⌋; (t::(ty list × ty err list) option) = ⌊(a, b)⌋; (s::(ty list × ty err list) option) = ⌊(aa, ba)⌋; x ∈ set (succs (is ! pc) (aa, ba) pc)⟧ ⟹ x ∈ set (succs (is ! pc) (a, b) pc)› and 2 goals remain*) apply (drule (2) succs_mono (*‹⟦wf_prog ?p ?P; app⇩i (?i, ?P, ?mxs, ?mpc, ?rT, ?τ'); ?P ⊢ ?τ ≤⇩i ?τ'⟧ ⟹ set (succs ?i ?τ ?pc) ⊆ set (succs ?i ?τ' ?pc)›*)) (*top goal: ‹⋀a b aa ba x. ⟦wf_prog p P; pc < length is; P ⊢ (aa, ba) ≤⇩i (a, b); t = ⌊(a, b)⌋; s = ⌊(aa, ba)⌋; x ∈ set (succs (is ! pc) (aa, ba) pc); app⇩i (is ! pc, P, pc, mxs, T⇩r, a, b); xcpt_app (is ! pc) P pc mxs xt (a, b); ∀x∈set (eff (is ! pc) P pc xt ⌊(a, b)⌋). case x of (pc', τ') ⇒ pc' < length is⟧ ⟹ x ∈ set (succs (is ! pc) (a, b) pc)› and 2 goals remain*) apply blast (*discuss goal 2*) apply simp (*top goal: ‹⋀a b aa ba x. ⟦wf_prog p P; pc < length is; P ⊢ (aa, ba) ≤⇩i (a, b); app (is ! pc) P mxs T⇩r pc (length is) xt ⌊(a, b)⌋; t = ⌊(a, b)⌋; s = ⌊(aa, ba)⌋; x ∈ set (succs (is ! pc) (aa, ba) pc); (x, ⌊eff⇩i (is ! pc, P, a, b)⌋) ∈ (λpc'. (pc', ⌊eff⇩i (is ! pc, P, a, b)⌋)) ` set (succs (is ! pc) (a, b) pc)⟧ ⟹ P ⊢ ⌊eff⇩i (is ! pc, P, aa, ba)⌋ ≤' ⌊eff⇩i (is ! pc, P, a, b)⌋› and 1 goal remains*) apply (erule eff⇩i_mono (*‹⟦wf_prog ?p ?P; ?P ⊢ ?τ ≤⇩i ?τ'; app ?i ?P ?m ?rT ?pc ?mpc ?xt ⌊?τ'⌋; succs ?i ?τ ?pc ≠ []; succs ?i ?τ' ?pc ≠ []⟧ ⟹ ?P ⊢ eff⇩i (?i, ?P, ?τ) ≤⇩i eff⇩i (?i, ?P, ?τ')›*)) (*goals: 1. ‹⋀a b aa ba x. ⟦pc < length is; P ⊢ aa [≤] a ∧ P ⊢ ba [≤⇩⊤] b; app (is ! pc) P mxs T⇩r pc (length is) xt ⌊(a, b)⌋; t = ⌊(a, b)⌋; s = ⌊(aa, ba)⌋; x ∈ set (succs (is ! pc) (aa, ba) pc); (x, ⌊eff⇩i (is ! pc, P, a, b)⌋) ∈ (λpc'. (pc', ⌊eff⇩i (is ! pc, P, a, b)⌋)) ` set (succs (is ! pc) (a, b) pc)⟧ ⟹ P ⊢ (aa, ba) ≤⇩i (a, b)› 2. ‹⋀a b aa ba x. ⟦pc < length is; P ⊢ aa [≤] a ∧ P ⊢ ba [≤⇩⊤] b; app (is ! pc) P mxs T⇩r pc (length is) xt ⌊(a, b)⌋; t = ⌊(a, b)⌋; s = ⌊(aa, ba)⌋; x ∈ set (succs (is ! pc) (aa, ba) pc); (x, ⌊eff⇩i (is ! pc, P, a, b)⌋) ∈ (λpc'. (pc', ⌊eff⇩i (is ! pc, P, a, b)⌋)) ` set (succs (is ! pc) (a, b) pc)⟧ ⟹ app (is ! pc) P (?m74 a b aa ba x) (?rT74 a b aa ba x) (?pc74 a b aa ba x) (?mpc74 a b aa ba x) (?xt74 a b aa ba x) ⌊(a, b)⌋› 3. ‹⋀a b aa ba x. ⟦pc < length is; P ⊢ aa [≤] a ∧ P ⊢ ba [≤⇩⊤] b; app (is ! pc) P mxs T⇩r pc (length is) xt ⌊(a, b)⌋; t = ⌊(a, b)⌋; s = ⌊(aa, ba)⌋; x ∈ set (succs (is ! pc) (aa, ba) pc); (x, ⌊eff⇩i (is ! pc, P, a, b)⌋) ∈ (λpc'. (pc', ⌊eff⇩i (is ! pc, P, a, b)⌋)) ` set (succs (is ! pc) (a, b) pc)⟧ ⟹ succs (is ! pc) (aa, ba) (?pc74 a b aa ba x) ≠ []› 4. ‹⋀a b aa ba x. ⟦pc < length is; P ⊢ aa [≤] a ∧ P ⊢ ba [≤⇩⊤] b; app (is ! pc) P mxs T⇩r pc (length is) xt ⌊(a, b)⌋; t = ⌊(a, b)⌋; s = ⌊(aa, ba)⌋; x ∈ set (succs (is ! pc) (aa, ba) pc); (x, ⌊eff⇩i (is ! pc, P, a, b)⌋) ∈ (λpc'. (pc', ⌊eff⇩i (is ! pc, P, a, b)⌋)) ` set (succs (is ! pc) (a, b) pc)⟧ ⟹ succs (is ! pc) (a, b) (?pc74 a b aa ba x) ≠ []› discuss goal 1*) apply simp (*discuss goal 2*) apply assumption (*discuss goal 3*) apply clarsimp (*discuss goal 4*) apply clarsimp (*proven 4 subgoals*) (*proven 2 subgoals*) (*discuss goal 2*) apply (rule lesubstep_type_simple (*‹?xs [⊑⇘Product.le (=) ?r⇙] ?ys ⟹ set ?xs {⊑⇘?r⇙} set ?ys›*)) (*goal: ‹⋀a b. ⟦wf_prog p P; pc < length is; ⌊b⌋ ⊑⇘sup_state_opt P⇙ ⌊a⌋; app (is ! pc) P mxs T⇩r pc (length is) xt ⌊a⌋; t = ⌊a⌋; s = ⌊b⌋⟧ ⟹ set (xcpt_eff (is ! pc) P pc b xt) {⊑⇘sup_state_opt P⇙} set (xcpt_eff (is ! pc) P pc a xt)›*) apply (simp add: xcpt_eff_def (*‹xcpt_eff (?i::instr) (?P::(char list × char list × (char list × ty) list × (char list × ty list × ty × ?'m::type) list) list) (?pc::nat) (?τ::ty list × ty err list) (?et::(nat × nat × char list × nat × nat) list) = (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))›*)) (*goal: ‹⋀a b. ⟦wf_prog p P; pc < length is; ⌊b⌋ ⊑⇘sup_state_opt P⇙ ⌊a⌋; app (is ! pc) P mxs T⇩r pc (length is) xt ⌊a⌋; t = ⌊a⌋; s = ⌊b⌋⟧ ⟹ xcpt_eff (is ! pc) P pc b xt [⊑⇘Product.le (=) (sup_state_opt P)⇙] xcpt_eff (is ! pc) P pc a xt›*) apply (rule le_listI (*‹⟦length ?a = length ?b; ⋀n. n < length ?a ⟹ ?a ! n ⊑⇘?r⇙ ?b ! n⟧ ⟹ ?a [⊑⇘?r⇙] ?b›*)) (*goals: 1. ‹⋀(a::ty list × ty err list) b::ty list × ty err list. ⟦wf_prog (p::(char list × char list × (char list × ty) list × (char list × ty list × ty × nat × nat × instr list × (nat × nat × char list × nat × nat) list) list) list ⇒ char list ⇒ char list × ty list × ty × nat × nat × instr list × (nat × nat × char list × nat × nat) list ⇒ bool) (P::(char list × char list × (char list × ty) list × (char list × ty list × ty × nat × nat × instr list × (nat × nat × char list × nat × nat) list) list) list); (pc::nat) < length (is::instr list); ⌊b⌋ ⊑⇘sup_state_opt P⇙ ⌊a⌋; app (is ! pc) P (mxs::nat) (T⇩r::ty) pc (length is) (xt::(nat × nat × char list × nat × nat) list) ⌊a⌋; (t::(ty list × ty err list) option) = ⌊a⌋; (s::(ty list × ty err list) option) = ⌊b⌋⟧ ⟹ length (case b of (ST::ty list, LT::ty err list) ⇒ map (λ(f::nat, t::nat, C::char list, h::nat, d::nat). (h, ⌊(Class C # drop (length ST - d) ST, LT)⌋)) (relevant_entries P (is ! pc) pc xt)) = length (case a of (ST::ty list, LT::ty err list) ⇒ map (λ(f::nat, t::nat, C::char list, h::nat, d::nat). (h, ⌊(Class C # drop (length ST - d) ST, LT)⌋)) (relevant_entries P (is ! pc) pc xt))› 2. ‹⋀(a::ty list × ty err list) (b::ty list × ty err list) n::nat. ⟦wf_prog (p::(char list × char list × (char list × ty) list × (char list × ty list × ty × nat × nat × instr list × (nat × nat × char list × nat × nat) list) list) list ⇒ char list ⇒ char list × ty list × ty × nat × nat × instr list × (nat × nat × char list × nat × nat) list ⇒ bool) (P::(char list × char list × (char list × ty) list × (char list × ty list × ty × nat × nat × instr list × (nat × nat × char list × nat × nat) list) list) list); (pc::nat) < length (is::instr list); ⌊b⌋ ⊑⇘sup_state_opt P⇙ ⌊a⌋; app (is ! pc) P (mxs::nat) (T⇩r::ty) pc (length is) (xt::(nat × nat × char list × nat × nat) list) ⌊a⌋; (t::(ty list × ty err list) option) = ⌊a⌋; (s::(ty list × ty err list) option) = ⌊b⌋; n < length (case b of (ST::ty list, LT::ty err list) ⇒ map (λ(f::nat, t::nat, C::char list, h::nat, d::nat). (h, ⌊(Class C # drop (length ST - d) ST, LT)⌋)) (relevant_entries P (is ! pc) pc xt))⟧ ⟹ (case b of (ST::ty list, LT::ty err list) ⇒ map (λ(f::nat, t::nat, C::char list, h::nat, d::nat). (h, ⌊(Class C # drop (length ST - d) ST, LT)⌋)) (relevant_entries P (is ! pc) pc xt)) ! n <=((=),sup_state_opt P) (case a of (ST::ty list, LT::ty err list) ⇒ map (λ(f::nat, t::nat, C::char list, h::nat, d::nat). (h, ⌊(Class C # drop (length ST - d) ST, LT)⌋)) (relevant_entries P (is ! pc) pc xt)) ! n› 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)›*)) (*goal: ‹⋀a b n. ⟦wf_prog p P; pc < length is; ⌊b⌋ ⊑⇘sup_state_opt P⇙ ⌊a⌋; app (is ! pc) P mxs T⇩r pc (length is) xt ⌊a⌋; t = ⌊a⌋; s = ⌊b⌋; n < length (case b of (ST, LT) ⇒ map (λ(f, t, C, h, d). (h, ⌊(Class C # drop (length ST - d) ST, LT)⌋)) (relevant_entries P (is ! pc) pc xt))⟧ ⟹ (case b of (ST, LT) ⇒ map (λ(f, t, C, h, d). (h, ⌊(Class C # drop (length ST - d) ST, LT)⌋)) (relevant_entries P (is ! pc) pc xt)) ! n <=((=),sup_state_opt P) (case a of (ST, LT) ⇒ map (λ(f, t, C, h, d). (h, ⌊(Class C # drop (length ST - d) ST, LT)⌋)) (relevant_entries P (is ! pc) pc xt)) ! n›*) apply (simp add: lesub_def (*‹(?x ⊑⇘?r⇙ ?y) = ?r ?x ?y›*) fun_of_def (*‹fun_of ?S ≡ λx y. (x, y) ∈ ?S›*)) (*goal: ‹⋀a b n. ⟦wf_prog p P; pc < length is; ⌊b⌋ ⊑⇘sup_state_opt P⇙ ⌊a⌋; app (is ! pc) P mxs T⇩r pc (length is) xt ⌊a⌋; t = ⌊a⌋; s = ⌊b⌋; n < length (relevant_entries P (is ! pc) pc xt)⟧ ⟹ fst (snd (snd (snd (relevant_entries P (is ! pc) pc xt ! n)))) ⊑⇘(=)⇙ fst (snd (snd (snd (relevant_entries P (is ! pc) pc xt ! n)))) ∧ ⌊(Class (fst (snd (snd (relevant_entries P (is ! pc) pc xt ! n)))) # drop (length (fst b) - snd (snd (snd (snd (relevant_entries P (is ! pc) pc xt ! n))))) (fst b), snd b)⌋ ⊑⇘sup_state_opt P⇙ ⌊(Class (fst (snd (snd (relevant_entries P (is ! pc) pc xt ! n)))) # drop (length (fst a) - snd (snd (snd (snd (relevant_entries P (is ! pc) pc xt ! n))))) (fst a), snd a)⌋›*) apply (case_tac a) (*goal: ‹⋀a b n. ⟦wf_prog p P; pc < length is; P ⊢ b ≤⇩i a; app (is ! pc) P mxs T⇩r pc (length is) xt ⌊a⌋; t = ⌊a⌋; s = ⌊b⌋; n < length (relevant_entries P (is ! pc) pc xt)⟧ ⟹ P ⊢ drop (length (fst b) - snd (snd (snd (snd (relevant_entries P (is ! pc) pc xt ! n))))) (fst b) [≤] drop (length (fst a) - snd (snd (snd (snd (relevant_entries P (is ! pc) pc xt ! n))))) (fst a) ∧ P ⊢ snd b [≤⇩⊤] snd a›*) apply (case_tac b) (*goal: ‹⋀(a::ty list × ty err list) (b::ty list × ty err list) (n::nat) (aa::ty list) ba::ty err list. ⟦wf_prog (p::(char list × char list × (char list × ty) list × (char list × ty list × ty × nat × nat × instr list × (nat × nat × char list × nat × nat) list) list) list ⇒ char list ⇒ char list × ty list × ty × nat × nat × instr list × (nat × nat × char list × nat × nat) list ⇒ bool) (P::(char list × char list × (char list × ty) list × (char list × ty list × ty × nat × nat × instr list × (nat × nat × char list × nat × nat) list) list) list); (pc::nat) < length (is::instr list); P ⊢ b ≤⇩i a; app (is ! pc) P (mxs::nat) (T⇩r::ty) pc (length is) (xt::(nat × nat × char list × nat × nat) list) ⌊a⌋; (t::(ty list × ty err list) option) = ⌊a⌋; (s::(ty list × ty err list) option) = ⌊b⌋; n < length (relevant_entries P (is ! pc) pc xt); a = (aa, ba)⟧ ⟹ P ⊢ drop (length (fst b) - snd (snd (snd (snd (relevant_entries P (is ! pc) pc xt ! n))))) (fst b) [≤] drop (length (fst a) - snd (snd (snd (snd (relevant_entries P (is ! pc) pc xt ! n))))) (fst a) ∧ P ⊢ snd b [≤⇩⊤] snd a›*) apply simp (*goal: ‹⋀a b n aa ba ab bb. ⟦wf_prog p P; pc < length is; P ⊢ b ≤⇩i a; app (is ! pc) P mxs T⇩r pc (length is) xt ⌊a⌋; t = ⌊a⌋; s = ⌊b⌋; n < length (relevant_entries P (is ! pc) pc xt); a = (aa, ba); b = (ab, bb)⟧ ⟹ P ⊢ drop (length (fst b) - snd (snd (snd (snd (relevant_entries P (is ! pc) pc xt ! n))))) (fst b) [≤] drop (length (fst a) - snd (snd (snd (snd (relevant_entries P (is ! pc) pc xt ! n))))) (fst a) ∧ P ⊢ snd b [≤⇩⊤] snd a›*) apply (subgoal_tac "size ab = size aa") (*goals: 1. ‹⋀a b n aa ba ab bb. ⟦wf_prog p P; pc < length is; P ⊢ ab [≤] aa ∧ P ⊢ bb [≤⇩⊤] ba; app (is ! pc) P mxs T⇩r pc (length is) xt ⌊(aa, ba)⌋; t = ⌊(aa, ba)⌋; s = ⌊(ab, bb)⌋; n < length (relevant_entries P (is ! pc) pc xt); a = (aa, ba); b = (ab, bb); length ab = length aa⟧ ⟹ P ⊢ drop (length ab - snd (snd (snd (snd (relevant_entries P (is ! pc) pc xt ! n))))) ab [≤] drop (length aa - snd (snd (snd (snd (relevant_entries P (is ! pc) pc xt ! n))))) aa› 2. ‹⋀a b n aa ba ab bb. ⟦wf_prog p P; pc < length is; P ⊢ ab [≤] aa ∧ P ⊢ bb [≤⇩⊤] ba; app (is ! pc) P mxs T⇩r pc (length is) xt ⌊(aa, ba)⌋; t = ⌊(aa, ba)⌋; s = ⌊(ab, bb)⌋; n < length (relevant_entries P (is ! pc) pc xt); a = (aa, ba); b = (ab, bb)⟧ ⟹ length ab = length aa› discuss goal 1*) apply simp (*discuss goal 2*) apply (clarsimp simp add: list_all2_lengthD (*‹list_all2 ?P ?xs ?ys ⟹ length ?xs = length ?ys›*)) (*proven 2 subgoals*) (*proven 2 subgoals*) (*proven 2 subgoals*) (*proven 2 subgoals*) (*proven 2 subgoals*) . (*>*) lemma (in JVM_sl) bounded_step: "bounded step (size is)" (*<*) apply simp (*goal: ‹bounded step (length is)›*) apply (unfold bounded_def (*‹bounded ?step ?n = (∀p<?n. ∀τ. ∀(q, τ')∈set (?step p τ). q < ?n)›*) err_step_def (*‹err_step ?n ?app ?step ?p ?t = (case ?t of Err ⇒ error ?n | OK τ ⇒ if ?app ?p τ then map_snd OK (?step ?p τ) else error ?n)›*) Effect.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))›*) Effect.eff_def (*‹eff ?i ?P ?pc ?et ?t = (case ?t of None ⇒ [] | ⌊τ⌋ ⇒ norm_eff ?i ?P ?pc τ @ xcpt_eff ?i ?P ?pc τ ?et)›*)) (*goal: ‹bounded (err_step (length is) (λpc. app (is ! pc) P mxs T⇩r pc (length is) xt) (λpc. eff (is ! pc) P pc xt)) (length is)›*) by (auto simp add: error_def (*‹error (?n::nat) = map (λx::nat. (x, Err)) [0::nat..<?n]›*) map_snd_def (*‹map_snd (?f::?'b ⇒ ?'c) = map (λ(x::?'a, y::?'b). (x, ?f y))›*) split: err.splits (*‹(?P::?'b ⇒ bool) (case ?err::?'a err of Err ⇒ ?f1.0::?'b | OK (x::?'a) ⇒ (?f2.0::?'a ⇒ ?'b) x) = ((?err = Err ⟶ ?P ?f1.0) ∧ (∀x2::?'a. ?err = OK x2 ⟶ ?P (?f2.0 x2)))› ‹(?P::?'b ⇒ bool) (case ?err::?'a err of Err ⇒ ?f1.0::?'b | OK (x::?'a) ⇒ (?f2.0::?'a ⇒ ?'b) x) = (¬ (?err = Err ∧ ¬ ?P ?f1.0 ∨ (∃x2::?'a. ?err = OK x2 ∧ ¬ ?P (?f2.0 x2))))›*) option.splits (*‹(?P::?'b ⇒ bool) (case ?option::?'a option of None ⇒ ?f1.0::?'b | ⌊x::?'a⌋ ⇒ (?f2.0::?'a ⇒ ?'b) x) = ((?option = None ⟶ ?P ?f1.0) ∧ (∀x2::?'a. ?option = ⌊x2⌋ ⟶ ?P (?f2.0 x2)))› ‹(?P::?'b ⇒ bool) (case ?option::?'a option of None ⇒ ?f1.0::?'b | ⌊x::?'a⌋ ⇒ (?f2.0::?'a ⇒ ?'b) x) = (¬ (?option = None ∧ ¬ ?P ?f1.0 ∨ (∃x2::?'a. ?option = ⌊x2⌋ ∧ ¬ ?P (?f2.0 x2))))›*)) (*>*) theorem (in JVM_sl) step_mono: "wf_prog wf_mb P ⟹ mono r step (size is) A" (*<*) apply (simp add: JVM_le_Err_conv (*‹JVM_SemiType.le (?P::(char list × char list × (char list × ty) list × (char list × ty list × ty × ?'a) list) list) (?m::nat) (?n::nat) = Err.le (sup_state_opt ?P)›*)) (*goal: ‹wf_prog wf_mb P ⟹ SemilatAlg.mono r step (length is) A›*) apply (insert bounded_step (*‹bounded step (length is)›*)) (*goal: ‹wf_prog (wf_mb::(char list × char list × (char list × ty) list × (char list × ty list × ty × nat × nat × instr list × (nat × nat × char list × nat × nat) list) list) list ⇒ char list ⇒ char list × ty list × ty × nat × nat × instr list × (nat × nat × char list × nat × nat) list ⇒ bool) (P::(char list × char list × (char list × ty) list × (char list × ty list × ty × nat × nat × instr list × (nat × nat × char list × nat × nat) list) list) list) ⟹ SemilatAlg.mono (Err.le (sup_state_opt P)) (err_step (length (is::instr list)) (λpc::nat. app (is ! pc) P (mxs::nat) (T⇩r::ty) pc (length is) (xt::(nat × nat × char list × nat × nat) list)) (λpc::nat. eff (is ! pc) P pc xt)) (length is) (states P mxs (Suc (length (Ts::ty list) + (mxl₀::nat))))›*) apply (unfold JVM_states_unfold (*‹states ?P ?mxs ?mxl ≡ err (opt (⋃ {nlists n (types ?P) |n. n ≤ ?mxs} × nlists ?mxl (err (types ?P))))›*)) (*goal: ‹⟦wf_prog wf_mb P; bounded step (length is)⟧ ⟹ SemilatAlg.mono (Err.le (sup_state_opt P)) (err_step (length is) (λpc. app (is ! pc) P mxs T⇩r pc (length is) xt) (λpc. eff (is ! pc) P pc xt)) (length is) (states P mxs (Suc (length Ts + mxl₀)))›*) apply (rule mono_lift (*‹⟦order ?r ?A; app_mono ?r ?app ?n ?A; bounded (err_step ?n ?app ?step) ?n; ∀s p t. s ∈ ?A ∧ p < ?n ∧ s ⊑⇘?r⇙ t ⟶ ?app p t ⟶ set (?step p s) {⊑⇘?r⇙} set (?step p t)⟧ ⟹ SemilatAlg.mono (Err.le ?r) (err_step ?n ?app ?step) ?n (err ?A)›*)) (*goals: 1. ‹⟦wf_prog wf_mb P; bounded step (length is)⟧ ⟹ order (sup_state_opt P) (opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists (Suc (length Ts + mxl₀)) (err (types P))))› 2. ‹⟦wf_prog wf_mb P; bounded step (length is)⟧ ⟹ app_mono (sup_state_opt P) (λpc. app (is ! pc) P mxs T⇩r pc (length is) xt) (length is) (opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists (Suc (length Ts + mxl₀)) (err (types P))))› 3. ‹⟦wf_prog wf_mb P; bounded step (length is)⟧ ⟹ bounded (err_step (length is) (λpc. app (is ! pc) P mxs T⇩r pc (length is) xt) (λpc. eff (is ! pc) P pc xt)) (length is)› 4. ‹⟦wf_prog wf_mb P; bounded step (length is)⟧ ⟹ ∀s p t. s ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists (Suc (length Ts + mxl₀)) (err (types P))) ∧ p < length is ∧ s ⊑⇘sup_state_opt P⇙ t ⟶ app (is ! p) P mxs T⇩r p (length is) xt t ⟶ set (eff (is ! p) P p xt s) {⊑⇘sup_state_opt P⇙} set (eff (is ! p) P p xt t)› discuss goal 1*) apply blast (*discuss goal 2*) apply ((unfold app_mono_def (*‹app_mono (?r::?'s ⇒ ?'s ⇒ bool) (?app::nat ⇒ ?'s ⇒ bool) (?n::nat) (?A::?'s set) = (∀(s::?'s) (p::nat) t::?'s. s ∈ ?A ∧ p < ?n ∧ s ⊑⇘?r⇙ t ⟶ ?app p t ⟶ ?app p s)›*) lesub_def (*‹((?x::?'a) ⊑⇘?r::?'a ⇒ ?'a ⇒ bool⇙ (?y::?'a)) = ?r ?x ?y›*))[1]) (*top goal: ‹⟦wf_prog wf_mb P; bounded step (length is)⟧ ⟹ app_mono (sup_state_opt P) (λpc. app (is ! pc) P mxs T⇩r pc (length is) xt) (length is) (opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists (Suc (length Ts + mxl₀)) (err (types P))))› and 2 goals remain*) apply clarsimp (*top goal: ‹⟦wf_prog wf_mb P; bounded step (length is)⟧ ⟹ ∀s p t. s ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists (Suc (length Ts + mxl₀)) (err (types P))) ∧ p < length is ∧ P ⊢ s ≤' t ⟶ app (is ! p) P mxs T⇩r p (length is) xt t ⟶ app (is ! p) P mxs T⇩r p (length is) xt s› and 2 goals remain*) apply (erule (2) app_mono (*‹⟦wf_prog ?p ?P; ?P ⊢ ?τ ≤' ?τ'; app ?i ?P ?m ?rT ?pc ?mpc ?xt ?τ'⟧ ⟹ app ?i ?P ?m ?rT ?pc ?mpc ?xt ?τ›*)) (*discuss goal 3*) apply simp (*discuss goal 4*) apply ((unfold app_mono_def (*‹app_mono ?r ?app ?n ?A = (∀s p t. s ∈ ?A ∧ p < ?n ∧ s ⊑⇘?r⇙ t ⟶ ?app p t ⟶ ?app p s)›*) lesub_def (*‹(?x ⊑⇘?r⇙ ?y) = ?r ?x ?y›*))[1]) (*goal: ‹⟦wf_prog wf_mb P; bounded step (length is)⟧ ⟹ ∀s p t. s ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists (Suc (length Ts + mxl₀)) (err (types P))) ∧ p < length is ∧ s ⊑⇘sup_state_opt P⇙ t ⟶ app (is ! p) P mxs T⇩r p (length is) xt t ⟶ set (eff (is ! p) P p xt s) {⊑⇘sup_state_opt P⇙} set (eff (is ! p) P p xt t)›*) apply clarify (*goal: ‹⟦wf_prog wf_mb P; bounded step (length is)⟧ ⟹ ∀s p t. s ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists (Suc (length Ts + mxl₀)) (err (types P))) ∧ p < length is ∧ P ⊢ s ≤' t ⟶ app (is ! p) P mxs T⇩r p (length is) xt t ⟶ set (eff (is ! p) P p xt s) {⊑⇘sup_state_opt P⇙} set (eff (is ! p) P p xt t)›*) apply (drule eff_mono (*‹⟦wf_prog (?p::(char list × char list × (char list × ty) list × (char list × ty list × ty × nat × nat × instr list × (nat × nat × char list × nat × nat) list) list) list ⇒ char list ⇒ char list × ty list × ty × nat × nat × instr list × (nat × nat × char list × nat × nat) list ⇒ bool) (P::(char list × char list × (char list × ty) list × (char list × ty list × ty × nat × nat × instr list × (nat × nat × char list × nat × nat) list) list) list); (?pc::nat) < length (is::instr list); (?s::(ty list × ty err list) option) ⊑⇘sup_state_opt P⇙ (?t::(ty list × ty err list) option); (app::nat ⇒ (ty list × ty err list) option ⇒ bool) ?pc ?t⟧ ⟹ set ((eff::nat ⇒ (ty list × ty err list) option ⇒ (nat × (ty list × ty err list) option) list) ?pc ?s) {⊑⇘sup_state_opt P⇙} set (eff ?pc ?t)›*)) (*goals: 1. ‹⋀s p t. ⟦bounded step (length is); s ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists (Suc (length Ts + mxl₀)) (err (types P))); p < length is; P ⊢ s ≤' t; app (is ! p) P mxs T⇩r p (length is) xt t⟧ ⟹ ?pc36 s p t < length is› 2. ‹⋀s p t. ⟦bounded step (length is); s ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists (Suc (length Ts + mxl₀)) (err (types P))); p < length is; P ⊢ s ≤' t; app (is ! p) P mxs T⇩r p (length is) xt t⟧ ⟹ ?s36 s p t ⊑⇘sup_state_opt P⇙ ?t36 s p t› 3. ‹⋀s p t. ⟦bounded step (length is); s ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists (Suc (length Ts + mxl₀)) (err (types P))); p < length is; P ⊢ s ≤' t; app (is ! p) P mxs T⇩r p (length is) xt t⟧ ⟹ app (?pc36 s p t) (?t36 s p t)› 4. ‹⋀s p t. ⟦bounded step (length is); s ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists (Suc (length Ts + mxl₀)) (err (types P))); p < length is; P ⊢ s ≤' t; app (is ! p) P mxs T⇩r p (length is) xt t; set (eff (?pc36 s p t) (?s36 s p t)) {⊑⇘sup_state_opt P⇙} set (eff (?pc36 s p t) (?t36 s p t))⟧ ⟹ set (eff (is ! p) P p xt s) {⊑⇘sup_state_opt P⇙} set (eff (is ! p) P p xt t)› discuss goal 1*) apply ((auto simp add: lesub_def (*‹((?x::?'a) ⊑⇘?r::?'a ⇒ ?'a ⇒ bool⇙ (?y::?'a)) = ?r ?x ?y›*))[1]) (*discuss goal 2*) apply ((auto simp add: lesub_def (*‹((?x::?'a::type) ⊑⇘?r::?'a::type ⇒ ?'a::type ⇒ bool⇙ (?y::?'a::type)) = ?r ?x ?y›*))[1]) (*discuss goal 3*) apply ((auto simp add: lesub_def (*‹((?x::?'a) ⊑⇘?r::?'a ⇒ ?'a ⇒ bool⇙ (?y::?'a)) = ?r ?x ?y›*))[1]) (*discuss goal 4*) apply ((auto simp add: lesub_def (*‹(?x ⊑⇘?r⇙ ?y) = ?r ?x ?y›*))[1]) (*proven 4 subgoals*) (*proven 4 subgoals*) . (*>*) lemma (in start_context) first_in_A [iff]: "OK first ∈ A" using Ts (*‹set Ts ⊆ types P›*) C (*‹is_class P C›*) by (force intro!: nlists_appendI (*‹⟦(?a::?'a list) ∈ nlists (?n::nat) (?A::?'a set); (?b::?'a list) ∈ nlists (?m::nat) ?A⟧ ⟹ ?a @ ?b ∈ nlists (?n + ?m) ?A›*) simp add: JVM_states_unfold (*‹states (?P::(char list × char list × (char list × ty) list × (char list × ty list × ty × ?'a) list) list) (?mxs::nat) (?mxl::nat) ≡ err (opt (⋃ {nlists n (types ?P) |n::nat. n ≤ ?mxs} × nlists ?mxl (err (types ?P))))›*)) lemma (in JVM_sl) wt_method_def2: "wt_method P C' Ts T⇩r mxs mxl₀ is xt τs = (is ≠ [] ∧ size τs = size is ∧ OK ` set τs ⊆ states P mxs mxl ∧ wt_start P C' Ts mxl₀ τs ∧ wt_app_eff (sup_state_opt P) app eff τs)" (*<*) apply (unfold wt_method_def (*‹wt_method ?P ?C ?Ts ?T⇩r ?mxs ?mxl₀ ?is ?xt ?τs ≡ 0 < length ?is ∧ length ?τs = length ?is ∧ check_types ?P ?mxs (1 + length ?Ts + ?mxl₀) (map OK ?τs) ∧ wt_start ?P ?C ?Ts ?mxl₀ ?τs ∧ (∀pc<length ?is. ?P,?T⇩r,?mxs,length ?is,?xt ⊢ ?is ! pc,pc :: ?τs)›*) wt_app_eff_def (*‹wt_app_eff ?r ?app ?step ?τs = (∀p<length ?τs. ?app p (?τs ! p) ∧ (∀(q, τ)∈set (?step p (?τs ! p)). τ ⊑⇘?r⇙ ?τs ! q))›*) 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')›*) lesub_def (*‹(?x ⊑⇘?r⇙ ?y) = ?r ?x ?y›*) check_types_def (*‹check_types ?P ?mxs ?mxl ?τs ≡ set ?τs ⊆ states ?P ?mxs ?mxl›*)) (*goal: ‹wt_method P C' Ts T⇩r mxs mxl₀ is xt τs = (is ≠ [] ∧ length τs = length is ∧ OK ` set τs ⊆ states P mxs mxl ∧ wt_start P C' Ts mxl₀ τs ∧ wt_app_eff (sup_state_opt P) app eff τs)›*) by auto (*>*) end
{ "path": "afp-2025-02-12/thys/Jinja/BV/TF_JVM.thy", "repo": "afp-2025-02-12", "sha": "08d4a9be37e2cab44f2a940acf335b98f2cb0dd62e0001fe929fd19a064661a7" }
(* Title: Safe OCL Author: Denis Nikiforov, March 2019 Maintainer: Denis Nikiforov <denis.nikif at gmail.com> License: LGPL *) (* TODO: There are a lot of similar lemmas in the theory. They should be generalized *) section ‹Tuples› theory Tuple imports Finite_Map_Ext Transitive_Closure_Ext begin subsection ‹Definitions› abbreviation "subtuple f xm ym ≡ fmrel_on_fset (fmdom ym) f xm ym" abbreviation "strict_subtuple f xm ym ≡ subtuple f xm ym ∧ xm ≠ ym" (*** Helper Lemmas **********************************************************) subsection ‹Helper Lemmas› lemma fmrel_to_subtuple: "fmrel r xm ym ⟹ subtuple r xm ym" unfolding fmrel_on_fset_fmrel_restrict (*goal: ‹fmrel r xm ym ⟹ fmrel r (fmrestrict_fset (fmdom ym) xm) (fmrestrict_fset (fmdom ym) ym)›*) by blast lemma subtuple_eq_fmrel_fmrestrict_fset: "subtuple r xm ym = fmrel r (fmrestrict_fset (fmdom ym) xm) ym" by (simp add: fmrel_on_fset_fmrel_restrict (*‹fmrel_on_fset ?S ?P ?m ?n = fmrel ?P (fmrestrict_fset ?S ?m) (fmrestrict_fset ?S ?n)›*)) lemma subtuple_fmdom: "subtuple f xm ym ⟹ subtuple g ym xm ⟹ fmdom xm = fmdom ym" by (meson fmrel_on_fset_fmdom (*‹⟦subtuple ?f ?xm ?ym; ?k |∈| fmdom ?ym⟧ ⟹ ?k |∈| fmdom ?xm›*) fset_eqI (*‹(⋀x. (x |∈| ?A) = (x |∈| ?B)) ⟹ ?A = ?B›*)) (*** Basic Properties *******************************************************) subsection ‹Basic Properties› lemma subtuple_refl: "reflp R ⟹ subtuple R xm xm" by (simp add: fmrel_on_fsetI (*‹(⋀x. x |∈| ?S ⟹ rel_option ?P (fmlookup ?m x) (fmlookup ?n x)) ⟹ fmrel_on_fset ?S ?P ?m ?n›*) option.rel_reflp (*‹reflp ?R ⟹ reflp (rel_option ?R)›*) reflpD (*‹reflp ?R ⟹ ?R ?x ?x›*)) lemma subtuple_mono [mono]: "(⋀x y. x ∈ fmran' xm ⟹ y ∈ fmran' ym ⟹ f x y ⟶ g x y) ⟹ subtuple f xm ym ⟶ subtuple g xm ym" apply auto (*goal: ‹(⋀x y. ⟦x ∈ fmran' xm; y ∈ fmran' ym⟧ ⟹ f x y ⟶ g x y) ⟹ subtuple f xm ym ⟶ subtuple g xm ym›*) apply (rule fmrel_on_fsetI (*‹(⋀x. x |∈| ?S ⟹ rel_option ?P (fmlookup ?m x) (fmlookup ?n x)) ⟹ fmrel_on_fset ?S ?P ?m ?n›*)) (*goal: ‹⟦⋀x y. ⟦x ∈ fmran' xm; y ∈ fmran' ym⟧ ⟹ f x y ⟶ g x y; subtuple f xm ym⟧ ⟹ subtuple g xm ym›*) apply (drule_tac ?P="f" and ?m="xm" and ?n="ym" in fmrel_on_fsetD (*‹⟦?x |∈| ?S; fmrel_on_fset ?S ?P ?m ?n⟧ ⟹ rel_option ?P (fmlookup ?m ?x) (fmlookup ?n ?x)›*)) (*goals: 1. ‹⋀x. ⟦⋀x y. ⟦x ∈ fmran' xm; y ∈ fmran' ym⟧ ⟹ f x y ⟶ g x y; subtuple f xm ym⟧ ⟹ subtuple f xm ym› 2. ‹⋀x. ⟦⋀x y. ⟦x ∈ fmran' xm; y ∈ fmran' ym⟧ ⟹ f x y ⟶ g x y; subtuple f xm ym; rel_option f (fmlookup xm x) (fmlookup ym x)⟧ ⟹ rel_option g (fmlookup xm x) (fmlookup ym x)› discuss goal 1*) apply simp (*discuss goal 2*) apply (erule 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. ⟦⋀x y. ⟦x ∈ fmran' xm; y ∈ fmran' ym⟧ ⟹ f x y ⟶ g x y; subtuple f xm ym; fmlookup xm x = None; fmlookup ym x = None⟧ ⟹ rel_option g (fmlookup xm x) (fmlookup ym x)› 2. ‹⋀x xa y. ⟦⋀x y. ⟦x ∈ fmran' xm; y ∈ fmran' ym⟧ ⟹ f x y ⟶ g x y; subtuple f xm ym; fmlookup xm x = Some xa; fmlookup ym x = Some y; f xa y⟧ ⟹ rel_option g (fmlookup xm x) (fmlookup ym x)› discuss goal 1*) apply simp (*discuss goal 2*) apply (auto simp add: option.rel_sel (*‹rel_option ?R ?a ?b = ((?a = None) = (?b = None) ∧ (?a ≠ None ⟶ ?b ≠ None ⟶ ?R (the ?a) (the ?b)))›*) fmran'I (*‹fmlookup ?m ?x = Some ?y ⟹ ?y ∈ fmran' ?m›*)) (*proven 2 subgoals*) (*proven 2 subgoals*) . lemma strict_subtuple_mono [mono]: "(⋀x y. x ∈ fmran' xm ⟹ y ∈ fmran' ym ⟹ f x y ⟶ g x y) ⟹ strict_subtuple f xm ym ⟶ strict_subtuple g xm ym" using subtuple_mono (*‹(⋀x y. ⟦x ∈ fmran' ?xm; y ∈ fmran' ?ym⟧ ⟹ ?f x y ⟶ ?g x y) ⟹ subtuple ?f ?xm ?ym ⟶ subtuple ?g ?xm ?ym›*) by blast lemma subtuple_antisym: assumes "subtuple (λx y. f x y ∨ x = y) xm ym" assumes "subtuple (λx y. f x y ∧ ¬ f y x ∨ x = y) ym xm" shows "xm = ym" proof (rule fmap_ext (*‹(⋀x. fmlookup ?m x = fmlookup ?n x) ⟹ ?m = ?n›*)) (*goal: ‹⋀x. fmlookup xm x = fmlookup ym x›*) fix x from assms (*‹subtuple (λx y. f x y ∨ x = y) xm ym› ‹subtuple (λ(x::'b) y::'b. (f::'b ⇒ 'b ⇒ bool) x y ∧ ¬ f y x ∨ x = y) (ym::'a ⇀⇩f 'b) (xm::'a ⇀⇩f 'b)›*) have "fmdom xm = fmdom ym" using subtuple_fmdom (*‹⟦subtuple ?f ?xm ?ym; subtuple ?g ?ym ?xm⟧ ⟹ fmdom ?xm = fmdom ?ym›*) by blast with assms (*‹subtuple (λx y. f x y ∨ x = y) xm ym› ‹subtuple (λx y. f x y ∧ ¬ f y x ∨ x = y) ym xm›*) have "fmrel (λx y. f x y ∨ x = y) xm ym" and "fmrel (λx y. f x y ∧ ¬ f y x ∨ x = y) ym xm" apply - (*goals: 1. ‹⟦subtuple (λx y. f x y ∨ x = y) xm ym; subtuple (λx y. f x y ∧ ¬ f y x ∨ x = y) ym xm; fmdom xm = fmdom ym⟧ ⟹ fmrel (λx y. f x y ∨ x = y) xm ym› 2. ‹⟦subtuple (λx y. f x y ∨ x = y) xm ym; subtuple (λx y. f x y ∧ ¬ f y x ∨ x = y) ym xm; fmdom xm = fmdom ym⟧ ⟹ fmrel (λx y. f x y ∧ ¬ f y x ∨ x = y) ym xm› discuss goal 1*) apply (metis (mono_tags, lifting) fmrel_code (*‹fmrel ?R ?m ?n = ((∀x|∈|fmdom ?m. rel_option ?R (fmlookup ?m x) (fmlookup ?n x)) ∧ (∀x|∈|fmdom ?n. rel_option ?R (fmlookup ?m x) (fmlookup ?n x)))›*) fmrel_on_fset_alt_def (*‹fmrel_on_fset ?S ?P ?m ?n = (∀x|∈|?S. rel_option ?P (fmlookup ?m x) (fmlookup ?n x))›*)) (*discuss goal 2*) apply (metis (mono_tags, lifting) fmrel_code (*‹fmrel ?R ?m ?n = ((∀x|∈|fmdom ?m. rel_option ?R (fmlookup ?m x) (fmlookup ?n x)) ∧ (∀x|∈|fmdom ?n. rel_option ?R (fmlookup ?m x) (fmlookup ?n x)))›*) fmrel_on_fset_alt_def (*‹fmrel_on_fset ?S ?P ?m ?n = (∀x|∈|?S. rel_option ?P (fmlookup ?m x) (fmlookup ?n x))›*)) (*proven 2 subgoals*) . thus "fmlookup xm x = fmlookup ym x" apply (erule_tac ?x="x" in fmrel_cases (*‹⟦fmrel (?P::?'a ⇒ ?'b ⇒ bool) (?m::?'c ⇀⇩f ?'a) (?n::?'c ⇀⇩f ?'b); ⟦fmlookup ?m (?x::?'c) = None; fmlookup ?n ?x = None⟧ ⟹ ?thesis::bool; ⋀(a::?'a) b::?'b. ⟦fmlookup ?m ?x = Some a; fmlookup ?n ?x = Some b; ?P a b⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*)) (*goals: 1. ‹⟦fmrel (λx y. f x y ∧ ¬ f y x ∨ x = y) ym xm; fmlookup xm x = None; fmlookup ym x = None⟧ ⟹ fmlookup xm x = fmlookup ym x› 2. ‹⋀a b. ⟦fmrel (λx y. f x y ∧ ¬ f y x ∨ x = y) ym xm; fmlookup xm x = Some a; fmlookup ym x = Some b; f a b ∨ a = b⟧ ⟹ fmlookup xm x = fmlookup ym x› discuss goal 1*) apply (erule_tac ?x="x" in fmrel_cases (*‹⟦fmrel ?P ?m ?n; ⟦fmlookup ?m ?x = None; fmlookup ?n ?x = None⟧ ⟹ ?thesis; ⋀a b. ⟦fmlookup ?m ?x = Some a; fmlookup ?n ?x = Some b; ?P a b⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*)) (*goals: 1. ‹⟦fmlookup xm x = None; fmlookup ym x = None; fmlookup ym x = None; fmlookup xm x = None⟧ ⟹ fmlookup xm x = fmlookup ym x› 2. ‹⋀a b. ⟦fmlookup xm x = None; fmlookup ym x = None; fmlookup ym x = Some a; fmlookup xm x = Some b; f a b ∧ ¬ f b a ∨ a = b⟧ ⟹ fmlookup xm x = fmlookup ym x› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) (*discuss goal 2*) apply ((auto)[1]) (*goal: ‹⋀a b. ⟦fmrel (λx y. f x y ∧ ¬ f y x ∨ x = y) ym xm; fmlookup xm x = Some a; fmlookup ym x = Some b; f a b ∨ a = b⟧ ⟹ fmlookup xm x = fmlookup ym x›*) apply (erule_tac ?x="x" in fmrel_cases (*‹⟦fmrel ?P ?m ?n; ⟦fmlookup ?m ?x = None; fmlookup ?n ?x = None⟧ ⟹ ?thesis; ⋀a b. ⟦fmlookup ?m ?x = Some a; fmlookup ?n ?x = Some b; ?P a b⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*)) (*goals: 1. ‹⋀a b. ⟦fmlookup xm x = Some a; fmlookup ym x = Some b; f a b; fmlookup ym x = None; fmlookup xm x = None⟧ ⟹ a = b› 2. ‹⋀a b aa ba. ⟦fmlookup xm x = Some a; fmlookup ym x = Some b; f a b; fmlookup ym x = Some aa; fmlookup xm x = Some ba; f aa ba ∧ ¬ f ba aa ∨ aa = ba⟧ ⟹ a = b› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) (*proven 2 subgoals*) . qed lemma strict_subtuple_antisym: "strict_subtuple (λx y. f x y ∨ x = y) xm ym ⟹ strict_subtuple (λx y. f x y ∧ ¬ f y x ∨ x = y) ym xm ⟹ False" by (auto simp add: subtuple_antisym (*‹⟦subtuple (λx y. ?f x y ∨ x = y) ?xm ?ym; subtuple (λx y. ?f x y ∧ ¬ ?f y x ∨ x = y) ?ym ?xm⟧ ⟹ ?xm = ?ym›*)) lemma subtuple_acyclic: assumes "acyclicP_on (fmran' xm) P" assumes "subtuple (λx y. P x y ∨ x = y)⁺⁺ xm ym" assumes "subtuple (λx y. P x y ∨ x = y) ym xm" shows "xm = ym" proof (rule fmap_ext (*‹(⋀x. fmlookup ?m x = fmlookup ?n x) ⟹ ?m = ?n›*)) (*goal: ‹⋀x. fmlookup xm x = fmlookup ym x›*) fix x from assms (*‹acyclicP_on (fmran' xm) P› ‹subtuple (λx y. P x y ∨ x = y)⁺⁺ xm ym› ‹subtuple (λx y. P x y ∨ x = y) ym xm›*) have fmdom_eq: "fmdom xm = fmdom ym" using subtuple_fmdom (*‹⟦subtuple ?f ?xm ?ym; subtuple ?g ?ym ?xm⟧ ⟹ fmdom ?xm = fmdom ?ym›*) by blast have "⋀x a b. acyclicP_on (fmran' xm) P ⟹ fmlookup xm x = Some a ⟹ fmlookup ym x = Some b ⟹ P⇧*⇧* a b ⟹ P b a ∨ a = b ⟹ a = b" by (meson Nitpick.tranclp_unfold (*‹(?r::?'a ⇒ ?'a ⇒ bool)⁺⁺ (?a::?'a) (?b::?'a) ≡ (?a, ?b) ∈ {(x::?'a, y::?'a). ?r x y}⁺›*) fmran'I (*‹fmlookup (?m::?'b ⇀⇩f ?'a) (?x::?'b) = Some (?y::?'a) ⟹ ?y ∈ fmran' ?m›*) rtranclp_into_tranclp1 (*‹⟦(?r::?'a ⇒ ?'a ⇒ bool)⇧*⇧* (?a::?'a) (?b::?'a); ?r ?b (?c::?'a)⟧ ⟹ ?r⁺⁺ ?a ?c›*)) moreover from fmdom_eq (*‹fmdom xm = fmdom ym›*) assms(2) (*‹subtuple (λx y. P x y ∨ x = y)⁺⁺ xm ym›*) have "fmrel P⇧*⇧* xm ym" unfolding fmrel_on_fset_fmrel_restrict (*goal: ‹fmrel P⇧*⇧* xm ym›*) apply auto (*goal: ‹fmrel P⇧*⇧* xm ym›*) by (metis fmrestrict_fset_dom (*‹fmrestrict_fset (fmdom (?m::?'a ⇀⇩f ?'b)) ?m = ?m›*)) moreover from fmdom_eq (*‹fmdom (xm::'b::type ⇀⇩f 'a::type) = fmdom (ym::'b::type ⇀⇩f 'a::type)›*) assms(3) (*‹subtuple (λx y. P x y ∨ x = y) ym xm›*) have "fmrel (λx y. P x y ∨ x = y) ym xm" unfolding fmrel_on_fset_fmrel_restrict (*goal: ‹fmrel (λx y. P x y ∨ x = y) ym xm›*) apply auto (*goal: ‹fmrel (λx y. P x y ∨ x = y) ym xm›*) by (metis fmrestrict_fset_dom (*‹fmrestrict_fset (fmdom (?m::?'a ⇀⇩f ?'b)) ?m = ?m›*)) ultimately show "fmlookup xm x = fmlookup ym x" apply (erule_tac ?x="x" in fmrel_cases (*‹⟦fmrel ?P ?m ?n; ⟦fmlookup ?m ?x = None; fmlookup ?n ?x = None⟧ ⟹ ?thesis; ⋀a b. ⟦fmlookup ?m ?x = Some a; fmlookup ?n ?x = Some b; ?P a b⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*)) (*goal: ‹fmlookup xm x = fmlookup ym x›*) apply ((erule_tac ?x="x" in fmrel_cases (*‹⟦fmrel ?P ?m ?n; ⟦fmlookup ?m ?x = None; fmlookup ?n ?x = None⟧ ⟹ ?thesis; ⋀a b. ⟦fmlookup ?m ?x = Some a; fmlookup ?n ?x = Some b; ?P a b⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*), simp_all)+) (*top goal: ‹⟦⋀x a b. ⟦acyclicP_on (fmran' xm) P; fmlookup xm x = Some a; fmlookup ym x = Some b; P⇧*⇧* a b; P b a ∨ a = b⟧ ⟹ a = b; fmrel (λx y. P x y ∨ x = y) ym xm; fmlookup xm x = None; fmlookup ym x = None⟧ ⟹ fmlookup xm x = fmlookup ym x› and 1 goal remains*) using assms(1) (*‹acyclicP_on (fmran' xm) P›*) by blast qed lemma subtuple_acyclic': assumes "acyclicP_on (fmran' ym) P" assumes "subtuple (λx y. P x y ∨ x = y)⁺⁺ xm ym" assumes "subtuple (λx y. P x y ∨ x = y) ym xm" shows "xm = ym" proof (rule fmap_ext (*‹(⋀x. fmlookup ?m x = fmlookup ?n x) ⟹ ?m = ?n›*)) (*goal: ‹⋀x. fmlookup xm x = fmlookup ym x›*) fix x from assms (*‹acyclicP_on (fmran' ym) P› ‹subtuple (λx y. P x y ∨ x = y)⁺⁺ xm ym› ‹subtuple (λx y. P x y ∨ x = y) ym xm›*) have fmdom_eq: "fmdom xm = fmdom ym" using subtuple_fmdom (*‹⟦subtuple ?f ?xm ?ym; subtuple ?g ?ym ?xm⟧ ⟹ fmdom ?xm = fmdom ?ym›*) by blast have "⋀x a b. acyclicP_on (fmran' ym) P ⟹ fmlookup xm x = Some a ⟹ fmlookup ym x = Some b ⟹ P⇧*⇧* a b ⟹ P b a ∨ a = b ⟹ a = b" by (meson Nitpick.tranclp_unfold (*‹?r⁺⁺ ?a ?b ≡ (?a, ?b) ∈ {(x, y). ?r x y}⁺›*) fmran'I (*‹fmlookup ?m ?x = Some ?y ⟹ ?y ∈ fmran' ?m›*) rtranclp_into_tranclp2 (*‹⟦?r ?a ?b; ?r⇧*⇧* ?b ?c⟧ ⟹ ?r⁺⁺ ?a ?c›*)) moreover from fmdom_eq (*‹fmdom xm = fmdom ym›*) assms(2) (*‹subtuple (λx y. P x y ∨ x = y)⁺⁺ xm ym›*) have "fmrel P⇧*⇧* xm ym" unfolding fmrel_on_fset_fmrel_restrict (*goal: ‹fmrel (P::'a::type ⇒ 'a::type ⇒ bool)⇧*⇧* (xm::'b::type ⇀⇩f 'a::type) (ym::'b::type ⇀⇩f 'a::type)›*) apply auto (*goal: ‹fmrel P⇧*⇧* xm ym›*) by (metis fmrestrict_fset_dom (*‹fmrestrict_fset (fmdom (?m::?'a::type ⇀⇩f ?'b::type)) ?m = ?m›*)) moreover from fmdom_eq (*‹fmdom xm = fmdom ym›*) assms(3) (*‹subtuple (λx y. P x y ∨ x = y) ym xm›*) have "fmrel (λx y. P x y ∨ x = y) ym xm" unfolding fmrel_on_fset_fmrel_restrict (*goal: ‹fmrel (λ(x::'a::type) y::'a::type. (P::'a::type ⇒ 'a::type ⇒ bool) x y ∨ x = y) (ym::'b::type ⇀⇩f 'a::type) (xm::'b::type ⇀⇩f 'a::type)›*) apply auto (*goal: ‹fmrel (λx y. P x y ∨ x = y) ym xm›*) by (metis fmrestrict_fset_dom (*‹fmrestrict_fset (fmdom ?m) ?m = ?m›*)) ultimately show "fmlookup xm x = fmlookup ym x" apply (erule_tac ?x="x" in fmrel_cases (*‹⟦fmrel ?P ?m ?n; ⟦fmlookup ?m ?x = None; fmlookup ?n ?x = None⟧ ⟹ ?thesis; ⋀a b. ⟦fmlookup ?m ?x = Some a; fmlookup ?n ?x = Some b; ?P a b⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*)) (*goal: ‹fmlookup xm x = fmlookup ym x›*) apply ((erule_tac ?x="x" in fmrel_cases (*‹⟦fmrel ?P ?m ?n; ⟦fmlookup ?m ?x = None; fmlookup ?n ?x = None⟧ ⟹ ?thesis; ⋀a b. ⟦fmlookup ?m ?x = Some a; fmlookup ?n ?x = Some b; ?P a b⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*), simp_all)+) (*top goal: ‹⟦⋀x a b. ⟦acyclicP_on (fmran' ym) P; fmlookup xm x = Some a; fmlookup ym x = Some b; P⇧*⇧* a b; P b a ∨ a = b⟧ ⟹ a = b; fmrel (λx y. P x y ∨ x = y) ym xm; fmlookup xm x = None; fmlookup ym x = None⟧ ⟹ fmlookup xm x = fmlookup ym x› and 1 goal remains*) using assms(1) (*‹acyclicP_on (fmran' (ym::'b ⇀⇩f 'a)) (P::'a ⇒ 'a ⇒ bool)›*) by blast qed lemma subtuple_acyclic'': "acyclicP_on (fmran' ym) R ⟹ subtuple R⇧*⇧* xm ym ⟹ subtuple R ym xm ⟹ xm = ym" by (metis (no_types, lifting) subtuple_acyclic' (*‹⟦acyclicP_on (fmran' ?ym) ?P; subtuple (λx y. ?P x y ∨ x = y)⁺⁺ ?xm ?ym; subtuple (λx y. ?P x y ∨ x = y) ?ym ?xm⟧ ⟹ ?xm = ?ym›*) subtuple_mono (*‹(⋀x y. ⟦x ∈ fmran' ?xm; y ∈ fmran' ?ym⟧ ⟹ ?f x y ⟶ ?g x y) ⟹ subtuple ?f ?xm ?ym ⟶ subtuple ?g ?xm ?ym›*) tranclp_eq_rtranclp (*‹(λx y. ?P x y ∨ x = y)⁺⁺ = ?P⇧*⇧*›*)) lemma strict_subtuple_trans: "acyclicP_on (fmran' xm) P ⟹ strict_subtuple (λx y. P x y ∨ x = y)⁺⁺ xm ym ⟹ strict_subtuple (λx y. P x y ∨ x = y) ym zm ⟹ strict_subtuple (λx y. P x y ∨ x = y)⁺⁺ xm zm" apply auto (*goal: ‹⟦acyclicP_on (fmran' xm) P; strict_subtuple (λx y. P x y ∨ x = y)⁺⁺ xm ym; strict_subtuple (λx y. P x y ∨ x = y) ym zm⟧ ⟹ strict_subtuple (λx y. P x y ∨ x = y)⁺⁺ xm zm›*) apply (rule fmrel_on_fset_trans (*‹⟦⋀x y z. ⟦x ∈ fmran' ?xm; ?P x y; ?Q y z⟧ ⟹ ?R x z; subtuple ?P ?xm ?ym; subtuple ?Q ?ym ?zm⟧ ⟹ subtuple ?R ?xm ?zm›*), auto) (*top goal: ‹⟦acyclicP_on (fmran' xm) P; subtuple P⇧*⇧* xm ym; xm ≠ ym; subtuple (λx y. P x y ∨ x = y) ym zm; ym ≠ zm⟧ ⟹ subtuple P⇧*⇧* xm zm› and 1 goal remains*) by (drule_tac ?ym="ym" in subtuple_acyclic (*‹⟦acyclicP_on (fmran' ?xm) ?P; subtuple (λx y. ?P x y ∨ x = y)⁺⁺ ?xm ?ym; subtuple (λx y. ?P x y ∨ x = y) ?ym ?xm⟧ ⟹ ?xm = ?ym›*); auto) lemma strict_subtuple_trans': "acyclicP_on (fmran' zm) P ⟹ strict_subtuple (λx y. P x y ∨ x = y) xm ym ⟹ strict_subtuple (λx y. P x y ∨ x = y)⁺⁺ ym zm ⟹ strict_subtuple (λx y. P x y ∨ x = y)⁺⁺ xm zm" apply auto (*goal: ‹⟦acyclicP_on (fmran' (zm::'b ⇀⇩f 'a)) (P::'a ⇒ 'a ⇒ bool); strict_subtuple (λ(x::'a) y::'a. P x y ∨ x = y) (xm::'b ⇀⇩f 'a) (ym::'b ⇀⇩f 'a); strict_subtuple (λ(x::'a) y::'a. P x y ∨ x = y)⁺⁺ ym zm⟧ ⟹ strict_subtuple (λ(x::'a) y::'a. P x y ∨ x = y)⁺⁺ xm zm›*) apply (rule fmrel_on_fset_trans (*‹⟦⋀(x::?'a) (y::?'b) z::?'c. ⟦x ∈ fmran' (?xm::?'d ⇀⇩f ?'a); (?P::?'a ⇒ ?'b ⇒ bool) x y; (?Q::?'b ⇒ ?'c ⇒ bool) y z⟧ ⟹ (?R::?'a ⇒ ?'c ⇒ bool) x z; subtuple ?P ?xm (?ym::?'d ⇀⇩f ?'b); subtuple ?Q ?ym (?zm::?'d ⇀⇩f ?'c)⟧ ⟹ subtuple ?R ?xm ?zm›*), auto) (*top goal: ‹⟦acyclicP_on (fmran' zm) P; subtuple (λx y. P x y ∨ x = y) xm ym; xm ≠ ym; subtuple P⇧*⇧* ym zm; ym ≠ zm⟧ ⟹ subtuple P⇧*⇧* xm zm› and 1 goal remains*) by (drule_tac ?xm="ym" in subtuple_acyclic' (*‹⟦acyclicP_on (fmran' ?ym) ?P; subtuple (λx y. ?P x y ∨ x = y)⁺⁺ ?xm ?ym; subtuple (λx y. ?P x y ∨ x = y) ?ym ?xm⟧ ⟹ ?xm = ?ym›*); auto) lemma strict_subtuple_trans'': "acyclicP_on (fmran' zm) R ⟹ strict_subtuple R xm ym ⟹ strict_subtuple R⇧*⇧* ym zm ⟹ strict_subtuple R⇧*⇧* xm zm" apply auto (*goal: ‹⟦acyclicP_on (fmran' zm) R; strict_subtuple R xm ym; strict_subtuple R⇧*⇧* ym zm⟧ ⟹ strict_subtuple R⇧*⇧* xm zm›*) apply (rule fmrel_on_fset_trans (*‹⟦⋀x y z. ⟦x ∈ fmran' ?xm; ?P x y; ?Q y z⟧ ⟹ ?R x z; subtuple ?P ?xm ?ym; subtuple ?Q ?ym ?zm⟧ ⟹ subtuple ?R ?xm ?zm›*), auto) (*top goal: ‹⟦acyclicP_on (fmran' zm) R; subtuple R xm ym; xm ≠ ym; subtuple R⇧*⇧* ym zm; ym ≠ zm⟧ ⟹ subtuple R⇧*⇧* xm zm› and 1 goal remains*) by (drule_tac ?xm="ym" in subtuple_acyclic'' (*‹⟦acyclicP_on (fmran' ?ym) ?R; subtuple ?R⇧*⇧* ?xm ?ym; subtuple ?R ?ym ?xm⟧ ⟹ ?xm = ?ym›*); auto) lemma strict_subtuple_trans''': "acyclicP_on (fmran' zm) P ⟹ strict_subtuple (λx y. P x y ∨ x = y) xm ym ⟹ strict_subtuple (λx y. P x y ∨ x = y)⇧*⇧* ym zm ⟹ strict_subtuple (λx y. P x y ∨ x = y)⇧*⇧* xm zm" apply auto (*goal: ‹⟦acyclicP_on (fmran' zm) P; strict_subtuple (λx y. P x y ∨ x = y) xm ym; strict_subtuple (λx y. P x y ∨ x = y)⇧*⇧* ym zm⟧ ⟹ strict_subtuple (λx y. P x y ∨ x = y)⇧*⇧* xm zm›*) apply (rule fmrel_on_fset_trans (*‹⟦⋀x y z. ⟦x ∈ fmran' ?xm; ?P x y; ?Q y z⟧ ⟹ ?R x z; subtuple ?P ?xm ?ym; subtuple ?Q ?ym ?zm⟧ ⟹ subtuple ?R ?xm ?zm›*), auto) (*top goal: ‹⟦acyclicP_on (fmran' zm) P; subtuple (λx y. P x y ∨ x = y) xm ym; xm ≠ ym; subtuple P⇧*⇧* ym zm; ym ≠ zm⟧ ⟹ subtuple P⇧*⇧* xm zm› and 1 goal remains*) by (drule_tac ?xm="ym" in subtuple_acyclic' (*‹⟦acyclicP_on (fmran' ?ym) ?P; subtuple (λx y. ?P x y ∨ x = y)⁺⁺ ?xm ?ym; subtuple (λx y. ?P x y ∨ x = y) ?ym ?xm⟧ ⟹ ?xm = ?ym›*); auto) lemma subtuple_fmmerge2 [intro]: "(⋀x y. x ∈ fmran' xm ⟹ f x (g x y)) ⟹ subtuple f xm (fmmerge g xm ym)" apply ((rule_tac ?S="fmdom ym" in fmrel_on_fsubset (*‹⟦fmrel_on_fset ?S ?R ?m ?n; ?T |⊆| ?S⟧ ⟹ fmrel_on_fset ?T ?R ?m ?n›*))[1]) (*goals: 1. ‹(⋀(x::'a) y::'b. x ∈ fmran' (xm::'c ⇀⇩f 'a) ⟹ (f::'a ⇒ 'd ⇒ bool) x ((g::'a ⇒ 'b ⇒ 'd) x y)) ⟹ fmrel_on_fset (fmdom (ym::'c ⇀⇩f 'b)) f xm (fmmerge g xm ym)› 2. ‹(⋀(x::'a) y::'b. x ∈ fmran' (xm::'c ⇀⇩f 'a) ⟹ (f::'a ⇒ 'd ⇒ bool) x ((g::'a ⇒ 'b ⇒ 'd) x y)) ⟹ fmdom (fmmerge g xm (ym::'c ⇀⇩f 'b)) |⊆| fmdom ym› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . (*** Transitive Closures ****************************************************) subsection ‹Transitive Closures› lemma trancl_to_subtuple: "(subtuple r)⁺⁺ xm ym ⟹ subtuple r⁺⁺ xm ym" 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›*)) (*goal: ‹(subtuple r)⁺⁺ xm ym ⟹ subtuple r⁺⁺ xm ym›*) apply (metis subtuple_mono (*‹(⋀x y. ⟦x ∈ fmran' ?xm; y ∈ fmran' ?ym⟧ ⟹ ?f x y ⟶ ?g x y) ⟹ subtuple ?f ?xm ?ym ⟶ subtuple ?g ?xm ?ym›*) tranclp.r_into_trancl (*‹?r ?a ?b ⟹ ?r⁺⁺ ?a ?b›*)) (*top goal: ‹⋀y. subtuple r xm y ⟹ subtuple r⁺⁺ xm y› and 1 goal remains*) by (rule fmrel_on_fset_trans (*‹⟦⋀x y z. ⟦x ∈ fmran' ?xm; ?P x y; ?Q y z⟧ ⟹ ?R x z; subtuple ?P ?xm ?ym; subtuple ?Q ?ym ?zm⟧ ⟹ subtuple ?R ?xm ?zm›*); auto) lemma rtrancl_to_subtuple: "(subtuple r)⇧*⇧* xm ym ⟹ subtuple r⇧*⇧* xm ym" apply (induct rule: rtranclp_induct (*‹⟦?r⇧*⇧* ?a ?b; ?P ?a; ⋀y z. ⟦?r⇧*⇧* ?a y; ?r y z; ?P y⟧ ⟹ ?P z⟧ ⟹ ?P ?b›*)) (*goal: ‹(subtuple r)⇧*⇧* xm ym ⟹ subtuple r⇧*⇧* xm ym›*) apply (simp add: fmap.rel_refl_strong (*‹(⋀z::?'a::type. z ∈ fmran' (?x::?'b::type ⇀⇩f ?'a::type) ⟹ (?Ra::?'a::type ⇒ ?'a::type ⇒ bool) z z) ⟹ fmrel ?Ra ?x ?x›*) fmrel_to_subtuple (*‹fmrel (?r::?'a::type ⇒ ?'b::type ⇒ bool) (?xm::?'c::type ⇀⇩f ?'a::type) (?ym::?'c::type ⇀⇩f ?'b::type) ⟹ subtuple ?r ?xm ?ym›*)) (*top goal: ‹subtuple r⇧*⇧* xm xm› and 1 goal remains*) by (rule fmrel_on_fset_trans (*‹⟦⋀x y z. ⟦x ∈ fmran' ?xm; ?P x y; ?Q y z⟧ ⟹ ?R x z; subtuple ?P ?xm ?ym; subtuple ?Q ?ym ?zm⟧ ⟹ subtuple ?R ?xm ?zm›*); auto) lemma fmrel_to_subtuple_trancl: "reflp r ⟹ (fmrel r)⁺⁺ (fmrestrict_fset (fmdom ym) xm) ym ⟹ (subtuple r)⁺⁺ xm ym" apply (frule trancl_to_fmrel (*‹(fmrel ?f)⁺⁺ ?xm ?ym ⟹ fmrel ?f⁺⁺ ?xm ?ym›*)) (*goal: ‹⟦reflp (r::'a ⇒ 'a ⇒ bool); (fmrel r)⁺⁺ (fmrestrict_fset (fmdom (ym::'b ⇀⇩f 'a)) (xm::'b ⇀⇩f 'a)) ym⟧ ⟹ (subtuple r)⁺⁺ xm ym›*) apply (rule_tac ?r="r" in fmrel_tranclp_induct (*‹⟦fmrel ?r⁺⁺ ?a ?b; reflp ?r; ⋀y. fmrel ?r ?a y ⟹ ?P y; ⋀y z. ⟦(fmrel ?r)⁺⁺ ?a y; fmrel ?r y z; ?P y⟧ ⟹ ?P z⟧ ⟹ ?P ?b›*), auto) (*goal: ‹⟦reflp r; (fmrel r)⁺⁺ (fmrestrict_fset (fmdom ym) xm) ym; fmrel r⁺⁺ (fmrestrict_fset (fmdom ym) xm) ym⟧ ⟹ (subtuple r)⁺⁺ xm ym›*) apply (metis (no_types, lifting) fmrel_fmdom_eq (*‹fmrel ?P ?x ?y ⟹ fmdom ?x = fmdom ?y›*) subtuple_eq_fmrel_fmrestrict_fset (*‹subtuple ?r ?xm ?ym = fmrel ?r (fmrestrict_fset (fmdom ?ym) ?xm) ?ym›*) tranclp.r_into_trancl (*‹?r ?a ?b ⟹ ?r⁺⁺ ?a ?b›*)) (*top goal: ‹⋀y. ⟦reflp r; (fmrel r)⁺⁺ (fmrestrict_fset (fmdom ym) xm) ym; fmrel r⁺⁺ (fmrestrict_fset (fmdom ym) xm) ym; fmrel r (fmrestrict_fset (fmdom ym) xm) y⟧ ⟹ (subtuple r)⁺⁺ xm y› and 1 goal remains*) by (meson fmrel_to_subtuple (*‹fmrel ?r ?xm ?ym ⟹ subtuple ?r ?xm ?ym›*) tranclp.simps (*‹?r⁺⁺ ?a1.0 ?a2.0 = ((∃a b. ?a1.0 = a ∧ ?a2.0 = b ∧ ?r a b) ∨ (∃a b c. ?a1.0 = a ∧ ?a2.0 = c ∧ ?r⁺⁺ a b ∧ ?r b c))›*)) lemma subtuple_to_trancl: "reflp r ⟹ subtuple r⁺⁺ xm ym ⟹ (subtuple r)⁺⁺ xm ym" apply (rule fmrel_to_subtuple_trancl (*‹⟦reflp ?r; (fmrel ?r)⁺⁺ (fmrestrict_fset (fmdom ?ym) ?xm) ?ym⟧ ⟹ (subtuple ?r)⁺⁺ ?xm ?ym›*)) (*goal: ‹⟦reflp r; subtuple r⁺⁺ xm ym⟧ ⟹ (subtuple r)⁺⁺ xm ym›*) unfolding fmrel_on_fset_fmrel_restrict (*goals: 1. ‹⟦reflp r; fmrel r⁺⁺ (fmrestrict_fset (fmdom ym) xm) (fmrestrict_fset (fmdom ym) ym)⟧ ⟹ reflp r› 2. ‹⟦reflp r; fmrel r⁺⁺ (fmrestrict_fset (fmdom ym) xm) (fmrestrict_fset (fmdom ym) ym)⟧ ⟹ (fmrel r)⁺⁺ (fmrestrict_fset (fmdom ym) xm) ym›*) (*goals: 1. ‹⟦reflp (r::'a ⇒ 'a ⇒ bool); fmrel r⁺⁺ (fmrestrict_fset (fmdom (ym::'b ⇀⇩f 'a)) (xm::'b ⇀⇩f 'a)) (fmrestrict_fset (fmdom ym) ym)⟧ ⟹ reflp r› 2. ‹⟦reflp (r::'a ⇒ 'a ⇒ bool); fmrel r⁺⁺ (fmrestrict_fset (fmdom (ym::'b ⇀⇩f 'a)) (xm::'b ⇀⇩f 'a)) (fmrestrict_fset (fmdom ym) ym)⟧ ⟹ (fmrel r)⁺⁺ (fmrestrict_fset (fmdom ym) xm) ym› discuss goal 1*) apply (simp add: fmrel_to_trancl (*‹⟦reflp ?r; fmrel ?r⁺⁺ ?xm ?ym⟧ ⟹ (fmrel ?r)⁺⁺ ?xm ?ym›*)) (*discuss goal 2*) apply (simp add: fmrel_to_trancl (*‹⟦reflp ?r; fmrel ?r⁺⁺ ?xm ?ym⟧ ⟹ (fmrel ?r)⁺⁺ ?xm ?ym›*)) (*proven 2 subgoals*) . lemma trancl_to_strict_subtuple: "acyclicP_on (fmran' ym) R ⟹ (strict_subtuple R)⁺⁺ xm ym ⟹ strict_subtuple R⇧*⇧* xm ym" apply (erule converse_tranclp_induct (*‹⟦?r⁺⁺ ?a ?b; ⋀y. ?r y ?b ⟹ ?P y; ⋀y z. ⟦?r y z; ?r⁺⁺ z ?b; ?P z⟧ ⟹ ?P y⟧ ⟹ ?P ?a›*)) (*goal: ‹⟦acyclicP_on (fmran' ym) R; (strict_subtuple R)⁺⁺ xm ym⟧ ⟹ strict_subtuple R⇧*⇧* xm ym›*) apply (metis r_into_rtranclp (*‹?r ?x ?y ⟹ ?r⇧*⇧* ?x ?y›*) strict_subtuple_mono (*‹(⋀x y. ⟦x ∈ fmran' ?xm; y ∈ fmran' ?ym⟧ ⟹ ?f x y ⟶ ?g x y) ⟹ strict_subtuple ?f ?xm ?ym ⟶ strict_subtuple ?g ?xm ?ym›*)) (*top goal: ‹⋀y. ⟦acyclicP_on (fmran' ym) R; strict_subtuple R y ym⟧ ⟹ strict_subtuple R⇧*⇧* y ym› and 1 goal remains*) using strict_subtuple_trans'' (*‹⟦acyclicP_on (fmran' ?zm) ?R; strict_subtuple ?R ?xm ?ym; strict_subtuple ?R⇧*⇧* ?ym ?zm⟧ ⟹ strict_subtuple ?R⇧*⇧* ?xm ?zm›*) by blast lemma trancl_to_strict_subtuple': "acyclicP_on (fmran' ym) R ⟹ (strict_subtuple (λx y. R x y ∨ x = y))⁺⁺ xm ym ⟹ strict_subtuple (λx y. R x y ∨ x = y)⇧*⇧* xm ym" apply (erule converse_tranclp_induct (*‹⟦?r⁺⁺ ?a ?b; ⋀y. ?r y ?b ⟹ ?P y; ⋀y z. ⟦?r y z; ?r⁺⁺ z ?b; ?P z⟧ ⟹ ?P y⟧ ⟹ ?P ?a›*)) (*goal: ‹⟦acyclicP_on (fmran' ym) R; (strict_subtuple (λx y. R x y ∨ x = y))⁺⁺ xm ym⟧ ⟹ strict_subtuple (λx y. R x y ∨ x = y)⇧*⇧* xm ym›*) apply (metis (no_types, lifting) r_into_rtranclp (*‹?r ?x ?y ⟹ ?r⇧*⇧* ?x ?y›*) strict_subtuple_mono (*‹(⋀x y. ⟦x ∈ fmran' ?xm; y ∈ fmran' ?ym⟧ ⟹ ?f x y ⟶ ?g x y) ⟹ strict_subtuple ?f ?xm ?ym ⟶ strict_subtuple ?g ?xm ?ym›*)) (*top goal: ‹⋀y. ⟦acyclicP_on (fmran' ym) R; strict_subtuple (λx y. R x y ∨ x = y) y ym⟧ ⟹ strict_subtuple (λx y. R x y ∨ x = y)⇧*⇧* y ym› and 1 goal remains*) using strict_subtuple_trans''' (*‹⟦acyclicP_on (fmran' (?zm::?'b ⇀⇩f ?'a)) (?P::?'a ⇒ ?'a ⇒ bool); strict_subtuple (λ(x::?'a) y::?'a. ?P x y ∨ x = y) (?xm::?'b ⇀⇩f ?'a) (?ym::?'b ⇀⇩f ?'a); strict_subtuple (λ(x::?'a) y::?'a. ?P x y ∨ x = y)⇧*⇧* ?ym ?zm⟧ ⟹ strict_subtuple (λ(x::?'a) y::?'a. ?P x y ∨ x = y)⇧*⇧* ?xm ?zm›*) by blast lemma subtuple_rtranclp_intro: assumes "⋀xm ym. R (f xm) (f ym) ⟹ subtuple R xm ym" and "bij_on_trancl R f" and "R⇧*⇧* (f xm) (f ym)" shows "subtuple R⇧*⇧* xm ym" proof (-) (*goal: ‹subtuple (R::'b ⇒ 'b ⇒ bool)⇧*⇧* (xm::'a ⇀⇩f 'b) (ym::'a ⇀⇩f 'b)›*) have "(λxm ym. R (f xm) (f ym))⇧*⇧* xm ym" apply ((insert assms( (*‹bij_on_trancl R f›*) 2) assms( (*‹R⇧*⇧* (f xm) (f ym)›*) 3))[1]) (*goal: ‹(λxm ym. R (f xm) (f ym))⇧*⇧* xm ym›*) apply (rule reflect_rtranclp (*‹⟦⋀x y. ?S (?f x) (?f y) ⟹ ?R x y; bij_on_trancl ?S ?f; ?S⇧*⇧* (?f ?x) (?f ?y)⟧ ⟹ ?R⇧*⇧* ?x ?y›*)) (*goals: 1. ‹⋀x y. ⟦bij_on_trancl R f; R⇧*⇧* (f xm) (f ym); ?S4 (?f4 x) (?f4 y)⟧ ⟹ R (f x) (f y)› 2. ‹⟦bij_on_trancl R f; R⇧*⇧* (f xm) (f ym)⟧ ⟹ bij_on_trancl ?S4 ?f4› 3. ‹⟦bij_on_trancl R f; R⇧*⇧* (f xm) (f ym)⟧ ⟹ ?S4⇧*⇧* (?f4 xm) (?f4 ym)› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*proven 3 subgoals*) . with assms(1) (*‹(R::'b::type ⇒ 'b::type ⇒ bool) ((f::'a::type ⇀⇩f 'b::type ⇒ 'b::type) (?xm::'a::type ⇀⇩f 'b::type)) (f (?ym::'a::type ⇀⇩f 'b::type)) ⟹ subtuple R ?xm ?ym›*) have "(subtuple R)⇧*⇧* xm ym" by (metis (mono_tags, lifting) mono_rtranclp (*‹(⋀a b. ?x a b ⟶ ?y a b) ⟹ ?x⇧*⇧* ?a ?b ⟶ ?y⇧*⇧* ?a ?b›*)) hence "subtuple R⇧*⇧* xm ym" by (rule rtrancl_to_subtuple (*‹(subtuple ?r)⇧*⇧* ?xm ?ym ⟹ subtuple ?r⇧*⇧* ?xm ?ym›*)) thus "?thesis" (*goal: ‹subtuple R⇧*⇧* xm ym›*) by simp qed lemma strict_subtuple_rtranclp_intro: assumes "⋀xm ym. R (f xm) (f ym) ⟹ strict_subtuple (λx y. R x y ∨ x = y) xm ym" and "bij_on_trancl R f" and "acyclicP_on (fmran' ym) R" and "R⁺⁺ (f xm) (f ym)" shows "strict_subtuple R⇧*⇧* xm ym" proof (-) (*goal: ‹strict_subtuple R⇧*⇧* xm ym›*) have "(λxm ym. R (f xm) (f ym))⁺⁺ xm ym" apply ((insert assms( (*‹R (f ?xm) (f ?ym) ⟹ strict_subtuple (λx y. R x y ∨ x = y) ?xm ?ym›*) 1) assms( (*‹bij_on_trancl R f›*) 2) assms( (*‹R⁺⁺ (f xm) (f ym)›*) 4))[1]) (*goal: ‹(λxm ym. R (f xm) (f ym))⁺⁺ xm ym›*) apply (rule reflect_tranclp (*‹⟦⋀x y. ?S (?f x) (?f y) ⟹ ?R x y; bij_on_trancl ?S ?f; ?S⁺⁺ (?f ?x) (?f ?y)⟧ ⟹ ?R⁺⁺ ?x ?y›*)) (*goals: 1. ‹⋀x y. ⟦⋀xm ym. R (f xm) (f ym) ⟹ strict_subtuple (λx y. R x y ∨ x = y) xm ym; bij_on_trancl R f; R⁺⁺ (f xm) (f ym); ?S6 (?f6 x) (?f6 y)⟧ ⟹ R (f x) (f y)› 2. ‹⟦⋀xm ym. R (f xm) (f ym) ⟹ strict_subtuple (λx y. R x y ∨ x = y) xm ym; bij_on_trancl R f; R⁺⁺ (f xm) (f ym)⟧ ⟹ bij_on_trancl ?S6 ?f6› 3. ‹⟦⋀xm ym. R (f xm) (f ym) ⟹ strict_subtuple (λx y. R x y ∨ x = y) xm ym; bij_on_trancl R f; R⁺⁺ (f xm) (f ym)⟧ ⟹ ?S6⁺⁺ (?f6 xm) (?f6 ym)› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*proven 3 subgoals*) . hence "(strict_subtuple (λx y. R x y ∨ x = y))⁺⁺ xm ym" apply - (*goal: ‹(strict_subtuple (λ(x::'b::type) y::'b::type. (R::'b::type ⇒ 'b::type ⇒ bool) x y ∨ x = y))⁺⁺ (xm::'a::type ⇀⇩f 'b::type) (ym::'a::type ⇀⇩f 'b::type)›*) by (msorry) with assms(3) (*‹acyclicP_on (fmran' ym) R›*) have "strict_subtuple (λx y. R x y ∨ x = y)⇧*⇧* xm ym" by (rule trancl_to_strict_subtuple' (*‹⟦acyclicP_on (fmran' ?ym) ?R; (strict_subtuple (λx y. ?R x y ∨ x = y))⁺⁺ ?xm ?ym⟧ ⟹ strict_subtuple (λx y. ?R x y ∨ x = y)⇧*⇧* ?xm ?ym›*)) thus "?thesis" (*goal: ‹strict_subtuple R⇧*⇧* xm ym›*) by simp qed (*** Code Setup *************************************************************) subsection ‹Code Setup› abbreviation "subtuple_fun f xm ym ≡ fBall (fmdom ym) (λx. rel_option f (fmlookup xm x) (fmlookup ym x))" abbreviation "strict_subtuple_fun f xm ym ≡ subtuple_fun f xm ym ∧ xm ≠ ym" lemma subtuple_fun_simp [code_abbrev, simp]: "subtuple_fun f xm ym = subtuple f xm ym" by (simp add: fmrel_on_fset_alt_def (*‹fmrel_on_fset ?S ?P ?m ?n = (∀x|∈|?S. rel_option ?P (fmlookup ?m x) (fmlookup ?n x))›*)) lemma strict_subtuple_fun_simp [code_abbrev, simp]: "strict_subtuple_fun f xm ym = strict_subtuple f xm ym" by simp end
{ "path": "afp-2025-02-12/thys/Safe_OCL/Tuple.thy", "repo": "afp-2025-02-12", "sha": "960b18884154ffac5f49de428a2a86bd38f79a4eacebec665782a9d3fdbeecf9" }
(******************************************************************************* Project: IsaNet Author: Tobias Klenze, ETH Zurich <tobias.klenze@inf.ethz.ch> Version: JCSPaper.1.0 Isabelle Version: Isabelle2021-1 Copyright (c) 2022 Tobias Klenze Licence: Mozilla Public License 2.0 (MPL) / BSD-3-Clause (dual license) *******************************************************************************) section ‹ICING variant› text‹We abstract and simplify from the protocol ICING in several ways. First, we only consider Proofs of Consent (PoC), not Proofs of Provenance (PoP). Our framework does not support proving the path validation properties that PoPs provide, and it also currently does not support XOR, and dynamically changing hop fields. Thus, instead of embedding $A_i \oplus PoP_{0,1}$, we embed $A_i$ directly. We also remove the payload from the Hash that is included in each packet. We offer three versions of this protocol: \begin{itemize} \item @{text "ICING"}, which contains our best effort at modeling the protocol as accurately as possible. \item @{text "ICING_variant"}, in which we strip down the protocol to what is required to obtain the security guarantees and remove unnecessary fields. \item @{text "ICING_variant2"}, in which we furthermore simplify the protocol. The key of the MAC in this protocol is only the key of the AS, as opposed to a key derived specifically for this hop field. In order to prove that this scheme is secure, we have to assume that ASes only occur once on an authorized path, since otherwise the MAC for two different hop fields (by the same AS) would be the same, and the AS could not distinguish the hop fields based on the MAC. \end{itemize}› theory ICING_variant2 imports "../Parametrized_Dataplane_3_undirected" begin locale icing_defs = network_assums_undirect _ _ _ auth_seg0 for auth_seg0 :: "(msgterm × ahi list) set" + assumes auth_seg0_no_dups: "⟦(ainfo, hfs) ∈ auth_seg0; hf ∈ set hfs; hf' ∈ set hfs; ASID hf' = ASID hf⟧ ⟹ hf' = hf" begin (******************************************************************************) subsection ‹Hop validation check and extract functions› (******************************************************************************) type_synonym ICING_HF = "(unit, unit) HF" text‹The term @{term "sntag"} simply is the AS key. We use it in the computation of @{term "hf_valid"}.› fun sntag :: "ahi ⇒ msgterm" where "sntag ⦇UpIF = upif, DownIF = downif, ASID = asid⦈ = macKey asid" text‹The predicate @{term "hf_valid"} is given to the concrete parametrized model as a parameter. It ensures the authenticity of the hop authenticator in the hop field. The predicate takes an expiration timestamp (in this model always a numeric value, hence the matching on @{term "Num PoC_i_expire"}), the entire segment and the hop field to be validated.› fun hf_valid :: "msgterm ⇒ msgterm ⇒ ICING_HF list ⇒ ICING_HF ⇒ bool" where "hf_valid (Num PoC_i_expire) uinfo hfs ⦇AHI = ahi, UHI = uhi, HVF = x⦈ ⟷ uhi = () ∧ x = Mac[sntag ahi] (L ((Num PoC_i_expire)#(map (hf2term o AHI) hfs))) ∧ uinfo = ε" | "hf_valid _ _ _ _ = False" text‹We can extract the entire path (past and future) from the hvf field.› fun extr :: "msgterm ⇒ ahi list" where "extr (Mac[_] (L hfs)) = map term2hf (tl hfs)" | "extr _ = []" text‹Extract the authenticated info field from a hop validation field.› fun extr_ainfo :: "msgterm ⇒ msgterm" where "extr_ainfo (Mac[_] (L (Num ts # xs))) = Num ts" | "extr_ainfo _ = ε" abbreviation term_ainfo :: "msgterm ⇒ msgterm" where "term_ainfo ≡ id" text‹An authenticated info field is always a number (corresponding to a timestamp). The unauthenticated info field is set to the empty term @{term "ε"}.› definition auth_restrict where "auth_restrict ainfo uinfo l ≡ (∃ts. ainfo = Num ts) ∧ (uinfo = ε)" text‹When observing a hop field, an attacker learns the HVF. UHI is empty and the AHI only contains public information that are not terms.› fun terms_hf :: "ICING_HF ⇒ msgterm set" where "terms_hf hf = {HVF hf}" abbreviation terms_uinfo :: "msgterm ⇒ msgterm set" where "terms_uinfo x ≡ {x}" abbreviation no_oracle where "no_oracle ≡ (λ _ _. True)" text‹We now define useful properties of the above definition.› lemma hf_valid_invert: "hf_valid tsn uinfo hfs hf ⟷ (∃ ts ahi. tsn = Num ts ∧ ahi = AHI hf ∧ UHI hf = () ∧ HVF hf = Mac[sntag ahi] (L ((Num ts)#(map (hf2term o AHI) hfs))) ∧ uinfo = ε)" apply (cases hf) (*goal: ‹hf_valid tsn uinfo hfs hf = (∃ts ahi. tsn = Num ts ∧ ahi = AHI hf ∧ UHI hf = () ∧ HVF hf = Mac[sntag ahi] (L (Num ts # map (hf2term ∘ AHI) hfs)) ∧ uinfo = ε)›*) by (auto elim!: hf_valid.elims (*‹⟦hf_valid ?x ?xa ?xb ?xc = ?y; ⋀PoC_i_expire uinfo hfs ahi uhi x. ⟦?x = Num PoC_i_expire; ?xa = uinfo; ?xb = hfs; ?xc = ⦇AHI = ahi, UHI = uhi, HVF = x⦈; ?y = (uhi = () ∧ x = Mac[sntag ahi] (L (Num PoC_i_expire # map (hf2term ∘ AHI) hfs)) ∧ uinfo = ε)⟧ ⟹ ?P; ⋀uv_ uw_ ux_. ⟦?x = ε; ?xa = uv_; ?xb = uw_; ?xc = ux_; ¬ ?y⟧ ⟹ ?P; ⋀v uv_ uw_ ux_. ⟦?x = AS v; ?xa = uv_; ?xb = uw_; ?xc = ux_; ¬ ?y⟧ ⟹ ?P; ⋀v uv_ uw_ ux_. ⟦?x = Key v; ?xa = uv_; ?xb = uw_; ?xc = ux_; ¬ ?y⟧ ⟹ ?P; ⋀v uv_ uw_ ux_. ⟦?x = Nonce v; ?xa = uv_; ?xb = uw_; ?xc = ux_; ¬ ?y⟧ ⟹ ?P; ⋀v uv_ uw_ ux_. ⟦?x = L v; ?xa = uv_; ?xb = uw_; ?xc = ux_; ¬ ?y⟧ ⟹ ?P; ⋀v uv_ uw_ ux_. ⟦?x = FS v; ?xa = uv_; ?xb = uw_; ?xc = ux_; ¬ ?y⟧ ⟹ ?P; ⋀v va uv_ uw_ ux_. ⟦?x = ⟨v, va⟩; ?xa = uv_; ?xb = uw_; ?xc = ux_; ¬ ?y⟧ ⟹ ?P; ⋀v uv_ uw_ ux_. ⟦?x = Hash v; ?xa = uv_; ?xb = uw_; ?xc = ux_; ¬ ?y⟧ ⟹ ?P; ⋀v va uv_ uw_ ux_. ⟦?x = Crypt v va; ?xa = uv_; ?xb = uw_; ?xc = ux_; ¬ ?y⟧ ⟹ ?P⟧ ⟹ ?P› ‹⟦hf_valid ?x ?xa ?xb ?xc; ⋀PoC_i_expire uinfo hfs ahi uhi x. ⟦?x = Num PoC_i_expire; ?xa = uinfo; ?xb = hfs; ?xc = ⦇AHI = ahi, UHI = uhi, HVF = x⦈; uhi = () ∧ x = Mac[sntag ahi] (L (Num PoC_i_expire # map (hf2term ∘ AHI) hfs)) ∧ uinfo = ε⟧ ⟹ ?P⟧ ⟹ ?P› ‹⟦¬ hf_valid ?x ?xa ?xb ?xc; ⋀PoC_i_expire uinfo hfs ahi uhi x. ⟦?x = Num PoC_i_expire; ?xa = uinfo; ?xb = hfs; ?xc = ⦇AHI = ahi, UHI = uhi, HVF = x⦈; ¬ (uhi = () ∧ x = Mac[sntag ahi] (L (Num PoC_i_expire # map (hf2term ∘ AHI) hfs)) ∧ uinfo = ε)⟧ ⟹ ?P; ⋀uv_ uw_ ux_. ⟦?x = ε; ?xa = uv_; ?xb = uw_; ?xc = ux_⟧ ⟹ ?P; ⋀v uv_ uw_ ux_. ⟦?x = AS v; ?xa = uv_; ?xb = uw_; ?xc = ux_⟧ ⟹ ?P; ⋀v uv_ uw_ ux_. ⟦?x = Key v; ?xa = uv_; ?xb = uw_; ?xc = ux_⟧ ⟹ ?P; ⋀v uv_ uw_ ux_. ⟦?x = Nonce v; ?xa = uv_; ?xb = uw_; ?xc = ux_⟧ ⟹ ?P; ⋀v uv_ uw_ ux_. ⟦?x = L v; ?xa = uv_; ?xb = uw_; ?xc = ux_⟧ ⟹ ?P; ⋀v uv_ uw_ ux_. ⟦?x = FS v; ?xa = uv_; ?xb = uw_; ?xc = ux_⟧ ⟹ ?P; ⋀v va uv_ uw_ ux_. ⟦?x = ⟨v, va⟩; ?xa = uv_; ?xb = uw_; ?xc = ux_⟧ ⟹ ?P; ⋀v uv_ uw_ ux_. ⟦?x = Hash v; ?xa = uv_; ?xb = uw_; ?xc = ux_⟧ ⟹ ?P; ⋀v va uv_ uw_ ux_. ⟦?x = Crypt v va; ?xa = uv_; ?xb = uw_; ?xc = ux_⟧ ⟹ ?P⟧ ⟹ ?P›*)) lemma hf_valid_auth_restrict[dest]: "hf_valid ainfo uinfo hfs hf ⟹ auth_restrict ainfo uinfo l" by (auto simp add: hf_valid_invert (*‹hf_valid ?tsn ?uinfo ?hfs ?hf = (∃ts ahi. ?tsn = Num ts ∧ ahi = AHI ?hf ∧ UHI ?hf = () ∧ HVF ?hf = Mac[sntag ahi] (L (Num ts # map (hf2term ∘ AHI) ?hfs)) ∧ ?uinfo = ε)›*) auth_restrict_def (*‹auth_restrict ?ainfo ?uinfo ?l ≡ (∃ts. ?ainfo = Num ts) ∧ ?uinfo = ε›*)) lemma auth_restrict_ainfo[dest]: "auth_restrict ainfo uinfo l ⟹ ∃ts. ainfo = Num ts" by (auto simp add: auth_restrict_def (*‹auth_restrict ?ainfo ?uinfo ?l ≡ (∃ts. ?ainfo = Num ts) ∧ ?uinfo = ε›*)) lemma auth_restrict_uinfo[dest]: "auth_restrict ainfo uinfo l ⟹ uinfo = ε" by (auto simp add: auth_restrict_def (*‹auth_restrict (?ainfo::msgterm) (?uinfo::msgterm) (?l::?'a) ≡ (∃ts::nat. ?ainfo = Num ts) ∧ ?uinfo = ε›*)) (******************************************************************************) subsection‹Definitions and properties of the added intruder knowledge› (******************************************************************************) text‹Here we define a @{text "ik_add"} and @{text "ik_oracle"} as being empty, as these features are not used in this instance model.› print_locale dataplane_3_undirected_defs sublocale dataplane_3_undirected_defs _ _ _ auth_seg0 hf_valid auth_restrict extr extr_ainfo term_ainfo terms_hf terms_uinfo no_oracle by unfold_locales declare parts_singleton[dest] abbreviation ik_add :: "msgterm set" where "ik_add ≡ {}" abbreviation ik_oracle :: "msgterm set" where "ik_oracle ≡ {}" lemma uinfo_empty[dest]: "(ainfo, hfs) ∈ auth_seg2 uinfo ⟹ uinfo = ε" by (auto simp add: auth_seg2_def (*‹auth_seg2 ?uinfo ≡ {(ainfo, l) |ainfo l. hfs_valid_prefix_generic ainfo ?uinfo [] None l None = l ∧ auth_restrict ainfo ?uinfo l ∧ True ∧ (ainfo, AHIS l) ∈ auth_seg0}›*) auth_restrict_def (*‹auth_restrict ?ainfo ?uinfo ?l ≡ (∃ts. ?ainfo = Num ts) ∧ ?uinfo = ε›*)) (******************************************************************************) subsection‹Properties of the intruder knowledge, including @{text "ik_add"} and @{text "ik_oracle"}› (******************************************************************************) text‹We now instantiate the parametrized model's definition of the intruder knowledge, using the definitions of @{text "ik_add"} and @{text "ik_oracle"} from above. We then prove the properties that we need to instantiate the @{text "dataplane_3_undirected"} locale.› print_locale dataplane_3_undirected_ik_defs sublocale dataplane_3_undirected_ik_defs _ _ _ auth_seg0 terms_uinfo no_oracle hf_valid auth_restrict extr extr_ainfo term_ainfo terms_hf ik_add ik_oracle by unfold_locales lemma ik_hfs_form: "t ∈ parts ik_hfs ⟹ ∃ t' . t = Hash t'" apply auto (*goal: ‹t ∈ parts ik_hfs ⟹ ∃t'. t = Hash t'›*) apply (drule parts_singleton (*‹?X ∈ parts ?H ⟹ ∃Y∈?H. ?X ∈ parts {Y}›*)) (*goal: ‹t ∈ parts {HVF hf |hf. ∃hfs. hf ∈ set hfs ∧ (∃ainfo uinfo. (ainfo, hfs) ∈ auth_seg2 uinfo)} ⟹ ∃t'. t = Hash t'›*) by (auto simp add: auth_seg2_def (*‹auth_seg2 ?uinfo ≡ {(ainfo, l) |ainfo l. hfs_valid_prefix_generic ainfo ?uinfo [] None l None = l ∧ auth_restrict ainfo ?uinfo l ∧ True ∧ (ainfo, AHIS l) ∈ auth_seg0}›*) hf_valid_invert (*‹hf_valid ?tsn ?uinfo ?hfs ?hf = (∃ts ahi. ?tsn = Num ts ∧ ahi = AHI ?hf ∧ UHI ?hf = () ∧ HVF ?hf = Mac[sntag ahi] (L (Num ts # map (hf2term ∘ AHI) ?hfs)) ∧ ?uinfo = ε)›*)) declare ik_hfs_def[simp del] lemma parts_ik_hfs[simp]: "parts ik_hfs = ik_hfs" by (auto intro!: parts_Hash (*‹(⋀t. t ∈ ?H ⟹ ∃t'. t = Hash t') ⟹ parts ?H = ?H›*) ik_hfs_form (*‹?t ∈ parts ik_hfs ⟹ ∃t'. ?t = Hash t'›*)) text‹This lemma allows us not only to expand the definition of @{term "ik_hfs"}, but also to obtain useful properties, such as a term being a Hash, and it being part of a valid hop field.› lemma ik_hfs_simp: "t ∈ ik_hfs ⟷ (∃t' . t = Hash t') ∧ (∃hf . t = HVF hf ∧ (∃hfs uinfo. hf ∈ set hfs ∧ (∃ainfo . (ainfo, hfs) ∈ auth_seg2 uinfo ∧ hf_valid ainfo uinfo hfs hf)))" (is "?lhs ⟷ ?rhs") proof (standard) (*goals: 1. ‹t ∈ ik_hfs ⟹ (∃t'. t = Hash t') ∧ (∃hf. t = HVF hf ∧ (∃hfs uinfo. hf ∈ set hfs ∧ (∃ainfo. (ainfo, hfs) ∈ auth_seg2 uinfo ∧ hf_valid ainfo uinfo hfs hf)))› 2. ‹(∃t'. t = Hash t') ∧ (∃hf. t = HVF hf ∧ (∃hfs uinfo. hf ∈ set hfs ∧ (∃ainfo. (ainfo, hfs) ∈ auth_seg2 uinfo ∧ hf_valid ainfo uinfo hfs hf))) ⟹ t ∈ ik_hfs›*) assume asm: "?lhs" (*‹(t::msgterm) ∈ ik_hfs›*) then obtain ainfo and uinfo and hf and hfs where dfs: "hf ∈ set hfs" "(ainfo, hfs) ∈ auth_seg2 uinfo" "t = HVF hf" (*goal: ‹(⋀hf hfs ainfo uinfo. ⟦hf ∈ set hfs; (ainfo, hfs) ∈ auth_seg2 uinfo; t = HVF hf⟧ ⟹ thesis) ⟹ thesis›*) by (auto simp add: ik_hfs_def (*‹ik_hfs = {uu_. ∃t hf hfs ainfo uinfo. uu_ = t ∧ t ∈ terms_hf hf ∧ hf ∈ set hfs ∧ (ainfo, hfs) ∈ auth_seg2 uinfo}›*)) then obtain uinfo where "hfs_valid_prefix ainfo uinfo [] hfs = hfs" "(ainfo, AHIS hfs) ∈ auth_seg0" (*goal: ‹(⋀uinfo. ⟦hfs_valid_prefix ainfo uinfo [] hfs = hfs; (ainfo, AHIS hfs) ∈ auth_seg0⟧ ⟹ thesis) ⟹ thesis›*) by (auto simp add: auth_seg2_def (*‹auth_seg2 (?uinfo::msgterm) ≡ {(ainfo, l) |(ainfo::msgterm) l::(unit, unit) HF list. hfs_valid_prefix_generic ainfo ?uinfo [] None l None = l ∧ auth_restrict ainfo ?uinfo l ∧ True ∧ (ainfo, AHIS l) ∈ (auth_seg0::(msgterm × ahi list) set)}›*)) then show "?rhs" using asm (*‹t ∈ ik_hfs›*) dfs (*‹(hf::(unit, unit) HF) ∈ set (hfs::(unit, unit) HF list)› ‹(ainfo, hfs) ∈ auth_seg2 uinfo__› ‹(t::msgterm) = HVF (hf::(unit, unit) HF)›*) by (auto 3 4 simp add: auth_seg2_def (*‹auth_seg2 ?uinfo ≡ {(ainfo, l) |ainfo l. hfs_valid_prefix_generic ainfo ?uinfo [] None l None = l ∧ auth_restrict ainfo ?uinfo l ∧ True ∧ (ainfo, AHIS l) ∈ auth_seg0}›*) intro!: ik_hfs_form (*‹?t ∈ parts ik_hfs ⟹ ∃t'. ?t = Hash t'›*) exI[of _ hf] (*‹?P hf ⟹ ∃x. ?P x›*)) qed (auto simp add: ik_hfs_def (*‹ik_hfs = {uu_::msgterm. ∃(t::msgterm) (hf::(unit, unit) HF) (hfs::(unit, unit) HF list) (ainfo::msgterm) uinfo::msgterm. uu_ = t ∧ t ∈ terms_hf hf ∧ hf ∈ set hfs ∧ (ainfo, hfs) ∈ auth_seg2 uinfo}›*)) (*solved the remaining goal: ‹(∃t'. t = Hash t') ∧ (∃hf. t = HVF hf ∧ (∃hfs uinfo. hf ∈ set hfs ∧ (∃ainfo. (ainfo, hfs) ∈ auth_seg2 uinfo ∧ hf_valid ainfo uinfo hfs hf))) ⟹ t ∈ ik_hfs›*) lemma ik_uinfo_empty[simp]: "ik_uinfo = {ε}" by (auto simp add: ik_uinfo_def (*‹ik_uinfo = {uu_. ∃ainfo hfs uinfo t. uu_ = t ∧ t ∈ {uinfo} ∧ (ainfo, hfs) ∈ auth_seg2 uinfo}›*) auth_seg2_def (*‹auth_seg2 ?uinfo ≡ {(ainfo, l) |ainfo l. hfs_valid_prefix_generic ainfo ?uinfo [] None l None = l ∧ auth_restrict ainfo ?uinfo l ∧ True ∧ (ainfo, AHIS l) ∈ auth_seg0}›*) auth_restrict_def (*‹auth_restrict ?ainfo ?uinfo ?l ≡ (∃ts. ?ainfo = Num ts) ∧ ?uinfo = ε›*) intro!: exI[of _ "[]"] (*‹?P [] ⟹ ∃x. ?P x›*)) declare ik_uinfo_def[simp del] (******************************************************************************) subsubsection ‹Properties of Intruder Knowledge› (******************************************************************************) lemma auth_ainfo[dest]: "⟦(ainfo, hfs) ∈ auth_seg2 uinfo⟧ ⟹ ∃ ts . ainfo = Num ts" by (auto simp add: auth_seg2_def (*‹auth_seg2 (?uinfo::msgterm) ≡ {(ainfo, l) |(ainfo::msgterm) l::(unit, unit) HF list. hfs_valid_prefix_generic ainfo ?uinfo [] None l None = l ∧ auth_restrict ainfo ?uinfo l ∧ True ∧ (ainfo, AHIS l) ∈ (auth_seg0::(msgterm × ahi list) set)}›*)) lemma Num_ik[intro]: "Num ts ∈ ik" by (auto simp add: ik_def (*‹ik = ik_hfs ∪ {uu_. ∃ainfo hfs uinfo. uu_ = id ainfo ∧ (ainfo, hfs) ∈ auth_seg2 uinfo} ∪ ik_uinfo ∪ Key ` macK ` bad ∪ {} ∪ {}›*) auth_seg2_def (*‹auth_seg2 ?uinfo ≡ {(ainfo, l) |ainfo l. hfs_valid_prefix_generic ainfo ?uinfo [] None l None = l ∧ auth_restrict ainfo ?uinfo l ∧ True ∧ (ainfo, AHIS l) ∈ auth_seg0}›*) auth_restrict_def (*‹auth_restrict ?ainfo ?uinfo ?l ≡ (∃ts. ?ainfo = Num ts) ∧ ?uinfo = ε›*) intro!: exI[of _ "[]"] (*‹?P [] ⟹ ∃x. ?P x›*)) text ‹There are no ciphertexts (or signatures) in @{term "parts ik"}. Thus, @{term "analz ik"} and @{term "parts ik"} are identical.› lemma analz_parts_ik[simp]: "analz ik = parts ik" apply (rule no_crypt_analz_is_parts (*‹∄K X. Crypt K X ∈ parts ?A ⟹ analz ?A = parts ?A›*)) (*goal: ‹analz ik = parts ik›*) by (auto simp add: ik_def (*‹ik = ik_hfs ∪ {uu_::msgterm. ∃(ainfo::msgterm) (hfs::(unit, unit) HF list) uinfo::msgterm. uu_ = id ainfo ∧ (ainfo, hfs) ∈ auth_seg2 uinfo} ∪ ik_uinfo ∪ Key ` macK ` (bad::nat set) ∪ {} ∪ {}›*) auth_seg2_def (*‹auth_seg2 (?uinfo::msgterm) ≡ {(ainfo, l) |(ainfo::msgterm) l::(unit, unit) HF list. hfs_valid_prefix_generic ainfo ?uinfo [] None l None = l ∧ auth_restrict ainfo ?uinfo l ∧ True ∧ (ainfo, AHIS l) ∈ (auth_seg0::(msgterm × ahi list) set)}›*) ik_hfs_simp (*‹((?t::msgterm) ∈ ik_hfs) = ((∃t'::msgterm. ?t = Hash t') ∧ (∃hf::(unit, unit) HF. ?t = HVF hf ∧ (∃(hfs::(unit, unit) HF list) uinfo::msgterm. hf ∈ set hfs ∧ (∃ainfo::msgterm. (ainfo, hfs) ∈ auth_seg2 uinfo ∧ hf_valid ainfo uinfo hfs hf))))›*) auth_restrict_def (*‹auth_restrict (?ainfo::msgterm) (?uinfo::msgterm) (?l::?'a) ≡ (∃ts::nat. ?ainfo = Num ts) ∧ ?uinfo = ε›*)) lemma parts_ik[simp]: "parts ik = ik" by (auto 3 4 simp add: ik_def (*‹ik = ik_hfs ∪ {uu_. ∃ainfo hfs uinfo. uu_ = id ainfo ∧ (ainfo, hfs) ∈ auth_seg2 uinfo} ∪ ik_uinfo ∪ Key ` macK ` bad ∪ {} ∪ {}›*) auth_seg2_def (*‹auth_seg2 ?uinfo ≡ {(ainfo, l) |ainfo l. hfs_valid_prefix_generic ainfo ?uinfo [] None l None = l ∧ auth_restrict ainfo ?uinfo l ∧ True ∧ (ainfo, AHIS l) ∈ auth_seg0}›*) auth_restrict_def (*‹auth_restrict ?ainfo ?uinfo ?l ≡ (∃ts. ?ainfo = Num ts) ∧ ?uinfo = ε›*) dest!: parts_singleton_set (*‹?x ∈ parts {s. ?P s} ⟹ ∃Y. ?P Y ∧ ?x ∈ parts {Y}›*)) lemma sntag_synth_bad: "sntag ahi ∈ synth ik ⟹ ASID ahi ∈ bad" apply (cases ahi) (*goal: ‹sntag (ahi::ahi) ∈ synth ik ⟹ ASID ahi ∈ (bad::nat set)›*) by (auto simp add: ik_def (*‹ik = ik_hfs ∪ {uu_. ∃ainfo hfs uinfo. uu_ = id ainfo ∧ (ainfo, hfs) ∈ auth_seg2 uinfo} ∪ ik_uinfo ∪ Key ` macK ` bad ∪ {} ∪ {}›*) ik_hfs_simp (*‹(?t ∈ ik_hfs) = ((∃t'. ?t = Hash t') ∧ (∃hf. ?t = HVF hf ∧ (∃hfs uinfo. hf ∈ set hfs ∧ (∃ainfo. (ainfo, hfs) ∈ auth_seg2 uinfo ∧ hf_valid ainfo uinfo hfs hf))))›*)) lemma back_subst_set_member: "⟦hf' ∈ set hfs; hf' = hf⟧ ⟹ hf ∈ set hfs" by simp lemma sntag_asid: "sntag hf = sntag hf' ⟹ ASID hf' = ASID hf" apply (cases hf) (*goal: ‹sntag hf = sntag hf' ⟹ ASID hf' = ASID hf›*) apply (cases hf') (*goal: ‹⋀UpIF DownIF ASIDa. ⟦sntag hf = sntag hf'; hf = ⦇UpIF = UpIF, DownIF = DownIF, ASID = ASIDa⦈⟧ ⟹ ASID hf' = ASID hf›*) by auto lemma map_hf2term_eq: "map (λx. hf2term (AHI x)) hfs = map (λx. hf2term (AHI x)) hfs' ⟹ AHIS hfs' = AHIS hfs" apply (induction hfs hfs' rule: list_induct2' (*‹⟦?P [] []; ⋀x xs. ?P (x # xs) []; ⋀y ys. ?P [] (y # ys); ⋀x xs y ys. ?P xs ys ⟹ ?P (x # xs) (y # ys)⟧ ⟹ ?P ?xs ?ys›*), auto) (*goal: ‹map (λx. hf2term (AHI x)) hfs = map (λx. hf2term (AHI x)) hfs' ⟹ AHIS hfs' = AHIS hfs›*) using term2hf_hf2term (*‹term2hf (hf2term ?hf) = ?hf›*) by metis (******************************************************************************) subsection‹Direct proof goals for interpretation of @{text "dataplane_3_undirected"}› (******************************************************************************) lemma COND_honest_hf_analz: assumes "ASID (AHI hf) ∉ bad" "hf_valid ainfo uinfo hfs hf" "terms_hf hf ⊆ synth (analz ik)" "no_oracle ainfo uinfo" "hf ∈ set hfs" shows "terms_hf hf ⊆ analz ik" proof (-) (*goal: ‹terms_hf (hf::(unit, unit) HF) ⊆ analz ik›*) from assms(3) (*‹terms_hf hf ⊆ synth (analz ik)›*) have hf_synth_ik: "HVF hf ∈ synth ik" by auto then have "∃hfs uinfo. hf ∈ set hfs ∧ (ainfo, hfs) ∈ auth_seg2 uinfo" using assms(1,2,4,5) (*‹ASID (AHI hf) ∉ bad› ‹hf_valid ainfo uinfo hfs hf› ‹True› ‹hf ∈ set hfs›*) apply (auto simp add: ik_def (*‹ik = ik_hfs ∪ {uu_::msgterm. ∃(ainfo::msgterm) (hfs::(unit, unit) HF list) uinfo::msgterm. uu_ = id ainfo ∧ (ainfo, hfs) ∈ auth_seg2 uinfo} ∪ ik_uinfo ∪ Key ` macK ` (bad::nat set) ∪ {} ∪ {}›*) hf_valid_invert (*‹hf_valid (?tsn::msgterm) (?uinfo::msgterm) (?hfs::(unit, unit) HF list) (?hf::(unit, unit) HF) = (∃(ts::nat) ahi::ahi. ?tsn = Num ts ∧ ahi = AHI ?hf ∧ UHI ?hf = () ∧ HVF ?hf = Mac[sntag ahi] (L (Num ts # map (hf2term ∘ AHI) ?hfs)) ∧ ?uinfo = ε)›*) ik_hfs_simp (*‹((?t::msgterm) ∈ ik_hfs) = ((∃t'::msgterm. ?t = Hash t') ∧ (∃hf::(unit, unit) HF. ?t = HVF hf ∧ (∃(hfs::(unit, unit) HF list) uinfo::msgterm. hf ∈ set hfs ∧ (∃ainfo::msgterm. (ainfo, hfs) ∈ auth_seg2 uinfo ∧ hf_valid ainfo uinfo hfs hf))))›*)) (*goal: ‹∃(hfs::(unit, unit) HF list) uinfo::msgterm. (hf::(unit, unit) HF) ∈ set hfs ∧ (ainfo::msgterm, hfs) ∈ auth_seg2 uinfo›*) subgoal for ts' and hf' and hfs' apply (auto intro!: exI[of _ hfs'] (*‹?P hfs' ⟹ ∃x. ?P x›*)) (*goal: ‹⟦ASID (AHI hf) ∉ bad; hf ∈ set hfs; ainfo = Num ts'; HVF hf = Mac[sntag (AHI hf')] (L (Num ts' # map (λx. hf2term (AHI x)) hfs')); uinfo = ε; hf' ∈ set hfs'; (Num ts', hfs') ∈ auth_seg2 ε; HVF hf' = Mac[sntag (AHI hf')] (L (Num ts' # map (λx. hf2term (AHI x)) hfs')); sntag (AHI hf) = sntag (AHI hf'); map (λx. hf2term (AHI x)) hfs = map (λx. hf2term (AHI x)) hfs'⟧ ⟹ ∃hfs. hf ∈ set hfs ∧ (∃uinfo. (Num ts', hfs) ∈ auth_seg2 uinfo)›*) apply (frule back_subst_set_member[where hfs="hfs'"] (*‹⟦?hf' ∈ set hfs'; ?hf' = ?hf⟧ ⟹ ?hf ∈ set hfs'›*)) (*goal: ‹⟦ASID (AHI (hf::(unit, unit) HF)) ∉ (bad::nat set); hf ∈ set (hfs::(unit, unit) HF list); (ainfo::msgterm) = Num (ts'::nat); HVF hf = Mac[sntag (AHI (hf'::(unit, unit) HF))] (L (Num ts' # map (λx::(unit, unit) HF. hf2term (AHI x)) (hfs'::(unit, unit) HF list))); (uinfo::msgterm) = ε; hf' ∈ set hfs'; (Num ts', hfs') ∈ auth_seg2 ε; HVF hf' = Mac[sntag (AHI hf')] (L (Num ts' # map (λx::(unit, unit) HF. hf2term (AHI x)) hfs')); sntag (AHI hf) = sntag (AHI hf'); map (λx::(unit, unit) HF. hf2term (AHI x)) hfs = map (λx::(unit, unit) HF. hf2term (AHI x)) hfs'⟧ ⟹ hf ∈ set hfs'›*) apply (rule HF.equality (*‹⟦AHI ?r = AHI ?r'; UHI ?r = UHI ?r'; HVF ?r = HVF ?r'; HF.more ?r = HF.more ?r'⟧ ⟹ ?r = ?r'›*)) (*top goal: ‹⟦ASID (AHI hf) ∉ bad; hf ∈ set hfs; ainfo = Num ts'; HVF hf = Mac[sntag (AHI hf')] (L (Num ts' # map (λx. hf2term (AHI x)) hfs')); uinfo = ε; hf' ∈ set hfs'; (Num ts', hfs') ∈ auth_seg2 ε; HVF hf' = Mac[sntag (AHI hf')] (L (Num ts' # map (λx. hf2term (AHI x)) hfs')); sntag (AHI hf) = sntag (AHI hf'); map (λx. hf2term (AHI x)) hfs = map (λx. hf2term (AHI x)) hfs'⟧ ⟹ hf' = ?hf46› and 1 goal remains*) apply auto (*top goal: ‹⟦ASID (AHI (hf::(unit, unit) HF)) ∉ (bad::nat set); hf ∈ set (hfs::(unit, unit) HF list); (ainfo::msgterm) = Num (ts'::nat); HVF hf = Mac[sntag (AHI (hf'::(unit, unit) HF))] (L (Num ts' # map (λx::(unit, unit) HF. hf2term (AHI x)) (hfs'::(unit, unit) HF list))); (uinfo::msgterm) = ε; hf' ∈ set hfs'; (Num ts', hfs') ∈ auth_seg2 ε; HVF hf' = Mac[sntag (AHI hf')] (L (Num ts' # map (λx::(unit, unit) HF. hf2term (AHI x)) hfs')); sntag (AHI hf) = sntag (AHI hf'); map (λx::(unit, unit) HF. hf2term (AHI x)) hfs = map (λx::(unit, unit) HF. hf2term (AHI x)) hfs'⟧ ⟹ AHI hf' = AHI (?hf46::(unit, unit) HF)› and 4 goals remain*) apply (drule sntag_asid (*‹sntag ?hf = sntag ?hf' ⟹ ASID ?hf' = ASID ?hf›*)) (*goal: ‹⟦ASID (AHI hf) ∉ bad; hf ∈ set hfs; ainfo = Num ts'; HVF hf = Mac[sntag (AHI hf')] (L (Num ts' # map (λx. hf2term (AHI x)) hfs')); uinfo = ε; hf' ∈ set hfs'; (Num ts', hfs') ∈ auth_seg2 ε; HVF hf' = Mac[sntag (AHI hf')] (L (Num ts' # map (λx. hf2term (AHI x)) hfs')); sntag (AHI hf) = sntag (AHI hf'); map (λx. hf2term (AHI x)) hfs = map (λx. hf2term (AHI x)) hfs'⟧ ⟹ AHI hf' = AHI hf›*) apply (drule map_hf2term_eq (*‹map (λx. hf2term (AHI x)) ?hfs = map (λx. hf2term (AHI x)) ?hfs' ⟹ AHIS ?hfs' = AHIS ?hfs›*)) (*goal: ‹⟦ASID (AHI (hf::(unit, unit) HF)) ∉ (bad::nat set); hf ∈ set (hfs::(unit, unit) HF list); (ainfo::msgterm) = Num (ts'::nat); HVF hf = Mac[sntag (AHI (hf'::(unit, unit) HF))] (L (Num ts' # map (λx::(unit, unit) HF. hf2term (AHI x)) (hfs'::(unit, unit) HF list))); (uinfo::msgterm) = ε; hf' ∈ set hfs'; (Num ts', hfs') ∈ auth_seg2 ε; HVF hf' = Mac[sntag (AHI hf')] (L (Num ts' # map (λx::(unit, unit) HF. hf2term (AHI x)) hfs')); map (λx::(unit, unit) HF. hf2term (AHI x)) hfs = map (λx::(unit, unit) HF. hf2term (AHI x)) hfs'; ASID (AHI hf') = ASID (AHI hf)⟧ ⟹ AHI hf' = AHI hf›*) using auth_seg0_no_dups (*‹⟦(?ainfo, ?hfs) ∈ auth_seg0; ?hf ∈ set ?hfs; ?hf' ∈ set ?hfs; ASID ?hf' = ASID ?hf⟧ ⟹ ?hf' = ?hf›*) by (metis (mono_tags, lifting) AHIS_set_rev (*‹⦇AHI = ?ahi, UHI = ?uhi, HVF = ?x⦈ ∈ set ?hfs ⟹ ?ahi ∈ set (AHIS ?hfs)›*) HF.surjective (*‹?r = ⦇AHI = AHI ?r, UHI = UHI ?r, HVF = HVF ?r, … = HF.more ?r⦈›*) auth_seg20 (*‹(?x, ?y) ∈ auth_seg2 ?uinfo ⟹ (?x, AHIS ?y) ∈ auth_seg0›*) old.unit.exhaust (*‹(?y = () ⟹ ?P) ⟹ ?P›*)) (*goals: 1. ‹⋀ts hfsa uinfoa. ⟦ASID (AHI hf) ∉ bad; hf ∈ set hfs; ainfo = Num ts; HVF hf = Mac[sntag (AHI hf)] (L (Num ts # map (λx. hf2term (AHI x)) hfs)); uinfo = ε; (Mac[sntag (AHI hf)] (L (Num ts # map (λx. hf2term (AHI x)) hfs)), hfsa) ∈ auth_seg2 uinfoa⟧ ⟹ ∃hfs. hf ∈ set hfs ∧ (∃uinfo. (Num ts, hfs) ∈ auth_seg2 uinfo)› 2. ‹⋀ts hfsa uinfoa. ⟦ASID (AHI hf) ∉ bad; hf ∈ set hfs; ainfo = Num ts; HVF hf = Mac[sntag (AHI hf)] (L (Num ts # map (λx. hf2term (AHI x)) hfs)); uinfo = ε; (⟨sntag (AHI hf), L (Num ts # map (λx. hf2term (AHI x)) hfs)⟩, hfsa) ∈ auth_seg2 uinfoa⟧ ⟹ ∃hfs. hf ∈ set hfs ∧ (∃uinfo. (Num ts, hfs) ∈ auth_seg2 uinfo)› 3. ‹⋀ts hfsa uinfoa. ⟦ASID (AHI hf) ∉ bad; hf ∈ set hfs; ainfo = Num ts; HVF hf = Mac[sntag (AHI hf)] (L (Num ts # map (λx. hf2term (AHI x)) hfs)); uinfo = ε; sntag (AHI hf) ∈ synth (insert ε (ik_hfs ∪ {uu_. ∃hfs uinfo. (uu_, hfs) ∈ auth_seg2 uinfo} ∪ Key ` macK ` bad)); (L (Num ts # map (λx. hf2term (AHI x)) hfs), hfsa) ∈ auth_seg2 uinfoa⟧ ⟹ ∃hfs. hf ∈ set hfs ∧ (∃uinfo. (Num ts, hfs) ∈ auth_seg2 uinfo)› 4. ‹⋀ts. ⟦ASID (AHI hf) ∉ bad; hf ∈ set hfs; ainfo = Num ts; HVF hf = Mac[sntag (AHI hf)] (L (Num ts # map (λx. hf2term (AHI x)) hfs)); uinfo = ε; sntag (AHI hf) ∈ synth (insert ε (ik_hfs ∪ {uu_. ∃hfs uinfo. (uu_, hfs) ∈ auth_seg2 uinfo} ∪ Key ` macK ` bad)); ∀x. x ∈ (λx. hf2term (AHI x)) ` set hfs ⟶ x ∈ synth (insert ε (ik_hfs ∪ {uu_. ∃hfs uinfo. (uu_, hfs) ∈ auth_seg2 uinfo} ∪ Key ` macK ` bad))⟧ ⟹ ∃hfs. hf ∈ set hfs ∧ (∃uinfo. (Num ts, hfs) ∈ auth_seg2 uinfo)› discuss goal 1*) apply ((auto simp add: ik_hfs_simp (*‹((?t::msgterm) ∈ ik_hfs) = ((∃t'::msgterm. ?t = Hash t') ∧ (∃hf::(unit, unit) HF. ?t = HVF hf ∧ (∃(hfs::(unit, unit) HF list) uinfo::msgterm. hf ∈ set hfs ∧ (∃ainfo::msgterm. (ainfo, hfs) ∈ auth_seg2 uinfo ∧ hf_valid ainfo uinfo hfs hf))))›*) ik_def (*‹ik = ik_hfs ∪ {uu_::msgterm. ∃(ainfo::msgterm) (hfs::(unit, unit) HF list) uinfo::msgterm. uu_ = id ainfo ∧ (ainfo, hfs) ∈ auth_seg2 uinfo} ∪ ik_uinfo ∪ Key ` macK ` (bad::nat set) ∪ {} ∪ {}›*) hf_valid_invert (*‹hf_valid (?tsn::msgterm) (?uinfo::msgterm) (?hfs::(unit, unit) HF list) (?hf::(unit, unit) HF) = (∃(ts::nat) ahi::ahi. ?tsn = Num ts ∧ ahi = AHI ?hf ∧ UHI ?hf = () ∧ HVF ?hf = Mac[sntag ahi] (L (Num ts # map (hf2term ∘ AHI) ?hfs)) ∧ ?uinfo = ε)›*) sntag_synth_bad (*‹sntag (?ahi::ahi) ∈ synth ik ⟹ ASID ?ahi ∈ (bad::nat set)›*))[1]) (*discuss goal 2*) apply ((auto simp add: ik_hfs_simp (*‹(?t ∈ ik_hfs) = ((∃t'. ?t = Hash t') ∧ (∃hf. ?t = HVF hf ∧ (∃hfs uinfo. hf ∈ set hfs ∧ (∃ainfo. (ainfo, hfs) ∈ auth_seg2 uinfo ∧ hf_valid ainfo uinfo hfs hf))))›*) ik_def (*‹ik = ik_hfs ∪ {uu_. ∃ainfo hfs uinfo. uu_ = id ainfo ∧ (ainfo, hfs) ∈ auth_seg2 uinfo} ∪ ik_uinfo ∪ Key ` macK ` bad ∪ {} ∪ {}›*) hf_valid_invert (*‹hf_valid ?tsn ?uinfo ?hfs ?hf = (∃ts ahi. ?tsn = Num ts ∧ ahi = AHI ?hf ∧ UHI ?hf = () ∧ HVF ?hf = Mac[sntag ahi] (L (Num ts # map (hf2term ∘ AHI) ?hfs)) ∧ ?uinfo = ε)›*) sntag_synth_bad (*‹sntag ?ahi ∈ synth ik ⟹ ASID ?ahi ∈ bad›*))[1]) (*discuss goal 3*) apply ((auto simp add: ik_hfs_simp (*‹(?t ∈ ik_hfs) = ((∃t'. ?t = Hash t') ∧ (∃hf. ?t = HVF hf ∧ (∃hfs uinfo. hf ∈ set hfs ∧ (∃ainfo. (ainfo, hfs) ∈ auth_seg2 uinfo ∧ hf_valid ainfo uinfo hfs hf))))›*) ik_def (*‹ik = ik_hfs ∪ {uu_. ∃ainfo hfs uinfo. uu_ = id ainfo ∧ (ainfo, hfs) ∈ auth_seg2 uinfo} ∪ ik_uinfo ∪ Key ` macK ` bad ∪ {} ∪ {}›*) hf_valid_invert (*‹hf_valid ?tsn ?uinfo ?hfs ?hf = (∃ts ahi. ?tsn = Num ts ∧ ahi = AHI ?hf ∧ UHI ?hf = () ∧ HVF ?hf = Mac[sntag ahi] (L (Num ts # map (hf2term ∘ AHI) ?hfs)) ∧ ?uinfo = ε)›*) sntag_synth_bad (*‹sntag ?ahi ∈ synth ik ⟹ ASID ?ahi ∈ bad›*))[1]) (*discuss goal 4*) apply ((auto simp add: ik_hfs_simp (*‹(?t ∈ ik_hfs) = ((∃t'. ?t = Hash t') ∧ (∃hf. ?t = HVF hf ∧ (∃hfs uinfo. hf ∈ set hfs ∧ (∃ainfo. (ainfo, hfs) ∈ auth_seg2 uinfo ∧ hf_valid ainfo uinfo hfs hf))))›*) ik_def (*‹ik = ik_hfs ∪ {uu_. ∃ainfo hfs uinfo. uu_ = id ainfo ∧ (ainfo, hfs) ∈ auth_seg2 uinfo} ∪ ik_uinfo ∪ Key ` macK ` bad ∪ {} ∪ {}›*) hf_valid_invert (*‹hf_valid ?tsn ?uinfo ?hfs ?hf = (∃ts ahi. ?tsn = Num ts ∧ ahi = AHI ?hf ∧ UHI ?hf = () ∧ HVF ?hf = Mac[sntag ahi] (L (Num ts # map (hf2term ∘ AHI) ?hfs)) ∧ ?uinfo = ε)›*) sntag_synth_bad (*‹sntag ?ahi ∈ synth ik ⟹ ASID ?ahi ∈ bad›*))[1]) (*proven 4 subgoals*) . then have "HVF hf ∈ ik" using assms(2) (*‹hf_valid ainfo uinfo hfs hf›*) by (auto simp add: ik_hfs_def (*‹ik_hfs = {uu_. ∃t hf hfs ainfo uinfo. uu_ = t ∧ t ∈ terms_hf hf ∧ hf ∈ set hfs ∧ (ainfo, hfs) ∈ auth_seg2 uinfo}›*) intro!: ik_ik_hfs (*‹?t ∈ ik_hfs ⟹ ?t ∈ ik›*) intro!: exI (*‹?P ?x ⟹ ∃x. ?P x›*)) then show "?thesis" (*goal: ‹terms_hf hf ⊆ analz ik›*) by auto qed lemma COND_terms_hf: assumes "hf_valid ainfo uinfo hfs hf" and "HVF hf ∈ ik" and "no_oracle ainfo uinfo" and "hf ∈ set hfs" shows "∃hfs. hf ∈ set hfs ∧ (∃uinfo' . (ainfo, hfs) ∈ auth_seg2 uinfo')" using assms (*‹hf_valid ainfo uinfo hfs hf› ‹HVF (hf::(unit, unit) HF) ∈ ik› ‹True› ‹hf ∈ set hfs›*) apply (auto 3 4 simp add: hf_valid_invert (*‹hf_valid ?tsn ?uinfo ?hfs ?hf = (∃ts ahi. ?tsn = Num ts ∧ ahi = AHI ?hf ∧ UHI ?hf = () ∧ HVF ?hf = Mac[sntag ahi] (L (Num ts # map (hf2term ∘ AHI) ?hfs)) ∧ ?uinfo = ε)›*) ik_hfs_simp (*‹(?t ∈ ik_hfs) = ((∃t'. ?t = Hash t') ∧ (∃hf. ?t = HVF hf ∧ (∃hfs uinfo. hf ∈ set hfs ∧ (∃ainfo. (ainfo, hfs) ∈ auth_seg2 uinfo ∧ hf_valid ainfo uinfo hfs hf))))›*) ik_def (*‹ik = ik_hfs ∪ {uu_. ∃ainfo hfs uinfo. uu_ = id ainfo ∧ (ainfo, hfs) ∈ auth_seg2 uinfo} ∪ ik_uinfo ∪ Key ` macK ` bad ∪ {} ∪ {}›*) dest: ahi_eq (*‹⟦ASID ?ahi' = ASID ?ahi; ASIF (DownIF ?ahi') ?downif; ASIF (UpIF ?ahi') ?upif; ASIF (DownIF ?ahi) ?downif; ASIF (UpIF ?ahi) ?upif⟧ ⟹ ?ahi = ?ahi'›*)) (*goal: ‹∃hfs::(unit, unit) HF list. (hf::(unit, unit) HF) ∈ set hfs ∧ (∃uinfo'::msgterm. (ainfo::msgterm, hfs) ∈ auth_seg2 uinfo')›*) subgoal for ts' and hf' and hfs' apply (auto intro!: exI[of _ hfs'] (*‹?P hfs' ⟹ ∃x. ?P x›*)) (*goal: ‹⟦hf ∈ set hfs; ainfo = Num ts'; uinfo = ε; HVF hf = Mac[sntag (AHI hf)] (L (Num ts' # map (λx. hf2term (AHI x)) hfs)); hf' ∈ set hfs'; (Num ts', hfs') ∈ auth_seg2 ε; HVF hf' = Mac[sntag (AHI hf)] (L (Num ts' # map (λx. hf2term (AHI x)) hfs)); sntag (AHI hf') = sntag (AHI hf); map (λx. hf2term (AHI x)) hfs' = map (λx. hf2term (AHI x)) hfs⟧ ⟹ ∃hfs. hf ∈ set hfs ∧ (∃uinfo'. (Num ts', hfs) ∈ auth_seg2 uinfo')›*) apply (frule back_subst_set_member[where hfs="hfs'"] (*‹⟦?hf' ∈ set hfs'; ?hf' = ?hf⟧ ⟹ ?hf ∈ set hfs'›*)) (*goal: ‹⟦hf ∈ set hfs; ainfo = Num ts'; uinfo = ε; HVF hf = Mac[sntag (AHI hf)] (L (Num ts' # map (λx. hf2term (AHI x)) hfs)); hf' ∈ set hfs'; (Num ts', hfs') ∈ auth_seg2 ε; HVF hf' = Mac[sntag (AHI hf)] (L (Num ts' # map (λx. hf2term (AHI x)) hfs)); sntag (AHI hf') = sntag (AHI hf); map (λx. hf2term (AHI x)) hfs' = map (λx. hf2term (AHI x)) hfs⟧ ⟹ hf ∈ set hfs'›*) apply auto (*top goal: ‹⟦hf ∈ set hfs; ainfo = Num ts'; uinfo = ε; HVF hf = Mac[sntag (AHI hf)] (L (Num ts' # map (λx. hf2term (AHI x)) hfs)); hf' ∈ set hfs'; (Num ts', hfs') ∈ auth_seg2 ε; HVF hf' = Mac[sntag (AHI hf)] (L (Num ts' # map (λx. hf2term (AHI x)) hfs)); sntag (AHI hf') = sntag (AHI hf); map (λx. hf2term (AHI x)) hfs' = map (λx. hf2term (AHI x)) hfs⟧ ⟹ hf' = ?hf42› and 1 goal remains*) apply (rule HF.equality (*‹⟦AHI ?r = AHI ?r'; UHI ?r = UHI ?r'; HVF ?r = HVF ?r'; HF.more ?r = HF.more ?r'⟧ ⟹ ?r = ?r'›*)) (*goal: ‹⟦hf ∈ set hfs; ainfo = Num ts'; uinfo = ε; HVF hf = Mac[sntag (AHI hf)] (L (Num ts' # map (λx. hf2term (AHI x)) hfs)); hf' ∈ set hfs'; (Num ts', hfs') ∈ auth_seg2 ε; HVF hf' = Mac[sntag (AHI hf)] (L (Num ts' # map (λx. hf2term (AHI x)) hfs)); sntag (AHI hf') = sntag (AHI hf); map (λx. hf2term (AHI x)) hfs' = map (λx. hf2term (AHI x)) hfs⟧ ⟹ hf' = hf›*) apply auto (*top goal: ‹⟦hf ∈ set hfs; ainfo = Num ts'; uinfo = ε; HVF hf = Mac[sntag (AHI hf)] (L (Num ts' # map (λx. hf2term (AHI x)) hfs)); hf' ∈ set hfs'; (Num ts', hfs') ∈ auth_seg2 ε; HVF hf' = Mac[sntag (AHI hf)] (L (Num ts' # map (λx. hf2term (AHI x)) hfs)); sntag (AHI hf') = sntag (AHI hf); map (λx. hf2term (AHI x)) hfs' = map (λx. hf2term (AHI x)) hfs⟧ ⟹ AHI hf' = AHI hf› and 3 goals remain*) apply (drule sntag_asid (*‹sntag (?hf::ahi) = sntag (?hf'::ahi) ⟹ ASID ?hf' = ASID ?hf›*)) (*goal: ‹⟦hf ∈ set hfs; ainfo = Num ts'; uinfo = ε; HVF hf = Mac[sntag (AHI hf)] (L (Num ts' # map (λx. hf2term (AHI x)) hfs)); hf' ∈ set hfs'; (Num ts', hfs') ∈ auth_seg2 ε; HVF hf' = Mac[sntag (AHI hf)] (L (Num ts' # map (λx. hf2term (AHI x)) hfs)); sntag (AHI hf') = sntag (AHI hf); map (λx. hf2term (AHI x)) hfs' = map (λx. hf2term (AHI x)) hfs⟧ ⟹ AHI hf' = AHI hf›*) apply (drule map_hf2term_eq (*‹map (λx. hf2term (AHI x)) ?hfs = map (λx. hf2term (AHI x)) ?hfs' ⟹ AHIS ?hfs' = AHIS ?hfs›*)) (*goal: ‹⟦hf ∈ set hfs; ainfo = Num ts'; uinfo = ε; HVF hf = Mac[sntag (AHI hf)] (L (Num ts' # map (λx. hf2term (AHI x)) hfs)); hf' ∈ set hfs'; (Num ts', hfs') ∈ auth_seg2 ε; HVF hf' = Mac[sntag (AHI hf)] (L (Num ts' # map (λx. hf2term (AHI x)) hfs)); map (λx. hf2term (AHI x)) hfs' = map (λx. hf2term (AHI x)) hfs; ASID (AHI hf) = ASID (AHI hf')⟧ ⟹ AHI hf' = AHI hf›*) using auth_seg0_no_dups (*‹⟦(?ainfo::msgterm, ?hfs::ahi list) ∈ (auth_seg0::(msgterm × ahi list) set); (?hf::ahi) ∈ set ?hfs; (?hf'::ahi) ∈ set ?hfs; ASID ?hf' = ASID ?hf⟧ ⟹ ?hf' = ?hf›*) by (metis (mono_tags, lifting) AHIS_set_rev (*‹⦇AHI = ?ahi, UHI = ?uhi, HVF = ?x⦈ ∈ set ?hfs ⟹ ?ahi ∈ set (AHIS ?hfs)›*) HF.surjective (*‹?r = ⦇AHI = AHI ?r, UHI = UHI ?r, HVF = HVF ?r, … = HF.more ?r⦈›*) auth_seg20 (*‹(?x, ?y) ∈ auth_seg2 ?uinfo ⟹ (?x, AHIS ?y) ∈ auth_seg0›*) old.unit.exhaust (*‹(?y = () ⟹ ?P) ⟹ ?P›*)) . lemma COND_extr: "⟦hf_valid ainfo uinfo l hf⟧ ⟹ extr (HVF hf) = AHIS l" by (auto simp add: hf_valid_invert (*‹hf_valid ?tsn ?uinfo ?hfs ?hf = (∃ts ahi. ?tsn = Num ts ∧ ahi = AHI ?hf ∧ UHI ?hf = () ∧ HVF ?hf = Mac[sntag ahi] (L (Num ts # map (hf2term ∘ AHI) ?hfs)) ∧ ?uinfo = ε)›*)) lemma COND_hf_valid_uinfo: "⟦hf_valid ainfo uinfo l hf; hf_valid ainfo' uinfo' l' hf⟧ ⟹ uinfo' = uinfo" by (auto simp add: hf_valid_invert (*‹hf_valid ?tsn ?uinfo ?hfs ?hf = (∃ts ahi. ?tsn = Num ts ∧ ahi = AHI ?hf ∧ UHI ?hf = () ∧ HVF ?hf = Mac[sntag ahi] (L (Num ts # map (hf2term ∘ AHI) ?hfs)) ∧ ?uinfo = ε)›*)) (******************************************************************************) subsection‹Instantiation of @{text "dataplane_3_undirected"} locale› (******************************************************************************) print_locale dataplane_3_undirected sublocale dataplane_3_undirected _ _ _ auth_seg0 hf_valid auth_restrict extr extr_ainfo term_ainfo terms_uinfo ik_add terms_hf ik_oracle no_oracle apply unfold_locales (*goal: ‹dataplane_3_undirected bad tgtas tgtif auth_seg0 hf_valid auth_restrict extr id (λx. {x}) {} terms_hf {} (λ_ _. True)›*) using COND_terms_hf (*‹⟦hf_valid ?ainfo ?uinfo ?hfs ?hf; HVF ?hf ∈ ik; True; ?hf ∈ set ?hfs⟧ ⟹ ∃hfs. ?hf ∈ set hfs ∧ (∃uinfo'. (?ainfo, hfs) ∈ auth_seg2 uinfo')›*) COND_honest_hf_analz (*‹⟦ASID (AHI (?hf::(unit, unit) HF)) ∉ (bad::nat set); hf_valid (?ainfo::msgterm) (?uinfo::msgterm) (?hfs::(unit, unit) HF list) ?hf; terms_hf ?hf ⊆ synth (analz ik); True; ?hf ∈ set ?hfs⟧ ⟹ terms_hf ?hf ⊆ analz ik›*) COND_extr (*‹hf_valid ?ainfo ?uinfo ?l ?hf ⟹ extr (HVF ?hf) = AHIS ?l›*) COND_hf_valid_uinfo (*‹⟦hf_valid ?ainfo ?uinfo ?l ?hf; hf_valid ?ainfo' ?uinfo' ?l' ?hf⟧ ⟹ ?uinfo' = ?uinfo›*) apply - (*goals: 1. ‹⋀ainfo uinfo l hf. ⟦hf_valid ainfo uinfo l hf; terms_hf hf ⊆ analz ik; True; hf ∈ set l; ⋀ainfo uinfo hfs hf. ⟦hf_valid ainfo uinfo hfs hf; HVF hf ∈ ik; True; hf ∈ set hfs⟧ ⟹ ∃hfs. hf ∈ set hfs ∧ (∃uinfo'. (ainfo, hfs) ∈ auth_seg2 uinfo'); ⋀hf ainfo uinfo hfs. ⟦ASID (AHI hf) ∉ bad; hf_valid ainfo uinfo hfs hf; terms_hf hf ⊆ synth (analz ik); True; hf ∈ set hfs⟧ ⟹ terms_hf hf ⊆ analz ik; ⋀ainfo uinfo l hf. hf_valid ainfo uinfo l hf ⟹ extr (HVF hf) = AHIS l; ⋀ainfo uinfo l hf ainfo' uinfo' l'. ⟦hf_valid ainfo uinfo l hf; hf_valid ainfo' uinfo' l' hf⟧ ⟹ uinfo' = uinfo⟧ ⟹ ∃hfs. hf ∈ set hfs ∧ (∃uinfo'. (ainfo, hfs) ∈ auth_seg2 uinfo')› 2. ‹⋀hf ainfo uinfo l. ⟦ASID (AHI hf) ∉ bad; hf_valid ainfo uinfo l hf; terms_hf hf ⊆ synth (analz ik); True; hf ∈ set l; ⋀ainfo uinfo hfs hf. ⟦hf_valid ainfo uinfo hfs hf; HVF hf ∈ ik; True; hf ∈ set hfs⟧ ⟹ ∃hfs. hf ∈ set hfs ∧ (∃uinfo'. (ainfo, hfs) ∈ auth_seg2 uinfo'); ⋀hf ainfo uinfo hfs. ⟦ASID (AHI hf) ∉ bad; hf_valid ainfo uinfo hfs hf; terms_hf hf ⊆ synth (analz ik); True; hf ∈ set hfs⟧ ⟹ terms_hf hf ⊆ analz ik; ⋀ainfo uinfo l hf. hf_valid ainfo uinfo l hf ⟹ extr (HVF hf) = AHIS l; ⋀ainfo uinfo l hf ainfo' uinfo' l'. ⟦hf_valid ainfo uinfo l hf; hf_valid ainfo' uinfo' l' hf⟧ ⟹ uinfo' = uinfo⟧ ⟹ terms_hf hf ⊆ analz ik› 3. ‹⋀ainfo uinfo l hf. ⟦hf_valid ainfo uinfo l hf; ⋀ainfo uinfo hfs hf. ⟦hf_valid ainfo uinfo hfs hf; HVF hf ∈ ik; True; hf ∈ set hfs⟧ ⟹ ∃hfs. hf ∈ set hfs ∧ (∃uinfo'. (ainfo, hfs) ∈ auth_seg2 uinfo'); ⋀hf ainfo uinfo hfs. ⟦ASID (AHI hf) ∉ bad; hf_valid ainfo uinfo hfs hf; terms_hf hf ⊆ synth (analz ik); True; hf ∈ set hfs⟧ ⟹ terms_hf hf ⊆ analz ik; ⋀ainfo uinfo l hf. hf_valid ainfo uinfo l hf ⟹ extr (HVF hf) = AHIS l; ⋀ainfo uinfo l hf ainfo' uinfo' l'. ⟦hf_valid ainfo uinfo l hf; hf_valid ainfo' uinfo' l' hf⟧ ⟹ uinfo' = uinfo⟧ ⟹ extr (HVF hf) = AHIS l› 4. ‹⋀ainfo uinfo l hf ainfo' uinfo' l'. ⟦hf_valid ainfo uinfo l hf; hf_valid ainfo' uinfo' l' hf; ⋀ainfo uinfo hfs hf. ⟦hf_valid ainfo uinfo hfs hf; HVF hf ∈ ik; True; hf ∈ set hfs⟧ ⟹ ∃hfs. hf ∈ set hfs ∧ (∃uinfo'. (ainfo, hfs) ∈ auth_seg2 uinfo'); ⋀hf ainfo uinfo hfs. ⟦ASID (AHI hf) ∉ bad; hf_valid ainfo uinfo hfs hf; terms_hf hf ⊆ synth (analz ik); True; hf ∈ set hfs⟧ ⟹ terms_hf hf ⊆ analz ik; ⋀ainfo uinfo l hf. hf_valid ainfo uinfo l hf ⟹ extr (HVF hf) = AHIS l; ⋀ainfo uinfo l hf ainfo' uinfo' l'. ⟦hf_valid ainfo uinfo l hf; hf_valid ainfo' uinfo' l' hf⟧ ⟹ uinfo' = uinfo⟧ ⟹ uinfo' = uinfo› 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 end
{ "path": "afp-2025-02-12/thys/IsaNet/instances/ICING_variant2.thy", "repo": "afp-2025-02-12", "sha": "0689510c4c94740ab99395a73e0529ad8de3c1f1efc7de881348b95b8da97d6c" }
(* Title: HOL/Library/While_Combinator.thy Author: Tobias Nipkow Author: Alexander Krauss *) section ‹A general ``while'' combinator› theory While_Combinator imports Main begin subsection ‹Partial version› definition while_option :: "('a ⇒ bool) ⇒ ('a ⇒ 'a) ⇒ 'a ⇒ 'a option" where "while_option b c s = (if (∃k. ¬ b ((c ^^ k) s)) then Some ((c ^^ (LEAST k. ¬ b ((c ^^ k) s))) s) else None)" theorem while_option_unfold[code]: "while_option b c s = (if b s then while_option b c (c s) else Some s)" proof (cases) (*goals: 1. ‹?P ⟹ while_option b c s = (if b s then while_option b c (c s) else Some s)› 2. ‹¬ ?P ⟹ while_option b c s = (if b s then while_option b c (c s) else Some s)›*) assume "b s" (*‹(b::'a ⇒ bool) (s::'a)›*) show "?thesis" (*goal: ‹while_option (b::'a::type ⇒ bool) (c::'a::type ⇒ 'a::type) (s::'a::type) = (if b s then while_option b c (c s) else Some s)›*) proof (cases "∃k. ¬ b ((c ^^ k) s)") (*goals: 1. ‹∃k::nat. ¬ (b::'a ⇒ bool) (((c::'a ⇒ 'a) ^^ k) (s::'a)) ⟹ while_option b c s = (if b s then while_option b c (c s) else Some s)› 2. ‹∄k::nat. ¬ (b::'a ⇒ bool) (((c::'a ⇒ 'a) ^^ k) (s::'a)) ⟹ while_option b c s = (if b s then while_option b c (c s) else Some s)›*) case True (*‹∃k::nat. ¬ (b::'a ⇒ bool) (((c::'a ⇒ 'a) ^^ k) (s::'a))›*) then obtain k where 1: "¬ b ((c ^^ k) s)" (*goal: ‹(⋀k::nat. ¬ (b::'a ⇒ bool) (((c::'a ⇒ 'a) ^^ k) (s::'a)) ⟹ thesis::bool) ⟹ thesis›*) by standard with ‹b s› (*‹b s›*) obtain l where "k = Suc l" (*goal: ‹(⋀l. k = Suc l ⟹ thesis) ⟹ thesis›*) apply (cases k) (*goals: 1. ‹⟦⋀l. k = Suc l ⟹ thesis; b s; ¬ b ((c ^^ k) s); k = 0⟧ ⟹ thesis› 2. ‹⋀nat. ⟦⋀l. k = Suc l ⟹ thesis; b s; ¬ b ((c ^^ k) s); k = Suc nat⟧ ⟹ thesis› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . with "1" (*‹¬ b ((c ^^ k) s)›*) have "¬ b ((c ^^ l) (c s))" by (auto simp: funpow_swap1 (*‹(?f::?'a::type ⇒ ?'a::type) ((?f ^^ (?n::nat)) (?x::?'a::type)) = (?f ^^ ?n) (?f ?x)›*)) then have 2: "∃l. ¬ b ((c ^^ l) (c s))" apply - (*goal: ‹∃l. ¬ b ((c ^^ l) (c s))›*) by standard from "1" (*‹¬ (b::'a ⇒ bool) (((c::'a ⇒ 'a) ^^ (k::nat)) (s::'a))›*) have "(LEAST k. ¬ b ((c ^^ k) s)) = Suc (LEAST l. ¬ b ((c ^^ Suc l) s))" apply (rule Least_Suc (*‹⟦?P ?n; ¬ ?P 0⟧ ⟹ (LEAST n. ?P n) = Suc (LEAST m. ?P (Suc m))›*)) (*goal: ‹(LEAST k. ¬ b ((c ^^ k) s)) = Suc (LEAST l. ¬ b ((c ^^ Suc l) s))›*) by (simp add: ‹b s›) also (*calculation: ‹(LEAST k. ¬ b ((c ^^ k) s)) = Suc (LEAST l. ¬ b ((c ^^ Suc l) s))›*) have "... = Suc (LEAST l. ¬ b ((c ^^ l) (c s)))" by (simp add: funpow_swap1 (*‹(?f::?'a ⇒ ?'a) ((?f ^^ (?n::nat)) (?x::?'a)) = (?f ^^ ?n) (?f ?x)›*)) finally (*calculation: ‹(LEAST k. ¬ b ((c ^^ k) s)) = Suc (LEAST l. ¬ b ((c ^^ l) (c s)))›*) show "?thesis" (*goal: ‹while_option b c s = (if b s then while_option b c (c s) else Some s)›*) using True (*‹∃k. ¬ b ((c ^^ k) s)›*) "2" (*‹∃l. ¬ b ((c ^^ l) (c s))›*) ‹b s› (*‹b s›*) by (simp add: funpow_swap1 (*‹?f ((?f ^^ ?n) ?x) = (?f ^^ ?n) (?f ?x)›*) while_option_def (*‹while_option ?b ?c ?s = (if ∃k. ¬ ?b ((?c ^^ k) ?s) then Some ((?c ^^ (LEAST k. ¬ ?b ((?c ^^ k) ?s))) ?s) else None)›*)) next (*goal: ‹∄k. ¬ b ((c ^^ k) s) ⟹ while_option b c s = (if b s then while_option b c (c s) else Some s)›*) case False (*‹∄k. ¬ b ((c ^^ k) s)›*) then have "¬ (∃l. ¬ b ((c ^^ Suc l) s))" by blast then have "¬ (∃l. ¬ b ((c ^^ l) (c s)))" by (simp add: funpow_swap1 (*‹?f ((?f ^^ ?n) ?x) = (?f ^^ ?n) (?f ?x)›*)) with False (*‹∄k. ¬ b ((c ^^ k) s)›*) ‹b s› (*‹b s›*) show "?thesis" (*goal: ‹while_option b c s = (if b s then while_option b c (c s) else Some s)›*) by (simp add: while_option_def (*‹while_option ?b ?c ?s = (if ∃k. ¬ ?b ((?c ^^ k) ?s) then Some ((?c ^^ (LEAST k. ¬ ?b ((?c ^^ k) ?s))) ?s) else None)›*)) qed next (*goal: ‹¬ b s ⟹ while_option b c s = (if b s then while_option b c (c s) else Some s)›*) assume [simp]: "¬ b s" (*‹¬ (b::'a ⇒ bool) (s::'a)›*) have least: "(LEAST k. ¬ b ((c ^^ k) s)) = 0" apply (rule Least_equality (*‹⟦?P ?x; ⋀y. ?P y ⟹ ?x ≤ y⟧ ⟹ Least ?P = ?x›*)) (*goals: 1. ‹¬ b ((c ^^ 0) s)› 2. ‹⋀y. ¬ b ((c ^^ y) s) ⟹ 0 ≤ y› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . moreover have "∃k. ¬ b ((c ^^ k) s)" apply (rule exI[of _ "0::nat"] (*‹?P 0 ⟹ ∃x. ?P x›*)) (*goal: ‹∃k. ¬ b ((c ^^ k) s)›*) by auto ultimately show "?thesis" (*goal: ‹while_option b c s = (if b s then while_option b c (c s) else Some s)›*) unfolding while_option_def (*goal: ‹(if ∃k. ¬ b ((c ^^ k) s) then Some ((c ^^ (LEAST k. ¬ b ((c ^^ k) s))) s) else None) = (if b s then if ∃k. ¬ b ((c ^^ k) (c s)) then Some ((c ^^ (LEAST k. ¬ b ((c ^^ k) (c s)))) (c s)) else None else Some s)›*) by auto qed lemma while_option_stop2: "while_option b c s = Some t ⟹ ∃k. t = (c^^k) s ∧ ¬ b t" apply (simp add: while_option_def (*‹while_option (?b::?'a ⇒ bool) (?c::?'a ⇒ ?'a) (?s::?'a) = (if ∃k::nat. ¬ ?b ((?c ^^ k) ?s) then Some ((?c ^^ (LEAST k::nat. ¬ ?b ((?c ^^ k) ?s))) ?s) else None)›*) 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))›*)) (*goal: ‹while_option b c s = Some t ⟹ ∃k. t = (c ^^ k) s ∧ ¬ b t›*) by (metis (lifting) LeastI_ex (*‹∃x. ?P x ⟹ ?P (Least ?P)›*)) lemma while_option_stop: "while_option b c s = Some t ⟹ ¬ b t" by (metis while_option_stop2 (*‹while_option ?b ?c ?s = Some ?t ⟹ ∃k. ?t = (?c ^^ k) ?s ∧ ¬ ?b ?t›*)) theorem while_option_rule: assumes step: "!!s. P s ==> b s ==> P (c s)" and result: "while_option b c s = Some t" and init: "P s" shows "P t" proof (-) (*goal: ‹(P::'a::type ⇒ bool) (t::'a::type)›*) define k where "k = (LEAST k. ¬ b ((c ^^ k) s))" from assms (*‹⟦P ?s; b ?s⟧ ⟹ P (c ?s)› ‹while_option (b::'a::type ⇒ bool) (c::'a::type ⇒ 'a::type) (s::'a::type) = Some (t::'a::type)› ‹P s›*) have t: "t = (c ^^ k) s" by (simp add: while_option_def (*‹while_option (?b::?'a ⇒ bool) (?c::?'a ⇒ ?'a) (?s::?'a) = (if ∃k::nat. ¬ ?b ((?c ^^ k) ?s) then Some ((?c ^^ (LEAST k::nat. ¬ ?b ((?c ^^ k) ?s))) ?s) else None)›*) k_def (*‹(k::nat) = (LEAST k::nat. ¬ (b::'a ⇒ bool) (((c::'a ⇒ 'a) ^^ k) (s::'a)))›*) 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))›*)) have 1: "∀i<k. b ((c ^^ i) s)" by (auto simp: k_def (*‹k = (LEAST k. ¬ b ((c ^^ k) s))›*) dest: not_less_Least (*‹?k < (LEAST x. ?P x) ⟹ ¬ ?P ?k›*)) { fix i assume "i ≤ k" (*‹(i::nat) ≤ (k::nat)›*) then have "P ((c ^^ i) s)" apply (induct i) (*goals: 1. ‹0 ≤ k ⟹ P ((c ^^ 0) s)› 2. ‹⋀i. ⟦i ≤ k ⟹ P ((c ^^ i) s); Suc i ≤ k⟧ ⟹ P ((c ^^ Suc i) s)› discuss goal 1*) apply ((auto simp: init (*‹P s›*) step (*‹⟦P ?s; b ?s⟧ ⟹ P (c ?s)›*) 1 (*‹∀i<k. b ((c ^^ i) s)›*))[1]) (*discuss goal 2*) apply ((auto simp: init (*‹P s›*) step (*‹⟦P ?s; b ?s⟧ ⟹ P (c ?s)›*) 1 (*‹∀i<k. b ((c ^^ i) s)›*))[1]) (*proven 2 subgoals*) . } thus "P t" by (auto simp: t (*‹t = (c ^^ k) s›*)) qed lemma funpow_commute: "⟦∀k' < k. f (c ((c^^k') s)) = c' (f ((c^^k') s))⟧ ⟹ f ((c^^k) s) = (c'^^k) (f s)" apply (induct k arbitrary: s) (*goals: 1. ‹⋀s. ∀k'<0. f (c ((c ^^ k') s)) = c' (f ((c ^^ k') s)) ⟹ f ((c ^^ 0) s) = (c' ^^ 0) (f s)› 2. ‹⋀k s. ⟦⋀s. ∀k'<k. f (c ((c ^^ k') s)) = c' (f ((c ^^ k') s)) ⟹ f ((c ^^ k) s) = (c' ^^ k) (f s); ∀k'<Suc k. f (c ((c ^^ k') s)) = c' (f ((c ^^ k') s))⟧ ⟹ f ((c ^^ Suc k) s) = (c' ^^ Suc k) (f s)› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . lemma while_option_commute_invariant: assumes Invariant: "⋀s. P s ⟹ b s ⟹ P (c s)" assumes TestCommute: "⋀s. P s ⟹ b s = b' (f s)" assumes BodyCommute: "⋀s. P s ⟹ b s ⟹ f (c s) = c' (f s)" assumes Initial: "P s" shows "map_option f (while_option b c s) = while_option b' c' (f s)" unfolding while_option_def (*goal: ‹map_option f (if ∃k. ¬ b ((c ^^ k) s) then Some ((c ^^ (LEAST k. ¬ b ((c ^^ k) s))) s) else None) = (if ∃k. ¬ b' ((c' ^^ k) (f s)) then Some ((c' ^^ (LEAST k. ¬ b' ((c' ^^ k) (f s)))) (f s)) else None)›*) proof (rule trans[OF if_distrib if_cong] (*‹⟦?b1 = ?c1; ?c1 ⟹ ?f2 ?x2 = ?u1; ¬ ?c1 ⟹ ?f2 ?y2 = ?v1⟧ ⟹ ?f2 (if ?b1 then ?x2 else ?y2) = (if ?c1 then ?u1 else ?v1)›*), safe, unfold option.inject (*‹(Some (?x2.0::?'a) = Some (?y2.0::?'a)) = (?x2.0 = ?y2.0)›*)) (*goals: 1. ‹⋀k. ¬ b ((c ^^ k) s) ⟹ ∃k. ¬ b' ((c' ^^ k) (f s))› 2. ‹⋀k. ¬ b' ((c' ^^ k) (f s)) ⟹ ∃k. ¬ b ((c ^^ k) s)› 3. ‹⋀k. ¬ b' ((c' ^^ k) (f s)) ⟹ ∃z. (c ^^ (LEAST k. ¬ b ((c ^^ k) s))) s = z ∧ f z = (c' ^^ (LEAST k. ¬ b' ((c' ^^ k) (f s)))) (f s)›*) fix k assume "¬ b ((c ^^ k) s)" (*‹¬ (b::'a ⇒ bool) (((c::'a ⇒ 'a) ^^ (k::nat)) (s::'a))›*) with Initial (*‹P s›*) show "∃k. ¬ b' ((c' ^^ k) (f s))" proof (induction k arbitrary: s) (*goals: 1. ‹⋀s. ⟦P s; ¬ b ((c ^^ 0) s)⟧ ⟹ ∃k. ¬ b' ((c' ^^ k) (f s))› 2. ‹⋀k s. ⟦⋀s. ⟦P s; ¬ b ((c ^^ k) s)⟧ ⟹ ∃k. ¬ b' ((c' ^^ k) (f s)); P s; ¬ b ((c ^^ Suc k) s)⟧ ⟹ ∃k. ¬ b' ((c' ^^ k) (f s))›*) case 0 (*‹P s› ‹¬ b ((c ^^ 0) s)›*) thus "?case" (*goal: ‹∃k. ¬ b' ((c' ^^ k) (f s))›*) by (auto simp: TestCommute (*‹P ?s ⟹ b ?s = b' (f ?s)›*) intro: exI[of _ 0] (*‹?P 0 ⟹ ∃x. ?P x›*)) next (*goal: ‹⋀k s. ⟦⋀s. ⟦P s; ¬ b ((c ^^ k) s)⟧ ⟹ ∃k. ¬ b' ((c' ^^ k) (f s)); P s; ¬ b ((c ^^ Suc k) s)⟧ ⟹ ∃k. ¬ b' ((c' ^^ k) (f s))›*) case (Suc k) (*‹⟦P ?s; ¬ b ((c ^^ k) ?s)⟧ ⟹ ∃k. ¬ b' ((c' ^^ k) (f ?s))› ‹P s› ‹¬ b ((c ^^ Suc k) s)›*) thus "?case" (*goal: ‹∃k. ¬ b' ((c' ^^ k) (f s))›*) proof (cases "b s") (*goals: 1. ‹⟦⋀s. ⟦P s; ¬ b ((c ^^ k) s)⟧ ⟹ ∃k. ¬ b' ((c' ^^ k) (f s)); P s; ¬ b ((c ^^ Suc k) s); b s⟧ ⟹ ∃k. ¬ b' ((c' ^^ k) (f s))› 2. ‹⟦⋀s. ⟦P s; ¬ b ((c ^^ k) s)⟧ ⟹ ∃k. ¬ b' ((c' ^^ k) (f s)); P s; ¬ b ((c ^^ Suc k) s); ¬ b s⟧ ⟹ ∃k. ¬ b' ((c' ^^ k) (f s))›*) assume "b s" (*‹(b::'a ⇒ bool) (s::'a)›*) with Suc.IH[of "c s"] (*‹⟦(P::'a ⇒ bool) ((c::'a ⇒ 'a) (s::'a)); ¬ (b::'a ⇒ bool) ((c ^^ (k::nat)) (c s))⟧ ⟹ ∃k::nat. ¬ (b'::'b ⇒ bool) (((c'::'b ⇒ 'b) ^^ k) ((f::'a ⇒ 'b) (c s)))›*) Suc.prems (*‹(P::'a ⇒ bool) (s::'a)› ‹¬ b ((c ^^ Suc k) s)›*) show "?thesis" (*goal: ‹∃k. ¬ b' ((c' ^^ k) (f s))›*) by (metis BodyCommute (*‹⟦P ?s; b ?s⟧ ⟹ f (c ?s) = c' (f ?s)›*) Invariant (*‹⟦P ?s; b ?s⟧ ⟹ P (c ?s)›*) comp_apply (*‹(?f ∘ ?g) ?x = ?f (?g ?x)›*) funpow.simps( (*‹?f ^^ Suc ?n = ?f ∘ ?f ^^ ?n›*) 2) funpow_swap1 (*‹?f ((?f ^^ ?n) ?x) = (?f ^^ ?n) (?f ?x)›*)) next (*goal: ‹⟦⋀s. ⟦P s; ¬ b ((c ^^ k) s)⟧ ⟹ ∃k. ¬ b' ((c' ^^ k) (f s)); P s; ¬ b ((c ^^ Suc k) s); ¬ b s⟧ ⟹ ∃k. ¬ b' ((c' ^^ k) (f s))›*) assume "¬ b s" (*‹¬ (b::'a ⇒ bool) (s::'a)›*) with Suc (*‹⟦P ?s; ¬ b ((c ^^ k) ?s)⟧ ⟹ ∃k. ¬ b' ((c' ^^ k) (f ?s))› ‹P s› ‹¬ b ((c ^^ Suc k) s)›*) show "?thesis" (*goal: ‹∃k::nat. ¬ (b'::'b ⇒ bool) (((c'::'b ⇒ 'b) ^^ k) ((f::'a ⇒ 'b) (s::'a)))›*) by (auto simp: TestCommute (*‹P ?s ⟹ b ?s = b' (f ?s)›*) intro: exI [of _ 0] (*‹?P 0 ⟹ ∃x. ?P x›*)) qed qed next (*goals: 1. ‹⋀k. ¬ b' ((c' ^^ k) (f s)) ⟹ ∃k. ¬ b ((c ^^ k) s)› 2. ‹⋀k. ¬ b' ((c' ^^ k) (f s)) ⟹ ∃z. (c ^^ (LEAST k. ¬ b ((c ^^ k) s))) s = z ∧ f z = (c' ^^ (LEAST k. ¬ b' ((c' ^^ k) (f s)))) (f s)›*) fix k assume "¬ b' ((c' ^^ k) (f s))" (*‹¬ (b'::'b ⇒ bool) (((c'::'b ⇒ 'b) ^^ (k::nat)) ((f::'a ⇒ 'b) (s::'a)))›*) with Initial (*‹P s›*) show "∃k. ¬ b ((c ^^ k) s)" proof (induction k arbitrary: s) (*goals: 1. ‹⋀s. ⟦P s; ¬ b' ((c' ^^ 0) (f s))⟧ ⟹ ∃k. ¬ b ((c ^^ k) s)› 2. ‹⋀k s. ⟦⋀s. ⟦P s; ¬ b' ((c' ^^ k) (f s))⟧ ⟹ ∃k. ¬ b ((c ^^ k) s); P s; ¬ b' ((c' ^^ Suc k) (f s))⟧ ⟹ ∃k. ¬ b ((c ^^ k) s)›*) case 0 (*‹P s› ‹¬ b' ((c' ^^ 0) (f s))›*) thus "?case" (*goal: ‹∃k. ¬ b ((c ^^ k) s)›*) by (auto simp: TestCommute (*‹P ?s ⟹ b ?s = b' (f ?s)›*) intro: exI[of _ 0] (*‹?P 0 ⟹ ∃x. ?P x›*)) next (*goal: ‹⋀k s. ⟦⋀s. ⟦P s; ¬ b' ((c' ^^ k) (f s))⟧ ⟹ ∃k. ¬ b ((c ^^ k) s); P s; ¬ b' ((c' ^^ Suc k) (f s))⟧ ⟹ ∃k. ¬ b ((c ^^ k) s)›*) case (Suc k) (*‹⟦P ?s; ¬ b' ((c' ^^ k) (f ?s))⟧ ⟹ ∃k. ¬ b ((c ^^ k) ?s)› ‹P s› ‹¬ b' ((c' ^^ Suc k) (f s))›*) thus "?case" (*goal: ‹∃k. ¬ b ((c ^^ k) s)›*) proof (cases "b s") (*goals: 1. ‹⟦⋀s. ⟦P s; ¬ b' ((c' ^^ k) (f s))⟧ ⟹ ∃k. ¬ b ((c ^^ k) s); P s; ¬ b' ((c' ^^ Suc k) (f s)); b s⟧ ⟹ ∃k. ¬ b ((c ^^ k) s)› 2. ‹⟦⋀s. ⟦P s; ¬ b' ((c' ^^ k) (f s))⟧ ⟹ ∃k. ¬ b ((c ^^ k) s); P s; ¬ b' ((c' ^^ Suc k) (f s)); ¬ b s⟧ ⟹ ∃k. ¬ b ((c ^^ k) s)›*) assume "b s" (*‹(b::'a ⇒ bool) (s::'a)›*) with Suc.IH[of "c s"] (*‹⟦P (c s); ¬ b' ((c' ^^ k) (f (c s)))⟧ ⟹ ∃k. ¬ b ((c ^^ k) (c s))›*) Suc.prems (*‹P s› ‹¬ (b'::'b ⇒ bool) (((c'::'b ⇒ 'b) ^^ Suc (k::nat)) ((f::'a ⇒ 'b) (s::'a)))›*) show "?thesis" (*goal: ‹∃k::nat. ¬ (b::'a::type ⇒ bool) (((c::'a::type ⇒ 'a::type) ^^ k) (s::'a::type))›*) by (metis BodyCommute (*‹⟦P ?s; b ?s⟧ ⟹ f (c ?s) = c' (f ?s)›*) Invariant (*‹⟦P ?s; b ?s⟧ ⟹ P (c ?s)›*) comp_apply (*‹(?f ∘ ?g) ?x = ?f (?g ?x)›*) funpow.simps( (*‹?f ^^ Suc ?n = ?f ∘ ?f ^^ ?n›*) 2) funpow_swap1 (*‹?f ((?f ^^ ?n) ?x) = (?f ^^ ?n) (?f ?x)›*)) next (*goal: ‹⟦⋀s. ⟦P s; ¬ b' ((c' ^^ k) (f s))⟧ ⟹ ∃k. ¬ b ((c ^^ k) s); P s; ¬ b' ((c' ^^ Suc k) (f s)); ¬ b s⟧ ⟹ ∃k. ¬ b ((c ^^ k) s)›*) assume "¬ b s" (*‹¬ (b::'a ⇒ bool) (s::'a)›*) with Suc (*‹⟦P ?s; ¬ b' ((c' ^^ k) (f ?s))⟧ ⟹ ∃k. ¬ b ((c ^^ k) ?s)› ‹P s› ‹¬ b' ((c' ^^ Suc k) (f s))›*) show "?thesis" (*goal: ‹∃k. ¬ b ((c ^^ k) s)›*) by (auto simp: TestCommute (*‹(P::'a ⇒ bool) (?s::'a) ⟹ (b::'a ⇒ bool) ?s = (b'::'b ⇒ bool) ((f::'a ⇒ 'b) ?s)›*) intro: exI [of _ 0] (*‹(?P::?'c1 ⇒ bool) (0::?'c1) ⟹ ∃x::?'c1. ?P x›*)) qed qed next (*goal: ‹⋀k::nat. ¬ (b'::'b ⇒ bool) (((c'::'b ⇒ 'b) ^^ k) ((f::'a ⇒ 'b) (s::'a))) ⟹ ∃z::'a. ((c::'a ⇒ 'a) ^^ (LEAST k::nat. ¬ (b::'a ⇒ bool) ((c ^^ k) s))) s = z ∧ f z = (c' ^^ (LEAST k::nat. ¬ b' ((c' ^^ k) (f s)))) (f s)›*) fix k assume k: "¬ b' ((c' ^^ k) (f s))" (*‹¬ (b'::'b ⇒ bool) (((c'::'b ⇒ 'b) ^^ (k::nat)) ((f::'a ⇒ 'b) (s::'a)))›*) have "*": "(LEAST k. ¬ b' ((c' ^^ k) (f s))) = (LEAST k. ¬ b ((c ^^ k) s))" (is "?k' = ?k") proof (cases ?k') (*goals: 1. ‹(LEAST k. ¬ b' ((c' ^^ k) (f s))) = 0 ⟹ (LEAST k. ¬ b' ((c' ^^ k) (f s))) = (LEAST k. ¬ b ((c ^^ k) s))› 2. ‹⋀nat. (LEAST k. ¬ b' ((c' ^^ k) (f s))) = Suc nat ⟹ (LEAST k. ¬ b' ((c' ^^ k) (f s))) = (LEAST k. ¬ b ((c ^^ k) s))›*) case 0 (*‹(LEAST k. ¬ b' ((c' ^^ k) (f s))) = 0›*) have "¬ b' ((c' ^^ 0) (f s))" unfolding "0"[symmetric] (*goal: ‹¬ b' ((c' ^^ (LEAST k. ¬ b' ((c' ^^ k) (f s)))) (f s))›*) apply (rule LeastI[of _ k] (*‹?P k ⟹ ?P (LEAST x. ?P x)›*)) (*goal: ‹¬ b' ((c' ^^ (LEAST k. ¬ b' ((c' ^^ k) (f s)))) (f s))›*) by (rule k (*‹¬ b' ((c' ^^ k) (f s))›*)) hence "¬ b s" by (auto simp: TestCommute (*‹P ?s ⟹ b ?s = b' (f ?s)›*) Initial (*‹P s›*)) hence "?k = 0" apply (intro Least_equality (*‹⟦?P ?x; ⋀y. ?P y ⟹ ?x ≤ y⟧ ⟹ Least ?P = ?x›*)) (*goals: 1. ‹¬ b s ⟹ ¬ b ((c ^^ 0) s)› 2. ‹⋀y. ⟦¬ b s; ¬ b ((c ^^ y) s)⟧ ⟹ 0 ≤ y› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . with "0" (*‹(LEAST k. ¬ b' ((c' ^^ k) (f s))) = 0›*) show "?thesis" (*goal: ‹(LEAST k::nat. ¬ (b'::'b::type ⇒ bool) (((c'::'b::type ⇒ 'b::type) ^^ k) ((f::'a::type ⇒ 'b::type) (s::'a::type)))) = (LEAST k::nat. ¬ (b::'a::type ⇒ bool) (((c::'a::type ⇒ 'a::type) ^^ k) s))›*) by auto next (*goal: ‹⋀nat. (LEAST k. ¬ b' ((c' ^^ k) (f s))) = Suc nat ⟹ (LEAST k. ¬ b' ((c' ^^ k) (f s))) = (LEAST k. ¬ b ((c ^^ k) s))›*) case (Suc k') (*‹(LEAST k. ¬ b' ((c' ^^ k) (f s))) = Suc k'›*) have "¬ b' ((c' ^^ Suc k') (f s))" unfolding Suc[symmetric] (*goal: ‹¬ b' ((c' ^^ (LEAST k. ¬ b' ((c' ^^ k) (f s)))) (f s))›*) apply (rule LeastI (*‹?P ?k ⟹ ?P (LEAST x. ?P x)›*)) (*goal: ‹¬ (b'::'b ⇒ bool) (((c'::'b ⇒ 'b) ^^ (LEAST k::nat. ¬ b' ((c' ^^ k) ((f::'a ⇒ 'b) (s::'a))))) (f s))›*) by (rule k (*‹¬ b' ((c' ^^ k) (f s))›*)) moreover { fix k assume "k ≤ k'" (*‹(k::nat) ≤ (k'::nat)›*) hence "k < ?k'" unfolding Suc (*goal: ‹k < Suc k'›*) by simp hence "b' ((c' ^^ k) (f s))" by (rule iffD1[OF not_not, OF not_less_Least] (*‹?k2 < (LEAST x. ¬ ?P3 x) ⟹ ?P3 ?k2›*)) } note b' = this (*‹(?ka2::nat) ≤ (k'::nat) ⟹ (b'::'b ⇒ bool) (((c'::'b ⇒ 'b) ^^ ?ka2) ((f::'a ⇒ 'b) (s::'a)))›*) { fix k assume "k ≤ k'" (*‹(k::nat) ≤ (k'::nat)›*) hence "f ((c ^^ k) s) = (c' ^^ k) (f s)" and "b ((c ^^ k) s) = b' ((c' ^^ k) (f s))" and "P ((c ^^ k) s)" apply (induct k) (*goals: 1. ‹0 ≤ k' ⟹ f ((c ^^ 0) s) = (c' ^^ 0) (f s)› 2. ‹0 ≤ k' ⟹ b ((c ^^ 0) s) = b' ((c' ^^ 0) (f s))› 3. ‹0 ≤ k' ⟹ P ((c ^^ 0) s)› 4. ‹⋀k. ⟦k ≤ k' ⟹ f ((c ^^ k) s) = (c' ^^ k) (f s); k ≤ k' ⟹ b ((c ^^ k) s) = b' ((c' ^^ k) (f s)); k ≤ k' ⟹ P ((c ^^ k) s); Suc k ≤ k'⟧ ⟹ f ((c ^^ Suc k) s) = (c' ^^ Suc k) (f s)› 5. ‹⋀k. ⟦k ≤ k' ⟹ f ((c ^^ k) s) = (c' ^^ k) (f s); k ≤ k' ⟹ b ((c ^^ k) s) = b' ((c' ^^ k) (f s)); k ≤ k' ⟹ P ((c ^^ k) s); Suc k ≤ k'⟧ ⟹ b ((c ^^ Suc k) s) = b' ((c' ^^ Suc k) (f s))› 6. ‹⋀k. ⟦k ≤ k' ⟹ f ((c ^^ k) s) = (c' ^^ k) (f s); k ≤ k' ⟹ b ((c ^^ k) s) = b' ((c' ^^ k) (f s)); k ≤ k' ⟹ P ((c ^^ k) s); Suc k ≤ k'⟧ ⟹ P ((c ^^ Suc k) s)› discuss goal 1*) apply ((auto simp: b' (*‹?ka2 ≤ k' ⟹ b' ((c' ^^ ?ka2) (f s))›*) assms (*‹⟦P ?s; b ?s⟧ ⟹ P (c ?s)› ‹P ?s ⟹ b ?s = b' (f ?s)› ‹⟦P ?s; b ?s⟧ ⟹ f (c ?s) = c' (f ?s)› ‹P s›*))[1]) (*discuss goal 2*) apply ((auto simp: b' (*‹(?ka2::nat) ≤ (k'::nat) ⟹ (b'::'b ⇒ bool) (((c'::'b ⇒ 'b) ^^ ?ka2) ((f::'a ⇒ 'b) (s::'a)))›*) assms (*‹⟦(P::'a ⇒ bool) (?s::'a); (b::'a ⇒ bool) ?s⟧ ⟹ P ((c::'a ⇒ 'a) ?s)› ‹(P::'a ⇒ bool) (?s::'a) ⟹ (b::'a ⇒ bool) ?s = (b'::'b ⇒ bool) ((f::'a ⇒ 'b) ?s)› ‹⟦(P::'a ⇒ bool) (?s::'a); (b::'a ⇒ bool) ?s⟧ ⟹ (f::'a ⇒ 'b) ((c::'a ⇒ 'a) ?s) = (c'::'b ⇒ 'b) (f ?s)› ‹(P::'a ⇒ bool) (s::'a)›*))[1]) (*discuss goal 3*) apply ((auto simp: b' (*‹?ka2 ≤ k' ⟹ b' ((c' ^^ ?ka2) (f s))›*) assms (*‹⟦P ?s; b ?s⟧ ⟹ P (c ?s)› ‹P ?s ⟹ b ?s = b' (f ?s)› ‹⟦P ?s; b ?s⟧ ⟹ f (c ?s) = c' (f ?s)› ‹P s›*))[1]) (*discuss goal 4*) apply ((auto simp: b' (*‹?ka2 ≤ k' ⟹ b' ((c' ^^ ?ka2) (f s))›*) assms (*‹⟦P ?s; b ?s⟧ ⟹ P (c ?s)› ‹P ?s ⟹ b ?s = b' (f ?s)› ‹⟦P ?s; b ?s⟧ ⟹ f (c ?s) = c' (f ?s)› ‹P s›*))[1]) (*discuss goal 5*) apply ((auto simp: b' (*‹?ka2 ≤ k' ⟹ b' ((c' ^^ ?ka2) (f s))›*) assms (*‹⟦P ?s; b ?s⟧ ⟹ P (c ?s)› ‹P ?s ⟹ b ?s = b' (f ?s)› ‹⟦P ?s; b ?s⟧ ⟹ f (c ?s) = c' (f ?s)› ‹P s›*))[1]) (*discuss goal 6*) apply ((auto simp: b' (*‹?ka2 ≤ k' ⟹ b' ((c' ^^ ?ka2) (f s))›*) assms (*‹⟦P ?s; b ?s⟧ ⟹ P (c ?s)› ‹P ?s ⟹ b ?s = b' (f ?s)› ‹⟦P ?s; b ?s⟧ ⟹ f (c ?s) = c' (f ?s)› ‹P s›*))[1]) (*proven 6 subgoals*) . with ‹k ≤ k'› (*‹k ≤ k'›*) have "b ((c ^^ k) s)" and "f ((c ^^ k) s) = (c' ^^ k) (f s)" and "P ((c ^^ k) s)" apply - (*goals: 1. ‹⟦k ≤ k'; f ((c ^^ k) s) = (c' ^^ k) (f s); b ((c ^^ k) s) = b' ((c' ^^ k) (f s)); P ((c ^^ k) s)⟧ ⟹ b ((c ^^ k) s)› 2. ‹⟦k ≤ k'; f ((c ^^ k) s) = (c' ^^ k) (f s); b ((c ^^ k) s) = b' ((c' ^^ k) (f s)); P ((c ^^ k) s)⟧ ⟹ f ((c ^^ k) s) = (c' ^^ k) (f s)› 3. ‹⟦k ≤ k'; f ((c ^^ k) s) = (c' ^^ k) (f s); b ((c ^^ k) s) = b' ((c' ^^ k) (f s)); P ((c ^^ k) s)⟧ ⟹ P ((c ^^ k) s)› discuss goal 1*) apply ((auto simp: b' (*‹?ka2 ≤ k' ⟹ b' ((c' ^^ ?ka2) (f s))›*))[1]) (*discuss goal 2*) apply ((auto simp: b' (*‹?ka2 ≤ k' ⟹ b' ((c' ^^ ?ka2) (f s))›*))[1]) (*discuss goal 3*) apply ((auto simp: b' (*‹?ka2 ≤ k' ⟹ b' ((c' ^^ ?ka2) (f s))›*))[1]) (*proven 3 subgoals*) . } note b = this(1) (*‹?ka2 ≤ k' ⟹ b ((c ^^ ?ka2) s)›*) and body = this(2) (*‹?ka2 ≤ k' ⟹ f ((c ^^ ?ka2) s) = (c' ^^ ?ka2) (f s)›*) and inv = this(3) (*‹?ka2 ≤ k' ⟹ P ((c ^^ ?ka2) s)›*) hence k': "f ((c ^^ k') s) = (c' ^^ k') (f s)" by auto ultimately show "?thesis" (*goal: ‹(LEAST k. ¬ b' ((c' ^^ k) (f s))) = (LEAST k. ¬ b ((c ^^ k) s))›*) unfolding Suc (*goal: ‹Suc k' = (LEAST k. ¬ b ((c ^^ k) s))›*) using b (*‹?ka2 ≤ k' ⟹ b ((c ^^ ?ka2) s)›*) proof (intro Least_equality[symmetric] (*‹⟦?P ?t; ⋀y. ?P y ⟹ ?t ≤ y⟧ ⟹ ?t = Least ?P›*), goal_cases) (*goals: 1. ‹⟦¬ (b'::'b ⇒ bool) (((c'::'b ⇒ 'b) ^^ Suc (k'::nat)) ((f::'a ⇒ 'b) (s::'a))); f (((c::'a ⇒ 'a) ^^ k') s) = (c' ^^ k') (f s); ⋀ka::nat. ka ≤ k' ⟹ (b::'a ⇒ bool) ((c ^^ ka) s)⟧ ⟹ ¬ b ((c ^^ Suc k') s)› 2. ‹⋀y::nat. ⟦¬ (b'::'b ⇒ bool) (((c'::'b ⇒ 'b) ^^ Suc (k'::nat)) ((f::'a ⇒ 'b) (s::'a))); f (((c::'a ⇒ 'a) ^^ k') s) = (c' ^^ k') (f s); ⋀ka::nat. ka ≤ k' ⟹ (b::'a ⇒ bool) ((c ^^ ka) s); ¬ b ((c ^^ y) s)⟧ ⟹ Suc k' ≤ y›*) case 1 (*‹¬ b' ((c' ^^ Suc k') (f s))› ‹(f::'a ⇒ 'b) (((c::'a ⇒ 'a) ^^ (k'::nat)) (s::'a)) = ((c'::'b ⇒ 'b) ^^ k') (f s)› ‹?ka ≤ k' ⟹ b ((c ^^ ?ka) s)›*) hence Test: "¬ b' (f ((c ^^ Suc k') s))" by (auto simp: BodyCommute (*‹⟦P ?s; b ?s⟧ ⟹ f (c ?s) = c' (f ?s)›*) inv (*‹?ka2 ≤ k' ⟹ P ((c ^^ ?ka2) s)›*) b (*‹?ka2 ≤ k' ⟹ b ((c ^^ ?ka2) s)›*)) have "P ((c ^^ Suc k') s)" by (auto simp: Invariant (*‹⟦(P::'a ⇒ bool) (?s::'a); (b::'a ⇒ bool) ?s⟧ ⟹ P ((c::'a ⇒ 'a) ?s)›*) inv (*‹(?ka2::nat) ≤ (k'::nat) ⟹ (P::'a ⇒ bool) (((c::'a ⇒ 'a) ^^ ?ka2) (s::'a))›*) b (*‹(?ka2::nat) ≤ (k'::nat) ⟹ (b::'a ⇒ bool) (((c::'a ⇒ 'a) ^^ ?ka2) (s::'a))›*)) with Test (*‹¬ b' (f ((c ^^ Suc k') s))›*) show "?case" (*goal: ‹¬ b ((c ^^ Suc k') s)›*) by (auto simp: TestCommute (*‹P ?s ⟹ b ?s = b' (f ?s)›*)) next (*goal: ‹⋀y. ⟦¬ b' ((c' ^^ Suc k') (f s)); f ((c ^^ k') s) = (c' ^^ k') (f s); ⋀ka. ka ≤ k' ⟹ b ((c ^^ ka) s); ¬ b ((c ^^ y) s)⟧ ⟹ Suc k' ≤ y›*) case 2 (*‹¬ b' ((c' ^^ Suc k') (f s))› ‹f ((c ^^ k') s) = (c' ^^ k') (f s)› ‹?ka ≤ k' ⟹ b ((c ^^ ?ka) s)› ‹¬ b ((c ^^ y_) s)›*) thus "?case" (*goal: ‹Suc k' ≤ y_›*) by (metis not_less_eq_eq (*‹(¬ ?m ≤ ?n) = (Suc ?n ≤ ?m)›*)) qed qed have "f ((c ^^ ?k) s) = (c' ^^ ?k') (f s)" unfolding "*" (*goal: ‹f ((c ^^ (LEAST k. ¬ b ((c ^^ k) s))) s) = (c' ^^ (LEAST k. ¬ b ((c ^^ k) s))) (f s)›*) apply (rule funpow_commute (*‹∀k'<?k. ?f (?c ((?c ^^ k') ?s)) = ?c' (?f ((?c ^^ k') ?s)) ⟹ ?f ((?c ^^ ?k) ?s) = (?c' ^^ ?k) (?f ?s)›*)) (*goal: ‹f ((c ^^ (LEAST k. ¬ b ((c ^^ k) s))) s) = (c' ^^ (LEAST k. ¬ b ((c ^^ k) s))) (f s)›*) proof (clarify) (*goal: ‹⋀k'. k' < (LEAST k. ¬ b ((c ^^ k) s)) ⟹ f (c ((c ^^ k') s)) = c' (f ((c ^^ k') s))›*) fix k assume "k < ?k" (*‹(k::nat) < (LEAST k::nat. ¬ (b::'a ⇒ bool) (((c::'a ⇒ 'a) ^^ k) (s::'a)))›*) hence TestTrue: "b ((c ^^ k) s)" by (auto dest: not_less_Least (*‹?k < (LEAST x. ?P x) ⟹ ¬ ?P ?k›*)) from ‹k < ?k› (*‹k < (LEAST k. ¬ b ((c ^^ k) s))›*) have "P ((c ^^ k) s)" proof (induct k) (*goals: 1. ‹0 < (LEAST k. ¬ b ((c ^^ k) s)) ⟹ P ((c ^^ 0) s)› 2. ‹⋀k. ⟦k < (LEAST k. ¬ b ((c ^^ k) s)) ⟹ P ((c ^^ k) s); Suc k < (LEAST k. ¬ b ((c ^^ k) s))⟧ ⟹ P ((c ^^ Suc k) s)›*) case 0 (*‹0 < (LEAST k. ¬ b ((c ^^ k) s))›*) thus "?case" (*goal: ‹P ((c ^^ 0) s)›*) by (auto simp: assms (*‹⟦(P::'a ⇒ bool) (?s::'a); (b::'a ⇒ bool) ?s⟧ ⟹ P ((c::'a ⇒ 'a) ?s)› ‹(P::'a ⇒ bool) (?s::'a) ⟹ (b::'a ⇒ bool) ?s = (b'::'b ⇒ bool) ((f::'a ⇒ 'b) ?s)› ‹⟦(P::'a ⇒ bool) (?s::'a); (b::'a ⇒ bool) ?s⟧ ⟹ (f::'a ⇒ 'b) ((c::'a ⇒ 'a) ?s) = (c'::'b ⇒ 'b) (f ?s)› ‹(P::'a ⇒ bool) (s::'a)›*)) next (*goal: ‹⋀k. ⟦k < (LEAST k. ¬ b ((c ^^ k) s)) ⟹ P ((c ^^ k) s); Suc k < (LEAST k. ¬ b ((c ^^ k) s))⟧ ⟹ P ((c ^^ Suc k) s)›*) case (Suc h) (*‹h < (LEAST k. ¬ b ((c ^^ k) s)) ⟹ P ((c ^^ h) s)› ‹Suc (h::nat) < (LEAST k::nat. ¬ (b::'a ⇒ bool) (((c::'a ⇒ 'a) ^^ k) (s::'a)))›*) hence "P ((c ^^ h) s)" by auto with Suc (*‹h < (LEAST k. ¬ b ((c ^^ k) s)) ⟹ P ((c ^^ h) s)› ‹Suc h < (LEAST k. ¬ b ((c ^^ k) s))›*) show "?case" (*goal: ‹P ((c ^^ Suc h) s)›*) apply auto (*goal: ‹P ((c ^^ Suc h) s)›*) by (metis (lifting, no_types) Invariant (*‹⟦(P::'a ⇒ bool) (?s::'a); (b::'a ⇒ bool) ?s⟧ ⟹ P ((c::'a ⇒ 'a) ?s)›*) Suc_lessD (*‹Suc (?m::nat) < (?n::nat) ⟹ ?m < ?n›*) not_less_Least (*‹(?k::?'a) < (LEAST x::?'a. (?P::?'a ⇒ bool) x) ⟹ ¬ ?P ?k›*)) qed with TestTrue (*‹b ((c ^^ k) s)›*) show "f (c ((c ^^ k) s)) = c' (f ((c ^^ k) s))" by (metis BodyCommute (*‹⟦P ?s; b ?s⟧ ⟹ f (c ?s) = c' (f ?s)›*)) qed thus "∃z. (c ^^ ?k) s = z ∧ f z = (c' ^^ ?k') (f s)" by blast qed lemma while_option_commute: assumes "⋀s. b s = b' (f s)" "⋀s. ⟦b s⟧ ⟹ f (c s) = c' (f s)" shows "map_option f (while_option b c s) = while_option b' c' (f s)" apply (rule while_option_commute_invariant[where P = "λ_. True"] (*‹⟦⋀s. ⟦True; ?b s⟧ ⟹ True; ⋀s. True ⟹ ?b s = ?b' (?f s); ⋀s. ⟦True; ?b s⟧ ⟹ ?f (?c s) = ?c' (?f s); True⟧ ⟹ map_option ?f (while_option ?b ?c ?s) = while_option ?b' ?c' (?f ?s)›*)) (*goals: 1. ‹⋀s. ⟦True; b s⟧ ⟹ True› 2. ‹⋀s. True ⟹ b s = b' (f s)› 3. ‹⋀s. ⟦True; b s⟧ ⟹ f (c s) = c' (f s)› 4. ‹True› discuss goal 1*) apply ((auto simp add: assms (*‹b ?s = b' (f ?s)› ‹b ?s ⟹ f (c ?s) = c' (f ?s)›*))[1]) (*discuss goal 2*) apply ((auto simp add: assms (*‹b ?s = b' (f ?s)› ‹b ?s ⟹ f (c ?s) = c' (f ?s)›*))[1]) (*discuss goal 3*) apply ((auto simp add: assms (*‹b ?s = b' (f ?s)› ‹b ?s ⟹ f (c ?s) = c' (f ?s)›*))[1]) (*discuss goal 4*) apply ((auto simp add: assms (*‹(b::'a::type ⇒ bool) (?s::'a::type) = (b'::'b::type ⇒ bool) ((f::'a::type ⇒ 'b::type) ?s)› ‹(b::'a::type ⇒ bool) (?s::'a::type) ⟹ (f::'a::type ⇒ 'b::type) ((c::'a::type ⇒ 'a::type) ?s) = (c'::'b::type ⇒ 'b::type) (f ?s)›*))[1]) (*proven 4 subgoals*) . subsection ‹Total version› definition while :: "('a ⇒ bool) ⇒ ('a ⇒ 'a) ⇒ 'a ⇒ 'a" where "while b c s = the (while_option b c s)" lemma while_unfold [code]: "while b c s = (if b s then while b c (c s) else s)" unfolding while_def (*goal: ‹the (while_option (b::'a ⇒ bool) (c::'a ⇒ 'a) (s::'a)) = (if b s then the (while_option b c (c s)) else s)›*) apply (subst while_option_unfold (*‹while_option ?b ?c ?s = (if ?b ?s then while_option ?b ?c (?c ?s) else Some ?s)›*)) (*goal: ‹the (while_option b c s) = (if b s then the (while_option b c (c s)) else s)›*) by simp lemma def_while_unfold: assumes fdef: "f == while test do" shows "f x = (if test x then f(do x) else x)" unfolding fdef (*goal: ‹while (test::'a ⇒ bool) (do::'a ⇒ 'a) (x::'a) = (if test x then while test do (do x) else x)›*) by (fact while_unfold (*‹while (?b::?'a::type ⇒ bool) (?c::?'a::type ⇒ ?'a::type) (?s::?'a::type) = (if ?b ?s then while ?b ?c (?c ?s) else ?s)›*)) text ‹ The proof rule for \<^term>‹while›, where \<^term>‹P› is the invariant. › theorem while_rule_lemma: assumes invariant: "!!s. P s ==> b s ==> P (c s)" and terminate: "!!s. P s ==> ¬ b s ==> Q s" and wf: "wf {(t, s). P s ∧ b s ∧ t = c s}" shows "P s ⟹ Q (while b c s)" using wf (*‹wf {(t, s). P s ∧ b s ∧ t = c s}›*) apply (induct s) (*goal: ‹P s ⟹ Q (while b c s)›*) apply simp (*goal: ‹⋀x::'a. ⟦⋀y::'a. ⟦(y, x) ∈ {(t::'a, s::'a). (P::'a ⇒ bool) s ∧ (b::'a ⇒ bool) s ∧ t = (c::'a ⇒ 'a) s}; P y⟧ ⟹ (Q::'a ⇒ bool) (while b c y); P x⟧ ⟹ Q (while b c x)›*) apply (subst while_unfold (*‹while ?b ?c ?s = (if ?b ?s then while ?b ?c (?c ?s) else ?s)›*)) (*goal: ‹⋀x. ⟦⟦b x; P (c x)⟧ ⟹ Q (while b c (c x)); P x⟧ ⟹ Q (while b c x)›*) by (simp add: invariant (*‹⟦(P::'a::type ⇒ bool) (?s::'a::type); (b::'a::type ⇒ bool) ?s⟧ ⟹ P ((c::'a::type ⇒ 'a::type) ?s)›*) terminate (*‹⟦(P::'a::type ⇒ bool) (?s::'a::type); ¬ (b::'a::type ⇒ bool) ?s⟧ ⟹ (Q::'a::type ⇒ bool) ?s›*)) theorem while_rule: "[| P s; !!s. [| P s; b s |] ==> P (c s); !!s. [| P s; ¬ b s |] ==> Q s; wf r; !!s. [| P s; b s |] ==> (c s, s) ∈ r |] ==> Q (while b c s)" apply (rule while_rule_lemma (*‹⟦⋀s. ⟦?P s; ?b s⟧ ⟹ ?P (?c s); ⋀s. ⟦?P s; ¬ ?b s⟧ ⟹ ?Q s; wf {(t, s). ?P s ∧ ?b s ∧ t = ?c s}; ?P ?s⟧ ⟹ ?Q (while ?b ?c ?s)›*)) (*goal: ‹⟦P s; ⋀s. ⟦P s; b s⟧ ⟹ P (c s); ⋀s. ⟦P s; ¬ b s⟧ ⟹ Q s; wf r; ⋀s. ⟦P s; b s⟧ ⟹ (c s, s) ∈ r⟧ ⟹ Q (while b c s)›*) prefer 4 (*top goal: ‹⟦P s; ⋀s. ⟦P s; b s⟧ ⟹ P (c s); ⋀s. ⟦P s; ¬ b s⟧ ⟹ Q s; wf r; ⋀s. ⟦P s; b s⟧ ⟹ (c s, s) ∈ r⟧ ⟹ ?P s› and 3 goals remain*) apply assumption (*top goal: ‹⟦(P::'a ⇒ bool) (s::'a); ⋀s::'a. ⟦P s; (b::'a ⇒ bool) s⟧ ⟹ P ((c::'a ⇒ 'a) s); ⋀s::'a. ⟦P s; ¬ b s⟧ ⟹ (Q::'a ⇒ bool) s; wf (r::('a × 'a) set); ⋀s::'a. ⟦P s; b s⟧ ⟹ (c s, s) ∈ r⟧ ⟹ (?P::'a ⇒ bool) s› and 3 goals remain*) apply blast (*top goal: ‹⋀sa. ⟦P s; ⋀s. ⟦P s; b s⟧ ⟹ P (c s); ⋀s. ⟦P s; ¬ b s⟧ ⟹ Q s; wf r; ⋀s. ⟦P s; b s⟧ ⟹ (c s, s) ∈ r; P sa; b sa⟧ ⟹ P (c sa)› and 2 goals remain*) apply blast (*top goal: ‹⋀sa. ⟦P s; ⋀s. ⟦P s; b s⟧ ⟹ P (c s); ⋀s. ⟦P s; ¬ b s⟧ ⟹ Q s; wf r; ⋀s. ⟦P s; b s⟧ ⟹ (c s, s) ∈ r; P sa; ¬ b sa⟧ ⟹ Q sa› and 1 goal remains*) apply (erule wf_subset (*‹⟦wf ?r; ?p ⊆ ?r⟧ ⟹ wf ?p›*)) (*goal: ‹⟦P s; ⋀s. ⟦P s; b s⟧ ⟹ P (c s); ⋀s. ⟦P s; ¬ b s⟧ ⟹ Q s; wf r; ⋀s. ⟦P s; b s⟧ ⟹ (c s, s) ∈ r⟧ ⟹ wf {(t, s). P s ∧ b s ∧ t = c s}›*) by blast text ‹Combine invariant preservation and variant decrease in one goal:› theorem while_rule2: "[| P s; !!s. [| P s; b s |] ==> P (c s) ∧ (c s, s) ∈ r; !!s. [| P s; ¬ b s |] ==> Q s; wf r |] ==> Q (while b c s)" using while_rule[of P] (*‹⟦P ?s; ⋀s. ⟦P s; ?b s⟧ ⟹ P (?c s); ⋀s. ⟦P s; ¬ ?b s⟧ ⟹ ?Q s; wf ?r; ⋀s. ⟦P s; ?b s⟧ ⟹ (?c s, s) ∈ ?r⟧ ⟹ ?Q (while ?b ?c ?s)›*) by metis text‹Proving termination:› theorem wf_while_option_Some: assumes "wf {(t, s). (P s ∧ b s) ∧ t = c s}" and "⋀s. P s ⟹ b s ⟹ P(c s)" and "P s" shows "∃t. while_option b c s = Some t" using assms(1,3) (*‹wf {(t, s). (P s ∧ b s) ∧ t = c s}› ‹P s›*) proof (induction s) (*goal: ‹⋀x. ⟦⋀y. ⟦(y, x) ∈ {(t, s). (P s ∧ b s) ∧ t = c s}; P y⟧ ⟹ ∃t. while_option b c y = Some t; P x⟧ ⟹ ∃t. while_option b c x = Some t›*) case less (*‹⟦(?y, x_) ∈ {(t, s). (P s ∧ b s) ∧ t = c s}; P ?y⟧ ⟹ ∃t. while_option b c ?y = Some t› ‹(P::'a ⇒ bool) (x_::'a)›*) thus "?case" (*goal: ‹∃t. while_option b c x_ = Some t›*) using assms(2) (*‹⟦P ?s; b ?s⟧ ⟹ P (c ?s)›*) apply (subst while_option_unfold (*‹while_option ?b ?c ?s = (if ?b ?s then while_option ?b ?c (?c ?s) else Some ?s)›*)) (*goal: ‹∃t. while_option b c x_ = Some t›*) by simp qed lemma wf_rel_while_option_Some: assumes wf: "wf R" assumes smaller: "⋀s. P s ∧ b s ⟹ (c s, s) ∈ R" assumes inv: "⋀s. P s ∧ b s ⟹ P(c s)" assumes init: "P s" shows "∃t. while_option b c s = Some t" proof (-) (*goal: ‹∃t. while_option b c s = Some t›*) from smaller (*‹P ?s ∧ b ?s ⟹ (c ?s, ?s) ∈ R›*) have "{(t,s). P s ∧ b s ∧ t = c s} ⊆ R" by auto with wf (*‹wf R›*) have "wf {(t,s). P s ∧ b s ∧ t = c s}" by (auto simp: wf_subset (*‹⟦wf ?r; ?p ⊆ ?r⟧ ⟹ wf ?p›*)) with inv (*‹P ?s ∧ b ?s ⟹ P (c ?s)›*) init (*‹P s›*) show "?thesis" (*goal: ‹∃t::'a. while_option (b::'a ⇒ bool) (c::'a ⇒ 'a) (s::'a) = Some t›*) by (auto simp: wf_while_option_Some (*‹⟦wf {(t, s). (?P s ∧ ?b s) ∧ t = ?c s}; ⋀s. ⟦?P s; ?b s⟧ ⟹ ?P (?c s); ?P ?s⟧ ⟹ ∃t. while_option ?b ?c ?s = Some t›*)) qed theorem measure_while_option_Some: fixes f :: "'s ⇒ nat" shows "(⋀s. P s ⟹ b s ⟹ P(c s) ∧ f(c s) < f s) ⟹ P s ⟹ ∃t. while_option b c s = Some t" by (blast intro: wf_while_option_Some[OF wf_if_measure, of P b f] (*‹⟦⋀s. P s ∧ b s ⟹ f (?c s) < f s; ⋀s. ⟦P s; b s⟧ ⟹ P (?c s); P ?s⟧ ⟹ ∃t. while_option b ?c ?s = Some t›*)) text‹Kleene iteration starting from the empty set and assuming some finite bounding set:› lemma while_option_finite_subset_Some: fixes C :: "'a set" assumes "mono f" and "!!X. X ⊆ C ⟹ f X ⊆ C" and "finite C" shows "∃P. while_option (λA. f A ≠ A) f {} = Some P" proof (rule measure_while_option_Some[where f= "%A::'a set. card C - card A" and P= "%A. A ⊆ C ∧ A ⊆ f A" and s= "{}"] (*‹⟦⋀s. ⟦s ⊆ C ∧ s ⊆ f s; ?b s⟧ ⟹ (?c s ⊆ C ∧ ?c s ⊆ f (?c s)) ∧ card C - card (?c s) < card C - card s; {} ⊆ C ∧ {} ⊆ f {}⟧ ⟹ ∃t. while_option ?b ?c {} = Some t›*)) (*goals: 1. ‹⋀s::'a::type set. ⟦s ⊆ (C::'a::type set) ∧ s ⊆ (f::'a::type set ⇒ 'a::type set) s; f s ≠ s⟧ ⟹ (f s ⊆ C ∧ f s ⊆ f (f s)) ∧ card C - card (f s) < card C - card s› 2. ‹{} ⊆ (C::'a::type set) ∧ {} ⊆ (f::'a::type set ⇒ 'a::type set) {}›*) fix A assume A: "A ⊆ C ∧ A ⊆ f A" "f A ≠ A" (*‹(A::'a set) ⊆ (C::'a set) ∧ A ⊆ (f::'a set ⇒ 'a set) A› ‹(f::'a set ⇒ 'a set) (A::'a set) ≠ A›*) show "(f A ⊆ C ∧ f A ⊆ f (f A)) ∧ card C - card (f A) < card C - card A" (is "?L ∧ ?R") proof (standard) (*goals: 1. ‹f A ⊆ C ∧ f A ⊆ f (f A)› 2. ‹card C - card (f A) < card C - card A›*) show "?L" by (metis A( (*‹A ⊆ C ∧ A ⊆ f A›*) 1) assms( (*‹?X ⊆ C ⟹ f ?X ⊆ C›*) 2) monoD[OF ‹mono f›] (*‹?x ⊆ ?y ⟹ f ?x ⊆ f ?y›*)) show "?R" by (metis A (*‹(A::'a set) ⊆ (C::'a set) ∧ A ⊆ (f::'a set ⇒ 'a set) A› ‹(f::'a set ⇒ 'a set) (A::'a set) ≠ A›*) assms( (*‹(?X::'a set) ⊆ (C::'a set) ⟹ (f::'a set ⇒ 'a set) ?X ⊆ C› ‹finite (C::'a set)›*) 2,3) card_seteq (*‹⟦finite (?B::?'a set); (?A::?'a set) ⊆ ?B; card ?B ≤ card ?A⟧ ⟹ ?A = ?B›*) diff_less_mono2 (*‹⟦(?m::nat) < (?n::nat); ?m < (?l::nat)⟧ ⟹ ?l - ?n < ?l - ?m›*) equalityI (*‹⟦(?A::?'a set) ⊆ (?B::?'a set); ?B ⊆ ?A⟧ ⟹ ?A = ?B›*) linorder_le_less_linear (*‹(?x::?'a) ≤ (?y::?'a) ∨ ?y < ?x›*) rev_finite_subset (*‹⟦finite (?B::?'a set); (?A::?'a set) ⊆ ?B⟧ ⟹ finite ?A›*)) qed qed (simp) (*solved the remaining goal: ‹{} ⊆ C ∧ {} ⊆ f {}›*) lemma lfp_the_while_option: assumes "mono f" and "!!X. X ⊆ C ⟹ f X ⊆ C" and "finite C" shows "lfp f = the(while_option (λA. f A ≠ A) f {})" proof (-) (*goal: ‹lfp (f::'a set ⇒ 'a set) = the (while_option (λA::'a set. f A ≠ A) f {})›*) obtain P where "while_option (λA. f A ≠ A) f {} = Some P" (*goal: ‹(⋀P. while_option (λA. f A ≠ A) f {} = Some P ⟹ thesis) ⟹ thesis›*) using while_option_finite_subset_Some[OF assms] (*‹(⋀X::'a set. X ⊆ (C::'a set) ⟹ X ⊆ C) ⟹ ∃P::'a set. while_option (λA::'a set. (f::'a set ⇒ 'a set) A ≠ A) f {} = Some P›*) by blast with while_option_stop2[OF this] (*‹∃k. P = (f ^^ k) {} ∧ ¬ f P ≠ P›*) lfp_Kleene_iter[OF assms ( 1 )] (*‹(f ^^ Suc ?k) {} = (f ^^ ?k) {} ⟹ lfp f = (f ^^ ?k) {}›*) show "?thesis" (*goal: ‹lfp f = the (while_option (λA. f A ≠ A) f {})›*) by auto qed lemma lfp_while: assumes "mono f" and "!!X. X ⊆ C ⟹ f X ⊆ C" and "finite C" shows "lfp f = while (λA. f A ≠ A) f {}" unfolding while_def (*goal: ‹lfp f = the (while_option (λA. f A ≠ A) f {})›*) using assms (*‹mono (f::'a set ⇒ 'a set)› ‹?X ⊆ C ⟹ f ?X ⊆ C› ‹finite C›*) apply (rule lfp_the_while_option (*‹⟦mono (?f::?'a set ⇒ ?'a set); ⋀X::?'a set. X ⊆ (?C::?'a set) ⟹ ?f X ⊆ ?C; finite ?C⟧ ⟹ lfp ?f = the (while_option (λA::?'a set. ?f A ≠ A) ?f {})›*)) (*goal: ‹lfp f = the (while_option (λA. f A ≠ A) f {})›*) by blast lemma wf_finite_less: assumes "finite (C :: 'a::order set)" shows "wf {(x, y). {x, y} ⊆ C ∧ x < y}" apply (rule wf_measure[where f="λb. card {a. a ∈ C ∧ a < b}", THEN wf_subset] (*‹?p ⊆ measure (λb. card {a ∈ C. a < b}) ⟹ wf ?p›*)) (*goal: ‹wf {(x, y). {x, y} ⊆ C ∧ x < y}›*) by (fastforce simp: less_eq (*‹((?m, ?n) ∈ pred_nat⁺) = (?m < ?n)›*) assms (*‹finite C›*) intro: psubset_card_mono (*‹⟦finite ?B; ?A ⊂ ?B⟧ ⟹ card ?A < card ?B›*)) lemma wf_finite_greater: assumes "finite (C :: 'a::order set)" shows "wf {(x, y). {x, y} ⊆ C ∧ y < x}" apply (rule wf_measure[where f="λb. card {a. a ∈ C ∧ b < a}", THEN wf_subset] (*‹?p ⊆ measure (λb. card {a ∈ C. b < a}) ⟹ wf ?p›*)) (*goal: ‹wf {(x, y). {x, y} ⊆ C ∧ y < x}›*) by (fastforce simp: less_eq (*‹((?m::nat, ?n::nat) ∈ pred_nat⁺) = (?m < ?n)›*) assms (*‹finite (C::'a set)›*) intro: psubset_card_mono (*‹⟦finite (?B::?'a set); (?A::?'a set) ⊂ ?B⟧ ⟹ card ?A < card ?B›*)) lemma while_option_finite_increasing_Some: fixes f :: "'a::order ⇒ 'a" assumes "mono f" and "finite (UNIV :: 'a set)" and "s ≤ f s" shows "∃P. while_option (λA. f A ≠ A) f s = Some P" apply (rule wf_rel_while_option_Some[where R="{(x, y). y < x}" and P="λA. A ≤ f A" and s="s"] (*‹⟦wf {(x, y). y < x}; ⋀s. s ≤ f s ∧ ?b s ⟹ (?c s, s) ∈ {(x, y). y < x}; ⋀s. s ≤ f s ∧ ?b s ⟹ ?c s ≤ f (?c s); s ≤ f s⟧ ⟹ ∃t. while_option ?b ?c s = Some t›*)) (*goals: 1. ‹wf {(x, y). y < x}› 2. ‹⋀s. s ≤ f s ∧ f s ≠ s ⟹ (f s, s) ∈ {(x, y). y < x}› 3. ‹⋀s. s ≤ f s ∧ f s ≠ s ⟹ f s ≤ f (f s)› 4. ‹s ≤ f s› discuss goal 1*) apply ((auto simp: assms (*‹mono f› ‹finite UNIV› ‹s ≤ f s›*) monoD (*‹⟦mono ?f; ?x ≤ ?y⟧ ⟹ ?f ?x ≤ ?f ?y›*) intro: wf_finite_greater[where C="UNIV::'a set", simplified] (*‹finite UNIV ⟹ wf {(x, y). y < x}›*))[1]) (*discuss goal 2*) apply ((auto simp: assms (*‹mono f› ‹finite UNIV› ‹s ≤ f s›*) monoD (*‹⟦mono ?f; ?x ≤ ?y⟧ ⟹ ?f ?x ≤ ?f ?y›*) intro: wf_finite_greater[where C="UNIV::'a set", simplified] (*‹finite UNIV ⟹ wf {(x, y). y < x}›*))[1]) (*discuss goal 3*) apply ((auto simp: assms (*‹mono f› ‹finite UNIV› ‹s ≤ f s›*) monoD (*‹⟦mono ?f; ?x ≤ ?y⟧ ⟹ ?f ?x ≤ ?f ?y›*) intro: wf_finite_greater[where C="UNIV::'a set", simplified] (*‹finite UNIV ⟹ wf {(x, y). y < x}›*))[1]) (*discuss goal 4*) apply ((auto simp: assms (*‹mono f› ‹finite UNIV› ‹s ≤ f s›*) monoD (*‹⟦mono ?f; ?x ≤ ?y⟧ ⟹ ?f ?x ≤ ?f ?y›*) intro: wf_finite_greater[where C="UNIV::'a set", simplified] (*‹finite UNIV ⟹ wf {(x, y). y < x}›*))[1]) (*proven 4 subgoals*) . lemma lfp_the_while_option_lattice: fixes f :: "'a::complete_lattice ⇒ 'a" assumes "mono f" and "finite (UNIV :: 'a set)" shows "lfp f = the (while_option (λA. f A ≠ A) f bot)" proof (-) (*goal: ‹lfp f = the (while_option (λA. f A ≠ A) f bot)›*) obtain P where "while_option (λA. f A ≠ A) f bot = Some P" (*goal: ‹(⋀P. while_option (λA. f A ≠ A) f bot = Some P ⟹ thesis) ⟹ thesis›*) using while_option_finite_increasing_Some[OF assms, where s = bot] (*‹bot ≤ f bot ⟹ ∃P. while_option (λA. f A ≠ A) f bot = Some P›*) apply simp (*goal: ‹(⋀P. while_option (λA. f A ≠ A) f bot = Some P ⟹ thesis) ⟹ thesis›*) by blast with while_option_stop2[OF this] (*‹∃k. P = (f ^^ k) bot ∧ ¬ f P ≠ P›*) lfp_Kleene_iter[OF assms ( 1 )] (*‹(f ^^ Suc ?k) bot = (f ^^ ?k) bot ⟹ lfp f = (f ^^ ?k) bot›*) show "?thesis" (*goal: ‹lfp (f::'a::complete_lattice ⇒ 'a::complete_lattice) = the (while_option (λA::'a::complete_lattice. f A ≠ A) f bot)›*) by auto qed lemma lfp_while_lattice: fixes f :: "'a::complete_lattice ⇒ 'a" assumes "mono f" and "finite (UNIV :: 'a set)" shows "lfp f = while (λA. f A ≠ A) f bot" unfolding while_def (*goal: ‹lfp f = the (while_option (λA. f A ≠ A) f bot)›*) using assms (*‹mono f› ‹finite UNIV›*) by (rule lfp_the_while_option_lattice (*‹⟦mono ?f; finite UNIV⟧ ⟹ lfp ?f = the (while_option (λA. ?f A ≠ A) ?f bot)›*)) lemma while_option_finite_decreasing_Some: fixes f :: "'a::order ⇒ 'a" assumes "mono f" and "finite (UNIV :: 'a set)" and "f s ≤ s" shows "∃P. while_option (λA. f A ≠ A) f s = Some P" apply (rule wf_rel_while_option_Some[where R="{(x, y). x < y}" and P="λA. f A ≤ A" and s="s"] (*‹⟦wf {(x::'a, y::'a). x < y}; ⋀s::'a. (f::'a ⇒ 'a) s ≤ s ∧ (?b::'a ⇒ bool) s ⟹ ((?c::'a ⇒ 'a) s, s) ∈ {(x::'a, y::'a). x < y}; ⋀s::'a. f s ≤ s ∧ ?b s ⟹ f (?c s) ≤ ?c s; f (s::'a) ≤ s⟧ ⟹ ∃t::'a. while_option ?b ?c s = Some t›*)) (*goals: 1. ‹wf {(x, y). x < y}› 2. ‹⋀s. f s ≤ s ∧ f s ≠ s ⟹ (f s, s) ∈ {(x, y). x < y}› 3. ‹⋀s. f s ≤ s ∧ f s ≠ s ⟹ f (f s) ≤ f s› 4. ‹f s ≤ s› discuss goal 1*) apply ((auto simp add: assms (*‹mono (f::'a ⇒ 'a)› ‹finite UNIV› ‹(f::'a ⇒ 'a) (s::'a) ≤ s›*) monoD (*‹⟦mono (?f::?'a ⇒ ?'b); (?x::?'a) ≤ (?y::?'a)⟧ ⟹ ?f ?x ≤ ?f ?y›*) intro: wf_finite_less[where C="UNIV::'a set", simplified] (*‹finite UNIV ⟹ wf {(x::'a, y::'a). x < y}›*))[1]) (*discuss goal 2*) apply ((auto simp add: assms (*‹mono (f::'a ⇒ 'a)› ‹finite UNIV› ‹(f::'a ⇒ 'a) (s::'a) ≤ s›*) monoD (*‹⟦mono (?f::?'a ⇒ ?'b); (?x::?'a) ≤ (?y::?'a)⟧ ⟹ ?f ?x ≤ ?f ?y›*) intro: wf_finite_less[where C="UNIV::'a set", simplified] (*‹finite UNIV ⟹ wf {(x::'a, y::'a). x < y}›*))[1]) (*discuss goal 3*) apply ((auto simp add: assms (*‹mono f› ‹finite UNIV› ‹f s ≤ s›*) monoD (*‹⟦mono ?f; ?x ≤ ?y⟧ ⟹ ?f ?x ≤ ?f ?y›*) intro: wf_finite_less[where C="UNIV::'a set", simplified] (*‹finite UNIV ⟹ wf {(x, y). x < y}›*))[1]) (*discuss goal 4*) apply ((auto simp add: assms (*‹mono f› ‹finite UNIV› ‹f s ≤ s›*) monoD (*‹⟦mono ?f; ?x ≤ ?y⟧ ⟹ ?f ?x ≤ ?f ?y›*) intro: wf_finite_less[where C="UNIV::'a set", simplified] (*‹finite UNIV ⟹ wf {(x, y). x < y}›*))[1]) (*proven 4 subgoals*) . lemma gfp_the_while_option_lattice: fixes f :: "'a::complete_lattice ⇒ 'a" assumes "mono f" and "finite (UNIV :: 'a set)" shows "gfp f = the(while_option (λA. f A ≠ A) f top)" proof (-) (*goal: ‹gfp f = the (while_option (λA. f A ≠ A) f top)›*) obtain P where "while_option (λA. f A ≠ A) f top = Some P" (*goal: ‹(⋀P. while_option (λA. f A ≠ A) f top = Some P ⟹ thesis) ⟹ thesis›*) using while_option_finite_decreasing_Some[OF assms, where s = top] (*‹f top ≤ top ⟹ ∃P. while_option (λA. f A ≠ A) f top = Some P›*) apply simp (*goal: ‹(⋀P. while_option (λA. f A ≠ A) f top = Some P ⟹ thesis) ⟹ thesis›*) by blast with while_option_stop2[OF this] (*‹∃k. P = (f ^^ k) top ∧ ¬ f P ≠ P›*) gfp_Kleene_iter[OF assms ( 1 )] (*‹(f ^^ Suc ?k) top = (f ^^ ?k) top ⟹ gfp f = (f ^^ ?k) top›*) show "?thesis" (*goal: ‹gfp f = the (while_option (λA. f A ≠ A) f top)›*) by auto qed lemma gfp_while_lattice: fixes f :: "'a::complete_lattice ⇒ 'a" assumes "mono f" and "finite (UNIV :: 'a set)" shows "gfp f = while (λA. f A ≠ A) f top" unfolding while_def (*goal: ‹gfp f = the (while_option (λA. f A ≠ A) f top)›*) using assms (*‹mono f› ‹finite UNIV›*) by (rule gfp_the_while_option_lattice (*‹⟦mono ?f; finite UNIV⟧ ⟹ gfp ?f = the (while_option (λA. ?f A ≠ A) ?f top)›*)) text‹Computing the reflexive, transitive closure by iterating a successor function. Stops when an element is found that dos not satisfy the test. More refined (and hence more efficient) versions can be found in ITP 2011 paper by Nipkow (the theories are in the AFP entry Flyspeck by Nipkow) and the AFP article Executable Transitive Closures by René Thiemann.› context fixes p :: "'a ⇒ bool" and f :: "'a ⇒ 'a list" and x :: 'a begin qualified fun rtrancl_while_test :: "'a list × 'a set ⇒ bool" where "rtrancl_while_test (ws,_) = (ws ≠ [] ∧ p(hd ws))" qualified fun rtrancl_while_step :: "'a list × 'a set ⇒ 'a list × 'a set" where "rtrancl_while_step (ws, Z) = (let x = hd ws; new = remdups (filter (λy. y ∉ Z) (f x)) in (new @ tl ws, set new ∪ Z))" definition rtrancl_while :: "('a list * 'a set) option" where "rtrancl_while = while_option rtrancl_while_test rtrancl_while_step ([x],{x})" qualified fun rtrancl_while_invariant :: "'a list × 'a set ⇒ bool" where "rtrancl_while_invariant (ws, Z) = (x ∈ Z ∧ set ws ⊆ Z ∧ distinct ws ∧ {(x,y). y ∈ set(f x)} `` (Z - set ws) ⊆ Z ∧ Z ⊆ {(x,y). y ∈ set(f x)}⇧* `` {x} ∧ (∀z∈Z - set ws. p z))" qualified lemma rtrancl_while_invariant: assumes inv: "rtrancl_while_invariant st" and test: "rtrancl_while_test st" shows "rtrancl_while_invariant (rtrancl_while_step st)" proof (cases st) (*goal: ‹⋀a b. st = (a, b) ⟹ rtrancl_while_invariant (rtrancl_while_step st)›*) fix ws and Z assume st: "st = (ws, Z)" (*‹(st::'a list × 'a set) = (ws::'a list, Z::'a set)›*) with test (*‹rtrancl_while_test st›*) obtain h and t where "ws = h # t" "p h" (*goal: ‹(⋀h t. ⟦ws = h # t; p h⟧ ⟹ thesis) ⟹ thesis›*) apply (cases ws) (*goals: 1. ‹⟦⋀(h::'a) t::'a list. ⟦(ws::'a list) = h # t; (p::'a ⇒ bool) h⟧ ⟹ thesis::bool; rtrancl_while_test (st::'a list × 'a set); st = (ws, Z::'a set); ws = []⟧ ⟹ thesis› 2. ‹⋀(a::'a) list::'a list. ⟦⋀(h::'a) t::'a list. ⟦(ws::'a list) = h # t; (p::'a ⇒ bool) h⟧ ⟹ thesis::bool; rtrancl_while_test (st::'a list × 'a set); st = (ws, Z::'a set); ws = a # list⟧ ⟹ thesis› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . with inv (*‹rtrancl_while_invariant st›*) st (*‹st = (ws, Z)›*) show "?thesis" (*goal: ‹rtrancl_while_invariant (rtrancl_while_step st)›*) by (auto intro: rtrancl.rtrancl_into_rtrancl (*‹⟦(?a, ?b) ∈ ?r⇧*; (?b, ?c) ∈ ?r⟧ ⟹ (?a, ?c) ∈ ?r⇧*›*)) qed lemma rtrancl_while_Some: assumes "rtrancl_while = Some(ws,Z)" shows "if ws = [] then Z = {(x,y). y ∈ set(f x)}⇧* `` {x} ∧ (∀z∈Z. p z) else ¬p(hd ws) ∧ hd ws ∈ {(x,y). y ∈ set(f x)}⇧* `` {x}" proof (-) (*goal: ‹if ws = [] then Z = {(x, y). y ∈ set (f x)}⇧* `` {x} ∧ (∀z∈Z. p z) else ¬ p (hd ws) ∧ hd ws ∈ {(x, y). y ∈ set (f x)}⇧* `` {x}›*) have "rtrancl_while_invariant ([x],{x})" by simp with rtrancl_while_invariant (*‹⟦rtrancl_while_invariant ?st; rtrancl_while_test ?st⟧ ⟹ rtrancl_while_invariant (rtrancl_while_step ?st)›*) have I: "rtrancl_while_invariant (ws,Z)" apply (rule while_option_rule[OF _ assms[unfolded rtrancl_while_def]] (*‹⟦⋀s. ⟦?P s; rtrancl_while_test s⟧ ⟹ ?P (rtrancl_while_step s); ?P ([x], {x})⟧ ⟹ ?P (ws, Z)›*)) (*goals: 1. ‹⋀s. ⟦rtrancl_while_invariant s; rtrancl_while_test s⟧ ⟹ rtrancl_while_invariant s› 2. ‹⋀s. ⟦rtrancl_while_invariant s; rtrancl_while_test s⟧ ⟹ rtrancl_while_test s› discuss goal 1*) apply ((assumption)[1]) (*discuss goal 2*) . (*proven 2 subgoals*) { assume "ws = []" (*‹(ws::'a list) = []›*) hence "?thesis" using I (*‹rtrancl_while_invariant (ws::'a list, Z::'a set)›*) by (auto simp del:Image_Collect_case_prod (*‹{(x, y). ?P x y} `` ?A = {y. ∃x∈?A. ?P x y}›*) dest: Image_closed_trancl (*‹?r `` ?X ⊆ ?X ⟹ ?r⇧* `` ?X = ?X›*)) } moreover { assume "ws ≠ []" (*‹(ws::'a list) ≠ []›*) hence "?thesis" using I (*‹rtrancl_while_invariant (ws, Z)›*) while_option_stop[OF assms [ unfolded rtrancl_while_def ]] (*‹¬ rtrancl_while_test (ws, Z)›*) by (simp add: subset_iff (*‹((?A::?'a set) ⊆ (?B::?'a set)) = (∀t::?'a. t ∈ ?A ⟶ t ∈ ?B)›*)) } ultimately show "?thesis" (*goal: ‹if ws = [] then Z = {(x, y). y ∈ set (f x)}⇧* `` {x} ∧ (∀z∈Z. p z) else ¬ p (hd ws) ∧ hd ws ∈ {(x, y). y ∈ set (f x)}⇧* `` {x}›*) by simp qed lemma rtrancl_while_finite_Some: assumes "finite ({(x, y). y ∈ set (f x)}⇧* `` {x})" (is "finite ?Cl") shows "∃y. rtrancl_while = Some y" proof (-) (*goal: ‹∃y. local.rtrancl_while = Some y›*) let ?R = "(λ(_, Z). card (?Cl - Z)) <*mlex*> (λ(ws, _). length ws) <*mlex*> {}" have "wf ?R" by (blast intro: wf_mlex (*‹wf ?R ⟹ wf (?f <*mlex*> ?R)›*)) then show "?thesis" (*goal: ‹∃y::'a list × 'a set. local.rtrancl_while = Some y›*) unfolding rtrancl_while_def (*goal: ‹∃y. while_option rtrancl_while_test rtrancl_while_step ([x], {x}) = Some y›*) proof (rule wf_rel_while_option_Some[of ?R rtrancl_while_invariant] (*‹⟦wf ((λ(uu_, Z). card ({(x, y). y ∈ set (f x)}⇧* `` {x} - Z)) <*mlex*> (λ(ws, uu_). length ws) <*mlex*> {}); ⋀s. rtrancl_while_invariant s ∧ ?b s ⟹ (?c s, s) ∈ (λ(uu_, Z). card ({(x, y). y ∈ set (f x)}⇧* `` {x} - Z)) <*mlex*> (λ(ws, uu_). length ws) <*mlex*> {}; ⋀s. rtrancl_while_invariant s ∧ ?b s ⟹ rtrancl_while_invariant (?c s); rtrancl_while_invariant ?s⟧ ⟹ ∃t. while_option ?b ?c ?s = Some t›*)) (*goals: 1. ‹⋀s. rtrancl_while_invariant s ∧ rtrancl_while_test s ⟹ (rtrancl_while_step s, s) ∈ (λ(uu_, Z). card ({(x, y). y ∈ set (f x)}⇧* `` {x} - Z)) <*mlex*> (λ(ws, uu_). length ws) <*mlex*> {}› 2. ‹⋀s. rtrancl_while_invariant s ∧ rtrancl_while_test s ⟹ rtrancl_while_invariant (rtrancl_while_step s)› 3. ‹rtrancl_while_invariant ([x], {x})›*) fix st assume "*": "rtrancl_while_invariant st ∧ rtrancl_while_test st" (*‹rtrancl_while_invariant (st::'a list × 'a set) ∧ rtrancl_while_test st›*) hence I: "rtrancl_while_invariant (rtrancl_while_step st)" by (blast intro: rtrancl_while_invariant (*‹⟦rtrancl_while_invariant ?st; rtrancl_while_test ?st⟧ ⟹ rtrancl_while_invariant (rtrancl_while_step ?st)›*)) show "(rtrancl_while_step st, st) ∈ ?R" proof (cases st) (*goal: ‹⋀(a::'a list) b::'a set. (st::'a list × 'a set) = (a, b) ⟹ (rtrancl_while_step st, st) ∈ (λ(uu_::'a list, Z::'a set). card ({(x::'a, y::'a). y ∈ set ((f::'a ⇒ 'a list) x)}⇧* `` {x::'a} - Z)) <*mlex*> (λ(ws::'a list, uu_::'a set). length ws) <*mlex*> {}›*) fix ws and Z let ?ws = "fst (rtrancl_while_step st)" and ?Z = "snd (rtrancl_while_step st)" assume st: "st = (ws, Z)" (*‹(st::'a list × 'a set) = (ws::'a list, Z::'a set)›*) with "*" (*‹rtrancl_while_invariant st ∧ rtrancl_while_test st›*) obtain h and t where ws: "ws = h # t" "p h" (*goal: ‹(⋀h t. ⟦ws = h # t; p h⟧ ⟹ thesis) ⟹ thesis›*) apply (cases ws) (*goals: 1. ‹⟦⋀h t. ⟦ws = h # t; p h⟧ ⟹ thesis; rtrancl_while_invariant st ∧ rtrancl_while_test st; st = (ws, Z); ws = []⟧ ⟹ thesis› 2. ‹⋀a list. ⟦⋀h t. ⟦ws = h # t; p h⟧ ⟹ thesis; rtrancl_while_invariant st ∧ rtrancl_while_test st; st = (ws, Z); ws = a # list⟧ ⟹ thesis› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . { assume "remdups (filter (λy. y ∉ Z) (f h)) ≠ []" (*‹remdups (filter (λy::'a. y ∉ (Z::'a set)) ((f::'a ⇒ 'a list) (h::'a))) ≠ []›*) then obtain z where "z ∈ set (remdups (filter (λy. y ∉ Z) (f h)))" (*goal: ‹(⋀z. z ∈ set (remdups (filter (λy. y ∉ Z) (f h))) ⟹ thesis) ⟹ thesis›*) by fastforce with st (*‹(st::'a list × 'a set) = (ws::'a list, Z::'a set)›*) ws (*‹ws = h # t› ‹p h›*) I (*‹rtrancl_while_invariant (rtrancl_while_step st)›*) have "Z ⊂ ?Z" "Z ⊆ ?Cl" "?Z ⊆ ?Cl" apply - (*goals: 1. ‹⟦st = (ws, Z); ws = h # t; p h; rtrancl_while_invariant (rtrancl_while_step st); z ∈ set (remdups (filter (λy. y ∉ Z) (f h)))⟧ ⟹ Z ⊂ snd (rtrancl_while_step st)› 2. ‹⟦st = (ws, Z); ws = h # t; p h; rtrancl_while_invariant (rtrancl_while_step st); z ∈ set (remdups (filter (λy. y ∉ Z) (f h)))⟧ ⟹ Z ⊆ {(x, y). y ∈ set (f x)}⇧* `` {x}› 3. ‹⟦st = (ws, Z); ws = h # t; p h; rtrancl_while_invariant (rtrancl_while_step st); z ∈ set (remdups (filter (λy. y ∉ Z) (f h)))⟧ ⟹ snd (rtrancl_while_step st) ⊆ {(x, y). y ∈ set (f x)}⇧* `` {x}› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*proven 3 subgoals*) . with assms (*‹finite ({(x::'a, y::'a). y ∈ set ((f::'a ⇒ 'a list) x)}⇧* `` {x::'a})›*) have "card (?Cl - ?Z) < card (?Cl - Z)" by (blast intro: psubset_card_mono (*‹⟦finite ?B; ?A ⊂ ?B⟧ ⟹ card ?A < card ?B›*)) with st (*‹st = (ws, Z)›*) ws (*‹(ws::'a::type list) = (h::'a::type) # (t::'a::type list)› ‹(p::'a ⇒ bool) (h::'a)›*) have "?thesis" unfolding mlex_prod_def (*goal: ‹(rtrancl_while_step st, st) ∈ inv_image (less_than <*lex*> inv_image (less_than <*lex*> {}) (λx. (case x of (ws, uu_) ⇒ length ws, x))) (λxa. (case xa of (uu_, Z) ⇒ card ({(x, y). y ∈ set (f x)}⇧* `` {x} - Z), xa))›*) by simp } moreover { assume "remdups (filter (λy. y ∉ Z) (f h)) = []" (*‹remdups (filter (λy::'a. y ∉ (Z::'a set)) ((f::'a ⇒ 'a list) (h::'a))) = []›*) with st (*‹st = (ws, Z)›*) ws (*‹(ws::'a list) = (h::'a) # (t::'a list)› ‹p h›*) have "?Z = Z" "?ws = t" apply - (*goals: 1. ‹⟦st = (ws, Z); ws = h # t; p h; remdups (filter (λy. y ∉ Z) (f h)) = []⟧ ⟹ snd (rtrancl_while_step st) = Z› 2. ‹⟦st = (ws, Z); ws = h # t; p h; remdups (filter (λy. y ∉ Z) (f h)) = []⟧ ⟹ fst (rtrancl_while_step st) = t› discuss goal 1*) apply ((auto simp: filter_empty_conv (*‹(filter (?P::?'a ⇒ bool) (?xs::?'a list) = []) = (∀x::?'a∈set ?xs. ¬ ?P x)›*))[1]) (*discuss goal 2*) apply ((auto simp: filter_empty_conv (*‹(filter ?P ?xs = []) = (∀x∈set ?xs. ¬ ?P x)›*))[1]) (*proven 2 subgoals*) . with st (*‹st = (ws, Z)›*) ws (*‹ws = h # t› ‹p h›*) have "?thesis" unfolding mlex_prod_def (*goal: ‹(rtrancl_while_step st, st) ∈ inv_image (less_than <*lex*> inv_image (less_than <*lex*> {}) (λx. (case x of (ws, uu_) ⇒ length ws, x))) (λxa. (case xa of (uu_, Z) ⇒ card ({(x, y). y ∈ set (f x)}⇧* `` {x} - Z), xa))›*) by simp } ultimately show "?thesis" (*goal: ‹(rtrancl_while_step st, st) ∈ (λ(uu_, Z). card ({(x, y). y ∈ set (f x)}⇧* `` {x} - Z)) <*mlex*> (λ(ws, uu_). length ws) <*mlex*> {}›*) by blast qed qed (simp_all add: rtrancl_while_invariant) (*solves the remaining goals: 1. ‹⋀s. rtrancl_while_invariant s ∧ rtrancl_while_test s ⟹ rtrancl_while_invariant (rtrancl_while_step s)› 2. ‹rtrancl_while_invariant ([x], {x})›*) qed end end
{ "path": "Isabelle2024/src/HOL/Library/While_Combinator.thy", "repo": "Isabelle2024", "sha": "9d15427766453eb6537b20fc988d028359de344478815ddbb855b5bf35cd28b4" }
section ‹Stochastic Dominance› theory Stochastic_Dominance imports Complex_Main "HOL-Probability.Probability" Lotteries Preference_Profiles Utility_Functions begin subsection ‹Definition of Stochastic Dominance› text ‹ This is the definition of stochastic dominance. It lifts a preference relation on alternatives to the stochastic dominance ordering on lotteries. › definition SD :: "'alt relation ⇒ 'alt lottery relation" where "p ≽[SD(R)] q ⟷ p ∈ lotteries_on {x. R x x} ∧ q ∈ lotteries_on {x. R x x} ∧ (∀x. R x x ⟶ measure_pmf.prob p {y. y ≽[R] x} ≥ measure_pmf.prob q {y. y ≽[R] x})" lemma SD_empty [simp]: "SD (λ_ _. False) = (λ_ _. False)" by (auto simp: fun_eq_iff (*‹(?f = ?g) = (∀x. ?f x = ?g x)›*) SD_def (*‹SD ?R ?q ?p = (?p ∈ lotteries_on {x. ?R x x} ∧ ?q ∈ lotteries_on {x. ?R x x} ∧ (∀x. ?R x x ⟶ measure_pmf.prob ?q {y. ?R x y} ≤ measure_pmf.prob ?p {y. ?R x y}))›*) lotteries_on_def (*‹lotteries_on ?A = {p. set_pmf p ⊆ ?A}›*) set_pmf_not_empty (*‹set_pmf ?M ≠ {}›*)) text ‹ Stochastic dominance over any relation is a preorder. › lemma SD_refl: "p ≼[SD(R)] p ⟷ p ∈ lotteries_on {x. R x x}" by (simp add: SD_def (*‹SD (?R::?'alt ⇒ ?'alt ⇒ bool) (?q::?'alt pmf) (?p::?'alt pmf) = (?p ∈ lotteries_on {x::?'alt. ?R x x} ∧ ?q ∈ lotteries_on {x::?'alt. ?R x x} ∧ (∀x::?'alt. ?R x x ⟶ measure_pmf.prob ?q {y::?'alt. ?R x y} ≤ measure_pmf.prob ?p {y::?'alt. ?R x y}))›*)) lemma SD_trans [simp, trans]: "p ≼[SD(R)] q ⟹ q ≼[SD(R)] r ⟹ p ≼[SD(R)] r" unfolding SD_def (*goal: ‹⟦(q::'a pmf) ∈ lotteries_on {x::'a. (R::'a ⇒ 'a ⇒ bool) x x} ∧ (p::'a pmf) ∈ lotteries_on {x::'a. R x x} ∧ (∀x::'a. R x x ⟶ measure_pmf.prob p (Collect (R x)) ≤ measure_pmf.prob q (Collect (R x))); (r::'a pmf) ∈ lotteries_on {x::'a. R x x} ∧ q ∈ lotteries_on {x::'a. R x x} ∧ (∀x::'a. R x x ⟶ measure_pmf.prob q (Collect (R x)) ≤ measure_pmf.prob r (Collect (R x)))⟧ ⟹ r ∈ lotteries_on {x::'a. R x x} ∧ p ∈ lotteries_on {x::'a. R x x} ∧ (∀x::'a. R x x ⟶ measure_pmf.prob p (Collect (R x)) ≤ measure_pmf.prob r (Collect (R x)))›*) by (auto intro: order.trans (*‹⟦?a ≤ ?b; ?b ≤ ?c⟧ ⟹ ?a ≤ ?c›*)) lemma SD_is_preorder: "preorder_on (lotteries_on {x. R x x}) (SD R)" apply unfold_locales (*goals: 1. ‹⋀x y. SD R x y ⟹ x ∈ lotteries_on {x. R x x}› 2. ‹⋀x y. SD R x y ⟹ y ∈ lotteries_on {x. R x x}› 3. ‹⋀x. x ∈ lotteries_on {x. R x x} ⟹ SD R x x› 4. ‹⋀x y z. ⟦SD R x y; SD R y z⟧ ⟹ SD R x z› discuss goal 1*) apply ((auto simp: SD_def (*‹SD ?R ?q ?p = (?p ∈ lotteries_on {x. ?R x x} ∧ ?q ∈ lotteries_on {x. ?R x x} ∧ (∀x. ?R x x ⟶ measure_pmf.prob ?q {y. ?R x y} ≤ measure_pmf.prob ?p {y. ?R x y}))›*) intro: order.trans (*‹⟦?a ≤ ?b; ?b ≤ ?c⟧ ⟹ ?a ≤ ?c›*))[1]) (*discuss goal 2*) apply ((auto simp: SD_def (*‹SD ?R ?q ?p = (?p ∈ lotteries_on {x. ?R x x} ∧ ?q ∈ lotteries_on {x. ?R x x} ∧ (∀x. ?R x x ⟶ measure_pmf.prob ?q {y. ?R x y} ≤ measure_pmf.prob ?p {y. ?R x y}))›*) intro: order.trans (*‹⟦?a ≤ ?b; ?b ≤ ?c⟧ ⟹ ?a ≤ ?c›*))[1]) (*discuss goal 3*) apply ((auto simp: SD_def (*‹SD ?R ?q ?p = (?p ∈ lotteries_on {x. ?R x x} ∧ ?q ∈ lotteries_on {x. ?R x x} ∧ (∀x. ?R x x ⟶ measure_pmf.prob ?q {y. ?R x y} ≤ measure_pmf.prob ?p {y. ?R x y}))›*) intro: order.trans (*‹⟦?a ≤ ?b; ?b ≤ ?c⟧ ⟹ ?a ≤ ?c›*))[1]) (*discuss goal 4*) apply ((auto simp: SD_def (*‹SD ?R ?q ?p = (?p ∈ lotteries_on {x. ?R x x} ∧ ?q ∈ lotteries_on {x. ?R x x} ∧ (∀x. ?R x x ⟶ measure_pmf.prob ?q {y. ?R x y} ≤ measure_pmf.prob ?p {y. ?R x y}))›*) intro: order.trans (*‹⟦?a ≤ ?b; ?b ≤ ?c⟧ ⟹ ?a ≤ ?c›*))[1]) (*proven 4 subgoals*) . context preorder_on begin lemma SD_preorder: "p ≽[SD(le)] q ⟷ p ∈ lotteries_on carrier ∧ q ∈ lotteries_on carrier ∧ (∀x∈carrier. measure_pmf.prob p (preferred_alts le x) ≥ measure_pmf.prob q (preferred_alts le x))" by (simp add: SD_def (*‹SD ?R ?q ?p = (?p ∈ lotteries_on {x. ?R x x} ∧ ?q ∈ lotteries_on {x. ?R x x} ∧ (∀x. ?R x x ⟶ measure_pmf.prob ?q {y. ?R x y} ≤ measure_pmf.prob ?p {y. ?R x y}))›*) preferred_alts_def (*‹preferred_alts ?R ?x = {y. ?R ?x y}›*) carrier_eq (*‹carrier = {x. le x x}›*)) lemma SD_preorderI [intro?]: assumes "p ∈ lotteries_on carrier" "q ∈ lotteries_on carrier" assumes "⋀x. x ∈ carrier ⟹ measure_pmf.prob p (preferred_alts le x) ≥ measure_pmf.prob q (preferred_alts le x)" shows "p ≽[SD(le)] q" using assms (*‹p ∈ lotteries_on carrier› ‹(q::'a pmf) ∈ lotteries_on (carrier::'a set)› ‹?x ∈ carrier ⟹ measure_pmf.prob q (preferred_alts le ?x) ≤ measure_pmf.prob p (preferred_alts le ?x)›*) by (simp add: SD_preorder (*‹SD le ?q ?p = (?p ∈ lotteries_on carrier ∧ ?q ∈ lotteries_on carrier ∧ (∀x∈carrier. measure_pmf.prob ?q (preferred_alts le x) ≤ measure_pmf.prob ?p (preferred_alts le x)))›*)) lemma SD_preorderD: assumes "p ≽[SD(le)] q" shows "p ∈ lotteries_on carrier" "q ∈ lotteries_on carrier" and "⋀x. x ∈ carrier ⟹ measure_pmf.prob p (preferred_alts le x) ≥ measure_pmf.prob q (preferred_alts le x)" using assms (*‹SD le q p›*) unfolding SD_preorder (*goals: 1. ‹(p::'a::type pmf) ∈ lotteries_on (carrier::'a::type set)› 2. ‹(q::'a::type pmf) ∈ lotteries_on (carrier::'a::type set)› 3. ‹⋀x::'a::type. x ∈ (carrier::'a::type set) ⟹ measure_pmf.prob (q::'a::type pmf) (preferred_alts (le::'a::type ⇒ 'a::type ⇒ bool) x) ≤ measure_pmf.prob (p::'a::type pmf) (preferred_alts le x)›*) apply - (*goals: 1. ‹p ∈ lotteries_on carrier ∧ q ∈ lotteries_on carrier ∧ (∀x∈carrier. measure_pmf.prob q (preferred_alts le x) ≤ measure_pmf.prob p (preferred_alts le x)) ⟹ p ∈ lotteries_on carrier› 2. ‹p ∈ lotteries_on carrier ∧ q ∈ lotteries_on carrier ∧ (∀x∈carrier. measure_pmf.prob q (preferred_alts le x) ≤ measure_pmf.prob p (preferred_alts le x)) ⟹ q ∈ lotteries_on carrier› 3. ‹⋀x. ⟦x ∈ carrier; p ∈ lotteries_on carrier ∧ q ∈ lotteries_on carrier ∧ (∀x∈carrier. measure_pmf.prob q (preferred_alts le x) ≤ measure_pmf.prob p (preferred_alts le x))⟧ ⟹ measure_pmf.prob q (preferred_alts le x) ≤ measure_pmf.prob p (preferred_alts le x)› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*discuss goal 3*) apply simp (*proven 3 subgoals*) . lemma SD_refl' [simp]: "p ≼[SD(le)] p ⟷ p ∈ lotteries_on carrier" by (simp add: SD_def (*‹SD (?R::?'alt ⇒ ?'alt ⇒ bool) (?q::?'alt pmf) (?p::?'alt pmf) = (?p ∈ lotteries_on {x::?'alt. ?R x x} ∧ ?q ∈ lotteries_on {x::?'alt. ?R x x} ∧ (∀x::?'alt. ?R x x ⟶ measure_pmf.prob ?q {y::?'alt. ?R x y} ≤ measure_pmf.prob ?p {y::?'alt. ?R x y}))›*) carrier_eq (*‹(carrier::'a set) = {x::'a. (le::'a ⇒ 'a ⇒ bool) x x}›*)) lemma SD_is_preorder': "preorder_on (lotteries_on carrier) (SD(le))" using SD_is_preorder[of le] (*‹Order_Predicates.preorder_on (lotteries_on {x. le x x}) (SD le)›*) by (simp add: carrier_eq (*‹carrier = {x. le x x}›*)) lemma SD_singleton_left: assumes "x ∈ carrier" "q ∈ lotteries_on carrier" shows "return_pmf x ≼[SD(le)] q ⟷ (∀y∈set_pmf q. x ≼[le] y)" proof (standard) (*goals: 1. ‹SD le (return_pmf x) q ⟹ ∀y∈set_pmf q. le x y› 2. ‹∀y∈set_pmf q. le x y ⟹ SD le (return_pmf x) q›*) assume SD: "return_pmf x ≼[SD(le)] q" (*‹SD (le::'a ⇒ 'a ⇒ bool) (return_pmf (x::'a)) (q::'a pmf)›*) from assms (*‹x ∈ carrier› ‹q ∈ lotteries_on carrier›*) SD_preorderD(3)[OF SD, of x] (*‹x ∈ carrier ⟹ measure_pmf.prob (return_pmf x) (preferred_alts le x) ≤ measure_pmf.prob q (preferred_alts le x)›*) have "measure_pmf.prob (return_pmf x) (preferred_alts le x) ≤ measure_pmf.prob q (preferred_alts le x)" by simp also (*calculation: ‹measure_pmf.prob (return_pmf (x::'a)) (preferred_alts (le::'a ⇒ 'a ⇒ bool) x) ≤ measure_pmf.prob (q::'a pmf) (preferred_alts le x)›*) from assms (*‹x ∈ carrier› ‹q ∈ lotteries_on carrier›*) have "measure_pmf.prob (return_pmf x) (preferred_alts le x) = 1" by (simp add: indicator_def (*‹indicator (?S::?'b::type set) (?x::?'b::type) = of_bool (?x ∈ ?S)›*)) finally (*calculation: ‹(1::real) ≤ measure_pmf.prob (q::'a pmf) (preferred_alts (le::'a ⇒ 'a ⇒ bool) (x::'a))›*) have "AE y in q. y ≽[le] x" by (simp add: measure_pmf.measure_ge_1_iff (*‹(1 ≤ measure_pmf.prob ?M ?A) = (measure_pmf.prob ?M ?A = 1)›*) measure_pmf.prob_eq_1 (*‹?A ∈ measure_pmf.events ?M ⟹ (measure_pmf.prob ?M ?A = 1) = (AE x in measure_pmf ?M. x ∈ ?A)›*) preferred_alts_def (*‹preferred_alts ?R ?x = {y. ?R ?x y}›*)) thus "∀y∈set_pmf q. y ≽[le] x" by (simp add: AE_measure_pmf_iff (*‹almost_everywhere (measure_pmf ?M) ?P = (∀y∈set_pmf ?M. ?P y)›*)) next (*goal: ‹∀y∈set_pmf q. le x y ⟹ SD le (return_pmf x) q›*) assume A: "∀y∈set_pmf q. x ≼[le] y" (*‹∀y::'a∈set_pmf (q::'a pmf). (le::'a ⇒ 'a ⇒ bool) (x::'a) y›*) show "return_pmf x ≼[SD(le)] q" proof (rule SD_preorderI (*‹⟦?p ∈ lotteries_on carrier; ?q ∈ lotteries_on carrier; ⋀x. x ∈ carrier ⟹ measure_pmf.prob ?q (preferred_alts le x) ≤ measure_pmf.prob ?p (preferred_alts le x)⟧ ⟹ SD le ?q ?p›*)) (*goals: 1. ‹q ∈ lotteries_on carrier› 2. ‹return_pmf x ∈ lotteries_on carrier› 3. ‹⋀xa. xa ∈ carrier ⟹ measure_pmf.prob (return_pmf x) (preferred_alts le xa) ≤ measure_pmf.prob q (preferred_alts le xa)›*) fix y assume y: "y ∈ carrier" (*‹(y::'a) ∈ (carrier::'a set)›*) show "measure_pmf.prob (return_pmf x) (preferred_alts le y) ≤ measure_pmf.prob q (preferred_alts le y)" proof (cases "y ≼[le] x") (*goals: 1. ‹le y x ⟹ measure_pmf.prob (return_pmf x) (preferred_alts le y) ≤ measure_pmf.prob q (preferred_alts le y)› 2. ‹¬ le y x ⟹ measure_pmf.prob (return_pmf x) (preferred_alts le y) ≤ measure_pmf.prob q (preferred_alts le y)›*) case True (*‹(le::'a ⇒ 'a ⇒ bool) (y::'a) (x::'a)›*) from True (*‹le y x›*) A (*‹∀y∈set_pmf q. le x y›*) have "measure_pmf.prob q (preferred_alts le y) = 1" by (auto simp: AE_measure_pmf_iff (*‹almost_everywhere (measure_pmf ?M) ?P = (∀y∈set_pmf ?M. ?P y)›*) measure_pmf.prob_eq_1 (*‹?A ∈ measure_pmf.events ?M ⟹ (measure_pmf.prob ?M ?A = 1) = (AE x in measure_pmf ?M. x ∈ ?A)›*) preferred_alts_def (*‹preferred_alts ?R ?x = {y. ?R ?x y}›*) intro: trans (*‹⟦le ?x ?y; le ?y ?z⟧ ⟹ le ?x ?z›*)) thus "?thesis" (*goal: ‹measure_pmf.prob (return_pmf x) (preferred_alts le y) ≤ measure_pmf.prob q (preferred_alts le y)›*) by simp qed (simp_all add: preferred_alts_def indicator_def measure_nonneg) (*solved the remaining goal: ‹¬ le y x ⟹ measure_pmf.prob (return_pmf x) (preferred_alts le y) ≤ measure_pmf.prob q (preferred_alts le y)›*) qed (insert assms (*‹x ∈ carrier› ‹q ∈ lotteries_on carrier›*), simp_all add: lotteries_on_def) (*solves the remaining goals: 1. ‹q ∈ lotteries_on carrier› 2. ‹return_pmf x ∈ lotteries_on carrier›*) qed lemma SD_singleton_right: assumes x: "x ∈ carrier" and q: "q ∈ lotteries_on carrier" shows "q ≼[SD(le)] return_pmf x ⟷ (∀y∈set_pmf q. y ≼[le] x)" proof (safe) (*goals: 1. ‹⋀y. ⟦SD le q (return_pmf x); y ∈ set_pmf q⟧ ⟹ le y x› 2. ‹∀y∈set_pmf q. le y x ⟹ SD le q (return_pmf x)›*) fix y assume SD: "q ≼[SD(le)] return_pmf x" and y: "y ∈ set_pmf q" (*‹SD (le::'a ⇒ 'a ⇒ bool) (q::'a pmf) (return_pmf (x::'a))› ‹(y::'a) ∈ set_pmf (q::'a pmf)›*) from y (*‹(y::'a) ∈ set_pmf (q::'a pmf)›*) assms (*‹(x::'a) ∈ (carrier::'a set)› ‹q ∈ lotteries_on carrier›*) have [simp]: "y ∈ carrier" by (auto simp: lotteries_on_def (*‹lotteries_on ?A = {p. set_pmf p ⊆ ?A}›*)) from y (*‹y ∈ set_pmf q›*) have "0 < measure_pmf.prob q (preferred_alts le y)" apply (rule measure_pmf_posI (*‹⟦(?x::?'a) ∈ set_pmf (?p::?'a pmf); ?x ∈ (?A::?'a set)⟧ ⟹ (0::real) < measure_pmf.prob ?p ?A›*)) (*goal: ‹0 < measure_pmf.prob q (preferred_alts le y)›*) by simp also (*calculation: ‹0 < measure_pmf.prob q (preferred_alts le y)›*) have "… ≤ measure_pmf.prob (return_pmf x) (preferred_alts le y)" apply (rule SD_preorderD(3)[OF SD] (*‹?x ∈ carrier ⟹ measure_pmf.prob q (preferred_alts le ?x) ≤ measure_pmf.prob (return_pmf x) (preferred_alts le ?x)›*)) (*goal: ‹measure_pmf.prob q (preferred_alts le y) ≤ measure_pmf.prob (return_pmf x) (preferred_alts le y)›*) by simp finally (*calculation: ‹(0::real) < measure_pmf.prob (return_pmf (x::'a::type)) (preferred_alts (le::'a::type ⇒ 'a::type ⇒ bool) (y::'a::type))›*) show "y ≼[le] x" by (auto simp: indicator_def (*‹indicator ?S ?x = of_bool (?x ∈ ?S)›*) preferred_alts_def (*‹preferred_alts ?R ?x = {y. ?R ?x y}›*) 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: ‹∀y∈set_pmf q. le y x ⟹ SD le q (return_pmf x)›*) assume A: "∀y∈set_pmf q. y ≼[le] x" (*‹∀y::'a∈set_pmf (q::'a pmf). (le::'a ⇒ 'a ⇒ bool) y (x::'a)›*) show "q ≼[SD(le)] return_pmf x" proof (rule SD_preorderI (*‹⟦(?p::'a pmf) ∈ lotteries_on (carrier::'a set); (?q::'a pmf) ∈ lotteries_on carrier; ⋀x::'a. x ∈ carrier ⟹ measure_pmf.prob ?q (preferred_alts (le::'a ⇒ 'a ⇒ bool) x) ≤ measure_pmf.prob ?p (preferred_alts le x)⟧ ⟹ SD le ?q ?p›*)) (*goals: 1. ‹return_pmf (x::'a::type) ∈ lotteries_on (carrier::'a::type set)› 2. ‹(q::'a::type pmf) ∈ lotteries_on (carrier::'a::type set)› 3. ‹⋀xa::'a::type. xa ∈ (carrier::'a::type set) ⟹ measure_pmf.prob (q::'a::type pmf) (preferred_alts (le::'a::type ⇒ 'a::type ⇒ bool) xa) ≤ measure_pmf.prob (return_pmf (x::'a::type)) (preferred_alts le xa)›*) fix y assume y: "y ∈ carrier" (*‹(y::'a) ∈ (carrier::'a set)›*) show "measure_pmf.prob q (preferred_alts le y) ≤ measure_pmf.prob (return_pmf x) (preferred_alts le y)" proof (cases "y ≼[le] x") (*goals: 1. ‹le y x ⟹ measure_pmf.prob q (preferred_alts le y) ≤ measure_pmf.prob (return_pmf x) (preferred_alts le y)› 2. ‹¬ le y x ⟹ measure_pmf.prob q (preferred_alts le y) ≤ measure_pmf.prob (return_pmf x) (preferred_alts le y)›*) case False (*‹¬ (le::'a ⇒ 'a ⇒ bool) (y::'a) (x::'a)›*) with A (*‹∀y::'a∈set_pmf (q::'a pmf). (le::'a ⇒ 'a ⇒ bool) y (x::'a)›*) show "?thesis" (*goal: ‹measure_pmf.prob q (preferred_alts le y) ≤ measure_pmf.prob (return_pmf x) (preferred_alts le y)›*) by (auto simp: preferred_alts_def (*‹preferred_alts ?R ?x = {y. ?R ?x y}›*) indicator_def (*‹indicator ?S ?x = of_bool (?x ∈ ?S)›*) measure_le_0_iff (*‹(Sigma_Algebra.measure ?M ?X ≤ 0) = (Sigma_Algebra.measure ?M ?X = 0)›*) measure_pmf.prob_eq_0 (*‹?A ∈ measure_pmf.events ?M ⟹ (measure_pmf.prob ?M ?A = 0) = (AE x in measure_pmf ?M. x ∉ ?A)›*) AE_measure_pmf_iff (*‹almost_everywhere (measure_pmf ?M) ?P = (∀y∈set_pmf ?M. ?P y)›*) intro: trans (*‹⟦le ?x ?y; le ?y ?z⟧ ⟹ le ?x ?z›*)) qed (simp_all add: indicator_def preferred_alts_def) (*solved the remaining goal: ‹le y x ⟹ measure_pmf.prob q (preferred_alts le y) ≤ measure_pmf.prob (return_pmf x) (preferred_alts le y)›*) qed (insert assms (*‹x ∈ carrier› ‹q ∈ lotteries_on carrier›*), simp_all add: lotteries_on_def) (*solves the remaining goals: 1. ‹return_pmf (x::'a) ∈ lotteries_on (carrier::'a set)› 2. ‹(q::'a pmf) ∈ lotteries_on (carrier::'a set)›*) qed lemma SD_strict_singleton_left: assumes "x ∈ carrier" "q ∈ lotteries_on carrier" shows "return_pmf x ≺[SD(le)] q ⟷ (∀y∈set_pmf q. x ≼[le] y) ∧ (∃y∈set_pmf q. (x ≺[le] y))" using assms (*‹(x::'a::type) ∈ (carrier::'a::type set)› ‹q ∈ lotteries_on carrier›*) by (auto simp add: strongly_preferred_def (*‹?a ≺[?R] ?b ≡ ?R ?a ?b ∧ ¬ ?R ?b ?a›*) SD_singleton_left (*‹⟦?x ∈ carrier; ?q ∈ lotteries_on carrier⟧ ⟹ SD le (return_pmf ?x) ?q = (∀y∈set_pmf ?q. le ?x y)›*) SD_singleton_right (*‹⟦?x ∈ carrier; ?q ∈ lotteries_on carrier⟧ ⟹ SD le ?q (return_pmf ?x) = (∀y∈set_pmf ?q. le y ?x)›*)) lemma SD_strict_singleton_right: assumes "x ∈ carrier" "q ∈ lotteries_on carrier" shows "q ≺[SD(le)] return_pmf x ⟷ (∀y∈set_pmf q. y ≼[le] x) ∧ (∃y∈set_pmf q. (y ≺[le] x))" using assms (*‹x ∈ carrier› ‹q ∈ lotteries_on carrier›*) by (auto simp add: strongly_preferred_def (*‹?a ≺[?R] ?b ≡ ?R ?a ?b ∧ ¬ ?R ?b ?a›*) SD_singleton_left (*‹⟦?x ∈ carrier; ?q ∈ lotteries_on carrier⟧ ⟹ SD le (return_pmf ?x) ?q = (∀y∈set_pmf ?q. le ?x y)›*) SD_singleton_right (*‹⟦?x ∈ carrier; ?q ∈ lotteries_on carrier⟧ ⟹ SD le ?q (return_pmf ?x) = (∀y∈set_pmf ?q. le y ?x)›*)) lemma SD_singleton [simp]: "x ∈ carrier ⟹ y ∈ carrier ⟹ return_pmf x ≼[SD(le)] return_pmf y ⟷ x ≼[le] y" apply (subst SD_singleton_left (*‹⟦?x ∈ carrier; ?q ∈ lotteries_on carrier⟧ ⟹ SD le (return_pmf ?x) ?q = (∀y∈set_pmf ?q. le ?x y)›*)) (*goals: 1. ‹⟦x ∈ carrier; y ∈ carrier⟧ ⟹ x ∈ carrier› 2. ‹⟦x ∈ carrier; y ∈ carrier⟧ ⟹ return_pmf y ∈ lotteries_on carrier› 3. ‹⟦x ∈ carrier; y ∈ carrier⟧ ⟹ Ball (set_pmf (return_pmf y)) (le x) = le x y› discuss goal 1*) apply (simp add: lotteries_on_def (*‹lotteries_on ?A = {p. set_pmf p ⊆ ?A}›*)) (*discuss goal 2*) apply (simp add: lotteries_on_def (*‹lotteries_on ?A = {p. set_pmf p ⊆ ?A}›*)) (*discuss goal 3*) apply (simp add: lotteries_on_def (*‹lotteries_on (?A::?'a set) = {p::?'a pmf. set_pmf p ⊆ ?A}›*)) (*proven 3 subgoals*) . lemma SD_strict_singleton [simp]: "x ∈ carrier ⟹ y ∈ carrier ⟹ return_pmf x ≺[SD(le)] return_pmf y ⟷ x ≺[le] y" by (simp add: strongly_preferred_def (*‹?a ≺[?R] ?b ≡ ?R ?a ?b ∧ ¬ ?R ?b ?a›*)) end context pref_profile_wf begin context fixes i assumes i: "i ∈ agents" begin interpretation Ri: preorder_on alts "R i" by (simp add: i (*‹i ∈ agents›*)) lemmas SD_singleton_left = Ri.SD_singleton_left lemmas SD_singleton_right = Ri.SD_singleton_right lemmas SD_strict_singleton_left = Ri.SD_strict_singleton_left lemmas SD_strict_singleton_right = Ri.SD_strict_singleton_right lemmas SD_singleton = Ri.SD_singleton lemmas SD_strict_singleton = Ri.SD_strict_singleton end end lemmas (in pref_profile_wf) [simp] = SD_singleton SD_strict_singleton subsection ‹Stochastic Dominance for preference profiles› context pref_profile_wf begin lemma SD_pref_profile: assumes "i ∈ agents" shows "p ≽[SD(R i)] q ⟷ p ∈ lotteries_on alts ∧ q ∈ lotteries_on alts ∧ (∀x∈alts. measure_pmf.prob p (preferred_alts (R i) x) ≥ measure_pmf.prob q (preferred_alts (R i) x))" proof (-) (*goal: ‹SD (R i) q p = (p ∈ lotteries_on alts ∧ q ∈ lotteries_on alts ∧ (∀x∈alts. measure_pmf.prob q (preferred_alts (R i) x) ≤ measure_pmf.prob p (preferred_alts (R i) x)))›*) from assms (*‹i ∈ agents›*) interpret total_preorder_on alts "R i" by simp have "preferred_alts (R i) x = {y. y ≽[R i] x}" for x using not_outside (*‹R i ?x ?y ⟹ ?x ∈ alts› ‹R i ?x ?y ⟹ ?y ∈ alts›*) by (auto simp: preferred_alts_def (*‹preferred_alts ?R ?x = {y. ?R ?x y}›*)) thus "?thesis" (*goal: ‹SD (R i) q p = (p ∈ lotteries_on alts ∧ q ∈ lotteries_on alts ∧ (∀x∈alts. measure_pmf.prob q (preferred_alts (R i) x) ≤ measure_pmf.prob p (preferred_alts (R i) x)))›*) by (simp add: SD_preorder (*‹SD (R i) ?q ?p = (?p ∈ lotteries_on alts ∧ ?q ∈ lotteries_on alts ∧ (∀x∈alts. measure_pmf.prob ?q (preferred_alts (R i) x) ≤ measure_pmf.prob ?p (preferred_alts (R i) x)))›*) preferred_alts_def (*‹preferred_alts ?R ?x = {y. ?R ?x y}›*)) qed lemma SD_pref_profileI [intro?]: assumes "i ∈ agents" "p ∈ lotteries_on alts" "q ∈ lotteries_on alts" assumes "⋀x. x ∈ alts ⟹ measure_pmf.prob p (preferred_alts (R i) x) ≥ measure_pmf.prob q (preferred_alts (R i) x)" shows "p ≽[SD(R i)] q" using assms (*‹i ∈ agents› ‹p ∈ lotteries_on alts› ‹q ∈ lotteries_on alts› ‹(?x::'alt) ∈ (alts::'alt set) ⟹ measure_pmf.prob (q::'alt pmf) (preferred_alts ((R::'agent ⇒ 'alt ⇒ 'alt ⇒ bool) (i::'agent)) ?x) ≤ measure_pmf.prob (p::'alt pmf) (preferred_alts (R i) ?x)›*) by (simp add: SD_pref_profile (*‹?i ∈ agents ⟹ SD (R ?i) ?q ?p = (?p ∈ lotteries_on alts ∧ ?q ∈ lotteries_on alts ∧ (∀x∈alts. measure_pmf.prob ?q (preferred_alts (R ?i) x) ≤ measure_pmf.prob ?p (preferred_alts (R ?i) x)))›*)) lemma SD_pref_profileD: assumes "i ∈ agents" "p ≽[SD(R i)] q" shows "p ∈ lotteries_on alts" "q ∈ lotteries_on alts" and "⋀x. x ∈ alts ⟹ measure_pmf.prob p (preferred_alts (R i) x) ≥ measure_pmf.prob q (preferred_alts (R i) x)" using assms (*‹i ∈ agents› ‹SD ((R::'agent ⇒ 'alt ⇒ 'alt ⇒ bool) (i::'agent)) (q::'alt pmf) (p::'alt pmf)›*) apply - (*goals: 1. ‹⟦i ∈ agents; SD (R i) q p⟧ ⟹ p ∈ lotteries_on alts› 2. ‹⟦i ∈ agents; SD (R i) q p⟧ ⟹ q ∈ lotteries_on alts› 3. ‹⋀x. ⟦x ∈ alts; i ∈ agents; SD (R i) q p⟧ ⟹ measure_pmf.prob q (preferred_alts (R i) x) ≤ measure_pmf.prob p (preferred_alts (R i) x)› discuss goal 1*) apply (simp add: SD_pref_profile (*‹(?i::'agent) ∈ (agents::'agent set) ⟹ SD ((R::'agent ⇒ 'alt ⇒ 'alt ⇒ bool) ?i) (?q::'alt pmf) (?p::'alt pmf) = (?p ∈ lotteries_on (alts::'alt set) ∧ ?q ∈ lotteries_on alts ∧ (∀x::'alt∈alts. measure_pmf.prob ?q (preferred_alts (R ?i) x) ≤ measure_pmf.prob ?p (preferred_alts (R ?i) x)))›*)) (*discuss goal 2*) apply (simp add: SD_pref_profile (*‹?i ∈ agents ⟹ SD (R ?i) ?q ?p = (?p ∈ lotteries_on alts ∧ ?q ∈ lotteries_on alts ∧ (∀x∈alts. measure_pmf.prob ?q (preferred_alts (R ?i) x) ≤ measure_pmf.prob ?p (preferred_alts (R ?i) x)))›*)) (*discuss goal 3*) apply (simp add: SD_pref_profile (*‹?i ∈ agents ⟹ SD (R ?i) ?q ?p = (?p ∈ lotteries_on alts ∧ ?q ∈ lotteries_on alts ∧ (∀x∈alts. measure_pmf.prob ?q (preferred_alts (R ?i) x) ≤ measure_pmf.prob ?p (preferred_alts (R ?i) x)))›*)) (*proven 3 subgoals*) . end subsection ‹SD efficient lotteries› definition SD_efficient :: "('agent, 'alt) pref_profile ⇒ 'alt lottery ⇒ bool" where SD_efficient_auxdef: "SD_efficient R p ⟷ ¬(∃q∈lotteries_on {x. ∃i. R i x x}. q ≻[Pareto (SD ∘ R)] p)" context pref_profile_wf begin sublocale SD: preorder_family agents "lotteries_on alts" "SD ∘ R" unfolding o_def (*goal: ‹preorder_family agents (lotteries_on alts) (λx. SD (R x))›*) apply (intro preorder_family.intro (*‹⟦(?dom::?'a::type set) ≠ {}; ⋀i::?'a::type. i ∈ ?dom ⟹ Order_Predicates.preorder_on (?carrier::?'b::type set) ((?R::?'a::type ⇒ ?'b::type ⇒ ?'b::type ⇒ bool) i); ⋀(i::?'a::type) (x::?'b::type) y::?'b::type. i ∉ ?dom ⟹ ¬ ?R i x y⟧ ⟹ preorder_family ?dom ?carrier ?R›*) SD_is_preorder (*‹Order_Predicates.preorder_on (lotteries_on {x::?'a::type. (?R::?'a::type ⇒ ?'a::type ⇒ bool) x x}) (SD ?R)›*)) (*goals: 1. ‹(agents::'agent set) ≠ {}› 2. ‹⋀i::'agent. i ∈ (agents::'agent set) ⟹ Order_Predicates.preorder_on (lotteries_on (alts::'alt set)) (SD ((R::'agent ⇒ 'alt ⇒ 'alt ⇒ bool) i))› 3. ‹⋀(i::'agent) (x::'alt pmf) y::'alt pmf. i ∉ (agents::'agent set) ⟹ ¬ SD ((R::'agent ⇒ 'alt ⇒ 'alt ⇒ bool) i) x y› discuss goal 1*) apply (simp add: preorder_on.SD_is_preorder' (*‹Order_Predicates.preorder_on ?carrier ?le ⟹ Order_Predicates.preorder_on (lotteries_on ?carrier) (SD ?le)›*) prefs_undefined' (*‹?i ∉ agents ⟹ R ?i = (λ_ _. False)›*)) (*discuss goal 2*) apply (simp add: preorder_on.SD_is_preorder' (*‹Order_Predicates.preorder_on ?carrier ?le ⟹ Order_Predicates.preorder_on (lotteries_on ?carrier) (SD ?le)›*) prefs_undefined' (*‹?i ∉ agents ⟹ R ?i = (λ_ _. False)›*)) (*discuss goal 3*) apply (simp add: preorder_on.SD_is_preorder' (*‹Order_Predicates.preorder_on ?carrier ?le ⟹ Order_Predicates.preorder_on (lotteries_on ?carrier) (SD ?le)›*) prefs_undefined' (*‹?i ∉ agents ⟹ R ?i = (λ_ _. False)›*)) (*proven 3 subgoals*) . text ‹ A lottery is considered SD-efficient if there is no other lottery such that all agents weakly prefer the other lottery (w.r.t. stochastic dominance) and at least one agent strongly prefers the other lottery. › lemma SD_efficient_def: "SD_efficient R p ⟷ ¬(∃q∈lotteries_on alts. q ≻[Pareto (SD ∘ R)] p)" proof (-) (*goal: ‹SD_efficient R p = (¬ (∃q∈lotteries_on alts. p ≺[Pareto (SD ∘ R)] q))›*) have "SD_efficient R p ⟷ ¬(∃q∈lotteries_on {x. ∃i. R i x x}. q ≻[Pareto (SD ∘ R)] p)" unfolding SD_efficient_auxdef (*goal: ‹(¬ Bex (lotteries_on {x. ∃i. R i x x}) (strongly_preferred p (Pareto (SD ∘ R)))) = (¬ (∃q∈lotteries_on {x. ∃i. R i x x}. p ≺[Pareto (SD ∘ R)] q))›*) by standard also (*calculation: ‹SD_efficient R p = (¬ (∃q∈lotteries_on {x. ∃i. R i x x}. p ≺[Pareto (SD ∘ R)] q))›*) from nonempty_agents (*‹agents ≠ {}›*) obtain i where i: "i ∈ agents" (*goal: ‹(⋀i::'agent. i ∈ (agents::'agent set) ⟹ thesis::bool) ⟹ thesis›*) by blast with preorder_on.refl[of alts "R i"] (*‹⟦Order_Predicates.preorder_on alts (R i); ?x ∈ alts⟧ ⟹ R i ?x ?x›*) have "{x. ∃i. R i x x} = alts" by (auto intro!: exI[of _ i] (*‹?P i ⟹ ∃x. ?P x›*) not_outside (*‹R ?i ?x ?y ⟹ ?i ∈ agents› ‹R ?i ?x ?y ⟹ ?x ∈ alts› ‹R ?i ?x ?y ⟹ ?y ∈ alts›*)) finally (*calculation: ‹SD_efficient R p = (¬ (∃q∈lotteries_on alts. p ≺[Pareto (SD ∘ R)] q))›*) show "?thesis" (*goal: ‹SD_efficient R p = (¬ (∃q∈lotteries_on alts. p ≺[Pareto (SD ∘ R)] q))›*) . qed lemma SD_efficient_def': "SD_efficient R p ⟷ ¬(∃q∈lotteries_on alts. (∀i∈agents. q ≽[SD(R i)] p) ∧ (∃i∈agents. q ≻[SD(R i)] p))" unfolding SD_efficient_def SD.Pareto_iff strongly_preferred_def[abs_def] (*goal: ‹(¬ (∃b::'alt pmf∈lotteries_on (alts::'alt set). (∀i::'agent∈agents::'agent set. (SD ∘ (R::'agent ⇒ 'alt ⇒ 'alt ⇒ bool)) i (p::'alt pmf) b) ∧ ¬ (∀i::'agent∈agents. (SD ∘ R) i b p))) = (¬ (∃q::'alt pmf∈lotteries_on alts. (∀i::'agent∈agents. SD (R i) p q) ∧ (∃i::'agent∈agents. SD (R i) p q ∧ ¬ SD (R i) q p)))›*) by auto lemma SD_inefficientI: assumes "q ∈ lotteries_on alts" "⋀i. i ∈ agents ⟹ q ≽[SD(R i)] p" "i ∈ agents" "q ≻[SD(R i)] p" shows "¬SD_efficient R p" using assms (*‹(q::'alt::type pmf) ∈ lotteries_on (alts::'alt::type set)› ‹(?i::'agent) ∈ (agents::'agent set) ⟹ SD ((R::'agent ⇒ 'alt ⇒ 'alt ⇒ bool) ?i) (p::'alt pmf) (q::'alt pmf)› ‹i ∈ agents› ‹(p::'alt pmf) ≺[SD ((R::'agent ⇒ 'alt ⇒ 'alt ⇒ bool) (i::'agent))] (q::'alt pmf)›*) unfolding SD_efficient_def' (*goal: ‹¬ ¬ (∃q∈lotteries_on alts. (∀i∈agents. SD (R i) p q) ∧ (∃i∈agents. p ≺[SD (R i)] q))›*) by blast lemma SD_inefficientI': assumes "q ∈ lotteries_on alts" "⋀i. i ∈ agents ⟹ q ≽[SD(R i)] p" "∃i ∈ agents. q ≻[SD(R i)] p" shows "¬SD_efficient R p" using assms (*‹q ∈ lotteries_on alts› ‹?i ∈ agents ⟹ SD (R ?i) p q› ‹∃i∈agents. p ≺[SD (R i)] q›*) unfolding SD_efficient_def' (*goal: ‹¬ ¬ (∃q::'alt pmf∈lotteries_on (alts::'alt set). (∀i::'agent∈agents::'agent set. SD ((R::'agent ⇒ 'alt ⇒ 'alt ⇒ bool) i) (p::'alt pmf) q) ∧ (∃i::'agent∈agents. p ≺[SD (R i)] q))›*) by blast lemma SD_inefficientE: assumes "¬SD_efficient R p" obtains q i where "q ∈ lotteries_on alts" "⋀i. i ∈ agents ⟹ q ≽[SD(R i)] p" "i ∈ agents" "q ≻[SD(R i)] p" using assms (*‹¬ SD_efficient R p›*) unfolding SD_efficient_def' (*goal: ‹(⋀q i. ⟦q ∈ lotteries_on alts; ⋀i. i ∈ agents ⟹ SD (R i) p q; i ∈ agents; p ≺[SD (R i)] q⟧ ⟹ thesis) ⟹ thesis›*) by blast lemma SD_efficientD: assumes "SD_efficient R p" "q ∈ lotteries_on alts" and "⋀i. i ∈ agents ⟹ q ≽[SD(R i)] p" "∃i∈agents. ¬(q ≼[SD(R i)] p)" shows False using assms (*‹SD_efficient R p› ‹q ∈ lotteries_on alts› ‹(?i::'agent::type) ∈ (agents::'agent::type set) ⟹ SD ((R::'agent::type ⇒ 'alt::type ⇒ 'alt::type ⇒ bool) ?i) (p::'alt::type pmf) (q::'alt::type pmf)› ‹∃i∈agents. ¬ SD (R i) q p›*) unfolding SD_efficient_def' strongly_preferred_def (*goal: ‹False›*) by blast lemma SD_efficient_singleton_iff: assumes [simp]: "x ∈ alts" shows "SD_efficient R (return_pmf x) ⟷ x ∉ pareto_losers R" proof (-) (*goal: ‹SD_efficient (R::'agent ⇒ 'alt ⇒ 'alt ⇒ bool) (return_pmf (x::'alt)) = (x ∉ pareto_losers R)›*) { assume "x ∈ pareto_losers R" (*‹(x::'alt) ∈ pareto_losers (R::'agent ⇒ 'alt ⇒ 'alt ⇒ bool)›*) then obtain y where "y ∈ alts" "x ≺[Pareto R] y" (*goal: ‹(⋀y. ⟦y ∈ alts; x ≺[Pareto R] y⟧ ⟹ thesis) ⟹ thesis›*) by (rule pareto_losersE (*‹⟦(?x::'alt) ∈ pareto_losers (R::'agent ⇒ 'alt ⇒ 'alt ⇒ bool); ⋀y::'alt. ⟦y ∈ (alts::'alt set); ?x ≺[Pareto R] y⟧ ⟹ ?thesis::bool⟧ ⟹ ?thesis›*)) then have "¬SD_efficient R (return_pmf x)" apply (intro SD_inefficientI'[of "return_pmf y"] (*‹⟦return_pmf y ∈ lotteries_on alts; ⋀i. i ∈ agents ⟹ SD (R i) ?p (return_pmf y); ∃i∈agents. ?p ≺[SD (R i)] return_pmf y⟧ ⟹ ¬ SD_efficient R ?p›*)) (*goals: 1. ‹⟦y ∈ alts; x ≺[Pareto R] y⟧ ⟹ return_pmf y ∈ lotteries_on alts› 2. ‹⋀i. ⟦y ∈ alts; x ≺[Pareto R] y; i ∈ agents⟧ ⟹ SD (R i) (return_pmf x) (return_pmf y)› 3. ‹⟦y ∈ alts; x ≺[Pareto R] y⟧ ⟹ ∃i∈agents. return_pmf x ≺[SD (R i)] return_pmf y› discuss goal 1*) apply (force simp: Pareto_strict_iff (*‹(?x::'alt) ≺[Pareto (R::'agent ⇒ 'alt ⇒ 'alt ⇒ bool)] (?y::'alt) = ((∀i::'agent∈agents::'agent set. R i ?x ?y) ∧ (∃i::'agent∈agents. ?x ≺[R i] ?y))›*)) (*discuss goal 2*) apply (force simp: Pareto_strict_iff (*‹?x ≺[Pareto R] ?y = ((∀i∈agents. R i ?x ?y) ∧ (∃i∈agents. ?x ≺[R i] ?y))›*)) (*discuss goal 3*) apply (force simp: Pareto_strict_iff (*‹(?x::'alt) ≺[Pareto (R::'agent ⇒ 'alt ⇒ 'alt ⇒ bool)] (?y::'alt) = ((∀i::'agent∈agents::'agent set. R i ?x ?y) ∧ (∃i::'agent∈agents. ?x ≺[R i] ?y))›*)) (*proven 3 subgoals*) . } moreover { assume "¬SD_efficient R (return_pmf x)" (*‹¬ SD_efficient (R::'agent ⇒ 'alt ⇒ 'alt ⇒ bool) (return_pmf (x::'alt))›*) from SD_inefficientE[OF this] (*‹(⋀q i. ⟦q ∈ lotteries_on alts; ⋀i. i ∈ agents ⟹ SD (R i) (return_pmf x) q; i ∈ agents; return_pmf x ≺[SD (R i)] q⟧ ⟹ ?thesis) ⟹ ?thesis›*) obtain q and i where q: "q ∈ lotteries_on alts" "⋀i. i ∈ agents ⟹ SD (R i) (return_pmf x) q" "i ∈ agents" "return_pmf x ≺[SD (R i)] q" (*goal: ‹(⋀q i. ⟦q ∈ lotteries_on alts; ⋀i. i ∈ agents ⟹ SD (R i) (return_pmf x) q; i ∈ agents; return_pmf x ≺[SD (R i)] q⟧ ⟹ thesis) ⟹ thesis›*) by blast from q (*‹q ∈ lotteries_on alts› ‹?i ∈ agents ⟹ SD (R ?i) (return_pmf x) q› ‹i ∈ agents› ‹return_pmf x ≺[SD (R i)] q›*) obtain y where "y ∈ set_pmf q" "y ≻[R i] x" (*goal: ‹(⋀y::'alt. ⟦y ∈ set_pmf (q::'alt pmf); (x::'alt) ≺[(R::'agent ⇒ 'alt ⇒ 'alt ⇒ bool) (i::'agent)] y⟧ ⟹ thesis::bool) ⟹ thesis›*) by (auto simp: SD_strict_singleton_left (*‹⟦?i ∈ agents; ?x ∈ alts; ?q ∈ lotteries_on alts⟧ ⟹ return_pmf ?x ≺[SD (R ?i)] ?q = ((∀y∈set_pmf ?q. R ?i ?x y) ∧ (∃y∈set_pmf ?q. ?x ≺[R ?i] y))›*)) with q (*‹q ∈ lotteries_on alts› ‹?i ∈ agents ⟹ SD (R ?i) (return_pmf x) q› ‹i ∈ agents› ‹return_pmf x ≺[SD (R i)] q›*) have "y ≻[Pareto(R)] x" by (fastforce simp: Pareto_strict_iff (*‹?x ≺[Pareto R] ?y = ((∀i∈agents. R i ?x ?y) ∧ (∃i∈agents. ?x ≺[R i] ?y))›*) SD_singleton_left (*‹⟦?i ∈ agents; ?x ∈ alts; ?q ∈ lotteries_on alts⟧ ⟹ SD (R ?i) (return_pmf ?x) ?q = (∀y∈set_pmf ?q. R ?i ?x y)›*)) hence "x ∈ pareto_losers R" by simp } ultimately show "?thesis" (*goal: ‹SD_efficient R (return_pmf x) = (x ∉ pareto_losers R)›*) by blast qed end subsection ‹Equivalence proof› text ‹ We now show that a lottery is preferred w.r.t. Stochastic Dominance iff it yields more expected utility for all compatible utility functions. › context finite_total_preorder_on begin abbreviation "is_vnm_utility ≡ vnm_utility carrier le" lemma utility_weak_ranking_index: "is_vnm_utility (λx. real (length (weak_ranking le) - weak_ranking_index x))" proof (standard) (*goal: ‹⋀x y. ⟦x ∈ carrier; y ∈ carrier⟧ ⟹ (real (length (weak_ranking le) - weak_ranking_index x) ≤ real (length (weak_ranking le) - weak_ranking_index y)) = le x y›*) fix x and y assume xy: "x ∈ carrier" "y ∈ carrier" (*‹(x::'a) ∈ (carrier::'a set)› ‹(y::'a) ∈ (carrier::'a set)›*) with this[THEN nth_weak_ranking_index ( 1 )] (*‹weak_ranking_index x < length (weak_ranking le)› ‹weak_ranking_index (y::'a) < length (weak_ranking (le::'a ⇒ 'a ⇒ bool))›*) this[THEN nth_weak_ranking_index ( 2 )] (*‹x ∈ weak_ranking le ! weak_ranking_index x› ‹y ∈ weak_ranking le ! weak_ranking_index y›*) show "(real (length (weak_ranking le) - weak_ranking_index x) ≤ real (length (weak_ranking le) - weak_ranking_index y)) ⟷ le x y" by (simp add: le_diff_iff' (*‹⟦?a ≤ ?c; ?b ≤ ?c⟧ ⟹ (?c - ?a ≤ ?c - ?b) = (?b ≤ ?a)›*)) qed (* TODO: one direction could probably be generalised to weakly consistent utility functions *) lemma SD_iff_expected_utilities_le: assumes "p ∈ lotteries_on carrier" "q ∈ lotteries_on carrier" shows "p ≼[SD(le)] q ⟷ (∀u. is_vnm_utility u ⟶ measure_pmf.expectation p u ≤ measure_pmf.expectation q u)" proof (safe) (*goals: 1. ‹⋀u::'a::type ⇒ real. ⟦SD (le::'a::type ⇒ 'a::type ⇒ bool) (p::'a::type pmf) (q::'a::type pmf); is_vnm_utility u⟧ ⟹ measure_pmf.expectation p u ≤ measure_pmf.expectation q u› 2. ‹∀u::'a::type ⇒ real. is_vnm_utility u ⟶ measure_pmf.expectation (p::'a::type pmf) u ≤ measure_pmf.expectation (q::'a::type pmf) u ⟹ SD (le::'a::type ⇒ 'a::type ⇒ bool) p q›*) fix u assume SD: "p ≼[SD(le)] q" and is_utility: "is_vnm_utility u" (*‹SD (le::'a ⇒ 'a ⇒ bool) (p::'a pmf) (q::'a pmf)› ‹is_vnm_utility (u::'a ⇒ real)›*) from is_utility (*‹is_vnm_utility u›*) interpret vnm_utility carrier le u . define xs where "xs = weak_ranking le" have le: "is_weak_ranking xs" "le = of_weak_ranking xs" (*goals: 1. ‹is_weak_ranking xs› 2. ‹le = of_weak_ranking xs› discuss goal 1*) apply (simp add: xs_def (*‹xs = weak_ranking le›*) weak_ranking_total_preorder (*‹is_weak_ranking (weak_ranking le)› ‹of_weak_ranking (weak_ranking le) = le›*)) (*discuss goal 2*) apply (simp add: xs_def (*‹xs = weak_ranking le›*) weak_ranking_total_preorder (*‹is_weak_ranking (weak_ranking le)› ‹of_weak_ranking (weak_ranking le) = le›*)) (*proven 2 subgoals*) . let ?pref = "λp x. measure_pmf.prob p {y. x ≼[le] y}" and ?pref' = "λp x. measure_pmf.prob p {y. x ≺[le] y}" define f where "f i = (SOME x. x ∈ xs ! i)" for i have xs_wf: "is_weak_ranking xs" by (simp add: xs_def (*‹xs = weak_ranking le›*) weak_ranking_total_preorder (*‹is_weak_ranking (weak_ranking le)› ‹of_weak_ranking (weak_ranking le) = le›*)) hence f: "f i ∈ xs ! i" if "i < length xs" for i using that (*‹(i::nat) < length (xs::'a set list)›*) unfolding f_def is_weak_ranking_def (*goal: ‹(SOME x. x ∈ xs ! i) ∈ xs ! i›*) apply (intro someI_ex[of "λx. x ∈ xs ! i"] (*‹∃x. x ∈ xs ! i ⟹ (SOME x. x ∈ xs ! i) ∈ xs ! i›*)) (*goal: ‹(SOME x. x ∈ xs ! i) ∈ xs ! i›*) by (auto simp: set_conv_nth (*‹set (?xs::?'a::type list) = {?xs ! i |i::nat. i < length ?xs}›*)) have f': "f i ∈ carrier" if "i < length xs" for i using that (*‹i < length xs›*) f (*‹?i < length xs ⟹ f ?i ∈ xs ! ?i›*) weak_ranking_Union (*‹⋃ (set (weak_ranking (le::'a::type ⇒ 'a::type ⇒ bool))) = (carrier::'a::type set)›*) unfolding xs_def (*goal: ‹f i ∈ carrier›*) by (auto simp: set_conv_nth (*‹set ?xs = {?xs ! i |i. i < length ?xs}›*)) define n where "n = length xs - 1" from assms (*‹(p::'a pmf) ∈ lotteries_on (carrier::'a set)› ‹q ∈ lotteries_on carrier›*) weak_ranking_Union (*‹⋃ (set (weak_ranking le)) = carrier›*) have carrier_nonempty: "carrier ≠ {}" and "xs ≠ []" apply - (*goals: 1. ‹⟦p ∈ lotteries_on carrier; q ∈ lotteries_on carrier; ⋃ (set (weak_ranking le)) = carrier⟧ ⟹ carrier ≠ {}› 2. ‹⟦p ∈ lotteries_on carrier; q ∈ lotteries_on carrier; ⋃ (set (weak_ranking le)) = carrier⟧ ⟹ xs ≠ []› discuss goal 1*) apply ((auto simp: xs_def (*‹xs = weak_ranking le›*) lotteries_on_def (*‹lotteries_on ?A = {p. set_pmf p ⊆ ?A}›*) set_pmf_not_empty (*‹set_pmf ?M ≠ {}›*))[1]) (*discuss goal 2*) apply ((auto simp: xs_def (*‹xs = weak_ranking le›*) lotteries_on_def (*‹lotteries_on ?A = {p. set_pmf p ⊆ ?A}›*) set_pmf_not_empty (*‹set_pmf ?M ≠ {}›*))[1]) (*proven 2 subgoals*) . hence n: "length xs = Suc n" and xs_nonempty: "xs ≠ []" apply - (*goals: 1. ‹⟦(carrier::'a set) ≠ {}; (xs::'a set list) ≠ []⟧ ⟹ length xs = Suc (n::nat)› 2. ‹⟦(carrier::'a set) ≠ {}; (xs::'a set list) ≠ []⟧ ⟹ xs ≠ []› discuss goal 1*) apply ((auto simp add: n_def (*‹n = length xs - 1›*))[1]) (*discuss goal 2*) apply ((auto simp add: n_def (*‹(n::nat) = length (xs::'a::type set list) - (1::nat)›*))[1]) (*proven 2 subgoals*) . have SD': "?pref p (f i) ≤ ?pref q (f i)" if "i < length xs" for i using f'[OF that] (*‹f i ∈ carrier›*) SD (*‹SD le p q›*) by (auto simp: SD_preorder (*‹SD le ?q ?p = (?p ∈ lotteries_on carrier ∧ ?q ∈ lotteries_on carrier ∧ (∀x∈carrier. measure_pmf.prob ?q (preferred_alts le x) ≤ measure_pmf.prob ?p (preferred_alts le x)))›*) preferred_alts_def (*‹preferred_alts ?R ?x = {y. ?R ?x y}›*)) have f_le: "le (f i) (f j) ⟷ i ≥ j" if "i < length xs" "j < length xs" for i and j using that (*‹i < length xs› ‹j < length xs›*) weak_ranking_index_unique[OF xs_wf that ( 1 ) _ f] (*‹⟦(?j::nat) < length (xs::'a::type set list); (i::nat) < length xs; (f::nat ⇒ 'a::type) i ∈ xs ! ?j⟧ ⟹ i = ?j›*) weak_ranking_index_unique[OF xs_wf that ( 2 ) _ f] (*‹⟦?j < length xs; j < length xs; f j ∈ xs ! ?j⟧ ⟹ j = ?j›*) by (auto simp add: le (*‹is_weak_ranking xs› ‹le = of_weak_ranking xs›*) intro: f (*‹?i < length xs ⟹ f ?i ∈ xs ! ?i›*) elim!: of_weak_ranking.cases (*‹⟦of_weak_ranking ?a1.0 ?a2.0 ?a3.0; ⋀i j xs x y. ⟦?a1.0 = xs; ?a2.0 = y; ?a3.0 = x; i ≤ j; i < length xs; j < length xs; x ∈ xs ! i; y ∈ xs ! j⟧ ⟹ ?P⟧ ⟹ ?P›*) intro!: of_weak_ranking.intros (*‹⟦?i ≤ ?j; ?i < length ?xs; ?j < length ?xs; ?x ∈ ?xs ! ?i; ?y ∈ ?xs ! ?j⟧ ⟹ of_weak_ranking ?xs ?y ?x›*)) have "measure_pmf.expectation p u = (∑i<n. (u (f i) - u (f (Suc i))) * ?pref p (f i)) + u (f n)" if p: "p ∈ lotteries_on carrier" for p proof (-) (*goal: ‹measure_pmf.expectation (p::'a pmf) (u::'a ⇒ real) = (∑i::nat<n::nat. (u ((f::nat ⇒ 'a) i) - u (f (Suc i))) * measure_pmf.prob p {y::'a. (le::'a ⇒ 'a ⇒ bool) (f i) y}) + u (f n)›*) from p (*‹p ∈ lotteries_on carrier›*) have "measure_pmf.expectation p u = (∑i<length xs. u (f i) * measure_pmf.prob p (xs ! i))" by (simp add: f_def (*‹f ?i = (SOME x. x ∈ xs ! ?i)›*) expected_utility_weak_ranking (*‹?p ∈ lotteries_on carrier ⟹ measure_pmf.expectation ?p u = (∑A←weak_ranking le. u (SOME x. x ∈ A) * measure_pmf.prob ?p A)›*) xs_def (*‹xs = weak_ranking le›*) sum_list_sum_nth (*‹sum_list ?xs = sum ((!) ?xs) {0..<length ?xs}›*) atLeast0LessThan (*‹{0..<?n} = {..<?n}›*)) also (*calculation: ‹measure_pmf.expectation p u = (∑i<length xs. u (f i) * measure_pmf.prob p (xs ! i))›*) have "… = (∑i<length xs. u (f i) * (?pref p (f i) - ?pref' p (f i)))" proof (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›*) HOL.refl (*‹(?t::?'a) = ?t›*)) (*goal: ‹⋀x. x ∈ {..<length xs} ⟹ u (f x) * measure_pmf.prob p (xs ! x) = u (f x) * (measure_pmf.prob p {y. le (f x) y} - measure_pmf.prob p {y. f x ≺[le] y})›*) fix i assume i: "i ∈ {..<length xs}" (*‹(i::nat) ∈ {..<length (xs::'a set list)}›*) have "?pref p (f i) - ?pref' p (f i) = measure_pmf.prob p ({y. f i ≼[le] y} - {y. f i ≺[le] y})" apply (subst measure_pmf.finite_measure_Diff [symmetric] (*‹⟦?A ∈ measure_pmf.events ?M; ?B ∈ measure_pmf.events ?M; ?B ⊆ ?A⟧ ⟹ measure_pmf.prob ?M ?A - measure_pmf.prob ?M ?B = measure_pmf.prob ?M (?A - ?B)›*)) (*goals: 1. ‹Collect (le (f i)) ∈ measure_pmf.events p› 2. ‹Collect (strongly_preferred (f i) le) ∈ measure_pmf.events p› 3. ‹Collect (strongly_preferred (f i) le) ⊆ Collect (le (f i))› 4. ‹measure_pmf.prob p (Collect (le (f i)) - Collect (strongly_preferred (f i) le)) = measure_pmf.prob p (Collect (le (f i)) - Collect (strongly_preferred (f i) le))› discuss goal 1*) apply ((auto simp: strongly_preferred_def (*‹?a ≺[?R] ?b ≡ ?R ?a ?b ∧ ¬ ?R ?b ?a›*))[1]) (*discuss goal 2*) apply ((auto simp: strongly_preferred_def (*‹?a ≺[?R] ?b ≡ ?R ?a ?b ∧ ¬ ?R ?b ?a›*))[1]) (*discuss goal 3*) apply ((auto simp: strongly_preferred_def (*‹?a ≺[?R] ?b ≡ ?R ?a ?b ∧ ¬ ?R ?b ?a›*))[1]) (*discuss goal 4*) apply ((auto simp: strongly_preferred_def (*‹?a ≺[?R] ?b ≡ ?R ?a ?b ∧ ¬ ?R ?b ?a›*))[1]) (*proven 4 subgoals*) . also (*calculation: ‹measure_pmf.prob p {y. le (f i) y} - measure_pmf.prob p {y. f i ≺[le] y} = measure_pmf.prob p ({y. le (f i) y} - {y. f i ≺[le] y})›*) have "{y. f i ≼[le] y} - {y. f i ≺[le] y} = {y. f i ≼[le] y ∧ y ≼[le] f i}" (is "_ = ?A") by (auto simp: strongly_preferred_def (*‹(?a::?'a) ≺[(?R::?'a ⇒ ?'a ⇒ bool)] (?b::?'a) ≡ ?R ?a ?b ∧ ¬ ?R ?b ?a›*)) also (*calculation: ‹measure_pmf.prob p {y. le (f i) y} - measure_pmf.prob p {y. f i ≺[le] y} = measure_pmf.prob p {y. le (f i) y ∧ le y (f i)}›*) have "… = xs ! i" proof (safe) (*goals: 1. ‹⋀x. ⟦le (f i) x; le x (f i)⟧ ⟹ x ∈ xs ! i› 2. ‹⋀x. x ∈ xs ! i ⟹ le (f i) x› 3. ‹⋀x. x ∈ xs ! i ⟹ le x (f i)›*) fix x assume le: "le (f i) x" "le x (f i)" (*‹(le::'a ⇒ 'a ⇒ bool) ((f::nat ⇒ 'a) (i::nat)) (x::'a)› ‹(le::'a ⇒ 'a ⇒ bool) (x::'a) ((f::nat ⇒ 'a) (i::nat))›*) from i (*‹i ∈ {..<length xs}›*) f (*‹?i < length xs ⟹ f ?i ∈ xs ! ?i›*) show "x ∈ xs ! i" apply (intro weak_ranking_eqclass2[OF _ _ le] (*‹⟦?A ∈ set (weak_ranking le); f i ∈ ?A⟧ ⟹ x ∈ ?A›*)) (*goals: 1. ‹⟦i ∈ {..<length xs}; ⋀i. i < length xs ⟹ f i ∈ xs ! i⟧ ⟹ xs ! i ∈ set (weak_ranking le)› 2. ‹⟦i ∈ {..<length xs}; ⋀i. i < length xs ⟹ f i ∈ xs ! i⟧ ⟹ f i ∈ xs ! i› discuss goal 1*) apply ((auto simp: xs_def (*‹xs = weak_ranking le›*))[1]) (*discuss goal 2*) apply ((auto simp: xs_def (*‹xs = weak_ranking le›*))[1]) (*proven 2 subgoals*) . next (*goals: 1. ‹⋀x::'a::type. x ∈ (xs::'a::type set list) ! (i::nat) ⟹ (le::'a::type ⇒ 'a::type ⇒ bool) ((f::nat ⇒ 'a::type) i) x› 2. ‹⋀x::'a::type. x ∈ (xs::'a::type set list) ! (i::nat) ⟹ (le::'a::type ⇒ 'a::type ⇒ bool) x ((f::nat ⇒ 'a::type) i)›*) fix x assume "x ∈ xs ! i" (*‹(x::'a) ∈ (xs::'a set list) ! (i::nat)›*) from weak_ranking_eqclass1[OF _ this f] (*‹⟦xs ! i ∈ set (weak_ranking le); i < length xs⟧ ⟹ le x (f i)›*) weak_ranking_eqclass1[OF _ f this] (*‹⟦xs ! i ∈ set (weak_ranking le); i < length xs⟧ ⟹ le (f i) x›*) i (*‹(i::nat) ∈ {..<length (xs::'a::type set list)}›*) show "le x (f i)" "le (f i) x" apply - (*goals: 1. ‹⟦⟦xs ! i ∈ set (weak_ranking le); i < length xs⟧ ⟹ le x (f i); ⟦xs ! i ∈ set (weak_ranking le); i < length xs⟧ ⟹ le (f i) x; i ∈ {..<length xs}⟧ ⟹ le x (f i)› 2. ‹⟦⟦xs ! i ∈ set (weak_ranking le); i < length xs⟧ ⟹ le x (f i); ⟦xs ! i ∈ set (weak_ranking le); i < length xs⟧ ⟹ le (f i) x; i ∈ {..<length xs}⟧ ⟹ le (f i) x› discuss goal 1*) apply (simp add: xs_def (*‹xs = weak_ranking le›*)) (*discuss goal 2*) apply (simp add: xs_def (*‹(xs::'a set list) = weak_ranking (le::'a ⇒ 'a ⇒ bool)›*)) (*proven 2 subgoals*) . qed finally (*calculation: ‹measure_pmf.prob p {y. le (f i) y} - measure_pmf.prob p {y. f i ≺[le] y} = measure_pmf.prob p (xs ! i)›*) show "u (f i) * measure_pmf.prob p (xs ! i) = u (f i) * (?pref p (f i) - ?pref' p (f i))" by simp qed also (*calculation: ‹measure_pmf.expectation p u = (∑i<length xs. u (f i) * (measure_pmf.prob p {y. le (f i) y} - measure_pmf.prob p {y. f i ≺[le] y}))›*) have "… = (∑i<length xs. u (f i) * ?pref p (f i)) - (∑i<length xs. u (f i) * ?pref' p (f i))" by (simp add: sum_subtractf (*‹(∑x::?'b∈(?A::?'b set). (?f::?'b ⇒ ?'a) x - (?g::?'b ⇒ ?'a) x) = sum ?f ?A - sum ?g ?A›*) ring_distribs (*‹(?a::?'a) * ((?b::?'a) + (?c::?'a)) = ?a * ?b + ?a * ?c› ‹((?a::?'a) + (?b::?'a)) * (?c::?'a) = ?a * ?c + ?b * ?c› ‹((?a::?'a) - (?b::?'a)) * (?c::?'a) = ?a * ?c - ?b * ?c› ‹(?a::?'a) * ((?b::?'a) - (?c::?'a)) = ?a * ?b - ?a * ?c›*)) also (*calculation: ‹measure_pmf.expectation p u = (∑i<length xs. u (f i) * measure_pmf.prob p {y. le (f i) y}) - (∑i<length xs. u (f i) * measure_pmf.prob p {y. f i ≺[le] y})›*) have "(∑i<length xs. u (f i) * ?pref p (f i)) = (∑i<n. u (f i) * ?pref p (f i)) + u (f n) * ?pref p (f n)" (is "_ = ?sum") by (simp add: n (*‹length (xs::'a::type set list) = Suc (n::nat)›*)) also (*calculation: ‹measure_pmf.expectation p u = (∑i<n. u (f i) * measure_pmf.prob p {y. le (f i) y}) + u (f n) * measure_pmf.prob p {y. le (f n) y} - (∑i<length xs. u (f i) * measure_pmf.prob p {y. f i ≺[le] y})›*) have "(∑i<length xs. u (f i) * ?pref' p (f i)) = (∑i<n. u (f (Suc i)) * ?pref' p (f (Suc i))) + u (f 0) * ?pref' p (f 0)" unfolding n sum.lessThan_Suc_shift (*goal: ‹u (f 0) * measure_pmf.prob p (Collect (strongly_preferred (f 0) le)) + (∑i<n. u (f (Suc i)) * measure_pmf.prob p (Collect (strongly_preferred (f (Suc i)) le))) = (∑i<n. u (f (Suc i)) * measure_pmf.prob p {y. f (Suc i) ≺[le] y}) + u (f 0) * measure_pmf.prob p {y. f 0 ≺[le] y}›*) by simp also (*calculation: ‹measure_pmf.expectation p u = (∑i<n. u (f i) * measure_pmf.prob p {y. le (f i) y}) + u (f n) * measure_pmf.prob p {y. le (f n) y} - ((∑i<n. u (f (Suc i)) * measure_pmf.prob p {y. f (Suc i) ≺[le] y}) + u (f 0) * measure_pmf.prob p {y. f 0 ≺[le] y})›*) have "(∑i<n. u (f (Suc i)) * ?pref' p (f (Suc i))) = (∑i<n. u (f (Suc i)) * ?pref p (f i))" proof (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›*) HOL.refl (*‹(?t::?'a) = ?t›*)) (*goal: ‹⋀x::nat. x ∈ {..<n::nat} ⟹ (u::'a::type ⇒ real) ((f::nat ⇒ 'a::type) (Suc x)) * measure_pmf.prob (p::'a::type pmf) {y::'a::type. f (Suc x) ≺[(le::'a::type ⇒ 'a::type ⇒ bool)] y} = u (f (Suc x)) * measure_pmf.prob p {y::'a::type. le (f x) y}›*) fix i assume i: "i ∈ {..<n}" (*‹(i::nat) ∈ {..<n::nat}›*) have "f (Suc i) ≺[le] y ⟷ f i ≼[le] y" for y proof (cases "y ∈ carrier") (*goals: 1. ‹y ∈ carrier ⟹ f (Suc i) ≺[le] y = le (f i) y› 2. ‹y ∉ carrier ⟹ f (Suc i) ≺[le] y = le (f i) y›*) assume "y ∈ carrier" (*‹(y::'a) ∈ (carrier::'a set)›*) with weak_ranking_Union (*‹⋃ (set (weak_ranking le)) = carrier›*) obtain j where j: "j < length xs" "y ∈ xs ! j" (*goal: ‹(⋀j. ⟦j < length xs; y ∈ xs ! j⟧ ⟹ thesis) ⟹ thesis›*) by (auto simp: set_conv_nth (*‹set ?xs = {?xs ! i |i. i < length ?xs}›*) xs_def (*‹xs = weak_ranking le›*)) with weak_ranking_eqclass1[OF _ f j ( 2 )] (*‹⟦xs ! j ∈ set (weak_ranking le); j < length xs⟧ ⟹ le (f j) y›*) weak_ranking_eqclass1[OF _ j ( 2 ) f] (*‹⟦xs ! j ∈ set (weak_ranking le); j < length xs⟧ ⟹ le y (f j)›*) have iff: "le y z ⟷ le (f j) z" "le z y ⟷ le z (f j)" for z apply - (*goals: 1. ‹⟦⟦xs ! j ∈ set (weak_ranking le); j < length xs⟧ ⟹ le (f j) y; ⟦xs ! j ∈ set (weak_ranking le); j < length xs⟧ ⟹ le y (f j); j < length xs; y ∈ xs ! j⟧ ⟹ le y z = le (f j) z› 2. ‹⟦⟦xs ! j ∈ set (weak_ranking le); j < length xs⟧ ⟹ le (f j) y; ⟦xs ! j ∈ set (weak_ranking le); j < length xs⟧ ⟹ le y (f j); j < length xs; y ∈ xs ! j⟧ ⟹ le z y = le z (f j)› discuss goal 1*) apply ((auto intro: trans (*‹⟦le ?x ?y; le ?y ?z⟧ ⟹ le ?x ?z›*) simp: xs_def (*‹xs = weak_ranking le›*))[1]) (*discuss goal 2*) apply ((auto intro: trans (*‹⟦(le::'a::type ⇒ 'a::type ⇒ bool) (?x::'a::type) (?y::'a::type); le ?y (?z::'a::type)⟧ ⟹ le ?x ?z›*) simp: xs_def (*‹(xs::'a::type set list) = weak_ranking (le::'a::type ⇒ 'a::type ⇒ bool)›*))[1]) (*proven 2 subgoals*) . thus "?thesis" (*goal: ‹f (Suc i) ≺[le] y = le (f i) y›*) using i (*‹i ∈ {..<n}›*) j (*‹(j::nat) < length (xs::'a set list)› ‹y ∈ xs ! j›*) unfolding n_def (*goal: ‹(f::nat ⇒ 'a) (Suc (i::nat)) ≺[(le::'a ⇒ 'a ⇒ bool)] (y::'a) = le (f i) y›*) by (auto simp: iff (*‹le y ?z = le (f j) ?z› ‹le ?z y = le ?z (f j)›*) f_le (*‹⟦?i < length xs; ?j < length xs⟧ ⟹ le (f ?i) (f ?j) = (?j ≤ ?i)›*) strongly_preferred_def (*‹?a ≺[?R] ?b ≡ ?R ?a ?b ∧ ¬ ?R ?b ?a›*)) qed (insert not_outside (*‹le ?x ?y ⟹ ?x ∈ carrier› ‹le ?x ?y ⟹ ?y ∈ carrier›*), auto simp: strongly_preferred_def (*‹?a ≺[?R] ?b ≡ ?R ?a ?b ∧ ¬ ?R ?b ?a›*)) (*solved the remaining goal: ‹y ∉ carrier ⟹ f (Suc i) ≺[le] y = le (f i) y›*) thus "u (f (Suc i)) * ?pref' p (f (Suc i)) = u (f (Suc i)) * ?pref p (f i)" by simp qed also (*calculation: ‹measure_pmf.expectation (p::'a pmf) (u::'a ⇒ real) = (∑i::nat<n::nat. u ((f::nat ⇒ 'a) i) * measure_pmf.prob p {y::'a. (le::'a ⇒ 'a ⇒ bool) (f i) y}) + u (f n) * measure_pmf.prob p {y::'a. le (f n) y} - ((∑i::nat<n. u (f (Suc i)) * measure_pmf.prob p {y::'a. le (f i) y}) + u (f (0::nat)) * measure_pmf.prob p {y::'a. f (0::nat) ≺[le] y})›*) have "?sum - (… + u (f 0) * ?pref' p (f 0)) = (∑i<n. (u (f i) - u (f (Suc i))) * ?pref p (f i)) - u (f 0) * ?pref' p (f 0) + u (f n) * ?pref p (f n)" by (simp add: 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›*) sum_subtractf (*‹(∑x∈?A. ?f x - ?g x) = sum ?f ?A - sum ?g ?A›*)) also (*calculation: ‹measure_pmf.expectation p u = (∑i<n. (u (f i) - u (f (Suc i))) * measure_pmf.prob p {y. le (f i) y}) - u (f 0) * measure_pmf.prob p {y. f 0 ≺[le] y} + u (f n) * measure_pmf.prob p {y. le (f n) y}›*) have "{y. f 0 ≺[le] y} = {}" using hd_weak_ranking[of "f 0"] (*‹⟦f 0 ∈ hd (weak_ranking le); ?y ∈ carrier⟧ ⟹ le ?y (f 0)›*) xs_nonempty (*‹xs ≠ []›*) f (*‹(?i::nat) < length (xs::'a set list) ⟹ (f::nat ⇒ 'a) ?i ∈ xs ! ?i›*) not_outside (*‹le ?x ?y ⟹ ?x ∈ carrier› ‹le ?x ?y ⟹ ?y ∈ carrier›*) by (auto simp: hd_conv_nth (*‹(?xs::?'a::type list) ≠ [] ⟹ hd ?xs = ?xs ! (0::nat)›*) xs_def (*‹(xs::'a::type set list) = weak_ranking (le::'a::type ⇒ 'a::type ⇒ bool)›*) strongly_preferred_def (*‹(?a::?'a::type) ≺[(?R::?'a::type ⇒ ?'a::type ⇒ bool)] (?b::?'a::type) ≡ ?R ?a ?b ∧ ¬ ?R ?b ?a›*)) also (*calculation: ‹measure_pmf.expectation p u = (∑i<n. (u (f i) - u (f (Suc i))) * measure_pmf.prob p {y. le (f i) y}) - u (f 0) * measure_pmf.prob p {} + u (f n) * measure_pmf.prob p {y. le (f n) y}›*) have "{y. le (f n) y} = carrier" using last_weak_ranking[of "f n"] (*‹⟦f n ∈ last (weak_ranking le); ?y ∈ carrier⟧ ⟹ le (f n) ?y›*) xs_nonempty (*‹xs ≠ []›*) f (*‹?i < length xs ⟹ f ?i ∈ xs ! ?i›*) not_outside (*‹(le::'a ⇒ 'a ⇒ bool) (?x::'a) (?y::'a) ⟹ ?x ∈ (carrier::'a set)› ‹(le::'a ⇒ 'a ⇒ bool) (?x::'a) (?y::'a) ⟹ ?y ∈ (carrier::'a set)›*) by (auto simp: last_conv_nth (*‹(?xs::?'a list) ≠ [] ⟹ last ?xs = ?xs ! (length ?xs - (1::nat))›*) xs_def (*‹(xs::'a set list) = weak_ranking (le::'a ⇒ 'a ⇒ bool)›*) n_def (*‹(n::nat) = length (xs::'a set list) - (1::nat)›*)) also (*calculation: ‹measure_pmf.expectation p u = (∑i<n. (u (f i) - u (f (Suc i))) * measure_pmf.prob p {y. le (f i) y}) - u (f 0) * measure_pmf.prob p {} + u (f n) * measure_pmf.prob p carrier›*) from p (*‹p ∈ lotteries_on carrier›*) have "measure_pmf.prob p carrier = 1" apply (subst measure_pmf.prob_eq_1 (*‹(?A::?'a::type set) ∈ measure_pmf.events (?M::?'a::type pmf) ⟹ (measure_pmf.prob ?M ?A = (1::real)) = (AE x::?'a::type in measure_pmf ?M. x ∈ ?A)›*)) (*goals: 1. ‹p ∈ lotteries_on carrier ⟹ carrier ∈ measure_pmf.events p› 2. ‹p ∈ lotteries_on carrier ⟹ AE x in measure_pmf p. x ∈ carrier› discuss goal 1*) apply ((auto simp: AE_measure_pmf_iff (*‹almost_everywhere (measure_pmf (?M::?'a::type pmf)) (?P::?'a::type ⇒ bool) = (∀y::?'a::type∈set_pmf ?M. ?P y)›*) lotteries_on_def (*‹lotteries_on (?A::?'a::type set) = {p::?'a::type pmf. set_pmf p ⊆ ?A}›*))[1]) (*discuss goal 2*) apply ((auto simp: AE_measure_pmf_iff (*‹almost_everywhere (measure_pmf ?M) ?P = (∀y∈set_pmf ?M. ?P y)›*) lotteries_on_def (*‹lotteries_on ?A = {p. set_pmf p ⊆ ?A}›*))[1]) (*proven 2 subgoals*) . finally (*calculation: ‹measure_pmf.expectation p u = (∑i<n. (u (f i) - u (f (Suc i))) * measure_pmf.prob p {y. le (f i) y}) - u (f 0) * measure_pmf.prob p {} + u (f n) * 1›*) show "?thesis" (*goal: ‹measure_pmf.expectation (p::'a pmf) (u::'a ⇒ real) = (∑i::nat<n::nat. (u ((f::nat ⇒ 'a) i) - u (f (Suc i))) * measure_pmf.prob p {y::'a. (le::'a ⇒ 'a ⇒ bool) (f i) y}) + u (f n)›*) by simp qed from assms[THEN this] (*‹measure_pmf.expectation p u = (∑i<n. (u (f i) - u (f (Suc i))) * measure_pmf.prob p {y. le (f i) y}) + u (f n)› ‹measure_pmf.expectation q u = (∑i<n. (u (f i) - u (f (Suc i))) * measure_pmf.prob q {y. le (f i) y}) + u (f n)›*) show "measure_pmf.expectation p u ≤ measure_pmf.expectation q u" unfolding SD_preorder n_def (*goal: ‹measure_pmf.expectation p u ≤ measure_pmf.expectation q u›*) using f' (*‹?i < length xs ⟹ f ?i ∈ carrier›*) by (auto 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_left_mono (*‹⟦(?a::?'a::ordered_semiring) ≤ (?b::?'a::ordered_semiring); (0::?'a::ordered_semiring) ≤ (?c::?'a::ordered_semiring)⟧ ⟹ ?c * ?a ≤ ?c * ?b›*) SD' (*‹(?i::nat) < length (xs::'a::type set list) ⟹ measure_pmf.prob (p::'a::type pmf) {y::'a::type. (le::'a::type ⇒ 'a::type ⇒ bool) ((f::nat ⇒ 'a::type) ?i) y} ≤ measure_pmf.prob (q::'a::type pmf) {y::'a::type. le (f ?i) y}›*) simp: utility_le_iff (*‹⟦(?x::'a::type) ∈ (carrier::'a::type set); (?y::'a::type) ∈ carrier⟧ ⟹ ((u::'a::type ⇒ real) ?x ≤ u ?y) = (le::'a::type ⇒ 'a::type ⇒ bool) ?x ?y›*) f_le (*‹⟦(?i::nat) < length (xs::'a::type set list); (?j::nat) < length xs⟧ ⟹ (le::'a::type ⇒ 'a::type ⇒ bool) ((f::nat ⇒ 'a::type) ?i) (f ?j) = (?j ≤ ?i)›*)) next (*goal: ‹∀u. is_vnm_utility u ⟶ measure_pmf.expectation p u ≤ measure_pmf.expectation q u ⟹ SD le p q›*) assume "∀u. is_vnm_utility u ⟶ measure_pmf.expectation p u ≤ measure_pmf.expectation q u" (*‹∀u::'a ⇒ real. is_vnm_utility u ⟶ measure_pmf.expectation (p::'a pmf) u ≤ measure_pmf.expectation (q::'a pmf) u›*) hence expected_utility_le: "measure_pmf.expectation p u ≤ measure_pmf.expectation q u" if "is_vnm_utility u" for u using that (*‹is_vnm_utility (u::'a::type ⇒ real)›*) by blast define xs where "xs = weak_ranking le" have le: "le = of_weak_ranking xs" and [simp]: "is_weak_ranking xs" (*goals: 1. ‹le = of_weak_ranking xs› 2. ‹is_weak_ranking xs› discuss goal 1*) apply (simp add: xs_def (*‹(xs::'a::type set list) = weak_ranking (le::'a::type ⇒ 'a::type ⇒ bool)›*) weak_ranking_total_preorder (*‹is_weak_ranking (weak_ranking (le::'a::type ⇒ 'a::type ⇒ bool))› ‹of_weak_ranking (weak_ranking (le::'a::type ⇒ 'a::type ⇒ bool)) = le›*)) (*discuss goal 2*) apply (simp add: xs_def (*‹(xs::'a set list) = weak_ranking (le::'a ⇒ 'a ⇒ bool)›*) weak_ranking_total_preorder (*‹is_weak_ranking (weak_ranking (le::'a ⇒ 'a ⇒ bool))› ‹of_weak_ranking (weak_ranking (le::'a ⇒ 'a ⇒ bool)) = le›*)) (*proven 2 subgoals*) . have carrier: "carrier = ⋃(set xs)" by (simp add: xs_def (*‹xs = weak_ranking le›*) weak_ranking_Union (*‹⋃ (set (weak_ranking le)) = carrier›*)) from assms (*‹(p::'a pmf) ∈ lotteries_on (carrier::'a set)› ‹q ∈ lotteries_on carrier›*) have carrier_nonempty: "carrier ≠ {}" by (auto simp: lotteries_on_def (*‹lotteries_on (?A::?'a set) = {p::?'a pmf. set_pmf p ⊆ ?A}›*) set_pmf_not_empty (*‹set_pmf (?M::?'a pmf) ≠ {}›*)) { fix x assume x: "x ∈ carrier" (*‹(x::'a) ∈ (carrier::'a set)›*) let ?idx = "λy. length xs - weak_ranking_index y" have preferred_subset_carrier: "{y. le x y} ⊆ carrier" using not_outside (*‹le ?x ?y ⟹ ?x ∈ carrier› ‹le ?x ?y ⟹ ?y ∈ carrier›*) x (*‹(x::'a) ∈ (carrier::'a set)›*) by auto have "measure_pmf.prob p {y. le x y} / real (length xs) ≤ measure_pmf.prob q {y. le x y} / real (length xs)" proof (rule field_le_epsilon (*‹(⋀e::?'a. (0::?'a) < e ⟹ (?x::?'a) ≤ (?y::?'a) + e) ⟹ ?x ≤ ?y›*)) (*goal: ‹⋀e. 0 < e ⟹ measure_pmf.prob p {y. le x y} / real (length xs) ≤ measure_pmf.prob q {y. le x y} / real (length xs) + e›*) fix ε :: real assume "ε": "ε > 0" (*‹(0::real) < (ε::real)›*) define u where "u y = indicator {y. y ≽[le] x} y + ε * ?idx y" for y have is_utility: "is_vnm_utility u" unfolding u_def xs_def (*goal: ‹is_vnm_utility (λy. indicat_real (Collect (le x)) y + ε * real (length (weak_ranking le) - weak_ranking_index y))›*) proof (intro vnm_utility.add_left (*‹⟦vnm_utility ?carrier ?le ?u; ⋀x y. ?le x y ⟹ ?f x ≤ ?f y⟧ ⟹ vnm_utility ?carrier ?le (λx. ?f x + ?u x)›*) vnm_utility.scaled (*‹⟦vnm_utility ?carrier ?le ?u; 0 < ?c⟧ ⟹ vnm_utility ?carrier ?le (λx. ?c * ?u x)›*) utility_weak_ranking_index (*‹is_vnm_utility (λx. real (length (weak_ranking le) - weak_ranking_index x))›*)) (*goals: 1. ‹0 < ε› 2. ‹⋀y ya. le y ya ⟹ indicat_real (Collect (le x)) y ≤ indicat_real (Collect (le x)) ya›*) fix y and z assume "le y z" (*‹(le::'a ⇒ 'a ⇒ bool) (y::'a) (z::'a)›*) thus "indicator {y. y ≽[le] x} y ≤ (indicator {y. y ≽[le] x} z :: real)" by (auto intro: trans (*‹⟦le ?x ?y; le ?y ?z⟧ ⟹ le ?x ?z›*) simp: indicator_def (*‹indicator ?S ?x = of_bool (?x ∈ ?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))›*)) qed ((fact)+) (*solved the remaining goal: ‹0 < ε›*) have "(∑y|le x y. pmf p y) ≤ (∑y|le x y. pmf p y) + ε * (∑y∈carrier. ?idx y * pmf p y)" using "ε" (*‹(0::real) < (ε::real)›*) by (auto intro!: mult_nonneg_nonneg (*‹⟦0 ≤ ?a; 0 ≤ ?b⟧ ⟹ 0 ≤ ?a * ?b›*) sum_nonneg (*‹(⋀x. x ∈ ?A ⟹ 0 ≤ ?f x) ⟹ 0 ≤ sum ?f ?A›*) pmf_nonneg (*‹0 ≤ pmf ?p ?x›*)) also (*calculation: ‹(∑y | le x y. pmf p y) ≤ (∑y | le x y. pmf p y) + ε * (∑y∈carrier. real (length xs - weak_ranking_index y) * pmf p y)›*) from expected_utility_le (*‹is_vnm_utility ?u ⟹ measure_pmf.expectation p ?u ≤ measure_pmf.expectation q ?u›*) is_utility (*‹is_vnm_utility (u::'a ⇒ real)›*) have "measure_pmf.expectation p u ≤ measure_pmf.expectation q u" . with assms (*‹(p::'a::type pmf) ∈ lotteries_on (carrier::'a::type set)› ‹(q::'a pmf) ∈ lotteries_on (carrier::'a set)›*) have "(∑a∈carrier. u a * pmf p a) ≤ (∑a∈carrier. u a * pmf q a)" apply (subst (asm) (1 2) integral_measure_pmf[OF finite_carrier] (*‹(⋀a. ⟦a ∈ set_pmf ?M; ?f a ≠ 0⟧ ⟹ a ∈ carrier) ⟹ measure_pmf.expectation ?M ?f = (∑a∈carrier. pmf ?M a *⇩R ?f a)›*)) (*goals: 1. ‹⋀a. ⟦p ∈ lotteries_on carrier; q ∈ lotteries_on carrier; a ∈ set_pmf q; u a ≠ 0⟧ ⟹ a ∈ carrier› 2. ‹⋀a. ⟦p ∈ lotteries_on carrier; q ∈ lotteries_on carrier; a ∈ set_pmf p; u a ≠ 0⟧ ⟹ a ∈ carrier› 3. ‹⟦p ∈ lotteries_on carrier; q ∈ lotteries_on carrier; (∑a∈carrier. pmf p a *⇩R u a) ≤ (∑a∈carrier. pmf q a *⇩R u a)⟧ ⟹ (∑a∈carrier. u a * pmf p a) ≤ (∑a∈carrier. u a * pmf q a)› discuss goal 1*) apply ((auto simp: lotteries_on_def (*‹lotteries_on ?A = {p. set_pmf p ⊆ ?A}›*) set_pmf_eq (*‹set_pmf ?M = {x. pmf ?M x ≠ 0}›*) 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 simp: lotteries_on_def (*‹lotteries_on ?A = {p. set_pmf p ⊆ ?A}›*) set_pmf_eq (*‹set_pmf ?M = {x. pmf ?M x ≠ 0}›*) 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 simp: lotteries_on_def (*‹lotteries_on ?A = {p. set_pmf p ⊆ ?A}›*) set_pmf_eq (*‹set_pmf ?M = {x. pmf ?M x ≠ 0}›*) 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 3 subgoals*) . hence "(∑y|le x y. pmf p y) + ε * (∑y∈carrier. ?idx y * pmf p y) ≤ (∑y|le x y. pmf q y) + ε * (∑y∈carrier. ?idx y * pmf q y)" using x (*‹x ∈ carrier›*) preferred_subset_carrier (*‹{y. le x y} ⊆ carrier›*) not_outside (*‹(le::'a::type ⇒ 'a::type ⇒ bool) (?x::'a::type) (?y::'a::type) ⟹ ?x ∈ (carrier::'a::type set)› ‹le ?x ?y ⟹ ?y ∈ carrier›*) by (simp add: u_def (*‹u ?y = indicat_real {y. le x y} ?y + ε * real (length xs - weak_ranking_index ?y)›*) sum.distrib (*‹(∑x∈?A. ?g x + ?h x) = sum ?g ?A + sum ?h ?A›*) finite_carrier (*‹finite carrier›*) 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*) sum_distrib_left (*‹?r * sum ?f ?A = (∑n∈?A. ?r * ?f n)›*) Int_absorb1 (*‹?B ⊆ ?A ⟹ ?A ∩ ?B = ?B›*) cong: rev_conj_cong (*‹⟦?Q = ?Q'; ?Q' ⟹ ?P = ?P'⟧ ⟹ (?P ∧ ?Q) = (?P' ∧ ?Q')›*)) also (*calculation: ‹(∑y::'a::type | (le::'a::type ⇒ 'a::type ⇒ bool) (x::'a::type) y. pmf (p::'a::type pmf) y) ≤ (∑y::'a::type | le x y. pmf (q::'a::type pmf) y) + (ε::real) * (∑y::'a::type∈(carrier::'a::type set). real (length (xs::'a::type set list) - weak_ranking_index y) * pmf q y)›*) have "(∑y∈carrier. ?idx y * pmf q y) ≤ (∑y∈carrier. length xs * pmf q y)" apply (intro 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›*)) (*goals: 1. ‹⋀y::'a::type. y ∈ (carrier::'a::type set) ⟹ real (length (xs::'a::type set list) - weak_ranking_index y) ≤ real (length xs)› 2. ‹⋀y::'a::type. y ∈ (carrier::'a::type set) ⟹ (0::real) ≤ pmf (q::'a::type pmf) y› discuss goal 1*) apply (simp add: pmf_nonneg (*‹0 ≤ pmf ?p ?x›*)) (*discuss goal 2*) apply (simp add: pmf_nonneg (*‹0 ≤ pmf ?p ?x›*)) (*proven 2 subgoals*) . also (*calculation: ‹(⋀(xa::real) y::real. xa ≤ y ⟹ (∑y::'a | (le::'a ⇒ 'a ⇒ bool) (x::'a) y. pmf (q::'a pmf) y) + (ε::real) * xa ≤ (∑y::'a | le x y. pmf q y) + ε * y) ⟹ (∑y::'a | le x y. pmf (p::'a pmf) y) ≤ (∑y::'a | le x y. pmf q y) + ε * (∑y::'a∈(carrier::'a set). real (length (xs::'a set list)) * pmf q y)›*) have "… = measure_pmf.expectation q (λ_. length xs)" using assms (*‹p ∈ lotteries_on carrier› ‹q ∈ lotteries_on carrier›*) apply (subst integral_measure_pmf[OF finite_carrier] (*‹(⋀a. ⟦a ∈ set_pmf ?M; ?f a ≠ 0⟧ ⟹ a ∈ carrier) ⟹ measure_pmf.expectation ?M ?f = (∑a∈carrier. pmf ?M a *⇩R ?f a)›*)) (*goals: 1. ‹⋀a. ⟦p ∈ lotteries_on carrier; q ∈ lotteries_on carrier; a ∈ set_pmf q; real (length xs) ≠ 0⟧ ⟹ a ∈ carrier› 2. ‹⟦p ∈ lotteries_on carrier; q ∈ lotteries_on carrier⟧ ⟹ (∑y∈carrier. real (length xs) * pmf q y) = (∑a∈carrier. pmf q a *⇩R real (length xs))› discuss goal 1*) apply ((auto simp: lotteries_on_def (*‹lotteries_on ?A = {p. set_pmf p ⊆ ?A}›*) set_pmf_eq (*‹set_pmf ?M = {x. pmf ?M x ≠ 0}›*) 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 simp: lotteries_on_def (*‹lotteries_on ?A = {p. set_pmf p ⊆ ?A}›*) set_pmf_eq (*‹set_pmf ?M = {x. pmf ?M x ≠ 0}›*) 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 2 subgoals*) . also (*calculation: ‹(⋀xa y. xa ≤ y ⟹ (∑y | le x y. pmf q y) + ε * xa ≤ (∑y | le x y. pmf q y) + ε * y) ⟹ (∑y | le x y. pmf p y) ≤ (∑y | le x y. pmf q y) + ε * measure_pmf.expectation q (λx. real (length xs))›*) have "… = length xs" by simp also (*calculation: ‹(⋀(xa::real) y::real. xa ≤ y ⟹ (∑y::'a::type | (le::'a::type ⇒ 'a::type ⇒ bool) (x::'a::type) y. pmf (q::'a::type pmf) y) + (ε::real) * xa ≤ (∑y::'a::type | le x y. pmf q y) + ε * y) ⟹ (∑y::'a::type | le x y. pmf (p::'a::type pmf) y) ≤ (∑y::'a::type | le x y. pmf q y) + ε * real (length (xs::'a::type set list))›*) have "(∑y | le x y. pmf p y) = measure_pmf.prob p {y. le x y}" using finite_subset[OF preferred_subset_carrier finite_carrier] (*‹finite {y. le x y}›*) by (simp add: measure_measure_pmf_finite (*‹finite ?S ⟹ measure_pmf.prob ?M ?S = sum (pmf ?M) ?S›*)) also (*calculation: ‹(⋀(xa::real) y::real. xa ≤ y ⟹ (∑y::'a | (le::'a ⇒ 'a ⇒ bool) (x::'a) y. pmf (q::'a pmf) y) + (ε::real) * xa ≤ (∑y::'a | le x y. pmf q y) + ε * y) ⟹ measure_pmf.prob (p::'a pmf) {y::'a. le x y} ≤ (∑y::'a | le x y. pmf q y) + ε * real (length (xs::'a set list))›*) have "(∑y | le x y. pmf q y) = measure_pmf.prob q {y. le x y}" using finite_subset[OF preferred_subset_carrier finite_carrier] (*‹finite {y. le x y}›*) by (simp add: measure_measure_pmf_finite (*‹finite ?S ⟹ measure_pmf.prob ?M ?S = sum (pmf ?M) ?S›*)) finally (*calculation: ‹(⋀xa y. xa ≤ y ⟹ (∑y | le x y. pmf q y) + ε * xa ≤ (∑y | le x y. pmf q y) + ε * y) ⟹ measure_pmf.prob p {y. le x y} ≤ measure_pmf.prob q {y. le x y} + ε * real (length xs)›*) show "measure_pmf.prob p {y. le x y} / length xs ≤ measure_pmf.prob q {y. le x y} / length xs + ε" using "ε" (*‹0 < ε›*) 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 moreover from carrier_nonempty (*‹(carrier::'a set) ≠ {}›*) carrier (*‹carrier = ⋃ (set xs)›*) have "xs ≠ []" by auto ultimately have "measure_pmf.prob p {y. le x y} ≤ measure_pmf.prob q {y. le x y}" 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*)) } with assms (*‹p ∈ lotteries_on carrier› ‹(q::'a pmf) ∈ lotteries_on (carrier::'a set)›*) show "p ≼[SD(le)] q" unfolding SD_preorder preferred_alts_def (*goal: ‹q ∈ lotteries_on carrier ∧ p ∈ lotteries_on carrier ∧ (∀x∈carrier. measure_pmf.prob p (Collect (le x)) ≤ measure_pmf.prob q (Collect (le x)))›*) by blast qed lemma not_strict_SD_iff: assumes "p ∈ lotteries_on carrier" "q ∈ lotteries_on carrier" shows "¬(p ≺[SD(le)] q) ⟷ (∃u. is_vnm_utility u ∧ measure_pmf.expectation q u ≤ measure_pmf.expectation p u)" proof (standard) (*goals: 1. ‹¬ p ≺[SD le] q ⟹ ∃u. is_vnm_utility u ∧ measure_pmf.expectation q u ≤ measure_pmf.expectation p u› 2. ‹∃u. is_vnm_utility u ∧ measure_pmf.expectation q u ≤ measure_pmf.expectation p u ⟹ ¬ p ≺[SD le] q›*) let ?E = "measure_pmf.expectation :: 'a pmf ⇒ _ ⇒ real" assume "∃u. is_vnm_utility u ∧ ?E p u ≥ ?E q u" (*‹∃u::'a ⇒ real. is_vnm_utility u ∧ measure_pmf.expectation (q::'a pmf) u ≤ measure_pmf.expectation (p::'a pmf) u›*) then obtain u where u: "is_vnm_utility u" "?E p u ≥ ?E q u" (*goal: ‹(⋀u::'a ⇒ real. ⟦is_vnm_utility u; measure_pmf.expectation (q::'a pmf) u ≤ measure_pmf.expectation (p::'a pmf) u⟧ ⟹ thesis::bool) ⟹ thesis›*) by blast interpret u: vnm_utility carrier le u by fact show "¬ p ≺[SD le] q" proof (standard) (*goal: ‹p ≺[SD le] q ⟹ False›*) assume less: "p ≺[SD le] q" (*‹(p::'a pmf) ≺[SD (le::'a ⇒ 'a ⇒ bool)] (q::'a pmf)›*) with assms (*‹p ∈ lotteries_on carrier› ‹q ∈ lotteries_on carrier›*) have pq: "?E p u ≤ ?E q u" if "is_vnm_utility u" for u using that (*‹is_vnm_utility u›*) by (auto simp: SD_iff_expected_utilities_le (*‹⟦?p ∈ lotteries_on carrier; ?q ∈ lotteries_on carrier⟧ ⟹ SD le ?p ?q = (∀u. is_vnm_utility u ⟶ measure_pmf.expectation ?p u ≤ measure_pmf.expectation ?q u)›*) strongly_preferred_def (*‹?a ≺[?R] ?b ≡ ?R ?a ?b ∧ ¬ ?R ?b ?a›*)) with u (*‹is_vnm_utility u› ‹measure_pmf.expectation q u ≤ measure_pmf.expectation p u›*) have u_eq: "?E p u = ?E q u" apply (intro antisym (*‹⟦?a ≤ ?b; ?b ≤ ?a⟧ ⟹ ?a = ?b›*)) (*goals: 1. ‹⟦is_vnm_utility u; measure_pmf.expectation q u ≤ measure_pmf.expectation p u; ⋀u. is_vnm_utility u ⟹ measure_pmf.expectation p u ≤ measure_pmf.expectation q u⟧ ⟹ measure_pmf.expectation p u ≤ measure_pmf.expectation q u› 2. ‹⟦is_vnm_utility u; measure_pmf.expectation q u ≤ measure_pmf.expectation p u; ⋀u. is_vnm_utility u ⟹ measure_pmf.expectation p u ≤ measure_pmf.expectation q u⟧ ⟹ measure_pmf.expectation q u ≤ measure_pmf.expectation p u› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) . from less (*‹p ≺[SD le] q›*) assms (*‹p ∈ lotteries_on carrier› ‹(q::'a::type pmf) ∈ lotteries_on (carrier::'a::type set)›*) obtain u' where u': "is_vnm_utility u'" "?E p u' < ?E q u'" (*goal: ‹(⋀u'. ⟦is_vnm_utility u'; measure_pmf.expectation p u' < measure_pmf.expectation q u'⟧ ⟹ thesis) ⟹ thesis›*) by (auto simp: SD_iff_expected_utilities_le (*‹⟦(?p::'a pmf) ∈ lotteries_on (carrier::'a set); (?q::'a pmf) ∈ lotteries_on carrier⟧ ⟹ SD (le::'a ⇒ 'a ⇒ bool) ?p ?q = (∀u::'a ⇒ real. is_vnm_utility u ⟶ measure_pmf.expectation ?p u ≤ measure_pmf.expectation ?q u)›*) strongly_preferred_def (*‹(?a::?'a) ≺[(?R::?'a ⇒ ?'a ⇒ bool)] (?b::?'a) ≡ ?R ?a ?b ∧ ¬ ?R ?b ?a›*) not_le (*‹(¬ (?x::?'a) ≤ (?y::?'a)) = (?y < ?x)›*)) interpret u': vnm_utility carrier le u' by fact have "∃ε>0. is_vnm_utility (λx. u x - ε * u' x)" apply (intro u.diff_epsilon (*‹(⋀(x::'a) y::'a. ⟦(le::'a ⇒ 'a ⇒ bool) x y; le y x⟧ ⟹ (?f::'a ⇒ real) x = ?f y) ⟹ ∃ε>0::real. is_vnm_utility (λx::'a. (u::'a ⇒ real) x - ε * ?f x)›*) antisym (*‹⟦(?a::?'a) ≤ (?b::?'a); ?b ≤ ?a⟧ ⟹ ?a = ?b›*) u'.utility_le (*‹(le::'a ⇒ 'a ⇒ bool) (?x::'a) (?y::'a) ⟹ (u'::'a ⇒ real) ?x ≤ u' ?y›*)) (*goals: 1. ‹⋀x y. ⟦le x y; le y x⟧ ⟹ le x y› 2. ‹⋀x y. ⟦le x y; le y x⟧ ⟹ le y x› discuss goal 1*) apply ((assumption)[1]) (*discuss goal 2*) . (*proven 2 subgoals*) then obtain ε where "ε": "ε > 0" "is_vnm_utility (λx. u x - ε * u' x)" (*goal: ‹(⋀ε::real. ⟦(0::real) < ε; is_vnm_utility (λx::'a. (u::'a ⇒ real) x - ε * (u'::'a ⇒ real) x)⟧ ⟹ thesis::bool) ⟹ thesis›*) by auto define u'' where "u'' x = u x - ε * u' x" for x interpret u'': vnm_utility carrier le u'' unfolding u''_def (*goal: ‹is_vnm_utility (λx. u x - ε * u' x)›*) by fact have exp_u'': "?E p u'' = ?E p u - ε * ?E p u'" if "p ∈ lotteries_on carrier" for p using that (*‹(p::'a::type pmf) ∈ lotteries_on (carrier::'a::type set)›*) apply (subst (1 2 3) integral_measure_pmf[of carrier] (*‹⟦finite carrier; ⋀a. ⟦a ∈ set_pmf ?M; ?f a ≠ 0⟧ ⟹ a ∈ carrier⟧ ⟹ measure_pmf.expectation ?M ?f = (∑a∈carrier. pmf ?M a *⇩R ?f a)›*)) (*goals: 1. ‹p ∈ lotteries_on carrier ⟹ finite carrier› 2. ‹⋀a. ⟦p ∈ lotteries_on carrier; a ∈ set_pmf p; u' a ≠ 0⟧ ⟹ a ∈ carrier› 3. ‹⋀a. ⟦p ∈ lotteries_on carrier; a ∈ set_pmf p; u a ≠ 0⟧ ⟹ a ∈ carrier› 4. ‹⋀a. ⟦p ∈ lotteries_on carrier; a ∈ set_pmf p; u'' a ≠ 0⟧ ⟹ a ∈ carrier› 5. ‹p ∈ lotteries_on carrier ⟹ (∑a∈carrier. pmf p a *⇩R u'' a) = (∑a∈carrier. pmf p a *⇩R u a) - ε * (∑a∈carrier. pmf p a *⇩R u' a)› discuss goal 1*) apply ((auto simp: lotteries_on_def (*‹lotteries_on (?A::?'a set) = {p::?'a pmf. set_pmf p ⊆ ?A}›*) u''_def (*‹(u''::'a ⇒ real) (?x::'a) = (u::'a ⇒ real) ?x - (ε::real) * (u'::'a ⇒ real) ?x›*) 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*) sum_subtractf (*‹(∑x::?'b∈(?A::?'b set). (?f::?'b ⇒ ?'a) x - (?g::?'b ⇒ ?'a) x) = sum ?f ?A - sum ?g ?A›*) sum_distrib_left (*‹(?r::?'a) * sum (?f::?'b ⇒ ?'a) (?A::?'b set) = (∑n::?'b∈?A. ?r * ?f n)›*))[1]) (*discuss goal 2*) apply ((auto simp: lotteries_on_def (*‹lotteries_on ?A = {p. set_pmf p ⊆ ?A}›*) u''_def (*‹u'' ?x = u ?x - ε * u' ?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*) sum_subtractf (*‹(∑x∈?A. ?f x - ?g x) = sum ?f ?A - sum ?g ?A›*) sum_distrib_left (*‹?r * sum ?f ?A = (∑n∈?A. ?r * ?f n)›*))[1]) (*discuss goal 3*) apply ((auto simp: lotteries_on_def (*‹lotteries_on ?A = {p. set_pmf p ⊆ ?A}›*) u''_def (*‹u'' ?x = u ?x - ε * u' ?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*) sum_subtractf (*‹(∑x∈?A. ?f x - ?g x) = sum ?f ?A - sum ?g ?A›*) sum_distrib_left (*‹?r * sum ?f ?A = (∑n∈?A. ?r * ?f n)›*))[1]) (*discuss goal 4*) apply ((auto simp: lotteries_on_def (*‹lotteries_on (?A::?'a::type set) = {p::?'a::type pmf. set_pmf p ⊆ ?A}›*) u''_def (*‹(u''::'a::type ⇒ real) (?x::'a::type) = (u::'a::type ⇒ real) ?x - (ε::real) * (u'::'a::type ⇒ real) ?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*) sum_subtractf (*‹(∑x::?'b::type∈(?A::?'b::type set). (?f::?'b::type ⇒ ?'a::ab_group_add) x - (?g::?'b::type ⇒ ?'a::ab_group_add) x) = sum ?f ?A - sum ?g ?A›*) sum_distrib_left (*‹(?r::?'a::semiring_0) * sum (?f::?'b::type ⇒ ?'a::semiring_0) (?A::?'b::type set) = (∑n::?'b::type∈?A. ?r * ?f n)›*))[1]) (*discuss goal 5*) apply ((auto simp: lotteries_on_def (*‹lotteries_on (?A::?'a set) = {p::?'a pmf. set_pmf p ⊆ ?A}›*) u''_def (*‹(u''::'a ⇒ real) (?x::'a) = (u::'a ⇒ real) ?x - (ε::real) * (u'::'a ⇒ real) ?x›*) 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*) sum_subtractf (*‹(∑x::?'b∈(?A::?'b set). (?f::?'b ⇒ ?'a) x - (?g::?'b ⇒ ?'a) x) = sum ?f ?A - sum ?g ?A›*) sum_distrib_left (*‹(?r::?'a) * sum (?f::?'b ⇒ ?'a) (?A::?'b set) = (∑n::?'b∈?A. ?r * ?f n)›*))[1]) (*proven 5 subgoals*) . from assms (*‹p ∈ lotteries_on carrier› ‹q ∈ lotteries_on carrier›*) "ε" (*‹0 < ε› ‹is_vnm_utility (λx. u x - ε * u' x)›*) have "?E p u'' > ?E q u''" by (simp add: exp_u'' (*‹?p ∈ lotteries_on carrier ⟹ measure_pmf.expectation ?p u'' = measure_pmf.expectation ?p u - ε * measure_pmf.expectation ?p u'›*) 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*) u_eq (*‹measure_pmf.expectation p u = measure_pmf.expectation q u›*) u' (*‹is_vnm_utility u'› ‹measure_pmf.expectation p u' < measure_pmf.expectation q u'›*)) with pq[OF u''.vnm_utility_axioms] (*‹measure_pmf.expectation p u'' ≤ measure_pmf.expectation q u''›*) show False by simp qed qed (insert assms (*‹(p::'a pmf) ∈ lotteries_on (carrier::'a set)› ‹(q::'a pmf) ∈ lotteries_on (carrier::'a set)›*) utility_weak_ranking_index (*‹is_vnm_utility (λx::'a. real (length (weak_ranking (le::'a ⇒ 'a ⇒ bool)) - weak_ranking_index x))›*), auto simp: strongly_preferred_def (*‹?a ≺[?R] ?b ≡ ?R ?a ?b ∧ ¬ ?R ?b ?a›*) SD_iff_expected_utilities_le (*‹⟦?p ∈ lotteries_on carrier; ?q ∈ lotteries_on carrier⟧ ⟹ SD le ?p ?q = (∀u. is_vnm_utility u ⟶ measure_pmf.expectation ?p u ≤ measure_pmf.expectation ?q u)›*) not_le (*‹(¬ ?x ≤ ?y) = (?y < ?x)›*) not_less (*‹(¬ ?x < ?y) = (?y ≤ ?x)›*) intro: antisym (*‹⟦?a ≤ ?b; ?b ≤ ?a⟧ ⟹ ?a = ?b›*)) (*solved the remaining goal: ‹¬ p ≺[SD le] q ⟹ ∃u. is_vnm_utility u ∧ measure_pmf.expectation q u ≤ measure_pmf.expectation p u›*) lemma strict_SD_iff: assumes "p ∈ lotteries_on carrier" "q ∈ lotteries_on carrier" shows "(p ≺[SD(le)] q) ⟷ (∀u. is_vnm_utility u ⟶ measure_pmf.expectation p u < measure_pmf.expectation q u)" using not_strict_SD_iff[OF assms] (*‹(¬ p ≺[SD le] q) = (∃u. is_vnm_utility u ∧ measure_pmf.expectation q u ≤ measure_pmf.expectation p u)›*) by auto end end
{ "path": "afp-2025-02-12/thys/Randomised_Social_Choice/Stochastic_Dominance.thy", "repo": "afp-2025-02-12", "sha": "c072dd97f68dee8e4da5dfc4fb0bb4c82f6a59ae410ef75b1b2f22ab6725cf2d" }
(* Title: OAodv.thy License: BSD 2-Clause. See LICENSE. Author: Timothy Bourke, Inria *) section "The `open' AODV model" theory OAodv imports Aodv AWN.OAWN_SOS_Labels AWN.OAWN_Convert begin text ‹Definitions for stating and proving global network properties over individual processes.› definition σ⇩A⇩O⇩D⇩V' :: "((ip ⇒ state) × ((state, msg, pseqp, pseqp label) seqp)) set" where "σ⇩A⇩O⇩D⇩V' ≡ {(λi. aodv_init i, Γ⇩A⇩O⇩D⇩V PAodv)}" abbreviation opaodv :: "ip ⇒ ((ip ⇒ state) × (state, msg, pseqp, pseqp label) seqp, msg seq_action) automaton" where "opaodv i ≡ ⦇ init = σ⇩A⇩O⇩D⇩V', trans = oseqp_sos Γ⇩A⇩O⇩D⇩V i ⦈" lemma initiali_aodv [intro!, simp]: "initiali i (init (opaodv i)) (init (paodv i))" unfolding "σ⇩A⇩O⇩D⇩V_def" "σ⇩A⇩O⇩D⇩V'_def" (*goal: ‹initiali i (init ⦇init = {(λi. ⦇ip = i, sn = 1, rt = λx. None, rreqs = {}, store = λx. None, msg = SOME x. True, data = SOME x. True, dests = SOME x. True, pre = SOME x. True, rreqid = SOME x. True, dip = SOME x. True, oip = SOME x. True, hops = SOME x. True, dsn = SOME x. True, dsk = SOME x. True, osn = SOME x. True, sip = SOME x. x ≠ i⦈, Γ⇩A⇩O⇩D⇩V PAodv)}, trans = oseqp_sos Γ⇩A⇩O⇩D⇩V i⦈) (init ⦇init = {(⦇ip = i, sn = 1, rt = λx. None, rreqs = {}, store = λx. None, msg = SOME x. True, data = SOME x. True, dests = SOME x. True, pre = SOME x. True, rreqid = SOME x. True, dip = SOME x. True, oip = SOME x. True, hops = SOME x. True, dsn = SOME x. True, dsk = SOME x. True, osn = SOME x. True, sip = SOME x. x ≠ i⦈, Γ⇩A⇩O⇩D⇩V PAodv)}, trans = seqp_sos Γ⇩A⇩O⇩D⇩V⦈)›*) apply rule (*goals: 1. ‹⋀σ p. (σ, p) ∈ init ⦇init = {(λi. ⦇ip = i, sn = 1, rt = λx. None, rreqs = {}, store = λx. None, msg = SOME x. True, data = SOME x. True, dests = SOME x. True, pre = SOME x. True, rreqid = SOME x. True, dip = SOME x. True, oip = SOME x. True, hops = SOME x. True, dsn = SOME x. True, dsk = SOME x. True, osn = SOME x. True, sip = SOME x. x ≠ i⦈, Γ⇩A⇩O⇩D⇩V PAodv)}, trans = oseqp_sos Γ⇩A⇩O⇩D⇩V i⦈ ⟹ (σ i, p) ∈ init ⦇init = {(⦇ip = i, sn = 1, rt = λx. None, rreqs = {}, store = λx. None, msg = SOME x. True, data = SOME x. True, dests = SOME x. True, pre = SOME x. True, rreqid = SOME x. True, dip = SOME x. True, oip = SOME x. True, hops = SOME x. True, dsn = SOME x. True, dsk = SOME x. True, osn = SOME x. True, sip = SOME x. x ≠ i⦈, Γ⇩A⇩O⇩D⇩V PAodv)}, trans = seqp_sos Γ⇩A⇩O⇩D⇩V⦈› 2. ‹⋀ξ p. (ξ, p) ∈ init ⦇init = {(⦇ip = i, sn = 1, rt = λx. None, rreqs = {}, store = λx. None, msg = SOME x. True, data = SOME x. True, dests = SOME x. True, pre = SOME x. True, rreqid = SOME x. True, dip = SOME x. True, oip = SOME x. True, hops = SOME x. True, dsn = SOME x. True, dsk = SOME x. True, osn = SOME x. True, sip = SOME x. x ≠ i⦈, Γ⇩A⇩O⇩D⇩V PAodv)}, trans = seqp_sos Γ⇩A⇩O⇩D⇩V⦈ ⟹ ∃σ. ξ = σ i ∧ (σ, p) ∈ init ⦇init = {(λi. ⦇ip = i, sn = 1, rt = λx. None, rreqs = {}, store = λx. None, msg = SOME x. True, data = SOME x. True, dests = SOME x. True, pre = SOME x. True, rreqid = SOME x. True, dip = SOME x. True, oip = SOME x. True, hops = SOME x. True, dsn = SOME x. True, dsk = SOME x. True, osn = SOME x. True, sip = SOME x. x ≠ i⦈, Γ⇩A⇩O⇩D⇩V PAodv)}, trans = oseqp_sos Γ⇩A⇩O⇩D⇩V i⦈› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) . lemma oaodv_control_within [simp]: "control_within Γ⇩A⇩O⇩D⇩V (init (opaodv i))" unfolding "σ⇩A⇩O⇩D⇩V'_def" (*goal: ‹control_within Γ⇩A⇩O⇩D⇩V (init ⦇init = {(λi. ⦇ip = i, sn = 1, rt = λx. None, rreqs = {}, store = λx. None, msg = SOME x. True, data = SOME x. True, dests = SOME x. True, pre = SOME x. True, rreqid = SOME x. True, dip = SOME x. True, oip = SOME x. True, hops = SOME x. True, dsn = SOME x. True, dsk = SOME x. True, osn = SOME x. True, sip = SOME x. x ≠ i⦈, Γ⇩A⇩O⇩D⇩V PAodv)}, trans = oseqp_sos Γ⇩A⇩O⇩D⇩V i⦈)›*) apply (rule control_withinI (*‹(⋀p. p ∈ Range ?σ ⟹ ∃pn. p ∈ subterms (?Γ pn)) ⟹ control_within ?Γ ?σ›*)) (*goal: ‹control_within Γ⇩A⇩O⇩D⇩V (init ⦇init = {(λi::nat. ⦇ip = i, sn = 1::nat, rt = λx::nat. None, rreqs = {}, store = λx::nat. None, msg = SOME x::msg. True, data = SOME x::nat. True, dests = SOME x::nat ⇒ nat option. True, pre = SOME x::nat set. True, rreqid = SOME x::nat. True, dip = SOME x::nat. True, oip = SOME x::nat. True, hops = SOME x::nat. True, dsn = SOME x::nat. True, dsk = SOME x::k. True, osn = SOME x::nat. True, sip = SOME x::nat. x ≠ i⦈, Γ⇩A⇩O⇩D⇩V PAodv)}, trans = oseqp_sos Γ⇩A⇩O⇩D⇩V (i::nat)⦈)›*) by (auto simp del: Γ⇩A⇩O⇩D⇩V_simps (*‹Γ⇩A⇩O⇩D⇩V PAodv = {PAodv-:0}receive(λmsg'. msg_update (λ_. msg')) . ({PAodv-:1}⟨is_newpkt⟩ {PAodv-:2}⟦λξ. clear_locals ξ⦇data := data ξ, dip := ip ξ⦈⟧ call(PNewPkt) ⊕ {PAodv-:1}⟨is_pkt⟩ {PAodv-:3}⟦λξ. clear_locals ξ⦇data := data ξ, dip := dip ξ, oip := oip ξ⦈⟧ call(PPkt) ⊕ {PAodv-:1}⟨is_rreq⟩ {PAodv-:4}⟦λξ. ξ⦇rt := update (rt ξ) (sip ξ) (0, unk, val, Suc 0, sip ξ, {})⦈⟧ {PAodv-:5}⟦λξ. clear_locals ξ⦇hops := hops ξ, rreqid := rreqid ξ, dip := dip ξ, dsn := dsn ξ, dsk := dsk ξ, oip := oip ξ, osn := osn ξ, sip := sip ξ⦈⟧ call(PRreq) ⊕ {PAodv-:1}⟨is_rrep⟩ {PAodv-:6}⟦λξ. ξ⦇rt := update (rt ξ) (sip ξ) (0, unk, val, Suc 0, sip ξ, {})⦈⟧ {PAodv-:7}⟦λξ. clear_locals ξ⦇hops := hops ξ, dip := dip ξ, dsn := dsn ξ, oip := oip ξ, sip := sip ξ⦈⟧ call(PRrep) ⊕ {PAodv-:1}⟨is_rerr⟩ {PAodv-:8}⟦λξ. ξ⦇rt := update (rt ξ) (sip ξ) (0, unk, val, Suc 0, sip ξ, {})⦈⟧ {PAodv-:9}⟦λξ. clear_locals ξ⦇dests := dests ξ, sip := sip ξ⦈⟧ call(PRerr)) ⊕ {PAodv-:0}⟨λξ. {ξ⦇dip := dip⦈ |dip. dip ∈ qD (store ξ) ∧ dip ∈ vD (rt ξ)}⟩ {PAodv-:10}⟦λξ. ξ⦇data := hd σ⇘queue⇙(store ξ, dip ξ)⦈⟧ {PAodv-:11}unicast(λξ. the (nhop (rt ξ) (dip ξ)), λξ. Pkt (data ξ) (dip ξ) (ip ξ)) . {PAodv-:12}⟦λξ. ξ⦇store := the (Aodv_Data.drop (dip ξ) (store ξ))⦈⟧ {PAodv-:13}⟦clear_locals⟧ call(PAodv) ▹ {PAodv-:14}⟦λξ. ξ⦇dests := λrip. if rip ∈ vD (rt ξ) ∧ nhop (rt ξ) rip = nhop (rt ξ) (dip ξ) then Some (inc (sqn (rt ξ) rip)) else None⦈⟧ {PAodv-:15}⟦λξ. ξ⦇rt := invalidate (rt ξ) (dests ξ)⦈⟧ {PAodv-:16}⟦λξ. ξ⦇store := setRRF (store ξ) (dests ξ)⦈⟧ {PAodv-:17}⟦λξ. ξ⦇pre := ⋃ {the (precs (rt ξ) rip) |rip. rip ∈ dom (dests ξ)}⦈⟧ {PAodv-:18}⟦λξ. ξ⦇dests := λrip. if (∃y. dests ξ rip = Some y) ∧ the (precs (rt ξ) rip) ≠ {} then dests ξ rip else None⦈⟧ {PAodv-:19}groupcast(pre, λξ. Rerr (dests ξ) (ip ξ)) . {PAodv-:20}⟦clear_locals⟧ call(PAodv) ⊕ {PAodv-:0}⟨λξ. {ξ⦇dip := dip⦈ |dip. dip ∈ qD (store ξ) ∧ dip ∉ vD (rt ξ) ∧ the σ⇘p-flag⇙(store ξ, dip) = req}⟩ {PAodv-:21}⟦λξ. ξ⦇store := unsetRRF (store ξ) (dip ξ)⦈⟧ {PAodv-:22}⟦λξ. ξ⦇sn := inc (sn ξ)⦈⟧ {PAodv-:23}⟦λξ. ξ⦇rreqid := nrreqid (rreqs ξ) (ip ξ)⦈⟧ {PAodv-:24}⟦λξ. ξ⦇rreqs := insert (ip ξ, rreqid ξ) (rreqs ξ)⦈⟧ {PAodv-:25}broadcast(λξ. Rreq 0 (rreqid ξ) (dip ξ) (sqn (rt ξ) (dip ξ)) (sqnf (rt ξ) (dip ξ)) (ip ξ) (sn ξ) (ip ξ)) . {PAodv-:26}⟦clear_locals⟧ call(PAodv)› ‹Γ⇩A⇩O⇩D⇩V PNewPkt = {PNewPkt-:0}⟨λξ. if dip ξ = ip ξ then {ξ} else {}⟩ {PNewPkt-:1}deliver(data) . {PNewPkt-:2}⟦clear_locals⟧ call(PAodv) ⊕ {PNewPkt-:0}⟨λξ. if dip ξ ≠ ip ξ then {ξ} else {}⟩ {PNewPkt-:3}⟦λξ. ξ⦇store := add (data ξ) (dip ξ) (store ξ)⦈⟧ {PNewPkt-:4}⟦clear_locals⟧ call(PAodv)› ‹Γ⇩A⇩O⇩D⇩V PPkt = {PPkt-:0}⟨λξ. if dip ξ = ip ξ then {ξ} else {}⟩ {PPkt-:1}deliver(data) . {PPkt-:2}⟦clear_locals⟧ call(PAodv) ⊕ {PPkt-:0}⟨λξ. if dip ξ ≠ ip ξ then {ξ} else {}⟩ ({PPkt-:3}⟨λξ. if dip ξ ∈ vD (rt ξ) then {ξ} else {}⟩ {PPkt-:4}unicast(λξ. the (nhop (rt ξ) (dip ξ)), λξ. Pkt (data ξ) (dip ξ) (oip ξ)) . {PPkt-:5}⟦clear_locals⟧ call(PAodv) ▹ {PPkt-:6}⟦λξ. ξ⦇dests := λrip. if rip ∈ vD (rt ξ) ∧ nhop (rt ξ) rip = nhop (rt ξ) (dip ξ) then Some (inc (sqn (rt ξ) rip)) else None⦈⟧ {PPkt-:7}⟦λξ. ξ⦇rt := invalidate (rt ξ) (dests ξ)⦈⟧ {PPkt-:8}⟦λξ. ξ⦇store := setRRF (store ξ) (dests ξ)⦈⟧ {PPkt-:9}⟦λξ. ξ⦇pre := ⋃ {the (precs (rt ξ) rip) |rip. rip ∈ dom (dests ξ)}⦈⟧ {PPkt-:10}⟦λξ. ξ⦇dests := λrip. if (∃y. dests ξ rip = Some y) ∧ the (precs (rt ξ) rip) ≠ {} then dests ξ rip else None⦈⟧ {PPkt-:11}groupcast(pre, λξ. Rerr (dests ξ) (ip ξ)) . {PPkt-:12}⟦clear_locals⟧ call(PAodv) ⊕ {PPkt-:3}⟨λξ. if dip ξ ∉ vD (rt ξ) then {ξ} else {}⟩ ({PPkt-:13}⟨λξ. if dip ξ ∈ iD (rt ξ) then {ξ} else {}⟩ {PPkt-:14}groupcast(λξ. the (precs (rt ξ) (dip ξ)), λξ. Rerr [dip ξ ↦ sqn (rt ξ) (dip ξ)] (ip ξ)) . {PPkt-:15}⟦clear_locals⟧ call(PAodv) ⊕ {PPkt-:13}⟨λξ. if dip ξ ∉ iD (rt ξ) then {ξ} else {}⟩ {PPkt-:16}⟦clear_locals⟧ call(PAodv)))› ‹Γ⇩A⇩O⇩D⇩V PRreq = {PRreq-:0}⟨λξ. if (oip ξ, rreqid ξ) ∈ rreqs ξ then {ξ} else {}⟩ {PRreq-:1}⟦clear_locals⟧ call(PAodv) ⊕ {PRreq-:0}⟨λξ. if (oip ξ, rreqid ξ) ∉ rreqs ξ then {ξ} else {}⟩ {PRreq-:2}⟦λξ. ξ⦇rt := update (rt ξ) (oip ξ) (osn ξ, kno, val, Suc (hops ξ), sip ξ, {})⦈⟧ {PRreq-:3}⟦λξ. ξ⦇rreqs := insert (oip ξ, rreqid ξ) (rreqs ξ)⦈⟧ ({PRreq-:4}⟨λξ. if dip ξ = ip ξ then {ξ} else {}⟩ {PRreq-:5}⟦λξ. ξ⦇sn := max (sn ξ) (dsn ξ)⦈⟧ {PRreq-:6}unicast(λξ. the (nhop (rt ξ) (oip ξ)), λξ. Rrep 0 (dip ξ) (sn ξ) (oip ξ) (ip ξ)) . {PRreq-:7}⟦clear_locals⟧ call(PAodv) ▹ {PRreq-:8}⟦λξ. ξ⦇dests := λrip. if rip ∈ vD (rt ξ) ∧ nhop (rt ξ) rip = nhop (rt ξ) (oip ξ) then Some (inc (sqn (rt ξ) rip)) else None⦈⟧ {PRreq-:9}⟦λξ. ξ⦇rt := invalidate (rt ξ) (dests ξ)⦈⟧ {PRreq-:10}⟦λξ. ξ⦇store := setRRF (store ξ) (dests ξ)⦈⟧ {PRreq-:11}⟦λξ. ξ⦇pre := ⋃ {the (precs (rt ξ) rip) |rip. rip ∈ dom (dests ξ)}⦈⟧ {PRreq-:12}⟦λξ. ξ⦇dests := λrip. if (∃y. dests ξ rip = Some y) ∧ the (precs (rt ξ) rip) ≠ {} then dests ξ rip else None⦈⟧ {PRreq-:13}groupcast(pre, λξ. Rerr (dests ξ) (ip ξ)) . {PRreq-:14}⟦clear_locals⟧ call(PAodv) ⊕ {PRreq-:4}⟨λξ. if dip ξ ≠ ip ξ then {ξ} else {}⟩ ({PRreq-:15}⟨λξ. if dip ξ ∈ vD (rt ξ) ∧ dsn ξ ≤ sqn (rt ξ) (dip ξ) ∧ sqnf (rt ξ) (dip ξ) = kno then {ξ} else {}⟩ {PRreq-:16}⟦λξ. ξ⦇rt := the (addpreRT (rt ξ) (dip ξ) {sip ξ})⦈⟧ {PRreq-:17}⟦λξ. ξ⦇rt := the (addpreRT (rt ξ) (oip ξ) {the (nhop (rt ξ) (dip ξ))})⦈⟧ {PRreq-:18}unicast(λξ. the (nhop (rt ξ) (oip ξ)), λξ. Rrep (the (dhops (rt ξ) (dip ξ))) (dip ξ) (sqn (rt ξ) (dip ξ)) (oip ξ) (ip ξ)) . {PRreq-:19}⟦clear_locals⟧ call(PAodv) ▹ {PRreq-:20}⟦λξ. ξ⦇dests := λrip. if rip ∈ vD (rt ξ) ∧ nhop (rt ξ) rip = nhop (rt ξ) (oip ξ) then Some (inc (sqn (rt ξ) rip)) else None⦈⟧ {PRreq-:21}⟦λξ. ξ⦇rt := invalidate (rt ξ) (dests ξ)⦈⟧ {PRreq-:22}⟦λξ. ξ⦇store := setRRF (store ξ) (dests ξ)⦈⟧ {PRreq-:23}⟦λξ. ξ⦇pre := ⋃ {the (precs (rt ξ) rip) |rip. rip ∈ dom (dests ξ)}⦈⟧ {PRreq-:24}⟦λξ. ξ⦇dests := λrip. if (∃y. dests ξ rip = Some y) ∧ the (precs (rt ξ) rip) ≠ {} then dests ξ rip else None⦈⟧ {PRreq-:25}groupcast(pre, λξ. Rerr (dests ξ) (ip ξ)) . {PRreq-:26}⟦clear_locals⟧ call(PAodv) ⊕ {PRreq-:15}⟨λξ. if dip ξ ∈ vD (rt ξ) ⟶ sqn (rt ξ) (dip ξ) < dsn ξ ∨ π₃ (the (rt ξ (dip ξ))) = unk then {ξ} else {}⟩ {PRreq-:27}broadcast(λξ. Rreq (Suc (hops ξ)) (rreqid ξ) (dip ξ) (max (sqn (rt ξ) (dip ξ)) (dsn ξ)) (dsk ξ) (oip ξ) (osn ξ) (ip ξ)) . {PRreq-:28}⟦clear_locals⟧ call(PAodv)))› ‹Γ⇩A⇩O⇩D⇩V PRrep = {PRrep-:0}⟨λξ. if rt ξ ≠ update (rt ξ) (dip ξ) (dsn ξ, kno, val, Suc (hops ξ), sip ξ, {}) then {ξ} else {}⟩ {PRrep-:1}⟦λξ. ξ⦇rt := update (rt ξ) (dip ξ) (dsn ξ, kno, val, Suc (hops ξ), sip ξ, {})⦈⟧ ({PRrep-:2}⟨λξ. if oip ξ = ip ξ then {ξ} else {}⟩ {PRrep-:3}⟦clear_locals⟧ call(PAodv) ⊕ {PRrep-:2}⟨λξ. if oip ξ ≠ ip ξ then {ξ} else {}⟩ ({PRrep-:4}⟨λξ. if oip ξ ∈ vD (rt ξ) then {ξ} else {}⟩ {PRrep-:5}⟦λξ. ξ⦇rt := the (addpreRT (rt ξ) (dip ξ) {the (nhop (rt ξ) (oip ξ))})⦈⟧ {PRrep-:6}⟦λξ. ξ⦇rt := the (addpreRT (rt ξ) (the (nhop (rt ξ) (dip ξ))) {the (nhop (rt ξ) (oip ξ))})⦈⟧ {PRrep-:7}unicast(λξ. the (nhop (rt ξ) (oip ξ)), λξ. Rrep (Suc (hops ξ)) (dip ξ) (dsn ξ) (oip ξ) (ip ξ)) . {PRrep-:8}⟦clear_locals⟧ call(PAodv) ▹ {PRrep-:9}⟦λξ. ξ⦇dests := λrip. if rip ∈ vD (rt ξ) ∧ nhop (rt ξ) rip = nhop (rt ξ) (oip ξ) then Some (inc (sqn (rt ξ) rip)) else None⦈⟧ {PRrep-:10}⟦λξ. ξ⦇rt := invalidate (rt ξ) (dests ξ)⦈⟧ {PRrep-:11}⟦λξ. ξ⦇store := setRRF (store ξ) (dests ξ)⦈⟧ {PRrep-:12}⟦λξ. ξ⦇pre := ⋃ {the (precs (rt ξ) rip) |rip. rip ∈ dom (dests ξ)}⦈⟧ {PRrep-:13}⟦λξ. ξ⦇dests := λrip. if (∃y. dests ξ rip = Some y) ∧ the (precs (rt ξ) rip) ≠ {} then dests ξ rip else None⦈⟧ {PRrep-:14}groupcast(pre, λξ. Rerr (dests ξ) (ip ξ)) . {PRrep-:15}⟦clear_locals⟧ call(PAodv) ⊕ {PRrep-:4}⟨λξ. if oip ξ ∉ vD (rt ξ) then {ξ} else {}⟩ {PRrep-:16}⟦clear_locals⟧ call(PAodv))) ⊕ {PRrep-:0}⟨λξ. if rt ξ = update (rt ξ) (dip ξ) (dsn ξ, kno, val, Suc (hops ξ), sip ξ, {}) then {ξ} else {}⟩ {PRrep-:17}⟦clear_locals⟧ call(PAodv)› ‹Γ⇩A⇩O⇩D⇩V PRerr = {PRerr-:0}⟦λξ. ξ⦇dests := λrip. case dests ξ rip of None ⇒ None | Some rsn ⇒ if rip ∈ vD (rt ξ) ∧ the (nhop (rt ξ) rip) = sip ξ ∧ sqn (rt ξ) rip < rsn then Some rsn else None⦈⟧ {PRerr-:1}⟦λξ. ξ⦇rt := invalidate (rt ξ) (dests ξ)⦈⟧ {PRerr-:2}⟦λξ. ξ⦇store := setRRF (store ξ) (dests ξ)⦈⟧ {PRerr-:3}⟦λξ. ξ⦇pre := ⋃ {the (precs (rt ξ) rip) |rip. rip ∈ dom (dests ξ)}⦈⟧ {PRerr-:4}⟦λξ. ξ⦇dests := λrip. if (∃y. dests ξ rip = Some y) ∧ the (precs (rt ξ) rip) ≠ {} then dests ξ rip else None⦈⟧ {PRerr-:5}groupcast(pre, λξ. Rerr (dests ξ) (ip ξ)) . {PRerr-:6}⟦clear_locals⟧ call(PAodv)›*)) lemma σ⇩A⇩O⇩D⇩V'_labels [simp]: "(σ, p) ∈ σ⇩A⇩O⇩D⇩V' ⟹ labels Γ⇩A⇩O⇩D⇩V p = {PAodv-:0}" unfolding "σ⇩A⇩O⇩D⇩V'_def" (*goal: ‹(σ, p) ∈ {(λi. ⦇ip = i, sn = 1, rt = λx. None, rreqs = {}, store = λx. None, msg = SOME x. True, data = SOME x. True, dests = SOME x. True, pre = SOME x. True, rreqid = SOME x. True, dip = SOME x. True, oip = SOME x. True, hops = SOME x. True, dsn = SOME x. True, dsk = SOME x. True, osn = SOME x. True, sip = SOME x. x ≠ i⦈, Γ⇩A⇩O⇩D⇩V PAodv)} ⟹ labels Γ⇩A⇩O⇩D⇩V p = {PAodv-:0}›*) by simp lemma oaodv_init_kD_empty [simp]: "(σ, p) ∈ σ⇩A⇩O⇩D⇩V' ⟹ kD (rt (σ i)) = {}" unfolding "σ⇩A⇩O⇩D⇩V'_def" kD_def (*goal: ‹(σ::nat ⇒ state, p::(state, msg, pseqp, pseqp label) seqp) ∈ {(λi::nat. ⦇ip = i, sn = 1::nat, rt = λx::nat. None, rreqs = {}, store = λx::nat. None, msg = SOME x::msg. True, data = SOME x::nat. True, dests = SOME x::nat ⇒ nat option. True, pre = SOME x::nat set. True, rreqid = SOME x::nat. True, dip = SOME x::nat. True, oip = SOME x::nat. True, hops = SOME x::nat. True, dsn = SOME x::nat. True, dsk = SOME x::k. True, osn = SOME x::nat. True, sip = SOME x::nat. x ≠ i⦈, Γ⇩A⇩O⇩D⇩V PAodv)} ⟹ {dip::nat. rt (σ (i::nat)) dip ≠ None} = {}›*) by simp lemma oaodv_init_vD_empty [simp]: "(σ, p) ∈ σ⇩A⇩O⇩D⇩V' ⟹ vD (rt (σ i)) = {}" unfolding "σ⇩A⇩O⇩D⇩V'_def" vD_def (*goal: ‹(σ::nat ⇒ state, p::(state, msg, pseqp, pseqp label) seqp) ∈ {(λi::nat. ⦇ip = i, sn = 1::nat, rt = λx::nat. None, rreqs = {}, store = λx::nat. None, msg = SOME x::msg. True, data = SOME x::nat. True, dests = SOME x::nat ⇒ nat option. True, pre = SOME x::nat set. True, rreqid = SOME x::nat. True, dip = SOME x::nat. True, oip = SOME x::nat. True, hops = SOME x::nat. True, dsn = SOME x::nat. True, dsk = SOME x::k. True, osn = SOME x::nat. True, sip = SOME x::nat. x ≠ i⦈, Γ⇩A⇩O⇩D⇩V PAodv)} ⟹ {dip::nat. flag (rt (σ (i::nat))) dip = Some val} = {}›*) by simp lemma oaodv_trans: "trans (opaodv i) = oseqp_sos Γ⇩A⇩O⇩D⇩V i" by simp declare oseq_invariant_ctermsI [OF aodv_wf oaodv_control_within aodv_simple_labels oaodv_trans, cterms_intros] oseq_step_invariant_ctermsI [OF aodv_wf oaodv_control_within aodv_simple_labels oaodv_trans, cterms_intros] end
{ "path": "afp-2025-02-12/thys/AODV/OAodv.thy", "repo": "afp-2025-02-12", "sha": "0fc9422dd2a06b2f8dc8c03fdd7debcdc89c831c6371d08d818f4a6d598ec57e" }
(* Title: Hermite_IArrays.thy Author: Jose Divasón <jose.divasonm at unirioja.es> Author: Jesús Aransay <jesus-maria.aransay at unirioja.es> *) section‹Hermite Normal Form refined to immutable arrays› theory Hermite_IArrays imports Hermite Echelon_Form.Echelon_Form_IArrays begin subsection‹Definition of the algorithm over immutable arrays› primrec Hermite_reduce_above_iarrays :: "'a::unique_euclidean_ring iarray iarray ⇒ nat ⇒ nat ⇒ nat ⇒ ('a⇒'a⇒'a) ⇒ 'a iarray iarray" where "Hermite_reduce_above_iarrays A 0 i j res = A" | "Hermite_reduce_above_iarrays A (Suc n) i j res = (let i'=n; Aij = A !! i !! j; Ai'j = A !! i' !! j in Hermite_reduce_above_iarrays (row_add_iarray A i' i (((res Aij (Ai'j)) - (Ai'j)) div Aij)) n i j res)" definition "Hermite_of_row_i_iarray ass res A i = ( if is_zero_iarray (A !! i) then A else let j = least_non_zero_position_of_vector (A !! i); Aij= (A !! i !! j); A' = mult_row_iarray A i ((ass Aij) div Aij) in Hermite_reduce_above_iarrays A' i i j res)" definition "Hermite_of_upt_row_i_iarrays A i ass res = foldl (Hermite_of_row_i_iarray ass res) A [0..<i]" definition "Hermite_of_iarrays A ass res bezout = (let A'= echelon_form_of_iarrays A bezout in Hermite_of_upt_row_i_iarrays A' (nrows_iarray A) ass res)" subsection‹Proving the equivalence between definitions of both representations› lemma matrix_to_iarray_Hermite_reduce_above: fixes A::"'a::{unique_euclidean_ring}^'cols::{mod_type}^'rows::{mod_type}" assumes "n<nrows A" shows "matrix_to_iarray (Hermite_reduce_above A n i j res) = Hermite_reduce_above_iarrays (matrix_to_iarray A) n (to_nat i) (to_nat j) res" using assms (*‹n < nrows A›*) proof (induct n arbitrary: A) (*goals: 1. ‹⋀A. 0 < nrows A ⟹ matrix_to_iarray (Hermite_reduce_above A 0 i j res) = Hermite_reduce_above_iarrays (matrix_to_iarray A) 0 (mod_type_class.to_nat i) (mod_type_class.to_nat j) res› 2. ‹⋀n A. ⟦⋀A. n < nrows A ⟹ matrix_to_iarray (Hermite_reduce_above A n i j res) = Hermite_reduce_above_iarrays (matrix_to_iarray A) n (mod_type_class.to_nat i) (mod_type_class.to_nat j) res; Suc n < nrows A⟧ ⟹ matrix_to_iarray (Hermite_reduce_above A (Suc n) i j res) = Hermite_reduce_above_iarrays (matrix_to_iarray A) (Suc n) (mod_type_class.to_nat i) (mod_type_class.to_nat j) res›*) case 0 (*‹0 < nrows A›*) thus "?case" (*goal: ‹matrix_to_iarray (Hermite_reduce_above A 0 i j res) = Hermite_reduce_above_iarrays (matrix_to_iarray A) 0 (mod_type_class.to_nat i) (mod_type_class.to_nat j) res›*) by auto next (*goal: ‹⋀n A. ⟦⋀A. n < nrows A ⟹ matrix_to_iarray (Hermite_reduce_above A n i j res) = Hermite_reduce_above_iarrays (matrix_to_iarray A) n (mod_type_class.to_nat i) (mod_type_class.to_nat j) res; Suc n < nrows A⟧ ⟹ matrix_to_iarray (Hermite_reduce_above A (Suc n) i j res) = Hermite_reduce_above_iarrays (matrix_to_iarray A) (Suc n) (mod_type_class.to_nat i) (mod_type_class.to_nat j) res›*) case (Suc n) (*‹n < nrows ?A ⟹ matrix_to_iarray (Hermite_reduce_above ?A n i j res) = Hermite_reduce_above_iarrays (matrix_to_iarray ?A) n (mod_type_class.to_nat i) (mod_type_class.to_nat j) res› ‹Suc n < nrows A›*) have n: "n<nrows A" using Suc.prems (*‹Suc n < nrows A›*) unfolding nrows_def (*goal: ‹(n::nat) < CARD('rows::mod_type)›*) by simp obtain a :: 'rows where n_tna: "n = to_nat a" (*goal: ‹(⋀a. n = mod_type_class.to_nat a ⟹ thesis) ⟹ thesis›*) by (metis Suc.prems (*‹Suc (n::nat) < nrows (A::(('a::unique_euclidean_ring, 'cols::mod_type) vec, 'rows::mod_type) vec)›*) Suc_lessD (*‹Suc (?m::nat) < (?n::nat) ⟹ ?m < ?n›*) nrows_def (*‹nrows (?A::((?'a::type, ?'columns::finite) vec, ?'rows::finite) vec) = CARD(?'rows::finite)›*) to_nat_from_nat_id (*‹(?x::nat) < CARD(?'a::mod_type) ⟹ mod_type_class.to_nat (mod_type_class.from_nat ?x) = ?x›*)) show "?case" (*goal: ‹matrix_to_iarray (Hermite_reduce_above A (Suc n) i j res) = Hermite_reduce_above_iarrays (matrix_to_iarray A) (Suc n) (mod_type_class.to_nat i) (mod_type_class.to_nat j) res›*) unfolding Hermite_reduce_above.simps (*goal: ‹matrix_to_iarray (let i' = mod_type_class.from_nat n; Aij = A $ i $ j; Ai'j = A $ i' $ j in Hermite_reduce_above (row_add A i' i ((res Aij Ai'j - Ai'j) div Aij)) n i j res) = Hermite_reduce_above_iarrays (matrix_to_iarray A) (Suc n) (mod_type_class.to_nat i) (mod_type_class.to_nat j) res›*) unfolding Hermite_reduce_above_iarrays.simps (*goal: ‹matrix_to_iarray (let i' = mod_type_class.from_nat n; Aij = A $ i $ j; Ai'j = A $ i' $ j in Hermite_reduce_above (row_add A i' i ((res Aij Ai'j - Ai'j) div Aij)) n i j res) = (let i' = n; Aij = matrix_to_iarray A !! mod_type_class.to_nat i !! mod_type_class.to_nat j; Ai'j = matrix_to_iarray A !! i' !! mod_type_class.to_nat j in Hermite_reduce_above_iarrays (row_add_iarray (matrix_to_iarray A) i' (mod_type_class.to_nat i) ((res Aij Ai'j - Ai'j) div Aij)) n (mod_type_class.to_nat i) (mod_type_class.to_nat j) res)›*) unfolding Let_def sub_def[symmetric] (*goal: ‹matrix_to_iarray (Hermite_reduce_above (row_add A (mod_type_class.from_nat n) i ((res (A $ i $ j) (A $ mod_type_class.from_nat n $ j) - A $ mod_type_class.from_nat n $ j) div A $ i $ j)) n i j res) = Hermite_reduce_above_iarrays (row_add_iarray (matrix_to_iarray A) n (mod_type_class.to_nat i) ((res (matrix_to_iarray A !! mod_type_class.to_nat i !! mod_type_class.to_nat j) (matrix_to_iarray A !! n !! mod_type_class.to_nat j) - matrix_to_iarray A !! n !! mod_type_class.to_nat j) div matrix_to_iarray A !! mod_type_class.to_nat i !! mod_type_class.to_nat j)) n (mod_type_class.to_nat i) (mod_type_class.to_nat j) res›*) unfolding n_tna (*goal: ‹matrix_to_iarray (Hermite_reduce_above (row_add A (mod_type_class.from_nat (mod_type_class.to_nat a)) i ((res (A $ i $ j) (A $ mod_type_class.from_nat (mod_type_class.to_nat a) $ j) - A $ mod_type_class.from_nat (mod_type_class.to_nat a) $ j) div A $ i $ j)) (mod_type_class.to_nat a) i j res) = Hermite_reduce_above_iarrays (row_add_iarray (matrix_to_iarray A) (mod_type_class.to_nat a) (mod_type_class.to_nat i) ((res (matrix_to_iarray A !! mod_type_class.to_nat i !! mod_type_class.to_nat j) (matrix_to_iarray A !! mod_type_class.to_nat a !! mod_type_class.to_nat j) - matrix_to_iarray A !! mod_type_class.to_nat a !! mod_type_class.to_nat j) div matrix_to_iarray A !! mod_type_class.to_nat i !! mod_type_class.to_nat j)) (mod_type_class.to_nat a) (mod_type_class.to_nat i) (mod_type_class.to_nat j) res›*) unfolding matrix_to_iarray_row_add[symmetric] from_nat_to_nat_id (*goal: ‹matrix_to_iarray (Hermite_reduce_above (row_add (A::(('a::unique_euclidean_ring, 'cols::mod_type) vec, 'rows::mod_type) vec) (a::'rows::mod_type) (i::'rows::mod_type) (((res::'a::unique_euclidean_ring ⇒ 'a::unique_euclidean_ring ⇒ 'a::unique_euclidean_ring) (A $ i $ (j::'cols::mod_type)) (A $ a $ j) - A $ a $ j) div A $ i $ j)) (mod_type_class.to_nat a) i j res) = Hermite_reduce_above_iarrays (matrix_to_iarray (row_add A a i ((res (matrix_to_iarray A !! mod_type_class.to_nat i !! mod_type_class.to_nat j) (matrix_to_iarray A !! mod_type_class.to_nat a !! mod_type_class.to_nat j) - matrix_to_iarray A !! mod_type_class.to_nat a !! mod_type_class.to_nat j) div matrix_to_iarray A !! mod_type_class.to_nat i !! mod_type_class.to_nat j))) (mod_type_class.to_nat a) (mod_type_class.to_nat i) (mod_type_class.to_nat j) res›*) unfolding matrix_to_iarray_nth (*goal: ‹matrix_to_iarray (Hermite_reduce_above (row_add A a i ((res (A $ i $ j) (A $ a $ j) - A $ a $ j) div A $ i $ j)) (mod_type_class.to_nat a) i j res) = Hermite_reduce_above_iarrays (matrix_to_iarray (row_add A a i ((res (A $ i $ j) (A $ a $ j) - A $ a $ j) div A $ i $ j))) (mod_type_class.to_nat a) (mod_type_class.to_nat i) (mod_type_class.to_nat j) res›*) unfolding n_tna[symmetric] (*goal: ‹matrix_to_iarray (Hermite_reduce_above (row_add A a i ((res (A $ i $ j) (A $ a $ j) - A $ a $ j) div A $ i $ j)) n i j res) = Hermite_reduce_above_iarrays (matrix_to_iarray (row_add A a i ((res (A $ i $ j) (A $ a $ j) - A $ a $ j) div A $ i $ j))) n (mod_type_class.to_nat i) (mod_type_class.to_nat j) res›*) apply (rule Suc.hyps (*‹n < nrows ?A ⟹ matrix_to_iarray (Hermite_reduce_above ?A n i j res) = Hermite_reduce_above_iarrays (matrix_to_iarray ?A) n (mod_type_class.to_nat i) (mod_type_class.to_nat j) res›*)) (*goal: ‹matrix_to_iarray (Hermite_reduce_above (row_add A a i ((res (A $ i $ j) (A $ a $ j) - A $ a $ j) div A $ i $ j)) n i j res) = Hermite_reduce_above_iarrays (matrix_to_iarray (row_add A a i ((res (A $ i $ j) (A $ a $ j) - A $ a $ j) div A $ i $ j))) n (mod_type_class.to_nat i) (mod_type_class.to_nat j) res›*) by (auto simp add: nrows_def (*‹nrows ?A = CARD(?'rows)›*) n[unfolded nrows_def] (*‹n < CARD('rows)›*)) qed lemma matrix_to_iarray_Hermite_of_row_i[code_unfold]: fixes A::"'a::{unique_euclidean_ring}^'cols::{mod_type}^'rows::{mod_type}" shows "matrix_to_iarray (Hermite_of_row_i ass res A i) = Hermite_of_row_i_iarray ass res (matrix_to_iarray A) (to_nat i)" proof (-) (*goal: ‹matrix_to_iarray (Hermite_of_row_i ass res A i) = Hermite_of_row_i_iarray ass res (matrix_to_iarray A) (mod_type_class.to_nat i)›*) have zero_rw: "is_zero_iarray (matrix_to_iarray A !! to_nat i) = is_zero_row i A" by (simp add: is_zero_iarray_eq_iff (*‹(?A = 0) = is_zero_iarray (vec_to_iarray ?A)›*) is_zero_row_eq_row_zero (*‹is_zero_row ?a ?A = (row ?a ?A = 0)›*) vec_to_iarray_row' (*‹vec_to_iarray (row ?i ?A) = matrix_to_iarray ?A !! mod_type_class.to_nat ?i›*)) show "?thesis" (*goal: ‹matrix_to_iarray (Hermite_of_row_i ass res A i) = Hermite_of_row_i_iarray ass res (matrix_to_iarray A) (mod_type_class.to_nat i)›*) proof (cases "is_zero_row i A") (*goals: 1. ‹is_zero_row (i::'rows::mod_type) (A::(('a::unique_euclidean_ring, 'cols::mod_type) vec, 'rows::mod_type) vec) ⟹ matrix_to_iarray (Hermite_of_row_i (ass::'a::unique_euclidean_ring ⇒ 'a::unique_euclidean_ring) (res::'a::unique_euclidean_ring ⇒ 'a::unique_euclidean_ring ⇒ 'a::unique_euclidean_ring) A i) = Hermite_of_row_i_iarray ass res (matrix_to_iarray A) (mod_type_class.to_nat i)› 2. ‹¬ is_zero_row (i::'rows::mod_type) (A::(('a::unique_euclidean_ring, 'cols::mod_type) vec, 'rows::mod_type) vec) ⟹ matrix_to_iarray (Hermite_of_row_i (ass::'a::unique_euclidean_ring ⇒ 'a::unique_euclidean_ring) (res::'a::unique_euclidean_ring ⇒ 'a::unique_euclidean_ring ⇒ 'a::unique_euclidean_ring) A i) = Hermite_of_row_i_iarray ass res (matrix_to_iarray A) (mod_type_class.to_nat i)›*) case True (*‹is_zero_row i A›*) thus "?thesis" (*goal: ‹matrix_to_iarray (Hermite_of_row_i ass res A i) = Hermite_of_row_i_iarray ass res (matrix_to_iarray A) (mod_type_class.to_nat i)›*) unfolding Hermite_of_row_i_def Hermite_of_row_i_iarray_def Let_def zero_rw (*goal: ‹matrix_to_iarray (if is_zero_row i A then A else Hermite_reduce_above (mult_row A i (ass (A $ i $ (LEAST n. A $ i $ n ≠ 0)) div A $ i $ (LEAST n. A $ i $ n ≠ 0))) (mod_type_class.to_nat i) i (LEAST n. A $ i $ n ≠ 0) res) = (if is_zero_row i A then matrix_to_iarray A else Hermite_reduce_above_iarrays (mult_row_iarray (matrix_to_iarray A) (mod_type_class.to_nat i) (ass (matrix_to_iarray A !! mod_type_class.to_nat i !! least_non_zero_position_of_vector (matrix_to_iarray A !! mod_type_class.to_nat i)) div matrix_to_iarray A !! mod_type_class.to_nat i !! least_non_zero_position_of_vector (matrix_to_iarray A !! mod_type_class.to_nat i))) (mod_type_class.to_nat i) (mod_type_class.to_nat i) (least_non_zero_position_of_vector (matrix_to_iarray A !! mod_type_class.to_nat i)) res)›*) by auto next (*goal: ‹¬ is_zero_row i A ⟹ matrix_to_iarray (Hermite_of_row_i ass res A i) = Hermite_of_row_i_iarray ass res (matrix_to_iarray A) (mod_type_class.to_nat i)›*) case False (*‹¬ is_zero_row i A›*) have Ain: "A $ i $ (LEAST n. A $ i $ n ≠ 0) ≠ 0" using False (*‹¬ is_zero_row i A›*) by (metis (mono_tags, lifting) LeastI (*‹?P ?k ⟹ ?P (LEAST x. ?P x)›*) is_zero_row_def' (*‹is_zero_row ?i ?A = (∀j. ?A $ ?i $ j = 0)›*)) have l: "least_non_zero_position_of_vector (matrix_to_iarray A !! to_nat i) = to_nat (LEAST n. A $ i $ n ≠ 0)" proof (-) (*goal: ‹least_non_zero_position_of_vector (matrix_to_iarray A !! mod_type_class.to_nat i) = mod_type_class.to_nat (LEAST n. A $ i $ n ≠ 0)›*) have least_rw: " (LEAST n. A $ i $ n ≠ 0 ∧ 0 ≤ n) = (LEAST n. A $ i $ n ≠ 0)" apply (rule Least_equality (*‹⟦(?P::?'a ⇒ bool) (?x::?'a); ⋀y::?'a. ?P y ⟹ ?x ≤ y⟧ ⟹ Least ?P = ?x›*)) (*goals: 1. ‹(A::(('a, 'cols) vec, 'rows) vec) $ (i::'rows) $ (LEAST n::'cols. A $ i $ n ≠ (0::'a)) ≠ (0::'a) ∧ (0::'cols) ≤ (LEAST n::'cols. A $ i $ n ≠ (0::'a))› 2. ‹⋀y::'cols. (A::(('a, 'cols) vec, 'rows) vec) $ (i::'rows) $ y ≠ (0::'a) ∧ (0::'cols) ≤ y ⟹ (LEAST n::'cols. A $ i $ n ≠ (0::'a)) ≤ y› discuss goal 1*) apply ((auto simp add: least_mod_type (*‹0 ≤ ?n›*) Ain (*‹A $ i $ (LEAST n. A $ i $ n ≠ 0) ≠ 0›*) Least_le (*‹?P ?k ⟹ (LEAST x. ?P x) ≤ ?k›*))[1]) (*discuss goal 2*) apply ((auto simp add: least_mod_type (*‹0 ≤ ?n›*) Ain (*‹A $ i $ (LEAST n. A $ i $ n ≠ 0) ≠ 0›*) Least_le (*‹?P ?k ⟹ (LEAST x. ?P x) ≤ ?k›*))[1]) (*proven 2 subgoals*) . have v_rw: "¬ vector_all_zero_from_index (to_nat (0::'cols), vec_to_iarray (A $ i))" using False (*‹¬ is_zero_row i A›*) least_mod_type (*‹0 ≤ ?n›*) unfolding vector_all_zero_from_index_eq[of 0 "A$i", symmetric] is_zero_row_def' (*goal: ‹¬ (∀m≥0. A $ i $ m = 0)›*) by auto show "?thesis" (*goal: ‹least_non_zero_position_of_vector (matrix_to_iarray (A::(('a, 'cols) vec, 'rows) vec) !! mod_type_class.to_nat (i::'rows)) = mod_type_class.to_nat (LEAST n::'cols. A $ i $ n ≠ (0::'a))›*) using vec_to_iarray_least_non_zero_position_of_vector_from_index[OF v_rw] (*‹least_non_zero_position_of_vector_from_index (vec_to_iarray (A $ i)) (mod_type_class.to_nat 0) = mod_type_class.to_nat (LEAST n. A $ i $ n ≠ 0 ∧ 0 ≤ n)›*) unfolding least_rw least_non_zero_position_of_vector_def to_nat_0 vec_matrix (*goal: ‹least_non_zero_position_of_vector_from_index (matrix_to_iarray (A::(('a, 'cols) vec, 'rows) vec) !! mod_type_class.to_nat (i::'rows)) (0::nat) = mod_type_class.to_nat (LEAST n::'cols. A $ i $ n ≠ (0::'a))›*) . qed show "?thesis" (*goal: ‹matrix_to_iarray (Hermite_of_row_i (ass::'a::unique_euclidean_ring ⇒ 'a::unique_euclidean_ring) (res::'a::unique_euclidean_ring ⇒ 'a::unique_euclidean_ring ⇒ 'a::unique_euclidean_ring) (A::(('a::unique_euclidean_ring, 'cols::mod_type) vec, 'rows::mod_type) vec) (i::'rows::mod_type)) = Hermite_of_row_i_iarray ass res (matrix_to_iarray A) (mod_type_class.to_nat i)›*) unfolding Hermite_of_row_i_def Hermite_of_row_i_iarray_def Let_def (*goal: ‹matrix_to_iarray (if is_zero_row i A then A else Hermite_reduce_above (mult_row A i (ass (A $ i $ (LEAST n. A $ i $ n ≠ 0)) div A $ i $ (LEAST n. A $ i $ n ≠ 0))) (mod_type_class.to_nat i) i (LEAST n. A $ i $ n ≠ 0) res) = (if is_zero_iarray (matrix_to_iarray A !! mod_type_class.to_nat i) then matrix_to_iarray A else Hermite_reduce_above_iarrays (mult_row_iarray (matrix_to_iarray A) (mod_type_class.to_nat i) (ass (matrix_to_iarray A !! mod_type_class.to_nat i !! least_non_zero_position_of_vector (matrix_to_iarray A !! mod_type_class.to_nat i)) div matrix_to_iarray A !! mod_type_class.to_nat i !! least_non_zero_position_of_vector (matrix_to_iarray A !! mod_type_class.to_nat i))) (mod_type_class.to_nat i) (mod_type_class.to_nat i) (least_non_zero_position_of_vector (matrix_to_iarray A !! mod_type_class.to_nat i)) res)›*) unfolding zero_rw[symmetric] (*goal: ‹matrix_to_iarray (if is_zero_iarray (matrix_to_iarray (A::(('a, 'cols) vec, 'rows) vec) !! mod_type_class.to_nat (i::'rows)) then A else Hermite_reduce_above (mult_row A i ((ass::'a ⇒ 'a) (A $ i $ (LEAST n::'cols. A $ i $ n ≠ (0::'a))) div A $ i $ (LEAST n::'cols. A $ i $ n ≠ (0::'a)))) (mod_type_class.to_nat i) i (LEAST n::'cols. A $ i $ n ≠ (0::'a)) (res::'a ⇒ 'a ⇒ 'a)) = (if is_zero_iarray (matrix_to_iarray A !! mod_type_class.to_nat i) then matrix_to_iarray A else Hermite_reduce_above_iarrays (mult_row_iarray (matrix_to_iarray A) (mod_type_class.to_nat i) (ass (matrix_to_iarray A !! mod_type_class.to_nat i !! least_non_zero_position_of_vector (matrix_to_iarray A !! mod_type_class.to_nat i)) div matrix_to_iarray A !! mod_type_class.to_nat i !! least_non_zero_position_of_vector (matrix_to_iarray A !! mod_type_class.to_nat i))) (mod_type_class.to_nat i) (mod_type_class.to_nat i) (least_non_zero_position_of_vector (matrix_to_iarray A !! mod_type_class.to_nat i)) res)›*) unfolding matrix_to_iarray_mult_row[symmetric] (*goal: ‹matrix_to_iarray (if is_zero_iarray (matrix_to_iarray A !! mod_type_class.to_nat i) then A else Hermite_reduce_above (mult_row A i (ass (A $ i $ (LEAST n. A $ i $ n ≠ 0)) div A $ i $ (LEAST n. A $ i $ n ≠ 0))) (mod_type_class.to_nat i) i (LEAST n. A $ i $ n ≠ 0) res) = (if is_zero_iarray (matrix_to_iarray A !! mod_type_class.to_nat i) then matrix_to_iarray A else Hermite_reduce_above_iarrays (matrix_to_iarray (mult_row A i (ass (matrix_to_iarray A !! mod_type_class.to_nat i !! least_non_zero_position_of_vector (matrix_to_iarray A !! mod_type_class.to_nat i)) div matrix_to_iarray A !! mod_type_class.to_nat i !! least_non_zero_position_of_vector (matrix_to_iarray A !! mod_type_class.to_nat i)))) (mod_type_class.to_nat i) (mod_type_class.to_nat i) (least_non_zero_position_of_vector (matrix_to_iarray A !! mod_type_class.to_nat i)) res)›*) unfolding l (*goal: ‹matrix_to_iarray (if is_zero_iarray (matrix_to_iarray (A::(('a, 'cols) vec, 'rows) vec) !! mod_type_class.to_nat (i::'rows)) then A else Hermite_reduce_above (mult_row A i ((ass::'a ⇒ 'a) (A $ i $ (LEAST n::'cols. A $ i $ n ≠ (0::'a))) div A $ i $ (LEAST n::'cols. A $ i $ n ≠ (0::'a)))) (mod_type_class.to_nat i) i (LEAST n::'cols. A $ i $ n ≠ (0::'a)) (res::'a ⇒ 'a ⇒ 'a)) = (if is_zero_iarray (matrix_to_iarray A !! mod_type_class.to_nat i) then matrix_to_iarray A else Hermite_reduce_above_iarrays (matrix_to_iarray (mult_row A i (ass (matrix_to_iarray A !! mod_type_class.to_nat i !! mod_type_class.to_nat (LEAST n::'cols. A $ i $ n ≠ (0::'a))) div matrix_to_iarray A !! mod_type_class.to_nat i !! mod_type_class.to_nat (LEAST n::'cols. A $ i $ n ≠ (0::'a))))) (mod_type_class.to_nat i) (mod_type_class.to_nat i) (mod_type_class.to_nat (LEAST n::'cols. A $ i $ n ≠ (0::'a))) res)›*) unfolding matrix_to_iarray_nth (*goal: ‹matrix_to_iarray (if is_zero_iarray (matrix_to_iarray A !! mod_type_class.to_nat i) then A else Hermite_reduce_above (mult_row A i (ass (A $ i $ (LEAST n. A $ i $ n ≠ 0)) div A $ i $ (LEAST n. A $ i $ n ≠ 0))) (mod_type_class.to_nat i) i (LEAST n. A $ i $ n ≠ 0) res) = (if is_zero_iarray (matrix_to_iarray A !! mod_type_class.to_nat i) then matrix_to_iarray A else Hermite_reduce_above_iarrays (matrix_to_iarray (mult_row A i (ass (A $ i $ (LEAST n. A $ i $ n ≠ 0)) div A $ i $ (LEAST n. A $ i $ n ≠ 0)))) (mod_type_class.to_nat i) (mod_type_class.to_nat i) (mod_type_class.to_nat (LEAST n. A $ i $ n ≠ 0)) res)›*) apply auto (*goal: ‹matrix_to_iarray (if is_zero_iarray (matrix_to_iarray A !! mod_type_class.to_nat i) then A else Hermite_reduce_above (mult_row A i (ass (A $ i $ (LEAST n. A $ i $ n ≠ 0)) div A $ i $ (LEAST n. A $ i $ n ≠ 0))) (mod_type_class.to_nat i) i (LEAST n. A $ i $ n ≠ 0) res) = (if is_zero_iarray (matrix_to_iarray A !! mod_type_class.to_nat i) then matrix_to_iarray A else Hermite_reduce_above_iarrays (matrix_to_iarray (mult_row A i (ass (A $ i $ (LEAST n. A $ i $ n ≠ 0)) div A $ i $ (LEAST n. A $ i $ n ≠ 0)))) (mod_type_class.to_nat i) (mod_type_class.to_nat i) (mod_type_class.to_nat (LEAST n. A $ i $ n ≠ 0)) res)›*) apply (rule matrix_to_iarray_Hermite_reduce_above (*‹?n < nrows ?A ⟹ matrix_to_iarray (Hermite_reduce_above ?A ?n ?i ?j ?res) = Hermite_reduce_above_iarrays (matrix_to_iarray ?A) ?n (mod_type_class.to_nat ?i) (mod_type_class.to_nat ?j) ?res›*)) (*goal: ‹¬ is_zero_iarray (IArray.list_of (matrix_to_iarray A) ! mod_type_class.to_nat i) ⟹ matrix_to_iarray (Hermite_reduce_above (mult_row A i (ass (A $ i $ (LEAST n. A $ i $ n ≠ 0)) div A $ i $ (LEAST n. A $ i $ n ≠ 0))) (mod_type_class.to_nat i) i (LEAST n. A $ i $ n ≠ 0) res) = Hermite_reduce_above_iarrays (matrix_to_iarray (mult_row A i (ass (A $ i $ (LEAST n. A $ i $ n ≠ 0)) div A $ i $ (LEAST n. A $ i $ n ≠ 0)))) (mod_type_class.to_nat i) (mod_type_class.to_nat i) (mod_type_class.to_nat (LEAST n. A $ i $ n ≠ 0)) res›*) by (simp add: nrows_def (*‹nrows ?A = CARD(?'rows)›*) to_nat_less_card (*‹mod_type_class.to_nat ?j < CARD(?'a)›*)) qed qed lemma matrix_to_iarray_Hermite_of_upt_row_i: fixes A::"'a::{unique_euclidean_ring}^'cols::{mod_type}^'rows::{mod_type}" assumes i: "i≤nrows A" shows "matrix_to_iarray (Hermite_of_upt_row_i A i ass res) = Hermite_of_upt_row_i_iarrays (matrix_to_iarray A) i ass res" using i (*‹i ≤ nrows A›*) proof (induct i arbitrary: A) (*goals: 1. ‹⋀A. 0 ≤ nrows A ⟹ matrix_to_iarray (Hermite_of_upt_row_i A 0 ass res) = Hermite_of_upt_row_i_iarrays (matrix_to_iarray A) 0 ass res› 2. ‹⋀i A. ⟦⋀A. i ≤ nrows A ⟹ matrix_to_iarray (Hermite_of_upt_row_i A i ass res) = Hermite_of_upt_row_i_iarrays (matrix_to_iarray A) i ass res; Suc i ≤ nrows A⟧ ⟹ matrix_to_iarray (Hermite_of_upt_row_i A (Suc i) ass res) = Hermite_of_upt_row_i_iarrays (matrix_to_iarray A) (Suc i) ass res›*) case 0 (*‹0 ≤ nrows A›*) thus "?case" (*goal: ‹matrix_to_iarray (Hermite_of_upt_row_i A 0 ass res) = Hermite_of_upt_row_i_iarrays (matrix_to_iarray A) 0 ass res›*) by (simp add: Hermite_of_upt_row_i_def (*‹Hermite_of_upt_row_i ?A ?i ?ass ?res = foldl (Hermite_of_row_i ?ass ?res) ?A (map mod_type_class.from_nat [0..<?i])›*) Hermite_of_upt_row_i_iarrays_def (*‹Hermite_of_upt_row_i_iarrays ?A ?i ?ass ?res = foldl (Hermite_of_row_i_iarray ?ass ?res) ?A [0..<?i]›*)) next (*goal: ‹⋀i A. ⟦⋀A. i ≤ nrows A ⟹ matrix_to_iarray (Hermite_of_upt_row_i A i ass res) = Hermite_of_upt_row_i_iarrays (matrix_to_iarray A) i ass res; Suc i ≤ nrows A⟧ ⟹ matrix_to_iarray (Hermite_of_upt_row_i A (Suc i) ass res) = Hermite_of_upt_row_i_iarrays (matrix_to_iarray A) (Suc i) ass res›*) case (Suc i) (*‹i ≤ nrows ?A ⟹ matrix_to_iarray (Hermite_of_upt_row_i ?A i ass res) = Hermite_of_upt_row_i_iarrays (matrix_to_iarray ?A) i ass res› ‹Suc i ≤ nrows A›*) have i: "i<nrows A" using Suc.prems (*‹Suc i ≤ nrows A›*) unfolding nrows_def (*goal: ‹i < CARD('rows)›*) by simp have "matrix_to_iarray (Hermite_of_upt_row_i A (Suc i) ass res) = matrix_to_iarray (Hermite_of_row_i ass res (Hermite_of_upt_row_i A i ass res) (from_nat i))" unfolding Hermite_of_upt_row_i_def (*goal: ‹matrix_to_iarray (foldl (Hermite_of_row_i (ass::'a::unique_euclidean_ring ⇒ 'a::unique_euclidean_ring) (res::'a::unique_euclidean_ring ⇒ 'a::unique_euclidean_ring ⇒ 'a::unique_euclidean_ring)) (A::(('a::unique_euclidean_ring, 'cols::mod_type) vec, 'rows::mod_type) vec) (map mod_type_class.from_nat [0::nat..<Suc (i::nat)])) = matrix_to_iarray (Hermite_of_row_i ass res (foldl (Hermite_of_row_i ass res) A (map mod_type_class.from_nat [0::nat..<i])) (mod_type_class.from_nat i))›*) by auto also (*calculation: ‹matrix_to_iarray (Hermite_of_upt_row_i A (Suc i) ass res) = matrix_to_iarray (Hermite_of_row_i ass res (Hermite_of_upt_row_i A i ass res) (mod_type_class.from_nat i))›*) have "... = (Hermite_of_row_i_iarray ass res (matrix_to_iarray (Hermite_of_upt_row_i A i ass res)) (to_nat (from_nat i::'rows)))" unfolding matrix_to_iarray_Hermite_of_row_i (*goal: ‹Hermite_of_row_i_iarray ass res (matrix_to_iarray (Hermite_of_upt_row_i A i ass res)) (mod_type_class.to_nat (mod_type_class.from_nat i)) = Hermite_of_row_i_iarray ass res (matrix_to_iarray (Hermite_of_upt_row_i A i ass res)) (mod_type_class.to_nat (mod_type_class.from_nat i))›*) by standard also (*calculation: ‹matrix_to_iarray (Hermite_of_upt_row_i A (Suc i) ass res) = Hermite_of_row_i_iarray ass res (matrix_to_iarray (Hermite_of_upt_row_i A i ass res)) (mod_type_class.to_nat (mod_type_class.from_nat i))›*) have "... = (Hermite_of_row_i_iarray ass res (matrix_to_iarray (Hermite_of_upt_row_i A i ass res)) i)" using to_nat_from_nat_id[OF i [ unfolded nrows_def ]] (*‹mod_type_class.to_nat (mod_type_class.from_nat i) = i›*) by simp also (*calculation: ‹matrix_to_iarray (Hermite_of_upt_row_i A (Suc i) ass res) = Hermite_of_row_i_iarray ass res (matrix_to_iarray (Hermite_of_upt_row_i A i ass res)) i›*) have "... = (Hermite_of_row_i_iarray ass res (Hermite_of_upt_row_i_iarrays (matrix_to_iarray A) i ass res) i)" using Suc.hyps (*‹(i::nat) ≤ nrows (?A::(('a, 'cols) vec, 'rows) vec) ⟹ matrix_to_iarray (Hermite_of_upt_row_i ?A i (ass::'a ⇒ 'a) (res::'a ⇒ 'a ⇒ 'a)) = Hermite_of_upt_row_i_iarrays (matrix_to_iarray ?A) i ass res›*) i (*‹(i::nat) < nrows (A::(('a::unique_euclidean_ring, 'cols::mod_type) vec, 'rows::mod_type) vec)›*) unfolding nrows_def (*goal: ‹Hermite_of_row_i_iarray ass res (matrix_to_iarray (Hermite_of_upt_row_i A i ass res)) i = Hermite_of_row_i_iarray ass res (Hermite_of_upt_row_i_iarrays (matrix_to_iarray A) i ass res) i›*) by simp also (*calculation: ‹matrix_to_iarray (Hermite_of_upt_row_i A (Suc i) ass res) = Hermite_of_row_i_iarray ass res (Hermite_of_upt_row_i_iarrays (matrix_to_iarray A) i ass res) i›*) have "... = Hermite_of_upt_row_i_iarrays (matrix_to_iarray A) (Suc i) ass res" unfolding Hermite_of_upt_row_i_iarrays_def (*goal: ‹Hermite_of_row_i_iarray ass res (foldl (Hermite_of_row_i_iarray ass res) (matrix_to_iarray A) [0..<i]) i = foldl (Hermite_of_row_i_iarray ass res) (matrix_to_iarray A) [0..<Suc i]›*) by simp finally (*calculation: ‹matrix_to_iarray (Hermite_of_upt_row_i (A::(('a, 'cols) vec, 'rows) vec) (Suc (i::nat)) (ass::'a ⇒ 'a) (res::'a ⇒ 'a ⇒ 'a)) = Hermite_of_upt_row_i_iarrays (matrix_to_iarray A) (Suc i) ass res›*) show "?case" (*goal: ‹matrix_to_iarray (Hermite_of_upt_row_i A (Suc i) ass res) = Hermite_of_upt_row_i_iarrays (matrix_to_iarray A) (Suc i) ass res›*) . qed lemma matrix_to_iarray_Hermite_of[code_unfold]: shows "matrix_to_iarray (Hermite_of A ass res bezout) = Hermite_of_iarrays (matrix_to_iarray A) ass res bezout" proof (-) (*goal: ‹matrix_to_iarray (Hermite_of A ass res bezout) = Hermite_of_iarrays (matrix_to_iarray A) ass res bezout›*) have n: "nrows A ≤ nrows (echelon_form_of A bezout)" unfolding nrows_def (*goal: ‹CARD('c) ≤ CARD('c)›*) by simp show "?thesis" (*goal: ‹matrix_to_iarray (Hermite_of (A::(('a, 'b) vec, 'c) vec) (ass::'a ⇒ 'a) (res::'a ⇒ 'a ⇒ 'a) (bezout::'a ⇒ 'a ⇒ 'a × 'a × 'a × 'a × 'a)) = Hermite_of_iarrays (matrix_to_iarray A) ass res bezout›*) unfolding Hermite_of_def Hermite_of_iarrays_def Let_def (*goal: ‹matrix_to_iarray (Hermite_of_upt_row_i (echelon_form_of A bezout) (nrows A) ass res) = Hermite_of_upt_row_i_iarrays (echelon_form_of_iarrays (matrix_to_iarray A) bezout) (nrows_iarray (matrix_to_iarray A)) ass res›*) unfolding matrix_to_iarray_Hermite_of_upt_row_i[OF n] (*goal: ‹Hermite_of_upt_row_i_iarrays (matrix_to_iarray (echelon_form_of A bezout)) (nrows A) ass res = Hermite_of_upt_row_i_iarrays (echelon_form_of_iarrays (matrix_to_iarray A) bezout) (nrows_iarray (matrix_to_iarray A)) ass res›*) unfolding matrix_to_iarray_echelon_form_of (*goal: ‹Hermite_of_upt_row_i_iarrays (echelon_form_of_iarrays (matrix_to_iarray A) bezout) (nrows A) ass res = Hermite_of_upt_row_i_iarrays (echelon_form_of_iarrays (matrix_to_iarray A) bezout) (nrows_iarray (matrix_to_iarray A)) ass res›*) unfolding matrix_to_iarray_nrows (*goal: ‹Hermite_of_upt_row_i_iarrays (echelon_form_of_iarrays (matrix_to_iarray A) bezout) (nrows_iarray (matrix_to_iarray A)) ass res = Hermite_of_upt_row_i_iarrays (echelon_form_of_iarrays (matrix_to_iarray A) bezout) (nrows_iarray (matrix_to_iarray A)) ass res›*) by standard qed subsection‹Examples of execution using immutable arrays› value[code] "let A = list_of_list_to_matrix ([[37,8,6],[5,4,-8],[3,24,-7]])::int^3^3 in matrix_to_iarray (Hermite_of A ass_function_euclidean res_function_euclidean euclid_ext2)" value[code] "let A = IArray[IArray[37,8,6::int],IArray[5,4,-8],IArray[3,24,-7]] in (Hermite_of_iarrays A ass_function_euclidean res_function_euclidean euclid_ext2)" value[code] "let A = list_of_list_to_matrix ([[[:3,4,5:],[:-2,1:]],[[:-1,0,2:],[:0,1,4,1:]]])::real poly^2^2 in matrix_to_iarray (Hermite_of A ass_function_euclidean res_function_euclidean euclid_ext2)" end
{ "path": "afp-2025-02-12/thys/Hermite/Hermite_IArrays.thy", "repo": "afp-2025-02-12", "sha": "ecaacf15d7855172d90ff480d9ea6366fb312c5bd09b51a28508ac75b7df88ca" }
section ‹Maximum Segment Sum› theory Maximum_Segment_Sum imports Main begin text ‹The \emph{maximum segment sum} problem is to compute, given a list of numbers, the largest of the sums of the contiguous segments of that list. It is also known as the \emph{maximum sum subarray} problem and has been considered many times in the literature; the Wikipedia article \href{https://en.wikipedia.org/wiki/Maximum\_subarray\_problem}{Maximum subarray problem} is a good starting point. We assume that the elements of the list are not necessarily numbers but just elements of some linearly ordered group.› class linordered_group_add = linorder + group_add + assumes add_left_mono: "a ≤ b ⟹ c + a ≤ c + b" assumes add_right_mono: "a ≤ b ⟹ a + c ≤ b + c" begin lemma max_add_distrib_left: "max y z + x = max (y+x) (z+x)" by (metis add_right_mono (*‹?a ≤ ?b ⟹ ?a + ?c ≤ ?b + ?c›*) max.absorb_iff1 (*‹(?b ≤ ?a) = (max ?a ?b = ?a)›*) max_def (*‹max ?a ?b = (if ?a ≤ ?b then ?b else ?a)›*)) lemma max_add_distrib_right: "x + max y z = max (x+y) (x+z)" by (metis add_left_mono (*‹?a ≤ ?b ⟹ ?c + ?a ≤ ?c + ?b›*) max.absorb1 (*‹?b ≤ ?a ⟹ max ?a ?b = ?a›*) max.cobounded2 (*‹?b ≤ max ?a ?b›*) max_def (*‹max ?a ?b = (if ?a ≤ ?b then ?b else ?a)›*)) subsection ‹Naive Solution› fun mss_rec_naive_aux :: "'a list ⇒ 'a" where "mss_rec_naive_aux [] = 0" | "mss_rec_naive_aux (x#xs) = max 0 (x + mss_rec_naive_aux xs)" fun mss_rec_naive :: "'a list ⇒ 'a" where "mss_rec_naive [] = 0" | "mss_rec_naive (x#xs) = max (mss_rec_naive_aux (x#xs)) (mss_rec_naive xs)" definition fronts :: "'a list ⇒ 'a list set" where "fronts xs = {as. ∃bs. xs = as @ bs}" definition "front_sums xs ≡ sum_list ` fronts xs" lemma fronts_cons: "fronts (x#xs) = ((#) x) ` fronts xs ∪ {[]}" (is "?l = ?r") proof (standard) (*goals: 1. ‹fronts (x # xs) ⊆ (#) x ` fronts xs ∪ {[]}› 2. ‹(#) x ` fronts xs ∪ {[]} ⊆ fronts (x # xs)›*) show "?l ⊆ ?r" proof (standard) (*goal: ‹⋀xa. xa ∈ fronts (x # xs) ⟹ xa ∈ (#) x ` fronts xs ∪ {[]}›*) fix as assume "as ∈ ?l" (*‹(as::'a list) ∈ fronts ((x::'a) # (xs::'a list))›*) then show "as ∈ ?r" apply (cases as) (*goals: 1. ‹⟦(as::'a::type list) ∈ fronts ((x::'a::type) # (xs::'a::type list)); as = []⟧ ⟹ as ∈ (#) x ` fronts xs ∪ {[]}› 2. ‹⋀(a::'a::type) list::'a::type list. ⟦(as::'a::type list) ∈ fronts ((x::'a::type) # (xs::'a::type list)); as = a # list⟧ ⟹ as ∈ (#) x ` fronts xs ∪ {[]}› discuss goal 1*) apply ((auto simp: fronts_def (*‹fronts (?xs::'a list) = {as::'a list. ∃bs::'a list. ?xs = as @ bs}›*))[1]) (*discuss goal 2*) apply ((auto simp: fronts_def (*‹fronts (?xs::'a::type list) = {as::'a::type list. ∃bs::'a::type list. ?xs = as @ bs}›*))[1]) (*proven 2 subgoals*) . qed show "?r ⊆ ?l" unfolding fronts_def (*goal: ‹(#) (x::'a) ` {as::'a list. ∃bs::'a list. (xs::'a list) = as @ bs} ∪ {[]} ⊆ {as::'a list. ∃bs::'a list. x # xs = as @ bs}›*) by auto qed lemma front_sums_cons: "front_sums (x#xs) = (+) x ` front_sums xs ∪ {0}" proof (-) (*goal: ‹front_sums (x # xs) = (+) x ` front_sums xs ∪ {0}›*) have "sum_list ` ((#) x) ` fronts xs = (+) x ` front_sums xs" unfolding front_sums_def (*goal: ‹sum_list ` (#) x ` fronts xs = (+) x ` sum_list ` fronts xs›*) by force then show "?thesis" (*goal: ‹front_sums ((x::'a) # (xs::'a list)) = (+) x ` front_sums xs ∪ {0::'a}›*) by (simp add: front_sums_def (*‹front_sums ?xs ≡ sum_list ` fronts ?xs›*) fronts_cons (*‹fronts (?x # ?xs) = (#) ?x ` fronts ?xs ∪ {[]}›*)) qed lemma finite_fronts: "finite (fronts xs)" apply (induction xs) (*goals: 1. ‹finite (fronts [])› 2. ‹⋀a xs. finite (fronts xs) ⟹ finite (fronts (a # xs))› discuss goal 1*) apply (simp add: fronts_def (*‹fronts ?xs = {as. ∃bs. ?xs = as @ bs}›*)) (*discuss goal 2*) apply (simp add: fronts_cons (*‹fronts (?x # ?xs) = (#) ?x ` fronts ?xs ∪ {[]}›*)) (*proven 2 subgoals*) . lemma finite_front_sums: "finite (front_sums xs)" using front_sums_def (*‹front_sums ?xs ≡ sum_list ` fronts ?xs›*) finite_fronts (*‹finite (fronts ?xs)›*) by simp lemma front_sums_not_empty: "front_sums xs ≠ {}" unfolding front_sums_def fronts_def (*goal: ‹sum_list ` {as. ∃bs. xs = as @ bs} ≠ {}›*) using image_iff (*‹((?z::?'a) ∈ (?f::?'b ⇒ ?'a) ` (?A::?'b set)) = (∃x::?'b∈?A. ?z = ?f x)›*) by fastforce lemma max_front_sum: "Max (front_sums (x#xs)) = max 0 (x + Max (front_sums xs))" using finite_front_sums (*‹finite (front_sums ?xs)›*) front_sums_not_empty (*‹front_sums ?xs ≠ {}›*) by (auto simp add: front_sums_cons (*‹front_sums (?x # ?xs) = (+) ?x ` front_sums ?xs ∪ {0}›*) hom_Max_commute (*‹⟦⋀x y. ?h (max x y) = max (?h x) (?h y); finite ?N; ?N ≠ {}⟧ ⟹ ?h (Max ?N) = Max (?h ` ?N)›*) max_add_distrib_right (*‹?x + max ?y ?z = max (?x + ?y) (?x + ?z)›*)) lemma mss_rec_naive_aux_front_sums: "mss_rec_naive_aux xs = Max (front_sums xs)" apply (induction xs) (*goals: 1. ‹mss_rec_naive_aux [] = Max (front_sums [])› 2. ‹⋀a xs. mss_rec_naive_aux xs = Max (front_sums xs) ⟹ mss_rec_naive_aux (a # xs) = Max (front_sums (a # xs))› discuss goal 1*) apply (simp add: front_sums_def (*‹front_sums (?xs::'a list) ≡ sum_list ` fronts ?xs›*) fronts_def (*‹fronts (?xs::'a list) = {as::'a list. ∃bs::'a list. ?xs = as @ bs}›*)) (*discuss goal 2*) apply (auto simp: max_front_sum (*‹Max (front_sums (?x # ?xs)) = max 0 (?x + Max (front_sums ?xs))›*)) (*proven 2 subgoals*) . lemma front_sums: "front_sums xs = {s. ∃as bs. xs = as @ bs ∧ s = sum_list as}" unfolding front_sums_def fronts_def (*goal: ‹sum_list ` {as. ∃bs. xs = as @ bs} = {s. ∃as bs. xs = as @ bs ∧ s = sum_list as}›*) by auto lemma mss_rec_naive_aux: "mss_rec_naive_aux xs = Max {s. ∃as bs. xs = as @ bs ∧ s = sum_list as}" using front_sums (*‹front_sums ?xs = {s. ∃as bs. ?xs = as @ bs ∧ s = sum_list as}›*) mss_rec_naive_aux_front_sums (*‹mss_rec_naive_aux ?xs = Max (front_sums ?xs)›*) by simp definition mids :: "'a list ⇒ 'a list set" where "mids xs ≡ {bs. ∃as cs. xs = as @ bs @ cs}" definition "mid_sums xs ≡ sum_list ` mids xs" lemma fronts_mids: "bs ∈ fronts xs ⟹ bs ∈ mids xs" unfolding fronts_def mids_def (*goal: ‹bs ∈ {as. ∃bs. xs = as @ bs} ⟹ bs ∈ {bs. ∃as cs. xs = as @ bs @ cs}›*) by auto lemma mids_mids_cons: "bs ∈ mids xs ⟹ bs ∈ mids (x#xs)" proof (-) (*goal: ‹bs ∈ mids xs ⟹ bs ∈ mids (x # xs)›*) fix bs assume "bs ∈ mids xs" (*‹(bs::'a list) ∈ mids (xs::'a list)›*) then obtain as and cs where "xs = as @ bs @ cs" (*goal: ‹(⋀as cs. xs = as @ bs @ cs ⟹ thesis) ⟹ thesis›*) unfolding mids_def (*goal: ‹(⋀(as::'a list) cs::'a list. (xs::'a list) = as @ (bs::'a list) @ cs ⟹ thesis::bool) ⟹ thesis›*) by blast then have "x # xs = (x#as) @ bs @ cs" by simp then show "bs ∈ mids (x#xs)" unfolding mids_def (*goal: ‹bs ∈ {bs. ∃as cs. x # xs = as @ bs @ cs}›*) by blast qed lemma mids_cons: "mids (x#xs) = fronts (x#xs) ∪ mids xs" (is "?l = ?r") proof (standard) (*goals: 1. ‹mids (x # xs) ⊆ fronts (x # xs) ∪ mids xs› 2. ‹fronts (x # xs) ∪ mids xs ⊆ mids (x # xs)›*) show "?l ⊆ ?r" proof (standard) (*goal: ‹⋀xa. xa ∈ mids (x # xs) ⟹ xa ∈ fronts (x # xs) ∪ mids xs›*) fix bs assume "bs ∈ ?l" (*‹(bs::'a list) ∈ mids ((x::'a) # (xs::'a list))›*) then obtain as and cs where as_bs_cs: "(x#xs) = as @ bs @ cs" (*goal: ‹(⋀as cs. x # xs = as @ bs @ cs ⟹ thesis) ⟹ thesis›*) unfolding mids_def (*goal: ‹(⋀as cs. x # xs = as @ bs @ cs ⟹ thesis) ⟹ thesis›*) by blast then show "bs ∈ ?r" proof (cases as) (*goals: 1. ‹⟦x # xs = as @ bs @ cs; as = []⟧ ⟹ bs ∈ fronts (x # xs) ∪ mids xs› 2. ‹⋀a list. ⟦x # xs = as @ bs @ cs; as = a # list⟧ ⟹ bs ∈ fronts (x # xs) ∪ mids xs›*) case Nil (*‹as = []›*) then have "bs ∈ fronts (x#xs)" by (simp add: fronts_def (*‹fronts (?xs::'a list) = {as::'a list. ∃bs::'a list. ?xs = as @ bs}›*) as_bs_cs (*‹(x::'a) # (xs::'a list) = (as::'a list) @ (bs::'a list) @ (cs::'a list)›*)) then show "?thesis" (*goal: ‹bs ∈ fronts (x # xs) ∪ mids xs›*) by simp next (*goal: ‹⋀a list. ⟦x # xs = as @ bs @ cs; as = a # list⟧ ⟹ bs ∈ fronts (x # xs) ∪ mids xs›*) case (Cons a as') (*‹as = a # as'›*) then have "xs = as' @ bs @ cs" using as_bs_cs (*‹x # xs = as @ bs @ cs›*) by simp then show "?thesis" (*goal: ‹bs ∈ fronts (x # xs) ∪ mids xs›*) unfolding mids_def (*goal: ‹bs ∈ fronts (x # xs) ∪ {bs. ∃as cs. xs = as @ bs @ cs}›*) by auto qed qed show "?r ⊆ ?l" using fronts_mids (*‹(?bs::'a list) ∈ fronts (?xs::'a list) ⟹ ?bs ∈ mids ?xs›*) mids_mids_cons (*‹?bs ∈ mids ?xs ⟹ ?bs ∈ mids (?x # ?xs)›*) by auto qed lemma mid_sums_cons: "mid_sums (x#xs) = front_sums (x#xs) ∪ mid_sums xs" unfolding mid_sums_def (*goal: ‹sum_list ` mids (x # xs) = front_sums (x # xs) ∪ sum_list ` mids xs›*) by (auto simp: mids_cons (*‹mids (?x # ?xs) = fronts (?x # ?xs) ∪ mids ?xs›*) front_sums_def (*‹front_sums ?xs ≡ sum_list ` fronts ?xs›*)) lemma finite_mids: "finite (mids xs)" apply (induction xs) (*goals: 1. ‹finite (mids [])› 2. ‹⋀(a::'a) xs::'a list. finite (mids xs) ⟹ finite (mids (a # xs))› discuss goal 1*) apply (simp add: mids_def (*‹mids ?xs ≡ {bs. ∃as cs. ?xs = as @ bs @ cs}›*)) (*discuss goal 2*) apply (simp add: mids_cons (*‹mids (?x # ?xs) = fronts (?x # ?xs) ∪ mids ?xs›*) finite_fronts (*‹finite (fronts ?xs)›*)) (*proven 2 subgoals*) . lemma finite_mid_sums: "finite (mid_sums xs)" by (simp add: mid_sums_def (*‹mid_sums ?xs ≡ sum_list ` mids ?xs›*) finite_mids (*‹finite (mids ?xs)›*)) lemma mid_sums_not_empty: "mid_sums xs ≠ {}" unfolding mid_sums_def mids_def (*goal: ‹sum_list ` {bs. ∃as cs. xs = as @ bs @ cs} ≠ {}›*) by blast lemma max_mid_sums_cons: "Max (mid_sums (x#xs)) = max (Max (front_sums (x#xs))) (Max (mid_sums xs))" by (auto simp: mid_sums_cons (*‹mid_sums (?x # ?xs) = front_sums (?x # ?xs) ∪ mid_sums ?xs›*) Max_Un (*‹⟦finite ?A; ?A ≠ {}; finite ?B; ?B ≠ {}⟧ ⟹ Max (?A ∪ ?B) = max (Max ?A) (Max ?B)›*) finite_front_sums (*‹finite (front_sums ?xs)›*) finite_mid_sums (*‹finite (mid_sums ?xs)›*) front_sums_not_empty (*‹front_sums ?xs ≠ {}›*) mid_sums_not_empty (*‹mid_sums ?xs ≠ {}›*)) lemma mss_rec_naive_max_mid_sum: "mss_rec_naive xs = Max (mid_sums xs)" apply (induction xs) (*goals: 1. ‹mss_rec_naive [] = Max (mid_sums [])› 2. ‹⋀a xs. mss_rec_naive xs = Max (mid_sums xs) ⟹ mss_rec_naive (a # xs) = Max (mid_sums (a # xs))› discuss goal 1*) apply (simp add: mid_sums_def (*‹mid_sums ?xs ≡ sum_list ` mids ?xs›*) mids_def (*‹mids ?xs ≡ {bs. ∃as cs. ?xs = as @ bs @ cs}›*)) (*discuss goal 2*) apply (auto simp: max_mid_sums_cons (*‹Max (mid_sums (?x # ?xs)) = max (Max (front_sums (?x # ?xs))) (Max (mid_sums ?xs))›*) mss_rec_naive_aux (*‹mss_rec_naive_aux ?xs = Max {s. ∃as bs. ?xs = as @ bs ∧ s = sum_list as}›*) front_sums (*‹front_sums ?xs = {s. ∃as bs. ?xs = as @ bs ∧ s = sum_list as}›*)) (*proven 2 subgoals*) . lemma mid_sums: "mid_sums xs = {s. ∃as bs cs. xs = as @ bs @ cs ∧ s = sum_list bs}" by (auto simp: mid_sums_def (*‹mid_sums ?xs ≡ sum_list ` mids ?xs›*) mids_def (*‹mids ?xs ≡ {bs. ∃as cs. ?xs = as @ bs @ cs}›*)) theorem mss_rec_naive: "mss_rec_naive xs = Max {s. ∃as bs cs. xs = as @ bs @ cs ∧ s = sum_list bs}" unfolding mss_rec_naive_max_mid_sum mid_sums (*goal: ‹Max {s. ∃as bs cs. xs = as @ bs @ cs ∧ s = sum_list bs} = Max {s. ∃as bs cs. xs = as @ bs @ cs ∧ s = sum_list bs}›*) by simp subsection ‹Kadane's Algorithms› fun kadane :: "'a list ⇒ 'a ⇒ 'a ⇒ 'a" where "kadane [] cur m = m" | "kadane (x#xs) cur m = (let cur' = max (cur + x) x in kadane xs cur' (max m cur'))" definition "mss_kadane xs ≡ kadane xs 0 0" lemma Max_front_sums_geq_0: "Max (front_sums xs) ≥ 0" proof (-) (*goal: ‹0 ≤ Max (front_sums xs)›*) have "[] ∈ fronts xs" unfolding fronts_def (*goal: ‹[] ∈ {as. ∃bs. xs = as @ bs}›*) by blast then have "0 ∈ front_sums xs" unfolding front_sums_def (*goal: ‹(0::'a) ∈ sum_list ` fronts (xs::'a list)›*) by force then show "?thesis" (*goal: ‹0 ≤ Max (front_sums xs)›*) using finite_front_sums (*‹finite (front_sums ?xs)›*) Max_ge (*‹⟦finite ?A; ?x ∈ ?A⟧ ⟹ ?x ≤ Max ?A›*) by simp qed lemma Max_mid_sums_geq_0: "Max (mid_sums xs) ≥ 0" proof (-) (*goal: ‹0 ≤ Max (mid_sums xs)›*) have "0 ∈ mid_sums xs" unfolding mid_sums_def mids_def (*goal: ‹0 ∈ sum_list ` {bs. ∃as cs. xs = as @ bs @ cs}›*) by force then show "?thesis" (*goal: ‹0 ≤ Max (mid_sums xs)›*) using finite_mid_sums (*‹finite (mid_sums ?xs)›*) Max_ge (*‹⟦finite (?A::'a set); (?x::'a) ∈ ?A⟧ ⟹ ?x ≤ Max ?A›*) by simp qed lemma kadane: "m ≥ cur ⟹ m ≥ 0 ⟹ kadane xs cur m = max m (max (cur + Max (front_sums xs)) (Max (mid_sums xs)))" proof (induction xs cur m rule: kadane.induct (*‹⟦⋀cur m. ?P [] cur m; ⋀x xs cur m. (⋀xa. xa = max (cur + x) x ⟹ ?P xs xa (max m xa)) ⟹ ?P (x # xs) cur m⟧ ⟹ ?P ?a0.0 ?a1.0 ?a2.0›*)) (*goals: 1. ‹⋀cur m. ⟦cur ≤ m; 0 ≤ m⟧ ⟹ kadane [] cur m = max m (max (cur + Max (front_sums [])) (Max (mid_sums [])))› 2. ‹⋀x xs cur m. ⟦⋀xa. ⟦xa = max (cur + x) x; xa ≤ max m xa; 0 ≤ max m xa⟧ ⟹ kadane xs xa (max m xa) = max (max m xa) (max (xa + Max (front_sums xs)) (Max (mid_sums xs))); cur ≤ m; 0 ≤ m⟧ ⟹ kadane (x # xs) cur m = max m (max (cur + Max (front_sums (x # xs))) (Max (mid_sums (x # xs))))›*) case (1 cur m) (*‹cur ≤ m› ‹0 ≤ m›*) then show "?case" (*goal: ‹kadane [] cur m = max m (max (cur + Max (front_sums [])) (Max (mid_sums [])))›*) unfolding front_sums_def fronts_def mid_sums_def mids_def (*goal: ‹kadane [] cur m = max m (max (cur + Max (sum_list ` {as. ∃bs. [] = as @ bs})) (Max (sum_list ` {bs. ∃as cs. [] = as @ bs @ cs})))›*) by auto next (*goal: ‹⋀x xs cur m. ⟦⋀xa. ⟦xa = max (cur + x) x; xa ≤ max m xa; 0 ≤ max m xa⟧ ⟹ kadane xs xa (max m xa) = max (max m xa) (max (xa + Max (front_sums xs)) (Max (mid_sums xs))); cur ≤ m; 0 ≤ m⟧ ⟹ kadane (x # xs) cur m = max m (max (cur + Max (front_sums (x # xs))) (Max (mid_sums (x # xs))))›*) case (2 x xs cur m) (*‹⟦?xa = max (cur + x) x; ?xa ≤ max m ?xa; 0 ≤ max m ?xa⟧ ⟹ kadane xs ?xa (max m ?xa) = max (max m ?xa) (max (?xa + Max (front_sums xs)) (Max (mid_sums xs)))› ‹cur ≤ m› ‹0 ≤ m›*) then show "?case" (*goal: ‹kadane (x # xs) cur m = max m (max (cur + Max (front_sums (x # xs))) (Max (mid_sums (x # xs))))›*) apply (auto simp: max_front_sum (*‹Max (front_sums (?x # ?xs)) = max 0 (?x + Max (front_sums ?xs))›*) max_mid_sums_cons (*‹Max (mid_sums (?x # ?xs)) = max (Max (front_sums (?x # ?xs))) (Max (mid_sums ?xs))›*) Let_def (*‹Let ?s ?f ≡ ?f ?s›*)) (*goal: ‹kadane (x # xs) cur m = max m (max (cur + Max (front_sums (x # xs))) (Max (mid_sums (x # xs))))›*) by (smt (verit, ccfv_threshold) Max_front_sums_geq_0 (*‹0 ≤ Max (front_sums ?xs)›*) add_assoc (*‹?a + ?b + ?c = ?a + (?b + ?c)›*) add_0_right (*‹?a + 0 = ?a›*) max.assoc (*‹max (max ?a ?b) ?c = max ?a (max ?b ?c)›*) max.coboundedI1 (*‹?c ≤ ?a ⟹ ?c ≤ max ?a ?b›*) max.left_commute (*‹max ?b (max ?a ?c) = max ?a (max ?b ?c)›*) max.orderE (*‹⟦?b ≤ ?a; ?a = max ?a ?b ⟹ ?thesis⟧ ⟹ ?thesis›*) max_add_distrib_left (*‹max ?y ?z + ?x = max (?y + ?x) (?z + ?x)›*) max_add_distrib_right (*‹?x + max ?y ?z = max (?x + ?y) (?x + ?z)›*)) qed lemma Max_front_sums_leq_Max_mid_sums: "Max (front_sums xs) ≤ Max (mid_sums xs)" proof (-) (*goal: ‹Max (front_sums xs) ≤ Max (mid_sums xs)›*) have "front_sums xs ⊆ mid_sums xs" unfolding front_sums_def mid_sums_def (*goal: ‹sum_list ` fronts xs ⊆ sum_list ` mids xs›*) using fronts_mids (*‹?bs ∈ fronts ?xs ⟹ ?bs ∈ mids ?xs›*) subset_iff (*‹(?A ⊆ ?B) = (∀t. t ∈ ?A ⟶ t ∈ ?B)›*) by blast then show "?thesis" (*goal: ‹Max (front_sums xs) ≤ Max (mid_sums xs)›*) using front_sums_not_empty (*‹front_sums ?xs ≠ {}›*) finite_mid_sums (*‹finite (mid_sums ?xs)›*) Max_mono (*‹⟦?M ⊆ ?N; ?M ≠ {}; finite ?N⟧ ⟹ Max ?M ≤ Max ?N›*) by blast qed lemma mss_kadane_mid_sums: "mss_kadane xs = Max (mid_sums xs)" unfolding mss_kadane_def (*goal: ‹kadane xs 0 0 = Max (mid_sums xs)›*) using kadane (*‹⟦?cur ≤ ?m; 0 ≤ ?m⟧ ⟹ kadane ?xs ?cur ?m = max ?m (max (?cur + Max (front_sums ?xs)) (Max (mid_sums ?xs)))›*) Max_mid_sums_geq_0 (*‹0 ≤ Max (mid_sums ?xs)›*) Max_front_sums_leq_Max_mid_sums (*‹Max (front_sums (?xs::'a list)) ≤ Max (mid_sums ?xs)›*) by auto theorem mss_kadane: "mss_kadane xs = Max {s. ∃as bs cs. xs = as @ bs @ cs ∧ s = sum_list bs}" using mss_kadane_mid_sums (*‹mss_kadane (?xs::'a::type list) = Max (mid_sums ?xs)›*) mid_sums (*‹mid_sums (?xs::'a list) = {s::'a. ∃(as::'a list) (bs::'a list) cs::'a list. ?xs = as @ bs @ cs ∧ s = sum_list bs}›*) by auto end end
{ "path": "afp-2025-02-12/thys/Maximum_Segment_Sum/Maximum_Segment_Sum.thy", "repo": "afp-2025-02-12", "sha": "250a799a8eb1acf6580f144b9ca21767ccd66b6cee3623ad015d97d66ed23836" }
(* Title: HOL/TLA/Buffer/Buffer.thy Author: Stephan Merz, University of Munich *) section ‹A simple FIFO buffer (synchronous communication, interleaving)› theory Buffer imports "HOL-TLA.TLA" begin (* actions *) definition BInit :: "'a stfun ⇒ 'a list stfun ⇒ 'a stfun ⇒ stpred" where "BInit ic q oc == PRED q = #[]" definition Enq :: "'a stfun ⇒ 'a list stfun ⇒ 'a stfun ⇒ action" where "Enq ic q oc == ACT (ic$ ≠ $ic) ∧ (q$ = $q @ [ ic$ ]) ∧ (oc$ = $oc)" definition Deq :: "'a stfun ⇒ 'a list stfun ⇒ 'a stfun ⇒ action" where "Deq ic q oc == ACT ($q ≠ #[]) ∧ (oc$ = hd< $q >) ∧ (q$ = tl< $q >) ∧ (ic$ = $ic)" definition Next :: "'a stfun ⇒ 'a list stfun ⇒ 'a stfun ⇒ action" where "Next ic q oc == ACT (Enq ic q oc ∨ Deq ic q oc)" (* temporal formulas *) definition IBuffer :: "'a stfun ⇒ 'a list stfun ⇒ 'a stfun ⇒ temporal" where "IBuffer ic q oc == TEMP Init (BInit ic q oc) ∧ □[Next ic q oc]_(ic,q,oc) ∧ WF(Deq ic q oc)_(ic,q,oc)" definition Buffer :: "'a stfun ⇒ 'a stfun ⇒ temporal" where "Buffer ic oc == TEMP (∃∃q. IBuffer ic q oc)" (* ---------------------------- Data lemmas ---------------------------- *) (*FIXME: move to theory List? Maybe as (tl xs = xs) = (xs = [])"?*) lemma tl_not_self [simp]: "xs ≠ [] ⟹ tl xs ≠ xs" by (auto simp: neq_Nil_conv (*‹(?xs ≠ []) = (∃y ys. ?xs = y # ys)›*)) (* ---------------------------- Action lemmas ---------------------------- *) (* Dequeue is visible *) lemma Deq_visible: "⊢ <Deq ic q oc>_(ic,q,oc) = Deq ic q oc" apply (unfold angle_def (*‹<?A>_?v ≡ ?A ∧ ¬ unchanged ?v›*) Deq_def (*‹Deq ?ic ?q ?oc ≡ $?q ≠ #[] ∧ ?oc$ = hd<$?q> ∧ ?q$ = tl<$?q> ∧ ?ic$ = $?ic›*)) (*goal: ‹⊢ <Deq ic q oc>_(ic, q, oc) = Deq ic q oc›*) apply safe (*goal: ‹⊢ (($q ≠ #[] ∧ oc$ = hd<$q> ∧ q$ = tl<$q> ∧ ic$ = $ic) ∧ ¬ unchanged (ic, q, oc)) = ($q ≠ #[] ∧ oc$ = hd<$q> ∧ q$ = tl<$q> ∧ ic$ = $ic)›*) apply (simp (asm_lr)) (*goal: ‹⋀(s::state) t::state. (s, t) ⊨ (($(q::state ⇒ 'a::type list) ≠ #[] ∧ (oc::state ⇒ 'a::type)$ = hd<$q> ∧ q$ = tl<$q> ∧ (ic::state ⇒ 'a::type)$ = $ic) ∧ ¬ unchanged (ic, q, oc)) = ($q ≠ #[] ∧ oc$ = hd<$q> ∧ q$ = tl<$q> ∧ ic$ = $ic)›*) apply safe (*goal: ‹⋀s t. (q s ≠ [] ∧ oc t = hd (q s) ∧ q t = tl (q s) ∧ ic t = ic s ∧ (q t = q s ⟶ ic t = ic s ⟶ oc t ≠ oc s)) = (q s ≠ [] ∧ oc t = hd (q s) ∧ q t = tl (q s) ∧ ic t = ic s)›*) by (simp (asm_lr)) (* Enabling condition for dequeue -- NOT NEEDED *) lemma Deq_enabled: "⋀q. basevars (ic,q,oc) ⟹ ⊢ Enabled (<Deq ic q oc>_(ic,q,oc)) = (q ≠ #[])" apply (unfold Deq_visible [temp_rewrite] (*‹<Deq (?ic::state ⇒ ?'a) (?q::state ⇒ ?'a list) (?oc::state ⇒ ?'a)>_(?ic, ?q, ?oc) ≡ Deq ?ic ?q ?oc›*)) (*goal: ‹⋀q. basevars (ic, q, oc) ⟹ ⊢ Enabled (<Deq ic q oc>_(ic, q, oc)) = (q ≠ #[])›*) by (force elim!: base_enabled [temp_use] (*‹⟦basevars ?vs; ∃c. ∀u. ?vs u = c ⟶ ?A (?s, u)⟧ ⟹ ?s ⊨ Enabled ?A›*) enabledE [temp_use] (*‹⟦?s ⊨ Enabled ?A; ⋀u. ?A (?s, u) ⟹ ?Q⟧ ⟹ ?Q›*) simp: Deq_def (*‹Deq ?ic ?q ?oc ≡ $?q ≠ #[] ∧ ?oc$ = hd<$?q> ∧ ?q$ = tl<$?q> ∧ ?ic$ = $?ic›*)) (* For the left-to-right implication, we don't need the base variable stuff *) lemma Deq_enabledE: "⊢ Enabled (<Deq ic q oc>_(ic,q,oc)) ⟶ (q ≠ #[])" apply (unfold Deq_visible [temp_rewrite] (*‹<Deq ?ic ?q ?oc>_(?ic, ?q, ?oc) ≡ Deq ?ic ?q ?oc›*)) (*goal: ‹⊢ Enabled (<Deq ic q oc>_(ic, q, oc)) ⟶ q ≠ #[]›*) by (auto elim!: enabledE (*‹⟦?s ⊨ Enabled ?A; ⋀u. ?A (?s, u) ⟹ ?Q⟧ ⟹ ?Q›*) simp add: Deq_def (*‹Deq ?ic ?q ?oc ≡ $?q ≠ #[] ∧ ?oc$ = hd<$?q> ∧ ?q$ = tl<$?q> ∧ ?ic$ = $?ic›*)) end
{ "path": "Isabelle2024/src/HOL/TLA/Buffer/Buffer.thy", "repo": "Isabelle2024", "sha": "03c485b71303648b2e083b26c3444daf5d2fbfe07450642578b90fbb1376b2dc" }
section ‹Missing Library Material› theory Lambert_Series_Library imports "HOL-Complex_Analysis.Complex_Analysis" "HOL-Library.Landau_Symbols" "HOL-Real_Asymp.Real_Asymp" begin subsection ‹Miscellaneous› lemma power_less_1_iff: "x ≥ 0 ⟹ (x :: real) ^ n < 1 ⟷ x < 1 ∧ n > 0" by (metis not_gr_zero (*‹(¬ 0 < ?n) = (?n = 0)›*) not_less_iff_gr_or_eq (*‹(¬ ?x < ?y) = (?y < ?x ∨ ?x = ?y)›*) power_0 (*‹?a ^ 0 = 1›*) real_root_lt_1_iff (*‹0 < ?n ⟹ (root ?n ?x < 1) = (?x < 1)›*) real_root_pos2 (*‹⟦0 < ?n; 0 ≤ ?x⟧ ⟹ root ?n (?x ^ ?n) = ?x›*)) lemma fls_nth_sum: "fls_nth (∑x∈A. f x) n = (∑x∈A. fls_nth (f x) n)" apply (induction 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 ⟹ fls_nth (sum f A) n = (∑x∈A. fls_nth (f x) n)› 2. ‹fls_nth (sum f {}) n = (∑x∈{}. fls_nth (f x) n)› 3. ‹⋀x F. ⟦finite F; x ∉ F; fls_nth (sum f F) n = (∑x∈F. fls_nth (f x) n)⟧ ⟹ fls_nth (sum f (insert x F)) n = (∑x∈insert x F. fls_nth (f x) n)› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*proven 3 subgoals*) . lemma two_times_choose_two: "2 * (n choose 2) = n * (n - 1)" unfolding choose_two (*goal: ‹2 * (n * (n - 1) div 2) = n * (n - 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*)) lemma Nats_not_empty [simp]: "ℕ ≠ {}" using Nats_1 (*‹1 ∈ ℕ›*) by blast subsection ‹Infinite sums› lemma has_sum_iff: "(f has_sum S) A ⟷ f summable_on A ∧ infsum f A = S" using infsumI (*‹((?f::?'a::type ⇒ ?'b::{comm_monoid_add,t2_space}) has_sum (?x::?'b::{comm_monoid_add,t2_space})) (?A::?'a::type set) ⟹ infsum ?f ?A = ?x›*) summable_iff_has_sum_infsum (*‹(?f summable_on ?A) = (?f has_sum infsum ?f ?A) ?A›*) by blast lemma summable_on_reindex_bij_witness: assumes "⋀a. a ∈ S ⟹ i (j a) = a" assumes "⋀a. a ∈ S ⟹ j a ∈ T" assumes "⋀b. b ∈ T ⟹ j (i b) = b" assumes "⋀b. b ∈ T ⟹ i b ∈ S" assumes "⋀a. a ∈ S ⟹ h (j a) = g a" shows "g summable_on S ⟷ h summable_on T" using has_sum_reindex_bij_witness[of S i j T h g, OF assms refl] (*‹⟦⋀a. a ∈ S ⟹ a ∈ S; ⋀a. a ∈ S ⟹ a ∈ S; ⋀b. b ∈ T ⟹ b ∈ T; ⋀b. b ∈ T ⟹ b ∈ T; ⋀a. a ∈ S ⟹ a ∈ S⟧ ⟹ (g has_sum ?s) S = (h has_sum ?s) T›*) by (simp add: summable_on_def (*‹?f summable_on ?A ≡ ∃x. (?f has_sum x) ?A›*)) lemma has_sum_diff: fixes f g :: "'a ⇒ 'b::{topological_ab_group_add}" assumes ‹(f has_sum a) A› assumes ‹(g has_sum b) A› shows ‹((λx. f x - g x) has_sum (a - b)) A› using has_sum_add[of f A a "λx. -g x" "-b"] (*‹⟦(f has_sum a) A; ((λx. - g x) has_sum - b) A⟧ ⟹ ((λx. f x + - g x) has_sum a + - b) A›*) assms (*‹(f has_sum a) A› ‹(g has_sum b) A›*) by (simp add: has_sum_uminus (*‹((λx::?'a. - (?f::?'a ⇒ ?'b) x) has_sum (?a::?'b)) (?A::?'a set) = (?f has_sum - ?a) ?A›*)) lemma summable_on_diff: fixes f g :: "'a ⇒ 'b::{topological_ab_group_add}" assumes ‹f summable_on A› assumes ‹g summable_on A› shows ‹(λx. f x - g x) summable_on A› by (metis (full_types) assms (*‹(f::'a::type ⇒ 'b::topological_ab_group_add) summable_on (A::'a::type set)› ‹(g::'a::type ⇒ 'b::topological_ab_group_add) summable_on (A::'a::type set)›*) summable_on_def (*‹(?f::?'a::type ⇒ ?'b::{comm_monoid_add,topological_space}) summable_on (?A::?'a::type set) ≡ ∃x::?'b::{comm_monoid_add,topological_space}. (?f has_sum x) ?A›*) has_sum_diff (*‹⟦((?f::?'a::type ⇒ ?'b::topological_ab_group_add) has_sum (?a::?'b::topological_ab_group_add)) (?A::?'a::type set); ((?g::?'a::type ⇒ ?'b::topological_ab_group_add) has_sum (?b::?'b::topological_ab_group_add)) ?A⟧ ⟹ ((λx::?'a::type. ?f x - ?g x) has_sum ?a - ?b) ?A›*)) lemma infsum_diff: fixes f g :: "'a ⇒ 'b::{topological_ab_group_add, t2_space}" assumes ‹f summable_on A› assumes ‹g summable_on A› shows ‹infsum (λx. f x - g x) A = infsum f A - infsum g A› proof (-) (*goal: ‹(∑⇩∞x::'a::type∈(A::'a::type set). (f::'a::type ⇒ 'b::{topological_ab_group_add,t2_space}) x - (g::'a::type ⇒ 'b::{topological_ab_group_add,t2_space}) x) = infsum f A - infsum g A›*) have "((λx. f x - g x) has_sum (infsum f A - infsum g A)) A" by (simp add: assms (*‹f summable_on A› ‹g summable_on A›*) has_sum_diff (*‹⟦(?f has_sum ?a) ?A; (?g has_sum ?b) ?A⟧ ⟹ ((λx. ?f x - ?g x) has_sum ?a - ?b) ?A›*)) then show "?thesis" (*goal: ‹(∑⇩∞x∈A. f x - g x) = infsum f A - infsum g A›*) using infsumI (*‹(?f has_sum ?x) ?A ⟹ infsum ?f ?A = ?x›*) by blast qed lemma summable_norm_add: assumes "summable (λn. norm (f n))" "summable (λn. norm (g n))" shows "summable (λn. norm (f n + g n))" proof (rule summable_comparison_test (*‹⟦∃N. ∀n≥N. norm (?f n) ≤ ?g n; summable ?g⟧ ⟹ summable ?f›*)) (*goals: 1. ‹∃N. ∀n≥N. norm (norm (f n + g n)) ≤ ?g n› 2. ‹summable ?g›*) show "summable (λn. norm (f n) + norm (g n))" by (intro summable_add (*‹⟦summable ?f; summable ?g⟧ ⟹ summable (λn. ?f n + ?g n)›*) assms (*‹summable (λn. norm (f n))› ‹summable (λn. norm (g n))›*)) show "∃N. ∀n≥N. norm (norm (f n + g n)) ≤ norm (f n) + norm (g n)" apply (intro exI[of _ 0] (*‹?P 0 ⟹ ∃x. ?P x›*) allI (*‹(⋀x. ?P x) ⟹ ∀x. ?P x›*) impI (*‹(?P ⟹ ?Q) ⟹ ?P ⟶ ?Q›*)) (*goal: ‹∃N. ∀n≥N. norm (norm (f n + g n)) ≤ norm (f n) + norm (g n)›*) by (auto simp: norm_triangle_ineq (*‹norm (?x + ?y) ≤ norm ?x + norm ?y›*)) qed lemma summable_norm_diff: assumes "summable (λn. norm (f n))" "summable (λn. norm (g n))" shows "summable (λn. norm (f n - g n))" using summable_norm_add[of f "λn. -g n"] (*‹⟦summable (λn. norm (f n)); summable (λn. norm (- g n))⟧ ⟹ summable (λn. norm (f n + - g n))›*) assms (*‹summable (λn. norm (f n))› ‹summable (λn::nat. norm ((g::nat ⇒ 'a) n))›*) by simp lemma sums_imp_has_prod_exp: fixes f :: "_ ⇒'a::{real_normed_field,banach}" assumes "f sums F" shows "(λn. exp (f n)) has_prod exp F" proof (-) (*goal: ‹(λn. exp (f n)) has_prod exp F›*) have "(λn. exp (∑i≤n. f i)) ⇢ exp F" apply (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 104 facts*)) (*goal: ‹(λn. exp (sum f {..n})) ⇢ exp F›*) by (use assms in ‹auto simp: sums_def' atLeast0AtMost›) also (*calculation: ‹(λn::nat. exp (sum (f::nat ⇒ 'a) {..n})) ⇢ exp (F::'a)›*) have "(λn. exp (∑i≤n. f i)) = (λn. ∏i≤n. exp (f i))" by (simp add: exp_sum (*‹finite ?I ⟹ exp (sum ?f ?I) = (∏x∈?I. exp (?f x))›*)) finally (*calculation: ‹(λn. ∏i≤n. exp (f i)) ⇢ exp F›*) have "raw_has_prod (λn. exp (f n)) 0 (exp F)" unfolding raw_has_prod_def (*goal: ‹(λn::nat. ∏i::nat≤n. exp ((f::nat ⇒ 'a) (i + (0::nat)))) ⇢ exp (F::'a) ∧ exp F ≠ (0::'a)›*) by auto thus "?thesis" (*goal: ‹(λn. exp (f n)) has_prod exp F›*) unfolding has_prod_def (*goal: ‹raw_has_prod (λn. exp (f n)) 0 (exp F) ∨ (∃i q. exp F = 0 ∧ exp (f i) = 0 ∧ raw_has_prod (λn. exp (f n)) (Suc i) q)›*) by blast qed lemma telescope_summable_iff: fixes f :: "nat ⇒ 'a::{real_normed_vector}" shows "summable (λn. f (Suc n) - f n) ⟷ convergent f" proof (standard) (*goals: 1. ‹summable (λn. f (Suc n) - f n) ⟹ convergent f› 2. ‹convergent f ⟹ summable (λn. f (Suc n) - f n)›*) assume "convergent f" (*‹convergent (f::nat ⇒ 'a)›*) thus "summable (λn. f (Suc n) - f n)" using telescope_summable[of f] (*‹f ⇢ ?c ⟹ summable (λn. f (Suc n) - f n)›*) by (auto simp: convergent_def (*‹convergent ?X = (∃L. ?X ⇢ L)›*)) next (*goal: ‹summable (λn::nat. (f::nat ⇒ 'a) (Suc n) - f n) ⟹ convergent f›*) assume "summable (λn. f (Suc n) - f n)" (*‹summable (λn::nat. (f::nat ⇒ 'a) (Suc n) - f n)›*) hence "convergent (λn. ∑i<n. f (Suc i) - f i)" by (simp add: summable_iff_convergent (*‹summable ?f = convergent (λn. sum ?f {..<n})›*)) also (*calculation: ‹convergent (λn::nat. ∑i::nat<n. (f::nat ⇒ 'a::real_normed_vector) (Suc i) - f i)›*) have "(λn. ∑i<n. f (Suc i) - f i) = (λn. f n - f 0)" apply (subst sum_lessThan_telescope (*‹(∑n::nat<?m::nat. (?f::nat ⇒ ?'a::ab_group_add) (Suc n) - ?f n) = ?f ?m - ?f (0::nat)›*)) (*goal: ‹(λn. ∑i<n. f (Suc i) - f i) = (λn. f n - f 0)›*) by auto also (*calculation: ‹convergent (λn. f n - f 0)›*) have "convergent … ⟷ convergent f" by (rule convergent_diff_const_right_iff (*‹convergent (λn. ?f n - ?c) = convergent ?f›*)) finally (*calculation: ‹convergent (f::nat ⇒ 'a)›*) show "convergent f" . qed lemma telescope_summable_iff': fixes f :: "nat ⇒ 'a::{real_normed_vector}" shows "summable (λn. f n - f (Suc n)) ⟷ convergent f" using telescope_summable_iff[of "λn. -f n"] (*‹summable (λn. - f (Suc n) - - f n) = convergent (λn. - f n)›*) by (simp flip: convergent_minus_iff (*‹convergent ?X = convergent (λn. - ?X n)›*)) lemma norm_summable_mult_bounded: assumes "summable (λn. norm (f n))" assumes "g ∈ O(λ_. 1)" shows "summable (λn. norm (f n * g n))" proof (-) (*goal: ‹summable (λn. norm (f n * g n))›*) from assms(2) (*‹(g::nat ⇒ 'a) ∈ O(λ_::nat. 1::'a)›*) obtain C where C: "C > 0" "eventually (λn. norm (g n) ≤ C) at_top" (*goal: ‹(⋀C. ⟦0 < C; ∀⇩F n in sequentially. norm (g n) ≤ C⟧ ⟹ thesis) ⟹ thesis›*) by (auto elim!: landau_o.bigE (*‹⟦?f ∈ O[?F](?g); ⋀c. ⟦0 < c; ∀⇩F x in ?F. norm (?f x) ≤ c * norm (?g x)⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*)) show "?thesis" (*goal: ‹summable (λn. norm (f n * g n))›*) proof (rule summable_comparison_test_ev (*‹⟦∀⇩F n in sequentially. norm (?f n) ≤ ?g n; summable ?g⟧ ⟹ summable ?f›*)) (*goals: 1. ‹∀⇩F n::nat in sequentially. norm (norm ((f::nat ⇒ 'a) n * (g::nat ⇒ 'a) n)) ≤ (?g::nat ⇒ real) n› 2. ‹summable (?g::nat ⇒ real)›*) show "summable (λn. norm (f n) * C)" apply (subst mult.commute (*‹?a * ?b = ?b * ?a›*)) (*goal: ‹summable (λn. norm (f n) * C)›*) by (intro summable_mult (*‹summable ?f ⟹ summable (λn. ?c * ?f n)›*) assms (*‹summable (λn. norm (f n))› ‹g ∈ O(λ_. 1)›*)) show "eventually (λn. norm (norm (f n * g n)) ≤ norm (f n) * C) at_top" using C(2) (*‹∀⇩F n in sequentially. norm (g n) ≤ C›*) apply eventually_elim (*goal: ‹∀⇩F n::nat in sequentially. norm (norm ((f::nat ⇒ 'a) n * (g::nat ⇒ 'a) n)) ≤ norm (f n) * (C::real)›*) by (use C(1) in ‹auto intro!: mult_mono simp: norm_mult›) qed qed lemma summable_powser_comparison_test_bigo: fixes f g :: "nat ⇒ 'a :: {real_normed_field, banach}" assumes "summable f" "g ∈ O(λn. f n * c ^ n)" "norm c < 1" shows "summable (λn. norm (g n))" proof (rule summable_comparison_test_bigo (*‹⟦summable (λn::nat. norm ((?g::nat ⇒ real) n)); (?f::nat ⇒ real) ∈ O(?g)⟧ ⟹ summable ?f›*)) (*goals: 1. ‹summable (λn. norm (?g n))› 2. ‹(λn. norm (g n)) ∈ O(?g)›*) have "summable (λn. norm (f n * c ^ n))" apply (rule powser_insidea[of _ 1] (*‹⟦summable (λn::nat. (?f::nat ⇒ ?'b1) n * (1::?'b1) ^ n); norm (?z::?'b1) < norm (1::?'b1)⟧ ⟹ summable (λn::nat. norm (?f n * ?z ^ n))›*)) (*goals: 1. ‹summable (λn. f n * 1 ^ n)› 2. ‹norm c < norm 1› discuss goal 1*) apply ((use assms in auto)[1]) (*discuss goal 2*) apply ((use assms in auto)[1]) (*proven 2 subgoals*) . thus "summable (λn. norm (norm (f n * c ^ n)))" by simp show "(λn. norm (g n)) ∈ O(λn. norm (f n * c ^ n))" using assms(2) (*‹(g::nat ⇒ 'a) ∈ O(λn::nat. (f::nat ⇒ 'a) n * (c::'a) ^ n)›*) by simp qed lemma geometric_sums_gen: assumes "norm (x :: 'a :: real_normed_field) < 1" shows "(λn. x ^ (n + k)) sums (x ^ k / (1 - x))" proof (-) (*goal: ‹(λn. x ^ (n + k)) sums (x ^ k / (1 - x))›*) have "(λn. x ^ k * x ^ n) sums (x ^ k * (1 / (1 - x)))" by (intro sums_mult (*‹?f sums ?a ⟹ (λn. ?c * ?f n) sums (?c * ?a)›*) geometric_sums (*‹norm ?c < 1 ⟹ (^) ?c sums (1 / (1 - ?c))›*) assms (*‹norm x < 1›*)) thus "?thesis" (*goal: ‹(λn. x ^ (n + k)) sums (x ^ k / (1 - x))›*) by (simp add: power_add (*‹?a ^ (?m + ?n) = ?a ^ ?m * ?a ^ ?n›*) mult_ac (*‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)›*)) qed lemma has_sum_geometric: fixes x :: "'a :: {real_normed_field, banach}" assumes "norm x < 1" shows "((λn. x ^ n) has_sum (x ^ m / (1 - x))) {m..}" proof (-) (*goal: ‹((^) (x::'a) has_sum x ^ (m::nat) / ((1::'a) - x)) {m..}›*) have "((λn. x ^ n) has_sum (1 / (1 - x))) UNIV" using assms (*‹norm x < 1›*) apply (intro norm_summable_imp_has_sum (*‹⟦summable (λn. norm (?f n)); ?f sums ?S⟧ ⟹ (?f has_sum ?S) UNIV›*)) (*goals: 1. ‹norm x < 1 ⟹ summable (λn. norm (x ^ n))› 2. ‹norm x < 1 ⟹ (^) x sums (1 / (1 - x))› discuss goal 1*) apply ((auto intro: geometric_sums (*‹norm ?c < 1 ⟹ (^) ?c sums (1 / (1 - ?c))›*) summable_geometric (*‹norm ?c < 1 ⟹ summable ((^) ?c)›*) simp: norm_power (*‹norm (?x ^ ?n) = norm ?x ^ ?n›*))[1]) (*discuss goal 2*) apply ((auto intro: geometric_sums (*‹norm (?c::?'a) < (1::real) ⟹ (^) ?c sums ((1::?'a) / ((1::?'a) - ?c))›*) summable_geometric (*‹norm (?c::?'a) < (1::real) ⟹ summable ((^) ?c)›*) simp: norm_power (*‹norm ((?x::?'a) ^ (?n::nat)) = norm ?x ^ ?n›*))[1]) (*proven 2 subgoals*) . hence "((λn. x ^ m * x ^ n) has_sum (x ^ m * (1 / (1 - x)))) UNIV" by (rule has_sum_cmult_right (*‹(?f has_sum ?a) ?A ⟹ ((λx. ?c * ?f x) has_sum ?c * ?a) ?A›*)) also (*calculation: ‹((λn. x ^ m * x ^ n) has_sum x ^ m * (1 / (1 - x))) UNIV›*) have "?this ⟷ ?thesis" apply (rule has_sum_reindex_bij_witness[of _ "λn. n - m" "λn. n + m"] (*‹⟦⋀a. a ∈ ?S ⟹ a + m - m = a; ⋀a. a ∈ ?S ⟹ a + m ∈ ?T; ⋀b. b ∈ ?T ⟹ b - m + m = b; ⋀b. b ∈ ?T ⟹ b - m ∈ ?S; ⋀a. a ∈ ?S ⟹ ?h (a + m) = ?g a; ?s = ?s'⟧ ⟹ (?g has_sum ?s) ?S = (?h has_sum ?s') ?T›*)) (*goals: 1. ‹⋀a::nat. a ∈ UNIV ⟹ a + (m::nat) - m = a› 2. ‹⋀a::nat. a ∈ UNIV ⟹ a + (m::nat) ∈ {m..}› 3. ‹⋀b::nat. b ∈ {m::nat..} ⟹ b - m + m = b› 4. ‹⋀b::nat. b ∈ {m::nat..} ⟹ b - m ∈ UNIV› 5. ‹⋀a::nat. a ∈ UNIV ⟹ (x::'a::{banach,real_normed_field}) ^ (a + (m::nat)) = x ^ m * x ^ a› 6. ‹(x::'a::{banach,real_normed_field}) ^ (m::nat) * ((1::'a::{banach,real_normed_field}) / ((1::'a::{banach,real_normed_field}) - x)) = x ^ m / ((1::'a::{banach,real_normed_field}) - x)› discuss goal 1*) apply ((auto simp: power_add (*‹?a ^ (?m + ?n) = ?a ^ ?m * ?a ^ ?n›*))[1]) (*discuss goal 2*) apply ((auto simp: power_add (*‹?a ^ (?m + ?n) = ?a ^ ?m * ?a ^ ?n›*))[1]) (*discuss goal 3*) apply ((auto simp: power_add (*‹?a ^ (?m + ?n) = ?a ^ ?m * ?a ^ ?n›*))[1]) (*discuss goal 4*) apply ((auto simp: power_add (*‹?a ^ (?m + ?n) = ?a ^ ?m * ?a ^ ?n›*))[1]) (*discuss goal 5*) apply ((auto simp: power_add (*‹?a ^ (?m + ?n) = ?a ^ ?m * ?a ^ ?n›*))[1]) (*discuss goal 6*) apply ((auto simp: power_add (*‹(?a::?'a) ^ ((?m::nat) + (?n::nat)) = ?a ^ ?m * ?a ^ ?n›*))[1]) (*proven 6 subgoals*) . finally (*calculation: ‹((^) x has_sum x ^ m / (1 - x)) {m..}›*) show "?thesis" (*goal: ‹((^) x has_sum x ^ m / (1 - x)) {m..}›*) . qed lemma n_powser_sums: fixes q :: "'a :: {real_normed_field,banach}" assumes q: "norm q < 1" shows "(λn. of_nat n * q ^ n) sums (q / (1 - q) ^ 2)" proof (-) (*goal: ‹(λn. of_nat n * q ^ n) sums (q / (1 - q)²)›*) have "(λn. q * (of_nat (Suc n) * q ^ n)) sums (q * (1 / (1 - q)²))" using q (*‹norm q < 1›*) by (intro sums_mult (*‹?f sums ?a ⟹ (λn. ?c * ?f n) sums (?c * ?a)›*) geometric_deriv_sums (*‹norm ?z < 1 ⟹ (λn. of_nat (Suc n) * ?z ^ n) sums (1 / (1 - ?z)²)›*)) also (*calculation: ‹(λn::nat. (q::'a) * (of_nat (Suc n) * q ^ n)) sums (q * ((1::'a) / ((1::'a) - q)²))›*) have "(λn. q * (of_nat (Suc n) * q ^ n)) = (λn. of_nat (Suc n) * q ^ 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*)) finally (*calculation: ‹(λn. of_nat (Suc n) * q ^ Suc n) sums (q * (1 / (1 - q)²))›*) have "(λn. of_nat n * q ^ n) sums (q * (1 / (1 - q)²) + of_nat 0 * q ^ 0)" by (rule sums_Suc (*‹(λn. ?f (Suc n)) sums ?l ⟹ ?f sums (?l + ?f 0)›*)) thus "(λn. of_nat n * q ^ n) sums (q / (1 - q) ^ 2)" by simp qed subsection ‹Convergence radius› lemma tendsto_imp_conv_radius_eq: assumes "(λn. ereal (norm (f n) powr (1 / real n))) ⇢ c'" "c = inverse c'" shows "conv_radius f = c" proof (-) (*goal: ‹conv_radius (f::nat ⇒ 'a::banach) = (c::ereal)›*) have "(λn. ereal (root n (norm (f n)))) ⇢ c'" proof (rule Lim_transform_eventually (*‹⟦(?f ⤏ ?l) ?F; ∀⇩F x in ?F. ?f x = ?g x⟧ ⟹ (?g ⤏ ?l) ?F›*)) (*goals: 1. ‹?f ⇢ c'› 2. ‹∀⇩F x in sequentially. ?f x = ereal (root x (norm (f x)))›*) show "(λn. ereal (norm (f n) powr (1 / real n))) ⇢ c'" using assms (*‹(λn. ereal (norm (f n) powr (1 / real n))) ⇢ c'› ‹c = inverse c'›*) by simp show "∀⇩F x in sequentially. ereal (norm (f x) powr (1 / real x)) = ereal (root x (norm (f x)))" using eventually_gt_at_top[of 0] (*‹eventually ((<) 0) at_top›*) proof (eventually_elim) (*goal: ‹⋀x. 0 < x ⟹ ereal (norm (f x) powr (1 / real x)) = ereal (root x (norm (f x)))›*) case (elim n) (*‹(0::nat) < (n::nat)›*) show "?case" (*goal: ‹ereal (norm ((f::nat ⇒ 'a) (n::nat)) powr ((1::real) / real n)) = ereal (root n (norm (f n)))›*) using elim (*‹0 < n›*) apply (cases "f n = 0") (*goals: 1. ‹⟦0 < n; f n = 0⟧ ⟹ ereal (norm (f n) powr (1 / real n)) = ereal (root n (norm (f n)))› 2. ‹⟦0 < n; f n ≠ 0⟧ ⟹ ereal (norm (f n) powr (1 / real n)) = ereal (root n (norm (f n)))› discuss goal 1*) apply (simp add: root_powr_inverse (*‹⟦0 < ?n; 0 < ?x⟧ ⟹ root ?n ?x = ?x powr (1 / real ?n)›*)) (*discuss goal 2*) apply (simp add: root_powr_inverse (*‹⟦0 < ?n; 0 < ?x⟧ ⟹ root ?n ?x = ?x powr (1 / real ?n)›*)) (*proven 2 subgoals*) . qed qed thus "?thesis" (*goal: ‹conv_radius (f::nat ⇒ 'a) = (c::ereal)›*) unfolding conv_radius_def (*goal: ‹inverse (limsup (λn. ereal (root n (norm (f n))))) = c›*) using assms (*‹(λn. ereal (norm (f n) powr (1 / real n))) ⇢ c'› ‹c = inverse c'›*) by (simp add: limsup_root_limit (*‹(λn::nat. ereal (root n (norm ((?f::nat ⇒ ?'a) n)))) ⇢ (?l::ereal) ⟹ limsup (λn::nat. ereal (root n (norm (?f n)))) = ?l›*)) qed lemma conv_radius_powr_real: "conv_radius (λn. real n powr a) = 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 (real n powr a) powr (1 / real n))) ⇢ ?c'› 2. ‹1 = inverse ?c'›*) have "(λn. ereal ((real n powr a) 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) powr (1 / real n))) ⇢ ereal 1›*) by real_asymp thus "(λn. ereal (norm (real n powr a) powr (1 / real n))) ⇢ ereal 1" by simp qed (simp_all add: one_ereal_def) (*solved the remaining goal: ‹1 = inverse (ereal 1)›*) lemma conv_radius_one_over: "conv_radius (λn. 1 / of_nat n :: 'a :: {real_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 (1 / of_nat n) powr (1 / real n))) ⇢ ?c'› 2. ‹1 = inverse ?c'›*) have "(λn. ereal ((1 / n) powr (1 / real n))) ⇢ ereal 1" apply (rule tendsto_ereal (*‹(?f ⤏ ?x) ?F ⟹ ((λx. ereal (?f x)) ⤏ ereal ?x) ?F›*)) (*goal: ‹(λn. ereal ((1 / real n) powr (1 / real n))) ⇢ ereal 1›*) by real_asymp thus "(λn. ereal (norm (1 / of_nat n :: 'a) powr (1 / real n))) ⇢ ereal 1" by (simp add: norm_divide (*‹norm (?a / ?b) = norm ?a / norm ?b›*)) qed (simp_all add: one_ereal_def) (*solved the remaining goal: ‹1 = inverse (ereal 1)›*) lemma conv_radius_mono: assumes "eventually (λn. norm (f n) ≥ norm (g n)) sequentially" shows "conv_radius f ≤ conv_radius g" unfolding conv_radius_def (*goal: ‹inverse (limsup (λn. ereal (root n (norm (f n))))) ≤ inverse (limsup (λn. ereal (root n (norm (g n)))))›*) proof (rule ereal_inverse_antimono[OF _ Limsup_mono] (*‹⟦0 ≤ Limsup ?F1 ?f1; ∀⇩F x in ?F1. ?f1 x ≤ ?g1 x⟧ ⟹ inverse (Limsup ?F1 ?g1) ≤ inverse (Limsup ?F1 ?f1)›*)) (*goals: 1. ‹0 ≤ limsup (λn. ereal (root n (norm (g n))))› 2. ‹∀⇩F x in sequentially. ereal (root x (norm (g x))) ≤ ereal (root x (norm (f x)))›*) have "limsup (λn. 0) ≤ limsup (λn. ereal (root n (norm (g n))))" apply (rule Limsup_mono (*‹∀⇩F x in ?F. ?f x ≤ ?g x ⟹ Limsup ?F ?f ≤ Limsup ?F ?g›*)) (*goal: ‹limsup (λn. 0) ≤ limsup (λn. ereal (root n (norm (g n))))›*) by (auto intro!: eventually_mono[OF eventually_gt_at_top[of 0]] (*‹(⋀x. 0 < x ⟹ ?Q x) ⟹ eventually ?Q at_top›*)) thus "limsup (λn. ereal (root n (norm (g n)))) ≥ 0" by (simp add: Limsup_const (*‹(?F::?'a filter) ≠ bot ⟹ Limsup ?F (λx::?'a. ?c::?'b) = ?c›*)) next (*goal: ‹∀⇩F x::nat in sequentially. ereal (root x (norm ((g::nat ⇒ 'a::banach) x))) ≤ ereal (root x (norm ((f::nat ⇒ 'b::banach) x)))›*) show "∀⇩F x in sequentially. ereal (root x (norm (g x))) ≤ ereal (root x (norm (f x)))" using assms (*‹∀⇩F n in sequentially. norm (g n) ≤ norm (f n)›*) eventually_gt_at_top[of 0] (*‹eventually ((<) (0::?'c1::{zero,linorder,no_top})) at_top›*) apply eventually_elim (*goal: ‹∀⇩F x in sequentially. ereal (root x (norm (g x))) ≤ ereal (root x (norm (f x)))›*) by auto qed lemma conv_radius_const [simp]: assumes "c ≠ 0" shows "conv_radius (λ_. c) = 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::nat. ereal (norm (c::'a::banach) powr ((1::real) / real n))) ⇢ (?c'::ereal)› 2. ‹(1::ereal) = inverse (?c'::ereal)›*) show "(λn. ereal (norm c powr (1 / real n))) ⇢ ereal 1" apply (rule tendsto_ereal (*‹(?f ⤏ ?x) ?F ⟹ ((λx. ereal (?f x)) ⤏ ereal ?x) ?F›*)) (*goal: ‹(λn. ereal (norm c powr (1 / real n))) ⇢ ereal 1›*) by (use assms in real_asymp) qed (auto) (*solved the remaining goal: ‹1 = inverse (ereal 1)›*) lemma conv_radius_bigo_polynomial: assumes "f ∈ O(λn. of_nat n ^ k)" shows "conv_radius f ≥ 1" proof (-) (*goal: ‹1 ≤ conv_radius f›*) from assms (*‹f ∈ O(λn. of_nat n ^ k)›*) obtain C where ev: "C > 0" "eventually (λn. norm (f n) ≤ C * real n ^ k) at_top" (*goal: ‹(⋀C. ⟦0 < C; ∀⇩F n in sequentially. norm (f n) ≤ C * real n ^ k⟧ ⟹ thesis) ⟹ thesis›*) apply (elim landau_o.bigE (*‹⟦?f ∈ O[?F](?g); ⋀c. ⟦0 < c; ∀⇩F x in ?F. norm (?f x) ≤ c * norm (?g x)⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*)) (*goal: ‹(⋀C. ⟦0 < C; ∀⇩F n in sequentially. norm (f n) ≤ C * real n ^ k⟧ ⟹ thesis) ⟹ thesis›*) by (auto simp: norm_power (*‹norm ((?x::?'a::real_normed_div_algebra) ^ (?n::nat)) = norm ?x ^ ?n›*)) have "(λx. (C * real x ^ k) powr (1 / real x)) ⇢ 1" using ev(1) (*‹0 < C›*) by real_asymp hence "conv_radius (λn. C * real n ^ k) = inverse (ereal 1)" using ev(1) (*‹0 < C›*) apply (intro tendsto_imp_conv_radius_eq[OF _ refl] (*‹(λn. ereal (norm (?f n) powr (1 / real n))) ⇢ ?c' ⟹ conv_radius ?f = inverse ?c'›*) tendsto_ereal (*‹(?f ⤏ ?x) ?F ⟹ ((λx. ereal (?f x)) ⤏ ereal ?x) ?F›*)) (*goal: ‹conv_radius (λn::nat. (C::real) * real n ^ (k::nat)) = inverse (ereal (1::real))›*) by (simp add: norm_mult (*‹norm ((?x::?'a) * (?y::?'a)) = norm ?x * norm ?y›*) norm_power (*‹norm ((?x::?'a) ^ (?n::nat)) = norm ?x ^ ?n›*) abs_mult (*‹¦(?a::?'a) * (?b::?'a)¦ = ¦?a¦ * ¦?b¦›*)) moreover have "conv_radius (λn. C * real n ^ k) ≤ conv_radius f" apply (intro conv_radius_mono (*‹∀⇩F n in sequentially. norm (?g n) ≤ norm (?f n) ⟹ conv_radius ?f ≤ conv_radius ?g›*) eventually_mono[OF ev(2)] (*‹(⋀x. norm (f x) ≤ C * real x ^ k ⟹ ?Q x) ⟹ eventually ?Q sequentially›*)) (*goal: ‹conv_radius (λn::nat. (C::real) * real n ^ (k::nat)) ≤ conv_radius (f::nat ⇒ 'a)›*) by auto ultimately show "?thesis" (*goal: ‹1 ≤ conv_radius f›*) by (simp add: one_ereal_def (*‹(1::ereal) = ereal (1::real)›*)) qed subsection ‹Limits› lemma oscillation_imp_not_tendsto: assumes "eventually (λn. f (g n) ∈ A) sequentially" "filterlim g F sequentially" assumes "eventually (λn. f (h n) ∈ B) sequentially" "filterlim h F sequentially" assumes "closed A" "closed B" "A ∩ B = {}" shows "¬filterlim f (nhds c) F" proof (standard) (*goal: ‹(f ⤏ c) F ⟹ False›*) assume "*": "filterlim f (nhds c) F" (*‹((f::'b ⇒ 'a) ⤏ (c::'a)) (F::'b filter)›*) have "filterlim (λn. f (g n)) (nhds c) sequentially" using "*" (*‹(f ⤏ c) F›*) assms(2) (*‹filterlim g F sequentially›*) by (rule filterlim_compose (*‹⟦filterlim ?g ?F3.0 ?F2.0; filterlim ?f ?F2.0 ?F1.0⟧ ⟹ LIM x ?F1.0. ?g (?f x) :> ?F3.0›*)) with assms(1,5) (*‹∀⇩F n in sequentially. f (g n) ∈ A› ‹closed A›*) have "c ∈ A" by (metis Lim_in_closed_set (*‹⟦closed ?S; ∀⇩F x in ?F. ?f x ∈ ?S; ?F ≠ bot; (?f ⤏ ?l) ?F⟧ ⟹ ?l ∈ ?S›*) sequentially_bot (*‹sequentially ≠ bot›*)) have "filterlim (λn. f (h n)) (nhds c) sequentially" using "*" (*‹(f ⤏ c) F›*) assms(4) (*‹filterlim h F sequentially›*) by (rule filterlim_compose (*‹⟦filterlim ?g ?F3.0 ?F2.0; filterlim ?f ?F2.0 ?F1.0⟧ ⟹ LIM x ?F1.0. ?g (?f x) :> ?F3.0›*)) with assms(3,6) (*‹∀⇩F n in sequentially. f (h n) ∈ B› ‹closed (B::'a::topological_space set)›*) have "c ∈ B" by (metis Lim_in_closed_set (*‹⟦closed ?S; ∀⇩F x in ?F. ?f x ∈ ?S; ?F ≠ bot; (?f ⤏ ?l) ?F⟧ ⟹ ?l ∈ ?S›*) sequentially_bot (*‹sequentially ≠ bot›*)) with ‹c ∈ A› (*‹c ∈ A›*) ‹A ∩ B = {}› (*‹A ∩ B = {}›*) show False by blast qed lemma oscillation_imp_not_convergent: assumes "frequently (λn. f n ∈ A) sequentially" assumes "frequently (λn. f n ∈ B) sequentially" assumes "closed A" "closed B" "A ∩ B = {}" shows "¬convergent f" proof (-) (*goal: ‹¬ convergent f›*) obtain g :: "nat ⇒ nat" where g: "strict_mono g" "⋀n. f (g n) ∈ A" (*goal: ‹(⋀g::nat ⇒ nat. ⟦strict_mono g; ⋀n::nat. (f::nat ⇒ 'a) (g n) ∈ (A::'a set)⟧ ⟹ thesis::bool) ⟹ thesis›*) using assms(1) (*‹∃⇩F n::nat in sequentially. (f::nat ⇒ 'a) n ∈ (A::'a set)›*) infinite_enumerate (*‹infinite ?S ⟹ ∃r. strict_mono r ∧ (∀n. r n ∈ ?S)›*) unfolding cofinite_eq_sequentially[symmetric] INFM_iff_infinite (*goal: ‹(⋀g. ⟦strict_mono g; ⋀n. f (g n) ∈ A⟧ ⟹ thesis) ⟹ thesis›*) by blast obtain h :: "nat ⇒ nat" where h: "strict_mono h" "⋀n. f (h n) ∈ B" (*goal: ‹(⋀h. ⟦strict_mono h; ⋀n. f (h n) ∈ B⟧ ⟹ thesis) ⟹ thesis›*) using assms(2) (*‹∃⇩F n in sequentially. f n ∈ B›*) infinite_enumerate (*‹infinite ?S ⟹ ∃r. strict_mono r ∧ (∀n. r n ∈ ?S)›*) unfolding cofinite_eq_sequentially[symmetric] INFM_iff_infinite (*goal: ‹(⋀h. ⟦strict_mono h; ⋀n. f (h n) ∈ B⟧ ⟹ thesis) ⟹ thesis›*) by blast have "¬f ⇢ L" for L 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. (f::nat ⇒ 'a) ((?g::nat ⇒ nat) n) ∈ (?A::'a set)› 2. ‹filterlim (?g::nat ⇒ nat) sequentially sequentially› 3. ‹∀⇩F n::nat in sequentially. (f::nat ⇒ 'a) ((?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 "∀⇩F n in sequentially. f (g n) ∈ A" "∀⇩F n in sequentially. f (h n) ∈ B" using g (*‹strict_mono g› ‹f (g ?n) ∈ A›*) h (*‹strict_mono h› ‹(f::nat ⇒ 'a) ((h::nat ⇒ nat) (?n::nat)) ∈ (B::'a set)›*) apply - (*goals: 1. ‹⟦strict_mono g; ⋀n. f (g n) ∈ A; strict_mono h; ⋀n. f (h n) ∈ B⟧ ⟹ ∀⇩F n in sequentially. f (g n) ∈ A› 2. ‹⟦strict_mono g; ⋀n. f (g n) ∈ A; strict_mono h; ⋀n. f (h n) ∈ B⟧ ⟹ ∀⇩F n in sequentially. f (h n) ∈ B› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . qed (use g h assms in ‹auto intro: filterlim_subseq›) (*solves the remaining goals: 1. ‹filterlim g sequentially sequentially› 2. ‹filterlim h sequentially sequentially› 3. ‹closed A› 4. ‹closed B› 5. ‹A ∩ B = {}›*) thus "?thesis" (*goal: ‹¬ convergent f›*) unfolding convergent_def (*goal: ‹∄L. f ⇢ L›*) by blast qed lemma seq_bigo_1_iff: "g ∈ O(λ_::nat. 1) ⟷ bounded (range g)" proof (standard) (*goals: 1. ‹g ∈ O(λ_. 1) ⟹ bounded (range g)› 2. ‹bounded (range g) ⟹ g ∈ O(λ_. 1)›*) assume "g ∈ O(λ_. 1)" (*‹(g::nat ⇒ 'a) ∈ O(λ_::nat. 1::'a)›*) then obtain C where "eventually (λn. norm (g n) ≤ C) at_top" (*goal: ‹(⋀C::real. ∀⇩F n::nat in sequentially. norm ((g::nat ⇒ 'a) n) ≤ C ⟹ thesis::bool) ⟹ thesis›*) apply (elim landau_o.bigE (*‹⟦?f ∈ O[?F](?g); ⋀c. ⟦0 < c; ∀⇩F x in ?F. norm (?f x) ≤ c * norm (?g x)⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*)) (*goal: ‹(⋀C. ∀⇩F n in sequentially. norm (g n) ≤ C ⟹ thesis) ⟹ thesis›*) by auto then obtain N where N: "⋀n. n ≥ N ⟹ norm (g n) ≤ C" (*goal: ‹(⋀N. (⋀n. N ≤ n ⟹ norm (g n) ≤ C) ⟹ thesis) ⟹ thesis›*) by (auto simp: eventually_at_top_linorder (*‹eventually ?P at_top = (∃N. ∀n≥N. ?P n)›*)) hence "norm (g n) ≤ Max (insert C (norm ` g ` {..<N}))" for n apply (cases "n < N") (*goals: 1. ‹⟦⋀n. N ≤ n ⟹ norm (g n) ≤ C; n < N⟧ ⟹ norm (g n) ≤ Max (insert C (norm ` g ` {..<N}))› 2. ‹⟦⋀n. N ≤ n ⟹ norm (g n) ≤ C; ¬ n < N⟧ ⟹ norm (g n) ≤ Max (insert C (norm ` g ` {..<N}))› discuss goal 1*) apply ((auto simp: Max_ge_iff (*‹⟦finite (?A::?'a set); ?A ≠ {}⟧ ⟹ ((?x::?'a) ≤ Max ?A) = (∃a::?'a∈?A. ?x ≤ a)›*))[1]) (*discuss goal 2*) apply ((auto simp: Max_ge_iff (*‹⟦finite (?A::?'a set); ?A ≠ {}⟧ ⟹ ((?x::?'a) ≤ Max ?A) = (∃a::?'a∈?A. ?x ≤ a)›*))[1]) (*proven 2 subgoals*) . thus "bounded (range g)" by (auto simp: bounded_iff (*‹bounded ?S = (∃a. ∀x∈?S. norm x ≤ a)›*)) next (*goal: ‹bounded (range (g::nat ⇒ 'a)) ⟹ g ∈ O(λ_::nat. 1::'a)›*) assume "bounded (range g)" (*‹bounded (range (g::nat ⇒ 'a))›*) then obtain C where "norm (g n) ≤ C" for n (*goal: ‹(⋀C. (⋀n. norm (g n) ≤ C) ⟹ thesis) ⟹ thesis›*) by (auto simp: bounded_iff (*‹bounded ?S = (∃a. ∀x∈?S. norm x ≤ a)›*)) thus "g ∈ O(λ_. 1)" apply (intro bigoI[where c = C] (*‹∀⇩F x in ?F. norm (?f x) ≤ C * norm (?g x) ⟹ ?f ∈ O[?F](?g)›*)) (*goal: ‹g ∈ O(λ_. 1)›*) by auto qed lemma incseq_convergent': assumes "incseq (g :: nat ⇒ real)" "g ∈ O(λ_. 1)" shows "convergent g" proof (-) (*goal: ‹convergent g›*) from assms(2) (*‹g ∈ O(λ_. 1)›*) have "bounded (range g)" by (simp add: seq_bigo_1_iff (*‹((?g::nat ⇒ ?'a) ∈ O(λ_::nat. 1::?'a)) = bounded (range ?g)›*)) then obtain C where C: "¦g n¦ ≤ C" for n (*goal: ‹(⋀C. (⋀n. ¦g n¦ ≤ C) ⟹ thesis) ⟹ thesis›*) unfolding bounded_iff (*goal: ‹(⋀C. (⋀n. ¦g n¦ ≤ C) ⟹ thesis) ⟹ thesis›*) by auto show "?thesis" (*goal: ‹convergent g›*) proof (rule incseq_convergent (*‹⟦incseq ?X; ∀i. ?X i ≤ ?B; ⋀L. ⟦?X ⇢ L; ∀i. ?X i ≤ L⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*)) (*goals: 1. ‹incseq (?X::nat ⇒ real)› 2. ‹∀i::nat. (?X::nat ⇒ real) i ≤ (?B::real)› 3. ‹⋀L::real. ⟦(?X::nat ⇒ real) ⇢ L; ∀i::nat. ?X i ≤ L⟧ ⟹ convergent (g::nat ⇒ real)›*) show "incseq g" by fact next (*goals: 1. ‹∀i. g i ≤ ?B› 2. ‹⋀L. ⟦g ⇢ L; ∀i. g i ≤ L⟧ ⟹ convergent g›*) have "g i ≤ C" for i :: nat using C[of i] (*‹¦(g::nat ⇒ real) (i::nat)¦ ≤ (C::real)›*) by auto thus "∀i. g i ≤ C" by blast qed (auto simp: convergent_def (*‹convergent ?X = (∃L. ?X ⇢ L)›*)) (*solved the remaining goal: ‹⋀L. ⟦g ⇢ L; ∀i. g i ≤ L⟧ ⟹ convergent g›*) qed lemma decseq_convergent': assumes "decseq (g :: nat ⇒ real)" "g ∈ O(λ_. 1)" shows "convergent g" using incseq_convergent'[of "λn. -g n "] (*‹⟦incseq (λn. - g n); (λn. - g n) ∈ O(λ_. 1)⟧ ⟹ convergent (λn. - g n)›*) assms (*‹decseq (g::nat ⇒ real)› ‹g ∈ O(λ_. 1)›*) by (simp flip: convergent_minus_iff (*‹convergent ?X = convergent (λn. - ?X n)›*) add: decseq_eq_incseq (*‹decseq ?X = incseq (λn. - ?X n)›*)) lemma filterlim_of_int_iff: fixes c :: "'a :: real_normed_algebra_1" assumes "F ≠ bot" shows "filterlim (λx. of_int (f x)) (nhds c) F ⟷ (∃c'. c = of_int c' ∧ eventually (λx. f x = c') F)" proof (standard) (*goals: 1. ‹((λx. of_int (f x)) ⤏ c) F ⟹ ∃c'. c = of_int c' ∧ (∀⇩F x in F. f x = c')› 2. ‹∃c'. c = of_int c' ∧ (∀⇩F x in F. f x = c') ⟹ ((λx. of_int (f x)) ⤏ c) F›*) assume "∃c'. c = of_int c' ∧ eventually (λx. f x = c') F" (*‹∃c'::int. (c::'a) = of_int c' ∧ (∀⇩F x::'b in F::'b filter. (f::'b ⇒ int) x = c')›*) then obtain c' where c': "c = of_int c'" "eventually (λx. f x = c') F" (*goal: ‹(⋀c'. ⟦c = of_int c'; ∀⇩F x in F. f x = c'⟧ ⟹ thesis) ⟹ thesis›*) by blast from c'(2) (*‹∀⇩F x in F. f x = c'›*) have "eventually (λx. of_int (f x) = c) F" apply eventually_elim (*goal: ‹∀⇩F x::'b::type in F::'b::type filter. of_int ((f::'b::type ⇒ int) x) = (c::'a::real_normed_algebra_1)›*) by (auto simp: c'( (*‹c = of_int c'›*) 1)) thus "filterlim (λx. of_int (f x)) (nhds c) F" by (rule tendsto_eventually (*‹∀⇩F x in ?net. ?f x = ?l ⟹ (?f ⤏ ?l) ?net›*)) next (*goal: ‹((λx::'b. of_int ((f::'b ⇒ int) x)) ⤏ (c::'a)) (F::'b filter) ⟹ ∃c'::int. c = of_int c' ∧ (∀⇩F x::'b in F. f x = c')›*) assume "*": "filterlim (λx. of_int (f x)) (nhds c) F" (*‹((λx::'b. of_int ((f::'b ⇒ int) x)) ⤏ (c::'a)) (F::'b filter)›*) show "(∃c'. c = of_int c' ∧ eventually (λx. f x = c') F)" proof (cases "c ∈ ℤ") (*goals: 1. ‹(c::'a) ∈ ℤ ⟹ ∃c'::int. c = of_int c' ∧ (∀⇩F x::'b in F::'b filter. (f::'b ⇒ int) x = c')› 2. ‹(c::'a) ∉ ℤ ⟹ ∃c'::int. c = of_int c' ∧ (∀⇩F x::'b in F::'b filter. (f::'b ⇒ int) x = c')›*) case False (*‹c ∉ ℤ›*) hence "setdist {c} ℤ > 0" apply (subst setdist_gt_0_compact_closed (*‹⟦compact ?S; closed ?T⟧ ⟹ (0 < setdist ?S ?T) = (?S ≠ {} ∧ ?T ≠ {} ∧ ?S ∩ ?T = {})›*)) (*goals: 1. ‹(c::'a) ∉ ℤ ⟹ compact {c}› 2. ‹(c::'a) ∉ ℤ ⟹ closed ℤ› 3. ‹(c::'a) ∉ ℤ ⟹ {c} ≠ {} ∧ ℤ ≠ {} ∧ {c} ∩ ℤ = {}› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*proven 3 subgoals*) . with "*" (*‹((λx. of_int (f x)) ⤏ c) F›*) have "eventually (λx. dist (of_int (f x)) c < setdist {c} ℤ) F" unfolding tendsto_iff (*goal: ‹∀⇩F x in F. dist (of_int (f x)) c < setdist {c} ℤ›*) by blast then obtain x where "dist (of_int (f x)) c < setdist {c} ℤ" (*goal: ‹(⋀x. dist (of_int (f x)) c < setdist {c} ℤ ⟹ thesis) ⟹ thesis›*) using ‹F ≠ bot› (*‹F ≠ bot›*) eventually_happens (*‹eventually ?P ?net ⟹ ?net = bot ∨ (∃x. ?P x)›*) by blast moreover have "dist c (of_int (f x)) ≥ setdist {c} ℤ" apply (rule setdist_le_dist (*‹⟦?x ∈ ?s; ?y ∈ ?t⟧ ⟹ setdist ?s ?t ≤ dist ?x ?y›*)) (*goals: 1. ‹c ∈ {c}› 2. ‹of_int (f x) ∈ ℤ› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . ultimately show "?thesis" (*goal: ‹∃c'. c = of_int c' ∧ (∀⇩F x in F. f x = c')›*) by (simp add: dist_commute (*‹dist ?x ?y = dist ?y ?x›*)) next (*goal: ‹c ∈ ℤ ⟹ ∃c'. c = of_int c' ∧ (∀⇩F x in F. f x = c')›*) case True (*‹(c::'a::real_normed_algebra_1) ∈ ℤ›*) then obtain c' where c: "c = of_int c'" (*goal: ‹(⋀c'. c = of_int c' ⟹ thesis) ⟹ thesis›*) by (elim Ints_cases (*‹⟦?q ∈ ℤ; ⋀z. ?q = of_int z ⟹ ?thesis⟧ ⟹ ?thesis›*)) have "eventually (λx. dist (of_int (f x)) c < 1) F" using "*" (*‹((λx. of_int (f x)) ⤏ c) F›*) unfolding tendsto_iff (*goal: ‹∀⇩F x::'b in F::'b filter. dist (of_int ((f::'b ⇒ int) x)) (c::'a) < (1::real)›*) by auto hence "eventually (λx. f x = c') F" apply eventually_elim (*goal: ‹∀⇩F x in F. f x = c'›*) by (auto simp: c (*‹c = of_int c'›*) dist_of_int (*‹dist (of_int ?m) (of_int ?n) = real_of_int ¦?m - ?n¦›*)) with c (*‹c = of_int c'›*) show "?thesis" (*goal: ‹∃c'. c = of_int c' ∧ (∀⇩F x in F. f x = c')›*) by auto qed qed lemma filterlim_of_nat_iff: fixes c :: "'a :: real_normed_algebra_1" assumes "F ≠ bot" shows "filterlim (λx. of_nat (f x)) (nhds c) F ⟷ (∃c'. c = of_nat c' ∧ eventually (λx. f x = c') F)" proof (standard) (*goals: 1. ‹((λx. of_nat (f x)) ⤏ c) F ⟹ ∃c'. c = of_nat c' ∧ (∀⇩F x in F. f x = c')› 2. ‹∃c'. c = of_nat c' ∧ (∀⇩F x in F. f x = c') ⟹ ((λx. of_nat (f x)) ⤏ c) F›*) assume "∃c'. c = of_nat c' ∧ eventually (λx. f x = c') F" (*‹∃c'::nat. (c::'a) = of_nat c' ∧ (∀⇩F x::'b in F::'b filter. (f::'b ⇒ nat) x = c')›*) then obtain c' where c': "c = of_nat c'" "eventually (λx. f x = c') F" (*goal: ‹(⋀c'. ⟦c = of_nat c'; ∀⇩F x in F. f x = c'⟧ ⟹ thesis) ⟹ thesis›*) by blast from c'(2) (*‹∀⇩F x in F. f x = c'›*) have "eventually (λx. of_nat (f x) = c) F" apply eventually_elim (*goal: ‹∀⇩F x::'b in F::'b filter. of_nat ((f::'b ⇒ nat) x) = (c::'a)›*) by (auto simp: c'( (*‹c = of_nat c'›*) 1)) thus "filterlim (λx. of_nat (f x)) (nhds c) F" by (rule tendsto_eventually (*‹∀⇩F x::?'b in ?net::?'b filter. (?f::?'b ⇒ ?'a) x = (?l::?'a) ⟹ (?f ⤏ ?l) ?net›*)) next (*goal: ‹((λx. of_nat (f x)) ⤏ c) F ⟹ ∃c'. c = of_nat c' ∧ (∀⇩F x in F. f x = c')›*) assume "*": "filterlim (λx. of_nat (f x)) (nhds c) F" (*‹((λx::'b. of_nat ((f::'b ⇒ nat) x)) ⤏ (c::'a)) (F::'b filter)›*) show "(∃c'. c = of_nat c' ∧ eventually (λx. f x = c') F)" proof (cases "c ∈ ℕ") (*goals: 1. ‹(c::'a) ∈ ℕ ⟹ ∃c'::nat. c = of_nat c' ∧ (∀⇩F x::'b in F::'b filter. (f::'b ⇒ nat) x = c')› 2. ‹(c::'a) ∉ ℕ ⟹ ∃c'::nat. c = of_nat c' ∧ (∀⇩F x::'b in F::'b filter. (f::'b ⇒ nat) x = c')›*) case False (*‹c ∉ ℕ›*) hence "setdist {c} ℕ > 0" apply (subst setdist_gt_0_compact_closed (*‹⟦compact ?S; closed ?T⟧ ⟹ (0 < setdist ?S ?T) = (?S ≠ {} ∧ ?T ≠ {} ∧ ?S ∩ ?T = {})›*)) (*goals: 1. ‹(c::'a) ∉ ℕ ⟹ compact {c}› 2. ‹(c::'a) ∉ ℕ ⟹ closed ℕ› 3. ‹(c::'a) ∉ ℕ ⟹ {c} ≠ {} ∧ ℕ ≠ {} ∧ {c} ∩ ℕ = {}› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*proven 3 subgoals*) . with "*" (*‹((λx. of_nat (f x)) ⤏ c) F›*) have "eventually (λx. dist (of_nat (f x)) c < setdist {c} ℕ) F" unfolding tendsto_iff (*goal: ‹∀⇩F x in F. dist (of_nat (f x)) c < setdist {c} ℕ›*) by blast then obtain x where "dist (of_nat (f x)) c < setdist {c} ℕ" (*goal: ‹(⋀x. dist (of_nat (f x)) c < setdist {c} ℕ ⟹ thesis) ⟹ thesis›*) using ‹F ≠ bot› (*‹F ≠ bot›*) eventually_happens (*‹eventually ?P ?net ⟹ ?net = bot ∨ (∃x. ?P x)›*) by blast moreover have "dist c (of_nat (f x)) ≥ setdist {c} ℕ" apply (rule setdist_le_dist (*‹⟦(?x::?'a::metric_space) ∈ (?s::?'a::metric_space set); (?y::?'a::metric_space) ∈ (?t::?'a::metric_space set)⟧ ⟹ setdist ?s ?t ≤ dist ?x ?y›*)) (*goals: 1. ‹c ∈ {c}› 2. ‹of_nat (f x) ∈ ℕ› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . ultimately show "?thesis" (*goal: ‹∃c'::nat. (c::'a) = of_nat c' ∧ (∀⇩F x::'b in F::'b filter. (f::'b ⇒ nat) x = c')›*) by (simp add: dist_commute (*‹dist ?x ?y = dist ?y ?x›*)) next (*goal: ‹c ∈ ℕ ⟹ ∃c'. c = of_nat c' ∧ (∀⇩F x in F. f x = c')›*) case True (*‹c ∈ ℕ›*) then obtain c' where c: "c = of_nat c'" (*goal: ‹(⋀c'. c = of_nat c' ⟹ thesis) ⟹ thesis›*) by (elim Nats_cases (*‹⟦(?x::?'a) ∈ ℕ; ⋀n::nat. ?x = of_nat n ⟹ ?thesis::bool⟧ ⟹ ?thesis›*)) have "eventually (λx. dist (of_nat (f x)) c < 1) F" using "*" (*‹((λx. of_nat (f x)) ⤏ c) F›*) unfolding tendsto_iff (*goal: ‹∀⇩F x in F. dist (of_nat (f x)) c < 1›*) by auto hence "eventually (λx. f x = c') F" apply eventually_elim (*goal: ‹∀⇩F x in F. f x = c'›*) by (auto simp: c (*‹(c::'a) = of_nat (c'::nat)›*) dist_of_nat (*‹dist (of_nat (?m::nat)) (of_nat (?n::nat)) = real_of_int ¦int ?m - int ?n¦›*)) with c (*‹(c::'a) = of_nat (c'::nat)›*) show "?thesis" (*goal: ‹∃c'. c = of_nat c' ∧ (∀⇩F x in F. f x = c')›*) by auto qed qed lemma uniform_limit_compose: assumes "uniform_limit B (λx y. f x y) (λy. f' y) F" "⋀y. y ∈ A ⟹ g y ∈ B" shows "uniform_limit A (λx y. f x (g y)) (λy. f' (g y)) F" proof (-) (*goal: ‹uniform_limit A (λx y. f x (g y)) (λy. f' (g y)) F›*) have "uniform_limit (g ` A) (λx y. f x y) (λy. f' y) F" using assms(1) (*‹uniform_limit B f f' F›*) apply (rule uniform_limit_on_subset (*‹⟦uniform_limit ?J ?f ?g ?F; ?I ⊆ ?J⟧ ⟹ uniform_limit ?I ?f ?g ?F›*)) (*goal: ‹uniform_limit (g ` A) f f' F›*) by (use assms(2) in blast) thus "uniform_limit A (λx y. f x (g y)) (λy. f' (g y)) F" unfolding uniform_limit_iff (*goal: ‹∀e>0. ∀⇩F n in F. ∀x∈A. dist (f n (g x)) (f' (g x)) < e›*) by auto qed lemma uniform_limit_const': assumes "filterlim f (nhds c) F" shows "uniform_limit A (λx y. f x) (λy. c) F" proof (-) (*goal: ‹uniform_limit (A::'c set) (λ(x::'a) y::'c. (f::'a ⇒ 'b) x) (λy::'c. c::'b) (F::'a filter)›*) have "∀⇩F n in F. ∀x∈A. dist (f n) c < ε" if "ε": "ε > 0" for ε :: real proof (-) (*goal: ‹∀⇩F n in F. ∀x∈A. dist (f n) c < ε›*) from assms (*‹((f::'a::type ⇒ 'b::metric_space) ⤏ (c::'b::metric_space)) (F::'a::type filter)›*) "ε" (*‹0 < ε›*) have "∀⇩F n in F. dist (f n) c < ε" unfolding tendsto_iff (*goal: ‹∀⇩F n in F. dist (f n) c < ε›*) by blast thus "?thesis" (*goal: ‹∀⇩F n in F. ∀x∈A. dist (f n) c < ε›*) apply eventually_elim (*goal: ‹∀⇩F n in F. ∀x∈A. dist (f n) c < ε›*) by auto qed thus "?thesis" (*goal: ‹uniform_limit A (λx y. f x) (λy. c) F›*) unfolding uniform_limit_iff (*goal: ‹∀e>0::real. ∀⇩F n::'a in F::'a filter. ∀x::'c∈A::'c set. dist ((f::'a ⇒ 'b) n) (c::'b) < e›*) by blast qed lemma uniform_limit_singleton_iff [simp]: "uniform_limit {x} f g F ⟷ filterlim (λy. f y x) (nhds (g x)) F" by (simp add: uniform_limit_iff (*‹uniform_limit ?S ?f ?l ?F = (∀e>0. ∀⇩F n in ?F. ∀x∈?S. dist (?f n x) (?l x) < e)›*) tendsto_iff (*‹(?f ⤏ ?l) ?F = (∀e>0. ∀⇩F x in ?F. dist (?f x) ?l < e)›*)) end
{ "path": "afp-2025-02-12/thys/Lambert_Series/Lambert_Series_Library.thy", "repo": "afp-2025-02-12", "sha": "97ab03ec76d6650ed43454f9a26c087d53e4121369509302a59ecc5a69a2c464" }
theory Construction_Utility imports Fused_Resource State_Isomorphism begin ― ‹Dummy converters that return a constant value on their external interface› primcorec ldummy_converter :: "('a ⇒ 'b) ⇒ ('i_cnv, 'o_cnv, 'i_res, 'o_res) converter ⇒ ('a + 'i_cnv, 'b + 'o_cnv, 'i_res, 'o_res) converter" where "run_converter (ldummy_converter f conv) = (λinp. case inp of Inl x ⇒ map_gpv (map_prod Inl (λ_. ldummy_converter f conv)) id (Done (f x, ())) | Inr x ⇒ map_gpv (map_prod Inr (λc. ldummy_converter f c)) id (run_converter conv x))" primcorec rdummy_converter :: "('a ⇒ 'b) ⇒ ('i_cnv, 'o_cnv, 'i_res, 'o_res) converter ⇒ ('i_cnv + 'a, 'o_cnv + 'b, 'i_res, 'o_res) converter" where "run_converter (rdummy_converter f conv) = (λinp. case inp of Inl x ⇒ map_gpv (map_prod Inl (λc. rdummy_converter f c)) id (run_converter conv x) | Inr x ⇒ map_gpv (map_prod Inr (λ_. rdummy_converter f conv)) id (Done (f x, ())))" lemma ldummy_converter_of_callee: "ldummy_converter f (converter_of_callee callee state) = converter_of_callee (λs q. case_sum (λql. Done (Inl (f ql), s)) (λqr. map_gpv (map_prod Inr id) id (callee s qr)) q) state" apply (coinduction arbitrary: callee state) (*goal: ‹ldummy_converter f (CNV callee state) = CNV (λs q. case q of Inl ql ⇒ Done (Inl (f ql), s) | Inr qr ⇒ map_gpv (map_prod Inr id) id (callee s qr)) state›*) apply (clarsimp intro!:rel_funI (*‹(⋀x y. ?A x y ⟹ ?B (?f x) (?g y)) ⟹ rel_fun ?A ?B ?f ?g›*) split!:sum.splits (*‹?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)))› ‹?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: ‹⋀callee state. rel_fun (=) (rel_gpv (rel_prod (=) (λconverter__ converter'__. ∃callee state. converter__ = ldummy_converter f (CNV callee state) ∧ converter'__ = CNV (λs. case_sum (λql. Done (Inl (f ql), s)) (λqr. map_gpv (map_prod Inr id) id (callee s qr))) state)) (=)) (run_converter (ldummy_converter f (CNV callee state))) (run_converter (CNV (λs. case_sum (λql. Done (Inl (f ql), s)) (λqr. map_gpv (map_prod Inr id) id (callee s qr))) state))›*) subgoal for by blast apply (simp add: gpv.rel_map (*‹rel_gpv ?S1b ?S2b (map_gpv ?i1.0 ?i2.0 ?x) ?y = rel_gpv (λx. ?S1b (?i1.0 x)) (λx. ?S2b (?i2.0 x)) ?x ?y› ‹rel_gpv ?S1a ?S2a ?x (map_gpv ?g1.0 ?g2.0 ?y) = rel_gpv (λx y. ?S1a x (?g1.0 y)) (λx y. ?S2a x (?g2.0 y)) ?x ?y›*) map_prod_def (*‹map_prod ?f ?g = (λ(x, y). (?f x, ?g y))›*) split_def (*‹case_prod = (λc p. c (fst p) (snd p))›*)) (*goal: ‹⋀callee state x2. rel_gpv (rel_prod (=) (λconverter__ converter'__. ∃callee state. converter__ = ldummy_converter f (CNV callee state) ∧ converter'__ = CNV (λs. case_sum (λql. Done (Inl (f ql), s)) (λqr. map_gpv (map_prod Inr id) id (callee s qr))) state)) (=) (map_gpv (map_prod Inr (ldummy_converter f)) id (map_gpv (map_prod id (CNV callee)) id (callee state x2))) (map_gpv (map_prod id (CNV (λs. case_sum (λql. Done (Inl (f ql), s)) (λqr. map_gpv (map_prod Inr id) id (callee s qr))))) id (map_gpv (map_prod Inr id) id (callee state x2)))›*) apply (rule gpv.rel_mono_strong0[of "(=)" "(=)"] (*‹⟦rel_gpv (=) (=) ?x ?y; ∀z1∈results'_gpv ?x. ∀y1∈results'_gpv ?y. z1 = y1 ⟶ ?R1a z1 y1; ∀z2∈outs'_gpv ?x. ∀y2∈outs'_gpv ?y. z2 = y2 ⟶ ?R2a z2 y2⟧ ⟹ rel_gpv ?R1a ?R2a ?x ?y›*)) (*goals: 1. ‹⋀callee state x2. rel_gpv (=) (=) (callee state x2) (callee state x2)› 2. ‹⋀callee state x2. ∀z1∈results'_gpv (callee state x2). ∀y1∈results'_gpv (callee state x2). z1 = y1 ⟶ fst z1 = fst y1 ∧ (∃calleea state. ldummy_converter f (CNV callee (snd z1)) = ldummy_converter f (CNV calleea state) ∧ CNV (λs. case_sum (λql. Done (Inl (f ql), s)) (λqr. map_gpv (λp. (Inr (fst p), snd p)) id (callee s qr))) (snd y1) = CNV (λs. case_sum (λql. Done (Inl (f ql), s)) (λqr. map_gpv (λp. (Inr (fst p), snd p)) id (calleea s qr))) state)› 3. ‹⋀callee state x2. ∀z2∈outs'_gpv (callee state x2). ∀y2∈outs'_gpv (callee state x2). z2 = y2 ⟶ z2 = y2› discuss goal 1*) apply ((auto simp add: gpv.rel_eq (*‹rel_gpv (=) (=) = (=)›*))[1]) (*discuss goal 2*) apply ((auto simp add: gpv.rel_eq (*‹rel_gpv (=) (=) = (=)›*))[1]) (*discuss goal 3*) apply ((auto simp add: gpv.rel_eq (*‹rel_gpv (=) (=) = (=)›*))[1]) (*proven 3 subgoals*) . lemma rdummy_converter_of_callee: "rdummy_converter f (converter_of_callee callee state) = converter_of_callee (λs q. case_sum (λql. map_gpv (map_prod Inl id) id (callee s ql)) (λqr. Done (Inr (f qr), s)) q) state" apply (coinduction arbitrary: callee state) (*goal: ‹rdummy_converter (f::'b ⇒ 'd) (CNV (callee::'g ⇒ 'a ⇒ ('c × 'g, 'e, 'f) gpv) (state::'g)) = CNV (λ(s::'g) q::'a + 'b. case q of Inl (ql::'a) ⇒ map_gpv (map_prod Inl id) id (callee s ql) | Inr (qr::'b) ⇒ Done (Inr (f qr), s)) state›*) apply (clarsimp intro!:rel_funI (*‹(⋀x y. ?A x y ⟹ ?B (?f x) (?g y)) ⟹ rel_fun ?A ?B ?f ?g›*) split!:sum.splits (*‹?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)))› ‹?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: ‹⋀callee state. rel_fun (=) (rel_gpv (rel_prod (=) (λconverter__ converter'__. ∃callee state. converter__ = rdummy_converter f (CNV callee state) ∧ converter'__ = CNV (λs. case_sum (λql. map_gpv (map_prod Inl id) id (callee s ql)) (λqr. Done (Inr (f qr), s))) state)) (=)) (run_converter (rdummy_converter f (CNV callee state))) (run_converter (CNV (λs. case_sum (λql. map_gpv (map_prod Inl id) id (callee s ql)) (λqr. Done (Inr (f qr), s))) state))›*) defer 1 (*top goal: ‹⋀(callee::'g::type ⇒ 'a::type ⇒ ('c::type × 'g::type, 'e::type, 'f::type) gpv) state::'g::type. ∃(calleea::'g::type ⇒ 'a::type ⇒ ('c::type × 'g::type, 'e::type, 'f::type) gpv) statea::'g::type. rdummy_converter (f::'b::type ⇒ 'd::type) (CNV callee state) = rdummy_converter f (CNV calleea statea) ∧ CNV (λs::'g::type. case_sum (λql::'a::type. map_gpv (map_prod Inl id) id (callee s ql)) (λqr::'b::type. Done (Inr (f qr), s))) state = CNV (λs::'g::type. case_sum (λql::'a::type. map_gpv (map_prod Inl id) id (calleea s ql)) (λqr::'b::type. Done (Inr (f qr), s))) statea› and 1 goal remains*) subgoal for by blast apply (simp add: gpv.rel_map (*‹rel_gpv ?S1b ?S2b (map_gpv ?i1.0 ?i2.0 ?x) ?y = rel_gpv (λx. ?S1b (?i1.0 x)) (λx. ?S2b (?i2.0 x)) ?x ?y› ‹rel_gpv ?S1a ?S2a ?x (map_gpv ?g1.0 ?g2.0 ?y) = rel_gpv (λx y. ?S1a x (?g1.0 y)) (λx y. ?S2a x (?g2.0 y)) ?x ?y›*) map_prod_def (*‹map_prod ?f ?g = (λ(x, y). (?f x, ?g y))›*) split_def (*‹case_prod = (λc p. c (fst p) (snd p))›*)) (*goal: ‹⋀(callee::'g ⇒ 'a ⇒ ('c × 'g, 'e, 'f) gpv) (state::'g) x1::'a. rel_gpv (rel_prod (=) (λ(converter__::('a + 'b, 'c + 'd, 'e, 'f) converter) converter'__::('a + 'b, 'c + 'd, 'e, 'f) converter. ∃(callee::'g ⇒ 'a ⇒ ('c × 'g, 'e, 'f) gpv) state::'g. converter__ = rdummy_converter (f::'b ⇒ 'd) (CNV callee state) ∧ converter'__ = CNV (λs::'g. case_sum (λql::'a. map_gpv (map_prod Inl id) id (callee s ql)) (λqr::'b. Done (Inr (f qr), s))) state)) (=) (map_gpv (map_prod Inl (rdummy_converter f)) id (map_gpv (map_prod id (CNV callee)) id (callee state x1))) (map_gpv (map_prod id (CNV (λs::'g. case_sum (λql::'a. map_gpv (map_prod Inl id) id (callee s ql)) (λqr::'b. Done (Inr (f qr), s))))) id (map_gpv (map_prod Inl id) id (callee state x1)))›*) apply (rule gpv.rel_mono_strong0[of "(=)" "(=)"] (*‹⟦rel_gpv (=) (=) (?x::(?'h1::type, ?'i1::type, ?'g::type) gpv) (?y::(?'h1::type, ?'i1::type, ?'g::type) gpv); ∀z1::?'h1::type∈results'_gpv ?x. ∀y1::?'h1::type∈results'_gpv ?y. z1 = y1 ⟶ (?R1a::?'h1::type ⇒ ?'h1::type ⇒ bool) z1 y1; ∀z2::?'i1::type∈outs'_gpv ?x. ∀y2::?'i1::type∈outs'_gpv ?y. z2 = y2 ⟶ (?R2a::?'i1::type ⇒ ?'i1::type ⇒ bool) z2 y2⟧ ⟹ rel_gpv ?R1a ?R2a ?x ?y›*)) (*goals: 1. ‹⋀callee state x1. rel_gpv (=) (=) (callee state x1) (callee state x1)› 2. ‹⋀callee state x1. ∀z1∈results'_gpv (callee state x1). ∀y1∈results'_gpv (callee state x1). z1 = y1 ⟶ fst z1 = fst y1 ∧ (∃calleea state. rdummy_converter f (CNV callee (snd z1)) = rdummy_converter f (CNV calleea state) ∧ CNV (λs. case_sum (λql. map_gpv (λp. (Inl (fst p), snd p)) id (callee s ql)) (λqr. Done (Inr (f qr), s))) (snd y1) = CNV (λs. case_sum (λql. map_gpv (λp. (Inl (fst p), snd p)) id (calleea s ql)) (λqr. Done (Inr (f qr), s))) state)› 3. ‹⋀callee state x1. ∀z2∈outs'_gpv (callee state x1). ∀y2∈outs'_gpv (callee state x1). z2 = y2 ⟶ z2 = y2› discuss goal 1*) apply ((auto simp add: gpv.rel_eq (*‹rel_gpv (=) (=) = (=)›*))[1]) (*discuss goal 2*) apply ((auto simp add: gpv.rel_eq (*‹rel_gpv (=) (=) = (=)›*))[1]) (*discuss goal 3*) apply ((auto simp add: gpv.rel_eq (*‹rel_gpv (=) (=) = (=)›*))[1]) (*proven 3 subgoals*) .<close> context fixes cnv1 :: "('icnv_usr1, 'ocnv_usr1, 'iusr1_res1 + 'iusr1_res2, 'ousr1_res1 + 'ousr1_res2) converter" and cnv2 :: "('icnv_usr2, 'ocnv_usr2, 'iusr2_res1 + 'iusr2_res2, 'ousr2_res1 + 'ousr2_res2) converter" begin ― ‹c1r22: a converter that has 1 interface and sends queries to two resources, where the first and second resources have 2 and 2 interfaces respectively› definition wiring_c1r22_c1r22 :: "('icnv_usr1 + 'icnv_usr2, 'ocnv_usr1 + 'ocnv_usr2, ('iusr1_res1 + 'iusr2_res1) + 'iusr1_res2 + 'iusr2_res2, ('ousr1_res1 + 'ousr2_res1) + 'ousr1_res2 + 'ousr2_res2) converter" where "wiring_c1r22_c1r22 ≡ (cnv1 |₌ cnv2) ⊙ parallel_wiring" end ― ‹Special wiring converters used for the parallel composition of Fused resources› definition fused_wiring :: " ((('iadv_core1 + 'iadv_core2) + ('iadv_rest1 + 'iadv_rest2)) + (('iusr_core1 + 'iusr_core2) + ('iusr_rest1 + 'iusr_rest2)), (('oadv_core1 + 'oadv_core2) + ('oadv_rest1 + 'oadv_rest2)) + (('ousr_core1 + 'ousr_core2) + ('ousr_rest1 + 'ousr_rest2)), (('iadv_core1 + 'iadv_rest1) + ('iusr_core1 + 'iusr_rest1)) + (('iadv_core2 + 'iadv_rest2) + ('iusr_core2 + 'iusr_rest2)), (('oadv_core1 + 'oadv_rest1) + ('ousr_core1 + 'ousr_rest1)) + (('oadv_core2 + 'oadv_rest2) + ('ousr_core2 + 'ousr_rest2))) converter" where "fused_wiring ≡ (parallel_wiring |₌ parallel_wiring) ⊙ parallel_wiring" definition fused_wiring⇩w where "fused_wiring⇩w ≡ (parallel_wiring⇩w |⇩w parallel_wiring⇩w) ∘⇩w parallel_wiring⇩w" schematic_goal wiring_fused_wiring[wiring_intro]: "wiring ?ℐ1 ?ℐ2 fused_wiring fused_wiring⇩w" unfolding fused_wiring_def "fused_wiring⇩w_def" (*goal: ‹wiring ?ℐ1 ?ℐ2 ((parallel_wiring |₌ parallel_wiring) ⊙ parallel_wiring) (parallel_wiring⇩w |⇩w parallel_wiring⇩w ∘⇩w parallel_wiring⇩w)›*) apply (rule wiring_intro (*‹wiring ?ℐ ?ℐ 1⇩C (id, id)› ‹⟦wiring ?ℐ ?ℐ' ?conv1.0 ?fg; wiring ?ℐ' ?ℐ'' ?conv2.0 ?fg'⟧ ⟹ wiring ?ℐ ?ℐ'' (?conv1.0 ⊙ ?conv2.0) (?fg ∘⇩w ?fg')› ‹⟦wiring ?ℐ1.0 ?ℐ1' ?conv1.0 ?fg; wiring ?ℐ2.0 ?ℐ2' ?conv2.0 ?fg'⟧ ⟹ wiring (?ℐ1.0 ⊕⇩ℐ ?ℐ2.0) (?ℐ1' ⊕⇩ℐ ?ℐ2') (?conv1.0 |₌ ?conv2.0) (?fg |⇩w ?fg')› ‹wiring ((?ℐ1.0 ⊕⇩ℐ ?ℐ2.0) ⊕⇩ℐ ?ℐ3.0) (?ℐ1.0 ⊕⇩ℐ (?ℐ2.0 ⊕⇩ℐ ?ℐ3.0)) lassocr⇩C lassocr⇩w› ‹wiring (?ℐ1.0 ⊕⇩ℐ (?ℐ2.0 ⊕⇩ℐ ?ℐ3.0)) ((?ℐ1.0 ⊕⇩ℐ ?ℐ2.0) ⊕⇩ℐ ?ℐ3.0) rassocl⇩C rassocl⇩w› ‹wiring (?ℐ1.0 ⊕⇩ℐ ?ℐ2.0) (?ℐ2.0 ⊕⇩ℐ ?ℐ1.0) swap⇩C swap⇩w› ‹wiring (?ℐ1.0 ⊕⇩ℐ (?ℐ2.0 ⊕⇩ℐ ?ℐ3.0)) (?ℐ2.0 ⊕⇩ℐ (?ℐ1.0 ⊕⇩ℐ ?ℐ3.0)) swap_lassocr swap_lassocr⇩w› ‹wiring ((?ℐ1.0 ⊕⇩ℐ ?ℐ2.0) ⊕⇩ℐ (?ℐ2a ⊕⇩ℐ ?ℐ3.0)) ((?ℐ1.0 ⊕⇩ℐ ?ℐ2a) ⊕⇩ℐ (?ℐ2.0 ⊕⇩ℐ ?ℐ3.0)) parallel_wiring parallel_wiring⇩w›*)) (*goals: 1. ‹wiring ?ℐ1 ?ℐ'6 (parallel_wiring |₌ parallel_wiring) (parallel_wiring⇩w |⇩w parallel_wiring⇩w)› 2. ‹wiring ?ℐ'6 ?ℐ2 parallel_wiring parallel_wiring⇩w› discuss goal 1*) apply (rule wiring_intro (*‹wiring ?ℐ ?ℐ 1⇩C (id, id)› ‹⟦wiring ?ℐ ?ℐ' ?conv1.0 ?fg; wiring ?ℐ' ?ℐ'' ?conv2.0 ?fg'⟧ ⟹ wiring ?ℐ ?ℐ'' (?conv1.0 ⊙ ?conv2.0) (?fg ∘⇩w ?fg')› ‹⟦wiring ?ℐ1.0 ?ℐ1' ?conv1.0 ?fg; wiring ?ℐ2.0 ?ℐ2' ?conv2.0 ?fg'⟧ ⟹ wiring (?ℐ1.0 ⊕⇩ℐ ?ℐ2.0) (?ℐ1' ⊕⇩ℐ ?ℐ2') (?conv1.0 |₌ ?conv2.0) (?fg |⇩w ?fg')› ‹wiring ((?ℐ1.0 ⊕⇩ℐ ?ℐ2.0) ⊕⇩ℐ ?ℐ3.0) (?ℐ1.0 ⊕⇩ℐ (?ℐ2.0 ⊕⇩ℐ ?ℐ3.0)) lassocr⇩C lassocr⇩w› ‹wiring (?ℐ1.0 ⊕⇩ℐ (?ℐ2.0 ⊕⇩ℐ ?ℐ3.0)) ((?ℐ1.0 ⊕⇩ℐ ?ℐ2.0) ⊕⇩ℐ ?ℐ3.0) rassocl⇩C rassocl⇩w› ‹wiring (?ℐ1.0 ⊕⇩ℐ ?ℐ2.0) (?ℐ2.0 ⊕⇩ℐ ?ℐ1.0) swap⇩C swap⇩w› ‹wiring (?ℐ1.0 ⊕⇩ℐ (?ℐ2.0 ⊕⇩ℐ ?ℐ3.0)) (?ℐ2.0 ⊕⇩ℐ (?ℐ1.0 ⊕⇩ℐ ?ℐ3.0)) swap_lassocr swap_lassocr⇩w› ‹wiring ((?ℐ1.0 ⊕⇩ℐ ?ℐ2.0) ⊕⇩ℐ (?ℐ2a ⊕⇩ℐ ?ℐ3.0)) ((?ℐ1.0 ⊕⇩ℐ ?ℐ2a) ⊕⇩ℐ (?ℐ2.0 ⊕⇩ℐ ?ℐ3.0)) parallel_wiring parallel_wiring⇩w›*)) (*goals: 1. ‹wiring ?ℐ1.9 ?ℐ1'9 parallel_wiring parallel_wiring⇩w› 2. ‹wiring ?ℐ2.9 ?ℐ2'9 parallel_wiring parallel_wiring⇩w› discuss goal 1*) apply (rule wiring_intro (*‹wiring (?ℐ::(?'a, ?'b) ℐ) ?ℐ 1⇩C (id, id)› ‹⟦wiring (?ℐ::(?'a, ?'b) ℐ) (?ℐ'::(?'c, ?'d) ℐ) (?conv1.0::(?'a, ?'b, ?'c, ?'d) converter) (?fg::(?'a ⇒ ?'c) × (?'d ⇒ ?'b)); wiring ?ℐ' (?ℐ''::(?'e, ?'f) ℐ) (?conv2.0::(?'c, ?'d, ?'e, ?'f) converter) (?fg'::(?'c ⇒ ?'e) × (?'f ⇒ ?'d))⟧ ⟹ wiring ?ℐ ?ℐ'' (?conv1.0 ⊙ ?conv2.0) (?fg ∘⇩w ?fg')› ‹⟦wiring (?ℐ1.0::(?'a, ?'b) ℐ) (?ℐ1'::(?'c, ?'d) ℐ) (?conv1.0::(?'a, ?'b, ?'c, ?'d) converter) (?fg::(?'a ⇒ ?'c) × (?'d ⇒ ?'b)); wiring (?ℐ2.0::(?'e, ?'f) ℐ) (?ℐ2'::(?'g, ?'h) ℐ) (?conv2.0::(?'e, ?'f, ?'g, ?'h) converter) (?fg'::(?'e ⇒ ?'g) × (?'h ⇒ ?'f))⟧ ⟹ wiring (?ℐ1.0 ⊕⇩ℐ ?ℐ2.0) (?ℐ1' ⊕⇩ℐ ?ℐ2') (?conv1.0 |₌ ?conv2.0) (?fg |⇩w ?fg')› ‹wiring (((?ℐ1.0::(?'a, ?'d) ℐ) ⊕⇩ℐ (?ℐ2.0::(?'b, ?'e) ℐ)) ⊕⇩ℐ (?ℐ3.0::(?'c, ?'f) ℐ)) (?ℐ1.0 ⊕⇩ℐ (?ℐ2.0 ⊕⇩ℐ ?ℐ3.0)) lassocr⇩C lassocr⇩w› ‹wiring ((?ℐ1.0::(?'a, ?'d) ℐ) ⊕⇩ℐ ((?ℐ2.0::(?'b, ?'e) ℐ) ⊕⇩ℐ (?ℐ3.0::(?'c, ?'f) ℐ))) ((?ℐ1.0 ⊕⇩ℐ ?ℐ2.0) ⊕⇩ℐ ?ℐ3.0) rassocl⇩C rassocl⇩w› ‹wiring ((?ℐ1.0::(?'a, ?'c) ℐ) ⊕⇩ℐ (?ℐ2.0::(?'b, ?'d) ℐ)) (?ℐ2.0 ⊕⇩ℐ ?ℐ1.0) swap⇩C swap⇩w› ‹wiring ((?ℐ1.0::(?'a, ?'d) ℐ) ⊕⇩ℐ ((?ℐ2.0::(?'b, ?'e) ℐ) ⊕⇩ℐ (?ℐ3.0::(?'c, ?'f) ℐ))) (?ℐ2.0 ⊕⇩ℐ (?ℐ1.0 ⊕⇩ℐ ?ℐ3.0)) swap_lassocr swap_lassocr⇩w› ‹wiring (((?ℐ1.0::(?'a, ?'e) ℐ) ⊕⇩ℐ (?ℐ2.0::(?'b, ?'f) ℐ)) ⊕⇩ℐ ((?ℐ2a::(?'c, ?'g) ℐ) ⊕⇩ℐ (?ℐ3.0::(?'d, ?'h) ℐ))) ((?ℐ1.0 ⊕⇩ℐ ?ℐ2a) ⊕⇩ℐ (?ℐ2.0 ⊕⇩ℐ ?ℐ3.0)) parallel_wiring parallel_wiring⇩w›*)) (*discuss goal 2*) apply (rule wiring_intro (*‹wiring ?ℐ ?ℐ 1⇩C (id, id)› ‹⟦wiring ?ℐ ?ℐ' ?conv1.0 ?fg; wiring ?ℐ' ?ℐ'' ?conv2.0 ?fg'⟧ ⟹ wiring ?ℐ ?ℐ'' (?conv1.0 ⊙ ?conv2.0) (?fg ∘⇩w ?fg')› ‹⟦wiring ?ℐ1.0 ?ℐ1' ?conv1.0 ?fg; wiring ?ℐ2.0 ?ℐ2' ?conv2.0 ?fg'⟧ ⟹ wiring (?ℐ1.0 ⊕⇩ℐ ?ℐ2.0) (?ℐ1' ⊕⇩ℐ ?ℐ2') (?conv1.0 |₌ ?conv2.0) (?fg |⇩w ?fg')› ‹wiring ((?ℐ1.0 ⊕⇩ℐ ?ℐ2.0) ⊕⇩ℐ ?ℐ3.0) (?ℐ1.0 ⊕⇩ℐ (?ℐ2.0 ⊕⇩ℐ ?ℐ3.0)) lassocr⇩C lassocr⇩w› ‹wiring (?ℐ1.0 ⊕⇩ℐ (?ℐ2.0 ⊕⇩ℐ ?ℐ3.0)) ((?ℐ1.0 ⊕⇩ℐ ?ℐ2.0) ⊕⇩ℐ ?ℐ3.0) rassocl⇩C rassocl⇩w› ‹wiring (?ℐ1.0 ⊕⇩ℐ ?ℐ2.0) (?ℐ2.0 ⊕⇩ℐ ?ℐ1.0) swap⇩C swap⇩w› ‹wiring (?ℐ1.0 ⊕⇩ℐ (?ℐ2.0 ⊕⇩ℐ ?ℐ3.0)) (?ℐ2.0 ⊕⇩ℐ (?ℐ1.0 ⊕⇩ℐ ?ℐ3.0)) swap_lassocr swap_lassocr⇩w› ‹wiring ((?ℐ1.0 ⊕⇩ℐ ?ℐ2.0) ⊕⇩ℐ (?ℐ2a ⊕⇩ℐ ?ℐ3.0)) ((?ℐ1.0 ⊕⇩ℐ ?ℐ2a) ⊕⇩ℐ (?ℐ2.0 ⊕⇩ℐ ?ℐ3.0)) parallel_wiring parallel_wiring⇩w›*)) (*proven 2 subgoals*) (*discuss goal 2*) apply (rule wiring_intro (*‹wiring ?ℐ ?ℐ 1⇩C (id, id)› ‹⟦wiring ?ℐ ?ℐ' ?conv1.0 ?fg; wiring ?ℐ' ?ℐ'' ?conv2.0 ?fg'⟧ ⟹ wiring ?ℐ ?ℐ'' (?conv1.0 ⊙ ?conv2.0) (?fg ∘⇩w ?fg')› ‹⟦wiring ?ℐ1.0 ?ℐ1' ?conv1.0 ?fg; wiring ?ℐ2.0 ?ℐ2' ?conv2.0 ?fg'⟧ ⟹ wiring (?ℐ1.0 ⊕⇩ℐ ?ℐ2.0) (?ℐ1' ⊕⇩ℐ ?ℐ2') (?conv1.0 |₌ ?conv2.0) (?fg |⇩w ?fg')› ‹wiring ((?ℐ1.0 ⊕⇩ℐ ?ℐ2.0) ⊕⇩ℐ ?ℐ3.0) (?ℐ1.0 ⊕⇩ℐ (?ℐ2.0 ⊕⇩ℐ ?ℐ3.0)) lassocr⇩C lassocr⇩w› ‹wiring (?ℐ1.0 ⊕⇩ℐ (?ℐ2.0 ⊕⇩ℐ ?ℐ3.0)) ((?ℐ1.0 ⊕⇩ℐ ?ℐ2.0) ⊕⇩ℐ ?ℐ3.0) rassocl⇩C rassocl⇩w› ‹wiring (?ℐ1.0 ⊕⇩ℐ ?ℐ2.0) (?ℐ2.0 ⊕⇩ℐ ?ℐ1.0) swap⇩C swap⇩w› ‹wiring (?ℐ1.0 ⊕⇩ℐ (?ℐ2.0 ⊕⇩ℐ ?ℐ3.0)) (?ℐ2.0 ⊕⇩ℐ (?ℐ1.0 ⊕⇩ℐ ?ℐ3.0)) swap_lassocr swap_lassocr⇩w› ‹wiring ((?ℐ1.0 ⊕⇩ℐ ?ℐ2.0) ⊕⇩ℐ (?ℐ2a ⊕⇩ℐ ?ℐ3.0)) ((?ℐ1.0 ⊕⇩ℐ ?ℐ2a) ⊕⇩ℐ (?ℐ2.0 ⊕⇩ℐ ?ℐ3.0)) parallel_wiring parallel_wiring⇩w›*)) (*proven 2 subgoals*) . schematic_goal WT_fused_wiring [WT_intro]: "?ℐ1, ?ℐ2 ⊢⇩C fused_wiring √" unfolding fused_wiring_def (*goal: ‹?ℐ1, ?ℐ2 ⊢⇩C (parallel_wiring |₌ parallel_wiring) ⊙ parallel_wiring √›*) apply (rule WT_intro (*‹map_ℐ (?g::?'a::type ⇒ ?'d::type) (?h::?'e::type ⇒ ?'b::type) (?ℐ::(?'d::type, ?'e::type) ℐ) ⊢g ?gpv::(?'c::type, ?'a::type, ?'b::type) gpv √ ⟹ ?ℐ ⊢g map_gpv' (?f::?'c::type ⇒ ?'f::type) ?g ?h ?gpv √› ‹map_ℐ (?g::?'a::type ⇒ ?'d::type) id (?ℐ::(?'d::type, ?'b::type) ℐ) ⊢g ?gpv::(?'c::type, ?'a::type, ?'b::type) gpv √ ⟹ ?ℐ ⊢g map_gpv (?f::?'c::type ⇒ ?'e::type) ?g ?gpv √› ‹⟦(?ℐ1.0::(?'a::type, ?'b::type) ℐ) ⊢res ?res1.0::(?'a::type, ?'b::type) resource √; (?ℐ2.0::(?'c::type, ?'d::type) ℐ) ⊢res ?res2.0::(?'c::type, ?'d::type) resource √⟧ ⟹ ?ℐ1.0 ⊕⇩ℐ ?ℐ2.0 ⊢res ?res1.0 ∥ ?res2.0 √› ‹⟦map_ℐ (inv (?f::?'e::type ⇒ ?'a::type)) (inv (?g::?'b::type ⇒ ?'f::type)) (?ℐ::(?'e::type, ?'f::type) ℐ), map_ℐ (?f'::?'c::type ⇒ ?'g::type) (?g'::?'h::type ⇒ ?'d::type) (?ℐ'::(?'g::type, ?'h::type) ℐ) ⊢⇩C ?conv::(?'a::type, ?'b::type, ?'c::type, ?'d::type) converter √; inj ?f; surj ?g⟧ ⟹ ?ℐ, ?ℐ' ⊢⇩C map_converter ?f ?g ?f' ?g' ?conv √› ‹(?ℐ::(?'a::type, ?'b::type) ℐ), ?ℐ ⊢⇩C 1⇩C √› ‹(?ℐ::(?'a::type, ?'b::type) ℐ), ?ℐ'::(?'c::type, ?'d::type) ℐ ⊢⇩C ⊥⇩C √› ‹⟦(?ℐ1.0::(?'a::type, ?'b::type) ℐ), ?ℐ2.0::(?'c::type, ?'d::type) ℐ ⊢⇩C ?conv1.0::(?'a::type, ?'b::type, ?'c::type, ?'d::type) converter √; (?ℐ1'::(?'e::type, ?'f::type) ℐ), ?ℐ2'::(?'g::type, ?'h::type) ℐ ⊢⇩C ?conv2.0::(?'e::type, ?'f::type, ?'g::type, ?'h::type) converter √⟧ ⟹ ?ℐ1.0 ⊕⇩ℐ ?ℐ1', ?ℐ2.0 ⊕⇩ℐ ?ℐ2' ⊢⇩C ?conv1.0 |₌ ?conv2.0 √› ‹⟦(?ℐ1.0::(?'a::type, ?'b::type) ℐ), ?ℐ::(?'c::type, ?'d::type) ℐ ⊢⇩C ?conv1.0::(?'a::type, ?'b::type, ?'c::type, ?'d::type) converter √; (?ℐ2.0::(?'e::type, ?'f::type) ℐ), ?ℐ ⊢⇩C ?conv2.0::(?'e::type, ?'f::type, ?'c::type, ?'d::type) converter √⟧ ⟹ ?ℐ1.0 ⊕⇩ℐ ?ℐ2.0, ?ℐ ⊢⇩C ?conv1.0 |⇩∝ ?conv2.0 √› ‹(?ℐ::(?'a::type, ?'b::type) ℐ) ⊢res ?res::(?'a::type, ?'b::type) resource √ ⟹ ?ℐ, ?ℐ'::(?'c::type, ?'d::type) ℐ ⊢⇩C converter_of_resource ?res √› ‹(?ℐ::(?'a::type, ?'b::type) ℐ), ?ℐ'::(?'c::type, ?'d::type) ℐ ⊢⇩C ?cnv::(?'a::type, ?'b::type, ?'c::type, ?'d::type) converter √ ⟹ ?ℐ, ?ℐ' ⊢⇩C restrict_converter (?A::?'a::type set) ?ℐ' ?cnv √› ‹⟦(?ℐ::(?'a::type, ?'b::type) ℐ), ?ℐ'::(?'c::type, ?'d::type) ℐ ⊢⇩C ?conv::(?'a::type, ?'b::type, ?'c::type, ?'d::type) converter √; ?ℐ' ⊢res ?res::(?'c::type, ?'d::type) resource √⟧ ⟹ ?ℐ ⊢res ?conv ⊳ ?res √› ‹⟦(?ℐ::(?'a::type, ?'b::type) ℐ), ?ℐ'::(?'c::type, ?'d::type) ℐ ⊢⇩C ?conv::(?'a::type, ?'b::type, ?'c::type, ?'d::type) converter √; ?ℐ', ?ℐ''::(?'e::type, ?'f::type) ℐ ⊢⇩C ?conv'::(?'c::type, ?'d::type, ?'e::type, ?'f::type) converter √⟧ ⟹ ?ℐ, ?ℐ'' ⊢⇩C ?conv ⊙ ?conv' √› and more 19 facts*)) (*goals: 1. ‹?ℐ1, ?ℐ'6 ⊢⇩C parallel_wiring |₌ parallel_wiring √› 2. ‹?ℐ'6, ?ℐ2 ⊢⇩C parallel_wiring √› discuss goal 1*) apply (rule WT_intro (*‹map_ℐ ?g ?h ?ℐ ⊢g ?gpv √ ⟹ ?ℐ ⊢g map_gpv' ?f ?g ?h ?gpv √› ‹map_ℐ ?g id ?ℐ ⊢g ?gpv √ ⟹ ?ℐ ⊢g map_gpv ?f ?g ?gpv √› ‹⟦?ℐ1.0 ⊢res ?res1.0 √; ?ℐ2.0 ⊢res ?res2.0 √⟧ ⟹ ?ℐ1.0 ⊕⇩ℐ ?ℐ2.0 ⊢res ?res1.0 ∥ ?res2.0 √› ‹⟦map_ℐ (inv ?f) (inv ?g) ?ℐ, map_ℐ ?f' ?g' ?ℐ' ⊢⇩C ?conv √; inj ?f; surj ?g⟧ ⟹ ?ℐ, ?ℐ' ⊢⇩C map_converter ?f ?g ?f' ?g' ?conv √› ‹?ℐ, ?ℐ ⊢⇩C 1⇩C √› ‹?ℐ, ?ℐ' ⊢⇩C ⊥⇩C √› ‹⟦?ℐ1.0, ?ℐ2.0 ⊢⇩C ?conv1.0 √; ?ℐ1', ?ℐ2' ⊢⇩C ?conv2.0 √⟧ ⟹ ?ℐ1.0 ⊕⇩ℐ ?ℐ1', ?ℐ2.0 ⊕⇩ℐ ?ℐ2' ⊢⇩C ?conv1.0 |₌ ?conv2.0 √› ‹⟦?ℐ1.0, ?ℐ ⊢⇩C ?conv1.0 √; ?ℐ2.0, ?ℐ ⊢⇩C ?conv2.0 √⟧ ⟹ ?ℐ1.0 ⊕⇩ℐ ?ℐ2.0, ?ℐ ⊢⇩C ?conv1.0 |⇩∝ ?conv2.0 √› ‹?ℐ ⊢res ?res √ ⟹ ?ℐ, ?ℐ' ⊢⇩C converter_of_resource ?res √› ‹?ℐ, ?ℐ' ⊢⇩C ?cnv √ ⟹ ?ℐ, ?ℐ' ⊢⇩C restrict_converter ?A ?ℐ' ?cnv √› ‹⟦?ℐ, ?ℐ' ⊢⇩C ?conv √; ?ℐ' ⊢res ?res √⟧ ⟹ ?ℐ ⊢res ?conv ⊳ ?res √› ‹⟦?ℐ, ?ℐ' ⊢⇩C ?conv √; ?ℐ', ?ℐ'' ⊢⇩C ?conv' √⟧ ⟹ ?ℐ, ?ℐ'' ⊢⇩C ?conv ⊙ ?conv' √› and more 19 facts*)) (*goals: 1. ‹?ℐ1.9, ?ℐ2.9 ⊢⇩C parallel_wiring √› 2. ‹?ℐ1'9, ?ℐ2'9 ⊢⇩C parallel_wiring √› discuss goal 1*) apply (rule WT_intro (*‹map_ℐ ?g ?h ?ℐ ⊢g ?gpv √ ⟹ ?ℐ ⊢g map_gpv' ?f ?g ?h ?gpv √› ‹map_ℐ ?g id ?ℐ ⊢g ?gpv √ ⟹ ?ℐ ⊢g map_gpv ?f ?g ?gpv √› ‹⟦?ℐ1.0 ⊢res ?res1.0 √; ?ℐ2.0 ⊢res ?res2.0 √⟧ ⟹ ?ℐ1.0 ⊕⇩ℐ ?ℐ2.0 ⊢res ?res1.0 ∥ ?res2.0 √› ‹⟦map_ℐ (inv ?f) (inv ?g) ?ℐ, map_ℐ ?f' ?g' ?ℐ' ⊢⇩C ?conv √; inj ?f; surj ?g⟧ ⟹ ?ℐ, ?ℐ' ⊢⇩C map_converter ?f ?g ?f' ?g' ?conv √› ‹?ℐ, ?ℐ ⊢⇩C 1⇩C √› ‹?ℐ, ?ℐ' ⊢⇩C ⊥⇩C √› ‹⟦?ℐ1.0, ?ℐ2.0 ⊢⇩C ?conv1.0 √; ?ℐ1', ?ℐ2' ⊢⇩C ?conv2.0 √⟧ ⟹ ?ℐ1.0 ⊕⇩ℐ ?ℐ1', ?ℐ2.0 ⊕⇩ℐ ?ℐ2' ⊢⇩C ?conv1.0 |₌ ?conv2.0 √› ‹⟦?ℐ1.0, ?ℐ ⊢⇩C ?conv1.0 √; ?ℐ2.0, ?ℐ ⊢⇩C ?conv2.0 √⟧ ⟹ ?ℐ1.0 ⊕⇩ℐ ?ℐ2.0, ?ℐ ⊢⇩C ?conv1.0 |⇩∝ ?conv2.0 √› ‹?ℐ ⊢res ?res √ ⟹ ?ℐ, ?ℐ' ⊢⇩C converter_of_resource ?res √› ‹?ℐ, ?ℐ' ⊢⇩C ?cnv √ ⟹ ?ℐ, ?ℐ' ⊢⇩C restrict_converter ?A ?ℐ' ?cnv √› ‹⟦?ℐ, ?ℐ' ⊢⇩C ?conv √; ?ℐ' ⊢res ?res √⟧ ⟹ ?ℐ ⊢res ?conv ⊳ ?res √› ‹⟦?ℐ, ?ℐ' ⊢⇩C ?conv √; ?ℐ', ?ℐ'' ⊢⇩C ?conv' √⟧ ⟹ ?ℐ, ?ℐ'' ⊢⇩C ?conv ⊙ ?conv' √› and more 19 facts*)) (*discuss goal 2*) apply (rule WT_intro (*‹map_ℐ ?g ?h ?ℐ ⊢g ?gpv √ ⟹ ?ℐ ⊢g map_gpv' ?f ?g ?h ?gpv √› ‹map_ℐ ?g id ?ℐ ⊢g ?gpv √ ⟹ ?ℐ ⊢g map_gpv ?f ?g ?gpv √› ‹⟦?ℐ1.0 ⊢res ?res1.0 √; ?ℐ2.0 ⊢res ?res2.0 √⟧ ⟹ ?ℐ1.0 ⊕⇩ℐ ?ℐ2.0 ⊢res ?res1.0 ∥ ?res2.0 √› ‹⟦map_ℐ (inv ?f) (inv ?g) ?ℐ, map_ℐ ?f' ?g' ?ℐ' ⊢⇩C ?conv √; inj ?f; surj ?g⟧ ⟹ ?ℐ, ?ℐ' ⊢⇩C map_converter ?f ?g ?f' ?g' ?conv √› ‹?ℐ, ?ℐ ⊢⇩C 1⇩C √› ‹?ℐ, ?ℐ' ⊢⇩C ⊥⇩C √› ‹⟦?ℐ1.0, ?ℐ2.0 ⊢⇩C ?conv1.0 √; ?ℐ1', ?ℐ2' ⊢⇩C ?conv2.0 √⟧ ⟹ ?ℐ1.0 ⊕⇩ℐ ?ℐ1', ?ℐ2.0 ⊕⇩ℐ ?ℐ2' ⊢⇩C ?conv1.0 |₌ ?conv2.0 √› ‹⟦?ℐ1.0, ?ℐ ⊢⇩C ?conv1.0 √; ?ℐ2.0, ?ℐ ⊢⇩C ?conv2.0 √⟧ ⟹ ?ℐ1.0 ⊕⇩ℐ ?ℐ2.0, ?ℐ ⊢⇩C ?conv1.0 |⇩∝ ?conv2.0 √› ‹?ℐ ⊢res ?res √ ⟹ ?ℐ, ?ℐ' ⊢⇩C converter_of_resource ?res √› ‹?ℐ, ?ℐ' ⊢⇩C ?cnv √ ⟹ ?ℐ, ?ℐ' ⊢⇩C restrict_converter ?A ?ℐ' ?cnv √› ‹⟦?ℐ, ?ℐ' ⊢⇩C ?conv √; ?ℐ' ⊢res ?res √⟧ ⟹ ?ℐ ⊢res ?conv ⊳ ?res √› ‹⟦?ℐ, ?ℐ' ⊢⇩C ?conv √; ?ℐ', ?ℐ'' ⊢⇩C ?conv' √⟧ ⟹ ?ℐ, ?ℐ'' ⊢⇩C ?conv ⊙ ?conv' √› and more 19 facts*)) (*proven 2 subgoals*) (*discuss goal 2*) apply (rule WT_intro (*‹map_ℐ ?g ?h ?ℐ ⊢g ?gpv √ ⟹ ?ℐ ⊢g map_gpv' ?f ?g ?h ?gpv √› ‹map_ℐ ?g id ?ℐ ⊢g ?gpv √ ⟹ ?ℐ ⊢g map_gpv ?f ?g ?gpv √› ‹⟦?ℐ1.0 ⊢res ?res1.0 √; ?ℐ2.0 ⊢res ?res2.0 √⟧ ⟹ ?ℐ1.0 ⊕⇩ℐ ?ℐ2.0 ⊢res ?res1.0 ∥ ?res2.0 √› ‹⟦map_ℐ (inv ?f) (inv ?g) ?ℐ, map_ℐ ?f' ?g' ?ℐ' ⊢⇩C ?conv √; inj ?f; surj ?g⟧ ⟹ ?ℐ, ?ℐ' ⊢⇩C map_converter ?f ?g ?f' ?g' ?conv √› ‹?ℐ, ?ℐ ⊢⇩C 1⇩C √› ‹?ℐ, ?ℐ' ⊢⇩C ⊥⇩C √› ‹⟦?ℐ1.0, ?ℐ2.0 ⊢⇩C ?conv1.0 √; ?ℐ1', ?ℐ2' ⊢⇩C ?conv2.0 √⟧ ⟹ ?ℐ1.0 ⊕⇩ℐ ?ℐ1', ?ℐ2.0 ⊕⇩ℐ ?ℐ2' ⊢⇩C ?conv1.0 |₌ ?conv2.0 √› ‹⟦?ℐ1.0, ?ℐ ⊢⇩C ?conv1.0 √; ?ℐ2.0, ?ℐ ⊢⇩C ?conv2.0 √⟧ ⟹ ?ℐ1.0 ⊕⇩ℐ ?ℐ2.0, ?ℐ ⊢⇩C ?conv1.0 |⇩∝ ?conv2.0 √› ‹?ℐ ⊢res ?res √ ⟹ ?ℐ, ?ℐ' ⊢⇩C converter_of_resource ?res √› ‹?ℐ, ?ℐ' ⊢⇩C ?cnv √ ⟹ ?ℐ, ?ℐ' ⊢⇩C restrict_converter ?A ?ℐ' ?cnv √› ‹⟦?ℐ, ?ℐ' ⊢⇩C ?conv √; ?ℐ' ⊢res ?res √⟧ ⟹ ?ℐ ⊢res ?conv ⊳ ?res √› ‹⟦?ℐ, ?ℐ' ⊢⇩C ?conv √; ?ℐ', ?ℐ'' ⊢⇩C ?conv' √⟧ ⟹ ?ℐ, ?ℐ'' ⊢⇩C ?conv ⊙ ?conv' √› and more 19 facts*)) (*proven 2 subgoals*) .<close> context fixes cnv1 :: "('icnv_usr1, 'ocnv_usr1, 'iusr1_core1 + 'iusr1_core2, 'ousr1_core1 + 'ousr1_core2) converter" and cnv2 :: "('icnv_usr2, 'ocnv_usr2, 'iusr2_core1 + 'iusr2_core2, 'ousr2_core1 + 'ousr2_core2) converter" and res1 :: "(('iadv_core1 + 'iadv_rest1) + ('iusr1_core1 + 'iusr2_core1) + 'iusr_rest1, ('oadv_core1 + 'oadv_rest1) + ('ousr1_core1 + 'ousr2_core1) + 'ousr_rest1) resource" and res2 :: "(('iadv_core2 + 'iadv_rest2) + ('iusr1_core2 + 'iusr2_core2) + 'iusr_rest2, ('oadv_core2 + 'oadv_rest2) + ('ousr1_core2 + 'ousr2_core2) + 'ousr_rest2) resource" begin ― ‹Attachement of two c1f22 ('f' instead of 'r' to indicate Fused Resources) converters to two 2-interface Fused Resources, the results will be a new 2-interface Fused Resource› definition attach_c1f22_c1f22 :: "((('iadv_core1 + 'iadv_core2) + 'iadv_rest1 + 'iadv_rest2) + ('icnv_usr1 + 'icnv_usr2) + 'iusr_rest1 + 'iusr_rest2, (('oadv_core1 + 'oadv_core2) + 'oadv_rest1 + 'oadv_rest2) + ('ocnv_usr1 + 'ocnv_usr2) + 'ousr_rest1 + 'ousr_rest2) resource" where "attach_c1f22_c1f22 = (((1⇩C |₌ 1⇩C) |₌ ((wiring_c1r22_c1r22 cnv1 cnv2) |₌ 1⇩C)) ⊙ fused_wiring) ⊳ (res1 ∥ res2)" end ― ‹Properties of Converters attaching to Fused resources› context fixes core1 :: "('s_core1, 'e1, 'iadv_core1, 'iusr_core1, 'oadv_core1, 'ousr_core1) core" and core2 :: "('s_core2, 'e2, 'iadv_core2, 'iusr_core2, 'oadv_core2, 'ousr_core2) core" and rest1 :: "('s_rest1, 'e1, 'iadv_rest1, 'iusr_rest1, 'oadv_rest1, 'ousr_rest1, 'm1) rest_scheme" and rest2 :: "('s_rest2, 'e2, 'iadv_rest2, 'iusr_rest2, 'oadv_rest2, 'ousr_rest2, 'm2) rest_scheme" begin lemma parallel_oracle_fuse: "apply_wiring fused_wiring⇩w (parallel_oracle (fused_resource.fuse core1 rest1) (fused_resource.fuse core2 rest2)) = apply_state_iso parallel_state_iso (fused_resource.fuse (parallel_core core1 core2) (parallel_rest rest1 rest2))" supply fused_resource.fuse.simps[simp] apply(rule ext)+ apply(clarsimp simp add: fused_wiring⇩w_def apply_state_iso_def parallel_state_iso_def parallel_wiring⇩w_def) apply(simp add: apply_wiring_def comp_wiring_def parallel2_wiring_def lassocr⇩w_def swap_lassocr⇩w_def rassocl⇩w_def swap⇩w_def) subgoal for s_core1 s_rest1 s_core2 s_rest2 i apply(cases "(parallel_rest rest1 rest2, ((s_core1, s_core2), (s_rest1, s_rest2)), i)" rule: fused_resource.fuse.cases) apply(auto split!: sum.splits) subgoal for iadv_core by (cases iadv_core) (auto simp add: map_spmf_bind_spmf bind_map_spmf intro!: bind_spmf_cong split!: sum.splits) subgoal for iadv_rest by (cases iadv_rest) (auto simp add: parallel_handler_left parallel_handler_right foldl_spmf_pair_left parallel_eoracle_def foldl_spmf_pair_right split_beta o_def map_spmf_bind_spmf bind_map_spmf) subgoal for iusr_core by (cases iusr_core) (auto simp add: map_spmf_bind_spmf bind_map_spmf intro!: bind_spmf_cong split!: sum.splits) subgoal for iusr_rest by (cases iusr_rest) (auto simp add: parallel_handler_left parallel_handler_right foldl_spmf_pair_left parallel_eoracle_def foldl_spmf_pair_right split_beta o_def map_spmf_bind_spmf bind_map_spmf) done done end lemma attach_callee_fuse: "attach_callee ((cnv_adv_core ‡⇩I cnv_adv_rest) ‡⇩I cnv_usr_core ‡⇩I cnv_usr_rest) (fused_resource.fuse core rest) = apply_state_iso iso_trisplit (fused_resource.fuse (attach_core cnv_adv_core cnv_usr_core core) (attach_rest cnv_adv_rest cnv_usr_rest f_init rest))" (is "?lhs = ?rhs") proof(intro ext; clarify) note fused_resource.fuse.simps [simp] let ?tri = "λ(((s11, s12), s13), (s21, s22), s23). (((s11, s21), s12, s22), s13, s23)" fix q :: "('g + 'h) + 'i + 'j" consider (ACore) qac where "q = Inl (Inl qac)" | (ARest) qar where "q = Inl (Inr qar)" | (UCore) quc where "q = Inr (Inl quc)" | (URest) qur where "q = Inr (Inr qur)" using fuse_callee.cases by blast then show "?lhs (((sac, sar), (suc, sur)), (sc, sr)) q = ?rhs (((sac, sar), (suc, sur)), (sc, sr)) q" for sac sar suc sur sc sr proof cases case ACore have "map_spmf rprodl (exec_gpv (fused_resource.fuse core rest) (left_gpv (map_gpv (map_prod Inl (λs1'. (s1', suc, sur))) id (left_gpv (map_gpv (map_prod Inl (λs1'. (s1', sar))) id (cnv_adv_core sac qac))))) (sc, sr)) = (map_spmf (map_prod (Inl ∘ Inl) (?tri ∘ prod.swap ∘ Pair ((sar, sur), sr))) (map_spmf (λ((oadv, s_adv'), s_core'). (oadv, (s_adv', suc), s_core')) (exec_gpv (cfunc_adv core) (cnv_adv_core sac qac) sc)))" proof(induction arbitrary: sc cnv_adv_core rule: exec_gpv_fixp_parallel_induct) case adm show ?case by simp case bottom show ?case by simp case (step execl execr) show ?case apply(clarsimp simp add: gpv.map_sel map_bind_spmf bind_map_spmf intro!: bind_spmf_cong[OF refl] split!: generat.split) apply(subst step.IH[unfolded id_def]) apply(simp add: spmf.map_comp o_def) done qed then show ?thesis using ACore by(simp add: apply_state_iso_def iso_trisplit_def map_spmf_conv_bind_spmf[symmetric] spmf.map_comp o_def split_def) next case ARest have "bind_spmf (foldl_spmf (cpoke core) (return_spmf sc) es) (λsc'. map_spmf rprodl (exec_gpv (fused_resource.fuse core rest) (left_gpv (map_gpv (map_prod Inl (λs1'. (s1', suc, sur))) id (right_gpv (map_gpv (map_prod Inr (Pair sac)) id (cnv_adv_rest sar qar))))) (sc', sr))) = bind_spmf (exec_gpv (λ(s, es) q. map_spmf (λ((out, e), s'). (out, s', es @ e)) (rfunc_adv rest s q)) (cnv_adv_rest sar qar) (sr, es)) (map_spmf (map_prod id ?tri) ∘ ((λ((o_rfunc, e_lst), s_rfunc). map_spmf (λs_notify. (Inl (Inr o_rfunc), s_notify, s_rfunc)) (map_spmf (Pair (sac, suc)) (foldl_spmf (cpoke core) (return_spmf sc) e_lst))) ∘ (λ((oadv, s_adv'), s_rest', es). ((oadv, es), (s_adv', sur), s_rest'))))" for es proof(induction arbitrary: sc sr es cnv_adv_rest rule: exec_gpv_fixp_parallel_induct) case adm then show ?case by simp case bottom then show ?case by simp case (step execl execr) show ?case apply(clarsimp simp add: gpv.map_sel map_bind_spmf bind_map_spmf) apply(subst bind_commute_spmf) apply(clarsimp simp add: gpv.map_sel map_bind_spmf bind_map_spmf spmf.map_comp o_def map_spmf_conv_bind_spmf[symmetric] intro!: bind_spmf_cong[OF refl] split!: generat.split) apply(subst bind_commute_spmf) apply(clarsimp simp add: gpv.map_sel map_bind_spmf bind_map_spmf spmf.map_comp o_def map_spmf_conv_bind_spmf[symmetric] intro!: bind_spmf_cong[OF refl] split!: generat.split) apply(simp add: bind_spmf_assoc[symmetric] bind_foldl_spmf_return foldl_spmf_append[symmetric] del: bind_spmf_assoc ) apply(subst step.IH[unfolded id_def]) apply(simp add: split_def o_def spmf.map_comp) done qed from this[of "[]"] show ?thesis using ARest by(simp add: apply_state_iso_def iso_trisplit_def map_bind_spmf bind_map_spmf map_spmf_conv_bind_spmf[symmetric] foldl_spmf_pair_right) next case UCore have "map_spmf rprodl (exec_gpv (fused_resource.fuse core rest) (right_gpv (map_gpv (map_prod Inr (Pair (sac, sar))) id (left_gpv (map_gpv (map_prod Inl (λs1'. (s1', sur))) id (cnv_usr_core suc quc))))) (sc, sr)) = (map_spmf (map_prod (Inr ∘ Inl) (?tri ∘ prod.swap ∘ Pair ((sar, sur), sr))) (map_spmf (λ((ousr, s_usr'), s_core'). (ousr, (sac, s_usr'), s_core')) (exec_gpv (cfunc_usr core) (cnv_usr_core suc quc) sc)))" proof(induction arbitrary: sc cnv_usr_core rule: exec_gpv_fixp_parallel_induct) case adm show ?case by simp case bottom show ?case by simp case (step execl execr) show ?case apply(clarsimp simp add: gpv.map_sel map_bind_spmf bind_map_spmf intro!: bind_spmf_cong[OF refl] split!: generat.split) apply(subst step.IH[unfolded id_def]) apply(simp add: spmf.map_comp o_def) done qed then show ?thesis using UCore by(simp add: apply_state_iso_def iso_trisplit_def map_spmf_conv_bind_spmf[symmetric] spmf.map_comp o_def split_def) next case URest have "bind_spmf (foldl_spmf (cpoke core) (return_spmf sc) es) (λsc'. map_spmf rprodl (exec_gpv (fused_resource.fuse core rest) (right_gpv (map_gpv (map_prod Inr (Pair (sac, sar))) id (right_gpv (map_gpv (map_prod Inr (Pair suc)) id (cnv_usr_rest sur qur))))) (sc', sr))) = bind_spmf (exec_gpv (λ(s, es) q. map_spmf (λ((out, e), s'). (out, s', es @ e)) (rfunc_usr rest s q)) (cnv_usr_rest sur qur) (sr, es)) (map_spmf (map_prod id ?tri) ∘ ((λ((o_rfunc, e_lst), s_rfunc). map_spmf (λs_notify. (Inr (Inr o_rfunc), s_notify, s_rfunc)) (map_spmf (Pair (sac, suc)) (foldl_spmf (cpoke core) (return_spmf sc) e_lst))) ∘ (λ((ousr, s_usr'), s_rest', es). ((ousr, es), (sar, s_usr'), s_rest'))))" for es proof(induction arbitrary: sc sr es cnv_usr_rest rule: exec_gpv_fixp_parallel_induct) case adm then show ?case by simp case bottom then show ?case by simp case (step execl execr) show ?case apply(clarsimp simp add: gpv.map_sel map_bind_spmf bind_map_spmf) apply(subst bind_commute_spmf) apply(clarsimp simp add: gpv.map_sel map_bind_spmf bind_map_spmf spmf.map_comp o_def map_spmf_conv_bind_spmf[symmetric] intro!: bind_spmf_cong[OF refl] split!: generat.split) apply(subst bind_commute_spmf) apply(clarsimp simp add: gpv.map_sel map_bind_spmf bind_map_spmf spmf.map_comp o_def map_spmf_conv_bind_spmf[symmetric] intro!: bind_spmf_cong[OF refl] split!: generat.split) apply(simp add: bind_spmf_assoc[symmetric] bind_foldl_spmf_return foldl_spmf_append[symmetric] del: bind_spmf_assoc ) apply(subst step.IH[unfolded id_def]) apply(simp add: split_def o_def spmf.map_comp) done qed from this[of "[]"] show ?thesis using URest by(simp add: apply_state_iso_def iso_trisplit_def map_bind_spmf bind_map_spmf map_spmf_conv_bind_spmf[symmetric] foldl_spmf_pair_right) qed qed lemma attach_parallel_fuse': "(CNV cnv_adv_core s_a_c |₌ CNV cnv_adv_rest s_a_r) |₌ (CNV cnv_usr_core s_u_c |₌ CNV cnv_usr_rest s_u_r) ⊳ RES (fused_resource.fuse core rest) (s_r_c, s_r_r) = RES (fused_resource.fuse (attach_core cnv_adv_core cnv_usr_core core) (attach_rest cnv_adv_rest cnv_usr_rest f_init rest)) (((s_a_c, s_u_c), s_r_c), ((s_a_r, s_u_r), s_r_r))" apply (fold conv_callee_parallel) (*goal: ‹(CNV cnv_adv_core s_a_c |₌ CNV cnv_adv_rest s_a_r) |₌ CNV cnv_usr_core s_u_c |₌ CNV cnv_usr_rest s_u_r ⊳ RES (fused_resource.fuse core rest) (s_r_c, s_r_r) = RES (fused_resource.fuse (attach_core cnv_adv_core cnv_usr_core core) (attach_rest cnv_adv_rest cnv_usr_rest f_init rest)) (((s_a_c, s_u_c), s_r_c), (s_a_r, s_u_r), s_r_r)›*) apply (unfold attach_CNV_RES (*‹CNV ?callee ?s ⊳ RES ?res ?s' = RES (attach_callee ?callee ?res) (?s, ?s')›*)) (*goal: ‹CNV ((cnv_adv_core ‡⇩I cnv_adv_rest) ‡⇩I cnv_usr_core ‡⇩I cnv_usr_rest) ((s_a_c, s_a_r), s_u_c, s_u_r) ⊳ RES (fused_resource.fuse core rest) (s_r_c, s_r_r) = RES (fused_resource.fuse (attach_core cnv_adv_core cnv_usr_core core) (attach_rest cnv_adv_rest cnv_usr_rest f_init rest)) (((s_a_c, s_u_c), s_r_c), (s_a_r, s_u_r), s_r_r)›*) apply (subst attach_callee_fuse (*‹attach_callee ((?cnv_adv_core ‡⇩I ?cnv_adv_rest) ‡⇩I ?cnv_usr_core ‡⇩I ?cnv_usr_rest) (fused_resource.fuse ?core ?rest) = apply_state_iso iso_trisplit (fused_resource.fuse (attach_core ?cnv_adv_core ?cnv_usr_core ?core) (attach_rest ?cnv_adv_rest ?cnv_usr_rest ?f_init ?rest))›*)) (*goal: ‹RES (attach_callee (((cnv_adv_core::'q::type ⇒ 'a::type ⇒ ('e::type × 'q::type, 'i::type, 'm::type) gpv) ‡⇩I (cnv_adv_rest::'r::type ⇒ 'b::type ⇒ ('f::type × 'r::type, 'j::type, 'n::type) gpv)) ‡⇩I (cnv_usr_core::'s::type ⇒ 'c::type ⇒ ('g::type × 's::type, 'k::type, 'o::type) gpv) ‡⇩I (cnv_usr_rest::'t::type ⇒ 'd::type ⇒ ('h::type × 't::type, 'l::type, 'p::type) gpv)) (fused_resource.fuse (core::('u::type, 'w::type, 'i::type, 'k::type, 'm::type, 'o::type) core) (rest::('v::type, 'w::type, 'j::type, 'l::type, 'n::type, 'p::type, 'x::type) rest_scheme))) (((s_a_c::'q::type, s_a_r::'r::type), s_u_c::'s::type, s_u_r::'t::type), s_r_c::'u::type, s_r_r::'v::type) = RES (fused_resource.fuse (attach_core cnv_adv_core cnv_usr_core core) (attach_rest cnv_adv_rest cnv_usr_rest (f_init::'x::type ⇒ 'y::type) rest)) (((s_a_c, s_u_c), s_r_c), (s_a_r, s_u_r), s_r_r)›*) apply (subst resource_of_oracle_state_iso (*‹state_iso ?fg ⟹ RES (apply_state_iso ?fg ?oracle) ?s = RES ?oracle (snd ?fg ?s)›*)) (*goals: 1. ‹state_iso iso_trisplit› 2. ‹RES (fused_resource.fuse (attach_core (cnv_adv_core::'q ⇒ 'a ⇒ ('e × 'q, 'i, 'm) gpv) (cnv_usr_core::'s ⇒ 'c ⇒ ('g × 's, 'k, 'o) gpv) (core::('u, 'w, 'i, 'k, 'm, 'o) core)) (attach_rest (cnv_adv_rest::'r ⇒ 'b ⇒ ('f × 'r, 'j, 'n) gpv) (cnv_usr_rest::'t ⇒ 'd ⇒ ('h × 't, 'l, 'p) gpv) (?f_init::'x ⇒ ?'ya) (rest::('v, 'w, 'j, 'l, 'n, 'p, 'x) rest_scheme))) (snd iso_trisplit (((s_a_c::'q, s_a_r::'r), s_u_c::'s, s_u_r::'t), s_r_c::'u, s_r_r::'v)) = RES (fused_resource.fuse (attach_core cnv_adv_core cnv_usr_core core) (attach_rest cnv_adv_rest cnv_usr_rest (f_init::'x ⇒ 'y) rest)) (((s_a_c, s_u_c), s_r_c), (s_a_r, s_u_r), s_r_r)› discuss goal 1*) apply simp (*discuss goal 2*) apply (simp add: iso_trisplit_def (*‹iso_trisplit = (λ(((s11, s12), s13), (s21, s22), s23). (((s11, s21), s12, s22), s13, s23), λ(((s11, s21), s12, s22), s13, s23). (((s11, s12), s13), (s21, s22), s23))›*)) (*proven 2 subgoals*) .<close> context fixes einit :: 's_event and etran :: "('s_event, 'ievent, 'oevent list) oracle'" and rest :: "('s_rest, 'ievent, 'iadv_rest, 'iusr_rest, 'oadv_rest, 'ousr_rest) rest_wstate" and core :: "('s_core, 'oevent, 'iadv_core, 'iusr_core, 'oadv_core, 'ousr_core) core" begin primcorec translate_rest :: "('s_event × 's_rest, 'oevent, 'iadv_rest, 'iusr_rest, 'oadv_rest, 'ousr_rest) rest_wstate" where "rinit translate_rest = (einit, rinit rest)" | "rfunc_adv translate_rest = translate_eoracle etran (extend_state_oracle (rfunc_adv rest))" | "rfunc_usr translate_rest = translate_eoracle etran (extend_state_oracle (rfunc_usr rest))" primcorec translate_core :: "('s_event × 's_core, 'ievent, 'iadv_core, 'iusr_core, 'oadv_core, 'ousr_core) core" where "cpoke translate_core = (λ(s_event, s_core) event. bind_spmf (etran s_event event) (λ(events, s_event'). map_spmf (λs_core'. (s_event', s_core')) (foldl_spmf (cpoke core) (return_spmf s_core) events)))" | "cfunc_adv translate_core = extend_state_oracle (cfunc_adv core)" | "cfunc_usr translate_core = extend_state_oracle (cfunc_usr core)" lemma WT_translate_rest [WT_intro]: assumes "WT_rest ℐ_adv ℐ_usr I_rest rest" shows "WT_rest ℐ_adv ℐ_usr (pred_prod (λ_. True) I_rest) translate_rest" apply (rule WT_rest.intros (*‹⟦⋀s x y es s'. ⟦((y, es), s') ∈ set_spmf (rfunc_adv ?rest s x); x ∈ outs_ℐ ?ℐ_adv; ?I s⟧ ⟹ y ∈ responses_ℐ ?ℐ_adv x ∧ ?I s'; ⋀s x y es s'. ⟦((y, es), s') ∈ set_spmf (rfunc_usr ?rest s x); x ∈ outs_ℐ ?ℐ_usr; ?I s⟧ ⟹ y ∈ responses_ℐ ?ℐ_usr x ∧ ?I s'; ?I (rinit ?rest)⟧ ⟹ WT_rest ?ℐ_adv ?ℐ_usr ?I ?rest›*)) (*goals: 1. ‹⋀s x y es s'. ⟦((y, es), s') ∈ set_spmf (rfunc_adv local.translate_rest s x); x ∈ outs_ℐ ℐ_adv; pred_prod (λ_. True) I_rest s⟧ ⟹ y ∈ responses_ℐ ℐ_adv x ∧ pred_prod (λ_. True) I_rest s'› 2. ‹⋀s x y es s'. ⟦((y, es), s') ∈ set_spmf (rfunc_usr local.translate_rest s x); x ∈ outs_ℐ ℐ_usr; pred_prod (λ_. True) I_rest s⟧ ⟹ y ∈ responses_ℐ ℐ_usr x ∧ pred_prod (λ_. True) I_rest s'› 3. ‹pred_prod (λ_. True) I_rest (rinit local.translate_rest)› discuss goal 1*) apply ((auto simp add: translate_eoracle_def (*‹translate_eoracle ?translator ?eoracle ?state ?inp ≡ ?eoracle ?state ?inp ⤜ (λ((out, e_in), s). let conc = λ(es, st) e. map_spmf (map_prod ((@) es) id) (?translator st e) in foldl_spmf conc (return_spmf ([], fst s)) e_in ⤜ (λ(e_out, s_event). return_spmf ((out, e_out), s_event, snd s)))›*) simp add: WT_restD_rinit[OF assms] (*‹I_rest (rinit rest)›*) dest!: WT_restD(1,2)[OF assms] (*‹⟦((?y, ?es), ?s') ∈ set_spmf (rfunc_adv rest ?s ?x); ?x ∈ outs_ℐ ℐ_adv; I_rest ?s⟧ ⟹ ?y ∈ responses_ℐ ℐ_adv ?x ∧ I_rest ?s'› ‹⟦((?y, ?es), ?s') ∈ set_spmf (rfunc_usr rest ?s ?x); ?x ∈ outs_ℐ ℐ_usr; I_rest ?s⟧ ⟹ ?y ∈ responses_ℐ ℐ_usr ?x ∧ I_rest ?s'›*))[1]) (*discuss goal 2*) apply ((auto simp add: translate_eoracle_def (*‹translate_eoracle ?translator ?eoracle ?state ?inp ≡ ?eoracle ?state ?inp ⤜ (λ((out, e_in), s). let conc = λ(es, st) e. map_spmf (map_prod ((@) es) id) (?translator st e) in foldl_spmf conc (return_spmf ([], fst s)) e_in ⤜ (λ(e_out, s_event). return_spmf ((out, e_out), s_event, snd s)))›*) simp add: WT_restD_rinit[OF assms] (*‹I_rest (rinit rest)›*) dest!: WT_restD(1,2)[OF assms] (*‹⟦((?y, ?es), ?s') ∈ set_spmf (rfunc_adv rest ?s ?x); ?x ∈ outs_ℐ ℐ_adv; I_rest ?s⟧ ⟹ ?y ∈ responses_ℐ ℐ_adv ?x ∧ I_rest ?s'› ‹⟦((?y, ?es), ?s') ∈ set_spmf (rfunc_usr rest ?s ?x); ?x ∈ outs_ℐ ℐ_usr; I_rest ?s⟧ ⟹ ?y ∈ responses_ℐ ℐ_usr ?x ∧ I_rest ?s'›*))[1]) (*discuss goal 3*) apply ((auto simp add: translate_eoracle_def (*‹translate_eoracle ?translator ?eoracle ?state ?inp ≡ ?eoracle ?state ?inp ⤜ (λ((out, e_in), s). let conc = λ(es, st) e. map_spmf (map_prod ((@) es) id) (?translator st e) in foldl_spmf conc (return_spmf ([], fst s)) e_in ⤜ (λ(e_out, s_event). return_spmf ((out, e_out), s_event, snd s)))›*) simp add: WT_restD_rinit[OF assms] (*‹I_rest (rinit rest)›*) dest!: WT_restD(1,2)[OF assms] (*‹⟦((?y, ?es), ?s') ∈ set_spmf (rfunc_adv rest ?s ?x); ?x ∈ outs_ℐ ℐ_adv; I_rest ?s⟧ ⟹ ?y ∈ responses_ℐ ℐ_adv ?x ∧ I_rest ?s'› ‹⟦((?y, ?es), ?s') ∈ set_spmf (rfunc_usr rest ?s ?x); ?x ∈ outs_ℐ ℐ_usr; I_rest ?s⟧ ⟹ ?y ∈ responses_ℐ ℐ_usr ?x ∧ I_rest ?s'›*))[1]) (*proven 3 subgoals*) . lemma fused_resource_move_translate: "fused_resource.fuse core translate_rest = apply_state_iso iso_swapar (fused_resource.fuse translate_core rest)" proof (-) (*goal: ‹fused_resource.fuse core local.translate_rest = apply_state_iso iso_swapar (fused_resource.fuse local.translate_core rest)›*) note [simp] = exec_gpv_bind (*‹exec_gpv ?callee (?c ⤜ ?f) ?s = exec_gpv ?callee ?c ?s ⤜ (λxa. case xa of (x, s') ⇒ exec_gpv ?callee (?f x) s')›*) spmf.map_comp (*‹map_spmf ?f (map_spmf ?g ?p) = map_spmf (?f ∘ ?g) ?p›*) o_def (*‹?f ∘ ?g = (λx. ?f (?g x))›*) map_bind_spmf (*‹map_spmf ?f (?p ⤜ ?g) = ?p ⤜ map_spmf ?f ∘ ?g›*) bind_map_spmf (*‹map_spmf ?f ?p ⤜ ?g = ?p ⤜ ?g ∘ ?f›*) bind_spmf_const (*‹(?p::?'b spmf) ⤜ (λx::?'b. ?q::?'a spmf) = scale_spmf (weight_spmf ?p) ?q›*) show "?thesis" (*goal: ‹fused_resource.fuse (core::('s_core::type, 'oevent::type, 'iadv_core::type, 'iusr_core::type, 'oadv_core::type, 'ousr_core::type) core) local.translate_rest = apply_state_iso iso_swapar (fused_resource.fuse local.translate_core (rest::('s_rest::type, 'ievent::type, 'iadv_rest::type, 'iusr_rest::type, 'oadv_rest::type, 'ousr_rest::type, 's_rest::type) rest_scheme))›*) apply (rule ext (*‹(⋀x. ?f x = ?g x) ⟹ ?f = ?g›*)) (*goal: ‹fused_resource.fuse (core::('s_core::type, 'oevent::type, 'iadv_core::type, 'iusr_core::type, 'oadv_core::type, 'ousr_core::type) core) local.translate_rest = apply_state_iso iso_swapar (fused_resource.fuse local.translate_core (rest::('s_rest::type, 'ievent::type, 'iadv_rest::type, 'iusr_rest::type, 'oadv_rest::type, 'ousr_rest::type, 's_rest::type) rest_scheme))›*) apply (rule ext (*‹(⋀x. ?f x = ?g x) ⟹ ?f = ?g›*)) (*goal: ‹⋀x. fused_resource.fuse core local.translate_rest x = apply_state_iso iso_swapar (fused_resource.fuse local.translate_core rest) x›*) subgoal for s and query apply (cases s) (*goal: ‹fused_resource.fuse core local.translate_rest s query = apply_state_iso iso_swapar (fused_resource.fuse local.translate_core rest) s query›*) subgoal for s_core and s_event and s_rest apply (cases query) (*goal: ‹(s::'s_core × 's_event × 's_rest) = (s_core::'s_core, s_event::'s_event, s_rest::'s_rest) ⟹ fused_resource.fuse (core::('s_core, 'oevent, 'iadv_core, 'iusr_core, 'oadv_core, 'ousr_core) core) local.translate_rest s (query::('iadv_core + 'iadv_rest) + 'iusr_core + 'iusr_rest) = apply_state_iso iso_swapar (fused_resource.fuse local.translate_core (rest::('s_rest, 'ievent, 'iadv_rest, 'iusr_rest, 'oadv_rest, 'ousr_rest, 's_rest) rest_scheme)) s query›*) subgoal for q_adv apply (cases q_adv) (*goal: ‹⟦s = (s_core, s_event, s_rest); query = Inl q_adv⟧ ⟹ fused_resource.fuse core local.translate_rest s query = apply_state_iso iso_swapar (fused_resource.fuse local.translate_core rest) s query›*) subgoal for q_acore by (simp add: apply_state_iso_def (*‹apply_state_iso ≡ λ(f, g). map_fun g (map_fun id (map_spmf (map_prod id f)))›*) iso_swapar_def (*‹iso_swapar = (λ((sm, s1), s2). (s1, sm, s2), λ(s1, sm, s2). ((sm, s1), s2))›*) fused_resource.fuse.simps (*‹fused_resource.fuse ?core ?rest ?state (Inl (Inl ?iadv_core)) = (let handle = map_prod (Inl ∘ Inl) (prod.swap ∘ Pair (snd ?state)) in cfunc_adv ?core (fst ?state) ?iadv_core ⤜ (λos_cfunc. return_spmf (handle os_cfunc)))› ‹fused_resource.fuse ?core ?rest ?state (Inl (Inr ?iadv_rest)) = rfunc_adv ?rest (snd ?state) ?iadv_rest ⤜ (λ((o_rfunc, e_lst), s_rfunc). foldl_spmf (cpoke ?core) (return_spmf (fst ?state)) e_lst ⤜ (λs_notify. return_spmf ((Inl ∘ Inr) o_rfunc, s_notify, s_rfunc)))› ‹fused_resource.fuse ?core ?rest ?state (Inr (Inl ?iusr_core)) = (let handle = map_prod (Inr ∘ Inl) (prod.swap ∘ Pair (snd ?state)) in cfunc_usr ?core (fst ?state) ?iusr_core ⤜ (λos_cfunc. return_spmf (handle os_cfunc)))› ‹fused_resource.fuse ?core ?rest ?state (Inr (Inr ?iusr_rest)) = rfunc_usr ?rest (snd ?state) ?iusr_rest ⤜ (λ((o_rfunc, e_lst), s_rfunc). foldl_spmf (cpoke ?core) (return_spmf (fst ?state)) e_lst ⤜ (λs_notify. return_spmf ((Inr ∘ Inr) o_rfunc, s_notify, s_rfunc)))›*) split_def (*‹case_prod = (λc p. c (fst p) (snd p))›*) map_prod_def (*‹map_prod ?f ?g = (λ(x, y). (?f x, ?g y))›*)) subgoal for q_arest apply (simp add: apply_state_iso_def (*‹apply_state_iso ≡ λ(f, g). map_fun g (map_fun id (map_spmf (map_prod id f)))›*) iso_swapar_def (*‹iso_swapar = (λ((sm, s1), s2). (s1, sm, s2), λ(s1, sm, s2). ((sm, s1), s2))›*) fused_resource.fuse.simps (*‹fused_resource.fuse ?core ?rest ?state (Inl (Inl ?iadv_core)) = (let handle = map_prod (Inl ∘ Inl) (prod.swap ∘ Pair (snd ?state)) in cfunc_adv ?core (fst ?state) ?iadv_core ⤜ (λos_cfunc. return_spmf (handle os_cfunc)))› ‹fused_resource.fuse ?core ?rest ?state (Inl (Inr ?iadv_rest)) = rfunc_adv ?rest (snd ?state) ?iadv_rest ⤜ (λ((o_rfunc, e_lst), s_rfunc). foldl_spmf (cpoke ?core) (return_spmf (fst ?state)) e_lst ⤜ (λs_notify. return_spmf ((Inl ∘ Inr) o_rfunc, s_notify, s_rfunc)))› ‹fused_resource.fuse ?core ?rest ?state (Inr (Inl ?iusr_core)) = (let handle = map_prod (Inr ∘ Inl) (prod.swap ∘ Pair (snd ?state)) in cfunc_usr ?core (fst ?state) ?iusr_core ⤜ (λos_cfunc. return_spmf (handle os_cfunc)))› ‹fused_resource.fuse ?core ?rest ?state (Inr (Inr ?iusr_rest)) = rfunc_usr ?rest (snd ?state) ?iusr_rest ⤜ (λ((o_rfunc, e_lst), s_rfunc). foldl_spmf (cpoke ?core) (return_spmf (fst ?state)) e_lst ⤜ (λs_notify. return_spmf ((Inr ∘ Inr) o_rfunc, s_notify, s_rfunc)))›*)) (*goal: ‹⟦s = (s_core, s_event, s_rest); query = Inl q_adv; q_adv = Inr q_arest⟧ ⟹ fused_resource.fuse core local.translate_rest s query = apply_state_iso iso_swapar (fused_resource.fuse local.translate_core rest) s query›*) apply (simp add: translate_eoracle_def (*‹translate_eoracle ?translator ?eoracle ?state ?inp ≡ ?eoracle ?state ?inp ⤜ (λ((out, e_in), s). let conc = λ(es, st) e. map_spmf (map_prod ((@) es) id) (?translator st e) in foldl_spmf conc (return_spmf ([], fst s)) e_in ⤜ (λ(e_out, s_event). return_spmf ((out, e_out), s_event, snd s)))›*) split_def (*‹case_prod = (λc p. c (fst p) (snd p))›*)) (*goal: ‹⟦s = (s_core, s_event, s_rest); query = Inl (Inr q_arest); q_adv = Inr q_arest⟧ ⟹ translate_eoracle etran †(rfunc_adv rest) (s_event, s_rest) q_arest ⤜ (λ((o_rfunc, e_lst), s_rfunc). foldl_spmf (cpoke core) (return_spmf s_core) e_lst ⤜ (λs_notify. return_spmf (Inl (Inr o_rfunc), s_notify, s_rfunc))) = rfunc_adv rest s_rest q_arest ⤜ (λx. map_spmf (map_prod id (λ((sm, s1), s2). (s1, sm, s2))) (case x of (x, xa) ⇒ (case x of (o_rfunc, e_lst) ⇒ λs_rfunc. foldl_spmf (λ(s_event, s_core) event. etran s_event event ⤜ (λ(events, s_event'). map_spmf (Pair s_event') (foldl_spmf (cpoke core) (return_spmf s_core) events))) (return_spmf (s_event, s_core)) e_lst ⤜ (λs_notify. return_spmf (Inl (Inr o_rfunc), s_notify, s_rfunc))) xa))›*) apply (rule bind_spmf_cong[OF refl] (*‹(⋀x::?'a::type. x ∈ set_spmf (?p::?'a::type spmf) ⟹ (?f::?'a::type ⇒ ?'b::type spmf) x = (?g::?'a::type ⇒ ?'b::type spmf) x) ⟹ ?p ⤜ ?f = ?p ⤜ ?g›*)) (*goal: ‹⟦s = (s_core, s_event, s_rest); query = Inl (Inr q_arest); q_adv = Inr q_arest⟧ ⟹ rfunc_adv rest s_rest q_arest ⤜ (λy. foldl_spmf (λp e. map_spmf (map_prod ((@) (fst p)) id) (etran (snd p) e)) (return_spmf ([], s_event)) (snd (fst y)) ⤜ (λya. foldl_spmf (cpoke core) (return_spmf s_core) (fst ya) ⤜ (λs_notify. return_spmf (Inl (Inr (fst (fst y))), s_notify, snd ya, snd y)))) = rfunc_adv rest s_rest q_arest ⤜ (λx. foldl_spmf (λp event. etran (fst p) event ⤜ (λpa. map_spmf (Pair (snd pa)) (foldl_spmf (cpoke core) (return_spmf (snd p)) (fst pa)))) (return_spmf (s_event, s_core)) (snd (fst x)) ⤜ (λxa. return_spmf (Inl (Inr (fst (fst x))), snd xa, fst xa, snd x)))›*) apply (subst foldl_spmf_chain[simplified split_def] (*‹foldl_spmf (λp event. map_spmf (map_prod ((@) (fst p)) id) (?fff (snd p) event)) (return_spmf ([], ?s_event)) ?ievents ⤜ (λp. foldl_spmf ?ggg (return_spmf ?s_core) (fst p) ⤜ (λs_core'. return_spmf (?f s_core' (snd p)))) = foldl_spmf (λp event. ?fff (fst p) event ⤜ (λpa. map_spmf (Pair (snd pa)) (foldl_spmf ?ggg (return_spmf (snd p)) (fst pa)))) (return_spmf (?s_event, ?s_core)) ?ievents ⤜ (λp. return_spmf (?f (snd p) (fst p)))›*)) (*goal: ‹⋀x::('oadv_rest × 'ievent list) × 's_rest. ⟦(s::'s_core × 's_event × 's_rest) = (s_core::'s_core, s_event::'s_event, s_rest::'s_rest); (query::('iadv_core + 'iadv_rest) + 'iusr_core + 'iusr_rest) = Inl (Inr (q_arest::'iadv_rest)); (q_adv::'iadv_core + 'iadv_rest) = Inr q_arest; x ∈ set_spmf (rfunc_adv (rest::('s_rest, 'ievent, 'iadv_rest, 'iusr_rest, 'oadv_rest, 'ousr_rest, 's_rest) rest_scheme) s_rest q_arest)⟧ ⟹ foldl_spmf (λ(p::'oevent list × 's_event) e::'ievent. map_spmf (map_prod ((@) (fst p)) id) ((etran::'s_event ⇒ 'ievent ⇒ ('oevent list × 's_event) spmf) (snd p) e)) (return_spmf ([], s_event)) (snd (fst x)) ⤜ (λy::'oevent list × 's_event. foldl_spmf (cpoke (core::('s_core, 'oevent, 'iadv_core, 'iusr_core, 'oadv_core, 'ousr_core) core)) (return_spmf s_core) (fst y) ⤜ (λs_notify::'s_core. return_spmf (Inl (Inr (fst (fst x))), s_notify, snd y, snd x))) = foldl_spmf (λ(p::'s_event × 's_core) event::'ievent. etran (fst p) event ⤜ (λpa::'oevent list × 's_event. map_spmf (Pair (snd pa)) (foldl_spmf (cpoke core) (return_spmf (snd p)) (fst pa)))) (return_spmf (s_event, s_core)) (snd (fst x)) ⤜ (λxa::'s_event × 's_core. return_spmf (Inl (Inr (fst (fst x))), snd xa, fst xa, snd x))›*) by simp . subgoal for q_usr apply (cases q_usr) (*goal: ‹⟦s = (s_core, s_event, s_rest); query = Inr q_usr⟧ ⟹ fused_resource.fuse core local.translate_rest s query = apply_state_iso iso_swapar (fused_resource.fuse local.translate_core rest) s query›*) subgoal for q_ucore by (simp add: apply_state_iso_def (*‹apply_state_iso ≡ λ(f, g). map_fun g (map_fun id (map_spmf (map_prod id f)))›*) iso_swapar_def (*‹iso_swapar = (λ((sm, s1), s2). (s1, sm, s2), λ(s1, sm, s2). ((sm, s1), s2))›*) fused_resource.fuse.simps (*‹fused_resource.fuse ?core ?rest ?state (Inl (Inl ?iadv_core)) = (let handle = map_prod (Inl ∘ Inl) (prod.swap ∘ Pair (snd ?state)) in cfunc_adv ?core (fst ?state) ?iadv_core ⤜ (λos_cfunc. return_spmf (handle os_cfunc)))› ‹fused_resource.fuse ?core ?rest ?state (Inl (Inr ?iadv_rest)) = rfunc_adv ?rest (snd ?state) ?iadv_rest ⤜ (λ((o_rfunc, e_lst), s_rfunc). foldl_spmf (cpoke ?core) (return_spmf (fst ?state)) e_lst ⤜ (λs_notify. return_spmf ((Inl ∘ Inr) o_rfunc, s_notify, s_rfunc)))› ‹fused_resource.fuse ?core ?rest ?state (Inr (Inl ?iusr_core)) = (let handle = map_prod (Inr ∘ Inl) (prod.swap ∘ Pair (snd ?state)) in cfunc_usr ?core (fst ?state) ?iusr_core ⤜ (λos_cfunc. return_spmf (handle os_cfunc)))› ‹fused_resource.fuse ?core ?rest ?state (Inr (Inr ?iusr_rest)) = rfunc_usr ?rest (snd ?state) ?iusr_rest ⤜ (λ((o_rfunc, e_lst), s_rfunc). foldl_spmf (cpoke ?core) (return_spmf (fst ?state)) e_lst ⤜ (λs_notify. return_spmf ((Inr ∘ Inr) o_rfunc, s_notify, s_rfunc)))›*) split_def (*‹case_prod = (λc p. c (fst p) (snd p))›*) map_prod_def (*‹map_prod ?f ?g = (λ(x, y). (?f x, ?g y))›*)) subgoal for q_urest apply (simp add: apply_state_iso_def (*‹apply_state_iso ≡ λ(f, g). map_fun g (map_fun id (map_spmf (map_prod id f)))›*) iso_swapar_def (*‹iso_swapar = (λ((sm, s1), s2). (s1, sm, s2), λ(s1, sm, s2). ((sm, s1), s2))›*) fused_resource.fuse.simps (*‹fused_resource.fuse ?core ?rest ?state (Inl (Inl ?iadv_core)) = (let handle = map_prod (Inl ∘ Inl) (prod.swap ∘ Pair (snd ?state)) in cfunc_adv ?core (fst ?state) ?iadv_core ⤜ (λos_cfunc. return_spmf (handle os_cfunc)))› ‹fused_resource.fuse ?core ?rest ?state (Inl (Inr ?iadv_rest)) = rfunc_adv ?rest (snd ?state) ?iadv_rest ⤜ (λ((o_rfunc, e_lst), s_rfunc). foldl_spmf (cpoke ?core) (return_spmf (fst ?state)) e_lst ⤜ (λs_notify. return_spmf ((Inl ∘ Inr) o_rfunc, s_notify, s_rfunc)))› ‹fused_resource.fuse ?core ?rest ?state (Inr (Inl ?iusr_core)) = (let handle = map_prod (Inr ∘ Inl) (prod.swap ∘ Pair (snd ?state)) in cfunc_usr ?core (fst ?state) ?iusr_core ⤜ (λos_cfunc. return_spmf (handle os_cfunc)))› ‹fused_resource.fuse ?core ?rest ?state (Inr (Inr ?iusr_rest)) = rfunc_usr ?rest (snd ?state) ?iusr_rest ⤜ (λ((o_rfunc, e_lst), s_rfunc). foldl_spmf (cpoke ?core) (return_spmf (fst ?state)) e_lst ⤜ (λs_notify. return_spmf ((Inr ∘ Inr) o_rfunc, s_notify, s_rfunc)))›*)) (*goal: ‹⟦s = (s_core, s_event, s_rest); query = Inr q_usr; q_usr = Inr q_urest⟧ ⟹ fused_resource.fuse core local.translate_rest s query = apply_state_iso iso_swapar (fused_resource.fuse local.translate_core rest) s query›*) apply (simp add: translate_eoracle_def (*‹translate_eoracle ?translator ?eoracle ?state ?inp ≡ ?eoracle ?state ?inp ⤜ (λ((out, e_in), s). let conc = λ(es, st) e. map_spmf (map_prod ((@) es) id) (?translator st e) in foldl_spmf conc (return_spmf ([], fst s)) e_in ⤜ (λ(e_out, s_event). return_spmf ((out, e_out), s_event, snd s)))›*) split_def (*‹case_prod = (λc p. c (fst p) (snd p))›*)) (*goal: ‹⟦(s::'s_core × 's_event × 's_rest) = (s_core::'s_core, s_event::'s_event, s_rest::'s_rest); (query::('iadv_core + 'iadv_rest) + 'iusr_core + 'iusr_rest) = Inr (Inr (q_urest::'iusr_rest)); (q_usr::'iusr_core + 'iusr_rest) = Inr q_urest⟧ ⟹ translate_eoracle (etran::'s_event ⇒ 'ievent ⇒ ('oevent list × 's_event) spmf) †(rfunc_usr (rest::('s_rest, 'ievent, 'iadv_rest, 'iusr_rest, 'oadv_rest, 'ousr_rest, 's_rest) rest_scheme)) (s_event, s_rest) q_urest ⤜ (λ((o_rfunc::'ousr_rest, e_lst::'oevent list), s_rfunc::'s_event × 's_rest). foldl_spmf (cpoke (core::('s_core, 'oevent, 'iadv_core, 'iusr_core, 'oadv_core, 'ousr_core) core)) (return_spmf s_core) e_lst ⤜ (λs_notify::'s_core. return_spmf (Inr (Inr o_rfunc), s_notify, s_rfunc))) = rfunc_usr rest s_rest q_urest ⤜ (λx::('ousr_rest × 'ievent list) × 's_rest. map_spmf (map_prod id (λ((sm::'s_event, s1::'s_core), s2::'s_rest). (s1, sm, s2))) (case x of (x::'ousr_rest × 'ievent list, xa::'s_rest) ⇒ (case x of (o_rfunc::'ousr_rest, e_lst::'ievent list) ⇒ λs_rfunc::'s_rest. foldl_spmf (λ(s_event::'s_event, s_core::'s_core) event::'ievent. etran s_event event ⤜ (λ(events::'oevent list, s_event'::'s_event). map_spmf (Pair s_event') (foldl_spmf (cpoke core) (return_spmf s_core) events))) (return_spmf (s_event, s_core)) e_lst ⤜ (λs_notify::'s_event × 's_core. return_spmf (Inr (Inr o_rfunc), s_notify, s_rfunc))) xa))›*) apply (rule bind_spmf_cong[OF refl] (*‹(⋀x. x ∈ set_spmf ?p ⟹ ?f x = ?g x) ⟹ ?p ⤜ ?f = ?p ⤜ ?g›*)) (*goal: ‹⟦s = (s_core, s_event, s_rest); query = Inr (Inr q_urest); q_usr = Inr q_urest⟧ ⟹ rfunc_usr rest s_rest q_urest ⤜ (λy. foldl_spmf (λp e. map_spmf (map_prod ((@) (fst p)) id) (etran (snd p) e)) (return_spmf ([], s_event)) (snd (fst y)) ⤜ (λya. foldl_spmf (cpoke core) (return_spmf s_core) (fst ya) ⤜ (λs_notify. return_spmf (Inr (Inr (fst (fst y))), s_notify, snd ya, snd y)))) = rfunc_usr rest s_rest q_urest ⤜ (λx. foldl_spmf (λp event. etran (fst p) event ⤜ (λpa. map_spmf (Pair (snd pa)) (foldl_spmf (cpoke core) (return_spmf (snd p)) (fst pa)))) (return_spmf (s_event, s_core)) (snd (fst x)) ⤜ (λxa. return_spmf (Inr (Inr (fst (fst x))), snd xa, fst xa, snd x)))›*) apply (subst foldl_spmf_chain[simplified split_def] (*‹foldl_spmf (λ(p::?'b list × ?'c) event::?'d. map_spmf (map_prod ((@) (fst p)) id) ((?fff::?'c ⇒ ?'d ⇒ (?'b list × ?'c) spmf) (snd p) event)) (return_spmf ([], ?s_event::?'c)) (?ievents::?'d list) ⤜ (λp::?'b list × ?'c. foldl_spmf (?ggg::?'e ⇒ ?'b ⇒ ?'e spmf) (return_spmf (?s_core::?'e)) (fst p) ⤜ (λs_core'::?'e. return_spmf ((?f::?'e ⇒ ?'c ⇒ ?'a) s_core' (snd p)))) = foldl_spmf (λ(p::?'c × ?'e) event::?'d. ?fff (fst p) event ⤜ (λpa::?'b list × ?'c. map_spmf (Pair (snd pa)) (foldl_spmf ?ggg (return_spmf (snd p)) (fst pa)))) (return_spmf (?s_event, ?s_core)) ?ievents ⤜ (λp::?'c × ?'e. return_spmf (?f (snd p) (fst p)))›*)) (*goal: ‹⋀x. ⟦s = (s_core, s_event, s_rest); query = Inr (Inr q_urest); q_usr = Inr q_urest; x ∈ set_spmf (rfunc_usr rest s_rest q_urest)⟧ ⟹ foldl_spmf (λp e. map_spmf (map_prod ((@) (fst p)) id) (etran (snd p) e)) (return_spmf ([], s_event)) (snd (fst x)) ⤜ (λy. foldl_spmf (cpoke core) (return_spmf s_core) (fst y) ⤜ (λs_notify. return_spmf (Inr (Inr (fst (fst x))), s_notify, snd y, snd x))) = foldl_spmf (λp event. etran (fst p) event ⤜ (λpa. map_spmf (Pair (snd pa)) (foldl_spmf (cpoke core) (return_spmf (snd p)) (fst pa)))) (return_spmf (s_event, s_core)) (snd (fst x)) ⤜ (λxa. return_spmf (Inr (Inr (fst (fst x))), snd xa, fst xa, snd x))›*) by simp . . . . qed end ― ‹Moving interfaces between rest and core› lemma fuse_ishift_core_to_rest: assumes "cpoke core' = (λs. case_sum (λq. fn s q) (cpoke core s))" and "cfunc_adv core = cfunc_adv core'" and "cfunc_usr core = cfunc_usr core' ⊕⇩O (λs i. map_spmf (Pair (h_out i)) (fn s i))" and "rfunc_adv rest' = (λs q. map_spmf (apfst (apsnd (map Inr))) (rfunc_adv rest s q))" and "rfunc_usr rest' = plus_eoracle (λs i. return_spmf ((h_out i, [i]), s)) (rfunc_usr rest)" shows "fused_resource.fuse core rest = apply_wiring (1⇩w |⇩w lassocr⇩w) (fused_resource.fuse core' rest')" (is "?L = ?R") proof (-) (*goal: ‹fused_resource.fuse core rest = apply_wiring ((id, id) |⇩w lassocr⇩w) (fused_resource.fuse core' rest')›*) note [simp] = fused_resource.fuse.simps (*‹fused_resource.fuse ?core ?rest ?state (Inl (Inl ?iadv_core)) = (let handle = map_prod (Inl ∘ Inl) (prod.swap ∘ Pair (snd ?state)) in cfunc_adv ?core (fst ?state) ?iadv_core ⤜ (λos_cfunc. return_spmf (handle os_cfunc)))› ‹fused_resource.fuse ?core ?rest ?state (Inl (Inr ?iadv_rest)) = rfunc_adv ?rest (snd ?state) ?iadv_rest ⤜ (λ((o_rfunc, e_lst), s_rfunc). foldl_spmf (cpoke ?core) (return_spmf (fst ?state)) e_lst ⤜ (λs_notify. return_spmf ((Inl ∘ Inr) o_rfunc, s_notify, s_rfunc)))› ‹fused_resource.fuse ?core ?rest ?state (Inr (Inl ?iusr_core)) = (let handle = map_prod (Inr ∘ Inl) (prod.swap ∘ Pair (snd ?state)) in cfunc_usr ?core (fst ?state) ?iusr_core ⤜ (λos_cfunc. return_spmf (handle os_cfunc)))› ‹fused_resource.fuse ?core ?rest ?state (Inr (Inr ?iusr_rest)) = rfunc_usr ?rest (snd ?state) ?iusr_rest ⤜ (λ((o_rfunc, e_lst), s_rfunc). foldl_spmf (cpoke ?core) (return_spmf (fst ?state)) e_lst ⤜ (λs_notify. return_spmf ((Inr ∘ Inr) o_rfunc, s_notify, s_rfunc)))›*) apply_wiring_def (*‹apply_wiring = (λ(f, g). map_fun id (map_fun f (map_spmf (map_prod g id))))›*) "lassocr⇩w_def" (*‹lassocr⇩w = (rsuml, lsumr)›*) parallel2_wiring_def (*‹(|⇩w) = (λ(f, g) (f', g'). (map_sum f f', map_sum g g'))›*) plus_eoracle_def (*‹plus_eoracle ?eoracle1.0 ?eoracle2.0 ?state ≡ map_spmf (map_prod (case_sum (map_prod Inl (map Inl)) (map_prod Inr (map Inr))) id) ∘ (?eoracle1.0 ⊕⇩O ?eoracle2.0) ?state›*) map_spmf_conv_bind_spmf (*‹map_spmf ?f ?p = ?p ⤜ (λx. return_spmf (?f x))›*) map_prod_def (*‹map_prod (?f::?'a ⇒ ?'c) (?g::?'b ⇒ ?'d) = (λ(x::?'a, y::?'b). (?f x, ?g y))›*) map_fun_def (*‹map_fun ?f ?g ?h = ?g ∘ ?h ∘ ?f›*) split_def (*‹case_prod = (λc p. c (fst p) (snd p))›*) o_def (*‹(?f::?'b ⇒ ?'c) ∘ (?g::?'a ⇒ ?'b) = (λx::?'a. ?f (?g x))›*) have "?L s q = ?R s q" for s and q apply (cases q; cases s) (*goal: ‹fused_resource.fuse core rest s q = apply_wiring ((id, id) |⇩w lassocr⇩w) (fused_resource.fuse core' rest') s q›*) subgoal for q_adv apply (cases q_adv) (*goals: 1. ‹⋀a. ⟦q = Inl q_adv; s = (aa_, b_); q_adv = Inl a⟧ ⟹ fused_resource.fuse core rest s q = apply_wiring ((id, id) |⇩w lassocr⇩w) (fused_resource.fuse core' rest') s q› 2. ‹⋀ba. ⟦q = Inl q_adv; s = (aa_, b_); q_adv = Inr ba⟧ ⟹ fused_resource.fuse core rest s q = apply_wiring ((id, id) |⇩w lassocr⇩w) (fused_resource.fuse core' rest') s q› discuss goal 1*) apply (simp add: assms( (*‹cpoke core' = (λs. case_sum (fn s) (cpoke core s))› ‹cfunc_adv core = cfunc_adv core'› ‹rfunc_adv rest' = (λs q. map_spmf (apfst (apsnd (map Inr))) (rfunc_adv rest s q))›*) 1, 2, 4)) (*discuss goal 2*) apply (simp add: assms( (*‹cpoke core' = (λs. case_sum (fn s) (cpoke core s))› ‹cfunc_adv core = cfunc_adv core'› ‹rfunc_adv rest' = (λs q. map_spmf (apfst (apsnd (map Inr))) (rfunc_adv rest s q))›*) 1, 2, 4)) (*proven 2 subgoals*) . subgoal for q_usr apply (cases q_usr) (*goal: ‹⟦q = Inr q_usr; s = (a_, ba_)⟧ ⟹ fused_resource.fuse core rest s q = apply_wiring ((id, id) |⇩w lassocr⇩w) (fused_resource.fuse core' rest') s q›*) subgoal for q_usr_core apply (cases q_usr_core) (*goal: ‹⟦q = Inr q_usr; s = (a_, ba_); q_usr = Inl q_usr_core⟧ ⟹ fused_resource.fuse core rest s q = apply_wiring ((id, id) |⇩w lassocr⇩w) (fused_resource.fuse core' rest') s q›*) subgoal for q_nrm by (simp add: assms( (*‹cfunc_usr core = cfunc_usr core' ⊕⇩O (λs i. map_spmf (Pair (h_out i)) (fn s i))›*) 3)) by (simp add: assms( (*‹cpoke core' = (λs. case_sum (fn s) (cpoke core s))› ‹cfunc_usr core = cfunc_usr core' ⊕⇩O (λs i. map_spmf (Pair (h_out i)) (fn s i))› ‹rfunc_usr rest' = plus_eoracle (λs i. return_spmf ((h_out i, [i]), s)) (rfunc_usr rest)›*) 1, 3, 5)) by (simp add: assms( (*‹cpoke core' = (λs. case_sum (fn s) (cpoke core s))› ‹rfunc_usr rest' = plus_eoracle (λs i. return_spmf ((h_out i, [i]), s)) (rfunc_usr rest)›*) 1, 5)) . then show "?thesis" (*goal: ‹fused_resource.fuse (core::('a, 'c, 'd, 'e + 'b, 'f, 'g + 'h) core) (rest::('i, 'c, 'j, 'l, 'k, 'm, 'o) rest_scheme) = apply_wiring ((id, id) |⇩w lassocr⇩w) (fused_resource.fuse (core'::('a, 'b + 'c, 'd, 'e, 'f, 'g) core) (rest'::('i, 'b + 'c, 'j, 'b + 'l, 'k, 'h + 'm, 'n) rest_scheme))›*) by blast qed lemma move_simulator_interface: defines "x_ifunc ≡ (λifunc core (se, sc) q. do { ((out, es), se') ← ifunc se q; sc' ← foldl_spmf (cpoke core) (return_spmf sc) es; return_spmf (out, se', sc') })" assumes "cpoke core' = cpoke (translate_core etran core)" and "cfunc_adv core' = †(cfunc_adv core) ⊕⇩O x_ifunc ifunc core" and "cfunc_usr core' = cfunc_usr (translate_core etran core)" and "rinit rest = (einit, rinit rest')" and "rfunc_adv rest = (λs q. case q of Inl ql ⇒ map_spmf (apfst (map_prod Inl id)) ((ifunc†) s ql) | Inr qr ⇒ map_spmf (apfst (map_prod Inr id)) ((translate_eoracle etran (†(rfunc_adv rest'))) s qr))" and "rfunc_usr rest = translate_eoracle etran (†(rfunc_usr rest'))" shows "fused_resource.fuse core rest = apply_wiring (rassocl⇩w |⇩w (id, id)) (apply_state_iso (rprodl o (apfst prod.swap), (apfst prod.swap) o lprodr) (fused_resource.fuse core' rest'))" (is "?L = ?R") proof (-) (*goal: ‹fused_resource.fuse core rest = apply_wiring (rassocl⇩w |⇩w (id, id)) (apply_state_iso (rprodl ∘ apfst prod.swap, apfst prod.swap ∘ lprodr) (fused_resource.fuse core' rest'))›*) note [simp] = fused_resource.fuse.simps (*‹fused_resource.fuse ?core ?rest ?state (Inl (Inl ?iadv_core)) = (let handle = map_prod (Inl ∘ Inl) (prod.swap ∘ Pair (snd ?state)) in cfunc_adv ?core (fst ?state) ?iadv_core ⤜ (λos_cfunc. return_spmf (handle os_cfunc)))› ‹fused_resource.fuse ?core ?rest ?state (Inl (Inr ?iadv_rest)) = rfunc_adv ?rest (snd ?state) ?iadv_rest ⤜ (λ((o_rfunc, e_lst), s_rfunc). foldl_spmf (cpoke ?core) (return_spmf (fst ?state)) e_lst ⤜ (λs_notify. return_spmf ((Inl ∘ Inr) o_rfunc, s_notify, s_rfunc)))› ‹fused_resource.fuse ?core ?rest ?state (Inr (Inl ?iusr_core)) = (let handle = map_prod (Inr ∘ Inl) (prod.swap ∘ Pair (snd ?state)) in cfunc_usr ?core (fst ?state) ?iusr_core ⤜ (λos_cfunc. return_spmf (handle os_cfunc)))› ‹fused_resource.fuse ?core ?rest ?state (Inr (Inr ?iusr_rest)) = rfunc_usr ?rest (snd ?state) ?iusr_rest ⤜ (λ((o_rfunc, e_lst), s_rfunc). foldl_spmf (cpoke ?core) (return_spmf (fst ?state)) e_lst ⤜ (λs_notify. return_spmf ((Inr ∘ Inr) o_rfunc, s_notify, s_rfunc)))›*) apply_wiring_def (*‹apply_wiring = (λ(f::?'a::type ⇒ ?'c::type, g::?'d::type ⇒ ?'b::type). map_fun id (map_fun f (map_spmf (map_prod g id))))›*) "rassocl⇩w_def" (*‹rassocl⇩w = (lsumr, rsuml)›*) parallel2_wiring_def (*‹(|⇩w) = (λ(f, g) (f', g'). (map_sum f f', map_sum g g'))›*) apply_state_iso_def (*‹apply_state_iso ≡ λ(f, g). map_fun g (map_fun id (map_spmf (map_prod id f)))›*) exec_gpv_bind (*‹exec_gpv (?callee::?'b ⇒ ?'c ⇒ (?'d × ?'b) spmf) ((?c::(?'e, ?'c, ?'d) gpv) ⤜ (?f::?'e ⇒ (?'a, ?'c, ?'d) gpv)) (?s::?'b) = exec_gpv ?callee ?c ?s ⤜ (λxa::?'e × ?'b. case xa of (x::?'e, s'::?'b) ⇒ exec_gpv ?callee (?f x) s')›*) spmf.map_comp (*‹map_spmf ?f (map_spmf ?g ?p) = map_spmf (?f ∘ ?g) ?p›*) map_bind_spmf (*‹map_spmf ?f (?p ⤜ ?g) = ?p ⤜ map_spmf ?f ∘ ?g›*) bind_map_spmf (*‹map_spmf ?f ?p ⤜ ?g = ?p ⤜ ?g ∘ ?f›*) bind_spmf_const (*‹?p ⤜ (λx. ?q) = scale_spmf (weight_spmf ?p) ?q›*) o_def (*‹?f ∘ ?g = (λx. ?f (?g x))›*) split_def (*‹case_prod = (λc p. c (fst p) (snd p))›*) have "?L (sc, st, sr) q = ?R (sc, st, sr) q" for sc and st and sr and q apply (simp add: map_fun_def (*‹map_fun ?f ?g ?h = ?g ∘ ?h ∘ ?f›*) map_prod_def (*‹map_prod ?f ?g = (λ(x, y). (?f x, ?g y))›*) prod.swap_def (*‹prod.swap ?p = (snd ?p, fst ?p)›*) apfst_def (*‹apfst ?f = map_prod ?f id›*) lprodr_def (*‹lprodr = (λ(a, b, c). ((a, b), c))›*) rprodl_def (*‹rprodl = (λ((a, b), c). (a, b, c))›*) id_def (*‹id = (λx. x)›*)) (*goal: ‹fused_resource.fuse core rest (sc, st, sr) q = apply_wiring (rassocl⇩w |⇩w (id, id)) (apply_state_iso (rprodl ∘ apfst prod.swap, apfst prod.swap ∘ lprodr) (fused_resource.fuse core' rest')) (sc, st, sr) q›*) using assms (*‹x_ifunc ≡ λifunc core (se, sc) q. ifunc se q ⤜ (λ((out, es), se'). foldl_spmf (cpoke core) (return_spmf sc) es ⤜ (λsc'. return_spmf (out, se', sc')))› ‹cpoke core' = cpoke (translate_core etran core)› ‹cfunc_adv core' = †(cfunc_adv core) ⊕⇩O x_ifunc ifunc core› ‹cfunc_usr core' = cfunc_usr (translate_core etran core)› ‹rinit rest = (einit, rinit rest')› ‹rfunc_adv (rest::('a::type × 'm::type, 'd::type, 'b::type + 'n::type, 'o::type, 'c::type + 'p::type, 'q::type, 'k::type × 'l::type) rest_scheme) = (λ(s::'a::type × 'm::type) q::'b::type + 'n::type. case q of Inl (ql::'b::type) ⇒ map_spmf (apfst (map_prod Inl id)) ((ifunc::'a::type ⇒ 'b::type ⇒ (('c::type × 'd::type list) × 'a::type) spmf)† s ql) | Inr (qr::'n::type) ⇒ map_spmf (apfst (map_prod Inr id)) (translate_eoracle (etran::'a::type ⇒ 'j::type ⇒ ('d::type list × 'a::type) spmf) †(rfunc_adv (rest'::('m::type, 'j::type, 'n::type, 'o::type, 'p::type, 'q::type, 'l::type) rest_scheme)) s qr))› ‹rfunc_usr rest = translate_eoracle etran †(rfunc_usr rest')›*) apply (cases q) (*goal: ‹fused_resource.fuse core rest (sc, st, sr) q = map_spmf (λx. (map_sum rsuml (λx. x) (fst x), snd (fst (snd x)), fst (fst (snd x)), snd (snd x))) (fused_resource.fuse core' rest' ((st, sc), sr) (map_sum lsumr (λx. x) q))›*) subgoal for q_adv apply (cases q_adv) (*goal: ‹⟦x_ifunc ≡ λifunc core (se, sc) q. ifunc se q ⤜ (λ((out, es), se'). foldl_spmf (cpoke core) (return_spmf sc) es ⤜ (λsc'. return_spmf (out, se', sc'))); cpoke core' = cpoke (translate_core etran core); cfunc_adv core' = †(cfunc_adv core) ⊕⇩O x_ifunc ifunc core; cfunc_usr core' = cfunc_usr (translate_core etran core); rinit rest = (einit, rinit rest'); rfunc_adv rest = (λs q. case q of Inl ql ⇒ map_spmf (apfst (map_prod Inl id)) (ifunc† s ql) | Inr qr ⇒ map_spmf (apfst (map_prod Inr id)) (translate_eoracle etran †(rfunc_adv rest') s qr)); rfunc_usr rest = translate_eoracle etran †(rfunc_usr rest'); q = Inl q_adv⟧ ⟹ fused_resource.fuse core rest (sc, st, sr) q = map_spmf (λx. (map_sum rsuml (λx. x) (fst x), snd (fst (snd x)), fst (fst (snd x)), snd (snd x))) (fused_resource.fuse core' rest' ((st, sc), sr) (map_sum lsumr (λx. x) q))›*) subgoal for q_adv_core by (simp add: map_prod_def (*‹map_prod ?f ?g = (λ(x, y). (?f x, ?g y))›*)) subgoal for q_adv_rest apply (cases q_adv_rest) (*goal: ‹⟦x_ifunc ≡ λifunc core (se, sc) q. ifunc se q ⤜ (λ((out, es), se'). foldl_spmf (cpoke core) (return_spmf sc) es ⤜ (λsc'. return_spmf (out, se', sc'))); cpoke core' = cpoke (translate_core etran core); cfunc_adv core' = †(cfunc_adv core) ⊕⇩O x_ifunc ifunc core; cfunc_usr core' = cfunc_usr (translate_core etran core); rinit rest = (einit, rinit rest'); rfunc_adv rest = (λs q. case q of Inl ql ⇒ map_spmf (apfst (map_prod Inl id)) (ifunc† s ql) | Inr qr ⇒ map_spmf (apfst (map_prod Inr id)) (translate_eoracle etran †(rfunc_adv rest') s qr)); rfunc_usr rest = translate_eoracle etran †(rfunc_usr rest'); q = Inl q_adv; q_adv = Inr q_adv_rest⟧ ⟹ fused_resource.fuse core rest (sc, st, sr) q = map_spmf (λx. (map_sum rsuml (λx. x) (fst x), snd (fst (snd x)), fst (fst (snd x)), snd (snd x))) (fused_resource.fuse core' rest' ((st, sc), sr) (map_sum lsumr (λx. x) q))›*) subgoal for q_adv_rest_ifunc by simp subgoal for q_adv_rest_etran apply (simp add: translate_eoracle_def (*‹translate_eoracle ?translator ?eoracle ?state ?inp ≡ ?eoracle ?state ?inp ⤜ (λ((out, e_in), s). let conc = λ(es, st) e. map_spmf (map_prod ((@) es) id) (?translator st e) in foldl_spmf conc (return_spmf ([], fst s)) e_in ⤜ (λ(e_out, s_event). return_spmf ((out, e_out), s_event, snd s)))›*)) (*goal: ‹⟦x_ifunc::('a::type ⇒ 'b::type ⇒ (('c::type × 'd::type list) × 'a::type) spmf) ⇒ ('e::type, 'd::type, 'f::type, 'g::type, 'h::type, 'i::type) core ⇒ 'a::type × 'e::type ⇒ 'b::type ⇒ ('c::type × 'a::type × 'e::type) spmf ≡ λ(ifunc::'a::type ⇒ 'b::type ⇒ (('c::type × 'd::type list) × 'a::type) spmf) (core::('e::type, 'd::type, 'f::type, 'g::type, 'h::type, 'i::type) core) (se::'a::type, sc::'e::type) q::'b::type. ifunc se q ⤜ (λ((out::'c::type, es::'d::type list), se'::'a::type). foldl_spmf (cpoke core) (return_spmf sc) es ⤜ (λsc'::'e::type. return_spmf (out, se', sc'))); cpoke (core'::('a::type × 'e::type, 'j::type, 'f::type + 'b::type, 'g::type, 'h::type + 'c::type, 'i::type) core) = cpoke (translate_core (etran::'a::type ⇒ 'j::type ⇒ ('d::type list × 'a::type) spmf) (core::('e::type, 'd::type, 'f::type, 'g::type, 'h::type, 'i::type) core)); cfunc_adv core' = †(cfunc_adv core) ⊕⇩O x_ifunc (ifunc::'a::type ⇒ 'b::type ⇒ (('c::type × 'd::type list) × 'a::type) spmf) core; cfunc_usr core' = cfunc_usr (translate_core etran core); rinit (rest::('a::type × 'm::type, 'd::type, 'b::type + 'n::type, 'o::type, 'c::type + 'p::type, 'q::type, 'k::type × 'l::type) rest_scheme) = (einit::'k::type, rinit (rest'::('m::type, 'j::type, 'n::type, 'o::type, 'p::type, 'q::type, 'l::type) rest_scheme)); rfunc_adv rest = (λ(s::'a::type × 'm::type) q::'b::type + 'n::type. case q of Inl (ql::'b::type) ⇒ map_spmf (apfst (map_prod Inl id)) (ifunc† s ql) | Inr (qr::'n::type) ⇒ map_spmf (apfst (map_prod Inr id)) (translate_eoracle etran †(rfunc_adv rest') s qr)); rfunc_usr rest = translate_eoracle etran †(rfunc_usr rest'); (q::('f::type + 'b::type + 'n::type) + 'g::type + 'o::type) = Inl (q_adv::'f::type + 'b::type + 'n::type); q_adv = Inr (q_adv_rest::'b::type + 'n::type); q_adv_rest = Inr (q_adv_rest_etran::'n::type)⟧ ⟹ fused_resource.fuse core rest (sc::'e::type, st::'a::type, sr::'m::type) q = map_spmf (λx::((('h::type + 'c::type) + 'p::type) + 'i::type + 'q::type) × ('a::type × 'e::type) × 'm::type. (map_sum rsuml (λx::'i::type + 'q::type. x) (fst x), snd (fst (snd x)), fst (fst (snd x)), snd (snd x))) (fused_resource.fuse core' rest' ((st, sc), sr) (map_sum lsumr (λx::'g::type + 'o::type. x) q))›*) apply (rule bind_spmf_cong[OF refl] (*‹(⋀x. x ∈ set_spmf ?p ⟹ ?f x = ?g x) ⟹ ?p ⤜ ?f = ?p ⤜ ?g›*)) (*goal: ‹⟦x_ifunc ≡ λifunc core p q. ifunc (fst p) q ⤜ (λpa. foldl_spmf (cpoke core) (return_spmf (snd p)) (snd (fst pa)) ⤜ (λsc'. return_spmf (fst (fst pa), snd pa, sc'))); cpoke core' = (λp event. etran (fst p) event ⤜ (λpa. map_spmf (Pair (snd pa)) (foldl_spmf (cpoke core) (return_spmf (snd p)) (fst pa)))); cfunc_adv core' = †(cfunc_adv core) ⊕⇩O (λp q. ifunc (fst p) q ⤜ (λpa. foldl_spmf (cpoke core) (return_spmf (snd p)) (snd (fst pa)) ⤜ (λsc'. return_spmf (fst (fst pa), snd pa, sc')))); cfunc_usr core' = †(cfunc_usr core); rinit rest = (einit, rinit rest'); rfunc_adv rest = (λs q. case q of Inl ql ⇒ map_spmf (apfst (map_prod Inl id)) (ifunc† s ql) | Inr qr ⇒ map_spmf (apfst (map_prod Inr id)) (translate_eoracle etran †(rfunc_adv rest') s qr)); rfunc_usr rest = translate_eoracle etran †(rfunc_usr rest'); q = Inl (Inr (Inr q_adv_rest_etran)); q_adv = Inr (Inr q_adv_rest_etran); q_adv_rest = Inr q_adv_rest_etran⟧ ⟹ rfunc_adv rest' sr q_adv_rest_etran ⤜ (λy. foldl_spmf (λp e. map_spmf (map_prod ((@) (fst p)) id) (etran (snd p) e)) (return_spmf ([], st)) (snd (fst y)) ⤜ (λya. foldl_spmf (cpoke core) (return_spmf sc) (fst ya) ⤜ (λs_notify. return_spmf (Inl (Inr (Inr (fst (fst y)))), s_notify, snd ya, snd y)))) = rfunc_adv rest' sr q_adv_rest_etran ⤜ (λx. foldl_spmf (λp event. etran (fst p) event ⤜ (λpa. map_spmf (Pair (snd pa)) (foldl_spmf (cpoke core) (return_spmf (snd p)) (fst pa)))) (return_spmf (st, sc)) (snd (fst x)) ⤜ (λxa. return_spmf (Inl (Inr (Inr (fst (fst x)))), snd xa, fst xa, snd x)))›*) apply (subst foldl_spmf_chain[simplified split_def] (*‹foldl_spmf (λp event. map_spmf (map_prod ((@) (fst p)) id) (?fff (snd p) event)) (return_spmf ([], ?s_event)) ?ievents ⤜ (λp. foldl_spmf ?ggg (return_spmf ?s_core) (fst p) ⤜ (λs_core'. return_spmf (?f s_core' (snd p)))) = foldl_spmf (λp event. ?fff (fst p) event ⤜ (λpa. map_spmf (Pair (snd pa)) (foldl_spmf ?ggg (return_spmf (snd p)) (fst pa)))) (return_spmf (?s_event, ?s_core)) ?ievents ⤜ (λp. return_spmf (?f (snd p) (fst p)))›*)) (*goal: ‹⋀x. ⟦x_ifunc ≡ λifunc core p q. ifunc (fst p) q ⤜ (λpa. foldl_spmf (cpoke core) (return_spmf (snd p)) (snd (fst pa)) ⤜ (λsc'. return_spmf (fst (fst pa), snd pa, sc'))); cpoke core' = (λp event. etran (fst p) event ⤜ (λpa. map_spmf (Pair (snd pa)) (foldl_spmf (cpoke core) (return_spmf (snd p)) (fst pa)))); cfunc_adv core' = †(cfunc_adv core) ⊕⇩O (λp q. ifunc (fst p) q ⤜ (λpa. foldl_spmf (cpoke core) (return_spmf (snd p)) (snd (fst pa)) ⤜ (λsc'. return_spmf (fst (fst pa), snd pa, sc')))); cfunc_usr core' = †(cfunc_usr core); rinit rest = (einit, rinit rest'); rfunc_adv rest = (λs q. case q of Inl ql ⇒ map_spmf (apfst (map_prod Inl id)) (ifunc† s ql) | Inr qr ⇒ map_spmf (apfst (map_prod Inr id)) (translate_eoracle etran †(rfunc_adv rest') s qr)); rfunc_usr rest = translate_eoracle etran †(rfunc_usr rest'); q = Inl (Inr (Inr q_adv_rest_etran)); q_adv = Inr (Inr q_adv_rest_etran); q_adv_rest = Inr q_adv_rest_etran; x ∈ set_spmf (rfunc_adv rest' sr q_adv_rest_etran)⟧ ⟹ foldl_spmf (λp e. map_spmf (map_prod ((@) (fst p)) id) (etran (snd p) e)) (return_spmf ([], st)) (snd (fst x)) ⤜ (λy. foldl_spmf (cpoke core) (return_spmf sc) (fst y) ⤜ (λs_notify. return_spmf (Inl (Inr (Inr (fst (fst x)))), s_notify, snd y, snd x))) = foldl_spmf (λp event. etran (fst p) event ⤜ (λpa. map_spmf (Pair (snd pa)) (foldl_spmf (cpoke core) (return_spmf (snd p)) (fst pa)))) (return_spmf (st, sc)) (snd (fst x)) ⤜ (λxa. return_spmf (Inl (Inr (Inr (fst (fst x)))), snd xa, fst xa, snd x))›*) by simp . . subgoal for q_usr apply (cases q_usr) (*goal: ‹⟦x_ifunc::('a ⇒ 'b ⇒ (('c × 'd list) × 'a) spmf) ⇒ ('e, 'd, 'f, 'g, 'h, 'i) core ⇒ 'a × 'e ⇒ 'b ⇒ ('c × 'a × 'e) spmf ≡ λ(ifunc::'a ⇒ 'b ⇒ (('c × 'd list) × 'a) spmf) (core::('e, 'd, 'f, 'g, 'h, 'i) core) (se::'a, sc::'e) q::'b. ifunc se q ⤜ (λ((out::'c, es::'d list), se'::'a). foldl_spmf (cpoke core) (return_spmf sc) es ⤜ (λsc'::'e. return_spmf (out, se', sc'))); cpoke (core'::('a × 'e, 'j, 'f + 'b, 'g, 'h + 'c, 'i) core) = cpoke (translate_core (etran::'a ⇒ 'j ⇒ ('d list × 'a) spmf) (core::('e, 'd, 'f, 'g, 'h, 'i) core)); cfunc_adv core' = †(cfunc_adv core) ⊕⇩O x_ifunc (ifunc::'a ⇒ 'b ⇒ (('c × 'd list) × 'a) spmf) core; cfunc_usr core' = cfunc_usr (translate_core etran core); rinit (rest::('a × 'm, 'd, 'b + 'n, 'o, 'c + 'p, 'q, 'k × 'l) rest_scheme) = (einit::'k, rinit (rest'::('m, 'j, 'n, 'o, 'p, 'q, 'l) rest_scheme)); rfunc_adv rest = (λ(s::'a × 'm) q::'b + 'n. case q of Inl (ql::'b) ⇒ map_spmf (apfst (map_prod Inl id)) (ifunc† s ql) | Inr (qr::'n) ⇒ map_spmf (apfst (map_prod Inr id)) (translate_eoracle etran †(rfunc_adv rest') s qr)); rfunc_usr rest = translate_eoracle etran †(rfunc_usr rest'); (q::('f + 'b + 'n) + 'g + 'o) = Inr (q_usr::'g + 'o)⟧ ⟹ fused_resource.fuse core rest (sc::'e, st::'a, sr::'m) q = map_spmf (λx::((('h + 'c) + 'p) + 'i + 'q) × ('a × 'e) × 'm. (map_sum rsuml (λx::'i + 'q. x) (fst x), snd (fst (snd x)), fst (fst (snd x)), snd (snd x))) (fused_resource.fuse core' rest' ((st, sc), sr) (map_sum lsumr (λx::'g + 'o. x) q))›*) subgoal for q_usr_core by (simp add: map_prod_def (*‹map_prod (?f::?'a ⇒ ?'c) (?g::?'b ⇒ ?'d) = (λ(x::?'a, y::?'b). (?f x, ?g y))›*)) subgoal for q_usr_rest apply (simp add: translate_eoracle_def (*‹translate_eoracle ?translator ?eoracle ?state ?inp ≡ ?eoracle ?state ?inp ⤜ (λ((out, e_in), s). let conc = λ(es, st) e. map_spmf (map_prod ((@) es) id) (?translator st e) in foldl_spmf conc (return_spmf ([], fst s)) e_in ⤜ (λ(e_out, s_event). return_spmf ((out, e_out), s_event, snd s)))›*) extend_state_oracle_def (*‹†?callee = (λ(s', s) x. map_spmf (λ(y, s). (y, s', s)) (?callee s x))›*)) (*goal: ‹⟦x_ifunc ≡ λifunc core (se, sc) q. ifunc se q ⤜ (λ((out, es), se'). foldl_spmf (cpoke core) (return_spmf sc) es ⤜ (λsc'. return_spmf (out, se', sc'))); cpoke core' = cpoke (translate_core etran core); cfunc_adv core' = †(cfunc_adv core) ⊕⇩O x_ifunc ifunc core; cfunc_usr core' = cfunc_usr (translate_core etran core); rinit rest = (einit, rinit rest'); rfunc_adv rest = (λs q. case q of Inl ql ⇒ map_spmf (apfst (map_prod Inl id)) (ifunc† s ql) | Inr qr ⇒ map_spmf (apfst (map_prod Inr id)) (translate_eoracle etran †(rfunc_adv rest') s qr)); rfunc_usr rest = translate_eoracle etran †(rfunc_usr rest'); q = Inr q_usr; q_usr = Inr q_usr_rest⟧ ⟹ fused_resource.fuse core rest (sc, st, sr) q = map_spmf (λx. (map_sum rsuml (λx. x) (fst x), snd (fst (snd x)), fst (fst (snd x)), snd (snd x))) (fused_resource.fuse core' rest' ((st, sc), sr) (map_sum lsumr (λx. x) q))›*) apply (rule bind_spmf_cong[OF refl] (*‹(⋀x. x ∈ set_spmf ?p ⟹ ?f x = ?g x) ⟹ ?p ⤜ ?f = ?p ⤜ ?g›*)) (*goal: ‹⟦x_ifunc ≡ λifunc core p q. ifunc (fst p) q ⤜ (λpa. foldl_spmf (cpoke core) (return_spmf (snd p)) (snd (fst pa)) ⤜ (λsc'. return_spmf (fst (fst pa), snd pa, sc'))); cpoke core' = (λp event. etran (fst p) event ⤜ (λpa. map_spmf (Pair (snd pa)) (foldl_spmf (cpoke core) (return_spmf (snd p)) (fst pa)))); cfunc_adv core' = (λp x. map_spmf (λpa. (fst pa, fst p, snd pa)) (cfunc_adv core (snd p) x)) ⊕⇩O (λp q. ifunc (fst p) q ⤜ (λpa. foldl_spmf (cpoke core) (return_spmf (snd p)) (snd (fst pa)) ⤜ (λsc'. return_spmf (fst (fst pa), snd pa, sc')))); cfunc_usr core' = (λp x. map_spmf (λpa. (fst pa, fst p, snd pa)) (cfunc_usr core (snd p) x)); rinit rest = (einit, rinit rest'); rfunc_adv rest = (λs q. case q of Inl ql ⇒ map_spmf (apfst (map_prod Inl id)) (ifunc† s ql) | Inr qr ⇒ map_spmf (apfst (map_prod Inr id)) (translate_eoracle etran †(rfunc_adv rest') s qr)); rfunc_usr rest = translate_eoracle etran (λp x. map_spmf (λpa. (fst pa, fst p, snd pa)) (rfunc_usr rest' (snd p) x)); q = Inr (Inr q_usr_rest); q_usr = Inr q_usr_rest⟧ ⟹ rfunc_usr rest' sr q_usr_rest ⤜ (λy. foldl_spmf (λp e. map_spmf (map_prod ((@) (fst p)) id) (etran (snd p) e)) (return_spmf ([], st)) (snd (fst y)) ⤜ (λya. foldl_spmf (cpoke core) (return_spmf sc) (fst ya) ⤜ (λs_notify. return_spmf (Inr (Inr (fst (fst y))), s_notify, snd ya, snd y)))) = rfunc_usr rest' sr q_usr_rest ⤜ (λx. foldl_spmf (λp event. etran (fst p) event ⤜ (λpa. map_spmf (Pair (snd pa)) (foldl_spmf (cpoke core) (return_spmf (snd p)) (fst pa)))) (return_spmf (st, sc)) (snd (fst x)) ⤜ (λxa. return_spmf (Inr (Inr (fst (fst x))), snd xa, fst xa, snd x)))›*) apply (subst foldl_spmf_chain[simplified split_def] (*‹foldl_spmf (λp event. map_spmf (map_prod ((@) (fst p)) id) (?fff (snd p) event)) (return_spmf ([], ?s_event)) ?ievents ⤜ (λp. foldl_spmf ?ggg (return_spmf ?s_core) (fst p) ⤜ (λs_core'. return_spmf (?f s_core' (snd p)))) = foldl_spmf (λp event. ?fff (fst p) event ⤜ (λpa. map_spmf (Pair (snd pa)) (foldl_spmf ?ggg (return_spmf (snd p)) (fst pa)))) (return_spmf (?s_event, ?s_core)) ?ievents ⤜ (λp. return_spmf (?f (snd p) (fst p)))›*)) (*goal: ‹⋀x::('q × 'j list) × 'm. ⟦x_ifunc::('a ⇒ 'b ⇒ (('c × 'd list) × 'a) spmf) ⇒ ('e, 'd, 'f, 'g, 'h, 'i) core ⇒ 'a × 'e ⇒ 'b ⇒ ('c × 'a × 'e) spmf ≡ λ(ifunc::'a ⇒ 'b ⇒ (('c × 'd list) × 'a) spmf) (core::('e, 'd, 'f, 'g, 'h, 'i) core) (p::'a × 'e) q::'b. ifunc (fst p) q ⤜ (λpa::('c × 'd list) × 'a. foldl_spmf (cpoke core) (return_spmf (snd p)) (snd (fst pa)) ⤜ (λsc'::'e. return_spmf (fst (fst pa), snd pa, sc'))); cpoke (core'::('a × 'e, 'j, 'f + 'b, 'g, 'h + 'c, 'i) core) = (λ(p::'a × 'e) event::'j. (etran::'a ⇒ 'j ⇒ ('d list × 'a) spmf) (fst p) event ⤜ (λpa::'d list × 'a. map_spmf (Pair (snd pa)) (foldl_spmf (cpoke (core::('e, 'd, 'f, 'g, 'h, 'i) core)) (return_spmf (snd p)) (fst pa)))); cfunc_adv core' = (λ(p::'a × 'e) x::'f. map_spmf (λpa::'h × 'e. (fst pa, fst p, snd pa)) (cfunc_adv core (snd p) x)) ⊕⇩O (λ(p::'a × 'e) q::'b. (ifunc::'a ⇒ 'b ⇒ (('c × 'd list) × 'a) spmf) (fst p) q ⤜ (λpa::('c × 'd list) × 'a. foldl_spmf (cpoke core) (return_spmf (snd p)) (snd (fst pa)) ⤜ (λsc'::'e. return_spmf (fst (fst pa), snd pa, sc')))); cfunc_usr core' = (λ(p::'a × 'e) x::'g. map_spmf (λpa::'i × 'e. (fst pa, fst p, snd pa)) (cfunc_usr core (snd p) x)); rinit (rest::('a × 'm, 'd, 'b + 'n, 'o, 'c + 'p, 'q, 'k × 'l) rest_scheme) = (einit::'k, rinit (rest'::('m, 'j, 'n, 'o, 'p, 'q, 'l) rest_scheme)); rfunc_adv rest = (λ(s::'a × 'm) q::'b + 'n. case q of Inl (ql::'b) ⇒ map_spmf (apfst (map_prod Inl id)) (ifunc† s ql) | Inr (qr::'n) ⇒ map_spmf (apfst (map_prod Inr id)) (translate_eoracle etran †(rfunc_adv rest') s qr)); rfunc_usr rest = translate_eoracle etran (λ(p::'a × 'm) x::'o. map_spmf (λpa::('q × 'j list) × 'm. (fst pa, fst p, snd pa)) (rfunc_usr rest' (snd p) x)); (q::('f + 'b + 'n) + 'g + 'o) = Inr (Inr (q_usr_rest::'o)); (q_usr::'g + 'o) = Inr q_usr_rest; x ∈ set_spmf (rfunc_usr rest' (sr::'m) q_usr_rest)⟧ ⟹ foldl_spmf (λ(p::'d list × 'a) e::'j. map_spmf (map_prod ((@) (fst p)) id) (etran (snd p) e)) (return_spmf ([], st::'a)) (snd (fst x)) ⤜ (λy::'d list × 'a. foldl_spmf (cpoke core) (return_spmf (sc::'e)) (fst y) ⤜ (λs_notify::'e. return_spmf (Inr (Inr (fst (fst x))), s_notify, snd y, snd x))) = foldl_spmf (λ(p::'a × 'e) event::'j. etran (fst p) event ⤜ (λpa::'d list × 'a. map_spmf (Pair (snd pa)) (foldl_spmf (cpoke core) (return_spmf (snd p)) (fst pa)))) (return_spmf (st, sc)) (snd (fst x)) ⤜ (λxa::'a × 'e. return_spmf (Inr (Inr (fst (fst x))), snd xa, fst xa, snd x))›*) by simp . . then show "?thesis" (*goal: ‹fused_resource.fuse (core::('e, 'd, 'f, 'g, 'h, 'i) core) (rest::('a × 'm, 'd, 'b + 'n, 'o, 'c + 'p, 'q, 'k × 'l) rest_scheme) = apply_wiring (rassocl⇩w |⇩w (id, id)) (apply_state_iso (rprodl ∘ apfst prod.swap, apfst prod.swap ∘ lprodr) (fused_resource.fuse (core'::('a × 'e, 'j, 'f + 'b, 'g, 'h + 'c, 'i) core) (rest'::('m, 'j, 'n, 'o, 'p, 'q, 'l) rest_scheme)))›*) by force qed end
{ "path": "afp-2025-02-12/thys/Constructive_Cryptography_CM/Construction_Utility.thy", "repo": "afp-2025-02-12", "sha": "61a91baed3f7aeff3a0b34bf613e5f16166c9bda89b372f010bd2ee422a6daa8" }
section ‹Correctness Theorem of Partial Order Reduction› theory Ample_Correctness imports Ample_Abstract Formula begin locale ample_correctness = S: transition_system_complete ex en init int + R: transition_system_complete ex ren init int + F: formula_next_free φ + ample_abstract ex en init int ind src ren for ex :: "'action ⇒ 'state ⇒ 'state" and en :: "'action ⇒ 'state ⇒ bool" and init :: "'state ⇒ bool" and int :: "'state ⇒ 'interpretation" and ind :: "'action ⇒ 'action ⇒ bool" and src :: "'state ⇒ 'state ⇒ bool" and ren :: "'action ⇒ 'state ⇒ bool" and φ :: "'interpretation pltl" begin lemma reduction_language_indistinguishable: assumes "R.language ⊆ F.language" shows "S.language ⊆ F.language" proof (standard) (*goal: ‹⋀x. x ∈ S.language ⟹ x ∈ F.language›*) fix u assume 1: "u ∈ S.language" (*‹(u::'interpretation stream) ∈ S.language›*) obtain v where 2: "v ∈ R.language" "snth u ≈ snth v" (*goal: ‹(⋀v. ⟦v ∈ R.language; (!!) u ≈ (!!) v⟧ ⟹ thesis) ⟹ thesis›*) using reduction_language_stuttering (*‹⟦(?u::'interpretation stream) ∈ S.language; ⋀v::'interpretation stream. ⟦v ∈ R.language; (!!) ?u ≈ (!!) v⟧ ⟹ ?thesis::bool⟧ ⟹ ?thesis›*) "1" (*‹(u::'interpretation::type stream) ∈ S.language›*) by this have 3: "v ∈ F.language" using assms (*‹R.language ⊆ F.language›*) "2"(1) (*‹v ∈ R.language›*) by rule show "u ∈ F.language" using "2"(2) (*‹(!!) u ≈ (!!) v›*) "3" (*‹v ∈ F.language›*) by auto qed theorem reduction_correct: "S.language ⊆ F.language ⟷ R.language ⊆ F.language" using reduction_language_subset (*‹R.language ⊆ S.language›*) reduction_language_indistinguishable (*‹R.language ⊆ F.language ⟹ S.language ⊆ F.language›*) by blast end end
{ "path": "afp-2025-02-12/thys/Partial_Order_Reduction/Ample_Correctness.thy", "repo": "afp-2025-02-12", "sha": "5a7ba40299dbaf81fe44df7b75773bed2eef5a28cc698a0aa151ead27743d044" }
(******************************************************************************* Project: Sumcheck Protocol Authors: Azucena Garvia Bosshard <zucegb@gmail.com> Christoph Sprenger, ETH Zurich <sprenger@inf.ethz.ch> Jonathan Bootle, IBM Research Europe <jbt@zurich.ibm.com> *******************************************************************************) section ‹Roots Bound for Multivariate Polynomials of Arity at Most One› theory Roots_Bounds imports "Polynomials.MPoly_Type_Univariate" Univariate_Roots_Bound begin text ‹ \textbf{NOTE:} if considered to be useful enough, the lemmas in this theory could be moved to the theory @{theory "Polynomials.MPoly_Type_Univariate"}. › subsection ‹Lemmas connecting univariate and multivariate polynomials› subsubsection ‹Basic lemmas› lemma mpoly_to_poly_zero_iff: fixes p::"'a::comm_monoid_add mpoly" assumes ‹vars p ⊆ {v}› shows "mpoly_to_poly v p = 0 ⟷ p = 0" by (metis assms (*‹vars p ⊆ {v}›*) mpoly_to_poly_inverse (*‹vars ?p ⊆ {?v} ⟹ poly_to_mpoly ?v (mpoly_to_poly ?v ?p) = ?p›*) poly_to_mpoly0 (*‹poly_to_mpoly ?v 0 = 0›*) poly_to_mpoly_inverse (*‹mpoly_to_poly ?v (poly_to_mpoly ?v ?p) = ?p›*)) lemma keys_monom_subset_vars: fixes p::"'a::zero mpoly" assumes ‹m ∈ keys (mapping_of p)› shows "keys m ⊆ vars p" using assms (*‹m ∈ keys (mapping_of p)›*) by (auto simp add: vars_def (*‹vars ?p = ⋃ (keys ` keys (mapping_of ?p))›*)) lemma sum_lookup_keys_eq_lookup: fixes p::"'a::zero mpoly" assumes ‹m ∈ keys (mapping_of p)› and ‹vars p ⊆ {v}› shows "sum (lookup m) (keys m) = lookup m v" using assms (*‹m ∈ keys (mapping_of p)› ‹vars p ⊆ {v}›*) by (auto simp add: subset_singleton_iff (*‹(?X ⊆ {?a}) = (?X = {} ∨ ?X = {?a})›*) dest!: keys_monom_subset_vars (*‹?m ∈ keys (mapping_of ?p) ⟹ keys ?m ⊆ vars ?p›*)) subsubsection ‹Total degree corresponds to degree for polynomials of arity at most one› lemma poly_degree_eq_mpoly_degree: fixes p::"'a::comm_monoid_add mpoly" assumes ‹vars p ⊆ {v}› shows "degree (mpoly_to_poly v p) = MPoly_Type.degree p v" using assms (*‹vars p ⊆ {v}›*) proof (-) (*goal: ‹vars (p::'a::comm_monoid_add mpoly) ⊆ {v::nat} ⟹ Polynomial.degree (mpoly_to_poly v p) = MPoly_Type.degree p v›*) have "*": "⋀n. MPoly_Type.coeff p (Poly_Mapping.single v n) ≠ 0 ⟷ (∃m∈keys (mapping_of p). n = lookup m v)" by (metis (no_types, opaque_lifting) Diff_eq_empty_iff (*‹((?A::?'a set) - (?B::?'a set) = {}) = (?A ⊆ ?B)›*) Diff_insert (*‹(?A::?'a set) - insert (?a::?'a) (?B::?'a set) = ?A - ?B - {?a}›*) add_0 (*‹(0::?'a) + (?a::?'a) = ?a›*) keys_eq_empty (*‹(keys (?c::?'a ⇒₀ ?'b) = {}) = (?c = (0::?'a ⇒₀ ?'b))›*) keys_monom_subset_vars (*‹(?m::nat ⇒₀ nat) ∈ keys (mapping_of (?p::?'a mpoly)) ⟹ keys ?m ⊆ vars ?p›*) lookup_single_eq (*‹lookup (Poly_Mapping.single (?k::?'b) (?v::?'a)) ?k = ?v›*) remove_key_keys (*‹keys (?f::?'a ⇒₀ ?'b) - {?k::?'a} = keys (remove_key ?k ?f)›*) remove_key_sum (*‹remove_key (?k::?'a) (?f::?'a ⇒₀ ?'b) + Poly_Mapping.single ?k (lookup ?f ?k) = ?f›*) singleton_insert_inj_eq' (*‹(insert (?a::?'a) (?A::?'a set) = {?b::?'a}) = (?a = ?b ∧ ?A ⊆ {?b})›*) coeff_keys[symmetric] (*‹(MPoly_Type.coeff (?p::?'a mpoly) (?m::nat ⇒₀ nat) ≠ (0::?'a)) = (?m ∈ keys (mapping_of ?p))›*) assms (*‹vars (p::'a mpoly) ⊆ {v::nat}›*)) have "degree (mpoly_to_poly v p) = Max (insert 0 {n. MPoly_Type.coeff p (Poly_Mapping.single v n) ≠ 0})" by (simp add: poly_degree_eq_Max_non_zero_coeffs (*‹Polynomial.degree ?p = Max (insert 0 {n. poly.coeff ?p n ≠ 0})›*)) also (*calculation: ‹Polynomial.degree (mpoly_to_poly (v::nat) (p::'a mpoly)) = Max (insert (0::nat) {n::nat. MPoly_Type.coeff p (Poly_Mapping.single v n) ≠ (0::'a)})›*) have "… = MPoly_Type.degree p v" by (simp add: degree.rep_eq (*‹MPoly_Type.degree (?x::?'a mpoly) = (λv::nat. Max (insert (0::nat) ((λm::nat ⇒₀ nat. lookup m v) ` keys (mapping_of ?x))))›*) image_def (*‹(?f::?'a ⇒ ?'b) ` (?A::?'a set) = {y::?'b. ∃x::?'a∈?A. y = ?f x}›*) * (*‹(MPoly_Type.coeff (p::'a mpoly) (Poly_Mapping.single (v::nat) (?n::nat)) ≠ (0::'a)) = (∃m::nat ⇒₀ nat∈keys (mapping_of p). ?n = lookup m v)›*)) finally (*calculation: ‹Polynomial.degree (mpoly_to_poly (v::nat) (p::'a mpoly)) = MPoly_Type.degree p v›*) show "?thesis" (*goal: ‹Polynomial.degree (mpoly_to_poly v p) = MPoly_Type.degree p v›*) . qed lemma mpoly_degree_eq_total_degree: fixes p::"'a::zero mpoly" assumes ‹vars p ⊆ {v}› shows "MPoly_Type.degree p v = total_degree p" using assms (*‹vars p ⊆ {v}›*) by (auto simp add: MPoly_Type.degree_def (*‹MPoly_Type.degree ≡ map_fun mapping_of id (λp v. Max (insert 0 ((λm. lookup m v) ` keys p)))›*) total_degree_def (*‹total_degree ≡ map_fun mapping_of id (λp. Max (insert 0 ((λm. sum (lookup m) (keys m)) ` keys p)))›*) sum_lookup_keys_eq_lookup (*‹⟦?m ∈ keys (mapping_of ?p); vars ?p ⊆ {?v}⟧ ⟹ sum (lookup ?m) (keys ?m) = lookup ?m ?v›*)) corollary poly_degree_eq_total_degree: fixes p::"'a::comm_monoid_add mpoly" assumes ‹vars p ⊆ {v}› shows "degree (mpoly_to_poly v p) = total_degree p" using assms (*‹vars p ⊆ {v}›*) by (simp add: poly_degree_eq_mpoly_degree (*‹vars ?p ⊆ {?v} ⟹ Polynomial.degree (mpoly_to_poly ?v ?p) = MPoly_Type.degree ?p ?v›*) mpoly_degree_eq_total_degree (*‹vars ?p ⊆ {?v} ⟹ MPoly_Type.degree ?p ?v = total_degree ?p›*)) subsection ‹Roots bound for univariate polynomials of type @{typ "'a mpoly"}› lemma univariate_mpoly_roots_bound: fixes p::"'a::idom mpoly" assumes ‹vars p ⊆ {v}› ‹p ≠ 0› shows ‹card {x. insertion (λv. x) p = 0} ≤ total_degree p› using assms (*‹vars p ⊆ {v}› ‹p ≠ 0›*) univariate_roots_bound[of "mpoly_to_poly v p", unfolded poly_eq_insertion [ OF ‹vars p ⊆ {v}› ]] (*‹mpoly_to_poly v p ≠ 0 ⟹ card {x. insertion (λv. x) p = 0} ≤ Polynomial.degree (mpoly_to_poly v p)›*) by (auto simp add: poly_degree_eq_total_degree (*‹vars ?p ⊆ {?v} ⟹ Polynomial.degree (mpoly_to_poly ?v ?p) = total_degree ?p›*) mpoly_to_poly_zero_iff (*‹vars ?p ⊆ {?v} ⟹ (mpoly_to_poly ?v ?p = 0) = (?p = 0)›*)) end
{ "path": "afp-2025-02-12/thys/Sumcheck_Protocol/Instantiation_with_Polynomials/Roots_Bounds.thy", "repo": "afp-2025-02-12", "sha": "20541a7769d55eb15f8ab83e34b9d5014ea685d5f597811856ea22a96f7e9090" }
(* Title: AWN.thy License: BSD 2-Clause. See LICENSE. Author: Timothy Bourke *) section "Terms of the Algebra for Wireless Networks" theory AWN imports Lib begin subsection "Sequential Processes" type_synonym ip = nat type_synonym data = nat text ‹ Most of AWN is independent of the type of messages, but the closed layer turns newpkt actions into the arrival of newpkt messages. We use a type class to maintain some abstraction (and independence from the definition of particular protocols). › class msg = fixes newpkt :: "data × ip ⇒ 'a" and eq_newpkt :: "'a ⇒ bool" assumes eq_newpkt_eq [simp]: "eq_newpkt (newpkt (d, i))" text ‹ Sequential process terms abstract over the types of data states (@{typ 's}), messages (@{typ 'm}), process names (@{typ 'p}),and labels (@{typ 'l}). › datatype (dead 's, dead 'm, dead 'p, 'l) seqp = GUARD "'l" "'s ⇒ 's set" "('s, 'm, 'p, 'l) seqp" | ASSIGN "'l" "'s ⇒ 's" "('s, 'm, 'p, 'l) seqp" | CHOICE "('s, 'm, 'p, 'l) seqp" "('s, 'm, 'p, 'l) seqp" | UCAST "'l" "'s ⇒ ip" "'s ⇒ 'm" "('s, 'm, 'p, 'l) seqp" "('s, 'm, 'p, 'l) seqp" | BCAST "'l" "'s ⇒ 'm" "('s, 'm, 'p, 'l) seqp" | GCAST "'l" "'s ⇒ ip set" "'s ⇒ 'm" "('s, 'm, 'p, 'l) seqp" | SEND "'l" "'s ⇒ 'm" "('s, 'm, 'p, 'l) seqp" | DELIVER "'l" "'s ⇒ data" "('s, 'm, 'p, 'l) seqp" | RECEIVE "'l" "'m ⇒ 's ⇒ 's" "('s, 'm, 'p, 'l) seqp" | CALL 'p for map: labelmap syntax "_guard" :: "['a, ('s, 'm, 'p, unit) seqp] ⇒ ('s, 'm, 'p, unit) seqp" ("(‹unbreakable›⟨_⟩)//_" [0, 60] 60) "_lguard" :: "['a, 'a, ('s, 'm, 'p, unit) seqp] ⇒ ('s, 'm, 'p, unit) seqp" ("{_}(‹unbreakable›⟨_⟩)//_" [0, 0, 60] 60) "_ifguard" :: "[pttrn, bool, ('s, 'm, 'p, unit) seqp] ⇒ ('s, 'm, 'p, unit) seqp" ("(‹unbreakable›⟨_. _⟩)//_" [0, 0, 60] 60) "_bassign" :: "[pttrn, 'a, ('s, 'm, 'p, unit) seqp] ⇒ ('s, 'm, 'p, unit) seqp" ("(‹unbreakable›⟦_. _⟧)//_" [0, 0, 60] 60) "_lbassign" :: "['a, pttrn, 'a, ('s, 'm, 'p, 'a) seqp] ⇒ ('s, 'm, 'p, 'a) seqp" ("{_}(‹unbreakable›⟦_. _⟧)//_" [0, 0, 0, 60] 60) "_assign" :: "['a, ('s, 'm, 'p, unit) seqp] ⇒ ('s, 'm, 'p, unit) seqp" ("((‹unbreakable›⟦_⟧))//_" [0, 60] 60) "_lassign" :: "['a, 'a, ('s, 'm, 'p, 'a) seqp] ⇒ ('s, 'm, 'p, 'a) seqp" ("({_}(‹unbreakable›⟦_⟧))//_" [0, 0, 60] 60) "_unicast" :: "['a, 'a, ('s, 'm, 'p, unit) seqp, ('s, 'm, 'p, unit) seqp] ⇒ ('s, 'm, 'p, unit) seqp" ("(3unicast'((1(3_),/ (3_))') .//(_)/ (2▹ _))" [0, 0, 60, 60] 60) "_lunicast" :: "['a, 'a, 'a, ('s, 'm, 'p, 'a) seqp, ('s, 'm, 'p, 'a) seqp] ⇒ ('s, 'm, 'p, 'a) seqp" ("(3{_}unicast'((1(3_),/ (3_))') .//(_)/ (2▹ _))" [0, 0, 0, 60, 60] 60) "_bcast" :: "['a, ('s, 'm, 'p, unit) seqp] ⇒ ('s, 'm, 'p, unit) seqp" ("(3broadcast'((1(_))') .)//_" [0, 60] 60) "_lbcast" :: "['a, 'a, ('s, 'm, 'p, 'a) seqp] ⇒ ('s, 'm, 'p, 'a) seqp" ("(3{_}broadcast'((1(_))') .)//_" [0, 0, 60] 60) "_gcast" :: "['a, 'a, ('s, 'm, 'p, unit) seqp] ⇒ ('s, 'm, 'p, unit) seqp" ("(3groupcast'((1(_),/ (_))') .)//_" [0, 0, 60] 60) "_lgcast" :: "['a, 'a, 'a, ('s, 'm, 'p, 'a) seqp] ⇒ ('s, 'm, 'p, 'a) seqp" ("(3{_}groupcast'((1(_),/ (_))') .)//_" [0, 0, 0, 60] 60) "_send" :: "['a, ('s, 'm, 'p, unit) seqp] ⇒ ('s, 'm, 'p, unit) seqp" ("(3send'((_)') .)//_" [0, 60] 60) "_lsend" :: "['a, 'a, ('s, 'm, 'p, 'a) seqp] ⇒ ('s, 'm, 'p, 'a) seqp" ("(3{_}send'((_)') .)//_" [0, 0, 60] 60) "_deliver" :: "['a, ('s, 'm, 'p, unit) seqp] ⇒ ('s, 'm, 'p, unit) seqp" ("(3deliver'((_)') .)//_" [0, 60] 60) "_ldeliver" :: "['a, 'a, ('s, 'm, 'p, 'a) seqp] ⇒ ('s, 'm, 'p, 'a) seqp" ("(3{_}deliver'((_)') .)//_" [0, 0, 60] 60) "_receive" :: "['a, ('s, 'm, 'p, unit) seqp] ⇒ ('s, 'm, 'p, unit) seqp" ("(3receive'((_)') .)//_" [0, 60] 60) "_lreceive" :: "['a, 'a, ('s, 'm, 'p, 'a) seqp] ⇒ ('s, 'm, 'p, 'a) seqp" ("(3{_}receive'((_)') .)//_" [0, 0, 60] 60) translations "_guard f p" ⇌ "CONST GUARD () f p" "_lguard l f p" ⇌ "CONST GUARD l f p" "_ifguard ξ e p" ⇀ "CONST GUARD () (λξ. if e then {ξ} else {}) p" "_assign f p" ⇌ "CONST ASSIGN () f p" "_lassign l f p" ⇌ "CONST ASSIGN l f p" "_bassign ξ e p" ⇌ "CONST ASSIGN () (λξ. e) p" "_lbassign l ξ e p" ⇌ "CONST ASSIGN l (λξ. e) p" "_unicast fip fmsg p q" ⇌ "CONST UCAST () fip fmsg p q" "_lunicast l fip fmsg p q" ⇌ "CONST UCAST l fip fmsg p q" "_bcast fmsg p" ⇌ "CONST BCAST () fmsg p" "_lbcast l fmsg p" ⇌ "CONST BCAST l fmsg p" "_gcast fipset fmsg p" ⇌ "CONST GCAST () fipset fmsg p" "_lgcast l fipset fmsg p" ⇌ "CONST GCAST l fipset fmsg p" "_send fmsg p" ⇌ "CONST SEND () fmsg p" "_lsend l fmsg p" ⇌ "CONST SEND l fmsg p" "_deliver fdata p" ⇌ "CONST DELIVER () fdata p" "_ldeliver l fdata p" ⇌ "CONST DELIVER l fdata p" "_receive fmsg p" ⇌ "CONST RECEIVE () fmsg p" "_lreceive l fmsg p" ⇌ "CONST RECEIVE l fmsg p" notation "CHOICE" ("((_)//⊕//(_))" [56, 55] 55) and "CALL" ("(3call'((3_)'))" [0] 60) definition not_call :: "('s, 'm, 'p, 'l) seqp ⇒ bool" where "not_call p ≡ ∀pn. p ≠ call(pn)" lemma not_call_simps [simp]: "⋀l fg p. not_call ({l}⟨fg⟩ p)" "⋀l fa p. not_call ({l}⟦fa⟧ p)" "⋀p1 p2. not_call (p1 ⊕ p2)" "⋀l fip fmsg p q. not_call ({l}unicast(fip, fmsg).p ▹ q)" "⋀l fmsg p. not_call ({l}broadcast(fmsg).p)" "⋀l fips fmsg p. not_call ({l}groupcast(fips, fmsg).p)" "⋀l fmsg p. not_call ({l}send(fmsg).p)" "⋀l fdata p. not_call ({l}deliver(fdata).p)" "⋀l fmsg p. not_call ({l}receive(fmsg).p)" "⋀l pn. ¬(not_call (call(pn)))" unfolding not_call_def (*goals: 1. ‹⋀l fg p. ∀pn. {l}⟨fg⟩ p ≠ call(pn)› 2. ‹⋀l fa p. ∀pn. {l}⟦fa⟧ p ≠ call(pn)› 3. ‹⋀p1 p2. ∀pn. p1 ⊕ p2 ≠ call(pn)› 4. ‹⋀l fip fmsg p q. ∀pn. {l}unicast(fip, fmsg) . p ▹ q ≠ call(pn)› 5. ‹⋀l fmsg p. ∀pn. {l}broadcast(fmsg) . p ≠ call(pn)› 6. ‹⋀l fips fmsg p. ∀pn. {l}groupcast(fips, fmsg) . p ≠ call(pn)› 7. ‹⋀l fmsg p. ∀pn. {l}send(fmsg) . p ≠ call(pn)› 8. ‹⋀l fdata p. ∀pn. {l}deliver(fdata) . p ≠ call(pn)› 9. ‹⋀l fmsg p. ∀pn. {l}receive(fmsg) . p ≠ call(pn)› 10. ‹⋀l pn. ¬ (∀pna. call(pn) ≠ call(pna))›*) (*goals: 1. ‹⋀l fg p. ∀pn. {l}⟨fg⟩ p ≠ call(pn)› 2. ‹⋀l fa p. ∀pn. {l}⟦fa⟧ p ≠ call(pn)› 3. ‹⋀p1 p2. ∀pn. p1 ⊕ p2 ≠ call(pn)› 4. ‹⋀l fip fmsg p q. ∀pn. {l}unicast(fip, fmsg) . p ▹ q ≠ call(pn)› 5. ‹⋀l fmsg p. ∀pn. {l}broadcast(fmsg) . p ≠ call(pn)› 6. ‹⋀l fips fmsg p. ∀pn. {l}groupcast(fips, fmsg) . p ≠ call(pn)› 7. ‹⋀l fmsg p. ∀pn. {l}send(fmsg) . p ≠ call(pn)› 8. ‹⋀l fdata p. ∀pn. {l}deliver(fdata) . p ≠ call(pn)› 9. ‹⋀l fmsg p. ∀pn. {l}receive(fmsg) . p ≠ call(pn)› 10. ‹⋀l pn. ¬ (∀pna. call(pn) ≠ call(pna))› 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]) (*proven 10 subgoals*) . definition not_choice :: "('s, 'm, 'p, 'l) seqp ⇒ bool" where "not_choice p ≡ ∀p1 p2. p ≠ p1 ⊕ p2" lemma not_choice_simps [simp]: "⋀l fg p. not_choice ({l}⟨fg⟩ p)" "⋀l fa p. not_choice ({l}⟦fa⟧ p)" "⋀p1 p2. ¬(not_choice (p1 ⊕ p2))" "⋀l fip fmsg p q. not_choice ({l}unicast(fip, fmsg).p ▹ q)" "⋀l fmsg p. not_choice ({l}broadcast(fmsg).p)" "⋀l fips fmsg p. not_choice ({l}groupcast(fips, fmsg).p)" "⋀l fmsg p. not_choice ({l}send(fmsg).p)" "⋀l fdata p. not_choice ({l}deliver(fdata).p)" "⋀l fmsg p. not_choice ({l}receive(fmsg).p)" "⋀l pn. not_choice (call(pn))" unfolding not_choice_def (*goals: 1. ‹⋀l fg p. ∀p1 p2. {l}⟨fg⟩ p ≠ p1 ⊕ p2› 2. ‹⋀l fa p. ∀p1 p2. {l}⟦fa⟧ p ≠ p1 ⊕ p2› 3. ‹⋀p1 p2. ¬ (∀p1a p2a. p1 ⊕ p2 ≠ p1a ⊕ p2a)› 4. ‹⋀l fip fmsg p q. ∀p1 p2. {l}unicast(fip, fmsg) . p ▹ q ≠ p1 ⊕ p2› 5. ‹⋀l fmsg p. ∀p1 p2. {l}broadcast(fmsg) . p ≠ p1 ⊕ p2› 6. ‹⋀l fips fmsg p. ∀p1 p2. {l}groupcast(fips, fmsg) . p ≠ p1 ⊕ p2› 7. ‹⋀l fmsg p. ∀p1 p2. {l}send(fmsg) . p ≠ p1 ⊕ p2› 8. ‹⋀l fdata p. ∀p1 p2. {l}deliver(fdata) . p ≠ p1 ⊕ p2› 9. ‹⋀l fmsg p. ∀p1 p2. {l}receive(fmsg) . p ≠ p1 ⊕ p2› 10. ‹⋀l pn. ∀p1 p2. call(pn) ≠ p1 ⊕ p2›*) (*goals: 1. ‹⋀l fg p. ∀p1 p2. {l}⟨fg⟩ p ≠ p1 ⊕ p2› 2. ‹⋀l fa p. ∀p1 p2. {l}⟦fa⟧ p ≠ p1 ⊕ p2› 3. ‹⋀p1 p2. ¬ (∀p1a p2a. p1 ⊕ p2 ≠ p1a ⊕ p2a)› 4. ‹⋀l fip fmsg p q. ∀p1 p2. {l}unicast(fip, fmsg) . p ▹ q ≠ p1 ⊕ p2› 5. ‹⋀l fmsg p. ∀p1 p2. {l}broadcast(fmsg) . p ≠ p1 ⊕ p2› 6. ‹⋀l fips fmsg p. ∀p1 p2. {l}groupcast(fips, fmsg) . p ≠ p1 ⊕ p2› 7. ‹⋀l fmsg p. ∀p1 p2. {l}send(fmsg) . p ≠ p1 ⊕ p2› 8. ‹⋀l fdata p. ∀p1 p2. {l}deliver(fdata) . p ≠ p1 ⊕ p2› 9. ‹⋀l fmsg p. ∀p1 p2. {l}receive(fmsg) . p ≠ p1 ⊕ p2› 10. ‹⋀l pn. ∀p1 p2. call(pn) ≠ p1 ⊕ p2› 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]) (*proven 10 subgoals*) . lemma seqp_congs: "⋀l fg p. {l}⟨fg⟩ p = {l}⟨fg⟩ p" "⋀l fa p. {l}⟦fa⟧ p = {l}⟦fa⟧ p" "⋀p1 p2. p1 ⊕ p2 = p1 ⊕ p2" "⋀l fip fmsg p q. {l}unicast(fip, fmsg).p ▹ q = {l}unicast(fip, fmsg).p ▹ q" "⋀l fmsg p. {l}broadcast(fmsg).p = {l}broadcast(fmsg).p" "⋀l fips fmsg p. {l}groupcast(fips, fmsg).p = {l}groupcast(fips, fmsg).p" "⋀l fmsg p. {l}send(fmsg).p = {l}send(fmsg).p" "⋀l fdata p. {l}deliver(fdata).p = {l}deliver(fdata).p" "⋀l fmsg p. {l}receive(fmsg).p = {l}receive(fmsg).p" "⋀l pn. call(pn) = call(pn)" (*goals: 1. ‹⋀l fg p. {l}⟨fg⟩ p = {l}⟨fg⟩ p› 2. ‹⋀l fa p. {l}⟦fa⟧ p = {l}⟦fa⟧ p› 3. ‹⋀p1 p2. p1 ⊕ p2 = p1 ⊕ p2› 4. ‹⋀l fip fmsg p q. {l}unicast(fip, fmsg) . p ▹ q = {l}unicast(fip, fmsg) . p ▹ q› 5. ‹⋀l fmsg p. {l}broadcast(fmsg) . p = {l}broadcast(fmsg) . p› 6. ‹⋀l fips fmsg p. {l}groupcast(fips, fmsg) . p = {l}groupcast(fips, fmsg) . p› 7. ‹⋀l fmsg p. {l}send(fmsg) . p = {l}send(fmsg) . p› 8. ‹⋀l fdata p. {l}deliver(fdata) . p = {l}deliver(fdata) . p› 9. ‹⋀l fmsg p. {l}receive(fmsg) . p = {l}receive(fmsg) . p› 10. ‹⋀l pn. call(pn) = call(pn)› 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]) (*proven 10 subgoals*) . text ‹Remove data expressions from process terms.› fun seqp_skeleton :: "('s, 'm, 'p, 'l) seqp ⇒ (unit, unit, 'p, 'l) seqp" where "seqp_skeleton ({l}⟨_⟩ p) = {l}⟨λ_. {()}⟩ (seqp_skeleton p)" | "seqp_skeleton ({l}⟦_⟧ p) = {l}⟦λ_. ()⟧ (seqp_skeleton p)" | "seqp_skeleton (p ⊕ q) = (seqp_skeleton p) ⊕ (seqp_skeleton q)" | "seqp_skeleton ({l}unicast(_, _). p ▹ q) = {l}unicast(λ_. 0, λ_. ()). (seqp_skeleton p) ▹ (seqp_skeleton q)" | "seqp_skeleton ({l}broadcast(_). p) = {l}broadcast(λ_. ()). (seqp_skeleton p)" | "seqp_skeleton ({l}groupcast(_, _). p) = {l}groupcast(λ_. {}, λ_. ()). (seqp_skeleton p)" | "seqp_skeleton ({l}send(_). p) = {l}send(λ_. ()). (seqp_skeleton p)" | "seqp_skeleton ({l}deliver(_). p) = {l}deliver(λ_. 0). (seqp_skeleton p)" | "seqp_skeleton ({l}receive(_). p) = {l}receive(λ_ _. ()). (seqp_skeleton p)" | "seqp_skeleton (call(pn)) = call(pn)" text ‹Calculate the subterms of a term.› fun subterms :: "('s, 'm, 'p, 'l) seqp ⇒ ('s, 'm, 'p, 'l) seqp set" where "subterms ({l}⟨fg⟩ p) = {{l}⟨fg⟩ p} ∪ subterms p" | "subterms ({l}⟦fa⟧ p) = {{l}⟦fa⟧ p} ∪ subterms p" | "subterms (p1 ⊕ p2) = {p1 ⊕ p2} ∪ subterms p1 ∪ subterms p2" | "subterms ({l}unicast(fip, fmsg). p ▹ q) = {{l}unicast(fip, fmsg). p ▹ q} ∪ subterms p ∪ subterms q" | "subterms ({l}broadcast(fmsg). p) = {{l}broadcast(fmsg). p} ∪ subterms p" | "subterms ({l}groupcast(fips, fmsg). p) = {{l}groupcast(fips, fmsg). p} ∪ subterms p" | "subterms ({l}send(fmsg). p) = {{l}send(fmsg).p} ∪ subterms p" | "subterms ({l}deliver(fdata). p) = {{l}deliver(fdata).p} ∪ subterms p" | "subterms ({l}receive(fmsg). p) = {{l}receive(fmsg).p} ∪ subterms p" | "subterms (call(pn)) = {call(pn)}" lemma subterms_refl [simp]: "p ∈ subterms p" apply (cases p) (*goals: 1. ‹⋀x11 x12 x13. p = {x11}⟨x12⟩ x13 ⟹ p ∈ subterms p› 2. ‹⋀x21 x22 x23. p = {x21}⟦x22⟧ x23 ⟹ p ∈ subterms p› 3. ‹⋀x31 x32. p = x31 ⊕ x32 ⟹ p ∈ subterms p› 4. ‹⋀x41 x42 x43 x44 x45. p = {x41}unicast(x42, x43) . x44 ▹ x45 ⟹ p ∈ subterms p› 5. ‹⋀x51 x52 x53. p = {x51}broadcast(x52) . x53 ⟹ p ∈ subterms p› 6. ‹⋀x61 x62 x63 x64. p = {x61}groupcast(x62, x63) . x64 ⟹ p ∈ subterms p› 7. ‹⋀x71 x72 x73. p = {x71}send(x72) . x73 ⟹ p ∈ subterms p› 8. ‹⋀x81 x82 x83. p = {x81}deliver(x82) . x83 ⟹ p ∈ subterms p› 9. ‹⋀x91 x92 x93. p = {x91}receive(x92) . x93 ⟹ p ∈ subterms p› 10. ‹⋀x10. p = call(x10) ⟹ p ∈ subterms p› 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 (*proven 10 subgoals*) . lemma subterms_trans [elim]: assumes "q ∈ subterms p" and "r ∈ subterms q" shows "r ∈ subterms p" using assms (*‹q ∈ subterms p› ‹(r::('a::type, 'b::type, 'c::type, 'd::type) seqp) ∈ subterms (q::('a::type, 'b::type, 'c::type, 'd::type) seqp)›*) apply (induction p) (*goals: 1. ‹⋀x1 x2 p. ⟦⟦q ∈ subterms p; r ∈ subterms q⟧ ⟹ r ∈ subterms p; q ∈ subterms ({x1}⟨x2⟩ p); r ∈ subterms q⟧ ⟹ r ∈ subterms ({x1}⟨x2⟩ p)› 2. ‹⋀x1 x2 p. ⟦⟦q ∈ subterms p; r ∈ subterms q⟧ ⟹ r ∈ subterms p; q ∈ subterms ({x1}⟦x2⟧ p); r ∈ subterms q⟧ ⟹ r ∈ subterms ({x1}⟦x2⟧ p)› 3. ‹⋀p1 p2. ⟦⟦q ∈ subterms p1; r ∈ subterms q⟧ ⟹ r ∈ subterms p1; ⟦q ∈ subterms p2; r ∈ subterms q⟧ ⟹ r ∈ subterms p2; q ∈ subterms (p1 ⊕ p2); r ∈ subterms q⟧ ⟹ r ∈ subterms (p1 ⊕ p2)› 4. ‹⋀x1 x2 x3 p1 p2. ⟦⟦q ∈ subterms p1; r ∈ subterms q⟧ ⟹ r ∈ subterms p1; ⟦q ∈ subterms p2; r ∈ subterms q⟧ ⟹ r ∈ subterms p2; q ∈ subterms ({x1}unicast(x2, x3) . p1 ▹ p2); r ∈ subterms q⟧ ⟹ r ∈ subterms ({x1}unicast(x2, x3) . p1 ▹ p2)› 5. ‹⋀x1 x2 p. ⟦⟦q ∈ subterms p; r ∈ subterms q⟧ ⟹ r ∈ subterms p; q ∈ subterms ({x1}broadcast(x2) . p); r ∈ subterms q⟧ ⟹ r ∈ subterms ({x1}broadcast(x2) . p)› 6. ‹⋀x1 x2 x3 p. ⟦⟦q ∈ subterms p; r ∈ subterms q⟧ ⟹ r ∈ subterms p; q ∈ subterms ({x1}groupcast(x2, x3) . p); r ∈ subterms q⟧ ⟹ r ∈ subterms ({x1}groupcast(x2, x3) . p)› 7. ‹⋀x1 x2 p. ⟦⟦q ∈ subterms p; r ∈ subterms q⟧ ⟹ r ∈ subterms p; q ∈ subterms ({x1}send(x2) . p); r ∈ subterms q⟧ ⟹ r ∈ subterms ({x1}send(x2) . p)› 8. ‹⋀x1 x2 p. ⟦⟦q ∈ subterms p; r ∈ subterms q⟧ ⟹ r ∈ subterms p; q ∈ subterms ({x1}deliver(x2) . p); r ∈ subterms q⟧ ⟹ r ∈ subterms ({x1}deliver(x2) . p)› 9. ‹⋀x1 x2 p. ⟦⟦q ∈ subterms p; r ∈ subterms q⟧ ⟹ r ∈ subterms p; q ∈ subterms ({x1}receive(x2) . p); r ∈ subterms q⟧ ⟹ r ∈ subterms ({x1}receive(x2) . p)› 10. ‹⋀x. ⟦q ∈ subterms (call(x)); r ∈ subterms q⟧ ⟹ r ∈ subterms (call(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]) (*discuss goal 8*) apply ((auto)[1]) (*discuss goal 9*) apply ((auto)[1]) (*discuss goal 10*) apply ((auto)[1]) (*proven 10 subgoals*) . lemma root_in_subterms [simp]: "⋀Γ pn. ∃pn'. Γ pn ∈ subterms (Γ pn')" apply (rule_tac x=pn in exI (*‹?P ?x ⟹ ∃x. ?P x›*)) (*goal: ‹⋀Γ pn. ∃pn'. Γ pn ∈ subterms (Γ pn')›*) by simp lemma deriv_in_subterms [elim, dest]: "⋀l f p q. {l}⟨f⟩ q ∈ subterms p ⟹ q ∈ subterms p" "⋀l fa p q. {l}⟦fa⟧ q ∈ subterms p ⟹ q ∈ subterms p" "⋀p1 p2 p. p1 ⊕ p2 ∈ subterms p ⟹ p1 ∈ subterms p" "⋀p1 p2 p. p1 ⊕ p2 ∈ subterms p ⟹ p2 ∈ subterms p" "⋀l fip fmsg p q r. {l}unicast(fip, fmsg). q ▹ r ∈ subterms p ⟹ q ∈ subterms p" "⋀l fip fmsg p q r. {l}unicast(fip, fmsg). q ▹ r ∈ subterms p ⟹ r ∈ subterms p" "⋀l fmsg p q. {l}broadcast(fmsg). q ∈ subterms p ⟹ q ∈ subterms p" "⋀l fips fmsg p q. {l}groupcast(fips, fmsg). q ∈ subterms p ⟹ q ∈ subterms p" "⋀l fmsg p q. {l}send(fmsg). q ∈ subterms p ⟹ q ∈ subterms p" "⋀l fdata p q. {l}deliver(fdata). q ∈ subterms p ⟹ q ∈ subterms p" "⋀l fmsg p q. {l}receive(fmsg). q ∈ subterms p ⟹ q ∈ subterms p" (*goals: 1. ‹⋀l f p q. {l}⟨f⟩ q ∈ subterms p ⟹ q ∈ subterms p› 2. ‹⋀l fa p q. {l}⟦fa⟧ q ∈ subterms p ⟹ q ∈ subterms p› 3. ‹⋀p1 p2 p. p1 ⊕ p2 ∈ subterms p ⟹ p1 ∈ subterms p› 4. ‹⋀p1 p2 p. p1 ⊕ p2 ∈ subterms p ⟹ p2 ∈ subterms p› 5. ‹⋀l fip fmsg p q r. {l}unicast(fip, fmsg) . q ▹ r ∈ subterms p ⟹ q ∈ subterms p› 6. ‹⋀l fip fmsg p q r. {l}unicast(fip, fmsg) . q ▹ r ∈ subterms p ⟹ r ∈ subterms p› 7. ‹⋀l fmsg p q. {l}broadcast(fmsg) . q ∈ subterms p ⟹ q ∈ subterms p› 8. ‹⋀l fips fmsg p q. {l}groupcast(fips, fmsg) . q ∈ subterms p ⟹ q ∈ subterms p› 9. ‹⋀l fmsg p q. {l}send(fmsg) . q ∈ subterms p ⟹ q ∈ subterms p› 10. ‹⋀l fdata p q. {l}deliver(fdata) . q ∈ subterms p ⟹ q ∈ subterms p› 11. ‹⋀l fmsg p q. {l}receive(fmsg) . q ∈ subterms p ⟹ q ∈ subterms 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*) . subsection "Actions" text ‹ There are two sorts of ‹τ› actions in AWN: one at the level of individual processes (within nodes), and one at the network level (outside nodes). We define a class so that we can ignore this distinction whenever it is not critical. › class tau = fixes tau :: "'a" ("τ") subsubsection "Sequential Actions (and related predicates)" datatype 'm seq_action = broadcast 'm | groupcast "ip set" 'm | unicast ip 'm | notunicast ip ("¬unicast _" [1000] 60) | send 'm | deliver data | receive 'm | seq_tau ("τ⇩s") instantiation "seq_action" :: (type) tau begin definition step_seq_tau [simp]: "τ ≡ τ⇩s" instance .. end definition recvmsg :: "('m ⇒ bool) ⇒ 'm seq_action ⇒ bool" where "recvmsg P a ≡ case a of receive m ⇒ P m | _ ⇒ True" lemma recvmsg_simps[simp]: "⋀m. recvmsg P (broadcast m) = True" "⋀ips m. recvmsg P (groupcast ips m) = True" "⋀ip m. recvmsg P (unicast ip m) = True" "⋀ip. recvmsg P (notunicast ip) = True" "⋀m. recvmsg P (send m) = True" "⋀d. recvmsg P (deliver d) = True" "⋀m. recvmsg P (receive m) = P m" " recvmsg P τ⇩s = True" unfolding recvmsg_def (*goals: 1. ‹⋀m::'a. (case broadcast m of receive (m::'a) ⇒ (P::'a ⇒ bool) m | _ ⇒ True) = True› 2. ‹⋀(ips::nat set) m::'a. (case groupcast ips m of receive (m::'a) ⇒ (P::'a ⇒ bool) m | _ ⇒ True) = True› 3. ‹⋀(ip::nat) m::'a. (case unicast ip m of receive (m::'a) ⇒ (P::'a ⇒ bool) m | _ ⇒ True) = True› 4. ‹⋀ip::nat. (case ¬unicast ip of receive (m::'a) ⇒ (P::'a ⇒ bool) m | _ ⇒ True) = True› 5. ‹⋀m::'a. (case send m of receive (m::'a) ⇒ (P::'a ⇒ bool) m | _ ⇒ True) = True› 6. ‹⋀d::nat. (case deliver d of receive (m::'a) ⇒ (P::'a ⇒ bool) m | _ ⇒ True) = True› 7. ‹⋀m::'a. (case receive m of receive (m::'a) ⇒ (P::'a ⇒ bool) m | _ ⇒ True) = P m› 8. ‹(case τ⇩s of receive (m::'a) ⇒ (P::'a ⇒ bool) m | _ ⇒ True) = True›*) (*goals: 1. ‹⋀m. (case broadcast m of receive m ⇒ P m | _ ⇒ True) = True› 2. ‹⋀ips m. (case groupcast ips m of receive m ⇒ P m | _ ⇒ True) = True› 3. ‹⋀ip m. (case unicast ip m of receive m ⇒ P m | _ ⇒ True) = True› 4. ‹⋀ip. (case ¬unicast ip of receive m ⇒ P m | _ ⇒ True) = True› 5. ‹⋀m. (case send m of receive m ⇒ P m | _ ⇒ True) = True› 6. ‹⋀d. (case deliver d of receive m ⇒ P m | _ ⇒ True) = True› 7. ‹⋀m. (case receive m of receive m ⇒ P m | _ ⇒ True) = P m› 8. ‹(case τ⇩s of receive m ⇒ P m | _ ⇒ True) = True› 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 recvmsgTT [simp]: "recvmsg TT a" apply (cases a) (*goals: 1. ‹⋀x1. a = broadcast x1 ⟹ recvmsg TT a› 2. ‹⋀x21 x22. a = groupcast x21 x22 ⟹ recvmsg TT a› 3. ‹⋀x31 x32. a = unicast x31 x32 ⟹ recvmsg TT a› 4. ‹⋀x4. a = ¬unicast x4 ⟹ recvmsg TT a› 5. ‹⋀x5. a = send x5 ⟹ recvmsg TT a› 6. ‹⋀x6. a = deliver x6 ⟹ recvmsg TT a› 7. ‹⋀x7. a = receive x7 ⟹ recvmsg TT a› 8. ‹a = τ⇩s ⟹ recvmsg TT a› 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 recvmsgE [elim]: assumes "recvmsg (R σ) a" and "⋀m. R σ m ⟹ R σ' m" shows "recvmsg (R σ') a" using assms(1) (*‹recvmsg ((R::'b ⇒ 'a ⇒ bool) (σ::'b)) (a::'a seq_action)›*) apply (cases a) (*goals: 1. ‹⋀x1. ⟦recvmsg (R σ) a; a = broadcast x1⟧ ⟹ recvmsg (R σ') a› 2. ‹⋀x21 x22. ⟦recvmsg (R σ) a; a = groupcast x21 x22⟧ ⟹ recvmsg (R σ') a› 3. ‹⋀x31 x32. ⟦recvmsg (R σ) a; a = unicast x31 x32⟧ ⟹ recvmsg (R σ') a› 4. ‹⋀x4. ⟦recvmsg (R σ) a; a = ¬unicast x4⟧ ⟹ recvmsg (R σ') a› 5. ‹⋀x5. ⟦recvmsg (R σ) a; a = send x5⟧ ⟹ recvmsg (R σ') a› 6. ‹⋀x6. ⟦recvmsg (R σ) a; a = deliver x6⟧ ⟹ recvmsg (R σ') a› 7. ‹⋀x7. ⟦recvmsg (R σ) a; a = receive x7⟧ ⟹ recvmsg (R σ') a› 8. ‹⟦recvmsg (R σ) a; a = τ⇩s⟧ ⟹ recvmsg (R σ') a› discuss goal 1*) apply ((auto elim!: assms( (*‹R σ ?m ⟹ R σ' ?m›*) 2))[1]) (*discuss goal 2*) apply ((auto elim!: assms( (*‹R σ ?m ⟹ R σ' ?m›*) 2))[1]) (*discuss goal 3*) apply ((auto elim!: assms( (*‹R σ ?m ⟹ R σ' ?m›*) 2))[1]) (*discuss goal 4*) apply ((auto elim!: assms( (*‹R σ ?m ⟹ R σ' ?m›*) 2))[1]) (*discuss goal 5*) apply ((auto elim!: assms( (*‹R σ ?m ⟹ R σ' ?m›*) 2))[1]) (*discuss goal 6*) apply ((auto elim!: assms( (*‹(R::'b::type ⇒ 'a::type ⇒ bool) (σ::'b::type) (?m::'a::type) ⟹ R (σ'::'b::type) ?m›*) 2))[1]) (*discuss goal 7*) apply ((auto elim!: assms( (*‹R σ ?m ⟹ R σ' ?m›*) 2))[1]) (*discuss goal 8*) apply ((auto elim!: assms( (*‹(R::'b::type ⇒ 'a::type ⇒ bool) (σ::'b::type) (?m::'a::type) ⟹ R (σ'::'b::type) ?m›*) 2))[1]) (*proven 8 subgoals*) . definition anycast :: "('m ⇒ bool) ⇒ 'm seq_action ⇒ bool" where "anycast P a ≡ case a of broadcast m ⇒ P m | groupcast _ m ⇒ P m | unicast _ m ⇒ P m | _ ⇒ True" lemma anycast_simps [simp]: "⋀m. anycast P (broadcast m) = P m" "⋀ips m. anycast P (groupcast ips m) = P m" "⋀ip m. anycast P (unicast ip m) = P m" "⋀ip. anycast P (notunicast ip) = True" "⋀m. anycast P (send m) = True" "⋀d. anycast P (deliver d) = True" "⋀m. anycast P (receive m) = True" " anycast P τ⇩s = True" unfolding anycast_def (*goals: 1. ‹⋀m. (case broadcast m of broadcast m ⇒ P m | groupcast x m ⇒ P m | unicast x m ⇒ P m | _ ⇒ True) = P m› 2. ‹⋀ips m. (case groupcast ips m of broadcast m ⇒ P m | groupcast x m ⇒ P m | unicast x m ⇒ P m | _ ⇒ True) = P m› 3. ‹⋀ip m. (case unicast ip m of broadcast m ⇒ P m | groupcast x m ⇒ P m | unicast x m ⇒ P m | _ ⇒ True) = P m› 4. ‹⋀ip. (case ¬unicast ip of broadcast m ⇒ P m | groupcast x m ⇒ P m | unicast x m ⇒ P m | _ ⇒ True) = True› 5. ‹⋀m. (case send m of broadcast m ⇒ P m | groupcast x m ⇒ P m | unicast x m ⇒ P m | _ ⇒ True) = True› 6. ‹⋀d. (case deliver d of broadcast m ⇒ P m | groupcast x m ⇒ P m | unicast x m ⇒ P m | _ ⇒ True) = True› 7. ‹⋀m. (case receive m of broadcast m ⇒ P m | groupcast x m ⇒ P m | unicast x m ⇒ P m | _ ⇒ True) = True› 8. ‹(case τ⇩s of broadcast m ⇒ P m | groupcast x m ⇒ P m | unicast x m ⇒ P m | _ ⇒ True) = True›*) (*goals: 1. ‹⋀m. (case broadcast m of broadcast m ⇒ P m | groupcast x m ⇒ P m | unicast x m ⇒ P m | _ ⇒ True) = P m› 2. ‹⋀ips m. (case groupcast ips m of broadcast m ⇒ P m | groupcast x m ⇒ P m | unicast x m ⇒ P m | _ ⇒ True) = P m› 3. ‹⋀ip m. (case unicast ip m of broadcast m ⇒ P m | groupcast x m ⇒ P m | unicast x m ⇒ P m | _ ⇒ True) = P m› 4. ‹⋀ip. (case ¬unicast ip of broadcast m ⇒ P m | groupcast x m ⇒ P m | unicast x m ⇒ P m | _ ⇒ True) = True› 5. ‹⋀m. (case send m of broadcast m ⇒ P m | groupcast x m ⇒ P m | unicast x m ⇒ P m | _ ⇒ True) = True› 6. ‹⋀d. (case deliver d of broadcast m ⇒ P m | groupcast x m ⇒ P m | unicast x m ⇒ P m | _ ⇒ True) = True› 7. ‹⋀m. (case receive m of broadcast m ⇒ P m | groupcast x m ⇒ P m | unicast x m ⇒ P m | _ ⇒ True) = True› 8. ‹(case τ⇩s of broadcast m ⇒ P m | groupcast x m ⇒ P m | unicast x m ⇒ P m | _ ⇒ True) = True› 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*) . definition orecvmsg :: "((ip ⇒ 's) ⇒ 'm ⇒ bool) ⇒ (ip ⇒ 's) ⇒ 'm seq_action ⇒ bool" where "orecvmsg P σ a ≡ (case a of receive m ⇒ P σ m | _ ⇒ True)" lemma orecvmsg_simps [simp]: "⋀m. orecvmsg P σ (broadcast m) = True" "⋀ips m. orecvmsg P σ (groupcast ips m) = True" "⋀ip m. orecvmsg P σ (unicast ip m) = True" "⋀ip. orecvmsg P σ (notunicast ip) = True" "⋀m. orecvmsg P σ (send m) = True" "⋀d. orecvmsg P σ (deliver d) = True" "⋀m. orecvmsg P σ (receive m) = P σ m" " orecvmsg P σ τ⇩s = True" unfolding orecvmsg_def (*goals: 1. ‹⋀m::'a. (case broadcast m of receive (m::'a) ⇒ (P::(nat ⇒ 'b) ⇒ 'a ⇒ bool) (σ::nat ⇒ 'b) m | _ ⇒ True) = True› 2. ‹⋀(ips::nat set) m::'a. (case groupcast ips m of receive (m::'a) ⇒ (P::(nat ⇒ 'b) ⇒ 'a ⇒ bool) (σ::nat ⇒ 'b) m | _ ⇒ True) = True› 3. ‹⋀(ip::nat) m::'a. (case unicast ip m of receive (m::'a) ⇒ (P::(nat ⇒ 'b) ⇒ 'a ⇒ bool) (σ::nat ⇒ 'b) m | _ ⇒ True) = True› 4. ‹⋀ip::nat. (case ¬unicast ip of receive (m::'a) ⇒ (P::(nat ⇒ 'b) ⇒ 'a ⇒ bool) (σ::nat ⇒ 'b) m | _ ⇒ True) = True› 5. ‹⋀m::'a. (case send m of receive (m::'a) ⇒ (P::(nat ⇒ 'b) ⇒ 'a ⇒ bool) (σ::nat ⇒ 'b) m | _ ⇒ True) = True› 6. ‹⋀d::nat. (case deliver d of receive (m::'a) ⇒ (P::(nat ⇒ 'b) ⇒ 'a ⇒ bool) (σ::nat ⇒ 'b) m | _ ⇒ True) = True› 7. ‹⋀m::'a. (case receive m of receive (m::'a) ⇒ (P::(nat ⇒ 'b) ⇒ 'a ⇒ bool) (σ::nat ⇒ 'b) m | _ ⇒ True) = P σ m› 8. ‹(case τ⇩s of receive (m::'a) ⇒ (P::(nat ⇒ 'b) ⇒ 'a ⇒ bool) (σ::nat ⇒ 'b) m | _ ⇒ True) = True›*) (*goals: 1. ‹⋀m::'a::type. (case broadcast m of receive (m::'a::type) ⇒ (P::(nat ⇒ 'b::type) ⇒ 'a::type ⇒ bool) (σ::nat ⇒ 'b::type) m | _ ⇒ True) = True› 2. ‹⋀(ips::nat set) m::'a::type. (case groupcast ips m of receive (m::'a::type) ⇒ (P::(nat ⇒ 'b::type) ⇒ 'a::type ⇒ bool) (σ::nat ⇒ 'b::type) m | _ ⇒ True) = True› 3. ‹⋀(ip::nat) m::'a::type. (case unicast ip m of receive (m::'a::type) ⇒ (P::(nat ⇒ 'b::type) ⇒ 'a::type ⇒ bool) (σ::nat ⇒ 'b::type) m | _ ⇒ True) = True› 4. ‹⋀ip::nat. (case ¬unicast ip of receive (m::'a::type) ⇒ (P::(nat ⇒ 'b::type) ⇒ 'a::type ⇒ bool) (σ::nat ⇒ 'b::type) m | _ ⇒ True) = True› 5. ‹⋀m::'a::type. (case send m of receive (m::'a::type) ⇒ (P::(nat ⇒ 'b::type) ⇒ 'a::type ⇒ bool) (σ::nat ⇒ 'b::type) m | _ ⇒ True) = True› 6. ‹⋀d::nat. (case deliver d of receive (m::'a::type) ⇒ (P::(nat ⇒ 'b::type) ⇒ 'a::type ⇒ bool) (σ::nat ⇒ 'b::type) m | _ ⇒ True) = True› 7. ‹⋀m::'a::type. (case receive m of receive (m::'a::type) ⇒ (P::(nat ⇒ 'b::type) ⇒ 'a::type ⇒ bool) (σ::nat ⇒ 'b::type) m | _ ⇒ True) = P σ m› 8. ‹(case τ⇩s of receive (m::'a::type) ⇒ (P::(nat ⇒ 'b::type) ⇒ 'a::type ⇒ bool) (σ::nat ⇒ 'b::type) m | _ ⇒ True) = True› 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 orecvmsgEI [elim]: "⟦ orecvmsg P σ a; ⋀σ a. P σ a ⟹ Q σ a ⟧ ⟹ orecvmsg Q σ a" apply (cases a) (*goals: 1. ‹⋀x1. ⟦orecvmsg P σ a; ⋀σ a. P σ a ⟹ Q σ a; a = broadcast x1⟧ ⟹ orecvmsg Q σ a› 2. ‹⋀x21 x22. ⟦orecvmsg P σ a; ⋀σ a. P σ a ⟹ Q σ a; a = groupcast x21 x22⟧ ⟹ orecvmsg Q σ a› 3. ‹⋀x31 x32. ⟦orecvmsg P σ a; ⋀σ a. P σ a ⟹ Q σ a; a = unicast x31 x32⟧ ⟹ orecvmsg Q σ a› 4. ‹⋀x4. ⟦orecvmsg P σ a; ⋀σ a. P σ a ⟹ Q σ a; a = ¬unicast x4⟧ ⟹ orecvmsg Q σ a› 5. ‹⋀x5. ⟦orecvmsg P σ a; ⋀σ a. P σ a ⟹ Q σ a; a = send x5⟧ ⟹ orecvmsg Q σ a› 6. ‹⋀x6. ⟦orecvmsg P σ a; ⋀σ a. P σ a ⟹ Q σ a; a = deliver x6⟧ ⟹ orecvmsg Q σ a› 7. ‹⋀x7. ⟦orecvmsg P σ a; ⋀σ a. P σ a ⟹ Q σ a; a = receive x7⟧ ⟹ orecvmsg Q σ a› 8. ‹⟦orecvmsg P σ a; ⋀σ a. P σ a ⟹ Q σ a; a = τ⇩s⟧ ⟹ orecvmsg Q σ a› 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 orecvmsg_stateless_recvmsg [elim]: "orecvmsg (λ_. P) σ a ⟹ recvmsg P a" apply (cases a) (*goals: 1. ‹⋀x1::'b. ⟦orecvmsg (λ_::nat ⇒ 'a. P::'b ⇒ bool) (σ::nat ⇒ 'a) (a::'b seq_action); a = broadcast x1⟧ ⟹ recvmsg P a› 2. ‹⋀(x21::nat set) x22::'b. ⟦orecvmsg (λ_::nat ⇒ 'a. P::'b ⇒ bool) (σ::nat ⇒ 'a) (a::'b seq_action); a = groupcast x21 x22⟧ ⟹ recvmsg P a› 3. ‹⋀(x31::nat) x32::'b. ⟦orecvmsg (λ_::nat ⇒ 'a. P::'b ⇒ bool) (σ::nat ⇒ 'a) (a::'b seq_action); a = unicast x31 x32⟧ ⟹ recvmsg P a› 4. ‹⋀x4::nat. ⟦orecvmsg (λ_::nat ⇒ 'a. P::'b ⇒ bool) (σ::nat ⇒ 'a) (a::'b seq_action); a = ¬unicast x4⟧ ⟹ recvmsg P a› 5. ‹⋀x5::'b. ⟦orecvmsg (λ_::nat ⇒ 'a. P::'b ⇒ bool) (σ::nat ⇒ 'a) (a::'b seq_action); a = send x5⟧ ⟹ recvmsg P a› 6. ‹⋀x6::nat. ⟦orecvmsg (λ_::nat ⇒ 'a. P::'b ⇒ bool) (σ::nat ⇒ 'a) (a::'b seq_action); a = deliver x6⟧ ⟹ recvmsg P a› 7. ‹⋀x7::'b. ⟦orecvmsg (λ_::nat ⇒ 'a. P::'b ⇒ bool) (σ::nat ⇒ 'a) (a::'b seq_action); a = receive x7⟧ ⟹ recvmsg P a› 8. ‹⟦orecvmsg (λ_::nat ⇒ 'a. P::'b ⇒ bool) (σ::nat ⇒ 'a) (a::'b seq_action); a = τ⇩s⟧ ⟹ recvmsg P a› 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 orecvmsg_recv_weaken [elim]: "⟦ orecvmsg P σ a; ⋀σ a. P σ a ⟹ Q a ⟧ ⟹ recvmsg Q a" apply (cases a) (*goals: 1. ‹⋀x1. ⟦orecvmsg P σ a; ⋀σ a. P σ a ⟹ Q a; a = broadcast x1⟧ ⟹ recvmsg Q a› 2. ‹⋀x21 x22. ⟦orecvmsg P σ a; ⋀σ a. P σ a ⟹ Q a; a = groupcast x21 x22⟧ ⟹ recvmsg Q a› 3. ‹⋀x31 x32. ⟦orecvmsg P σ a; ⋀σ a. P σ a ⟹ Q a; a = unicast x31 x32⟧ ⟹ recvmsg Q a› 4. ‹⋀x4. ⟦orecvmsg P σ a; ⋀σ a. P σ a ⟹ Q a; a = ¬unicast x4⟧ ⟹ recvmsg Q a› 5. ‹⋀x5. ⟦orecvmsg P σ a; ⋀σ a. P σ a ⟹ Q a; a = send x5⟧ ⟹ recvmsg Q a› 6. ‹⋀x6. ⟦orecvmsg P σ a; ⋀σ a. P σ a ⟹ Q a; a = deliver x6⟧ ⟹ recvmsg Q a› 7. ‹⋀x7. ⟦orecvmsg P σ a; ⋀σ a. P σ a ⟹ Q a; a = receive x7⟧ ⟹ recvmsg Q a› 8. ‹⟦orecvmsg P σ a; ⋀σ a. P σ a ⟹ Q a; a = τ⇩s⟧ ⟹ recvmsg Q a› 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 orecvmsg_recvmsg [elim]: "orecvmsg P σ a ⟹ recvmsg (P σ) a" apply (cases a) (*goals: 1. ‹⋀x1. ⟦orecvmsg P σ a; a = broadcast x1⟧ ⟹ recvmsg (P σ) a› 2. ‹⋀x21 x22. ⟦orecvmsg P σ a; a = groupcast x21 x22⟧ ⟹ recvmsg (P σ) a› 3. ‹⋀x31 x32. ⟦orecvmsg P σ a; a = unicast x31 x32⟧ ⟹ recvmsg (P σ) a› 4. ‹⋀x4. ⟦orecvmsg P σ a; a = ¬unicast x4⟧ ⟹ recvmsg (P σ) a› 5. ‹⋀x5. ⟦orecvmsg P σ a; a = send x5⟧ ⟹ recvmsg (P σ) a› 6. ‹⋀x6. ⟦orecvmsg P σ a; a = deliver x6⟧ ⟹ recvmsg (P σ) a› 7. ‹⋀x7. ⟦orecvmsg P σ a; a = receive x7⟧ ⟹ recvmsg (P σ) a› 8. ‹⟦orecvmsg P σ a; a = τ⇩s⟧ ⟹ recvmsg (P σ) a› 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*) . definition sendmsg :: "('m ⇒ bool) ⇒ 'm seq_action ⇒ bool" where "sendmsg P a ≡ case a of send m ⇒ P m | _ ⇒ True" lemma sendmsg_simps [simp]: "⋀m. sendmsg P (broadcast m) = True" "⋀ips m. sendmsg P (groupcast ips m) = True" "⋀ip m. sendmsg P (unicast ip m) = True" "⋀ip. sendmsg P (notunicast ip) = True" "⋀m. sendmsg P (send m) = P m" "⋀d. sendmsg P (deliver d) = True" "⋀m. sendmsg P (receive m) = True" " sendmsg P τ⇩s = True" unfolding sendmsg_def (*goals: 1. ‹⋀m. (case broadcast m of send m ⇒ P m | _ ⇒ True) = True› 2. ‹⋀ips m. (case groupcast ips m of send m ⇒ P m | _ ⇒ True) = True› 3. ‹⋀ip m. (case unicast ip m of send m ⇒ P m | _ ⇒ True) = True› 4. ‹⋀ip. (case ¬unicast ip of send m ⇒ P m | _ ⇒ True) = True› 5. ‹⋀m. (case send m of send m ⇒ P m | _ ⇒ True) = P m› 6. ‹⋀d. (case deliver d of send m ⇒ P m | _ ⇒ True) = True› 7. ‹⋀m. (case receive m of send m ⇒ P m | _ ⇒ True) = True› 8. ‹(case τ⇩s of send m ⇒ P m | _ ⇒ True) = True›*) (*goals: 1. ‹⋀m. (case broadcast m of send m ⇒ P m | _ ⇒ True) = True› 2. ‹⋀ips m. (case groupcast ips m of send m ⇒ P m | _ ⇒ True) = True› 3. ‹⋀ip m. (case unicast ip m of send m ⇒ P m | _ ⇒ True) = True› 4. ‹⋀ip. (case ¬unicast ip of send m ⇒ P m | _ ⇒ True) = True› 5. ‹⋀m. (case send m of send m ⇒ P m | _ ⇒ True) = P m› 6. ‹⋀d. (case deliver d of send m ⇒ P m | _ ⇒ True) = True› 7. ‹⋀m. (case receive m of send m ⇒ P m | _ ⇒ True) = True› 8. ‹(case τ⇩s of send m ⇒ P m | _ ⇒ True) = True› 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*) . type_synonym ('s, 'm, 'p, 'l) seqp_env = "'p ⇒ ('s, 'm, 'p, 'l) seqp" subsubsection "Node Actions (and related predicates)" datatype 'm node_action = node_cast "ip set" 'm ("_:*cast'(_')" [200, 200] 200) | node_deliver ip data ("_:deliver'(_')" [200, 200] 200) | node_arrive "ip set" "ip set" 'm ("_¬_:arrive'(_')" [200, 200, 200] 200) | node_connect ip ip ("connect'(_, _')" [200, 200] 200) | node_disconnect ip ip ("disconnect'(_, _')" [200, 200] 200) | node_newpkt ip data ip ("_:newpkt'(_, _')" [200, 200, 200] 200) | node_tau ("τ⇩n") instantiation "node_action" :: (type) tau begin definition step_node_tau [simp]: "τ ≡ τ⇩n" instance .. end definition arrivemsg :: "ip ⇒ ('m ⇒ bool) ⇒ 'm node_action ⇒ bool" where "arrivemsg i P a ≡ case a of node_arrive ii ni m ⇒ ((ii = {i} ⟶ P m)) | _ ⇒ True" lemma arrivemsg_simps[simp]: "⋀R m. arrivemsg i P (R:*cast(m)) = True" "⋀d m. arrivemsg i P (d:deliver(m)) = True" "⋀i ii ni m. arrivemsg i P (ii¬ni:arrive(m)) = (ii = {i} ⟶ P m)" "⋀i1 i2. arrivemsg i P (connect(i1, i2)) = True" "⋀i1 i2. arrivemsg i P (disconnect(i1, i2)) = True" "⋀i i' d di. arrivemsg i P (i':newpkt(d, di)) = True" " arrivemsg i P τ⇩n = True" unfolding arrivemsg_def (*goals: 1. ‹⋀R m. (case R:*cast(m) of ii¬ni:arrive(m) ⇒ ii = {i} ⟶ P m | _ ⇒ True) = True› 2. ‹⋀d m. (case d:deliver(m) of ii¬ni:arrive(m) ⇒ ii = {i} ⟶ P m | _ ⇒ True) = True› 3. ‹⋀i ii ni m. (case ii¬ni:arrive(m) of ii¬ni:arrive(m) ⇒ ii = {i} ⟶ P m | _ ⇒ True) = (ii = {i} ⟶ P m)› 4. ‹⋀i1 i2. (case connect(i1, i2) of ii¬ni:arrive(m) ⇒ ii = {i} ⟶ P m | _ ⇒ True) = True› 5. ‹⋀i1 i2. (case disconnect(i1, i2) of ii¬ni:arrive(m) ⇒ ii = {i} ⟶ P m | _ ⇒ True) = True› 6. ‹⋀i i' d di. (case i':newpkt(d, di) of ii¬ni:arrive(m) ⇒ ii = {i} ⟶ P m | _ ⇒ True) = True› 7. ‹(case τ⇩n of ii¬ni:arrive(m) ⇒ ii = {i} ⟶ P m | _ ⇒ True) = True›*) (*goals: 1. ‹⋀R m. (case R:*cast(m) of ii¬ni:arrive(m) ⇒ ii = {i} ⟶ P m | _ ⇒ True) = True› 2. ‹⋀d m. (case d:deliver(m) of ii¬ni:arrive(m) ⇒ ii = {i} ⟶ P m | _ ⇒ True) = True› 3. ‹⋀i ii ni m. (case ii¬ni:arrive(m) of ii¬ni:arrive(m) ⇒ ii = {i} ⟶ P m | _ ⇒ True) = (ii = {i} ⟶ P m)› 4. ‹⋀i1 i2. (case connect(i1, i2) of ii¬ni:arrive(m) ⇒ ii = {i} ⟶ P m | _ ⇒ True) = True› 5. ‹⋀i1 i2. (case disconnect(i1, i2) of ii¬ni:arrive(m) ⇒ ii = {i} ⟶ P m | _ ⇒ True) = True› 6. ‹⋀i i' d di. (case i':newpkt(d, di) of ii¬ni:arrive(m) ⇒ ii = {i} ⟶ P m | _ ⇒ True) = True› 7. ‹(case τ⇩n of ii¬ni:arrive(m) ⇒ ii = {i} ⟶ P m | _ ⇒ True) = True› 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 (*proven 7 subgoals*) . lemma arrivemsgTT [simp]: "arrivemsg i TT = TT" apply (rule ext (*‹(⋀x. ?f x = ?g x) ⟹ ?f = ?g›*)) (*goal: ‹arrivemsg i TT = TT›*) by (clarsimp simp: arrivemsg_def (*‹arrivemsg ?i ?P ?a ≡ case ?a of ii¬ni:arrive(m) ⇒ ii = {?i} ⟶ ?P m | _ ⇒ True›*) split: node_action.split (*‹?P (case ?node_action of x:*cast(xa) ⇒ ?f1.0 x xa | x:deliver(xa) ⇒ ?f2.0 x xa | x¬xa:arrive(xb) ⇒ ?f3.0 x xa xb | connect(x, xa) ⇒ ?f4.0 x xa | disconnect(x, xa) ⇒ ?f5.0 x xa | x:newpkt(xa, xb) ⇒ ?f6.0 x xa xb | τ⇩n ⇒ ?f7.0) = ((∀x11 x12. ?node_action = x11:*cast(x12) ⟶ ?P (?f1.0 x11 x12)) ∧ (∀x21 x22. ?node_action = x21:deliver(x22) ⟶ ?P (?f2.0 x21 x22)) ∧ (∀x31 x32 x33. ?node_action = x31¬x32:arrive(x33) ⟶ ?P (?f3.0 x31 x32 x33)) ∧ (∀x41 x42. ?node_action = connect(x41, x42) ⟶ ?P (?f4.0 x41 x42)) ∧ (∀x51 x52. ?node_action = disconnect(x51, x52) ⟶ ?P (?f5.0 x51 x52)) ∧ (∀x61 x62 x63. ?node_action = x61:newpkt(x62, x63) ⟶ ?P (?f6.0 x61 x62 x63)) ∧ (?node_action = τ⇩n ⟶ ?P ?f7.0))›*)) definition oarrivemsg :: "((ip ⇒ 's) ⇒ 'm ⇒ bool) ⇒ (ip ⇒ 's) ⇒ 'm node_action ⇒ bool" where "oarrivemsg P σ a ≡ case a of node_arrive ii ni m ⇒ P σ m | _ ⇒ True" lemma oarrivemsg_simps[simp]: "⋀R m. oarrivemsg P σ (R:*cast(m)) = True" "⋀d m. oarrivemsg P σ (d:deliver(m)) = True" "⋀i ii ni m. oarrivemsg P σ (ii¬ni:arrive(m)) = P σ m" "⋀i1 i2. oarrivemsg P σ (connect(i1, i2)) = True" "⋀i1 i2. oarrivemsg P σ (disconnect(i1, i2)) = True" "⋀i i' d di. oarrivemsg P σ (i':newpkt(d, di)) = True" " oarrivemsg P σ τ⇩n = True" unfolding oarrivemsg_def (*goals: 1. ‹⋀R m. (case R:*cast(m) of ii¬ni:arrive(m) ⇒ P σ m | _ ⇒ True) = True› 2. ‹⋀d m. (case d:deliver(m) of ii¬ni:arrive(m) ⇒ P σ m | _ ⇒ True) = True› 3. ‹⋀i ii ni m. (case ii¬ni:arrive(m) of ii¬ni:arrive(m) ⇒ P σ m | _ ⇒ True) = P σ m› 4. ‹⋀i1 i2. (case connect(i1, i2) of ii¬ni:arrive(m) ⇒ P σ m | _ ⇒ True) = True› 5. ‹⋀i1 i2. (case disconnect(i1, i2) of ii¬ni:arrive(m) ⇒ P σ m | _ ⇒ True) = True› 6. ‹⋀i i' d di. (case i':newpkt(d, di) of ii¬ni:arrive(m) ⇒ P σ m | _ ⇒ True) = True› 7. ‹(case τ⇩n of ii¬ni:arrive(m) ⇒ P σ m | _ ⇒ True) = True›*) (*goals: 1. ‹⋀R m. (case R:*cast(m) of ii¬ni:arrive(m) ⇒ P σ m | _ ⇒ True) = True› 2. ‹⋀d m. (case d:deliver(m) of ii¬ni:arrive(m) ⇒ P σ m | _ ⇒ True) = True› 3. ‹⋀i ii ni m. (case ii¬ni:arrive(m) of ii¬ni:arrive(m) ⇒ P σ m | _ ⇒ True) = P σ m› 4. ‹⋀i1 i2. (case connect(i1, i2) of ii¬ni:arrive(m) ⇒ P σ m | _ ⇒ True) = True› 5. ‹⋀i1 i2. (case disconnect(i1, i2) of ii¬ni:arrive(m) ⇒ P σ m | _ ⇒ True) = True› 6. ‹⋀i i' d di. (case i':newpkt(d, di) of ii¬ni:arrive(m) ⇒ P σ m | _ ⇒ True) = True› 7. ‹(case τ⇩n of ii¬ni:arrive(m) ⇒ P σ m | _ ⇒ True) = True› 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 (*proven 7 subgoals*) . lemma oarrivemsg_True [simp, intro]: "oarrivemsg (λ_ _. True) σ a" apply (cases a) (*goals: 1. ‹⋀x11 x12. a = x11:*cast(x12) ⟹ oarrivemsg (λ_ _. True) σ a› 2. ‹⋀x21 x22. a = x21:deliver(x22) ⟹ oarrivemsg (λ_ _. True) σ a› 3. ‹⋀x31 x32 x33. a = x31¬x32:arrive(x33) ⟹ oarrivemsg (λ_ _. True) σ a› 4. ‹⋀x41 x42. a = connect(x41, x42) ⟹ oarrivemsg (λ_ _. True) σ a› 5. ‹⋀x51 x52. a = disconnect(x51, x52) ⟹ oarrivemsg (λ_ _. True) σ a› 6. ‹⋀x61 x62 x63. a = x61:newpkt(x62, x63) ⟹ oarrivemsg (λ_ _. True) σ a› 7. ‹a = τ⇩n ⟹ oarrivemsg (λ_ _. True) σ 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]) (*discuss goal 6*) apply ((auto)[1]) (*discuss goal 7*) apply ((auto)[1]) (*proven 7 subgoals*) . definition castmsg :: "('m ⇒ bool) ⇒ 'm node_action ⇒ bool" where "castmsg P a ≡ case a of _:*cast(m) ⇒ P m | _ ⇒ True" lemma castmsg_simps[simp]: "⋀R m. castmsg P (R:*cast(m)) = P m" "⋀d m. castmsg P (d:deliver(m)) = True" "⋀i ii ni m. castmsg P (ii¬ni:arrive(m)) = True" "⋀i1 i2. castmsg P (connect(i1, i2)) = True" "⋀i1 i2. castmsg P (disconnect(i1, i2)) = True" "⋀i i' d di. castmsg P (i':newpkt(d, di)) = True" " castmsg P τ⇩n = True" unfolding castmsg_def (*goals: 1. ‹⋀R m. (case R:*cast(m) of x:*cast(m) ⇒ P m | _ ⇒ True) = P m› 2. ‹⋀d m. (case d:deliver(m) of x:*cast(m) ⇒ P m | _ ⇒ True) = True› 3. ‹⋀i ii ni m. (case ii¬ni:arrive(m) of x:*cast(m) ⇒ P m | _ ⇒ True) = True› 4. ‹⋀i1 i2. (case connect(i1, i2) of x:*cast(m) ⇒ P m | _ ⇒ True) = True› 5. ‹⋀i1 i2. (case disconnect(i1, i2) of x:*cast(m) ⇒ P m | _ ⇒ True) = True› 6. ‹⋀i i' d di. (case i':newpkt(d, di) of x:*cast(m) ⇒ P m | _ ⇒ True) = True› 7. ‹(case τ⇩n of x:*cast(m) ⇒ P m | _ ⇒ True) = True›*) (*goals: 1. ‹⋀(R::nat set) m::'a::type. (case R:*cast(m) of (x::nat set):*cast((m::'a::type)) ⇒ (P::'a::type ⇒ bool) m | _ ⇒ True) = P m› 2. ‹⋀(d::nat) m::nat. (case d:deliver(m) of (x::nat set):*cast((m::'a::type)) ⇒ (P::'a::type ⇒ bool) m | _ ⇒ True) = True› 3. ‹⋀(i::'b::type) (ii::nat set) (ni::nat set) m::'a::type. (case ii¬ni:arrive(m) of (x::nat set):*cast((m::'a::type)) ⇒ (P::'a::type ⇒ bool) m | _ ⇒ True) = True› 4. ‹⋀(i1::nat) i2::nat. (case connect(i1, i2) of (x::nat set):*cast((m::'a::type)) ⇒ (P::'a::type ⇒ bool) m | _ ⇒ True) = True› 5. ‹⋀(i1::nat) i2::nat. (case disconnect(i1, i2) of (x::nat set):*cast((m::'a::type)) ⇒ (P::'a::type ⇒ bool) m | _ ⇒ True) = True› 6. ‹⋀(i::'c::type) (i'::nat) (d::nat) di::nat. (case i':newpkt(d, di) of (x::nat set):*cast((m::'a::type)) ⇒ (P::'a::type ⇒ bool) m | _ ⇒ True) = True› 7. ‹(case τ⇩n of (x::nat set):*cast((m::'a::type)) ⇒ (P::'a::type ⇒ bool) m | _ ⇒ True) = True› 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 (*proven 7 subgoals*) . subsection "Networks" datatype net_tree = Node ip "ip set" ("⟨_; _⟩") | Subnet net_tree net_tree (infixl "∥" 90) declare net_tree.induct [[induct del]] lemmas net_tree_induct [induct type: net_tree] = net_tree.induct [rename_abs i R p1 p2] datatype 's net_state = NodeS ip 's "ip set" | SubnetS "'s net_state" "'s net_state" fun net_ips :: "'s net_state ⇒ ip set" where "net_ips (NodeS i s R) = {i}" | "net_ips (SubnetS n1 n2) = net_ips n1 ∪ net_ips n2" fun net_tree_ips :: "net_tree ⇒ ip set" where "net_tree_ips (p1 ∥ p2) = net_tree_ips p1 ∪ net_tree_ips p2" | "net_tree_ips (⟨i; R⟩) = {i}" lemma net_tree_ips_commute: "net_tree_ips (p1 ∥ p2) = net_tree_ips (p2 ∥ p1)" apply simp (*goal: ‹net_tree_ips (p1 ∥ p2) = net_tree_ips (p2 ∥ p1)›*) by (rule Un_commute (*‹?A ∪ ?B = ?B ∪ ?A›*)) fun wf_net_tree :: "net_tree ⇒ bool" where "wf_net_tree (p1 ∥ p2) = (net_tree_ips p1 ∩ net_tree_ips p2 = {} ∧ wf_net_tree p1 ∧ wf_net_tree p2)" | "wf_net_tree (⟨i; R⟩) = True" lemma wf_net_tree_children [elim]: assumes "wf_net_tree (p1 ∥ p2)" obtains "wf_net_tree p1" and "wf_net_tree p2" using assms (*‹wf_net_tree (p1 ∥ p2)›*) by simp fun netmap :: "'s net_state ⇒ ip ⇒ 's option" where "netmap (NodeS i p R⇩i) = [i ↦ p]" | "netmap (SubnetS s t) = netmap s ++ netmap t" lemma not_in_netmap [simp]: assumes "i ∉ net_ips ns" shows "netmap ns i = None" using assms (*‹i ∉ net_ips ns›*) apply (induction ns) (*goals: 1. ‹⋀x1 x2 x3. i ∉ net_ips (NodeS x1 x2 x3) ⟹ netmap (NodeS x1 x2 x3) i = None› 2. ‹⋀ns1 ns2. ⟦i ∉ net_ips ns1 ⟹ netmap ns1 i = None; i ∉ net_ips ns2 ⟹ netmap ns2 i = None; i ∉ net_ips (SubnetS ns1 ns2)⟧ ⟹ netmap (SubnetS ns1 ns2) i = None› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) . lemma netmap_none_not_in_net_ips: assumes "netmap ns i = None" shows "i∉net_ips ns" using assms (*‹netmap ns i = None›*) apply (induction ns) (*goals: 1. ‹⋀x1 x2 x3. netmap (NodeS x1 x2 x3) i = None ⟹ i ∉ net_ips (NodeS x1 x2 x3)› 2. ‹⋀ns1 ns2. ⟦netmap ns1 i = None ⟹ i ∉ net_ips ns1; netmap ns2 i = None ⟹ i ∉ net_ips ns2; netmap (SubnetS ns1 ns2) i = None⟧ ⟹ i ∉ net_ips (SubnetS ns1 ns2)› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . lemma net_ips_is_dom_netmap: "net_ips s = dom(netmap s)" proof (induction s) (*goals: 1. ‹⋀x1 x2 x3. net_ips (NodeS x1 x2 x3) = dom (netmap (NodeS x1 x2 x3))› 2. ‹⋀s1 s2. ⟦net_ips s1 = dom (netmap s1); net_ips s2 = dom (netmap s2)⟧ ⟹ net_ips (SubnetS s1 s2) = dom (netmap (SubnetS s1 s2))›*) fix i and R⇩i and p :: 's show "net_ips (NodeS i p R⇩i) = dom (netmap (NodeS i p R⇩i))" by auto next (*goal: ‹⋀s1 s2. ⟦net_ips s1 = dom (netmap s1); net_ips s2 = dom (netmap s2)⟧ ⟹ net_ips (SubnetS s1 s2) = dom (netmap (SubnetS s1 s2))›*) fix s1 :: "'s net_state" and s2 :: "'s net_state" assume "net_ips s1 = dom (netmap s1)" and "net_ips s2 = dom (netmap s2)" (*‹net_ips (s1::'s net_state) = dom (netmap s1)› ‹net_ips (s2::'s net_state) = dom (netmap s2)›*) thus "net_ips (SubnetS s1 s2) = dom (netmap (SubnetS s1 s2))" by auto qed lemma in_netmap [simp]: assumes "i ∈ net_ips ns" shows "netmap ns i ≠ None" using assms (*‹i ∈ net_ips ns›*) by (auto simp add: net_ips_is_dom_netmap (*‹net_ips ?s = dom (netmap ?s)›*)) lemma netmap_subnets_same: assumes "netmap s1 i = x" and "netmap s2 i = x" shows "netmap (SubnetS s1 s2) i = x" using assms (*‹netmap (s1::'a::type net_state) (i::nat) = (x::'a::type option)› ‹netmap s2 i = x›*) apply simp (*goal: ‹netmap (SubnetS s1 s2) i = x›*) by (metis map_add_dom_app_simps( (*‹?m ∈ dom ?l2.0 ⟹ (?l1.0 ++ ?l2.0) ?m = ?l2.0 ?m›*) 1) map_add_dom_app_simps( (*‹?m ∉ dom ?l2.0 ⟹ (?l1.0 ++ ?l2.0) ?m = ?l1.0 ?m›*) 3)) lemma netmap_subnets_samef: assumes "netmap s1 = f" and "netmap s2 = f" shows "netmap (SubnetS s1 s2) = f" using assms (*‹netmap (s1::'a net_state) = (f::nat ⇒ 'a option)› ‹netmap s2 = f›*) apply simp (*goal: ‹netmap (SubnetS s1 s2) = f›*) by (metis map_add_le_mapI (*‹⟦?f ⊆⇩m ?h; ?g ⊆⇩m ?h⟧ ⟹ ?f ++ ?g ⊆⇩m ?h›*) map_le_antisym (*‹⟦?f ⊆⇩m ?g; ?g ⊆⇩m ?f⟧ ⟹ ?f = ?g›*) map_le_map_add (*‹?f ⊆⇩m ?g ++ ?f›*) map_le_refl (*‹?f ⊆⇩m ?f›*)) lemma netmap_add_disjoint [elim]: assumes "∀i∈net_ips s1 ∪ net_ips s2. the ((netmap s1 ++ netmap s2) i) = σ i" and "net_ips s1 ∩ net_ips s2 = {}" shows "∀i∈net_ips s1. the (netmap s1 i) = σ i" proof (standard) (*goal: ‹⋀i. i ∈ net_ips s1 ⟹ the (netmap s1 i) = σ i›*) fix i assume "i ∈ net_ips s1" (*‹(i::nat) ∈ net_ips (s1::'a net_state)›*) hence "i ∈ dom(netmap s1)" by (simp add: net_ips_is_dom_netmap (*‹net_ips ?s = dom (netmap ?s)›*)) moreover with assms(2) (*‹net_ips (s1::'a net_state) ∩ net_ips (s2::'a net_state) = {}›*) have "i ∉ dom(netmap s2)" by (auto simp add: net_ips_is_dom_netmap (*‹net_ips ?s = dom (netmap ?s)›*)) ultimately have "the (netmap s1 i) = the ((netmap s1 ++ netmap s2) i)" by (simp add: map_add_dom_app_simps (*‹?m ∈ dom ?l2.0 ⟹ (?l1.0 ++ ?l2.0) ?m = ?l2.0 ?m› ‹?m ∉ dom ?l1.0 ⟹ (?l1.0 ++ ?l2.0) ?m = ?l2.0 ?m› ‹?m ∉ dom ?l2.0 ⟹ (?l1.0 ++ ?l2.0) ?m = ?l1.0 ?m›*)) with assms(1) (*‹∀i::nat∈net_ips (s1::'a::type net_state) ∪ net_ips (s2::'a::type net_state). the ((netmap s1 ++ netmap s2) i) = (σ::nat ⇒ 'a::type) i›*) ‹i∈net_ips s1› (*‹i ∈ net_ips s1›*) show "the (netmap s1 i) = σ i" by simp qed lemma netmap_add_disjoint2 [elim]: assumes "∀i∈net_ips s1 ∪ net_ips s2. the ((netmap s1 ++ netmap s2) i) = σ i" shows "∀i∈net_ips s2. the (netmap s2 i) = σ i" using assms (*‹∀i∈net_ips s1 ∪ net_ips s2. the ((netmap s1 ++ netmap s2) i) = σ i›*) apply (simp add: net_ips_is_dom_netmap (*‹net_ips ?s = dom (netmap ?s)›*)) (*goal: ‹∀i::nat∈net_ips (s2::'a::type net_state). the (netmap s2 i) = (σ::nat ⇒ 'a::type) i›*) by (metis Un_iff (*‹((?c::?'a) ∈ (?A::?'a set) ∪ (?B::?'a set)) = (?c ∈ ?A ∨ ?c ∈ ?B)›*) map_add_dom_app_simps( (*‹(?m::?'a) ∈ dom (?l2.0::?'a ⇒ ?'b option) ⟹ ((?l1.0::?'a ⇒ ?'b option) ++ ?l2.0) ?m = ?l2.0 ?m›*) 1)) lemma net_ips_netmap_subnet [elim]: assumes "net_ips s1 ∩ net_ips s2 = {}" and "∀i∈net_ips (SubnetS s1 s2). the (netmap (SubnetS s1 s2) i) = σ i" shows "∀i∈net_ips s1. the (netmap s1 i) = σ i" and "∀i∈net_ips s2. the (netmap s2 i) = σ i" proof (-) (*goals: 1. ‹∀i∈net_ips s1. the (netmap s1 i) = σ i› 2. ‹∀i∈net_ips s2. the (netmap s2 i) = σ i›*) from assms(2) (*‹∀i∈net_ips (SubnetS s1 s2). the (netmap (SubnetS s1 s2) i) = σ i›*) have "∀i∈net_ips s1 ∪ net_ips s2. the ((netmap s1 ++ netmap s2) i) = σ i" by auto with assms(1) (*‹net_ips s1 ∩ net_ips s2 = {}›*) show "∀i∈net_ips s1. the (netmap s1 i) = σ i" apply - (*goal: ‹∀i∈net_ips s1. the (netmap s1 i) = σ i›*) by (erule(1) netmap_add_disjoint (*‹⟦∀i::nat∈net_ips (?s1.0::?'a::type net_state) ∪ net_ips (?s2.0::?'a::type net_state). the ((netmap ?s1.0 ++ netmap ?s2.0) i) = (?σ::nat ⇒ ?'a::type) i; net_ips ?s1.0 ∩ net_ips ?s2.0 = {}⟧ ⟹ ∀i::nat∈net_ips ?s1.0. the (netmap ?s1.0 i) = ?σ i›*)) next (*goal: ‹∀i∈net_ips s2. the (netmap s2 i) = σ i›*) from assms(2) (*‹∀i∈net_ips (SubnetS s1 s2). the (netmap (SubnetS s1 s2) i) = σ i›*) have "∀i∈net_ips s1 ∪ net_ips s2. the ((netmap s1 ++ netmap s2) i) = σ i" by auto thus "∀i∈net_ips s2. the (netmap s2 i) = σ i" apply - (*goal: ‹∀i∈net_ips s2. the (netmap s2 i) = σ i›*) by (erule netmap_add_disjoint2 (*‹∀i∈net_ips ?s1.0 ∪ net_ips ?s2.0. the ((netmap ?s1.0 ++ netmap ?s2.0) i) = ?σ i ⟹ ∀i∈net_ips ?s2.0. the (netmap ?s2.0 i) = ?σ i›*)) qed fun inoclosed :: "'s ⇒ 'm::msg node_action ⇒ bool" where "inoclosed _ (node_arrive ii ni m) = eq_newpkt m" | "inoclosed _ (node_newpkt i d di) = False" | "inoclosed _ _ = True" lemma inclosed_simps [simp]: "⋀σ ii ni. inoclosed σ (ii¬ni:arrive(m)) = eq_newpkt m" "⋀σ d di. inoclosed σ (i:newpkt(d, di)) = False" "⋀σ R m. inoclosed σ (R:*cast(m)) = True" "⋀σ i d. inoclosed σ (i:deliver(d)) = True" "⋀σ i i'. inoclosed σ (connect(i, i')) = True" "⋀σ i i'. inoclosed σ (disconnect(i, i')) = True" "⋀σ. inoclosed σ (τ) = True" (*goals: 1. ‹⋀σ ii ni. inoclosed σ (ii¬ni:arrive(m)) = eq_newpkt m› 2. ‹⋀σ d di. inoclosed σ (i:newpkt(d, di)) = False› 3. ‹⋀σ R m. inoclosed σ (R:*cast(m)) = True› 4. ‹⋀σ i d. inoclosed σ (i:deliver(d)) = True› 5. ‹⋀σ i i'. inoclosed σ (connect(i, i')) = True› 6. ‹⋀σ i i'. inoclosed σ (disconnect(i, i')) = True› 7. ‹⋀σ. inoclosed σ τ = True› 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*) . definition netmask :: "ip set ⇒ ((ip ⇒ 's) × 'l) ⇒ ((ip ⇒ 's option) × 'l)" where "netmask I s ≡ (λi. if i∈I then Some (fst s i) else None, snd s)" lemma netmask_def' [simp]: "netmask I (σ, ζ) = (λi. if i∈I then Some (σ i) else None, ζ)" unfolding netmask_def (*goal: ‹(λi::nat. if i ∈ (I::nat set) then Some (fst (σ::nat ⇒ 'a, ζ::'b) i) else None, snd (σ, ζ)) = (λi::nat. if i ∈ I then Some (σ i) else None, ζ)›*) by auto fun netgmap :: "('s ⇒ 'g × 'l) ⇒ 's net_state ⇒ (nat ⇒ 'g option) × 'l net_state" where "netgmap sr (NodeS i s R) = ([i ↦ fst (sr s)], NodeS i (snd (sr s)) R)" | "netgmap sr (SubnetS s₁ s₂) = (let (σ₁, ss) = netgmap sr s₁ in let (σ₂, tt) = netgmap sr s₂ in (σ₁ ++ σ₂, SubnetS ss tt))" lemma dom_fst_netgmap [simp, intro]: "dom (fst (netgmap sr n)) = net_ips n" proof (induction n) (*goals: 1. ‹⋀x1 x2 x3. dom (fst (netgmap sr (NodeS x1 x2 x3))) = net_ips (NodeS x1 x2 x3)› 2. ‹⋀n1 n2. ⟦dom (fst (netgmap sr n1)) = net_ips n1; dom (fst (netgmap sr n2)) = net_ips n2⟧ ⟹ dom (fst (netgmap sr (SubnetS n1 n2))) = net_ips (SubnetS n1 n2)›*) fix i and s and R show "dom (fst (netgmap sr (NodeS i s R))) = net_ips (NodeS i s R)" by simp next (*goal: ‹⋀(n1::'c net_state) n2::'c net_state. ⟦dom (fst (netgmap (sr::'c ⇒ 'a × 'b) n1)) = net_ips n1; dom (fst (netgmap sr n2)) = net_ips n2⟧ ⟹ dom (fst (netgmap sr (SubnetS n1 n2))) = net_ips (SubnetS n1 n2)›*) fix n1 and n2 assume a1: "dom (fst (netgmap sr n1)) = net_ips n1" and a2: "dom (fst (netgmap sr n2)) = net_ips n2" (*‹dom (fst (netgmap (sr::'c ⇒ 'a × 'b) (n1::'c net_state))) = net_ips n1› ‹dom (fst (netgmap (sr::'c ⇒ 'a × 'b) (n2::'c net_state))) = net_ips n2›*) obtain σ₁ and ζ₁ and σ₂ and ζ₂ where nm1: "netgmap sr n1 = (σ₁, ζ₁)" and nm2: "netgmap sr n2 = (σ₂, ζ₂)" (*goal: ‹(⋀σ₁ ζ₁ σ₂ ζ₂. ⟦netgmap sr n1 = (σ₁, ζ₁); netgmap sr n2 = (σ₂, ζ₂)⟧ ⟹ thesis) ⟹ thesis›*) by (metis surj_pair (*‹∃x y. ?p = (x, y)›*)) hence "netgmap sr (SubnetS n1 n2) = (σ₁ ++ σ₂, SubnetS ζ₁ ζ₂)" by simp hence "dom (fst (netgmap sr (SubnetS n1 n2))) = dom (σ₁ ++ σ₂)" by simp also (*calculation: ‹dom (fst (netgmap (sr::'c ⇒ 'a × 'b) (SubnetS (n1::'c net_state) (n2::'c net_state)))) = dom ((σ₁::nat ⇒ 'a option) ++ (σ₂::nat ⇒ 'a option))›*) from a1 (*‹dom (fst (netgmap sr n1)) = net_ips n1›*) a2 (*‹dom (fst (netgmap sr n2)) = net_ips n2›*) nm1 (*‹netgmap sr n1 = (σ₁, ζ₁)›*) nm2 (*‹netgmap sr n2 = (σ₂, ζ₂)›*) have "dom (σ₁ ++ σ₂) = net_ips (SubnetS n1 n2)" by auto finally (*calculation: ‹dom (fst (netgmap sr (SubnetS n1 n2))) = net_ips (SubnetS n1 n2)›*) show "dom (fst (netgmap sr (SubnetS n1 n2))) = net_ips (SubnetS n1 n2)" . qed lemma netgmap_pair_dom [elim]: obtains σ ζ where "netgmap sr n = (σ, ζ)" and "dom σ = net_ips n" by (metis dom_fst_netgmap (*‹dom (fst (netgmap ?sr ?n)) = net_ips ?n›*) surjective_pairing (*‹?t = (fst ?t, snd ?t)›*)) lemma net_ips_netgmap [simp]: "net_ips (snd (netgmap sr s)) = net_ips s" proof (induction s) (*goals: 1. ‹⋀x1 x2 x3. net_ips (snd (netgmap sr (NodeS x1 x2 x3))) = net_ips (NodeS x1 x2 x3)› 2. ‹⋀s1 s2. ⟦net_ips (snd (netgmap sr s1)) = net_ips s1; net_ips (snd (netgmap sr s2)) = net_ips s2⟧ ⟹ net_ips (snd (netgmap sr (SubnetS s1 s2))) = net_ips (SubnetS s1 s2)›*) fix s1 and s2 assume "net_ips (snd (netgmap sr s1)) = net_ips s1" and "net_ips (snd (netgmap sr s2)) = net_ips s2" (*‹net_ips (snd (netgmap (sr::'c ⇒ 'b × 'a) (s1::'c net_state))) = net_ips s1› ‹net_ips (snd (netgmap (sr::'c ⇒ 'b × 'a) (s2::'c net_state))) = net_ips s2›*) thus "net_ips (snd (netgmap sr (SubnetS s1 s2))) = net_ips (SubnetS s1 s2)" apply (cases "netgmap sr s1") (*goal: ‹net_ips (snd (netgmap sr (SubnetS s1 s2))) = net_ips (SubnetS s1 s2)›*) apply (cases "netgmap sr s2") (*goal: ‹⋀a b. ⟦net_ips (snd (netgmap sr s1)) = net_ips s1; net_ips (snd (netgmap sr s2)) = net_ips s2; netgmap sr s1 = (a, b)⟧ ⟹ net_ips (snd (netgmap sr (SubnetS s1 s2))) = net_ips (SubnetS s1 s2)›*) by auto qed (simp) (*solved the remaining goal: ‹⋀x1 x2 x3. net_ips (snd (netgmap sr (NodeS x1 x2 x3))) = net_ips (NodeS x1 x2 x3)›*) lemma some_the_fst_netgmap: assumes "i ∈ net_ips s" shows "Some (the (fst (netgmap sr s) i)) = fst (netgmap sr s) i" using assms (*‹i ∈ net_ips s›*) by (metis domIff (*‹(?a ∈ dom ?m) = (?m ?a ≠ None)›*) dom_fst_netgmap (*‹dom (fst (netgmap ?sr ?n)) = net_ips ?n›*) option.collapse (*‹?option ≠ None ⟹ Some (the ?option) = ?option›*)) lemma fst_netgmap_none [simp]: assumes "i ∉ net_ips s" shows "fst (netgmap sr s) i = None" using assms (*‹i ∉ net_ips s›*) by (metis domIff (*‹(?a ∈ dom ?m) = (?m ?a ≠ None)›*) dom_fst_netgmap (*‹dom (fst (netgmap ?sr ?n)) = net_ips ?n›*)) lemma fst_netgmap_subnet [simp]: "fst (case netgmap sr s1 of (σ₁, ss) ⇒ case netgmap sr s2 of (σ₂, tt) ⇒ (σ₁ ++ σ₂, SubnetS ss tt)) = (fst (netgmap sr s1) ++ fst (netgmap sr s2))" by (metis (mono_tags) fst_conv (*‹fst (?x1.0::?'a, ?x2.0::?'b) = ?x1.0›*) netgmap_pair_dom (*‹(⋀(σ::nat ⇒ ?'a option) ζ::?'b net_state. ⟦netgmap (?sr::?'c ⇒ ?'a × ?'b) (?n::?'c net_state) = (σ, ζ); dom σ = net_ips ?n⟧ ⟹ ?thesis::bool) ⟹ ?thesis›*) split_conv (*‹(case (?a::?'b, ?b::?'c) of (c::?'b, d::?'c) ⇒ (?f::?'b ⇒ ?'c ⇒ ?'a) c d) = ?f ?a ?b›*)) lemma snd_netgmap_subnet [simp]: "snd (case netgmap sr s1 of (σ₁, ss) ⇒ case netgmap sr s2 of (σ₂, tt) ⇒ (σ₁ ++ σ₂, SubnetS ss tt)) = (SubnetS (snd (netgmap sr s1)) (snd (netgmap sr s2)))" by (metis (lifting, no_types) Pair_inject (*‹⟦(?a, ?b) = (?a', ?b'); ⟦?a = ?a'; ?b = ?b'⟧ ⟹ ?R⟧ ⟹ ?R›*) split_beta' (*‹(λ(x, y). ?f x y) = (λx. ?f (fst x) (snd x))›*) surjective_pairing (*‹?t = (fst ?t, snd ?t)›*)) lemma fst_netgmap_not_none [simp]: assumes "i ∈ net_ips s" shows "fst (netgmap sr s) i ≠ None" using assms (*‹i ∈ net_ips s›*) apply (induction s) (*goals: 1. ‹⋀x1 x2 x3. i ∈ net_ips (NodeS x1 x2 x3) ⟹ fst (netgmap sr (NodeS x1 x2 x3)) i ≠ None› 2. ‹⋀s1 s2. ⟦i ∈ net_ips s1 ⟹ fst (netgmap sr s1) i ≠ None; i ∈ net_ips s2 ⟹ fst (netgmap sr s2) i ≠ None; i ∈ net_ips (SubnetS s1 s2)⟧ ⟹ fst (netgmap sr (SubnetS s1 s2)) i ≠ None› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . lemma netgmap_netgmap_not_rhs [simp]: assumes "i ∉ net_ips s2" shows "(fst (netgmap sr s1) ++ fst (netgmap sr s2)) i = (fst (netgmap sr s1)) i" proof (-) (*goal: ‹(fst (netgmap sr s1) ++ fst (netgmap sr s2)) i = fst (netgmap sr s1) i›*) from assms(1) (*‹i ∉ net_ips s2›*) have "i ∉ dom (fst (netgmap sr s2))" by simp thus "?thesis" (*goal: ‹(fst (netgmap sr s1) ++ fst (netgmap sr s2)) i = fst (netgmap sr s1) i›*) by (simp add: map_add_dom_app_simps (*‹?m ∈ dom ?l2.0 ⟹ (?l1.0 ++ ?l2.0) ?m = ?l2.0 ?m› ‹?m ∉ dom ?l1.0 ⟹ (?l1.0 ++ ?l2.0) ?m = ?l2.0 ?m› ‹?m ∉ dom ?l2.0 ⟹ (?l1.0 ++ ?l2.0) ?m = ?l1.0 ?m›*)) qed lemma netgmap_netgmap_rhs [simp]: assumes "i ∈ net_ips s2" shows "(fst (netgmap sr s1) ++ fst (netgmap sr s2)) i = (fst (netgmap sr s2)) i" using assms (*‹i ∈ net_ips s2›*) by (simp add: map_add_dom_app_simps (*‹?m ∈ dom ?l2.0 ⟹ (?l1.0 ++ ?l2.0) ?m = ?l2.0 ?m› ‹?m ∉ dom ?l1.0 ⟹ (?l1.0 ++ ?l2.0) ?m = ?l2.0 ?m› ‹?m ∉ dom ?l2.0 ⟹ (?l1.0 ++ ?l2.0) ?m = ?l1.0 ?m›*)) lemma netgmap_netmask_subnets [elim]: assumes "netgmap sr s1 = netmask (net_tree_ips n1) (σ, snd (netgmap sr s1))" and "netgmap sr s2 = netmask (net_tree_ips n2) (σ, snd (netgmap sr s2))" shows "fst (netgmap sr (SubnetS s1 s2)) = fst (netmask (net_tree_ips (n1 ∥ n2)) (σ, snd (netgmap sr (SubnetS s1 s2))))" proof (rule ext (*‹(⋀x. ?f x = ?g x) ⟹ ?f = ?g›*)) (*goal: ‹⋀x. fst (netgmap sr (SubnetS s1 s2)) x = fst (netmask (net_tree_ips (n1 ∥ n2)) (σ, snd (netgmap sr (SubnetS s1 s2)))) x›*) fix i have "i ∈ net_tree_ips n1 ∨ i ∈ net_tree_ips n2 ∨ (i∉net_tree_ips n1 ∪ net_tree_ips n2)" by auto thus "fst (netgmap sr (SubnetS s1 s2)) i = fst (netmask (net_tree_ips (n1 ∥ n2)) (σ, snd (netgmap sr (SubnetS s1 s2)))) i" proof (elim disjE (*‹⟦(?P::bool) ∨ (?Q::bool); ?P ⟹ ?R::bool; ?Q ⟹ ?R⟧ ⟹ ?R›*)) (*goals: 1. ‹i ∈ net_tree_ips n1 ⟹ fst (netgmap sr (SubnetS s1 s2)) i = fst (netmask (net_tree_ips (n1 ∥ n2)) (σ, snd (netgmap sr (SubnetS s1 s2)))) i› 2. ‹i ∈ net_tree_ips n2 ⟹ fst (netgmap sr (SubnetS s1 s2)) i = fst (netmask (net_tree_ips (n1 ∥ n2)) (σ, snd (netgmap sr (SubnetS s1 s2)))) i› 3. ‹i ∉ net_tree_ips n1 ∪ net_tree_ips n2 ⟹ fst (netgmap sr (SubnetS s1 s2)) i = fst (netmask (net_tree_ips (n1 ∥ n2)) (σ, snd (netgmap sr (SubnetS s1 s2)))) i›*) assume "i ∈ net_tree_ips n1" (*‹(i::nat) ∈ net_tree_ips (n1::net_tree)›*) with ‹netgmap sr s1 = netmask (net_tree_ips n1) (σ, snd (netgmap sr s1))› (*‹netgmap sr s1 = netmask (net_tree_ips n1) (σ, snd (netgmap sr s1))›*) ‹netgmap sr s2 = netmask (net_tree_ips n2) (σ, snd (netgmap sr s2))› (*‹netgmap sr s2 = netmask (net_tree_ips n2) (σ, snd (netgmap sr s2))›*) show "?thesis" (*goal: ‹fst (netgmap sr (SubnetS s1 s2)) i = fst (netmask (net_tree_ips (n1 ∥ n2)) (σ, snd (netgmap sr (SubnetS s1 s2)))) i›*) apply (cases "netgmap sr s1") (*goal: ‹fst (netgmap sr (SubnetS s1 s2)) i = fst (netmask (net_tree_ips (n1 ∥ n2)) (σ, snd (netgmap sr (SubnetS s1 s2)))) i›*) apply (cases "netgmap sr s2") (*goal: ‹⋀a b. ⟦netgmap sr s1 = netmask (net_tree_ips n1) (σ, snd (netgmap sr s1)); netgmap sr s2 = netmask (net_tree_ips n2) (σ, snd (netgmap sr s2)); i ∈ net_tree_ips n1; netgmap sr s1 = (a, b)⟧ ⟹ fst (netgmap sr (SubnetS s1 s2)) i = fst (netmask (net_tree_ips (n1 ∥ n2)) (σ, snd (netgmap sr (SubnetS s1 s2)))) i›*) apply clarsimp (*goal: ‹⋀a b aa ba. ⟦netgmap sr s1 = netmask (net_tree_ips n1) (σ, snd (netgmap sr s1)); netgmap sr s2 = netmask (net_tree_ips n2) (σ, snd (netgmap sr s2)); i ∈ net_tree_ips n1; netgmap sr s1 = (a, b); netgmap sr s2 = (aa, ba)⟧ ⟹ fst (netgmap sr (SubnetS s1 s2)) i = fst (netmask (net_tree_ips (n1 ∥ n2)) (σ, snd (netgmap sr (SubnetS s1 s2)))) i›*) by (metis (lifting, mono_tags) map_add_Some_iff (*‹((?m ++ ?n) ?k = Some ?x) = (?n ?k = Some ?x ∨ ?n ?k = None ∧ ?m ?k = Some ?x)›*)) next (*goals: 1. ‹i ∈ net_tree_ips n2 ⟹ fst (netgmap sr (SubnetS s1 s2)) i = fst (netmask (net_tree_ips (n1 ∥ n2)) (σ, snd (netgmap sr (SubnetS s1 s2)))) i› 2. ‹i ∉ net_tree_ips n1 ∪ net_tree_ips n2 ⟹ fst (netgmap sr (SubnetS s1 s2)) i = fst (netmask (net_tree_ips (n1 ∥ n2)) (σ, snd (netgmap sr (SubnetS s1 s2)))) i›*) assume "i ∈ net_tree_ips n2" (*‹(i::nat) ∈ net_tree_ips (n2::net_tree)›*) with ‹netgmap sr s2 = netmask (net_tree_ips n2) (σ, snd (netgmap sr s2))› (*‹netgmap sr s2 = netmask (net_tree_ips n2) (σ, snd (netgmap sr s2))›*) show "?thesis" (*goal: ‹fst (netgmap sr (SubnetS s1 s2)) i = fst (netmask (net_tree_ips (n1 ∥ n2)) (σ, snd (netgmap sr (SubnetS s1 s2)))) i›*) apply simp (*goal: ‹fst (netgmap sr (SubnetS s1 s2)) i = fst (netmask (net_tree_ips (n1 ∥ n2)) (σ, snd (netgmap sr (SubnetS s1 s2)))) i›*) by (metis (lifting, mono_tags) fst_conv (*‹fst (?x1.0, ?x2.0) = ?x1.0›*) map_add_find_right (*‹?n ?k = Some ?xx ⟹ (?m ++ ?n) ?k = Some ?xx›*)) next (*goal: ‹i ∉ net_tree_ips n1 ∪ net_tree_ips n2 ⟹ fst (netgmap sr (SubnetS s1 s2)) i = fst (netmask (net_tree_ips (n1 ∥ n2)) (σ, snd (netgmap sr (SubnetS s1 s2)))) i›*) assume "i∉net_tree_ips n1 ∪ net_tree_ips n2" (*‹(i::nat) ∉ net_tree_ips (n1::net_tree) ∪ net_tree_ips (n2::net_tree)›*) with ‹netgmap sr s1 = netmask (net_tree_ips n1) (σ, snd (netgmap sr s1))› (*‹netgmap sr s1 = netmask (net_tree_ips n1) (σ, snd (netgmap sr s1))›*) ‹netgmap sr s2 = netmask (net_tree_ips n2) (σ, snd (netgmap sr s2))› (*‹netgmap sr s2 = netmask (net_tree_ips n2) (σ, snd (netgmap sr s2))›*) show "?thesis" (*goal: ‹fst (netgmap sr (SubnetS s1 s2)) i = fst (netmask (net_tree_ips (n1 ∥ n2)) (σ, snd (netgmap sr (SubnetS s1 s2)))) i›*) apply simp (*goal: ‹fst (netgmap (sr::'c::type ⇒ 'a::type × 'b::type) (SubnetS (s1::'c::type net_state) (s2::'c::type net_state))) (i::nat) = fst (netmask (net_tree_ips ((n1::net_tree) ∥ (n2::net_tree))) (σ::nat ⇒ 'a::type, snd (netgmap sr (SubnetS s1 s2)))) i›*) by (metis (lifting, mono_tags) fst_conv (*‹fst (?x1.0, ?x2.0) = ?x1.0›*)) qed qed lemma netgmap_netmask_subnets' [elim]: assumes "netgmap sr s1 = netmask (net_tree_ips n1) (σ, snd (netgmap sr s1))" and "netgmap sr s2 = netmask (net_tree_ips n2) (σ, snd (netgmap sr s2))" and "s = SubnetS s1 s2" shows "netgmap sr s = netmask (net_tree_ips (n1 ∥ n2)) (σ, snd (netgmap sr s))" apply (simp only: assms( (*‹s = SubnetS s1 s2›*) 3)) (*goal: ‹netgmap sr s = netmask (net_tree_ips (n1 ∥ n2)) (σ, snd (netgmap sr s))›*) apply (rule prod_eqI [OF netgmap_netmask_subnets [OF assms(1-2)]] (*‹snd (netgmap sr (SubnetS s1 s2)) = snd (netmask (net_tree_ips (n1 ∥ n2)) (σ, snd (netgmap sr (SubnetS s1 s2)))) ⟹ netgmap sr (SubnetS s1 s2) = netmask (net_tree_ips (n1 ∥ n2)) (σ, snd (netgmap sr (SubnetS s1 s2)))›*)) (*goal: ‹netgmap sr (SubnetS s1 s2) = netmask (net_tree_ips (n1 ∥ n2)) (σ, snd (netgmap sr (SubnetS s1 s2)))›*) by simp lemma netgmap_subnet_split1: assumes "netgmap sr (SubnetS s1 s2) = netmask (net_tree_ips (n1 ∥ n2)) (σ, ζ)" and "net_tree_ips n1 ∩ net_tree_ips n2 = {}" and "net_ips s1 = net_tree_ips n1" and "net_ips s2 = net_tree_ips n2" shows "netgmap sr s1 = netmask (net_tree_ips n1) (σ, snd (netgmap sr s1))" proof (rule prod_eqI (*‹⟦fst ?p = fst ?q; snd ?p = snd ?q⟧ ⟹ ?p = ?q›*)) (*goals: 1. ‹fst (netgmap sr s1) = fst (netmask (net_tree_ips n1) (σ, snd (netgmap sr s1)))› 2. ‹snd (netgmap sr s1) = snd (netmask (net_tree_ips n1) (σ, snd (netgmap sr s1)))›*) show "fst (netgmap sr s1) = fst (netmask (net_tree_ips n1) (σ, snd (netgmap sr s1)))" proof (rule ext (*‹(⋀x. ?f x = ?g x) ⟹ ?f = ?g›*), simp, intro conjI (*‹⟦?P; ?Q⟧ ⟹ ?P ∧ ?Q›*) impI (*‹(?P ⟹ ?Q) ⟹ ?P ⟶ ?Q›*)) (*goals: 1. ‹⋀x. x ∈ net_tree_ips n1 ⟹ fst (netgmap sr s1) x = Some (σ x)› 2. ‹⋀x. x ∉ net_tree_ips n1 ⟹ fst (netgmap sr s1) x = None›*) fix i assume "i∈net_tree_ips n1" (*‹(i::nat) ∈ net_tree_ips (n1::net_tree)›*) with ‹net_tree_ips n1 ∩ net_tree_ips n2 = {}› (*‹net_tree_ips (n1::net_tree) ∩ net_tree_ips (n2::net_tree) = {}›*) have "i∉net_tree_ips n2" by auto from assms(1)[simplified prod_eq_iff] (*‹fst (netgmap sr (SubnetS s1 s2)) = fst (netmask (net_tree_ips (n1 ∥ n2)) (σ, ζ)) ∧ snd (netgmap sr (SubnetS s1 s2)) = snd (netmask (net_tree_ips (n1 ∥ n2)) (σ, ζ))›*) have "(fst (netgmap sr s1) ++ fst (netgmap sr s2)) i = (if i ∈ net_tree_ips n1 ∨ i ∈ net_tree_ips n2 then Some (σ i) else None)" by simp also (*calculation: ‹(fst (netgmap sr s1) ++ fst (netgmap sr s2)) i = (if i ∈ net_tree_ips n1 ∨ i ∈ net_tree_ips n2 then Some (σ i) else None)›*) from ‹i∉net_tree_ips n2› (*‹i ∉ net_tree_ips n2›*) ‹net_ips s2 = net_tree_ips n2› (*‹net_ips s2 = net_tree_ips n2›*) have "(fst (netgmap sr s1) ++ fst (netgmap sr s2)) i = fst (netgmap sr s1) i" by (metis dom_fst_netgmap (*‹dom (fst (netgmap (?sr::?'c::type ⇒ ?'a::type × ?'b::type) (?n::?'c::type net_state))) = net_ips ?n›*) map_add_dom_app_simps( (*‹(?m::?'a::type) ∉ dom (?l2.0::?'a::type ⇒ ?'b::type option) ⟹ ((?l1.0::?'a::type ⇒ ?'b::type option) ++ ?l2.0) ?m = ?l1.0 ?m›*) 3)) finally (*calculation: ‹fst (netgmap sr s1) i = (if i ∈ net_tree_ips n1 ∨ i ∈ net_tree_ips n2 then Some (σ i) else None)›*) show "fst (netgmap sr s1) i = Some (σ i)" using ‹i∈net_tree_ips n1› (*‹i ∈ net_tree_ips n1›*) by simp next (*goal: ‹⋀x. x ∉ net_tree_ips n1 ⟹ fst (netgmap sr s1) x = None›*) fix i assume "i ∉ net_tree_ips n1" (*‹(i::nat) ∉ net_tree_ips (n1::net_tree)›*) with ‹net_ips s1 = net_tree_ips n1› (*‹net_ips s1 = net_tree_ips n1›*) have "i ∉ net_ips s1" by simp thus "fst (netgmap sr s1) i = None" by simp qed qed (simp) (*solved the remaining goal: ‹snd (netgmap sr s1) = snd (netmask (net_tree_ips n1) (σ, snd (netgmap sr s1)))›*) lemma netgmap_subnet_split2: assumes "netgmap sr (SubnetS s1 s2) = netmask (net_tree_ips (n1 ∥ n2)) (σ, ζ)" and "net_ips s1 = net_tree_ips n1" and "net_ips s2 = net_tree_ips n2" shows "netgmap sr s2 = netmask (net_tree_ips n2) (σ, snd (netgmap sr s2))" proof (rule prod_eqI (*‹⟦fst (?p::?'a × ?'b) = fst (?q::?'a × ?'b); snd ?p = snd ?q⟧ ⟹ ?p = ?q›*)) (*goals: 1. ‹fst (netgmap sr s2) = fst (netmask (net_tree_ips n2) (σ, snd (netgmap sr s2)))› 2. ‹snd (netgmap sr s2) = snd (netmask (net_tree_ips n2) (σ, snd (netgmap sr s2)))›*) show "fst (netgmap sr s2) = fst (netmask (net_tree_ips n2) (σ, snd (netgmap sr s2)))" proof (rule ext (*‹(⋀x. ?f x = ?g x) ⟹ ?f = ?g›*), simp, intro conjI (*‹⟦?P::bool; ?Q::bool⟧ ⟹ ?P ∧ ?Q›*) impI (*‹(?P::bool ⟹ ?Q::bool) ⟹ ?P ⟶ ?Q›*)) (*goals: 1. ‹⋀x. x ∈ net_tree_ips n2 ⟹ fst (netgmap sr s2) x = Some (σ x)› 2. ‹⋀x. x ∉ net_tree_ips n2 ⟹ fst (netgmap sr s2) x = None›*) fix i assume "i∈net_tree_ips n2" (*‹(i::nat) ∈ net_tree_ips (n2::net_tree)›*) from assms(1)[simplified prod_eq_iff] (*‹fst (netgmap sr (SubnetS s1 s2)) = fst (netmask (net_tree_ips (n1 ∥ n2)) (σ, ζ)) ∧ snd (netgmap sr (SubnetS s1 s2)) = snd (netmask (net_tree_ips (n1 ∥ n2)) (σ, ζ))›*) have "(fst (netgmap sr s1) ++ fst (netgmap sr s2)) i = (if i ∈ net_tree_ips n1 ∨ i ∈ net_tree_ips n2 then Some (σ i) else None)" by simp also (*calculation: ‹(fst (netgmap sr s1) ++ fst (netgmap sr s2)) i = (if i ∈ net_tree_ips n1 ∨ i ∈ net_tree_ips n2 then Some (σ i) else None)›*) from ‹i∈net_tree_ips n2› (*‹i ∈ net_tree_ips n2›*) ‹net_ips s2 = net_tree_ips n2› (*‹net_ips s2 = net_tree_ips n2›*) have "(fst (netgmap sr s1) ++ fst (netgmap sr s2)) i = fst (netgmap sr s2) i" by (metis dom_fst_netgmap (*‹dom (fst (netgmap ?sr ?n)) = net_ips ?n›*) map_add_dom_app_simps( (*‹?m ∈ dom ?l2.0 ⟹ (?l1.0 ++ ?l2.0) ?m = ?l2.0 ?m›*) 1)) finally (*calculation: ‹fst (netgmap sr s2) i = (if i ∈ net_tree_ips n1 ∨ i ∈ net_tree_ips n2 then Some (σ i) else None)›*) show "fst (netgmap sr s2) i = Some (σ i)" using ‹i∈net_tree_ips n2› (*‹i ∈ net_tree_ips n2›*) by simp next (*goal: ‹⋀x. x ∉ net_tree_ips n2 ⟹ fst (netgmap sr s2) x = None›*) fix i assume "i ∉ net_tree_ips n2" (*‹(i::nat) ∉ net_tree_ips (n2::net_tree)›*) with ‹net_ips s2 = net_tree_ips n2› (*‹net_ips s2 = net_tree_ips n2›*) have "i ∉ net_ips s2" by simp thus "fst (netgmap sr s2) i = None" by simp qed qed (simp) (*solved the remaining goal: ‹snd (netgmap (sr::'c ⇒ 'a × 'b) (s2::'c net_state)) = snd (netmask (net_tree_ips (n2::net_tree)) (σ::nat ⇒ 'a, snd (netgmap sr s2)))›*) lemma netmap_fst_netgmap_rel: shows "(λi. map_option (fst o sr) (netmap s i)) = fst (netgmap sr s)" proof (induction s) (*goals: 1. ‹⋀(x1::nat) (x2::'b::type) x3::nat set. (λi::nat. map_option (fst ∘ (sr::'b::type ⇒ 'a::type × 'c::type)) (netmap (NodeS x1 x2 x3) i)) = fst (netgmap sr (NodeS x1 x2 x3))› 2. ‹⋀(s1::'b::type net_state) s2::'b::type net_state. ⟦(λi::nat. map_option (fst ∘ (sr::'b::type ⇒ 'a::type × 'c::type)) (netmap s1 i)) = fst (netgmap sr s1); (λi::nat. map_option (fst ∘ sr) (netmap s2 i)) = fst (netgmap sr s2)⟧ ⟹ (λi::nat. map_option (fst ∘ sr) (netmap (SubnetS s1 s2) i)) = fst (netgmap sr (SubnetS s1 s2))›*) fix ii and s and R show "(λi. map_option (fst ∘ sr) (netmap (NodeS ii s R) i)) = fst (netgmap sr (NodeS ii s R))" by auto next (*goal: ‹⋀s1 s2. ⟦(λi. map_option (fst ∘ sr) (netmap s1 i)) = fst (netgmap sr s1); (λi. map_option (fst ∘ sr) (netmap s2 i)) = fst (netgmap sr s2)⟧ ⟹ (λi. map_option (fst ∘ sr) (netmap (SubnetS s1 s2) i)) = fst (netgmap sr (SubnetS s1 s2))›*) fix s1 and s2 assume a1: "(λi. map_option (fst ∘ sr) (netmap s1 i)) = fst (netgmap sr s1)" and a2: "(λi. map_option (fst ∘ sr) (netmap s2 i)) = fst (netgmap sr s2)" (*‹(λi::nat. map_option (fst ∘ (sr::'b ⇒ 'a × 'c)) (netmap (s1::'b net_state) i)) = fst (netgmap sr s1)› ‹(λi::nat. map_option (fst ∘ (sr::'b ⇒ 'a × 'c)) (netmap (s2::'b net_state) i)) = fst (netgmap sr s2)›*) show "(λi. map_option (fst ∘ sr) (netmap (SubnetS s1 s2) i)) = fst (netgmap sr (SubnetS s1 s2))" proof (rule ext (*‹(⋀x. ?f x = ?g x) ⟹ ?f = ?g›*)) (*goal: ‹⋀i. map_option (fst ∘ sr) (netmap (SubnetS s1 s2) i) = fst (netgmap sr (SubnetS s1 s2)) i›*) fix i from a1 (*‹(λi. map_option (fst ∘ sr) (netmap s1 i)) = fst (netgmap sr s1)›*) a2 (*‹(λi. map_option (fst ∘ sr) (netmap s2 i)) = fst (netgmap sr s2)›*) have "map_option (fst ∘ sr) ((netmap s1 ++ netmap s2) i) = (fst (netgmap sr s1) ++ fst (netgmap sr s2)) i" by (metis fst_conv (*‹fst (?x1.0, ?x2.0) = ?x1.0›*) map_add_dom_app_simps( (*‹?m ∈ dom ?l2.0 ⟹ (?l1.0 ++ ?l2.0) ?m = ?l2.0 ?m›*) 1) map_add_dom_app_simps( (*‹?m ∉ dom ?l2.0 ⟹ (?l1.0 ++ ?l2.0) ?m = ?l1.0 ?m›*) 3) net_ips_is_dom_netmap (*‹net_ips ?s = dom (netmap ?s)›*) netgmap_pair_dom (*‹(⋀σ ζ. ⟦netgmap ?sr ?n = (σ, ζ); dom σ = net_ips ?n⟧ ⟹ ?thesis) ⟹ ?thesis›*)) thus "map_option (fst ∘ sr) (netmap (SubnetS s1 s2) i) = fst (netgmap sr (SubnetS s1 s2)) i" by simp qed qed lemma netmap_is_fst_netgmap': assumes "netmap s' i = netmap s i" shows "fst (netgmap sr s') i = fst (netgmap sr s) i" using assms (*‹netmap s' i = netmap s i›*) by (metis netmap_fst_netgmap_rel (*‹(λi. map_option (fst ∘ ?sr) (netmap ?s i)) = fst (netgmap ?sr ?s)›*)) lemma netmap_is_fst_netgmap: assumes "netmap s' = netmap s" shows "fst (netgmap sr s') = fst (netgmap sr s)" apply (rule ext (*‹(⋀x. ?f x = ?g x) ⟹ ?f = ?g›*)) (*goal: ‹fst (netgmap (sr::'a ⇒ 'b × 'c) (s'::'a net_state)) = fst (netgmap sr (s::'a net_state))›*) by (metis assms (*‹netmap s' = netmap s›*) netmap_fst_netgmap_rel (*‹(λi. map_option (fst ∘ ?sr) (netmap ?s i)) = fst (netgmap ?sr ?s)›*)) lemma fst_netgmap_pair_fst [simp]: "fst (netgmap (λ(p, q). (fst p, snd p, q)) s) = fst (netgmap fst s)" apply (induction s) (*goals: 1. ‹⋀x1 x2 x3. fst (netgmap (λa. case a of (p, q) ⇒ (fst p, snd p, q)) (NodeS x1 x2 x3)) = fst (netgmap fst (NodeS x1 x2 x3))› 2. ‹⋀s1 s2. ⟦fst (netgmap (λa. case a of (p, q) ⇒ (fst p, snd p, q)) s1) = fst (netgmap fst s1); fst (netgmap (λa. case a of (p, q) ⇒ (fst p, snd p, q)) s2) = fst (netgmap fst s2)⟧ ⟹ fst (netgmap (λa. case a of (p, q) ⇒ (fst p, snd p, q)) (SubnetS s1 s2)) = fst (netgmap fst (SubnetS s1 s2))› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . text ‹Introduce streamlined alternatives to netgmap to simplify certain property statements and thus make them easier to understand and to present.› fun netlift :: "('s ⇒ 'g × 'l) ⇒ 's net_state ⇒ (nat ⇒ 'g option)" where "netlift sr (NodeS i s R) = [i ↦ fst (sr s)]" | "netlift sr (SubnetS s t) = (netlift sr s) ++ (netlift sr t)" lemma fst_netgmap_netlift: "fst (netgmap sr s) = netlift sr s" apply (induction s) (*goals: 1. ‹⋀x1 x2 x3. fst (netgmap sr (NodeS x1 x2 x3)) = netlift sr (NodeS x1 x2 x3)› 2. ‹⋀s1 s2. ⟦fst (netgmap sr s1) = netlift sr s1; fst (netgmap sr s2) = netlift sr s2⟧ ⟹ fst (netgmap sr (SubnetS s1 s2)) = netlift sr (SubnetS s1 s2)› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) . fun netliftl :: "('s ⇒ 'g × 'l) ⇒ 's net_state ⇒ 'l net_state" where "netliftl sr (NodeS i s R) = NodeS i (snd (sr s)) R" | "netliftl sr (SubnetS s t) = SubnetS (netliftl sr s) (netliftl sr t)" lemma snd_netgmap_netliftl: "snd (netgmap sr s) = netliftl sr s" apply (induction s) (*goals: 1. ‹⋀x1 x2 x3. snd (netgmap sr (NodeS x1 x2 x3)) = netliftl sr (NodeS x1 x2 x3)› 2. ‹⋀s1 s2. ⟦snd (netgmap sr s1) = netliftl sr s1; snd (netgmap sr s2) = netliftl sr s2⟧ ⟹ snd (netgmap sr (SubnetS s1 s2)) = netliftl sr (SubnetS s1 s2)› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) . lemma netgmap_netlift_netliftl: "netgmap sr s = (netlift sr s, netliftl sr s)" apply rule (*goals: 1. ‹fst (netgmap sr s) = fst (netlift sr s, netliftl sr s)› 2. ‹snd (netgmap sr s) = snd (netlift sr s, netliftl sr s)› discuss goal 1*) apply (simp add: fst_netgmap_netlift (*‹fst (netgmap ?sr ?s) = netlift ?sr ?s›*) snd_netgmap_netliftl (*‹snd (netgmap ?sr ?s) = netliftl ?sr ?s›*)) (*discuss goal 2*) apply (simp add: fst_netgmap_netlift (*‹fst (netgmap ?sr ?s) = netlift ?sr ?s›*) snd_netgmap_netliftl (*‹snd (netgmap ?sr ?s) = netliftl ?sr ?s›*)) (*proven 2 subgoals*) . end
{ "path": "afp-2025-02-12/thys/AWN/AWN.thy", "repo": "afp-2025-02-12", "sha": "54bc480f84d2bf58c02125b2daa43b4bef22bdbd6b17b82f90559c5afe0d7f45" }
section ‹The Euler--MacLaurin summation formula› theory Euler_MacLaurin imports "HOL-Complex_Analysis.Complex_Analysis" Bernoulli.Periodic_Bernpoly Bernoulli.Bernoulli_FPS begin subsection ‹Auxiliary facts› (* TODO Move? *) lemma pbernpoly_of_int [simp]: "pbernpoly n (of_int a) = bernoulli n" by (simp add: pbernpoly_def (*‹pbernpoly ?n ?x = bernpoly ?n (frac ?x)›*)) lemma continuous_on_bernpoly' [continuous_intros]: assumes "continuous_on A f" shows "continuous_on A (λx. bernpoly n (f x) :: 'a :: real_normed_algebra_1)" using continuous_on_compose2[OF continuous_on_bernpoly assms, of UNIV n] (*‹f ` A ⊆ UNIV ⟹ continuous_on A (λx. bernpoly n (f x))›*) by auto lemma sum_atLeastAtMost_int_last: assumes "a < (b :: int)" shows "sum f {a..b} = sum f {a..<b} + f b" proof (-) (*goal: ‹sum f {a..b} = sum f {a..<b} + f b›*) from assms (*‹(a::int) < (b::int)›*) have "{a..b} = insert b {a..<b}" by auto also (*calculation: ‹{a..b} = insert b {a..<b}›*) have "sum f … = sum f {a..<b} + f b" apply (subst sum.insert (*‹⟦finite ?A; ?x ∉ ?A⟧ ⟹ sum ?g (insert ?x ?A) = ?g ?x + sum ?g ?A›*)) (*goals: 1. ‹finite {a..<b}› 2. ‹b ∉ {a..<b}› 3. ‹f b + sum f {a..<b} = sum f {a..<b} + f b› discuss goal 1*) apply ((auto simp: 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: 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: add_ac (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)›*))[1]) (*proven 3 subgoals*) . finally (*calculation: ‹sum f {a..b} = sum f {a..<b} + f b›*) show "?thesis" (*goal: ‹sum f {a..b} = sum f {a..<b} + f b›*) . qed lemma sum_atLeastAtMost_int_head: assumes "a < (b :: int)" shows "sum f {a..b} = f a + sum f {a<..b}" proof (-) (*goal: ‹sum (f::int ⇒ 'a) {a::int..b::int} = f a + sum f {a<..b}›*) from assms (*‹a < b›*) have "{a..b} = insert a {a<..b}" by auto also (*calculation: ‹{a::int..b::int} = insert a {a<..b}›*) have "sum f … = f a + sum f {a<..b}" apply (subst sum.insert (*‹⟦finite (?A::?'b set); (?x::?'b) ∉ ?A⟧ ⟹ sum (?g::?'b ⇒ ?'a) (insert ?x ?A) = ?g ?x + sum ?g ?A›*)) (*goals: 1. ‹finite {a<..b}› 2. ‹a ∉ {a<..b}› 3. ‹f a + sum f {a<..b} = f a + sum f {a<..b}› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*proven 3 subgoals*) . finally (*calculation: ‹sum f {a..b} = f a + sum f {a<..b}›*) show "?thesis" (*goal: ‹sum f {a..b} = f a + sum f {a<..b}›*) . qed lemma not_in_nonpos_Reals_imp_add_nonzero: assumes "z ∉ ℝ⇩≤₀" "x ≥ 0" shows "z + of_real x ≠ 0" using assms (*‹(z::'a::real_algebra_1) ∉ ℝ⇩≤₀› ‹0 ≤ x›*) by (auto simp: add_eq_0_iff2 (*‹((?a::?'a::group_add) + (?b::?'a::group_add) = (0::?'a::group_add)) = (?a = - ?b)›*)) (* END TODO *) lemma negligible_atLeastAtMostI: "b ≤ a ⟹ negligible {a..(b::real)}" apply (cases "b < a") (*goals: 1. ‹⟦(b::real) ≤ (a::real); b < a⟧ ⟹ negligible {a..b}› 2. ‹⟦(b::real) ≤ (a::real); ¬ b < a⟧ ⟹ negligible {a..b}› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . lemma integrable_on_negligible: "negligible A ⟹ (f :: 'n :: euclidean_space ⇒ 'a :: banach) integrable_on A" apply (subst integrable_spike_set_eq[of _ "{}"] (*‹negligible (sym_diff ?S {}) ⟹ (?f integrable_on ?S) = (?f integrable_on {})›*)) (*goals: 1. ‹negligible (A::'n set) ⟹ negligible (sym_diff A {})› 2. ‹negligible (A::'n set) ⟹ (f::'n ⇒ 'a) integrable_on {}› discuss goal 1*) apply (simp add: integrable_on_empty (*‹?f integrable_on {}›*)) (*discuss goal 2*) apply (simp add: integrable_on_empty (*‹?f integrable_on {}›*)) (*proven 2 subgoals*) . lemma Union_atLeastAtMost_real_of_int: assumes "a < b" shows "(⋃n∈{a..<b}. {real_of_int n..real_of_int (n + 1)}) = {real_of_int a..real_of_int b}" proof (intro equalityI (*‹⟦?A ⊆ ?B; ?B ⊆ ?A⟧ ⟹ ?A = ?B›*) subsetI (*‹(⋀x. x ∈ ?A ⟹ x ∈ ?B) ⟹ ?A ⊆ ?B›*)) (*goals: 1. ‹⋀x::real. x ∈ (⋃n::int∈{a::int..<b::int}. {real_of_int n..real_of_int (n + (1::int))}) ⟹ x ∈ {real_of_int a..real_of_int b}› 2. ‹⋀x::real. x ∈ {real_of_int (a::int)..real_of_int (b::int)} ⟹ x ∈ (⋃n::int∈{a..<b}. {real_of_int n..real_of_int (n + (1::int))})›*) fix x assume x: "x ∈ {real_of_int a..real_of_int b}" (*‹(x::real) ∈ {real_of_int (a::int)..real_of_int (b::int)}›*) thus "x ∈ (⋃n∈{a..<b}. {real_of_int n..real_of_int (n + 1)})" proof (cases "x = real_of_int b") (*goals: 1. ‹⟦(x::real) ∈ {real_of_int (a::int)..real_of_int (b::int)}; x = real_of_int b⟧ ⟹ x ∈ (⋃n::int∈{a..<b}. {real_of_int n..real_of_int (n + (1::int))})› 2. ‹⟦(x::real) ∈ {real_of_int (a::int)..real_of_int (b::int)}; x ≠ real_of_int b⟧ ⟹ x ∈ (⋃n::int∈{a..<b}. {real_of_int n..real_of_int (n + (1::int))})›*) case True (*‹(x::real) = real_of_int (b::int)›*) with assms (*‹a < b›*) show "?thesis" (*goal: ‹(x::real) ∈ (⋃n::int∈{a::int..<b::int}. {real_of_int n..real_of_int (n + (1::int))})›*) by (auto intro!: bexI[of _ "b - 1"] (*‹⟦?P (b - 1); b - 1 ∈ ?A⟧ ⟹ ∃x∈?A. ?P x›*)) next (*goal: ‹⟦(x::real) ∈ {real_of_int (a::int)..real_of_int (b::int)}; x ≠ real_of_int b⟧ ⟹ x ∈ (⋃n::int∈{a..<b}. {real_of_int n..real_of_int (n + (1::int))})›*) case False (*‹x ≠ real_of_int b›*) with x (*‹x ∈ {real_of_int a..real_of_int b}›*) have x: "x ≥ real_of_int a" "x < real_of_int b" apply - (*goals: 1. ‹⟦x ∈ {real_of_int a..real_of_int b}; x ≠ real_of_int b⟧ ⟹ real_of_int a ≤ x› 2. ‹⟦x ∈ {real_of_int a..real_of_int b}; x ≠ real_of_int b⟧ ⟹ x < real_of_int b› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) . hence "x ≥ of_int ⌊x⌋" "x ≤ of_int ⌊x⌋ + 1" (*goals: 1. ‹real_of_int ⌊x⌋ ≤ x› 2. ‹x ≤ real_of_int ⌊x⌋ + 1› discuss goal 1*) apply linarith (*discuss goal 2*) apply linarith (*proven 2 subgoals*) . moreover from x (*‹real_of_int (a::int) ≤ (x::real)› ‹x < real_of_int b›*) have "⌊x⌋ ≥ a" "⌊x⌋ < b" apply - (*goals: 1. ‹⟦real_of_int (a::int) ≤ (x::real); x < real_of_int (b::int)⟧ ⟹ a ≤ ⌊x⌋› 2. ‹⟦real_of_int (a::int) ≤ (x::real); x < real_of_int (b::int)⟧ ⟹ ⌊x⌋ < b› discuss goal 1*) apply linarith (*discuss goal 2*) apply linarith (*proven 2 subgoals*) . ultimately have "∃n∈{a..<b}. x ∈ {of_int n..of_int (n + 1)}" apply (intro bexI[of _ "⌊x⌋"] (*‹⟦?P ⌊x⌋; ⌊x⌋ ∈ ?A⟧ ⟹ ∃x∈?A. ?P x›*)) (*goals: 1. ‹⟦real_of_int ⌊x⌋ ≤ x; x ≤ real_of_int ⌊x⌋ + 1; a ≤ ⌊x⌋; ⌊x⌋ < b⟧ ⟹ x ∈ {real_of_int ⌊x⌋..real_of_int (⌊x⌋ + 1)}› 2. ‹⟦real_of_int ⌊x⌋ ≤ x; x ≤ real_of_int ⌊x⌋ + 1; a ≤ ⌊x⌋; ⌊x⌋ < b⟧ ⟹ ⌊x⌋ ∈ {a..<b}› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) . thus "?thesis" (*goal: ‹(x::real) ∈ (⋃n::int∈{a::int..<b::int}. {real_of_int n..real_of_int (n + (1::int))})›*) by blast qed qed (auto) (*solved the remaining goal: ‹⋀x. x ∈ (⋃n∈{a..<b}. {real_of_int n..real_of_int (n + 1)}) ⟹ x ∈ {real_of_int a..real_of_int b}›*) subsection ‹The remainder terms› text ‹ The following describes the remainder term in the classical version of the Euler--MacLaurin formula. › definition EM_remainder' :: "nat ⇒ (real ⇒ 'a :: banach) ⇒ real ⇒ real ⇒ 'a" where "EM_remainder' n f a b = ((-1) ^ Suc n / fact n) *⇩R integral {a..b} (λt. pbernpoly n t *⇩R f t)" text ‹ Next, we define the remainder term that occurs when one lets the right bound of summation in the Euler--MacLaurin formula tend to infinity. › definition EM_remainder_converges :: "nat ⇒ (real ⇒ 'a :: banach) ⇒ int ⇒ bool" where "EM_remainder_converges n f a ⟷ (∃L. ((λx. EM_remainder' n f a (of_int x)) ⤏ L) at_top)" definition EM_remainder :: "nat ⇒ (real ⇒ 'a :: banach) ⇒ int ⇒ 'a" where "EM_remainder n f a = (if EM_remainder_converges n f a then Lim at_top (λx. EM_remainder' n f a (of_int x)) else 0)" text ‹ The following lemmas are fairly obvious -- but tedious to prove -- properties of the remainder terms. › lemma EM_remainder_eqI: fixes L assumes "((λx. EM_remainder' n f b (of_int x)) ⤏ L) at_top" shows "EM_remainder n f b = L" using assms (*‹((λx. EM_remainder' n f (real_of_int b) (real_of_int x)) ⤏ L) at_top›*) by (auto simp: EM_remainder_def (*‹EM_remainder ?n ?f ?a = (if EM_remainder_converges ?n ?f ?a then Lim at_top (λx. EM_remainder' ?n ?f (real_of_int ?a) (real_of_int x)) else 0)›*) EM_remainder_converges_def (*‹EM_remainder_converges ?n ?f ?a = (∃L. ((λx. EM_remainder' ?n ?f (real_of_int ?a) (real_of_int x)) ⤏ L) at_top)›*) intro!: tendsto_Lim (*‹⟦?net ≠ bot; (?f ⤏ ?l) ?net⟧ ⟹ Lim ?net ?f = ?l›*)) lemma integrable_EM_remainder'_int: fixes a b :: int and f :: "real ⇒ 'a :: banach" assumes "continuous_on {of_int a..of_int b} f" shows "(λt. pbernpoly n t *⇩R f t) integrable_on {a..b}" sorry lemma integrable_EM_remainder': fixes a b :: real and f :: "real ⇒ 'a :: banach" assumes "continuous_on {a..b} f" shows "(λt. pbernpoly n t *⇩R f t) integrable_on {a..b}" proof (cases "⌈a⌉ ≤ ⌊b⌋") (*goals: 1. ‹⌈a⌉ ≤ ⌊b⌋ ⟹ (λt. pbernpoly n t *⇩R f t) integrable_on {a..b}› 2. ‹¬ ⌈a⌉ ≤ ⌊b⌋ ⟹ (λt. pbernpoly n t *⇩R f t) integrable_on {a..b}›*) case True (*‹⌈a⌉ ≤ ⌊b⌋›*) define a' and b' where "a' = ⌈a⌉" and "b' = ⌊b⌋" from True (*‹⌈a⌉ ≤ ⌊b⌋›*) have "*": "a' ≤ b'" "a' ≥ a" "b' ≤ b" apply - (*goals: 1. ‹⌈a⌉ ≤ ⌊b⌋ ⟹ a' ≤ b'› 2. ‹⌈a⌉ ≤ ⌊b⌋ ⟹ a ≤ real_of_int a'› 3. ‹⌈a⌉ ≤ ⌊b⌋ ⟹ real_of_int b' ≤ b› discuss goal 1*) apply ((auto simp: a'_def (*‹a' = ⌈a⌉›*) b'_def (*‹b' = ⌊b⌋›*))[1]) (*discuss goal 2*) apply ((auto simp: a'_def (*‹a' = ⌈a⌉›*) b'_def (*‹b' = ⌊b⌋›*))[1]) (*discuss goal 3*) apply ((auto simp: a'_def (*‹a' = ⌈a⌉›*) b'_def (*‹b' = ⌊b⌋›*))[1]) (*proven 3 subgoals*) . from "*" (*‹a' ≤ b'› ‹a ≤ real_of_int a'› ‹real_of_int b' ≤ b›*) have A: "(λt. pbernpoly n t *⇩R f t) integrable_on ({a'..b'})" apply (intro integrable_EM_remainder'_int (*‹continuous_on {real_of_int (?a::int)..real_of_int (?b::int)} (?f::real ⇒ ?'a) ⟹ (λt::real. pbernpoly (?n::nat) t *⇩R ?f t) integrable_on {real_of_int ?a..real_of_int ?b}›*) continuous_on_subset[OF assms] (*‹(?t::real set) ⊆ {a::real..b::real} ⟹ continuous_on ?t (f::real ⇒ 'a)›*)) (*goal: ‹(λt. pbernpoly n t *⇩R f t) integrable_on {real_of_int a'..real_of_int b'}›*) by auto have B: "(λt. pbernpoly n t *⇩R f t) integrable_on ({a..a'})" proof (rule integrable_spike (*‹⟦?f integrable_on ?T; negligible ?S; ⋀x. x ∈ ?T - ?S ⟹ ?g x = ?f x⟧ ⟹ ?g integrable_on ?T›*)) (*goals: 1. ‹?f integrable_on {a..real_of_int a'}› 2. ‹negligible ?S› 3. ‹⋀x. x ∈ {a..real_of_int a'} - ?S ⟹ pbernpoly n x *⇩R f x = ?f x›*) show "pbernpoly n x *⇩R f x = bernpoly n (x - of_int (floor a)) *⇩R f x" if "x ∈ {a..real_of_int a'} - {real_of_int a'}" for x proof (-) (*goal: ‹pbernpoly n x *⇩R f x = bernpoly n (x - real_of_int ⌊a⌋) *⇩R f x›*) have "x ≥ a" "x <real_of_int a'" using that (*‹(x::real) ∈ {a::real..real_of_int (a'::int)} - {real_of_int a'}›*) apply - (*goals: 1. ‹x ∈ {a..real_of_int a'} - {real_of_int a'} ⟹ a ≤ x› 2. ‹x ∈ {a..real_of_int a'} - {real_of_int a'} ⟹ x < real_of_int a'› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . with True (*‹⌈a⌉ ≤ ⌊b⌋›*) have "floor x = floor a" unfolding a'_def (*goal: ‹⌊x::real⌋ = ⌊a::real⌋›*) using ceiling_diff_floor_le_1[of a] (*‹⌈a⌉ - ⌊a⌋ ≤ 1›*) apply (intro floor_unique (*‹⟦of_int ?z ≤ ?x; ?x < of_int ?z + 1⟧ ⟹ ⌊?x⌋ = ?z›*)) (*goals: 1. ‹⟦⌈a⌉ ≤ ⌊b⌋; a ≤ x; x < real_of_int ⌈a⌉; ⌈a⌉ - ⌊a⌋ ≤ 1⟧ ⟹ real_of_int ⌊a⌋ ≤ x› 2. ‹⟦⌈a⌉ ≤ ⌊b⌋; a ≤ x; x < real_of_int ⌈a⌉; ⌈a⌉ - ⌊a⌋ ≤ 1⟧ ⟹ x < real_of_int ⌊a⌋ + 1› discuss goal 1*) apply linarith (*discuss goal 2*) apply linarith (*proven 2 subgoals*) . thus "?thesis" (*goal: ‹pbernpoly (n::nat) (x::real) *⇩R (f::real ⇒ 'a::banach) x = bernpoly n (x - real_of_int ⌊a::real⌋) *⇩R f x›*) by (simp add: pbernpoly_def (*‹pbernpoly ?n ?x = bernpoly ?n (frac ?x)›*) frac_def (*‹frac ?x ≡ ?x - of_int ⌊?x⌋›*)) qed qed (insert * (*‹a' ≤ b'› ‹a ≤ real_of_int a'› ‹real_of_int b' ≤ b›*), 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 272 facts*) integrable_continuous_real (*‹continuous_on {?a..?b} ?f ⟹ ?f integrable_on {?a..?b}›*) continuous_on_subset[OF assms] (*‹?t ⊆ {a..b} ⟹ continuous_on ?t f›*)) (*solves the remaining goals: 1. ‹(λx. bernpoly n (x - real_of_int ⌊a⌋) *⇩R f x) integrable_on {a..real_of_int a'}› 2. ‹negligible {real_of_int a'}›*) have C: "(λt. pbernpoly n t *⇩R f t) integrable_on ({b'..b})" proof (rule integrable_spike (*‹⟦?f integrable_on ?T; negligible ?S; ⋀x. x ∈ ?T - ?S ⟹ ?g x = ?f x⟧ ⟹ ?g integrable_on ?T›*)) (*goals: 1. ‹?f integrable_on {real_of_int b'..b}› 2. ‹negligible ?S› 3. ‹⋀x. x ∈ {real_of_int b'..b} - ?S ⟹ pbernpoly n x *⇩R f x = ?f x›*) show "pbernpoly n x *⇩R f x = bernpoly n (x - of_int b') *⇩R f x" if "x ∈ {real_of_int b'..b} - {real_of_int b'}" for x proof (-) (*goal: ‹pbernpoly n x *⇩R f x = bernpoly n (x - real_of_int b') *⇩R f x›*) have "x ≤ b" "x > real_of_int b'" using that (*‹x ∈ {real_of_int b'..b} - {real_of_int b'}›*) apply - (*goals: 1. ‹(x::real) ∈ {real_of_int (b'::int)..b::real} - {real_of_int b'} ⟹ x ≤ b› 2. ‹(x::real) ∈ {real_of_int (b'::int)..b::real} - {real_of_int b'} ⟹ real_of_int b' < x› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . with True (*‹⌈a⌉ ≤ ⌊b⌋›*) have "floor x = b'" unfolding b'_def (*goal: ‹⌊x⌋ = ⌊b⌋›*) apply (intro floor_unique (*‹⟦of_int ?z ≤ ?x; ?x < of_int ?z + 1⟧ ⟹ ⌊?x⌋ = ?z›*)) (*goals: 1. ‹⟦⌈a⌉ ≤ ⌊b⌋; x ≤ b; real_of_int ⌊b⌋ < x⟧ ⟹ real_of_int ⌊b⌋ ≤ x› 2. ‹⟦⌈a⌉ ≤ ⌊b⌋; x ≤ b; real_of_int ⌊b⌋ < x⟧ ⟹ x < real_of_int ⌊b⌋ + 1› discuss goal 1*) apply linarith (*discuss goal 2*) apply linarith (*proven 2 subgoals*) . thus "?thesis" (*goal: ‹pbernpoly n x *⇩R f x = bernpoly n (x - real_of_int b') *⇩R f x›*) by (simp add: pbernpoly_def (*‹pbernpoly ?n ?x = bernpoly ?n (frac ?x)›*) frac_def (*‹frac ?x ≡ ?x - of_int ⌊?x⌋›*)) qed qed (insert * (*‹a' ≤ b'› ‹a ≤ real_of_int a'› ‹real_of_int b' ≤ b›*), 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 272 facts*) integrable_continuous_real (*‹continuous_on {?a..?b} ?f ⟹ ?f integrable_on {?a..?b}›*) continuous_on_subset[OF assms] (*‹?t ⊆ {a..b} ⟹ continuous_on ?t f›*)) (*solves the remaining goals: 1. ‹(λx. bernpoly n (x - real_of_int b') *⇩R f x) integrable_on {real_of_int b'..b}› 2. ‹negligible {real_of_int b'}›*) have "(λt. pbernpoly n t *⇩R f t) integrable_on ({a..a'} ∪ {a'..b'} ∪ {b'..b})" using "*" (*‹a' ≤ b'› ‹a ≤ real_of_int a'› ‹real_of_int (b'::int) ≤ (b::real)›*) A (*‹(λt. pbernpoly n t *⇩R f t) integrable_on {real_of_int a'..real_of_int b'}›*) B (*‹(λt. pbernpoly n t *⇩R f t) integrable_on {a..real_of_int a'}›*) C (*‹(λt. pbernpoly n t *⇩R f t) integrable_on {real_of_int b'..b}›*) apply (intro integrable_Un (*‹⟦negligible (?A ∩ ?B); ?f integrable_on ?A; ?f integrable_on ?B⟧ ⟹ ?f integrable_on ?A ∪ ?B›*)) (*goals: 1. ‹⟦(a'::int) ≤ (b'::int); (a::real) ≤ real_of_int a'; real_of_int b' ≤ (b::real); (λt::real. pbernpoly (n::nat) t *⇩R (f::real ⇒ 'a::banach) t) integrable_on {real_of_int a'..real_of_int b'}; (λt::real. pbernpoly n t *⇩R f t) integrable_on {a..real_of_int a'}; (λt::real. pbernpoly n t *⇩R f t) integrable_on {real_of_int b'..b}⟧ ⟹ negligible (({a..real_of_int a'} ∪ {real_of_int a'..real_of_int b'}) ∩ {real_of_int b'..b})› 2. ‹⟦(a'::int) ≤ (b'::int); (a::real) ≤ real_of_int a'; real_of_int b' ≤ (b::real); (λt::real. pbernpoly (n::nat) t *⇩R (f::real ⇒ 'a::banach) t) integrable_on {real_of_int a'..real_of_int b'}; (λt::real. pbernpoly n t *⇩R f t) integrable_on {a..real_of_int a'}; (λt::real. pbernpoly n t *⇩R f t) integrable_on {real_of_int b'..b}⟧ ⟹ negligible ({a..real_of_int a'} ∩ {real_of_int a'..real_of_int b'})› 3. ‹⟦(a'::int) ≤ (b'::int); (a::real) ≤ real_of_int a'; real_of_int b' ≤ (b::real); (λt::real. pbernpoly (n::nat) t *⇩R (f::real ⇒ 'a::banach) t) integrable_on {real_of_int a'..real_of_int b'}; (λt::real. pbernpoly n t *⇩R f t) integrable_on {a..real_of_int a'}; (λt::real. pbernpoly n t *⇩R f t) integrable_on {real_of_int b'..b}⟧ ⟹ (λt::real. pbernpoly n t *⇩R f t) integrable_on {a..real_of_int a'}› 4. ‹⟦(a'::int) ≤ (b'::int); (a::real) ≤ real_of_int a'; real_of_int b' ≤ (b::real); (λt::real. pbernpoly (n::nat) t *⇩R (f::real ⇒ 'a::banach) t) integrable_on {real_of_int a'..real_of_int b'}; (λt::real. pbernpoly n t *⇩R f t) integrable_on {a..real_of_int a'}; (λt::real. pbernpoly n t *⇩R f t) integrable_on {real_of_int b'..b}⟧ ⟹ (λt::real. pbernpoly n t *⇩R f t) integrable_on {real_of_int a'..real_of_int b'}› 5. ‹⟦(a'::int) ≤ (b'::int); (a::real) ≤ real_of_int a'; real_of_int b' ≤ (b::real); (λt::real. pbernpoly (n::nat) t *⇩R (f::real ⇒ 'a::banach) t) integrable_on {real_of_int a'..real_of_int b'}; (λt::real. pbernpoly n t *⇩R f t) integrable_on {a..real_of_int a'}; (λt::real. pbernpoly n t *⇩R f t) integrable_on {real_of_int b'..b}⟧ ⟹ (λt::real. pbernpoly n t *⇩R f t) integrable_on {real_of_int b'..b}› discuss goal 1*) apply (subst ivl_disj_un (*‹{?l} ∪ {?l<..} = {?l..}› ‹{..<?u} ∪ {?u} = {..?u}› ‹?l < ?u ⟹ {?l} ∪ {?l<..<?u} = {?l..<?u}› ‹?l < ?u ⟹ {?l<..<?u} ∪ {?u} = {?l<..?u}› ‹?l ≤ ?u ⟹ {?l} ∪ {?l<..?u} = {?l..?u}› ‹?l ≤ ?u ⟹ {?l..<?u} ∪ {?u} = {?l..?u}› ‹?l < ?u ⟹ {..?l} ∪ {?l<..<?u} = {..<?u}› ‹?l ≤ ?u ⟹ {..<?l} ∪ {?l..<?u} = {..<?u}› ‹?l ≤ ?u ⟹ {..?l} ∪ {?l<..?u} = {..?u}› ‹?l ≤ ?u ⟹ {..<?l} ∪ {?l..?u} = {..?u}› ‹?l ≤ ?u ⟹ {?l<..?u} ∪ {?u<..} = {?l<..}› ‹?l < ?u ⟹ {?l<..<?u} ∪ {?u..} = {?l<..}› and more 14 facts*)) (*goals: 1. ‹⟦a' ≤ b'; a ≤ real_of_int a'; real_of_int b' ≤ b; (λt. pbernpoly n t *⇩R f t) integrable_on {real_of_int a'..real_of_int b'}; (λt. pbernpoly n t *⇩R f t) integrable_on {a..real_of_int a'}; (λt. pbernpoly n t *⇩R f t) integrable_on {real_of_int b'..b}⟧ ⟹ a ≤ real_of_int a'› 2. ‹⟦a' ≤ b'; a ≤ real_of_int a'; real_of_int b' ≤ b; (λt. pbernpoly n t *⇩R f t) integrable_on {real_of_int a'..real_of_int b'}; (λt. pbernpoly n t *⇩R f t) integrable_on {a..real_of_int a'}; (λt. pbernpoly n t *⇩R f t) integrable_on {real_of_int b'..b}⟧ ⟹ real_of_int a' ≤ real_of_int b'› 3. ‹⟦a' ≤ b'; a ≤ real_of_int a'; real_of_int b' ≤ b; (λt. pbernpoly n t *⇩R f t) integrable_on {real_of_int a'..real_of_int b'}; (λt. pbernpoly n t *⇩R f t) integrable_on {a..real_of_int a'}; (λt. pbernpoly n t *⇩R f t) integrable_on {real_of_int b'..b}⟧ ⟹ negligible ({a..real_of_int b'} ∩ {real_of_int b'..b})› discuss goal 1*) apply ((auto simp: ivl_disj_un (*‹{?l} ∪ {?l<..} = {?l..}› ‹{..<?u} ∪ {?u} = {..?u}› ‹?l < ?u ⟹ {?l} ∪ {?l<..<?u} = {?l..<?u}› ‹?l < ?u ⟹ {?l<..<?u} ∪ {?u} = {?l<..?u}› ‹?l ≤ ?u ⟹ {?l} ∪ {?l<..?u} = {?l..?u}› ‹?l ≤ ?u ⟹ {?l..<?u} ∪ {?u} = {?l..?u}› ‹?l < ?u ⟹ {..?l} ∪ {?l<..<?u} = {..<?u}› ‹?l ≤ ?u ⟹ {..<?l} ∪ {?l..<?u} = {..<?u}› ‹?l ≤ ?u ⟹ {..?l} ∪ {?l<..?u} = {..?u}› ‹?l ≤ ?u ⟹ {..<?l} ∪ {?l..?u} = {..?u}› ‹?l ≤ ?u ⟹ {?l<..?u} ∪ {?u<..} = {?l<..}› ‹?l < ?u ⟹ {?l<..<?u} ∪ {?u..} = {?l<..}› and more 14 facts*) max_def (*‹max ?a ?b = (if ?a ≤ ?b then ?b else ?a)›*) min_def (*‹min ?a ?b = (if ?a ≤ ?b then ?a else ?b)›*))[1]) (*discuss goal 2*) apply ((auto simp: ivl_disj_un (*‹{?l} ∪ {?l<..} = {?l..}› ‹{..<?u} ∪ {?u} = {..?u}› ‹?l < ?u ⟹ {?l} ∪ {?l<..<?u} = {?l..<?u}› ‹?l < ?u ⟹ {?l<..<?u} ∪ {?u} = {?l<..?u}› ‹?l ≤ ?u ⟹ {?l} ∪ {?l<..?u} = {?l..?u}› ‹?l ≤ ?u ⟹ {?l..<?u} ∪ {?u} = {?l..?u}› ‹?l < ?u ⟹ {..?l} ∪ {?l<..<?u} = {..<?u}› ‹?l ≤ ?u ⟹ {..<?l} ∪ {?l..<?u} = {..<?u}› ‹?l ≤ ?u ⟹ {..?l} ∪ {?l<..?u} = {..?u}› ‹?l ≤ ?u ⟹ {..<?l} ∪ {?l..?u} = {..?u}› ‹?l ≤ ?u ⟹ {?l<..?u} ∪ {?u<..} = {?l<..}› ‹?l < ?u ⟹ {?l<..<?u} ∪ {?u..} = {?l<..}› and more 14 facts*) max_def (*‹max ?a ?b = (if ?a ≤ ?b then ?b else ?a)›*) min_def (*‹min ?a ?b = (if ?a ≤ ?b then ?a else ?b)›*))[1]) (*discuss goal 3*) apply ((auto simp: ivl_disj_un (*‹{?l::?'a::linorder} ∪ {?l<..} = {?l..}› ‹{..<?u::?'a::linorder} ∪ {?u} = {..?u}› ‹(?l::?'a::linorder) < (?u::?'a::linorder) ⟹ {?l} ∪ {?l<..<?u} = {?l..<?u}› ‹(?l::?'a::linorder) < (?u::?'a::linorder) ⟹ {?l<..<?u} ∪ {?u} = {?l<..?u}› ‹(?l::?'a::linorder) ≤ (?u::?'a::linorder) ⟹ {?l} ∪ {?l<..?u} = {?l..?u}› ‹(?l::?'a::linorder) ≤ (?u::?'a::linorder) ⟹ {?l..<?u} ∪ {?u} = {?l..?u}› ‹(?l::?'a::linorder) < (?u::?'a::linorder) ⟹ {..?l} ∪ {?l<..<?u} = {..<?u}› ‹(?l::?'a::linorder) ≤ (?u::?'a::linorder) ⟹ {..<?l} ∪ {?l..<?u} = {..<?u}› ‹(?l::?'a::linorder) ≤ (?u::?'a::linorder) ⟹ {..?l} ∪ {?l<..?u} = {..?u}› ‹(?l::?'a::linorder) ≤ (?u::?'a::linorder) ⟹ {..<?l} ∪ {?l..?u} = {..?u}› ‹(?l::?'a::linorder) ≤ (?u::?'a::linorder) ⟹ {?l<..?u} ∪ {?u<..} = {?l<..}› ‹(?l::?'a::linorder) < (?u::?'a::linorder) ⟹ {?l<..<?u} ∪ {?u..} = {?l<..}› and more 14 facts*) max_def (*‹max (?a::?'a::ord) (?b::?'a::ord) = (if ?a ≤ ?b then ?b else ?a)›*) min_def (*‹min (?a::?'a::ord) (?b::?'a::ord) = (if ?a ≤ ?b then ?a else ?b)›*))[1]) (*proven 3 subgoals*) (*discuss goal 2*) apply ((auto simp: ivl_disj_un (*‹{?l} ∪ {?l<..} = {?l..}› ‹{..<?u} ∪ {?u} = {..?u}› ‹?l < ?u ⟹ {?l} ∪ {?l<..<?u} = {?l..<?u}› ‹?l < ?u ⟹ {?l<..<?u} ∪ {?u} = {?l<..?u}› ‹?l ≤ ?u ⟹ {?l} ∪ {?l<..?u} = {?l..?u}› ‹?l ≤ ?u ⟹ {?l..<?u} ∪ {?u} = {?l..?u}› ‹?l < ?u ⟹ {..?l} ∪ {?l<..<?u} = {..<?u}› ‹?l ≤ ?u ⟹ {..<?l} ∪ {?l..<?u} = {..<?u}› ‹?l ≤ ?u ⟹ {..?l} ∪ {?l<..?u} = {..?u}› ‹?l ≤ ?u ⟹ {..<?l} ∪ {?l..?u} = {..?u}› ‹?l ≤ ?u ⟹ {?l<..?u} ∪ {?u<..} = {?l<..}› ‹?l < ?u ⟹ {?l<..<?u} ∪ {?u..} = {?l<..}› and more 14 facts*) max_def (*‹max ?a ?b = (if ?a ≤ ?b then ?b else ?a)›*) min_def (*‹min ?a ?b = (if ?a ≤ ?b then ?a else ?b)›*))[1]) (*discuss goal 3*) apply ((auto simp: ivl_disj_un (*‹{?l} ∪ {?l<..} = {?l..}› ‹{..<?u} ∪ {?u} = {..?u}› ‹?l < ?u ⟹ {?l} ∪ {?l<..<?u} = {?l..<?u}› ‹?l < ?u ⟹ {?l<..<?u} ∪ {?u} = {?l<..?u}› ‹?l ≤ ?u ⟹ {?l} ∪ {?l<..?u} = {?l..?u}› ‹?l ≤ ?u ⟹ {?l..<?u} ∪ {?u} = {?l..?u}› ‹?l < ?u ⟹ {..?l} ∪ {?l<..<?u} = {..<?u}› ‹?l ≤ ?u ⟹ {..<?l} ∪ {?l..<?u} = {..<?u}› ‹?l ≤ ?u ⟹ {..?l} ∪ {?l<..?u} = {..?u}› ‹?l ≤ ?u ⟹ {..<?l} ∪ {?l..?u} = {..?u}› ‹?l ≤ ?u ⟹ {?l<..?u} ∪ {?u<..} = {?l<..}› ‹?l < ?u ⟹ {?l<..<?u} ∪ {?u..} = {?l<..}› and more 14 facts*) max_def (*‹max ?a ?b = (if ?a ≤ ?b then ?b else ?a)›*) min_def (*‹min ?a ?b = (if ?a ≤ ?b then ?a else ?b)›*))[1]) (*discuss goal 4*) apply ((auto simp: ivl_disj_un (*‹{?l} ∪ {?l<..} = {?l..}› ‹{..<?u} ∪ {?u} = {..?u}› ‹?l < ?u ⟹ {?l} ∪ {?l<..<?u} = {?l..<?u}› ‹?l < ?u ⟹ {?l<..<?u} ∪ {?u} = {?l<..?u}› ‹?l ≤ ?u ⟹ {?l} ∪ {?l<..?u} = {?l..?u}› ‹?l ≤ ?u ⟹ {?l..<?u} ∪ {?u} = {?l..?u}› ‹?l < ?u ⟹ {..?l} ∪ {?l<..<?u} = {..<?u}› ‹?l ≤ ?u ⟹ {..<?l} ∪ {?l..<?u} = {..<?u}› ‹?l ≤ ?u ⟹ {..?l} ∪ {?l<..?u} = {..?u}› ‹?l ≤ ?u ⟹ {..<?l} ∪ {?l..?u} = {..?u}› ‹?l ≤ ?u ⟹ {?l<..?u} ∪ {?u<..} = {?l<..}› ‹?l < ?u ⟹ {?l<..<?u} ∪ {?u..} = {?l<..}› and more 14 facts*) max_def (*‹max ?a ?b = (if ?a ≤ ?b then ?b else ?a)›*) min_def (*‹min ?a ?b = (if ?a ≤ ?b then ?a else ?b)›*))[1]) (*discuss goal 5*) apply ((auto simp: ivl_disj_un (*‹{?l} ∪ {?l<..} = {?l..}› ‹{..<?u} ∪ {?u} = {..?u}› ‹?l < ?u ⟹ {?l} ∪ {?l<..<?u} = {?l..<?u}› ‹?l < ?u ⟹ {?l<..<?u} ∪ {?u} = {?l<..?u}› ‹?l ≤ ?u ⟹ {?l} ∪ {?l<..?u} = {?l..?u}› ‹?l ≤ ?u ⟹ {?l..<?u} ∪ {?u} = {?l..?u}› ‹?l < ?u ⟹ {..?l} ∪ {?l<..<?u} = {..<?u}› ‹?l ≤ ?u ⟹ {..<?l} ∪ {?l..<?u} = {..<?u}› ‹?l ≤ ?u ⟹ {..?l} ∪ {?l<..?u} = {..?u}› ‹?l ≤ ?u ⟹ {..<?l} ∪ {?l..?u} = {..?u}› ‹?l ≤ ?u ⟹ {?l<..?u} ∪ {?u<..} = {?l<..}› ‹?l < ?u ⟹ {?l<..<?u} ∪ {?u..} = {?l<..}› and more 14 facts*) max_def (*‹max ?a ?b = (if ?a ≤ ?b then ?b else ?a)›*) min_def (*‹min ?a ?b = (if ?a ≤ ?b then ?a else ?b)›*))[1]) (*proven 5 subgoals*) . also (*calculation: ‹(λt. pbernpoly n t *⇩R f t) integrable_on {a..real_of_int a'} ∪ {real_of_int a'..real_of_int b'} ∪ {real_of_int b'..b}›*) have "{a..a'} ∪ {a'..b'} ∪ {b'..b} = {a..b}" using "*" (*‹a' ≤ b'› ‹a ≤ real_of_int a'› ‹real_of_int b' ≤ b›*) by auto finally (*calculation: ‹(λt::real. pbernpoly (n::nat) t *⇩R (f::real ⇒ 'a) t) integrable_on {a::real..b::real}›*) show "?thesis" (*goal: ‹(λt. pbernpoly n t *⇩R f t) integrable_on {a..b}›*) . next (*goal: ‹¬ ⌈a⌉ ≤ ⌊b⌋ ⟹ (λt. pbernpoly n t *⇩R f t) integrable_on {a..b}›*) assume "*": "¬ceiling a ≤ floor b" (*‹¬ ⌈a::real⌉ ≤ ⌊b::real⌋›*) show "?thesis" (*goal: ‹(λt. pbernpoly n t *⇩R f t) integrable_on {a..b}›*) proof (rule integrable_spike (*‹⟦(?f::?'a ⇒ ?'b) integrable_on (?T::?'a set); negligible (?S::?'a set); ⋀x::?'a. x ∈ ?T - ?S ⟹ (?g::?'a ⇒ ?'b) x = ?f x⟧ ⟹ ?g integrable_on ?T›*)) (*goals: 1. ‹(?f::real ⇒ 'a) integrable_on {a::real..b::real}› 2. ‹negligible (?S::real set)› 3. ‹⋀x::real. x ∈ {a::real..b::real} - (?S::real set) ⟹ pbernpoly (n::nat) x *⇩R (f::real ⇒ 'a) x = (?f::real ⇒ 'a) x›*) show "(λt. bernpoly n (t - floor a) *⇩R f t) integrable_on {a..b}" using "*" (*‹¬ ⌈a⌉ ≤ ⌊b⌋›*) by (auto 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 272 facts*) assms (*‹continuous_on {a..b} f›*)) next (*goals: 1. ‹negligible ?S› 2. ‹⋀x. x ∈ {a..b} - ?S ⟹ pbernpoly n x *⇩R f x = bernpoly n (x - real_of_int ⌊a⌋) *⇩R f x›*) show "pbernpoly n x *⇩R f x = bernpoly n (x - floor a) *⇩R f x" if "x ∈ {a..b} - {}" for x proof (-) (*goal: ‹pbernpoly n x *⇩R f x = bernpoly n (x - real_of_int ⌊a⌋) *⇩R f x›*) from "*" (*‹¬ ⌈a⌉ ≤ ⌊b⌋›*) have "**": "b < floor a + 1" unfolding ceiling_altdef (*goal: ‹b < real_of_int (⌊a⌋ + 1)›*) 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: le_floor_iff (*‹(?z ≤ ⌊?x⌋) = (of_int ?z ≤ ?x)›*)) from that (*‹x ∈ {a..b} - {}›*) have x: "x ≥ a" "x ≤ b" apply - (*goals: 1. ‹(x::real) ∈ {a::real..b::real} - {} ⟹ a ≤ x› 2. ‹(x::real) ∈ {a::real..b::real} - {} ⟹ x ≤ b› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) . with "*" (*‹¬ ⌈a::real⌉ ≤ ⌊b::real⌋›*) "**" (*‹b < real_of_int (⌊a⌋ + 1)›*) have "floor x = floor a" by linarith thus "?thesis" (*goal: ‹pbernpoly n x *⇩R f x = bernpoly n (x - real_of_int ⌊a⌋) *⇩R f x›*) by (simp add: pbernpoly_def (*‹pbernpoly ?n ?x = bernpoly ?n (frac ?x)›*) frac_def (*‹frac ?x ≡ ?x - of_int ⌊?x⌋›*)) qed qed (simp_all) (*solved the remaining goal: ‹negligible {}›*) qed lemma EM_remainder'_bounded_linear: assumes "bounded_linear h" assumes "continuous_on {a..b} f" shows "EM_remainder' n (λx. h (f x)) a b = h (EM_remainder' n f a b)" proof (-) (*goal: ‹EM_remainder' (n::nat) (λx::real. (h::'a ⇒ 'b) ((f::real ⇒ 'a) x)) (a::real) (b::real) = h (EM_remainder' n f a b)›*) have "integral {a..b} (λt. pbernpoly n t *⇩R h (f t)) = integral {a..b} (λt. h (pbernpoly n t *⇩R f t))" using assms (*‹bounded_linear (h::'a::banach ⇒ 'b::banach)› ‹continuous_on {a..b} f›*) by (simp add: linear_simps (*‹bounded_linear (?f::?'a ⇒ ?'b) ⟹ ?f ((?a::?'a) + (?b::?'a)) = ?f ?a + ?f ?b› ‹bounded_linear (?f::?'a ⇒ ?'b) ⟹ ?f ((?a::?'a) - (?b::?'a)) = ?f ?a - ?f ?b› ‹bounded_linear (?f::?'a ⇒ ?'b) ⟹ ?f (0::?'a) = (0::?'b)› ‹bounded_linear (?f::?'a ⇒ ?'b) ⟹ ?f (- (?a::?'a)) = - ?f ?a› ‹bounded_linear (?f::?'a ⇒ ?'b) ⟹ ?f ((?s::real) *⇩R (?v::?'a)) = ?s *⇩R ?f ?v›*)) also (*calculation: ‹integral {a..b} (λt. pbernpoly n t *⇩R h (f t)) = integral {a..b} (λt. h (pbernpoly n t *⇩R f t))›*) have "… = h (integral {a..b} (λt. pbernpoly n t *⇩R f t))" apply (subst integral_linear [OF _ assms(1), symmetric] (*‹(?f::?'a ⇒ 'a) integrable_on (?S::?'a set) ⟹ (h::'a ⇒ 'b) (integral ?S ?f) = integral ?S (h ∘ ?f)›*)) (*goals: 1. ‹(λt. pbernpoly n t *⇩R f t) integrable_on {a..b}› 2. ‹integral {a..b} (λt. h (pbernpoly n t *⇩R f t)) = integral {a..b} (h ∘ (λt. pbernpoly n t *⇩R f t))› discuss goal 1*) apply ((auto intro!: integrable_EM_remainder' (*‹continuous_on {?a..?b} ?f ⟹ (λt. pbernpoly ?n t *⇩R ?f t) integrable_on {?a..?b}›*) assms( (*‹continuous_on {a..b} f›*) 2) simp: o_def (*‹?f ∘ ?g = (λx. ?f (?g x))›*))[1]) (*discuss goal 2*) apply ((auto intro!: integrable_EM_remainder' (*‹continuous_on {?a..?b} ?f ⟹ (λt. pbernpoly ?n t *⇩R ?f t) integrable_on {?a..?b}›*) assms( (*‹continuous_on {a..b} f›*) 2) simp: o_def (*‹?f ∘ ?g = (λx. ?f (?g x))›*))[1]) (*proven 2 subgoals*) . finally (*calculation: ‹integral {a::real..b::real} (λt::real. pbernpoly (n::nat) t *⇩R (h::'a::banach ⇒ 'b::banach) ((f::real ⇒ 'a::banach) t)) = h (integral {a..b} (λt::real. pbernpoly n t *⇩R f t))›*) show "?thesis" (*goal: ‹EM_remainder' n (λx. h (f x)) a b = h (EM_remainder' n f a b)›*) using assms(1) (*‹bounded_linear h›*) by (simp add: EM_remainder'_def (*‹EM_remainder' ?n ?f ?a ?b = ((- 1) ^ Suc ?n / fact ?n) *⇩R integral {?a..?b} (λt. pbernpoly ?n t *⇩R ?f t)›*) linear_simps (*‹bounded_linear ?f ⟹ ?f (?a + ?b) = ?f ?a + ?f ?b› ‹bounded_linear ?f ⟹ ?f (?a - ?b) = ?f ?a - ?f ?b› ‹bounded_linear ?f ⟹ ?f 0 = 0› ‹bounded_linear ?f ⟹ ?f (- ?a) = - ?f ?a› ‹bounded_linear ?f ⟹ ?f (?s *⇩R ?v) = ?s *⇩R ?f ?v›*)) qed lemma EM_remainder_converges_of_real: assumes "EM_remainder_converges n f a" "continuous_on {of_int a..} f" shows "EM_remainder_converges n (λx. of_real (f x)) a" proof (-) (*goal: ‹EM_remainder_converges n (λx. of_real (f x)) a›*) from assms (*‹EM_remainder_converges n f a› ‹continuous_on {real_of_int a..} f›*) obtain L where L: "((λb. EM_remainder' n f (real_of_int a) (real_of_int b)) ⤏ L) at_top" (*goal: ‹(⋀L. ((λb. EM_remainder' n f (real_of_int a) (real_of_int b)) ⤏ L) at_top ⟹ thesis) ⟹ thesis›*) by (auto simp: EM_remainder_converges_def (*‹EM_remainder_converges ?n ?f ?a = (∃L. ((λx. EM_remainder' ?n ?f (real_of_int ?a) (real_of_int x)) ⤏ L) at_top)›*)) have "((λb. EM_remainder' n (λx. of_real (f x)) (of_int a) (of_int b)) ⤏ of_real L) at_top" proof (rule Lim_transform_eventually (*‹⟦((?f::?'a ⇒ ?'b) ⤏ (?l::?'b)) (?F::?'a filter); ∀⇩F x::?'a in ?F. ?f x = (?g::?'a ⇒ ?'b) x⟧ ⟹ (?g ⤏ ?l) ?F›*)) (*goals: 1. ‹(?f ⤏ of_real L) at_top› 2. ‹∀⇩F x in at_top. ?f x = EM_remainder' n (λx. of_real (f x)) (real_of_int a) (real_of_int x)›*) show "eventually (λb. of_real (EM_remainder' n f (of_int a) (of_int b)) = EM_remainder' n (λx. of_real (f x)) (of_int a) (of_int b)) at_top" using eventually_ge_at_top[of a] (*‹eventually ((≤) a) at_top›*) apply eventually_elim (*goal: ‹∀⇩F b in at_top. of_real (EM_remainder' n f (real_of_int a) (real_of_int b)) = EM_remainder' n (λx. of_real (f x)) (real_of_int a) (real_of_int b)›*) apply (intro EM_remainder'_bounded_linear [OF bounded_linear_of_real, symmetric] (*‹continuous_on {?a..?b} ?f ⟹ of_real (EM_remainder' ?n ?f ?a ?b) = EM_remainder' ?n (λx. of_real (?f x)) ?a ?b›*) continuous_on_subset[OF assms(2)] (*‹?t ⊆ {real_of_int a..} ⟹ continuous_on ?t f›*)) (*goal: ‹⋀b. a ≤ b ⟹ of_real (EM_remainder' n f (real_of_int a) (real_of_int b)) = EM_remainder' n (λx. of_real (f x)) (real_of_int a) (real_of_int b)›*) by auto qed (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 104 facts*) L (*‹((λb. EM_remainder' n f (real_of_int a) (real_of_int b)) ⤏ L) at_top›*)) (*solved the remaining goal: ‹((λb. of_real (EM_remainder' n f (real_of_int a) (real_of_int b))) ⤏ of_real L) at_top›*) thus "?thesis" (*goal: ‹EM_remainder_converges n (λx. of_real (f x)) a›*) unfolding EM_remainder_converges_def (*goal: ‹∃L::'a. ((λx::int. EM_remainder' (n::nat) (λx::real. of_real ((f::real ⇒ real) x)) (real_of_int (a::int)) (real_of_int x)) ⤏ L) at_top›*) by standard qed lemma EM_remainder_converges_of_real_iff: fixes f :: "real ⇒ real" assumes "continuous_on {of_int a..} f" shows "EM_remainder_converges n (λx. of_real (f x) :: 'a :: {banach, real_normed_algebra_1, real_inner}) a ⟷ EM_remainder_converges n f a" proof (standard) (*goals: 1. ‹EM_remainder_converges (n::nat) (λx::real. of_real ((f::real ⇒ real) x)) (a::int) ⟹ EM_remainder_converges n f a› 2. ‹EM_remainder_converges (n::nat) (f::real ⇒ real) (a::int) ⟹ EM_remainder_converges n (λx::real. of_real (f x)) a›*) assume "EM_remainder_converges n (λx. of_real (f x) :: 'a) a" (*‹EM_remainder_converges (n::nat) (λx::real. of_real ((f::real ⇒ real) x)) (a::int)›*) then obtain L :: 'a where L: "((λb. EM_remainder' n (λx. of_real (f x)) (of_int a) (of_int b)) ⤏ L) at_top" (*goal: ‹(⋀L. ((λb. EM_remainder' n (λx. of_real (f x)) (real_of_int a) (real_of_int b)) ⤏ L) at_top ⟹ thesis) ⟹ thesis›*) by (auto simp: EM_remainder_converges_def (*‹EM_remainder_converges ?n ?f ?a = (∃L. ((λx. EM_remainder' ?n ?f (real_of_int ?a) (real_of_int x)) ⤏ L) at_top)›*)) have "((λb. EM_remainder' n f (of_int a) (of_int b)) ⤏ L ∙ 1) at_top" proof (rule Lim_transform_eventually (*‹⟦(?f ⤏ ?l) ?F; ∀⇩F x in ?F. ?f x = ?g x⟧ ⟹ (?g ⤏ ?l) ?F›*)) (*goals: 1. ‹(?f ⤏ L ∙ 1) at_top› 2. ‹∀⇩F x in at_top. ?f x = EM_remainder' n f (real_of_int a) (real_of_int x)›*) show "eventually (λb. EM_remainder' n (λx. of_real (f x) :: 'a) (of_int a) (of_int b) ∙ 1 = EM_remainder' n f (of_int a) (of_int b)) at_top" using eventually_ge_at_top[of a] (*‹eventually ((≤) a) at_top›*) apply eventually_elim (*goal: ‹∀⇩F b in at_top. EM_remainder' n (λx. of_real (f x)) (real_of_int a) (real_of_int b) ∙ 1 = EM_remainder' n f (real_of_int a) (real_of_int b)›*) apply (subst EM_remainder'_bounded_linear [OF bounded_linear_of_real] (*‹continuous_on {?a..?b} ?f ⟹ EM_remainder' ?n (λx. of_real (?f x)) ?a ?b = of_real (EM_remainder' ?n ?f ?a ?b)›*)) (*goals: 1. ‹⋀b. a ≤ b ⟹ continuous_on {real_of_int a..real_of_int b} f› 2. ‹⋀b. a ≤ b ⟹ of_real (EM_remainder' n f (real_of_int a) (real_of_int b)) ∙ 1 = EM_remainder' n f (real_of_int a) (real_of_int b)› discuss goal 1*) apply ((auto intro!: continuous_on_subset[OF assms] (*‹?t ⊆ {real_of_int a..} ⟹ continuous_on ?t f›*))[1]) (*discuss goal 2*) apply ((auto intro!: continuous_on_subset[OF assms] (*‹(?t::real set) ⊆ {real_of_int (a::int)..} ⟹ continuous_on ?t (f::real ⇒ real)›*))[1]) (*proven 2 subgoals*) . qed (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 104 facts*) L (*‹((λb. EM_remainder' n (λx. of_real (f x)) (real_of_int a) (real_of_int b)) ⤏ L) at_top›*)) (*solved the remaining goal: ‹((λb. EM_remainder' n (λx. of_real (f x)) (real_of_int a) (real_of_int b) ∙ 1) ⤏ L ∙ 1) at_top›*) thus "EM_remainder_converges n f a" unfolding EM_remainder_converges_def (*goal: ‹∃L. ((λx. EM_remainder' n f (real_of_int a) (real_of_int x)) ⤏ L) at_top›*) by standard qed (intro EM_remainder_converges_of_real (*‹⟦EM_remainder_converges ?n ?f ?a; continuous_on {real_of_int ?a..} ?f⟧ ⟹ EM_remainder_converges ?n (λx. of_real (?f x)) ?a›*) assms (*‹continuous_on {real_of_int a..} f›*)) (*solved the remaining goal: ‹EM_remainder_converges n f a ⟹ EM_remainder_converges n (λx. of_real (f x)) a›*) lemma EM_remainder_of_real: assumes "continuous_on {a..} f" shows "EM_remainder n (λx. of_real (f x) :: 'a :: {banach, real_normed_algebra_1, real_inner}) a = of_real (EM_remainder n f a)" proof (-) (*goal: ‹EM_remainder n (λx. of_real (f x)) a = of_real (EM_remainder n f a)›*) have eq: "EM_remainder' n (λx. of_real (f x) :: 'a) (real_of_int a) = (λx::int. of_real (EM_remainder' n f a x))" apply (intro ext (*‹(⋀x::?'a. (?f::?'a ⇒ ?'b) x = (?g::?'a ⇒ ?'b) x) ⟹ ?f = ?g›*) EM_remainder'_bounded_linear[OF bounded_linear_of_real] (*‹continuous_on {?a::real..?b::real} (?f::real ⇒ real) ⟹ EM_remainder' (?n::nat) (λx::real. of_real (?f x)) ?a ?b = of_real (EM_remainder' ?n ?f ?a ?b)›*) continuous_on_subset[OF assms] (*‹(?t::real set) ⊆ {real_of_int (a::int)..} ⟹ continuous_on ?t (f::real ⇒ real)›*)) (*goal: ‹(λx. EM_remainder' n (λx. of_real (f x)) (real_of_int a) (real_of_int x)) = (λx. of_real (EM_remainder' n f (real_of_int a) (real_of_int x)))›*) by auto show "?thesis" (*goal: ‹EM_remainder (n::nat) (λx::real. of_real ((f::real ⇒ real) x)) (a::int) = of_real (EM_remainder n f a)›*) proof (cases "EM_remainder_converges n f a") (*goals: 1. ‹EM_remainder_converges n f a ⟹ EM_remainder n (λx. of_real (f x)) a = of_real (EM_remainder n f a)› 2. ‹¬ EM_remainder_converges n f a ⟹ EM_remainder n (λx. of_real (f x)) a = of_real (EM_remainder n f a)›*) case False (*‹¬ EM_remainder_converges n f a›*) with EM_remainder_converges_of_real_iff[OF assms, of n] (*‹EM_remainder_converges n (λx. of_real (f x)) a = EM_remainder_converges n f a›*) show "?thesis" (*goal: ‹EM_remainder n (λx. of_real (f x)) a = of_real (EM_remainder n f a)›*) by (auto simp: EM_remainder_def (*‹EM_remainder ?n ?f ?a = (if EM_remainder_converges ?n ?f ?a then Lim at_top (λx. EM_remainder' ?n ?f (real_of_int ?a) (real_of_int x)) else 0)›*)) next (*goal: ‹EM_remainder_converges n f a ⟹ EM_remainder n (λx. of_real (f x)) a = of_real (EM_remainder n f a)›*) case True (*‹EM_remainder_converges n f a›*) then obtain L where L: "((λx. EM_remainder' n f a (real_of_int x)) ⤏ L) at_top" (*goal: ‹(⋀L::real. ((λx::int. EM_remainder' (n::nat) (f::real ⇒ real) (real_of_int (a::int)) (real_of_int x)) ⤏ L) at_top ⟹ thesis::bool) ⟹ thesis›*) by (auto simp: EM_remainder_converges_def (*‹EM_remainder_converges ?n ?f ?a = (∃L. ((λx. EM_remainder' ?n ?f (real_of_int ?a) (real_of_int x)) ⤏ L) at_top)›*)) have L': "((λx. EM_remainder' n (λx. of_real (f x) :: 'a) a (real_of_int x)) ⤏ of_real L) at_top" unfolding eq (*goal: ‹((λx. of_real (EM_remainder' n f (real_of_int a) (real_of_int x))) ⤏ of_real L) at_top›*) by (intro tendsto_of_real (*‹(?g ⤏ ?a) ?F ⟹ ((λx. of_real (?g x)) ⤏ of_real ?a) ?F›*) L (*‹((λx. EM_remainder' n f (real_of_int a) (real_of_int x)) ⤏ L) at_top›*)) from L (*‹((λx. EM_remainder' n f (real_of_int a) (real_of_int x)) ⤏ L) at_top›*) L' (*‹((λx::int. EM_remainder' (n::nat) (λx::real. of_real ((f::real ⇒ real) x)) (real_of_int (a::int)) (real_of_int x)) ⤏ of_real (L::real)) at_top›*) tendsto_Lim[OF _ L] (*‹at_top ≠ bot ⟹ Lim at_top (λx. EM_remainder' n f (real_of_int a) (real_of_int x)) = L›*) tendsto_Lim[OF _ L'] (*‹at_top ≠ bot ⟹ Lim at_top (λx. EM_remainder' n (λx. of_real (f x)) (real_of_int a) (real_of_int x)) = of_real L›*) show "?thesis" (*goal: ‹EM_remainder n (λx. of_real (f x)) a = of_real (EM_remainder n f a)›*) by (auto simp: EM_remainder_def (*‹EM_remainder (?n::nat) (?f::real ⇒ ?'a::banach) (?a::int) = (if EM_remainder_converges ?n ?f ?a then Lim at_top (λx::int. EM_remainder' ?n ?f (real_of_int ?a) (real_of_int x)) else (0::?'a::banach))›*) EM_remainder_converges_def (*‹EM_remainder_converges (?n::nat) (?f::real ⇒ ?'a::banach) (?a::int) = (∃L::?'a::banach. ((λx::int. EM_remainder' ?n ?f (real_of_int ?a) (real_of_int x)) ⤏ L) at_top)›*)) qed qed lemma EM_remainder'_cong: assumes "⋀x. x ∈ {a..b} ⟹ f x = g x" "n = n'" "a = a'" "b = b'" shows "EM_remainder' n f a b = EM_remainder' n' g a' b'" proof (-) (*goal: ‹EM_remainder' n f a b = EM_remainder' n' g a' b'›*) have "integral {a..b} (λt. pbernpoly n t *⇩R f t) = integral {a'..b'} (λt. pbernpoly n' t *⇩R g t)" unfolding assms (*goal: ‹integral {a'..b'} (λt. pbernpoly n' t *⇩R f t) = integral {a'..b'} (λt. pbernpoly n' t *⇩R g t)›*) using assms (*‹(?x::real) ∈ {a::real..b::real} ⟹ (f::real ⇒ 'a) ?x = (g::real ⇒ 'a) ?x› ‹n = n'› ‹a = a'› ‹(b::real) = (b'::real)›*) apply (intro integral_cong (*‹(⋀x::?'a::euclidean_space. x ∈ (?s::?'a::euclidean_space set) ⟹ (?f::?'a::euclidean_space ⇒ ?'b::real_normed_vector) x = (?g::?'a::euclidean_space ⇒ ?'b::real_normed_vector) x) ⟹ integral ?s ?f = integral ?s ?g›*)) (*goal: ‹integral {a'..b'} (λt. pbernpoly n' t *⇩R f t) = integral {a'..b'} (λt. pbernpoly n' t *⇩R g t)›*) by auto with assms (*‹?x ∈ {a..b} ⟹ f ?x = g ?x› ‹n = n'› ‹(a::real) = (a'::real)› ‹b = b'›*) show "?thesis" (*goal: ‹EM_remainder' n f a b = EM_remainder' n' g a' b'›*) by (simp add: EM_remainder'_def (*‹EM_remainder' ?n ?f ?a ?b = ((- 1) ^ Suc ?n / fact ?n) *⇩R integral {?a..?b} (λt. pbernpoly ?n t *⇩R ?f t)›*)) qed lemma EM_remainder_converges_cong: assumes "⋀x. x ≥ of_int a ⟹ f x = g x" "n = n'" "a = a'" shows "EM_remainder_converges n f a = EM_remainder_converges n' g a'" unfolding EM_remainder_converges_def (*goal: ‹(∃L. ((λx. EM_remainder' n f (real_of_int a) (real_of_int x)) ⤏ L) at_top) = (∃L. ((λx. EM_remainder' n' g (real_of_int a') (real_of_int x)) ⤏ L) at_top)›*) apply (subst EM_remainder'_cong[OF _ refl refl refl, of _ _ f g] (*‹(⋀x. x ∈ {?a..?b} ⟹ f x = g x) ⟹ EM_remainder' ?n f ?a ?b = EM_remainder' ?n g ?a ?b›*)) (*goals: 1. ‹⋀x L xa. xa ∈ {real_of_int a..real_of_int x} ⟹ f xa = g xa› 2. ‹(∃L. ((λx. EM_remainder' n g (real_of_int a) (real_of_int x)) ⤏ L) at_top) = (∃L. ((λx. EM_remainder' n' g (real_of_int a') (real_of_int x)) ⤏ L) at_top)› discuss goal 1*) apply ((use assms in auto)[1]) (*discuss goal 2*) apply ((use assms in auto)[1]) (*proven 2 subgoals*) . lemma EM_remainder_cong: assumes "⋀x. x ≥ of_int a ⟹ f x = g x" "n = n'" "a = a'" shows "EM_remainder n f a = EM_remainder n' g a'" proof (-) (*goal: ‹EM_remainder (n::nat) (f::real ⇒ 'a) (a::int) = EM_remainder (n'::nat) (g::real ⇒ 'a) (a'::int)›*) have "*": "EM_remainder_converges n f a = EM_remainder_converges n' g a'" using assms (*‹real_of_int a ≤ ?x ⟹ f ?x = g ?x› ‹n = n'› ‹a = a'›*) apply (intro EM_remainder_converges_cong (*‹⟦⋀x. real_of_int ?a ≤ x ⟹ ?f x = ?g x; ?n = ?n'; ?a = ?a'⟧ ⟹ EM_remainder_converges ?n ?f ?a = EM_remainder_converges ?n' ?g ?a'›*)) (*goals: 1. ‹⋀x::real. ⟦⋀x::real. real_of_int (a::int) ≤ x ⟹ (f::real ⇒ 'a::banach) x = (g::real ⇒ 'a::banach) x; (n::nat) = (n'::nat); a = (a'::int); real_of_int a ≤ x⟧ ⟹ f x = g x› 2. ‹⟦⋀x::real. real_of_int (a::int) ≤ x ⟹ (f::real ⇒ 'a::banach) x = (g::real ⇒ 'a::banach) x; (n::nat) = (n'::nat); a = (a'::int)⟧ ⟹ n = n'› 3. ‹⟦⋀x::real. real_of_int (a::int) ≤ x ⟹ (f::real ⇒ 'a::banach) x = (g::real ⇒ 'a::banach) x; (n::nat) = (n'::nat); a = (a'::int)⟧ ⟹ a = a'› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*proven 3 subgoals*) . show "?thesis" (*goal: ‹EM_remainder n f a = EM_remainder n' g a'›*) unfolding EM_remainder_def (*goal: ‹(if EM_remainder_converges n f a then Lim at_top (λx. EM_remainder' n f (real_of_int a) (real_of_int x)) else 0) = (if EM_remainder_converges n' g a' then Lim at_top (λx. EM_remainder' n' g (real_of_int a') (real_of_int x)) else 0)›*) apply (subst EM_remainder'_cong[OF _ refl refl refl, of _ _ f g] (*‹(⋀x. x ∈ {?a..?b} ⟹ f x = g x) ⟹ EM_remainder' ?n f ?a ?b = EM_remainder' ?n g ?a ?b›*)) (*goals: 1. ‹⋀x xa. xa ∈ {real_of_int a..real_of_int x} ⟹ f xa = g xa› 2. ‹(if EM_remainder_converges n f a then Lim at_top (λx. EM_remainder' n g (real_of_int a) (real_of_int x)) else 0) = (if EM_remainder_converges n' g a' then Lim at_top (λx. EM_remainder' n' g (real_of_int a') (real_of_int x)) else 0)› discuss goal 1*) apply ((use assms * in auto)[1]) (*discuss goal 2*) apply ((use assms * in auto)[1]) (*proven 2 subgoals*) . qed lemma EM_remainder_converges_cnj: assumes "continuous_on {a..} f" and "EM_remainder_converges n f a" shows "EM_remainder_converges n (λx. cnj (f x)) a" proof (-) (*goal: ‹EM_remainder_converges n (λx. cnj (f x)) a›*) interpret bounded_linear cnj by (rule bounded_linear_cnj (*‹bounded_linear cnj›*)) obtain L where L: "((λx. EM_remainder' n f (real_of_int a) (real_of_int x)) ⤏ L) at_top" (*goal: ‹(⋀L. ((λx. EM_remainder' n f (real_of_int a) (real_of_int x)) ⤏ L) at_top ⟹ thesis) ⟹ thesis›*) using assms (*‹continuous_on {real_of_int a..} f› ‹EM_remainder_converges n f a›*) unfolding EM_remainder_converges_def (*goal: ‹(⋀L. ((λx. EM_remainder' n f (real_of_int a) (real_of_int x)) ⤏ L) at_top ⟹ thesis) ⟹ thesis›*) by blast note tendsto_cnj[OF this] (*‹((λx. cnj (EM_remainder' n f (real_of_int a) (real_of_int x))) ⤏ cnj L) at_top›*) also (*calculation: ‹((λx. cnj (EM_remainder' n f (real_of_int a) (real_of_int x))) ⤏ cnj L) at_top›*) have "(λx. cnj (EM_remainder' n f (real_of_int a) (real_of_int x))) = (λx. EM_remainder' n (λx. cnj (f x)) (real_of_int a) (real_of_int x))" apply (subst EM_remainder'_bounded_linear [OF bounded_linear_cnj] (*‹continuous_on {?a..?b} ?f ⟹ EM_remainder' ?n (λx. cnj (?f x)) ?a ?b = cnj (EM_remainder' ?n ?f ?a ?b)›*)) (*goals: 1. ‹⋀x. continuous_on {real_of_int a..real_of_int x} f› 2. ‹(λx. cnj (EM_remainder' n f (real_of_int a) (real_of_int x))) = (λx. cnj (EM_remainder' n f (real_of_int a) (real_of_int x)))› discuss goal 1*) apply (rule continuous_on_subset [OF assms(1)] (*‹?t ⊆ {real_of_int a..} ⟹ continuous_on ?t f›*)) (*top goal: ‹⋀x. continuous_on {real_of_int a..real_of_int x} f› and 1 goal remains*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . finally (*calculation: ‹((λx. EM_remainder' n (λx. cnj (f x)) (real_of_int a) (real_of_int x)) ⤏ cnj L) at_top›*) have L': "(… ⤏ cnj L) at_top" . thus "EM_remainder_converges n (λx. cnj (f x)) a" by (auto simp: EM_remainder_converges_def (*‹EM_remainder_converges (?n::nat) (?f::real ⇒ ?'a) (?a::int) = (∃L::?'a. ((λx::int. EM_remainder' ?n ?f (real_of_int ?a) (real_of_int x)) ⤏ L) at_top)›*)) qed lemma EM_remainder_converges_cnj_iff: assumes "continuous_on {of_int a..} f" shows "EM_remainder_converges n (λx. cnj (f x)) a ⟷ EM_remainder_converges n f a" proof (standard) (*goals: 1. ‹EM_remainder_converges n (λx. cnj (f x)) a ⟹ EM_remainder_converges n f a› 2. ‹EM_remainder_converges n f a ⟹ EM_remainder_converges n (λx. cnj (f x)) a›*) assume "EM_remainder_converges n (λx. cnj (f x)) a" (*‹EM_remainder_converges (n::nat) (λx::real. cnj ((f::real ⇒ complex) x)) (a::int)›*) hence "EM_remainder_converges n (λx. cnj (cnj (f x))) a" apply (rule EM_remainder_converges_cnj [rotated] (*‹⟦EM_remainder_converges (?n::nat) (?f::real ⇒ complex) (?a::int); continuous_on {real_of_int ?a..} ?f⟧ ⟹ EM_remainder_converges ?n (λx::real. cnj (?f x)) ?a›*)) (*goal: ‹EM_remainder_converges (n::nat) (λx::real. cnj (cnj ((f::real ⇒ complex) x))) (a::int)›*) 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 272 facts*) assms (*‹continuous_on {real_of_int a..} f›*)) thus "EM_remainder_converges n f a" by simp qed (intro EM_remainder_converges_cnj (*‹⟦continuous_on {real_of_int ?a..} ?f; EM_remainder_converges ?n ?f ?a⟧ ⟹ EM_remainder_converges ?n (λx. cnj (?f x)) ?a›*) assms (*‹continuous_on {real_of_int a..} f›*)) (*solved the remaining goal: ‹EM_remainder_converges n f a ⟹ EM_remainder_converges n (λx. cnj (f x)) a›*) lemma EM_remainder_cnj: assumes "continuous_on {a..} f" shows "EM_remainder n (λx. cnj (f x)) a = cnj (EM_remainder n f a)" proof (cases "EM_remainder_converges n f a") (*goals: 1. ‹EM_remainder_converges n f a ⟹ EM_remainder n (λx. cnj (f x)) a = cnj (EM_remainder n f a)› 2. ‹¬ EM_remainder_converges n f a ⟹ EM_remainder n (λx. cnj (f x)) a = cnj (EM_remainder n f a)›*) case False (*‹¬ EM_remainder_converges n f a›*) hence "¬EM_remainder_converges n (λx. cnj (f x)) a" by (subst EM_remainder_converges_cnj_iff [OF assms] (*‹EM_remainder_converges (?n::nat) (λx::real. cnj ((f::real ⇒ complex) x)) (a::int) = EM_remainder_converges ?n f a›*)) with False (*‹¬ EM_remainder_converges n f a›*) show "?thesis" (*goal: ‹EM_remainder n (λx. cnj (f x)) a = cnj (EM_remainder n f a)›*) by (simp add: EM_remainder_def (*‹EM_remainder ?n ?f ?a = (if EM_remainder_converges ?n ?f ?a then Lim at_top (λx. EM_remainder' ?n ?f (real_of_int ?a) (real_of_int x)) else 0)›*)) next (*goal: ‹EM_remainder_converges n f a ⟹ EM_remainder n (λx. cnj (f x)) a = cnj (EM_remainder n f a)›*) case True (*‹EM_remainder_converges n f a›*) then obtain L where L: "((λx. EM_remainder' n f (real_of_int a) (real_of_int x)) ⤏ L) at_top" (*goal: ‹(⋀L::complex. ((λx::int. EM_remainder' (n::nat) (f::real ⇒ complex) (real_of_int (a::int)) (real_of_int x)) ⤏ L) at_top ⟹ thesis::bool) ⟹ thesis›*) unfolding EM_remainder_converges_def (*goal: ‹(⋀L. ((λx. EM_remainder' n f (real_of_int a) (real_of_int x)) ⤏ L) at_top ⟹ thesis) ⟹ thesis›*) by blast note tendsto_cnj[OF this] (*‹((λx. cnj (EM_remainder' n f (real_of_int a) (real_of_int x))) ⤏ cnj L) at_top›*) also (*calculation: ‹((λx. cnj (EM_remainder' n f (real_of_int a) (real_of_int x))) ⤏ cnj L) at_top›*) have "(λx. cnj (EM_remainder' n f (real_of_int a) (real_of_int x))) = (λx. EM_remainder' n (λx. cnj (f x)) (real_of_int a) (real_of_int x))" apply (subst EM_remainder'_bounded_linear [OF bounded_linear_cnj] (*‹continuous_on {?a..?b} ?f ⟹ EM_remainder' ?n (λx. cnj (?f x)) ?a ?b = cnj (EM_remainder' ?n ?f ?a ?b)›*)) (*goals: 1. ‹⋀x. continuous_on {real_of_int a..real_of_int x} f› 2. ‹(λx. cnj (EM_remainder' n f (real_of_int a) (real_of_int x))) = (λx. cnj (EM_remainder' n f (real_of_int a) (real_of_int x)))› discuss goal 1*) apply (rule continuous_on_subset [OF assms(1)] (*‹(?t::real set) ⊆ {real_of_int (a::int)..} ⟹ continuous_on ?t (f::real ⇒ complex)›*)) (*top goal: ‹⋀x. continuous_on {real_of_int a..real_of_int x} f› and 1 goal remains*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . finally (*calculation: ‹((λx. EM_remainder' n (λx. cnj (f x)) (real_of_int a) (real_of_int x)) ⤏ cnj L) at_top›*) have L': "(… ⤏ cnj L) at_top" . moreover from assms (*‹continuous_on {real_of_int a..} f›*) L (*‹((λx. EM_remainder' n f (real_of_int a) (real_of_int x)) ⤏ L) at_top›*) have "EM_remainder n f a = L" by (intro EM_remainder_eqI (*‹((λx. EM_remainder' ?n ?f (real_of_int ?b) (real_of_int x)) ⤏ ?L) at_top ⟹ EM_remainder ?n ?f ?b = ?L›*)) ultimately show "EM_remainder n (λx. cnj (f x)) a = cnj (EM_remainder n f a)" using L' (*‹((λx. EM_remainder' n (λx. cnj (f x)) (real_of_int a) (real_of_int x)) ⤏ cnj L) at_top›*) apply (intro EM_remainder_eqI (*‹((λx::int. EM_remainder' (?n::nat) (?f::real ⇒ ?'a) (real_of_int (?b::int)) (real_of_int x)) ⤏ (?L::?'a)) at_top ⟹ EM_remainder ?n ?f ?b = ?L›*)) (*goal: ‹EM_remainder n (λx. cnj (f x)) a = cnj (EM_remainder n f a)›*) by simp qed lemma EM_remainder'_combine: fixes f :: "real ⇒ 'a :: banach" assumes [continuous_intros]: "continuous_on {a..c} f" assumes "a ≤ b" "b ≤ c" shows "EM_remainder' n f a b + EM_remainder' n f b c = EM_remainder' n f a c" proof (-) (*goal: ‹EM_remainder' (n::nat) (f::real ⇒ 'a) (a::real) (b::real) + EM_remainder' n f b (c::real) = EM_remainder' n f a c›*) have "integral {a..b} (λt. pbernpoly n t *⇩R f t) + integral {b..c} (λt. pbernpoly n t *⇩R f t) = integral {a..c} (λt. pbernpoly n t *⇩R f t)" by (intro Henstock_Kurzweil_Integration.integral_combine (*‹⟦?a ≤ ?c; ?c ≤ ?b; ?f integrable_on {?a..?b}⟧ ⟹ integral {?a..?c} ?f + integral {?c..?b} ?f = integral {?a..?b} ?f›*) assms (*‹continuous_on {a..c} f› ‹a ≤ b› ‹b ≤ c›*) integrable_EM_remainder' (*‹continuous_on {?a..?b} ?f ⟹ (λt. pbernpoly ?n t *⇩R ?f t) integrable_on {?a..?b}›*)) from this[symmetric] (*‹integral {a..c} (λt. pbernpoly n t *⇩R f t) = integral {a..b} (λt. pbernpoly n t *⇩R f t) + integral {b..c} (λt. pbernpoly n t *⇩R f t)›*) show "?thesis" (*goal: ‹EM_remainder' n f a b + EM_remainder' n f b c = EM_remainder' n f a c›*) by (simp add: EM_remainder'_def (*‹EM_remainder' (?n::nat) (?f::real ⇒ ?'a::banach) (?a::real) (?b::real) = ((- (1::real)) ^ Suc ?n / fact ?n) *⇩R integral {?a..?b} (λt::real. pbernpoly ?n t *⇩R ?f t)›*) 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*)) qed lemma uniformly_convergent_EM_remainder': fixes f :: "'a ⇒ real ⇒ 'b :: {banach,real_normed_algebra}" assumes deriv: "⋀y. a ≤ y ⟹ (G has_real_derivative g y) (at y within {a..})" assumes integrable: "⋀a' b y. y ∈ A ⟹ a ≤ a' ⟹ a' ≤ b ⟹ (λt. pbernpoly n t *⇩R f y t) integrable_on {a'..b}" assumes conv: "convergent (λy. G (real y))" assumes bound: "eventually (λx. ∀y∈A. norm (f y x) ≤ g x) at_top" shows "uniformly_convergent_on A (λb s. EM_remainder' n (f s) a b)" proof (-) (*goal: ‹uniformly_convergent_on A (λx s. EM_remainder' n (f s) a (real x))›*) interpret bounded_linear "λx::'b. ((- 1) ^ Suc n / fact n) *⇩R x" by (rule bounded_linear_scaleR_right (*‹bounded_linear ((*⇩R) ?r)›*)) from bounded_pbernpoly (*‹(⋀c. (⋀x. norm (pbernpoly ?n x) ≤ c) ⟹ ?thesis) ⟹ ?thesis›*) obtain C where C: "⋀x. norm (pbernpoly n x) ≤ C" (*goal: ‹(⋀C. (⋀x. norm (pbernpoly n x) ≤ C) ⟹ thesis) ⟹ thesis›*) by auto from C[of 0] (*‹norm (pbernpoly n 0) ≤ C›*) have [simp]: "C ≥ 0" by simp show "?thesis" (*goal: ‹uniformly_convergent_on (A::'a set) (λ(x::nat) s::'a. EM_remainder' (n::nat) ((f::'a ⇒ real ⇒ 'b) s) (a::real) (real x))›*) unfolding EM_remainder'_def (*goal: ‹uniformly_convergent_on A (λx s. ((- 1) ^ Suc n / fact n) *⇩R integral {a..real x} (λt. pbernpoly n t *⇩R f s t))›*) proof (intro uniformly_convergent_on (*‹uniformly_convergent_on ?A ?g ⟹ uniformly_convergent_on ?A (λx y. ((- 1) ^ Suc n / fact n) *⇩R ?g x y)›*) uniformly_convergent_improper_integral' (*‹⟦⋀x. ?a ≤ x ⟹ (?G has_real_derivative ?g x) (at x within {?a..}); ⋀a' b x. ⟦x ∈ ?A; ?a ≤ a'; a' ≤ b⟧ ⟹ ?f x integrable_on {a'..b}; convergent (λx. ?G (real x)); ∀⇩F x in at_top. ∀y∈?A. norm (?f y x) ≤ ?g x⟧ ⟹ uniformly_convergent_on ?A (λx xa. integral {?a..real x} (?f xa))›*)) (*goals: 1. ‹⋀y::real. (a::real) ≤ y ⟹ ((?G1::real ⇒ real) has_real_derivative (?g1::real ⇒ real) y) (at y within {a..})› 2. ‹⋀(a'::real) (b::real) y::'a. ⟦y ∈ (A::'a set); (a::real) ≤ a'; a' ≤ b⟧ ⟹ (λt::real. pbernpoly (n::nat) t *⇩R (f::'a ⇒ real ⇒ 'b) y t) integrable_on {a'..b}› 3. ‹convergent (λy::nat. (?G1::real ⇒ real) (real y))› 4. ‹∀⇩F y::real in at_top. ∀ya::'a∈A::'a set. norm (pbernpoly (n::nat) y *⇩R (f::'a ⇒ real ⇒ 'b) ya y) ≤ (?g1::real ⇒ real) y›*) fix x assume "x ≥ a" (*‹(a::real) ≤ (x::real)›*) thus "((λx. C * G x) has_real_derivative C * g x) (at x within {a..})" by (intro DERIV_cmult (*‹(?f has_field_derivative ?D) (at ?x within ?s) ⟹ ((λx. ?c * ?f x) has_field_derivative ?c * ?D) (at ?x within ?s)›*) deriv (*‹a ≤ ?y ⟹ (G has_real_derivative g ?y) (at ?y within {a..})›*)) next (*goals: 1. ‹⋀a' b y. ⟦y ∈ A; a ≤ a'; a' ≤ b⟧ ⟹ (λt. pbernpoly n t *⇩R f y t) integrable_on {a'..b}› 2. ‹convergent (λy. C * G (real y))› 3. ‹∀⇩F y in at_top. ∀ya∈A. norm (pbernpoly n y *⇩R f ya y) ≤ C * g y›*) fix y and a' and b assume "y ∈ A" "a ≤ a'" "a' ≤ b" (*‹(y::'a) ∈ (A::'a set)› ‹(a::real) ≤ (a'::real)› ‹(a'::real) ≤ (b::real)›*) thus "(λt. pbernpoly n t *⇩R f y t) integrable_on {a'..b}" by (rule integrable (*‹⟦?y ∈ A; a ≤ ?a'; ?a' ≤ ?b⟧ ⟹ (λt. pbernpoly n t *⇩R f ?y t) integrable_on {?a'..?b}›*)) next (*goals: 1. ‹convergent (λy. C * G (real y))› 2. ‹∀⇩F y in at_top. ∀ya∈A. norm (pbernpoly n y *⇩R f ya y) ≤ C * g y›*) from conv (*‹convergent (λy. G (real y))›*) obtain L where "(λy. G (real y)) ⇢ L" (*goal: ‹(⋀L. (λy. G (real y)) ⇢ L ⟹ thesis) ⟹ thesis›*) by (auto simp: convergent_def (*‹convergent (?X::nat ⇒ ?'a) = (∃L::?'a. ?X ⇢ L)›*)) from tendsto_mult[OF tendsto_const [ of C ] this] (*‹(λx. C * G (real x)) ⇢ C * L›*) show "convergent (λy. C * G (real y))" by (auto simp: convergent_def (*‹convergent ?X = (∃L. ?X ⇢ L)›*)) next (*goal: ‹∀⇩F y in at_top. ∀ya∈A. norm (pbernpoly n y *⇩R f ya y) ≤ C * g y›*) show "∀⇩F x in at_top. ∀y∈A. norm (pbernpoly n x *⇩R f y x) ≤ C * g x" using C (*‹norm (pbernpoly n ?x) ≤ C›*) unfolding norm_scaleR (*goal: ‹∀⇩F x in at_top. ∀y∈A. ¦pbernpoly n x¦ * norm (f y x) ≤ C * g x›*) apply (intro eventually_mono[OF bound] (*‹(⋀x::real. ∀y::'a∈A::'a set. norm ((f::'a ⇒ real ⇒ 'b) y x) ≤ (g::real ⇒ real) x ⟹ (?Q::real ⇒ bool) x) ⟹ eventually ?Q at_top›*) ballI (*‹(⋀x::?'a. x ∈ (?A::?'a set) ⟹ (?P::?'a ⇒ bool) x) ⟹ ∀x::?'a∈?A. ?P x›*) mult_mono (*‹⟦(?a::?'a) ≤ (?b::?'a); (?c::?'a) ≤ (?d::?'a); (0::?'a) ≤ ?b; (0::?'a) ≤ ?c⟧ ⟹ ?a * ?c ≤ ?b * ?d›*)) (*goals: 1. ‹⋀x y. ⟦⋀x. norm (pbernpoly n x) ≤ C; ∀y∈A. norm (f y x) ≤ g x; y ∈ A⟧ ⟹ ¦pbernpoly n x¦ ≤ C› 2. ‹⋀x y. ⟦⋀x. norm (pbernpoly n x) ≤ C; ∀y∈A. norm (f y x) ≤ g x; y ∈ A⟧ ⟹ norm (f y x) ≤ g x› 3. ‹⋀x y. ⟦⋀x. norm (pbernpoly n x) ≤ C; ∀y∈A. norm (f y x) ≤ g x; y ∈ A⟧ ⟹ 0 ≤ C› 4. ‹⋀x y. ⟦⋀x. norm (pbernpoly n x) ≤ C; ∀y∈A. norm (f y x) ≤ g x; y ∈ A⟧ ⟹ 0 ≤ norm (f y 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]) (*proven 4 subgoals*) . qed qed lemma uniform_limit_EM_remainder: fixes f :: "'a ⇒ real ⇒ 'b :: {banach,real_normed_algebra}" assumes deriv: "⋀y. a ≤ y ⟹ (G has_real_derivative g y) (at y within {a..})" assumes integrable: "⋀a' b y. y ∈ A ⟹ a ≤ a' ⟹ a' ≤ b ⟹ (λt. pbernpoly n t *⇩R f y t) integrable_on {a'..b}" assumes conv: "convergent (λy. G (real y))" assumes bound: "eventually (λx. ∀y∈A. norm (f y x) ≤ g x) at_top" shows "uniform_limit A (λb s. EM_remainder' n (f s) a b) (λs. EM_remainder n (f s) a) sequentially" proof (-) (*goal: ‹uniform_limit A (λb s. EM_remainder' n (f s) (real_of_int a) (real b)) (λs. EM_remainder n (f s) a) sequentially›*) have "*": "uniformly_convergent_on A (λb s. EM_remainder' n (f s) a b)" apply (rule uniformly_convergent_EM_remainder'[OF assms] (*‹⟦⋀y. real_of_int a ≤ y ⟹ real_of_int a ≤ y; ⋀a' b y. ⟦y ∈ A; real_of_int a ≤ a'; a' ≤ b⟧ ⟹ y ∈ A; ⋀a' b y. ⟦y ∈ A; real_of_int a ≤ a'; a' ≤ b⟧ ⟹ real_of_int a ≤ a'; ⋀a' b y. ⟦y ∈ A; real_of_int a ≤ a'; a' ≤ b⟧ ⟹ a' ≤ b⟧ ⟹ uniformly_convergent_on A (λx s. EM_remainder' n (f s) (real_of_int a) (real x))›*)) (*goals: 1. ‹⋀y. real_of_int a ≤ y ⟹ real_of_int a ≤ y› 2. ‹⋀a' b y. ⟦y ∈ A; real_of_int a ≤ a'; a' ≤ b⟧ ⟹ y ∈ A› 3. ‹⋀a' b y. ⟦y ∈ A; real_of_int a ≤ a'; a' ≤ b⟧ ⟹ real_of_int a ≤ a'› 4. ‹⋀a' b y. ⟦y ∈ A; real_of_int a ≤ a'; a' ≤ b⟧ ⟹ 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*) also (*calculation: ‹uniformly_convergent_on A (λx s. EM_remainder' n (f s) (real_of_int a) (real x))›*) have "?this ⟷ ?thesis" unfolding uniformly_convergent_uniform_limit_iff (*goal: ‹uniform_limit A (λx s. EM_remainder' n (f s) (real_of_int a) (real x)) (λx. lim (λna. EM_remainder' n (f x) (real_of_int a) (real na))) sequentially = uniform_limit A (λb s. EM_remainder' n (f s) (real_of_int a) (real b)) (λs. EM_remainder n (f s) a) sequentially›*) proof (intro uniform_limit_cong (*‹⟦∀⇩F y in ?F. ∀x∈?X. ?f y x = ?g y x; ⋀x. x ∈ ?X ⟹ ?h x = ?i x⟧ ⟹ uniform_limit ?X ?f ?h ?F = uniform_limit ?X ?g ?i ?F›*) refl (*‹?t = ?t›*) always_eventually (*‹∀x. ?P x ⟹ eventually ?P ?F›*) allI (*‹(⋀x. ?P x) ⟹ ∀x. ?P x›*) ballI (*‹(⋀x. x ∈ ?A ⟹ ?P x) ⟹ ∀x∈?A. ?P x›*)) (*goal: ‹⋀x. x ∈ A ⟹ lim (λna. EM_remainder' n (f x) (real_of_int a) (real na)) = EM_remainder n (f x) a›*) fix s assume "s ∈ A" (*‹(s::'a) ∈ (A::'a set)›*) with "*" (*‹uniformly_convergent_on A (λx s. EM_remainder' n (f s) (real_of_int a) (real x))›*) have "**": "convergent (λb. EM_remainder' n (f s) a b)" by (rule uniformly_convergent_imp_convergent (*‹⟦uniformly_convergent_on ?X ?f; ?x ∈ ?X⟧ ⟹ convergent (λn. ?f n ?x)›*)) show "lim (λb. EM_remainder' n (f s) a b) = EM_remainder n (f s) a" apply (rule sym (*‹?s = ?t ⟹ ?t = ?s›*)) (*goal: ‹lim (λx. EM_remainder' n (f s) (real_of_int a) (real x)) = EM_remainder n (f s) a›*) proof (rule EM_remainder_eqI (*‹((λx. EM_remainder' ?n ?f (real_of_int ?b) (real_of_int x)) ⤏ ?L) at_top ⟹ EM_remainder ?n ?f ?b = ?L›*)) (*goal: ‹((λx. EM_remainder' n (f s) (real_of_int a) (real_of_int x)) ⤏ lim (λx. EM_remainder' n (f s) (real_of_int a) (real x))) at_top›*) have "((λx. EM_remainder' n (f s) (real_of_int a) (real x)) ⤏ lim (λx. EM_remainder' n (f s) (real_of_int a) (real x))) at_top" (is "(_ ⤏ ?L) _") using "**" (*‹convergent (λx. EM_remainder' n (f s) (real_of_int a) (real x))›*) unfolding convergent_LIMSEQ_iff (*goal: ‹(λx::nat. EM_remainder' (n::nat) ((f::'a ⇒ real ⇒ 'b) (s::'a)) (real_of_int (a::int)) (real x)) ⇢ lim (λx::nat. EM_remainder' n (f s) (real_of_int a) (real x))›*) by blast hence "((λx. EM_remainder' n (f s) (real_of_int a) (real (nat x))) ⤏ ?L) at_top" apply (rule filterlim_compose (*‹⟦filterlim ?g ?F3.0 ?F2.0; filterlim ?f ?F2.0 ?F1.0⟧ ⟹ LIM x ?F1.0. ?g (?f x) :> ?F3.0›*)) (*goal: ‹((λx. EM_remainder' n (f s) (real_of_int a) (real (nat x))) ⤏ lim (λx. EM_remainder' n (f s) (real_of_int a) (real x))) at_top›*) by (fact filterlim_nat_sequentially (*‹filterlim nat sequentially at_top›*)) thus "((λx. EM_remainder' n (f s) (real_of_int a) (real_of_int x)) ⤏ ?L) at_top" apply (rule Lim_transform_eventually (*‹⟦(?f ⤏ ?l) ?F; ∀⇩F x in ?F. ?f x = ?g x⟧ ⟹ (?g ⤏ ?l) ?F›*)) (*goal: ‹((λx. EM_remainder' n (f s) (real_of_int a) (real_of_int x)) ⤏ lim (λx. EM_remainder' n (f s) (real_of_int a) (real x))) at_top›*) by (auto intro: eventually_mono[OF eventually_ge_at_top[of 0]] (*‹(⋀x. 0 ≤ x ⟹ ?Q x) ⟹ eventually ?Q at_top›*)) qed qed finally (*calculation: ‹uniform_limit A (λb s. EM_remainder' n (f s) (real_of_int a) (real b)) (λs. EM_remainder n (f s) a) sequentially›*) show "…" . qed lemma tendsto_EM_remainder: fixes f :: "real ⇒ 'b :: {banach,real_normed_algebra}" assumes deriv: "⋀y. a ≤ y ⟹ (G has_real_derivative g y) (at y within {a..})" assumes integrable: "⋀a' b . a ≤ a' ⟹ a' ≤ b ⟹ (λt. pbernpoly n t *⇩R f t) integrable_on {a'..b}" assumes conv: "convergent (λy. G (real y))" assumes bound: "eventually (λx. norm (f x) ≤ g x) at_top" shows "filterlim (λb. EM_remainder' n f a b) (nhds (EM_remainder n f a)) sequentially" proof (-) (*goal: ‹(λb::nat. EM_remainder' (n::nat) (f::real ⇒ 'b) (real_of_int (a::int)) (real b)) ⇢ EM_remainder n f a›*) have "uniform_limit {()} (λb s. EM_remainder' n f a b) (λs. EM_remainder n f a) sequentially" using assms (*‹real_of_int a ≤ ?y ⟹ (G has_real_derivative g ?y) (at ?y within {real_of_int a..})› ‹⟦real_of_int (a::int) ≤ (?a'::real); ?a' ≤ (?b::real)⟧ ⟹ (λt::real. pbernpoly (n::nat) t *⇩R (f::real ⇒ 'b::{banach,real_normed_algebra}) t) integrable_on {?a'..?b}› ‹convergent (λy. G (real y))› ‹∀⇩F x in at_top. norm (f x) ≤ g x›*) apply (intro uniform_limit_EM_remainder[where G = G and g = g] (*‹⟦⋀y::real. real_of_int (?a::int) ≤ y ⟹ ((G::real ⇒ real) has_real_derivative (g::real ⇒ real) y) (at y within {real_of_int ?a..}); ⋀(a'::real) (b::real) y::?'a. ⟦y ∈ (?A::?'a set); real_of_int ?a ≤ a'; a' ≤ b⟧ ⟹ (λt::real. pbernpoly (?n::nat) t *⇩R (?f::?'a ⇒ real ⇒ ?'b) y t) integrable_on {a'..b}; convergent (λy::nat. G (real y)); ∀⇩F x::real in at_top. ∀y::?'a∈?A. norm (?f y x) ≤ g x⟧ ⟹ uniform_limit ?A (λ(b::nat) s::?'a. EM_remainder' ?n (?f s) (real_of_int ?a) (real b)) (λs::?'a. EM_remainder ?n (?f s) ?a) sequentially›*)) (*goals: 1. ‹⋀y. ⟦⋀y. real_of_int a ≤ y ⟹ (G has_real_derivative g y) (at y within {real_of_int a..}); ⋀a' b. ⟦real_of_int a ≤ a'; a' ≤ b⟧ ⟹ (λt. pbernpoly n t *⇩R f t) integrable_on {a'..b}; convergent (λy. G (real y)); ∀⇩F x in at_top. norm (f x) ≤ g x; real_of_int a ≤ y⟧ ⟹ (G has_real_derivative g y) (at y within {real_of_int a..})› 2. ‹⋀a' b y. ⟦⋀y. real_of_int a ≤ y ⟹ (G has_real_derivative g y) (at y within {real_of_int a..}); ⋀a' b. ⟦real_of_int a ≤ a'; a' ≤ b⟧ ⟹ (λt. pbernpoly n t *⇩R f t) integrable_on {a'..b}; convergent (λy. G (real y)); ∀⇩F x in at_top. norm (f x) ≤ g x; y ∈ {()}; real_of_int a ≤ a'; a' ≤ b⟧ ⟹ (λt. pbernpoly n t *⇩R f t) integrable_on {a'..b}› 3. ‹⟦⋀y. real_of_int a ≤ y ⟹ (G has_real_derivative g y) (at y within {real_of_int a..}); ⋀a' b. ⟦real_of_int a ≤ a'; a' ≤ b⟧ ⟹ (λt. pbernpoly n t *⇩R f t) integrable_on {a'..b}; convergent (λy. G (real y)); ∀⇩F x in at_top. norm (f x) ≤ g x⟧ ⟹ convergent (λy. G (real y))› 4. ‹⟦⋀y. real_of_int a ≤ y ⟹ (G has_real_derivative g y) (at y within {real_of_int a..}); ⋀a' b. ⟦real_of_int a ≤ a'; a' ≤ b⟧ ⟹ (λt. pbernpoly n t *⇩R f t) integrable_on {a'..b}; convergent (λy. G (real y)); ∀⇩F x in at_top. norm (f x) ≤ g x⟧ ⟹ ∀⇩F x in at_top. ∀y∈{()}. norm (f x) ≤ g 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]) (*proven 4 subgoals*) . moreover have "() ∈ {()}" by simp ultimately show "?thesis" (*goal: ‹(λb. EM_remainder' n f (real_of_int a) (real b)) ⇢ EM_remainder n f a›*) by (rule tendsto_uniform_limitI (*‹⟦uniform_limit ?S ?f ?l ?F; ?x ∈ ?S⟧ ⟹ ((λy. ?f y ?x) ⤏ ?l ?x) ?F›*)) qed lemma EM_remainder_0 [simp]: "EM_remainder n (λx. 0) a = 0" apply (rule EM_remainder_eqI (*‹((λx. EM_remainder' ?n ?f (real_of_int ?b) (real_of_int x)) ⤏ ?L) at_top ⟹ EM_remainder ?n ?f ?b = ?L›*)) (*goal: ‹EM_remainder n (λx. 0) a = 0›*) by (simp add: EM_remainder'_def (*‹EM_remainder' ?n ?f ?a ?b = ((- 1) ^ Suc ?n / fact ?n) *⇩R integral {?a..?b} (λt. pbernpoly ?n t *⇩R ?f t)›*)) lemma holomorphic_EM_remainder': assumes deriv: "⋀z t. z ∈ U ⟹ t ∈ {a..x} ⟹ ((λz. f z t) has_field_derivative f' z t) (at z within U)" assumes int: "⋀b c z e. a ≤ b ⟹ c ≤ x ⟹ z ∈ U ⟹ (λt. of_real (bernpoly n (t - e)) * f z t) integrable_on {b..c}" assumes cont: "continuous_on (U × {a..x}) (λ(z, t). f' z t)" assumes "convex U" shows "(λs. EM_remainder' n (f s) a x) holomorphic_on U" unfolding EM_remainder'_def scaleR_conv_of_real (*goal: ‹(λs::complex. complex_of_real ((- (1::real)) ^ Suc (n::nat) / fact n) * integral {a::real..x::real} (λt::real. complex_of_real (pbernpoly n t) * (f::complex ⇒ real ⇒ complex) s t)) holomorphic_on (U::complex set)›*) proof (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 29 facts*)) (*goal: ‹(λz. integral {a..x} (λt. complex_of_real (pbernpoly n t) * f z t)) holomorphic_on U›*) have holo: "(λz. integral (cbox b c) (λt. of_real (bernpoly n (t - e)) * f z t)) holomorphic_on U" if "b ≥ a" "c ≤ x" for b :: real and c :: real and e :: real proof (rule leibniz_rule_holomorphic (*‹⟦⋀x t. ⟦x ∈ ?U; t ∈ cbox ?a ?b⟧ ⟹ ((λx. ?f x t) has_field_derivative ?fx x t) (at x within ?U); ⋀x. x ∈ ?U ⟹ ?f x integrable_on cbox ?a ?b; continuous_on (?U × cbox ?a ?b) (λ(x, t). ?fx x t); convex ?U⟧ ⟹ (λx. integral (cbox ?a ?b) (?f x)) holomorphic_on ?U›*)) (*goals: 1. ‹⋀z t. ⟦z ∈ U; t ∈ cbox b c⟧ ⟹ ((λz. complex_of_real (bernpoly n (t - e)) * f z t) has_field_derivative ?fx z t) (at z within U)› 2. ‹⋀z. z ∈ U ⟹ (λt. complex_of_real (bernpoly n (t - e)) * f z t) integrable_on cbox b c› 3. ‹continuous_on (U × cbox b c) (λ(z, t). ?fx z t)› 4. ‹convex U›*) fix z and t assume "z ∈ U" "t ∈ cbox b c" (*‹(z::complex) ∈ (U::complex set)› ‹(t::real) ∈ cbox (b::real) (c::real)›*) thus "((λz. complex_of_real (bernpoly n (t - e)) * f z t) has_field_derivative complex_of_real (bernpoly n (t - e)) * f' z t) (at z within U)" using that (*‹a ≤ b› ‹c ≤ x›*) apply (intro DERIV_cmult (*‹(?f has_field_derivative ?D) (at ?x within ?s) ⟹ ((λx. ?c * ?f x) has_field_derivative ?c * ?D) (at ?x within ?s)›*) deriv (*‹⟦?z ∈ U; ?t ∈ {a..x}⟧ ⟹ ((λz. f z ?t) has_field_derivative f' ?z ?t) (at ?z within U)›*)) (*goals: 1. ‹⟦(z::complex) ∈ (U::complex set); (t::real) ∈ cbox (b::real) (c::real); (a::real) ≤ b; c ≤ (x::real)⟧ ⟹ z ∈ U› 2. ‹⟦(z::complex) ∈ (U::complex set); (t::real) ∈ cbox (b::real) (c::real); (a::real) ≤ b; c ≤ (x::real)⟧ ⟹ t ∈ {a..x}› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . next (*goals: 1. ‹⋀z. z ∈ U ⟹ (λt. complex_of_real (bernpoly n (t - e)) * f z t) integrable_on cbox b c› 2. ‹continuous_on (U × cbox b c) (λ(z, t). complex_of_real (bernpoly n (t - e)) * f' z t)› 3. ‹convex U›*) fix z assume "z ∈ U" (*‹(z::complex) ∈ (U::complex set)›*) thus "(λt. complex_of_real (bernpoly n (t - e)) * f z t) integrable_on cbox b c" using that (*‹a ≤ b› ‹(c::real) ≤ (x::real)›*) int[of b c z] (*‹⟦(a::real) ≤ (b::real); (c::real) ≤ (x::real); (z::complex) ∈ (U::complex set)⟧ ⟹ (λt::real. complex_of_real (bernpoly (n::nat) (t - (?e::real))) * (f::complex ⇒ real ⇒ complex) z t) integrable_on {b..c}›*) by auto next (*goals: 1. ‹continuous_on (U × cbox b c) (λ(z, t). complex_of_real (bernpoly n (t - e)) * f' z t)› 2. ‹convex U›*) have "continuous_on (U × {b..c}) (λ(z, t). f' z t)" using cont (*‹continuous_on (U × {a..x}) (λ(z, t). f' z t)›*) apply (rule continuous_on_subset (*‹⟦continuous_on ?s ?f; ?t ⊆ ?s⟧ ⟹ continuous_on ?t ?f›*)) (*goal: ‹continuous_on ((U::complex set) × {b::real..c::real}) (λ(z::complex, t::real). (f'::complex ⇒ real ⇒ complex) z t)›*) apply (insert that (*‹a ≤ b› ‹c ≤ x›*)) (*goal: ‹U × {b..c} ⊆ U × {a..x}›*) by auto thus "continuous_on (U × cbox b c) (λ(z, t). complex_of_real (bernpoly n (t - e)) * f' z t)" by (auto simp: case_prod_unfold (*‹case_prod = (λc p. c (fst p) (snd p))›*) 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 272 facts*)) qed ((fact)+) (*solved the remaining goal: ‹convex U›*) consider "a > x" | "a ≤ x" and "floor x ≤ a" | "a ≤ x" and "floor x > a" (*goal: ‹⟦x < a ⟹ thesis; ⟦a ≤ x; real_of_int ⌊x⌋ ≤ a⟧ ⟹ thesis; ⟦a ≤ x; a < real_of_int ⌊x⌋⟧ ⟹ thesis⟧ ⟹ thesis›*) by force hence "(λz. integral (cbox a x) (λt. of_real (pbernpoly n t) * f z t)) holomorphic_on U" (is "?f a x holomorphic_on _") proof (cases) (*goals: 1. ‹x < a ⟹ (λz. integral (cbox a x) (λt. complex_of_real (pbernpoly n t) * f z t)) holomorphic_on U› 2. ‹⟦a ≤ x; real_of_int ⌊x⌋ ≤ a⟧ ⟹ (λz. integral (cbox a x) (λt. complex_of_real (pbernpoly n t) * f z t)) holomorphic_on U› 3. ‹⟦a ≤ x; a < real_of_int ⌊x⌋⟧ ⟹ (λz. integral (cbox a x) (λt. complex_of_real (pbernpoly n t) * f z t)) holomorphic_on U›*) case 2 (*‹a ≤ x› ‹real_of_int ⌊x⌋ ≤ a›*) have "(λz. integral (cbox a x) (λt. of_real (bernpoly n (t - of_int ⌊x⌋)) * f z t)) holomorphic_on U" apply (intro holo (*‹⟦a ≤ ?b; ?c ≤ x⟧ ⟹ (λz. integral (cbox ?b ?c) (λt. complex_of_real (bernpoly n (t - ?e)) * f z t)) holomorphic_on U›*)) (*goals: 1. ‹a ≤ a› 2. ‹x ≤ x› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . also (*calculation: ‹(λz. integral (cbox a x) (λt. complex_of_real (bernpoly n (t - real_of_int ⌊x⌋)) * f z t)) holomorphic_on U›*) have "(λz. integral (cbox a x) (λt. of_real (bernpoly n (t - of_int ⌊x⌋)) * f z t)) = ?f a x" apply (intro ext (*‹(⋀x::?'a. (?f::?'a ⇒ ?'b) x = (?g::?'a ⇒ ?'b) x) ⟹ ?f = ?g›*) integral_cong (*‹(⋀x::?'a. x ∈ (?s::?'a set) ⟹ (?f::?'a ⇒ ?'b) x = (?g::?'a ⇒ ?'b) x) ⟹ integral ?s ?f = integral ?s ?g›*)) (*goal: ‹(λz. integral (cbox a x) (λt. complex_of_real (bernpoly n (t - real_of_int ⌊x⌋)) * f z t)) = (λb. integral (cbox a x) (λt. complex_of_real (pbernpoly n t) * f b t))›*) proof (goal_cases) (*goal: ‹⋀(z::complex) xa::real. xa ∈ cbox (a::real) (x::real) ⟹ complex_of_real (bernpoly (n::nat) (xa - real_of_int ⌊x⌋)) * (f::complex ⇒ real ⇒ complex) z xa = complex_of_real (pbernpoly n xa) * f z xa›*) case (1 z t) (*‹t ∈ cbox a x›*) hence "t ≥ a" "t ≤ x" apply - (*goals: 1. ‹t ∈ cbox a x ⟹ a ≤ t› 2. ‹t ∈ cbox a x ⟹ t ≤ x› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . hence "floor t = floor x" using "2" (*‹(a::real) ≤ (x::real)› ‹real_of_int ⌊x::real⌋ ≤ (a::real)›*) by linarith thus "?case" (*goal: ‹complex_of_real (bernpoly n (t - real_of_int ⌊x⌋)) * f z t = complex_of_real (pbernpoly n t) * f z t›*) by (simp add: pbernpoly_def (*‹pbernpoly ?n ?x = bernpoly ?n (frac ?x)›*) frac_def (*‹frac ?x ≡ ?x - of_int ⌊?x⌋›*)) qed finally (*calculation: ‹(λz. integral (cbox a x) (λt. complex_of_real (pbernpoly n t) * f z t)) holomorphic_on U›*) show "?thesis" (*goal: ‹(λz. integral (cbox a x) (λt. complex_of_real (pbernpoly n t) * f z t)) holomorphic_on U›*) . next (*goals: 1. ‹x < a ⟹ (λz. integral (cbox a x) (λt. complex_of_real (pbernpoly n t) * f z t)) holomorphic_on U› 2. ‹⟦a ≤ x; a < real_of_int ⌊x⌋⟧ ⟹ (λz. integral (cbox a x) (λt. complex_of_real (pbernpoly n t) * f z t)) holomorphic_on U›*) case 3 (*‹a ≤ x› ‹a < real_of_int ⌊x⌋›*) define N :: "int set" where "N = {⌈a⌉..<⌊x⌋}" define A where "A = insert {a..of_int ⌈a⌉} (insert {of_int ⌊x⌋..x} ((λn. {of_int n..of_int n + 1}) ` N))" { fix X assume "X ∈ A" (*‹(X::real set) ∈ (A::real set set)›*) then consider "X = {a..of_int ⌈a⌉}" | "X = {of_int ⌊x⌋..x}" | n where "X = {of_int n..of_int n + 1}" and "n ∈ N" (*goal: ‹⟦X = {a..real_of_int ⌈a⌉} ⟹ thesis; X = {real_of_int ⌊x⌋..x} ⟹ thesis; ⋀n. ⟦X = {real_of_int n..real_of_int n + 1}; n ∈ N⟧ ⟹ thesis⟧ ⟹ thesis›*) by (auto simp: A_def (*‹A = insert {a..real_of_int ⌈a⌉} (insert {real_of_int ⌊x⌋..x} ((λn. {real_of_int n..real_of_int n + 1}) ` N))›*)) } note A_cases = this (*‹⟦?X5 ∈ A; ?X5 = {a..real_of_int ⌈a⌉} ⟹ ?thesis2; ?X5 = {real_of_int ⌊x⌋..x} ⟹ ?thesis2; ⋀n. ⟦?X5 = {real_of_int n..real_of_int n + 1}; n ∈ N⟧ ⟹ ?thesis2⟧ ⟹ ?thesis2›*) have division: "A division_of {a..x}" proof (rule division_ofI (*‹⟦finite ?s; ⋀K. K ∈ ?s ⟹ K ⊆ ?i; ⋀K. K ∈ ?s ⟹ K ≠ {}; ⋀K. K ∈ ?s ⟹ ∃a b. K = cbox a b; ⋀K1 K2. ⟦K1 ∈ ?s; K2 ∈ ?s; K1 ≠ K2⟧ ⟹ interior K1 ∩ interior K2 = {}; ⋃ ?s = ?i⟧ ⟹ ?s division_of ?i›*)) (*goals: 1. ‹finite A› 2. ‹⋀K. K ∈ A ⟹ K ⊆ {a..x}› 3. ‹⋀K. K ∈ A ⟹ K ≠ {}› 4. ‹⋀K. K ∈ A ⟹ ∃a b. K = cbox a b› 5. ‹⋀K1 K2. ⟦K1 ∈ A; K2 ∈ A; K1 ≠ K2⟧ ⟹ interior K1 ∩ interior K2 = {}› 6. ‹⋃ A = {a..x}›*) show "finite A" by (auto simp: A_def (*‹A = insert {a..real_of_int ⌈a⌉} (insert {real_of_int ⌊x⌋..x} ((λn. {real_of_int n..real_of_int n + 1}) ` N))›*) N_def (*‹N = {⌈a⌉..<⌊x⌋}›*)) fix K assume K: "K ∈ A" (*‹(K::real set) ∈ (A::real set set)›*) from "3" (*‹a ≤ x› ‹a < real_of_int ⌊x⌋›*) have "of_int ⌈a⌉ ≤ x" using ceiling_le[of a "floor x"] (*‹a ≤ real_of_int ⌊x⌋ ⟹ ⌈a⌉ ≤ ⌊x⌋›*) by linarith moreover from "3" (*‹a ≤ x› ‹a < real_of_int ⌊x⌋›*) have "of_int ⌊x⌋ ≥ a" by linarith ultimately show "K ⊆ {a..x}" using K (*‹K ∈ A›*) "3" (*‹a ≤ x› ‹a < real_of_int ⌊x⌋›*) apply (auto simp: A_def (*‹(A::real set set) = insert {a::real..real_of_int ⌈a⌉} (insert {real_of_int ⌊x::real⌋..x} ((λn::int. {real_of_int n..real_of_int n + (1::real)}) ` (N::int set)))›*) N_def (*‹(N::int set) = {⌈a::real⌉..<⌊x::real⌋}›*)) (*goals: 1. ‹⋀xa xaa. ⟦real_of_int ⌈a⌉ ≤ x; a ≤ x; a < real_of_int ⌊x⌋; K = {real_of_int xaa..real_of_int xaa + 1}; real_of_int xaa ≤ xa; xa ≤ real_of_int xaa + 1; ⌈a⌉ ≤ xaa; xaa < ⌊x⌋⟧ ⟹ a ≤ xa› 2. ‹⋀xa xaa. ⟦real_of_int ⌈a⌉ ≤ x; a ≤ x; a < real_of_int ⌊x⌋; K = {real_of_int xaa..real_of_int xaa + 1}; real_of_int xaa ≤ xa; xa ≤ real_of_int xaa + 1; ⌈a⌉ ≤ xaa; xaa < ⌊x⌋⟧ ⟹ xa ≤ x› discuss goal 1*) apply linarith (*discuss goal 2*) apply linarith (*proven 2 subgoals*) . from K (*‹K ∈ A›*) show "K ≠ {}" and "∃a b. K = cbox a b" apply - (*goals: 1. ‹K ∈ A ⟹ K ≠ {}› 2. ‹K ∈ A ⟹ ∃a b. K = cbox a b› discuss goal 1*) apply ((auto simp: A_def (*‹(A::real set set) = insert {a::real..real_of_int ⌈a⌉} (insert {real_of_int ⌊x::real⌋..x} ((λn::int. {real_of_int n..real_of_int n + (1::real)}) ` (N::int set)))›*))[1]) (*discuss goal 2*) apply ((auto simp: A_def (*‹(A::real set set) = insert {a::real..real_of_int ⌈a⌉} (insert {real_of_int ⌊x::real⌋..x} ((λn::int. {real_of_int n..real_of_int n + (1::real)}) ` (N::int set)))›*))[1]) (*proven 2 subgoals*) . next (*goals: 1. ‹⋀K1 K2. ⟦K1 ∈ A; K2 ∈ A; K1 ≠ K2⟧ ⟹ interior K1 ∩ interior K2 = {}› 2. ‹⋃ A = {a..x}›*) fix K1 and K2 assume K: "K1 ∈ A" "K2 ∈ A" "K1 ≠ K2" (*‹(K1::real set) ∈ (A::real set set)› ‹(K2::real set) ∈ (A::real set set)› ‹(K1::real set) ≠ (K2::real set)›*) have F1: "interior {a..⌈a⌉} ∩ interior {⌊x⌋..x} = {}" using "3" (*‹(a::real) ≤ (x::real)› ‹a < real_of_int ⌊x⌋›*) ceiling_le[of a "floor x"] (*‹a ≤ real_of_int ⌊x⌋ ⟹ ⌈a⌉ ≤ ⌊x⌋›*) by (auto simp: min_def (*‹min ?a ?b = (if ?a ≤ ?b then ?a else ?b)›*) max_def (*‹max ?a ?b = (if ?a ≤ ?b then ?b else ?a)›*)) hence F2: "interior {⌊x⌋..x} ∩ interior {a..⌈a⌉} = {}" by simp have F3: "interior {a..⌈a⌉} ∩ interior {of_int n..of_int n+1} = {}" "interior {⌊x⌋..x} ∩ interior {of_int n..of_int n+1} = {}" "interior {of_int n..of_int n+1} ∩ interior {a..⌈a⌉} = {}" "interior {of_int n..of_int n+1} ∩ interior {⌊x⌋..x} = {}" if "n ∈ N" for n using "3" (*‹a ≤ x› ‹a < real_of_int ⌊x⌋›*) ceiling_le[of a "floor x"] (*‹a ≤ real_of_int ⌊x⌋ ⟹ ⌈a⌉ ≤ ⌊x⌋›*) that (*‹(n::int) ∈ (N::int set)›*) apply - (*goals: 1. ‹⟦(a::real) ≤ (x::real); a < real_of_int ⌊x⌋; a ≤ real_of_int ⌊x⌋ ⟹ ⌈a⌉ ≤ ⌊x⌋; (n::int) ∈ (N::int set)⟧ ⟹ interior {a..real_of_int ⌈a⌉} ∩ interior {real_of_int n..real_of_int n + (1::real)} = {}› 2. ‹⟦(a::real) ≤ (x::real); a < real_of_int ⌊x⌋; a ≤ real_of_int ⌊x⌋ ⟹ ⌈a⌉ ≤ ⌊x⌋; (n::int) ∈ (N::int set)⟧ ⟹ interior {real_of_int ⌊x⌋..x} ∩ interior {real_of_int n..real_of_int n + (1::real)} = {}› 3. ‹⟦(a::real) ≤ (x::real); a < real_of_int ⌊x⌋; a ≤ real_of_int ⌊x⌋ ⟹ ⌈a⌉ ≤ ⌊x⌋; (n::int) ∈ (N::int set)⟧ ⟹ interior {real_of_int n..real_of_int n + (1::real)} ∩ interior {a..real_of_int ⌈a⌉} = {}› 4. ‹⟦(a::real) ≤ (x::real); a < real_of_int ⌊x⌋; a ≤ real_of_int ⌊x⌋ ⟹ ⌈a⌉ ≤ ⌊x⌋; (n::int) ∈ (N::int set)⟧ ⟹ interior {real_of_int n..real_of_int n + (1::real)} ∩ interior {real_of_int ⌊x⌋..x} = {}› discuss goal 1*) apply ((auto simp: min_def (*‹min ?a ?b = (if ?a ≤ ?b then ?a else ?b)›*) max_def (*‹max ?a ?b = (if ?a ≤ ?b then ?b else ?a)›*) N_def (*‹N = {⌈a⌉..<⌊x⌋}›*))[1]) (*discuss goal 2*) apply ((auto simp: min_def (*‹min ?a ?b = (if ?a ≤ ?b then ?a else ?b)›*) max_def (*‹max ?a ?b = (if ?a ≤ ?b then ?b else ?a)›*) N_def (*‹N = {⌈a⌉..<⌊x⌋}›*))[1]) (*discuss goal 3*) apply ((auto simp: min_def (*‹min ?a ?b = (if ?a ≤ ?b then ?a else ?b)›*) max_def (*‹max ?a ?b = (if ?a ≤ ?b then ?b else ?a)›*) N_def (*‹N = {⌈a⌉..<⌊x⌋}›*))[1]) (*discuss goal 4*) apply ((auto simp: 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)›*) N_def (*‹(N::int set) = {⌈a::real⌉..<⌊x::real⌋}›*))[1]) (*proven 4 subgoals*) . have F4: "interior {real_of_int n..of_int n+1} ∩ interior {of_int m..of_int m+1} = {}" if "{real_of_int n..of_int n+1} ≠ {of_int m..of_int m+1}" for m and n proof (-) (*goal: ‹interior {real_of_int n..real_of_int n + 1} ∩ interior {real_of_int m..real_of_int m + 1} = {}›*) from that (*‹{real_of_int (n::int)..real_of_int n + (1::real)} ≠ {real_of_int (m::int)..real_of_int m + (1::real)}›*) have "n ≠ m" by auto thus "?thesis" (*goal: ‹interior {real_of_int n..real_of_int n + 1} ∩ interior {real_of_int m..real_of_int m + 1} = {}›*) by simp qed from F1 (*‹interior {a..real_of_int ⌈a⌉} ∩ interior {real_of_int ⌊x⌋..x} = {}›*) F2 (*‹interior {real_of_int ⌊x⌋..x} ∩ interior {a..real_of_int ⌈a⌉} = {}›*) F3 (*‹?n ∈ N ⟹ interior {a..real_of_int ⌈a⌉} ∩ interior {real_of_int ?n..real_of_int ?n + 1} = {}› ‹?n ∈ N ⟹ interior {real_of_int ⌊x⌋..x} ∩ interior {real_of_int ?n..real_of_int ?n + 1} = {}› ‹?n ∈ N ⟹ interior {real_of_int ?n..real_of_int ?n + 1} ∩ interior {a..real_of_int ⌈a⌉} = {}› ‹(?n::int) ∈ (N::int set) ⟹ interior {real_of_int ?n..real_of_int ?n + (1::real)} ∩ interior {real_of_int ⌊x::real⌋..x} = {}›*) F4 (*‹{real_of_int ?n..real_of_int ?n + 1} ≠ {real_of_int ?m..real_of_int ?m + 1} ⟹ interior {real_of_int ?n..real_of_int ?n + 1} ∩ interior {real_of_int ?m..real_of_int ?m + 1} = {}›*) K (*‹K1 ∈ A› ‹K2 ∈ A› ‹(K1::real set) ≠ (K2::real set)›*) show "interior K1 ∩ interior K2 = {}" apply (elim A_cases (*‹⟦?X5 ∈ A; ?X5 = {a..real_of_int ⌈a⌉} ⟹ ?thesis2; ?X5 = {real_of_int ⌊x⌋..x} ⟹ ?thesis2; ⋀n. ⟦?X5 = {real_of_int n..real_of_int n + 1}; n ∈ N⟧ ⟹ ?thesis2⟧ ⟹ ?thesis2›*)) (*goals: 1. ‹⟦interior {a..real_of_int ⌈a⌉} ∩ interior {real_of_int ⌊x⌋..x} = {}; interior {real_of_int ⌊x⌋..x} ∩ interior {a..real_of_int ⌈a⌉} = {}; ⋀n. n ∈ N ⟹ interior {a..real_of_int ⌈a⌉} ∩ interior {real_of_int n..real_of_int n + 1} = {}; ⋀n. n ∈ N ⟹ interior {real_of_int ⌊x⌋..x} ∩ interior {real_of_int n..real_of_int n + 1} = {}; ⋀n. n ∈ N ⟹ interior {real_of_int n..real_of_int n + 1} ∩ interior {a..real_of_int ⌈a⌉} = {}; ⋀n. n ∈ N ⟹ interior {real_of_int n..real_of_int n + 1} ∩ interior {real_of_int ⌊x⌋..x} = {}; ⋀n m. {real_of_int n..real_of_int n + 1} ≠ {real_of_int m..real_of_int m + 1} ⟹ interior {real_of_int n..real_of_int n + 1} ∩ interior {real_of_int m..real_of_int m + 1} = {}; K1 ≠ K2; K1 = {a..real_of_int ⌈a⌉}; K2 = {a..real_of_int ⌈a⌉}⟧ ⟹ interior K1 ∩ interior K2 = {}› 2. ‹⟦interior {a..real_of_int ⌈a⌉} ∩ interior {real_of_int ⌊x⌋..x} = {}; interior {real_of_int ⌊x⌋..x} ∩ interior {a..real_of_int ⌈a⌉} = {}; ⋀n. n ∈ N ⟹ interior {a..real_of_int ⌈a⌉} ∩ interior {real_of_int n..real_of_int n + 1} = {}; ⋀n. n ∈ N ⟹ interior {real_of_int ⌊x⌋..x} ∩ interior {real_of_int n..real_of_int n + 1} = {}; ⋀n. n ∈ N ⟹ interior {real_of_int n..real_of_int n + 1} ∩ interior {a..real_of_int ⌈a⌉} = {}; ⋀n. n ∈ N ⟹ interior {real_of_int n..real_of_int n + 1} ∩ interior {real_of_int ⌊x⌋..x} = {}; ⋀n m. {real_of_int n..real_of_int n + 1} ≠ {real_of_int m..real_of_int m + 1} ⟹ interior {real_of_int n..real_of_int n + 1} ∩ interior {real_of_int m..real_of_int m + 1} = {}; K1 ≠ K2; K1 = {a..real_of_int ⌈a⌉}; K2 = {real_of_int ⌊x⌋..x}⟧ ⟹ interior K1 ∩ interior K2 = {}› 3. ‹⋀n. ⟦interior {a..real_of_int ⌈a⌉} ∩ interior {real_of_int ⌊x⌋..x} = {}; interior {real_of_int ⌊x⌋..x} ∩ interior {a..real_of_int ⌈a⌉} = {}; ⋀n. n ∈ N ⟹ interior {a..real_of_int ⌈a⌉} ∩ interior {real_of_int n..real_of_int n + 1} = {}; ⋀n. n ∈ N ⟹ interior {real_of_int ⌊x⌋..x} ∩ interior {real_of_int n..real_of_int n + 1} = {}; ⋀n. n ∈ N ⟹ interior {real_of_int n..real_of_int n + 1} ∩ interior {a..real_of_int ⌈a⌉} = {}; ⋀n. n ∈ N ⟹ interior {real_of_int n..real_of_int n + 1} ∩ interior {real_of_int ⌊x⌋..x} = {}; ⋀n m. {real_of_int n..real_of_int n + 1} ≠ {real_of_int m..real_of_int m + 1} ⟹ interior {real_of_int n..real_of_int n + 1} ∩ interior {real_of_int m..real_of_int m + 1} = {}; K1 ≠ K2; K1 = {a..real_of_int ⌈a⌉}; K2 = {real_of_int n..real_of_int n + 1}; n ∈ N⟧ ⟹ interior K1 ∩ interior K2 = {}› 4. ‹⟦interior {a..real_of_int ⌈a⌉} ∩ interior {real_of_int ⌊x⌋..x} = {}; interior {real_of_int ⌊x⌋..x} ∩ interior {a..real_of_int ⌈a⌉} = {}; ⋀n. n ∈ N ⟹ interior {a..real_of_int ⌈a⌉} ∩ interior {real_of_int n..real_of_int n + 1} = {}; ⋀n. n ∈ N ⟹ interior {real_of_int ⌊x⌋..x} ∩ interior {real_of_int n..real_of_int n + 1} = {}; ⋀n. n ∈ N ⟹ interior {real_of_int n..real_of_int n + 1} ∩ interior {a..real_of_int ⌈a⌉} = {}; ⋀n. n ∈ N ⟹ interior {real_of_int n..real_of_int n + 1} ∩ interior {real_of_int ⌊x⌋..x} = {}; ⋀n m. {real_of_int n..real_of_int n + 1} ≠ {real_of_int m..real_of_int m + 1} ⟹ interior {real_of_int n..real_of_int n + 1} ∩ interior {real_of_int m..real_of_int m + 1} = {}; K1 ≠ K2; K1 = {real_of_int ⌊x⌋..x}; K2 = {a..real_of_int ⌈a⌉}⟧ ⟹ interior K1 ∩ interior K2 = {}› 5. ‹⟦interior {a..real_of_int ⌈a⌉} ∩ interior {real_of_int ⌊x⌋..x} = {}; interior {real_of_int ⌊x⌋..x} ∩ interior {a..real_of_int ⌈a⌉} = {}; ⋀n. n ∈ N ⟹ interior {a..real_of_int ⌈a⌉} ∩ interior {real_of_int n..real_of_int n + 1} = {}; ⋀n. n ∈ N ⟹ interior {real_of_int ⌊x⌋..x} ∩ interior {real_of_int n..real_of_int n + 1} = {}; ⋀n. n ∈ N ⟹ interior {real_of_int n..real_of_int n + 1} ∩ interior {a..real_of_int ⌈a⌉} = {}; ⋀n. n ∈ N ⟹ interior {real_of_int n..real_of_int n + 1} ∩ interior {real_of_int ⌊x⌋..x} = {}; ⋀n m. {real_of_int n..real_of_int n + 1} ≠ {real_of_int m..real_of_int m + 1} ⟹ interior {real_of_int n..real_of_int n + 1} ∩ interior {real_of_int m..real_of_int m + 1} = {}; K1 ≠ K2; K1 = {real_of_int ⌊x⌋..x}; K2 = {real_of_int ⌊x⌋..x}⟧ ⟹ interior K1 ∩ interior K2 = {}› 6. ‹⋀n. ⟦interior {a..real_of_int ⌈a⌉} ∩ interior {real_of_int ⌊x⌋..x} = {}; interior {real_of_int ⌊x⌋..x} ∩ interior {a..real_of_int ⌈a⌉} = {}; ⋀n. n ∈ N ⟹ interior {a..real_of_int ⌈a⌉} ∩ interior {real_of_int n..real_of_int n + 1} = {}; ⋀n. n ∈ N ⟹ interior {real_of_int ⌊x⌋..x} ∩ interior {real_of_int n..real_of_int n + 1} = {}; ⋀n. n ∈ N ⟹ interior {real_of_int n..real_of_int n + 1} ∩ interior {a..real_of_int ⌈a⌉} = {}; ⋀n. n ∈ N ⟹ interior {real_of_int n..real_of_int n + 1} ∩ interior {real_of_int ⌊x⌋..x} = {}; ⋀n m. {real_of_int n..real_of_int n + 1} ≠ {real_of_int m..real_of_int m + 1} ⟹ interior {real_of_int n..real_of_int n + 1} ∩ interior {real_of_int m..real_of_int m + 1} = {}; K1 ≠ K2; K1 = {real_of_int ⌊x⌋..x}; K2 = {real_of_int n..real_of_int n + 1}; n ∈ N⟧ ⟹ interior K1 ∩ interior K2 = {}› 7. ‹⋀n. ⟦interior {a..real_of_int ⌈a⌉} ∩ interior {real_of_int ⌊x⌋..x} = {}; interior {real_of_int ⌊x⌋..x} ∩ interior {a..real_of_int ⌈a⌉} = {}; ⋀n. n ∈ N ⟹ interior {a..real_of_int ⌈a⌉} ∩ interior {real_of_int n..real_of_int n + 1} = {}; ⋀n. n ∈ N ⟹ interior {real_of_int ⌊x⌋..x} ∩ interior {real_of_int n..real_of_int n + 1} = {}; ⋀n. n ∈ N ⟹ interior {real_of_int n..real_of_int n + 1} ∩ interior {a..real_of_int ⌈a⌉} = {}; ⋀n. n ∈ N ⟹ interior {real_of_int n..real_of_int n + 1} ∩ interior {real_of_int ⌊x⌋..x} = {}; ⋀n m. {real_of_int n..real_of_int n + 1} ≠ {real_of_int m..real_of_int m + 1} ⟹ interior {real_of_int n..real_of_int n + 1} ∩ interior {real_of_int m..real_of_int m + 1} = {}; K1 ≠ K2; K1 = {real_of_int n..real_of_int n + 1}; n ∈ N; K2 = {a..real_of_int ⌈a⌉}⟧ ⟹ interior K1 ∩ interior K2 = {}› 8. ‹⋀n. ⟦interior {a..real_of_int ⌈a⌉} ∩ interior {real_of_int ⌊x⌋..x} = {}; interior {real_of_int ⌊x⌋..x} ∩ interior {a..real_of_int ⌈a⌉} = {}; ⋀n. n ∈ N ⟹ interior {a..real_of_int ⌈a⌉} ∩ interior {real_of_int n..real_of_int n + 1} = {}; ⋀n. n ∈ N ⟹ interior {real_of_int ⌊x⌋..x} ∩ interior {real_of_int n..real_of_int n + 1} = {}; ⋀n. n ∈ N ⟹ interior {real_of_int n..real_of_int n + 1} ∩ interior {a..real_of_int ⌈a⌉} = {}; ⋀n. n ∈ N ⟹ interior {real_of_int n..real_of_int n + 1} ∩ interior {real_of_int ⌊x⌋..x} = {}; ⋀n m. {real_of_int n..real_of_int n + 1} ≠ {real_of_int m..real_of_int m + 1} ⟹ interior {real_of_int n..real_of_int n + 1} ∩ interior {real_of_int m..real_of_int m + 1} = {}; K1 ≠ K2; K1 = {real_of_int n..real_of_int n + 1}; n ∈ N; K2 = {real_of_int ⌊x⌋..x}⟧ ⟹ interior K1 ∩ interior K2 = {}› 9. ‹⋀n na. ⟦interior {a..real_of_int ⌈a⌉} ∩ interior {real_of_int ⌊x⌋..x} = {}; interior {real_of_int ⌊x⌋..x} ∩ interior {a..real_of_int ⌈a⌉} = {}; ⋀n. n ∈ N ⟹ interior {a..real_of_int ⌈a⌉} ∩ interior {real_of_int n..real_of_int n + 1} = {}; ⋀n. n ∈ N ⟹ interior {real_of_int ⌊x⌋..x} ∩ interior {real_of_int n..real_of_int n + 1} = {}; ⋀n. n ∈ N ⟹ interior {real_of_int n..real_of_int n + 1} ∩ interior {a..real_of_int ⌈a⌉} = {}; ⋀n. n ∈ N ⟹ interior {real_of_int n..real_of_int n + 1} ∩ interior {real_of_int ⌊x⌋..x} = {}; ⋀n m. {real_of_int n..real_of_int n + 1} ≠ {real_of_int m..real_of_int m + 1} ⟹ interior {real_of_int n..real_of_int n + 1} ∩ interior {real_of_int m..real_of_int m + 1} = {}; K1 ≠ K2; K1 = {real_of_int n..real_of_int n + 1}; n ∈ N; K2 = {real_of_int na..real_of_int na + 1}; na ∈ N⟧ ⟹ interior K1 ∩ interior K2 = {}› discuss goal 1*) apply (simp only: not_False_eq_True (*‹(¬ False) = True›*)) (*discuss goal 2*) apply (simp only: not_False_eq_True (*‹(¬ False) = True›*)) (*discuss goal 3*) apply (simp only: not_False_eq_True (*‹(¬ False) = True›*)) (*discuss goal 4*) apply (simp only: not_False_eq_True (*‹(¬ False) = True›*)) (*discuss goal 5*) apply (simp only: not_False_eq_True (*‹(¬ False) = True›*)) (*discuss goal 6*) apply (simp only: not_False_eq_True (*‹(¬ False) = True›*)) (*discuss goal 7*) apply (simp only: not_False_eq_True (*‹(¬ False) = True›*)) (*discuss goal 8*) apply (simp only: not_False_eq_True (*‹(¬ False) = True›*)) (*discuss goal 9*) apply (simp only: not_False_eq_True (*‹(¬ False) = True›*)) (*proven 9 subgoals*) . next (*goal: ‹⋃ (A::real set set) = {a::real..x::real}›*) show "⋃A = {a..x}" proof (cases "⌈a⌉ = ⌊x⌋") (*goals: 1. ‹⌈a⌉ = ⌊x⌋ ⟹ ⋃ A = {a..x}› 2. ‹⌈a⌉ ≠ ⌊x⌋ ⟹ ⋃ A = {a..x}›*) case True (*‹⌈a::real⌉ = ⌊x::real⌋›*) thus "?thesis" (*goal: ‹⋃ A = {a..x}›*) using "3" (*‹a ≤ x› ‹a < real_of_int ⌊x⌋›*) apply (auto simp: A_def (*‹A = insert {a..real_of_int ⌈a⌉} (insert {real_of_int ⌊x⌋..x} ((λn. {real_of_int n..real_of_int n + 1}) ` N))›*) N_def (*‹N = {⌈a⌉..<⌊x⌋}›*) intro: order.trans (*‹⟦?a ≤ ?b; ?b ≤ ?c⟧ ⟹ ?a ≤ ?c›*)) (*goal: ‹⋃ A = {a..x}›*) by linarith next (*goal: ‹⌈a⌉ ≠ ⌊x⌋ ⟹ ⋃ A = {a..x}›*) case False (*‹⌈a⌉ ≠ ⌊x⌋›*) with "3" (*‹a ≤ x› ‹a < real_of_int ⌊x⌋›*) have "*": "⌈a⌉ < ⌊x⌋" by linarith have "⋃A = {a..of_int ⌈a⌉} ∪ (⋃n∈N. {of_int n..of_int (n + 1)}) ∪ {of_int ⌊x⌋..x}" by (simp add: A_def (*‹A = insert {a..real_of_int ⌈a⌉} (insert {real_of_int ⌊x⌋..x} ((λn. {real_of_int n..real_of_int n + 1}) ` N))›*) Un_ac (*‹?A ∪ ?B ∪ ?C = ?A ∪ (?B ∪ ?C)› ‹?A ∪ (?A ∪ ?B) = ?A ∪ ?B› ‹?A ∪ ?B = ?B ∪ ?A› ‹?A ∪ (?B ∪ ?C) = ?B ∪ (?A ∪ ?C)›*)) also (*calculation: ‹⋃ A = {a..real_of_int ⌈a⌉} ∪ (⋃n∈N. {real_of_int n..real_of_int (n + 1)}) ∪ {real_of_int ⌊x⌋..x}›*) have "(⋃n∈N. {of_int n..of_int (n + 1)}) = {of_int ⌈a⌉..real_of_int ⌊x⌋}" using "*" (*‹⌈a⌉ < ⌊x⌋›*) unfolding N_def (*goal: ‹(⋃n∈{⌈a⌉..<⌊x⌋}. {real_of_int n..real_of_int (n + 1)}) = {real_of_int ⌈a⌉..real_of_int ⌊x⌋}›*) by (intro Union_atLeastAtMost_real_of_int (*‹?a < ?b ⟹ (⋃n∈{?a..<?b}. {real_of_int n..real_of_int (n + 1)}) = {real_of_int ?a..real_of_int ?b}›*)) also (*calculation: ‹⋃ A = {a..real_of_int ⌈a⌉} ∪ {real_of_int ⌈a⌉..real_of_int ⌊x⌋} ∪ {real_of_int ⌊x⌋..x}›*) have "{a..of_int ⌈a⌉} ∪ … = {a..real_of_int ⌊x⌋}" using "3" (*‹a ≤ x› ‹a < real_of_int ⌊x⌋›*) "*" (*‹⌈a⌉ < ⌊x⌋›*) apply (intro ivl_disj_un (*‹{?l::?'a} ∪ {?l<..} = {?l..}› ‹{..<?u::?'a} ∪ {?u} = {..?u}› ‹(?l::?'a) < (?u::?'a) ⟹ {?l} ∪ {?l<..<?u} = {?l..<?u}› ‹(?l::?'a) < (?u::?'a) ⟹ {?l<..<?u} ∪ {?u} = {?l<..?u}› ‹(?l::?'a) ≤ (?u::?'a) ⟹ {?l} ∪ {?l<..?u} = {?l..?u}› ‹(?l::?'a) ≤ (?u::?'a) ⟹ {?l..<?u} ∪ {?u} = {?l..?u}› ‹(?l::?'a) < (?u::?'a) ⟹ {..?l} ∪ {?l<..<?u} = {..<?u}› ‹(?l::?'a) ≤ (?u::?'a) ⟹ {..<?l} ∪ {?l..<?u} = {..<?u}› ‹(?l::?'a) ≤ (?u::?'a) ⟹ {..?l} ∪ {?l<..?u} = {..?u}› ‹(?l::?'a) ≤ (?u::?'a) ⟹ {..<?l} ∪ {?l..?u} = {..?u}› ‹(?l::?'a) ≤ (?u::?'a) ⟹ {?l<..?u} ∪ {?u<..} = {?l<..}› ‹(?l::?'a) < (?u::?'a) ⟹ {?l<..<?u} ∪ {?u..} = {?l<..}› and more 14 facts*)) (*goals: 1. ‹⟦(a::real) ≤ (x::real); a < real_of_int ⌊x⌋; ⌈a⌉ < ⌊x⌋⟧ ⟹ a ≤ real_of_int ⌈a⌉› 2. ‹⟦(a::real) ≤ (x::real); a < real_of_int ⌊x⌋; ⌈a⌉ < ⌊x⌋⟧ ⟹ real_of_int ⌈a⌉ ≤ real_of_int ⌊x⌋› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . also (*calculation: ‹⋃ (A::real set set) = {a::real..real_of_int ⌊x::real⌋} ∪ {real_of_int ⌊x⌋..x}›*) have "… ∪ {of_int ⌊x⌋..x} = {a..x}" using "3" (*‹a ≤ x› ‹(a::real) < real_of_int ⌊x::real⌋›*) "*" (*‹⌈a⌉ < ⌊x⌋›*) apply (intro ivl_disj_un (*‹{?l::?'a::linorder} ∪ {?l<..} = {?l..}› ‹{..<?u::?'a::linorder} ∪ {?u} = {..?u}› ‹(?l::?'a::linorder) < (?u::?'a::linorder) ⟹ {?l} ∪ {?l<..<?u} = {?l..<?u}› ‹(?l::?'a::linorder) < (?u::?'a::linorder) ⟹ {?l<..<?u} ∪ {?u} = {?l<..?u}› ‹(?l::?'a::linorder) ≤ (?u::?'a::linorder) ⟹ {?l} ∪ {?l<..?u} = {?l..?u}› ‹(?l::?'a::linorder) ≤ (?u::?'a::linorder) ⟹ {?l..<?u} ∪ {?u} = {?l..?u}› ‹(?l::?'a::linorder) < (?u::?'a::linorder) ⟹ {..?l} ∪ {?l<..<?u} = {..<?u}› ‹(?l::?'a::linorder) ≤ (?u::?'a::linorder) ⟹ {..<?l} ∪ {?l..<?u} = {..<?u}› ‹(?l::?'a::linorder) ≤ (?u::?'a::linorder) ⟹ {..?l} ∪ {?l<..?u} = {..?u}› ‹(?l::?'a::linorder) ≤ (?u::?'a::linorder) ⟹ {..<?l} ∪ {?l..?u} = {..?u}› ‹(?l::?'a::linorder) ≤ (?u::?'a::linorder) ⟹ {?l<..?u} ∪ {?u<..} = {?l<..}› ‹(?l::?'a::linorder) < (?u::?'a::linorder) ⟹ {?l<..<?u} ∪ {?u..} = {?l<..}› and more 14 facts*)) (*goals: 1. ‹⟦(a::real) ≤ (x::real); a < real_of_int ⌊x⌋; ⌈a⌉ < ⌊x⌋⟧ ⟹ a ≤ real_of_int ⌊x⌋› 2. ‹⟦(a::real) ≤ (x::real); a < real_of_int ⌊x⌋; ⌈a⌉ < ⌊x⌋⟧ ⟹ real_of_int ⌊x⌋ ≤ x› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . finally (*calculation: ‹⋃ A = {a..x}›*) show "?thesis" (*goal: ‹⋃ (A::real set set) = {a::real..x::real}›*) . qed qed have "(λz. ∑X∈A. integral X (λt. of_real (bernpoly n (t - ⌊Inf X⌋)) * f z t)) holomorphic_on U" apply (intro holomorphic_on_sum (*‹(⋀i. i ∈ ?I ⟹ ?f i holomorphic_on ?A) ⟹ (λx. ∑i∈?I. ?f i x) holomorphic_on ?A›*) holo (*‹⟦a ≤ ?b; ?c ≤ x⟧ ⟹ (λz. integral (cbox ?b ?c) (λt. complex_of_real (bernpoly n (t - ?e)) * f z t)) holomorphic_on U›*)) (*goal: ‹(λz. ∑X∈A. integral X (λt. complex_of_real (bernpoly n (t - real_of_int ⌊Inf X⌋)) * f z t)) holomorphic_on U›*) proof (goal_cases) (*goal: ‹⋀X. X ∈ A ⟹ (λx. integral X (λt. complex_of_real (bernpoly n (t - real_of_int ⌊Inf X⌋)) * f x t)) holomorphic_on U›*) case (1 X) (*‹X ∈ A›*) from "1" (*‹X ∈ A›*) division (*‹(A::real set set) division_of {a::real..x::real}›*) have subset: "X ⊆ {a..x}" by (auto simp: division_of_def (*‹(?s division_of ?i) = (finite ?s ∧ (∀K∈?s. K ⊆ ?i ∧ K ≠ {} ∧ (∃a b. K = cbox a b)) ∧ (∀K1∈?s. ∀K2∈?s. K1 ≠ K2 ⟶ interior K1 ∩ interior K2 = {}) ∧ ⋃ ?s = ?i)›*)) from "1" (*‹X ∈ A›*) obtain b and c where [simp]: "X = cbox b c" "b ≤ c" (*goal: ‹(⋀b c. ⟦X = cbox b c; b ≤ c⟧ ⟹ thesis) ⟹ thesis›*) by (auto simp: A_def (*‹A = insert {a..real_of_int ⌈a⌉} (insert {real_of_int ⌊x⌋..x} ((λn. {real_of_int n..real_of_int n + 1}) ` N))›*)) from subset (*‹X ⊆ {a..x}›*) have "b ≥ a" "c ≤ x" apply - (*goals: 1. ‹X ⊆ {a..x} ⟹ a ≤ b› 2. ‹X ⊆ {a..x} ⟹ c ≤ x› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . hence "(λx. integral (cbox b c) (λt. of_real (bernpoly n (t - ⌊Inf {b..c}⌋)) * f x t)) holomorphic_on U" apply (intro holo (*‹⟦a ≤ ?b; ?c ≤ x⟧ ⟹ (λz. integral (cbox ?b ?c) (λt. complex_of_real (bernpoly n (t - ?e)) * f z t)) holomorphic_on U›*)) (*goals: 1. ‹⟦a ≤ b; c ≤ x⟧ ⟹ a ≤ b› 2. ‹⟦a ≤ b; c ≤ x⟧ ⟹ c ≤ x› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . thus "?case" (*goal: ‹(λx. integral X (λt. complex_of_real (bernpoly n (t - real_of_int ⌊Inf X⌋)) * f x t)) holomorphic_on U›*) by simp qed also (*calculation: ‹(λz::complex. ∑X::real set∈(A::real set set). integral X (λt::real. complex_of_real (bernpoly (n::nat) (t - real_of_int ⌊Inf X⌋)) * (f::complex ⇒ real ⇒ complex) z t)) holomorphic_on (U::complex set)›*) have "?this ⟷ (λz. integral {a..x} (λt. of_real (pbernpoly n t) * f z t)) holomorphic_on U" apply (intro holomorphic_cong (*‹⟦?s = ?t; ⋀x. x ∈ ?s ⟹ ?f x = ?g x⟧ ⟹ (?f holomorphic_on ?s) = (?g holomorphic_on ?t)›*) refl (*‹?t = ?t›*)) (*goal: ‹((λz. ∑X∈A. integral X (λt. complex_of_real (bernpoly n (t - real_of_int ⌊Inf X⌋)) * f z t)) holomorphic_on U) = ((λz. integral {a..x} (λt. complex_of_real (pbernpoly n t) * f z t)) holomorphic_on U)›*) proof (goal_cases) (*goal: ‹⋀xa::complex. xa ∈ (U::complex set) ⟹ (∑X::real set∈(A::real set set). integral X (λt::real. complex_of_real (bernpoly (n::nat) (t - real_of_int ⌊Inf X⌋)) * (f::complex ⇒ real ⇒ complex) xa t)) = integral {a::real..x::real} (λt::real. complex_of_real (pbernpoly n t) * f xa t)›*) case (1 z) (*‹z ∈ U›*) have "((λt. of_real (pbernpoly n t) * f z t) has_integral (∑X∈A. integral X (λt. of_real (bernpoly n (t - ⌊Inf X⌋)) * f z t))) {a..x}" using division (*‹A division_of {a..x}›*) proof (rule has_integral_combine_division (*‹⟦?𝒟 division_of ?S; ⋀k. k ∈ ?𝒟 ⟹ (?f has_integral ?i k) k⟧ ⟹ (?f has_integral sum ?i ?𝒟) ?S›*)) (*goal: ‹⋀k. k ∈ A ⟹ ((λt. complex_of_real (pbernpoly n t) * f z t) has_integral integral k (λt. complex_of_real (bernpoly n (t - real_of_int ⌊Inf k⌋)) * f z t)) k›*) fix X assume X: "X ∈ A" (*‹(X::real set) ∈ (A::real set set)›*) then obtain b and c where X': "X = {b..c}" "b ≤ c" (*goal: ‹(⋀b c. ⟦X = {b..c}; b ≤ c⟧ ⟹ thesis) ⟹ thesis›*) apply (elim A_cases (*‹⟦?X5 ∈ A; ?X5 = {a..real_of_int ⌈a⌉} ⟹ ?thesis2; ?X5 = {real_of_int ⌊x⌋..x} ⟹ ?thesis2; ⋀n. ⟦?X5 = {real_of_int n..real_of_int n + 1}; n ∈ N⟧ ⟹ ?thesis2⟧ ⟹ ?thesis2›*)) (*goals: 1. ‹⟦⋀b c. ⟦X = {b..c}; b ≤ c⟧ ⟹ thesis; X = {a..real_of_int ⌈a⌉}⟧ ⟹ thesis› 2. ‹⟦⋀b c. ⟦X = {b..c}; b ≤ c⟧ ⟹ thesis; X = {real_of_int ⌊x⌋..x}⟧ ⟹ thesis› 3. ‹⋀n. ⟦⋀b c. ⟦X = {b..c}; b ≤ c⟧ ⟹ thesis; X = {real_of_int n..real_of_int n + 1}; n ∈ N⟧ ⟹ thesis› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*proven 3 subgoals*) . from X (*‹X ∈ A›*) division (*‹A division_of {a..x}›*) have "X ⊆ {a..x}" by (auto simp: division_of_def (*‹((?s::?'a set set) division_of (?i::?'a set)) = (finite ?s ∧ (∀K::?'a set∈?s. K ⊆ ?i ∧ K ≠ {} ∧ (∃(a::?'a) b::?'a. K = cbox a b)) ∧ (∀K1::?'a set∈?s. ∀K2::?'a set∈?s. K1 ≠ K2 ⟶ interior K1 ∩ interior K2 = {}) ∧ ⋃ ?s = ?i)›*)) with X' (*‹X = {b..c}› ‹b ≤ c›*) have bc: "b ≥ a" "c ≤ x" apply - (*goals: 1. ‹⟦X = {b..c}; b ≤ c; X ⊆ {a..x}⟧ ⟹ a ≤ b› 2. ‹⟦X = {b..c}; b ≤ c; X ⊆ {a..x}⟧ ⟹ c ≤ x› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . have "((λt. of_real (bernpoly n (t - of_int ⌊Inf X⌋)) * f z t) has_integral integral X (λt. of_real (bernpoly n (t - of_int ⌊Inf X⌋)) * f z t)) X" unfolding X' (*goal: ‹((λt. complex_of_real (bernpoly n (t - real_of_int ⌊Inf {b..c}⌋)) * f z t) has_integral integral {b..c} (λt. complex_of_real (bernpoly n (t - real_of_int ⌊Inf {b..c}⌋)) * f z t)) {b..c}›*) using ‹z ∈ U› (*‹z ∈ U›*) bc (*‹a ≤ b› ‹(c::real) ≤ (x::real)›*) apply (intro integrable_integral (*‹(?f::?'a ⇒ ?'b) integrable_on (?i::?'a set) ⟹ (?f has_integral integral ?i ?f) ?i›*) int (*‹⟦(a::real) ≤ (?b::real); (?c::real) ≤ (x::real); (?z::complex) ∈ (U::complex set)⟧ ⟹ (λt::real. complex_of_real (bernpoly (n::nat) (t - (?e::real))) * (f::complex ⇒ real ⇒ complex) ?z t) integrable_on {?b..?c}›*)) (*goals: 1. ‹⟦z ∈ U; a ≤ b; c ≤ x⟧ ⟹ a ≤ b› 2. ‹⟦z ∈ U; a ≤ b; c ≤ x⟧ ⟹ c ≤ x› 3. ‹⟦z ∈ U; a ≤ b; c ≤ x⟧ ⟹ z ∈ U› discuss goal 1*) apply ((assumption)[1]) (*discuss goal 2*) apply ((assumption)[1]) (*discuss goal 3*) . (*proven 3 subgoals*) also (*calculation: ‹((λt. complex_of_real (bernpoly n (t - real_of_int ⌊Inf X⌋)) * f z t) has_integral integral X (λt. complex_of_real (bernpoly n (t - real_of_int ⌊Inf X⌋)) * f z t)) X›*) have "?this ⟷ ((λt. of_real (pbernpoly n t) * f z t) has_integral integral X (λt. of_real (bernpoly n (t - of_int ⌊Inf X⌋)) * f z t)) X" proof (rule has_integral_spike_eq[of "{Sup X}"] (*‹⟦negligible {Sup X}; ⋀x. x ∈ ?T - {Sup X} ⟹ ?g x = ?f x⟧ ⟹ (?f has_integral ?y) ?T = (?g has_integral ?y) ?T›*), goal_cases) (*goals: 1. ‹negligible {Sup X}› 2. ‹⋀x. x ∈ X - {Sup X} ⟹ complex_of_real (pbernpoly n x) * f z x = complex_of_real (bernpoly n (x - real_of_int ⌊Inf X⌋)) * f z x›*) case (2 t) (*‹(t::real) ∈ (X::real set) - {Sup X}›*) note t = this (*‹t ∈ X - {Sup X}›*) from ‹X ∈ A› (*‹X ∈ A›*) have "⌊t⌋ = ⌊Inf X⌋" proof (cases rule: A_cases [consumes 1] (*‹⟦?X5 ∈ A; ?X5 = {a..real_of_int ⌈a⌉} ⟹ ?thesis2; ?X5 = {real_of_int ⌊x⌋..x} ⟹ ?thesis2; ⋀n. ⟦?X5 = {real_of_int n..real_of_int n + 1}; n ∈ N⟧ ⟹ ?thesis2⟧ ⟹ ?thesis2›*)) (*goals: 1. ‹X = {a..real_of_int ⌈a⌉} ⟹ ⌊t⌋ = ⌊Inf X⌋› 2. ‹X = {real_of_int ⌊x⌋..x} ⟹ ⌊t⌋ = ⌊Inf X⌋› 3. ‹⋀n. ⟦X = {real_of_int n..real_of_int n + 1}; n ∈ N⟧ ⟹ ⌊t⌋ = ⌊Inf X⌋›*) case 1 (*‹X = {a..real_of_int ⌈a⌉}›*) with t (*‹t ∈ X - {Sup X}›*) show "?thesis" (*goal: ‹⌊t::real⌋ = ⌊Inf (X::real set)⌋›*) apply (intro floor_unique (*‹⟦of_int ?z ≤ ?x; ?x < of_int ?z + 1⟧ ⟹ ⌊?x⌋ = ?z›*)) (*goals: 1. ‹⟦t ∈ X - {Sup X}; X = {a..real_of_int ⌈a⌉}⟧ ⟹ real_of_int ⌊Inf X⌋ ≤ t› 2. ‹⟦t ∈ X - {Sup X}; X = {a..real_of_int ⌈a⌉}⟧ ⟹ t < real_of_int ⌊Inf X⌋ + 1› discuss goal 1*) apply ((auto simp: ceiling_altdef (*‹⌈?x⌉ = (if ?x = of_int ⌊?x⌋ then ⌊?x⌋ else ⌊?x⌋ + 1)›*) 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]) (*top goal: ‹⟦t ∈ X - {Sup X}; X = {a..real_of_int ⌈a⌉}⟧ ⟹ real_of_int ⌊Inf X⌋ ≤ t› and 1 goal remains*) apply linarith (*discuss goal 2*) apply ((auto simp: ceiling_altdef (*‹⌈?x⌉ = (if ?x = of_int ⌊?x⌋ then ⌊?x⌋ else ⌊?x⌋ + 1)›*) 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*) . next (*goals: 1. ‹X = {real_of_int ⌊x⌋..x} ⟹ ⌊t⌋ = ⌊Inf X⌋› 2. ‹⋀n. ⟦X = {real_of_int n..real_of_int n + 1}; n ∈ N⟧ ⟹ ⌊t⌋ = ⌊Inf X⌋›*) case 2 (*‹X = {real_of_int ⌊x⌋..x}›*) with t (*‹t ∈ X - {Sup X}›*) show "?thesis" (*goal: ‹⌊t⌋ = ⌊Inf X⌋›*) apply (intro floor_unique (*‹⟦of_int ?z ≤ ?x; ?x < of_int ?z + 1⟧ ⟹ ⌊?x⌋ = ?z›*)) (*goals: 1. ‹⟦(t::real) ∈ (X::real set) - {Sup X}; X = {real_of_int ⌊x::real⌋..x}⟧ ⟹ real_of_int ⌊Inf X⌋ ≤ t› 2. ‹⟦(t::real) ∈ (X::real set) - {Sup X}; X = {real_of_int ⌊x::real⌋..x}⟧ ⟹ t < real_of_int ⌊Inf X⌋ + (1::real)› discuss goal 1*) apply ((auto simp: ceiling_altdef (*‹⌈?x⌉ = (if ?x = of_int ⌊?x⌋ then ⌊?x⌋ else ⌊?x⌋ + 1)›*) 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: ceiling_altdef (*‹⌈?x⌉ = (if ?x = of_int ⌊?x⌋ then ⌊?x⌋ else ⌊?x⌋ + 1)›*) 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]) (*goal: ‹⟦t ∈ X - {Sup X}; X = {real_of_int ⌊x⌋..x}⟧ ⟹ t < real_of_int ⌊Inf X⌋ + 1›*) apply linarith (*proven 2 subgoals*) . next (*goal: ‹⋀n. ⟦X = {real_of_int n..real_of_int n + 1}; n ∈ N⟧ ⟹ ⌊t⌋ = ⌊Inf X⌋›*) case 3 (*‹X = {real_of_int n_..real_of_int n_ + 1}› ‹n_ ∈ N›*) with t (*‹t ∈ X - {Sup X}›*) show "?thesis" (*goal: ‹⌊t⌋ = ⌊Inf X⌋›*) apply (intro floor_unique (*‹⟦of_int (?z::int) ≤ (?x::?'a); ?x < of_int ?z + (1::?'a)⟧ ⟹ ⌊?x⌋ = ?z›*)) (*goals: 1. ‹⟦(t::real) ∈ (X::real set) - {Sup X}; X = {real_of_int (n_::int)..real_of_int n_ + (1::real)}; n_ ∈ (N::int set)⟧ ⟹ real_of_int ⌊Inf X⌋ ≤ t› 2. ‹⟦(t::real) ∈ (X::real set) - {Sup X}; X = {real_of_int (n_::int)..real_of_int n_ + (1::real)}; n_ ∈ (N::int set)⟧ ⟹ t < real_of_int ⌊Inf X⌋ + (1::real)› discuss goal 1*) apply ((auto simp: ceiling_altdef (*‹⌈?x⌉ = (if ?x = of_int ⌊?x⌋ then ⌊?x⌋ else ⌊?x⌋ + 1)›*) N_def (*‹N = {⌈a⌉..<⌊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))›*))[1]) (*discuss goal 2*) apply ((auto simp: ceiling_altdef (*‹⌈?x⌉ = (if ?x = of_int ⌊?x⌋ then ⌊?x⌋ else ⌊?x⌋ + 1)›*) N_def (*‹N = {⌈a⌉..<⌊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))›*))[1]) (*proven 2 subgoals*) . qed thus "?case" (*goal: ‹complex_of_real (pbernpoly n t) * f z t = complex_of_real (bernpoly n (t - real_of_int ⌊Inf X⌋)) * f z t›*) by (simp add: pbernpoly_def (*‹pbernpoly ?n ?x = bernpoly ?n (frac ?x)›*) frac_def (*‹frac ?x ≡ ?x - of_int ⌊?x⌋›*)) qed (auto) (*solved the remaining goal: ‹negligible {Sup X}›*) finally (*calculation: ‹((λt::real. complex_of_real (pbernpoly (n::nat) t) * (f::complex ⇒ real ⇒ complex) (z::complex) t) has_integral integral (X::real set) (λt::real. complex_of_real (bernpoly n (t - real_of_int ⌊Inf X⌋)) * f z t)) X›*) show "…" . qed thus "?case" (*goal: ‹(∑X::real set∈(A::real set set). integral X (λt::real. complex_of_real (bernpoly (n::nat) (t - real_of_int ⌊Inf X⌋)) * (f::complex ⇒ real ⇒ complex) (z::complex) t)) = integral {a::real..x::real} (λt::real. complex_of_real (pbernpoly n t) * f z t)›*) by (simp add: has_integral_iff (*‹(?f has_integral ?i) ?S = (?f integrable_on ?S ∧ integral ?S ?f = ?i)›*)) qed finally (*calculation: ‹(λz. integral {a..x} (λt. complex_of_real (pbernpoly n t) * f z t)) holomorphic_on U›*) show "?thesis" (*goal: ‹(λz. integral (cbox a x) (λt. complex_of_real (pbernpoly n t) * f z t)) holomorphic_on U›*) by simp qed (auto) (*solved the remaining goal: ‹x < a ⟹ (λz. integral (cbox a x) (λt. complex_of_real (pbernpoly n t) * f z t)) holomorphic_on U›*) thus "(λz. integral {a..x} (λt. of_real (pbernpoly n t) * f z t)) holomorphic_on U" by simp qed lemma assumes deriv: "⋀y. a ≤ y ⟹ (G has_real_derivative g y) (at y within {a..})" assumes deriv': "⋀z t x. z ∈ U ⟹ x ≥ a ⟹ t ∈ {a..x} ⟹ ((λz. f z t) has_field_derivative f' z t) (at z within U)" assumes cont: "continuous_on (U × {of_int a..}) (λ(z, t). f' z t)" assumes int: "⋀b c z e. a ≤ b ⟹ z ∈ U ⟹ (λt. of_real (bernpoly n (t - e)) * f z t) integrable_on {b..c}" assumes int': "⋀a' b y. y ∈ U ⟹ a ≤ a' ⟹ a' ≤ b ⟹ (λt. pbernpoly n t *⇩R f y t) integrable_on {a'..b}" assumes conv: "convergent (λy. G (real y))" assumes bound: "eventually (λx. ∀y∈U. norm (f y x) ≤ g x) at_top" assumes "open U" shows analytic_EM_remainder: "(λs::complex. EM_remainder n (f s) a) analytic_on U" and holomorphic_EM_remainder: "(λs::complex. EM_remainder n (f s) a) holomorphic_on U" proof (-) (*goals: 1. ‹(λs. EM_remainder n (f s) a) analytic_on U› 2. ‹(λs. EM_remainder n (f s) a) holomorphic_on U›*) show "(λs::complex. EM_remainder n (f s) a) analytic_on U" unfolding analytic_on_def (*goal: ‹∀x∈U. ∃ε>0. (λs. EM_remainder n (f s) a) holomorphic_on ball x ε›*) proof (standard) (*goal: ‹⋀x. x ∈ U ⟹ ∃ε>0. (λs. EM_remainder n (f s) a) holomorphic_on ball x ε›*) fix z assume "z ∈ U" (*‹(z::complex) ∈ (U::complex set)›*) from ‹z ∈ U› (*‹z ∈ U›*) ‹open U› (*‹open (U::complex set)›*) obtain ε where "ε": "ε > 0" "ball z ε ⊆ U" (*goal: ‹(⋀ε. ⟦0 < ε; ball z ε ⊆ U⟧ ⟹ thesis) ⟹ thesis›*) by (auto simp: open_contains_ball (*‹open ?S = (∀x∈?S. ∃e>0. ball x e ⊆ ?S)›*)) have "(λs. EM_remainder n (f s) a) holomorphic_on ball z ε" proof (rule holomorphic_uniform_sequence (*‹⟦open ?S; ⋀n. ?f n holomorphic_on ?S; ⋀x. x ∈ ?S ⟹ ∃d>0. cball x d ⊆ ?S ∧ uniform_limit (cball x d) ?f ?g sequentially⟧ ⟹ ?g holomorphic_on ?S›*)) (*goals: 1. ‹open (ball z ε)› 2. ‹⋀n. ?f n holomorphic_on ball z ε› 3. ‹⋀x. x ∈ ball z ε ⟹ ∃d>0. cball x d ⊆ ball z ε ∧ uniform_limit (cball x d) ?f (λs. EM_remainder n (f s) a) sequentially›*) fix x :: nat show "(λs. EM_remainder' n (f s) a x) holomorphic_on ball z ε" proof (rule holomorphic_EM_remainder' (*‹⟦⋀(z::complex) t::real. ⟦z ∈ (?U::complex set); t ∈ {?a::real..?x::real}⟧ ⟹ ((λz::complex. (?f::complex ⇒ real ⇒ complex) z t) has_field_derivative (?f'::complex ⇒ real ⇒ complex) z t) (at z within ?U); ⋀(b::real) (c::real) (z::complex) e::real. ⟦?a ≤ b; c ≤ ?x; z ∈ ?U⟧ ⟹ (λt::real. complex_of_real (bernpoly (?n::nat) (t - e)) * ?f z t) integrable_on {b..c}; continuous_on (?U × {?a..?x}) (λ(z::complex, t::real). ?f' z t); convex ?U⟧ ⟹ (λs::complex. EM_remainder' ?n (?f s) ?a ?x) holomorphic_on ?U›*), goal_cases) (*goals: 1. ‹⋀(za::complex) t::real. ⟦za ∈ ball (z::complex) (ε::real); t ∈ {real_of_int (a::int)..real (x::nat)}⟧ ⟹ ((λz::complex. (f::complex ⇒ real ⇒ complex) z t) has_field_derivative (?f'::complex ⇒ real ⇒ complex) za t) (at za within ball z ε)› 2. ‹⋀(b::real) (c::real) (za::complex) e::real. ⟦real_of_int (a::int) ≤ b; c ≤ real (x::nat); za ∈ ball (z::complex) (ε::real)⟧ ⟹ (λt::real. complex_of_real (bernpoly (n::nat) (t - e)) * (f::complex ⇒ real ⇒ complex) za t) integrable_on {b..c}› 3. ‹continuous_on (ball (z::complex) (ε::real) × {real_of_int (a::int)..real (x::nat)}) (λ(z::complex, t::real). (?f'::complex ⇒ real ⇒ complex) z t)› 4. ‹convex (ball (z::complex) (ε::real))›*) fix s and t assume "s ∈ ball z ε" "t ∈ {real_of_int a..real x}" (*‹(s::complex) ∈ ball (z::complex) (ε::real)› ‹(t::real) ∈ {real_of_int (a::int)..real (x::nat)}›*) thus "((λz. f z t) has_field_derivative f' s t) (at s within ball z ε)" using "ε" (*‹0 < ε› ‹ball (z::complex) (ε::real) ⊆ (U::complex set)›*) apply (intro DERIV_subset[OF deriv'[of _ x]] (*‹⟦?x ∈ U; a ≤ int x; ?t1 ∈ {real_of_int a..real_of_int (int x)}; ?t ⊆ U⟧ ⟹ ((λz. f z ?t1) has_field_derivative f' ?x ?t1) (at ?x within ?t)›*)) (*goals: 1. ‹⟦s ∈ ball z ε; t ∈ {real_of_int a..real x}; 0 < ε; ball z ε ⊆ U⟧ ⟹ s ∈ U› 2. ‹⟦s ∈ ball z ε; t ∈ {real_of_int a..real x}; 0 < ε; ball z ε ⊆ U⟧ ⟹ a ≤ int x› 3. ‹⟦s ∈ ball z ε; t ∈ {real_of_int a..real x}; 0 < ε; ball z ε ⊆ U⟧ ⟹ t ∈ {real_of_int a..real_of_int (int x)}› 4. ‹⟦s ∈ ball z ε; t ∈ {real_of_int a..real x}; 0 < ε; ball z ε ⊆ U⟧ ⟹ ball z ε ⊆ 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]) (*proven 4 subgoals*) . next (*goals: 1. ‹⋀b c za e. ⟦real_of_int a ≤ b; c ≤ real x; za ∈ ball z ε⟧ ⟹ (λt. complex_of_real (bernpoly n (t - e)) * f za t) integrable_on {b..c}› 2. ‹continuous_on (ball z ε × {real_of_int a..real x}) (λ(z, t). f' z t)› 3. ‹convex (ball z ε)›*) case (2 b c s e) (*‹real_of_int a ≤ b› ‹(c::real) ≤ real (x::nat)› ‹s ∈ ball z ε›*) with "ε" (*‹0 < ε› ‹ball z ε ⊆ U›*) have "s ∈ U" by blast with "2" (*‹real_of_int a ≤ b› ‹c ≤ real x› ‹s ∈ ball z ε›*) show "?case" (*goal: ‹(λt. complex_of_real (bernpoly n (t - e)) * f s t) integrable_on {b..c}›*) using "ε" (*‹0 < ε› ‹ball z ε ⊆ U›*) int[of b s e c] (*‹⟦real_of_int a ≤ b; s ∈ U⟧ ⟹ (λt. complex_of_real (bernpoly n (t - e)) * f s t) integrable_on {b..c}›*) apply (cases "a ≤ x") (*goals: 1. ‹⟦real_of_int a ≤ b; c ≤ real x; s ∈ ball z ε; s ∈ U; 0 < ε; ball z ε ⊆ U; ⟦real_of_int a ≤ b; s ∈ U⟧ ⟹ (λt. complex_of_real (bernpoly n (t - e)) * f s t) integrable_on {b..c}; a ≤ int x⟧ ⟹ (λt. complex_of_real (bernpoly n (t - e)) * f s t) integrable_on {b..c}› 2. ‹⟦real_of_int a ≤ b; c ≤ real x; s ∈ ball z ε; s ∈ U; 0 < ε; ball z ε ⊆ U; ⟦real_of_int a ≤ b; s ∈ U⟧ ⟹ (λt. complex_of_real (bernpoly n (t - e)) * f s t) integrable_on {b..c}; ¬ a ≤ int x⟧ ⟹ (λt. complex_of_real (bernpoly n (t - e)) * f s t) integrable_on {b..c}› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . next (*goals: 1. ‹continuous_on (ball z ε × {real_of_int a..real x}) (λ(z, t). f' z t)› 2. ‹convex (ball z ε)›*) from cont (*‹continuous_on (U × {real_of_int a..}) (λ(z, t). f' z t)›*) show "continuous_on (ball z ε × {real_of_int a..real x}) (λ(z, t). f' z t)" apply (rule continuous_on_subset (*‹⟦continuous_on ?s ?f; ?t ⊆ ?s⟧ ⟹ continuous_on ?t ?f›*)) (*goal: ‹continuous_on (ball z ε × {real_of_int a..real x}) (λ(z, t). f' z t)›*) apply (insert ε (*‹0 < ε› ‹ball z ε ⊆ U›*)) (*goal: ‹ball z ε × {real_of_int a..real x} ⊆ U × {real_of_int a..}›*) by auto qed (auto) (*solved the remaining goal: ‹convex (ball z ε)›*) next (*goals: 1. ‹open (ball z ε)› 2. ‹⋀x. x ∈ ball z ε ⟹ ∃d>0. cball x d ⊆ ball z ε ∧ uniform_limit (cball x d) (λna s. EM_remainder' n (f s) (real_of_int a) (real (?x7 na))) (λs. EM_remainder n (f s) a) sequentially›*) fix s assume s: "s ∈ ball z ε" (*‹(s::complex) ∈ ball (z::complex) (ε::real)›*) have "open (ball z ε)" by simp with s (*‹s ∈ ball z ε›*) obtain δ where "δ": "δ > 0" "cball s δ ⊆ ball z ε" (*goal: ‹(⋀δ. ⟦0 < δ; cball s δ ⊆ ball z ε⟧ ⟹ thesis) ⟹ thesis›*) unfolding open_contains_cball (*goal: ‹(⋀δ. ⟦0 < δ; cball s δ ⊆ ball z ε⟧ ⟹ thesis) ⟹ thesis›*) by blast moreover have bound': "eventually (λx. ∀y∈cball s δ. norm (f y x) ≤ g x) at_top" apply (intro eventually_mono [OF bound] (*‹(⋀x::real. ∀y::complex∈U::complex set. cmod ((f::complex ⇒ real ⇒ complex) y x) ≤ (g::real ⇒ real) x ⟹ (?Q::real ⇒ bool) x) ⟹ eventually ?Q at_top›*)) (*goal: ‹∀⇩F x in at_top. ∀y∈cball s δ. cmod (f y x) ≤ g x›*) apply (insert δ (*‹0 < δ› ‹cball s δ ⊆ ball z ε›*) ε (*‹0 < ε› ‹ball z ε ⊆ U›*)) (*goal: ‹⋀x. ∀y∈U. cmod (f y x) ≤ g x ⟹ ∀y∈cball s δ. cmod (f y x) ≤ g x›*) by auto have "uniform_limit (cball s δ) (λx s. EM_remainder' n (f s) (real_of_int a) (real x)) (λs. EM_remainder n (f s) a) sequentially" apply (rule uniform_limit_EM_remainder[OF deriv int' conv bound'] (*‹⟦⋀y. real_of_int a ≤ y ⟹ real_of_int a ≤ y; ⋀a' b y. ⟦y ∈ cball s δ; real_of_int a ≤ a'; a' ≤ b⟧ ⟹ y ∈ U; ⋀a' b y. ⟦y ∈ cball s δ; real_of_int a ≤ a'; a' ≤ b⟧ ⟹ real_of_int a ≤ a'; ⋀a' b y. ⟦y ∈ cball s δ; real_of_int a ≤ a'; a' ≤ b⟧ ⟹ a' ≤ b⟧ ⟹ uniform_limit (cball s δ) (λb s. EM_remainder' n (f s) (real_of_int a) (real b)) (λs. EM_remainder n (f s) a) sequentially›*)) (*goals: 1. ‹⋀y. real_of_int a ≤ y ⟹ real_of_int a ≤ y› 2. ‹⋀a' x y. ⟦y ∈ cball s δ; real_of_int a ≤ a'; a' ≤ x⟧ ⟹ y ∈ U› 3. ‹⋀a' x y. ⟦y ∈ cball s δ; real_of_int a ≤ a'; a' ≤ x⟧ ⟹ real_of_int a ≤ a'› 4. ‹⋀a' x y. ⟦y ∈ cball s δ; real_of_int a ≤ a'; a' ≤ x⟧ ⟹ a' ≤ x› discuss goal 1*) apply ((insert δ (*‹(0::real) < (δ::real)› ‹cball (s::complex) (δ::real) ⊆ ball (z::complex) (ε::real)›*) ε (*‹(0::real) < (ε::real)› ‹ball (z::complex) (ε::real) ⊆ (U::complex set)›*) s (*‹(s::complex) ∈ ball (z::complex) (ε::real)›*))[1]) (*top goal: ‹⋀y. real_of_int a ≤ y ⟹ real_of_int a ≤ y› and 3 goals remain*) apply ((auto)[1]) (*discuss goal 2*) apply ((insert δ (*‹0 < δ› ‹cball s δ ⊆ ball z ε›*) ε (*‹0 < ε› ‹ball z ε ⊆ U›*) s (*‹s ∈ ball z ε›*))[1]) (*top goal: ‹⋀a' x y. ⟦y ∈ cball s δ; real_of_int a ≤ a'; a' ≤ x⟧ ⟹ y ∈ U› and 2 goals remain*) apply ((auto)[1]) (*discuss goal 3*) apply ((insert δ (*‹(0::real) < (δ::real)› ‹cball (s::complex) (δ::real) ⊆ ball (z::complex) (ε::real)›*) ε (*‹(0::real) < (ε::real)› ‹ball (z::complex) (ε::real) ⊆ (U::complex set)›*) s (*‹(s::complex) ∈ ball (z::complex) (ε::real)›*))[1]) (*top goal: ‹⋀a' x y. ⟦y ∈ cball s δ; real_of_int a ≤ a'; a' ≤ x⟧ ⟹ real_of_int a ≤ a'› and 1 goal remains*) apply ((auto)[1]) (*discuss goal 4*) apply ((insert δ (*‹0 < δ› ‹cball s δ ⊆ ball z ε›*) ε (*‹0 < ε› ‹ball z ε ⊆ U›*) s (*‹s ∈ ball z ε›*))[1]) (*goal: ‹⋀a' x y. ⟦y ∈ cball s δ; real_of_int a ≤ a'; a' ≤ x⟧ ⟹ a' ≤ x›*) apply ((auto)[1]) (*proven 4 subgoals*) . ultimately show "∃δ>0. cball s δ ⊆ ball z ε ∧ uniform_limit (cball s δ) (λx s. EM_remainder' n (f s) (real_of_int a) (real x)) (λs. EM_remainder n (f s) a) sequentially" by blast qed (auto) (*solved the remaining goal: ‹open (ball z ε)›*) with "ε" (*‹0 < ε› ‹ball z ε ⊆ U›*) show "∃ε>0. (λs. EM_remainder n (f s) a) holomorphic_on ball z ε" by blast qed thus "(λs::complex. EM_remainder n (f s) a) holomorphic_on U" by (rule analytic_imp_holomorphic (*‹?f analytic_on ?S ⟹ ?f holomorphic_on ?S›*)) qed text ‹ The following lemma is the first step in the proof of the Euler--MacLaurin formula: We show the relationship between the first-order remainder term and the difference of the integral and the sum. › context fixes f f' :: "real ⇒ 'a :: banach" fixes a b :: int and I S :: 'a fixes Y :: "real set" assumes "a ≤ b" assumes fin: "finite Y" assumes cont: "continuous_on {real_of_int a..real_of_int b} f" assumes deriv [derivative_intros]: "⋀x::real. x ∈ {a..b} - Y ⟹ (f has_vector_derivative f' x) (at x)" defines S_def: "S ≡ (∑i∈{a<..b}. f i)" and I_def: "I ≡ integral {a..b} f" begin lemma diff_sum_integral_has_integral_int: "((λt. (frac t - 1/2) *⇩R f' t) has_integral (S - I - (f b - f a) /⇩R 2)) {a..b}" proof (cases "a = b") (*goals: 1. ‹a = b ⟹ ((λt. (frac t - 1 / 2) *⇩R f' t) has_integral S - I - (f (real_of_int b) - f (real_of_int a)) /⇩R 2) {real_of_int a..real_of_int b}› 2. ‹a ≠ b ⟹ ((λt. (frac t - 1 / 2) *⇩R f' t) has_integral S - I - (f (real_of_int b) - f (real_of_int a)) /⇩R 2) {real_of_int a..real_of_int b}›*) case True (*‹a = b›*) thus "?thesis" (*goal: ‹((λt::real. (frac t - (1::real) / (2::real)) *⇩R (f'::real ⇒ 'a::banach) t) has_integral (S::'a::banach) - (I::'a::banach) - ((f::real ⇒ 'a::banach) (real_of_int (b::int)) - f (real_of_int (a::int))) /⇩R (2::real)) {real_of_int a..real_of_int b}›*) by (simp add: S_def (*‹S ≡ ∑i∈{a<..b}. f (real_of_int i)›*) I_def (*‹I ≡ integral {real_of_int a..real_of_int b} f›*) has_integral_refl (*‹(?f has_integral 0) (cbox ?a ?a)› ‹(?f has_integral 0) {?a}›*)) next (*goal: ‹a ≠ b ⟹ ((λt. (frac t - 1 / 2) *⇩R f' t) has_integral S - I - (f (real_of_int b) - f (real_of_int a)) /⇩R 2) {real_of_int a..real_of_int b}›*) case False (*‹(a::int) ≠ (b::int)›*) with ‹a ≤ b› (*‹a ≤ b›*) have ab: "a < b" by simp let ?A = "(λn. {real_of_int n..real_of_int (n+1)}) ` {a..<b}" have division: "?A division_of {of_int a..of_int b}" using Union_atLeastAtMost_real_of_int[OF ab] (*‹(⋃n∈{a..<b}. {real_of_int n..real_of_int (n + 1)}) = {real_of_int a..real_of_int b}›*) by (simp add: division_of_def (*‹(?s division_of ?i) = (finite ?s ∧ (∀K∈?s. K ⊆ ?i ∧ K ≠ {} ∧ (∃a b. K = cbox a b)) ∧ (∀K1∈?s. ∀K2∈?s. K1 ≠ K2 ⟶ interior K1 ∩ interior K2 = {}) ∧ ⋃ ?s = ?i)›*)) have cont'[continuous_intros]: "continuous_on A f" if "A ⊆ {of_int a..of_int b}" for A using continuous_on_subset[OF cont that] (*‹continuous_on A f›*) . define d where "d = (λx. (f x + f (x + 1)) /⇩R 2 - integral {x..x+1} f)" have "((λt. (frac t - 1/2) *⇩R f' t) has_integral d i) {of_int i..of_int (i+1)}" if i: "i ∈ {a..<b}" for i proof (rule has_integral_spike (*‹⟦negligible ?S; ⋀x. x ∈ ?T - ?S ⟹ ?g x = ?f x; (?f has_integral ?y) ?T⟧ ⟹ (?g has_integral ?y) ?T›*)) (*goals: 1. ‹negligible (?S::real set)› 2. ‹⋀x::real. x ∈ {real_of_int (i::int)..real_of_int (i + (1::int))} - (?S::real set) ⟹ (frac x - (1::real) / (2::real)) *⇩R (f'::real ⇒ 'a) x = (?f::real ⇒ 'a) x› 3. ‹((?f::real ⇒ 'a) has_integral (d::real ⇒ 'a) (real_of_int (i::int))) {real_of_int i..real_of_int (i + (1::int))}›*) show "(frac x - 1 / 2) *⇩R f' x = (x - of_int i - 1 / 2) *⇩R f' x" if "x ∈ {of_int i..of_int (i + 1)} - {of_int (i + 1)}" for x proof (-) (*goal: ‹(frac x - 1 / 2) *⇩R f' x = (x - real_of_int i - 1 / 2) *⇩R f' x›*) have "x ≥ of_int i" "x < of_int (i + 1)" using that (*‹x ∈ {real_of_int i..real_of_int (i + 1)} - {real_of_int (i + 1)}›*) apply - (*goals: 1. ‹x ∈ {real_of_int i..real_of_int (i + 1)} - {real_of_int (i + 1)} ⟹ real_of_int i ≤ x› 2. ‹x ∈ {real_of_int i..real_of_int (i + 1)} - {real_of_int (i + 1)} ⟹ x < real_of_int (i + 1)› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . hence "floor x = of_int i" apply (subst floor_unique (*‹⟦of_int (?z::int) ≤ (?x::?'a); ?x < of_int ?z + (1::?'a)⟧ ⟹ ⌊?x⌋ = ?z›*)) (*goals: 1. ‹⟦real_of_int i ≤ x; x < real_of_int (i + 1)⟧ ⟹ real_of_int ?y2 ≤ x› 2. ‹⟦real_of_int i ≤ x; x < real_of_int (i + 1)⟧ ⟹ x < real_of_int ?y2 + 1› 3. ‹⟦real_of_int i ≤ x; x < real_of_int (i + 1)⟧ ⟹ ?y2 = of_int i› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*proven 3 subgoals*) . thus "?thesis" (*goal: ‹(frac x - 1 / 2) *⇩R f' x = (x - real_of_int i - 1 / 2) *⇩R f' x›*) by (simp add: frac_def (*‹frac ?x ≡ ?x - of_int ⌊?x⌋›*)) qed next (*goals: 1. ‹negligible {real_of_int (i + 1)}› 2. ‹((λx. (x - real_of_int i - 1 / 2) *⇩R f' x) has_integral d (real_of_int i)) {real_of_int i..real_of_int (i + 1)}›*) define h where "h = (λx::real. (x - of_int i - 1 / 2) *⇩R f' x)" define g where "g = (λx::real. (x - of_int i - 1/2) *⇩R f x - integral {of_int i..x} f)" have "*": "((λx. integral {real_of_int i..x} f) has_vector_derivative f x) (at x within {i..i+1})" if "x ∈ {of_int i<..<of_int i + 1}" for x using that (*‹x ∈ {real_of_int i<..<real_of_int i + 1}›*) i (*‹i ∈ {a..<b}›*) apply (intro integral_has_vector_derivative (*‹⟦continuous_on {?a::real..?b::real} (?f::real ⇒ ?'a); (?x::real) ∈ {?a..?b}⟧ ⟹ ((λu::real. integral {?a..u} ?f) has_vector_derivative ?f ?x) (at ?x within {?a..?b})›*) cont' (*‹(?A::real set) ⊆ {real_of_int (a::int)..real_of_int (b::int)} ⟹ continuous_on ?A (f::real ⇒ 'a)›*)) (*goals: 1. ‹⟦x ∈ {real_of_int i<..<real_of_int i + 1}; i ∈ {a..<b}⟧ ⟹ {real_of_int i..real_of_int (i + 1)} ⊆ {real_of_int a..real_of_int b}› 2. ‹⟦x ∈ {real_of_int i<..<real_of_int i + 1}; i ∈ {a..<b}⟧ ⟹ x ∈ {real_of_int i..real_of_int (i + 1)}› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . have "((λx. integral {real_of_int i..x} f) has_vector_derivative f x) (at x)" if "x ∈ {of_int i<..<of_int i + 1}" for x using that (*‹x ∈ {real_of_int i<..<real_of_int i + 1}›*) i (*‹(i::int) ∈ {a::int..<b::int}›*) at_within_interior[of x "{of_int i..of_int (i + 1)}"] (*‹(x::real) ∈ interior {real_of_int (i::int)..real_of_int (i + (1::int))} ⟹ at x within {real_of_int i..real_of_int (i + (1::int))} = at x›*) "*"[of x] (*‹(x::real) ∈ {real_of_int (i::int)<..<real_of_int i + (1::real)} ⟹ ((λx::real. integral {real_of_int i..x} (f::real ⇒ 'a)) has_vector_derivative f x) (at x within {real_of_int i..real_of_int (i + (1::int))})›*) by simp hence "(h has_integral g (of_int (i + 1)) - g (of_int i)) {of_int i..of_int (i+1)}" unfolding g_def h_def (*goal: ‹((λx. (x - real_of_int i - 1 / 2) *⇩R f' x) has_integral (real_of_int (i + 1) - real_of_int i - 1 / 2) *⇩R f (real_of_int (i + 1)) - integral {real_of_int i..real_of_int (i + 1)} f - ((real_of_int i - real_of_int i - 1 / 2) *⇩R f (real_of_int i) - integral {real_of_int i..real_of_int i} f)) {real_of_int i..real_of_int (i + 1)}›*) using that (*‹i ∈ {a..<b}›*) apply (intro fundamental_theorem_of_calculus_interior_strong[OF fin] (*‹⟦?a ≤ ?b; ⋀x. x ∈ {?a<..<?b} - Y ⟹ (?f has_vector_derivative ?f' x) (at x); continuous_on {?a..?b} ?f⟧ ⟹ (?f' has_integral ?f ?b - ?f ?a) {?a..?b}›*)) (*goals: 1. ‹⟦⋀x. x ∈ {real_of_int i<..<real_of_int i + 1} ⟹ ((λx. integral {real_of_int i..x} f) has_vector_derivative f x) (at x); i ∈ {a..<b}⟧ ⟹ real_of_int i ≤ real_of_int (i + 1)› 2. ‹⋀x. ⟦⋀x. x ∈ {real_of_int i<..<real_of_int i + 1} ⟹ ((λx. integral {real_of_int i..x} f) has_vector_derivative f x) (at x); i ∈ {a..<b}; x ∈ {real_of_int i<..<real_of_int (i + 1)} - Y⟧ ⟹ ((λa. (a - real_of_int i - 1 / 2) *⇩R f a - integral {real_of_int i..a} f) has_vector_derivative (x - real_of_int i - 1 / 2) *⇩R f' x) (at x)› 3. ‹⟦⋀x. x ∈ {real_of_int i<..<real_of_int i + 1} ⟹ ((λx. integral {real_of_int i..x} f) has_vector_derivative f x) (at x); i ∈ {a..<b}⟧ ⟹ continuous_on {real_of_int i..real_of_int (i + 1)} (λa. (a - real_of_int i - 1 / 2) *⇩R f a - integral {real_of_int i..a} f)› 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*) 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 273 facts*) indefinite_integral_continuous_1 (*‹?f integrable_on {?a..?b} ⟹ continuous_on {?a..?b} (λx. integral {?a..x} ?f)›*) integrable_continuous_real (*‹continuous_on {?a..?b} ?f ⟹ ?f integrable_on {?a..?b}›*))[1]) (*discuss goal 2*) 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*) 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 273 facts*) indefinite_integral_continuous_1 (*‹?f integrable_on {?a..?b} ⟹ continuous_on {?a..?b} (λx. integral {?a..x} ?f)›*) integrable_continuous_real (*‹continuous_on {?a..?b} ?f ⟹ ?f integrable_on {?a..?b}›*))[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*) 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 273 facts*) indefinite_integral_continuous_1 (*‹?f integrable_on {?a..?b} ⟹ continuous_on {?a..?b} (λx. integral {?a..x} ?f)›*) integrable_continuous_real (*‹continuous_on {?a..?b} ?f ⟹ ?f integrable_on {?a..?b}›*))[1]) (*proven 3 subgoals*) . also (*calculation: ‹(h has_integral g (real_of_int (i + 1)) - g (real_of_int i)) {real_of_int i..real_of_int (i + 1)}›*) have "g (of_int (i + 1)) - g (of_int i) = d i" by (simp add: g_def (*‹g = (λx. (x - real_of_int i - 1 / 2) *⇩R f x - integral {real_of_int i..x} f)›*) scaleR_add_right [symmetric] (*‹?a *⇩R ?x + ?a *⇩R ?y = ?a *⇩R (?x + ?y)›*) d_def (*‹d = (λx. (f x + f (x + 1)) /⇩R 2 - integral {x..x + 1} f)›*)) finally (*calculation: ‹(h has_integral d (real_of_int i)) {real_of_int i..real_of_int (i + 1)}›*) show "(h has_integral d i) {of_int i..of_int (i + 1)}" . qed (simp_all) (*solved the remaining goal: ‹negligible {real_of_int (i + 1)}›*) hence "*": "⋀I. I∈?A ⟹ ((λx. (frac x - 1 / 2) *⇩R f' x) has_integral d (⌊Inf I⌋)) I" by (auto simp: add_ac (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)›*)) have "((λx::real. (frac x - 1 / 2) *⇩R f' x) has_integral (∑I∈?A. d (⌊Inf I⌋))) (⋃?A)" apply (intro has_integral_Union (*‹⟦finite (?𝒯::?'n set set); ⋀S::?'n set. S ∈ ?𝒯 ⟹ ((?f::?'n ⇒ ?'a) has_integral (?i::?'n set ⇒ ?'a) S) S; pairwise (λ(S::?'n set) S'::?'n set. negligible (S ∩ S')) ?𝒯⟧ ⟹ (?f has_integral sum ?i ?𝒯) (⋃ ?𝒯)›*) * (*‹(?I::real set) ∈ (λn::int. {real_of_int n..real_of_int (n + (1::int))}) ` {a::int..<b::int} ⟹ ((λx::real. (frac x - (1::real) / (2::real)) *⇩R (f'::real ⇒ 'a) x) has_integral (d::real ⇒ 'a) (real_of_int ⌊Inf ?I⌋)) ?I›*) finite_imageI (*‹finite (?F::?'a set) ⟹ finite ((?h::?'a ⇒ ?'b) ` ?F)›*)) (*goals: 1. ‹finite {a..<b}› 2. ‹⋀S. S ∈ (λn. {real_of_int n..real_of_int (n + 1)}) ` {a..<b} ⟹ S ∈ (λn. {real_of_int n..real_of_int (n + 1)}) ` {a..<b}› 3. ‹pairwise (λS S'. negligible (S ∩ S')) ((λn. {real_of_int n..real_of_int (n + 1)}) ` {a..<b})› discuss goal 1*) apply (force intro!: negligible_atLeastAtMostI (*‹?b ≤ ?a ⟹ negligible {?a..?b}›*) pairwiseI (*‹(⋀x y. ⟦x ∈ ?S; y ∈ ?S; x ≠ y⟧ ⟹ ?R x y) ⟹ pairwise ?R ?S›*)) (*discuss goal 2*) apply (force intro!: negligible_atLeastAtMostI (*‹(?b::real) ≤ (?a::real) ⟹ negligible {?a..?b}›*) pairwiseI (*‹(⋀(x::?'a) y::?'a. ⟦x ∈ (?S::?'a set); y ∈ ?S; x ≠ y⟧ ⟹ (?R::?'a ⇒ ?'a ⇒ bool) x y) ⟹ pairwise ?R ?S›*)) (*discuss goal 3*) apply (force intro!: negligible_atLeastAtMostI (*‹?b ≤ ?a ⟹ negligible {?a..?b}›*) pairwiseI (*‹(⋀x y. ⟦x ∈ ?S; y ∈ ?S; x ≠ y⟧ ⟹ ?R x y) ⟹ pairwise ?R ?S›*)) (*proven 3 subgoals*) . also (*calculation: ‹((λx. (frac x - 1 / 2) *⇩R f' x) has_integral (∑I∈(λn. {real_of_int n..real_of_int (n + 1)}) ` {a..<b}. d (real_of_int ⌊Inf I⌋))) (⋃n∈{a..<b}. {real_of_int n..real_of_int (n + 1)})›*) have "⋃?A = {of_int a..of_int b}" by (intro Union_atLeastAtMost_real_of_int (*‹?a < ?b ⟹ (⋃n∈{?a..<?b}. {real_of_int n..real_of_int (n + 1)}) = {real_of_int ?a..real_of_int ?b}›*) ab (*‹a < b›*)) also (*calculation: ‹((λx. (frac x - 1 / 2) *⇩R f' x) has_integral (∑I∈(λn. {real_of_int n..real_of_int (n + 1)}) ` {a..<b}. d (real_of_int ⌊Inf I⌋))) {real_of_int a..real_of_int b}›*) have "(∑I∈?A. d (⌊Inf I⌋)) = (∑i=a..<b. d i)" apply (subst sum.reindex (*‹inj_on ?h ?A ⟹ sum ?g (?h ` ?A) = sum (?g ∘ ?h) ?A›*)) (*goals: 1. ‹inj_on (λn. {real_of_int n..real_of_int (n + 1)}) {a..<b}› 2. ‹sum ((λI. d (real_of_int ⌊Inf I⌋)) ∘ (λn. {real_of_int n..real_of_int (n + 1)})) {a..<b} = (∑i = a..<b. d (real_of_int i))› 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*) . also (*calculation: ‹((λx. (frac x - 1 / 2) *⇩R f' x) has_integral (∑i = a..<b. d (real_of_int i))) {real_of_int a..real_of_int b}›*) have "… = (1 / 2) *⇩R ((∑i = a..<b. f (real_of_int i)) + (∑i = a..<b. f (real_of_int (i + 1)))) - (∑i = a..<b. integral {real_of_int i..1 + real_of_int i} f)" (is "_ = _ *⇩R (?S1 + ?S2) - ?S3") by (simp add: d_def (*‹d = (λx. (f x + f (x + 1)) /⇩R 2 - integral {x..x + 1} f)›*) 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*) sum.distrib (*‹(∑x∈?A. ?g x + ?h x) = sum ?g ?A + sum ?h ?A›*) sum_subtractf (*‹(∑x∈?A. ?f x - ?g x) = sum ?f ?A - sum ?g ?A›*) scaleR_sum_right (*‹?a *⇩R sum ?f ?A = (∑x∈?A. ?a *⇩R ?f x)›*)) also (*calculation: ‹((λx. (frac x - 1 / 2) *⇩R f' x) has_integral (1 / 2) *⇩R ((∑i = a..<b. f (real_of_int i)) + (∑i = a..<b. f (real_of_int (i + 1)))) - (∑i = a..<b. integral {real_of_int i..1 + real_of_int i} f)) {real_of_int a..real_of_int b}›*) have "?S1 = (∑i = a..b. f (real_of_int i)) - f b" unfolding S_def (*goal: ‹(∑i = a..<b. f (real_of_int i)) = (∑i = a..b. f (real_of_int i)) - f (real_of_int b)›*) using ab (*‹a < b›*) apply (subst sum_atLeastAtMost_int_last (*‹?a < ?b ⟹ sum ?f {?a..?b} = sum ?f {?a..<?b} + ?f ?b›*)) (*goals: 1. ‹a < b ⟹ a < b› 2. ‹a < b ⟹ (∑i = a..<b. f (real_of_int i)) = (∑i = a..<b. f (real_of_int i)) + f (real_of_int b) - f (real_of_int b)› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . also (*calculation: ‹((λx. (frac x - 1 / 2) *⇩R f' x) has_integral (1 / 2) *⇩R ((∑i = a..b. f (real_of_int i)) - f (real_of_int b) + (∑i = a..<b. f (real_of_int (i + 1)))) - (∑i = a..<b. integral {real_of_int i..1 + real_of_int i} f)) {real_of_int a..real_of_int b}›*) have "(∑i = a..b. f (real_of_int i)) = S + f a" unfolding S_def (*goal: ‹(∑i::int = a::int..b::int. (f::real ⇒ 'a) (real_of_int i)) = (∑i::int∈{a<..b}. f (real_of_int i)) + f (real_of_int a)›*) using ab (*‹a < b›*) apply (subst sum_atLeastAtMost_int_head (*‹?a < ?b ⟹ sum ?f {?a..?b} = ?f ?a + sum ?f {?a<..?b}›*)) (*goals: 1. ‹a < b ⟹ a < b› 2. ‹a < b ⟹ f (real_of_int a) + (∑i∈{a<..b}. f (real_of_int i)) = (∑i∈{a<..b}. f (real_of_int i)) + f (real_of_int a)› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . also (*calculation: ‹((λx. (frac x - 1 / 2) *⇩R f' x) has_integral (1 / 2) *⇩R (S + f (real_of_int a) - f (real_of_int b) + (∑i = a..<b. f (real_of_int (i + 1)))) - (∑i = a..<b. integral {real_of_int i..1 + real_of_int i} f)) {real_of_int a..real_of_int b}›*) have "?S2 = S" unfolding S_def (*goal: ‹(∑i = a..<b. f (real_of_int (i + 1))) = (∑i∈{a<..b}. f (real_of_int i))›*) apply (intro sum.reindex_bij_witness[of _ "λi. i-1" "λi. i+1"] (*‹⟦⋀a. a ∈ ?S ⟹ a + 1 - 1 = a; ⋀a. a ∈ ?S ⟹ a + 1 ∈ ?T; ⋀b. b ∈ ?T ⟹ b - 1 + 1 = b; ⋀b. b ∈ ?T ⟹ b - 1 ∈ ?S; ⋀a. a ∈ ?S ⟹ ?h (a + 1) = ?g a⟧ ⟹ sum ?g ?S = sum ?h ?T›*)) (*goals: 1. ‹⋀aa. aa ∈ {a..<b} ⟹ aa + 1 - 1 = aa› 2. ‹⋀aa. aa ∈ {a..<b} ⟹ aa + 1 ∈ {a<..b}› 3. ‹⋀ba. ba ∈ {a<..b} ⟹ ba - 1 + 1 = ba› 4. ‹⋀ba. ba ∈ {a<..b} ⟹ ba - 1 ∈ {a..<b}› 5. ‹⋀aa. aa ∈ {a..<b} ⟹ f (real_of_int (aa + 1)) = f (real_of_int (aa + 1))› 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*) . also (*calculation: ‹((λx. (frac x - 1 / 2) *⇩R f' x) has_integral (1 / 2) *⇩R (S + f (real_of_int a) - f (real_of_int b) + S) - (∑i = a..<b. integral {real_of_int i..1 + real_of_int i} f)) {real_of_int a..real_of_int b}›*) have "(1 / 2) *⇩R (S + f a - f b + S) = (1/2) *⇩R S + (1/2) *⇩R S - (f b - f a) /⇩R 2" 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 34 facts*)) also (*calculation: ‹((λx::real. (frac x - (1::real) / (2::real)) *⇩R (f'::real ⇒ 'a) x) has_integral ((1::real) / (2::real)) *⇩R (S::'a) + ((1::real) / (2::real)) *⇩R S - ((f::real ⇒ 'a) (real_of_int (b::int)) - f (real_of_int (a::int))) /⇩R (2::real) - (∑i::int = a..<b. integral {real_of_int i..(1::real) + real_of_int i} f)) {real_of_int a..real_of_int b}›*) have "(1/2) *⇩R S + (1/2) *⇩R S = S" by (simp add: scaleR_add_right [symmetric] (*‹?a *⇩R ?x + ?a *⇩R ?y = ?a *⇩R (?x + ?y)›*)) also (*calculation: ‹((λx::real. (frac x - (1::real) / (2::real)) *⇩R (f'::real ⇒ 'a::banach) x) has_integral (S::'a::banach) - ((f::real ⇒ 'a::banach) (real_of_int (b::int)) - f (real_of_int (a::int))) /⇩R (2::real) - (∑i::int = a..<b. integral {real_of_int i..(1::real) + real_of_int i} f)) {real_of_int a..real_of_int b}›*) have "?S3 = (∑I∈?A. integral I f)" apply (subst sum.reindex (*‹inj_on ?h ?A ⟹ sum ?g (?h ` ?A) = sum (?g ∘ ?h) ?A›*)) (*goals: 1. ‹inj_on (λn::int. {real_of_int n..real_of_int (n + (1::int))}) {a::int..<b::int}› 2. ‹(∑i::int = a::int..<b::int. integral {real_of_int i..(1::real) + real_of_int i} (f::real ⇒ 'a)) = sum ((λI::real set. integral I f) ∘ (λn::int. {real_of_int n..real_of_int (n + (1::int))})) {a..<b}› discuss goal 1*) apply ((auto simp: inj_on_def (*‹inj_on ?f ?A = (∀x∈?A. ∀y∈?A. ?f x = ?f y ⟶ x = y)›*) 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: inj_on_def (*‹inj_on ?f ?A = (∀x∈?A. ∀y∈?A. ?f x = ?f y ⟶ x = y)›*) add_ac (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)›*))[1]) (*proven 2 subgoals*) . also (*calculation: ‹((λx. (frac x - 1 / 2) *⇩R f' x) has_integral S - (f (real_of_int b) - f (real_of_int a)) /⇩R 2 - (∑I∈(λn. {real_of_int n..real_of_int (n + 1)}) ` {a..<b}. integral I f)) {real_of_int a..real_of_int b}›*) have "… = I" unfolding I_def (*goal: ‹(∑I∈(λn. {real_of_int n..real_of_int (n + 1)}) ` {a..<b}. integral I f) = integral {real_of_int a..real_of_int b} f›*) apply (intro integral_combine_division_topdown [symmetric] (*‹⟦?f integrable_on ?S; ?𝒟 division_of ?S⟧ ⟹ (∑i∈?𝒟. integral i ?f) = integral ?S ?f›*) division (*‹(λn. {real_of_int n..real_of_int (n + 1)}) ` {a..<b} division_of {real_of_int a..real_of_int 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 273 facts*)) (*goal: ‹(∑I::real set∈(λn::int. {real_of_int n..real_of_int (n + (1::int))}) ` {a::int..<b::int}. integral I (f::real ⇒ 'a)) = integral {real_of_int a..real_of_int b} f›*) by simp finally (*calculation: ‹((λx. (frac x - 1 / 2) *⇩R f' x) has_integral S - (f (real_of_int b) - f (real_of_int a)) /⇩R 2 - I) {real_of_int a..real_of_int b}›*) show "?thesis" (*goal: ‹((λt::real. (frac t - (1::real) / (2::real)) *⇩R (f'::real ⇒ 'a::banach) t) has_integral (S::'a::banach) - (I::'a::banach) - ((f::real ⇒ 'a::banach) (real_of_int (b::int)) - f (real_of_int (a::int))) /⇩R (2::real)) {real_of_int a..real_of_int 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 diff_sum_integral_has_integral_int': "((λt. pbernpoly 1 t *⇩R f' t) has_integral (S - I - (f b - f a) /⇩R 2 )) {a..b}" using diff_sum_integral_has_integral_int (*‹((λt. (frac t - 1 / 2) *⇩R f' t) has_integral S - I - (f (real_of_int b) - f (real_of_int a)) /⇩R 2) {real_of_int a..real_of_int b}›*) by (simp add: pbernpoly_def (*‹pbernpoly ?n ?x = bernpoly ?n (frac ?x)›*) bernpoly_def (*‹bernpoly ?n = (λx. ∑k≤?n. of_nat (?n choose k) * of_real (bernoulli k) * x ^ (?n - k))›*)) lemma EM_remainder'_Suc_0: "EM_remainder' (Suc 0) f' a b = S - I - (f b - f a) /⇩R 2" using diff_sum_integral_has_integral_int' (*‹((λt. pbernpoly 1 t *⇩R f' t) has_integral S - I - (f (real_of_int b) - f (real_of_int a)) /⇩R 2) {real_of_int a..real_of_int b}›*) by (simp add: has_integral_iff (*‹(?f has_integral ?i) ?S = (?f integrable_on ?S ∧ integral ?S ?f = ?i)›*) EM_remainder'_def (*‹EM_remainder' ?n ?f ?a ?b = ((- 1) ^ Suc ?n / fact ?n) *⇩R integral {?a..?b} (λt. pbernpoly ?n t *⇩R ?f t)›*)) end text ‹ Next, we show that the $n$-th-order remainder can be expressed in terms of the $n+1$-th-order remainder term. Iterating this essentially yields the Euler--MacLaurin formula. › context fixes f f' :: "real ⇒ 'a :: banach" and a b :: int and n :: nat and A :: "real set" assumes ab: "a ≤ b" and n: "n > 0" assumes fin: "finite A" assumes cont: "continuous_on {of_int a..of_int b} f" assumes cont': "continuous_on {of_int a..of_int b} f'" assumes deriv: "⋀x. x ∈ {of_int a<..<of_int b} - A ⟹ (f has_vector_derivative f' x) (at x)" begin lemma EM_remainder'_integral_conv_Suc: shows "integral {a..b} (λt. pbernpoly n t *⇩R f t) = (bernoulli (Suc n) / real (Suc n)) *⇩R (f b - f a) - integral {a..b} (λt. pbernpoly (Suc n) t *⇩R f' t) /⇩R real (Suc n)" unfolding EM_remainder'_def (*goal: ‹integral {real_of_int a..real_of_int b} (λt. pbernpoly n t *⇩R f t) = (bernoulli (Suc n) / real (Suc n)) *⇩R (f (real_of_int b) - f (real_of_int a)) - integral {real_of_int a..real_of_int b} (λt. pbernpoly (Suc n) t *⇩R f' t) /⇩R real (Suc n)›*) proof (-) (*goal: ‹integral {real_of_int a..real_of_int b} (λt. pbernpoly n t *⇩R f t) = (bernoulli (Suc n) / real (Suc n)) *⇩R (f (real_of_int b) - f (real_of_int a)) - integral {real_of_int a..real_of_int b} (λt. pbernpoly (Suc n) t *⇩R f' t) /⇩R real (Suc n)›*) let ?h = "λi. (pbernpoly (Suc n) (real_of_int i) / real (Suc n)) *⇩R f (real_of_int i)" define T where "T = integral {a..b} (λt. (pbernpoly (Suc n) t / real (Suc n)) *⇩R f' t)" note [derivative_intros] = has_field_derivative_pbernpoly_Suc' (*‹⟦(?f has_real_derivative ?D) (at ?x within ?s); 2 ≤ ?n ∨ ?f ?x ∉ ℤ⟧ ⟹ ((λx. pbernpoly (Suc ?n) (?f x)) has_real_derivative real (Suc ?n) * pbernpoly ?n (?f ?x) * ?D) (at ?x within ?s)›*) let ?A = "real_of_int ` {a..b} ∪ A" have "((λt. pbernpoly n t *⇩R f t) has_integral (-T + (?h b - ?h a))) {a..b}" proof (rule integration_by_parts_interior_strong[OF bounded_bilinear_scaleR] (*‹⟦finite ?s; ?a ≤ ?b; continuous_on {?a..?b} ?f; continuous_on {?a..?b} ?g; ⋀x. x ∈ {?a<..<?b} - ?s ⟹ (?f has_vector_derivative ?f' x) (at x); ⋀x. x ∈ {?a<..<?b} - ?s ⟹ (?g has_vector_derivative ?g' x) (at x); ((λx. ?f x *⇩R ?g' x) has_integral ?f ?b *⇩R ?g ?b - ?f ?a *⇩R ?g ?a - ?y) {?a..?b}⟧ ⟹ ((λx. ?f' x *⇩R ?g x) has_integral ?y) {?a..?b}›*)) (*goals: 1. ‹finite ?s› 2. ‹real_of_int a ≤ real_of_int b› 3. ‹continuous_on {real_of_int a..real_of_int b} ?f› 4. ‹continuous_on {real_of_int a..real_of_int b} f› 5. ‹⋀t. t ∈ {real_of_int a<..<real_of_int b} - ?s ⟹ (?f has_vector_derivative pbernpoly n t) (at t)› 6. ‹⋀t. t ∈ {real_of_int a<..<real_of_int b} - ?s ⟹ (f has_vector_derivative ?g' t) (at t)› 7. ‹((λt. ?f t *⇩R ?g' t) has_integral ?f (real_of_int b) *⇩R f (real_of_int b) - ?f (real_of_int a) *⇩R f (real_of_int a) - (- T + ((pbernpoly (Suc n) (real_of_int b) / real (Suc n)) *⇩R f (real_of_int b) - (pbernpoly (Suc n) (real_of_int a) / real (Suc n)) *⇩R f (real_of_int a)))) {real_of_int a..real_of_int b}›*) from fin (*‹finite A›*) show "finite ?A" by simp from ‹n > 0› (*‹0 < n›*) show "continuous_on {of_int a..of_int b} (λt. pbernpoly (Suc n) t / real (Suc n))" apply (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 272 facts*)) (*goals: 1. ‹0 < n ⟹ Suc n ≠ 1› 2. ‹0 < n ⟹ ∀t∈{real_of_int a..real_of_int b}. real (Suc n) ≠ 0› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . show "continuous_on {of_int a..of_int b} f" by fact show "(f has_vector_derivative f' t) (at t)" if "t ∈ {of_int a<..<of_int b} - ?A" for t using deriv[of t] (*‹t ∈ {real_of_int a<..<real_of_int b} - A ⟹ (f has_vector_derivative f' t) (at t)›*) that (*‹t ∈ {real_of_int a<..<real_of_int b} - (real_of_int ` {a..b} ∪ A)›*) by auto have "(λt. pbernpoly (Suc n) t *⇩R f' t) integrable_on {a..b}" by (intro integrable_EM_remainder' (*‹continuous_on {?a..?b} ?f ⟹ (λt. pbernpoly ?n t *⇩R ?f t) integrable_on {?a..?b}›*) cont' (*‹continuous_on {real_of_int a..real_of_int b} f'›*)) hence "(λt. (1 / real (Suc n)) *⇩R pbernpoly (Suc n) t *⇩R f' t) integrable_on {a..b}" by (rule integrable_cmul (*‹?f integrable_on ?S ⟹ (λx. ?c *⇩R ?f x) integrable_on ?S›*)) also (*calculation: ‹(λt. (1 / real (Suc n)) *⇩R pbernpoly (Suc n) t *⇩R f' t) integrable_on {real_of_int a..real_of_int b}›*) have "(λt. (1 / real (Suc n)) *⇩R pbernpoly (Suc n) t *⇩R f' t) = (λt. (pbernpoly (Suc n) t / real (Suc n)) *⇩R f' t)" apply (rule ext (*‹(⋀x. ?f x = ?g x) ⟹ ?f = ?g›*)) (*goal: ‹(λt. (1 / real (Suc n)) *⇩R pbernpoly (Suc n) t *⇩R f' t) = (λt. (pbernpoly (Suc n) t / real (Suc n)) *⇩R f' 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*)) finally (*calculation: ‹(λt. (pbernpoly (Suc n) t / real (Suc n)) *⇩R f' t) integrable_on {real_of_int a..real_of_int b}›*) show "((λt. (pbernpoly (Suc n) t / real (Suc n)) *⇩R f' t) has_integral ?h b - ?h a - (- T + (?h b - ?h a))) {a..b}" using integrable_EM_remainder'[of a b f' "Suc n"] (*‹continuous_on {real_of_int a..real_of_int b} f' ⟹ (λt. pbernpoly (Suc n) t *⇩R f' t) integrable_on {real_of_int a..real_of_int b}›*) by (simp add: has_integral_iff (*‹(?f has_integral ?i) ?S = (?f integrable_on ?S ∧ integral ?S ?f = ?i)›*) T_def (*‹T = integral {real_of_int a..real_of_int b} (λt. (pbernpoly (Suc n) t / real (Suc n)) *⇩R f' t)›*)) qed (insert ab (*‹a ≤ b›*) n (*‹0 < n›*), 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 136 facts*) simp: has_real_derivative_iff_has_vector_derivative [symmetric] (*‹((?f::real ⇒ real) has_vector_derivative (?y::real)) (?F::real filter) = (?f has_real_derivative ?y) ?F›*) not_le (*‹(¬ (?x::?'a::linorder) ≤ (?y::?'a::linorder)) = (?y < ?x)›*) elim!: Ints_cases (*‹⟦(?q::?'a::ring_1) ∈ ℤ; ⋀z::int. ?q = of_int z ⟹ ?thesis::bool⟧ ⟹ ?thesis›*)) (*solves the remaining goals: 1. ‹real_of_int a ≤ real_of_int b› 2. ‹⋀t. t ∈ {real_of_int a<..<real_of_int b} - (real_of_int ` {a..b} ∪ A) ⟹ ((λt. pbernpoly (Suc n) t / real (Suc n)) has_vector_derivative pbernpoly n t) (at t)›*) also (*calculation: ‹((λt. pbernpoly n t *⇩R f t) has_integral - T + ((pbernpoly (Suc n) (real_of_int b) / real (Suc n)) *⇩R f (real_of_int b) - (pbernpoly (Suc n) (real_of_int a) / real (Suc n)) *⇩R f (real_of_int a))) {real_of_int a..real_of_int b}›*) have "?h b - ?h a = (bernoulli (Suc n) / real (Suc n)) *⇩R (f b - f a)" using n (*‹0 < 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*) bernoulli'_def (*‹bernoulli' ?n = (if ?n = 1 then 1 / 2 else bernoulli ?n)›*)) finally (*calculation: ‹((λt. pbernpoly n t *⇩R f t) has_integral - T + (bernoulli (Suc n) / real (Suc n)) *⇩R (f (real_of_int b) - f (real_of_int a))) {real_of_int a..real_of_int b}›*) have "integral {a..b} (λt. pbernpoly n t *⇩R f t) = … - T" by (simp add: has_integral_iff (*‹(?f has_integral ?i) ?S = (?f integrable_on ?S ∧ integral ?S ?f = ?i)›*)) also (*calculation: ‹integral {real_of_int a..real_of_int b} (λt. pbernpoly n t *⇩R f t) = (bernoulli (Suc n) / real (Suc n)) *⇩R (f (real_of_int b) - f (real_of_int a)) - T›*) have "T = integral {a..b} (λt. (1 / real (Suc n)) *⇩R (pbernpoly (Suc n) t) *⇩R f' t)" by (simp add: T_def (*‹T = integral {real_of_int a..real_of_int b} (λt. (pbernpoly (Suc n) t / real (Suc n)) *⇩R f' t)›*)) also (*calculation: ‹integral {real_of_int a..real_of_int b} (λt. pbernpoly n t *⇩R f t) = (bernoulli (Suc n) / real (Suc n)) *⇩R (f (real_of_int b) - f (real_of_int a)) - integral {real_of_int a..real_of_int b} (λt. (1 / real (Suc n)) *⇩R pbernpoly (Suc n) t *⇩R f' t)›*) have "… = integral {a..b} (λt. pbernpoly (Suc n) t *⇩R f' t) /⇩R real (Suc n)" apply (subst integral_cmul (*‹integral ?S (λx. ?c *⇩R ?f x) = ?c *⇩R integral ?S ?f›*)) (*goal: ‹integral {real_of_int a..real_of_int b} (λt. (1 / real (Suc n)) *⇩R pbernpoly (Suc n) t *⇩R f' t) = integral {real_of_int a..real_of_int b} (λt. pbernpoly (Suc n) t *⇩R f' t) /⇩R real (Suc 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*)) finally (*calculation: ‹integral {real_of_int (a::int)..real_of_int (b::int)} (λt::real. pbernpoly (n::nat) t *⇩R (f::real ⇒ 'a::banach) t) = (bernoulli (Suc n) / real (Suc n)) *⇩R (f (real_of_int b) - f (real_of_int a)) - integral {real_of_int a..real_of_int b} (λt::real. pbernpoly (Suc n) t *⇩R (f'::real ⇒ 'a::banach) t) /⇩R real (Suc n)›*) show "?thesis" (*goal: ‹integral {real_of_int a..real_of_int b} (λt. pbernpoly n t *⇩R f t) = (bernoulli (Suc n) / real (Suc n)) *⇩R (f (real_of_int b) - f (real_of_int a)) - integral {real_of_int a..real_of_int b} (λt. pbernpoly (Suc n) t *⇩R f' t) /⇩R real (Suc n)›*) . qed lemma EM_remainder'_conv_Suc: "EM_remainder' n f a b = ((-1) ^ Suc n * bernoulli (Suc n) / fact (Suc n)) *⇩R (f b - f a) + EM_remainder' (Suc n) f' a b" by (simp add: EM_remainder'_def (*‹EM_remainder' ?n ?f ?a ?b = ((- 1) ^ Suc ?n / fact ?n) *⇩R integral {?a..?b} (λt. pbernpoly ?n t *⇩R ?f t)›*) EM_remainder'_integral_conv_Suc (*‹integral {real_of_int a..real_of_int b} (λt. pbernpoly n t *⇩R f t) = (bernoulli (Suc n) / real (Suc n)) *⇩R (f (real_of_int b) - f (real_of_int a)) - integral {real_of_int a..real_of_int b} (λt. pbernpoly (Suc n) t *⇩R f' t) /⇩R real (Suc n)›*) scaleR_diff_right (*‹?a *⇩R (?x - ?y) = ?a *⇩R ?x - ?a *⇩R ?y›*) scaleR_add_right (*‹?a *⇩R (?x + ?y) = ?a *⇩R ?x + ?a *⇩R ?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*) del: of_nat_Suc (*‹of_nat (Suc ?m) = 1 + of_nat ?m›*)) end context fixes f f' :: "real ⇒ 'a :: banach" and a :: int and n :: nat and A :: "real set" and C assumes n: "n > 0" assumes fin: "finite A" assumes cont: "continuous_on {of_int a..} f" assumes cont': "continuous_on {of_int a..} f'" assumes lim: "(f ⤏ C) at_top" assumes deriv: "⋀x. x ∈ {of_int a<..} - A ⟹ (f has_vector_derivative f' x) (at x)" begin lemma shows EM_remainder_converges_iff_Suc_converges: "EM_remainder_converges n f a ⟷ EM_remainder_converges (Suc n) f' a" and EM_remainder_conv_Suc: "EM_remainder_converges n f a ⟹ EM_remainder n f a = ((-1) ^ Suc n * bernoulli (Suc n) / fact (Suc n)) *⇩R (C - f a) + EM_remainder (Suc n) f' a" proof (rule iffI (*‹⟦?P ⟹ ?Q; ?Q ⟹ ?P⟧ ⟹ ?P = ?Q›*)) (*goals: 1. ‹EM_remainder_converges (n::nat) (f::real ⇒ 'a) (a::int) ⟹ EM_remainder_converges (Suc n) (f'::real ⇒ 'a) a› 2. ‹EM_remainder_converges (Suc (n::nat)) (f'::real ⇒ 'a) (a::int) ⟹ EM_remainder_converges n (f::real ⇒ 'a) a› 3. ‹EM_remainder_converges (n::nat) (f::real ⇒ 'a) (a::int) ⟹ EM_remainder n f a = ((- (1::real)) ^ Suc n * bernoulli (Suc n) / fact (Suc n)) *⇩R ((C::'a) - f (real_of_int a)) + EM_remainder (Suc n) (f'::real ⇒ 'a) a›*) define g where "g = (λx. ((-1) ^ Suc n * bernoulli (Suc n) / fact (Suc n)) *⇩R (f x - f a))" define G where "G = ((-1) ^ Suc n * bernoulli (Suc n) / fact (Suc n)) *⇩R (C - f a)" have limit_g: "(g ⤏ G) at_top" unfolding g_def G_def (*goal: ‹((λx. ((- 1) ^ Suc n * bernoulli (Suc n) / fact (Suc n)) *⇩R (f x - f (real_of_int a))) ⤏ ((- 1) ^ Suc n * bernoulli (Suc n) / fact (Suc n)) *⇩R (C - f (real_of_int a))) at_top›*) 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 104 facts*) lim (*‹(f ⤏ C) at_top›*)) have "*": "eventually (λx. EM_remainder' n f (real_of_int a) (real_of_int x) = g x + EM_remainder' (Suc n) f' (real_of_int a) (real_of_int x)) at_top" using eventually_ge_at_top[of a] (*‹eventually ((≤) a) at_top›*) proof (eventually_elim) (*goal: ‹⋀x. a ≤ x ⟹ EM_remainder' n f (real_of_int a) (real_of_int x) = g (real_of_int x) + EM_remainder' (Suc n) f' (real_of_int a) (real_of_int x)›*) case (elim b) (*‹a ≤ b›*) thus "?case" (*goal: ‹EM_remainder' n f (real_of_int a) (real_of_int b) = g (real_of_int b) + EM_remainder' (Suc n) f' (real_of_int a) (real_of_int b)›*) using EM_remainder'_conv_Suc[OF elim n fin continuous_on_subset [ OF cont ] continuous_on_subset [ OF cont' ] deriv] (*‹⟦{real_of_int a..real_of_int b} ⊆ {real_of_int a..}; {real_of_int a..real_of_int b} ⊆ {real_of_int a..}; ⋀x. x ∈ {real_of_int a<..<real_of_int b} - A ⟹ x ∈ {real_of_int a<..} - A⟧ ⟹ EM_remainder' n f (real_of_int a) (real_of_int b) = ((- 1) ^ Suc n * bernoulli (Suc n) / fact (Suc n)) *⇩R (f (real_of_int b) - f (real_of_int a)) + EM_remainder' (Suc n) f' (real_of_int a) (real_of_int b)›*) by (auto simp: g_def (*‹(g::real ⇒ 'a) = (λx::real. ((- (1::real)) ^ Suc (n::nat) * bernoulli (Suc n) / fact (Suc n)) *⇩R ((f::real ⇒ 'a) x - f (real_of_int (a::int))))›*)) qed { assume "EM_remainder_converges n f a" (*‹EM_remainder_converges (n::nat) (f::real ⇒ 'a) (a::int)›*) then obtain L where L: "((λb. EM_remainder' n f (real_of_int a) (real_of_int b)) ⤏ L) at_top" (*goal: ‹(⋀L::'a::banach. ((λb::int. EM_remainder' (n::nat) (f::real ⇒ 'a::banach) (real_of_int (a::int)) (real_of_int b)) ⤏ L) at_top ⟹ thesis::bool) ⟹ thesis›*) by (auto simp: EM_remainder_converges_def (*‹EM_remainder_converges ?n ?f ?a = (∃L. ((λx. EM_remainder' ?n ?f (real_of_int ?a) (real_of_int x)) ⤏ L) at_top)›*)) have "*": "((λb. EM_remainder' (Suc n) f' (real_of_int a) (real_of_int b)) ⤏ L - G) at_top" proof (rule Lim_transform_eventually (*‹⟦((?f::?'a::type ⇒ ?'b::topological_space) ⤏ (?l::?'b::topological_space)) (?F::?'a::type filter); ∀⇩F x::?'a::type in ?F. ?f x = (?g::?'a::type ⇒ ?'b::topological_space) x⟧ ⟹ (?g ⤏ ?l) ?F›*)) (*goals: 1. ‹(?f ⤏ L - G) at_top› 2. ‹∀⇩F x in at_top. ?f x = EM_remainder' (Suc n) f' (real_of_int a) (real_of_int x)›*) show "∀⇩F x in at_top. EM_remainder' n f (real_of_int a) (real_of_int x) - g x = EM_remainder' (Suc n) f' (real_of_int a) (real_of_int x)" using "*" (*‹∀⇩F x in at_top. EM_remainder' n f (real_of_int a) (real_of_int x) = g (real_of_int x) + EM_remainder' (Suc n) f' (real_of_int a) (real_of_int x)›*) 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*)) show "((λx. EM_remainder' n f (real_of_int a) (real_of_int x) - g x) ⤏ L - G) at_top" 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 104 facts*) filterlim_compose[OF limit_g] (*‹filterlim ?f at_top ?F1.0 ⟹ ((λx. g (?f x)) ⤏ G) ?F1.0›*) L (*‹((λb. EM_remainder' n f (real_of_int a) (real_of_int b)) ⤏ L) at_top›*)) qed from "*" (*‹((λb. EM_remainder' (Suc n) f' (real_of_int a) (real_of_int b)) ⤏ L - G) at_top›*) show "EM_remainder_converges (Suc n) f' a" unfolding EM_remainder_converges_def (*goal: ‹∃L. ((λx. EM_remainder' (Suc n) f' (real_of_int a) (real_of_int x)) ⤏ L) at_top›*) by standard from "*" (*‹((λb::int. EM_remainder' (Suc (n::nat)) (f'::real ⇒ 'a) (real_of_int (a::int)) (real_of_int b)) ⤏ (L::'a) - (G::'a)) at_top›*) have "EM_remainder (Suc n) f' a = L - G" by (rule EM_remainder_eqI (*‹((λx. EM_remainder' ?n ?f (real_of_int ?b) (real_of_int x)) ⤏ ?L) at_top ⟹ EM_remainder ?n ?f ?b = ?L›*)) moreover from L (*‹((λb::int. EM_remainder' (n::nat) (f::real ⇒ 'a) (real_of_int (a::int)) (real_of_int b)) ⤏ (L::'a)) at_top›*) have "EM_remainder n f a = L" by (rule EM_remainder_eqI (*‹((λx. EM_remainder' ?n ?f (real_of_int ?b) (real_of_int x)) ⤏ ?L) at_top ⟹ EM_remainder ?n ?f ?b = ?L›*)) ultimately show "EM_remainder n f a = G + EM_remainder (Suc n) f' a" by (simp add: G_def (*‹(G::'a) = ((- (1::real)) ^ Suc (n::nat) * bernoulli (Suc n) / fact (Suc n)) *⇩R ((C::'a) - (f::real ⇒ 'a) (real_of_int (a::int)))›*)) } { assume "EM_remainder_converges (Suc n) f' a" (*‹EM_remainder_converges (Suc (n::nat)) (f'::real ⇒ 'a) (a::int)›*) then obtain L where L: "((λb. EM_remainder' (Suc n) f' (real_of_int a) (real_of_int b)) ⤏ L) at_top" (*goal: ‹(⋀L. ((λb. EM_remainder' (Suc n) f' (real_of_int a) (real_of_int b)) ⤏ L) at_top ⟹ thesis) ⟹ thesis›*) by (auto simp: EM_remainder_converges_def (*‹EM_remainder_converges ?n ?f ?a = (∃L. ((λx. EM_remainder' ?n ?f (real_of_int ?a) (real_of_int x)) ⤏ L) at_top)›*)) have "*": "((λb. EM_remainder' n f (real_of_int a) (real_of_int b)) ⤏ G + L) at_top" proof (rule Lim_transform_eventually (*‹⟦((?f::?'a::type ⇒ ?'b::topological_space) ⤏ (?l::?'b::topological_space)) (?F::?'a::type filter); ∀⇩F x::?'a::type in ?F. ?f x = (?g::?'a::type ⇒ ?'b::topological_space) x⟧ ⟹ (?g ⤏ ?l) ?F›*)) (*goals: 1. ‹(?f ⤏ G + L) at_top› 2. ‹∀⇩F x in at_top. ?f x = EM_remainder' n f (real_of_int a) (real_of_int x)›*) show "∀⇩F x in at_top. g x + EM_remainder' (Suc n) f' (real_of_int a) (real_of_int x) = EM_remainder' n f (real_of_int a) (real_of_int x)" using "*" (*‹∀⇩F x::int in at_top. EM_remainder' (n::nat) (f::real ⇒ 'a) (real_of_int (a::int)) (real_of_int x) = (g::real ⇒ 'a) (real_of_int x) + EM_remainder' (Suc n) (f'::real ⇒ 'a) (real_of_int a) (real_of_int x)›*) by (subst eq_commute (*‹(?a = ?b) = (?b = ?a)›*)) show "((λx. g x + EM_remainder' (Suc n) f' (real_of_int a) (real_of_int x)) ⤏ G + L) at_top" 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 104 facts*) filterlim_compose[OF limit_g] (*‹filterlim ?f at_top ?F1.0 ⟹ ((λx. g (?f x)) ⤏ G) ?F1.0›*) L (*‹((λb. EM_remainder' (Suc n) f' (real_of_int a) (real_of_int b)) ⤏ L) at_top›*)) qed thus "EM_remainder_converges n f a" unfolding EM_remainder_converges_def (*goal: ‹∃L. ((λx. EM_remainder' n f (real_of_int a) (real_of_int x)) ⤏ L) at_top›*) by standard } qed end subsection ‹The conventional version of the Euler--MacLaurin formula› text ‹ The following theorems are the classic Euler--MacLaurin formula that can be found, with slight variations, in many sources (e.\,g.\ \<^cite>‹"AS_HMF" and "apostol99" and "GKP_CM"›). › context fixes f :: "real ⇒ 'a :: banach" fixes fs :: "nat ⇒ real ⇒ 'a" fixes a b :: int assumes ab: "a ≤ b" fixes N :: nat assumes N: "N > 0" fixes Y :: "real set" assumes fin: "finite Y" assumes fs_0 [simp]: "fs 0 = f" assumes fs_cont [continuous_intros]: "⋀k. k ≤ N ⟹ continuous_on {real_of_int a..real_of_int b} (fs k)" assumes fs_deriv [derivative_intros]: "⋀k x. k < N ⟹ x ∈ {a..b} - Y ⟹ (fs k has_vector_derivative fs (Suc k) x) (at x)" begin theorem euler_maclaurin_raw_strong_int: defines "S ≡ (∑i∈{a<..b}. f (of_int i))" defines "I ≡ integral {of_int a..of_int b} f" defines "c' ≡ λk. (bernoulli' (Suc k) / fact (Suc k)) *⇩R (fs k b - fs k a)" shows "S - I = (∑k<N. c' k) + EM_remainder' N (fs N) a b" proof (-) (*goal: ‹(S::'a) - (I::'a) = sum (c'::nat ⇒ 'a) {..<N::nat} + EM_remainder' N ((fs::nat ⇒ real ⇒ 'a) N) (real_of_int (a::int)) (real_of_int (b::int))›*) define c :: "nat ⇒ 'a" where "c = (λk. ((-1) ^ (Suc k) * bernoulli (Suc k) / fact (Suc k)) *⇩R (fs k b - fs k a))" have "S - I = (∑k<m. c k) + EM_remainder' m (fs m) a b" if "m ≥ 1" "m ≤ N" for m using that (*‹(1::nat) ≤ (m::nat)› ‹m ≤ N›*) proof (induction m rule: dec_induct (*‹⟦(?i::nat) ≤ (?j::nat); (?P::nat ⇒ bool) ?i; ⋀n::nat. ⟦?i ≤ n; n < ?j; ?P n⟧ ⟹ ?P (Suc n)⟧ ⟹ ?P ?j›*)) (*goals: 1. ‹(1::nat) ≤ (N::nat) ⟹ (S::'a) - (I::'a) = sum (c::nat ⇒ 'a) {..<1::nat} + EM_remainder' (1::nat) ((fs::nat ⇒ real ⇒ 'a) (1::nat)) (real_of_int (a::int)) (real_of_int (b::int))› 2. ‹⋀n::nat. ⟦(1::nat) ≤ n; n < (m::nat); n ≤ (N::nat) ⟹ (S::'a) - (I::'a) = sum (c::nat ⇒ 'a) {..<n} + EM_remainder' n ((fs::nat ⇒ real ⇒ 'a) n) (real_of_int (a::int)) (real_of_int (b::int)); Suc n ≤ N⟧ ⟹ S - I = sum c {..<Suc n} + EM_remainder' (Suc n) (fs (Suc n)) (real_of_int a) (real_of_int b)›*) case base (*‹1 ≤ N›*) with ab (*‹(a::int) ≤ (b::int)›*) fin (*‹finite Y›*) fs_cont[of 0] (*‹0 ≤ N ⟹ continuous_on {real_of_int a..real_of_int b} (fs 0)›*) show "?case" (*goal: ‹(S::'a::banach) - (I::'a::banach) = sum (c::nat ⇒ 'a::banach) {..<1::nat} + EM_remainder' (1::nat) ((fs::nat ⇒ real ⇒ 'a::banach) (1::nat)) (real_of_int (a::int)) (real_of_int (b::int))›*) using fs_deriv[of 0] (*‹⟦0 < N; ?x ∈ {real_of_int a..real_of_int b} - Y⟧ ⟹ (fs 0 has_vector_derivative fs (Suc 0) ?x) (at ?x)›*) N (*‹0 < N›*) unfolding One_nat_def (*goal: ‹S - I = sum c {..<Suc 0} + EM_remainder' (Suc 0) (fs (Suc 0)) (real_of_int a) (real_of_int b)›*) apply (subst EM_remainder'_Suc_0[of _ _ Y f] (*‹⟦(?a::int) ≤ (?b::int); finite (Y::real set); continuous_on {real_of_int ?a..real_of_int ?b} (f::real ⇒ 'a); ⋀x::real. x ∈ {real_of_int ?a..real_of_int ?b} - Y ⟹ (f has_vector_derivative (?f'::real ⇒ 'a) x) (at x)⟧ ⟹ EM_remainder' (Suc (0::nat)) ?f' (real_of_int ?a) (real_of_int ?b) = (∑i::int∈{?a<..?b}. f (real_of_int i)) - integral {real_of_int ?a..real_of_int ?b} f - (f (real_of_int ?b) - f (real_of_int ?a)) /⇩R (2::real)›*)) (*goals: 1. ‹⟦a ≤ b; finite Y; 0 ≤ N ⟹ continuous_on {real_of_int a..real_of_int b} (fs 0); Suc 0 ≤ N; ⋀x. ⟦0 < N; x ∈ {real_of_int a..real_of_int b} - Y⟧ ⟹ (fs 0 has_vector_derivative fs (Suc 0) x) (at x); 0 < N⟧ ⟹ a ≤ b› 2. ‹⟦a ≤ b; finite Y; 0 ≤ N ⟹ continuous_on {real_of_int a..real_of_int b} (fs 0); Suc 0 ≤ N; ⋀x. ⟦0 < N; x ∈ {real_of_int a..real_of_int b} - Y⟧ ⟹ (fs 0 has_vector_derivative fs (Suc 0) x) (at x); 0 < N⟧ ⟹ finite Y› 3. ‹⟦a ≤ b; finite Y; 0 ≤ N ⟹ continuous_on {real_of_int a..real_of_int b} (fs 0); Suc 0 ≤ N; ⋀x. ⟦0 < N; x ∈ {real_of_int a..real_of_int b} - Y⟧ ⟹ (fs 0 has_vector_derivative fs (Suc 0) x) (at x); 0 < N⟧ ⟹ continuous_on {real_of_int a..real_of_int b} f› 4. ‹⋀x. ⟦a ≤ b; finite Y; 0 ≤ N ⟹ continuous_on {real_of_int a..real_of_int b} (fs 0); Suc 0 ≤ N; ⋀x. ⟦0 < N; x ∈ {real_of_int a..real_of_int b} - Y⟧ ⟹ (fs 0 has_vector_derivative fs (Suc 0) x) (at x); 0 < N; x ∈ {real_of_int a..real_of_int b} - Y⟧ ⟹ (f has_vector_derivative fs (Suc 0) x) (at x)› 5. ‹⟦a ≤ b; finite Y; 0 ≤ N ⟹ continuous_on {real_of_int a..real_of_int b} (fs 0); Suc 0 ≤ N; ⋀x. ⟦0 < N; x ∈ {real_of_int a..real_of_int b} - Y⟧ ⟹ (fs 0 has_vector_derivative fs (Suc 0) x) (at x); 0 < N⟧ ⟹ S - I = sum c {..<Suc 0} + ((∑i∈{a<..b}. f (real_of_int i)) - integral {real_of_int a..real_of_int b} f - (f (real_of_int b) - f (real_of_int a)) /⇩R 2)› discuss goal 1*) apply (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*) S_def (*‹S ≡ ∑i∈{a<..b}. f (real_of_int i)›*) I_def (*‹I ≡ integral {real_of_int a..real_of_int b} f›*) c_def (*‹c = (λk. ((- 1) ^ Suc k * bernoulli (Suc k) / fact (Suc k)) *⇩R (fs k (real_of_int b) - fs k (real_of_int a)))›*)) (*discuss goal 2*) apply (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*) S_def (*‹S ≡ ∑i∈{a<..b}. f (real_of_int i)›*) I_def (*‹I ≡ integral {real_of_int a..real_of_int b} f›*) c_def (*‹c = (λk. ((- 1) ^ Suc k * bernoulli (Suc k) / fact (Suc k)) *⇩R (fs k (real_of_int b) - fs k (real_of_int a)))›*)) (*discuss goal 3*) apply (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 34 facts*) S_def (*‹S::'a::banach ≡ ∑i::int∈{a::int<..b::int}. (f::real ⇒ 'a::banach) (real_of_int i)›*) I_def (*‹I::'a::banach ≡ integral {real_of_int (a::int)..real_of_int (b::int)} (f::real ⇒ 'a::banach)›*) c_def (*‹(c::nat ⇒ 'a::banach) = (λk::nat. ((- (1::real)) ^ Suc k * bernoulli (Suc k) / fact (Suc k)) *⇩R ((fs::nat ⇒ real ⇒ 'a::banach) k (real_of_int (b::int)) - fs k (real_of_int (a::int))))›*)) (*discuss goal 4*) apply (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*) S_def (*‹S::'a ≡ ∑i::int∈{a::int<..b::int}. (f::real ⇒ 'a) (real_of_int i)›*) I_def (*‹I::'a ≡ integral {real_of_int (a::int)..real_of_int (b::int)} (f::real ⇒ 'a)›*) c_def (*‹(c::nat ⇒ 'a) = (λk::nat. ((- (1::real)) ^ Suc k * bernoulli (Suc k) / fact (Suc k)) *⇩R ((fs::nat ⇒ real ⇒ 'a) k (real_of_int (b::int)) - fs k (real_of_int (a::int))))›*)) (*discuss goal 5*) apply (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*) S_def (*‹S ≡ ∑i∈{a<..b}. f (real_of_int i)›*) I_def (*‹I ≡ integral {real_of_int a..real_of_int b} f›*) c_def (*‹c = (λk. ((- 1) ^ Suc k * bernoulli (Suc k) / fact (Suc k)) *⇩R (fs k (real_of_int b) - fs k (real_of_int a)))›*)) (*proven 5 subgoals*) . next (*goal: ‹⋀n. ⟦1 ≤ n; n < m; n ≤ N ⟹ S - I = sum c {..<n} + EM_remainder' n (fs n) (real_of_int a) (real_of_int b); Suc n ≤ N⟧ ⟹ S - I = sum c {..<Suc n} + EM_remainder' (Suc n) (fs (Suc n)) (real_of_int a) (real_of_int b)›*) case (step n) (*‹(1::nat) ≤ (n::nat)› ‹n < m› ‹(n::nat) ≤ (N::nat) ⟹ (S::'a) - (I::'a) = sum (c::nat ⇒ 'a) {..<n} + EM_remainder' n ((fs::nat ⇒ real ⇒ 'a) n) (real_of_int (a::int)) (real_of_int (b::int))› ‹Suc (n::nat) ≤ (N::nat)›*) from step.prems (*‹Suc n ≤ N›*) have "S - I = (∑k<n. c k) + EM_remainder' n (fs n) a b" apply (intro step.IH (*‹n ≤ N ⟹ S - I = sum c {..<n} + EM_remainder' n (fs n) (real_of_int a) (real_of_int b)›*)) (*goal: ‹S - I = sum c {..<n} + EM_remainder' n (fs n) (real_of_int a) (real_of_int b)›*) by simp also (*calculation: ‹S - I = sum c {..<n} + EM_remainder' n (fs n) (real_of_int a) (real_of_int b)›*) have "(∑k<n. c k) = (∑k<Suc n. c k) + (((-1) ^ n * bernoulli (Suc n) / fact (Suc n)) *⇩R (fs n b - fs n a))" (is "_ = _ + ?c") by (simp add: EM_remainder'_Suc_0 (*‹⟦?a ≤ ?b; finite ?Y; continuous_on {real_of_int ?a..real_of_int ?b} ?f; ⋀x. x ∈ {real_of_int ?a..real_of_int ?b} - ?Y ⟹ (?f has_vector_derivative ?f' x) (at x)⟧ ⟹ EM_remainder' (Suc 0) ?f' (real_of_int ?a) (real_of_int ?b) = (∑i∈{?a<..?b}. ?f (real_of_int i)) - integral {real_of_int ?a..real_of_int ?b} ?f - (?f (real_of_int ?b) - ?f (real_of_int ?a)) /⇩R 2›*) c_def (*‹c = (λk. ((- 1) ^ Suc k * bernoulli (Suc k) / fact (Suc k)) *⇩R (fs k (real_of_int b) - fs k (real_of_int a)))›*)) also (*calculation: ‹S - I = sum c {..<Suc n} + ((- 1) ^ n * bernoulli (Suc n) / fact (Suc n)) *⇩R (fs n (real_of_int b) - fs n (real_of_int a)) + EM_remainder' n (fs n) (real_of_int a) (real_of_int b)›*) have "… + EM_remainder' n (fs n) a b = (∑k<Suc n. c k) + (?c + EM_remainder' n (fs n) a b)" by (simp add: add.assoc (*‹?a + ?b + ?c = ?a + (?b + ?c)›*)) also (*calculation: ‹S - I = sum c {..<Suc n} + (((- 1) ^ n * bernoulli (Suc n) / fact (Suc n)) *⇩R (fs n (real_of_int b) - fs n (real_of_int a)) + EM_remainder' n (fs n) (real_of_int a) (real_of_int b))›*) from step.prems (*‹Suc n ≤ N›*) step.hyps (*‹1 ≤ n› ‹n < m›*) ab (*‹a ≤ b›*) fin (*‹finite Y›*) have "?c + EM_remainder' n (fs n) a b = EM_remainder' (Suc n) (fs (Suc n)) a b" apply (subst EM_remainder'_conv_Suc [where A = Y] (*‹⟦?a ≤ ?b; 0 < ?n; finite Y; continuous_on {real_of_int ?a..real_of_int ?b} ?f; continuous_on {real_of_int ?a..real_of_int ?b} ?f'; ⋀x. x ∈ {real_of_int ?a<..<real_of_int ?b} - Y ⟹ (?f has_vector_derivative ?f' x) (at x)⟧ ⟹ EM_remainder' ?n ?f (real_of_int ?a) (real_of_int ?b) = ((- 1) ^ Suc ?n * bernoulli (Suc ?n) / fact (Suc ?n)) *⇩R (?f (real_of_int ?b) - ?f (real_of_int ?a)) + EM_remainder' (Suc ?n) ?f' (real_of_int ?a) (real_of_int ?b)›*)) (*goals: 1. ‹⟦Suc n ≤ N; 1 ≤ n; n < m; a ≤ b; finite Y⟧ ⟹ a ≤ b› 2. ‹⟦Suc n ≤ N; 1 ≤ n; n < m; a ≤ b; finite Y⟧ ⟹ 0 < n› 3. ‹⟦Suc n ≤ N; 1 ≤ n; n < m; a ≤ b; finite Y⟧ ⟹ finite Y› 4. ‹⟦Suc n ≤ N; 1 ≤ n; n < m; a ≤ b; finite Y⟧ ⟹ continuous_on {real_of_int a..real_of_int b} (fs n)› 5. ‹⟦Suc n ≤ N; 1 ≤ n; n < m; a ≤ b; finite Y⟧ ⟹ continuous_on {real_of_int a..real_of_int b} ?f'5› 6. ‹⋀x. ⟦Suc n ≤ N; 1 ≤ n; n < m; a ≤ b; finite Y; x ∈ {real_of_int a<..<real_of_int b} - Y⟧ ⟹ (fs n has_vector_derivative ?f'5 x) (at x)› 7. ‹⟦Suc n ≤ N; 1 ≤ n; n < m; a ≤ b; finite Y⟧ ⟹ ((- 1) ^ n * bernoulli (Suc n) / fact (Suc n)) *⇩R (fs n (real_of_int b) - fs n (real_of_int a)) + (((- 1) ^ Suc n * bernoulli (Suc n) / fact (Suc n)) *⇩R (fs n (real_of_int b) - fs n (real_of_int a)) + EM_remainder' (Suc n) ?f'5 (real_of_int a) (real_of_int b)) = EM_remainder' (Suc n) (fs (Suc n)) (real_of_int a) (real_of_int b)› discuss goal 1*) apply ((auto intro!: fs_deriv (*‹⟦?k < N; ?x ∈ {real_of_int a..real_of_int b} - Y⟧ ⟹ (fs ?k has_vector_derivative fs (Suc ?k) ?x) (at ?x)›*) fs_cont (*‹?k ≤ N ⟹ continuous_on {real_of_int a..real_of_int b} (fs ?k)›*))[1]) (*discuss goal 2*) apply ((auto intro!: fs_deriv (*‹⟦?k < N; ?x ∈ {real_of_int a..real_of_int b} - Y⟧ ⟹ (fs ?k has_vector_derivative fs (Suc ?k) ?x) (at ?x)›*) fs_cont (*‹?k ≤ N ⟹ continuous_on {real_of_int a..real_of_int b} (fs ?k)›*))[1]) (*discuss goal 3*) apply ((auto intro!: fs_deriv (*‹⟦?k < N; ?x ∈ {real_of_int a..real_of_int b} - Y⟧ ⟹ (fs ?k has_vector_derivative fs (Suc ?k) ?x) (at ?x)›*) fs_cont (*‹?k ≤ N ⟹ continuous_on {real_of_int a..real_of_int b} (fs ?k)›*))[1]) (*discuss goal 4*) apply ((auto intro!: fs_deriv (*‹⟦?k < N; ?x ∈ {real_of_int a..real_of_int b} - Y⟧ ⟹ (fs ?k has_vector_derivative fs (Suc ?k) ?x) (at ?x)›*) fs_cont (*‹?k ≤ N ⟹ continuous_on {real_of_int a..real_of_int b} (fs ?k)›*))[1]) (*discuss goal 5*) apply ((auto intro!: fs_deriv (*‹⟦(?k::nat) < (N::nat); (?x::real) ∈ {real_of_int (a::int)..real_of_int (b::int)} - (Y::real set)⟧ ⟹ ((fs::nat ⇒ real ⇒ 'a::banach) ?k has_vector_derivative fs (Suc ?k) ?x) (at ?x)›*) fs_cont (*‹(?k::nat) ≤ (N::nat) ⟹ continuous_on {real_of_int (a::int)..real_of_int (b::int)} ((fs::nat ⇒ real ⇒ 'a::banach) ?k)›*))[1]) (*discuss goal 6*) apply ((auto intro!: fs_deriv (*‹⟦(?k::nat) < (N::nat); (?x::real) ∈ {real_of_int (a::int)..real_of_int (b::int)} - (Y::real set)⟧ ⟹ ((fs::nat ⇒ real ⇒ 'a) ?k has_vector_derivative fs (Suc ?k) ?x) (at ?x)›*) fs_cont (*‹(?k::nat) ≤ (N::nat) ⟹ continuous_on {real_of_int (a::int)..real_of_int (b::int)} ((fs::nat ⇒ real ⇒ 'a) ?k)›*))[1]) (*discuss goal 7*) apply ((auto intro!: fs_deriv (*‹⟦?k < N; ?x ∈ {real_of_int a..real_of_int b} - Y⟧ ⟹ (fs ?k has_vector_derivative fs (Suc ?k) ?x) (at ?x)›*) fs_cont (*‹?k ≤ N ⟹ continuous_on {real_of_int a..real_of_int b} (fs ?k)›*))[1]) (*proven 7 subgoals*) . finally (*calculation: ‹S - I = sum c {..<Suc n} + EM_remainder' (Suc n) (fs (Suc n)) (real_of_int a) (real_of_int b)›*) show "?case" (*goal: ‹S - I = sum c {..<Suc n} + EM_remainder' (Suc n) (fs (Suc n)) (real_of_int a) (real_of_int b)›*) . qed from this[of N] (*‹⟦(1::nat) ≤ (N::nat); N ≤ N⟧ ⟹ (S::'a::banach) - (I::'a::banach) = sum (c::nat ⇒ 'a::banach) {..<N} + EM_remainder' N ((fs::nat ⇒ real ⇒ 'a::banach) N) (real_of_int (a::int)) (real_of_int (b::int))›*) N (*‹0 < N›*) have "S - I = sum c {..<N} + EM_remainder' N (fs N) (real_of_int a) (real_of_int b)" by simp also (*calculation: ‹(S::'a) - (I::'a) = sum (c::nat ⇒ 'a) {..<N::nat} + EM_remainder' N ((fs::nat ⇒ real ⇒ 'a) N) (real_of_int (a::int)) (real_of_int (b::int))›*) have "sum c {..<N} = sum c' {..<N}" proof (intro sum.cong (*‹⟦?A = ?B; ⋀x. x ∈ ?B ⟹ ?g x = ?h x⟧ ⟹ sum ?g ?A = sum ?h ?B›*) refl (*‹?t = ?t›*)) (*goal: ‹⋀x. x ∈ {..<N} ⟹ c x = c' x›*) fix k :: nat show "c k = c' k" apply (cases "even k") (*goals: 1. ‹even k ⟹ c k = c' k› 2. ‹odd k ⟹ c k = c' k› discuss goal 1*) apply ((auto simp: c_def (*‹c = (λk. ((- 1) ^ Suc k * bernoulli (Suc k) / fact (Suc k)) *⇩R (fs k (real_of_int b) - fs k (real_of_int a)))›*) c'_def (*‹c' ≡ λk. (bernoulli' (Suc k) / fact (Suc k)) *⇩R (fs k (real_of_int b) - fs k (real_of_int a))›*) bernoulli'_def (*‹bernoulli' ?n = (if ?n = 1 then 1 / 2 else bernoulli ?n)›*) 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*) bernoulli_odd_eq_0 (*‹⟦?n ≠ 1; odd ?n⟧ ⟹ bernoulli ?n = 0›*))[1]) (*discuss goal 2*) apply ((auto simp: c_def (*‹c = (λk. ((- 1) ^ Suc k * bernoulli (Suc k) / fact (Suc k)) *⇩R (fs k (real_of_int b) - fs k (real_of_int a)))›*) c'_def (*‹c' ≡ λk. (bernoulli' (Suc k) / fact (Suc k)) *⇩R (fs k (real_of_int b) - fs k (real_of_int a))›*) bernoulli'_def (*‹bernoulli' ?n = (if ?n = 1 then 1 / 2 else bernoulli ?n)›*) 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*) bernoulli_odd_eq_0 (*‹⟦?n ≠ 1; odd ?n⟧ ⟹ bernoulli ?n = 0›*))[1]) (*proven 2 subgoals*) . qed finally (*calculation: ‹S - I = sum c' {..<N} + EM_remainder' N (fs N) (real_of_int a) (real_of_int b)›*) show "?thesis" (*goal: ‹S - I = sum c' {..<N} + EM_remainder' N (fs N) (real_of_int a) (real_of_int b)›*) . qed end theorem euler_maclaurin_strong_raw_nat: assumes "a ≤ b" "0 < N" "finite Y" "fs 0 = f" "(⋀k. k ≤ N ⟹ continuous_on {real a..real b} (fs k))" "(⋀k x. k < N ⟹ x ∈ {real a..real b} - Y ⟹ (fs k has_vector_derivative fs (Suc k) x) (at x))" shows "(∑i∈{a<..b}. f (real i)) - integral {real a..real b} f = (∑k<N. (bernoulli' (Suc k) / fact (Suc k)) *⇩R (fs k (real b) - fs k (real a))) + EM_remainder' N (fs N) (real a) (real b)" proof (-) (*goal: ‹(∑i∈{a<..b}. f (real i)) - integral {real a..real b} f = (∑k<N. (bernoulli' (Suc k) / fact (Suc k)) *⇩R (fs k (real b) - fs k (real a))) + EM_remainder' N (fs N) (real a) (real b)›*) have "(∑i∈{int a<..int b}. f (real_of_int i)) - integral {real_of_int (int a)..real_of_int (int b)} f = (∑k<N. (bernoulli' (Suc k) / fact (Suc k)) *⇩R (fs k (real_of_int (int b)) - fs k (real_of_int (int a)))) + EM_remainder' N (fs N) (real_of_int (int a)) (real_of_int (int b))" using assms (*‹(a::nat) ≤ (b::nat)› ‹(0::nat) < (N::nat)› ‹finite Y› ‹fs 0 = f› ‹(?k::nat) ≤ (N::nat) ⟹ continuous_on {real (a::nat)..real (b::nat)} ((fs::nat ⇒ real ⇒ 'a) ?k)› ‹⟦?k < N; ?x ∈ {real a..real b} - Y⟧ ⟹ (fs ?k has_vector_derivative fs (Suc ?k) ?x) (at ?x)›*) apply (intro euler_maclaurin_raw_strong_int[where Y = Y] (*‹⟦?a ≤ ?b; 0 < ?N; finite Y; ?fs 0 = ?f; ⋀k. k ≤ ?N ⟹ continuous_on {real_of_int ?a..real_of_int ?b} (?fs k); ⋀k x. ⟦k < ?N; x ∈ {real_of_int ?a..real_of_int ?b} - Y⟧ ⟹ (?fs k has_vector_derivative ?fs (Suc k) x) (at x)⟧ ⟹ (∑i∈{?a<..?b}. ?f (real_of_int i)) - integral {real_of_int ?a..real_of_int ?b} ?f = (∑k<?N. (bernoulli' (Suc k) / fact (Suc k)) *⇩R (?fs k (real_of_int ?b) - ?fs k (real_of_int ?a))) + EM_remainder' ?N (?fs ?N) (real_of_int ?a) (real_of_int ?b)›*) assms (*‹a ≤ b› ‹0 < N› ‹finite Y› ‹fs 0 = f› ‹?k ≤ N ⟹ continuous_on {real a..real b} (fs ?k)› ‹⟦?k < N; ?x ∈ {real a..real b} - Y⟧ ⟹ (fs ?k has_vector_derivative fs (Suc ?k) ?x) (at ?x)›*)) (*goals: 1. ‹⟦a ≤ b; 0 < N; finite Y; fs 0 = f; ⋀k. k ≤ N ⟹ continuous_on {real a..real b} (fs k); ⋀k x. ⟦k < N; x ∈ {real a..real b} - Y⟧ ⟹ (fs k has_vector_derivative fs (Suc k) x) (at x)⟧ ⟹ int a ≤ int b› 2. ‹⋀k. ⟦a ≤ b; 0 < N; finite Y; fs 0 = f; ⋀k. k ≤ N ⟹ continuous_on {real a..real b} (fs k); ⋀k x. ⟦k < N; x ∈ {real a..real b} - Y⟧ ⟹ (fs k has_vector_derivative fs (Suc k) x) (at x); k ≤ N⟧ ⟹ continuous_on {real_of_int (int a)..real_of_int (int b)} (fs k)› 3. ‹⋀k x. ⟦a ≤ b; 0 < N; finite Y; fs 0 = f; ⋀k. k ≤ N ⟹ continuous_on {real a..real b} (fs k); ⋀k x. ⟦k < N; x ∈ {real a..real b} - Y⟧ ⟹ (fs k has_vector_derivative fs (Suc k) x) (at x); k < N; x ∈ {real_of_int (int a)..real_of_int (int b)} - Y⟧ ⟹ k < N› 4. ‹⋀k x. ⟦a ≤ b; 0 < N; finite Y; fs 0 = f; ⋀k. k ≤ N ⟹ continuous_on {real a..real b} (fs k); ⋀k x. ⟦k < N; x ∈ {real a..real b} - Y⟧ ⟹ (fs k has_vector_derivative fs (Suc k) x) (at x); k < N; x ∈ {real_of_int (int a)..real_of_int (int b)} - Y⟧ ⟹ x ∈ {real a..real b} - Y› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*discuss goal 3*) apply simp (*discuss goal 4*) apply simp (*proven 4 subgoals*) . also (*calculation: ‹(∑i∈{int a<..int b}. f (real_of_int i)) - integral {real_of_int (int a)..real_of_int (int b)} f = (∑k<N. (bernoulli' (Suc k) / fact (Suc k)) *⇩R (fs k (real_of_int (int b)) - fs k (real_of_int (int a)))) + EM_remainder' N (fs N) (real_of_int (int a)) (real_of_int (int b))›*) have "(∑i∈{int a<..int b}. f (real_of_int i)) = (∑i∈{a<..b}. f (real i))" apply (intro sum.reindex_bij_witness[of _ int nat] (*‹⟦⋀a::int. a ∈ (?S::int set) ⟹ int (nat a) = a; ⋀a::int. a ∈ ?S ⟹ nat a ∈ (?T::nat set); ⋀b::nat. b ∈ ?T ⟹ nat (int b) = b; ⋀b::nat. b ∈ ?T ⟹ int b ∈ ?S; ⋀a::int. a ∈ ?S ⟹ (?h::nat ⇒ ?'a::comm_monoid_add) (nat a) = (?g::int ⇒ ?'a::comm_monoid_add) a⟧ ⟹ sum ?g ?S = sum ?h ?T›*)) (*goals: 1. ‹⋀aa. aa ∈ {int a<..int b} ⟹ int (nat aa) = aa› 2. ‹⋀aa. aa ∈ {int a<..int b} ⟹ nat aa ∈ {a<..b}› 3. ‹⋀ba. ba ∈ {a<..b} ⟹ nat (int ba) = ba› 4. ‹⋀ba. ba ∈ {a<..b} ⟹ int ba ∈ {int a<..int b}› 5. ‹⋀aa. aa ∈ {int a<..int b} ⟹ f (real (nat aa)) = f (real_of_int aa)› 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*) . finally (*calculation: ‹(∑i∈{a<..b}. f (real i)) - integral {real_of_int (int a)..real_of_int (int b)} f = (∑k<N. (bernoulli' (Suc k) / fact (Suc k)) *⇩R (fs k (real_of_int (int b)) - fs k (real_of_int (int a)))) + EM_remainder' N (fs N) (real_of_int (int a)) (real_of_int (int b))›*) show "?thesis" (*goal: ‹(∑i∈{a<..b}. f (real i)) - integral {real a..real b} f = (∑k<N. (bernoulli' (Suc k) / fact (Suc k)) *⇩R (fs k (real b) - fs k (real a))) + EM_remainder' N (fs N) (real a) (real b)›*) by simp qed subsection ‹The ``Concrete Mathematics'' version of the Euler--MacLaurin formula› text ‹ As explained in \textit{Concrete Mathematics}~\<^cite>‹"GKP_CM"›, the above form of the formula has some drawbacks: When applying it to determine the asymptotics of some concrete function, one is usually left with several different unwieldy constant terms that are difficult to get rid of. There is no general way to determine what these constant terms are, but in concrete applications, they can often be determined or estimated by other means. We can therefore simply group all the constant terms into a single constant and have the user provide a proof of what it is. › locale euler_maclaurin_int = fixes F f :: "real ⇒ 'a :: banach" fixes fs :: "nat ⇒ real ⇒ 'a" fixes a :: int fixes N :: nat assumes N: "N > 0" fixes C :: 'a fixes Y :: "real set" assumes fin: "finite Y" assumes fs_0 [simp]: "fs 0 = f" assumes fs_cont [continuous_intros]: "⋀k. k ≤ N ⟹ continuous_on {real_of_int a..} (fs k)" assumes fs_deriv [derivative_intros]: "⋀k x. k < N ⟹ x ∈ {of_int a..} - Y ⟹ (fs k has_vector_derivative fs (Suc k) x) (at x)" assumes F_cont [continuous_intros]: "continuous_on {of_int a..} F" assumes F_deriv [derivative_intros]: "⋀x. x ∈ {of_int a..} - Y ⟹ (F has_vector_derivative f x) (at x)" assumes limit: "((λb. (∑k=a..b. f k) - F (of_int b) - (∑i<N. (bernoulli' (Suc i) / fact (Suc i)) *⇩R fs i (of_int b))) ⤏ C) at_top" begin context fixes C' T defines "C' ≡ -f a + F a + C + (∑k<N. (bernoulli' (Suc k) / fact (Suc k)) *⇩R (fs k (of_int a)))" and "T ≡ (λx. ∑i<N. (bernoulli' (Suc i) / fact (Suc i)) *⇩R fs i x)" begin lemma euler_maclaurin_strong_int_aux: assumes ab: "a ≤ b" defines "S ≡ (∑k=a..b. f (of_int k))" shows "S - F (of_int b) - T (of_int b) = EM_remainder' N (fs N) (of_int a) (of_int b) + (C - C')" proof (cases "a = b") (*goals: 1. ‹a = b ⟹ S - F (real_of_int b) - T (real_of_int b) = EM_remainder' N (fs N) (real_of_int a) (real_of_int b) + (C - C')› 2. ‹a ≠ b ⟹ S - F (real_of_int b) - T (real_of_int b) = EM_remainder' N (fs N) (real_of_int a) (real_of_int b) + (C - C')›*) case True (*‹a = b›*) thus "?thesis" (*goal: ‹S - F (real_of_int b) - T (real_of_int b) = EM_remainder' N (fs N) (real_of_int a) (real_of_int b) + (C - C')›*) unfolding C'_def (*goal: ‹S - F (real_of_int b) - T (real_of_int b) = EM_remainder' N (fs N) (real_of_int a) (real_of_int b) + (C - (- f (real_of_int a) + F (real_of_int a) + C + (∑k<N. (bernoulli' (Suc k) / fact (Suc k)) *⇩R fs k (real_of_int a))))›*) by (simp add: S_def (*‹S ≡ ∑k = a..b. f (real_of_int k)›*) EM_remainder'_def (*‹EM_remainder' ?n ?f ?a ?b = ((- 1) ^ Suc ?n / fact ?n) *⇩R integral {?a..?b} (λt. pbernpoly ?n t *⇩R ?f t)›*) T_def (*‹T ≡ λx. ∑i<N. (bernoulli' (Suc i) / fact (Suc i)) *⇩R fs i x›*)) next (*goal: ‹(a::int) ≠ (b::int) ⟹ (S::'a) - (F::real ⇒ 'a) (real_of_int b) - (T::real ⇒ 'a) (real_of_int b) = EM_remainder' (N::nat) ((fs::nat ⇒ real ⇒ 'a) N) (real_of_int a) (real_of_int b) + ((C::'a) - (C'::'a))›*) case False (*‹a ≠ b›*) with assms (*‹a ≤ b› ‹S ≡ ∑k = a..b. f (real_of_int k)›*) have ab: "a < b" by simp define T' where "T' = (∑k<N. (bernoulli' (Suc k) / fact (Suc k)) *⇩R (fs k (of_int a)))" have "(∑i∈{a<..b}. f (of_int i)) - integral {of_int a..of_int b} f = (∑k<N. (bernoulli' (Suc k) / fact (Suc k)) *⇩R (fs k (of_int b) - fs k (of_int a))) + EM_remainder' N (fs N) (of_int a) (of_int b)" using ab (*‹a < b›*) apply (intro euler_maclaurin_raw_strong_int [where Y = Y] (*‹⟦?a ≤ ?b; 0 < ?N; finite Y; ?fs 0 = ?f; ⋀k. k ≤ ?N ⟹ continuous_on {real_of_int ?a..real_of_int ?b} (?fs k); ⋀k x. ⟦k < ?N; x ∈ {real_of_int ?a..real_of_int ?b} - Y⟧ ⟹ (?fs k has_vector_derivative ?fs (Suc k) x) (at x)⟧ ⟹ (∑i∈{?a<..?b}. ?f (real_of_int i)) - integral {real_of_int ?a..real_of_int ?b} ?f = (∑k<?N. (bernoulli' (Suc k) / fact (Suc k)) *⇩R (?fs k (real_of_int ?b) - ?fs k (real_of_int ?a))) + EM_remainder' ?N (?fs ?N) (real_of_int ?a) (real_of_int ?b)›*) N (*‹0 < N›*) fin (*‹finite Y›*) fs_0 (*‹fs 0 = f›*) continuous_on_subset[OF fs_cont] (*‹⟦?k1 ≤ N; ?t ⊆ {real_of_int a..}⟧ ⟹ continuous_on ?t (fs ?k1)›*) fs_deriv (*‹⟦?k < N; ?x ∈ {real_of_int a..} - Y⟧ ⟹ (fs ?k has_vector_derivative fs (Suc ?k) ?x) (at ?x)›*)) (*goals: 1. ‹a < b ⟹ a ≤ b› 2. ‹⋀k. ⟦a < b; k ≤ N⟧ ⟹ k ≤ N› 3. ‹⋀k. ⟦a < b; k ≤ N⟧ ⟹ {real_of_int a..real_of_int b} ⊆ {real_of_int a..}› 4. ‹⋀k x. ⟦a < b; k < N; x ∈ {real_of_int a..real_of_int b} - Y⟧ ⟹ k < N› 5. ‹⋀k x. ⟦a < b; k < N; x ∈ {real_of_int a..real_of_int b} - Y⟧ ⟹ x ∈ {real_of_int a..} - 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]) (*proven 5 subgoals*) . also (*calculation: ‹(∑i∈{a<..b}. f (real_of_int i)) - integral {real_of_int a..real_of_int b} f = (∑k<N. (bernoulli' (Suc k) / fact (Suc k)) *⇩R (fs k (real_of_int b) - fs k (real_of_int a))) + EM_remainder' N (fs N) (real_of_int a) (real_of_int b)›*) have "(f has_integral (F b - F a)) {of_int a..of_int b}" using ab (*‹(a::int) < (b::int)›*) apply (intro fundamental_theorem_of_calculus_strong[OF fin] (*‹⟦?a ≤ ?b; ⋀x. x ∈ {?a..?b} - Y ⟹ (?f has_vector_derivative ?f' x) (at x); continuous_on {?a..?b} ?f⟧ ⟹ (?f' has_integral ?f ?b - ?f ?a) {?a..?b}›*)) (*goals: 1. ‹a < b ⟹ real_of_int a ≤ real_of_int b› 2. ‹⋀x. ⟦a < b; x ∈ {real_of_int a..real_of_int b} - Y⟧ ⟹ (F has_vector_derivative f x) (at x)› 3. ‹a < b ⟹ continuous_on {real_of_int a..real_of_int b} F› discuss goal 1*) apply ((auto intro!: continuous_on_subset[OF F_cont] (*‹?t ⊆ {real_of_int a..} ⟹ continuous_on ?t 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 199 facts*))[1]) (*discuss goal 2*) apply ((auto intro!: continuous_on_subset[OF F_cont] (*‹?t ⊆ {real_of_int a..} ⟹ continuous_on ?t 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 199 facts*))[1]) (*discuss goal 3*) apply ((auto intro!: continuous_on_subset[OF F_cont] (*‹(?t::real set) ⊆ {real_of_int (a::int)..} ⟹ continuous_on ?t (F::real ⇒ 'a)›*) 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 199 facts*))[1]) (*proven 3 subgoals*) . hence "integral {of_int a..of_int b} f = F (of_int b) - F (of_int a)" by (simp add: has_integral_iff (*‹(?f has_integral ?i) ?S = (?f integrable_on ?S ∧ integral ?S ?f = ?i)›*)) also (*calculation: ‹(∑i∈{a<..b}. f (real_of_int i)) - (F (real_of_int b) - F (real_of_int a)) = (∑k<N. (bernoulli' (Suc k) / fact (Suc k)) *⇩R (fs k (real_of_int b) - fs k (real_of_int a))) + EM_remainder' N (fs N) (real_of_int a) (real_of_int b)›*) have "(∑k<N. (bernoulli' (Suc k) / fact (Suc k)) *⇩R (fs k (of_int b) - fs k (of_int a))) = T (of_int b) - T'" by (simp add: T_def (*‹T::real ⇒ 'a ≡ λx::real. ∑i::nat<N::nat. (bernoulli' (Suc i) / fact (Suc i)) *⇩R (fs::nat ⇒ real ⇒ 'a) i x›*) T'_def (*‹(T'::'a) = (∑k::nat<N::nat. (bernoulli' (Suc k) / fact (Suc k)) *⇩R (fs::nat ⇒ real ⇒ 'a) k (real_of_int (a::int)))›*) 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*) sum_subtractf (*‹(∑x::?'b∈(?A::?'b set). (?f::?'b ⇒ ?'a) x - (?g::?'b ⇒ ?'a) x) = sum ?f ?A - sum ?g ?A›*)) also (*calculation: ‹(∑i∈{a<..b}. f (real_of_int i)) - (F (real_of_int b) - F (real_of_int a)) = T (real_of_int b) - T' + EM_remainder' N (fs N) (real_of_int a) (real_of_int b)›*) have "(∑i∈{a<..b}. f (of_int i)) = S - f (of_int a)" unfolding S_def (*goal: ‹(∑i∈{a<..b}. f (real_of_int i)) = (∑k = a..b. f (real_of_int k)) - f (real_of_int a)›*) using ab (*‹(a::int) < (b::int)›*) apply (subst sum_atLeastAtMost_int_head (*‹?a < ?b ⟹ sum ?f {?a..?b} = ?f ?a + sum ?f {?a<..?b}›*)) (*goals: 1. ‹a < b ⟹ a < b› 2. ‹a < b ⟹ (∑i∈{a<..b}. f (real_of_int i)) = f (real_of_int a) + (∑k∈{a<..b}. f (real_of_int k)) - f (real_of_int a)› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . finally (*calculation: ‹S - f (real_of_int a) - (F (real_of_int b) - F (real_of_int a)) = T (real_of_int b) - T' + EM_remainder' N (fs N) (real_of_int a) (real_of_int b)›*) show "?thesis" (*goal: ‹S - F (real_of_int b) - T (real_of_int b) = EM_remainder' N (fs N) (real_of_int a) (real_of_int b) + (C - 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 34 facts*) C'_def (*‹C' ≡ - f (real_of_int a) + F (real_of_int a) + C + (∑k<N. (bernoulli' (Suc k) / fact (Suc k)) *⇩R fs k (real_of_int a))›*) T'_def (*‹T' = (∑k<N. (bernoulli' (Suc k) / fact (Suc k)) *⇩R fs k (real_of_int a))›*)) qed lemma EM_remainder_limit: assumes ab: "a ≤ b" defines "D ≡ EM_remainder' N (fs N) (of_int a) (of_int b)" shows "EM_remainder N (fs N) b = C' - D" and EM_remainder_converges: "EM_remainder_converges N (fs N) b" proof (-) (*goals: 1. ‹EM_remainder N (fs N) b = C' - D› 2. ‹EM_remainder_converges N (fs N) b›*) note limit (*‹((λb. (∑k = a..b. f (real_of_int k)) - F (real_of_int b) - (∑i<N. (bernoulli' (Suc i) / fact (Suc i)) *⇩R fs i (real_of_int b))) ⤏ C) at_top›*) also (*calculation: ‹((λb::int. (∑k::int = a::int..b. (f::real ⇒ 'a::banach) (real_of_int k)) - (F::real ⇒ 'a::banach) (real_of_int b) - (∑i::nat<N::nat. (bernoulli' (Suc i) / fact (Suc i)) *⇩R (fs::nat ⇒ real ⇒ 'a::banach) i (real_of_int b))) ⤏ (C::'a::banach)) at_top›*) have "((λb. (∑k = a..b. f (of_int k)) - F (of_int b) - (∑i<N. (bernoulli' (Suc i) / fact (Suc i)) *⇩R fs i (of_int b))) ⤏ C) at_top = ((λb. (∑k = a..b. f (of_int k)) - F (of_int b) - T (of_int b)) ⤏ C) at_top" unfolding T_def (*goal: ‹((λb. (∑k = a..b. f (real_of_int k)) - F (real_of_int b) - (∑i<N. (bernoulli' (Suc i) / fact (Suc i)) *⇩R fs i (real_of_int b))) ⤏ C) at_top = ((λb. (∑k = a..b. f (real_of_int k)) - F (real_of_int b) - (∑i<N. (bernoulli' (Suc i) / fact (Suc i)) *⇩R fs i (real_of_int b))) ⤏ C) at_top›*) by standard also (*calculation: ‹((λb. (∑k = a..b. f (real_of_int k)) - F (real_of_int b) - T (real_of_int b)) ⤏ C) at_top›*) have "eventually (λx. (∑k=a..x. f k) - F (of_int x) - T (of_int x) = EM_remainder' N (fs N) (of_int a) (of_int x) + (C - C')) at_top" (is "eventually (λx. ?f x = ?g x) _") using eventually_gt_at_top[of b] (*‹eventually ((<) b) at_top›*) apply eventually_elim (*goal: ‹∀⇩F x in at_top. (∑k = a..x. f (real_of_int k)) - F (real_of_int x) - T (real_of_int x) = EM_remainder' N (fs N) (real_of_int a) (real_of_int x) + (C - C')›*) apply (rule euler_maclaurin_strong_int_aux (*‹a ≤ ?b ⟹ (∑k = a..?b. f (real_of_int k)) - F (real_of_int ?b) - T (real_of_int ?b) = EM_remainder' N (fs N) (real_of_int a) (real_of_int ?b) + (C - C')›*)) (*goal: ‹⋀x. b < x ⟹ (∑k = a..x. f (real_of_int k)) - F (real_of_int x) - T (real_of_int x) = EM_remainder' N (fs N) (real_of_int a) (real_of_int x) + (C - C')›*) apply (insert ab (*‹a ≤ b›*)) (*goal: ‹⋀x. b < x ⟹ a ≤ x›*) by simp hence "(?f ⤏ C) at_top ⟷ (?g ⤏ C) at_top" by (intro filterlim_cong (*‹⟦?F1.0 = ?F1'; ?F2.0 = ?F2'; ∀⇩F x in ?F2.0. ?f x = ?g x⟧ ⟹ filterlim ?f ?F1.0 ?F2.0 = filterlim ?g ?F1' ?F2'›*) refl (*‹?t = ?t›*)) finally (*calculation: ‹((λx. EM_remainder' N (fs N) (real_of_int a) (real_of_int x) + (C - C')) ⤏ C) at_top›*) have "((λx. ?g x - (C - C')) ⤏ (C - (C - C'))) at_top" by (rule tendsto_diff[OF _ tendsto_const] (*‹(?f ⤏ ?a) ?F ⟹ ((λx. ?f x - ?b) ⤏ ?a - ?b) ?F›*)) hence "*": "((λx. EM_remainder' N (fs N) (of_int a) (of_int x)) ⤏ C') at_top" by simp have "((λx. EM_remainder' N (fs N) (of_int a) (of_int x) - D) ⤏ C' - D) at_top" 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 104 facts*) * (*‹((λx. EM_remainder' N (fs N) (real_of_int a) (real_of_int x)) ⤏ C') at_top›*)) also (*calculation: ‹((λx::int. EM_remainder' (N::nat) ((fs::nat ⇒ real ⇒ 'a) N) (real_of_int (a::int)) (real_of_int x) - (D::'a)) ⤏ (C'::'a) - D) at_top›*) have "eventually (λx. EM_remainder' N (fs N) (of_int a) (of_int x) - D = EM_remainder' N (fs N) (of_int b) (of_int x)) at_top" (is "eventually (λx. ?f x = ?g x) _") using eventually_ge_at_top[of b] (*‹eventually ((≤) b) at_top›*) proof (eventually_elim) (*goal: ‹⋀x. b ≤ x ⟹ EM_remainder' N (fs N) (real_of_int a) (real_of_int x) - D = EM_remainder' N (fs N) (real_of_int b) (real_of_int x)›*) case (elim x) (*‹(b::int) ≤ (x::int)›*) have "EM_remainder' N (fs N) (of_int a) (of_int x) = D + EM_remainder' N (fs N) (of_int b) (of_int x)" using elim (*‹b ≤ x›*) ab (*‹(a::int) ≤ (b::int)›*) unfolding D_def (*goal: ‹EM_remainder' N (fs N) (real_of_int a) (real_of_int x) = EM_remainder' N (fs N) (real_of_int a) (real_of_int b) + EM_remainder' N (fs N) (real_of_int b) (real_of_int x)›*) apply (intro EM_remainder'_combine [symmetric] (*‹⟦continuous_on {?a..?c} ?f; ?a ≤ ?b; ?b ≤ ?c⟧ ⟹ EM_remainder' ?n ?f ?a ?c = EM_remainder' ?n ?f ?a ?b + EM_remainder' ?n ?f ?b ?c›*) continuous_on_subset[OF fs_cont] (*‹⟦?k1 ≤ N; ?t ⊆ {real_of_int a..}⟧ ⟹ continuous_on ?t (fs ?k1)›*)) (*goals: 1. ‹⟦b ≤ x; a ≤ b⟧ ⟹ N ≤ N› 2. ‹⟦b ≤ x; a ≤ b⟧ ⟹ {real_of_int a..real_of_int x} ⊆ {real_of_int a..}› 3. ‹⟦b ≤ x; a ≤ b⟧ ⟹ real_of_int a ≤ real_of_int b› 4. ‹⟦b ≤ x; a ≤ b⟧ ⟹ real_of_int b ≤ real_of_int 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]) (*proven 4 subgoals*) . thus "?case" (*goal: ‹EM_remainder' N (fs N) (real_of_int a) (real_of_int x) - D = EM_remainder' N (fs N) (real_of_int b) (real_of_int x)›*) by simp qed hence "(?f ⤏ C' - D) at_top ⟷ (?g ⤏ C' - D) at_top" by (intro filterlim_cong (*‹⟦?F1.0 = ?F1'; ?F2.0 = ?F2'; ∀⇩F x in ?F2.0. ?f x = ?g x⟧ ⟹ filterlim ?f ?F1.0 ?F2.0 = filterlim ?g ?F1' ?F2'›*) refl (*‹?t = ?t›*)) finally (*calculation: ‹((λx. EM_remainder' N (fs N) (real_of_int b) (real_of_int x)) ⤏ C' - D) at_top›*) have "*": "…" . from "*" (*‹((λx::int. EM_remainder' (N::nat) ((fs::nat ⇒ real ⇒ 'a) N) (real_of_int (b::int)) (real_of_int x)) ⤏ (C'::'a) - (D::'a)) at_top›*) show "EM_remainder_converges N (fs N) b" unfolding EM_remainder_converges_def (*goal: ‹∃L. ((λx. EM_remainder' N (fs N) (real_of_int b) (real_of_int x)) ⤏ L) at_top›*) by standard from "*" (*‹((λx::int. EM_remainder' (N::nat) ((fs::nat ⇒ real ⇒ 'a::banach) N) (real_of_int (b::int)) (real_of_int x)) ⤏ (C'::'a::banach) - (D::'a::banach)) at_top›*) show "EM_remainder N (fs N) b = C' - D" by (rule EM_remainder_eqI (*‹((λx. EM_remainder' ?n ?f (real_of_int ?b) (real_of_int x)) ⤏ ?L) at_top ⟹ EM_remainder ?n ?f ?b = ?L›*)) qed theorem euler_maclaurin_strong_int: assumes ab: "a ≤ b" defines "S ≡ (∑k=a..b. f (of_int k))" shows "S = F (of_int b) + C + T (of_int b) - EM_remainder N (fs N) b" proof (-) (*goal: ‹S = F (real_of_int b) + C + T (real_of_int b) - EM_remainder N (fs N) b›*) have "S = F (of_int b) + T (of_int b) + - (C' - EM_remainder' N (fs N) (of_int a) (of_int b)) + C" using euler_maclaurin_strong_int_aux[OF ab] (*‹(∑k = a..b. f (real_of_int k)) - F (real_of_int b) - T (real_of_int b) = EM_remainder' N (fs N) (real_of_int a) (real_of_int b) + (C - 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 34 facts*) S_def (*‹S ≡ ∑k = a..b. f (real_of_int k)›*)) also (*calculation: ‹S = F (real_of_int b) + T (real_of_int b) + - (C' - EM_remainder' N (fs N) (real_of_int a) (real_of_int b)) + C›*) have "C' - EM_remainder' N (fs N) (of_int a) (of_int b) = EM_remainder N (fs N) b" using ab (*‹a ≤ b›*) by (rule EM_remainder_limit(1) [symmetric] (*‹a ≤ ?b ⟹ C' - EM_remainder' N (fs N) (real_of_int a) (real_of_int ?b) = EM_remainder N (fs N) ?b›*)) finally (*calculation: ‹S = F (real_of_int b) + T (real_of_int b) + - EM_remainder N (fs N) b + C›*) show "?thesis" (*goal: ‹S = F (real_of_int b) + C + T (real_of_int b) - EM_remainder N (fs N) b›*) by simp qed end end text ‹ The following version of the formula removes all the terms where the associated Bernoulli numbers vanish. › locale euler_maclaurin_int' = fixes F f :: "real ⇒ 'a :: banach" fixes fs :: "nat ⇒ real ⇒ 'a" fixes a :: int fixes N :: nat fixes C :: 'a fixes Y :: "real set" assumes fin: "finite Y" assumes fs_0 [simp]: "fs 0 = f" assumes fs_cont [continuous_intros]: "⋀k. k ≤ 2*N+1 ⟹ continuous_on {real_of_int a..} (fs k)" assumes fs_deriv [derivative_intros]: "⋀k x. k ≤ 2*N ⟹ x ∈ {of_int a..} - Y ⟹ (fs k has_vector_derivative fs (Suc k) x) (at x)" assumes F_cont [continuous_intros]: "continuous_on {of_int a..} F" assumes F_deriv [derivative_intros]: "⋀x. x ∈ {of_int a..} - Y ⟹ (F has_vector_derivative f x) (at x)" assumes limit: "((λb. (∑k=a..b. f k) - F (of_int b) - (∑i<2*N+1. (bernoulli' (Suc i) / fact (Suc i)) *⇩R fs i (of_int b))) ⤏ C) at_top" begin sublocale euler_maclaurin_int F f fs a "2*N+1" C Y apply standard (*goals: 1. ‹(0::nat) < (2::nat) * (N::nat) + (1::nat)› 2. ‹finite (Y::real set)› 3. ‹(fs::nat ⇒ real ⇒ 'a) (0::nat) = (f::real ⇒ 'a)› 4. ‹⋀k::nat. k ≤ (2::nat) * (N::nat) + (1::nat) ⟹ continuous_on {real_of_int (a::int)..} ((fs::nat ⇒ real ⇒ 'a) k)› 5. ‹⋀(k::nat) x::real. ⟦k < (2::nat) * (N::nat) + (1::nat); x ∈ {real_of_int (a::int)..} - (Y::real set)⟧ ⟹ ((fs::nat ⇒ real ⇒ 'a) k has_vector_derivative fs (Suc k) x) (at x)› 6. ‹continuous_on {real_of_int (a::int)..} (F::real ⇒ 'a)› 7. ‹⋀x::real. x ∈ {real_of_int (a::int)..} - (Y::real set) ⟹ ((F::real ⇒ 'a) has_vector_derivative (f::real ⇒ 'a) x) (at x)› 8. ‹((λb::int. (∑k::int = a::int..b. (f::real ⇒ 'a) (real_of_int k)) - (F::real ⇒ 'a) (real_of_int b) - (∑i::nat<(2::nat) * (N::nat) + (1::nat). (bernoulli' (Suc i) / fact (Suc i)) *⇩R (fs::nat ⇒ real ⇒ 'a) i (real_of_int b))) ⤏ (C::'a)) at_top› discuss goal 1*) apply ((insert fin (*‹finite (Y::real set)›*) fs_0 (*‹(fs::nat ⇒ real ⇒ 'a) (0::nat) = (f::real ⇒ 'a)›*) fs_cont (*‹(?k::nat) ≤ (2::nat) * (N::nat) + (1::nat) ⟹ continuous_on {real_of_int (a::int)..} ((fs::nat ⇒ real ⇒ 'a) ?k)›*) fs_deriv (*‹⟦(?k::nat) ≤ (2::nat) * (N::nat); (?x::real) ∈ {real_of_int (a::int)..} - (Y::real set)⟧ ⟹ ((fs::nat ⇒ real ⇒ 'a) ?k has_vector_derivative fs (Suc ?k) ?x) (at ?x)›*) F_cont (*‹continuous_on {real_of_int (a::int)..} (F::real ⇒ 'a)›*) F_deriv (*‹(?x::real) ∈ {real_of_int (a::int)..} - (Y::real set) ⟹ ((F::real ⇒ 'a) has_vector_derivative (f::real ⇒ 'a) ?x) (at ?x)›*) limit (*‹((λb::int. (∑k::int = a::int..b. (f::real ⇒ 'a) (real_of_int k)) - (F::real ⇒ 'a) (real_of_int b) - (∑i::nat<(2::nat) * (N::nat) + (1::nat). (bernoulli' (Suc i) / fact (Suc i)) *⇩R (fs::nat ⇒ real ⇒ 'a) i (real_of_int b))) ⤏ (C::'a)) at_top›*))[1]) (*top goal: ‹0 < 2 * N + 1› and 7 goals remain*) apply simp (*discuss goal 2*) apply ((insert fin (*‹finite Y›*) fs_0 (*‹fs 0 = f›*) fs_cont (*‹?k ≤ 2 * N + 1 ⟹ continuous_on {real_of_int a..} (fs ?k)›*) fs_deriv (*‹⟦?k ≤ 2 * N; ?x ∈ {real_of_int a..} - Y⟧ ⟹ (fs ?k has_vector_derivative fs (Suc ?k) ?x) (at ?x)›*) F_cont (*‹continuous_on {real_of_int a..} F›*) F_deriv (*‹?x ∈ {real_of_int a..} - Y ⟹ (F has_vector_derivative f ?x) (at ?x)›*) limit (*‹((λb. (∑k = a..b. f (real_of_int k)) - F (real_of_int b) - (∑i<2 * N + 1. (bernoulli' (Suc i) / fact (Suc i)) *⇩R fs i (real_of_int b))) ⤏ C) at_top›*))[1]) (*top goal: ‹finite Y› and 6 goals remain*) apply simp (*discuss goal 3*) apply ((insert fin (*‹finite Y›*) fs_0 (*‹fs 0 = f›*) fs_cont (*‹?k ≤ 2 * N + 1 ⟹ continuous_on {real_of_int a..} (fs ?k)›*) fs_deriv (*‹⟦?k ≤ 2 * N; ?x ∈ {real_of_int a..} - Y⟧ ⟹ (fs ?k has_vector_derivative fs (Suc ?k) ?x) (at ?x)›*) F_cont (*‹continuous_on {real_of_int a..} F›*) F_deriv (*‹?x ∈ {real_of_int a..} - Y ⟹ (F has_vector_derivative f ?x) (at ?x)›*) limit (*‹((λb. (∑k = a..b. f (real_of_int k)) - F (real_of_int b) - (∑i<2 * N + 1. (bernoulli' (Suc i) / fact (Suc i)) *⇩R fs i (real_of_int b))) ⤏ C) at_top›*))[1]) (*top goal: ‹fs 0 = f› and 5 goals remain*) apply simp (*discuss goal 4*) apply ((insert fin (*‹finite Y›*) fs_0 (*‹fs 0 = f›*) fs_cont (*‹?k ≤ 2 * N + 1 ⟹ continuous_on {real_of_int a..} (fs ?k)›*) fs_deriv (*‹⟦?k ≤ 2 * N; ?x ∈ {real_of_int a..} - Y⟧ ⟹ (fs ?k has_vector_derivative fs (Suc ?k) ?x) (at ?x)›*) F_cont (*‹continuous_on {real_of_int a..} F›*) F_deriv (*‹?x ∈ {real_of_int a..} - Y ⟹ (F has_vector_derivative f ?x) (at ?x)›*) limit (*‹((λb. (∑k = a..b. f (real_of_int k)) - F (real_of_int b) - (∑i<2 * N + 1. (bernoulli' (Suc i) / fact (Suc i)) *⇩R fs i (real_of_int b))) ⤏ C) at_top›*))[1]) (*top goal: ‹⋀k::nat. k ≤ (2::nat) * (N::nat) + (1::nat) ⟹ continuous_on {real_of_int (a::int)..} ((fs::nat ⇒ real ⇒ 'a::banach) k)› and 4 goals remain*) apply simp (*discuss goal 5*) apply ((insert fin (*‹finite (Y::real set)›*) fs_0 (*‹(fs::nat ⇒ real ⇒ 'a) (0::nat) = (f::real ⇒ 'a)›*) fs_cont (*‹(?k::nat) ≤ (2::nat) * (N::nat) + (1::nat) ⟹ continuous_on {real_of_int (a::int)..} ((fs::nat ⇒ real ⇒ 'a) ?k)›*) fs_deriv (*‹⟦(?k::nat) ≤ (2::nat) * (N::nat); (?x::real) ∈ {real_of_int (a::int)..} - (Y::real set)⟧ ⟹ ((fs::nat ⇒ real ⇒ 'a) ?k has_vector_derivative fs (Suc ?k) ?x) (at ?x)›*) F_cont (*‹continuous_on {real_of_int (a::int)..} (F::real ⇒ 'a)›*) F_deriv (*‹(?x::real) ∈ {real_of_int (a::int)..} - (Y::real set) ⟹ ((F::real ⇒ 'a) has_vector_derivative (f::real ⇒ 'a) ?x) (at ?x)›*) limit (*‹((λb::int. (∑k::int = a::int..b. (f::real ⇒ 'a) (real_of_int k)) - (F::real ⇒ 'a) (real_of_int b) - (∑i::nat<(2::nat) * (N::nat) + (1::nat). (bernoulli' (Suc i) / fact (Suc i)) *⇩R (fs::nat ⇒ real ⇒ 'a) i (real_of_int b))) ⤏ (C::'a)) at_top›*))[1]) (*top goal: ‹⋀k x. ⟦k < 2 * N + 1; x ∈ {real_of_int a..} - Y⟧ ⟹ (fs k has_vector_derivative fs (Suc k) x) (at x)› and 3 goals remain*) apply simp (*discuss goal 6*) apply ((insert fin (*‹finite Y›*) fs_0 (*‹fs 0 = f›*) fs_cont (*‹?k ≤ 2 * N + 1 ⟹ continuous_on {real_of_int a..} (fs ?k)›*) fs_deriv (*‹⟦?k ≤ 2 * N; ?x ∈ {real_of_int a..} - Y⟧ ⟹ (fs ?k has_vector_derivative fs (Suc ?k) ?x) (at ?x)›*) F_cont (*‹continuous_on {real_of_int a..} F›*) F_deriv (*‹?x ∈ {real_of_int a..} - Y ⟹ (F has_vector_derivative f ?x) (at ?x)›*) limit (*‹((λb. (∑k = a..b. f (real_of_int k)) - F (real_of_int b) - (∑i<2 * N + 1. (bernoulli' (Suc i) / fact (Suc i)) *⇩R fs i (real_of_int b))) ⤏ C) at_top›*))[1]) (*top goal: ‹continuous_on {real_of_int (a::int)..} (F::real ⇒ 'a)› and 2 goals remain*) apply simp (*discuss goal 7*) apply ((insert fin (*‹finite Y›*) fs_0 (*‹fs 0 = f›*) fs_cont (*‹?k ≤ 2 * N + 1 ⟹ continuous_on {real_of_int a..} (fs ?k)›*) fs_deriv (*‹⟦?k ≤ 2 * N; ?x ∈ {real_of_int a..} - Y⟧ ⟹ (fs ?k has_vector_derivative fs (Suc ?k) ?x) (at ?x)›*) F_cont (*‹continuous_on {real_of_int a..} F›*) F_deriv (*‹?x ∈ {real_of_int a..} - Y ⟹ (F has_vector_derivative f ?x) (at ?x)›*) limit (*‹((λb. (∑k = a..b. f (real_of_int k)) - F (real_of_int b) - (∑i<2 * N + 1. (bernoulli' (Suc i) / fact (Suc i)) *⇩R fs i (real_of_int b))) ⤏ C) at_top›*))[1]) (*top goal: ‹⋀x. x ∈ {real_of_int a..} - Y ⟹ (F has_vector_derivative f x) (at x)› and 1 goal remains*) apply simp (*discuss goal 8*) apply ((insert fin (*‹finite Y›*) fs_0 (*‹fs 0 = f›*) fs_cont (*‹?k ≤ 2 * N + 1 ⟹ continuous_on {real_of_int a..} (fs ?k)›*) fs_deriv (*‹⟦?k ≤ 2 * N; ?x ∈ {real_of_int a..} - Y⟧ ⟹ (fs ?k has_vector_derivative fs (Suc ?k) ?x) (at ?x)›*) F_cont (*‹continuous_on {real_of_int a..} F›*) F_deriv (*‹?x ∈ {real_of_int a..} - Y ⟹ (F has_vector_derivative f ?x) (at ?x)›*) limit (*‹((λb. (∑k = a..b. f (real_of_int k)) - F (real_of_int b) - (∑i<2 * N + 1. (bernoulli' (Suc i) / fact (Suc i)) *⇩R fs i (real_of_int b))) ⤏ C) at_top›*))[1]) (*goal: ‹((λb. (∑k = a..b. f (real_of_int k)) - F (real_of_int b) - (∑i<2 * N + 1. (bernoulli' (Suc i) / fact (Suc i)) *⇩R fs i (real_of_int b))) ⤏ C) at_top›*) apply simp (*proven 8 subgoals*) . theorem euler_maclaurin_strong_int': assumes "a ≤ b" shows "(∑k=a..b. f (of_int k)) = F (of_int b) + C + (1 / 2) *⇩R f (of_int b) + (∑i=1..N. (bernoulli (2*i) / fact (2*i)) *⇩R fs (2*i-1) (of_int b)) - EM_remainder (2*N+1) (fs (2*N+1)) b" proof (-) (*goal: ‹(∑k = a..b. f (real_of_int k)) = F (real_of_int b) + C + (1 / 2) *⇩R f (real_of_int b) + (∑i = 1..N. (bernoulli (2 * i) / fact (2 * i)) *⇩R fs (2 * i - 1) (real_of_int b)) - EM_remainder (2 * N + 1) (fs (2 * N + 1)) b›*) have "(∑k=a..b. f (real_of_int k)) = F (of_int b) + C + (∑i<2*N+1. (bernoulli' (Suc i) / fact (Suc i)) *⇩R fs i (of_int b)) - EM_remainder (2*N+1) (fs (2*N+1)) b" apply (rule euler_maclaurin_strong_int (*‹a ≤ ?b ⟹ (∑k = a..?b. f (real_of_int k)) = F (real_of_int ?b) + C + (∑i<2 * N + 1. (bernoulli' (Suc i) / fact (Suc i)) *⇩R fs i (real_of_int ?b)) - EM_remainder (2 * N + 1) (fs (2 * N + 1)) ?b›*)) (*goal: ‹(∑k = a..b. f (real_of_int k)) = F (real_of_int b) + C + (∑i<2 * N + 1. (bernoulli' (Suc i) / fact (Suc i)) *⇩R fs i (real_of_int b)) - EM_remainder (2 * N + 1) (fs (2 * N + 1)) b›*) by (simp only: lessThan_Suc_atMost (*‹{..<Suc ?k} = {..?k}›*) Suc_eq_plus1 [symmetric] (*‹?n + 1 = Suc ?n›*) assms (*‹a ≤ b›*)) also (*calculation: ‹(∑k = a..b. f (real_of_int k)) = F (real_of_int b) + C + (∑i<2 * N + 1. (bernoulli' (Suc i) / fact (Suc i)) *⇩R fs i (real_of_int b)) - EM_remainder (2 * N + 1) (fs (2 * N + 1)) b›*) have "{..<2*N+1} = insert 0 {1..2*N}" by auto also (*calculation: ‹(∑k = a..b. f (real_of_int k)) = F (real_of_int b) + C + (∑i∈insert 0 {1..2 * N}. (bernoulli' (Suc i) / fact (Suc i)) *⇩R fs i (real_of_int b)) - EM_remainder (2 * N + 1) (fs (2 * N + 1)) b›*) have "(∑i∈…. (bernoulli' (Suc i) / fact (Suc i)) *⇩R fs i (of_int b)) = (1 / 2) *⇩R f (of_int b) + (∑i∈{1..2*N}. (bernoulli' (Suc i) / fact (Suc i)) *⇩R fs i (of_int b))" apply (subst sum.insert (*‹⟦finite ?A; ?x ∉ ?A⟧ ⟹ sum ?g (insert ?x ?A) = ?g ?x + sum ?g ?A›*)) (*goals: 1. ‹finite {1..2 * N}› 2. ‹0 ∉ {1..2 * N}› 3. ‹(bernoulli' (Suc 0) / fact (Suc 0)) *⇩R fs 0 (real_of_int b) + (∑i = 1..2 * N. (bernoulli' (Suc i) / fact (Suc i)) *⇩R fs i (real_of_int b)) = (1 / 2) *⇩R f (real_of_int b) + (∑i = 1..2 * N. (bernoulli' (Suc i) / fact (Suc i)) *⇩R fs i (real_of_int b))› discuss goal 1*) apply ((auto simp: assms (*‹a ≤ b›*) bernoulli'_def (*‹bernoulli' ?n = (if ?n = 1 then 1 / 2 else bernoulli ?n)›*))[1]) (*discuss goal 2*) apply ((auto simp: assms (*‹a ≤ b›*) bernoulli'_def (*‹bernoulli' ?n = (if ?n = 1 then 1 / 2 else bernoulli ?n)›*))[1]) (*discuss goal 3*) apply ((auto simp: assms (*‹(a::int) ≤ (b::int)›*) bernoulli'_def (*‹bernoulli' (?n::nat) = (if ?n = (1::nat) then (1::real) / (2::real) else bernoulli ?n)›*))[1]) (*proven 3 subgoals*) . also (*calculation: ‹(∑k = a..b. f (real_of_int k)) = F (real_of_int b) + C + ((1 / 2) *⇩R f (real_of_int b) + (∑i = 1..2 * N. (bernoulli' (Suc i) / fact (Suc i)) *⇩R fs i (real_of_int b))) - EM_remainder (2 * N + 1) (fs (2 * N + 1)) b›*) have "(∑i∈{1..2*N}. (bernoulli' (Suc i) / fact (Suc i)) *⇩R fs i (of_int b)) = (∑i∈{1..N}. (bernoulli' (2*i) / fact (2*i)) *⇩R fs (2*i-1) (of_int b))" proof (rule sym (*‹?s = ?t ⟹ ?t = ?s›*), rule sum.reindex_bij_witness_not_neutral (*‹⟦finite ?S'; finite ?T'; ⋀a. a ∈ ?S - ?S' ⟹ ?i (?j a) = a; ⋀a. a ∈ ?S - ?S' ⟹ ?j a ∈ ?T - ?T'; ⋀b. b ∈ ?T - ?T' ⟹ ?j (?i b) = b; ⋀b. b ∈ ?T - ?T' ⟹ ?i b ∈ ?S - ?S'; ⋀a. a ∈ ?S' ⟹ ?g a = 0; ⋀b. b ∈ ?T' ⟹ ?h b = 0; ⋀a. a ∈ ?S ⟹ ?h (?j a) = ?g a⟧ ⟹ sum ?g ?S = sum ?h ?T›*)) (*goals: 1. ‹finite ?S'2› 2. ‹finite ?T'2› 3. ‹⋀a. a ∈ {1..N} - ?S'2 ⟹ ?i2 (?j2 a) = a› 4. ‹⋀a. a ∈ {1..N} - ?S'2 ⟹ ?j2 a ∈ {1..2 * N} - ?T'2› 5. ‹⋀b. b ∈ {1..2 * N} - ?T'2 ⟹ ?j2 (?i2 b) = b› 6. ‹⋀b. b ∈ {1..2 * N} - ?T'2 ⟹ ?i2 b ∈ {1..N} - ?S'2› 7. ‹⋀a. a ∈ ?S'2 ⟹ (bernoulli' (2 * a) / fact (2 * a)) *⇩R fs (2 * a - 1) (real_of_int b) = 0› 8. ‹⋀ba. ba ∈ ?T'2 ⟹ (bernoulli' (Suc ba) / fact (Suc ba)) *⇩R fs ba (real_of_int b) = 0› 9. ‹⋀a. a ∈ {1..N} ⟹ (bernoulli' (Suc (?j2 a)) / fact (Suc (?j2 a))) *⇩R fs (?j2 a) (real_of_int b) = (bernoulli' (2 * a) / fact (2 * a)) *⇩R fs (2 * a - 1) (real_of_int b)›*) fix i assume "i ∈ {1..2*N} - {i∈{1..2*N}. even i}" (*‹(i::nat) ∈ {1::nat..(2::nat) * (N::nat)} - {i::nat ∈ {1::nat..(2::nat) * N}. even i}›*) thus "2 * ((i + 1) div 2) - 1 = i" "(i + 1) div 2 ∈ {1..N} - {}" apply - (*goals: 1. ‹i ∈ {1..2 * N} - {i ∈ {1..2 * N}. even i} ⟹ 2 * ((i + 1) div 2) - 1 = i› 2. ‹i ∈ {1..2 * N} - {i ∈ {1..2 * N}. even i} ⟹ (i + 1) div 2 ∈ {1..N} - {}› discuss goal 1*) apply ((auto elim!: oddE (*‹⟦odd ?a; ⋀b. ?a = 2 * b + 1 ⟹ ?thesis⟧ ⟹ ?thesis›*))[1]) (*discuss goal 2*) apply ((auto elim!: oddE (*‹⟦odd ?a; ⋀b. ?a = 2 * b + 1 ⟹ ?thesis⟧ ⟹ ?thesis›*))[1]) (*proven 2 subgoals*) . qed (auto simp: bernoulli_odd_eq_0 (*‹⟦(?n::nat) ≠ (1::nat); odd ?n⟧ ⟹ bernoulli ?n = (0::real)›*) bernoulli'_def (*‹bernoulli' (?n::nat) = (if ?n = (1::nat) then (1::real) / (2::real) else bernoulli ?n)›*) 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*)) (*solves the remaining goals: 1. ‹finite {}› 2. ‹finite {i ∈ {1..2 * N}. even i}› 3. ‹⋀a. a ∈ {1..N} - {} ⟹ (2 * a - 1 + 1) div 2 = a› 4. ‹⋀a. a ∈ {1..N} - {} ⟹ 2 * a - 1 ∈ {1..2 * N} - {i ∈ {1..2 * N}. even i}› 5. ‹⋀a. a ∈ {} ⟹ (bernoulli' (2 * a) / fact (2 * a)) *⇩R fs (2 * a - 1) (real_of_int b) = 0› 6. ‹⋀ba. ba ∈ {i ∈ {1..2 * N}. even i} ⟹ (bernoulli' (Suc ba) / fact (Suc ba)) *⇩R fs ba (real_of_int b) = 0› 7. ‹⋀a. a ∈ {1..N} ⟹ (bernoulli' (Suc (2 * a - 1)) / fact (Suc (2 * a - 1))) *⇩R fs (2 * a - 1) (real_of_int b) = (bernoulli' (2 * a) / fact (2 * a)) *⇩R fs (2 * a - 1) (real_of_int b)›*) also (*calculation: ‹(∑k::int = a::int..b::int. (f::real ⇒ 'a::banach) (real_of_int k)) = (F::real ⇒ 'a::banach) (real_of_int b) + (C::'a::banach) + (((1::real) / (2::real)) *⇩R f (real_of_int b) + (∑i::nat = 1::nat..N::nat. (bernoulli' ((2::nat) * i) / fact ((2::nat) * i)) *⇩R (fs::nat ⇒ real ⇒ 'a::banach) ((2::nat) * i - (1::nat)) (real_of_int b))) - EM_remainder ((2::nat) * N + (1::nat)) (fs ((2::nat) * N + (1::nat))) b›*) have "… = (∑i∈{1..N}. (bernoulli (2*i) / fact (2*i)) *⇩R fs (2*i-1) (of_int b))" apply (intro sum.cong (*‹⟦?A = ?B; ⋀x. x ∈ ?B ⟹ ?g x = ?h x⟧ ⟹ sum ?g ?A = sum ?h ?B›*) refl (*‹?t = ?t›*)) (*goal: ‹(∑i = 1..N. (bernoulli' (2 * i) / fact (2 * i)) *⇩R fs (2 * i - 1) (real_of_int b)) = (∑i = 1..N. (bernoulli (2 * i) / fact (2 * i)) *⇩R fs (2 * i - 1) (real_of_int b))›*) by (auto simp: bernoulli'_def (*‹bernoulli' ?n = (if ?n = 1 then 1 / 2 else bernoulli ?n)›*)) finally (*calculation: ‹(∑k = a..b. f (real_of_int k)) = F (real_of_int b) + C + ((1 / 2) *⇩R f (real_of_int b) + (∑i = 1..N. (bernoulli (2 * i) / fact (2 * i)) *⇩R fs (2 * i - 1) (real_of_int b))) - EM_remainder (2 * N + 1) (fs (2 * N + 1)) b›*) show "?thesis" (*goal: ‹(∑k = a..b. f (real_of_int k)) = F (real_of_int b) + C + (1 / 2) *⇩R f (real_of_int b) + (∑i = 1..N. (bernoulli (2 * i) / fact (2 * i)) *⇩R fs (2 * i - 1) (real_of_int b)) - EM_remainder (2 * N + 1) (fs (2 * N + 1)) b›*) by (simp only: 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)›*)) qed end text ‹ For convenience, we also offer a version where the sum ranges over natural numbers instead of integers. › lemma sum_atLeastAtMost_of_int_nat_transfer: "(∑k=int a..int b. f (of_int k)) = (∑k=a..b. f (of_nat k))" apply (intro sum.reindex_bij_witness[of _ int nat] (*‹⟦⋀a::int. a ∈ (?S::int set) ⟹ int (nat a) = a; ⋀a::int. a ∈ ?S ⟹ nat a ∈ (?T::nat set); ⋀b::nat. b ∈ ?T ⟹ nat (int b) = b; ⋀b::nat. b ∈ ?T ⟹ int b ∈ ?S; ⋀a::int. a ∈ ?S ⟹ (?h::nat ⇒ ?'a) (nat a) = (?g::int ⇒ ?'a) a⟧ ⟹ sum ?g ?S = sum ?h ?T›*)) (*goals: 1. ‹⋀aa. aa ∈ {int a..int b} ⟹ int (nat aa) = aa› 2. ‹⋀aa. aa ∈ {int a..int b} ⟹ nat aa ∈ {a..b}› 3. ‹⋀ba. ba ∈ {a..b} ⟹ nat (int ba) = ba› 4. ‹⋀ba. ba ∈ {a..b} ⟹ int ba ∈ {int a..int b}› 5. ‹⋀aa. aa ∈ {int a..int b} ⟹ f (of_nat (nat aa)) = f (of_int aa)› 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 euler_maclaurin_nat_int_transfer: fixes F and f :: "real ⇒ 'a :: real_normed_vector" assumes "((λb. (∑k=a..b. f (real k)) - F (real b) - T (real b)) ⤏ C) at_top" shows "((λb. (∑k=int a..b. f (of_int k)) - F (of_int b) - T (of_int b)) ⤏ C) at_top" proof (-) (*goal: ‹((λb::int. (∑k::int = int (a::nat)..b. (f::real ⇒ 'a) (real_of_int k)) - (F::real ⇒ 'a) (real_of_int b) - (T::real ⇒ 'a) (real_of_int b)) ⤏ (C::'a)) at_top›*) have "*": "((λb. (∑k=int a..int b. f (of_int k)) - F (of_int (int b)) - T (of_int (int b))) ⤏ C) at_top" using assms (*‹(λb. (∑k = a..b. f (real k)) - F (real b) - T (real b)) ⇢ C›*) apply (subst sum_atLeastAtMost_of_int_nat_transfer (*‹(∑k = int ?a..int ?b. ?f (of_int k)) = (∑k = ?a..?b. ?f (of_nat k))›*)) (*goal: ‹(λb. (∑k = int a..int b. f (real_of_int k)) - F (real_of_int (int b)) - T (real_of_int (int b))) ⇢ C›*) by simp thus "?thesis" (*goal: ‹((λb. (∑k = int a..b. f (real_of_int k)) - F (real_of_int b) - T (real_of_int b)) ⤏ C) at_top›*) by (rule filterlim_int_of_nat_at_topD (*‹LIM x sequentially. ?f (int x) :> ?F ⟹ filterlim ?f ?F at_top›*)) qed locale euler_maclaurin_nat = fixes F f :: "real ⇒ 'a :: banach" fixes fs :: "nat ⇒ real ⇒ 'a" fixes a :: nat fixes N :: nat assumes N: "N > 0" fixes C :: 'a fixes Y :: "real set" assumes fin: "finite Y" assumes fs_0 [simp]: "fs 0 = f" assumes fs_cont [continuous_intros]: "⋀k. k ≤ N ⟹ continuous_on {real a..} (fs k)" assumes fs_deriv [derivative_intros]: "⋀k x. k < N ⟹ x ∈ {real a..} - Y ⟹ (fs k has_vector_derivative fs (Suc k) x) (at x)" assumes F_cont [continuous_intros]: "continuous_on {real a..} F" assumes F_deriv [derivative_intros]: "⋀x. x ∈ {real a..} - Y ⟹ (F has_vector_derivative f x) (at x)" assumes limit: "((λb. (∑k=a..b. f k) - F (real b) - (∑i<N. (bernoulli' (Suc i) / fact (Suc i)) *⇩R fs i (real b))) ⤏ C) at_top" begin sublocale euler_maclaurin_int F f fs "int a" N C Y apply standard (*goals: 1. ‹0 < N› 2. ‹finite Y› 3. ‹fs 0 = f› 4. ‹⋀k. k ≤ N ⟹ continuous_on {real_of_int (int a)..} (fs k)› 5. ‹⋀k x. ⟦k < N; x ∈ {real_of_int (int a)..} - Y⟧ ⟹ (fs k has_vector_derivative fs (Suc k) x) (at x)› 6. ‹continuous_on {real_of_int (int a)..} F› 7. ‹⋀x. x ∈ {real_of_int (int a)..} - Y ⟹ (F has_vector_derivative f x) (at x)› 8. ‹((λb. (∑k = int a..b. f (real_of_int k)) - F (real_of_int b) - (∑i<N. (bernoulli' (Suc i) / fact (Suc i)) *⇩R fs i (real_of_int b))) ⤏ C) at_top› discuss goal 1*) apply ((insert N (*‹0 < N›*) fin (*‹finite Y›*) fs_cont (*‹?k ≤ N ⟹ continuous_on {real a..} (fs ?k)›*) fs_deriv (*‹⟦?k < N; ?x ∈ {real a..} - Y⟧ ⟹ (fs ?k has_vector_derivative fs (Suc ?k) ?x) (at ?x)›*) F_cont (*‹continuous_on {real a..} F›*) F_deriv (*‹?x ∈ {real a..} - Y ⟹ (F has_vector_derivative f ?x) (at ?x)›*) euler_maclaurin_nat_int_transfer[OF limit] (*‹((λb. (∑k = int a..b. f (real_of_int k)) - F (real_of_int b) - (∑i<N. (bernoulli' (Suc i) / fact (Suc i)) *⇩R fs i (real_of_int b))) ⤏ C) at_top›*))[1]) (*top goal: ‹0 < N› and 7 goals remain*) apply simp (*discuss goal 2*) apply ((insert N (*‹(0::nat) < (N::nat)›*) fin (*‹finite (Y::real set)›*) fs_cont (*‹(?k::nat) ≤ (N::nat) ⟹ continuous_on {real (a::nat)..} ((fs::nat ⇒ real ⇒ 'a) ?k)›*) fs_deriv (*‹⟦(?k::nat) < (N::nat); (?x::real) ∈ {real (a::nat)..} - (Y::real set)⟧ ⟹ ((fs::nat ⇒ real ⇒ 'a) ?k has_vector_derivative fs (Suc ?k) ?x) (at ?x)›*) F_cont (*‹continuous_on {real (a::nat)..} (F::real ⇒ 'a)›*) F_deriv (*‹(?x::real) ∈ {real (a::nat)..} - (Y::real set) ⟹ ((F::real ⇒ 'a) has_vector_derivative (f::real ⇒ 'a) ?x) (at ?x)›*) euler_maclaurin_nat_int_transfer[OF limit] (*‹((λb::int. (∑k::int = int (a::nat)..b. (f::real ⇒ 'a) (real_of_int k)) - (F::real ⇒ 'a) (real_of_int b) - (∑i::nat<N::nat. (bernoulli' (Suc i) / fact (Suc i)) *⇩R (fs::nat ⇒ real ⇒ 'a) i (real_of_int b))) ⤏ (C::'a)) at_top›*))[1]) (*top goal: ‹finite Y› and 6 goals remain*) apply simp (*discuss goal 3*) apply ((insert N (*‹0 < N›*) fin (*‹finite Y›*) fs_cont (*‹?k ≤ N ⟹ continuous_on {real a..} (fs ?k)›*) fs_deriv (*‹⟦?k < N; ?x ∈ {real a..} - Y⟧ ⟹ (fs ?k has_vector_derivative fs (Suc ?k) ?x) (at ?x)›*) F_cont (*‹continuous_on {real a..} F›*) F_deriv (*‹?x ∈ {real a..} - Y ⟹ (F has_vector_derivative f ?x) (at ?x)›*) euler_maclaurin_nat_int_transfer[OF limit] (*‹((λb. (∑k = int a..b. f (real_of_int k)) - F (real_of_int b) - (∑i<N. (bernoulli' (Suc i) / fact (Suc i)) *⇩R fs i (real_of_int b))) ⤏ C) at_top›*))[1]) (*top goal: ‹fs 0 = f› and 5 goals remain*) apply simp (*discuss goal 4*) apply ((insert N (*‹0 < N›*) fin (*‹finite Y›*) fs_cont (*‹?k ≤ N ⟹ continuous_on {real a..} (fs ?k)›*) fs_deriv (*‹⟦?k < N; ?x ∈ {real a..} - Y⟧ ⟹ (fs ?k has_vector_derivative fs (Suc ?k) ?x) (at ?x)›*) F_cont (*‹continuous_on {real a..} F›*) F_deriv (*‹?x ∈ {real a..} - Y ⟹ (F has_vector_derivative f ?x) (at ?x)›*) euler_maclaurin_nat_int_transfer[OF limit] (*‹((λb. (∑k = int a..b. f (real_of_int k)) - F (real_of_int b) - (∑i<N. (bernoulli' (Suc i) / fact (Suc i)) *⇩R fs i (real_of_int b))) ⤏ C) at_top›*))[1]) (*top goal: ‹⋀k. k ≤ N ⟹ continuous_on {real_of_int (int a)..} (fs k)› and 4 goals remain*) apply simp (*discuss goal 5*) apply ((insert N (*‹0 < N›*) fin (*‹finite Y›*) fs_cont (*‹?k ≤ N ⟹ continuous_on {real a..} (fs ?k)›*) fs_deriv (*‹⟦?k < N; ?x ∈ {real a..} - Y⟧ ⟹ (fs ?k has_vector_derivative fs (Suc ?k) ?x) (at ?x)›*) F_cont (*‹continuous_on {real a..} F›*) F_deriv (*‹?x ∈ {real a..} - Y ⟹ (F has_vector_derivative f ?x) (at ?x)›*) euler_maclaurin_nat_int_transfer[OF limit] (*‹((λb. (∑k = int a..b. f (real_of_int k)) - F (real_of_int b) - (∑i<N. (bernoulli' (Suc i) / fact (Suc i)) *⇩R fs i (real_of_int b))) ⤏ C) at_top›*))[1]) (*top goal: ‹⋀k x. ⟦k < N; x ∈ {real_of_int (int a)..} - Y⟧ ⟹ (fs k has_vector_derivative fs (Suc k) x) (at x)› and 3 goals remain*) apply simp (*discuss goal 6*) apply ((insert N (*‹0 < N›*) fin (*‹finite Y›*) fs_cont (*‹?k ≤ N ⟹ continuous_on {real a..} (fs ?k)›*) fs_deriv (*‹⟦?k < N; ?x ∈ {real a..} - Y⟧ ⟹ (fs ?k has_vector_derivative fs (Suc ?k) ?x) (at ?x)›*) F_cont (*‹continuous_on {real a..} F›*) F_deriv (*‹?x ∈ {real a..} - Y ⟹ (F has_vector_derivative f ?x) (at ?x)›*) euler_maclaurin_nat_int_transfer[OF limit] (*‹((λb. (∑k = int a..b. f (real_of_int k)) - F (real_of_int b) - (∑i<N. (bernoulli' (Suc i) / fact (Suc i)) *⇩R fs i (real_of_int b))) ⤏ C) at_top›*))[1]) (*top goal: ‹continuous_on {real_of_int (int a)..} F› and 2 goals remain*) apply simp (*discuss goal 7*) apply ((insert N (*‹0 < N›*) fin (*‹finite Y›*) fs_cont (*‹?k ≤ N ⟹ continuous_on {real a..} (fs ?k)›*) fs_deriv (*‹⟦?k < N; ?x ∈ {real a..} - Y⟧ ⟹ (fs ?k has_vector_derivative fs (Suc ?k) ?x) (at ?x)›*) F_cont (*‹continuous_on {real a..} F›*) F_deriv (*‹?x ∈ {real a..} - Y ⟹ (F has_vector_derivative f ?x) (at ?x)›*) euler_maclaurin_nat_int_transfer[OF limit] (*‹((λb. (∑k = int a..b. f (real_of_int k)) - F (real_of_int b) - (∑i<N. (bernoulli' (Suc i) / fact (Suc i)) *⇩R fs i (real_of_int b))) ⤏ C) at_top›*))[1]) (*top goal: ‹⋀x::real. x ∈ {real_of_int (int (a::nat))..} - (Y::real set) ⟹ ((F::real ⇒ 'a) has_vector_derivative (f::real ⇒ 'a) x) (at x)› and 1 goal remains*) apply simp (*discuss goal 8*) apply ((insert N (*‹0 < N›*) fin (*‹finite Y›*) fs_cont (*‹?k ≤ N ⟹ continuous_on {real a..} (fs ?k)›*) fs_deriv (*‹⟦?k < N; ?x ∈ {real a..} - Y⟧ ⟹ (fs ?k has_vector_derivative fs (Suc ?k) ?x) (at ?x)›*) F_cont (*‹continuous_on {real a..} F›*) F_deriv (*‹?x ∈ {real a..} - Y ⟹ (F has_vector_derivative f ?x) (at ?x)›*) euler_maclaurin_nat_int_transfer[OF limit] (*‹((λb. (∑k = int a..b. f (real_of_int k)) - F (real_of_int b) - (∑i<N. (bernoulli' (Suc i) / fact (Suc i)) *⇩R fs i (real_of_int b))) ⤏ C) at_top›*))[1]) (*goal: ‹((λb. (∑k = int a..b. f (real_of_int k)) - F (real_of_int b) - (∑i<N. (bernoulli' (Suc i) / fact (Suc i)) *⇩R fs i (real_of_int b))) ⤏ C) at_top›*) apply simp (*proven 8 subgoals*) . theorem euler_maclaurin_strong_nat: assumes ab: "a ≤ b" defines "S ≡ (∑k=a..b. f (real k))" shows "S = F (real b) + C + (∑i<N. (bernoulli' (Suc i) / fact (Suc i)) *⇩R fs i (real b)) - EM_remainder N (fs N) (int b)" using euler_maclaurin_strong_int[of "int b"] (*‹int a ≤ int b ⟹ (∑k = int a..int b. f (real_of_int k)) = F (real_of_int (int b)) + C + (∑i<N. (bernoulli' (Suc i) / fact (Suc i)) *⇩R fs i (real_of_int (int b))) - EM_remainder N (fs N) (int b)›*) by (simp add: assms (*‹a ≤ b› ‹S ≡ ∑k = a..b. f (real k)›*) sum_atLeastAtMost_of_int_nat_transfer (*‹(∑k = int ?a..int ?b. ?f (of_int k)) = (∑k = ?a..?b. ?f (of_nat k))›*)) end locale euler_maclaurin_nat' = fixes F f :: "real ⇒ 'a :: banach" fixes fs :: "nat ⇒ real ⇒ 'a" fixes a :: nat fixes N :: nat fixes C :: 'a fixes Y :: "real set" assumes fin: "finite Y" assumes fs_0 [simp]: "fs 0 = f" assumes fs_cont [continuous_intros]: "⋀k. k ≤ 2*N+1 ⟹ continuous_on {real a..} (fs k)" assumes fs_deriv [derivative_intros]: "⋀k x. k ≤ 2*N ⟹ x ∈ {real a..} - Y ⟹ (fs k has_vector_derivative fs (Suc k) x) (at x)" assumes F_cont [continuous_intros]: "continuous_on {real a..} F" assumes F_deriv [derivative_intros]: "⋀x. x ∈ {real a..} - Y ⟹ (F has_vector_derivative f x) (at x)" assumes limit: "((λb. (∑k=a..b. f k) - F (real b) - (∑i<2*N+1. (bernoulli' (Suc i) / fact (Suc i)) *⇩R fs i (real b))) ⤏ C) at_top" begin sublocale euler_maclaurin_int' F f fs "int a" N C Y apply standard (*goals: 1. ‹finite Y› 2. ‹fs 0 = f› 3. ‹⋀k. k ≤ 2 * N + 1 ⟹ continuous_on {real_of_int (int a)..} (fs k)› 4. ‹⋀k x. ⟦k ≤ 2 * N; x ∈ {real_of_int (int a)..} - Y⟧ ⟹ (fs k has_vector_derivative fs (Suc k) x) (at x)› 5. ‹continuous_on {real_of_int (int a)..} F› 6. ‹⋀x. x ∈ {real_of_int (int a)..} - Y ⟹ (F has_vector_derivative f x) (at x)› 7. ‹((λb. (∑k = int a..b. f (real_of_int k)) - F (real_of_int b) - (∑i<2 * N + 1. (bernoulli' (Suc i) / fact (Suc i)) *⇩R fs i (real_of_int b))) ⤏ C) at_top› discuss goal 1*) apply ((insert fin (*‹finite Y›*) fs_cont (*‹?k ≤ 2 * N + 1 ⟹ continuous_on {real a..} (fs ?k)›*) fs_deriv (*‹⟦?k ≤ 2 * N; ?x ∈ {real a..} - Y⟧ ⟹ (fs ?k has_vector_derivative fs (Suc ?k) ?x) (at ?x)›*) F_cont (*‹continuous_on {real a..} F›*) F_deriv (*‹?x ∈ {real a..} - Y ⟹ (F has_vector_derivative f ?x) (at ?x)›*) euler_maclaurin_nat_int_transfer[OF limit] (*‹((λb. (∑k = int a..b. f (real_of_int k)) - F (real_of_int b) - (∑i<2 * N + 1. (bernoulli' (Suc i) / fact (Suc i)) *⇩R fs i (real_of_int b))) ⤏ C) at_top›*))[1]) (*top goal: ‹finite Y› and 6 goals remain*) apply simp (*discuss goal 2*) apply ((insert fin (*‹finite Y›*) fs_cont (*‹?k ≤ 2 * N + 1 ⟹ continuous_on {real a..} (fs ?k)›*) fs_deriv (*‹⟦?k ≤ 2 * N; ?x ∈ {real a..} - Y⟧ ⟹ (fs ?k has_vector_derivative fs (Suc ?k) ?x) (at ?x)›*) F_cont (*‹continuous_on {real a..} F›*) F_deriv (*‹?x ∈ {real a..} - Y ⟹ (F has_vector_derivative f ?x) (at ?x)›*) euler_maclaurin_nat_int_transfer[OF limit] (*‹((λb. (∑k = int a..b. f (real_of_int k)) - F (real_of_int b) - (∑i<2 * N + 1. (bernoulli' (Suc i) / fact (Suc i)) *⇩R fs i (real_of_int b))) ⤏ C) at_top›*))[1]) (*top goal: ‹fs 0 = f› and 5 goals remain*) apply simp (*discuss goal 3*) apply ((insert fin (*‹finite (Y::real set)›*) fs_cont (*‹(?k::nat) ≤ (2::nat) * (N::nat) + (1::nat) ⟹ continuous_on {real (a::nat)..} ((fs::nat ⇒ real ⇒ 'a) ?k)›*) fs_deriv (*‹⟦(?k::nat) ≤ (2::nat) * (N::nat); (?x::real) ∈ {real (a::nat)..} - (Y::real set)⟧ ⟹ ((fs::nat ⇒ real ⇒ 'a) ?k has_vector_derivative fs (Suc ?k) ?x) (at ?x)›*) F_cont (*‹continuous_on {real (a::nat)..} (F::real ⇒ 'a)›*) F_deriv (*‹(?x::real) ∈ {real (a::nat)..} - (Y::real set) ⟹ ((F::real ⇒ 'a) has_vector_derivative (f::real ⇒ 'a) ?x) (at ?x)›*) euler_maclaurin_nat_int_transfer[OF limit] (*‹((λb::int. (∑k::int = int (a::nat)..b. (f::real ⇒ 'a) (real_of_int k)) - (F::real ⇒ 'a) (real_of_int b) - (∑i::nat<(2::nat) * (N::nat) + (1::nat). (bernoulli' (Suc i) / fact (Suc i)) *⇩R (fs::nat ⇒ real ⇒ 'a) i (real_of_int b))) ⤏ (C::'a)) at_top›*))[1]) (*top goal: ‹⋀k. k ≤ 2 * N + 1 ⟹ continuous_on {real_of_int (int a)..} (fs k)› and 4 goals remain*) apply simp (*discuss goal 4*) apply ((insert fin (*‹finite Y›*) fs_cont (*‹?k ≤ 2 * N + 1 ⟹ continuous_on {real a..} (fs ?k)›*) fs_deriv (*‹⟦?k ≤ 2 * N; ?x ∈ {real a..} - Y⟧ ⟹ (fs ?k has_vector_derivative fs (Suc ?k) ?x) (at ?x)›*) F_cont (*‹continuous_on {real a..} F›*) F_deriv (*‹?x ∈ {real a..} - Y ⟹ (F has_vector_derivative f ?x) (at ?x)›*) euler_maclaurin_nat_int_transfer[OF limit] (*‹((λb. (∑k = int a..b. f (real_of_int k)) - F (real_of_int b) - (∑i<2 * N + 1. (bernoulli' (Suc i) / fact (Suc i)) *⇩R fs i (real_of_int b))) ⤏ C) at_top›*))[1]) (*top goal: ‹⋀(k::nat) x::real. ⟦k ≤ (2::nat) * (N::nat); x ∈ {real_of_int (int (a::nat))..} - (Y::real set)⟧ ⟹ ((fs::nat ⇒ real ⇒ 'a) k has_vector_derivative fs (Suc k) x) (at x)› and 3 goals remain*) apply simp (*discuss goal 5*) apply ((insert fin (*‹finite Y›*) fs_cont (*‹?k ≤ 2 * N + 1 ⟹ continuous_on {real a..} (fs ?k)›*) fs_deriv (*‹⟦?k ≤ 2 * N; ?x ∈ {real a..} - Y⟧ ⟹ (fs ?k has_vector_derivative fs (Suc ?k) ?x) (at ?x)›*) F_cont (*‹continuous_on {real a..} F›*) F_deriv (*‹?x ∈ {real a..} - Y ⟹ (F has_vector_derivative f ?x) (at ?x)›*) euler_maclaurin_nat_int_transfer[OF limit] (*‹((λb. (∑k = int a..b. f (real_of_int k)) - F (real_of_int b) - (∑i<2 * N + 1. (bernoulli' (Suc i) / fact (Suc i)) *⇩R fs i (real_of_int b))) ⤏ C) at_top›*))[1]) (*top goal: ‹continuous_on {real_of_int (int a)..} F› and 2 goals remain*) apply simp (*discuss goal 6*) apply ((insert fin (*‹finite (Y::real set)›*) fs_cont (*‹(?k::nat) ≤ (2::nat) * (N::nat) + (1::nat) ⟹ continuous_on {real (a::nat)..} ((fs::nat ⇒ real ⇒ 'a) ?k)›*) fs_deriv (*‹⟦(?k::nat) ≤ (2::nat) * (N::nat); (?x::real) ∈ {real (a::nat)..} - (Y::real set)⟧ ⟹ ((fs::nat ⇒ real ⇒ 'a) ?k has_vector_derivative fs (Suc ?k) ?x) (at ?x)›*) F_cont (*‹continuous_on {real (a::nat)..} (F::real ⇒ 'a)›*) F_deriv (*‹(?x::real) ∈ {real (a::nat)..} - (Y::real set) ⟹ ((F::real ⇒ 'a) has_vector_derivative (f::real ⇒ 'a) ?x) (at ?x)›*) euler_maclaurin_nat_int_transfer[OF limit] (*‹((λb::int. (∑k::int = int (a::nat)..b. (f::real ⇒ 'a) (real_of_int k)) - (F::real ⇒ 'a) (real_of_int b) - (∑i::nat<(2::nat) * (N::nat) + (1::nat). (bernoulli' (Suc i) / fact (Suc i)) *⇩R (fs::nat ⇒ real ⇒ 'a) i (real_of_int b))) ⤏ (C::'a)) at_top›*))[1]) (*top goal: ‹⋀x. x ∈ {real_of_int (int a)..} - Y ⟹ (F has_vector_derivative f x) (at x)› and 1 goal remains*) apply simp (*discuss goal 7*) apply ((insert fin (*‹finite Y›*) fs_cont (*‹?k ≤ 2 * N + 1 ⟹ continuous_on {real a..} (fs ?k)›*) fs_deriv (*‹⟦?k ≤ 2 * N; ?x ∈ {real a..} - Y⟧ ⟹ (fs ?k has_vector_derivative fs (Suc ?k) ?x) (at ?x)›*) F_cont (*‹continuous_on {real a..} F›*) F_deriv (*‹?x ∈ {real a..} - Y ⟹ (F has_vector_derivative f ?x) (at ?x)›*) euler_maclaurin_nat_int_transfer[OF limit] (*‹((λb. (∑k = int a..b. f (real_of_int k)) - F (real_of_int b) - (∑i<2 * N + 1. (bernoulli' (Suc i) / fact (Suc i)) *⇩R fs i (real_of_int b))) ⤏ C) at_top›*))[1]) (*goal: ‹((λb. (∑k = int a..b. f (real_of_int k)) - F (real_of_int b) - (∑i<2 * N + 1. (bernoulli' (Suc i) / fact (Suc i)) *⇩R fs i (real_of_int b))) ⤏ C) at_top›*) apply simp (*proven 7 subgoals*) . theorem euler_maclaurin_strong_nat': assumes "a ≤ b" shows "(∑k=a..b. f (real k)) = F (real b) + C + (1 / 2) *⇩R f (real b) + (∑i=1..N. (bernoulli (2*i) / fact (2*i)) *⇩R fs (2*i-1) (real b)) - EM_remainder (2*N+1) (fs (2*N+1)) b" using euler_maclaurin_strong_int'[of b] (*‹int a ≤ int b ⟹ (∑k = int a..int b. f (real_of_int k)) = F (real_of_int (int b)) + C + (1 / 2) *⇩R f (real_of_int (int b)) + (∑i = 1..N. (bernoulli (2 * i) / fact (2 * i)) *⇩R fs (2 * i - 1) (real_of_int (int b))) - EM_remainder (2 * N + 1) (fs (2 * N + 1)) (int b)›*) by (simp add: assms (*‹a ≤ b›*) sum_atLeastAtMost_of_int_nat_transfer (*‹(∑k = int ?a..int ?b. ?f (of_int k)) = (∑k = ?a..?b. ?f (of_nat k))›*)) end subsection ‹Bounds on the remainder term› text ‹ The following theorems provide some simple means to bound the remainder terms. In practice, better bounds can often be obtained e.\,g. for the $n$-th remainder term by expanding it to the sum of the first discarded term in the expansion and the $n+1$-th remainder term. › lemma fixes f :: "real ⇒ 'a :: {real_normed_field, banach}" and g g' :: "real ⇒ real" assumes fin: "finite Y" assumes pbernpoly_bound: "∀x. ¦pbernpoly n x¦ ≤ D" assumes cont_f: "continuous_on {a..} f" assumes cont_g: "continuous_on {a..} g" assumes cont_g': "continuous_on {a..} g'" assumes limit_g: "(g ⤏ C) at_top" assumes f_bound: "⋀x. x ≥ a ⟹ norm (f x) ≤ g' x" assumes deriv: "⋀x. x ∈ {a..} - Y ⟹ (g has_field_derivative g' x) (at x)" shows norm_EM_remainder_le_strong_int: "∀x. of_int x ≥ a ⟶ norm (EM_remainder n f x) ≤ D / fact n * (C - g x)" and norm_EM_remainder_le_strong_nat: "∀x. real x ≥ a ⟶ norm (EM_remainder n f (int x)) ≤ D / fact n * (C - g x)" proof (-) (*goals: 1. ‹∀x. a ≤ real_of_int x ⟶ norm (EM_remainder n f x) ≤ D / fact n * (C - g (real_of_int x))› 2. ‹∀x. a ≤ real x ⟶ norm (EM_remainder n f (int x)) ≤ D / fact n * (C - g (real x))›*) from pbernpoly_bound (*‹∀x::real. ¦pbernpoly (n::nat) x¦ ≤ (D::real)›*) have D: "norm (pbernpoly n x) ≤ D" for x by auto from this[of 0] (*‹norm (pbernpoly n 0) ≤ D›*) have D_nonneg: "D ≥ 0" by simp define D' where "D' = D / fact n" from D_nonneg (*‹(0::real) ≤ (D::real)›*) have D'_nonneg: "D' ≥ 0" by (simp add: D'_def (*‹D' = D / fact n›*)) have bound: "norm (EM_remainder' n f x y) ≤ D' * (g y - g x)" if xy: "x ≥ a" "x ≤ y" for x :: real and y :: real proof (-) (*goal: ‹norm (EM_remainder' n f x y) ≤ D' * (g y - g x)›*) have "norm (EM_remainder' n f x y) = norm (integral {x..y} (λt. pbernpoly n t *⇩R f t)) / fact n" by (simp add: EM_remainder'_def (*‹EM_remainder' (?n::nat) (?f::real ⇒ ?'a) (?a::real) (?b::real) = ((- (1::real)) ^ Suc ?n / fact ?n) *⇩R integral {?a..?b} (λt::real. pbernpoly ?n t *⇩R ?f t)›*)) also (*calculation: ‹norm (EM_remainder' n f x y) = norm (integral {x..y} (λt. pbernpoly n t *⇩R f t)) / fact n›*) have "(λt. D * g' t) integrable_on {x..y}" using xy (*‹a ≤ x› ‹x ≤ y›*) apply (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 272 facts*) continuous_on_subset[OF cont_g'] (*‹?t ⊆ {a..} ⟹ continuous_on ?t g'›*)) (*goal: ‹(λt::real. (D::real) * (g'::real ⇒ real) t) integrable_on {x::real..y::real}›*) by auto hence "norm (integral {x..y} (λt. pbernpoly n t *⇩R f t)) ≤ integral {x..y} (λt. D * g' t)" using D (*‹norm (pbernpoly (n::nat) (?x::real)) ≤ (D::real)›*) D_nonneg (*‹0 ≤ D›*) xy (*‹a ≤ x› ‹x ≤ y›*) apply (intro integral_norm_bound_integral (*‹⟦(?f::?'n ⇒ ?'a) integrable_on (?S::?'n set); (?g::?'n ⇒ real) integrable_on ?S; ⋀x::?'n. x ∈ ?S ⟹ norm (?f x) ≤ ?g x⟧ ⟹ norm (integral ?S ?f) ≤ integral ?S ?g›*) integrable_EM_remainder' (*‹continuous_on {?a::real..?b::real} (?f::real ⇒ ?'a) ⟹ (λt::real. pbernpoly (?n::nat) t *⇩R ?f t) integrable_on {?a..?b}›*) continuous_on_subset[OF cont_f] (*‹(?t::real set) ⊆ {a::real..} ⟹ continuous_on ?t (f::real ⇒ 'a)›*)) (*goals: 1. ‹⟦(λt. D * g' t) integrable_on {x..y}; ⋀x. norm (pbernpoly n x) ≤ D; 0 ≤ D; a ≤ x; x ≤ y⟧ ⟹ {x..y} ⊆ {a..}› 2. ‹⟦(λt. D * g' t) integrable_on {x..y}; ⋀x. norm (pbernpoly n x) ≤ D; 0 ≤ D; a ≤ x; x ≤ y⟧ ⟹ (λt. D * g' t) integrable_on {x..y}› 3. ‹⋀xa. ⟦(λt. D * g' t) integrable_on {x..y}; ⋀x. norm (pbernpoly n x) ≤ D; 0 ≤ D; a ≤ x; x ≤ y; xa ∈ {x..y}⟧ ⟹ norm (pbernpoly n xa *⇩R f xa) ≤ D * g' xa› discuss goal 1*) apply ((auto intro!: mult_mono (*‹⟦?a ≤ ?b; ?c ≤ ?d; 0 ≤ ?b; 0 ≤ ?c⟧ ⟹ ?a * ?c ≤ ?b * ?d›*) f_bound (*‹a ≤ ?x ⟹ norm (f ?x) ≤ g' ?x›*))[1]) (*discuss goal 2*) apply ((auto intro!: mult_mono (*‹⟦?a ≤ ?b; ?c ≤ ?d; 0 ≤ ?b; 0 ≤ ?c⟧ ⟹ ?a * ?c ≤ ?b * ?d›*) f_bound (*‹a ≤ ?x ⟹ norm (f ?x) ≤ g' ?x›*))[1]) (*discuss goal 3*) apply ((auto intro!: mult_mono (*‹⟦?a ≤ ?b; ?c ≤ ?d; 0 ≤ ?b; 0 ≤ ?c⟧ ⟹ ?a * ?c ≤ ?b * ?d›*) f_bound (*‹a ≤ ?x ⟹ norm (f ?x) ≤ g' ?x›*))[1]) (*proven 3 subgoals*) . also (*calculation: ‹(⋀(x::real) y::real. x ≤ y ⟹ x / fact (n::nat) ≤ y / fact n) ⟹ norm (EM_remainder' n (f::real ⇒ 'a::{banach,real_normed_field}) (x::real) (y::real)) ≤ integral {x..y} (λt::real. (D::real) * (g'::real ⇒ real) t) / fact n›*) have "… = D * integral {x..y} g'" by simp also (*calculation: ‹(⋀x y. x ≤ y ⟹ x / fact n ≤ y / fact n) ⟹ norm (EM_remainder' n f x y) ≤ D * integral {x..y} g' / fact n›*) have "(g' has_integral (g y - g x)) {x..y}" using xy (*‹a ≤ x› ‹x ≤ y›*) apply (intro fundamental_theorem_of_calculus_strong[OF fin] (*‹⟦?a ≤ ?b; ⋀x. x ∈ {?a..?b} - Y ⟹ (?f has_vector_derivative ?f' x) (at x); continuous_on {?a..?b} ?f⟧ ⟹ (?f' has_integral ?f ?b - ?f ?a) {?a..?b}›*) continuous_on_subset[OF cont_g] (*‹?t ⊆ {a..} ⟹ continuous_on ?t g›*)) (*goals: 1. ‹⟦(a::real) ≤ (x::real); x ≤ (y::real)⟧ ⟹ x ≤ y› 2. ‹⋀xa::real. ⟦(a::real) ≤ (x::real); x ≤ (y::real); xa ∈ {x..y} - (Y::real set)⟧ ⟹ ((g::real ⇒ real) has_vector_derivative (g'::real ⇒ real) xa) (at xa)› 3. ‹⟦(a::real) ≤ (x::real); x ≤ (y::real)⟧ ⟹ {x..y} ⊆ {a..}› discuss goal 1*) apply ((auto simp: has_real_derivative_iff_has_vector_derivative [symmetric] (*‹(?f has_vector_derivative ?y) ?F = (?f has_real_derivative ?y) ?F›*) intro!: deriv (*‹?x ∈ {a..} - Y ⟹ (g has_real_derivative g' ?x) (at ?x)›*))[1]) (*discuss goal 2*) apply ((auto simp: has_real_derivative_iff_has_vector_derivative [symmetric] (*‹(?f has_vector_derivative ?y) ?F = (?f has_real_derivative ?y) ?F›*) intro!: deriv (*‹?x ∈ {a..} - Y ⟹ (g has_real_derivative g' ?x) (at ?x)›*))[1]) (*discuss goal 3*) apply ((auto simp: has_real_derivative_iff_has_vector_derivative [symmetric] (*‹(?f has_vector_derivative ?y) ?F = (?f has_real_derivative ?y) ?F›*) intro!: deriv (*‹?x ∈ {a..} - Y ⟹ (g has_real_derivative g' ?x) (at ?x)›*))[1]) (*proven 3 subgoals*) . hence "integral {x..y} g' = g y - g x" by (simp add: has_integral_iff (*‹(?f has_integral ?i) ?S = (?f integrable_on ?S ∧ integral ?S ?f = ?i)›*)) finally (*calculation: ‹(⋀x y. x ≤ y ⟹ x / fact n ≤ y / fact n) ⟹ norm (EM_remainder' n f x y) ≤ D * (g y - g x) / fact n›*) show "?thesis" (*goal: ‹norm (EM_remainder' n f x y) ≤ D' * (g y - g x)›*) by (simp add: D'_def (*‹D' = D / fact n›*) 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 have lim: "((λy. EM_remainder' n f x (of_int y)) ⤏ EM_remainder n f x) at_top" if x: "x ≥ a" for x :: int proof (-) (*goal: ‹((λy. EM_remainder' n f (real_of_int x) (real_of_int y)) ⤏ EM_remainder n f x) at_top›*) have "(λn. g (real n)) ⇢ C" by (rule filterlim_compose[OF limit_g filterlim_real_sequentially] (*‹(λx. g (real x)) ⇢ C›*)) hence Cauchy: "Cauchy (λn. g (real n))" using convergent_eq_Cauchy (*‹(∃l. ?S ⇢ l) = Cauchy ?S›*) by blast have "Cauchy (λy. EM_remainder' n f x (int y))" apply (rule CauchyI' (*‹(⋀e. 0 < e ⟹ ∃M. ∀m≥M. ∀n>m. dist (?X m) (?X n) < e) ⟹ Cauchy ?X›*)) (*goal: ‹Cauchy (λy::nat. EM_remainder' (n::nat) (f::real ⇒ 'a) (real_of_int (x::int)) (real_of_int (int y)))›*) proof (goal_cases) (*goal: ‹⋀e. 0 < e ⟹ ∃M. ∀m≥M. ∀na>m. dist (EM_remainder' n f (real_of_int x) (real_of_int (int m))) (EM_remainder' n f (real_of_int x) (real_of_int (int na))) < e›*) case (1 ε) (*‹0 < ε›*) define ε' where "ε' = (if D' = 0 then 1 else ε / (2*D'))" from ‹ε > 0› (*‹0 < ε›*) D'_nonneg (*‹0 ≤ D'›*) have "ε'": "ε' > 0" by (simp add: ε'_def (*‹ε' = (if D' = 0 then 1 else ε / (2 * D'))›*) 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*)) from CauchyD[OF Cauchy this] (*‹∃M. ∀m≥M. ∀n≥M. norm (g (real m) - g (real n)) < ε'›*) obtain M where M: "⋀m n. m ≥ M ⟹ n ≥ M ⟹ norm (g (real m) - g (real n)) < ε'" (*goal: ‹(⋀M. (⋀m n. ⟦M ≤ m; M ≤ n⟧ ⟹ norm (g (real m) - g (real n)) < ε') ⟹ thesis) ⟹ thesis›*) by blast show "?case" (*goal: ‹∃M. ∀m≥M. ∀na>m. dist (EM_remainder' n f (real_of_int x) (real_of_int (int m))) (EM_remainder' n f (real_of_int x) (real_of_int (int na))) < ε›*) apply (intro CauchyI' (*‹(⋀e. 0 < e ⟹ ∃M. ∀m≥M. ∀n>m. dist (?X m) (?X n) < e) ⟹ Cauchy ?X›*) exI[of _ "max (max 0 M) (nat x)"] (*‹?P (max (max 0 M) (nat x)) ⟹ ∃x. ?P x›*) allI (*‹(⋀x. ?P x) ⟹ ∀x. ?P x›*) impI (*‹(?P ⟹ ?Q) ⟹ ?P ⟶ ?Q›*)) (*goal: ‹∃M. ∀m≥M. ∀na>m. dist (EM_remainder' n f (real_of_int x) (real_of_int (int m))) (EM_remainder' n f (real_of_int x) (real_of_int (int na))) < ε›*) proof (goal_cases) (*goal: ‹⋀m na. ⟦max (max 0 M) (nat x) ≤ m; m < na⟧ ⟹ dist (EM_remainder' n f (real_of_int x) (real_of_int (int m))) (EM_remainder' n f (real_of_int x) (real_of_int (int na))) < ε›*) case (1 k l) (*‹max (max 0 M) (nat x) ≤ k› ‹k < l›*) have "EM_remainder' n f x k + EM_remainder' n f k l = EM_remainder' n f x l" using "1" (*‹max (max (0::nat) (M::nat)) (nat (x::int)) ≤ (k::nat)› ‹(k::nat) < (l::nat)›*) x (*‹a ≤ real_of_int x›*) apply (intro EM_remainder'_combine (*‹⟦continuous_on {?a..?c} ?f; ?a ≤ ?b; ?b ≤ ?c⟧ ⟹ EM_remainder' ?n ?f ?a ?b + EM_remainder' ?n ?f ?b ?c = EM_remainder' ?n ?f ?a ?c›*) continuous_on_subset[OF cont_f] (*‹?t ⊆ {a..} ⟹ continuous_on ?t f›*)) (*goals: 1. ‹⟦max (max 0 M) (nat x) ≤ k; k < l; a ≤ real_of_int x⟧ ⟹ {real_of_int x..real l} ⊆ {a..}› 2. ‹⟦max (max 0 M) (nat x) ≤ k; k < l; a ≤ real_of_int x⟧ ⟹ real_of_int x ≤ real k› 3. ‹⟦max (max 0 M) (nat x) ≤ k; k < l; a ≤ real_of_int x⟧ ⟹ real k ≤ real l› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*proven 3 subgoals*) . hence "EM_remainder' n f x l - EM_remainder' n f x k = EM_remainder' n f k l" 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: ‹EM_remainder' n f (real_of_int x) (real l) - EM_remainder' n f (real_of_int x) (real k) = EM_remainder' n f (real k) (real l)›*) from "1" (*‹max (max 0 M) (nat x) ≤ k› ‹k < l›*) x (*‹a ≤ real_of_int x›*) have "norm … ≤ D' * (g l - g k)" apply (intro bound (*‹⟦(a::real) ≤ (?x::real); ?x ≤ (?y::real)⟧ ⟹ norm (EM_remainder' (n::nat) (f::real ⇒ 'a) ?x ?y) ≤ (D'::real) * ((g::real ⇒ real) ?y - g ?x)›*)) (*goals: 1. ‹⟦max (max 0 M) (nat x) ≤ k; k < l; a ≤ real_of_int x⟧ ⟹ a ≤ real k› 2. ‹⟦max (max 0 M) (nat x) ≤ k; k < l; a ≤ real_of_int x⟧ ⟹ real k ≤ real l› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . also (*calculation: ‹norm (EM_remainder' n f (real_of_int x) (real l) - EM_remainder' n f (real_of_int x) (real k)) ≤ D' * (g (real l) - g (real k))›*) have "g l - g k ≤ norm (g l - g k)" by simp also (*calculation: ‹(⋀(x::real) y::real. x ≤ y ⟹ (D'::real) * x ≤ D' * y) ⟹ norm (EM_remainder' (n::nat) (f::real ⇒ 'a) (real_of_int (x::int)) (real (l::nat)) - EM_remainder' n f (real_of_int x) (real (k::nat))) ≤ D' * norm ((g::real ⇒ real) (real l) - g (real k))›*) from "1" (*‹max (max 0 M) (nat x) ≤ k› ‹k < l›*) have "… ≤ ε'" using M[of l k] (*‹⟦M ≤ l; M ≤ k⟧ ⟹ norm (g (real l) - g (real k)) < ε'›*) by auto also (*calculation: ‹⟦⋀x y. x ≤ y ⟹ D' * x ≤ D' * y; ⋀x y. x ≤ y ⟹ D' * x ≤ D' * y⟧ ⟹ norm (EM_remainder' n f (real_of_int x) (real l) - EM_remainder' n f (real_of_int x) (real k)) ≤ D' * ε'›*) from ‹ε > 0› (*‹0 < ε›*) have "D' * ε' ≤ ε / 2" by (simp add: ε'_def (*‹(ε'::real) = (if (D'::real) = (0::real) then 1::real else (ε::real) / ((2::real) * D'))›*)) also (*calculation: ‹⟦⋀x y. x ≤ y ⟹ D' * x ≤ D' * y; ⋀x y. x ≤ y ⟹ D' * x ≤ D' * y⟧ ⟹ norm (EM_remainder' n f (real_of_int x) (real l) - EM_remainder' n f (real_of_int x) (real k)) ≤ ε / 2›*) from ‹ε > 0› (*‹0 < ε›*) have "… < ε" by simp finally (*calculation: ‹⟦⋀x y. x ≤ y ⟹ D' * x ≤ D' * y; ⋀x y. x ≤ y ⟹ D' * x ≤ D' * y⟧ ⟹ norm (EM_remainder' n f (real_of_int x) (real l) - EM_remainder' n f (real_of_int x) (real k)) < ε›*) show "?case" (*goal: ‹dist (EM_remainder' (n::nat) (f::real ⇒ 'a::{banach,real_normed_field}) (real_of_int (x::int)) (real_of_int (int (k::nat)))) (EM_remainder' n f (real_of_int x) (real_of_int (int (l::nat)))) < (ε::real)›*) by (simp add: D'_nonneg (*‹0 ≤ D'›*) mult_left_mono (*‹⟦?a ≤ ?b; 0 ≤ ?c⟧ ⟹ ?c * ?a ≤ ?c * ?b›*) dist_norm (*‹dist ?x ?y = norm (?x - ?y)›*) norm_minus_commute (*‹norm (?a - ?b) = norm (?b - ?a)›*)) qed qed then obtain L where "(λy. EM_remainder' n f x (int y)) ⇢ L" (*goal: ‹(⋀L. (λy. EM_remainder' n f (real_of_int x) (real_of_int (int y))) ⇢ L ⟹ thesis) ⟹ thesis›*) by (auto simp: Cauchy_convergent_iff (*‹Cauchy ?X = convergent ?X›*) convergent_def (*‹convergent ?X = (∃L. ?X ⇢ L)›*)) from filterlim_int_of_nat_at_topD[OF this] (*‹((λa. EM_remainder' n f (real_of_int x) (real_of_int a)) ⤏ L) at_top›*) have "((λy. EM_remainder' n f x (of_int y)) ⤏ L) at_top" by simp moreover from this (*‹((λy. EM_remainder' n f (real_of_int x) (real_of_int y)) ⤏ L) at_top›*) have "EM_remainder n f x = L" by (rule EM_remainder_eqI (*‹((λx::int. EM_remainder' (?n::nat) (?f::real ⇒ ?'a::banach) (real_of_int (?b::int)) (real_of_int x)) ⤏ (?L::?'a::banach)) at_top ⟹ EM_remainder ?n ?f ?b = ?L›*)) ultimately show "((λy. EM_remainder' n f x (of_int y)) ⤏ EM_remainder n f x) at_top" by simp qed have "*": "norm (EM_remainder n f x) ≤ D' * (C - g x)" if x: "x ≥ a" for x :: int proof (rule tendsto_le (*‹⟦(?F::?'b::type filter) ≠ bot; ((?f::?'b::type ⇒ ?'a::linorder_topology) ⤏ (?x::?'a::linorder_topology)) ?F; ((?g::?'b::type ⇒ ?'a::linorder_topology) ⤏ (?y::?'a::linorder_topology)) ?F; ∀⇩F x::?'b::type in ?F. ?g x ≤ ?f x⟧ ⟹ ?y ≤ ?x›*)) (*goals: 1. ‹?F ≠ bot› 2. ‹(?f ⤏ D' * (C - g (real_of_int x))) ?F› 3. ‹(?g ⤏ norm (EM_remainder n f x)) ?F› 4. ‹∀⇩F x in ?F. ?g x ≤ ?f x›*) show "((λy. D' * (g (of_int y) - g (of_int x))) ⤏ D' * (C - g (of_int x))) at_top" 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 104 facts*) filterlim_compose[OF limit_g] (*‹filterlim ?f at_top ?F1.0 ⟹ ((λx. g (?f x)) ⤏ C) ?F1.0›*)) show "((λy. norm (EM_remainder' n f x (of_int y))) ⤏ norm (EM_remainder n f x)) at_top" using x (*‹a ≤ real_of_int x›*) by (intro tendsto_norm (*‹((?f::?'a ⇒ ?'b) ⤏ (?a::?'b)) (?F::?'a filter) ⟹ ((λx::?'a. norm (?f x)) ⤏ norm ?a) ?F›*) lim (*‹(a::real) ≤ real_of_int (?x::int) ⟹ ((λy::int. EM_remainder' (n::nat) (f::real ⇒ 'a) (real_of_int ?x) (real_of_int y)) ⤏ EM_remainder n f ?x) at_top›*)) show "eventually (λy. norm (EM_remainder' n f (of_int x) (of_int y)) ≤ D' * (g (of_int y) - g (of_int x))) at_top" using eventually_ge_at_top[of x] (*‹eventually ((≤) x) at_top›*) apply eventually_elim (*goal: ‹∀⇩F y in at_top. norm (EM_remainder' n f (real_of_int x) (real_of_int y)) ≤ D' * (g (real_of_int y) - g (real_of_int x))›*) apply (rule bound (*‹⟦a ≤ ?x; ?x ≤ ?y⟧ ⟹ norm (EM_remainder' n f ?x ?y) ≤ D' * (g ?y - g ?x)›*)) (*goals: 1. ‹⋀y. x ≤ y ⟹ a ≤ real_of_int x› 2. ‹⋀y. x ≤ y ⟹ real_of_int x ≤ real_of_int y› discuss goal 1*) apply ((insert x (*‹(a::real) ≤ real_of_int (x::int)›*))[1]) (*top goal: ‹⋀y. x ≤ y ⟹ a ≤ real_of_int x› and 1 goal remains*) apply simp (*discuss goal 2*) apply ((insert x (*‹a ≤ real_of_int x›*))[1]) (*goal: ‹⋀y. x ≤ y ⟹ real_of_int x ≤ real_of_int y›*) apply simp (*proven 2 subgoals*) . qed (simp_all) (*solved the remaining goal: ‹at_top ≠ bot›*) thus "∀x. of_int x ≥ a ⟶ norm (EM_remainder n f x) ≤ D' * (C - g x)" by blast have "norm (EM_remainder n f x) ≤ D' * (C - g x)" if x: "x ≥ a" for x :: nat using x (*‹a ≤ real x›*) "*"[of "int x"] (*‹(a::real) ≤ real_of_int (int (x::nat)) ⟹ norm (EM_remainder (n::nat) (f::real ⇒ 'a::{banach,real_normed_field}) (int x)) ≤ (D'::real) * ((C::real) - (g::real ⇒ real) (real_of_int (int x)))›*) by simp thus "∀x. real x ≥ a ⟶ norm (EM_remainder n f (int x)) ≤ D' * (C - g x)" by blast qed lemma fixes f :: "real ⇒ 'a :: {real_normed_field, banach}" and g g' :: "real ⇒ real" assumes fin: "finite Y" assumes pbernpoly_bound: "∀x. ¦pbernpoly n x¦ ≤ D" assumes cont_f: "continuous_on {a..} f" assumes cont_g: "continuous_on {a..} g" assumes cont_g': "continuous_on {a..} g'" assumes limit_g: "(g ⤏ 0) at_top" assumes f_bound: "⋀x. x ≥ a ⟹ norm (f x) ≤ g' x" assumes deriv: "⋀x. x ∈ {a..} - Y ⟹ (g has_field_derivative -g' x) (at x)" shows norm_EM_remainder_le_strong_int': "∀x. of_int x ≥ a ⟶ norm (EM_remainder n f x) ≤ D / fact n * g x" and norm_EM_remainder_le_strong_nat': "∀x. real x ≥ a ⟶ norm (EM_remainder n f (int x)) ≤ D / fact n * g x" proof (-) (*goals: 1. ‹∀x. a ≤ real_of_int x ⟶ norm (EM_remainder n f x) ≤ D / fact n * g (real_of_int x)› 2. ‹∀x. a ≤ real x ⟶ norm (EM_remainder n f (int x)) ≤ D / fact n * g (real x)›*) have "∀x. of_int x ≥ a ⟶ norm (EM_remainder n f x) ≤ D / fact n * (0 - (-g x))" using assms (*‹finite Y› ‹∀x. ¦pbernpoly n x¦ ≤ D› ‹continuous_on {a..} f› ‹continuous_on {a..} g› ‹continuous_on {a::real..} (g'::real ⇒ real)› ‹(g ⤏ 0) at_top› ‹a ≤ ?x ⟹ norm (f ?x) ≤ g' ?x› ‹?x ∈ {a..} - Y ⟹ (g has_real_derivative - g' ?x) (at ?x)›*) apply (intro norm_EM_remainder_le_strong_int[OF fin pbernpoly_bound _ _ cont_g'] (*‹⟦continuous_on {a..} ?f; continuous_on {a..} ?g; (?g ⤏ ?C) at_top; ⋀x. a ≤ x ⟹ norm (?f x) ≤ g' x; ⋀x. x ∈ {a..} - Y ⟹ (?g has_real_derivative g' x) (at x)⟧ ⟹ ∀x. a ≤ real_of_int x ⟶ norm (EM_remainder n ?f x) ≤ D / fact n * (?C - ?g (real_of_int x))›*)) (*goals: 1. ‹⟦finite Y; ∀x. ¦pbernpoly n x¦ ≤ D; continuous_on {a..} f; continuous_on {a..} g; continuous_on {a..} g'; (g ⤏ 0) at_top; ⋀x. a ≤ x ⟹ norm (f x) ≤ g' x; ⋀x. x ∈ {a..} - Y ⟹ (g has_real_derivative - g' x) (at x)⟧ ⟹ continuous_on {a..} f› 2. ‹⟦finite Y; ∀x. ¦pbernpoly n x¦ ≤ D; continuous_on {a..} f; continuous_on {a..} g; continuous_on {a..} g'; (g ⤏ 0) at_top; ⋀x. a ≤ x ⟹ norm (f x) ≤ g' x; ⋀x. x ∈ {a..} - Y ⟹ (g has_real_derivative - g' x) (at x)⟧ ⟹ continuous_on {a..} (λa. - g a)› 3. ‹⟦finite Y; ∀x. ¦pbernpoly n x¦ ≤ D; continuous_on {a..} f; continuous_on {a..} g; continuous_on {a..} g'; (g ⤏ 0) at_top; ⋀x. a ≤ x ⟹ norm (f x) ≤ g' x; ⋀x. x ∈ {a..} - Y ⟹ (g has_real_derivative - g' x) (at x)⟧ ⟹ ((λa. - g a) ⤏ 0) at_top› 4. ‹⋀x. ⟦finite Y; ∀x. ¦pbernpoly n x¦ ≤ D; continuous_on {a..} f; continuous_on {a..} g; continuous_on {a..} g'; (g ⤏ 0) at_top; ⋀x. a ≤ x ⟹ norm (f x) ≤ g' x; ⋀x. x ∈ {a..} - Y ⟹ (g has_real_derivative - g' x) (at x); a ≤ x⟧ ⟹ norm (f x) ≤ g' x› 5. ‹⋀x. ⟦finite Y; ∀x. ¦pbernpoly n x¦ ≤ D; continuous_on {a..} f; continuous_on {a..} g; continuous_on {a..} g'; (g ⤏ 0) at_top; ⋀x. a ≤ x ⟹ norm (f x) ≤ g' x; ⋀x. x ∈ {a..} - Y ⟹ (g has_real_derivative - g' x) (at x); x ∈ {a..} - Y⟧ ⟹ ((λa. - g a) has_real_derivative g' x) (at x)› discuss goal 1*) 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 272 facts*) 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 94 facts*) 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 135 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 272 facts*) 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 94 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*))[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 272 facts*) 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 94 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*))[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 272 facts*) 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 94 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*))[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 272 facts*) 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 94 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*))[1]) (*proven 5 subgoals*) . thus "∀x. of_int x ≥ a ⟶ norm (EM_remainder n f x) ≤ D / fact n * g x" by auto next (*goal: ‹∀x. a ≤ real x ⟶ norm (EM_remainder n f (int x)) ≤ D / fact n * g (real x)›*) have "∀x. real x ≥ a ⟶ norm (EM_remainder n f (int x)) ≤ D / fact n * (0 - (-g x))" using assms (*‹finite Y› ‹∀x. ¦pbernpoly n x¦ ≤ D› ‹continuous_on {a::real..} (f::real ⇒ 'a::{banach,real_normed_field})› ‹continuous_on {a::real..} (g::real ⇒ real)› ‹continuous_on {a..} g'› ‹(g ⤏ 0) at_top› ‹a ≤ ?x ⟹ norm (f ?x) ≤ g' ?x› ‹?x ∈ {a..} - Y ⟹ (g has_real_derivative - g' ?x) (at ?x)›*) apply (intro norm_EM_remainder_le_strong_nat[OF fin pbernpoly_bound _ _ cont_g'] (*‹⟦continuous_on {a..} ?f; continuous_on {a..} ?g; (?g ⤏ ?C) at_top; ⋀x. a ≤ x ⟹ norm (?f x) ≤ g' x; ⋀x. x ∈ {a..} - Y ⟹ (?g has_real_derivative g' x) (at x)⟧ ⟹ ∀x. a ≤ real x ⟶ norm (EM_remainder n ?f (int x)) ≤ D / fact n * (?C - ?g (real x))›*)) (*goals: 1. ‹⟦finite (Y::real set); ∀x::real. ¦pbernpoly (n::nat) x¦ ≤ (D::real); continuous_on {a::real..} (f::real ⇒ 'a); continuous_on {a..} (g::real ⇒ real); continuous_on {a..} (g'::real ⇒ real); (g ⤏ (0::real)) at_top; ⋀x::real. a ≤ x ⟹ norm (f x) ≤ g' x; ⋀x::real. x ∈ {a..} - Y ⟹ (g has_real_derivative - g' x) (at x)⟧ ⟹ continuous_on {a..} f› 2. ‹⟦finite (Y::real set); ∀x::real. ¦pbernpoly (n::nat) x¦ ≤ (D::real); continuous_on {a::real..} (f::real ⇒ 'a); continuous_on {a..} (g::real ⇒ real); continuous_on {a..} (g'::real ⇒ real); (g ⤏ (0::real)) at_top; ⋀x::real. a ≤ x ⟹ norm (f x) ≤ g' x; ⋀x::real. x ∈ {a..} - Y ⟹ (g has_real_derivative - g' x) (at x)⟧ ⟹ continuous_on {a..} (λa::real. - g a)› 3. ‹⟦finite (Y::real set); ∀x::real. ¦pbernpoly (n::nat) x¦ ≤ (D::real); continuous_on {a::real..} (f::real ⇒ 'a); continuous_on {a..} (g::real ⇒ real); continuous_on {a..} (g'::real ⇒ real); (g ⤏ (0::real)) at_top; ⋀x::real. a ≤ x ⟹ norm (f x) ≤ g' x; ⋀x::real. x ∈ {a..} - Y ⟹ (g has_real_derivative - g' x) (at x)⟧ ⟹ ((λa::real. - g a) ⤏ (0::real)) at_top› 4. ‹⋀x::real. ⟦finite (Y::real set); ∀x::real. ¦pbernpoly (n::nat) x¦ ≤ (D::real); continuous_on {a::real..} (f::real ⇒ 'a); continuous_on {a..} (g::real ⇒ real); continuous_on {a..} (g'::real ⇒ real); (g ⤏ (0::real)) at_top; ⋀x::real. a ≤ x ⟹ norm (f x) ≤ g' x; ⋀x::real. x ∈ {a..} - Y ⟹ (g has_real_derivative - g' x) (at x); a ≤ x⟧ ⟹ norm (f x) ≤ g' x› 5. ‹⋀x::real. ⟦finite (Y::real set); ∀x::real. ¦pbernpoly (n::nat) x¦ ≤ (D::real); continuous_on {a::real..} (f::real ⇒ 'a); continuous_on {a..} (g::real ⇒ real); continuous_on {a..} (g'::real ⇒ real); (g ⤏ (0::real)) at_top; ⋀x::real. a ≤ x ⟹ norm (f x) ≤ g' x; ⋀x::real. x ∈ {a..} - Y ⟹ (g has_real_derivative - g' x) (at x); x ∈ {a..} - Y⟧ ⟹ ((λa::real. - g a) has_real_derivative g' x) (at x)› 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 272 facts*) 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 94 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*))[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 272 facts*) 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 94 facts*) 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 135 facts*))[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 272 facts*) 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 94 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 135 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 272 facts*) 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 94 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*))[1]) (*discuss goal 5*) 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 272 facts*) 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 94 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 135 facts*))[1]) (*proven 5 subgoals*) . thus "∀x. real x ≥ a ⟶ norm (EM_remainder n f (int x)) ≤ D / fact n * g x" by auto qed lemma norm_EM_remainder'_le: fixes f :: "real ⇒ 'a :: {real_normed_field, banach}" and g g' :: "real ⇒ real" assumes cont_f: "continuous_on {a..} f" assumes cont_g': "continuous_on {a..} g'" assumes f_bigo: "eventually (λx. norm (f x) ≤ g' x) at_top" assumes deriv: "eventually (λx. (g has_field_derivative g' x) (at x)) at_top" obtains C D where "eventually (λx. norm (EM_remainder' n f a x) ≤ C + D * g x) at_top" proof (-) (*goal: ‹(⋀C D. ∀⇩F x in at_top. norm (EM_remainder' n f a x) ≤ C + D * g x ⟹ thesis) ⟹ thesis›*) note cont = continuous_on_subset[OF cont_f] (*‹(?t::real set) ⊆ {a::real..} ⟹ continuous_on ?t (f::real ⇒ 'a::{banach,real_normed_field})›*) continuous_on_subset[OF cont_g'] (*‹?t ⊆ {a..} ⟹ continuous_on ?t g'›*) from bounded_pbernpoly[of n] (*‹(⋀c. (⋀x. norm (pbernpoly n x) ≤ c) ⟹ ?thesis) ⟹ ?thesis›*) obtain D where D: "⋀x. norm (pbernpoly n x) ≤ D" (*goal: ‹(⋀D. (⋀x. norm (pbernpoly n x) ≤ D) ⟹ thesis) ⟹ thesis›*) by blast from this[of 0] (*‹norm (pbernpoly n 0) ≤ D›*) have D_nonneg: "D ≥ 0" by simp from eventually_conj[OF f_bigo eventually_conj [ OF deriv eventually_ge_at_top [ of a ] ]] (*‹∀⇩F x in at_top. norm (f x) ≤ g' x ∧ (g has_real_derivative g' x) (at x) ∧ a ≤ x›*) obtain x0 where x0: "x0 ≥ a" "⋀x. x ≥ x0 ⟹ norm (f x) ≤ g' x" "⋀x. x ≥ x0 ⟹ (g has_field_derivative g' x) (at x)" (*goal: ‹(⋀x0. ⟦a ≤ x0; ⋀x. x0 ≤ x ⟹ norm (f x) ≤ g' x; ⋀x. x0 ≤ x ⟹ (g has_real_derivative g' x) (at x)⟧ ⟹ thesis) ⟹ thesis›*) by (auto simp: eventually_at_top_linorder (*‹eventually ?P at_top = (∃N. ∀n≥N. ?P n)›*)) define C where "C = (norm (integral {a..x0} (λt. pbernpoly n t *⇩R f t)) - D * g x0) / fact n" have "eventually (λx. norm (EM_remainder' n f a x) ≤ C + D / fact n * g x) at_top" using eventually_ge_at_top[of x0] (*‹eventually ((≤) x0) at_top›*) proof (eventually_elim) (*goal: ‹⋀x. x0 ≤ x ⟹ norm (EM_remainder' n f a x) ≤ C + D / fact n * g x›*) case (elim x) (*‹x0 ≤ x›*) have "integral {a..x} (λt. pbernpoly n t *⇩R f t) = integral {a..x0} (λt. pbernpoly n t *⇩R f t) + integral {x0..x} (λt. pbernpoly n t *⇩R f t)" (is "_ = ?I1 + ?I2") using elim (*‹(x0::real) ≤ (x::real)›*) x0(1) (*‹a ≤ x0›*) apply (intro Henstock_Kurzweil_Integration.integral_combine [symmetric] (*‹⟦?a ≤ ?c; ?c ≤ ?b; ?f integrable_on {?a..?b}⟧ ⟹ integral {?a..?b} ?f = integral {?a..?c} ?f + integral {?c..?b} ?f›*) integrable_EM_remainder' (*‹continuous_on {?a..?b} ?f ⟹ (λt. pbernpoly ?n t *⇩R ?f t) integrable_on {?a..?b}›*) cont (*‹?t ⊆ {a..} ⟹ continuous_on ?t f› ‹?t ⊆ {a..} ⟹ continuous_on ?t g'›*)) (*goals: 1. ‹⟦x0 ≤ x; a ≤ x0⟧ ⟹ a ≤ x0› 2. ‹⟦x0 ≤ x; a ≤ x0⟧ ⟹ x0 ≤ x› 3. ‹⟦x0 ≤ x; a ≤ x0⟧ ⟹ {a..x} ⊆ {a..}› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*proven 3 subgoals*) . also (*calculation: ‹integral {a..x} (λt. pbernpoly n t *⇩R f t) = integral {a..x0} (λt. pbernpoly n t *⇩R f t) + integral {x0..x} (λt. pbernpoly n t *⇩R f t)›*) have "norm … ≤ norm ?I1 + norm ?I2" by (rule norm_triangle_ineq (*‹norm ((?x::?'a) + (?y::?'a)) ≤ norm ?x + norm ?y›*)) also (*calculation: ‹norm (integral {a..x} (λt. pbernpoly n t *⇩R f t)) ≤ norm (integral {a..x0} (λt. pbernpoly n t *⇩R f t)) + norm (integral {x0..x} (λt. pbernpoly n t *⇩R f t))›*) have "norm ?I2 ≤ integral {x0..x} (λt. D * g' t)" using x0 (*‹a ≤ x0› ‹x0 ≤ ?x ⟹ norm (f ?x) ≤ g' ?x› ‹x0 ≤ ?x ⟹ (g has_real_derivative g' ?x) (at ?x)›*) D (*‹norm (pbernpoly (n::nat) (?x::real)) ≤ (D::real)›*) D_nonneg (*‹(0::real) ≤ (D::real)›*) 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›*) integrable_EM_remainder' (*‹continuous_on {?a..?b} ?f ⟹ (λt. pbernpoly ?n t *⇩R ?f t) integrable_on {?a..?b}›*)) (*goals: 1. ‹⟦a ≤ x0; ⋀x. x0 ≤ x ⟹ norm (f x) ≤ g' x; ⋀x. x0 ≤ x ⟹ (g has_real_derivative g' x) (at x); ⋀x. norm (pbernpoly n x) ≤ D; 0 ≤ D⟧ ⟹ continuous_on {x0..x} f› 2. ‹⟦a ≤ x0; ⋀x. x0 ≤ x ⟹ norm (f x) ≤ g' x; ⋀x. x0 ≤ x ⟹ (g has_real_derivative g' x) (at x); ⋀x. norm (pbernpoly n x) ≤ D; 0 ≤ D⟧ ⟹ (λt. D * g' t) integrable_on {x0..x}› 3. ‹⋀xa. ⟦a ≤ x0; ⋀x. x0 ≤ x ⟹ norm (f x) ≤ g' x; ⋀x. x0 ≤ x ⟹ (g has_real_derivative g' x) (at x); ⋀x. norm (pbernpoly n x) ≤ D; 0 ≤ D; xa ∈ {x0..x}⟧ ⟹ norm (pbernpoly n xa *⇩R f xa) ≤ D * g' xa› discuss goal 1*) apply ((auto 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 272 facts*) cont (*‹?t ⊆ {a..} ⟹ continuous_on ?t f› ‹?t ⊆ {a..} ⟹ continuous_on ?t g'›*) mult_mono (*‹⟦?a ≤ ?b; ?c ≤ ?d; 0 ≤ ?b; 0 ≤ ?c⟧ ⟹ ?a * ?c ≤ ?b * ?d›*))[1]) (*discuss goal 2*) apply ((auto 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 272 facts*) cont (*‹?t ⊆ {a..} ⟹ continuous_on ?t f› ‹?t ⊆ {a..} ⟹ continuous_on ?t g'›*) mult_mono (*‹⟦?a ≤ ?b; ?c ≤ ?d; 0 ≤ ?b; 0 ≤ ?c⟧ ⟹ ?a * ?c ≤ ?b * ?d›*))[1]) (*discuss goal 3*) apply ((auto 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 272 facts*) cont (*‹?t ⊆ {a..} ⟹ continuous_on ?t f› ‹?t ⊆ {a..} ⟹ continuous_on ?t g'›*) mult_mono (*‹⟦?a ≤ ?b; ?c ≤ ?d; 0 ≤ ?b; 0 ≤ ?c⟧ ⟹ ?a * ?c ≤ ?b * ?d›*))[1]) (*proven 3 subgoals*) . also (*calculation: ‹(⋀x y. x ≤ y ⟹ norm (integral {a..x0} (λt. pbernpoly n t *⇩R f t)) + x ≤ norm (integral {a..x0} (λt. pbernpoly n t *⇩R f t)) + y) ⟹ norm (integral {a..x} (λt. pbernpoly n t *⇩R f t)) ≤ norm (integral {a..x0} (λt. pbernpoly n t *⇩R f t)) + integral {x0..x} (λt. D * g' t)›*) have "… = D * integral {x0..x} g'" by simp also (*calculation: ‹(⋀x y. x ≤ y ⟹ norm (integral {a..x0} (λt. pbernpoly n t *⇩R f t)) + x ≤ norm (integral {a..x0} (λt. pbernpoly n t *⇩R f t)) + y) ⟹ norm (integral {a..x} (λt. pbernpoly n t *⇩R f t)) ≤ norm (integral {a..x0} (λt. pbernpoly n t *⇩R f t)) + D * integral {x0..x} g'›*) from elim (*‹x0 ≤ x›*) have "(g' has_integral (g x - g x0)) {x0..x}" apply (intro fundamental_theorem_of_calculus (*‹⟦?a ≤ ?b; ⋀x. x ∈ {?a..?b} ⟹ (?f has_vector_derivative ?f' x) (at x within {?a..?b})⟧ ⟹ (?f' has_integral ?f ?b - ?f ?a) {?a..?b}›*)) (*goals: 1. ‹(x0::real) ≤ (x::real) ⟹ x0 ≤ x› 2. ‹⋀xa::real. ⟦(x0::real) ≤ (x::real); xa ∈ {x0..x}⟧ ⟹ ((g::real ⇒ real) has_vector_derivative (g'::real ⇒ real) xa) (at xa within {x0..x})› discuss goal 1*) apply ((auto intro!: has_field_derivative_at_within[OF x0(3)] (*‹x0 ≤ ?x ⟹ (g has_real_derivative g' ?x) (at ?x within ?s)›*) simp: has_real_derivative_iff_has_vector_derivative [symmetric] (*‹(?f has_vector_derivative ?y) ?F = (?f has_real_derivative ?y) ?F›*))[1]) (*discuss goal 2*) apply ((auto intro!: has_field_derivative_at_within[OF x0(3)] (*‹x0 ≤ ?x ⟹ (g has_real_derivative g' ?x) (at ?x within ?s)›*) simp: has_real_derivative_iff_has_vector_derivative [symmetric] (*‹(?f has_vector_derivative ?y) ?F = (?f has_real_derivative ?y) ?F›*))[1]) (*proven 2 subgoals*) . hence "integral {x0..x} g' = g x - g x0" by (simp add: has_integral_iff (*‹(?f has_integral ?i) ?S = (?f integrable_on ?S ∧ integral ?S ?f = ?i)›*)) finally (*calculation: ‹(⋀x y. x ≤ y ⟹ norm (integral {a..x0} (λt. pbernpoly n t *⇩R f t)) + x ≤ norm (integral {a..x0} (λt. pbernpoly n t *⇩R f t)) + y) ⟹ norm (integral {a..x} (λt. pbernpoly n t *⇩R f t)) ≤ norm (integral {a..x0} (λt. pbernpoly n t *⇩R f t)) + D * (g x - g x0)›*) have "norm (integral {a..x} (λt. pbernpoly n t *⇩R f t)) ≤ norm ?I1 + D * (g x - g x0)" by simp thus "norm (EM_remainder' n f a x) ≤ C + D / fact n * g x" by (simp add: EM_remainder'_def (*‹EM_remainder' ?n ?f ?a ?b = ((- 1) ^ Suc ?n / fact ?n) *⇩R integral {?a..?b} (λt. pbernpoly ?n t *⇩R ?f t)›*) 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*) C_def (*‹C = (norm (integral {a..x0} (λt. pbernpoly n t *⇩R f t)) - D * g x0) / fact n›*)) qed thus "?thesis" (*goal: ‹thesis›*) by (rule that (*‹∀⇩F x in at_top. norm (EM_remainder' n f a x) ≤ ?C + ?D * g x ⟹ thesis›*)) qed subsection ‹Application to harmonic numbers› text ‹ As a first application, we can apply the machinery we have developed to the harmonic numbers. › definition harm_remainder :: "nat ⇒ nat ⇒ real" where "harm_remainder N n = EM_remainder (2*N+1) (λx. -fact (2*N+1) / x ^ (2*N+2)) (int n)" lemma harm_expansion: assumes n: "n > 0" and N: "N > 0" shows "harm n = ln n + euler_mascheroni + 1 / (2*n) - (∑i=1..N. bernoulli (2*i) / ((2*i) * n ^ (2*i))) - harm_remainder N n" proof (-) (*goal: ‹harm n = ln (real n) + euler_mascheroni + 1 / (2 * real n) - (∑i = 1..N. bernoulli (2 * i) / (2 * real i * real n ^ (2 * i))) - harm_remainder N n›*) define fs where "fs = (λk x. (-1) ^ k * fact k / x ^ (Suc k) :: real)" interpret euler_maclaurin_nat' ln "λx. 1/x" fs 1 N euler_mascheroni "{}" proof (standard) (*goals: 1. ‹finite {}› 2. ‹fs 0 = (/) 1› 3. ‹⋀k. k ≤ 2 * N + 1 ⟹ continuous_on {real 1..} (fs k)› 4. ‹⋀k x. ⟦k ≤ 2 * N; x ∈ {real 1..} - {}⟧ ⟹ (fs k has_vector_derivative fs (Suc k) x) (at x)› 5. ‹continuous_on {real 1..} ln› 6. ‹⋀x. x ∈ {real 1..} - {} ⟹ (ln has_vector_derivative 1 / x) (at x)› 7. ‹(λb. (∑k = 1..b. 1 / real k) - ln (real b) - (∑i<2 * N + 1. (bernoulli' (Suc i) / fact (Suc i)) *⇩R fs i (real b))) ⇢ euler_mascheroni›*) fix k and x assume "k ≤ 2*N" "x ∈ {real 1..} - {}" (*‹(k::nat) ≤ (2::nat) * (N::nat)› ‹(x::real) ∈ {real (1::nat)..} - {}›*) thus "(fs k has_vector_derivative fs (Suc k) x) (at x)" apply (cases "k = 0") (*goals: 1. ‹⟦k ≤ 2 * N; x ∈ {real 1..} - {}; k = 0⟧ ⟹ (fs k has_vector_derivative fs (Suc k) x) (at x)› 2. ‹⟦k ≤ 2 * N; x ∈ {real 1..} - {}; k ≠ 0⟧ ⟹ (fs k has_vector_derivative fs (Suc k) x) (at 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 135 facts*) simp: fs_def (*‹fs = (λk x. (- 1) ^ k * fact k / x ^ Suc k)›*) has_real_derivative_iff_has_vector_derivative [symmetric] (*‹(?f has_vector_derivative ?y) ?F = (?f has_real_derivative ?y) ?F›*) 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*) power_diff (*‹⟦?a ≠ 0; ?n ≤ ?m⟧ ⟹ ?a ^ (?m - ?n) = ?a ^ ?m div ?a ^ ?n›*))[1]) (*discuss goal 2*) 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 135 facts*) simp: fs_def (*‹fs = (λk x. (- 1) ^ k * fact k / x ^ Suc k)›*) has_real_derivative_iff_has_vector_derivative [symmetric] (*‹(?f has_vector_derivative ?y) ?F = (?f has_real_derivative ?y) ?F›*) 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*) power_diff (*‹⟦?a ≠ 0; ?n ≤ ?m⟧ ⟹ ?a ^ (?m - ?n) = ?a ^ ?m div ?a ^ ?n›*))[1]) (*proven 2 subgoals*) . next (*goals: 1. ‹finite {}› 2. ‹(fs::nat ⇒ real ⇒ real) (0::nat) = (/) (1::real)› 3. ‹⋀k::nat. k ≤ (2::nat) * (N::nat) + (1::nat) ⟹ continuous_on {real (1::nat)..} ((fs::nat ⇒ real ⇒ real) k)› 4. ‹continuous_on {real (1::nat)..} ln› 5. ‹⋀x::real. x ∈ {real (1::nat)..} - {} ⟹ (ln has_vector_derivative (1::real) / x) (at x)› 6. ‹(λb::nat. (∑k::nat = 1::nat..b. (1::real) / real k) - ln (real b) - (∑i::nat<(2::nat) * (N::nat) + (1::nat). (bernoulli' (Suc i) / fact (Suc i)) *⇩R (fs::nat ⇒ real ⇒ real) i (real b))) ⇢ euler_mascheroni›*) have "(λb. harm b - ln (real b) - (∑i<2*N+1. bernoulli' (Suc i) * (- 1) ^ i / (real (Suc i) * (real b ^ Suc i)))) ⇢ (euler_mascheroni - (∑i<2*N+1. 0))" apply (intro tendsto_diff (*‹⟦(?f ⤏ ?a) ?F; (?g ⤏ ?b) ?F⟧ ⟹ ((λx. ?f x - ?g x) ⤏ ?a - ?b) ?F›*) euler_mascheroni_LIMSEQ (*‹(λn. harm n - ln (real n)) ⇢ euler_mascheroni›*) tendsto_sum (*‹(⋀i. i ∈ ?I ⟹ (?f i ⤏ ?a i) ?F) ⟹ ((λx. ∑i∈?I. ?f i x) ⤏ sum ?a ?I) ?F›*) real_tendsto_divide_at_top[OF tendsto_const] (*‹filterlim ?g at_top ?F ⟹ ((λx. ?c / ?g x) ⤏ 0) ?F›*) filterlim_tendsto_pos_mult_at_top[OF tendsto_const] (*‹⟦0 < ?c; filterlim ?g at_top ?F⟧ ⟹ LIM x ?F. ?c * ?g x :> at_top›*) filterlim_pow_at_top (*‹⟦0 < ?n; filterlim ?f at_top ?F⟧ ⟹ LIM x ?F. ?f x ^ ?n :> at_top›*) filterlim_real_sequentially (*‹filterlim real at_top sequentially›*)) (*goals: 1. ‹⋀i. i ∈ {..<2 * N + 1} ⟹ 0 < real (Suc i)› 2. ‹⋀i. i ∈ {..<2 * N + 1} ⟹ 0 < Suc i› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . thus "(λb. (∑k = 1..b. 1 / real k) - ln (real b) - (∑i<2*N+1. (bernoulli' (Suc i) / fact (Suc i)) *⇩R fs i (real b))) ⇢ euler_mascheroni" by (simp add: harm_def (*‹harm ?n = (∑k = 1..?n. inverse (of_nat k))›*) 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*) fs_def (*‹fs = (λk x. (- 1) ^ k * fact k / x ^ Suc k)›*)) qed (insert n (*‹(0::nat) < (n::nat)›*) N (*‹(0::nat) < (N::nat)›*), 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 272 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: fs_def (*‹fs = (λk x. (- 1) ^ k * fact k / x ^ Suc k)›*) has_real_derivative_iff_has_vector_derivative [symmetric] (*‹(?f has_vector_derivative ?y) ?F = (?f has_real_derivative ?y) ?F›*)) (*solves the remaining goals: 1. ‹finite {}› 2. ‹(fs::nat ⇒ real ⇒ real) (0::nat) = (/) (1::real)› 3. ‹⋀k::nat. k ≤ (2::nat) * (N::nat) + (1::nat) ⟹ continuous_on {real (1::nat)..} ((fs::nat ⇒ real ⇒ real) k)› 4. ‹continuous_on {real (1::nat)..} ln› 5. ‹⋀x::real. x ∈ {real (1::nat)..} - {} ⟹ (ln has_vector_derivative (1::real) / x) (at x)›*) have "harm n = (∑k=1..n. 1 / real k)" by (simp add: harm_def (*‹harm ?n = (∑k = 1..?n. inverse (of_nat k))›*) 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: ‹harm n = (∑k = 1..n. 1 / real k)›*) have "… = ln (real n) + euler_mascheroni + (1/2) *⇩R (1 / real n) + (∑i=1..N. (bernoulli (2*i) / fact (2*i)) *⇩R fs (2*i-1) (real n)) - EM_remainder (2*N+1) (fs (2*N+1)) (int n)" using n (*‹0 < n›*) N (*‹0 < 2 * N + 1›*) using n (*‹0 < n›*) apply (intro euler_maclaurin_strong_nat' (*‹1 ≤ ?b ⟹ (∑k = 1..?b. 1 / real k) = ln (real ?b) + euler_mascheroni + (1 / 2) *⇩R (1 / real ?b) + (∑i = 1..N. (bernoulli (2 * i) / fact (2 * i)) *⇩R fs (2 * i - 1) (real ?b)) - EM_remainder (2 * N + 1) (fs (2 * N + 1)) (int ?b)›*)) (*goal: ‹(∑k = 1..n. 1 / real k) = ln (real n) + euler_mascheroni + (1 / 2) *⇩R (1 / real n) + (∑i = 1..N. (bernoulli (2 * i) / fact (2 * i)) *⇩R fs (2 * i - 1) (real n)) - EM_remainder (2 * N + 1) (fs (2 * N + 1)) (int n)›*) by simp also (*calculation: ‹harm n = ln (real n) + euler_mascheroni + (1 / 2) *⇩R (1 / real n) + (∑i = 1..N. (bernoulli (2 * i) / fact (2 * i)) *⇩R fs (2 * i - 1) (real n)) - EM_remainder (2 * N + 1) (fs (2 * N + 1)) (int n)›*) have "(∑i=1..N. (bernoulli (2*i) / fact (2*i)) *⇩R (fs (2*i-1) (real n))) = (∑i=1..N. -(bernoulli (2*i) / (real (2*i) * real n ^ (2*i))))" apply (intro sum.cong (*‹⟦?A = ?B; ⋀x. x ∈ ?B ⟹ ?g x = ?h x⟧ ⟹ sum ?g ?A = sum ?h ?B›*) refl (*‹?t = ?t›*)) (*goal: ‹(∑i = 1..N. (bernoulli (2 * i) / fact (2 * i)) *⇩R fs (2 * i - 1) (real n)) = (∑i = 1..N. - (bernoulli (2 * i) / (real (2 * i) * real n ^ (2 * i))))›*) by (simp add: fs_def (*‹fs = (λk x. (- 1) ^ k * fact k / x ^ Suc k)›*) 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*) fact_reduce (*‹0 < ?n ⟹ fact ?n = of_nat ?n * fact (?n - 1)›*) del: of_nat_Suc (*‹of_nat (Suc ?m) = 1 + of_nat ?m›*) power_Suc (*‹?a ^ Suc ?n = ?a * ?a ^ ?n›*)) also (*calculation: ‹harm n = ln (real n) + euler_mascheroni + (1 / 2) *⇩R (1 / real n) + (∑i = 1..N. - (bernoulli (2 * i) / (real (2 * i) * real n ^ (2 * i)))) - EM_remainder (2 * N + 1) (fs (2 * N + 1)) (int n)›*) have "… = -(∑i=1..N. bernoulli (2*i) / (real (2*i) * real n ^ (2*i)))" by (simp add: sum_negf (*‹(∑x∈?A. - ?f x) = - sum ?f ?A›*)) finally (*calculation: ‹harm n = ln (real n) + euler_mascheroni + (1 / 2) *⇩R (1 / real n) + - (∑i = 1..N. bernoulli (2 * i) / (real (2 * i) * real n ^ (2 * i))) - EM_remainder (2 * N + 1) (fs (2 * N + 1)) (int n)›*) show "?thesis" (*goal: ‹harm n = ln (real n) + euler_mascheroni + 1 / (2 * real n) - (∑i = 1..N. bernoulli (2 * i) / (2 * real i * real n ^ (2 * i))) - harm_remainder N n›*) unfolding fs_def (*goal: ‹harm n = ln (real n) + euler_mascheroni + 1 / (2 * real n) - (∑i = 1..N. bernoulli (2 * i) / (2 * real i * real n ^ (2 * i))) - harm_remainder N n›*) by (simp add: harm_remainder_def (*‹harm_remainder (?N::nat) (?n::nat) = EM_remainder ((2::nat) * ?N + (1::nat)) (λx::real. - fact ((2::nat) * ?N + (1::nat)) / x ^ ((2::nat) * ?N + (2::nat))) (int ?n)›*)) qed lemma of_nat_ge_1_iff: "of_nat x ≥ (1 :: 'a :: linordered_semidom) ⟷ x ≥ 1" using of_nat_le_iff[of 1 x] (*‹(of_nat 1 ≤ of_nat x) = (1 ≤ x)›*) by (simp del: of_nat_le_iff (*‹(of_nat ?m ≤ of_nat ?n) = (?m ≤ ?n)›*)) lemma harm_remainder_bound: fixes N :: nat assumes N: "N > 0" shows "∃C. ∀n≥1. norm (harm_remainder N n) ≤ C / real n ^ (2*N+1)" proof (-) (*goal: ‹∃C. ∀n≥1. norm (harm_remainder N n) ≤ C / real n ^ (2 * N + 1)›*) from bounded_pbernpoly[of "2*N+1"] (*‹(⋀c. (⋀x. norm (pbernpoly (2 * N + 1) x) ≤ c) ⟹ ?thesis) ⟹ ?thesis›*) obtain D where D: "∀x. ¦pbernpoly (2*N+1) x¦ ≤ D" (*goal: ‹(⋀D::real. ∀x::real. ¦pbernpoly ((2::nat) * (N::nat) + (1::nat)) x¦ ≤ D ⟹ thesis::bool) ⟹ thesis›*) by auto have "∀x. 1 ≤ real x ⟶ norm (harm_remainder N x) ≤ D / fact (2*N+1) * (fact (2*N) / x ^ (2*N+1))" unfolding harm_remainder_def of_int_of_nat_eq (*goal: ‹∀x. 1 ≤ real x ⟶ norm (EM_remainder (2 * N + 1) (λx. - fact (2 * N + 1) / x ^ (2 * N + 2)) (int x)) ≤ D / fact (2 * N + 1) * (fact (2 * N) / real x ^ (2 * N + 1))›*) proof (rule norm_EM_remainder_le_strong_nat'[of "{}"] (*‹⟦finite {}; ∀x::real. ¦pbernpoly (?n::nat) x¦ ≤ (?D::real); continuous_on {?a::real..} (?f::real ⇒ ?'a); continuous_on {?a..} (?g::real ⇒ real); continuous_on {?a..} (?g'::real ⇒ real); (?g ⤏ (0::real)) at_top; ⋀x::real. ?a ≤ x ⟹ norm (?f x) ≤ ?g' x; ⋀x::real. x ∈ {?a..} - {} ⟹ (?g has_real_derivative - ?g' x) (at x)⟧ ⟹ ∀x::nat. ?a ≤ real x ⟶ norm (EM_remainder ?n ?f (int x)) ≤ ?D / fact ?n * ?g (real x)›*)) (*goals: 1. ‹finite {}› 2. ‹∀x. ¦pbernpoly (2 * N + 1) x¦ ≤ D› 3. ‹continuous_on {1..} (λa. - fact (2 * N + 1) / a ^ (2 * N + 2))› 4. ‹continuous_on {1..} (λa. fact (2 * N) / a ^ (2 * N + 1))› 5. ‹continuous_on {1..} ?g'› 6. ‹((λa. fact (2 * N) / a ^ (2 * N + 1)) ⤏ 0) at_top› 7. ‹⋀x. 1 ≤ x ⟹ norm (- fact (2 * N + 1) / x ^ (2 * N + 2)) ≤ ?g' x› 8. ‹⋀x. x ∈ {1..} - {} ⟹ ((λa. fact (2 * N) / a ^ (2 * N + 1)) has_real_derivative - ?g' x) (at x)›*) fix x :: real assume x: "x ≥ 1" (*‹(1::real) ≤ (x::real)›*) show "norm (-fact (2*N+1) / x ^ (2 * N + 2)) ≤ fact (2*N+1) / x ^ (2*N+2)" using x (*‹(1::real) ≤ (x::real)›*) by simp next (*goals: 1. ‹finite {}› 2. ‹∀x. ¦pbernpoly (2 * N + 1) x¦ ≤ D› 3. ‹continuous_on {1..} (λa. - fact (2 * N + 1) / a ^ (2 * N + 2))› 4. ‹continuous_on {1..} (λa. fact (2 * N) / a ^ (2 * N + 1))› 5. ‹continuous_on {1..} (λx. fact (2 * N + 1) / x ^ (2 * N + 2))› 6. ‹((λa. fact (2 * N) / a ^ (2 * N + 1)) ⤏ 0) at_top› 7. ‹⋀x. x ∈ {1..} - {} ⟹ ((λa. fact (2 * N) / a ^ (2 * N + 1)) has_real_derivative - (fact (2 * N + 1) / x ^ (2 * N + 2))) (at x)›*) show "((λx::real. fact (2 * N) / x ^ (2 * N + 1)) ⤏ 0) at_top" apply (intro real_tendsto_divide_at_top[OF tendsto_const] (*‹filterlim (?g::?'a ⇒ real) at_top (?F::?'a filter) ⟹ ((λx::?'a. (?c::real) / ?g x) ⤏ (0::real)) ?F›*) filterlim_pow_at_top (*‹⟦(0::nat) < (?n::nat); filterlim (?f::?'a ⇒ real) at_top (?F::?'a filter)⟧ ⟹ LIM (x::?'a) ?F. ?f x ^ ?n :> at_top›*) filterlim_ident (*‹LIM (x::?'a) ?F. x :> (?F::?'a filter)›*)) (*goal: ‹((λx. fact (2 * N) / x ^ (2 * N + 1)) ⤏ 0) at_top›*) by simp qed (insert N (*‹0 < N›*) D (*‹∀x. ¦pbernpoly (2 * N + 1) x¦ ≤ D›*), 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 135 facts*) 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 272 facts*) 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*) power_diff (*‹⟦?a ≠ 0; ?n ≤ ?m⟧ ⟹ ?a ^ (?m - ?n) = ?a ^ ?m div ?a ^ ?n›*)) (*solves the remaining goals: 1. ‹finite {}› 2. ‹∀x. ¦pbernpoly (2 * N + 1) x¦ ≤ D› 3. ‹continuous_on {1..} (λa. - fact (2 * N + 1) / a ^ (2 * N + 2))› 4. ‹continuous_on {1..} (λa. fact (2 * N) / a ^ (2 * N + 1))› 5. ‹continuous_on {1..} (λx. fact (2 * N + 1) / x ^ (2 * N + 2))› 6. ‹⋀x. x ∈ {1..} - {} ⟹ ((λa. fact (2 * N) / a ^ (2 * N + 1)) has_real_derivative - (fact (2 * N + 1) / x ^ (2 * N + 2))) (at x)›*) hence "∀x. 1 ≤ x ⟶ norm (harm_remainder N x) ≤ D / (2*N+1) / real x ^ (2*N+1)" by simp thus "?thesis" (*goal: ‹∃C. ∀n≥1. norm (harm_remainder N n) ≤ C / real n ^ (2 * N + 1)›*) by blast qed subsection ‹Application to sums of inverse squares› text ‹ In the same vein, we can derive the asymptotics of the partial sum of inverse squares. › lemma sum_inverse_squares_expansion: assumes n: "n > 0" and N: "N > 0" shows "(∑k=1..n. 1 / real k ^ 2) = pi ^ 2 / 6 - 1 / real n + 1 / (2 * real n ^ 2) - (∑i=1..N. bernoulli (2*i) / n ^ (2*i+1)) - EM_remainder (2*N+1) (λx. -fact (2*N+2) / x ^ (2*N+3)) (int n)" proof (-) (*goal: ‹(∑k = 1..n. 1 / (real k)²) = pi² / 6 - 1 / real n + 1 / (2 * (real n)²) - (∑i = 1..N. bernoulli (2 * i) / real (n ^ (2 * i + 1))) - EM_remainder (2 * N + 1) (λx. - fact (2 * N + 2) / x ^ (2 * N + 3)) (int n)›*) have 3: "3 = Suc (Suc (Suc 0))" 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))›*)) define fs where "fs = (λk x. (-1) ^ k * fact (Suc k) / x ^ (k+2) :: real)" interpret euler_maclaurin_nat' "λx. -1/x" "λx. 1/x^2" fs 1 N "pi^2/6" "{}" proof (standard) (*goals: 1. ‹finite {}› 2. ‹fs 0 = (λx. 1 / x²)› 3. ‹⋀k. k ≤ 2 * N + 1 ⟹ continuous_on {real 1..} (fs k)› 4. ‹⋀k x. ⟦k ≤ 2 * N; x ∈ {real 1..} - {}⟧ ⟹ (fs k has_vector_derivative fs (Suc k) x) (at x)› 5. ‹continuous_on {real 1..} ((/) (- 1))› 6. ‹⋀x. x ∈ {real 1..} - {} ⟹ ((/) (- 1) has_vector_derivative 1 / x²) (at x)› 7. ‹(λb. (∑k = 1..b. 1 / (real k)²) - - 1 / real b - (∑i<2 * N + 1. (bernoulli' (Suc i) / fact (Suc i)) *⇩R fs i (real b))) ⇢ pi² / 6›*) fix k and x assume "k ≤ 2*N" "x ∈ {real 1..} - {}" (*‹(k::nat) ≤ (2::nat) * (N::nat)› ‹(x::real) ∈ {real (1::nat)..} - {}›*) thus "(fs k has_vector_derivative fs (Suc k) x) (at x)" apply (cases "k = 0") (*goals: 1. ‹⟦k ≤ 2 * N; x ∈ {real 1..} - {}; k = 0⟧ ⟹ (fs k has_vector_derivative fs (Suc k) x) (at x)› 2. ‹⟦k ≤ 2 * N; x ∈ {real 1..} - {}; k ≠ 0⟧ ⟹ (fs k has_vector_derivative fs (Suc k) x) (at 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 135 facts*) simp: fs_def (*‹fs = (λk x. (- 1) ^ k * fact (Suc k) / x ^ (k + 2))›*) has_real_derivative_iff_has_vector_derivative [symmetric] (*‹(?f has_vector_derivative ?y) ?F = (?f has_real_derivative ?y) ?F›*) 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*) power_diff (*‹⟦?a ≠ 0; ?n ≤ ?m⟧ ⟹ ?a ^ (?m - ?n) = ?a ^ ?m div ?a ^ ?n›*))[1]) (*discuss goal 2*) 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 135 facts*) simp: fs_def (*‹fs = (λk x. (- 1) ^ k * fact (Suc k) / x ^ (k + 2))›*) has_real_derivative_iff_has_vector_derivative [symmetric] (*‹(?f has_vector_derivative ?y) ?F = (?f has_real_derivative ?y) ?F›*) 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*) power_diff (*‹⟦?a ≠ 0; ?n ≤ ?m⟧ ⟹ ?a ^ (?m - ?n) = ?a ^ ?m div ?a ^ ?n›*))[1]) (*proven 2 subgoals*) . next (*goals: 1. ‹finite {}› 2. ‹fs 0 = (λx. 1 / x²)› 3. ‹⋀k. k ≤ 2 * N + 1 ⟹ continuous_on {real 1..} (fs k)› 4. ‹continuous_on {real 1..} ((/) (- 1))› 5. ‹⋀x. x ∈ {real 1..} - {} ⟹ ((/) (- 1) has_vector_derivative 1 / x²) (at x)› 6. ‹(λb. (∑k = 1..b. 1 / (real k)²) - - 1 / real b - (∑i<2 * N + 1. (bernoulli' (Suc i) / fact (Suc i)) *⇩R fs i (real b))) ⇢ pi² / 6›*) from inverse_squares_sums (*‹(λn. 1 / real ((n + 1)²)) sums (pi² / 6)›*) have "(λn. ∑k<n. 1 / real (Suc k) ^ 2) ⇢ pi² / 6" by (simp add: sums_def (*‹?f sums ?s = (λn. sum ?f {..<n}) ⇢ ?s›*)) also (*calculation: ‹(λn. ∑k<n. 1 / (real (Suc k))²) ⇢ pi² / 6›*) have "(λn. ∑k<n. 1 / real (Suc k) ^ 2) = (λn. ∑k=1..n. 1 / real k ^ 2)" apply (intro ext (*‹(⋀x. ?f x = ?g x) ⟹ ?f = ?g›*) sum.reindex_bij_witness[of _ "λn. n - 1" Suc] (*‹⟦⋀a. a ∈ ?S ⟹ Suc a - 1 = a; ⋀a. a ∈ ?S ⟹ Suc a ∈ ?T; ⋀b. b ∈ ?T ⟹ Suc (b - 1) = b; ⋀b. b ∈ ?T ⟹ b - 1 ∈ ?S; ⋀a. a ∈ ?S ⟹ ?h (Suc a) = ?g a⟧ ⟹ sum ?g ?S = sum ?h ?T›*)) (*goals: 1. ‹⋀(n::nat) a::nat. a ∈ {..<n} ⟹ Suc a - (1::nat) = a› 2. ‹⋀(n::nat) a::nat. a ∈ {..<n} ⟹ Suc a ∈ {1::nat..n}› 3. ‹⋀(n::nat) b::nat. b ∈ {1::nat..n} ⟹ Suc (b - (1::nat)) = b› 4. ‹⋀(n::nat) b::nat. b ∈ {1::nat..n} ⟹ b - (1::nat) ∈ {..<n}› 5. ‹⋀(n::nat) a::nat. a ∈ {..<n} ⟹ (1::real) / (real (Suc a))² = (1::real) / (real (Suc 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*) . finally (*calculation: ‹(λn. ∑k = 1..n. 1 / (real k)²) ⇢ pi² / 6›*) have "(λb. (∑k = 1..b. 1 / real k^2) + 1 / real b - (∑i<2*N+1. bernoulli' (Suc i) * (- 1) ^ i / (real b ^ (i+2)))) ⇢ (pi^2/6 + 0 - (∑i<2*N+1. 0))" apply (intro tendsto_diff (*‹⟦(?f ⤏ ?a) ?F; (?g ⤏ ?b) ?F⟧ ⟹ ((λx. ?f x - ?g x) ⤏ ?a - ?b) ?F›*) tendsto_add (*‹⟦(?f ⤏ ?a) ?F; (?g ⤏ ?b) ?F⟧ ⟹ ((λx. ?f x + ?g x) ⤏ ?a + ?b) ?F›*) real_tendsto_divide_at_top[OF tendsto_const] (*‹filterlim ?g at_top ?F ⟹ ((λx. ?c / ?g x) ⤏ 0) ?F›*) filterlim_tendsto_pos_mult_at_top[OF tendsto_const] (*‹⟦0 < ?c; filterlim ?g at_top ?F⟧ ⟹ LIM x ?F. ?c * ?g x :> at_top›*) filterlim_pow_at_top (*‹⟦0 < ?n; filterlim ?f at_top ?F⟧ ⟹ LIM x ?F. ?f x ^ ?n :> at_top›*) filterlim_real_sequentially (*‹filterlim real at_top sequentially›*) tendsto_sum (*‹(⋀i. i ∈ ?I ⟹ (?f i ⤏ ?a i) ?F) ⟹ ((λx. ∑i∈?I. ?f i x) ⤏ sum ?a ?I) ?F›*)) (*goals: 1. ‹(λn. ∑k = 1..n. 1 / (real k)²) ⇢ pi² / 6 ⟹ (λx. ∑k = 1..x. 1 / (real k)²) ⇢ pi² / 6› 2. ‹⋀i. ⟦(λn. ∑k = 1..n. 1 / (real k)²) ⇢ pi² / 6; i ∈ {..<2 * N + 1}⟧ ⟹ 0 < i + 2› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . thus "(λb. (∑k = 1..b. 1 / real k^2) - (- 1 / real b) - (∑i<2*N+1. (bernoulli' (Suc i) / fact (Suc i)) *⇩R fs i (real b))) ⇢ pi^2/6" by (simp add: harm_def (*‹harm ?n = (∑k = 1..?n. inverse (of_nat k))›*) 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*) fs_def (*‹fs = (λk x. (- 1) ^ k * fact (Suc k) / x ^ (k + 2))›*) del: power_Suc (*‹?a ^ Suc ?n = ?a * ?a ^ ?n›*) of_nat_Suc (*‹of_nat (Suc ?m) = 1 + of_nat ?m›*)) qed (insert n (*‹0 < n›*) N (*‹0 < N›*), 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 272 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: fs_def (*‹fs = (λk x. (- 1) ^ k * fact (Suc k) / x ^ (k + 2))›*) has_real_derivative_iff_has_vector_derivative [symmetric] (*‹(?f has_vector_derivative ?y) ?F = (?f has_real_derivative ?y) ?F›*) power2_eq_square (*‹?a² = ?a * ?a›*)) (*solves the remaining goals: 1. ‹finite {}› 2. ‹fs 0 = (λx. 1 / x²)› 3. ‹⋀k. k ≤ 2 * N + 1 ⟹ continuous_on {real 1..} (fs k)› 4. ‹continuous_on {real 1..} ((/) (- 1))› 5. ‹⋀x. x ∈ {real 1..} - {} ⟹ ((/) (- 1) has_vector_derivative 1 / x²) (at x)›*) have "(∑k=1..n. 1 / real k ^ 2) = - 1 / real n + pi^2/6 + (1/2) *⇩R (1 / real n^2) + (∑i=1..N. (bernoulli (2*i) / fact (2*i)) *⇩R fs (2*i-1) (real n)) - EM_remainder (2*N+1) (fs (2*N+1)) (int n)" using n (*‹0 < n›*) N (*‹0 < 2 * N + 1›*) using n (*‹0 < n›*) apply (intro euler_maclaurin_strong_nat' (*‹1 ≤ ?b ⟹ (∑k = 1..?b. 1 / (real k)²) = - 1 / real ?b + pi² / 6 + (1 / 2) *⇩R (1 / (real ?b)²) + (∑i = 1..N. (bernoulli (2 * i) / fact (2 * i)) *⇩R fs (2 * i - 1) (real ?b)) - EM_remainder (2 * N + 1) (fs (2 * N + 1)) (int ?b)›*)) (*goal: ‹(∑k::nat = 1::nat..n::nat. (1::real) / (real k)²) = - (1::real) / real n + pi² / (6::real) + ((1::real) / (2::real)) *⇩R ((1::real) / (real n)²) + (∑i::nat = 1::nat..N::nat. (bernoulli ((2::nat) * i) / fact ((2::nat) * i)) *⇩R (fs::nat ⇒ real ⇒ real) ((2::nat) * i - (1::nat)) (real n)) - EM_remainder ((2::nat) * N + (1::nat)) (fs ((2::nat) * N + (1::nat))) (int n)›*) by simp also (*calculation: ‹(∑k = 1..n. 1 / (real k)²) = - 1 / real n + pi² / 6 + (1 / 2) *⇩R (1 / (real n)²) + (∑i = 1..N. (bernoulli (2 * i) / fact (2 * i)) *⇩R fs (2 * i - 1) (real n)) - EM_remainder (2 * N + 1) (fs (2 * N + 1)) (int n)›*) have "(∑i=1..N. (bernoulli (2*i) / fact (2*i)) *⇩R (fs (2*i-1) (real n))) = (∑i=1..N. -(bernoulli (2*i) / (real n ^ (2*i+1))))" apply (intro sum.cong (*‹⟦?A = ?B; ⋀x. x ∈ ?B ⟹ ?g x = ?h x⟧ ⟹ sum ?g ?A = sum ?h ?B›*) refl (*‹?t = ?t›*)) (*goal: ‹(∑i = 1..N. (bernoulli (2 * i) / fact (2 * i)) *⇩R fs (2 * i - 1) (real n)) = (∑i = 1..N. - (bernoulli (2 * i) / real n ^ (2 * i + 1)))›*) by (simp add: fs_def (*‹fs = (λk x. (- 1) ^ k * fact (Suc k) / x ^ (k + 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*) fact_reduce (*‹0 < ?n ⟹ fact ?n = of_nat ?n * fact (?n - 1)›*) del: of_nat_Suc (*‹of_nat (Suc ?m) = 1 + of_nat ?m›*) power_Suc (*‹?a ^ Suc ?n = ?a * ?a ^ ?n›*)) also (*calculation: ‹(∑k = 1..n. 1 / (real k)²) = - 1 / real n + pi² / 6 + (1 / 2) *⇩R (1 / (real n)²) + (∑i = 1..N. - (bernoulli (2 * i) / real n ^ (2 * i + 1))) - EM_remainder (2 * N + 1) (fs (2 * N + 1)) (int n)›*) have "… = -(∑i=1..N. bernoulli (2*i) / real n ^ (2*i+1))" by (simp add: sum_negf (*‹(∑x∈?A. - ?f x) = - sum ?f ?A›*)) finally (*calculation: ‹(∑k = 1..n. 1 / (real k)²) = - 1 / real n + pi² / 6 + (1 / 2) *⇩R (1 / (real n)²) + - (∑i = 1..N. bernoulli (2 * i) / real n ^ (2 * i + 1)) - EM_remainder (2 * N + 1) (fs (2 * N + 1)) (int n)›*) show "?thesis" (*goal: ‹(∑k = 1..n. 1 / (real k)²) = pi² / 6 - 1 / real n + 1 / (2 * (real n)²) - (∑i = 1..N. bernoulli (2 * i) / real (n ^ (2 * i + 1))) - EM_remainder (2 * N + 1) (λx. - fact (2 * N + 2) / x ^ (2 * N + 3)) (int n)›*) unfolding fs_def (*goal: ‹(∑k = 1..n. 1 / (real k)²) = pi² / 6 - 1 / real n + 1 / (2 * (real n)²) - (∑i = 1..N. bernoulli (2 * i) / real (n ^ (2 * i + 1))) - EM_remainder (2 * N + 1) (λx. - fact (2 * N + 2) / x ^ (2 * N + 3)) (int n)›*) by (simp add: fs_def (*‹fs = (λk x. (- 1) ^ k * fact (Suc k) / x ^ (k + 2))›*) 3 (*‹3 = Suc (Suc (Suc 0))›*)) qed lemma sum_inverse_squares_remainder_bound: fixes N :: nat assumes N: "N > 0" defines "R ≡ (λn. EM_remainder (2*N+1) (λx. -fact (2*N+2) / x ^ (2*N+3)) (int n))" shows "∃C. ∀n≥1. norm (R n) ≤ C / real n ^ (2*N+2)" proof (-) (*goal: ‹∃C. ∀n≥1. norm (R n) ≤ C / real n ^ (2 * N + 2)›*) have 3: "3 = Suc (Suc (Suc 0))" by simp from bounded_pbernpoly[of "2*N+1"] (*‹(⋀c. (⋀x. norm (pbernpoly (2 * N + 1) x) ≤ c) ⟹ ?thesis) ⟹ ?thesis›*) obtain D where D: "∀x. ¦pbernpoly (2*N+1) x¦ ≤ D" (*goal: ‹(⋀D. ∀x. ¦pbernpoly (2 * N + 1) x¦ ≤ D ⟹ thesis) ⟹ thesis›*) by auto have "∀x. 1 ≤ real x ⟶ norm (R x) ≤ D / fact (2*N+1) * (fact (2*N+1) / x ^ (2*N+2))" unfolding R_def of_int_of_nat_eq (*goal: ‹∀x::nat. (1::real) ≤ real x ⟶ norm (EM_remainder ((2::nat) * (N::nat) + (1::nat)) (λx::real. - fact ((2::nat) * N + (2::nat)) / x ^ ((2::nat) * N + (3::nat))) (int x)) ≤ (D::real) / fact ((2::nat) * N + (1::nat)) * (fact ((2::nat) * N + (1::nat)) / real x ^ ((2::nat) * N + (2::nat)))›*) proof (rule norm_EM_remainder_le_strong_nat'[of "{}"] (*‹⟦finite {}; ∀x. ¦pbernpoly ?n x¦ ≤ ?D; continuous_on {?a..} ?f; continuous_on {?a..} ?g; continuous_on {?a..} ?g'; (?g ⤏ 0) at_top; ⋀x. ?a ≤ x ⟹ norm (?f x) ≤ ?g' x; ⋀x. x ∈ {?a..} - {} ⟹ (?g has_real_derivative - ?g' x) (at x)⟧ ⟹ ∀x. ?a ≤ real x ⟶ norm (EM_remainder ?n ?f (int x)) ≤ ?D / fact ?n * ?g (real x)›*)) (*goals: 1. ‹finite {}› 2. ‹∀x. ¦pbernpoly (2 * N + 1) x¦ ≤ D› 3. ‹continuous_on {1..} (λa. - fact (2 * N + 2) / a ^ (2 * N + 3))› 4. ‹continuous_on {1..} (λa. fact (2 * N + 1) / a ^ (2 * N + 2))› 5. ‹continuous_on {1..} ?g'› 6. ‹((λa. fact (2 * N + 1) / a ^ (2 * N + 2)) ⤏ 0) at_top› 7. ‹⋀x. 1 ≤ x ⟹ norm (- fact (2 * N + 2) / x ^ (2 * N + 3)) ≤ ?g' x› 8. ‹⋀x. x ∈ {1..} - {} ⟹ ((λa. fact (2 * N + 1) / a ^ (2 * N + 2)) has_real_derivative - ?g' x) (at x)›*) fix x :: real assume x: "x ≥ 1" (*‹(1::real) ≤ (x::real)›*) show "norm (-fact (2*N+2) / x ^ (2*N+3)) ≤ fact (2*N+2) / x ^ (2*N+3)" using x (*‹1 ≤ x›*) by simp next (*goals: 1. ‹finite {}› 2. ‹∀x. ¦pbernpoly (2 * N + 1) x¦ ≤ D› 3. ‹continuous_on {1..} (λa. - fact (2 * N + 2) / a ^ (2 * N + 3))› 4. ‹continuous_on {1..} (λa. fact (2 * N + 1) / a ^ (2 * N + 2))› 5. ‹continuous_on {1..} (λx. fact (2 * N + 2) / x ^ (2 * N + 3))› 6. ‹((λa. fact (2 * N + 1) / a ^ (2 * N + 2)) ⤏ 0) at_top› 7. ‹⋀x. x ∈ {1..} - {} ⟹ ((λa. fact (2 * N + 1) / a ^ (2 * N + 2)) has_real_derivative - (fact (2 * N + 2) / x ^ (2 * N + 3))) (at x)›*) show "((λx::real. fact (2*N+1) / x ^ (2*N+2)) ⤏ 0) at_top" apply (intro real_tendsto_divide_at_top[OF tendsto_const] (*‹filterlim ?g at_top ?F ⟹ ((λx. ?c / ?g x) ⤏ 0) ?F›*) filterlim_pow_at_top (*‹⟦0 < ?n; filterlim ?f at_top ?F⟧ ⟹ LIM x ?F. ?f x ^ ?n :> at_top›*) filterlim_ident (*‹LIM x ?F. x :> ?F›*)) (*goal: ‹((λx::real. fact ((2::nat) * (N::nat) + (1::nat)) / x ^ ((2::nat) * N + (2::nat))) ⤏ (0::real)) at_top›*) by simp qed (insert N (*‹(0::nat) < (N::nat)›*) D (*‹∀x::real. ¦pbernpoly ((2::nat) * (N::nat) + (1::nat)) x¦ ≤ (D::real)›*), 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 135 facts*) 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 272 facts*) 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*) power_diff (*‹⟦?a ≠ 0; ?n ≤ ?m⟧ ⟹ ?a ^ (?m - ?n) = ?a ^ ?m div ?a ^ ?n›*) 3 (*‹3 = Suc (Suc (Suc 0))›*)) (*solves the remaining goals: 1. ‹finite {}› 2. ‹∀x::real. ¦pbernpoly ((2::nat) * (N::nat) + (1::nat)) x¦ ≤ (D::real)› 3. ‹continuous_on {1::real..} (λa::real. - fact ((2::nat) * (N::nat) + (2::nat)) / a ^ ((2::nat) * N + (3::nat)))› 4. ‹continuous_on {1::real..} (λa::real. fact ((2::nat) * (N::nat) + (1::nat)) / a ^ ((2::nat) * N + (2::nat)))› 5. ‹continuous_on {1::real..} (λx::real. fact ((2::nat) * (N::nat) + (2::nat)) / x ^ ((2::nat) * N + (3::nat)))› 6. ‹⋀x::real. x ∈ {1::real..} - {} ⟹ ((λa::real. fact ((2::nat) * (N::nat) + (1::nat)) / a ^ ((2::nat) * N + (2::nat))) has_real_derivative - (fact ((2::nat) * N + (2::nat)) / x ^ ((2::nat) * N + (3::nat)))) (at x)›*) hence "∀x≥1. norm (R x) ≤ D / real x ^ (2 * N + 2)" by simp thus "?thesis" (*goal: ‹∃C. ∀n≥1. norm (R n) ≤ C / real n ^ (2 * N + 2)›*) by blast qed end
{ "path": "afp-2025-02-12/thys/Euler_MacLaurin/Euler_MacLaurin.thy", "repo": "afp-2025-02-12", "sha": "713ccf0ed7de5f1fed69a218203053c8b947027262aa35b715a6b950a755cd34" }
theory Get_Types_Verification imports "../abs-def/Abs_SAIS" "../def/Get_Types" begin section "Suffix Types" lemma get_suffix_types_step_r0_ret: "∃xs' i'. get_suffix_types_step_r0 (xs, i) ys = (xs', i') ∧ length xs' = length xs ∧ (i = 0 ⟶ i' = 0) ∧ (∃j. i = Suc j ⟶ i' = j)" apply (cases i) (*goals: 1. ‹i = 0 ⟹ ∃xs' i'. get_suffix_types_step_r0 (xs, i) ys = (xs', i') ∧ length xs' = length xs ∧ (i = 0 ⟶ i' = 0) ∧ (∃j. i = Suc j ⟶ i' = j)› 2. ‹⋀nat. i = Suc nat ⟹ ∃xs' i'. get_suffix_types_step_r0 (xs, i) ys = (xs', i') ∧ length xs' = length xs ∧ (i = 0 ⟶ i' = 0) ∧ (∃j. i = Suc j ⟶ i' = j)› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) . lemma get_suffix_types_step_r0_0: "get_suffix_types_step_r0 (xs, 0) ys = (xs, 0)" by simp lemma get_suffix_types_step_r0_Suc: "⟦Suc i < length xs; length xs = length ys; ∀k < length xs. i < k ⟶ xs ! k = suffix_type ys k⟧ ⟹ get_suffix_types_step_r0 (xs, Suc i) ys = (xs[i := suffix_type ys i], i)" apply clarsimp (*goal: ‹⟦Suc i < length xs; length xs = length ys; ∀k<length xs. i < k ⟶ xs ! k = suffix_type ys k⟧ ⟹ get_suffix_types_step_r0 (xs, Suc i) ys = (xs[i := suffix_type ys i], i)›*) apply (intro conjI (*‹⟦?P; ?Q⟧ ⟹ ?P ∧ ?Q›*) impI (*‹(?P ⟹ ?Q) ⟹ ?P ⟶ ?Q›*) arg_cong[where f = "λx. xs[i := x]"] (*‹?x = ?y ⟹ xs[i := ?x] = xs[i := ?y]›*)) (*goals: 1. ‹⟦Suc i < length ys; length xs = length ys; ∀k<length ys. i < k ⟶ xs ! k = suffix_type ys k; ys ! Suc i < ys ! i; ¬ ys ! i < ys ! Suc i⟧ ⟹ L_type = suffix_type ys i› 2. ‹⟦Suc i < length ys; length xs = length ys; ∀k<length ys. i < k ⟶ xs ! k = suffix_type ys k; ¬ ys ! Suc i < ys ! i; ys ! i < ys ! Suc i⟧ ⟹ S_type = suffix_type ys i› 3. ‹⟦Suc i < length ys; length xs = length ys; ∀k<length ys. i < k ⟶ xs ! k = suffix_type ys k; ¬ ys ! Suc i < ys ! i; ys ! i = ys ! Suc i⟧ ⟹ suffix_type ys (Suc i) = suffix_type ys i› discuss goal 1*) apply (simp add: nth_gr_imp_l_type (*‹⟦Suc ?i < length ?s; ?s ! Suc ?i < ?s ! ?i⟧ ⟹ suffix_type ?s ?i = L_type›*)) (*discuss goal 2*) apply (simp add: nth_less_imp_s_type (*‹⟦Suc ?i < length ?s; ?s ! ?i < ?s ! Suc ?i⟧ ⟹ suffix_type ?s ?i = S_type›*)) (*discuss goal 3*) apply (metis suffix_type_neq (*‹⟦suffix_type ?T ?j ≠ suffix_type ?T (Suc ?j); Suc ?j < length ?T⟧ ⟹ ?T ! ?j ≠ ?T ! Suc ?j›*)) (*proven 3 subgoals*) . fun get_suffix_types_inv where "get_suffix_types_inv ys (xs, i) = (length xs = length ys ∧ i < length xs ∧ (∀k < length xs. i ≤ k ⟶ xs ! k = suffix_type ys k))" lemma get_suffix_types_inv_maintained: assumes "get_suffix_types_inv ys (xs, i)" shows "get_suffix_types_inv ys (get_suffix_types_step_r0 (xs, i) ys)" proof (cases i) (*goals: 1. ‹i = 0 ⟹ get_suffix_types_inv ys (get_suffix_types_step_r0 (xs, i) ys)› 2. ‹⋀nat. i = Suc nat ⟹ get_suffix_types_inv ys (get_suffix_types_step_r0 (xs, i) ys)›*) case 0 (*‹(i::nat) = (0::nat)›*) hence "get_suffix_types_step_r0 (xs, i) ys = (xs, 0)" using get_suffix_types_step_r0_0 (*‹get_suffix_types_step_r0 (?xs, 0) ?ys = (?xs, 0)›*) by simp moreover have "get_suffix_types_inv ys (xs, 0)" using "0" (*‹i = 0›*) assms (*‹get_suffix_types_inv ys (xs, i)›*) by auto ultimately show "?thesis" (*goal: ‹get_suffix_types_inv ys (get_suffix_types_step_r0 (xs, i) ys)›*) by presburger next (*goal: ‹⋀nat. i = Suc nat ⟹ get_suffix_types_inv ys (get_suffix_types_step_r0 (xs, i) ys)›*) case (Suc n) (*‹i = Suc n›*) hence "get_suffix_types_step_r0 (xs, i) ys = (xs[n := suffix_type ys n], n)" by (metis Suc_leI (*‹(?m::nat) < (?n::nat) ⟹ Suc ?m ≤ ?n›*) assms (*‹get_suffix_types_inv (ys::'a list) (xs::SL_types list, i::nat)›*) get_suffix_types_inv.simps (*‹get_suffix_types_inv (?ys::?'a list) (?xs::SL_types list, ?i::nat) = (length ?xs = length ?ys ∧ ?i < length ?xs ∧ (∀k<length ?xs. ?i ≤ k ⟶ ?xs ! k = suffix_type ?ys k))›*) get_suffix_types_step_r0_Suc (*‹⟦Suc (?i::nat) < length (?xs::SL_types list); length ?xs = length (?ys::?'a list); ∀k<length ?xs. ?i < k ⟶ ?xs ! k = suffix_type ?ys k⟧ ⟹ get_suffix_types_step_r0 (?xs, Suc ?i) ?ys = (?xs[?i := suffix_type ?ys ?i], ?i)›*)) moreover have "get_suffix_types_inv ys (xs[n := suffix_type ys n], n)" using Suc (*‹(i::nat) = Suc (n::nat)›*) assms (*‹get_suffix_types_inv ys (xs, i)›*) le_eq_less_or_eq (*‹(?m ≤ ?n) = (?m < ?n ∨ ?m = ?n)›*) by fastforce ultimately show "?thesis" (*goal: ‹get_suffix_types_inv ys (get_suffix_types_step_r0 (xs, i) ys)›*) by simp qed lemma get_suffix_types_inv_established: "xs ≠ [] ⟹ get_suffix_types_inv xs (replicate (length xs) S_type, length xs - Suc 0)" by (simp add: suffix_type_last (*‹length ?xs = Suc ?n ⟹ suffix_type ?xs ?n = S_type›*)) lemma get_suffix_types_base_prod': "∃xs'. repeat n get_suffix_types_step_r0 (xs, m) ys = (xs', m - n)" proof (induct n arbitrary: xs m) (*goals: 1. ‹⋀xs m. ∃xs'. repeat 0 get_suffix_types_step_r0 (xs, m) ys = (xs', m - 0)› 2. ‹⋀n xs m. (⋀xs m. ∃xs'. repeat n get_suffix_types_step_r0 (xs, m) ys = (xs', m - n)) ⟹ ∃xs'. repeat (Suc n) get_suffix_types_step_r0 (xs, m) ys = (xs', m - Suc n)›*) case 0 (*no hyothesis introduced yet*) then show "?case" (*goal: ‹∃xs'. repeat 0 get_suffix_types_step_r0 (xs, m) ys = (xs', m - 0)›*) by (simp add: repeat_0 (*‹repeat 0 ?f ?a ?b = ?a›*)) next (*goal: ‹⋀n xs m. (⋀xs m. ∃xs'. repeat n get_suffix_types_step_r0 (xs, m) ys = (xs', m - n)) ⟹ ∃xs'. repeat (Suc n) get_suffix_types_step_r0 (xs, m) ys = (xs', m - Suc n)›*) case (Suc n) (*‹∃xs'::SL_types list. repeat (n::nat) get_suffix_types_step_r0 (?xs::SL_types list, ?m::nat) (ys::'a list) = (xs', ?m - n)›*) note IH = this (*‹∃xs'. repeat n get_suffix_types_step_r0 (?xs, ?m) ys = (xs', ?m - n)›*) from repeat_step[of n get_suffix_types_step_r0 "(xs, m)" ys] (*‹repeat (Suc n) get_suffix_types_step_r0 (xs, m) ys = get_suffix_types_step_r0 (repeat n get_suffix_types_step_r0 (xs, m) ys) ys›*) have "repeat (Suc n) get_suffix_types_step_r0 (xs, m) ys = get_suffix_types_step_r0 (repeat n get_suffix_types_step_r0 (xs, m) ys) ys" . moreover from IH[of xs m] (*‹∃xs'. repeat n get_suffix_types_step_r0 (xs, m) ys = (xs', m - n)›*) obtain xs' where "repeat n get_suffix_types_step_r0 (xs, m) ys = (xs', m - n)" (*goal: ‹(⋀xs'. repeat n get_suffix_types_step_r0 (xs, m) ys = (xs', m - n) ⟹ thesis) ⟹ thesis›*) by blast moreover have "∃xs''. get_suffix_types_step_r0 (xs', m - n) ys = (xs'', m - Suc n)" proof (cases "m-n") (*goals: 1. ‹m - n = 0 ⟹ ∃xs''. get_suffix_types_step_r0 (xs', m - n) ys = (xs'', m - Suc n)› 2. ‹⋀nat. m - n = Suc nat ⟹ ∃xs''. get_suffix_types_step_r0 (xs', m - n) ys = (xs'', m - Suc n)›*) case 0 (*‹m - n = 0›*) hence "get_suffix_types_step_r0 (xs', m - n) ys = (xs', 0)" by auto moreover have "m - Suc n = 0" using "0" (*‹(m::nat) - (n::nat) = (0::nat)›*) by auto ultimately show "?thesis" (*goal: ‹∃xs''. get_suffix_types_step_r0 (xs', m - n) ys = (xs'', m - Suc n)›*) by simp next (*goal: ‹⋀nat::nat. (m::nat) - (n::nat) = Suc nat ⟹ ∃xs''::SL_types list. get_suffix_types_step_r0 (xs'::SL_types list, m - n) (ys::'a list) = (xs'', m - Suc n)›*) case (Suc k) (*‹m - n = Suc k›*) have "(m - n < length xs' ∧ m - n < length ys) ∨ ¬(m - n < length xs' ∧ m - n < length ys)" by blast moreover have "m - n < length xs' ∧ m - n < length ys ⟹ ?thesis" by (clarsimp simp add: Suc (*‹m - n = Suc k›*) diff_Suc (*‹?m - Suc ?n = (case ?m - ?n of 0 ⇒ 0 | Suc k ⇒ k)›*)) moreover have "¬(m - n < length xs' ∧ m - n < length ys) ⟹ ?thesis" by (clarsimp simp add: Suc (*‹m - n = Suc k›*) diff_Suc (*‹?m - Suc ?n = (case ?m - ?n of 0 ⇒ 0 | Suc k ⇒ k)›*)) ultimately show "?thesis" (*goal: ‹∃xs''. get_suffix_types_step_r0 (xs', m - n) ys = (xs'', m - Suc n)›*) by blast qed ultimately show "?case" (*goal: ‹∃xs'::SL_types list. repeat (Suc (n::nat)) get_suffix_types_step_r0 (xs::SL_types list, m::nat) (ys::'a list) = (xs', m - Suc n)›*) by presburger qed lemma get_suffix_types_inv_holds: assumes "xs ≠ []" shows "get_suffix_types_inv xs (get_suffix_types_base xs)" unfolding get_suffix_types_base_def (*goal: ‹get_suffix_types_inv (xs::'a list) (repeat (length xs - Suc (0::nat)) get_suffix_types_step_r0 (replicate (length xs) S_type, length xs - Suc (0::nat)) xs)›*) apply (rule repeat_maintain_inv (*‹⟦⋀a. ?P a ⟹ ?P (?f a ?b); ?P ?a⟧ ⟹ ?P (repeat ?n ?f ?a ?b)›*)) (*goals: 1. ‹⋀a. get_suffix_types_inv xs a ⟹ get_suffix_types_inv xs (get_suffix_types_step_r0 a xs)› 2. ‹get_suffix_types_inv xs (replicate (length xs) S_type, length xs - Suc 0)› discuss goal 1*) apply (metis get_suffix_types_inv_maintained (*‹get_suffix_types_inv ?ys (?xs, ?i) ⟹ get_suffix_types_inv ?ys (get_suffix_types_step_r0 (?xs, ?i) ?ys)›*) prod.collapse (*‹(fst ?prod, snd ?prod) = ?prod›*)) (*discuss goal 2*) apply (rule get_suffix_types_inv_established[OF assms] (*‹get_suffix_types_inv (xs::'a list) (replicate (length xs) S_type, length xs - Suc (0::nat))›*)) (*proven 2 subgoals*) . lemma get_suffix_types_base_prod: "∃xs'. get_suffix_types_base xs = (xs', 0)" unfolding get_suffix_types_base_def (*goal: ‹∃xs'. repeat (length xs - Suc 0) get_suffix_types_step_r0 (replicate (length xs) S_type, length xs - Suc 0) xs = (xs', 0)›*) by (metis cancel_comm_monoid_add_class.diff_cancel (*‹?a - ?a = 0›*) get_suffix_types_base_prod' (*‹∃xs'. repeat ?n get_suffix_types_step_r0 (?xs, ?m) ?ys = (xs', ?m - ?n)›*)) lemma get_suffix_types_base_ref: "get_suffix_types_base xs = (abs_get_suffix_types xs, 0)" proof (cases "xs ≠ []") (*goals: 1. ‹xs ≠ [] ⟹ get_suffix_types_base xs = (abs_get_suffix_types xs, 0)› 2. ‹¬ xs ≠ [] ⟹ get_suffix_types_base xs = (abs_get_suffix_types xs, 0)›*) assume "¬ xs ≠ []" (*‹¬ (xs::'a list) ≠ []›*) then show "?thesis" (*goal: ‹get_suffix_types_base xs = (abs_get_suffix_types xs, 0)›*) by (clarsimp simp: get_suffix_types_base_def (*‹get_suffix_types_base ?xs ≡ repeat (length ?xs - Suc 0) get_suffix_types_step_r0 (replicate (length ?xs) S_type, length ?xs - Suc 0) ?xs›*) repeat_0 (*‹repeat 0 ?f ?a ?b = ?a›*) get_suffix_types_def (*‹get_suffix_types ?xs ≡ fst (get_suffix_types_base ?xs)›*)) next (*goal: ‹xs ≠ [] ⟹ get_suffix_types_base xs = (abs_get_suffix_types xs, 0)›*) assume "xs ≠ []" (*‹(xs::'a list) ≠ []›*) with get_suffix_types_inv_holds (*‹?xs ≠ [] ⟹ get_suffix_types_inv ?xs (get_suffix_types_base ?xs)›*) have "get_suffix_types_inv xs (get_suffix_types_base xs)" by blast moreover from get_suffix_types_base_prod[of xs] (*‹∃xs'. get_suffix_types_base xs = (xs', 0)›*) obtain xs' where "get_suffix_types_base xs = (xs', 0)" (*goal: ‹(⋀xs'. get_suffix_types_base xs = (xs', 0) ⟹ thesis) ⟹ thesis›*) by blast ultimately have "get_suffix_types_inv xs (xs', 0)" by auto moreover have "abs_get_suffix_types xs = xs'" unfolding list_eq_iff_nth_eq (*goal: ‹length (abs_get_suffix_types xs) = length xs' ∧ (∀i<length (abs_get_suffix_types xs). abs_get_suffix_types xs ! i = xs' ! i)›*) by (metis bot_nat_0.extremum (*‹0 ≤ ?a›*) calculation (*‹get_suffix_types_inv xs (xs', 0)›*) get_suffix_types_correct (*‹∀i<length ?s. abs_get_suffix_types ?s ! i = suffix_type ?s i›*) get_suffix_types_inv.simps (*‹get_suffix_types_inv ?ys (?xs, ?i) = (length ?xs = length ?ys ∧ ?i < length ?xs ∧ (∀k<length ?xs. ?i ≤ k ⟶ ?xs ! k = suffix_type ?ys k))›*) length_abs_get_suffix_types (*‹length (abs_get_suffix_types ?s) = length ?s›*)) ultimately show "?thesis" (*goal: ‹get_suffix_types_base xs = (abs_get_suffix_types xs, 0)›*) by (simp add: ‹get_suffix_types_base xs = (xs', 0)›) qed lemma get_suffix_types_eq: "get_suffix_types xs = abs_get_suffix_types xs" by (simp add: get_suffix_types_base_ref (*‹get_suffix_types_base ?xs = (abs_get_suffix_types ?xs, 0)›*) get_suffix_types_def (*‹get_suffix_types ?xs ≡ fst (get_suffix_types_base ?xs)›*)) lemmas length_get_suffix_types = length_abs_get_suffix_types[simplified get_suffix_types_eq] (* abbreviation "get_suffix_types_ref ≡ get_suffix_types" lemmas get_suffix_types_refinement = get_suffix_types_r0_ref *) section "LMS types" lemma is_lms_refinement: assumes "length ST = length T" "∀i < length T. ST ! i = suffix_type T i" shows "is_lms_ref ST = abs_is_lms T" proof (standard) (*goal: ‹⋀x. is_lms_ref ST x = abs_is_lms T x›*) fix i show "is_lms_ref ST i = abs_is_lms T i" proof (cases i) (*goals: 1. ‹i = 0 ⟹ is_lms_ref ST i = abs_is_lms T i› 2. ‹⋀nat. i = Suc nat ⟹ is_lms_ref ST i = abs_is_lms T i›*) case 0 (*‹i = 0›*) then show "?thesis" (*goal: ‹is_lms_ref ST i = abs_is_lms T i›*) by (simp add: abs_is_lms_0 (*‹¬ abs_is_lms ?s 0›*)) next (*goal: ‹⋀nat::nat. (i::nat) = Suc nat ⟹ is_lms_ref (ST::SL_types list) i = abs_is_lms (T::'a::{linorder,order_bot} list) i›*) case (Suc n) (*‹i = Suc n›*) then show "?thesis" (*goal: ‹is_lms_ref ST i = abs_is_lms T i›*) by (metis Suc_lessD (*‹Suc ?m < ?n ⟹ ?m < ?n›*) assms (*‹length ST = length T› ‹∀i<length T. ST ! i = suffix_type T i›*) abs_is_lms_def (*‹abs_is_lms ?s ?i ≡ suffix_type ?s ?i = S_type ∧ (∃j. ?i = Suc j ∧ suffix_type ?s j = L_type)›*) abs_is_lms_imp_less_length (*‹abs_is_lms ?T ?i ⟹ ?i < length ?T›*) is_lms_ref.simps( (*‹is_lms_ref ?ST (Suc ?i) = (if Suc ?i < length ?ST then ?ST ! ?i = L_type ∧ ?ST ! Suc ?i = S_type else False)›*) 2)) qed qed section "Extracting LMS types" lemma extract_lms_eq: "⟦length ST = length T; ∀i < length T. ST ! i = suffix_type T i⟧ ⟹ extract_lms ST = abs_extract_lms T" by (clarsimp simp: fun_eq_iff (*‹(?f = ?g) = (∀x. ?f x = ?g x)›*) is_lms_refinement (*‹⟦length ?ST = length ?T; ∀i<length ?T. ?ST ! i = suffix_type ?T i⟧ ⟹ is_lms_ref ?ST = abs_is_lms ?T›*)) section "LMS Substrings" lemma find_next_lms_refinement: "⟦length ST = length T; ∀i < length T. ST ! i = suffix_type T i⟧ ⟹ find_next_lms ST= abs_find_next_lms T" unfolding find_next_lms_def abs_find_next_lms_def (*goal: ‹⟦length (ST::SL_types list) = length (T::'a list); ∀i<length T. ST ! i = suffix_type T i⟧ ⟹ (λi::nat. case find (is_lms_ref ST) [Suc i..<length ST] of None ⇒ length ST | Some (j::nat) ⇒ j) = (λi::nat. case find (abs_is_lms T) [Suc i..<length T] of None ⇒ length T | Some (j::nat) ⇒ j)›*) apply (clarsimp simp: is_lms_refinement (*‹⟦length ?ST = length ?T; ∀i<length ?T. ?ST ! i = suffix_type ?T i⟧ ⟹ is_lms_ref ?ST = abs_is_lms ?T›*) fun_eq_iff (*‹(?f = ?g) = (∀x. ?f x = ?g x)›*)) (*goal: ‹⟦length ST = length T; ∀i<length T. ST ! i = suffix_type T i⟧ ⟹ (λi. case find (is_lms_ref ST) [Suc i..<length ST] of None ⇒ length ST | Some j ⇒ j) = (λi. case find (abs_is_lms T) [Suc i..<length T] of None ⇒ length T | Some j ⇒ j)›*) by argo lemma lms_slice_refinement: "⟦length ST = length T; ∀i < length T. ST ! i = suffix_type T i⟧ ⟹ lms_slice_ref T ST = lms_slice T" unfolding lms_slice_ref_def lms_slice_def (*goal: ‹⟦length (ST::SL_types list) = length (T::'a::{linorder,order_bot} list); ∀i<length T. ST ! i = suffix_type T i⟧ ⟹ (λi::nat. list_slice T i (Suc (find_next_lms ST i))) = (λi::nat. list_slice T i (Suc (abs_find_next_lms T i)))›*) by (clarsimp simp: find_next_lms_refinement (*‹⟦length ?ST = length ?T; ∀i<length ?T. ?ST ! i = suffix_type ?T i⟧ ⟹ find_next_lms ?ST = abs_find_next_lms ?T›*) fun_eq_iff (*‹(?f = ?g) = (∀x. ?f x = ?g x)›*)) section ‹Rename Mapping› lemma rename_mapping'_refinement: assumes "length ST = length T" "∀i < length T. ST ! i = suffix_type T i" shows "rename_mapping' T ST = abs_rename_mapping' T" proof (intro fun_eq_iff[THEN iffD2] (*‹∀x. ?f1 x = ?g1 x ⟹ ?f1 = ?g1›*) allI (*‹(⋀x. ?P x) ⟹ ∀x. ?P x›*)) (*goal: ‹⋀x xa xb. rename_mapping' T ST x xa xb = abs_rename_mapping' T x xa xb›*) fix xs and ns and i show "rename_mapping' T ST xs ns i = abs_rename_mapping' T xs ns i" using assms (*‹length ST = length T› ‹∀i<length T. ST ! i = suffix_type T i›*) proof (induct rule: rename_mapping'.induct[of _ T ST xs ns i] (*‹⟦⋀uu_ uv_ names uw_. ?P uu_ uv_ [] names uw_; ⋀ux_ uy_ x names i. ?P ux_ uy_ [x] names i; ⋀T ST a b xs names i. ⟦lms_slice_ref T ST a = lms_slice_ref T ST b ⟹ ?P T ST (b # xs) (names[a := i]) i; lms_slice_ref T ST a ≠ lms_slice_ref T ST b ⟹ ?P T ST (b # xs) (names[a := i]) (Suc i)⟧ ⟹ ?P T ST (a # b # xs) names i⟧ ⟹ ?P T ST xs ns i›*)) (*goals: 1. ‹⋀uu_ uv_ names uw_. ⟦length uv_ = length uu_; ∀i<length uu_. uv_ ! i = suffix_type uu_ i⟧ ⟹ rename_mapping' uu_ uv_ [] names uw_ = abs_rename_mapping' uu_ [] names uw_› 2. ‹⋀ux_ uy_ x names i. ⟦length uy_ = length ux_; ∀i<length ux_. uy_ ! i = suffix_type ux_ i⟧ ⟹ rename_mapping' ux_ uy_ [x] names i = abs_rename_mapping' ux_ [x] names i› 3. ‹⋀T ST a b xs names i. ⟦⟦lms_slice_ref T ST a = lms_slice_ref T ST b; length ST = length T; ∀i<length T. ST ! i = suffix_type T i⟧ ⟹ rename_mapping' T ST (b # xs) (names[a := i]) i = abs_rename_mapping' T (b # xs) (names[a := i]) i; ⟦lms_slice_ref T ST a ≠ lms_slice_ref T ST b; length ST = length T; ∀i<length T. ST ! i = suffix_type T i⟧ ⟹ rename_mapping' T ST (b # xs) (names[a := i]) (Suc i) = abs_rename_mapping' T (b # xs) (names[a := i]) (Suc i); length ST = length T; ∀i<length T. ST ! i = suffix_type T i⟧ ⟹ rename_mapping' T ST (a # b # xs) names i = abs_rename_mapping' T (a # b # xs) names i›*) case (1 T ST ns i) (*‹length ST = length T› ‹∀i<length (T::'a::{linorder,order_bot} list). (ST::SL_types list) ! i = suffix_type T i›*) then show "?case" (*goal: ‹rename_mapping' T ST [] ns i = abs_rename_mapping' T [] ns i›*) by simp next (*goals: 1. ‹⋀ux_ uy_ x names i. ⟦length uy_ = length ux_; ∀i<length ux_. uy_ ! i = suffix_type ux_ i⟧ ⟹ rename_mapping' ux_ uy_ [x] names i = abs_rename_mapping' ux_ [x] names i› 2. ‹⋀T ST a b xs names i. ⟦⟦lms_slice_ref T ST a = lms_slice_ref T ST b; length ST = length T; ∀i<length T. ST ! i = suffix_type T i⟧ ⟹ rename_mapping' T ST (b # xs) (names[a := i]) i = abs_rename_mapping' T (b # xs) (names[a := i]) i; ⟦lms_slice_ref T ST a ≠ lms_slice_ref T ST b; length ST = length T; ∀i<length T. ST ! i = suffix_type T i⟧ ⟹ rename_mapping' T ST (b # xs) (names[a := i]) (Suc i) = abs_rename_mapping' T (b # xs) (names[a := i]) (Suc i); length ST = length T; ∀i<length T. ST ! i = suffix_type T i⟧ ⟹ rename_mapping' T ST (a # b # xs) names i = abs_rename_mapping' T (a # b # xs) names i›*) case (2 T ST x ns i) (*‹length ST = length T› ‹∀i<length T. ST ! i = suffix_type T i›*) then show "?case" (*goal: ‹rename_mapping' T ST [x] ns i = abs_rename_mapping' T [x] ns i›*) by simp next (*goal: ‹⋀T ST a b xs names i. ⟦⟦lms_slice_ref T ST a = lms_slice_ref T ST b; length ST = length T; ∀i<length T. ST ! i = suffix_type T i⟧ ⟹ rename_mapping' T ST (b # xs) (names[a := i]) i = abs_rename_mapping' T (b # xs) (names[a := i]) i; ⟦lms_slice_ref T ST a ≠ lms_slice_ref T ST b; length ST = length T; ∀i<length T. ST ! i = suffix_type T i⟧ ⟹ rename_mapping' T ST (b # xs) (names[a := i]) (Suc i) = abs_rename_mapping' T (b # xs) (names[a := i]) (Suc i); length ST = length T; ∀i<length T. ST ! i = suffix_type T i⟧ ⟹ rename_mapping' T ST (a # b # xs) names i = abs_rename_mapping' T (a # b # xs) names i›*) case (3 T ST a b xs ns i) (*‹⟦lms_slice_ref T ST a = lms_slice_ref T ST b; length ST = length T; ∀i<length T. ST ! i = suffix_type T i⟧ ⟹ rename_mapping' T ST (b # xs) (ns[a := i]) i = abs_rename_mapping' T (b # xs) (ns[a := i]) i› ‹⟦lms_slice_ref T ST a ≠ lms_slice_ref T ST b; length ST = length T; ∀i<length T. ST ! i = suffix_type T i⟧ ⟹ rename_mapping' T ST (b # xs) (ns[a := i]) (Suc i) = abs_rename_mapping' T (b # xs) (ns[a := i]) (Suc i)› ‹length ST = length T› ‹∀i<length T. ST ! i = suffix_type T i›*) then show "?case" (*goal: ‹rename_mapping' T ST (a # b # xs) ns i = abs_rename_mapping' T (a # b # xs) ns i›*) by (simp add: lms_slice_refinement (*‹⟦length (?ST::SL_types list) = length (?T::?'a list); ∀i<length ?T. ?ST ! i = suffix_type ?T i⟧ ⟹ lms_slice_ref ?T ?ST = lms_slice ?T›*)) qed qed lemma rename_mapping_refinement: assumes "length ST = length T" assumes "∀i < length T. ST ! i = suffix_type T i" shows "rename_mapping T ST = abs_rename_mapping T" by (clarsimp simp: fun_eq_iff (*‹(?f = ?g) = (∀x. ?f x = ?g x)›*) assms (*‹length ST = length T› ‹∀i<length T. ST ! i = suffix_type T i›*) rename_mapping'_refinement (*‹⟦length ?ST = length ?T; ∀i<length ?T. ?ST ! i = suffix_type ?T i⟧ ⟹ rename_mapping' ?T ?ST = abs_rename_mapping' ?T›*) abs_rename_mapping_def (*‹abs_rename_mapping ?T ?LMS = abs_rename_mapping' ?T ?LMS (replicate (length ?T) (length ?T)) 0›*) rename_mapping_def (*‹rename_mapping ?T ?ST ?LMS = rename_mapping' ?T ?ST ?LMS (replicate (length ?T) (length ?T)) 0›*)) end
{ "path": "afp-2025-02-12/thys/SuffixArray/sais/proof/Get_Types_Verification.thy", "repo": "afp-2025-02-12", "sha": "9f4c4c1bb3e557dfcbf3e62170d55e36460ab330892758e5dd169819b5d68585" }
section ‹Absolute Retracts, Absolute Neighbourhood Retracts and Euclidean Neighbourhood Retracts› theory Retracts imports Brouwer_Fixpoint Continuous_Extension begin text ‹Absolute retracts (AR), absolute neighbourhood retracts (ANR) and also Euclidean neighbourhood retracts (ENR). We define AR and ANR by specializing the standard definitions for a set to embedding in spaces of higher dimension. John Harrison writes: "This turns out to be sufficient (since any set in ‹ℝ⇧n› can be embedded as a closed subset of a convex subset of ‹ℝ⇧n⁺¹›) to derive the usual definitions, but we need to split them into two implications because of the lack of type quantifiers. Then ENR turns out to be equivalent to ANR plus local compactness."› definition✐‹tag important› AR :: "'a::topological_space set ⇒ bool" where "AR S ≡ ∀U. ∀S'::('a * real) set. S homeomorphic S' ∧ closedin (top_of_set U) S' ⟶ S' retract_of U" definition✐‹tag important› ANR :: "'a::topological_space set ⇒ bool" where "ANR S ≡ ∀U. ∀S'::('a * real) set. S homeomorphic S' ∧ closedin (top_of_set U) S' ⟶ (∃T. openin (top_of_set U) T ∧ S' retract_of T)" definition✐‹tag important› ENR :: "'a::topological_space set ⇒ bool" where "ENR S ≡ ∃U. open U ∧ S retract_of U" text ‹First, show that we do indeed get the "usual" properties of ARs and ANRs.› lemma AR_imp_absolute_extensor: fixes f :: "'a::euclidean_space ⇒ 'b::euclidean_space" assumes "AR S" and contf: "continuous_on T f" and "f ` T ⊆ S" and cloUT: "closedin (top_of_set U) T" obtains g where "continuous_on U g" "g ` U ⊆ S" "⋀x. x ∈ T ⟹ g x = f x" proof (-) (*goal: ‹(⋀g. ⟦continuous_on U g; g ` U ⊆ S; ⋀x. x ∈ T ⟹ g x = f x⟧ ⟹ thesis) ⟹ thesis›*) have "aff_dim S < int (DIM('b × real))" using aff_dim_le_DIM[of S] (*‹aff_dim (S::'b set) ≤ int DIM('b)›*) by simp then obtain C and S' :: "('b * real) set" where C: "convex C" "C ≠ {}" and cloCS: "closedin (top_of_set C) S'" and hom: "S homeomorphic S'" (*goal: ‹(⋀C S'. ⟦convex C; C ≠ {}; closedin (top_of_set C) S'; S homeomorphic S'⟧ ⟹ thesis) ⟹ thesis›*) by (metis that (*‹⟦convex ?C; ?C ≠ {}; closedin (top_of_set ?C) ?S'; S homeomorphic ?S'⟧ ⟹ thesis›*) homeomorphic_closedin_convex (*‹⟦aff_dim ?S < int DIM(?'n); ⋀U T. ⟦convex U; U ≠ {}; closedin (top_of_set U) T; ?S homeomorphic T⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*)) then have "S' retract_of C" using ‹AR S› (*‹AR (S::'b set)›*) by (simp add: AR_def (*‹AR ?S ≡ ∀U S'. ?S homeomorphic S' ∧ closedin (top_of_set U) S' ⟶ S' retract_of U›*)) then obtain r where "S' ⊆ C" and contr: "continuous_on C r" and "r ` C ⊆ S'" and rid: "⋀x. x∈S' ⟹ r x = x" (*goal: ‹(⋀r. ⟦S' ⊆ C; continuous_on C r; r ` C ⊆ S'; ⋀x. x ∈ S' ⟹ r x = x⟧ ⟹ thesis) ⟹ thesis›*) by (auto simp: retraction_def (*‹retraction (?S::?'a set) (?T::?'a set) (?r::?'a ⇒ ?'a) = (?T ⊆ ?S ∧ continuous_on ?S ?r ∧ ?r ∈ ?S → ?T ∧ (∀x::?'a∈?T. ?r x = x))›*) retract_of_def (*‹((?T::?'a set) retract_of (?S::?'a set)) = (∃r::?'a ⇒ ?'a. retraction ?S ?T r)›*)) obtain g and h where "homeomorphism S S' g h" (*goal: ‹(⋀g h. homeomorphism S S' g h ⟹ thesis) ⟹ thesis›*) using hom (*‹S homeomorphic S'›*) by (force simp: homeomorphic_def (*‹?s homeomorphic ?t ≡ ∃f g. homeomorphism ?s ?t f g›*)) then have "continuous_on (f ` T) g" by (meson ‹f ` T ⊆ S› continuous_on_subset (*‹⟦continuous_on ?s ?f; ?t ⊆ ?s⟧ ⟹ continuous_on ?t ?f›*) homeomorphism_def (*‹homeomorphism ?S ?T ?f ?g = ((∀x∈?S. ?g (?f x) = x) ∧ ?f ` ?S = ?T ∧ continuous_on ?S ?f ∧ (∀y∈?T. ?f (?g y) = y) ∧ ?g ` ?T = ?S ∧ continuous_on ?T ?g)›*)) then have contgf: "continuous_on T (g ∘ f)" by (metis continuous_on_compose (*‹⟦continuous_on (?s::?'a::topological_space set) (?f::?'a::topological_space ⇒ ?'b::topological_space); continuous_on (?f ` ?s) (?g::?'b::topological_space ⇒ ?'c::topological_space)⟧ ⟹ continuous_on ?s (?g ∘ ?f)›*) contf (*‹continuous_on (T::'a::euclidean_space set) (f::'a::euclidean_space ⇒ 'b::euclidean_space)›*)) have gfTC: "(g ∘ f) ` T ⊆ C" proof (-) (*goal: ‹(g ∘ f) ` T ⊆ C›*) have "g ` S = S'" by (metis (no_types) ‹homeomorphism S S' g h› homeomorphism_def (*‹homeomorphism ?S ?T ?f ?g = ((∀x∈?S. ?g (?f x) = x) ∧ ?f ` ?S = ?T ∧ continuous_on ?S ?f ∧ (∀y∈?T. ?f (?g y) = y) ∧ ?g ` ?T = ?S ∧ continuous_on ?T ?g)›*)) with ‹S' ⊆ C› (*‹S' ⊆ C›*) ‹f ` T ⊆ S› (*‹f ` T ⊆ S›*) show "?thesis" (*goal: ‹(g ∘ f) ` T ⊆ C›*) by force qed obtain f' where f': "continuous_on U f'" "f' ` U ⊆ C" "⋀x. x ∈ T ⟹ f' x = (g ∘ f) x" (*goal: ‹(⋀f'. ⟦continuous_on U f'; f' ` U ⊆ C; ⋀x. x ∈ T ⟹ f' x = (g ∘ f) x⟧ ⟹ thesis) ⟹ thesis›*) by (metis Dugundji [OF C cloUT contgf gfTC] (*‹(⋀ga. ⟦continuous_on U ga; ga ` U ⊆ C; ⋀x. x ∈ T ⟹ ga x = (g ∘ f) x⟧ ⟹ ?thesis) ⟹ ?thesis›*)) show "?thesis" (*goal: ‹thesis›*) proof (rule_tac g = "h ∘ r ∘ f'" in that (*‹⟦continuous_on U ?g; ?g ` U ⊆ S; ⋀x. x ∈ T ⟹ ?g x = f x⟧ ⟹ thesis›*)) (*goals: 1. ‹continuous_on U (h ∘ r ∘ f')› 2. ‹(h ∘ r ∘ f') ` U ⊆ S› 3. ‹⋀x. x ∈ T ⟹ (h ∘ r ∘ f') x = f x›*) show "continuous_on U (h ∘ r ∘ f')" proof (intro continuous_on_compose (*‹⟦continuous_on ?s ?f; continuous_on (?f ` ?s) ?g⟧ ⟹ continuous_on ?s (?g ∘ ?f)›*) f' (*‹continuous_on U f'› ‹f' ` U ⊆ C› ‹?x ∈ T ⟹ f' ?x = (g ∘ f) ?x›*)) (*goals: 1. ‹continuous_on (f' ` U) r› 2. ‹continuous_on (r ` f' ` U) h›*) show "continuous_on (f' ` U) r" using continuous_on_subset (*‹⟦continuous_on (?s::?'a::topological_space set) (?f::?'a::topological_space ⇒ ?'b::topological_space); (?t::?'a::topological_space set) ⊆ ?s⟧ ⟹ continuous_on ?t ?f›*) contr (*‹continuous_on (C::('b × real) set) (r::'b × real ⇒ 'b × real)›*) f' (*‹continuous_on U f'› ‹f' ` U ⊆ C› ‹(?x::'a::euclidean_space) ∈ (T::'a::euclidean_space set) ⟹ (f'::'a::euclidean_space ⇒ 'b::euclidean_space × real) ?x = ((g::'b::euclidean_space ⇒ 'b::euclidean_space × real) ∘ (f::'a::euclidean_space ⇒ 'b::euclidean_space)) ?x›*) by blast show "continuous_on (r ` f' ` U) h" using ‹homeomorphism S S' g h› (*‹homeomorphism S S' g h›*) ‹f' ` U ⊆ C› (*‹f' ` U ⊆ C›*) unfolding homeomorphism_def (*goal: ‹continuous_on (r ` f' ` U) h›*) by (metis ‹r ` C ⊆ S'› continuous_on_subset (*‹⟦continuous_on ?s ?f; ?t ⊆ ?s⟧ ⟹ continuous_on ?t ?f›*) image_mono (*‹?A ⊆ ?B ⟹ ?f ` ?A ⊆ ?f ` ?B›*)) qed show "(h ∘ r ∘ f') ` U ⊆ S" using ‹homeomorphism S S' g h› (*‹homeomorphism (S::'b set) (S'::('b × real) set) (g::'b ⇒ 'b × real) (h::'b × real ⇒ 'b)›*) ‹r ` C ⊆ S'› (*‹r ` C ⊆ S'›*) ‹f' ` U ⊆ C› (*‹f' ` U ⊆ C›*) by (fastforce simp: homeomorphism_def (*‹homeomorphism ?S ?T ?f ?g = ((∀x∈?S. ?g (?f x) = x) ∧ ?f ` ?S = ?T ∧ continuous_on ?S ?f ∧ (∀y∈?T. ?f (?g y) = y) ∧ ?g ` ?T = ?S ∧ continuous_on ?T ?g)›*)) show "⋀x. x ∈ T ⟹ (h ∘ r ∘ f') x = f x" using ‹homeomorphism S S' g h› (*‹homeomorphism S S' g h›*) ‹f ` T ⊆ S› (*‹f ` T ⊆ S›*) f' (*‹continuous_on (U::'a set) (f'::'a ⇒ 'b × real)› ‹f' ` U ⊆ C› ‹?x ∈ T ⟹ f' ?x = (g ∘ f) ?x›*) by (auto simp: rid (*‹(?x::'b × real) ∈ (S'::('b × real) set) ⟹ (r::'b × real ⇒ 'b × real) ?x = ?x›*) homeomorphism_def (*‹homeomorphism (?S::?'a set) (?T::?'b set) (?f::?'a ⇒ ?'b) (?g::?'b ⇒ ?'a) = ((∀x::?'a∈?S. ?g (?f x) = x) ∧ ?f ` ?S = ?T ∧ continuous_on ?S ?f ∧ (∀y::?'b∈?T. ?f (?g y) = y) ∧ ?g ` ?T = ?S ∧ continuous_on ?T ?g)›*)) qed qed lemma AR_imp_absolute_retract: fixes S :: "'a::euclidean_space set" and S' :: "'b::euclidean_space set" assumes "AR S" "S homeomorphic S'" and clo: "closedin (top_of_set U) S'" shows "S' retract_of U" proof (-) (*goal: ‹S' retract_of U›*) obtain g and h where hom: "homeomorphism S S' g h" (*goal: ‹(⋀(g::'a::euclidean_space ⇒ 'b::euclidean_space) h::'b::euclidean_space ⇒ 'a::euclidean_space. homeomorphism (S::'a::euclidean_space set) (S'::'b::euclidean_space set) g h ⟹ thesis::bool) ⟹ thesis›*) using assms (*‹AR S› ‹S homeomorphic S'› ‹closedin (top_of_set U) S'›*) by (force simp: homeomorphic_def (*‹?s homeomorphic ?t ≡ ∃f g. homeomorphism ?s ?t f g›*)) obtain h: "continuous_on S' h" " h ` S' ⊆ S" (*goal: ‹(⟦continuous_on S' h; h ` S' ⊆ S⟧ ⟹ thesis) ⟹ thesis›*) using hom (*‹homeomorphism (S::'a set) (S'::'b set) (g::'a ⇒ 'b) (h::'b ⇒ 'a)›*) homeomorphism_def (*‹homeomorphism ?S ?T ?f ?g = ((∀x∈?S. ?g (?f x) = x) ∧ ?f ` ?S = ?T ∧ continuous_on ?S ?f ∧ (∀y∈?T. ?f (?g y) = y) ∧ ?g ` ?T = ?S ∧ continuous_on ?T ?g)›*) by blast obtain h' where h': "continuous_on U h'" "h' ` U ⊆ S" and h'h: "⋀x. x ∈ S' ⟹ h' x = h x" (*goal: ‹(⋀h'. ⟦continuous_on U h'; h' ` U ⊆ S; ⋀x. x ∈ S' ⟹ h' x = h x⟧ ⟹ thesis) ⟹ thesis›*) by (blast intro: AR_imp_absolute_extensor [OF ‹AR S› h clo] (*‹(⋀g::'b ⇒ 'a. ⟦continuous_on (U::'b set) g; g ` U ⊆ (S::'a set); ⋀x::'b. x ∈ (S'::'b set) ⟹ g x = (h::'b ⇒ 'a) x⟧ ⟹ ?thesis::bool) ⟹ ?thesis›*)) have [simp]: "S' ⊆ U" using clo (*‹closedin (top_of_set U) S'›*) closedin_limpt (*‹closedin (top_of_set ?T) ?S = (?S ⊆ ?T ∧ (∀x. x islimpt ?S ∧ x ∈ ?T ⟶ x ∈ ?S))›*) by blast show "?thesis" (*goal: ‹S' retract_of U›*) proof (simp add: retraction_def (*‹retraction (?S::?'a set) (?T::?'a set) (?r::?'a ⇒ ?'a) = (?T ⊆ ?S ∧ continuous_on ?S ?r ∧ ?r ∈ ?S → ?T ∧ (∀x::?'a∈?T. ?r x = x))›*) retract_of_def (*‹((?T::?'a set) retract_of (?S::?'a set)) = (∃r::?'a ⇒ ?'a. retraction ?S ?T r)›*), intro exI (*‹?P ?x ⟹ ∃x. ?P x›*) conjI (*‹⟦?P; ?Q⟧ ⟹ ?P ∧ ?Q›*)) (*goals: 1. ‹continuous_on U ?r3› 2. ‹?r3 ∈ U → S'› 3. ‹∀x∈S'. ?r3 x = x›*) show "continuous_on U (g ∘ h')" by (meson continuous_on_compose (*‹⟦continuous_on ?s ?f; continuous_on (?f ` ?s) ?g⟧ ⟹ continuous_on ?s (?g ∘ ?f)›*) continuous_on_subset (*‹⟦continuous_on ?s ?f; ?t ⊆ ?s⟧ ⟹ continuous_on ?t ?f›*) h' (*‹continuous_on U h'› ‹h' ` U ⊆ S›*) hom (*‹homeomorphism S S' g h›*) homeomorphism_cont1 (*‹homeomorphism ?S ?T ?f ?g ⟹ continuous_on ?S ?f›*)) show "(g ∘ h') ∈ U → S'" using h' (*‹continuous_on U h'› ‹(h'::'b ⇒ 'a) ` (U::'b set) ⊆ (S::'a set)›*) apply clarsimp (*goal: ‹g ∘ h' ∈ U → S'›*) by (metis hom (*‹homeomorphism S S' g h›*) subsetD (*‹⟦?A ⊆ ?B; ?c ∈ ?A⟧ ⟹ ?c ∈ ?B›*) homeomorphism_def (*‹homeomorphism ?S ?T ?f ?g = ((∀x∈?S. ?g (?f x) = x) ∧ ?f ` ?S = ?T ∧ continuous_on ?S ?f ∧ (∀y∈?T. ?f (?g y) = y) ∧ ?g ` ?T = ?S ∧ continuous_on ?T ?g)›*) imageI (*‹?x ∈ ?A ⟹ ?f ?x ∈ ?f ` ?A›*)) show "∀x∈S'. (g ∘ h') x = x" apply clarsimp (*goal: ‹∀x::'b∈S'::'b set. ((g::'a ⇒ 'b) ∘ (h'::'b ⇒ 'a)) x = x›*) by (metis h'h (*‹?x ∈ S' ⟹ h' ?x = h ?x›*) hom (*‹homeomorphism S S' g h›*) homeomorphism_def (*‹homeomorphism ?S ?T ?f ?g = ((∀x∈?S. ?g (?f x) = x) ∧ ?f ` ?S = ?T ∧ continuous_on ?S ?f ∧ (∀y∈?T. ?f (?g y) = y) ∧ ?g ` ?T = ?S ∧ continuous_on ?T ?g)›*)) qed qed lemma AR_imp_absolute_retract_UNIV: fixes S :: "'a::euclidean_space set" and S' :: "'b::euclidean_space set" assumes "AR S" "S homeomorphic S'" "closed S'" shows "S' retract_of UNIV" using AR_imp_absolute_retract (*‹⟦AR ?S; ?S homeomorphic ?S'; closedin (top_of_set ?U) ?S'⟧ ⟹ ?S' retract_of ?U›*) assms (*‹AR (S::'a::euclidean_space set)› ‹S homeomorphic S'› ‹closed (S'::'b set)›*) by fastforce lemma absolute_extensor_imp_AR: fixes S :: "'a::euclidean_space set" assumes "⋀f :: 'a * real ⇒ 'a. ⋀U T. ⟦continuous_on T f; f ` T ⊆ S; closedin (top_of_set U) T⟧ ⟹ ∃g. continuous_on U g ∧ g ` U ⊆ S ∧ (∀x ∈ T. g x = f x)" shows "AR S" proof (clarsimp simp: AR_def (*‹AR ?S ≡ ∀U S'. ?S homeomorphic S' ∧ closedin (top_of_set U) S' ⟶ S' retract_of U›*)) (*goal: ‹⋀U S'. ⟦S homeomorphic S'; closedin (top_of_set U) S'⟧ ⟹ S' retract_of U›*) fix U and T :: "('a * real) set" assume "S homeomorphic T" and clo: "closedin (top_of_set U) T" (*‹(S::'a set) homeomorphic (T::('a × real) set)› ‹closedin (top_of_set (U::('a × real) set)) (T::('a × real) set)›*) then obtain g and h where hom: "homeomorphism S T g h" (*goal: ‹(⋀g h. homeomorphism S T g h ⟹ thesis) ⟹ thesis›*) by (force simp: homeomorphic_def (*‹(?s::?'a set) homeomorphic (?t::?'b set) ≡ ∃(f::?'a ⇒ ?'b) g::?'b ⇒ ?'a. homeomorphism ?s ?t f g›*)) obtain h: "continuous_on T h" " h ` T ⊆ S" (*goal: ‹(⟦continuous_on T h; h ` T ⊆ S⟧ ⟹ thesis) ⟹ thesis›*) using hom (*‹homeomorphism S T g h›*) homeomorphism_def (*‹homeomorphism ?S ?T ?f ?g = ((∀x∈?S. ?g (?f x) = x) ∧ ?f ` ?S = ?T ∧ continuous_on ?S ?f ∧ (∀y∈?T. ?f (?g y) = y) ∧ ?g ` ?T = ?S ∧ continuous_on ?T ?g)›*) by blast obtain h' where h': "continuous_on U h'" "h' ` U ⊆ S" and h'h: "∀x∈T. h' x = h x" (*goal: ‹(⋀h'. ⟦continuous_on U h'; h' ` U ⊆ S; ∀x∈T. h' x = h x⟧ ⟹ thesis) ⟹ thesis›*) using assms[OF h clo] (*‹∃g. continuous_on U g ∧ g ` U ⊆ S ∧ (∀x∈T. g x = h x)›*) by blast have [simp]: "T ⊆ U" using clo (*‹closedin (top_of_set U) T›*) closedin_imp_subset (*‹closedin (subtopology (?U::?'a::type topology) (?S::?'a::type set)) (?T::?'a::type set) ⟹ ?T ⊆ ?S›*) by auto show "T retract_of U" proof (simp add: retraction_def (*‹retraction ?S ?T ?r = (?T ⊆ ?S ∧ continuous_on ?S ?r ∧ ?r ∈ ?S → ?T ∧ (∀x∈?T. ?r x = x))›*) retract_of_def (*‹(?T retract_of ?S) = (∃r. retraction ?S ?T r)›*), intro exI (*‹(?P::?'a ⇒ bool) (?x::?'a) ⟹ ∃x::?'a. ?P x›*) conjI (*‹⟦?P::bool; ?Q::bool⟧ ⟹ ?P ∧ ?Q›*)) (*goals: 1. ‹continuous_on (U::('a × real) set) (?r3::'a × real ⇒ 'a × real)› 2. ‹(?r3::'a × real ⇒ 'a × real) ∈ (U::('a × real) set) → (T::('a × real) set)› 3. ‹∀x::'a × real∈T::('a × real) set. (?r3::'a × real ⇒ 'a × real) x = x›*) show "continuous_on U (g ∘ h')" by (meson continuous_on_compose (*‹⟦continuous_on ?s ?f; continuous_on (?f ` ?s) ?g⟧ ⟹ continuous_on ?s (?g ∘ ?f)›*) continuous_on_subset (*‹⟦continuous_on ?s ?f; ?t ⊆ ?s⟧ ⟹ continuous_on ?t ?f›*) h' (*‹continuous_on U h'› ‹h' ` U ⊆ S›*) hom (*‹homeomorphism S T g h›*) homeomorphism_cont1 (*‹homeomorphism ?S ?T ?f ?g ⟹ continuous_on ?S ?f›*)) show "(g ∘ h') ∈ U → T" using h' (*‹continuous_on U h'› ‹h' ` U ⊆ S›*) apply clarsimp (*goal: ‹(g::'a ⇒ 'a × real) ∘ (h'::'a × real ⇒ 'a) ∈ (U::('a × real) set) → (T::('a × real) set)›*) by (metis hom (*‹homeomorphism S T g h›*) subsetD (*‹⟦?A ⊆ ?B; ?c ∈ ?A⟧ ⟹ ?c ∈ ?B›*) homeomorphism_def (*‹homeomorphism ?S ?T ?f ?g = ((∀x∈?S. ?g (?f x) = x) ∧ ?f ` ?S = ?T ∧ continuous_on ?S ?f ∧ (∀y∈?T. ?f (?g y) = y) ∧ ?g ` ?T = ?S ∧ continuous_on ?T ?g)›*) imageI (*‹?x ∈ ?A ⟹ ?f ?x ∈ ?f ` ?A›*)) show "∀x∈T. (g ∘ h') x = x" apply clarsimp (*goal: ‹∀x∈T. (g ∘ h') x = x›*) by (metis h'h (*‹∀x∈T. h' x = h x›*) hom (*‹homeomorphism S T g h›*) homeomorphism_def (*‹homeomorphism ?S ?T ?f ?g = ((∀x∈?S. ?g (?f x) = x) ∧ ?f ` ?S = ?T ∧ continuous_on ?S ?f ∧ (∀y∈?T. ?f (?g y) = y) ∧ ?g ` ?T = ?S ∧ continuous_on ?T ?g)›*)) qed qed lemma AR_eq_absolute_extensor: fixes S :: "'a::euclidean_space set" shows "AR S ⟷ (∀f :: 'a * real ⇒ 'a. ∀U T. continuous_on T f ⟶ f ` T ⊆ S ⟶ closedin (top_of_set U) T ⟶ (∃g. continuous_on U g ∧ g ` U ⊆ S ∧ (∀x ∈ T. g x = f x)))" by (metis (mono_tags, opaque_lifting) AR_imp_absolute_extensor (*‹⟦AR ?S; continuous_on ?T ?f; ?f ` ?T ⊆ ?S; closedin (top_of_set ?U) ?T; ⋀g. ⟦continuous_on ?U g; g ` ?U ⊆ ?S; ⋀x. x ∈ ?T ⟹ g x = ?f x⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*) absolute_extensor_imp_AR (*‹(⋀f U T. ⟦continuous_on T f; f ` T ⊆ ?S; closedin (top_of_set U) T⟧ ⟹ ∃g. continuous_on U g ∧ g ` U ⊆ ?S ∧ (∀x∈T. g x = f x)) ⟹ AR ?S›*)) lemma AR_imp_retract: fixes S :: "'a::euclidean_space set" assumes "AR S ∧ closedin (top_of_set U) S" shows "S retract_of U" using AR_imp_absolute_retract (*‹⟦AR ?S; ?S homeomorphic ?S'; closedin (top_of_set ?U) ?S'⟧ ⟹ ?S' retract_of ?U›*) assms (*‹AR S ∧ closedin (top_of_set U) S›*) homeomorphic_refl (*‹?S homeomorphic ?S›*) by blast lemma AR_homeomorphic_AR: fixes S :: "'a::euclidean_space set" and T :: "'b::euclidean_space set" assumes "AR T" "S homeomorphic T" shows "AR S" unfolding AR_def (*goal: ‹∀U S'. S homeomorphic S' ∧ closedin (top_of_set U) S' ⟶ S' retract_of U›*) by (metis assms (*‹AR T› ‹S homeomorphic T›*) AR_imp_absolute_retract (*‹⟦AR ?S; ?S homeomorphic ?S'; closedin (top_of_set ?U) ?S'⟧ ⟹ ?S' retract_of ?U›*) homeomorphic_trans [of _ S] (*‹⟦?S homeomorphic S; S homeomorphic ?U⟧ ⟹ ?S homeomorphic ?U›*) homeomorphic_sym (*‹?S homeomorphic ?T = ?T homeomorphic ?S›*)) lemma homeomorphic_AR_iff_AR: fixes S :: "'a::euclidean_space set" and T :: "'b::euclidean_space set" shows "S homeomorphic T ⟹ AR S ⟷ AR T" by (metis AR_homeomorphic_AR (*‹⟦AR ?T; ?S homeomorphic ?T⟧ ⟹ AR ?S›*) homeomorphic_sym (*‹?S homeomorphic ?T = ?T homeomorphic ?S›*)) lemma ANR_imp_absolute_neighbourhood_extensor: fixes f :: "'a::euclidean_space ⇒ 'b::euclidean_space" assumes "ANR S" and contf: "continuous_on T f" and "f ∈ T → S" and cloUT: "closedin (top_of_set U) T" obtains V g where "T ⊆ V" "openin (top_of_set U) V" "continuous_on V g" "g ∈ V → S" "⋀x. x ∈ T ⟹ g x = f x" proof (-) (*goal: ‹(⋀V g. ⟦T ⊆ V; openin (top_of_set U) V; continuous_on V g; g ∈ V → S; ⋀x. x ∈ T ⟹ g x = f x⟧ ⟹ thesis) ⟹ thesis›*) have "aff_dim S < int (DIM('b × real))" using aff_dim_le_DIM[of S] (*‹aff_dim (S::'b set) ≤ int DIM('b)›*) by simp then obtain C and S' :: "('b * real) set" where C: "convex C" "C ≠ {}" and cloCS: "closedin (top_of_set C) S'" and hom: "S homeomorphic S'" (*goal: ‹(⋀(C::('b::euclidean_space × real) set) S'::('b::euclidean_space × real) set. ⟦convex C; C ≠ {}; closedin (top_of_set C) S'; (S::'b::euclidean_space set) homeomorphic S'⟧ ⟹ thesis::bool) ⟹ thesis›*) by (metis that (*‹⟦convex ?C; ?C ≠ {}; closedin (top_of_set ?C) ?S'; S homeomorphic ?S'⟧ ⟹ thesis›*) homeomorphic_closedin_convex (*‹⟦aff_dim ?S < int DIM(?'n); ⋀U T. ⟦convex U; U ≠ {}; closedin (top_of_set U) T; ?S homeomorphic T⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*)) then obtain D where opD: "openin (top_of_set C) D" and "S' retract_of D" (*goal: ‹(⋀D. ⟦openin (top_of_set C) D; S' retract_of D⟧ ⟹ thesis) ⟹ thesis›*) using ‹ANR S› (*‹ANR (S::'b::euclidean_space set)›*) by (auto simp: ANR_def (*‹ANR ?S ≡ ∀U S'. ?S homeomorphic S' ∧ closedin (top_of_set U) S' ⟶ (∃T. openin (top_of_set U) T ∧ S' retract_of T)›*)) then obtain r where "S' ⊆ D" and contr: "continuous_on D r" and "r ` D ⊆ S'" and rid: "⋀x. x ∈ S' ⟹ r x = x" (*goal: ‹(⋀r::'b × real ⇒ 'b × real. ⟦(S'::('b × real) set) ⊆ (D::('b × real) set); continuous_on D r; r ` D ⊆ S'; ⋀x::'b × real. x ∈ S' ⟹ r x = x⟧ ⟹ thesis::bool) ⟹ thesis›*) by (auto simp: retraction_def (*‹retraction ?S ?T ?r = (?T ⊆ ?S ∧ continuous_on ?S ?r ∧ ?r ∈ ?S → ?T ∧ (∀x∈?T. ?r x = x))›*) retract_of_def (*‹(?T retract_of ?S) = (∃r. retraction ?S ?T r)›*)) obtain g and h where homgh: "homeomorphism S S' g h" (*goal: ‹(⋀g h. homeomorphism S S' g h ⟹ thesis) ⟹ thesis›*) using hom (*‹S homeomorphic S'›*) by (force simp: homeomorphic_def (*‹?s homeomorphic ?t ≡ ∃f g. homeomorphism ?s ?t f g›*)) have "continuous_on (f ` T) g" by (metis PiE (*‹⟦?f ∈ Pi ?A ?B; ?f ?x ∈ ?B ?x ⟹ ?Q; ?x ∉ ?A ⟹ ?Q⟧ ⟹ ?Q›*) assms( (*‹f ∈ T → S›*) 3) continuous_on_subset (*‹⟦continuous_on ?s ?f; ?t ⊆ ?s⟧ ⟹ continuous_on ?t ?f›*) homeomorphism_cont1 (*‹homeomorphism ?S ?T ?f ?g ⟹ continuous_on ?S ?f›*) homgh (*‹homeomorphism S S' g h›*) image_subset_iff (*‹(?f ` ?A ⊆ ?B) = (∀x∈?A. ?f x ∈ ?B)›*)) then have contgf: "continuous_on T (g ∘ f)" by (intro continuous_on_compose (*‹⟦continuous_on ?s ?f; continuous_on (?f ` ?s) ?g⟧ ⟹ continuous_on ?s (?g ∘ ?f)›*) contf (*‹continuous_on T f›*)) have gfTC: "(g ∘ f) ` T ⊆ C" proof (-) (*goal: ‹(g ∘ f) ` T ⊆ C›*) have "g ` S = S'" by (metis (no_types) homeomorphism_def (*‹homeomorphism ?S ?T ?f ?g = ((∀x∈?S. ?g (?f x) = x) ∧ ?f ` ?S = ?T ∧ continuous_on ?S ?f ∧ (∀y∈?T. ?f (?g y) = y) ∧ ?g ` ?T = ?S ∧ continuous_on ?T ?g)›*) homgh (*‹homeomorphism S S' g h›*)) then show "?thesis" (*goal: ‹(g ∘ f) ` T ⊆ C›*) by (metis PiE (*‹⟦(?f::?'a ⇒ ?'b) ∈ Pi (?A::?'a set) (?B::?'a ⇒ ?'b set); ?f (?x::?'a) ∈ ?B ?x ⟹ ?Q::bool; ?x ∉ ?A ⟹ ?Q⟧ ⟹ ?Q›*) assms( (*‹(f::'a ⇒ 'b) ∈ (T::'a set) → (S::'b set)›*) 3) cloCS (*‹closedin (top_of_set (C::('b × real) set)) (S'::('b × real) set)›*) closedin_def (*‹closedin (?U::?'a topology) (?S::?'a set) = (?S ⊆ topspace ?U ∧ openin ?U (topspace ?U - ?S))›*) image_comp (*‹(?f::?'b ⇒ ?'a) ` (?g::?'c ⇒ ?'b) ` (?r::?'c set) = (?f ∘ ?g) ` ?r›*) image_mono (*‹(?A::?'a set) ⊆ (?B::?'a set) ⟹ (?f::?'a ⇒ ?'b) ` ?A ⊆ ?f ` ?B›*) image_subset_iff (*‹((?f::?'b ⇒ ?'a) ` (?A::?'b set) ⊆ (?B::?'a set)) = (∀x::?'b∈?A. ?f x ∈ ?B)›*) order.trans (*‹⟦(?a::?'a) ≤ (?b::?'a); ?b ≤ (?c::?'a)⟧ ⟹ ?a ≤ ?c›*) topspace_euclidean_subtopology (*‹topspace (top_of_set (?S::?'a set)) = ?S›*)) qed obtain f' where contf': "continuous_on U f'" and "f' ` U ⊆ C" and eq: "⋀x. x ∈ T ⟹ f' x = (g ∘ f) x" (*goal: ‹(⋀f'. ⟦continuous_on U f'; f' ` U ⊆ C; ⋀x. x ∈ T ⟹ f' x = (g ∘ f) x⟧ ⟹ thesis) ⟹ thesis›*) by (metis Dugundji [OF C cloUT contgf gfTC] (*‹(⋀ga. ⟦continuous_on U ga; ga ` U ⊆ C; ⋀x. x ∈ T ⟹ ga x = (g ∘ f) x⟧ ⟹ ?thesis) ⟹ ?thesis›*)) show "?thesis" (*goal: ‹thesis›*) proof (rule_tac V = "U ∩ f' -` D" and g = "h ∘ r ∘ f'" in that (*‹⟦T ⊆ ?V; openin (top_of_set U) ?V; continuous_on ?V ?g; ?g ∈ ?V → S; ⋀x. x ∈ T ⟹ ?g x = f x⟧ ⟹ thesis›*)) (*goals: 1. ‹T ⊆ U ∩ f' -` D› 2. ‹openin (top_of_set U) (U ∩ f' -` D)› 3. ‹continuous_on (U ∩ f' -` D) (h ∘ r ∘ f')› 4. ‹h ∘ r ∘ f' ∈ U ∩ f' -` D → S› 5. ‹⋀x. x ∈ T ⟹ (h ∘ r ∘ f') x = f x›*) show "T ⊆ U ∩ f' -` D" using cloUT (*‹closedin (top_of_set U) T›*) closedin_imp_subset (*‹closedin (subtopology ?U ?S) ?T ⟹ ?T ⊆ ?S›*) ‹S' ⊆ D› (*‹S' ⊆ D›*) ‹f ∈ T → S› (*‹(f::'a ⇒ 'b) ∈ (T::'a set) → (S::'b set)›*) eq (*‹?x ∈ T ⟹ f' ?x = (g ∘ f) ?x›*) homeomorphism_image1 (*‹homeomorphism ?S ?T ?f ?g ⟹ ?f ` ?S = ?T›*) homgh (*‹homeomorphism (S::'b set) (S'::('b × real) set) (g::'b ⇒ 'b × real) (h::'b × real ⇒ 'b)›*) by fastforce show ope: "openin (top_of_set U) (U ∩ f' -` D)" by (meson ‹f' ` U ⊆ C› contf' (*‹continuous_on U f'›*) continuous_openin_preimage (*‹⟦continuous_on ?S ?f; ?f ∈ ?S → ?T; openin (top_of_set ?T) ?U⟧ ⟹ openin (top_of_set ?S) (?S ∩ ?f -` ?U)›*) image_subset_iff_funcset (*‹(?F ` ?A ⊆ ?B) = (?F ∈ ?A → ?B)›*) opD (*‹openin (top_of_set C) D›*)) have conth: "continuous_on (r ` f' ` (U ∩ f' -` D)) h" proof (rule continuous_on_subset [of S'] (*‹⟦continuous_on S' ?f; ?t ⊆ S'⟧ ⟹ continuous_on ?t ?f›*)) (*goals: 1. ‹continuous_on S' h› 2. ‹r ` f' ` (U ∩ f' -` D) ⊆ S'›*) show "continuous_on S' h" using homeomorphism_def (*‹homeomorphism ?S ?T ?f ?g = ((∀x∈?S. ?g (?f x) = x) ∧ ?f ` ?S = ?T ∧ continuous_on ?S ?f ∧ (∀y∈?T. ?f (?g y) = y) ∧ ?g ` ?T = ?S ∧ continuous_on ?T ?g)›*) homgh (*‹homeomorphism S S' g h›*) by blast qed (use ‹r ` D ⊆ S'› in blast) (*solved the remaining goal: ‹(r::'b::euclidean_space × real ⇒ 'b::euclidean_space × real) ` (f'::'a::euclidean_space ⇒ 'b::euclidean_space × real) ` ((U::'a::euclidean_space set) ∩ f' -` (D::('b::euclidean_space × real) set)) ⊆ (S'::('b::euclidean_space × real) set)›*) show "continuous_on (U ∩ f' -` D) (h ∘ r ∘ f')" by (blast intro: continuous_on_compose (*‹⟦continuous_on ?s ?f; continuous_on (?f ` ?s) ?g⟧ ⟹ continuous_on ?s (?g ∘ ?f)›*) conth (*‹continuous_on (r ` f' ` (U ∩ f' -` D)) h›*) continuous_on_subset [OF contr] (*‹?t ⊆ D ⟹ continuous_on ?t r›*) continuous_on_subset [OF contf'] (*‹?t ⊆ U ⟹ continuous_on ?t f'›*)) show "(h ∘ r ∘ f') ∈ (U ∩ f' -` D) → S" using ‹homeomorphism S S' g h› (*‹homeomorphism S S' g h›*) ‹f' ` U ⊆ C› (*‹f' ` U ⊆ C›*) ‹r ` D ⊆ S'› (*‹(r::'b × real ⇒ 'b × real) ` (D::('b × real) set) ⊆ (S'::('b × real) set)›*) by (auto simp: homeomorphism_def (*‹homeomorphism ?S ?T ?f ?g = ((∀x∈?S. ?g (?f x) = x) ∧ ?f ` ?S = ?T ∧ continuous_on ?S ?f ∧ (∀y∈?T. ?f (?g y) = y) ∧ ?g ` ?T = ?S ∧ continuous_on ?T ?g)›*)) show "⋀x. x ∈ T ⟹ (h ∘ r ∘ f') x = f x" using ‹homeomorphism S S' g h› (*‹homeomorphism S S' g h›*) ‹f ∈ T → S› (*‹f ∈ T → S›*) eq (*‹?x ∈ T ⟹ f' ?x = (g ∘ f) ?x›*) by (metis PiE (*‹⟦?f ∈ Pi ?A ?B; ?f ?x ∈ ?B ?x ⟹ ?Q; ?x ∉ ?A ⟹ ?Q⟧ ⟹ ?Q›*) comp_apply (*‹(?f ∘ ?g) ?x = ?f (?g ?x)›*) homeomorphism_def (*‹homeomorphism ?S ?T ?f ?g = ((∀x∈?S. ?g (?f x) = x) ∧ ?f ` ?S = ?T ∧ continuous_on ?S ?f ∧ (∀y∈?T. ?f (?g y) = y) ∧ ?g ` ?T = ?S ∧ continuous_on ?T ?g)›*) image_iff (*‹(?z ∈ ?f ` ?A) = (∃x∈?A. ?z = ?f x)›*) rid (*‹?x ∈ S' ⟹ r ?x = ?x›*)) qed qed corollary ANR_imp_absolute_neighbourhood_retract: fixes S :: "'a::euclidean_space set" and S' :: "'b::euclidean_space set" assumes "ANR S" "S homeomorphic S'" and clo: "closedin (top_of_set U) S'" obtains V where "openin (top_of_set U) V" "S' retract_of V" proof (-) (*goal: ‹(⋀V::'b set. ⟦openin (top_of_set (U::'b set)) V; (S'::'b set) retract_of V⟧ ⟹ thesis::bool) ⟹ thesis›*) obtain g and h where hom: "homeomorphism S S' g h" (*goal: ‹(⋀g h. homeomorphism S S' g h ⟹ thesis) ⟹ thesis›*) using assms (*‹ANR S› ‹S homeomorphic S'› ‹closedin (top_of_set U) S'›*) by (force simp: homeomorphic_def (*‹?s homeomorphic ?t ≡ ∃f g. homeomorphism ?s ?t f g›*)) obtain h: "continuous_on S' h" " h ∈ S' → S" (*goal: ‹(⟦continuous_on S' h; h ∈ S' → S⟧ ⟹ thesis) ⟹ thesis›*) using hom (*‹homeomorphism (S::'a::euclidean_space set) (S'::'b::euclidean_space set) (g::'a::euclidean_space ⇒ 'b::euclidean_space) (h::'b::euclidean_space ⇒ 'a::euclidean_space)›*) homeomorphism_def (*‹homeomorphism (?S::?'a::topological_space set) (?T::?'b::topological_space set) (?f::?'a::topological_space ⇒ ?'b::topological_space) (?g::?'b::topological_space ⇒ ?'a::topological_space) = ((∀x::?'a::topological_space∈?S. ?g (?f x) = x) ∧ ?f ` ?S = ?T ∧ continuous_on ?S ?f ∧ (∀y::?'b::topological_space∈?T. ?f (?g y) = y) ∧ ?g ` ?T = ?S ∧ continuous_on ?T ?g)›*) by blast from ANR_imp_absolute_neighbourhood_extensor[OF ‹ANR S› h clo] (*‹(⋀(V::'b set) g::'b ⇒ 'a. ⟦(S'::'b set) ⊆ V; openin (top_of_set (U::'b set)) V; continuous_on V g; g ∈ V → (S::'a set); ⋀x::'b. x ∈ S' ⟹ g x = (h::'b ⇒ 'a) x⟧ ⟹ ?thesis::bool) ⟹ ?thesis›*) obtain V and h' where "S' ⊆ V" and opUV: "openin (top_of_set U) V" and h': "continuous_on V h'" "h' ` V ⊆ S" and h'h: "⋀x. x ∈ S' ⟹ h' x = h x" (*goal: ‹(⋀V h'. ⟦S' ⊆ V; openin (top_of_set U) V; continuous_on V h'; h' ` V ⊆ S; ⋀x. x ∈ S' ⟹ h' x = h x⟧ ⟹ thesis) ⟹ thesis›*) by (blast intro: ANR_imp_absolute_neighbourhood_extensor [OF ‹ANR S› h clo] (*‹(⋀V g. ⟦S' ⊆ V; openin (top_of_set U) V; continuous_on V g; g ∈ V → S; ⋀x. x ∈ S' ⟹ g x = h x⟧ ⟹ ?thesis) ⟹ ?thesis›*)) have "S' retract_of V" proof (simp add: retraction_def (*‹retraction ?S ?T ?r = (?T ⊆ ?S ∧ continuous_on ?S ?r ∧ ?r ∈ ?S → ?T ∧ (∀x∈?T. ?r x = x))›*) retract_of_def (*‹(?T retract_of ?S) = (∃r. retraction ?S ?T r)›*), intro exI (*‹?P ?x ⟹ ∃x. ?P x›*) conjI (*‹⟦?P; ?Q⟧ ⟹ ?P ∧ ?Q›*) ‹S' ⊆ V›) (*goals: 1. ‹continuous_on V ?r6› 2. ‹?r6 ∈ V → S'› 3. ‹∀x∈S'. ?r6 x = x›*) show "continuous_on V (g ∘ h')" by (meson continuous_on_compose (*‹⟦continuous_on ?s ?f; continuous_on (?f ` ?s) ?g⟧ ⟹ continuous_on ?s (?g ∘ ?f)›*) continuous_on_subset (*‹⟦continuous_on ?s ?f; ?t ⊆ ?s⟧ ⟹ continuous_on ?t ?f›*) h'( (*‹continuous_on V h'›*) 1) h'( (*‹h' ` V ⊆ S›*) 2) hom (*‹homeomorphism S S' g h›*) homeomorphism_cont1 (*‹homeomorphism ?S ?T ?f ?g ⟹ continuous_on ?S ?f›*)) show "(g ∘ h') ∈ V → S'" using h' (*‹continuous_on V h'› ‹h' ` V ⊆ S›*) apply clarsimp (*goal: ‹g ∘ h' ∈ V → S'›*) by (metis hom (*‹homeomorphism (S::'a::euclidean_space set) (S'::'b::euclidean_space set) (g::'a::euclidean_space ⇒ 'b::euclidean_space) (h::'b::euclidean_space ⇒ 'a::euclidean_space)›*) subsetD (*‹⟦(?A::?'a::type set) ⊆ (?B::?'a::type set); (?c::?'a::type) ∈ ?A⟧ ⟹ ?c ∈ ?B›*) homeomorphism_def (*‹homeomorphism (?S::?'a::topological_space set) (?T::?'b::topological_space set) (?f::?'a::topological_space ⇒ ?'b::topological_space) (?g::?'b::topological_space ⇒ ?'a::topological_space) = ((∀x::?'a::topological_space∈?S. ?g (?f x) = x) ∧ ?f ` ?S = ?T ∧ continuous_on ?S ?f ∧ (∀y::?'b::topological_space∈?T. ?f (?g y) = y) ∧ ?g ` ?T = ?S ∧ continuous_on ?T ?g)›*) imageI (*‹(?x::?'a::type) ∈ (?A::?'a::type set) ⟹ (?f::?'a::type ⇒ ?'b::type) ?x ∈ ?f ` ?A›*)) show "∀x∈S'. (g ∘ h') x = x" apply clarsimp (*goal: ‹∀x::'b∈S'::'b set. ((g::'a ⇒ 'b) ∘ (h'::'b ⇒ 'a)) x = x›*) by (metis h'h (*‹(?x::'b) ∈ (S'::'b set) ⟹ (h'::'b ⇒ 'a) ?x = (h::'b ⇒ 'a) ?x›*) hom (*‹homeomorphism (S::'a set) (S'::'b set) (g::'a ⇒ 'b) (h::'b ⇒ 'a)›*) homeomorphism_def (*‹homeomorphism (?S::?'a set) (?T::?'b set) (?f::?'a ⇒ ?'b) (?g::?'b ⇒ ?'a) = ((∀x::?'a∈?S. ?g (?f x) = x) ∧ ?f ` ?S = ?T ∧ continuous_on ?S ?f ∧ (∀y::?'b∈?T. ?f (?g y) = y) ∧ ?g ` ?T = ?S ∧ continuous_on ?T ?g)›*)) qed then show "?thesis" (*goal: ‹thesis›*) by (rule that [OF opUV] (*‹(S'::'b::euclidean_space set) retract_of (V::'b::euclidean_space set) ⟹ thesis::bool›*)) qed corollary ANR_imp_absolute_neighbourhood_retract_UNIV: fixes S :: "'a::euclidean_space set" and S' :: "'b::euclidean_space set" assumes "ANR S" and hom: "S homeomorphic S'" and clo: "closed S'" obtains V where "open V" "S' retract_of V" using ANR_imp_absolute_neighbourhood_retract[OF ‹ANR S› hom] (*‹⟦closedin (top_of_set ?U) S'; ⋀V. ⟦openin (top_of_set ?U) V; S' retract_of V⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*) by (metis clo (*‹closed S'›*) closed_closedin (*‹closed ?S = closedin euclidean ?S›*) open_openin (*‹open ?S = openin euclidean ?S›*) subtopology_UNIV (*‹subtopology ?U UNIV = ?U›*)) corollary neighbourhood_extension_into_ANR: fixes f :: "'a::euclidean_space ⇒ 'b::euclidean_space" assumes contf: "continuous_on S f" and fim: "f ∈ S → T" and "ANR T" "closed S" obtains V g where "S ⊆ V" "open V" "continuous_on V g" "g ∈ V → T" "⋀x. x ∈ S ⟹ g x = f x" using ANR_imp_absolute_neighbourhood_extensor[OF ‹ANR T› contf fim] (*‹⟦closedin (top_of_set ?U) S; ⋀V g. ⟦S ⊆ V; openin (top_of_set ?U) V; continuous_on V g; g ∈ V → T; ⋀x. x ∈ S ⟹ g x = f x⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*) by (metis ‹closed S› closed_closedin (*‹closed ?S = closedin euclidean ?S›*) open_openin (*‹open ?S = openin euclidean ?S›*) subtopology_UNIV (*‹subtopology ?U UNIV = ?U›*)) lemma absolute_neighbourhood_extensor_imp_ANR: fixes S :: "'a::euclidean_space set" assumes "⋀f :: 'a * real ⇒ 'a. ⋀U T. ⟦continuous_on T f; f ∈ T → S; closedin (top_of_set U) T⟧ ⟹ ∃V g. T ⊆ V ∧ openin (top_of_set U) V ∧ continuous_on V g ∧ g ∈ V → S ∧ (∀x ∈ T. g x = f x)" shows "ANR S" proof (clarsimp simp: ANR_def (*‹ANR ?S ≡ ∀U S'. ?S homeomorphic S' ∧ closedin (top_of_set U) S' ⟶ (∃T. openin (top_of_set U) T ∧ S' retract_of T)›*)) (*goal: ‹⋀(U::('a × real) set) S'::('a × real) set. ⟦(S::'a set) homeomorphic S'; closedin (top_of_set U) S'⟧ ⟹ ∃T::('a × real) set. openin (top_of_set U) T ∧ S' retract_of T›*) fix U and T :: "('a * real) set" assume "S homeomorphic T" and clo: "closedin (top_of_set U) T" (*‹(S::'a set) homeomorphic (T::('a × real) set)› ‹closedin (top_of_set (U::('a × real) set)) (T::('a × real) set)›*) then obtain g and h where hom: "homeomorphism S T g h" (*goal: ‹(⋀g h. homeomorphism S T g h ⟹ thesis) ⟹ thesis›*) by (force simp: homeomorphic_def (*‹?s homeomorphic ?t ≡ ∃f g. homeomorphism ?s ?t f g›*)) obtain h: "continuous_on T h" " h ∈ T → S" (*goal: ‹(⟦continuous_on T h; h ∈ T → S⟧ ⟹ thesis) ⟹ thesis›*) using hom (*‹homeomorphism S T g h›*) homeomorphism_def (*‹homeomorphism ?S ?T ?f ?g = ((∀x∈?S. ?g (?f x) = x) ∧ ?f ` ?S = ?T ∧ continuous_on ?S ?f ∧ (∀y∈?T. ?f (?g y) = y) ∧ ?g ` ?T = ?S ∧ continuous_on ?T ?g)›*) by blast obtain V and h' where "T ⊆ V" and opV: "openin (top_of_set U) V" and h': "continuous_on V h'" "h' ∈ V → S" and h'h: "∀x∈T. h' x = h x" (*goal: ‹(⋀(V::('a::euclidean_space × real) set) h'::'a::euclidean_space × real ⇒ 'a::euclidean_space. ⟦(T::('a::euclidean_space × real) set) ⊆ V; openin (top_of_set (U::('a::euclidean_space × real) set)) V; continuous_on V h'; h' ∈ V → (S::'a::euclidean_space set); ∀x::'a::euclidean_space × real∈T. h' x = (h::'a::euclidean_space × real ⇒ 'a::euclidean_space) x⟧ ⟹ thesis::bool) ⟹ thesis›*) using assms[OF h clo] (*‹∃V g. T ⊆ V ∧ openin (top_of_set U) V ∧ continuous_on V g ∧ g ∈ V → S ∧ (∀x∈T. g x = h x)›*) by blast have [simp]: "T ⊆ U" using clo (*‹closedin (top_of_set U) T›*) closedin_imp_subset (*‹closedin (subtopology ?U ?S) ?T ⟹ ?T ⊆ ?S›*) by auto have "T retract_of V" proof (simp add: retraction_def (*‹retraction ?S ?T ?r = (?T ⊆ ?S ∧ continuous_on ?S ?r ∧ ?r ∈ ?S → ?T ∧ (∀x∈?T. ?r x = x))›*) retract_of_def (*‹(?T retract_of ?S) = (∃r. retraction ?S ?T r)›*), intro exI (*‹(?P::?'a ⇒ bool) (?x::?'a) ⟹ ∃x::?'a. ?P x›*) conjI (*‹⟦?P::bool; ?Q::bool⟧ ⟹ ?P ∧ ?Q›*) ‹T ⊆ V›) (*goals: 1. ‹continuous_on (V::('a × real) set) (?r6::'a × real ⇒ 'a × real)› 2. ‹(?r6::'a × real ⇒ 'a × real) ∈ (V::('a × real) set) → (T::('a × real) set)› 3. ‹∀x::'a × real∈T::('a × real) set. (?r6::'a × real ⇒ 'a × real) x = x›*) show "continuous_on V (g ∘ h')" by (meson continuous_on_compose (*‹⟦continuous_on ?s ?f; continuous_on (?f ` ?s) ?g⟧ ⟹ continuous_on ?s (?g ∘ ?f)›*) continuous_on_subset (*‹⟦continuous_on ?s ?f; ?t ⊆ ?s⟧ ⟹ continuous_on ?t ?f›*) h' (*‹continuous_on V h'› ‹h' ∈ V → S›*) hom (*‹homeomorphism S T g h›*) homeomorphism_def (*‹homeomorphism ?S ?T ?f ?g = ((∀x∈?S. ?g (?f x) = x) ∧ ?f ` ?S = ?T ∧ continuous_on ?S ?f ∧ (∀y∈?T. ?f (?g y) = y) ∧ ?g ` ?T = ?S ∧ continuous_on ?T ?g)›*) image_subset_iff_funcset (*‹(?F ` ?A ⊆ ?B) = (?F ∈ ?A → ?B)›*)) show "(g ∘ h') ∈ V → T" using h' (*‹continuous_on V h'› ‹(h'::'a × real ⇒ 'a) ∈ (V::('a × real) set) → (S::'a set)›*) hom (*‹homeomorphism S T g h›*) homeomorphism_image1 (*‹homeomorphism ?S ?T ?f ?g ⟹ ?f ` ?S = ?T›*) by fastforce show "∀x∈T. (g ∘ h') x = x" apply clarsimp (*goal: ‹∀x∈T. (g ∘ h') x = x›*) by (metis h'h (*‹∀x∈T. h' x = h x›*) hom (*‹homeomorphism S T g h›*) homeomorphism_def (*‹homeomorphism ?S ?T ?f ?g = ((∀x∈?S. ?g (?f x) = x) ∧ ?f ` ?S = ?T ∧ continuous_on ?S ?f ∧ (∀y∈?T. ?f (?g y) = y) ∧ ?g ` ?T = ?S ∧ continuous_on ?T ?g)›*)) qed then show "∃V. openin (top_of_set U) V ∧ T retract_of V" using opV (*‹openin (top_of_set U) V›*) by blast qed lemma ANR_eq_absolute_neighbourhood_extensor: fixes S :: "'a::euclidean_space set" shows "ANR S ⟷ (∀f :: 'a * real ⇒ 'a. ∀U T. continuous_on T f ⟶ f ∈ T → S ⟶ closedin (top_of_set U) T ⟶ (∃V g. T ⊆ V ∧ openin (top_of_set U) V ∧ continuous_on V g ∧ g ∈ V → S ∧ (∀x ∈ T. g x = f x)))" (is "_ = ?rhs") proof (standard) (*goals: 1. ‹ANR S ⟹ ∀f U T. continuous_on T f ⟶ f ∈ T → S ⟶ closedin (top_of_set U) T ⟶ (∃V g. T ⊆ V ∧ openin (top_of_set U) V ∧ continuous_on V g ∧ g ∈ V → S ∧ (∀x∈T. g x = f x))› 2. ‹∀f U T. continuous_on T f ⟶ f ∈ T → S ⟶ closedin (top_of_set U) T ⟶ (∃V g. T ⊆ V ∧ openin (top_of_set U) V ∧ continuous_on V g ∧ g ∈ V → S ∧ (∀x∈T. g x = f x)) ⟹ ANR S›*) assume "ANR S" (*‹ANR (S::'a set)›*) then show "?rhs" by (metis ANR_imp_absolute_neighbourhood_extensor (*‹⟦ANR ?S; continuous_on ?T ?f; ?f ∈ ?T → ?S; closedin (top_of_set ?U) ?T; ⋀V g. ⟦?T ⊆ V; openin (top_of_set ?U) V; continuous_on V g; g ∈ V → ?S; ⋀x. x ∈ ?T ⟹ g x = ?f x⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*)) qed (simp add: absolute_neighbourhood_extensor_imp_ANR (*‹(⋀f U T. ⟦continuous_on T f; f ∈ T → ?S; closedin (top_of_set U) T⟧ ⟹ ∃V g. T ⊆ V ∧ openin (top_of_set U) V ∧ continuous_on V g ∧ g ∈ V → ?S ∧ (∀x∈T. g x = f x)) ⟹ ANR ?S›*)) (*solved the remaining goal: ‹∀f U T. continuous_on T f ⟶ f ∈ T → S ⟶ closedin (top_of_set U) T ⟶ (∃V g. T ⊆ V ∧ openin (top_of_set U) V ∧ continuous_on V g ∧ g ∈ V → S ∧ (∀x∈T. g x = f x)) ⟹ ANR S›*) lemma ANR_imp_neighbourhood_retract: fixes S :: "'a::euclidean_space set" assumes "ANR S" "closedin (top_of_set U) S" obtains V where "openin (top_of_set U) V" "S retract_of V" using ANR_imp_absolute_neighbourhood_retract (*‹⟦ANR ?S; ?S homeomorphic ?S'; closedin (top_of_set ?U) ?S'; ⋀V. ⟦openin (top_of_set ?U) V; ?S' retract_of V⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*) assms (*‹ANR S› ‹closedin (top_of_set U) S›*) homeomorphic_refl (*‹?S homeomorphic ?S›*) by blast lemma ANR_imp_absolute_closed_neighbourhood_retract: fixes S :: "'a::euclidean_space set" and S' :: "'b::euclidean_space set" assumes "ANR S" "S homeomorphic S'" and US': "closedin (top_of_set U) S'" obtains V W where "openin (top_of_set U) V" "closedin (top_of_set U) W" "S' ⊆ V" "V ⊆ W" "S' retract_of W" proof (-) (*goal: ‹(⋀V W. ⟦openin (top_of_set U) V; closedin (top_of_set U) W; S' ⊆ V; V ⊆ W; S' retract_of W⟧ ⟹ thesis) ⟹ thesis›*) obtain Z where "openin (top_of_set U) Z" and S'Z: "S' retract_of Z" (*goal: ‹(⋀Z. ⟦openin (top_of_set U) Z; S' retract_of Z⟧ ⟹ thesis) ⟹ thesis›*) by (blast intro: assms (*‹ANR S› ‹S homeomorphic S'› ‹closedin (top_of_set U) S'›*) ANR_imp_absolute_neighbourhood_retract (*‹⟦ANR ?S; ?S homeomorphic ?S'; closedin (top_of_set ?U) ?S'; ⋀V. ⟦openin (top_of_set ?U) V; ?S' retract_of V⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*)) then have UUZ: "closedin (top_of_set U) (U - Z)" by auto have "S' ∩ (U - Z) = {}" using ‹S' retract_of Z› (*‹S' retract_of Z›*) closedin_retract (*‹?S retract_of ?T ⟹ closedin (top_of_set ?T) ?S›*) closedin_subtopology (*‹closedin (subtopology ?U ?V) ?S = (∃T. closedin ?U T ∧ ?S = T ∩ ?V)›*) by fastforce then obtain V and W where "openin (top_of_set U) V" and "openin (top_of_set U) W" and "S' ⊆ V" "U - Z ⊆ W" "V ∩ W = {}" (*goal: ‹(⋀V W. ⟦openin (top_of_set U) V; openin (top_of_set U) W; S' ⊆ V; U - Z ⊆ W; V ∩ W = {}⟧ ⟹ thesis) ⟹ thesis›*) using separation_normal_local[OF US' UUZ] (*‹⟦S' ∩ (U - Z) = {}; ⋀S'a T'. ⟦openin (top_of_set U) S'a; openin (top_of_set U) T'; S' ⊆ S'a; U - Z ⊆ T'; S'a ∩ T' = {}⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*) by auto moreover have "S' retract_of U - W" proof (rule retract_of_subset [OF S'Z] (*‹⟦S' ⊆ ?S'; ?S' ⊆ Z⟧ ⟹ S' retract_of ?S'›*)) (*goals: 1. ‹(S'::'b set) ⊆ (U::'b set) - (W::'b set)› 2. ‹(U::'b set) - (W::'b set) ⊆ (Z::'b set)›*) show "S' ⊆ U - W" using US' (*‹closedin (top_of_set U) S'›*) ‹S' ⊆ V› (*‹S' ⊆ V›*) ‹V ∩ W = {}› (*‹V ∩ W = {}›*) closedin_subset (*‹closedin ?U ?S ⟹ ?S ⊆ topspace ?U›*) by fastforce show "U - W ⊆ Z" using Diff_subset_conv (*‹(?A - ?B ⊆ ?C) = (?A ⊆ ?B ∪ ?C)›*) ‹U - Z ⊆ W› (*‹(U::'b set) - (Z::'b set) ⊆ (W::'b set)›*) by blast qed ultimately show "?thesis" (*goal: ‹thesis::bool›*) by (metis Diff_subset_conv (*‹((?A::?'a set) - (?B::?'a set) ⊆ (?C::?'a set)) = (?A ⊆ ?B ∪ ?C)›*) Diff_triv (*‹(?A::?'a set) ∩ (?B::?'a set) = {} ⟹ ?A - ?B = ?A›*) Int_Diff_Un (*‹(?A::?'a set) ∩ (?B::?'a set) ∪ (?A - ?B) = ?A›*) Int_absorb1 (*‹(?B::?'a set) ⊆ (?A::?'a set) ⟹ ?A ∩ ?B = ?B›*) openin_closedin_eq (*‹openin (?U::?'a topology) (?S::?'a set) = (?S ⊆ topspace ?U ∧ closedin ?U (topspace ?U - ?S))›*) that (*‹⟦openin (top_of_set (U::'b set)) (?V::'b set); closedin (top_of_set U) (?W::'b set); (S'::'b set) ⊆ ?V; ?V ⊆ ?W; S' retract_of ?W⟧ ⟹ thesis::bool›*) topspace_euclidean_subtopology (*‹topspace (top_of_set (?S::?'a set)) = ?S›*)) qed lemma ANR_imp_closed_neighbourhood_retract: fixes S :: "'a::euclidean_space set" assumes "ANR S" "closedin (top_of_set U) S" obtains V W where "openin (top_of_set U) V" "closedin (top_of_set U) W" "S ⊆ V" "V ⊆ W" "S retract_of W" by (meson ANR_imp_absolute_closed_neighbourhood_retract (*‹⟦ANR (?S::?'a::euclidean_space set); ?S homeomorphic (?S'::?'b::euclidean_space set); closedin (top_of_set (?U::?'b::euclidean_space set)) ?S'; ⋀(V::?'b::euclidean_space set) W::?'b::euclidean_space set. ⟦openin (top_of_set ?U) V; closedin (top_of_set ?U) W; ?S' ⊆ V; V ⊆ W; ?S' retract_of W⟧ ⟹ ?thesis::bool⟧ ⟹ ?thesis›*) assms (*‹ANR (S::'a::euclidean_space set)› ‹closedin (top_of_set (U::'a::euclidean_space set)) (S::'a::euclidean_space set)›*) homeomorphic_refl (*‹(?S::?'a::topological_space set) homeomorphic ?S›*)) lemma ANR_homeomorphic_ANR: fixes S :: "'a::euclidean_space set" and T :: "'b::euclidean_space set" assumes "ANR T" "S homeomorphic T" shows "ANR S" unfolding ANR_def (*goal: ‹∀(U::('a × real) set) S'::('a × real) set. (S::'a set) homeomorphic S' ∧ closedin (top_of_set U) S' ⟶ (∃T::('a × real) set. openin (top_of_set U) T ∧ S' retract_of T)›*) by (metis assms (*‹ANR T› ‹S homeomorphic T›*) ANR_imp_absolute_neighbourhood_retract (*‹⟦ANR ?S; ?S homeomorphic ?S'; closedin (top_of_set ?U) ?S'; ⋀V. ⟦openin (top_of_set ?U) V; ?S' retract_of V⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*) homeomorphic_trans [of _ S] (*‹⟦?S homeomorphic S; S homeomorphic ?U⟧ ⟹ ?S homeomorphic ?U›*) homeomorphic_sym (*‹?S homeomorphic ?T = ?T homeomorphic ?S›*)) lemma homeomorphic_ANR_iff_ANR: fixes S :: "'a::euclidean_space set" and T :: "'b::euclidean_space set" shows "S homeomorphic T ⟹ ANR S ⟷ ANR T" by (metis ANR_homeomorphic_ANR (*‹⟦ANR ?T; ?S homeomorphic ?T⟧ ⟹ ANR ?S›*) homeomorphic_sym (*‹?S homeomorphic ?T = ?T homeomorphic ?S›*)) subsection ‹Analogous properties of ENRs› lemma ENR_imp_absolute_neighbourhood_retract: fixes S :: "'a::euclidean_space set" and S' :: "'b::euclidean_space set" assumes "ENR S" and hom: "S homeomorphic S'" and "S' ⊆ U" obtains V where "openin (top_of_set U) V" "S' retract_of V" proof (-) (*goal: ‹(⋀V. ⟦openin (top_of_set U) V; S' retract_of V⟧ ⟹ thesis) ⟹ thesis›*) obtain X where "open X" "S retract_of X" (*goal: ‹(⋀X. ⟦open X; S retract_of X⟧ ⟹ thesis) ⟹ thesis›*) using ‹ENR S› (*‹ENR (S::'a set)›*) by (auto simp: ENR_def (*‹ENR ?S ≡ ∃U. open U ∧ ?S retract_of U›*)) then obtain r where "retraction X S r" (*goal: ‹(⋀r. retraction X S r ⟹ thesis) ⟹ thesis›*) by (auto simp: retract_of_def (*‹(?T retract_of ?S) = (∃r. retraction ?S ?T r)›*)) have "locally compact S'" using retract_of_locally_compact (*‹⟦locally compact ?S; ?T retract_of ?S⟧ ⟹ locally compact ?T›*) open_imp_locally_compact (*‹open ?S ⟹ locally compact ?S›*) homeomorphic_local_compactness (*‹?S homeomorphic ?T ⟹ locally compact ?S = locally compact ?T›*) ‹S retract_of X› (*‹(S::'a set) retract_of (X::'a set)›*) ‹open X› (*‹open X›*) hom (*‹S homeomorphic S'›*) by blast then obtain W where UW: "openin (top_of_set U) W" and WS': "closedin (top_of_set W) S'" (*goal: ‹(⋀W. ⟦openin (top_of_set U) W; closedin (top_of_set W) S'⟧ ⟹ thesis) ⟹ thesis›*) apply (rule locally_compact_closedin_open (*‹⟦locally compact ?S; ⋀T. ⟦open T; closedin (top_of_set T) ?S⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*)) (*goal: ‹(⋀W. ⟦openin (top_of_set U) W; closedin (top_of_set W) S'⟧ ⟹ thesis) ⟹ thesis›*) by (meson Int_lower2 (*‹?A ∩ ?B ⊆ ?B›*) assms( (*‹S' ⊆ U›*) 3) closedin_imp_subset (*‹closedin (subtopology ?U ?S) ?T ⟹ ?T ⊆ ?S›*) closedin_subset_trans (*‹⟦closedin (top_of_set ?U) ?S; ?S ⊆ ?T; ?T ⊆ ?U⟧ ⟹ closedin (top_of_set ?T) ?S›*) le_inf_iff (*‹(?x ≤ inf ?y ?z) = (?x ≤ ?y ∧ ?x ≤ ?z)›*) openin_open (*‹openin (top_of_set ?U) ?S = (∃T. open T ∧ ?S = ?U ∩ T)›*)) obtain f and g where hom: "homeomorphism S S' f g" (*goal: ‹(⋀f g. homeomorphism S S' f g ⟹ thesis) ⟹ thesis›*) using assms (*‹ENR S› ‹S homeomorphic S'› ‹S' ⊆ U›*) by (force simp: homeomorphic_def (*‹?s homeomorphic ?t ≡ ∃f g. homeomorphism ?s ?t f g›*)) have contg: "continuous_on S' g" using hom (*‹homeomorphism (S::'a set) (S'::'b set) (f::'a ⇒ 'b) (g::'b ⇒ 'a)›*) homeomorphism_def (*‹homeomorphism ?S ?T ?f ?g = ((∀x∈?S. ?g (?f x) = x) ∧ ?f ` ?S = ?T ∧ continuous_on ?S ?f ∧ (∀y∈?T. ?f (?g y) = y) ∧ ?g ` ?T = ?S ∧ continuous_on ?T ?g)›*) by blast moreover have "g ` S' ⊆ S" by (metis hom (*‹homeomorphism S S' f g›*) equalityE (*‹⟦?A = ?B; ⟦?A ⊆ ?B; ?B ⊆ ?A⟧ ⟹ ?P⟧ ⟹ ?P›*) homeomorphism_def (*‹homeomorphism ?S ?T ?f ?g = ((∀x∈?S. ?g (?f x) = x) ∧ ?f ` ?S = ?T ∧ continuous_on ?S ?f ∧ (∀y∈?T. ?f (?g y) = y) ∧ ?g ` ?T = ?S ∧ continuous_on ?T ?g)›*)) ultimately obtain h where conth: "continuous_on W h" and hg: "⋀x. x ∈ S' ⟹ h x = g x" (*goal: ‹(⋀h. ⟦continuous_on W h; ⋀x. x ∈ S' ⟹ h x = g x⟧ ⟹ thesis) ⟹ thesis›*) using Tietze_unbounded[of S' g W] (*‹⟦continuous_on S' g; closedin (top_of_set W) S'; ⋀ga. ⟦continuous_on W ga; ⋀x. x ∈ S' ⟹ ga x = g x⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*) WS' (*‹closedin (top_of_set W) S'›*) by blast have "W ⊆ U" using UW (*‹openin (top_of_set U) W›*) openin_open (*‹openin (top_of_set ?U) ?S = (∃T. open T ∧ ?S = ?U ∩ T)›*) by auto have "S' ⊆ W" using WS' (*‹closedin (top_of_set W) S'›*) closedin_closed (*‹closedin (top_of_set (?U::?'a set)) (?S::?'a set) = (∃T::?'a set. closed T ∧ ?S = ?U ∩ T)›*) by auto have him: "⋀x. x ∈ S' ⟹ h x ∈ X" by (metis (no_types) ‹S retract_of X› hg (*‹?x ∈ S' ⟹ h ?x = g ?x›*) hom (*‹homeomorphism S S' f g›*) homeomorphism_def (*‹homeomorphism ?S ?T ?f ?g = ((∀x∈?S. ?g (?f x) = x) ∧ ?f ` ?S = ?T ∧ continuous_on ?S ?f ∧ (∀y∈?T. ?f (?g y) = y) ∧ ?g ` ?T = ?S ∧ continuous_on ?T ?g)›*) image_insert (*‹?f ` insert ?a ?B = insert (?f ?a) (?f ` ?B)›*) insert_absorb (*‹?a ∈ ?A ⟹ insert ?a ?A = ?A›*) insert_iff (*‹(?a ∈ insert ?b ?A) = (?a = ?b ∨ ?a ∈ ?A)›*) retract_of_imp_subset (*‹?S retract_of ?T ⟹ ?S ⊆ ?T›*) subset_eq (*‹(?A ⊆ ?B) = (∀x∈?A. x ∈ ?B)›*)) have "S' retract_of (W ∩ h -` X)" proof (simp add: retraction_def (*‹retraction ?S ?T ?r = (?T ⊆ ?S ∧ continuous_on ?S ?r ∧ ?r ∈ ?S → ?T ∧ (∀x∈?T. ?r x = x))›*) retract_of_def (*‹(?T retract_of ?S) = (∃r. retraction ?S ?T r)›*), intro exI (*‹?P ?x ⟹ ∃x. ?P x›*) conjI (*‹⟦?P; ?Q⟧ ⟹ ?P ∧ ?Q›*)) (*goals: 1. ‹S' ⊆ W› 2. ‹S' ⊆ h -` X› 3. ‹continuous_on (W ∩ h -` X) ?r9› 4. ‹?r9 ∈ W ∩ h -` X → S'› 5. ‹∀x∈S'. ?r9 x = x›*) show "S' ⊆ W" "S' ⊆ h -` X" using him (*‹?x ∈ S' ⟹ h ?x ∈ X›*) WS' (*‹closedin (top_of_set W) S'›*) closedin_imp_subset (*‹closedin (subtopology (?U::?'a::type topology) (?S::?'a::type set)) (?T::?'a::type set) ⟹ ?T ⊆ ?S›*) apply - (*goals: 1. ‹⟦⋀x. x ∈ S' ⟹ h x ∈ X; closedin (top_of_set W) S'; ⋀U S T. closedin (subtopology U S) T ⟹ T ⊆ S⟧ ⟹ S' ⊆ W› 2. ‹⟦⋀x. x ∈ S' ⟹ h x ∈ X; closedin (top_of_set W) S'; ⋀U S T. closedin (subtopology U S) T ⟹ T ⊆ S⟧ ⟹ S' ⊆ h -` X› discuss goal 1*) apply blast (*discuss goal 2*) apply blast (*proven 2 subgoals*) . show "continuous_on (W ∩ h -` X) (f ∘ r ∘ h)" proof (intro continuous_on_compose (*‹⟦continuous_on (?s::?'a::topological_space set) (?f::?'a::topological_space ⇒ ?'b::topological_space); continuous_on (?f ` ?s) (?g::?'b::topological_space ⇒ ?'c::topological_space)⟧ ⟹ continuous_on ?s (?g ∘ ?f)›*)) (*goals: 1. ‹continuous_on ((W::'b set) ∩ (h::'b ⇒ 'a) -` (X::'a set)) h› 2. ‹continuous_on ((h::'b ⇒ 'a) ` ((W::'b set) ∩ h -` (X::'a set))) (r::'a ⇒ 'a)› 3. ‹continuous_on ((r::'a ⇒ 'a) ` (h::'b ⇒ 'a) ` ((W::'b set) ∩ h -` (X::'a set))) (f::'a ⇒ 'b)›*) show "continuous_on (W ∩ h -` X) h" by (meson conth (*‹continuous_on W h›*) continuous_on_subset (*‹⟦continuous_on ?s ?f; ?t ⊆ ?s⟧ ⟹ continuous_on ?t ?f›*) inf_le1 (*‹inf ?x ?y ≤ ?x›*)) show "continuous_on (h ` (W ∩ h -` X)) r" proof (-) (*goal: ‹continuous_on (h ` (W ∩ h -` X)) r›*) have "h ` (W ∩ h -` X) ⊆ X" by blast then show "continuous_on (h ` (W ∩ h -` X)) r" by (meson ‹retraction X S r› continuous_on_subset (*‹⟦continuous_on ?s ?f; ?t ⊆ ?s⟧ ⟹ continuous_on ?t ?f›*) retraction (*‹retraction ?S ?T ?r = (?T ⊆ ?S ∧ continuous_on ?S ?r ∧ ?r ` ?S = ?T ∧ (∀x∈?T. ?r x = x))›*)) qed show "continuous_on (r ` h ` (W ∩ h -` X)) f" proof (rule continuous_on_subset [of S] (*‹⟦continuous_on S ?f; ?t ⊆ S⟧ ⟹ continuous_on ?t ?f›*)) (*goals: 1. ‹continuous_on S f› 2. ‹r ` h ` (W ∩ h -` X) ⊆ S›*) show "continuous_on S f" using hom (*‹homeomorphism S S' f g›*) homeomorphism_def (*‹homeomorphism ?S ?T ?f ?g = ((∀x∈?S. ?g (?f x) = x) ∧ ?f ` ?S = ?T ∧ continuous_on ?S ?f ∧ (∀y∈?T. ?f (?g y) = y) ∧ ?g ` ?T = ?S ∧ continuous_on ?T ?g)›*) by blast show "r ` h ` (W ∩ h -` X) ⊆ S" by (metis ‹retraction X S r› image_mono (*‹?A ⊆ ?B ⟹ ?f ` ?A ⊆ ?f ` ?B›*) image_subset_iff_subset_vimage (*‹(?f ` ?A ⊆ ?B) = (?A ⊆ ?f -` ?B)›*) inf_le2 (*‹inf ?x ?y ≤ ?y›*) retraction (*‹retraction ?S ?T ?r = (?T ⊆ ?S ∧ continuous_on ?S ?r ∧ ?r ` ?S = ?T ∧ (∀x∈?T. ?r x = x))›*)) qed qed show "(f ∘ r ∘ h) ∈ (W ∩ h -` X) → S'" using ‹retraction X S r› (*‹retraction X S r›*) hom (*‹homeomorphism S S' f g›*) by (auto simp: retraction_def (*‹retraction ?S ?T ?r = (?T ⊆ ?S ∧ continuous_on ?S ?r ∧ ?r ∈ ?S → ?T ∧ (∀x∈?T. ?r x = x))›*) homeomorphism_def (*‹homeomorphism ?S ?T ?f ?g = ((∀x∈?S. ?g (?f x) = x) ∧ ?f ` ?S = ?T ∧ continuous_on ?S ?f ∧ (∀y∈?T. ?f (?g y) = y) ∧ ?g ` ?T = ?S ∧ continuous_on ?T ?g)›*)) show "∀x∈S'. (f ∘ r ∘ h) x = x" using ‹retraction X S r› (*‹retraction X S r›*) hom (*‹homeomorphism S S' f g›*) by (auto simp: retraction_def (*‹retraction ?S ?T ?r = (?T ⊆ ?S ∧ continuous_on ?S ?r ∧ ?r ∈ ?S → ?T ∧ (∀x∈?T. ?r x = x))›*) homeomorphism_def (*‹homeomorphism ?S ?T ?f ?g = ((∀x∈?S. ?g (?f x) = x) ∧ ?f ` ?S = ?T ∧ continuous_on ?S ?f ∧ (∀y∈?T. ?f (?g y) = y) ∧ ?g ` ?T = ?S ∧ continuous_on ?T ?g)›*) hg (*‹?x ∈ S' ⟹ h ?x = g ?x›*)) qed then show "?thesis" (*goal: ‹thesis›*) using UW (*‹openin (top_of_set U) W›*) ‹open X› (*‹open X›*) conth (*‹continuous_on (W::'b::euclidean_space set) (h::'b::euclidean_space ⇒ 'a::euclidean_space)›*) continuous_openin_preimage_eq (*‹continuous_on ?S ?f = (∀T. open T ⟶ openin (top_of_set ?S) (?S ∩ ?f -` T))›*) openin_trans (*‹⟦openin (top_of_set ?T) ?S; openin (top_of_set ?U) ?T⟧ ⟹ openin (top_of_set ?U) ?S›*) that (*‹⟦openin (top_of_set U) ?V; S' retract_of ?V⟧ ⟹ thesis›*) by blast qed corollary ENR_imp_absolute_neighbourhood_retract_UNIV: fixes S :: "'a::euclidean_space set" and S' :: "'b::euclidean_space set" assumes "ENR S" "S homeomorphic S'" obtains T' where "open T'" "S' retract_of T'" by (metis ENR_imp_absolute_neighbourhood_retract (*‹⟦ENR ?S; ?S homeomorphic ?S'; ?S' ⊆ ?U; ⋀V. ⟦openin (top_of_set ?U) V; ?S' retract_of V⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*) UNIV_I (*‹?x ∈ UNIV›*) assms( (*‹ENR S›*) 1) assms( (*‹S homeomorphic S'›*) 2) open_openin (*‹open ?S = openin euclidean ?S›*) subsetI (*‹(⋀x. x ∈ ?A ⟹ x ∈ ?B) ⟹ ?A ⊆ ?B›*) subtopology_UNIV (*‹subtopology ?U UNIV = ?U›*)) lemma ENR_homeomorphic_ENR: fixes S :: "'a::euclidean_space set" and T :: "'b::euclidean_space set" assumes "ENR T" "S homeomorphic T" shows "ENR S" unfolding ENR_def (*goal: ‹∃U::'a::euclidean_space set. open U ∧ (S::'a::euclidean_space set) retract_of U›*) by (meson ENR_imp_absolute_neighbourhood_retract_UNIV (*‹⟦ENR ?S; ?S homeomorphic ?S'; ⋀T'. ⟦open T'; ?S' retract_of T'⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*) assms (*‹ENR T› ‹S homeomorphic T›*) homeomorphic_sym (*‹?S homeomorphic ?T = ?T homeomorphic ?S›*)) lemma homeomorphic_ENR_iff_ENR: fixes S :: "'a::euclidean_space set" and T :: "'b::euclidean_space set" assumes "S homeomorphic T" shows "ENR S ⟷ ENR T" by (meson ENR_homeomorphic_ENR (*‹⟦ENR ?T; ?S homeomorphic ?T⟧ ⟹ ENR ?S›*) assms (*‹S homeomorphic T›*) homeomorphic_sym (*‹?S homeomorphic ?T = ?T homeomorphic ?S›*)) lemma ENR_translation: fixes S :: "'a::euclidean_space set" shows "ENR(image (λx. a + x) S) ⟷ ENR S" by (meson homeomorphic_sym (*‹?S homeomorphic ?T = ?T homeomorphic ?S›*) homeomorphic_translation (*‹?S homeomorphic (+) ?a ` ?S›*) homeomorphic_ENR_iff_ENR (*‹?S homeomorphic ?T ⟹ ENR ?S = ENR ?T›*)) lemma ENR_linear_image_eq: fixes f :: "'a::euclidean_space ⇒ 'b::euclidean_space" assumes "linear f" "inj f" shows "ENR (image f S) ⟷ ENR S" by (meson assms (*‹linear f› ‹inj f›*) homeomorphic_ENR_iff_ENR (*‹?S homeomorphic ?T ⟹ ENR ?S = ENR ?T›*) linear_homeomorphic_image (*‹⟦linear ?f; inj ?f⟧ ⟹ ?S homeomorphic ?f ` ?S›*)) text ‹Some relations among the concepts. We also relate AR to being a retract of UNIV, which is often a more convenient proxy in the closed case.› lemma AR_imp_ANR: "AR S ⟹ ANR S" using ANR_def (*‹ANR ?S ≡ ∀U S'. ?S homeomorphic S' ∧ closedin (top_of_set U) S' ⟶ (∃T. openin (top_of_set U) T ∧ S' retract_of T)›*) AR_def (*‹AR ?S ≡ ∀U S'. ?S homeomorphic S' ∧ closedin (top_of_set U) S' ⟶ S' retract_of U›*) by fastforce lemma ENR_imp_ANR: fixes S :: "'a::euclidean_space set" shows "ENR S ⟹ ANR S" by (meson ANR_def (*‹ANR ?S ≡ ∀U S'. ?S homeomorphic S' ∧ closedin (top_of_set U) S' ⟶ (∃T. openin (top_of_set U) T ∧ S' retract_of T)›*) ENR_imp_absolute_neighbourhood_retract (*‹⟦ENR ?S; ?S homeomorphic ?S'; ?S' ⊆ ?U; ⋀V. ⟦openin (top_of_set ?U) V; ?S' retract_of V⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*) closedin_imp_subset (*‹closedin (subtopology ?U ?S) ?T ⟹ ?T ⊆ ?S›*)) lemma ENR_ANR: fixes S :: "'a::euclidean_space set" shows "ENR S ⟷ ANR S ∧ locally compact S" proof (standard) (*goals: 1. ‹ENR S ⟹ ANR S ∧ locally compact S› 2. ‹ANR S ∧ locally compact S ⟹ ENR S›*) assume "ENR S" (*‹ENR (S::'a set)›*) then have "locally compact S" using ENR_def (*‹ENR ?S ≡ ∃U. open U ∧ ?S retract_of U›*) open_imp_locally_compact (*‹open ?S ⟹ locally compact ?S›*) retract_of_locally_compact (*‹⟦locally compact ?S; ?T retract_of ?S⟧ ⟹ locally compact ?T›*) by auto then show "ANR S ∧ locally compact S" using ENR_imp_ANR (*‹ENR ?S ⟹ ANR ?S›*) ‹ENR S› (*‹ENR S›*) by blast next (*goal: ‹ANR S ∧ locally compact S ⟹ ENR S›*) assume "ANR S ∧ locally compact S" (*‹ANR (S::'a set) ∧ locally compact S›*) then have "ANR S" "locally compact S" apply - (*goals: 1. ‹ANR S ∧ locally compact S ⟹ ANR S› 2. ‹ANR S ∧ locally compact S ⟹ locally compact S› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . then obtain T :: "('a * real) set" where "closed T" "S homeomorphic T" (*goal: ‹(⋀T::('a::euclidean_space × real) set. ⟦closed T; (S::'a::euclidean_space set) homeomorphic T⟧ ⟹ thesis::bool) ⟹ thesis›*) using locally_compact_homeomorphic_closed (*‹⟦locally compact ?S; DIM(?'a) < DIM(?'b); ⋀T. ⟦closed T; ?S homeomorphic T⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*) by (metis DIM_prod (*‹DIM(?'a × ?'b) = DIM(?'a) + DIM(?'b)›*) DIM_real (*‹DIM(real) = 1›*) Suc_eq_plus1 (*‹Suc ?n = ?n + 1›*) lessI (*‹?n < Suc ?n›*)) then show "ENR S" using ‹ANR S› (*‹ANR S›*) by (meson ANR_imp_absolute_neighbourhood_retract_UNIV (*‹⟦ANR (?S::?'a set); ?S homeomorphic (?S'::?'b set); closed ?S'; ⋀V::?'b set. ⟦open V; ?S' retract_of V⟧ ⟹ ?thesis::bool⟧ ⟹ ?thesis›*) ENR_def (*‹ENR (?S::?'a set) ≡ ∃U::?'a set. open U ∧ ?S retract_of U›*) ENR_homeomorphic_ENR (*‹⟦ENR (?T::?'b set); (?S::?'a set) homeomorphic ?T⟧ ⟹ ENR ?S›*)) qed lemma AR_ANR: fixes S :: "'a::euclidean_space set" shows "AR S ⟷ ANR S ∧ contractible S ∧ S ≠ {}" (is "?lhs = ?rhs") proof (standard) (*goals: 1. ‹AR S ⟹ ANR S ∧ contractible S ∧ S ≠ {}› 2. ‹ANR S ∧ contractible S ∧ S ≠ {} ⟹ AR S›*) assume "?lhs" (*‹AR (S::'a set)›*) have "aff_dim S < int DIM('a × real)" using aff_dim_le_DIM[of S] (*‹aff_dim S ≤ int DIM('a)›*) by auto then obtain C and S' :: "('a * real) set" where "convex C" "C ≠ {}" "closedin (top_of_set C) S'" "S homeomorphic S'" (*goal: ‹(⋀C S'. ⟦convex C; C ≠ {}; closedin (top_of_set C) S'; S homeomorphic S'⟧ ⟹ thesis) ⟹ thesis›*) using homeomorphic_closedin_convex (*‹⟦aff_dim (?S::?'m::euclidean_space set) < int DIM(?'n::euclidean_space); ⋀(U::?'n::euclidean_space set) T::?'n::euclidean_space set. ⟦convex U; U ≠ {}; closedin (top_of_set U) T; ?S homeomorphic T⟧ ⟹ ?thesis::bool⟧ ⟹ ?thesis›*) by blast with ‹AR S› (*‹AR S›*) have "contractible S" by (meson AR_def (*‹AR (?S::?'a set) ≡ ∀(U::(?'a × real) set) S'::(?'a × real) set. ?S homeomorphic S' ∧ closedin (top_of_set U) S' ⟶ S' retract_of U›*) convex_imp_contractible (*‹convex (?S::?'a set) ⟹ contractible ?S›*) homeomorphic_contractible_eq (*‹(?S::?'a set) homeomorphic (?T::?'b set) ⟹ contractible ?S = contractible ?T›*) retract_of_contractible (*‹⟦contractible (?T::?'a set); (?S::?'a set) retract_of ?T⟧ ⟹ contractible ?S›*)) with ‹AR S› (*‹AR S›*) show "?rhs" using AR_imp_ANR (*‹AR ?S ⟹ ANR ?S›*) AR_imp_retract (*‹AR (?S::?'a set) ∧ closedin (top_of_set (?U::?'a set)) ?S ⟹ ?S retract_of ?U›*) by fastforce next (*goal: ‹ANR (S::'a set) ∧ contractible S ∧ S ≠ {} ⟹ AR S›*) assume "?rhs" (*‹ANR (S::'a set) ∧ contractible S ∧ S ≠ {}›*) then obtain a and h :: "real × 'a ⇒ 'a" where conth: "continuous_on ({0..1} × S) h" and hS: "h ` ({0..1} × S) ⊆ S" and [simp]: "⋀x. h(0, x) = x" and [simp]: "⋀x. h(1, x) = a" and "ANR S" "S ≠ {}" (*goal: ‹(⋀(h::real × 'a::euclidean_space ⇒ 'a::euclidean_space) a::'a::euclidean_space. ⟦continuous_on ({0::real..1::real} × (S::'a::euclidean_space set)) h; h ` ({0::real..1::real} × S) ⊆ S; ⋀x::'a::euclidean_space. h (0::real, x) = x; ⋀x::'a::euclidean_space. h (1::real, x) = a; ANR S; S ≠ {}⟧ ⟹ thesis::bool) ⟹ thesis›*) by (auto simp: contractible_def (*‹contractible (?S::?'a set) ≡ ∃a::?'a. homotopic_with_canon (λx::?'a ⇒ ?'a. True) ?S ?S id (λx::?'a. a)›*) homotopic_with_def (*‹homotopic_with (?P::(?'a ⇒ ?'b) ⇒ bool) (?X::?'a topology) (?Y::?'b topology) (?f::?'a ⇒ ?'b) (?g::?'a ⇒ ?'b) ≡ ∃h::real × ?'a ⇒ ?'b. continuous_map (prod_topology (top_of_set {0::real..1::real}) ?X) ?Y h ∧ (∀x::?'a. h (0::real, x) = ?f x) ∧ (∀x::?'a. h (1::real, x) = ?g x) ∧ (∀t::real∈{0::real..1::real}. ?P (λx::?'a. h (t, x)))›*)) then have "a ∈ S" by (metis all_not_in_conv (*‹(∀x. x ∉ ?A) = (?A = {})›*) atLeastAtMost_iff (*‹(?i ∈ {?l..?u}) = (?l ≤ ?i ∧ ?i ≤ ?u)›*) image_subset_iff (*‹(?f ` ?A ⊆ ?B) = (∀x∈?A. ?f x ∈ ?B)›*) mem_Sigma_iff (*‹((?a, ?b) ∈ Sigma ?A ?B) = (?a ∈ ?A ∧ ?b ∈ ?B ?a)›*) order_refl (*‹?x ≤ ?x›*) zero_le_one (*‹0 ≤ 1›*)) have "∃g. continuous_on W g ∧ g ∈ W → S ∧ (∀x∈T. g x = f x)" if f: "continuous_on T f" "f ∈ T → S" and WT: "closedin (top_of_set W) T" for W and T and f :: "'a × real ⇒ 'a" proof (-) (*goal: ‹∃g. continuous_on W g ∧ g ∈ W → S ∧ (∀x∈T. g x = f x)›*) obtain U and g where "T ⊆ U" and WU: "openin (top_of_set W) U" and contg: "continuous_on U g" and "g ∈ U → S" and gf: "⋀x. x ∈ T ⟹ g x = f x" (*goal: ‹(⋀U g. ⟦T ⊆ U; openin (top_of_set W) U; continuous_on U g; g ∈ U → S; ⋀x. x ∈ T ⟹ g x = f x⟧ ⟹ thesis) ⟹ thesis›*) using iffD1[OF ANR_eq_absolute_neighbourhood_extensor ‹ANR S›, rule_format, OF f WT] (*‹∃V g. T ⊆ V ∧ openin (top_of_set W) V ∧ continuous_on V g ∧ g ∈ V → S ∧ (∀x∈T. g x = f x)›*) by auto have WWU: "closedin (top_of_set W) (W - U)" using WU (*‹openin (top_of_set W) U›*) closedin_diff (*‹⟦closedin (?U::?'a::type topology) (?S::?'a::type set); openin ?U (?T::?'a::type set)⟧ ⟹ closedin ?U (?S - ?T)›*) by fastforce moreover have "(W - U) ∩ T = {}" using ‹T ⊆ U› (*‹T ⊆ U›*) by auto ultimately obtain V and V' where WV': "openin (top_of_set W) V'" and WV: "openin (top_of_set W) V" and "W - U ⊆ V'" "T ⊆ V" "V' ∩ V = {}" (*goal: ‹(⋀V' V. ⟦openin (top_of_set W) V'; openin (top_of_set W) V; W - U ⊆ V'; T ⊆ V; V' ∩ V = {}⟧ ⟹ thesis) ⟹ thesis›*) using separation_normal_local[of W "W-U" T] (*‹⟦closedin (top_of_set W) (W - U); closedin (top_of_set W) T; (W - U) ∩ T = {}; ⋀S' T'. ⟦openin (top_of_set W) S'; openin (top_of_set W) T'; W - U ⊆ S'; T ⊆ T'; S' ∩ T' = {}⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*) WT (*‹closedin (top_of_set W) T›*) by blast then have WVT: "T ∩ (W - V) = {}" by auto have WWV: "closedin (top_of_set W) (W - V)" using WV (*‹openin (top_of_set (W::('a × real) set)) (V::('a × real) set)›*) closedin_diff (*‹⟦closedin ?U ?S; openin ?U ?T⟧ ⟹ closedin ?U (?S - ?T)›*) by fastforce obtain j :: " 'a × real ⇒ real" where contj: "continuous_on W j" and j: "⋀x. x ∈ W ⟹ j x ∈ {0..1}" and j0: "⋀x. x ∈ W - V ⟹ j x = 1" and j1: "⋀x. x ∈ T ⟹ j x = 0" (*goal: ‹(⋀j. ⟦continuous_on W j; ⋀x. x ∈ W ⟹ j x ∈ {0..1}; ⋀x. x ∈ W - V ⟹ j x = 1; ⋀x. x ∈ T ⟹ j x = 0⟧ ⟹ thesis) ⟹ thesis›*) apply (rule Urysohn_local [OF WT WWV WVT, of 0 "1::real"] (*‹(⋀f. ⟦continuous_on W f; ⋀x. x ∈ W ⟹ f x ∈ closed_segment 0 1; ⋀x. x ∈ T ⟹ f x = 0; ⋀x. x ∈ W - V ⟹ f x = 1⟧ ⟹ ?thesis) ⟹ ?thesis›*)) (*goal: ‹(⋀j. ⟦continuous_on W j; ⋀x. x ∈ W ⟹ j x ∈ {0..1}; ⋀x. x ∈ W - V ⟹ j x = 1; ⋀x. x ∈ T ⟹ j x = 0⟧ ⟹ thesis) ⟹ thesis›*) by (auto simp: in_segment (*‹(?x ∈ closed_segment ?a ?b) = (∃u≥0. u ≤ 1 ∧ ?x = (1 - u) *⇩R ?a + u *⇩R ?b)› ‹(?x ∈ open_segment ?a ?b) = (?a ≠ ?b ∧ (∃u>0. u < 1 ∧ ?x = (1 - u) *⇩R ?a + u *⇩R ?b))›*)) have Weq: "W = (W - V) ∪ (W - V')" using ‹V' ∩ V = {}› (*‹V' ∩ V = {}›*) by force show "?thesis" (*goal: ‹∃g. continuous_on W g ∧ g ∈ W → S ∧ (∀x∈T. g x = f x)›*) proof (intro conjI (*‹⟦?P; ?Q⟧ ⟹ ?P ∧ ?Q›*) exI (*‹?P ?x ⟹ ∃x. ?P x›*)) (*goals: 1. ‹continuous_on (W::('a × real) set) (?g::'a × real ⇒ 'a)› 2. ‹(?g::'a × real ⇒ 'a) ∈ (W::('a × real) set) → (S::'a set)› 3. ‹∀x::'a × real∈T::('a × real) set. (?g::'a × real ⇒ 'a) x = (f::'a × real ⇒ 'a) x›*) have "*": "continuous_on (W - V') (λx. h (j x, g x))" proof (rule continuous_on_compose2 [OF conth continuous_on_Pair] (*‹⟦continuous_on ?s ?f1; continuous_on ?s ?g1; (λx. (?f1 x, ?g1 x)) ` ?s ⊆ {0..1} × S⟧ ⟹ continuous_on ?s (λx. h (?f1 x, ?g1 x))›*)) (*goals: 1. ‹continuous_on (W - V') j› 2. ‹continuous_on (W - V') g› 3. ‹(λx. (j x, g x)) ` (W - V') ⊆ {0..1} × S›*) show "continuous_on (W - V') j" by (rule continuous_on_subset [OF contj Diff_subset] (*‹continuous_on ((W::('a × real) set) - (?B1::('a × real) set)) (j::'a × real ⇒ real)›*)) show "continuous_on (W - V') g" by (metis Diff_subset_conv (*‹(?A - ?B ⊆ ?C) = (?A ⊆ ?B ∪ ?C)›*) ‹W - U ⊆ V'› contg (*‹continuous_on U g›*) continuous_on_subset (*‹⟦continuous_on ?s ?f; ?t ⊆ ?s⟧ ⟹ continuous_on ?t ?f›*) Un_commute (*‹?A ∪ ?B = ?B ∪ ?A›*)) show "(λx. (j x, g x)) ` (W - V') ⊆ {0..1} × S" using j (*‹?x ∈ W ⟹ j ?x ∈ {0..1}›*) ‹g ∈ U → S› (*‹g ∈ U → S›*) ‹W - U ⊆ V'› (*‹W - U ⊆ V'›*) by fastforce qed show "continuous_on W (λx. if x ∈ W - V then a else h (j x, g x))" proof (subst Weq (*‹W = W - V ∪ (W - V')›*), rule continuous_on_cases_local (*‹⟦closedin (top_of_set (?S ∪ ?T)) ?S; closedin (top_of_set (?S ∪ ?T)) ?T; continuous_on ?S ?f; continuous_on ?T ?g; ⋀x. x ∈ ?S ∧ ¬ ?P x ∨ x ∈ ?T ∧ ?P x ⟹ ?f x = ?g x⟧ ⟹ continuous_on (?S ∪ ?T) (λx. if ?P x then ?f x else ?g x)›*)) (*goals: 1. ‹closedin (top_of_set (W - V ∪ (W - V'))) (W - V)› 2. ‹closedin (top_of_set (W - V ∪ (W - V'))) (W - V')› 3. ‹continuous_on (W - V) (λx. a)› 4. ‹continuous_on (W - V') (λx. h (j x, g x))› 5. ‹⋀x. x ∈ W - V ∧ x ∉ W - V ∨ x ∈ W - V' ∧ x ∈ W - V ⟹ a = h (j x, g x)›*) show "continuous_on (W - V') (λx. h (j x, g x))" using "*" (*‹continuous_on (W - V') (λx. h (j x, g x))›*) by blast qed (use WWV WV' Weq j0 j1 in auto) (*solves the remaining goals: 1. ‹closedin (top_of_set (W - V ∪ (W - V'))) (W - V)› 2. ‹closedin (top_of_set (W - V ∪ (W - V'))) (W - V')› 3. ‹continuous_on (W - V) (λx. a)› 4. ‹⋀x. x ∈ W - V ∧ x ∉ W - V ∨ x ∈ W - V' ∧ x ∈ W - V ⟹ a = h (j x, g x)›*) next (*goals: 1. ‹(λx. if x ∈ W - V then a else h (j x, g x)) ∈ W → S› 2. ‹∀x∈T. (if x ∈ W - V then a else h (j x, g x)) = f x›*) have "h (j (x, y), g (x, y)) ∈ S" if "(x, y) ∈ W" "(x, y) ∈ V" for x and y proof (-) (*goal: ‹h (j (x, y), g (x, y)) ∈ S›*) have "j(x, y) ∈ {0..1}" using j (*‹?x ∈ W ⟹ j ?x ∈ {0..1}›*) that (*‹(x, y) ∈ W› ‹(x, y) ∈ V›*) by blast moreover have "g(x, y) ∈ S" using ‹V' ∩ V = {}› (*‹V' ∩ V = {}›*) ‹W - U ⊆ V'› (*‹W - U ⊆ V'›*) ‹g ∈ U → S› (*‹g ∈ U → S›*) that (*‹(x::'a, y::real) ∈ (W::('a × real) set)› ‹(x::'a, y::real) ∈ (V::('a × real) set)›*) by fastforce ultimately show "?thesis" (*goal: ‹h (j (x, y), g (x, y)) ∈ S›*) using hS (*‹h ` ({0..1} × S) ⊆ S›*) by blast qed with ‹a ∈ S› (*‹(a::'a::euclidean_space) ∈ (S::'a::euclidean_space set)›*) ‹g ∈ U → S› (*‹g ∈ U → S›*) show "(λx. if x ∈ W - V then a else h (j x, g x)) ∈ W → S" by auto next (*goal: ‹∀x∈T. (if x ∈ W - V then a else h (j x, g x)) = f x›*) show "∀x∈T. (if x ∈ W - V then a else h (j x, g x)) = f x" using ‹T ⊆ V› (*‹T ⊆ V›*) by (auto simp: j0 (*‹?x ∈ W - V ⟹ j ?x = 1›*) j1 (*‹?x ∈ T ⟹ j ?x = 0›*) gf (*‹?x ∈ T ⟹ g ?x = f ?x›*)) qed qed then show "?lhs" by (simp add: AR_eq_absolute_extensor (*‹AR ?S = (∀f U T. continuous_on T f ⟶ f ` T ⊆ ?S ⟶ closedin (top_of_set U) T ⟶ (∃g. continuous_on U g ∧ g ` U ⊆ ?S ∧ (∀x∈T. g x = f x)))›*) image_subset_iff_funcset (*‹(?F ` ?A ⊆ ?B) = (?F ∈ ?A → ?B)›*)) qed lemma ANR_retract_of_ANR: fixes S :: "'a::euclidean_space set" assumes "ANR T" and ST: "S retract_of T" shows "ANR S" proof (clarsimp simp add: ANR_eq_absolute_neighbourhood_extensor (*‹ANR (?S::?'a::euclidean_space set) = (∀(f::?'a::euclidean_space × real ⇒ ?'a::euclidean_space) (U::(?'a::euclidean_space × real) set) T::(?'a::euclidean_space × real) set. continuous_on T f ⟶ f ∈ T → ?S ⟶ closedin (top_of_set U) T ⟶ (∃(V::(?'a::euclidean_space × real) set) g::?'a::euclidean_space × real ⇒ ?'a::euclidean_space. T ⊆ V ∧ openin (top_of_set U) V ∧ continuous_on V g ∧ g ∈ V → ?S ∧ (∀x::?'a::euclidean_space × real∈T. g x = f x)))›*)) (*goal: ‹⋀f U T. ⟦continuous_on T f; f ∈ T → S; closedin (top_of_set U) T⟧ ⟹ ∃V. T ⊆ V ∧ openin (top_of_set U) V ∧ (∃g. continuous_on V g ∧ g ∈ V → S ∧ (∀x∈T. g x = f x))›*) fix f :: "'a × real ⇒ 'a" and U and W assume W: "continuous_on W f" "f ∈ W → S" "closedin (top_of_set U) W" (*‹continuous_on (W::('a × real) set) (f::'a × real ⇒ 'a)› ‹(f::'a × real ⇒ 'a) ∈ (W::('a × real) set) → (S::'a set)› ‹closedin (top_of_set (U::('a × real) set)) (W::('a × real) set)›*) then obtain r where "S ⊆ T" and r: "continuous_on T r" "r ∈ T → S" "∀x∈S. r x = x" "continuous_on W f" "f ∈ W → S" "closedin (top_of_set U) W" (*goal: ‹(⋀r. ⟦S ⊆ T; continuous_on T r; r ∈ T → S; ∀x∈S. r x = x; continuous_on W f; f ∈ W → S; closedin (top_of_set U) W⟧ ⟹ thesis) ⟹ thesis›*) by (metis ST (*‹S retract_of T›*) retract_of_def (*‹(?T retract_of ?S) = (∃r. retraction ?S ?T r)›*) retraction_def (*‹retraction ?S ?T ?r = (?T ⊆ ?S ∧ continuous_on ?S ?r ∧ ?r ∈ ?S → ?T ∧ (∀x∈?T. ?r x = x))›*)) then have "f ` W ⊆ T" by blast with W (*‹continuous_on (W::('a × real) set) (f::'a × real ⇒ 'a)› ‹f ∈ W → S› ‹closedin (top_of_set U) W›*) obtain V and g where V: "W ⊆ V" "openin (top_of_set U) V" "continuous_on V g" "g ∈ V → T" "∀x∈W. g x = f x" (*goal: ‹(⋀V g. ⟦W ⊆ V; openin (top_of_set U) V; continuous_on V g; g ∈ V → T; ∀x∈W. g x = f x⟧ ⟹ thesis) ⟹ thesis›*) by (smt (verit) ANR_imp_absolute_neighbourhood_extensor (*‹⟦ANR ?S; continuous_on ?T ?f; ?f ∈ ?T → ?S; closedin (top_of_set ?U) ?T; ⋀V g. ⟦?T ⊆ V; openin (top_of_set ?U) V; continuous_on V g; g ∈ V → ?S; ⋀x. x ∈ ?T ⟹ g x = ?f x⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*) Pi_I (*‹(⋀x. x ∈ ?A ⟹ ?f x ∈ ?B x) ⟹ ?f ∈ Pi ?A ?B›*) assms( (*‹ANR T›*) 1) funcset_mem (*‹⟦?f ∈ ?A → ?B; ?x ∈ ?A⟧ ⟹ ?f ?x ∈ ?B›*) image_subset_iff_funcset (*‹(?F ` ?A ⊆ ?B) = (?F ∈ ?A → ?B)›*)) with r (*‹continuous_on T r› ‹r ∈ T → S› ‹∀x∈S. r x = x› ‹continuous_on W f› ‹f ∈ W → S› ‹closedin (top_of_set (U::('a × real) set)) (W::('a × real) set)›*) have "continuous_on V (r ∘ g) ∧ (r ∘ g) ∈ V → S ∧ (∀x∈W. (r ∘ g) x = f x)" by (smt (verit, del_insts) Pi_iff (*‹((?f::?'a::type ⇒ ?'b::type) ∈ Pi (?I::?'a::type set) (?X::?'a::type ⇒ ?'b::type set)) = (∀i::?'a::type∈?I. ?f i ∈ ?X i)›*) comp_apply (*‹((?f::?'b::type ⇒ ?'a::type) ∘ (?g::?'c::type ⇒ ?'b::type)) (?x::?'c::type) = ?f (?g ?x)›*) continuous_on_compose (*‹⟦continuous_on (?s::?'a::topological_space set) (?f::?'a::topological_space ⇒ ?'b::topological_space); continuous_on (?f ` ?s) (?g::?'b::topological_space ⇒ ?'c::topological_space)⟧ ⟹ continuous_on ?s (?g ∘ ?f)›*) continuous_on_subset (*‹⟦continuous_on (?s::?'a::topological_space set) (?f::?'a::topological_space ⇒ ?'b::topological_space); (?t::?'a::topological_space set) ⊆ ?s⟧ ⟹ continuous_on ?t ?f›*) image_subset_iff_funcset (*‹((?F::?'b::type ⇒ ?'a::type) ` (?A::?'b::type set) ⊆ (?B::?'a::type set)) = (?F ∈ ?A → ?B)›*)) then show "∃V. W ⊆ V ∧ openin (top_of_set U) V ∧ (∃g. continuous_on V g ∧ g ∈ V → S ∧ (∀x∈W. g x = f x))" by (meson V (*‹W ⊆ V› ‹openin (top_of_set U) V› ‹continuous_on V g› ‹g ∈ V → T› ‹∀x∈W. g x = f x›*)) qed lemma AR_retract_of_AR: fixes S :: "'a::euclidean_space set" shows "⟦AR T; S retract_of T⟧ ⟹ AR S" using ANR_retract_of_ANR (*‹⟦ANR ?T; ?S retract_of ?T⟧ ⟹ ANR ?S›*) AR_ANR (*‹AR (?S::?'a::euclidean_space set) = (ANR ?S ∧ contractible ?S ∧ ?S ≠ {})›*) retract_of_contractible (*‹⟦contractible (?T::?'a set); (?S::?'a set) retract_of ?T⟧ ⟹ contractible ?S›*) by fastforce lemma ENR_retract_of_ENR: "⟦ENR T; S retract_of T⟧ ⟹ ENR S" by (meson ENR_def (*‹ENR ?S ≡ ∃U. open U ∧ ?S retract_of U›*) retract_of_trans (*‹⟦?S retract_of ?T; ?T retract_of ?U⟧ ⟹ ?S retract_of ?U›*)) lemma retract_of_UNIV: fixes S :: "'a::euclidean_space set" shows "S retract_of UNIV ⟷ AR S ∧ closed S" by (metis AR_ANR (*‹AR ?S = (ANR ?S ∧ contractible ?S ∧ ?S ≠ {})›*) AR_imp_retract (*‹AR ?S ∧ closedin (top_of_set ?U) ?S ⟹ ?S retract_of ?U›*) ENR_def (*‹ENR ?S ≡ ∃U. open U ∧ ?S retract_of U›*) ENR_imp_ANR (*‹ENR ?S ⟹ ANR ?S›*) closed_UNIV (*‹closed UNIV›*) closed_closedin (*‹closed ?S = closedin euclidean ?S›*) contractible_UNIV (*‹contractible UNIV›*) empty_not_UNIV (*‹{} ≠ UNIV›*) open_UNIV (*‹open UNIV›*) retract_of_closed (*‹⟦closed ?T; ?S retract_of ?T⟧ ⟹ closed ?S›*) retract_of_contractible (*‹⟦contractible ?T; ?S retract_of ?T⟧ ⟹ contractible ?S›*) retract_of_empty( (*‹({} retract_of ?S) = (?S = {})›*) 1) subtopology_UNIV (*‹subtopology ?U UNIV = ?U›*)) lemma compact_AR: fixes S :: "'a::euclidean_space set" shows "compact S ∧ AR S ⟷ compact S ∧ S retract_of UNIV" using compact_imp_closed (*‹compact ?s ⟹ closed ?s›*) retract_of_UNIV (*‹(?S retract_of UNIV) = (AR ?S ∧ closed ?S)›*) by blast text ‹More properties of ARs, ANRs and ENRs› lemma not_AR_empty [simp]: "¬ AR({})" by (auto simp: AR_def (*‹AR ?S ≡ ∀U S'. ?S homeomorphic S' ∧ closedin (top_of_set U) S' ⟶ S' retract_of U›*)) lemma ENR_empty [simp]: "ENR {}" by (simp add: ENR_def (*‹ENR (?S::?'a::topological_space set) ≡ ∃U::?'a::topological_space set. open U ∧ ?S retract_of U›*)) lemma ANR_empty [simp]: "ANR ({} :: 'a::euclidean_space set)" by (simp add: ENR_imp_ANR (*‹ENR ?S ⟹ ANR ?S›*)) lemma convex_imp_AR: fixes S :: "'a::euclidean_space set" shows "⟦convex S; S ≠ {}⟧ ⟹ AR S" by (metis (mono_tags, lifting) Dugundji (*‹⟦convex ?C; ?C ≠ {}; closedin (top_of_set ?U) ?S; continuous_on ?S ?f; ?f ` ?S ⊆ ?C; ⋀g. ⟦continuous_on ?U g; g ` ?U ⊆ ?C; ⋀x. x ∈ ?S ⟹ g x = ?f x⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*) absolute_extensor_imp_AR (*‹(⋀f U T. ⟦continuous_on T f; f ` T ⊆ ?S; closedin (top_of_set U) T⟧ ⟹ ∃g. continuous_on U g ∧ g ` U ⊆ ?S ∧ (∀x∈T. g x = f x)) ⟹ AR ?S›*)) lemma convex_imp_ANR: fixes S :: "'a::euclidean_space set" shows "convex S ⟹ ANR S" using ANR_empty (*‹ANR {}›*) AR_imp_ANR (*‹AR ?S ⟹ ANR ?S›*) convex_imp_AR (*‹⟦convex ?S; ?S ≠ {}⟧ ⟹ AR ?S›*) by blast lemma ENR_convex_closed: fixes S :: "'a::euclidean_space set" shows "⟦closed S; convex S⟧ ⟹ ENR S" using ENR_def (*‹ENR ?S ≡ ∃U. open U ∧ ?S retract_of U›*) ENR_empty (*‹ENR {}›*) convex_imp_AR (*‹⟦convex ?S; ?S ≠ {}⟧ ⟹ AR ?S›*) retract_of_UNIV (*‹(?S retract_of UNIV) = (AR ?S ∧ closed ?S)›*) by blast lemma AR_UNIV [simp]: "AR (UNIV :: 'a::euclidean_space set)" using retract_of_UNIV (*‹(?S retract_of UNIV) = (AR ?S ∧ closed ?S)›*) by auto lemma ANR_UNIV [simp]: "ANR (UNIV :: 'a::euclidean_space set)" by (simp add: AR_imp_ANR (*‹AR ?S ⟹ ANR ?S›*)) lemma ENR_UNIV [simp]:"ENR UNIV" using ENR_def (*‹ENR ?S ≡ ∃U. open U ∧ ?S retract_of U›*) by blast lemma AR_singleton: fixes a :: "'a::euclidean_space" shows "AR {a}" using retract_of_UNIV (*‹(?S retract_of UNIV) = (AR ?S ∧ closed ?S)›*) by blast lemma ANR_singleton: fixes a :: "'a::euclidean_space" shows "ANR {a}" by (simp add: AR_imp_ANR (*‹AR ?S ⟹ ANR ?S›*) AR_singleton (*‹AR {?a}›*)) lemma ENR_singleton: "ENR {a}" using ENR_def (*‹ENR (?S::?'a set) ≡ ∃U::?'a set. open U ∧ ?S retract_of U›*) by blast text ‹ARs closed under union› lemma AR_closed_Un_local_aux: fixes U :: "'a::euclidean_space set" assumes "closedin (top_of_set U) S" "closedin (top_of_set U) T" "AR S" "AR T" "AR(S ∩ T)" shows "(S ∪ T) retract_of U" proof (-) (*goal: ‹S ∪ T retract_of U›*) have "S ∩ T ≠ {}" using assms (*‹closedin (top_of_set U) S› ‹closedin (top_of_set U) T› ‹AR S› ‹AR (T::'a set)› ‹AR (S ∩ T)›*) AR_def (*‹AR ?S ≡ ∀U S'. ?S homeomorphic S' ∧ closedin (top_of_set U) S' ⟶ S' retract_of U›*) by fastforce have "S ⊆ U" "T ⊆ U" using assms (*‹closedin (top_of_set U) S› ‹closedin (top_of_set U) T› ‹AR (S::'a set)› ‹AR T› ‹AR (S ∩ T)›*) apply - (*goals: 1. ‹⟦closedin (top_of_set U) S; closedin (top_of_set U) T; AR S; AR T; AR (S ∩ T)⟧ ⟹ S ⊆ U› 2. ‹⟦closedin (top_of_set U) S; closedin (top_of_set U) T; AR S; AR T; AR (S ∩ T)⟧ ⟹ T ⊆ U› discuss goal 1*) apply ((auto simp: closedin_imp_subset (*‹closedin (subtopology ?U ?S) ?T ⟹ ?T ⊆ ?S›*))[1]) (*discuss goal 2*) apply ((auto simp: closedin_imp_subset (*‹closedin (subtopology ?U ?S) ?T ⟹ ?T ⊆ ?S›*))[1]) (*proven 2 subgoals*) . define S' where "S' ≡ {x ∈ U. setdist {x} S ≤ setdist {x} T}" define T' where "T' ≡ {x ∈ U. setdist {x} T ≤ setdist {x} S}" define W where "W ≡ {x ∈ U. setdist {x} S = setdist {x} T}" have US': "closedin (top_of_set U) S'" using continuous_closedin_preimage[of U "λx. setdist {x} S - setdist {x} T" "{..0}"] (*‹⟦continuous_on U (λx. setdist {x} S - setdist {x} T); closed {..0}⟧ ⟹ closedin (top_of_set U) (U ∩ (λx. setdist {x} S - setdist {x} T) -` {..0})›*) by (simp add: S'_def (*‹S' ≡ {x ∈ U. setdist {x} S ≤ setdist {x} T}›*) vimage_def (*‹?f -` ?B ≡ {x. ?f x ∈ ?B}›*) Collect_conj_eq (*‹{x. ?P x ∧ ?Q x} = {x. ?P x} ∩ {x. ?Q x}›*) continuous_on_diff (*‹⟦continuous_on ?s ?f; continuous_on ?s ?g⟧ ⟹ continuous_on ?s (λx. ?f x - ?g x)›*) continuous_on_setdist (*‹continuous_on ?T (λy. setdist {y} ?S)›*)) have UT': "closedin (top_of_set U) T'" using continuous_closedin_preimage[of U "λx. setdist {x} T - setdist {x} S" "{..0}"] (*‹⟦continuous_on (U::'a::euclidean_space set) (λx::'a::euclidean_space. setdist {x} (T::'a::euclidean_space set) - setdist {x} (S::'a::euclidean_space set)); closed {..0::real}⟧ ⟹ closedin (top_of_set U) (U ∩ (λx::'a::euclidean_space. setdist {x} T - setdist {x} S) -` {..0::real})›*) by (simp add: T'_def (*‹T' ≡ {x ∈ U. setdist {x} T ≤ setdist {x} S}›*) vimage_def (*‹?f -` ?B ≡ {x. ?f x ∈ ?B}›*) Collect_conj_eq (*‹{x. ?P x ∧ ?Q x} = {x. ?P x} ∩ {x. ?Q x}›*) continuous_on_diff (*‹⟦continuous_on ?s ?f; continuous_on ?s ?g⟧ ⟹ continuous_on ?s (λx. ?f x - ?g x)›*) continuous_on_setdist (*‹continuous_on ?T (λy. setdist {y} ?S)›*)) have "S ⊆ S'" using S'_def (*‹S' ≡ {x ∈ U. setdist {x} S ≤ setdist {x} T}›*) ‹S ⊆ U› (*‹S ⊆ U›*) setdist_sing_in_set (*‹?x ∈ ?S ⟹ setdist {?x} ?S = 0›*) by fastforce have "T ⊆ T'" using T'_def (*‹T' ≡ {x ∈ U. setdist {x} T ≤ setdist {x} S}›*) ‹T ⊆ U› (*‹T ⊆ U›*) setdist_sing_in_set (*‹(?x::?'a::metric_space) ∈ (?S::?'a::metric_space set) ⟹ setdist {?x} ?S = (0::real)›*) by fastforce have "S ∩ T ⊆ W" "W ⊆ U" using ‹S ⊆ U› (*‹S ⊆ U›*) apply - (*goals: 1. ‹S ⊆ U ⟹ S ∩ T ⊆ W› 2. ‹S ⊆ U ⟹ W ⊆ U› discuss goal 1*) apply ((auto simp: W_def (*‹W ≡ {x ∈ U. setdist {x} S = setdist {x} T}›*) setdist_sing_in_set (*‹?x ∈ ?S ⟹ setdist {?x} ?S = 0›*))[1]) (*discuss goal 2*) apply ((auto simp: W_def (*‹W ≡ {x ∈ U. setdist {x} S = setdist {x} T}›*) setdist_sing_in_set (*‹?x ∈ ?S ⟹ setdist {?x} ?S = 0›*))[1]) (*proven 2 subgoals*) . have "(S ∩ T) retract_of W" proof (rule AR_imp_absolute_retract [OF ‹AR(S ∩ T)›] (*‹⟦S ∩ T homeomorphic ?S'; closedin (top_of_set ?U) ?S'⟧ ⟹ ?S' retract_of ?U›*)) (*goals: 1. ‹S ∩ T homeomorphic S ∩ T› 2. ‹closedin (top_of_set W) (S ∩ T)›*) show "S ∩ T homeomorphic S ∩ T" by (simp add: homeomorphic_refl (*‹?S homeomorphic ?S›*)) show "closedin (top_of_set W) (S ∩ T)" by (meson ‹S ∩ T ⊆ W› ‹W ⊆ U› assms (*‹closedin (top_of_set U) S› ‹closedin (top_of_set U) T› ‹AR S› ‹AR T› ‹AR (S ∩ T)›*) closedin_Int (*‹⟦closedin ?U ?S; closedin ?U ?T⟧ ⟹ closedin ?U (?S ∩ ?T)›*) closedin_subset_trans (*‹⟦closedin (top_of_set ?U) ?S; ?S ⊆ ?T; ?T ⊆ ?U⟧ ⟹ closedin (top_of_set ?T) ?S›*)) qed then obtain r0 where "S ∩ T ⊆ W" and contr0: "continuous_on W r0" and "r0 ` W ⊆ S ∩ T" and r0[simp]: "⋀x. x ∈ S ∩ T ⟹ r0 x = x" (*goal: ‹(⋀r0. ⟦S ∩ T ⊆ W; continuous_on W r0; r0 ` W ⊆ S ∩ T; ⋀x. x ∈ S ∩ T ⟹ r0 x = x⟧ ⟹ thesis) ⟹ thesis›*) by (auto simp: retract_of_def (*‹(?T retract_of ?S) = (∃r. retraction ?S ?T r)›*) retraction_def (*‹retraction ?S ?T ?r = (?T ⊆ ?S ∧ continuous_on ?S ?r ∧ ?r ∈ ?S → ?T ∧ (∀x∈?T. ?r x = x))›*)) have ST: "x ∈ W ⟹ x ∈ S ⟷ x ∈ T" for x using setdist_eq_0_closedin (*‹⟦closedin (top_of_set ?U) ?S; ?x ∈ ?U⟧ ⟹ (setdist {?x} ?S = 0) = (?S = {} ∨ ?x ∈ ?S)›*) ‹S ∩ T ≠ {}› (*‹S ∩ T ≠ {}›*) assms (*‹closedin (top_of_set (U::'a set)) (S::'a set)› ‹closedin (top_of_set U) T› ‹AR (S::'a set)› ‹AR T› ‹AR (S ∩ T)›*) by (force simp: W_def (*‹W ≡ {x ∈ U. setdist {x} S = setdist {x} T}›*) setdist_sing_in_set (*‹?x ∈ ?S ⟹ setdist {?x} ?S = 0›*)) have "S' ∩ T' = W" by (auto simp: S'_def (*‹S'::'a set ≡ {x::'a ∈ U::'a set. setdist {x} (S::'a set) ≤ setdist {x} (T::'a set)}›*) T'_def (*‹T'::'a set ≡ {x::'a ∈ U::'a set. setdist {x} (T::'a set) ≤ setdist {x} (S::'a set)}›*) W_def (*‹W::'a set ≡ {x::'a ∈ U::'a set. setdist {x} (S::'a set) = setdist {x} (T::'a set)}›*)) then have cloUW: "closedin (top_of_set U) W" using closedin_Int (*‹⟦closedin ?U ?S; closedin ?U ?T⟧ ⟹ closedin ?U (?S ∩ ?T)›*) US' (*‹closedin (top_of_set U) S'›*) UT' (*‹closedin (top_of_set U) T'›*) by blast define r where "r ≡ λx. if x ∈ W then r0 x else x" have contr: "continuous_on (W ∪ (S ∪ T)) r" unfolding r_def (*goal: ‹continuous_on ((W::'a set) ∪ ((S::'a set) ∪ (T::'a set))) (λx::'a. if x ∈ W then (r0::'a ⇒ 'a) x else x)›*) proof (rule continuous_on_cases_local [OF _ _ contr0 continuous_on_id] (*‹⟦closedin (top_of_set (W ∪ ?T)) W; closedin (top_of_set (W ∪ ?T)) ?T; ⋀x. x ∈ W ∧ ¬ ?P x ∨ x ∈ ?T ∧ ?P x ⟹ r0 x = x⟧ ⟹ continuous_on (W ∪ ?T) (λx. if ?P x then r0 x else x)›*)) (*goals: 1. ‹closedin (top_of_set ((W::'a set) ∪ ((S::'a set) ∪ (T::'a set)))) W› 2. ‹closedin (top_of_set ((W::'a set) ∪ ((S::'a set) ∪ (T::'a set)))) (S ∪ T)› 3. ‹⋀x::'a. x ∈ (W::'a set) ∧ x ∉ W ∨ x ∈ (S::'a set) ∪ (T::'a set) ∧ x ∈ W ⟹ (r0::'a ⇒ 'a) x = x›*) show "closedin (top_of_set (W ∪ (S ∪ T))) W" using ‹S ⊆ U› (*‹(S::'a set) ⊆ (U::'a set)›*) ‹T ⊆ U› (*‹T ⊆ U›*) ‹W ⊆ U› (*‹W ⊆ U›*) ‹closedin (top_of_set U) W› (*‹closedin (top_of_set U) W›*) closedin_subset_trans (*‹⟦closedin (top_of_set ?U) ?S; ?S ⊆ ?T; ?T ⊆ ?U⟧ ⟹ closedin (top_of_set ?T) ?S›*) by fastforce show "closedin (top_of_set (W ∪ (S ∪ T))) (S ∪ T)" by (meson ‹S ⊆ U› ‹T ⊆ U› ‹W ⊆ U› assms (*‹closedin (top_of_set U) S› ‹closedin (top_of_set U) T› ‹AR S› ‹AR T› ‹AR (S ∩ T)›*) closedin_Un (*‹⟦closedin ?U ?S; closedin ?U ?T⟧ ⟹ closedin ?U (?S ∪ ?T)›*) closedin_subset_trans (*‹⟦closedin (top_of_set ?U) ?S; ?S ⊆ ?T; ?T ⊆ ?U⟧ ⟹ closedin (top_of_set ?T) ?S›*) sup.bounded_iff (*‹(sup ?b ?c ≤ ?a) = (?b ≤ ?a ∧ ?c ≤ ?a)›*) sup.cobounded2 (*‹?b ≤ sup ?a ?b›*)) show "⋀x. x ∈ W ∧ x ∉ W ∨ x ∈ S ∪ T ∧ x ∈ W ⟹ r0 x = x" by (auto simp: ST (*‹?x ∈ W ⟹ (?x ∈ S) = (?x ∈ T)›*)) qed have rim: "r ` (W ∪ S) ⊆ S" "r ` (W ∪ T) ⊆ T" using ‹r0 ` W ⊆ S ∩ T› (*‹r0 ` W ⊆ S ∩ T›*) r_def (*‹r::'a ⇒ 'a ≡ λx::'a. if x ∈ (W::'a set) then (r0::'a ⇒ 'a) x else x›*) apply - (*goals: 1. ‹⟦r0 ` W ⊆ S ∩ T; r ≡ λx. if x ∈ W then r0 x else x⟧ ⟹ r ` (W ∪ S) ⊆ S› 2. ‹⟦r0 ` W ⊆ S ∩ T; r ≡ λx. if x ∈ W then r0 x else x⟧ ⟹ r ` (W ∪ T) ⊆ T› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . have cloUWS: "closedin (top_of_set U) (W ∪ S)" by (simp add: cloUW (*‹closedin (top_of_set U) W›*) assms (*‹closedin (top_of_set U) S› ‹closedin (top_of_set U) T› ‹AR S› ‹AR T› ‹AR (S ∩ T)›*) closedin_Un (*‹⟦closedin ?U ?S; closedin ?U ?T⟧ ⟹ closedin ?U (?S ∪ ?T)›*)) obtain g where contg: "continuous_on U g" and "g ` U ⊆ S" and geqr: "⋀x. x ∈ W ∪ S ⟹ g x = r x" (*goal: ‹(⋀g. ⟦continuous_on U g; g ` U ⊆ S; ⋀x. x ∈ W ∪ S ⟹ g x = r x⟧ ⟹ thesis) ⟹ thesis›*) proof (rule AR_imp_absolute_extensor [OF ‹AR S› _ _ cloUWS] (*‹⟦continuous_on (W ∪ S) ?f; ?f ` (W ∪ S) ⊆ S; ⋀g. ⟦continuous_on U g; g ` U ⊆ S; ⋀x. x ∈ W ∪ S ⟹ g x = ?f x⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*)) (*goals: 1. ‹(⋀g. ⟦continuous_on U g; g ` U ⊆ S; ⋀x. x ∈ W ∪ S ⟹ g x = r x⟧ ⟹ thesis) ⟹ continuous_on (W ∪ S) ?f2› 2. ‹(⋀g. ⟦continuous_on U g; g ` U ⊆ S; ⋀x. x ∈ W ∪ S ⟹ g x = r x⟧ ⟹ thesis) ⟹ ?f2 ` (W ∪ S) ⊆ S› 3. ‹⋀g. ⟦⋀g. ⟦continuous_on U g; g ` U ⊆ S; ⋀x. x ∈ W ∪ S ⟹ g x = r x⟧ ⟹ thesis; continuous_on U g; g ` U ⊆ S; ⋀x. x ∈ W ∪ S ⟹ g x = ?f2 x⟧ ⟹ thesis›*) show "continuous_on (W ∪ S) r" using continuous_on_subset (*‹⟦continuous_on ?s ?f; ?t ⊆ ?s⟧ ⟹ continuous_on ?t ?f›*) contr (*‹continuous_on (W ∪ (S ∪ T)) r›*) sup_assoc (*‹sup (sup ?x ?y) ?z = sup ?x (sup ?y ?z)›*) by blast qed (use rim in auto) (*solves the remaining goals: 1. ‹(⋀g. ⟦continuous_on U g; g ` U ⊆ S; ⋀x. x ∈ W ∪ S ⟹ g x = r x⟧ ⟹ thesis) ⟹ r ` (W ∪ S) ⊆ S› 2. ‹⋀g. ⟦⋀g. ⟦continuous_on U g; g ` U ⊆ S; ⋀x. x ∈ W ∪ S ⟹ g x = r x⟧ ⟹ thesis; continuous_on U g; g ` U ⊆ S; ⋀x. x ∈ W ∪ S ⟹ g x = r x⟧ ⟹ thesis›*) have cloUWT: "closedin (top_of_set U) (W ∪ T)" by (simp add: cloUW (*‹closedin (top_of_set U) W›*) assms (*‹closedin (top_of_set U) S› ‹closedin (top_of_set U) T› ‹AR S› ‹AR T› ‹AR (S ∩ T)›*) closedin_Un (*‹⟦closedin ?U ?S; closedin ?U ?T⟧ ⟹ closedin ?U (?S ∪ ?T)›*)) obtain h where conth: "continuous_on U h" and "h ` U ⊆ T" and heqr: "⋀x. x ∈ W ∪ T ⟹ h x = r x" (*goal: ‹(⋀h. ⟦continuous_on U h; h ` U ⊆ T; ⋀x. x ∈ W ∪ T ⟹ h x = r x⟧ ⟹ thesis) ⟹ thesis›*) proof (rule AR_imp_absolute_extensor [OF ‹AR T› _ _ cloUWT] (*‹⟦continuous_on (W ∪ T) ?f; ?f ` (W ∪ T) ⊆ T; ⋀g. ⟦continuous_on U g; g ` U ⊆ T; ⋀x. x ∈ W ∪ T ⟹ g x = ?f x⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*)) (*goals: 1. ‹(⋀h. ⟦continuous_on U h; h ` U ⊆ T; ⋀x. x ∈ W ∪ T ⟹ h x = r x⟧ ⟹ thesis) ⟹ continuous_on (W ∪ T) ?f2› 2. ‹(⋀h. ⟦continuous_on U h; h ` U ⊆ T; ⋀x. x ∈ W ∪ T ⟹ h x = r x⟧ ⟹ thesis) ⟹ ?f2 ` (W ∪ T) ⊆ T› 3. ‹⋀g. ⟦⋀h. ⟦continuous_on U h; h ` U ⊆ T; ⋀x. x ∈ W ∪ T ⟹ h x = r x⟧ ⟹ thesis; continuous_on U g; g ` U ⊆ T; ⋀x. x ∈ W ∪ T ⟹ g x = ?f2 x⟧ ⟹ thesis›*) show "continuous_on (W ∪ T) r" using continuous_on_subset (*‹⟦continuous_on (?s::?'a set) (?f::?'a ⇒ ?'b); (?t::?'a set) ⊆ ?s⟧ ⟹ continuous_on ?t ?f›*) contr (*‹continuous_on (W ∪ (S ∪ T)) r›*) sup_assoc (*‹sup (sup ?x ?y) ?z = sup ?x (sup ?y ?z)›*) by blast qed (use rim in auto) (*solves the remaining goals: 1. ‹(⋀h. ⟦continuous_on U h; h ` U ⊆ T; ⋀x. x ∈ W ∪ T ⟹ h x = r x⟧ ⟹ thesis) ⟹ r ` (W ∪ T) ⊆ T› 2. ‹⋀g. ⟦⋀h. ⟦continuous_on U h; h ` U ⊆ T; ⋀x. x ∈ W ∪ T ⟹ h x = r x⟧ ⟹ thesis; continuous_on U g; g ` U ⊆ T; ⋀x. x ∈ W ∪ T ⟹ g x = r x⟧ ⟹ thesis›*) have U: "U = S' ∪ T'" by (force simp: S'_def (*‹S' ≡ {x ∈ U. setdist {x} S ≤ setdist {x} T}›*) T'_def (*‹T' ≡ {x ∈ U. setdist {x} T ≤ setdist {x} S}›*)) have cont: "continuous_on U (λx. if x ∈ S' then g x else h x)" unfolding U (*goal: ‹continuous_on (S' ∪ T') (λx. if x ∈ S' then g x else h x)›*) apply (rule continuous_on_cases_local (*‹⟦closedin (top_of_set (?S ∪ ?T)) ?S; closedin (top_of_set (?S ∪ ?T)) ?T; continuous_on ?S ?f; continuous_on ?T ?g; ⋀x. x ∈ ?S ∧ ¬ ?P x ∨ x ∈ ?T ∧ ?P x ⟹ ?f x = ?g x⟧ ⟹ continuous_on (?S ∪ ?T) (λx. if ?P x then ?f x else ?g x)›*)) (*goal: ‹continuous_on ((S'::'a set) ∪ (T'::'a set)) (λx::'a. if x ∈ S' then (g::'a ⇒ 'a) x else (h::'a ⇒ 'a) x)›*) using US' (*‹closedin (top_of_set U) S'›*) UT' (*‹closedin (top_of_set U) T'›*) ‹S' ∩ T' = W› (*‹S' ∩ T' = W›*) ‹U = S' ∪ T'› (*‹U = S' ∪ T'›*) contg (*‹continuous_on U g›*) conth (*‹continuous_on U h›*) continuous_on_subset (*‹⟦continuous_on ?s ?f; ?t ⊆ ?s⟧ ⟹ continuous_on ?t ?f›*) geqr (*‹?x ∈ W ∪ S ⟹ g ?x = r ?x›*) heqr (*‹?x ∈ W ∪ T ⟹ h ?x = r ?x›*) apply - (*goals: 1. ‹⟦closedin (top_of_set U) S'; closedin (top_of_set U) T'; S' ∩ T' = W; U = S' ∪ T'; continuous_on U g; continuous_on U h; ⋀s f t. ⟦continuous_on s f; t ⊆ s⟧ ⟹ continuous_on t f; ⋀x. x ∈ W ∪ S ⟹ g x = r x; ⋀x. x ∈ W ∪ T ⟹ h x = r x⟧ ⟹ closedin (top_of_set (S' ∪ T')) S'› 2. ‹⟦closedin (top_of_set U) S'; closedin (top_of_set U) T'; S' ∩ T' = W; U = S' ∪ T'; continuous_on U g; continuous_on U h; ⋀s f t. ⟦continuous_on s f; t ⊆ s⟧ ⟹ continuous_on t f; ⋀x. x ∈ W ∪ S ⟹ g x = r x; ⋀x. x ∈ W ∪ T ⟹ h x = r x⟧ ⟹ closedin (top_of_set (S' ∪ T')) T'› 3. ‹⟦closedin (top_of_set U) S'; closedin (top_of_set U) T'; S' ∩ T' = W; U = S' ∪ T'; continuous_on U g; continuous_on U h; ⋀s f t. ⟦continuous_on s f; t ⊆ s⟧ ⟹ continuous_on t f; ⋀x. x ∈ W ∪ S ⟹ g x = r x; ⋀x. x ∈ W ∪ T ⟹ h x = r x⟧ ⟹ continuous_on S' g› 4. ‹⟦closedin (top_of_set U) S'; closedin (top_of_set U) T'; S' ∩ T' = W; U = S' ∪ T'; continuous_on U g; continuous_on U h; ⋀s f t. ⟦continuous_on s f; t ⊆ s⟧ ⟹ continuous_on t f; ⋀x. x ∈ W ∪ S ⟹ g x = r x; ⋀x. x ∈ W ∪ T ⟹ h x = r x⟧ ⟹ continuous_on T' h› 5. ‹⋀x. ⟦x ∈ S' ∧ x ∉ S' ∨ x ∈ T' ∧ x ∈ S'; closedin (top_of_set U) S'; closedin (top_of_set U) T'; S' ∩ T' = W; U = S' ∪ T'; continuous_on U g; continuous_on U h; ⋀s f t. ⟦continuous_on s f; t ⊆ s⟧ ⟹ continuous_on t f; ⋀x. x ∈ W ∪ S ⟹ g x = r x; ⋀x. x ∈ W ∪ T ⟹ h x = r x⟧ ⟹ g x = h 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*) . have UST: "(λx. if x ∈ S' then g x else h x) ` U ⊆ S ∪ T" using ‹g ` U ⊆ S› (*‹g ` U ⊆ S›*) ‹h ` U ⊆ T› (*‹h ` U ⊆ T›*) by auto show "?thesis" (*goal: ‹(S::'a::euclidean_space set) ∪ (T::'a::euclidean_space set) retract_of (U::'a::euclidean_space set)›*) apply (simp add: retract_of_def (*‹((?T::?'a::topological_space set) retract_of (?S::?'a::topological_space set)) = (∃r::?'a::topological_space ⇒ ?'a::topological_space. retraction ?S ?T r)›*) retraction_def (*‹retraction (?S::?'a::topological_space set) (?T::?'a::topological_space set) (?r::?'a::topological_space ⇒ ?'a::topological_space) = (?T ⊆ ?S ∧ continuous_on ?S ?r ∧ ?r ∈ ?S → ?T ∧ (∀x::?'a::topological_space∈?T. ?r x = x))›*) ‹S ⊆ U› ‹T ⊆ U›) (*goal: ‹(S::'a set) ∪ (T::'a set) retract_of (U::'a set)›*) apply (rule_tac x="λx. if x ∈ S' then g x else h x" in exI (*‹?P ?x ⟹ ∃x. ?P x›*)) (*goal: ‹∃r. continuous_on U r ∧ r ∈ U → S ∪ T ∧ (∀x∈S ∪ T. r x = x)›*) using ST (*‹?x ∈ W ⟹ (?x ∈ S) = (?x ∈ T)›*) UST (*‹(λx::'a. if x ∈ (S'::'a set) then (g::'a ⇒ 'a) x else (h::'a ⇒ 'a) x) ` (U::'a set) ⊆ (S::'a set) ∪ (T::'a set)›*) ‹S ⊆ S'› (*‹S ⊆ S'›*) ‹S' ∩ T' = W› (*‹(S'::'a set) ∩ (T'::'a set) = (W::'a set)›*) ‹T ⊆ T'› (*‹T ⊆ T'›*) cont (*‹continuous_on U (λx. if x ∈ S' then g x else h x)›*) geqr (*‹?x ∈ W ∪ S ⟹ g ?x = r ?x›*) heqr (*‹(?x::'a) ∈ (W::'a set) ∪ (T::'a set) ⟹ (h::'a ⇒ 'a) ?x = (r::'a ⇒ 'a) ?x›*) r_def (*‹r ≡ λx. if x ∈ W then r0 x else x›*) by (smt (verit, del_insts) IntI (*‹⟦?c ∈ ?A; ?c ∈ ?B⟧ ⟹ ?c ∈ ?A ∩ ?B›*) Pi_I (*‹(⋀x. x ∈ ?A ⟹ ?f x ∈ ?B x) ⟹ ?f ∈ Pi ?A ?B›*) Un_iff (*‹(?c ∈ ?A ∪ ?B) = (?c ∈ ?A ∨ ?c ∈ ?B)›*) image_subset_iff (*‹(?f ` ?A ⊆ ?B) = (∀x∈?A. ?f x ∈ ?B)›*) r0 (*‹?x ∈ S ∩ T ⟹ r0 ?x = ?x›*) subsetD (*‹⟦?A ⊆ ?B; ?c ∈ ?A⟧ ⟹ ?c ∈ ?B›*)) qed lemma AR_closed_Un_local: fixes S :: "'a::euclidean_space set" assumes STS: "closedin (top_of_set (S ∪ T)) S" and STT: "closedin (top_of_set (S ∪ T)) T" and "AR S" "AR T" "AR(S ∩ T)" shows "AR(S ∪ T)" proof (-) (*goal: ‹AR (S ∪ T)›*) have "C retract_of U" if hom: "S ∪ T homeomorphic C" and UC: "closedin (top_of_set U) C" for U and C :: "('a * real) set" proof (-) (*goal: ‹C retract_of U›*) obtain f and g where hom: "homeomorphism (S ∪ T) C f g" (*goal: ‹(⋀f g. homeomorphism (S ∪ T) C f g ⟹ thesis) ⟹ thesis›*) using hom (*‹S ∪ T homeomorphic C›*) by (force simp: homeomorphic_def (*‹?s homeomorphic ?t ≡ ∃f g. homeomorphism ?s ?t f g›*)) have US: "closedin (top_of_set U) (C ∩ g -` S)" by (metis STS (*‹closedin (top_of_set (S ∪ T)) S›*) continuous_on_imp_closedin (*‹⟦continuous_on ?S ?f; closedin (top_of_set (?f ` ?S)) ?T⟧ ⟹ closedin (top_of_set ?S) (?S ∩ ?f -` ?T)›*) hom (*‹homeomorphism (S ∪ T) C f g›*) homeomorphism_def (*‹homeomorphism ?S ?T ?f ?g = ((∀x∈?S. ?g (?f x) = x) ∧ ?f ` ?S = ?T ∧ continuous_on ?S ?f ∧ (∀y∈?T. ?f (?g y) = y) ∧ ?g ` ?T = ?S ∧ continuous_on ?T ?g)›*) closedin_trans [OF _ UC] (*‹closedin (top_of_set C) ?S ⟹ closedin (top_of_set U) ?S›*)) have UT: "closedin (top_of_set U) (C ∩ g -` T)" by (metis STT (*‹closedin (top_of_set (S ∪ T)) T›*) continuous_on_closed (*‹continuous_on ?S ?f = (∀T. closedin (top_of_set (?f ` ?S)) T ⟶ closedin (top_of_set ?S) (?S ∩ ?f -` T))›*) hom (*‹homeomorphism (S ∪ T) C f g›*) homeomorphism_def (*‹homeomorphism ?S ?T ?f ?g = ((∀x∈?S. ?g (?f x) = x) ∧ ?f ` ?S = ?T ∧ continuous_on ?S ?f ∧ (∀y∈?T. ?f (?g y) = y) ∧ ?g ` ?T = ?S ∧ continuous_on ?T ?g)›*) closedin_trans [OF _ UC] (*‹closedin (top_of_set C) ?S ⟹ closedin (top_of_set U) ?S›*)) have "homeomorphism (C ∩ g -` S) S g f" using hom (*‹homeomorphism (S ∪ T) C f g›*) apply (auto simp: homeomorphism_def (*‹homeomorphism ?S ?T ?f ?g = ((∀x∈?S. ?g (?f x) = x) ∧ ?f ` ?S = ?T ∧ continuous_on ?S ?f ∧ (∀y∈?T. ?f (?g y) = y) ∧ ?g ` ?T = ?S ∧ continuous_on ?T ?g)›*) elim!: continuous_on_subset (*‹⟦continuous_on ?s ?f; ?t ⊆ ?s⟧ ⟹ continuous_on ?t ?f›*)) (*goal: ‹homeomorphism (C ∩ g -` S) S g f›*) apply (rule_tac x="f x" in image_eqI (*‹⟦?b = ?f ?x; ?x ∈ ?A⟧ ⟹ ?b ∈ ?f ` ?A›*)) (*goals: 1. ‹⋀x. ⟦∀x∈S ∪ T. g (f x) = x; C = f ` (S ∪ T); continuous_on (S ∪ T) f; g ` f ` (S ∪ T) = S ∪ T; continuous_on (f ` (S ∪ T)) g; x ∈ S⟧ ⟹ x = g (f x)› 2. ‹⋀x. ⟦∀x∈S ∪ T. g (f x) = x; C = f ` (S ∪ T); continuous_on (S ∪ T) f; g ` f ` (S ∪ T) = S ∪ T; continuous_on (f ` (S ∪ T)) g; x ∈ S⟧ ⟹ f x ∈ f ` (S ∪ T) ∩ g -` S› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . then have ARS: "AR (C ∩ g -` S)" using ‹AR S› (*‹AR (S::'a::euclidean_space set)›*) homeomorphic_AR_iff_AR (*‹(?S::?'a set) homeomorphic (?T::?'b set) ⟹ AR ?S = AR ?T›*) homeomorphic_def (*‹?s homeomorphic ?t ≡ ∃f g. homeomorphism ?s ?t f g›*) by blast have "homeomorphism (C ∩ g -` T) T g f" using hom (*‹homeomorphism (S ∪ T) C f g›*) apply (auto simp: homeomorphism_def (*‹homeomorphism ?S ?T ?f ?g = ((∀x∈?S. ?g (?f x) = x) ∧ ?f ` ?S = ?T ∧ continuous_on ?S ?f ∧ (∀y∈?T. ?f (?g y) = y) ∧ ?g ` ?T = ?S ∧ continuous_on ?T ?g)›*) elim!: continuous_on_subset (*‹⟦continuous_on ?s ?f; ?t ⊆ ?s⟧ ⟹ continuous_on ?t ?f›*)) (*goal: ‹homeomorphism (C ∩ g -` T) T g f›*) apply (rule_tac x="f x" in image_eqI (*‹⟦?b = ?f ?x; ?x ∈ ?A⟧ ⟹ ?b ∈ ?f ` ?A›*)) (*goals: 1. ‹⋀x. ⟦∀x∈S ∪ T. g (f x) = x; C = f ` (S ∪ T); continuous_on (S ∪ T) f; g ` f ` (S ∪ T) = S ∪ T; continuous_on (f ` (S ∪ T)) g; x ∈ T⟧ ⟹ x = g (f x)› 2. ‹⋀x. ⟦∀x∈S ∪ T. g (f x) = x; C = f ` (S ∪ T); continuous_on (S ∪ T) f; g ` f ` (S ∪ T) = S ∪ T; continuous_on (f ` (S ∪ T)) g; x ∈ T⟧ ⟹ f x ∈ f ` (S ∪ T) ∩ g -` T› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . then have ART: "AR (C ∩ g -` T)" using ‹AR T› (*‹AR T›*) homeomorphic_AR_iff_AR (*‹?S homeomorphic ?T ⟹ AR ?S = AR ?T›*) homeomorphic_def (*‹(?s::?'a::topological_space set) homeomorphic (?t::?'b::topological_space set) ≡ ∃(f::?'a::topological_space ⇒ ?'b::topological_space) g::?'b::topological_space ⇒ ?'a::topological_space. homeomorphism ?s ?t f g›*) by blast have "homeomorphism (C ∩ g -` S ∩ (C ∩ g -` T)) (S ∩ T) g f" using hom (*‹homeomorphism ((S::'a::euclidean_space set) ∪ (T::'a::euclidean_space set)) (C::('a::euclidean_space × real) set) (f::'a::euclidean_space ⇒ 'a::euclidean_space × real) (g::'a::euclidean_space × real ⇒ 'a::euclidean_space)›*) apply (auto simp: homeomorphism_def (*‹homeomorphism ?S ?T ?f ?g = ((∀x∈?S. ?g (?f x) = x) ∧ ?f ` ?S = ?T ∧ continuous_on ?S ?f ∧ (∀y∈?T. ?f (?g y) = y) ∧ ?g ` ?T = ?S ∧ continuous_on ?T ?g)›*) elim!: continuous_on_subset (*‹⟦continuous_on ?s ?f; ?t ⊆ ?s⟧ ⟹ continuous_on ?t ?f›*)) (*goal: ‹homeomorphism (C ∩ g -` S ∩ (C ∩ g -` T)) (S ∩ T) g f›*) apply (rule_tac x="f x" in image_eqI (*‹⟦?b = ?f ?x; ?x ∈ ?A⟧ ⟹ ?b ∈ ?f ` ?A›*)) (*goals: 1. ‹⋀x. ⟦∀x∈S ∪ T. g (f x) = x; C = f ` (S ∪ T); continuous_on (S ∪ T) f; g ` f ` (S ∪ T) = S ∪ T; continuous_on (f ` (S ∪ T)) g; x ∈ S; x ∈ T⟧ ⟹ x = g (f x)› 2. ‹⋀x. ⟦∀x∈S ∪ T. g (f x) = x; C = f ` (S ∪ T); continuous_on (S ∪ T) f; g ` f ` (S ∪ T) = S ∪ T; continuous_on (f ` (S ∪ T)) g; x ∈ S; x ∈ T⟧ ⟹ f x ∈ f ` (S ∪ T) ∩ g -` S ∩ (f ` (S ∪ T) ∩ g -` T)› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . then have ARI: "AR ((C ∩ g -` S) ∩ (C ∩ g -` T))" using ‹AR (S ∩ T)› (*‹AR ((S::'a set) ∩ (T::'a set))›*) homeomorphic_AR_iff_AR (*‹?S homeomorphic ?T ⟹ AR ?S = AR ?T›*) homeomorphic_def (*‹?s homeomorphic ?t ≡ ∃f g. homeomorphism ?s ?t f g›*) by blast have "C = (C ∩ g -` S) ∪ (C ∩ g -` T)" using hom (*‹homeomorphism ((S::'a set) ∪ (T::'a set)) (C::('a × real) set) (f::'a ⇒ 'a × real) (g::'a × real ⇒ 'a)›*) by (auto simp: homeomorphism_def (*‹homeomorphism ?S ?T ?f ?g = ((∀x∈?S. ?g (?f x) = x) ∧ ?f ` ?S = ?T ∧ continuous_on ?S ?f ∧ (∀y∈?T. ?f (?g y) = y) ∧ ?g ` ?T = ?S ∧ continuous_on ?T ?g)›*)) then show "?thesis" (*goal: ‹C retract_of U›*) by (metis AR_closed_Un_local_aux [OF US UT ARS ART ARI] (*‹C ∩ g -` S ∪ C ∩ g -` T retract_of U›*)) qed then show "?thesis" (*goal: ‹AR ((S::'a set) ∪ (T::'a set))›*) by (force simp: AR_def (*‹AR ?S ≡ ∀U S'. ?S homeomorphic S' ∧ closedin (top_of_set U) S' ⟶ S' retract_of U›*)) qed corollary AR_closed_Un: fixes S :: "'a::euclidean_space set" shows "⟦closed S; closed T; AR S; AR T; AR (S ∩ T)⟧ ⟹ AR (S ∪ T)" by (metis AR_closed_Un_local_aux (*‹⟦closedin (top_of_set ?U) ?S; closedin (top_of_set ?U) ?T; AR ?S; AR ?T; AR (?S ∩ ?T)⟧ ⟹ ?S ∪ ?T retract_of ?U›*) closed_closedin (*‹closed ?S = closedin euclidean ?S›*) retract_of_UNIV (*‹(?S retract_of UNIV) = (AR ?S ∧ closed ?S)›*) subtopology_UNIV (*‹subtopology ?U UNIV = ?U›*)) text ‹ANRs closed under union› lemma ANR_closed_Un_local_aux: fixes U :: "'a::euclidean_space set" assumes US: "closedin (top_of_set U) S" and UT: "closedin (top_of_set U) T" and "ANR S" "ANR T" "ANR(S ∩ T)" obtains V where "openin (top_of_set U) V" "(S ∪ T) retract_of V" proof (cases "S = {} ∨ T = {}") (*goals: 1. ‹⟦⋀V::'a set. ⟦openin (top_of_set (U::'a set)) V; (S::'a set) ∪ (T::'a set) retract_of V⟧ ⟹ thesis::bool; S = {} ∨ T = {}⟧ ⟹ thesis› 2. ‹⟦⋀V::'a set. ⟦openin (top_of_set (U::'a set)) V; (S::'a set) ∪ (T::'a set) retract_of V⟧ ⟹ thesis::bool; ¬ (S = {} ∨ T = {})⟧ ⟹ thesis›*) case True (*‹S = {} ∨ T = {}›*) with assms (*‹closedin (top_of_set U) S› ‹closedin (top_of_set U) T› ‹ANR (S::'a set)› ‹ANR T› ‹ANR (S ∩ T)›*) that (*‹⟦openin (top_of_set U) ?V; S ∪ T retract_of ?V⟧ ⟹ thesis›*) show "?thesis" (*goal: ‹thesis›*) by (metis ANR_imp_neighbourhood_retract (*‹⟦ANR ?S; closedin (top_of_set ?U) ?S; ⋀V. ⟦openin (top_of_set ?U) V; ?S retract_of V⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*) Un_commute (*‹?A ∪ ?B = ?B ∪ ?A›*) inf_bot_right (*‹inf ?x bot = bot›*) sup_inf_absorb (*‹sup ?x (inf ?x ?y) = ?x›*)) next (*goal: ‹⟦⋀V. ⟦openin (top_of_set U) V; S ∪ T retract_of V⟧ ⟹ thesis; ¬ (S = {} ∨ T = {})⟧ ⟹ thesis›*) case False (*‹¬ (S = {} ∨ T = {})›*) then have [simp]: "S ≠ {}" "T ≠ {}" apply - (*goals: 1. ‹¬ (S = {} ∨ T = {}) ⟹ S ≠ {}› 2. ‹¬ (S = {} ∨ T = {}) ⟹ T ≠ {}› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . have "S ⊆ U" "T ⊆ U" using assms (*‹closedin (top_of_set U) S› ‹closedin (top_of_set U) T› ‹ANR (S::'a set)› ‹ANR (T::'a set)› ‹ANR ((S::'a set) ∩ (T::'a set))›*) apply - (*goals: 1. ‹⟦closedin (top_of_set U) S; closedin (top_of_set U) T; ANR S; ANR T; ANR (S ∩ T)⟧ ⟹ S ⊆ U› 2. ‹⟦closedin (top_of_set U) S; closedin (top_of_set U) T; ANR S; ANR T; ANR (S ∩ T)⟧ ⟹ T ⊆ U› discuss goal 1*) apply ((auto simp: closedin_imp_subset (*‹closedin (subtopology ?U ?S) ?T ⟹ ?T ⊆ ?S›*))[1]) (*discuss goal 2*) apply ((auto simp: closedin_imp_subset (*‹closedin (subtopology ?U ?S) ?T ⟹ ?T ⊆ ?S›*))[1]) (*proven 2 subgoals*) . define S' where "S' ≡ {x ∈ U. setdist {x} S ≤ setdist {x} T}" define T' where "T' ≡ {x ∈ U. setdist {x} T ≤ setdist {x} S}" define W where "W ≡ {x ∈ U. setdist {x} S = setdist {x} T}" have cloUS': "closedin (top_of_set U) S'" using continuous_closedin_preimage[of U "λx. setdist {x} S - setdist {x} T" "{..0}"] (*‹⟦continuous_on U (λx. setdist {x} S - setdist {x} T); closed {..0}⟧ ⟹ closedin (top_of_set U) (U ∩ (λx. setdist {x} S - setdist {x} T) -` {..0})›*) by (simp add: S'_def (*‹S' ≡ {x ∈ U. setdist {x} S ≤ setdist {x} T}›*) vimage_def (*‹?f -` ?B ≡ {x. ?f x ∈ ?B}›*) Collect_conj_eq (*‹{x. ?P x ∧ ?Q x} = {x. ?P x} ∩ {x. ?Q x}›*) continuous_on_diff (*‹⟦continuous_on ?s ?f; continuous_on ?s ?g⟧ ⟹ continuous_on ?s (λx. ?f x - ?g x)›*) continuous_on_setdist (*‹continuous_on ?T (λy. setdist {y} ?S)›*)) have cloUT': "closedin (top_of_set U) T'" using continuous_closedin_preimage[of U "λx. setdist {x} T - setdist {x} S" "{..0}"] (*‹⟦continuous_on (U::'a set) (λx::'a. setdist {x} (T::'a set) - setdist {x} (S::'a set)); closed {..0::real}⟧ ⟹ closedin (top_of_set U) (U ∩ (λx::'a. setdist {x} T - setdist {x} S) -` {..0::real})›*) by (simp add: T'_def (*‹T' ≡ {x ∈ U. setdist {x} T ≤ setdist {x} S}›*) vimage_def (*‹?f -` ?B ≡ {x. ?f x ∈ ?B}›*) Collect_conj_eq (*‹{x. ?P x ∧ ?Q x} = {x. ?P x} ∩ {x. ?Q x}›*) continuous_on_diff (*‹⟦continuous_on ?s ?f; continuous_on ?s ?g⟧ ⟹ continuous_on ?s (λx. ?f x - ?g x)›*) continuous_on_setdist (*‹continuous_on ?T (λy. setdist {y} ?S)›*)) have "S ⊆ S'" using S'_def (*‹S' ≡ {x ∈ U. setdist {x} S ≤ setdist {x} T}›*) ‹S ⊆ U› (*‹(S::'a::euclidean_space set) ⊆ (U::'a::euclidean_space set)›*) setdist_sing_in_set (*‹(?x::?'a) ∈ (?S::?'a set) ⟹ setdist {?x} ?S = (0::real)›*) by fastforce have "T ⊆ T'" using T'_def (*‹T'::'a::euclidean_space set ≡ {x::'a::euclidean_space ∈ U::'a::euclidean_space set. setdist {x} (T::'a::euclidean_space set) ≤ setdist {x} (S::'a::euclidean_space set)}›*) ‹T ⊆ U› (*‹T ⊆ U›*) setdist_sing_in_set (*‹?x ∈ ?S ⟹ setdist {?x} ?S = 0›*) by fastforce have "S' ∪ T' = U" by (auto simp: S'_def (*‹S' ≡ {x ∈ U. setdist {x} S ≤ setdist {x} T}›*) T'_def (*‹T' ≡ {x ∈ U. setdist {x} T ≤ setdist {x} S}›*)) have "W ⊆ S'" by (simp add: Collect_mono (*‹(⋀x. ?P x ⟶ ?Q x) ⟹ Collect ?P ⊆ Collect ?Q›*) S'_def (*‹S' ≡ {x ∈ U. setdist {x} S ≤ setdist {x} T}›*) W_def (*‹W ≡ {x ∈ U. setdist {x} S = setdist {x} T}›*)) have "W ⊆ T'" by (simp add: Collect_mono (*‹(⋀x. ?P x ⟶ ?Q x) ⟹ Collect ?P ⊆ Collect ?Q›*) T'_def (*‹T' ≡ {x ∈ U. setdist {x} T ≤ setdist {x} S}›*) W_def (*‹W ≡ {x ∈ U. setdist {x} S = setdist {x} T}›*)) have ST_W: "S ∩ T ⊆ W" and "W ⊆ U" using ‹S ⊆ U› (*‹(S::'a set) ⊆ (U::'a set)›*) (*goals: 1. ‹S ∩ T ⊆ W› 2. ‹W ⊆ U› discuss goal 1*) apply (force simp: W_def (*‹W ≡ {x ∈ U. setdist {x} S = setdist {x} T}›*) setdist_sing_in_set (*‹?x ∈ ?S ⟹ setdist {?x} ?S = 0›*)) (*discuss goal 2*) apply (force simp: W_def (*‹W ≡ {x ∈ U. setdist {x} S = setdist {x} T}›*) setdist_sing_in_set (*‹?x ∈ ?S ⟹ setdist {?x} ?S = 0›*)) (*proven 2 subgoals*) . have "S' ∩ T' = W" by (auto simp: S'_def (*‹S'::'a set ≡ {x::'a ∈ U::'a set. setdist {x} (S::'a set) ≤ setdist {x} (T::'a set)}›*) T'_def (*‹T'::'a set ≡ {x::'a ∈ U::'a set. setdist {x} (T::'a set) ≤ setdist {x} (S::'a set)}›*) W_def (*‹W::'a set ≡ {x::'a ∈ U::'a set. setdist {x} (S::'a set) = setdist {x} (T::'a set)}›*)) then have cloUW: "closedin (top_of_set U) W" using closedin_Int (*‹⟦closedin ?U ?S; closedin ?U ?T⟧ ⟹ closedin ?U (?S ∩ ?T)›*) cloUS' (*‹closedin (top_of_set U) S'›*) cloUT' (*‹closedin (top_of_set U) T'›*) by blast obtain W' and W0 where "openin (top_of_set W) W'" and cloWW0: "closedin (top_of_set W) W0" and "S ∩ T ⊆ W'" "W' ⊆ W0" and ret: "(S ∩ T) retract_of W0" (*goal: ‹(⋀W' W0. ⟦openin (top_of_set W) W'; closedin (top_of_set W) W0; S ∩ T ⊆ W'; W' ⊆ W0; S ∩ T retract_of W0⟧ ⟹ thesis) ⟹ thesis›*) by (meson ANR_imp_closed_neighbourhood_retract (*‹⟦ANR ?S; closedin (top_of_set ?U) ?S; ⋀V W. ⟦openin (top_of_set ?U) V; closedin (top_of_set ?U) W; ?S ⊆ V; V ⊆ W; ?S retract_of W⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*) ST_W (*‹S ∩ T ⊆ W›*) US (*‹closedin (top_of_set U) S›*) UT (*‹closedin (top_of_set U) T›*) ‹W ⊆ U› ‹ANR(S ∩ T)› closedin_Int (*‹⟦closedin ?U ?S; closedin ?U ?T⟧ ⟹ closedin ?U (?S ∩ ?T)›*) closedin_subset_trans (*‹⟦closedin (top_of_set ?U) ?S; ?S ⊆ ?T; ?T ⊆ ?U⟧ ⟹ closedin (top_of_set ?T) ?S›*)) then obtain U0 where opeUU0: "openin (top_of_set U) U0" and U0: "S ∩ T ⊆ U0" "U0 ∩ W ⊆ W0" (*goal: ‹(⋀U0::'a::euclidean_space set. ⟦openin (top_of_set (U::'a::euclidean_space set)) U0; (S::'a::euclidean_space set) ∩ (T::'a::euclidean_space set) ⊆ U0; U0 ∩ (W::'a::euclidean_space set) ⊆ (W0::'a::euclidean_space set)⟧ ⟹ thesis::bool) ⟹ thesis›*) unfolding openin_open (*goal: ‹(⋀U0. ⟦∃T. open T ∧ U0 = U ∩ T; S ∩ T ⊆ U0; U0 ∩ W ⊆ W0⟧ ⟹ thesis) ⟹ thesis›*) using ‹W ⊆ U› (*‹(W::'a::euclidean_space set) ⊆ (U::'a::euclidean_space set)›*) by blast have "W0 ⊆ U" using ‹W ⊆ U› (*‹W ⊆ U›*) cloWW0 (*‹closedin (top_of_set W) W0›*) closedin_subset (*‹closedin ?U ?S ⟹ ?S ⊆ topspace ?U›*) by fastforce obtain r0 where "S ∩ T ⊆ W0" and contr0: "continuous_on W0 r0" and "r0 ∈ W0 → S ∩ T" and r0[simp]: "⋀x. x ∈ S ∩ T ⟹ r0 x = x" (*goal: ‹(⋀r0::'a ⇒ 'a. ⟦(S::'a set) ∩ (T::'a set) ⊆ (W0::'a set); continuous_on W0 r0; r0 ∈ W0 → S ∩ T; ⋀x::'a. x ∈ S ∩ T ⟹ r0 x = x⟧ ⟹ thesis::bool) ⟹ thesis›*) using ret (*‹S ∩ T retract_of W0›*) by (force simp: retract_of_def (*‹(?T retract_of ?S) = (∃r. retraction ?S ?T r)›*) retraction_def (*‹retraction ?S ?T ?r = (?T ⊆ ?S ∧ continuous_on ?S ?r ∧ ?r ∈ ?S → ?T ∧ (∀x∈?T. ?r x = x))›*)) have ST: "x ∈ W ⟹ x ∈ S ⟷ x ∈ T" for x using assms (*‹closedin (top_of_set U) S› ‹closedin (top_of_set (U::'a set)) (T::'a set)› ‹ANR S› ‹ANR (T::'a set)› ‹ANR (S ∩ T)›*) by (auto simp: W_def (*‹W ≡ {x ∈ U. setdist {x} S = setdist {x} T}›*) setdist_sing_in_set (*‹?x ∈ ?S ⟹ setdist {?x} ?S = 0›*) dest!: setdist_eq_0_closedin (*‹⟦closedin (top_of_set ?U) ?S; ?x ∈ ?U⟧ ⟹ (setdist {?x} ?S = 0) = (?S = {} ∨ ?x ∈ ?S)›*)) define r where "r ≡ λx. if x ∈ W0 then r0 x else x" have "r ` (W0 ∪ S) ⊆ S" "r ` (W0 ∪ T) ⊆ T" using ‹r0 ∈ W0 → S ∩ T› (*‹(r0::'a::euclidean_space ⇒ 'a::euclidean_space) ∈ (W0::'a::euclidean_space set) → (S::'a::euclidean_space set) ∩ (T::'a::euclidean_space set)›*) r_def (*‹r ≡ λx. if x ∈ W0 then r0 x else x›*) apply - (*goals: 1. ‹⟦(r0::'a ⇒ 'a) ∈ (W0::'a set) → (S::'a set) ∩ (T::'a set); r::'a ⇒ 'a ≡ λx::'a. if x ∈ W0 then r0 x else x⟧ ⟹ r ` (W0 ∪ S) ⊆ S› 2. ‹⟦(r0::'a ⇒ 'a) ∈ (W0::'a set) → (S::'a set) ∩ (T::'a set); r::'a ⇒ 'a ≡ λx::'a. if x ∈ W0 then r0 x else x⟧ ⟹ r ` (W0 ∪ T) ⊆ T› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . have contr: "continuous_on (W0 ∪ (S ∪ T)) r" unfolding r_def (*goal: ‹continuous_on (W0 ∪ (S ∪ T)) (λx. if x ∈ W0 then r0 x else x)›*) proof (rule continuous_on_cases_local [OF _ _ contr0 continuous_on_id] (*‹⟦closedin (top_of_set (W0 ∪ ?T)) W0; closedin (top_of_set (W0 ∪ ?T)) ?T; ⋀x. x ∈ W0 ∧ ¬ ?P x ∨ x ∈ ?T ∧ ?P x ⟹ r0 x = x⟧ ⟹ continuous_on (W0 ∪ ?T) (λx. if ?P x then r0 x else x)›*)) (*goals: 1. ‹closedin (top_of_set (W0 ∪ (S ∪ T))) W0› 2. ‹closedin (top_of_set (W0 ∪ (S ∪ T))) (S ∪ T)› 3. ‹⋀x. x ∈ W0 ∧ x ∉ W0 ∨ x ∈ S ∪ T ∧ x ∈ W0 ⟹ r0 x = x›*) show "closedin (top_of_set (W0 ∪ (S ∪ T))) W0" using closedin_subset_trans[of U] (*‹⟦closedin (top_of_set U) ?S; ?S ⊆ ?T; ?T ⊆ U⟧ ⟹ closedin (top_of_set ?T) ?S›*) by (metis le_sup_iff (*‹(sup ?x ?y ≤ ?z) = (?x ≤ ?z ∧ ?y ≤ ?z)›*) order_refl (*‹?x ≤ ?x›*) cloWW0 (*‹closedin (top_of_set W) W0›*) cloUW (*‹closedin (top_of_set U) W›*) closedin_trans (*‹⟦closedin (top_of_set ?T) ?S; closedin (top_of_set ?U) ?T⟧ ⟹ closedin (top_of_set ?U) ?S›*) ‹W0 ⊆ U› ‹S ⊆ U› ‹T ⊆ U›) show "closedin (top_of_set (W0 ∪ (S ∪ T))) (S ∪ T)" by (meson ‹S ⊆ U› ‹T ⊆ U› ‹W0 ⊆ U› assms (*‹closedin (top_of_set U) S› ‹closedin (top_of_set U) T› ‹ANR S› ‹ANR T› ‹ANR (S ∩ T)›*) closedin_Un (*‹⟦closedin ?U ?S; closedin ?U ?T⟧ ⟹ closedin ?U (?S ∪ ?T)›*) closedin_subset_trans (*‹⟦closedin (top_of_set ?U) ?S; ?S ⊆ ?T; ?T ⊆ ?U⟧ ⟹ closedin (top_of_set ?T) ?S›*) sup.bounded_iff (*‹(sup ?b ?c ≤ ?a) = (?b ≤ ?a ∧ ?c ≤ ?a)›*) sup.cobounded2 (*‹?b ≤ sup ?a ?b›*)) show "⋀x. x ∈ W0 ∧ x ∉ W0 ∨ x ∈ S ∪ T ∧ x ∈ W0 ⟹ r0 x = x" using ST (*‹?x ∈ W ⟹ (?x ∈ S) = (?x ∈ T)›*) cloWW0 (*‹closedin (top_of_set W) W0›*) closedin_subset (*‹closedin ?U ?S ⟹ ?S ⊆ topspace ?U›*) by fastforce qed have cloS'WS: "closedin (top_of_set S') (W0 ∪ S)" by (meson closedin_subset_trans (*‹⟦closedin (top_of_set ?U) ?S; ?S ⊆ ?T; ?T ⊆ ?U⟧ ⟹ closedin (top_of_set ?T) ?S›*) US (*‹closedin (top_of_set U) S›*) cloUS' (*‹closedin (top_of_set U) S'›*) ‹S ⊆ S'› ‹W ⊆ S'› cloUW (*‹closedin (top_of_set U) W›*) cloWW0 (*‹closedin (top_of_set W) W0›*) closedin_Un (*‹⟦closedin ?U ?S; closedin ?U ?T⟧ ⟹ closedin ?U (?S ∪ ?T)›*) closedin_imp_subset (*‹closedin (subtopology ?U ?S) ?T ⟹ ?T ⊆ ?S›*) closedin_trans (*‹⟦closedin (top_of_set ?T) ?S; closedin (top_of_set ?U) ?T⟧ ⟹ closedin (top_of_set ?U) ?S›*)) obtain W1 and g where "W0 ∪ S ⊆ W1" and contg: "continuous_on W1 g" and opeSW1: "openin (top_of_set S') W1" and "g ∈ W1 → S" and geqr: "⋀x. x ∈ W0 ∪ S ⟹ g x = r x" (*goal: ‹(⋀W1 g. ⟦W0 ∪ S ⊆ W1; continuous_on W1 g; openin (top_of_set S') W1; g ∈ W1 → S; ⋀x. x ∈ W0 ∪ S ⟹ g x = r x⟧ ⟹ thesis) ⟹ thesis›*) proof (rule ANR_imp_absolute_neighbourhood_extensor [OF ‹ANR S› _ _ cloS'WS] (*‹⟦continuous_on (W0 ∪ S) ?f; ?f ∈ W0 ∪ S → S; ⋀V g. ⟦W0 ∪ S ⊆ V; openin (top_of_set S') V; continuous_on V g; g ∈ V → S; ⋀x. x ∈ W0 ∪ S ⟹ g x = ?f x⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*)) (*goals: 1. ‹(⋀W1 g. ⟦W0 ∪ S ⊆ W1; continuous_on W1 g; openin (top_of_set S') W1; g ∈ W1 → S; ⋀x. x ∈ W0 ∪ S ⟹ g x = r x⟧ ⟹ thesis) ⟹ continuous_on (W0 ∪ S) ?f2› 2. ‹(⋀W1 g. ⟦W0 ∪ S ⊆ W1; continuous_on W1 g; openin (top_of_set S') W1; g ∈ W1 → S; ⋀x. x ∈ W0 ∪ S ⟹ g x = r x⟧ ⟹ thesis) ⟹ ?f2 ∈ W0 ∪ S → S› 3. ‹⋀V g. ⟦⋀W1 g. ⟦W0 ∪ S ⊆ W1; continuous_on W1 g; openin (top_of_set S') W1; g ∈ W1 → S; ⋀x. x ∈ W0 ∪ S ⟹ g x = r x⟧ ⟹ thesis; W0 ∪ S ⊆ V; openin (top_of_set S') V; continuous_on V g; g ∈ V → S; ⋀x. x ∈ W0 ∪ S ⟹ g x = ?f2 x⟧ ⟹ thesis›*) show "continuous_on (W0 ∪ S) r" using continuous_on_subset (*‹⟦continuous_on ?s ?f; ?t ⊆ ?s⟧ ⟹ continuous_on ?t ?f›*) contr (*‹continuous_on (W0 ∪ (S ∪ T)) r›*) sup_assoc (*‹sup (sup ?x ?y) ?z = sup ?x (sup ?y ?z)›*) by blast qed (use ‹r ` (W0 ∪ S) ⊆ S› in auto) (*solves the remaining goals: 1. ‹(⋀W1 g. ⟦W0 ∪ S ⊆ W1; continuous_on W1 g; openin (top_of_set S') W1; g ∈ W1 → S; ⋀x. x ∈ W0 ∪ S ⟹ g x = r x⟧ ⟹ thesis) ⟹ r ∈ W0 ∪ S → S› 2. ‹⋀V g. ⟦⋀W1 g. ⟦W0 ∪ S ⊆ W1; continuous_on W1 g; openin (top_of_set S') W1; g ∈ W1 → S; ⋀x. x ∈ W0 ∪ S ⟹ g x = r x⟧ ⟹ thesis; W0 ∪ S ⊆ V; openin (top_of_set S') V; continuous_on V g; g ∈ V → S; ⋀x. x ∈ W0 ∪ S ⟹ g x = r x⟧ ⟹ thesis›*) have cloT'WT: "closedin (top_of_set T') (W0 ∪ T)" by (meson closedin_subset_trans (*‹⟦closedin (top_of_set ?U) ?S; ?S ⊆ ?T; ?T ⊆ ?U⟧ ⟹ closedin (top_of_set ?T) ?S›*) UT (*‹closedin (top_of_set U) T›*) cloUT' (*‹closedin (top_of_set U) T'›*) ‹T ⊆ T'› ‹W ⊆ T'› cloUW (*‹closedin (top_of_set U) W›*) cloWW0 (*‹closedin (top_of_set W) W0›*) closedin_Un (*‹⟦closedin ?U ?S; closedin ?U ?T⟧ ⟹ closedin ?U (?S ∪ ?T)›*) closedin_imp_subset (*‹closedin (subtopology ?U ?S) ?T ⟹ ?T ⊆ ?S›*) closedin_trans (*‹⟦closedin (top_of_set ?T) ?S; closedin (top_of_set ?U) ?T⟧ ⟹ closedin (top_of_set ?U) ?S›*)) obtain W2 and h where "W0 ∪ T ⊆ W2" and conth: "continuous_on W2 h" and opeSW2: "openin (top_of_set T') W2" and "h ` W2 ⊆ T" and heqr: "⋀x. x ∈ W0 ∪ T ⟹ h x = r x" (*goal: ‹(⋀W2 h. ⟦W0 ∪ T ⊆ W2; continuous_on W2 h; openin (top_of_set T') W2; h ` W2 ⊆ T; ⋀x. x ∈ W0 ∪ T ⟹ h x = r x⟧ ⟹ thesis) ⟹ thesis›*) proof (rule ANR_imp_absolute_neighbourhood_extensor [OF ‹ANR T› _ _ cloT'WT] (*‹⟦continuous_on (W0 ∪ T) ?f; ?f ∈ W0 ∪ T → T; ⋀V g. ⟦W0 ∪ T ⊆ V; openin (top_of_set T') V; continuous_on V g; g ∈ V → T; ⋀x. x ∈ W0 ∪ T ⟹ g x = ?f x⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*)) (*goals: 1. ‹(⋀W2 h. ⟦W0 ∪ T ⊆ W2; continuous_on W2 h; openin (top_of_set T') W2; h ` W2 ⊆ T; ⋀x. x ∈ W0 ∪ T ⟹ h x = r x⟧ ⟹ thesis) ⟹ continuous_on (W0 ∪ T) ?f2› 2. ‹(⋀W2 h. ⟦W0 ∪ T ⊆ W2; continuous_on W2 h; openin (top_of_set T') W2; h ` W2 ⊆ T; ⋀x. x ∈ W0 ∪ T ⟹ h x = r x⟧ ⟹ thesis) ⟹ ?f2 ∈ W0 ∪ T → T› 3. ‹⋀V g. ⟦⋀W2 h. ⟦W0 ∪ T ⊆ W2; continuous_on W2 h; openin (top_of_set T') W2; h ` W2 ⊆ T; ⋀x. x ∈ W0 ∪ T ⟹ h x = r x⟧ ⟹ thesis; W0 ∪ T ⊆ V; openin (top_of_set T') V; continuous_on V g; g ∈ V → T; ⋀x. x ∈ W0 ∪ T ⟹ g x = ?f2 x⟧ ⟹ thesis›*) show "continuous_on (W0 ∪ T) r" using continuous_on_subset (*‹⟦continuous_on ?s ?f; ?t ⊆ ?s⟧ ⟹ continuous_on ?t ?f›*) contr (*‹continuous_on (W0 ∪ (S ∪ T)) r›*) sup_assoc (*‹sup (sup ?x ?y) ?z = sup ?x (sup ?y ?z)›*) by blast qed (use ‹r ` (W0 ∪ T) ⊆ T› in auto) (*solves the remaining goals: 1. ‹(⋀(W2::'a set) h::'a ⇒ 'a. ⟦(W0::'a set) ∪ (T::'a set) ⊆ W2; continuous_on W2 h; openin (top_of_set (T'::'a set)) W2; h ` W2 ⊆ T; ⋀x::'a. x ∈ W0 ∪ T ⟹ h x = (r::'a ⇒ 'a) x⟧ ⟹ thesis::bool) ⟹ r ∈ W0 ∪ T → T› 2. ‹⋀(V::'a set) g::'a ⇒ 'a. ⟦⋀(W2::'a set) h::'a ⇒ 'a. ⟦(W0::'a set) ∪ (T::'a set) ⊆ W2; continuous_on W2 h; openin (top_of_set (T'::'a set)) W2; h ` W2 ⊆ T; ⋀x::'a. x ∈ W0 ∪ T ⟹ h x = (r::'a ⇒ 'a) x⟧ ⟹ thesis::bool; W0 ∪ T ⊆ V; openin (top_of_set T') V; continuous_on V g; g ∈ V → T; ⋀x::'a. x ∈ W0 ∪ T ⟹ g x = r x⟧ ⟹ thesis›*) have "S' ∩ T' = W" by (force simp: S'_def (*‹S'::'a set ≡ {x::'a ∈ U::'a set. setdist {x} (S::'a set) ≤ setdist {x} (T::'a set)}›*) T'_def (*‹T'::'a set ≡ {x::'a ∈ U::'a set. setdist {x} (T::'a set) ≤ setdist {x} (S::'a set)}›*) W_def (*‹W::'a set ≡ {x::'a ∈ U::'a set. setdist {x} (S::'a set) = setdist {x} (T::'a set)}›*)) obtain O1 and O2 where O12: "open O1" "W1 = S' ∩ O1" "open O2" "W2 = T' ∩ O2" (*goal: ‹(⋀O1 O2. ⟦open O1; W1 = S' ∩ O1; open O2; W2 = T' ∩ O2⟧ ⟹ thesis) ⟹ thesis›*) using opeSW1 (*‹openin (top_of_set S') W1›*) opeSW2 (*‹openin (top_of_set T') W2›*) by (force simp: openin_open (*‹openin (top_of_set (?U::?'a set)) (?S::?'a set) = (∃T::?'a set. open T ∧ ?S = ?U ∩ T)›*)) show "?thesis" (*goal: ‹thesis›*) proof (standard) (*goals: 1. ‹openin (top_of_set U) ?V› 2. ‹S ∪ T retract_of ?V›*) have eq: "W1 - (W - U0) ∪ (W2 - (W - U0)) = ((U - T') ∩ O1 ∪ (U - S') ∩ O2 ∪ U ∩ O1 ∩ O2) - (W - U0)" (is "?WW1 ∪ ?WW2 = ?rhs") using ‹U0 ∩ W ⊆ W0› (*‹U0 ∩ W ⊆ W0›*) ‹W0 ∪ S ⊆ W1› (*‹(W0::'a::euclidean_space set) ∪ (S::'a::euclidean_space set) ⊆ (W1::'a::euclidean_space set)›*) ‹W0 ∪ T ⊆ W2› (*‹(W0::'a::euclidean_space set) ∪ (T::'a::euclidean_space set) ⊆ (W2::'a::euclidean_space set)›*) by (auto simp: ‹S' ∪ T' = U› [symmetric] ‹S' ∩ T' = W› [symmetric] ‹W1 = S' ∩ O1› ‹W2 = T' ∩ O2›) show "openin (top_of_set U) (?WW1 ∪ ?WW2)" by (simp add: eq (*‹W1 - (W - U0) ∪ (W2 - (W - U0)) = (U - T') ∩ O1 ∪ (U - S') ∩ O2 ∪ U ∩ O1 ∩ O2 - (W - U0)›*) ‹open O1› ‹open O2› cloUS' (*‹closedin (top_of_set U) S'›*) cloUT' (*‹closedin (top_of_set U) T'›*) cloUW (*‹closedin (top_of_set U) W›*) closedin_diff (*‹⟦closedin ?U ?S; openin ?U ?T⟧ ⟹ closedin ?U (?S - ?T)›*) opeUU0 (*‹openin (top_of_set U) U0›*) openin_Int_open (*‹⟦openin (top_of_set ?U) ?S; open ?T⟧ ⟹ openin (top_of_set ?U) (?S ∩ ?T)›*) openin_Un (*‹⟦openin ?U ?S; openin ?U ?T⟧ ⟹ openin ?U (?S ∪ ?T)›*) openin_diff (*‹⟦openin ?U ?S; closedin ?U ?T⟧ ⟹ openin ?U (?S - ?T)›*)) obtain SU' where "closed SU'" "S' = U ∩ SU'" (*goal: ‹(⋀SU'. ⟦closed SU'; S' = U ∩ SU'⟧ ⟹ thesis) ⟹ thesis›*) using cloUS' (*‹closedin (top_of_set U) S'›*) by (auto simp add: closedin_closed (*‹closedin (top_of_set ?U) ?S = (∃T. closed T ∧ ?S = ?U ∩ T)›*)) moreover have "?WW1 = (?WW1 ∪ ?WW2) ∩ SU'" using ‹S' = U ∩ SU'› (*‹S' = U ∩ SU'›*) ‹W1 = S' ∩ O1› (*‹W1 = S' ∩ O1›*) ‹S' ∪ T' = U› (*‹S' ∪ T' = U›*) ‹W2 = T' ∩ O2› (*‹W2 = T' ∩ O2›*) ‹S' ∩ T' = W› (*‹S' ∩ T' = W›*) ‹W0 ∪ S ⊆ W1› (*‹W0 ∪ S ⊆ W1›*) U0 (*‹S ∩ T ⊆ U0› ‹U0 ∩ W ⊆ W0›*) by auto ultimately have cloW1: "closedin (top_of_set (W1 - (W - U0) ∪ (W2 - (W - U0)))) (W1 - (W - U0))" by (metis closedin_closed_Int (*‹closed ?S ⟹ closedin (top_of_set ?U) (?U ∩ ?S)›*)) obtain TU' where "closed TU'" "T' = U ∩ TU'" (*goal: ‹(⋀TU'. ⟦closed TU'; T' = U ∩ TU'⟧ ⟹ thesis) ⟹ thesis›*) using cloUT' (*‹closedin (top_of_set U) T'›*) by (auto simp add: closedin_closed (*‹closedin (top_of_set ?U) ?S = (∃T. closed T ∧ ?S = ?U ∩ T)›*)) moreover have "?WW2 = (?WW1 ∪ ?WW2) ∩ TU'" using ‹T' = U ∩ TU'› (*‹T' = U ∩ TU'›*) ‹W1 = S' ∩ O1› (*‹W1 = S' ∩ O1›*) ‹S' ∪ T' = U› (*‹S' ∪ T' = U›*) ‹W2 = T' ∩ O2› (*‹W2 = T' ∩ O2›*) ‹S' ∩ T' = W› (*‹S' ∩ T' = W›*) ‹W0 ∪ T ⊆ W2› (*‹W0 ∪ T ⊆ W2›*) U0 (*‹S ∩ T ⊆ U0› ‹U0 ∩ W ⊆ W0›*) by auto ultimately have cloW2: "closedin (top_of_set (?WW1 ∪ ?WW2)) ?WW2" by (metis closedin_closed_Int (*‹closed ?S ⟹ closedin (top_of_set ?U) (?U ∩ ?S)›*)) let ?gh = "λx. if x ∈ S' then g x else h x" have "∃r. continuous_on (?WW1 ∪ ?WW2) r ∧ r ` (?WW1 ∪ ?WW2) ⊆ S ∪ T ∧ (∀x∈S ∪ T. r x = x)" proof (intro exI (*‹?P ?x ⟹ ∃x. ?P x›*) conjI (*‹⟦?P; ?Q⟧ ⟹ ?P ∧ ?Q›*)) (*goals: 1. ‹continuous_on (W1 - (W - U0) ∪ (W2 - (W - U0))) ?r› 2. ‹?r ` (W1 - (W - U0) ∪ (W2 - (W - U0))) ⊆ S ∪ T› 3. ‹∀x∈S ∪ T. ?r x = x›*) show "∀x∈S ∪ T. ?gh x = x" using ST (*‹?x ∈ W ⟹ (?x ∈ S) = (?x ∈ T)›*) ‹S' ∩ T' = W› (*‹S' ∩ T' = W›*) geqr (*‹?x ∈ W0 ∪ S ⟹ g ?x = r ?x›*) heqr (*‹?x ∈ W0 ∪ T ⟹ h ?x = r ?x›*) O12 (*‹open (O1::'a::euclidean_space set)› ‹W1 = S' ∩ O1› ‹open (O2::'a set)› ‹W2 = T' ∩ O2›*) by (metis Int_iff (*‹(?c ∈ ?A ∩ ?B) = (?c ∈ ?A ∧ ?c ∈ ?B)›*) Un_iff (*‹(?c ∈ ?A ∪ ?B) = (?c ∈ ?A ∨ ?c ∈ ?B)›*) ‹W0 ∪ S ⊆ W1› ‹W0 ∪ T ⊆ W2› r0 (*‹?x ∈ S ∩ T ⟹ r0 ?x = ?x›*) r_def (*‹r ≡ λx. if x ∈ W0 then r0 x else x›*) sup.order_iff (*‹(?b ≤ ?a) = (?a = sup ?a ?b)›*)) have "⋀x. x ∈ ?WW1 ∧ x ∉ S' ∨ x ∈ ?WW2 ∧ x ∈ S' ⟹ g x = h x" using O12 (*‹open O1› ‹(W1::'a set) = (S'::'a set) ∩ (O1::'a set)› ‹open O2› ‹(W2::'a set) = (T'::'a set) ∩ (O2::'a set)›*) by (metis (full_types) DiffD1 (*‹?c ∈ ?A - ?B ⟹ ?c ∈ ?A›*) DiffD2 (*‹⟦?c ∈ ?A - ?B; ?c ∈ ?B⟧ ⟹ ?P›*) DiffI (*‹⟦?c ∈ ?A; ?c ∉ ?B⟧ ⟹ ?c ∈ ?A - ?B›*) IntE (*‹⟦?c ∈ ?A ∩ ?B; ⟦?c ∈ ?A; ?c ∈ ?B⟧ ⟹ ?P⟧ ⟹ ?P›*) IntI (*‹⟦?c ∈ ?A; ?c ∈ ?B⟧ ⟹ ?c ∈ ?A ∩ ?B›*) U0( (*‹U0 ∩ W ⊆ W0›*) 2) UnCI (*‹(?c ∉ ?B ⟹ ?c ∈ ?A) ⟹ ?c ∈ ?A ∪ ?B›*) ‹S' ∩ T' = W› geqr (*‹?x ∈ W0 ∪ S ⟹ g ?x = r ?x›*) heqr (*‹?x ∈ W0 ∪ T ⟹ h ?x = r ?x›*) in_mono (*‹?A ⊆ ?B ⟹ ?x ∈ ?A ⟶ ?x ∈ ?B›*)) then show "continuous_on (?WW1 ∪ ?WW2) ?gh" using continuous_on_cases_local[OF cloW1 cloW2 continuous_on_subset [ OF contg ] continuous_on_subset [ OF conth ]] (*‹⟦W1 - (W - U0) ⊆ W1; W2 - (W - U0) ⊆ W2; ⋀x. x ∈ W1 - (W - U0) ∧ ¬ ?P x ∨ x ∈ W2 - (W - U0) ∧ ?P x ⟹ g x = h x⟧ ⟹ continuous_on (W1 - (W - U0) ∪ (W2 - (W - U0))) (λx. if ?P x then g x else h x)›*) by simp show "?gh ` (?WW1 ∪ ?WW2) ⊆ S ∪ T" using ‹W1 = S' ∩ O1› (*‹W1 = S' ∩ O1›*) ‹W2 = T' ∩ O2› (*‹W2 = T' ∩ O2›*) ‹S' ∩ T' = W› (*‹(S'::'a set) ∩ (T'::'a set) = (W::'a set)›*) ‹g ∈ W1 → S› (*‹g ∈ W1 → S›*) ‹h ` W2 ⊆ T› (*‹(h::'a ⇒ 'a) ` (W2::'a set) ⊆ (T::'a set)›*) ‹U0 ∩ W ⊆ W0› (*‹U0 ∩ W ⊆ W0›*) ‹W0 ∪ S ⊆ W1› (*‹W0 ∪ S ⊆ W1›*) by (auto simp add: image_subset_iff (*‹(?f ` ?A ⊆ ?B) = (∀x∈?A. ?f x ∈ ?B)›*)) qed then show "S ∪ T retract_of ?WW1 ∪ ?WW2" using ‹W0 ∪ S ⊆ W1› (*‹W0 ∪ S ⊆ W1›*) ‹W0 ∪ T ⊆ W2› (*‹W0 ∪ T ⊆ W2›*) ST (*‹(?x::'a) ∈ (W::'a set) ⟹ (?x ∈ (S::'a set)) = (?x ∈ (T::'a set))›*) opeUU0 (*‹openin (top_of_set U) U0›*) U0 (*‹(S::'a::euclidean_space set) ∩ (T::'a::euclidean_space set) ⊆ (U0::'a::euclidean_space set)› ‹U0 ∩ W ⊆ W0›*) by (auto simp: retract_of_def (*‹((?T::?'a::topological_space set) retract_of (?S::?'a::topological_space set)) = (∃r::?'a::topological_space ⇒ ?'a::topological_space. retraction ?S ?T r)›*) retraction_def (*‹retraction (?S::?'a::topological_space set) (?T::?'a::topological_space set) (?r::?'a::topological_space ⇒ ?'a::topological_space) = (?T ⊆ ?S ∧ continuous_on ?S ?r ∧ ?r ∈ ?S → ?T ∧ (∀x::?'a::topological_space∈?T. ?r x = x))›*) image_subset_iff_funcset (*‹((?F::?'b::type ⇒ ?'a::type) ` (?A::?'b::type set) ⊆ (?B::?'a::type set)) = (?F ∈ ?A → ?B)›*)) qed qed lemma ANR_closed_Un_local: fixes S :: "'a::euclidean_space set" assumes STS: "closedin (top_of_set (S ∪ T)) S" and STT: "closedin (top_of_set (S ∪ T)) T" and "ANR S" "ANR T" "ANR(S ∩ T)" shows "ANR(S ∪ T)" proof (-) (*goal: ‹ANR (S ∪ T)›*) have "∃T. openin (top_of_set U) T ∧ C retract_of T" if hom: "S ∪ T homeomorphic C" and UC: "closedin (top_of_set U) C" for U and C :: "('a * real) set" proof (-) (*goal: ‹∃T. openin (top_of_set U) T ∧ C retract_of T›*) obtain f and g where hom: "homeomorphism (S ∪ T) C f g" (*goal: ‹(⋀f g. homeomorphism (S ∪ T) C f g ⟹ thesis) ⟹ thesis›*) using hom (*‹S ∪ T homeomorphic C›*) by (force simp: homeomorphic_def (*‹(?s::?'a set) homeomorphic (?t::?'b set) ≡ ∃(f::?'a ⇒ ?'b) g::?'b ⇒ ?'a. homeomorphism ?s ?t f g›*)) have US: "closedin (top_of_set U) (C ∩ g -` S)" by (metis STS (*‹closedin (top_of_set (S ∪ T)) S›*) UC (*‹closedin (top_of_set U) C›*) closedin_trans (*‹⟦closedin (top_of_set ?T) ?S; closedin (top_of_set ?U) ?T⟧ ⟹ closedin (top_of_set ?U) ?S›*) continuous_on_imp_closedin (*‹⟦continuous_on ?S ?f; closedin (top_of_set (?f ` ?S)) ?T⟧ ⟹ closedin (top_of_set ?S) (?S ∩ ?f -` ?T)›*) hom (*‹homeomorphism (S ∪ T) C f g›*) homeomorphism_def (*‹homeomorphism ?S ?T ?f ?g = ((∀x∈?S. ?g (?f x) = x) ∧ ?f ` ?S = ?T ∧ continuous_on ?S ?f ∧ (∀y∈?T. ?f (?g y) = y) ∧ ?g ` ?T = ?S ∧ continuous_on ?T ?g)›*)) have UT: "closedin (top_of_set U) (C ∩ g -` T)" by (metis STT (*‹closedin (top_of_set (S ∪ T)) T›*) UC (*‹closedin (top_of_set U) C›*) closedin_trans (*‹⟦closedin (top_of_set ?T) ?S; closedin (top_of_set ?U) ?T⟧ ⟹ closedin (top_of_set ?U) ?S›*) continuous_on_imp_closedin (*‹⟦continuous_on ?S ?f; closedin (top_of_set (?f ` ?S)) ?T⟧ ⟹ closedin (top_of_set ?S) (?S ∩ ?f -` ?T)›*) hom (*‹homeomorphism (S ∪ T) C f g›*) homeomorphism_def (*‹homeomorphism ?S ?T ?f ?g = ((∀x∈?S. ?g (?f x) = x) ∧ ?f ` ?S = ?T ∧ continuous_on ?S ?f ∧ (∀y∈?T. ?f (?g y) = y) ∧ ?g ` ?T = ?S ∧ continuous_on ?T ?g)›*)) have "homeomorphism (C ∩ g -` S) S g f" using hom (*‹homeomorphism (S ∪ T) C f g›*) apply (auto simp: homeomorphism_def (*‹homeomorphism ?S ?T ?f ?g = ((∀x∈?S. ?g (?f x) = x) ∧ ?f ` ?S = ?T ∧ continuous_on ?S ?f ∧ (∀y∈?T. ?f (?g y) = y) ∧ ?g ` ?T = ?S ∧ continuous_on ?T ?g)›*) elim!: continuous_on_subset (*‹⟦continuous_on ?s ?f; ?t ⊆ ?s⟧ ⟹ continuous_on ?t ?f›*)) (*goal: ‹homeomorphism (C ∩ g -` S) S g f›*) apply (rule_tac x="f x" in image_eqI (*‹⟦?b = ?f ?x; ?x ∈ ?A⟧ ⟹ ?b ∈ ?f ` ?A›*)) (*goals: 1. ‹⋀x. ⟦∀x∈S ∪ T. g (f x) = x; C = f ` (S ∪ T); continuous_on (S ∪ T) f; g ` f ` (S ∪ T) = S ∪ T; continuous_on (f ` (S ∪ T)) g; x ∈ S⟧ ⟹ x = g (f x)› 2. ‹⋀x. ⟦∀x∈S ∪ T. g (f x) = x; C = f ` (S ∪ T); continuous_on (S ∪ T) f; g ` f ` (S ∪ T) = S ∪ T; continuous_on (f ` (S ∪ T)) g; x ∈ S⟧ ⟹ f x ∈ f ` (S ∪ T) ∩ g -` S› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . then have ANRS: "ANR (C ∩ g -` S)" using ‹ANR S› (*‹ANR S›*) homeomorphic_ANR_iff_ANR (*‹?S homeomorphic ?T ⟹ ANR ?S = ANR ?T›*) homeomorphic_def (*‹?s homeomorphic ?t ≡ ∃f g. homeomorphism ?s ?t f g›*) by blast have "homeomorphism (C ∩ g -` T) T g f" using hom (*‹homeomorphism (S ∪ T) C f g›*) apply (auto simp: homeomorphism_def (*‹homeomorphism ?S ?T ?f ?g = ((∀x∈?S. ?g (?f x) = x) ∧ ?f ` ?S = ?T ∧ continuous_on ?S ?f ∧ (∀y∈?T. ?f (?g y) = y) ∧ ?g ` ?T = ?S ∧ continuous_on ?T ?g)›*) elim!: continuous_on_subset (*‹⟦continuous_on ?s ?f; ?t ⊆ ?s⟧ ⟹ continuous_on ?t ?f›*)) (*goal: ‹homeomorphism (C ∩ g -` T) T g f›*) apply (rule_tac x="f x" in image_eqI (*‹⟦?b = ?f ?x; ?x ∈ ?A⟧ ⟹ ?b ∈ ?f ` ?A›*)) (*goals: 1. ‹⋀x. ⟦∀x∈S ∪ T. g (f x) = x; C = f ` (S ∪ T); continuous_on (S ∪ T) f; g ` f ` (S ∪ T) = S ∪ T; continuous_on (f ` (S ∪ T)) g; x ∈ T⟧ ⟹ x = g (f x)› 2. ‹⋀x. ⟦∀x∈S ∪ T. g (f x) = x; C = f ` (S ∪ T); continuous_on (S ∪ T) f; g ` f ` (S ∪ T) = S ∪ T; continuous_on (f ` (S ∪ T)) g; x ∈ T⟧ ⟹ f x ∈ f ` (S ∪ T) ∩ g -` T› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . then have ANRT: "ANR (C ∩ g -` T)" using ‹ANR T› (*‹ANR T›*) homeomorphic_ANR_iff_ANR (*‹?S homeomorphic ?T ⟹ ANR ?S = ANR ?T›*) homeomorphic_def (*‹(?s::?'a set) homeomorphic (?t::?'b set) ≡ ∃(f::?'a ⇒ ?'b) g::?'b ⇒ ?'a. homeomorphism ?s ?t f g›*) by blast have "homeomorphism (C ∩ g -` S ∩ (C ∩ g -` T)) (S ∩ T) g f" using hom (*‹homeomorphism ((S::'a set) ∪ (T::'a set)) (C::('a × real) set) (f::'a ⇒ 'a × real) (g::'a × real ⇒ 'a)›*) apply (auto simp: homeomorphism_def (*‹homeomorphism ?S ?T ?f ?g = ((∀x∈?S. ?g (?f x) = x) ∧ ?f ` ?S = ?T ∧ continuous_on ?S ?f ∧ (∀y∈?T. ?f (?g y) = y) ∧ ?g ` ?T = ?S ∧ continuous_on ?T ?g)›*) elim!: continuous_on_subset (*‹⟦continuous_on ?s ?f; ?t ⊆ ?s⟧ ⟹ continuous_on ?t ?f›*)) (*goal: ‹homeomorphism (C ∩ g -` S ∩ (C ∩ g -` T)) (S ∩ T) g f›*) apply (rule_tac x="f x" in image_eqI (*‹⟦(?b::?'a::type) = (?f::?'b::type ⇒ ?'a::type) (?x::?'b::type); ?x ∈ (?A::?'b::type set)⟧ ⟹ ?b ∈ ?f ` ?A›*)) (*goals: 1. ‹⋀x. ⟦∀x∈S ∪ T. g (f x) = x; C = f ` (S ∪ T); continuous_on (S ∪ T) f; g ` f ` (S ∪ T) = S ∪ T; continuous_on (f ` (S ∪ T)) g; x ∈ S; x ∈ T⟧ ⟹ x = g (f x)› 2. ‹⋀x. ⟦∀x∈S ∪ T. g (f x) = x; C = f ` (S ∪ T); continuous_on (S ∪ T) f; g ` f ` (S ∪ T) = S ∪ T; continuous_on (f ` (S ∪ T)) g; x ∈ S; x ∈ T⟧ ⟹ f x ∈ f ` (S ∪ T) ∩ g -` S ∩ (f ` (S ∪ T) ∩ g -` T)› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . then have ANRI: "ANR ((C ∩ g -` S) ∩ (C ∩ g -` T))" using ‹ANR (S ∩ T)› (*‹ANR (S ∩ T)›*) homeomorphic_ANR_iff_ANR (*‹?S homeomorphic ?T ⟹ ANR ?S = ANR ?T›*) homeomorphic_def (*‹?s homeomorphic ?t ≡ ∃f g. homeomorphism ?s ?t f g›*) by blast have "C = (C ∩ g -` S) ∪ (C ∩ g -` T)" using hom (*‹homeomorphism ((S::'a::euclidean_space set) ∪ (T::'a::euclidean_space set)) (C::('a::euclidean_space × real) set) (f::'a::euclidean_space ⇒ 'a::euclidean_space × real) (g::'a::euclidean_space × real ⇒ 'a::euclidean_space)›*) by (auto simp: homeomorphism_def (*‹homeomorphism ?S ?T ?f ?g = ((∀x∈?S. ?g (?f x) = x) ∧ ?f ` ?S = ?T ∧ continuous_on ?S ?f ∧ (∀y∈?T. ?f (?g y) = y) ∧ ?g ` ?T = ?S ∧ continuous_on ?T ?g)›*)) then show "?thesis" (*goal: ‹∃T. openin (top_of_set U) T ∧ C retract_of T›*) by (metis ANR_closed_Un_local_aux [OF US UT ANRS ANRT ANRI] (*‹(⋀V. ⟦openin (top_of_set U) V; C ∩ g -` S ∪ C ∩ g -` T retract_of V⟧ ⟹ ?thesis) ⟹ ?thesis›*)) qed then show "?thesis" (*goal: ‹ANR (S ∪ T)›*) by (auto simp: ANR_def (*‹ANR ?S ≡ ∀U S'. ?S homeomorphic S' ∧ closedin (top_of_set U) S' ⟶ (∃T. openin (top_of_set U) T ∧ S' retract_of T)›*)) qed corollary ANR_closed_Un: fixes S :: "'a::euclidean_space set" shows "⟦closed S; closed T; ANR S; ANR T; ANR (S ∩ T)⟧ ⟹ ANR (S ∪ T)" by (simp add: ANR_closed_Un_local (*‹⟦closedin (top_of_set (?S ∪ ?T)) ?S; closedin (top_of_set (?S ∪ ?T)) ?T; ANR ?S; ANR ?T; ANR (?S ∩ ?T)⟧ ⟹ ANR (?S ∪ ?T)›*) closedin_def (*‹closedin ?U ?S = (?S ⊆ topspace ?U ∧ openin ?U (topspace ?U - ?S))›*) diff_eq (*‹?x - ?y = inf ?x (- ?y)›*) open_Compl (*‹closed ?S ⟹ open (- ?S)›*) openin_open_Int (*‹open ?S ⟹ openin (top_of_set ?U) (?U ∩ ?S)›*)) lemma ANR_openin: fixes S :: "'a::euclidean_space set" assumes "ANR T" and opeTS: "openin (top_of_set T) S" shows "ANR S" proof (clarsimp simp only: ANR_eq_absolute_neighbourhood_extensor (*‹ANR ?S = (∀f U T. continuous_on T f ⟶ f ∈ T → ?S ⟶ closedin (top_of_set U) T ⟶ (∃V g. T ⊆ V ∧ openin (top_of_set U) V ∧ continuous_on V g ∧ g ∈ V → ?S ∧ (∀x∈T. g x = f x)))›*)) (*goal: ‹⋀(f::'a × real ⇒ 'a) (U::('a × real) set) T::('a × real) set. ⟦continuous_on T f; f ∈ T → (S::'a set); closedin (top_of_set U) T⟧ ⟹ ∃(V::('a × real) set) g::'a × real ⇒ 'a. T ⊆ V ∧ openin (top_of_set U) V ∧ continuous_on V g ∧ g ∈ V → S ∧ (∀x::'a × real∈T. g x = f x)›*) fix f :: "'a × real ⇒ 'a" and U and C assume contf: "continuous_on C f" and fim: "f ∈ C → S" and cloUC: "closedin (top_of_set U) C" (*‹continuous_on (C::('a × real) set) (f::'a × real ⇒ 'a)› ‹(f::'a × real ⇒ 'a) ∈ (C::('a × real) set) → (S::'a set)› ‹closedin (top_of_set (U::('a × real) set)) (C::('a × real) set)›*) have "f ∈ C → T" using fim (*‹(f::'a × real ⇒ 'a) ∈ (C::('a × real) set) → (S::'a set)›*) opeTS (*‹openin (top_of_set T) S›*) openin_imp_subset (*‹openin (subtopology ?U ?S) ?T ⟹ ?T ⊆ ?S›*) by blast obtain W and g where "C ⊆ W" and UW: "openin (top_of_set U) W" and contg: "continuous_on W g" and gim: "g ∈ W → T" and geq: "⋀x. x ∈ C ⟹ g x = f x" (*goal: ‹(⋀(W::('a × real) set) g::'a × real ⇒ 'a. ⟦(C::('a × real) set) ⊆ W; openin (top_of_set (U::('a × real) set)) W; continuous_on W g; g ∈ W → (T::'a set); ⋀x::'a × real. x ∈ C ⟹ g x = (f::'a × real ⇒ 'a) x⟧ ⟹ thesis::bool) ⟹ thesis›*) using ANR_imp_absolute_neighbourhood_extensor[OF ‹ANR T› contf ‹f ∈ C → T› cloUC] (*‹(⋀V g. ⟦C ⊆ V; openin (top_of_set U) V; continuous_on V g; g ∈ V → T; ⋀x. x ∈ C ⟹ g x = f x⟧ ⟹ ?thesis) ⟹ ?thesis›*) fim (*‹f ∈ C → S›*) by auto show "∃V g. C ⊆ V ∧ openin (top_of_set U) V ∧ continuous_on V g ∧ g ∈ V → S ∧ (∀x∈C. g x = f x)" proof (intro exI (*‹?P ?x ⟹ ∃x. ?P x›*) conjI (*‹⟦?P; ?Q⟧ ⟹ ?P ∧ ?Q›*)) (*goals: 1. ‹C ⊆ ?V› 2. ‹openin (top_of_set U) ?V› 3. ‹continuous_on ?V ?g1› 4. ‹?g1 ∈ ?V → S› 5. ‹∀x∈C. ?g1 x = f x›*) show "C ⊆ W ∩ g -` S" using ‹C ⊆ W› (*‹(C::('a::euclidean_space × real) set) ⊆ (W::('a::euclidean_space × real) set)›*) fim (*‹f ∈ C → S›*) geq (*‹?x ∈ C ⟹ g ?x = f ?x›*) by blast show "openin (top_of_set U) (W ∩ g -` S)" by (metis (mono_tags, lifting) UW (*‹openin (top_of_set U) W›*) contg (*‹continuous_on W g›*) continuous_openin_preimage (*‹⟦continuous_on ?S ?f; ?f ∈ ?S → ?T; openin (top_of_set ?T) ?U⟧ ⟹ openin (top_of_set ?S) (?S ∩ ?f -` ?U)›*) gim (*‹g ∈ W → T›*) opeTS (*‹openin (top_of_set T) S›*) openin_trans (*‹⟦openin (top_of_set ?T) ?S; openin (top_of_set ?U) ?T⟧ ⟹ openin (top_of_set ?U) ?S›*)) show "continuous_on (W ∩ g -` S) g" by (blast intro: continuous_on_subset [OF contg] (*‹(?t::('a::euclidean_space × real) set) ⊆ (W::('a::euclidean_space × real) set) ⟹ continuous_on ?t (g::'a::euclidean_space × real ⇒ 'a::euclidean_space)›*)) show "g ∈ (W ∩ g -` S) → S" using gim (*‹g ∈ W → T›*) by blast show "∀x∈C. g x = f x" using geq (*‹?x ∈ C ⟹ g ?x = f ?x›*) by blast qed qed lemma ENR_openin: fixes S :: "'a::euclidean_space set" assumes "ENR T" "openin (top_of_set T) S" shows "ENR S" by (meson ANR_openin (*‹⟦ANR (?T::?'a set); openin (top_of_set ?T) (?S::?'a set)⟧ ⟹ ANR ?S›*) ENR_ANR (*‹ENR (?S::?'a set) = (ANR ?S ∧ locally compact ?S)›*) assms (*‹ENR (T::'a set)› ‹openin (top_of_set (T::'a set)) (S::'a set)›*) locally_open_subset (*‹⟦locally (?P::?'a set ⇒ bool) (?S::?'a set); openin (top_of_set ?S) (?t::?'a set)⟧ ⟹ locally ?P ?t›*)) lemma ANR_neighborhood_retract: fixes S :: "'a::euclidean_space set" assumes "ANR U" "S retract_of T" "openin (top_of_set U) T" shows "ANR S" using ANR_openin (*‹⟦ANR ?T; openin (top_of_set ?T) ?S⟧ ⟹ ANR ?S›*) ANR_retract_of_ANR (*‹⟦ANR (?T::?'a set); (?S::?'a set) retract_of ?T⟧ ⟹ ANR ?S›*) assms (*‹ANR U› ‹S retract_of T› ‹openin (top_of_set U) T›*) by blast lemma ENR_neighborhood_retract: fixes S :: "'a::euclidean_space set" assumes "ENR U" "S retract_of T" "openin (top_of_set U) T" shows "ENR S" using ENR_openin (*‹⟦ENR ?T; openin (top_of_set ?T) ?S⟧ ⟹ ENR ?S›*) ENR_retract_of_ENR (*‹⟦ENR ?T; ?S retract_of ?T⟧ ⟹ ENR ?S›*) assms (*‹ENR U› ‹S retract_of T› ‹openin (top_of_set U) T›*) by blast lemma ANR_rel_interior: fixes S :: "'a::euclidean_space set" shows "ANR S ⟹ ANR(rel_interior S)" by (blast intro: ANR_openin (*‹⟦ANR ?T; openin (top_of_set ?T) ?S⟧ ⟹ ANR ?S›*) openin_set_rel_interior (*‹openin (top_of_set ?S) (rel_interior ?S)›*)) lemma ANR_delete: fixes S :: "'a::euclidean_space set" shows "ANR S ⟹ ANR(S - {a})" by (blast intro: ANR_openin (*‹⟦ANR (?T::?'a set); openin (top_of_set ?T) (?S::?'a set)⟧ ⟹ ANR ?S›*) openin_delete (*‹openin (top_of_set (?u::?'a set)) (?S::?'a set) ⟹ openin (top_of_set ?u) (?S - {?a::?'a})›*) openin_subtopology_self (*‹openin (top_of_set (?S::?'a set)) ?S›*)) lemma ENR_rel_interior: fixes S :: "'a::euclidean_space set" shows "ENR S ⟹ ENR(rel_interior S)" by (blast intro: ENR_openin (*‹⟦ENR ?T; openin (top_of_set ?T) ?S⟧ ⟹ ENR ?S›*) openin_set_rel_interior (*‹openin (top_of_set ?S) (rel_interior ?S)›*)) lemma ENR_delete: fixes S :: "'a::euclidean_space set" shows "ENR S ⟹ ENR(S - {a})" by (blast intro: ENR_openin (*‹⟦ENR (?T::?'a::euclidean_space set); openin (top_of_set ?T) (?S::?'a::euclidean_space set)⟧ ⟹ ENR ?S›*) openin_delete (*‹openin (top_of_set (?u::?'a::t1_space set)) (?S::?'a::t1_space set) ⟹ openin (top_of_set ?u) (?S - {?a::?'a::t1_space})›*) openin_subtopology_self (*‹openin (top_of_set (?S::?'a::topological_space set)) ?S›*)) lemma open_imp_ENR: "open S ⟹ ENR S" using ENR_def (*‹ENR ?S ≡ ∃U. open U ∧ ?S retract_of U›*) by blast lemma open_imp_ANR: fixes S :: "'a::euclidean_space set" shows "open S ⟹ ANR S" by (simp add: ENR_imp_ANR (*‹ENR ?S ⟹ ANR ?S›*) open_imp_ENR (*‹open ?S ⟹ ENR ?S›*)) lemma ANR_ball [iff]: fixes a :: "'a::euclidean_space" shows "ANR(ball a r)" by (simp add: convex_imp_ANR (*‹convex ?S ⟹ ANR ?S›*)) lemma ENR_ball [iff]: "ENR(ball a r)" by (simp add: open_imp_ENR (*‹open (?S::?'a set) ⟹ ENR ?S›*)) lemma AR_ball [simp]: fixes a :: "'a::euclidean_space" shows "AR(ball a r) ⟷ 0 < r" by (auto simp: AR_ANR (*‹AR ?S = (ANR ?S ∧ contractible ?S ∧ ?S ≠ {})›*) convex_imp_contractible (*‹convex ?S ⟹ contractible ?S›*)) lemma ANR_cball [iff]: fixes a :: "'a::euclidean_space" shows "ANR(cball a r)" by (simp add: convex_imp_ANR (*‹convex ?S ⟹ ANR ?S›*)) lemma ENR_cball: fixes a :: "'a::euclidean_space" shows "ENR(cball a r)" using ENR_convex_closed (*‹⟦closed (?S::?'a set); convex ?S⟧ ⟹ ENR ?S›*) by blast lemma AR_cball [simp]: fixes a :: "'a::euclidean_space" shows "AR(cball a r) ⟷ 0 ≤ r" by (auto simp: AR_ANR (*‹AR (?S::?'a set) = (ANR ?S ∧ contractible ?S ∧ ?S ≠ {})›*) convex_imp_contractible (*‹convex (?S::?'a set) ⟹ contractible ?S›*)) lemma ANR_box [iff]: fixes a :: "'a::euclidean_space" shows "ANR(cbox a b)" "ANR(box a b)" (*goals: 1. ‹ANR (cbox a b)› 2. ‹ANR (box a b)› discuss goal 1*) apply ((auto simp: convex_imp_ANR (*‹convex (?S::?'a set) ⟹ ANR ?S›*) open_imp_ANR (*‹open (?S::?'a set) ⟹ ANR ?S›*))[1]) (*discuss goal 2*) apply ((auto simp: convex_imp_ANR (*‹convex ?S ⟹ ANR ?S›*) open_imp_ANR (*‹open ?S ⟹ ANR ?S›*))[1]) (*proven 2 subgoals*) . lemma ENR_box [iff]: fixes a :: "'a::euclidean_space" shows "ENR(cbox a b)" "ENR(box a b)" (*goals: 1. ‹ENR (cbox a b)› 2. ‹ENR (box a b)› discuss goal 1*) apply (simp add: ENR_convex_closed (*‹⟦closed ?S; convex ?S⟧ ⟹ ENR ?S›*) closed_cbox (*‹closed (cbox ?a ?b)›*) open_box (*‹open (box ?a ?b)›*) open_imp_ENR (*‹open ?S ⟹ ENR ?S›*)) (*discuss goal 2*) apply (simp add: ENR_convex_closed (*‹⟦closed ?S; convex ?S⟧ ⟹ ENR ?S›*) closed_cbox (*‹closed (cbox ?a ?b)›*) open_box (*‹open (box ?a ?b)›*) open_imp_ENR (*‹open ?S ⟹ ENR ?S›*)) (*proven 2 subgoals*) . lemma AR_box [simp]: "AR(cbox a b) ⟷ cbox a b ≠ {}" "AR(box a b) ⟷ box a b ≠ {}" (*goals: 1. ‹AR (cbox a b) = (cbox a b ≠ {})› 2. ‹AR (box a b) = (box a b ≠ {})› discuss goal 1*) apply ((auto simp: AR_ANR (*‹AR ?S = (ANR ?S ∧ contractible ?S ∧ ?S ≠ {})›*) convex_imp_contractible (*‹convex ?S ⟹ contractible ?S›*))[1]) (*discuss goal 2*) apply ((auto simp: AR_ANR (*‹AR (?S::?'a set) = (ANR ?S ∧ contractible ?S ∧ ?S ≠ {})›*) convex_imp_contractible (*‹convex (?S::?'a set) ⟹ contractible ?S›*))[1]) (*proven 2 subgoals*) . lemma ANR_interior: fixes S :: "'a::euclidean_space set" shows "ANR(interior S)" by (simp add: open_imp_ANR (*‹open ?S ⟹ ANR ?S›*)) lemma ENR_interior: fixes S :: "'a::euclidean_space set" shows "ENR(interior S)" by (simp add: open_imp_ENR (*‹open ?S ⟹ ENR ?S›*)) lemma AR_imp_contractible: fixes S :: "'a::euclidean_space set" shows "AR S ⟹ contractible S" by (simp add: AR_ANR (*‹AR ?S = (ANR ?S ∧ contractible ?S ∧ ?S ≠ {})›*)) lemma ENR_imp_locally_compact: fixes S :: "'a::euclidean_space set" shows "ENR S ⟹ locally compact S" by (simp add: ENR_ANR (*‹ENR ?S = (ANR ?S ∧ locally compact ?S)›*)) lemma ANR_imp_locally_path_connected: fixes S :: "'a::euclidean_space set" assumes "ANR S" shows "locally path_connected S" proof (-) (*goal: ‹locally path_connected S›*) obtain U and T :: "('a × real) set" where "convex U" "U ≠ {}" and UT: "closedin (top_of_set U) T" and "S homeomorphic T" (*goal: ‹(⋀(U::('a × real) set) T::('a × real) set. ⟦convex U; U ≠ {}; closedin (top_of_set U) T; (S::'a set) homeomorphic T⟧ ⟹ thesis::bool) ⟹ thesis›*) proof (rule homeomorphic_closedin_convex (*‹⟦aff_dim ?S < int DIM(?'n); ⋀U T. ⟦convex U; U ≠ {}; closedin (top_of_set U) T; ?S homeomorphic T⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*)) (*goals: 1. ‹(⋀U T. ⟦convex U; U ≠ {}; closedin (top_of_set U) T; S homeomorphic T⟧ ⟹ thesis) ⟹ aff_dim ?S2 < int DIM(?'n2)› 2. ‹⋀U T. ⟦⋀U T. ⟦convex U; U ≠ {}; closedin (top_of_set U) T; S homeomorphic T⟧ ⟹ thesis; convex U; U ≠ {}; closedin (top_of_set U) T; ?S2 homeomorphic T⟧ ⟹ thesis›*) show "aff_dim S < int DIM('a × real)" using aff_dim_le_DIM[of S] (*‹aff_dim (S::'a set) ≤ int DIM('a)›*) by auto qed (auto) (*solved the remaining goal: ‹⋀U T. ⟦⋀U T. ⟦convex U; U ≠ {}; closedin (top_of_set U) T; S homeomorphic T⟧ ⟹ thesis; convex U; U ≠ {}; closedin (top_of_set U) T; S homeomorphic T⟧ ⟹ thesis›*) then have "locally path_connected T" by (meson ANR_imp_absolute_neighbourhood_retract (*‹⟦ANR (?S::?'a set); ?S homeomorphic (?S'::?'b set); closedin (top_of_set (?U::?'b set)) ?S'; ⋀V::?'b set. ⟦openin (top_of_set ?U) V; ?S' retract_of V⟧ ⟹ ?thesis::bool⟧ ⟹ ?thesis›*) assms (*‹ANR (S::'a set)›*) convex_imp_locally_path_connected (*‹convex (?S::?'a set) ⟹ locally path_connected ?S›*) locally_open_subset (*‹⟦locally (?P::?'a set ⇒ bool) (?S::?'a set); openin (top_of_set ?S) (?t::?'a set)⟧ ⟹ locally ?P ?t›*) retract_of_locally_path_connected (*‹⟦locally path_connected (?T::?'a set); (?S::?'a set) retract_of ?T⟧ ⟹ locally path_connected ?S›*)) then have S: "locally path_connected S" if "openin (top_of_set U) V" "T retract_of V" "U ≠ {}" for V using ‹S homeomorphic T› (*‹S homeomorphic T›*) homeomorphic_locally (*‹⟦(?S::?'a::metric_space set) homeomorphic (?T::?'b::metric_space set); ⋀(X::?'a::metric_space set) Y::?'b::metric_space set. X homeomorphic Y ⟹ (?P::?'a::metric_space set ⇒ bool) X = (?Q::?'b::metric_space set ⇒ bool) Y⟧ ⟹ locally ?P ?S = locally ?Q ?T›*) homeomorphic_path_connectedness (*‹(?S::?'a::topological_space set) homeomorphic (?T::?'b::topological_space set) ⟹ path_connected ?S = path_connected ?T›*) by blast obtain Ta where "(openin (top_of_set U) Ta ∧ T retract_of Ta)" (*goal: ‹(⋀Ta. openin (top_of_set U) Ta ∧ T retract_of Ta ⟹ thesis) ⟹ thesis›*) using ANR_def (*‹ANR ?S ≡ ∀U S'. ?S homeomorphic S' ∧ closedin (top_of_set U) S' ⟶ (∃T. openin (top_of_set U) T ∧ S' retract_of T)›*) UT (*‹closedin (top_of_set U) T›*) ‹S homeomorphic T› (*‹S homeomorphic T›*) assms (*‹ANR S›*) apply atomize_elim (*goal: ‹(⋀Ta. openin (top_of_set U) Ta ∧ T retract_of Ta ⟹ thesis) ⟹ thesis›*) by (auto simp: choice (*‹∀x. ∃y. ?Q x y ⟹ ∃f. ∀x. ?Q x (f x)›*)) then show "?thesis" (*goal: ‹locally path_connected S›*) using S (*‹⟦openin (top_of_set U) ?V; T retract_of ?V; U ≠ {}⟧ ⟹ locally path_connected S›*) ‹U ≠ {}› (*‹U ≠ {}›*) by blast qed lemma ANR_imp_locally_connected: fixes S :: "'a::euclidean_space set" assumes "ANR S" shows "locally connected S" using locally_path_connected_imp_locally_connected (*‹locally path_connected ?S ⟹ locally connected ?S›*) ANR_imp_locally_path_connected (*‹ANR ?S ⟹ locally path_connected ?S›*) assms (*‹ANR S›*) by auto lemma AR_imp_locally_path_connected: fixes S :: "'a::euclidean_space set" assumes "AR S" shows "locally path_connected S" by (simp add: ANR_imp_locally_path_connected (*‹ANR (?S::?'a::euclidean_space set) ⟹ locally path_connected ?S›*) AR_imp_ANR (*‹AR (?S::?'a::topological_space set) ⟹ ANR ?S›*) assms (*‹AR (S::'a::euclidean_space set)›*)) lemma AR_imp_locally_connected: fixes S :: "'a::euclidean_space set" assumes "AR S" shows "locally connected S" using ANR_imp_locally_connected (*‹ANR ?S ⟹ locally connected ?S›*) AR_ANR (*‹AR ?S = (ANR ?S ∧ contractible ?S ∧ ?S ≠ {})›*) assms (*‹AR S›*) by blast lemma ENR_imp_locally_path_connected: fixes S :: "'a::euclidean_space set" assumes "ENR S" shows "locally path_connected S" by (simp add: ANR_imp_locally_path_connected (*‹ANR ?S ⟹ locally path_connected ?S›*) ENR_imp_ANR (*‹ENR ?S ⟹ ANR ?S›*) assms (*‹ENR S›*)) lemma ENR_imp_locally_connected: fixes S :: "'a::euclidean_space set" assumes "ENR S" shows "locally connected S" using ANR_imp_locally_connected (*‹ANR ?S ⟹ locally connected ?S›*) ENR_ANR (*‹ENR ?S = (ANR ?S ∧ locally compact ?S)›*) assms (*‹ENR (S::'a set)›*) by blast lemma ANR_Times: fixes S :: "'a::euclidean_space set" and T :: "'b::euclidean_space set" assumes "ANR S" "ANR T" shows "ANR(S × T)" proof (clarsimp simp only: ANR_eq_absolute_neighbourhood_extensor (*‹ANR ?S = (∀f U T. continuous_on T f ⟶ f ∈ T → ?S ⟶ closedin (top_of_set U) T ⟶ (∃V g. T ⊆ V ∧ openin (top_of_set U) V ∧ continuous_on V g ∧ g ∈ V → ?S ∧ (∀x∈T. g x = f x)))›*)) (*goal: ‹⋀f U Ta. ⟦continuous_on Ta f; f ∈ Ta → S × T; closedin (top_of_set U) Ta⟧ ⟹ ∃V g. Ta ⊆ V ∧ openin (top_of_set U) V ∧ continuous_on V g ∧ g ∈ V → S × T ∧ (∀x∈Ta. g x = f x)›*) fix f :: " ('a × 'b) × real ⇒ 'a × 'b" and U and C assume "continuous_on C f" and fim: "f ∈ C → S × T" and cloUC: "closedin (top_of_set U) C" (*‹continuous_on (C::(('a × 'b) × real) set) (f::('a × 'b) × real ⇒ 'a × 'b)› ‹(f::('a × 'b) × real ⇒ 'a × 'b) ∈ (C::(('a × 'b) × real) set) → (S::'a set) × (T::'b set)› ‹closedin (top_of_set (U::(('a × 'b) × real) set)) (C::(('a × 'b) × real) set)›*) have contf1: "continuous_on C (fst ∘ f)" by (simp add: ‹continuous_on C f› continuous_on_fst (*‹continuous_on (?s::?'a set) (?f::?'a ⇒ ?'b × ?'c) ⟹ continuous_on ?s (λx::?'a. fst (?f x))›*)) obtain W1 and g where "C ⊆ W1" and UW1: "openin (top_of_set U) W1" and contg: "continuous_on W1 g" and gim: "g ` W1 ⊆ S" and geq: "⋀x. x ∈ C ⟹ g x = (fst ∘ f) x" (*goal: ‹(⋀(W1::(('a × 'b) × real) set) g::('a × 'b) × real ⇒ 'a. ⟦(C::(('a × 'b) × real) set) ⊆ W1; openin (top_of_set (U::(('a × 'b) × real) set)) W1; continuous_on W1 g; g ` W1 ⊆ (S::'a set); ⋀x::('a × 'b) × real. x ∈ C ⟹ g x = (fst ∘ (f::('a × 'b) × real ⇒ 'a × 'b)) x⟧ ⟹ thesis::bool) ⟹ thesis›*) proof (rule ANR_imp_absolute_neighbourhood_extensor [OF ‹ANR S› contf1 _ cloUC] (*‹⟦fst ∘ (f::('a × 'b) × real ⇒ 'a × 'b) ∈ (C::(('a × 'b) × real) set) → (S::'a set); ⋀(V::(('a × 'b) × real) set) g::('a × 'b) × real ⇒ 'a. ⟦C ⊆ V; openin (top_of_set (U::(('a × 'b) × real) set)) V; continuous_on V g; g ∈ V → S; ⋀x::('a × 'b) × real. x ∈ C ⟹ g x = (fst ∘ f) x⟧ ⟹ ?thesis::bool⟧ ⟹ ?thesis›*)) (*goals: 1. ‹(⋀W1 g. ⟦C ⊆ W1; openin (top_of_set U) W1; continuous_on W1 g; g ` W1 ⊆ S; ⋀x. x ∈ C ⟹ g x = (fst ∘ f) x⟧ ⟹ thesis) ⟹ fst ∘ f ∈ C → S› 2. ‹⋀V g. ⟦⋀W1 g. ⟦C ⊆ W1; openin (top_of_set U) W1; continuous_on W1 g; g ` W1 ⊆ S; ⋀x. x ∈ C ⟹ g x = (fst ∘ f) x⟧ ⟹ thesis; C ⊆ V; openin (top_of_set U) V; continuous_on V g; g ∈ V → S; ⋀x. x ∈ C ⟹ g x = (fst ∘ f) x⟧ ⟹ thesis›*) show "(fst ∘ f) ∈ C → S" using fim (*‹f ∈ C → S × T›*) by force qed (auto) (*solved the remaining goal: ‹⋀V g. ⟦⋀W1 g. ⟦C ⊆ W1; openin (top_of_set U) W1; continuous_on W1 g; g ` W1 ⊆ S; ⋀x. x ∈ C ⟹ g x = (fst ∘ f) x⟧ ⟹ thesis; C ⊆ V; openin (top_of_set U) V; continuous_on V g; g ∈ V → S; ⋀x. x ∈ C ⟹ g x = (fst ∘ f) x⟧ ⟹ thesis›*) have contf2: "continuous_on C (snd ∘ f)" by (simp add: ‹continuous_on C f› continuous_on_snd (*‹continuous_on ?s ?f ⟹ continuous_on ?s (λx. snd (?f x))›*)) obtain W2 and h where "C ⊆ W2" and UW2: "openin (top_of_set U) W2" and conth: "continuous_on W2 h" and him: "h ∈ W2 → T" and heq: "⋀x. x ∈ C ⟹ h x = (snd ∘ f) x" (*goal: ‹(⋀W2 h. ⟦C ⊆ W2; openin (top_of_set U) W2; continuous_on W2 h; h ∈ W2 → T; ⋀x. x ∈ C ⟹ h x = (snd ∘ f) x⟧ ⟹ thesis) ⟹ thesis›*) proof (rule ANR_imp_absolute_neighbourhood_extensor [OF ‹ANR T› contf2 _ cloUC] (*‹⟦snd ∘ f ∈ C → T; ⋀V g. ⟦C ⊆ V; openin (top_of_set U) V; continuous_on V g; g ∈ V → T; ⋀x. x ∈ C ⟹ g x = (snd ∘ f) x⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*)) (*goals: 1. ‹(⋀W2 h. ⟦C ⊆ W2; openin (top_of_set U) W2; continuous_on W2 h; h ∈ W2 → T; ⋀x. x ∈ C ⟹ h x = (snd ∘ f) x⟧ ⟹ thesis) ⟹ snd ∘ f ∈ C → T› 2. ‹⋀V g. ⟦⋀W2 h. ⟦C ⊆ W2; openin (top_of_set U) W2; continuous_on W2 h; h ∈ W2 → T; ⋀x. x ∈ C ⟹ h x = (snd ∘ f) x⟧ ⟹ thesis; C ⊆ V; openin (top_of_set U) V; continuous_on V g; g ∈ V → T; ⋀x. x ∈ C ⟹ g x = (snd ∘ f) x⟧ ⟹ thesis›*) show "(snd ∘ f) ∈ C → T" using fim (*‹f ∈ C → S × T›*) by force qed (auto) (*solved the remaining goal: ‹⋀V g. ⟦⋀W2 h. ⟦C ⊆ W2; openin (top_of_set U) W2; continuous_on W2 h; h ∈ W2 → T; ⋀x. x ∈ C ⟹ h x = (snd ∘ f) x⟧ ⟹ thesis; C ⊆ V; openin (top_of_set U) V; continuous_on V g; g ∈ V → T; ⋀x. x ∈ C ⟹ g x = (snd ∘ f) x⟧ ⟹ thesis›*) show "∃V g. C ⊆ V ∧ openin (top_of_set U) V ∧ continuous_on V g ∧ g ∈ V → S × T ∧ (∀x∈C. g x = f x)" proof (intro exI (*‹?P ?x ⟹ ∃x. ?P x›*) conjI (*‹⟦?P; ?Q⟧ ⟹ ?P ∧ ?Q›*)) (*goals: 1. ‹C ⊆ ?V› 2. ‹openin (top_of_set U) ?V› 3. ‹continuous_on ?V ?g1› 4. ‹?g1 ∈ ?V → S × T› 5. ‹∀x∈C. ?g1 x = f x›*) show "C ⊆ W1 ∩ W2" by (simp add: ‹C ⊆ W1› ‹C ⊆ W2›) show "openin (top_of_set U) (W1 ∩ W2)" by (simp add: UW1 (*‹openin (top_of_set U) W1›*) UW2 (*‹openin (top_of_set U) W2›*) openin_Int (*‹⟦openin ?U ?S; openin ?U ?T⟧ ⟹ openin ?U (?S ∩ ?T)›*)) show "continuous_on (W1 ∩ W2) (λx. (g x, h x))" by (metis (no_types) contg (*‹continuous_on W1 g›*) conth (*‹continuous_on W2 h›*) continuous_on_Pair (*‹⟦continuous_on ?s ?f; continuous_on ?s ?g⟧ ⟹ continuous_on ?s (λx. (?f x, ?g x))›*) continuous_on_subset (*‹⟦continuous_on ?s ?f; ?t ⊆ ?s⟧ ⟹ continuous_on ?t ?f›*) inf_commute (*‹inf ?x ?y = inf ?y ?x›*) inf_le1 (*‹inf ?x ?y ≤ ?x›*)) show "(λx. (g x, h x)) ∈ (W1 ∩ W2) → S × T" using gim (*‹g ` W1 ⊆ S›*) him (*‹h ∈ W2 → T›*) by blast show "(∀x∈C. (g x, h x) = f x)" using geq (*‹?x ∈ C ⟹ g ?x = (fst ∘ f) ?x›*) heq (*‹?x ∈ C ⟹ h ?x = (snd ∘ f) ?x›*) by auto qed qed lemma AR_Times: fixes S :: "'a::euclidean_space set" and T :: "'b::euclidean_space set" assumes "AR S" "AR T" shows "AR(S × T)" using assms (*‹AR S› ‹AR T›*) by (simp add: AR_ANR (*‹AR ?S = (ANR ?S ∧ contractible ?S ∧ ?S ≠ {})›*) ANR_Times (*‹⟦ANR ?S; ANR ?T⟧ ⟹ ANR (?S × ?T)›*) contractible_Times (*‹⟦contractible ?S; contractible ?T⟧ ⟹ contractible (?S × ?T)›*)) (* Unused and requires ordered_euclidean_space subsection✐‹tag unimportant›‹Retracts and intervals in ordered euclidean space› lemma ANR_interval [iff]: fixes a :: "'a::ordered_euclidean_space" shows "ANR{a..b}" by (simp add: interval_cbox) lemma ENR_interval [iff]: fixes a :: "'a::ordered_euclidean_space" shows "ENR{a..b}" by (auto simp: interval_cbox) *) subsection ‹More advanced properties of ANRs and ENRs› lemma ENR_rel_frontier_convex: fixes S :: "'a::euclidean_space set" assumes "bounded S" "convex S" shows "ENR(rel_frontier S)" proof (cases "S = {}") (*goals: 1. ‹(S::'a set) = {} ⟹ ENR (rel_frontier S)› 2. ‹(S::'a set) ≠ {} ⟹ ENR (rel_frontier S)›*) case True (*‹S = {}›*) then show "?thesis" (*goal: ‹ENR (rel_frontier S)›*) by simp next (*goal: ‹(S::'a set) ≠ {} ⟹ ENR (rel_frontier S)›*) case False (*‹S ≠ {}›*) with assms (*‹bounded S› ‹convex (S::'a set)›*) have "rel_interior S ≠ {}" by (simp add: rel_interior_eq_empty (*‹convex (?S::?'n set) ⟹ (rel_interior ?S = {}) = (?S = {})›*)) then obtain a where a: "a ∈ rel_interior S" (*goal: ‹(⋀a::'a. a ∈ rel_interior (S::'a set) ⟹ thesis::bool) ⟹ thesis›*) by auto have ahS: "affine hull S - {a} ⊆ {x. closest_point (affine hull S) x ≠ a}" by (auto simp: closest_point_self (*‹?x ∈ ?S ⟹ closest_point ?S ?x = ?x›*)) have "rel_frontier S retract_of affine hull S - {a}" by (simp add: assms (*‹bounded S› ‹convex S›*) a (*‹a ∈ rel_interior S›*) rel_frontier_retract_of_punctured_affine_hull (*‹⟦bounded ?S; convex ?S; ?a ∈ rel_interior ?S⟧ ⟹ rel_frontier ?S retract_of affine hull ?S - {?a}›*)) also (*calculation: ‹rel_frontier S retract_of affine hull S - {a}›*) have "… retract_of {x. closest_point (affine hull S) x ≠ a}" unfolding retract_of_def retraction_def ahS (*goal: ‹∃r. affine hull S - {a} ⊆ {x. closest_point (affine hull S) x ≠ a} ∧ continuous_on {x. closest_point (affine hull S) x ≠ a} r ∧ r ∈ {x. closest_point (affine hull S) x ≠ a} → affine hull S - {a} ∧ (∀x∈affine hull S - {a}. r x = x)›*) apply (rule_tac x="closest_point (affine hull S)" in exI (*‹?P ?x ⟹ ∃x. ?P x›*)) (*goal: ‹∃r. affine hull S - {a} ⊆ {x. closest_point (affine hull S) x ≠ a} ∧ continuous_on {x. closest_point (affine hull S) x ≠ a} r ∧ r ∈ {x. closest_point (affine hull S) x ≠ a} → affine hull S - {a} ∧ (∀x∈affine hull S - {a}. r x = x)›*) by (auto simp: False (*‹S ≠ {}›*) closest_point_self (*‹?x ∈ ?S ⟹ closest_point ?S ?x = ?x›*) affine_imp_convex (*‹affine ?s ⟹ convex ?s›*) closest_point_in_set (*‹⟦closed ?S; ?S ≠ {}⟧ ⟹ closest_point ?S ?a ∈ ?S›*) continuous_on_closest_point (*‹⟦convex ?S; closed ?S; ?S ≠ {}⟧ ⟹ continuous_on ?t (closest_point ?S)›*)) finally (*calculation: ‹rel_frontier S retract_of {x. closest_point (affine hull S) x ≠ a}›*) have "rel_frontier S retract_of {x. closest_point (affine hull S) x ≠ a}" . moreover have "openin (top_of_set UNIV) (UNIV ∩ closest_point (affine hull S) -` (- {a}))" apply (intro continuous_openin_preimage_gen (*‹⟦continuous_on ?S ?f; open ?T⟧ ⟹ openin (top_of_set ?S) (?S ∩ ?f -` ?T)›*)) (*goals: 1. ‹continuous_on UNIV (closest_point (affine hull (S::'a::euclidean_space set)))› 2. ‹open (- {a::'a::euclidean_space})› discuss goal 1*) apply ((auto simp: False (*‹(S::'a set) ≠ {}›*) affine_imp_convex (*‹affine (?s::?'a set) ⟹ convex ?s›*) continuous_on_closest_point (*‹⟦convex (?S::?'a set); closed ?S; ?S ≠ {}⟧ ⟹ continuous_on (?t::?'a set) (closest_point ?S)›*))[1]) (*discuss goal 2*) apply ((auto simp: False (*‹(S::'a set) ≠ {}›*) affine_imp_convex (*‹affine (?s::?'a set) ⟹ convex ?s›*) continuous_on_closest_point (*‹⟦convex (?S::?'a set); closed ?S; ?S ≠ {}⟧ ⟹ continuous_on (?t::?'a set) (closest_point ?S)›*))[1]) (*proven 2 subgoals*) . ultimately show "?thesis" (*goal: ‹ENR (rel_frontier S)›*) by (meson ENR_convex_closed (*‹⟦closed (?S::?'a::euclidean_space set); convex ?S⟧ ⟹ ENR ?S›*) ENR_delete (*‹ENR (?S::?'a::euclidean_space set) ⟹ ENR (?S - {?a::?'a::euclidean_space})›*) ENR_retract_of_ENR (*‹⟦ENR (?T::?'a::topological_space set); (?S::?'a::topological_space set) retract_of ?T⟧ ⟹ ENR ?S›*) ‹rel_frontier S retract_of affine hull S - {a}› closed_affine_hull (*‹closed (affine hull (?S::?'n::euclidean_space set))›*) convex_affine_hull (*‹convex (affine hull (?S::?'a::real_vector set))›*)) qed lemma ANR_rel_frontier_convex: fixes S :: "'a::euclidean_space set" assumes "bounded S" "convex S" shows "ANR(rel_frontier S)" by (simp add: ENR_imp_ANR (*‹ENR (?S::?'a set) ⟹ ANR ?S›*) ENR_rel_frontier_convex (*‹⟦bounded (?S::?'a set); convex ?S⟧ ⟹ ENR (rel_frontier ?S)›*) assms (*‹bounded (S::'a set)› ‹convex (S::'a set)›*)) lemma ENR_closedin_Un_local: fixes S :: "'a::euclidean_space set" shows "⟦ENR S; ENR T; ENR(S ∩ T); closedin (top_of_set (S ∪ T)) S; closedin (top_of_set (S ∪ T)) T⟧ ⟹ ENR(S ∪ T)" by (simp add: ENR_ANR (*‹ENR ?S = (ANR ?S ∧ locally compact ?S)›*) ANR_closed_Un_local (*‹⟦closedin (top_of_set (?S ∪ ?T)) ?S; closedin (top_of_set (?S ∪ ?T)) ?T; ANR ?S; ANR ?T; ANR (?S ∩ ?T)⟧ ⟹ ANR (?S ∪ ?T)›*) locally_compact_closedin_Un (*‹⟦locally compact ?S; locally compact ?T; closedin (top_of_set (?S ∪ ?T)) ?S; closedin (top_of_set (?S ∪ ?T)) ?T⟧ ⟹ locally compact (?S ∪ ?T)›*)) lemma ENR_closed_Un: fixes S :: "'a::euclidean_space set" shows "⟦closed S; closed T; ENR S; ENR T; ENR(S ∩ T)⟧ ⟹ ENR(S ∪ T)" by (auto simp: closed_subset (*‹⟦(?S::?'a set) ⊆ (?T::?'a set); closed ?S⟧ ⟹ closedin (top_of_set ?T) ?S›*) ENR_closedin_Un_local (*‹⟦ENR (?S::?'a set); ENR (?T::?'a set); ENR (?S ∩ ?T); closedin (top_of_set (?S ∪ ?T)) ?S; closedin (top_of_set (?S ∪ ?T)) ?T⟧ ⟹ ENR (?S ∪ ?T)›*)) lemma absolute_retract_Un: fixes S :: "'a::euclidean_space set" shows "⟦S retract_of UNIV; T retract_of UNIV; (S ∩ T) retract_of UNIV⟧ ⟹ (S ∪ T) retract_of UNIV" by (meson AR_closed_Un_local_aux (*‹⟦closedin (top_of_set (?U::?'a::euclidean_space set)) (?S::?'a::euclidean_space set); closedin (top_of_set ?U) (?T::?'a::euclidean_space set); AR ?S; AR ?T; AR (?S ∩ ?T)⟧ ⟹ ?S ∪ ?T retract_of ?U›*) closed_subset (*‹⟦(?S::?'a::topological_space set) ⊆ (?T::?'a::topological_space set); closed ?S⟧ ⟹ closedin (top_of_set ?T) ?S›*) retract_of_UNIV (*‹((?S::?'a::euclidean_space set) retract_of UNIV) = (AR ?S ∧ closed ?S)›*) retract_of_imp_subset (*‹(?S::?'a::topological_space set) retract_of (?T::?'a::topological_space set) ⟹ ?S ⊆ ?T›*)) lemma retract_from_Un_Int: fixes S :: "'a::euclidean_space set" assumes clS: "closedin (top_of_set (S ∪ T)) S" and clT: "closedin (top_of_set (S ∪ T)) T" and Un: "(S ∪ T) retract_of U" and Int: "(S ∩ T) retract_of T" shows "S retract_of U" proof (-) (*goal: ‹S retract_of U›*) obtain r where r: "continuous_on T r" "r ` T ⊆ S ∩ T" "∀x∈S ∩ T. r x = x" (*goal: ‹(⋀r::'a ⇒ 'a. ⟦continuous_on (T::'a set) r; r ` T ⊆ (S::'a set) ∩ T; ∀x::'a∈S ∩ T. r x = x⟧ ⟹ thesis::bool) ⟹ thesis›*) using Int (*‹S ∩ T retract_of T›*) by (auto simp: retraction_def (*‹retraction ?S ?T ?r = (?T ⊆ ?S ∧ continuous_on ?S ?r ∧ ?r ∈ ?S → ?T ∧ (∀x∈?T. ?r x = x))›*) retract_of_def (*‹(?T retract_of ?S) = (∃r. retraction ?S ?T r)›*)) have "S retract_of S ∪ T" unfolding retraction_def retract_of_def (*goal: ‹∃r. S ⊆ S ∪ T ∧ continuous_on (S ∪ T) r ∧ r ∈ S ∪ T → S ∧ (∀x∈S. r x = x)›*) proof (intro exI (*‹?P ?x ⟹ ∃x. ?P x›*) conjI (*‹⟦?P; ?Q⟧ ⟹ ?P ∧ ?Q›*)) (*goals: 1. ‹S ⊆ S ∪ T› 2. ‹continuous_on (S ∪ T) ?r› 3. ‹?r ∈ S ∪ T → S› 4. ‹∀x∈S. ?r x = x›*) show "continuous_on (S ∪ T) (λx. if x ∈ S then x else r x)" using r (*‹continuous_on (T::'a set) (r::'a ⇒ 'a)› ‹r ` T ⊆ S ∩ T› ‹∀x∈S ∩ T. r x = x›*) apply (intro continuous_on_cases_local [OF clS clT] (*‹⟦continuous_on (S::'a set) (?f::'a ⇒ ?'b); continuous_on (T::'a set) (?g::'a ⇒ ?'b); ⋀x::'a. x ∈ S ∧ ¬ (?P::'a ⇒ bool) x ∨ x ∈ T ∧ ?P x ⟹ ?f x = ?g x⟧ ⟹ continuous_on (S ∪ T) (λx::'a. if ?P x then ?f x else ?g x)›*)) (*goals: 1. ‹⟦continuous_on T r; r ` T ⊆ S ∩ T; ∀x∈S ∩ T. r x = x⟧ ⟹ continuous_on S (λx. x)› 2. ‹⟦continuous_on T r; r ` T ⊆ S ∩ T; ∀x∈S ∩ T. r x = x⟧ ⟹ continuous_on T r› 3. ‹⋀x. ⟦continuous_on T r; r ` T ⊆ S ∩ T; ∀x∈S ∩ T. r x = x; x ∈ S ∧ x ∉ S ∨ x ∈ T ∧ x ∈ S⟧ ⟹ x = r x› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*proven 3 subgoals*) . qed (use r in auto) (*solves the remaining goals: 1. ‹S ⊆ S ∪ T› 2. ‹(λx. if x ∈ S then x else r x) ∈ S ∪ T → S› 3. ‹∀x∈S. (if x ∈ S then x else r x) = x›*) also (*calculation: ‹S retract_of S ∪ T›*) have "… retract_of U" by (rule Un (*‹S ∪ T retract_of U›*)) finally (*calculation: ‹S retract_of U›*) show "?thesis" (*goal: ‹S retract_of U›*) . qed lemma AR_from_Un_Int_local: fixes S :: "'a::euclidean_space set" assumes clS: "closedin (top_of_set (S ∪ T)) S" and clT: "closedin (top_of_set (S ∪ T)) T" and Un: "AR(S ∪ T)" and Int: "AR(S ∩ T)" shows "AR S" by (meson AR_imp_retract (*‹AR (?S::?'a set) ∧ closedin (top_of_set (?U::?'a set)) ?S ⟹ ?S retract_of ?U›*) AR_retract_of_AR (*‹⟦AR (?T::?'a set); (?S::?'a set) retract_of ?T⟧ ⟹ AR ?S›*) Un (*‹AR ((S::'a set) ∪ (T::'a set))›*) assms (*‹closedin (top_of_set ((S::'a set) ∪ (T::'a set))) S› ‹closedin (top_of_set ((S::'a set) ∪ (T::'a set))) T› ‹AR ((S::'a set) ∪ (T::'a set))› ‹AR ((S::'a set) ∩ (T::'a set))›*) closedin_closed_subset (*‹⟦closedin (top_of_set (?U::?'a set)) (?V::?'a set); (?T::?'a set) ⊆ ?U; (?S::?'a set) = ?V ∩ ?T⟧ ⟹ closedin (top_of_set ?T) ?S›*) local.Int (*‹AR ((S::'a set) ∩ (T::'a set))›*) retract_from_Un_Int (*‹⟦closedin (top_of_set ((?S::?'a set) ∪ (?T::?'a set))) ?S; closedin (top_of_set (?S ∪ ?T)) ?T; ?S ∪ ?T retract_of (?U::?'a set); ?S ∩ ?T retract_of ?T⟧ ⟹ ?S retract_of ?U›*) retract_of_refl (*‹(?S::?'a set) retract_of ?S›*) sup_ge2 (*‹(?y::?'a) ≤ sup (?x::?'a) ?y›*)) lemma AR_from_Un_Int_local': fixes S :: "'a::euclidean_space set" assumes "closedin (top_of_set (S ∪ T)) S" and "closedin (top_of_set (S ∪ T)) T" and "AR(S ∪ T)" "AR(S ∩ T)" shows "AR T" using AR_from_Un_Int_local[of T S] (*‹⟦closedin (top_of_set (T ∪ S)) T; closedin (top_of_set (T ∪ S)) S; AR (T ∪ S); AR (T ∩ S)⟧ ⟹ AR T›*) assms (*‹closedin (top_of_set (S ∪ T)) S› ‹closedin (top_of_set ((S::'a set) ∪ (T::'a set))) T› ‹AR (S ∪ T)› ‹AR (S ∩ T)›*) by (simp add: Un_commute (*‹?A ∪ ?B = ?B ∪ ?A›*) Int_commute (*‹?A ∩ ?B = ?B ∩ ?A›*)) lemma AR_from_Un_Int: fixes S :: "'a::euclidean_space set" assumes clo: "closed S" "closed T" and Un: "AR(S ∪ T)" and Int: "AR(S ∩ T)" shows "AR S" by (metis AR_from_Un_Int_local [OF _ _ Un Int] (*‹⟦closedin (top_of_set ((S::'a::euclidean_space set) ∪ (T::'a::euclidean_space set))) S; closedin (top_of_set (S ∪ T)) T⟧ ⟹ AR S›*) Un_commute (*‹(?A::?'a::type set) ∪ (?B::?'a::type set) = ?B ∪ ?A›*) clo (*‹closed (S::'a::euclidean_space set)› ‹closed (T::'a::euclidean_space set)›*) closed_closedin (*‹closed (?S::?'a::topological_space set) = closedin euclidean ?S›*) closedin_closed_subset (*‹⟦closedin (top_of_set (?U::?'a::topological_space set)) (?V::?'a::topological_space set); (?T::?'a::topological_space set) ⊆ ?U; (?S::?'a::topological_space set) = ?V ∩ ?T⟧ ⟹ closedin (top_of_set ?T) ?S›*) inf_sup_absorb (*‹inf (?x::?'a::lattice) (sup ?x (?y::?'a::lattice)) = ?x›*) subtopology_UNIV (*‹subtopology (?U::?'a::type topology) UNIV = ?U›*) top_greatest (*‹(?a::?'a::order_top) ≤ top›*)) lemma ANR_from_Un_Int_local: fixes S :: "'a::euclidean_space set" assumes clS: "closedin (top_of_set (S ∪ T)) S" and clT: "closedin (top_of_set (S ∪ T)) T" and Un: "ANR(S ∪ T)" and Int: "ANR(S ∩ T)" shows "ANR S" proof (-) (*goal: ‹ANR (S::'a set)›*) obtain V where clo: "closedin (top_of_set (S ∪ T)) (S ∩ T)" and ope: "openin (top_of_set (S ∪ T)) V" and ret: "S ∩ T retract_of V" (*goal: ‹(⋀V. ⟦closedin (top_of_set (S ∪ T)) (S ∩ T); openin (top_of_set (S ∪ T)) V; S ∩ T retract_of V⟧ ⟹ thesis) ⟹ thesis›*) using ANR_imp_neighbourhood_retract[OF Int] (*‹⟦closedin (top_of_set ?U) (S ∩ T); ⋀V. ⟦openin (top_of_set ?U) V; S ∩ T retract_of V⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*) by (metis clS (*‹closedin (top_of_set (S ∪ T)) S›*) clT (*‹closedin (top_of_set (S ∪ T)) T›*) closedin_Int (*‹⟦closedin ?U ?S; closedin ?U ?T⟧ ⟹ closedin ?U (?S ∩ ?T)›*)) then obtain r where r: "continuous_on V r" and rim: "r ` V ⊆ S ∩ T" and req: "∀x∈S ∩ T. r x = x" (*goal: ‹(⋀r::'a ⇒ 'a. ⟦continuous_on (V::'a set) r; r ` V ⊆ (S::'a set) ∩ (T::'a set); ∀x::'a∈S ∩ T. r x = x⟧ ⟹ thesis::bool) ⟹ thesis›*) by (auto simp: retraction_def (*‹retraction ?S ?T ?r = (?T ⊆ ?S ∧ continuous_on ?S ?r ∧ ?r ∈ ?S → ?T ∧ (∀x∈?T. ?r x = x))›*) retract_of_def (*‹(?T retract_of ?S) = (∃r. retraction ?S ?T r)›*)) have Vsub: "V ⊆ S ∪ T" by (meson ope (*‹openin (top_of_set (S ∪ T)) V›*) openin_contains_cball (*‹openin (top_of_set ?T) ?S = (?S ⊆ ?T ∧ (∀x∈?S. ∃e>0. cball x e ∩ ?T ⊆ ?S))›*)) have Vsup: "S ∩ T ⊆ V" by (simp add: retract_of_imp_subset (*‹?S retract_of ?T ⟹ ?S ⊆ ?T›*) ret (*‹S ∩ T retract_of V›*)) then have eq: "S ∪ V = ((S ∪ T) - T) ∪ V" by auto have eq': "S ∪ V = S ∪ (V ∩ T)" using Vsub (*‹(V::'a set) ⊆ (S::'a set) ∪ (T::'a set)›*) by blast have "continuous_on (S ∪ V ∩ T) (λx. if x ∈ S then x else r x)" proof (rule continuous_on_cases_local (*‹⟦closedin (top_of_set (?S ∪ ?T)) ?S; closedin (top_of_set (?S ∪ ?T)) ?T; continuous_on ?S ?f; continuous_on ?T ?g; ⋀x. x ∈ ?S ∧ ¬ ?P x ∨ x ∈ ?T ∧ ?P x ⟹ ?f x = ?g x⟧ ⟹ continuous_on (?S ∪ ?T) (λx. if ?P x then ?f x else ?g x)›*)) (*goals: 1. ‹closedin (top_of_set (S ∪ V ∩ T)) S› 2. ‹closedin (top_of_set (S ∪ V ∩ T)) (V ∩ T)› 3. ‹continuous_on S (λx. x)› 4. ‹continuous_on (V ∩ T) r› 5. ‹⋀x. x ∈ S ∧ x ∉ S ∨ x ∈ V ∩ T ∧ x ∈ S ⟹ x = r x›*) show "closedin (top_of_set (S ∪ V ∩ T)) S" using clS (*‹closedin (top_of_set (S ∪ T)) S›*) closedin_subset_trans (*‹⟦closedin (top_of_set (?U::?'a set)) (?S::?'a set); ?S ⊆ (?T::?'a set); ?T ⊆ ?U⟧ ⟹ closedin (top_of_set ?T) ?S›*) inf.boundedE (*‹⟦?a ≤ inf ?b ?c; ⟦?a ≤ ?b; ?a ≤ ?c⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*) by blast show "closedin (top_of_set (S ∪ V ∩ T)) (V ∩ T)" using clT (*‹closedin (top_of_set (S ∪ T)) T›*) Vsup (*‹(S::'a::euclidean_space set) ∩ (T::'a::euclidean_space set) ⊆ (V::'a::euclidean_space set)›*) by (auto simp: closedin_closed (*‹closedin (top_of_set ?U) ?S = (∃T. closed T ∧ ?S = ?U ∩ T)›*)) show "continuous_on (V ∩ T) r" by (meson Int_lower1 (*‹?A ∩ ?B ⊆ ?A›*) continuous_on_subset (*‹⟦continuous_on ?s ?f; ?t ⊆ ?s⟧ ⟹ continuous_on ?t ?f›*) r (*‹continuous_on V r›*)) qed (use req continuous_on_id in auto) (*solves the remaining goals: 1. ‹continuous_on S (λx. x)› 2. ‹⋀x. x ∈ S ∧ x ∉ S ∨ x ∈ V ∩ T ∧ x ∈ S ⟹ x = r x›*) with rim (*‹r ` V ⊆ S ∩ T›*) have "S retract_of S ∪ V" unfolding retraction_def retract_of_def (*goal: ‹∃r. S ⊆ S ∪ V ∧ continuous_on (S ∪ V) r ∧ r ∈ S ∪ V → S ∧ (∀x∈S. r x = x)›*) using eq' (*‹S ∪ V = S ∪ V ∩ T›*) by fastforce then show "?thesis" (*goal: ‹ANR S›*) using ANR_neighborhood_retract[OF Un] (*‹⟦?S retract_of ?T; openin (top_of_set (S ∪ T)) ?T⟧ ⟹ ANR ?S›*) using ‹S ∪ V = S ∪ T - T ∪ V› (*‹S ∪ V = S ∪ T - T ∪ V›*) clT (*‹closedin (top_of_set (S ∪ T)) T›*) ope (*‹openin (top_of_set (S ∪ T)) V›*) by fastforce qed lemma ANR_from_Un_Int: fixes S :: "'a::euclidean_space set" assumes clo: "closed S" "closed T" and Un: "ANR(S ∪ T)" and Int: "ANR(S ∩ T)" shows "ANR S" by (metis ANR_from_Un_Int_local [OF _ _ Un Int] (*‹⟦closedin (top_of_set ((S::'a set) ∪ (T::'a set))) S; closedin (top_of_set (S ∪ T)) T⟧ ⟹ ANR S›*) Un_commute (*‹(?A::?'a set) ∪ (?B::?'a set) = ?B ∪ ?A›*) clo (*‹closed (S::'a set)› ‹closed (T::'a set)›*) closed_closedin (*‹closed (?S::?'a set) = closedin euclidean ?S›*) closedin_closed_subset (*‹⟦closedin (top_of_set (?U::?'a set)) (?V::?'a set); (?T::?'a set) ⊆ ?U; (?S::?'a set) = ?V ∩ ?T⟧ ⟹ closedin (top_of_set ?T) ?S›*) inf_sup_absorb (*‹inf (?x::?'a) (sup ?x (?y::?'a)) = ?x›*) subtopology_UNIV (*‹subtopology (?U::?'a topology) UNIV = ?U›*) top_greatest (*‹(?a::?'a) ≤ top›*)) lemma ANR_finite_Union_convex_closed: fixes 𝒯 :: "'a::euclidean_space set set" assumes 𝒯: "finite 𝒯" and clo: "⋀C. C ∈ 𝒯 ⟹ closed C" and con: "⋀C. C ∈ 𝒯 ⟹ convex C" shows "ANR(⋃𝒯)" proof (-) (*goal: ‹ANR (⋃ 𝒯)›*) have "ANR(⋃𝒯)" if "card 𝒯 < n" for n using assms (*‹finite 𝒯› ‹?C ∈ 𝒯 ⟹ closed ?C› ‹?C ∈ 𝒯 ⟹ convex ?C›*) that (*‹card 𝒯 < n›*) proof (induction n arbitrary: 𝒯) (*goals: 1. ‹⋀𝒯. ⟦finite 𝒯; ⋀C. C ∈ 𝒯 ⟹ closed C; ⋀C. C ∈ 𝒯 ⟹ convex C; card 𝒯 < 0⟧ ⟹ ANR (⋃ 𝒯)› 2. ‹⋀n 𝒯. ⟦⋀𝒯. ⟦finite 𝒯; ⋀C. C ∈ 𝒯 ⟹ closed C; ⋀C. C ∈ 𝒯 ⟹ convex C; card 𝒯 < n⟧ ⟹ ANR (⋃ 𝒯); finite 𝒯; ⋀C. C ∈ 𝒯 ⟹ closed C; ⋀C. C ∈ 𝒯 ⟹ convex C; card 𝒯 < Suc n⟧ ⟹ ANR (⋃ 𝒯)›*) case 0 (*‹finite 𝒯› ‹?C ∈ 𝒯 ⟹ closed ?C› ‹?C ∈ 𝒯 ⟹ convex ?C› ‹card 𝒯 < 0›*) then show "?case" (*goal: ‹ANR (⋃ 𝒯)›*) by simp next (*goal: ‹⋀n 𝒯. ⟦⋀𝒯. ⟦finite 𝒯; ⋀C. C ∈ 𝒯 ⟹ closed C; ⋀C. C ∈ 𝒯 ⟹ convex C; card 𝒯 < n⟧ ⟹ ANR (⋃ 𝒯); finite 𝒯; ⋀C. C ∈ 𝒯 ⟹ closed C; ⋀C. C ∈ 𝒯 ⟹ convex C; card 𝒯 < Suc n⟧ ⟹ ANR (⋃ 𝒯)›*) case (Suc n) (*‹⟦finite (?𝒯::'a set set); ⋀C::'a set. C ∈ ?𝒯 ⟹ closed C; ⋀C::'a set. C ∈ ?𝒯 ⟹ convex C; card ?𝒯 < (n::nat)⟧ ⟹ ANR (⋃ ?𝒯)› ‹finite 𝒯› ‹?C ∈ 𝒯 ⟹ closed ?C› ‹?C ∈ 𝒯 ⟹ convex ?C› ‹card 𝒯 < Suc n›*) have "ANR(⋃𝒰)" if "finite 𝒰" "𝒰 ⊆ 𝒯" for 𝒰 using that (*‹finite 𝒰› ‹𝒰 ⊆ 𝒯›*) proof (induction 𝒰) (*goals: 1. ‹{} ⊆ (𝒯::'a::euclidean_space set set) ⟹ ANR (⋃ {})› 2. ‹⋀(x::'a::euclidean_space set) F::'a::euclidean_space set set. ⟦finite F; x ∉ F; F ⊆ (𝒯::'a::euclidean_space set set) ⟹ ANR (⋃ F); insert x F ⊆ 𝒯⟧ ⟹ ANR (⋃ (insert x F))›*) case empty (*‹{} ⊆ 𝒯›*) then show "?case" (*goal: ‹ANR (⋃ {})›*) by simp next (*goal: ‹⋀x F. ⟦finite F; x ∉ F; F ⊆ 𝒯 ⟹ ANR (⋃ F); insert x F ⊆ 𝒯⟧ ⟹ ANR (⋃ (insert x F))›*) case (insert C 𝒰) (*‹finite 𝒰› ‹(C::'a set) ∉ (𝒰::'a set set)› ‹𝒰 ⊆ 𝒯 ⟹ ANR (⋃ 𝒰)› ‹insert C 𝒰 ⊆ 𝒯›*) have "ANR (C ∪ ⋃𝒰)" proof (rule ANR_closed_Un (*‹⟦closed ?S; closed ?T; ANR ?S; ANR ?T; ANR (?S ∩ ?T)⟧ ⟹ ANR (?S ∪ ?T)›*)) (*goals: 1. ‹closed C› 2. ‹closed (⋃ 𝒰)› 3. ‹ANR C› 4. ‹ANR (⋃ 𝒰)› 5. ‹ANR (C ∩ ⋃ 𝒰)›*) show "ANR (C ∩ ⋃𝒰)" unfolding Int_Union (*goal: ‹ANR (⋃ ((∩) (C::'a set) ` (𝒰::'a set set)))›*) proof (rule Suc (*‹⟦finite ?𝒯; ⋀C. C ∈ ?𝒯 ⟹ closed C; ⋀C. C ∈ ?𝒯 ⟹ convex C; card ?𝒯 < n⟧ ⟹ ANR (⋃ ?𝒯)› ‹finite 𝒯› ‹?C ∈ 𝒯 ⟹ closed ?C› ‹?C ∈ 𝒯 ⟹ convex ?C› ‹card 𝒯 < Suc n›*)) (*goals: 1. ‹finite ((∩) (C::'a::euclidean_space set) ` (𝒰::'a::euclidean_space set set))› 2. ‹⋀Ca::'a::euclidean_space set. Ca ∈ (∩) (C::'a::euclidean_space set) ` (𝒰::'a::euclidean_space set set) ⟹ closed Ca› 3. ‹⋀Ca::'a::euclidean_space set. Ca ∈ (∩) (C::'a::euclidean_space set) ` (𝒰::'a::euclidean_space set set) ⟹ convex Ca› 4. ‹card ((∩) (C::'a::euclidean_space set) ` (𝒰::'a::euclidean_space set set)) < (n::nat)›*) show "finite ((∩) C ` 𝒰)" by (simp add: insert.hyps( (*‹finite (𝒰::'a set set)›*) 1)) show "⋀Ca. Ca ∈ (∩) C ` 𝒰 ⟹ closed Ca" by (metis (no_types, opaque_lifting) Suc.prems( (*‹?C ∈ 𝒯 ⟹ closed ?C›*) 2) closed_Int (*‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∩ ?T)›*) subsetD (*‹⟦?A ⊆ ?B; ?c ∈ ?A⟧ ⟹ ?c ∈ ?B›*) imageE (*‹⟦?b ∈ ?f ` ?A; ⋀x. ⟦?b = ?f x; x ∈ ?A⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*) insert.prems (*‹insert C 𝒰 ⊆ 𝒯›*) insertI1 (*‹?a ∈ insert ?a ?B›*) insertI2 (*‹?a ∈ ?B ⟹ ?a ∈ insert ?b ?B›*)) show "⋀Ca. Ca ∈ (∩) C ` 𝒰 ⟹ convex Ca" by (metis (mono_tags, lifting) Suc.prems( (*‹?C ∈ 𝒯 ⟹ convex ?C›*) 3) convex_Int (*‹⟦convex ?s; convex ?t⟧ ⟹ convex (?s ∩ ?t)›*) imageE (*‹⟦?b ∈ ?f ` ?A; ⋀x. ⟦?b = ?f x; x ∈ ?A⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*) insert.prems (*‹insert C 𝒰 ⊆ 𝒯›*) insert_subset (*‹(insert ?x ?A ⊆ ?B) = (?x ∈ ?B ∧ ?A ⊆ ?B)›*) subsetCE (*‹⟦?A ⊆ ?B; ?c ∉ ?A ⟹ ?P; ?c ∈ ?B ⟹ ?P⟧ ⟹ ?P›*)) show "card ((∩) C ` 𝒰) < n" proof (-) (*goal: ‹card ((∩) C ` 𝒰) < n›*) have "card 𝒯 ≤ n" by (meson Suc.prems( (*‹card (𝒯::'a::euclidean_space set set) < Suc (n::nat)›*) 4) not_less (*‹(¬ (?x::?'a::linorder) < (?y::?'a::linorder)) = (?y ≤ ?x)›*) not_less_eq (*‹(¬ (?m::nat) < (?n::nat)) = (?n < Suc ?m)›*)) then show "?thesis" (*goal: ‹card ((∩) C ` 𝒰) < n›*) by (metis Suc.prems( (*‹finite (𝒯::'a set set)›*) 1) card_image_le (*‹finite (?A::?'a set) ⟹ card ((?f::?'a ⇒ ?'b) ` ?A) ≤ card ?A›*) card_seteq (*‹⟦finite (?B::?'a set); (?A::?'a set) ⊆ ?B; card ?B ≤ card ?A⟧ ⟹ ?A = ?B›*) insert.hyps (*‹finite (𝒰::'a set set)› ‹(C::'a set) ∉ (𝒰::'a set set)›*) insert.prems (*‹insert (C::'a set) (𝒰::'a set set) ⊆ (𝒯::'a set set)›*) insert_subset (*‹(insert (?x::?'a) (?A::?'a set) ⊆ (?B::?'a set)) = (?x ∈ ?B ∧ ?A ⊆ ?B)›*) le_trans (*‹⟦(?i::nat) ≤ (?j::nat); ?j ≤ (?k::nat)⟧ ⟹ ?i ≤ ?k›*) not_less (*‹(¬ (?x::?'a) < (?y::?'a)) = (?y ≤ ?x)›*)) qed qed show "closed (⋃𝒰)" using Suc.prems(2) (*‹?C ∈ 𝒯 ⟹ closed ?C›*) insert.hyps(1) (*‹finite 𝒰›*) insert.prems (*‹insert C 𝒰 ⊆ 𝒯›*) by blast qed (use Suc.prems convex_imp_ANR insert.prems insert.IH in auto) (*solves the remaining goals: 1. ‹closed C› 2. ‹ANR C› 3. ‹ANR (⋃ 𝒰)›*) then show "?case" (*goal: ‹ANR (⋃ (insert (C::'a set) (𝒰::'a set set)))›*) by simp qed then show "?case" (*goal: ‹ANR (⋃ (𝒯::'a::euclidean_space set set))›*) using Suc.prems(1) (*‹finite 𝒯›*) by blast qed then show "?thesis" (*goal: ‹ANR (⋃ (𝒯::'a set set))›*) by blast qed lemma finite_imp_ANR: fixes S :: "'a::euclidean_space set" assumes "finite S" shows "ANR S" proof (-) (*goal: ‹ANR S›*) have "ANR(⋃x ∈ S. {x})" by (blast intro: ANR_finite_Union_convex_closed (*‹⟦finite (?𝒯::?'a set set); ⋀C::?'a set. C ∈ ?𝒯 ⟹ closed C; ⋀C::?'a set. C ∈ ?𝒯 ⟹ convex C⟧ ⟹ ANR (⋃ ?𝒯)›*) assms (*‹finite (S::'a set)›*)) then show "?thesis" (*goal: ‹ANR S›*) by simp qed lemma ANR_insert: fixes S :: "'a::euclidean_space set" assumes "ANR S" "closed S" shows "ANR(insert a S)" by (metis ANR_closed_Un (*‹⟦closed ?S; closed ?T; ANR ?S; ANR ?T; ANR (?S ∩ ?T)⟧ ⟹ ANR (?S ∪ ?T)›*) ANR_empty (*‹ANR {}›*) ANR_singleton (*‹ANR {?a}›*) Diff_disjoint (*‹?A ∩ (?B - ?A) = {}›*) Diff_insert_absorb (*‹?x ∉ ?A ⟹ insert ?x ?A - {?x} = ?A›*) assms (*‹ANR S› ‹closed S›*) closed_singleton (*‹closed {?a}›*) insert_absorb (*‹?a ∈ ?A ⟹ insert ?a ?A = ?A›*) insert_is_Un (*‹insert ?a ?A = {?a} ∪ ?A›*)) lemma ANR_path_component_ANR: fixes S :: "'a::euclidean_space set" shows "ANR S ⟹ ANR(path_component_set S x)" using ANR_imp_locally_path_connected (*‹ANR ?S ⟹ locally path_connected ?S›*) ANR_openin (*‹⟦ANR ?T; openin (top_of_set ?T) ?S⟧ ⟹ ANR ?S›*) openin_path_component_locally_path_connected (*‹locally path_connected ?S ⟹ openin (top_of_set ?S) (path_component_set ?S ?x)›*) by blast lemma ANR_connected_component_ANR: fixes S :: "'a::euclidean_space set" shows "ANR S ⟹ ANR(connected_component_set S x)" by (metis ANR_openin (*‹⟦ANR (?T::?'a set); openin (top_of_set ?T) (?S::?'a set)⟧ ⟹ ANR ?S›*) openin_connected_component_locally_connected (*‹locally connected (?S::?'a set) ⟹ openin (top_of_set ?S) (connected_component_set ?S (?x::?'a))›*) ANR_imp_locally_connected (*‹ANR (?S::?'a set) ⟹ locally connected ?S›*)) lemma ANR_component_ANR: fixes S :: "'a::euclidean_space set" assumes "ANR S" "c ∈ components S" shows "ANR c" by (metis ANR_connected_component_ANR (*‹ANR ?S ⟹ ANR (connected_component_set ?S ?x)›*) assms (*‹ANR S› ‹c ∈ components S›*) componentsE (*‹⟦?S ∈ components ?U; ⋀x. ⟦x ∈ ?U; ?S = connected_component_set ?U x⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*)) subsection‹Original ANR material, now for ENRs› lemma ENR_bounded: fixes S :: "'a::euclidean_space set" assumes "bounded S" shows "ENR S ⟷ (∃U. open U ∧ bounded U ∧ S retract_of U)" (is "?lhs = ?rhs") proof (standard) (*goals: 1. ‹ENR S ⟹ ∃U. open U ∧ bounded U ∧ S retract_of U› 2. ‹∃U. open U ∧ bounded U ∧ S retract_of U ⟹ ENR S›*) obtain r where "0 < r" and r: "S ⊆ ball 0 r" (*goal: ‹(⋀r::real. ⟦(0::real) < r; (S::'a set) ⊆ ball (0::'a) r⟧ ⟹ thesis::bool) ⟹ thesis›*) using bounded_subset_ballD (*‹bounded ?S ⟹ ∃r>0. ?S ⊆ ball ?x r›*) assms (*‹bounded S›*) by blast assume "?lhs" (*‹ENR (S::'a set)›*) then show "?rhs" by (meson ENR_def (*‹ENR ?S ≡ ∃U. open U ∧ ?S retract_of U›*) Elementary_Metric_Spaces.open_ball (*‹open (ball ?x ?e)›*) bounded_Int (*‹bounded ?S ∨ bounded ?T ⟹ bounded (?S ∩ ?T)›*) bounded_ball (*‹bounded (ball ?x ?e)›*) inf_le2 (*‹inf ?x ?y ≤ ?y›*) le_inf_iff (*‹(?x ≤ inf ?y ?z) = (?x ≤ ?y ∧ ?x ≤ ?z)›*) open_Int (*‹⟦open ?S; open ?T⟧ ⟹ open (?S ∩ ?T)›*) r (*‹S ⊆ ball 0 r›*) retract_of_imp_subset (*‹?S retract_of ?T ⟹ ?S ⊆ ?T›*) retract_of_subset (*‹⟦?T retract_of ?S; ?T ⊆ ?S'; ?S' ⊆ ?S⟧ ⟹ ?T retract_of ?S'›*)) next (*goal: ‹∃U. open U ∧ bounded U ∧ S retract_of U ⟹ ENR S›*) assume "?rhs" (*‹∃U::'a set. open U ∧ bounded U ∧ (S::'a set) retract_of U›*) then show "?lhs" using ENR_def (*‹ENR ?S ≡ ∃U. open U ∧ ?S retract_of U›*) by blast qed lemma absolute_retract_imp_AR_gen: fixes S :: "'a::euclidean_space set" and S' :: "'b::euclidean_space set" assumes "S retract_of T" "convex T" "T ≠ {}" "S homeomorphic S'" "closedin (top_of_set U) S'" shows "S' retract_of U" proof (-) (*goal: ‹S' retract_of U›*) have "AR T" by (simp add: assms (*‹S retract_of T› ‹convex T› ‹T ≠ {}› ‹S homeomorphic S'› ‹closedin (top_of_set U) S'›*) convex_imp_AR (*‹⟦convex ?S; ?S ≠ {}⟧ ⟹ AR ?S›*)) then have "AR S" using AR_retract_of_AR (*‹⟦AR ?T; ?S retract_of ?T⟧ ⟹ AR ?S›*) assms (*‹S retract_of T› ‹convex T› ‹T ≠ {}› ‹S homeomorphic S'› ‹closedin (top_of_set (U::'b set)) (S'::'b set)›*) by auto then show "?thesis" (*goal: ‹S' retract_of U›*) using assms (*‹S retract_of T› ‹convex T› ‹T ≠ {}› ‹(S::'a set) homeomorphic (S'::'b set)› ‹closedin (top_of_set U) S'›*) AR_imp_absolute_retract (*‹⟦AR ?S; ?S homeomorphic ?S'; closedin (top_of_set ?U) ?S'⟧ ⟹ ?S' retract_of ?U›*) by metis qed lemma absolute_retract_imp_AR: fixes S :: "'a::euclidean_space set" and S' :: "'b::euclidean_space set" assumes "S retract_of UNIV" "S homeomorphic S'" "closed S'" shows "S' retract_of UNIV" using AR_imp_absolute_retract_UNIV (*‹⟦AR ?S; ?S homeomorphic ?S'; closed ?S'⟧ ⟹ ?S' retract_of UNIV›*) assms (*‹S retract_of UNIV› ‹S homeomorphic S'› ‹closed S'›*) retract_of_UNIV (*‹(?S retract_of UNIV) = (AR ?S ∧ closed ?S)›*) by blast lemma homeomorphic_compact_arness: fixes S :: "'a::euclidean_space set" and S' :: "'b::euclidean_space set" assumes "S homeomorphic S'" shows "compact S ∧ S retract_of UNIV ⟷ compact S' ∧ S' retract_of UNIV" using assms (*‹S homeomorphic S'›*) homeomorphic_compactness (*‹?S homeomorphic ?T ⟹ compact ?S = compact ?T›*) by (metis compact_AR (*‹(compact ?S ∧ AR ?S) = (compact ?S ∧ ?S retract_of UNIV)›*) homeomorphic_AR_iff_AR (*‹?S homeomorphic ?T ⟹ AR ?S = AR ?T›*)) lemma absolute_retract_from_Un_Int: fixes S :: "'a::euclidean_space set" assumes "(S ∪ T) retract_of UNIV" "(S ∩ T) retract_of UNIV" "closed S" "closed T" shows "S retract_of UNIV" using AR_from_Un_Int (*‹⟦closed ?S; closed ?T; AR (?S ∪ ?T); AR (?S ∩ ?T)⟧ ⟹ AR ?S›*) assms (*‹S ∪ T retract_of UNIV› ‹S ∩ T retract_of UNIV› ‹closed S› ‹closed T›*) retract_of_UNIV (*‹(?S retract_of UNIV) = (AR ?S ∧ closed ?S)›*) by auto lemma ENR_from_Un_Int_gen: fixes S :: "'a::euclidean_space set" assumes "closedin (top_of_set (S ∪ T)) S" "closedin (top_of_set (S ∪ T)) T" "ENR(S ∪ T)" "ENR(S ∩ T)" shows "ENR S" by (meson ANR_from_Un_Int_local (*‹⟦closedin (top_of_set (?S ∪ ?T)) ?S; closedin (top_of_set (?S ∪ ?T)) ?T; ANR (?S ∪ ?T); ANR (?S ∩ ?T)⟧ ⟹ ANR ?S›*) ANR_imp_neighbourhood_retract (*‹⟦ANR ?S; closedin (top_of_set ?U) ?S; ⋀V. ⟦openin (top_of_set ?U) V; ?S retract_of V⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*) ENR_ANR (*‹ENR ?S = (ANR ?S ∧ locally compact ?S)›*) ENR_neighborhood_retract (*‹⟦ENR ?U; ?S retract_of ?T; openin (top_of_set ?U) ?T⟧ ⟹ ENR ?S›*) assms (*‹closedin (top_of_set (S ∪ T)) S› ‹closedin (top_of_set (S ∪ T)) T› ‹ENR (S ∪ T)› ‹ENR (S ∩ T)›*)) lemma ENR_from_Un_Int: fixes S :: "'a::euclidean_space set" assumes "closed S" "closed T" "ENR(S ∪ T)" "ENR(S ∩ T)" shows "ENR S" by (meson ENR_from_Un_Int_gen (*‹⟦closedin (top_of_set (?S ∪ ?T)) ?S; closedin (top_of_set (?S ∪ ?T)) ?T; ENR (?S ∪ ?T); ENR (?S ∩ ?T)⟧ ⟹ ENR ?S›*) assms (*‹closed S› ‹closed T› ‹ENR (S ∪ T)› ‹ENR (S ∩ T)›*) closed_subset (*‹⟦?S ⊆ ?T; closed ?S⟧ ⟹ closedin (top_of_set ?T) ?S›*) sup_ge1 (*‹?x ≤ sup ?x ?y›*) sup_ge2 (*‹?y ≤ sup ?x ?y›*)) lemma ENR_finite_Union_convex_closed: fixes 𝒯 :: "'a::euclidean_space set set" assumes 𝒯: "finite 𝒯" and clo: "⋀C. C ∈ 𝒯 ⟹ closed C" and con: "⋀C. C ∈ 𝒯 ⟹ convex C" shows "ENR(⋃ 𝒯)" by (simp add: ENR_ANR (*‹ENR (?S::?'a set) = (ANR ?S ∧ locally compact ?S)›*) ANR_finite_Union_convex_closed (*‹⟦finite (?𝒯::?'a set set); ⋀C::?'a set. C ∈ ?𝒯 ⟹ closed C; ⋀C::?'a set. C ∈ ?𝒯 ⟹ convex C⟧ ⟹ ANR (⋃ ?𝒯)›*) 𝒯 (*‹finite (𝒯::'a set set)›*) clo (*‹(?C::'a set) ∈ (𝒯::'a set set) ⟹ closed ?C›*) closed_Union (*‹⟦finite (?S::?'a set set); ∀T::?'a set∈?S. closed T⟧ ⟹ closed (⋃ ?S)›*) closed_imp_locally_compact (*‹closed (?S::?'a set) ⟹ locally compact ?S›*) con (*‹(?C::'a set) ∈ (𝒯::'a set set) ⟹ convex ?C›*)) lemma finite_imp_ENR: fixes S :: "'a::euclidean_space set" shows "finite S ⟹ ENR S" by (simp add: ENR_ANR (*‹ENR ?S = (ANR ?S ∧ locally compact ?S)›*) finite_imp_ANR (*‹finite ?S ⟹ ANR ?S›*) finite_imp_closed (*‹finite ?S ⟹ closed ?S›*) closed_imp_locally_compact (*‹closed ?S ⟹ locally compact ?S›*)) lemma ENR_insert: fixes S :: "'a::euclidean_space set" assumes "closed S" "ENR S" shows "ENR(insert a S)" proof (-) (*goal: ‹ENR (insert a S)›*) have "ENR ({a} ∪ S)" by (metis ANR_insert (*‹⟦ANR ?S; closed ?S⟧ ⟹ ANR (insert ?a ?S)›*) ENR_ANR (*‹ENR ?S = (ANR ?S ∧ locally compact ?S)›*) Un_commute (*‹?A ∪ ?B = ?B ∪ ?A›*) Un_insert_right (*‹?A ∪ insert ?a ?B = insert ?a (?A ∪ ?B)›*) assms (*‹closed S› ‹ENR S›*) closed_imp_locally_compact (*‹closed ?S ⟹ locally compact ?S›*) closed_insert (*‹closed ?S ⟹ closed (insert ?a ?S)›*) sup_bot_right (*‹sup ?x bot = ?x›*)) then show "?thesis" (*goal: ‹ENR (insert a S)›*) by auto qed lemma ENR_path_component_ENR: fixes S :: "'a::euclidean_space set" assumes "ENR S" shows "ENR(path_component_set S x)" by (metis ANR_imp_locally_path_connected (*‹ANR ?S ⟹ locally path_connected ?S›*) ENR_empty (*‹ENR {}›*) ENR_imp_ANR (*‹ENR ?S ⟹ ANR ?S›*) ENR_openin (*‹⟦ENR ?T; openin (top_of_set ?T) ?S⟧ ⟹ ENR ?S›*) assms (*‹ENR S›*) locally_path_connected_2 (*‹⟦locally path_connected ?S; openin (top_of_set ?S) ?t; ?x ∈ ?t⟧ ⟹ openin (top_of_set ?S) (path_component_set ?t ?x)›*) openin_subtopology_self (*‹openin (top_of_set ?S) ?S›*) path_component_eq_empty (*‹(path_component_set ?S ?x = {}) = (?x ∉ ?S)›*)) (*UNUSED lemma ENR_Times: fixes S :: "'a::euclidean_space set" and T :: "'b::euclidean_space set" assumes "ENR S" "ENR T" shows "ENR(S × T)" using assms apply (simp add: ENR_ANR ANR_Times) thm locally_compact_Times oops SIMP_TAC[ENR_ANR; ANR_PCROSS; LOCALLY_COMPACT_PCROSS]);; *) subsection‹Finally, spheres are ANRs and ENRs› lemma absolute_retract_homeomorphic_convex_compact: fixes S :: "'a::euclidean_space set" and U :: "'b::euclidean_space set" assumes "S homeomorphic U" "S ≠ {}" "S ⊆ T" "convex U" "compact U" shows "S retract_of T" by (metis UNIV_I (*‹?x ∈ UNIV›*) assms (*‹S homeomorphic U› ‹S ≠ {}› ‹S ⊆ T› ‹convex U› ‹compact U›*) compact_AR (*‹(compact ?S ∧ AR ?S) = (compact ?S ∧ ?S retract_of UNIV)›*) convex_imp_AR (*‹⟦convex ?S; ?S ≠ {}⟧ ⟹ AR ?S›*) homeomorphic_AR_iff_AR (*‹?S homeomorphic ?T ⟹ AR ?S = AR ?T›*) homeomorphic_compactness (*‹?S homeomorphic ?T ⟹ compact ?S = compact ?T›*) homeomorphic_empty( (*‹?S homeomorphic {} = (?S = {})›*) 1) retract_of_subset (*‹⟦?T retract_of ?S; ?T ⊆ ?S'; ?S' ⊆ ?S⟧ ⟹ ?T retract_of ?S'›*) subsetI (*‹(⋀x. x ∈ ?A ⟹ x ∈ ?B) ⟹ ?A ⊆ ?B›*)) lemma frontier_retract_of_punctured_universe: fixes S :: "'a::euclidean_space set" assumes "convex S" "bounded S" "a ∈ interior S" shows "(frontier S) retract_of (- {a})" using rel_frontier_retract_of_punctured_affine_hull (*‹⟦bounded ?S; convex ?S; ?a ∈ rel_interior ?S⟧ ⟹ rel_frontier ?S retract_of affine hull ?S - {?a}›*) by (metis Compl_eq_Diff_UNIV (*‹- (?A::?'a set) = UNIV - ?A›*) affine_hull_nonempty_interior (*‹interior (?S::?'n set) ≠ {} ⟹ affine hull ?S = UNIV›*) assms (*‹convex (S::'a set)› ‹bounded (S::'a set)› ‹(a::'a) ∈ interior (S::'a set)›*) empty_iff (*‹((?c::?'a) ∈ {}) = False›*) rel_frontier_frontier (*‹affine hull (?S::?'n set) = UNIV ⟹ rel_frontier ?S = frontier ?S›*) rel_interior_nonempty_interior (*‹interior (?S::?'n set) ≠ {} ⟹ rel_interior ?S = interior ?S›*)) lemma sphere_retract_of_punctured_universe_gen: fixes a :: "'a::euclidean_space" assumes "b ∈ ball a r" shows "sphere a r retract_of (- {b})" proof (-) (*goal: ‹sphere (a::'a::euclidean_space) (r::real) retract_of - {b::'a::euclidean_space}›*) have "frontier (cball a r) retract_of (- {b})" using assms (*‹b ∈ ball a r›*) frontier_retract_of_punctured_universe (*‹⟦convex ?S; bounded ?S; ?a ∈ interior ?S⟧ ⟹ frontier ?S retract_of - {?a}›*) interior_cball (*‹interior (cball ?x ?e) = ball ?x ?e›*) by blast then show "?thesis" (*goal: ‹sphere (a::'a) (r::real) retract_of - {b::'a}›*) by simp qed lemma sphere_retract_of_punctured_universe: fixes a :: "'a::euclidean_space" assumes "0 < r" shows "sphere a r retract_of (- {a})" by (simp add: assms (*‹0 < r›*) sphere_retract_of_punctured_universe_gen (*‹?b ∈ ball ?a ?r ⟹ sphere ?a ?r retract_of - {?b}›*)) lemma ENR_sphere: fixes a :: "'a::euclidean_space" shows "ENR(sphere a r)" proof (cases "0 < r") (*goals: 1. ‹0 < r ⟹ ENR (sphere a r)› 2. ‹¬ 0 < r ⟹ ENR (sphere a r)›*) case True (*‹(0::real) < (r::real)›*) then have "sphere a r retract_of -{a}" by (simp add: sphere_retract_of_punctured_universe (*‹0 < ?r ⟹ sphere ?a ?r retract_of - {?a}›*)) with open_delete (*‹open ?S ⟹ open (?S - {?x})›*) show "?thesis" (*goal: ‹ENR (sphere a r)›*) by (auto simp: ENR_def (*‹ENR (?S::?'a set) ≡ ∃U::?'a set. open U ∧ ?S retract_of U›*)) next (*goal: ‹¬ 0 < r ⟹ ENR (sphere a r)›*) case False (*‹¬ 0 < r›*) then show "?thesis" (*goal: ‹ENR (sphere a r)›*) using finite_imp_ENR (*‹finite ?S ⟹ ENR ?S›*) by (metis finite_insert (*‹finite (insert ?a ?A) = finite ?A›*) infinite_imp_nonempty (*‹infinite ?S ⟹ ?S ≠ {}›*) less_linear (*‹?x < ?y ∨ ?x = ?y ∨ ?y < ?x›*) sphere_eq_empty (*‹(sphere ?a ?r = {}) = (?r < 0)›*) sphere_trivial (*‹sphere ?x 0 = {?x}›*)) qed corollary✐‹tag unimportant› ANR_sphere: fixes a :: "'a::euclidean_space" shows "ANR(sphere a r)" by (simp add: ENR_imp_ANR (*‹ENR ?S ⟹ ANR ?S›*) ENR_sphere (*‹ENR (sphere ?a ?r)›*)) subsection‹Spheres are connected, etc› lemma locally_path_connected_sphere_gen: fixes S :: "'a::euclidean_space set" assumes "bounded S" and "convex S" shows "locally path_connected (rel_frontier S)" proof (cases "rel_interior S = {}") (*goals: 1. ‹rel_interior S = {} ⟹ locally path_connected (rel_frontier S)› 2. ‹rel_interior S ≠ {} ⟹ locally path_connected (rel_frontier S)›*) case True (*‹rel_interior (S::'a::euclidean_space set) = {}›*) with assms (*‹bounded S› ‹convex (S::'a::euclidean_space set)›*) show "?thesis" (*goal: ‹locally path_connected (rel_frontier S)›*) by (simp add: rel_interior_eq_empty (*‹convex ?S ⟹ (rel_interior ?S = {}) = (?S = {})›*)) next (*goal: ‹rel_interior S ≠ {} ⟹ locally path_connected (rel_frontier S)›*) case False (*‹rel_interior S ≠ {}›*) then obtain a where a: "a ∈ rel_interior S" (*goal: ‹(⋀a. a ∈ rel_interior S ⟹ thesis) ⟹ thesis›*) by blast show "?thesis" (*goal: ‹locally path_connected (rel_frontier S)›*) proof (rule retract_of_locally_path_connected (*‹⟦locally path_connected ?T; ?S retract_of ?T⟧ ⟹ locally path_connected ?S›*)) (*goals: 1. ‹locally path_connected (?T::'a set)› 2. ‹rel_frontier (S::'a set) retract_of (?T::'a set)›*) show "locally path_connected (affine hull S - {a})" by (meson convex_affine_hull (*‹convex (affine hull (?S::?'a::real_vector set))›*) convex_imp_locally_path_connected (*‹convex (?S::?'a::real_normed_vector set) ⟹ locally path_connected ?S›*) locally_open_subset (*‹⟦locally (?P::?'a::topological_space set ⇒ bool) (?S::?'a::topological_space set); openin (top_of_set ?S) (?t::?'a::topological_space set)⟧ ⟹ locally ?P ?t›*) openin_delete (*‹openin (top_of_set (?u::?'a::t1_space set)) (?S::?'a::t1_space set) ⟹ openin (top_of_set ?u) (?S - {?a::?'a::t1_space})›*) openin_subtopology_self (*‹openin (top_of_set (?S::?'a::topological_space set)) ?S›*)) show "rel_frontier S retract_of affine hull S - {a}" using a (*‹a ∈ rel_interior S›*) assms (*‹bounded S› ‹convex S›*) rel_frontier_retract_of_punctured_affine_hull (*‹⟦bounded ?S; convex ?S; ?a ∈ rel_interior ?S⟧ ⟹ rel_frontier ?S retract_of affine hull ?S - {?a}›*) by blast qed qed lemma locally_connected_sphere_gen: fixes S :: "'a::euclidean_space set" assumes "bounded S" and "convex S" shows "locally connected (rel_frontier S)" by (simp add: ANR_imp_locally_connected (*‹ANR (?S::?'a::euclidean_space set) ⟹ locally connected ?S›*) ANR_rel_frontier_convex (*‹⟦bounded (?S::?'a::euclidean_space set); convex ?S⟧ ⟹ ANR (rel_frontier ?S)›*) assms (*‹bounded (S::'a::euclidean_space set)› ‹convex (S::'a::euclidean_space set)›*)) lemma locally_path_connected_sphere: fixes a :: "'a::euclidean_space" shows "locally path_connected (sphere a r)" using ENR_imp_locally_path_connected (*‹ENR ?S ⟹ locally path_connected ?S›*) ENR_sphere (*‹ENR (sphere ?a ?r)›*) by blast lemma locally_connected_sphere: fixes a :: "'a::euclidean_space" shows "locally connected(sphere a r)" using ANR_imp_locally_connected (*‹ANR ?S ⟹ locally connected ?S›*) ANR_sphere (*‹ANR (sphere (?a::?'a::euclidean_space) (?r::real))›*) by blast subsection‹Borsuk homotopy extension theorem› text‹It's only this late so we can use the concept of retraction, saying that the domain sets or range set are ENRs.› theorem Borsuk_homotopy_extension_homotopic: fixes f :: "'a::euclidean_space ⇒ 'b::euclidean_space" assumes cloTS: "closedin (top_of_set T) S" and anr: "(ANR S ∧ ANR T) ∨ ANR U" and contf: "continuous_on T f" and "f ∈ T → U" and "homotopic_with_canon (λx. True) S U f g" obtains g' where "homotopic_with_canon (λx. True) T U f g'" "continuous_on T g'" "image g' T ⊆ U" "⋀x. x ∈ S ⟹ g' x = g x" proof (-) (*goal: ‹(⋀g'. ⟦homotopic_with_canon (λx. True) T U f g'; continuous_on T g'; g' ` T ⊆ U; ⋀x. x ∈ S ⟹ g' x = g x⟧ ⟹ thesis) ⟹ thesis›*) have "S ⊆ T" using assms (*‹closedin (top_of_set (T::'a set)) (S::'a set)› ‹ANR S ∧ ANR T ∨ ANR U› ‹continuous_on T f› ‹f ∈ T → U› ‹homotopic_with_canon (λx. True) S U f g›*) closedin_imp_subset (*‹closedin (subtopology ?U ?S) ?T ⟹ ?T ⊆ ?S›*) by blast obtain h where conth: "continuous_on ({0..1} × S) h" and him: "h ∈ ({0..1} × S) → U" and [simp]: "⋀x. h(0, x) = f x" "⋀x. h(1::real, x) = g x" (*goal: ‹(⋀h. ⟦continuous_on ({0..1} × S) h; h ∈ {0..1} × S → U; ⋀x. h (0, x) = f x; ⋀x. h (1, x) = g x⟧ ⟹ thesis) ⟹ thesis›*) using assms (*‹closedin (top_of_set T) S› ‹ANR (S::'a::euclidean_space set) ∧ ANR (T::'a::euclidean_space set) ∨ ANR (U::'b::euclidean_space set)› ‹continuous_on T f› ‹f ∈ T → U› ‹homotopic_with_canon (λx. True) S U f g›*) by (fastforce simp: homotopic_with_def (*‹homotopic_with ?P ?X ?Y ?f ?g ≡ ∃h. continuous_map (prod_topology (top_of_set {0..1}) ?X) ?Y h ∧ (∀x. h (0, x) = ?f x) ∧ (∀x. h (1, x) = ?g x) ∧ (∀t∈{0..1}. ?P (λx. h (t, x)))›*)) define h' where "h' ≡ λz. if snd z ∈ S then h z else (f ∘ snd) z" define B where "B ≡ {0::real} × T ∪ {0..1} × S" have clo0T: "closedin (top_of_set ({0..1} × T)) ({0::real} × T)" by (simp add: Abstract_Topology.closedin_Times (*‹⟦closedin (top_of_set ?S) ?S'; closedin (top_of_set ?T) ?T'⟧ ⟹ closedin (top_of_set (?S × ?T)) (?S' × ?T')›*)) moreover have cloT1S: "closedin (top_of_set ({0..1} × T)) ({0..1} × S)" by (simp add: Abstract_Topology.closedin_Times (*‹⟦closedin (top_of_set ?S) ?S'; closedin (top_of_set ?T) ?T'⟧ ⟹ closedin (top_of_set (?S × ?T)) (?S' × ?T')›*) assms (*‹closedin (top_of_set T) S› ‹ANR S ∧ ANR T ∨ ANR U› ‹continuous_on T f› ‹f ∈ T → U› ‹homotopic_with_canon (λx. True) S U f g›*)) ultimately have clo0TB: "closedin (top_of_set ({0..1} × T)) B" by (auto simp: B_def (*‹B ≡ {0} × T ∪ {0..1} × S›*)) have cloBS: "closedin (top_of_set B) ({0..1} × S)" by (metis (no_types) Un_subset_iff (*‹(?A ∪ ?B ⊆ ?C) = (?A ⊆ ?C ∧ ?B ⊆ ?C)›*) B_def (*‹B ≡ {0} × T ∪ {0..1} × S›*) closedin_subset_trans [OF cloT1S] (*‹⟦{0..1} × S ⊆ ?T; ?T ⊆ {0..1} × T⟧ ⟹ closedin (top_of_set ?T) ({0..1} × S)›*) clo0TB (*‹closedin (top_of_set ({0..1} × T)) B›*) closedin_imp_subset (*‹closedin (subtopology ?U ?S) ?T ⟹ ?T ⊆ ?S›*) closedin_self (*‹closedin (top_of_set ?S) ?S›*)) moreover have cloBT: "closedin (top_of_set B) ({0} × T)" using ‹S ⊆ T› (*‹(S::'a set) ⊆ (T::'a set)›*) closedin_subset_trans[OF clo0T] (*‹⟦{0} × T ⊆ ?T; ?T ⊆ {0..1} × T⟧ ⟹ closedin (top_of_set ?T) ({0} × T)›*) by (metis B_def (*‹B ≡ {0} × T ∪ {0..1} × S›*) Un_upper1 (*‹?A ⊆ ?A ∪ ?B›*) clo0TB (*‹closedin (top_of_set ({0..1} × T)) B›*) closedin_closed (*‹closedin (top_of_set ?U) ?S = (∃T. closed T ∧ ?S = ?U ∩ T)›*) inf_le1 (*‹inf ?x ?y ≤ ?x›*)) moreover have "continuous_on ({0} × T) (f ∘ snd)" proof ((rule 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 227 facts*))+) (*goal: ‹continuous_on (snd ` ({0} × T)) f›*) show "continuous_on (snd ` ({0} × T)) f" by (simp add: contf (*‹continuous_on T f›*)) qed ultimately have "continuous_on ({0..1} × S ∪ {0} × T) (λx. if snd x ∈ S then h x else (f ∘ snd) x)" by (auto intro!: continuous_on_cases_local (*‹⟦closedin (top_of_set (?S ∪ ?T)) ?S; closedin (top_of_set (?S ∪ ?T)) ?T; continuous_on ?S ?f; continuous_on ?T ?g; ⋀x. x ∈ ?S ∧ ¬ ?P x ∨ x ∈ ?T ∧ ?P x ⟹ ?f x = ?g x⟧ ⟹ continuous_on (?S ∪ ?T) (λx. if ?P x then ?f x else ?g x)›*) conth (*‹continuous_on ({0..1} × S) h›*) simp: B_def (*‹B ≡ {0} × T ∪ {0..1} × S›*) Un_commute [of "{0} × T"] (*‹{0} × T ∪ ?B = ?B ∪ {0} × T›*)) then have conth': "continuous_on B h'" by (simp add: h'_def (*‹h' ≡ λz. if snd z ∈ S then h z else (f ∘ snd) z›*) B_def (*‹B ≡ {0} × T ∪ {0..1} × S›*) Un_commute [of "{0} × T"] (*‹{0} × T ∪ ?B = ?B ∪ {0} × T›*)) have "image h' B ⊆ U" using ‹f ∈ T → U› (*‹(f::'a ⇒ 'b) ∈ (T::'a set) → (U::'b set)›*) him (*‹h ∈ {0..1} × S → U›*) by (auto simp: h'_def (*‹h' ≡ λz. if snd z ∈ S then h z else (f ∘ snd) z›*) B_def (*‹B ≡ {0} × T ∪ {0..1} × S›*)) obtain V and k where "B ⊆ V" and opeTV: "openin (top_of_set ({0..1} × T)) V" and contk: "continuous_on V k" and kim: "k ∈ V → U" and keq: "⋀x. x ∈ B ⟹ k x = h' x" (*goal: ‹(⋀V k. ⟦B ⊆ V; openin (top_of_set ({0..1} × T)) V; continuous_on V k; k ∈ V → U; ⋀x. x ∈ B ⟹ k x = h' x⟧ ⟹ thesis) ⟹ thesis›*) using anr (*‹ANR S ∧ ANR T ∨ ANR U›*) proof (standard) (*goals: 1. ‹⟦⋀(V::(real × 'a::euclidean_space) set) k::real × 'a::euclidean_space ⇒ 'b::euclidean_space. ⟦(B::(real × 'a::euclidean_space) set) ⊆ V; openin (top_of_set ({0::real..1::real} × (T::'a::euclidean_space set))) V; continuous_on V k; k ∈ V → (U::'b::euclidean_space set); ⋀x::real × 'a::euclidean_space. x ∈ B ⟹ k x = (h'::real × 'a::euclidean_space ⇒ 'b::euclidean_space) x⟧ ⟹ thesis::bool; ANR (S::'a::euclidean_space set) ∧ ANR T⟧ ⟹ thesis› 2. ‹⟦⋀(V::(real × 'a::euclidean_space) set) k::real × 'a::euclidean_space ⇒ 'b::euclidean_space. ⟦(B::(real × 'a::euclidean_space) set) ⊆ V; openin (top_of_set ({0::real..1::real} × (T::'a::euclidean_space set))) V; continuous_on V k; k ∈ V → (U::'b::euclidean_space set); ⋀x::real × 'a::euclidean_space. x ∈ B ⟹ k x = (h'::real × 'a::euclidean_space ⇒ 'b::euclidean_space) x⟧ ⟹ thesis::bool; ANR U⟧ ⟹ thesis›*) assume ST: "ANR S ∧ ANR T" (*‹ANR (S::'a set) ∧ ANR (T::'a set)›*) have eq: "({0} × T ∩ {0..1} × S) = {0::real} × S" using ‹S ⊆ T› (*‹S ⊆ T›*) by auto have "ANR B" unfolding B_def (*goal: ‹ANR ({0} × T ∪ {0..1} × S)›*) proof (rule ANR_closed_Un_local (*‹⟦closedin (top_of_set ((?S::?'a::euclidean_space set) ∪ (?T::?'a::euclidean_space set))) ?S; closedin (top_of_set (?S ∪ ?T)) ?T; ANR ?S; ANR ?T; ANR (?S ∩ ?T)⟧ ⟹ ANR (?S ∪ ?T)›*)) (*goals: 1. ‹closedin (top_of_set ({0::real} × (T::'a::euclidean_space set) ∪ {0::real..1::real} × (S::'a::euclidean_space set))) ({0::real} × T)› 2. ‹closedin (top_of_set ({0::real} × (T::'a::euclidean_space set) ∪ {0::real..1::real} × (S::'a::euclidean_space set))) ({0::real..1::real} × S)› 3. ‹ANR ({0::real} × (T::'a::euclidean_space set))› 4. ‹ANR ({0::real..1::real} × (S::'a::euclidean_space set))› 5. ‹ANR ({0::real} × (T::'a::euclidean_space set) ∩ {0::real..1::real} × (S::'a::euclidean_space set))›*) show "closedin (top_of_set ({0} × T ∪ {0..1} × S)) ({0::real} × T)" by (metis cloBT (*‹closedin (top_of_set B) ({0} × T)›*) B_def (*‹B ≡ {0} × T ∪ {0..1} × S›*)) show "closedin (top_of_set ({0} × T ∪ {0..1} × S)) ({0..1::real} × S)" by (metis Un_commute (*‹?A ∪ ?B = ?B ∪ ?A›*) cloBS (*‹closedin (top_of_set B) ({0..1} × S)›*) B_def (*‹B ≡ {0} × T ∪ {0..1} × S›*)) qed (simp_all add: ANR_Times convex_imp_ANR ANR_singleton ST eq) (*solves the remaining goals: 1. ‹ANR ({0} × T)› 2. ‹ANR ({0..1} × S)› 3. ‹ANR ({0} × T ∩ {0..1} × S)›*) note Vk = that (*‹⟦(B::(real × 'a::euclidean_space) set) ⊆ (?V2::(real × 'a::euclidean_space) set); openin (top_of_set ({0::real..1::real} × (T::'a::euclidean_space set))) ?V2; continuous_on ?V2 (?k2::real × 'a::euclidean_space ⇒ 'b::euclidean_space); ?k2 ∈ ?V2 → (U::'b::euclidean_space set); ⋀x::real × 'a::euclidean_space. x ∈ B ⟹ ?k2 x = (h'::real × 'a::euclidean_space ⇒ 'b::euclidean_space) x⟧ ⟹ thesis::bool›*) have "*": thesis if "openin (top_of_set ({0..1::real} × T)) V" "retraction V B r" for V and r proof (-) (*goal: ‹thesis::bool›*) have "continuous_on V (h' ∘ r)" using conth' (*‹continuous_on B h'›*) continuous_on_compose (*‹⟦continuous_on ?s ?f; continuous_on (?f ` ?s) ?g⟧ ⟹ continuous_on ?s (?g ∘ ?f)›*) retractionE (*‹⟦retraction (?S::?'a set) (?T::?'a set) (?r::?'a ⇒ ?'a); ⟦?T = ?r ` ?S; ?r ∈ ?S → ?S; continuous_on ?S ?r; ⋀x::?'a. x ∈ ?S ⟹ ?r (?r x) = ?r x⟧ ⟹ ?thesis::bool⟧ ⟹ ?thesis›*) that(2) (*‹retraction V B r›*) by blast moreover have "(h' ∘ r) ` V ⊆ U" by (metis ‹h' ` B ⊆ U› image_comp (*‹?f ` ?g ` ?r = (?f ∘ ?g) ` ?r›*) retractionE (*‹⟦retraction ?S ?T ?r; ⟦?T = ?r ` ?S; ?r ∈ ?S → ?S; continuous_on ?S ?r; ⋀x. x ∈ ?S ⟹ ?r (?r x) = ?r x⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*) that( (*‹retraction V B r›*) 2)) ultimately show "?thesis" (*goal: ‹thesis›*) using Vk[of V "h' ∘ r"] (*‹⟦B ⊆ V; openin (top_of_set ({0..1} × T)) V; continuous_on V (h' ∘ r); h' ∘ r ∈ V → U; ⋀x. x ∈ B ⟹ (h' ∘ r) x = h' x⟧ ⟹ thesis›*) by (metis comp_apply (*‹(?f ∘ ?g) ?x = ?f (?g ?x)›*) retraction (*‹retraction ?S ?T ?r = (?T ⊆ ?S ∧ continuous_on ?S ?r ∧ ?r ` ?S = ?T ∧ (∀x∈?T. ?r x = x))›*) image_subset_iff_funcset (*‹(?F ` ?A ⊆ ?B) = (?F ∈ ?A → ?B)›*) that (*‹openin (top_of_set ({0..1} × T)) V› ‹retraction V B r›*)) qed show thesis by (meson "*" (*‹⟦openin (top_of_set ({0::real..1::real} × (T::'a set))) (?V2::(real × 'a) set); retraction ?V2 (B::(real × 'a) set) (?r2::real × 'a ⇒ real × 'a)⟧ ⟹ thesis::bool›*) ANR_imp_neighbourhood_retract (*‹⟦ANR (?S::?'a set); closedin (top_of_set (?U::?'a set)) ?S; ⋀V::?'a set. ⟦openin (top_of_set ?U) V; ?S retract_of V⟧ ⟹ ?thesis::bool⟧ ⟹ ?thesis›*) ‹ANR B› clo0TB (*‹closedin (top_of_set ({0::real..1::real} × (T::'a set))) (B::(real × 'a) set)›*) retract_of_def (*‹((?T::?'a set) retract_of (?S::?'a set)) = (∃r::?'a ⇒ ?'a. retraction ?S ?T r)›*)) next (*goal: ‹⟦⋀V k. ⟦B ⊆ V; openin (top_of_set ({0..1} × T)) V; continuous_on V k; k ∈ V → U; ⋀x. x ∈ B ⟹ k x = h' x⟧ ⟹ thesis; ANR U⟧ ⟹ thesis›*) assume "ANR U" (*‹ANR (U::'b set)›*) with ANR_imp_absolute_neighbourhood_extensor (*‹⟦ANR ?S; continuous_on ?T ?f; ?f ∈ ?T → ?S; closedin (top_of_set ?U) ?T; ⋀V g. ⟦?T ⊆ V; openin (top_of_set ?U) V; continuous_on V g; g ∈ V → ?S; ⋀x. x ∈ ?T ⟹ g x = ?f x⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*) ‹h' ` B ⊆ U› (*‹(h'::real × 'a ⇒ 'b) ` (B::(real × 'a) set) ⊆ (U::'b set)›*) clo0TB (*‹closedin (top_of_set ({0..1} × T)) B›*) conth' (*‹continuous_on B h'›*) image_subset_iff_funcset (*‹(?F ` ?A ⊆ ?B) = (?F ∈ ?A → ?B)›*) that (*‹⟦B ⊆ ?V2; openin (top_of_set ({0..1} × T)) ?V2; continuous_on ?V2 ?k2; ?k2 ∈ ?V2 → U; ⋀x. x ∈ B ⟹ ?k2 x = h' x⟧ ⟹ thesis›*) show "?thesis" (*goal: ‹thesis::bool›*) by (smt (verit) Pi_I (*‹(⋀x. x ∈ ?A ⟹ ?f x ∈ ?B x) ⟹ ?f ∈ Pi ?A ?B›*) funcset_mem (*‹⟦?f ∈ ?A → ?B; ?x ∈ ?A⟧ ⟹ ?f ?x ∈ ?B›*)) qed define S' where "S' ≡ {x. ∃u::real. u ∈ {0..1} ∧ (u, x::'a) ∈ {0..1} × T - V}" have "closedin (top_of_set T) S'" unfolding S'_def (*goal: ‹closedin (top_of_set (T::'a set)) {x::'a. ∃u::real. u ∈ {0::real..1::real} ∧ (u, x) ∈ {0::real..1::real} × T - (V::(real × 'a) set)}›*) using closedin_self (*‹closedin (top_of_set ?S) ?S›*) opeTV (*‹openin (top_of_set ({0..1} × T)) V›*) by (blast intro: closedin_compact_projection (*‹⟦compact ?S; closedin (top_of_set (?S × ?T)) ?U⟧ ⟹ closedin (top_of_set ?T) {y. ∃x. x ∈ ?S ∧ (x, y) ∈ ?U}›*)) have S'_def: "S' = {x. ∃u::real. (u, x::'a) ∈ {0..1} × T - V}" by (auto simp: S'_def (*‹S' ≡ {x. ∃u. u ∈ {0..1} ∧ (u, x) ∈ {0..1} × T - V}›*)) have cloTS': "closedin (top_of_set T) S'" using S'_def (*‹S' = {x. ∃u. (u, x) ∈ {0..1} × T - V}›*) ‹closedin (top_of_set T) S'› (*‹closedin (top_of_set (T::'a set)) (S'::'a set)›*) by blast have "S ∩ S' = {}" using S'_def (*‹S' = {x. ∃u. (u, x) ∈ {0..1} × T - V}›*) B_def (*‹B ≡ {0} × T ∪ {0..1} × S›*) ‹B ⊆ V› (*‹B ⊆ V›*) by force obtain a :: "'a ⇒ real" where conta: "continuous_on T a" and "⋀x. x ∈ T ⟹ a x ∈ closed_segment 1 0" and a1: "⋀x. x ∈ S ⟹ a x = 1" and a0: "⋀x. x ∈ S' ⟹ a x = 0" (*goal: ‹(⋀a. ⟦continuous_on T a; ⋀x. x ∈ T ⟹ a x ∈ closed_segment 1 0; ⋀x. x ∈ S ⟹ a x = 1; ⋀x. x ∈ S' ⟹ a x = 0⟧ ⟹ thesis) ⟹ thesis›*) apply (rule Urysohn_local [OF cloTS cloTS' ‹S ∩ S' = {}›, of 1 0] (*‹(⋀f. ⟦continuous_on T f; ⋀x. x ∈ T ⟹ f x ∈ closed_segment 1 0; ⋀x. x ∈ S ⟹ f x = 1; ⋀x. x ∈ S' ⟹ f x = 0⟧ ⟹ ?thesis) ⟹ ?thesis›*)) (*goal: ‹(⋀a. ⟦continuous_on T a; ⋀x. x ∈ T ⟹ a x ∈ closed_segment 1 0; ⋀x. x ∈ S ⟹ a x = 1; ⋀x. x ∈ S' ⟹ a x = 0⟧ ⟹ thesis) ⟹ thesis›*) by blast then have ain: "⋀x. x ∈ T ⟹ a x ∈ {0..1}" using closed_segment_eq_real_ivl (*‹closed_segment (?a::real) (?b::real) = (if ?a ≤ ?b then {?a..?b} else {?b..?a})›*) by auto have inV: "(u * a t, t) ∈ V" if "t ∈ T" "0 ≤ u" "u ≤ 1" for t and u proof (rule ccontr (*‹(¬ ?P ⟹ False) ⟹ ?P›*)) (*goal: ‹(u * a t, t) ∉ V ⟹ False›*) assume "(u * a t, t) ∉ V" (*‹((u::real) * (a::'a ⇒ real) (t::'a), t) ∉ (V::(real × 'a) set)›*) with ain[OF ‹t ∈ T›] (*‹a t ∈ {0..1}›*) have "a t = 0" apply simp (*goal: ‹a t = 0›*) by (metis (no_types, lifting) a0 (*‹(?x2::'a) ∈ (S'::'a set) ⟹ (a::'a ⇒ real) ?x2 = (0::real)›*) DiffI (*‹⟦(?c::?'a) ∈ (?A::?'a set); ?c ∉ (?B::?'a set)⟧ ⟹ ?c ∈ ?A - ?B›*) S'_def (*‹(S'::'a set) = {x::'a. ∃u::real. (u, x) ∈ {0::real..1::real} × (T::'a set) - (V::(real × 'a) set)}›*) SigmaI (*‹⟦(?a::?'a) ∈ (?A::?'a set); (?b::?'b) ∈ (?B::?'a ⇒ ?'b set) ?a⟧ ⟹ (?a, ?b) ∈ Sigma ?A ?B›*) atLeastAtMost_iff (*‹((?i::?'a) ∈ {?l::?'a..?u::?'a}) = (?l ≤ ?i ∧ ?i ≤ ?u)›*) mem_Collect_eq (*‹((?a::?'a) ∈ Collect (?P::?'a ⇒ bool)) = ?P ?a›*) mult_le_one (*‹⟦(?a::?'a) ≤ (1::?'a); (0::?'a) ≤ (?b::?'a); ?b ≤ (1::?'a)⟧ ⟹ ?a * ?b ≤ (1::?'a)›*) mult_nonneg_nonneg (*‹⟦(0::?'a) ≤ (?a::?'a); (0::?'a) ≤ (?b::?'a)⟧ ⟹ (0::?'a) ≤ ?a * ?b›*) that (*‹(t::'a) ∈ (T::'a set)› ‹(0::real) ≤ (u::real)› ‹(u::real) ≤ (1::real)›*)) show False using B_def (*‹B ≡ {0} × T ∪ {0..1} × S›*) ‹(u * a t, t) ∉ V› (*‹(u * a t, t) ∉ V›*) ‹B ⊆ V› (*‹B ⊆ V›*) ‹a t = 0› (*‹a t = 0›*) that (*‹t ∈ T› ‹0 ≤ u› ‹u ≤ 1›*) by auto qed show "?thesis" (*goal: ‹thesis›*) proof (standard) (*goals: 1. ‹homotopic_with_canon (λx. True) T U f ?g'› 2. ‹continuous_on T ?g'› 3. ‹?g' ` T ⊆ U› 4. ‹⋀x. x ∈ S ⟹ ?g' x = g x›*) show hom: "homotopic_with_canon (λx. True) T U f (λx. k (a x, x))" proof (simp add: homotopic_with (*‹(⋀h k. (⋀x. x ∈ topspace ?X ⟹ h x = k x) ⟹ ?P h = ?P k) ⟹ homotopic_with ?P ?X ?Y ?p ?q = (∃h. continuous_map (prod_topology (top_of_set {0..1}) ?X) ?Y h ∧ (∀x∈topspace ?X. h (0, x) = ?p x) ∧ (∀x∈topspace ?X. h (1, x) = ?q x) ∧ (∀t∈{0..1}. ?P (λx. h (t, x))))›*), intro exI (*‹?P ?x ⟹ ∃x. ?P x›*) conjI (*‹⟦?P; ?Q⟧ ⟹ ?P ∧ ?Q›*)) (*goals: 1. ‹continuous_on ({0..1} × T) ?h8› 2. ‹?h8 ` ({0..1} × T) ⊆ U› 3. ‹∀x∈T. ?h8 (0, x) = f x› 4. ‹∀x∈T. ?h8 (1, x) = k (a x, x)›*) show "continuous_on ({0..1} × T) (k ∘ (λz. (fst z *⇩R (a ∘ snd) z, snd z)))" apply (intro continuous_on_compose (*‹⟦continuous_on ?s ?f; continuous_on (?f ` ?s) ?g⟧ ⟹ continuous_on ?s (?g ∘ ?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 227 facts*)) (*goals: 1. ‹continuous_on (snd ` ({0..1} × T)) a› 2. ‹continuous_on ((λz. (fst z *⇩R (a ∘ snd) z, snd z)) ` ({0..1} × T)) k› discuss goal 1*) apply (force intro: inV (*‹⟦?t2 ∈ T; 0 ≤ ?u2; ?u2 ≤ 1⟧ ⟹ (?u2 * a ?t2, ?t2) ∈ V›*) continuous_on_subset [OF contk] (*‹?t ⊆ V ⟹ continuous_on ?t k›*) continuous_on_subset [OF conta] (*‹?t ⊆ T ⟹ continuous_on ?t a›*)) (*discuss goal 2*) apply (force intro: inV (*‹⟦?t2 ∈ T; 0 ≤ ?u2; ?u2 ≤ 1⟧ ⟹ (?u2 * a ?t2, ?t2) ∈ V›*) continuous_on_subset [OF contk] (*‹?t ⊆ V ⟹ continuous_on ?t k›*) continuous_on_subset [OF conta] (*‹?t ⊆ T ⟹ continuous_on ?t a›*)) (*proven 2 subgoals*) . show "(k ∘ (λz. (fst z *⇩R (a ∘ snd) z, snd z))) ` ({0..1} × T) ⊆ U" using inV (*‹⟦?t2 ∈ T; 0 ≤ ?u2; ?u2 ≤ 1⟧ ⟹ (?u2 * a ?t2, ?t2) ∈ V›*) kim (*‹k ∈ V → U›*) by auto show "∀x∈T. (k ∘ (λz. (fst z *⇩R (a ∘ snd) z, snd z))) (0, x) = f x" by (simp add: B_def (*‹B ≡ {0} × T ∪ {0..1} × S›*) h'_def (*‹h' ≡ λz. if snd z ∈ S then h z else (f ∘ snd) z›*) keq (*‹?x2 ∈ B ⟹ k ?x2 = h' ?x2›*)) show "∀x∈T. (k ∘ (λz. (fst z *⇩R (a ∘ snd) z, snd z))) (1, x) = k (a x, x)" by auto qed show "continuous_on T (λx. k (a x, x))" using homotopic_with_imp_continuous_maps[OF hom] (*‹continuous_map (top_of_set T) (top_of_set U) f ∧ continuous_map (top_of_set T) (top_of_set U) (λx. k (a x, x))›*) by auto show "(λx. k (a x, x)) ` T ⊆ U" proof (clarify) (*goal: ‹⋀x xa. xa ∈ T ⟹ k (a xa, xa) ∈ U›*) fix t assume "t ∈ T" (*‹(t::'a) ∈ (T::'a set)›*) show "k (a t, t) ∈ U" by (metis ‹t ∈ T› image_subset_iff (*‹(?f ` ?A ⊆ ?B) = (∀x∈?A. ?f x ∈ ?B)›*) inV (*‹⟦?t2 ∈ T; 0 ≤ ?u2; ?u2 ≤ 1⟧ ⟹ (?u2 * a ?t2, ?t2) ∈ V›*) kim (*‹k ∈ V → U›*) not_one_le_zero (*‹¬ 1 ≤ 0›*) linear (*‹?x ≤ ?y ∨ ?y ≤ ?x›*) mult_cancel_right1 (*‹(?c = ?b * ?c) = (?c = 0 ∨ ?b = 1)›*) image_subset_iff_funcset (*‹(?F ` ?A ⊆ ?B) = (?F ∈ ?A → ?B)›*)) qed show "⋀x. x ∈ S ⟹ k (a x, x) = g x" by (simp add: B_def (*‹B::(real × 'a) set ≡ {0::real} × (T::'a set) ∪ {0::real..1::real} × (S::'a set)›*) a1 (*‹(?x2::'a) ∈ (S::'a set) ⟹ (a::'a ⇒ real) ?x2 = (1::real)›*) h'_def (*‹h'::real × 'a ⇒ 'b ≡ λz::real × 'a. if snd z ∈ (S::'a set) then (h::real × 'a ⇒ 'b) z else ((f::'a ⇒ 'b) ∘ snd) z›*) keq (*‹(?x2::real × 'a) ∈ (B::(real × 'a) set) ⟹ (k::real × 'a ⇒ 'b) ?x2 = (h'::real × 'a ⇒ 'b) ?x2›*)) qed qed corollary✐‹tag unimportant› nullhomotopic_into_ANR_extension: fixes f :: "'a::euclidean_space ⇒ 'b::euclidean_space" assumes "closed S" and contf: "continuous_on S f" and "ANR T" and fim: "f ` S ⊆ T" and "S ≠ {}" shows "(∃c. homotopic_with_canon (λx. True) S T f (λx. c)) ⟷ (∃g. continuous_on UNIV g ∧ range g ⊆ T ∧ (∀x ∈ S. g x = f x))" (is "?lhs = ?rhs") proof (standard) (*goals: 1. ‹∃c. homotopic_with_canon (λx. True) S T f (λx. c) ⟹ ∃g. continuous_on UNIV g ∧ range g ⊆ T ∧ (∀x∈S. g x = f x)› 2. ‹∃g. continuous_on UNIV g ∧ range g ⊆ T ∧ (∀x∈S. g x = f x) ⟹ ∃c. homotopic_with_canon (λx. True) S T f (λx. c)›*) assume "?lhs" (*‹∃c::'b. homotopic_with_canon (λx::'a ⇒ 'b. True) (S::'a set) (T::'b set) (f::'a ⇒ 'b) (λx::'a. c)›*) then obtain c where c: "homotopic_with_canon (λx. True) S T (λx. c) f" (*goal: ‹(⋀c. homotopic_with_canon (λx. True) S T (λx. c) f ⟹ thesis) ⟹ thesis›*) by (blast intro: homotopic_with_symD (*‹homotopic_with ?P ?X ?Y ?f ?g ⟹ homotopic_with ?P ?X ?Y ?g ?f›*)) have "closedin (top_of_set UNIV) S" using ‹closed S› (*‹closed S›*) closed_closedin (*‹closed ?S = closedin euclidean ?S›*) by fastforce then obtain g where "continuous_on UNIV g" "range g ⊆ T" "⋀x. x ∈ S ⟹ g x = f x" (*goal: ‹(⋀g. ⟦continuous_on UNIV g; range g ⊆ T; ⋀x. x ∈ S ⟹ g x = f x⟧ ⟹ thesis) ⟹ thesis›*) proof (rule Borsuk_homotopy_extension_homotopic (*‹⟦closedin (top_of_set ?T) ?S; ANR ?S ∧ ANR ?T ∨ ANR ?U; continuous_on ?T ?f; ?f ∈ ?T → ?U; homotopic_with_canon (λx. True) ?S ?U ?f ?g; ⋀g'. ⟦homotopic_with_canon (λx. True) ?T ?U ?f g'; continuous_on ?T g'; g' ` ?T ⊆ ?U; ⋀x. x ∈ ?S ⟹ g' x = ?g x⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*)) (*goals: 1. ‹(⋀g. ⟦continuous_on UNIV g; range g ⊆ T; ⋀x. x ∈ S ⟹ g x = f x⟧ ⟹ thesis) ⟹ ANR S ∧ ANR UNIV ∨ ANR ?U2› 2. ‹(⋀g. ⟦continuous_on UNIV g; range g ⊆ T; ⋀x. x ∈ S ⟹ g x = f x⟧ ⟹ thesis) ⟹ continuous_on UNIV ?f2› 3. ‹(⋀g. ⟦continuous_on UNIV g; range g ⊆ T; ⋀x. x ∈ S ⟹ g x = f x⟧ ⟹ thesis) ⟹ ?f2 ∈ UNIV → ?U2› 4. ‹(⋀g. ⟦continuous_on UNIV g; range g ⊆ T; ⋀x. x ∈ S ⟹ g x = f x⟧ ⟹ thesis) ⟹ homotopic_with_canon (λx. True) S ?U2 ?f2 ?g2› 5. ‹⋀g'. ⟦⋀g. ⟦continuous_on UNIV g; range g ⊆ T; ⋀x. x ∈ S ⟹ g x = f x⟧ ⟹ thesis; homotopic_with_canon (λx. True) UNIV ?U2 ?f2 g'; continuous_on UNIV g'; range g' ⊆ ?U2; ⋀x. x ∈ S ⟹ g' x = ?g2 x⟧ ⟹ thesis›*) show "(λx. c) ∈ UNIV → T" using ‹S ≠ {}› (*‹(S::'a set) ≠ {}›*) c (*‹homotopic_with_canon (λx. True) S T (λx. c) f›*) homotopic_with_imp_subset1 (*‹homotopic_with_canon ?P ?X ?Y ?f ?g ⟹ ?f ` ?X ⊆ ?Y›*) by fastforce qed (use assms c in auto) (*solves the remaining goals: 1. ‹(⋀g. ⟦continuous_on UNIV g; range g ⊆ T; ⋀x. x ∈ S ⟹ g x = f x⟧ ⟹ thesis) ⟹ ANR S ∧ ANR UNIV ∨ ANR T› 2. ‹(⋀g. ⟦continuous_on UNIV g; range g ⊆ T; ⋀x. x ∈ S ⟹ g x = f x⟧ ⟹ thesis) ⟹ continuous_on UNIV (λx. c)› 3. ‹(⋀g. ⟦continuous_on UNIV g; range g ⊆ T; ⋀x. x ∈ S ⟹ g x = f x⟧ ⟹ thesis) ⟹ homotopic_with_canon (λx. True) S T (λx. c) ?g2› 4. ‹⋀g'. ⟦⋀g. ⟦continuous_on UNIV g; range g ⊆ T; ⋀x. x ∈ S ⟹ g x = f x⟧ ⟹ thesis; homotopic_with_canon (λx. True) UNIV T (λx. c) g'; continuous_on UNIV g'; range g' ⊆ T; ⋀x. x ∈ S ⟹ g' x = ?g2 x⟧ ⟹ thesis›*) then show "?rhs" by blast next (*goal: ‹∃g::'a ⇒ 'b. continuous_on UNIV g ∧ range g ⊆ (T::'b set) ∧ (∀x::'a∈S::'a set. g x = (f::'a ⇒ 'b) x) ⟹ ∃c::'b. homotopic_with_canon (λx::'a ⇒ 'b. True) S T f (λx::'a. c)›*) assume "?rhs" (*‹∃g::'a ⇒ 'b. continuous_on UNIV g ∧ range g ⊆ (T::'b set) ∧ (∀x::'a∈S::'a set. g x = (f::'a ⇒ 'b) x)›*) then obtain g where "continuous_on UNIV g" "range g ⊆ T" "⋀x. x∈S ⟹ g x = f x" (*goal: ‹(⋀g. ⟦continuous_on UNIV g; range g ⊆ T; ⋀x. x ∈ S ⟹ g x = f x⟧ ⟹ thesis) ⟹ thesis›*) by blast then obtain c where "homotopic_with_canon (λh. True) UNIV T g (λx. c)" (*goal: ‹(⋀c::'b::euclidean_space. homotopic_with_canon (λh::'a::euclidean_space ⇒ 'b::euclidean_space. True) UNIV (T::'b::euclidean_space set) (g::'a::euclidean_space ⇒ 'b::euclidean_space) (λx::'a::euclidean_space. c) ⟹ thesis::bool) ⟹ thesis›*) using nullhomotopic_from_contractible[of UNIV g T] (*‹⟦continuous_on UNIV g; g ∈ UNIV → T; contractible UNIV; ⋀c. homotopic_with_canon (λh. True) UNIV T g (λx. c) ⟹ ?thesis⟧ ⟹ ?thesis›*) contractible_UNIV (*‹contractible UNIV›*) by blast then have "homotopic_with_canon (λx. True) S T g (λx. c)" by (simp add: homotopic_from_subtopology (*‹homotopic_with ?P ?X ?X' ?f ?g ⟹ homotopic_with ?P (subtopology ?X ?S) ?X' ?f ?g›*)) then show "?lhs" by (force elim: homotopic_with_eq [of _ _ _ g "λx. c"] (*‹⟦homotopic_with ?P ?X ?Y g (λx. c); ⋀x. x ∈ topspace ?X ⟹ ?f' x = g x; ⋀x. x ∈ topspace ?X ⟹ ?g' x = c; ⋀h k. (⋀x. x ∈ topspace ?X ⟹ h x = k x) ⟹ ?P h = ?P k⟧ ⟹ homotopic_with ?P ?X ?Y ?f' ?g'›*) simp: ‹⋀x. x ∈ S ⟹ g x = f x›) qed corollary✐‹tag unimportant› nullhomotopic_into_rel_frontier_extension: fixes f :: "'a::euclidean_space ⇒ 'b::euclidean_space" assumes "closed S" and contf: "continuous_on S f" and "convex T" "bounded T" and fim: "f ` S ⊆ rel_frontier T" and "S ≠ {}" shows "(∃c. homotopic_with_canon (λx. True) S (rel_frontier T) f (λx. c)) ⟷ (∃g. continuous_on UNIV g ∧ range g ⊆ rel_frontier T ∧ (∀x ∈ S. g x = f x))" by (simp add: nullhomotopic_into_ANR_extension (*‹⟦closed ?S; continuous_on ?S ?f; ANR ?T; ?f ` ?S ⊆ ?T; ?S ≠ {}⟧ ⟹ (∃c. homotopic_with_canon (λx. True) ?S ?T ?f (λx. c)) = (∃g. continuous_on UNIV g ∧ range g ⊆ ?T ∧ (∀x∈?S. g x = ?f x))›*) assms (*‹closed S› ‹continuous_on S f› ‹convex T› ‹bounded T› ‹f ` S ⊆ rel_frontier T› ‹S ≠ {}›*) ANR_rel_frontier_convex (*‹⟦bounded ?S; convex ?S⟧ ⟹ ANR (rel_frontier ?S)›*)) corollary✐‹tag unimportant› nullhomotopic_into_sphere_extension: fixes f :: "'a::euclidean_space ⇒ 'b :: euclidean_space" assumes "closed S" and contf: "continuous_on S f" and "S ≠ {}" and fim: "f ` S ⊆ sphere a r" shows "((∃c. homotopic_with_canon (λx. True) S (sphere a r) f (λx. c)) ⟷ (∃g. continuous_on UNIV g ∧ range g ⊆ sphere a r ∧ (∀x ∈ S. g x = f x)))" (is "?lhs = ?rhs") proof (cases "r = 0") (*goals: 1. ‹r = 0 ⟹ (∃c. homotopic_with_canon (λx. True) S (sphere a r) f (λx. c)) = (∃g. continuous_on UNIV g ∧ range g ⊆ sphere a r ∧ (∀x∈S. g x = f x))› 2. ‹r ≠ 0 ⟹ (∃c. homotopic_with_canon (λx. True) S (sphere a r) f (λx. c)) = (∃g. continuous_on UNIV g ∧ range g ⊆ sphere a r ∧ (∀x∈S. g x = f x))›*) case True (*‹r = 0›*) with fim (*‹f ` S ⊆ sphere a r›*) show "?thesis" (*goal: ‹(∃c. homotopic_with_canon (λx. True) S (sphere a r) f (λx. c)) = (∃g. continuous_on UNIV g ∧ range g ⊆ sphere a r ∧ (∀x∈S. g x = f x))›*) by (metis ANR_sphere (*‹ANR (sphere ?a ?r)›*) ‹closed S› ‹S ≠ {}› contf (*‹continuous_on S f›*) nullhomotopic_into_ANR_extension (*‹⟦closed ?S; continuous_on ?S ?f; ANR ?T; ?f ` ?S ⊆ ?T; ?S ≠ {}⟧ ⟹ (∃c. homotopic_with_canon (λx. True) ?S ?T ?f (λx. c)) = (∃g. continuous_on UNIV g ∧ range g ⊆ ?T ∧ (∀x∈?S. g x = ?f x))›*)) next (*goal: ‹r ≠ 0 ⟹ (∃c. homotopic_with_canon (λx. True) S (sphere a r) f (λx. c)) = (∃g. continuous_on UNIV g ∧ range g ⊆ sphere a r ∧ (∀x∈S. g x = f x))›*) case False (*‹r ≠ 0›*) then have eq: "sphere a r = rel_frontier (cball a r)" by simp show "?thesis" (*goal: ‹(∃c::'b::euclidean_space. homotopic_with_canon (λx::'a::euclidean_space ⇒ 'b::euclidean_space. True) (S::'a::euclidean_space set) (sphere (a::'b::euclidean_space) (r::real)) (f::'a::euclidean_space ⇒ 'b::euclidean_space) (λx::'a::euclidean_space. c)) = (∃g::'a::euclidean_space ⇒ 'b::euclidean_space. continuous_on UNIV g ∧ range g ⊆ sphere a r ∧ (∀x::'a::euclidean_space∈S. g x = f x))›*) using fim (*‹f ` S ⊆ sphere a r›*) nullhomotopic_into_rel_frontier_extension[OF ‹closed S› contf convex_cball bounded_cball] (*‹⟦f ` S ⊆ rel_frontier (cball ?x1 ?e1); S ≠ {}⟧ ⟹ (∃c. homotopic_with_canon (λx. True) S (rel_frontier (cball ?x1 ?e1)) f (λx. c)) = (∃g. continuous_on UNIV g ∧ range g ⊆ rel_frontier (cball ?x1 ?e1) ∧ (∀x∈S. g x = f x))›*) by (simp add: ‹S ≠ {}› eq (*‹sphere a r = rel_frontier (cball a r)›*)) qed proposition✐‹tag unimportant› Borsuk_map_essential_bounded_component: fixes a :: "'a :: euclidean_space" assumes "compact S" and "a ∉ S" shows "bounded (connected_component_set (- S) a) ⟷ ¬(∃c. homotopic_with_canon (λx. True) S (sphere 0 1) (λx. inverse(norm(x - a)) *⇩R (x - a)) (λx. c))" (is "?lhs = ?rhs") proof (cases "S = {}") (*goals: 1. ‹S = {} ⟹ bounded (connected_component_set (- S) a) = (∄c. homotopic_with_canon (λx. True) S (sphere 0 1) (λx. (x - a) /⇩R norm (x - a)) (λx. c))› 2. ‹S ≠ {} ⟹ bounded (connected_component_set (- S) a) = (∄c. homotopic_with_canon (λx. True) S (sphere 0 1) (λx. (x - a) /⇩R norm (x - a)) (λx. c))›*) case True (*‹S = {}›*) then show "?thesis" (*goal: ‹bounded (connected_component_set (- S) a) = (∄c. homotopic_with_canon (λx. True) S (sphere 0 1) (λx. (x - a) /⇩R norm (x - a)) (λx. c))›*) by (simp add: homotopic_on_emptyI (*‹⟦?P ?f; ?P ?g⟧ ⟹ homotopic_with ?P trivial_topology ?X ?f ?g›*)) next (*goal: ‹S ≠ {} ⟹ bounded (connected_component_set (- S) a) = (∄c. homotopic_with_canon (λx. True) S (sphere 0 1) (λx. (x - a) /⇩R norm (x - a)) (λx. c))›*) case False (*‹S ≠ {}›*) have "closed S" "bounded S" using ‹compact S› (*‹compact S›*) compact_eq_bounded_closed (*‹compact ?S = (bounded ?S ∧ closed ?S)›*) apply - (*goals: 1. ‹⟦compact (S::'a set); ⋀S::?'a4 set. compact S = (bounded S ∧ closed S)⟧ ⟹ closed S› 2. ‹⟦compact (S::'a set); ⋀S::?'a1 set. compact S = (bounded S ∧ closed S)⟧ ⟹ bounded S› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . have s01: "(λx. (x - a) /⇩R norm (x - a)) ` S ⊆ sphere 0 1" using ‹a ∉ S› (*‹(a::'a) ∉ (S::'a set)›*) apply clarsimp (*goal: ‹(λx. (x - a) /⇩R norm (x - a)) ` S ⊆ sphere 0 1›*) by (metis dist_eq_0_iff (*‹(dist ?x ?y = 0) = (?x = ?y)›*) dist_norm (*‹dist ?x ?y = norm (?x - ?y)›*) mult.commute (*‹?a * ?b = ?b * ?a›*) right_inverse (*‹?a ≠ 0 ⟹ ?a * inverse ?a = 1›*)) have aincc: "a ∈ connected_component_set (- S) a" by (simp add: ‹a ∉ S›) obtain r where "r>0" and r: "S ⊆ ball 0 r" (*goal: ‹(⋀r. ⟦0 < r; S ⊆ ball 0 r⟧ ⟹ thesis) ⟹ thesis›*) using bounded_subset_ballD (*‹bounded ?S ⟹ ∃r>0. ?S ⊆ ball ?x r›*) ‹bounded S› (*‹bounded (S::'a set)›*) by blast have "¬ ?rhs ⟷ ¬ ?lhs" proof (standard) (*goals: 1. ‹¬ (∄c. homotopic_with_canon (λx. True) S (sphere 0 1) (λx. (x - a) /⇩R norm (x - a)) (λx. c)) ⟹ ¬ bounded (connected_component_set (- S) a)› 2. ‹¬ bounded (connected_component_set (- S) a) ⟹ ¬ (∄c. homotopic_with_canon (λx. True) S (sphere 0 1) (λx. (x - a) /⇩R norm (x - a)) (λx. c))›*) assume notr: "¬ ?rhs" (*‹¬ (∄c::'a. homotopic_with_canon (λx::'a ⇒ 'a. True) (S::'a set) (sphere (0::'a) (1::real)) (λx::'a. (x - (a::'a)) /⇩R norm (x - a)) (λx::'a. c))›*) have nog: "∄g. continuous_on (S ∪ connected_component_set (- S) a) g ∧ g ` (S ∪ connected_component_set (- S) a) ⊆ sphere 0 1 ∧ (∀x∈S. g x = (x - a) /⇩R norm (x - a))" if "bounded (connected_component_set (- S) a)" using non_extensible_Borsuk_map[OF ‹compact S› componentsI _ aincc] (*‹⟦a ∈ - S; bounded (connected_component_set (- S) a)⟧ ⟹ ∄g. continuous_on (S ∪ connected_component_set (- S) a) g ∧ g ∈ S ∪ connected_component_set (- S) a → sphere 0 1 ∧ (∀x∈S. g x = (x - a) /⇩R norm (x - a))›*) ‹a ∉ S› (*‹a ∉ S›*) that (*‹bounded (connected_component_set (- S) a)›*) by auto obtain g where "range g ⊆ sphere 0 1" "continuous_on UNIV g" "⋀x. x ∈ S ⟹ g x = (x - a) /⇩R norm (x - a)" (*goal: ‹(⋀g. ⟦range g ⊆ sphere 0 1; continuous_on UNIV g; ⋀x. x ∈ S ⟹ g x = (x - a) /⇩R norm (x - a)⟧ ⟹ thesis) ⟹ thesis›*) using notr (*‹¬ (∄c. homotopic_with_canon (λx. True) S (sphere 0 1) (λx. (x - a) /⇩R norm (x - a)) (λx. c))›*) by (auto simp: nullhomotopic_into_sphere_extension [OF ‹closed S› continuous_on_Borsuk_map [OF ‹a ∉ S›] False s01] (*‹(∃c. homotopic_with_canon (λx. True) S (sphere 0 1) (λx. (x - a) /⇩R norm (x - a)) (λx. c)) = (∃g. continuous_on UNIV g ∧ range g ⊆ sphere 0 1 ∧ (∀x∈S. g x = (x - a) /⇩R norm (x - a)))›*)) with ‹a ∉ S› (*‹a ∉ S›*) show "¬ ?lhs" by (metis UNIV_I (*‹?x ∈ UNIV›*) continuous_on_subset (*‹⟦continuous_on ?s ?f; ?t ⊆ ?s⟧ ⟹ continuous_on ?t ?f›*) image_subset_iff (*‹(?f ` ?A ⊆ ?B) = (∀x∈?A. ?f x ∈ ?B)›*) nog (*‹bounded (connected_component_set (- S) a) ⟹ ∄g. continuous_on (S ∪ connected_component_set (- S) a) g ∧ g ` (S ∪ connected_component_set (- S) a) ⊆ sphere 0 1 ∧ (∀x∈S. g x = (x - a) /⇩R norm (x - a))›*) subsetI (*‹(⋀x. x ∈ ?A ⟹ x ∈ ?B) ⟹ ?A ⊆ ?B›*)) next (*goal: ‹¬ bounded (connected_component_set (- S) a) ⟹ ¬ (∄c. homotopic_with_canon (λx. True) S (sphere 0 1) (λx. (x - a) /⇩R norm (x - a)) (λx. c))›*) assume "¬ ?lhs" (*‹¬ bounded (connected_component_set (- (S::'a set)) (a::'a))›*) then obtain b where b: "b ∈ connected_component_set (- S) a" and "r ≤ norm b" (*goal: ‹(⋀b. ⟦b ∈ connected_component_set (- S) a; r ≤ norm b⟧ ⟹ thesis) ⟹ thesis›*) using bounded_iff (*‹bounded ?S = (∃a. ∀x∈?S. norm x ≤ a)›*) linear (*‹?x ≤ ?y ∨ ?y ≤ ?x›*) by blast then have bnot: "b ∉ ball 0 r" by simp have "homotopic_with_canon (λx. True) S (sphere 0 1) (λx. (x - a) /⇩R norm (x - a)) (λx. (x - b) /⇩R norm (x - b))" proof (-) (*goal: ‹homotopic_with_canon (λx::'a::euclidean_space ⇒ 'a::euclidean_space. True) (S::'a::euclidean_space set) (sphere (0::'a::euclidean_space) (1::real)) (λx::'a::euclidean_space. (x - (a::'a::euclidean_space)) /⇩R norm (x - a)) (λx::'a::euclidean_space. (x - (b::'a::euclidean_space)) /⇩R norm (x - b))›*) have "path_component (- S) a b" by (metis (full_types) ‹closed S› b (*‹b ∈ connected_component_set (- S) a›*) mem_Collect_eq (*‹(?a ∈ Collect ?P) = ?P ?a›*) open_Compl (*‹closed ?S ⟹ open (- ?S)›*) open_path_connected_component (*‹open ?S ⟹ path_component ?S ?x = connected_component ?S ?x›*)) then show "?thesis" (*goal: ‹homotopic_with_canon (λx. True) S (sphere 0 1) (λx. (x - a) /⇩R norm (x - a)) (λx. (x - b) /⇩R norm (x - b))›*) using Borsuk_maps_homotopic_in_path_component (*‹path_component (- ?S) ?a ?b ⟹ homotopic_with_canon (λx. True) ?S (sphere 0 1) (λx. (x - ?a) /⇩R norm (x - ?a)) (λx. (x - ?b) /⇩R norm (x - ?b))›*) by blast qed moreover obtain c where "homotopic_with_canon (λx. True) (ball 0 r) (sphere 0 1) (λx. inverse (norm (x - b)) *⇩R (x - b)) (λx. c)" (*goal: ‹(⋀c::'a. homotopic_with_canon (λx::'a ⇒ 'a. True) (ball (0::'a) (r::real)) (sphere (0::'a) (1::real)) (λx::'a. (x - (b::'a)) /⇩R norm (x - b)) (λx::'a. c) ⟹ thesis::bool) ⟹ thesis›*) proof (rule nullhomotopic_from_contractible (*‹⟦continuous_on ?S ?f; ?f ∈ ?S → ?T; contractible ?S; ⋀c. homotopic_with_canon (λh. True) ?S ?T ?f (λx. c) ⟹ ?thesis⟧ ⟹ ?thesis›*)) (*goals: 1. ‹(⋀c::'a. homotopic_with_canon (λx::'a ⇒ 'a. True) (ball (0::'a) (r::real)) (sphere (0::'a) (1::real)) (λx::'a. (x - (b::'a)) /⇩R norm (x - b)) (λx::'a. c) ⟹ thesis::bool) ⟹ continuous_on (?S2::?'a2 set) (?f2::?'a2 ⇒ ?'b2)› 2. ‹(⋀c::'a. homotopic_with_canon (λx::'a ⇒ 'a. True) (ball (0::'a) (r::real)) (sphere (0::'a) (1::real)) (λx::'a. (x - (b::'a)) /⇩R norm (x - b)) (λx::'a. c) ⟹ thesis::bool) ⟹ (?f2::?'a2 ⇒ ?'b2) ∈ (?S2::?'a2 set) → (?T2::?'b2 set)› 3. ‹(⋀c::'a. homotopic_with_canon (λx::'a ⇒ 'a. True) (ball (0::'a) (r::real)) (sphere (0::'a) (1::real)) (λx::'a. (x - (b::'a)) /⇩R norm (x - b)) (λx::'a. c) ⟹ thesis::bool) ⟹ contractible (?S2::?'a2 set)› 4. ‹⋀c::?'b2. ⟦⋀c::'a. homotopic_with_canon (λx::'a ⇒ 'a. True) (ball (0::'a) (r::real)) (sphere (0::'a) (1::real)) (λx::'a. (x - (b::'a)) /⇩R norm (x - b)) (λx::'a. c) ⟹ thesis::bool; homotopic_with_canon (λh::?'a2 ⇒ ?'b2. True) (?S2::?'a2 set) (?T2::?'b2 set) (?f2::?'a2 ⇒ ?'b2) (λx::?'a2. c)⟧ ⟹ thesis›*) show "contractible (ball (0::'a) r)" by (metis convex_imp_contractible (*‹convex (?S::?'a set) ⟹ contractible ?S›*) convex_ball (*‹convex (ball (?x::?'a) (?e::real))›*)) show "continuous_on (ball 0 r) (λx. inverse(norm (x - b)) *⇩R (x - b))" by (rule continuous_on_Borsuk_map [OF bnot] (*‹continuous_on (ball (0::'a::euclidean_space) (r::real)) (λx::'a::euclidean_space. (x - (b::'a::euclidean_space)) /⇩R norm (x - b))›*)) show "(λx. (x - b) /⇩R norm (x - b)) ∈ ball 0 r → sphere 0 1" using bnot (*‹b ∉ ball 0 r›*) Borsuk_map_into_sphere (*‹((λx. (x - ?a) /⇩R norm (x - ?a)) ∈ ?S → sphere 0 1) = (?a ∉ ?S)›*) by blast qed (blast) (*solved the remaining goal: ‹⋀c. ⟦⋀c. homotopic_with_canon (λx. True) (ball 0 r) (sphere 0 1) (λx. (x - b) /⇩R norm (x - b)) (λx. c) ⟹ thesis; homotopic_with_canon (λh. True) (ball 0 r) (sphere 0 1) (λx. (x - b) /⇩R norm (x - b)) (λx. c)⟧ ⟹ thesis›*) ultimately have "homotopic_with_canon (λx. True) S (sphere 0 1) (λx. (x - a) /⇩R norm (x - a)) (λx. c)" by (meson homotopic_with_subset_left (*‹⟦homotopic_with_canon ?P ?X ?Y ?f ?g; ?Z ⊆ ?X⟧ ⟹ homotopic_with_canon ?P ?Z ?Y ?f ?g›*) homotopic_with_trans (*‹⟦homotopic_with ?P ?X ?Y ?f ?g; homotopic_with ?P ?X ?Y ?g ?h⟧ ⟹ homotopic_with ?P ?X ?Y ?f ?h›*) r (*‹S ⊆ ball 0 r›*)) then show "¬ ?rhs" by blast qed then show "?thesis" (*goal: ‹bounded (connected_component_set (- S) a) = (∄c. homotopic_with_canon (λx. True) S (sphere 0 1) (λx. (x - a) /⇩R norm (x - a)) (λx. c))›*) by blast qed lemma homotopic_Borsuk_maps_in_bounded_component: fixes a :: "'a :: euclidean_space" assumes "compact S" and "a ∉ S"and "b ∉ S" and boc: "bounded (connected_component_set (- S) a)" and hom: "homotopic_with_canon (λx. True) S (sphere 0 1) (λx. (x - a) /⇩R norm (x - a)) (λx. (x - b) /⇩R norm (x - b))" shows "connected_component (- S) a b" proof (rule ccontr (*‹(¬ ?P ⟹ False) ⟹ ?P›*)) (*goal: ‹¬ connected_component (- S) a b ⟹ False›*) assume notcc: "¬ connected_component (- S) a b" (*‹¬ connected_component (- (S::'a set)) (a::'a) (b::'a)›*) let ?T = "S ∪ connected_component_set (- S) a" have "∄g. continuous_on (S ∪ connected_component_set (- S) a) g ∧ g ∈ (S ∪ connected_component_set (- S) a) → sphere 0 1 ∧ (∀x∈S. g x = (x - a) /⇩R norm (x - a))" using non_extensible_Borsuk_map[OF ‹compact S› _ boc] (*‹⟦connected_component_set (- S) a ∈ components (- S); ?a ∈ connected_component_set (- S) a⟧ ⟹ ∄g. continuous_on (S ∪ connected_component_set (- S) a) g ∧ g ∈ S ∪ connected_component_set (- S) a → sphere 0 1 ∧ (∀x∈S. g x = (x - ?a) /⇩R norm (x - ?a))›*) ‹a ∉ S› (*‹(a::'a) ∉ (S::'a set)›*) by (simp add: componentsI (*‹?x ∈ ?U ⟹ connected_component_set ?U ?x ∈ components ?U›*)) moreover obtain g where "continuous_on (S ∪ connected_component_set (- S) a) g" "g ` (S ∪ connected_component_set (- S) a) ⊆ sphere 0 1" "⋀x. x ∈ S ⟹ g x = (x - a) /⇩R norm (x - a)" (*goal: ‹(⋀g. ⟦continuous_on (S ∪ connected_component_set (- S) a) g; g ` (S ∪ connected_component_set (- S) a) ⊆ sphere 0 1; ⋀x. x ∈ S ⟹ g x = (x - a) /⇩R norm (x - a)⟧ ⟹ thesis) ⟹ thesis›*) proof (rule Borsuk_homotopy_extension_homotopic (*‹⟦closedin (top_of_set ?T) ?S; ANR ?S ∧ ANR ?T ∨ ANR ?U; continuous_on ?T ?f; ?f ∈ ?T → ?U; homotopic_with_canon (λx. True) ?S ?U ?f ?g; ⋀g'. ⟦homotopic_with_canon (λx. True) ?T ?U ?f g'; continuous_on ?T g'; g' ` ?T ⊆ ?U; ⋀x. x ∈ ?S ⟹ g' x = ?g x⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*)) (*goals: 1. ‹(⋀g. ⟦continuous_on (S ∪ connected_component_set (- S) a) g; g ` (S ∪ connected_component_set (- S) a) ⊆ sphere 0 1; ⋀x. x ∈ S ⟹ g x = (x - a) /⇩R norm (x - a)⟧ ⟹ thesis) ⟹ closedin (top_of_set ?T2) ?S2› 2. ‹(⋀g. ⟦continuous_on (S ∪ connected_component_set (- S) a) g; g ` (S ∪ connected_component_set (- S) a) ⊆ sphere 0 1; ⋀x. x ∈ S ⟹ g x = (x - a) /⇩R norm (x - a)⟧ ⟹ thesis) ⟹ ANR ?S2 ∧ ANR ?T2 ∨ ANR ?U2› 3. ‹(⋀g. ⟦continuous_on (S ∪ connected_component_set (- S) a) g; g ` (S ∪ connected_component_set (- S) a) ⊆ sphere 0 1; ⋀x. x ∈ S ⟹ g x = (x - a) /⇩R norm (x - a)⟧ ⟹ thesis) ⟹ continuous_on ?T2 ?f2› 4. ‹(⋀g. ⟦continuous_on (S ∪ connected_component_set (- S) a) g; g ` (S ∪ connected_component_set (- S) a) ⊆ sphere 0 1; ⋀x. x ∈ S ⟹ g x = (x - a) /⇩R norm (x - a)⟧ ⟹ thesis) ⟹ ?f2 ∈ ?T2 → ?U2› 5. ‹(⋀g. ⟦continuous_on (S ∪ connected_component_set (- S) a) g; g ` (S ∪ connected_component_set (- S) a) ⊆ sphere 0 1; ⋀x. x ∈ S ⟹ g x = (x - a) /⇩R norm (x - a)⟧ ⟹ thesis) ⟹ homotopic_with_canon (λx. True) ?S2 ?U2 ?f2 ?g2› 6. ‹⋀g'. ⟦⋀g. ⟦continuous_on (S ∪ connected_component_set (- S) a) g; g ` (S ∪ connected_component_set (- S) a) ⊆ sphere 0 1; ⋀x. x ∈ S ⟹ g x = (x - a) /⇩R norm (x - a)⟧ ⟹ thesis; homotopic_with_canon (λx. True) ?T2 ?U2 ?f2 g'; continuous_on ?T2 g'; g' ` ?T2 ⊆ ?U2; ⋀x. x ∈ ?S2 ⟹ g' x = ?g2 x⟧ ⟹ thesis›*) show "closedin (top_of_set ?T) S" by (simp add: ‹compact S› closed_subset (*‹⟦?S ⊆ ?T; closed ?S⟧ ⟹ closedin (top_of_set ?T) ?S›*) compact_imp_closed (*‹compact ?s ⟹ closed ?s›*)) show "continuous_on ?T (λx. (x - b) /⇩R norm (x - b))" by (simp add: ‹b ∉ S› notcc (*‹¬ connected_component (- S) a b›*) continuous_on_Borsuk_map (*‹?a ∉ ?S ⟹ continuous_on ?S (λx. (x - ?a) /⇩R norm (x - ?a))›*)) show "(λx. (x - b) /⇩R norm (x - b)) ∈ ?T → sphere 0 1" by (simp add: ‹b ∉ S› notcc (*‹¬ connected_component (- S) a b›*) Borsuk_map_into_sphere (*‹((λx. (x - ?a) /⇩R norm (x - ?a)) ∈ ?S → sphere 0 1) = (?a ∉ ?S)›*)) show "homotopic_with_canon (λx. True) S (sphere 0 1) (λx. (x - b) /⇩R norm (x - b)) (λx. (x - a) /⇩R norm (x - a))" by (simp add: hom (*‹homotopic_with_canon (λx. True) S (sphere 0 1) (λx. (x - a) /⇩R norm (x - a)) (λx. (x - b) /⇩R norm (x - b))›*) homotopic_with_symD (*‹homotopic_with ?P ?X ?Y ?f ?g ⟹ homotopic_with ?P ?X ?Y ?g ?f›*)) qed (auto simp: ANR_sphere (*‹ANR (sphere ?a ?r)›*) intro: that (*‹⟦continuous_on (S ∪ connected_component_set (- S) a) ?g; ?g ` (S ∪ connected_component_set (- S) a) ⊆ sphere 0 1; ⋀x. x ∈ S ⟹ ?g x = (x - a) /⇩R norm (x - a)⟧ ⟹ thesis›*)) (*solves the remaining goals: 1. ‹(⋀g. ⟦continuous_on (S ∪ connected_component_set (- S) a) g; g ` (S ∪ connected_component_set (- S) a) ⊆ sphere 0 1; ⋀x. x ∈ S ⟹ g x = (x - a) /⇩R norm (x - a)⟧ ⟹ thesis) ⟹ ANR S ∧ ANR (S ∪ connected_component_set (- S) a) ∨ ANR (sphere 0 1)› 2. ‹⋀g'. ⟦⋀g. ⟦continuous_on (S ∪ connected_component_set (- S) a) g; g ` (S ∪ connected_component_set (- S) a) ⊆ sphere 0 1; ⋀x. x ∈ S ⟹ g x = (x - a) /⇩R norm (x - a)⟧ ⟹ thesis; homotopic_with_canon (λx. True) (S ∪ connected_component_set (- S) a) (sphere 0 1) (λx. (x - b) /⇩R norm (x - b)) g'; continuous_on (S ∪ connected_component_set (- S) a) g'; g' ` (S ∪ connected_component_set (- S) a) ⊆ sphere 0 1; ⋀x. x ∈ S ⟹ g' x = (x - a) /⇩R norm (x - a)⟧ ⟹ thesis›*) ultimately show False by blast qed lemma Borsuk_maps_homotopic_in_connected_component_eq: fixes a :: "'a :: euclidean_space" assumes S: "compact S" "a ∉ S" "b ∉ S" and 2: "2 ≤ DIM('a)" shows "(homotopic_with_canon (λx. True) S (sphere 0 1) (λx. (x - a) /⇩R norm (x - a)) (λx. (x - b) /⇩R norm (x - b)) ⟷ connected_component (- S) a b)" (is "?lhs = ?rhs") proof (standard) (*goals: 1. ‹homotopic_with_canon (λx. True) S (sphere 0 1) (λx. (x - a) /⇩R norm (x - a)) (λx. (x - b) /⇩R norm (x - b)) ⟹ connected_component (- S) a b› 2. ‹connected_component (- S) a b ⟹ homotopic_with_canon (λx. True) S (sphere 0 1) (λx. (x - a) /⇩R norm (x - a)) (λx. (x - b) /⇩R norm (x - b))›*) assume L: "?lhs" (*‹homotopic_with_canon (λx::'a ⇒ 'a. True) (S::'a set) (sphere (0::'a) (1::real)) (λx::'a. (x - (a::'a)) /⇩R norm (x - a)) (λx::'a. (x - (b::'a)) /⇩R norm (x - b))›*) show "?rhs" proof (cases "bounded(connected_component_set (- S) a)") (*goals: 1. ‹bounded (connected_component_set (- S) a) ⟹ connected_component (- S) a b› 2. ‹¬ bounded (connected_component_set (- S) a) ⟹ connected_component (- S) a b›*) case True (*‹bounded (connected_component_set (- S) a)›*) show "?thesis" (*goal: ‹connected_component (- S) a b›*) by (rule homotopic_Borsuk_maps_in_bounded_component [OF S True L] (*‹connected_component (- S) a b›*)) next (*goal: ‹¬ bounded (connected_component_set (- S) a) ⟹ connected_component (- S) a b›*) case not_bo_a: False (*‹¬ bounded (connected_component_set (- S) a)›*) show "?thesis" (*goal: ‹connected_component (- S) a b›*) proof (cases "bounded(connected_component_set (- S) b)") (*goals: 1. ‹bounded (connected_component_set (- (S::'a set)) (b::'a)) ⟹ connected_component (- S) (a::'a) b› 2. ‹¬ bounded (connected_component_set (- (S::'a set)) (b::'a)) ⟹ connected_component (- S) (a::'a) b›*) case True (*‹bounded (connected_component_set (- (S::'a set)) (b::'a))›*) show "?thesis" (*goal: ‹connected_component (- S) a b›*) using homotopic_Borsuk_maps_in_bounded_component[OF S] (*‹⟦bounded (connected_component_set (- S) a); homotopic_with_canon (λx. True) S (sphere 0 1) (λx. (x - a) /⇩R norm (x - a)) (λx. (x - b) /⇩R norm (x - b))⟧ ⟹ connected_component (- S) a b›*) by (simp add: L (*‹homotopic_with_canon (λx::'a ⇒ 'a. True) (S::'a set) (sphere (0::'a) (1::real)) (λx::'a. (x - (a::'a)) /⇩R norm (x - a)) (λx::'a. (x - (b::'a)) /⇩R norm (x - b))›*) True (*‹bounded (connected_component_set (- (S::'a set)) (b::'a))›*) assms (*‹compact (S::'a set)› ‹(a::'a) ∉ (S::'a set)› ‹(b::'a) ∉ (S::'a set)› ‹(2::nat) ≤ DIM('a)›*) connected_component_sym (*‹connected_component (?S::?'a set) (?x::?'a) (?y::?'a) ⟹ connected_component ?S ?y ?x›*) homotopic_Borsuk_maps_in_bounded_component (*‹⟦compact (?S::?'a set); (?a::?'a) ∉ ?S; (?b::?'a) ∉ ?S; bounded (connected_component_set (- ?S) ?a); homotopic_with_canon (λx::?'a ⇒ ?'a. True) ?S (sphere (0::?'a) (1::real)) (λx::?'a. (x - ?a) /⇩R norm (x - ?a)) (λx::?'a. (x - ?b) /⇩R norm (x - ?b))⟧ ⟹ connected_component (- ?S) ?a ?b›*) homotopic_with_sym (*‹homotopic_with (?P::(?'a ⇒ ?'b) ⇒ bool) (?X::?'a topology) (?Y::?'b topology) (?f::?'a ⇒ ?'b) (?g::?'a ⇒ ?'b) = homotopic_with ?P ?X ?Y ?g ?f›*)) next (*goal: ‹¬ bounded (connected_component_set (- S) b) ⟹ connected_component (- S) a b›*) case False (*‹¬ bounded (connected_component_set (- S) b)›*) then show "?thesis" (*goal: ‹connected_component (- (S::'a::euclidean_space set)) (a::'a::euclidean_space) (b::'a::euclidean_space)›*) using cobounded_unique_unbounded_component[of "-S" a b] (*‹⟦bounded (- (- S)); 2 ≤ DIM('a); ¬ bounded (connected_component_set (- S) a); ¬ bounded (connected_component_set (- S) b)⟧ ⟹ connected_component_set (- S) a = connected_component_set (- S) b›*) ‹compact S› (*‹compact S›*) not_bo_a (*‹¬ bounded (connected_component_set (- (S::'a set)) (a::'a))›*) by (auto simp: compact_eq_bounded_closed (*‹compact (?S::?'a::heine_borel set) = (bounded ?S ∧ closed ?S)›*) assms (*‹compact (S::'a::euclidean_space set)› ‹(a::'a::euclidean_space) ∉ (S::'a::euclidean_space set)› ‹(b::'a::euclidean_space) ∉ (S::'a::euclidean_space set)› ‹(2::nat) ≤ DIM('a::euclidean_space)›*) connected_component_eq_eq (*‹(connected_component_set (?S::?'a::topological_space set) (?x::?'a::topological_space) = connected_component_set ?S (?y::?'a::topological_space)) = (?x ∉ ?S ∧ ?y ∉ ?S ∨ ?x ∈ ?S ∧ ?y ∈ ?S ∧ connected_component ?S ?x ?y)›*)) qed qed next (*goal: ‹connected_component (- S) a b ⟹ homotopic_with_canon (λx. True) S (sphere 0 1) (λx. (x - a) /⇩R norm (x - a)) (λx. (x - b) /⇩R norm (x - b))›*) assume R: "?rhs" (*‹connected_component (- (S::'a set)) (a::'a) (b::'a)›*) then have "path_component (- S) a b" using assms(1) (*‹compact (S::'a set)›*) compact_eq_bounded_closed (*‹compact ?S = (bounded ?S ∧ closed ?S)›*) open_Compl (*‹closed ?S ⟹ open (- ?S)›*) open_path_connected_component_set (*‹open ?S ⟹ path_component_set ?S ?x = connected_component_set ?S ?x›*) by fastforce then show "?lhs" by (simp add: Borsuk_maps_homotopic_in_path_component (*‹path_component (- (?S::?'a set)) (?a::?'a) (?b::?'a) ⟹ homotopic_with_canon (λx::?'a ⇒ ?'a. True) ?S (sphere (0::?'a) (1::real)) (λx::?'a. (x - ?a) /⇩R norm (x - ?a)) (λx::?'a. (x - ?b) /⇩R norm (x - ?b))›*)) qed subsection‹More extension theorems› lemma extension_from_clopen: assumes ope: "openin (top_of_set S) T" and clo: "closedin (top_of_set S) T" and contf: "continuous_on T f" and fim: "f ` T ⊆ U" and null: "U = {} ⟹ S = {}" obtains g where "continuous_on S g" "g ` S ⊆ U" "⋀x. x ∈ T ⟹ g x = f x" proof (cases "U = {}") (*goals: 1. ‹⟦⋀g. ⟦continuous_on S g; g ` S ⊆ U; ⋀x. x ∈ T ⟹ g x = f x⟧ ⟹ thesis; U = {}⟧ ⟹ thesis› 2. ‹⟦⋀g. ⟦continuous_on S g; g ` S ⊆ U; ⋀x. x ∈ T ⟹ g x = f x⟧ ⟹ thesis; U ≠ {}⟧ ⟹ thesis›*) case True (*‹U = {}›*) then show "?thesis" (*goal: ‹thesis›*) by (simp add: null (*‹U = {} ⟹ S = {}›*) that (*‹⟦continuous_on S ?g; ?g ` S ⊆ U; ⋀x. x ∈ T ⟹ ?g x = f x⟧ ⟹ thesis›*)) next (*goal: ‹⟦⋀g. ⟦continuous_on S g; g ` S ⊆ U; ⋀x. x ∈ T ⟹ g x = f x⟧ ⟹ thesis; U ≠ {}⟧ ⟹ thesis›*) case False (*‹U ≠ {}›*) then obtain a where "a ∈ U" (*goal: ‹(⋀a. a ∈ U ⟹ thesis) ⟹ thesis›*) by auto let ?g = "λx. if x ∈ T then f x else a" have Seq: "S = T ∪ (S - T)" using clo (*‹closedin (top_of_set (S::'a set)) (T::'a set)›*) closedin_imp_subset (*‹closedin (subtopology ?U ?S) ?T ⟹ ?T ⊆ ?S›*) by fastforce show "?thesis" (*goal: ‹thesis::bool›*) proof (standard) (*goals: 1. ‹continuous_on (S::'a::topological_space set) (?g::'a::topological_space ⇒ 'b::topological_space)› 2. ‹(?g::'a::topological_space ⇒ 'b::topological_space) ` (S::'a::topological_space set) ⊆ (U::'b::topological_space set)› 3. ‹⋀x::'a::topological_space. x ∈ (T::'a::topological_space set) ⟹ (?g::'a::topological_space ⇒ 'b::topological_space) x = (f::'a::topological_space ⇒ 'b::topological_space) x›*) have "continuous_on (T ∪ (S - T)) ?g" using Seq (*‹S = T ∪ (S - T)›*) clo (*‹closedin (top_of_set S) T›*) ope (*‹openin (top_of_set (S::'a set)) (T::'a set)›*) apply (intro continuous_on_cases_local (*‹⟦closedin (top_of_set (?S ∪ ?T)) ?S; closedin (top_of_set (?S ∪ ?T)) ?T; continuous_on ?S ?f; continuous_on ?T ?g; ⋀x. x ∈ ?S ∧ ¬ ?P x ∨ x ∈ ?T ∧ ?P x ⟹ ?f x = ?g x⟧ ⟹ continuous_on (?S ∪ ?T) (λx. if ?P x then ?f x else ?g x)›*)) (*goals: 1. ‹⟦(S::'a set) = (T::'a set) ∪ (S - T); closedin (top_of_set S) T; openin (top_of_set S) T⟧ ⟹ closedin (top_of_set (T ∪ (S - T))) T› 2. ‹⟦(S::'a set) = (T::'a set) ∪ (S - T); closedin (top_of_set S) T; openin (top_of_set S) T⟧ ⟹ closedin (top_of_set (T ∪ (S - T))) (S - T)› 3. ‹⟦(S::'a set) = (T::'a set) ∪ (S - T); closedin (top_of_set S) T; openin (top_of_set S) T⟧ ⟹ continuous_on T (f::'a ⇒ 'b)› 4. ‹⟦(S::'a set) = (T::'a set) ∪ (S - T); closedin (top_of_set S) T; openin (top_of_set S) T⟧ ⟹ continuous_on (S - T) (λx::'a. a::'b)› 5. ‹⋀x::'a. ⟦(S::'a set) = (T::'a set) ∪ (S - T); closedin (top_of_set S) T; openin (top_of_set S) T; x ∈ T ∧ x ∉ T ∨ x ∈ S - T ∧ x ∈ T⟧ ⟹ (f::'a ⇒ 'b) x = (a::'b)› discuss goal 1*) apply ((auto simp: contf (*‹continuous_on T f›*))[1]) (*discuss goal 2*) apply ((auto simp: contf (*‹continuous_on T f›*))[1]) (*discuss goal 3*) apply ((auto simp: contf (*‹continuous_on T f›*))[1]) (*discuss goal 4*) apply ((auto simp: contf (*‹continuous_on T f›*))[1]) (*discuss goal 5*) apply ((auto simp: contf (*‹continuous_on T f›*))[1]) (*proven 5 subgoals*) . with Seq (*‹S = T ∪ (S - T)›*) show "continuous_on S ?g" by metis show "?g ` S ⊆ U" using ‹a ∈ U› (*‹a ∈ U›*) fim (*‹f ` T ⊆ U›*) by auto show "⋀x. x ∈ T ⟹ ?g x = f x" by auto qed qed lemma extension_from_component: fixes f :: "'a :: euclidean_space ⇒ 'b :: euclidean_space" assumes S: "locally connected S ∨ compact S" and "ANR U" and C: "C ∈ components S" and contf: "continuous_on C f" and fim: "f ∈ C → U" obtains g where "continuous_on S g" "g ∈ S → U" "⋀x. x ∈ C ⟹ g x = f x" proof (-) (*goal: ‹(⋀g. ⟦continuous_on S g; g ∈ S → U; ⋀x. x ∈ C ⟹ g x = f x⟧ ⟹ thesis) ⟹ thesis›*) obtain T and g where ope: "openin (top_of_set S) T" and clo: "closedin (top_of_set S) T" and "C ⊆ T" and contg: "continuous_on T g" and gim: "g ∈ T → U" and gf: "⋀x. x ∈ C ⟹ g x = f x" (*goal: ‹(⋀T g. ⟦openin (top_of_set S) T; closedin (top_of_set S) T; C ⊆ T; continuous_on T g; g ∈ T → U; ⋀x. x ∈ C ⟹ g x = f x⟧ ⟹ thesis) ⟹ thesis›*) using S (*‹locally connected S ∨ compact S›*) proof (standard) (*goals: 1. ‹⟦⋀T g. ⟦openin (top_of_set S) T; closedin (top_of_set S) T; C ⊆ T; continuous_on T g; g ∈ T → U; ⋀x. x ∈ C ⟹ g x = f x⟧ ⟹ thesis; locally connected S⟧ ⟹ thesis› 2. ‹⟦⋀T g. ⟦openin (top_of_set S) T; closedin (top_of_set S) T; C ⊆ T; continuous_on T g; g ∈ T → U; ⋀x. x ∈ C ⟹ g x = f x⟧ ⟹ thesis; compact S⟧ ⟹ thesis›*) assume "locally connected S" (*‹locally connected (S::'a set)›*) show "?thesis" (*goal: ‹thesis›*) by (metis C (*‹C ∈ components S›*) ‹locally connected S› openin_components_locally_connected (*‹⟦locally connected ?S; ?c ∈ components ?S⟧ ⟹ openin (top_of_set ?S) ?c›*) closedin_component (*‹?C ∈ components ?S ⟹ closedin (top_of_set ?S) ?C›*) contf (*‹continuous_on C f›*) fim (*‹f ∈ C → U›*) order_refl (*‹?x ≤ ?x›*) that (*‹⟦openin (top_of_set S) ?T; closedin (top_of_set S) ?T; C ⊆ ?T; continuous_on ?T ?g; ?g ∈ ?T → U; ⋀x. x ∈ C ⟹ ?g x = f x⟧ ⟹ thesis›*)) next (*goal: ‹⟦⋀T g. ⟦openin (top_of_set S) T; closedin (top_of_set S) T; C ⊆ T; continuous_on T g; g ∈ T → U; ⋀x. x ∈ C ⟹ g x = f x⟧ ⟹ thesis; compact S⟧ ⟹ thesis›*) assume "compact S" (*‹compact (S::'a set)›*) then obtain W and g where "C ⊆ W" and opeW: "openin (top_of_set S) W" and contg: "continuous_on W g" and gim: "g ∈ W → U" and gf: "⋀x. x ∈ C ⟹ g x = f x" (*goal: ‹(⋀W g. ⟦C ⊆ W; openin (top_of_set S) W; continuous_on W g; g ∈ W → U; ⋀x. x ∈ C ⟹ g x = f x⟧ ⟹ thesis) ⟹ thesis›*) using ANR_imp_absolute_neighbourhood_extensor[of U C f S] (*‹⟦ANR (U::'b set); continuous_on (C::'a set) (f::'a ⇒ 'b); f ∈ C → U; closedin (top_of_set (S::'a set)) C; ⋀(V::'a set) g::'a ⇒ 'b. ⟦C ⊆ V; openin (top_of_set S) V; continuous_on V g; g ∈ V → U; ⋀x::'a. x ∈ C ⟹ g x = f x⟧ ⟹ ?thesis::bool⟧ ⟹ ?thesis›*) C (*‹C ∈ components S›*) ‹ANR U› (*‹ANR U›*) closedin_component (*‹?C ∈ components ?S ⟹ closedin (top_of_set ?S) ?C›*) contf (*‹continuous_on C f›*) fim (*‹f ∈ C → U›*) by blast then obtain V where "open V" and V: "W = S ∩ V" (*goal: ‹(⋀V::'a set. ⟦open V; (W::'a set) = (S::'a set) ∩ V⟧ ⟹ thesis::bool) ⟹ thesis›*) by (auto simp: openin_open (*‹openin (top_of_set ?U) ?S = (∃T. open T ∧ ?S = ?U ∩ T)›*)) moreover have "locally compact S" by (simp add: ‹compact S› closed_imp_locally_compact (*‹closed ?S ⟹ locally compact ?S›*) compact_imp_closed (*‹compact ?s ⟹ closed ?s›*)) ultimately obtain K where opeK: "openin (top_of_set S) K" and "compact K" "C ⊆ K" "K ⊆ V" (*goal: ‹(⋀K::'a set. ⟦openin (top_of_set (S::'a set)) K; compact K; (C::'a set) ⊆ K; K ⊆ (V::'a set)⟧ ⟹ thesis::bool) ⟹ thesis›*) by (metis C (*‹C ∈ components S›*) Int_subset_iff (*‹(?C ⊆ ?A ∩ ?B) = (?C ⊆ ?A ∧ ?C ⊆ ?B)›*) ‹C ⊆ W› ‹compact S› compact_components (*‹⟦compact ?s; ?c ∈ components ?s⟧ ⟹ compact ?c›*) Sura_Bura_clopen_subset (*‹⟦locally compact ?S; ?C ∈ components ?S; compact ?C; open ?U; ?C ⊆ ?U; ⋀K. ⟦openin (top_of_set ?S) K; compact K; ?C ⊆ K; K ⊆ ?U⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*)) show "?thesis" (*goal: ‹thesis›*) proof (standard) (*goals: 1. ‹openin (top_of_set S) ?T› 2. ‹closedin (top_of_set S) ?T› 3. ‹C ⊆ ?T› 4. ‹continuous_on ?T ?g› 5. ‹?g ∈ ?T → U› 6. ‹⋀x. x ∈ C ⟹ ?g x = f x›*) show "closedin (top_of_set S) K" by (meson ‹compact K› ‹compact S› closedin_compact_eq (*‹compact ?S ⟹ closedin (top_of_set ?S) ?T = (compact ?T ∧ ?T ⊆ ?S)›*) opeK (*‹openin (top_of_set S) K›*) openin_imp_subset (*‹openin (subtopology ?U ?S) ?T ⟹ ?T ⊆ ?S›*)) show "continuous_on K g" by (metis Int_subset_iff (*‹((?C::?'a set) ⊆ (?A::?'a set) ∩ (?B::?'a set)) = (?C ⊆ ?A ∧ ?C ⊆ ?B)›*) V (*‹(W::'a set) = (S::'a set) ∩ (V::'a set)›*) ‹K ⊆ V› contg (*‹continuous_on (W::'a set) (g::'a ⇒ 'b)›*) continuous_on_subset (*‹⟦continuous_on (?s::?'a set) (?f::?'a ⇒ ?'b); (?t::?'a set) ⊆ ?s⟧ ⟹ continuous_on ?t ?f›*) opeK (*‹openin (top_of_set (S::'a set)) (K::'a set)›*) openin_subtopology (*‹openin (subtopology (?U::?'a topology) (?V::?'a set)) (?S::?'a set) = (∃T::?'a set. openin ?U T ∧ ?S = T ∩ ?V)›*) subset_eq (*‹((?A::?'a set) ⊆ (?B::?'a set)) = (∀x::?'a∈?A. x ∈ ?B)›*)) show "g ∈ K → U" using V (*‹W = S ∩ V›*) ‹K ⊆ V› (*‹K ⊆ V›*) gim (*‹g ∈ W → U›*) opeK (*‹openin (top_of_set S) K›*) openin_imp_subset (*‹openin (subtopology ?U ?S) ?T ⟹ ?T ⊆ ?S›*) by fastforce qed (use opeK gf ‹C ⊆ K› in auto) (*solves the remaining goals: 1. ‹openin (top_of_set S) K› 2. ‹C ⊆ K› 3. ‹⋀x. x ∈ C ⟹ g x = f x›*) qed obtain h where "continuous_on S h" "h ∈ S → U" "⋀x. x ∈ T ⟹ h x = g x" (*goal: ‹(⋀h. ⟦continuous_on S h; h ∈ S → U; ⋀x. x ∈ T ⟹ h x = g x⟧ ⟹ thesis) ⟹ thesis›*) using extension_from_clopen (*‹⟦openin (top_of_set (?S::?'a set)) (?T::?'a set); closedin (top_of_set ?S) ?T; continuous_on ?T (?f::?'a ⇒ ?'b); ?f ` ?T ⊆ (?U::?'b set); ?U = {} ⟹ ?S = {}; ⋀g::?'a ⇒ ?'b. ⟦continuous_on ?S g; g ` ?S ⊆ ?U; ⋀x::?'a. x ∈ ?T ⟹ g x = ?f x⟧ ⟹ ?thesis::bool⟧ ⟹ ?thesis›*) by (metis C (*‹C ∈ components S›*) bot.extremum_uniqueI (*‹?a ≤ bot ⟹ ?a = bot›*) clo (*‹closedin (top_of_set S) T›*) contg (*‹continuous_on T g›*) gim (*‹g ∈ T → U›*) fim (*‹f ∈ C → U›*) image_is_empty (*‹(?f ` ?A = {}) = (?A = {})›*) in_components_nonempty (*‹?C ∈ components ?S ⟹ ?C ≠ {}›*) ope (*‹openin (top_of_set S) T›*) image_subset_iff_funcset (*‹(?F ` ?A ⊆ ?B) = (?F ∈ ?A → ?B)›*)) then show "?thesis" (*goal: ‹thesis›*) by (metis ‹C ⊆ T› gf (*‹?x ∈ C ⟹ g ?x = f ?x›*) subset_eq (*‹(?A ⊆ ?B) = (∀x∈?A. x ∈ ?B)›*) that (*‹⟦continuous_on S ?g; ?g ∈ S → U; ⋀x. x ∈ C ⟹ ?g x = f x⟧ ⟹ thesis›*)) qed lemma tube_lemma: fixes S :: "'a::euclidean_space set" and T :: "'b::euclidean_space set" assumes "compact S" and S: "S ≠ {}" "(λx. (x,a)) ` S ⊆ U" and ope: "openin (top_of_set (S × T)) U" obtains V where "openin (top_of_set T) V" "a ∈ V" "S × V ⊆ U" proof (-) (*goal: ‹(⋀V. ⟦openin (top_of_set T) V; a ∈ V; S × V ⊆ U⟧ ⟹ thesis) ⟹ thesis›*) let ?W = "{y. ∃x. x ∈ S ∧ (x, y) ∈ (S × T - U)}" have "U ⊆ S × T" "closedin (top_of_set (S × T)) (S × T - U)" using ope (*‹openin (top_of_set ((S::'a set) × (T::'b set))) (U::('a × 'b) set)›*) apply - (*goals: 1. ‹openin (top_of_set (S × T)) U ⟹ U ⊆ S × T› 2. ‹openin (top_of_set (S × T)) U ⟹ closedin (top_of_set (S × T)) (S × T - U)› discuss goal 1*) apply ((auto simp: openin_closedin_eq (*‹openin ?U ?S = (?S ⊆ topspace ?U ∧ closedin ?U (topspace ?U - ?S))›*))[1]) (*discuss goal 2*) apply ((auto simp: openin_closedin_eq (*‹openin (?U::?'a topology) (?S::?'a set) = (?S ⊆ topspace ?U ∧ closedin ?U (topspace ?U - ?S))›*))[1]) (*proven 2 subgoals*) . then have "closedin (top_of_set T) ?W" using ‹compact S› (*‹compact S›*) closedin_compact_projection (*‹⟦compact ?S; closedin (top_of_set (?S × ?T)) ?U⟧ ⟹ closedin (top_of_set ?T) {y. ∃x. x ∈ ?S ∧ (x, y) ∈ ?U}›*) by blast moreover have "a ∈ T - ?W" using ‹U ⊆ S × T› (*‹U ⊆ S × T›*) S (*‹S ≠ {}› ‹(λx. (x, a)) ` S ⊆ U›*) by auto moreover have "S × (T - ?W) ⊆ U" by auto ultimately show "?thesis" (*goal: ‹thesis::bool›*) by (metis (no_types, lifting) Sigma_cong (*‹⟦?A = ?B; ⋀x. x ∈ ?B ⟹ ?C x = ?D x⟧ ⟹ Sigma ?A ?C = Sigma ?B ?D›*) closedin_def (*‹closedin ?U ?S = (?S ⊆ topspace ?U ∧ openin ?U (topspace ?U - ?S))›*) that (*‹⟦openin (top_of_set T) ?V; a ∈ ?V; S × ?V ⊆ U⟧ ⟹ thesis›*) topspace_euclidean_subtopology (*‹topspace (top_of_set ?S) = ?S›*)) qed lemma tube_lemma_gen: fixes S :: "'a::euclidean_space set" and T :: "'b::euclidean_space set" assumes "compact S" "S ≠ {}" "T ⊆ T'" "S × T ⊆ U" and ope: "openin (top_of_set (S × T')) U" obtains V where "openin (top_of_set T') V" "T ⊆ V" "S × V ⊆ U" proof (-) (*goal: ‹(⋀V. ⟦openin (top_of_set T') V; T ⊆ V; S × V ⊆ U⟧ ⟹ thesis) ⟹ thesis›*) have "⋀x. x ∈ T ⟹ ∃V. openin (top_of_set T') V ∧ x ∈ V ∧ S × V ⊆ U" using assms (*‹compact S› ‹S ≠ {}› ‹T ⊆ T'› ‹S × T ⊆ U› ‹openin (top_of_set (S × T')) U›*) by (auto intro: tube_lemma [OF ‹compact S›] (*‹⟦S ≠ {}; (λx. (x, ?a)) ` S ⊆ ?U; openin (top_of_set (S × ?T)) ?U; ⋀V. ⟦openin (top_of_set ?T) V; ?a ∈ V; S × V ⊆ ?U⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*)) then obtain F where F: "⋀x. x ∈ T ⟹ openin (top_of_set T') (F x) ∧ x ∈ F x ∧ S × F x ⊆ U" (*goal: ‹(⋀F. (⋀x. x ∈ T ⟹ openin (top_of_set T') (F x) ∧ x ∈ F x ∧ S × F x ⊆ U) ⟹ thesis) ⟹ thesis›*) by metis show "?thesis" (*goal: ‹thesis›*) proof (standard) (*goals: 1. ‹openin (top_of_set T') ?V› 2. ‹T ⊆ ?V› 3. ‹S × ?V ⊆ U›*) show "openin (top_of_set T') (⋃(F ` T))" using F (*‹?x ∈ T ⟹ openin (top_of_set T') (F ?x) ∧ ?x ∈ F ?x ∧ S × F ?x ⊆ U›*) by blast show "T ⊆ ⋃(F ` T)" using F (*‹?x ∈ T ⟹ openin (top_of_set T') (F ?x) ∧ ?x ∈ F ?x ∧ S × F ?x ⊆ U›*) by blast show "S × ⋃(F ` T) ⊆ U" using F (*‹?x ∈ T ⟹ openin (top_of_set T') (F ?x) ∧ ?x ∈ F ?x ∧ S × F ?x ⊆ U›*) by auto qed qed proposition✐‹tag unimportant› homotopic_neighbourhood_extension: fixes f :: "'a::euclidean_space ⇒ 'b::euclidean_space" assumes contf: "continuous_on S f" and fim: "f ` S ⊆ U" and contg: "continuous_on S g" and gim: "g ` S ⊆ U" and clo: "closedin (top_of_set S) T" and "ANR U" and hom: "homotopic_with_canon (λx. True) T U f g" obtains V where "T ⊆ V" "openin (top_of_set S) V" "homotopic_with_canon (λx. True) V U f g" proof (-) (*goal: ‹(⋀V. ⟦T ⊆ V; openin (top_of_set S) V; homotopic_with_canon (λx. True) V U f g⟧ ⟹ thesis) ⟹ thesis›*) have "T ⊆ S" using clo (*‹closedin (top_of_set (S::'a set)) (T::'a set)›*) closedin_imp_subset (*‹closedin (subtopology ?U ?S) ?T ⟹ ?T ⊆ ?S›*) by blast obtain h where conth: "continuous_on ({0..1::real} × T) h" and him: "h ` ({0..1} × T) ⊆ U" and h0: "⋀x. h(0, x) = f x" and h1: "⋀x. h(1, x) = g x" (*goal: ‹(⋀h::real × 'a ⇒ 'b. ⟦continuous_on ({0::real..1::real} × (T::'a set)) h; h ` ({0::real..1::real} × T) ⊆ (U::'b set); ⋀x::'a. h (0::real, x) = (f::'a ⇒ 'b) x; ⋀x::'a. h (1::real, x) = (g::'a ⇒ 'b) x⟧ ⟹ thesis::bool) ⟹ thesis›*) using hom (*‹homotopic_with_canon (λx::'a ⇒ 'b. True) (T::'a set) (U::'b set) (f::'a ⇒ 'b) (g::'a ⇒ 'b)›*) by (auto simp: homotopic_with_def (*‹homotopic_with ?P ?X ?Y ?f ?g ≡ ∃h. continuous_map (prod_topology (top_of_set {0..1}) ?X) ?Y h ∧ (∀x. h (0, x) = ?f x) ∧ (∀x. h (1, x) = ?g x) ∧ (∀t∈{0..1}. ?P (λx. h (t, x)))›*)) define h' where "h' ≡ λz. if fst z ∈ {0} then f(snd z) else if fst z ∈ {1} then g(snd z) else h z" let ?S0 = "{0::real} × S" and ?S1 = "{1::real} × S" have "continuous_on(?S0 ∪ (?S1 ∪ {0..1} × T)) h'" unfolding h'_def (*goal: ‹continuous_on ({0} × S ∪ ({1} × S ∪ {0..1} × T)) (λz. if fst z ∈ {0} then f (snd z) else if fst z ∈ {1} then g (snd z) else h z)›*) proof (intro continuous_on_cases_local (*‹⟦closedin (top_of_set ((?S::?'a::topological_space set) ∪ (?T::?'a::topological_space set))) ?S; closedin (top_of_set (?S ∪ ?T)) ?T; continuous_on ?S (?f::?'a::topological_space ⇒ ?'b::topological_space); continuous_on ?T (?g::?'a::topological_space ⇒ ?'b::topological_space); ⋀x::?'a::topological_space. x ∈ ?S ∧ ¬ (?P::?'a::topological_space ⇒ bool) x ∨ x ∈ ?T ∧ ?P x ⟹ ?f x = ?g x⟧ ⟹ continuous_on (?S ∪ ?T) (λx::?'a::topological_space. if ?P x then ?f x else ?g x)›*)) (*goals: 1. ‹closedin (top_of_set ({0} × S ∪ ({1} × S ∪ {0..1} × T))) ({0} × S)› 2. ‹closedin (top_of_set ({0} × S ∪ ({1} × S ∪ {0..1} × T))) ({1} × S ∪ {0..1} × T)› 3. ‹continuous_on ({0} × S) (λx. f (snd x))› 4. ‹closedin (top_of_set ({1} × S ∪ {0..1} × T)) ({1} × S)› 5. ‹closedin (top_of_set ({1} × S ∪ {0..1} × T)) ({0..1} × T)› 6. ‹continuous_on ({1} × S) (λx. g (snd x))› 7. ‹continuous_on ({0..1} × T) h› 8. ‹⋀x. x ∈ {1} × S ∧ fst x ∉ {1} ∨ x ∈ {0..1} × T ∧ fst x ∈ {1} ⟹ g (snd x) = h x› 9. ‹⋀z. z ∈ {0} × S ∧ fst z ∉ {0} ∨ z ∈ {1} × S ∪ {0..1} × T ∧ fst z ∈ {0} ⟹ f (snd z) = (if fst z ∈ {1} then g (snd z) else h z)›*) show "closedin (top_of_set (?S0 ∪ (?S1 ∪ {0..1} × T))) ?S0" "closedin (top_of_set (?S1 ∪ {0..1} × T)) ?S1" using ‹T ⊆ S› (*‹T ⊆ S›*) apply - (*goals: 1. ‹T ⊆ S ⟹ closedin (top_of_set ({0} × S ∪ ({1} × S ∪ {0..1} × T))) ({0} × S)› 2. ‹T ⊆ S ⟹ closedin (top_of_set ({1} × S ∪ {0..1} × T)) ({1} × S)› discuss goal 1*) apply (force intro: closedin_Times (*‹⟦closedin (top_of_set ?S) ?S'; closedin (top_of_set ?T) ?T'⟧ ⟹ closedin (top_of_set (?S × ?T)) (?S' × ?T')›*) closedin_subset_trans [of "{0..1} × S"] (*‹⟦closedin (top_of_set ({0..1} × S)) ?S; ?S ⊆ ?T; ?T ⊆ {0..1} × S⟧ ⟹ closedin (top_of_set ?T) ?S›*)) (*discuss goal 2*) apply (force intro: closedin_Times (*‹⟦closedin (top_of_set ?S) ?S'; closedin (top_of_set ?T) ?T'⟧ ⟹ closedin (top_of_set (?S × ?T)) (?S' × ?T')›*) closedin_subset_trans [of "{0..1} × S"] (*‹⟦closedin (top_of_set ({0..1} × S)) ?S; ?S ⊆ ?T; ?T ⊆ {0..1} × S⟧ ⟹ closedin (top_of_set ?T) ?S›*)) (*proven 2 subgoals*) . show "closedin (top_of_set (?S0 ∪ (?S1 ∪ {0..1} × T))) (?S1 ∪ {0..1} × T)" "closedin (top_of_set (?S1 ∪ {0..1} × T)) ({0..1} × T)" using ‹T ⊆ S› (*‹T ⊆ S›*) apply - (*goals: 1. ‹T ⊆ S ⟹ closedin (top_of_set ({0} × S ∪ ({1} × S ∪ {0..1} × T))) ({1} × S ∪ {0..1} × T)› 2. ‹T ⊆ S ⟹ closedin (top_of_set ({1} × S ∪ {0..1} × T)) ({0..1} × T)› discuss goal 1*) apply (force intro: clo (*‹closedin (top_of_set S) T›*) closedin_Times (*‹⟦closedin (top_of_set ?S) ?S'; closedin (top_of_set ?T) ?T'⟧ ⟹ closedin (top_of_set (?S × ?T)) (?S' × ?T')›*) closedin_subset_trans [of "{0..1} × S"] (*‹⟦closedin (top_of_set ({0..1} × S)) ?S; ?S ⊆ ?T; ?T ⊆ {0..1} × S⟧ ⟹ closedin (top_of_set ?T) ?S›*)) (*discuss goal 2*) apply (force intro: clo (*‹closedin (top_of_set S) T›*) closedin_Times (*‹⟦closedin (top_of_set ?S) ?S'; closedin (top_of_set ?T) ?T'⟧ ⟹ closedin (top_of_set (?S × ?T)) (?S' × ?T')›*) closedin_subset_trans [of "{0..1} × S"] (*‹⟦closedin (top_of_set ({0..1} × S)) ?S; ?S ⊆ ?T; ?T ⊆ {0..1} × S⟧ ⟹ closedin (top_of_set ?T) ?S›*)) (*proven 2 subgoals*) . show "continuous_on (?S0) (λx. f (snd x))" apply (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 227 facts*) continuous_on_compose2 [OF contf] (*‹⟦continuous_on ?s ?f; ?f ` ?s ⊆ S⟧ ⟹ continuous_on ?s (λx. f (?f x))›*)) (*goal: ‹continuous_on ({0} × S) (λx. f (snd x))›*) by auto show "continuous_on (?S1) (λx. g (snd x))" apply (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 227 facts*) continuous_on_compose2 [OF contg] (*‹⟦continuous_on ?s ?f; ?f ` ?s ⊆ S⟧ ⟹ continuous_on ?s (λx. g (?f x))›*)) (*goal: ‹continuous_on ({1} × S) (λx. g (snd x))›*) by auto qed (use h0 h1 conth in auto) (*solves the remaining goals: 1. ‹continuous_on ({0..1} × T) h› 2. ‹⋀x. x ∈ {1} × S ∧ fst x ∉ {1} ∨ x ∈ {0..1} × T ∧ fst x ∈ {1} ⟹ g (snd x) = h x› 3. ‹⋀z. z ∈ {0} × S ∧ fst z ∉ {0} ∨ z ∈ {1} × S ∪ {0..1} × T ∧ fst z ∈ {0} ⟹ f (snd z) = (if fst z ∈ {1} then g (snd z) else h z)›*) then have "continuous_on ({0,1} × S ∪ ({0..1} × T)) h'" by (metis Sigma_Un_distrib1 (*‹Sigma ((?I::?'a set) ∪ (?J::?'a set)) (?C::?'a ⇒ ?'b set) = Sigma ?I ?C ∪ Sigma ?J ?C›*) Un_assoc (*‹(?A::?'a set) ∪ (?B::?'a set) ∪ (?C::?'a set) = ?A ∪ (?B ∪ ?C)›*) insert_is_Un (*‹insert (?a::?'a) (?A::?'a set) = {?a} ∪ ?A›*)) moreover have "h' ` ({0,1} × S ∪ {0..1} × T) ⊆ U" using fim (*‹f ` S ⊆ U›*) gim (*‹(g::'a::euclidean_space ⇒ 'b::euclidean_space) ` (S::'a::euclidean_space set) ⊆ (U::'b::euclidean_space set)›*) him (*‹h ` ({0..1} × T) ⊆ U›*) ‹T ⊆ S› (*‹T ⊆ S›*) unfolding h'_def (*goal: ‹(λz. if fst z ∈ {0} then f (snd z) else if fst z ∈ {1} then g (snd z) else h z) ` ({0, 1} × S ∪ {0..1} × T) ⊆ U›*) by force moreover have "closedin (top_of_set ({0..1::real} × S)) ({0,1} × S ∪ {0..1::real} × T)" apply (intro closedin_Times (*‹⟦closedin (top_of_set ?S) ?S'; closedin (top_of_set ?T) ?T'⟧ ⟹ closedin (top_of_set (?S × ?T)) (?S' × ?T')›*) closedin_Un (*‹⟦closedin ?U ?S; closedin ?U ?T⟧ ⟹ closedin ?U (?S ∪ ?T)›*) clo (*‹closedin (top_of_set S) T›*)) (*goals: 1. ‹closedin (top_of_set {0..1}) {0, 1}› 2. ‹closedin (top_of_set S) S› 3. ‹closedin (top_of_set {0..1}) {0..1}› discuss goal 1*) apply (simp add: closed_subset (*‹⟦?S ⊆ ?T; closed ?S⟧ ⟹ closedin (top_of_set ?T) ?S›*)) (*discuss goal 2*) apply (simp add: closed_subset (*‹⟦?S ⊆ ?T; closed ?S⟧ ⟹ closedin (top_of_set ?T) ?S›*)) (*discuss goal 3*) apply (simp add: closed_subset (*‹⟦?S ⊆ ?T; closed ?S⟧ ⟹ closedin (top_of_set ?T) ?S›*)) (*proven 3 subgoals*) . ultimately obtain W and k where W: "({0,1} × S) ∪ ({0..1} × T) ⊆ W" and opeW: "openin (top_of_set ({0..1} × S)) W" and contk: "continuous_on W k" and kim: "k ∈ W → U" and kh': "⋀x. x ∈ ({0,1} × S) ∪ ({0..1} × T) ⟹ k x = h' x" (*goal: ‹(⋀(W::(real × 'a::euclidean_space) set) k::real × 'a::euclidean_space ⇒ 'b::euclidean_space. ⟦{0::real, 1::real} × (S::'a::euclidean_space set) ∪ {0::real..1::real} × (T::'a::euclidean_space set) ⊆ W; openin (top_of_set ({0::real..1::real} × S)) W; continuous_on W k; k ∈ W → (U::'b::euclidean_space set); ⋀x::real × 'a::euclidean_space. x ∈ {0::real, 1::real} × S ∪ {0::real..1::real} × T ⟹ k x = (h'::real × 'a::euclidean_space ⇒ 'b::euclidean_space) x⟧ ⟹ thesis::bool) ⟹ thesis›*) by (metis ANR_imp_absolute_neighbourhood_extensor [OF ‹ANR U›, of "({0,1} × S) ∪ ({0..1} × T)" h' "{0..1} × S"] (*‹⟦continuous_on ({0::real, 1::real} × (S::'a set) ∪ {0::real..1::real} × (T::'a set)) (h'::real × 'a ⇒ 'b); h' ∈ {0::real, 1::real} × S ∪ {0::real..1::real} × T → (U::'b set); closedin (top_of_set ({0::real..1::real} × S)) ({0::real, 1::real} × S ∪ {0::real..1::real} × T); ⋀(V::(real × 'a) set) g::real × 'a ⇒ 'b. ⟦{0::real, 1::real} × S ∪ {0::real..1::real} × T ⊆ V; openin (top_of_set ({0::real..1::real} × S)) V; continuous_on V g; g ∈ V → U; ⋀x::real × 'a. x ∈ {0::real, 1::real} × S ∪ {0::real..1::real} × T ⟹ g x = h' x⟧ ⟹ ?thesis::bool⟧ ⟹ ?thesis›*) image_subset_iff_funcset (*‹((?F::?'b ⇒ ?'a) ` (?A::?'b set) ⊆ (?B::?'a set)) = (?F ∈ ?A → ?B)›*)) obtain T' where opeT': "openin (top_of_set S) T'" and "T ⊆ T'" and TW: "{0..1} × T' ⊆ W" (*goal: ‹(⋀T'. ⟦openin (top_of_set S) T'; T ⊆ T'; {0..1} × T' ⊆ W⟧ ⟹ thesis) ⟹ thesis›*) using tube_lemma_gen[of "{0..1::real}" T S W] (*‹⟦compact {0..1}; {0..1} ≠ {}; T ⊆ S; {0..1} × T ⊆ W; openin (top_of_set ({0..1} × S)) W; ⋀V. ⟦openin (top_of_set S) V; T ⊆ V; {0..1} × V ⊆ W⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*) W (*‹{0::real, 1::real} × (S::'a set) ∪ {0::real..1::real} × (T::'a set) ⊆ (W::(real × 'a) set)›*) ‹T ⊆ S› (*‹T ⊆ S›*) opeW (*‹openin (top_of_set ({0::real..1::real} × (S::'a set))) (W::(real × 'a) set)›*) by auto moreover have "homotopic_with_canon (λx. True) T' U f g" proof (simp add: homotopic_with (*‹(⋀h k. (⋀x. x ∈ topspace ?X ⟹ h x = k x) ⟹ ?P h = ?P k) ⟹ homotopic_with ?P ?X ?Y ?p ?q = (∃h. continuous_map (prod_topology (top_of_set {0..1}) ?X) ?Y h ∧ (∀x∈topspace ?X. h (0, x) = ?p x) ∧ (∀x∈topspace ?X. h (1, x) = ?q x) ∧ (∀t∈{0..1}. ?P (λx. h (t, x))))›*), intro exI (*‹?P ?x ⟹ ∃x. ?P x›*) conjI (*‹⟦?P; ?Q⟧ ⟹ ?P ∧ ?Q›*)) (*goals: 1. ‹continuous_on ({0..1} × T') ?h8› 2. ‹?h8 ` ({0..1} × T') ⊆ U› 3. ‹∀x∈T'. ?h8 (0, x) = f x› 4. ‹∀x∈T'. ?h8 (1, x) = g x›*) show "continuous_on ({0..1} × T') k" using TW (*‹{0..1} × T' ⊆ W›*) continuous_on_subset (*‹⟦continuous_on ?s ?f; ?t ⊆ ?s⟧ ⟹ continuous_on ?t ?f›*) contk (*‹continuous_on W k›*) by auto show "k ` ({0..1} × T') ⊆ U" using TW (*‹{0..1} × T' ⊆ W›*) kim (*‹k ∈ W → U›*) by fastforce have "T' ⊆ S" by (meson opeT' (*‹openin (top_of_set S) T'›*) subsetD (*‹⟦?A ⊆ ?B; ?c ∈ ?A⟧ ⟹ ?c ∈ ?B›*) openin_imp_subset (*‹openin (subtopology ?U ?S) ?T ⟹ ?T ⊆ ?S›*)) then show "∀x∈T'. k (0, x) = f x" "∀x∈T'. k (1, x) = g x" apply - (*goals: 1. ‹(T'::'a set) ⊆ (S::'a set) ⟹ ∀x::'a∈T'. (k::real × 'a ⇒ 'b) (0::real, x) = (f::'a ⇒ 'b) x› 2. ‹(T'::'a set) ⊆ (S::'a set) ⟹ ∀x::'a∈T'. (k::real × 'a ⇒ 'b) (1::real, x) = (g::'a ⇒ 'b) x› discuss goal 1*) apply ((auto simp: kh' (*‹?x ∈ {0, 1} × S ∪ {0..1} × T ⟹ k ?x = h' ?x›*) h'_def (*‹h' ≡ λz. if fst z ∈ {0} then f (snd z) else if fst z ∈ {1} then g (snd z) else h z›*))[1]) (*discuss goal 2*) apply ((auto simp: kh' (*‹?x ∈ {0, 1} × S ∪ {0..1} × T ⟹ k ?x = h' ?x›*) h'_def (*‹h' ≡ λz. if fst z ∈ {0} then f (snd z) else if fst z ∈ {1} then g (snd z) else h z›*))[1]) (*proven 2 subgoals*) . qed ultimately show "?thesis" (*goal: ‹thesis›*) by (blast intro: that (*‹⟦T ⊆ ?V; openin (top_of_set S) ?V; homotopic_with_canon (λx. True) ?V U f g⟧ ⟹ thesis›*)) qed text‹ Homotopy on a union of closed-open sets.› proposition✐‹tag unimportant› homotopic_on_clopen_Union: fixes ℱ :: "'a::euclidean_space set set" assumes "⋀S. S ∈ ℱ ⟹ closedin (top_of_set (⋃ℱ)) S" and "⋀S. S ∈ ℱ ⟹ openin (top_of_set (⋃ℱ)) S" and "⋀S. S ∈ ℱ ⟹ homotopic_with_canon (λx. True) S T f g" shows "homotopic_with_canon (λx. True) (⋃ℱ) T f g" proof (-) (*goal: ‹homotopic_with_canon (λx. True) (⋃ ℱ) T f g›*) obtain 𝒱 where "𝒱 ⊆ ℱ" "countable 𝒱" and eqU: "⋃𝒱 = ⋃ℱ" (*goal: ‹(⋀𝒱::'a set set. ⟦𝒱 ⊆ (ℱ::'a set set); countable 𝒱; ⋃ 𝒱 = ⋃ ℱ⟧ ⟹ thesis::bool) ⟹ thesis›*) using Lindelof_openin (*‹⟦⋀S. S ∈ ?ℱ ⟹ openin (top_of_set ?U) S; ⋀ℱ'. ⟦ℱ' ⊆ ?ℱ; countable ℱ'; ⋃ ℱ' = ⋃ ?ℱ⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*) assms (*‹(?S::'a set) ∈ (ℱ::'a set set) ⟹ closedin (top_of_set (⋃ ℱ)) ?S› ‹?S ∈ ℱ ⟹ openin (top_of_set (⋃ ℱ)) ?S› ‹?S ∈ ℱ ⟹ homotopic_with_canon (λx. True) ?S T f g›*) by blast show "?thesis" (*goal: ‹homotopic_with_canon (λx. True) (⋃ ℱ) T f g›*) proof (cases "𝒱 = {}") (*goals: 1. ‹(𝒱::'a::euclidean_space set set) = {} ⟹ homotopic_with_canon (λx::'a::euclidean_space ⇒ 'b::topological_space. True) (⋃ (ℱ::'a::euclidean_space set set)) (T::'b::topological_space set) (f::'a::euclidean_space ⇒ 'b::topological_space) (g::'a::euclidean_space ⇒ 'b::topological_space)› 2. ‹(𝒱::'a::euclidean_space set set) ≠ {} ⟹ homotopic_with_canon (λx::'a::euclidean_space ⇒ 'b::topological_space. True) (⋃ (ℱ::'a::euclidean_space set set)) (T::'b::topological_space set) (f::'a::euclidean_space ⇒ 'b::topological_space) (g::'a::euclidean_space ⇒ 'b::topological_space)›*) case True (*‹𝒱 = {}›*) then show "?thesis" (*goal: ‹homotopic_with_canon (λx. True) (⋃ ℱ) T f g›*) by (metis Union_empty (*‹⋃ {} = {}›*) eqU (*‹⋃ 𝒱 = ⋃ ℱ›*) homotopic_with_canon_on_empty (*‹homotopic_with_canon (λx. True) {} ?t ?f ?g›*)) next (*goal: ‹𝒱 ≠ {} ⟹ homotopic_with_canon (λx. True) (⋃ ℱ) T f g›*) case False (*‹𝒱 ≠ {}›*) then obtain V :: "nat ⇒ 'a set" where V: "range V = 𝒱" (*goal: ‹(⋀V. range V = 𝒱 ⟹ thesis) ⟹ thesis›*) using range_from_nat_into (*‹⟦?A ≠ {}; countable ?A⟧ ⟹ range (from_nat_into ?A) = ?A›*) ‹countable 𝒱› (*‹countable 𝒱›*) by metis with ‹𝒱 ⊆ ℱ› (*‹𝒱 ⊆ ℱ›*) have clo: "⋀n. closedin (top_of_set (⋃ℱ)) (V n)" and ope: "⋀n. openin (top_of_set (⋃ℱ)) (V n)" and hom: "⋀n. homotopic_with_canon (λx. True) (V n) T f g" using assms (*‹?S ∈ ℱ ⟹ closedin (top_of_set (⋃ ℱ)) ?S› ‹?S ∈ ℱ ⟹ openin (top_of_set (⋃ ℱ)) ?S› ‹?S ∈ ℱ ⟹ homotopic_with_canon (λx. True) ?S T f g›*) apply - (*goals: 1. ‹⋀n. ⟦𝒱 ⊆ ℱ; range V = 𝒱; ⋀S. S ∈ ℱ ⟹ closedin (top_of_set (⋃ ℱ)) S; ⋀S. S ∈ ℱ ⟹ openin (top_of_set (⋃ ℱ)) S; ⋀S. S ∈ ℱ ⟹ homotopic_with_canon (λx. True) S T f g⟧ ⟹ closedin (top_of_set (⋃ ℱ)) (V n)› 2. ‹⋀n. ⟦𝒱 ⊆ ℱ; range V = 𝒱; ⋀S. S ∈ ℱ ⟹ closedin (top_of_set (⋃ ℱ)) S; ⋀S. S ∈ ℱ ⟹ openin (top_of_set (⋃ ℱ)) S; ⋀S. S ∈ ℱ ⟹ homotopic_with_canon (λx. True) S T f g⟧ ⟹ openin (top_of_set (⋃ ℱ)) (V n)› 3. ‹⋀n. ⟦𝒱 ⊆ ℱ; range V = 𝒱; ⋀S. S ∈ ℱ ⟹ closedin (top_of_set (⋃ ℱ)) S; ⋀S. S ∈ ℱ ⟹ openin (top_of_set (⋃ ℱ)) S; ⋀S. S ∈ ℱ ⟹ homotopic_with_canon (λx. True) S T f g⟧ ⟹ homotopic_with_canon (λx. True) (V n) T f g› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*proven 3 subgoals*) . then obtain h where conth: "⋀n. continuous_on ({0..1::real} × V n) (h n)" and him: "⋀n. h n ` ({0..1} × V n) ⊆ T" and h0: "⋀n. ⋀x. x ∈ V n ⟹ h n (0, x) = f x" and h1: "⋀n. ⋀x. x ∈ V n ⟹ h n (1, x) = g x" (*goal: ‹(⋀h. ⟦⋀n. continuous_on ({0..1} × V n) (h n); ⋀n. h n ` ({0..1} × V n) ⊆ T; ⋀n x. x ∈ V n ⟹ h n (0, x) = f x; ⋀n x. x ∈ V n ⟹ h n (1, x) = g x⟧ ⟹ thesis) ⟹ thesis›*) apply (simp add: homotopic_with (*‹(⋀h k. (⋀x. x ∈ topspace ?X ⟹ h x = k x) ⟹ ?P h = ?P k) ⟹ homotopic_with ?P ?X ?Y ?p ?q = (∃h. continuous_map (prod_topology (top_of_set {0..1}) ?X) ?Y h ∧ (∀x∈topspace ?X. h (0, x) = ?p x) ∧ (∀x∈topspace ?X. h (1, x) = ?q x) ∧ (∀t∈{0..1}. ?P (λx. h (t, x))))›*)) (*goal: ‹(⋀h. ⟦⋀n. continuous_on ({0..1} × V n) (h n); ⋀n. h n ` ({0..1} × V n) ⊆ T; ⋀n x. x ∈ V n ⟹ h n (0, x) = f x; ⋀n x. x ∈ V n ⟹ h n (1, x) = g x⟧ ⟹ thesis) ⟹ thesis›*) by metis have wop: "b ∈ V x ⟹ ∃k. b ∈ V k ∧ (∀j<k. b ∉ V j)" for b and x using nat_less_induct[where P = "λi. b ∉ V i"] (*‹(⋀n. ∀m<n. b ∉ V m ⟹ b ∉ V n) ⟹ b ∉ V ?n›*) by meson obtain ζ where cont: "continuous_on ({0..1} × ⋃(V ` UNIV)) ζ" and eq: "⋀x i. ⟦x ∈ {0..1} × ⋃(V ` UNIV) ∩ {0..1} × (V i - (⋃m<i. V m))⟧ ⟹ ζ x = h i x" (*goal: ‹(⋀ζ. ⟦continuous_on ({0..1} × ⋃ (range V)) ζ; ⋀x i. x ∈ {0..1} × ⋃ (range V) ∩ {0..1} × (V i - ⋃ (V ` {..<i})) ⟹ ζ x = h i x⟧ ⟹ thesis) ⟹ thesis›*) proof (rule pasting_lemma_exists (*‹⟦topspace ?X ⊆ ⋃ (?T ` ?I); ⋀i. i ∈ ?I ⟹ openin ?X (?T i); ⋀i. i ∈ ?I ⟹ continuous_map (subtopology ?X (?T i)) ?Y (?f i); ⋀i j x. ⟦i ∈ ?I; j ∈ ?I; x ∈ topspace ?X ∩ ?T i ∩ ?T j⟧ ⟹ ?f i x = ?f j x; ⋀g. ⟦continuous_map ?X ?Y g; ⋀x i. ⟦i ∈ ?I; x ∈ topspace ?X ∩ ?T i⟧ ⟹ g x = ?f i x⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*)) (*goals: 1. ‹(⋀ζ::real × 'a ⇒ 'b. ⟦continuous_on ({0::real..1::real} × ⋃ (range (V::nat ⇒ 'a set))) ζ; ⋀(x::real × 'a) i::nat. x ∈ {0::real..1::real} × ⋃ (range V) ∩ {0::real..1::real} × (V i - ⋃ (V ` {..<i})) ⟹ ζ x = (h::nat ⇒ real × 'a ⇒ 'b) i x⟧ ⟹ thesis::bool) ⟹ topspace (?X2::?'a2 topology) ⊆ ⋃ ((?T2::?'b2 ⇒ ?'a2 set) ` (?I2::?'b2 set))› 2. ‹⋀i::?'b2. ⟦⋀ζ::real × 'a ⇒ 'b. ⟦continuous_on ({0::real..1::real} × ⋃ (range (V::nat ⇒ 'a set))) ζ; ⋀(x::real × 'a) i::nat. x ∈ {0::real..1::real} × ⋃ (range V) ∩ {0::real..1::real} × (V i - ⋃ (V ` {..<i})) ⟹ ζ x = (h::nat ⇒ real × 'a ⇒ 'b) i x⟧ ⟹ thesis::bool; i ∈ (?I2::?'b2 set)⟧ ⟹ openin (?X2::?'a2 topology) ((?T2::?'b2 ⇒ ?'a2 set) i)› 3. ‹⋀i::?'b2. ⟦⋀ζ::real × 'a ⇒ 'b. ⟦continuous_on ({0::real..1::real} × ⋃ (range (V::nat ⇒ 'a set))) ζ; ⋀(x::real × 'a) i::nat. x ∈ {0::real..1::real} × ⋃ (range V) ∩ {0::real..1::real} × (V i - ⋃ (V ` {..<i})) ⟹ ζ x = (h::nat ⇒ real × 'a ⇒ 'b) i x⟧ ⟹ thesis::bool; i ∈ (?I2::?'b2 set)⟧ ⟹ continuous_map (subtopology (?X2::?'a2 topology) ((?T2::?'b2 ⇒ ?'a2 set) i)) (?Y2::?'c2 topology) ((?f2::?'b2 ⇒ ?'a2 ⇒ ?'c2) i)› 4. ‹⋀(i::?'b2) (j::?'b2) x::?'a2. ⟦⋀ζ::real × 'a ⇒ 'b. ⟦continuous_on ({0::real..1::real} × ⋃ (range (V::nat ⇒ 'a set))) ζ; ⋀(x::real × 'a) i::nat. x ∈ {0::real..1::real} × ⋃ (range V) ∩ {0::real..1::real} × (V i - ⋃ (V ` {..<i})) ⟹ ζ x = (h::nat ⇒ real × 'a ⇒ 'b) i x⟧ ⟹ thesis::bool; i ∈ (?I2::?'b2 set); j ∈ ?I2; x ∈ topspace (?X2::?'a2 topology) ∩ (?T2::?'b2 ⇒ ?'a2 set) i ∩ ?T2 j⟧ ⟹ (?f2::?'b2 ⇒ ?'a2 ⇒ ?'c2) i x = ?f2 j x› 5. ‹⋀g::?'a2 ⇒ ?'c2. ⟦⋀ζ::real × 'a ⇒ 'b. ⟦continuous_on ({0::real..1::real} × ⋃ (range (V::nat ⇒ 'a set))) ζ; ⋀(x::real × 'a) i::nat. x ∈ {0::real..1::real} × ⋃ (range V) ∩ {0::real..1::real} × (V i - ⋃ (V ` {..<i})) ⟹ ζ x = (h::nat ⇒ real × 'a ⇒ 'b) i x⟧ ⟹ thesis::bool; continuous_map (?X2::?'a2 topology) (?Y2::?'c2 topology) g; ⋀(x::?'a2) i::?'b2. ⟦i ∈ (?I2::?'b2 set); x ∈ topspace ?X2 ∩ (?T2::?'b2 ⇒ ?'a2 set) i⟧ ⟹ g x = (?f2::?'b2 ⇒ ?'a2 ⇒ ?'c2) i x⟧ ⟹ thesis›*) let ?X = "top_of_set ({0..1::real} × ⋃(range V))" show "topspace ?X ⊆ (⋃i. {0..1::real} × (V i - (⋃m<i. V m)))" by (force simp: Ball_def (*‹Ball ?A ?P = (∀x. x ∈ ?A ⟶ ?P x)›*) dest: wop (*‹?b ∈ V ?x ⟹ ∃k. ?b ∈ V k ∧ (∀j<k. ?b ∉ V j)›*)) show "openin (top_of_set ({0..1} × ⋃(V ` UNIV))) ({0..1::real} × (V i - (⋃m<i. V m)))" for i proof (intro openin_Times (*‹⟦openin (top_of_set ?S) ?S'; openin (top_of_set ?T) ?T'⟧ ⟹ openin (top_of_set (?S × ?T)) (?S' × ?T')›*) openin_subtopology_self (*‹openin (top_of_set ?S) ?S›*) openin_diff (*‹⟦openin ?U ?S; closedin ?U ?T⟧ ⟹ openin ?U (?S - ?T)›*)) (*goals: 1. ‹openin (top_of_set (⋃ (range V))) (V i)› 2. ‹closedin (top_of_set (⋃ (range V))) (⋃ (V ` {..<i}))›*) show "openin (top_of_set (⋃(V ` UNIV))) (V i)" using ope (*‹openin (top_of_set (⋃ ℱ)) (V ?n)›*) V (*‹range V = 𝒱›*) eqU (*‹⋃ (𝒱::'a set set) = ⋃ (ℱ::'a set set)›*) by auto show "closedin (top_of_set (⋃(V ` UNIV))) (⋃m<i. V m)" using V (*‹range V = 𝒱›*) clo (*‹closedin (top_of_set (⋃ ℱ)) (V ?n)›*) eqU (*‹⋃ 𝒱 = ⋃ ℱ›*) by (force intro: closedin_Union (*‹⟦finite ?S; ⋀T. T ∈ ?S ⟹ closedin ?U T⟧ ⟹ closedin ?U (⋃ ?S)›*)) qed show "continuous_map (subtopology ?X ({0..1} × (V i - ⋃ (V ` {..<i})))) euclidean (h i)" for i by (auto simp add: subtopology_subtopology (*‹subtopology (subtopology (?X::?'a topology) (?S::?'a set)) (?T::?'a set) = subtopology ?X (?S ∩ ?T)›*) intro!: continuous_on_subset [OF conth] (*‹(?t::(real × 'a) set) ⊆ {0::real..1::real} × (V::nat ⇒ 'a set) (?n1::nat) ⟹ continuous_on ?t ((h::nat ⇒ real × 'a ⇒ 'b) ?n1)›*)) show "⋀i j x. x ∈ topspace ?X ∩ {0..1} × (V i - (⋃m<i. V m)) ∩ {0..1} × (V j - (⋃m<j. V m)) ⟹ h i x = h j x" apply clarsimp (*goal: ‹⋀i j x. x ∈ topspace (top_of_set ({0..1} × ⋃ (range V))) ∩ {0..1} × (V i - ⋃ (V ` {..<i})) ∩ {0..1} × (V j - ⋃ (V ` {..<j})) ⟹ h i x = h j x›*) by (metis lessThan_iff (*‹(?i ∈ {..<?k}) = (?i < ?k)›*) linorder_neqE_nat (*‹⟦?x ≠ ?y; ?x < ?y ⟹ ?R; ?y < ?x ⟹ ?R⟧ ⟹ ?R›*)) qed (auto) (*solved the remaining goal: ‹⋀g::real × 'a::euclidean_space ⇒ 'b::topological_space. ⟦⋀ζ::real × 'a::euclidean_space ⇒ 'b::topological_space. ⟦continuous_on ({0::real..1::real} × ⋃ (range (V::nat ⇒ 'a::euclidean_space set))) ζ; ⋀(x::real × 'a::euclidean_space) i::nat. x ∈ {0::real..1::real} × ⋃ (range V) ∩ {0::real..1::real} × (V i - ⋃ (V ` {..<i})) ⟹ ζ x = (h::nat ⇒ real × 'a::euclidean_space ⇒ 'b::topological_space) i x⟧ ⟹ thesis::bool; continuous_map (top_of_set ({0::real..1::real} × ⋃ (range V))) euclidean g; ⋀(x::real × 'a::euclidean_space) i::nat. ⟦i ∈ UNIV; x ∈ topspace (top_of_set ({0::real..1::real} × ⋃ (range V))) ∩ {0::real..1::real} × (V i - ⋃ (V ` {..<i}))⟧ ⟹ g x = h i x⟧ ⟹ thesis›*) show "?thesis" (*goal: ‹homotopic_with_canon (λx. True) (⋃ ℱ) T f g›*) proof (simp add: homotopic_with (*‹(⋀h k. (⋀x. x ∈ topspace ?X ⟹ h x = k x) ⟹ ?P h = ?P k) ⟹ homotopic_with ?P ?X ?Y ?p ?q = (∃h. continuous_map (prod_topology (top_of_set {0..1}) ?X) ?Y h ∧ (∀x∈topspace ?X. h (0, x) = ?p x) ∧ (∀x∈topspace ?X. h (1, x) = ?q x) ∧ (∀t∈{0..1}. ?P (λx. h (t, x))))›*) eqU [symmetric] (*‹⋃ ℱ = ⋃ 𝒱›*), intro exI (*‹?P ?x ⟹ ∃x. ?P x›*) conjI (*‹⟦?P; ?Q⟧ ⟹ ?P ∧ ?Q›*) ballI (*‹(⋀x. x ∈ ?A ⟹ ?P x) ⟹ ∀x∈?A. ?P x›*)) (*goals: 1. ‹continuous_on ({0..1} × ⋃ 𝒱) ?h9› 2. ‹?h9 ` ({0..1} × ⋃ 𝒱) ⊆ T› 3. ‹⋀y x. ⟦y ∈ 𝒱; x ∈ y⟧ ⟹ ?h9 (0, x) = f x› 4. ‹⋀y x. ⟦y ∈ 𝒱; x ∈ y⟧ ⟹ ?h9 (1, x) = g x›*) show "continuous_on ({0..1} × ⋃𝒱) ζ" using V (*‹range (V::nat ⇒ 'a set) = (𝒱::'a set set)›*) eqU (*‹⋃ 𝒱 = ⋃ ℱ›*) by (blast intro!: continuous_on_subset [OF cont] (*‹?t ⊆ {0..1} × ⋃ (range V) ⟹ continuous_on ?t ζ›*)) show "ζ` ({0..1} × ⋃𝒱) ⊆ T" proof (clarsimp) (*goal: ‹⋀a b X. ⟦b ∈ X; X ∈ 𝒱; 0 ≤ a; a ≤ 1⟧ ⟹ ζ (a, b) ∈ T›*) fix t :: real and y :: 'a and X :: "'a set" assume "y ∈ X" "X ∈ 𝒱" and t: "0 ≤ t" "t ≤ 1" (*‹(y::'a) ∈ (X::'a set)› ‹(X::'a set) ∈ (𝒱::'a set set)› ‹(0::real) ≤ (t::real)› ‹(t::real) ≤ (1::real)›*) then obtain k where "y ∈ V k" and j: "∀j<k. y ∉ V j" (*goal: ‹(⋀k. ⟦y ∈ V k; ∀j<k. y ∉ V j⟧ ⟹ thesis) ⟹ thesis›*) by (metis image_iff (*‹(?z ∈ ?f ` ?A) = (∃x∈?A. ?z = ?f x)›*) V (*‹range V = 𝒱›*) wop (*‹?b ∈ V ?x ⟹ ∃k. ?b ∈ V k ∧ (∀j<k. ?b ∉ V j)›*)) with him (*‹h ?n ` ({0..1} × V ?n) ⊆ T›*) t (*‹0 ≤ t› ‹t ≤ 1›*) show "ζ(t, y) ∈ T" apply (subst eq (*‹?x ∈ {0..1} × ⋃ (range V) ∩ {0..1} × (V ?i - ⋃ (V ` {..<?i})) ⟹ ζ ?x = h ?i ?x›*)) (*goals: 1. ‹⟦⋀n. h n ` ({0..1} × V n) ⊆ T; 0 ≤ t; t ≤ 1; y ∈ V k; ∀j<k. y ∉ V j⟧ ⟹ (t, y) ∈ {0..1} × ⋃ (range V) ∩ {0..1} × (V ?i6 - ⋃ (V ` {..<?i6}))› 2. ‹⟦⋀n. h n ` ({0..1} × V n) ⊆ T; 0 ≤ t; t ≤ 1; y ∈ V k; ∀j<k. y ∉ V j⟧ ⟹ h ?i6 (t, y) ∈ T› discuss goal 1*) apply force (*discuss goal 2*) apply force (*proven 2 subgoals*) . qed fix X and y assume "X ∈ 𝒱" "y ∈ X" (*‹(X::'a set) ∈ (𝒱::'a set set)› ‹(y::'a) ∈ (X::'a set)›*) then obtain k where "y ∈ V k" and j: "∀j<k. y ∉ V j" (*goal: ‹(⋀k::nat. ⟦(y::'a) ∈ (V::nat ⇒ 'a set) k; ∀j<k. y ∉ V j⟧ ⟹ thesis::bool) ⟹ thesis›*) by (metis image_iff (*‹(?z ∈ ?f ` ?A) = (∃x∈?A. ?z = ?f x)›*) V (*‹range V = 𝒱›*) wop (*‹?b ∈ V ?x ⟹ ∃k. ?b ∈ V k ∧ (∀j<k. ?b ∉ V j)›*)) then show "ζ(0, y) = f y" and "ζ(1, y) = g y" apply - (*goals: 1. ‹⟦y ∈ V k; ∀j<k. y ∉ V j⟧ ⟹ ζ (0, y) = f y› 2. ‹⟦y ∈ V k; ∀j<k. y ∉ V j⟧ ⟹ ζ (1, y) = g y› discuss goal 1*) apply (subst eq [where i=k] (*‹?x ∈ {0..1} × ⋃ (range V) ∩ {0..1} × (V k - ⋃ (V ` {..<k})) ⟹ ζ ?x = h k ?x›*)) (*goals: 1. ‹⟦y ∈ V k; ∀j<k. y ∉ V j⟧ ⟹ (0, y) ∈ {0..1} × ⋃ (range V) ∩ {0..1} × (V k - ⋃ (V ` {..<k}))› 2. ‹⟦y ∈ V k; ∀j<k. y ∉ V j⟧ ⟹ h k (0, y) = f y› discuss goal 1*) apply (force simp: h0 (*‹?x ∈ V ?n ⟹ h ?n (0, ?x) = f ?x›*) h1 (*‹?x ∈ V ?n ⟹ h ?n (1, ?x) = g ?x›*)) (*discuss goal 2*) apply (force simp: h0 (*‹(?x::'a) ∈ (V::nat ⇒ 'a set) (?n::nat) ⟹ (h::nat ⇒ real × 'a ⇒ 'b) ?n (0::real, ?x) = (f::'a ⇒ 'b) ?x›*) h1 (*‹(?x::'a) ∈ (V::nat ⇒ 'a set) (?n::nat) ⟹ (h::nat ⇒ real × 'a ⇒ 'b) ?n (1::real, ?x) = (g::'a ⇒ 'b) ?x›*)) (*proven 2 subgoals*) (*discuss goal 2*) apply (subst eq [where i=k] (*‹?x ∈ {0..1} × ⋃ (range V) ∩ {0..1} × (V k - ⋃ (V ` {..<k})) ⟹ ζ ?x = h k ?x›*)) (*goals: 1. ‹⟦y ∈ V k; ∀j<k. y ∉ V j⟧ ⟹ (1, y) ∈ {0..1} × ⋃ (range V) ∩ {0..1} × (V k - ⋃ (V ` {..<k}))› 2. ‹⟦y ∈ V k; ∀j<k. y ∉ V j⟧ ⟹ h k (1, y) = g y› discuss goal 1*) apply (force simp: h0 (*‹?x ∈ V ?n ⟹ h ?n (0, ?x) = f ?x›*) h1 (*‹?x ∈ V ?n ⟹ h ?n (1, ?x) = g ?x›*)) (*discuss goal 2*) apply (force simp: h0 (*‹?x ∈ V ?n ⟹ h ?n (0, ?x) = f ?x›*) h1 (*‹?x ∈ V ?n ⟹ h ?n (1, ?x) = g ?x›*)) (*proven 2 subgoals*) (*proven 2 subgoals*) . qed qed qed lemma homotopic_on_components_eq: fixes S :: "'a :: euclidean_space set" and T :: "'b :: euclidean_space set" assumes S: "locally connected S ∨ compact S" and "ANR T" shows "homotopic_with_canon (λx. True) S T f g ⟷ (continuous_on S f ∧ f ` S ⊆ T ∧ continuous_on S g ∧ g ` S ⊆ T) ∧ (∀C ∈ components S. homotopic_with_canon (λx. True) C T f g)" (is "?lhs ⟷ ?C ∧ ?rhs") proof (-) (*goal: ‹homotopic_with_canon (λx. True) S T f g = ((continuous_on S f ∧ f ` S ⊆ T ∧ continuous_on S g ∧ g ` S ⊆ T) ∧ (∀C∈components S. homotopic_with_canon (λx. True) C T f g))›*) have "continuous_on S f" "f ` S ⊆ T" "continuous_on S g" "g ` S ⊆ T" if "?lhs" using homotopic_with_imp_continuous (*‹homotopic_with_canon ?P ?X ?Y ?f ?g ⟹ continuous_on ?X ?f ∧ continuous_on ?X ?g›*) homotopic_with_imp_subset1 (*‹homotopic_with_canon (?P::(?'a::topological_space ⇒ ?'b::topological_space) ⇒ bool) (?X::?'a::topological_space set) (?Y::?'b::topological_space set) (?f::?'a::topological_space ⇒ ?'b::topological_space) (?g::?'a::topological_space ⇒ ?'b::topological_space) ⟹ ?f ` ?X ⊆ ?Y›*) homotopic_with_imp_subset2 (*‹homotopic_with_canon ?P ?X ?Y ?f ?g ⟹ ?g ` ?X ⊆ ?Y›*) that (*‹homotopic_with_canon (λx. True) S T f g›*) apply - (*goals: 1. ‹⟦⋀(P::(?'a21 ⇒ ?'b21) ⇒ bool) (X::?'a21 set) (Y::?'b21 set) (f::?'a21 ⇒ ?'b21) g::?'a21 ⇒ ?'b21. homotopic_with_canon P X Y f g ⟹ continuous_on X f ∧ continuous_on X g; ⋀(P::(?'a23 ⇒ ?'b23) ⇒ bool) (X::?'a23 set) (Y::?'b23 set) (f::?'a23 ⇒ ?'b23) g::?'a23 ⇒ ?'b23. homotopic_with_canon P X Y f g ⟹ f ` X ⊆ Y; ⋀(P::(?'a25 ⇒ ?'b25) ⇒ bool) (X::?'a25 set) (Y::?'b25 set) (f::?'a25 ⇒ ?'b25) g::?'a25 ⇒ ?'b25. homotopic_with_canon P X Y f g ⟹ g ` X ⊆ Y; homotopic_with_canon (λx::'a ⇒ 'b. True) (S::'a set) (T::'b set) (f::'a ⇒ 'b) (g::'a ⇒ 'b)⟧ ⟹ continuous_on S f› 2. ‹⟦⋀(P::(?'a14 ⇒ ?'b14) ⇒ bool) (X::?'a14 set) (Y::?'b14 set) (f::?'a14 ⇒ ?'b14) g::?'a14 ⇒ ?'b14. homotopic_with_canon P X Y f g ⟹ continuous_on X f ∧ continuous_on X g; ⋀(P::(?'a16 ⇒ ?'b16) ⇒ bool) (X::?'a16 set) (Y::?'b16 set) (f::?'a16 ⇒ ?'b16) g::?'a16 ⇒ ?'b16. homotopic_with_canon P X Y f g ⟹ f ` X ⊆ Y; ⋀(P::(?'a18 ⇒ ?'b18) ⇒ bool) (X::?'a18 set) (Y::?'b18 set) (f::?'a18 ⇒ ?'b18) g::?'a18 ⇒ ?'b18. homotopic_with_canon P X Y f g ⟹ g ` X ⊆ Y; homotopic_with_canon (λx::'a ⇒ 'b. True) (S::'a set) (T::'b set) (f::'a ⇒ 'b) (g::'a ⇒ 'b)⟧ ⟹ f ` S ⊆ T› 3. ‹⟦⋀(P::(?'a7 ⇒ ?'b7) ⇒ bool) (X::?'a7 set) (Y::?'b7 set) (f::?'a7 ⇒ ?'b7) g::?'a7 ⇒ ?'b7. homotopic_with_canon P X Y f g ⟹ continuous_on X f ∧ continuous_on X g; ⋀(P::(?'a9 ⇒ ?'b9) ⇒ bool) (X::?'a9 set) (Y::?'b9 set) (f::?'a9 ⇒ ?'b9) g::?'a9 ⇒ ?'b9. homotopic_with_canon P X Y f g ⟹ f ` X ⊆ Y; ⋀(P::(?'a11 ⇒ ?'b11) ⇒ bool) (X::?'a11 set) (Y::?'b11 set) (f::?'a11 ⇒ ?'b11) g::?'a11 ⇒ ?'b11. homotopic_with_canon P X Y f g ⟹ g ` X ⊆ Y; homotopic_with_canon (λx::'a ⇒ 'b. True) (S::'a set) (T::'b set) (f::'a ⇒ 'b) (g::'a ⇒ 'b)⟧ ⟹ continuous_on S g› 4. ‹⟦⋀(P::(?'a ⇒ ?'b) ⇒ bool) (X::?'a set) (Y::?'b set) (f::?'a ⇒ ?'b) g::?'a ⇒ ?'b. homotopic_with_canon P X Y f g ⟹ continuous_on X f ∧ continuous_on X g; ⋀(P::(?'a2 ⇒ ?'b2) ⇒ bool) (X::?'a2 set) (Y::?'b2 set) (f::?'a2 ⇒ ?'b2) g::?'a2 ⇒ ?'b2. homotopic_with_canon P X Y f g ⟹ f ` X ⊆ Y; ⋀(P::(?'a4 ⇒ ?'b4) ⇒ bool) (X::?'a4 set) (Y::?'b4 set) (f::?'a4 ⇒ ?'b4) g::?'a4 ⇒ ?'b4. homotopic_with_canon P X Y f g ⟹ g ` X ⊆ Y; homotopic_with_canon (λx::'a ⇒ 'b. True) (S::'a set) (T::'b set) (f::'a ⇒ 'b) (g::'a ⇒ 'b)⟧ ⟹ g ` S ⊆ T› discuss goal 1*) apply blast (*discuss goal 2*) apply blast (*discuss goal 3*) apply blast (*discuss goal 4*) apply blast (*proven 4 subgoals*) . moreover have "?lhs ⟷ ?rhs" if contf: "continuous_on S f" and fim: "f ` S ⊆ T" and contg: "continuous_on S g" and gim: "g ` S ⊆ T" proof (standard) (*goals: 1. ‹homotopic_with_canon (λx. True) S T f g ⟹ ∀C∈components S. homotopic_with_canon (λx. True) C T f g› 2. ‹∀C∈components S. homotopic_with_canon (λx. True) C T f g ⟹ homotopic_with_canon (λx. True) S T f g›*) assume "?lhs" (*‹homotopic_with_canon (λx::'a ⇒ 'b. True) (S::'a set) (T::'b set) (f::'a ⇒ 'b) (g::'a ⇒ 'b)›*) with that (*‹continuous_on S f› ‹f ` S ⊆ T› ‹continuous_on S g› ‹g ` S ⊆ T›*) show "?rhs" by (simp add: homotopic_with_subset_left (*‹⟦homotopic_with_canon (?P::(?'a ⇒ ?'b) ⇒ bool) (?X::?'a set) (?Y::?'b set) (?f::?'a ⇒ ?'b) (?g::?'a ⇒ ?'b); (?Z::?'a set) ⊆ ?X⟧ ⟹ homotopic_with_canon ?P ?Z ?Y ?f ?g›*) in_components_subset (*‹(?C::?'a set) ∈ components (?S::?'a set) ⟹ ?C ⊆ ?S›*)) next (*goal: ‹∀C∈components S. homotopic_with_canon (λx. True) C T f g ⟹ homotopic_with_canon (λx. True) S T f g›*) assume R: "?rhs" (*‹∀C::'a set∈components (S::'a set). homotopic_with_canon (λx::'a ⇒ 'b. True) C (T::'b set) (f::'a ⇒ 'b) (g::'a ⇒ 'b)›*) have "∃U. C ⊆ U ∧ closedin (top_of_set S) U ∧ openin (top_of_set S) U ∧ homotopic_with_canon (λx. True) U T f g" if C: "C ∈ components S" for C proof (-) (*goal: ‹∃U. C ⊆ U ∧ closedin (top_of_set S) U ∧ openin (top_of_set S) U ∧ homotopic_with_canon (λx. True) U T f g›*) have "C ⊆ S" by (simp add: in_components_subset (*‹?C ∈ components ?S ⟹ ?C ⊆ ?S›*) that (*‹C ∈ components S›*)) show "?thesis" (*goal: ‹∃U. C ⊆ U ∧ closedin (top_of_set S) U ∧ openin (top_of_set S) U ∧ homotopic_with_canon (λx. True) U T f g›*) using S (*‹locally connected S ∨ compact S›*) proof (standard) (*goals: 1. ‹locally connected (S::'a set) ⟹ ∃U::'a set. (C::'a set) ⊆ U ∧ closedin (top_of_set S) U ∧ openin (top_of_set S) U ∧ homotopic_with_canon (λx::'a ⇒ 'b. True) U (T::'b set) (f::'a ⇒ 'b) (g::'a ⇒ 'b)› 2. ‹compact (S::'a set) ⟹ ∃U::'a set. (C::'a set) ⊆ U ∧ closedin (top_of_set S) U ∧ openin (top_of_set S) U ∧ homotopic_with_canon (λx::'a ⇒ 'b. True) U (T::'b set) (f::'a ⇒ 'b) (g::'a ⇒ 'b)›*) assume "locally connected S" (*‹locally connected (S::'a set)›*) show "?thesis" (*goal: ‹∃U. C ⊆ U ∧ closedin (top_of_set S) U ∧ openin (top_of_set S) U ∧ homotopic_with_canon (λx. True) U T f g›*) proof (intro exI (*‹?P ?x ⟹ ∃x. ?P x›*) conjI (*‹⟦?P; ?Q⟧ ⟹ ?P ∧ ?Q›*)) (*goals: 1. ‹C ⊆ ?U› 2. ‹closedin (top_of_set S) ?U› 3. ‹openin (top_of_set S) ?U› 4. ‹homotopic_with_canon (λx. True) ?U T f g›*) show "closedin (top_of_set S) C" by (simp add: closedin_component (*‹?C ∈ components ?S ⟹ closedin (top_of_set ?S) ?C›*) that (*‹C ∈ components S›*)) show "openin (top_of_set S) C" by (simp add: ‹locally connected S› openin_components_locally_connected (*‹⟦locally connected ?S; ?c ∈ components ?S⟧ ⟹ openin (top_of_set ?S) ?c›*) that (*‹C ∈ components S›*)) show "homotopic_with_canon (λx. True) C T f g" by (simp add: R (*‹∀C∈components S. homotopic_with_canon (λx. True) C T f g›*) that (*‹C ∈ components S›*)) qed (auto) (*solved the remaining goal: ‹C ⊆ C›*) next (*goal: ‹compact (S::'a::euclidean_space set) ⟹ ∃U::'a::euclidean_space set. (C::'a::euclidean_space set) ⊆ U ∧ closedin (top_of_set S) U ∧ openin (top_of_set S) U ∧ homotopic_with_canon (λx::'a::euclidean_space ⇒ 'b::euclidean_space. True) U (T::'b::euclidean_space set) (f::'a::euclidean_space ⇒ 'b::euclidean_space) (g::'a::euclidean_space ⇒ 'b::euclidean_space)›*) assume "compact S" (*‹compact (S::'a set)›*) have hom: "homotopic_with_canon (λx. True) C T f g" using R (*‹∀C::'a set∈components (S::'a set). homotopic_with_canon (λx::'a ⇒ 'b. True) C (T::'b set) (f::'a ⇒ 'b) (g::'a ⇒ 'b)›*) that (*‹C ∈ components S›*) by blast obtain U where "C ⊆ U" and opeU: "openin (top_of_set S) U" and hom: "homotopic_with_canon (λx. True) U T f g" (*goal: ‹(⋀U. ⟦C ⊆ U; openin (top_of_set S) U; homotopic_with_canon (λx. True) U T f g⟧ ⟹ thesis) ⟹ thesis›*) using homotopic_neighbourhood_extension[OF contf fim contg gim _ ‹ANR T› hom] (*‹⟦closedin (top_of_set S) C; ⋀V. ⟦C ⊆ V; openin (top_of_set S) V; homotopic_with_canon (λx. True) V T f g⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*) ‹C ∈ components S› (*‹C ∈ components S›*) closedin_component (*‹?C ∈ components ?S ⟹ closedin (top_of_set ?S) ?C›*) by blast then obtain V where "open V" and V: "U = S ∩ V" (*goal: ‹(⋀V. ⟦open V; U = S ∩ V⟧ ⟹ thesis) ⟹ thesis›*) by (auto simp: openin_open (*‹openin (top_of_set (?U::?'a::topological_space set)) (?S::?'a::topological_space set) = (∃T::?'a::topological_space set. open T ∧ ?S = ?U ∩ T)›*)) moreover have "locally compact S" by (simp add: ‹compact S› closed_imp_locally_compact (*‹closed ?S ⟹ locally compact ?S›*) compact_imp_closed (*‹compact ?s ⟹ closed ?s›*)) ultimately obtain K where opeK: "openin (top_of_set S) K" and "compact K" "C ⊆ K" "K ⊆ V" (*goal: ‹(⋀K. ⟦openin (top_of_set S) K; compact K; C ⊆ K; K ⊆ V⟧ ⟹ thesis) ⟹ thesis›*) by (metis C (*‹C ∈ components S›*) Int_subset_iff (*‹(?C ⊆ ?A ∩ ?B) = (?C ⊆ ?A ∧ ?C ⊆ ?B)›*) Sura_Bura_clopen_subset (*‹⟦locally compact ?S; ?C ∈ components ?S; compact ?C; open ?U; ?C ⊆ ?U; ⋀K. ⟦openin (top_of_set ?S) K; compact K; ?C ⊆ K; K ⊆ ?U⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*) ‹C ⊆ U› ‹compact S› compact_components (*‹⟦compact ?s; ?c ∈ components ?s⟧ ⟹ compact ?c›*)) show "?thesis" (*goal: ‹∃U. C ⊆ U ∧ closedin (top_of_set S) U ∧ openin (top_of_set S) U ∧ homotopic_with_canon (λx. True) U T f g›*) proof (intro exI (*‹(?P::?'a ⇒ bool) (?x::?'a) ⟹ ∃x::?'a. ?P x›*) conjI (*‹⟦?P::bool; ?Q::bool⟧ ⟹ ?P ∧ ?Q›*)) (*goals: 1. ‹C ⊆ ?U› 2. ‹closedin (top_of_set S) ?U› 3. ‹openin (top_of_set S) ?U› 4. ‹homotopic_with_canon (λx. True) ?U T f g›*) show "closedin (top_of_set S) K" by (meson ‹compact K› ‹compact S› closedin_compact_eq (*‹compact ?S ⟹ closedin (top_of_set ?S) ?T = (compact ?T ∧ ?T ⊆ ?S)›*) opeK (*‹openin (top_of_set S) K›*) openin_imp_subset (*‹openin (subtopology ?U ?S) ?T ⟹ ?T ⊆ ?S›*)) show "homotopic_with_canon (λx. True) K T f g" using V (*‹U = S ∩ V›*) ‹K ⊆ V› (*‹(K::'a::euclidean_space set) ⊆ (V::'a::euclidean_space set)›*) hom (*‹homotopic_with_canon (λx. True) U T f g›*) homotopic_with_subset_left (*‹⟦homotopic_with_canon ?P ?X ?Y ?f ?g; ?Z ⊆ ?X⟧ ⟹ homotopic_with_canon ?P ?Z ?Y ?f ?g›*) opeK (*‹openin (top_of_set S) K›*) openin_imp_subset (*‹openin (subtopology ?U ?S) ?T ⟹ ?T ⊆ ?S›*) by fastforce qed (use opeK ‹C ⊆ K› in auto) (*solves the remaining goals: 1. ‹C ⊆ K› 2. ‹openin (top_of_set S) K›*) qed qed then obtain φ where "φ": "⋀C. C ∈ components S ⟹ C ⊆ φ C" and "cloφ": "⋀C. C ∈ components S ⟹ closedin (top_of_set S) (φ C)" and "opeφ": "⋀C. C ∈ components S ⟹ openin (top_of_set S) (φ C)" and "homφ": "⋀C. C ∈ components S ⟹ homotopic_with_canon (λx. True) (φ C) T f g" (*goal: ‹(⋀φ. ⟦⋀C. C ∈ components S ⟹ C ⊆ φ C; ⋀C. C ∈ components S ⟹ closedin (top_of_set S) (φ C); ⋀C. C ∈ components S ⟹ openin (top_of_set S) (φ C); ⋀C. C ∈ components S ⟹ homotopic_with_canon (λx. True) (φ C) T f g⟧ ⟹ thesis) ⟹ thesis›*) by metis have Seq: "S = ⋃ (φ ` components S)" proof (standard) (*goals: 1. ‹S ⊆ ⋃ (φ ` components S)› 2. ‹⋃ (φ ` components S) ⊆ S›*) show "S ⊆ ⋃ (φ ` components S)" by (metis Sup_mono (*‹(⋀a. a ∈ ?A ⟹ ∃b∈?B. a ≤ b) ⟹ Sup ?A ≤ Sup ?B›*) Union_components (*‹⋃ (components ?U) = ?U›*) φ (*‹?C ∈ components S ⟹ ?C ⊆ φ ?C›*) imageI (*‹?x ∈ ?A ⟹ ?f ?x ∈ ?f ` ?A›*)) show "⋃ (φ ` components S) ⊆ S" using "opeφ" (*‹?C ∈ components S ⟹ openin (top_of_set S) (φ ?C)›*) openin_imp_subset (*‹openin (subtopology (?U::?'a topology) (?S::?'a set)) (?T::?'a set) ⟹ ?T ⊆ ?S›*) by fastforce qed show "?lhs" apply (subst Seq (*‹S = ⋃ (φ ` components S)›*)) (*goal: ‹homotopic_with_canon (λx. True) S T f g›*) using Seq (*‹(S::'a::euclidean_space set) = ⋃ ((φ::'a::euclidean_space set ⇒ 'a::euclidean_space set) ` components S)›*) "cloφ" (*‹?C ∈ components S ⟹ closedin (top_of_set S) (φ ?C)›*) "opeφ" (*‹?C ∈ components S ⟹ openin (top_of_set S) (φ ?C)›*) "homφ" (*‹?C ∈ components S ⟹ homotopic_with_canon (λx. True) (φ ?C) T f g›*) apply (intro homotopic_on_clopen_Union (*‹⟦⋀S. S ∈ ?ℱ ⟹ closedin (top_of_set (⋃ ?ℱ)) S; ⋀S. S ∈ ?ℱ ⟹ openin (top_of_set (⋃ ?ℱ)) S; ⋀S. S ∈ ?ℱ ⟹ homotopic_with_canon (λx. True) S ?T ?f ?g⟧ ⟹ homotopic_with_canon (λx. True) (⋃ ?ℱ) ?T ?f ?g›*)) (*goals: 1. ‹⋀Sa. ⟦S = ⋃ (φ ` components S); ⋀C. C ∈ components S ⟹ closedin (top_of_set S) (φ C); ⋀C. C ∈ components S ⟹ openin (top_of_set S) (φ C); ⋀C. C ∈ components S ⟹ homotopic_with_canon (λx. True) (φ C) T f g; Sa ∈ φ ` components S⟧ ⟹ closedin (top_of_set (⋃ (φ ` components S))) Sa› 2. ‹⋀Sa. ⟦S = ⋃ (φ ` components S); ⋀C. C ∈ components S ⟹ closedin (top_of_set S) (φ C); ⋀C. C ∈ components S ⟹ openin (top_of_set S) (φ C); ⋀C. C ∈ components S ⟹ homotopic_with_canon (λx. True) (φ C) T f g; Sa ∈ φ ` components S⟧ ⟹ openin (top_of_set (⋃ (φ ` components S))) Sa› 3. ‹⋀Sa. ⟦S = ⋃ (φ ` components S); ⋀C. C ∈ components S ⟹ closedin (top_of_set S) (φ C); ⋀C. C ∈ components S ⟹ openin (top_of_set S) (φ C); ⋀C. C ∈ components S ⟹ homotopic_with_canon (λx. True) (φ C) T f g; Sa ∈ φ ` components S⟧ ⟹ homotopic_with_canon (λx. True) Sa T f g› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*proven 3 subgoals*) . qed ultimately show "?thesis" (*goal: ‹homotopic_with_canon (λx. True) S T f g = ((continuous_on S f ∧ f ` S ⊆ T ∧ continuous_on S g ∧ g ` S ⊆ T) ∧ (∀C∈components S. homotopic_with_canon (λx. True) C T f g))›*) by blast qed lemma cohomotopically_trivial_on_components: fixes S :: "'a :: euclidean_space set" and T :: "'b :: euclidean_space set" assumes S: "locally connected S ∨ compact S" and "ANR T" shows "(∀f g. continuous_on S f ⟶ f ∈ S → T ⟶ continuous_on S g ⟶ g ∈ S → T ⟶ homotopic_with_canon (λx. True) S T f g) ⟷ (∀C∈components S. ∀f g. continuous_on C f ⟶ f ∈ C → T ⟶ continuous_on C g ⟶ g ∈ C → T ⟶ homotopic_with_canon (λx. True) C T f g)" (is "?lhs = ?rhs") proof (standard) (*goals: 1. ‹∀f g. continuous_on S f ⟶ f ∈ S → T ⟶ continuous_on S g ⟶ g ∈ S → T ⟶ homotopic_with_canon (λx. True) S T f g ⟹ ∀C∈components S. ∀f g. continuous_on C f ⟶ f ∈ C → T ⟶ continuous_on C g ⟶ g ∈ C → T ⟶ homotopic_with_canon (λx. True) C T f g› 2. ‹∀C∈components S. ∀f g. continuous_on C f ⟶ f ∈ C → T ⟶ continuous_on C g ⟶ g ∈ C → T ⟶ homotopic_with_canon (λx. True) C T f g ⟹ ∀f g. continuous_on S f ⟶ f ∈ S → T ⟶ continuous_on S g ⟶ g ∈ S → T ⟶ homotopic_with_canon (λx. True) S T f g›*) assume L[rule_format]: "?lhs" (*‹⟦continuous_on (S::'a set) (?f::'a ⇒ 'b); ?f ∈ S → (T::'b set); continuous_on S (?g::'a ⇒ 'b); ?g ∈ S → T⟧ ⟹ homotopic_with_canon (λx::'a ⇒ 'b. True) S T ?f ?g›*) show "?rhs" proof (clarify) (*goal: ‹⋀C f g. ⟦C ∈ components S; continuous_on C f; f ∈ C → T; continuous_on C g; g ∈ C → T⟧ ⟹ homotopic_with_canon (λx. True) C T f g›*) fix C and f and g assume contf: "continuous_on C f" and fim: "f ∈ C → T" and contg: "continuous_on C g" and gim: "g ∈ C → T" and C: "C ∈ components S" (*‹continuous_on (C::'a set) (f::'a ⇒ 'b)› ‹(f::'a ⇒ 'b) ∈ (C::'a set) → (T::'b set)› ‹continuous_on (C::'a set) (g::'a ⇒ 'b)› ‹(g::'a ⇒ 'b) ∈ (C::'a set) → (T::'b set)› ‹(C::'a set) ∈ components (S::'a set)›*) obtain f' where contf': "continuous_on S f'" and f'im: "f' ∈ S → T" and f'f: "⋀x. x ∈ C ⟹ f' x = f x" (*goal: ‹(⋀f'. ⟦continuous_on S f'; f' ∈ S → T; ⋀x. x ∈ C ⟹ f' x = f x⟧ ⟹ thesis) ⟹ thesis›*) using extension_from_component[OF S ‹ANR T› C contf fim] (*‹(⋀g::'a ⇒ 'b. ⟦continuous_on (S::'a set) g; g ∈ S → (T::'b set); ⋀x::'a. x ∈ (C::'a set) ⟹ g x = (f::'a ⇒ 'b) x⟧ ⟹ ?thesis::bool) ⟹ ?thesis›*) by metis obtain g' where contg': "continuous_on S g'" and g'im: "g' ∈ S → T" and g'g: "⋀x. x ∈ C ⟹ g' x = g x" (*goal: ‹(⋀g'. ⟦continuous_on S g'; g' ∈ S → T; ⋀x. x ∈ C ⟹ g' x = g x⟧ ⟹ thesis) ⟹ thesis›*) using extension_from_component[OF S ‹ANR T› C contg gim] (*‹(⋀ga. ⟦continuous_on S ga; ga ∈ S → T; ⋀x. x ∈ C ⟹ ga x = g x⟧ ⟹ ?thesis) ⟹ ?thesis›*) by metis have "homotopic_with_canon (λx. True) C T f' g'" using L[OF contf' f'im contg' g'im] (*‹homotopic_with_canon (λx. True) S T f' g'›*) homotopic_with_subset_left (*‹⟦homotopic_with_canon ?P ?X ?Y ?f ?g; ?Z ⊆ ?X⟧ ⟹ homotopic_with_canon ?P ?Z ?Y ?f ?g›*) C (*‹(C::'a set) ∈ components (S::'a set)›*) in_components_subset (*‹?C ∈ components ?S ⟹ ?C ⊆ ?S›*) by fastforce then show "homotopic_with_canon (λx. True) C T f g" using f'f (*‹?x ∈ C ⟹ f' ?x = f ?x›*) g'g (*‹?x ∈ C ⟹ g' ?x = g ?x›*) homotopic_with_eq (*‹⟦homotopic_with ?P ?X ?Y ?f ?g; ⋀x. x ∈ topspace ?X ⟹ ?f' x = ?f x; ⋀x. x ∈ topspace ?X ⟹ ?g' x = ?g x; ⋀h k. (⋀x. x ∈ topspace ?X ⟹ h x = k x) ⟹ ?P h = ?P k⟧ ⟹ homotopic_with ?P ?X ?Y ?f' ?g'›*) by force qed next (*goal: ‹∀C∈components S. ∀f g. continuous_on C f ⟶ f ∈ C → T ⟶ continuous_on C g ⟶ g ∈ C → T ⟶ homotopic_with_canon (λx. True) C T f g ⟹ ∀f g. continuous_on S f ⟶ f ∈ S → T ⟶ continuous_on S g ⟶ g ∈ S → T ⟶ homotopic_with_canon (λx. True) S T f g›*) assume R[rule_format]: "?rhs" (*‹⟦(?C::'a set) ∈ components (S::'a set); continuous_on ?C (?f::'a ⇒ 'b); ?f ∈ ?C → (T::'b set); continuous_on ?C (?g::'a ⇒ 'b); ?g ∈ ?C → T⟧ ⟹ homotopic_with_canon (λx::'a ⇒ 'b. True) ?C T ?f ?g›*) show "?lhs" proof (clarify) (*goal: ‹⋀f g. ⟦continuous_on S f; f ∈ S → T; continuous_on S g; g ∈ S → T⟧ ⟹ homotopic_with_canon (λx. True) S T f g›*) fix f and g assume contf: "continuous_on S f" and fim: "f ∈ S → T" and contg: "continuous_on S g" and gim: "g ∈ S → T" (*‹continuous_on (S::'a set) (f::'a ⇒ 'b)› ‹(f::'a ⇒ 'b) ∈ (S::'a set) → (T::'b set)› ‹continuous_on (S::'a set) (g::'a ⇒ 'b)› ‹(g::'a ⇒ 'b) ∈ (S::'a set) → (T::'b set)›*) moreover have "homotopic_with_canon (λx. True) C T f g" if "C ∈ components S" for C using R[OF that] (*‹⟦continuous_on C ?f; ?f ∈ C → T; continuous_on C ?g; ?g ∈ C → T⟧ ⟹ homotopic_with_canon (λx. True) C T ?f ?g›*) contf (*‹continuous_on S f›*) contg (*‹continuous_on S g›*) continuous_on_subset (*‹⟦continuous_on ?s ?f; ?t ⊆ ?s⟧ ⟹ continuous_on ?t ?f›*) fim (*‹f ∈ S → T›*) gim (*‹g ∈ S → T›*) in_components_subset (*‹(?C::?'a set) ∈ components (?S::?'a set) ⟹ ?C ⊆ ?S›*) by (smt (verit, del_insts) Pi_anti_mono (*‹?A' ⊆ ?A ⟹ Pi ?A ?B ⊆ Pi ?A' ?B›*) subsetD (*‹⟦?A ⊆ ?B; ?c ∈ ?A⟧ ⟹ ?c ∈ ?B›*) that (*‹C ∈ components S›*)) ultimately show "homotopic_with_canon (λx. True) S T f g" apply (subst homotopic_on_components_eq [OF S ‹ANR T›] (*‹homotopic_with_canon (λx. True) S T ?f ?g = ((continuous_on S ?f ∧ ?f ` S ⊆ T ∧ continuous_on S ?g ∧ ?g ` S ⊆ T) ∧ (∀C∈components S. homotopic_with_canon (λx. True) C T ?f ?g))›*)) (*goal: ‹homotopic_with_canon (λx. True) S T f g›*) by auto qed qed subsection‹The complement of a set and path-connectedness› text‹Complement in dimension N > 1 of set homeomorphic to any interval in any dimension is (path-)connected. This naively generalizes the argument in Ryuji Maehara's paper "The Jordan curve theorem via the Brouwer fixed point theorem", American Mathematical Monthly 1984.› lemma unbounded_components_complement_absolute_retract: fixes S :: "'a::euclidean_space set" assumes C: "C ∈ components(- S)" and S: "compact S" "AR S" shows "¬ bounded C" proof (-) (*goal: ‹¬ bounded (C::'a set)›*) obtain y where y: "C = connected_component_set (- S) y" and "y ∉ S" (*goal: ‹(⋀y::'a. ⟦(C::'a set) = connected_component_set (- (S::'a set)) y; y ∉ S⟧ ⟹ thesis::bool) ⟹ thesis›*) using C (*‹C ∈ components (- S)›*) by (auto simp: components_def (*‹components (?S::?'a set) ≡ connected_component_set ?S ` ?S›*)) have "open(- S)" using S (*‹compact S› ‹AR S›*) by (simp add: closed_open (*‹closed (?S::?'a::topological_space set) = open (- ?S)›*) compact_eq_bounded_closed (*‹compact (?S::?'a::heine_borel set) = (bounded ?S ∧ closed ?S)›*)) have "S retract_of UNIV" using S (*‹compact S› ‹AR S›*) compact_AR (*‹(compact (?S::?'a::euclidean_space set) ∧ AR ?S) = (compact ?S ∧ ?S retract_of UNIV)›*) by blast then obtain r where contr: "continuous_on UNIV r" and ontor: "range r ⊆ S" and r: "⋀x. x ∈ S ⟹ r x = x" (*goal: ‹(⋀r. ⟦continuous_on UNIV r; range r ⊆ S; ⋀x. x ∈ S ⟹ r x = x⟧ ⟹ thesis) ⟹ thesis›*) by (auto simp: retract_of_def (*‹(?T retract_of ?S) = (∃r. retraction ?S ?T r)›*) retraction_def (*‹retraction ?S ?T ?r = (?T ⊆ ?S ∧ continuous_on ?S ?r ∧ ?r ∈ ?S → ?T ∧ (∀x∈?T. ?r x = x))›*)) show "?thesis" (*goal: ‹¬ bounded C›*) proof (standard) (*goal: ‹bounded (C::'a::euclidean_space set) ⟹ False›*) assume "bounded C" (*‹bounded (C::'a set)›*) have "connected_component_set (- S) y ⊆ S" proof (rule frontier_subset_retraction (*‹⟦bounded ?S; frontier ?S ⊆ ?T; continuous_on (closure ?S) ?f; ?f ∈ ?S → ?T; ⋀x. x ∈ ?T ⟹ ?f x = x⟧ ⟹ ?S ⊆ ?T›*)) (*goals: 1. ‹bounded (connected_component_set (- S) y)› 2. ‹frontier (connected_component_set (- S) y) ⊆ S› 3. ‹continuous_on (closure (connected_component_set (- S) y)) ?f› 4. ‹?f ∈ connected_component_set (- S) y → S› 5. ‹⋀x. x ∈ S ⟹ ?f x = x›*) show "bounded (connected_component_set (- S) y)" using ‹bounded C› (*‹bounded C›*) y (*‹C = connected_component_set (- S) y›*) by blast show "frontier (connected_component_set (- S) y) ⊆ S" using C (*‹C ∈ components (- S)›*) ‹compact S› (*‹compact S›*) compact_eq_bounded_closed (*‹compact ?S = (bounded ?S ∧ closed ?S)›*) frontier_of_components_closed_complement (*‹⟦closed ?S; ?C ∈ components (- ?S)⟧ ⟹ frontier ?C ⊆ ?S›*) y (*‹(C::'a set) = connected_component_set (- (S::'a set)) (y::'a)›*) by blast show "continuous_on (closure (connected_component_set (- S) y)) r" by (blast intro: continuous_on_subset [OF contr] (*‹(?t::'a::euclidean_space set) ⊆ UNIV ⟹ continuous_on ?t (r::'a::euclidean_space ⇒ 'a::euclidean_space)›*)) qed (use ontor r in auto) (*solves the remaining goals: 1. ‹r ∈ connected_component_set (- S) y → S› 2. ‹⋀x. x ∈ S ⟹ r x = x›*) with ‹y ∉ S› (*‹y ∉ S›*) show False by force qed qed lemma connected_complement_absolute_retract: fixes S :: "'a::euclidean_space set" assumes S: "compact S" "AR S" and 2: "2 ≤ DIM('a)" shows "connected(- S)" proof (-) (*goal: ‹connected (- S)›*) have "S retract_of UNIV" using S (*‹compact S› ‹AR S›*) compact_AR (*‹(compact ?S ∧ AR ?S) = (compact ?S ∧ ?S retract_of UNIV)›*) by blast show "?thesis" (*goal: ‹connected (- S)›*) proof (clarsimp simp: connected_iff_connected_component_eq (*‹connected ?S = (∀x∈?S. ∀y∈?S. connected_component_set ?S x = connected_component_set ?S y)›*)) (*goal: ‹⋀x y. ⟦x ∉ S; y ∉ S⟧ ⟹ connected_component_set (- S) x = connected_component_set (- S) y›*) have "¬ bounded (connected_component_set (- S) x)" if "x ∉ S" for x by (meson Compl_iff (*‹(?c ∈ - ?A) = (?c ∉ ?A)›*) assms (*‹compact S› ‹AR S› ‹2 ≤ DIM('a)›*) componentsI (*‹?x ∈ ?U ⟹ connected_component_set ?U ?x ∈ components ?U›*) that (*‹x ∉ S›*) unbounded_components_complement_absolute_retract (*‹⟦?C ∈ components (- ?S); compact ?S; AR ?S⟧ ⟹ ¬ bounded ?C›*)) then show "connected_component_set (- S) x = connected_component_set (- S) y" if "x ∉ S" "y ∉ S" for x and y using cobounded_unique_unbounded_component[OF _ 2] (*‹⟦bounded (- ?S); ¬ bounded (connected_component_set ?S ?x); ¬ bounded (connected_component_set ?S ?y)⟧ ⟹ connected_component_set ?S ?x = connected_component_set ?S ?y›*) by (metis ‹compact S› compact_imp_bounded (*‹compact ?U ⟹ bounded ?U›*) double_compl (*‹- (- ?x) = ?x›*) that (*‹x ∉ S› ‹y ∉ S›*)) qed qed lemma path_connected_complement_absolute_retract: fixes S :: "'a::euclidean_space set" assumes "compact S" "AR S" "2 ≤ DIM('a)" shows "path_connected(- S)" using connected_complement_absolute_retract[OF assms] (*‹connected (- S)›*) using ‹compact S› (*‹compact S›*) compact_eq_bounded_closed (*‹compact ?S = (bounded ?S ∧ closed ?S)›*) connected_open_path_connected (*‹⟦open ?S; connected ?S⟧ ⟹ path_connected ?S›*) by blast theorem connected_complement_homeomorphic_convex_compact: fixes S :: "'a::euclidean_space set" and T :: "'b::euclidean_space set" assumes hom: "S homeomorphic T" and T: "convex T" "compact T" and 2: "2 ≤ DIM('a)" shows "connected(- S)" proof (cases "S = {}") (*goals: 1. ‹S = {} ⟹ connected (- S)› 2. ‹S ≠ {} ⟹ connected (- S)›*) case True (*‹S = {}›*) then show "?thesis" (*goal: ‹connected (- S)›*) by (simp add: connected_UNIV (*‹connected UNIV›*)) next (*goal: ‹S ≠ {} ⟹ connected (- S)›*) case False (*‹S ≠ {}›*) show "?thesis" (*goal: ‹connected (- S)›*) proof (rule connected_complement_absolute_retract (*‹⟦compact ?S; AR ?S; 2 ≤ DIM(?'a)⟧ ⟹ connected (- ?S)›*)) (*goals: 1. ‹compact (S::'a set)› 2. ‹AR (S::'a set)› 3. ‹(2::nat) ≤ DIM('a)›*) show "compact S" using ‹compact T› (*‹compact T›*) hom (*‹S homeomorphic T›*) homeomorphic_compactness (*‹(?S::?'a set) homeomorphic (?T::?'b set) ⟹ compact ?S = compact ?T›*) by auto show "AR S" by (meson AR_ANR (*‹AR ?S = (ANR ?S ∧ contractible ?S ∧ ?S ≠ {})›*) False (*‹S ≠ {}›*) ‹convex T› convex_imp_ANR (*‹convex ?S ⟹ ANR ?S›*) convex_imp_contractible (*‹convex ?S ⟹ contractible ?S›*) hom (*‹S homeomorphic T›*) homeomorphic_ANR_iff_ANR (*‹?S homeomorphic ?T ⟹ ANR ?S = ANR ?T›*) homeomorphic_contractible_eq (*‹?S homeomorphic ?T ⟹ contractible ?S = contractible ?T›*)) qed (rule 2 (*‹2 ≤ DIM('a)›*)) (*solved the remaining goal: ‹(2::nat) ≤ DIM('a::euclidean_space)›*) qed corollary path_connected_complement_homeomorphic_convex_compact: fixes S :: "'a::euclidean_space set" and T :: "'b::euclidean_space set" assumes hom: "S homeomorphic T" "convex T" "compact T" "2 ≤ DIM('a)" shows "path_connected(- S)" using connected_complement_homeomorphic_convex_compact[OF assms] (*‹connected (- S)›*) using ‹compact T› (*‹compact T›*) compact_eq_bounded_closed (*‹compact ?S = (bounded ?S ∧ closed ?S)›*) connected_open_path_connected (*‹⟦open ?S; connected ?S⟧ ⟹ path_connected ?S›*) hom (*‹(S::'a::euclidean_space set) homeomorphic (T::'b::euclidean_space set)› ‹convex (T::'b set)› ‹compact (T::'b::euclidean_space set)› ‹2 ≤ DIM('a)›*) homeomorphic_compactness (*‹(?S::?'a::topological_space set) homeomorphic (?T::?'b::topological_space set) ⟹ compact ?S = compact ?T›*) by blast lemma path_connected_complement_homeomorphic_interval: fixes S :: "'a::euclidean_space set" assumes "S homeomorphic cbox a b" "2 ≤ DIM('a)" shows "path_connected(-S)" using assms (*‹S homeomorphic cbox a b› ‹2 ≤ DIM('a)›*) compact_cbox (*‹compact (cbox ?a ?b)›*) convex_box(1) (*‹convex (cbox ?a ?b)›*) path_connected_complement_homeomorphic_convex_compact (*‹⟦?S homeomorphic ?T; convex ?T; compact ?T; 2 ≤ DIM(?'a)⟧ ⟹ path_connected (- ?S)›*) by blast lemma connected_complement_homeomorphic_interval: fixes S :: "'a::euclidean_space set" assumes "S homeomorphic cbox a b" "2 ≤ DIM('a)" shows "connected(-S)" using assms (*‹S homeomorphic cbox a b› ‹2 ≤ DIM('a)›*) path_connected_complement_homeomorphic_interval (*‹⟦(?S::?'a set) homeomorphic cbox (?a::?'b) (?b::?'b); (2::nat) ≤ DIM(?'a)⟧ ⟹ path_connected (- ?S)›*) path_connected_imp_connected (*‹path_connected (?S::?'a::topological_space set) ⟹ connected ?S›*) by blast end
{ "path": "Isabelle2024/src/HOL/Analysis/Retracts.thy", "repo": "Isabelle2024", "sha": "45a0d3515ecd9ef13da35e9470024900d1c8ba956c0473e0e450501720586f77" }
(* Author: Maximilian Schäffeler *) theory Policy_Iteration imports "MDP-Rewards.MDP_reward" begin section ‹Policy Iteration› text ‹ The Policy Iteration algorithms provides another way to find optimal policies under the expected total reward criterion. It differs from Value Iteration in that it continuously improves an initial guess for an optimal decision rule. Its execution can be subdivided into two alternating steps: policy evaluation and policy improvement. Policy evaluation means the calculation of the value of the current decision rule. During the improvement phase, we choose the decision rule with the maximum value for L, while we prefer to keep the old action selection in case of ties. › context MDP_att_ℒ begin definition "policy_eval d = ν⇩b (mk_stationary_det d)" end context MDP_act_disc begin definition "policy_improvement d v s = ( if is_arg_max (λa. L⇩a a (apply_bfun v) s) (λa. a ∈ A s) (d s) then d s else arb_act (opt_acts v s))" definition "policy_step d = policy_improvement d (policy_eval d)" (* todo: move check is_dec_det outside the recursion *) function policy_iteration :: "('s ⇒ 'a) ⇒ ('s ⇒ 'a)" where "policy_iteration d = ( let d' = policy_step d in if d = d' ∨ ¬is_dec_det d then d else policy_iteration d')" by auto text ‹ The policy iteration algorithm as stated above does require that the supremum in @{const ℒ⇩b} is always attained. › text ‹ Each policy improvement returns a valid decision rule. › lemma is_dec_det_pi: "is_dec_det (policy_improvement d v)" unfolding policy_improvement_def is_dec_det_def is_arg_max_def (*goal: ‹∀s. (if d s ∈ A s ∧ (∄y. y ∈ A s ∧ L⇩a (d s) (apply_bfun v) s < L⇩a y (apply_bfun v) s) then d s else arb_act (opt_acts (apply_bfun v) s)) ∈ A s›*) by (auto simp: some_opt_acts_in_A (*‹arb_act (opt_acts ?v ?s) ∈ A ?s›*)) lemma policy_improvement_is_dec_det: "d ∈ D⇩D ⟹ policy_improvement d v ∈ D⇩D" unfolding policy_improvement_def is_dec_det_def (*goal: ‹d ∈ {d. ∀s. d s ∈ A s} ⟹ (λs. if is_arg_max (λa. L⇩a a (apply_bfun v) s) (λa. a ∈ A s) (d s) then d s else arb_act (opt_acts (apply_bfun v) s)) ∈ {d. ∀s. d s ∈ A s}›*) using some_opt_acts_in_A (*‹arb_act (opt_acts ?v ?s) ∈ A ?s›*) by auto lemma policy_improvement_improving: assumes "d ∈ D⇩D" shows "ν_improving v (mk_dec_det (policy_improvement d v))" proof (-) (*goal: ‹ν_improving v (mk_dec_det (policy_improvement d v))›*) have "ℒ⇩b v x = L (mk_dec_det (policy_improvement d v)) v x" for x using is_opt_act_some (*‹is_opt_act ?v ?s (arb_act (opt_acts ?v ?s))›*) by (fastforce simp: ℒ⇩b_eq_argmax_L⇩a (*‹is_arg_max (λa. L⇩a a (apply_bfun ?v) ?s) (λa. a ∈ A ?s) ?a ⟹ apply_bfun (ℒ⇩b ?v) ?s = L⇩a ?a (apply_bfun ?v) ?s›*) L_eq_L⇩a_det (*‹apply_bfun (L (mk_dec_det ?d) ?v) ?s = L⇩a (?d ?s) (apply_bfun ?v) ?s›*) is_opt_act_def (*‹is_opt_act ?v ?s = is_arg_max (λa. L⇩a a ?v ?s) (λa. a ∈ A ?s)›*) policy_improvement_def (*‹policy_improvement ?d ?v ?s = (if is_arg_max (λa. L⇩a a (apply_bfun ?v) ?s) (λa. a ∈ A ?s) (?d ?s) then ?d ?s else arb_act (opt_acts (apply_bfun ?v) ?s))›*) arg_max_SUP (*‹is_arg_max ?f (λx. x ∈ ?X) ?m ⟹ ?f ?m = ⨆ (?f ` ?X)›*)) thus "?thesis" (*goal: ‹ν_improving (v::'s::countable ⇒⇩b real) (mk_dec_det (policy_improvement (d::'s::countable ⇒ 'a::countable) v))›*) using policy_improvement_is_dec_det (*‹?d ∈ D⇩D ⟹ policy_improvement ?d ?v ∈ D⇩D›*) assms (*‹d ∈ D⇩D›*) by (auto simp: ν_improving_alt (*‹?d ∈ D⇩R ⟹ ν_improving ?v ?d = (ℒ⇩b ?v = L ?d ?v)›*)) qed lemma eval_policy_step_L: "is_dec_det d ⟹ L (mk_dec_det (policy_step d)) (policy_eval d) = ℒ⇩b (policy_eval d)" by (auto simp: policy_step_def (*‹policy_step ?d = policy_improvement ?d (policy_eval ?d)›*) ν_improving_imp_ℒ⇩b[OF policy_improvement_improving] (*‹?d1 ∈ D⇩D ⟹ ℒ⇩b ?v = L (mk_dec_det (policy_improvement ?d1 ?v)) ?v›*)) text ‹ The sequence of policies generated by policy iteration has monotonically increasing discounted reward.› lemma policy_eval_mon: assumes "is_dec_det d" shows "policy_eval d ≤ policy_eval (policy_step d)" proof (-) (*goal: ‹policy_eval d ≤ policy_eval (policy_step d)›*) let ?d' = "mk_dec_det (policy_step d)" let ?dp = "mk_stationary_det d" let ?P = "∑t. l ^ t *⇩R 𝒫₁ ?d' ^^ t" have "L (mk_dec_det d) (policy_eval d) ≤ L ?d' (policy_eval d)" using assms (*‹is_dec_det d›*) by (auto simp: L_le_ℒ⇩b (*‹is_dec ?d ⟹ L ?d ?v ≤ ℒ⇩b ?v›*) eval_policy_step_L (*‹is_dec_det ?d ⟹ L (mk_dec_det (policy_step ?d)) (policy_eval ?d) = ℒ⇩b (policy_eval ?d)›*)) hence "policy_eval d ≤ L ?d' (policy_eval d)" using "L_ν_fix" (*‹ν⇩b (mk_stationary ?d) = L ?d (ν⇩b (mk_stationary ?d))›*) policy_eval_def (*‹policy_eval ?d = ν⇩b (mk_stationary_det ?d)›*) by auto hence "ν⇩b ?dp ≤ r_dec⇩b ?d' + l *⇩R 𝒫₁ ?d' (ν⇩b ?dp)" unfolding policy_eval_def L_def (*goal: ‹ν⇩b (mk_stationary_det d) ≤ r_dec⇩b (mk_dec_det (policy_step d)) + l *⇩R blinfun_apply (𝒫₁ (mk_dec_det (policy_step d))) (ν⇩b (mk_stationary_det d))›*) by auto hence "(id_blinfun - l *⇩R 𝒫₁ ?d') (ν⇩b ?dp) ≤ r_dec⇩b ?d'" by (simp add: blinfun.diff_left (*‹blinfun_apply (?a - ?a') ?b = blinfun_apply ?a ?b - blinfun_apply ?a' ?b›*) diff_le_eq (*‹(?a - ?b ≤ ?c) = (?a ≤ ?c + ?b)›*) scaleR_blinfun.rep_eq (*‹blinfun_apply (?x *⇩R ?xa) = (λx. ?x *⇩R blinfun_apply ?xa x)›*)) hence "?P ((id_blinfun - l *⇩R 𝒫₁ ?d') (ν⇩b ?dp)) ≤ ?P (r_dec⇩b ?d')" using lemma_6_1_2_b (*‹?v ≤ ?u ⟹ blinfun_apply (∑t. l ^ t *⇩R 𝒫₁ ?d ^^ t) ?v ≤ blinfun_apply (∑t. l ^ t *⇩R 𝒫₁ ?d ^^ t) ?u›*) by auto hence "ν⇩b ?dp ≤ ?P (r_dec⇩b ?d')" using inv_norm_le'(2)[OF norm_𝒫₁_l_less] (*‹blinfun_apply (∑i. (l *⇩R 𝒫₁ ?d1) ^^ i) (blinfun_apply (id_blinfun - l *⇩R 𝒫₁ ?d1) ?x) = ?x›*) by (auto simp: blincomp_scaleR_right (*‹(?a *⇩R ?F) ^^ ?t = ?a ^ ?t *⇩R ?F ^^ ?t›*)) thus "?thesis" (*goal: ‹policy_eval d ≤ policy_eval (policy_step d)›*) by (auto simp: policy_eval_def (*‹policy_eval ?d = ν⇩b (mk_stationary_det ?d)›*) ν_stationary (*‹ν⇩b (mk_stationary ?d) = blinfun_apply (∑t. l ^ t *⇩R 𝒫₁ ?d ^^ t) (r_dec⇩b ?d)›*)) qed text ‹ If policy iteration terminates, i.e. @{term "d = policy_step d"}, then it does so with optimal value. › lemma policy_step_eq_imp_opt: assumes "is_dec_det d" "d = policy_step d" shows "ν⇩b (mk_stationary_det d) = ν⇩b_opt" using "L_ν_fix" (*‹ν⇩b (mk_stationary (?d::'s ⇒ 'a pmf)) = L ?d (ν⇩b (mk_stationary ?d))›*) assms (*‹is_dec_det d› ‹d = policy_step d›*) eval_policy_step_L[unfolded policy_eval_def] (*‹is_dec_det ?d ⟹ L (mk_dec_det (policy_step ?d)) (ν⇩b (mk_stationary_det ?d)) = ℒ⇩b (ν⇩b (mk_stationary_det ?d))›*) by (fastforce intro: ℒ_fix_imp_opt (*‹?v = ℒ⇩b ?v ⟹ ?v = ν⇩b_opt›*)) end text ‹We prove termination of policy iteration only if both the state and action sets are finite.› locale MDP_PI_finite = MDP_act_disc arb_act A K r l for A and K :: "'s ::countable × 'a ::countable ⇒ 's pmf" and r l arb_act + assumes fin_states: "finite (UNIV :: 's set)" and fin_actions: "⋀s. finite (A s)" begin text ‹If the state and action sets are both finite, then so is the set of deterministic decision rules @{const "D⇩D"}› lemma finite_D⇩D[simp]: "finite D⇩D" proof (-) (*goal: ‹finite D⇩D›*) let ?set = "{d. ∀x :: 's. (x ∈ UNIV ⟶ d x ∈ (⋃s. A s)) ∧ (x ∉ UNIV ⟶ d x = undefined)}" have "finite (⋃s. A s)" using fin_actions (*‹finite ((A::'s::countable ⇒ 'a::countable set) (?s::'s::countable))›*) fin_states (*‹finite UNIV›*) by blast hence "finite ?set" using fin_states (*‹finite UNIV›*) by (fastforce intro: finite_set_of_finite_funs (*‹⟦finite ?A; finite ?B⟧ ⟹ finite {f. ∀x. (x ∈ ?A ⟶ f x ∈ ?B) ∧ (x ∉ ?A ⟶ f x = ?d)}›*)) moreover have "D⇩D ⊆ ?set" unfolding is_dec_det_def (*goal: ‹{d. ∀s. d s ∈ A s} ⊆ {d. ∀x. (x ∈ UNIV ⟶ d x ∈ ⋃ (range A)) ∧ (x ∉ UNIV ⟶ d x = undefined)}›*) by auto ultimately show "?thesis" (*goal: ‹finite D⇩D›*) using finite_subset (*‹⟦?A ⊆ ?B; finite ?B⟧ ⟹ finite ?A›*) by auto qed lemma finite_rel: "finite {(u, v). is_dec_det u ∧ is_dec_det v ∧ ν⇩b (mk_stationary_det u) > ν⇩b (mk_stationary_det v)}" proof (-) (*goal: ‹finite {(u, v). is_dec_det u ∧ is_dec_det v ∧ ν⇩b (mk_stationary_det v) < ν⇩b (mk_stationary_det u)}›*) have aux: "finite {(u, v). is_dec_det u ∧ is_dec_det v}" by auto show "?thesis" (*goal: ‹finite {(u, v). is_dec_det u ∧ is_dec_det v ∧ ν⇩b (mk_stationary_det v) < ν⇩b (mk_stationary_det u)}›*) by (auto intro: finite_subset[OF _ aux] (*‹?A ⊆ {(u, v). is_dec_det u ∧ is_dec_det v} ⟹ finite ?A›*)) qed text ‹ This auxiliary lemma shows that policy iteration terminates if no improvement to the value of the policy could be made, as then the policy remains unchanged. › lemma eval_eq_imp_policy_eq: assumes "policy_eval d = policy_eval (policy_step d)" "is_dec_det d" shows "d = policy_step d" proof (-) (*goal: ‹d = policy_step d›*) have "policy_eval d s = policy_eval (policy_step d) s" for s using assms (*‹policy_eval d = policy_eval (policy_step d)› ‹is_dec_det (d::'s::countable ⇒ 'a::countable)›*) by auto have "policy_eval d = L (mk_dec_det d) (policy_eval (policy_step d))" unfolding policy_eval_def (*goal: ‹ν⇩b (mk_stationary_det (d::'s ⇒ 'a)) = L (mk_dec_det d) (ν⇩b (mk_stationary_det (policy_step d)))›*) using "L_ν_fix" (*‹ν⇩b (mk_stationary ?d) = L ?d (ν⇩b (mk_stationary ?d))›*) by (auto simp: assms(1)[symmetric, unfolded policy_eval_def] (*‹ν⇩b (mk_stationary_det (policy_step d)) = ν⇩b (mk_stationary_det d)›*)) hence "policy_eval d = ℒ⇩b (policy_eval d)" by (metis L_ν_fix (*‹ν⇩b (mk_stationary ?d) = L ?d (ν⇩b (mk_stationary ?d))›*) policy_eval_def (*‹policy_eval ?d = ν⇩b (mk_stationary_det ?d)›*) assms (*‹policy_eval d = policy_eval (policy_step d)› ‹is_dec_det d›*) eval_policy_step_L (*‹is_dec_det ?d ⟹ L (mk_dec_det (policy_step ?d)) (policy_eval ?d) = ℒ⇩b (policy_eval ?d)›*)) hence "L (mk_dec_det d) (policy_eval d) s = ℒ⇩b (policy_eval d) s" for s using ‹policy_eval d = L (mk_dec_det d) (policy_eval (policy_step d))› (*‹policy_eval d = L (mk_dec_det d) (policy_eval (policy_step d))›*) assms(1) (*‹policy_eval d = policy_eval (policy_step d)›*) by auto hence "is_arg_max (λa. L⇩a a (ν⇩b (mk_stationary (mk_dec_det d))) s) (λa. a ∈ A s) (d s)" for s unfolding "L_eq_L⇩a_det" (*goal: ‹is_arg_max (λa. L⇩a a (apply_bfun (ν⇩b (mk_stationary_det d))) s) (λa. a ∈ A s) (d s)›*) unfolding policy_eval_def "ℒ⇩b.rep_eq" "ℒ_eq_SUP_det" SUP_step_det_eq (*goal: ‹is_arg_max (λa. L⇩a a (apply_bfun (ν⇩b (mk_stationary_det d))) s) (λa. a ∈ A s) (d s)›*) using assms(2) (*‹is_dec_det d›*) is_dec_det_def (*‹is_dec_det ?d ≡ ∀s. ?d s ∈ A s›*) "L⇩a_le" (*‹¦L⇩a ?a (apply_bfun ?v) ?s¦ ≤ r⇩M + l * norm ?v›*) by (auto intro!: SUP_is_arg_max (*‹⟦?x ∈ ?X; bdd_above (?f ` ?X); ?f ?x = ⨆ (?f ` ?X)⟧ ⟹ is_arg_max ?f (λx. x ∈ ?X) ?x›*) boundedI (*‹(⋀x. x ∈ ?S ⟹ norm x ≤ ?B) ⟹ bounded ?S›*) bounded_imp_bdd_above (*‹bounded ?S ⟹ bdd_above ?S›*)) thus "?thesis" (*goal: ‹d = policy_step d›*) unfolding policy_eval_def policy_step_def policy_improvement_def (*goal: ‹d = (λs. if is_arg_max (λa. L⇩a a (apply_bfun (ν⇩b (mk_stationary_det d))) s) (λa. a ∈ A s) (d s) then d s else arb_act (opt_acts (apply_bfun (ν⇩b (mk_stationary_det d))) s))›*) by auto qed text ‹ We are now ready to prove termination in the context of finite state-action spaces. Intuitively, the algorithm terminates as there are only finitely many decision rules, and in each recursive call the value of the decision rule increases. › termination policy_iteration proof (relation "{(u, v). u ∈ D⇩D ∧ v ∈ D⇩D ∧ ν⇩b (mk_stationary_det u) > ν⇩b (mk_stationary_det v)}") show "wf {(u, v). u ∈ D⇩D ∧ v ∈ D⇩D ∧ ν⇩b (mk_stationary_det v) < ν⇩b (mk_stationary_det u)}" using finite_rel by (auto intro!: finite_acyclic_wf acyclicI_order) next fix d x assume h: "x = policy_step d" "¬ (d = x ∨ ¬ is_dec_det d)" have "is_dec_det d ⟹ ν⇩b (mk_stationary_det d) ≤ ν⇩b (mk_stationary_det (policy_step d))" using policy_eval_mon by (simp add: policy_eval_def) hence "is_dec_det d ⟹ d ≠ policy_step d ⟹ ν⇩b (mk_stationary_det d) < ν⇩b (mk_stationary_det (policy_step d))" using eval_eq_imp_policy_eq policy_eval_def by (force intro!: order.not_eq_order_implies_strict) thus "(x, d) ∈ {(u, v). u ∈ D⇩D ∧ v ∈ D⇩D ∧ ν⇩b (mk_stationary_det v) < ν⇩b (mk_stationary_det u)}" using is_dec_det_pi policy_step_def h by auto qed text ‹ The termination proof gives us access to the induction rule/simplification lemmas associated with the @{const policy_iteration} definition. Thus we can prove that the algorithm finds an optimal policy. › lemma is_dec_det_pi': "d ∈ D⇩D ⟹ is_dec_det (policy_iteration d)" using is_dec_det_pi (*‹is_dec_det (policy_improvement ?d ?v)›*) apply (induction d rule: policy_iteration.induct (*‹(⋀d::'s::countable ⇒ 'a::countable. (⋀x::'s::countable ⇒ 'a::countable. ⟦x = policy_step d; ¬ (d = x ∨ ¬ is_dec_det d)⟧ ⟹ (?P::('s::countable ⇒ 'a::countable) ⇒ bool) x) ⟹ ?P d) ⟹ ?P (?a0.0::'s::countable ⇒ 'a::countable)›*)) (*goal: ‹(d::'s ⇒ 'a) ∈ D⇩D ⟹ is_dec_det (policy_iteration d)›*) by (auto simp: Let_def (*‹Let (?s::?'a::type) (?f::?'a::type ⇒ ?'b::type) ≡ ?f ?s›*) policy_step_def (*‹policy_step (?d::'s::countable ⇒ 'a::countable) = policy_improvement ?d (policy_eval ?d)›*)) lemma pi_pi[simp]: "d ∈ D⇩D ⟹ policy_step (policy_iteration d) = policy_iteration d" using is_dec_det_pi (*‹is_dec_det (policy_improvement (?d::'s ⇒ 'a) (?v::'s ⇒⇩b real))›*) apply (induction d rule: policy_iteration.induct (*‹(⋀d. (⋀x. ⟦x = policy_step d; ¬ (d = x ∨ ¬ is_dec_det d)⟧ ⟹ ?P x) ⟹ ?P d) ⟹ ?P ?a0.0›*)) (*goal: ‹d ∈ D⇩D ⟹ policy_step (policy_iteration d) = policy_iteration d›*) by (auto simp: policy_step_def (*‹policy_step ?d = policy_improvement ?d (policy_eval ?d)›*) Let_def (*‹Let ?s ?f ≡ ?f ?s›*)) lemma policy_iteration_correct: "d ∈ D⇩D ⟹ ν⇩b (mk_stationary_det (policy_iteration d)) = ν⇩b_opt" apply (induction d rule: policy_iteration.induct (*‹(⋀d::'s::countable ⇒ 'a::countable. (⋀x::'s::countable ⇒ 'a::countable. ⟦x = policy_step d; ¬ (d = x ∨ ¬ is_dec_det d)⟧ ⟹ (?P::('s::countable ⇒ 'a::countable) ⇒ bool) x) ⟹ ?P d) ⟹ ?P (?a0.0::'s::countable ⇒ 'a::countable)›*)) (*goal: ‹d ∈ D⇩D ⟹ ν⇩b (mk_stationary_det (policy_iteration d)) = ν⇩b_opt›*) by (fastforce intro!: policy_step_eq_imp_opt (*‹⟦is_dec_det ?d; ?d = policy_step ?d⟧ ⟹ ν⇩b (mk_stationary_det ?d) = ν⇩b_opt›*) is_dec_det_pi' (*‹?d ∈ D⇩D ⟹ is_dec_det (policy_iteration ?d)›*) simp del: policy_iteration.simps (*‹policy_iteration ?d = (let d' = policy_step ?d in if ?d = d' ∨ ¬ is_dec_det ?d then ?d else policy_iteration d')›*)) end context MDP_finite_type begin text ‹ The following proofs concern code generation, i.e. how to represent @{const 𝒫₁} as a matrix. › sublocale MDP_att_ℒ by (auto simp: A_ne (*‹(A::'s ⇒ 'a set) (?s::'s) ≠ {}›*) finite_is_arg_max (*‹⟦finite (?X::?'c set); ?X ≠ {}⟧ ⟹ ∃x::?'c. is_arg_max (?f::?'c ⇒ real) (λx::?'c. x ∈ ?X) x›*) MDP_att_ℒ_def (*‹MDP_att_ℒ (?A::?'s ⇒ ?'a set) (?K::?'s × ?'a ⇒ ?'s pmf) (?r::?'s × ?'a ⇒ real) (?l::real) ≡ MDP_reward_disc ?A ?r ?l ∧ MDP_att_ℒ_axioms ?A ?K ?r ?l›*) MDP_att_ℒ_axioms_def (*‹MDP_att_ℒ_axioms (?A::?'s ⇒ ?'a set) (?K::?'s × ?'a ⇒ ?'s pmf) (?r::?'s × ?'a ⇒ real) (?l::real) ≡ ∀(s::?'s) v::?'s ⇒ real. MDP_reward_disc.max_L_ex ?A ?K ?r ?l s v›*) max_L_ex_def (*‹max_L_ex (?s::'s) (?v::'s ⇒ real) ≡ has_arg_max (λa::'a. L⇩a a ?v ?s) ((A::'s ⇒ 'a set) ?s)›*) has_arg_max_def (*‹has_arg_max (?f::?'a ⇒ ?'b) (?X::?'a set) ≡ ∃x::?'a. is_arg_max ?f (λx::?'a. x ∈ ?X) x›*) MDP_reward_disc_axioms (*‹MDP_reward_disc (A::'s ⇒ 'a set) (r::'s × 'a ⇒ real) (l::real)›*)) definition "fun_to_matrix f = matrix (λv. (χ j. f (vec_nth v) j))" definition "Ek_mat d = fun_to_matrix (λv. ((𝒫₁ d) (Bfun v)))" definition "nu_inv_mat d = fun_to_matrix ((λv. ((id_blinfun - l *⇩R 𝒫₁ d) (Bfun v))))" definition "nu_mat d = fun_to_matrix (λv. ((∑i. (l *⇩R 𝒫₁ d) ^^ i) (Bfun v)))" lemma apply_nu_inv_mat: "(id_blinfun - l *⇩R 𝒫₁ d) v = Bfun (λi. ((nu_inv_mat d) *v (vec_lambda v)) $ i)" proof (-) (*goal: ‹blinfun_apply (id_blinfun - (l::real) *⇩R 𝒫₁ (d::'s::finite ⇒ 'a::finite pmf)) (v::'s::finite ⇒⇩b real) = bfun.Bfun (($) (nu_inv_mat d *v vec_lambda (apply_bfun v)))›*) have eq_onpI: "P x ⟹ eq_onp P x x" for P and x by (simp add: eq_onp_def (*‹eq_onp (?R::?'a ⇒ bool) = (λ(x::?'a) y::?'a. ?R x ∧ x = y)›*)) have "Real_Vector_Spaces.linear (λv. vec_lambda (((id_blinfun - l *⇩R 𝒫₁ d) (bfun.Bfun (($) v)))))" by (auto simp del: real_scaleR_def (*‹?a *⇩R ?x = ?a * ?x›*) intro: linearI (*‹⟦⋀b1 b2. ?f (b1 + b2) = ?f b1 + ?f b2; ⋀r b. ?f (r *⇩R b) = r *⇩R ?f b⟧ ⟹ linear ?f›*) simp: scaleR_vec_def (*‹(*⇩R) ≡ λr x. χi. r *⇩R x $ i›*) eq_onpI (*‹?P3 ?x3 ⟹ eq_onp ?P3 ?x3 ?x3›*) plus_vec_def (*‹(+) ≡ λx y. χi. x $ i + y $ i›*) vec_lambda_inverse (*‹?y ∈ UNIV ⟹ ($) (vec_lambda ?y) = ?y›*) plus_bfun.abs_eq[symmetric] (*‹⟦eq_onp (λx. x ∈ bfun) ?xa ?xa; eq_onp (λx. x ∈ bfun) ?x ?x⟧ ⟹ bfun.Bfun (λx. ?xa x + ?x x) = bfun.Bfun ?xa + bfun.Bfun ?x›*) scaleR_bfun.abs_eq[symmetric] (*‹eq_onp (λx. x ∈ bfun) ?x ?x ⟹ bfun.Bfun (λx. ?xa *⇩R ?x x) = ?xa *⇩R bfun.Bfun ?x›*) blinfun.scaleR_right (*‹blinfun_apply ?a (?r *⇩R ?b) = ?r *⇩R blinfun_apply ?a ?b›*) blinfun.add_right (*‹blinfun_apply ?a (?b + ?b') = blinfun_apply ?a ?b + blinfun_apply ?a ?b'›*)) thus "?thesis" (*goal: ‹blinfun_apply (id_blinfun - l *⇩R 𝒫₁ d) v = bfun.Bfun (($) (nu_inv_mat d *v vec_lambda (apply_bfun v)))›*) unfolding Ek_mat_def fun_to_matrix_def nu_inv_mat_def (*goal: ‹blinfun_apply (id_blinfun - l *⇩R 𝒫₁ d) v = bfun.Bfun (($) (matrix (λv. vec_lambda (apply_bfun (blinfun_apply (id_blinfun - l *⇩R 𝒫₁ d) (bfun.Bfun (($) v))))) *v vec_lambda (apply_bfun v)))›*) by (auto simp: apply_bfun_inverse (*‹bfun.Bfun (apply_bfun ?x) = ?x›*) vec_lambda_inverse (*‹?y ∈ UNIV ⟹ ($) (vec_lambda ?y) = ?y›*)) qed lemma bounded_linear_vec_lambda: "bounded_linear (λx. vec_lambda (x :: 's ⇒⇩b real))" proof (intro bounded_linear_intro (*‹⟦⋀x y. ?f (x + y) = ?f x + ?f y; ⋀r x. ?f (r *⇩R x) = r *⇩R ?f x; ⋀x. norm (?f x) ≤ norm x * ?K⟧ ⟹ bounded_linear ?f›*)) (*goals: 1. ‹⋀x y. vec_lambda (apply_bfun (x + y)) = vec_lambda (apply_bfun x) + vec_lambda (apply_bfun y)› 2. ‹⋀r x. vec_lambda (apply_bfun (r *⇩R x)) = r *⇩R vec_lambda (apply_bfun x)› 3. ‹⋀x. norm (vec_lambda (apply_bfun x)) ≤ norm x * ?K›*) fix x :: "'s ⇒⇩b real" have "sqrt (∑ i ∈ UNIV . (apply_bfun x i)²) ≤ (∑ i ∈ UNIV . ¦(apply_bfun x i)¦)" using L2_set_le_sum_abs (*‹L2_set ?f ?A ≤ (∑i∈?A. ¦?f i¦)›*) unfolding L2_set_def (*goal: ‹sqrt (∑i∈UNIV. (apply_bfun x i)²) ≤ (∑i∈UNIV. ¦apply_bfun x i¦)›*) by auto also (*calculation: ‹sqrt (∑i∈UNIV. (apply_bfun x i)²) ≤ (∑i∈UNIV. ¦apply_bfun x i¦)›*) have "(∑ i ∈ UNIV . ¦(apply_bfun x i)¦) ≤ (card (UNIV :: 's set) * (⨆xa. ¦apply_bfun x xa¦))" by (auto intro!: cSup_upper (*‹⟦?x ∈ ?X; bdd_above ?X⟧ ⟹ ?x ≤ ⨆ ?X›*) sum_bounded_above (*‹(⋀i. i ∈ ?A ⟹ ?f i ≤ ?K) ⟹ sum ?f ?A ≤ of_nat (card ?A) * ?K›*)) finally (*calculation: ‹sqrt (∑i∈UNIV. (apply_bfun x i)²) ≤ real CARD('s) * (⨆xa. ¦apply_bfun x xa¦)›*) show "norm (vec_lambda (apply_bfun x)) ≤ norm x * CARD('s)" unfolding norm_vec_def norm_bfun_def dist_bfun_def L2_set_def (*goal: ‹sqrt (∑i::'s::finite∈UNIV. (norm (vec_lambda (apply_bfun (x::'s::finite ⇒⇩b real)) $ i))²) ≤ map_fun apply_bfun (map_fun apply_bfun id) (λ(f::'s::finite ⇒ real) g::'s::finite ⇒ real. ⨆x::'s::finite. dist (f x) (g x)) x (0::'s::finite ⇒⇩b real) * real CARD('s::finite)›*) by (auto simp add: mult.commute (*‹(?a::?'a) * (?b::?'a) = ?b * ?a›*)) qed (auto simp: plus_vec_def (*‹(+) ≡ λx y. χi. x $ i + y $ i›*) scaleR_vec_def (*‹(*⇩R) ≡ λr x. χi. r *⇩R x $ i›*)) (*solves the remaining goals: 1. ‹⋀(x::'s ⇒⇩b real) y::'s ⇒⇩b real. vec_lambda (apply_bfun (x + y)) = vec_lambda (apply_bfun x) + vec_lambda (apply_bfun y)› 2. ‹⋀(r::real) x::'s ⇒⇩b real. vec_lambda (apply_bfun (r *⇩R x)) = r *⇩R vec_lambda (apply_bfun x)›*) lemma bounded_linear_vec_lambda_blinfun: fixes f :: "('s ⇒⇩b real) ⇒⇩L ('s ⇒⇩b real)" shows "bounded_linear (λv. vec_lambda (apply_bfun (blinfun_apply f (bfun.Bfun (($) v)))))" using blinfun.bounded_linear_right (*‹bounded_linear (blinfun_apply ?a)›*) by (fastforce intro: bounded_linear_compose[OF bounded_linear_vec_lambda] (*‹bounded_linear (?g::?'c ⇒ 's ⇒⇩b real) ⟹ bounded_linear (λx::?'c. vec_lambda (apply_bfun (?g x)))›*) bounded_linear_bfun_nth (*‹bounded_linear (?f::?'a ⇒ (?'b, ?'c) vec) ⟹ bounded_linear (λv::?'a. bfun.Bfun (($) (?f v)))›*) bounded_linear_compose[of f] (*‹⟦bounded_linear (blinfun_apply (f::('s ⇒⇩b real) ⇒⇩L 's ⇒⇩b real)); bounded_linear (?g::?'c ⇒ 's ⇒⇩b real)⟧ ⟹ bounded_linear (λx::?'c. blinfun_apply f (?g x))›*)) lemma invertible_nu_inv_max: "invertible (nu_inv_mat d)" unfolding nu_inv_mat_def fun_to_matrix_def (*goal: ‹invertible (matrix (λv. vec_lambda (apply_bfun (blinfun_apply (id_blinfun - l *⇩R 𝒫₁ d) (bfun.Bfun (($) v))))))›*) by (auto simp: matrix_invertible (*‹linear ?f ⟹ invertible (matrix ?f) = (∃g. linear g ∧ ?f ∘ g = id ∧ g ∘ ?f = id)›*) inv_norm_le' (*‹norm ?Q < 1 ⟹ blinfun_apply (id_blinfun - ?Q) (blinfun_apply (∑i. ?Q ^^ i) ?x) = ?x› ‹norm ?Q < 1 ⟹ blinfun_apply (∑i. ?Q ^^ i) (blinfun_apply (id_blinfun - ?Q) ?x) = ?x›*) vec_lambda_inverse (*‹?y ∈ UNIV ⟹ ($) (vec_lambda ?y) = ?y›*) apply_bfun_inverse (*‹bfun.Bfun (apply_bfun ?x) = ?x›*) bounded_linear.linear[OF bounded_linear_vec_lambda_blinfun] (*‹linear (λv. vec_lambda (apply_bfun (blinfun_apply ?f1 (bfun.Bfun (($) v)))))›*) intro!: exI[of _ "λv. (χ j. (λv. (∑i. (l *⇩R 𝒫₁ d) ^^ i) (Bfun v)) (vec_nth v) j)"] (*‹?P (λv. χj. apply_bfun (blinfun_apply (∑i. (l *⇩R 𝒫₁ d) ^^ i) (bfun.Bfun (($) v))) j) ⟹ ∃x. ?P x›*)) end locale MDP_ord = MDP_finite_type A K r l for A and K :: "'s :: {finite, wellorder} × 'a :: {finite, wellorder} ⇒ 's pmf" and r l begin lemma ℒ_fin_eq_det: "ℒ v s = (⨆a ∈ A s. L⇩a a v s)" by (simp add: SUP_step_det_eq (*‹(⨆d∈D⇩D. apply_bfun (L (mk_dec_det d) ?v) ?s) = (⨆a∈A ?s. L⇩a a (apply_bfun ?v) ?s)›*) ℒ_eq_SUP_det (*‹ℒ ?v ?s = (⨆d∈D⇩D. apply_bfun (L (mk_dec_det d) ?v) ?s)›*)) lemma ℒ⇩b_fin_eq_det: "ℒ⇩b v s = (⨆a ∈ A s. L⇩a a v s)" by (simp add: SUP_step_det_eq (*‹(⨆d∈D⇩D. apply_bfun (L (mk_dec_det d) ?v) ?s) = (⨆a∈A ?s. L⇩a a (apply_bfun ?v) ?s)›*) ℒ⇩b.rep_eq (*‹apply_bfun (ℒ⇩b ?x) = ℒ ?x›*) ℒ_eq_SUP_det (*‹ℒ ?v ?s = (⨆d∈D⇩D. apply_bfun (L (mk_dec_det d) ?v) ?s)›*)) sublocale MDP_PI_finite A K r l "λX. Least (λx. x ∈ X)" apply unfold_locales (*goals: 1. ‹⋀X. X ≠ {} ⟹ (LEAST x. x ∈ X) ∈ X› 2. ‹finite UNIV› 3. ‹⋀s. finite (A s)› discuss goal 1*) apply ((auto intro: LeastI (*‹?P ?k ⟹ ?P (LEAST x. ?P x)›*))[1]) (*discuss goal 2*) apply ((auto intro: LeastI (*‹?P ?k ⟹ ?P (LEAST x. ?P x)›*))[1]) (*discuss goal 3*) apply ((auto intro: LeastI (*‹(?P::?'a ⇒ bool) (?k::?'a) ⟹ ?P (LEAST x::?'a. ?P x)›*))[1]) (*proven 3 subgoals*) . end end
{ "path": "afp-2025-02-12/thys/MDP-Algorithms/Policy_Iteration.thy", "repo": "afp-2025-02-12", "sha": "4e1b57fd1783510b702d3cdbce14e3366543d7b74b81492715c51119600108cb" }
section ‹ Technical Lemmas › text ‹We show three lemmas used in the proof of both main theorems.› theory Polygonal_Number_Theorem_Lemmas imports "Three_Squares.Three_Squares" begin subsection ‹ Lemma 1.10 in \cite{nathanson1996} › text ‹This lemma is split into two parts. We modify the proof given in \cite{nathanson1996} slightly as we require the second result to hold for $l=2$ in the proof of Legendre's polygonal number theorem.› theorem interval_length_greater_than_four: fixes m N L :: real assumes "m ≥ 3" assumes "N ≥ 2*m" assumes "L = (2/3 + sqrt (8*N/m - 8)) - (1/2 + sqrt (6*N/m - 3))" shows "N ≥ 108*m ⟹ L > 4" proof (-) (*goal: ‹(108::real) * (m::real) ≤ (N::real) ⟹ (4::real) < (L::real)›*) assume asm: "N ≥ 108*m" (*‹(108::real) * (m::real) ≤ (N::real)›*) show "L > 4" proof (-) (*goal: ‹4 < L›*) define x :: real where "x = N / m" define l :: real where "l = 4" define l_0 :: real where "l_0 = 4 - 1/6" have 0: "x ≥ 2" unfolding x_def (*goal: ‹2 ≤ N / m›*) using assms(2) (*‹2 * m ≤ N›*) by (metis assms( (*‹3 ≤ m›*) 1) divide_right_mono (*‹⟦?a ≤ ?b; 0 ≤ ?c⟧ ⟹ ?a / ?c ≤ ?b / ?c›*) dual_order.trans (*‹⟦?b ≤ ?a; ?c ≤ ?b⟧ ⟹ ?c ≤ ?a›*) linorder_le_cases (*‹⟦?x ≤ ?y ⟹ ?P; ?y ≤ ?x ⟹ ?P⟧ ⟹ ?P›*) mult.commute (*‹?a * ?b = ?b * ?a›*) mult_1 (*‹1 * ?a = ?a›*) nonzero_mult_div_cancel_left (*‹?a ≠ 0 ⟹ ?a * ?b div ?a = ?b›*) numeral_le_one_iff (*‹(numeral ?n ≤ 1) = (?n ≤ num.One)›*) semiring_norm( (*‹(num.Bit1 ?m ≤ num.One) = False›*) 70) zero_le_square (*‹0 ≤ ?a * ?a›*)) have 1: "L = sqrt (8*x - 8) - sqrt (6*x - 3) + 1/6" by (auto simp add: x_def (*‹x = N / m›*) assms( (*‹L = 2 / 3 + sqrt (8 * N / m - 8) - (1 / 2 + sqrt (6 * N / m - 3))›*) 3)) hence 2: "L > l ⟷ sqrt (8*x - 8) > sqrt (6*x - 3) + l_0" unfolding l_0_def l_def (*goal: ‹(4 < L) = (sqrt (6 * x - 3) + (4 - 1 / 6) < sqrt (8 * x - 8))›*) by auto have 3: "sqrt (8*x - 8) > sqrt (6*x - 3) + l_0 ⟷ 2*x - l_0^2 - 5 > 2*l_0 * sqrt (6*x - 3)" proof (standard) (*goals: 1. ‹sqrt (6 * x - 3) + l_0 < sqrt (8 * x - 8) ⟹ 2 * l_0 * sqrt (6 * x - 3) < 2 * x - l_0² - 5› 2. ‹2 * l_0 * sqrt (6 * x - 3) < 2 * x - l_0² - 5 ⟹ sqrt (6 * x - 3) + l_0 < sqrt (8 * x - 8)›*) assume "sqrt (8*x - 8) > sqrt (6*x - 3) + l_0" (*‹sqrt ((6::real) * (x::real) - (3::real)) + (l_0::real) < sqrt ((8::real) * x - (8::real))›*) hence "(sqrt (8*x - 8))^2 > (sqrt (6*x - 3) + l_0)^2" using l_0_def (*‹l_0 = 4 - 1 / 6›*) asm (*‹108 * m ≤ N›*) by (smt (verit, ccfv_SIG) "0" (*‹2 ≤ x›*) divide_less_eq_1_pos (*‹0 < ?a ⟹ (?b / ?a < 1) = (?b < ?a)›*) one_power2 (*‹1² = 1›*) pos2 (*‹0 < 2›*) power_mono_iff (*‹⟦0 ≤ ?a; 0 ≤ ?b; 0 < ?n⟧ ⟹ (?a ^ ?n ≤ ?b ^ ?n) = (?a ≤ ?b)›*) real_less_rsqrt (*‹?x² < ?y ⟹ ?x < sqrt ?y›*)) hence "8*x - 8 > 6*x - 3 + l_0^2 + 2*l_0* sqrt (6*x - 3)" by (smt (verit, del_insts) "0" (*‹2 ≤ x›*) power2_sum (*‹(?x + ?y)² = ?x² + ?y² + 2 * ?x * ?y›*) real_sqrt_pow2_iff (*‹((sqrt ?x)² = ?x) = (0 ≤ ?x)›*)) thus "2*x - l_0^2 - 5 > 2*l_0* sqrt (6*x - 3)" by auto next (*goal: ‹2 * l_0 * sqrt (6 * x - 3) < 2 * x - l_0² - 5 ⟹ sqrt (6 * x - 3) + l_0 < sqrt (8 * x - 8)›*) assume "2*x - l_0^2 - 5 > 2*l_0* sqrt (6*x - 3)" (*‹(2::real) * (l_0::real) * sqrt ((6::real) * (x::real) - (3::real)) < (2::real) * x - l_0² - (5::real)›*) hence "8*x - 8 > 6*x - 3 + l_0^2 + 2*l_0* sqrt (6*x - 3)" by auto hence "(sqrt (8*x - 8))^2 > (sqrt (6*x - 3) + l_0)^2" by (smt (verit, best) 0 (*‹(2::real) ≤ (x::real)›*) power2_sum (*‹((?x::?'a) + (?y::?'a))² = ?x² + ?y² + (2::?'a) * ?x * ?y›*) real_sqrt_pow2_iff (*‹((sqrt (?x::real))² = ?x) = ((0::real) ≤ ?x)›*)) thus "sqrt (8*x - 8) > sqrt (6*x - 3) + l_0" using "0" (*‹2 ≤ x›*) real_less_rsqrt (*‹?x² < ?y ⟹ ?x < sqrt ?y›*) by force qed have "2*x - l_0^2 - 5 > 2*l_0* sqrt (6*x - 3) ⟷ 4*x*(x - (7*l_0^2 + 5)) + (l_0^2 + 5)^2 + 12*l_0^2 > 0" proof (standard) (*goals: 1. ‹(2::real) * (l_0::real) * sqrt ((6::real) * (x::real) - (3::real)) < (2::real) * x - l_0² - (5::real) ⟹ (0::real) < (4::real) * x * (x - ((7::real) * l_0² + (5::real))) + (l_0² + (5::real))² + (12::real) * l_0²› 2. ‹(0::real) < (4::real) * (x::real) * (x - ((7::real) * (l_0::real)² + (5::real))) + (l_0² + (5::real))² + (12::real) * l_0² ⟹ (2::real) * l_0 * sqrt ((6::real) * x - (3::real)) < (2::real) * x - l_0² - (5::real)›*) assume "2*x - l_0^2 - 5 > 2*l_0* sqrt (6*x - 3)" (*‹(2::real) * (l_0::real) * sqrt ((6::real) * (x::real) - (3::real)) < (2::real) * x - l_0² - (5::real)›*) hence "(2*x - l_0^2 - 5)^2 > (2*l_0* sqrt (6*x - 3))^2" by (smt (verit, del_insts) "0" (*‹2 ≤ x›*) asm (*‹108 * m ≤ N›*) l_0_def (*‹l_0 = 4 - 1 / 6›*) le_divide_eq_1_pos (*‹0 < ?a ⟹ (1 ≤ ?b / ?a) = (?a ≤ ?b)›*) less_1_mult (*‹⟦1 < ?m; 1 < ?n⟧ ⟹ 1 < ?m * ?n›*) one_power2 (*‹1² = 1›*) pos2 (*‹0 < 2›*) power_mono_iff (*‹⟦0 ≤ ?a; 0 ≤ ?b; 0 < ?n⟧ ⟹ (?a ^ ?n ≤ ?b ^ ?n) = (?a ≤ ?b)›*) sqrt_le_D (*‹sqrt ?x ≤ ?y ⟹ ?x ≤ ?y²›*)) thus "4*x*(x - (7*l_0^2 + 5)) + (l_0^2 + 5)^2 + 12*l_0^2 > 0" using "0" (*‹(2::real) ≤ (x::real)›*) 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 34 facts*) power2_eq_square (*‹(?a::?'a::monoid_mult)² = ?a * ?a›*) power4_eq_xxxx (*‹(?x::?'a::monoid_mult) ^ (4::nat) = ?x * ?x * ?x * ?x›*)) next (*goal: ‹(0::real) < (4::real) * (x::real) * (x - ((7::real) * (l_0::real)² + (5::real))) + (l_0² + (5::real))² + (12::real) * l_0² ⟹ (2::real) * l_0 * sqrt ((6::real) * x - (3::real)) < (2::real) * x - l_0² - (5::real)›*) assume "4*x*(x - (7*l_0^2 + 5)) + (l_0^2 + 5)^2 + 12*l_0^2 > 0" (*‹(0::real) < (4::real) * (x::real) * (x - ((7::real) * (l_0::real)² + (5::real))) + (l_0² + (5::real))² + (12::real) * l_0²›*) hence "(2*x - l_0^2 - 5)^2 > (2*l_0* sqrt (6*x - 3))^2" using "0" (*‹2 ≤ 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*) power2_eq_square (*‹?a² = ?a * ?a›*) power4_eq_xxxx (*‹?x ^ 4 = ?x * ?x * ?x * ?x›*)) from assms(1) (*‹(3::real) ≤ (m::real)›*) have "m > 0" by auto hence "2*x ≥ 2*108" using x_def (*‹x = N / m›*) asm (*‹(108::real) * (m::real) ≤ (N::real)›*) by (simp add: le_divide_eq (*‹((?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))›*)) hence "2*x - l_0^2 - 5 ≥ 2*108 - (4-1/6)*(4-1/6) - 5" unfolding l_0_def (*goal: ‹2 * 108 - (4 - 1 / 6) * (4 - 1 / 6) - 5 ≤ 2 * x - (4 - 1 / 6)² - 5›*) by (auto simp add: power2_eq_square (*‹?a² = ?a * ?a›*)) hence "2*x - l_0^2 - 5 > 0" by auto thus "2*x - l_0^2 - 5 > 2*l_0* sqrt (6*x - 3)" using ‹(2*x - l_0^2 - 5)^2 > (2*l_0* sqrt (6*x - 3))^2› (*‹(2 * l_0 * sqrt (6 * x - 3))² < (2 * x - l_0² - 5)²›*) using power2_less_imp_less (*‹⟦?x² < ?y²; 0 ≤ ?y⟧ ⟹ ?x < ?y›*) by fastforce qed from assms(1) (*‹3 ≤ m›*) have "m > 0" by auto hence "x ≥ 108" using x_def (*‹x = N / m›*) asm (*‹108 * m ≤ N›*) by (simp add: le_divide_eq (*‹(?a ≤ ?b / ?c) = (if 0 < ?c then ?a * ?c ≤ ?b else if ?c < 0 then ?b ≤ ?a * ?c else ?a ≤ 0)›*)) have "7*(4-1/6)*(4-1/6) + 5 < (108::real)" by simp hence "7*l_0^2 + 5 < 108" unfolding l_0_def (*goal: ‹7 * (4 - 1 / 6)² + 5 < 108›*) by (auto simp add: power2_eq_square (*‹?a² = ?a * ?a›*)) hence "x ≥ 7*l_0^2 + 5" using ‹108 ≤ x› (*‹108 ≤ x›*) by auto hence "4*x*(x - (7*l_0^2 + 5)) + (l_0^2 + 5)^2 + 12*l_0^2 > 0" by (smt (verit) mult_nonneg_nonneg (*‹⟦0 ≤ ?a; 0 ≤ ?b⟧ ⟹ 0 ≤ ?a * ?b›*) power2_less_eq_zero_iff (*‹(?a² ≤ 0) = (?a = 0)›*) zero_le_power2 (*‹0 ≤ ?a²›*)) thus "?thesis" (*goal: ‹(4::real) < (L::real)›*) using "2" (*‹((l::real) < (L::real)) = (sqrt ((6::real) * (x::real) - (3::real)) + (l_0::real) < sqrt ((8::real) * x - (8::real)))›*) "3" (*‹(sqrt (6 * x - 3) + l_0 < sqrt (8 * x - 8)) = (2 * l_0 * sqrt (6 * x - 3) < 2 * x - l_0² - 5)›*) ‹(2 * l_0 * sqrt (6 * x - 3) < 2 * x - l_0² - 5) = (0 < 4 * x * (x - (7 * l_0² + 5)) + (l_0² + 5)² + 12 * l_0²)› (*‹(2 * l_0 * sqrt (6 * x - 3) < 2 * x - l_0² - 5) = (0 < 4 * x * (x - (7 * l_0² + 5)) + (l_0² + 5)² + 12 * l_0²)›*) l_def (*‹l = 4›*) by blast qed qed theorem interval_length_greater_than_lm: fixes m N :: real fixes L l :: real assumes "m ≥ 3" assumes "N ≥ 2*m" assumes "L = (2/3 + sqrt (8*N/m - 8)) - (1/2 + sqrt (6*N/m - 3))" shows "l ≥ 2 ∧ N ≥ 7*l^2*m^3 ⟹ L > l*m" proof (-) (*goal: ‹2 ≤ l ∧ 7 * l² * m ^ 3 ≤ N ⟹ l * m < L›*) assume asm: "l ≥ 2 ∧ N ≥ 7*l^2*m^3" (*‹(2::real) ≤ (l::real) ∧ (7::real) * l² * (m::real) ^ (3::nat) ≤ (N::real)›*) show "L > l*m" proof (-) (*goal: ‹l * m < L›*) from asm (*‹2 ≤ l ∧ 7 * l² * m ^ 3 ≤ N›*) have asm1: "l ≥ 2" and asm2: "N ≥ 7*l^2*m^3" apply - (*goals: 1. ‹2 ≤ l ∧ 7 * l² * m ^ 3 ≤ N ⟹ 2 ≤ l› 2. ‹2 ≤ l ∧ 7 * l² * m ^ 3 ≤ N ⟹ 7 * l² * m ^ 3 ≤ N› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . define x :: real where "x = N / m" define l_0 :: real where "l_0 = l*m - 1/6" have "l_0 > 0" using l_0_def (*‹l_0 = l * m - 1 / 6›*) asm1 (*‹2 ≤ l›*) assms(1) (*‹3 ≤ m›*) by (smt (verit, ccfv_threshold) le_divide_eq_1 (*‹((1::?'a::linordered_field) ≤ (?b::?'a::linordered_field) / (?a::?'a::linordered_field)) = ((0::?'a::linordered_field) < ?a ∧ ?a ≤ ?b ∨ ?a < (0::?'a::linordered_field) ∧ ?b ≤ ?a)›*) mult_le_cancel_left2 (*‹((?c::?'a::linordered_idom) * (?a::?'a::linordered_idom) ≤ ?c) = (((0::?'a::linordered_idom) < ?c ⟶ ?a ≤ (1::?'a::linordered_idom)) ∧ (?c < (0::?'a::linordered_idom) ⟶ (1::?'a::linordered_idom) ≤ ?a))›*) of_int_le_1_iff (*‹(of_int (?z::int) ≤ (1::?'a::linordered_idom)) = (?z ≤ (1::int))›*)) have 0: "x ≥ 2" using x_def (*‹x = N / m›*) assms(1,2) (*‹3 ≤ m› ‹2 * m ≤ N›*) by (simp add: pos_le_divide_eq (*‹0 < ?c ⟹ (?a ≤ ?b / ?c) = (?a * ?c ≤ ?b)›*)) have 1: "L = sqrt (8*x - 8) - sqrt (6*x - 3) + 1/6" by (auto simp add: x_def (*‹x = N / m›*) assms( (*‹L = 2 / 3 + sqrt (8 * N / m - 8) - (1 / 2 + sqrt (6 * N / m - 3))›*) 3)) hence 2: "L > l*m ⟷ sqrt (8*x - 8) > sqrt (6*x - 3) + l_0" by (auto simp add: l_0_def (*‹l_0 = l * m - 1 / 6›*)) have 3: "sqrt (8*x - 8) > sqrt (6*x - 3) + l_0 ⟷ 2*x - l_0^2 - 5 > 2*l_0 * sqrt (6*x - 3)" proof (standard) (*goals: 1. ‹sqrt (6 * x - 3) + l_0 < sqrt (8 * x - 8) ⟹ 2 * l_0 * sqrt (6 * x - 3) < 2 * x - l_0² - 5› 2. ‹2 * l_0 * sqrt (6 * x - 3) < 2 * x - l_0² - 5 ⟹ sqrt (6 * x - 3) + l_0 < sqrt (8 * x - 8)›*) assume "sqrt (8*x - 8) > sqrt (6*x - 3) + l_0" (*‹sqrt ((6::real) * (x::real) - (3::real)) + (l_0::real) < sqrt ((8::real) * x - (8::real))›*) hence "(sqrt (8*x - 8))^2 > (sqrt (6*x - 3) + l_0)^2" using l_0_def (*‹l_0 = l * m - 1 / 6›*) asm1 (*‹2 ≤ l›*) by (smt (verit, best) ‹0 < l_0› real_le_lsqrt (*‹⟦(0::real) ≤ (?y::real); (?x::real) ≤ ?y²⟧ ⟹ sqrt ?x ≤ ?y›*) real_sqrt_four (*‹sqrt (4::real) = (2::real)›*) real_sqrt_less_iff (*‹(sqrt (?x::real) < sqrt (?y::real)) = (?x < ?y)›*) real_sqrt_pow2_iff (*‹((sqrt (?x::real))² = ?x) = ((0::real) ≤ ?x)›*)) hence "8*x - 8 > 6*x - 3 + l_0^2 + 2* l_0 * sqrt (6*x - 3)" by (smt (verit, del_insts) "0" (*‹(2::real) ≤ (x::real)›*) power2_sum (*‹((?x::?'a) + (?y::?'a))² = ?x² + ?y² + (2::?'a) * ?x * ?y›*) real_sqrt_pow2_iff (*‹((sqrt (?x::real))² = ?x) = ((0::real) ≤ ?x)›*)) thus "2*x - l_0^2 - 5 > 2*l_0 * sqrt (6*x - 3)" by auto next (*goal: ‹2 * l_0 * sqrt (6 * x - 3) < 2 * x - l_0² - 5 ⟹ sqrt (6 * x - 3) + l_0 < sqrt (8 * x - 8)›*) assume "2*x - l_0^2 - 5 > 2*l_0 * sqrt (6*x - 3)" (*‹(2::real) * (l_0::real) * sqrt ((6::real) * (x::real) - (3::real)) < (2::real) * x - l_0² - (5::real)›*) hence "8*x - 8 > 6*x - 3 + l_0^2 + 2*l_0 * sqrt (6*x - 3)" by auto hence "(sqrt (8*x - 8))^2 > (sqrt (6*x - 3) + l_0)^2" by (smt (verit, del_insts) "0" (*‹2 ≤ x›*) power2_sum (*‹(?x + ?y)² = ?x² + ?y² + 2 * ?x * ?y›*) real_sqrt_pow2_iff (*‹((sqrt ?x)² = ?x) = (0 ≤ ?x)›*)) thus "sqrt (8*x - 8) > sqrt (6*x - 3) + l_0" using "0" (*‹2 ≤ x›*) real_less_rsqrt (*‹?x² < ?y ⟹ ?x < sqrt ?y›*) by force qed have "2*x - l_0^2 - 5 > 2*l_0 * sqrt (6*x - 3) ⟷ 4*x*(x - (7*l_0^2 + 5)) + (l_0^2 + 5)^2 + 12*l_0^2 > 0" proof (standard) (*goals: 1. ‹2 * l_0 * sqrt (6 * x - 3) < 2 * x - l_0² - 5 ⟹ 0 < 4 * x * (x - (7 * l_0² + 5)) + (l_0² + 5)² + 12 * l_0²› 2. ‹0 < 4 * x * (x - (7 * l_0² + 5)) + (l_0² + 5)² + 12 * l_0² ⟹ 2 * l_0 * sqrt (6 * x - 3) < 2 * x - l_0² - 5›*) assume "2*x - l_0^2 - 5 > 2*l_0 * sqrt (6*x - 3)" (*‹(2::real) * (l_0::real) * sqrt ((6::real) * (x::real) - (3::real)) < (2::real) * x - l_0² - (5::real)›*) have "(2*x - l_0^2 - 5)^2 > (2*l_0 * sqrt (6*x - 3))^2" using ‹0 < l_0› (*‹0 < l_0›*) by (smt (verit, ccfv_SIG) 0 (*‹2 ≤ x›*) ‹2 * l_0 * sqrt (6 * x - 3) < 2 * x - l_0² - 5› pos2 (*‹0 < 2›*) power_strict_mono (*‹⟦?a < ?b; 0 ≤ ?a; 0 < ?n⟧ ⟹ ?a ^ ?n < ?b ^ ?n›*) real_sqrt_ge_zero (*‹0 ≤ ?x ⟹ 0 ≤ sqrt ?x›*) zero_le_mult_iff (*‹(0 ≤ ?a * ?b) = (0 ≤ ?a ∧ 0 ≤ ?b ∨ ?a ≤ 0 ∧ ?b ≤ 0)›*)) thus "4*x*(x - (7*l_0^2 + 5)) + (l_0^2 + 5)^2 + 12*l_0^2 > 0" using "0" (*‹2 ≤ x›*) 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*) power2_eq_square (*‹(?a::?'a)² = ?a * ?a›*) power4_eq_xxxx (*‹(?x::?'a) ^ (4::nat) = ?x * ?x * ?x * ?x›*)) next (*goal: ‹0 < 4 * x * (x - (7 * l_0² + 5)) + (l_0² + 5)² + 12 * l_0² ⟹ 2 * l_0 * sqrt (6 * x - 3) < 2 * x - l_0² - 5›*) assume "4*x*(x - (7*l_0^2 + 5)) + (l_0^2 + 5)^2 + 12*l_0^2 > 0" (*‹(0::real) < (4::real) * (x::real) * (x - ((7::real) * (l_0::real)² + (5::real))) + (l_0² + (5::real))² + (12::real) * l_0²›*) hence "(2*x - l_0^2 - 5)^2 > (2*l_0 * sqrt (6*x - 3))^2" using "0" (*‹2 ≤ 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*) power2_eq_square (*‹?a² = ?a * ?a›*) power4_eq_xxxx (*‹?x ^ 4 = ?x * ?x * ?x * ?x›*)) have "m > 0" using assms(1) (*‹3 ≤ m›*) by simp hence "x ≥ 7*l^2*m^2" unfolding x_def (*goal: ‹7 * l² * m² ≤ N / m›*) using asm2 (*‹7 * l² * m ^ 3 ≤ N›*) assms(1) (*‹3 ≤ m›*) by (simp add: mult_imp_le_div_pos (*‹⟦0 < ?y; ?z * ?y ≤ ?x⟧ ⟹ ?z ≤ ?x / ?y›*) power2_eq_square (*‹?a² = ?a * ?a›*) power3_eq_cube (*‹?a ^ 3 = ?a * ?a * ?a›*)) hence 4: "2*x - l_0^2 - 5 ≥ 14*l^2*m^2 - (l*m-1/6)^2 - 5" by (simp add: x_def (*‹x = N / m›*) l_0_def (*‹l_0 = l * m - 1 / 6›*) power2_eq_square (*‹?a² = ?a * ?a›*)) have "(l*m-(1/6::real))^2 = (l*m)^2 - l*m/3 + (1/36::real)" apply (simp add: power2_eq_square (*‹?a² = ?a * ?a›*)) (*goal: ‹((l::real) * (m::real) - (1::real) / (6::real))² = (l * m)² - l * m / (3::real) + (1::real) / (36::real)›*) by argo hence "14*l^2*m^2 - (l*m-1/6)^2 - 5 = 14*l^2*m^2 - l^2*m^2 + l*m/3 - 1/36 - 5" using "4" (*‹14 * l² * m² - (l * m - 1 / 6)² - 5 ≤ 2 * x - l_0² - 5›*) by (auto simp add: power2_eq_square (*‹?a² = ?a * ?a›*)) hence "14*l^2*m^2 - l^2*m^2 + l*m/3 - 1/36 - 5 = 13*l^2*m^2 + l*m/3 - 1/36 - 5" by argo from asm1 (*‹2 ≤ l›*) assms(1) (*‹3 ≤ m›*) have 5: "l*m/3 > 0" by simp have "l > 0" using asm1 (*‹2 ≤ l›*) by auto hence "l*l ≥ 2*2" using asm1 (*‹2 ≤ l›*) mult_mono' (*‹⟦?a ≤ ?b; ?c ≤ ?d; 0 ≤ ?a; 0 ≤ ?c⟧ ⟹ ?a * ?c ≤ ?b * ?d›*) zero_le_numeral (*‹0 ≤ numeral ?n›*) by blast have "m > 0" using assms(1) (*‹3 ≤ m›*) by auto hence "m*m ≥ 3*3" by (metis assms( (*‹3 ≤ m›*) 1) less_eq_real_def (*‹(?x ≤ ?y) = (?x < ?y ∨ ?x = ?y)›*) mult_le_less_imp_less (*‹⟦?a ≤ ?b; ?c < ?d; 0 < ?a; 0 ≤ ?c⟧ ⟹ ?a * ?c < ?b * ?d›*) zero_less_numeral (*‹0 < numeral ?n›*)) hence "13*m*m - 1 ≥ 13*3*3-1" by simp have "3*3 > (0::real)" by auto hence "13*l*l*m*m ≥(13::real)*2*2*3*3" using ‹l*l ≥ 2*2› (*‹2 * 2 ≤ l * l›*) asm1 (*‹2 ≤ l›*) by (meson ‹0 < l› ‹0 < m› assms( (*‹3 ≤ m›*) 1) less_eq_real_def (*‹(?x ≤ ?y) = (?x < ?y ∨ ?x = ?y)›*) mult_mono (*‹⟦?a ≤ ?b; ?c ≤ ?d; 0 ≤ ?b; 0 ≤ ?c⟧ ⟹ ?a * ?c ≤ ?b * ?d›*) split_mult_pos_le (*‹0 ≤ ?a ∧ 0 ≤ ?b ∨ ?a ≤ 0 ∧ ?b ≤ 0 ⟹ 0 ≤ ?a * ?b›*) zero_le_numeral (*‹0 ≤ numeral ?n›*)) hence "13*l^2*m^2 + l*m/3 - 1/36 - 5 ≥ 13*2*2*3*3-1/36-(5::real)" using "5" (*‹0 < l * m / 3›*) by (auto simp add: power2_eq_square (*‹?a² = ?a * ?a›*)) have "13*3*3*3*3-1/36-(5::real) > 0" by auto hence "2*x - l_0^2 - 5 > 0" using "4" (*‹14 * l² * m² - (l * m - 1 / 6)² - 5 ≤ 2 * x - l_0² - 5›*) ‹13 * 2 * 2 * 3 * 3 - 1 / 36 - 5 ≤ 13 * l² * m² + l * m / 3 - 1 / 36 - 5› (*‹13 * 2 * 2 * 3 * 3 - 1 / 36 - 5 ≤ 13 * l² * m² + l * m / 3 - 1 / 36 - 5›*) ‹14 * l² * m² - (l * m - 1 / 6)² - 5 = 14 * l² * m² - l² * m² + l * m / 3 - 1 / 36 - 5› (*‹14 * l² * m² - (l * m - 1 / 6)² - 5 = 14 * l² * m² - l² * m² + l * m / 3 - 1 / 36 - 5›*) by force thus "2*x - l_0^2 - 5 > 2*l_0 * sqrt (6*x - 3)" by (smt (verit) ‹(2 * l_0 * sqrt (6 * x - 3))² < (2 * x - l_0² - 5)²› power_mono (*‹⟦?a ≤ ?b; 0 ≤ ?a⟧ ⟹ ?a ^ ?n ≤ ?b ^ ?n›*)) qed have "(1/6)^2 * (36::real) = 1" by (auto simp add: power2_eq_square (*‹(?a::?'a)² = ?a * ?a›*)) from assms(1) (*‹3 ≤ m›*) have "m > 0" by auto hence "x ≥ 7*l^2*m^2" unfolding x_def (*goal: ‹7 * l² * m² ≤ N / m›*) using asm2 (*‹(7::real) * (l::real)² * (m::real) ^ (3::nat) ≤ (N::real)›*) by (simp add: pos_le_divide_eq (*‹0 < ?c ⟹ (?a ≤ ?b / ?c) = (?a * ?c ≤ ?b)›*) power2_eq_square (*‹?a² = ?a * ?a›*) power3_eq_cube (*‹?a ^ 3 = ?a * ?a * ?a›*)) from asm1 (*‹2 ≤ l›*) have "l > 0" by auto from assms(1) (*‹(3::real) ≤ (m::real)›*) asm1 (*‹2 ≤ l›*) ‹m > 0› (*‹0 < m›*) ‹l > 0› (*‹(0::real) < (l::real)›*) have "l*m ≥ 2*(3::real)" by (metis mult_less_cancel_right (*‹(?a * ?c < ?b * ?c) = ((0 ≤ ?c ⟶ ?a < ?b) ∧ (?c ≤ 0 ⟶ ?b < ?a))›*) mult_mono (*‹⟦?a ≤ ?b; ?c ≤ ?d; 0 ≤ ?b; 0 ≤ ?c⟧ ⟹ ?a * ?c ≤ ?b * ?d›*) verit_comp_simplify1( (*‹(?a < ?a) = False›*) 1) verit_comp_simplify1( (*‹(¬ ?b' ≤ ?a') = (?a' < ?b')›*) 3) zero_le_numeral (*‹0 ≤ numeral ?n›*)) hence "-2*7*l*m/6 + 7*(1/6)*(1/6) + 5 < (0::real)" by simp hence "7*l^2*m^2 > 7*l_0^2 + (5::real)" unfolding l_0_def (*goal: ‹7 * (l * m - 1 / 6)² + 5 < 7 * l² * m²›*) apply (auto simp add: power2_eq_square (*‹(?a::?'a)² = ?a * ?a›*)) (*goal: ‹7 * (l * m - 1 / 6)² + 5 < 7 * l² * m²›*) by argo hence "x ≥ 7*l_0^2 + 5" using ‹7 * l² * m² ≤ x› (*‹7 * l² * m² ≤ x›*) by linarith hence "4*x*(x - (7*l_0^2 + 5)) + (l_0^2 + 5)^2 + 12*l_0^2 > 0" by (smt (verit) mult_nonneg_nonneg (*‹⟦0 ≤ ?a; 0 ≤ ?b⟧ ⟹ 0 ≤ ?a * ?b›*) power2_less_eq_zero_iff (*‹(?a² ≤ 0) = (?a = 0)›*) zero_le_power2 (*‹0 ≤ ?a²›*)) thus "?thesis" (*goal: ‹l * m < L›*) using "2" (*‹(l * m < L) = (sqrt (6 * x - 3) + l_0 < sqrt (8 * x - 8))›*) "3" (*‹(sqrt (6 * x - 3) + l_0 < sqrt (8 * x - 8)) = (2 * l_0 * sqrt (6 * x - 3) < 2 * x - l_0² - 5)›*) ‹(2 * l_0 * sqrt (6 * x - 3) < 2 * x - l_0² - 5) = (0 < 4 * x * (x - (7 * l_0² + 5)) + (l_0² + 5)² + 12 * l_0²)› (*‹(2 * l_0 * sqrt (6 * x - 3) < 2 * x - l_0² - 5) = (0 < 4 * x * (x - (7 * l_0² + 5)) + (l_0² + 5)² + 12 * l_0²)›*) by fastforce qed qed lemmas interval_length_greater_than_2m [simp] = interval_length_greater_than_lm [where l=2, simplified] subsection ‹ Lemma 1.11 in \cite{nathanson1996} › text ‹ We show Lemma 1.11 in \cite{nathanson1996} which is also known as Cauchy's Lemma.› theorem Cauchy_lemma: fixes m N a b r :: real assumes "m ≥ 3" "N ≥ 2*m" and "0 ≤ a" "0 ≤ b" "0 ≤ r" "r < m" and "N = m*(a - b)/2 + b + r" and "1/2 + sqrt (6*N/m - 3) ≤ b ∧ b ≤ 2/3 + sqrt (8*N/m - 8)" shows "b^2 < 4*a ∧ 3*a < b^2 + 2*b + 4" proof (-) (*goal: ‹b² < 4 * a ∧ 3 * a < b² + 2 * b + 4›*) from assms (*‹3 ≤ m› ‹2 * m ≤ N› ‹0 ≤ a› ‹(0::real) ≤ (b::real)› ‹0 ≤ r› ‹r < m› ‹N = m * (a - b) / 2 + b + r› ‹1 / 2 + sqrt (6 * N / m - 3) ≤ b ∧ b ≤ 2 / 3 + sqrt (8 * N / m - 8)›*) have asm1: "1/2 + sqrt (6*N/m - 3) ≤ b" and asm2: "b ≤ 2/3 + sqrt (8*N/m - 8)" apply - (*goals: 1. ‹⟦3 ≤ m; 2 * m ≤ N; 0 ≤ a; 0 ≤ b; 0 ≤ r; r < m; N = m * (a - b) / 2 + b + r; 1 / 2 + sqrt (6 * N / m - 3) ≤ b ∧ b ≤ 2 / 3 + sqrt (8 * N / m - 8)⟧ ⟹ 1 / 2 + sqrt (6 * N / m - 3) ≤ b› 2. ‹⟦3 ≤ m; 2 * m ≤ N; 0 ≤ a; 0 ≤ b; 0 ≤ r; r < m; N = m * (a - b) / 2 + b + r; 1 / 2 + sqrt (6 * N / m - 3) ≤ b ∧ b ≤ 2 / 3 + sqrt (8 * N / m - 8)⟧ ⟹ b ≤ 2 / 3 + sqrt (8 * N / m - 8)› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . have "N - b - r = m*(a - b)/2" using assms(7) (*‹N = m * (a - b) / 2 + b + r›*) by simp hence "a = (N - b - r)*2/m + b" using assms(1) (*‹3 ≤ m›*) by simp hence "a = b - 2/m * b + 2 * (N - r)/m" apply (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*)) (*goal: ‹a = b - 2 / m * b + 2 * (N - r) / m›*) by (smt (verit, del_insts) add_divide_distrib (*‹(?a + ?b) / ?c = ?a / ?c + ?b / ?c›*)) hence a: "a = b*(1 - 2/m) + 2*(N - r)/m" by (simp add: right_diff_distrib' (*‹?a * (?b - ?c) = ?a * ?b - ?a * ?c›*)) have "b^2 < 4*a" proof (-) (*goal: ‹(b::real)² < (4::real) * (a::real)›*) from a (*‹a = b * (1 - 2 / m) + 2 * (N - r) / m›*) have 0: "b^2 - 4*a = b^2 - 4*(1 - 2/m)*b - 8*(N-r)/m" by simp have "3/m ≤ 1" using assms(1) (*‹3 ≤ m›*) by simp hence 1: "2/3 ≤ 2*(1 - 2/m)" by simp have "N/m - 1 < N/m - r/m" using assms(1,6) (*‹(3::real) ≤ (m::real)› ‹r < m›*) by simp hence "sqrt(8*(N/m - 1)) < sqrt (8*((N - r)/m))" by (simp add: diff_divide_distrib (*‹(?a - ?b) / ?c = ?a / ?c - ?b / ?c›*)) hence 2: "sqrt(8*N/m - 8) < sqrt (8*((N - r)/m))" by simp have "2/3 + sqrt (8*N/m - 8) < 2*(1 - 2/m) + sqrt (8*((N-r)/m))" using "1" (*‹2 / 3 ≤ 2 * (1 - 2 / m)›*) "2" (*‹sqrt (8 * N / m - 8) < sqrt (8 * ((N - r) / m))›*) by linarith hence "b < 2*(1-2/m) + sqrt (8*(N - r)/m)" using asm2 (*‹b ≤ 2 / 3 + sqrt (8 * N / m - 8)›*) by simp hence 3: "b < 2*(1-2/m) + sqrt (4*(1-2/m)^2 + 8*(N - r)/m)" by (smt (verit, best) power2_less_0 (*‹¬ ?a² < 0›*) real_sqrt_le_iff (*‹(sqrt ?x ≤ sqrt ?y) = (?x ≤ ?y)›*)) define r1 where "r1 = 2*(1-2/m) - sqrt (4*(1-2/m)^2 + 8*(N - r)/m)" define r2 where "r2 = 2*(1-2/m) + sqrt (4*(1-2/m)^2 + 8*(N - r)/m)" have "r1*r2 = (2*(1-2/m) - sqrt (4*(1-2/m)^2 + 8*(N - r)/m))*(2*(1-2/m) + sqrt (4*(1-2/m)^2 + 8*(N - r)/m))" using r1_def (*‹r1 = 2 * (1 - 2 / m) - sqrt (4 * (1 - 2 / m)² + 8 * (N - r) / m)›*) r2_def (*‹r2 = 2 * (1 - 2 / m) + sqrt (4 * (1 - 2 / m)² + 8 * (N - r) / m)›*) by simp hence "r1*r2 = 2*(1-2/m)*(2*(1-2/m) + sqrt (4*(1-2/m)^2 + 8*(N - r)/m)) - sqrt (4*(1-2/m)^2 + 8*(N - r)/m)*(2*(1-2/m) + sqrt (4*(1-2/m)^2 + 8*(N - r)/m))" by (simp add: Rings.ring_distribs( (*‹(?a - ?b) * ?c = ?a * ?c - ?b * ?c›*) 3)) hence "r1*r2 = (2*(1-2/m))^2+2*(1-2/m)* sqrt (4*(1-2/m)^2 + 8*(N - r)/m) - 2*(1-2/m)* sqrt (4*(1-2/m)^2 + 8*(N - r)/m) - (sqrt (4*(1-2/m)^2 + 8*(N - r)/m))^2" by (simp add: distrib_left (*‹?a * (?b + ?c) = ?a * ?b + ?a * ?c›*) power2_eq_square (*‹?a² = ?a * ?a›*)) hence "r1*r2 = (2*(1-2/m))^2 -(sqrt (4*(1-2/m)^2 + 8*(N - r)/m))^2" by simp hence "r1 * r2 = 4*(1-2/m)^2 - 4*(1-2/m)^2 - 8*(N - r)/m" using assms(1) (*‹(3::real) ≤ (m::real)›*) assms(2) (*‹2 * m ≤ N›*) assms(6) (*‹r < m›*) four_x_squared (*‹(4::real) * (?x::real)² = ((2::real) * ?x)²›*) by (smt (verit) divide_nonneg_nonneg (*‹⟦0 ≤ ?x; 0 ≤ ?y⟧ ⟹ 0 ≤ ?x / ?y›*) real_sqrt_pow2_iff (*‹((sqrt ?x)² = ?x) = (0 ≤ ?x)›*) zero_compare_simps( (*‹0 ≤ ?a²›*) 12)) hence r1_times_r2: "r1*r2 = -8*(N-r)/m" by linarith have "(b-r1)*(b-r2) = b*(b-r2) - r1*(b-r2)" using cross3_simps(28) (*‹((?a::?'a) - (?b::?'a)) * (?c::?'a) = ?a * ?c - ?b * ?c›*) by blast hence "(b-r1)*(b-r2) = b^2-b*r2-b*r1+r1*r2" by (simp add: power2_eq_square (*‹?a² = ?a * ?a›*) right_diff_distrib (*‹?a * (?b - ?c) = ?a * ?b - ?a * ?c›*)) hence "(b-r1)*(b-r2) = b^2-b*(2*(1-2/m) + sqrt (4*(1-2/m)^2 + 8*(N - r)/m))-b*(2*(1-2/m) - sqrt (4*(1-2/m)^2 + 8*(N - r)/m))+r1*r2" using r1_def (*‹(r1::real) = (2::real) * ((1::real) - (2::real) / (m::real)) - sqrt ((4::real) * ((1::real) - (2::real) / m)² + (8::real) * ((N::real) - (r::real)) / m)›*) r2_def (*‹r2 = 2 * (1 - 2 / m) + sqrt (4 * (1 - 2 / m)² + 8 * (N - r) / m)›*) by simp hence "(b-r1)*(b-r2) = b^2-b*2*(1-2/m)-b* sqrt (4*(1-2/m)^2 + 8*(N - r)/m)-b*(2*(1-2/m) - sqrt (4*(1-2/m)^2 + 8*(N - r)/m)) +r1*r2" by (simp add: distrib_left (*‹?a * (?b + ?c) = ?a * ?b + ?a * ?c›*)) hence "(b-r1)*(b-r2) = b^2-b*2*(1-2/m)-b* sqrt (4*(1-2/m)^2 + 8*(N - r)/m)-b*2*(1-2/m)+b* sqrt (4*(1-2/m)^2 + 8*(N - r)/m)+r1*r2" by (simp add: Rings.ring_distribs( (*‹?a * (?b - ?c) = ?a * ?b - ?a * ?c›*) 4)) hence "(b-r1)*(b-r2) = b^2-b*4*(1-2/m)+r1*r2" by simp hence "(b-r1)*(b-r2) = b^2 - 4*(1 - 2/m)*b - 8*(N-r)/m" using r1_times_r2 (*‹r1 * r2 = - 8 * (N - r) / m›*) by (simp add: ‹r1 * r2 = 4 * (1 - 2 / m)² - 4 * (1 - 2 / m)² - 8 * (N - r) / m›) hence "b^2 - 4*(1 - 2/m)*b - 8*(N-r)/m < 0" using "3" (*‹b < 2 * (1 - 2 / m) + sqrt (4 * (1 - 2 / m)² + 8 * (N - r) / m)›*) assms(4) (*‹0 ≤ b›*) by (smt (verit, del_insts) ‹r1 * r2 = 4 * (1 - 2 / m)² - 4 * (1 - 2 / m)² - 8 * (N - r) / m› assms( (*‹(3::real) ≤ (m::real)›*) 1) assms( (*‹(2::real) * (m::real) ≤ (N::real)›*) 2) assms( (*‹(r::real) < (m::real)›*) 6) divide_pos_pos (*‹⟦(0::?'a) < (?x::?'a); (0::?'a) < (?y::?'a)⟧ ⟹ (0::?'a) < ?x / ?y›*) mult_nonneg_nonneg (*‹⟦(0::?'a) ≤ (?a::?'a); (0::?'a) ≤ (?b::?'a)⟧ ⟹ (0::?'a) ≤ ?a * ?b›*) mult_pos_neg (*‹⟦(0::?'a) < (?a::?'a); (?b::?'a) < (0::?'a)⟧ ⟹ ?a * ?b < (0::?'a)›*) r2_def (*‹(r2::real) = (2::real) * ((1::real) - (2::real) / (m::real)) + sqrt ((4::real) * ((1::real) - (2::real) / m)² + (8::real) * ((N::real) - (r::real)) / m)›*)) thus "?thesis" (*goal: ‹b² < 4 * a›*) using "0" (*‹b² - 4 * a = b² - 4 * (1 - 2 / m) * b - 8 * (N - r) / m›*) by simp qed have "3*a < b^2 + 2*b + 4" proof (-) (*goal: ‹3 * a < b² + 2 * b + 4›*) from a (*‹a = b * (1 - 2 / m) + 2 * (N - r) / m›*) have 4: "b^2 + 2*b + 4 - 3*a = b^2 - (1-6/m)*b - (6*(N-r)/m - 4)" by argo have 5: "1/2 > 1/2 - 3/m" using assms(1) (*‹3 ≤ m›*) by simp hence "1/2 - 3/m < 1" by linarith also (*calculation: ‹1 / 2 - 3 / m < 1›*) have "1/2 - 3/m > -1" using assms(1) (*‹3 ≤ m›*) by (smt (verit) divide_le_0_1_iff (*‹(1 / ?a ≤ 0) = (?a ≤ 0)›*) less_divide_eq_1_pos (*‹0 < ?a ⟹ (1 < ?b / ?a) = (?a < ?b)›*)) hence "(1/2 - 3/m)^2 < 1" by (metis (no_types, opaque_lifting) calculation (*‹1 / 2 - 3 / m < 1›*) less_eq_real_def (*‹(?x ≤ ?y) = (?x < ?y ∨ ?x = ?y)›*) power2_eq_1_iff (*‹(?a² = 1) = (?a = 1 ∨ ?a = - 1)›*) square_le_1 (*‹⟦- 1 ≤ ?x; ?x ≤ 1⟧ ⟹ ?x² ≤ 1›*) verit_comp_simplify1( (*‹(¬ ?b' ≤ ?a') = (?a' < ?b')›*) 3)) hence 6: "sqrt (6*N/m - 3) > sqrt ((1/2 - 3/m)^2 + 6*N/m - 4)" using assms(1) (*‹3 ≤ m›*) by simp from asm1 (*‹1 / 2 + sqrt (6 * N / m - 3) ≤ b›*) "5" (*‹1 / 2 - 3 / m < 1 / 2›*) "6" (*‹sqrt (((1::real) / (2::real) - (3::real) / (m::real))² + (6::real) * (N::real) / m - (4::real)) < sqrt ((6::real) * N / m - (3::real))›*) have "b > (1/2 - 3/m) + sqrt ((1/2 - 3/m)^2 + 6*N/m - 4)" by linarith hence 7: "b > (1/2 - 3/m) + sqrt ((1/2 - 3/m)^2 + 6*(N - r)/m - 4)" by (smt (verit, ccfv_SIG) assms( (*‹(3::real) ≤ (m::real)›*) 1) assms( (*‹(0::real) ≤ (r::real)›*) 5) divide_right_mono (*‹⟦(?a::?'a::linordered_field) ≤ (?b::?'a::linordered_field); (0::?'a::linordered_field) ≤ (?c::?'a::linordered_field)⟧ ⟹ ?a / ?c ≤ ?b / ?c›*) real_sqrt_le_mono (*‹(?x::real) ≤ (?y::real) ⟹ sqrt ?x ≤ sqrt ?y›*)) define s1 where "s1 = (1/2 - 3/m) - sqrt ((1/2 - 3/m)^2 + 6*(N - r)/m - 4)" define s2 where "s2 = (1/2 - 3/m) + sqrt ((1/2 - 3/m)^2 + 6*(N - r)/m - 4)" have "s1* s2=(1/2-3/m)*((1/2 - 3/m) + sqrt ((1/2 - 3/m)^2 + 6*(N - r)/m - 4))- sqrt ((1/2 - 3/m)^2 + 6*(N - r)/m - 4)*((1/2 - 3/m) + sqrt ((1/2 - 3/m)^2 + 6*(N - r)/m - 4))" using s1_def (*‹(s1::real) = (1::real) / (2::real) - (3::real) / (m::real) - sqrt (((1::real) / (2::real) - (3::real) / m)² + (6::real) * ((N::real) - (r::real)) / m - (4::real))›*) s2_def (*‹s2 = 1 / 2 - 3 / m + sqrt ((1 / 2 - 3 / m)² + 6 * (N - r) / m - 4)›*) Rings.ring_distribs(3) (*‹(?a - ?b) * ?c = ?a * ?c - ?b * ?c›*) by blast hence "s1* s2= (1/2-3/m)^2+(1/2-3/m)* sqrt ((1/2 - 3/m)^2 + 6*(N - r)/m - 4)- sqrt ((1/2 - 3/m)^2 + 6*(N - r)/m - 4)*((1/2 - 3/m) + sqrt ((1/2 - 3/m)^2 + 6*(N - r)/m - 4))" by (simp add: nat_distrib( (*‹?a * (?b + ?c) = ?a * ?b + ?a * ?c›*) 2) power2_eq_square (*‹?a² = ?a * ?a›*)) hence "s1* s2= (1/2-3/m)^2+(1/2-3/m)* sqrt ((1/2 - 3/m)^2 + 6*(N - r)/m - 4)- (1/2-3/m)* sqrt ((1/2 - 3/m)^2 + 6*(N - r)/m - 4) - (sqrt ((1/2 - 3/m)^2 + 6*(N - r)/m - 4))^2" by (smt (verit, ccfv_SIG) Groups.mult_ac( (*‹(?a::?'a) * (?b::?'a) = ?b * ?a›*) 2) Rings.ring_distribs( (*‹((?a::?'a) - (?b::?'a)) * (?c::?'a) = ?a * ?c - ?b * ?c›*) 3) power2_eq_square (*‹(?a::?'a)² = ?a * ?a›*)) hence 8: "s1* s2=(1/2-3/m)^2- (sqrt ((1/2 - 3/m)^2 + 6*(N - r)/m - 4))^2" by simp from assms(1,6) (*‹3 ≤ m› ‹(r::real) < (m::real)›*) have "-r/m > -1" by simp hence "-6*r/m > -6" by simp hence "12 - 4 - 6*r/m > 0" by simp hence "12*m/m - 6*r/m - 4 > 0" using assms(1) (*‹3 ≤ m›*) by simp hence "6*(2*m - r)/m - 4 > 0" by argo hence "6*(N - r)/m - 4 > 0" using assms(1,2) (*‹(3::real) ≤ (m::real)› ‹2 * m ≤ N›*) by (smt (verit, best) divide_right_mono (*‹⟦?a ≤ ?b; 0 ≤ ?c⟧ ⟹ ?a / ?c ≤ ?b / ?c›*)) hence "s1 * s2 = (1/2 - 3/m)^2 - (1/2 - 3/m)^2 - 6*(N - r)/m + 4" using "8" (*‹s1 * s2 = (1 / 2 - 3 / m)² - (sqrt ((1 / 2 - 3 / m)² + 6 * (N - r) / m - 4))²›*) by (smt (verit) real_sqrt_pow2_iff (*‹((sqrt ?x)² = ?x) = (0 ≤ ?x)›*) zero_le_power2 (*‹0 ≤ ?a²›*)) have "(b-s1)*(b-s2) = b*(b-s2) - s1*(b-s2)" using cross3_simps(28) (*‹(?a - ?b) * ?c = ?a * ?c - ?b * ?c›*) by blast hence "(b-s1)*(b-s2) = b^2-b* s2-b* s1+s1* s2" by (simp add: power2_eq_square (*‹?a² = ?a * ?a›*) right_diff_distrib (*‹?a * (?b - ?c) = ?a * ?b - ?a * ?c›*)) hence "(b-s1)*(b-s2) = b^2-b*((1/2 - 3/m) + sqrt ((1/2 - 3/m)^2 + 6*(N - r)/m - 4))-b*((1/2 - 3/m) - sqrt ((1/2 - 3/m)^2 + 6*(N - r)/m - 4)) + s1* s2" using s1_def (*‹s1 = 1 / 2 - 3 / m - sqrt ((1 / 2 - 3 / m)² + 6 * (N - r) / m - 4)›*) s2_def (*‹s2 = 1 / 2 - 3 / m + sqrt ((1 / 2 - 3 / m)² + 6 * (N - r) / m - 4)›*) by simp hence "(b-s1)*(b-s2) = b^2-b*(1/2 - 3/m)-b* sqrt ((1/2 - 3/m)^2 + 6*(N - r)/m - 4)-b*((1/2 - 3/m) - sqrt ((1/2 - 3/m)^2 + 6*(N - r)/m - 4)) + s1* s2" by (simp add: nat_distrib( (*‹?a * (?b + ?c) = ?a * ?b + ?a * ?c›*) 2)) hence "(b-s1)*(b-s2) = b^2-b*(1/2 - 3/m)-b* sqrt ((1/2 - 3/m)^2 + 6*(N - r)/m - 4)-b*(1/2 - 3/m)+b* sqrt ((1/2 - 3/m)^2 + 6*(N - r)/m-4)+s1* s2" by (smt (verit, ccfv_SIG) nat_distrib( (*‹?a * (?b + ?c) = ?a * ?b + ?a * ?c›*) 2)) hence "(b-s1)*(b-s2) = b^2-2*b*(1/2 - 3/m)+s1* s2" by simp hence "(b-s1)*(b-s2) = b^2-2*b*(1/2 - 3/m)+ (1/2 - 3/m)^2 - (1/2 - 3/m)^2 - 6*(N - r)/m + 4" using ‹s1 * s2 = (1 / 2 - 3 / m)² - (1 / 2 - 3 / m)² - 6 * (N - r) / m + 4› (*‹s1 * s2 = (1 / 2 - 3 / m)² - (1 / 2 - 3 / m)² - 6 * (N - r) / m + 4›*) by fastforce hence "(b-s1)*(b-s2) = b^2-2*b*(1/2-3/m)- 6*(N - r)/m + 4" by simp hence "(b-s1)*(b-s2) = b^2-b*(1-6/m)- 6*(N - r)/m + 4" by simp hence "(b-s1)*(b-s2) = b^2-b*(1-6/m)- (6*(N - r)/m - 4)" by simp hence "b^2 - (1-6/m)*b - (6*(N-r)/m - 4) > 0" using "7" (*‹1 / 2 - 3 / m + sqrt ((1 / 2 - 3 / m)² + 6 * (N - r) / m - 4) < b›*) by (smt (verit, del_insts) "8" (*‹(s1::real) * (s2::real) = ((1::real) / (2::real) - (3::real) / (m::real))² - (sqrt (((1::real) / (2::real) - (3::real) / m)² + (6::real) * ((N::real) - (r::real)) / m - (4::real)))²›*) Groups.mult_ac( (*‹(?a::?'a) * (?b::?'a) = ?b * ?a›*) 2) ‹s1 * s2 = (1 / 2 - 3 / m)² - (1 / 2 - 3 / m)² - 6 * (N - r) / m + 4› real_sqrt_ge_0_iff (*‹((0::real) ≤ sqrt (?y::real)) = ((0::real) ≤ ?y)›*) s1_def (*‹(s1::real) = (1::real) / (2::real) - (3::real) / (m::real) - sqrt (((1::real) / (2::real) - (3::real) / m)² + (6::real) * ((N::real) - (r::real)) / m - (4::real))›*) s2_def (*‹(s2::real) = (1::real) / (2::real) - (3::real) / (m::real) + sqrt (((1::real) / (2::real) - (3::real) / m)² + (6::real) * ((N::real) - (r::real)) / m - (4::real))›*) zero_compare_simps( (*‹((?a::?'a) * (?b::?'a) ≤ (0::?'a)) = ((0::?'a) ≤ ?a ∧ ?b ≤ (0::?'a) ∨ ?a ≤ (0::?'a) ∧ (0::?'a) ≤ ?b)›*) 8) zero_le_power2 (*‹(0::?'a) ≤ (?a::?'a)²›*)) thus "?thesis" (*goal: ‹3 * a < b² + 2 * b + 4›*) using "4" (*‹b² + 2 * b + 4 - 3 * a = b² - (1 - 6 / m) * b - (6 * (N - r) / m - 4)›*) by simp qed show "?thesis" (*goal: ‹b² < 4 * a ∧ 3 * a < b² + 2 * b + 4›*) by (simp add: ‹3 * a < b² + 2 * b + 4› ‹b² < 4 * a›) qed lemmas Cauchy_lemma_r_eq_zero = Cauchy_lemma [where r=0, simplified] subsection ‹ Lemma 1.12 in \cite{nathanson1996} › lemma not_one: fixes a b :: nat assumes "a≥1" assumes "b≥1" assumes "∃k1 :: nat. a = 2*k1+1" assumes "∃k2 :: nat. b = 2*k2+1" assumes "b^2 < 4*a" shows "4*a-b^2 ≠ 1" proof (standard) (*goal: ‹4 * a - b² = 1 ⟹ False›*) assume "4*a-b^2 = 1" (*‹(4::nat) * (a::nat) - (b::nat)² = (1::nat)›*) hence "b^2 = 4*a-1" by auto hence "b^2 mod 4 = (4*a-1) mod 4" by auto have "(4*a-1) mod 4 = 3 mod 4" using assms(1) (*‹1 ≤ a›*) by (simp add: mod_diff_eq_nat (*‹(?b::nat) ≤ (?a::nat) ⟹ (?a - ?b) mod (?m::nat) = (?m + ?a mod ?m - ?b mod ?m) mod ?m›*)) hence "b^2 mod 4 = 3" using ‹b^2 = 4*a-1› (*‹(b::nat)² = (4::nat) * (a::nat) - (1::nat)›*) mod_less (*‹?m < ?n ⟹ ?m mod ?n = ?m›*) by presburger thus False using assms (*‹1 ≤ a› ‹1 ≤ b› ‹∃k1. a = 2 * k1 + 1› ‹∃k2. b = 2 * k2 + 1› ‹b² < 4 * a›*) by (metis One_nat_def (*‹(1::nat) = Suc (0::nat)›*) eq_numeral_Suc (*‹(numeral (?k::num) = Suc (?n::nat)) = (pred_numeral ?k = ?n)›*) insert_iff (*‹((?a::?'a) ∈ insert (?b::?'a) (?A::?'a set)) = (?a = ?b ∨ ?a ∈ ?A)›*) nat.simps( (*‹Suc (?x2.0::nat) ≠ (0::nat)›*) 3) power_two_mod_four (*‹(?n::nat)² mod (4::nat) ∈ {0::nat, 1::nat}›*) pred_numeral_simps( (*‹pred_numeral (num.Bit1 (?k::num)) = numeral (num.Bit0 ?k)›*) 3) singletonD (*‹(?b::?'a) ∈ {?a::?'a} ⟹ ?b = ?a›*)) qed lemma not_two: fixes a b :: nat assumes "a≥1" assumes "b≥1" assumes "∃k1 :: nat. a = 2*k1+1" assumes 1:"∃k2 :: nat. b = 2*k2+1" assumes "b^2 < 4*a" shows "4*a-b^2 ≠ 2" proof (standard) (*goal: ‹4 * a - b² = 2 ⟹ False›*) assume "4*a-b^2=2" (*‹(4::nat) * (a::nat) - (b::nat)² = (2::nat)›*) hence "b^2=4*a-2" by auto from "1" (*‹∃k2. b = 2 * k2 + 1›*) have 2: "¬ 2 dvd b^2" by auto have "2 dvd (4*a-2)" by auto thus False using ‹b^2=4*a-2› (*‹b² = 4 * a - 2›*) "2" (*‹odd ((b::nat)²)›*) by auto qed text ‹The following lemma shows that given odd positive integers $x,y,z$ and $b$, where $x \geq y \geq z$, we may pick a suitable integer $u$ where $u = z$ or $u = -z$, such that $b+x+y+u \equiv 0 \pmod{4}$.› lemma suit_z: fixes b x y z :: nat assumes "odd b ∧ odd x ∧ odd y ∧ odd z" assumes "x≥y ∧ y≥z" shows "∃ u :: int. (u=z ∨ u=-z) ∧ (b+x+y+u) mod 4 = 0" proof (-) (*goal: ‹∃u::int. (u = int (z::nat) ∨ u = - int z) ∧ (int ((b::nat) + (x::nat) + (y::nat)) + u) mod (4::int) = (0::int)›*) from assms (*‹odd b ∧ odd x ∧ odd y ∧ odd z› ‹(y::nat) ≤ (x::nat) ∧ (z::nat) ≤ y›*) have 0: "(b+x+y) mod 4 = 1 ∨ (b+x+y) mod 4 = 3" by (metis dvd_refl (*‹?a dvd ?a›*) even_add (*‹even (?a + ?b) = (even ?a = even ?b)›*) even_even_mod_4_iff (*‹even ?n = even (?n mod 4)›*) landau_product_preprocess( (*‹?a + 0 = ?a›*) 53) mod_exhaust_less_4 (*‹?m mod 4 = 0 ∨ ?m mod 4 = 1 ∨ ?m mod 4 = 2 ∨ ?m mod 4 = 3›*)) from assms (*‹odd b ∧ odd x ∧ odd y ∧ odd z› ‹y ≤ x ∧ z ≤ y›*) have 1: "z mod 4 = 1 ∨ z mod 4 = 3" by (metis dvd_0_right (*‹?a dvd 0›*) dvd_refl (*‹?a dvd ?a›*) even_even_mod_4_iff (*‹even ?n = even (?n mod 4)›*) mod_exhaust_less_4 (*‹?m mod 4 = 0 ∨ ?m mod 4 = 1 ∨ ?m mod 4 = 2 ∨ ?m mod 4 = 3›*)) have c1: "∃u1::int. (u1=z ∨ u1=-z) ∧ (b+x+y+u1) mod 4 = 0" if asm1: "(b+x+y) mod 4 = 1 ∧ z mod 4 = 3" proof (-) (*goal: ‹∃u1. (u1 = int z ∨ u1 = - int z) ∧ (int (b + x + y) + u1) mod 4 = 0›*) from asm1 (*‹(b + x + y) mod 4 = 1 ∧ z mod 4 = 3›*) have 2: "(b+x+y+z) mod 4 = 0" by (metis add_num_simps( (*‹num.One + num.One = num.Bit0 num.One›*) 1) add_num_simps( (*‹num.Bit1 ?m + num.One = num.Bit0 (?m + num.One)›*) 7) mod_add_eq (*‹(?a mod ?c + ?b mod ?c) mod ?c = (?a + ?b) mod ?c›*) mod_self (*‹?a mod ?a = 0›*) numeral_plus_one (*‹numeral ?n + 1 = numeral (?n + num.One)›*) one_plus_numeral_commute (*‹1 + numeral ?x = numeral ?x + 1›*)) define u1 :: int where "u1=z" show "∃u1::int. (u1=z ∨ u1=-z) ∧ (b+x+y+u1) mod 4 = 0" using "2" (*‹(b + x + y + z) mod 4 = 0›*) u1_def (*‹u1 = int z›*) by (metis Num.of_nat_simps( (*‹of_nat (?m + ?n) = of_nat ?m + of_nat ?n›*) 4) of_nat_0 (*‹of_nat 0 = 0›*) of_nat_numeral (*‹of_nat (numeral ?n) = numeral ?n›*) zmod_int (*‹int (?m mod ?n) = int ?m mod int ?n›*)) qed have c2: "∃u2::int.(u2=z ∨ u2=-z) ∧ (b+x+y+u2) mod 4 = 0" if asm2: "(b+x+y) mod 4 = 1 ∧ z mod 4 = 1" proof (-) (*goal: ‹∃u2. (u2 = int z ∨ u2 = - int z) ∧ (int (b + x + y) + u2) mod 4 = 0›*) from asm2 (*‹(b + x + y) mod 4 = 1 ∧ z mod 4 = 1›*) have 3: "(b+x+y-z) mod 4 = 0" by (metis assms( (*‹y ≤ x ∧ z ≤ y›*) 2) mod_eq_0_iff_dvd (*‹(?a mod ?b = 0) = (?b dvd ?a)›*) mod_eq_dvd_iff_nat (*‹?n ≤ ?m ⟹ (?m mod ?q = ?n mod ?q) = (?q dvd ?m - ?n)›*) trans_le_add2 (*‹?i ≤ ?j ⟹ ?i ≤ ?m + ?j›*)) define u2 :: int where "u2=-z" show "∃u2::int.(u2=z ∨ u2=-z) ∧ (b+x+y+u2) mod 4 = 0" using "3" (*‹((b::nat) + (x::nat) + (y::nat) - (z::nat)) mod (4::nat) = (0::nat)›*) u2_def (*‹u2 = - int z›*) by (metis Num.of_nat_simps( (*‹of_nat (1::nat) = (1::?'a::semiring_1)›*) 2) asm2 (*‹((b::nat) + (x::nat) + (y::nat)) mod (4::nat) = (1::nat) ∧ (z::nat) mod (4::nat) = (1::nat)›*) mod_0 (*‹(0::?'a::semiring_modulo_trivial) mod (?a::?'a::semiring_modulo_trivial) = (0::?'a::semiring_modulo_trivial)›*) mod_add_cong (*‹⟦(?a::?'a::euclidean_semiring_cancel) mod (?c::?'a::euclidean_semiring_cancel) = (?a'::?'a::euclidean_semiring_cancel) mod ?c; (?b::?'a::euclidean_semiring_cancel) mod ?c = (?b'::?'a::euclidean_semiring_cancel) mod ?c⟧ ⟹ (?a + ?b) mod ?c = (?a' + ?b') mod ?c›*) more_arith_simps( (*‹(?a::?'a::group_add) + - ?a = (0::?'a::group_add)›*) 4) of_nat_numeral (*‹of_nat (numeral (?n::num)) = numeral ?n›*) zmod_int (*‹int ((?m::nat) mod (?n::nat)) = int ?m mod int ?n›*)) qed have c3: "∃u3::int.(u3=z ∨ u3=-z) ∧ (b+x+y+u3) mod 4 = 0" if asm3: "(b+x+y) mod 4 = 3 ∧ z mod 4 = 1" proof (-) (*goal: ‹∃u3. (u3 = int z ∨ u3 = - int z) ∧ (int (b + x + y) + u3) mod 4 = 0›*) from asm3 (*‹(b + x + y) mod 4 = 3 ∧ z mod 4 = 1›*) have 4: "(b+x+y+z) mod 4 = 0" by (metis add_num_simps( (*‹num.One + num.One = num.Bit0 num.One›*) 1) add_num_simps( (*‹num.Bit1 ?m + num.One = num.Bit0 (?m + num.One)›*) 7) mod_add_eq (*‹(?a mod ?c + ?b mod ?c) mod ?c = (?a + ?b) mod ?c›*) mod_self (*‹?a mod ?a = 0›*) numeral_plus_one (*‹numeral ?n + 1 = numeral (?n + num.One)›*)) define u3 :: int where "u3=z" show "∃u3::int.(u3=z ∨ u3=-z) ∧ (b+x+y+u3) mod 4 = 0" using "4" (*‹(b + x + y + z) mod 4 = 0›*) u3_def (*‹u3 = int z›*) by (metis Num.of_nat_simps( (*‹of_nat (?m + ?n) = of_nat ?m + of_nat ?n›*) 4) of_nat_0 (*‹of_nat 0 = 0›*) of_nat_numeral (*‹of_nat (numeral ?n) = numeral ?n›*) zmod_int (*‹int (?m mod ?n) = int ?m mod int ?n›*)) qed have c4: "∃u4::int.(u4=z ∨ u4=-z) ∧ (b+x+y+u4) mod 4 = 0" if asm4: "(b+x+y) mod 4 = 3 ∧ z mod 4 = 3" proof (-) (*goal: ‹∃u4. (u4 = int z ∨ u4 = - int z) ∧ (int (b + x + y) + u4) mod 4 = 0›*) from asm4 (*‹(b + x + y) mod 4 = 3 ∧ z mod 4 = 3›*) have 5: "(b+x+y-z) mod 4 = 0" by (metis assms( (*‹(y::nat) ≤ (x::nat) ∧ (z::nat) ≤ y›*) 2) mod_eq_0_iff_dvd (*‹((?a::?'a) mod (?b::?'a) = (0::?'a)) = (?b dvd ?a)›*) mod_eq_dvd_iff_nat (*‹(?n::nat) ≤ (?m::nat) ⟹ (?m mod (?q::nat) = ?n mod ?q) = (?q dvd ?m - ?n)›*) trans_le_add2 (*‹(?i::nat) ≤ (?j::nat) ⟹ ?i ≤ (?m::nat) + ?j›*)) define u4 :: int where "u4=-z" show "∃u4::int.(u4=z ∨ u4=-z) ∧ (b+x+y+u4) mod 4 = 0" using "5" (*‹(b + x + y - z) mod 4 = 0›*) u4_def (*‹u4 = - int z›*) by (metis asm4 (*‹(b + x + y) mod 4 = 3 ∧ z mod 4 = 3›*) mod_0 (*‹0 mod ?a = 0›*) mod_add_cong (*‹⟦?a mod ?c = ?a' mod ?c; ?b mod ?c = ?b' mod ?c⟧ ⟹ (?a + ?b) mod ?c = (?a' + ?b') mod ?c›*) more_arith_simps( (*‹?a + - ?a = 0›*) 4) of_nat_numeral (*‹of_nat (numeral ?n) = numeral ?n›*) zmod_int (*‹int (?m mod ?n) = int ?m mod int ?n›*)) qed show "?thesis" (*goal: ‹∃u. (u = int z ∨ u = - int z) ∧ (int (b + x + y) + u) mod 4 = 0›*) using assms (*‹odd b ∧ odd x ∧ odd y ∧ odd z› ‹y ≤ x ∧ z ≤ y›*) "0" (*‹((b::nat) + (x::nat) + (y::nat)) mod (4::nat) = (1::nat) ∨ (b + x + y) mod (4::nat) = (3::nat)›*) "1" (*‹z mod 4 = 1 ∨ z mod 4 = 3›*) c1 (*‹(b + x + y) mod 4 = 1 ∧ z mod 4 = 3 ⟹ ∃u1. (u1 = int z ∨ u1 = - int z) ∧ (int (b + x + y) + u1) mod 4 = 0›*) c2 (*‹(b + x + y) mod 4 = 1 ∧ z mod 4 = 1 ⟹ ∃u2. (u2 = int z ∨ u2 = - int z) ∧ (int (b + x + y) + u2) mod 4 = 0›*) c3 (*‹(b + x + y) mod 4 = 3 ∧ z mod 4 = 1 ⟹ ∃u3. (u3 = int z ∨ u3 = - int z) ∧ (int (b + x + y) + u3) mod 4 = 0›*) c4 (*‹((b::nat) + (x::nat) + (y::nat)) mod (4::nat) = (3::nat) ∧ (z::nat) mod (4::nat) = (3::nat) ⟹ ∃u4::int. (u4 = int z ∨ u4 = - int z) ∧ (int (b + x + y) + u4) mod (4::int) = (0::int)›*) by auto qed lemma four_terms_bin_exp_allsum: fixes b s t u v :: int assumes "b = s+t+u+v" shows "b^2 = t^2+u^2+s^2+v^2+2*t*u+2 * s * v + 2*t * s + 2*t * v +2*u * s +2*u * v" proof (-) (*goal: ‹b² = t² + u² + s² + v² + 2 * t * u + 2 * s * v + 2 * t * s + 2 * t * v + 2 * u * s + 2 * u * v›*) from assms (*‹(b::int) = (s::int) + (t::int) + (u::int) + (v::int)›*) have "b^2 = (t+u)^2+(s+v)^2+2*(t+u)*(s+v)" by (smt (verit, best) power2_sum (*‹(?x + ?y)² = ?x² + ?y² + 2 * ?x * ?y›*)) hence b_simp1: "b^2 = (t^2+u^2+2*t*u) + (s^2+v^2+2 * s * v)+2*(t+u)*(s+v)" by (simp add: power2_sum (*‹((?x::?'a) + (?y::?'a))² = ?x² + ?y² + (2::?'a) * ?x * ?y›*)) have "2*(t+u)*(s+v) = 2*t * s + 2*t * v +2*u * s +2*u * v" using int_distrib(1) (*‹(?z1.0 + ?z2.0) * ?w = ?z1.0 * ?w + ?z2.0 * ?w›*) int_distrib(2) (*‹(?w::int) * ((?z1.0::int) + (?z2.0::int)) = ?w * ?z1.0 + ?w * ?z2.0›*) by force from this (*‹2 * (t + u) * (s + v) = 2 * t * s + 2 * t * v + 2 * u * s + 2 * u * v›*) b_simp1 (*‹(b::int)² = (t::int)² + (u::int)² + (2::int) * t * u + ((s::int)² + (v::int)² + (2::int) * s * v) + (2::int) * (t + u) * (s + v)›*) have b_expression: "b^2 = t^2+u^2+s^2+v^2+2*t*u+2 * s * v + 2*t * s + 2*t * v +2*u * s +2*u * v" by auto thus "?thesis" (*goal: ‹b² = t² + u² + s² + v² + 2 * t * u + 2 * s * v + 2 * t * s + 2 * t * v + 2 * u * s + 2 * u * v›*) by auto qed lemma four_terms_bin_exp_twodiff: fixes b s t u v :: int assumes "b = s+t-u-v" shows "b^2 = t^2+u^2+s^2+v^2-2*t*u-2 * s * v + 2*t * s - 2*t * v -2*u * s +2*u * v" proof (-) (*goal: ‹(b::int)² = (t::int)² + (u::int)² + (s::int)² + (v::int)² - (2::int) * t * u - (2::int) * s * v + (2::int) * t * s - (2::int) * t * v - (2::int) * u * s + (2::int) * u * v›*) from assms (*‹b = s + t - u - v›*) have "b^2 = (s-u)^2+(t-v)^2+2*(s-u)*(t-v)" by (smt (verit, best) power2_sum (*‹((?x::?'a) + (?y::?'a))² = ?x² + ?y² + (2::?'a) * ?x * ?y›*)) hence b_simp1: "b^2 = s^2+u^2-2 * s *u + t^2+v^2 - 2 * t * v + 2*(s-u)*(t-v)" by (simp add: power2_diff (*‹(?x - ?y)² = ?x² + ?y² - 2 * ?x * ?y›*)) have "2*(s-u)*(t-v) = 2* s * t - 2* s * v - 2*u*t+2*u * v" by (simp add: Rings.ring_distribs( (*‹(?a - ?b) * ?c = ?a * ?c - ?b * ?c›*) 3) Rings.ring_distribs( (*‹?a * (?b - ?c) = ?a * ?b - ?a * ?c›*) 4)) from this (*‹2 * (s - u) * (t - v) = 2 * s * t - 2 * s * v - 2 * u * t + 2 * u * v›*) b_simp1 (*‹b² = s² + u² - 2 * s * u + t² + v² - 2 * t * v + 2 * (s - u) * (t - v)›*) have b_expression: "b^2 = t^2+u^2+s^2+v^2-2*t*u-2 * s * v + 2*t * s - 2*t * v -2*u * s +2*u * v" by auto thus "?thesis" (*goal: ‹b² = t² + u² + s² + v² - 2 * t * u - 2 * s * v + 2 * t * s - 2 * t * v - 2 * u * s + 2 * u * v›*) by auto qed text‹If a quadratic with positive leading coefficient is always non-negative, its discriminant is non-positive.› lemma qua_disc: fixes a b c :: real assumes "a>0" assumes "∀x::real. a*x^2+b*x+c ≥0" shows "b^2 - 4*a*c ≤ 0" proof (-) (*goal: ‹b² - 4 * a * c ≤ 0›*) from assms (*‹0 < a› ‹∀x. 0 ≤ a * x² + b * x + c›*) have 0: "∀x::real. (a*x^2+b*x+c)/a ≥0" by simp from assms (*‹(0::real) < (a::real)› ‹∀x. 0 ≤ a * x² + b * x + c›*) have 1: "∀x::real.(b*x+c)/a = b/a*x+c/a" by (simp add: add_divide_distrib (*‹((?a::?'a::division_ring) + (?b::?'a::division_ring)) / (?c::?'a::division_ring) = ?a / ?c + ?b / ?c›*)) from assms (*‹0 < a› ‹∀x. 0 ≤ a * x² + b * x + c›*) have "∀x::real.(a*x^2+b*x+c)/a = x^2+(b*x+c)/a" by (simp add: is_num_normalize( (*‹?a + ?b + ?c = ?a + (?b + ?c)›*) 1)) from "1" (*‹∀x. (b * x + c) / a = b / a * x + c / a›*) this (*‹∀x. (a * x² + b * x + c) / a = x² + (b * x + c) / a›*) have "∀x::real.(a*x^2+b*x+c)/a = x^2+b/a*x+c/a" by simp hence atleastzero: "∀x::real. x^2+b/a*x+c/a ≥0" using "0" (*‹∀x. 0 ≤ (a * x² + b * x + c) / a›*) by simp from assms (*‹(0::real) < (a::real)› ‹∀x. 0 ≤ a * x² + b * x + c›*) have 2: "∀x::real. x^2+b/a*x+c/a = x^2+2*b/(2*a)*x+c/a+b^2/(4*a^2)-b^2/(4*a^2)" by simp have simp1: "∀x::real.(x+b/(2*a))^2 = x^2+2*b/(2*a)*x+(b/(2*a))^2" by (simp add: power2_sum (*‹(?x + ?y)² = ?x² + ?y² + 2 * ?x * ?y›*)) have "(b/(2*a))^2 = b^2/(4*a^2)" by (metis four_x_squared (*‹4 * ?x² = (2 * ?x)²›*) power_divide (*‹(?a / ?b) ^ ?n = ?a ^ ?n / ?b ^ ?n›*)) hence "∀x::real. x^2+b/a*x+c/a = (x+b/(2*a))^2+c/a-b^2/(4*a^2)" using "2" (*‹∀x. x² + b / a * x + c / a = x² + 2 * b / (2 * a) * x + c / a + b² / (4 * a²) - b² / (4 * a²)›*) simp1 (*‹∀x. (x + b / (2 * a))² = x² + 2 * b / (2 * a) * x + (b / (2 * a))²›*) by auto hence "∀x::real. (x+b/(2*a))^2+c/a-b^2/(4*a^2) ≥0" using atleastzero (*‹∀x. 0 ≤ x² + b / a * x + c / a›*) by presburger hence 3: "∀x::real. b^2/(4*a^2)-c/a≤(x+b/(2*a))^2" by (smt (verit, del_insts)) have "∃x::real. (x+b/(2*a))^2=0" by (metis diff_add_cancel (*‹?a - ?b + ?b = ?a›*) power_zero_numeral (*‹0 ^ numeral ?k = 0›*)) hence "b^2/(4*a^2)-c/a≤0" using "3" (*‹∀x. b² / (4 * a²) - c / a ≤ (x + b / (2 * a))²›*) by metis hence 4: "4*a^2*(b^2/(4*a^2)-c/a)≤0" using assms (*‹0 < a› ‹∀x. 0 ≤ a * x² + b * x + c›*) by (simp add: mult_nonneg_nonpos (*‹⟦0 ≤ ?a; ?b ≤ 0⟧ ⟹ ?a * ?b ≤ 0›*)) have 5: "4*a^2*b^2/(4*a^2) = b^2" using assms (*‹0 < a› ‹∀x. 0 ≤ a * x² + b * x + c›*) by simp have 6: "4*a^2*c/a = 4*a*c" using assms (*‹0 < a› ‹∀x. 0 ≤ a * x² + b * x + c›*) by (simp add: power2_eq_square (*‹?a² = ?a * ?a›*)) show "?thesis" (*goal: ‹b² - 4 * a * c ≤ 0›*) using "4" (*‹4 * a² * (b² / (4 * a²) - c / a) ≤ 0›*) "5" (*‹4 * a² * b² / (4 * a²) = b²›*) "6" (*‹4 * a² * c / a = 4 * a * c›*) assms (*‹0 < a› ‹∀x. 0 ≤ a * x² + b * x + c›*) by (simp add: Rings.ring_distribs( (*‹?a * (?b - ?c) = ?a * ?b - ?a * ?c›*) 4)) qed text‹The following lemma shows for any point on a 3D sphere with radius $a$, the sum of its coordinates lies between $\sqrt{3a}$ and $-\sqrt{3a}$.› lemma three_terms_Cauchy_Schwarz: fixes x y z a :: real assumes "a > 0" assumes "x^2+y^2+z^2 = a" shows "(x+y+z)≥-sqrt(3*a) ∧ (x+y+z)≤sqrt(3*a)" proof (-) (*goal: ‹- sqrt (3 * a) ≤ x + y + z ∧ x + y + z ≤ sqrt (3 * a)›*) have 1: "∀t::real. (t*x+1)^2 = t^2*x^2+1+2*t*x" by (simp add: power2_sum (*‹((?x::?'a) + (?y::?'a))² = ?x² + ?y² + (2::?'a) * ?x * ?y›*) power_mult_distrib (*‹((?a::?'a) * (?b::?'a)) ^ (?n::nat) = ?a ^ ?n * ?b ^ ?n›*)) have 2: "∀t::real. (t*y+1)^2 = t^2*y^2+1+2*t*y" by (simp add: power2_sum (*‹(?x + ?y)² = ?x² + ?y² + 2 * ?x * ?y›*) power_mult_distrib (*‹(?a * ?b) ^ ?n = ?a ^ ?n * ?b ^ ?n›*)) have 3: "∀t::real. (t*z+1)^2 = t^2*z^2+1+2*t*z" by (simp add: power2_sum (*‹(?x + ?y)² = ?x² + ?y² + 2 * ?x * ?y›*) power_mult_distrib (*‹(?a * ?b) ^ ?n = ?a ^ ?n * ?b ^ ?n›*)) from "1" (*‹∀t. (t * x + 1)² = t² * x² + 1 + 2 * t * x›*) "2" (*‹∀t. (t * y + 1)² = t² * y² + 1 + 2 * t * y›*) "3" (*‹∀t. (t * z + 1)² = t² * z² + 1 + 2 * t * z›*) have 4: "∀t::real.(t*x+1)^2+(t*y+1)^2+(t*z+1)^2 = t^2*x^2+1+2*t*x + t^2*y^2+1+2*t*y + t^2*z^2+1+2*t*z" by auto have "∀t::real. t^2*x^2+t^2*y^2=t^2*(x^2+y^2)" by (simp add: nat_distrib( (*‹?a * (?b + ?c) = ?a * ?b + ?a * ?c›*) 2)) hence 5: "∀t::real. t^2*x^2+t^2*y^2+t^2*z^2=t^2*(x^2+y^2+z^2)" by (metis nat_distrib( (*‹?a * (?b + ?c) = ?a * ?b + ?a * ?c›*) 2)) have 6: "∀t::real. 2*t*x+2*t*y+2*t*z = t*2*(x+y+z)" by (simp add: Groups.mult_ac( (*‹?a * ?b = ?b * ?a›*) 2) distrib_right (*‹(?a + ?b) * ?c = ?a * ?c + ?b * ?c›*)) from "4" (*‹∀t. (t * x + 1)² + (t * y + 1)² + (t * z + 1)² = t² * x² + 1 + 2 * t * x + t² * y² + 1 + 2 * t * y + t² * z² + 1 + 2 * t * z›*) "5" (*‹∀t. t² * x² + t² * y² + t² * z² = t² * (x² + y² + z²)›*) "6" (*‹∀t. 2 * t * x + 2 * t * y + 2 * t * z = t * 2 * (x + y + z)›*) have "∀t::real.(t*x+1)^2+(t*y+1)^2+(t*z+1)^2 = t^2*(x^2+y^2+z^2)+ t*2*(x+y+z)+3" by (smt (verit, best)) hence "∀t::real. t^2*(x^2+y^2+z^2)+ t*2*(x+y+z)+3 ≥0" by (metis add_nonneg_nonneg (*‹⟦0 ≤ ?a; 0 ≤ ?b⟧ ⟹ 0 ≤ ?a + ?b›*) zero_le_power2 (*‹0 ≤ ?a²›*)) hence "(2*(x+y+z))^2 - 12*(x^2+y^2+z^2)≤0" using qua_disc (*‹⟦0 < ?a; ∀x. 0 ≤ ?a * x² + ?b * x + ?c⟧ ⟹ ?b² - 4 * ?a * ?c ≤ 0›*) by (smt (z3) power2_diff (*‹(?x - ?y)² = ?x² + ?y² - 2 * ?x * ?y›*) power2_sum (*‹(?x + ?y)² = ?x² + ?y² + 2 * ?x * ?y›*) power_zero_numeral (*‹0 ^ numeral ?k = 0›*) sum_squares_bound (*‹2 * ?x * ?y ≤ ?x² + ?y²›*)) hence "12*(x^2+y^2+z^2)≥4*(x+y+z)^2" by (simp add: four_x_squared (*‹(4::real) * (?x::real)² = ((2::real) * ?x)²›*)) hence "3*a≥(x+y+z)^2" using assms (*‹0 < a› ‹x² + y² + z² = a›*) by auto thus "?thesis" (*goal: ‹- sqrt ((3::real) * (a::real)) ≤ (x::real) + (y::real) + (z::real) ∧ x + y + z ≤ sqrt ((3::real) * a)›*) by (smt (verit, del_insts) real_sqrt_abs (*‹sqrt (?x²) = ¦?x¦›*) real_sqrt_le_iff (*‹(sqrt ?x ≤ sqrt ?y) = (?x ≤ ?y)›*)) qed text‹We adapt the lemma above through changing the types for the convenience of our proof.› lemma three_terms_Cauchy_Schwarz_nat_ver: fixes x y z a :: nat assumes "a>0" assumes "x^2+y^2+z^2 = a" shows "(x+y+z)≥-sqrt(3*a) ∧ (x+y+z)≤sqrt(3*a)" proof (-) (*goal: ‹- sqrt (real (3 * a)) ≤ real (x + y + z) ∧ real (x + y + z) ≤ sqrt (real (3 * a))›*) have fac1: "real(x+y+z) = real x + real y + real z" by auto have fac2: "3*(real a) = real(3*a)" by auto thus "?thesis" (*goal: ‹- sqrt (real (3 * a)) ≤ real (x + y + z) ∧ real (x + y + z) ≤ sqrt (real (3 * a))›*) using fac1 (*‹real (x + y + z) = real x + real y + real z›*) three_terms_Cauchy_Schwarz (*‹⟦0 < ?a; ?x² + ?y² + ?z² = ?a⟧ ⟹ - sqrt (3 * ?a) ≤ ?x + ?y + ?z ∧ ?x + ?y + ?z ≤ sqrt (3 * ?a)›*) fac2 (*‹3 * real a = real (3 * a)›*) by (smt (verit) assms( (*‹0 < a›*) 1) assms( (*‹x² + y² + z² = a›*) 2) nat_less_real_le (*‹(?n < ?m) = (real ?n + 1 ≤ real ?m)›*) of_nat_0_le_iff (*‹0 ≤ of_nat ?n›*) of_nat_add (*‹of_nat (?m + ?n) = of_nat ?m + of_nat ?n›*) of_nat_power (*‹of_nat (?m ^ ?n) = of_nat ?m ^ ?n›*)) qed text‹This theorem is Lemma 1.12 in \cite{nathanson1996}, which shows for odd positive integers $a$ and $b$ satisfying certain properties, there exist four non-negative integers $s,t,u$ and $v$ such that $a = s^2+t^2+u^2+v^2$ and $b = s+t+u+v$. We use the Three Squares Theorem AFP entry \cite{Three_Squares-AFP}.› theorem four_nonneg_int_sum: fixes a b :: nat assumes "a≥1" assumes "b≥1" assumes "odd a" assumes "odd b" assumes 3:"b^2 < 4*a" assumes "3*a < b^2+2*b+4" shows "∃s t u v :: int. s ≥ 0 ∧ t ≥ 0 ∧ u ≥ 0 ∧ v ≥ 0 ∧ a = s^2 + t^2 + u^2 + v^2 ∧ b = s+t+u+v" proof (-) (*goal: ‹∃(s::int) (t::int) (u::int) v::int. (0::int) ≤ s ∧ (0::int) ≤ t ∧ (0::int) ≤ u ∧ (0::int) ≤ v ∧ int (a::nat) = s² + t² + u² + v² ∧ int (b::nat) = s + t + u + v›*) from assms (*‹1 ≤ a› ‹1 ≤ b› ‹odd a› ‹odd b› ‹b² < 4 * a› ‹(3::nat) * (a::nat) < (b::nat)² + (2::nat) * b + (4::nat)›*) have 0: "∃k1 :: nat. a = 2*k1+1" by (meson oddE (*‹⟦odd ?a; ⋀b. ?a = 2 * b + 1 ⟹ ?thesis⟧ ⟹ ?thesis›*)) from assms (*‹(1::nat) ≤ (a::nat)› ‹1 ≤ b› ‹odd a› ‹odd b› ‹b² < 4 * a› ‹(3::nat) * (a::nat) < (b::nat)² + (2::nat) * b + (4::nat)›*) have 1: "∃k2 :: nat. b = 2*k2+1" by (meson oddE (*‹⟦odd ?a; ⋀b. ?a = 2 * b + 1 ⟹ ?thesis⟧ ⟹ ?thesis›*)) from "0" (*‹∃k1. a = 2 * k1 + 1›*) have "4*a mod 8 = 4" by auto hence 2: "8 dvd (4*a-4)" by (metis dvd_minus_mod (*‹?b dvd ?a - ?a mod ?b›*)) obtain k2 where "b = 2*k2+1" (*goal: ‹(⋀k2. b = 2 * k2 + 1 ⟹ thesis) ⟹ thesis›*) using "1" (*‹∃k2. b = 2 * k2 + 1›*) by auto have "2 dvd k2*(k2+1)" by auto hence "8 dvd 4*k2*(k2+1)" by (metis ab_semigroup_mult_class.mult_ac( (*‹?a * ?b * ?c = ?a * (?b * ?c)›*) 1) mult_2_right (*‹?z * 2 = ?z + ?z›*) nat_mult_dvd_cancel_disj (*‹(?k * ?m dvd ?k * ?n) = (?k = 0 ∨ ?m dvd ?n)›*) numeral_Bit0 (*‹numeral (num.Bit0 ?n) = numeral ?n + numeral ?n›*)) hence "b^2 mod 8 = 1" using "1" (*‹∃k2. b = 2 * k2 + 1›*) by (metis One_nat_def (*‹1 = Suc 0›*) Suc_0_mod_numeral( (*‹Suc 0 mod numeral (num.Bit0 ?n) = 1›*) 2) assms( (*‹odd b›*) 4) square_mod_8_eq_1_iff (*‹[?x² = 1] (mod 8) = odd ?x›*) unique_euclidean_semiring_class.cong_def (*‹[?b = ?c] (mod ?a) = (?b mod ?a = ?c mod ?a)›*)) hence "8 dvd (b^2-1)" by (metis dvd_minus_mod (*‹?b dvd ?a - ?a mod ?b›*)) from "2" (*‹8 dvd 4 * a - 4›*) this (*‹8 dvd b² - 1›*) have "8 dvd ((4*a-4)-(b^2-1))" using dvd_diff_nat (*‹⟦(?k::nat) dvd (?m::nat); ?k dvd (?n::nat)⟧ ⟹ ?k dvd ?m - ?n›*) by blast from assms (*‹1 ≤ a› ‹1 ≤ b› ‹odd a› ‹odd b› ‹b² < 4 * a› ‹3 * a < b² + 2 * b + 4›*) "0" (*‹∃k1. a = 2 * k1 + 1›*) "1" (*‹∃k2. b = 2 * k2 + 1›*) this (*‹(8::nat) dvd (4::nat) * (a::nat) - (4::nat) - ((b::nat)² - (1::nat))›*) have 7: "8 dvd ((4*a-b^2)-3)" by auto from assms (*‹1 ≤ a› ‹1 ≤ b› ‹odd a› ‹odd b› ‹b² < 4 * a› ‹(3::nat) * (a::nat) < (b::nat)² + (2::nat) * b + (4::nat)›*) "0" (*‹∃k1::nat. (a::nat) = (2::nat) * k1 + (1::nat)›*) "1" (*‹∃k2. b = 2 * k2 + 1›*) have 5: "4*a-b^2≠1" using not_one (*‹⟦1 ≤ ?a; 1 ≤ ?b; ∃k1. ?a = 2 * k1 + 1; ∃k2. ?b = 2 * k2 + 1; ?b² < 4 * ?a⟧ ⟹ 4 * ?a - ?b² ≠ 1›*) by auto from assms (*‹1 ≤ a› ‹1 ≤ b› ‹odd a› ‹odd b› ‹b² < 4 * a› ‹3 * a < b² + 2 * b + 4›*) "0" (*‹∃k1. a = 2 * k1 + 1›*) "1" (*‹∃k2. b = 2 * k2 + 1›*) have 6: "4*a-b^2≠2" using not_two (*‹⟦1 ≤ ?a; 1 ≤ ?b; ∃k1. ?a = 2 * k1 + 1; ∃k2. ?b = 2 * k2 + 1; ?b² < 4 * ?a⟧ ⟹ 4 * ?a - ?b² ≠ 2›*) by auto from "3" (*‹b² < 4 * a›*) "5" (*‹(4::nat) * (a::nat) - (b::nat)² ≠ (1::nat)›*) "6" (*‹4 * a - b² ≠ 2›*) have "4*a-b^2 ≥ 3" by auto from this (*‹3 ≤ 4 * a - b²›*) "7" (*‹8 dvd 4 * a - b² - 3›*) have 8: "(4*a-b^2) mod 8 = 3" using mod_nat_eqI (*‹⟦?r < ?n; ?r ≤ ?m; ?n dvd ?m - ?r⟧ ⟹ ?m mod ?n = ?r›*) by presburger obtain j and k and l where ints: "odd j ∧ odd k ∧ odd l ∧ (4*a-b^2) = j^2+k^2+l^2" (*goal: ‹(⋀j k l. odd j ∧ odd k ∧ odd l ∧ 4 * a - b² = j² + k² + l² ⟹ thesis) ⟹ thesis›*) using "8" (*‹(4 * a - b²) mod 8 = 3›*) odd_three_squares_using_mod_eight (*‹?n mod 8 = 3 ⟹ ∃x₁ x₂ x₃. odd x₁ ∧ odd x₂ ∧ odd x₃ ∧ ?n = x₁² + x₂² + x₃²›*) by presburger define x where "x = sort[j,k,l] ! 2" define y where "y = sort[j,k,l] ! 1" define z where "z = sort[j,k,l] ! 0" have "x^2+y^2+z^2 = sum_list (map (λx. x^2) [j,k,l])" using x_def (*‹(x::nat) = sort [j::nat, k::nat, l::nat] ! (2::nat)›*) y_def (*‹y = sort [j, k, l] ! 1›*) z_def (*‹z = sort [j, k, l] ! 0›*) by auto from this (*‹x² + y² + z² = sum_list (map power2 [j, k, l])›*) ints (*‹odd j ∧ odd k ∧ odd l ∧ 4 * a - b² = j² + k² + l²›*) have a_and_b: "(4*a-b^2) = x^2+y^2+z^2" by auto have size: "x≥y ∧ y≥z" using x_def (*‹x = sort [j, k, l] ! 2›*) y_def (*‹y = sort [j, k, l] ! 1›*) z_def (*‹z = sort [j, k, l] ! 0›*) by auto have x_par: "x = j ∨ x = k ∨ x = l" using x_def (*‹x = sort [j, k, l] ! 2›*) by auto have y_par: "y = j ∨ y = k ∨ y = l" using y_def (*‹y = sort [j, k, l] ! 1›*) by auto have z_par: "z = j ∨ z = k ∨ z = l" using z_def (*‹(z::nat) = sort [j::nat, k::nat, l::nat] ! (0::nat)›*) by auto hence parity: "odd x ∧ odd y ∧ odd z" using ints (*‹odd j ∧ odd k ∧ odd l ∧ 4 * a - b² = j² + k² + l²›*) x_par (*‹x = j ∨ x = k ∨ x = l›*) y_par (*‹y = j ∨ y = k ∨ y = l›*) z_par (*‹(z::nat) = (j::nat) ∨ z = (k::nat) ∨ z = (l::nat)›*) by fastforce from "1" (*‹∃k2. b = 2 * k2 + 1›*) have b_par: "odd b" by auto obtain w :: int where w_def: "(w=z ∨ w=-z) ∧ (b+x+y+w) mod 4 = 0" (*goal: ‹(⋀w. (w = int z ∨ w = - int z) ∧ (int (b + x + y) + w) mod 4 = 0 ⟹ thesis) ⟹ thesis›*) using suit_z (*‹⟦odd ?b ∧ odd ?x ∧ odd ?y ∧ odd ?z; ?y ≤ ?x ∧ ?z ≤ ?y⟧ ⟹ ∃u. (u = int ?z ∨ u = - int ?z) ∧ (int (?b + ?x + ?y) + u) mod 4 = 0›*) size (*‹y ≤ x ∧ z ≤ y›*) parity (*‹odd x ∧ odd y ∧ odd z›*) b_par (*‹odd b›*) by presburger from parity (*‹odd x ∧ odd y ∧ odd z›*) have fac1: "(int z) mod 4 = 3 ∨ (int z) mod 4 = 1" by presburger from parity (*‹odd (x::nat) ∧ odd (y::nat) ∧ odd (z::nat)›*) have fac2: "-z mod 4 = 3 ∨ -z mod 4 = 1" by presburger from w_def (*‹(w = int z ∨ w = - int z) ∧ (int (b + x + y) + w) mod 4 = 0›*) have fac3: "w mod 4 = 3 ∨ w mod 4 = 1" using fac1 (*‹int z mod 4 = 3 ∨ int z mod 4 = 1›*) fac2 (*‹- int z mod 4 = 3 ∨ - int z mod 4 = 1›*) by auto have s_int: "4 dvd (b+x+y+w)" using b_par (*‹odd b›*) parity (*‹odd x ∧ odd y ∧ odd z›*) fac3 (*‹w mod 4 = 3 ∨ w mod 4 = 1›*) w_def (*‹(w = int z ∨ w = - int z) ∧ (int (b + x + y) + w) mod 4 = 0›*) by presburger have b_x_int: "2 dvd (b+x)" using b_par (*‹odd b›*) parity (*‹odd x ∧ odd y ∧ odd z›*) by presburger have b_y_int: "2 dvd (b+y)" using b_par (*‹odd b›*) parity (*‹odd x ∧ odd y ∧ odd z›*) by presburger have b_w_int: "2 dvd (b+w)" using b_par (*‹odd b›*) fac3 (*‹(w::int) mod (4::int) = (3::int) ∨ w mod (4::int) = (1::int)›*) by presburger obtain s :: int where s_def: "s = (b+x+y+w) div 4" (*goal: ‹(⋀s. s = (int (b + x + y) + w) div 4 ⟹ thesis) ⟹ thesis›*) using s_int (*‹4 dvd int (b + x + y) + w›*) by fastforce obtain t :: int where t_def: "t = (b+x) div 2 - s" (*goal: ‹(⋀t. t = int ((b + x) div 2) - s ⟹ thesis) ⟹ thesis›*) using s_int (*‹4 dvd int (b + x + y) + w›*) b_x_int (*‹even ((b::nat) + (x::nat))›*) by blast obtain u :: int where u_def: "u = (b+y) div 2 - s" (*goal: ‹(⋀u. u = int ((b + y) div 2) - s ⟹ thesis) ⟹ thesis›*) using s_int (*‹4 dvd int (b + x + y) + w›*) b_y_int (*‹even (b + y)›*) by blast obtain v :: int where v_def: "v = (b+w) div 2 - s" (*goal: ‹(⋀v. v = (int b + w) div 2 - s ⟹ thesis) ⟹ thesis›*) using s_int (*‹4 dvd int (b + x + y) + w›*) b_w_int (*‹even (int b + w)›*) by blast from t_def (*‹t = int ((b + x) div 2) - s›*) s_def (*‹s = (int (b + x + y) + w) div 4›*) have t_simp1: "t = (2*b+2*x) div 4 - (b+x+y+w) div 4" by auto have t_simp2: "(2* b+2* x) - (b+x+y+w) = b+x-y-w" using size (*‹y ≤ x ∧ z ≤ y›*) by auto hence t_expre: "t = (b+x-y-w) div 4" using t_simp1 (*‹(t::int) = int (((2::nat) * (b::nat) + (2::nat) * (x::nat)) div (4::nat)) - (int (b + x + (y::nat)) + (w::int)) div (4::int)›*) by (smt (verit, ccfv_SIG) add_num_simps( (*‹num.One + num.One = num.Bit0 num.One›*) 1) div_plus_div_distrib_dvd_right (*‹(?c::?'a) dvd (?b::?'a) ⟹ ((?a::?'a) + ?b) div ?c = ?a div ?c + ?b div ?c›*) numeral_Bit0 (*‹numeral (num.Bit0 (?n::num)) = numeral ?n + numeral ?n›*) of_nat_numeral (*‹of_nat (numeral (?n::num)) = numeral ?n›*) one_plus_numeral (*‹(1::?'a) + numeral (?n::num) = numeral (num.One + ?n)›*) s_int (*‹(4::int) dvd int ((b::nat) + (x::nat) + (y::nat)) + (w::int)›*) linordered_euclidean_semiring_class.of_nat_div (*‹of_nat ((?m::nat) div (?n::nat)) = of_nat ?m div of_nat ?n›*)) from b_x_int (*‹even ((b::nat) + (x::nat))›*) have "4 dvd (2*b+2*x)" by (metis distrib_left_numeral (*‹numeral ?v * (?b + ?c) = numeral ?v * ?b + numeral ?v * ?c›*) mult_2_right (*‹?z * 2 = ?z + ?z›*) nat_mult_dvd_cancel_disj (*‹(?k * ?m dvd ?k * ?n) = (?k = 0 ∨ ?m dvd ?n)›*) numeral_Bit0 (*‹numeral (num.Bit0 ?n) = numeral ?n + numeral ?n›*)) hence four_div_tn: "4 dvd (b+x-y-w)" using s_int (*‹4 dvd int (b + x + y) + w›*) t_simp2 (*‹int (2 * b + 2 * x) - (int (b + x + y) + w) = int (b + x - y) - w›*) by presburger have " (b+x) div 2 + (b+y) div 2 = (2*b+x+y) div 2" by (smt (verit, best) Groups.add_ac( (*‹?a + ?b = ?b + ?a›*) 2) b_y_int (*‹even (b + y)›*) div_plus_div_distrib_dvd_right (*‹?c dvd ?b ⟹ (?a + ?b) div ?c = ?a div ?c + ?b div ?c›*) left_add_twice (*‹?a + (?a + ?b) = 2 * ?a + ?b›*) nat_arith.add2 (*‹?B ≡ ?k + ?b ⟹ ?a + ?B ≡ ?k + (?a + ?b)›*)) hence threesum: "t + u + s = (2*b+x+y) div 2 - s" using t_def (*‹t = int ((b + x) div 2) - s›*) u_def (*‹u = int ((b + y) div 2) - s›*) by auto have "2 dvd (x+y)" using parity (*‹odd x ∧ odd y ∧ odd z›*) by auto hence "(2*b+x+y) div 2 + (b+w) div 2 = (2*b+b+x+y+w) div 2" by (smt (verit, ccfv_threshold) Num.of_nat_simps( (*‹of_nat (?m + ?n) = of_nat ?m + of_nat ?n›*) 4) b_w_int (*‹even (int b + w)›*) div_plus_div_distrib_dvd_right (*‹?c dvd ?b ⟹ (?a + ?b) div ?c = ?a div ?c + ?b div ?c›*) landau_product_preprocess( (*‹num.One + num.One = num.Bit0 num.One›*) 4) numerals( (*‹Numeral1 = 1›*) 1) of_nat_1 (*‹of_nat 1 = 1›*) one_plus_numeral (*‹1 + numeral ?n = numeral (num.One + ?n)›*) linordered_euclidean_semiring_class.of_nat_div (*‹of_nat (?m div ?n) = of_nat ?m div of_nat ?n›*)) hence "t+u+s+v = (2*b+b+x+y+w) div 2 -s -s" using v_def (*‹v = (int b + w) div 2 - s›*) threesum (*‹(t::int) + (u::int) + (s::int) = int (((2::nat) * (b::nat) + (x::nat) + (y::nat)) div (2::nat)) - s›*) by auto hence foursum0: "t+u+s+v = (2*b+b+x+y+w) div 2 - (b+x+y+w) div 4 - (b+x+y+w) div 4" using s_def (*‹s = (int (b + x + y) + w) div 4›*) by auto have foursum1: "(b+x+y+w) div 4 + (b+x+y+w) div 4 = (b+x+y+w) div 2" using div_mult_swap (*‹?c dvd ?b ⟹ ?a * (?b div ?c) = ?a * ?b div ?c›*) s_int (*‹(4::int) dvd int ((b::nat) + (x::nat) + (y::nat)) + (w::int)›*) by auto have "(2*b+b+x+y+w) div 2 - (b+x+y+w) div 2 = (2*b) div 2" by auto hence "t+u+s+v = (2*b) div 2" using foursum0 (*‹t + u + s + v = (int (2 * b + b + x + y) + w) div 2 - (int (b + x + y) + w) div 4 - (int (b + x + y) + w) div 4›*) foursum1 (*‹(int (b + x + y) + w) div 4 + (int (b + x + y) + w) div 4 = (int (b + x + y) + w) div 2›*) by linarith hence second: "t+u+s+v = b" by auto from a_and_b (*‹4 * a - b² = x² + y² + z²›*) have "4*a = x^2+y^2+z^2+b^2" by (metis Nat.add_diff_assoc2 (*‹?k ≤ ?j ⟹ ?j - ?k + ?i = ?j + ?i - ?k›*) add_diff_cancel_right' (*‹?a + ?b - ?b = ?a›*) assms( (*‹b² < 4 * a›*) 5) less_or_eq_imp_le (*‹?m < ?n ∨ ?m = ?n ⟹ ?m ≤ ?n›*)) hence "a = (x^2+y^2+z^2+b^2) div 4" using parity (*‹odd x ∧ odd y ∧ odd z›*) b_par (*‹odd b›*) by auto from second (*‹t + u + s + v = int b›*) have b_expresion: "b^2 = t^2+u^2+s^2+v^2+2*t*u+2* s * v + 2*t* s + 2*t * v +2*u * s +2*u * v" using four_terms_bin_exp_allsum (*‹(?b::int) = (?s::int) + (?t::int) + (?u::int) + (?v::int) ⟹ ?b² = ?t² + ?u² + ?s² + ?v² + (2::int) * ?t * ?u + (2::int) * ?s * ?v + (2::int) * ?t * ?s + (2::int) * ?t * ?v + (2::int) * ?u * ?s + (2::int) * ?u * ?v›*) by (metis is_num_normalize( (*‹?a + ?b + ?c = ?a + (?b + ?c)›*) 1) nat_arith.add2 (*‹?B ≡ ?k + ?b ⟹ ?a + ?B ≡ ?k + (?a + ?b)›*) of_nat_power (*‹of_nat (?m ^ ?n) = of_nat ?m ^ ?n›*)) define sn where sn_def: "sn = b+x+y+w" from sn_def (*‹sn = int (b + x + y) + w›*) s_def (*‹s = (int (b + x + y) + w) div 4›*) have sn_nume: "4* s = sn" by (metis dvd_div_mult_self (*‹?a dvd ?b ⟹ ?b div ?a * ?a = ?b›*) mult.commute (*‹?a * ?b = ?b * ?a›*) s_int (*‹4 dvd int (b + x + y) + w›*)) from sn_def (*‹(sn::int) = int ((b::nat) + (x::nat) + (y::nat)) + (w::int)›*) have sn_sqr: "sn^2 = b^2+x^2+y^2+w^2+2* b * x+2* b * y+2*b*w+2*x*y+2*x*w+2*y*w" using four_terms_bin_exp_allsum (*‹?b = ?s + ?t + ?u + ?v ⟹ ?b² = ?t² + ?u² + ?s² + ?v² + 2 * ?t * ?u + 2 * ?s * ?v + 2 * ?t * ?s + 2 * ?t * ?v + 2 * ?u * ?s + 2 * ?u * ?v›*) w_def (*‹(w = int z ∨ w = - int z) ∧ (int (b + x + y) + w) mod 4 = 0›*) by auto hence s_pen: "16* s^2 = b^2+x^2+y^2+w^2+2*b*x+2*b*y+2*b*w+2*x*y+2*x*w+2*y*w" using sn_nume (*‹4 * s = sn›*) by auto have "4 dvd sn" using s_int (*‹4 dvd int (b + x + y) + w›*) sn_def (*‹sn = int (b + x + y) + w›*) by auto hence "16 dvd sn^2" by auto hence s_sqr_expression: "s^2=(b^2+x^2+y^2+w^2+2*b*x+2*b*y+2*b*w+2*x*y+2*x*w+2*y*w) div 16" using sn_sqr (*‹sn² = int (b² + x² + y²) + w² + int (2 * b * x) + int (2 * b * y) + int (2 * b) * w + int (2 * x * y) + int (2 * x) * w + int (2 * y) * w›*) s_pen (*‹(16::int) * (s::int)² = int ((b::nat)² + (x::nat)² + (y::nat)²) + (w::int)² + int ((2::nat) * b * x) + int ((2::nat) * b * y) + int ((2::nat) * b) * w + int ((2::nat) * x * y) + int ((2::nat) * x) * w + int ((2::nat) * y) * w›*) by auto define tn where tn_def: "tn = b+x-y-w" from tn_def (*‹tn = int (b + x - y) - w›*) t_expre (*‹t = (int (b + x - y) - w) div 4›*) size (*‹(y::nat) ≤ (x::nat) ∧ (z::nat) ≤ y›*) four_div_tn (*‹4 dvd int (b + x - y) - w›*) have tn_nume: "4* t = tn" by (metis dvd_div_mult_self (*‹?a dvd ?b ⟹ ?b div ?a * ?a = ?b›*) mult.commute (*‹?a * ?b = ?b * ?a›*)) from size (*‹y ≤ x ∧ z ≤ y›*) assms (*‹1 ≤ a› ‹1 ≤ b› ‹odd a› ‹odd b› ‹b² < 4 * a› ‹(3::nat) * (a::nat) < (b::nat)² + (2::nat) * b + (4::nat)›*) have "b+x-y > 0" by auto hence "tn = int b + int x - int y -w" using tn_def (*‹(tn::int) = int ((b::nat) + (x::nat) - (y::nat)) - (w::int)›*) by auto from this (*‹tn = int b + int x - int y - w›*) have tn_sqr: "tn^2 = b^2+x^2+y^2+w^2+2*b*x-2*b*y-2*b*w-2*x*y-2*x*w+2*y*w" using four_terms_bin_exp_twodiff (*‹?b = ?s + ?t - ?u - ?v ⟹ ?b² = ?t² + ?u² + ?s² + ?v² - 2 * ?t * ?u - 2 * ?s * ?v + 2 * ?t * ?s - 2 * ?t * ?v - 2 * ?u * ?s + 2 * ?u * ?v›*) w_def (*‹(w = int z ∨ w = - int z) ∧ (int (b + x + y) + w) mod 4 = 0›*) by auto hence t_pen: "16*t^2 = b^2+x^2+y^2+w^2+2*b*x-2*b*y-2*b*w-2*x*y-2*x*w+2*y*w" using tn_nume (*‹4 * t = tn›*) by auto have "16 dvd tn^2" using tn_def (*‹tn = int (b + x - y) - w›*) four_div_tn (*‹(4::int) dvd int ((b::nat) + (x::nat) - (y::nat)) - (w::int)›*) by auto hence t_sqr_expression: "t^2=(b^2+x^2+y^2+w^2+2*b*x-2*b*y-2*b*w-2*x*y-2*x*w+2*y*w) div 16" using tn_sqr (*‹tn² = int (b² + x² + y²) + w² + int (2 * b * x) - int (2 * b * y) - int (2 * b) * w - int (2 * x * y) - int (2 * x) * w + int (2 * y) * w›*) t_pen (*‹16 * t² = int (b² + x² + y²) + w² + int (2 * b * x) - int (2 * b * y) - int (2 * b) * w - int (2 * x * y) - int (2 * x) * w + int (2 * y) * w›*) by auto from size (*‹y ≤ x ∧ z ≤ y›*) s_def (*‹s = (int (b + x + y) + w) div 4›*) t_expre (*‹(t::int) = (int ((b::nat) + (x::nat) - (y::nat)) - (w::int)) div (4::int)›*) w_def (*‹(w = int z ∨ w = - int z) ∧ (int (b + x + y) + w) mod 4 = 0›*) have sgeqt: "s≥t" by auto from size (*‹y ≤ x ∧ z ≤ y›*) s_def (*‹(s::int) = (int ((b::nat) + (x::nat) + (y::nat)) + (w::int)) div (4::int)›*) t_def (*‹t = int ((b + x) div 2) - s›*) u_def (*‹u = int ((b + y) div 2) - s›*) have tgequ: "t≥u" by auto from size (*‹y ≤ x ∧ z ≤ y›*) s_def (*‹s = (int (b + x + y) + w) div 4›*) u_def (*‹u = int ((b + y) div 2) - s›*) v_def (*‹v = (int b + w) div 2 - s›*) w_def (*‹(w = int z ∨ w = - int z) ∧ (int (b + x + y) + w) mod 4 = 0›*) have ugeqv: "u≥v" by auto from assms(6) (*‹(3::nat) * (a::nat) < (b::nat)² + (2::nat) * b + (4::nat)›*) have "12*a < 4*b^2+8*b+16" by auto hence "12*a-3*b^2 < b^2+8*b+16" by auto hence "12*a-3*b^2 < (b+4)^2" by (smt (z3) add.commute (*‹?a + ?b = ?b + ?a›*) add.left_commute (*‹?b + (?a + ?c) = ?a + (?b + ?c)›*) mult_2 (*‹2 * ?z = ?z + ?z›*) numeral_Bit0 (*‹numeral (num.Bit0 ?n) = numeral ?n + numeral ?n›*) power2_eq_square (*‹?a² = ?a * ?a›*) power2_sum (*‹(?x + ?y)² = ?x² + ?y² + 2 * ?x * ?y›*)) hence mid_ineq: "sqrt(12*a-3*b^2) < b+4" by (meson of_nat_0_le_iff (*‹(0::?'a) ≤ of_nat (?n::nat)›*) of_nat_power_less_of_nat_cancel_iff (*‹(of_nat (?x::nat) < of_nat (?b::nat) ^ (?w::nat)) = (?x < ?b ^ ?w)›*) real_less_lsqrt (*‹⟦(0::real) ≤ (?y::real); (?x::real) < ?y²⟧ ⟹ sqrt ?x < ?y›*)) define ab :: nat where ab_def: "ab = 4*a-b^2" from assms (*‹1 ≤ a› ‹(1::nat) ≤ (b::nat)› ‹odd a› ‹odd (b::nat)› ‹b² < 4 * a› ‹3 * a < b² + 2 * b + 4›*) ab_def (*‹ab = 4 * a - b²›*) have nonneg_ab: "ab>0" by auto from a_and_b (*‹4 * a - b² = x² + y² + z²›*) ab_def (*‹ab = 4 * a - b²›*) have sum_of_sqrs: "x^2+y^2+z^2 = ab" by auto from this (*‹x² + y² + z² = ab›*) nonneg_ab (*‹(0::nat) < (ab::nat)›*) have "x^2+y^2+z^2>0" by auto from this (*‹0 < x² + y² + z²›*) sum_of_sqrs (*‹x² + y² + z² = ab›*) three_terms_Cauchy_Schwarz_nat_ver (*‹⟦0 < ?a; ?x² + ?y² + ?z² = ?a⟧ ⟹ - sqrt (real (3 * ?a)) ≤ real (?x + ?y + ?z) ∧ real (?x + ?y + ?z) ≤ sqrt (real (3 * ?a))›*) have "x+y+z ≤ sqrt(3*ab)" by auto hence left_ineq: "x+y+z ≤ sqrt(3*(4*a-b^2))" using ab_def (*‹ab = 4 * a - b²›*) by auto have "sqrt(3*(4*a-b^2)) = sqrt(12*a-3*b^2)" by (simp add: diff_mult_distrib2 (*‹?k * (?m - ?n) = ?k * ?m - ?k * ?n›*)) from left_ineq (*‹real (x + y + z) ≤ sqrt (real (3 * (4 * a - b²)))›*) mid_ineq (*‹sqrt (real (12 * a - 3 * b²)) < real (b + 4)›*) this (*‹sqrt (real (3 * (4 * a - b²))) = sqrt (real (12 * a - 3 * b²))›*) have "x+y+z < b+4" by auto hence num_bound: "int b- x- y- z > -4" by auto define vn where vn_def: "vn = int b+w-x-y" from num_bound (*‹- (4::int) < int (b::nat) - int (x::nat) - int (y::nat) - int (z::nat)›*) vn_def (*‹vn = int b + w - int x - int y›*) w_def (*‹(w = int z ∨ w = - int z) ∧ (int (b + x + y) + w) mod 4 = 0›*) have vn_bound: "vn > -4" by auto from w_def (*‹(w = int z ∨ w = - int z) ∧ (int (b + x + y) + w) mod 4 = 0›*) have four_div_sn: "4 dvd (int b +x+y+w)" by auto from parity (*‹odd x ∧ odd y ∧ odd z›*) have "4 dvd (int 2*x+2*y)" by (metis Num.of_nat_simps( (*‹of_nat (?m * ?n) = of_nat ?m * of_nat ?n›*) 5) ‹even (x + y)› distrib_left (*‹?a * (?b + ?c) = ?a * ?b + ?a * ?c›*) int_dvd_int_iff (*‹(int ?m dvd int ?n) = (?m dvd ?n)›*) nat_mult_dvd_cancel_disj (*‹(?k * ?m dvd ?k * ?n) = (?k = 0 ∨ ?m dvd ?n)›*) num_double (*‹num.Bit0 num.One * ?n = num.Bit0 ?n›*) numeral_mult (*‹numeral (?m * ?n) = numeral ?m * numeral ?n›*) of_nat_add (*‹of_nat (?m + ?n) = of_nat ?m + of_nat ?n›*) of_nat_numeral (*‹of_nat (numeral ?n) = numeral ?n›*)) hence "4 dvd (int b +x+y+w - 2*x - 2*y)" using four_div_sn (*‹4 dvd int b + int x + int y + w›*) by (smt (verit) Num.of_nat_simps( (*‹of_nat (?m * ?n) = of_nat ?m * of_nat ?n›*) 5) dvd_add_left_iff (*‹?a dvd ?c ⟹ (?a dvd ?b + ?c) = (?a dvd ?b)›*)) hence "4 dvd vn" using vn_def (*‹vn = int b + w - int x - int y›*) by presburger from v_def (*‹v = (int b + w) div 2 - s›*) s_def (*‹s = (int (b + x + y) + w) div 4›*) have "v = (int 2*b + 2*w) div 4 - (int b + x + y + w) div 4" by auto hence v_expre: "v = (int b-x-y+w) div 4" using four_div_sn (*‹4 dvd int b + int x + int y + w›*) by fastforce hence "v = vn div 4" using vn_def (*‹vn = int b + w - int x - int y›*) by auto hence "v ≥ 0" using vn_bound (*‹- 4 < vn›*) four_div_sn (*‹4 dvd int b + int x + int y + w›*) using ‹4 dvd vn› (*‹4 dvd vn›*) by fastforce hence stuv_nonneg: " s ≥ 0 ∧ t ≥ 0 ∧ u ≥ 0 ∧ v ≥ 0 " using sgeqt (*‹t ≤ s›*) tgequ (*‹u ≤ t›*) ugeqv (*‹v ≤ u›*) by linarith from vn_def (*‹(vn::int) = int (b::nat) + (w::int) - int (x::nat) - int (y::nat)›*) have vn_sqr: "vn^2 = b^2+x^2+y^2+w^2 - 2*b*x-2*b*y+2*b*w+2*x*y-2*x*w-2*y*w" using four_terms_bin_exp_twodiff (*‹?b = ?s + ?t - ?u - ?v ⟹ ?b² = ?t² + ?u² + ?s² + ?v² - 2 * ?t * ?u - 2 * ?s * ?v + 2 * ?t * ?s - 2 * ?t * ?v - 2 * ?u * ?s + 2 * ?u * ?v›*) w_def (*‹(w = int z ∨ w = - int z) ∧ (int (b + x + y) + w) mod 4 = 0›*) by auto from ‹v = vn div 4› (*‹(v::int) = (vn::int) div (4::int)›*) have vn_is_num: "v^2 = vn^2 div 16" using ‹4 dvd vn› (*‹4 dvd vn›*) by fastforce hence "16 dvd vn^2" using v_def (*‹(v::int) = (int (b::nat) + (w::int)) div (2::int) - (s::int)›*) using ‹4 dvd vn› (*‹4 dvd vn›*) by fastforce from vn_is_num (*‹v² = vn² div 16›*) vn_sqr (*‹(vn::int)² = int ((b::nat)² + (x::nat)² + (y::nat)²) + (w::int)² - int ((2::nat) * b * x) - int ((2::nat) * b * y) + int ((2::nat) * b) * w + int ((2::nat) * x * y) - int ((2::nat) * x) * w - int ((2::nat) * y) * w›*) have v_sqr_expression: "v^2=(b^2+x^2+y^2+w^2-2*b*x-2*b*y+2*b*w+2*x*y-2*x*w-2*y*w) div 16" by auto define un where un_def: "un = int b+y-x-w" from parity (*‹odd (x::nat) ∧ odd (y::nat) ∧ odd (z::nat)›*) w_def (*‹(w = int z ∨ w = - int z) ∧ (int (b + x + y) + w) mod 4 = 0›*) have "even (x+w)" by auto from this (*‹even (int x + w)›*) parity (*‹odd x ∧ odd y ∧ odd z›*) have "4 dvd (int 2*x+2*w)" by (metis distrib_left (*‹?a * (?b + ?c) = ?a * ?b + ?a * ?c›*) even_numeral (*‹even (numeral (num.Bit0 ?n))›*) mult_2_right (*‹?z * 2 = ?z + ?z›*) mult_dvd_mono (*‹⟦?a dvd ?b; ?c dvd ?d⟧ ⟹ ?a * ?c dvd ?b * ?d›*) numeral_Bit0 (*‹numeral (num.Bit0 ?n) = numeral ?n + numeral ?n›*) of_nat_numeral (*‹of_nat (numeral ?n) = numeral ?n›*)) hence "4 dvd (int b +x+y+w - 2*x-2*w)" using four_div_sn (*‹4 dvd int b + int x + int y + w›*) by (smt (verit) Num.of_nat_simps( (*‹of_nat (?m * ?n) = of_nat ?m * of_nat ?n›*) 5) dvd_add_left_iff (*‹?a dvd ?c ⟹ (?a dvd ?b + ?c) = (?a dvd ?b)›*)) hence "4 dvd un" using un_def (*‹(un::int) = int (b::nat) + int (y::nat) - int (x::nat) - (w::int)›*) by presburger from u_def (*‹u = int ((b + y) div 2) - s›*) s_def (*‹s = (int (b + x + y) + w) div 4›*) have "u = (int 2*b+2*y) div 4 - (int b + x + y + w) div 4" by auto hence u_expre: "u = (int b-x+y-w) div 4" using four_div_sn (*‹(4::int) dvd int (b::nat) + int (x::nat) + int (y::nat) + (w::int)›*) by fastforce hence "u = un div 4" using un_def (*‹un = int b + int y - int x - w›*) by auto from un_def (*‹un = int b + int y - int x - w›*) have un_sqr: "un^2 = b^2+x^2+y^2+w^2+2*b*y-2*b*x-2*b*w-2*y*x-2*y*w+2*x*w" using four_terms_bin_exp_twodiff (*‹(?b::int) = (?s::int) + (?t::int) - (?u::int) - (?v::int) ⟹ ?b² = ?t² + ?u² + ?s² + ?v² - (2::int) * ?t * ?u - (2::int) * ?s * ?v + (2::int) * ?t * ?s - (2::int) * ?t * ?v - (2::int) * ?u * ?s + (2::int) * ?u * ?v›*) w_def (*‹((w::int) = int (z::nat) ∨ w = - int z) ∧ (int ((b::nat) + (x::nat) + (y::nat)) + w) mod (4::int) = (0::int)›*) by auto from ‹u = un div 4› (*‹(u::int) = (un::int) div (4::int)›*) have un_is_num: "u^2 = un^2 div 16" using ‹4 dvd un› (*‹4 dvd un›*) by fastforce hence "16 dvd un^2" using u_def (*‹u = int ((b + y) div 2) - s›*) using ‹4 dvd un› (*‹(4::int) dvd (un::int)›*) by fastforce from un_is_num (*‹u² = un² div 16›*) un_sqr (*‹(un::int)² = int ((b::nat)² + (x::nat)² + (y::nat)²) + (w::int)² + int ((2::nat) * b * y) - int ((2::nat) * b * x) - int ((2::nat) * b) * w - int ((2::nat) * y * x) - int ((2::nat) * y) * w + int ((2::nat) * x) * w›*) have u_sqr_expression: "u^2 = (b^2+x^2+y^2+w^2+2*b*y-2*b*x-2*b*w-2*y*x-2*y*w+2*x*w) div 16" by auto from u_sqr_expression (*‹(u::int)² = (int ((b::nat)² + (x::nat)² + (y::nat)²) + (w::int)² + int ((2::nat) * b * y) - int ((2::nat) * b * x) - int ((2::nat) * b) * w - int ((2::nat) * y * x) - int ((2::nat) * y) * w + int ((2::nat) * x) * w) div (16::int)›*) v_sqr_expression (*‹v² = (int (b² + x² + y²) + w² - int (2 * b * x) - int (2 * b * y) + int (2 * b) * w + int (2 * x * y) - int (2 * x) * w - int (2 * y) * w) div 16›*) have uv_simp1: "u^2+v^2 = (int b^2+x^2+y^2+w^2-2*b*x-2*b*y+2*b*w+2*x*y-2*x*w-2*y*w) div 16 + (int b^2+x^2+y^2+w^2+2*b*y-2*b*x-2*b*w-2*y*x-2*y*w+2*x*w) div 16" by auto have uv_simp2: "(int b^2+x^2+y^2+w^2-2*b*x-2*b*y+2*b*w+2*x*y-2*x*w-2*y*w)+ (int b^2+x^2+y^2+w^2+2*b*y-2*b*x-2*b*w-2*y*x-2*y*w+2*x*w)= (int 2*b^2+2*x^2+2*y^2+2*w^2-4*b*x-4*y*w)" by auto hence "16 dvd (int 2*b^2+2*x^2+2*y^2+2*w^2-4*b*x-4*y*w)" by (smt (verit) ‹16 dvd un²› ‹16 dvd vn²› dvd_add_right_iff (*‹?a dvd ?b ⟹ (?a dvd ?b + ?c) = (?a dvd ?c)›*) of_nat_power (*‹of_nat (?m ^ ?n) = of_nat ?m ^ ?n›*) un_sqr (*‹un² = int (b² + x² + y²) + w² + int (2 * b * y) - int (2 * b * x) - int (2 * b) * w - int (2 * y * x) - int (2 * y) * w + int (2 * x) * w›*) vn_sqr (*‹vn² = int (b² + x² + y²) + w² - int (2 * b * x) - int (2 * b * y) + int (2 * b) * w + int (2 * x * y) - int (2 * x) * w - int (2 * y) * w›*) zadd_int_left (*‹int ?m + (int ?n + ?z) = int (?m + ?n) + ?z›*)) hence usqr_plus_vsqr: "u^2+v^2 = (int 2*b^2+2*x^2+2*y^2+2*w^2-4*b*x-4*y*w) div 16" using uv_simp1 (*‹u² + v² = ((int b)² + int (x²) + int (y²) + w² - int (2 * b * x) - int (2 * b * y) + int (2 * b) * w + int (2 * x * y) - int (2 * x) * w - int (2 * y) * w) div 16 + ((int b)² + int (x²) + int (y²) + w² + int (2 * b * y) - int (2 * b * x) - int (2 * b) * w - int (2 * y * x) - int (2 * y) * w + int (2 * x) * w) div 16›*) uv_simp2 (*‹(int b)² + int (x²) + int (y²) + w² - int (2 * b * x) - int (2 * b * y) + int (2 * b) * w + int (2 * x * y) - int (2 * x) * w - int (2 * y) * w + ((int b)² + int (x²) + int (y²) + w² + int (2 * b * y) - int (2 * b * x) - int (2 * b) * w - int (2 * y * x) - int (2 * y) * w + int (2 * x) * w) = int 2 * int (b²) + int (2 * x²) + int (2 * y²) + 2 * w² - int (4 * b * x) - int (4 * y) * w›*) by (smt (verit, ccfv_threshold) Num.of_nat_simps( (*‹of_nat (?m + ?n) = of_nat ?m + of_nat ?n›*) 4) Num.of_nat_simps( (*‹of_nat (?m * ?n) = of_nat ?m * of_nat ?n›*) 5) ‹16 dvd vn²› div_plus_div_distrib_dvd_right (*‹?c dvd ?b ⟹ (?a + ?b) div ?c = ?a div ?c + ?b div ?c›*) power2_eq_square (*‹?a² = ?a * ?a›*) vn_sqr (*‹vn² = int (b² + x² + y²) + w² - int (2 * b * x) - int (2 * b * y) + int (2 * b) * w + int (2 * x * y) - int (2 * x) * w - int (2 * y) * w›*)) have allsum0: "s^2+t^2+u^2+v^2 = (sn^2+tn^2+un^2+vn^2) div 16" using ‹16 dvd vn²› (*‹16 dvd vn²›*) ‹16 dvd sn²› (*‹(16::int) dvd (sn::int)²›*) ‹16 dvd un²› (*‹(16::int) dvd (un::int)²›*) ‹16 dvd tn²› (*‹16 dvd tn²›*) s_sqr_expression (*‹s² = (int (b² + x² + y²) + w² + int (2 * b * x) + int (2 * b * y) + int (2 * b) * w + int (2 * x * y) + int (2 * x) * w + int (2 * y) * w) div 16›*) t_sqr_expression (*‹t² = (int (b² + x² + y²) + w² + int (2 * b * x) - int (2 * b * y) - int (2 * b) * w - int (2 * x * y) - int (2 * x) * w + int (2 * y) * w) div 16›*) u_sqr_expression (*‹u² = (int (b² + x² + y²) + w² + int (2 * b * y) - int (2 * b * x) - int (2 * b) * w - int (2 * y * x) - int (2 * y) * w + int (2 * x) * w) div 16›*) v_sqr_expression (*‹v² = (int (b² + x² + y²) + w² - int (2 * b * x) - int (2 * b * y) + int (2 * b) * w + int (2 * x * y) - int (2 * x) * w - int (2 * y) * w) div 16›*) sn_sqr (*‹(sn::int)² = int ((b::nat)² + (x::nat)² + (y::nat)²) + (w::int)² + int ((2::nat) * b * x) + int ((2::nat) * b * y) + int ((2::nat) * b) * w + int ((2::nat) * x * y) + int ((2::nat) * x) * w + int ((2::nat) * y) * w›*) tn_sqr (*‹(tn::int)² = int ((b::nat)² + (x::nat)² + (y::nat)²) + (w::int)² + int ((2::nat) * b * x) - int ((2::nat) * b * y) - int ((2::nat) * b) * w - int ((2::nat) * x * y) - int ((2::nat) * x) * w + int ((2::nat) * y) * w›*) un_sqr (*‹(un::int)² = int ((b::nat)² + (x::nat)² + (y::nat)²) + (w::int)² + int ((2::nat) * b * y) - int ((2::nat) * b * x) - int ((2::nat) * b) * w - int ((2::nat) * y * x) - int ((2::nat) * y) * w + int ((2::nat) * x) * w›*) vn_sqr (*‹(vn::int)² = int ((b::nat)² + (x::nat)² + (y::nat)²) + (w::int)² - int ((2::nat) * b * x) - int ((2::nat) * b * y) + int ((2::nat) * b) * w + int ((2::nat) * x * y) - int ((2::nat) * x) * w - int ((2::nat) * y) * w›*) by (metis add.commute (*‹?a + ?b = ?b + ?a›*) div_plus_div_distrib_dvd_left (*‹?c dvd ?a ⟹ (?a + ?b) div ?c = ?a div ?c + ?b div ?c›*)) have allsum1: "(sn^2+tn^2+un^2+vn^2) = (int 4*b^2+4*x^2+4*y^2+4*w^2)" using sn_sqr (*‹sn² = int (b² + x² + y²) + w² + int (2 * b * x) + int (2 * b * y) + int (2 * b) * w + int (2 * x * y) + int (2 * x) * w + int (2 * y) * w›*) tn_sqr (*‹tn² = int (b² + x² + y²) + w² + int (2 * b * x) - int (2 * b * y) - int (2 * b) * w - int (2 * x * y) - int (2 * x) * w + int (2 * y) * w›*) un_sqr (*‹un² = int (b² + x² + y²) + w² + int (2 * b * y) - int (2 * b * x) - int (2 * b) * w - int (2 * y * x) - int (2 * y) * w + int (2 * x) * w›*) vn_sqr (*‹vn² = int (b² + x² + y²) + w² - int (2 * b * x) - int (2 * b * y) + int (2 * b) * w + int (2 * x * y) - int (2 * x) * w - int (2 * y) * w›*) by auto have "16 dvd (sn^2+tn^2+un^2+vn^2)" by (simp add: ‹16 dvd sn²› ‹16 dvd tn²› ‹16 dvd un²› ‹16 dvd vn²›) hence "16 dvd 4*(int b^2+x^2+y^2+w^2)" using allsum1 (*‹sn² + tn² + un² + vn² = int 4 * int (b²) + int (4 * x²) + int (4 * y²) + 4 * w²›*) by auto hence "4 dvd (int b^2+x^2+y^2+w^2)" by presburger from allsum1 (*‹sn² + tn² + un² + vn² = int 4 * int (b²) + int (4 * x²) + int (4 * y²) + 4 * w²›*) have "s^2+t^2+u^2+v^2 = (int 4*b^2+4*x^2+4*y^2+4*w^2) div 16" using allsum0 (*‹s² + t² + u² + v² = (sn² + tn² + un² + vn²) div 16›*) by presburger hence "s^2+t^2+u^2+v^2 = 4*(int b^2+x^2+y^2+w^2) div 16" by simp hence allsum2: "s^2+t^2+u^2+v^2 = (int b^2+x^2+y^2+w^2) div 4" by simp from a_and_b (*‹4 * a - b² = x² + y² + z²›*) have "4*a = int b^2+x^2+y^2+w^2" using w_def (*‹(w = int z ∨ w = - int z) ∧ (int (b + x + y) + w) mod 4 = 0›*) using ‹4 * a = x² + y² + z² + b²› (*‹4 * a = x² + y² + z² + b²›*) by fastforce hence first: "a = s^2+t^2+u^2+v^2" using allsum2 (*‹s² + t² + u² + v² = ((int b)² + int (x²) + int (y²) + w²) div 4›*) by linarith show "?thesis" (*goal: ‹∃s t u v. 0 ≤ s ∧ 0 ≤ t ∧ 0 ≤ u ∧ 0 ≤ v ∧ int a = s² + t² + u² + v² ∧ int b = s + t + u + v›*) using first (*‹int a = s² + t² + u² + v²›*) second (*‹(t::int) + (u::int) + (s::int) + (v::int) = int (b::nat)›*) stuv_nonneg (*‹0 ≤ s ∧ 0 ≤ t ∧ 0 ≤ u ∧ 0 ≤ v›*) by (smt (verit, best)) qed end
{ "path": "afp-2025-02-12/thys/Polygonal_Number_Theorem/Polygonal_Number_Theorem_Lemmas.thy", "repo": "afp-2025-02-12", "sha": "67f36d3d18c1df66befe3f1204d5995c62e3fd87e6b9840d9fc8304c4b8aee26" }
(* Title: Psi-calculi Author/Maintainer: Jesper Bengtson (jebe@itu.dk), 2012 *) theory Weaken_Transition imports Weakening begin context weak begin definition weakenTransition :: "'b ⇒ ('a, 'b, 'c) psi ⇒ 'a action ⇒ ('a, 'b, 'c) psi ⇒ bool" ("_ ⊳ _ ⟹_ ≺ _" [80, 80, 80, 80] 80) where "Ψ ⊳ P ⟹α ≺ P' ≡ (∃P''' P''. Ψ ⊳ P ⟹⇧^⇩τ P''' ∧ Ψ ⊳ P''' ⟼α ≺ P'' ∧ Ψ ⊳ P'' ⟹⇧^⇩τ P') ∨ (P = P' ∧ α = τ)" lemma weakenTransitionCases[consumes 1, case_names cBase cStep]: assumes "Ψ ⊳ P ⟹α ≺ P'" and "Prop (τ) P" and "⋀P''' P''. ⟦Ψ ⊳ P ⟹⇧^⇩τ P'''; Ψ ⊳ P''' ⟼α ≺ P''; Ψ ⊳ P'' ⟹⇧^⇩τ P'⟧ ⟹ Prop α P'" shows "Prop α P'" using assms (*‹Ψ ⊳ P ⟹α ≺ P'› ‹Prop (τ) P› ‹⟦(Ψ::'b) ⊳ (P::('a, 'b, 'c) psi) ⟹⇧^⇩τ (?P'''::('a, 'b, 'c) psi); Ψ ⊳ ?P''' ⟼ (α::'a action) ≺ (?P''::('a, 'b, 'c) psi); Ψ ⊳ ?P'' ⟹⇧^⇩τ (P'::('a, 'b, 'c) psi)⟧ ⟹ (Prop::'a action ⇒ ('a, 'b, 'c) psi ⇒ bool) α P'›*) by (auto simp add: weakenTransition_def (*‹?Ψ ⊳ ?P ⟹?α ≺ ?P' ≡ (∃P''' P''. ?Ψ ⊳ ?P ⟹⇧^⇩τ P''' ∧ ?Ψ ⊳ P''' ⟼ ?α ≺ P'' ∧ ?Ψ ⊳ P'' ⟹⇧^⇩τ ?P') ∨ ?P = ?P' ∧ ?α = τ›*)) lemma statImpTauChainDerivative: fixes Ψ :: 'b and P :: "('a, 'b, 'c) psi" and P' :: "('a, 'b, 'c) psi" assumes "Ψ ⊳ P ⟹⇧^⇩τ P'" shows "insertAssertion (extractFrame P) Ψ ↪⇩F insertAssertion (extractFrame P') Ψ" using assms (*‹(Ψ::'b) ⊳ (P::('a, 'b, 'c) psi) ⟹⇧^⇩τ (P'::('a, 'b, 'c) psi)›*) apply (induct rule: tauChainInduct (*‹⟦(?Ψ::'b) ⊳ (?x1.0::('a, 'b, 'c) psi) ⟹⇧^⇩τ (?x2.0::('a, 'b, 'c) psi); ⋀a::('a, 'b, 'c) psi. (?P::('a, 'b, 'c) psi ⇒ ('a, 'b, 'c) psi ⇒ bool) a a; ⋀(a::('a, 'b, 'c) psi) (b::('a, 'b, 'c) psi) c::('a, 'b, 'c) psi. ⟦?Ψ ⊳ a ⟹⇧^⇩τ b; ?P a b; ?Ψ ⊳ b ⟼ τ ≺ c⟧ ⟹ ?P a c⟧ ⟹ ?P ?x1.0 ?x2.0›*)) (*goals: 1. ‹⋀a. insertAssertion (extractFrame a) Ψ ↪⇩F insertAssertion (extractFrame a) Ψ› 2. ‹⋀a b c. ⟦Ψ ⊳ a ⟹⇧^⇩τ b; insertAssertion (extractFrame a) Ψ ↪⇩F insertAssertion (extractFrame b) Ψ; Ψ ⊳ b ⟼ τ ≺ c⟧ ⟹ insertAssertion (extractFrame a) Ψ ↪⇩F insertAssertion (extractFrame c) Ψ› discuss goal 1*) apply ((auto intro: statImpTauDerivative (*‹?Ψ ⊳ ?P ⟼ τ ≺ ?P' ⟹ insertAssertion (extractFrame ?P) ?Ψ ↪⇩F insertAssertion (extractFrame ?P') ?Ψ›*) dest: FrameStatImpTrans (*‹⟦?F ↪⇩F ?G; ?G ↪⇩F ?H⟧ ⟹ ?F ↪⇩F ?H›*))[1]) (*discuss goal 2*) apply ((auto intro: statImpTauDerivative (*‹(?Ψ::'b) ⊳ (?P::('a, 'b, 'c) psi) ⟼ τ ≺ (?P'::('a, 'b, 'c) psi) ⟹ insertAssertion (extractFrame ?P) ?Ψ ↪⇩F insertAssertion (extractFrame ?P') ?Ψ›*) dest: FrameStatImpTrans (*‹⟦(?F::'b frame) ↪⇩F (?G::'b frame); ?G ↪⇩F (?H::'b frame)⟧ ⟹ ?F ↪⇩F ?H›*))[1]) (*proven 2 subgoals*) . lemma weakenTauChain: fixes Ψ :: 'b and P :: "('a, 'b, 'c) psi" and P' :: "('a, 'b, 'c) psi" and Ψ' :: 'b assumes "Ψ ⊳ P ⟹⇧^⇩τ P'" shows "Ψ ⊗ Ψ' ⊳ P ⟹⇧^⇩τ P'" using assms (*‹(Ψ::'b::fs_name) ⊳ (P::('a::fs_name, 'b::fs_name, 'c::fs_name) psi) ⟹⇧^⇩τ (P'::('a::fs_name, 'b::fs_name, 'c::fs_name) psi)›*) proof (induct rule: tauChainInduct (*‹⟦?Ψ ⊳ ?x1.0 ⟹⇧^⇩τ ?x2.0; ⋀a. ?P a a; ⋀a b c. ⟦?Ψ ⊳ a ⟹⇧^⇩τ b; ?P a b; ?Ψ ⊳ b ⟼ τ ≺ c⟧ ⟹ ?P a c⟧ ⟹ ?P ?x1.0 ?x2.0›*)) (*goals: 1. ‹⋀a. Ψ ⊗ Ψ' ⊳ a ⟹⇧^⇩τ a› 2. ‹⋀a b c. ⟦Ψ ⊳ a ⟹⇧^⇩τ b; Ψ ⊗ Ψ' ⊳ a ⟹⇧^⇩τ b; Ψ ⊳ b ⟼ τ ≺ c⟧ ⟹ Ψ ⊗ Ψ' ⊳ a ⟹⇧^⇩τ c›*) case (TauBase P) (*no hyothesis introduced yet*) thus "?case" (*goal: ‹Ψ ⊗ Ψ' ⊳ P ⟹⇧^⇩τ P›*) by simp next (*goal: ‹⋀a b c. ⟦Ψ ⊳ a ⟹⇧^⇩τ b; Ψ ⊗ Ψ' ⊳ a ⟹⇧^⇩τ b; Ψ ⊳ b ⟼ τ ≺ c⟧ ⟹ Ψ ⊗ Ψ' ⊳ a ⟹⇧^⇩τ c›*) case (TauStep P P' P'') (*‹Ψ ⊳ P ⟹⇧^⇩τ P'› ‹Ψ ⊗ Ψ' ⊳ P ⟹⇧^⇩τ P'› ‹Ψ ⊳ P' ⟼ τ ≺ P''›*) note ‹Ψ ⊗ Ψ' ⊳ P ⟹⇧^⇩τ P'› (*‹Ψ ⊗ Ψ' ⊳ P ⟹⇧^⇩τ P'›*) moreover from ‹Ψ ⊳ P' ⟼τ ≺ P''› (*‹(Ψ::'b) ⊳ (P'::('a, 'b, 'c) psi) ⟼ τ ≺ (P''::('a, 'b, 'c) psi)›*) have "Ψ ⊗ Ψ' ⊳ P' ⟼τ ≺ P''" by (rule weakenTransition (*‹?Ψ ⊳ ?P ⟼ ?Rs ⟹ ?Ψ ⊗ ?Ψ' ⊳ ?P ⟼ ?Rs›*)) ultimately show "?case" (*goal: ‹(Ψ::'b) ⊗ (Ψ'::'b) ⊳ (P::('a, 'b, 'c) psi) ⟹⇧^⇩τ (P''::('a, 'b, 'c) psi)›*) by (auto dest: tauActTauChain (*‹(?Ψ::'b) ⊳ (?P::('a, 'b, 'c) psi) ⟼ τ ≺ (?P'::('a, 'b, 'c) psi) ⟹ ?Ψ ⊳ ?P ⟹⇧^⇩τ ?P'›*)) qed end end
{ "path": "afp-2025-02-12/thys/Psi_Calculi/Weaken_Transition.thy", "repo": "afp-2025-02-12", "sha": "b3b69eadabd2756ac46be73ac12293e115fee66e4e13b2aa65d38fef5ceb02ae" }
(* Title: HOL/Auth/Guard/Guard_OtwayRees.thy Author: Frederic Blanqui, University of Cambridge Computer Laboratory Copyright 2002 University of Cambridge *) section‹Otway-Rees Protocol› theory Guard_OtwayRees imports Guard_Shared begin subsection‹messages used in the protocol› abbreviation nil :: "msg" where "nil == Number 0" abbreviation or1 :: "agent => agent => nat => event" where "or1 A B NA == Says A B ⦃Nonce NA, Agent A, Agent B, Ciph A ⦃Nonce NA, Agent A, Agent B⦄⦄" abbreviation or1' :: "agent => agent => agent => nat => msg => event" where "or1' A' A B NA X == Says A' B ⦃Nonce NA, Agent A, Agent B, X⦄" abbreviation or2 :: "agent => agent => nat => nat => msg => event" where "or2 A B NA NB X == Says B Server ⦃Nonce NA, Agent A, Agent B, X, Ciph B ⦃Nonce NA, Nonce NB, Agent A, Agent B⦄⦄" abbreviation or2' :: "agent => agent => agent => nat => nat => event" where "or2' B' A B NA NB == Says B' Server ⦃Nonce NA, Agent A, Agent B, Ciph A ⦃Nonce NA, Agent A, Agent B⦄, Ciph B ⦃Nonce NA, Nonce NB, Agent A, Agent B⦄⦄" abbreviation or3 :: "agent => agent => nat => nat => key => event" where "or3 A B NA NB K == Says Server B ⦃Nonce NA, Ciph A ⦃Nonce NA, Key K⦄, Ciph B ⦃Nonce NB, Key K⦄⦄" abbreviation or3':: "agent => msg => agent => agent => nat => nat => key => event" where "or3' S Y A B NA NB K == Says S B ⦃Nonce NA, Y, Ciph B ⦃Nonce NB, Key K⦄⦄" abbreviation or4 :: "agent => agent => nat => msg => event" where "or4 A B NA X == Says B A ⦃Nonce NA, X, nil⦄" abbreviation or4' :: "agent => agent => nat => key => event" where "or4' B' A NA K == Says B' A ⦃Nonce NA, Ciph A ⦃Nonce NA, Key K⦄, nil⦄" subsection‹definition of the protocol› inductive_set or :: "event list set" where Nil: "[] ∈ or" | Fake: "⟦evs ∈ or; X ∈ synth (analz (spies evs))⟧ ⟹ Says Spy B X # evs ∈ or" | OR1: "⟦evs1 ∈ or; Nonce NA ∉ used evs1⟧ ⟹ or1 A B NA # evs1 ∈ or" | OR2: "⟦evs2 ∈ or; or1' A' A B NA X ∈ set evs2; Nonce NB ∉ used evs2⟧ ⟹ or2 A B NA NB X # evs2 ∈ or" | OR3: "⟦evs3 ∈ or; or2' B' A B NA NB ∈ set evs3; Key K ∉ used evs3⟧ ⟹ or3 A B NA NB K # evs3 ∈ or" | OR4: "⟦evs4 ∈ or; or2 A B NA NB X ∈ set evs4; or3' S Y A B NA NB K ∈ set evs4⟧ ⟹ or4 A B NA X # evs4 ∈ or" subsection‹declarations for tactics› declare knows_Spy_partsEs [elim] declare Fake_parts_insert [THEN subsetD, dest] declare initState.simps [simp del] subsection‹general properties of or› lemma or_has_no_Gets: "evs ∈ or ⟹ ∀A X. Gets A X ∉ set evs" apply (erule or.induct (*‹⟦(?x::event list) ∈ Guard_OtwayRees.or; (?P::event list ⇒ bool) []; ⋀(evs::event list) (X::msg) B::agent. ⟦evs ∈ Guard_OtwayRees.or; ?P evs; X ∈ synth (analz (knows Spy evs))⟧ ⟹ ?P (Says Spy B X # evs); ⋀(evs1::event list) (NA::nat) (A::agent) B::agent. ⟦evs1 ∈ Guard_OtwayRees.or; ?P evs1; Nonce NA ∉ used evs1⟧ ⟹ ?P (or1' A A B NA (Ciph A ⦃Nonce NA, Agent A, Agent B⦄) # evs1); ⋀(evs2::event list) (A'::agent) (A::agent) (B::agent) (NA::nat) (X::msg) NB::nat. ⟦evs2 ∈ Guard_OtwayRees.or; ?P evs2; or1' A' A B NA X ∈ set evs2; Nonce NB ∉ used evs2⟧ ⟹ ?P (or2 A B NA NB X # evs2); ⋀(evs3::event list) (B'::agent) (A::agent) (B::agent) (NA::nat) (NB::nat) K::nat. ⟦evs3 ∈ Guard_OtwayRees.or; ?P evs3; or2' B' A B NA NB ∈ set evs3; Key K ∉ used evs3⟧ ⟹ ?P (or3 A B NA NB K # evs3); ⋀(evs4::event list) (A::agent) (B::agent) (NA::nat) (NB::nat) (X::msg) (S::agent) (Y::msg) K::nat. ⟦evs4 ∈ Guard_OtwayRees.or; ?P evs4; or2 A B NA NB X ∈ set evs4; Says S B ⦃Nonce NA, Y, Ciph B ⦃Nonce NB, Key K⦄⦄ ∈ set evs4⟧ ⟹ ?P (or4 A B NA X # evs4)⟧ ⟹ ?P ?x›*)) (*goals: 1. ‹∀(A::agent) X::msg. Gets A X ∉ set []› 2. ‹⋀(evs::event list) (X::msg) B::agent. ⟦evs ∈ Guard_OtwayRees.or; ∀(A::agent) X::msg. Gets A X ∉ set evs; X ∈ synth (analz (knows Spy evs))⟧ ⟹ ∀(A::agent) Xa::msg. Gets A Xa ∉ set (Says Spy B X # evs)› 3. ‹⋀(evs1::event list) (NA::nat) (A::agent) B::agent. ⟦evs1 ∈ Guard_OtwayRees.or; ∀(A::agent) X::msg. Gets A X ∉ set evs1; Nonce NA ∉ used evs1⟧ ⟹ ∀(Aa::agent) X::msg. Gets Aa X ∉ set (or1' A A B NA (Ciph A ⦃Nonce NA, Agent A, Agent B⦄) # evs1)› 4. ‹⋀(evs2::event list) (A'::agent) (A::agent) (B::agent) (NA::nat) (X::msg) NB::nat. ⟦evs2 ∈ Guard_OtwayRees.or; ∀(A::agent) X::msg. Gets A X ∉ set evs2; or1' A' A B NA X ∈ set evs2; Nonce NB ∉ used evs2⟧ ⟹ ∀(Aa::agent) Xa::msg. Gets Aa Xa ∉ set (or2 A B NA NB X # evs2)› 5. ‹⋀(evs3::event list) (B'::agent) (A::agent) (B::agent) (NA::nat) (NB::nat) K::nat. ⟦evs3 ∈ Guard_OtwayRees.or; ∀(A::agent) X::msg. Gets A X ∉ set evs3; or2' B' A B NA NB ∈ set evs3; Key K ∉ used evs3⟧ ⟹ ∀(Aa::agent) X::msg. Gets Aa X ∉ set (or3 A B NA NB K # evs3)› 6. ‹⋀(evs4::event list) (A::agent) (B::agent) (NA::nat) (NB::nat) (X::msg) (S::agent) (Y::msg) K::nat. ⟦evs4 ∈ Guard_OtwayRees.or; ∀(A::agent) X::msg. Gets A X ∉ set evs4; or2 A B NA NB X ∈ set evs4; Says S B ⦃Nonce NA, Y, Ciph B ⦃Nonce NB, Key K⦄⦄ ∈ set evs4⟧ ⟹ ∀(Aa::agent) Xa::msg. Gets Aa Xa ∉ set (or4 A B NA X # evs4)› 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 or_is_Gets_correct [iff]: "Gets_correct or" by (auto simp: Gets_correct_def (*‹Gets_correct (?p::event list set) ≡ ∀(evs::event list) (B::agent) X::msg. evs ∈ ?p ⟶ Gets B X ∈ set evs ⟶ (∃A::agent. Says A B X ∈ set evs)›*) dest: or_has_no_Gets (*‹(?evs::event list) ∈ Guard_OtwayRees.or ⟹ ∀(A::agent) X::msg. Gets A X ∉ set ?evs›*)) lemma or_is_one_step [iff]: "one_step or" unfolding one_step_def (*goal: ‹∀evs ev. ev # evs ∈ Guard_OtwayRees.or ⟶ evs ∈ Guard_OtwayRees.or›*) apply clarify (*goal: ‹∀evs ev. ev # evs ∈ Guard_OtwayRees.or ⟶ evs ∈ Guard_OtwayRees.or›*) apply (ind_cases "ev#evs ∈ or" for ev evs) (*goals: 1. ‹⋀evs ev X B. ⟦ev = Says Spy B X; evs ∈ Guard_OtwayRees.or; X ∈ synth (analz (knows Spy evs))⟧ ⟹ evs ∈ Guard_OtwayRees.or› 2. ‹⋀evs ev NA A B. ⟦ev = or1' A A B NA (Ciph A ⦃Nonce NA, Agent A, Agent B⦄); evs ∈ Guard_OtwayRees.or; Nonce NA ∉ used evs⟧ ⟹ evs ∈ Guard_OtwayRees.or› 3. ‹⋀evs ev A' A B NA X NB. ⟦ev = or2 A B NA NB X; evs ∈ Guard_OtwayRees.or; or1' A' A B NA X ∈ set evs; Nonce NB ∉ used evs⟧ ⟹ evs ∈ Guard_OtwayRees.or› 4. ‹⋀evs ev B' A B NA NB K. ⟦ev = or3 A B NA NB K; evs ∈ Guard_OtwayRees.or; or2' B' A B NA NB ∈ set evs; Key K ∉ used evs⟧ ⟹ evs ∈ Guard_OtwayRees.or› 5. ‹⋀evs ev A B NA NB X S Y K. ⟦ev = or4 A B NA X; evs ∈ Guard_OtwayRees.or; or2 A B NA NB X ∈ set evs; Says S B ⦃Nonce NA, Y, Ciph B ⦃Nonce NB, Key K⦄⦄ ∈ set evs⟧ ⟹ evs ∈ Guard_OtwayRees.or› 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 or_has_only_Says' [rule_format]: "evs ∈ or ⟹ ev ∈ set evs ⟶ (∃A B X. ev=Says A B X)" apply (erule or.induct (*‹⟦?x ∈ Guard_OtwayRees.or; ?P []; ⋀evs X B. ⟦evs ∈ Guard_OtwayRees.or; ?P evs; X ∈ synth (analz (knows Spy evs))⟧ ⟹ ?P (Says Spy B X # evs); ⋀evs1 NA A B. ⟦evs1 ∈ Guard_OtwayRees.or; ?P evs1; Nonce NA ∉ used evs1⟧ ⟹ ?P (or1' A A B NA (Ciph A ⦃Nonce NA, Agent A, Agent B⦄) # evs1); ⋀evs2 A' A B NA X NB. ⟦evs2 ∈ Guard_OtwayRees.or; ?P evs2; or1' A' A B NA X ∈ set evs2; Nonce NB ∉ used evs2⟧ ⟹ ?P (or2 A B NA NB X # evs2); ⋀evs3 B' A B NA NB K. ⟦evs3 ∈ Guard_OtwayRees.or; ?P evs3; or2' B' A B NA NB ∈ set evs3; Key K ∉ used evs3⟧ ⟹ ?P (or3 A B NA NB K # evs3); ⋀evs4 A B NA NB X S Y K. ⟦evs4 ∈ Guard_OtwayRees.or; ?P evs4; or2 A B NA NB X ∈ set evs4; Says S B ⦃Nonce NA, Y, Ciph B ⦃Nonce NB, Key K⦄⦄ ∈ set evs4⟧ ⟹ ?P (or4 A B NA X # evs4)⟧ ⟹ ?P ?x›*)) (*goals: 1. ‹ev ∈ set [] ⟶ (∃A B X. ev = Says A B X)› 2. ‹⋀evs X B. ⟦evs ∈ Guard_OtwayRees.or; ev ∈ set evs ⟶ (∃A B X. ev = Says A B X); X ∈ synth (analz (knows Spy evs))⟧ ⟹ ev ∈ set (Says Spy B X # evs) ⟶ (∃A B X. ev = Says A B X)› 3. ‹⋀evs1 NA A B. ⟦evs1 ∈ Guard_OtwayRees.or; ev ∈ set evs1 ⟶ (∃A B X. ev = Says A B X); Nonce NA ∉ used evs1⟧ ⟹ ev ∈ set (or1' A A B NA (Ciph A ⦃Nonce NA, Agent A, Agent B⦄) # evs1) ⟶ (∃A B X. ev = Says A B X)› 4. ‹⋀evs2 A' A B NA X NB. ⟦evs2 ∈ Guard_OtwayRees.or; ev ∈ set evs2 ⟶ (∃A B X. ev = Says A B X); or1' A' A B NA X ∈ set evs2; Nonce NB ∉ used evs2⟧ ⟹ ev ∈ set (or2 A B NA NB X # evs2) ⟶ (∃A B X. ev = Says A B X)› 5. ‹⋀evs3 B' A B NA NB K. ⟦evs3 ∈ Guard_OtwayRees.or; ev ∈ set evs3 ⟶ (∃A B X. ev = Says A B X); or2' B' A B NA NB ∈ set evs3; Key K ∉ used evs3⟧ ⟹ ev ∈ set (or3 A B NA NB K # evs3) ⟶ (∃A B X. ev = Says A B X)› 6. ‹⋀evs4 A B NA NB X S Y K. ⟦evs4 ∈ Guard_OtwayRees.or; ev ∈ set evs4 ⟶ (∃A B X. ev = Says A B X); or2 A B NA NB X ∈ set evs4; Says S B ⦃Nonce NA, Y, Ciph B ⦃Nonce NB, Key K⦄⦄ ∈ set evs4⟧ ⟹ ev ∈ set (or4 A B NA X # evs4) ⟶ (∃A B X. ev = Says A B 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*) . lemma or_has_only_Says [iff]: "has_only_Says or" by (auto simp: has_only_Says_def (*‹has_only_Says ?p ≡ ∀evs ev. evs ∈ ?p ⟶ ev ∈ set evs ⟶ (∃A B X. ev = Says A B X)›*) dest: or_has_only_Says' (*‹⟦?evs ∈ Guard_OtwayRees.or; ?ev ∈ set ?evs⟧ ⟹ ∃A B X. ?ev = Says A B X›*)) subsection‹or is regular› lemma or1'_parts_spies [dest]: "or1' A' A B NA X ∈ set evs ⟹ X ∈ parts (spies evs)" by blast lemma or2_parts_spies [dest]: "or2 A B NA NB X ∈ set evs ⟹ X ∈ parts (spies evs)" by blast lemma or3_parts_spies [dest]: "Says S B ⦃NA, Y, Ciph B ⦃NB, K⦄⦄ ∈ set evs ⟹ K ∈ parts (spies evs)" by blast lemma or_is_regular [iff]: "regular or" apply (simp only: regular_def (*‹regular (?p::event list set) ≡ ∀(evs::event list) A::agent. evs ∈ ?p ⟶ (Key (shrK A) ∈ parts (knows Spy evs)) = (A ∈ bad)›*)) (*goal: ‹regular Guard_OtwayRees.or›*) apply clarify (*goal: ‹∀evs A. evs ∈ Guard_OtwayRees.or ⟶ (Key (shrK A) ∈ parts (knows Spy evs)) = (A ∈ bad)›*) apply (erule or.induct (*‹⟦?x ∈ Guard_OtwayRees.or; ?P []; ⋀evs X B. ⟦evs ∈ Guard_OtwayRees.or; ?P evs; X ∈ synth (analz (knows Spy evs))⟧ ⟹ ?P (Says Spy B X # evs); ⋀evs1 NA A B. ⟦evs1 ∈ Guard_OtwayRees.or; ?P evs1; Nonce NA ∉ used evs1⟧ ⟹ ?P (or1' A A B NA (Ciph A ⦃Nonce NA, Agent A, Agent B⦄) # evs1); ⋀evs2 A' A B NA X NB. ⟦evs2 ∈ Guard_OtwayRees.or; ?P evs2; or1' A' A B NA X ∈ set evs2; Nonce NB ∉ used evs2⟧ ⟹ ?P (or2 A B NA NB X # evs2); ⋀evs3 B' A B NA NB K. ⟦evs3 ∈ Guard_OtwayRees.or; ?P evs3; or2' B' A B NA NB ∈ set evs3; Key K ∉ used evs3⟧ ⟹ ?P (or3 A B NA NB K # evs3); ⋀evs4 A B NA NB X S Y K. ⟦evs4 ∈ Guard_OtwayRees.or; ?P evs4; or2 A B NA NB X ∈ set evs4; Says S B ⦃Nonce NA, Y, Ciph B ⦃Nonce NB, Key K⦄⦄ ∈ set evs4⟧ ⟹ ?P (or4 A B NA X # evs4)⟧ ⟹ ?P ?x›*)) (*goals: 1. ‹⋀evs A. (Key (shrK A) ∈ parts (knows Spy [])) = (A ∈ bad)› 2. ‹⋀evs A evsa X B. ⟦evsa ∈ Guard_OtwayRees.or; (Key (shrK A) ∈ parts (knows Spy evsa)) = (A ∈ bad); X ∈ synth (analz (knows Spy evsa))⟧ ⟹ (Key (shrK A) ∈ parts (knows Spy (Says Spy B X # evsa))) = (A ∈ bad)› 3. ‹⋀evs A evs1 NA Aa B. ⟦evs1 ∈ Guard_OtwayRees.or; (Key (shrK A) ∈ parts (knows Spy evs1)) = (A ∈ bad); Nonce NA ∉ used evs1⟧ ⟹ (Key (shrK A) ∈ parts (knows Spy (or1' Aa Aa B NA (Ciph Aa ⦃Nonce NA, Agent Aa, Agent B⦄) # evs1))) = (A ∈ bad)› 4. ‹⋀evs A evs2 A' Aa B NA X NB. ⟦evs2 ∈ Guard_OtwayRees.or; (Key (shrK A) ∈ parts (knows Spy evs2)) = (A ∈ bad); or1' A' Aa B NA X ∈ set evs2; Nonce NB ∉ used evs2⟧ ⟹ (Key (shrK A) ∈ parts (knows Spy (or2 Aa B NA NB X # evs2))) = (A ∈ bad)› 5. ‹⋀evs A evs3 B' Aa B NA NB K. ⟦evs3 ∈ Guard_OtwayRees.or; (Key (shrK A) ∈ parts (knows Spy evs3)) = (A ∈ bad); or2' B' Aa B NA NB ∈ set evs3; Key K ∉ used evs3⟧ ⟹ (Key (shrK A) ∈ parts (knows Spy (or3 Aa B NA NB K # evs3))) = (A ∈ bad)› 6. ‹⋀evs A evs4 Aa B NA NB X S Y K. ⟦evs4 ∈ Guard_OtwayRees.or; (Key (shrK A) ∈ parts (knows Spy evs4)) = (A ∈ bad); or2 Aa B NA NB X ∈ set evs4; Says S B ⦃Nonce NA, Y, Ciph B ⦃Nonce NB, Key K⦄⦄ ∈ set evs4⟧ ⟹ (Key (shrK A) ∈ parts (knows Spy (or4 Aa B NA X # evs4))) = (A ∈ bad)› discuss goal 1*) apply (simp add: initState.simps (*‹initState Server = Key ` range shrK› ‹initState (Friend ?i) = {Key (shrK (Friend ?i))}› ‹initState Spy = Key ` shrK ` bad›*) knows.simps (*‹knows ?A [] = initState ?A› ‹knows ?A (?ev # ?evs) = (if ?A = Spy then case ?ev of Says A' B X ⇒ insert X (knows Spy ?evs) | Gets A' X ⇒ knows Spy ?evs | Notes A' X ⇒ if A' ∈ bad then insert X (knows Spy ?evs) else knows Spy ?evs else case ?ev of Says A' B X ⇒ if A' = ?A then insert X (knows ?A ?evs) else knows ?A ?evs | Gets A' X ⇒ if A' = ?A then insert X (knows ?A ?evs) else knows ?A ?evs | Notes A' X ⇒ if A' = ?A then insert X (knows ?A ?evs) else knows ?A ?evs)›*)) (*discuss goal 2*) apply (simp add: initState.simps (*‹initState Server = Key ` range shrK› ‹initState (Friend (?i::nat)) = {Key (shrK (Friend ?i))}› ‹initState Spy = Key ` shrK ` bad›*) knows.simps (*‹knows (?A::agent) [] = initState ?A› ‹knows (?A::agent) ((?ev::event) # (?evs::event list)) = (if ?A = Spy then case ?ev of Says (A'::agent) (B::agent) (X::msg) ⇒ insert X (knows Spy ?evs) | Gets (A'::agent) (X::msg) ⇒ knows Spy ?evs | Notes (A'::agent) (X::msg) ⇒ if A' ∈ bad then insert X (knows Spy ?evs) else knows Spy ?evs else case ?ev of Says (A'::agent) (B::agent) (X::msg) ⇒ if A' = ?A then insert X (knows ?A ?evs) else knows ?A ?evs | Gets (A'::agent) (X::msg) ⇒ if A' = ?A then insert X (knows ?A ?evs) else knows ?A ?evs | Notes (A'::agent) (X::msg) ⇒ if A' = ?A then insert X (knows ?A ?evs) else knows ?A ?evs)›*)) (*top goal: ‹⋀evs A evsa X B. ⟦evsa ∈ Guard_OtwayRees.or; (Key (shrK A) ∈ parts (knows Spy evsa)) = (A ∈ bad); X ∈ synth (analz (knows Spy evsa))⟧ ⟹ (Key (shrK A) ∈ parts (knows Spy (Says Spy B X # evsa))) = (A ∈ bad)› and 4 goals remain*) apply ((auto dest: parts_sub (*‹⟦?X ∈ parts ?G; ?G ⊆ ?H⟧ ⟹ ?X ∈ parts ?H›*))[1]) (*discuss goal 3*) apply (simp add: initState.simps (*‹initState Server = Key ` range shrK› ‹initState (Friend ?i) = {Key (shrK (Friend ?i))}› ‹initState Spy = Key ` shrK ` bad›*) knows.simps (*‹knows ?A [] = initState ?A› ‹knows ?A (?ev # ?evs) = (if ?A = Spy then case ?ev of Says A' B X ⇒ insert X (knows Spy ?evs) | Gets A' X ⇒ knows Spy ?evs | Notes A' X ⇒ if A' ∈ bad then insert X (knows Spy ?evs) else knows Spy ?evs else case ?ev of Says A' B X ⇒ if A' = ?A then insert X (knows ?A ?evs) else knows ?A ?evs | Gets A' X ⇒ if A' = ?A then insert X (knows ?A ?evs) else knows ?A ?evs | Notes A' X ⇒ if A' = ?A then insert X (knows ?A ?evs) else knows ?A ?evs)›*)) (*discuss goal 4*) apply (simp add: initState.simps (*‹initState Server = Key ` range shrK› ‹initState (Friend ?i) = {Key (shrK (Friend ?i))}› ‹initState Spy = Key ` shrK ` bad›*) knows.simps (*‹knows ?A [] = initState ?A› ‹knows ?A (?ev # ?evs) = (if ?A = Spy then case ?ev of Says A' B X ⇒ insert X (knows Spy ?evs) | Gets A' X ⇒ knows Spy ?evs | Notes A' X ⇒ if A' ∈ bad then insert X (knows Spy ?evs) else knows Spy ?evs else case ?ev of Says A' B X ⇒ if A' = ?A then insert X (knows ?A ?evs) else knows ?A ?evs | Gets A' X ⇒ if A' = ?A then insert X (knows ?A ?evs) else knows ?A ?evs | Notes A' X ⇒ if A' = ?A then insert X (knows ?A ?evs) else knows ?A ?evs)›*)) (*top goal: ‹⋀evs A evs2 A' Aa B NA X NB. ⟦evs2 ∈ Guard_OtwayRees.or; (Key (shrK A) ∈ parts (knows Spy evs2)) = (A ∈ bad); or1' A' Aa B NA X ∈ set evs2; Nonce NB ∉ used evs2⟧ ⟹ (Key (shrK A) ∈ parts (knows Spy (or2 Aa B NA NB X # evs2))) = (A ∈ bad)› and 2 goals remain*) apply ((auto dest: parts_sub (*‹⟦?X ∈ parts ?G; ?G ⊆ ?H⟧ ⟹ ?X ∈ parts ?H›*))[1]) (*discuss goal 5*) apply (simp add: initState.simps (*‹initState Server = Key ` range shrK› ‹initState (Friend ?i) = {Key (shrK (Friend ?i))}› ‹initState Spy = Key ` shrK ` bad›*) knows.simps (*‹knows ?A [] = initState ?A› ‹knows ?A (?ev # ?evs) = (if ?A = Spy then case ?ev of Says A' B X ⇒ insert X (knows Spy ?evs) | Gets A' X ⇒ knows Spy ?evs | Notes A' X ⇒ if A' ∈ bad then insert X (knows Spy ?evs) else knows Spy ?evs else case ?ev of Says A' B X ⇒ if A' = ?A then insert X (knows ?A ?evs) else knows ?A ?evs | Gets A' X ⇒ if A' = ?A then insert X (knows ?A ?evs) else knows ?A ?evs | Notes A' X ⇒ if A' = ?A then insert X (knows ?A ?evs) else knows ?A ?evs)›*)) (*discuss goal 6*) apply (simp add: initState.simps (*‹initState Server = Key ` range shrK› ‹initState (Friend ?i) = {Key (shrK (Friend ?i))}› ‹initState Spy = Key ` shrK ` bad›*) knows.simps (*‹knows ?A [] = initState ?A› ‹knows ?A (?ev # ?evs) = (if ?A = Spy then case ?ev of Says A' B X ⇒ insert X (knows Spy ?evs) | Gets A' X ⇒ knows Spy ?evs | Notes A' X ⇒ if A' ∈ bad then insert X (knows Spy ?evs) else knows Spy ?evs else case ?ev of Says A' B X ⇒ if A' = ?A then insert X (knows ?A ?evs) else knows ?A ?evs | Gets A' X ⇒ if A' = ?A then insert X (knows ?A ?evs) else knows ?A ?evs | Notes A' X ⇒ if A' = ?A then insert X (knows ?A ?evs) else knows ?A ?evs)›*)) (*goal: ‹⋀evs A evs4 Aa B NA NB X S Y K. ⟦evs4 ∈ Guard_OtwayRees.or; (Key (shrK A) ∈ parts (knows Spy evs4)) = (A ∈ bad); or2 Aa B NA NB X ∈ set evs4; Says S B ⦃Nonce NA, Y, Ciph B ⦃Nonce NB, Key K⦄⦄ ∈ set evs4⟧ ⟹ (Key (shrK A) ∈ parts (knows Spy (or4 Aa B NA X # evs4))) = (A ∈ bad)›*) apply ((auto dest: parts_sub (*‹⟦?X ∈ parts ?G; ?G ⊆ ?H⟧ ⟹ ?X ∈ parts ?H›*))[1]) (*proven 6 subgoals*) . subsection‹guardedness of KAB› lemma Guard_KAB [rule_format]: "⟦evs ∈ or; A ∉ bad; B ∉ bad⟧ ⟹ or3 A B NA NB K ∈ set evs ⟶ GuardK K {shrK A,shrK B} (spies evs)" apply (erule or.induct (*‹⟦(?x::event list) ∈ Guard_OtwayRees.or; (?P::event list ⇒ bool) []; ⋀(evs::event list) (X::msg) B::agent. ⟦evs ∈ Guard_OtwayRees.or; ?P evs; X ∈ synth (analz (knows Spy evs))⟧ ⟹ ?P (Says Spy B X # evs); ⋀(evs1::event list) (NA::nat) (A::agent) B::agent. ⟦evs1 ∈ Guard_OtwayRees.or; ?P evs1; Nonce NA ∉ used evs1⟧ ⟹ ?P (or1' A A B NA (Ciph A ⦃Nonce NA, Agent A, Agent B⦄) # evs1); ⋀(evs2::event list) (A'::agent) (A::agent) (B::agent) (NA::nat) (X::msg) NB::nat. ⟦evs2 ∈ Guard_OtwayRees.or; ?P evs2; or1' A' A B NA X ∈ set evs2; Nonce NB ∉ used evs2⟧ ⟹ ?P (or2 A B NA NB X # evs2); ⋀(evs3::event list) (B'::agent) (A::agent) (B::agent) (NA::nat) (NB::nat) K::nat. ⟦evs3 ∈ Guard_OtwayRees.or; ?P evs3; or2' B' A B NA NB ∈ set evs3; Key K ∉ used evs3⟧ ⟹ ?P (or3 A B NA NB K # evs3); ⋀(evs4::event list) (A::agent) (B::agent) (NA::nat) (NB::nat) (X::msg) (S::agent) (Y::msg) K::nat. ⟦evs4 ∈ Guard_OtwayRees.or; ?P evs4; or2 A B NA NB X ∈ set evs4; Says S B ⦃Nonce NA, Y, Ciph B ⦃Nonce NB, Key K⦄⦄ ∈ set evs4⟧ ⟹ ?P (or4 A B NA X # evs4)⟧ ⟹ ?P ?x›*)) (*goals: 1. ‹⟦A ∉ bad; B ∉ bad⟧ ⟹ or3 A B NA NB K ∈ set [] ⟶ GuardK K {shrK A, shrK B} (knows Spy [])› 2. ‹⋀evs X Ba. ⟦A ∉ bad; B ∉ bad; evs ∈ Guard_OtwayRees.or; or3 A B NA NB K ∈ set evs ⟶ GuardK K {shrK A, shrK B} (knows Spy evs); X ∈ synth (analz (knows Spy evs))⟧ ⟹ or3 A B NA NB K ∈ set (Says Spy Ba X # evs) ⟶ GuardK K {shrK A, shrK B} (knows Spy (Says Spy Ba X # evs))› 3. ‹⋀evs1 NAa Aa Ba. ⟦A ∉ bad; B ∉ bad; evs1 ∈ Guard_OtwayRees.or; or3 A B NA NB K ∈ set evs1 ⟶ GuardK K {shrK A, shrK B} (knows Spy evs1); Nonce NAa ∉ used evs1⟧ ⟹ or3 A B NA NB K ∈ set (or1' Aa Aa Ba NAa (Ciph Aa ⦃Nonce NAa, Agent Aa, Agent Ba⦄) # evs1) ⟶ GuardK K {shrK A, shrK B} (knows Spy (or1' Aa Aa Ba NAa (Ciph Aa ⦃Nonce NAa, Agent Aa, Agent Ba⦄) # evs1))› 4. ‹⋀evs2 A' Aa Ba NAa X NBa. ⟦A ∉ bad; B ∉ bad; evs2 ∈ Guard_OtwayRees.or; or3 A B NA NB K ∈ set evs2 ⟶ GuardK K {shrK A, shrK B} (knows Spy evs2); or1' A' Aa Ba NAa X ∈ set evs2; Nonce NBa ∉ used evs2⟧ ⟹ or3 A B NA NB K ∈ set (or2 Aa Ba NAa NBa X # evs2) ⟶ GuardK K {shrK A, shrK B} (knows Spy (or2 Aa Ba NAa NBa X # evs2))› 5. ‹⋀evs3 B' Aa Ba NAa NBa Ka. ⟦A ∉ bad; B ∉ bad; evs3 ∈ Guard_OtwayRees.or; or3 A B NA NB K ∈ set evs3 ⟶ GuardK K {shrK A, shrK B} (knows Spy evs3); or2' B' Aa Ba NAa NBa ∈ set evs3; Key Ka ∉ used evs3⟧ ⟹ or3 A B NA NB K ∈ set (or3 Aa Ba NAa NBa Ka # evs3) ⟶ GuardK K {shrK A, shrK B} (knows Spy (or3 Aa Ba NAa NBa Ka # evs3))› 6. ‹⋀evs4 Aa Ba NAa NBa X S Y Ka. ⟦A ∉ bad; B ∉ bad; evs4 ∈ Guard_OtwayRees.or; or3 A B NA NB K ∈ set evs4 ⟶ GuardK K {shrK A, shrK B} (knows Spy evs4); or2 Aa Ba NAa NBa X ∈ set evs4; Says S Ba ⦃Nonce NAa, Y, Ciph Ba ⦃Nonce NBa, Key Ka⦄⦄ ∈ set evs4⟧ ⟹ or3 A B NA NB K ∈ set (or4 Aa Ba NAa X # evs4) ⟶ GuardK K {shrK A, shrK B} (knows Spy (or4 Aa Ba NAa X # evs4))› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*top goal: ‹⋀(evs::event list) (X::msg) Ba::agent. ⟦(A::agent) ∉ bad; (B::agent) ∉ bad; evs ∈ Guard_OtwayRees.or; or3 A B (NA::nat) (NB::nat) (K::nat) ∈ set evs ⟶ GuardK K {shrK A, shrK B} (knows Spy evs); X ∈ synth (analz (knows Spy evs))⟧ ⟹ or3 A B NA NB K ∈ set (Says Spy Ba X # evs) ⟶ GuardK K {shrK A, shrK B} (knows Spy (Says Spy Ba X # evs))› and 4 goals remain*) apply clarify (*top goal: ‹⋀evs X. ⟦A ∉ bad; B ∉ bad; evs ∈ Guard_OtwayRees.or; or3 A B NA NB K ∈ set evs ⟶ GuardK K {shrK A, shrK B} (knows Spy evs); X ∈ synth (analz (knows Spy evs))⟧ ⟹ or3 A B NA NB K ∈ set evs ⟶ X ∈ guardK K {shrK A, shrK B}› and 4 goals remain*) apply (erule in_synth_GuardK (*‹⟦?X ∈ synth ?G; GuardK ?n ?Ks ?G⟧ ⟹ ?X ∈ guardK ?n ?Ks›*)) (*top goal: ‹⋀evs X. ⟦A ∉ bad; B ∉ bad; evs ∈ Guard_OtwayRees.or; X ∈ synth (analz (knows Spy evs)); or3 A B NA NB K ∈ set evs; GuardK K {shrK A, shrK B} (knows Spy evs)⟧ ⟹ X ∈ guardK K {shrK A, shrK B}› and 4 goals remain*) apply (erule GuardK_analz (*‹⟦GuardK ?n ?Ks ?G; ∀K. K ∈ ?Ks ⟶ Key K ∉ analz ?G⟧ ⟹ GuardK ?n ?Ks (analz ?G)›*)) (*top goal: ‹⋀evs X. ⟦A ∉ bad; B ∉ bad; evs ∈ Guard_OtwayRees.or; or3 A B NA NB K ∈ set evs; GuardK K {shrK A, shrK B} (knows Spy evs)⟧ ⟹ GuardK K {shrK A, shrK B} (analz (knows Spy evs))› and 4 goals remain*) apply simp (*discuss goal 3*) apply simp (*top goal: ‹⋀evs1 NAa Aa Ba. ⟦A ∉ bad; B ∉ bad; evs1 ∈ Guard_OtwayRees.or; or3 A B NA NB K ∈ set evs1 ⟶ GuardK K {shrK A, shrK B} (knows Spy evs1); Nonce NAa ∉ used evs1⟧ ⟹ or3 A B NA NB K ∈ set (or1' Aa Aa Ba NAa (Ciph Aa ⦃Nonce NAa, Agent Aa, Agent Ba⦄) # evs1) ⟶ GuardK K {shrK A, shrK B} (knows Spy (or1' Aa Aa Ba NAa (Ciph Aa ⦃Nonce NAa, Agent Aa, Agent Ba⦄) # evs1))› and 3 goals remain*) apply blast (*discuss goal 4*) apply simp (*top goal: ‹⋀evs2 A' Aa Ba NAa X NBa. ⟦A ∉ bad; B ∉ bad; evs2 ∈ Guard_OtwayRees.or; or3 A B NA NB K ∈ set evs2 ⟶ GuardK K {shrK A, shrK B} (knows Spy evs2); or1' A' Aa Ba NAa X ∈ set evs2; Nonce NBa ∉ used evs2⟧ ⟹ or3 A B NA NB K ∈ set (or2 Aa Ba NAa NBa X # evs2) ⟶ GuardK K {shrK A, shrK B} (knows Spy (or2 Aa Ba NAa NBa X # evs2))› and 2 goals remain*) apply ((safe)[1]) (*goals: 1. ‹⋀evs2 A' Aa Ba NAa X NBa. ⟦A ∉ bad; B ∉ bad; evs2 ∈ Guard_OtwayRees.or; or1' A' Aa Ba NAa X ∈ set evs2; Nonce NBa ∉ used evs2; or3 A B NA NB K ∈ set evs2; GuardK K {shrK A, shrK B} (knows Spy evs2)⟧ ⟹ X ∈ guardK K {shrK A, shrK B}› 2. ‹⋀evs2 A' Aa Ba NAa X NBa. ⟦A ∉ bad; B ∉ bad; evs2 ∈ Guard_OtwayRees.or; or1' A' Aa Ba NAa X ∈ set evs2; Nonce NBa ∉ used evs2; or3 A B NA NB K ∈ set evs2; GuardK K {shrK A, shrK B} (knows Spy evs2)⟧ ⟹ Ciph Ba ⦃Nonce NAa, Nonce NBa, Agent Aa, Agent Ba⦄ ∈ guardK K {shrK A, shrK B}› discuss goal 1*) apply (blast dest: Says_imp_spies (*‹Says ?A ?B ?X ∈ set ?evs ⟹ ?X ∈ knows Spy ?evs›*)) (*discuss goal 2*) apply blast (*proven 2 subgoals*) (*discuss goal 5*) apply simp (*top goal: ‹⋀evs3 B' Aa Ba NAa NBa Ka. ⟦A ∉ bad; B ∉ bad; evs3 ∈ Guard_OtwayRees.or; or3 A B NA NB K ∈ set evs3 ⟶ GuardK K {shrK A, shrK B} (knows Spy evs3); or2' B' Aa Ba NAa NBa ∈ set evs3; Key Ka ∉ used evs3⟧ ⟹ or3 A B NA NB K ∈ set (or3 Aa Ba NAa NBa Ka # evs3) ⟶ GuardK K {shrK A, shrK B} (knows Spy (or3 Aa Ba NAa NBa Ka # evs3))› and 1 goal remains*) apply ((safe)[1]) (*goals: 1. ‹⋀evs3 B' Aa Ba NAa NBa Ka. ⟦A ∉ bad; B ∉ bad; evs3 ∈ Guard_OtwayRees.or; or2' B' A B NA NB ∈ set evs3; Key K ∉ used evs3; or3 A B NA NB K ∉ set evs3⟧ ⟹ GuardK K {shrK A, shrK B} (knows Spy evs3)› 2. ‹⋀evs3 B' Aa Ba NAa NBa Ka. ⟦A ∉ bad; B ∉ bad; evs3 ∈ Guard_OtwayRees.or; or2' B' Aa Ba NAa NBa ∈ set evs3; Key Ka ∉ used evs3; GuardK K {shrK A, shrK B} (knows Spy evs3); or3 A B NA NB K ∈ set evs3⟧ ⟹ Ciph Aa ⦃Nonce NAa, Key Ka⦄ ∈ guardK K {shrK A, shrK B}› 3. ‹⋀evs3 B' Aa Ba NAa NBa Ka. ⟦A ∉ bad; B ∉ bad; evs3 ∈ Guard_OtwayRees.or; or2' B' Aa Ba NAa NBa ∈ set evs3; Key Ka ∉ used evs3; GuardK K {shrK A, shrK B} (knows Spy evs3); or3 A B NA NB K ∈ set evs3⟧ ⟹ Ciph Ba ⦃Nonce NBa, Key Ka⦄ ∈ guardK K {shrK A, shrK B}› discuss goal 1*) apply blast (*discuss goal 2*) apply (drule_tac A=Server in Key_neq (*‹⟦Key ?n' ∉ used ?evs; Says ?A ?B ?X ∈ set ?evs; Key ?n ∈ parts {?X}⟧ ⟹ ?n ≠ ?n'›*)) (*goals: 1. ‹⋀evs3 B' Aa Ba NAa NBa Ka. ⟦A ∉ bad; B ∉ bad; evs3 ∈ Guard_OtwayRees.or; or2' B' Aa Ba NAa NBa ∈ set evs3; GuardK K {shrK A, shrK B} (knows Spy evs3); or3 A B NA NB K ∈ set evs3⟧ ⟹ Says Server (?B121 evs3 B' Aa Ba NAa NBa Ka) (?X121 evs3 B' Aa Ba NAa NBa Ka) ∈ set evs3› 2. ‹⋀evs3 B' Aa Ba NAa NBa Ka. ⟦A ∉ bad; B ∉ bad; evs3 ∈ Guard_OtwayRees.or; or2' B' Aa Ba NAa NBa ∈ set evs3; GuardK K {shrK A, shrK B} (knows Spy evs3); or3 A B NA NB K ∈ set evs3⟧ ⟹ Key (?n121 evs3 B' Aa Ba NAa NBa Ka) ∈ parts {?X121 evs3 B' Aa Ba NAa NBa Ka}› 3. ‹⋀evs3 B' Aa Ba NAa NBa Ka. ⟦A ∉ bad; B ∉ bad; evs3 ∈ Guard_OtwayRees.or; or2' B' Aa Ba NAa NBa ∈ set evs3; GuardK K {shrK A, shrK B} (knows Spy evs3); or3 A B NA NB K ∈ set evs3; ?n121 evs3 B' Aa Ba NAa NBa Ka ≠ Ka⟧ ⟹ Ciph Aa ⦃Nonce NAa, Key Ka⦄ ∈ guardK K {shrK A, shrK B}› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*discuss goal 3*) apply (rule No_Key (*‹Key ?n ∉ parts {?X} ⟹ ?X ∈ guardK ?n ?Ks›*)) (*top goal: ‹⋀(evs3::event list) (B'::agent) (Aa::agent) (Ba::agent) (NAa::nat) (NBa::nat) Ka::nat. ⟦(A::agent) ∉ bad; (B::agent) ∉ bad; evs3 ∈ Guard_OtwayRees.or; or2' B' Aa Ba NAa NBa ∈ set evs3; GuardK (K::nat) {shrK A, shrK B} (knows Spy evs3); or3 A B (NA::nat) (NB::nat) K ∈ set evs3; K ≠ Ka⟧ ⟹ Ciph Aa ⦃Nonce NAa, Key Ka⦄ ∈ guardK K {shrK A, shrK B}› and 2 goals remain*) apply simp (*proven 3 subgoals*) (*discuss goal 3*) apply (drule_tac A=Server in Key_neq (*‹⟦Key ?n' ∉ used ?evs; Says ?A ?B ?X ∈ set ?evs; Key ?n ∈ parts {?X}⟧ ⟹ ?n ≠ ?n'›*)) (*goals: 1. ‹⋀(evs3::event list) (B'::agent) (Aa::agent) (Ba::agent) (NAa::nat) (NBa::nat) Ka::nat. ⟦(A::agent) ∉ bad; (B::agent) ∉ bad; evs3 ∈ Guard_OtwayRees.or; or2' B' Aa Ba NAa NBa ∈ set evs3; GuardK (K::nat) {shrK A, shrK B} (knows Spy evs3); or3 A B (NA::nat) (NB::nat) K ∈ set evs3⟧ ⟹ Says Server ((?B126::event list ⇒ agent ⇒ agent ⇒ agent ⇒ nat ⇒ nat ⇒ nat ⇒ agent) evs3 B' Aa Ba NAa NBa Ka) ((?X126::event list ⇒ agent ⇒ agent ⇒ agent ⇒ nat ⇒ nat ⇒ nat ⇒ msg) evs3 B' Aa Ba NAa NBa Ka) ∈ set evs3› 2. ‹⋀(evs3::event list) (B'::agent) (Aa::agent) (Ba::agent) (NAa::nat) (NBa::nat) Ka::nat. ⟦(A::agent) ∉ bad; (B::agent) ∉ bad; evs3 ∈ Guard_OtwayRees.or; or2' B' Aa Ba NAa NBa ∈ set evs3; GuardK (K::nat) {shrK A, shrK B} (knows Spy evs3); or3 A B (NA::nat) (NB::nat) K ∈ set evs3⟧ ⟹ Key ((?n126::event list ⇒ agent ⇒ agent ⇒ agent ⇒ nat ⇒ nat ⇒ nat ⇒ nat) evs3 B' Aa Ba NAa NBa Ka) ∈ parts {(?X126::event list ⇒ agent ⇒ agent ⇒ agent ⇒ nat ⇒ nat ⇒ nat ⇒ msg) evs3 B' Aa Ba NAa NBa Ka}› 3. ‹⋀(evs3::event list) (B'::agent) (Aa::agent) (Ba::agent) (NAa::nat) (NBa::nat) Ka::nat. ⟦(A::agent) ∉ bad; (B::agent) ∉ bad; evs3 ∈ Guard_OtwayRees.or; or2' B' Aa Ba NAa NBa ∈ set evs3; GuardK (K::nat) {shrK A, shrK B} (knows Spy evs3); or3 A B (NA::nat) (NB::nat) K ∈ set evs3; (?n126::event list ⇒ agent ⇒ agent ⇒ agent ⇒ nat ⇒ nat ⇒ nat ⇒ nat) evs3 B' Aa Ba NAa NBa Ka ≠ Ka⟧ ⟹ Ciph Ba ⦃Nonce NBa, Key Ka⦄ ∈ guardK K {shrK A, shrK B}› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*discuss goal 3*) apply (rule No_Key (*‹Key ?n ∉ parts {?X} ⟹ ?X ∈ guardK ?n ?Ks›*)) (*top goal: ‹⋀evs3 B' Aa Ba NAa NBa Ka. ⟦A ∉ bad; B ∉ bad; evs3 ∈ Guard_OtwayRees.or; or2' B' Aa Ba NAa NBa ∈ set evs3; GuardK K {shrK A, shrK B} (knows Spy evs3); or3 A B NA NB K ∈ set evs3; K ≠ Ka⟧ ⟹ Ciph Ba ⦃Nonce NBa, Key Ka⦄ ∈ guardK K {shrK A, shrK B}› and 1 goal remains*) apply simp (*proven 3 subgoals*) (*proven 3 subgoals*) (*discuss goal 6*) apply simp (*goal: ‹⋀evs4 Aa Ba NAa NBa X S Y Ka. ⟦A ∉ bad; B ∉ bad; evs4 ∈ Guard_OtwayRees.or; or3 A B NA NB K ∈ set evs4 ⟶ GuardK K {shrK A, shrK B} (knows Spy evs4); or2 Aa Ba NAa NBa X ∈ set evs4; Says S Ba ⦃Nonce NAa, Y, Ciph Ba ⦃Nonce NBa, Key Ka⦄⦄ ∈ set evs4⟧ ⟹ or3 A B NA NB K ∈ set (or4 Aa Ba NAa X # evs4) ⟶ GuardK K {shrK A, shrK B} (knows Spy (or4 Aa Ba NAa X # evs4))›*) apply ((safe)[1]) (*goal: ‹⋀(evs4::event list) (Aa::agent) (Ba::agent) (NAa::nat) (NBa::nat) (X::msg) (S::agent) (Y::msg) Ka::nat. ⟦(A::agent) ∉ bad; (B::agent) ∉ bad; evs4 ∈ Guard_OtwayRees.or; or3 A B (NA::nat) (NB::nat) (K::nat) ∈ set evs4 ⟶ GuardK K {shrK A, shrK B} (knows Spy evs4); or2 Aa Ba NAa NBa X ∈ set evs4; Says S Ba ⦃Nonce NAa, Y, Ciph Ba ⦃Nonce NBa, Key Ka⦄⦄ ∈ set evs4⟧ ⟹ or3 A B NA NB K ∈ set evs4 ⟶ X ∈ guardK K {shrK A, shrK B}›*) apply (blast dest: Says_imp_spies (*‹Says ?A ?B ?X ∈ set ?evs ⟹ ?X ∈ knows Spy ?evs›*) in_GuardK_kparts (*‹⟦?X ∈ ?G; GuardK ?n ?Ks ?G; ?Y ∈ kparts {?X}⟧ ⟹ ?Y ∈ guardK ?n ?Ks›*)) (*proven 6 subgoals*) . subsection‹guardedness of NB› lemma Guard_NB [rule_format]: "⟦evs ∈ or; B ∉ bad⟧ ⟹ or2 A B NA NB X ∈ set evs ⟶ Guard NB {shrK B} (spies evs)" apply (erule or.induct (*‹⟦?x ∈ Guard_OtwayRees.or; ?P []; ⋀evs X B. ⟦evs ∈ Guard_OtwayRees.or; ?P evs; X ∈ synth (analz (knows Spy evs))⟧ ⟹ ?P (Says Spy B X # evs); ⋀evs1 NA A B. ⟦evs1 ∈ Guard_OtwayRees.or; ?P evs1; Nonce NA ∉ used evs1⟧ ⟹ ?P (or1' A A B NA (Ciph A ⦃Nonce NA, Agent A, Agent B⦄) # evs1); ⋀evs2 A' A B NA X NB. ⟦evs2 ∈ Guard_OtwayRees.or; ?P evs2; or1' A' A B NA X ∈ set evs2; Nonce NB ∉ used evs2⟧ ⟹ ?P (or2 A B NA NB X # evs2); ⋀evs3 B' A B NA NB K. ⟦evs3 ∈ Guard_OtwayRees.or; ?P evs3; or2' B' A B NA NB ∈ set evs3; Key K ∉ used evs3⟧ ⟹ ?P (or3 A B NA NB K # evs3); ⋀evs4 A B NA NB X S Y K. ⟦evs4 ∈ Guard_OtwayRees.or; ?P evs4; or2 A B NA NB X ∈ set evs4; Says S B ⦃Nonce NA, Y, Ciph B ⦃Nonce NB, Key K⦄⦄ ∈ set evs4⟧ ⟹ ?P (or4 A B NA X # evs4)⟧ ⟹ ?P ?x›*)) (*goals: 1. ‹B ∉ bad ⟹ or2 A B NA NB X ∈ set [] ⟶ Guard NB {shrK B} (knows Spy [])› 2. ‹⋀evs Xa Ba. ⟦B ∉ bad; evs ∈ Guard_OtwayRees.or; or2 A B NA NB X ∈ set evs ⟶ Guard NB {shrK B} (knows Spy evs); Xa ∈ synth (analz (knows Spy evs))⟧ ⟹ or2 A B NA NB X ∈ set (Says Spy Ba Xa # evs) ⟶ Guard NB {shrK B} (knows Spy (Says Spy Ba Xa # evs))› 3. ‹⋀evs1 NAa Aa Ba. ⟦B ∉ bad; evs1 ∈ Guard_OtwayRees.or; or2 A B NA NB X ∈ set evs1 ⟶ Guard NB {shrK B} (knows Spy evs1); Nonce NAa ∉ used evs1⟧ ⟹ or2 A B NA NB X ∈ set (or1' Aa Aa Ba NAa (Ciph Aa ⦃Nonce NAa, Agent Aa, Agent Ba⦄) # evs1) ⟶ Guard NB {shrK B} (knows Spy (or1' Aa Aa Ba NAa (Ciph Aa ⦃Nonce NAa, Agent Aa, Agent Ba⦄) # evs1))› 4. ‹⋀evs2 A' Aa Ba NAa Xa NBa. ⟦B ∉ bad; evs2 ∈ Guard_OtwayRees.or; or2 A B NA NB X ∈ set evs2 ⟶ Guard NB {shrK B} (knows Spy evs2); or1' A' Aa Ba NAa Xa ∈ set evs2; Nonce NBa ∉ used evs2⟧ ⟹ or2 A B NA NB X ∈ set (or2 Aa Ba NAa NBa Xa # evs2) ⟶ Guard NB {shrK B} (knows Spy (or2 Aa Ba NAa NBa Xa # evs2))› 5. ‹⋀evs3 B' Aa Ba NAa NBa K. ⟦B ∉ bad; evs3 ∈ Guard_OtwayRees.or; or2 A B NA NB X ∈ set evs3 ⟶ Guard NB {shrK B} (knows Spy evs3); or2' B' Aa Ba NAa NBa ∈ set evs3; Key K ∉ used evs3⟧ ⟹ or2 A B NA NB X ∈ set (or3 Aa Ba NAa NBa K # evs3) ⟶ Guard NB {shrK B} (knows Spy (or3 Aa Ba NAa NBa K # evs3))› 6. ‹⋀evs4 Aa Ba NAa NBa Xa S Y K. ⟦B ∉ bad; evs4 ∈ Guard_OtwayRees.or; or2 A B NA NB X ∈ set evs4 ⟶ Guard NB {shrK B} (knows Spy evs4); or2 Aa Ba NAa NBa Xa ∈ set evs4; Says S Ba ⦃Nonce NAa, Y, Ciph Ba ⦃Nonce NBa, Key K⦄⦄ ∈ set evs4⟧ ⟹ or2 A B NA NB X ∈ set (or4 Aa Ba NAa Xa # evs4) ⟶ Guard NB {shrK B} (knows Spy (or4 Aa Ba NAa Xa # evs4))› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*top goal: ‹⋀evs Xa Ba. ⟦B ∉ bad; evs ∈ Guard_OtwayRees.or; or2 A B NA NB X ∈ set evs ⟶ Guard NB {shrK B} (knows Spy evs); Xa ∈ synth (analz (knows Spy evs))⟧ ⟹ or2 A B NA NB X ∈ set (Says Spy Ba Xa # evs) ⟶ Guard NB {shrK B} (knows Spy (Says Spy Ba Xa # evs))› and 4 goals remain*) apply ((safe)[1]) (*top goal: ‹⋀evs Xa Ba. ⟦B ∉ bad; evs ∈ Guard_OtwayRees.or; or2 A B NA NB X ∈ set evs ⟶ Guard NB {shrK B} (knows Spy evs); Xa ∈ synth (analz (knows Spy evs))⟧ ⟹ (B = Spy ∧ Server = Ba ∧ ⦃Nonce NA, Agent A, Agent B, X, Ciph B ⦃Nonce NA, Nonce NB, Agent A, Agent B⦄⦄ = Xa ⟶ Guard NB {shrK Spy} (knows Spy evs) ∧ Xa ∈ guard NB {shrK Spy}) ∧ (or2 A B NA NB X ∈ set evs ⟶ Xa ∈ guard NB {shrK B})› and 4 goals remain*) apply (erule in_synth_Guard (*‹⟦?X ∈ synth ?G; Guard ?n ?Ks ?G⟧ ⟹ ?X ∈ guard ?n ?Ks›*)) (*top goal: ‹⋀evs Xa Ba. ⟦B ∉ bad; evs ∈ Guard_OtwayRees.or; Xa ∈ synth (analz (knows Spy evs)); Guard NB {shrK B} (knows Spy evs); or2 A B NA NB X ∈ set evs⟧ ⟹ Xa ∈ guard NB {shrK B}› and 4 goals remain*) apply (erule Guard_analz (*‹⟦Guard ?n ?Ks ?G; ∀K. K ∈ ?Ks ⟶ Key K ∉ analz ?G⟧ ⟹ Guard ?n ?Ks (analz ?G)›*)) (*top goal: ‹⋀evs Xa Ba. ⟦B ∉ bad; evs ∈ Guard_OtwayRees.or; Guard NB {shrK B} (knows Spy evs); or2 A B NA NB X ∈ set evs⟧ ⟹ Guard NB {shrK B} (analz (knows Spy evs))› and 4 goals remain*) apply simp (*discuss goal 3*) apply simp (*top goal: ‹⋀evs1 NAa Aa Ba. ⟦B ∉ bad; evs1 ∈ Guard_OtwayRees.or; or2 A B NA NB X ∈ set evs1 ⟶ Guard NB {shrK B} (knows Spy evs1); Nonce NAa ∉ used evs1⟧ ⟹ or2 A B NA NB X ∈ set (or1' Aa Aa Ba NAa (Ciph Aa ⦃Nonce NAa, Agent Aa, Agent Ba⦄) # evs1) ⟶ Guard NB {shrK B} (knows Spy (or1' Aa Aa Ba NAa (Ciph Aa ⦃Nonce NAa, Agent Aa, Agent Ba⦄) # evs1))› and 3 goals remain*) apply ((safe)[1]) (*goals: 1. ‹⋀(evs1::event list) (NAa::nat) (Aa::agent) Ba::agent. ⟦(B::agent) ∉ bad; evs1 ∈ Guard_OtwayRees.or; Nonce NAa ∉ used evs1; or2 (A::agent) B (NA::nat) (NB::nat) (X::msg) ∈ set evs1; Guard NB {shrK B} (knows Spy evs1)⟧ ⟹ Nonce NAa ∈ guard NB {shrK B}› 2. ‹⋀(evs1::event list) (NAa::nat) (Aa::agent) Ba::agent. ⟦(B::agent) ∉ bad; evs1 ∈ Guard_OtwayRees.or; Nonce NAa ∉ used evs1; or2 (A::agent) B (NA::nat) (NB::nat) (X::msg) ∈ set evs1; Guard NB {shrK B} (knows Spy evs1)⟧ ⟹ Ciph Aa ⦃Nonce NAa, Agent Aa, Agent Ba⦄ ∈ guard NB {shrK B}› discuss goal 1*) apply (drule_tac n=NB in Nonce_neq (*‹⟦Nonce ?n' ∉ used ?evs; Says ?A ?B ?X ∈ set ?evs; Nonce ?n ∈ parts {?X}⟧ ⟹ ?n ≠ ?n'›*)) (*goals: 1. ‹⋀evs1 NAa Aa Ba. ⟦B ∉ bad; evs1 ∈ Guard_OtwayRees.or; or2 A B NA NB X ∈ set evs1; Guard NB {shrK B} (knows Spy evs1)⟧ ⟹ Says (?A36 evs1 NAa Aa Ba) (?B36 evs1 NAa Aa Ba) (?X36 evs1 NAa Aa Ba) ∈ set evs1› 2. ‹⋀evs1 NAa Aa Ba. ⟦B ∉ bad; evs1 ∈ Guard_OtwayRees.or; or2 A B NA NB X ∈ set evs1; Guard NB {shrK B} (knows Spy evs1)⟧ ⟹ Nonce NB ∈ parts {?X36 evs1 NAa Aa Ba}› 3. ‹⋀evs1 NAa Aa Ba. ⟦B ∉ bad; evs1 ∈ Guard_OtwayRees.or; or2 A B NA NB X ∈ set evs1; Guard NB {shrK B} (knows Spy evs1); NB ≠ NAa⟧ ⟹ Nonce NAa ∈ guard NB {shrK B}› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*discuss goal 3*) apply simp (*top goal: ‹⋀evs1 NAa Aa Ba. ⟦B ∉ bad; evs1 ∈ Guard_OtwayRees.or; or2 A B NA NB X ∈ set evs1; Guard NB {shrK B} (knows Spy evs1); NB ≠ NAa⟧ ⟹ Nonce NAa ∈ guard NB {shrK B}› and 4 goals remain*) apply (rule No_Nonce (*‹Nonce ?n ∉ parts {?X} ⟹ ?X ∈ guard ?n ?Ks›*)) (*top goal: ‹⋀(evs1::event list) NAa::nat. ⟦(B::agent) ∉ bad; evs1 ∈ Guard_OtwayRees.or; or2 (A::agent) B (NA::nat) (NB::nat) (X::msg) ∈ set evs1; Guard NB {shrK B} (knows Spy evs1); NB ≠ NAa⟧ ⟹ Nonce NAa ∈ guard NB {shrK B}› and 4 goals remain*) apply simp (*proven 3 subgoals*) (*discuss goal 2*) apply (drule_tac n=NB in Nonce_neq (*‹⟦Nonce ?n' ∉ used ?evs; Says ?A ?B ?X ∈ set ?evs; Nonce ?n ∈ parts {?X}⟧ ⟹ ?n ≠ ?n'›*)) (*goals: 1. ‹⋀evs1 NAa Aa Ba. ⟦B ∉ bad; evs1 ∈ Guard_OtwayRees.or; or2 A B NA NB X ∈ set evs1; Guard NB {shrK B} (knows Spy evs1)⟧ ⟹ Says (?A40 evs1 NAa Aa Ba) (?B40 evs1 NAa Aa Ba) (?X40 evs1 NAa Aa Ba) ∈ set evs1› 2. ‹⋀evs1 NAa Aa Ba. ⟦B ∉ bad; evs1 ∈ Guard_OtwayRees.or; or2 A B NA NB X ∈ set evs1; Guard NB {shrK B} (knows Spy evs1)⟧ ⟹ Nonce NB ∈ parts {?X40 evs1 NAa Aa Ba}› 3. ‹⋀evs1 NAa Aa Ba. ⟦B ∉ bad; evs1 ∈ Guard_OtwayRees.or; or2 A B NA NB X ∈ set evs1; Guard NB {shrK B} (knows Spy evs1); NB ≠ NAa⟧ ⟹ Ciph Aa ⦃Nonce NAa, Agent Aa, Agent Ba⦄ ∈ guard NB {shrK B}› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*discuss goal 3*) apply (rule No_Nonce (*‹Nonce ?n ∉ parts {?X} ⟹ ?X ∈ guard ?n ?Ks›*)) (*top goal: ‹⋀evs1 NAa Aa Ba. ⟦B ∉ bad; evs1 ∈ Guard_OtwayRees.or; or2 A B NA NB X ∈ set evs1; Guard NB {shrK B} (knows Spy evs1); NB ≠ NAa⟧ ⟹ Ciph Aa ⦃Nonce NAa, Agent Aa, Agent Ba⦄ ∈ guard NB {shrK B}› and 3 goals remain*) apply simp (*proven 3 subgoals*) (*proven 2 subgoals*) (*discuss goal 4*) apply simp (*top goal: ‹⋀(evs2::event list) (A'::agent) (Aa::agent) (Ba::agent) (NAa::nat) (Xa::msg) NBa::nat. ⟦(B::agent) ∉ bad; evs2 ∈ Guard_OtwayRees.or; or2 (A::agent) B (NA::nat) (NB::nat) (X::msg) ∈ set evs2 ⟶ Guard NB {shrK B} (knows Spy evs2); or1' A' Aa Ba NAa Xa ∈ set evs2; Nonce NBa ∉ used evs2⟧ ⟹ or2 A B NA NB X ∈ set (or2 Aa Ba NAa NBa Xa # evs2) ⟶ Guard NB {shrK B} (knows Spy (or2 Aa Ba NAa NBa Xa # evs2))› and 2 goals remain*) apply ((safe)[1]) (*goals: 1. ‹⋀(evs2::event list) (A'::agent) (Aa::agent) (Ba::agent) (NAa::nat) (Xa::msg) NBa::nat. ⟦(B::agent) ∉ bad; evs2 ∈ Guard_OtwayRees.or; or1' A' (A::agent) B (NA::nat) (X::msg) ∈ set evs2; Nonce (NB::nat) ∉ used evs2; or2 A B NA NB X ∉ set evs2⟧ ⟹ Guard NB {shrK B} (knows Spy evs2)› 2. ‹⋀(evs2::event list) (A'::agent) (Aa::agent) (Ba::agent) (NAa::nat) (Xa::msg) NBa::nat. ⟦(B::agent) ∉ bad; evs2 ∈ Guard_OtwayRees.or; or1' A' (A::agent) B (NA::nat) (X::msg) ∈ set evs2; Nonce (NB::nat) ∉ used evs2; or2 A B NA NB X ∉ set evs2⟧ ⟹ Nonce NA ∈ guard NB {shrK B}› 3. ‹⋀(evs2::event list) (A'::agent) (Aa::agent) (Ba::agent) (NAa::nat) (Xa::msg) NBa::nat. ⟦(B::agent) ∉ bad; evs2 ∈ Guard_OtwayRees.or; or1' A' (A::agent) B (NA::nat) (X::msg) ∈ set evs2; Nonce (NB::nat) ∉ used evs2; or2 A B NA NB X ∉ set evs2⟧ ⟹ X ∈ guard NB {shrK B}› 4. ‹⋀(evs2::event list) (A'::agent) (Aa::agent) (Ba::agent) (NAa::nat) (Xa::msg) NBa::nat. ⟦(B::agent) ∉ bad; evs2 ∈ Guard_OtwayRees.or; or1' A' (A::agent) B (NA::nat) (X::msg) ∈ set evs2; Nonce (NB::nat) ∉ used evs2; Guard NB {shrK B} (knows Spy evs2)⟧ ⟹ Nonce NA ∈ guard NB {shrK B}› 5. ‹⋀(evs2::event list) (A'::agent) (Aa::agent) (Ba::agent) (NAa::nat) (Xa::msg) NBa::nat. ⟦(B::agent) ∉ bad; evs2 ∈ Guard_OtwayRees.or; or1' A' (A::agent) B (NA::nat) (X::msg) ∈ set evs2; Nonce (NB::nat) ∉ used evs2; Guard NB {shrK B} (knows Spy evs2)⟧ ⟹ X ∈ guard NB {shrK B}› 6. ‹⋀(evs2::event list) (A'::agent) (Aa::agent) (Ba::agent) (NAa::nat) (Xa::msg) NBa::nat. ⟦(B::agent) ∉ bad; evs2 ∈ Guard_OtwayRees.or; or1' A' Aa Ba NAa Xa ∈ set evs2; Nonce NBa ∉ used evs2; Guard (NB::nat) {shrK B} (knows Spy evs2); or2 (A::agent) B (NA::nat) NB (X::msg) ∈ set evs2⟧ ⟹ Nonce NAa ∈ guard NB {shrK B}› 7. ‹⋀(evs2::event list) (A'::agent) (Aa::agent) (Ba::agent) (NAa::nat) (Xa::msg) NBa::nat. ⟦(B::agent) ∉ bad; evs2 ∈ Guard_OtwayRees.or; or1' A' Aa Ba NAa Xa ∈ set evs2; Nonce NBa ∉ used evs2; Guard (NB::nat) {shrK B} (knows Spy evs2); or2 (A::agent) B (NA::nat) NB (X::msg) ∈ set evs2⟧ ⟹ Xa ∈ guard NB {shrK B}› 8. ‹⋀(evs2::event list) (A'::agent) (Aa::agent) (Ba::agent) (NAa::nat) (Xa::msg) NBa::nat. ⟦(B::agent) ∉ bad; evs2 ∈ Guard_OtwayRees.or; or1' A' Aa Ba NAa Xa ∈ set evs2; Nonce NBa ∉ used evs2; Guard (NB::nat) {shrK B} (knows Spy evs2); or2 (A::agent) B (NA::nat) NB (X::msg) ∈ set evs2⟧ ⟹ Ciph Ba ⦃Nonce NAa, Nonce NBa, Agent Aa, Agent Ba⦄ ∈ guard NB {shrK B}› discuss goal 1*) apply blast (*discuss goal 2*) apply (drule_tac n=NA in Nonce_neq (*‹⟦Nonce ?n' ∉ used ?evs; Says ?A ?B ?X ∈ set ?evs; Nonce ?n ∈ parts {?X}⟧ ⟹ ?n ≠ ?n'›*)) (*goals: 1. ‹⋀(evs2::event list) (A'::agent) (Aa::agent) (Ba::agent) (NAa::nat) (Xa::msg) NBa::nat. ⟦(B::agent) ∉ bad; evs2 ∈ Guard_OtwayRees.or; or1' A' (A::agent) B (NA::nat) (X::msg) ∈ set evs2; or2 A B NA (NB::nat) X ∉ set evs2⟧ ⟹ Says ((?A110::event list ⇒ agent ⇒ agent ⇒ agent ⇒ nat ⇒ msg ⇒ nat ⇒ agent) evs2 A' Aa Ba NAa Xa NBa) ((?B110::event list ⇒ agent ⇒ agent ⇒ agent ⇒ nat ⇒ msg ⇒ nat ⇒ agent) evs2 A' Aa Ba NAa Xa NBa) ((?X110::event list ⇒ agent ⇒ agent ⇒ agent ⇒ nat ⇒ msg ⇒ nat ⇒ msg) evs2 A' Aa Ba NAa Xa NBa) ∈ set evs2› 2. ‹⋀(evs2::event list) (A'::agent) (Aa::agent) (Ba::agent) (NAa::nat) (Xa::msg) NBa::nat. ⟦(B::agent) ∉ bad; evs2 ∈ Guard_OtwayRees.or; or1' A' (A::agent) B (NA::nat) (X::msg) ∈ set evs2; or2 A B NA (NB::nat) X ∉ set evs2⟧ ⟹ Nonce NA ∈ parts {(?X110::event list ⇒ agent ⇒ agent ⇒ agent ⇒ nat ⇒ msg ⇒ nat ⇒ msg) evs2 A' Aa Ba NAa Xa NBa}› 3. ‹⋀(evs2::event list) (A'::agent) (Aa::agent) (Ba::agent) (NAa::nat) (Xa::msg) NBa::nat. ⟦(B::agent) ∉ bad; evs2 ∈ Guard_OtwayRees.or; or1' A' (A::agent) B (NA::nat) (X::msg) ∈ set evs2; or2 A B NA (NB::nat) X ∉ set evs2; NA ≠ NB⟧ ⟹ Nonce NA ∈ guard NB {shrK B}› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*discuss goal 3*) apply simp (*top goal: ‹⋀(evs2::event list) (A'::agent) (Aa::agent) (Ba::agent) (NAa::nat) (Xa::msg) NBa::nat. ⟦(B::agent) ∉ bad; evs2 ∈ Guard_OtwayRees.or; or1' A' (A::agent) B (NA::nat) (X::msg) ∈ set evs2; or2 A B NA (NB::nat) X ∉ set evs2; NA ≠ NB⟧ ⟹ Nonce NA ∈ guard NB {shrK B}› and 8 goals remain*) apply (rule No_Nonce (*‹Nonce ?n ∉ parts {?X} ⟹ ?X ∈ guard ?n ?Ks›*)) (*top goal: ‹⋀(evs2::event list) A'::agent. ⟦(B::agent) ∉ bad; evs2 ∈ Guard_OtwayRees.or; or1' A' (A::agent) B (NA::nat) (X::msg) ∈ set evs2; or2 A B NA (NB::nat) X ∉ set evs2; NA ≠ NB⟧ ⟹ Nonce NA ∈ guard NB {shrK B}› and 8 goals remain*) apply simp (*proven 3 subgoals*) (*discuss goal 3*) apply (blast intro!: No_Nonce (*‹Nonce ?n ∉ parts {?X} ⟹ ?X ∈ guard ?n ?Ks›*) dest: used_parts (*‹⟦?X ∈ parts {?Y}; ?Y ∈ used ?evs⟧ ⟹ ?X ∈ used ?evs›*)) (*discuss goal 4*) apply (drule_tac n=NA in Nonce_neq (*‹⟦Nonce ?n' ∉ used ?evs; Says ?A ?B ?X ∈ set ?evs; Nonce ?n ∈ parts {?X}⟧ ⟹ ?n ≠ ?n'›*)) (*goals: 1. ‹⋀evs2 A' Aa Ba NAa Xa NBa. ⟦B ∉ bad; evs2 ∈ Guard_OtwayRees.or; or1' A' A B NA X ∈ set evs2; Guard NB {shrK B} (knows Spy evs2)⟧ ⟹ Says (?A134 evs2 A' Aa Ba NAa Xa NBa) (?B134 evs2 A' Aa Ba NAa Xa NBa) (?X134 evs2 A' Aa Ba NAa Xa NBa) ∈ set evs2› 2. ‹⋀evs2 A' Aa Ba NAa Xa NBa. ⟦B ∉ bad; evs2 ∈ Guard_OtwayRees.or; or1' A' A B NA X ∈ set evs2; Guard NB {shrK B} (knows Spy evs2)⟧ ⟹ Nonce NA ∈ parts {?X134 evs2 A' Aa Ba NAa Xa NBa}› 3. ‹⋀evs2 A' Aa Ba NAa Xa NBa. ⟦B ∉ bad; evs2 ∈ Guard_OtwayRees.or; or1' A' A B NA X ∈ set evs2; Guard NB {shrK B} (knows Spy evs2); NA ≠ NB⟧ ⟹ Nonce NA ∈ guard NB {shrK B}› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*discuss goal 3*) apply simp (*top goal: ‹⋀evs2 A' Aa Ba NAa Xa NBa. ⟦B ∉ bad; evs2 ∈ Guard_OtwayRees.or; or1' A' A B NA X ∈ set evs2; Guard NB {shrK B} (knows Spy evs2); NA ≠ NB⟧ ⟹ Nonce NA ∈ guard NB {shrK B}› and 6 goals remain*) apply (rule No_Nonce (*‹Nonce ?n ∉ parts {?X} ⟹ ?X ∈ guard ?n ?Ks›*)) (*top goal: ‹⋀evs2 A'. ⟦B ∉ bad; evs2 ∈ Guard_OtwayRees.or; or1' A' A B NA X ∈ set evs2; Guard NB {shrK B} (knows Spy evs2); NA ≠ NB⟧ ⟹ Nonce NA ∈ guard NB {shrK B}› and 6 goals remain*) apply simp (*proven 3 subgoals*) (*discuss goal 5*) apply (blast intro!: No_Nonce (*‹Nonce ?n ∉ parts {?X} ⟹ ?X ∈ guard ?n ?Ks›*) dest: used_parts (*‹⟦?X ∈ parts {?Y}; ?Y ∈ used ?evs⟧ ⟹ ?X ∈ used ?evs›*)) (*discuss goal 6*) apply (blast dest: Says_imp_spies (*‹Says ?A ?B ?X ∈ set ?evs ⟹ ?X ∈ knows Spy ?evs›*)) (*discuss goal 7*) apply (blast dest: Says_imp_spies (*‹Says ?A ?B ?X ∈ set ?evs ⟹ ?X ∈ knows Spy ?evs›*)) (*discuss goal 8*) apply (case_tac "Ba=B") (*goals: 1. ‹⋀(evs2::event list) (A'::agent) (Aa::agent) (Ba::agent) (NAa::nat) (Xa::msg) NBa::nat. ⟦(B::agent) ∉ bad; evs2 ∈ Guard_OtwayRees.or; or1' A' Aa Ba NAa Xa ∈ set evs2; Nonce NBa ∉ used evs2; Guard (NB::nat) {shrK B} (knows Spy evs2); or2 (A::agent) B (NA::nat) NB (X::msg) ∈ set evs2; Ba = B⟧ ⟹ Ciph Ba ⦃Nonce NAa, Nonce NBa, Agent Aa, Agent Ba⦄ ∈ guard NB {shrK B}› 2. ‹⋀(evs2::event list) (A'::agent) (Aa::agent) (Ba::agent) (NAa::nat) (Xa::msg) NBa::nat. ⟦(B::agent) ∉ bad; evs2 ∈ Guard_OtwayRees.or; or1' A' Aa Ba NAa Xa ∈ set evs2; Nonce NBa ∉ used evs2; Guard (NB::nat) {shrK B} (knows Spy evs2); or2 (A::agent) B (NA::nat) NB (X::msg) ∈ set evs2; Ba ≠ B⟧ ⟹ Ciph Ba ⦃Nonce NAa, Nonce NBa, Agent Aa, Agent Ba⦄ ∈ guard NB {shrK B}› discuss goal 1*) apply clarsimp (*discuss goal 2*) apply (drule_tac n=NB and A=B in Nonce_neq (*‹⟦Nonce ?n' ∉ used ?evs; Says ?A ?B ?X ∈ set ?evs; Nonce ?n ∈ parts {?X}⟧ ⟹ ?n ≠ ?n'›*)) (*goals: 1. ‹⋀evs2 A' Aa Ba NAa Xa NBa. ⟦B ∉ bad; evs2 ∈ Guard_OtwayRees.or; or1' A' Aa Ba NAa Xa ∈ set evs2; Guard NB {shrK B} (knows Spy evs2); or2 A B NA NB X ∈ set evs2; Ba ≠ B⟧ ⟹ Says B (?B203 evs2 A' Aa Ba NAa Xa NBa) (?X203 evs2 A' Aa Ba NAa Xa NBa) ∈ set evs2› 2. ‹⋀evs2 A' Aa Ba NAa Xa NBa. ⟦B ∉ bad; evs2 ∈ Guard_OtwayRees.or; or1' A' Aa Ba NAa Xa ∈ set evs2; Guard NB {shrK B} (knows Spy evs2); or2 A B NA NB X ∈ set evs2; Ba ≠ B⟧ ⟹ Nonce NB ∈ parts {?X203 evs2 A' Aa Ba NAa Xa NBa}› 3. ‹⋀evs2 A' Aa Ba NAa Xa NBa. ⟦B ∉ bad; evs2 ∈ Guard_OtwayRees.or; or1' A' Aa Ba NAa Xa ∈ set evs2; Guard NB {shrK B} (knows Spy evs2); or2 A B NA NB X ∈ set evs2; Ba ≠ B; NB ≠ NBa⟧ ⟹ Ciph Ba ⦃Nonce NAa, Nonce NBa, Agent Aa, Agent Ba⦄ ∈ guard NB {shrK B}› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*discuss goal 3*) apply (drule Says_imp_spies (*‹Says ?A ?B ?X ∈ set ?evs ⟹ ?X ∈ knows Spy ?evs›*)) (*top goal: ‹⋀(evs2::event list) (A'::agent) (Aa::agent) (Ba::agent) (NAa::nat) (Xa::msg) NBa::nat. ⟦(B::agent) ∉ bad; evs2 ∈ Guard_OtwayRees.or; or1' A' Aa Ba NAa Xa ∈ set evs2; Guard (NB::nat) {shrK B} (knows Spy evs2); or2 (A::agent) B (NA::nat) NB (X::msg) ∈ set evs2; Ba ≠ B; NB ≠ NBa⟧ ⟹ Ciph Ba ⦃Nonce NAa, Nonce NBa, Agent Aa, Agent Ba⦄ ∈ guard NB {shrK B}› and 2 goals remain*) apply (drule_tac n'=NAa in in_Guard_kparts_neq (*‹⟦?X ∈ ?G; Guard ?n ?Ks ?G; Nonce ?n' ∈ kparts {?X}⟧ ⟹ ?n ≠ ?n'›*)) (*goals: 1. ‹⋀(evs2::event list) (A'::agent) (Aa::agent) (Ba::agent) (NAa::nat) (Xa::msg) NBa::nat. ⟦(B::agent) ∉ bad; evs2 ∈ Guard_OtwayRees.or; Guard (NB::nat) {shrK B} (knows Spy evs2); or2 (A::agent) B (NA::nat) NB (X::msg) ∈ set evs2; Ba ≠ B; NB ≠ NBa⟧ ⟹ Guard ((?n207::event list ⇒ agent ⇒ agent ⇒ agent ⇒ nat ⇒ msg ⇒ nat ⇒ nat) evs2 A' Aa Ba NAa Xa NBa) ((?Ks207::event list ⇒ agent ⇒ agent ⇒ agent ⇒ nat ⇒ msg ⇒ nat ⇒ nat set) evs2 A' Aa Ba NAa Xa NBa) (knows Spy evs2)› 2. ‹⋀(evs2::event list) (A'::agent) (Aa::agent) (Ba::agent) (NAa::nat) (Xa::msg) NBa::nat. ⟦(B::agent) ∉ bad; evs2 ∈ Guard_OtwayRees.or; Guard (NB::nat) {shrK B} (knows Spy evs2); or2 (A::agent) B (NA::nat) NB (X::msg) ∈ set evs2; Ba ≠ B; NB ≠ NBa⟧ ⟹ Nonce NAa ∈ kparts {⦃Nonce NAa, Agent Aa, Agent Ba, Xa⦄}› 3. ‹⋀(evs2::event list) (A'::agent) (Aa::agent) (Ba::agent) (NAa::nat) (Xa::msg) NBa::nat. ⟦(B::agent) ∉ bad; evs2 ∈ Guard_OtwayRees.or; Guard (NB::nat) {shrK B} (knows Spy evs2); or2 (A::agent) B (NA::nat) NB (X::msg) ∈ set evs2; Ba ≠ B; NB ≠ NBa; (?n207::event list ⇒ agent ⇒ agent ⇒ agent ⇒ nat ⇒ msg ⇒ nat ⇒ nat) evs2 A' Aa Ba NAa Xa NBa ≠ NAa⟧ ⟹ Ciph Ba ⦃Nonce NAa, Nonce NBa, Agent Aa, Agent Ba⦄ ∈ guard NB {shrK B}› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*discuss goal 3*) apply simp (*top goal: ‹⋀(evs2::event list) (A'::agent) (Aa::agent) (Ba::agent) (NAa::nat) (Xa::msg) NBa::nat. ⟦(B::agent) ∉ bad; evs2 ∈ Guard_OtwayRees.or; Guard (NB::nat) {shrK B} (knows Spy evs2); or2 (A::agent) B (NA::nat) NB (X::msg) ∈ set evs2; Ba ≠ B; NB ≠ NBa; NB ≠ NAa⟧ ⟹ Ciph Ba ⦃Nonce NAa, Nonce NBa, Agent Aa, Agent Ba⦄ ∈ guard NB {shrK B}› and 2 goals remain*) apply (rule No_Nonce (*‹Nonce ?n ∉ parts {?X} ⟹ ?X ∈ guard ?n ?Ks›*)) (*top goal: ‹⋀evs2 Aa Ba NAa NBa. ⟦B ∉ bad; evs2 ∈ Guard_OtwayRees.or; Guard NB {shrK B} (knows Spy evs2); or2 A B NA NB X ∈ set evs2; Ba ≠ B; NB ≠ NBa; NB ≠ NAa⟧ ⟹ Ciph Ba ⦃Nonce NAa, Nonce NBa, Agent Aa, Agent Ba⦄ ∈ guard NB {shrK B}› and 2 goals remain*) apply simp (*proven 3 subgoals*) (*proven 3 subgoals*) (*proven 2 subgoals*) (*proven 8 subgoals*) (*discuss goal 5*) apply simp (*top goal: ‹⋀evs3 B' Aa Ba NAa NBa K. ⟦B ∉ bad; evs3 ∈ Guard_OtwayRees.or; or2 A B NA NB X ∈ set evs3 ⟶ Guard NB {shrK B} (knows Spy evs3); or2' B' Aa Ba NAa NBa ∈ set evs3; Key K ∉ used evs3⟧ ⟹ or2 A B NA NB X ∈ set (or3 Aa Ba NAa NBa K # evs3) ⟶ Guard NB {shrK B} (knows Spy (or3 Aa Ba NAa NBa K # evs3))› and 1 goal remains*) apply ((safe)[1]) (*goals: 1. ‹⋀evs3 B' Aa Ba NAa NBa K. ⟦B ∉ bad; evs3 ∈ Guard_OtwayRees.or; or2' B' Aa Ba NAa NBa ∈ set evs3; Key K ∉ used evs3; or2 A B NA NB X ∈ set evs3; Guard NB {shrK B} (knows Spy evs3)⟧ ⟹ Nonce NAa ∈ guard NB {shrK B}› 2. ‹⋀evs3 B' Aa Ba NAa NBa K. ⟦B ∉ bad; evs3 ∈ Guard_OtwayRees.or; or2' B' Aa Ba NAa NBa ∈ set evs3; Key K ∉ used evs3; or2 A B NA NB X ∈ set evs3; Guard NB {shrK B} (knows Spy evs3)⟧ ⟹ Ciph Aa ⦃Nonce NAa, Key K⦄ ∈ guard NB {shrK B}› 3. ‹⋀evs3 B' Aa Ba NAa NBa K. ⟦B ∉ bad; evs3 ∈ Guard_OtwayRees.or; or2' B' Aa Ba NAa NBa ∈ set evs3; Key K ∉ used evs3; or2 A B NA NB X ∈ set evs3; Guard NB {shrK B} (knows Spy evs3)⟧ ⟹ Ciph Ba ⦃Nonce NBa, Key K⦄ ∈ guard NB {shrK B}› discuss goal 1*) apply (drule Says_imp_spies (*‹Says ?A ?B ?X ∈ set ?evs ⟹ ?X ∈ knows Spy ?evs›*)) (*top goal: ‹⋀(evs3::event list) (B'::agent) (Aa::agent) (Ba::agent) (NAa::nat) (NBa::nat) K::nat. ⟦(B::agent) ∉ bad; evs3 ∈ Guard_OtwayRees.or; or2' B' Aa Ba NAa NBa ∈ set evs3; Key K ∉ used evs3; or2 (A::agent) B (NA::nat) (NB::nat) (X::msg) ∈ set evs3; Guard NB {shrK B} (knows Spy evs3)⟧ ⟹ Nonce NAa ∈ guard NB {shrK B}› and 3 goals remain*) apply (frule_tac n'=NAa in in_Guard_kparts_neq (*‹⟦?X ∈ ?G; Guard ?n ?Ks ?G; Nonce ?n' ∈ kparts {?X}⟧ ⟹ ?n ≠ ?n'›*)) (*goals: 1. ‹⋀evs3 B' Aa Ba NAa NBa K. ⟦B ∉ bad; evs3 ∈ Guard_OtwayRees.or; Key K ∉ used evs3; or2 A B NA NB X ∈ set evs3; Guard NB {shrK B} (knows Spy evs3); ⦃Nonce NAa, Agent Aa, Agent Ba, Ciph Aa ⦃Nonce NAa, Agent Aa, Agent Ba⦄, Ciph Ba ⦃Nonce NAa, Nonce NBa, Agent Aa, Agent Ba⦄⦄ ∈ knows Spy evs3⟧ ⟹ Guard (?n219 evs3 B' Aa Ba NAa NBa K) (?Ks219 evs3 B' Aa Ba NAa NBa K) (knows Spy evs3)› 2. ‹⋀evs3 B' Aa Ba NAa NBa K. ⟦B ∉ bad; evs3 ∈ Guard_OtwayRees.or; Key K ∉ used evs3; or2 A B NA NB X ∈ set evs3; Guard NB {shrK B} (knows Spy evs3); ⦃Nonce NAa, Agent Aa, Agent Ba, Ciph Aa ⦃Nonce NAa, Agent Aa, Agent Ba⦄, Ciph Ba ⦃Nonce NAa, Nonce NBa, Agent Aa, Agent Ba⦄⦄ ∈ knows Spy evs3⟧ ⟹ Nonce NAa ∈ kparts {⦃Nonce NAa, Agent Aa, Agent Ba, Ciph Aa ⦃Nonce NAa, Agent Aa, Agent Ba⦄, Ciph Ba ⦃Nonce NAa, Nonce NBa, Agent Aa, Agent Ba⦄⦄}› 3. ‹⋀evs3 B' Aa Ba NAa NBa K. ⟦B ∉ bad; evs3 ∈ Guard_OtwayRees.or; Key K ∉ used evs3; or2 A B NA NB X ∈ set evs3; Guard NB {shrK B} (knows Spy evs3); ⦃Nonce NAa, Agent Aa, Agent Ba, Ciph Aa ⦃Nonce NAa, Agent Aa, Agent Ba⦄, Ciph Ba ⦃Nonce NAa, Nonce NBa, Agent Aa, Agent Ba⦄⦄ ∈ knows Spy evs3; ?n219 evs3 B' Aa Ba NAa NBa K ≠ NAa⟧ ⟹ Nonce NAa ∈ guard NB {shrK B}› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*discuss goal 3*) apply simp (*top goal: ‹⋀(evs3::event list) (B'::agent) (Aa::agent) (Ba::agent) (NAa::nat) (NBa::nat) K::nat. ⟦(B::agent) ∉ bad; evs3 ∈ Guard_OtwayRees.or; Key K ∉ used evs3; or2 (A::agent) B (NA::nat) (NB::nat) (X::msg) ∈ set evs3; Guard NB {shrK B} (knows Spy evs3); ⦃Nonce NAa, Agent Aa, Agent Ba, Ciph Aa ⦃Nonce NAa, Agent Aa, Agent Ba⦄, Ciph Ba ⦃Nonce NAa, Nonce NBa, Agent Aa, Agent Ba⦄⦄ ∈ knows Spy evs3; NB ≠ NAa⟧ ⟹ Nonce NAa ∈ guard NB {shrK B}› and 3 goals remain*) apply (rule No_Nonce (*‹Nonce ?n ∉ parts {?X} ⟹ ?X ∈ guard ?n ?Ks›*)) (*top goal: ‹⋀evs3 Aa Ba NAa NBa K. ⟦B ∉ bad; evs3 ∈ Guard_OtwayRees.or; Key K ∉ used evs3; or2 A B NA NB X ∈ set evs3; Guard NB {shrK B} (knows Spy evs3); ⦃Nonce NAa, Agent Aa, Agent Ba, Ciph Aa ⦃Nonce NAa, Agent Aa, Agent Ba⦄, Ciph Ba ⦃Nonce NAa, Nonce NBa, Agent Aa, Agent Ba⦄⦄ ∈ knows Spy evs3; NB ≠ NAa⟧ ⟹ Nonce NAa ∈ guard NB {shrK B}› and 3 goals remain*) apply simp (*proven 3 subgoals*) (*discuss goal 2*) apply (case_tac "Aa=B") (*goals: 1. ‹⋀evs3 B' Aa Ba NAa NBa K. ⟦B ∉ bad; evs3 ∈ Guard_OtwayRees.or; or2' B' Aa Ba NAa NBa ∈ set evs3; Key K ∉ used evs3; or2 A B NA NB X ∈ set evs3; Guard NB {shrK B} (knows Spy evs3); Aa = B⟧ ⟹ Ciph Aa ⦃Nonce NAa, Key K⦄ ∈ guard NB {shrK B}› 2. ‹⋀evs3 B' Aa Ba NAa NBa K. ⟦B ∉ bad; evs3 ∈ Guard_OtwayRees.or; or2' B' Aa Ba NAa NBa ∈ set evs3; Key K ∉ used evs3; or2 A B NA NB X ∈ set evs3; Guard NB {shrK B} (knows Spy evs3); Aa ≠ B⟧ ⟹ Ciph Aa ⦃Nonce NAa, Key K⦄ ∈ guard NB {shrK B}› discuss goal 1*) apply clarsimp (*discuss goal 2*) apply (case_tac "NAa=NB") (*goals: 1. ‹⋀evs3 B' Aa Ba NAa NBa K. ⟦B ∉ bad; evs3 ∈ Guard_OtwayRees.or; or2' B' Aa Ba NAa NBa ∈ set evs3; Key K ∉ used evs3; or2 A B NA NB X ∈ set evs3; Guard NB {shrK B} (knows Spy evs3); Aa ≠ B; NAa = NB⟧ ⟹ Ciph Aa ⦃Nonce NAa, Key K⦄ ∈ guard NB {shrK B}› 2. ‹⋀evs3 B' Aa Ba NAa NBa K. ⟦B ∉ bad; evs3 ∈ Guard_OtwayRees.or; or2' B' Aa Ba NAa NBa ∈ set evs3; Key K ∉ used evs3; or2 A B NA NB X ∈ set evs3; Guard NB {shrK B} (knows Spy evs3); Aa ≠ B; NAa ≠ NB⟧ ⟹ Ciph Aa ⦃Nonce NAa, Key K⦄ ∈ guard NB {shrK B}› discuss goal 1*) apply clarsimp (*top goal: ‹⋀evs3 B' Aa Ba NAa NBa K. ⟦B ∉ bad; evs3 ∈ Guard_OtwayRees.or; or2' B' Aa Ba NAa NBa ∈ set evs3; Key K ∉ used evs3; or2 A B NA NB X ∈ set evs3; Guard NB {shrK B} (knows Spy evs3); Aa ≠ B; NAa = NB⟧ ⟹ Ciph Aa ⦃Nonce NAa, Key K⦄ ∈ guard NB {shrK B}› and 3 goals remain*) apply (drule Says_imp_spies (*‹Says ?A ?B ?X ∈ set ?evs ⟹ ?X ∈ knows Spy ?evs›*)) (*top goal: ‹⋀evs3 B' Aa Ba NBa K. ⟦B ∉ bad; evs3 ∈ Guard_OtwayRees.or; or2' B' Aa Ba NB NBa ∈ set evs3; Key K ∉ used evs3; or2 A B NA NB X ∈ set evs3; Guard NB {shrK B} (knows Spy evs3); Aa ≠ B⟧ ⟹ Ciph Aa ⦃Nonce NB, Key K⦄ ∈ guard NB {shrK B}› and 3 goals remain*) apply (drule_tac Y="⦃Nonce NB, Agent Aa, Agent Ba⦄" and K="shrK Aa" in in_Guard_kparts_Crypt (*‹⟦(?X::msg) ∈ (?G::msg set); Guard (?n::nat) (?Ks::nat set) ?G; is_MPair ?X; Crypt (?K::nat) (?Y::msg) ∈ kparts {?X}; Nonce ?n ∈ kparts {?Y}⟧ ⟹ invKey ?K ∈ ?Ks›*)) (*goals: 1. ‹⋀evs3 B' Aa Ba NBa K. ⟦B ∉ bad; evs3 ∈ Guard_OtwayRees.or; Key K ∉ used evs3; or2 A B NA NB X ∈ set evs3; Guard NB {shrK B} (knows Spy evs3); Aa ≠ B⟧ ⟹ Guard (?n230 evs3 B' Aa Ba NBa K) (?Ks230 evs3 B' Aa Ba NBa K) (knows Spy evs3)› 2. ‹⋀evs3 B' Aa Ba NBa K. ⟦B ∉ bad; evs3 ∈ Guard_OtwayRees.or; Key K ∉ used evs3; or2 A B NA NB X ∈ set evs3; Guard NB {shrK B} (knows Spy evs3); Aa ≠ B⟧ ⟹ is_MPair ⦃Nonce NB, Agent Aa, Agent Ba, Ciph Aa ⦃Nonce NB, Agent Aa, Agent Ba⦄, Ciph Ba ⦃Nonce NB, Nonce NBa, Agent Aa, Agent Ba⦄⦄› 3. ‹⋀evs3 B' Aa Ba NBa K. ⟦B ∉ bad; evs3 ∈ Guard_OtwayRees.or; Key K ∉ used evs3; or2 A B NA NB X ∈ set evs3; Guard NB {shrK B} (knows Spy evs3); Aa ≠ B⟧ ⟹ Ciph Aa ⦃Nonce NB, Agent Aa, Agent Ba⦄ ∈ kparts {⦃Nonce NB, Agent Aa, Agent Ba, Ciph Aa ⦃Nonce NB, Agent Aa, Agent Ba⦄, Ciph Ba ⦃Nonce NB, Nonce NBa, Agent Aa, Agent Ba⦄⦄}› 4. ‹⋀evs3 B' Aa Ba NBa K. ⟦B ∉ bad; evs3 ∈ Guard_OtwayRees.or; Key K ∉ used evs3; or2 A B NA NB X ∈ set evs3; Guard NB {shrK B} (knows Spy evs3); Aa ≠ B⟧ ⟹ Nonce (?n230 evs3 B' Aa Ba NBa K) ∈ kparts {⦃Nonce NB, Agent Aa, Agent Ba⦄}› 5. ‹⋀evs3 B' Aa Ba NBa K. ⟦B ∉ bad; evs3 ∈ Guard_OtwayRees.or; Key K ∉ used evs3; or2 A B NA NB X ∈ set evs3; Guard NB {shrK B} (knows Spy evs3); Aa ≠ B; invKey (shrK Aa) ∈ ?Ks230 evs3 B' Aa Ba NBa K⟧ ⟹ Ciph Aa ⦃Nonce NB, Key K⦄ ∈ guard NB {shrK B}› 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*) (*discuss goal 2*) apply (simp add: No_Nonce (*‹Nonce (?n::nat) ∉ parts {?X::msg} ⟹ ?X ∈ guard ?n (?Ks::nat set)›*)) (*proven 2 subgoals*) (*proven 2 subgoals*) (*discuss goal 3*) apply (case_tac "Ba=B") (*goals: 1. ‹⋀(evs3::event list) (B'::agent) (Aa::agent) (Ba::agent) (NAa::nat) (NBa::nat) K::nat. ⟦(B::agent) ∉ bad; evs3 ∈ Guard_OtwayRees.or; or2' B' Aa Ba NAa NBa ∈ set evs3; Key K ∉ used evs3; or2 (A::agent) B (NA::nat) (NB::nat) (X::msg) ∈ set evs3; Guard NB {shrK B} (knows Spy evs3); Ba = B⟧ ⟹ Ciph Ba ⦃Nonce NBa, Key K⦄ ∈ guard NB {shrK B}› 2. ‹⋀(evs3::event list) (B'::agent) (Aa::agent) (Ba::agent) (NAa::nat) (NBa::nat) K::nat. ⟦(B::agent) ∉ bad; evs3 ∈ Guard_OtwayRees.or; or2' B' Aa Ba NAa NBa ∈ set evs3; Key K ∉ used evs3; or2 (A::agent) B (NA::nat) (NB::nat) (X::msg) ∈ set evs3; Guard NB {shrK B} (knows Spy evs3); Ba ≠ B⟧ ⟹ Ciph Ba ⦃Nonce NBa, Key K⦄ ∈ guard NB {shrK B}› discuss goal 1*) apply clarsimp (*discuss goal 2*) apply (case_tac "NBa=NB") (*goals: 1. ‹⋀(evs3::event list) (B'::agent) (Aa::agent) (Ba::agent) (NAa::nat) (NBa::nat) K::nat. ⟦(B::agent) ∉ bad; evs3 ∈ Guard_OtwayRees.or; or2' B' Aa Ba NAa NBa ∈ set evs3; Key K ∉ used evs3; or2 (A::agent) B (NA::nat) (NB::nat) (X::msg) ∈ set evs3; Guard NB {shrK B} (knows Spy evs3); Ba ≠ B; NBa = NB⟧ ⟹ Ciph Ba ⦃Nonce NBa, Key K⦄ ∈ guard NB {shrK B}› 2. ‹⋀(evs3::event list) (B'::agent) (Aa::agent) (Ba::agent) (NAa::nat) (NBa::nat) K::nat. ⟦(B::agent) ∉ bad; evs3 ∈ Guard_OtwayRees.or; or2' B' Aa Ba NAa NBa ∈ set evs3; Key K ∉ used evs3; or2 (A::agent) B (NA::nat) (NB::nat) (X::msg) ∈ set evs3; Guard NB {shrK B} (knows Spy evs3); Ba ≠ B; NBa ≠ NB⟧ ⟹ Ciph Ba ⦃Nonce NBa, Key K⦄ ∈ guard NB {shrK B}› discuss goal 1*) apply clarify (*top goal: ‹⋀evs3 B' Aa Ba NAa NBa K. ⟦B ∉ bad; evs3 ∈ Guard_OtwayRees.or; or2' B' Aa Ba NAa NBa ∈ set evs3; Key K ∉ used evs3; or2 A B NA NB X ∈ set evs3; Guard NB {shrK B} (knows Spy evs3); Ba ≠ B; NBa = NB⟧ ⟹ Ciph Ba ⦃Nonce NBa, Key K⦄ ∈ guard NB {shrK B}› and 2 goals remain*) apply (drule Says_imp_spies (*‹Says ?A ?B ?X ∈ set ?evs ⟹ ?X ∈ knows Spy ?evs›*)) (*top goal: ‹⋀(evs3::event list) (B'::agent) (Aa::agent) (Ba::agent) (NAa::nat) (NBa::nat) K::nat. ⟦(B::agent) ∉ bad; evs3 ∈ Guard_OtwayRees.or; or2' B' Aa Ba NAa (NB::nat) ∈ set evs3; Key K ∉ used evs3; or2 (A::agent) B (NA::nat) NB (X::msg) ∈ set evs3; Guard NB {shrK B} (knows Spy evs3); Ba ≠ B⟧ ⟹ Ciph Ba ⦃Nonce NB, Key K⦄ ∈ guard NB {shrK B}› and 2 goals remain*) apply (drule_tac Y="⦃Nonce NAa, Nonce NB, Agent Aa, Agent Ba⦄" and K="shrK Ba" in in_Guard_kparts_Crypt (*‹⟦?X ∈ ?G; Guard ?n ?Ks ?G; is_MPair ?X; Crypt ?K ?Y ∈ kparts {?X}; Nonce ?n ∈ kparts {?Y}⟧ ⟹ invKey ?K ∈ ?Ks›*)) (*goals: 1. ‹⋀(evs3::event list) (B'::agent) (Aa::agent) (Ba::agent) (NAa::nat) (NBa::nat) K::nat. ⟦(B::agent) ∉ bad; evs3 ∈ Guard_OtwayRees.or; Key K ∉ used evs3; or2 (A::agent) B (NA::nat) (NB::nat) (X::msg) ∈ set evs3; Guard NB {shrK B} (knows Spy evs3); Ba ≠ B⟧ ⟹ Guard ((?n239::event list ⇒ agent ⇒ agent ⇒ agent ⇒ nat ⇒ nat ⇒ nat ⇒ nat) evs3 B' Aa Ba NAa NBa K) ((?Ks239::event list ⇒ agent ⇒ agent ⇒ agent ⇒ nat ⇒ nat ⇒ nat ⇒ nat set) evs3 B' Aa Ba NAa NBa K) (knows Spy evs3)› 2. ‹⋀(evs3::event list) (B'::agent) (Aa::agent) (Ba::agent) (NAa::nat) (NBa::nat) K::nat. ⟦(B::agent) ∉ bad; evs3 ∈ Guard_OtwayRees.or; Key K ∉ used evs3; or2 (A::agent) B (NA::nat) (NB::nat) (X::msg) ∈ set evs3; Guard NB {shrK B} (knows Spy evs3); Ba ≠ B⟧ ⟹ is_MPair ⦃Nonce NAa, Agent Aa, Agent Ba, Ciph Aa ⦃Nonce NAa, Agent Aa, Agent Ba⦄, Ciph Ba ⦃Nonce NAa, Nonce NB, Agent Aa, Agent Ba⦄⦄› 3. ‹⋀(evs3::event list) (B'::agent) (Aa::agent) (Ba::agent) (NAa::nat) (NBa::nat) K::nat. ⟦(B::agent) ∉ bad; evs3 ∈ Guard_OtwayRees.or; Key K ∉ used evs3; or2 (A::agent) B (NA::nat) (NB::nat) (X::msg) ∈ set evs3; Guard NB {shrK B} (knows Spy evs3); Ba ≠ B⟧ ⟹ Ciph Ba ⦃Nonce NAa, Nonce NB, Agent Aa, Agent Ba⦄ ∈ kparts {⦃Nonce NAa, Agent Aa, Agent Ba, Ciph Aa ⦃Nonce NAa, Agent Aa, Agent Ba⦄, Ciph Ba ⦃Nonce NAa, Nonce NB, Agent Aa, Agent Ba⦄⦄}› 4. ‹⋀(evs3::event list) (B'::agent) (Aa::agent) (Ba::agent) (NAa::nat) (NBa::nat) K::nat. ⟦(B::agent) ∉ bad; evs3 ∈ Guard_OtwayRees.or; Key K ∉ used evs3; or2 (A::agent) B (NA::nat) (NB::nat) (X::msg) ∈ set evs3; Guard NB {shrK B} (knows Spy evs3); Ba ≠ B⟧ ⟹ Nonce ((?n239::event list ⇒ agent ⇒ agent ⇒ agent ⇒ nat ⇒ nat ⇒ nat ⇒ nat) evs3 B' Aa Ba NAa NBa K) ∈ kparts {⦃Nonce NAa, Nonce NB, Agent Aa, Agent Ba⦄}› 5. ‹⋀(evs3::event list) (B'::agent) (Aa::agent) (Ba::agent) (NAa::nat) (NBa::nat) K::nat. ⟦(B::agent) ∉ bad; evs3 ∈ Guard_OtwayRees.or; Key K ∉ used evs3; or2 (A::agent) B (NA::nat) (NB::nat) (X::msg) ∈ set evs3; Guard NB {shrK B} (knows Spy evs3); Ba ≠ B; invKey (shrK Ba) ∈ (?Ks239::event list ⇒ agent ⇒ agent ⇒ agent ⇒ nat ⇒ nat ⇒ nat ⇒ nat set) evs3 B' Aa Ba NAa NBa K⟧ ⟹ Ciph Ba ⦃Nonce NB, Key K⦄ ∈ guard NB {shrK B}› 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*) (*discuss goal 2*) apply (simp add: No_Nonce (*‹Nonce (?n::nat) ∉ parts {?X::msg} ⟹ ?X ∈ guard ?n (?Ks::nat set)›*)) (*proven 2 subgoals*) (*proven 2 subgoals*) (*proven 3 subgoals*) (*discuss goal 6*) apply simp (*goal: ‹⋀evs4 Aa Ba NAa NBa Xa S Y K. ⟦B ∉ bad; evs4 ∈ Guard_OtwayRees.or; or2 A B NA NB X ∈ set evs4 ⟶ Guard NB {shrK B} (knows Spy evs4); or2 Aa Ba NAa NBa Xa ∈ set evs4; Says S Ba ⦃Nonce NAa, Y, Ciph Ba ⦃Nonce NBa, Key K⦄⦄ ∈ set evs4⟧ ⟹ or2 A B NA NB X ∈ set (or4 Aa Ba NAa Xa # evs4) ⟶ Guard NB {shrK B} (knows Spy (or4 Aa Ba NAa Xa # evs4))›*) apply ((safe)[1]) (*goals: 1. ‹⋀evs4 Aa Ba NAa NBa Xa S Y K. ⟦B ∉ bad; evs4 ∈ Guard_OtwayRees.or; or2 Aa Ba NAa NBa Xa ∈ set evs4; Says S Ba ⦃Nonce NAa, Y, Ciph Ba ⦃Nonce NBa, Key K⦄⦄ ∈ set evs4; or2 A B NA NB X ∈ set evs4; Guard NB {shrK B} (knows Spy evs4)⟧ ⟹ Nonce NAa ∈ guard NB {shrK B}› 2. ‹⋀evs4 Aa Ba NAa NBa Xa S Y K. ⟦B ∉ bad; evs4 ∈ Guard_OtwayRees.or; or2 Aa Ba NAa NBa Xa ∈ set evs4; Says S Ba ⦃Nonce NAa, Y, Ciph Ba ⦃Nonce NBa, Key K⦄⦄ ∈ set evs4; or2 A B NA NB X ∈ set evs4; Guard NB {shrK B} (knows Spy evs4)⟧ ⟹ Xa ∈ guard NB {shrK B}› discuss goal 1*) apply (blast dest: Says_imp_spies (*‹Says ?A ?B ?X ∈ set ?evs ⟹ ?X ∈ knows Spy ?evs›*)) (*discuss goal 2*) apply (blast dest: Says_imp_spies (*‹Says ?A ?B ?X ∈ set ?evs ⟹ ?X ∈ knows Spy ?evs›*)) (*proven 2 subgoals*) (*proven 6 subgoals*) . end
{ "path": "Isabelle2024/src/HOL/Auth/Guard/Guard_OtwayRees.thy", "repo": "Isabelle2024", "sha": "1fe133cbc5b75252e628c98f186898e455fa119b316d8f2f8942ff3acac5dd90" }
(* Theory: Indep_Events.thy Author: Chelsea Edmonds *) section ‹ Independent Events › theory Indep_Events imports Cond_Prob_Extensions begin subsection ‹More bijection helpers› lemma bij_betw_obtain_subsetr: assumes "bij_betw f A B" assumes "A' ⊆ A" obtains B' where "B' ⊆ B" and "B' = f ` A'" using assms (*‹bij_betw (f::'a ⇒ 'b) (A::'a set) (B::'b set)› ‹A' ⊆ A›*) by (metis bij_betw_def (*‹bij_betw ?f ?A ?B = (inj_on ?f ?A ∧ ?f ` ?A = ?B)›*) image_mono (*‹?A ⊆ ?B ⟹ ?f ` ?A ⊆ ?f ` ?B›*)) lemma bij_betw_obtain_subsetl: assumes "bij_betw f A B" assumes "B' ⊆ B" obtains A' where "A' ⊆ A" and "B' = f ` A'" using assms (*‹bij_betw f A B› ‹B' ⊆ B›*) by (metis bij_betw_imp_surj_on (*‹bij_betw ?f ?A ?B ⟹ ?f ` ?A = ?B›*) subset_imageE (*‹⟦?B ⊆ ?f ` ?A; ⋀C. ⟦C ⊆ ?A; ?B = ?f ` C⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*)) lemma bij_betw_remove: "bij_betw f A B ⟹ a ∈ A ⟹ bij_betw f (A - {a}) (B - {f a})" using bij_betwE (*‹bij_betw ?f ?A ?B ⟹ ∀a∈?A. ?f a ∈ ?B›*) notIn_Un_bij_betw3 (*‹⟦?b ∉ ?A; ?f ?b ∉ ?A'⟧ ⟹ bij_betw ?f ?A ?A' = bij_betw ?f (?A ∪ {?b}) (?A' ∪ {?f ?b})›*) by (metis Un_insert_right (*‹?A ∪ insert ?a ?B = insert ?a (?A ∪ ?B)›*) insert_Diff (*‹?a ∈ ?A ⟹ insert ?a (?A - {?a}) = ?A›*) member_remove (*‹(?x ∈ Set.remove ?y ?A) = (?x ∈ ?A ∧ ?x ≠ ?y)›*) remove_def (*‹Set.remove ?x ?A = ?A - {?x}›*) sup_bot.right_neutral (*‹?a ⊔ ⊥ = ?a›*)) (* Slow *) subsection ‹Independent Event Extensions › text ‹ Extensions on both the indep\_event definition and the indep\_events definition › context prob_space begin lemma indep_eventsD: "indep_events A I ⟹ (A`I ⊆ events) ⟹ J ⊆ I ⟹ J ≠ {} ⟹ finite J ⟹ prob (⋂j∈J. A j) = (∏j∈J. prob (A j))" using indep_events_def[of A I] (*‹indep_events (A::'b ⇒ 'a set) (I::'b set) = (A ` I ⊆ events ∧ (∀J⊆I. J ≠ {} ⟶ finite J ⟶ prob (⋂ (A ` J)) = (∏j::'b∈J. prob (A j))))›*) by auto lemma assumes indep: "indep_event A B" shows indep_eventD_ev1: "A ∈ events" and indep_eventD_ev2: "B ∈ events" using indep (*‹indep_event A B›*) unfolding indep_event_def indep_events_def UNIV_bool (*goals: 1. ‹A ∈ events› 2. ‹B ∈ events›*) apply - (*goals: 1. ‹case_bool A B ` {False, True} ⊆ events ∧ (∀J⊆{False, True}. J ≠ {} ⟶ finite J ⟶ prob (⋂ (case_bool A B ` J)) = (∏j∈J. prob (case j of True ⇒ A | False ⇒ B))) ⟹ A ∈ events› 2. ‹case_bool A B ` {False, True} ⊆ events ∧ (∀J⊆{False, True}. J ≠ {} ⟶ finite J ⟶ prob (⋂ (case_bool A B ` J)) = (∏j∈J. prob (case j of True ⇒ A | False ⇒ B))) ⟹ B ∈ events› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . lemma indep_eventD: assumes ie: "indep_event A B" shows "prob (A ∩ B) = prob (A) * prob (B)" using assms (*‹indep_event A B›*) indep_eventD_ev1 (*‹indep_event (?A::'a set) (?B::'a set) ⟹ ?A ∈ events›*) indep_eventD_ev2 (*‹indep_event ?A ?B ⟹ ?B ∈ events›*) ie[unfolded indep_event_def, THEN indep_eventsD, of UNIV] (*‹⟦range (case_bool A B) ⊆ events; UNIV ⊆ UNIV; UNIV ≠ {}; finite UNIV⟧ ⟹ prob (⋂j. case j of True ⇒ A | False ⇒ B) = (∏j∈UNIV. prob (case j of True ⇒ A | False ⇒ B))›*) by (simp add: 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*) UNIV_bool (*‹UNIV = {False, True}›*)) lemma indep_eventI[intro]: assumes ev: "A ∈ events" "B ∈ events" and indep: "prob (A ∩ B) = prob A * prob B" shows "indep_event A B" unfolding indep_event_def (*goal: ‹indep_events (case_bool A B) UNIV›*) proof (intro indep_eventsI (*‹⟦⋀i. i ∈ ?I ⟹ ?F i ∈ events; ⋀J. ⟦J ⊆ ?I; finite J; J ≠ {}⟧ ⟹ prob (⋂ (?F ` J)) = (∏i∈J. prob (?F i))⟧ ⟹ indep_events ?F ?I›*)) (*goals: 1. ‹⋀i. i ∈ UNIV ⟹ (case i of True ⇒ A | False ⇒ B) ∈ events› 2. ‹⋀J. ⟦J ⊆ UNIV; finite J; J ≠ {}⟧ ⟹ prob (⋂i∈J. case i of True ⇒ A | False ⇒ B) = (∏i∈J. prob (case i of True ⇒ A | False ⇒ B))›*) show "⋀i. i ∈ UNIV ⟹ (case i of True ⇒ A | False ⇒ B) ∈ events" using assms (*‹A ∈ events› ‹B ∈ events› ‹prob (A ∩ B) = prob A * prob B›*) by (auto split: bool.split (*‹?P (case ?bool of True ⇒ ?f1.0 | False ⇒ ?f2.0) = ((?bool = True ⟶ ?P ?f1.0) ∧ (?bool = False ⟶ ?P ?f2.0))›*)) next (*goal: ‹⋀J::bool set. ⟦J ⊆ UNIV; finite J; J ≠ {}⟧ ⟹ prob (⋂i::bool∈J. case i of True ⇒ A::'a set | False ⇒ B::'a set) = (∏i::bool∈J. prob (case i of True ⇒ A | False ⇒ B))›*) fix J :: "bool set" assume jss: "J ⊆ UNIV" and jne: "J ≠ {}" and finJ: "finite J" (*‹(J::bool set) ⊆ UNIV› ‹(J::bool set) ≠ {}› ‹finite (J::bool set)›*) have "J ∈ Pow UNIV" by auto then have c: "J = UNIV ∨ J = {True} ∨ J = {False}" using jne (*‹J ≠ {}›*) jss (*‹J ⊆ UNIV›*) UNIV_bool (*‹UNIV = {False, True}›*) by (metis (full_types) UNIV_eq_I (*‹(⋀x. x ∈ ?A) ⟹ UNIV = ?A›*) insert_commute (*‹insert ?x (insert ?y ?A) = insert ?y (insert ?x ?A)›*) subset_insert (*‹?x ∉ ?A ⟹ (?A ⊆ insert ?x ?B) = (?A ⊆ ?B)›*) subset_singletonD (*‹?A ⊆ {?x} ⟹ ?A = {} ∨ ?A = {?x}›*)) then show "prob (⋂i∈J. case i of True ⇒ A | False ⇒ B) = (∏i∈J. prob (case i of True ⇒ A | False ⇒ B)) " unfolding UNIV_bool (*goal: ‹prob (⋂i∈J. case i of True ⇒ A | False ⇒ B) = (∏i∈J. prob (case i of True ⇒ A | False ⇒ B))›*) using indep (*‹prob ((A::'a::type set) ∩ (B::'a::type set)) = prob A * prob B›*) 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*)) qed text ‹Alternate set definition - when no possibility of duplicate objects › definition indep_events_set :: "'a set set ⇒ bool" where "indep_events_set E ≡ (E ⊆ events ∧ (∀J. J ⊆ E ⟶ finite J ⟶ J ≠ {} ⟶ prob (⋂J) = (∏i∈J. prob i)))" lemma indep_events_setI[intro]: "E ⊆ events ⟹ (⋀J. J ⊆ E ⟹ finite J ⟹ J ≠ {} ⟹ prob (⋂J) = (∏i∈J. prob i)) ⟹ indep_events_set E" using indep_events_set_def (*‹indep_events_set ?E ≡ ?E ⊆ events ∧ (∀J⊆?E. finite J ⟶ J ≠ {} ⟶ prob (⋂ J) = prod prob J)›*) by simp lemma indep_events_subset: "indep_events_set E ⟷ (∀J⊆E. indep_events_set J)" by (auto simp: indep_events_set_def (*‹indep_events_set ?E ≡ ?E ⊆ events ∧ (∀J⊆?E. finite J ⟶ J ≠ {} ⟶ prob (⋂ J) = prod prob J)›*)) lemma indep_events_subset2: "indep_events_set E ⟹ J ⊆ E ⟹ indep_events_set J" by (auto simp: indep_events_set_def (*‹indep_events_set ?E ≡ ?E ⊆ events ∧ (∀J⊆?E. finite J ⟶ J ≠ {} ⟶ prob (⋂ J) = prod prob J)›*)) lemma indep_events_set_events: "indep_events_set E ⟹ (⋀e. e ∈ E ⟹ e ∈ events)" using indep_events_set_def (*‹indep_events_set (?E::'a::type set set) ≡ ?E ⊆ events ∧ (∀J⊆?E. finite J ⟶ J ≠ {} ⟶ prob (⋂ J) = prod prob J)›*) by auto lemma indep_events_set_events_ss: "indep_events_set E ⟹ E ⊆ events" using indep_events_set_events (*‹⟦indep_events_set ?E; ?e ∈ ?E⟧ ⟹ ?e ∈ events›*) by auto lemma indep_events_set_probs: "indep_events_set E ⟹ J ⊆ E ⟹ finite J ⟹ J ≠ {} ⟹ prob (⋂J) = (∏i∈J. prob i)" by (simp add: indep_events_set_def (*‹indep_events_set ?E ≡ ?E ⊆ events ∧ (∀J⊆?E. finite J ⟶ J ≠ {} ⟶ prob (⋂ J) = prod prob J)›*)) lemma indep_events_set_prod_all: "indep_events_set E ⟹ finite E ⟹ E ≠ {} ⟹ prob (⋂E) = prod prob E" using indep_events_set_probs (*‹⟦indep_events_set ?E; ?J ⊆ ?E; finite ?J; ?J ≠ {}⟧ ⟹ prob (⋂ ?J) = prod prob ?J›*) by simp lemma indep_events_not_contain_compl: assumes "indep_events_set E" assumes "A ∈ E" assumes "prob A > 0" "prob A < 1" shows "(space M - A) ∉ E" (is "?A' ∉ E") proof (rule ccontr (*‹(¬ ?P ⟹ False) ⟹ ?P›*)) (*goal: ‹¬ space M - A ∉ E ⟹ False›*) assume "¬ (?A') ∉ E" (*‹¬ space (M::'a measure) - (A::'a set) ∉ (E::'a set set)›*) then have "?A' ∈ E" by auto then have "{A, ?A'} ⊆ E" using assms(2) (*‹A ∈ E›*) by auto moreover have "finite {A, ?A'}" by simp moreover have "{A, ?A'} ≠ {}" by simp ultimately have "prob (⋂i∈{A, ?A'}. i) = (∏i∈{A, ?A'}. prob i)" using indep_events_set_probs[of E "{A, ?A'}"] (*‹⟦indep_events_set E; {A, space M - A} ⊆ E; finite {A, space M - A}; {A, space M - A} ≠ {}⟧ ⟹ prob (⋂ {A, space M - A}) = prod prob {A, space M - A}›*) assms(1) (*‹indep_events_set E›*) by auto then have "prob (A ∩ ?A') = prob A * prob ?A'" by simp moreover have "prob (A ∩ ?A') = 0" by simp moreover have "prob A * prob ?A' = prob A * (1 - prob A)" using assms(1) (*‹indep_events_set E›*) assms(2) (*‹A ∈ E›*) indep_events_set_events (*‹⟦indep_events_set ?E; ?e ∈ ?E⟧ ⟹ ?e ∈ events›*) prob_compl (*‹?A ∈ events ⟹ prob (space M - ?A) = 1 - prob ?A›*) by auto moreover have "prob A * (1 - prob A) > 0" using assms(3) (*‹0 < prob A›*) assms(4) (*‹prob (A::'a set) < (1::real)›*) 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*)) ultimately show False by auto qed lemma indep_events_contain_compl_prob01: assumes "indep_events_set E" assumes "A ∈ E" assumes "space M - A ∈ E" shows "prob A = 0 ∨ prob A = 1" proof (rule ccontr (*‹(¬ ?P ⟹ False) ⟹ ?P›*)) (*goal: ‹¬ (prob A = 0 ∨ prob A = 1) ⟹ False›*) let ?A' = "space M - A" assume a: "¬ (prob A = 0 ∨ prob A = 1)" (*‹¬ (prob (A::'a set) = (0::real) ∨ prob A = (1::real))›*) then have "prob A > 0" by (simp add: zero_less_measure_iff (*‹(0 < Sigma_Algebra.measure ?M ?A) = (Sigma_Algebra.measure ?M ?A ≠ 0)›*)) moreover have "prob A < 1" using a (*‹¬ (prob A = 0 ∨ prob A = 1)›*) measure_ge_1_iff (*‹((1::real) ≤ prob (?A::'a set)) = (prob ?A = (1::real))›*) by fastforce ultimately have "?A' ∉ E" using assms(1) (*‹indep_events_set E›*) assms(2) (*‹A ∈ E›*) indep_events_not_contain_compl (*‹⟦indep_events_set ?E; ?A ∈ ?E; 0 < prob ?A; prob ?A < 1⟧ ⟹ space M - ?A ∉ ?E›*) by auto then show False using assms(3) (*‹space M - A ∈ E›*) by auto qed lemma indep_events_set_singleton: assumes "A ∈ events" shows "indep_events_set {A}" proof (intro indep_events_setI (*‹⟦?E ⊆ events; ⋀J. ⟦J ⊆ ?E; finite J; J ≠ {}⟧ ⟹ prob (⋂ J) = prod prob J⟧ ⟹ indep_events_set ?E›*)) (*goals: 1. ‹{A} ⊆ events› 2. ‹⋀J. ⟦J ⊆ {A}; finite J; J ≠ {}⟧ ⟹ prob (⋂ J) = prod prob J›*) show "{A} ⊆ events" using assms (*‹(A::'a::type set) ∈ events›*) by simp next (*goal: ‹⋀J. ⟦J ⊆ {A}; finite J; J ≠ {}⟧ ⟹ prob (⋂ J) = prod prob J›*) fix J assume "J ⊆ {A}" "finite J" "J ≠ {}" (*‹(J::'a set set) ⊆ {A::'a set}› ‹finite (J::'a set set)› ‹(J::'a set set) ≠ {}›*) then have "J = {A}" by auto then show "prob (⋂J) = prod prob J" by simp qed lemma indep_events_pairs: assumes "indep_events_set S" assumes "A ∈ S" "B ∈ S" "A ≠ B" shows "indep_event A B" using assms (*‹indep_events_set (S::'a set set)› ‹A ∈ S› ‹B ∈ S› ‹A ≠ B›*) indep_events_set_probs[of "S" "{A, B}"] (*‹⟦indep_events_set S; {A, B} ⊆ S; finite {A, B}; {A, B} ≠ {}⟧ ⟹ prob (⋂ {A, B}) = prod prob {A, B}›*) apply (intro indep_eventI (*‹⟦?A ∈ events; ?B ∈ events; prob (?A ∩ ?B) = prob ?A * prob ?B⟧ ⟹ indep_event ?A ?B›*)) (*goals: 1. ‹⟦indep_events_set S; A ∈ S; B ∈ S; A ≠ B; ⟦indep_events_set S; {A, B} ⊆ S; finite {A, B}; {A, B} ≠ {}⟧ ⟹ prob (⋂ {A, B}) = prod prob {A, B}⟧ ⟹ A ∈ events› 2. ‹⟦indep_events_set S; A ∈ S; B ∈ S; A ≠ B; ⟦indep_events_set S; {A, B} ⊆ S; finite {A, B}; {A, B} ≠ {}⟧ ⟹ prob (⋂ {A, B}) = prod prob {A, B}⟧ ⟹ B ∈ events› 3. ‹⟦indep_events_set S; A ∈ S; B ∈ S; A ≠ B; ⟦indep_events_set S; {A, B} ⊆ S; finite {A, B}; {A, B} ≠ {}⟧ ⟹ prob (⋂ {A, B}) = prod prob {A, B}⟧ ⟹ prob (A ∩ B) = prob A * prob B› discuss goal 1*) apply (simp add: indep_events_set_events (*‹⟦indep_events_set ?E; ?e ∈ ?E⟧ ⟹ ?e ∈ events›*)) (*discuss goal 2*) apply (simp add: indep_events_set_events (*‹⟦indep_events_set ?E; ?e ∈ ?E⟧ ⟹ ?e ∈ events›*)) (*discuss goal 3*) apply (simp add: indep_events_set_events (*‹⟦indep_events_set (?E::'a set set); (?e::'a set) ∈ ?E⟧ ⟹ ?e ∈ events›*)) (*proven 3 subgoals*) . lemma indep_events_inter_pairs: assumes "indep_events_set S" assumes "finite A" "finite B" assumes "A ≠ {}" "B ≠ {}" assumes "A ⊆ S" "B ⊆ S" "A ∩ B = {}" shows "indep_event (⋂A) (⋂B)" proof (intro indep_eventI (*‹⟦?A ∈ events; ?B ∈ events; prob (?A ∩ ?B) = prob ?A * prob ?B⟧ ⟹ indep_event ?A ?B›*)) (*goals: 1. ‹⋂ A ∈ events› 2. ‹⋂ B ∈ events› 3. ‹prob (⋂ A ∩ ⋂ B) = prob (⋂ A) * prob (⋂ B)›*) have "A ⊆ events" "B ⊆ events" using indep_events_set_events (*‹⟦indep_events_set (?E::'a set set); (?e::'a set) ∈ ?E⟧ ⟹ ?e ∈ events›*) assms (*‹indep_events_set S› ‹finite A› ‹finite B› ‹A ≠ {}› ‹B ≠ {}› ‹A ⊆ S› ‹B ⊆ S› ‹A ∩ B = {}›*) apply - (*goals: 1. ‹⟦⋀E e. ⟦indep_events_set E; e ∈ E⟧ ⟹ e ∈ events; indep_events_set S; finite A; finite B; A ≠ {}; B ≠ {}; A ⊆ S; B ⊆ S; A ∩ B = {}⟧ ⟹ A ⊆ events› 2. ‹⟦⋀E e. ⟦indep_events_set E; e ∈ E⟧ ⟹ e ∈ events; indep_events_set S; finite A; finite B; A ≠ {}; B ≠ {}; A ⊆ S; B ⊆ S; A ∩ B = {}⟧ ⟹ B ⊆ events› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . then show "⋂ A ∈ events" "⋂ B ∈ events" using Inter_event_ss (*‹⟦finite ?A; ?A ⊆ events; ?A ≠ {}⟧ ⟹ ⋂ ?A ∈ events›*) assms (*‹indep_events_set S› ‹finite A› ‹finite (B::'a set set)› ‹A ≠ {}› ‹(B::'a::type set set) ≠ {}› ‹A ⊆ S› ‹B ⊆ S› ‹(A::'a set set) ∩ (B::'a set set) = {}›*) apply - (*goals: 1. ‹⟦A ⊆ events; B ⊆ events; ⋀A. ⟦finite A; A ⊆ events; A ≠ {}⟧ ⟹ ⋂ A ∈ events; indep_events_set S; finite A; finite B; A ≠ {}; B ≠ {}; A ⊆ S; B ⊆ S; A ∩ B = {}⟧ ⟹ ⋂ A ∈ events› 2. ‹⟦A ⊆ events; B ⊆ events; ⋀A. ⟦finite A; A ⊆ events; A ≠ {}⟧ ⟹ ⋂ A ∈ events; indep_events_set S; finite A; finite B; A ≠ {}; B ≠ {}; A ⊆ S; B ⊆ S; A ∩ B = {}⟧ ⟹ ⋂ B ∈ events› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . next (*goal: ‹prob (⋂ A ∩ ⋂ B) = prob (⋂ A) * prob (⋂ B)›*) have "A ∪ B ⊆ S" using assms (*‹indep_events_set S› ‹finite (A::'a::type set set)› ‹finite B› ‹A ≠ {}› ‹B ≠ {}› ‹A ⊆ S› ‹B ⊆ S› ‹A ∩ B = {}›*) by auto then have "prob (⋂(A ∪ B)) = prod prob (A ∪ B)" using assms (*‹indep_events_set S› ‹finite A› ‹finite B› ‹A ≠ {}› ‹B ≠ {}› ‹(A::'a set set) ⊆ (S::'a set set)› ‹B ⊆ S› ‹A ∩ B = {}›*) by (metis Un_empty (*‹(?A ∪ ?B = {}) = (?A = {} ∧ ?B = {})›*) indep_events_subset (*‹indep_events_set ?E = (∀J⊆?E. indep_events_set J)›*) infinite_Un (*‹infinite (?S ∪ ?T) = (infinite ?S ∨ infinite ?T)›*) prob_space.indep_events_set_prod_all (*‹⟦prob_space ?M; prob_space.indep_events_set ?M ?E; finite ?E; ?E ≠ {}⟧ ⟹ Sigma_Algebra.measure ?M (⋂ ?E) = prod (Sigma_Algebra.measure ?M) ?E›*) prob_space_axioms (*‹prob_space M›*)) also (*calculation: ‹prob (⋂ ((A::'a::type set set) ∪ (B::'a::type set set))) = prod prob (A ∪ B)›*) have "... = prod prob A * prod prob B" using assms(8) (*‹(A::'a::type set set) ∩ (B::'a::type set set) = {}›*) by (simp add: assms( (*‹finite A›*) 2) assms( (*‹finite B›*) 3) prod.union_disjoint (*‹⟦finite ?A; finite ?B; ?A ∩ ?B = {}⟧ ⟹ prod ?g (?A ∪ ?B) = prod ?g ?A * prod ?g ?B›*)) finally (*calculation: ‹prob (⋂ (A ∪ B)) = prod prob A * prod prob B›*) have "prob (⋂(A ∪ B)) = prob (⋂ A) * prob (⋂ B)" using assms (*‹indep_events_set S› ‹finite A› ‹finite B› ‹(A::'a set set) ≠ {}› ‹B ≠ {}› ‹A ⊆ S› ‹B ⊆ S› ‹A ∩ B = {}›*) indep_events_subset (*‹indep_events_set ?E = (∀J⊆?E. indep_events_set J)›*) indep_events_set_prod_all (*‹⟦indep_events_set ?E; finite ?E; ?E ≠ {}⟧ ⟹ prob (⋂ ?E) = prod prob ?E›*) by metis moreover have "⋂ (A ∪ B) = (⋂ A ∩ ⋂ B)" by auto ultimately show "prob (⋂ A ∩ ⋂ B) = prob (⋂ A) * prob (⋂ B)" by simp qed lemma indep_events_inter_single: assumes "indep_events_set S" assumes "finite B" assumes "B ≠ {}" assumes "A ∈ S" "B ⊆ S" "A ∉ B" shows "indep_event A (⋂B)" proof (-) (*goal: ‹indep_event A (⋂ B)›*) have "{A} ≠ {}" "finite {A}" "{A} ⊆ S" using assms (*‹indep_events_set S› ‹finite B› ‹(B::'a set set) ≠ {}› ‹(A::'a::type set) ∈ (S::'a::type set set)› ‹(B::'a set set) ⊆ (S::'a set set)› ‹(A::'a set) ∉ (B::'a set set)›*) apply - (*goals: 1. ‹⟦indep_events_set (S::'a set set); finite (B::'a set set); B ≠ {}; (A::'a set) ∈ S; B ⊆ S; A ∉ B⟧ ⟹ {A} ≠ {}› 2. ‹⟦indep_events_set (S::'a set set); finite (B::'a set set); B ≠ {}; (A::'a set) ∈ S; B ⊆ S; A ∉ B⟧ ⟹ finite {A}› 3. ‹⟦indep_events_set (S::'a set set); finite (B::'a set set); B ≠ {}; (A::'a set) ∈ S; B ⊆ S; A ∉ B⟧ ⟹ {A} ⊆ S› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*discuss goal 3*) apply simp (*proven 3 subgoals*) . moreover have "{A} ∩ B = {}" using assms(6) (*‹A ∉ B›*) by auto ultimately show "?thesis" (*goal: ‹indep_event (A::'a::type set) (⋂ (B::'a::type set set))›*) using indep_events_inter_pairs[of S "{A}" B] (*‹⟦indep_events_set (S::'a set set); finite {A::'a set}; finite (B::'a set set); {A} ≠ {}; B ≠ {}; {A} ⊆ S; B ⊆ S; {A} ∩ B = {}⟧ ⟹ indep_event (⋂ {A}) (⋂ B)›*) assms (*‹indep_events_set S› ‹finite (B::'a set set)› ‹B ≠ {}› ‹A ∈ S› ‹(B::'a set set) ⊆ (S::'a set set)› ‹A ∉ B›*) by auto qed lemma indep_events_set_prob1: assumes "A ∈ events" assumes "prob A = 1" assumes "A ∉ S" assumes "indep_events_set S" shows "indep_events_set (S ∪ {A})" proof (intro indep_events_setI (*‹⟦?E ⊆ events; ⋀J. ⟦J ⊆ ?E; finite J; J ≠ {}⟧ ⟹ prob (⋂ J) = prod prob J⟧ ⟹ indep_events_set ?E›*)) (*goals: 1. ‹S ∪ {A} ⊆ events› 2. ‹⋀J. ⟦J ⊆ S ∪ {A}; finite J; J ≠ {}⟧ ⟹ prob (⋂ J) = prod prob J›*) show " S ∪ {A} ⊆ events" using assms(1) (*‹A ∈ events›*) assms(4) (*‹indep_events_set S›*) indep_events_set_events (*‹⟦indep_events_set ?E; ?e ∈ ?E⟧ ⟹ ?e ∈ events›*) by auto next (*goal: ‹⋀J::'a set set. ⟦J ⊆ (S::'a set set) ∪ {A::'a set}; finite J; J ≠ {}⟧ ⟹ prob (⋂ J) = prod prob J›*) fix J assume jss: "J ⊆ S ∪ {A}" and finJ: "finite J" and jne: "J ≠ {}" (*‹(J::'a set set) ⊆ (S::'a set set) ∪ {A::'a set}› ‹finite (J::'a set set)› ‹(J::'a set set) ≠ {}›*) show "prob (⋂J) = prod prob J" proof (cases "A ∈ J") (*goals: 1. ‹A ∈ J ⟹ prob (⋂ J) = prod prob J› 2. ‹A ∉ J ⟹ prob (⋂ J) = prod prob J›*) case t1: True (*‹A ∈ J›*) then show "?thesis" (*goal: ‹prob (⋂ J) = prod prob J›*) proof (cases "J = {A}") (*goals: 1. ‹⟦A ∈ J; J = {A}⟧ ⟹ prob (⋂ J) = prod prob J› 2. ‹⟦A ∈ J; J ≠ {A}⟧ ⟹ prob (⋂ J) = prod prob J›*) case True (*‹J = {A}›*) then show "?thesis" (*goal: ‹prob (⋂ J) = prod prob J›*) using indep_events_set_singleton (*‹?A ∈ events ⟹ indep_events_set {?A}›*) assms(1) (*‹A ∈ events›*) by auto next (*goal: ‹⟦A ∈ J; J ≠ {A}⟧ ⟹ prob (⋂ J) = prod prob J›*) case False (*‹J ≠ {A}›*) then have jun: "(J - {A}) ∪ {A} = J" using t1 (*‹A ∈ J›*) by auto have "J - {A} ⊆ S" using jss (*‹J ⊆ S ∪ {A}›*) by auto then have iej: "indep_events_set (J - {A})" using indep_events_subset2[of S "J - {A}"] (*‹⟦indep_events_set S; J - {A} ⊆ S⟧ ⟹ indep_events_set (J - {A})›*) assms(4) (*‹indep_events_set S›*) by auto have jsse: "J - {A} ⊆ events" using indep_events_set_events (*‹⟦indep_events_set ?E; ?e ∈ ?E⟧ ⟹ ?e ∈ events›*) jss (*‹J ⊆ S ∪ {A}›*) using assms(4) (*‹indep_events_set S›*) by blast have jne2: "J - {A} ≠ {}" using False (*‹J ≠ {A}›*) jss (*‹J ⊆ S ∪ {A}›*) jne (*‹(J::'a::type set set) ≠ {}›*) by auto have split: "(J - {A}) ∩ {A} = {}" by auto then have "prob (⋂i∈J. i) = prob ((⋂i∈(J - {A}). i) ∩ A)" using jun (*‹J - {A} ∪ {A} = J›*) by (metis Int_commute (*‹(?A::?'a set) ∩ (?B::?'a set) = ?B ∩ ?A›*) Inter_insert (*‹⋂ (insert (?a::?'a set) (?B::?'a set set)) = ?a ∩ ⋂ ?B›*) Un_ac( (*‹(?A::?'a set) ∪ (?B::?'a set) = ?B ∪ ?A›*) 3) image_ident (*‹(λx::?'a. x) ` (?Y::?'a set) = ?Y›*) insert_is_Un (*‹insert (?a::?'a) (?A::?'a set) = {?a} ∪ ?A›*)) also (*calculation: ‹prob (⋂i∈J. i) = prob ((⋂i∈J - {A}. i) ∩ A)›*) have "... = prob ((⋂i∈(J - {A}). i))" using prob1_basic_Inter[of A "J - {A}"] (*‹⟦(A::'a set) ∈ events; (J::'a set set) - {A} ⊆ events; prob A = (1::real); J - {A} ≠ {}; finite (J - {A})⟧ ⟹ prob (A ∩ ⋂ (J - {A})) = prob (⋂ (J - {A}))›*) jsse (*‹(J::'a set set) - {A::'a set} ⊆ events›*) assms(2) (*‹prob A = 1›*) jne2 (*‹J - {A} ≠ {}›*) assms(1) (*‹A ∈ events›*) finJ (*‹finite J›*) by (simp add: Int_commute (*‹(?A::?'a::type set) ∩ (?B::?'a::type set) = ?B ∩ ?A›*)) also (*calculation: ‹prob (⋂i∈J. i) = prob (⋂i∈J - {A}. i)›*) have "... = prob (⋂(J - {A})) * prob A" using assms(2) (*‹prob A = 1›*) by simp also (*calculation: ‹prob (⋂i∈J. i) = prob (⋂ (J - {A})) * prob A›*) have "... = (prod prob (J - {A})) * prob A" using iej (*‹indep_events_set (J - {A})›*) indep_events_set_prod_all[of "J - {A}"] (*‹⟦indep_events_set ((J::'a set set) - {A::'a set}); finite (J - {A}); J - {A} ≠ {}⟧ ⟹ prob (⋂ (J - {A})) = prod prob (J - {A})›*) jne2 (*‹J - {A} ≠ {}›*) finJ (*‹finite J›*) finite_subset (*‹⟦?A ⊆ ?B; finite ?B⟧ ⟹ finite ?A›*) by auto also (*calculation: ‹prob (⋂i∈J. i) = prod prob (J - {A}) * prob A›*) have "... = prod prob ((J - {A}) ∪ {A})" using split (*‹(J - {A}) ∩ {A} = {}›*) by (metis finJ (*‹finite J›*) jun (*‹J - {A} ∪ {A} = J›*) mult.commute (*‹?a * ?b = ?b * ?a›*) prod.remove (*‹⟦finite ?A; ?x ∈ ?A⟧ ⟹ prod ?g ?A = ?g ?x * prod ?g (?A - {?x})›*) t1 (*‹A ∈ J›*)) finally (*calculation: ‹prob (⋂i∈J. i) = prod prob (J - {A} ∪ {A})›*) show "?thesis" (*goal: ‹prob (⋂ J) = prod prob J›*) using jun (*‹(J::'a set set) - {A::'a set} ∪ {A} = J›*) by auto qed next (*goal: ‹A ∉ J ⟹ prob (⋂ J) = prod prob J›*) case False (*‹A ∉ J›*) then have jss2: "J ⊆ S" using jss (*‹J ⊆ S ∪ {A}›*) by auto then have "indep_events_set J" using assms(4) (*‹indep_events_set S›*) indep_events_subset2[of S J] (*‹⟦indep_events_set (S::'a::type set set); (J::'a::type set set) ⊆ S⟧ ⟹ indep_events_set J›*) by auto then show "?thesis" (*goal: ‹prob (⋂ J) = prod prob J›*) using indep_events_set_probs (*‹⟦indep_events_set ?E; ?J ⊆ ?E; finite ?J; ?J ≠ {}⟧ ⟹ prob (⋂ ?J) = prod prob ?J›*) finJ (*‹finite (J::'a set set)›*) jne (*‹(J::'a set set) ≠ {}›*) jss2 (*‹J ⊆ S›*) by auto qed qed lemma indep_events_set_prob0: assumes "A ∈ events" assumes "prob A = 0" assumes "A ∉ S" assumes "indep_events_set S" shows "indep_events_set (S ∪ {A})" proof (intro indep_events_setI (*‹⟦?E ⊆ events; ⋀J. ⟦J ⊆ ?E; finite J; J ≠ {}⟧ ⟹ prob (⋂ J) = prod prob J⟧ ⟹ indep_events_set ?E›*)) (*goals: 1. ‹(S::'a set set) ∪ {A::'a set} ⊆ events› 2. ‹⋀J::'a set set. ⟦J ⊆ (S::'a set set) ∪ {A::'a set}; finite J; J ≠ {}⟧ ⟹ prob (⋂ J) = prod prob J›*) show "S ∪ {A}⊆ events" using assms(1) (*‹A ∈ events›*) assms(4) (*‹indep_events_set (S::'a set set)›*) indep_events_set_events (*‹⟦indep_events_set (?E::'a::type set set); (?e::'a::type set) ∈ ?E⟧ ⟹ ?e ∈ events›*) by auto next (*goal: ‹⋀J::'a set set. ⟦J ⊆ (S::'a set set) ∪ {A::'a set}; finite J; J ≠ {}⟧ ⟹ prob (⋂ J) = prod prob J›*) fix J assume jss: "J ⊆ S ∪ {A}" and finJ: "finite J" and jne: "J ≠ {}" (*‹(J::'a set set) ⊆ (S::'a set set) ∪ {A::'a set}› ‹finite (J::'a set set)› ‹(J::'a set set) ≠ {}›*) show "prob (⋂J) = prod prob J" proof (cases "A ∈ J") (*goals: 1. ‹A ∈ J ⟹ prob (⋂ J) = prod prob J› 2. ‹A ∉ J ⟹ prob (⋂ J) = prod prob J›*) case t1: True (*‹A ∈ J›*) then show "?thesis" (*goal: ‹prob (⋂ J) = prod prob J›*) proof (cases "J = {A}") (*goals: 1. ‹⟦(A::'a set) ∈ (J::'a set set); J = {A}⟧ ⟹ prob (⋂ J) = prod prob J› 2. ‹⟦(A::'a set) ∈ (J::'a set set); J ≠ {A}⟧ ⟹ prob (⋂ J) = prod prob J›*) case True (*‹J = {A}›*) then show "?thesis" (*goal: ‹prob (⋂ J) = prod prob J›*) using indep_events_set_singleton (*‹?A ∈ events ⟹ indep_events_set {?A}›*) assms(1) (*‹(A::'a set) ∈ events›*) by auto next (*goal: ‹⟦(A::'a set) ∈ (J::'a set set); J ≠ {A}⟧ ⟹ prob (⋂ J) = prod prob J›*) case False (*‹J ≠ {A}›*) then have jun: "(J - {A}) ∪ {A} = J" using t1 (*‹A ∈ J›*) by auto have "J - {A} ⊆ S" using jss (*‹(J::'a::type set set) ⊆ (S::'a::type set set) ∪ {A::'a::type set}›*) by auto then have iej: "indep_events_set (J - {A})" using indep_events_subset2[of S "J - {A}"] (*‹⟦indep_events_set S; J - {A} ⊆ S⟧ ⟹ indep_events_set (J - {A})›*) assms(4) (*‹indep_events_set S›*) by auto have jsse: "J - {A} ⊆ events" using indep_events_set_events (*‹⟦indep_events_set (?E::'a::type set set); (?e::'a::type set) ∈ ?E⟧ ⟹ ?e ∈ events›*) jss (*‹(J::'a::type set set) ⊆ (S::'a::type set set) ∪ {A::'a::type set}›*) using assms(4) (*‹indep_events_set S›*) by blast have jne2: "J - {A} ≠ {}" using False (*‹J ≠ {A}›*) jss (*‹(J::'a set set) ⊆ (S::'a set set) ∪ {A::'a set}›*) jne (*‹(J::'a set set) ≠ {}›*) by auto have split: "(J - {A}) ∩ {A} = {}" by auto then have "prob (⋂i∈J. i) = prob ((⋂i∈(J - {A}). i) ∩ A)" using jun (*‹J - {A} ∪ {A} = J›*) by (metis Int_commute (*‹(?A::?'a set) ∩ (?B::?'a set) = ?B ∩ ?A›*) Inter_insert (*‹⋂ (insert (?a::?'a set) (?B::?'a set set)) = ?a ∩ ⋂ ?B›*) Un_ac( (*‹(?A::?'a set) ∪ (?B::?'a set) = ?B ∪ ?A›*) 3) image_ident (*‹(λx::?'a. x) ` (?Y::?'a set) = ?Y›*) insert_is_Un (*‹insert (?a::?'a) (?A::?'a set) = {?a} ∪ ?A›*)) also (*calculation: ‹prob (⋂i∈J. i) = prob ((⋂i∈J - {A}. i) ∩ A)›*) have "... = 0" using prob0_basic_Inter[of A "J - {A}"] (*‹⟦A ∈ events; J - {A} ⊆ events; prob A = 0⟧ ⟹ prob (A ∩ ⋂ (J - {A})) = 0›*) jsse (*‹J - {A} ⊆ events›*) assms(2) (*‹prob A = 0›*) jne2 (*‹J - {A} ≠ {}›*) assms(1) (*‹A ∈ events›*) finJ (*‹finite J›*) by (simp add: Int_commute (*‹?A ∩ ?B = ?B ∩ ?A›*)) also (*calculation: ‹prob (⋂i∈J. i) = 0›*) have "... = prob (⋂(J - {A})) * prob A" using assms(2) (*‹prob A = 0›*) by simp also (*calculation: ‹prob (⋂i∈J. i) = prob (⋂ (J - {A})) * prob A›*) have "... = (prod prob (J - {A})) * prob A" using iej (*‹indep_events_set (J - {A})›*) indep_events_set_prod_all[of "J - {A}"] (*‹⟦indep_events_set (J - {A}); finite (J - {A}); J - {A} ≠ {}⟧ ⟹ prob (⋂ (J - {A})) = prod prob (J - {A})›*) jne2 (*‹J - {A} ≠ {}›*) finJ (*‹finite J›*) finite_subset (*‹⟦?A ⊆ ?B; finite ?B⟧ ⟹ finite ?A›*) by auto also (*calculation: ‹prob (⋂i∈J. i) = prod prob (J - {A}) * prob A›*) have "... = prod prob ((J - {A}) ∪ {A})" using split (*‹(J - {A}) ∩ {A} = {}›*) by (metis finJ (*‹finite J›*) jun (*‹J - {A} ∪ {A} = J›*) mult.commute (*‹?a * ?b = ?b * ?a›*) prod.remove (*‹⟦finite ?A; ?x ∈ ?A⟧ ⟹ prod ?g ?A = ?g ?x * prod ?g (?A - {?x})›*) t1 (*‹A ∈ J›*)) finally (*calculation: ‹prob (⋂i∈J. i) = prod prob (J - {A} ∪ {A})›*) show "?thesis" (*goal: ‹prob (⋂ (J::'a set set)) = prod prob J›*) using jun (*‹J - {A} ∪ {A} = J›*) by auto qed next (*goal: ‹A ∉ J ⟹ prob (⋂ J) = prod prob J›*) case False (*‹A ∉ J›*) then have jss2: "J ⊆ S" using jss (*‹J ⊆ S ∪ {A}›*) by auto then have "indep_events_set J" using assms(4) (*‹indep_events_set (S::'a set set)›*) indep_events_subset2[of S J] (*‹⟦indep_events_set S; J ⊆ S⟧ ⟹ indep_events_set J›*) by auto then show "?thesis" (*goal: ‹prob (⋂ J) = prod prob J›*) using indep_events_set_probs (*‹⟦indep_events_set ?E; ?J ⊆ ?E; finite ?J; ?J ≠ {}⟧ ⟹ prob (⋂ ?J) = prod prob ?J›*) finJ (*‹finite J›*) jne (*‹J ≠ {}›*) jss2 (*‹(J::'a set set) ⊆ (S::'a set set)›*) by auto qed qed lemma indep_event_commute: assumes "indep_event A B" shows "indep_event B A" using indep_eventI[of "B" "A"] (*‹⟦B ∈ events; A ∈ events; prob (B ∩ A) = prob B * prob A⟧ ⟹ indep_event B A›*) indep_eventD[unfolded assms ( 1 ), of "A" "B"] (*‹indep_event (A::'a set) (B::'a set) ⟹ prob (A ∩ B) = prob A * prob B›*) by (metis Groups.mult_ac( (*‹?a * ?b = ?b * ?a›*) 2) Int_commute (*‹?A ∩ ?B = ?B ∩ ?A›*) assms (*‹indep_event A B›*) indep_eventD_ev1 (*‹indep_event ?A ?B ⟹ ?A ∈ events›*) indep_eventD_ev2 (*‹indep_event ?A ?B ⟹ ?B ∈ events›*)) text‹Showing complement operation maintains independence › lemma indep_event_one_compl: assumes "indep_event A B" shows "indep_event A (space M - B)" proof (-) (*goal: ‹indep_event (A::'a::type set) (space (M::'a::type measure) - (B::'a::type set))›*) let ?B' = "space M - B" have "A = (A ∩ B) ∪ (A ∩ ?B')" by (metis Int_Diff (*‹(?A::?'a set) ∩ (?B::?'a set) - (?C::?'a set) = ?A ∩ (?B - ?C)›*) Int_Diff_Un (*‹(?A::?'a set) ∩ (?B::?'a set) ∪ (?A - ?B) = ?A›*) assms (*‹indep_event (A::'a set) (B::'a set)›*) prob_space.indep_eventD_ev1 (*‹⟦prob_space (?M::?'a measure); prob_space.indep_event ?M (?A::?'a set) (?B::?'a set)⟧ ⟹ ?A ∈ sets ?M›*) prob_space_axioms (*‹prob_space (M::'a measure)›*) sets.Int_space_eq2 (*‹(?x::?'a set) ∈ sets (?M::?'a measure) ⟹ ?x ∩ space ?M = ?x›*)) then have "prob A = prob (A ∩ B) + prob (A ∩ ?B')" by (metis Diff_Int_distrib (*‹?C ∩ (?A - ?B) = ?C ∩ ?A - ?C ∩ ?B›*) Diff_disjoint (*‹?A ∩ (?B - ?A) = {}›*) assms (*‹indep_event A B›*) finite_measure_Union (*‹⟦?A ∈ events; ?B ∈ events; ?A ∩ ?B = {}⟧ ⟹ prob (?A ∪ ?B) = prob ?A + prob ?B›*) indep_eventD_ev1 (*‹indep_event ?A ?B ⟹ ?A ∈ events›*) indep_eventD_ev2 (*‹indep_event ?A ?B ⟹ ?B ∈ events›*) sets.Int (*‹⟦?a ∈ sets ?M; ?b ∈ sets ?M⟧ ⟹ ?a ∩ ?b ∈ sets ?M›*) sets.compl_sets (*‹?a ∈ sets ?M ⟹ space ?M - ?a ∈ sets ?M›*)) then have "prob (A ∩ ?B') = prob A - prob (A ∩ B)" by simp also (*calculation: ‹prob (A ∩ (space M - B)) = prob A - prob (A ∩ B)›*) have "... = prob A - prob A * prob B" using indep_eventD (*‹indep_event (?A::'a::type set) (?B::'a::type set) ⟹ prob (?A ∩ ?B) = prob ?A * prob ?B›*) assms(1) (*‹indep_event A B›*) by auto also (*calculation: ‹prob (A ∩ (space M - B)) = prob A - prob A * prob B›*) have "... = prob A * (1 - prob B)" by (simp add: vector_space_over_itself.scale_right_diff_distrib (*‹?a * (?x - ?y) = ?a * ?x - ?a * ?y›*)) finally (*calculation: ‹prob (A ∩ (space M - B)) = prob A * (1 - prob B)›*) have "prob (A ∩ ?B') = prob A * prob ?B'" using prob_compl (*‹?A ∈ events ⟹ prob (space M - ?A) = 1 - prob ?A›*) indep_eventD_ev1 (*‹indep_event ?A ?B ⟹ ?A ∈ events›*) assms(1) (*‹indep_event A B›*) indep_eventD_ev2 (*‹indep_event ?A ?B ⟹ ?B ∈ events›*) by presburger then show "indep_event A ?B'" using indep_eventI (*‹⟦?A ∈ events; ?B ∈ events; prob (?A ∩ ?B) = prob ?A * prob ?B⟧ ⟹ indep_event ?A ?B›*) indep_eventD_ev2 (*‹indep_event (?A::'a set) (?B::'a set) ⟹ ?B ∈ events›*) indep_eventD_ev1 (*‹indep_event ?A ?B ⟹ ?A ∈ events›*) assms(1) (*‹indep_event (A::'a set) (B::'a set)›*) by (meson sets.compl_sets (*‹?a ∈ sets ?M ⟹ space ?M - ?a ∈ sets ?M›*)) qed lemma indep_event_one_compl_rev: assumes "B ∈ events" assumes "indep_event A (space M - B)" shows "indep_event A B" proof (-) (*goal: ‹indep_event (A::'a::type set) (B::'a::type set)›*) have "space M - B ∈ events" using indep_eventD_ev2 (*‹indep_event (?A::'a set) (?B::'a set) ⟹ ?B ∈ events›*) assms (*‹B ∈ events› ‹indep_event (A::'a set) (space (M::'a measure) - (B::'a set))›*) by auto have "space M - (space M - B) = B" using compl_identity (*‹?A ∈ events ⟹ space M - (space M - ?A) = ?A›*) assms (*‹(B::'a set) ∈ events› ‹indep_event A (space M - B)›*) by simp then show "?thesis" (*goal: ‹indep_event A B›*) using indep_event_one_compl[of "A" "space M - B"] (*‹indep_event A (space M - B) ⟹ indep_event A (space M - (space M - B))›*) assms(2) (*‹indep_event A (space M - B)›*) by auto qed lemma indep_event_double_compl: "indep_event A B ⟹ indep_event (space M - A) (space M - B)" using indep_event_one_compl (*‹indep_event ?A ?B ⟹ indep_event ?A (space M - ?B)›*) indep_event_commute (*‹indep_event (?A::'a::type set) (?B::'a::type set) ⟹ indep_event ?B ?A›*) by auto lemma indep_event_double_compl_rev: "A ∈ events ⟹ B ∈ events ⟹ indep_event (space M - A) (space M - B) ⟹ indep_event A B" using indep_event_double_compl[of "space M - A" "space M - B"] (*‹indep_event (space (M::'a::type measure) - (A::'a::type set)) (space M - (B::'a::type set)) ⟹ indep_event (space M - (space M - A)) (space M - (space M - B))›*) compl_identity (*‹?A ∈ events ⟹ space M - (space M - ?A) = ?A›*) by auto lemma indep_events_set_one_compl: assumes "indep_events_set S" assumes "A ∈ S" shows "indep_events_set ({space M - A} ∪ (S - {A}))" proof (intro indep_events_setI (*‹⟦?E ⊆ events; ⋀J. ⟦J ⊆ ?E; finite J; J ≠ {}⟧ ⟹ prob (⋂ J) = prod prob J⟧ ⟹ indep_events_set ?E›*)) (*goals: 1. ‹{space M - A} ∪ (S - {A}) ⊆ events› 2. ‹⋀J. ⟦J ⊆ {space M - A} ∪ (S - {A}); finite J; J ≠ {}⟧ ⟹ prob (⋂ J) = prod prob J›*) show "{space M - A} ∪ (S - {A}) ⊆ events" using indep_events_set_events (*‹⟦indep_events_set ?E; ?e ∈ ?E⟧ ⟹ ?e ∈ events›*) assms(1) (*‹indep_events_set S›*) assms(2) (*‹A ∈ S›*) by auto next (*goal: ‹⋀J. ⟦J ⊆ {space M - A} ∪ (S - {A}); finite J; J ≠ {}⟧ ⟹ prob (⋂ J) = prod prob J›*) fix J assume jss: "J ⊆ {space M - A} ∪ (S - {A})" (*‹(J::'a set set) ⊆ {space (M::'a measure) - (A::'a set)} ∪ ((S::'a set set) - {A})›*) assume finJ: "finite J" (*‹finite (J::'a set set)›*) assume jne: "J ≠ {}" (*‹(J::'a set set) ≠ {}›*) show "prob (⋂J) = prod prob J" proof (cases "J - {space M - A} = {}") (*goals: 1. ‹J - {space M - A} = {} ⟹ prob (⋂ J) = prod prob J› 2. ‹J - {space M - A} ≠ {} ⟹ prob (⋂ J) = prod prob J›*) case True (*‹J - {space M - A} = {}›*) then have "J = {space M - A}" using jne (*‹J ≠ {}›*) by blast then show "?thesis" (*goal: ‹prob (⋂ J) = prod prob J›*) by simp next (*goal: ‹J - {space M - A} ≠ {} ⟹ prob (⋂ J) = prod prob J›*) case jne2: False (*‹J - {space M - A} ≠ {}›*) have jss2: "J - {space M - A} ⊆ S" using jss (*‹(J::'a::type set set) ⊆ {space (M::'a::type measure) - (A::'a::type set)} ∪ ((S::'a::type set set) - {A})›*) assms(2) (*‹(A::'a set) ∈ (S::'a set set)›*) by auto moreover have "A ∉ (J - {space M - A})" using jss (*‹(J::'a set set) ⊆ {space (M::'a measure) - (A::'a set)} ∪ ((S::'a set set) - {A})›*) by auto moreover have "finite (J - {space M - A})" using finJ (*‹finite J›*) by simp ultimately have "indep_event A (⋂ (J - {space M - A}))" using indep_events_inter_single[of S "(J - {space M - A})" A] (*‹⟦indep_events_set S; finite (J - {space M - A}); J - {space M - A} ≠ {}; A ∈ S; J - {space M - A} ⊆ S; A ∉ J - {space M - A}⟧ ⟹ indep_event A (⋂ (J - {space M - A}))›*) assms (*‹indep_events_set S› ‹A ∈ S›*) jne2 (*‹(J::'a set set) - {space (M::'a measure) - (A::'a set)} ≠ {}›*) by auto then have ie: "indep_event (space M - A) (⋂ (J - {space M - A}))" using indep_event_one_compl (*‹indep_event ?A ?B ⟹ indep_event ?A (space M - ?B)›*) indep_event_commute (*‹indep_event ?A ?B ⟹ indep_event ?B ?A›*) by auto have iess: "indep_events_set (J - {space M - A})" using jss2 (*‹J - {space M - A} ⊆ S›*) indep_events_subset2[of S "J - {space M - A}"] (*‹⟦indep_events_set S; J - {space M - A} ⊆ S⟧ ⟹ indep_events_set (J - {space M - A})›*) assms(1) (*‹indep_events_set S›*) by auto show "?thesis" (*goal: ‹prob (⋂ J) = prod prob J›*) proof (cases "space M - A ∈ J") (*goals: 1. ‹space M - A ∈ J ⟹ prob (⋂ J) = prod prob J› 2. ‹space M - A ∉ J ⟹ prob (⋂ J) = prod prob J›*) case True (*‹space (M::'a::type measure) - (A::'a::type set) ∈ (J::'a::type set set)›*) then have split: "J = (J - {space M - A}) ∪ {space M - A}" by auto then have "prob (⋂ J) = prob (⋂ ((J - {space M - A}) ∪ {space M - A}))" by simp also (*calculation: ‹prob (⋂ J) = prob (⋂ (J - {space M - A} ∪ {space M - A}))›*) have "... = prob ((⋂ (J - {space M - A})) ∩ (space M - A))" by (metis Inter_insert (*‹⋂ (insert ?a ?B) = ?a ∩ ⋂ ?B›*) True (*‹space M - A ∈ J›*) ‹J = J - {space M - A} ∪ {space M - A}› inf.commute (*‹?a ⊓ ?b = ?b ⊓ ?a›*) insert_Diff (*‹?a ∈ ?A ⟹ insert ?a (?A - {?a}) = ?A›*)) also (*calculation: ‹prob (⋂ J) = prob (⋂ (J - {space M - A}) ∩ (space M - A))›*) have "... = prob (⋂ (J - {space M - A})) * prob (space M - A)" using ie (*‹indep_event (space (M::'a measure) - (A::'a set)) (⋂ ((J::'a set set) - {space M - A}))›*) indep_eventD[of "⋂ (J - {space M - A})" "space M - A"] (*‹indep_event (⋂ (J - {space M - A})) (space M - A) ⟹ prob (⋂ (J - {space M - A}) ∩ (space M - A)) = prob (⋂ (J - {space M - A})) * prob (space M - A)›*) indep_event_commute (*‹indep_event ?A ?B ⟹ indep_event ?B ?A›*) by auto also (*calculation: ‹prob (⋂ J) = prob (⋂ (J - {space M - A})) * prob (space M - A)›*) have "... = (prod prob ((J - {space M - A}))) * prob (space M - A)" using indep_events_set_prod_all[of "J - {space M - A}"] (*‹⟦indep_events_set (J - {space M - A}); finite (J - {space M - A}); J - {space M - A} ≠ {}⟧ ⟹ prob (⋂ (J - {space M - A})) = prod prob (J - {space M - A})›*) iess (*‹indep_events_set (J - {space M - A})›*) jne2 (*‹(J::'a set set) - {space (M::'a measure) - (A::'a set)} ≠ {}›*) finJ (*‹finite J›*) by auto finally (*calculation: ‹prob (⋂ J) = prod prob (J - {space M - A}) * prob (space M - A)›*) have "prob (⋂ J) = prod prob J" using split (*‹J = J - {space M - A} ∪ {space M - A}›*) by (metis Groups.mult_ac( (*‹?a * ?b = ?b * ?a›*) 2) True (*‹space M - A ∈ J›*) finJ (*‹finite J›*) prod.remove (*‹⟦finite ?A; ?x ∈ ?A⟧ ⟹ prod ?g ?A = ?g ?x * prod ?g (?A - {?x})›*)) then show "?thesis" (*goal: ‹prob (⋂ J) = prod prob J›*) by simp next (*goal: ‹space (M::'a::type measure) - (A::'a::type set) ∉ (J::'a::type set set) ⟹ prob (⋂ J) = prod prob J›*) case False (*‹space M - A ∉ J›*) then show "?thesis" (*goal: ‹prob (⋂ J) = prod prob J›*) using iess (*‹indep_events_set (J - {space M - A})›*) by (simp add: assms( (*‹indep_events_set (S::'a set set)›*) 1) finJ (*‹finite (J::'a set set)›*) indep_events_set_prod_all (*‹⟦indep_events_set (?E::'a set set); finite ?E; ?E ≠ {}⟧ ⟹ prob (⋂ ?E) = prod prob ?E›*) jne (*‹(J::'a set set) ≠ {}›*)) qed qed qed lemma indep_events_set_update_compl: assumes "indep_events_set E" assumes "E = A ∪ B" assumes "A ∩ B = {}" assumes "finite E" shows "indep_events_set (((-) (space M) ` A) ∪ B)" using assms(2) (*‹E = A ∪ B›*) assms(3) (*‹A ∩ B = {}›*) proof (induct "card A" arbitrary: A B) (*goals: 1. ‹⋀A B. ⟦0 = card A; E = A ∪ B; A ∩ B = {}⟧ ⟹ indep_events_set ((-) (space M) ` A ∪ B)› 2. ‹⋀x A B. ⟦⋀A B. ⟦x = card A; E = A ∪ B; A ∩ B = {}⟧ ⟹ indep_events_set ((-) (space M) ` A ∪ B); Suc x = card A; E = A ∪ B; A ∩ B = {}⟧ ⟹ indep_events_set ((-) (space M) ` A ∪ B)›*) case 0 (*‹0 = card A› ‹E = A ∪ B› ‹A ∩ B = {}›*) then show "?case" (*goal: ‹indep_events_set ((-) (space M) ` A ∪ B)›*) using assms(1) (*‹indep_events_set E›*) using assms(4) (*‹finite (E::'a::type set set)›*) by auto next (*goal: ‹⋀x A B. ⟦⋀A B. ⟦x = card A; E = A ∪ B; A ∩ B = {}⟧ ⟹ indep_events_set ((-) (space M) ` A ∪ B); Suc x = card A; E = A ∪ B; A ∩ B = {}⟧ ⟹ indep_events_set ((-) (space M) ` A ∪ B)›*) case (Suc x) (*‹⟦x = card ?A12; E = ?A12 ∪ ?B12; ?A12 ∩ ?B12 = {}⟧ ⟹ indep_events_set ((-) (space M) ` ?A12 ∪ ?B12)› ‹Suc x = card A› ‹(E::'a set set) = (A::'a set set) ∪ (B::'a set set)› ‹A ∩ B = {}›*) then obtain a and A' where aeq: "A = insert a A'" and anotin: "a ∉ A'" (*goal: ‹(⋀a A'. ⟦A = insert a A'; a ∉ A'⟧ ⟹ thesis) ⟹ thesis›*) by (metis card_Suc_eq_finite (*‹(card ?A = Suc ?k) = (∃b B. ?A = insert b B ∧ b ∉ B ∧ card B = ?k ∧ finite B)›*)) then have xcard: "card A' = x" using Suc(2) (*‹Suc (x::nat) = card (A::'a set set)›*) Suc(3) (*‹E = A ∪ B›*) assms(4) (*‹finite E›*) by auto let ?B' = "B ∪ {a}" have "E = A' ∪ ?B'" using aeq (*‹A = insert a A'›*) Suc.prems (*‹E = A ∪ B› ‹(A::'a set set) ∩ (B::'a set set) = {}›*) by auto moreover have "A' ∩ ?B' = {}" using anotin (*‹a ∉ A'›*) Suc.prems(2) (*‹A ∩ B = {}›*) aeq (*‹A = insert a A'›*) by auto moreover have "?B' ≠ {}" by simp ultimately have ies: "indep_events_set ((-) (space M) ` A' ∪ ?B')" using Suc.hyps(1)[of "A'" ?B'] (*‹⟦x = card A'; E = A' ∪ (B ∪ {a}); A' ∩ (B ∪ {a}) = {}⟧ ⟹ indep_events_set ((-) (space M) ` A' ∪ (B ∪ {a}))›*) xcard (*‹card (A'::'a set set) = (x::nat)›*) by auto then have "a ∈ A ∪ B" using aeq (*‹A = insert a A'›*) by auto then show "?case" (*goal: ‹indep_events_set ((-) (space (M::'a measure)) ` (A::'a set set) ∪ (B::'a set set))›*) proof (cases "(A ∪ B) - {a} = {}") (*goals: 1. ‹⟦a ∈ A ∪ B; A ∪ B - {a} = {}⟧ ⟹ indep_events_set ((-) (space M) ` A ∪ B)› 2. ‹⟦a ∈ A ∪ B; A ∪ B - {a} ≠ {}⟧ ⟹ indep_events_set ((-) (space M) ` A ∪ B)›*) case True (*‹A ∪ B - {a} = {}›*) then have "A = {a}" "B = {}" using Suc.prems (*‹(E::'a::type set set) = (A::'a::type set set) ∪ (B::'a::type set set)› ‹A ∩ B = {}›*) aeq (*‹A = insert a A'›*) apply - (*goals: 1. ‹⟦A ∪ B - {a} = {}; E = A ∪ B; A ∩ B = {}; A = insert a A'⟧ ⟹ A = {a}› 2. ‹⟦A ∪ B - {a} = {}; E = A ∪ B; A ∩ B = {}; A = insert a A'⟧ ⟹ B = {}› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . then have "((-) (space M) ` A ∪ B) = {space M - a}" by auto moreover have "space M - a ∈ events" using aeq (*‹A = insert a A'›*) assms(1) (*‹indep_events_set E›*) Suc.prems (*‹E = A ∪ B› ‹A ∩ B = {}›*) indep_events_set_events (*‹⟦indep_events_set (?E::'a set set); (?e::'a set) ∈ ?E⟧ ⟹ ?e ∈ events›*) by auto ultimately show "?thesis" (*goal: ‹indep_events_set ((-) (space M) ` A ∪ B)›*) using indep_events_set_singleton (*‹?A ∈ events ⟹ indep_events_set {?A}›*) by simp next (*goal: ‹⟦a ∈ A ∪ B; A ∪ B - {a} ≠ {}⟧ ⟹ indep_events_set ((-) (space M) ` A ∪ B)›*) case False (*‹A ∪ B - {a} ≠ {}›*) have "a ∈ (-) (space M) ` A' ∪ ?B'" using aeq (*‹A = insert a A'›*) by auto then have ie: "indep_events_set ({space M - a} ∪ ((-) (space M) ` A' ∪ ?B' - {a}))" using indep_events_set_one_compl[of "(-) (space M) ` A' ∪ ?B'" a] (*‹⟦indep_events_set ((-) (space M) ` A' ∪ (B ∪ {a})); a ∈ (-) (space M) ` A' ∪ (B ∪ {a})⟧ ⟹ indep_events_set ({space M - a} ∪ ((-) (space M) ` A' ∪ (B ∪ {a}) - {a}))›*) ies (*‹indep_events_set ((-) (space M) ` A' ∪ (B ∪ {a}))›*) by auto show "?thesis" (*goal: ‹indep_events_set ((-) (space M) ` A ∪ B)›*) proof (cases "a ∈ (-) (space M) ` A'") (*goals: 1. ‹a ∈ (-) (space M) ` A' ⟹ indep_events_set ((-) (space M) ` A ∪ B)› 2. ‹a ∉ (-) (space M) ` A' ⟹ indep_events_set ((-) (space M) ` A ∪ B)›*) case True (*‹a ∈ (-) (space M) ` A'›*) then have "space M - a ∈ A'" by (smt (verit) ‹E = A' ∪ (B ∪ {a})› assms( (*‹indep_events_set E›*) 1) compl_identity (*‹?A ∈ events ⟹ space M - (space M - ?A) = ?A›*) image_iff (*‹(?z ∈ ?f ` ?A) = (∃x∈?A. ?z = ?f x)›*) indep_events_set_events (*‹⟦indep_events_set ?E; ?e ∈ ?E⟧ ⟹ ?e ∈ events›*) indep_events_subset2 (*‹⟦indep_events_set ?E; ?J ⊆ ?E⟧ ⟹ indep_events_set ?J›*) inf_sup_ord( (*‹?x ≤ ?x ⊔ ?y›*) 3)) then have "space M - a ∈ A" using aeq (*‹(A::'a set set) = insert (a::'a set) (A'::'a set set)›*) by auto moreover have "indep_events_set A" using Suc.prems(1) (*‹E = A ∪ B›*) indep_events_subset2 (*‹⟦indep_events_set (?E::'a set set); (?J::'a set set) ⊆ ?E⟧ ⟹ indep_events_set ?J›*) assms(1) (*‹indep_events_set (E::'a set set)›*) using aeq (*‹A = insert a A'›*) by blast moreover have "a ∈ A" using aeq (*‹A = insert a A'›*) by auto ultimately have probs: "prob a = 0 ∨ prob a = 1" using indep_events_contain_compl_prob01[of A a] (*‹⟦indep_events_set (A::'a set set); (a::'a set) ∈ A; space (M::'a measure) - a ∈ A⟧ ⟹ prob a = (0::real) ∨ prob a = (1::real)›*) by auto have "((-) (space M) ` A ∪ B) = (-) (space M) ` A' ∪ {space M - a} ∪ B" using aeq (*‹A = insert a A'›*) by auto moreover have "((-) (space M) ` A' ∪ ?B' - {a}) = ((-) (space M) ` A' - {a}) ∪ B" using Suc.prems(2) (*‹A ∩ B = {}›*) aeq (*‹A = insert a A'›*) by auto moreover have "(-) (space M) ` A' = ((-) (space M) ` A' - {a}) ∪ {a}" using True (*‹a ∈ (-) (space M) ` A'›*) by auto ultimately have "((-) (space M) ` A ∪ B) = {space M - a} ∪ ((-) (space M) ` A' ∪ ?B' - {a}) ∪ {a}" by (smt (verit) Un_empty_right (*‹?A ∪ {} = ?A›*) Un_insert_right (*‹?A ∪ insert ?a ?B = insert ?a (?A ∪ ?B)›*) Un_left_commute (*‹?A ∪ (?B ∪ ?C) = ?B ∪ (?A ∪ ?C)›*)) moreover have "a ∉ {space M - a} ∪ ((-) (space M) ` A' ∪ ?B' - {a})" using Diff_disjoint (*‹?A ∩ (?B - ?A) = {}›*) ‹space M - a ∈ A'› (*‹space (M::'a::type measure) - (a::'a::type set) ∈ (A'::'a::type set set)›*) anotin (*‹a ∉ A'›*) empty_iff (*‹(?c ∈ {}) = False›*) insert_iff (*‹(?a ∈ insert ?b ?A) = (?a = ?b ∨ ?a ∈ ?A)›*) by fastforce moreover have "a ∈ events" using Suc.prems(1) (*‹E = A ∪ B›*) assms(1) (*‹indep_events_set E›*) indep_events_set_events (*‹⟦indep_events_set ?E; ?e ∈ ?E⟧ ⟹ ?e ∈ events›*) aeq (*‹A = insert a A'›*) by auto ultimately show "?thesis" (*goal: ‹indep_events_set ((-) (space M) ` A ∪ B)›*) using ie (*‹indep_events_set ({space M - a} ∪ ((-) (space M) ` A' ∪ (B ∪ {a}) - {a}))›*) indep_events_set_prob0 (*‹⟦?A ∈ events; prob ?A = 0; ?A ∉ ?S; indep_events_set ?S⟧ ⟹ indep_events_set (?S ∪ {?A})›*) indep_events_set_prob1 (*‹⟦?A ∈ events; prob ?A = 1; ?A ∉ ?S; indep_events_set ?S⟧ ⟹ indep_events_set (?S ∪ {?A})›*) probs (*‹prob (a::'a set) = (0::real) ∨ prob a = (1::real)›*) by presburger next (*goal: ‹a ∉ (-) (space M) ` A' ⟹ indep_events_set ((-) (space M) ` A ∪ B)›*) case False (*‹a ∉ (-) (space M) ` A'›*) then have "(((-) (space M) `A' ∪ ?B') - {a}) = (-) (space M) `A' ∪ B" using Suc.prems(2) (*‹A ∩ B = {}›*) aeq (*‹A = insert a A'›*) by auto moreover have "(-) (space M) ` A = (-) (space M) ` A' ∪ {space M - a}" using aeq (*‹A = insert a A'›*) by simp ultimately have "((-) (space M) ` A ∪ B) = {space M - a} ∪ ((-) (space M) ` A' ∪ ?B' - {a})" by auto then show "?thesis" (*goal: ‹indep_events_set ((-) (space (M::'a measure)) ` (A::'a set set) ∪ (B::'a set set))›*) using ie (*‹indep_events_set ({space (M::'a measure) - (a::'a set)} ∪ ((-) (space M) ` (A'::'a set set) ∪ ((B::'a set set) ∪ {a}) - {a}))›*) by simp qed qed qed lemma indep_events_set_compl: assumes "indep_events_set E" assumes "finite E" shows "indep_events_set ((λ e. space M - e) ` E)" using indep_events_set_update_compl[of E E "{}"] (*‹⟦indep_events_set E; E = E ∪ {}; E ∩ {} = {}; finite E⟧ ⟹ indep_events_set ((-) (space M) ` E ∪ {})›*) assms (*‹indep_events_set E› ‹finite (E::'a::type set set)›*) by auto lemma indep_event_empty: assumes "A ∈ events" shows "indep_event A {}" using assms (*‹(A::'a set) ∈ events›*) indep_eventI (*‹⟦(?A::'a set) ∈ events; (?B::'a set) ∈ events; prob (?A ∩ ?B) = prob ?A * prob ?B⟧ ⟹ indep_event ?A ?B›*) by auto lemma indep_event_compl_inter: assumes "indep_event A C" assumes "B ∈ events" assumes "indep_event A (B ∩ C)" shows "indep_event A ((space M - B) ∩ C)" proof (intro indep_eventI (*‹⟦?A ∈ events; ?B ∈ events; prob (?A ∩ ?B) = prob ?A * prob ?B⟧ ⟹ indep_event ?A ?B›*)) (*goals: 1. ‹A ∈ events› 2. ‹(space M - B) ∩ C ∈ events› 3. ‹prob (A ∩ ((space M - B) ∩ C)) = prob A * prob ((space M - B) ∩ C)›*) show "A ∈ events" using assms(1) (*‹indep_event A C›*) indep_eventD_ev1 (*‹indep_event ?A ?B ⟹ ?A ∈ events›*) by auto show "(space M - B) ∩ C ∈ events" using assms(3) (*‹indep_event A (B ∩ C)›*) indep_eventD_ev2 (*‹indep_event ?A ?B ⟹ ?B ∈ events›*) by (metis Diff_Int_distrib2 (*‹(?A - ?B) ∩ ?C = ?A ∩ ?C - ?B ∩ ?C›*) assms( (*‹indep_event A C›*) 1) sets.Diff (*‹⟦?a ∈ sets ?M; ?b ∈ sets ?M⟧ ⟹ ?a - ?b ∈ sets ?M›*) sets.Int_space_eq1 (*‹?x ∈ sets ?M ⟹ space ?M ∩ ?x = ?x›*)) next (*goal: ‹prob (A ∩ ((space M - B) ∩ C)) = prob A * prob ((space M - B) ∩ C)›*) have ac: "A ∩ C ∈ events" using assms(1) (*‹indep_event A C›*) indep_eventD_ev1 (*‹indep_event (?A::'a set) (?B::'a set) ⟹ ?A ∈ events›*) indep_eventD_ev2 (*‹indep_event ?A ?B ⟹ ?B ∈ events›*) sets.Int_space_eq1 (*‹?x ∈ sets ?M ⟹ space ?M ∩ ?x = ?x›*) by auto have "prob (A ∩ ((space M - B) ∩ C)) = prob (A ∩ (space M - B) ∩ C)" by (simp add: inf_sup_aci( (*‹(?x::?'a::lattice) ⊓ (?y::?'a::lattice) ⊓ (?z::?'a::lattice) = ?x ⊓ (?y ⊓ ?z)›*) 2)) also (*calculation: ‹prob (A ∩ ((space M - B) ∩ C)) = prob (A ∩ (space M - B) ∩ C)›*) have "... = prob (A ∩ C ∩ (space M - B))" by (simp add: 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*)) also (*calculation: ‹prob (A ∩ ((space M - B) ∩ C)) = prob (A ∩ C ∩ (space M - B))›*) have "... = prob (A ∩ C) - prob (A ∩ C ∩ B)" using prob_compl_diff_inter[of "A ∩ C" "B"] (*‹⟦A ∩ C ∈ events; B ∈ events⟧ ⟹ prob (A ∩ C ∩ (space M - B)) = prob (A ∩ C) - prob (A ∩ C ∩ B)›*) ac (*‹A ∩ C ∈ events›*) assms(2) (*‹B ∈ events›*) by auto also (*calculation: ‹prob ((A::'a set) ∩ ((space (M::'a measure) - (B::'a set)) ∩ (C::'a set))) = prob (A ∩ C) - prob (A ∩ C ∩ B)›*) have "... = prob (A) * prob C - (prob A * prob (C ∩ B))" using assms(1) (*‹indep_event A C›*) assms(3) (*‹indep_event (A::'a::type set) ((B::'a::type set) ∩ (C::'a::type set))›*) indep_eventD (*‹indep_event ?A ?B ⟹ prob (?A ∩ ?B) = prob ?A * prob ?B›*) by (simp add: inf_commute (*‹?x ⊓ ?y = ?y ⊓ ?x›*) inf_left_commute (*‹?x ⊓ (?y ⊓ ?z) = ?y ⊓ (?x ⊓ ?z)›*)) also (*calculation: ‹prob (A ∩ ((space M - B) ∩ C)) = prob A * prob C - prob A * prob (C ∩ B)›*) have "... = prob A * (prob C - prob (C ∩ 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*)) finally (*calculation: ‹prob (A ∩ ((space M - B) ∩ C)) = prob A * (prob C - prob (C ∩ B))›*) have "prob (A ∩ ((space M - B) ∩ C)) = prob A * (prob (C ∩ (space M - B)))" using prob_compl_diff_inter[of "C" "B"] (*‹⟦C ∈ events; B ∈ events⟧ ⟹ prob (C ∩ (space M - B)) = prob C - prob (C ∩ B)›*) using assms(1) (*‹indep_event A C›*) assms(2) (*‹B ∈ events›*) by (simp add: indep_eventD_ev2 (*‹indep_event ?A ?B ⟹ ?B ∈ events›*)) then show "prob (A ∩ ((space M - B) ∩ C)) = prob A * prob ((space M - B) ∩ C)" by (simp add: 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*)) qed (* Indep events indexed lemmas *) lemma indep_events_index_subset: "indep_events F E ⟷ (∀J⊆E. indep_events F J)" unfolding indep_events_def (*goal: ‹(F ` E ⊆ events ∧ (∀J⊆E. J ≠ {} ⟶ finite J ⟶ prob (⋂ (F ` J)) = (∏j∈J. prob (F j)))) = (∀J⊆E. F ` J ⊆ events ∧ (∀Ja⊆J. Ja ≠ {} ⟶ finite Ja ⟶ prob (⋂ (F ` Ja)) = (∏j∈Ja. prob (F j))))›*) by (meson image_mono (*‹(?A::?'a::type set) ⊆ (?B::?'a::type set) ⟹ (?f::?'a::type ⇒ ?'b::type) ` ?A ⊆ ?f ` ?B›*) set_eq_subset (*‹((?A::?'a::type set) = (?B::?'a::type set)) = (?A ⊆ ?B ∧ ?B ⊆ ?A)›*) subset_trans (*‹⟦(?A::?'a::type set) ⊆ (?B::?'a::type set); ?B ⊆ (?C::?'a::type set)⟧ ⟹ ?A ⊆ ?C›*)) lemma indep_events_index_subset2: "indep_events F E ⟹ J ⊆ E ⟹ indep_events F J" using indep_events_index_subset (*‹indep_events (?F::?'b::type ⇒ 'a::type set) (?E::?'b::type set) = (∀J⊆?E. indep_events ?F J)›*) by auto lemma indep_events_events_ss: "indep_events F E ⟹ F ` E ⊆ events" unfolding indep_events_def (*goal: ‹F ` E ⊆ events ∧ (∀J⊆E. J ≠ {} ⟶ finite J ⟶ prob (⋂ (F ` J)) = (∏j∈J. prob (F j))) ⟹ F ` E ⊆ events›*) by auto lemma indep_events_events: "indep_events F E ⟹ (⋀e. e ∈ E ⟹ F e ∈ events)" using indep_events_events_ss (*‹indep_events (?F::?'b ⇒ 'a set) (?E::?'b set) ⟹ ?F ` ?E ⊆ events›*) by auto lemma indep_events_probs: "indep_events F E ⟹ J ⊆ E ⟹ finite J ⟹ J ≠ {} ⟹ prob (⋂(F ` J)) = (∏i∈J. prob (F i))" unfolding indep_events_def (*goal: ‹⟦F ` E ⊆ events ∧ (∀J⊆E. J ≠ {} ⟶ finite J ⟶ prob (⋂ (F ` J)) = (∏j∈J. prob (F j))); J ⊆ E; finite J; J ≠ {}⟧ ⟹ prob (⋂ (F ` J)) = (∏i∈J. prob (F i))›*) by auto lemma indep_events_prod_all: "indep_events F E ⟹ finite E ⟹ E ≠ {} ⟹ prob (⋂(F ` E)) = (∏i∈E. prob (F i))" using indep_events_probs (*‹⟦indep_events ?F ?E; ?J ⊆ ?E; finite ?J; ?J ≠ {}⟧ ⟹ prob (⋂ (?F ` ?J)) = (∏i∈?J. prob (?F i))›*) by auto lemma indep_events_ev_not_contain_compl: assumes "indep_events F E" assumes "A ∈ E" assumes "prob (F A) > 0" "prob (F A) < 1" shows "(space M - F A) ∉ F ` E" (is "?A' ∉ F ` E") proof (rule ccontr (*‹(¬ (?P::bool) ⟹ False) ⟹ ?P›*)) (*goal: ‹¬ space M - F A ∉ F ` E ⟹ False›*) assume "¬ ?A' ∉ F ` E" (*‹¬ space (M::'a measure) - (F::'b ⇒ 'a set) (A::'b) ∉ F ` (E::'b set)›*) then have "?A' ∈ F ` E" by auto then obtain Ae where aeq: "?A' = F Ae" and "Ae ∈ E" (*goal: ‹(⋀Ae. ⟦space M - F A = F Ae; Ae ∈ E⟧ ⟹ thesis) ⟹ thesis›*) by blast then have "{A, Ae} ⊆ E" using assms(2) (*‹A ∈ E›*) by auto moreover have "finite {A, Ae}" by simp moreover have "{A, Ae} ≠ {}" by simp ultimately have "prob (⋂i∈{A, Ae}. F i) = (∏i∈{A, Ae}. prob (F i))" using indep_events_probs[of F E "{A, Ae}"] (*‹⟦indep_events F E; {A, Ae} ⊆ E; finite {A, Ae}; {A, Ae} ≠ {}⟧ ⟹ prob (⋂ (F ` {A, Ae})) = (∏i∈{A, Ae}. prob (F i))›*) assms(1) (*‹indep_events F E›*) by auto moreover have "A ≠ Ae" using subprob_not_empty (*‹space M ≠ {}›*) using aeq (*‹space M - F A = F Ae›*) by auto ultimately have "prob (F A ∩ ?A') = prob (F A) * prob (?A')" using aeq (*‹space M - F A = F Ae›*) by simp moreover have "prob (F A ∩ ?A') = 0" by simp moreover have "prob (F A) * prob ?A' = prob (F A) * (1 - prob (F A))" using assms(1) (*‹indep_events F E›*) assms(2) (*‹A ∈ E›*) indep_events_events (*‹⟦indep_events (?F::?'b ⇒ 'a set) (?E::?'b set); (?e::?'b) ∈ ?E⟧ ⟹ ?F ?e ∈ events›*) prob_compl (*‹?A ∈ events ⟹ prob (space M - ?A) = 1 - prob ?A›*) by metis moreover have "prob (F A) * (1 - prob (F A)) > 0" using assms(3) (*‹0 < prob (F A)›*) assms(4) (*‹prob (F A) < 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*)) ultimately show False by auto qed lemma indep_events_singleton: assumes "F A ∈ events" shows "indep_events F {A}" proof (intro indep_eventsI (*‹⟦⋀i. i ∈ ?I ⟹ ?F i ∈ events; ⋀J. ⟦J ⊆ ?I; finite J; J ≠ {}⟧ ⟹ prob (⋂ (?F ` J)) = (∏i∈J. prob (?F i))⟧ ⟹ indep_events ?F ?I›*)) (*goals: 1. ‹⋀i. i ∈ {A} ⟹ F i ∈ events› 2. ‹⋀J. ⟦J ⊆ {A}; finite J; J ≠ {}⟧ ⟹ prob (⋂ (F ` J)) = (∏i∈J. prob (F i))›*) show "⋀i. i ∈ {A} ⟹ F i ∈ events" using assms (*‹F A ∈ events›*) by simp next (*goal: ‹⋀J. ⟦J ⊆ {A}; finite J; J ≠ {}⟧ ⟹ prob (⋂ (F ` J)) = (∏i∈J. prob (F i))›*) fix J assume "J ⊆ {A}" "finite J" "J ≠ {}" (*‹(J::'b set) ⊆ {A::'b}› ‹finite (J::'b set)› ‹(J::'b set) ≠ {}›*) then have "J = {A}" by auto then show "prob (⋂ (F ` J)) = (∏i∈J. prob (F i))" by simp qed lemma indep_events_ev_pairs: assumes "indep_events F S" assumes "A ∈ S" "B ∈ S" "A ≠ B" shows "indep_event (F A) (F B)" using assms (*‹indep_events F S› ‹A ∈ S› ‹B ∈ S› ‹(A::'b::type) ≠ (B::'b::type)›*) indep_events_probs[of F "S" "{A, B}"] (*‹⟦indep_events F S; {A, B} ⊆ S; finite {A, B}; {A, B} ≠ {}⟧ ⟹ prob (⋂ (F ` {A, B})) = (∏i∈{A, B}. prob (F i))›*) apply (intro indep_eventI (*‹⟦(?A::'a set) ∈ events; (?B::'a set) ∈ events; prob (?A ∩ ?B) = prob ?A * prob ?B⟧ ⟹ indep_event ?A ?B›*)) (*goals: 1. ‹⟦indep_events F S; A ∈ S; B ∈ S; A ≠ B; ⟦indep_events F S; {A, B} ⊆ S; finite {A, B}; {A, B} ≠ {}⟧ ⟹ prob (⋂ (F ` {A, B})) = (∏i∈{A, B}. prob (F i))⟧ ⟹ F A ∈ events› 2. ‹⟦indep_events F S; A ∈ S; B ∈ S; A ≠ B; ⟦indep_events F S; {A, B} ⊆ S; finite {A, B}; {A, B} ≠ {}⟧ ⟹ prob (⋂ (F ` {A, B})) = (∏i∈{A, B}. prob (F i))⟧ ⟹ F B ∈ events› 3. ‹⟦indep_events F S; A ∈ S; B ∈ S; A ≠ B; ⟦indep_events F S; {A, B} ⊆ S; finite {A, B}; {A, B} ≠ {}⟧ ⟹ prob (⋂ (F ` {A, B})) = (∏i∈{A, B}. prob (F i))⟧ ⟹ prob (F A ∩ F B) = prob (F A) * prob (F B)› discuss goal 1*) apply (simp add: indep_events_events (*‹⟦indep_events ?F ?E; ?e ∈ ?E⟧ ⟹ ?F ?e ∈ events›*)) (*discuss goal 2*) apply (simp add: indep_events_events (*‹⟦indep_events ?F ?E; ?e ∈ ?E⟧ ⟹ ?F ?e ∈ events›*)) (*discuss goal 3*) apply (simp add: indep_events_events (*‹⟦indep_events ?F ?E; ?e ∈ ?E⟧ ⟹ ?F ?e ∈ events›*)) (*proven 3 subgoals*) . lemma indep_events_ev_inter_pairs: assumes "indep_events F S" assumes "finite A" "finite B" assumes "A ≠ {}" "B ≠ {}" assumes "A ⊆ S" "B ⊆ S" "A ∩ B = {}" shows "indep_event (⋂(F ` A)) (⋂(F ` B))" proof (intro indep_eventI (*‹⟦?A ∈ events; ?B ∈ events; prob (?A ∩ ?B) = prob ?A * prob ?B⟧ ⟹ indep_event ?A ?B›*)) (*goals: 1. ‹⋂ (F ` A) ∈ events› 2. ‹⋂ (F ` B) ∈ events› 3. ‹prob (⋂ (F ` A) ∩ ⋂ (F ` B)) = prob (⋂ (F ` A)) * prob (⋂ (F ` B))›*) have "(F ` A) ⊆ events" "(F ` B) ⊆ events" using indep_events_events (*‹⟦indep_events (?F::?'b ⇒ 'a set) (?E::?'b set); (?e::?'b) ∈ ?E⟧ ⟹ ?F ?e ∈ events›*) assms(1) (*‹indep_events F S›*) assms(6) (*‹A ⊆ S›*) assms(7) (*‹(B::'b set) ⊆ (S::'b set)›*) apply - (*goals: 1. ‹⟦⋀F E e. ⟦indep_events F E; e ∈ E⟧ ⟹ F e ∈ events; indep_events F S; A ⊆ S; B ⊆ S⟧ ⟹ F ` A ⊆ events› 2. ‹⟦⋀F E e. ⟦indep_events F E; e ∈ E⟧ ⟹ F e ∈ events; indep_events F S; A ⊆ S; B ⊆ S⟧ ⟹ F ` B ⊆ events› discuss goal 1*) apply fast (*discuss goal 2*) apply fast (*proven 2 subgoals*) . then show "⋂ (F ` A) ∈ events" "⋂ (F `B) ∈ events" using Inter_event_ss (*‹⟦finite ?A; ?A ⊆ events; ?A ≠ {}⟧ ⟹ ⋂ ?A ∈ events›*) assms (*‹indep_events F S› ‹finite A› ‹finite B› ‹(A::'b::type set) ≠ {}› ‹B ≠ {}› ‹A ⊆ S› ‹(B::'b set) ⊆ (S::'b set)› ‹(A::'b set) ∩ (B::'b set) = {}›*) apply - (*goals: 1. ‹⟦(F::'b::type ⇒ 'a::type set) ` (A::'b::type set) ⊆ events; F ` (B::'b::type set) ⊆ events; ⋀A::'a::type set set. ⟦finite A; A ⊆ events; A ≠ {}⟧ ⟹ ⋂ A ∈ events; indep_events F (S::'b::type set); finite A; finite B; A ≠ {}; B ≠ {}; A ⊆ S; B ⊆ S; A ∩ B = {}⟧ ⟹ ⋂ (F ` A) ∈ events› 2. ‹⟦(F::'b::type ⇒ 'a::type set) ` (A::'b::type set) ⊆ events; F ` (B::'b::type set) ⊆ events; ⋀A::'a::type set set. ⟦finite A; A ⊆ events; A ≠ {}⟧ ⟹ ⋂ A ∈ events; indep_events F (S::'b::type set); finite A; finite B; A ≠ {}; B ≠ {}; A ⊆ S; B ⊆ S; A ∩ B = {}⟧ ⟹ ⋂ (F ` B) ∈ events› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . next (*goal: ‹prob (⋂ (F ` A) ∩ ⋂ (F ` B)) = prob (⋂ (F ` A)) * prob (⋂ (F ` B))›*) have "A ∪ B ⊆ S" using assms (*‹indep_events (F::'b::type ⇒ 'a::type set) (S::'b::type set)› ‹finite A› ‹finite B› ‹A ≠ {}› ‹B ≠ {}› ‹A ⊆ S› ‹B ⊆ S› ‹(A::'b::type set) ∩ (B::'b::type set) = {}›*) by auto moreover have "finite (A ∪ B)" using assms(2) (*‹finite (A::'b set)›*) assms(3) (*‹finite B›*) by simp moreover have "A ∪ B ≠ {}" using assms (*‹indep_events F S› ‹finite A› ‹finite B› ‹(A::'b set) ≠ {}› ‹B ≠ {}› ‹A ⊆ S› ‹B ⊆ S› ‹A ∩ B = {}›*) by simp ultimately have "prob (⋂(F `(A ∪ B))) = (∏i∈A ∪ B. prob (F i))" using assms (*‹indep_events F S› ‹finite (A::'b set)› ‹finite B› ‹A ≠ {}› ‹(B::'b set) ≠ {}› ‹A ⊆ S› ‹B ⊆ S› ‹(A::'b set) ∩ (B::'b set) = {}›*) using indep_events_probs[of F S "A ∪ B"] (*‹⟦indep_events (F::'b ⇒ 'a set) (S::'b set); (A::'b set) ∪ (B::'b set) ⊆ S; finite (A ∪ B); A ∪ B ≠ {}⟧ ⟹ prob (⋂ (F ` (A ∪ B))) = (∏i::'b∈A ∪ B. prob (F i))›*) by simp also (*calculation: ‹prob (⋂ (F ` (A ∪ B))) = (∏i∈A ∪ B. prob (F i))›*) have "... = (∏i∈A. prob (F i)) * (∏i∈B. prob (F i))" using assms(8) (*‹A ∩ B = {}›*) prod.union_disjoint[of A B "λ i. prob (F i)"] (*‹⟦finite A; finite B; A ∩ B = {}⟧ ⟹ (∏i∈A ∪ B. prob (F i)) = (∏i∈A. prob (F i)) * (∏i∈B. prob (F i))›*) assms(2) (*‹finite (A::'b set)›*) assms(3) (*‹finite B›*) by simp finally (*calculation: ‹prob (⋂ (F ` (A ∪ B))) = (∏i∈A. prob (F i)) * (∏i∈B. prob (F i))›*) have "prob (⋂(F `(A ∪ B))) = prob (⋂ (F ` A)) * prob (⋂ (F ` B))" using assms (*‹indep_events F S› ‹finite (A::'b::type set)› ‹finite B› ‹A ≠ {}› ‹(B::'b::type set) ≠ {}› ‹A ⊆ S› ‹B ⊆ S› ‹(A::'b set) ∩ (B::'b set) = {}›*) indep_events_index_subset (*‹indep_events (?F::?'b ⇒ 'a set) (?E::?'b set) = (∀J⊆?E. indep_events ?F J)›*) indep_events_prod_all (*‹⟦indep_events ?F ?E; finite ?E; ?E ≠ {}⟧ ⟹ prob (⋂ (?F ` ?E)) = (∏i∈?E. prob (?F i))›*) by metis moreover have "⋂ (F ` (A ∪ B)) = (⋂ (F ` A)) ∩ ⋂ (F ` B)" by auto ultimately show "prob (⋂ (F ` A) ∩ ⋂ (F ` B)) = prob (⋂ (F ` A)) * prob (⋂ (F ` B))" by simp qed lemma indep_events_ev_inter_single: assumes "indep_events F S" assumes "finite B" assumes "B ≠ {}" assumes "A ∈ S" "B ⊆ S" "A ∉ B" shows "indep_event (F A) (⋂(F ` B))" proof (-) (*goal: ‹indep_event (F A) (⋂ (F ` B))›*) have "{A} ≠ {}" "finite {A}" "{A} ⊆ S" using assms (*‹indep_events F S› ‹finite B› ‹B ≠ {}› ‹A ∈ S› ‹B ⊆ S› ‹A ∉ B›*) apply - (*goals: 1. ‹⟦indep_events F S; finite B; B ≠ {}; A ∈ S; B ⊆ S; A ∉ B⟧ ⟹ {A} ≠ {}› 2. ‹⟦indep_events F S; finite B; B ≠ {}; A ∈ S; B ⊆ S; A ∉ B⟧ ⟹ finite {A}› 3. ‹⟦indep_events F S; finite B; B ≠ {}; A ∈ S; B ⊆ S; A ∉ B⟧ ⟹ {A} ⊆ S› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*discuss goal 3*) apply simp (*proven 3 subgoals*) . moreover have "{A} ∩ B = {}" using assms(6) (*‹A ∉ B›*) by auto ultimately show "?thesis" (*goal: ‹indep_event (F A) (⋂ (F ` B))›*) using indep_events_ev_inter_pairs[of F S "{A}" B] (*‹⟦indep_events F S; finite {A}; finite B; {A} ≠ {}; B ≠ {}; {A} ⊆ S; B ⊆ S; {A} ∩ B = {}⟧ ⟹ indep_event (⋂ (F ` {A})) (⋂ (F ` B))›*) assms (*‹indep_events F S› ‹finite B› ‹B ≠ {}› ‹A ∈ S› ‹B ⊆ S› ‹A ∉ B›*) by auto qed lemma indep_events_fn_eq: assumes "⋀ Ai. Ai ∈ E ⟹ F Ai = G Ai" assumes "indep_events F E" shows "indep_events G E" proof (intro indep_eventsI (*‹⟦⋀i. i ∈ ?I ⟹ ?F i ∈ events; ⋀J. ⟦J ⊆ ?I; finite J; J ≠ {}⟧ ⟹ prob (⋂ (?F ` J)) = (∏i∈J. prob (?F i))⟧ ⟹ indep_events ?F ?I›*)) (*goals: 1. ‹⋀i. i ∈ E ⟹ G i ∈ events› 2. ‹⋀J. ⟦J ⊆ E; finite J; J ≠ {}⟧ ⟹ prob (⋂ (G ` J)) = (∏i∈J. prob (G i))›*) show "⋀i. i ∈ E ⟹ G i ∈ events" using assms(2) (*‹indep_events F E›*) indep_events_events (*‹⟦indep_events ?F ?E; ?e ∈ ?E⟧ ⟹ ?F ?e ∈ events›*) assms(1) (*‹(?Ai12::'b) ∈ (E::'b set) ⟹ (F::'b ⇒ 'a set) ?Ai12 = (G::'b ⇒ 'a set) ?Ai12›*) by metis next (*goal: ‹⋀J::'b set. ⟦J ⊆ (E::'b set); finite J; J ≠ {}⟧ ⟹ prob (⋂ ((G::'b ⇒ 'a set) ` J)) = (∏i::'b∈J. prob (G i))›*) fix J assume jss: "J ⊆ E" "finite J" "J ≠ {}" (*‹(J::'b set) ⊆ (E::'b set)› ‹finite (J::'b set)› ‹(J::'b set) ≠ {}›*) moreover have "G ` J = F ` J" using assms(1) (*‹?Ai12 ∈ E ⟹ F ?Ai12 = G ?Ai12›*) calculation(1) (*‹(J::'b set) ⊆ (E::'b set)›*) by auto moreover have "⋀ i . i ∈ J ⟹ prob (G i) = prob (F i)" using jss (*‹J ⊆ E› ‹finite (J::'b::type set)› ‹J ≠ {}›*) assms(1) (*‹?Ai12 ∈ E ⟹ F ?Ai12 = G ?Ai12›*) by auto moreover have "(∏i∈J. prob (F i)) = (∏i∈J. prob (G i))" using calculation(5) (*‹?i12 ∈ J ⟹ prob (G ?i12) = prob (F ?i12)›*) by auto ultimately show "prob (⋂ (G ` J)) = (∏i∈J. prob (G i))" using assms(2) (*‹indep_events F E›*) indep_events_probs[of F E J] (*‹⟦indep_events F E; J ⊆ E; finite J; J ≠ {}⟧ ⟹ prob (⋂ (F ` J)) = (∏i∈J. prob (F i))›*) by simp qed lemma indep_events_fn_eq_iff: assumes "⋀ Ai. Ai ∈ E ⟹ F Ai = G Ai" shows "indep_events F E ⟷ indep_events G E" using indep_events_fn_eq (*‹⟦⋀Ai::?'b::type. Ai ∈ (?E::?'b::type set) ⟹ (?F::?'b::type ⇒ 'a::type set) Ai = (?G::?'b::type ⇒ 'a::type set) Ai; indep_events ?F ?E⟧ ⟹ indep_events ?G ?E›*) assms (*‹(?Ai12::'b) ∈ (E::'b set) ⟹ (F::'b ⇒ 'a set) ?Ai12 = (G::'b ⇒ 'a set) ?Ai12›*) by auto lemma indep_events_one_compl: assumes "indep_events F S" assumes "A ∈ S" shows "indep_events (λ i. if (i = A) then (space M - F i) else F i) S" (is "indep_events ?G S") proof (intro indep_eventsI (*‹⟦⋀i. i ∈ ?I ⟹ ?F i ∈ events; ⋀J. ⟦J ⊆ ?I; finite J; J ≠ {}⟧ ⟹ prob (⋂ (?F ` J)) = (∏i∈J. prob (?F i))⟧ ⟹ indep_events ?F ?I›*)) (*goals: 1. ‹⋀i. i ∈ S ⟹ (if i = A then space M - F i else F i) ∈ events› 2. ‹⋀J. ⟦J ⊆ S; finite J; J ≠ {}⟧ ⟹ prob (⋂i∈J. if i = A then space M - F i else F i) = (∏i∈J. prob (if i = A then space M - F i else F i))›*) show "⋀i. i ∈ S ⟹ (if i = A then space M - F i else F i) ∈ events" using indep_events_events (*‹⟦indep_events (?F::?'b ⇒ 'a set) (?E::?'b set); (?e::?'b) ∈ ?E⟧ ⟹ ?F ?e ∈ events›*) assms(1) (*‹indep_events F S›*) assms(2) (*‹A ∈ S›*) by (metis sets.compl_sets (*‹?a ∈ sets ?M ⟹ space ?M - ?a ∈ sets ?M›*)) next (*goal: ‹⋀J::'b set. ⟦J ⊆ (S::'b set); finite J; J ≠ {}⟧ ⟹ prob (⋂i::'b∈J. if i = (A::'b) then space (M::'a measure) - (F::'b ⇒ 'a set) i else F i) = (∏i::'b∈J. prob (if i = A then space M - F i else F i))›*) define G where "G ≡?G" fix J assume jss: "J ⊆ S" (*‹(J::'b set) ⊆ (S::'b set)›*) assume finJ: "finite J" (*‹finite (J::'b set)›*) assume jne: "J ≠ {}" (*‹(J::'b set) ≠ {}›*) show "prob (⋂i∈J. ?G i) = (∏i∈J. prob (?G i))" proof (cases "J = {A}") (*goals: 1. ‹J = {A} ⟹ prob (⋂i∈J. if i = A then space M - F i else F i) = (∏i∈J. prob (if i = A then space M - F i else F i))› 2. ‹J ≠ {A} ⟹ prob (⋂i∈J. if i = A then space M - F i else F i) = (∏i∈J. prob (if i = A then space M - F i else F i))›*) case True (*‹(J::'b set) = {A::'b}›*) then show "?thesis" (*goal: ‹prob (⋂i∈J. if i = A then space M - F i else F i) = (∏i∈J. prob (if i = A then space M - F i else F i))›*) by simp next (*goal: ‹(J::'b set) ≠ {A::'b} ⟹ prob (⋂i::'b∈J. if i = A then space (M::'a measure) - (F::'b ⇒ 'a set) i else F i) = (∏i::'b∈J. prob (if i = A then space M - F i else F i))›*) case jne2: False (*‹J ≠ {A}›*) have jss2: "J - {A} ⊆ S" using jss (*‹(J::'b set) ⊆ (S::'b set)›*) assms(2) (*‹A ∈ S›*) by auto moreover have "A ∉ (J - {A})" using jss (*‹J ⊆ S›*) by auto moreover have "finite (J - {A})" using finJ (*‹finite J›*) by simp moreover have "J - {A} ≠ {}" using jne2 (*‹J ≠ {A}›*) jne (*‹J ≠ {}›*) by auto ultimately have "indep_event (F A) (⋂ (F ` (J - {A})))" using indep_events_ev_inter_single[of F S "(J - {A})" A] (*‹⟦indep_events F S; finite (J - {A}); J - {A} ≠ {}; A ∈ S; J - {A} ⊆ S; A ∉ J - {A}⟧ ⟹ indep_event (F A) (⋂ (F ` (J - {A})))›*) assms (*‹indep_events (F::'b ⇒ 'a set) (S::'b set)› ‹A ∈ S›*) by auto then have ie: "indep_event (G A) (⋂ (G ` (J - {A})))" using indep_event_one_compl (*‹indep_event ?A ?B ⟹ indep_event ?A (space M - ?B)›*) indep_event_commute (*‹indep_event (?A::'a set) (?B::'a set) ⟹ indep_event ?B ?A›*) G_def (*‹G ≡ λi. if i = A then space M - F i else F i›*) by auto have iess: "indep_events G (J - {A})" using jss2 (*‹J - {A} ⊆ S›*) G_def (*‹G ≡ λi. if i = A then space M - F i else F i›*) indep_events_index_subset2[of F S "J - {A}"] (*‹⟦indep_events F S; J - {A} ⊆ S⟧ ⟹ indep_events F (J - {A})›*) assms(1) (*‹indep_events F S›*) indep_events_fn_eq[of "J - {A}"] (*‹⟦⋀Ai. Ai ∈ J - {A} ⟹ ?F Ai = ?G Ai; indep_events ?F (J - {A})⟧ ⟹ indep_events ?G (J - {A})›*) by auto show "?thesis" (*goal: ‹prob (⋂i∈J. if i = A then space M - F i else F i) = (∏i∈J. prob (if i = A then space M - F i else F i))›*) proof (cases "A ∈ J") (*goals: 1. ‹A ∈ J ⟹ prob (⋂i∈J. if i = A then space M - F i else F i) = (∏i∈J. prob (if i = A then space M - F i else F i))› 2. ‹A ∉ J ⟹ prob (⋂i∈J. if i = A then space M - F i else F i) = (∏i∈J. prob (if i = A then space M - F i else F i))›*) case True (*‹A ∈ J›*) then have split: "G ` J = insert (G A) (G ` (J - {A}))" by auto then have "prob (⋂ (G ` J)) = prob (⋂ (insert (G A) (G ` (J - {A}))))" by auto also (*calculation: ‹prob (⋂ (G ` J)) = prob (⋂ (insert (G A) (G ` (J - {A}))))›*) have "... = prob ((G A)∩ ⋂ (G ` (J - {A})) )" using Inter_insert (*‹⋂ (insert ?a ?B) = ?a ∩ ⋂ ?B›*) by simp also (*calculation: ‹prob (⋂ (G ` J)) = prob (G A ∩ ⋂ (G ` (J - {A})))›*) have "... = prob (G A) * prob (⋂ (G ` (J - {A})))" using ie (*‹indep_event ((G::'b ⇒ 'a set) (A::'b)) (⋂ (G ` ((J::'b set) - {A})))›*) indep_eventD[of "G A" "⋂ (G ` (J - {A}))"] (*‹indep_event (G A) (⋂ (G ` (J - {A}))) ⟹ prob (G A ∩ ⋂ (G ` (J - {A}))) = prob (G A) * prob (⋂ (G ` (J - {A})))›*) by auto also (*calculation: ‹prob (⋂ (G ` J)) = prob (G A) * prob (⋂ (G ` (J - {A})))›*) have "... = prob (G A) * (∏i ∈ (J - {A}). prob (G i)) " using indep_events_prod_all[of G "J - {A}"] (*‹⟦indep_events G (J - {A}); finite (J - {A}); J - {A} ≠ {}⟧ ⟹ prob (⋂ (G ` (J - {A}))) = (∏i∈J - {A}. prob (G i))›*) iess (*‹indep_events G (J - {A})›*) jne2 (*‹J ≠ {A}›*) jne (*‹J ≠ {}›*) finJ (*‹finite J›*) by auto finally (*calculation: ‹prob (⋂ (G ` J)) = prob (G A) * (∏i∈J - {A}. prob (G i))›*) have "prob (⋂ (G ` J)) = (∏i ∈ J. prob (G i))" using split (*‹G ` J = insert (G A) (G ` (J - {A}))›*) by (metis True (*‹A ∈ J›*) finJ (*‹finite J›*) prod.remove (*‹⟦finite ?A; ?x ∈ ?A⟧ ⟹ prod ?g ?A = ?g ?x * prod ?g (?A - {?x})›*)) then show "?thesis" (*goal: ‹prob (⋂i∈J. if i = A then space M - F i else F i) = (∏i∈J. prob (if i = A then space M - F i else F i))›*) using G_def (*‹G ≡ λi. if i = A then space M - F i else F i›*) by simp next (*goal: ‹A ∉ J ⟹ prob (⋂i∈J. if i = A then space M - F i else F i) = (∏i∈J. prob (if i = A then space M - F i else F i))›*) case False (*‹A ∉ J›*) then have "prob (⋂i∈J. G i) = (∏i∈J. prob (G i))" using iess (*‹indep_events G (J - {A})›*) by (simp add: assms( (*‹indep_events F S›*) 1) finJ (*‹finite J›*) indep_events_prod_all (*‹⟦indep_events ?F ?E; finite ?E; ?E ≠ {}⟧ ⟹ prob (⋂ (?F ` ?E)) = (∏i∈?E. prob (?F i))›*) jne (*‹J ≠ {}›*)) then show "?thesis" (*goal: ‹prob (⋂i∈J. if i = A then space M - F i else F i) = (∏i∈J. prob (if i = A then space M - F i else F i))›*) using G_def (*‹G::'b::type ⇒ 'a::type set ≡ λi::'b::type. if i = (A::'b::type) then space (M::'a::type measure) - (F::'b::type ⇒ 'a::type set) i else F i›*) by simp qed qed qed lemma indep_events_update_compl: assumes "indep_events F E" assumes "E = A ∪ B" assumes "A ∩ B = {}" assumes "finite E" shows "indep_events (λ Ai. if (Ai ∈ A) then (space M - (F Ai)) else (F Ai)) E" using assms(2) (*‹E = A ∪ B›*) assms(3) (*‹A ∩ B = {}›*) proof (induct "card A" arbitrary: A B) (*goals: 1. ‹⋀(A::'b set) B::'b set. ⟦(0::nat) = card A; (E::'b set) = A ∪ B; A ∩ B = {}⟧ ⟹ indep_events (λAi::'b. if Ai ∈ A then space (M::'a measure) - (F::'b ⇒ 'a set) Ai else F Ai) E› 2. ‹⋀(x::nat) (A::'b set) B::'b set. ⟦⋀(A::'b set) B::'b set. ⟦x = card A; (E::'b set) = A ∪ B; A ∩ B = {}⟧ ⟹ indep_events (λAi::'b. if Ai ∈ A then space (M::'a measure) - (F::'b ⇒ 'a set) Ai else F Ai) E; Suc x = card A; E = A ∪ B; A ∩ B = {}⟧ ⟹ indep_events (λAi::'b. if Ai ∈ A then space M - F Ai else F Ai) E›*) case 0 (*‹0 = card A› ‹E = A ∪ B› ‹A ∩ B = {}›*) let ?G = "(λAi. if Ai ∈ A then space M - F Ai else F Ai)" have "E = B" using assms(4) (*‹finite E›*) ‹E = A ∪ B› (*‹E = A ∪ B›*) ‹0 = card A› (*‹0 = card A›*) by simp then have "⋀ i. i ∈ E ⟹ F i = ?G i" using ‹A ∩ B = {}› (*‹A ∩ B = {}›*) by auto then show "?case" (*goal: ‹indep_events (λAi. if Ai ∈ A then space M - F Ai else F Ai) E›*) using assms(1) (*‹indep_events F E›*) indep_events_fn_eq[of E F ?G] (*‹⟦⋀Ai. Ai ∈ E ⟹ F Ai = (if Ai ∈ A then space M - F Ai else F Ai); indep_events F E⟧ ⟹ indep_events (λAi. if Ai ∈ A then space M - F Ai else F Ai) E›*) by simp next (*goal: ‹⋀x A B. ⟦⋀A B. ⟦x = card A; E = A ∪ B; A ∩ B = {}⟧ ⟹ indep_events (λAi. if Ai ∈ A then space M - F Ai else F Ai) E; Suc x = card A; E = A ∪ B; A ∩ B = {}⟧ ⟹ indep_events (λAi. if Ai ∈ A then space M - F Ai else F Ai) E›*) case (Suc x) (*‹⟦x = card ?A12; E = ?A12 ∪ ?B12; ?A12 ∩ ?B12 = {}⟧ ⟹ indep_events (λAi. if Ai ∈ ?A12 then space M - F Ai else F Ai) E› ‹Suc x = card A› ‹E = A ∪ B› ‹A ∩ B = {}›*) define G where "G ≡ (λAi. if Ai ∈ A then space M - F Ai else F Ai)" obtain a and A' where aeq: "A = insert a A'" and anotin: "a ∉ A'" (*goal: ‹(⋀a A'. ⟦A = insert a A'; a ∉ A'⟧ ⟹ thesis) ⟹ thesis›*) using Suc.hyps (*‹⟦x = card ?A12; E = ?A12 ∪ ?B12; ?A12 ∩ ?B12 = {}⟧ ⟹ indep_events (λAi. if Ai ∈ ?A12 then space M - F Ai else F Ai) E› ‹Suc x = card A›*) by (metis card_Suc_eq_finite (*‹(card ?A = Suc ?k) = (∃b B. ?A = insert b B ∧ b ∉ B ∧ card B = ?k ∧ finite B)›*)) then have xcard: "card A' = x" using Suc(2) (*‹Suc (x::nat) = card (A::'b set)›*) Suc(3) (*‹E = A ∪ B›*) assms(4) (*‹finite E›*) by auto define G1 where "G1 ≡ (λAi. if Ai ∈ A' then space M - F Ai else F Ai)" let ?B' = "B ∪ {a}" have eeq: "E = A' ∪ ?B'" using aeq (*‹(A::'b set) = insert (a::'b) (A'::'b set)›*) Suc.prems (*‹E = A ∪ B› ‹A ∩ B = {}›*) by auto moreover have "A' ∩ ?B' = {}" using anotin (*‹a ∉ A'›*) Suc.prems(2) (*‹(A::'b::type set) ∩ (B::'b::type set) = {}›*) aeq (*‹A = insert a A'›*) by auto moreover have "?B' ≠ {}" by simp ultimately have ies: "indep_events G1 (A' ∪ ?B')" using Suc.hyps(1)[of "A'" ?B'] (*‹⟦x = card A'; E = A' ∪ (B ∪ {a}); A' ∩ (B ∪ {a}) = {}⟧ ⟹ indep_events (λAi. if Ai ∈ A' then space M - F Ai else F Ai) E›*) xcard (*‹card A' = x›*) G1_def (*‹G1 ≡ λAi. if Ai ∈ A' then space M - F Ai else F Ai›*) by auto then have "a ∈ A ∪ B" using aeq (*‹A = insert a A'›*) by auto define G2 where "G2 ≡ λ Ai. if Ai = a then (space M - (G1 Ai)) else (G1 Ai)" have "a ∈ A' ∪ ?B'" by auto then have ie: "indep_events G2 E" using indep_events_one_compl[of G1 "(A' ∪ ?B')" a] (*‹⟦indep_events G1 (A' ∪ (B ∪ {a})); a ∈ A' ∪ (B ∪ {a})⟧ ⟹ indep_events (λi. if i = a then space M - G1 i else G1 i) (A' ∪ (B ∪ {a}))›*) ies (*‹indep_events G1 (A' ∪ (B ∪ {a}))›*) G2_def (*‹G2 ≡ λAi. if Ai = a then space M - G1 Ai else G1 Ai›*) eeq (*‹E = A' ∪ (B ∪ {a})›*) by auto moreover have "⋀ i. i ∈ E ⟹ G2 i = G i" unfolding G2_def G1_def G_def (*goal: ‹⋀i. i ∈ E ⟹ (if i = a then space M - (if i ∈ A' then space M - F i else F i) else if i ∈ A' then space M - F i else F i) = (if i ∈ A then space M - F i else F i)›*) by (simp add: aeq (*‹A = insert a A'›*) anotin (*‹a ∉ A'›*)) ultimately have "indep_events G E" using indep_events_fn_eq[of E G2 G] (*‹⟦⋀Ai. Ai ∈ E ⟹ G2 Ai = G Ai; indep_events G2 E⟧ ⟹ indep_events G E›*) by auto then show "?case" (*goal: ‹indep_events (λAi. if Ai ∈ A then space M - F Ai else F Ai) E›*) using G_def (*‹G::'b ⇒ 'a set ≡ λAi::'b. if Ai ∈ (A::'b set) then space (M::'a measure) - (F::'b ⇒ 'a set) Ai else F Ai›*) by simp qed lemma indep_events_compl: assumes "indep_events F E" assumes "finite E" shows "indep_events (λ Ai. space M - F Ai) E" proof (-) (*goal: ‹indep_events (λAi. space M - F Ai) E›*) have "indep_events (λAi. if Ai ∈ E then space M - F Ai else F Ai) E" using indep_events_update_compl[of F E E "{}"] (*‹⟦indep_events F E; E = E ∪ {}; E ∩ {} = {}; finite E⟧ ⟹ indep_events (λAi. if Ai ∈ E then space M - F Ai else F Ai) E›*) assms (*‹indep_events (F::'b::type ⇒ 'a::type set) (E::'b::type set)› ‹finite E›*) by auto moreover have "⋀ i. i ∈ E ⟹ (λAi. if Ai ∈ E then space M - F Ai else F Ai) i = (λ Ai. space M - F Ai) i" by simp ultimately show "?thesis" (*goal: ‹indep_events (λAi. space M - F Ai) E›*) using indep_events_fn_eq[of E "(λAi. if Ai ∈ E then space M - F Ai else F Ai)"] (*‹⟦⋀Ai::'b. Ai ∈ (E::'b set) ⟹ (if Ai ∈ E then space (M::'a measure) - (F::'b ⇒ 'a set) Ai else F Ai) = (?G::'b ⇒ 'a set) Ai; indep_events (λAi::'b. if Ai ∈ E then space M - F Ai else F Ai) E⟧ ⟹ indep_events ?G E›*) by auto qed lemma indep_events_impl_inj_on: assumes "finite A" assumes "indep_events F A" assumes "⋀ A' . A' ∈ A ⟹ prob (F A') > 0 ∧ prob (F A') < 1" shows "inj_on F A" apply (intro inj_onI (*‹(⋀x y. ⟦x ∈ ?A; y ∈ ?A; ?f x = ?f y⟧ ⟹ x = y) ⟹ inj_on ?f ?A›*)) (*goal: ‹inj_on F A›*) proof (rule ccontr (*‹(¬ ?P ⟹ False) ⟹ ?P›*)) (*goal: ‹⋀x y. ⟦x ∈ A; y ∈ A; F x = F y; x ≠ y⟧ ⟹ False›*) fix x and y assume xin: "x ∈ A" and yin: "y ∈ A" and feq: "F x = F y" (*‹(x::'b) ∈ (A::'b set)› ‹(y::'b) ∈ (A::'b set)› ‹(F::'b ⇒ 'a set) (x::'b) = F (y::'b)›*) assume contr: "x ≠ y" (*‹(x::'b) ≠ (y::'b)›*) then have "{x, y} ⊆ A" "{x, y} ≠ {}" "finite {x, y}" using xin (*‹x ∈ A›*) yin (*‹(y::'b) ∈ (A::'b set)›*) apply - (*goals: 1. ‹⟦(x::'b) ≠ (y::'b); x ∈ (A::'b set); y ∈ A⟧ ⟹ {x, y} ⊆ A› 2. ‹⟦(x::'b) ≠ (y::'b); x ∈ (A::'b set); y ∈ A⟧ ⟹ {x, y} ≠ {}› 3. ‹⟦(x::'b) ≠ (y::'b); x ∈ (A::'b set); y ∈ A⟧ ⟹ finite {x, y}› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*proven 3 subgoals*) . then have "prob (⋂j∈{x, y}. F j) = (∏j∈{x, y}. prob (F j))" using assms(2) (*‹indep_events F A›*) indep_events_probs[of F A "{x, y}"] (*‹⟦indep_events F A; {x, y} ⊆ A; finite {x, y}; {x, y} ≠ {}⟧ ⟹ prob (⋂ (F ` {x, y})) = (∏i∈{x, y}. prob (F i))›*) by auto moreover have "(∏j∈{x, y}. prob (F j)) = prob (F x) * prob (F y)" using contr (*‹x ≠ y›*) by auto moreover have "prob (⋂j∈{x, y}. F j) = prob (F x)" using feq (*‹(F::'b ⇒ 'a set) (x::'b) = F (y::'b)›*) by simp ultimately have "prob (F x) = prob (F x) * prob (F x)" using feq (*‹F x = F y›*) by simp then show False using assms(3) (*‹?A'12 ∈ A ⟹ 0 < prob (F ?A'12) ∧ prob (F ?A'12) < 1›*) using xin (*‹(x::'b) ∈ (A::'b set)›*) by fastforce qed lemma indep_events_imp_set: assumes "finite A" assumes "indep_events F A" assumes "⋀ A' . A' ∈ A ⟹ prob (F A') > 0 ∧ prob (F A') < 1" shows "indep_events_set (F ` A)" proof (intro indep_events_setI (*‹⟦?E ⊆ events; ⋀J. ⟦J ⊆ ?E; finite J; J ≠ {}⟧ ⟹ prob (⋂ J) = prod prob J⟧ ⟹ indep_events_set ?E›*)) (*goals: 1. ‹F ` A ⊆ events› 2. ‹⋀J. ⟦J ⊆ F ` A; finite J; J ≠ {}⟧ ⟹ prob (⋂ J) = prod prob J›*) show "F ` A ⊆ events" using assms(2) (*‹indep_events F A›*) indep_events_events (*‹⟦indep_events (?F::?'b ⇒ 'a set) (?E::?'b set); (?e::?'b) ∈ ?E⟧ ⟹ ?F ?e ∈ events›*) by auto next (*goal: ‹⋀J. ⟦J ⊆ F ` A; finite J; J ≠ {}⟧ ⟹ prob (⋂ J) = prod prob J›*) fix J assume jss: "J ⊆ F ` A" and finj: "finite J" and jne: "J ≠ {}" (*‹(J::'a set set) ⊆ (F::'b ⇒ 'a set) ` (A::'b set)› ‹finite (J::'a set set)› ‹(J::'a set set) ≠ {}›*) have bb: "bij_betw F A (F `A)" using bij_betw_imageI (*‹⟦inj_on ?f ?A; ?f ` ?A = ?B⟧ ⟹ bij_betw ?f ?A ?B›*) indep_events_impl_inj_on (*‹⟦finite ?A; indep_events ?F ?A; ⋀A'. A' ∈ ?A ⟹ 0 < prob (?F A') ∧ prob (?F A') < 1⟧ ⟹ inj_on ?F ?A›*) assms (*‹finite A› ‹indep_events F A› ‹?A'12 ∈ A ⟹ 0 < prob (F ?A'12) ∧ prob (F ?A'12) < 1›*) by meson then obtain I where iss: "I ⊆ A" and jeq: "J = F ` I" (*goal: ‹(⋀I. ⟦I ⊆ A; J = F ` I⟧ ⟹ thesis) ⟹ thesis›*) using bij_betw_obtain_subsetl[OF bb] (*‹⟦?B' ⊆ F ` A; ⋀A'. ⟦A' ⊆ A; ?B' = F ` A'⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*) jss (*‹(J::'a set set) ⊆ (F::'b ⇒ 'a set) ` (A::'b set)›*) by metis moreover have "I ≠ {}" "finite I" using finj (*‹finite J›*) jeq (*‹J = F ` I›*) jne (*‹J ≠ {}›*) assms(1) (*‹finite (A::'b set)›*) finite_subset (*‹⟦?A ⊆ ?B; finite ?B⟧ ⟹ finite ?A›*) iss (*‹I ⊆ A›*) apply - (*goals: 1. ‹⟦finite J; J = F ` I; J ≠ {}; finite A; ⋀A B. ⟦A ⊆ B; finite B⟧ ⟹ finite A; I ⊆ A⟧ ⟹ I ≠ {}› 2. ‹⟦finite J; J = F ` I; J ≠ {}; finite A; ⋀A B. ⟦A ⊆ B; finite B⟧ ⟹ finite A; I ⊆ A⟧ ⟹ finite I› discuss goal 1*) apply blast (*discuss goal 2*) apply blast (*proven 2 subgoals*) . ultimately have "prob (⋂ (F ` I)) = (∏i∈I. prob (F i))" using jne (*‹(J::'a::type set set) ≠ {}›*) finj (*‹finite J›*) jss (*‹(J::'a set set) ⊆ (F::'b ⇒ 'a set) ` (A::'b set)›*) indep_events_probs[of F A I] (*‹⟦indep_events F A; I ⊆ A; finite I; I ≠ {}⟧ ⟹ prob (⋂ (F ` I)) = (∏i∈I. prob (F i))›*) assms(2) (*‹indep_events F A›*) by simp moreover have "bij_betw F I J" using jeq (*‹(J::'a set set) = (F::'b ⇒ 'a set) ` (I::'b set)›*) iss (*‹I ⊆ A›*) jss (*‹J ⊆ F ` A›*) bb (*‹bij_betw F A (F ` A)›*) by (meson bij_betw_subset (*‹⟦bij_betw ?f ?A ?A'; ?B ⊆ ?A; ?f ` ?B = ?B'⟧ ⟹ bij_betw ?f ?B ?B'›*)) ultimately show "prob (⋂ J) = prod prob J" using bij_betw_prod_prob (*‹bij_betw ?f ?A ?B ⟹ prod prob ?B = (∏a∈?A. prob (?f a))›*) jeq (*‹J = F ` I›*) by metis qed lemma indep_event_set_equiv_bij: assumes "bij_betw F A E" assumes "finite E" shows "indep_events_set E ⟷ indep_events F A" proof (-) (*goal: ‹indep_events_set E = indep_events F A›*) have im: "F ` A = E" using assms(1) (*‹bij_betw F A E›*) by (simp add: bij_betw_def (*‹bij_betw ?f ?A ?B = (inj_on ?f ?A ∧ ?f ` ?A = ?B)›*)) then have ss: "(∀e. e ∈ E ⟶ e ∈ events) ⟷ (F ` A ⊆ events)" using image_iff (*‹((?z::?'a) ∈ (?f::?'b ⇒ ?'a) ` (?A::?'b set)) = (∃x::?'b∈?A. ?z = ?f x)›*) by (simp add: subset_iff (*‹(?A ⊆ ?B) = (∀t. t ∈ ?A ⟶ t ∈ ?B)›*)) have prob: "(∀ J. J ⊆ E ⟶ finite J ⟶ J ≠ {} ⟶ prob (⋂i∈J. i) = (∏i∈J. prob i)) ⟷ (∀ I. I ⊆ A ⟶ finite I ⟶ I ≠ {} ⟶ prob (⋂i∈I. F i) = (∏i∈I. prob (F i)))" proof (intro allI (*‹(⋀x. ?P x) ⟹ ∀x. ?P x›*) impI (*‹(?P ⟹ ?Q) ⟹ ?P ⟶ ?Q›*) iffI (*‹⟦?P ⟹ ?Q; ?Q ⟹ ?P⟧ ⟹ ?P = ?Q›*)) (*goals: 1. ‹⋀I. ⟦∀J⊆E. finite J ⟶ J ≠ {} ⟶ prob (⋂i∈J. i) = prod prob J; I ⊆ A; finite I; I ≠ {}⟧ ⟹ prob (⋂ (F ` I)) = (∏i∈I. prob (F i))› 2. ‹⋀J. ⟦∀I⊆A. finite I ⟶ I ≠ {} ⟶ prob (⋂ (F ` I)) = (∏i∈I. prob (F i)); J ⊆ E; finite J; J ≠ {}⟧ ⟹ prob (⋂i∈J. i) = prod prob J›*) fix I assume p1: " ∀J⊆E. finite J ⟶ J ≠ {} ⟶ prob (⋂i∈J. i) = prod prob J" and iss: "I ⊆ A" and f1: "finite I" and i1: "I ≠ {}" (*‹∀J⊆E::'a set set. finite J ⟶ J ≠ {} ⟶ prob (⋂i::'a set∈J. i) = prod prob J› ‹(I::'b set) ⊆ (A::'b set)› ‹finite (I::'b set)› ‹(I::'b set) ≠ {}›*) then obtain J where jeq: "J = F ` I" and jss: "J ⊆ E" (*goal: ‹(⋀J. ⟦J = F ` I; J ⊆ E⟧ ⟹ thesis) ⟹ thesis›*) using bij_betw_obtain_subsetr[OF assms ( 1 ) iss] (*‹(⋀B'. ⟦B' ⊆ E; B' = F ` I⟧ ⟹ ?thesis) ⟹ ?thesis›*) by metis then have "prob (⋂J) = prod prob J" using i1 (*‹I ≠ {}›*) f1 (*‹finite I›*) p1 (*‹∀J⊆E. finite J ⟶ J ≠ {} ⟶ prob (⋂i∈J. i) = prod prob J›*) jss (*‹J ⊆ E›*) by auto moreover have "bij_betw F I J" using jeq (*‹J = F ` I›*) jss (*‹J ⊆ E›*) assms(1) (*‹bij_betw F A E›*) iss (*‹(I::'b set) ⊆ (A::'b set)›*) by (meson bij_betw_subset (*‹⟦bij_betw ?f ?A ?A'; ?B ⊆ ?A; ?f ` ?B = ?B'⟧ ⟹ bij_betw ?f ?B ?B'›*)) ultimately show "prob (⋂ (F ` I)) = (∏i∈I. prob (F i))" using bij_betw_prod_prob (*‹bij_betw ?f ?A ?B ⟹ prod prob ?B = (∏a∈?A. prob (?f a))›*) by (metis jeq (*‹J = F ` I›*)) next (*goal: ‹⋀J. ⟦∀I⊆A. finite I ⟶ I ≠ {} ⟶ prob (⋂ (F ` I)) = (∏i∈I. prob (F i)); J ⊆ E; finite J; J ≠ {}⟧ ⟹ prob (⋂i∈J. i) = prod prob J›*) fix J assume p2: "∀I⊆A. finite I ⟶ I ≠ {} ⟶ prob (⋂ (F ` I)) = (∏i∈I. prob (F i))" and jss: "J ⊆ E" and f2: "finite J" and j1: "J ≠ {}" (*‹∀I⊆A::'b set. finite I ⟶ I ≠ {} ⟶ prob (⋂ ((F::'b ⇒ 'a set) ` I)) = (∏i::'b∈I. prob (F i))› ‹(J::'a set set) ⊆ (E::'a set set)› ‹finite (J::'a set set)› ‹(J::'a set set) ≠ {}›*) then obtain I where iss: "I ⊆ A" and jeq: "J = F ` I" (*goal: ‹(⋀I. ⟦I ⊆ A; J = F ` I⟧ ⟹ thesis) ⟹ thesis›*) using bij_betw_obtain_subsetl[OF assms ( 1 )] (*‹⟦(?B'::'a::type set set) ⊆ (E::'a::type set set); ⋀A'::'b::type set. ⟦A' ⊆ (A::'b::type set); ?B' = (F::'b::type ⇒ 'a::type set) ` A'⟧ ⟹ ?thesis::bool⟧ ⟹ ?thesis›*) by metis moreover have "finite A" using assms(1) (*‹bij_betw F A E›*) assms(2) (*‹finite E›*) by (simp add: bij_betw_finite (*‹bij_betw ?f ?A ?B ⟹ finite ?A = finite ?B›*)) ultimately have "prob (⋂ (F ` I)) = (∏i∈I. prob (F i))" using j1 (*‹J ≠ {}›*) f2 (*‹finite (J::'a set set)›*) p2 (*‹∀I⊆A. finite I ⟶ I ≠ {} ⟶ prob (⋂ (F ` I)) = (∏i∈I. prob (F i))›*) jss (*‹J ⊆ E›*) by (simp add: finite_subset (*‹⟦?A ⊆ ?B; finite ?B⟧ ⟹ finite ?A›*)) moreover have "bij_betw F I J" using jeq (*‹J = F ` I›*) iss (*‹I ⊆ A›*) assms(1) (*‹bij_betw F A E›*) jss (*‹(J::'a set set) ⊆ (E::'a set set)›*) by (meson bij_betw_subset (*‹⟦bij_betw ?f ?A ?A'; ?B ⊆ ?A; ?f ` ?B = ?B'⟧ ⟹ bij_betw ?f ?B ?B'›*)) ultimately show "prob (⋂i∈J. i) = prod prob J" using bij_betw_prod_prob (*‹bij_betw (?f::?'b ⇒ 'a set) (?A::?'b set) (?B::'a set set) ⟹ prod prob ?B = (∏a::?'b∈?A. prob (?f a))›*) jeq (*‹(J::'a::type set set) = (F::'b::type ⇒ 'a::type set) ` (I::'b::type set)›*) by (metis image_ident (*‹(λx. x) ` ?Y = ?Y›*)) qed have "indep_events_set E ⟹ indep_events F A" proof (intro indep_eventsI (*‹⟦⋀i. i ∈ ?I ⟹ ?F i ∈ events; ⋀J. ⟦J ⊆ ?I; finite J; J ≠ {}⟧ ⟹ prob (⋂ (?F ` J)) = (∏i∈J. prob (?F i))⟧ ⟹ indep_events ?F ?I›*)) (*goals: 1. ‹⋀i. ⟦indep_events_set E; i ∈ A⟧ ⟹ F i ∈ events› 2. ‹⋀J. ⟦indep_events_set E; J ⊆ A; finite J; J ≠ {}⟧ ⟹ prob (⋂ (F ` J)) = (∏i∈J. prob (F i))›*) show "⋀i. indep_events_set E ⟹ i ∈ A ⟹ F i ∈ events" using indep_events_set_events (*‹⟦indep_events_set ?E; ?e ∈ ?E⟧ ⟹ ?e ∈ events›*) ss (*‹(∀e. e ∈ E ⟶ e ∈ events) = (F ` A ⊆ events)›*) by auto show "⋀J. indep_events_set E ⟹ J ⊆ A ⟹ finite J ⟹ J ≠ {} ⟹ prob (⋂ (F ` J)) = (∏i∈J. prob (F i))" using indep_events_set_probs (*‹⟦indep_events_set ?E; ?J ⊆ ?E; finite ?J; ?J ≠ {}⟧ ⟹ prob (⋂ ?J) = prod prob ?J›*) prob (*‹(∀J⊆E. finite J ⟶ J ≠ {} ⟶ prob (⋂i∈J. i) = prod prob J) = (∀I⊆A. finite I ⟶ I ≠ {} ⟶ prob (⋂ (F ` I)) = (∏i∈I. prob (F i)))›*) by auto qed moreover have "indep_events F A ⟹ indep_events_set E" proof (intro indep_events_setI (*‹⟦?E ⊆ events; ⋀J. ⟦J ⊆ ?E; finite J; J ≠ {}⟧ ⟹ prob (⋂ J) = prod prob J⟧ ⟹ indep_events_set ?E›*)) (*goals: 1. ‹indep_events F A ⟹ E ⊆ events› 2. ‹⋀J. ⟦indep_events F A; J ⊆ E; finite J; J ≠ {}⟧ ⟹ prob (⋂ J) = prod prob J›*) have "⋀e. indep_events F A ⟹ e ∈ E ⟹ e ∈ events" using ss (*‹(∀e. e ∈ E ⟶ e ∈ events) = (F ` A ⊆ events)›*) indep_events_def (*‹indep_events (?A::?'b ⇒ 'a set) (?I::?'b set) = (?A ` ?I ⊆ events ∧ (∀J⊆?I. J ≠ {} ⟶ finite J ⟶ prob (⋂ (?A ` J)) = (∏j::?'b∈J. prob (?A j))))›*) by metis then show "indep_events F A ⟹ E ⊆ events" by auto show "⋀J. indep_events F A ⟹ J ⊆ E ⟹ finite J ⟹ J ≠ {} ⟹ prob (⋂J) = prod prob J" using prob (*‹(∀J⊆E. finite J ⟶ J ≠ {} ⟶ prob (⋂i∈J. i) = prod prob J) = (∀I⊆A. finite I ⟶ I ≠ {} ⟶ prob (⋂ (F ` I)) = (∏i∈I. prob (F i)))›*) indep_events_def (*‹indep_events ?A ?I = (?A ` ?I ⊆ events ∧ (∀J⊆?I. J ≠ {} ⟶ finite J ⟶ prob (⋂ (?A ` J)) = (∏j∈J. prob (?A j))))›*) by (metis image_ident (*‹(λx. x) ` ?Y = ?Y›*)) qed ultimately show "?thesis" (*goal: ‹indep_events_set E = indep_events F A›*) by auto qed subsection ‹ Mutual Independent Events › text ‹Note, set based version only if no duplicates in usage case. The mutual\_indep\_events definition is more general and recommended › definition mutual_indep_set:: "'a set ⇒ 'a set set ⇒ bool" where "mutual_indep_set A S ⟷ A ∈ events ∧ S ⊆ events ∧ (∀ T ⊆ S . T ≠ {} ⟶ prob (A ∩ (⋂T)) = prob A * prob (⋂T))" (* Note condition about T not empty, only necessary due to Univ issue*) (* Use every subset, rather than the not version given by Zhao *) lemma mutual_indep_setI[intro]: "A ∈ events ⟹ S ⊆ events ⟹ (⋀ T. T ⊆ S ⟹ T ≠ {} ⟹ prob (A ∩ (⋂T)) = prob A * prob (⋂T)) ⟹ mutual_indep_set A S" using mutual_indep_set_def (*‹mutual_indep_set ?A ?S = (?A ∈ events ∧ ?S ⊆ events ∧ (∀T⊆?S. T ≠ {} ⟶ prob (?A ∩ ⋂ T) = prob ?A * prob (⋂ T)))›*) by simp lemma mutual_indep_setD[dest]: "mutual_indep_set A S ⟹ T ⊆ S ⟹ T ≠ {} ⟹ prob (A ∩ (⋂T)) = prob A * prob (⋂T)" using mutual_indep_set_def (*‹mutual_indep_set ?A ?S = (?A ∈ events ∧ ?S ⊆ events ∧ (∀T⊆?S. T ≠ {} ⟶ prob (?A ∩ ⋂ T) = prob ?A * prob (⋂ T)))›*) by simp lemma mutual_indep_setD2[dest]: "mutual_indep_set A S ⟹ A ∈ events" using mutual_indep_set_def (*‹mutual_indep_set ?A ?S = (?A ∈ events ∧ ?S ⊆ events ∧ (∀T⊆?S. T ≠ {} ⟶ prob (?A ∩ ⋂ T) = prob ?A * prob (⋂ T)))›*) by simp lemma mutual_indep_setD3[dest]: "mutual_indep_set A S ⟹ S ⊆ events" using mutual_indep_set_def (*‹mutual_indep_set ?A ?S = (?A ∈ events ∧ ?S ⊆ events ∧ (∀T⊆?S. T ≠ {} ⟶ prob (?A ∩ ⋂ T) = prob ?A * prob (⋂ T)))›*) by simp lemma mutual_indep_subset: "mutual_indep_set A S ⟹ T ⊆ S ⟹ mutual_indep_set A T" using mutual_indep_set_def (*‹mutual_indep_set ?A ?S = (?A ∈ events ∧ ?S ⊆ events ∧ (∀T⊆?S. T ≠ {} ⟶ prob (?A ∩ ⋂ T) = prob ?A * prob (⋂ T)))›*) by auto lemma mutual_indep_event_set_defD: assumes "mutual_indep_set A S" assumes "finite T" assumes "T ⊆ S" assumes "T ≠ {}" shows "indep_event A (⋂T)" proof (intro indep_eventI (*‹⟦?A ∈ events; ?B ∈ events; prob (?A ∩ ?B) = prob ?A * prob ?B⟧ ⟹ indep_event ?A ?B›*)) (*goals: 1. ‹A ∈ events› 2. ‹⋂ T ∈ events› 3. ‹prob (A ∩ ⋂ T) = prob A * prob (⋂ T)›*) show "A ∈ events" using mutual_indep_setD2 (*‹mutual_indep_set (?A::'a set) (?S::'a set set) ⟹ ?A ∈ events›*) assms(1) (*‹mutual_indep_set A S›*) by auto show "⋂ T ∈ events" using Inter_event_ss (*‹⟦finite ?A; ?A ⊆ events; ?A ≠ {}⟧ ⟹ ⋂ ?A ∈ events›*) assms (*‹mutual_indep_set A S› ‹finite T› ‹T ⊆ S› ‹T ≠ {}›*) mutual_indep_setD3 (*‹mutual_indep_set ?A ?S ⟹ ?S ⊆ events›*) finite_subset (*‹⟦?A ⊆ ?B; finite ?B⟧ ⟹ finite ?A›*) by blast show "prob (A ∩ ⋂ T) = prob A * prob (⋂ T) " using assms(1) (*‹mutual_indep_set A S›*) mutual_indep_setD (*‹⟦mutual_indep_set (?A::'a set) (?S::'a set set); (?T::'a set set) ⊆ ?S; ?T ≠ {}⟧ ⟹ prob (?A ∩ ⋂ ?T) = prob ?A * prob (⋂ ?T)›*) assms(3) (*‹T ⊆ S›*) assms(4) (*‹(T::'a set set) ≠ {}›*) by simp qed lemma mutual_indep_event_defI: "A ∈ events ⟹ S ⊆ events ⟹ (⋀ T. T ⊆ S ⟹ T ≠ {} ⟹ indep_event A (⋂T)) ⟹ mutual_indep_set A S" using indep_eventD (*‹indep_event ?A ?B ⟹ prob (?A ∩ ?B) = prob ?A * prob ?B›*) mutual_indep_set_def (*‹mutual_indep_set ?A ?S = (?A ∈ events ∧ ?S ⊆ events ∧ (∀T⊆?S. T ≠ {} ⟶ prob (?A ∩ ⋂ T) = prob ?A * prob (⋂ T)))›*) by simp lemma mutual_indep_singleton_event: "mutual_indep_set A S ⟹ B ∈ S ⟹ indep_event A B" using mutual_indep_event_set_defD (*‹⟦mutual_indep_set (?A::'a set) (?S::'a set set); finite (?T::'a set set); ?T ⊆ ?S; ?T ≠ {}⟧ ⟹ indep_event ?A (⋂ ?T)›*) empty_subsetI (*‹{} ⊆ ?A›*) by (metis Set.insert_mono (*‹(?C::?'a set) ⊆ (?D::?'a set) ⟹ insert (?a::?'a) ?C ⊆ insert ?a ?D›*) cInf_singleton (*‹⨅ {?x::?'a} = ?x›*) finite.emptyI (*‹finite {}›*) finite_insert (*‹finite (insert (?a::?'a) (?A::?'a set)) = finite ?A›*) insert_absorb (*‹(?a::?'a) ∈ (?A::?'a set) ⟹ insert ?a ?A = ?A›*) insert_not_empty (*‹insert (?a::?'a) (?A::?'a set) ≠ {}›*)) lemma mutual_indep_cond: assumes "A ∈ events" and "T ⊆ events" and "finite T" and "mutual_indep_set A S" and "T ⊆ S" and "T ≠ {}" and "prob (⋂T) ≠ 0" shows "𝒫(A |(⋂T)) = prob A" proof (-) (*goal: ‹𝒫(A::'a::type set | ⋂ (T::'a::type set set)) = prob A›*) have "⋂T ∈ events" using assms (*‹A ∈ events› ‹(T::'a set set) ⊆ events› ‹finite (T::'a set set)› ‹mutual_indep_set A S› ‹T ⊆ S› ‹T ≠ {}› ‹prob (⋂ (T::'a set set)) ≠ (0::real)›*) by (simp add: Inter_event_ss (*‹⟦finite ?A; ?A ⊆ events; ?A ≠ {}⟧ ⟹ ⋂ ?A ∈ events›*)) then have "𝒫(A | (⋂T)) = prob ((⋂T) ∩ A)/prob(⋂T)" using cond_prob_ev_def (*‹⟦?A ∈ events; ?B ∈ events⟧ ⟹ 𝒫(?B | ?A) = prob (?A ∩ ?B) / prob ?A›*) assms(1) (*‹A ∈ events›*) by blast also (*calculation: ‹𝒫(A | ⋂ T) = prob (⋂ T ∩ A) / prob (⋂ T)›*) have "... = prob (A ∩ (⋂T))/prob(⋂T)" by (simp add: inf_commute (*‹?x ⊓ ?y = ?y ⊓ ?x›*)) also (*calculation: ‹𝒫(A | ⋂ T) = prob (A ∩ ⋂ T) / prob (⋂ T)›*) have "... = prob A * prob (⋂T)/prob(⋂T)" using assms (*‹A ∈ events› ‹T ⊆ events› ‹finite T› ‹mutual_indep_set A S› ‹T ⊆ S› ‹T ≠ {}› ‹prob (⋂ T) ≠ 0›*) mutual_indep_setD (*‹⟦mutual_indep_set ?A ?S; ?T ⊆ ?S; ?T ≠ {}⟧ ⟹ prob (?A ∩ ⋂ ?T) = prob ?A * prob (⋂ ?T)›*) by auto finally (*calculation: ‹𝒫(A | ⋂ T) = prob A * prob (⋂ T) / prob (⋂ T)›*) show "?thesis" (*goal: ‹𝒫(A::'a::type set | ⋂ (T::'a::type set set)) = prob A›*) using assms(7) (*‹prob (⋂ T) ≠ 0›*) by simp qed lemma mutual_indep_cond_full: assumes "A ∈ events" and "S ⊆ events" and "finite S" and "mutual_indep_set A S" and "S ≠ {}" and "prob (⋂S) ≠ 0" shows "𝒫(A |(⋂S)) = prob A" using mutual_indep_cond[of A S S] (*‹⟦A ∈ events; S ⊆ events; finite S; mutual_indep_set A S; S ⊆ S; S ≠ {}; prob (⋂ S) ≠ 0⟧ ⟹ 𝒫(A | ⋂ S) = prob A›*) assms (*‹A ∈ events› ‹S ⊆ events› ‹finite (S::'a set set)› ‹mutual_indep_set A S› ‹S ≠ {}› ‹prob (⋂ (S::'a set set)) ≠ (0::real)›*) by auto lemma mutual_indep_cond_single: assumes "A ∈ events" and "B ∈ events" and "mutual_indep_set A S" and "B ∈ S" and "prob B ≠ 0" shows "𝒫(A |B) = prob A" using mutual_indep_cond[of "A" "{B}" S] (*‹⟦A ∈ events; {B} ⊆ events; finite {B}; mutual_indep_set A S; {B} ⊆ S; {B} ≠ {}; prob (⋂ {B}) ≠ 0⟧ ⟹ 𝒫(A | ⋂ {B}) = prob A›*) assms (*‹A ∈ events› ‹B ∈ events› ‹mutual_indep_set A S› ‹B ∈ S› ‹prob B ≠ 0›*) by auto lemma mutual_indep_set_empty: "A ∈ events ⟹ mutual_indep_set A {}" using mutual_indep_setI (*‹⟦(?A::'a set) ∈ events; (?S::'a set set) ⊆ events; ⋀T::'a set set. ⟦T ⊆ ?S; T ≠ {}⟧ ⟹ prob (?A ∩ ⋂ T) = prob ?A * prob (⋂ T)⟧ ⟹ mutual_indep_set ?A ?S›*) by auto lemma not_mutual_indep_set_itself: assumes "prob A > 0" and "prob A < 1" shows "¬ mutual_indep_set A {A}" proof (rule ccontr (*‹(¬ (?P::bool) ⟹ False) ⟹ ?P›*)) (*goal: ‹¬ ¬ mutual_indep_set (A::'a set) {A} ⟹ False›*) assume "¬ ¬ mutual_indep_set A {A}" (*‹¬ ¬ mutual_indep_set (A::'a set) {A}›*) then have "mutual_indep_set A {A}" by simp then have "⋀ T . T ⊆ {A} ⟹ T ≠ {} ⟹ prob (A ∩ (⋂ T)) = prob A * prob (⋂T)" using mutual_indep_setD (*‹⟦mutual_indep_set (?A::'a set) (?S::'a set set); (?T::'a set set) ⊆ ?S; ?T ≠ {}⟧ ⟹ prob (?A ∩ ⋂ ?T) = prob ?A * prob (⋂ ?T)›*) by simp then have eq: "prob (A ∩ (⋂ {A})) = prob A * prob (⋂{A})" by blast have "prob (A ∩ (⋂{A})) = prob A" by simp moreover have "prob A * (prob (⋂ {A})) = (prob A)^2" by (simp add: power2_eq_square (*‹?a² = ?a * ?a›*)) ultimately show False using eq (*‹prob ((A::'a set) ∩ ⋂ {A}) = prob A * prob (⋂ {A})›*) assms (*‹0 < prob A› ‹prob A < 1›*) by auto qed lemma is_mutual_indep_set_itself: assumes "A ∈ events" assumes "prob A = 0 ∨ prob A = 1" shows "mutual_indep_set A {A}" proof (intro mutual_indep_setI (*‹⟦?A ∈ events; ?S ⊆ events; ⋀T. ⟦T ⊆ ?S; T ≠ {}⟧ ⟹ prob (?A ∩ ⋂ T) = prob ?A * prob (⋂ T)⟧ ⟹ mutual_indep_set ?A ?S›*)) (*goals: 1. ‹(A::'a::type set) ∈ events› 2. ‹{A::'a::type set} ⊆ events› 3. ‹⋀T::'a::type set set. ⟦T ⊆ {A::'a::type set}; T ≠ {}⟧ ⟹ prob (A ∩ ⋂ T) = prob A * prob (⋂ T)›*) show "A ∈ events" "{A} ⊆ events" using assms(1) (*‹A ∈ events›*) apply - (*goals: 1. ‹A ∈ events ⟹ A ∈ events› 2. ‹A ∈ events ⟹ {A} ⊆ events› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . fix T assume "T ⊆ {A}" and "T ≠ {}" (*‹(T::'a set set) ⊆ {A::'a set}› ‹(T::'a set set) ≠ {}›*) then have teq: "T = {A}" by auto have "prob (A ∩ (⋂{A})) = prob A" by simp moreover have "prob A * (prob (⋂ {A})) = (prob A)^2" by (simp add: power2_eq_square (*‹?a² = ?a * ?a›*)) ultimately show "prob (A ∩ (⋂ T)) = prob A * prob (⋂T)" using teq (*‹T = {A}›*) assms (*‹(A::'a::type set) ∈ events› ‹prob (A::'a set) = (0::real) ∨ prob A = (1::real)›*) by auto qed lemma mutual_indep_set_singleton: assumes "indep_event A B" shows "mutual_indep_set A {B}" using indep_eventD_ev1 (*‹indep_event ?A ?B ⟹ ?A ∈ events›*) indep_eventD_ev2 (*‹indep_event ?A ?B ⟹ ?B ∈ events›*) assms (*‹indep_event (A::'a set) (B::'a set)›*) apply (intro mutual_indep_event_defI (*‹⟦?A ∈ events; ?S ⊆ events; ⋀T. ⟦T ⊆ ?S; T ≠ {}⟧ ⟹ indep_event ?A (⋂ T)⟧ ⟹ mutual_indep_set ?A ?S›*)) (*goals: 1. ‹⟦⋀A B. indep_event A B ⟹ A ∈ events; ⋀A B. indep_event A B ⟹ B ∈ events; indep_event A B⟧ ⟹ A ∈ events› 2. ‹⟦⋀A B. indep_event A B ⟹ A ∈ events; ⋀A B. indep_event A B ⟹ B ∈ events; indep_event A B⟧ ⟹ {B} ⊆ events› 3. ‹⋀T. ⟦⋀A B. indep_event A B ⟹ A ∈ events; ⋀A B. indep_event A B ⟹ B ∈ events; indep_event A B; T ⊆ {B}; T ≠ {}⟧ ⟹ indep_event A (⋂ T)› discuss goal 1*) apply (simp add: subset_singleton_iff (*‹(?X ⊆ {?a}) = (?X = {} ∨ ?X = {?a})›*)) (*discuss goal 2*) apply (simp add: subset_singleton_iff (*‹(?X ⊆ {?a}) = (?X = {} ∨ ?X = {?a})›*)) (*discuss goal 3*) apply (simp add: subset_singleton_iff (*‹(?X ⊆ {?a}) = (?X = {} ∨ ?X = {?a})›*)) (*proven 3 subgoals*) . lemma mutual_indep_set_one_compl: assumes "mutual_indep_set A S" assumes "finite S" assumes "B ∈ S" shows "mutual_indep_set A ({space M - B} ∪ S)" proof (intro mutual_indep_event_defI (*‹⟦?A ∈ events; ?S ⊆ events; ⋀T. ⟦T ⊆ ?S; T ≠ {}⟧ ⟹ indep_event ?A (⋂ T)⟧ ⟹ mutual_indep_set ?A ?S›*)) (*goals: 1. ‹A ∈ events› 2. ‹{space M - B} ∪ S ⊆ events› 3. ‹⋀T. ⟦T ⊆ {space M - B} ∪ S; T ≠ {}⟧ ⟹ indep_event A (⋂ T)›*) show "A ∈ events" using assms(1) (*‹mutual_indep_set A S›*) mutual_indep_setD2 (*‹mutual_indep_set ?A ?S ⟹ ?A ∈ events›*) by auto next (*goals: 1. ‹{space M - B} ∪ S ⊆ events› 2. ‹⋀T. ⟦T ⊆ {space M - B} ∪ S; T ≠ {}⟧ ⟹ indep_event A (⋂ T)›*) show "{space M - B} ∪ (S) ⊆ events" using assms(1) (*‹mutual_indep_set A S›*) assms(2) (*‹finite S›*) mutual_indep_setD3 (*‹mutual_indep_set ?A ?S ⟹ ?S ⊆ events›*) assms(3) (*‹B ∈ S›*) by blast next (*goal: ‹⋀T. ⟦T ⊆ {space M - B} ∪ S; T ≠ {}⟧ ⟹ indep_event A (⋂ T)›*) fix T assume jss: "T ⊆ {space M - B} ∪ (S)" (*‹(T::'a set set) ⊆ {space (M::'a measure) - (B::'a set)} ∪ (S::'a set set)›*) assume tne: "T ≠ {}" (*‹(T::'a set set) ≠ {}›*) let ?T' = "T - {space M - B}" show "indep_event A (⋂ T)" proof (cases "?T' = {}") (*goals: 1. ‹T - {space M - B} = {} ⟹ indep_event A (⋂ T)› 2. ‹T - {space M - B} ≠ {} ⟹ indep_event A (⋂ T)›*) case True (*‹T - {space M - B} = {}›*) then have "T = {space M - B}" using tne (*‹T ≠ {}›*) by blast moreover have "indep_event A B" using assms(1) (*‹mutual_indep_set A S›*) assms(3) (*‹B ∈ S›*) assms(3) (*‹B ∈ S›*) mutual_indep_singleton_event (*‹⟦mutual_indep_set ?A ?S; ?B ∈ ?S⟧ ⟹ indep_event ?A ?B›*) by auto ultimately show "?thesis" (*goal: ‹indep_event A (⋂ T)›*) using indep_event_one_compl (*‹indep_event ?A ?B ⟹ indep_event ?A (space M - ?B)›*) by auto next (*goal: ‹T - {space M - B} ≠ {} ⟹ indep_event A (⋂ T)›*) case tne2: False (*‹T - {space M - B} ≠ {}›*) have finT: "finite T" using jss (*‹T ⊆ {space M - B} ∪ S›*) assms(2) (*‹finite S›*) finite_subset (*‹⟦?A ⊆ ?B; finite ?B⟧ ⟹ finite ?A›*) by fast have tss2: "?T' ⊆ S" using jss (*‹T ⊆ {space M - B} ∪ S›*) assms(2) (*‹finite S›*) by auto show "?thesis" (*goal: ‹indep_event A (⋂ T)›*) proof (cases "space M - B ∈ T") (*goals: 1. ‹space M - B ∈ T ⟹ indep_event A (⋂ T)› 2. ‹space M - B ∉ T ⟹ indep_event A (⋂ T)›*) case True (*‹space M - B ∈ T›*) have "?T' ∪ {B} ⊆ S" using assms(3) (*‹B ∈ S›*) tss2 (*‹T - {space M - B} ⊆ S›*) by auto then have "indep_event A (⋂(?T' ∪ {B}))" using assms(1) (*‹mutual_indep_set A S›*) mutual_indep_event_set_defD (*‹⟦mutual_indep_set (?A::'a set) (?S::'a set set); finite (?T::'a set set); ?T ⊆ ?S; ?T ≠ {}⟧ ⟹ indep_event ?A (⋂ ?T)›*) tne2 (*‹T - {space M - B} ≠ {}›*) finT (*‹finite (T::'a set set)›*) by (meson Un_empty (*‹(?A ∪ ?B = {}) = (?A = {} ∧ ?B = {})›*) assms( (*‹finite S›*) 2) finite_subset (*‹⟦?A ⊆ ?B; finite ?B⟧ ⟹ finite ?A›*)) moreover have "indep_event A (⋂?T')" using assms(1) (*‹mutual_indep_set A S›*) mutual_indep_event_set_defD (*‹⟦mutual_indep_set ?A ?S; finite ?T; ?T ⊆ ?S; ?T ≠ {}⟧ ⟹ indep_event ?A (⋂ ?T)›*) finT (*‹finite T›*) finite_subset (*‹⟦?A ⊆ ?B; finite ?B⟧ ⟹ finite ?A›*) tss2 (*‹T - {space M - B} ⊆ S›*) tne2 (*‹T - {space M - B} ≠ {}›*) by auto moreover have "⋂(?T' ∪ {B}) = B ∩ (⋂?T')" by auto moreover have "B ∈ events" using assms(3) (*‹(B::'a::type set) ∈ (S::'a::type set set)›*) assms(1) (*‹mutual_indep_set (A::'a::type set) (S::'a::type set set)›*) mutual_indep_setD3 (*‹mutual_indep_set ?A ?S ⟹ ?S ⊆ events›*) by auto ultimately have "indep_event A ((space M - B) ∩ (⋂?T'))" using indep_event_compl_inter (*‹⟦indep_event (?A::'a set) (?C::'a set); (?B::'a set) ∈ events; indep_event ?A (?B ∩ ?C)⟧ ⟹ indep_event ?A ((space (M::'a measure) - ?B) ∩ ?C)›*) by auto then show "?thesis" (*goal: ‹indep_event A (⋂ T)›*) by (metis Inter_insert (*‹⋂ (insert ?a ?B) = ?a ∩ ⋂ ?B›*) True (*‹space M - B ∈ T›*) insert_Diff (*‹?a ∈ ?A ⟹ insert ?a (?A - {?a}) = ?A›*)) next (*goal: ‹space M - B ∉ T ⟹ indep_event A (⋂ T)›*) case False (*‹space M - B ∉ T›*) then have "T ⊆ S" using jss (*‹T ⊆ {space M - B} ∪ S›*) by auto then show "?thesis" (*goal: ‹indep_event A (⋂ T)›*) using assms(1) (*‹mutual_indep_set (A::'a::type set) (S::'a::type set set)›*) mutual_indep_event_set_defD (*‹⟦mutual_indep_set ?A ?S; finite ?T; ?T ⊆ ?S; ?T ≠ {}⟧ ⟹ indep_event ?A (⋂ ?T)›*) finT (*‹finite T›*) tne (*‹T ≠ {}›*) by auto qed qed qed lemma mutual_indep_events_set_update_compl: assumes "mutual_indep_set X E" assumes "E = A ∪ B" assumes "A ∩ B = {}" assumes "finite E" shows "mutual_indep_set X (((-) (space M) ` A) ∪ B)" using assms(2) (*‹E = A ∪ B›*) assms(3) (*‹A ∩ B = {}›*) proof (induct "card A" arbitrary: A B) (*goals: 1. ‹⋀A B. ⟦0 = card A; E = A ∪ B; A ∩ B = {}⟧ ⟹ mutual_indep_set X ((-) (space M) ` A ∪ B)› 2. ‹⋀x A B. ⟦⋀A B. ⟦x = card A; E = A ∪ B; A ∩ B = {}⟧ ⟹ mutual_indep_set X ((-) (space M) ` A ∪ B); Suc x = card A; E = A ∪ B; A ∩ B = {}⟧ ⟹ mutual_indep_set X ((-) (space M) ` A ∪ B)›*) case 0 (*‹0 = card A› ‹E = A ∪ B› ‹A ∩ B = {}›*) then show "?case" (*goal: ‹mutual_indep_set X ((-) (space M) ` A ∪ B)›*) using assms(1) (*‹mutual_indep_set X E›*) using assms(4) (*‹finite E›*) by auto next (*goal: ‹⋀(x::nat) (A::'a set set) B::'a set set. ⟦⋀(A::'a set set) B::'a set set. ⟦x = card A; (E::'a set set) = A ∪ B; A ∩ B = {}⟧ ⟹ mutual_indep_set (X::'a set) ((-) (space (M::'a measure)) ` A ∪ B); Suc x = card A; E = A ∪ B; A ∩ B = {}⟧ ⟹ mutual_indep_set X ((-) (space M) ` A ∪ B)›*) case (Suc x) (*‹⟦(x::nat) = card (?A12::'a::type set set); (E::'a::type set set) = ?A12 ∪ (?B12::'a::type set set); ?A12 ∩ ?B12 = {}⟧ ⟹ mutual_indep_set (X::'a::type set) ((-) (space (M::'a::type measure)) ` ?A12 ∪ ?B12)› ‹Suc x = card A› ‹(E::'a set set) = (A::'a set set) ∪ (B::'a set set)› ‹A ∩ B = {}›*) then obtain a and A' where aeq: "A = insert a A'" and anotin: "a ∉ A'" (*goal: ‹(⋀a A'. ⟦A = insert a A'; a ∉ A'⟧ ⟹ thesis) ⟹ thesis›*) by (metis card_Suc_eq_finite (*‹(card ?A = Suc ?k) = (∃b B. ?A = insert b B ∧ b ∉ B ∧ card B = ?k ∧ finite B)›*)) then have xcard: "card A' = x" using Suc(2) (*‹Suc x = card A›*) Suc(3) (*‹(E::'a set set) = (A::'a set set) ∪ (B::'a set set)›*) assms(4) (*‹finite E›*) by auto let ?B' = "B ∪ {a}" have "E = A' ∪ ?B'" using aeq (*‹A = insert a A'›*) Suc.prems (*‹E = A ∪ B› ‹A ∩ B = {}›*) by auto moreover have "A' ∩ ?B' = {}" using anotin (*‹a ∉ A'›*) Suc.prems(2) (*‹(A::'a set set) ∩ (B::'a set set) = {}›*) aeq (*‹A = insert a A'›*) by auto ultimately have ies: "mutual_indep_set X ((-) (space M) ` A' ∪ ?B')" using Suc.hyps(1)[of "A'" ?B'] (*‹⟦x = card A'; E = A' ∪ (B ∪ {a}); A' ∩ (B ∪ {a}) = {}⟧ ⟹ mutual_indep_set X ((-) (space M) ` A' ∪ (B ∪ {a}))›*) xcard (*‹card (A'::'a::type set set) = (x::nat)›*) by auto then have "a ∈ A ∪ B" using aeq (*‹A = insert a A'›*) by auto then show "?case" (*goal: ‹mutual_indep_set X ((-) (space M) ` A ∪ B)›*) proof (cases "(A ∪ B) - {a} = {}") (*goals: 1. ‹⟦a ∈ A ∪ B; A ∪ B - {a} = {}⟧ ⟹ mutual_indep_set X ((-) (space M) ` A ∪ B)› 2. ‹⟦a ∈ A ∪ B; A ∪ B - {a} ≠ {}⟧ ⟹ mutual_indep_set X ((-) (space M) ` A ∪ B)›*) case True (*‹A ∪ B - {a} = {}›*) then have "A = {a}" "B = {}" using Suc.prems (*‹E = A ∪ B› ‹(A::'a set set) ∩ (B::'a set set) = {}›*) aeq (*‹A = insert a A'›*) apply - (*goals: 1. ‹⟦A ∪ B - {a} = {}; E = A ∪ B; A ∩ B = {}; A = insert a A'⟧ ⟹ A = {a}› 2. ‹⟦A ∪ B - {a} = {}; E = A ∪ B; A ∩ B = {}; A = insert a A'⟧ ⟹ B = {}› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . moreover have "indep_event X a" using mutual_indep_singleton_event (*‹⟦mutual_indep_set ?A ?S; ?B ∈ ?S⟧ ⟹ indep_event ?A ?B›*) ies (*‹mutual_indep_set (X::'a set) ((-) (space (M::'a measure)) ` (A'::'a set set) ∪ ((B::'a set set) ∪ {a::'a set}))›*) by auto ultimately show "?thesis" (*goal: ‹mutual_indep_set X ((-) (space M) ` A ∪ B)›*) using mutual_indep_set_singleton (*‹indep_event ?A ?B ⟹ mutual_indep_set ?A {?B}›*) indep_event_one_compl (*‹indep_event (?A::'a::type set) (?B::'a::type set) ⟹ indep_event ?A (space (M::'a::type measure) - ?B)›*) by simp next (*goal: ‹⟦a ∈ A ∪ B; A ∪ B - {a} ≠ {}⟧ ⟹ mutual_indep_set X ((-) (space M) ` A ∪ B)›*) case False (*‹(A::'a::type set set) ∪ (B::'a::type set set) - {a::'a::type set} ≠ {}›*) let ?c = "(-) (space M)" have un: "?c ` A ∪ B = ?c ` A' ∪ ({?c a}) ∪ (?B' - {a})" using Suc(4) (*‹A ∩ B = {}›*) aeq (*‹A = insert a A'›*) by force moreover have "?B' - {a} ⊆ ?B'" by auto moreover have "?B' - {a} ⊆ ?c ` A' ∪ {?c a} ∪ (?B')" by auto moreover have "?c ` A' ∪ {?c a} ⊆ ?c ` A' ∪ {?c a} ∪ (?B')" by auto ultimately have ss: "?c ` A ∪ B ⊆ {?c a} ∪ (?c ` A' ∪ ?B')" using Un_least (*‹⟦?A ⊆ ?C; ?B ⊆ ?C⟧ ⟹ ?A ∪ ?B ⊆ ?C›*) by auto have "a ∈ (-) (space M) ` A' ∪ ?B'" using aeq (*‹A = insert a A'›*) by auto then have ie: "mutual_indep_set X ({?c a} ∪ (?c ` A' ∪ ?B'))" using mutual_indep_set_one_compl[of X "?c ` A' ∪ ?B'" a] (*‹⟦mutual_indep_set (X::'a set) ((-) (space (M::'a measure)) ` (A'::'a set set) ∪ ((B::'a set set) ∪ {a::'a set})); finite ((-) (space M) ` A' ∪ (B ∪ {a})); a ∈ (-) (space M) ` A' ∪ (B ∪ {a})⟧ ⟹ mutual_indep_set X ({space M - a} ∪ ((-) (space M) ` A' ∪ (B ∪ {a})))›*) ies (*‹mutual_indep_set X ((-) (space M) ` A' ∪ (B ∪ {a}))›*) ‹E = A' ∪ (B ∪ {a})› (*‹(E::'a set set) = (A'::'a set set) ∪ ((B::'a set set) ∪ {a::'a set})›*) assms(4) (*‹finite (E::'a set set)›*) by blast then show "?thesis" (*goal: ‹mutual_indep_set X ((-) (space M) ` A ∪ B)›*) using mutual_indep_subset (*‹⟦mutual_indep_set (?A::'a::type set) (?S::'a::type set set); (?T::'a::type set set) ⊆ ?S⟧ ⟹ mutual_indep_set ?A ?T›*) ss (*‹(-) (space M) ` A ∪ B ⊆ {space M - a} ∪ ((-) (space M) ` A' ∪ (B ∪ {a}))›*) by auto qed qed lemma mutual_indep_events_compl: assumes "finite S" assumes "mutual_indep_set A S" shows "mutual_indep_set A ((λ s . space M - s) ` S)" using mutual_indep_events_set_update_compl[of A S S "{}"] (*‹⟦mutual_indep_set (A::'a set) (S::'a set set); S = S ∪ {}; S ∩ {} = {}; finite S⟧ ⟹ mutual_indep_set A ((-) (space (M::'a measure)) ` S ∪ {})›*) assms (*‹finite S› ‹mutual_indep_set A S›*) by auto lemma mutual_indep_set_all: assumes "A ⊆ events" assumes "⋀ Ai. Ai ∈ A ⟹ (mutual_indep_set Ai (A - {Ai}))" shows "indep_events_set A" proof (intro indep_events_setI (*‹⟦?E ⊆ events; ⋀J. ⟦J ⊆ ?E; finite J; J ≠ {}⟧ ⟹ prob (⋂ J) = prod prob J⟧ ⟹ indep_events_set ?E›*)) (*goals: 1. ‹A ⊆ events› 2. ‹⋀J. ⟦J ⊆ A; finite J; J ≠ {}⟧ ⟹ prob (⋂ J) = prod prob J›*) show "A ⊆ events" using assms(1) (*‹(A::'a set set) ⊆ events›*) by auto next (*goal: ‹⋀J. ⟦J ⊆ A; finite J; J ≠ {}⟧ ⟹ prob (⋂ J) = prod prob J›*) fix J assume ss: "J ⊆ A" and fin: "finite J" and ne: "J ≠ {}" (*‹(J::'a set set) ⊆ (A::'a set set)› ‹finite (J::'a set set)› ‹(J::'a set set) ≠ {}›*) from fin (*‹finite J›*) ne (*‹J ≠ {}›*) ss (*‹J ⊆ A›*) show "prob (⋂J) = prod prob J" proof (induct J rule: finite_ne_induct (*‹⟦finite ?F; ?F ≠ {}; ⋀x. ?P {x}; ⋀x F. ⟦finite F; F ≠ {}; x ∉ F; ?P F⟧ ⟹ ?P (insert x F)⟧ ⟹ ?P ?F›*)) (*goals: 1. ‹⋀x::'a::type set. {x} ⊆ (A::'a::type set set) ⟹ prob (⋂ {x}) = prod prob {x}› 2. ‹⋀(x::'a::type set) F::'a::type set set. ⟦finite F; F ≠ {}; x ∉ F; F ⊆ (A::'a::type set set) ⟹ prob (⋂ F) = prod prob F; insert x F ⊆ A⟧ ⟹ prob (⋂ (insert x F)) = prod prob (insert x F)›*) case (singleton x) (*‹{x::'a set} ⊆ (A::'a set set)›*) then show "?case" (*goal: ‹prob (⋂ {x}) = prod prob {x}›*) by simp next (*goal: ‹⋀x F. ⟦finite F; F ≠ {}; x ∉ F; F ⊆ A ⟹ prob (⋂ F) = prod prob F; insert x F ⊆ A⟧ ⟹ prob (⋂ (insert x F)) = prod prob (insert x F)›*) case (insert x F) (*‹finite F› ‹F ≠ {}› ‹x ∉ F› ‹F ⊆ A ⟹ prob (⋂ F) = prod prob F› ‹insert (x::'a::type set) (F::'a::type set set) ⊆ (A::'a::type set set)›*) then have "mutual_indep_set x (A - {x})" using assms(2) (*‹?Ai12 ∈ A ⟹ mutual_indep_set ?Ai12 (A - {?Ai12})›*) by simp moreover have "F ⊆ (A - {x})" using insert.prems (*‹insert x F ⊆ A›*) insert.hyps (*‹finite F› ‹F ≠ {}› ‹x ∉ F› ‹F ⊆ A ⟹ prob (⋂ F) = prod prob F›*) by auto ultimately have "prob (x ∩ (⋂F)) = prob x * prob (⋂F)" by (simp add: local.insert( (*‹F ≠ {}›*) 2) mutual_indep_setD (*‹⟦mutual_indep_set ?A ?S; ?T ⊆ ?S; ?T ≠ {}⟧ ⟹ prob (?A ∩ ⋂ ?T) = prob ?A * prob (⋂ ?T)›*)) then show "?case" (*goal: ‹prob (⋂ (insert x F)) = prod prob (insert x F)›*) using insert.hyps (*‹finite F› ‹F ≠ {}› ‹x ∉ F› ‹F ⊆ A ⟹ prob (⋂ F) = prod prob F›*) insert.prems (*‹insert x F ⊆ A›*) by simp qed qed text ‹Prefered version using indexed notation › definition mutual_indep_events:: "'a set ⇒ (nat ⇒ 'a set) ⇒ nat set ⇒ bool" where "mutual_indep_events A F I ⟷ A ∈ events ∧ (F ` I ⊆ events) ∧ (∀ J ⊆ I . J ≠ {} ⟶ prob (A ∩ (⋂j ∈ J . F j)) = prob A * prob (⋂j ∈ J . F j))" (* Not condition about T not empty, only necessary due to Univ issue?*) (* Use every subset, rather than the not version given by Zhao, should this include condition re prob *) lemma mutual_indep_eventsI[intro]: "A ∈ events ⟹ (F ` I ⊆ events) ⟹ (⋀ J. J ⊆ I ⟹ J ≠ {} ⟹ prob (A ∩ (⋂j ∈ J . F j)) = prob A * prob (⋂j ∈ J . F j)) ⟹ mutual_indep_events A F I" using mutual_indep_events_def (*‹mutual_indep_events ?A ?F ?I = (?A ∈ events ∧ ?F ` ?I ⊆ events ∧ (∀J⊆?I. J ≠ {} ⟶ prob (?A ∩ ⋂ (?F ` J)) = prob ?A * prob (⋂ (?F ` J))))›*) by simp lemma mutual_indep_eventsD[dest]: "mutual_indep_events A F I ⟹ J ⊆ I ⟹ J ≠ {} ⟹ prob (A ∩ (⋂j ∈ J . F j)) = prob A * prob (⋂j ∈ J . F j)" using mutual_indep_events_def (*‹mutual_indep_events ?A ?F ?I = (?A ∈ events ∧ ?F ` ?I ⊆ events ∧ (∀J⊆?I. J ≠ {} ⟶ prob (?A ∩ ⋂ (?F ` J)) = prob ?A * prob (⋂ (?F ` J))))›*) by simp lemma mutual_indep_eventsD2[dest]: "mutual_indep_events A F I ⟹ A ∈ events" using mutual_indep_events_def (*‹mutual_indep_events ?A ?F ?I = (?A ∈ events ∧ ?F ` ?I ⊆ events ∧ (∀J⊆?I. J ≠ {} ⟶ prob (?A ∩ ⋂ (?F ` J)) = prob ?A * prob (⋂ (?F ` J))))›*) by simp lemma mutual_indep_eventsD3[dest]: "mutual_indep_events A F I ⟹ F ` I ⊆ events" using mutual_indep_events_def (*‹mutual_indep_events ?A ?F ?I = (?A ∈ events ∧ ?F ` ?I ⊆ events ∧ (∀J⊆?I. J ≠ {} ⟶ prob (?A ∩ ⋂ (?F ` J)) = prob ?A * prob (⋂ (?F ` J))))›*) by simp lemma mutual_indep_ev_subset: "mutual_indep_events A F I ⟹ J ⊆ I ⟹ mutual_indep_events A F J" using mutual_indep_events_def (*‹mutual_indep_events ?A ?F ?I = (?A ∈ events ∧ ?F ` ?I ⊆ events ∧ (∀J⊆?I. J ≠ {} ⟶ prob (?A ∩ ⋂ (?F ` J)) = prob ?A * prob (⋂ (?F ` J))))›*) by (meson image_mono (*‹?A ⊆ ?B ⟹ ?f ` ?A ⊆ ?f ` ?B›*) subset_trans (*‹⟦?A ⊆ ?B; ?B ⊆ ?C⟧ ⟹ ?A ⊆ ?C›*)) lemma mutual_indep_event_defD: assumes "mutual_indep_events A F I" assumes "finite J" assumes "J ⊆ I" assumes "J ≠ {}" shows "indep_event A (⋂j ∈ J . F j)" proof (intro indep_eventI (*‹⟦?A ∈ events; ?B ∈ events; prob (?A ∩ ?B) = prob ?A * prob ?B⟧ ⟹ indep_event ?A ?B›*)) (*goals: 1. ‹A ∈ events› 2. ‹⋂ (F ` J) ∈ events› 3. ‹prob (A ∩ ⋂ (F ` J)) = prob A * prob (⋂ (F ` J))›*) show "A ∈ events" using mutual_indep_setD2 (*‹mutual_indep_set ?A ?S ⟹ ?A ∈ events›*) assms(1) (*‹mutual_indep_events (A::'a set) (F::nat ⇒ 'a set) (I::nat set)›*) by auto show "prob (A ∩ ⋂ (F ` J)) = prob A * prob (⋂ (F ` J))" using assms(1) (*‹mutual_indep_events A F I›*) mutual_indep_eventsD (*‹⟦mutual_indep_events ?A ?F ?I; ?J ⊆ ?I; ?J ≠ {}⟧ ⟹ prob (?A ∩ ⋂ (?F ` ?J)) = prob ?A * prob (⋂ (?F ` ?J))›*) assms(3) (*‹J ⊆ I›*) assms(4) (*‹J ≠ {}›*) by simp have "finite (F ` J)" using finite_subset (*‹⟦?A ⊆ ?B; finite ?B⟧ ⟹ finite ?A›*) assms(2) (*‹finite J›*) by simp then show "(⋂j ∈ J . F j) ∈ events" using Inter_event_ss[of "F ` J"] (*‹⟦finite (F ` J); F ` J ⊆ events; F ` J ≠ {}⟧ ⟹ ⋂ (F ` J) ∈ events›*) assms (*‹mutual_indep_events A F I› ‹finite J› ‹J ⊆ I› ‹J ≠ {}›*) mutual_indep_eventsD3 (*‹mutual_indep_events ?A ?F ?I ⟹ ?F ` ?I ⊆ events›*) by blast qed lemma mutual_ev_indep_event_defI: "A ∈ events ⟹ F ` I ⊆ events ⟹ (⋀ J. J ⊆ I ⟹ J ≠ {} ⟹ indep_event A (⋂(F` J))) ⟹ mutual_indep_events A F I" using indep_eventD (*‹indep_event ?A ?B ⟹ prob (?A ∩ ?B) = prob ?A * prob ?B›*) mutual_indep_events_def[of A F I] (*‹mutual_indep_events A F I = (A ∈ events ∧ F ` I ⊆ events ∧ (∀J⊆I. J ≠ {} ⟶ prob (A ∩ ⋂ (F ` J)) = prob A * prob (⋂ (F ` J))))›*) by auto lemma mutual_indep_ev_singleton_event: assumes "mutual_indep_events A F I" assumes "B ∈ F ` I" shows"indep_event A B" proof (-) (*goal: ‹indep_event (A::'a::type set) (B::'a::type set)›*) obtain J where beq: "B = F J" and "J ∈ I" (*goal: ‹(⋀J::nat. ⟦(B::'a::type set) = (F::nat ⇒ 'a::type set) J; J ∈ (I::nat set)⟧ ⟹ thesis::bool) ⟹ thesis›*) using assms(2) (*‹B ∈ F ` I›*) by blast then have "{J} ⊆ I" and "finite {J}" and "{J} ≠ {}" apply - (*goals: 1. ‹⟦B = F J; J ∈ I⟧ ⟹ {J} ⊆ I› 2. ‹⟦B = F J; J ∈ I⟧ ⟹ finite {J}› 3. ‹⟦B = F J; J ∈ I⟧ ⟹ {J} ≠ {}› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*proven 3 subgoals*) . moreover have "B = ⋂ (F ` {J})" using beq (*‹B = F J›*) by simp ultimately show "?thesis" (*goal: ‹indep_event A B›*) using mutual_indep_event_defD (*‹⟦mutual_indep_events ?A ?F ?I; finite ?J; ?J ⊆ ?I; ?J ≠ {}⟧ ⟹ indep_event ?A (⋂ (?F ` ?J))›*) assms(1) (*‹mutual_indep_events A F I›*) by meson qed lemma mutual_indep_ev_singleton_event2: assumes "mutual_indep_events A F I" assumes "i ∈ I" shows"indep_event A (F i)" using mutual_indep_event_defD[of A F I "{i}"] (*‹⟦mutual_indep_events A F I; finite {i}; {i} ⊆ I; {i} ≠ {}⟧ ⟹ indep_event A (⋂ (F ` {i}))›*) assms (*‹mutual_indep_events A F I› ‹(i::nat) ∈ (I::nat set)›*) by auto lemma mutual_indep_iff: shows "mutual_indep_events A F I ⟷ mutual_indep_set A (F ` I)" proof (intro iffI (*‹⟦?P ⟹ ?Q; ?Q ⟹ ?P⟧ ⟹ ?P = ?Q›*) mutual_indep_setI (*‹⟦?A ∈ events; ?S ⊆ events; ⋀T. ⟦T ⊆ ?S; T ≠ {}⟧ ⟹ prob (?A ∩ ⋂ T) = prob ?A * prob (⋂ T)⟧ ⟹ mutual_indep_set ?A ?S›*) mutual_indep_eventsI (*‹⟦?A ∈ events; ?F ` ?I ⊆ events; ⋀J. ⟦J ⊆ ?I; J ≠ {}⟧ ⟹ prob (?A ∩ ⋂ (?F ` J)) = prob ?A * prob (⋂ (?F ` J))⟧ ⟹ mutual_indep_events ?A ?F ?I›*)) (*goals: 1. ‹mutual_indep_events A F I ⟹ A ∈ events› 2. ‹mutual_indep_events A F I ⟹ F ` I ⊆ events› 3. ‹⋀T. ⟦mutual_indep_events A F I; T ⊆ F ` I; T ≠ {}⟧ ⟹ prob (A ∩ ⋂ T) = prob A * prob (⋂ T)› 4. ‹mutual_indep_set A (F ` I) ⟹ A ∈ events› 5. ‹mutual_indep_set A (F ` I) ⟹ F ` I ⊆ events› 6. ‹⋀J. ⟦mutual_indep_set A (F ` I); J ⊆ I; J ≠ {}⟧ ⟹ prob (A ∩ ⋂ (F ` J)) = prob A * prob (⋂ (F ` J))›*) show "mutual_indep_events A F I ⟹ A ∈ events" using mutual_indep_eventsD2 (*‹mutual_indep_events ?A ?F ?I ⟹ ?A ∈ events›*) by simp show "mutual_indep_set A (F ` I) ⟹ A ∈ events" using mutual_indep_setD2 (*‹mutual_indep_set ?A ?S ⟹ ?A ∈ events›*) by simp show "mutual_indep_events A F I ⟹ F ` I ⊆ events" using mutual_indep_eventsD3 (*‹mutual_indep_events ?A ?F ?I ⟹ ?F ` ?I ⊆ events›*) by simp show "mutual_indep_set A (F ` I) ⟹ F ` I ⊆ events" using mutual_indep_setD3 (*‹mutual_indep_set ?A ?S ⟹ ?S ⊆ events›*) by simp show "⋀T. mutual_indep_events A F I ⟹ T ⊆ F ` I ⟹ T ≠ {} ⟹ prob (A ∩ ⋂ T) = prob A * prob (⋂ T)" using mutual_indep_eventsD (*‹⟦mutual_indep_events ?A ?F ?I; ?J ⊆ ?I; ?J ≠ {}⟧ ⟹ prob (?A ∩ ⋂ (?F ` ?J)) = prob ?A * prob (⋂ (?F ` ?J))›*) by (metis empty_is_image (*‹({} = ?f ` ?A) = (?A = {})›*) subset_imageE (*‹⟦?B ⊆ ?f ` ?A; ⋀C. ⟦C ⊆ ?A; ?B = ?f ` C⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*)) show "⋀J. mutual_indep_set A (F ` I) ⟹ J ⊆ I ⟹ J ≠ {} ⟹ prob (A ∩ ⋂ (F ` J)) = prob A * prob (⋂ (F ` J))" using mutual_indep_setD (*‹⟦mutual_indep_set ?A ?S; ?T ⊆ ?S; ?T ≠ {}⟧ ⟹ prob (?A ∩ ⋂ ?T) = prob ?A * prob (⋂ ?T)›*) by (simp add: image_mono (*‹?A ⊆ ?B ⟹ ?f ` ?A ⊆ ?f ` ?B›*)) qed lemma mutual_indep_ev_cond: assumes "A ∈ events" and "F ` J ⊆ events" and "finite J" and "mutual_indep_events A F I" and "J ⊆ I" and "J ≠ {}" and "prob (⋂(F `J)) ≠ 0" shows "𝒫(A |(⋂(F ` J))) = prob A" proof (-) (*goal: ‹𝒫(A::'a::type set | ⋂ ((F::nat ⇒ 'a::type set) ` (J::nat set))) = prob A›*) have "⋂(F ` J) ∈ events" using assms (*‹(A::'a::type set) ∈ events› ‹F ` J ⊆ events› ‹finite J› ‹mutual_indep_events A F I› ‹(J::nat set) ⊆ (I::nat set)› ‹(J::nat set) ≠ {}› ‹prob (⋂ (F ` J)) ≠ 0›*) by (simp add: Inter_event_ss (*‹⟦finite ?A; ?A ⊆ events; ?A ≠ {}⟧ ⟹ ⋂ ?A ∈ events›*)) then have "𝒫(A | (⋂(F ` J))) = prob ((⋂(F ` J)) ∩ A)/prob(⋂(F ` J))" using cond_prob_ev_def (*‹⟦?A ∈ events; ?B ∈ events⟧ ⟹ 𝒫(?B | ?A) = prob (?A ∩ ?B) / prob ?A›*) assms(1) (*‹A ∈ events›*) by blast also (*calculation: ‹𝒫(A | ⋂ (F ` J)) = prob (⋂ (F ` J) ∩ A) / prob (⋂ (F ` J))›*) have "... = prob (A ∩ (⋂(F ` J)))/prob(⋂(F ` J))" by (simp add: inf_commute (*‹?x ⊓ ?y = ?y ⊓ ?x›*)) also (*calculation: ‹𝒫(A | ⋂ (F ` J)) = prob (A ∩ ⋂ (F ` J)) / prob (⋂ (F ` J))›*) have "... = prob A * prob (⋂(F ` J))/prob(⋂(F ` J))" using assms (*‹A ∈ events› ‹F ` J ⊆ events› ‹finite J› ‹mutual_indep_events A F I› ‹(J::nat set) ⊆ (I::nat set)› ‹J ≠ {}› ‹prob (⋂ (F ` J)) ≠ 0›*) mutual_indep_eventsD (*‹⟦mutual_indep_events (?A::'a set) (?F::nat ⇒ 'a set) (?I::nat set); (?J::nat set) ⊆ ?I; ?J ≠ {}⟧ ⟹ prob (?A ∩ ⋂ (?F ` ?J)) = prob ?A * prob (⋂ (?F ` ?J))›*) by auto finally (*calculation: ‹𝒫(A | ⋂ (F ` J)) = prob A * prob (⋂ (F ` J)) / prob (⋂ (F ` J))›*) show "?thesis" (*goal: ‹𝒫(A | ⋂ (F ` J)) = prob A›*) using assms(7) (*‹prob (⋂ (F ` J)) ≠ 0›*) by simp qed lemma mutual_indep_ev_cond_full: assumes "A ∈ events" and "F ` I ⊆ events" and "finite I" and "mutual_indep_events A F I" and "I ≠ {}" and "prob (⋂(F ` I)) ≠ 0" shows "𝒫(A |(⋂(F `I))) = prob A" using mutual_indep_ev_cond[of A F I I] (*‹⟦A ∈ events; F ` I ⊆ events; finite I; mutual_indep_events A F I; I ⊆ I; I ≠ {}; prob (⋂ (F ` I)) ≠ 0⟧ ⟹ 𝒫(A | ⋂ (F ` I)) = prob A›*) assms (*‹A ∈ events› ‹F ` I ⊆ events› ‹finite I› ‹mutual_indep_events A F I› ‹I ≠ {}› ‹prob (⋂ (F ` I)) ≠ 0›*) by auto lemma mutual_indep_ev_cond_single: assumes "A ∈ events" and "B ∈ events" and "mutual_indep_events A F I" and "B ∈ F ` I" and "prob B ≠ 0" shows "𝒫(A |B) = prob A" proof (-) (*goal: ‹𝒫(A | B) = prob A›*) obtain i where "B = F i" and "i ∈ I" (*goal: ‹(⋀i. ⟦B = F i; i ∈ I⟧ ⟹ thesis) ⟹ thesis›*) using assms (*‹(A::'a::type set) ∈ events› ‹B ∈ events› ‹mutual_indep_events (A::'a set) (F::nat ⇒ 'a set) (I::nat set)› ‹B ∈ F ` I› ‹prob B ≠ 0›*) by blast then show "?thesis" (*goal: ‹𝒫(A | B) = prob A›*) using mutual_indep_ev_cond[of "A" F "{i}" I] (*‹⟦A ∈ events; F ` {i} ⊆ events; finite {i}; mutual_indep_events A F I; {i} ⊆ I; {i} ≠ {}; prob (⋂ (F ` {i})) ≠ 0⟧ ⟹ 𝒫(A | ⋂ (F ` {i})) = prob A›*) assms (*‹A ∈ events› ‹B ∈ events› ‹mutual_indep_events (A::'a set) (F::nat ⇒ 'a set) (I::nat set)› ‹B ∈ F ` I› ‹prob B ≠ 0›*) by auto qed lemma mutual_indep_ev_empty: "A ∈ events ⟹ mutual_indep_events A F {}" using mutual_indep_eventsI (*‹⟦(?A::'a::type set) ∈ events; (?F::nat ⇒ 'a::type set) ` (?I::nat set) ⊆ events; ⋀J::nat set. ⟦J ⊆ ?I; J ≠ {}⟧ ⟹ prob (?A ∩ ⋂ (?F ` J)) = prob ?A * prob (⋂ (?F ` J))⟧ ⟹ mutual_indep_events ?A ?F ?I›*) by auto lemma not_mutual_indep_ev_itself: assumes "prob A > 0" and "prob A < 1" and "A = F i" shows "¬ mutual_indep_events A F {i}" proof (rule ccontr (*‹(¬ (?P::bool) ⟹ False) ⟹ ?P›*)) (*goal: ‹¬ ¬ mutual_indep_events (A::'a set) (F::nat ⇒ 'a set) {i::nat} ⟹ False›*) assume "¬ ¬ mutual_indep_events A F {i}" (*‹¬ ¬ mutual_indep_events (A::'a set) (F::nat ⇒ 'a set) {i::nat}›*) then have "mutual_indep_events A F {i}" by simp then have "⋀ J . J ⊆ {i} ⟹ J ≠ {} ⟹ prob (A ∩ (⋂ (F ` J))) = prob A * prob (⋂(F ` J))" using mutual_indep_eventsD (*‹⟦mutual_indep_events ?A ?F ?I; ?J ⊆ ?I; ?J ≠ {}⟧ ⟹ prob (?A ∩ ⋂ (?F ` ?J)) = prob ?A * prob (⋂ (?F ` ?J))›*) by simp then have eq: "prob (A ∩ (⋂ (F `{i}))) = prob A * prob (⋂(F ` {i}))" by blast have "prob (A ∩ (⋂(F `{i}))) = prob A" using assms(3) (*‹A = F i›*) by simp moreover have "prob A * (prob (⋂ {A})) = (prob A)^2" by (simp add: power2_eq_square (*‹?a² = ?a * ?a›*)) ultimately show False using eq (*‹prob (A ∩ ⋂ (F ` {i})) = prob A * prob (⋂ (F ` {i}))›*) assms (*‹0 < prob A› ‹prob A < 1› ‹A = F i›*) by auto qed lemma is_mutual_indep_ev_itself: assumes "A ∈ events" and "A = F i" assumes "prob A = 0 ∨ prob A = 1" shows "mutual_indep_events A F {i}" proof (intro mutual_indep_eventsI (*‹⟦(?A::'a set) ∈ events; (?F::nat ⇒ 'a set) ` (?I::nat set) ⊆ events; ⋀J::nat set. ⟦J ⊆ ?I; J ≠ {}⟧ ⟹ prob (?A ∩ ⋂ (?F ` J)) = prob ?A * prob (⋂ (?F ` J))⟧ ⟹ mutual_indep_events ?A ?F ?I›*)) (*goals: 1. ‹(A::'a set) ∈ events› 2. ‹(F::nat ⇒ 'a set) ` {i::nat} ⊆ events› 3. ‹⋀J::nat set. ⟦J ⊆ {i::nat}; J ≠ {}⟧ ⟹ prob ((A::'a set) ∩ ⋂ ((F::nat ⇒ 'a set) ` J)) = prob A * prob (⋂ (F ` J))›*) show "A ∈ events" "F ` {i} ⊆ events" using assms(1) (*‹A ∈ events›*) assms(2) (*‹A = F i›*) apply - (*goals: 1. ‹⟦A ∈ events; A = F i⟧ ⟹ A ∈ events› 2. ‹⟦A ∈ events; A = F i⟧ ⟹ F ` {i} ⊆ events› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . fix J assume "J ⊆ {i}" and "J ≠ {}" (*‹(J::nat set) ⊆ {i::nat}› ‹(J::nat set) ≠ {}›*) then have teq: "J = {i}" by auto have "prob (A ∩ (⋂(F `{i}))) = prob A" using assms(2) (*‹A = F i›*) by simp moreover have "prob A * (prob (⋂ (F `{i}))) = (prob A)^2" using assms(2) (*‹A = F i›*) by (simp add: power2_eq_square (*‹?a² = ?a * ?a›*)) ultimately show "prob (A ∩ ⋂ (F ` J)) = prob A * prob (⋂ (F ` J))" using teq (*‹J = {i}›*) assms (*‹A ∈ events› ‹A = F i› ‹prob A = 0 ∨ prob A = 1›*) by auto qed lemma mutual_indep_ev_singleton: assumes "indep_event A (F i)" shows "mutual_indep_events A F {i}" using indep_eventD_ev1 (*‹indep_event ?A ?B ⟹ ?A ∈ events›*) indep_eventD_ev2 (*‹indep_event ?A ?B ⟹ ?B ∈ events›*) assms (*‹indep_event A (F i)›*) apply (intro mutual_ev_indep_event_defI (*‹⟦?A ∈ events; ?F ` ?I ⊆ events; ⋀J. ⟦J ⊆ ?I; J ≠ {}⟧ ⟹ indep_event ?A (⋂ (?F ` J))⟧ ⟹ mutual_indep_events ?A ?F ?I›*)) (*goals: 1. ‹⟦⋀(A::'a::type set) B::'a::type set. indep_event A B ⟹ A ∈ events; ⋀(A::'a::type set) B::'a::type set. indep_event A B ⟹ B ∈ events; indep_event (A::'a::type set) ((F::nat ⇒ 'a::type set) (i::nat))⟧ ⟹ A ∈ events› 2. ‹⟦⋀(A::'a::type set) B::'a::type set. indep_event A B ⟹ A ∈ events; ⋀(A::'a::type set) B::'a::type set. indep_event A B ⟹ B ∈ events; indep_event (A::'a::type set) ((F::nat ⇒ 'a::type set) (i::nat))⟧ ⟹ F ` {i} ⊆ events› 3. ‹⋀J::nat set. ⟦⋀(A::'a::type set) B::'a::type set. indep_event A B ⟹ A ∈ events; ⋀(A::'a::type set) B::'a::type set. indep_event A B ⟹ B ∈ events; indep_event (A::'a::type set) ((F::nat ⇒ 'a::type set) (i::nat)); J ⊆ {i}; J ≠ {}⟧ ⟹ indep_event A (⋂ (F ` J))› discuss goal 1*) apply (simp add: subset_singleton_iff (*‹(?X ⊆ {?a}) = (?X = {} ∨ ?X = {?a})›*)) (*discuss goal 2*) apply (simp add: subset_singleton_iff (*‹(?X ⊆ {?a}) = (?X = {} ∨ ?X = {?a})›*)) (*discuss goal 3*) apply (simp add: subset_singleton_iff (*‹((?X::?'a::type set) ⊆ {?a::?'a::type}) = (?X = {} ∨ ?X = {?a})›*)) (*proven 3 subgoals*) . lemma mutual_indep_ev_one_compl: assumes "mutual_indep_events A F I" assumes "finite I" assumes "i ∈ I" assumes "space M - F i = F j" shows "mutual_indep_events A F ({j} ∪ I)" proof (intro mutual_ev_indep_event_defI (*‹⟦(?A::'a set) ∈ events; (?F::nat ⇒ 'a set) ` (?I::nat set) ⊆ events; ⋀J::nat set. ⟦J ⊆ ?I; J ≠ {}⟧ ⟹ indep_event ?A (⋂ (?F ` J))⟧ ⟹ mutual_indep_events ?A ?F ?I›*)) (*goals: 1. ‹A ∈ events› 2. ‹F ` ({j} ∪ I) ⊆ events› 3. ‹⋀J. ⟦J ⊆ {j} ∪ I; J ≠ {}⟧ ⟹ indep_event A (⋂ (F ` J))›*) show "A ∈ events" using assms(1) (*‹mutual_indep_events A F I›*) mutual_indep_setD2 (*‹mutual_indep_set ?A ?S ⟹ ?A ∈ events›*) by auto next (*goals: 1. ‹F ` ({j} ∪ I) ⊆ events› 2. ‹⋀J. ⟦J ⊆ {j} ∪ I; J ≠ {}⟧ ⟹ indep_event A (⋂ (F ` J))›*) show "F ` ({j} ∪ I) ⊆ events" using assms(1) (*‹mutual_indep_events (A::'a set) (F::nat ⇒ 'a set) (I::nat set)›*) assms(2) (*‹finite I›*) mutual_indep_eventsD3 (*‹mutual_indep_events ?A ?F ?I ⟹ ?F ` ?I ⊆ events›*) assms(3) (*‹i ∈ I›*) assms(4) (*‹space M - F i = F j›*) by (metis image_insert (*‹(?f::?'b ⇒ ?'a) ` insert (?a::?'b) (?B::?'b set) = insert (?f ?a) (?f ` ?B)›*) image_subset_iff (*‹((?f::?'b ⇒ ?'a) ` (?A::?'b set) ⊆ (?B::?'a set)) = (∀x::?'b∈?A. ?f x ∈ ?B)›*) insert_is_Un (*‹insert (?a::?'a) (?A::?'a set) = {?a} ∪ ?A›*) insert_subset (*‹(insert (?x::?'a) (?A::?'a set) ⊆ (?B::?'a set)) = (?x ∈ ?B ∧ ?A ⊆ ?B)›*) sets.compl_sets (*‹(?a::?'a set) ∈ sets (?M::?'a measure) ⟹ space ?M - ?a ∈ sets ?M›*)) next (*goal: ‹⋀J. ⟦J ⊆ {j} ∪ I; J ≠ {}⟧ ⟹ indep_event A (⋂ (F ` J))›*) fix J assume jss: "J ⊆ {j} ∪ I" (*‹(J::nat set) ⊆ {j::nat} ∪ (I::nat set)›*) assume tne: "J ≠ {}" (*‹(J::nat set) ≠ {}›*) let ?J' = "J - {j}" show "indep_event A (⋂ (F ` J))" proof (cases "?J' = {}") (*goals: 1. ‹J - {j} = {} ⟹ indep_event A (⋂ (F ` J))› 2. ‹J - {j} ≠ {} ⟹ indep_event A (⋂ (F ` J))›*) case True (*‹(J::nat set) - {j::nat} = {}›*) then have "J = {j}" using tne (*‹J ≠ {}›*) by blast moreover have "indep_event A (F i)" using assms(1) (*‹mutual_indep_events A F I›*) assms (*‹mutual_indep_events A F I› ‹finite I› ‹(i::nat) ∈ (I::nat set)› ‹space M - F i = F j›*) mutual_indep_ev_singleton_event2 (*‹⟦mutual_indep_events ?A ?F ?I; ?i ∈ ?I⟧ ⟹ indep_event ?A (?F ?i)›*) by simp ultimately show "?thesis" (*goal: ‹indep_event A (⋂ (F ` J))›*) using indep_event_one_compl (*‹indep_event (?A::'a set) (?B::'a set) ⟹ indep_event ?A (space (M::'a measure) - ?B)›*) assms(4) (*‹space M - F i = F j›*) by fastforce next (*goal: ‹J - {j} ≠ {} ⟹ indep_event A (⋂ (F ` J))›*) case tne2: False (*‹J - {j} ≠ {}›*) have finT: "finite J" using jss (*‹J ⊆ {j} ∪ I›*) assms(2) (*‹finite I›*) finite_subset (*‹⟦(?A::?'a set) ⊆ (?B::?'a set); finite ?B⟧ ⟹ finite ?A›*) by fast have tss2: "?J' ⊆ I" using jss (*‹J ⊆ {j} ∪ I›*) assms(2) (*‹finite (I::nat set)›*) by auto show "?thesis" (*goal: ‹indep_event (A::'a::type set) (⋂ ((F::nat ⇒ 'a::type set) ` (J::nat set)))›*) proof (cases "j ∈ J") (*goals: 1. ‹j ∈ J ⟹ indep_event A (⋂ (F ` J))› 2. ‹j ∉ J ⟹ indep_event A (⋂ (F ` J))›*) case True (*‹j ∈ J›*) have "?J' ∪ {i} ⊆ I" using assms(3) (*‹i ∈ I›*) tss2 (*‹J - {j} ⊆ I›*) by auto then have "indep_event A (⋂(F ` ?J' ∪ { F i}))" using assms(1) (*‹mutual_indep_events (A::'a set) (F::nat ⇒ 'a set) (I::nat set)›*) mutual_indep_event_defD (*‹⟦mutual_indep_events (?A::'a set) (?F::nat ⇒ 'a set) (?I::nat set); finite (?J::nat set); ?J ⊆ ?I; ?J ≠ {}⟧ ⟹ indep_event ?A (⋂ (?F ` ?J))›*) tne2 (*‹J - {j} ≠ {}›*) finT (*‹finite (J::nat set)›*) assms(2) (*‹finite I›*) finite_subset (*‹⟦(?A::?'a set) ⊆ (?B::?'a set); finite ?B⟧ ⟹ finite ?A›*) by (metis Diff_cancel (*‹?A - ?A = {}›*) Un_Diff_cancel (*‹?A ∪ (?B - ?A) = ?A ∪ ?B›*) Un_absorb (*‹?A ∪ ?A = ?A›*) Un_insert_right (*‹?A ∪ insert ?a ?B = insert ?a (?A ∪ ?B)›*) image_insert (*‹?f ` insert ?a ?B = insert (?f ?a) (?f ` ?B)›*)) moreover have "indep_event A (⋂(F ` ?J'))" using assms(1) (*‹mutual_indep_events A F I›*) mutual_indep_event_defD (*‹⟦mutual_indep_events ?A ?F ?I; finite ?J; ?J ⊆ ?I; ?J ≠ {}⟧ ⟹ indep_event ?A (⋂ (?F ` ?J))›*) finT (*‹finite J›*) finite_subset (*‹⟦?A ⊆ ?B; finite ?B⟧ ⟹ finite ?A›*) tss2 (*‹(J::nat set) - {j::nat} ⊆ (I::nat set)›*) tne2 (*‹J - {j} ≠ {}›*) by auto moreover have "(⋂(F ` ?J' ∪ { F i})) = F i ∩ (⋂(F ` ?J'))" by auto moreover have "F i ∈ events" using assms(3) (*‹i ∈ I›*) assms(1) (*‹mutual_indep_events A F I›*) mutual_indep_eventsD3 (*‹mutual_indep_events ?A ?F ?I ⟹ ?F ` ?I ⊆ events›*) by simp ultimately have "indep_event A (F j ∩ (⋂(F ` ?J')))" using indep_event_compl_inter[of A "⋂(F ` ?J')" "F i"] (*‹⟦indep_event A (⋂ (F ` (J - {j}))); F i ∈ events; indep_event A (F i ∩ ⋂ (F ` (J - {j})))⟧ ⟹ indep_event A ((space M - F i) ∩ ⋂ (F ` (J - {j})))›*) assms(4) (*‹space M - F i = F j›*) by auto then show "?thesis" (*goal: ‹indep_event A (⋂ (F ` J))›*) using Inter_insert (*‹⋂ (insert ?a ?B) = ?a ∩ ⋂ ?B›*) True (*‹(j::nat) ∈ (J::nat set)›*) insert_Diff (*‹?a ∈ ?A ⟹ insert ?a (?A - {?a}) = ?A›*) by (metis image_insert (*‹?f ` insert ?a ?B = insert (?f ?a) (?f ` ?B)›*)) next (*goal: ‹j ∉ J ⟹ indep_event A (⋂ (F ` J))›*) case False (*‹j ∉ J›*) then have "J ⊆ I" using jss (*‹J ⊆ {j} ∪ I›*) by auto then show "?thesis" (*goal: ‹indep_event A (⋂ (F ` J))›*) using assms(1) (*‹mutual_indep_events A F I›*) mutual_indep_event_defD (*‹⟦mutual_indep_events ?A ?F ?I; finite ?J; ?J ⊆ ?I; ?J ≠ {}⟧ ⟹ indep_event ?A (⋂ (?F ` ?J))›*) finT (*‹finite J›*) tne (*‹(J::nat set) ≠ {}›*) by auto qed qed qed lemma mutual_indep_events_update_compl: assumes "mutual_indep_events X F S" assumes "S = A ∪ B" assumes "A ∩ B = {}" assumes "finite S" assumes "bij_betw G A A'" assumes "⋀ i. i ∈ A ⟹ F (G i) = space M - F i" shows "mutual_indep_events X F (A' ∪ B)" using assms(2) (*‹S = A ∪ B›*) assms(3) (*‹A ∩ B = {}›*) assms(6) (*‹?i12 ∈ A ⟹ F (G ?i12) = space M - F ?i12›*) assms(5) (*‹bij_betw G A A'›*) proof (induct "card A" arbitrary: A B A') (*goals: 1. ‹⋀A B A'. ⟦0 = card A; S = A ∪ B; A ∩ B = {}; ⋀i. i ∈ A ⟹ F (G i) = space M - F i; bij_betw G A A'⟧ ⟹ mutual_indep_events X F (A' ∪ B)› 2. ‹⋀x A B A'. ⟦⋀A B A'. ⟦x = card A; S = A ∪ B; A ∩ B = {}; ⋀i. i ∈ A ⟹ F (G i) = space M - F i; bij_betw G A A'⟧ ⟹ mutual_indep_events X F (A' ∪ B); Suc x = card A; S = A ∪ B; A ∩ B = {}; ⋀i. i ∈ A ⟹ F (G i) = space M - F i; bij_betw G A A'⟧ ⟹ mutual_indep_events X F (A' ∪ B)›*) case 0 (*‹0 = card A› ‹(S::nat set) = (A::nat set) ∪ (B::nat set)› ‹(A::nat set) ∩ (B::nat set) = {}› ‹(?i12::nat) ∈ (A::nat set) ⟹ (F::nat ⇒ 'a set) ((G::nat ⇒ nat) ?i12) = space (M::'a measure) - F ?i12› ‹bij_betw G A A'›*) then have aempty: "A = {}" using finite_subset (*‹⟦(?A::?'a set) ⊆ (?B::?'a set); finite ?B⟧ ⟹ finite ?A›*) assms(4) (*‹finite S›*) by simp then have "A' = {}" using "0.prems"(4) (*‹bij_betw G A A'›*) by (metis all_not_in_conv (*‹(∀x. x ∉ ?A) = (?A = {})›*) bij_betwE (*‹bij_betw ?f ?A ?B ⟹ ∀a∈?A. ?f a ∈ ?B›*) bij_betw_inv (*‹bij_betw ?f ?A ?B ⟹ ∃g. bij_betw g ?B ?A›*)) then show "?case" (*goal: ‹mutual_indep_events X F (A' ∪ B)›*) using assms(1) (*‹mutual_indep_events (X::'a set) (F::nat ⇒ 'a set) (S::nat set)›*) using "0.prems"(1) (*‹S = A ∪ B›*) aempty (*‹A = {}›*) by simp next (*goal: ‹⋀x A B A'. ⟦⋀A B A'. ⟦x = card A; S = A ∪ B; A ∩ B = {}; ⋀i. i ∈ A ⟹ F (G i) = space M - F i; bij_betw G A A'⟧ ⟹ mutual_indep_events X F (A' ∪ B); Suc x = card A; S = A ∪ B; A ∩ B = {}; ⋀i. i ∈ A ⟹ F (G i) = space M - F i; bij_betw G A A'⟧ ⟹ mutual_indep_events X F (A' ∪ B)›*) case (Suc x) (*‹⟦x = card ?A12; S = ?A12 ∪ ?B12; ?A12 ∩ ?B12 = {}; ⋀i. i ∈ ?A12 ⟹ F (G i) = space M - F i; bij_betw G ?A12 ?A'12⟧ ⟹ mutual_indep_events X F (?A'12 ∪ ?B12)› ‹Suc x = card A› ‹S = A ∪ B› ‹(A::nat set) ∩ (B::nat set) = {}› ‹?i12 ∈ A ⟹ F (G ?i12) = space M - F ?i12› ‹bij_betw G A A'›*) then obtain a and C where aeq: "C = A - {a}" and ain: "a ∈ A" (*goal: ‹(⋀C a. ⟦C = A - {a}; a ∈ A⟧ ⟹ thesis) ⟹ thesis›*) by fastforce then have xcard: "card C = x" using Suc(2) (*‹Suc x = card A›*) Suc(3) (*‹S = A ∪ B›*) assms(4) (*‹finite S›*) by auto let ?C' = "A' - {G a}" have compl: "(⋀i. i ∈ C ⟹ F (G i) = space M - F i)" using Suc.prems (*‹(S::nat set) = (A::nat set) ∪ (B::nat set)› ‹A ∩ B = {}› ‹?i12 ∈ A ⟹ F (G ?i12) = space M - F ?i12› ‹bij_betw G A A'›*) aeq (*‹C = A - {a}›*) by simp have bb: "bij_betw G C ?C'" using Suc.prems(4) (*‹bij_betw G A A'›*) aeq (*‹C = A - {a}›*) bij_betw_remove[of G A A' a] (*‹⟦bij_betw G A A'; a ∈ A⟧ ⟹ bij_betw G (A - {a}) (A' - {G a})›*) ain (*‹(a::nat) ∈ (A::nat set)›*) by simp let ?B' = "B ∪ {a}" have "S = C ∪ ?B'" using aeq (*‹(C::nat set) = (A::nat set) - {a::nat}›*) Suc.prems (*‹S = A ∪ B› ‹A ∩ B = {}› ‹?i12 ∈ A ⟹ F (G ?i12) = space M - F ?i12› ‹bij_betw G A A'›*) ain (*‹a ∈ A›*) by auto moreover have "C ∩ ?B' = {}" using ain (*‹a ∈ A›*) Suc.prems(2) (*‹A ∩ B = {}›*) aeq (*‹C = A - {a}›*) by auto ultimately have ies: "mutual_indep_events X F (?C' ∪ ?B')" using Suc.hyps(1)[of "C" ?B'] (*‹⟦x = card C; S = C ∪ (B ∪ {a}); C ∩ (B ∪ {a}) = {}; ⋀i. i ∈ C ⟹ F (G i) = space M - F i; bij_betw G C ?A'12⟧ ⟹ mutual_indep_events X F (?A'12 ∪ (B ∪ {a}))›*) xcard (*‹card (C::nat set) = (x::nat)›*) compl (*‹?i12 ∈ C ⟹ F (G ?i12) = space M - F ?i12›*) bb (*‹bij_betw (G::nat ⇒ nat) (C::nat set) ((A'::nat set) - {G (a::nat)})›*) by auto then have "a ∈ A ∪ B" using ain (*‹a ∈ A›*) by auto then show "?case" (*goal: ‹mutual_indep_events X F (A' ∪ B)›*) proof (cases "(A ∪ B) - {a} = {}") (*goals: 1. ‹⟦a ∈ A ∪ B; A ∪ B - {a} = {}⟧ ⟹ mutual_indep_events X F (A' ∪ B)› 2. ‹⟦a ∈ A ∪ B; A ∪ B - {a} ≠ {}⟧ ⟹ mutual_indep_events X F (A' ∪ B)›*) case True (*‹A ∪ B - {a} = {}›*) then have aeq: "A = {a}" and beq: "B = {}" using Suc.prems (*‹S = A ∪ B› ‹(A::nat set) ∩ (B::nat set) = {}› ‹?i12 ∈ A ⟹ F (G ?i12) = space M - F ?i12› ‹bij_betw G A A'›*) ain (*‹a ∈ A›*) apply - (*goals: 1. ‹⟦(A::nat set) ∪ (B::nat set) - {a::nat} = {}; (S::nat set) = A ∪ B; A ∩ B = {}; ⋀i::nat. i ∈ A ⟹ (F::nat ⇒ 'a set) ((G::nat ⇒ nat) i) = space (M::'a measure) - F i; bij_betw G A (A'::nat set); a ∈ A⟧ ⟹ A = {a}› 2. ‹⟦(A::nat set) ∪ (B::nat set) - {a::nat} = {}; (S::nat set) = A ∪ B; A ∩ B = {}; ⋀i::nat. i ∈ A ⟹ (F::nat ⇒ 'a set) ((G::nat ⇒ nat) i) = space (M::'a measure) - F i; bij_betw G A (A'::nat set); a ∈ A⟧ ⟹ B = {}› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . then have "A' = {G a}" using aeq (*‹A = {a}›*) Suc.prems (*‹S = A ∪ B› ‹A ∩ B = {}› ‹?i12 ∈ A ⟹ F (G ?i12) = space M - F ?i12› ‹bij_betw G A A'›*) ain (*‹(a::nat) ∈ (A::nat set)›*) aeq (*‹A = {a}›*) bb (*‹bij_betw G C (A' - {G a})›*) bij_betwE (*‹bij_betw ?f ?A ?B ⟹ ∀a∈?A. ?f a ∈ ?B›*) bij_betw_empty1 (*‹bij_betw ?f {} ?A ⟹ ?A = {}›*) insert_Diff (*‹?a ∈ ?A ⟹ insert ?a (?A - {?a}) = ?A›*) by (metis Un_Int_eq( (*‹(?T::?'a set) ∩ ((?S::?'a set) ∪ ?T) = ?T›*) 4) Un_commute (*‹(?A::?'a set) ∪ (?B::?'a set) = ?B ∪ ?A›*) ‹C ∩ (B ∪ {a}) = {}› ‹S = C ∪ (B ∪ {a})›) moreover have "F (G a) = space M - (F a)" using Suc.prems (*‹S = A ∪ B› ‹A ∩ B = {}› ‹?i12 ∈ A ⟹ F (G ?i12) = space M - F ?i12› ‹bij_betw G A A'›*) ain (*‹a ∈ A›*) by auto moreover have "indep_event X (F a)" using mutual_indep_ev_singleton_event (*‹⟦mutual_indep_events ?A ?F ?I; ?B ∈ ?F ` ?I⟧ ⟹ indep_event ?A ?B›*) ies (*‹mutual_indep_events (X::'a::type set) (F::nat ⇒ 'a::type set) ((A'::nat set) - {(G::nat ⇒ nat) (a::nat)} ∪ ((B::nat set) ∪ {a}))›*) by auto ultimately show "?thesis" (*goal: ‹mutual_indep_events X F (A' ∪ B)›*) using mutual_indep_ev_singleton (*‹indep_event ?A (?F ?i) ⟹ mutual_indep_events ?A ?F {?i}›*) indep_event_one_compl (*‹indep_event ?A ?B ⟹ indep_event ?A (space M - ?B)›*) beq (*‹B = {}›*) by auto next (*goal: ‹⟦a ∈ A ∪ B; A ∪ B - {a} ≠ {}⟧ ⟹ mutual_indep_events X F (A' ∪ B)›*) case False (*‹A ∪ B - {a} ≠ {}›*) have un: "A' ∪ B = ?C' ∪ {G a} ∪ (?B' - {a})" using Suc.prems (*‹S = A ∪ B› ‹A ∩ B = {}› ‹(?i12::nat) ∈ (A::nat set) ⟹ (F::nat ⇒ 'a set) ((G::nat ⇒ nat) ?i12) = space (M::'a measure) - F ?i12› ‹bij_betw G A A'›*) aeq (*‹(C::nat set) = (A::nat set) - {a::nat}›*) by (metis Diff_insert_absorb (*‹?x ∉ ?A ⟹ insert ?x ?A - {?x} = ?A›*) Un_empty_right (*‹?A ∪ {} = ?A›*) Un_insert_right (*‹?A ∪ insert ?a ?B = insert ?a (?A ∪ ?B)›*) ain (*‹a ∈ A›*) bij_betwE (*‹bij_betw ?f ?A ?B ⟹ ∀a∈?A. ?f a ∈ ?B›*) disjoint_iff_not_equal (*‹(?A ∩ ?B = {}) = (∀x∈?A. ∀y∈?B. x ≠ y)›*) insert_Diff (*‹?a ∈ ?A ⟹ insert ?a (?A - {?a}) = ?A›*)) moreover have "?B' - {a} ⊆ ?B'" by auto moreover have "?B' - {a} ⊆ ?C' ∪ {G a} ∪ (?B')" by auto moreover have "?C' ∪ {G a} ⊆ ?C' ∪ {G a} ∪ (?B')" by auto ultimately have ss: "A' ∪ B ⊆ {G a} ∪ (?C' ∪ ?B')" using Un_least (*‹⟦?A ⊆ ?C; ?B ⊆ ?C⟧ ⟹ ?A ∪ ?B ⊆ ?C›*) by auto have "a ∈ ?C' ∪ ?B'" using aeq (*‹C = A - {a}›*) by auto then have ie: "mutual_indep_events X F ({G a} ∪ (?C' ∪ ?B'))" using mutual_indep_ev_one_compl[of X F "(?C' ∪ ?B')" "a" "G a"] (*‹⟦mutual_indep_events X F (A' - {G a} ∪ (B ∪ {a})); finite (A' - {G a} ∪ (B ∪ {a})); a ∈ A' - {G a} ∪ (B ∪ {a}); space M - F a = F (G a)⟧ ⟹ mutual_indep_events X F ({G a} ∪ (A' - {G a} ∪ (B ∪ {a})))›*) using Suc.prems(3) (*‹?i12 ∈ A ⟹ F (G ?i12) = space M - F ?i12›*) by (metis ‹S = C ∪ (B ∪ {a})› ain (*‹a ∈ A›*) assms( (*‹finite S›*) 4) bb (*‹bij_betw G C (A' - {G a})›*) bij_betw_finite (*‹bij_betw ?f ?A ?B ⟹ finite ?A = finite ?B›*) ies (*‹mutual_indep_events X F (A' - {G a} ∪ (B ∪ {a}))›*) infinite_Un (*‹infinite (?S ∪ ?T) = (infinite ?S ∨ infinite ?T)›*)) then show "?thesis" (*goal: ‹mutual_indep_events X F (A' ∪ B)›*) using mutual_indep_ev_subset (*‹⟦mutual_indep_events (?A::'a set) (?F::nat ⇒ 'a set) (?I::nat set); (?J::nat set) ⊆ ?I⟧ ⟹ mutual_indep_events ?A ?F ?J›*) ss (*‹A' ∪ B ⊆ {G a} ∪ (A' - {G a} ∪ (B ∪ {a}))›*) by auto qed qed lemma mutual_indep_ev_events_compl: assumes "finite S" assumes "mutual_indep_events A F S" assumes "bij_betw G S S'" assumes "⋀ i. i ∈ S ⟹ F (G i) = space M - F i" shows "mutual_indep_events A F S'" using mutual_indep_events_update_compl[of A F S S "{}"] (*‹⟦mutual_indep_events (A::'a set) (F::nat ⇒ 'a set) (S::nat set); S = S ∪ {}; S ∩ {} = {}; finite S; bij_betw (?G::nat ⇒ nat) S (?A'::nat set); ⋀i::nat. i ∈ S ⟹ F (?G i) = space (M::'a measure) - F i⟧ ⟹ mutual_indep_events A F (?A' ∪ {})›*) assms (*‹finite S› ‹mutual_indep_events (A::'a::type set) (F::nat ⇒ 'a::type set) (S::nat set)› ‹bij_betw G S S'› ‹?i12 ∈ S ⟹ F (G ?i12) = space M - F ?i12›*) by auto text ‹Important lemma on relation between independence and mutual independence of a set › lemma mutual_indep_ev_set_all: assumes "F ` I ⊆ events" assumes "⋀ i. i ∈ I ⟹ (mutual_indep_events (F i) F (I - {i}))" shows "indep_events F I" proof (intro indep_eventsI (*‹⟦⋀i::?'b. i ∈ (?I::?'b set) ⟹ (?F::?'b ⇒ 'a set) i ∈ events; ⋀J::?'b set. ⟦J ⊆ ?I; finite J; J ≠ {}⟧ ⟹ prob (⋂ (?F ` J)) = (∏i::?'b∈J. prob (?F i))⟧ ⟹ indep_events ?F ?I›*)) (*goals: 1. ‹⋀i. i ∈ I ⟹ F i ∈ events› 2. ‹⋀J. ⟦J ⊆ I; finite J; J ≠ {}⟧ ⟹ prob (⋂ (F ` J)) = (∏i∈J. prob (F i))›*) show "⋀i. i ∈ I ⟹ F i ∈ events" using assms(1) (*‹F ` I ⊆ events›*) by auto next (*goal: ‹⋀J::nat set. ⟦J ⊆ (I::nat set); finite J; J ≠ {}⟧ ⟹ prob (⋂ ((F::nat ⇒ 'a set) ` J)) = (∏i::nat∈J. prob (F i))›*) fix J assume ss: "J ⊆ I" and fin: "finite J" and ne: "J ≠ {}" (*‹(J::nat set) ⊆ (I::nat set)› ‹finite (J::nat set)› ‹(J::nat set) ≠ {}›*) from fin (*‹finite (J::nat set)›*) ne (*‹J ≠ {}›*) ss (*‹J ⊆ I›*) show "prob (⋂ (F ` J)) = (∏i∈J. prob (F i))" proof (induct J rule: finite_ne_induct (*‹⟦finite ?F; ?F ≠ {}; ⋀x. ?P {x}; ⋀x F. ⟦finite F; F ≠ {}; x ∉ F; ?P F⟧ ⟹ ?P (insert x F)⟧ ⟹ ?P ?F›*)) (*goals: 1. ‹⋀x::nat. {x} ⊆ (I::nat set) ⟹ prob (⋂ ((F::nat ⇒ 'a set) ` {x})) = (∏i::nat∈{x}. prob (F i))› 2. ‹⋀(x::nat) Fa::nat set. ⟦finite Fa; Fa ≠ {}; x ∉ Fa; Fa ⊆ (I::nat set) ⟹ prob (⋂ ((F::nat ⇒ 'a set) ` Fa)) = (∏i::nat∈Fa. prob (F i)); insert x Fa ⊆ I⟧ ⟹ prob (⋂ (F ` insert x Fa)) = (∏i::nat∈insert x Fa. prob (F i))›*) case (singleton x) (*‹{x} ⊆ I›*) then show "?case" (*goal: ‹prob (⋂ (F ` {x})) = (∏i∈{x}. prob (F i))›*) by simp next (*goal: ‹⋀x Fa. ⟦finite Fa; Fa ≠ {}; x ∉ Fa; Fa ⊆ I ⟹ prob (⋂ (F ` Fa)) = (∏i∈Fa. prob (F i)); insert x Fa ⊆ I⟧ ⟹ prob (⋂ (F ` insert x Fa)) = (∏i∈insert x Fa. prob (F i))›*) case (insert x X) (*‹finite X› ‹X ≠ {}› ‹(x::nat) ∉ (X::nat set)› ‹X ⊆ I ⟹ prob (⋂ (F ` X)) = (∏i∈X. prob (F i))› ‹insert x X ⊆ I›*) then have "mutual_indep_events (F x) F (I - {x})" using assms(2) (*‹?i12 ∈ I ⟹ mutual_indep_events (F ?i12) F (I - {?i12})›*) by simp moreover have "X ⊆ (I - {x})" using insert.prems (*‹insert (x::nat) (X::nat set) ⊆ (I::nat set)›*) insert.hyps (*‹finite X› ‹X ≠ {}› ‹x ∉ X› ‹X ⊆ I ⟹ prob (⋂ (F ` X)) = (∏i∈X. prob (F i))›*) by auto ultimately have "prob (F x ∩ (⋂(F `X))) = prob (F x) * prob (⋂(F ` X))" by (simp add: local.insert( (*‹X ≠ {}›*) 2) mutual_indep_eventsD (*‹⟦mutual_indep_events ?A ?F ?I; ?J ⊆ ?I; ?J ≠ {}⟧ ⟹ prob (?A ∩ ⋂ (?F ` ?J)) = prob ?A * prob (⋂ (?F ` ?J))›*)) then show "?case" (*goal: ‹prob (⋂ (F ` insert x X)) = (∏i∈insert x X. prob (F i))›*) using insert.hyps (*‹finite X› ‹(X::nat set) ≠ {}› ‹x ∉ X› ‹X ⊆ I ⟹ prob (⋂ (F ` X)) = (∏i∈X. prob (F i))›*) insert.prems (*‹insert (x::nat) (X::nat set) ⊆ (I::nat set)›*) by simp qed qed end end
{ "path": "afp-2025-02-12/thys/Lovasz_Local/Indep_Events.thy", "repo": "afp-2025-02-12", "sha": "beea1f945914d4cdd6425ed3a058932495b7249a68cc7cbe2c6421ded2917aa5" }
(* Title: Linear_Algebra_More Author: Richard Schmoetten <richard.schmoetten@ed.ac.uk>, 2024 Maintainer: Richard Schmoetten <richard.schmoetten@ed.ac.uk> *) theory Linear_Algebra_More imports "HOL-Analysis.Analysis" "Smooth_Manifolds.Smooth" Transfer_Cayley_Hamilton begin section ‹Continuity of the determinant (and other maps)› lemma continuous_on_proj: "continuous_on s fst" "continuous_on s snd" (*goals: 1. ‹continuous_on s fst› 2. ‹continuous_on s snd› discuss goal 1*) apply (simp add: continuous_on_fst[OF continuous_on_id] (*‹continuous_on ?s fst›*)) (*discuss goal 2*) apply (simp add: continuous_on_snd[OF continuous_on_id] (*‹continuous_on (?s::(?'b × ?'c) set) snd›*)) (*proven 2 subgoals*) . lemma continuous_on_plus: fixes s::"('a × 'a::topological_monoid_add) set" shows "continuous_on s (λ(x,y). x+y)" by (simp add: continuous_on_add[OF continuous_on_proj] (*‹continuous_on ?s (λx. fst x + snd x)›*) case_prod_beta' (*‹(λ(x, y). ?f x y) = (λx. ?f (fst x) (snd x))›*)) lemma continuous_on_times: fixes s::"('a × 'a::real_normed_algebra) set" shows "continuous_on s (λ(x,y). x*y)" by (simp add: case_prod_beta' (*‹(λ(x, y). ?f x y) = (λx. ?f (fst x) (snd x))›*) continuous_on_mult[OF continuous_on_proj] (*‹continuous_on ?s (λx. fst x * snd x)›*)) lemma continuous_on_times': fixes s::"('a × 'a::topological_monoid_mult) set" shows "continuous_on s (λ(x,y). x*y)" by (simp add: case_prod_beta' (*‹(λ(x::?'a, y::?'b). (?f::?'a ⇒ ?'b ⇒ ?'c) x y) = (λx::?'a × ?'b. ?f (fst x) (snd x))›*) continuous_on_mult'[OF continuous_on_proj] (*‹continuous_on (?A::(?'b × ?'b) set) (λx::?'b × ?'b. fst x * snd x)›*)) text ‹Only functions between ‹real_normed_vector› spaces can be ‹bounded_linear›...› lemma continuous_on_nth_of_vec: fixes s::"('a::real_normed_field,'n::finite)vec set" shows "continuous_on s (λx. x $ n)" by (simp add: bounded_linear_vec_nth (*‹bounded_linear (λx. x $ ?i)›*) linear_continuous_on (*‹bounded_linear ?f ⟹ continuous_on ?s ?f›*)) lemma bounded_linear_mat_ijth[intro]: "bounded_linear (λx. x $ i $ j)" apply standard (*goals: 1. ‹⋀b1 b2. (b1 + b2) $ i $ j = b1 $ i $ j + b2 $ i $ j› 2. ‹⋀r b. (r *⇩R b) $ i $ j = r *⇩R b $ i $ j› 3. ‹∃K. ∀x. norm (x $ i $ j) ≤ norm x * K› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*discuss goal 3*) apply (intro exI[of _ 1] (*‹?P 1 ⟹ ∃x. ?P x›*)) (*goal: ‹∃K::real. ∀x::(('a::real_normed_vector, 'b::finite) vec, 'c::finite) vec. norm (x $ (i::'c::finite) $ (j::'b::finite)) ≤ norm x * K›*) apply (simp add: norm_nth_le (*‹?i ∈ Basis ⟹ norm (?x ∙ ?i) ≤ norm ?x›*)) (*goal: ‹∀x. norm (x $ i $ j) ≤ norm x * 1›*) apply (meson Finite_Cartesian_Product.norm_nth_le (*‹norm (?x $ ?i) ≤ norm ?x›*) dual_order.trans (*‹⟦?b ≤ ?a; ?c ≤ ?b⟧ ⟹ ?c ≤ ?a›*)) (*proven 3 subgoals*) . lemma continuous_on_ijth_of_mat: fixes s::"('a::real_normed_field,'n::finite)square_matrix set" shows "continuous_on s (λx. x $ i $ j)" by (simp add: bounded_linear_mat_ijth (*‹bounded_linear (λx. x $ ?i $ ?j)›*) linear_continuous_on (*‹bounded_linear ?f ⟹ continuous_on ?s ?f›*)) lemma continuous_on_det: fixes s::"('a::real_normed_field,'n::finite)square_matrix set" shows "continuous_on s det" apply (unfold det_def (*‹det ?A = (∑p | p permutes UNIV. of_int (sign p) * (∏i∈UNIV. ?A $ i $ p i))›*)) (*goal: ‹continuous_on s det›*) proof (intro continuous_on_sum (*‹(⋀i. i ∈ ?I ⟹ continuous_on ?S (?f i)) ⟹ continuous_on ?S (λx. ∑i∈?I. ?f i x)›*)) (*goal: ‹⋀p::'n ⇒ 'n. p ∈ {p::'n ⇒ 'n. p permutes UNIV} ⟹ continuous_on (s::(('a, 'n) vec, 'n) vec set) (λx::(('a, 'n) vec, 'n) vec. of_int (sign p) * (∏i::'n∈UNIV. x $ i $ p i))›*) fix p assume "p ∈ {p. p permutes (UNIV::'n set)}" (*‹(p::'n ⇒ 'n) ∈ {p::'n ⇒ 'n. p permutes UNIV}›*) show "continuous_on s (λA. of_int (sign p) * (∏i∈UNIV. A $ i $ p i))" proof (intro continuous_on_mult (*‹⟦continuous_on ?s ?f; continuous_on ?s ?g⟧ ⟹ continuous_on ?s (λx. ?f x * ?g x)›*)) (*goals: 1. ‹continuous_on s (λx. of_int (sign p))› 2. ‹continuous_on s (λx. ∏i∈UNIV. x $ i $ p i)›*) show "continuous_on s (λx. of_int (sign p))" by simp show "continuous_on s (λx. ∏i∈UNIV. x $ i $ p i)" apply (intro continuous_on_prod (*‹(⋀i::?'a::type. i ∈ (?S::?'a::type set) ⟹ continuous_on (?s::?'d::topological_space set) ((?f::?'a::type ⇒ ?'d::topological_space ⇒ ?'c::{real_normed_algebra,comm_ring_1}) i)) ⟹ continuous_on ?s (λx::?'d::topological_space. ∏i::?'a::type∈?S. ?f i x)›*)) (*goal: ‹continuous_on s (λx. ∏i∈UNIV. x $ i $ p i)›*) by (simp add: continuous_on_ijth_of_mat (*‹continuous_on ?s (λx. x $ ?i $ ?j)›*)) qed qed lemma invertible_inv_ex: fixes a::"'a::semiring_1^'n^'n" assumes "invertible a" shows "(matrix_inv a)**a = mat 1" "a**(matrix_inv a) = mat 1" using some_eq_ex (*‹?P (SOME x. ?P x) = (∃x. ?P x)›*) assms (*‹invertible a›*) invertible_def (*‹invertible (?A::((?'a, ?'n) vec, ?'m) vec) = (∃A'::((?'a, ?'m) vec, ?'n) vec. ?A ** A' = mat (1::?'a) ∧ A' ** ?A = mat (1::?'a))›*) matrix_inv_def (*‹matrix_inv (?A::((?'a, ?'n) vec, ?'m) vec) = (SOME A'::((?'a, ?'m) vec, ?'n) vec. ?A ** A' = mat (1::?'a) ∧ A' ** ?A = mat (1::?'a))›*) apply - (*goals: 1. ‹⟦⋀P. P (SOME x. P x) = (∃x. P x); invertible a; ⋀A. invertible A = (∃A'. A ** A' = mat 1 ∧ A' ** A = mat 1); ⋀A. matrix_inv A = (SOME A'. A ** A' = mat 1 ∧ A' ** A = mat 1)⟧ ⟹ matrix_inv a ** a = mat 1› 2. ‹⟦⋀P. P (SOME x. P x) = (∃x. P x); invertible a; ⋀A. invertible A = (∃A'. A ** A' = mat 1 ∧ A' ** A = mat 1); ⋀A. matrix_inv A = (SOME A'. A ** A' = mat 1 ∧ A' ** A = mat 1)⟧ ⟹ a ** matrix_inv a = mat 1› discuss goal 1*) apply ((msorry)[1]) (*discuss goal 2*) apply ((msorry)[1]) (*proven 2 subgoals*) . text ‹ A similar result to the below already exists for fields, see e.g. ‹invertible_left_inverse›. This is more general, as it applies to any semiring (with 1). › lemma invertible_matrix_inv: fixes a::"'a::semiring_1^'n^'n" assumes "invertible a" shows "invertible (matrix_inv a)" using invertible_inv_ex (*‹invertible ?a ⟹ matrix_inv ?a ** ?a = mat 1› ‹invertible ?a ⟹ ?a ** matrix_inv ?a = mat 1›*) assms (*‹invertible a›*) invertible_def (*‹invertible ?A = (∃A'. ?A ** A' = mat 1 ∧ A' ** ?A = mat 1)›*) by auto section ‹Component expressions for inverse matrices over fields› lemma inv_adj_det_field_component: fixes i j::"'n::finite" and A A'::"'a::field^'n^'n" defines invA: "A' ≡ map_matrix (λx. x / (det A)) (adjugate A)" assumes "invertible A" shows "(A**A')$i$j = (if i=j then 1 else 0)" proof (-) (*goal: ‹(A ** A') $ i $ j = (if i = j then 1 else 0)›*) let ?D = "det A" have det_not_0: "?D ≠ 0" using assms (*‹A' ≡ map_matrix (λx. x / det A) (adjugate A)› ‹invertible A›*) by (metis det_I (*‹det (mat (1::?'a)) = (1::?'a)›*) det_mul (*‹det ((?A::((?'a, ?'n) vec, ?'n) vec) ** (?B::((?'a, ?'n) vec, ?'n) vec)) = det ?A * det ?B›*) invertible_inv_ex( (*‹invertible (?a::((?'a, ?'n) vec, ?'n) vec) ⟹ ?a ** matrix_inv ?a = mat (1::?'a)›*) 2) mult_zero_left (*‹(0::?'a) * (?a::?'a) = (0::?'a)›*) zero_neq_one (*‹(0::?'a) ≠ (1::?'a)›*)) have "(∑ k∈UNIV. (A$i$k * (adjugate A)$k$j)) = (if i=j then ?D else 0)" using mult_adjugate_det_2[of A] (*‹A ** adjugate A = mat (det A)›*) unfolding matrix_matrix_mult_def mat_def (*goal: ‹(∑k∈UNIV. A $ i $ k * adjugate A $ k $ j) = (if i = j then det A else 0)›*) by (metis (mono_tags, lifting) iso_tuple_UNIV_I (*‹(?x::?'a::type) ∈ UNIV ≡ True›*) vec_lambda_inverse (*‹(?y::?'b::finite ⇒ ?'a::type) ∈ UNIV ⟹ ($) (vec_lambda ?y) = ?y›*)) then have "(if i=j then 1 else 0) = (∑ k∈UNIV. (A$i$k * (adjugate A)$k$j)) / ?D" by (simp add: det_not_0 (*‹det A ≠ 0›*)) also (*calculation: ‹(if i = j then 1 else 0) = (∑k∈UNIV. A $ i $ k * adjugate A $ k $ j) / det A›*) have "… = (∑ k∈UNIV. (A$i$k * A'$k$j))" using sum_divide_distrib (*‹sum (?f::?'b ⇒ ?'a) (?A::?'b set) / (?r::?'a) = (∑n::?'b∈?A. ?f n / ?r)›*) invA (*‹A' ≡ map_matrix (λx. x / det A) (adjugate A)›*) by force finally (*calculation: ‹(if i = j then 1 else 0) = (∑k∈UNIV. A $ i $ k * A' $ k $ j)›*) show "?thesis" (*goal: ‹((A::(('a, 'n) vec, 'n) vec) ** (A'::(('a, 'n) vec, 'n) vec)) $ (i::'n) $ (j::'n) = (if i = j then 1::'a else (0::'a))›*) unfolding matrix_matrix_mult_def (*goal: ‹(χi j. ∑k∈UNIV. A $ i $ k * A' $ k $ j) $ i $ j = (if i = j then 1 else 0)›*) by simp qed lemma inverse_adjugate_det_2: fixes A::"'a::field^'n^'n" assumes "invertible A" shows "matrix_inv A = map_matrix (λx. x / (det A)) (adjugate A)" (is "matrix_inv A = ?A'") proof (-) (*goal: ‹matrix_inv A = map_matrix (λx. x / det A) (adjugate A)›*) let ?D = "det A" have det_not_0: "?D ≠ 0" using assms (*‹invertible A›*) by (metis det_I (*‹det (mat (1::?'a)) = (1::?'a)›*) det_mul (*‹det ((?A::((?'a, ?'n) vec, ?'n) vec) ** (?B::((?'a, ?'n) vec, ?'n) vec)) = det ?A * det ?B›*) invertible_inv_ex( (*‹invertible (?a::((?'a, ?'n) vec, ?'n) vec) ⟹ ?a ** matrix_inv ?a = mat (1::?'a)›*) 2) mult_zero_left (*‹(0::?'a) * (?a::?'a) = (0::?'a)›*) zero_neq_one (*‹(0::?'a) ≠ (1::?'a)›*)) have AA': "A ** ?A' = mat 1" unfolding mat_def (*goal: ‹A ** map_matrix (λx. x / det A) (adjugate A) = (χi j. if i = j then 1 else 0)›*) using inv_adj_det_field_component[OF assms] (*‹(A ** map_matrix (λx. x / det A) (adjugate A)) $ ?i $ ?j = (if ?i = ?j then 1 else 0)›*) by (simp add: vec_eq_iff (*‹(?x = ?y) = (∀i. ?x $ i = ?y $ i)›*)) moreover have "?A' ** A = mat 1" using AA' (*‹A ** map_matrix (λx. x / det A) (adjugate A) = mat 1›*) by (simp add: matrix_left_right_inverse (*‹((?A::((?'a::field, ?'n::finite) vec, ?'n::finite) vec) ** (?A'::((?'a::field, ?'n::finite) vec, ?'n::finite) vec) = mat (1::?'a::field)) = (?A' ** ?A = mat (1::?'a::field))›*)) ultimately show "matrix_inv A = ?A'" by (metis (no_types) invertible_def (*‹invertible ?A = (∃A'. ?A ** A' = mat 1 ∧ A' ** ?A = mat 1)›*) invertible_inv_ex( (*‹invertible ?a ⟹ ?a ** matrix_inv ?a = mat 1›*) 2) matrix_mul_assoc (*‹?A ** (?B ** ?C) = ?A ** ?B ** ?C›*) matrix_mul_lid (*‹mat 1 ** ?A = ?A›*)) qed lemma inverse_adjugate_det: fixes A::"'a::field^'n^'n" assumes "invertible A" shows "matrix_inv A = (1 / (det A)) *⇩s (adjugate A)" using inverse_adjugate_det_2[OF assms] (*‹matrix_inv A = map_matrix (λx. x / det A) (adjugate A)›*) unfolding map_matrix_def smult_mat_def (*goal: ‹matrix_inv A = (χi j. 1 / det A * adjugate A $ i $ j)›*) by auto lemma transpose_component: "(transpose A) $i$j = A$j$i" unfolding transpose_def (*goal: ‹(χi j. A $ j $ i) $ i $ j = A $ j $ i›*) by simp lemma matrix_inverse_component: fixes A::"'a::field^'n^'n" and i j::"'n::finite" assumes "invertible A" shows "(matrix_inv A)$i$j = det (χ k l. if k = j ∧ l = i then 1 else if k = j ∨ l = i then 0 else A $ k $ l) / (det A)" using inverse_adjugate_det_2[OF assms] (*‹matrix_inv A = map_matrix (λx. x / det A) (adjugate A)›*) by (simp add: transpose_component (*‹Finite_Cartesian_Product.transpose ?A $ ?i $ ?j = ?A $ ?j $ ?i›*) adjugate_def (*‹adjugate ?A ≡ Finite_Cartesian_Product.transpose (cofac ?A)›*) cofac_def (*‹cofac ?A ≡ χi j. det (minor_mat ?A i j)›*) minor_mat_def (*‹minor_mat ?A ?i ?j ≡ χk l. if k = ?i ∧ l = ?j then 1 else if k = ?i ∨ l = ?j then 0 else ?A $ k $ l›*)) lemma matrix_adjugate_component: fixes A::"'a::field^'n^'n" and i j::"'n::finite" assumes "invertible A" shows "(adjugate A)$i$j = det (χ k l. if k = j ∧ l = i then 1 else if k = j ∨ l = i then 0 else A $ k $ l)" by (simp add: transpose_component (*‹Finite_Cartesian_Product.transpose ?A $ ?i $ ?j = ?A $ ?j $ ?i›*) adjugate_def (*‹adjugate ?A ≡ Finite_Cartesian_Product.transpose (cofac ?A)›*) cofac_def (*‹cofac ?A ≡ χi j. det (minor_mat ?A i j)›*) minor_mat_def (*‹minor_mat ?A ?i ?j ≡ χk l. if k = ?i ∧ l = ?j then 1 else if k = ?i ∨ l = ?j then 0 else ?A $ k $ l›*)) section ‹Smoothness of real matrix operations and ‹det›› subsection ‹Smoothness of matrix multiplication› lemma smooth_on_ijth_of_mat: fixes s::"('a::real_normed_field,'n::finite)square_matrix set" shows "smooth_on s (λx. x $ i $ j)" by (simp add: bounded_linear.smooth_on (*‹bounded_linear ?f ⟹ ?k-smooth_on ?S ?f›*) bounded_linear_mat_ijth (*‹bounded_linear (λx. x $ ?i $ ?j)›*)) text ‹ Notice the following result holds only for matrices over the real numbers. (Try removing the type annotations: Isabelle automatically casts to the indicated type anyway.) This is because only real inner product spaces are defined: thus whatever "base field" a matrix is defined over, is implicitly assumed to also be a real inner product space (as is possible, for example, for ‹\mathbb{C}› with the normal inner product of ‹\mathbb{R}^2›), and the inner product is built on top of the existing one to return a ‹real› result. › lemma matrix_matrix_mul_component_real: fixes A::"real^'k^'n" and B::"real^'m^'k" shows "A**B = (χ i j. inner (row i A) (column j B))" and "A**B = (χ i j. inner (A$i) (transpose B$j))" proof (-) (*goals: 1. ‹A ** B = (χi j. row i A ∙ column j B)› 2. ‹A ** B = (χi j. A $ i ∙ Finite_Cartesian_Product.transpose B $ j)›*) have "(∑k∈UNIV. A $ i $ k * B $ k $ j) = inner (row i A) (column j B)" for i and j unfolding column_def row_def inner_vec_def inner_real_def (*goal: ‹(∑k∈UNIV. A $ i $ k * B $ k $ j) = (∑ia∈UNIV. vec_lambda (($) (A $ i)) $ ia * (χi. B $ i $ j) $ ia)›*) using UNIV_I (*‹?x ∈ UNIV›*) sum.cong (*‹⟦?A = ?B; ⋀x. x ∈ ?B ⟹ ?g x = ?h x⟧ ⟹ sum ?g ?A = sum ?h ?B›*) vec_lambda_inverse (*‹(?y::?'b::finite ⇒ ?'a::type) ∈ UNIV ⟹ ($) (vec_lambda ?y) = ?y›*) by force thus c1: "A**B = (χ i j. inner (row i A) (column j B))" by (simp add: matrix_matrix_mult_def (*‹(?m::((?'a, ?'n) vec, ?'m) vec) ** (?m'::((?'a, ?'p) vec, ?'n) vec) ≡ χ(i::?'m) j::?'p. ∑k::?'n∈UNIV. ?m $ i $ k * ?m' $ k $ j›*)) show "A**B = (χ i j. inner (A$i) (transpose B$j))" proof (-) (*goal: ‹A ** B = (χi j. A $ i ∙ Finite_Cartesian_Product.transpose B $ j)›*) have "(χ i j. A $ i ∙ transpose B $ j) = (χ i j. row i A ∙ column j B)" by (simp add: row_def (*‹row ?i ?A = (χj. ?A $ ?i $ j)›*) column_def (*‹column ?j ?A = (χi. ?A $ i $ ?j)›*) transpose_def (*‹Finite_Cartesian_Product.transpose ?A = (χi j. ?A $ j $ i)›*)) then show "?thesis" (*goal: ‹A ** B = (χi j. A $ i ∙ Finite_Cartesian_Product.transpose B $ j)›*) using c1 (*‹A ** B = (χi j. row i A ∙ column j B)›*) by metis qed qed lemma matrix_inner_sum: shows "x ∙ y = (∑i∈UNIV. ∑j∈UNIV. (x$i$j)∙(y$i$j))" and "x ∙ y = (∑(i,j)∈UNIV. (x$i$j)∙(y$i$j))" (*goals: 1. ‹x ∙ y = (∑i∈UNIV. ∑j∈UNIV. x $ i $ j ∙ y $ i $ j)› 2. ‹x ∙ y = (∑(i, j)∈UNIV. x $ i $ j ∙ y $ i $ j)› discuss goal 1*) apply (simp add: inner_vec_def (*‹(?x::(?'a::real_inner, ?'b::finite) vec) ∙ (?y::(?'a::real_inner, ?'b::finite) vec) = (∑i::?'b::finite∈UNIV. ?x $ i ∙ ?y $ i)›*)) (*discuss goal 2*) apply (simp add: inner_vec_def (*‹?x ∙ ?y = (∑i∈UNIV. ?x $ i ∙ ?y $ i)›*)) (*goal: ‹x ∙ y = (∑(i, j)∈UNIV. x $ i $ j ∙ y $ i $ j)›*) apply (simp add: sum.cartesian_product (*‹(∑x∈?A. sum (?g x) ?B) = (∑(x, y)∈?A × ?B. ?g x y)›*)) (*proven 2 subgoals*) . lemma matrix_norm_sum_sqrs: shows "norm x = sqrt(∑i∈UNIV. ∑j∈UNIV. (norm (x$i$j))²)" and "norm x = sqrt(∑(i,j)∈UNIV. (norm (x$i$j))²)" using real_sqrt_abs (*‹sqrt (?x²) = ¦?x¦›*) real_sqrt_power (*‹sqrt (?x ^ ?k) = sqrt ?x ^ ?k›*) (*goals: 1. ‹norm x = sqrt (∑i∈UNIV. ∑j∈UNIV. (norm (x $ i $ j))²)› 2. ‹norm x = sqrt (∑(i, j)∈UNIV. (norm (x $ i $ j))²)› discuss goal 1*) apply ((auto simp: norm_vec_def (*‹norm (?x::(?'a, ?'b) vec) = L2_set (λi::?'b. norm (?x $ i)) UNIV›*) L2_set_def (*‹L2_set (?f::?'a ⇒ real) (?A::?'a set) = sqrt (∑i::?'a∈?A. (?f i)²)›*) sum_nonneg (*‹(⋀x::?'b. x ∈ (?A::?'b set) ⟹ (0::?'a) ≤ (?f::?'b ⇒ ?'a) x) ⟹ (0::?'a) ≤ sum ?f ?A›*) sum.cartesian_product (*‹(∑x::?'b∈(?A::?'b set). sum ((?g::?'b ⇒ ?'c ⇒ ?'a) x) (?B::?'c set)) = (∑(x::?'b, y::?'c)∈?A × ?B. ?g x y)›*))[1]) (*discuss goal 2*) apply ((auto simp: norm_vec_def (*‹norm ?x = L2_set (λi. norm (?x $ i)) UNIV›*) L2_set_def (*‹L2_set ?f ?A = sqrt (∑i∈?A. (?f i)²)›*) sum_nonneg (*‹(⋀x. x ∈ ?A ⟹ 0 ≤ ?f x) ⟹ 0 ≤ sum ?f ?A›*) sum.cartesian_product (*‹(∑x∈?A. sum (?g x) ?B) = (∑(x, y)∈?A × ?B. ?g x y)›*))[1]) (*proven 2 subgoals*) . lemma norm_transpose: shows "norm x = norm (transpose x)" proof (-) (*goal: ‹norm x = norm (Finite_Cartesian_Product.transpose x)›*) have "(∑(i,j)∈UNIV. (norm (x$i$j))²) = (∑(j,i)∈UNIV. (norm (x$i$j))²)" using sum.swap[of "λi j. (norm (x$i$j))²" UNIV UNIV] (*‹(∑i∈UNIV. ∑j∈UNIV. (norm (x $ i $ j))²) = (∑j∈UNIV. ∑i∈UNIV. (norm (x $ i $ j))²)›*) by (simp add: sum.cartesian_product (*‹(∑x∈?A. sum (?g x) ?B) = (∑(x, y)∈?A × ?B. ?g x y)›*)) then show "?thesis" (*goal: ‹norm x = norm (Finite_Cartesian_Product.transpose x)›*) unfolding transpose_def matrix_norm_sum_sqrs(2) (*goal: ‹sqrt (∑(i, j)∈UNIV. (norm (x $ i $ j))²) = sqrt (∑(i, j)∈UNIV. (norm ((χi j. x $ j $ i) $ i $ j))²)›*) by simp qed lemma matrix_norm_inner: fixes x::"real^'n^'m" shows "norm x = sqrt(∑(i,j)∈UNIV. (x$i$j)∙(x$i$j))" using matrix_inner_sum(2)[of x x] (*‹x ∙ x = (∑(i, j)∈UNIV. x $ i $ j ∙ x $ i $ j)›*) by (simp add: norm_eq_sqrt_inner (*‹norm ?x = sqrt (?x ∙ ?x)›*)) lemma matrix_norm_row: shows "norm x = sqrt(∑i∈UNIV. (norm (row i x))²)" unfolding norm_vec_def L2_set_def row_def (*goal: ‹sqrt (∑i∈UNIV. (sqrt (∑ia∈UNIV. (norm (x $ i $ ia))²))²) = sqrt (∑i∈UNIV. (sqrt (∑ia∈UNIV. (norm (vec_lambda (($) (x $ i)) $ ia))²))²)›*) by simp lemma matrix_norm_column: shows "norm x = sqrt(∑j∈UNIV. (norm (column j x))²)" using matrix_norm_row (*‹norm ?x = sqrt (∑i∈UNIV. (norm (row i ?x))²)›*) norm_transpose (*‹norm ?x = norm (Finite_Cartesian_Product.transpose ?x)›*) row_transpose (*‹row ?i (Finite_Cartesian_Product.transpose ?A) = column ?i ?A›*) by (metis (lifting) Finite_Cartesian_Product.sum_cong_aux (*‹(⋀x. x ∈ ?A ⟹ ?f x = ?g x) ⟹ sum ?f ?A = sum ?g ?A›*)) lemma mat_mul_indexed: "(A**B)$i$j = (∑k∈UNIV. A $ i $ k * B $ k $ j)" using matrix_matrix_mult_def (*‹?m ** ?m' ≡ χi j. ∑k∈UNIV. ?m $ i $ k * ?m' $ k $ j›*) vec_lambda_beta (*‹vec_lambda ?g $ ?i = ?g ?i›*) by (metis (no_types, lifting) Finite_Cartesian_Product.sum_cong_aux (*‹(⋀x. x ∈ ?A ⟹ ?f x = ?g x) ⟹ sum ?f ?A = sum ?g ?A›*)) lemma norm_matrix_mult_ineq: fixes A :: "real^'l^'n" and B :: "real^'m^'l" shows "norm (A ** B) ≤ norm A * norm B" proof (-) (*goal: ‹norm (A ** B) ≤ norm A * norm B›*) have "(A**B)$i$j = row i A ∙ column j B" for i and j by (simp add: matrix_matrix_mul_component_real(1)[of A B] (*‹A ** B = (χi j. row i A ∙ column j B)›*)) then have "norm (A**B) = sqrt(∑(i,j)∈UNIV. (norm (row i A ∙ column j B))²)" by (simp add: matrix_norm_sum_sqrs(2)[of "A**B"] (*‹norm (A ** B) = sqrt (∑(i, j)∈UNIV. (norm ((A ** B) $ i $ j))²)›*)) then have "(norm (A**B))² = (∑(i,j)∈UNIV. (norm (row i A ∙ column j B))²)" by (metis (no_types, lifting) norm_ge_zero (*‹0 ≤ norm ?x›*) real_sqrt_ge_0_iff (*‹(0 ≤ sqrt ?y) = (0 ≤ ?y)›*) real_sqrt_pow2 (*‹0 ≤ ?x ⟹ (sqrt ?x)² = ?x›*)) also (*calculation: ‹(norm (A ** B))² = (∑(i, j)∈UNIV. (norm (row i A ∙ column j B))²)›*) have "(∑(i,j)∈UNIV. (norm (row i A ∙ column j B))²) ≤ (∑(i,j)∈UNIV. (norm(row i A) * norm(column j B))²)" proof (-) (*goal: ‹(∑(i::'n, j::'m)∈UNIV. (norm (row i (A::((real, 'l) vec, 'n) vec) ∙ column j (B::((real, 'm) vec, 'l) vec)))²) ≤ (∑(i::'n, j::'m)∈UNIV. (norm (row i A) * norm (column j B))²)›*) obtain f and g where defs: "f = (λ(i::'n,j::'m). (row i A ∙ column j B)²)" "g = (λ(i::'n,j::'m). (norm (row i A) * norm (column j B))²)" (*goal: ‹(⋀(f::'n × 'm ⇒ real) g::'n × 'm ⇒ real. ⟦f = (λ(i::'n, j::'m). (row i (A::((real, 'l) vec, 'n) vec) ∙ column j (B::((real, 'm) vec, 'l) vec))²); g = (λ(i::'n, j::'m). (norm (row i A) * norm (column j B))²)⟧ ⟹ thesis::bool) ⟹ thesis›*) by simp then have "f (i,j) ≤ g (i,j)" for i :: 'n and j :: 'm by (simp add: Cauchy_Schwarz_ineq (*‹(?x ∙ ?y)² ≤ ?x ∙ ?x * (?y ∙ ?y)›*) power2_norm_eq_inner (*‹(norm ?x)² = ?x ∙ ?x›*) power_mult_distrib (*‹(?a * ?b) ^ ?n = ?a ^ ?n * ?b ^ ?n›*)) hence "(∑(i,j)∈UNIV. f (i,j)) ≤ (∑(i,j)∈UNIV. g (i,j))" using sum_mono[of UNIV f g] (*‹(⋀i. i ∈ UNIV ⟹ f i ≤ g i) ⟹ sum f UNIV ≤ sum g UNIV›*) by fastforce thus "?thesis" (*goal: ‹(∑(i, j)∈UNIV. (norm (row i A ∙ column j B))²) ≤ (∑(i, j)∈UNIV. (norm (row i A) * norm (column j B))²)›*) by (simp add: defs (*‹f = (λ(i, j). (row i A ∙ column j B)²)› ‹g = (λ(i, j). (norm (row i A) * norm (column j B))²)›*)) qed also (*calculation: ‹(norm (A ** B))² ≤ (∑(i, j)∈UNIV. (norm (row i A) * norm (column j B))²)›*) have "(∑(i,j)∈UNIV. (norm(row i A) * norm(column j B))²) = (norm A * norm B)²" proof (-) (*goal: ‹(∑(i, j)∈UNIV. (norm (row i A) * norm (column j B))²) = (norm A * norm B)²›*) let ?f = "λi. (norm (row i A))²" let ?g = "λj. (norm (column j B))²" have "(∑(i,j)∈UNIV. (norm(row i A) * norm(column j B))²) = (∑(i,j)∈UNIV. (norm(row i A))² * (norm(column j B))²)" by (simp add: power_mult_distrib (*‹(?a * ?b) ^ ?n = ?a ^ ?n * ?b ^ ?n›*)) then have 1: "(∑(i,j)∈UNIV. (norm(row i A) * norm(column j B))²) = (∑i∈UNIV. (norm(row i A))²) * (∑j∈UNIV. (norm(column j B))²)" by (simp add: sum_product (*‹sum ?f ?A * sum ?g ?B = (∑i∈?A. ∑j∈?B. ?f i * ?g j)›*) sum.cartesian_product (*‹(∑x∈?A. sum (?g x) ?B) = (∑(x, y)∈?A × ?B. ?g x y)›*)) have 2: "(∑i∈UNIV. (norm(row i A))²) = (norm A)²" "(∑j∈UNIV. (norm(column j B))²) = (norm B)²" using matrix_norm_row (*‹norm ?x = sqrt (∑i∈UNIV. (norm (row i ?x))²)›*) matrix_norm_column (*‹norm ?x = sqrt (∑j∈UNIV. (norm (column j ?x))²)›*) abs_norm_cancel (*‹¦norm ?a¦ = norm ?a›*) real_sqrt_abs (*‹sqrt (?x²) = ¦?x¦›*) real_sqrt_eq_iff (*‹(sqrt (?x::real) = sqrt (?y::real)) = (?x = ?y)›*) apply - (*goals: 1. ‹⟦⋀x. norm x = sqrt (∑i∈UNIV. (norm (row i x))²); ⋀x. norm x = sqrt (∑j∈UNIV. (norm (column j x))²); ⋀a. ¦norm a¦ = norm a; ⋀x. sqrt (x²) = ¦x¦; ⋀x y. (sqrt x = sqrt y) = (x = y)⟧ ⟹ (∑i∈UNIV. (norm (row i A))²) = (norm A)²› 2. ‹⟦⋀x. norm x = sqrt (∑i∈UNIV. (norm (row i x))²); ⋀x. norm x = sqrt (∑j∈UNIV. (norm (column j x))²); ⋀a. ¦norm a¦ = norm a; ⋀x. sqrt (x²) = ¦x¦; ⋀x y. (sqrt x = sqrt y) = (x = y)⟧ ⟹ (∑j∈UNIV. (norm (column j B))²) = (norm B)²› discuss goal 1*) apply ((msorry)[1]) (*discuss goal 2*) apply ((msorry)[1]) (*proven 2 subgoals*) . show "?thesis" (*goal: ‹(∑(i, j)∈UNIV. (norm (row i A) * norm (column j B))²) = (norm A * norm B)²›*) using "1" (*‹(∑(i, j)∈UNIV. (norm (row i A) * norm (column j B))²) = (∑i∈UNIV. (norm (row i A))²) * (∑j∈UNIV. (norm (column j B))²)›*) "2" (*‹(∑i∈UNIV. (norm (row i A))²) = (norm A)²› ‹(∑j∈UNIV. (norm (column j B))²) = (norm B)²›*) by (metis power_mult_distrib (*‹(?a * ?b) ^ ?n = ?a ^ ?n * ?b ^ ?n›*)) qed finally (*calculation: ‹(norm (A ** B))² ≤ (norm A * norm B)²›*) show "?thesis" (*goal: ‹norm (A ** B) ≤ norm A * norm B›*) by simp qed lemma bounded_bilinear_matrix_mult: "bounded_bilinear ((**) :: real^'l^'m ⇒ real^'n^'l ⇒ real^'n^'m)" apply (rule bounded_bilinear.intro (*‹⟦⋀a a' b. ?prod (a + a') b = ?prod a b + ?prod a' b; ⋀a b b'. ?prod a (b + b') = ?prod a b + ?prod a b'; ⋀r a b. ?prod (r *⇩R a) b = r *⇩R ?prod a b; ⋀a r b. ?prod a (r *⇩R b) = r *⇩R ?prod a b; ∃K. ∀a b. norm (?prod a b) ≤ norm a * norm b * K⟧ ⟹ bounded_bilinear ?prod›*)) (*goals: 1. ‹⋀a a' b. (a + a') ** b = a ** b + a' ** b› 2. ‹⋀a b b'. a ** (b + b') = a ** b + a ** b'› 3. ‹⋀r a b. r *⇩R a ** b = r *⇩R (a ** b)› 4. ‹⋀a r b. a ** r *⇩R b = r *⇩R (a ** b)› 5. ‹∃K. ∀a b. norm (a ** b) ≤ norm a * norm b * K› discuss goal 1*) apply (metis (no_types, lifting) matrix_eq (*‹(?A = ?B) = (∀x. ?A *v x = ?B *v x)›*) matrix_vector_mul_assoc (*‹?A *v (?B *v ?x) = ?A ** ?B *v ?x›*) matrix_vector_mult_add_rdistrib (*‹(?A + ?B) *v ?x = ?A *v ?x + ?B *v ?x›*)) (*discuss goal 2*) apply (simp add: matrix_add_ldistrib (*‹?A ** (?B + ?C) = ?A ** ?B + ?A ** ?C›*) matrix_scalar_ac (*‹?A ** ?k *⇩R ?B = ?k *⇩R ?A ** ?B›*) scalar_matrix_assoc (*‹?k *⇩R (?A ** ?B) = ?k *⇩R ?A ** ?B›*)) (*discuss goal 3*) apply (simp add: matrix_add_ldistrib (*‹?A ** (?B + ?C) = ?A ** ?B + ?A ** ?C›*) matrix_scalar_ac (*‹?A ** ?k *⇩R ?B = ?k *⇩R ?A ** ?B›*) scalar_matrix_assoc (*‹?k *⇩R (?A ** ?B) = ?k *⇩R ?A ** ?B›*)) (*discuss goal 4*) apply (simp add: matrix_add_ldistrib (*‹(?A::((?'a, ?'d) vec, ?'c) vec) ** ((?B::((?'a, ?'b) vec, ?'d) vec) + (?C::((?'a, ?'b) vec, ?'d) vec)) = ?A ** ?B + ?A ** ?C›*) matrix_scalar_ac (*‹(?A::((?'a, ?'m) vec, ?'n) vec) ** (?k::real) *⇩R (?B::((?'a, ?'b) vec, ?'m) vec) = ?k *⇩R ?A ** ?B›*) scalar_matrix_assoc (*‹(?k::real) *⇩R ((?A::((?'a, ?'m) vec, ?'n) vec) ** (?B::((?'a, ?'b) vec, ?'m) vec)) = ?k *⇩R ?A ** ?B›*)) (*discuss goal 5*) apply (intro exI[of _ 1] (*‹?P 1 ⟹ ∃x. ?P x›*)) (*goal: ‹∃K::real. ∀(a::((real, 'l) vec, 'm) vec) b::((real, 'n) vec, 'l) vec. norm (a ** b) ≤ norm a * norm b * K›*) apply (simp add: norm_matrix_mult_ineq (*‹norm (?A ** ?B) ≤ norm ?A * norm ?B›*)) (*proven 5 subgoals*) . lemma smooth_on_matrix_mult: fixes f::"'a::real_normed_vector ⇒ (real^'n^'m)" assumes "k-smooth_on S f" "k-smooth_on S g" "open S" shows "k-smooth_on S (λx. f x ** g x)" by (rule bounded_bilinear.smooth_on[OF bounded_bilinear_matrix_mult assms] (*‹(k::enat)-smooth_on (S::'a set) (λx::'a. (f::'a ⇒ ((real, 'n) vec, 'm) vec) x ** (g::'a ⇒ ((real, 'b) vec, 'n) vec) x)›*)) subsection ‹Smoothness of ‹∏› and ‹det›› lemma higher_differentiable_on_prod: fixes f::"_ ⇒ _ ⇒ 'c::{real_normed_algebra, comm_monoid_mult}" assumes "⋀i. i ∈ F ⟹ finite F ⟹ higher_differentiable_on S (f i) n" "open S" shows "higher_differentiable_on S (λx. ∏i∈F. f i x) n" using assms (*‹⟦(?i::'d::type) ∈ (F::'d::type set); finite F⟧ ⟹ higher_differentiable_on (S::'e::real_normed_vector set) ((f::'d::type ⇒ 'e::real_normed_vector ⇒ 'c::{comm_monoid_mult,real_normed_algebra}) ?i) (n::nat)› ‹open S›*) apply (induction F 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; finite A⟧ ⟹ higher_differentiable_on S (f i) n; open S⟧ ⟹ higher_differentiable_on S (λx. ∏i∈A. f i x) n› 2. ‹⟦⋀i. ⟦i ∈ {}; finite {}⟧ ⟹ higher_differentiable_on S (f i) n; open S⟧ ⟹ higher_differentiable_on S (λx. ∏i∈{}. f i x) n› 3. ‹⋀x F. ⟦finite F; x ∉ F; ⟦⋀i. ⟦i ∈ F; finite F⟧ ⟹ higher_differentiable_on S (f i) n; open S⟧ ⟹ higher_differentiable_on S (λx. ∏i∈F. f i x) n; ⋀i. ⟦i ∈ insert x F; finite (insert x F)⟧ ⟹ higher_differentiable_on S (f i) n; open S⟧ ⟹ higher_differentiable_on S (λxa. ∏i∈insert x F. f i xa) n› discuss goal 1*) apply (simp add: higher_differentiable_on_const (*‹higher_differentiable_on ?S (λx. ?c) ?n›*) higher_differentiable_on_mult (*‹⟦higher_differentiable_on ?S ?f ?n; higher_differentiable_on ?S ?g ?n; open ?S⟧ ⟹ higher_differentiable_on ?S (λx. ?f x * ?g x) ?n›*)) (*discuss goal 2*) apply (simp add: higher_differentiable_on_const (*‹higher_differentiable_on ?S (λx. ?c) ?n›*) higher_differentiable_on_mult (*‹⟦higher_differentiable_on ?S ?f ?n; higher_differentiable_on ?S ?g ?n; open ?S⟧ ⟹ higher_differentiable_on ?S (λx. ?f x * ?g x) ?n›*)) (*discuss goal 3*) apply (simp add: higher_differentiable_on_const (*‹higher_differentiable_on ?S (λx. ?c) ?n›*) higher_differentiable_on_mult (*‹⟦higher_differentiable_on ?S ?f ?n; higher_differentiable_on ?S ?g ?n; open ?S⟧ ⟹ higher_differentiable_on ?S (λx. ?f x * ?g x) ?n›*)) (*proven 3 subgoals*) . lemma smooth_on_prod: fixes f::"_ ⇒ _ ⇒ 'c::{real_normed_algebra, comm_monoid_mult}" assumes "(⋀i. i ∈ F ⟹ finite F ⟹ k-smooth_on S (f i))" "open S" shows "k-smooth_on S (λx. ∏i∈F. f i x)" using higher_differentiable_on_prod (*‹⟦⋀i. ⟦i ∈ ?F; finite ?F⟧ ⟹ higher_differentiable_on ?S (?f i) ?n; open ?S⟧ ⟹ higher_differentiable_on ?S (λx. ∏i∈?F. ?f i x) ?n›*) by (metis assms (*‹⟦?i ∈ F; finite F⟧ ⟹ k-smooth_on S (f ?i)› ‹open S›*) smooth_on_def (*‹?k-smooth_on ?S ?f = (∀n. enat n ≤ ?k ⟶ higher_differentiable_on ?S ?f n)›*)) lemma smooth_on_det: fixes s::"('a::real_normed_field,'n::finite)square_matrix set" assumes "open s" shows "k-smooth_on s det" proof (unfold det_def (*‹det (?A::((?'a, ?'n) vec, ?'n) vec) = (∑p::?'n ⇒ ?'n | p permutes UNIV. of_int (sign p) * (∏i::?'n∈UNIV. ?A $ i $ p i))›*), intro smooth_on_sum (*‹⟦⋀i::?'a. ⟦i ∈ (?F::?'a set); finite ?F⟧ ⟹ (?n::enat)-smooth_on (?S::?'b set) ((?f::?'a ⇒ ?'b ⇒ ?'c) i); open ?S⟧ ⟹ ?n-smooth_on ?S (λx::?'b. ∑i::?'a∈?F. ?f i x)›*)) (*goals: 1. ‹⋀p. ⟦p ∈ {p. p permutes UNIV}; finite {p. p permutes UNIV}⟧ ⟹ k-smooth_on s (λx. of_int (sign p) * (∏i∈UNIV. x $ i $ p i))› 2. ‹open s›*) fix p assume "p ∈ {p. p permutes (UNIV::'n set)}" (*‹(p::'n ⇒ 'n) ∈ {p::'n ⇒ 'n. p permutes UNIV}›*) show "k-smooth_on s (λA. of_int (sign p) * (∏i∈UNIV. A $ i $ p i))" proof (intro smooth_on_mult (*‹⟦?k-smooth_on ?S ?f; ?k-smooth_on ?S ?g; open ?S⟧ ⟹ ?k-smooth_on ?S (λx. ?f x * ?g x)›*)) (*goals: 1. ‹k-smooth_on s (λx. of_int (sign p))› 2. ‹k-smooth_on s (λx. ∏i∈UNIV. x $ i $ p i)› 3. ‹open s›*) show "k-smooth_on s (λx. of_int (sign p))" by (simp add: smooth_on_const (*‹?k-smooth_on ?S (λx. ?c)›*)) show "k-smooth_on s (λx. ∏i∈UNIV. x $ i $ p i)" "open s" (*goals: 1. ‹(k::enat)-smooth_on (s::(('a, 'n) vec, 'n) vec set) (λx::(('a, 'n) vec, 'n) vec. ∏i::'n∈UNIV. x $ i $ (p::'n ⇒ 'n) i)› 2. ‹open (s::(('a, 'n) vec, 'n) vec set)› discuss goal 1*) apply (intro smooth_on_prod (*‹⟦⋀i. ⟦i ∈ ?F; finite ?F⟧ ⟹ ?k-smooth_on ?S (?f i); open ?S⟧ ⟹ ?k-smooth_on ?S (λx. ∏i∈?F. ?f i x)›*)) (*goals: 1. ‹⋀i. ⟦i ∈ UNIV; finite UNIV⟧ ⟹ k-smooth_on s (λx. x $ i $ p i)› 2. ‹open s› discuss goal 1*) apply (simp add: bounded_linear.smooth_on (*‹bounded_linear ?f ⟹ ?k-smooth_on ?S ?f›*) bounded_linear_mat_ijth (*‹bounded_linear (λx. x $ ?i $ ?j)›*)) (*discuss goal 2*) apply (rule assms (*‹open s›*)) (*proven 2 subgoals*) (*discuss goal 2*) apply (rule assms (*‹open s›*)) (*proven 2 subgoals*) . qed qed (rule assms (*‹open (s::(('a, 'n) vec, 'n) vec set)›*)) (*solved the remaining goal: ‹open s›*) (*lemma fixes f::"_⇒_::euclidean_space" assumes "smooth_on T g" and "smooth_on S f" and "open S" and "open T" and "f`S ⊆ T" shows "smooth_on S (g∘f)" by (rule smooth_on_compose[OF assms])*) subsection ‹Smoothness of matrix inversion› lemma invertible_mat_1: "invertible (mat 1)" by (simp add: invertible_def (*‹invertible ?A = (∃A'. ?A ** A' = mat 1 ∧ A' ** ?A = mat 1)›*)) lemma continuous_on_vec: assumes "⋀i. continuous_on S (λx. f x $ i)" shows "continuous_on S f" using assms (*‹continuous_on S (λx. f x $ ?i)›*) unfolding continuous_on_def (*goal: ‹∀x∈S. (f ⤏ f x) (at x within S)›*) by (simp add: vec_tendstoI (*‹(⋀i. ((λx. ?f x $ i) ⤏ ?a $ i) ?net) ⟹ (?f ⤏ ?a) ?net›*)) lemma frechet_derivative_eucl: fixes f::"'a::euclidean_space ⇒ 'b::real_normed_vector" assumes "f differentiable at x" shows "frechet_derivative f (at x) = (λv. ∑i∈Basis. (v ∙ i) *⇩R frechet_derivative f (at x) i)" proof (-) (*goal: ‹frechet_derivative f (at x) = (λv. ∑i∈Basis. (v ∙ i) *⇩R frechet_derivative f (at x) i)›*) have 1: "id differentiable at x" "f differentiable at (id x)" (*goals: 1. ‹id differentiable at x› 2. ‹f differentiable at (id x)› discuss goal 1*) apply (simp add: frechet_derivative_works (*‹(?f differentiable ?net) = (?f has_derivative frechet_derivative ?f ?net) ?net›*)) (*discuss goal 2*) apply (simp add: assms (*‹f differentiable at x›*)) (*proven 2 subgoals*) . show "?thesis" (*goal: ‹frechet_derivative f (at x) = (λv. ∑i∈Basis. (v ∙ i) *⇩R frechet_derivative f (at x) i)›*) using frechet_derivative_compose_eucl[OF 1] (*‹frechet_derivative (f ∘ id) (at x) = (λv. ∑i∈Basis. (frechet_derivative id (at x) v ∙ i) *⇩R frechet_derivative f (at (id x)) i)›*) frechet_derivative_id[of x] (*‹frechet_derivative id (at x) = id›*) apply auto (*goal: ‹frechet_derivative f (at x) = (λv. ∑i∈Basis. (v ∙ i) *⇩R frechet_derivative f (at x) i)›*) by (metis comp_id (*‹?f ∘ id = ?f›*) fun.map_ident (*‹(λx. x) ∘ ?t = ?t›*)) qed text ‹TODO! This should maybe be changed in ‹Finite_Cartesian_Product.norm_le_l1_cart›. That result only works for ‹real^'n›, this one should work for all ‹'a::real_normed_vector^'n›.› lemma norm_le_l1_cart': "norm x ≤ sum(λi. norm (x$i)) UNIV" by (simp add: norm_vec_def (*‹norm ?x = L2_set (λi. norm (?x $ i)) UNIV›*) L2_set_le_sum (*‹(⋀i. i ∈ ?A ⟹ 0 ≤ ?f i) ⟹ L2_set ?f ?A ≤ sum ?f ?A›*)) lemma bounded_linear_vec_nth_fun: fixes f::"'a::real_normed_vector ⇒ 'b::real_normed_vector^'m" assumes "⋀i. bounded_linear (λx. (f x)$i)" shows "bounded_linear f" proof (standard) (*goals: 1. ‹⋀b1 b2. f (b1 + b2) = f b1 + f b2› 2. ‹⋀r b. f (r *⇩R b) = r *⇩R f b› 3. ‹∃K. ∀x. norm (f x) ≤ norm x * K›*) fix x and y and r :: real interpret fi: bounded_linear "λx. (f x)$i" for i by fact show "f (r*⇩R x) = r *⇩R f x" using fi.scale (*‹f (?r *⇩R ?b) $ ?i = ?r *⇩R f ?b $ ?i›*) by (simp add: vec_eq_iff (*‹(?x = ?y) = (∀i. ?x $ i = ?y $ i)›*)) show "f (x+y) = f x + f y" using fi.add (*‹f (?b1.0 + ?b2.0) $ ?i = f ?b1.0 $ ?i + f ?b2.0 $ ?i›*) by (simp add: vec_eq_iff (*‹(?x = ?y) = (∀i. ?x $ i = ?y $ i)›*)) obtain F where "0<F i" and norm_f: "⋀x. norm ((f x)$i) ≤ norm x * F i" for i (*goal: ‹(⋀F. ⟦⋀i. 0 < F i; ⋀i x. norm (f x $ i) ≤ norm x * F i⟧ ⟹ thesis) ⟹ thesis›*) using fi.pos_bounded (*‹∃K>0. ∀x. norm (f x $ ?i) ≤ norm x * K›*) by metis have "∀x. norm (f x) ≤ norm x * (∑i∈UNIV. F i)" proof (rule allI (*‹(⋀x::?'a. (?P::?'a ⇒ bool) x) ⟹ ∀x::?'a. ?P x›*)) (*goal: ‹⋀x. norm (f x) ≤ norm x * sum F UNIV›*) fix x have "norm (f x) ≤ (∑i∈UNIV. norm (f x $ i))" by (rule norm_le_l1_cart'[of "f x" for x] (*‹norm (f ?xb2) ≤ (∑i∈UNIV. norm (f ?xb2 $ i))›*)) also (*calculation: ‹norm (f x) ≤ (∑i∈UNIV. norm (f x $ i))›*) have "… ≤ (∑i∈UNIV. norm x * F i)" using norm_f[of x i for i] (*‹norm (f x $ ?ia2) ≤ norm x * F ?ia2›*) by (simp add: sum_mono (*‹(⋀i::?'b. i ∈ (?K::?'b set) ⟹ (?f::?'b ⇒ ?'a) i ≤ (?g::?'b ⇒ ?'a) i) ⟹ sum ?f ?K ≤ sum ?g ?K›*)) also (*calculation: ‹norm (f x) ≤ (∑i∈UNIV. norm x * F i)›*) have "… ≤ norm x * (∑i∈UNIV. F i)" by (simp add: sum_distrib_left (*‹(?r::?'a::semiring_0) * sum (?f::?'b::type ⇒ ?'a::semiring_0) (?A::?'b::type set) = (∑n::?'b::type∈?A. ?r * ?f n)›*)) finally (*calculation: ‹norm (f x) ≤ norm x * sum F UNIV›*) show "norm (f x) ≤ norm x * (∑i∈UNIV. F i)" . qed thus "∃K. ∀x. norm (f x) ≤ norm x * K" by blast qed lemma has_derivative_vec_lambda [derivative_intros]: fixes f::"'a::real_normed_vector ⇒ 'b::real_normed_vector^'m" assumes "⋀i. ((λx. (f x)$i) has_derivative (λx. (f' x)$i)) (at x within s)" shows "(f has_derivative f') (at x within s)" proof (intro has_derivativeI_sandwich[of 1] (*‹⟦0 < 1; bounded_linear ?f'; ⋀y. ⟦y ∈ ?s; y ≠ ?x; dist y ?x < 1⟧ ⟹ norm (?f y - ?f ?x - ?f' (y - ?x)) / norm (y - ?x) ≤ ?H y; (?H ⤏ 0) (at ?x within ?s)⟧ ⟹ (?f has_derivative ?f') (at ?x within ?s)›*)) (*goals: 1. ‹0 < 1› 2. ‹bounded_linear f'› 3. ‹⋀y. ⟦y ∈ s; y ≠ x; dist y x < 1⟧ ⟹ norm (f y - f x - f' (y - x)) / norm (y - x) ≤ ?H y› 4. ‹(?H ⤏ 0) (at x within s)›*) show "bounded_linear f'" using assms (*‹((λx::'a. (f::'a ⇒ ('b, 'm) vec) x $ (?i::'m)) has_derivative (λx::'a. (f'::'a ⇒ ('b, 'm) vec) x $ ?i)) (at (x::'a) within (s::'a set))›*) by (intro bounded_linear_vec_nth_fun (*‹(⋀i::?'m::finite. bounded_linear (λx::?'a::real_normed_vector. (?f::?'a::real_normed_vector ⇒ (?'b::real_normed_vector, ?'m::finite) vec) x $ i)) ⟹ bounded_linear ?f›*) has_derivative_bounded_linear (*‹((?f::?'a::real_normed_vector ⇒ ?'b::real_normed_vector) has_derivative (?f'::?'a::real_normed_vector ⇒ ?'b::real_normed_vector)) (?F::?'a::real_normed_vector filter) ⟹ bounded_linear ?f'›*)) let ?Ri = "λi y. (f y)$i - (f x)$i - (f' (y-x))$i" let ?R = "λy. f y - f x - f' (y-x)" show "((λy. (∑i∈UNIV. norm (?Ri i y) / norm (y-x))) ⤏ 0) (at x within s)" using assms (*‹((λx. f x $ ?i) has_derivative (λx. f' x $ ?i)) (at x within s)›*) apply (intro tendsto_null_sum (*‹(⋀i. i ∈ ?I ⟹ ((λx. ?f x i) ⤏ 0) ?F) ⟹ ((λi. sum (?f i) ?I) ⤏ 0) ?F›*)) (*goal: ‹((λy::'a. ∑i::'m∈UNIV. norm ((f::'a ⇒ ('b, 'm) vec) y $ i - f (x::'a) $ i - (f'::'a ⇒ ('b, 'm) vec) (y - x) $ i) / norm (y - x)) ⤏ (0::real)) (at x within (s::'a set))›*) by (auto simp: has_derivative_iff_norm (*‹(?f has_derivative ?f') (at ?x within ?s) = (bounded_linear ?f' ∧ ((λy. norm (?f y - ?f ?x - ?f' (y - ?x)) / norm (y - ?x)) ⤏ 0) (at ?x within ?s))›*)) fix y assume "y ≠ x" (*‹(y::'a) ≠ (x::'a)›*) show "norm (?R y) / norm (y-x) ≤ (∑i∈UNIV. norm (?Ri i y) / norm (y-x))" unfolding sum_divide_distrib[symmetric] (*goal: ‹norm ((f::'a::real_normed_vector ⇒ ('b::real_normed_vector, 'm::finite) vec) (y::'a::real_normed_vector) - f (x::'a::real_normed_vector) - (f'::'a::real_normed_vector ⇒ ('b::real_normed_vector, 'm::finite) vec) (y - x)) / norm (y - x) ≤ (∑i::'m::finite∈UNIV. norm (f y $ i - f x $ i - f' (y - x) $ i)) / norm (y - x)›*) apply (rule divide_right_mono (*‹⟦?a ≤ ?b; 0 ≤ ?c⟧ ⟹ ?a / ?c ≤ ?b / ?c›*)) (*goal: ‹norm (f y - f x - f' (y - x)) / norm (y - x) ≤ (∑i∈UNIV. norm (f y $ i - f x $ i - f' (y - x) $ i)) / norm (y - x)›*) prefer 2 (*top goal: ‹0 ≤ norm (y - x)› and 1 goal remains*) apply simp (*top goal: ‹0 ≤ norm (y - x)› and 1 goal remains*) using norm_le_l1_cart' (*‹norm ?x ≤ (∑i∈UNIV. norm (?x $ i))›*) by (smt (verit, ccfv_SIG) real_norm_def (*‹norm ?r = ¦?r¦›*) sum_mono (*‹(⋀i. i ∈ ?K ⟹ ?f i ≤ ?g i) ⟹ sum ?f ?K ≤ sum ?g ?K›*) vector_minus_component (*‹(?x - ?y) $ ?i = ?x $ ?i - ?y $ ?i›*)) qed (simp) (*solved the remaining goal: ‹(0::real) < (1::real)›*) lemma has_derivative_vec_lambda_2: fixes f::"'a::real_normed_vector ⇒ 'b::real_normed_vector^'m" assumes "⋀i. ((λx. (f x)$i) has_derivative (f' i)) (at x within s)" shows "(f has_derivative (λx. χ i. f' i x)) (at x within s)" apply (intro has_derivative_vec_lambda[of f "λx. χ i. f' i x" x s] (*‹(⋀i. ((λx. f x $ i) has_derivative (λx. (χi. f' i x) $ i)) (at x within s)) ⟹ (f has_derivative (λx. χi. f' i x)) (at x within s)›*)) (*goal: ‹(f has_derivative (λx. χi. f' i x)) (at x within s)›*) using assms (*‹((λx. f x $ ?i) has_derivative f' ?i) (at x within s)›*) by auto lemma differentiable_componentwise: fixes f::"'a::real_normed_vector ⇒ 'b::real_normed_vector^'m" assumes "⋀i. (λx. f x $ i) differentiable (at x within s)" shows "f differentiable (at x within s)" apply (unfold differentiable_def (*‹(?f differentiable ?F) = (∃D. (?f has_derivative D) ?F)›*)) (*goal: ‹f differentiable at x within s›*) proof (intro exI (*‹(?P::?'a::type ⇒ bool) (?x::?'a::type) ⟹ ∃x::?'a::type. ?P x›*)) (*goal: ‹((f::'a ⇒ ('b, 'm) vec) has_derivative (?D::'a ⇒ ('b, 'm) vec)) (at (x::'a) within (s::'a set))›*) let ?f' = "λi. SOME f'. ((λx. f x $ i) has_derivative f') (at x within s)" have 1: "⋀i. ((λx. (f x)$i) has_derivative (?f' i)) (at x within s)" by (metis assms (*‹(λx. f x $ ?i) differentiable at x within s›*) differentiable_def (*‹(?f differentiable ?F) = (∃D. (?f has_derivative D) ?F)›*) some_eq_imp (*‹⟦Eps ?P = ?a; ?P ?b⟧ ⟹ ?P ?a›*)) show "(f has_derivative (λx. χ i. ?f' i x)) (at x within s)" by (rule has_derivative_vec_lambda_2[OF 1] (*‹(f has_derivative (λxa. χi. (SOME f'. ((λx. f x $ i) has_derivative f') (at x within s)) xa)) (at x within s)›*)) qed lemma frechet_derivative_vec: fixes f::"'a::real_normed_vector ⇒ 'b::real_normed_vector^'m" assumes "⋀i. (λx. f x $ i) differentiable (at x)" shows "frechet_derivative f (at x) = (λv. χ i. (frechet_derivative (λx. f x $ i) (at x) v))" apply (rule frechet_derivative_at' (*‹(?f has_derivative ?s) (at ?x) ⟹ frechet_derivative ?f (at ?x) = ?s›*)) (*goal: ‹frechet_derivative f (at x) = (λv. χi. frechet_derivative (λx. f x $ i) (at x) v)›*) apply (intro has_derivative_vec_lambda (*‹(⋀i. ((λx. ?f x $ i) has_derivative (λx. ?f' x $ i)) (at ?x within ?s)) ⟹ (?f has_derivative ?f') (at ?x within ?s)›*)) (*goal: ‹((f::'a::real_normed_vector ⇒ ('b::real_normed_vector, 'm::finite) vec) has_derivative (λv::'a::real_normed_vector. χi::'m::finite. frechet_derivative (λx::'a::real_normed_vector. f x $ i) (at (x::'a::real_normed_vector)) v)) (at x)›*) 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 135 facts*) frechet_derivative_worksI[OF assms] (*‹((λx. f x $ ?i1) has_derivative frechet_derivative (λx. f x $ ?i1) (at x)) (at x)›*)) lemma higher_differentiable_on_vec: fixes f::"'a::real_normed_vector ⇒ 'b::real_normed_vector^'m" assumes "⋀i. higher_differentiable_on S (λx. (f x) $ i) n" and "open S" shows "higher_differentiable_on S f n" using assms (*‹higher_differentiable_on S (λx. f x $ ?i) n› ‹open S›*) proof (induction n arbitrary: f) (*goals: 1. ‹⋀f::'a ⇒ ('b, 'm) vec. ⟦⋀i::'m. higher_differentiable_on (S::'a set) (λx::'a. f x $ i) (0::nat); open S⟧ ⟹ higher_differentiable_on S f (0::nat)› 2. ‹⋀(n::nat) f::'a ⇒ ('b, 'm) vec. ⟦⋀f::'a ⇒ ('b, 'm) vec. ⟦⋀i::'m. higher_differentiable_on (S::'a set) (λx::'a. f x $ i) n; open S⟧ ⟹ higher_differentiable_on S f n; ⋀i::'m. higher_differentiable_on S (λx::'a. f x $ i) (Suc n); open S⟧ ⟹ higher_differentiable_on S f (Suc n)›*) case 0 (*‹higher_differentiable_on S (λx. f x $ ?i) 0› ‹open S›*) then show "?case" (*goal: ‹higher_differentiable_on S f 0›*) using continuous_on_vec (*‹(⋀i. continuous_on ?S (λx. ?f x $ i)) ⟹ continuous_on ?S ?f›*) by (metis higher_differentiable_on.simps( (*‹higher_differentiable_on ?S ?f 0 = continuous_on ?S ?f›*) 1)) next (*goal: ‹⋀n f. ⟦⋀f. ⟦⋀i. higher_differentiable_on S (λx. f x $ i) n; open S⟧ ⟹ higher_differentiable_on S f n; ⋀i. higher_differentiable_on S (λx. f x $ i) (Suc n); open S⟧ ⟹ higher_differentiable_on S f (Suc n)›*) case (Suc n) (*‹⟦⋀i::'m. higher_differentiable_on (S::'a set) (λx::'a. (?f::'a ⇒ ('b, 'm) vec) x $ i) (n::nat); open S⟧ ⟹ higher_differentiable_on S ?f n› ‹higher_differentiable_on (S::'a set) (λx::'a. (f::'a ⇒ ('b, 'm) vec) x $ (?i::'m)) (Suc (n::nat))› ‹open S›*) have f: "⋀x i. x ∈ S ⟹ (λx. f x $ i) differentiable (at x)" and hf: "⋀i. higher_differentiable_on S (λx. frechet_derivative (λy. f y $ i) (at x) v) n" for v using Suc.prems (*‹higher_differentiable_on S (λx. f x $ ?i) (Suc n)› ‹open S›*) higher_differentiable_on.simps(2) (*‹higher_differentiable_on ?S ?f (Suc ?n) = ((∀x∈?S. ?f differentiable at x) ∧ (∀v. higher_differentiable_on ?S (λx. frechet_derivative ?f (at x) v) ?n))›*) apply - (*goals: 1. ‹⋀(x::'a) i::'m. ⟦x ∈ (S::'a set); ⋀i::'m. higher_differentiable_on S (λx::'a. (f::'a ⇒ ('b, 'm) vec) x $ i) (Suc (n::nat)); open S; ⋀(S::?'a8 set) (f::?'a8 ⇒ ?'b8) n::nat. higher_differentiable_on S f (Suc n) = ((∀x::?'a8∈S. f differentiable at x) ∧ (∀v::?'a8. higher_differentiable_on S (λx::?'a8. frechet_derivative f (at x) v) n))⟧ ⟹ (λx::'a. f x $ i) differentiable at x› 2. ‹⋀i::'m. ⟦⋀i::'m. higher_differentiable_on (S::'a set) (λx::'a. (f::'a ⇒ ('b, 'm) vec) x $ i) (Suc (n::nat)); open S; ⋀(S::?'a3 set) (f::?'a3 ⇒ ?'b3) n::nat. higher_differentiable_on S f (Suc n) = ((∀x::?'a3∈S. f differentiable at x) ∧ (∀v::?'a3. higher_differentiable_on S (λx::?'a3. frechet_derivative f (at x) v) n))⟧ ⟹ higher_differentiable_on S (λx::'a. frechet_derivative (λy::'a. f y $ i) (at x) (v::'a)) n› discuss goal 1*) apply blast (*discuss goal 2*) apply blast (*proven 2 subgoals*) . have f': "higher_differentiable_on S f n" using Suc(1,2) (*‹⟦⋀i. higher_differentiable_on S (λx. ?f x $ i) n; open S⟧ ⟹ higher_differentiable_on S ?f n› ‹higher_differentiable_on S (λx. f x $ ?i) (Suc n)›*) assms(2) (*‹open S›*) higher_differentiable_on_SucD (*‹higher_differentiable_on ?S ?f (Suc ?n) ⟹ higher_differentiable_on ?S ?f ?n›*) by blast have 1: "∀x∈S. f differentiable (at x)" using f (*‹?x ∈ S ⟹ (λx. f x $ ?i) differentiable at ?x›*) differentiable_componentwise[of f _ UNIV] (*‹(⋀i::'m. (λx::'a. (f::'a ⇒ ('b, 'm) vec) x $ i) differentiable at (?x::'a)) ⟹ f differentiable at ?x›*) by simp have 2: "∀v. higher_differentiable_on S (λx. frechet_derivative f (at x) v) n" proof (intro allI (*‹(⋀x. ?P x) ⟹ ∀x. ?P x›*)) (*goal: ‹⋀v::'a. higher_differentiable_on (S::'a set) (λx::'a. frechet_derivative (f::'a ⇒ ('b, 'm) vec) (at x) v) (n::nat)›*) fix v let ?f' = "λx. frechet_derivative f (at x) v" let ?f'⇩i = "λx. χ i. frechet_derivative (λy. f y $ i) (at x) v" { fix x assume "x ∈ S" (*‹(x::'a) ∈ (S::'a set)›*) hence "?f' x = (χ i. frechet_derivative (λy. f y $ i) (at x) v)" using frechet_derivative_vec[OF f] (*‹(⋀i. ?x ∈ S) ⟹ frechet_derivative f (at ?x) = (λv. χi. frechet_derivative (λx. f x $ i) (at ?x) v)›*) by simp } then have "higher_differentiable_on S ?f' n = higher_differentiable_on S ?f'⇩i n" using higher_differentiable_on_cong[of S S "?f'" "?f'⇩i" n] (*‹⟦open S; S = S; ⋀x. x ∈ S ⟹ frechet_derivative f (at x) v = (χi. frechet_derivative (λy. f y $ i) (at x) v)⟧ ⟹ higher_differentiable_on S (λx. frechet_derivative f (at x) v) n = higher_differentiable_on S (λx. χi. frechet_derivative (λy. f y $ i) (at x) v) n›*) assms(2) (*‹open S›*) by simp then show "higher_differentiable_on S ?f' n" using hf (*‹higher_differentiable_on S (λx. frechet_derivative (λy. f y $ ?i) (at x) ?v1) n›*) Suc.IH (*‹⟦⋀i::'m::finite. higher_differentiable_on (S::'a::real_normed_vector set) (λx::'a::real_normed_vector. (?f::'a::real_normed_vector ⇒ ('b::real_normed_vector, 'm::finite) vec) x $ i) (n::nat); open S⟧ ⟹ higher_differentiable_on S ?f n›*) assms(2) (*‹open (S::'a set)›*) by auto qed show "?case" (*goal: ‹higher_differentiable_on (S::'a set) (f::'a ⇒ ('b, 'm) vec) (Suc (n::nat))›*) by (simp add: 1 (*‹∀x∈S. f differentiable at x›*) 2 (*‹∀v. higher_differentiable_on S (λx. frechet_derivative f (at x) v) n›*) higher_differentiable_on.simps( (*‹higher_differentiable_on ?S ?f (Suc ?n) = ((∀x∈?S. ?f differentiable at x) ∧ (∀v. higher_differentiable_on ?S (λx. frechet_derivative ?f (at x) v) ?n))›*) 2)) qed lemma smooth_on_vec: fixes f::"'a::real_normed_vector ⇒ 'b::real_normed_vector^'m" assumes "⋀i. k-smooth_on S (λx. (f x) $ i)" "open S" shows "k-smooth_on S f" apply (unfold smooth_on_def (*‹?k-smooth_on ?S ?f = (∀n. enat n ≤ ?k ⟶ higher_differentiable_on ?S ?f n)›*)) (*goal: ‹k-smooth_on S f›*) proof (intro allI (*‹(⋀x. ?P x) ⟹ ∀x. ?P x›*) impI (*‹(?P ⟹ ?Q) ⟹ ?P ⟶ ?Q›*)) (*goal: ‹⋀n::nat. enat n ≤ (k::enat) ⟹ higher_differentiable_on (S::'a set) (f::'a ⇒ ('b, 'm) vec) n›*) fix n assume asm: "enat n ≤ k" (*‹enat (n::nat) ≤ (k::enat)›*) show "higher_differentiable_on S f n" apply (intro higher_differentiable_on_vec (*‹⟦⋀i. higher_differentiable_on ?S (λx. ?f x $ i) ?n; open ?S⟧ ⟹ higher_differentiable_on ?S ?f ?n›*)) (*goal: ‹higher_differentiable_on (S::'a::real_normed_vector set) (f::'a::real_normed_vector ⇒ ('b::real_normed_vector, 'm::finite) vec) (n::nat)›*) using assms (*‹(k::enat)-smooth_on (S::'a set) (λx::'a. (f::'a ⇒ ('b, 'm) vec) x $ (?i::'m))› ‹open S›*) asm (*‹enat n ≤ k›*) unfolding smooth_on_def (*goals: 1. ‹⋀i. higher_differentiable_on S (λx. f x $ i) n› 2. ‹open S›*) apply - (*goals: 1. ‹⋀i. ⟦⋀i. ∀n. enat n ≤ k ⟶ higher_differentiable_on S (λx. f x $ i) n; open S; enat n ≤ k⟧ ⟹ higher_differentiable_on S (λx. f x $ i) n› 2. ‹⟦⋀i. ∀n. enat n ≤ k ⟶ higher_differentiable_on S (λx. f x $ i) n; open S; enat n ≤ k⟧ ⟹ open S› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) . qed lemma smooth_on_mat: fixes f::"('a::real_normed_vector) ⇒ ('b::real_normed_vector^'k^'l)" assumes "⋀i j. k-smooth_on S (λx. (f x)$i$j)" "open S" shows "k-smooth_on S f" by (simp add: smooth_on_vec (*‹⟦⋀i. ?k-smooth_on ?S (λx. ?f x $ i); open ?S⟧ ⟹ ?k-smooth_on ?S ?f›*) assms (*‹k-smooth_on S (λx. f x $ ?i $ ?j)› ‹open S›*)) text ‹This type constraint is annoying. The ‹euclidean_space› is inherited from ‹higher_differentiable_on_compose›, where it is marked as: `TODO: can we get around this restriction?`. Notice this type constraint is exactly ‹real_normed_eucl› as defined in ‹Classical_Groups›.› lemma smooth_on_matrix_inv_component: fixes S::"('a::{euclidean_space,real_normed_field}^'n^'n) set" assumes "∀A∈S. invertible A" "open S" shows "k-smooth_on S (λA. (matrix_inv A)$i$j)" using matrix_inverse_component (*‹invertible ?A ⟹ matrix_inv ?A $ ?i $ ?j = det (χk l. if k = ?j ∧ l = ?i then 1 else if k = ?j ∨ l = ?i then 0 else ?A $ k $ l) / det ?A›*) smooth_on_mat (*‹⟦⋀i j. ?k-smooth_on ?S (λx. ?f x $ i $ j); open ?S⟧ ⟹ ?k-smooth_on ?S ?f›*) smooth_on_det (*‹open (?s::((?'a::real_normed_field, ?'n::finite) vec, ?'n::finite) vec set) ⟹ (?k::enat)-smooth_on ?s det›*) smooth_on_compose (*‹⟦?k-smooth_on ?T ?f; ?k-smooth_on ?S ?g; open ?S; open ?T; ?g ` ?S ⊆ ?T⟧ ⟹ ?k-smooth_on ?S (?f ∘ ?g)›*) smooth_on_divide (*‹⟦?k-smooth_on ?S ?f; ?k-smooth_on ?S ?g; open ?S; ⋀x. x ∈ ?S ⟹ ?g x ≠ 0⟧ ⟹ ?k-smooth_on ?S (λx. ?f x / ?g x)›*) smooth_on_cong (*‹⟦?k-smooth_on ?S ?g; open ?S; ⋀x. x ∈ ?S ⟹ ?f x = ?g x⟧ ⟹ ?k-smooth_on ?S ?f›*) proof (-) (*goal: ‹⟦⋀A i j. invertible A ⟹ matrix_inv A $ i $ j = det (χk l. if k = j ∧ l = i then 1 else if k = j ∨ l = i then 0 else A $ k $ l) / det A; ⋀k S f. ⟦⋀i j. k-smooth_on S (λx. f x $ i $ j); open S⟧ ⟹ k-smooth_on S f; ⋀s k. open s ⟹ k-smooth_on s det; ⋀k T f S g. ⟦k-smooth_on T f; k-smooth_on S g; open S; open T; g ` S ⊆ T⟧ ⟹ k-smooth_on S (f ∘ g); ⋀k S f g. ⟦k-smooth_on S f; k-smooth_on S g; open S; ⋀x. x ∈ S ⟹ g x ≠ 0⟧ ⟹ k-smooth_on S (λx. f x / g x); ⋀k S g f. ⟦k-smooth_on S g; open S; ⋀x. x ∈ S ⟹ f x = g x⟧ ⟹ k-smooth_on S f⟧ ⟹ k-smooth_on S (λA. matrix_inv A $ i $ j)›*) have smooth_on_div_det: "k-smooth_on S (λx. f x / (det x))" if "smooth_on S f" for f apply (intro smooth_on_divide[of k S f det] (*‹⟦k-smooth_on S f; k-smooth_on S det; open S; ⋀x. x ∈ S ⟹ det x ≠ 0⟧ ⟹ k-smooth_on S (λx. f x / det x)›*)) (*goal: ‹k-smooth_on S (λx. f x / det x)›*) using that (*‹smooth_on S f›*) smooth_on_det[OF assms ( 2 )] (*‹?k-smooth_on S det›*) assms (*‹∀A∈S. invertible A› ‹open (S::(('a, 'n) vec, 'n) vec set)›*) apply - (*goals: 1. ‹⟦smooth_on S f; ⋀k. k-smooth_on S det; ∀A∈S. invertible A; open S⟧ ⟹ k-smooth_on S f› 2. ‹⟦smooth_on S f; ⋀k. k-smooth_on S det; ∀A∈S. invertible A; open S⟧ ⟹ k-smooth_on S det› 3. ‹⟦smooth_on S f; ⋀k. k-smooth_on S det; ∀A∈S. invertible A; open S⟧ ⟹ open S› 4. ‹⋀x. ⟦x ∈ S; smooth_on S f; ⋀k. k-smooth_on S det; ∀A∈S. invertible A; open S⟧ ⟹ det x ≠ 0› discuss goal 1*) apply ((auto simp: smooth_on_def (*‹?k-smooth_on ?S ?f = (∀n. enat n ≤ ?k ⟶ higher_differentiable_on ?S ?f n)›*) invertible_det_nz (*‹invertible ?A = (det ?A ≠ 0)›*))[1]) (*discuss goal 2*) apply ((auto simp: smooth_on_def (*‹?k-smooth_on ?S ?f = (∀n. enat n ≤ ?k ⟶ higher_differentiable_on ?S ?f n)›*) invertible_det_nz (*‹invertible ?A = (det ?A ≠ 0)›*))[1]) (*discuss goal 3*) apply ((auto simp: smooth_on_def (*‹?k-smooth_on ?S ?f = (∀n. enat n ≤ ?k ⟶ higher_differentiable_on ?S ?f n)›*) invertible_det_nz (*‹invertible ?A = (det ?A ≠ 0)›*))[1]) (*discuss goal 4*) apply ((auto simp: smooth_on_def (*‹(?k::enat)-smooth_on (?S::?'a set) (?f::?'a ⇒ ?'b) = (∀n::nat. enat n ≤ ?k ⟶ higher_differentiable_on ?S ?f n)›*) invertible_det_nz (*‹invertible (?A::((?'a, ?'n) vec, ?'n) vec) = (det ?A ≠ (0::?'a))›*))[1]) (*proven 4 subgoals*) . let ?inv_comp' = "λA::'a^'n^'n. χ k l. if k = j ∧ l = i then 1 else if k = j ∨ l = i then 0 else A $ k $ l" let ?inv_comp = "λA::'a^'n^'n. det (?inv_comp' A) / det A" have matrix_inv_cong: "⋀A. A∈S ⟹ (matrix_inv A)$i$j = ?inv_comp A" using matrix_inverse_component (*‹invertible ?A ⟹ matrix_inv ?A $ ?i $ ?j = det (χk l. if k = ?j ∧ l = ?i then 1 else if k = ?j ∨ l = ?i then 0 else ?A $ k $ l) / det ?A›*) assms (*‹∀A∈S. invertible A› ‹open S›*) by blast have smooth_on_component: "smooth_on S ?inv_comp'" proof (intro smooth_on_mat[of ∞ S ?inv_comp'] (*‹⟦⋀ia ja. smooth_on S (λx. (χk l. if k = j ∧ l = i then 1 else if k = j ∨ l = i then 0 else x $ k $ l) $ ia $ ja); open S⟧ ⟹ smooth_on S (λA. χk l. if k = j ∧ l = i then 1 else if k = j ∨ l = i then 0 else A $ k $ l)›*)) (*goals: 1. ‹⋀ia ja. smooth_on S (λx. (χk l. if k = j ∧ l = i then 1 else if k = j ∨ l = i then 0 else x $ k $ l) $ ia $ ja)› 2. ‹open S›*) fix n and m consider "n=j ∧ m=i" | "n=j ∧ m≠i" | "n≠j ∧ m=i" | "n≠j ∧ m≠i" (*goal: ‹⟦n = j ∧ m = i ⟹ thesis; n = j ∧ m ≠ i ⟹ thesis; n ≠ j ∧ m = i ⟹ thesis; n ≠ j ∧ m ≠ i ⟹ thesis⟧ ⟹ thesis›*) by linarith hence "smooth_on S (λx. if n = j ∧ m = i then 1 else if n = j ∨ m = i then 0 else x$n$m)" apply cases (*goals: 1. ‹n = j ∧ m = i ⟹ smooth_on S (λx. if n = j ∧ m = i then 1 else if n = j ∨ m = i then 0 else x $ n $ m)› 2. ‹n = j ∧ m ≠ i ⟹ smooth_on S (λx. if n = j ∧ m = i then 1 else if n = j ∨ m = i then 0 else x $ n $ m)› 3. ‹n ≠ j ∧ m = i ⟹ smooth_on S (λx. if n = j ∧ m = i then 1 else if n = j ∨ m = i then 0 else x $ n $ m)› 4. ‹n ≠ j ∧ m ≠ i ⟹ smooth_on S (λx. if n = j ∧ m = i then 1 else if n = j ∨ m = i then 0 else x $ n $ m)› discuss goal 1*) apply (simp add: smooth_on_const (*‹(?k::enat)-smooth_on (?S::?'a set) (λx::?'a. ?c::?'b)›*) smooth_on_ijth_of_mat (*‹smooth_on (?s::((?'a, ?'n) vec, ?'n) vec set) (λx::((?'a, ?'n) vec, ?'n) vec. x $ (?i::?'n) $ (?j::?'n))›*)) (*discuss goal 2*) apply (simp add: smooth_on_const (*‹?k-smooth_on ?S (λx. ?c)›*) smooth_on_ijth_of_mat (*‹smooth_on ?s (λx. x $ ?i $ ?j)›*)) (*discuss goal 3*) apply (simp add: smooth_on_const (*‹?k-smooth_on ?S (λx. ?c)›*) smooth_on_ijth_of_mat (*‹smooth_on ?s (λx. x $ ?i $ ?j)›*)) (*discuss goal 4*) apply (simp add: smooth_on_const (*‹?k-smooth_on ?S (λx. ?c)›*) smooth_on_ijth_of_mat (*‹smooth_on ?s (λx. x $ ?i $ ?j)›*)) (*proven 4 subgoals*) . thus "smooth_on S (λx. (χ k l. if k = j ∧ l = i then 1 else if k = j ∨ l = i then 0 else x $ k $ l) $ n $ m)" by simp qed (fact) (*solved the remaining goal: ‹open S›*) thus "k-smooth_on S (λA. (matrix_inv A)$i$j)" apply (intro smooth_on_cong[OF _ assms(2) matrix_inv_cong] (*‹⟦?k-smooth_on S (λx. det (χk l. if k = j ∧ l = i then 1 else if k = j ∨ l = i then 0 else ?A1 x $ k $ l) / det (?A1 x)); ⋀x. x ∈ S ⟹ ?A1 x ∈ S⟧ ⟹ ?k-smooth_on S (λx. matrix_inv (?A1 x) $ i $ j)›*)) (*goal: ‹k-smooth_on S (λA. matrix_inv A $ i $ j)›*) apply (intro smooth_on_div_det[of "λA. det (?inv_comp' A)"] (*‹smooth_on S (λA. det (χk l. if k = j ∧ l = i then 1 else if k = j ∨ l = i then 0 else A $ k $ l)) ⟹ k-smooth_on S (λx. det (χk l. if k = j ∧ l = i then 1 else if k = j ∨ l = i then 0 else x $ k $ l) / det x)›*)) (*top goal: ‹smooth_on (S::(('a::{euclidean_space,real_normed_field}, 'n::finite) vec, 'n::finite) vec set) (λA::(('a::{euclidean_space,real_normed_field}, 'n::finite) vec, 'n::finite) vec. χ(k::'n::finite) l::'n::finite. if k = (j::'n::finite) ∧ l = (i::'n::finite) then 1::'a::{euclidean_space,real_normed_field} else if k = j ∨ l = i then 0::'a::{euclidean_space,real_normed_field} else A $ k $ l) ⟹ (k::enat)-smooth_on S (λA::(('a::{euclidean_space,real_normed_field}, 'n::finite) vec, 'n::finite) vec. det (χ(k::'n::finite) l::'n::finite. if k = j ∧ l = i then 1::'a::{euclidean_space,real_normed_field} else if k = j ∨ l = i then 0::'a::{euclidean_space,real_normed_field} else A $ k $ l) / det A)› and 1 goal remains*) using smooth_on_compose[of ∞ UNIV det S ?inv_comp'] (*‹⟦smooth_on UNIV det; smooth_on S (λA. χk l. if k = j ∧ l = i then 1 else if k = j ∨ l = i then 0 else A $ k $ l); open S; open UNIV; (λA. χk l. if k = j ∧ l = i then 1 else if k = j ∨ l = i then 0 else A $ k $ l) ` S ⊆ UNIV⟧ ⟹ smooth_on S (det ∘ (λA. χk l. if k = j ∧ l = i then 1 else if k = j ∨ l = i then 0 else A $ k $ l))›*) smooth_on_det[OF open_UNIV] (*‹(?k::enat)-smooth_on UNIV det›*) using assms(2) (*‹open S›*) 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 S (λA. χk l. if k = j ∧ l = i then 1 else if k = j ∨ l = i then 0 else A $ k $ l) ⟹ smooth_on S (λA. det (χk l. if k = j ∧ l = i then 1 else if k = j ∨ l = i then 0 else A $ k $ l))› 2. ‹⋀A. ⟦smooth_on S (λA. χk l. if k = j ∧ l = i then 1 else if k = j ∨ l = i then 0 else A $ k $ l); A ∈ S⟧ ⟹ A ∈ S› discuss goal 1*) apply fastforce (*discuss goal 2*) . (*proven 2 subgoals*) qed lemma fin_sum_over_delta: fixes f::"'n::finite ⇒ 'a::semiring_1" shows "(∑(i::'n::finite)∈UNIV. ((if i=j then 1 else 0) * f i)) = f j" proof (-) (*goal: ‹(∑i∈UNIV. (if i = j then 1 else 0) * f i) = f j›*) have "(∑i∈UNIV. (if i = j then 1 else 0) * f i) = (∑i∈UNIV. (if i=j then f j else 0))" by (simp add: mult_delta_left (*‹(if ?b then ?x else 0) * ?y = (if ?b then ?x * ?y else 0)›*)) also (*calculation: ‹(∑i∈UNIV. (if i = j then 1 else 0) * f i) = (∑i∈UNIV. if i = j then f j else 0)›*) have "(∑i∈UNIV. (if i=j then f j else 0)) = f j" using sum.delta (*‹finite ?S ⟹ (∑k∈?S. if k = ?a then ?b k else 0) = (if ?a ∈ ?S then ?b ?a else 0)›*) by auto then show "?thesis" (*goal: ‹(∑i∈UNIV. (if i = j then 1 else 0) * f i) = f j›*) by (simp add: calculation (*‹(∑i∈UNIV. (if i = j then 1 else 0) * f i) = (∑i∈UNIV. if i = j then f j else 0)›*)) qed lemma matrix_is_linear_map: fixes A::"('a::{real_algebra_1,comm_semiring_1})^'m^'n" ― ‹again, real-based entries only...› shows "linear ((*v) A) ∧ matrix ((*v) A) = A" proof (rule conjI (*‹⟦?P; ?Q⟧ ⟹ ?P ∧ ?Q›*)) (*goals: 1. ‹linear ((*v) A)› 2. ‹matrix ((*v) A) = A›*) let ?f = "λv. (A *v v)" show "linear ?f" using matrix_vector_mul_linear (*‹linear ((*v) ?A)›*) by simp { fix i :: 'n and j :: 'm let ?v = "χ j'. if j' = j then 1 else 0" have "?v $ k = (if k=j then 1 else 0)" for k by simp then have "A *v ?v = transpose A $ j" using matrix_vector_column[where A = A and x = "?v"] (*‹A *v (χj'. if j' = j then 1 else 0) = (∑i∈UNIV. (χj'. if j' = j then 1 else 0) $ i *s Finite_Cartesian_Product.transpose A $ i)›*) fin_sum_over_delta (*‹(∑i∈UNIV. (if i = ?j then 1 else 0) * ?f i) = ?f ?j›*) by (smt (verit, best) mult.commute (*‹?a * ?b = ?b * ?a›*) mult.right_neutral (*‹?a * 1 = ?a›*) mult_zero_right (*‹?a * 0 = 0›*) sum.cong (*‹⟦?A = ?B; ⋀x. x ∈ ?B ⟹ ?g x = ?h x⟧ ⟹ sum ?g ?A = sum ?h ?B›*) vector_smult_lid (*‹1 *s ?x = ?x›*) vector_smult_lzero (*‹0 *s ?x = 0›*)) then have "(A *v (χ j'. if j' = j then 1 else 0))$i = A$i$j" using matrix_vector_column[where x = "?v"] (*‹(?A::((?'b2, 'm) vec, ?'b) vec) *v (χj'::'m. if j' = (j::'m) then 1::?'b2 else (0::?'b2)) = (∑i::'m∈UNIV. (χj'::'m. if j' = j then 1::?'b2 else (0::?'b2)) $ i *s Finite_Cartesian_Product.transpose ?A $ i)›*) transpose_def (*‹Finite_Cartesian_Product.transpose ?A = (χi j. ?A $ j $ i)›*) vec_lambda_beta (*‹vec_lambda ?g $ ?i = ?g ?i›*) by (smt (z3)) } then show "matrix ?f = A" unfolding matrix_def axis_def (*goal: ‹(χ(i::'n) j::'m. ((A::(('a, 'm) vec, 'n) vec) *v (χi::'m. if i = j then 1::'a else (0::'a))) $ i) = A›*) by auto qed lemma smooth_on_matrix_inv: assumes "∀A. A∈S ⟶ invertible A" "open S" shows "k-smooth_on S (matrix_inv::'a::{euclidean_space,real_normed_field}^'n^'n ⇒ 'a^'n^'n)" apply (intro smooth_on_mat[of k S] (*‹⟦⋀i j. k-smooth_on S (λx. ?f x $ i $ j); open S⟧ ⟹ k-smooth_on S ?f›*)) (*goals: 1. ‹⋀i j. k-smooth_on S (λx. matrix_inv x $ i $ j)› 2. ‹open S› discuss goal 1*) apply (intro smooth_on_matrix_inv_component[of S] (*‹⟦∀A∈S. invertible A; open S⟧ ⟹ ?k-smooth_on S (λA. matrix_inv A $ ?i $ ?j)›*)) (*goals: 1. ‹⋀i j. ∀x∈S. invertible x› 2. ‹⋀i j. open S› discuss goal 1*) apply ((auto simp add: assms (*‹∀A::(('a::{euclidean_space,real_normed_field}, 'n::finite) vec, 'n::finite) vec. A ∈ (S::(('a::{euclidean_space,real_normed_field}, 'n::finite) vec, 'n::finite) vec set) ⟶ invertible A› ‹open (S::(('a::{euclidean_space,real_normed_field}, 'n::finite) vec, 'n::finite) vec set)›*))[1]) (*discuss goal 2*) apply ((auto simp add: assms (*‹∀A. A ∈ S ⟶ invertible A› ‹open S›*))[1]) (*proven 2 subgoals*) (*discuss goal 2*) apply ((auto simp add: assms (*‹∀A::(('a::{euclidean_space,real_normed_field}, 'n::finite) vec, 'n::finite) vec. A ∈ (S::(('a::{euclidean_space,real_normed_field}, 'n::finite) vec, 'n::finite) vec set) ⟶ invertible A› ‹open (S::(('a::{euclidean_space,real_normed_field}, 'n::finite) vec, 'n::finite) vec set)›*))[1]) (*proven 2 subgoals*) . end
{ "path": "afp-2025-02-12/thys/Lie_Groups/Linear_Algebra_More.thy", "repo": "afp-2025-02-12", "sha": "4e1fdf5ba107f8699008bc7e18a32a0976f10b28e9c6bed5039364c7e9d4b6d0" }
(* Title: HOL/HOLCF/UpperPD.thy Author: Brian Huffman *) section ‹Upper powerdomain› theory UpperPD imports Compact_Basis begin subsection ‹Basis preorder› definition upper_le :: "'a pd_basis ⇒ 'a pd_basis ⇒ bool" (infix "≤♯" 50) where "upper_le = (λu v. ∀y∈Rep_pd_basis v. ∃x∈Rep_pd_basis u. x ⊑ y)" lemma upper_le_refl [simp]: "t ≤♯ t" unfolding upper_le_def (*goal: ‹∀y∈Rep_pd_basis t. ∃x∈Rep_pd_basis t. x ⊑ y›*) by fast lemma upper_le_trans: "⟦t ≤♯ u; u ≤♯ v⟧ ⟹ t ≤♯ v" unfolding upper_le_def (*goal: ‹⟦∀y∈Rep_pd_basis u. ∃x∈Rep_pd_basis t. x ⊑ y; ∀y∈Rep_pd_basis v. ∃x∈Rep_pd_basis u. x ⊑ y⟧ ⟹ ∀y∈Rep_pd_basis v. ∃x∈Rep_pd_basis t. x ⊑ y›*) apply (rule ballI (*‹(⋀x. x ∈ ?A ⟹ ?P x) ⟹ ∀x∈?A. ?P x›*)) (*goal: ‹⟦∀y∈Rep_pd_basis u. ∃x∈Rep_pd_basis t. x ⊑ y; ∀y∈Rep_pd_basis v. ∃x∈Rep_pd_basis u. x ⊑ y⟧ ⟹ ∀y∈Rep_pd_basis v. ∃x∈Rep_pd_basis t. x ⊑ y›*) apply (drule (1) bspec (*‹⟦∀x∈?A. ?P x; ?x ∈ ?A⟧ ⟹ ?P ?x›*)) (*goal: ‹⋀y::'a compact_basis. ⟦∀y::'a compact_basis∈Rep_pd_basis (u::'a pd_basis). ∃x::'a compact_basis∈Rep_pd_basis (t::'a pd_basis). x ⊑ y; ∀y::'a compact_basis∈Rep_pd_basis (v::'a pd_basis). ∃x::'a compact_basis∈Rep_pd_basis u. x ⊑ y; y ∈ Rep_pd_basis v⟧ ⟹ ∃x::'a compact_basis∈Rep_pd_basis t. x ⊑ y›*) apply (erule bexE (*‹⟦∃x∈?A. ?P x; ⋀x. ⟦x ∈ ?A; ?P x⟧ ⟹ ?Q⟧ ⟹ ?Q›*)) (*goal: ‹⋀y::'a::bifinite compact_basis. ⟦∀y::'a::bifinite compact_basis∈Rep_pd_basis (u::'a::bifinite pd_basis). ∃x::'a::bifinite compact_basis∈Rep_pd_basis (t::'a::bifinite pd_basis). x ⊑ y; y ∈ Rep_pd_basis (v::'a::bifinite pd_basis); ∃x::'a::bifinite compact_basis∈Rep_pd_basis u. x ⊑ y⟧ ⟹ ∃x::'a::bifinite compact_basis∈Rep_pd_basis t. x ⊑ y›*) apply (drule (1) bspec (*‹⟦∀x∈?A. ?P x; ?x ∈ ?A⟧ ⟹ ?P ?x›*)) (*goal: ‹⋀y x. ⟦∀y∈Rep_pd_basis u. ∃x∈Rep_pd_basis t. x ⊑ y; y ∈ Rep_pd_basis v; x ∈ Rep_pd_basis u; x ⊑ y⟧ ⟹ ∃x∈Rep_pd_basis t. x ⊑ y›*) apply (erule bexE (*‹⟦∃x∈?A. ?P x; ⋀x. ⟦x ∈ ?A; ?P x⟧ ⟹ ?Q⟧ ⟹ ?Q›*)) (*goal: ‹⋀y x. ⟦y ∈ Rep_pd_basis v; x ∈ Rep_pd_basis u; x ⊑ y; ∃xa∈Rep_pd_basis t. xa ⊑ x⟧ ⟹ ∃x∈Rep_pd_basis t. x ⊑ y›*) apply (erule rev_bexI (*‹⟦?x ∈ ?A; ?P ?x⟧ ⟹ ∃x∈?A. ?P x›*)) (*goal: ‹⋀y x xa. ⟦y ∈ Rep_pd_basis v; x ∈ Rep_pd_basis u; x ⊑ y; xa ∈ Rep_pd_basis t; xa ⊑ x⟧ ⟹ ∃x∈Rep_pd_basis t. x ⊑ y›*) by (erule (1) below_trans (*‹⟦?x ⊑ ?y; ?y ⊑ ?z⟧ ⟹ ?x ⊑ ?z›*)) interpretation upper_le: preorder upper_le apply (rule preorder.intro (*‹⟦⋀x. ?r x x; ⋀x y z. ⟦?r x y; ?r y z⟧ ⟹ ?r x z⟧ ⟹ preorder ?r›*)) (*goals: 1. ‹⋀x. x ≤♯ x› 2. ‹⋀x y z. ⟦x ≤♯ y; y ≤♯ z⟧ ⟹ x ≤♯ z› discuss goal 1*) apply (rule upper_le_refl (*‹?t ≤♯ ?t›*)) (*discuss goal 2*) apply (rule upper_le_trans (*‹⟦?t ≤♯ ?u; ?u ≤♯ ?v⟧ ⟹ ?t ≤♯ ?v›*)) (*goals: 1. ‹⋀x y z. ⟦x ≤♯ y; y ≤♯ z⟧ ⟹ x ≤♯ ?u5 x y z› 2. ‹⋀x y z. ⟦x ≤♯ y; y ≤♯ z⟧ ⟹ ?u5 x y z ≤♯ z› discuss goal 1*) apply ((assumption)[1]) (*discuss goal 2*) . (*proven 2 subgoals*) (*proven 2 subgoals*) lemma upper_le_minimal [simp]: "PDUnit compact_bot ≤♯ t" unfolding upper_le_def Rep_PDUnit (*goal: ‹∀y∈Rep_pd_basis t. ∃x∈{compact_bot}. x ⊑ y›*) by simp lemma PDUnit_upper_mono: "x ⊑ y ⟹ PDUnit x ≤♯ PDUnit y" unfolding upper_le_def Rep_PDUnit (*goal: ‹x ⊑ y ⟹ ∀y∈{y}. ∃x∈{x}. x ⊑ y›*) by simp lemma PDPlus_upper_mono: "⟦s ≤♯ t; u ≤♯ v⟧ ⟹ PDPlus s u ≤♯ PDPlus t v" unfolding upper_le_def Rep_PDPlus (*goal: ‹⟦∀y∈Rep_pd_basis t. ∃x∈Rep_pd_basis s. x ⊑ y; ∀y∈Rep_pd_basis v. ∃x∈Rep_pd_basis u. x ⊑ y⟧ ⟹ ∀y∈Rep_pd_basis t ∪ Rep_pd_basis v. ∃x∈Rep_pd_basis s ∪ Rep_pd_basis u. x ⊑ y›*) by fast lemma PDPlus_upper_le: "PDPlus t u ≤♯ t" unfolding upper_le_def Rep_PDPlus (*goal: ‹∀y::'a compact_basis∈Rep_pd_basis (t::'a pd_basis). ∃x::'a compact_basis∈Rep_pd_basis t ∪ Rep_pd_basis (u::'a pd_basis). x ⊑ y›*) by fast lemma upper_le_PDUnit_PDUnit_iff [simp]: "(PDUnit a ≤♯ PDUnit b) = (a ⊑ b)" unfolding upper_le_def Rep_PDUnit (*goal: ‹(∀y∈{b}. ∃x∈{a}. x ⊑ y) = (a ⊑ b)›*) by fast lemma upper_le_PDPlus_PDUnit_iff: "(PDPlus t u ≤♯ PDUnit a) = (t ≤♯ PDUnit a ∨ u ≤♯ PDUnit a)" unfolding upper_le_def Rep_PDPlus Rep_PDUnit (*goal: ‹(∀y∈{a}. ∃x∈Rep_pd_basis t ∪ Rep_pd_basis u. x ⊑ y) = ((∀y∈{a}. ∃x∈Rep_pd_basis t. x ⊑ y) ∨ (∀y∈{a}. ∃x∈Rep_pd_basis u. x ⊑ y))›*) by fast lemma upper_le_PDPlus_iff: "(t ≤♯ PDPlus u v) = (t ≤♯ u ∧ t ≤♯ v)" unfolding upper_le_def Rep_PDPlus (*goal: ‹(∀y∈Rep_pd_basis u ∪ Rep_pd_basis v. ∃x∈Rep_pd_basis t. x ⊑ y) = ((∀y∈Rep_pd_basis u. ∃x∈Rep_pd_basis t. x ⊑ y) ∧ (∀y∈Rep_pd_basis v. ∃x∈Rep_pd_basis t. x ⊑ y))›*) by fast lemma upper_le_induct [induct set: upper_le]: assumes le: "t ≤♯ u" assumes 1: "⋀a b. a ⊑ b ⟹ P (PDUnit a) (PDUnit b)" assumes 2: "⋀t u a. P t (PDUnit a) ⟹ P (PDPlus t u) (PDUnit a)" assumes 3: "⋀t u v. ⟦P t u; P t v⟧ ⟹ P t (PDPlus u v)" shows "P t u" using le (*‹(t::'a pd_basis) ≤♯ (u::'a pd_basis)›*) apply (induct u arbitrary: t rule: pd_basis_induct) (*goals: 1. ‹⋀a t. t ≤♯ PDUnit a ⟹ P t (PDUnit a)› 2. ‹⋀t u ta. ⟦⋀ta. ta ≤♯ t ⟹ P ta t; ⋀t. t ≤♯ u ⟹ P t u; ta ≤♯ PDPlus t u⟧ ⟹ P ta (PDPlus t u)› discuss goal 1*) apply (erule rev_mp (*‹⟦?P; ?P ⟶ ?Q⟧ ⟹ ?Q›*)) (*top goal: ‹⋀a t. t ≤♯ PDUnit a ⟹ P t (PDUnit a)› and 1 goal remains*) apply (induct_tac t rule: pd_basis_induct) (*goals: 1. ‹⋀a t aa. PDUnit aa ≤♯ PDUnit a ⟶ P (PDUnit aa) (PDUnit a)› 2. ‹⋀a t ta u. ⟦ta ≤♯ PDUnit a ⟶ P ta (PDUnit a); u ≤♯ PDUnit a ⟶ P u (PDUnit a)⟧ ⟹ PDPlus ta u ≤♯ PDUnit a ⟶ P (PDPlus ta u) (PDUnit a)› discuss goal 1*) apply (simp add: 1 (*‹?a ⊑ ?b ⟹ P (PDUnit ?a) (PDUnit ?b)›*)) (*discuss goal 2*) apply (simp add: upper_le_PDPlus_PDUnit_iff (*‹(PDPlus ?t ?u ≤♯ PDUnit ?a) = (?t ≤♯ PDUnit ?a ∨ ?u ≤♯ PDUnit ?a)›*)) (*top goal: ‹⋀a t ta u. ⟦ta ≤♯ PDUnit a ⟶ P ta (PDUnit a); u ≤♯ PDUnit a ⟶ P u (PDUnit a)⟧ ⟹ PDPlus ta u ≤♯ PDUnit a ⟶ P (PDPlus ta u) (PDUnit a)› and 1 goal remains*) apply (simp add: 2 (*‹P ?t (PDUnit ?a) ⟹ P (PDPlus ?t ?u) (PDUnit ?a)›*)) (*top goal: ‹⋀a ta u. ⟦ta ≤♯ PDUnit a ⟶ P ta (PDUnit a); u ≤♯ PDUnit a ⟶ P u (PDUnit a)⟧ ⟹ (ta ≤♯ PDUnit a ⟶ P (PDPlus ta u) (PDUnit a)) ∧ (u ≤♯ PDUnit a ⟶ P (PDPlus ta u) (PDUnit a))› and 1 goal remains*) apply (subst PDPlus_commute (*‹PDPlus ?t ?u = PDPlus ?u ?t›*)) (*top goal: ‹⋀(a::'a compact_basis) (ta::'a pd_basis) u::'a pd_basis. ⟦ta ≤♯ PDUnit a ⟶ (P::'a pd_basis ⇒ 'a pd_basis ⇒ bool) ta (PDUnit a); u ≤♯ PDUnit a ⟶ P u (PDUnit a)⟧ ⟹ u ≤♯ PDUnit a ⟶ P (PDPlus ta u) (PDUnit a)› and 1 goal remains*) apply (simp add: 2 (*‹P ?t (PDUnit ?a) ⟹ P (PDPlus ?t ?u) (PDUnit ?a)›*)) (*proven 2 subgoals*) (*discuss goal 2*) apply (simp add: upper_le_PDPlus_iff (*‹(?t ≤♯ PDPlus ?u ?v) = (?t ≤♯ ?u ∧ ?t ≤♯ ?v)›*) 3 (*‹⟦P ?t ?u; P ?t ?v⟧ ⟹ P ?t (PDPlus ?u ?v)›*)) (*proven 2 subgoals*) . subsection ‹Type definition› typedef 'a upper_pd ("('(_')♯)") = "{S::'a pd_basis set. upper_le.ideal S}" by (rule upper_le.ex_ideal) instantiation upper_pd :: (bifinite) below begin definition "x ⊑ y ⟷ Rep_upper_pd x ⊆ Rep_upper_pd y" instance .. end instance upper_pd :: (bifinite) po using type_definition_upper_pd below_upper_pd_def by (rule upper_le.typedef_ideal_po) instance upper_pd :: (bifinite) cpo using type_definition_upper_pd below_upper_pd_def by (rule upper_le.typedef_ideal_cpo) definition upper_principal :: "'a pd_basis ⇒ 'a upper_pd" where "upper_principal t = Abs_upper_pd {u. u ≤♯ t}" interpretation upper_pd: ideal_completion upper_le upper_principal Rep_upper_pd using type_definition_upper_pd (*‹type_definition Rep_upper_pd Abs_upper_pd (Collect upper_le.ideal)›*) below_upper_pd_def (*‹(?x ⊑ ?y) = (Rep_upper_pd ?x ⊆ Rep_upper_pd ?y)›*) using upper_principal_def (*‹upper_principal ?t = Abs_upper_pd {u. u ≤♯ ?t}›*) pd_basis_countable (*‹∃f. inj f›*) by (rule upper_le.typedef_ideal_completion (*‹⟦type_definition (?Rep::?'b ⇒ ?'a pd_basis set) (?Abs::?'a pd_basis set ⇒ ?'b) (Collect upper_le.ideal); ⋀(x::?'b) y::?'b. (x ⊑ y) = (?Rep x ⊆ ?Rep y); ⋀a::?'a pd_basis. (?principal::?'a pd_basis ⇒ ?'b) a = ?Abs {b::?'a pd_basis. b ≤♯ a}; ∃f::?'a pd_basis ⇒ nat. inj f⟧ ⟹ ideal_completion (≤♯) ?principal ?Rep›*)) text ‹Upper powerdomain is pointed› lemma upper_pd_minimal: "upper_principal (PDUnit compact_bot) ⊑ ys" apply (induct ys rule: upper_pd.principal_induct (*‹⟦adm (?P::(?'a::bifinite)♯ ⇒ bool); ⋀a::?'a::bifinite pd_basis. ?P (upper_principal a)⟧ ⟹ ?P (?x::(?'a::bifinite)♯)›*)) (*goals: 1. ‹adm ((⊑) (upper_principal (PDUnit compact_bot)))› 2. ‹⋀a::'a::bifinite pd_basis. upper_principal (PDUnit compact_bot) ⊑ upper_principal a› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) . instance upper_pd :: (bifinite) pcpo by intro_classes (fast intro: upper_pd_minimal) lemma inst_upper_pd_pcpo: "⊥ = upper_principal (PDUnit compact_bot)" by (rule upper_pd_minimal [THEN bottomI, symmetric] (*‹⊥ = upper_principal (PDUnit compact_bot)›*)) subsection ‹Monadic unit and plus› definition upper_unit :: "'a → 'a upper_pd" where "upper_unit = compact_basis.extension (λa. upper_principal (PDUnit a))" definition upper_plus :: "'a upper_pd → 'a upper_pd → 'a upper_pd" where "upper_plus = upper_pd.extension (λt. upper_pd.extension (λu. upper_principal (PDPlus t u)))" abbreviation upper_add :: "'a upper_pd ⇒ 'a upper_pd ⇒ 'a upper_pd" (infixl "∪♯" 65) where "xs ∪♯ ys == upper_plus⋅xs⋅ys" syntax "_upper_pd" :: "args ⇒ logic" ("{_}♯") translations "{x,xs}♯" == "{x}♯ ∪♯ {xs}♯" "{x}♯" == "CONST upper_unit⋅x" lemma upper_unit_Rep_compact_basis [simp]: "{Rep_compact_basis a}♯ = upper_principal (PDUnit a)" unfolding upper_unit_def (*goal: ‹compact_basis.extension (λa::'a compact_basis. upper_principal (PDUnit a))⋅(Rep_compact_basis (a::'a compact_basis)) = upper_principal (PDUnit a)›*) by (simp add: compact_basis.extension_principal (*‹(⋀a b. a ⊑ b ⟹ ?f a ⊑ ?f b) ⟹ compact_basis.extension ?f⋅(Rep_compact_basis ?a) = ?f ?a›*) PDUnit_upper_mono (*‹?x ⊑ ?y ⟹ PDUnit ?x ≤♯ PDUnit ?y›*)) lemma upper_plus_principal [simp]: "upper_principal t ∪♯ upper_principal u = upper_principal (PDPlus t u)" unfolding upper_plus_def (*goal: ‹upper_pd.extension (λt. upper_pd.extension (λu. upper_principal (PDPlus t u)))⋅(upper_principal t)⋅(upper_principal u) = upper_principal (PDPlus t u)›*) by (simp add: upper_pd.extension_principal (*‹(⋀a b. a ≤♯ b ⟹ ?f a ⊑ ?f b) ⟹ upper_pd.extension ?f⋅(upper_principal ?a) = ?f ?a›*) upper_pd.extension_mono (*‹⟦⋀a b. a ≤♯ b ⟹ ?f a ⊑ ?f b; ⋀a b. a ≤♯ b ⟹ ?g a ⊑ ?g b; ⋀a. ?f a ⊑ ?g a⟧ ⟹ upper_pd.extension ?f ⊑ upper_pd.extension ?g›*) PDPlus_upper_mono (*‹⟦?s ≤♯ ?t; ?u ≤♯ ?v⟧ ⟹ PDPlus ?s ?u ≤♯ PDPlus ?t ?v›*)) interpretation upper_add: semilattice upper_add proof (standard) (*goals: 1. ‹⋀(a::('a)♯) (b::('a)♯) c::('a)♯. a ∪♯ b ∪♯ c = a ∪♯ (b ∪♯ c)› 2. ‹⋀(a::('a)♯) b::('a)♯. a ∪♯ b = b ∪♯ a› 3. ‹⋀a::('a)♯. a ∪♯ a = a›*) fix xs :: "'a upper_pd" and ys :: "'a upper_pd" and zs :: "'a upper_pd" show "(xs ∪♯ ys) ∪♯ zs = xs ∪♯ (ys ∪♯ zs)" apply (induct xs rule: upper_pd.principal_induct (*‹⟦adm ?P; ⋀a. ?P (upper_principal a)⟧ ⟹ ?P ?x›*)) (*goals: 1. ‹adm (λa. a ∪♯ ys ∪♯ zs = a ∪♯ (ys ∪♯ zs))› 2. ‹⋀a. upper_principal a ∪♯ ys ∪♯ zs = upper_principal a ∪♯ (ys ∪♯ zs)› discuss goal 1*) apply simp (*discuss goal 2*) apply (induct ys rule: upper_pd.principal_induct (*‹⟦adm ?P; ⋀a. ?P (upper_principal a)⟧ ⟹ ?P ?x›*)) (*goals: 1. ‹adm (λa. ∀x. upper_principal x ∪♯ a ∪♯ zs = upper_principal x ∪♯ (a ∪♯ zs))› 2. ‹⋀a aa. upper_principal aa ∪♯ upper_principal a ∪♯ zs = upper_principal aa ∪♯ (upper_principal a ∪♯ zs)› discuss goal 1*) apply simp (*discuss goal 2*) apply (induct zs rule: upper_pd.principal_induct (*‹⟦adm ?P; ⋀a. ?P (upper_principal a)⟧ ⟹ ?P ?x›*)) (*goals: 1. ‹adm (λa. ∀x xa. upper_principal xa ∪♯ upper_principal x ∪♯ a = upper_principal xa ∪♯ (upper_principal x ∪♯ a))› 2. ‹⋀a aa aaa. upper_principal aaa ∪♯ upper_principal aa ∪♯ upper_principal a = upper_principal aaa ∪♯ (upper_principal aa ∪♯ upper_principal a)› discuss goal 1*) apply simp (*discuss goal 2*) apply (simp add: PDPlus_assoc (*‹PDPlus (PDPlus ?t ?u) ?v = PDPlus ?t (PDPlus ?u ?v)›*)) (*proven 2 subgoals*) (*proven 2 subgoals*) (*proven 2 subgoals*) . show "xs ∪♯ ys = ys ∪♯ xs" apply (induct xs rule: upper_pd.principal_induct (*‹⟦adm ?P; ⋀a. ?P (upper_principal a)⟧ ⟹ ?P ?x›*)) (*goals: 1. ‹adm (λa. a ∪♯ ys = ys ∪♯ a)› 2. ‹⋀a. upper_principal a ∪♯ ys = ys ∪♯ upper_principal a› discuss goal 1*) apply simp (*discuss goal 2*) apply (induct ys rule: upper_pd.principal_induct (*‹⟦adm ?P; ⋀a. ?P (upper_principal a)⟧ ⟹ ?P ?x›*)) (*goals: 1. ‹adm (λa::('a)♯. ∀x::'a pd_basis. upper_principal x ∪♯ a = a ∪♯ upper_principal x)› 2. ‹⋀(a::'a pd_basis) aa::'a pd_basis. upper_principal aa ∪♯ upper_principal a = upper_principal a ∪♯ upper_principal aa› discuss goal 1*) apply simp (*discuss goal 2*) apply (simp add: PDPlus_commute (*‹PDPlus ?t ?u = PDPlus ?u ?t›*)) (*proven 2 subgoals*) (*proven 2 subgoals*) . show "xs ∪♯ xs = xs" apply (induct xs rule: upper_pd.principal_induct (*‹⟦adm ?P; ⋀a. ?P (upper_principal a)⟧ ⟹ ?P ?x›*)) (*goals: 1. ‹adm (λa. a ∪♯ a = a)› 2. ‹⋀a. upper_principal a ∪♯ upper_principal a = upper_principal a› discuss goal 1*) apply simp (*discuss goal 2*) apply (simp add: PDPlus_absorb (*‹PDPlus ?t ?t = ?t›*)) (*proven 2 subgoals*) . qed lemmas upper_plus_assoc = upper_add.assoc lemmas upper_plus_commute = upper_add.commute lemmas upper_plus_absorb = upper_add.idem lemmas upper_plus_left_commute = upper_add.left_commute lemmas upper_plus_left_absorb = upper_add.left_idem text ‹Useful for ‹simp add: upper_plus_ac›› lemmas upper_plus_ac = upper_plus_assoc upper_plus_commute upper_plus_left_commute text ‹Useful for ‹simp only: upper_plus_aci›› lemmas upper_plus_aci = upper_plus_ac upper_plus_absorb upper_plus_left_absorb lemma upper_plus_below1: "xs ∪♯ ys ⊑ xs" apply (induct xs rule: upper_pd.principal_induct (*‹⟦adm (?P::(?'a)♯ ⇒ bool); ⋀a::?'a pd_basis. ?P (upper_principal a)⟧ ⟹ ?P (?x::(?'a)♯)›*)) (*goals: 1. ‹adm (λa. a ∪♯ ys ⊑ a)› 2. ‹⋀a. upper_principal a ∪♯ ys ⊑ upper_principal a› discuss goal 1*) apply simp (*discuss goal 2*) apply (induct ys rule: upper_pd.principal_induct (*‹⟦adm ?P; ⋀a. ?P (upper_principal a)⟧ ⟹ ?P ?x›*)) (*goals: 1. ‹adm (λa. ∀x. upper_principal x ∪♯ a ⊑ upper_principal x)› 2. ‹⋀a aa. upper_principal aa ∪♯ upper_principal a ⊑ upper_principal aa› discuss goal 1*) apply simp (*discuss goal 2*) apply (simp add: PDPlus_upper_le (*‹PDPlus (?t::?'a pd_basis) (?u::?'a pd_basis) ≤♯ ?t›*)) (*proven 2 subgoals*) (*proven 2 subgoals*) . lemma upper_plus_below2: "xs ∪♯ ys ⊑ ys" apply (subst upper_plus_commute (*‹(?a::(?'a)♯) ∪♯ (?b::(?'a)♯) = ?b ∪♯ ?a›*)) (*goal: ‹xs ∪♯ ys ⊑ ys›*) by (rule upper_plus_below1 (*‹?xs ∪♯ ?ys ⊑ ?xs›*)) lemma upper_plus_greatest: "⟦xs ⊑ ys; xs ⊑ zs⟧ ⟹ xs ⊑ ys ∪♯ zs" apply (subst upper_plus_absorb [of xs, symmetric] (*‹xs = xs ∪♯ xs›*)) (*goal: ‹⟦xs ⊑ ys; xs ⊑ zs⟧ ⟹ xs ⊑ ys ∪♯ zs›*) by (erule (1) monofun_cfun [OF monofun_cfun_arg] (*‹⟦(?x1::?'a1) ⊑ (?y1::?'a1); (?x::?'a) ⊑ (?y::?'a)⟧ ⟹ (?f1::?'a1 → ?'a → ?'b)⋅?x1⋅?x ⊑ ?f1⋅?y1⋅?y›*)) lemma upper_below_plus_iff [simp]: "xs ⊑ ys ∪♯ zs ⟷ xs ⊑ ys ∧ xs ⊑ zs" apply safe (*goals: 1. ‹xs ⊑ ys ∪♯ zs ⟹ xs ⊑ ys› 2. ‹xs ⊑ ys ∪♯ zs ⟹ xs ⊑ zs› 3. ‹⟦xs ⊑ ys; xs ⊑ zs⟧ ⟹ xs ⊑ ys ∪♯ zs› discuss goal 1*) apply (erule below_trans [OF _ upper_plus_below1] (*‹?x ⊑ ?z ∪♯ ?ys1 ⟹ ?x ⊑ ?z›*)) (*discuss goal 2*) apply (erule below_trans [OF _ upper_plus_below2] (*‹?x ⊑ ?xs1 ∪♯ ?z ⟹ ?x ⊑ ?z›*)) (*discuss goal 3*) apply (erule (1) upper_plus_greatest (*‹⟦?xs ⊑ ?ys; ?xs ⊑ ?zs⟧ ⟹ ?xs ⊑ ?ys ∪♯ ?zs›*)) (*proven 3 subgoals*) . lemma upper_plus_below_unit_iff [simp]: "xs ∪♯ ys ⊑ {z}♯ ⟷ xs ⊑ {z}♯ ∨ ys ⊑ {z}♯" apply (induct xs rule: upper_pd.principal_induct (*‹⟦adm ?P; ⋀a. ?P (upper_principal a)⟧ ⟹ ?P ?x›*)) (*goals: 1. ‹adm (λa. (a ∪♯ ys ⊑ {z}♯) = (a ⊑ {z}♯ ∨ ys ⊑ {z}♯))› 2. ‹⋀a. (upper_principal a ∪♯ ys ⊑ {z}♯) = (upper_principal a ⊑ {z}♯ ∨ ys ⊑ {z}♯)› discuss goal 1*) apply simp (*discuss goal 2*) apply (induct ys rule: upper_pd.principal_induct (*‹⟦adm ?P; ⋀a. ?P (upper_principal a)⟧ ⟹ ?P ?x›*)) (*goals: 1. ‹adm (λa. ∀x. (upper_principal x ∪♯ a ⊑ {z}♯) = (upper_principal x ⊑ {z}♯ ∨ a ⊑ {z}♯))› 2. ‹⋀a aa. (upper_principal aa ∪♯ upper_principal a ⊑ {z}♯) = (upper_principal aa ⊑ {z}♯ ∨ upper_principal a ⊑ {z}♯)› discuss goal 1*) apply simp (*discuss goal 2*) apply (induct z rule: compact_basis.principal_induct (*‹⟦adm (?P::?'a ⇒ bool); ⋀a::?'a compact_basis. ?P (Rep_compact_basis a)⟧ ⟹ ?P (?x::?'a)›*)) (*goals: 1. ‹adm (λa. ∀x xa. (upper_principal xa ∪♯ upper_principal x ⊑ {a}♯) = (upper_principal xa ⊑ {a}♯ ∨ upper_principal x ⊑ {a}♯))› 2. ‹⋀a aa aaa. (upper_principal aaa ∪♯ upper_principal aa ⊑ {Rep_compact_basis a}♯) = (upper_principal aaa ⊑ {Rep_compact_basis a}♯ ∨ upper_principal aa ⊑ {Rep_compact_basis a}♯)› discuss goal 1*) apply simp (*discuss goal 2*) apply (simp add: upper_le_PDPlus_PDUnit_iff (*‹(PDPlus ?t ?u ≤♯ PDUnit ?a) = (?t ≤♯ PDUnit ?a ∨ ?u ≤♯ PDUnit ?a)›*)) (*proven 2 subgoals*) (*proven 2 subgoals*) (*proven 2 subgoals*) . lemma upper_unit_below_iff [simp]: "{x}♯ ⊑ {y}♯ ⟷ x ⊑ y" apply (induct x rule: compact_basis.principal_induct (*‹⟦adm (?P::?'a::bifinite ⇒ bool); ⋀a::?'a::bifinite compact_basis. ?P (Rep_compact_basis a)⟧ ⟹ ?P (?x::?'a::bifinite)›*)) (*goals: 1. ‹adm (λa::'a. ({a}♯ ⊑ {y::'a}♯) = (a ⊑ y))› 2. ‹⋀a::'a compact_basis. ({Rep_compact_basis a}♯ ⊑ {y::'a}♯) = (Rep_compact_basis a ⊑ y)› discuss goal 1*) apply simp (*discuss goal 2*) apply (induct y rule: compact_basis.principal_induct (*‹⟦adm ?P; ⋀a. ?P (Rep_compact_basis a)⟧ ⟹ ?P ?x›*)) (*goals: 1. ‹adm (λa. ∀x. ({Rep_compact_basis x}♯ ⊑ {a}♯) = (Rep_compact_basis x ⊑ a))› 2. ‹⋀a aa. ({Rep_compact_basis aa}♯ ⊑ {Rep_compact_basis a}♯) = (Rep_compact_basis aa ⊑ Rep_compact_basis a)› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) (*proven 2 subgoals*) . lemmas upper_pd_below_simps = upper_unit_below_iff upper_below_plus_iff upper_plus_below_unit_iff lemma upper_unit_eq_iff [simp]: "{x}♯ = {y}♯ ⟷ x = y" unfolding po_eq_conv (*goal: ‹({x}♯ ⊑ {y}♯ ∧ {y}♯ ⊑ {x}♯) = (x ⊑ y ∧ y ⊑ x)›*) by simp lemma upper_unit_strict [simp]: "{⊥}♯ = ⊥" using upper_unit_Rep_compact_basis[of compact_bot] (*‹{Rep_compact_basis compact_bot}♯ = upper_principal (PDUnit compact_bot)›*) by (simp add: inst_upper_pd_pcpo (*‹⊥ = upper_principal (PDUnit compact_bot)›*)) lemma upper_plus_strict1 [simp]: "⊥ ∪♯ ys = ⊥" apply (rule bottomI (*‹?x ⊑ ⊥ ⟹ ?x = ⊥›*)) (*goal: ‹⊥ ∪♯ ys = ⊥›*) by (rule upper_plus_below1 (*‹(?xs::(?'a)♯) ∪♯ (?ys::(?'a)♯) ⊑ ?xs›*)) lemma upper_plus_strict2 [simp]: "xs ∪♯ ⊥ = ⊥" apply (rule bottomI (*‹(?x::?'a) ⊑ ⊥ ⟹ ?x = ⊥›*)) (*goal: ‹xs ∪♯ ⊥ = ⊥›*) by (rule upper_plus_below2 (*‹?xs ∪♯ ?ys ⊑ ?ys›*)) lemma upper_unit_bottom_iff [simp]: "{x}♯ = ⊥ ⟷ x = ⊥" unfolding upper_unit_strict[symmetric] (*goal: ‹({x}♯ = {⊥}♯) = (x = ⊥)›*) by (rule upper_unit_eq_iff (*‹({?x}♯ = {?y}♯) = (?x = ?y)›*)) lemma upper_plus_bottom_iff [simp]: "xs ∪♯ ys = ⊥ ⟷ xs = ⊥ ∨ ys = ⊥" apply (induct xs rule: upper_pd.principal_induct (*‹⟦adm ?P; ⋀a. ?P (upper_principal a)⟧ ⟹ ?P ?x›*)) (*goals: 1. ‹adm (λa. (a ∪♯ ys = ⊥) = (a = ⊥ ∨ ys = ⊥))› 2. ‹⋀a. (upper_principal a ∪♯ ys = ⊥) = (upper_principal a = ⊥ ∨ ys = ⊥)› discuss goal 1*) apply simp (*discuss goal 2*) apply (induct ys rule: upper_pd.principal_induct (*‹⟦adm ?P; ⋀a. ?P (upper_principal a)⟧ ⟹ ?P ?x›*)) (*goals: 1. ‹adm (λa::('a::bifinite)♯. ∀x::'a::bifinite pd_basis. (upper_principal x ∪♯ a = ⊥) = (upper_principal x = ⊥ ∨ a = ⊥))› 2. ‹⋀(a::'a::bifinite pd_basis) aa::'a::bifinite pd_basis. (upper_principal aa ∪♯ upper_principal a = ⊥) = (upper_principal aa = ⊥ ∨ upper_principal a = ⊥)› discuss goal 1*) apply simp (*discuss goal 2*) apply (simp add: inst_upper_pd_pcpo (*‹⊥ = upper_principal (PDUnit compact_bot)›*) upper_pd.principal_eq_iff (*‹(upper_principal ?a = upper_principal ?b) = (?a ≤♯ ?b ∧ ?b ≤♯ ?a)›*) upper_le_PDPlus_PDUnit_iff (*‹(PDPlus ?t ?u ≤♯ PDUnit ?a) = (?t ≤♯ PDUnit ?a ∨ ?u ≤♯ PDUnit ?a)›*)) (*proven 2 subgoals*) (*proven 2 subgoals*) . lemma compact_upper_unit: "compact x ⟹ compact {x}♯" by (auto dest!: compact_basis.compact_imp_principal (*‹compact ?x ⟹ ∃a. ?x = Rep_compact_basis a›*)) lemma compact_upper_unit_iff [simp]: "compact {x}♯ ⟷ compact x" apply (safe elim!: compact_upper_unit (*‹compact ?x ⟹ compact {?x}♯›*)) (*goal: ‹compact {x}♯ = compact x›*) apply (simp only: compact_def (*‹compact ?k = adm ((\<notsqsubseteq>) ?k)›*) upper_unit_below_iff [symmetric] (*‹(?x ⊑ ?y) = ({?x}♯ ⊑ {?y}♯)›*)) (*goal: ‹compact {x}♯ ⟹ compact x›*) by (erule adm_subst [OF cont_Rep_cfun2] (*‹adm ?P ⟹ adm (λx. ?P (?f1⋅x))›*)) lemma compact_upper_plus [simp]: "⟦compact xs; compact ys⟧ ⟹ compact (xs ∪♯ ys)" by (auto dest!: upper_pd.compact_imp_principal (*‹compact ?x ⟹ ∃a. ?x = upper_principal a›*)) subsection ‹Induction rules› lemma upper_pd_induct1: assumes P: "adm P" assumes unit: "⋀x. P {x}♯" assumes insert: "⋀x ys. ⟦P {x}♯; P ys⟧ ⟹ P ({x}♯ ∪♯ ys)" shows "P (xs::'a upper_pd)" apply (induct xs rule: upper_pd.principal_induct (*‹⟦adm ?P; ⋀a. ?P (upper_principal a)⟧ ⟹ ?P ?x›*)) (*goals: 1. ‹adm (P::('a)♯ ⇒ bool)› 2. ‹⋀a::'a pd_basis. (P::('a)♯ ⇒ bool) (upper_principal a)› discuss goal 1*) apply (rule P (*‹adm P›*)) (*discuss goal 2*) apply (induct_tac a rule: pd_basis_induct1) (*goals: 1. ‹⋀a aa. P (upper_principal (PDUnit aa))› 2. ‹⋀a aa t. P (upper_principal t) ⟹ P (upper_principal (PDPlus (PDUnit aa) t))› discuss goal 1*) apply (simp only: upper_unit_Rep_compact_basis [symmetric] (*‹upper_principal (PDUnit ?a) = {Rep_compact_basis ?a}♯›*)) (*top goal: ‹⋀a aa. P (upper_principal (PDUnit aa))› and 1 goal remains*) apply (rule unit (*‹P {?x}♯›*)) (*discuss goal 2*) apply (simp only: upper_unit_Rep_compact_basis [symmetric] (*‹upper_principal (PDUnit ?a) = {Rep_compact_basis ?a}♯›*) upper_plus_principal [symmetric] (*‹upper_principal (PDPlus ?t ?u) = upper_principal ?t ∪♯ upper_principal ?u›*)) (*goal: ‹⋀a aa t. P (upper_principal t) ⟹ P (upper_principal (PDPlus (PDUnit aa) t))›*) apply (erule insert [OF unit] (*‹P ?ys ⟹ P ({?x}♯ ∪♯ ?ys)›*)) (*proven 2 subgoals*) (*proven 2 subgoals*) . lemma upper_pd_induct [case_names adm upper_unit upper_plus, induct type: upper_pd]: assumes P: "adm P" assumes unit: "⋀x. P {x}♯" assumes plus: "⋀xs ys. ⟦P xs; P ys⟧ ⟹ P (xs ∪♯ ys)" shows "P (xs::'a upper_pd)" apply (induct xs rule: upper_pd.principal_induct (*‹⟦adm (?P::(?'a::bifinite)♯ ⇒ bool); ⋀a::?'a::bifinite pd_basis. ?P (upper_principal a)⟧ ⟹ ?P (?x::(?'a::bifinite)♯)›*)) (*goals: 1. ‹adm (P::('a)♯ ⇒ bool)› 2. ‹⋀a::'a pd_basis. (P::('a)♯ ⇒ bool) (upper_principal a)› discuss goal 1*) apply (rule P (*‹adm (P::('a::bifinite)♯ ⇒ bool)›*)) (*discuss goal 2*) apply (induct_tac a rule: pd_basis_induct) (*goals: 1. ‹⋀a aa. P (upper_principal (PDUnit aa))› 2. ‹⋀a t u. ⟦P (upper_principal t); P (upper_principal u)⟧ ⟹ P (upper_principal (PDPlus t u))› discuss goal 1*) apply (simp only: upper_unit_Rep_compact_basis [symmetric] (*‹upper_principal (PDUnit ?a) = {Rep_compact_basis ?a}♯›*) unit (*‹P {?x}♯›*)) (*discuss goal 2*) apply (simp only: upper_plus_principal [symmetric] (*‹upper_principal (PDPlus ?t ?u) = upper_principal ?t ∪♯ upper_principal ?u›*) plus (*‹⟦P ?xs; P ?ys⟧ ⟹ P (?xs ∪♯ ?ys)›*)) (*proven 2 subgoals*) (*proven 2 subgoals*) . subsection ‹Monadic bind› definition upper_bind_basis :: "'a pd_basis ⇒ ('a → 'b upper_pd) → 'b upper_pd" where "upper_bind_basis = fold_pd (λa. Λ f. f⋅(Rep_compact_basis a)) (λx y. Λ f. x⋅f ∪♯ y⋅f)" lemma ACI_upper_bind: "semilattice (λx y. Λ f. x⋅f ∪♯ y⋅f)" apply unfold_locales (*goals: 1. ‹⋀a b c. (Λ f. (Λ f. a⋅f ∪♯ b⋅f)⋅f ∪♯ c⋅f) = (Λ f. a⋅f ∪♯ (Λ f. b⋅f ∪♯ c⋅f)⋅f)› 2. ‹⋀a b. (Λ f. a⋅f ∪♯ b⋅f) = (Λ f. b⋅f ∪♯ a⋅f)› 3. ‹⋀a. (Λ f. a⋅f ∪♯ a⋅f) = a› discuss goal 1*) apply (simp add: upper_plus_assoc (*‹?a ∪♯ ?b ∪♯ ?c = ?a ∪♯ (?b ∪♯ ?c)›*)) (*discuss goal 2*) apply (simp add: upper_plus_commute (*‹?a ∪♯ ?b = ?b ∪♯ ?a›*)) (*discuss goal 3*) apply (simp add: eta_cfun (*‹(Λ x. ?f⋅x) = ?f›*)) (*proven 3 subgoals*) . lemma upper_bind_basis_simps [simp]: "upper_bind_basis (PDUnit a) = (Λ f. f⋅(Rep_compact_basis a))" "upper_bind_basis (PDPlus t u) = (Λ f. upper_bind_basis t⋅f ∪♯ upper_bind_basis u⋅f)" unfolding upper_bind_basis_def (*goals: 1. ‹fold_pd (λa. Λ f. f⋅(Rep_compact_basis a)) (λx y. Λ f. x⋅f ∪♯ y⋅f) (PDUnit a) = (Λ f. f⋅(Rep_compact_basis a))› 2. ‹fold_pd (λa. Λ f. f⋅(Rep_compact_basis a)) (λx y. Λ f. x⋅f ∪♯ y⋅f) (PDPlus t u) = (Λ f. fold_pd (λa. Λ f. f⋅(Rep_compact_basis a)) (λx y. Λ f. x⋅f ∪♯ y⋅f) t⋅f ∪♯ fold_pd (λa. Λ f. f⋅(Rep_compact_basis a)) (λx y. Λ f. x⋅f ∪♯ y⋅f) u⋅f)›*) (*goals: 1. ‹fold_pd (λa::'a compact_basis. Λ (f::'a → ('b)♯). f⋅(Rep_compact_basis a)) (λ(x::('a → ('b)♯) → ('b)♯) y::('a → ('b)♯) → ('b)♯. Λ (f::'a → ('b)♯). x⋅f ∪♯ y⋅f) (PDUnit (a::'a compact_basis)) = (Λ (f::'a → ('b)♯). f⋅(Rep_compact_basis a))› 2. ‹fold_pd (λa::'c compact_basis. Λ (f::'c → ('d)♯). f⋅(Rep_compact_basis a)) (λ(x::('c → ('d)♯) → ('d)♯) y::('c → ('d)♯) → ('d)♯. Λ (f::'c → ('d)♯). x⋅f ∪♯ y⋅f) (PDPlus (t::'c pd_basis) (u::'c pd_basis)) = (Λ (f::'c → ('d)♯). fold_pd (λa::'c compact_basis. Λ (f::'c → ('d)♯). f⋅(Rep_compact_basis a)) (λ(x::('c → ('d)♯) → ('d)♯) y::('c → ('d)♯) → ('d)♯. Λ (f::'c → ('d)♯). x⋅f ∪♯ y⋅f) t⋅f ∪♯ fold_pd (λa::'c compact_basis. Λ (f::'c → ('d)♯). f⋅(Rep_compact_basis a)) (λ(x::('c → ('d)♯) → ('d)♯) y::('c → ('d)♯) → ('d)♯. Λ (f::'c → ('d)♯). x⋅f ∪♯ y⋅f) u⋅f)› discuss goal 1*) apply - (*top goal: ‹fold_pd (λa. Λ f. f⋅(Rep_compact_basis a)) (λx y. Λ f. x⋅f ∪♯ y⋅f) (PDUnit a) = (Λ f. f⋅(Rep_compact_basis a))› and 1 goal remains*) apply (rule fold_pd_PDUnit [OF ACI_upper_bind] (*‹fold_pd (?g::?'b compact_basis ⇒ ?'a1 → (?'b1)♯) (λ(x::?'a1 → (?'b1)♯) y::?'a1 → (?'b1)♯. Λ (f::?'a1). x⋅f ∪♯ y⋅f) (PDUnit (?x::?'b compact_basis)) = ?g ?x›*)) (*discuss goal 2*) apply (rule fold_pd_PDPlus [OF ACI_upper_bind] (*‹fold_pd ?g (λx y. Λ f. x⋅f ∪♯ y⋅f) (PDPlus ?t ?u) = (Λ f. fold_pd ?g (λx y. Λ f. x⋅f ∪♯ y⋅f) ?t⋅f ∪♯ fold_pd ?g (λx y. Λ f. x⋅f ∪♯ y⋅f) ?u⋅f)›*)) (*proven 2 subgoals*) . lemma upper_bind_basis_mono: "t ≤♯ u ⟹ upper_bind_basis t ⊑ upper_bind_basis u" unfolding cfun_below_iff (*goal: ‹t ≤♯ u ⟹ ∀x. upper_bind_basis t⋅x ⊑ upper_bind_basis u⋅x›*) apply (erule upper_le_induct (*‹⟦(?t::?'a::bifinite pd_basis) ≤♯ (?u::?'a::bifinite pd_basis); ⋀(a::?'a::bifinite compact_basis) b::?'a::bifinite compact_basis. a ⊑ b ⟹ (?P::?'a::bifinite pd_basis ⇒ ?'a::bifinite pd_basis ⇒ bool) (PDUnit a) (PDUnit b); ⋀(t::?'a::bifinite pd_basis) (u::?'a::bifinite pd_basis) a::?'a::bifinite compact_basis. ?P t (PDUnit a) ⟹ ?P (PDPlus t u) (PDUnit a); ⋀(t::?'a::bifinite pd_basis) (u::?'a::bifinite pd_basis) v::?'a::bifinite pd_basis. ⟦?P t u; ?P t v⟧ ⟹ ?P t (PDPlus u v)⟧ ⟹ ?P ?t ?u›*)) (*goals: 1. ‹⋀a b. a ⊑ b ⟹ ∀x. upper_bind_basis (PDUnit a)⋅x ⊑ upper_bind_basis (PDUnit b)⋅x› 2. ‹⋀t u a. ∀x. upper_bind_basis t⋅x ⊑ upper_bind_basis (PDUnit a)⋅x ⟹ ∀x. upper_bind_basis (PDPlus t u)⋅x ⊑ upper_bind_basis (PDUnit a)⋅x› 3. ‹⋀t u v. ⟦∀x. upper_bind_basis t⋅x ⊑ upper_bind_basis u⋅x; ∀x. upper_bind_basis t⋅x ⊑ upper_bind_basis v⋅x⟧ ⟹ ∀x. upper_bind_basis t⋅x ⊑ upper_bind_basis (PDPlus u v)⋅x› discuss goal 1*) apply ((safe)[1]) (*top goal: ‹⋀a b. a ⊑ b ⟹ ∀x. upper_bind_basis (PDUnit a)⋅x ⊑ upper_bind_basis (PDUnit b)⋅x› and 2 goals remain*) apply (simp add: monofun_cfun (*‹⟦?f ⊑ ?g; ?x ⊑ ?y⟧ ⟹ ?f⋅?x ⊑ ?g⋅?y›*)) (*discuss goal 2*) apply ((safe)[1]) (*top goal: ‹⋀(t::'a::bifinite pd_basis) (u::'a::bifinite pd_basis) a::'a::bifinite compact_basis. ∀x::'a::bifinite → ('b::bifinite)♯. upper_bind_basis t⋅x ⊑ upper_bind_basis (PDUnit a)⋅x ⟹ ∀x::'a::bifinite → ('b::bifinite)♯. upper_bind_basis (PDPlus t u)⋅x ⊑ upper_bind_basis (PDUnit a)⋅x› and 1 goal remains*) apply (simp add: below_trans [OF upper_plus_below1] (*‹?y ⊑ ?z ⟹ ?y ∪♯ ?ys1 ⊑ ?z›*)) (*discuss goal 3*) apply ((safe)[1]) (*goal: ‹⋀t u v. ⟦∀x. upper_bind_basis t⋅x ⊑ upper_bind_basis u⋅x; ∀x. upper_bind_basis t⋅x ⊑ upper_bind_basis v⋅x⟧ ⟹ ∀x. upper_bind_basis t⋅x ⊑ upper_bind_basis (PDPlus u v)⋅x›*) apply simp (*proven 3 subgoals*) . definition upper_bind :: "'a upper_pd → ('a → 'b upper_pd) → 'b upper_pd" where "upper_bind = upper_pd.extension upper_bind_basis" syntax "_upper_bind" :: "[logic, logic, logic] ⇒ logic" ("(3⋃♯_∈_./ _)" [0, 0, 10] 10) translations "⋃♯x∈xs. e" == "CONST upper_bind⋅xs⋅(Λ x. e)" lemma upper_bind_principal [simp]: "upper_bind⋅(upper_principal t) = upper_bind_basis t" unfolding upper_bind_def (*goal: ‹upper_pd.extension upper_bind_basis⋅(upper_principal t) = upper_bind_basis t›*) apply (rule upper_pd.extension_principal (*‹(⋀a b. a ≤♯ b ⟹ ?f a ⊑ ?f b) ⟹ upper_pd.extension ?f⋅(upper_principal ?a) = ?f ?a›*)) (*goal: ‹upper_pd.extension upper_bind_basis⋅(upper_principal t) = upper_bind_basis t›*) by (erule upper_bind_basis_mono (*‹?t ≤♯ ?u ⟹ upper_bind_basis ?t ⊑ upper_bind_basis ?u›*)) lemma upper_bind_unit [simp]: "upper_bind⋅{x}♯⋅f = f⋅x" apply (induct x rule: compact_basis.principal_induct (*‹⟦adm ?P; ⋀a. ?P (Rep_compact_basis a)⟧ ⟹ ?P ?x›*)) (*goals: 1. ‹adm (λa. upper_bind⋅{a}♯⋅f = f⋅a)› 2. ‹⋀a. upper_bind⋅{Rep_compact_basis a}♯⋅f = f⋅(Rep_compact_basis a)› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) . lemma upper_bind_plus [simp]: "upper_bind⋅(xs ∪♯ ys)⋅f = upper_bind⋅xs⋅f ∪♯ upper_bind⋅ys⋅f" apply (induct xs rule: upper_pd.principal_induct (*‹⟦adm ?P; ⋀a. ?P (upper_principal a)⟧ ⟹ ?P ?x›*)) (*goals: 1. ‹adm (λa. upper_bind⋅(a ∪♯ ys)⋅f = upper_bind⋅a⋅f ∪♯ upper_bind⋅ys⋅f)› 2. ‹⋀a. upper_bind⋅(upper_principal a ∪♯ ys)⋅f = upper_bind⋅(upper_principal a)⋅f ∪♯ upper_bind⋅ys⋅f› discuss goal 1*) apply simp (*discuss goal 2*) apply (induct ys rule: upper_pd.principal_induct (*‹⟦adm ?P; ⋀a. ?P (upper_principal a)⟧ ⟹ ?P ?x›*)) (*goals: 1. ‹adm (λa::('b)♯. ∀x::'b pd_basis. upper_bind⋅(upper_principal x ∪♯ a)⋅(f::'b → ('a)♯) = upper_bind⋅(upper_principal x)⋅f ∪♯ upper_bind⋅a⋅f)› 2. ‹⋀(a::'b pd_basis) aa::'b pd_basis. upper_bind⋅(upper_principal aa ∪♯ upper_principal a)⋅(f::'b → ('a)♯) = upper_bind⋅(upper_principal aa)⋅f ∪♯ upper_bind⋅(upper_principal a)⋅f› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) (*proven 2 subgoals*) . lemma upper_bind_strict [simp]: "upper_bind⋅⊥⋅f = f⋅⊥" unfolding upper_unit_strict[symmetric] (*goal: ‹upper_bind⋅{⊥}♯⋅(f::'b → ('a)♯) = f⋅⊥›*) by (rule upper_bind_unit (*‹upper_bind⋅{?x}♯⋅?f = ?f⋅?x›*)) lemma upper_bind_bind: "upper_bind⋅(upper_bind⋅xs⋅f)⋅g = upper_bind⋅xs⋅(Λ x. upper_bind⋅(f⋅x)⋅g)" apply (induct xs) (*goals: 1. ‹adm (λa. upper_bind⋅(upper_bind⋅a⋅f)⋅g = (⋃♯x∈a. upper_bind⋅(f⋅x)⋅g))› 2. ‹⋀x. upper_bind⋅(upper_bind⋅{x}♯⋅f)⋅g = (⋃♯x∈{x}♯. upper_bind⋅(f⋅x)⋅g)› 3. ‹⋀xs1 xs2. ⟦upper_bind⋅(upper_bind⋅xs1⋅f)⋅g = (⋃♯x∈xs1. upper_bind⋅(f⋅x)⋅g); upper_bind⋅(upper_bind⋅xs2⋅f)⋅g = (⋃♯x∈xs2. upper_bind⋅(f⋅x)⋅g)⟧ ⟹ upper_bind⋅(upper_bind⋅(xs1 ∪♯ xs2)⋅f)⋅g = (⋃♯x∈xs1 ∪♯ xs2. upper_bind⋅(f⋅x)⋅g)› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*discuss goal 3*) apply simp (*proven 3 subgoals*) . subsection ‹Map› definition upper_map :: "('a → 'b) → 'a upper_pd → 'b upper_pd" where "upper_map = (Λ f xs. upper_bind⋅xs⋅(Λ x. {f⋅x}♯))" lemma upper_map_unit [simp]: "upper_map⋅f⋅{x}♯ = {f⋅x}♯" unfolding upper_map_def (*goal: ‹(Λ (f::'b → 'a) (xs::('b)♯). ⋃♯x::'b∈xs. {f⋅x}♯)⋅(f::'b → 'a)⋅{x::'b}♯ = {f⋅x}♯›*) by simp lemma upper_map_plus [simp]: "upper_map⋅f⋅(xs ∪♯ ys) = upper_map⋅f⋅xs ∪♯ upper_map⋅f⋅ys" unfolding upper_map_def (*goal: ‹(Λ f xs. ⋃♯x∈xs. {f⋅x}♯)⋅f⋅(xs ∪♯ ys) = (Λ f xs. ⋃♯x∈xs. {f⋅x}♯)⋅f⋅xs ∪♯ (Λ f xs. ⋃♯x∈xs. {f⋅x}♯)⋅f⋅ys›*) by simp lemma upper_map_bottom [simp]: "upper_map⋅f⋅⊥ = {f⋅⊥}♯" unfolding upper_map_def (*goal: ‹(Λ f xs. ⋃♯x∈xs. {f⋅x}♯)⋅f⋅⊥ = {f⋅⊥}♯›*) by simp lemma upper_map_ident: "upper_map⋅(Λ x. x)⋅xs = xs" apply (induct xs rule: upper_pd_induct (*‹⟦adm ?P; ⋀x. ?P {x}♯; ⋀xs ys. ⟦?P xs; ?P ys⟧ ⟹ ?P (xs ∪♯ ys)⟧ ⟹ ?P ?xs›*)) (*goals: 1. ‹adm (λa::('a::bifinite)♯. upper_map⋅(Λ (x::'a::bifinite). x)⋅a = a)› 2. ‹⋀x::'a::bifinite. upper_map⋅(Λ (x::'a::bifinite). x)⋅{x}♯ = {x}♯› 3. ‹⋀(xs::('a::bifinite)♯) ys::('a::bifinite)♯. ⟦upper_map⋅(Λ (x::'a::bifinite). x)⋅xs = xs; upper_map⋅(Λ (x::'a::bifinite). x)⋅ys = ys⟧ ⟹ upper_map⋅(Λ (x::'a::bifinite). x)⋅(xs ∪♯ ys) = xs ∪♯ ys› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*discuss goal 3*) apply simp (*proven 3 subgoals*) . lemma upper_map_ID: "upper_map⋅ID = ID" by (simp add: cfun_eq_iff (*‹(?f = ?g) = (∀x. ?f⋅x = ?g⋅x)›*) ID_def (*‹ID = (Λ x. x)›*) upper_map_ident (*‹upper_map⋅(Λ x. x)⋅?xs = ?xs›*)) lemma upper_map_map: "upper_map⋅f⋅(upper_map⋅g⋅xs) = upper_map⋅(Λ x. f⋅(g⋅x))⋅xs" apply (induct xs rule: upper_pd_induct (*‹⟦adm ?P; ⋀x. ?P {x}♯; ⋀xs ys. ⟦?P xs; ?P ys⟧ ⟹ ?P (xs ∪♯ ys)⟧ ⟹ ?P ?xs›*)) (*goals: 1. ‹adm (λa. upper_map⋅f⋅(upper_map⋅g⋅a) = upper_map⋅(Λ x. f⋅(g⋅x))⋅a)› 2. ‹⋀x. upper_map⋅f⋅(upper_map⋅g⋅{x}♯) = upper_map⋅(Λ x. f⋅(g⋅x))⋅{x}♯› 3. ‹⋀xs ys. ⟦upper_map⋅f⋅(upper_map⋅g⋅xs) = upper_map⋅(Λ x. f⋅(g⋅x))⋅xs; upper_map⋅f⋅(upper_map⋅g⋅ys) = upper_map⋅(Λ x. f⋅(g⋅x))⋅ys⟧ ⟹ upper_map⋅f⋅(upper_map⋅g⋅(xs ∪♯ ys)) = upper_map⋅(Λ x. f⋅(g⋅x))⋅(xs ∪♯ ys)› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*discuss goal 3*) apply simp (*proven 3 subgoals*) . lemma upper_bind_map: "upper_bind⋅(upper_map⋅f⋅xs)⋅g = upper_bind⋅xs⋅(Λ x. g⋅(f⋅x))" by (simp add: upper_map_def (*‹upper_map = (Λ f xs. ⋃♯x∈xs. {f⋅x}♯)›*) upper_bind_bind (*‹upper_bind⋅(upper_bind⋅?xs⋅?f)⋅?g = (⋃♯x∈?xs. upper_bind⋅(?f⋅x)⋅?g)›*)) lemma upper_map_bind: "upper_map⋅f⋅(upper_bind⋅xs⋅g) = upper_bind⋅xs⋅(Λ x. upper_map⋅f⋅(g⋅x))" by (simp add: upper_map_def (*‹upper_map = (Λ f xs. ⋃♯x∈xs. {f⋅x}♯)›*) upper_bind_bind (*‹upper_bind⋅(upper_bind⋅?xs⋅?f)⋅?g = (⋃♯x∈?xs. upper_bind⋅(?f⋅x)⋅?g)›*)) lemma ep_pair_upper_map: "ep_pair e p ⟹ ep_pair (upper_map⋅e) (upper_map⋅p)" apply standard (*goals: 1. ‹⋀x. ep_pair e p ⟹ upper_map⋅p⋅(upper_map⋅e⋅x) = x› 2. ‹⋀y. ep_pair e p ⟹ upper_map⋅e⋅(upper_map⋅p⋅y) ⊑ y› discuss goal 1*) apply (induct_tac x rule: upper_pd_induct) (*goals: 1. ‹⋀x. ep_pair e p ⟹ adm (λa. upper_map⋅p⋅(upper_map⋅e⋅a) = a)› 2. ‹⋀x xa. ep_pair e p ⟹ upper_map⋅p⋅(upper_map⋅e⋅{xa}♯) = {xa}♯› 3. ‹⋀x xs ys. ⟦ep_pair e p; upper_map⋅p⋅(upper_map⋅e⋅xs) = xs; upper_map⋅p⋅(upper_map⋅e⋅ys) = ys⟧ ⟹ upper_map⋅p⋅(upper_map⋅e⋅(xs ∪♯ ys)) = xs ∪♯ ys› discuss goal 1*) apply (simp add: ep_pair.e_inverse (*‹ep_pair ?e ?p ⟹ ?p⋅(?e⋅?x) = ?x›*)) (*discuss goal 2*) apply (simp add: ep_pair.e_inverse (*‹ep_pair ?e ?p ⟹ ?p⋅(?e⋅?x) = ?x›*)) (*discuss goal 3*) apply (simp add: ep_pair.e_inverse (*‹ep_pair ?e ?p ⟹ ?p⋅(?e⋅?x) = ?x›*)) (*proven 3 subgoals*) (*discuss goal 2*) apply (induct_tac y rule: upper_pd_induct) (*goals: 1. ‹⋀y. ep_pair e p ⟹ adm (λa. upper_map⋅e⋅(upper_map⋅p⋅a) ⊑ a)› 2. ‹⋀y x. ep_pair e p ⟹ upper_map⋅e⋅(upper_map⋅p⋅{x}♯) ⊑ {x}♯› 3. ‹⋀y xs ys. ⟦ep_pair e p; upper_map⋅e⋅(upper_map⋅p⋅xs) ⊑ xs; upper_map⋅e⋅(upper_map⋅p⋅ys) ⊑ ys⟧ ⟹ upper_map⋅e⋅(upper_map⋅p⋅(xs ∪♯ ys)) ⊑ xs ∪♯ ys› discuss goal 1*) apply (simp add: ep_pair.e_p_below (*‹ep_pair ?e ?p ⟹ ?e⋅(?p⋅?y) ⊑ ?y›*) monofun_cfun (*‹⟦?f ⊑ ?g; ?x ⊑ ?y⟧ ⟹ ?f⋅?x ⊑ ?g⋅?y›*) del: upper_below_plus_iff (*‹(?xs ⊑ ?ys ∪♯ ?zs) = (?xs ⊑ ?ys ∧ ?xs ⊑ ?zs)›*)) (*discuss goal 2*) apply (simp add: ep_pair.e_p_below (*‹ep_pair ?e ?p ⟹ ?e⋅(?p⋅?y) ⊑ ?y›*) monofun_cfun (*‹⟦?f ⊑ ?g; ?x ⊑ ?y⟧ ⟹ ?f⋅?x ⊑ ?g⋅?y›*) del: upper_below_plus_iff (*‹(?xs ⊑ ?ys ∪♯ ?zs) = (?xs ⊑ ?ys ∧ ?xs ⊑ ?zs)›*)) (*discuss goal 3*) apply (simp add: ep_pair.e_p_below (*‹ep_pair ?e ?p ⟹ ?e⋅(?p⋅?y) ⊑ ?y›*) monofun_cfun (*‹⟦?f ⊑ ?g; ?x ⊑ ?y⟧ ⟹ ?f⋅?x ⊑ ?g⋅?y›*) del: upper_below_plus_iff (*‹(?xs ⊑ ?ys ∪♯ ?zs) = (?xs ⊑ ?ys ∧ ?xs ⊑ ?zs)›*)) (*proven 3 subgoals*) (*proven 2 subgoals*) . lemma deflation_upper_map: "deflation d ⟹ deflation (upper_map⋅d)" apply standard (*goals: 1. ‹⋀x::('a)♯. deflation (d::'a → 'a) ⟹ upper_map⋅d⋅(upper_map⋅d⋅x) = upper_map⋅d⋅x› 2. ‹⋀x::('a)♯. deflation (d::'a → 'a) ⟹ upper_map⋅d⋅x ⊑ x› discuss goal 1*) apply (induct_tac x rule: upper_pd_induct) (*goals: 1. ‹⋀x. deflation d ⟹ adm (λa. upper_map⋅d⋅(upper_map⋅d⋅a) = upper_map⋅d⋅a)› 2. ‹⋀x xa. deflation d ⟹ upper_map⋅d⋅(upper_map⋅d⋅{xa}♯) = upper_map⋅d⋅{xa}♯› 3. ‹⋀x xs ys. ⟦deflation d; upper_map⋅d⋅(upper_map⋅d⋅xs) = upper_map⋅d⋅xs; upper_map⋅d⋅(upper_map⋅d⋅ys) = upper_map⋅d⋅ys⟧ ⟹ upper_map⋅d⋅(upper_map⋅d⋅(xs ∪♯ ys)) = upper_map⋅d⋅(xs ∪♯ ys)› 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›*)) (*discuss goal 3*) apply (simp add: deflation.idem (*‹deflation ?d ⟹ ?d⋅(?d⋅?x) = ?d⋅?x›*)) (*proven 3 subgoals*) (*discuss goal 2*) apply (induct_tac x rule: upper_pd_induct) (*goals: 1. ‹⋀x. deflation d ⟹ adm (λa. upper_map⋅d⋅a ⊑ a)› 2. ‹⋀x xa. deflation d ⟹ upper_map⋅d⋅{xa}♯ ⊑ {xa}♯› 3. ‹⋀x xs ys. ⟦deflation d; upper_map⋅d⋅xs ⊑ xs; upper_map⋅d⋅ys ⊑ ys⟧ ⟹ upper_map⋅d⋅(xs ∪♯ ys) ⊑ xs ∪♯ ys› discuss goal 1*) apply (simp add: deflation.below (*‹deflation (?d::?'a → ?'a) ⟹ ?d⋅(?x::?'a) ⊑ ?x›*) monofun_cfun (*‹⟦(?f::?'a → ?'b) ⊑ (?g::?'a → ?'b); (?x::?'a) ⊑ (?y::?'a)⟧ ⟹ ?f⋅?x ⊑ ?g⋅?y›*) del: upper_below_plus_iff (*‹((?xs::(?'a)♯) ⊑ (?ys::(?'a)♯) ∪♯ (?zs::(?'a)♯)) = (?xs ⊑ ?ys ∧ ?xs ⊑ ?zs)›*)) (*discuss goal 2*) apply (simp add: deflation.below (*‹deflation ?d ⟹ ?d⋅?x ⊑ ?x›*) monofun_cfun (*‹⟦?f ⊑ ?g; ?x ⊑ ?y⟧ ⟹ ?f⋅?x ⊑ ?g⋅?y›*) del: upper_below_plus_iff (*‹(?xs ⊑ ?ys ∪♯ ?zs) = (?xs ⊑ ?ys ∧ ?xs ⊑ ?zs)›*)) (*discuss goal 3*) apply (simp add: deflation.below (*‹deflation ?d ⟹ ?d⋅?x ⊑ ?x›*) monofun_cfun (*‹⟦?f ⊑ ?g; ?x ⊑ ?y⟧ ⟹ ?f⋅?x ⊑ ?g⋅?y›*) del: upper_below_plus_iff (*‹(?xs ⊑ ?ys ∪♯ ?zs) = (?xs ⊑ ?ys ∧ ?xs ⊑ ?zs)›*)) (*proven 3 subgoals*) (*proven 2 subgoals*) . (* FIXME: long proof! *) lemma finite_deflation_upper_map: assumes "finite_deflation d" shows "finite_deflation (upper_map⋅d)" proof (rule finite_deflation_intro (*‹⟦deflation (?d::?'a → ?'a); finite {x::?'a. ?d⋅x = x}⟧ ⟹ finite_deflation ?d›*)) (*goals: 1. ‹deflation (upper_map⋅d)› 2. ‹finite {x. upper_map⋅d⋅x = x}›*) interpret d: finite_deflation d by fact from d.deflation_axioms (*‹deflation d›*) show "deflation (upper_map⋅d)" by (rule deflation_upper_map (*‹deflation ?d ⟹ deflation (upper_map⋅?d)›*)) have "finite (range (λx. d⋅x))" by (rule d.finite_range (*‹finite (range (Rep_cfun (d::'a → 'a)))›*)) hence "finite (Rep_compact_basis -` range (λx. d⋅x))" apply (rule finite_vimageI (*‹⟦finite (?F::?'a set); inj (?h::?'b ⇒ ?'a)⟧ ⟹ finite (?h -` ?F)›*)) (*goal: ‹finite (Rep_compact_basis -` range (Rep_cfun d))›*) by (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)›*) Rep_compact_basis_inject (*‹(Rep_compact_basis (?x::?'a compact_basis) = Rep_compact_basis (?y::?'a compact_basis)) = (?x = ?y)›*)) hence "finite (Pow (Rep_compact_basis -` range (λx. d⋅x)))" by simp hence "finite (Rep_pd_basis -` (Pow (Rep_compact_basis -` range (λx. d⋅x))))" apply (rule finite_vimageI (*‹⟦finite ?F; inj ?h⟧ ⟹ finite (?h -` ?F)›*)) (*goal: ‹finite (Rep_pd_basis -` Pow (Rep_compact_basis -` range (Rep_cfun d)))›*) by (simp add: inj_on_def (*‹inj_on ?f ?A = (∀x∈?A. ∀y∈?A. ?f x = ?f y ⟶ x = y)›*) Rep_pd_basis_inject (*‹(Rep_pd_basis ?x = Rep_pd_basis ?y) = (?x = ?y)›*)) hence "*": "finite (upper_principal ` Rep_pd_basis -` (Pow (Rep_compact_basis -` range (λx. d⋅x))))" by simp hence "finite (range (λxs. upper_map⋅d⋅xs))" apply (rule rev_finite_subset (*‹⟦finite ?B; ?A ⊆ ?B⟧ ⟹ finite ?A›*)) (*goal: ‹finite (range (Rep_cfun (upper_map⋅(d::'a::bifinite → 'a::bifinite))))›*) apply clarsimp (*goal: ‹range (Rep_cfun (upper_map⋅(d::'a → 'a))) ⊆ upper_principal ` Rep_pd_basis -` Pow (Rep_compact_basis -` range (Rep_cfun d))›*) apply (induct_tac xs rule: upper_pd.principal_induct) (*goals: 1. ‹⋀xs::('a)♯. adm (λa::('a)♯. upper_map⋅(d::'a → 'a)⋅a ∈ upper_principal ` Rep_pd_basis -` Pow (Rep_compact_basis -` range (Rep_cfun d)))› 2. ‹⋀(xs::('a)♯) a::'a pd_basis. upper_map⋅(d::'a → 'a)⋅(upper_principal a) ∈ upper_principal ` Rep_pd_basis -` Pow (Rep_compact_basis -` range (Rep_cfun d))› discuss goal 1*) apply (simp add: adm_mem_finite (*‹⟦cont ?f; finite ?S⟧ ⟹ adm (λx. ?f x ∈ ?S)›*) * (*‹finite (upper_principal ` Rep_pd_basis -` Pow (Rep_compact_basis -` range (Rep_cfun d)))›*)) (*discuss goal 2*) apply (rename_tac t) (*goal: ‹⋀xs a. upper_map⋅d⋅(upper_principal a) ∈ upper_principal ` Rep_pd_basis -` Pow (Rep_compact_basis -` range (Rep_cfun d))›*) apply (induct_tac t rule: pd_basis_induct) (*goals: 1. ‹⋀xs t a. upper_map⋅d⋅(upper_principal (PDUnit a)) ∈ upper_principal ` Rep_pd_basis -` Pow (Rep_compact_basis -` range (Rep_cfun d))› 2. ‹⋀xs t ta u. ⟦upper_map⋅d⋅(upper_principal ta) ∈ upper_principal ` Rep_pd_basis -` Pow (Rep_compact_basis -` range (Rep_cfun d)); upper_map⋅d⋅(upper_principal u) ∈ upper_principal ` Rep_pd_basis -` Pow (Rep_compact_basis -` range (Rep_cfun d))⟧ ⟹ upper_map⋅d⋅(upper_principal (PDPlus ta u)) ∈ upper_principal ` Rep_pd_basis -` Pow (Rep_compact_basis -` range (Rep_cfun d))› discuss goal 1*) apply (simp only: upper_unit_Rep_compact_basis [symmetric] (*‹upper_principal (PDUnit ?a) = {Rep_compact_basis ?a}♯›*) upper_map_unit (*‹upper_map⋅?f⋅{?x}♯ = {?f⋅?x}♯›*)) (*top goal: ‹⋀(xs::('a)♯) (t::'a pd_basis) a::'a compact_basis. upper_map⋅(d::'a → 'a)⋅(upper_principal (PDUnit a)) ∈ upper_principal ` Rep_pd_basis -` Pow (Rep_compact_basis -` range (Rep_cfun d))› and 1 goal remains*) apply simp (*top goal: ‹⋀xs t a. {d⋅(Rep_compact_basis a)}♯ ∈ upper_principal ` Rep_pd_basis -` Pow (Rep_compact_basis -` range (Rep_cfun d))› and 1 goal remains*) apply (subgoal_tac "∃b. d⋅(Rep_compact_basis a) = Rep_compact_basis b") (*goals: 1. ‹⋀a. ∃b. d⋅(Rep_compact_basis a) = Rep_compact_basis b ⟹ {d⋅(Rep_compact_basis a)}♯ ∈ upper_principal ` Rep_pd_basis -` Pow (Rep_compact_basis -` range (Rep_cfun d))› 2. ‹⋀a. ∃b. d⋅(Rep_compact_basis a) = Rep_compact_basis b› discuss goal 1*) apply clarsimp (*top goal: ‹⋀a::'a compact_basis. ∃b::'a compact_basis. (d::'a → 'a)⋅(Rep_compact_basis a) = Rep_compact_basis b ⟹ {d⋅(Rep_compact_basis a)}♯ ∈ upper_principal ` Rep_pd_basis -` Pow (Rep_compact_basis -` range (Rep_cfun d))› and 2 goals remain*) apply (rule imageI (*‹?x ∈ ?A ⟹ ?f ?x ∈ ?f ` ?A›*)) (*top goal: ‹⋀a b. d⋅(Rep_compact_basis a) = Rep_compact_basis b ⟹ upper_principal (PDUnit b) ∈ upper_principal ` Rep_pd_basis -` Pow (Rep_compact_basis -` range (Rep_cfun d))› and 2 goals remain*) apply (rule vimageI2 (*‹(?f::?'b ⇒ ?'a) (?a::?'b) ∈ (?A::?'a set) ⟹ ?a ∈ ?f -` ?A›*)) (*top goal: ‹⋀(a::'a compact_basis) b::'a compact_basis. (d::'a → 'a)⋅(Rep_compact_basis a) = Rep_compact_basis b ⟹ PDUnit b ∈ Rep_pd_basis -` Pow (Rep_compact_basis -` range (Rep_cfun d))› and 2 goals remain*) apply (simp add: Rep_PDUnit (*‹Rep_pd_basis (PDUnit ?x) = {?x}›*)) (*top goal: ‹⋀a b. d⋅(Rep_compact_basis a) = Rep_compact_basis b ⟹ Rep_pd_basis (PDUnit b) ∈ Pow (Rep_compact_basis -` range (Rep_cfun d))› and 2 goals remain*) apply (rule range_eqI (*‹?b = ?f ?x ⟹ ?b ∈ range ?f›*)) (*top goal: ‹⋀a b. d⋅(Rep_compact_basis a) = Rep_compact_basis b ⟹ Rep_compact_basis b ∈ range (Rep_cfun d)› and 2 goals remain*) apply (erule sym (*‹?s = ?t ⟹ ?t = ?s›*)) (*discuss goal 2*) apply (rule exI (*‹?P ?x ⟹ ∃x. ?P x›*)) (*top goal: ‹⋀a. ∃b. d⋅(Rep_compact_basis a) = Rep_compact_basis b› and 1 goal remains*) apply (rule Abs_compact_basis_inverse [symmetric] (*‹?t ∈ {x. compact x} ⟹ ?t = Rep_compact_basis (Abs_compact_basis ?t)›*)) (*top goal: ‹⋀a. d⋅(Rep_compact_basis a) = Rep_compact_basis (?b23 a)› and 1 goal remains*) apply (simp add: d.compact (*‹compact ((d::'a → 'a)⋅(?x::'a))›*)) (*proven 2 subgoals*) (*discuss goal 2*) apply (simp only: upper_plus_principal [symmetric] (*‹upper_principal (PDPlus ?t ?u) = upper_principal ?t ∪♯ upper_principal ?u›*) upper_map_plus (*‹upper_map⋅?f⋅(?xs ∪♯ ?ys) = upper_map⋅?f⋅?xs ∪♯ upper_map⋅?f⋅?ys›*)) (*goal: ‹⋀xs t ta u. ⟦upper_map⋅d⋅(upper_principal ta) ∈ upper_principal ` Rep_pd_basis -` Pow (Rep_compact_basis -` range (Rep_cfun d)); upper_map⋅d⋅(upper_principal u) ∈ upper_principal ` Rep_pd_basis -` Pow (Rep_compact_basis -` range (Rep_cfun d))⟧ ⟹ upper_map⋅d⋅(upper_principal (PDPlus ta u)) ∈ upper_principal ` Rep_pd_basis -` Pow (Rep_compact_basis -` range (Rep_cfun d))›*) apply clarsimp (*goal: ‹⋀xs t ta u. ⟦upper_map⋅d⋅(upper_principal ta) ∈ upper_principal ` Rep_pd_basis -` Pow (Rep_compact_basis -` range (Rep_cfun d)); upper_map⋅d⋅(upper_principal u) ∈ upper_principal ` Rep_pd_basis -` Pow (Rep_compact_basis -` range (Rep_cfun d))⟧ ⟹ upper_map⋅d⋅(upper_principal ta) ∪♯ upper_map⋅d⋅(upper_principal u) ∈ upper_principal ` Rep_pd_basis -` Pow (Rep_compact_basis -` range (Rep_cfun d))›*) apply (rule imageI (*‹?x ∈ ?A ⟹ ?f ?x ∈ ?f ` ?A›*)) (*goal: ‹⋀(ta::'a::bifinite pd_basis) (u::'a::bifinite pd_basis) (x::'a::bifinite pd_basis) xb::'a::bifinite pd_basis. ⟦upper_map⋅(d::'a::bifinite → 'a::bifinite)⋅(upper_principal ta) = upper_principal x; upper_map⋅d⋅(upper_principal u) = upper_principal xb; Rep_pd_basis x ⊆ Rep_compact_basis -` range (Rep_cfun d); Rep_pd_basis xb ⊆ Rep_compact_basis -` range (Rep_cfun d)⟧ ⟹ upper_principal (PDPlus x xb) ∈ upper_principal ` Rep_pd_basis -` Pow (Rep_compact_basis -` range (Rep_cfun d))›*) apply (rule vimageI2 (*‹?f ?a ∈ ?A ⟹ ?a ∈ ?f -` ?A›*)) (*goal: ‹⋀ta u x xb. ⟦upper_map⋅d⋅(upper_principal ta) = upper_principal x; upper_map⋅d⋅(upper_principal u) = upper_principal xb; Rep_pd_basis x ⊆ Rep_compact_basis -` range (Rep_cfun d); Rep_pd_basis xb ⊆ Rep_compact_basis -` range (Rep_cfun d)⟧ ⟹ PDPlus x xb ∈ Rep_pd_basis -` Pow (Rep_compact_basis -` range (Rep_cfun d))›*) apply (simp add: Rep_PDPlus (*‹Rep_pd_basis (PDPlus ?u ?v) = Rep_pd_basis ?u ∪ Rep_pd_basis ?v›*)) (*proven 2 subgoals*) (*proven 2 subgoals*) . thus "finite {xs. upper_map⋅d⋅xs = xs}" by (rule finite_range_imp_finite_fixes (*‹finite (range (?f::?'a::type ⇒ ?'a::type)) ⟹ finite {x::?'a::type. ?f x = x}›*)) qed subsection ‹Upper powerdomain is bifinite› lemma approx_chain_upper_map: assumes "approx_chain a" shows "approx_chain (λi. upper_map⋅(a i))" using assms (*‹approx_chain (a::nat ⇒ 'a → 'a)›*) unfolding approx_chain_def (*goal: ‹chain (λi. upper_map⋅(a i)) ∧ (⨆i. upper_map⋅(a i)) = ID ∧ (∀i. finite_deflation (upper_map⋅(a i)))›*) by (simp add: lub_APP (*‹⟦chain ?F; chain ?Y⟧ ⟹ (⨆i. ?F i⋅(?Y i)) = (⨆i. ?F i)⋅(⨆i. ?Y i)›*) upper_map_ID (*‹upper_map⋅ID = ID›*) finite_deflation_upper_map (*‹finite_deflation ?d ⟹ finite_deflation (upper_map⋅?d)›*)) instance upper_pd :: (bifinite) bifinite proof show "∃(a::nat ⇒ 'a upper_pd → 'a upper_pd). approx_chain a" using bifinite [where 'a='a] by (fast intro!: approx_chain_upper_map) qed subsection ‹Join› definition upper_join :: "'a upper_pd upper_pd → 'a upper_pd" where "upper_join = (Λ xss. upper_bind⋅xss⋅(Λ xs. xs))" lemma upper_join_unit [simp]: "upper_join⋅{xs}♯ = xs" unfolding upper_join_def (*goal: ‹(Λ (xss::(('a::bifinite)♯)♯). ⋃♯xs::('a::bifinite)♯∈xss. xs)⋅{xs::('a::bifinite)♯}♯ = xs›*) by simp lemma upper_join_plus [simp]: "upper_join⋅(xss ∪♯ yss) = upper_join⋅xss ∪♯ upper_join⋅yss" unfolding upper_join_def (*goal: ‹(Λ xss. ⋃♯xs∈xss. xs)⋅(xss ∪♯ yss) = (Λ xss. ⋃♯xs∈xss. xs)⋅xss ∪♯ (Λ xss. ⋃♯xs∈xss. xs)⋅yss›*) by simp lemma upper_join_bottom [simp]: "upper_join⋅⊥ = ⊥" unfolding upper_join_def (*goal: ‹(Λ xss. ⋃♯xs∈xss. xs)⋅⊥ = ⊥›*) by simp lemma upper_join_map_unit: "upper_join⋅(upper_map⋅upper_unit⋅xs) = xs" apply (induct xs rule: upper_pd_induct (*‹⟦adm ?P; ⋀x. ?P {x}♯; ⋀xs ys. ⟦?P xs; ?P ys⟧ ⟹ ?P (xs ∪♯ ys)⟧ ⟹ ?P ?xs›*)) (*goals: 1. ‹adm (λa. upper_join⋅(upper_map⋅upper_unit⋅a) = a)› 2. ‹⋀x. upper_join⋅(upper_map⋅upper_unit⋅{x}♯) = {x}♯› 3. ‹⋀xs ys. ⟦upper_join⋅(upper_map⋅upper_unit⋅xs) = xs; upper_join⋅(upper_map⋅upper_unit⋅ys) = ys⟧ ⟹ upper_join⋅(upper_map⋅upper_unit⋅(xs ∪♯ ys)) = xs ∪♯ ys› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*discuss goal 3*) apply simp (*proven 3 subgoals*) . lemma upper_join_map_join: "upper_join⋅(upper_map⋅upper_join⋅xsss) = upper_join⋅(upper_join⋅xsss)" apply (induct xsss rule: upper_pd_induct (*‹⟦adm ?P; ⋀x. ?P {x}♯; ⋀xs ys. ⟦?P xs; ?P ys⟧ ⟹ ?P (xs ∪♯ ys)⟧ ⟹ ?P ?xs›*)) (*goals: 1. ‹adm (λa. upper_join⋅(upper_map⋅upper_join⋅a) = upper_join⋅(upper_join⋅a))› 2. ‹⋀x. upper_join⋅(upper_map⋅upper_join⋅{x}♯) = upper_join⋅(upper_join⋅{x}♯)› 3. ‹⋀xs ys. ⟦upper_join⋅(upper_map⋅upper_join⋅xs) = upper_join⋅(upper_join⋅xs); upper_join⋅(upper_map⋅upper_join⋅ys) = upper_join⋅(upper_join⋅ys)⟧ ⟹ upper_join⋅(upper_map⋅upper_join⋅(xs ∪♯ ys)) = upper_join⋅(upper_join⋅(xs ∪♯ ys))› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*discuss goal 3*) apply simp (*proven 3 subgoals*) . lemma upper_join_map_map: "upper_join⋅(upper_map⋅(upper_map⋅f)⋅xss) = upper_map⋅f⋅(upper_join⋅xss)" apply (induct xss rule: upper_pd_induct (*‹⟦adm (?P::(?'a)♯ ⇒ bool); ⋀x::?'a. ?P {x}♯; ⋀(xs::(?'a)♯) ys::(?'a)♯. ⟦?P xs; ?P ys⟧ ⟹ ?P (xs ∪♯ ys)⟧ ⟹ ?P (?xs::(?'a)♯)›*)) (*goals: 1. ‹adm (λa. upper_join⋅(upper_map⋅(upper_map⋅f)⋅a) = upper_map⋅f⋅(upper_join⋅a))› 2. ‹⋀x. upper_join⋅(upper_map⋅(upper_map⋅f)⋅{x}♯) = upper_map⋅f⋅(upper_join⋅{x}♯)› 3. ‹⋀xs ys. ⟦upper_join⋅(upper_map⋅(upper_map⋅f)⋅xs) = upper_map⋅f⋅(upper_join⋅xs); upper_join⋅(upper_map⋅(upper_map⋅f)⋅ys) = upper_map⋅f⋅(upper_join⋅ys)⟧ ⟹ upper_join⋅(upper_map⋅(upper_map⋅f)⋅(xs ∪♯ ys)) = upper_map⋅f⋅(upper_join⋅(xs ∪♯ ys))› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*discuss goal 3*) apply simp (*proven 3 subgoals*) . end
{ "path": "Isabelle2024/src/HOL/HOLCF/UpperPD.thy", "repo": "Isabelle2024", "sha": "e4b15b44997e4ff2e7cf5515887c13e1291bb3ecdc1441a5aaeffde7bd699444" }
(* Title: Free_Boolean_Algebra.thy Author: Brian Huffman, Portland State University *) section ‹Free Boolean algebras› theory Free_Boolean_Algebra imports Main begin (*<*) notation bot ("⊥") and top ("⊤") and inf (infixl "⊓" 70) and sup (infixl "⊔" 65) lemma sup_conv_inf: fixes x y :: "'a::boolean_algebra" shows "x ⊔ y = - (- x ⊓ - y)" by simp (*>*) subsection ‹Free boolean algebra as a set› text ‹ We start by defining the free boolean algebra over type @{typ 'a} as an inductive set. Here ‹i :: 'a› represents a variable; ‹A :: 'a set› represents a valuation, assigning a truth value to each variable; and ‹S :: 'a set set› represents a formula, as the set of valuations that make the formula true. The set ‹fba› contains representatives of formulas built from finite combinations of variables with negation and conjunction. › inductive_set fba :: "'a set set set" where var: "{A. i ∈ A} ∈ fba" | Compl: "S ∈ fba ⟹ - S ∈ fba" | inter: "S ∈ fba ⟹ T ∈ fba ⟹ S ∩ T ∈ fba" lemma fba_Diff: "S ∈ fba ⟹ T ∈ fba ⟹ S - T ∈ fba" unfolding Diff_eq (*goal: ‹⟦S ∈ fba; T ∈ fba⟧ ⟹ S ∩ - T ∈ fba›*) apply (intro fba.inter (*‹⟦(?S::?'a set set) ∈ fba; (?T::?'a set set) ∈ fba⟧ ⟹ ?S ∩ ?T ∈ fba›*) fba.Compl (*‹(?S::?'a set set) ∈ fba ⟹ - ?S ∈ fba›*)) (*goals: 1. ‹⟦S ∈ fba; T ∈ fba⟧ ⟹ S ∈ fba› 2. ‹⟦S ∈ fba; T ∈ fba⟧ ⟹ T ∈ fba› discuss goal 1*) apply ((assumption)[1]) (*discuss goal 2*) . (*proven 2 subgoals*) lemma fba_union: "S ∈ fba ⟹ T ∈ fba ⟹ S ∪ T ∈ fba" proof (-) (*goal: ‹⟦S ∈ fba; T ∈ fba⟧ ⟹ S ∪ T ∈ fba›*) assume "S ∈ fba" and "T ∈ fba" (*‹(S::'a set set) ∈ fba› ‹(T::'a set set) ∈ fba›*) hence "- (- S ∩ - T) ∈ fba" apply (intro fba.intros (*‹Collect ((∈) ?i) ∈ fba› ‹?S ∈ fba ⟹ - ?S ∈ fba› ‹⟦?S ∈ fba; ?T ∈ fba⟧ ⟹ ?S ∩ ?T ∈ fba›*)) (*goals: 1. ‹⟦S ∈ fba; T ∈ fba⟧ ⟹ S ∈ fba› 2. ‹⟦S ∈ fba; T ∈ fba⟧ ⟹ T ∈ fba› discuss goal 1*) apply ((assumption)[1]) (*discuss goal 2*) . (*proven 2 subgoals*) thus "S ∪ T ∈ fba" by simp qed lemma fba_empty: "({} :: 'a set set) ∈ fba" proof (-) (*goal: ‹{} ∈ fba›*) obtain S :: "'a set set" where "S ∈ fba" (*goal: ‹(⋀S. S ∈ fba ⟹ thesis) ⟹ thesis›*) by (fast intro: fba.var (*‹Collect ((∈) ?i) ∈ fba›*)) hence "S ∩ - S ∈ fba" apply (intro fba.intros (*‹Collect ((∈) (?i::?'a)) ∈ fba› ‹(?S::?'a set set) ∈ fba ⟹ - ?S ∈ fba› ‹⟦(?S::?'a set set) ∈ fba; (?T::?'a set set) ∈ fba⟧ ⟹ ?S ∩ ?T ∈ fba›*)) (*goals: 1. ‹S ∈ fba ⟹ S ∈ fba› 2. ‹S ∈ fba ⟹ S ∈ fba› discuss goal 1*) apply ((assumption)[1]) (*discuss goal 2*) . (*proven 2 subgoals*) thus "?thesis" (*goal: ‹{} ∈ fba›*) by simp qed lemma fba_UNIV: "(UNIV :: 'a set set) ∈ fba" proof (-) (*goal: ‹UNIV ∈ fba›*) have "- {} ∈ fba" using fba_empty (*‹{} ∈ fba›*) by (rule fba.Compl (*‹?S ∈ fba ⟹ - ?S ∈ fba›*)) thus "UNIV ∈ fba" by simp qed subsection ‹Free boolean algebra as a type› text ‹ The next step is to use ‹typedef› to define a type isomorphic to the set @{const fba}. We also define a constructor ‹var› that corresponds with the similarly-named introduction rule for @{const fba}. › typedef 'a formula = "fba :: 'a set set set" by (auto intro: fba_empty) definition var :: "'a ⇒ 'a formula" where "var i = Abs_formula {A. i ∈ A}" lemma Rep_formula_var: "Rep_formula (var i) = {A. i ∈ A}" unfolding var_def (*goal: ‹Rep_formula (Abs_formula (Collect ((∈) i))) = {A. i ∈ A}›*) using fba.var (*‹Collect ((∈) ?i) ∈ fba›*) by (rule Abs_formula_inverse (*‹(?y::?'a set set) ∈ fba ⟹ Rep_formula (Abs_formula ?y) = ?y›*)) text ‹ \medskip Now we make type @{typ "'a formula"} into a Boolean algebra. This involves defining the various operations (ordering relations, binary infimum and supremum, complement, difference, top and bottom elements) and proving that they satisfy the appropriate laws. › instantiation formula :: (type) boolean_algebra begin definition "x ⊓ y = Abs_formula (Rep_formula x ∩ Rep_formula y)" definition "x ⊔ y = Abs_formula (Rep_formula x ∪ Rep_formula y)" definition "⊤ = Abs_formula UNIV" definition "⊥ = Abs_formula {}" definition "x ≤ y ⟷ Rep_formula x ⊆ Rep_formula y" definition "x < y ⟷ Rep_formula x ⊂ Rep_formula y" definition "- x = Abs_formula (- Rep_formula x)" definition "x - y = Abs_formula (Rep_formula x - Rep_formula y)" lemma Rep_formula_inf: "Rep_formula (x ⊓ y) = Rep_formula x ∩ Rep_formula y" unfolding inf_formula_def (*goal: ‹Rep_formula (Abs_formula (Rep_formula x ∩ Rep_formula y)) = Rep_formula x ∩ Rep_formula y›*) by (intro Abs_formula_inverse (*‹(?y::?'a set set) ∈ fba ⟹ Rep_formula (Abs_formula ?y) = ?y›*) fba.inter (*‹⟦(?S::?'a set set) ∈ fba; (?T::?'a set set) ∈ fba⟧ ⟹ ?S ∩ ?T ∈ fba›*) Rep_formula (*‹Rep_formula (?x::?'a formula) ∈ fba›*)) lemma Rep_formula_sup: "Rep_formula (x ⊔ y) = Rep_formula x ∪ Rep_formula y" unfolding sup_formula_def (*goal: ‹Rep_formula (Abs_formula (Rep_formula x ∪ Rep_formula y)) = Rep_formula x ∪ Rep_formula y›*) by (intro Abs_formula_inverse (*‹(?y::?'a set set) ∈ fba ⟹ Rep_formula (Abs_formula ?y) = ?y›*) fba_union (*‹⟦(?S::?'a set set) ∈ fba; (?T::?'a set set) ∈ fba⟧ ⟹ ?S ∪ ?T ∈ fba›*) Rep_formula (*‹Rep_formula (?x::?'a formula) ∈ fba›*)) lemma Rep_formula_top: "Rep_formula ⊤ = UNIV" sorry lemma Rep_formula_bot: "Rep_formula ⊥ = {}" unfolding bot_formula_def (*goal: ‹Rep_formula (Abs_formula {}) = {}›*) by (intro Abs_formula_inverse (*‹?y ∈ fba ⟹ Rep_formula (Abs_formula ?y) = ?y›*) fba_empty (*‹{} ∈ fba›*)) lemma Rep_formula_compl: "Rep_formula (- x) = - Rep_formula x" unfolding uminus_formula_def (*goal: ‹Rep_formula (Abs_formula (- Rep_formula x)) = - Rep_formula x›*) by (intro Abs_formula_inverse (*‹?y ∈ fba ⟹ Rep_formula (Abs_formula ?y) = ?y›*) fba.Compl (*‹?S ∈ fba ⟹ - ?S ∈ fba›*) Rep_formula (*‹Rep_formula ?x ∈ fba›*)) lemma Rep_formula_diff: "Rep_formula (x - y) = Rep_formula x - Rep_formula y" unfolding minus_formula_def (*goal: ‹Rep_formula (Abs_formula (Rep_formula x - Rep_formula y)) = Rep_formula x - Rep_formula y›*) by (intro Abs_formula_inverse (*‹?y ∈ fba ⟹ Rep_formula (Abs_formula ?y) = ?y›*) fba_Diff (*‹⟦?S ∈ fba; ?T ∈ fba⟧ ⟹ ?S - ?T ∈ fba›*) Rep_formula (*‹Rep_formula ?x ∈ fba›*)) lemmas eq_formula_iff = Rep_formula_inject [symmetric] lemmas Rep_formula_simps = less_eq_formula_def less_formula_def eq_formula_iff Rep_formula_sup Rep_formula_inf Rep_formula_top Rep_formula_bot Rep_formula_compl Rep_formula_diff Rep_formula_var instance proof qed (unfold Rep_formula_simps, auto) end text ‹ \medskip The laws of a Boolean algebra do not require the top and bottom elements to be distinct, so the following rules must be proved separately: › lemma bot_neq_top_formula [simp]: "(⊥ :: 'a formula) ≠ ⊤" unfolding Rep_formula_simps (*goal: ‹{} ≠ UNIV›*) by auto lemma top_neq_bot_formula [simp]: "(⊤ :: 'a formula) ≠ ⊥" unfolding Rep_formula_simps (*goal: ‹UNIV ≠ {}›*) by auto text ‹ \medskip Here we prove an essential property of a free Boolean algebra: all generators are independent. › lemma var_le_var_simps [simp]: "var i ≤ var j ⟷ i = j" "¬ var i ≤ - var j" "¬ - var i ≤ var j" unfolding Rep_formula_simps (*goals: 1. ‹(Collect ((∈) (i::'a)) ⊆ Collect ((∈) (j::'a))) = (i = j)› 2. ‹¬ Collect ((∈) (i::'a)) ⊆ - Collect ((∈) (j::'a))› 3. ‹¬ - Collect ((∈) (i::'a)) ⊆ Collect ((∈) (j::'a))›*) (*goals: 1. ‹(Collect ((∈) i) ⊆ Collect ((∈) j)) = (i = j)› 2. ‹¬ Collect ((∈) i) ⊆ - Collect ((∈) j)› 3. ‹¬ - Collect ((∈) i) ⊆ Collect ((∈) j)› discuss goal 1*) apply fast (*discuss goal 2*) apply fast (*discuss goal 3*) apply fast (*proven 3 subgoals*) . lemma var_eq_var_simps [simp]: "var i = var j ⟷ i = j" "var i ≠ - var j" "- var i ≠ var j" unfolding Rep_formula_simps set_eq_subset (*goals: 1. ‹(Collect ((∈) i) ⊆ Collect ((∈) j) ∧ Collect ((∈) j) ⊆ Collect ((∈) i)) = (i = j)› 2. ‹¬ (Collect ((∈) i) ⊆ - Collect ((∈) j) ∧ - Collect ((∈) j) ⊆ Collect ((∈) i))› 3. ‹¬ (- Collect ((∈) i) ⊆ Collect ((∈) j) ∧ Collect ((∈) j) ⊆ - Collect ((∈) i))›*) (*goals: 1. ‹(Collect ((∈) i) ⊆ Collect ((∈) j) ∧ Collect ((∈) j) ⊆ Collect ((∈) i)) = (i = j)› 2. ‹¬ (Collect ((∈) i) ⊆ - Collect ((∈) j) ∧ - Collect ((∈) j) ⊆ Collect ((∈) i))› 3. ‹¬ (- Collect ((∈) i) ⊆ Collect ((∈) j) ∧ Collect ((∈) j) ⊆ - Collect ((∈) i))› discuss goal 1*) apply fast (*discuss goal 2*) apply fast (*discuss goal 3*) apply fast (*proven 3 subgoals*) . text ‹ \medskip We conclude this section by proving an induction principle for formulas. It mirrors the definition of the inductive set ‹fba›, with cases for variables, complements, and conjunction. › lemma formula_induct [case_names var compl inf, induct type: formula]: fixes P :: "'a formula ⇒ bool" assumes 1: "⋀i. P (var i)" assumes 2: "⋀x. P x ⟹ P (- x)" assumes 3: "⋀x y. P x ⟹ P y ⟹ P (x ⊓ y)" shows "P x" proof (induct x rule: Abs_formula_induct (*‹(⋀y. y ∈ fba ⟹ ?P (Abs_formula y)) ⟹ ?P ?x›*)) (*goal: ‹⋀y. y ∈ fba ⟹ P (Abs_formula y)›*) fix y :: "'a set set" assume "y ∈ fba" (*‹(y::'a set set) ∈ fba›*) thus "P (Abs_formula y)" proof (induct rule: fba.induct (*‹⟦(?x::?'a set set) ∈ fba; ⋀i::?'a. (?P::?'a set set ⇒ bool) {A::?'a set. i ∈ A}; ⋀S::?'a set set. ⟦S ∈ fba; ?P S⟧ ⟹ ?P (- S); ⋀(S::?'a set set) T::?'a set set. ⟦S ∈ fba; ?P S; T ∈ fba; ?P T⟧ ⟹ ?P (S ∩ T)⟧ ⟹ ?P ?x›*)) (*goals: 1. ‹⋀i. P (Abs_formula {A. i ∈ A})› 2. ‹⋀S. ⟦S ∈ fba; P (Abs_formula S)⟧ ⟹ P (Abs_formula (- S))› 3. ‹⋀S T. ⟦S ∈ fba; P (Abs_formula S); T ∈ fba; P (Abs_formula T)⟧ ⟹ P (Abs_formula (S ∩ T))›*) case (var i) (*no hyothesis introduced yet*) have "P (var i)" by (rule 1 (*‹P (var ?i)›*)) thus "?case" (*goal: ‹P (Abs_formula {A. i ∈ A})›*) unfolding var_def (*goal: ‹P (Abs_formula {A. i ∈ A})›*) . next (*goals: 1. ‹⋀S::'a set set. ⟦S ∈ fba; (P::'a formula ⇒ bool) (Abs_formula S)⟧ ⟹ P (Abs_formula (- S))› 2. ‹⋀(S::'a set set) T::'a set set. ⟦S ∈ fba; (P::'a formula ⇒ bool) (Abs_formula S); T ∈ fba; P (Abs_formula T)⟧ ⟹ P (Abs_formula (S ∩ T))›*) case (Compl S) (*‹S ∈ fba› ‹P (Abs_formula S)›*) from ‹P (Abs_formula S)› (*‹(P::'a formula ⇒ bool) (Abs_formula (S::'a set set))›*) have "P (- Abs_formula S)" by (rule 2 (*‹(P::'a formula ⇒ bool) (?x::'a formula) ⟹ P (- ?x)›*)) with ‹S ∈ fba› (*‹(S::'a set set) ∈ fba›*) show "?case" (*goal: ‹P (Abs_formula (- S))›*) unfolding uminus_formula_def (*goal: ‹P (Abs_formula (- S))›*) by (simp add: Abs_formula_inverse (*‹?y ∈ fba ⟹ Rep_formula (Abs_formula ?y) = ?y›*)) next (*goal: ‹⋀S T. ⟦S ∈ fba; P (Abs_formula S); T ∈ fba; P (Abs_formula T)⟧ ⟹ P (Abs_formula (S ∩ T))›*) case (inter S T) (*‹S ∈ fba› ‹P (Abs_formula S)› ‹(T::'a::type set set) ∈ fba› ‹P (Abs_formula T)›*) from ‹P (Abs_formula S)› (*‹P (Abs_formula S)›*) ‹P (Abs_formula T)› (*‹P (Abs_formula T)›*) have "P (Abs_formula S ⊓ Abs_formula T)" by (rule 3 (*‹⟦P ?x; P ?y⟧ ⟹ P (?x ⊓ ?y)›*)) with ‹S ∈ fba› (*‹(S::'a::type set set) ∈ fba›*) ‹T ∈ fba› (*‹T ∈ fba›*) show "?case" (*goal: ‹P (Abs_formula (S ∩ T))›*) unfolding inf_formula_def (*goal: ‹P (Abs_formula (S ∩ T))›*) by (simp add: Abs_formula_inverse (*‹(?y::?'a set set) ∈ fba ⟹ Rep_formula (Abs_formula ?y) = ?y›*)) qed qed subsection ‹If-then-else for Boolean algebras› text ‹ This is a generic if-then-else operator for arbitrary Boolean algebras. › definition ifte :: "'a::boolean_algebra ⇒ 'a ⇒ 'a ⇒ 'a" where "ifte a x y = (a ⊓ x) ⊔ (- a ⊓ y)" lemma ifte_top [simp]: "ifte ⊤ x y = x" unfolding ifte_def (*goal: ‹⊤ ⊓ x ⊔ - ⊤ ⊓ y = x›*) by simp lemma ifte_bot [simp]: "ifte ⊥ x y = y" unfolding ifte_def (*goal: ‹⊥ ⊓ (x::'a) ⊔ - ⊥ ⊓ (y::'a) = y›*) by simp lemma ifte_same: "ifte a x x = x" unfolding ifte_def (*goal: ‹a ⊓ x ⊔ - a ⊓ x = x›*) by (simp add: inf_sup_distrib2 [symmetric] (*‹(?y::?'a) ⊓ (?x::?'a) ⊔ (?z::?'a) ⊓ ?x = (?y ⊔ ?z) ⊓ ?x›*) sup_compl_top (*‹(?x::?'a) ⊔ - ?x = ⊤›*)) lemma compl_ifte: "- ifte a x y = ifte a (- x) (- y)" unfolding ifte_def (*goal: ‹- (a ⊓ x ⊔ - a ⊓ y) = a ⊓ - x ⊔ - a ⊓ - y›*) apply (rule order_antisym (*‹⟦?x ≤ ?y; ?y ≤ ?x⟧ ⟹ ?x = ?y›*)) (*goals: 1. ‹- (a ⊓ x ⊔ - a ⊓ y) ≤ a ⊓ - x ⊔ - a ⊓ - y› 2. ‹a ⊓ - x ⊔ - a ⊓ - y ≤ - (a ⊓ x ⊔ - a ⊓ y)› discuss goal 1*) apply (simp add: inf_sup_distrib1 (*‹?x ⊓ (?y ⊔ ?z) = ?x ⊓ ?y ⊔ ?x ⊓ ?z›*) inf_sup_distrib2 (*‹(?y ⊔ ?z) ⊓ ?x = ?y ⊓ ?x ⊔ ?z ⊓ ?x›*) compl_inf_bot (*‹- ?x ⊓ ?x = ⊥›*)) (*top goal: ‹- (a ⊓ x ⊔ - a ⊓ y) ≤ a ⊓ - x ⊔ - a ⊓ - y› and 1 goal remains*) apply (simp add: sup_inf_distrib1 (*‹?x ⊔ ?y ⊓ ?z = (?x ⊔ ?y) ⊓ (?x ⊔ ?z)›*) sup_inf_distrib2 (*‹?y ⊓ ?z ⊔ ?x = (?y ⊔ ?x) ⊓ (?z ⊔ ?x)›*) sup_compl_top (*‹?x ⊔ - ?x = ⊤›*)) (*top goal: ‹- x ⊓ a ≤ a ⊓ - x ⊔ - a ⊓ - y ∧ - x ⊓ - y ≤ a ⊓ - x ⊔ - a ⊓ - y› and 1 goal remains*) apply (simp add: le_infI1 (*‹(?a::?'a) ≤ (?x::?'a) ⟹ ?a ⊓ (?b::?'a) ≤ ?x›*) le_infI2 (*‹(?b::?'a) ≤ (?x::?'a) ⟹ (?a::?'a) ⊓ ?b ≤ ?x›*) le_supI1 (*‹(?x::?'a) ≤ (?a::?'a) ⟹ ?x ≤ ?a ⊔ (?b::?'a)›*) le_supI2 (*‹(?x::?'a) ≤ (?b::?'a) ⟹ ?x ≤ (?a::?'a) ⊔ ?b›*)) (*discuss goal 2*) apply (simp add: le_infI1 (*‹?a ≤ ?x ⟹ ?a ⊓ ?b ≤ ?x›*) le_infI2 (*‹?b ≤ ?x ⟹ ?a ⊓ ?b ≤ ?x›*) le_supI1 (*‹?x ≤ ?a ⟹ ?x ≤ ?a ⊔ ?b›*) le_supI2 (*‹?x ≤ ?b ⟹ ?x ≤ ?a ⊔ ?b›*)) (*proven 2 subgoals*) . lemma inf_ifte_distrib: "ifte x a b ⊓ ifte x c d = ifte x (a ⊓ c) (b ⊓ d)" unfolding ifte_def (*goal: ‹(x ⊓ a ⊔ - x ⊓ b) ⊓ (x ⊓ c ⊔ - x ⊓ d) = x ⊓ (a ⊓ c) ⊔ - x ⊓ (b ⊓ d)›*) apply (simp add: inf_sup_distrib1 (*‹(?x::?'a) ⊓ ((?y::?'a) ⊔ (?z::?'a)) = ?x ⊓ ?y ⊔ ?x ⊓ ?z›*) inf_sup_distrib2 (*‹((?y::?'a) ⊔ (?z::?'a)) ⊓ (?x::?'a) = ?y ⊓ ?x ⊔ ?z ⊓ ?x›*)) (*goal: ‹(x ⊓ a ⊔ - x ⊓ b) ⊓ (x ⊓ c ⊔ - x ⊓ d) = x ⊓ (a ⊓ c) ⊔ - x ⊓ (b ⊓ d)›*) by (simp add: inf_sup_aci (*‹?x ⊓ ?y = ?y ⊓ ?x› ‹?x ⊓ ?y ⊓ ?z = ?x ⊓ (?y ⊓ ?z)› ‹?x ⊓ (?y ⊓ ?z) = ?y ⊓ (?x ⊓ ?z)› ‹?x ⊓ (?x ⊓ ?y) = ?x ⊓ ?y› ‹?x ⊔ ?y = ?y ⊔ ?x› ‹?x ⊔ ?y ⊔ ?z = ?x ⊔ (?y ⊔ ?z)› ‹?x ⊔ (?y ⊔ ?z) = ?y ⊔ (?x ⊔ ?z)› ‹?x ⊔ (?x ⊔ ?y) = ?x ⊔ ?y›*) inf_compl_bot (*‹?x ⊓ - ?x = ⊥›*)) lemma ifte_ifte_distrib: "ifte x (ifte y a b) (ifte y c d) = ifte y (ifte x a c) (ifte x b d)" unfolding ifte_def[of x] sup_conv_inf (*goal: ‹- (- (x ⊓ ifte y a b) ⊓ - (- x ⊓ ifte y c d)) = ifte y (- (- (x ⊓ a) ⊓ - (- x ⊓ c))) (- (- (x ⊓ b) ⊓ - (- x ⊓ d)))›*) by (simp only: compl_ifte [symmetric] (*‹ifte ?a (- ?x) (- ?y) = - ifte ?a ?x ?y›*) inf_ifte_distrib [symmetric] (*‹ifte ?x (?a ⊓ ?c) (?b ⊓ ?d) = ifte ?x ?a ?b ⊓ ifte ?x ?c ?d›*) ifte_same (*‹ifte ?a ?x ?x = ?x›*)) subsection ‹Formulas over a set of generators› text ‹ The set ‹formulas S› consists of those formulas that only depend on variables in the set ‹S›. It is analogous to the @{const lists} operator for the list datatype. › definition formulas :: "'a set ⇒ 'a formula set" where "formulas S = {x. ∀A B. (∀i∈S. i ∈ A ⟷ i ∈ B) ⟶ A ∈ Rep_formula x ⟷ B ∈ Rep_formula x}" lemma formulasI: assumes "⋀A B. ∀i∈S. i ∈ A ⟷ i ∈ B ⟹ A ∈ Rep_formula x ⟷ B ∈ Rep_formula x" shows "x ∈ formulas S" using assms (*‹∀i∈S. (i ∈ ?A) = (i ∈ ?B) ⟹ (?A ∈ Rep_formula x) = (?B ∈ Rep_formula x)›*) unfolding formulas_def (*goal: ‹x ∈ {x. ∀A B. (∀i∈S. (i ∈ A) = (i ∈ B)) ⟶ (A ∈ Rep_formula x) = (B ∈ Rep_formula x)}›*) by simp lemma formulasD: assumes "x ∈ formulas S" assumes "∀i∈S. i ∈ A ⟷ i ∈ B" shows "A ∈ Rep_formula x ⟷ B ∈ Rep_formula x" using assms (*‹x ∈ formulas S› ‹∀i∈S. (i ∈ A) = (i ∈ B)›*) unfolding formulas_def (*goal: ‹(A ∈ Rep_formula x) = (B ∈ Rep_formula x)›*) by simp lemma formulas_mono: "S ⊆ T ⟹ formulas S ⊆ formulas T" by (fast intro!: formulasI (*‹(⋀A B. ∀i∈?S. (i ∈ A) = (i ∈ B) ⟹ (A ∈ Rep_formula ?x) = (B ∈ Rep_formula ?x)) ⟹ ?x ∈ formulas ?S›*) elim!: formulasD (*‹⟦?x ∈ formulas ?S; ∀i∈?S. (i ∈ ?A) = (i ∈ ?B)⟧ ⟹ (?A ∈ Rep_formula ?x) = (?B ∈ Rep_formula ?x)›*)) lemma formulas_insert: "x ∈ formulas S ⟹ x ∈ formulas (insert a S)" unfolding formulas_def (*goal: ‹x ∈ {x. ∀A B. (∀i∈S. (i ∈ A) = (i ∈ B)) ⟶ (A ∈ Rep_formula x) = (B ∈ Rep_formula x)} ⟹ x ∈ {x. ∀A B. (∀i∈insert a S. (i ∈ A) = (i ∈ B)) ⟶ (A ∈ Rep_formula x) = (B ∈ Rep_formula x)}›*) by simp lemma formulas_var: "i ∈ S ⟹ var i ∈ formulas S" unfolding formulas_def (*goal: ‹i ∈ S ⟹ var i ∈ {x. ∀A B. (∀i∈S. (i ∈ A) = (i ∈ B)) ⟶ (A ∈ Rep_formula x) = (B ∈ Rep_formula x)}›*) by (simp add: Rep_formula_simps (*‹(?x ≤ ?y) = (Rep_formula ?x ⊆ Rep_formula ?y)› ‹(?x < ?y) = (Rep_formula ?x ⊂ Rep_formula ?y)› ‹(?x = ?y) = (Rep_formula ?x = Rep_formula ?y)› ‹Rep_formula (?x ⊔ ?y) = Rep_formula ?x ∪ Rep_formula ?y› ‹Rep_formula (?x ⊓ ?y) = Rep_formula ?x ∩ Rep_formula ?y› ‹Rep_formula ⊤ = UNIV› ‹Rep_formula ⊥ = {}› ‹Rep_formula (- ?x) = - Rep_formula ?x› ‹Rep_formula (?x - ?y) = Rep_formula ?x - Rep_formula ?y› ‹Rep_formula (var ?i) = {A. ?i ∈ A}›*)) lemma formulas_var_iff: "var i ∈ formulas S ⟷ i ∈ S" unfolding formulas_def (*goal: ‹(var i ∈ {x. ∀A B. (∀i∈S. (i ∈ A) = (i ∈ B)) ⟶ (A ∈ Rep_formula x) = (B ∈ Rep_formula x)}) = (i ∈ S)›*) apply (simp add: Rep_formula_simps (*‹(?x ≤ ?y) = (Rep_formula ?x ⊆ Rep_formula ?y)› ‹(?x < ?y) = (Rep_formula ?x ⊂ Rep_formula ?y)› ‹(?x = ?y) = (Rep_formula ?x = Rep_formula ?y)› ‹Rep_formula (?x ⊔ ?y) = Rep_formula ?x ∪ Rep_formula ?y› ‹Rep_formula (?x ⊓ ?y) = Rep_formula ?x ∩ Rep_formula ?y› ‹Rep_formula ⊤ = UNIV› ‹Rep_formula ⊥ = {}› ‹Rep_formula (- ?x) = - Rep_formula ?x› ‹Rep_formula (?x - ?y) = Rep_formula ?x - Rep_formula ?y› ‹Rep_formula (var ?i) = {A. ?i ∈ A}›*)) (*goal: ‹(var i ∈ {x. ∀A B. (∀i∈S. (i ∈ A) = (i ∈ B)) ⟶ (A ∈ Rep_formula x) = (B ∈ Rep_formula x)}) = (i ∈ S)›*) by fast lemma formulas_bot: "⊥ ∈ formulas S" unfolding formulas_def (*goal: ‹⊥ ∈ {x. ∀A B. (∀i∈S. (i ∈ A) = (i ∈ B)) ⟶ (A ∈ Rep_formula x) = (B ∈ Rep_formula x)}›*) by (simp add: Rep_formula_simps (*‹(?x ≤ ?y) = (Rep_formula ?x ⊆ Rep_formula ?y)› ‹(?x < ?y) = (Rep_formula ?x ⊂ Rep_formula ?y)› ‹(?x = ?y) = (Rep_formula ?x = Rep_formula ?y)› ‹Rep_formula (?x ⊔ ?y) = Rep_formula ?x ∪ Rep_formula ?y› ‹Rep_formula (?x ⊓ ?y) = Rep_formula ?x ∩ Rep_formula ?y› ‹Rep_formula ⊤ = UNIV› ‹Rep_formula ⊥ = {}› ‹Rep_formula (- ?x) = - Rep_formula ?x› ‹Rep_formula (?x - ?y) = Rep_formula ?x - Rep_formula ?y› ‹Rep_formula (var ?i) = {A. ?i ∈ A}›*)) lemma formulas_top: "⊤ ∈ formulas S" sorry lemma formulas_compl: "x ∈ formulas S ⟹ - x ∈ formulas S" unfolding formulas_def (*goal: ‹x ∈ {x. ∀A B. (∀i∈S. (i ∈ A) = (i ∈ B)) ⟶ (A ∈ Rep_formula x) = (B ∈ Rep_formula x)} ⟹ - x ∈ {x. ∀A B. (∀i∈S. (i ∈ A) = (i ∈ B)) ⟶ (A ∈ Rep_formula x) = (B ∈ Rep_formula x)}›*) by (simp add: Rep_formula_simps (*‹((?x::?'a::type formula) ≤ (?y::?'a::type formula)) = (Rep_formula ?x ⊆ Rep_formula ?y)› ‹((?x::?'a::type formula) < (?y::?'a::type formula)) = (Rep_formula ?x ⊂ Rep_formula ?y)› ‹((?x::?'a::type formula) = (?y::?'a::type formula)) = (Rep_formula ?x = Rep_formula ?y)› ‹Rep_formula ((?x::?'a::type formula) ⊔ (?y::?'a::type formula)) = Rep_formula ?x ∪ Rep_formula ?y› ‹Rep_formula ((?x::?'a::type formula) ⊓ (?y::?'a::type formula)) = Rep_formula ?x ∩ Rep_formula ?y› ‹Rep_formula ⊤ = UNIV› ‹Rep_formula ⊥ = {}› ‹Rep_formula (- (?x::?'a::type formula)) = - Rep_formula ?x› ‹Rep_formula ((?x::?'a::type formula) - (?y::?'a::type formula)) = Rep_formula ?x - Rep_formula ?y› ‹Rep_formula (var (?i::?'a::type)) = {A::?'a::type set. ?i ∈ A}›*)) lemma formulas_inf: "x ∈ formulas S ⟹ y ∈ formulas S ⟹ x ⊓ y ∈ formulas S" unfolding formulas_def (*goal: ‹⟦x ∈ {x. ∀A B. (∀i∈S. (i ∈ A) = (i ∈ B)) ⟶ (A ∈ Rep_formula x) = (B ∈ Rep_formula x)}; y ∈ {x. ∀A B. (∀i∈S. (i ∈ A) = (i ∈ B)) ⟶ (A ∈ Rep_formula x) = (B ∈ Rep_formula x)}⟧ ⟹ x ⊓ y ∈ {x. ∀A B. (∀i∈S. (i ∈ A) = (i ∈ B)) ⟶ (A ∈ Rep_formula x) = (B ∈ Rep_formula x)}›*) by (auto simp add: Rep_formula_simps (*‹((?x::?'a::type formula) ≤ (?y::?'a::type formula)) = (Rep_formula ?x ⊆ Rep_formula ?y)› ‹((?x::?'a::type formula) < (?y::?'a::type formula)) = (Rep_formula ?x ⊂ Rep_formula ?y)› ‹((?x::?'a::type formula) = (?y::?'a::type formula)) = (Rep_formula ?x = Rep_formula ?y)› ‹Rep_formula ((?x::?'a::type formula) ⊔ (?y::?'a::type formula)) = Rep_formula ?x ∪ Rep_formula ?y› ‹Rep_formula ((?x::?'a::type formula) ⊓ (?y::?'a::type formula)) = Rep_formula ?x ∩ Rep_formula ?y› ‹Rep_formula ⊤ = UNIV› ‹Rep_formula ⊥ = {}› ‹Rep_formula (- (?x::?'a::type formula)) = - Rep_formula ?x› ‹Rep_formula ((?x::?'a::type formula) - (?y::?'a::type formula)) = Rep_formula ?x - Rep_formula ?y› ‹Rep_formula (var (?i::?'a::type)) = {A::?'a::type set. ?i ∈ A}›*)) lemma formulas_sup: "x ∈ formulas S ⟹ y ∈ formulas S ⟹ x ⊔ y ∈ formulas S" unfolding formulas_def (*goal: ‹⟦x ∈ {x. ∀A B. (∀i∈S. (i ∈ A) = (i ∈ B)) ⟶ (A ∈ Rep_formula x) = (B ∈ Rep_formula x)}; y ∈ {x. ∀A B. (∀i∈S. (i ∈ A) = (i ∈ B)) ⟶ (A ∈ Rep_formula x) = (B ∈ Rep_formula x)}⟧ ⟹ x ⊔ y ∈ {x. ∀A B. (∀i∈S. (i ∈ A) = (i ∈ B)) ⟶ (A ∈ Rep_formula x) = (B ∈ Rep_formula x)}›*) by (auto simp add: Rep_formula_simps (*‹(?x ≤ ?y) = (Rep_formula ?x ⊆ Rep_formula ?y)› ‹(?x < ?y) = (Rep_formula ?x ⊂ Rep_formula ?y)› ‹(?x = ?y) = (Rep_formula ?x = Rep_formula ?y)› ‹Rep_formula (?x ⊔ ?y) = Rep_formula ?x ∪ Rep_formula ?y› ‹Rep_formula (?x ⊓ ?y) = Rep_formula ?x ∩ Rep_formula ?y› ‹Rep_formula ⊤ = UNIV› ‹Rep_formula ⊥ = {}› ‹Rep_formula (- ?x) = - Rep_formula ?x› ‹Rep_formula (?x - ?y) = Rep_formula ?x - Rep_formula ?y› ‹Rep_formula (var ?i) = {A. ?i ∈ A}›*)) lemma formulas_diff: "x ∈ formulas S ⟹ y ∈ formulas S ⟹ x - y ∈ formulas S" unfolding formulas_def (*goal: ‹⟦x ∈ {x. ∀A B. (∀i∈S. (i ∈ A) = (i ∈ B)) ⟶ (A ∈ Rep_formula x) = (B ∈ Rep_formula x)}; y ∈ {x. ∀A B. (∀i∈S. (i ∈ A) = (i ∈ B)) ⟶ (A ∈ Rep_formula x) = (B ∈ Rep_formula x)}⟧ ⟹ x - y ∈ {x. ∀A B. (∀i∈S. (i ∈ A) = (i ∈ B)) ⟶ (A ∈ Rep_formula x) = (B ∈ Rep_formula x)}›*) by (auto simp add: Rep_formula_simps (*‹(?x ≤ ?y) = (Rep_formula ?x ⊆ Rep_formula ?y)› ‹(?x < ?y) = (Rep_formula ?x ⊂ Rep_formula ?y)› ‹(?x = ?y) = (Rep_formula ?x = Rep_formula ?y)› ‹Rep_formula (?x ⊔ ?y) = Rep_formula ?x ∪ Rep_formula ?y› ‹Rep_formula (?x ⊓ ?y) = Rep_formula ?x ∩ Rep_formula ?y› ‹Rep_formula ⊤ = UNIV› ‹Rep_formula ⊥ = {}› ‹Rep_formula (- ?x) = - Rep_formula ?x› ‹Rep_formula (?x - ?y) = Rep_formula ?x - Rep_formula ?y› ‹Rep_formula (var ?i) = {A. ?i ∈ A}›*)) lemma formulas_ifte: "a ∈ formulas S ⟹ x ∈ formulas S ⟹ y ∈ formulas S ⟹ ifte a x y ∈ formulas S" unfolding ifte_def (*goal: ‹⟦a ∈ formulas S; x ∈ formulas S; y ∈ formulas S⟧ ⟹ a ⊓ x ⊔ - a ⊓ y ∈ formulas S›*) apply (intro formulas_sup (*‹⟦(?x::?'a::type formula) ∈ formulas (?S::?'a::type set); (?y::?'a::type formula) ∈ formulas ?S⟧ ⟹ ?x ⊔ ?y ∈ formulas ?S›*) formulas_inf (*‹⟦(?x::?'a::type formula) ∈ formulas (?S::?'a::type set); (?y::?'a::type formula) ∈ formulas ?S⟧ ⟹ ?x ⊓ ?y ∈ formulas ?S›*) formulas_compl (*‹(?x::?'a::type formula) ∈ formulas (?S::?'a::type set) ⟹ - ?x ∈ formulas ?S›*)) (*goals: 1. ‹⟦(a::'a formula) ∈ formulas (S::'a set); (x::'a formula) ∈ formulas S; (y::'a formula) ∈ formulas S⟧ ⟹ a ∈ formulas S› 2. ‹⟦(a::'a formula) ∈ formulas (S::'a set); (x::'a formula) ∈ formulas S; (y::'a formula) ∈ formulas S⟧ ⟹ x ∈ formulas S› 3. ‹⟦(a::'a formula) ∈ formulas (S::'a set); (x::'a formula) ∈ formulas S; (y::'a formula) ∈ formulas S⟧ ⟹ a ∈ formulas S› 4. ‹⟦(a::'a formula) ∈ formulas (S::'a set); (x::'a formula) ∈ formulas S; (y::'a formula) ∈ formulas S⟧ ⟹ y ∈ formulas S› discuss goal 1*) apply ((assumption)[1]) (*discuss goal 2*) apply ((assumption)[1]) (*discuss goal 3*) apply ((assumption)[1]) (*discuss goal 4*) . (*proven 4 subgoals*) lemmas formulas_intros = formulas_var formulas_bot formulas_top formulas_compl formulas_inf formulas_sup formulas_diff formulas_ifte subsection ‹Injectivity of if-then-else› text ‹ The if-then-else operator is injective in some limited circumstances: when the scrutinee is a variable that is not mentioned in either branch. › lemma ifte_inject: assumes "ifte (var i) x y = ifte (var i) x' y'" assumes "i ∉ S" assumes "x ∈ formulas S" and "x' ∈ formulas S" assumes "y ∈ formulas S" and "y' ∈ formulas S" shows "x = x' ∧ y = y'" proof (standard) (*goals: 1. ‹x = x'› 2. ‹y = y'›*) have 1: "⋀A. i ∈ A ⟹ A ∈ Rep_formula x ⟷ A ∈ Rep_formula x'" using assms(1) (*‹ifte (var i) x y = ifte (var i) x' y'›*) apply (simp add: Rep_formula_simps (*‹(?x ≤ ?y) = (Rep_formula ?x ⊆ Rep_formula ?y)› ‹(?x < ?y) = (Rep_formula ?x ⊂ Rep_formula ?y)› ‹(?x = ?y) = (Rep_formula ?x = Rep_formula ?y)› ‹Rep_formula (?x ⊔ ?y) = Rep_formula ?x ∪ Rep_formula ?y› ‹Rep_formula (?x ⊓ ?y) = Rep_formula ?x ∩ Rep_formula ?y› ‹Rep_formula ⊤ = UNIV› ‹Rep_formula ⊥ = {}› ‹Rep_formula (- ?x) = - Rep_formula ?x› ‹Rep_formula (?x - ?y) = Rep_formula ?x - Rep_formula ?y› ‹Rep_formula (var ?i) = {A. ?i ∈ A}›*) ifte_def (*‹ifte ?a ?x ?y = ?a ⊓ ?x ⊔ - ?a ⊓ ?y›*) set_eq_iff (*‹(?A = ?B) = (∀x. (x ∈ ?A) = (x ∈ ?B))›*)) (*goal: ‹⋀A. i ∈ A ⟹ (A ∈ Rep_formula x) = (A ∈ Rep_formula x')›*) by fast have 2: "⋀A. i ∉ A ⟹ A ∈ Rep_formula y ⟷ A ∈ Rep_formula y'" using assms(1) (*‹ifte (var i) x y = ifte (var i) x' y'›*) apply (simp add: Rep_formula_simps (*‹(?x ≤ ?y) = (Rep_formula ?x ⊆ Rep_formula ?y)› ‹(?x < ?y) = (Rep_formula ?x ⊂ Rep_formula ?y)› ‹(?x = ?y) = (Rep_formula ?x = Rep_formula ?y)› ‹Rep_formula (?x ⊔ ?y) = Rep_formula ?x ∪ Rep_formula ?y› ‹Rep_formula (?x ⊓ ?y) = Rep_formula ?x ∩ Rep_formula ?y› ‹Rep_formula ⊤ = UNIV› ‹Rep_formula ⊥ = {}› ‹Rep_formula (- ?x) = - Rep_formula ?x› ‹Rep_formula (?x - ?y) = Rep_formula ?x - Rep_formula ?y› ‹Rep_formula (var ?i) = {A. ?i ∈ A}›*) ifte_def (*‹ifte ?a ?x ?y = ?a ⊓ ?x ⊔ - ?a ⊓ ?y›*) set_eq_iff (*‹(?A = ?B) = (∀x. (x ∈ ?A) = (x ∈ ?B))›*)) (*goal: ‹⋀A. i ∉ A ⟹ (A ∈ Rep_formula y) = (A ∈ Rep_formula y')›*) by fast show "x = x'" unfolding Rep_formula_simps (*goal: ‹Rep_formula x = Rep_formula x'›*) proof (rule set_eqI (*‹(⋀x. (x ∈ ?A) = (x ∈ ?B)) ⟹ ?A = ?B›*)) (*goal: ‹⋀xa. (xa ∈ Rep_formula x) = (xa ∈ Rep_formula x')›*) fix A have "A ∈ Rep_formula x ⟷ insert i A ∈ Rep_formula x" using ‹x ∈ formulas S› (*‹x ∈ formulas S›*) apply (rule formulasD (*‹⟦?x ∈ formulas ?S; ∀i∈?S. (i ∈ ?A) = (i ∈ ?B)⟧ ⟹ (?A ∈ Rep_formula ?x) = (?B ∈ Rep_formula ?x)›*)) (*goal: ‹(A ∈ Rep_formula x) = (insert i A ∈ Rep_formula x)›*) by (force simp add: ‹i ∉ S›) also (*calculation: ‹(A ∈ Rep_formula x) = (insert i A ∈ Rep_formula x)›*) have "… ⟷ insert i A ∈ Rep_formula x'" apply (rule 1 (*‹i ∈ ?A ⟹ (?A ∈ Rep_formula x) = (?A ∈ Rep_formula x')›*)) (*goal: ‹(insert i A ∈ Rep_formula x) = (insert i A ∈ Rep_formula x')›*) by simp also (*calculation: ‹(A ∈ Rep_formula x) = (insert i A ∈ Rep_formula x')›*) have "… ⟷ A ∈ Rep_formula x'" using ‹x' ∈ formulas S› (*‹x' ∈ formulas S›*) apply (rule formulasD (*‹⟦?x ∈ formulas ?S; ∀i∈?S. (i ∈ ?A) = (i ∈ ?B)⟧ ⟹ (?A ∈ Rep_formula ?x) = (?B ∈ Rep_formula ?x)›*)) (*goal: ‹(insert i A ∈ Rep_formula x') = (A ∈ Rep_formula x')›*) by (force simp add: ‹i ∉ S›) finally (*calculation: ‹(A ∈ Rep_formula x) = (A ∈ Rep_formula x')›*) show "A ∈ Rep_formula x ⟷ A ∈ Rep_formula x'" . qed show "y = y'" unfolding Rep_formula_simps (*goal: ‹Rep_formula y = Rep_formula y'›*) proof (rule set_eqI (*‹(⋀x::?'a::type. (x ∈ (?A::?'a::type set)) = (x ∈ (?B::?'a::type set))) ⟹ ?A = ?B›*)) (*goal: ‹⋀x. (x ∈ Rep_formula y) = (x ∈ Rep_formula y')›*) fix A have "A ∈ Rep_formula y ⟷ A - {i} ∈ Rep_formula y" using ‹y ∈ formulas S› (*‹y ∈ formulas S›*) apply (rule formulasD (*‹⟦?x ∈ formulas ?S; ∀i∈?S. (i ∈ ?A) = (i ∈ ?B)⟧ ⟹ (?A ∈ Rep_formula ?x) = (?B ∈ Rep_formula ?x)›*)) (*goal: ‹(A ∈ Rep_formula y) = (A - {i} ∈ Rep_formula y)›*) by (force simp add: ‹i ∉ S›) also (*calculation: ‹(A ∈ Rep_formula y) = (A - {i} ∈ Rep_formula y)›*) have "… ⟷ A - {i} ∈ Rep_formula y'" apply (rule 2 (*‹i ∉ ?A ⟹ (?A ∈ Rep_formula y) = (?A ∈ Rep_formula y')›*)) (*goal: ‹((A::'a::type set) - {i::'a::type} ∈ Rep_formula (y::'a::type formula)) = (A - {i} ∈ Rep_formula (y'::'a::type formula))›*) by simp also (*calculation: ‹((A::'a::type set) ∈ Rep_formula (y::'a::type formula)) = (A - {i::'a::type} ∈ Rep_formula (y'::'a::type formula))›*) have "… ⟷ A ∈ Rep_formula y'" using ‹y' ∈ formulas S› (*‹(y'::'a formula) ∈ formulas (S::'a set)›*) apply (rule formulasD (*‹⟦?x ∈ formulas ?S; ∀i∈?S. (i ∈ ?A) = (i ∈ ?B)⟧ ⟹ (?A ∈ Rep_formula ?x) = (?B ∈ Rep_formula ?x)›*)) (*goal: ‹(A - {i} ∈ Rep_formula y') = (A ∈ Rep_formula y')›*) by (force simp add: ‹i ∉ S›) finally (*calculation: ‹(A ∈ Rep_formula y) = (A ∈ Rep_formula y')›*) show "A ∈ Rep_formula y ⟷ A ∈ Rep_formula y'" . qed qed subsection ‹Specification of homomorphism operator› text ‹ Our goal is to define a homomorphism operator ‹hom› such that for any function ‹f›, ‹hom f› is the unique Boolean algebra homomorphism satisfying ‹hom f (var i) = f i› for all ‹i›. Instead of defining ‹hom› directly, we will follow the approach used to define Isabelle's ‹fold› operator for finite sets. First we define the graph of the ‹hom› function as a relation; later we will define the ‹hom› function itself using definite choice. The ‹hom_graph› relation is defined inductively, with introduction rules based on the if-then-else normal form of Boolean formulas. The relation is also indexed by an extra set parameter ‹S›, to ensure that branches of each if-then-else do not use the same variable again. › inductive hom_graph :: "('a ⇒ 'b::boolean_algebra) ⇒ 'a set ⇒ 'a formula ⇒ 'b ⇒ bool" for f :: "'a ⇒ 'b::boolean_algebra" where bot: "hom_graph f {} bot bot" | top: "hom_graph f {} top top" | ifte: "i ∉ S ⟹ hom_graph f S x a ⟹ hom_graph f S y b ⟹ hom_graph f (insert i S) (ifte (var i) x y) (ifte (f i) a b)" text ‹ \medskip The next two lemmas establish a stronger elimination rule for assumptions of the form @{term "hom_graph f (insert i S) x a"}. Essentially, they say that we can arrange the top-level if-then-else to use the variable of our choice. The proof makes use of the distributive properties of if-then-else. › lemma hom_graph_dest: "hom_graph f S x a ⟹ k ∈ S ⟹ ∃y z b c. x = ifte (var k) y z ∧ a = ifte (f k) b c ∧ hom_graph f (S - {k}) y b ∧ hom_graph f (S - {k}) z c" proof (induct set: hom_graph) (*goals: 1. ‹(k::'a) ∈ {} ⟹ ∃(y::'a formula) (z::'a formula) (b::'b) c::'b. ⊥ = ifte (var k) y z ∧ ⊥ = ifte ((f::'a ⇒ 'b) k) b c ∧ hom_graph f ({} - {k}) y b ∧ hom_graph f ({} - {k}) z c› 2. ‹(k::'a) ∈ {} ⟹ ∃(y::'a formula) (z::'a formula) (b::'b) c::'b. ⊤ = ifte (var k) y z ∧ ⊤ = ifte ((f::'a ⇒ 'b) k) b c ∧ hom_graph f ({} - {k}) y b ∧ hom_graph f ({} - {k}) z c› 3. ‹⋀(i::'a) (S::'a set) (x::'a formula) (a::'b) (y::'a formula) b::'b. ⟦i ∉ S; hom_graph (f::'a ⇒ 'b) S x a; (k::'a) ∈ S ⟹ ∃(y::'a formula) (z::'a formula) (b::'b) c::'b. x = ifte (var k) y z ∧ a = ifte (f k) b c ∧ hom_graph f (S - {k}) y b ∧ hom_graph f (S - {k}) z c; hom_graph f S y b; k ∈ S ⟹ ∃(ya::'a formula) (z::'a formula) (ba::'b) c::'b. y = ifte (var k) ya z ∧ b = ifte (f k) ba c ∧ hom_graph f (S - {k}) ya ba ∧ hom_graph f (S - {k}) z c; k ∈ insert i S⟧ ⟹ ∃(ya::'a formula) (z::'a formula) (ba::'b) c::'b. ifte (var i) x y = ifte (var k) ya z ∧ ifte (f i) a b = ifte (f k) ba c ∧ hom_graph f (insert i S - {k}) ya ba ∧ hom_graph f (insert i S - {k}) z c›*) case (ifte i S x a y b) (*‹i ∉ S› ‹hom_graph (f::'a::type ⇒ 'b::boolean_algebra) (S::'a::type set) (x::'a::type formula) (a::'b::boolean_algebra)› ‹k ∈ S ⟹ ∃y z b c. x = ifte (var k) y z ∧ a = ifte (f k) b c ∧ hom_graph f (S - {k}) y b ∧ hom_graph f (S - {k}) z c› ‹hom_graph f S y b› ‹k ∈ S ⟹ ∃ya z ba c. y = ifte (var k) ya z ∧ b = ifte (f k) ba c ∧ hom_graph f (S - {k}) ya ba ∧ hom_graph f (S - {k}) z c› ‹(k::'a) ∈ insert (i::'a) (S::'a set)›*) show "?case" (*goal: ‹∃ya z ba c. ifte (var i) x y = ifte (var k) ya z ∧ ifte (f i) a b = ifte (f k) ba c ∧ hom_graph f (insert i S - {k}) ya ba ∧ hom_graph f (insert i S - {k}) z c›*) proof (cases "i = k") (*goals: 1. ‹i = k ⟹ ∃ya z ba c. ifte (var i) x y = ifte (var k) ya z ∧ ifte (f i) a b = ifte (f k) ba c ∧ hom_graph f (insert i S - {k}) ya ba ∧ hom_graph f (insert i S - {k}) z c› 2. ‹i ≠ k ⟹ ∃ya z ba c. ifte (var i) x y = ifte (var k) ya z ∧ ifte (f i) a b = ifte (f k) ba c ∧ hom_graph f (insert i S - {k}) ya ba ∧ hom_graph f (insert i S - {k}) z c›*) assume "i = k" (*‹(i::'a) = (k::'a)›*) with ifte(1,2,4) (*‹i ∉ S› ‹hom_graph f S x a› ‹hom_graph f S y b›*) show "?case" (*goal: ‹∃ya z ba c. ifte (var i) x y = ifte (var k) ya z ∧ ifte (f i) a b = ifte (f k) ba c ∧ hom_graph f (insert i S - {k}) ya ba ∧ hom_graph f (insert i S - {k}) z c›*) by auto next (*goal: ‹i ≠ k ⟹ ∃ya z ba c. ifte (var i) x y = ifte (var k) ya z ∧ ifte (f i) a b = ifte (f k) ba c ∧ hom_graph f (insert i S - {k}) ya ba ∧ hom_graph f (insert i S - {k}) z c›*) assume "i ≠ k" (*‹(i::'a) ≠ (k::'a)›*) with ‹k ∈ insert i S› (*‹k ∈ insert i S›*) have k: "k ∈ S" by simp have "*": "insert i S - {k} = insert i (S - {k})" using ‹i ≠ k› (*‹i ≠ k›*) by (simp add: insert_Diff_if (*‹insert (?x::?'a) (?A::?'a set) - (?B::?'a set) = (if ?x ∈ ?B then ?A - ?B else insert ?x (?A - ?B))›*)) have "**": "i ∉ S - {k}" using ‹i ∉ S› (*‹i ∉ S›*) by simp from ifte(1) (*‹i ∉ S›*) ifte(3)[OF k] (*‹∃y z b c. x = ifte (var k) y z ∧ a = ifte (f k) b c ∧ hom_graph f (S - {k}) y b ∧ hom_graph f (S - {k}) z c›*) ifte(5)[OF k] (*‹∃ya z ba c. y = ifte (var k) ya z ∧ b = ifte (f k) ba c ∧ hom_graph f (S - {k}) ya ba ∧ hom_graph f (S - {k}) z c›*) show "?case" (*goal: ‹∃ya z ba c. ifte (var i) x y = ifte (var k) ya z ∧ ifte (f i) a b = ifte (f k) ba c ∧ hom_graph f (insert i S - {k}) ya ba ∧ hom_graph f (insert i S - {k}) z c›*) unfolding "*" (*goal: ‹∃(ya::'a formula) (z::'a formula) (ba::'b) c::'b. ifte (var (i::'a)) (x::'a formula) (y::'a formula) = ifte (var (k::'a)) ya z ∧ ifte ((f::'a ⇒ 'b) i) (a::'b) (b::'b) = ifte (f k) ba c ∧ hom_graph f (insert i ((S::'a set) - {k})) ya ba ∧ hom_graph f (insert i (S - {k})) z c›*) apply clarify (*goal: ‹∃ya z ba c. ifte (var i) x y = ifte (var k) ya z ∧ ifte (f i) a b = ifte (f k) ba c ∧ hom_graph f (insert i (S - {k})) ya ba ∧ hom_graph f (insert i (S - {k})) z c›*) apply (simp only: ifte_ifte_distrib [of "var i"] (*‹ifte (var (i::'a::type)) (ifte (?y::'a::type formula) (?a::'a::type formula) (?b::'a::type formula)) (ifte ?y (?c::'a::type formula) (?d::'a::type formula)) = ifte ?y (ifte (var i) ?a ?c) (ifte (var i) ?b ?d)›*)) (*goal: ‹⋀ya yaa z za ba baa c ca. ⟦i ∉ S; x = ifte (var k) ya z; y = ifte (var k) yaa za; a = ifte (f k) ba c; b = ifte (f k) baa ca; hom_graph f (S - {k}) ya ba; hom_graph f (S - {k}) z c; hom_graph f (S - {k}) yaa baa; hom_graph f (S - {k}) za ca⟧ ⟹ ∃y zb b cb. ifte (var i) (ifte (var k) ya z) (ifte (var k) yaa za) = ifte (var k) y zb ∧ ifte (f i) (ifte (f k) ba c) (ifte (f k) baa ca) = ifte (f k) b cb ∧ hom_graph f (insert i (S - {k})) y b ∧ hom_graph f (insert i (S - {k})) zb cb›*) apply (simp only: ifte_ifte_distrib [of "f i"] (*‹ifte (f i) (ifte ?y ?a ?b) (ifte ?y ?c ?d) = ifte ?y (ifte (f i) ?a ?c) (ifte (f i) ?b ?d)›*)) (*goal: ‹⋀ya yaa z za ba baa c ca. ⟦i ∉ S; x = ifte (var k) ya z; y = ifte (var k) yaa za; a = ifte (f k) ba c; b = ifte (f k) baa ca; hom_graph f (S - {k}) ya ba; hom_graph f (S - {k}) z c; hom_graph f (S - {k}) yaa baa; hom_graph f (S - {k}) za ca⟧ ⟹ ∃y zb b cb. ifte (var k) (ifte (var i) ya yaa) (ifte (var i) z za) = ifte (var k) y zb ∧ ifte (f i) (ifte (f k) ba c) (ifte (f k) baa ca) = ifte (f k) b cb ∧ hom_graph f (insert i (S - {k})) y b ∧ hom_graph f (insert i (S - {k})) zb cb›*) by (fast intro: hom_graph.ifte [OF **] (*‹⟦hom_graph ?f (S - {k}) ?x ?a; hom_graph ?f (S - {k}) ?y ?b⟧ ⟹ hom_graph ?f (insert i (S - {k})) (ifte (var i) ?x ?y) (ifte (?f i) ?a ?b)›*)) qed qed (simp_all) (*solves the remaining goals: 1. ‹k ∈ {} ⟹ ∃y z b c. ⊥ = ifte (var k) y z ∧ ⊥ = ifte (f k) b c ∧ hom_graph f ({} - {k}) y b ∧ hom_graph f ({} - {k}) z c› 2. ‹k ∈ {} ⟹ ∃y z b c. ⊤ = ifte (var k) y z ∧ ⊤ = ifte (f k) b c ∧ hom_graph f ({} - {k}) y b ∧ hom_graph f ({} - {k}) z c›*) lemma hom_graph_insert_elim: assumes "hom_graph f (insert i S) x a" and "i ∉ S" obtains y z b c where "x = ifte (var i) y z" and "a = ifte (f i) b c" and "hom_graph f S y b" and "hom_graph f S z c" using hom_graph_dest[OF assms ( 1 ) insertI1] (*‹∃y z b c. x = ifte (var i) y z ∧ a = ifte (f i) b c ∧ hom_graph f (insert i S - {i}) y b ∧ hom_graph f (insert i S - {i}) z c›*) apply clarify (*goal: ‹(⋀(y::'a::type formula) (z::'a::type formula) (b::'b::boolean_algebra) c::'b::boolean_algebra. ⟦(x::'a::type formula) = ifte (var (i::'a::type)) y z; (a::'b::boolean_algebra) = ifte ((f::'a::type ⇒ 'b::boolean_algebra) i) b c; hom_graph f (S::'a::type set) y b; hom_graph f S z c⟧ ⟹ thesis::bool) ⟹ thesis›*) by (simp add: assms( (*‹(i::'a) ∉ (S::'a set)›*) 2)) text ‹ \medskip Now we prove the first uniqueness property of the @{const hom_graph} relation. This version of uniqueness says that for any particular value of ‹S›, the relation @{term "hom_graph f S"} maps each ‹x› to at most one ‹a›. The proof uses the injectiveness of if-then-else, which we proved earlier. › lemma hom_graph_imp_formulas: "hom_graph f S x a ⟹ x ∈ formulas S" apply (induct set: hom_graph) (*goals: 1. ‹⊥ ∈ formulas {}› 2. ‹⊤ ∈ formulas {}› 3. ‹⋀i S x a y b. ⟦i ∉ S; hom_graph f S x a; x ∈ formulas S; hom_graph f S y b; y ∈ formulas S⟧ ⟹ ifte (var i) x y ∈ formulas (insert i S)› discuss goal 1*) apply (simp add: formulas_intros (*‹?i ∈ ?S ⟹ var ?i ∈ formulas ?S› ‹⊥ ∈ formulas ?S› ‹⊤ ∈ formulas ?S› ‹?x ∈ formulas ?S ⟹ - ?x ∈ formulas ?S› ‹⟦?x ∈ formulas ?S; ?y ∈ formulas ?S⟧ ⟹ ?x ⊓ ?y ∈ formulas ?S› ‹⟦?x ∈ formulas ?S; ?y ∈ formulas ?S⟧ ⟹ ?x ⊔ ?y ∈ formulas ?S› ‹⟦?x ∈ formulas ?S; ?y ∈ formulas ?S⟧ ⟹ ?x - ?y ∈ formulas ?S› ‹⟦?a ∈ formulas ?S; ?x ∈ formulas ?S; ?y ∈ formulas ?S⟧ ⟹ ifte ?a ?x ?y ∈ formulas ?S›*) formulas_insert (*‹?x ∈ formulas ?S ⟹ ?x ∈ formulas (insert ?a ?S)›*)) (*discuss goal 2*) apply (simp add: formulas_intros (*‹?i ∈ ?S ⟹ var ?i ∈ formulas ?S› ‹⊥ ∈ formulas ?S› ‹⊤ ∈ formulas ?S› ‹?x ∈ formulas ?S ⟹ - ?x ∈ formulas ?S› ‹⟦?x ∈ formulas ?S; ?y ∈ formulas ?S⟧ ⟹ ?x ⊓ ?y ∈ formulas ?S› ‹⟦?x ∈ formulas ?S; ?y ∈ formulas ?S⟧ ⟹ ?x ⊔ ?y ∈ formulas ?S› ‹⟦?x ∈ formulas ?S; ?y ∈ formulas ?S⟧ ⟹ ?x - ?y ∈ formulas ?S› ‹⟦?a ∈ formulas ?S; ?x ∈ formulas ?S; ?y ∈ formulas ?S⟧ ⟹ ifte ?a ?x ?y ∈ formulas ?S›*) formulas_insert (*‹?x ∈ formulas ?S ⟹ ?x ∈ formulas (insert ?a ?S)›*)) (*discuss goal 3*) apply (simp add: formulas_intros (*‹?i ∈ ?S ⟹ var ?i ∈ formulas ?S› ‹⊥ ∈ formulas ?S› ‹⊤ ∈ formulas ?S› ‹?x ∈ formulas ?S ⟹ - ?x ∈ formulas ?S› ‹⟦?x ∈ formulas ?S; ?y ∈ formulas ?S⟧ ⟹ ?x ⊓ ?y ∈ formulas ?S› ‹⟦?x ∈ formulas ?S; ?y ∈ formulas ?S⟧ ⟹ ?x ⊔ ?y ∈ formulas ?S› ‹⟦?x ∈ formulas ?S; ?y ∈ formulas ?S⟧ ⟹ ?x - ?y ∈ formulas ?S› ‹⟦?a ∈ formulas ?S; ?x ∈ formulas ?S; ?y ∈ formulas ?S⟧ ⟹ ifte ?a ?x ?y ∈ formulas ?S›*) formulas_insert (*‹?x ∈ formulas ?S ⟹ ?x ∈ formulas (insert ?a ?S)›*)) (*proven 3 subgoals*) . lemma hom_graph_unique: "hom_graph f S x a ⟹ hom_graph f S x a' ⟹ a = a'" proof (induct arbitrary: a' set: hom_graph) (*goals: 1. ‹⋀a'::'b. hom_graph (f::'a ⇒ 'b) {} ⊥ a' ⟹ ⊥ = a'› 2. ‹⋀a'::'b. hom_graph (f::'a ⇒ 'b) {} ⊤ a' ⟹ ⊤ = a'› 3. ‹⋀(i::'a) (S::'a set) (x::'a formula) (a::'b) (y::'a formula) (b::'b) a'::'b. ⟦i ∉ S; hom_graph (f::'a ⇒ 'b) S x a; ⋀a'::'b. hom_graph f S x a' ⟹ a = a'; hom_graph f S y b; ⋀a'::'b. hom_graph f S y a' ⟹ b = a'; hom_graph f (insert i S) (ifte (var i) x y) a'⟧ ⟹ ifte (f i) a b = a'›*) case (ifte i S y b z c a') (*‹i ∉ S› ‹hom_graph f S y b› ‹hom_graph f S y ?a' ⟹ b = ?a'› ‹hom_graph f S z c› ‹hom_graph f S z ?a' ⟹ c = ?a'› ‹hom_graph f (insert i S) (ifte (var i) y z) a'›*) from ifte(6,1) (*‹hom_graph f (insert i S) (ifte (var i) y z) a'› ‹i ∉ S›*) obtain y' and z' and b' and c' where 1: "ifte (var i) y z = ifte (var i) y' z'" and 2: "a' = ifte (f i) b' c'" and 3: "hom_graph f S y' b'" and 4: "hom_graph f S z' c'" (*goal: ‹(⋀y' z' b' c'. ⟦ifte (var i) y z = ifte (var i) y' z'; a' = ifte (f i) b' c'; hom_graph f S y' b'; hom_graph f S z' c'⟧ ⟹ thesis) ⟹ thesis›*) by (rule hom_graph_insert_elim (*‹⟦hom_graph ?f (insert ?i ?S) ?x ?a; ?i ∉ ?S; ⋀y z b c. ⟦?x = ifte (var ?i) y z; ?a = ifte (?f ?i) b c; hom_graph ?f ?S y b; hom_graph ?f ?S z c⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*)) from "1" (*‹ifte (var i) y z = ifte (var i) y' z'›*) "3" (*‹hom_graph f S y' b'›*) "4" (*‹hom_graph f S z' c'›*) ifte(1,2,4) (*‹i ∉ S› ‹hom_graph f S y b› ‹hom_graph f S z c›*) have "y = y' ∧ z = z'" apply (intro ifte_inject (*‹⟦ifte (var ?i) ?x ?y = ifte (var ?i) ?x' ?y'; ?i ∉ ?S; ?x ∈ formulas ?S; ?x' ∈ formulas ?S; ?y ∈ formulas ?S; ?y' ∈ formulas ?S⟧ ⟹ ?x = ?x' ∧ ?y = ?y'›*) hom_graph_imp_formulas (*‹hom_graph ?f ?S ?x ?a ⟹ ?x ∈ formulas ?S›*)) (*goals: 1. ‹⟦ifte (var i) y z = ifte (var i) y' z'; hom_graph f S y' b'; hom_graph f S z' c'; i ∉ S; hom_graph f S y b; hom_graph f S z c⟧ ⟹ ifte (var ?i6) y z = ifte (var ?i6) y' z'› 2. ‹⟦ifte (var i) y z = ifte (var i) y' z'; hom_graph f S y' b'; hom_graph f S z' c'; i ∉ S; hom_graph f S y b; hom_graph f S z c⟧ ⟹ ?i6 ∉ ?S6› 3. ‹⟦ifte (var i) y z = ifte (var i) y' z'; hom_graph f S y' b'; hom_graph f S z' c'; i ∉ S; hom_graph f S y b; hom_graph f S z c⟧ ⟹ hom_graph ?f10 ?S6 y ?a10› 4. ‹⟦ifte (var i) y z = ifte (var i) y' z'; hom_graph f S y' b'; hom_graph f S z' c'; i ∉ S; hom_graph f S y b; hom_graph f S z c⟧ ⟹ hom_graph ?f9 ?S6 y' ?a9› 5. ‹⟦ifte (var i) y z = ifte (var i) y' z'; hom_graph f S y' b'; hom_graph f S z' c'; i ∉ S; hom_graph f S y b; hom_graph f S z c⟧ ⟹ hom_graph ?f8 ?S6 z ?a8› 6. ‹⟦ifte (var i) y z = ifte (var i) y' z'; hom_graph f S y' b'; hom_graph f S z' c'; i ∉ S; hom_graph f S y b; hom_graph f S z c⟧ ⟹ hom_graph ?f7 ?S6 z' ?a7› 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*) with "2" (*‹a' = ifte (f i) b' c'›*) "3" (*‹hom_graph f S y' b'›*) "4" (*‹hom_graph f S z' c'›*) ifte(3,5) (*‹hom_graph f S y ?a' ⟹ b = ?a'› ‹hom_graph f S z ?a' ⟹ c = ?a'›*) show "ifte (f i) b c = a'" by simp qed ((erule hom_graph.cases (*‹⟦hom_graph ?f ?a1.0 ?a2.0 ?a3.0; ⟦?a1.0 = {}; ?a2.0 = ⊥; ?a3.0 = ⊥⟧ ⟹ ?P; ⟦?a1.0 = {}; ?a2.0 = ⊤; ?a3.0 = ⊤⟧ ⟹ ?P; ⋀i S x a y b. ⟦?a1.0 = insert i S; ?a2.0 = ifte (var i) x y; ?a3.0 = ifte (?f i) a b; i ∉ S; hom_graph ?f S x a; hom_graph ?f S y b⟧ ⟹ ?P⟧ ⟹ ?P›*), simp_all)+) (*solves the remaining goals: 1. ‹⋀a'. hom_graph f {} ⊥ a' ⟹ ⊥ = a'› 2. ‹⋀a'. hom_graph f {} ⊤ a' ⟹ ⊤ = a'›*) text ‹ \medskip The next few lemmas will help to establish a stronger version of the uniqueness property of @{const hom_graph}. They show that the @{const hom_graph} relation is preserved if we replace ‹S› with a larger finite set. › lemma hom_graph_insert: assumes "hom_graph f S x a" shows "hom_graph f (insert i S) x a" proof (cases "i ∈ S") (*goals: 1. ‹i ∈ S ⟹ hom_graph f (insert i S) x a› 2. ‹i ∉ S ⟹ hom_graph f (insert i S) x a›*) assume "i ∈ S" (*‹(i::'a) ∈ (S::'a set)›*) with assms (*‹hom_graph (f::'a::type ⇒ 'b::boolean_algebra) (S::'a::type set) (x::'a::type formula) (a::'b::boolean_algebra)›*) show "?thesis" (*goal: ‹hom_graph f (insert i S) x a›*) by (simp add: insert_absorb (*‹?a ∈ ?A ⟹ insert ?a ?A = ?A›*)) next (*goal: ‹(i::'a) ∉ (S::'a set) ⟹ hom_graph (f::'a ⇒ 'b) (insert i S) (x::'a formula) (a::'b)›*) assume "i ∉ S" (*‹(i::'a) ∉ (S::'a set)›*) hence "hom_graph f (insert i S) (ifte (var i) x x) (ifte (f i) a a)" by (intro hom_graph.ifte (*‹⟦?i ∉ ?S; hom_graph ?f ?S ?x ?a; hom_graph ?f ?S ?y ?b⟧ ⟹ hom_graph ?f (insert ?i ?S) (ifte (var ?i) ?x ?y) (ifte (?f ?i) ?a ?b)›*) assms (*‹hom_graph f S x a›*)) thus "hom_graph f (insert i S) x a" by (simp only: ifte_same (*‹ifte ?a ?x ?x = ?x›*)) qed lemma hom_graph_finite_superset: assumes "hom_graph f S x a" and "finite T" and "S ⊆ T" shows "hom_graph f T x a" proof (-) (*goal: ‹hom_graph f T x a›*) from ‹finite T› (*‹finite (T::'a set)›*) have "hom_graph f (S ∪ T) x a" apply (induct set: finite) (*goals: 1. ‹hom_graph (f::'a::type ⇒ 'b::boolean_algebra) ((S::'a::type set) ∪ {}) (x::'a::type formula) (a::'b::boolean_algebra)› 2. ‹⋀(xa::'a::type) F::'a::type set. ⟦finite F; xa ∉ F; hom_graph (f::'a::type ⇒ 'b::boolean_algebra) ((S::'a::type set) ∪ F) (x::'a::type formula) (a::'b::boolean_algebra)⟧ ⟹ hom_graph f (S ∪ insert xa F) x a› discuss goal 1*) apply (simp add: assms (*‹hom_graph f S x a› ‹finite T› ‹S ⊆ T›*)) (*discuss goal 2*) apply (simp add: hom_graph_insert (*‹hom_graph ?f ?S ?x ?a ⟹ hom_graph ?f (insert ?i ?S) ?x ?a›*)) (*proven 2 subgoals*) . with ‹S ⊆ T› (*‹S ⊆ T›*) show "hom_graph f T x a" by (simp only: subset_Un_eq (*‹(?A ⊆ ?B) = (?A ∪ ?B = ?B)›*)) qed lemma hom_graph_imp_finite: "hom_graph f S x a ⟹ finite S" apply (induct set: hom_graph) (*goals: 1. ‹finite {}› 2. ‹finite {}› 3. ‹⋀(i::'a) (S::'a set) (x::'a formula) (a::'b) (y::'a formula) b::'b. ⟦i ∉ S; hom_graph (f::'a ⇒ 'b) S x a; finite S; hom_graph f S y b; finite S⟧ ⟹ finite (insert i S)› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*discuss goal 3*) apply simp (*proven 3 subgoals*) . text ‹ \medskip This stronger uniqueness property says that @{term "hom_graph f"} maps each ‹x› to at most one ‹a›, even for \emph{different} values of the set parameter. › lemma hom_graph_unique': assumes "hom_graph f S x a" and "hom_graph f T x a'" shows "a = a'" proof (rule hom_graph_unique (*‹⟦hom_graph (?f::?'a ⇒ ?'b) (?S::?'a set) (?x::?'a formula) (?a::?'b); hom_graph ?f ?S ?x (?a'::?'b)⟧ ⟹ ?a = ?a'›*)) (*goals: 1. ‹hom_graph ?f ?S ?x a› 2. ‹hom_graph ?f ?S ?x a'›*) have fin: "finite (S ∪ T)" using assms (*‹hom_graph (f::'a ⇒ 'b) (S::'a set) (x::'a formula) (a::'b)› ‹hom_graph f T x a'›*) apply (intro finite_UnI (*‹⟦finite ?F; finite ?G⟧ ⟹ finite (?F ∪ ?G)›*) hom_graph_imp_finite (*‹hom_graph ?f ?S ?x ?a ⟹ finite ?S›*)) (*goals: 1. ‹⟦hom_graph f S x a; hom_graph f T x a'⟧ ⟹ hom_graph ?f4 S ?x4 ?a4› 2. ‹⟦hom_graph f S x a; hom_graph f T x a'⟧ ⟹ hom_graph ?f3 T ?x3 ?a3› discuss goal 1*) apply ((assumption)[1]) (*discuss goal 2*) . (*proven 2 subgoals*) show "hom_graph f (S ∪ T) x a" using assms(1) (*‹hom_graph (f::'a ⇒ 'b) (S::'a set) (x::'a formula) (a::'b)›*) fin (*‹finite (S ∪ T)›*) Un_upper1 (*‹?A ⊆ ?A ∪ ?B›*) by (rule hom_graph_finite_superset (*‹⟦hom_graph ?f ?S ?x ?a; finite ?T; ?S ⊆ ?T⟧ ⟹ hom_graph ?f ?T ?x ?a›*)) show "hom_graph f (S ∪ T) x a'" using assms(2) (*‹hom_graph f T x a'›*) fin (*‹finite (S ∪ T)›*) Un_upper2 (*‹?B ⊆ ?A ∪ ?B›*) by (rule hom_graph_finite_superset (*‹⟦hom_graph ?f ?S ?x ?a; finite ?T; ?S ⊆ ?T⟧ ⟹ hom_graph ?f ?T ?x ?a›*)) qed text ‹ \medskip Finally, these last few lemmas establish that the @{term "hom_graph f"} relation is total: every ‹x› is mapped to some ‹a›. › lemma hom_graph_var: "hom_graph f {i} (var i) (f i)" proof (-) (*goal: ‹hom_graph (f::'a ⇒ 'b) {i::'a} (var i) (f i)›*) have "hom_graph f {i} (ifte (var i) top bot) (ifte (f i) top bot)" by (simp add: hom_graph.intros (*‹hom_graph (?f::?'a ⇒ ?'b) {} ⊥ ⊥› ‹hom_graph (?f::?'a ⇒ ?'b) {} ⊤ ⊤› ‹⟦(?i::?'a) ∉ (?S::?'a set); hom_graph (?f::?'a ⇒ ?'b) ?S (?x::?'a formula) (?a::?'b); hom_graph ?f ?S (?y::?'a formula) (?b::?'b)⟧ ⟹ hom_graph ?f (insert ?i ?S) (ifte (var ?i) ?x ?y) (ifte (?f ?i) ?a ?b)›*)) thus "hom_graph f {i} (var i) (f i)" unfolding ifte_def (*goal: ‹hom_graph f {i} (var i) (f i)›*) by simp qed lemma hom_graph_compl: "hom_graph f S x a ⟹ hom_graph f S (- x) (- a)" apply (induct set: hom_graph) (*goals: 1. ‹hom_graph f {} (- ⊥) (- ⊥)› 2. ‹hom_graph f {} (- ⊤) (- ⊤)› 3. ‹⋀i S x a y b. ⟦i ∉ S; hom_graph f S x a; hom_graph f S (- x) (- a); hom_graph f S y b; hom_graph f S (- y) (- b)⟧ ⟹ hom_graph f (insert i S) (- ifte (var i) x y) (- ifte (f i) a b)› discuss goal 1*) apply (simp add: hom_graph.intros (*‹hom_graph (?f::?'a ⇒ ?'b) {} ⊥ ⊥› ‹hom_graph (?f::?'a ⇒ ?'b) {} ⊤ ⊤› ‹⟦(?i::?'a) ∉ (?S::?'a set); hom_graph (?f::?'a ⇒ ?'b) ?S (?x::?'a formula) (?a::?'b); hom_graph ?f ?S (?y::?'a formula) (?b::?'b)⟧ ⟹ hom_graph ?f (insert ?i ?S) (ifte (var ?i) ?x ?y) (ifte (?f ?i) ?a ?b)›*) compl_ifte (*‹- ifte (?a::?'a) (?x::?'a) (?y::?'a) = ifte ?a (- ?x) (- ?y)›*)) (*discuss goal 2*) apply (simp add: hom_graph.intros (*‹hom_graph ?f {} ⊥ ⊥› ‹hom_graph ?f {} ⊤ ⊤› ‹⟦?i ∉ ?S; hom_graph ?f ?S ?x ?a; hom_graph ?f ?S ?y ?b⟧ ⟹ hom_graph ?f (insert ?i ?S) (ifte (var ?i) ?x ?y) (ifte (?f ?i) ?a ?b)›*) compl_ifte (*‹- ifte ?a ?x ?y = ifte ?a (- ?x) (- ?y)›*)) (*discuss goal 3*) apply (simp add: hom_graph.intros (*‹hom_graph ?f {} ⊥ ⊥› ‹hom_graph ?f {} ⊤ ⊤› ‹⟦?i ∉ ?S; hom_graph ?f ?S ?x ?a; hom_graph ?f ?S ?y ?b⟧ ⟹ hom_graph ?f (insert ?i ?S) (ifte (var ?i) ?x ?y) (ifte (?f ?i) ?a ?b)›*) compl_ifte (*‹- ifte ?a ?x ?y = ifte ?a (- ?x) (- ?y)›*)) (*proven 3 subgoals*) . lemma hom_graph_inf: "hom_graph f S x a ⟹ hom_graph f S y b ⟹ hom_graph f S (x ⊓ y) (a ⊓ b)" apply (induct arbitrary: y b set: hom_graph) (*goals: 1. ‹⋀y b. hom_graph f {} y b ⟹ hom_graph f {} (⊥ ⊓ y) (⊥ ⊓ b)› 2. ‹⋀y b. hom_graph f {} y b ⟹ hom_graph f {} (⊤ ⊓ y) (⊤ ⊓ b)› 3. ‹⋀i S x a y b ya ba. ⟦i ∉ S; hom_graph f S x a; ⋀y b. hom_graph f S y b ⟹ hom_graph f S (x ⊓ y) (a ⊓ b); hom_graph f S y b; ⋀ya ba. hom_graph f S ya ba ⟹ hom_graph f S (y ⊓ ya) (b ⊓ ba); hom_graph f (insert i S) ya ba⟧ ⟹ hom_graph f (insert i S) (ifte (var i) x y ⊓ ya) (ifte (f i) a b ⊓ ba)› discuss goal 1*) apply (simp add: hom_graph.bot (*‹hom_graph ?f {} ⊥ ⊥›*)) (*discuss goal 2*) apply simp (*discuss goal 3*) apply (erule (1) hom_graph_insert_elim (*‹⟦hom_graph ?f (insert ?i ?S) ?x ?a; ?i ∉ ?S; ⋀y z b c. ⟦?x = ifte (var ?i) y z; ?a = ifte (?f ?i) b c; hom_graph ?f ?S y b; hom_graph ?f ?S z c⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*)) (*goal: ‹⋀i S x a y b ya ba. ⟦i ∉ S; hom_graph f S x a; ⋀y b. hom_graph f S y b ⟹ hom_graph f S (x ⊓ y) (a ⊓ b); hom_graph f S y b; ⋀ya ba. hom_graph f S ya ba ⟹ hom_graph f S (y ⊓ ya) (b ⊓ ba); hom_graph f (insert i S) ya ba⟧ ⟹ hom_graph f (insert i S) (ifte (var i) x y ⊓ ya) (ifte (f i) a b ⊓ ba)›*) apply (auto simp add: inf_ifte_distrib (*‹ifte ?x ?a ?b ⊓ ifte ?x ?c ?d = ifte ?x (?a ⊓ ?c) (?b ⊓ ?d)›*) hom_graph.ifte (*‹⟦?i ∉ ?S; hom_graph ?f ?S ?x ?a; hom_graph ?f ?S ?y ?b⟧ ⟹ hom_graph ?f (insert ?i ?S) (ifte (var ?i) ?x ?y) (ifte (?f ?i) ?a ?b)›*)) (*proven 3 subgoals*) . lemma hom_graph_union_inf: assumes "hom_graph f S x a" and "hom_graph f T y b" shows "hom_graph f (S ∪ T) (x ⊓ y) (a ⊓ b)" proof (rule hom_graph_inf (*‹⟦hom_graph ?f ?S ?x ?a; hom_graph ?f ?S ?y ?b⟧ ⟹ hom_graph ?f ?S (?x ⊓ ?y) (?a ⊓ ?b)›*)) (*goals: 1. ‹hom_graph f (S ∪ T) x a› 2. ‹hom_graph f (S ∪ T) y b›*) have fin: "finite (S ∪ T)" using assms (*‹hom_graph (f::'a ⇒ 'b) (S::'a set) (x::'a formula) (a::'b)› ‹hom_graph f T y b›*) apply (intro finite_UnI (*‹⟦finite ?F; finite ?G⟧ ⟹ finite (?F ∪ ?G)›*) hom_graph_imp_finite (*‹hom_graph ?f ?S ?x ?a ⟹ finite ?S›*)) (*goals: 1. ‹⟦hom_graph f S x a; hom_graph f T y b⟧ ⟹ hom_graph ?f4 S ?x4 ?a4› 2. ‹⟦hom_graph f S x a; hom_graph f T y b⟧ ⟹ hom_graph ?f3 T ?x3 ?a3› discuss goal 1*) apply ((assumption)[1]) (*discuss goal 2*) . (*proven 2 subgoals*) show "hom_graph f (S ∪ T) x a" using assms(1) (*‹hom_graph f S x a›*) fin (*‹finite (S ∪ T)›*) Un_upper1 (*‹?A ⊆ ?A ∪ ?B›*) by (rule hom_graph_finite_superset (*‹⟦hom_graph ?f ?S ?x ?a; finite ?T; ?S ⊆ ?T⟧ ⟹ hom_graph ?f ?T ?x ?a›*)) show "hom_graph f (S ∪ T) y b" using assms(2) (*‹hom_graph (f::'a ⇒ 'b) (T::'a set) (y::'a formula) (b::'b)›*) fin (*‹finite (S ∪ T)›*) Un_upper2 (*‹?B ⊆ ?A ∪ ?B›*) by (rule hom_graph_finite_superset (*‹⟦hom_graph ?f ?S ?x ?a; finite ?T; ?S ⊆ ?T⟧ ⟹ hom_graph ?f ?T ?x ?a›*)) qed lemma hom_graph_exists: "∃a S. hom_graph f S x a" apply (induct x) (*goals: 1. ‹⋀i. ∃a S. hom_graph f S (var i) a› 2. ‹⋀x. ∃a S. hom_graph f S x a ⟹ ∃a S. hom_graph f S (- x) a› 3. ‹⋀x1 x2. ⟦∃a S. hom_graph f S x1 a; ∃a S. hom_graph f S x2 a⟧ ⟹ ∃a S. hom_graph f S (x1 ⊓ x2) a› discuss goal 1*) apply ((auto intro: hom_graph_var (*‹hom_graph (?f::?'a ⇒ ?'b) {?i::?'a} (var ?i) (?f ?i)›*) hom_graph_compl (*‹hom_graph (?f::?'a ⇒ ?'b) (?S::?'a set) (?x::?'a formula) (?a::?'b) ⟹ hom_graph ?f ?S (- ?x) (- ?a)›*) hom_graph_union_inf (*‹⟦hom_graph (?f::?'a ⇒ ?'b) (?S::?'a set) (?x::?'a formula) (?a::?'b); hom_graph ?f (?T::?'a set) (?y::?'a formula) (?b::?'b)⟧ ⟹ hom_graph ?f (?S ∪ ?T) (?x ⊓ ?y) (?a ⊓ ?b)›*))[1]) (*discuss goal 2*) apply ((auto intro: hom_graph_var (*‹hom_graph ?f {?i} (var ?i) (?f ?i)›*) hom_graph_compl (*‹hom_graph ?f ?S ?x ?a ⟹ hom_graph ?f ?S (- ?x) (- ?a)›*) hom_graph_union_inf (*‹⟦hom_graph ?f ?S ?x ?a; hom_graph ?f ?T ?y ?b⟧ ⟹ hom_graph ?f (?S ∪ ?T) (?x ⊓ ?y) (?a ⊓ ?b)›*))[1]) (*discuss goal 3*) apply ((auto intro: hom_graph_var (*‹hom_graph ?f {?i} (var ?i) (?f ?i)›*) hom_graph_compl (*‹hom_graph ?f ?S ?x ?a ⟹ hom_graph ?f ?S (- ?x) (- ?a)›*) hom_graph_union_inf (*‹⟦hom_graph ?f ?S ?x ?a; hom_graph ?f ?T ?y ?b⟧ ⟹ hom_graph ?f (?S ∪ ?T) (?x ⊓ ?y) (?a ⊓ ?b)›*))[1]) (*proven 3 subgoals*) . subsection ‹Homomorphisms into other boolean algebras› text ‹ Now that we have proved the necessary existence and uniqueness properties of @{const hom_graph}, we can define the function ‹hom› using definite choice. › definition hom :: "('a ⇒ 'b::boolean_algebra) ⇒ 'a formula ⇒ 'b" where "hom f x = (THE a. ∃S. hom_graph f S x a)" lemma hom_graph_hom: "∃S. hom_graph f S x (hom f x)" unfolding hom_def (*goal: ‹∃S. hom_graph f S x (THE a. ∃S. hom_graph f S x a)›*) apply (rule theI' (*‹∃!x. ?P x ⟹ ?P (THE x. ?P x)›*)) (*goal: ‹∃S. hom_graph f S x (THE a. ∃S. hom_graph f S x a)›*) apply (rule ex_ex1I (*‹⟦∃x. ?P x; ⋀x y. ⟦?P x; ?P y⟧ ⟹ x = y⟧ ⟹ ∃!x. ?P x›*)) (*goals: 1. ‹∃xa S. hom_graph f S x xa› 2. ‹⋀xa y. ⟦∃S. hom_graph f S x xa; ∃S. hom_graph f S x y⟧ ⟹ xa = y› discuss goal 1*) apply (rule hom_graph_exists (*‹∃a S. hom_graph ?f S ?x a›*)) (*discuss goal 2*) apply (fast elim: hom_graph_unique' (*‹⟦hom_graph (?f::?'a ⇒ ?'b) (?S::?'a set) (?x::?'a formula) (?a::?'b); hom_graph ?f (?T::?'a set) ?x (?a'::?'b)⟧ ⟹ ?a = ?a'›*)) (*proven 2 subgoals*) . lemma hom_equality: "hom_graph f S x a ⟹ hom f x = a" unfolding hom_def (*goal: ‹hom_graph f S x a ⟹ (THE a. ∃S. hom_graph f S x a) = a›*) apply (rule the_equality (*‹⟦(?P::?'a ⇒ bool) (?a::?'a); ⋀x::?'a. ?P x ⟹ x = ?a⟧ ⟹ (THE x::?'a. ?P x) = ?a›*)) (*goals: 1. ‹hom_graph (f::'a ⇒ 'b) (S::'a set) (x::'a formula) (a::'b) ⟹ ∃S::'a set. hom_graph f S x a› 2. ‹⋀aa::'b. ⟦hom_graph (f::'a ⇒ 'b) (S::'a set) (x::'a formula) (a::'b); ∃S::'a set. hom_graph f S x aa⟧ ⟹ aa = a› discuss goal 1*) apply (erule exI (*‹?P ?x ⟹ ∃x. ?P x›*)) (*discuss goal 2*) apply (erule exE (*‹⟦∃x::?'a::type. (?P::?'a::type ⇒ bool) x; ⋀x::?'a::type. ?P x ⟹ ?Q::bool⟧ ⟹ ?Q›*)) (*goal: ‹⋀aa. ⟦hom_graph f S x a; ∃S. hom_graph f S x aa⟧ ⟹ aa = a›*) apply (erule (1) hom_graph_unique' (*‹⟦hom_graph (?f::?'a::type ⇒ ?'b::boolean_algebra) (?S::?'a::type set) (?x::?'a::type formula) (?a::?'b::boolean_algebra); hom_graph ?f (?T::?'a::type set) ?x (?a'::?'b::boolean_algebra)⟧ ⟹ ?a = ?a'›*)) (*proven 2 subgoals*) . text ‹ \medskip The @{const hom} function correctly implements its specification: › lemma hom_var [simp]: "hom f (var i) = f i" apply (rule hom_equality (*‹hom_graph ?f ?S ?x ?a ⟹ hom ?f ?x = ?a›*)) (*goal: ‹hom f (var i) = f i›*) by (rule hom_graph_var (*‹hom_graph ?f {?i} (var ?i) (?f ?i)›*)) lemma hom_bot [simp]: "hom f ⊥ = ⊥" apply (rule hom_equality (*‹hom_graph ?f ?S ?x ?a ⟹ hom ?f ?x = ?a›*)) (*goal: ‹hom f ⊥ = ⊥›*) by (rule hom_graph.bot (*‹hom_graph (?f::?'a ⇒ ?'b) {} ⊥ ⊥›*)) lemma hom_top [simp]: "hom f ⊤ = ⊤" apply (rule hom_equality (*‹hom_graph ?f ?S ?x ?a ⟹ hom ?f ?x = ?a›*)) (*goal: ‹hom f ⊤ = ⊤›*) by (rule hom_graph.top (*‹hom_graph (?f::?'a ⇒ ?'b) {} ⊤ ⊤›*)) lemma hom_compl [simp]: "hom f (- x) = - hom f x" proof (-) (*goal: ‹hom f (- x) = - hom f x›*) obtain S where "hom_graph f S x (hom f x)" (*goal: ‹(⋀S. hom_graph f S x (hom f x) ⟹ thesis) ⟹ thesis›*) using hom_graph_hom (*‹∃S. hom_graph ?f S ?x (hom ?f ?x)›*) by standard hence "hom_graph f S (- x) (- hom f x)" by (rule hom_graph_compl (*‹hom_graph ?f ?S ?x ?a ⟹ hom_graph ?f ?S (- ?x) (- ?a)›*)) thus "hom f (- x) = - hom f x" by (rule hom_equality (*‹hom_graph (?f::?'a ⇒ ?'b) (?S::?'a set) (?x::?'a formula) (?a::?'b) ⟹ hom ?f ?x = ?a›*)) qed lemma hom_inf [simp]: "hom f (x ⊓ y) = hom f x ⊓ hom f y" proof (-) (*goal: ‹hom (f::'b ⇒ 'a) ((x::'b formula) ⊓ (y::'b formula)) = hom f x ⊓ hom f y›*) obtain S where S: "hom_graph f S x (hom f x)" (*goal: ‹(⋀S. hom_graph f S x (hom f x) ⟹ thesis) ⟹ thesis›*) using hom_graph_hom (*‹∃S. hom_graph ?f S ?x (hom ?f ?x)›*) by standard obtain T where T: "hom_graph f T y (hom f y)" (*goal: ‹(⋀T::'b::type set. hom_graph (f::'b::type ⇒ 'a::boolean_algebra) T (y::'b::type formula) (hom f y) ⟹ thesis::bool) ⟹ thesis›*) using hom_graph_hom (*‹∃S. hom_graph ?f S ?x (hom ?f ?x)›*) by standard have "hom_graph f (S ∪ T) (x ⊓ y) (hom f x ⊓ hom f y)" using S (*‹hom_graph f S x (hom f x)›*) T (*‹hom_graph f T y (hom f y)›*) by (rule hom_graph_union_inf (*‹⟦hom_graph ?f ?S ?x ?a; hom_graph ?f ?T ?y ?b⟧ ⟹ hom_graph ?f (?S ∪ ?T) (?x ⊓ ?y) (?a ⊓ ?b)›*)) thus "?thesis" (*goal: ‹hom f (x ⊓ y) = hom f x ⊓ hom f y›*) by (rule hom_equality (*‹hom_graph ?f ?S ?x ?a ⟹ hom ?f ?x = ?a›*)) qed lemma hom_sup [simp]: "hom f (x ⊔ y) = hom f x ⊔ hom f y" unfolding sup_conv_inf (*goal: ‹hom f (- (- x ⊓ - y)) = - (- hom f x ⊓ - hom f y)›*) by (simp only: hom_compl (*‹hom ?f (- ?x) = - hom ?f ?x›*) hom_inf (*‹hom ?f (?x ⊓ ?y) = hom ?f ?x ⊓ hom ?f ?y›*)) lemma hom_diff [simp]: "hom f (x - y) = hom f x - hom f y" unfolding diff_eq (*goal: ‹hom f (x ⊓ - y) = hom f x ⊓ - hom f y›*) by (simp only: hom_compl (*‹hom ?f (- ?x) = - hom ?f ?x›*) hom_inf (*‹hom ?f (?x ⊓ ?y) = hom ?f ?x ⊓ hom ?f ?y›*)) lemma hom_ifte [simp]: "hom f (ifte x y z) = ifte (hom f x) (hom f y) (hom f z)" unfolding ifte_def (*goal: ‹hom f (x ⊓ y ⊔ - x ⊓ z) = hom f x ⊓ hom f y ⊔ - hom f x ⊓ hom f z›*) by (simp only: hom_compl (*‹hom (?f::?'b ⇒ ?'a) (- (?x::?'b formula)) = - hom ?f ?x›*) hom_inf (*‹hom (?f::?'b ⇒ ?'a) ((?x::?'b formula) ⊓ (?y::?'b formula)) = hom ?f ?x ⊓ hom ?f ?y›*) hom_sup (*‹hom (?f::?'b ⇒ ?'a) ((?x::?'b formula) ⊔ (?y::?'b formula)) = hom ?f ?x ⊔ hom ?f ?y›*)) lemmas hom_simps = hom_var hom_bot hom_top hom_compl hom_inf hom_sup hom_diff hom_ifte text ‹ \medskip The type @{typ "'a formula"} can be viewed as a monad, with @{const var} as the unit, and @{const hom} as the bind operator. We can prove the standard monad laws with simple proofs by induction. › lemma hom_var_eq_id: "hom var x = x" apply (induct x) (*goals: 1. ‹⋀i. hom var (var i) = var i› 2. ‹⋀x. hom var x = x ⟹ hom var (- x) = - x› 3. ‹⋀x1 x2. ⟦hom var x1 = x1; hom var x2 = x2⟧ ⟹ hom var (x1 ⊓ x2) = x1 ⊓ x2› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*discuss goal 3*) apply simp (*proven 3 subgoals*) . lemma hom_hom: "hom f (hom g x) = hom (λi. hom f (g i)) x" apply (induct x) (*goals: 1. ‹⋀i. hom f (hom g (var i)) = hom (λi. hom f (g i)) (var i)› 2. ‹⋀x. hom f (hom g x) = hom (λi. hom f (g i)) x ⟹ hom f (hom g (- x)) = hom (λi. hom f (g i)) (- x)› 3. ‹⋀x1 x2. ⟦hom f (hom g x1) = hom (λi. hom f (g i)) x1; hom f (hom g x2) = hom (λi. hom f (g i)) x2⟧ ⟹ hom f (hom g (x1 ⊓ x2)) = hom (λi. hom f (g i)) (x1 ⊓ x2)› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*discuss goal 3*) apply simp (*proven 3 subgoals*) . subsection ‹Map operation on Boolean formulas› text ‹ We can define a map functional in terms of @{const hom} and @{const var}. The properties of ‹fmap› follow directly from the lemmas we have already proved about @{const hom}. › definition fmap :: "('a ⇒ 'b) ⇒ 'a formula ⇒ 'b formula" where "fmap f = hom (λi. var (f i))" lemma fmap_var [simp]: "fmap f (var i) = var (f i)" unfolding fmap_def (*goal: ‹hom (λi. var (f i)) (var i) = var (f i)›*) by simp lemma fmap_bot [simp]: "fmap f ⊥ = ⊥" unfolding fmap_def (*goal: ‹hom (λi::'b. var ((f::'b ⇒ 'a) i)) ⊥ = ⊥›*) by simp lemma fmap_top [simp]: "fmap f ⊤ = ⊤" unfolding fmap_def (*goal: ‹hom (λi. var (f i)) ⊤ = ⊤›*) by simp lemma fmap_compl [simp]: "fmap f (- x) = - fmap f x" unfolding fmap_def (*goal: ‹hom (λi. var (f i)) (- x) = - hom (λi. var (f i)) x›*) by simp lemma fmap_inf [simp]: "fmap f (x ⊓ y) = fmap f x ⊓ fmap f y" unfolding fmap_def (*goal: ‹hom (λi::'b. var ((f::'b ⇒ 'a) i)) ((x::'b formula) ⊓ (y::'b formula)) = hom (λi::'b. var (f i)) x ⊓ hom (λi::'b. var (f i)) y›*) by simp lemma fmap_sup [simp]: "fmap f (x ⊔ y) = fmap f x ⊔ fmap f y" unfolding fmap_def (*goal: ‹hom (λi::'b. var ((f::'b ⇒ 'a) i)) ((x::'b formula) ⊔ (y::'b formula)) = hom (λi::'b. var (f i)) x ⊔ hom (λi::'b. var (f i)) y›*) by simp lemma fmap_diff [simp]: "fmap f (x - y) = fmap f x - fmap f y" unfolding fmap_def (*goal: ‹hom (λi. var (f i)) (x - y) = hom (λi. var (f i)) x - hom (λi. var (f i)) y›*) by simp lemma fmap_ifte [simp]: "fmap f (ifte x y z) = ifte (fmap f x) (fmap f y) (fmap f z)" unfolding fmap_def (*goal: ‹hom (λi::'b::type. var ((f::'b::type ⇒ 'a::type) i)) (ifte (x::'b::type formula) (y::'b::type formula) (z::'b::type formula)) = ifte (hom (λi::'b::type. var (f i)) x) (hom (λi::'b::type. var (f i)) y) (hom (λi::'b::type. var (f i)) z)›*) by simp lemmas fmap_simps = fmap_var fmap_bot fmap_top fmap_compl fmap_inf fmap_sup fmap_diff fmap_ifte text ‹ \medskip The map functional satisfies the functor laws: it preserves identity and function composition. › lemma fmap_ident: "fmap (λi. i) x = x" apply (induct x) (*goals: 1. ‹⋀i. fmap (λi. i) (var i) = var i› 2. ‹⋀x. fmap (λi. i) x = x ⟹ fmap (λi. i) (- x) = - x› 3. ‹⋀x1 x2. ⟦fmap (λi. i) x1 = x1; fmap (λi. i) x2 = x2⟧ ⟹ fmap (λi. i) (x1 ⊓ x2) = x1 ⊓ x2› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*discuss goal 3*) apply simp (*proven 3 subgoals*) . lemma fmap_fmap: "fmap f (fmap g x) = fmap (f ∘ g) x" apply (induct x) (*goals: 1. ‹⋀i::'c::type. fmap (f::'b::type ⇒ 'a::type) (fmap (g::'c::type ⇒ 'b::type) (var i)) = fmap (f ∘ g) (var i)› 2. ‹⋀x::'c::type formula. fmap (f::'b::type ⇒ 'a::type) (fmap (g::'c::type ⇒ 'b::type) x) = fmap (f ∘ g) x ⟹ fmap f (fmap g (- x)) = fmap (f ∘ g) (- x)› 3. ‹⋀(x1::'c::type formula) x2::'c::type formula. ⟦fmap (f::'b::type ⇒ 'a::type) (fmap (g::'c::type ⇒ 'b::type) x1) = fmap (f ∘ g) x1; fmap f (fmap g x2) = fmap (f ∘ g) x2⟧ ⟹ fmap f (fmap g (x1 ⊓ x2)) = fmap (f ∘ g) (x1 ⊓ x2)› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*discuss goal 3*) apply simp (*proven 3 subgoals*) . subsection ‹Hiding lattice syntax› text ‹ The following command hides the lattice syntax, to avoid potential conflicts with other theories that import this one. To re-enable the syntax, users should unbundle ‹lattice_syntax›. › unbundle no_lattice_syntax end
{ "path": "afp-2025-02-12/thys/Free-Boolean-Algebra/Free_Boolean_Algebra.thy", "repo": "afp-2025-02-12", "sha": "33939ff3c52e54e39a25c82b3b9b586aac21cc458b98b1d1a996326c22a16566" }
(* Title: A Definitional Encoding of TLA in Isabelle/HOL Authors: Gudmund Grov <ggrov at inf.ed.ac.uk> Stephan Merz <Stephan.Merz at loria.fr> Year: 2011 Maintainer: Gudmund Grov <ggrov at inf.ed.ac.uk> *) section ‹Representing Intensional Logic› theory Intensional imports Main begin text‹ In higher-order logic, every proof rule has a corresponding tautology, i.e. the \emph{deduction theorem} holds. Isabelle/HOL implements this since object-level implication ($\longrightarrow$) and meta-level entailment ($\Longrightarrow$) commute, viz. the proof rule ‹impI:› @{thm impI}. However, the deduction theorem does not hold for most modal and temporal logics \<^cite>‹‹page 95› in "Lamport02"›\<^cite>‹"Merz98"›. For example $A \vdash \Box A$ holds, meaning that if $A$ holds in any world, then it always holds. However, $\vdash A \longrightarrow \Box A$, stating that $A$ always holds if it initially holds, is not valid. Merz \<^cite>‹"Merz98"› overcame this problem by creating an @{term Intensional} logic. It exploits Isabelle's axiomatic type class feature \<^cite>‹"Wenzel00b"› by creating a type class @{term world}, which provides Skolem constants to associate formulas with the world they hold in. The class is trivial, not requiring any axioms. › class world text ‹ @{term world} is a type class of possible worlds. It is a subclass of all HOL types @{term type}. No axioms are provided, since its only purpose is to avoid silly use of the @{term Intensional} syntax. › subsection‹Abstract Syntax and Definitions› type_synonym ('w,'a) expr = "'w ⇒ 'a" type_synonym 'w form = "('w, bool) expr" text ‹The intention is that @{typ 'a} will be used for unlifted types (class @{term type}), while @{typ 'w} is lifted (class @{term world}). › definition Valid :: "('w::world) form ⇒ bool" where "Valid A ≡ ∀w. A w" definition const :: "'a ⇒ ('w::world, 'a) expr" where unl_con: "const c w ≡ c" definition lift :: "['a ⇒ 'b, ('w::world, 'a) expr] ⇒ ('w,'b) expr" where unl_lift: "lift f x w ≡ f (x w)" definition lift2 :: "['a ⇒ 'b ⇒ 'c, ('w::world,'a) expr, ('w,'b) expr] ⇒ ('w,'c) expr" where unl_lift2: "lift2 f x y w ≡ f (x w) (y w)" definition lift3 :: "['a ⇒ 'b => 'c ⇒ 'd, ('w::world,'a) expr, ('w,'b) expr, ('w,'c) expr] ⇒ ('w,'d) expr" where unl_lift3: "lift3 f x y z w ≡ f (x w) (y w) (z w)" definition lift4 :: "['a ⇒ 'b => 'c ⇒ 'd ⇒ 'e, ('w::world,'a) expr, ('w,'b) expr, ('w,'c) expr,('w,'d) expr] ⇒ ('w,'e) expr" where unl_lift4: "lift4 f x y z zz w ≡ f (x w) (y w) (z w) (zz w)" text ‹ @{term "Valid F"} asserts that the lifted formula @{term F} holds everywhere. @{term const} allows lifting of a constant, while @{term lift} through @{term lift4} allow functions with arity 1--4 to be lifted. (Note that there is no way to define a generic lifting operator for functions of arbitrary arity.) › definition RAll :: "('a ⇒ ('w::world) form) ⇒ 'w form" (binder "Rall " 10) where unl_Rall: "(Rall x. A x) w ≡ ∀x. A x w" definition REx :: "('a ⇒ ('w::world) form) ⇒ 'w form" (binder "Rex " 10) where unl_Rex: "(Rex x. A x) w ≡ ∃x. A x w" definition REx1 :: "('a ⇒ ('w::world) form) ⇒ 'w form" (binder "Rex! " 10) where unl_Rex1: "(Rex! x. A x) w ≡ ∃!x. A x w" text ‹ @{term RAll}, @{term REx} and @{term REx1} introduces ``rigid'' quantification over values (of non-world types) within ``intensional'' formulas. @{term RAll} is universal quantification, @{term REx} is existential quantifcation. @{term REx1} requires unique existence. › text ‹ We declare the ``unlifting rules'' as rewrite rules that will be applied automatically. › lemmas intensional_rews[simp] = unl_con unl_lift unl_lift2 unl_lift3 unl_lift4 unl_Rall unl_Rex unl_Rex1 subsection‹Concrete Syntax› nonterminal lift and liftargs text‹ The non-terminal @{term lift} represents lifted expressions. The idea is to use Isabelle's macro mechanism to convert between the concrete and abstract syntax. › syntax "" :: "id ⇒ lift" ("_") "" :: "longid ⇒ lift" ("_") "" :: "var ⇒ lift" ("_") "_applC" :: "[lift, cargs] ⇒ lift" ("(1_/ _)" [1000, 1000] 999) "" :: "lift ⇒ lift" ("'(_')") "_lambda" :: "[idts, 'a] ⇒ lift" ("(3%_./ _)" [0, 3] 3) "_constrain" :: "[lift, type] ⇒ lift" ("(_::_)" [4, 0] 3) "" :: "lift ⇒ liftargs" ("_") "_liftargs" :: "[lift, liftargs] ⇒ liftargs" ("_,/ _") "_Valid" :: "lift ⇒ bool" ("(⊢ _)" 5) "_holdsAt" :: "['a, lift] ⇒ bool" ("(_ ⊨ _)" [100,10] 10) (* Syntax for lifted expressions outside the scope of ⊢ or ⊨.*) "LIFT" :: "lift ⇒ 'a" ("LIFT _") (* generic syntax for lifted constants and functions *) "_const" :: "'a ⇒ lift" ("(#_)" [1000] 999) "_lift" :: "['a, lift] ⇒ lift" ("(_<_>)" [1000] 999) "_lift2" :: "['a, lift, lift] ⇒ lift" ("(_<_,/ _>)" [1000] 999) "_lift3" :: "['a, lift, lift, lift] ⇒ lift" ("(_<_,/ _,/ _>)" [1000] 999) "_lift4" :: "['a, lift, lift, lift,lift] ⇒ lift" ("(_<_,/ _,/ _,/ _>)" [1000] 999) (* concrete syntax for common infix functions: reuse same symbol *) "_liftEqu" :: "[lift, lift] ⇒ lift" ("(_ =/ _)" [50,51] 50) "_liftNeq" :: "[lift, lift] ⇒ lift" (infixl "≠" 50) "_liftNot" :: "lift ⇒ lift" ("¬ _" [90] 90) "_liftAnd" :: "[lift, lift] ⇒ lift" (infixr "∧" 35) "_liftOr" :: "[lift, lift] ⇒ lift" (infixr "∨" 30) "_liftImp" :: "[lift, lift] ⇒ lift" (infixr "⟶" 25) "_liftIf" :: "[lift, lift, lift] ⇒ lift" ("(if (_)/ then (_)/ else (_))" 10) "_liftPlus" :: "[lift, lift] ⇒ lift" ("(_ +/ _)" [66,65] 65) "_liftMinus" :: "[lift, lift] ⇒ lift" ("(_ -/ _)" [66,65] 65) "_liftTimes" :: "[lift, lift] ⇒ lift" ("(_ */ _)" [71,70] 70) "_liftDiv" :: "[lift, lift] ⇒ lift" ("(_ div _)" [71,70] 70) "_liftMod" :: "[lift, lift] ⇒ lift" ("(_ mod _)" [71,70] 70) "_liftLess" :: "[lift, lift] ⇒ lift" ("(_/ < _)" [50, 51] 50) "_liftLeq" :: "[lift, lift] ⇒ lift" ("(_/ ≤ _)" [50, 51] 50) "_liftMem" :: "[lift, lift] ⇒ lift" ("(_/ ∈ _)" [50, 51] 50) "_liftNotMem" :: "[lift, lift] ⇒ lift" ("(_/ ∉ _)" [50, 51] 50) "_liftFinset" :: "liftargs => lift" ("{(_)}") (** TODO: syntax for lifted collection / comprehension **) "_liftPair" :: "[lift,liftargs] ⇒ lift" ("(1'(_,/ _'))") (* infix syntax for list operations *) "_liftCons" :: "[lift, lift] ⇒ lift" ("(_ #/ _)" [65,66] 65) "_liftApp" :: "[lift, lift] ⇒ lift" ("(_ @/ _)" [65,66] 65) "_liftList" :: "liftargs ⇒ lift" ("[(_)]") (* Rigid quantification (syntax level) *) "_ARAll" :: "[idts, lift] ⇒ lift" ("(3! _./ _)" [0, 10] 10) "_AREx" :: "[idts, lift] ⇒ lift" ("(3? _./ _)" [0, 10] 10) "_AREx1" :: "[idts, lift] ⇒ lift" ("(3?! _./ _)" [0, 10] 10) "_RAll" :: "[idts, lift] ⇒ lift" ("(3∀_./ _)" [0, 10] 10) "_REx" :: "[idts, lift] ⇒ lift" ("(3∃_./ _)" [0, 10] 10) "_REx1" :: "[idts, lift] ⇒ lift" ("(3∃!_./ _)" [0, 10] 10) translations "_const" ⇌ "CONST const" translations "_lift" ⇌ "CONST lift" "_lift2" ⇌ "CONST lift2" "_lift3" ⇌ "CONST lift3" "_lift4" ⇌ "CONST lift4" "_Valid" ⇌ "CONST Valid" translations "_RAll x A" ⇌ "Rall x. A" "_REx x A" ⇌ "Rex x. A" "_REx1 x A" ⇌ "Rex! x. A" translations "_ARAll" ⇀ "_RAll" "_AREx" ⇀ "_REx" "_AREx1" ⇀ "_REx1" "w ⊨ A" ⇀ "A w" "LIFT A" ⇀ "A::_⇒_" translations "_liftEqu" ⇌ "_lift2 (=)" "_liftNeq u v" ⇌ "_liftNot (_liftEqu u v)" "_liftNot" ⇌ "_lift (CONST Not)" "_liftAnd" ⇌ "_lift2 (&)" "_liftOr" ⇌ "_lift2 ((|) )" "_liftImp" ⇌ "_lift2 (-->)" "_liftIf" ⇌ "_lift3 (CONST If)" "_liftPlus" ⇌ "_lift2 (+)" "_liftMinus" ⇌ "_lift2 (-)" "_liftTimes" ⇌ "_lift2 (*)" "_liftDiv" ⇌ "_lift2 (div)" "_liftMod" ⇌ "_lift2 (mod)" "_liftLess" ⇌ "_lift2 (<)" "_liftLeq" ⇌ "_lift2 (<=)" "_liftMem" ⇌ "_lift2 (:)" "_liftNotMem x xs" ⇌ "_liftNot (_liftMem x xs)" translations "_liftFinset (_liftargs x xs)" ⇌ "_lift2 (CONST insert) x (_liftFinset xs)" "_liftFinset x" ⇌ "_lift2 (CONST insert) x (_const (CONST Set.empty))" "_liftPair x (_liftargs y z)" ⇌ "_liftPair x (_liftPair y z)" "_liftPair" ⇌ "_lift2 (CONST Pair)" "_liftCons" ⇌ "_lift2 (CONST Cons)" "_liftApp" ⇌ "_lift2 (@)" "_liftList (_liftargs x xs)" ⇌ "_liftCons x (_liftList xs)" "_liftList x" ⇌ "_liftCons x (_const [])" "w ⊨ ¬ A" ↽ "_liftNot A w" "w ⊨ A ∧ B" ↽ "_liftAnd A B w" "w ⊨ A ∨ B" ↽ "_liftOr A B w" "w ⊨ A ⟶ B" ↽ "_liftImp A B w" "w ⊨ u = v" ↽ "_liftEqu u v w" "w ⊨ ∀x. A" ↽ "_RAll x A w" "w ⊨ ∃x. A" ↽ "_REx x A w" "w ⊨ ∃!x. A" ↽ "_REx1 x A w" syntax (ASCII) "_Valid" :: "lift ⇒ bool" ("(|- _)" 5) "_holdsAt" :: "['a, lift] ⇒ bool" ("(_ |= _)" [100,10] 10) "_liftNeq" :: "[lift, lift] ⇒ lift" ("(_ ~=/ _)" [50,51] 50) "_liftNot" :: "lift ⇒ lift" ("(~ _)" [90] 90) "_liftAnd" :: "[lift, lift] ⇒ lift" ("(_ &/ _)" [36,35] 35) "_liftOr" :: "[lift, lift] ⇒ lift" ("(_ |/ _)" [31,30] 30) "_liftImp" :: "[lift, lift] ⇒ lift" ("(_ -->/ _)" [26,25] 25) "_liftLeq" :: "[lift, lift] ⇒ lift" ("(_/ <= _)" [50, 51] 50) "_liftMem" :: "[lift, lift] ⇒ lift" ("(_/ : _)" [50, 51] 50) "_liftNotMem" :: "[lift, lift] ⇒ lift" ("(_/ ~: _)" [50, 51] 50) "_RAll" :: "[idts, lift] ⇒ lift" ("(3ALL _./ _)" [0, 10] 10) "_REx" :: "[idts, lift] ⇒ lift" ("(3EX _./ _)" [0, 10] 10) "_REx1" :: "[idts, lift] ⇒ lift" ("(3EX! _./ _)" [0, 10] 10) subsection ‹Lemmas and Tactics› lemma intD[dest]: "⊢ A ⟹ w ⊨ A" proof (-) (*goal: ‹⊢ A ⟹ A w›*) assume a: "⊢ A" (*‹⊢ A::'a ⇒ bool›*) from a (*‹⊢ A›*) have "∀w. w ⊨ A" by (auto simp add: Valid_def (*‹⊢ ?A ≡ ∀w. ?A w›*)) thus "?thesis" (*goal: ‹A w›*) by standard qed lemma intI [intro!]: assumes P1:"(⋀ w. w ⊨ A)" shows "⊢ A" using assms (*‹A ?w›*) by (auto simp: Valid_def (*‹⊢ ?A ≡ ∀w. ?A w›*)) text‹ Basic unlifting introduces a parameter @{term w} and applies basic rewrites, e.g @{term "⊢ F = G"} becomes @{term "F w = G w"} and @{term "⊢ F ⟶ G"} becomes @{term "F w ⟶ G w"}. › method_setup int_unlift = ‹ Scan.succeed (fn ctxt => SIMPLE_METHOD' (resolve_tac ctxt @{thms intI} THEN' rewrite_goal_tac ctxt @{thms intensional_rews})) › "method to unlift and followed by intensional rewrites" lemma inteq_reflection: assumes P1: "⊢ x=y" shows "(x ≡ y)" proof (-) (*goal: ‹x ≡ y›*) from P1 (*‹⊢ x = y›*) have P2: "∀w. x w = y w" by (unfold Valid_def (*‹⊢ ?A ≡ ∀w. ?A w›*) unl_lift2 (*‹(?f<?x, ?y>) ?w ≡ ?f (?x ?w) (?y ?w)›*)) hence P3: "x=y" by blast thus "x ≡ y" by (rule "eq_reflection" (*‹?x = ?y ⟹ ?x ≡ ?y›*)) qed lemma int_simps: "⊢ (x=x) = #True" "⊢ (¬ #True) = #False" "⊢ (¬ #False) = #True" "⊢ (¬¬ P) = P" "⊢ ((¬ P) = P) = #False" "⊢ (P = (¬P)) = #False" "⊢ (P ≠ Q) = (P = (¬ Q))" "⊢ (#True=P) = P" "⊢ (P=#True) = P" "⊢ (#True ⟶ P) = P" "⊢ (#False ⟶ P) = #True" "⊢ (P ⟶ #True) = #True" "⊢ (P ⟶ P) = #True" "⊢ (P ⟶ #False) = (¬P)" "⊢ (P ⟶ ~P) = (¬P)" "⊢ (P ∧ #True) = P" "⊢ (#True ∧ P) = P" "⊢ (P ∧ #False) = #False" "⊢ (#False ∧ P) = #False" "⊢ (P ∧ P) = P" "⊢ (P ∧ ~P) = #False" "⊢ (¬P ∧ P) = #False" "⊢ (P ∨ #True) = #True" "⊢ (#True ∨ P) = #True" "⊢ (P ∨ #False) = P" "⊢ (#False ∨ P) = P" "⊢ (P ∨ P) = P" "⊢ (P ∨ ¬P) = #True" "⊢ (¬P ∨ P) = #True" "⊢ (∀ x. P) = P" "⊢ (∃ x. P) = P" (*goals: 1. ‹⊢ (x::'a ⇒ 'b) = x = #True› 2. ‹⊢ ¬ #True = #False› 3. ‹⊢ ¬ #False = #True› 4. ‹⊢ ¬ ¬ (P::'e ⇒ bool) = P› 5. ‹⊢ ¬ (P::'e ⇒ bool) = P = #False› 6. ‹⊢ (P::'e ⇒ bool) = ¬ P = #False› 7. ‹⊢ (P::'e ⇒ bool) ≠ (Q::'e ⇒ bool) = (P = ¬ Q)› 8. ‹⊢ #True = (P::'e ⇒ bool) = P› 9. ‹⊢ (P::'e ⇒ bool) = #True = P› 10. ‹⊢ (#True ⟶ (P::'e ⇒ bool)) = P› 11. ‹⊢ (#False ⟶ (P::'e ⇒ bool)) = #True› 12. ‹⊢ ((P::'e ⇒ bool) ⟶ #True) = #True› 13. ‹⊢ ((P::'e ⇒ bool) ⟶ P) = #True› 14. ‹⊢ ((P::'e ⇒ bool) ⟶ #False) = ¬ P› 15. ‹⊢ ((P::'e ⇒ bool) ⟶ ¬ P) = ¬ P› 16. ‹⊢ ((P::'e ⇒ bool) ∧ #True) = P› 17. ‹⊢ (#True ∧ (P::'e ⇒ bool)) = P› 18. ‹⊢ ((P::'e ⇒ bool) ∧ #False) = #False› 19. ‹⊢ (#False ∧ (P::'e ⇒ bool)) = #False› 20. ‹⊢ ((P::'e ⇒ bool) ∧ P) = P› 21. ‹⊢ ((P::'e ⇒ bool) ∧ ¬ P) = #False› 22. ‹⊢ (¬ (P::'e ⇒ bool) ∧ P) = #False› 23. ‹⊢ ((P::'e ⇒ bool) ∨ #True) = #True› 24. ‹⊢ (#True ∨ (P::'e ⇒ bool)) = #True› 25. ‹⊢ ((P::'e ⇒ bool) ∨ #False) = P› 26. ‹⊢ (#False ∨ (P::'e ⇒ bool)) = P› 27. ‹⊢ ((P::'e ⇒ bool) ∨ P) = P› 28. ‹⊢ ((P::'e ⇒ bool) ∨ ¬ P) = #True› 29. ‹⊢ (¬ (P::'e ⇒ bool) ∨ P) = #True› 30. ‹⊢ (∀x::'f. (P::'e ⇒ bool)) = P› 31. ‹⊢ (∃x::'g. (P::'e ⇒ bool)) = 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]) (*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]) (*discuss goal 25*) apply ((auto)[1]) (*discuss goal 26*) apply ((auto)[1]) (*discuss goal 27*) apply ((auto)[1]) (*discuss goal 28*) apply ((auto)[1]) (*discuss goal 29*) apply ((auto)[1]) (*discuss goal 30*) apply ((auto)[1]) (*discuss goal 31*) apply ((auto)[1]) (*proven 31 subgoals*) . lemmas intensional_simps[simp] = int_simps[THEN inteq_reflection] method_setup int_rewrite = ‹ Scan.succeed (fn ctxt => SIMPLE_METHOD' (rewrite_goal_tac ctxt @{thms intensional_simps})) › "rewrite method at intensional level" lemma Not_Rall: "⊢ (¬(∀ x. F x)) = (∃ x. ¬F x)" by auto lemma Not_Rex: "⊢ (¬(∃ x. F x)) = (∀ x. ¬F x)" by auto lemma TrueW [simp]: "⊢ #True" by auto lemma int_eq: "⊢ X = Y ⟹ X = Y" by (auto simp: inteq_reflection (*‹⊢ ?x = ?y ⟹ ?x ≡ ?y›*)) lemma int_iffI: assumes "⊢ F ⟶ G" and "⊢ G ⟶ F" shows "⊢ F = G" using assms (*‹⊢ F ⟶ G› ‹⊢ G ⟶ F›*) by force lemma int_iffD1: assumes h: "⊢ F = G" shows "⊢ F ⟶ G" using h (*‹⊢ F = G›*) by auto lemma int_iffD2: assumes h: "⊢ F = G" shows "⊢ G ⟶ F" using h (*‹⊢ F = G›*) by auto lemma lift_imp_trans: assumes "⊢ A ⟶ B" and "⊢ B ⟶ C" shows "⊢ A ⟶ C" using assms (*‹⊢ A ⟶ B› ‹⊢ (B::'a ⇒ bool) ⟶ (C::'a ⇒ bool)›*) by force lemma lift_imp_neg: assumes "⊢ A ⟶ B" shows "⊢ ¬B ⟶ ¬A" using assms (*‹⊢ (A::'a ⇒ bool) ⟶ (B::'a ⇒ bool)›*) by auto lemma lift_and_com: "⊢ (A ∧ B) = (B ∧ A)" by auto end
{ "path": "afp-2025-02-12/thys/TLA/Intensional.thy", "repo": "afp-2025-02-12", "sha": "7f51d6c4dde2e2a400268a76fdb5cda86fd916084dbfc8a4e6eb1f2e7ed13e8d" }
theory Powers3844 imports Main Kyber_Values begin section ‹Checking Powers of Root of Unity› text ‹In order to check, that $3844$ is indeed a root of unity, we need to calculate all powers and show that they are not equal to one.› fun fast_exp_7681 ::" int ⇒ nat ⇒ int" where "fast_exp_7681 x 0 = 1" | "fast_exp_7681 x (Suc e) = (x * (fast_exp_7681 x e)) mod 7681" lemma list_all_fast_exp_7681: "list_all (λl. fast_exp_7681 (3844::int) l ≠ 1) [1..<256]" by (msorry) lemma fast_exp_7681_to_mod_ring: "fast_exp_7681 x e = to_int_mod_ring ((of_int_mod_ring x :: fin7681 mod_ring)^e)" proof (induct e arbitrary: x rule: fast_exp_7681.induct) (*goals: 1. ‹⋀x xa. fast_exp_7681 xa 0 = to_int_mod_ring (of_int_mod_ring xa ^ 0)› 2. ‹⋀x e xa. (⋀x. fast_exp_7681 x e = to_int_mod_ring (of_int_mod_ring x ^ e)) ⟹ fast_exp_7681 xa (Suc e) = to_int_mod_ring (of_int_mod_ring xa ^ Suc e)›*) case (2 x e) (*‹fast_exp_7681 ?x e = to_int_mod_ring (of_int_mod_ring ?x ^ e)›*) then show "?case" (*goal: ‹fast_exp_7681 (x::int) (Suc (e::nat)) = to_int_mod_ring (of_int_mod_ring x ^ Suc e)›*) by (metis (no_types, lifting) Suc_inject (*‹Suc ?x = Suc ?y ⟹ ?x = ?y›*) fast_exp_7681.elims (*‹⟦fast_exp_7681 ?x ?xa = ?y; ⋀x. ⟦?x = x; ?xa = 0; ?y = 1⟧ ⟹ ?P; ⋀x e. ⟦?x = x; ?xa = Suc e; ?y = x * fast_exp_7681 x e mod 7681⟧ ⟹ ?P⟧ ⟹ ?P›*) kyber7681.module_spec_axioms (*‹module_spec TYPE(fin7681) TYPE(3) 256 7681 3 8›*) module_spec.CARD_a (*‹module_spec TYPE(?'a) TYPE(?'k) ?n ?q ?k ?n' ⟹ int CARD(?'a) = ?q›*) nat.simps( (*‹Suc ?x2.0 ≠ 0›*) 3) of_int_mod_ring.rep_eq (*‹Rep_mod_ring (of_int_mod_ring ?x) = ?x mod int CARD(?'a)›*) of_int_mod_ring_mult (*‹of_int_mod_ring (?a * ?b) = of_int_mod_ring ?a * of_int_mod_ring ?b›*) of_int_mod_ring_to_int_mod_ring (*‹of_int_mod_ring (to_int_mod_ring ?x) = ?x›*) power_Suc (*‹?a ^ Suc ?n = ?a * ?a ^ ?n›*) to_int_mod_ring.rep_eq (*‹to_int_mod_ring ?x = Rep_mod_ring ?x›*)) qed (auto) (*solved the remaining goal: ‹⋀x xa. fast_exp_7681 xa 0 = to_int_mod_ring (of_int_mod_ring xa ^ 0)›*) lemma fast_exp_7681_less256: assumes "0<l" "l<256" shows "fast_exp_7681 3844 l ≠ 1" using list_all_fast_exp_7681 (*‹list_all (λl::nat. fast_exp_7681 (3844::int) l ≠ (1::int)) [1::nat..<256::nat]›*) assms (*‹(0::nat) < (l::nat)› ‹(l::nat) < (256::nat)›*) by (smt (verit, ccfv_threshold) Ball_set (*‹Ball (set ?xs) ?P = list_all ?P ?xs›*) One_nat_def (*‹1 = Suc 0›*) atLeastLessThan_iff (*‹(?i ∈ {?l..<?u}) = (?l ≤ ?i ∧ ?i < ?u)›*) bot_nat_0.not_eq_extremum (*‹(?a ≠ 0) = (0 < ?a)›*) fast_exp_7681.elims (*‹⟦fast_exp_7681 ?x ?xa = ?y; ⋀x. ⟦?x = x; ?xa = 0; ?y = 1⟧ ⟹ ?P; ⋀x e. ⟦?x = x; ?xa = Suc e; ?y = x * fast_exp_7681 x e mod 7681⟧ ⟹ ?P⟧ ⟹ ?P›*) less_Suc_numeral (*‹(Suc ?n < numeral ?k) = (?n < pred_numeral ?k)›*) less_nat_zero_code (*‹(?n < 0) = False›*) not_less (*‹(¬ ?x < ?y) = (?y ≤ ?x)›*) numeral_One (*‹Numeral1 = 1›*) numeral_less_iff (*‹(numeral ?m < numeral ?n) = (?m < ?n)›*) set_upt (*‹set [?i..<?j] = {?i..<?j}›*)) lemma powr_less256: assumes "0<l" "l<256" shows "(3844::fin7681 mod_ring)^l ≠ 1" using fast_exp_7681_less256[OF assms] (*‹fast_exp_7681 3844 l ≠ 1›*) unfolding fast_exp_7681_to_mod_ring (*goal: ‹3844 ^ l ≠ 1›*) by (metis of_int_numeral (*‹of_int (numeral ?k) = numeral ?k›*) of_int_of_int_mod_ring (*‹of_int = of_int_mod_ring›*) to_int_mod_ring_hom.hom_one (*‹to_int_mod_ring 1 = 1›*)) end
{ "path": "afp-2025-02-12/thys/CRYSTALS-Kyber/Powers3844.thy", "repo": "afp-2025-02-12", "sha": "c75e5f5741987f06f1f35c79a8e8fdbc6f32a6cace6ef967c8d722655686d676" }
(*<*) ―‹ ******************************************************************** * Project : AGM Theory * Version : 1.0 * * Authors : Valentin Fouillard, Safouan Taha, Frederic Boulanger and Nicolas Sabouret * * This file : AGM contraction * * Copyright (c) 2021 Université Paris Saclay, France * * All rights reserved. * ******************************************************************************› theory AGM_Contraction imports AGM_Logic AGM_Remainder begin (*>*) section ‹Contractions› text‹The first operator of belief change of the AGM framework is contraction. This operator consist to remove a sentence @{term ‹φ›} from a belief set @{term ‹K›} in such a way that @{term ‹K›} no longer imply @{term ‹φ›}. In the following we will first axiomatize such operators at different levels of logics (Tarskian, supraclassical and compact) and then we will give constructions satisfying these axioms. The following graph summarizes all equivalences we established: \includegraphics[width=\textwidth]{"graph_locales.pdf"} We will use the extension feature of locales in Isabelle/HOL to incrementally define the contraction operator as shown by blue arrows in the previous figure. Then, using the interpretation feature of locales, we will prove the equivalence between descriptive and constructive approaches at each level depending on the adopted logics (black arrows). › subsection‹AGM contraction postulates› text‹ The operator of contraction is denoted by the symbol @{text ‹÷›} and respects the six following conditions : ▪ @{text ‹contract_closure›} : a belief set @{term ‹K›} contracted by @{term ‹φ›} should be logically closed ▪ @{text ‹contract_inclusion›} : a contracted set @{term ‹K›} should be a subset of the original one ▪ @{text ‹contract_vacuity›} : if @{term ‹φ›} is not included in a set @{term ‹K›} then the contraction of @{term ‹K›} by @{term ‹φ›} involves no change at all ▪ @{text ‹contract_success›} : if a set @{term ‹K›} is contracted by @{term ‹φ›} then @{term ‹K›} does not imply @{term ‹φ›} ▪ @{text ‹contract_recovery›}: all propositions removed in a set @{term ‹K›} by contraction of @{term ‹φ›} will be recovered by expansion of @{term ‹φ›} ▪ @{text ‹contract_extensionality›} : Extensionality guarantees that the logic of contraction is extensional in the sense of allowing logically quivalent sentences to be freely substituted for each other› locale AGM_Contraction = Tarskian_logic + fixes contraction::‹'a set ⇒ 'a ⇒ 'a set› (infix ‹÷› 55) assumes contract_closure: ‹K = Cn(A) ⟹ K ÷ φ = Cn(K ÷ φ)› and contract_inclusion: ‹K = Cn(A) ⟹ K ÷ φ ⊆ K› and contract_vacuity: ‹K = Cn(A) ⟹ φ ∉ K ⟹ K ÷ φ = K› and contract_success: ‹K = Cn(A) ⟹ φ ∉ Cn({}) ⟹ φ ∉ K ÷ φ› and contract_recovery: ‹K = Cn(A) ⟹ K ⊆ ((K ÷ φ) ⊕ φ)› and contract_extensionality: ‹K = Cn(A) ⟹ Cn({φ}) = Cn({ψ}) ⟹ K ÷ φ = K ÷ ψ› text‹ A full contraction is defined by two more postulates to rule the conjunction. We base on a supraclassical logic. ▪ @{text ‹contract_conj_overlap›} : An element in both @{text ‹K ÷ φ›} and @{text ‹K ÷ ψ›} is also an element of @{text ‹K ÷ (φ ∧ ψ)›} ▪ @{text ‹contract_conj_inclusion›} : If @{term ‹φ›} not in @{text ‹K ÷ (φ ∧ ψ)›} then all elements removed by this contraction are also removed from @{text ‹K ÷ φ›}› locale AGM_FullContraction = AGM_Contraction + Supraclassical_logic + assumes contract_conj_overlap: ‹K = Cn(A) ⟹ (K ÷ φ) ∩ (K ÷ ψ) ⊆ (K ÷ (φ .∧. ψ))› and contract_conj_inclusion: ‹K = Cn(A) ⟹ φ ∉ (K ÷ (φ .∧. ψ)) ⟹ ((K ÷ (φ .∧. ψ) ⊆ (K ÷ φ)))› begin ― ‹two important lemmas/corollaries that can replace the two assumptions @{text ‹contract_conj_overlap›} and @{text ‹contract_conj_inclusion›}› text‹@{text ‹contract_conj_overlap_variant›} does not need ‹ψ› to occur in the left side! › corollary contract_conj_overlap_variant: ‹K = Cn(A) ⟹ (K ÷ φ) ∩ Cn({φ}) ⊆ (K ÷ (φ .∧. ψ))› proof (-) (*goal: ‹K = Cn A ⟹ (K ÷ φ) ∩ Cn {φ} ⊆ K ÷ (φ .∧. ψ)›*) assume a: "K = Cn(A)" (*‹(K::'a set) = (Cn::'a set ⇒ 'a set) (A::'a set)›*) { assume b: "K ⊢ φ" and c: "K ⊢ ψ" (*‹(K::'a set) ⊢ (φ::'a)› ‹(K::'a set) ⊢ (ψ::'a)›*) hence d: "K ÷ (φ .∧. ψ) = K ÷ (φ .∧. ((.¬ φ) .∨. ψ))" apply (rule_tac contract_extensionality[OF a] (*‹Cn {?φ} = Cn {?ψ} ⟹ K ÷ ?φ = K ÷ ?ψ›*)) (*goal: ‹K ÷ (φ .∧. ψ) = K ÷ (φ .∧. (.¬ φ .∨. ψ))›*) using conj_overlap[of _ φ ψ] (*‹(?A ⊢ φ .∧. ψ) = (?A ⊢ φ .∧. (.¬ φ .∨. ψ))›*) by (simp add: Cn_same (*‹(Cn ?A = Cn ?B) = (∀C. (?A ⊆ Cn C) = (?B ⊆ Cn C))›*)) have e: "K ∩ Cn {φ} ⊆ K ÷ (.¬ φ .∨. ψ)" proof (safe) (*goal: ‹⋀x. ⟦x ∈ K; x ∈ Cn {φ}⟧ ⟹ x ∈ K ÷ (.¬ φ .∨. ψ)›*) fix χ assume f: "χ ∈ K" and g: "χ ∈ Cn {φ}" (*‹(χ::'a) ∈ (K::'a set)› ‹(χ::'a) ∈ (Cn::'a set ⇒ 'a set) {φ::'a}›*) have "K ÷ (.¬ φ .∨. ψ) ⊢ (.¬ φ .∨. ψ) .⟶. χ" by (metis a (*‹(K::'a::type set) = (Cn::'a::type set ⇒ 'a::type set) (A::'a::type set)›*) contract_recovery (*‹(?K::'a::type set) = (Cn::'a::type set ⇒ 'a::type set) (?A::'a::type set) ⟹ ?K ⊆ (?K ÷ (?φ::'a::type)) ⊕ ?φ›*) expansion_def (*‹(?A::'a::type set) ⊕ (?φ::'a::type) ≡ (Cn::'a::type set ⇒ 'a::type set) (?A ∪ {?φ})›*) f (*‹(χ::'a::type) ∈ (K::'a::type set)›*) impI_PL (*‹(?A::'a::type set) ∪ {?p::'a::type} ⊢ (?q::'a::type) ⟹ ?A ⊢ ?p .⟶. ?q›*) infer_def (*‹(?A::'a::type set) ⊢ (?φ::'a::type) ≡ ?φ ∈ (Cn::'a::type set ⇒ 'a::type set) ?A›*) subset_eq (*‹((?A::?'a::type set) ⊆ (?B::?'a::type set)) = (∀x::?'a::type∈?A. x ∈ ?B)›*)) hence "K ÷ (.¬ φ .∨. ψ) ⊢ .¬ φ .⟶. χ" by (meson disjI1_PL (*‹(?A::'a set) ⊢ (?p::'a) ⟹ ?A ⊢ ?p .∨. (?q::'a)›*) imp_trans (*‹⟦(?A::'a set) ⊢ (?p::'a) .⟶. (?q::'a); ?A ⊢ ?q .⟶. (?r::'a)⟧ ⟹ ?A ⊢ ?p .⟶. ?r›*) inclusion_L (*‹(?A::'a set) ⊆ (Cn::'a set ⇒ 'a set) ?A›*) infer_def (*‹(?A::'a set) ⊢ (?φ::'a) ≡ ?φ ∈ (Cn::'a set ⇒ 'a set) ?A›*) insert_subset (*‹(insert (?x::?'a) (?A::?'a set) ⊆ (?B::?'a set)) = (?x ∈ ?B ∧ ?A ⊆ ?B)›*) validD_L (*‹⊩ (?φ::'a) ⟹ ?φ ∈ (Cn::'a set ⇒ 'a set) (?A::'a set)›*) valid_imp_PL (*‹⊩ ((?p::'a) .⟶. (?q::'a)) = ({?p} ⊢ ?q)›*)) with g (*‹χ ∈ Cn {φ}›*) show "χ ∈ K ÷ (.¬ φ .∨. ψ)" by (metis a (*‹K = Cn A›*) contract_closure (*‹?K = Cn ?A ⟹ ?K ÷ ?φ = Cn (?K ÷ ?φ)›*) disjE_PL (*‹⟦?A ⊢ ?p .∨. ?q; ?A ⊢ ?p .⟶. ?r; ?A ⊢ ?q .⟶. ?r⟧ ⟹ ?A ⊢ ?r›*) ex_mid_PL (*‹?A ⊢ ?p .∨. .¬ ?p›*) infer_def (*‹?A ⊢ ?φ ≡ ?φ ∈ Cn ?A›*) validD_L (*‹⊩ ?φ ⟹ ?φ ∈ Cn ?A›*) valid_imp_PL (*‹⊩ (?p .⟶. ?q) = ({?p} ⊢ ?q)›*)) qed have "?thesis" unfolding d (*goal: ‹(K ÷ φ) ∩ Cn {φ} ⊆ K ÷ (φ .∧. (.¬ φ .∨. ψ))›*) using e (*‹K ∩ Cn {φ} ⊆ K ÷ (.¬ φ .∨. ψ)›*) contract_conj_overlap[OF a, of φ ‹(.¬ φ .∨. ψ)›] (*‹(K ÷ φ) ∩ (K ÷ (.¬ φ .∨. ψ)) ⊆ K ÷ (φ .∧. (.¬ φ .∨. ψ))›*) a (*‹K = Cn A›*) contract_inclusion (*‹?K = Cn ?A ⟹ ?K ÷ ?φ ⊆ ?K›*) by force } then show "?thesis" (*goal: ‹(K ÷ φ) ∩ Cn {φ} ⊆ K ÷ (φ .∧. ψ)›*) apply (cases ‹¬ K ⊢ φ ∨ ¬ K ⊢ ψ›) (*goals: 1. ‹⟦⟦K ⊢ φ; K ⊢ ψ⟧ ⟹ (K ÷ φ) ∩ Cn {φ} ⊆ K ÷ (φ .∧. ψ); ¬ K ⊢ φ ∨ ¬ K ⊢ ψ⟧ ⟹ (K ÷ φ) ∩ Cn {φ} ⊆ K ÷ (φ .∧. ψ)› 2. ‹⟦⟦K ⊢ φ; K ⊢ ψ⟧ ⟹ (K ÷ φ) ∩ Cn {φ} ⊆ K ÷ (φ .∧. ψ); ¬ (¬ K ⊢ φ ∨ ¬ K ⊢ ψ)⟧ ⟹ (K ÷ φ) ∩ Cn {φ} ⊆ K ÷ (φ .∧. ψ)› discuss goal 1*) apply (metis IntE (*‹⟦?c ∈ ?A ∩ ?B; ⟦?c ∈ ?A; ?c ∈ ?B⟧ ⟹ ?P⟧ ⟹ ?P›*) a (*‹K = Cn A›*) assumption_L (*‹?φ ∈ ?A ⟹ ?A ⊢ ?φ›*) conjE1_PL (*‹?A ⊢ ?p .∧. ?q ⟹ ?A ⊢ ?p›*) conjE2_PL (*‹?A ⊢ ?p .∧. ?q ⟹ ?A ⊢ ?q›*) contract_inclusion (*‹?K = Cn ?A ⟹ ?K ÷ ?φ ⊆ ?K›*) contract_vacuity (*‹⟦?K = Cn ?A; ?φ ∉ ?K⟧ ⟹ ?K ÷ ?φ = ?K›*) subsetD (*‹⟦?A ⊆ ?B; ?c ∈ ?A⟧ ⟹ ?c ∈ ?B›*) subsetI (*‹(⋀x. x ∈ ?A ⟹ x ∈ ?B) ⟹ ?A ⊆ ?B›*)) (*discuss goal 2*) apply blast (*proven 2 subgoals*) . qed text‹@{text ‹contract_conj_inclusion_variant›}: Everything retained in @{text ‹K ÷ (φ ∧ ψ)›} is retained in @{text ‹K ÷ ψ›}› corollary contract_conj_inclusion_variant : ‹K = Cn(A) ⟹ (K ÷ (φ .∧. ψ) ⊆ (K ÷ φ)) ∨ (K ÷ (φ .∧. ψ) ⊆ (K ÷ ψ))› proof (-) (*goal: ‹(K::'a set) = (Cn::'a set ⇒ 'a set) (A::'a set) ⟹ K ÷ ((φ::'a) .∧. (ψ::'a)) ⊆ K ÷ φ ∨ K ÷ (φ .∧. ψ) ⊆ K ÷ ψ›*) assume a: "K = Cn(A)" (*‹(K::'a set) = (Cn::'a set ⇒ 'a set) (A::'a set)›*) { assume d: "φ ∈ (K ÷ (φ .∧. ψ)) ∧ ψ ∈ (K ÷ (φ .∧. ψ))" (*‹(φ::'a) ∈ (K::'a set) ÷ (φ .∧. (ψ::'a)) ∧ ψ ∈ K ÷ (φ .∧. ψ)›*) hence "φ .∧. ψ ∈ (K ÷ (φ .∧. ψ))" using Supraclassical_logic.conjI_PL (*‹⟦Supraclassical_logic ?Cn ?true_PL ?false_PL ?imp_PL ?not_PL ?conj_PL ?disj_PL ?equiv_PL; ?p ∈ ?Cn ?A; ?q ∈ ?Cn ?A⟧ ⟹ ?conj_PL ?p ?q ∈ ?Cn ?A›*) Supraclassical_logic_axioms (*‹Supraclassical_logic Cn ⊤ ⊥ (.⟶.) .¬ (.∧.) (.∨.) (.⟷.)›*) a (*‹K = Cn A›*) contract_closure (*‹?K = Cn ?A ⟹ ?K ÷ ?φ = Cn (?K ÷ ?φ)›*) by fastforce with d (*‹φ ∈ K ÷ (φ .∧. ψ) ∧ ψ ∈ K ÷ (φ .∧. ψ)›*) have "?thesis" by (metis (no_types, lifting) Supraclassical_logic.valid_conj_PL (*‹Supraclassical_logic ?Cn ?true_PL ?false_PL ?imp_PL ?not_PL ?conj_PL ?disj_PL ?equiv_PL ⟹ (?conj_PL ?p ?q ∈ ?Cn {}) = (?p ∈ ?Cn {} ∧ ?q ∈ ?Cn {})›*) Supraclassical_logic_axioms (*‹Supraclassical_logic Cn ⊤ ⊥ (.⟶.) .¬ (.∧.) (.∨.) (.⟷.)›*) Tarskian_logic.valid_expansion (*‹⟦Tarskian_logic ?Cn; ?K = ?Cn ?A; ?φ ∈ ?Cn {}⟧ ⟹ ?Cn (?K ∪ {?φ}) = ?K›*) Tarskian_logic_axioms (*‹Tarskian_logic Cn›*) a (*‹K = Cn A›*) contract_closure (*‹?K = Cn ?A ⟹ ?K ÷ ?φ = Cn (?K ÷ ?φ)›*) contract_inclusion (*‹?K = Cn ?A ⟹ ?K ÷ ?φ ⊆ ?K›*) contract_recovery (*‹?K = Cn ?A ⟹ ?K ⊆ (?K ÷ ?φ) ⊕ ?φ›*) contract_success (*‹⟦?K = Cn ?A; ?φ ∉ Cn {}⟧ ⟹ ?φ ∉ ?K ÷ ?φ›*) dual_order.trans (*‹⟦?b ≤ ?a; ?c ≤ ?b⟧ ⟹ ?c ≤ ?a›*) expansion_def (*‹?A ⊕ ?φ ≡ Cn (?A ∪ {?φ})›*)) } then show "?thesis" (*goal: ‹(K::'a set) ÷ ((φ::'a) .∧. (ψ::'a)) ⊆ K ÷ φ ∨ K ÷ (φ .∧. ψ) ⊆ K ÷ ψ›*) by (metis a (*‹K = Cn A›*) conj_com_Cn (*‹Cn {?p .∧. ?q} = Cn {?q .∧. ?p}›*) contract_conj_inclusion (*‹⟦?K = Cn ?A; ?φ ∉ ?K ÷ (?φ .∧. ?ψ)⟧ ⟹ ?K ÷ (?φ .∧. ?ψ) ⊆ ?K ÷ ?φ›*) contract_extensionality (*‹⟦?K = Cn ?A; Cn {?φ} = Cn {?ψ}⟧ ⟹ ?K ÷ ?φ = ?K ÷ ?ψ›*)) qed end subsection ‹Partial meet contraction definition› text‹A partial meet contraction of @{term ‹K›} by @{term ‹φ›} is the intersection of some sets that not imply @{term ‹φ›}. We define these sets as the "remainders" @{text ‹(K .⊥. φ›}. The function of selection @{term ‹γ›} select the best set of the remainders that do not imply @{term ‹φ›}. This function respect these postulates : ▪ @{text ‹is_selection›} : if there exist some set that do not imply @{term ‹φ›} then the function selection @{term ‹γ›} is a subset of these sets ▪ @{text ‹tautology_selection›} : if there is no set that do not imply @{term ‹φ›} then the result of the selection function is @{term ‹K›} ▪ @{text nonempty_selection} : An empty selection function do not exist ▪ @{text extensional_selection} : Two proposition with the same closure have the same selection function› locale PartialMeetContraction = Tarskian_logic + fixes selection::‹'a set ⇒ 'a ⇒ 'a set set› (‹γ›) assumes is_selection: ‹K = Cn(A) ⟹ (K .⊥. φ) ≠ {} ⟹ γ K φ ⊆ (K .⊥. φ)› assumes tautology_selection: ‹K = Cn(A) ⟹ (K .⊥. φ) = {} ⟹ γ K φ = {K}› assumes nonempty_selection: ‹K = Cn(A) ⟹ γ K φ ≠ {}› assumes extensional_selection: ‹K = Cn(A) ⟹ Cn({φ}) = Cn({ψ}) ⟹ γ K φ = γ K ψ› ― ‹extensionality seems very hard to implement for a constructive approach, one basic implementation will be to ignore @{term ‹A›} and @{term ‹φ›} and only base on @{text ‹A .⊥. φ›} that is already proved as extensional (lemma @{text ‹remainder_extensionality›})› begin text ‹A partial meet is the intersection of set of selected element.› definition (in Tarskian_logic) meet_contraction::‹'a set ⇒ ('a set ⇒ 'a ⇒ 'a set set) ⇒ 'a ⇒ 'a set› (‹_ ÷⇘_⇙ _› [60,50,60]55) where mc: ‹(A ÷⇘γ⇙ φ) ≡ ⋂(γ A φ)› text ‹Following this definition 4 postulates of AGM can be proved on a partial meet contraction: ▪ @{text ‹contract_inclusion›} ▪ @{text ‹ contract_vacuity›} ▪ @{text ‹ contract_closure›} ▪ @{text ‹ contract_extensionality›}› text ‹@{text ‹pmc_inclusion› } :a partial meet contraction is a subset of the contracted set› lemma pmc_inclusion: ‹K = Cn(A) ⟹ K ÷⇘γ⇙ φ ⊆ K› apply (cases ‹(K .⊥. φ) = {}›) (*goals: 1. ‹⟦K = Cn A; K .⊥. φ = {}⟧ ⟹ K ÷⇘γ⇙ φ ⊆ K› 2. ‹⟦K = Cn A; K .⊥. φ ≠ {}⟧ ⟹ K ÷⇘γ⇙ φ ⊆ K› discuss goal 1*) apply (simp add: mc (*‹?A ÷⇘?γ⇙ ?φ ≡ ⋂ (?γ ?A ?φ)›*) tautology_selection (*‹⟦?K = Cn ?A; ?K .⊥. ?φ = {}⟧ ⟹ γ ?K ?φ = {?K}›*)) (*discuss goal 2*) apply (simp add: mc (*‹(?A::'a set) ÷⇘(?γ::'a set ⇒ 'a ⇒ 'a set set)⇙ (?φ::'a) ≡ ⋂ (?γ ?A ?φ)›*) tautology_selection (*‹⟦(?K::'a set) = (Cn::'a set ⇒ 'a set) (?A::'a set); ?K .⊥. (?φ::'a) = {}⟧ ⟹ γ ?K ?φ = {?K}›*)) (*goal: ‹⟦K = Cn A; K .⊥. φ ≠ {}⟧ ⟹ K ÷⇘γ⇙ φ ⊆ K›*) apply (meson Inf_less_eq (*‹⟦⋀v. v ∈ ?A ⟹ v ≤ ?u; ?A ≠ {}⟧ ⟹ Inf ?A ≤ ?u›*) in_mono (*‹?A ⊆ ?B ⟹ ?x ∈ ?A ⟶ ?x ∈ ?B›*) is_selection (*‹⟦?K = Cn ?A; ?K .⊥. ?φ ≠ {}⟧ ⟹ γ ?K ?φ ⊆ ?K .⊥. ?φ›*) nonempty_selection (*‹?K = Cn ?A ⟹ γ ?K ?φ ≠ {}›*) rem_inclusion (*‹?B ∈ ?A .⊥. ?φ ⟹ ?B ⊆ ?A›*)) (*proven 2 subgoals*) . text‹@{text ‹pmc_vacuity›} : if @{term ‹φ›} is not included in a set @{term ‹K›} then the partial meet contraction of @{term ‹K›} by @{term ‹φ›} involves not change at all› lemma pmc_vacuity: ‹K = Cn(A) ⟹ ¬ K ⊢ φ ⟹ K ÷⇘γ⇙ φ = K› unfolding mc nonconsequence_remainder (*goal: ‹⟦K = Cn A; ¬ K ⊢ φ⟧ ⟹ ⋂ (γ K φ) = K›*) by (metis Inf_superset_mono (*‹?B ⊆ ?A ⟹ Inf ?A ≤ Inf ?B›*) Un_absorb1 (*‹?A ⊆ ?B ⟹ ?A ∪ ?B = ?B›*) cInf_singleton (*‹Inf {?x} = ?x›*) insert_not_empty (*‹insert ?a ?A ≠ {}›*) is_selection (*‹⟦?K = Cn ?A; ?K .⊥. ?φ ≠ {}⟧ ⟹ γ ?K ?φ ⊆ ?K .⊥. ?φ›*) mc (*‹?A ÷⇘?γ⇙ ?φ ≡ ⋂ (?γ ?A ?φ)›*) nonconsequence_remainder (*‹(?A .⊥. ?φ = {?A}) = (¬ ?A ⊢ ?φ)›*) pmc_inclusion (*‹?K = Cn ?A ⟹ ?K ÷⇘γ⇙ ?φ ⊆ ?K›*) sup_commute (*‹sup ?x ?y = sup ?y ?x›*)) text‹@{text ‹pmc_closure›} : a partial meet contraction is logically closed› lemma pmc_closure: ‹K = Cn(A) ⟹ (K ÷⇘γ⇙ φ) = Cn(K ÷⇘γ⇙ φ)› proof (rule subset_antisym (*‹⟦?A ⊆ ?B; ?B ⊆ ?A⟧ ⟹ ?A = ?B›*), simp_all add:inclusion_L mc transitivity_L, goal_cases) (*goal: ‹K = Cn A ⟹ Cn (⋂ (γ (Cn A) φ)) ⊆ ⋂ (γ (Cn A) φ)›*) case 1 (*‹K = Cn A›*) have "⋂(γ (Cn A) φ) = ⋂{Cn(B)|B. B ∈ γ (Cn A) φ}" apply auto (*goals: 1. ‹⋀(x::'a::type) B::'a::type set. ⟦∀xa::'a::type set∈γ ((Cn::'a::type set ⇒ 'a::type set) (A::'a::type set)) (φ::'a::type). x ∈ xa; B ∈ γ (Cn A) φ⟧ ⟹ x ∈ Cn B› 2. ‹⋀(x::'a::type) X::'a::type set. ⟦∀xa::'a::type set. (∃B::'a::type set. xa = (Cn::'a::type set ⇒ 'a::type set) B ∧ B ∈ γ (Cn (A::'a::type set)) (φ::'a::type)) ⟶ x ∈ xa; X ∈ γ (Cn A) φ⟧ ⟹ x ∈ X› discuss goal 1*) apply (metis idempotency_L (*‹Cn (Cn ?A) = Cn ?A›*) insert_absorb (*‹?a ∈ ?A ⟹ insert ?a ?A = ?A›*) insert_iff (*‹(?a ∈ insert ?b ?A) = (?a = ?b ∨ ?a ∈ ?A)›*) insert_subset (*‹(insert ?x ?A ⊆ ?B) = (?x ∈ ?B ∧ ?A ⊆ ?B)›*) is_selection (*‹⟦?K = Cn ?A; ?K .⊥. ?φ ≠ {}⟧ ⟹ γ ?K ?φ ⊆ ?K .⊥. ?φ›*) rem_closure (*‹⟦?K = Cn ?A; ?B ∈ ?K .⊥. ?φ⟧ ⟹ ?B = Cn ?B›*) tautology_selection (*‹⟦?K = Cn ?A; ?K .⊥. ?φ = {}⟧ ⟹ γ ?K ?φ = {?K}›*)) (*discuss goal 2*) apply (metis idempotency_L (*‹Cn (Cn ?A) = Cn ?A›*) insert_absorb (*‹?a ∈ ?A ⟹ insert ?a ?A = ?A›*) insert_iff (*‹(?a ∈ insert ?b ?A) = (?a = ?b ∨ ?a ∈ ?A)›*) insert_subset (*‹(insert ?x ?A ⊆ ?B) = (?x ∈ ?B ∧ ?A ⊆ ?B)›*) is_selection (*‹⟦?K = Cn ?A; ?K .⊥. ?φ ≠ {}⟧ ⟹ γ ?K ?φ ⊆ ?K .⊥. ?φ›*) rem_closure (*‹⟦?K = Cn ?A; ?B ∈ ?K .⊥. ?φ⟧ ⟹ ?B = Cn ?B›*) tautology_selection (*‹⟦?K = Cn ?A; ?K .⊥. ?φ = {}⟧ ⟹ γ ?K ?φ = {?K}›*)) (*proven 2 subgoals*) . from Cn_Inter[OF this] (*‹⋂ (γ ((Cn::'a set ⇒ 'a set) (A::'a set)) (φ::'a)) = Cn (⋂ (γ (Cn A) φ))›*) show "?case" (*goal: ‹(Cn::'a set ⇒ 'a set) (⋂ (γ (Cn (A::'a set)) (φ::'a))) ⊆ ⋂ (γ (Cn A) φ)›*) by blast qed text ‹@{text ‹pmc_extensionality›} : Extensionality guarantees that the logic of contraction is extensional in the sense of allowing logically equivalent sentences to be freely substituted for each other› lemma pmc_extensionality: ‹K = Cn(A) ⟹ Cn({φ}) = Cn({ψ}) ⟹ K ÷⇘γ⇙ φ = K ÷⇘γ⇙ ψ› by (metis extensional_selection (*‹⟦?K = Cn ?A; Cn {?φ} = Cn {?ψ}⟧ ⟹ γ ?K ?φ = γ ?K ?ψ›*) mc (*‹?A ÷⇘?γ⇙ ?φ ≡ ⋂ (?γ ?A ?φ)›*)) text ‹@{text ‹pmc_tautology›} : if @{term ‹φ›} is a tautology then the partial meet contraction of @{term ‹K›} by @{term ‹φ›} is @{term ‹K›}› lemma pmc_tautology: ‹K = Cn(A) ⟹ ⊩ φ ⟹ K ÷⇘γ⇙ φ = K› by (simp add: mc (*‹(?A::'a set) ÷⇘(?γ::'a set ⇒ 'a ⇒ 'a set set)⇙ (?φ::'a) ≡ ⋂ (?γ ?A ?φ)›*) taut2emptyrem (*‹⊩ (?φ::'a) ⟹ (?A::'a set) .⊥. ?φ = {}›*) tautology_selection (*‹⟦(?K::'a set) = (Cn::'a set ⇒ 'a set) (?A::'a set); ?K .⊥. (?φ::'a) = {}⟧ ⟹ γ ?K ?φ = {?K}›*)) text‹@{text ‹completion›} is a an operator that can build an equivalent selection from an existing one› definition (in Tarskian_logic) completion::‹('a set ⇒ 'a ⇒ 'a set set) ⇒ 'a set ⇒ 'a ⇒ 'a set set› (‹*›) where ‹* γ A φ ≡ if (A .⊥. φ) = {} then {A} else {B. B ∈ A .⊥. φ ∧ ⋂ (γ A φ) ⊆ B}› lemma selection_completion: "K = Cn(A) ⟹ γ K φ ⊆ * γ K φ" using completion_def (*‹* ?γ ?A ?φ ≡ if ?A .⊥. ?φ = {} then {?A} else {B ∈ ?A .⊥. ?φ. ⋂ (?γ ?A ?φ) ⊆ B}›*) is_selection (*‹⟦(?K::'a set) = (Cn::'a set ⇒ 'a set) (?A::'a set); ?K .⊥. (?φ::'a) ≠ {}⟧ ⟹ γ ?K ?φ ⊆ ?K .⊥. ?φ›*) tautology_selection (*‹⟦(?K::'a::type set) = (Cn::'a::type set ⇒ 'a::type set) (?A::'a::type set); ?K .⊥. (?φ::'a::type) = {}⟧ ⟹ γ ?K ?φ = {?K}›*) by fastforce lemma (in Tarskian_logic) completion_completion: "K = Cn(A) ⟹ * (* γ) K φ = * γ K φ" by (auto simp add:completion_def (*‹* ?γ ?A ?φ ≡ if ?A .⊥. ?φ = {} then {?A} else {B ∈ ?A .⊥. ?φ. ⋂ (?γ ?A ?φ) ⊆ B}›*)) lemma pmc_completion: ‹K = Cn(A) ⟹ K ÷⇘*γ⇙ φ = K ÷⇘γ⇙ φ› apply (auto simp add: mc (*‹(?A::'a set) ÷⇘(?γ::'a set ⇒ 'a ⇒ 'a set set)⇙ (?φ::'a) ≡ ⋂ (?γ ?A ?φ)›*) completion_def (*‹* (?γ::'a set ⇒ 'a ⇒ 'a set set) (?A::'a set) (?φ::'a) ≡ if ?A .⊥. ?φ = {} then {?A} else {B::'a set ∈ ?A .⊥. ?φ. ⋂ (?γ ?A ?φ) ⊆ B}›*) tautology_selection (*‹⟦(?K::'a set) = (Cn::'a set ⇒ 'a set) (?A::'a set); ?K .⊥. (?φ::'a) = {}⟧ ⟹ γ ?K ?φ = {?K}›*)) (*goal: ‹K = Cn A ⟹ K ÷⇘* γ⇙ φ = K ÷⇘γ⇙ φ›*) by (metis Inter_lower (*‹?B ∈ ?A ⟹ ⋂ ?A ⊆ ?B›*) equals0D (*‹?A = {} ⟹ ?a ∉ ?A›*) in_mono (*‹?A ⊆ ?B ⟹ ?x ∈ ?A ⟶ ?x ∈ ?B›*) is_selection (*‹⟦?K = Cn ?A; ?K .⊥. ?φ ≠ {}⟧ ⟹ γ ?K ?φ ⊆ ?K .⊥. ?φ›*)) end text‹A transitively relational meet contraction is a partial meet contraction using a binary relation between the elements of the selection function› text‹A relation is : ▪ transitive (@{text ‹trans_rel›}) ▪ non empty (there is always an element preferred to the others (@{text ‹nonempty_rel›}))› text‹A selection function @{term ‹γ⇩T⇩R›} is transitively relational @{text ‹rel_sel›} with the following condition : ▪ If the the remainders @{text ‹K .⊥. φ›} is empty then the selection function return @{term ‹K›} ▪ Else the selection function return a non empty transitive relation on the remainders› locale TransitivelyRelationalMeetContraction = Tarskian_logic + fixes relation::‹'a set ⇒ 'a set ⇒ 'a set ⇒ bool› (‹_ ≼⇘_⇙ _› [60,50,60]55) assumes trans_rel: ‹K = Cn(A) ⟹ B ≼⇘K⇙ C ⟹ C ≼⇘K⇙ D ⟹ B ≼⇘K⇙ D› assumes nonempty_rel: ‹K = Cn(A) ⟹ (K .⊥. φ) ≠ {} ⟹ ∃B∈(K .⊥. φ). (∀C∈(K .⊥. φ). C ≼⇘K⇙ B)› ― ‹pas clair dans la litterrature› fixes rel_sel::‹'a set ⇒ 'a ⇒ 'a set set› (‹γ⇩T⇩R›) defines rel_sel: ‹γ⇩T⇩R K φ ≡ if (K .⊥. φ) = {} then {K} else {B. B∈(K .⊥. φ) ∧ (∀C∈(K .⊥. φ). C ≼⇘K⇙ B)}› begin text‹A transitively relational selection function respect the partial meet contraction postulates.› sublocale PartialMeetContraction where selection = γ⇩T⇩R apply unfold_locales (*top goal: ‹PartialMeetContraction Cn γ⇩T⇩R› and 3 goals remain*) apply (simp_all add: rel_sel) (*top goal: ‹⋀K A φ. ⟦K = Cn A; K .⊥. φ ≠ {}⟧ ⟹ γ⇩T⇩R K φ ⊆ K .⊥. φ› and 3 goals remain*) using nonempty_rel (*‹⟦?K = Cn ?A; ?K .⊥. ?φ ≠ {}⟧ ⟹ ∃B∈?K .⊥. ?φ. ∀C∈?K .⊥. ?φ. C ≼⇘?K⇙ B›*) apply blast (*top goal: ‹⋀K A φ. K = Cn A ⟹ Cn A .⊥. φ ≠ {} ⟶ (∃x. x ∈ Cn A .⊥. φ ∧ (∀C∈Cn A .⊥. φ. C ≼⇘Cn A⇙ x))› and 1 goal remains*) using remainder_extensionality (*‹Cn {?φ} = Cn {?ψ} ⟹ ?A .⊥. ?φ = ?A .⊥. ?ψ›*) by blast end text‹A full meet contraction is a limiting case of the partial meet contraction where if the remainders are not empty then the selection function return all the remainders (as defined by @{text ‹full_sel›}› locale FullMeetContraction = Tarskian_logic + fixes full_sel::‹'a set ⇒ 'a ⇒ 'a set set› (‹γ⇩F⇩C›) defines full_sel: ‹γ⇩F⇩C K φ ≡ if K .⊥. φ = {} then {K} else K .⊥. φ› begin text‹A full selection and a relation ? is a transitively relational meet contraction postulates.› sublocale TransitivelyRelationalMeetContraction where relation = ‹λ K A B. True› and rel_sel=γ⇩F⇩C (*goals: 1. ‹TransitivelyRelationalMeetContraction Cn (λK A B. True)› 2. ‹⋀A φ. A ⊢ φ ≡ φ ∈ Cn A› 3. ‹⋀φ. ⊩ φ ≡ {} ⊢ φ› 4. ‹⋀A φ. A ⊕ φ ≡ Cn (A ∪ {φ})› 5. ‹⋀K φ. γ⇩F⇩C K φ ≡ if K .⊥. φ = {} then {K} else {B ∈ K .⊥. φ. ∀C∈K .⊥. φ. True}› discuss goal 1*) apply ((unfold_locales)[1]) (*goals: 1. ‹⋀(K::'a set) (A::'a set) (B::'a set) (C::'a set) D::'a set. ⟦K = (Cn::'a set ⇒ 'a set) A; True; True⟧ ⟹ True› 2. ‹⋀(K::'a set) (A::'a set) φ::'a. ⟦K = (Cn::'a set ⇒ 'a set) A; K .⊥. φ ≠ {}⟧ ⟹ ∃B::'a set∈K .⊥. φ. ∀C::'a set∈K .⊥. φ. True› discuss goal 1*) apply ((auto simp add:full_sel (*‹γ⇩F⇩C ?K ?φ ≡ if ?K .⊥. ?φ = {} then {?K} else ?K .⊥. ?φ›*))[1]) (*discuss goal 2*) apply ((auto simp add:full_sel (*‹γ⇩F⇩C ?K ?φ ≡ if ?K .⊥. ?φ = {} then {?K} else ?K .⊥. ?φ›*))[1]) (*proven 2 subgoals*) (*discuss goal 2*) apply ((unfold_locales)[1]) (*discuss goal 3*) apply ((unfold_locales)[1]) (*discuss goal 4*) apply ((unfold_locales)[1]) (*discuss goal 5*) apply ((unfold_locales)[1]) (*goal: ‹⋀(K::'a set) φ::'a. γ⇩F⇩C K φ ≡ if K .⊥. φ = {} then {K} else {B::'a set ∈ K .⊥. φ. ∀C::'a set∈K .⊥. φ. True}›*) apply ((auto simp add:full_sel (*‹γ⇩F⇩C ?K ?φ ≡ if ?K .⊥. ?φ = {} then {?K} else ?K .⊥. ?φ›*))[1]) (*goal: ‹⋀K φ. γ⇩F⇩C K φ ≡ if K .⊥. φ = {} then {K} else {B ∈ K .⊥. φ. ∀C∈K .⊥. φ. True}›*) apply (rule eq_reflection (*‹?x = ?y ⟹ ?x ≡ ?y›*)) (*goal: ‹⋀K φ. if K .⊥. φ = {} then {K} else K .⊥. φ ≡ if K .⊥. φ = {} then {K} else {B ∈ K .⊥. φ. ∀C∈K .⊥. φ. True}›*) apply simp (*proven 5 subgoals*) . end subsection‹Equivalence of partial meet contraction and AGM contraction› locale PMC_SC = PartialMeetContraction + Supraclassical_logic + Compact_logic begin text ‹In a context of a supraclassical and a compact logic the two remaining postulates of AGM contraction : ▪ @{text ‹contract_recovery›} ▪ @{text ‹contract_success›} can be proved on a partial meet contraction.› text‹@{text ‹pmc_recovery›} : all proposition removed by a partial meet contraction of @{term ‹φ›} will be recovered by the expansion of @{term ‹φ›}› ― ‹recovery requires supraclassicality› lemma pmc_recovery: ‹K = Cn(A) ⟹ K ⊆ ((K ÷⇘γ⇙ φ) ⊕ φ)› apply (cases ‹(K .⊥. φ) = {}›, simp_all (no_asm) add:mc expansion_def) (*goal: ‹K = Cn A ⟹ K ⊆ (K ÷⇘γ⇙ φ) ⊕ φ›*) using inclusion_L (*‹(?A::'a::type set) ⊆ (Cn::'a::type set ⇒ 'a::type set) ?A›*) tautology_selection (*‹⟦?K = Cn ?A; ?K .⊥. ?φ = {}⟧ ⟹ γ ?K ?φ = {?K}›*) proof (fastforce) (*goal: ‹⟦K = Cn A; K .⊥. φ ≠ {}⟧ ⟹ K ⊆ Cn (insert φ (⋂ (γ K φ)))›*) assume a: "K = Cn(A)" and b: "K .⊥. φ ≠ {}" (*‹(K::'a set) = (Cn::'a set ⇒ 'a set) (A::'a set)› ‹(K::'a set) .⊥. (φ::'a) ≠ {}›*) { fix ψ assume d: "K ⊢ ψ" (*‹(K::'a set) ⊢ (ψ::'a)›*) have "φ .⟶. ψ ∈ ⋂(γ K φ)" using is_selection[OF a b] (*‹γ K φ ⊆ K .⊥. φ›*) apply auto (*goal: ‹φ .⟶. ψ ∈ ⋂ (γ K φ)›*) by (metis a (*‹(K::'a set) = (Cn::'a set ⇒ 'a set) (A::'a set)›*) d (*‹(K::'a set) ⊢ (ψ::'a)›*) infer_def (*‹(?A::'a set) ⊢ (?φ::'a) ≡ ?φ ∈ (Cn::'a set ⇒ 'a set) ?A›*) rem_closure (*‹⟦(?K::'a set) = (Cn::'a set ⇒ 'a set) (?A::'a set); (?B::'a set) ∈ ?K .⊥. (?φ::'a)⟧ ⟹ ?B = Cn ?B›*) remainder_recovery (*‹⟦(?K::'a set) = (Cn::'a set ⇒ 'a set) (?A::'a set); ?K ⊢ (?ψ::'a); (?B::'a set) ∈ ?K .⊥. (?φ::'a)⟧ ⟹ ?B ⊢ ?φ .⟶. ?ψ›*) subsetD (*‹⟦(?A::?'a set) ⊆ (?B::?'a set); (?c::?'a) ∈ ?A⟧ ⟹ ?c ∈ ?B›*)) } with a (*‹K = Cn A›*) b (*‹K .⊥. φ ≠ {}›*) show "K ⊆ Cn (insert φ (⋂ (γ K φ)))" by (metis (no_types, lifting) Un_commute (*‹(?A::?'a set) ∪ (?B::?'a set) = ?B ∪ ?A›*) assumption_L (*‹(?φ::'a) ∈ (?A::'a set) ⟹ ?A ⊢ ?φ›*) imp_PL (*‹((?A::'a set) ⊢ (?p::'a) .⟶. (?q::'a)) = (?A ∪ {?p} ⊢ ?q)›*) infer_def (*‹(?A::'a set) ⊢ (?φ::'a) ≡ ?φ ∈ (Cn::'a set ⇒ 'a set) ?A›*) insert_is_Un (*‹insert (?a::?'a) (?A::?'a set) = {?a} ∪ ?A›*) subsetI (*‹(⋀x::?'a. x ∈ (?A::?'a set) ⟹ x ∈ (?B::?'a set)) ⟹ ?A ⊆ ?B›*)) qed text ‹@{text ‹pmc_success›} : a partial meet contraction of @{term ‹K›} by @{term ‹φ›} not imply @{term ‹φ›}› ― ‹success requires compacteness› lemma pmc_success: ‹K = Cn(A) ⟹ φ ∉ Cn({}) ⟹ φ ∉ K ÷⇘γ⇙ φ› proof (standard) (*goal: ‹⟦(K::'a set) = (Cn::'a set ⇒ 'a set) (A::'a set); (φ::'a) ∉ Cn {}; φ ∈ K ÷⇘γ⇙ φ⟧ ⟹ False›*) assume a: "K = Cn(A)" and b: "φ ∉ Cn({})" and c: "φ ∈ K ÷⇘γ⇙ φ" (*‹(K::'a set) = (Cn::'a set ⇒ 'a set) (A::'a set)› ‹(φ::'a) ∉ (Cn::'a set ⇒ 'a set) {}› ‹(φ::'a) ∈ (K::'a set) ÷⇘γ⇙ φ›*) from c (*‹(φ::'a) ∈ (K::'a set) ÷⇘γ⇙ φ›*) show False unfolding mc (*goal: ‹False›*) proof (cases ‹K .⊥. φ = {K}›) (*goals: 1. ‹⟦φ ∈ ⋂ (γ K φ); K .⊥. φ = {K}⟧ ⟹ False› 2. ‹⟦φ ∈ ⋂ (γ K φ); K .⊥. φ ≠ {K}⟧ ⟹ False›*) case True (*‹K .⊥. φ = {K}›*) then show "?thesis" (*goal: ‹False›*) by (meson assumption_L (*‹?φ ∈ ?A ⟹ ?A ⊢ ?φ›*) c (*‹φ ∈ K ÷⇘γ⇙ φ›*) nonconsequence_remainder (*‹(?A .⊥. ?φ = {?A}) = (¬ ?A ⊢ ?φ)›*) pmc_inclusion[OF a] (*‹K ÷⇘γ⇙ ?φ ⊆ K›*) subsetD (*‹⟦?A ⊆ ?B; ?c ∈ ?A⟧ ⟹ ?c ∈ ?B›*)) next (*goal: ‹⟦φ ∈ ⋂ (γ K φ); K .⊥. φ ≠ {K}⟧ ⟹ False›*) case False (*‹K .⊥. φ ≠ {K}›*) hence "∀B∈K .⊥. φ. φ ∉ B" using assumption_L (*‹?φ ∈ ?A ⟹ ?A ⊢ ?φ›*) rem (*‹?A .⊥. ?φ ≡ {B. B ⊆ ?A ∧ ¬ B ⊢ ?φ ∧ (∀B'⊆?A. B ⊂ B' ⟶ B' ⊢ ?φ)}›*) by auto moreover have "K .⊥. φ ≠ {}" using b (*‹φ ∉ Cn {}›*) emptyrem2taut (*‹?A .⊥. ?φ = {} ⟹ ⊩ ?φ›*) validD_L (*‹⊩ ?φ ⟹ ?φ ∈ Cn ?A›*) by blast ultimately show "?thesis" (*goal: ‹False›*) using b (*‹(φ::'a) ∉ (Cn::'a set ⇒ 'a set) {}›*) c (*‹φ ∈ K ÷⇘γ⇙ φ›*) mc (*‹?A ÷⇘?γ⇙ ?φ ≡ ⋂ (?γ ?A ?φ)›*) nonempty_selection[OF a] (*‹γ K ?φ ≠ {}›*) validD_L (*‹⊩ ?φ ⟹ ?φ ∈ Cn ?A›*) emptyrem2taut (*‹?A .⊥. ?φ = {} ⟹ ⊩ ?φ›*) is_selection[OF a] (*‹(K::'a set) .⊥. (?φ::'a) ≠ {} ⟹ γ K ?φ ⊆ K .⊥. ?φ›*) by (metis Inter_iff (*‹((?A::?'a::type) ∈ ⋂ (?C::?'a::type set set)) = (∀X::?'a::type set∈?C. ?A ∈ X)›*) bot.extremum_uniqueI (*‹(?a::?'a::order_bot) ≤ bot ⟹ ?a = bot›*) subset_iff (*‹((?A::?'a::type set) ⊆ (?B::?'a::type set)) = (∀t::?'a::type. t ∈ ?A ⟶ t ∈ ?B)›*)) qed qed text‹As a partial meet contraction has been proven to respect all postulates of AGM contraction the equivalence between the both are straightforward› sublocale AGM_Contraction where contraction = ‹λA φ. A ÷⇘γ⇙ φ› using pmc_closure (*‹?K = Cn ?A ⟹ ?K ÷⇘γ⇙ ?φ = Cn (?K ÷⇘γ⇙ ?φ)›*) pmc_inclusion (*‹?K = Cn ?A ⟹ ?K ÷⇘γ⇙ ?φ ⊆ ?K›*) pmc_vacuity (*‹⟦(?K::'a set) = (Cn::'a set ⇒ 'a set) (?A::'a set); ¬ ?K ⊢ (?φ::'a)⟧ ⟹ ?K ÷⇘γ⇙ ?φ = ?K›*) pmc_success (*‹⟦?K = Cn ?A; ?φ ∉ Cn {}⟧ ⟹ ?φ ∉ ?K ÷⇘γ⇙ ?φ›*) pmc_recovery (*‹?K = Cn ?A ⟹ ?K ⊆ (?K ÷⇘γ⇙ ?φ) ⊕ ?φ›*) pmc_extensionality (*‹⟦?K = Cn ?A; Cn {?φ} = Cn {?ψ}⟧ ⟹ ?K ÷⇘γ⇙ ?φ = ?K ÷⇘γ⇙ ?ψ›*) expansion_def (*‹?A ⊕ ?φ ≡ Cn (?A ∪ {?φ})›*) idempotency_L (*‹Cn (Cn ?A) = Cn ?A›*) infer_def (*‹?A ⊢ ?φ ≡ ?φ ∈ Cn ?A›*) (*goals: 1. ‹AGM_Contraction Cn (λA. meet_contraction A γ)› 2. ‹⋀A φ. A ⊢ φ ≡ φ ∈ Cn A› 3. ‹⋀φ. ⊩ φ ≡ {} ⊢ φ› 4. ‹⋀A φ. A ⊕ φ ≡ Cn (A ∪ {φ})› discuss goal 1*) apply ((unfold_locales)[1]) (*goals: 1. ‹⋀K A φ. ⟦⋀K A φ. K = Cn A ⟹ K ÷⇘γ⇙ φ = Cn (K ÷⇘γ⇙ φ); ⋀K A φ. K = Cn A ⟹ K ÷⇘γ⇙ φ ⊆ K; ⋀K A φ. ⟦K = Cn A; ¬ K ⊢ φ⟧ ⟹ K ÷⇘γ⇙ φ = K; ⋀K A φ. ⟦K = Cn A; φ ∉ Cn {}⟧ ⟹ φ ∉ K ÷⇘γ⇙ φ; ⋀K A φ. K = Cn A ⟹ K ⊆ (K ÷⇘γ⇙ φ) ⊕ φ; ⋀K A φ ψ. ⟦K = Cn A; Cn {φ} = Cn {ψ}⟧ ⟹ K ÷⇘γ⇙ φ = K ÷⇘γ⇙ ψ; ⋀A φ. A ⊕ φ ≡ Cn (A ∪ {φ}); ⋀A. Cn (Cn A) = Cn A; ⋀A φ. A ⊢ φ ≡ φ ∈ Cn A; K = Cn A⟧ ⟹ K ÷⇘γ⇙ φ = Cn (K ÷⇘γ⇙ φ)› 2. ‹⋀K A φ. ⟦⋀K A φ. K = Cn A ⟹ K ÷⇘γ⇙ φ = Cn (K ÷⇘γ⇙ φ); ⋀K A φ. K = Cn A ⟹ K ÷⇘γ⇙ φ ⊆ K; ⋀K A φ. ⟦K = Cn A; ¬ K ⊢ φ⟧ ⟹ K ÷⇘γ⇙ φ = K; ⋀K A φ. ⟦K = Cn A; φ ∉ Cn {}⟧ ⟹ φ ∉ K ÷⇘γ⇙ φ; ⋀K A φ. K = Cn A ⟹ K ⊆ (K ÷⇘γ⇙ φ) ⊕ φ; ⋀K A φ ψ. ⟦K = Cn A; Cn {φ} = Cn {ψ}⟧ ⟹ K ÷⇘γ⇙ φ = K ÷⇘γ⇙ ψ; ⋀A φ. A ⊕ φ ≡ Cn (A ∪ {φ}); ⋀A. Cn (Cn A) = Cn A; ⋀A φ. A ⊢ φ ≡ φ ∈ Cn A; K = Cn A⟧ ⟹ K ÷⇘γ⇙ φ ⊆ K› 3. ‹⋀K A φ. ⟦⋀K A φ. K = Cn A ⟹ K ÷⇘γ⇙ φ = Cn (K ÷⇘γ⇙ φ); ⋀K A φ. K = Cn A ⟹ K ÷⇘γ⇙ φ ⊆ K; ⋀K A φ. ⟦K = Cn A; ¬ K ⊢ φ⟧ ⟹ K ÷⇘γ⇙ φ = K; ⋀K A φ. ⟦K = Cn A; φ ∉ Cn {}⟧ ⟹ φ ∉ K ÷⇘γ⇙ φ; ⋀K A φ. K = Cn A ⟹ K ⊆ (K ÷⇘γ⇙ φ) ⊕ φ; ⋀K A φ ψ. ⟦K = Cn A; Cn {φ} = Cn {ψ}⟧ ⟹ K ÷⇘γ⇙ φ = K ÷⇘γ⇙ ψ; ⋀A φ. A ⊕ φ ≡ Cn (A ∪ {φ}); ⋀A. Cn (Cn A) = Cn A; ⋀A φ. A ⊢ φ ≡ φ ∈ Cn A; K = Cn A; φ ∉ K⟧ ⟹ K ÷⇘γ⇙ φ = K› 4. ‹⋀K A φ. ⟦⋀K A φ. K = Cn A ⟹ K ÷⇘γ⇙ φ = Cn (K ÷⇘γ⇙ φ); ⋀K A φ. K = Cn A ⟹ K ÷⇘γ⇙ φ ⊆ K; ⋀K A φ. ⟦K = Cn A; ¬ K ⊢ φ⟧ ⟹ K ÷⇘γ⇙ φ = K; ⋀K A φ. ⟦K = Cn A; φ ∉ Cn {}⟧ ⟹ φ ∉ K ÷⇘γ⇙ φ; ⋀K A φ. K = Cn A ⟹ K ⊆ (K ÷⇘γ⇙ φ) ⊕ φ; ⋀K A φ ψ. ⟦K = Cn A; Cn {φ} = Cn {ψ}⟧ ⟹ K ÷⇘γ⇙ φ = K ÷⇘γ⇙ ψ; ⋀A φ. A ⊕ φ ≡ Cn (A ∪ {φ}); ⋀A. Cn (Cn A) = Cn A; ⋀A φ. A ⊢ φ ≡ φ ∈ Cn A; K = Cn A; φ ∉ Cn {}⟧ ⟹ φ ∉ K ÷⇘γ⇙ φ› 5. ‹⋀K A φ. ⟦⋀K A φ. K = Cn A ⟹ K ÷⇘γ⇙ φ = Cn (K ÷⇘γ⇙ φ); ⋀K A φ. K = Cn A ⟹ K ÷⇘γ⇙ φ ⊆ K; ⋀K A φ. ⟦K = Cn A; ¬ K ⊢ φ⟧ ⟹ K ÷⇘γ⇙ φ = K; ⋀K A φ. ⟦K = Cn A; φ ∉ Cn {}⟧ ⟹ φ ∉ K ÷⇘γ⇙ φ; ⋀K A φ. K = Cn A ⟹ K ⊆ (K ÷⇘γ⇙ φ) ⊕ φ; ⋀K A φ ψ. ⟦K = Cn A; Cn {φ} = Cn {ψ}⟧ ⟹ K ÷⇘γ⇙ φ = K ÷⇘γ⇙ ψ; ⋀A φ. A ⊕ φ ≡ Cn (A ∪ {φ}); ⋀A. Cn (Cn A) = Cn A; ⋀A φ. A ⊢ φ ≡ φ ∈ Cn A; K = Cn A⟧ ⟹ K ⊆ Cn ((K ÷⇘γ⇙ φ) ∪ {φ})› 6. ‹⋀K A φ ψ. ⟦⋀K A φ. K = Cn A ⟹ K ÷⇘γ⇙ φ = Cn (K ÷⇘γ⇙ φ); ⋀K A φ. K = Cn A ⟹ K ÷⇘γ⇙ φ ⊆ K; ⋀K A φ. ⟦K = Cn A; ¬ K ⊢ φ⟧ ⟹ K ÷⇘γ⇙ φ = K; ⋀K A φ. ⟦K = Cn A; φ ∉ Cn {}⟧ ⟹ φ ∉ K ÷⇘γ⇙ φ; ⋀K A φ. K = Cn A ⟹ K ⊆ (K ÷⇘γ⇙ φ) ⊕ φ; ⋀K A φ ψ. ⟦K = Cn A; Cn {φ} = Cn {ψ}⟧ ⟹ K ÷⇘γ⇙ φ = K ÷⇘γ⇙ ψ; ⋀A φ. A ⊕ φ ≡ Cn (A ∪ {φ}); ⋀A. Cn (Cn A) = Cn A; ⋀A φ. A ⊢ φ ≡ φ ∈ Cn A; K = Cn A; Cn {φ} = Cn {ψ}⟧ ⟹ K ÷⇘γ⇙ φ = K ÷⇘γ⇙ ψ› 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 (*discuss goal 6*) apply metis (*proven 6 subgoals*) (*discuss goal 2*) apply ((unfold_locales)[1]) (*discuss goal 3*) apply ((unfold_locales)[1]) (*discuss goal 4*) apply ((unfold_locales)[1]) (*proven 4 subgoals*) . end locale AGMC_SC = AGM_Contraction + Supraclassical_logic + Compact_logic begin text ‹obs 2.5 page 514› definition AGM_selection::‹'a set ⇒ 'a ⇒ 'a set set› (‹γ⇩A⇩G⇩M›) where AGM_sel: ‹γ⇩A⇩G⇩M A φ ≡ if A .⊥. φ = {} then {A} else {B. B ∈ A .⊥. φ ∧ A ÷ φ ⊆ B}› text‹The selection function @{term ‹γ⇩A⇩G⇩M›} respect the partial meet contraction postulates› sublocale PartialMeetContraction where selection = γ⇩A⇩G⇩M proof (unfold_locales, unfold AGM_sel (*‹γ⇩A⇩G⇩M ?A ?φ ≡ if ?A .⊥. ?φ = {} then {?A} else {B ∈ ?A .⊥. ?φ. ?A ÷ ?φ ⊆ B}›*), simp_all, goal_cases) (*goals: 1. ‹⋀K A φ. K = Cn A ⟹ Cn A .⊥. φ ≠ {} ⟶ (∃x. x ∈ Cn A .⊥. φ ∧ Cn A ÷ φ ⊆ x)› 2. ‹⋀K A φ ψ. ⟦K = Cn A; Cn {φ} = Cn {ψ}⟧ ⟹ (Cn A .⊥. φ = {} ⟶ Cn A .⊥. ψ ≠ {} ⟶ {Cn A} = {B ∈ Cn A .⊥. ψ. Cn A ÷ ψ ⊆ B}) ∧ (Cn A .⊥. φ ≠ {} ⟶ (Cn A .⊥. ψ = {} ⟶ {B ∈ Cn A .⊥. φ. Cn A ÷ φ ⊆ B} = {Cn A}) ∧ (Cn A .⊥. ψ ≠ {} ⟶ {B ∈ Cn A .⊥. φ. Cn A ÷ φ ⊆ B} = {B ∈ Cn A .⊥. ψ. Cn A ÷ ψ ⊆ B}))›*) case (1 K A φ) (*‹K = Cn A›*) then show "?case" (*goal: ‹Cn A .⊥. φ ≠ {} ⟶ (∃x. x ∈ Cn A .⊥. φ ∧ Cn A ÷ φ ⊆ x)›*) using upper_remainder[of ‹K ÷ φ› K φ] (*‹⟦K ÷ φ ⊆ K; ¬ K ÷ φ ⊢ φ⟧ ⟹ ∃B'. K ÷ φ ⊆ B' ∧ B' ∈ K .⊥. φ›*) contract_success[OF 1 ( 1 )] (*‹?φ ∉ Cn {} ⟹ ?φ ∉ K ÷ ?φ›*) by (metis contract_closure (*‹?K = Cn ?A ⟹ ?K ÷ ?φ = Cn (?K ÷ ?φ)›*) contract_inclusion (*‹?K = Cn ?A ⟹ ?K ÷ ?φ ⊆ ?K›*) infer_def (*‹?A ⊢ ?φ ≡ ?φ ∈ Cn ?A›*) taut2emptyrem (*‹⊩ ?φ ⟹ ?A .⊥. ?φ = {}›*) valid_def (*‹⊩ ?φ ≡ {} ⊢ ?φ›*)) next (*goal: ‹⋀K A φ ψ. ⟦K = Cn A; Cn {φ} = Cn {ψ}⟧ ⟹ (Cn A .⊥. φ = {} ⟶ Cn A .⊥. ψ ≠ {} ⟶ {Cn A} = {B ∈ Cn A .⊥. ψ. Cn A ÷ ψ ⊆ B}) ∧ (Cn A .⊥. φ ≠ {} ⟶ (Cn A .⊥. ψ = {} ⟶ {B ∈ Cn A .⊥. φ. Cn A ÷ φ ⊆ B} = {Cn A}) ∧ (Cn A .⊥. ψ ≠ {} ⟶ {B ∈ Cn A .⊥. φ. Cn A ÷ φ ⊆ B} = {B ∈ Cn A .⊥. ψ. Cn A ÷ ψ ⊆ B}))›*) case (2 K A φ ψ) (*‹K = Cn A› ‹(Cn::'a set ⇒ 'a set) {φ::'a} = Cn {ψ::'a}›*) then show "?case" (*goal: ‹((Cn::'a::type set ⇒ 'a::type set) (A::'a::type set) .⊥. (φ::'a::type) = {} ⟶ Cn A .⊥. (ψ::'a::type) ≠ {} ⟶ {Cn A} = {B::'a::type set ∈ Cn A .⊥. ψ. Cn A ÷ ψ ⊆ B}) ∧ (Cn A .⊥. φ ≠ {} ⟶ (Cn A .⊥. ψ = {} ⟶ {B::'a::type set ∈ Cn A .⊥. φ. Cn A ÷ φ ⊆ B} = {Cn A}) ∧ (Cn A .⊥. ψ ≠ {} ⟶ {B::'a::type set ∈ Cn A .⊥. φ. Cn A ÷ φ ⊆ B} = {B::'a::type set ∈ Cn A .⊥. ψ. Cn A ÷ ψ ⊆ B}))›*) by (metis (mono_tags, lifting) contract_extensionality (*‹⟦?K = Cn ?A; Cn {?φ} = Cn {?ψ}⟧ ⟹ ?K ÷ ?φ = ?K ÷ ?ψ›*) Collect_cong (*‹(⋀x. ?P x = ?Q x) ⟹ {x. ?P x} = {x. ?Q x}›*) remainder_extensionality (*‹Cn {?φ} = Cn {?ψ} ⟹ ?A .⊥. ?φ = ?A .⊥. ?ψ›*)) qed text ‹@{text ‹contraction_is_pmc›} : an AGM contraction is equivalent to a partial met contraction using the selection function ‹γ⇩A⇩G⇩M›› lemma contraction_is_pmc: ‹K = Cn(A) ⟹ K ÷ φ = K ÷⇘γ⇩A⇩G⇩M⇙ φ› ― ‹requires a supraclassical logic› proof (standard) (*goals: 1. ‹K = Cn A ⟹ K ÷ φ ⊆ K ÷⇘γ⇩A⇩G⇩M⇙ φ› 2. ‹K = Cn A ⟹ K ÷⇘γ⇩A⇩G⇩M⇙ φ ⊆ K ÷ φ›*) assume a: "K = Cn(A)" (*‹(K::'a set) = (Cn::'a set ⇒ 'a set) (A::'a set)›*) show "K ÷ φ ⊆ K ÷⇘γ⇩A⇩G⇩M⇙ φ" using contract_inclusion[OF a] (*‹K ÷ ?φ ⊆ K›*) by (auto simp add:mc (*‹(?A::'a::type set) ÷⇘(?γ::'a::type set ⇒ 'a::type ⇒ 'a::type set set)⇙ (?φ::'a::type) ≡ ⋂ (?γ ?A ?φ)›*) AGM_sel (*‹γ⇩A⇩G⇩M (?A::'a::type set) (?φ::'a::type) ≡ if ?A .⊥. ?φ = {} then {?A} else {B::'a::type set ∈ ?A .⊥. ?φ. ?A ÷ ?φ ⊆ B}›*)) next (*goal: ‹K = Cn A ⟹ K ÷⇘γ⇩A⇩G⇩M⇙ φ ⊆ K ÷ φ›*) assume a: "K = Cn(A)" (*‹(K::'a set) = (Cn::'a set ⇒ 'a set) (A::'a set)›*) show "K ÷⇘γ⇩A⇩G⇩M⇙ φ ⊆ K ÷ φ" proof (cases ‹⊩ φ›) (*goals: 1. ‹⊩ φ ⟹ K ÷⇘γ⇩A⇩G⇩M⇙ φ ⊆ K ÷ φ› 2. ‹¬ ⊩ φ ⟹ K ÷⇘γ⇩A⇩G⇩M⇙ φ ⊆ K ÷ φ›*) case True (*‹⊩ (φ::'a)›*) hence "K .⊥. φ = {}" using nonconsequence_remainder (*‹(?A .⊥. ?φ = {?A}) = (¬ ?A ⊢ ?φ)›*) taut2emptyrem (*‹⊩ ?φ ⟹ ?A .⊥. ?φ = {}›*) by auto then show "?thesis" (*goal: ‹(K::'a::type set) ÷⇘γ⇩A⇩G⇩M⇙ (φ::'a::type) ⊆ K ÷ φ›*) apply (simp add:mc (*‹?A ÷⇘?γ⇙ ?φ ≡ ⋂ (?γ ?A ?φ)›*) AGM_sel (*‹γ⇩A⇩G⇩M ?A ?φ ≡ if ?A .⊥. ?φ = {} then {?A} else {B ∈ ?A .⊥. ?φ. ?A ÷ ?φ ⊆ B}›*)) (*goal: ‹(K::'a::type set) ÷⇘γ⇩A⇩G⇩M⇙ (φ::'a::type) ⊆ K ÷ φ›*) by (metis a (*‹K = Cn A›*) emptyrem2taut (*‹?A .⊥. ?φ = {} ⟹ ⊩ ?φ›*) contract_closure (*‹?K = Cn ?A ⟹ ?K ÷ ?φ = Cn (?K ÷ ?φ)›*) contract_recovery (*‹?K = Cn ?A ⟹ ?K ⊆ (?K ÷ ?φ) ⊕ ?φ›*) valid_expansion (*‹⟦?K = Cn ?A; ⊩ ?φ⟧ ⟹ ?K ⊕ ?φ = ?K›*)) next (*goal: ‹¬ ⊩ φ ⟹ K ÷⇘γ⇩A⇩G⇩M⇙ φ ⊆ K ÷ φ›*) case validFalse: False (*‹¬ ⊩ φ›*) then show "?thesis" (*goal: ‹K ÷⇘γ⇩A⇩G⇩M⇙ φ ⊆ K ÷ φ›*) proof (cases ‹K ⊢ φ›) (*goals: 1. ‹⟦¬ ⊩ φ; K ⊢ φ⟧ ⟹ K ÷⇘γ⇩A⇩G⇩M⇙ φ ⊆ K ÷ φ› 2. ‹⟦¬ ⊩ φ; ¬ K ⊢ φ⟧ ⟹ K ÷⇘γ⇩A⇩G⇩M⇙ φ ⊆ K ÷ φ›*) case True (*‹K ⊢ φ›*) hence b: "K .⊥. φ ≠ {}" using emptyrem2taut (*‹?A .⊥. ?φ = {} ⟹ ⊩ ?φ›*) validFalse (*‹¬ ⊩ φ›*) by blast have d: "ψ ∈ K ⟹ φ .⟶. ψ ∈ K ÷ φ" for ψ using Supraclassical_logic.impI_PL (*‹⟦Supraclassical_logic ?Cn ?true_PL ?false_PL ?imp_PL ?not_PL ?conj_PL ?disj_PL ?equiv_PL; ?q ∈ ?Cn (?A ∪ {?p})⟧ ⟹ ?imp_PL ?p ?q ∈ ?Cn ?A›*) Supraclassical_logic_axioms (*‹Supraclassical_logic Cn ⊤ ⊥ (.⟶.) .¬ (.∧.) (.∨.) (.⟷.)›*) a (*‹K = Cn A›*) contract_closure (*‹?K = Cn ?A ⟹ ?K ÷ ?φ = Cn (?K ÷ ?φ)›*) contract_recovery (*‹?K = Cn ?A ⟹ ?K ⊆ (?K ÷ ?φ) ⊕ ?φ›*) expansion_def (*‹?A ⊕ ?φ ≡ Cn (?A ∪ {?φ})›*) by fastforce { fix ψ assume e: "ψ ∈ K " and f: "ψ ∉ K ÷ φ" (*‹(ψ::'a) ∈ (K::'a set)› ‹(ψ::'a) ∉ (K::'a set) ÷ (φ::'a)›*) have "(ψ .⟶. φ) .⟶. φ ∉ K ÷ φ" using imp_recovery2[of ‹K ÷ φ› φ ψ] (*‹⟦(K::'a set) ÷ (φ::'a) ⊢ φ .⟶. (ψ::'a); K ÷ φ ⊢ (ψ .⟶. φ) .⟶. φ⟧ ⟹ K ÷ φ ⊢ ψ›*) a (*‹K = Cn A›*) contract_closure (*‹?K = Cn ?A ⟹ ?K ÷ ?φ = Cn (?K ÷ ?φ)›*) d (*‹(?ψ::'a) ∈ (K::'a set) ⟹ (φ::'a) .⟶. ?ψ ∈ K ÷ φ›*) e (*‹ψ ∈ K›*) f (*‹ψ ∉ K ÷ φ›*) by auto hence g: "¬ (K ÷ φ) ∪ {ψ .⟶. φ} ⊢ φ" using a (*‹(K::'a set) = (Cn::'a set ⇒ 'a set) (A::'a set)›*) contract_closure (*‹?K = Cn ?A ⟹ ?K ÷ ?φ = Cn (?K ÷ ?φ)›*) impI_PL (*‹?A ∪ {?p} ⊢ ?q ⟹ ?A ⊢ ?p .⟶. ?q›*) by fastforce then obtain B where h: "(K ÷ φ) ∪ {ψ .⟶. φ} ⊆ B" and i: "B ∈ K .⊥. φ" (*goal: ‹(⋀B::'a::type set. ⟦((K::'a::type set) ÷ (φ::'a::type)) ∪ {(ψ::'a::type) .⟶. φ} ⊆ B; B ∈ K .⊥. φ⟧ ⟹ thesis::bool) ⟹ thesis›*) using upper_remainder[of ‹(K ÷ φ) ∪ {ψ .⟶. φ}› K φ] (*‹⟦(K ÷ φ) ∪ {ψ .⟶. φ} ⊆ K; ¬ (K ÷ φ) ∪ {ψ .⟶. φ} ⊢ φ⟧ ⟹ ∃B'. (K ÷ φ) ∪ {ψ .⟶. φ} ⊆ B' ∧ B' ∈ K .⊥. φ›*) a (*‹K = Cn A›*) True (*‹K ⊢ φ›*) contract_inclusion (*‹?K = Cn ?A ⟹ ?K ÷ ?φ ⊆ ?K›*) idempotency_L (*‹(Cn::'a set ⇒ 'a set) (Cn (?A::'a set)) = Cn ?A›*) impI2 (*‹?A ⊢ ?q ⟹ ?A ⊢ ?p .⟶. ?q›*) by auto hence j: "ψ ∉ Cn(B)" by (metis (no_types, lifting) CollectD (*‹?a ∈ {x. ?P x} ⟹ ?P ?a›*) mp_PL (*‹⟦?A ⊢ ?p .⟶. ?q; ?A ⊢ ?p⟧ ⟹ ?A ⊢ ?q›*) Un_insert_right (*‹?A ∪ insert ?a ?B = insert ?a (?A ∪ ?B)›*) a (*‹K = Cn A›*) infer_def (*‹?A ⊢ ?φ ≡ ?φ ∈ Cn ?A›*) insert_subset (*‹(insert ?x ?A ⊆ ?B) = (?x ∈ ?B ∧ ?A ⊆ ?B)›*) rem (*‹?A .⊥. ?φ ≡ {B. B ⊆ ?A ∧ ¬ B ⊢ ?φ ∧ (∀B'⊆?A. B ⊂ B' ⟶ B' ⊢ ?φ)}›*) rem_closure (*‹⟦?K = Cn ?A; ?B ∈ ?K .⊥. ?φ⟧ ⟹ ?B = Cn ?B›*)) have "ψ ∉ K ÷⇘γ⇩A⇩G⇩M⇙ φ" apply (simp add:mc (*‹?A ÷⇘?γ⇙ ?φ ≡ ⋂ (?γ ?A ?φ)›*) AGM_sel (*‹γ⇩A⇩G⇩M ?A ?φ ≡ if ?A .⊥. ?φ = {} then {?A} else {B ∈ ?A .⊥. ?φ. ?A ÷ ?φ ⊆ B}›*) b (*‹K .⊥. φ ≠ {}›*)) (*goal: ‹ψ ∉ K ÷⇘γ⇩A⇩G⇩M⇙ φ›*) apply (rule_tac x=B in exI (*‹?P ?x ⟹ ∃x. ?P x›*)) (*goal: ‹∃x. x ∈ K .⊥. φ ∧ K ÷ φ ⊆ x ∧ ψ ∉ x›*) by (meson Tarskian_logic.assumption_L (*‹⟦Tarskian_logic ?Cn; ?φ ∈ ?A⟧ ⟹ ?φ ∈ ?Cn ?A›*) Tarskian_logic_axioms (*‹Tarskian_logic Cn›*) h (*‹(K ÷ φ) ∪ {ψ .⟶. φ} ⊆ B›*) i (*‹B ∈ K .⊥. φ›*) j (*‹ψ ∉ Cn B›*) le_sup_iff (*‹(sup ?x ?y ≤ ?z) = (?x ≤ ?z ∧ ?y ≤ ?z)›*)) } then show "?thesis" (*goal: ‹K ÷⇘γ⇩A⇩G⇩M⇙ φ ⊆ K ÷ φ›*) using a (*‹K = Cn A›*) pmc_inclusion (*‹?K = Cn ?A ⟹ ?K ÷⇘γ⇩A⇩G⇩M⇙ ?φ ⊆ ?K›*) by fastforce next (*goal: ‹⟦¬ ⊩ φ; ¬ K ⊢ φ⟧ ⟹ K ÷⇘γ⇩A⇩G⇩M⇙ φ ⊆ K ÷ φ›*) case False (*‹¬ K ⊢ φ›*) hence "K .⊥. φ = {K}" using nonconsequence_remainder (*‹(?A .⊥. ?φ = {?A}) = (¬ ?A ⊢ ?φ)›*) taut2emptyrem (*‹⊩ ?φ ⟹ ?A .⊥. ?φ = {}›*) by auto then show "?thesis" (*goal: ‹K ÷⇘γ⇩A⇩G⇩M⇙ φ ⊆ K ÷ φ›*) using False (*‹¬ K ⊢ φ›*) a (*‹(K::'a set) = (Cn::'a set ⇒ 'a set) (A::'a set)›*) contract_vacuity (*‹⟦?K = Cn ?A; ?φ ∉ ?K⟧ ⟹ ?K ÷ ?φ = ?K›*) idempotency_L (*‹Cn (Cn ?A) = Cn ?A›*) pmc_vacuity (*‹⟦?K = Cn ?A; ¬ ?K ⊢ ?φ⟧ ⟹ ?K ÷⇘γ⇩A⇩G⇩M⇙ ?φ = ?K›*) by auto qed qed qed lemma contraction_with_completion: ‹K = Cn(A) ⟹ K ÷ φ = K ÷⇘* γ⇩A⇩G⇩M⇙ φ› by (simp add: contraction_is_pmc (*‹?K = Cn ?A ⟹ ?K ÷ ?φ = ?K ÷⇘γ⇩A⇩G⇩M⇙ ?φ›*) pmc_completion (*‹?K = Cn ?A ⟹ ?K ÷⇘* γ⇩A⇩G⇩M⇙ ?φ = ?K ÷⇘γ⇩A⇩G⇩M⇙ ?φ›*)) end (* in case of doubt uncomment one of these∈ sublocale AGMC_SC ⊆ PMC_SC where selection = γ⇩A⇩G⇩M⇩C by (unfold_locales) sublocale PMC_SC ⊆ AGMC_SC where contraction = ‹λA φ. A ÷⇘γ⇙ φ› by (unfold_locales) *) locale TRMC_SC = TransitivelyRelationalMeetContraction + PMC_SC where selection = γ⇩T⇩R begin text ‹A transitively relational selection function respect conjuctive overlap.› lemma rel_sel_conj_overlap: ‹K = Cn(A) ⟹ γ⇩T⇩R K (φ .∧. ψ) ⊆ γ⇩T⇩R K φ ∪ γ⇩T⇩R K ψ› proof (intro subsetI (*‹(⋀x. x ∈ ?A ⟹ x ∈ ?B) ⟹ ?A ⊆ ?B›*)) (*goal: ‹⋀x. ⟦K = Cn A; x ∈ γ⇩T⇩R K (φ .∧. ψ)⟧ ⟹ x ∈ γ⇩T⇩R K φ ∪ γ⇩T⇩R K ψ›*) fix B assume a: "K = Cn(A)" and b: "B ∈ γ⇩T⇩R K (φ .∧. ψ)" (*‹(K::'a set) = (Cn::'a set ⇒ 'a set) (A::'a set)› ‹(B::'a set) ∈ γ⇩T⇩R (K::'a set) ((φ::'a) .∧. (ψ::'a))›*) show "B ∈ γ⇩T⇩R K φ ∪ γ⇩T⇩R K ψ" (is "?A") proof (cases ‹⊩ φ ∨ ⊩ ψ ∨ ¬ K ⊢ φ ∨ ¬ K ⊢ ψ›, elim disjE (*‹⟦?P ∨ ?Q; ?P ⟹ ?R; ?Q ⟹ ?R⟧ ⟹ ?R›*)) (*goals: 1. ‹⊩ (φ::'a) ⟹ (B::'a set) ∈ γ⇩T⇩R (K::'a set) φ ∪ γ⇩T⇩R K (ψ::'a)› 2. ‹⊩ (ψ::'a) ⟹ (B::'a set) ∈ γ⇩T⇩R (K::'a set) (φ::'a) ∪ γ⇩T⇩R K ψ› 3. ‹¬ (K::'a set) ⊢ (φ::'a) ⟹ (B::'a set) ∈ γ⇩T⇩R K φ ∪ γ⇩T⇩R K (ψ::'a)› 4. ‹¬ (K::'a set) ⊢ (ψ::'a) ⟹ (B::'a set) ∈ γ⇩T⇩R K (φ::'a) ∪ γ⇩T⇩R K ψ› 5. ‹¬ (⊩ (φ::'a) ∨ ⊩ (ψ::'a) ∨ ¬ (K::'a set) ⊢ φ ∨ ¬ K ⊢ ψ) ⟹ (B::'a set) ∈ γ⇩T⇩R K φ ∪ γ⇩T⇩R K ψ›*) assume "⊩ φ" (*‹⊩ (φ::'a)›*) hence c: "Cn({φ .∧. ψ}) = Cn({ψ})" using conj_equiv (*‹?A ⊢ ?p ⟹ ?A ⊢ (?p .∧. ?q) .⟷. ?q›*) valid_Cn_equiv (*‹⊩ (?p .⟷. ?q) = (Cn {?p} = Cn {?q})›*) valid_def (*‹⊩ ?φ ≡ {} ⊢ ?φ›*) by blast from b (*‹(B::'a set) ∈ γ⇩T⇩R (K::'a set) ((φ::'a) .∧. (ψ::'a))›*) show "?A" by (metis Un_iff (*‹(?c ∈ ?A ∪ ?B) = (?c ∈ ?A ∨ ?c ∈ ?B)›*) a (*‹K = Cn A›*) c (*‹Cn {φ .∧. ψ} = Cn {ψ}›*) extensional_selection (*‹⟦?K = Cn ?A; Cn {?φ} = Cn {?ψ}⟧ ⟹ γ⇩T⇩R ?K ?φ = γ⇩T⇩R ?K ?ψ›*)) next (*goals: 1. ‹⊩ ψ ⟹ B ∈ γ⇩T⇩R K φ ∪ γ⇩T⇩R K ψ› 2. ‹¬ K ⊢ φ ⟹ B ∈ γ⇩T⇩R K φ ∪ γ⇩T⇩R K ψ› 3. ‹¬ K ⊢ ψ ⟹ B ∈ γ⇩T⇩R K φ ∪ γ⇩T⇩R K ψ› 4. ‹¬ (⊩ φ ∨ ⊩ ψ ∨ ¬ K ⊢ φ ∨ ¬ K ⊢ ψ) ⟹ B ∈ γ⇩T⇩R K φ ∪ γ⇩T⇩R K ψ›*) assume "⊩ ψ" (*‹⊩ (ψ::'a)›*) hence c: "Cn({φ .∧. ψ}) = Cn({φ})" by (simp add: Cn_conj_bis (*‹Cn {?p .∧. ?q} = Cn {?p, ?q}›*) Cn_same (*‹(Cn ?A = Cn ?B) = (∀C. (?A ⊆ Cn C) = (?B ⊆ Cn C))›*) validD_L (*‹⊩ ?φ ⟹ ?φ ∈ Cn ?A›*)) from b (*‹B ∈ γ⇩T⇩R K (φ .∧. ψ)›*) show "?A" by (metis Un_iff (*‹(?c ∈ ?A ∪ ?B) = (?c ∈ ?A ∨ ?c ∈ ?B)›*) a (*‹K = Cn A›*) c (*‹Cn {φ .∧. ψ} = Cn {φ}›*) extensional_selection (*‹⟦?K = Cn ?A; Cn {?φ} = Cn {?ψ}⟧ ⟹ γ⇩T⇩R ?K ?φ = γ⇩T⇩R ?K ?ψ›*)) next (*goals: 1. ‹¬ (K::'a::type set) ⊢ (φ::'a::type) ⟹ (B::'a::type set) ∈ γ⇩T⇩R K φ ∪ γ⇩T⇩R K (ψ::'a::type)› 2. ‹¬ (K::'a::type set) ⊢ (ψ::'a::type) ⟹ (B::'a::type set) ∈ γ⇩T⇩R K (φ::'a::type) ∪ γ⇩T⇩R K ψ› 3. ‹¬ (⊩ (φ::'a::type) ∨ ⊩ (ψ::'a::type) ∨ ¬ (K::'a::type set) ⊢ φ ∨ ¬ K ⊢ ψ) ⟹ (B::'a::type set) ∈ γ⇩T⇩R K φ ∪ γ⇩T⇩R K ψ›*) assume "¬ K ⊢ φ" (*‹¬ (K::'a set) ⊢ (φ::'a)›*) then show "?A" by (metis UnI1 (*‹?c ∈ ?A ⟹ ?c ∈ ?A ∪ ?B›*) a (*‹K = Cn A›*) b (*‹B ∈ γ⇩T⇩R K (φ .∧. ψ)›*) conjE1_PL (*‹?A ⊢ ?p .∧. ?q ⟹ ?A ⊢ ?p›*) is_selection (*‹⟦?K = Cn ?A; ?K .⊥. ?φ ≠ {}⟧ ⟹ γ⇩T⇩R ?K ?φ ⊆ ?K .⊥. ?φ›*) nonconsequence_remainder (*‹(?A .⊥. ?φ = {?A}) = (¬ ?A ⊢ ?φ)›*) nonempty_selection (*‹?K = Cn ?A ⟹ γ⇩T⇩R ?K ?φ ≠ {}›*) tautology_selection (*‹⟦?K = Cn ?A; ?K .⊥. ?φ = {}⟧ ⟹ γ⇩T⇩R ?K ?φ = {?K}›*) subset_singletonD (*‹?A ⊆ {?x} ⟹ ?A = {} ∨ ?A = {?x}›*)) next (*goals: 1. ‹¬ K ⊢ ψ ⟹ B ∈ γ⇩T⇩R K φ ∪ γ⇩T⇩R K ψ› 2. ‹¬ (⊩ φ ∨ ⊩ ψ ∨ ¬ K ⊢ φ ∨ ¬ K ⊢ ψ) ⟹ B ∈ γ⇩T⇩R K φ ∪ γ⇩T⇩R K ψ›*) assume "¬ K ⊢ ψ" (*‹¬ (K::'a set) ⊢ (ψ::'a)›*) then show "?A" by (metis UnI2 (*‹?c ∈ ?B ⟹ ?c ∈ ?A ∪ ?B›*) a (*‹K = Cn A›*) b (*‹B ∈ γ⇩T⇩R K (φ .∧. ψ)›*) conjE2_PL (*‹?A ⊢ ?p .∧. ?q ⟹ ?A ⊢ ?q›*) is_selection (*‹⟦?K = Cn ?A; ?K .⊥. ?φ ≠ {}⟧ ⟹ γ⇩T⇩R ?K ?φ ⊆ ?K .⊥. ?φ›*) nonconsequence_remainder (*‹(?A .⊥. ?φ = {?A}) = (¬ ?A ⊢ ?φ)›*) nonempty_selection (*‹?K = Cn ?A ⟹ γ⇩T⇩R ?K ?φ ≠ {}›*) tautology_selection (*‹⟦?K = Cn ?A; ?K .⊥. ?φ = {}⟧ ⟹ γ⇩T⇩R ?K ?φ = {?K}›*) subset_singletonD (*‹?A ⊆ {?x} ⟹ ?A = {} ∨ ?A = {?x}›*)) next (*goal: ‹¬ (⊩ φ ∨ ⊩ ψ ∨ ¬ K ⊢ φ ∨ ¬ K ⊢ ψ) ⟹ B ∈ γ⇩T⇩R K φ ∪ γ⇩T⇩R K ψ›*) assume d: "¬ (⊩ φ ∨ ⊩ ψ ∨ ¬ K ⊢ φ ∨ ¬ K ⊢ ψ)" (*‹¬ (⊩ (φ::'a) ∨ ⊩ (ψ::'a) ∨ ¬ (K::'a set) ⊢ φ ∨ ¬ K ⊢ ψ)›*) hence h: "K .⊥. φ ≠ {}" and i: "K .⊥. ψ ≠ {}" and j: "K .⊥. (φ .∧. ψ) ≠ {}" and k: "K ⊢ φ .∧. ψ" using d (*‹¬ (⊩ φ ∨ ⊩ ψ ∨ ¬ K ⊢ φ ∨ ¬ K ⊢ ψ)›*) emptyrem2taut (*‹(?A::'a set) .⊥. (?φ::'a) = {} ⟹ ⊩ ?φ›*) valid_conj_PL (*‹⊩ (?p .∧. ?q) = (⊩ ?p ∧ ⊩ ?q)›*) apply - (*goals: 1. ‹⟦¬ (⊩ (φ::'a::type) ∨ ⊩ (ψ::'a::type) ∨ ¬ (K::'a::type set) ⊢ φ ∨ ¬ K ⊢ ψ); ¬ (⊩ φ ∨ ⊩ ψ ∨ ¬ K ⊢ φ ∨ ¬ K ⊢ ψ); ⋀(A::'a::type set) φ::'a::type. A .⊥. φ = {} ⟹ ⊩ φ; ⋀(p::'a::type) q::'a::type. ⊩ (p .∧. q) = (⊩ p ∧ ⊩ q)⟧ ⟹ K .⊥. φ ≠ {}› 2. ‹⟦¬ (⊩ (φ::'a::type) ∨ ⊩ (ψ::'a::type) ∨ ¬ (K::'a::type set) ⊢ φ ∨ ¬ K ⊢ ψ); ¬ (⊩ φ ∨ ⊩ ψ ∨ ¬ K ⊢ φ ∨ ¬ K ⊢ ψ); ⋀(A::'a::type set) φ::'a::type. A .⊥. φ = {} ⟹ ⊩ φ; ⋀(p::'a::type) q::'a::type. ⊩ (p .∧. q) = (⊩ p ∧ ⊩ q)⟧ ⟹ K .⊥. ψ ≠ {}› 3. ‹⟦¬ (⊩ (φ::'a::type) ∨ ⊩ (ψ::'a::type) ∨ ¬ (K::'a::type set) ⊢ φ ∨ ¬ K ⊢ ψ); ¬ (⊩ φ ∨ ⊩ ψ ∨ ¬ K ⊢ φ ∨ ¬ K ⊢ ψ); ⋀(A::'a::type set) φ::'a::type. A .⊥. φ = {} ⟹ ⊩ φ; ⋀(p::'a::type) q::'a::type. ⊩ (p .∧. q) = (⊩ p ∧ ⊩ q)⟧ ⟹ K .⊥. (φ .∧. ψ) ≠ {}› 4. ‹⟦¬ (⊩ (φ::'a::type) ∨ ⊩ (ψ::'a::type) ∨ ¬ (K::'a::type set) ⊢ φ ∨ ¬ K ⊢ ψ); ¬ (⊩ φ ∨ ⊩ ψ ∨ ¬ K ⊢ φ ∨ ¬ K ⊢ ψ); ⋀(A::'a::type set) φ::'a::type. A .⊥. φ = {} ⟹ ⊩ φ; ⋀(p::'a::type) q::'a::type. ⊩ (p .∧. q) = (⊩ p ∧ ⊩ q)⟧ ⟹ 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]) (*goal: ‹⟦¬ (⊩ (φ::'a) ∨ ⊩ (ψ::'a) ∨ ¬ (K::'a set) ⊢ φ ∨ ¬ K ⊢ ψ); ¬ (⊩ φ ∨ ⊩ ψ ∨ ¬ K ⊢ φ ∨ ¬ K ⊢ ψ); ⋀(A::'a set) φ::'a. A .⊥. φ = {} ⟹ ⊩ φ; ⋀(p::'a) q::'a. ⊩ (p .∧. q) = (⊩ p ∧ ⊩ q)⟧ ⟹ K ⊢ φ .∧. ψ›*) apply (meson Supraclassical_logic.conjI_PL (*‹⟦Supraclassical_logic ?Cn ?true_PL ?false_PL ?imp_PL ?not_PL ?conj_PL ?disj_PL ?equiv_PL; ?p ∈ ?Cn ?A; ?q ∈ ?Cn ?A⟧ ⟹ ?conj_PL ?p ?q ∈ ?Cn ?A›*) Supraclassical_logic_axioms (*‹Supraclassical_logic Cn ⊤ ⊥ (.⟶.) .¬ (.∧.) (.∨.) (.⟷.)›*) d (*‹¬ (⊩ φ ∨ ⊩ ψ ∨ ¬ K ⊢ φ ∨ ¬ K ⊢ ψ)›*)) (*proven 4 subgoals*) . show "?A" using remainder_conj[OF a k] (*‹K .⊥. (φ .∧. ψ) = (K .⊥. φ) ∪ (K .⊥. ψ)›*) b (*‹B ∈ γ⇩T⇩R K (φ .∧. ψ)›*) h (*‹K .⊥. φ ≠ {}›*) i (*‹K .⊥. ψ ≠ {}›*) j (*‹K .⊥. (φ .∧. ψ) ≠ {}›*) rel_sel (*‹γ⇩T⇩R (?K::'a set) (?φ::'a) ≡ if ?K .⊥. ?φ = {} then {?K} else {B::'a set ∈ ?K .⊥. ?φ. ∀C::'a set∈?K .⊥. ?φ. C ≼⇘?K⇙ B}›*) by auto qed qed text‹A transitively relational meet contraction respect conjuctive overlap.› lemma trmc_conj_overlap: ‹K = Cn(A) ⟹ (K ÷⇘γ⇩T⇩R⇙ φ) ∩ (K ÷⇘γ⇩T⇩R⇙ ψ) ⊆ (K ÷⇘γ⇩T⇩R⇙ (φ .∧. ψ))› unfolding mc (*goal: ‹K = Cn A ⟹ ⋂ (γ⇩T⇩R K φ) ∩ ⋂ (γ⇩T⇩R K ψ) ⊆ ⋂ (γ⇩T⇩R K (φ .∧. ψ))›*) using rel_sel_conj_overlap (*‹?K = Cn ?A ⟹ γ⇩T⇩R ?K (?φ .∧. ?ψ) ⊆ γ⇩T⇩R ?K ?φ ∪ γ⇩T⇩R ?K ?ψ›*) by blast text‹A transitively relational selection function respect conjuctive inclusion› lemma rel_sel_conj_inclusion: ‹K = Cn(A) ⟹ γ⇩T⇩R K (φ .∧. ψ) ∩ (K .⊥. φ) ≠ {} ⟹ γ⇩T⇩R K φ ⊆ γ⇩T⇩R K (φ .∧. ψ)› proof (intro subsetI (*‹(⋀x::?'a. x ∈ (?A::?'a set) ⟹ x ∈ (?B::?'a set)) ⟹ ?A ⊆ ?B›*)) (*goal: ‹⋀x. ⟦K = Cn A; γ⇩T⇩R K (φ .∧. ψ) ∩ (K .⊥. φ) ≠ {}; x ∈ γ⇩T⇩R K φ⟧ ⟹ x ∈ γ⇩T⇩R K (φ .∧. ψ)›*) fix B assume a: "K = Cn(A)" and b: "γ⇩T⇩R K (φ .∧. ψ) ∩ (K .⊥. φ) ≠ {}" and c: "B ∈ γ⇩T⇩R K φ" (*‹(K::'a set) = (Cn::'a set ⇒ 'a set) (A::'a set)› ‹γ⇩T⇩R (K::'a set) ((φ::'a) .∧. (ψ::'a)) ∩ (K .⊥. φ) ≠ {}› ‹(B::'a set) ∈ γ⇩T⇩R (K::'a set) (φ::'a)›*) show "B ∈ γ⇩T⇩R K (φ .∧. ψ)" (is "?A") proof (cases ‹⊩ φ ∨ ⊩ ψ ∨ ¬ K ⊢ φ ∨ ¬ K ⊢ ψ›, auto) (*goals: 1. ‹φ ∉ Cn K ⟹ B ∈ γ⇩T⇩R K (φ .∧. ψ)› 2. ‹⊩ φ ⟹ B ∈ γ⇩T⇩R K (φ .∧. ψ)› 3. ‹⊩ ψ ⟹ B ∈ γ⇩T⇩R K (φ .∧. ψ)› 4. ‹ψ ∉ Cn K ⟹ B ∈ γ⇩T⇩R K (φ .∧. ψ)› 5. ‹⟦φ ∈ Cn K; ¬ ⊩ φ; ¬ ⊩ ψ; ψ ∈ Cn K⟧ ⟹ B ∈ γ⇩T⇩R K (φ .∧. ψ)›*) assume "⊩ φ" (*‹⊩ (φ::'a)›*) then show "?A" using b (*‹γ⇩T⇩R K (φ .∧. ψ) ∩ (K .⊥. φ) ≠ {}›*) taut2emptyrem (*‹⊩ (?φ::'a) ⟹ (?A::'a set) .⊥. ?φ = {}›*) by auto next (*goals: 1. ‹φ ∉ Cn K ⟹ B ∈ γ⇩T⇩R K (φ .∧. ψ)› 2. ‹⊩ ψ ⟹ B ∈ γ⇩T⇩R K (φ .∧. ψ)› 3. ‹ψ ∉ Cn K ⟹ B ∈ γ⇩T⇩R K (φ .∧. ψ)› 4. ‹⟦φ ∈ Cn K; ¬ ⊩ φ; ¬ ⊩ ψ; ψ ∈ Cn K⟧ ⟹ B ∈ γ⇩T⇩R K (φ .∧. ψ)›*) assume "⊩ ψ" (*‹⊩ (ψ::'a)›*) hence "Cn({φ .∧. ψ}) = Cn({φ})" by (simp add: Cn_conj_bis (*‹Cn {?p .∧. ?q} = Cn {?p, ?q}›*) Cn_same (*‹(Cn ?A = Cn ?B) = (∀C. (?A ⊆ Cn C) = (?B ⊆ Cn C))›*) validD_L (*‹⊩ ?φ ⟹ ?φ ∈ Cn ?A›*)) then show "?A" using a (*‹K = Cn A›*) c (*‹B ∈ γ⇩T⇩R K φ›*) extensional_selection (*‹⟦?K = Cn ?A; Cn {?φ} = Cn {?ψ}⟧ ⟹ γ⇩T⇩R ?K ?φ = γ⇩T⇩R ?K ?ψ›*) by blast next (*goals: 1. ‹φ ∉ Cn K ⟹ B ∈ γ⇩T⇩R K (φ .∧. ψ)› 2. ‹ψ ∉ Cn K ⟹ B ∈ γ⇩T⇩R K (φ .∧. ψ)› 3. ‹⟦φ ∈ Cn K; ¬ ⊩ φ; ¬ ⊩ ψ; ψ ∈ Cn K⟧ ⟹ B ∈ γ⇩T⇩R K (φ .∧. ψ)›*) assume d: "φ ∉ Cn K" (*‹(φ::'a) ∉ (Cn::'a set ⇒ 'a set) (K::'a set)›*) with d (*‹φ ∉ Cn K›*) show "?A" by (metis Int_emptyI (*‹(⋀x. ⟦x ∈ ?A; x ∈ ?B⟧ ⟹ False) ⟹ ?A ∩ ?B = {}›*) Tarskian_logic.nonconsequence_remainder (*‹Tarskian_logic ?Cn ⟹ (Tarskian_logic.remainder ?Cn ?A ?φ = {?A}) = (?φ ∉ ?Cn ?A)›*) Tarskian_logic_axioms (*‹Tarskian_logic Cn›*) a (*‹K = Cn A›*) b (*‹γ⇩T⇩R K (φ .∧. ψ) ∩ (K .⊥. φ) ≠ {}›*) c (*‹B ∈ γ⇩T⇩R K φ›*) idempotency_L (*‹Cn (Cn ?A) = Cn ?A›*) inf_bot_right (*‹inf ?x bot = bot›*) is_selection (*‹⟦?K = Cn ?A; ?K .⊥. ?φ ≠ {}⟧ ⟹ γ⇩T⇩R ?K ?φ ⊆ ?K .⊥. ?φ›*) nonempty_selection (*‹?K = Cn ?A ⟹ γ⇩T⇩R ?K ?φ ≠ {}›*) singletonD (*‹?b ∈ {?a} ⟹ ?b = ?a›*) subset_singletonD (*‹?A ⊆ {?x} ⟹ ?A = {} ∨ ?A = {?x}›*)) next (*goals: 1. ‹ψ ∉ Cn K ⟹ B ∈ γ⇩T⇩R K (φ .∧. ψ)› 2. ‹⟦φ ∈ Cn K; ¬ ⊩ φ; ¬ ⊩ ψ; ψ ∈ Cn K⟧ ⟹ B ∈ γ⇩T⇩R K (φ .∧. ψ)›*) assume d: "ψ ∉ Cn K" (*‹(ψ::'a) ∉ (Cn::'a set ⇒ 'a set) (K::'a set)›*) hence e: "(φ .∧. ψ) ∉ Cn K" by (meson Supraclassical_logic.conjE2_PL (*‹⟦Supraclassical_logic ?Cn ?true_PL ?false_PL ?imp_PL ?not_PL ?conj_PL ?disj_PL ?equiv_PL; ?conj_PL ?p ?q ∈ ?Cn ?A⟧ ⟹ ?q ∈ ?Cn ?A›*) Supraclassical_logic_axioms (*‹Supraclassical_logic Cn ⊤ ⊥ (.⟶.) .¬ (.∧.) (.∨.) (.⟷.)›*)) hence f: "γ⇩T⇩R K (φ .∧. ψ) = {K}" by (metis Tarskian_logic.nonconsequence_remainder (*‹Tarskian_logic ?Cn ⟹ (Tarskian_logic.remainder ?Cn ?A ?φ = {?A}) = (?φ ∉ ?Cn ?A)›*) Tarskian_logic_axioms (*‹Tarskian_logic Cn›*) a (*‹K = Cn A›*) insert_not_empty (*‹insert ?a ?A ≠ {}›*) is_selection (*‹⟦?K = Cn ?A; ?K .⊥. ?φ ≠ {}⟧ ⟹ γ⇩T⇩R ?K ?φ ⊆ ?K .⊥. ?φ›*) nonempty_selection (*‹?K = Cn ?A ⟹ γ⇩T⇩R ?K ?φ ≠ {}›*) subset_singletonD (*‹?A ⊆ {?x} ⟹ ?A = {} ∨ ?A = {?x}›*)) with b (*‹γ⇩T⇩R (K::'a::type set) ((φ::'a::type) .∧. (ψ::'a::type)) ∩ (K .⊥. φ) ≠ {}›*) have g: "(K .⊥. φ) = {K}" unfolding nonconsequence_remainder[symmetric] (*goal: ‹(K::'a::type set) .⊥. (φ::'a::type) = {K}›*) using rem (*‹(?A::'a set) .⊥. (?φ::'a) ≡ {B::'a set. B ⊆ ?A ∧ ¬ B ⊢ ?φ ∧ (∀B'⊆?A. B ⊂ B' ⟶ B' ⊢ ?φ)}›*) by auto with d (*‹ψ ∉ Cn K›*) f (*‹γ⇩T⇩R K (φ .∧. ψ) = {K}›*) show "?A" using a (*‹(K::'a set) = (Cn::'a set ⇒ 'a set) (A::'a set)›*) c (*‹(B::'a set) ∈ γ⇩T⇩R (K::'a set) (φ::'a)›*) is_selection (*‹⟦?K = Cn ?A; ?K .⊥. ?φ ≠ {}⟧ ⟹ γ⇩T⇩R ?K ?φ ⊆ ?K .⊥. ?φ›*) by fastforce next (*goal: ‹⟦φ ∈ Cn K; ¬ ⊩ φ; ¬ ⊩ ψ; ψ ∈ Cn K⟧ ⟹ B ∈ γ⇩T⇩R K (φ .∧. ψ)›*) assume d: "¬ ⊩ φ" and e: "¬ ⊩ ψ" and f: "φ ∈ Cn K" and g: "ψ ∈ Cn K" (*‹¬ ⊩ (φ::'a)› ‹¬ ⊩ (ψ::'a)› ‹(φ::'a) ∈ (Cn::'a set ⇒ 'a set) (K::'a set)› ‹(ψ::'a) ∈ (Cn::'a set ⇒ 'a set) (K::'a set)›*) hence h: "K .⊥. φ ≠ {}" and i: "K .⊥. ψ ≠ {}" and j: "K .⊥. (φ .∧. ψ) ≠ {}" and k: "K ⊢ φ .∧. ψ" using e (*‹¬ ⊩ (ψ::'a::type)›*) d (*‹¬ ⊩ φ›*) emptyrem2taut (*‹(?A::'a::type set) .⊥. (?φ::'a::type) = {} ⟹ ⊩ ?φ›*) valid_conj_PL (*‹⊩ (?p .∧. ?q) = (⊩ ?p ∧ ⊩ ?q)›*) apply - (*goals: 1. ‹⟦¬ ⊩ (φ::'a); ¬ ⊩ (ψ::'a); φ ∈ (Cn::'a set ⇒ 'a set) (K::'a set); ψ ∈ Cn K; ¬ ⊩ ψ; ¬ ⊩ φ; ⋀(A::'a set) φ::'a. A .⊥. φ = {} ⟹ ⊩ φ; ⋀(p::'a) q::'a. ⊩ (p .∧. q) = (⊩ p ∧ ⊩ q)⟧ ⟹ K .⊥. φ ≠ {}› 2. ‹⟦¬ ⊩ (φ::'a); ¬ ⊩ (ψ::'a); φ ∈ (Cn::'a set ⇒ 'a set) (K::'a set); ψ ∈ Cn K; ¬ ⊩ ψ; ¬ ⊩ φ; ⋀(A::'a set) φ::'a. A .⊥. φ = {} ⟹ ⊩ φ; ⋀(p::'a) q::'a. ⊩ (p .∧. q) = (⊩ p ∧ ⊩ q)⟧ ⟹ K .⊥. ψ ≠ {}› 3. ‹⟦¬ ⊩ (φ::'a); ¬ ⊩ (ψ::'a); φ ∈ (Cn::'a set ⇒ 'a set) (K::'a set); ψ ∈ Cn K; ¬ ⊩ ψ; ¬ ⊩ φ; ⋀(A::'a set) φ::'a. A .⊥. φ = {} ⟹ ⊩ φ; ⋀(p::'a) q::'a. ⊩ (p .∧. q) = (⊩ p ∧ ⊩ q)⟧ ⟹ K .⊥. (φ .∧. ψ) ≠ {}› 4. ‹⟦¬ ⊩ (φ::'a); ¬ ⊩ (ψ::'a); φ ∈ (Cn::'a set ⇒ 'a set) (K::'a set); ψ ∈ Cn K; ¬ ⊩ ψ; ¬ ⊩ φ; ⋀(A::'a set) φ::'a. A .⊥. φ = {} ⟹ ⊩ φ; ⋀(p::'a) q::'a. ⊩ (p .∧. q) = (⊩ p ∧ ⊩ q)⟧ ⟹ 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]) (*goal: ‹⟦¬ ⊩ φ; ¬ ⊩ ψ; φ ∈ Cn K; ψ ∈ Cn K; ¬ ⊩ ψ; ¬ ⊩ φ; ⋀A φ. A .⊥. φ = {} ⟹ ⊩ φ; ⋀p q. ⊩ (p .∧. q) = (⊩ p ∧ ⊩ q)⟧ ⟹ K ⊢ φ .∧. ψ›*) apply (meson Supraclassical_logic.conjI_PL (*‹⟦Supraclassical_logic ?Cn ?true_PL ?false_PL ?imp_PL ?not_PL ?conj_PL ?disj_PL ?equiv_PL; ?p ∈ ?Cn ?A; ?q ∈ ?Cn ?A⟧ ⟹ ?conj_PL ?p ?q ∈ ?Cn ?A›*) Supraclassical_logic_axioms (*‹Supraclassical_logic Cn ⊤ ⊥ (.⟶.) .¬ (.∧.) (.∨.) (.⟷.)›*) f (*‹φ ∈ Cn K›*) g (*‹ψ ∈ Cn K›*)) (*proven 4 subgoals*) . have o: "B ∈ K .⊥. φ ⟹ B ∈ K .⊥. (φ .∧. ψ)" for B using a (*‹K = Cn A›*) k (*‹K ⊢ φ .∧. ψ›*) remainder_conj (*‹⟦?K = Cn ?A; ?K ⊢ ?φ .∧. ?ψ⟧ ⟹ ?K .⊥. (?φ .∧. ?ψ) = (?K .⊥. ?φ) ∪ (?K .⊥. ?ψ)›*) by auto from b (*‹γ⇩T⇩R K (φ .∧. ψ) ∩ (K .⊥. φ) ≠ {}›*) obtain B' where l: "B' ∈ K .⊥. (φ .∧. ψ)" and m: "∀C∈K .⊥. (φ .∧. ψ). C ≼⇘K⇙ B'" and n: "φ ∉ B'" (*goal: ‹(⋀B'. ⟦B' ∈ K .⊥. (φ .∧. ψ); ∀C∈K .⊥. (φ .∧. ψ). C ≼⇘K⇙ B'; φ ∉ B'⟧ ⟹ thesis) ⟹ thesis›*) apply (auto simp add:mc (*‹?A ÷⇘?γ⇙ ?φ ≡ ⋂ (?γ ?A ?φ)›*) rel_sel (*‹γ⇩T⇩R ?K ?φ ≡ if ?K .⊥. ?φ = {} then {?K} else {B ∈ ?K .⊥. ?φ. ∀C∈?K .⊥. ?φ. C ≼⇘?K⇙ B}›*) j (*‹K .⊥. (φ .∧. ψ) ≠ {}›*)) (*goal: ‹(⋀B'. ⟦B' ∈ K .⊥. (φ .∧. ψ); ∀C∈K .⊥. (φ .∧. ψ). C ≼⇘K⇙ B'; φ ∉ B'⟧ ⟹ thesis) ⟹ thesis›*) using assumption_L (*‹(?φ::'a) ∈ (?A::'a set) ⟹ ?A ⊢ ?φ›*) rem (*‹?A .⊥. ?φ ≡ {B. B ⊆ ?A ∧ ¬ B ⊢ ?φ ∧ (∀B'⊆?A. B ⊂ B' ⟶ B' ⊢ ?φ)}›*) by force have p: "B' ∈ K .⊥. φ" apply (simp add: rem (*‹(?A::'a set) .⊥. (?φ::'a) ≡ {B::'a set. B ⊆ ?A ∧ ¬ B ⊢ ?φ ∧ (∀B'⊆?A. B ⊂ B' ⟶ B' ⊢ ?φ)}›*)) (*goal: ‹B' ∈ K .⊥. φ›*) by (metis (no_types, lifting) Supraclassical_logic.conjE1_PL (*‹⟦Supraclassical_logic ?Cn ?true_PL ?false_PL ?imp_PL ?not_PL ?conj_PL ?disj_PL ?equiv_PL; ?conj_PL ?p ?q ∈ ?Cn ?A⟧ ⟹ ?p ∈ ?Cn ?A›*) Supraclassical_logic_axioms (*‹Supraclassical_logic Cn ⊤ ⊥ (.⟶.) .¬ (.∧.) (.∨.) (.⟷.)›*) Tarskian_logic.rem (*‹Tarskian_logic ?Cn ⟹ Tarskian_logic.remainder ?Cn ?A ?φ ≡ {B. B ⊆ ?A ∧ ?φ ∉ ?Cn B ∧ (∀B'⊆?A. B ⊂ B' ⟶ ?φ ∈ ?Cn B')}›*) Tarskian_logic_axioms (*‹Tarskian_logic Cn›*) a (*‹K = Cn A›*) l (*‹B' ∈ K .⊥. (φ .∧. ψ)›*) mem_Collect_eq (*‹(?a ∈ Collect ?P) = ?P ?a›*) n (*‹φ ∉ B'›*) rem_closure (*‹⟦?K = Cn ?A; ?B ∈ ?K .⊥. ?φ⟧ ⟹ ?B = Cn ?B›*)) from c (*‹B ∈ γ⇩T⇩R K φ›*) show "?A" apply (simp add:rel_sel (*‹γ⇩T⇩R (?K::'a::type set) (?φ::'a::type) ≡ if ?K .⊥. ?φ = {} then {?K} else {B::'a::type set ∈ ?K .⊥. ?φ. ∀C::'a::type set∈?K .⊥. ?φ. C ≼⇘?K⇙ B}›*) o (*‹(?B::'a::type set) ∈ (K::'a::type set) .⊥. (φ::'a::type) ⟹ ?B ∈ K .⊥. (φ .∧. (ψ::'a::type))›*) j (*‹(K::'a::type set) .⊥. ((φ::'a::type) .∧. (ψ::'a::type)) ≠ {}›*) h (*‹(K::'a::type set) .⊥. (φ::'a::type) ≠ {}›*)) (*goal: ‹B ∈ γ⇩T⇩R K (φ .∧. ψ)›*) using m (*‹∀C∈K .⊥. (φ .∧. ψ). C ≼⇘K⇙ B'›*) p (*‹B' ∈ K .⊥. φ›*) trans_rel (*‹⟦?K = Cn ?A; ?B ≼⇘?K⇙ ?C; ?C ≼⇘?K⇙ ?D⟧ ⟹ ?B ≼⇘?K⇙ ?D›*) a (*‹K = Cn A›*) by blast qed qed text‹A transitively relational meet contraction respect conjuctive inclusion› lemma trmc_conj_inclusion: ‹K = Cn(A) ⟹ φ ∉ (K ÷⇘γ⇩T⇩R⇙ (φ .∧. ψ)) ⟹ ((K ÷⇘γ⇩T⇩R⇙ (φ .∧. ψ) ⊆ (K ÷⇘γ⇩T⇩R⇙ φ)))› proof (-) (*goal: ‹⟦K = Cn A; φ ∉ K ÷⇘γ⇩T⇩R⇙ (φ .∧. ψ)⟧ ⟹ K ÷⇘γ⇩T⇩R⇙ (φ .∧. ψ) ⊆ K ÷⇘γ⇩T⇩R⇙ φ›*) assume a: "K = Cn(A)" and b: "φ ∉ (K ÷⇘γ⇩T⇩R⇙ (φ .∧. ψ))" (*‹(K::'a set) = (Cn::'a set ⇒ 'a set) (A::'a set)› ‹(φ::'a) ∉ (K::'a set) ÷⇘γ⇩T⇩R⇙ (φ .∧. (ψ::'a))›*) then obtain B where c: "B ∈ γ⇩T⇩R K (φ .∧. ψ)" and d: "¬ B ⊢ φ" (*goal: ‹(⋀B. ⟦B ∈ γ⇩T⇩R K (φ .∧. ψ); ¬ B ⊢ φ⟧ ⟹ thesis) ⟹ thesis›*) apply (simp add:mc (*‹?A ÷⇘?γ⇙ ?φ ≡ ⋂ (?γ ?A ?φ)›*)) (*goal: ‹(⋀B. ⟦B ∈ γ⇩T⇩R K (φ .∧. ψ); ¬ B ⊢ φ⟧ ⟹ thesis) ⟹ thesis›*) by (metis b (*‹(φ::'a::type) ∉ (K::'a::type set) ÷⇘γ⇩T⇩R⇙ (φ .∧. (ψ::'a::type))›*) emptyrem2taut (*‹(?A::'a::type set) .⊥. (?φ::'a::type) = {} ⟹ ⊩ ?φ›*) is_selection (*‹⟦(?K::'a::type set) = (Cn::'a::type set ⇒ 'a::type set) (?A::'a::type set); ?K .⊥. (?φ::'a::type) ≠ {}⟧ ⟹ γ⇩T⇩R ?K ?φ ⊆ ?K .⊥. ?φ›*) pmc_tautology (*‹⟦(?K::'a::type set) = (Cn::'a::type set ⇒ 'a::type set) (?A::'a::type set); ⊩ (?φ::'a::type)⟧ ⟹ ?K ÷⇘γ⇩T⇩R⇙ ?φ = ?K›*) rem_closure (*‹⟦(?K::'a::type set) = (Cn::'a::type set ⇒ 'a::type set) (?A::'a::type set); (?B::'a::type set) ∈ ?K .⊥. (?φ::'a::type)⟧ ⟹ ?B = Cn ?B›*) subset_iff (*‹((?A::?'a::type set) ⊆ (?B::?'a::type set)) = (∀t::?'a::type. t ∈ ?A ⟶ t ∈ ?B)›*) validD_L (*‹⊩ (?φ::'a::type) ⟹ ?φ ∈ (Cn::'a::type set ⇒ 'a::type set) (?A::'a::type set)›*) valid_conj_PL (*‹⊩ ((?p::'a::type) .∧. (?q::'a::type)) = (⊩ ?p ∧ ⊩ ?q)›*)) hence "B ∈ (K .⊥. φ)" using remainder_recovery_bis[OF a _ d, of ‹φ .∧. ψ›] (*‹⟦(K::'a set) ⊢ (φ::'a); (B::'a set) ∈ K .⊥. (φ .∧. (ψ::'a))⟧ ⟹ B ∈ K .⊥. φ›*) by (metis (no_types, opaque_lifting) a (*‹K = Cn A›*) conj_PL (*‹(?A ⊢ ?p .∧. ?q) = (?A ⊢ ?p ∧ ?A ⊢ ?q)›*) emptyrem2taut (*‹?A .⊥. ?φ = {} ⟹ ⊩ ?φ›*) insert_not_empty (*‹insert ?a ?A ≠ {}›*) is_selection (*‹⟦?K = Cn ?A; ?K .⊥. ?φ ≠ {}⟧ ⟹ γ⇩T⇩R ?K ?φ ⊆ ?K .⊥. ?φ›*) nonconsequence_remainder (*‹(?A .⊥. ?φ = {?A}) = (¬ ?A ⊢ ?φ)›*) subsetD (*‹⟦?A ⊆ ?B; ?c ∈ ?A⟧ ⟹ ?c ∈ ?B›*) taut2emptyrem (*‹⊩ ?φ ⟹ ?A .⊥. ?φ = {}›*)) with c (*‹B ∈ γ⇩T⇩R K (φ .∧. ψ)›*) have e: "γ⇩T⇩R K (φ .∧. ψ) ∩ (K .⊥. φ) ≠ {}" by blast then show "((K ÷⇘γ⇩T⇩R⇙ (φ .∧. ψ) ⊆ (K ÷⇘γ⇩T⇩R⇙ φ)))" unfolding mc (*goal: ‹⋂ (γ⇩T⇩R (K::'a set) ((φ::'a) .∧. (ψ::'a))) ⊆ ⋂ (γ⇩T⇩R K φ)›*) using rel_sel_conj_inclusion[OF a e] (*‹γ⇩T⇩R K φ ⊆ γ⇩T⇩R K (φ .∧. ψ)›*) by blast qed text‹As a transitively relational meet contraction has been proven to respect all postulates of AGM full contraction the equivalence between the both are straightforward› sublocale AGM_FullContraction where contraction = ‹λA φ. A ÷⇘γ⇩T⇩R⇙ φ› using trmc_conj_inclusion (*‹⟦?K = Cn ?A; ?φ ∉ ?K ÷⇘γ⇩T⇩R⇙ (?φ .∧. ?ψ)⟧ ⟹ ?K ÷⇘γ⇩T⇩R⇙ (?φ .∧. ?ψ) ⊆ ?K ÷⇘γ⇩T⇩R⇙ ?φ›*) trmc_conj_overlap (*‹?K = Cn ?A ⟹ (?K ÷⇘γ⇩T⇩R⇙ ?φ) ∩ (?K ÷⇘γ⇩T⇩R⇙ ?ψ) ⊆ ?K ÷⇘γ⇩T⇩R⇙ (?φ .∧. ?ψ)›*) apply - (*goals: 1. ‹⟦⋀K A φ ψ. ⟦K = Cn A; φ ∉ K ÷⇘γ⇩T⇩R⇙ (φ .∧. ψ)⟧ ⟹ K ÷⇘γ⇩T⇩R⇙ (φ .∧. ψ) ⊆ K ÷⇘γ⇩T⇩R⇙ φ; ⋀K A φ ψ. K = Cn A ⟹ (K ÷⇘γ⇩T⇩R⇙ φ) ∩ (K ÷⇘γ⇩T⇩R⇙ ψ) ⊆ K ÷⇘γ⇩T⇩R⇙ (φ .∧. ψ)⟧ ⟹ AGM_FullContraction Cn (λA. meet_contraction A γ⇩T⇩R) ⊤ ⊥ (.⟶.) .¬ (.∧.) (.∨.) (.⟷.)› 2. ‹⋀A φ. ⟦⋀K A φ ψ. ⟦K = Cn A; φ ∉ K ÷⇘γ⇩T⇩R⇙ (φ .∧. ψ)⟧ ⟹ K ÷⇘γ⇩T⇩R⇙ (φ .∧. ψ) ⊆ K ÷⇘γ⇩T⇩R⇙ φ; ⋀K A φ ψ. K = Cn A ⟹ (K ÷⇘γ⇩T⇩R⇙ φ) ∩ (K ÷⇘γ⇩T⇩R⇙ ψ) ⊆ K ÷⇘γ⇩T⇩R⇙ (φ .∧. ψ)⟧ ⟹ A ⊢ φ ≡ φ ∈ Cn A› 3. ‹⋀φ. ⟦⋀K A φ ψ. ⟦K = Cn A; φ ∉ K ÷⇘γ⇩T⇩R⇙ (φ .∧. ψ)⟧ ⟹ K ÷⇘γ⇩T⇩R⇙ (φ .∧. ψ) ⊆ K ÷⇘γ⇩T⇩R⇙ φ; ⋀K A φ ψ. K = Cn A ⟹ (K ÷⇘γ⇩T⇩R⇙ φ) ∩ (K ÷⇘γ⇩T⇩R⇙ ψ) ⊆ K ÷⇘γ⇩T⇩R⇙ (φ .∧. ψ)⟧ ⟹ ⊩ φ ≡ {} ⊢ φ› 4. ‹⋀A φ. ⟦⋀K A φ ψ. ⟦K = Cn A; φ ∉ K ÷⇘γ⇩T⇩R⇙ (φ .∧. ψ)⟧ ⟹ K ÷⇘γ⇩T⇩R⇙ (φ .∧. ψ) ⊆ K ÷⇘γ⇩T⇩R⇙ φ; ⋀K A φ ψ. K = Cn A ⟹ (K ÷⇘γ⇩T⇩R⇙ φ) ∩ (K ÷⇘γ⇩T⇩R⇙ ψ) ⊆ K ÷⇘γ⇩T⇩R⇙ (φ .∧. ψ)⟧ ⟹ A ⊕ φ ≡ Cn (A ∪ {φ})› discuss goal 1*) apply ((unfold_locales)[1]) (*goals: 1. ‹⋀K A φ ψ. ⟦⋀K A φ ψ. ⟦K = Cn A; φ ∉ K ÷⇘γ⇩T⇩R⇙ (φ .∧. ψ)⟧ ⟹ K ÷⇘γ⇩T⇩R⇙ (φ .∧. ψ) ⊆ K ÷⇘γ⇩T⇩R⇙ φ; ⋀K A φ ψ. K = Cn A ⟹ (K ÷⇘γ⇩T⇩R⇙ φ) ∩ (K ÷⇘γ⇩T⇩R⇙ ψ) ⊆ K ÷⇘γ⇩T⇩R⇙ (φ .∧. ψ); K = Cn A⟧ ⟹ (K ÷⇘γ⇩T⇩R⇙ φ) ∩ (K ÷⇘γ⇩T⇩R⇙ ψ) ⊆ K ÷⇘γ⇩T⇩R⇙ (φ .∧. ψ)› 2. ‹⋀K A φ ψ. ⟦⋀K A φ ψ. ⟦K = Cn A; φ ∉ K ÷⇘γ⇩T⇩R⇙ (φ .∧. ψ)⟧ ⟹ K ÷⇘γ⇩T⇩R⇙ (φ .∧. ψ) ⊆ K ÷⇘γ⇩T⇩R⇙ φ; ⋀K A φ ψ. K = Cn A ⟹ (K ÷⇘γ⇩T⇩R⇙ φ) ∩ (K ÷⇘γ⇩T⇩R⇙ ψ) ⊆ K ÷⇘γ⇩T⇩R⇙ (φ .∧. ψ); K = Cn A; φ ∉ K ÷⇘γ⇩T⇩R⇙ (φ .∧. ψ)⟧ ⟹ K ÷⇘γ⇩T⇩R⇙ (φ .∧. ψ) ⊆ K ÷⇘γ⇩T⇩R⇙ φ› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) (*discuss goal 2*) apply ((unfold_locales)[1]) (*discuss goal 3*) apply ((unfold_locales)[1]) (*discuss goal 4*) apply ((unfold_locales)[1]) (*proven 4 subgoals*) . end locale AGMFC_SC = AGM_FullContraction + AGMC_SC begin text‹An AGM relation is defined as ?› definition AGM_relation::‹'a set ⇒ 'a set ⇒ 'a set ⇒ bool› where AGM_rel: ‹AGM_relation C K B ≡ (C = K ∧ B = K) ∨ ( (∃φ. K ⊢ φ ∧ C ∈ K .⊥. φ) ∧ (∃φ. K ⊢ φ ∧ B ∈ K .⊥. φ ∧ K ÷ φ ⊆ B) ∧ (∀φ. (K ⊢ φ ∧ C ∈ K .⊥. φ ∧ B ∈ K .⊥. φ ∧ K ÷ φ ⊆ C) ⟶ K ÷ φ ⊆ B))› text‹An AGM relational selection is defined as a function that return @{term ‹K›} if the remainders of @{text ‹K .⊥. φ›} is empty and the best element of the remainders according to an AGM relation› definition AGM_relational_selection::‹'a set ⇒ 'a ⇒ 'a set set› (‹γ⇩A⇩G⇩M⇩T⇩R›) where AGM_rel_sel: ‹γ⇩A⇩G⇩M⇩T⇩R K φ ≡ if (K .⊥. φ) = {} then {K} else {B. B∈(K .⊥. φ) ∧ (∀C∈(K .⊥. φ). AGM_relation C K B)}› lemma AGM_rel_sel_completion: ‹K = Cn(A) ⟹ γ⇩A⇩G⇩M⇩T⇩R K φ = * γ⇩A⇩G⇩M K φ› apply (unfold AGM_rel_sel (*‹γ⇩A⇩G⇩M⇩T⇩R ?K ?φ ≡ if ?K .⊥. ?φ = {} then {?K} else {B ∈ ?K .⊥. ?φ. ∀C∈?K .⊥. ?φ. AGM_relation C ?K B}›*), simp add:completion_def (*‹* ?γ ?A ?φ ≡ if ?A .⊥. ?φ = {} then {?A} else {B ∈ ?A .⊥. ?φ. ⋂ (?γ ?A ?φ) ⊆ 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))›*)) (*goal: ‹K = Cn A ⟹ γ⇩A⇩G⇩M⇩T⇩R K φ = * γ⇩A⇩G⇩M K φ›*) proof (auto simp add:AGM_sel (*‹γ⇩A⇩G⇩M ?A ?φ ≡ if ?A .⊥. ?φ = {} then {?A} else {B ∈ ?A .⊥. ?φ. ?A ÷ ?φ ⊆ B}›*)) (*goals: 1. ‹⋀x xa xb. ⟦K = Cn A; x ∈ Cn A .⊥. φ; xa ∈ Cn A .⊥. φ; ∀C∈Cn A .⊥. φ. AGM_relation C (Cn A) xa; ∀x. x ∈ Cn A .⊥. φ ∧ Cn A ÷ φ ⊆ x ⟶ xb ∈ x⟧ ⟹ xb ∈ xa› 2. ‹⋀x xa C. ⟦K = Cn A; x ∈ Cn A .⊥. φ; xa ∈ Cn A .⊥. φ; ⋂ {B ∈ Cn A .⊥. φ. Cn A ÷ φ ⊆ B} ⊆ xa; C ∈ Cn A .⊥. φ⟧ ⟹ AGM_relation C (Cn A) xa›*) fix S and B and C assume a: "S ∈ Cn(A) .⊥. φ" and b: "B ∈ Cn(A) .⊥. φ" and c: "⋂ {B ∈ Cn(A) .⊥. φ. Cn(A) ÷ φ ⊆ B} ⊆ B" and d: "C ∈ Cn(A) .⊥. φ" (*‹(S::'a set) ∈ (Cn::'a set ⇒ 'a set) (A::'a set) .⊥. (φ::'a)› ‹(B::'a set) ∈ (Cn::'a set ⇒ 'a set) (A::'a set) .⊥. (φ::'a)› ‹⋂ {B::'a set ∈ (Cn::'a set ⇒ 'a set) (A::'a set) .⊥. (φ::'a). Cn A ÷ φ ⊆ B} ⊆ (B::'a set)› ‹(C::'a set) ∈ (Cn::'a set ⇒ 'a set) (A::'a set) .⊥. (φ::'a)›*) hence e: "φ ∉ Cn(A) ÷ φ" using Tarskian_logic.taut2emptyrem (*‹⟦Tarskian_logic ?Cn; ?φ ∈ ?Cn {}⟧ ⟹ Tarskian_logic.remainder ?Cn ?A ?φ = {}›*) Tarskian_logic_axioms (*‹Tarskian_logic Cn›*) contract_success (*‹⟦?K = Cn ?A; ?φ ∉ Cn {}⟧ ⟹ ?φ ∉ ?K ÷ ?φ›*) by fastforce show "AGM_relation C (Cn(A)) B" proof (cases ‹φ ∈ Cn(A)›) (*goals: 1. ‹φ ∈ Cn A ⟹ AGM_relation C (Cn A) B› 2. ‹φ ∉ Cn A ⟹ AGM_relation C (Cn A) B›*) case True (*‹φ ∈ Cn A›*) { fix ψ assume "Cn A ÷ ψ ⊆ C" (*‹(Cn::'a set ⇒ 'a set) (A::'a set) ÷ (ψ::'a) ⊆ (C::'a set)›*) hence "Cn A ÷ (φ .∧. ψ) ⊆ Cn A ÷ φ" using contract_conj_inclusion_variant[of ‹Cn(A)› A φ ψ] (*‹Cn A = Cn A ⟹ Cn A ÷ (φ .∧. ψ) ⊆ Cn A ÷ φ ∨ Cn A ÷ (φ .∧. ψ) ⊆ Cn A ÷ ψ›*) by (metis (mono_tags, lifting) assumption_L (*‹?φ ∈ ?A ⟹ ?A ⊢ ?φ›*) contract_conj_inclusion (*‹⟦?K = Cn ?A; ?φ ∉ ?K ÷ (?φ .∧. ?ψ)⟧ ⟹ ?K ÷ (?φ .∧. ?ψ) ⊆ ?K ÷ ?φ›*) d (*‹C ∈ Cn A .⊥. φ›*) mem_Collect_eq (*‹(?a ∈ Collect ?P) = ?P ?a›*) rem (*‹?A .⊥. ?φ ≡ {B. B ⊆ ?A ∧ ¬ B ⊢ ?φ ∧ (∀B'⊆?A. B ⊂ B' ⟶ B' ⊢ ?φ)}›*) subset_iff (*‹(?A ⊆ ?B) = (∀t. t ∈ ?A ⟶ t ∈ ?B)›*)) } note f = this (*‹Cn A ÷ ?ψ2 ⊆ C ⟹ Cn A ÷ (φ .∧. ?ψ2) ⊆ Cn A ÷ φ›*) { fix ψ and φ' assume g: "ψ ∈ Cn A ÷ φ'" and h: "B ∈ Cn A .⊥. φ'" and j: "Cn A ÷ φ' ⊆ C" and i: "ψ ∉ B" (*‹(ψ::'a) ∈ (Cn::'a set ⇒ 'a set) (A::'a set) ÷ (φ'::'a)› ‹(B::'a set) ∈ (Cn::'a set ⇒ 'a set) (A::'a set) .⊥. (φ'::'a)› ‹(Cn::'a set ⇒ 'a set) (A::'a set) ÷ (φ'::'a) ⊆ (C::'a set)› ‹(ψ::'a) ∉ (B::'a set)›*) hence "φ' .∨. ψ ∈ Cn A ÷ φ'" using Supraclassical_logic.disjI2_PL (*‹⟦Supraclassical_logic ?Cn ?true_PL ?false_PL ?imp_PL ?not_PL ?conj_PL ?disj_PL ?equiv_PL; ?q ∈ ?Cn ?A⟧ ⟹ ?disj_PL ?p ?q ∈ ?Cn ?A›*) Supraclassical_logic_axioms (*‹Supraclassical_logic Cn ⊤ ⊥ (.⟶.) .¬ (.∧.) (.∨.) (.⟷.)›*) contract_closure (*‹?K = Cn ?A ⟹ ?K ÷ ?φ = Cn (?K ÷ ?φ)›*) by fastforce hence k: "φ' .∨. ψ ∈ Cn A ÷ φ" using contract_conj_overlap_variant[of ‹Cn(A)› A φ' φ] (*‹Cn A = Cn A ⟹ (Cn A ÷ φ') ∩ Cn {φ'} ⊆ Cn A ÷ (φ' .∧. φ)›*) f[OF j] (*‹Cn A ÷ (φ .∧. φ') ⊆ Cn A ÷ φ›*) by (metis IntI (*‹⟦?c ∈ ?A; ?c ∈ ?B⟧ ⟹ ?c ∈ ?A ∩ ?B›*) Supraclassical_logic.disjI1_PL (*‹⟦Supraclassical_logic ?Cn ?true_PL ?false_PL ?imp_PL ?not_PL ?conj_PL ?disj_PL ?equiv_PL; ?p ∈ ?Cn ?A⟧ ⟹ ?disj_PL ?p ?q ∈ ?Cn ?A›*) Supraclassical_logic_axioms (*‹Supraclassical_logic Cn ⊤ ⊥ (.⟶.) .¬ (.∧.) (.∨.) (.⟷.)›*) conj_com_Cn (*‹Cn {?p .∧. ?q} = Cn {?q .∧. ?p}›*) contract_extensionality (*‹⟦?K = Cn ?A; Cn {?φ} = Cn {?ψ}⟧ ⟹ ?K ÷ ?φ = ?K ÷ ?ψ›*) inclusion_L (*‹?A ⊆ Cn ?A›*) singletonI (*‹?a ∈ {?a}›*) subsetD (*‹⟦?A ⊆ ?B; ?c ∈ ?A⟧ ⟹ ?c ∈ ?B›*)) hence l: "Cn A ÷ φ ⊆ B" using c (*‹⋂ {B::'a set ∈ (Cn::'a set ⇒ 'a set) (A::'a set) .⊥. (φ::'a). Cn A ÷ φ ⊆ B} ⊆ (B::'a set)›*) by auto from k (*‹φ' .∨. ψ ∈ Cn A ÷ φ›*) l (*‹Cn A ÷ φ ⊆ B›*) have m: "φ' .∨. ψ ∈ B" and n: "B =Cn(B)" using b (*‹B ∈ Cn A .⊥. φ›*) rem_closure (*‹⟦?K = Cn ?A; ?B ∈ ?K .⊥. ?φ⟧ ⟹ ?B = Cn ?B›*) apply - (*goals: 1. ‹⟦φ' .∨. ψ ∈ Cn A ÷ φ; Cn A ÷ φ ⊆ B; B ∈ Cn A .⊥. φ; ⋀K A B φ. ⟦K = Cn A; B ∈ K .⊥. φ⟧ ⟹ B = Cn B⟧ ⟹ φ' .∨. ψ ∈ B› 2. ‹⟦φ' .∨. ψ ∈ Cn A ÷ φ; Cn A ÷ φ ⊆ B; B ∈ Cn A .⊥. φ; ⋀K A B φ. ⟦K = Cn A; B ∈ K .⊥. φ⟧ ⟹ B = Cn B⟧ ⟹ B = Cn B› discuss goal 1*) apply blast (*discuss goal 2*) apply blast (*proven 2 subgoals*) . have "B ∪ {ψ} ⊢ φ'" using g (*‹ψ ∈ Cn A ÷ φ'›*) h (*‹B ∈ Cn A .⊥. φ'›*) i (*‹ψ ∉ B›*) apply (simp add:rem (*‹?A .⊥. ?φ ≡ {B. B ⊆ ?A ∧ ¬ B ⊢ ?φ ∧ (∀B'⊆?A. B ⊂ B' ⟶ B' ⊢ ?φ)}›*)) (*goal: ‹B ∪ {ψ} ⊢ φ'›*) by (metis contract_inclusion (*‹(?K::'a::type set) = (Cn::'a::type set ⇒ 'a::type set) (?A::'a::type set) ⟹ ?K ÷ (?φ::'a::type) ⊆ ?K›*) insertI1 (*‹(?a::?'a::type) ∈ insert ?a (?B::?'a::type set)›*) insert_subsetI (*‹⟦(?x::?'a::type) ∈ (?A::?'a::type set); (?X::?'a::type set) ⊆ ?A⟧ ⟹ insert ?x ?X ⊆ ?A›*) psubsetI (*‹⟦(?A::?'a::type set) ⊆ (?B::?'a::type set); ?A ≠ ?B⟧ ⟹ ?A ⊂ ?B›*) subsetD (*‹⟦(?A::?'a::type set) ⊆ (?B::?'a::type set); (?c::?'a::type) ∈ ?A⟧ ⟹ ?c ∈ ?B›*) subset_insertI (*‹(?B::?'a::type set) ⊆ insert (?a::?'a::type) ?B›*)) with n (*‹(B::'a set) = (Cn::'a set ⇒ 'a set) B›*) m (*‹(φ'::'a) .∨. (ψ::'a) ∈ (B::'a set)›*) have "B ⊢ φ'" by (metis Cn_equiv (*‹(?A ⊢ ?p .⟷. ?q) = (Cn (?A ∪ {?p}) = Cn (?A ∪ {?q}))›*) assumption_L (*‹?φ ∈ ?A ⟹ ?A ⊢ ?φ›*) disjE_PL (*‹⟦?A ⊢ ?p .∨. ?q; ?A ⊢ ?p .⟶. ?r; ?A ⊢ ?q .⟶. ?r⟧ ⟹ ?A ⊢ ?r›*) disj_com (*‹(?A ⊢ ?p .∨. ?q) = (?A ⊢ ?q .∨. ?p)›*) equiv_PL (*‹(?A ⊢ ?p .⟷. ?q) = (?A ∪ {?p} ⊢ ?q ∧ ?A ∪ {?q} ⊢ ?p)›*) imp_PL (*‹(?A ⊢ ?p .⟶. ?q) = (?A ∪ {?p} ⊢ ?q)›*)) with h (*‹B ∈ Cn A .⊥. φ'›*) have False using assumption_L (*‹?φ ∈ ?A ⟹ ?A ⊢ ?φ›*) rem (*‹?A .⊥. ?φ ≡ {B. B ⊆ ?A ∧ ¬ B ⊢ ?φ ∧ (∀B'⊆?A. B ⊂ B' ⟶ B' ⊢ ?φ)}›*) by auto } note g = this (*‹⟦?ψ2 ∈ Cn A ÷ ?φ'2; B ∈ Cn A .⊥. ?φ'2; Cn A ÷ ?φ'2 ⊆ C; ?ψ2 ∉ B⟧ ⟹ False›*) with True (*‹φ ∈ Cn A›*) show "?thesis" (*goal: ‹AGM_relation C (Cn A) B›*) apply (unfold AGM_rel (*‹AGM_relation ?C ?K ?B ≡ ?C = ?K ∧ ?B = ?K ∨ (∃φ. ?K ⊢ φ ∧ ?C ∈ ?K .⊥. φ) ∧ (∃φ. ?K ⊢ φ ∧ ?B ∈ ?K .⊥. φ ∧ ?K ÷ φ ⊆ ?B) ∧ (∀φ. ?K ⊢ φ ∧ ?C ∈ ?K .⊥. φ ∧ ?B ∈ ?K .⊥. φ ∧ ?K ÷ φ ⊆ ?C ⟶ ?K ÷ φ ⊆ ?B)›*), rule_tac disjI2 (*‹?Q ⟹ ?P ∨ ?Q›*)) (*goal: ‹AGM_relation C (Cn A) B›*) using d (*‹C ∈ Cn A .⊥. φ›*) b (*‹(B::'a set) ∈ (Cn::'a set ⇒ 'a set) (A::'a set) .⊥. (φ::'a)›*) c (*‹⋂ {B::'a set ∈ (Cn::'a set ⇒ 'a set) (A::'a set) .⊥. (φ::'a). Cn A ÷ φ ⊆ B} ⊆ (B::'a set)›*) apply (auto simp add:AGM_rel (*‹AGM_relation ?C ?K ?B ≡ ?C = ?K ∧ ?B = ?K ∨ (∃φ. ?K ⊢ φ ∧ ?C ∈ ?K .⊥. φ) ∧ (∃φ. ?K ⊢ φ ∧ ?B ∈ ?K .⊥. φ ∧ ?K ÷ φ ⊆ ?B) ∧ (∀φ. ?K ⊢ φ ∧ ?C ∈ ?K .⊥. φ ∧ ?B ∈ ?K .⊥. φ ∧ ?K ÷ φ ⊆ ?C ⟶ ?K ÷ φ ⊆ ?B)›*) idempotency_L (*‹Cn (Cn ?A) = Cn ?A›*) del:subsetI (*‹(⋀x. x ∈ ?A ⟹ x ∈ ?B) ⟹ ?A ⊆ ?B›*)) (*goals: 1. ‹⟦⋀ψ φ'. ⟦ψ ∈ Cn A ÷ φ'; B ∈ Cn A .⊥. φ'; Cn A ÷ φ' ⊆ C; ψ ∉ B⟧ ⟹ False; φ ∈ Cn A; ⋀ψ φ'. ⟦ψ ∈ Cn A ÷ φ'; B ∈ Cn A .⊥. φ'; Cn A ÷ φ' ⊆ C; ψ ∉ B⟧ ⟹ False; C ∈ Cn A .⊥. φ; B ∈ Cn A .⊥. φ; ⋂ {B ∈ Cn A .⊥. φ. Cn A ÷ φ ⊆ B} ⊆ B⟧ ⟹ ∃φ. φ ∈ Cn A ∧ B ∈ Cn A .⊥. φ ∧ Cn A ÷ φ ⊆ B› 2. ‹⋀φ'. ⟦⋀ψ φ'. ⟦ψ ∈ Cn A ÷ φ'; B ∈ Cn A .⊥. φ'; Cn A ÷ φ' ⊆ C; ψ ∉ B⟧ ⟹ False; φ ∈ Cn A; ⋀ψ φ'. ⟦ψ ∈ Cn A ÷ φ'; B ∈ Cn A .⊥. φ'; Cn A ÷ φ' ⊆ C; ψ ∉ B⟧ ⟹ False; C ∈ Cn A .⊥. φ; B ∈ Cn A .⊥. φ; ⋂ {B ∈ Cn A .⊥. φ. Cn A ÷ φ ⊆ B} ⊆ B; φ' ∈ Cn A; C ∈ Cn A .⊥. φ'; B ∈ Cn A .⊥. φ'; Cn A ÷ φ' ⊆ C⟧ ⟹ Cn A ÷ φ' ⊆ B› discuss goal 1*) apply blast (*discuss goal 2*) apply blast (*proven 2 subgoals*) . next (*goal: ‹φ ∉ Cn A ⟹ AGM_relation C (Cn A) B›*) case False (*‹(φ::'a::type) ∉ (Cn::'a::type set ⇒ 'a::type set) (A::'a::type set)›*) then show "?thesis" (*goal: ‹AGM_relation C (Cn A) B›*) by (metis AGM_rel (*‹AGM_relation ?C ?K ?B ≡ ?C = ?K ∧ ?B = ?K ∨ (∃φ. ?K ⊢ φ ∧ ?C ∈ ?K .⊥. φ) ∧ (∃φ. ?K ⊢ φ ∧ ?B ∈ ?K .⊥. φ ∧ ?K ÷ φ ⊆ ?B) ∧ (∀φ. ?K ⊢ φ ∧ ?C ∈ ?K .⊥. φ ∧ ?B ∈ ?K .⊥. φ ∧ ?K ÷ φ ⊆ ?C ⟶ ?K ÷ φ ⊆ ?B)›*) b (*‹B ∈ Cn A .⊥. φ›*) d (*‹C ∈ Cn A .⊥. φ›*) idempotency_L (*‹Cn (Cn ?A) = Cn ?A›*) infer_def (*‹?A ⊢ ?φ ≡ ?φ ∈ Cn ?A›*) nonconsequence_remainder (*‹(?A .⊥. ?φ = {?A}) = (¬ ?A ⊢ ?φ)›*) singletonD (*‹?b ∈ {?a} ⟹ ?b = ?a›*)) qed next (*goal: ‹⋀x xa xb. ⟦K = Cn A; x ∈ Cn A .⊥. φ; xa ∈ Cn A .⊥. φ; ∀C∈Cn A .⊥. φ. AGM_relation C (Cn A) xa; ∀x. x ∈ Cn A .⊥. φ ∧ Cn A ÷ φ ⊆ x ⟶ xb ∈ x⟧ ⟹ xb ∈ xa›*) fix S and B and ψ assume a: "S ∈ Cn(A) .⊥. φ" and b: "B ∈ Cn(A) .⊥. φ" and c: "∀C∈Cn A .⊥. φ. AGM_relation C (Cn A) B" and d: "∀C'. C' ∈ Cn A .⊥. φ ∧ Cn A ÷ φ ⊆ C' ⟶ ψ ∈ C'" (*‹(S::'a set) ∈ (Cn::'a set ⇒ 'a set) (A::'a set) .⊥. (φ::'a)› ‹(B::'a set) ∈ (Cn::'a set ⇒ 'a set) (A::'a set) .⊥. (φ::'a)› ‹∀C::'a set∈(Cn::'a set ⇒ 'a set) (A::'a set) .⊥. (φ::'a). AGM_relation C (Cn A) (B::'a set)› ‹∀C'::'a set. C' ∈ (Cn::'a set ⇒ 'a set) (A::'a set) .⊥. (φ::'a) ∧ Cn A ÷ φ ⊆ C' ⟶ (ψ::'a) ∈ C'›*) then show "ψ ∈ B" unfolding AGM_rel (*goal: ‹ψ ∈ B›*) by (metis (no_types, lifting) AGM_sel (*‹γ⇩A⇩G⇩M ?A ?φ ≡ if ?A .⊥. ?φ = {} then {?A} else {B ∈ ?A .⊥. ?φ. ?A ÷ ?φ ⊆ B}›*) empty_Collect_eq (*‹({} = Collect ?P) = (∀x. ¬ ?P x)›*) insert_Diff (*‹?a ∈ ?A ⟹ insert ?a (?A - {?a}) = ?A›*) insert_not_empty (*‹insert ?a ?A ≠ {}›*) nonconsequence_remainder (*‹(?A .⊥. ?φ = {?A}) = (¬ ?A ⊢ ?φ)›*) nonempty_selection (*‹?K = Cn ?A ⟹ γ⇩A⇩G⇩M ?K ?φ ≠ {}›*) singletonD (*‹?b ∈ {?a} ⟹ ?b = ?a›*)) qed text‹A transitively relational selection and an AGM relation is a transitively relational meet contraction› sublocale TransitivelyRelationalMeetContraction where relation = AGM_relation and rel_sel = ‹γ⇩A⇩G⇩M⇩T⇩R› proof (unfold_locales, simp_all (no_asm) only:atomize_eq, goal_cases) (*goals: 1. ‹⋀(K::'a set) (A::'a set) (B::'a set) (C::'a set) D::'a set. ⟦K = (Cn::'a set ⇒ 'a set) A; AGM_relation B K C; AGM_relation C K D⟧ ⟹ AGM_relation B K D› 2. ‹⋀(K::'a set) (A::'a set) φ::'a. ⟦K = (Cn::'a set ⇒ 'a set) A; K .⊥. φ ≠ {}⟧ ⟹ ∃B::'a set∈K .⊥. φ. ∀C::'a set∈K .⊥. φ. AGM_relation C K B› 3. ‹⋀(K::'a set) φ::'a. γ⇩A⇩G⇩M⇩T⇩R K φ = (if K .⊥. φ = {} then {K} else {B::'a set ∈ K .⊥. φ. ∀C::'a set∈K .⊥. φ. AGM_relation C K B})›*) case a: (1 K A C B' B) (*‹K = Cn A› ‹AGM_relation C K B'› ‹AGM_relation (B'::'a set) (K::'a set) (B::'a set)›*) from a(2,3) (*‹AGM_relation C K B'› ‹AGM_relation B' K B›*) show "?case" (*goal: ‹AGM_relation C K B›*) unfolding AGM_rel (*goal: ‹C = K ∧ B = K ∨ (∃φ. K ⊢ φ ∧ C ∈ K .⊥. φ) ∧ (∃φ. K ⊢ φ ∧ B ∈ K .⊥. φ ∧ K ÷ φ ⊆ B) ∧ (∀φ. K ⊢ φ ∧ C ∈ K .⊥. φ ∧ B ∈ K .⊥. φ ∧ K ÷ φ ⊆ C ⟶ K ÷ φ ⊆ B)›*) apply (elim disjE (*‹⟦?P ∨ ?Q; ?P ⟹ ?R; ?Q ⟹ ?R⟧ ⟹ ?R›*) conjE (*‹⟦?P ∧ ?Q; ⟦?P; ?Q⟧ ⟹ ?R⟧ ⟹ ?R›*), simp_all) (*goal: ‹C = K ∧ B = K ∨ (∃φ. K ⊢ φ ∧ C ∈ K .⊥. φ) ∧ (∃φ. K ⊢ φ ∧ B ∈ K .⊥. φ ∧ K ÷ φ ⊆ B) ∧ (∀φ. K ⊢ φ ∧ C ∈ K .⊥. φ ∧ B ∈ K .⊥. φ ∧ K ÷ φ ⊆ C ⟶ K ÷ φ ⊆ B)›*) proof (intro disjI2 (*‹?Q ⟹ ?P ∨ ?Q›*) allI (*‹(⋀x. ?P x) ⟹ ∀x. ?P x›*) impI (*‹(?P ⟹ ?Q) ⟹ ?P ⟶ ?Q›*), elim exE (*‹⟦∃x::?'a::type. (?P::?'a::type ⇒ bool) x; ⋀x::?'a::type. ?P x ⟹ ?Q::bool⟧ ⟹ ?Q›*) conjE (*‹⟦(?P::bool) ∧ (?Q::bool); ⟦?P; ?Q⟧ ⟹ ?R::bool⟧ ⟹ ?R›*), goal_cases) (*goal: ‹⋀(φ::'a) (φ'::'a) (φ''::'a) (φ'''::'a) φ''''::'a. ⟦∀φ::'a. φ ∈ (Cn::'a set ⇒ 'a set) (K::'a set) ∧ (C::'a set) ∈ K .⊥. φ ∧ (B'::'a set) ∈ K .⊥. φ ∧ K ÷ φ ⊆ C ⟶ K ÷ φ ⊆ B'; ∀φ::'a. φ ∈ Cn K ∧ B' ∈ K .⊥. φ ∧ (B::'a set) ∈ K .⊥. φ ∧ K ÷ φ ⊆ B' ⟶ K ÷ φ ⊆ B; φ ∈ Cn K; φ' ∈ Cn K; C ∈ K .⊥. φ'; φ'' ∈ Cn K; B' ∈ K .⊥. φ''; φ''' ∈ Cn K; φ'''' ∈ Cn K; C ∈ K .⊥. φ; B' ∈ K .⊥. φ'''; K ÷ φ''' ⊆ B'; B ∈ K .⊥. φ''''; K ÷ φ'''' ⊆ B; B ∈ K .⊥. φ; K ÷ φ ⊆ C⟧ ⟹ K ÷ φ ⊆ B›*) case (1 ψ__ φ) (*‹∀φ. φ ∈ Cn K ∧ C ∈ K .⊥. φ ∧ B' ∈ K .⊥. φ ∧ K ÷ φ ⊆ C ⟶ K ÷ φ ⊆ B'› ‹∀φ. φ ∈ Cn K ∧ B' ∈ K .⊥. φ ∧ B ∈ K .⊥. φ ∧ K ÷ φ ⊆ B' ⟶ K ÷ φ ⊆ B› ‹ψ ∈ Cn K› ‹φ'_ ∈ Cn K› ‹(C::'a::type set) ∈ (K::'a::type set) .⊥. (φ'_::'a::type)› ‹φ''_ ∈ Cn K› ‹(B'::'a::type set) ∈ (K::'a::type set) .⊥. (φ''_::'a::type)› ‹φ ∈ Cn K› ‹(φ''''_::'a::type) ∈ (Cn::'a::type set ⇒ 'a::type set) (K::'a::type set)› ‹C ∈ K .⊥. ψ› ‹(B'::'a::type set) ∈ (K::'a::type set) .⊥. (φ::'a::type)› ‹K ÷ φ ⊆ B'› ‹B ∈ K .⊥. φ''''_› ‹K ÷ φ''''_ ⊆ B› ‹B ∈ K .⊥. ψ› ‹K ÷ ψ ⊆ C›*) have b: "B ∈ K .⊥. (φ .∧. ψ)" and c: "B' ∈ K .⊥. (φ .∧. ψ)" and d: "C ∈ K .⊥. (φ .∧. ψ)" using remainder_conj[OF a ( 1 )] (*‹K ⊢ ?φ .∧. ?ψ ⟹ K .⊥. (?φ .∧. ?ψ) = (K .⊥. ?φ) ∪ (K .⊥. ?ψ)›*) "1" (*‹∀φ. φ ∈ Cn K ∧ C ∈ K .⊥. φ ∧ B' ∈ K .⊥. φ ∧ K ÷ φ ⊆ C ⟶ K ÷ φ ⊆ B'› ‹∀φ. φ ∈ Cn K ∧ B' ∈ K .⊥. φ ∧ B ∈ K .⊥. φ ∧ K ÷ φ ⊆ B' ⟶ K ÷ φ ⊆ B› ‹(ψ::'a::type) ∈ (Cn::'a::type set ⇒ 'a::type set) (K::'a::type set)› ‹φ'_ ∈ Cn K› ‹(C::'a set) ∈ (K::'a set) .⊥. (φ'_::'a)› ‹φ''_ ∈ Cn K› ‹B' ∈ K .⊥. φ''_› ‹φ ∈ Cn K› ‹φ''''_ ∈ Cn K› ‹C ∈ K .⊥. ψ› ‹B' ∈ K .⊥. φ› ‹K ÷ φ ⊆ B'› and more 4 facts*) conjI_PL (*‹⟦(?A::'a set) ⊢ (?p::'a); ?A ⊢ (?q::'a)⟧ ⟹ ?A ⊢ ?p .∧. ?q›*) apply - (*goals: 1. ‹⟦⋀φ ψ. K ⊢ φ .∧. ψ ⟹ K .⊥. (φ .∧. ψ) = (K .⊥. φ) ∪ (K .⊥. ψ); ∀φ. φ ∈ Cn K ∧ C ∈ K .⊥. φ ∧ B' ∈ K .⊥. φ ∧ K ÷ φ ⊆ C ⟶ K ÷ φ ⊆ B'; ∀φ. φ ∈ Cn K ∧ B' ∈ K .⊥. φ ∧ B ∈ K .⊥. φ ∧ K ÷ φ ⊆ B' ⟶ K ÷ φ ⊆ B; ψ ∈ Cn K; φ'_ ∈ Cn K; C ∈ K .⊥. φ'_; φ''_ ∈ Cn K; B' ∈ K .⊥. φ''_; φ ∈ Cn K; φ''''_ ∈ Cn K; C ∈ K .⊥. ψ; B' ∈ K .⊥. φ; K ÷ φ ⊆ B'; B ∈ K .⊥. φ''''_; K ÷ φ''''_ ⊆ B; B ∈ K .⊥. ψ; K ÷ ψ ⊆ C; ⋀A p q. ⟦A ⊢ p; A ⊢ q⟧ ⟹ A ⊢ p .∧. q⟧ ⟹ B ∈ K .⊥. (φ .∧. ψ)› 2. ‹⟦⋀φ ψ. K ⊢ φ .∧. ψ ⟹ K .⊥. (φ .∧. ψ) = (K .⊥. φ) ∪ (K .⊥. ψ); ∀φ. φ ∈ Cn K ∧ C ∈ K .⊥. φ ∧ B' ∈ K .⊥. φ ∧ K ÷ φ ⊆ C ⟶ K ÷ φ ⊆ B'; ∀φ. φ ∈ Cn K ∧ B' ∈ K .⊥. φ ∧ B ∈ K .⊥. φ ∧ K ÷ φ ⊆ B' ⟶ K ÷ φ ⊆ B; ψ ∈ Cn K; φ'_ ∈ Cn K; C ∈ K .⊥. φ'_; φ''_ ∈ Cn K; B' ∈ K .⊥. φ''_; φ ∈ Cn K; φ''''_ ∈ Cn K; C ∈ K .⊥. ψ; B' ∈ K .⊥. φ; K ÷ φ ⊆ B'; B ∈ K .⊥. φ''''_; K ÷ φ''''_ ⊆ B; B ∈ K .⊥. ψ; K ÷ ψ ⊆ C; ⋀A p q. ⟦A ⊢ p; A ⊢ q⟧ ⟹ A ⊢ p .∧. q⟧ ⟹ B' ∈ K .⊥. (φ .∧. ψ)› 3. ‹⟦⋀φ ψ. K ⊢ φ .∧. ψ ⟹ K .⊥. (φ .∧. ψ) = (K .⊥. φ) ∪ (K .⊥. ψ); ∀φ. φ ∈ Cn K ∧ C ∈ K .⊥. φ ∧ B' ∈ K .⊥. φ ∧ K ÷ φ ⊆ C ⟶ K ÷ φ ⊆ B'; ∀φ. φ ∈ Cn K ∧ B' ∈ K .⊥. φ ∧ B ∈ K .⊥. φ ∧ K ÷ φ ⊆ B' ⟶ K ÷ φ ⊆ B; ψ ∈ Cn K; φ'_ ∈ Cn K; C ∈ K .⊥. φ'_; φ''_ ∈ Cn K; B' ∈ K .⊥. φ''_; φ ∈ Cn K; φ''''_ ∈ Cn K; C ∈ K .⊥. ψ; B' ∈ K .⊥. φ; K ÷ φ ⊆ B'; B ∈ K .⊥. φ''''_; K ÷ φ''''_ ⊆ B; B ∈ K .⊥. ψ; K ÷ ψ ⊆ C; ⋀A p q. ⟦A ⊢ p; A ⊢ q⟧ ⟹ A ⊢ p .∧. q⟧ ⟹ C ∈ K .⊥. (φ .∧. ψ)› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*proven 3 subgoals*) . hence e: "K ÷ (φ .∧. ψ) ⊆ B" using contract_conj_inclusion_variant[OF a ( 1 ), of φ ψ] (*‹(K::'a::type set) ÷ ((φ::'a::type) .∧. (ψ::'a::type)) ⊆ K ÷ φ ∨ K ÷ (φ .∧. ψ) ⊆ K ÷ ψ›*) by (meson "1" (*‹∀φ. φ ∈ Cn K ∧ C ∈ K .⊥. φ ∧ B' ∈ K .⊥. φ ∧ K ÷ φ ⊆ C ⟶ K ÷ φ ⊆ B'›*) (1) "1" (*‹K ÷ φ ⊆ B'›*) (12) "1" (*‹K ÷ ψ ⊆ C›*) (16) "1" (*‹∀φ. φ ∈ Cn K ∧ B' ∈ K .⊥. φ ∧ B ∈ K .⊥. φ ∧ K ÷ φ ⊆ B' ⟶ K ÷ φ ⊆ B›*) (2) "1" (*‹ψ ∈ Cn K›*) (3) "1" (*‹φ ∈ Cn K›*) (8) Supraclassical_logic.conj_PL (*‹Supraclassical_logic ?Cn ?true_PL ?false_PL ?imp_PL ?not_PL ?conj_PL ?disj_PL ?equiv_PL ⟹ (?conj_PL ?p ?q ∈ ?Cn ?A) = (?p ∈ ?Cn ?A ∧ ?q ∈ ?Cn ?A)›*) Supraclassical_logic_axioms (*‹Supraclassical_logic Cn ⊤ ⊥ (.⟶.) .¬ (.∧.) (.∨.) (.⟷.)›*) dual_order.trans (*‹⟦?b ≤ ?a; ?c ≤ ?b⟧ ⟹ ?c ≤ ?a›*)) { fix χ assume f: "χ ∈ K ÷ ψ" (*‹(χ::'a) ∈ (K::'a set) ÷ (ψ::'a)›*) have "ψ .∨. χ ∈ (K ÷ ψ) ∩ Cn {ψ}" by (metis Int_iff (*‹(?c ∈ ?A ∩ ?B) = (?c ∈ ?A ∧ ?c ∈ ?B)›*) Supraclassical_logic.disjI1_PL (*‹⟦Supraclassical_logic ?Cn ?true_PL ?false_PL ?imp_PL ?not_PL ?conj_PL ?disj_PL ?equiv_PL; ?p ∈ ?Cn ?A⟧ ⟹ ?disj_PL ?p ?q ∈ ?Cn ?A›*) Supraclassical_logic.disjI2_PL (*‹⟦Supraclassical_logic ?Cn ?true_PL ?false_PL ?imp_PL ?not_PL ?conj_PL ?disj_PL ?equiv_PL; ?q ∈ ?Cn ?A⟧ ⟹ ?disj_PL ?p ?q ∈ ?Cn ?A›*) Supraclassical_logic_axioms (*‹Supraclassical_logic Cn ⊤ ⊥ (.⟶.) .¬ (.∧.) (.∨.) (.⟷.)›*) f (*‹χ ∈ K ÷ ψ›*) a( (*‹K = Cn A›*) 1) contract_closure (*‹?K = Cn ?A ⟹ ?K ÷ ?φ = Cn (?K ÷ ?φ)›*) in_mono (*‹?A ⊆ ?B ⟹ ?x ∈ ?A ⟶ ?x ∈ ?B›*) inclusion_L (*‹?A ⊆ Cn ?A›*) singletonI (*‹?a ∈ {?a}›*)) hence g: "ψ .∨. χ ∈ B" using contract_conj_overlap_variant[OF a ( 1 ), of ψ] (*‹((K::'a set) ÷ (ψ::'a)) ∩ (Cn::'a set ⇒ 'a set) {ψ} ⊆ K ÷ (ψ .∧. (?ψ::'a))›*) by (metis AGM_Contraction.contract_extensionality (*‹⟦AGM_Contraction ?Cn ?contraction; ?K = ?Cn ?A; ?Cn {?φ} = ?Cn {?ψ}⟧ ⟹ ?contraction ?K ?φ = ?contraction ?K ?ψ›*) AGM_Contraction_axioms (*‹AGM_Contraction Cn (÷)›*) a( (*‹K = Cn A›*) 1) conj_com_Cn (*‹Cn {?p .∧. ?q} = Cn {?q .∧. ?p}›*) e (*‹K ÷ (φ .∧. ψ) ⊆ B›*) in_mono (*‹?A ⊆ ?B ⟹ ?x ∈ ?A ⟶ ?x ∈ ?B›*)) have "ψ .⟶. χ ∈ B" by (metis a( (*‹K = Cn A›*) 1) "1" (*‹C ∈ K .⊥. ψ›*) (10) "1" (*‹B ∈ K .⊥. ψ›*) (15) "1" (*‹K ÷ ψ ⊆ C›*) (16) assumption_L (*‹?φ ∈ ?A ⟹ ?A ⊢ ?φ›*) f (*‹χ ∈ K ÷ ψ›*) in_mono (*‹?A ⊆ ?B ⟹ ?x ∈ ?A ⟶ ?x ∈ ?B›*) infer_def (*‹?A ⊢ ?φ ≡ ?φ ∈ Cn ?A›*) rem_closure (*‹⟦?K = Cn ?A; ?B ∈ ?K .⊥. ?φ⟧ ⟹ ?B = Cn ?B›*) rem_inclusion (*‹?B ∈ ?A .⊥. ?φ ⟹ ?B ⊆ ?A›*) remainder_recovery (*‹⟦?K = Cn ?A; ?K ⊢ ?ψ; ?B ∈ ?K .⊥. ?φ⟧ ⟹ ?B ⊢ ?φ .⟶. ?ψ›*)) with g (*‹ψ .∨. χ ∈ B›*) have "χ ∈ B" by (metis 1( (*‹(B::'a set) ∈ (K::'a set) .⊥. (ψ::'a)›*) 15) a( (*‹(K::'a set) = (Cn::'a set ⇒ 'a set) (A::'a set)›*) 1) disjE_PL (*‹⟦(?A::'a set) ⊢ (?p::'a) .∨. (?q::'a); ?A ⊢ ?p .⟶. (?r::'a); ?A ⊢ ?q .⟶. ?r⟧ ⟹ ?A ⊢ ?r›*) infer_def (*‹(?A::'a set) ⊢ (?φ::'a) ≡ ?φ ∈ (Cn::'a set ⇒ 'a set) ?A›*) order_refl (*‹(?x::?'a) ≤ ?x›*) rem_closure (*‹⟦(?K::'a set) = (Cn::'a set ⇒ 'a set) (?A::'a set); (?B::'a set) ∈ ?K .⊥. (?φ::'a)⟧ ⟹ ?B = Cn ?B›*) validD_L (*‹⊩ (?φ::'a) ⟹ ?φ ∈ (Cn::'a set ⇒ 'a set) (?A::'a set)›*) valid_Cn_imp (*‹⊩ ((?p::'a) .⟶. (?q::'a)) = ((Cn::'a set ⇒ 'a set) {?q} ⊆ Cn {?p})›*)) } then show "?case" (*goal: ‹(K::'a set) ÷ (ψ::'a) ⊆ (B::'a set)›*) by blast qed next (*goals: 1. ‹⋀K A φ. ⟦K = Cn A; K .⊥. φ ≠ {}⟧ ⟹ ∃B∈K .⊥. φ. ∀C∈K .⊥. φ. AGM_relation C K B› 2. ‹⋀K φ. γ⇩A⇩G⇩M⇩T⇩R K φ = (if K .⊥. φ = {} then {K} else {B ∈ K .⊥. φ. ∀C∈K .⊥. φ. AGM_relation C K B})›*) case (2 K A φ) (*‹K = Cn A› ‹K .⊥. φ ≠ {}›*) hence "* γ⇩A⇩G⇩M K φ ≠ {}" using nonempty_selection[OF 2 ( 1 ), of φ] (*‹γ⇩A⇩G⇩M K φ ≠ {}›*) selection_completion[OF 2 ( 1 ), of φ] (*‹γ⇩A⇩G⇩M K φ ⊆ * γ⇩A⇩G⇩M K φ›*) by blast then show "?case" (*goal: ‹∃B∈K .⊥. φ. ∀C∈K .⊥. φ. AGM_relation C K B›*) using AGM_rel_sel_completion[OF 2 ( 1 ), of φ] (*‹γ⇩A⇩G⇩M⇩T⇩R K φ = * γ⇩A⇩G⇩M K φ›*) AGM_rel_sel (*‹γ⇩A⇩G⇩M⇩T⇩R ?K ?φ ≡ if ?K .⊥. ?φ = {} then {?K} else {B ∈ ?K .⊥. ?φ. ∀C∈?K .⊥. ?φ. AGM_relation C ?K B}›*) "2"(1,2) (*‹K = Cn A› ‹K .⊥. φ ≠ {}›*) by force next (*goal: ‹⋀(K::'a set) φ::'a. γ⇩A⇩G⇩M⇩T⇩R K φ = (if K .⊥. φ = {} then {K} else {B::'a set ∈ K .⊥. φ. ∀C::'a set∈K .⊥. φ. AGM_relation C K B})›*) case (3 K φ) (*no hyothesis introduced yet*) then show "?case" (*goal: ‹γ⇩A⇩G⇩M⇩T⇩R K φ = (if K .⊥. φ = {} then {K} else {B ∈ K .⊥. φ. ∀C∈K .⊥. φ. AGM_relation C K B})›*) using AGM_rel_sel_completion (*‹?K = Cn ?A ⟹ γ⇩A⇩G⇩M⇩T⇩R ?K ?φ = * γ⇩A⇩G⇩M ?K ?φ›*) AGM_rel_sel (*‹γ⇩A⇩G⇩M⇩T⇩R ?K ?φ ≡ if ?K .⊥. ?φ = {} then {?K} else {B ∈ ?K .⊥. ?φ. ∀C∈?K .⊥. ?φ. AGM_relation C ?K B}›*) by simp qed<close> lemmas fullcontraction_is_pmc = contraction_is_pmc lemmas fullcontraction_is_trmc = contraction_with_completion end locale FMC_SC = FullMeetContraction + TRMC_SC begin lemma full_meet_weak1: ‹K = Cn(A) ⟹ K ⊢ φ ⟹ (K ÷⇘γ⇩F⇩C⇙ φ) = K ∩ Cn({.¬ φ})› proof (intro subset_antisym (*‹⟦?A ⊆ ?B; ?B ⊆ ?A⟧ ⟹ ?A = ?B›*) Int_greatest (*‹⟦?C ⊆ ?A; ?C ⊆ ?B⟧ ⟹ ?C ⊆ ?A ∩ ?B›*)) (*goals: 1. ‹⟦K = Cn A; K ⊢ φ⟧ ⟹ K ÷⇘γ⇩F⇩C⇙ φ ⊆ K› 2. ‹⟦K = Cn A; K ⊢ φ⟧ ⟹ K ÷⇘γ⇩F⇩C⇙ φ ⊆ Cn {.¬ φ}› 3. ‹⟦K = Cn A; K ⊢ φ⟧ ⟹ K ∩ Cn {.¬ φ} ⊆ K ÷⇘γ⇩F⇩C⇙ φ›*) assume a: "K = Cn(A)" and b: "K ⊢ φ" (*‹(K::'a set) = (Cn::'a set ⇒ 'a set) (A::'a set)› ‹(K::'a set) ⊢ (φ::'a)›*) then show " (K ÷⇘γ⇩F⇩C⇙ φ) ⊆ K" by (simp add: Inf_less_eq (*‹⟦⋀v. v ∈ ?A ⟹ v ≤ ?u; ?A ≠ {}⟧ ⟹ Inf ?A ≤ ?u›*) full_sel (*‹γ⇩F⇩C ?K ?φ ≡ if ?K .⊥. ?φ = {} then {?K} else ?K .⊥. ?φ›*) mc (*‹?A ÷⇘?γ⇙ ?φ ≡ ⋂ (?γ ?A ?φ)›*) rem_inclusion (*‹?B ∈ ?A .⊥. ?φ ⟹ ?B ⊆ ?A›*)) next (*goals: 1. ‹⟦K = Cn A; K ⊢ φ⟧ ⟹ K ÷⇘γ⇩F⇩C⇙ φ ⊆ Cn {.¬ φ}› 2. ‹⟦K = Cn A; K ⊢ φ⟧ ⟹ K ∩ Cn {.¬ φ} ⊆ K ÷⇘γ⇩F⇩C⇙ φ›*) assume a: "K = Cn(A)" and b: "K ⊢ φ" (*‹(K::'a set) = (Cn::'a set ⇒ 'a set) (A::'a set)› ‹(K::'a set) ⊢ (φ::'a)›*) show "(K ÷⇘γ⇩F⇩C⇙ φ) ⊆ Cn({.¬ φ})" proof (standard) (*goal: ‹⋀x. x ∈ K ÷⇘γ⇩F⇩C⇙ φ ⟹ x ∈ Cn {.¬ φ}›*) fix ψ assume c: "ψ ∈ (K ÷⇘γ⇩F⇩C⇙ φ)" (*‹(ψ::'a) ∈ (K::'a set) ÷⇘γ⇩F⇩C⇙ (φ::'a)›*) { assume "¬ {.¬ φ} ⊢ ψ" (*‹¬ {.¬ (φ::'a)} ⊢ (ψ::'a)›*) hence "¬ {.¬ ψ} ⊢ φ" by (metis Un_insert_right (*‹(?A::?'a set) ∪ insert (?a::?'a) (?B::?'a set) = insert ?a (?A ∪ ?B)›*) insert_is_Un (*‹insert (?a::?'a) (?A::?'a set) = {?a} ∪ ?A›*) not_PL (*‹((?A::'a set) ⊢ .¬ (?p::'a)) = (?A ∪ {?p} ⊢ ⊥)›*) notnot_PL (*‹((?A::'a set) ⊢ .¬ (.¬ (?p::'a))) = (?A ⊢ ?p)›*)) hence "¬ {φ .∨. .¬ ψ} ⊢ φ" by (metis assumption_L (*‹?φ ∈ ?A ⟹ ?A ⊢ ?φ›*) disjI2_PL (*‹?A ⊢ ?q ⟹ ?A ⊢ ?p .∨. ?q›*) singleton_iff (*‹(?b ∈ {?a}) = (?b = ?a)›*) transitivity2_L (*‹⟦∀φ∈?B. ?A ⊢ φ; ?B ⊢ ?ψ⟧ ⟹ ?A ⊢ ?ψ›*)) then obtain B where d: "{φ .∨. .¬ ψ} ⊆ B" and e: "B ∈ K .⊥. φ" (*goal: ‹(⋀B::'a set. ⟦{(φ::'a) .∨. .¬ (ψ::'a)} ⊆ B; B ∈ (K::'a set) .⊥. φ⟧ ⟹ thesis::bool) ⟹ thesis›*) by (metis a (*‹K = Cn A›*) b (*‹K ⊢ φ›*) disjI1_PL (*‹?A ⊢ ?p ⟹ ?A ⊢ ?p .∨. ?q›*) empty_subsetI (*‹{} ⊆ ?A›*) idempotency_L (*‹Cn (Cn ?A) = Cn ?A›*) infer_def (*‹?A ⊢ ?φ ≡ ?φ ∈ Cn ?A›*) insert_subset (*‹(insert ?x ?A ⊆ ?B) = (?x ∈ ?B ∧ ?A ⊆ ?B)›*) upper_remainder (*‹⟦?B ⊆ ?A; ¬ ?B ⊢ ?φ⟧ ⟹ ∃B'. ?B ⊆ B' ∧ B' ∈ ?A .⊥. ?φ›*)) hence f: "¬ ψ ∈ B" by (metis (no_types, lifting) CollectD (*‹?a ∈ {x. ?P x} ⟹ ?P ?a›*) assumption_L (*‹?φ ∈ ?A ⟹ ?A ⊢ ?φ›*) insert_subset (*‹(insert ?x ?A ⊆ ?B) = (?x ∈ ?B ∧ ?A ⊆ ?B)›*) disj_notE_PL (*‹⟦?A ⊢ ?q; ?A ⊢ ?p .∨. .¬ ?q⟧ ⟹ ?A ⊢ ?p›*) rem (*‹?A .⊥. ?φ ≡ {B. B ⊆ ?A ∧ ¬ B ⊢ ?φ ∧ (∀B'⊆?A. B ⊂ B' ⟶ B' ⊢ ?φ)}›*)) hence "¬ ψ ∈ (K ÷⇘γ⇩F⇩C⇙ φ)" using e (*‹B ∈ K .⊥. φ›*) mc (*‹?A ÷⇘?γ⇙ ?φ ≡ ⋂ (?γ ?A ?φ)›*) full_sel (*‹γ⇩F⇩C ?K ?φ ≡ if ?K .⊥. ?φ = {} then {?K} else ?K .⊥. ?φ›*) by auto } then show "ψ ∈ Cn({.¬ φ})" using c (*‹ψ ∈ K ÷⇘γ⇩F⇩C⇙ φ›*) infer_def (*‹?A ⊢ ?φ ≡ ?φ ∈ Cn ?A›*) by blast qed next (*goal: ‹⟦K = Cn A; K ⊢ φ⟧ ⟹ K ∩ Cn {.¬ φ} ⊆ K ÷⇘γ⇩F⇩C⇙ φ›*) assume a: "K = Cn(A)" and b: "K ⊢ φ" (*‹(K::'a set) = (Cn::'a set ⇒ 'a set) (A::'a set)› ‹(K::'a set) ⊢ (φ::'a)›*) show "K ∩ Cn({.¬ φ}) ⊆ (K ÷⇘γ⇩F⇩C⇙ φ)" proof (safe) (*goal: ‹⋀x. ⟦x ∈ K; x ∈ Cn {.¬ φ}⟧ ⟹ x ∈ K ÷⇘γ⇩F⇩C⇙ φ›*) fix ψ assume c: "ψ ∈ K" and d: "ψ ∈ Cn {.¬ φ}" (*‹(ψ::'a) ∈ (K::'a set)› ‹(ψ::'a) ∈ (Cn::'a set ⇒ 'a set) {.¬ (φ::'a)}›*) have e: "B ⊢ .¬ φ .⟶. ψ" for B by (simp add: d (*‹(ψ::'a) ∈ (Cn::'a set ⇒ 'a set) {.¬ (φ::'a)}›*) validD_L (*‹⊩ (?φ::'a) ⟹ ?φ ∈ (Cn::'a set ⇒ 'a set) (?A::'a set)›*) valid_imp_PL (*‹⊩ ((?p::'a) .⟶. (?q::'a)) = ({?p} ⊢ ?q)›*)) { fix B assume f: "B ∈ K .⊥. φ" (*‹(B::'a set) ∈ (K::'a set) .⊥. (φ::'a)›*) hence "B ⊢ φ .⟶. ψ" using a (*‹K = Cn A›*) assumption_L (*‹?φ ∈ ?A ⟹ ?A ⊢ ?φ›*) c (*‹ψ ∈ K›*) remainder_recovery (*‹⟦?K = Cn ?A; ?K ⊢ ?ψ; ?B ∈ ?K .⊥. ?φ⟧ ⟹ ?B ⊢ ?φ .⟶. ?ψ›*) by auto then have f: "B ⊢ ψ" using d (*‹(ψ::'a::type) ∈ (Cn::'a::type set ⇒ 'a::type set) {.¬ (φ::'a::type)}›*) e (*‹?B ⊢ .¬ φ .⟶. ψ›*) using disjE_PL (*‹⟦?A ⊢ ?p .∨. ?q; ?A ⊢ ?p .⟶. ?r; ?A ⊢ ?q .⟶. ?r⟧ ⟹ ?A ⊢ ?r›*) ex_mid_PL (*‹?A ⊢ ?p .∨. .¬ ?p›*) by blast } then show "ψ ∈ (K ÷⇘γ⇩F⇩C⇙ φ)" apply (simp_all add:mc c full_sel) (*goal: ‹(ψ::'a) ∈ (K::'a set) ÷⇘γ⇩F⇩C⇙ (φ::'a)›*) using a (*‹K = Cn A›*) rem_closure (*‹⟦?K = Cn ?A; ?B ∈ ?K .⊥. ?φ⟧ ⟹ ?B = Cn ?B›*) by blast qed qed lemma full_meet_weak2:‹K = Cn(A) ⟹ K ⊢ φ ⟹ Cn((K ÷⇘γ⇩F⇩C⇙ φ) ∪ {.¬ φ}) = Cn({.¬ φ})› unfolding full_meet_weak1 (*goal: ‹⟦K = Cn A; K ⊢ φ⟧ ⟹ Cn (K ∩ Cn {.¬ φ} ∪ {.¬ φ}) = Cn {.¬ φ}›*) by (metis Cn_union (*‹(Cn::'a::type set ⇒ 'a::type set) (Cn (?A::'a::type set) ∪ Cn (?B::'a::type set)) = Cn (?A ∪ ?B)›*) idempotency_L (*‹(Cn::'a::type set ⇒ 'a::type set) (Cn (?A::'a::type set)) = Cn ?A›*) inf.cobounded2 (*‹inf (?a::?'a::semilattice_inf) (?b::?'a::semilattice_inf) ≤ ?b›*) sup.absorb_iff2 (*‹((?a::?'a::semilattice_sup) ≤ (?b::?'a::semilattice_sup)) = (sup ?a ?b = ?b)›*) sup_commute (*‹sup (?x::?'a::semilattice_sup) (?y::?'a::semilattice_sup) = sup ?y ?x›*)) end end
{ "path": "afp-2025-02-12/thys/Belief_Revision/AGM_Contraction.thy", "repo": "afp-2025-02-12", "sha": "debf1610d2d43eb890d928cd9bd5540fe273a1ec30e7ee5df4617ff48653b122" }
(******************************************************************************* Project: Refining Authenticated Key Agreement with Strong Adversaries Module: sklvl3_symmetric.thy (Isabelle/HOL 2016-1) ID: $Id: sklvl3_symmetric.thy 133183 2017-01-31 13:55:43Z csprenge $ Author: Joseph Lallemand, INRIA Nancy <joseph.lallemand@loria.fr> Christoph Sprenger, ETH Zurich <sprenger@inf.ethz.ch> Level-3 SKEME/IKEv1 protocol; symmetric instantiation of version with generic channel implementation. Refines model sklvl2 based on channel assumptions. Copyright (c) 2015-2016 Joseph Lallemand and Christoph Sprenger Licence: LGPL *******************************************************************************) section ‹SKEME Protocol (L3 with symmetric implementation)› theory sklvl3_symmetric imports sklvl3 Implem_symmetric begin interpretation sklvl3_sym: sklvl3 implem_sym by unfold_locales end
{ "path": "afp-2025-02-12/thys/Key_Agreement_Strong_Adversaries/sklvl3_symmetric.thy", "repo": "afp-2025-02-12", "sha": "45c2c032b227c3762356c38a0db28104a10685deba5d574029ca80ad246fe365" }
(* Title: Group_Divisible_Designs.thy Author: Chelsea Edmonds *) section ‹Group Divisible Designs› text ‹Definitions in this section taken from the handbook \<^cite>‹"colbournHandbookCombinatorialDesigns2007"› and Stinson \<^cite>‹"stinsonCombinatorialDesignsConstructions2004"›› theory Group_Divisible_Designs imports Resolvable_Designs begin subsection ‹Group design› text ‹We define a group design to have an additional paramater $G$ which is a partition on the point set $V$. This is not defined in the handbook, but is a precursor to GDD's without index constraints› locale group_design = proper_design + fixes groups :: "'a set set" ("𝒢") assumes group_partitions: "partition_on 𝒱 𝒢" assumes groups_size: "card 𝒢 > 1" begin lemma groups_not_empty: "𝒢 ≠ {}" using groups_size (*‹1 < card 𝒢›*) by auto lemma num_groups_lt_points: "card 𝒢 ≤ 𝗏" by (simp add: partition_on_le_set_elements (*‹⟦finite (?A::?'a set); partition_on ?A (?P::?'a set set)⟧ ⟹ card ?P ≤ card ?A›*) finite_sets (*‹finite 𝒱›*) group_partitions (*‹partition_on 𝒱 𝒢›*)) lemma groups_disjoint: "disjoint 𝒢" using group_partitions (*‹partition_on 𝒱 𝒢›*) partition_onD2 (*‹partition_on ?A ?P ⟹ disjoint ?P›*) by auto lemma groups_disjoint_pairwise: "G1 ∈ 𝒢 ⟹ G2 ∈ 𝒢 ⟹ G1 ≠ G2 ⟹ disjnt G1 G2" using group_partitions (*‹partition_on 𝒱 𝒢›*) partition_onD2 (*‹partition_on ?A ?P ⟹ disjoint ?P›*) pairwiseD (*‹⟦pairwise ?R ?S; ?x ∈ ?S; ?y ∈ ?S; ?x ≠ ?y⟧ ⟹ ?R ?x ?y›*) by fastforce lemma point_in_one_group: "x ∈ G1 ⟹ G1 ∈ 𝒢 ⟹ G2 ∈ 𝒢 ⟹ G1 ≠ G2 ⟹ x ∉ G2" using groups_disjoint_pairwise (*‹⟦(?G1.0::'a set) ∈ 𝒢; (?G2.0::'a set) ∈ 𝒢; ?G1.0 ≠ ?G2.0⟧ ⟹ disjnt ?G1.0 ?G2.0›*) by (simp add: disjnt_iff (*‹disjnt (?A::?'a set) (?B::?'a set) = (∀x::?'a. ¬ (x ∈ ?A ∧ x ∈ ?B))›*)) lemma point_has_unique_group: "x ∈ 𝒱 ⟹ ∃!G. x ∈ G ∧ G ∈ 𝒢" using partition_on_partition_on_unique (*‹⟦partition_on ?A ?P; ?x ∈ ?A⟧ ⟹ ∃!X. ?x ∈ X ∧ X ∈ ?P›*) group_partitions (*‹partition_on 𝒱 𝒢›*) by fastforce lemma rep_number_point_group_one: assumes "x ∈ 𝒱" shows "card {g ∈ 𝒢 . x ∈ g} = 1" proof (-) (*goal: ‹card {g ∈ 𝒢. x ∈ g} = 1›*) obtain g' where "g' ∈ 𝒢" and "x ∈ g'" (*goal: ‹(⋀g'. ⟦g' ∈ 𝒢; x ∈ g'⟧ ⟹ thesis) ⟹ thesis›*) using assms (*‹(x::'a) ∈ 𝒱›*) point_has_unique_group (*‹?x ∈ 𝒱 ⟹ ∃!G. ?x ∈ G ∧ G ∈ 𝒢›*) by blast then have "{g ∈ 𝒢 . x ∈ g} = {g'}" using group_partitions (*‹partition_on 𝒱 𝒢›*) partition_onD4 (*‹⟦partition_on (?A::?'a set) (?P::?'a set set); (?p::?'a set) ∈ ?P; (?q::?'a set) ∈ ?P; (?x::?'a) ∈ ?p; ?x ∈ ?q⟧ ⟹ ?p = ?q›*) by force thus "?thesis" (*goal: ‹card {g ∈ 𝒢. x ∈ g} = 1›*) by simp qed lemma point_in_group: "G ∈ 𝒢 ⟹ x ∈ G ⟹ x ∈ 𝒱" using group_partitions (*‹partition_on 𝒱 𝒢›*) partition_onD1 (*‹partition_on ?A ?P ⟹ ?A = ⋃ ?P›*) by auto lemma point_subset_in_group: "G ∈ 𝒢 ⟹ ps ⊆ G ⟹ ps ⊆ 𝒱" using point_in_group (*‹⟦?G ∈ 𝒢; ?x ∈ ?G⟧ ⟹ ?x ∈ 𝒱›*) by auto lemma group_subset_point_subset: "G ∈ 𝒢 ⟹ G' ⊆ G ⟹ ps ⊆ G' ⟹ ps ⊆ 𝒱" using point_subset_in_group (*‹⟦(?G::'a::type set) ∈ 𝒢; (?ps::'a::type set) ⊆ ?G⟧ ⟹ ?ps ⊆ 𝒱›*) by auto lemma groups_finite: "finite 𝒢" using finite_elements (*‹⟦finite (?A::?'a set); partition_on ?A (?P::?'a set set)⟧ ⟹ finite ?P›*) finite_sets (*‹finite 𝒱›*) group_partitions (*‹partition_on 𝒱 𝒢›*) by auto lemma group_elements_finite: "G ∈ 𝒢 ⟹ finite G" using groups_finite (*‹finite 𝒢›*) finite_sets (*‹finite 𝒱›*) group_partitions (*‹partition_on 𝒱 𝒢›*) by (meson finite_subset (*‹⟦?A ⊆ ?B; finite ?B⟧ ⟹ finite ?A›*) point_in_group (*‹⟦?G ∈ 𝒢; ?x ∈ ?G⟧ ⟹ ?x ∈ 𝒱›*) subset_iff (*‹(?A ⊆ ?B) = (∀t. t ∈ ?A ⟶ t ∈ ?B)›*)) lemma v_equals_sum_group_sizes: "𝗏 = (∑G ∈ 𝒢. card G)" using group_partitions (*‹partition_on 𝒱 𝒢›*) groups_disjoint (*‹disjoint 𝒢›*) partition_onD1 (*‹partition_on ?A ?P ⟹ ?A = ⋃ ?P›*) card_Union_disjoint (*‹⟦disjoint (?C::?'a set set); ⋀A::?'a set. A ∈ ?C ⟹ finite A⟧ ⟹ card (⋃ ?C) = sum card ?C›*) group_elements_finite (*‹?G ∈ 𝒢 ⟹ finite ?G›*) by fastforce lemma gdd_min_v: "𝗏 ≥ 2" proof (-) (*goal: ‹2 ≤ 𝗏›*) have assm: "card 𝒢 ≥ 2" using groups_size (*‹1 < card 𝒢›*) by simp then have "⋀ G . G ∈ 𝒢 ⟹ G ≠ {}" using partition_onD3 (*‹partition_on ?A ?P ⟹ {} ∉ ?P›*) group_partitions (*‹partition_on 𝒱 𝒢›*) by auto then have "⋀ G . G ∈ 𝒢 ⟹ card G ≥ 1" using group_elements_finite (*‹?G ∈ 𝒢 ⟹ finite ?G›*) card_0_eq (*‹finite ?A ⟹ (card ?A = 0) = (?A = {})›*) by fastforce then have " (∑G ∈ 𝒢. card G) ≥ 2" using assm (*‹2 ≤ card 𝒢›*) using sum_mono (*‹(⋀i. i ∈ ?K ⟹ ?f i ≤ ?g i) ⟹ sum ?f ?K ≤ sum ?g ?K›*) by force thus "?thesis" (*goal: ‹2 ≤ 𝗏›*) using v_equals_sum_group_sizes (*‹𝗏 = sum card 𝒢›*) by linarith qed lemma min_group_size: "G ∈ 𝒢 ⟹ card G ≥ 1" using partition_onD3 (*‹partition_on (?A::?'a set) (?P::?'a set set) ⟹ {} ∉ ?P›*) group_partitions (*‹partition_on 𝒱 𝒢›*) using group_elements_finite (*‹(?G::'a::type set) ∈ 𝒢 ⟹ finite ?G›*) not_le_imp_less (*‹¬ (?y::?'a) ≤ (?x::?'a) ⟹ ?x < ?y›*) by fastforce lemma group_size_lt_v: assumes "G ∈ 𝒢" shows "card G < 𝗏" proof (-) (*goal: ‹card G < 𝗏›*) have "(∑G' ∈ 𝒢. card G') = 𝗏" using gdd_min_v (*‹2 ≤ 𝗏›*) v_equals_sum_group_sizes (*‹𝗏 = sum card 𝒢›*) by linarith then have split_sum: "card G + (∑G' ∈ (𝒢 - {G}). card G') = 𝗏" using assms (*‹G ∈ 𝒢›*) sum.remove (*‹⟦finite ?A; ?x ∈ ?A⟧ ⟹ sum ?g ?A = ?g ?x + sum ?g (?A - {?x})›*) by (metis groups_finite (*‹finite 𝒢›*) v_equals_sum_group_sizes (*‹𝗏 = sum card 𝒢›*)) have "card (𝒢 - {G}) ≥ 1" using groups_size (*‹1 < card 𝒢›*) by (simp add: assms (*‹G ∈ 𝒢›*) groups_finite (*‹finite 𝒢›*)) then obtain G' where gin: "G' ∈ (𝒢 - {G})" (*goal: ‹(⋀G'. G' ∈ 𝒢 - {G} ⟹ thesis) ⟹ thesis›*) by (meson elem_exists_non_empty_set (*‹⟦(0::nat) < card (?A::?'a::type set); ⋀x::?'a::type. x ∈ ?A ⟹ ?thesis::bool⟧ ⟹ ?thesis›*) less_le_trans (*‹⟦(?x::?'a::preorder) < (?y::?'a::preorder); ?y ≤ (?z::?'a::preorder)⟧ ⟹ ?x < ?z›*) less_numeral_extra( (*‹(0::?'a::linordered_nonzero_semiring) < (1::?'a::linordered_nonzero_semiring)›*) 1)) then have "card G' ≥ 1" using min_group_size (*‹(?G::'a set) ∈ 𝒢 ⟹ (1::nat) ≤ card ?G›*) by auto then have "(∑G' ∈ (𝒢 - {G}). card G') ≥ 1" by (metis gin (*‹G' ∈ 𝒢 - {G}›*) finite_Diff (*‹finite ?A ⟹ finite (?A - ?B)›*) groups_finite (*‹finite 𝒢›*) leI (*‹¬ ?x < ?y ⟹ ?y ≤ ?x›*) less_one (*‹(?n < 1) = (?n = 0)›*) sum_eq_0_iff (*‹finite ?F ⟹ (sum ?f ?F = 0) = (∀a∈?F. ?f a = 0)›*)) thus "?thesis" (*goal: ‹card G < 𝗏›*) using split_sum (*‹card G + sum card (𝒢 - {G}) = 𝗏›*) by linarith qed subsubsection ‹Group Type› text ‹GDD's have a "type", which is defined by a sequence of group sizes $g_i$, and the number of groups of that size $a_i$: $g_1^{a_1}g2^{a_2}...g_n^{a_n}$› definition group_sizes :: "nat set" where "group_sizes ≡ {card G | G . G ∈ 𝒢}" definition groups_of_size :: "nat ⇒ nat" where "groups_of_size g ≡ card { G ∈ 𝒢 . card G = g }" definition group_type :: "(nat × nat) set" where "group_type ≡ {(g, groups_of_size g) | g . g ∈ group_sizes }" lemma group_sizes_min: "x ∈ group_sizes ⟹ x ≥ 1 " unfolding group_sizes_def (*goal: ‹(x::nat) ∈ {card G |G::'a set. G ∈ 𝒢} ⟹ (1::nat) ≤ x›*) using min_group_size (*‹?G ∈ 𝒢 ⟹ 1 ≤ card ?G›*) group_size_lt_v (*‹(?G::'a::type set) ∈ 𝒢 ⟹ card ?G < 𝗏›*) by auto lemma group_sizes_max: "x ∈ group_sizes ⟹ x < 𝗏 " unfolding group_sizes_def (*goal: ‹x ∈ {card G |G. G ∈ 𝒢} ⟹ x < 𝗏›*) using min_group_size (*‹(?G::'a::type set) ∈ 𝒢 ⟹ (1::nat) ≤ card ?G›*) group_size_lt_v (*‹?G ∈ 𝒢 ⟹ card ?G < 𝗏›*) by auto lemma group_size_implies_group_existance: "x ∈ group_sizes ⟹ ∃G. G ∈ 𝒢 ∧ card G = x" unfolding group_sizes_def (*goal: ‹x ∈ {card G |G. G ∈ 𝒢} ⟹ ∃G. G ∈ 𝒢 ∧ card G = x›*) by auto lemma groups_of_size_zero: "groups_of_size 0 = 0" proof (-) (*goal: ‹groups_of_size 0 = 0›*) have empty: "{G ∈ 𝒢 . card G = 0} = {}" using min_group_size (*‹?G ∈ 𝒢 ⟹ 1 ≤ card ?G›*) by fastforce thus "?thesis" (*goal: ‹groups_of_size 0 = 0›*) unfolding groups_of_size_def (*goal: ‹card {G::'a set ∈ 𝒢. card G = (0::nat)} = (0::nat)›*) by (simp add: empty (*‹{G ∈ 𝒢. card G = 0} = {}›*)) qed lemma groups_of_size_max: assumes "g ≥ 𝗏" shows "groups_of_size g = 0" proof (-) (*goal: ‹groups_of_size g = 0›*) have "{G ∈ 𝒢 . card G = g} = {}" using group_size_lt_v (*‹?G ∈ 𝒢 ⟹ card ?G < 𝗏›*) assms (*‹𝗏 ≤ (g::nat)›*) by fastforce thus "?thesis" (*goal: ‹groups_of_size (g::nat) = (0::nat)›*) unfolding groups_of_size_def (*goal: ‹card {G ∈ 𝒢. card G = g} = 0›*) by (simp add: ‹{G ∈ 𝒢. card G = g} = {}›) qed lemma group_type_contained_sizes: "(g, a) ∈ group_type ⟹ g ∈ group_sizes" unfolding group_type_def (*goal: ‹(g, a) ∈ {(g, groups_of_size g) |g. g ∈ group_sizes} ⟹ g ∈ group_sizes›*) by simp lemma group_type_contained_count: "(g, a) ∈ group_type ⟹ card {G ∈ 𝒢 . card G = g} = a" unfolding group_type_def groups_of_size_def (*goal: ‹(g, a) ∈ {(g, card {G ∈ 𝒢. card G = g}) |g. g ∈ group_sizes} ⟹ card {G ∈ 𝒢. card G = g} = a›*) by simp lemma group_card_in_sizes: "g ∈ 𝒢 ⟹ card g ∈ group_sizes" unfolding group_sizes_def (*goal: ‹g ∈ 𝒢 ⟹ card g ∈ {card G |G. G ∈ 𝒢}›*) by auto lemma group_card_non_zero_groups_of_size_min: assumes "g ∈ 𝒢" assumes "card g = a" shows "groups_of_size a ≥ 1" proof (-) (*goal: ‹1 ≤ groups_of_size a›*) have "g ∈ {G ∈ 𝒢 . card G = a}" using assms (*‹g ∈ 𝒢› ‹card g = a›*) by simp then have "{G ∈ 𝒢 . card G = a} ≠ {}" by auto then have "card {G ∈ 𝒢 . card G = a} ≠ 0" by (simp add: groups_finite (*‹finite 𝒢›*)) thus "?thesis" (*goal: ‹1 ≤ groups_of_size a›*) unfolding groups_of_size_def (*goal: ‹1 ≤ card {G ∈ 𝒢. card G = a}›*) by simp qed lemma elem_in_group_sizes_min_of_size: assumes "a ∈ group_sizes" shows "groups_of_size a ≥ 1" using assms (*‹a ∈ group_sizes›*) group_card_non_zero_groups_of_size_min (*‹⟦?g ∈ 𝒢; card ?g = ?a⟧ ⟹ 1 ≤ groups_of_size ?a›*) group_size_implies_group_existance (*‹(?x::nat) ∈ group_sizes ⟹ ∃G::'a::type set. G ∈ 𝒢 ∧ card G = ?x›*) by blast lemma group_card_non_zero_groups_of_size_max: shows "groups_of_size a ≤ 𝗏" proof (-) (*goal: ‹groups_of_size a ≤ 𝗏›*) have "{G ∈ 𝒢 . card G = a} ⊆ 𝒢" by simp then have "card {G ∈ 𝒢 . card G = a} ≤ card 𝒢" by (simp add: card_mono (*‹⟦finite (?B::?'a set); (?A::?'a set) ⊆ ?B⟧ ⟹ card ?A ≤ card ?B›*) groups_finite (*‹finite 𝒢›*)) thus "?thesis" (*goal: ‹groups_of_size a ≤ 𝗏›*) using groups_of_size_def (*‹groups_of_size ?g ≡ card {G ∈ 𝒢. card G = ?g}›*) num_groups_lt_points (*‹card 𝒢 ≤ 𝗏›*) by auto qed lemma group_card_in_type: "g ∈ 𝒢 ⟹ ∃ x . (card g, x) ∈ group_type ∧ x ≥ 1" unfolding group_type_def (*goal: ‹g ∈ 𝒢 ⟹ ∃x. (card g, x) ∈ {(g, groups_of_size g) |g. g ∈ group_sizes} ∧ 1 ≤ x›*) using group_card_non_zero_groups_of_size_min (*‹⟦?g ∈ 𝒢; card ?g = ?a⟧ ⟹ 1 ≤ groups_of_size ?a›*) by (simp add: group_card_in_sizes (*‹?g ∈ 𝒢 ⟹ card ?g ∈ group_sizes›*)) lemma partition_groups_on_size: "partition_on 𝒢 {{ G ∈ 𝒢 . card G = g } | g . g ∈ group_sizes}" proof (intro partition_onI (*‹⟦⋀p::?'a set. p ∈ (?P::?'a set set) ⟹ p ≠ {}; ⋃ ?P = (?A::?'a set); ⋀(p::?'a set) p'::?'a set. ⟦p ∈ ?P; p' ∈ ?P; p ≠ p'⟧ ⟹ p ∩ p' = {}⟧ ⟹ partition_on ?A ?P›*), auto) (*goals: 1. ‹⋀g. ⟦g ∈ group_sizes; ∀x. x ∈ 𝒢 ⟶ card x ≠ g⟧ ⟹ False› 2. ‹⋀x. x ∈ 𝒢 ⟹ ∃xa. (∃g. xa = {G ∈ 𝒢. card G = g} ∧ g ∈ group_sizes) ∧ x ∈ xa›*) fix g assume a1: "g ∈ group_sizes" (*‹(g::nat) ∈ group_sizes›*) assume " ∀x. x ∈ 𝒢 ⟶ card x ≠ g" (*‹∀x::'a set. x ∈ 𝒢 ⟶ card x ≠ (g::nat)›*) then show False using a1 (*‹g ∈ group_sizes›*) group_size_implies_group_existance (*‹(?x::nat) ∈ group_sizes ⟹ ∃G::'a set. G ∈ 𝒢 ∧ card G = ?x›*) by auto next (*goal: ‹⋀x. x ∈ 𝒢 ⟹ ∃xa. (∃g. xa = {G ∈ 𝒢. card G = g} ∧ g ∈ group_sizes) ∧ x ∈ xa›*) fix x assume "x ∈ 𝒢" (*‹(x::'a set) ∈ 𝒢›*) then show "∃xa. (∃g. xa = {G ∈ 𝒢. card G = g} ∧ g ∈ group_sizes) ∧ x ∈ xa" using group_card_in_sizes (*‹?g ∈ 𝒢 ⟹ card ?g ∈ group_sizes›*) by auto qed lemma group_size_partition_covers_points: "⋃(⋃{{ G ∈ 𝒢 . card G = g } | g . g ∈ group_sizes}) = 𝒱" by (metis (no_types, lifting) group_partitions (*‹partition_on 𝒱 𝒢›*) partition_groups_on_size (*‹partition_on 𝒢 {{G::'a set ∈ 𝒢. card G = g} |g::nat. g ∈ group_sizes}›*) partition_onD1 (*‹partition_on (?A::?'a set) (?P::?'a set set) ⟹ ?A = ⋃ ?P›*)) lemma groups_of_size_alt_def_count: "groups_of_size g = count {# card G . G ∈# mset_set 𝒢 #} g" proof (-) (*goal: ‹groups_of_size g = count (image_mset card (mset_set 𝒢)) g›*) have a: "groups_of_size g = card { G ∈ 𝒢 . card G = g }" unfolding groups_of_size_def (*goal: ‹card {G ∈ 𝒢. card G = g} = card {G ∈ 𝒢. card G = g}›*) by simp then have "groups_of_size g = size {# G ∈# (mset_set 𝒢) . card G = g #}" using groups_finite (*‹finite 𝒢›*) by auto then have size_repr: "groups_of_size g = size {# x ∈# {# card G . G ∈# mset_set 𝒢 #} . x = g #}" using groups_finite (*‹finite 𝒢›*) by (simp add: filter_mset_image_mset (*‹filter_mset ?P (image_mset ?f ?A) = image_mset ?f {#x ∈# ?A. ?P (?f x)#}›*)) have "group_sizes = set_mset ({# card G . G ∈# mset_set 𝒢 #})" using group_sizes_def (*‹group_sizes ≡ {card G |G. G ∈ 𝒢}›*) groups_finite (*‹finite 𝒢›*) by auto thus "?thesis" (*goal: ‹groups_of_size g = count (image_mset card (mset_set 𝒢)) g›*) using size_repr (*‹groups_of_size g = size {#x ∈# image_mset card (mset_set 𝒢). x = g#}›*) by (simp add: count_size_set_repr (*‹size {#x::?'a ∈# ?A::?'a multiset. x = (?g::?'a)#} = count ?A ?g›*)) qed lemma v_sum_type_rep: "𝗏 = (∑ g ∈ group_sizes . g * (groups_of_size g))" proof (-) (*goal: ‹𝗏 = (∑g∈group_sizes. g * groups_of_size g)›*) have gs: "set_mset {# card G . G ∈# mset_set 𝒢 #} = group_sizes" unfolding group_sizes_def (*goal: ‹set_mset (image_mset card (mset_set 𝒢)) = {card G |G. G ∈ 𝒢}›*) using groups_finite (*‹finite 𝒢›*) by auto have "𝗏 = card (⋃(⋃{{ G ∈ 𝒢 . card G = g } | g . g ∈ group_sizes}))" using group_size_partition_covers_points (*‹⋃ (⋃ {{G ∈ 𝒢. card G = g} |g. g ∈ group_sizes}) = 𝒱›*) by simp have v1: "𝗏 = (∑x ∈# {# card G . G ∈# mset_set 𝒢 #}. x)" by (simp add: sum_unfold_sum_mset (*‹sum ?f ?A = ∑⇩# (image_mset ?f (mset_set ?A))›*) v_equals_sum_group_sizes (*‹𝗏 = sum card 𝒢›*)) then have "𝗏 = (∑x ∈ set_mset {# card G . G ∈# mset_set 𝒢 #} . x * (count {# card G . G ∈# mset_set 𝒢 #} x))" using mset_set_size_card_count (*‹(∑x∈#?A. x) = (∑x∈set_mset ?A. x * count ?A x)›*) by (simp add: v1 (*‹𝗏 = (∑x::nat∈#image_mset card (mset_set 𝒢). x)›*)) thus "?thesis" (*goal: ‹𝗏 = (∑g∈group_sizes. g * groups_of_size g)›*) using gs (*‹set_mset (image_mset card (mset_set 𝒢)) = group_sizes›*) groups_of_size_alt_def_count (*‹groups_of_size ?g = count (image_mset card (mset_set 𝒢)) ?g›*) by auto qed end subsubsection ‹Uniform Group designs› text ‹A group design requiring all groups are the same size› locale uniform_group_design = group_design + fixes u_group_size :: nat ("𝗆") assumes uniform_groups: "G ∈ 𝒢 ⟹ card G = 𝗆" begin lemma m_positive: "𝗆 ≥ 1" proof (-) (*goal: ‹1 ≤ 𝗆›*) obtain G where "G ∈ 𝒢" (*goal: ‹(⋀G. G ∈ 𝒢 ⟹ thesis) ⟹ thesis›*) using groups_size (*‹1 < card 𝒢›*) elem_exists_non_empty_set (*‹⟦0 < card ?A; ⋀x. x ∈ ?A ⟹ ?thesis⟧ ⟹ ?thesis›*) gr_implies_not_zero (*‹?m < ?n ⟹ ?n ≠ 0›*) by blast thus "?thesis" (*goal: ‹1 ≤ 𝗆›*) using uniform_groups (*‹?G ∈ 𝒢 ⟹ card ?G = 𝗆›*) min_group_size (*‹?G ∈ 𝒢 ⟹ 1 ≤ card ?G›*) by fastforce qed lemma uniform_groups_alt: " ∀ G ∈ 𝒢 . card G = 𝗆" using uniform_groups (*‹(?G::'a set) ∈ 𝒢 ⟹ card ?G = 𝗆›*) by blast lemma uniform_groups_group_sizes: "group_sizes = {𝗆}" using design_points_nempty (*‹𝒱 ≠ {}›*) group_card_in_sizes (*‹(?g::'a set) ∈ 𝒢 ⟹ card ?g ∈ group_sizes›*) group_size_implies_group_existance (*‹(?x::nat) ∈ group_sizes ⟹ ∃G::'a::type set. G ∈ 𝒢 ∧ card G = ?x›*) point_has_unique_group (*‹?x ∈ 𝒱 ⟹ ∃!G. ?x ∈ G ∧ G ∈ 𝒢›*) uniform_groups_alt (*‹∀G∈𝒢. card G = 𝗆›*) by force lemma uniform_groups_group_size_singleton: "is_singleton (group_sizes)" using uniform_groups_group_sizes (*‹group_sizes = {𝗆}›*) by auto lemma set_filter_eq_P_forall:"∀ x ∈ X . P x ⟹ Set.filter P X = X" by (simp add: Collect_conj_eq (*‹{x. ?P x ∧ ?Q x} = {x. ?P x} ∩ {x. ?Q x}›*) Int_absorb2 (*‹?A ⊆ ?B ⟹ ?A ∩ ?B = ?A›*) Set.filter_def (*‹Set.filter ?P ?A = {a ∈ ?A. ?P a}›*) subsetI (*‹(⋀x. x ∈ ?A ⟹ x ∈ ?B) ⟹ ?A ⊆ ?B›*)) lemma uniform_groups_groups_of_size_m: "groups_of_size 𝗆 = card 𝒢" proof (simp add: groups_of_size_def (*‹groups_of_size ?g ≡ card {G ∈ 𝒢. card G = ?g}›*)) (*goal: ‹card {G ∈ 𝒢. card G = 𝗆} = card 𝒢›*) have "{G ∈ 𝒢. card G = 𝗆} = 𝒢" using uniform_groups_alt (*‹∀G::'a set∈𝒢. card G = 𝗆›*) set_filter_eq_P_forall (*‹∀x∈?X. ?P x ⟹ Set.filter ?P ?X = ?X›*) by auto thus "card {G ∈ 𝒢. card G = 𝗆} = card 𝒢" by simp qed lemma uniform_groups_of_size_not_m: "x ≠ 𝗆 ⟹ groups_of_size x = 0" by (simp add: groups_of_size_def (*‹groups_of_size (?g::nat) ≡ card {G::'a set ∈ 𝒢. card G = ?g}›*) card_eq_0_iff (*‹(card (?A::?'a set) = (0::nat)) = (?A = {} ∨ infinite ?A)›*) uniform_groups (*‹(?G::'a set) ∈ 𝒢 ⟹ card ?G = 𝗆›*)) end subsection ‹GDD› text ‹A GDD extends a group design with an additional index parameter. Each pair of elements must occur either \Lambda times if in diff groups, or 0 times if in the same group› locale GDD = group_design + fixes index :: int ("Λ") assumes index_ge_1: "Λ ≥ 1" assumes index_together: "G ∈ 𝒢 ⟹ x ∈ G ⟹ y ∈ G ⟹ x ≠ y ⟹ ℬ index {x, y} = 0" assumes index_distinct: "G1 ∈ 𝒢 ⟹ G2 ∈ 𝒢 ⟹ G1 ≠ G2 ⟹ x ∈ G1 ⟹ y ∈ G2 ⟹ ℬ index {x, y} = Λ" begin lemma points_sep_groups_ne: "G1 ∈ 𝒢 ⟹ G2 ∈ 𝒢 ⟹ G1 ≠ G2 ⟹ x ∈ G1 ⟹ y ∈ G2 ⟹ x ≠ y" by (meson point_in_one_group (*‹⟦?x ∈ ?G1.0; ?G1.0 ∈ 𝒢; ?G2.0 ∈ 𝒢; ?G1.0 ≠ ?G2.0⟧ ⟹ ?x ∉ ?G2.0›*)) lemma index_together_alt_ss: "ps ⊆ G ⟹ G ∈ 𝒢 ⟹ card ps = 2 ⟹ ℬ index ps = 0" using index_together (*‹⟦?G ∈ 𝒢; ?x ∈ ?G; ?y ∈ ?G; ?x ≠ ?y⟧ ⟹ ℬ index {?x, ?y} = 0›*) by (metis card_2_iff (*‹(card ?S = 2) = (∃x y. ?S = {x, y} ∧ x ≠ y)›*) insert_subset (*‹(insert ?x ?A ⊆ ?B) = (?x ∈ ?B ∧ ?A ⊆ ?B)›*)) lemma index_distinct_alt_ss: "ps ⊆ 𝒱 ⟹ card ps = 2 ⟹ (⋀ G . G ∈ 𝒢 ⟹ ¬ ps ⊆ G) ⟹ ℬ index ps = Λ" using index_distinct (*‹⟦?G1.0 ∈ 𝒢; ?G2.0 ∈ 𝒢; ?G1.0 ≠ ?G2.0; ?x ∈ ?G1.0; ?y ∈ ?G2.0⟧ ⟹ int (ℬ index {?x, ?y}) = Λ›*) by (metis card_2_iff (*‹(card (?S::?'a set) = (2::nat)) = (∃(x::?'a) y::?'a. ?S = {x, y} ∧ x ≠ y)›*) empty_subsetI (*‹{} ⊆ (?A::?'a set)›*) insert_subset (*‹(insert (?x::?'a) (?A::?'a set) ⊆ (?B::?'a set)) = (?x ∈ ?B ∧ ?A ⊆ ?B)›*) point_has_unique_group (*‹(?x::'a) ∈ 𝒱 ⟹ ∃!G::'a set. ?x ∈ G ∧ G ∈ 𝒢›*)) lemma gdd_index_options: "ps ⊆ 𝒱 ⟹ card ps = 2 ⟹ ℬ index ps = 0 ∨ ℬ index ps = Λ" using index_distinct_alt_ss (*‹⟦?ps ⊆ 𝒱; card ?ps = 2; ⋀G. G ∈ 𝒢 ⟹ ¬ ?ps ⊆ G⟧ ⟹ int (ℬ index ?ps) = Λ›*) index_together_alt_ss (*‹⟦?ps ⊆ ?G; ?G ∈ 𝒢; card ?ps = 2⟧ ⟹ ℬ index ?ps = 0›*) by blast lemma index_zero_implies_same_group: "ps ⊆ 𝒱 ⟹ card ps = 2 ⟹ ℬ index ps = 0 ⟹ ∃ G ∈ 𝒢 . ps ⊆ G" using index_distinct_alt_ss (*‹⟦?ps ⊆ 𝒱; card ?ps = 2; ⋀G. G ∈ 𝒢 ⟹ ¬ ?ps ⊆ G⟧ ⟹ int (ℬ index ?ps) = Λ›*) gr_implies_not_zero (*‹?m < ?n ⟹ ?n ≠ 0›*) by (metis index_ge_1 (*‹1 ≤ Λ›*) less_one (*‹(?n < 1) = (?n = 0)›*) of_nat_0 (*‹of_nat 0 = 0›*) of_nat_1 (*‹of_nat 1 = 1›*) of_nat_le_0_iff (*‹(of_nat ?m ≤ 0) = (?m = 0)›*)) lemma index_zero_implies_same_group_unique: "ps ⊆ 𝒱 ⟹ card ps = 2 ⟹ ℬ index ps = 0 ⟹ ∃! G ∈ 𝒢 . ps ⊆ G" by (meson GDD.index_zero_implies_same_group (*‹⟦GDD (?point_set::?'a set) (?block_collection::?'a set multiset) (?groups::?'a set set) (?index::int); (?ps::?'a set) ⊆ ?point_set; card ?ps = (2::nat); ?block_collection index ?ps = (0::nat)⟧ ⟹ ∃G::?'a set∈?groups. ?ps ⊆ G›*) GDD_axioms (*‹GDD 𝒱 ℬ 𝒢 Λ›*) card_2_iff' (*‹(card (?S::?'a set) = (2::nat)) = (∃x::?'a∈?S. ∃y::?'a∈?S. x ≠ y ∧ (∀z::?'a∈?S. z = x ∨ z = y))›*) group_design.point_in_one_group (*‹⟦group_design (?point_set::?'a set) (?block_collection::?'a set multiset) (?groups::?'a set set); (?x::?'a) ∈ (?G1.0::?'a set); ?G1.0 ∈ ?groups; (?G2.0::?'a set) ∈ ?groups; ?G1.0 ≠ ?G2.0⟧ ⟹ ?x ∉ ?G2.0›*) group_design_axioms (*‹group_design 𝒱 ℬ 𝒢›*) in_mono (*‹(?A::?'a set) ⊆ (?B::?'a set) ⟹ (?x::?'a) ∈ ?A ⟶ ?x ∈ ?B›*)) lemma index_not_zero_impl_diff_group: "ps ⊆ 𝒱 ⟹ card ps = 2 ⟹ ℬ index ps = Λ ⟹ (⋀ G . G ∈ 𝒢 ⟹ ¬ ps ⊆ G)" using index_ge_1 (*‹1 ≤ Λ›*) index_together_alt_ss (*‹⟦?ps ⊆ ?G; ?G ∈ 𝒢; card ?ps = 2⟧ ⟹ ℬ index ?ps = 0›*) by auto lemma index_zero_implies_one_group: assumes "ps ⊆ 𝒱" and "card ps = 2" and "ℬ index ps = 0" shows "size {#b ∈# mset_set 𝒢 . ps ⊆ b#} = 1" proof (-) (*goal: ‹size (filter_mset ((⊆) ps) (mset_set 𝒢)) = 1›*) obtain G where ging: "G ∈ 𝒢" and psin: "ps ⊆ G" (*goal: ‹(⋀G. ⟦G ∈ 𝒢; ps ⊆ G⟧ ⟹ thesis) ⟹ thesis›*) using index_zero_implies_same_group (*‹⟦(?ps::'a::type set) ⊆ 𝒱; card ?ps = (2::nat); ℬ index ?ps = (0::nat)⟧ ⟹ ∃G::'a::type set∈𝒢. ?ps ⊆ G›*) groups_size (*‹1 < card 𝒢›*) assms (*‹ps ⊆ 𝒱› ‹card ps = 2› ‹ℬ index (ps::'a::type set) = (0::nat)›*) by blast then have unique: "⋀ G2 . G2 ∈ 𝒢 ⟹ G ≠ G2 ⟹ ¬ ps ⊆ G2" using index_zero_implies_same_group_unique (*‹⟦?ps ⊆ 𝒱; card ?ps = 2; ℬ index ?ps = 0⟧ ⟹ ∃!G. G ∈ 𝒢 ∧ ?ps ⊆ G›*) by (metis assms (*‹(ps::'a set) ⊆ 𝒱› ‹card (ps::'a set) = (2::nat)› ‹ℬ index (ps::'a set) = (0::nat)›*)) have "⋀ G'. G' ∈ 𝒢 ⟷ G' ∈# mset_set 𝒢" by (simp add: groups_finite (*‹finite 𝒢›*)) then have eq_mset: "{#b ∈# mset_set 𝒢 . ps ⊆ b#} = mset_set {b ∈ 𝒢 . ps ⊆ b}" using filter_mset_mset_set (*‹finite ?A ⟹ filter_mset ?P (mset_set ?A) = mset_set {x ∈ ?A. ?P x}›*) groups_finite (*‹finite 𝒢›*) by blast then have "{b ∈ 𝒢 . ps ⊆ b} = {G}" using unique (*‹⟦?G2.0 ∈ 𝒢; G ≠ ?G2.0⟧ ⟹ ¬ ps ⊆ ?G2.0›*) psin (*‹ps ⊆ G›*) by (smt Collect_cong (*‹(⋀x. ?P x = ?Q x) ⟹ {x. ?P x} = {x. ?Q x}›*) ging (*‹G ∈ 𝒢›*) singleton_conv (*‹{x. x = ?a} = {?a}›*)) thus "?thesis" (*goal: ‹size (filter_mset ((⊆) ps) (mset_set 𝒢)) = 1›*) by (simp add: eq_mset (*‹filter_mset ((⊆) ps) (mset_set 𝒢) = mset_set {b ∈ 𝒢. ps ⊆ b}›*)) qed lemma index_distinct_group_num_alt_def: "ps ⊆ 𝒱 ⟹ card ps = 2 ⟹ size {#b ∈# mset_set 𝒢 . ps ⊆ b#} = 0 ⟹ ℬ index ps = Λ" by (metis gdd_index_options (*‹⟦?ps ⊆ 𝒱; card ?ps = 2⟧ ⟹ ℬ index ?ps = 0 ∨ int (ℬ index ?ps) = Λ›*) index_zero_implies_one_group (*‹⟦?ps ⊆ 𝒱; card ?ps = 2; ℬ index ?ps = 0⟧ ⟹ size (filter_mset ((⊆) ?ps) (mset_set 𝒢)) = 1›*) numeral_One (*‹Numeral1 = 1›*) zero_neq_numeral (*‹0 ≠ numeral ?n›*)) lemma index_non_zero_implies_no_group: assumes "ps ⊆ 𝒱" and "card ps = 2" and "ℬ index ps = Λ" shows "size {#b ∈# mset_set 𝒢 . ps ⊆ b#} = 0" proof (-) (*goal: ‹size (filter_mset ((⊆) ps) (mset_set 𝒢)) = 0›*) have "⋀ G . G ∈ 𝒢 ⟹ ¬ ps ⊆ G" using index_not_zero_impl_diff_group (*‹⟦?ps ⊆ 𝒱; card ?ps = 2; int (ℬ index ?ps) = Λ; ?G ∈ 𝒢⟧ ⟹ ¬ ?ps ⊆ ?G›*) assms (*‹ps ⊆ 𝒱› ‹card ps = 2› ‹int (ℬ index ps) = Λ›*) by simp then have "{#b ∈# mset_set 𝒢 . ps ⊆ b#} = {#}" using filter_mset_empty_if_finite_and_filter_set_empty (*‹⟦{x ∈ ?X. ?P x} = {}; finite ?X⟧ ⟹ filter_mset ?P (mset_set ?X) = {#}›*) by force thus "?thesis" (*goal: ‹size (filter_mset ((⊆) ps) (mset_set 𝒢)) = 0›*) by simp qed lemma gdd_index_non_zero_iff: "ps ⊆ 𝒱 ⟹ card ps = 2 ⟹ ℬ index ps = Λ ⟷ size {#b ∈# mset_set 𝒢 . ps ⊆ b#} = 0" using index_non_zero_implies_no_group (*‹⟦?ps ⊆ 𝒱; card ?ps = 2; int (ℬ index ?ps) = Λ⟧ ⟹ size (filter_mset ((⊆) ?ps) (mset_set 𝒢)) = 0›*) index_distinct_group_num_alt_def (*‹⟦?ps ⊆ 𝒱; card ?ps = 2; size (filter_mset ((⊆) ?ps) (mset_set 𝒢)) = 0⟧ ⟹ int (ℬ index ?ps) = Λ›*) by auto lemma gdd_index_zero_iff: "ps ⊆ 𝒱 ⟹ card ps = 2 ⟹ ℬ index ps = 0 ⟷ size {#b ∈# mset_set 𝒢 . ps ⊆ b#} = 1" apply (auto simp add: index_zero_implies_one_group (*‹⟦?ps ⊆ 𝒱; card ?ps = 2; ℬ index ?ps = 0⟧ ⟹ size (filter_mset ((⊆) ?ps) (mset_set 𝒢)) = 1›*)) (*goal: ‹⟦ps ⊆ 𝒱; card ps = 2⟧ ⟹ (ℬ index ps = 0) = (size (filter_mset ((⊆) ps) (mset_set 𝒢)) = 1)›*) by (metis GDD.gdd_index_options (*‹⟦GDD ?point_set ?block_collection ?groups ?index; ?ps ⊆ ?point_set; card ?ps = 2⟧ ⟹ ?block_collection index ?ps = 0 ∨ int (?block_collection index ?ps) = ?index›*) GDD_axioms (*‹GDD 𝒱 ℬ 𝒢 Λ›*) index_non_zero_implies_no_group (*‹⟦?ps ⊆ 𝒱; card ?ps = 2; int (ℬ index ?ps) = Λ⟧ ⟹ size (filter_mset ((⊆) ?ps) (mset_set 𝒢)) = 0›*) old.nat.distinct( (*‹Suc ?nat'1 ≠ 0›*) 2)) lemma points_index_upper_bound: "ps ⊆ 𝒱 ⟹ card ps = 2 ⟹ ℬ index ps ≤ Λ" using gdd_index_options (*‹⟦?ps ⊆ 𝒱; card ?ps = 2⟧ ⟹ ℬ index ?ps = 0 ∨ int (ℬ index ?ps) = Λ›*) index_ge_1 (*‹1 ≤ Λ›*) by (metis int_one_le_iff_zero_less (*‹(1 ≤ ?z) = (0 < ?z)›*) le_refl (*‹?n ≤ ?n›*) of_nat_0 (*‹of_nat 0 = 0›*) of_nat_0_le_iff (*‹0 ≤ of_nat ?n›*) of_nat_le_iff (*‹(of_nat ?m ≤ of_nat ?n) = (?m ≤ ?n)›*) zero_less_imp_eq_int (*‹0 < ?k ⟹ ∃n>0. ?k = int n›*)) lemma index_1_imp_mult_1: assumes "Λ = 1" assumes "bl ∈# ℬ" assumes "card bl ≥ 2" shows "multiplicity bl = 1" proof (rule ccontr (*‹(¬ ?P ⟹ False) ⟹ ?P›*)) (*goal: ‹multiplicity bl ≠ 1 ⟹ False›*) assume "¬ (multiplicity bl = 1)" (*‹multiplicity (bl::'a set) ≠ (1::nat)›*) then have "multiplicity bl ≠ 1" and "multiplicity bl ≠ 0" using assms (*‹Λ = 1› ‹bl ∈# ℬ› ‹2 ≤ card bl›*) apply - (*goals: 1. ‹⟦multiplicity bl ≠ 1; Λ = 1; bl ∈# ℬ; 2 ≤ card bl⟧ ⟹ multiplicity bl ≠ 1› 2. ‹⟦multiplicity bl ≠ 1; Λ = 1; bl ∈# ℬ; 2 ≤ card bl⟧ ⟹ multiplicity bl ≠ 0› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) . then have m: "multiplicity bl ≥ 2" by linarith obtain ps where ps: "ps ⊆ bl ∧ card ps = 2" (*goal: ‹(⋀ps. ps ⊆ bl ∧ card ps = 2 ⟹ thesis) ⟹ thesis›*) using nat_int_comparison(3) (*‹(?a ≤ ?b) = (int ?a ≤ int ?b)›*) obtain_subset_with_card_n (*‹⟦?n ≤ card ?S; ⋀T. ⟦T ⊆ ?S; card T = ?n; finite T⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*) by (metis assms( (*‹(2::nat) ≤ card (bl::'a::type set)›*) 3)) then have "ℬ index ps ≥ 2" using m (*‹2 ≤ multiplicity bl›*) points_index_count_min (*‹⟦(?n::nat) ≤ multiplicity (?bl::'a set); (?ps::'a set) ⊆ ?bl⟧ ⟹ ?n ≤ ℬ index ?ps›*) ps (*‹ps ⊆ bl ∧ card ps = 2›*) by blast then show False using assms (*‹Λ = 1› ‹bl ∈# ℬ› ‹2 ≤ card bl›*) index_distinct (*‹⟦?G1.0 ∈ 𝒢; ?G2.0 ∈ 𝒢; ?G1.0 ≠ ?G2.0; ?x ∈ ?G1.0; ?y ∈ ?G2.0⟧ ⟹ int (ℬ index {?x, ?y}) = Λ›*) ps (*‹ps ⊆ bl ∧ card ps = 2›*) antisym_conv2 (*‹?x ≤ ?y ⟹ (¬ ?x < ?y) = (?x = ?y)›*) not_numeral_less_zero (*‹¬ numeral ?n < 0›*) numeral_le_one_iff (*‹(numeral ?n ≤ 1) = (?n ≤ num.One)›*) points_index_ps_nin (*‹¬ ?ps ⊆ 𝒱 ⟹ ℬ index ?ps = 0›*) semiring_norm(69) (*‹(num.Bit0 ?m ≤ num.One) = False›*) zero_neq_numeral (*‹0 ≠ numeral ?n›*) by (metis gdd_index_options (*‹⟦?ps ⊆ 𝒱; card ?ps = 2⟧ ⟹ ℬ index ?ps = 0 ∨ int (ℬ index ?ps) = Λ›*) int_int_eq (*‹(int ?m = int ?n) = (?m = ?n)›*) int_ops( (*‹int 1 = 1›*) 2)) qed lemma simple_if_block_size_gt_2: assumes "⋀ bl . card bl ≥ 2" assumes "Λ = 1" shows "simple_design 𝒱 ℬ" using index_1_imp_mult_1 (*‹⟦Λ = 1; ?bl ∈# ℬ; 2 ≤ card ?bl⟧ ⟹ multiplicity ?bl = 1›*) assms (*‹2 ≤ card ?bl› ‹Λ = 1›*) apply unfold_locales (*goal: ‹simple_design 𝒱 ℬ›*) by (metis card.empty (*‹card {} = 0›*) not_numeral_le_zero (*‹¬ numeral ?n ≤ 0›*)) end subsubsection ‹Sub types of GDD's› text ‹In literature, a GDD is usually defined in a number of different ways, including factors such as block size limitations› locale K_Λ_GDD = K_block_design + GDD locale k_Λ_GDD = block_design + GDD sublocale k_Λ_GDD ⊆ K_Λ_GDD 𝒱 ℬ "{𝗄}" 𝒢 Λ by unfold_locales locale K_GDD = K_Λ_GDD 𝒱 ℬ 𝒦 𝒢 1 for point_set ("𝒱") and block_collection ("ℬ") and sizes ("𝒦") and groups ("𝒢") locale k_GDD = k_Λ_GDD 𝒱 ℬ 𝗄 𝒢 1 for point_set ("𝒱") and block_collection ("ℬ") and u_block_size ("𝗄") and groups ("𝒢") sublocale k_GDD ⊆ K_GDD 𝒱 ℬ "{𝗄}" 𝒢 by unfold_locales lemma (in K_GDD) multiplicity_1: "bl ∈# ℬ ⟹ card bl ≥ 2 ⟹ multiplicity bl = 1" using index_1_imp_mult_1 (*‹⟦1 = 1; ?bl ∈# ℬ; 2 ≤ card ?bl⟧ ⟹ multiplicity ?bl = 1›*) by simp locale RGDD = GDD + resolvable_design subsection ‹GDD and PBD Constructions› text ‹GDD's are commonly studied alongside PBD's (pairwise balanced designs). Many constructions have been developed for designs to create a GDD from a PBD and vice versa. In particular, Wilsons Construction is a well known construction, which is formalised in this section. It should be noted that many of the more basic constructions in this section are often stated without proof/all the necessary assumptions in textbooks/course notes.› context GDD begin subsubsection ‹GDD Delete Point construction› lemma delete_point_index_zero: assumes "G ∈ {g - {x} |g. g ∈ 𝒢 ∧ g ≠ {x}}" and "y ∈ G" and "z ∈ G" and "z≠ y" shows "(del_point_blocks x) index {y, z} = 0" proof (-) (*goal: ‹del_point_blocks x index {y, z} = 0›*) have "y ≠ x" using assms(1) (*‹G ∈ {g - {x} |g. g ∈ 𝒢 ∧ g ≠ {x}}›*) assms(2) (*‹y ∈ G›*) by blast have "z ≠ x" using assms(1) (*‹G ∈ {g - {x} |g. g ∈ 𝒢 ∧ g ≠ {x}}›*) assms(3) (*‹z ∈ G›*) by blast obtain G' where ing: "G' ∈ 𝒢" and ss: "G ⊆ G'" (*goal: ‹(⋀G'. ⟦G' ∈ 𝒢; G ⊆ G'⟧ ⟹ thesis) ⟹ thesis›*) using assms(1) (*‹G ∈ {g - {x} |g. g ∈ 𝒢 ∧ g ≠ {x}}›*) by auto have "{y, z} ⊆ G" by (simp add: assms( (*‹y ∈ G›*) 2) assms( (*‹z ∈ G›*) 3)) then have "{y, z} ⊆ 𝒱" by (meson ss (*‹G ⊆ G'›*) ing (*‹G' ∈ 𝒢›*) group_subset_point_subset (*‹⟦?G ∈ 𝒢; ?G' ⊆ ?G; ?ps ⊆ ?G'⟧ ⟹ ?ps ⊆ 𝒱›*)) then have "{y, z} ⊆ (del_point x)" using ‹y ≠ x› (*‹(y::'a) ≠ (x::'a)›*) ‹z ≠ x› (*‹z ≠ x›*) del_point_def (*‹del_point (?p::'a) ≡ 𝒱 - {?p}›*) by fastforce thus "?thesis" (*goal: ‹del_point_blocks x index {y, z} = 0›*) using delete_point_index_eq (*‹(?ps::'a set) ⊆ del_point (?p::'a) ⟹ del_point_blocks ?p index ?ps = ℬ index ?ps›*) index_together (*‹⟦?G ∈ 𝒢; ?x ∈ ?G; ?y ∈ ?G; ?x ≠ ?y⟧ ⟹ ℬ index {?x, ?y} = 0›*) by (metis assms( (*‹y ∈ G›*) 2) assms( (*‹z ∈ G›*) 3) assms( (*‹z ≠ y›*) 4) in_mono (*‹?A ⊆ ?B ⟹ ?x ∈ ?A ⟶ ?x ∈ ?B›*) ing (*‹G' ∈ 𝒢›*) ss (*‹G ⊆ G'›*)) qed lemma delete_point_index: assumes "G1 ∈ {g - {x} |g. g ∈ 𝒢 ∧ g ≠ {x}}" assumes "G2 ∈ {g - {x} |g. g ∈ 𝒢 ∧ g ≠ {x}}" assumes "G1 ≠ G2" and "y ∈ G1" and "z ∈ G2" shows "del_point_blocks x index {y, z} = Λ" proof (-) (*goal: ‹int (del_point_blocks x index {y, z}) = Λ›*) have "y ≠ x" using assms (*‹G1 ∈ {g - {x} |g. g ∈ 𝒢 ∧ g ≠ {x}}› ‹(G2::'a set) ∈ {g - {x::'a} |g::'a set. g ∈ 𝒢 ∧ g ≠ {x}}› ‹(G1::'a set) ≠ (G2::'a set)› ‹y ∈ G1› ‹z ∈ G2›*) by blast have "z ≠ x" using assms (*‹G1 ∈ {g - {x} |g. g ∈ 𝒢 ∧ g ≠ {x}}› ‹G2 ∈ {g - {x} |g. g ∈ 𝒢 ∧ g ≠ {x}}› ‹(G1::'a::type set) ≠ (G2::'a::type set)› ‹y ∈ G1› ‹(z::'a::type) ∈ (G2::'a::type set)›*) by blast obtain G1' where ing1: "G1' ∈ 𝒢" and t1: "G1 = G1' - {x}" (*goal: ‹(⋀G1'. ⟦G1' ∈ 𝒢; G1 = G1' - {x}⟧ ⟹ thesis) ⟹ thesis›*) using assms(1) (*‹G1 ∈ {g - {x} |g. g ∈ 𝒢 ∧ g ≠ {x}}›*) by auto obtain G2' where ing2: "G2' ∈ 𝒢" and t2: "G2 = G2' - {x}" (*goal: ‹(⋀G2'::'a set. ⟦G2' ∈ 𝒢; (G2::'a set) = G2' - {x::'a}⟧ ⟹ thesis::bool) ⟹ thesis›*) using assms(2) (*‹G2 ∈ {g - {x} |g. g ∈ 𝒢 ∧ g ≠ {x}}›*) by auto then have ss1: "G1 ⊆ G1'" and ss2: "G2 ⊆ G2'" using t1 (*‹G1 = G1' - {x}›*) apply - (*goals: 1. ‹⟦G2' ∈ 𝒢; G2 = G2' - {x}; G1 = G1' - {x}⟧ ⟹ G1 ⊆ G1'› 2. ‹⟦G2' ∈ 𝒢; G2 = G2' - {x}; G1 = G1' - {x}⟧ ⟹ G2 ⊆ G2'› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . then have "{y, z} ⊆ 𝒱" using ing1 (*‹G1' ∈ 𝒢›*) ing2 (*‹G2' ∈ 𝒢›*) ss1 (*‹G1 ⊆ G1'›*) ss2 (*‹G2 ⊆ G2'›*) assms(4) (*‹y ∈ G1›*) assms(5) (*‹z ∈ G2›*) by (metis empty_subsetI (*‹{} ⊆ (?A::?'a set)›*) insert_absorb (*‹(?a::?'a) ∈ (?A::?'a set) ⟹ insert ?a ?A = ?A›*) insert_subset (*‹(insert (?x::?'a) (?A::?'a set) ⊆ (?B::?'a set)) = (?x ∈ ?B ∧ ?A ⊆ ?B)›*) point_in_group (*‹⟦(?G::'a set) ∈ 𝒢; (?x::'a) ∈ ?G⟧ ⟹ ?x ∈ 𝒱›*)) then have "{y, z} ⊆ del_point x" using ‹y ≠ x› (*‹y ≠ x›*) ‹z ≠ x› (*‹z ≠ x›*) del_point_def (*‹del_point ?p ≡ 𝒱 - {?p}›*) by auto then have indx: "del_point_blocks x index {y, z} = ℬ index {y, z}" using delete_point_index_eq (*‹?ps ⊆ del_point ?p ⟹ del_point_blocks ?p index ?ps = ℬ index ?ps›*) by auto have "G1' ≠ G2'" using assms (*‹G1 ∈ {g - {x} |g. g ∈ 𝒢 ∧ g ≠ {x}}› ‹G2 ∈ {g - {x} |g. g ∈ 𝒢 ∧ g ≠ {x}}› ‹G1 ≠ G2› ‹y ∈ G1› ‹z ∈ G2›*) t1 (*‹G1 = G1' - {x}›*) t2 (*‹G2 = G2' - {x}›*) by fastforce thus "?thesis" (*goal: ‹int (del_point_blocks x index {y, z}) = Λ›*) using index_distinct (*‹⟦?G1.0 ∈ 𝒢; ?G2.0 ∈ 𝒢; ?G1.0 ≠ ?G2.0; ?x ∈ ?G1.0; ?y ∈ ?G2.0⟧ ⟹ int (ℬ index {?x, ?y}) = Λ›*) using indx (*‹del_point_blocks x index {y, z} = ℬ index {y, z}›*) assms(4) (*‹y ∈ G1›*) assms(5) (*‹z ∈ G2›*) ing1 (*‹G1' ∈ 𝒢›*) ing2 (*‹G2' ∈ 𝒢›*) t1 (*‹G1 = G1' - {x}›*) t2 (*‹G2 = G2' - {x}›*) by auto qed lemma delete_point_group_size: assumes "{x} ∈ 𝒢 ⟹ card 𝒢 > 2" shows "1 < card {g - {x} |g. g ∈ 𝒢 ∧ g ≠ {x}}" proof (cases "{x} ∈ 𝒢") (*goals: 1. ‹{x} ∈ 𝒢 ⟹ 1 < card {g - {x} |g. g ∈ 𝒢 ∧ g ≠ {x}}› 2. ‹{x} ∉ 𝒢 ⟹ 1 < card {g - {x} |g. g ∈ 𝒢 ∧ g ≠ {x}}›*) case True (*‹{x} ∈ 𝒢›*) then have "⋀ g . g ∈ (𝒢 - {{x}}) ⟹ x ∉ g" by (meson disjnt_insert1 (*‹disjnt (insert ?a ?X) ?Y = (?a ∉ ?Y ∧ disjnt ?X ?Y)›*) groups_disjoint (*‹disjoint 𝒢›*) pairwise_alt (*‹pairwise ?R ?S = (∀x∈?S. ∀y∈?S - {x}. ?R x y)›*)) then have simpg: "⋀ g . g ∈ (𝒢 - {{x}}) ⟹ g - {x} = g" by simp have "{g - {x} |g. g ∈ 𝒢 ∧ g ≠ {x}} = {g - {x} |g. (g ∈ 𝒢 - {{x}})}" using True (*‹{x} ∈ 𝒢›*) by force then have "{g - {x} |g. g ∈ 𝒢 ∧ g ≠ {x}} = {g |g. (g ∈ 𝒢 - {{x}})}" using simpg (*‹?g ∈ 𝒢 - {{x}} ⟹ ?g - {x} = ?g›*) by (smt (verit) Collect_cong (*‹(⋀x. ?P x = ?Q x) ⟹ {x. ?P x} = {x. ?Q x}›*)) then have eq: "{g - {x} |g. g ∈ 𝒢 ∧ g ≠ {x}} = 𝒢 - {{x}}" using set_self_img_compr (*‹{a |a. a ∈ ?A} = ?A›*) by blast have "card (𝒢 - {{x}}) = card 𝒢 - 1" using True (*‹{x} ∈ 𝒢›*) by (simp add: groups_finite (*‹finite 𝒢›*)) then show "?thesis" (*goal: ‹1 < card {g - {x} |g. g ∈ 𝒢 ∧ g ≠ {x}}›*) using True (*‹{x} ∈ 𝒢›*) assms (*‹{x} ∈ 𝒢 ⟹ 2 < card 𝒢›*) eq (*‹{g - {x} |g. g ∈ 𝒢 ∧ g ≠ {x}} = 𝒢 - {{x}}›*) diff_is_0_eq' (*‹?m ≤ ?n ⟹ ?m - ?n = 0›*) by force next (*goal: ‹{x::'a::type} ∉ 𝒢 ⟹ (1::nat) < card {g - {x} |g::'a::type set. g ∈ 𝒢 ∧ g ≠ {x}}›*) case False (*‹{x} ∉ 𝒢›*) then have "⋀g' y. {x} ∉ 𝒢 ⟹ g' ∈ 𝒢 ⟹ y ∈ 𝒢 ⟹ g' - {x} = y - {x} ⟹ g' = y" by (metis all_not_in_conv (*‹(∀x. x ∉ ?A) = (?A = {})›*) insert_Diff_single (*‹insert ?a (?A - {?a}) = insert ?a ?A›*) insert_absorb (*‹?a ∈ ?A ⟹ insert ?a ?A = ?A›*) insert_iff (*‹(?a ∈ insert ?b ?A) = (?a = ?b ∨ ?a ∈ ?A)›*) points_sep_groups_ne (*‹⟦?G1.0 ∈ 𝒢; ?G2.0 ∈ 𝒢; ?G1.0 ≠ ?G2.0; ?x ∈ ?G1.0; ?y ∈ ?G2.0⟧ ⟹ ?x ≠ ?y›*)) then have inj: "inj_on (λ g . g - {x}) 𝒢" by (simp add: inj_onI (*‹(⋀(x::?'a) y::?'a. ⟦x ∈ (?A::?'a set); y ∈ ?A; (?f::?'a ⇒ ?'b) x = ?f y⟧ ⟹ x = y) ⟹ inj_on ?f ?A›*) False (*‹{x::'a} ∉ 𝒢›*)) have "{g - {x} |g. g ∈ 𝒢 ∧ g ≠ {x}} = {g - {x} |g. g ∈ 𝒢}" using False (*‹{x} ∉ 𝒢›*) by auto then have "card {g - {x} |g. g ∈ 𝒢 ∧ g ≠ {x}} = card 𝒢" using inj (*‹inj_on (λg::'a::type set. g - {x::'a::type}) 𝒢›*) groups_finite (*‹finite 𝒢›*) card_image (*‹inj_on ?f ?A ⟹ card (?f ` ?A) = card ?A›*) by (auto simp add: card_image (*‹inj_on ?f ?A ⟹ card (?f ` ?A) = card ?A›*) setcompr_eq_image (*‹{?f x |x. ?P x} = ?f ` {x. ?P x}›*)) then show "?thesis" (*goal: ‹1 < card {g - {x} |g. g ∈ 𝒢 ∧ g ≠ {x}}›*) using groups_size (*‹(1::nat) < card 𝒢›*) by presburger qed lemma GDD_by_deleting_point: assumes "⋀bl. bl ∈# ℬ ⟹ x ∈ bl ⟹ 2 ≤ card bl" assumes "{x} ∈ 𝒢 ⟹ card 𝒢 > 2" shows "GDD (del_point x) (del_point_blocks x) {g - {x} | g . g ∈ 𝒢 ∧ g ≠ {x}} Λ" proof (-) (*goal: ‹GDD (del_point x) (del_point_blocks x) {g - {x} |g. g ∈ 𝒢 ∧ g ≠ {x}} Λ›*) interpret pd: proper_design "del_point x" "del_point_blocks x" using delete_point_proper (*‹(⋀bl::'a::type set. ⟦bl ∈# ℬ; (?p::'a::type) ∈ bl⟧ ⟹ (2::nat) ≤ card bl) ⟹ proper_design (del_point ?p) (del_point_blocks ?p)›*) assms (*‹⟦?bl ∈# ℬ; x ∈ ?bl⟧ ⟹ 2 ≤ card ?bl› ‹{x} ∈ 𝒢 ⟹ 2 < card 𝒢›*) by blast show "?thesis" (*goal: ‹GDD (del_point x) (del_point_blocks x) {g - {x} |g. g ∈ 𝒢 ∧ g ≠ {x}} Λ›*) using delete_point_index_zero (*‹⟦?G ∈ {g - {?x} |g. g ∈ 𝒢 ∧ g ≠ {?x}}; ?y ∈ ?G; ?z ∈ ?G; ?z ≠ ?y⟧ ⟹ del_point_blocks ?x index {?y, ?z} = 0›*) delete_point_index (*‹⟦?G1.0 ∈ {g - {?x} |g. g ∈ 𝒢 ∧ g ≠ {?x}}; ?G2.0 ∈ {g - {?x} |g. g ∈ 𝒢 ∧ g ≠ {?x}}; ?G1.0 ≠ ?G2.0; ?y ∈ ?G1.0; ?z ∈ ?G2.0⟧ ⟹ int (del_point_blocks ?x index {?y, ?z}) = Λ›*) assms (*‹⟦(?bl::'a set) ∈# ℬ; (x::'a) ∈ ?bl⟧ ⟹ (2::nat) ≤ card ?bl› ‹{x::'a} ∈ 𝒢 ⟹ (2::nat) < card 𝒢›*) delete_point_group_size (*‹({?x} ∈ 𝒢 ⟹ 2 < card 𝒢) ⟹ 1 < card {g - {?x} |g. g ∈ 𝒢 ∧ g ≠ {?x}}›*) apply unfold_locales (*goals: 1. ‹⟦⋀G x y z. ⟦G ∈ {g - {x} |g. g ∈ 𝒢 ∧ g ≠ {x}}; y ∈ G; z ∈ G; z ≠ y⟧ ⟹ del_point_blocks x index {y, z} = 0; ⋀G1 x G2 y z. ⟦G1 ∈ {g - {x} |g. g ∈ 𝒢 ∧ g ≠ {x}}; G2 ∈ {g - {x} |g. g ∈ 𝒢 ∧ g ≠ {x}}; G1 ≠ G2; y ∈ G1; z ∈ G2⟧ ⟹ int (del_point_blocks x index {y, z}) = Λ; ⋀bl. ⟦bl ∈# ℬ; x ∈ bl⟧ ⟹ 2 ≤ card bl; {x} ∈ 𝒢 ⟹ 2 < card 𝒢; ⋀x. ({x} ∈ 𝒢 ⟹ 2 < card 𝒢) ⟹ 1 < card {g - {x} |g. g ∈ 𝒢 ∧ g ≠ {x}}⟧ ⟹ partition_on (del_point x) {g - {x} |g. g ∈ 𝒢 ∧ g ≠ {x}}› 2. ‹⟦⋀G x y z. ⟦G ∈ {g - {x} |g. g ∈ 𝒢 ∧ g ≠ {x}}; y ∈ G; z ∈ G; z ≠ y⟧ ⟹ del_point_blocks x index {y, z} = 0; ⋀G1 x G2 y z. ⟦G1 ∈ {g - {x} |g. g ∈ 𝒢 ∧ g ≠ {x}}; G2 ∈ {g - {x} |g. g ∈ 𝒢 ∧ g ≠ {x}}; G1 ≠ G2; y ∈ G1; z ∈ G2⟧ ⟹ int (del_point_blocks x index {y, z}) = Λ; ⋀bl. ⟦bl ∈# ℬ; x ∈ bl⟧ ⟹ 2 ≤ card bl; {x} ∈ 𝒢 ⟹ 2 < card 𝒢; ⋀x. ({x} ∈ 𝒢 ⟹ 2 < card 𝒢) ⟹ 1 < card {g - {x} |g. g ∈ 𝒢 ∧ g ≠ {x}}⟧ ⟹ 1 < card {g - {x} |g. g ∈ 𝒢 ∧ g ≠ {x}}› 3. ‹⟦⋀G x y z. ⟦G ∈ {g - {x} |g. g ∈ 𝒢 ∧ g ≠ {x}}; y ∈ G; z ∈ G; z ≠ y⟧ ⟹ del_point_blocks x index {y, z} = 0; ⋀G1 x G2 y z. ⟦G1 ∈ {g - {x} |g. g ∈ 𝒢 ∧ g ≠ {x}}; G2 ∈ {g - {x} |g. g ∈ 𝒢 ∧ g ≠ {x}}; G1 ≠ G2; y ∈ G1; z ∈ G2⟧ ⟹ int (del_point_blocks x index {y, z}) = Λ; ⋀bl. ⟦bl ∈# ℬ; x ∈ bl⟧ ⟹ 2 ≤ card bl; {x} ∈ 𝒢 ⟹ 2 < card 𝒢; ⋀x. ({x} ∈ 𝒢 ⟹ 2 < card 𝒢) ⟹ 1 < card {g - {x} |g. g ∈ 𝒢 ∧ g ≠ {x}}⟧ ⟹ 1 ≤ Λ› 4. ‹⋀G xa y. ⟦⋀G x y z. ⟦G ∈ {g - {x} |g. g ∈ 𝒢 ∧ g ≠ {x}}; y ∈ G; z ∈ G; z ≠ y⟧ ⟹ del_point_blocks x index {y, z} = 0; ⋀G1 x G2 y z. ⟦G1 ∈ {g - {x} |g. g ∈ 𝒢 ∧ g ≠ {x}}; G2 ∈ {g - {x} |g. g ∈ 𝒢 ∧ g ≠ {x}}; G1 ≠ G2; y ∈ G1; z ∈ G2⟧ ⟹ int (del_point_blocks x index {y, z}) = Λ; ⋀bl. ⟦bl ∈# ℬ; x ∈ bl⟧ ⟹ 2 ≤ card bl; {x} ∈ 𝒢 ⟹ 2 < card 𝒢; ⋀x. ({x} ∈ 𝒢 ⟹ 2 < card 𝒢) ⟹ 1 < card {g - {x} |g. g ∈ 𝒢 ∧ g ≠ {x}}; G ∈ {g - {x} |g. g ∈ 𝒢 ∧ g ≠ {x}}; xa ∈ G; y ∈ G; xa ≠ y⟧ ⟹ del_point_blocks x index {xa, y} = 0› 5. ‹⋀G1 G2 xa y. ⟦⋀G x y z. ⟦G ∈ {g - {x} |g. g ∈ 𝒢 ∧ g ≠ {x}}; y ∈ G; z ∈ G; z ≠ y⟧ ⟹ del_point_blocks x index {y, z} = 0; ⋀G1 x G2 y z. ⟦G1 ∈ {g - {x} |g. g ∈ 𝒢 ∧ g ≠ {x}}; G2 ∈ {g - {x} |g. g ∈ 𝒢 ∧ g ≠ {x}}; G1 ≠ G2; y ∈ G1; z ∈ G2⟧ ⟹ int (del_point_blocks x index {y, z}) = Λ; ⋀bl. ⟦bl ∈# ℬ; x ∈ bl⟧ ⟹ 2 ≤ card bl; {x} ∈ 𝒢 ⟹ 2 < card 𝒢; ⋀x. ({x} ∈ 𝒢 ⟹ 2 < card 𝒢) ⟹ 1 < card {g - {x} |g. g ∈ 𝒢 ∧ g ≠ {x}}; G1 ∈ {g - {x} |g. g ∈ 𝒢 ∧ g ≠ {x}}; G2 ∈ {g - {x} |g. g ∈ 𝒢 ∧ g ≠ {x}}; G1 ≠ G2; xa ∈ G1; y ∈ G2⟧ ⟹ int (del_point_blocks x index {xa, y}) = Λ› discuss goal 1*) apply (simp add: partition_on_remove_pt (*‹partition_on ?A ?G ⟹ partition_on (?A - {?x}) {g - {?x} |g. g ∈ ?G ∧ g ≠ {?x}}›*) group_partitions (*‹partition_on 𝒱 𝒢›*) index_ge_1 (*‹1 ≤ Λ›*) del_point_def (*‹del_point ?p ≡ 𝒱 - {?p}›*)) (*discuss goal 2*) apply (simp add: partition_on_remove_pt (*‹partition_on ?A ?G ⟹ partition_on (?A - {?x}) {g - {?x} |g. g ∈ ?G ∧ g ≠ {?x}}›*) group_partitions (*‹partition_on 𝒱 𝒢›*) index_ge_1 (*‹1 ≤ Λ›*) del_point_def (*‹del_point ?p ≡ 𝒱 - {?p}›*)) (*discuss goal 3*) apply (simp add: partition_on_remove_pt (*‹partition_on ?A ?G ⟹ partition_on (?A - {?x}) {g - {?x} |g. g ∈ ?G ∧ g ≠ {?x}}›*) group_partitions (*‹partition_on 𝒱 𝒢›*) index_ge_1 (*‹1 ≤ Λ›*) del_point_def (*‹del_point ?p ≡ 𝒱 - {?p}›*)) (*discuss goal 4*) apply (simp add: partition_on_remove_pt (*‹partition_on ?A ?G ⟹ partition_on (?A - {?x}) {g - {?x} |g. g ∈ ?G ∧ g ≠ {?x}}›*) group_partitions (*‹partition_on 𝒱 𝒢›*) index_ge_1 (*‹1 ≤ Λ›*) del_point_def (*‹del_point ?p ≡ 𝒱 - {?p}›*)) (*discuss goal 5*) apply (simp add: partition_on_remove_pt (*‹partition_on ?A ?G ⟹ partition_on (?A - {?x}) {g - {?x} |g. g ∈ ?G ∧ g ≠ {?x}}›*) group_partitions (*‹partition_on 𝒱 𝒢›*) index_ge_1 (*‹1 ≤ Λ›*) del_point_def (*‹del_point ?p ≡ 𝒱 - {?p}›*)) (*proven 5 subgoals*) . qed end context K_GDD begin subsubsection ‹PBD construction from GDD› text ‹Two well known PBD constructions involve taking a GDD and either combining the groups and blocks to form a new block collection, or by adjoining a point› text ‹First prove that combining the groups and block set results in a constant index› lemma kgdd1_points_index_group_block: assumes "ps ⊆ 𝒱" and "card ps = 2" shows "(ℬ + mset_set 𝒢) index ps = 1" proof (-) (*goal: ‹(ℬ + mset_set 𝒢) index ps = 1›*) have index1: "(⋀ G . G ∈ 𝒢 ⟹ ¬ ps ⊆ G) ⟹ ℬ index ps = 1" using index_distinct_alt_ss (*‹⟦?ps ⊆ 𝒱; card ?ps = 2; ⋀G. G ∈ 𝒢 ⟹ ¬ ?ps ⊆ G⟧ ⟹ int (ℬ index ?ps) = 1›*) assms (*‹ps ⊆ 𝒱› ‹card ps = 2›*) by fastforce have groups1: "ℬ index ps = 0 ⟹ size {#b ∈# mset_set 𝒢 . ps ⊆ b#} = 1" using index_zero_implies_one_group (*‹⟦?ps ⊆ 𝒱; card ?ps = 2; ℬ index ?ps = 0⟧ ⟹ size (filter_mset ((⊆) ?ps) (mset_set 𝒢)) = 1›*) assms (*‹ps ⊆ 𝒱› ‹card ps = 2›*) by simp then have "(ℬ + mset_set 𝒢) index ps = size (filter_mset ((⊆) ps) (ℬ + mset_set 𝒢))" by (simp add: points_index_def (*‹?B index ?ps ≡ size (filter_mset ((⊆) ?ps) ?B)›*)) thus "?thesis" (*goal: ‹(ℬ + mset_set 𝒢) index ps = 1›*) using index1 (*‹(⋀G::'a set. G ∈ 𝒢 ⟹ ¬ (ps::'a set) ⊆ G) ⟹ ℬ index ps = (1::nat)›*) groups1 (*‹ℬ index ps = 0 ⟹ size (filter_mset ((⊆) ps) (mset_set 𝒢)) = 1›*) gdd_index_non_zero_iff (*‹⟦?ps ⊆ 𝒱; card ?ps = 2⟧ ⟹ (int (ℬ index ?ps) = 1) = (size (filter_mset ((⊆) ?ps) (mset_set 𝒢)) = 0)›*) gdd_index_zero_iff (*‹⟦?ps ⊆ 𝒱; card ?ps = 2⟧ ⟹ (ℬ index ?ps = 0) = (size (filter_mset ((⊆) ?ps) (mset_set 𝒢)) = 1)›*) assms (*‹ps ⊆ 𝒱› ‹card ps = 2›*) gdd_index_options (*‹⟦?ps ⊆ 𝒱; card ?ps = 2⟧ ⟹ ℬ index ?ps = 0 ∨ int (ℬ index ?ps) = 1›*) points_index_def (*‹(?B::?'a set multiset) index (?ps::?'a set) ≡ size (filter_mset ((⊆) ?ps) ?B)›*) filter_union_mset (*‹filter_mset (?P::?'a ⇒ bool) ((?M::?'a multiset) + (?N::?'a multiset)) = filter_mset ?P ?M + filter_mset ?P ?N›*) union_commute (*‹?M + ?N = ?N + ?M›*) by (smt (z3) empty_neutral( (*‹{#} + ?x = ?x›*) 1) less_irrefl_nat (*‹?n < ?n ⟹ ?R›*) nonempty_has_size (*‹(?S ≠ {#}) = (0 < size ?S)›*) of_nat_1_eq_iff (*‹(1 = of_nat ?n) = (?n = 1)›*)) qed text ‹Combining blocks and the group set forms a PBD› lemma combine_block_groups_pairwise: "pairwise_balance 𝒱 (ℬ + mset_set 𝒢) 1" proof (-) (*goal: ‹pairwise_balance 𝒱 (ℬ + mset_set 𝒢) (1::nat)›*) let ?B = "ℬ + mset_set 𝒢" have ss: "⋀ G. G ∈ 𝒢 ⟹ G ⊆ 𝒱" by (simp add: point_in_group (*‹⟦?G ∈ 𝒢; ?x ∈ ?G⟧ ⟹ ?x ∈ 𝒱›*) subsetI (*‹(⋀x. x ∈ ?A ⟹ x ∈ ?B) ⟹ ?A ⊆ ?B›*)) have "⋀ G. G ∈ 𝒢 ⟹ G ≠ {}" using group_partitions (*‹partition_on 𝒱 𝒢›*) using partition_onD3 (*‹partition_on (?A::?'a set) (?P::?'a set set) ⟹ {} ∉ ?P›*) by auto then interpret inc: design "𝒱" "?B" proof (unfold_locales) (*goals: 1. ‹⋀b. ⟦⋀G. G ∈ 𝒢 ⟹ G ≠ {}; b ∈# ℬ + mset_set 𝒢⟧ ⟹ b ⊆ 𝒱› 2. ‹(⋀G. G ∈ 𝒢 ⟹ G ≠ {}) ⟹ finite 𝒱› 3. ‹⋀bl. ⟦⋀G. G ∈ 𝒢 ⟹ G ≠ {}; bl ∈# ℬ + mset_set 𝒢⟧ ⟹ bl ≠ {}›*) show "⋀b. (⋀G. G ∈ 𝒢 ⟹ G ≠ {}) ⟹ b ∈# ℬ + mset_set 𝒢 ⟹ b ⊆ 𝒱" by (metis finite_set_mset_mset_set (*‹finite ?A ⟹ set_mset (mset_set ?A) = ?A›*) groups_finite (*‹finite 𝒢›*) ss (*‹?G ∈ 𝒢 ⟹ ?G ⊆ 𝒱›*) union_iff (*‹(?a ∈# ?A + ?B) = (?a ∈# ?A ∨ ?a ∈# ?B)›*) wellformed (*‹?b ∈# ℬ ⟹ ?b ⊆ 𝒱›*)) show "(⋀G. G ∈ 𝒢 ⟹ G ≠ {}) ⟹ finite 𝒱" by (simp add: finite_sets (*‹finite 𝒱›*)) show "⋀bl. (⋀G. G ∈ 𝒢 ⟹ G ≠ {}) ⟹ bl ∈# ℬ + mset_set 𝒢 ⟹ bl ≠ {}" using blocks_nempty (*‹?bl ∈# ℬ ⟹ ?bl ≠ {}›*) groups_finite (*‹finite 𝒢›*) by auto qed show "?thesis" (*goal: ‹pairwise_balance 𝒱 (ℬ + mset_set 𝒢) 1›*) proof (unfold_locales) (*goals: 1. ‹inc.𝖻 ≠ 0› 2. ‹1 ≤ 2› 3. ‹2 ≤ inc.𝗏› 4. ‹⋀ps. ⟦ps ⊆ 𝒱; card ps = 2⟧ ⟹ (ℬ + mset_set 𝒢) index ps = 1›*) show "inc.𝖻 ≠ 0" using b_positive (*‹0 < 𝖻›*) by auto show "(1 ::nat) ≤ 2" by simp show "2 ≤ inc.𝗏" by (simp add: gdd_min_v (*‹2 ≤ inc.𝗏›*)) then show "⋀ps. ps ⊆ 𝒱 ⟹ card ps = 2 ⟹ (ℬ + mset_set 𝒢) index ps = 1" using kgdd1_points_index_group_block (*‹⟦?ps ⊆ 𝒱; card ?ps = 2⟧ ⟹ (ℬ + mset_set 𝒢) index ?ps = 1›*) by simp qed qed lemma combine_block_groups_PBD: assumes "⋀ G. G ∈ 𝒢 ⟹ card G ∈ 𝒦" assumes "⋀ k . k ∈ 𝒦 ⟹ k ≥ 2" shows "PBD 𝒱 (ℬ + mset_set 𝒢) 𝒦" proof (-) (*goal: ‹PBD 𝒱 (ℬ + mset_set 𝒢) 𝒦›*) let ?B = "ℬ + mset_set 𝒢" interpret inc: pairwise_balance "𝒱" "?B" 1 using combine_block_groups_pairwise (*‹pairwise_balance 𝒱 (ℬ + mset_set 𝒢) (1::nat)›*) by simp show "?thesis" (*goal: ‹PBD 𝒱 (ℬ + mset_set 𝒢) 𝒦›*) using assms (*‹?G ∈ 𝒢 ⟹ card ?G ∈ 𝒦› ‹?k ∈ 𝒦 ⟹ 2 ≤ ?k›*) block_sizes (*‹?bl ∈# ℬ ⟹ card ?bl ∈ 𝒦›*) groups_finite (*‹finite 𝒢›*) positive_ints (*‹(?x::nat) ∈ 𝒦 ⟹ (0::nat) < ?x›*) apply unfold_locales (*goals: 1. ‹⋀bl. ⟦⋀G. G ∈ 𝒢 ⟹ card G ∈ 𝒦; ⋀k. k ∈ 𝒦 ⟹ 2 ≤ k; ⋀bl. bl ∈# ℬ ⟹ card bl ∈ 𝒦; finite 𝒢; ⋀x. x ∈ 𝒦 ⟹ 0 < x; bl ∈# ℬ + mset_set 𝒢⟧ ⟹ card bl ∈ 𝒦› 2. ‹⋀x. ⟦⋀G. G ∈ 𝒢 ⟹ card G ∈ 𝒦; ⋀k. k ∈ 𝒦 ⟹ 2 ≤ k; ⋀bl. bl ∈# ℬ ⟹ card bl ∈ 𝒦; finite 𝒢; ⋀x. x ∈ 𝒦 ⟹ 0 < x; x ∈ 𝒦⟧ ⟹ 0 < x› 3. ‹⋀k. ⟦⋀G. G ∈ 𝒢 ⟹ card G ∈ 𝒦; ⋀k. k ∈ 𝒦 ⟹ 2 ≤ k; ⋀bl. bl ∈# ℬ ⟹ card bl ∈ 𝒦; finite 𝒢; ⋀x. x ∈ 𝒦 ⟹ 0 < x; k ∈ 𝒦⟧ ⟹ 2 ≤ k› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*proven 3 subgoals*) . qed text ‹Prove adjoining a point to each group set results in a constant points index› lemma kgdd1_index_adjoin_group_block: assumes "x ∉ 𝒱" assumes "ps ⊆ insert x 𝒱" assumes "card ps = 2" shows "(ℬ + mset_set {insert x g |g. g ∈ 𝒢}) index ps = 1" proof (-) (*goal: ‹(ℬ + mset_set {insert x g |g. g ∈ 𝒢}) index ps = 1›*) have "inj_on ((insert) x) 𝒢" by (meson assms( (*‹x ∉ 𝒱›*) 1) inj_onI (*‹(⋀x y. ⟦x ∈ ?A; y ∈ ?A; ?f x = ?f y⟧ ⟹ x = y) ⟹ inj_on ?f ?A›*) insert_ident (*‹⟦?x ∉ ?A; ?x ∉ ?B⟧ ⟹ (insert ?x ?A = insert ?x ?B) = (?A = ?B)›*) point_in_group (*‹⟦?G ∈ 𝒢; ?x ∈ ?G⟧ ⟹ ?x ∈ 𝒱›*)) then have eq: "mset_set {insert x g |g. g ∈ 𝒢} = {# insert x g . g ∈# mset_set 𝒢#}" by (simp add: image_mset_mset_set (*‹inj_on ?f ?A ⟹ image_mset ?f (mset_set ?A) = mset_set (?f ` ?A)›*) setcompr_eq_image (*‹{?f x |x. ?P x} = ?f ` {x. ?P x}›*)) thus "?thesis" (*goal: ‹(ℬ + mset_set {insert (x::'a) g |g::'a set. g ∈ 𝒢}) index (ps::'a set) = (1::nat)›*) proof (cases "x ∈ ps") (*goals: 1. ‹⟦mset_set {insert x g |g. g ∈ 𝒢} = image_mset (insert x) (mset_set 𝒢); x ∈ ps⟧ ⟹ (ℬ + mset_set {insert x g |g. g ∈ 𝒢}) index ps = 1› 2. ‹⟦mset_set {insert x g |g. g ∈ 𝒢} = image_mset (insert x) (mset_set 𝒢); x ∉ ps⟧ ⟹ (ℬ + mset_set {insert x g |g. g ∈ 𝒢}) index ps = 1›*) case True (*‹x ∈ ps›*) then obtain y where y_ps: "ps = {x, y}" (*goal: ‹(⋀y. ps = {x, y} ⟹ thesis) ⟹ thesis›*) using assms(3) (*‹card ps = 2›*) by (metis card_2_iff (*‹(card ?S = 2) = (∃x y. ?S = {x, y} ∧ x ≠ y)›*) doubleton_eq_iff (*‹({?a, ?b} = {?c, ?d}) = (?a = ?c ∧ ?b = ?d ∨ ?a = ?d ∧ ?b = ?c)›*) insertE (*‹⟦?a ∈ insert ?b ?A; ?a = ?b ⟹ ?P; ?a ∈ ?A ⟹ ?P⟧ ⟹ ?P›*) singletonD (*‹?b ∈ {?a} ⟹ ?b = ?a›*)) then have ynex: "y ≠ x" using assms (*‹(x::'a) ∉ 𝒱› ‹ps ⊆ insert x 𝒱› ‹card ps = 2›*) by fastforce have yinv: "y ∈ 𝒱" using assms(2) (*‹ps ⊆ insert x 𝒱›*) y_ps (*‹(ps::'a set) = {x::'a, y::'a}›*) ynex (*‹y ≠ x›*) by auto have all_g: "⋀ g. g ∈# (mset_set {insert x g |g. g ∈ 𝒢}) ⟹ x ∈ g" using eq (*‹mset_set {insert (x::'a::type) g |g::'a::type set. g ∈ 𝒢} = image_mset (insert x) (mset_set 𝒢)›*) by force have iff: "⋀ g . g ∈ 𝒢 ⟹ y ∈ (insert x g) ⟷ y ∈ g" using ynex (*‹y ≠ x›*) by simp have b: "ℬ index ps = 0" using True (*‹x ∈ ps›*) assms(1) (*‹x ∉ 𝒱›*) points_index_ps_nin (*‹¬ ?ps ⊆ 𝒱 ⟹ ℬ index ?ps = 0›*) by fastforce then have "(ℬ + mset_set {insert x g |g. g ∈ 𝒢}) index ps = (mset_set {insert x g |g. g ∈ 𝒢}) index ps" using eq (*‹mset_set {insert (x::'a) g |g::'a set. g ∈ 𝒢} = image_mset (insert x) (mset_set 𝒢)›*) by (simp add: point_index_distrib (*‹(?B1.0 + ?B2.0) index ?ps = ?B1.0 index ?ps + ?B2.0 index ?ps›*)) also (*calculation: ‹(ℬ + mset_set {insert x g |g. g ∈ 𝒢}) index ps = mset_set {insert x g |g. g ∈ 𝒢} index ps›*) have "... = (mset_set {insert x g |g. g ∈ 𝒢}) rep y" using points_index_pair_rep_num (*‹(⋀b. b ∈# ?B ⟹ ?x ∈ b) ⟹ ?B index {?x, ?y} = ?B rep ?y›*) by (metis (no_types, lifting) all_g (*‹?g ∈# mset_set {insert x g |g. g ∈ 𝒢} ⟹ x ∈ ?g›*) y_ps (*‹ps = {x, y}›*)) also (*calculation: ‹(ℬ + mset_set {insert x g |g. g ∈ 𝒢}) index ps = mset_set {insert x g |g. g ∈ 𝒢} rep y›*) have 0: "... = card {b ∈ {insert x g |g. g ∈ 𝒢} . y ∈ b}" by (simp add: groups_finite (*‹finite 𝒢›*) rep_number_on_set_def (*‹finite ?B ⟹ mset_set ?B rep ?x = card {b ∈ ?B. ?x ∈ b}›*)) also (*calculation: ‹(ℬ + mset_set {insert x g |g. g ∈ 𝒢}) index ps = card {b ∈ {insert x g |g. g ∈ 𝒢}. y ∈ b}›*) have 1: "... = card {insert x g |g. g ∈ 𝒢 ∧ y ∈ insert x g}" by (smt (verit) Collect_cong (*‹(⋀x. ?P x = ?Q x) ⟹ {x. ?P x} = {x. ?Q x}›*) mem_Collect_eq (*‹(?a ∈ Collect ?P) = ?P ?a›*)) also (*calculation: ‹(ℬ + mset_set {insert x g |g. g ∈ 𝒢}) index ps = card {insert x g |g. g ∈ 𝒢 ∧ y ∈ insert x g}›*) have 2: " ... = card {insert x g |g. g ∈ 𝒢 ∧ y ∈ g}" using iff (*‹?g ∈ 𝒢 ⟹ (y ∈ insert x ?g) = (y ∈ ?g)›*) by metis also (*calculation: ‹(ℬ + mset_set {insert x g |g. g ∈ 𝒢}) index ps = card {insert x g |g. g ∈ 𝒢 ∧ y ∈ g}›*) have "... = card {g ∈ 𝒢 . y ∈ g}" using "1" (*‹card {b ∈ {insert x g |g. g ∈ 𝒢}. y ∈ b} = card {insert x g |g. g ∈ 𝒢 ∧ y ∈ insert x g}›*) "2" (*‹card {insert x g |g. g ∈ 𝒢 ∧ y ∈ insert x g} = card {insert x g |g. g ∈ 𝒢 ∧ y ∈ g}›*) "0" (*‹mset_set {insert x g |g. g ∈ 𝒢} rep y = card {b ∈ {insert x g |g. g ∈ 𝒢}. y ∈ b}›*) empty_iff (*‹(?c ∈ {}) = False›*) eq (*‹mset_set {insert x g |g. g ∈ 𝒢} = image_mset (insert x) (mset_set 𝒢)›*) groups_finite (*‹finite 𝒢›*) ynex (*‹y ≠ x›*) insert_iff (*‹(?a ∈ insert ?b ?A) = (?a = ?b ∨ ?a ∈ ?A)›*) by (metis points_index_block_image_add_eq (*‹⟦?x ∉ ?ps; ?B index ?ps = ?l⟧ ⟹ image_mset (insert ?x) ?B index ?ps = ?l›*) points_index_single_rep_num (*‹?B index {?x} = ?B rep ?x›*) rep_number_on_set_def (*‹finite ?B ⟹ mset_set ?B rep ?x = card {b ∈ ?B. ?x ∈ b}›*)) finally (*calculation: ‹(ℬ + mset_set {insert x g |g. g ∈ 𝒢}) index ps = card {g ∈ 𝒢. y ∈ g}›*) have "(ℬ + mset_set {insert x g |g. g ∈ 𝒢}) index ps = 1" using rep_number_point_group_one (*‹?x ∈ 𝒱 ⟹ card {g ∈ 𝒢. ?x ∈ g} = 1›*) yinv (*‹y ∈ 𝒱›*) by simp then show "?thesis" (*goal: ‹(ℬ + mset_set {insert x g |g. g ∈ 𝒢}) index ps = 1›*) by simp next (*goal: ‹⟦mset_set {insert (x::'a::type) g |g::'a::type set. g ∈ 𝒢} = image_mset (insert x) (mset_set 𝒢); x ∉ (ps::'a::type set)⟧ ⟹ (ℬ + mset_set {insert x g |g::'a::type set. g ∈ 𝒢}) index ps = (1::nat)›*) case False (*‹x ∉ ps›*) then have v: "ps ⊆ 𝒱" using assms(2) (*‹ps ⊆ insert x 𝒱›*) by auto then have "(ℬ + mset_set {insert x g |g. g ∈ 𝒢}) index ps = (ℬ + mset_set 𝒢) index ps" using eq (*‹mset_set {insert (x::'a) g |g::'a set. g ∈ 𝒢} = image_mset (insert x) (mset_set 𝒢)›*) by (simp add: points_index_block_image_add_eq (*‹⟦?x ∉ ?ps; ?B index ?ps = ?l⟧ ⟹ image_mset (insert ?x) ?B index ?ps = ?l›*) False (*‹x ∉ ps›*) point_index_distrib (*‹(?B1.0 + ?B2.0) index ?ps = ?B1.0 index ?ps + ?B2.0 index ?ps›*)) then show "?thesis" (*goal: ‹(ℬ + mset_set {insert x g |g. g ∈ 𝒢}) index ps = 1›*) using v (*‹ps ⊆ 𝒱›*) assms (*‹x ∉ 𝒱› ‹ps ⊆ insert x 𝒱› ‹card ps = 2›*) kgdd1_points_index_group_block (*‹⟦?ps ⊆ 𝒱; card ?ps = 2⟧ ⟹ (ℬ + mset_set 𝒢) index ?ps = 1›*) by simp qed qed lemma pairwise_by_adjoining_point: assumes "x ∉ 𝒱" shows "pairwise_balance (add_point x) (ℬ + mset_set { insert x g | g. g ∈ 𝒢}) 1" proof (-) (*goal: ‹pairwise_balance (add_point (x::'a::type)) (ℬ + mset_set {insert x g |g::'a::type set. g ∈ 𝒢}) (1::nat)›*) let ?B = "ℬ + mset_set { insert x g | g. g ∈ 𝒢}" let ?V = "add_point x" have vdef: "?V = 𝒱 ∪ {x}" using add_point_def (*‹add_point ?p ≡ insert ?p 𝒱›*) by simp show "?thesis" (*goal: ‹pairwise_balance (add_point (x::'a::type)) (ℬ + mset_set {insert x g |g::'a::type set. g ∈ 𝒢}) (1::nat)›*) unfolding add_point_def (*goal: ‹pairwise_balance (insert x 𝒱) (ℬ + mset_set {insert x g |g. g ∈ 𝒢}) 1›*) using finite_sets (*‹finite 𝒱›*) design_blocks_nempty (*‹ℬ ≠ {#}›*) proof (unfold_locales, simp_all) (*goals: 1. ‹⋀b. ⟦b ∈# ℬ ∨ b ∈# mset_set {insert x g |g. g ∈ 𝒢}; finite 𝒱; ℬ ≠ {#}⟧ ⟹ b ⊆ insert x 𝒱› 2. ‹⋀bl. ⟦bl ∈# ℬ ∨ bl ∈# mset_set {insert x g |g. g ∈ 𝒢}; finite 𝒱; ℬ ≠ {#}⟧ ⟹ bl ≠ {}› 3. ‹⟦finite 𝒱; ℬ ≠ {#}⟧ ⟹ 2 ≤ card (insert x 𝒱)› 4. ‹⋀ps. ⟦ps ⊆ insert x 𝒱; card ps = 2; finite 𝒱; ℬ ≠ {#}⟧ ⟹ (ℬ + mset_set {insert x g |g. g ∈ 𝒢}) index ps = Suc 0›*) have "⋀ G. G ∈ 𝒢 ⟹ insert x G ⊆ ?V" by (simp add: point_in_group (*‹⟦?G ∈ 𝒢; ?x ∈ ?G⟧ ⟹ ?x ∈ 𝒱›*) subsetI (*‹(⋀x. x ∈ ?A ⟹ x ∈ ?B) ⟹ ?A ⊆ ?B›*) vdef (*‹add_point x = 𝒱 ∪ {x}›*)) then have "⋀ G. G ∈# (mset_set { insert x g | g. g ∈ 𝒢}) ⟹ G ⊆ ?V" by (smt (verit, del_insts) elem_mset_set (*‹finite ?A ⟹ (?x ∈# mset_set ?A) = (?x ∈ ?A)›*) empty_iff (*‹(?c ∈ {}) = False›*) infinite_set_mset_mset_set (*‹infinite ?A ⟹ set_mset (mset_set ?A) = {}›*) mem_Collect_eq (*‹(?a ∈ Collect ?P) = ?P ?a›*)) then show "⋀b. b ∈# ℬ ∨ b ∈# mset_set {insert x g |g. g ∈ 𝒢} ⟹ b ⊆ insert x 𝒱" using wellformed (*‹?b ∈# ℬ ⟹ ?b ⊆ 𝒱›*) add_point_def (*‹add_point ?p ≡ insert ?p 𝒱›*) by fastforce next (*goals: 1. ‹⋀bl. ⟦bl ∈# ℬ ∨ bl ∈# mset_set {insert x g |g. g ∈ 𝒢}; finite 𝒱; ℬ ≠ {#}⟧ ⟹ bl ≠ {}› 2. ‹⟦finite 𝒱; ℬ ≠ {#}⟧ ⟹ 2 ≤ card (insert x 𝒱)› 3. ‹⋀ps. ⟦ps ⊆ insert x 𝒱; card ps = 2; finite 𝒱; ℬ ≠ {#}⟧ ⟹ (ℬ + mset_set {insert x g |g. g ∈ 𝒢}) index ps = Suc 0›*) have "⋀ G. G ∈ 𝒢 ⟹ insert x G ≠ {}" using group_partitions (*‹partition_on 𝒱 𝒢›*) using partition_onD3 (*‹partition_on ?A ?P ⟹ {} ∉ ?P›*) by auto then have gnempty: "⋀ G. G ∈# (mset_set { insert x g | g. g ∈ 𝒢}) ⟹ G ≠ {}" by (smt (verit, del_insts) elem_mset_set (*‹finite ?A ⟹ (?x ∈# mset_set ?A) = (?x ∈ ?A)›*) empty_iff (*‹(?c ∈ {}) = False›*) infinite_set_mset_mset_set (*‹infinite ?A ⟹ set_mset (mset_set ?A) = {}›*) mem_Collect_eq (*‹(?a ∈ Collect ?P) = ?P ?a›*)) then show "⋀bl. bl ∈# ℬ ∨ bl ∈# mset_set {insert x g |g. g ∈ 𝒢} ⟹ bl ≠ {}" using blocks_nempty (*‹?bl ∈# ℬ ⟹ ?bl ≠ {}›*) by auto next (*goals: 1. ‹⟦finite 𝒱; ℬ ≠ {#}⟧ ⟹ (2::nat) ≤ card (insert (x::'a) 𝒱)› 2. ‹⋀ps::'a set. ⟦ps ⊆ insert (x::'a) 𝒱; card ps = (2::nat); finite 𝒱; ℬ ≠ {#}⟧ ⟹ (ℬ + mset_set {insert x g |g::'a set. g ∈ 𝒢}) index ps = Suc (0::nat)›*) have "card 𝒱 ≥ 2" using gdd_min_v (*‹2 ≤ 𝗏›*) by simp then have "card (insert x 𝒱) ≥ 2" by (meson card_insert_le (*‹card ?A ≤ card (insert ?x ?A)›*) dual_order.trans (*‹⟦?b ≤ ?a; ?c ≤ ?b⟧ ⟹ ?c ≤ ?a›*) finite_sets (*‹finite 𝒱›*)) then show "2 ≤ card (insert x 𝒱)" by auto next (*goal: ‹⋀ps::'a set. ⟦ps ⊆ insert (x::'a) 𝒱; card ps = (2::nat); finite 𝒱; ℬ ≠ {#}⟧ ⟹ (ℬ + mset_set {insert x g |g::'a set. g ∈ 𝒢}) index ps = Suc (0::nat)›*) show "⋀ps. ps ⊆ insert x 𝒱 ⟹ card ps = 2 ⟹ (ℬ + mset_set {insert x g |g. g ∈ 𝒢}) index ps = Suc 0" using kgdd1_index_adjoin_group_block (*‹⟦?x ∉ 𝒱; ?ps ⊆ insert ?x 𝒱; card ?ps = 2⟧ ⟹ (ℬ + mset_set {insert ?x g |g. g ∈ 𝒢}) index ?ps = 1›*) by (simp add: assms (*‹x ∉ 𝒱›*)) qed qed lemma PBD_by_adjoining_point: assumes "x ∉ 𝒱" assumes "⋀ k . k ∈ 𝒦 ⟹ k ≥ 2" shows "PBD (add_point x) (ℬ + mset_set { insert x g | g. g ∈ 𝒢}) (𝒦 ∪ {(card g) + 1 | g . g ∈ 𝒢})" proof (-) (*goal: ‹PBD (add_point (x::'a)) (ℬ + mset_set {insert x g |g::'a set. g ∈ 𝒢}) (𝒦 ∪ {card g + (1::nat) |g::'a set. g ∈ 𝒢})›*) let ?B = "ℬ + mset_set { insert x g | g. g ∈ 𝒢}" let ?V = "(add_point x)" interpret inc: pairwise_balance "?V" "?B" 1 using pairwise_by_adjoining_point (*‹?x ∉ 𝒱 ⟹ pairwise_balance (add_point ?x) (ℬ + mset_set {insert ?x g |g. g ∈ 𝒢}) 1›*) assms (*‹x ∉ 𝒱› ‹?k ∈ 𝒦 ⟹ 2 ≤ ?k›*) by auto show "?thesis" (*goal: ‹PBD (add_point x) (ℬ + mset_set {insert x g |g. g ∈ 𝒢}) (𝒦 ∪ {card g + 1 |g. g ∈ 𝒢})›*) using block_sizes (*‹?bl ∈# ℬ ⟹ card ?bl ∈ 𝒦›*) positive_ints (*‹?x ∈ 𝒦 ⟹ 0 < ?x›*) proof (unfold_locales) (*goals: 1. ‹⋀bl. ⟦⋀bl. bl ∈# ℬ ⟹ card bl ∈ 𝒦; ⋀x. x ∈ 𝒦 ⟹ 0 < x; bl ∈# ℬ + mset_set {insert x g |g. g ∈ 𝒢}⟧ ⟹ card bl ∈ 𝒦 ∪ {card g + 1 |g. g ∈ 𝒢}› 2. ‹⋀x. ⟦⋀bl. bl ∈# ℬ ⟹ card bl ∈ 𝒦; ⋀x. x ∈ 𝒦 ⟹ 0 < x; x ∈ 𝒦 ∪ {card g + 1 |g. g ∈ 𝒢}⟧ ⟹ 0 < x› 3. ‹⋀k. ⟦⋀bl. bl ∈# ℬ ⟹ card bl ∈ 𝒦; ⋀x. x ∈ 𝒦 ⟹ 0 < x; k ∈ 𝒦 ∪ {card g + 1 |g. g ∈ 𝒢}⟧ ⟹ 2 ≤ k›*) have xg: "⋀ g. g ∈ 𝒢 ⟹ x ∉ g" using assms (*‹x ∉ 𝒱› ‹?k ∈ 𝒦 ⟹ 2 ≤ ?k›*) point_in_group (*‹⟦?G ∈ 𝒢; ?x ∈ ?G⟧ ⟹ ?x ∈ 𝒱›*) by auto have "⋀ bl . bl ∈# ℬ ⟹ card bl ∈ 𝒦" by (simp add: block_sizes (*‹?bl ∈# ℬ ⟹ card ?bl ∈ 𝒦›*)) have "⋀ bl . bl ∈# mset_set {insert x g |g. g ∈ 𝒢} ⟹ bl ∈ {insert x g | g . g ∈ 𝒢}" by (simp add: groups_finite (*‹finite 𝒢›*)) then have "⋀ bl . bl ∈# mset_set {insert x g |g. g ∈ 𝒢} ⟹ card bl ∈ {card g + 1 |g. g ∈ 𝒢}" proof (-) (*goal: ‹⋀bl. ⟦bl ∈# mset_set {insert x g |g. g ∈ 𝒢}; ⋀bl. bl ∈# mset_set {insert x g |g. g ∈ 𝒢} ⟹ bl ∈ {insert x g |g. g ∈ 𝒢}⟧ ⟹ card bl ∈ {card g + 1 |g. g ∈ 𝒢}›*) fix bl assume "bl ∈# mset_set {insert x g |g. g ∈ 𝒢}" (*‹(bl::'a set) ∈# mset_set {insert (x::'a) g |g::'a set. g ∈ 𝒢}›*) then have "bl ∈ {insert x g | g . g ∈ 𝒢}" by (simp add: groups_finite (*‹finite 𝒢›*)) then obtain g where gin: "g ∈ 𝒢" and i: "bl = insert x g" (*goal: ‹(⋀g. ⟦g ∈ 𝒢; bl = insert x g⟧ ⟹ thesis) ⟹ thesis›*) by auto thus "card bl ∈ {(card g + 1) |g. g ∈ 𝒢}" using gin (*‹g ∈ 𝒢›*) group_elements_finite (*‹(?G::'a set) ∈ 𝒢 ⟹ finite ?G›*) i (*‹bl = insert x g›*) xg (*‹(?g::'a set) ∈ 𝒢 ⟹ (x::'a) ∉ ?g›*) by auto qed then show "⋀bl. bl ∈# ℬ + mset_set {insert x g |g. g ∈ 𝒢} ⟹ (card bl) ∈ 𝒦 ∪ {(card g + 1) |g. g ∈ 𝒢}" using UnI1 (*‹?c ∈ ?A ⟹ ?c ∈ ?A ∪ ?B›*) UnI2 (*‹?c ∈ ?B ⟹ ?c ∈ ?A ∪ ?B›*) block_sizes (*‹?bl ∈# ℬ ⟹ card ?bl ∈ 𝒦›*) union_iff (*‹(?a ∈# ?A + ?B) = (?a ∈# ?A ∨ ?a ∈# ?B)›*) by (smt (z3) mem_Collect_eq (*‹(?a ∈ Collect ?P) = ?P ?a›*)) show "⋀x. x ∈ 𝒦 ∪ {card g + 1 |g. g ∈ 𝒢} ⟹ 0 < x" using min_group_size (*‹?G ∈ 𝒢 ⟹ 1 ≤ card ?G›*) positive_ints (*‹?x ∈ 𝒦 ⟹ 0 < ?x›*) by auto show "⋀k. k ∈ 𝒦 ∪ {card g + 1 |g. g ∈ 𝒢} ⟹ 2 ≤ k" using min_group_size (*‹(?G::'a::type set) ∈ 𝒢 ⟹ (1::nat) ≤ card ?G›*) positive_ints (*‹?x ∈ 𝒦 ⟹ 0 < ?x›*) assms (*‹x ∉ 𝒱› ‹?k ∈ 𝒦 ⟹ 2 ≤ ?k›*) by fastforce qed qed subsubsection ‹Wilson's Construction› text ‹Wilson's construction involves the combination of multiple k-GDD's. This proof was based of Stinson \<^cite>‹"stinsonCombinatorialDesignsConstructions2004"›› lemma wilsons_construction_proper: assumes "card I = w" assumes "w > 0" assumes "⋀ n. n ∈ 𝒦' ⟹ n ≥ 2" assumes "⋀ B . B ∈# ℬ ⟹ K_GDD (B × I) (f B) 𝒦' {{x} × I |x . x ∈ B }" shows "proper_design (𝒱 × I) (∑B ∈# ℬ. (f B))" (is "proper_design ?Y ?B") proof (unfold_locales, simp_all) (*goals: 1. ‹⋀b. ∃x∈#ℬ. b ∈# f x ⟹ b ⊆ 𝒱 × I› 2. ‹finite (𝒱 × I)› 3. ‹⋀bl. ∃x∈#ℬ. bl ∈# f x ⟹ bl ≠ {}› 4. ‹∃i∈#ℬ. f i ≠ {#}›*) show "⋀b. ∃x∈#ℬ. b ∈# f x ⟹ b ⊆ 𝒱 × I" proof (-) (*goal: ‹⋀b. ∃x∈#ℬ. b ∈# f x ⟹ b ⊆ 𝒱 × I›*) fix b assume "∃x∈#ℬ. b ∈# f x" (*‹∃x::'a set∈#ℬ. (b::('a × 'b) set) ∈# (f::'a set ⇒ ('a × 'b) set multiset) x›*) then obtain B where "B ∈# ℬ" and "b ∈# (f B)" (*goal: ‹(⋀B. ⟦B ∈# ℬ; b ∈# f B⟧ ⟹ thesis) ⟹ thesis›*) by auto then interpret kgdd: K_GDD "(B × I)" "(f B)" "𝒦'" "{{x} × I |x . x ∈ B }" using assms (*‹card I = w› ‹(0::nat) < (w::nat)› ‹?n ∈ 𝒦' ⟹ 2 ≤ ?n› ‹?B ∈# ℬ ⟹ K_GDD (?B × I) (f ?B) 𝒦' {{x} × I |x. x ∈ ?B}›*) by auto show "b ⊆ 𝒱 × I" using kgdd.wellformed (*‹(?b::('a × 'b) set) ∈# (f::'a set ⇒ ('a × 'b) set multiset) (B::'a set) ⟹ ?b ⊆ B × (I::'b set)›*) using ‹B ∈# ℬ› (*‹B ∈# ℬ›*) ‹b ∈# f B› (*‹(b::('a::type × 'b::type) set) ∈# (f::'a::type set ⇒ ('a::type × 'b::type) set multiset) (B::'a::type set)›*) wellformed (*‹(?b::'a set) ∈# ℬ ⟹ ?b ⊆ 𝒱›*) by fastforce qed show "finite (𝒱 × I)" using finite_sets (*‹finite 𝒱›*) assms (*‹card (I::'b set) = (w::nat)› ‹(0::nat) < (w::nat)› ‹?n ∈ 𝒦' ⟹ 2 ≤ ?n› ‹?B ∈# ℬ ⟹ K_GDD (?B × I) (f ?B) 𝒦' {{x} × I |x. x ∈ ?B}›*) bot_nat_0.not_eq_extremum (*‹(?a ≠ 0) = (0 < ?a)›*) card.infinite (*‹infinite ?A ⟹ card ?A = 0›*) by blast show "⋀bl. ∃x∈#ℬ. bl ∈# f x ⟹ bl ≠ {}" proof (-) (*goal: ‹⋀bl. ∃x∈#ℬ. bl ∈# f x ⟹ bl ≠ {}›*) fix bl assume "∃x∈#ℬ. bl ∈# f x" (*‹∃x::'a set∈#ℬ. (bl::('a × 'b) set) ∈# (f::'a set ⇒ ('a × 'b) set multiset) x›*) then obtain B where "B ∈# ℬ" and "bl ∈# (f B)" (*goal: ‹(⋀B::'a set. ⟦B ∈# ℬ; (bl::('a × 'b) set) ∈# (f::'a set ⇒ ('a × 'b) set multiset) B⟧ ⟹ thesis::bool) ⟹ thesis›*) by auto then interpret kgdd: K_GDD "(B × I)" "(f B)" "𝒦'" "{{x} × I |x . x ∈ B }" using assms (*‹card I = w› ‹(0::nat) < (w::nat)› ‹?n ∈ 𝒦' ⟹ 2 ≤ ?n› ‹?B ∈# ℬ ⟹ K_GDD (?B × I) (f ?B) 𝒦' {{x} × I |x. x ∈ ?B}›*) by auto show "bl ≠ {}" using kgdd.blocks_nempty (*‹(?bl::('a × 'b) set) ∈# (f::'a set ⇒ ('a × 'b) set multiset) (B::'a set) ⟹ ?bl ≠ {}›*) by (simp add: ‹bl ∈# f B›) qed show "∃i∈#ℬ. f i ≠ {#}" proof (-) (*goal: ‹∃i∈#ℬ. f i ≠ {#}›*) obtain B where "B ∈# ℬ" (*goal: ‹(⋀B. B ∈# ℬ ⟹ thesis) ⟹ thesis›*) using design_blocks_nempty (*‹ℬ ≠ {#}›*) by auto then interpret kgdd: K_GDD "(B × I)" "(f B)" "𝒦'" "{{x} × I |x . x ∈ B }" using assms (*‹card I = w› ‹(0::nat) < (w::nat)› ‹?n ∈ 𝒦' ⟹ 2 ≤ ?n› ‹?B ∈# ℬ ⟹ K_GDD (?B × I) (f ?B) 𝒦' {{x} × I |x. x ∈ ?B}›*) by auto have "f B ≠ {#}" using kgdd.design_blocks_nempty (*‹f B ≠ {#}›*) by simp then show "∃i∈#ℬ. f i ≠ {#}" using ‹B ∈# ℬ› (*‹B ∈# ℬ›*) by auto qed qed lemma pair_construction_block_sizes: assumes "K_GDD (B × I) (f B) 𝒦' {{x} × I |x . x ∈ B }" assumes "B ∈# ℬ" assumes "b ∈# (f B)" shows "card b ∈ 𝒦'" proof (-) (*goal: ‹card b ∈ 𝒦'›*) interpret bkgdd: K_GDD "(B × I)" "(f B)" "𝒦'" "{{x} × I |x . x ∈ B }" using assms (*‹K_GDD (B × I) (f B) 𝒦' {{x} × I |x. x ∈ B}› ‹B ∈# ℬ› ‹b ∈# f B›*) by simp show "card b ∈ 𝒦'" using bkgdd.block_sizes (*‹?bl ∈# f B ⟹ card ?bl ∈ 𝒦'›*) by (simp add:assms (*‹K_GDD (B × I) (f B) 𝒦' {{x} × I |x. x ∈ B}› ‹B ∈# ℬ› ‹b ∈# f B›*)) qed lemma wilsons_construction_index_0: assumes "⋀ B . B ∈# ℬ ⟹ K_GDD (B × I) (f B) 𝒦' {{x} × I |x . x ∈ B }" assumes "G ∈ {GG × I |GG. GG ∈ 𝒢}" assumes "X ∈ G" assumes "Y ∈ G" assumes "X ≠ Y" shows "(∑⇩# (image_mset f ℬ)) index {X, Y} = 0" proof (-) (*goal: ‹∑⇩# (image_mset (f::'a set ⇒ ('a × 'b) set multiset) ℬ) index {X::'a × 'b, Y::'a × 'b} = (0::nat)›*) obtain G' where gi: "G = G' × I" and ging: "G' ∈ 𝒢" (*goal: ‹(⋀G'::'a::type set. ⟦(G::('a::type × 'b::type) set) = G' × (I::'b::type set); G' ∈ 𝒢⟧ ⟹ thesis::bool) ⟹ thesis›*) using assms (*‹?B ∈# ℬ ⟹ K_GDD (?B × I) (f ?B) 𝒦' {{x} × I |x. x ∈ ?B}› ‹G ∈ {GG × I |GG. GG ∈ 𝒢}› ‹X ∈ G› ‹Y ∈ G› ‹X ≠ Y›*) by auto obtain x and y and ix and iy where xpair: "X = (x, ix)" and ypair: "Y = (y, iy)" (*goal: ‹(⋀(x::'a) (ix::'b) (y::'a) iy::'b. ⟦(X::'a × 'b) = (x, ix); (Y::'a × 'b) = (y, iy)⟧ ⟹ thesis::bool) ⟹ thesis›*) using assms (*‹(?B::'a set) ∈# ℬ ⟹ K_GDD (?B × (I::'b set)) ((f::'a set ⇒ ('a × 'b) set multiset) ?B) (𝒦'::nat set) {{x} × I |x::'a. x ∈ ?B}› ‹(G::('a × 'b) set) ∈ {GG × (I::'b set) |GG::'a set. GG ∈ 𝒢}› ‹X ∈ G› ‹Y ∈ G› ‹X ≠ Y›*) by auto then have ixin: "ix ∈ I" and xing: "x ∈ G'" using assms (*‹?B ∈# ℬ ⟹ K_GDD (?B × I) (f ?B) 𝒦' {{x} × I |x. x ∈ ?B}› ‹G ∈ {GG × I |GG. GG ∈ 𝒢}› ‹(X::'a::type × 'b::type) ∈ (G::('a::type × 'b::type) set)› ‹Y ∈ G› ‹X ≠ Y›*) gi (*‹G = G' × I›*) apply - (*goals: 1. ‹⟦(X::'a × 'b) = (x::'a, ix::'b); (Y::'a × 'b) = (y::'a, iy::'b); ⋀B::'a set. B ∈# ℬ ⟹ K_GDD (B × (I::'b set)) ((f::'a set ⇒ ('a × 'b) set multiset) B) (𝒦'::nat set) {{x} × I |x::'a. x ∈ B}; (G::('a × 'b) set) ∈ {GG × I |GG::'a set. GG ∈ 𝒢}; X ∈ G; Y ∈ G; X ≠ Y; G = (G'::'a set) × I⟧ ⟹ ix ∈ I› 2. ‹⟦(X::'a × 'b) = (x::'a, ix::'b); (Y::'a × 'b) = (y::'a, iy::'b); ⋀B::'a set. B ∈# ℬ ⟹ K_GDD (B × (I::'b set)) ((f::'a set ⇒ ('a × 'b) set multiset) B) (𝒦'::nat set) {{x} × I |x::'a. x ∈ B}; (G::('a × 'b) set) ∈ {GG × I |GG::'a set. GG ∈ 𝒢}; X ∈ G; Y ∈ G; X ≠ Y; G = (G'::'a set) × I⟧ ⟹ x ∈ G'› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . have iyin: "iy ∈ I" and ying: "y ∈ G'" using assms (*‹?B ∈# ℬ ⟹ K_GDD (?B × I) (f ?B) 𝒦' {{x} × I |x. x ∈ ?B}› ‹G ∈ {GG × I |GG. GG ∈ 𝒢}› ‹(X::'a × 'b) ∈ (G::('a × 'b) set)› ‹(Y::'a::type × 'b::type) ∈ (G::('a::type × 'b::type) set)› ‹X ≠ Y›*) ypair (*‹(Y::'a × 'b) = (y::'a, iy::'b)›*) gi (*‹G = G' × I›*) apply - (*goals: 1. ‹⟦⋀B. B ∈# ℬ ⟹ K_GDD (B × I) (f B) 𝒦' {{x} × I |x. x ∈ B}; G ∈ {GG × I |GG. GG ∈ 𝒢}; X ∈ G; Y ∈ G; X ≠ Y; Y = (y, iy); G = G' × I⟧ ⟹ iy ∈ I› 2. ‹⟦⋀B. B ∈# ℬ ⟹ K_GDD (B × I) (f B) 𝒦' {{x} × I |x. x ∈ B}; G ∈ {GG × I |GG. GG ∈ 𝒢}; X ∈ G; Y ∈ G; X ≠ Y; Y = (y, iy); G = G' × I⟧ ⟹ y ∈ G'› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . have ne_index_0: "x ≠ y ⟹ ℬ index {x, y} = 0" using ying (*‹y ∈ G'›*) xing (*‹(x::'a::type) ∈ (G'::'a::type set)›*) index_together (*‹⟦?G ∈ 𝒢; ?x ∈ ?G; ?y ∈ ?G; ?x ≠ ?y⟧ ⟹ ℬ index {?x, ?y} = 0›*) ging (*‹G' ∈ 𝒢›*) by simp have "⋀ B. B ∈# ℬ ⟹ (f B) index {(x, ix), (y, iy)} = 0" proof (-) (*goal: ‹⋀B. B ∈# ℬ ⟹ f B index {(x, ix), (y, iy)} = 0›*) fix B assume assm: "B ∈# ℬ" (*‹(B::'a set) ∈# ℬ›*) then interpret kgdd: K_GDD "(B × I)" "(f B)" "𝒦'" "{{x} × I |x . x ∈ B }" using assms (*‹(?B::'a set) ∈# ℬ ⟹ K_GDD (?B × (I::'b set)) ((f::'a set ⇒ ('a × 'b) set multiset) ?B) (𝒦'::nat set) {{x} × I |x::'a. x ∈ ?B}› ‹G ∈ {GG × I |GG. GG ∈ 𝒢}› ‹X ∈ G› ‹Y ∈ G› ‹X ≠ Y›*) by simp have not_ss_0: "¬ ({(x, ix), (y, iy)} ⊆ (B × I)) ⟹ (f B) index {(x, ix), (y, iy)} = 0" by (metis kgdd.points_index_ps_nin (*‹¬ ?ps ⊆ B × I ⟹ f B index ?ps = 0›*)) have "x ≠ y ⟹ ¬ {x, y} ⊆ B" using ne_index_0 (*‹x ≠ y ⟹ ℬ index {x, y} = 0›*) assm (*‹B ∈# ℬ›*) points_index_0_left_imp (*‹⟦?B index ?ps = 0; ?b ∈# ?B⟧ ⟹ ¬ ?ps ⊆ ?b›*) by auto then have "x ≠ y ⟹ ¬ ({(x, ix), (y, iy)} ⊆ (B × I))" using assms (*‹(?B::'a set) ∈# ℬ ⟹ K_GDD (?B × (I::'b set)) ((f::'a set ⇒ ('a × 'b) set multiset) ?B) (𝒦'::nat set) {{x} × I |x::'a. x ∈ ?B}› ‹G ∈ {GG × I |GG. GG ∈ 𝒢}› ‹X ∈ G› ‹Y ∈ G› ‹X ≠ Y›*) by (meson empty_subsetI (*‹{} ⊆ ?A›*) insert_subset (*‹(insert ?x ?A ⊆ ?B) = (?x ∈ ?B ∧ ?A ⊆ ?B)›*) mem_Sigma_iff (*‹((?a, ?b) ∈ Sigma ?A ?B) = (?a ∈ ?A ∧ ?b ∈ ?B ?a)›*)) then have nexy: "x ≠ y ⟹ (f B) index {(x, ix), (y, iy)} = 0" using not_ss_0 (*‹¬ {(x, ix), (y, iy)} ⊆ B × I ⟹ f B index {(x, ix), (y, iy)} = 0›*) by simp have "x = y ⟹ ({(x, ix), (y, iy)} ⊆ (B × I)) ⟹ (f B) index {(x, ix), (y, iy)} = 0" proof (-) (*goal: ‹⟦(x::'a) = (y::'a); {(x, ix::'b), (y, iy::'b)} ⊆ (B::'a set) × (I::'b set)⟧ ⟹ (f::'a set ⇒ ('a × 'b) set multiset) B index {(x, ix), (y, iy)} = (0::nat)›*) assume eq: "x = y" (*‹(x::'a) = (y::'a)›*) assume "({(x, ix), (y, iy)} ⊆ (B × I))" (*‹{(x::'a, ix::'b), (y::'a, iy::'b)} ⊆ (B::'a set) × (I::'b set)›*) then obtain g where "g ∈ {{x} × I |x . x ∈ B }" and "(x, ix) ∈ g" and "(y, ix) ∈ g" (*goal: ‹(⋀g. ⟦g ∈ {{x} × I |x. x ∈ B}; (x, ix) ∈ g; (y, ix) ∈ g⟧ ⟹ thesis) ⟹ thesis›*) using eq (*‹x = y›*) by auto then show "?thesis" (*goal: ‹f B index {(x, ix), (y, iy)} = 0›*) using kgdd.index_together (*‹⟦?G ∈ {{x} × I |x. x ∈ B}; ?x ∈ ?G; ?y ∈ ?G; ?x ≠ ?y⟧ ⟹ f B index {?x, ?y} = 0›*) by (smt (verit, best) SigmaD1 (*‹(?a, ?b) ∈ Sigma ?A ?B ⟹ ?a ∈ ?A›*) SigmaD2 (*‹(?a, ?b) ∈ Sigma ?A ?B ⟹ ?b ∈ ?B ?a›*) SigmaI (*‹⟦?a ∈ ?A; ?b ∈ ?B ?a⟧ ⟹ (?a, ?b) ∈ Sigma ?A ?B›*) assms( (*‹Y ∈ G›*) 4) assms( (*‹X ≠ Y›*) 5) gi (*‹G = G' × I›*) mem_Collect_eq (*‹(?a ∈ Collect ?P) = ?P ?a›*) xpair (*‹X = (x, ix)›*) ypair (*‹Y = (y, iy)›*)) qed then show "(f B) index {(x, ix), (y, iy)} = 0" using not_ss_0 (*‹¬ {(x, ix), (y, iy)} ⊆ B × I ⟹ f B index {(x, ix), (y, iy)} = 0›*) nexy (*‹x ≠ y ⟹ f B index {(x, ix), (y, iy)} = 0›*) by auto qed then have "⋀ B. B ∈# (image_mset f ℬ) ⟹ B index {(x, ix), (y, iy)} = 0" by auto then show "(∑⇩# (image_mset f ℬ)) index {X, Y} = 0" by (simp add: points_index_sum (*‹∑⇩# (?B::?'a::type set multiset multiset) index (?ps::?'a::type set) = (∑b::?'a::type set multiset∈#?B. b index ?ps)›*) xpair (*‹(X::'a::type × 'b::type) = (x::'a::type, ix::'b::type)›*) ypair (*‹(Y::'a::type × 'b::type) = (y::'a::type, iy::'b::type)›*)) qed lemma wilsons_construction_index_1: assumes "⋀ B . B ∈# ℬ ⟹ K_GDD (B × I) (f B) 𝒦' {{x} × I |x . x ∈ B }" assumes "G1 ∈ {G × I |G. G ∈ 𝒢}" assumes "G2 ∈ {G × I |G. G ∈ 𝒢}" assumes "G1 ≠ G2" and "(x, ix) ∈ G1" and "(y, iy) ∈ G2" shows "(∑⇩# (image_mset f ℬ)) index {(x, ix), (y, iy)} = (1 ::int)" proof (-) (*goal: ‹int (∑⇩# (image_mset f ℬ) index {(x, ix), (y, iy)}) = 1›*) obtain G1' where gi1: "G1 = G1' × I" and ging1: "G1' ∈ 𝒢" (*goal: ‹(⋀G1'. ⟦G1 = G1' × I; G1' ∈ 𝒢⟧ ⟹ thesis) ⟹ thesis›*) using assms (*‹?B ∈# ℬ ⟹ K_GDD (?B × I) (f ?B) 𝒦' {{x} × I |x. x ∈ ?B}› ‹(G1::('a × 'b) set) ∈ {G × (I::'b set) |G::'a set. G ∈ 𝒢}› ‹G2 ∈ {G × I |G. G ∈ 𝒢}› ‹G1 ≠ G2› ‹(x, ix) ∈ G1› ‹(y, iy) ∈ G2›*) by auto obtain G2' where gi2: "G2 = G2' × I" and ging2: "G2' ∈ 𝒢" (*goal: ‹(⋀G2'. ⟦G2 = G2' × I; G2' ∈ 𝒢⟧ ⟹ thesis) ⟹ thesis›*) using assms (*‹(?B::'a set) ∈# ℬ ⟹ K_GDD (?B × (I::'b set)) ((f::'a set ⇒ ('a × 'b) set multiset) ?B) (𝒦'::nat set) {{x} × I |x::'a. x ∈ ?B}› ‹G1 ∈ {G × I |G. G ∈ 𝒢}› ‹G2 ∈ {G × I |G. G ∈ 𝒢}› ‹G1 ≠ G2› ‹(x::'a::type, ix::'b::type) ∈ (G1::('a::type × 'b::type) set)› ‹(y, iy) ∈ G2›*) by auto have xing: "x ∈ G1'" using assms (*‹?B ∈# ℬ ⟹ K_GDD (?B × I) (f ?B) 𝒦' {{x} × I |x. x ∈ ?B}› ‹G1 ∈ {G × I |G. G ∈ 𝒢}› ‹G2 ∈ {G × I |G. G ∈ 𝒢}› ‹G1 ≠ G2› ‹(x, ix) ∈ G1› ‹(y, iy) ∈ G2›*) gi1 (*‹G1 = G1' × I›*) by simp have ying: "y ∈ G2'" using assms (*‹?B ∈# ℬ ⟹ K_GDD (?B × I) (f ?B) 𝒦' {{x} × I |x. x ∈ ?B}› ‹G1 ∈ {G × I |G. G ∈ 𝒢}› ‹G2 ∈ {G × I |G. G ∈ 𝒢}› ‹G1 ≠ G2› ‹(x, ix) ∈ G1› ‹(y, iy) ∈ G2›*) gi2 (*‹(G2::('a × 'b) set) = (G2'::'a set) × (I::'b set)›*) by simp have gne: "G1' ≠ G2'" using assms (*‹(?B::'a::type set) ∈# ℬ ⟹ K_GDD (?B × (I::'b::type set)) ((f::'a::type set ⇒ ('a::type × 'b::type) set multiset) ?B) (𝒦'::nat set) {{x} × I |x::'a::type. x ∈ ?B}› ‹G1 ∈ {G × I |G. G ∈ 𝒢}› ‹G2 ∈ {G × I |G. G ∈ 𝒢}› ‹G1 ≠ G2› ‹(x, ix) ∈ G1› ‹(y, iy) ∈ G2›*) gi1 (*‹G1 = G1' × I›*) gi2 (*‹(G2::('a × 'b) set) = (G2'::'a set) × (I::'b set)›*) by auto then have xyne: "x ≠ y" using xing (*‹x ∈ G1'›*) ying (*‹y ∈ G2'›*) ging1 (*‹(G1'::'a set) ∈ 𝒢›*) ging2 (*‹G2' ∈ 𝒢›*) point_in_one_group (*‹⟦?x ∈ ?G1.0; ?G1.0 ∈ 𝒢; ?G2.0 ∈ 𝒢; ?G1.0 ≠ ?G2.0⟧ ⟹ ?x ∉ ?G2.0›*) by blast have "∃! bl . bl ∈# ℬ ∧ {x, y} ⊆ bl" using index_distinct (*‹⟦?G1.0 ∈ 𝒢; ?G2.0 ∈ 𝒢; ?G1.0 ≠ ?G2.0; ?x ∈ ?G1.0; ?y ∈ ?G2.0⟧ ⟹ int (ℬ index {?x, ?y}) = 1›*) points_index_one_unique_block (*‹?B index ?ps = 1 ⟹ ∃!bl. bl ∈# ?B ∧ ?ps ⊆ bl›*) by (metis ging1 (*‹G1' ∈ 𝒢›*) ging2 (*‹G2' ∈ 𝒢›*) gne (*‹G1' ≠ G2'›*) of_nat_1_eq_iff (*‹(1 = of_nat ?n) = (?n = 1)›*) xing (*‹x ∈ G1'›*) ying (*‹y ∈ G2'›*)) then obtain bl where blinb: "bl ∈# ℬ" and xyblss: "{x, y} ⊆ bl" (*goal: ‹(⋀bl. ⟦bl ∈# ℬ; {x, y} ⊆ bl⟧ ⟹ thesis) ⟹ thesis›*) by auto then have "⋀ b . b ∈# ℬ - {#bl#} ⟹ ¬ {x, y} ⊆ b" using points_index_one_not_unique_block (*‹⟦?B index ?ps = 1; ?ps ⊆ ?bl; ?bl ∈# ?B; ?bl' ∈# remove1_mset ?bl ?B⟧ ⟹ ¬ ?ps ⊆ ?bl'›*) by (metis ging1 (*‹G1' ∈ 𝒢›*) ging2 (*‹G2' ∈ 𝒢›*) gne (*‹G1' ≠ G2'›*) index_distinct (*‹⟦?G1.0 ∈ 𝒢; ?G2.0 ∈ 𝒢; ?G1.0 ≠ ?G2.0; ?x ∈ ?G1.0; ?y ∈ ?G2.0⟧ ⟹ int (ℬ index {?x, ?y}) = 1›*) int_ops( (*‹int 1 = 1›*) 2) nat_int_comparison( (*‹(?a = ?b) = (int ?a = int ?b)›*) 1) xing (*‹x ∈ G1'›*) ying (*‹y ∈ G2'›*)) then have not_ss: "⋀ b . b ∈# ℬ - {#bl#} ⟹ ¬ ({(x, ix), (y, iy)} ⊆ (b × I))" using assms (*‹?B ∈# ℬ ⟹ K_GDD (?B × I) (f ?B) 𝒦' {{x} × I |x. x ∈ ?B}› ‹(G1::('a::type × 'b::type) set) ∈ {G × (I::'b::type set) |G::'a::type set. G ∈ 𝒢}› ‹G2 ∈ {G × I |G. G ∈ 𝒢}› ‹G1 ≠ G2› ‹(x, ix) ∈ G1› ‹(y, iy) ∈ G2›*) by (meson SigmaD1 (*‹(?a::?'a, ?b::?'b) ∈ Sigma (?A::?'a set) (?B::?'a ⇒ ?'b set) ⟹ ?a ∈ ?A›*) empty_subsetI (*‹{} ⊆ (?A::?'a set)›*) insert_subset (*‹(insert (?x::?'a) (?A::?'a set) ⊆ (?B::?'a set)) = (?x ∈ ?B ∧ ?A ⊆ ?B)›*)) then have pi0: "⋀ b . b ∈# ℬ - {#bl#} ⟹ (f b) index {(x, ix), (y, iy)} = 0" proof (-) (*goal: ‹⋀b. ⟦b ∈# remove1_mset bl ℬ; ⋀b. b ∈# remove1_mset bl ℬ ⟹ ¬ {(x, ix), (y, iy)} ⊆ b × I⟧ ⟹ f b index {(x, ix), (y, iy)} = 0›*) fix b assume assm: "b ∈# ℬ - {#bl#}" (*‹(b::'a set) ∈# remove1_mset (bl::'a set) ℬ›*) then have "b ∈# ℬ" by (meson in_diffD (*‹?a ∈# ?M - ?N ⟹ ?a ∈# ?M›*)) then interpret kgdd: K_GDD "(b × I)" "(f b)" "𝒦'" "{{x} × I |x . x ∈ b }" using assms (*‹?B ∈# ℬ ⟹ K_GDD (?B × I) (f ?B) 𝒦' {{x} × I |x. x ∈ ?B}› ‹(G1::('a × 'b) set) ∈ {G × (I::'b set) |G::'a set. G ∈ 𝒢}› ‹G2 ∈ {G × I |G. G ∈ 𝒢}› ‹G1 ≠ G2› ‹(x::'a, ix::'b) ∈ (G1::('a × 'b) set)› ‹(y, iy) ∈ G2›*) by simp show "(f b) index {(x, ix), (y, iy)} = 0" using assm (*‹b ∈# remove1_mset bl ℬ›*) not_ss (*‹?b ∈# remove1_mset bl ℬ ⟹ ¬ {(x, ix), (y, iy)} ⊆ ?b × I›*) by (metis kgdd.points_index_ps_nin (*‹¬ (?ps::('a × 'b) set) ⊆ (b::'a set) × (I::'b set) ⟹ (f::'a set ⇒ ('a × 'b) set multiset) b index ?ps = (0::nat)›*)) qed let ?G = "{{x} × I |x . x ∈ bl }" interpret bkgdd: K_GDD "(bl × I)" "(f bl)" "𝒦'" "?G" using assms (*‹?B ∈# ℬ ⟹ K_GDD (?B × I) (f ?B) 𝒦' {{x} × I |x. x ∈ ?B}› ‹G1 ∈ {G × I |G. G ∈ 𝒢}› ‹(G2::('a × 'b) set) ∈ {G × (I::'b set) |G::'a set. G ∈ 𝒢}› ‹G1 ≠ G2› ‹(x, ix) ∈ G1› ‹(y, iy) ∈ G2›*) blinb (*‹bl ∈# ℬ›*) by simp obtain g1 and g2 where xing1: "(x, ix) ∈ g1" and ying2: "(y, iy) ∈ g2" and g1g: "g1 ∈ ?G" and g2g: "g2 ∈ ?G" (*goal: ‹(⋀(g1::('a::type × 'b::type) set) g2::('a::type × 'b::type) set. ⟦(x::'a::type, ix::'b::type) ∈ g1; (y::'a::type, iy::'b::type) ∈ g2; g1 ∈ {{x} × (I::'b::type set) |x::'a::type. x ∈ (bl::'a::type set)}; g2 ∈ {{x} × I |x::'a::type. x ∈ bl}⟧ ⟹ thesis::bool) ⟹ thesis›*) using assms(5) (*‹(x, ix) ∈ G1›*) assms(6) (*‹(y, iy) ∈ G2›*) gi1 (*‹G1 = G1' × I›*) gi2 (*‹G2 = G2' × I›*) by (metis (no_types, lifting) bkgdd.point_has_unique_group (*‹?x ∈ bl × I ⟹ ∃!G. ?x ∈ G ∧ G ∈ {{x} × I |x. x ∈ bl}›*) insert_subset (*‹(insert ?x ?A ⊆ ?B) = (?x ∈ ?B ∧ ?A ⊆ ?B)›*) mem_Sigma_iff (*‹((?a, ?b) ∈ Sigma ?A ?B) = (?a ∈ ?A ∧ ?b ∈ ?B ?a)›*) xyblss (*‹{x, y} ⊆ bl›*)) then have "g1 ≠ g2" using xyne (*‹x ≠ y›*) by blast then have pi1: "(f bl) index {(x, ix), (y, iy)} = 1" using bkgdd.index_distinct (*‹⟦?G1.0 ∈ {{x} × I |x. x ∈ bl}; ?G2.0 ∈ {{x} × I |x. x ∈ bl}; ?G1.0 ≠ ?G2.0; ?x ∈ ?G1.0; ?y ∈ ?G2.0⟧ ⟹ int (f bl index {?x, ?y}) = 1›*) xing1 (*‹(x, ix) ∈ g1›*) ying2 (*‹(y, iy) ∈ g2›*) g1g (*‹g1 ∈ {{x} × I |x. x ∈ bl}›*) g2g (*‹(g2::('a × 'b) set) ∈ {{x} × (I::'b set) |x::'a. x ∈ (bl::'a set)}›*) by simp have "(∑⇩# (image_mset f ℬ)) index {(x, ix), (y, iy)} = (∑B ∈# ℬ. (f B) index {(x, ix), (y, iy)} )" by (simp add: points_index_sum (*‹∑⇩# ?B index ?ps = (∑b∈#?B. b index ?ps)›*)) then have "(∑⇩# (image_mset f ℬ)) index {(x, ix), (y, iy)} = (∑B ∈# (ℬ - {#bl#}). (f B) index {(x, ix), (y, iy)}) + (f bl) index {(x, ix), (y, iy)}" by (metis (no_types, lifting) add.commute (*‹?a + ?b = ?b + ?a›*) blinb (*‹bl ∈# ℬ›*) insert_DiffM (*‹?x ∈# ?M ⟹ add_mset ?x (remove1_mset ?x ?M) = ?M›*) sum_mset.insert (*‹∑⇩# (image_mset ?g (add_mset ?x ?A)) = ?g ?x + ∑⇩# (image_mset ?g ?A)›*)) thus "?thesis" (*goal: ‹int (∑⇩# (image_mset f ℬ) index {(x, ix), (y, iy)}) = 1›*) using pi0 (*‹?b ∈# remove1_mset bl ℬ ⟹ f ?b index {(x, ix), (y, iy)} = 0›*) pi1 (*‹f bl index {(x, ix), (y, iy)} = 1›*) by simp qed theorem Wilsons_Construction: assumes "card I = w" assumes "w > 0" assumes "⋀ n. n ∈ 𝒦' ⟹ n ≥ 2" assumes "⋀ B . B ∈# ℬ ⟹ K_GDD (B × I) (f B) 𝒦' {{x} × I |x . x ∈ B }" shows "K_GDD (𝒱 × I) (∑B ∈# ℬ. (f B)) 𝒦' {G × I | G . G ∈ 𝒢}" proof (-) (*goal: ‹K_GDD (𝒱 × I) (∑⇩# (image_mset f ℬ)) 𝒦' {G × I |G. G ∈ 𝒢}›*) let ?Y = "𝒱 × I" and ?H = "{G × I | G . G ∈ 𝒢}" and ?B = "∑B ∈# ℬ. (f B)" interpret pd: proper_design "?Y" "?B" using wilsons_construction_proper (*‹⟦card ?I = ?w; 0 < ?w; ⋀n. n ∈ ?𝒦' ⟹ 2 ≤ n; ⋀B. B ∈# ℬ ⟹ K_GDD (B × ?I) (?f B) ?𝒦' {{x} × ?I |x. x ∈ B}⟧ ⟹ proper_design (𝒱 × ?I) (∑⇩# (image_mset ?f ℬ))›*) assms (*‹card I = w› ‹(0::nat) < (w::nat)› ‹?n ∈ 𝒦' ⟹ 2 ≤ ?n› ‹?B ∈# ℬ ⟹ K_GDD (?B × I) (f ?B) 𝒦' {{x} × I |x. x ∈ ?B}›*) by auto have "⋀ bl . bl ∈# (∑B ∈# ℬ. (f B)) ⟹ card bl ∈ 𝒦'" using assms (*‹card I = w› ‹0 < w› ‹?n ∈ 𝒦' ⟹ 2 ≤ ?n› ‹?B ∈# ℬ ⟹ K_GDD (?B × I) (f ?B) 𝒦' {{x} × I |x. x ∈ ?B}›*) pair_construction_block_sizes (*‹⟦K_GDD (?B × ?I) (?f ?B) ?𝒦' {{x} × ?I |x. x ∈ ?B}; ?B ∈# ℬ; ?b ∈# ?f ?B⟧ ⟹ card ?b ∈ ?𝒦'›*) by blast then interpret kdes: K_block_design "?Y" "?B" "𝒦'" using assms(3) (*‹?n ∈ 𝒦' ⟹ 2 ≤ ?n›*) apply unfold_locales (*goals: 1. ‹⋀bl. ⟦⋀bl. bl ∈# ∑⇩# (image_mset f ℬ) ⟹ card bl ∈ 𝒦'; ⋀n. n ∈ 𝒦' ⟹ 2 ≤ n; bl ∈# ∑⇩# (image_mset f ℬ)⟧ ⟹ card bl ∈ 𝒦'› 2. ‹⋀x. ⟦⋀bl. bl ∈# ∑⇩# (image_mset f ℬ) ⟹ card bl ∈ 𝒦'; ⋀n. n ∈ 𝒦' ⟹ 2 ≤ n; x ∈ 𝒦'⟧ ⟹ 0 < x› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*goal: ‹⋀x. ⟦⋀bl. bl ∈# ∑⇩# (image_mset f ℬ) ⟹ card bl ∈ 𝒦'; ⋀n. n ∈ 𝒦' ⟹ 2 ≤ n; x ∈ 𝒦'⟧ ⟹ 0 < x›*) apply fastforce (*proven 2 subgoals*) . interpret gdd: GDD "?Y" "?B" "?H" "1:: int" proof (unfold_locales) (*goals: 1. ‹partition_on (𝒱 × I) {G × I |G. G ∈ 𝒢}› 2. ‹1 < card {G × I |G. G ∈ 𝒢}› 3. ‹1 ≤ 1› 4. ‹⋀G x y. ⟦G ∈ {G × I |G. G ∈ 𝒢}; x ∈ G; y ∈ G; x ≠ y⟧ ⟹ ∑⇩# (image_mset f ℬ) index {x, y} = 0› 5. ‹⋀G1 G2 x y. ⟦G1 ∈ {G × I |G. G ∈ 𝒢}; G2 ∈ {G × I |G. G ∈ 𝒢}; G1 ≠ G2; x ∈ G1; y ∈ G2⟧ ⟹ int (∑⇩# (image_mset f ℬ) index {x, y}) = 1›*) show "partition_on (𝒱 × I) {G × I |G. G ∈ 𝒢}" using assms (*‹card I = w› ‹0 < w› ‹?n ∈ 𝒦' ⟹ 2 ≤ ?n› ‹?B ∈# ℬ ⟹ K_GDD (?B × I) (f ?B) 𝒦' {{x} × I |x. x ∈ ?B}›*) groups_not_empty (*‹𝒢 ≠ {}›*) design_points_nempty (*‹𝒱 ≠ {}›*) group_partitions (*‹partition_on 𝒱 𝒢›*) by (simp add: partition_on_cart_prod (*‹⟦0 < card ?I; ?A ≠ {}; ?G ≠ {}; partition_on ?A ?G⟧ ⟹ partition_on (?A × ?I) {g × ?I |g. g ∈ ?G}›*)) have "inj_on (λ G. G × I) 𝒢" using inj_on_def (*‹inj_on ?f ?A = (∀x∈?A. ∀y∈?A. ?f x = ?f y ⟶ x = y)›*) pd.design_points_nempty (*‹𝒱 × I ≠ {}›*) by auto then have "card {G × I |G. G ∈ 𝒢} = card 𝒢" using card_image (*‹inj_on ?f ?A ⟹ card (?f ` ?A) = card ?A›*) by (simp add: Setcompr_eq_image (*‹{?f x |x. x ∈ ?A} = ?f ` ?A›*)) then show "1 < card {G × I |G. G ∈ 𝒢}" using groups_size (*‹(1::nat) < card 𝒢›*) by linarith show "(1::int) ≤ 1" by simp have gdd_fact: "⋀ B . B ∈# ℬ ⟹ K_GDD (B × I) (f B) 𝒦' {{x} × I |x . x ∈ B }" using assms (*‹card I = w› ‹0 < w› ‹(?n::nat) ∈ (𝒦'::nat set) ⟹ (2::nat) ≤ ?n› ‹?B ∈# ℬ ⟹ K_GDD (?B × I) (f ?B) 𝒦' {{x} × I |x. x ∈ ?B}›*) by simp show "⋀G X Y. G ∈ {GG × I |GG. GG ∈ 𝒢} ⟹ X ∈ G ⟹ Y ∈ G ⟹ X ≠ Y ⟹ (∑⇩# (image_mset f ℬ)) index {X, Y} = 0" using wilsons_construction_index_0[OF assms ( 4 )] (*‹⟦⋀B. B ∈# ℬ ⟹ B ∈# ℬ; ?G ∈ {GG × I |GG. GG ∈ 𝒢}; ?X ∈ ?G; ?Y ∈ ?G; ?X ≠ ?Y⟧ ⟹ ∑⇩# (image_mset f ℬ) index {?X, ?Y} = 0›*) by auto show "⋀G1 G2 X Y. G1 ∈ {G × I |G. G ∈ 𝒢} ⟹ G2 ∈ {G × I |G. G ∈ 𝒢} ⟹ G1 ≠ G2 ⟹ X ∈ G1 ⟹ Y ∈ G2 ⟹ ((∑⇩# (image_mset f ℬ)) index {X, Y}) = (1 ::int)" using wilsons_construction_index_1[OF assms ( 4 )] (*‹⟦⋀B. B ∈# ℬ ⟹ B ∈# ℬ; ?G1.0 ∈ {G × I |G. G ∈ 𝒢}; ?G2.0 ∈ {G × I |G. G ∈ 𝒢}; ?G1.0 ≠ ?G2.0; (?x, ?ix) ∈ ?G1.0; (?y, ?iy) ∈ ?G2.0⟧ ⟹ int (∑⇩# (image_mset f ℬ) index {(?x, ?ix), (?y, ?iy)}) = 1›*) by blast qed show "?thesis" (*goal: ‹K_GDD (𝒱 × (I::'b set)) (∑⇩# (image_mset (f::'a set ⇒ ('a × 'b) set multiset) ℬ)) (𝒦'::nat set) {G × I |G::'a set. G ∈ 𝒢}›*) by unfold_locales qed end context pairwise_balance begin lemma PBD_by_deleting_point: assumes "𝗏 > 2" assumes "⋀ bl . bl ∈# ℬ ⟹ card bl ≥ 2" shows "pairwise_balance (del_point x) (del_point_blocks x) Λ" proof (cases "x ∈ 𝒱") (*goals: 1. ‹x ∈ 𝒱 ⟹ pairwise_balance (del_point x) (del_point_blocks x) Λ› 2. ‹x ∉ 𝒱 ⟹ pairwise_balance (del_point x) (del_point_blocks x) Λ›*) case True (*‹x ∈ 𝒱›*) interpret des: design "del_point x" "del_point_blocks x" using delete_point_design (*‹(⋀bl. ⟦bl ∈# ℬ; ?p ∈ bl⟧ ⟹ 2 ≤ card bl) ⟹ design (del_point ?p) (del_point_blocks ?p)›*) assms (*‹2 < 𝗏› ‹?bl ∈# ℬ ⟹ 2 ≤ card ?bl›*) by blast show "?thesis" (*goal: ‹pairwise_balance (del_point x) (del_point_blocks x) Λ›*) using assms (*‹(2::nat) < 𝗏› ‹?bl ∈# ℬ ⟹ 2 ≤ card ?bl›*) design_blocks_nempty (*‹ℬ ≠ {#}›*) del_point_def (*‹del_point ?p ≡ 𝒱 - {?p}›*) del_point_blocks_def (*‹del_point_blocks ?p ≡ {#bl - {?p}. bl ∈# ℬ#}›*) proof (unfold_locales, simp_all) (*goals: 1. ‹⟦⋀p. 𝒱 - {p} ≡ 𝒱 - {p}; ⋀p. {#bl - {p}. bl ∈# ℬ#} ≡ {#bl - {p}. bl ∈# ℬ#}; 2 < 𝗏; ⋀bl. bl ∈# ℬ ⟹ 2 ≤ card bl; ℬ ≠ {#}; ⋀p. del_point p ≡ 𝒱 - {p}; ⋀p. del_point_blocks p ≡ {#bl - {p}. bl ∈# ℬ#}⟧ ⟹ 2 ≤ card (𝒱 - {x})› 2. ‹⋀ps. ⟦⋀p. 𝒱 - {p} ≡ 𝒱 - {p}; ⋀p. {#bl - {p}. bl ∈# ℬ#} ≡ {#bl - {p}. bl ∈# ℬ#}; ps ⊆ 𝒱 - {x}; card ps = 2; 2 < 𝗏; ⋀bl. bl ∈# ℬ ⟹ 2 ≤ card bl; ℬ ≠ {#}; ⋀p. del_point p ≡ 𝒱 - {p}; ⋀p. del_point_blocks p ≡ {#bl - {p}. bl ∈# ℬ#}⟧ ⟹ {#bl - {x}. bl ∈# ℬ#} index ps = Λ›*) show "2 < 𝗏 ⟹ (⋀bl. bl ∈# ℬ ⟹ 2 ≤ card bl) ⟹ 2 ≤ (card (𝒱 - {x}))" using card_Diff_singleton_if (*‹card (?A - {?x}) = (if ?x ∈ ?A then card ?A - 1 else card ?A)›*) diff_diff_cancel (*‹(?i::nat) ≤ (?n::nat) ⟹ ?n - (?n - ?i) = ?i›*) diff_le_mono2 (*‹?m ≤ ?n ⟹ ?l - ?n ≤ ?l - ?m›*) finite_sets (*‹finite 𝒱›*) less_one (*‹((?n::nat) < (1::nat)) = (?n = (0::nat))›*) by (metis diff_is_0_eq (*‹(?m - ?n = 0) = (?m ≤ ?n)›*) neq0_conv (*‹(?n ≠ 0) = (0 < ?n)›*) t_lt_order (*‹2 ≤ 𝗏›*) zero_less_diff (*‹(0 < ?n - ?m) = (?m < ?n)›*)) have "⋀ ps . ps ⊆ 𝒱 - {x} ⟹ ps ⊆ 𝒱" by auto then show "⋀ps. ps ⊆ 𝒱 - {x} ⟹ card ps = 2 ⟹ {#bl - {x}. bl ∈# ℬ#} index ps = Λ" using delete_point_index_eq (*‹(?ps::'a::type set) ⊆ del_point (?p::'a::type) ⟹ del_point_blocks ?p index ?ps = ℬ index ?ps›*) del_point_def (*‹del_point ?p ≡ 𝒱 - {?p}›*) del_point_blocks_def (*‹del_point_blocks ?p ≡ {#bl - {?p}. bl ∈# ℬ#}›*) by simp qed next (*goal: ‹x ∉ 𝒱 ⟹ pairwise_balance (del_point x) (del_point_blocks x) Λ›*) case False (*‹(x::'a) ∉ 𝒱›*) then show "?thesis" (*goal: ‹pairwise_balance (del_point x) (del_point_blocks x) Λ›*) by (simp add: del_invalid_point (*‹?p ∉ 𝒱 ⟹ del_point ?p = 𝒱›*) del_invalid_point_blocks (*‹?p ∉ 𝒱 ⟹ del_point_blocks ?p = ℬ›*) pairwise_balance_axioms (*‹pairwise_balance 𝒱 ℬ Λ›*)) qed end context k_GDD begin lemma bibd_from_kGDD: assumes "𝗄 > 1" assumes "⋀ g. g ∈ 𝒢 ⟹ card g = 𝗄 - 1" assumes " x ∉ 𝒱" shows "bibd (add_point x) (ℬ + mset_set { insert x g | g. g ∈ 𝒢}) (𝗄) 1" proof (-) (*goal: ‹bibd (add_point x) (ℬ + mset_set {insert x g |g. g ∈ 𝒢}) 𝗄 1›*) have "⋀ k . k∈ {𝗄} ⟹ k = 𝗄" by blast then have kge: "⋀ k . k∈ {𝗄} ⟹ k ≥ 2" using assms(1) (*‹1 < 𝗄›*) by simp have "⋀ g . g ∈ 𝒢 ⟹ card g + 1 = 𝗄" using assms (*‹1 < 𝗄› ‹?g ∈ 𝒢 ⟹ card ?g = 𝗄 - 1› ‹x ∉ 𝒱›*) k_non_zero (*‹(1::nat) ≤ 𝗄›*) by auto then have s: "({𝗄} ∪ {(card g) + 1 | g . g ∈ 𝒢}) = {𝗄}" by auto then interpret pbd: PBD "(add_point x)" "ℬ + mset_set { insert x g | g. g ∈ 𝒢}" "{𝗄}" using PBD_by_adjoining_point[of "x"] (*‹⟦(x::'a::type) ∉ 𝒱; ⋀k::nat. k ∈ {𝗄} ⟹ (2::nat) ≤ k⟧ ⟹ PBD (add_point x) (ℬ + mset_set {insert x g |g::'a::type set. g ∈ 𝒢}) ({𝗄} ∪ {card g + (1::nat) |g::'a::type set. g ∈ 𝒢})›*) kge (*‹?k ∈ {𝗄} ⟹ 2 ≤ ?k›*) assms (*‹1 < 𝗄› ‹?g ∈ 𝒢 ⟹ card ?g = 𝗄 - 1› ‹x ∉ 𝒱›*) by (smt (z3) Collect_cong (*‹(⋀x. ?P x = ?Q x) ⟹ {x. ?P x} = {x. ?Q x}›*)) show "?thesis" (*goal: ‹bibd (add_point x) (ℬ + mset_set {insert x g |g. g ∈ 𝒢}) 𝗄 1›*) using assms (*‹1 < 𝗄› ‹?g ∈ 𝒢 ⟹ card ?g = 𝗄 - 1› ‹x ∉ 𝒱›*) pbd.block_sizes (*‹?bl ∈# ℬ + mset_set {insert x g |g. g ∈ 𝒢} ⟹ card ?bl ∈ {𝗄}›*) block_size_lt_v (*‹𝗄 ≤ 𝗏›*) finite_sets (*‹finite 𝒱›*) add_point_def (*‹add_point ?p ≡ insert ?p 𝒱›*) apply unfold_locales (*goals: 1. ‹⋀bl::'a set. ⟦(1::nat) < 𝗄; ⋀g::'a set. g ∈ 𝒢 ⟹ card g = 𝗄 - (1::nat); (x::'a) ∉ 𝒱; ⋀bl::'a set. bl ∈# ℬ + mset_set {insert x g |g::'a set. g ∈ 𝒢} ⟹ card bl ∈ {𝗄}; 𝗄 ≤ 𝗏; finite 𝒱; ⋀p::'a. add_point p ≡ insert p 𝒱; bl ∈# ℬ + mset_set {insert x g |g::'a set. g ∈ 𝒢}⟧ ⟹ card bl = 𝗄› 2. ‹⟦(1::nat) < 𝗄; ⋀g::'a set. g ∈ 𝒢 ⟹ card g = 𝗄 - (1::nat); (x::'a) ∉ 𝒱; ⋀bl::'a set. bl ∈# ℬ + mset_set {insert x g |g::'a set. g ∈ 𝒢} ⟹ card bl ∈ {𝗄}; 𝗄 ≤ 𝗏; finite 𝒱; ⋀p::'a. add_point p ≡ insert p 𝒱⟧ ⟹ 𝗄 < pbd.𝗏› 3. ‹⟦(1::nat) < 𝗄; ⋀g::'a set. g ∈ 𝒢 ⟹ card g = 𝗄 - (1::nat); (x::'a) ∉ 𝒱; ⋀bl::'a set. bl ∈# ℬ + mset_set {insert x g |g::'a set. g ∈ 𝒢} ⟹ card bl ∈ {𝗄}; 𝗄 ≤ 𝗏; finite 𝒱; ⋀p::'a. add_point p ≡ insert p 𝒱⟧ ⟹ (2::nat) ≤ 𝗄› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*discuss goal 3*) apply simp (*proven 3 subgoals*) . qed end context PBD begin lemma pbd_points_index1: "ps ⊆ 𝒱 ⟹ card ps = 2 ⟹ ℬ index ps = 1" using balanced (*‹⟦?ps ⊆ 𝒱; card ?ps = 2⟧ ⟹ ℬ index ?ps = 1›*) by simp lemma pbd_index1_points_imply_unique_block: assumes "b1 ∈# ℬ" and "b2 ∈# ℬ" and "b1 ≠ b2" assumes "x ≠ y" and "{x, y} ⊆ b1" and "x ∈ b2" shows "y ∉ b2" proof (rule ccontr (*‹(¬ ?P ⟹ False) ⟹ ?P›*)) (*goal: ‹¬ (y::'a::type) ∉ (b2::'a::type set) ⟹ False›*) let ?ps = "{# b ∈# ℬ . {x, y} ⊆ b#}" assume "¬ y ∉ b2" (*‹¬ (y::'a) ∉ (b2::'a set)›*) then have a: "y ∈ b2" by linarith then have "{x, y} ⊆ b2" by (simp add: assms( (*‹x ∈ b2›*) 6)) then have "b1 ∈# ?ps" and "b2 ∈# ?ps" using assms (*‹b1 ∈# ℬ› ‹b2 ∈# ℬ› ‹b1 ≠ b2› ‹x ≠ y› ‹{x, y} ⊆ b1› ‹x ∈ b2›*) apply - (*goals: 1. ‹⟦{x, y} ⊆ b2; b1 ∈# ℬ; b2 ∈# ℬ; b1 ≠ b2; x ≠ y; {x, y} ⊆ b1; x ∈ b2⟧ ⟹ b1 ∈# filter_mset ((⊆) {x, y}) ℬ› 2. ‹⟦{x, y} ⊆ b2; b1 ∈# ℬ; b2 ∈# ℬ; b1 ≠ b2; x ≠ y; {x, y} ⊆ b1; x ∈ b2⟧ ⟹ b2 ∈# filter_mset ((⊆) {x, y}) ℬ› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . then have ss: "{#b1, b2#} ⊆# ?ps" using assms (*‹b1 ∈# ℬ› ‹b2 ∈# ℬ› ‹b1 ≠ b2› ‹x ≠ y› ‹{x, y} ⊆ b1› ‹x ∈ b2›*) by (metis insert_noteq_member (*‹⟦add_mset ?b ?B = add_mset ?c ?C; ?b ≠ ?c⟧ ⟹ ?c ∈# ?B›*) mset_add (*‹⟦?a ∈# ?A; ⋀B. ?A = add_mset ?a B ⟹ ?thesis⟧ ⟹ ?thesis›*) mset_subset_eq_add_mset_cancel (*‹(add_mset ?a ?A ⊆# add_mset ?a ?B) = (?A ⊆# ?B)›*) single_subset_iff (*‹({#?a#} ⊆# ?M) = (?a ∈# ?M)›*)) have "size {#b1, b2#} = 2" using assms (*‹b1 ∈# ℬ› ‹b2 ∈# ℬ› ‹b1 ≠ b2› ‹(x::'a) ≠ (y::'a)› ‹{x, y} ⊆ b1› ‹x ∈ b2›*) by auto then have ge2: "size ?ps ≥ 2" using assms (*‹b1 ∈# ℬ› ‹b2 ∈# ℬ› ‹b1 ≠ b2› ‹x ≠ y› ‹{x, y} ⊆ b1› ‹(x::'a) ∈ (b2::'a set)›*) ss (*‹{#b1, b2#} ⊆# filter_mset ((⊆) {x, y}) ℬ›*) by (metis size_mset_mono (*‹?A ⊆# ?B ⟹ size ?A ≤ size ?B›*)) have pair: "card {x, y} = 2" using assms (*‹b1 ∈# ℬ› ‹b2 ∈# ℬ› ‹b1 ≠ b2› ‹x ≠ y› ‹{x, y} ⊆ b1› ‹x ∈ b2›*) by auto have "{x, y} ⊆ 𝒱" using assms (*‹b1 ∈# ℬ› ‹b2 ∈# ℬ› ‹b1 ≠ b2› ‹x ≠ y› ‹{x::'a::type, y::'a::type} ⊆ (b1::'a::type set)› ‹(x::'a) ∈ (b2::'a set)›*) wellformed (*‹?b ∈# ℬ ⟹ ?b ⊆ 𝒱›*) by auto then have "ℬ index {x, y} = 1" using pbd_points_index1 (*‹⟦?ps ⊆ 𝒱; card ?ps = 2⟧ ⟹ ℬ index ?ps = 1›*) pair (*‹card {x, y} = 2›*) by simp then show False using points_index_def (*‹?B index ?ps ≡ size (filter_mset ((⊆) ?ps) ?B)›*) ge2 (*‹(2::nat) ≤ size (filter_mset ((⊆) {x::'a, y::'a}) ℬ)›*) by (metis numeral_le_one_iff (*‹(numeral ?n ≤ 1) = (?n ≤ num.One)›*) semiring_norm( (*‹(num.Bit0 ?m ≤ num.One) = False›*) 69)) qed lemma strong_delete_point_groups_index_zero: assumes "G ∈ {b - {x} |b. b ∈# ℬ ∧ x ∈ b}" assumes "xa ∈ G" and "y ∈ G" and "xa ≠ y" shows "(str_del_point_blocks x) index {xa, y} = 0" proof (auto simp add: points_index_0_iff (*‹(?B index ?ps = 0) = (∀b. b ∈# ?B ⟶ ¬ ?ps ⊆ b)›*) str_del_point_blocks_def (*‹str_del_point_blocks ?p ≡ filter_mset ((∉) ?p) ℬ›*)) (*goal: ‹⋀b. ⟦b ∈# ℬ; x ∉ b; xa ∈ b; y ∈ b⟧ ⟹ False›*) fix b assume a1: "b ∈# ℬ" and a2: "x ∉ b" and a3: "xa ∈ b" and a4: "y ∈ b" (*‹(b::'a set) ∈# ℬ› ‹(x::'a) ∉ (b::'a set)› ‹(xa::'a) ∈ (b::'a set)› ‹(y::'a) ∈ (b::'a set)›*) obtain b' where "G = b' - {x}" and "b' ∈# ℬ" and "x ∈ b'" (*goal: ‹(⋀b'. ⟦G = b' - {x}; b' ∈# ℬ; x ∈ b'⟧ ⟹ thesis) ⟹ thesis›*) using assms (*‹G ∈ {b - {x} |b. b ∈# ℬ ∧ x ∈ b}› ‹(xa::'a) ∈ (G::'a set)› ‹y ∈ G› ‹xa ≠ y›*) by blast then show False using a1 (*‹(b::'a set) ∈# ℬ›*) a2 (*‹x ∉ b›*) a3 (*‹xa ∈ b›*) a4 (*‹y ∈ b›*) assms (*‹G ∈ {b - {x} |b. b ∈# ℬ ∧ x ∈ b}› ‹xa ∈ G› ‹y ∈ G› ‹xa ≠ y›*) pbd_index1_points_imply_unique_block (*‹⟦?b1.0 ∈# ℬ; ?b2.0 ∈# ℬ; ?b1.0 ≠ ?b2.0; ?x ≠ ?y; {?x, ?y} ⊆ ?b1.0; ?x ∈ ?b2.0⟧ ⟹ ?y ∉ ?b2.0›*) by fastforce qed lemma strong_delete_point_groups_index_one: assumes "G1 ∈ {b - {x} |b. b ∈# ℬ ∧ x ∈ b}" assumes "G2 ∈ {b - {x} |b. b ∈# ℬ ∧ x ∈ b}" assumes "G1 ≠ G2" and "xa ∈ G1" and "y ∈ G2" shows "(str_del_point_blocks x) index {xa, y} = 1" proof (-) (*goal: ‹str_del_point_blocks x index {xa, y} = 1›*) obtain b1 where gb1: "G1 = b1 - {x}" and b1in: "b1 ∈# ℬ" and xin1: "x ∈ b1" (*goal: ‹(⋀b1::'a set. ⟦(G1::'a set) = b1 - {x::'a}; b1 ∈# ℬ; x ∈ b1⟧ ⟹ thesis::bool) ⟹ thesis›*) using assms (*‹G1 ∈ {b - {x} |b. b ∈# ℬ ∧ x ∈ b}› ‹G2 ∈ {b - {x} |b. b ∈# ℬ ∧ x ∈ b}› ‹(G1::'a::type set) ≠ (G2::'a::type set)› ‹xa ∈ G1› ‹(y::'a::type) ∈ (G2::'a::type set)›*) by blast obtain b2 where gb2: "G2 = b2 - {x}" and b2in: "b2 ∈# ℬ" and xin2: "x ∈ b2" (*goal: ‹(⋀b2. ⟦G2 = b2 - {x}; b2 ∈# ℬ; x ∈ b2⟧ ⟹ thesis) ⟹ thesis›*) using assms (*‹G1 ∈ {b - {x} |b. b ∈# ℬ ∧ x ∈ b}› ‹(G2::'a set) ∈ {b - {x::'a} |b::'a set. b ∈# ℬ ∧ x ∈ b}› ‹G1 ≠ G2› ‹xa ∈ G1› ‹y ∈ G2›*) by blast have bneq: "b1 ≠ b2 " using assms(3) (*‹G1 ≠ G2›*) gb1 (*‹G1 = b1 - {x}›*) gb2 (*‹G2 = b2 - {x}›*) by auto have "xa ≠ y" using gb1 (*‹G1 = b1 - {x}›*) b1in (*‹b1 ∈# ℬ›*) xin1 (*‹x ∈ b1›*) gb2 (*‹G2 = b2 - {x}›*) b2in (*‹b2 ∈# ℬ›*) xin2 (*‹(x::'a) ∈ (b2::'a set)›*) assms(3) (*‹(G1::'a set) ≠ (G2::'a set)›*) assms(4) (*‹xa ∈ G1›*) assms(5) (*‹y ∈ G2›*) insert_subset (*‹(insert ?x ?A ⊆ ?B) = (?x ∈ ?B ∧ ?A ⊆ ?B)›*) by (smt (verit, best) Diff_eq_empty_iff (*‹((?A::?'a set) - (?B::?'a set) = {}) = (?A ⊆ ?B)›*) Diff_iff (*‹((?c::?'a) ∈ (?A::?'a set) - (?B::?'a set)) = (?c ∈ ?A ∧ ?c ∉ ?B)›*) empty_Diff (*‹{} - (?A::?'a set) = {}›*) insertCI (*‹((?a::?'a) ∉ (?B::?'a set) ⟹ ?a = (?b::?'a)) ⟹ ?a ∈ insert ?b ?B›*) pbd_index1_points_imply_unique_block (*‹⟦(?b1.0::'a set) ∈# ℬ; (?b2.0::'a set) ∈# ℬ; ?b1.0 ≠ ?b2.0; (?x::'a) ≠ (?y::'a); {?x, ?y} ⊆ ?b1.0; ?x ∈ ?b2.0⟧ ⟹ ?y ∉ ?b2.0›*)) then have pair: "card {xa, y} = 2" by simp have inv: "{xa, y} ⊆ 𝒱" using gb1 (*‹G1 = b1 - {x}›*) b1in (*‹b1 ∈# ℬ›*) gb2 (*‹(G2::'a::type set) = (b2::'a::type set) - {x::'a::type}›*) b2in (*‹b2 ∈# ℬ›*) assms(4) (*‹xa ∈ G1›*) assms(5) (*‹(y::'a) ∈ (G2::'a set)›*) by (metis Diff_cancel (*‹?A - ?A = {}›*) Diff_subset (*‹?A - ?B ⊆ ?A›*) insert_Diff (*‹?a ∈ ?A ⟹ insert ?a (?A - {?a}) = ?A›*) insert_subset (*‹(insert ?x ?A ⊆ ?B) = (?x ∈ ?B ∧ ?A ⊆ ?B)›*) wellformed (*‹?b ∈# ℬ ⟹ ?b ⊆ 𝒱›*)) have "{# bl ∈# ℬ . x ∈ bl#} index {xa, y} = 0" proof (auto simp add: points_index_0_iff (*‹(?B index ?ps = 0) = (∀b. b ∈# ?B ⟶ ¬ ?ps ⊆ b)›*)) (*goal: ‹⋀b. ⟦b ∈# ℬ; x ∈ b; xa ∈ b; y ∈ b⟧ ⟹ False›*) fix b assume a1: "b ∈# ℬ" and a2: "x ∈ b" and a3: "xa ∈ b" and a4: "y ∈ b" (*‹(b::'a set) ∈# ℬ› ‹(x::'a) ∈ (b::'a set)› ‹(xa::'a) ∈ (b::'a set)› ‹(y::'a) ∈ (b::'a set)›*) then have yxss: "{y, x} ⊆ b2" using assms(5) (*‹y ∈ G2›*) gb2 (*‹(G2::'a set) = (b2::'a set) - {x::'a}›*) xin2 (*‹(x::'a) ∈ (b2::'a set)›*) by blast have "{xa, x} ⊆ b1" using assms(4) (*‹xa ∈ G1›*) gb1 (*‹(G1::'a::type set) = (b1::'a::type set) - {x::'a::type}›*) xin1 (*‹x ∈ b1›*) by auto then have "xa ∉ b2" using pbd_index1_points_imply_unique_block (*‹⟦?b1.0 ∈# ℬ; ?b2.0 ∈# ℬ; ?b1.0 ≠ ?b2.0; ?x ≠ ?y; {?x, ?y} ⊆ ?b1.0; ?x ∈ ?b2.0⟧ ⟹ ?y ∉ ?b2.0›*) by (metis DiffE (*‹⟦?c ∈ ?A - ?B; ⟦?c ∈ ?A; ?c ∉ ?B⟧ ⟹ ?P⟧ ⟹ ?P›*) assms( (*‹xa ∈ G1›*) 4) b1in (*‹b1 ∈# ℬ›*) b2in (*‹b2 ∈# ℬ›*) bneq (*‹b1 ≠ b2›*) gb1 (*‹G1 = b1 - {x}›*) singletonI (*‹?a ∈ {?a}›*) xin2 (*‹x ∈ b2›*)) then have "b2 ≠ b" using a3 (*‹xa ∈ b›*) by auto then show False using pbd_index1_points_imply_unique_block (*‹⟦(?b1.0::'a::type set) ∈# ℬ; (?b2.0::'a::type set) ∈# ℬ; ?b1.0 ≠ ?b2.0; (?x::'a::type) ≠ (?y::'a::type); {?x, ?y} ⊆ ?b1.0; ?x ∈ ?b2.0⟧ ⟹ ?y ∉ ?b2.0›*) by (metis DiffD2 (*‹⟦?c ∈ ?A - ?B; ?c ∈ ?B⟧ ⟹ ?P›*) yxss (*‹{y, x} ⊆ b2›*) a1 (*‹b ∈# ℬ›*) a2 (*‹x ∈ b›*) a4 (*‹y ∈ b›*) assms( (*‹y ∈ G2›*) 5) b2in (*‹b2 ∈# ℬ›*) gb2 (*‹G2 = b2 - {x}›*) insertI1 (*‹?a ∈ insert ?a ?B›*)) qed then have "(str_del_point_blocks x) index {xa, y} = ℬ index {xa, y}" by (metis multiset_partition (*‹?M = filter_mset ?P ?M + {#x ∈# ?M. ¬ ?P x#}›*) plus_nat.add_0 (*‹0 + ?n = ?n›*) point_index_distrib (*‹(?B1.0 + ?B2.0) index ?ps = ?B1.0 index ?ps + ?B2.0 index ?ps›*) str_del_point_blocks_def (*‹str_del_point_blocks ?p ≡ filter_mset ((∉) ?p) ℬ›*)) thus "?thesis" (*goal: ‹str_del_point_blocks (x::'a) index {xa::'a, y::'a} = (1::nat)›*) using pbd_points_index1 (*‹⟦?ps ⊆ 𝒱; card ?ps = 2⟧ ⟹ ℬ index ?ps = 1›*) pair (*‹card {xa, y} = 2›*) inv (*‹{xa, y} ⊆ 𝒱›*) by fastforce qed lemma blocks_with_x_partition: assumes "x ∈ 𝒱" shows "partition_on (𝒱 - {x}) {b - {x} |b. b ∈# ℬ ∧ x ∈ b}" proof (intro partition_onI (*‹⟦⋀p. p ∈ ?P ⟹ p ≠ {}; ⋃ ?P = ?A; ⋀p p'. ⟦p ∈ ?P; p' ∈ ?P; p ≠ p'⟧ ⟹ p ∩ p' = {}⟧ ⟹ partition_on ?A ?P›*)) (*goals: 1. ‹⋀p. p ∈ {b - {x} |b. b ∈# ℬ ∧ x ∈ b} ⟹ p ≠ {}› 2. ‹⋃ {b - {x} |b. b ∈# ℬ ∧ x ∈ b} = 𝒱 - {x}› 3. ‹⋀p p'. ⟦p ∈ {b - {x} |b. b ∈# ℬ ∧ x ∈ b}; p' ∈ {b - {x} |b. b ∈# ℬ ∧ x ∈ b}; p ≠ p'⟧ ⟹ p ∩ p' = {}›*) have gtt: "⋀ bl. bl ∈# ℬ ⟹ card bl ≥ 2" using block_size_gt_t (*‹?k ∈ 𝒦 ⟹ 2 ≤ ?k›*) by (simp add: block_sizes (*‹(?bl::'a set) ∈# ℬ ⟹ card ?bl ∈ 𝒦›*) nat_int_comparison( (*‹((?a::nat) ≤ (?b::nat)) = (int ?a ≤ int ?b)›*) 3)) show "⋀p. p ∈ {b - {x} |b. b ∈# ℬ ∧ x ∈ b} ⟹ p ≠ {}" proof (-) (*goal: ‹⋀p. p ∈ {b - {x} |b. b ∈# ℬ ∧ x ∈ b} ⟹ p ≠ {}›*) fix p assume "p ∈ {b - {x} |b. b ∈# ℬ ∧ x ∈ b}" (*‹(p::'a set) ∈ {b - {x::'a} |b::'a set. b ∈# ℬ ∧ x ∈ b}›*) then obtain b where ptx: "p = b - {x}" and "b ∈# ℬ" and xinb: "x ∈ b" (*goal: ‹(⋀b. ⟦p = b - {x}; b ∈# ℬ; x ∈ b⟧ ⟹ thesis) ⟹ thesis›*) by blast then have ge2: "card b ≥ 2" using gtt (*‹?bl ∈# ℬ ⟹ 2 ≤ card ?bl›*) by (simp add: nat_int_comparison( (*‹(?a ≤ ?b) = (int ?a ≤ int ?b)›*) 3)) then have "finite b" by (metis card.infinite (*‹infinite ?A ⟹ card ?A = 0›*) not_numeral_le_zero (*‹¬ numeral ?n ≤ 0›*)) then have "card p = card b - 1" using xinb (*‹x ∈ b›*) ptx (*‹(p::'a set) = (b::'a set) - {x::'a}›*) by simp then have "card p ≥ 1" using ge2 (*‹2 ≤ card b›*) by linarith thus "p ≠ {}" by auto qed show "⋃ {b - {x} |b. b ∈# ℬ ∧ x ∈ b} = 𝒱 - {x}" proof (intro subset_antisym (*‹⟦(?A::?'a set) ⊆ (?B::?'a set); ?B ⊆ ?A⟧ ⟹ ?A = ?B›*) subsetI (*‹(⋀x::?'a. x ∈ (?A::?'a set) ⟹ x ∈ (?B::?'a set)) ⟹ ?A ⊆ ?B›*)) (*goals: 1. ‹⋀xa. xa ∈ ⋃ {b - {x} |b. b ∈# ℬ ∧ x ∈ b} ⟹ xa ∈ 𝒱 - {x}› 2. ‹⋀xa. xa ∈ 𝒱 - {x} ⟹ xa ∈ ⋃ {b - {x} |b. b ∈# ℬ ∧ x ∈ b}›*) fix xa assume "xa ∈ ⋃ {b - {x} |b. b ∈# ℬ ∧ x ∈ b}" (*‹(xa::'a) ∈ ⋃ {b - {x::'a} |b::'a set. b ∈# ℬ ∧ x ∈ b}›*) then obtain b where "xa ∈ b" and "b ∈# ℬ" and "x ∈ b" and "xa ≠ x" (*goal: ‹(⋀b. ⟦xa ∈ b; b ∈# ℬ; x ∈ b; xa ≠ x⟧ ⟹ thesis) ⟹ thesis›*) by auto then show "xa ∈ 𝒱 - {x}" using wf_invalid_point (*‹⟦?x ∉ 𝒱; ?b ∈# ℬ⟧ ⟹ ?x ∉ ?b›*) by blast next (*goal: ‹⋀xa. xa ∈ 𝒱 - {x} ⟹ xa ∈ ⋃ {b - {x} |b. b ∈# ℬ ∧ x ∈ b}›*) fix xa assume a: "xa ∈ 𝒱 - {x}" (*‹(xa::'a) ∈ 𝒱 - {x::'a}›*) then have nex: "xa ≠ x" by simp then have pair: "card {xa, x} = 2" by simp have "{xa, x} ⊆ 𝒱" using a (*‹(xa::'a::type) ∈ 𝒱 - {x::'a::type}›*) assms (*‹x ∈ 𝒱›*) by auto then have "card {b ∈ design_support . {xa, x} ⊆ b} = 1" using balanced (*‹⟦(?ps::'a set) ⊆ 𝒱; card ?ps = (2::nat)⟧ ⟹ ℬ index ?ps = (1::nat)›*) points_index_simple_def (*‹ℬ index (?ps::'a::type set) = card {b::'a::type set ∈ design_support. ?ps ⊆ b}›*) pbd_points_index1 (*‹⟦?ps ⊆ 𝒱; card ?ps = 2⟧ ⟹ ℬ index ?ps = 1›*) assms (*‹x ∈ 𝒱›*) by (metis pair (*‹card {xa, x} = 2›*)) then obtain b where des: "b ∈ design_support" and ss: "{xa, x} ⊆ b" (*goal: ‹(⋀b. ⟦b ∈ design_support; {xa, x} ⊆ b⟧ ⟹ thesis) ⟹ thesis›*) by (metis (no_types, lifting) card_1_singletonE (*‹⟦card ?A = 1; ⋀x. ?A = {x} ⟹ ?thesis⟧ ⟹ ?thesis›*) mem_Collect_eq (*‹(?a ∈ Collect ?P) = ?P ?a›*) singletonI (*‹?a ∈ {?a}›*)) then show "xa ∈ ⋃ {b - {x} |b. b ∈# ℬ ∧ x ∈ b}" using des (*‹b ∈ design_support›*) ss (*‹{xa, x} ⊆ b›*) nex (*‹xa ≠ x›*) design_support_def (*‹design_support ≡ set_mset ℬ›*) by auto qed show "⋀p p'. p ∈ {b - {x} |b. b ∈# ℬ ∧ x ∈ b} ⟹ p' ∈ {b - {x} |b. b ∈# ℬ ∧ x ∈ b} ⟹ p ≠ p' ⟹ p ∩ p' = {}" proof (-) (*goal: ‹⋀p p'. ⟦p ∈ {b - {x} |b. b ∈# ℬ ∧ x ∈ b}; p' ∈ {b - {x} |b. b ∈# ℬ ∧ x ∈ b}; p ≠ p'⟧ ⟹ p ∩ p' = {}›*) fix p and p' assume p1: "p ∈ {b - {x} |b. b ∈# ℬ ∧ x ∈ b}" and p2: "p' ∈ {b - {x} |b. b ∈# ℬ ∧ x ∈ b}" and pne: "p ≠ p'" (*‹(p::'a set) ∈ {b - {x::'a} |b::'a set. b ∈# ℬ ∧ x ∈ b}› ‹(p'::'a set) ∈ {b - {x::'a} |b::'a set. b ∈# ℬ ∧ x ∈ b}› ‹(p::'a set) ≠ (p'::'a set)›*) then obtain b where b1: "p = b - {x}" and b1in: "b ∈# ℬ" and xinb1: "x ∈ b" (*goal: ‹(⋀b. ⟦p = b - {x}; b ∈# ℬ; x ∈ b⟧ ⟹ thesis) ⟹ thesis›*) by blast then obtain b' where b2: "p' = b' - {x}" and b2in: "b' ∈# ℬ" and xinb2: "x ∈ b'" (*goal: ‹(⋀b'::'a::type set. ⟦(p'::'a::type set) = b' - {x::'a::type}; b' ∈# ℬ; x ∈ b'⟧ ⟹ thesis::bool) ⟹ thesis›*) using p2 (*‹(p'::'a set) ∈ {b - {x::'a} |b::'a set. b ∈# ℬ ∧ x ∈ b}›*) by blast then have "b ≠ b'" using pne (*‹p ≠ p'›*) b1 (*‹p = b - {x}›*) by auto then have "⋀ y. y ∈ b ⟹ y ≠ x ⟹ y ∉ b'" using b1in (*‹b ∈# ℬ›*) b2in (*‹b' ∈# ℬ›*) xinb1 (*‹x ∈ b›*) xinb2 (*‹x ∈ b'›*) pbd_index1_points_imply_unique_block (*‹⟦(?b1.0::'a set) ∈# ℬ; (?b2.0::'a set) ∈# ℬ; ?b1.0 ≠ ?b2.0; (?x::'a) ≠ (?y::'a); {?x, ?y} ⊆ ?b1.0; ?x ∈ ?b2.0⟧ ⟹ ?y ∉ ?b2.0›*) by (meson empty_subsetI (*‹{} ⊆ ?A›*) insert_subset (*‹(insert ?x ?A ⊆ ?B) = (?x ∈ ?B ∧ ?A ⊆ ?B)›*)) then have "⋀ y. y ∈ p ⟹ y ∉ p'" by (metis Diff_iff (*‹(?c ∈ ?A - ?B) = (?c ∈ ?A ∧ ?c ∉ ?B)›*) b1 (*‹p = b - {x}›*) b2 (*‹p' = b' - {x}›*) insertI1 (*‹?a ∈ insert ?a ?B›*)) then show "p ∩ p' = {}" using disjoint_iff (*‹(?A ∩ ?B = {}) = (∀x. x ∈ ?A ⟶ x ∉ ?B)›*) by auto qed qed lemma KGDD_by_deleting_point: assumes "x ∈ 𝒱" assumes "ℬ rep x < 𝖻" assumes "ℬ rep x > 1" shows "K_GDD (del_point x) (str_del_point_blocks x) 𝒦 { b - {x} | b . b ∈# ℬ ∧ x ∈ b}" proof (-) (*goal: ‹K_GDD (del_point (x::'a)) (str_del_point_blocks x) 𝒦 {b - {x} |b::'a set. b ∈# ℬ ∧ x ∈ b}›*) have "⋀ bl. bl ∈# ℬ ⟹ card bl ≥ 2" using block_size_gt_t (*‹?k ∈ 𝒦 ⟹ 2 ≤ ?k›*) by (simp add: block_sizes (*‹?bl ∈# ℬ ⟹ card ?bl ∈ 𝒦›*) nat_int_comparison( (*‹(?a ≤ ?b) = (int ?a ≤ int ?b)›*) 3)) then interpret des: proper_design "(del_point x)" "(str_del_point_blocks x)" using strong_delete_point_proper (*‹⟦⋀bl. ⟦bl ∈# ℬ; ?p ∈ bl⟧ ⟹ 2 ≤ card bl; ℬ rep ?p < 𝖻⟧ ⟹ proper_design (del_point ?p) (str_del_point_blocks ?p)›*) assms (*‹(x::'a) ∈ 𝒱› ‹ℬ rep x < 𝖻› ‹1 < ℬ rep x›*) by blast show "?thesis" (*goal: ‹K_GDD (del_point x) (str_del_point_blocks x) 𝒦 {b - {x} |b. b ∈# ℬ ∧ x ∈ b}›*) using blocks_with_x_partition (*‹?x ∈ 𝒱 ⟹ partition_on (𝒱 - {?x}) {b - {?x} |b. b ∈# ℬ ∧ ?x ∈ b}›*) strong_delete_point_groups_index_zero (*‹⟦?G ∈ {b - {?x} |b. b ∈# ℬ ∧ ?x ∈ b}; ?xa ∈ ?G; ?y ∈ ?G; ?xa ≠ ?y⟧ ⟹ str_del_point_blocks ?x index {?xa, ?y} = 0›*) strong_delete_point_groups_index_one (*‹⟦?G1.0 ∈ {b - {?x} |b. b ∈# ℬ ∧ ?x ∈ b}; ?G2.0 ∈ {b - {?x} |b. b ∈# ℬ ∧ ?x ∈ b}; ?G1.0 ≠ ?G2.0; ?xa ∈ ?G1.0; ?y ∈ ?G2.0⟧ ⟹ str_del_point_blocks ?x index {?xa, ?y} = 1›*) str_del_point_blocks_def (*‹str_del_point_blocks ?p ≡ filter_mset ((∉) ?p) ℬ›*) del_point_def (*‹del_point ?p ≡ 𝒱 - {?p}›*) proof (unfold_locales, simp_all add: block_sizes positive_ints assms) (*goal: ‹⟦⋀G x xa y. ⟦∃b. G = b - {x} ∧ b ∈# ℬ ∧ x ∈ b; xa ∈ G; y ∈ G; xa ≠ y⟧ ⟹ filter_mset ((∉) x) ℬ index {xa, y} = 0; ⋀G1 x G2 xa y. ⟦∃b. G1 = b - {x} ∧ b ∈# ℬ ∧ x ∈ b; ∃b. G2 = b - {x} ∧ b ∈# ℬ ∧ x ∈ b; G1 ≠ G2; xa ∈ G1; y ∈ G2⟧ ⟹ filter_mset ((∉) x) ℬ index {xa, y} = Suc 0; ⋀p. filter_mset ((∉) p) ℬ ≡ filter_mset ((∉) p) ℬ; ⋀p. 𝒱 - {p} ≡ 𝒱 - {p}; ⋀x. x ∈ 𝒱 ⟹ partition_on (𝒱 - {x}) {b - {x} |b. b ∈# ℬ ∧ x ∈ b}; ⋀p. str_del_point_blocks p ≡ filter_mset ((∉) p) ℬ; ⋀p. del_point p ≡ 𝒱 - {p}⟧ ⟹ Suc 0 < card {b - {x} |b. b ∈# ℬ ∧ x ∈ b}›*) have ge1: "card {b . b ∈# ℬ ∧ x ∈ b} > 1" using assms(3) (*‹1 < ℬ rep x›*) replication_num_simple_def (*‹ℬ rep ?x = card {b ∈ design_support. ?x ∈ b}›*) design_support_def (*‹design_support ≡ set_mset ℬ›*) by auto have fin: "finite {b . b ∈# ℬ ∧ x ∈ b}" by simp have inj: "inj_on (λ b . b - {x}) {b . b ∈# ℬ ∧ x ∈ b}" using assms(2) (*‹ℬ rep (x::'a) < 𝖻›*) inj_on_def (*‹inj_on ?f ?A = (∀x∈?A. ∀y∈?A. ?f x = ?f y ⟶ x = y)›*) mem_Collect_eq (*‹((?a::?'a::type) ∈ Collect (?P::?'a::type ⇒ bool)) = ?P ?a›*) by auto then have "card {b - {x} |b. b ∈# ℬ ∧ x ∈ b} = card {b . b ∈# ℬ ∧ x ∈ b}" using card_image (*‹inj_on ?f ?A ⟹ card (?f ` ?A) = card ?A›*) fin (*‹finite {b. b ∈# ℬ ∧ x ∈ b}›*) by (simp add: inj (*‹inj_on (λb. b - {x}) {b. b ∈# ℬ ∧ x ∈ b}›*) card_image (*‹inj_on ?f ?A ⟹ card (?f ` ?A) = card ?A›*) setcompr_eq_image (*‹{?f x |x. ?P x} = ?f ` {x. ?P x}›*)) then show "Suc 0 < card {b - {x} |b. b ∈# ℬ ∧ x ∈ b}" using ge1 (*‹1 < card {b. b ∈# ℬ ∧ x ∈ b}›*) by presburger qed qed lemma card_singletons_eq: "card {{a} | a . a ∈ A} = card A" by (simp add: card_image (*‹inj_on ?f ?A ⟹ card (?f ` ?A) = card ?A›*) Setcompr_eq_image (*‹{?f x |x. x ∈ ?A} = ?f ` ?A›*)) lemma KGDD_from_PBD: "K_GDD 𝒱 ℬ 𝒦 {{x} | x . x ∈ 𝒱}" proof (unfold_locales, auto simp add: Setcompr_eq_image (*‹{?f x |x. x ∈ ?A} = ?f ` ?A›*) partition_on_singletons (*‹partition_on ?A ((λx. {x}) ` ?A)›*)) (*goals: 1. ‹Suc 0 < card ((λx. {x}) ` 𝒱)› 2. ‹⋀xa xb. ⟦xa ∈ 𝒱; xb ∈ 𝒱; ℬ index {xa, xb} ≠ Suc 0⟧ ⟹ xa = xb›*) have "card ((λx. {x}) ` 𝒱) ≥ 2" using t_lt_order (*‹2 ≤ 𝗏›*) card_singletons_eq (*‹card {{a} |a. a ∈ ?A} = card ?A›*) by (metis Collect_mem_eq (*‹{x. x ∈ ?A} = ?A›*) setcompr_eq_image (*‹{?f x |x. ?P x} = ?f ` {x. ?P x}›*)) then show "Suc 0 < card ((λx. {x}) ` 𝒱)" by linarith show "⋀xa xb. xa ∈ 𝒱 ⟹ xb ∈ 𝒱 ⟹ ℬ index {xa, xb} ≠ Suc 0 ⟹ xa = xb" proof (rule ccontr (*‹(¬ ?P ⟹ False) ⟹ ?P›*)) (*goal: ‹⋀(xa::'a) xb::'a. ⟦xa ∈ 𝒱; xb ∈ 𝒱; ℬ index {xa, xb} ≠ Suc (0::nat); xa ≠ xb⟧ ⟹ False›*) fix xa and xb assume ain: "xa ∈ 𝒱" and bin: "xb ∈ 𝒱" and ne1: "ℬ index {xa, xb} ≠ Suc 0" (*‹(xa::'a) ∈ 𝒱› ‹(xb::'a) ∈ 𝒱› ‹ℬ index {xa::'a, xb::'a} ≠ Suc (0::nat)›*) assume "xa ≠ xb" (*‹(xa::'a) ≠ (xb::'a)›*) then have "card {xa, xb} = 2" by auto then have "ℬ index {xa, xb} = 1" by (simp add: ain (*‹xa ∈ 𝒱›*) bin (*‹xb ∈ 𝒱›*)) thus False using ne1 (*‹ℬ index {xa, xb} ≠ Suc 0›*) by linarith qed qed end context bibd begin lemma kGDD_from_bibd: assumes "Λ = 1" assumes "x ∈ 𝒱" shows "k_GDD (del_point x) (str_del_point_blocks x) 𝗄 { b - {x} | b . b ∈# ℬ ∧ x ∈ b}" proof (-) (*goal: ‹k_GDD (del_point x) (str_del_point_blocks x) 𝗄 {b - {x} |b. b ∈# ℬ ∧ x ∈ b}›*) interpret pbd: PBD "𝒱" "ℬ" "{𝗄}" using assms (*‹Λ = 1› ‹(x::'a) ∈ 𝒱›*) using PBD.intro (*‹Λ_PBD (?point_set::?'a set) (?block_collection::?'a set multiset) (1::nat) (?sizes::nat set) ⟹ PBD ?point_set ?block_collection ?sizes›*) "Λ_PBD_axioms" (*‹Λ_PBD 𝒱 ℬ Λ {𝗄}›*) by auto have lt: "ℬ rep x < 𝖻" using block_num_gt_rep (*‹𝗋 < 𝖻›*) by (simp add: assms( (*‹x ∈ 𝒱›*) 2)) have "ℬ rep x > 1" using r_ge_two (*‹2 ≤ 𝗋›*) assms (*‹Λ = 1› ‹x ∈ 𝒱›*) by simp then interpret kgdd: K_GDD "(del_point x)" "str_del_point_blocks x" "{𝗄}" "{ b - {x} | b . b ∈# ℬ ∧ x ∈ b}" using pbd.KGDD_by_deleting_point (*‹⟦?x ∈ 𝒱; ℬ rep ?x < 𝖻; 1 < ℬ rep ?x⟧ ⟹ K_GDD (del_point ?x) (str_del_point_blocks ?x) {𝗄} {b - {?x} |b. b ∈# ℬ ∧ ?x ∈ b}›*) lt (*‹ℬ rep x < 𝖻›*) assms (*‹Λ = 1› ‹x ∈ 𝒱›*) by blast show "?thesis" (*goal: ‹k_GDD (del_point (x::'a::type)) (str_del_point_blocks x) 𝗄 {b - {x} |b::'a::type set. b ∈# ℬ ∧ x ∈ b}›*) using del_point_def (*‹del_point (?p::'a) ≡ 𝒱 - {?p}›*) str_del_point_blocks_def (*‹str_del_point_blocks (?p::'a) ≡ filter_mset ((∉) ?p) ℬ›*) apply unfold_locales (*goal: ‹k_GDD (del_point x) (str_del_point_blocks x) 𝗄 {b - {x} |b. b ∈# ℬ ∧ x ∈ b}›*) by simp qed end end
{ "path": "afp-2025-02-12/thys/Design_Theory/Group_Divisible_Designs.thy", "repo": "afp-2025-02-12", "sha": "1c01934525160b5bde5e85754ef4d82def8dee74ba3bbcc2fe175d7d25ad6e05" }
(* Title: HOL/Proofs/Lambda/NormalForm.thy Author: Stefan Berghofer, TU Muenchen, 2003 *) section ‹Inductive characterization of lambda terms in normal form› theory NormalForm imports ListBeta begin subsection ‹Terms in normal form› definition listall :: "('a ⇒ bool) ⇒ 'a list ⇒ bool" where "listall P xs ≡ (∀i. i < length xs ⟶ P (xs ! i))" declare listall_def [extraction_expand_def] theorem listall_nil: "listall P []" by (simp add: listall_def (*‹listall ?P ?xs ≡ ∀i<length ?xs. ?P (?xs ! i)›*)) theorem listall_nil_eq [simp]: "listall P [] = True" by (iprover intro: listall_nil) theorem listall_cons: "P x ⟹ listall P xs ⟹ listall P (x # xs)" apply (simp add: listall_def (*‹listall (?P::?'a ⇒ bool) (?xs::?'a list) ≡ ∀i<length ?xs. ?P (?xs ! i)›*)) (*goal: ‹⟦P x; listall P xs⟧ ⟹ listall P (x # xs)›*) apply (rule allI (*‹(⋀x::?'a. (?P::?'a ⇒ bool) x) ⟹ ∀x::?'a. ?P x›*) impI (*‹(?P::bool ⟹ ?Q::bool) ⟹ ?P ⟶ ?Q›*)) (*goal: ‹⟦(P::'a ⇒ bool) (x::'a); ∀i<length (xs::'a list). P (xs ! i)⟧ ⟹ ∀i<Suc (length xs). P ((x # xs) ! i)›*) apply (rule allI (*‹(⋀x. ?P x) ⟹ ∀x. ?P x›*) impI (*‹(?P ⟹ ?Q) ⟹ ?P ⟶ ?Q›*)) (*goal: ‹⋀i. ⟦P x; ∀i<length xs. P (xs ! i)⟧ ⟹ i < Suc (length xs) ⟶ P ((x # xs) ! i)›*) apply (case_tac i) (*goals: 1. ‹⋀i. ⟦P x; ∀i<length xs. P (xs ! i); i < Suc (length xs); i = 0⟧ ⟹ P ((x # xs) ! i)› 2. ‹⋀i nat. ⟦P x; ∀i<length xs. P (xs ! i); i < Suc (length xs); i = Suc nat⟧ ⟹ P ((x # xs) ! i)› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) . theorem listall_cons_eq [simp]: "listall P (x # xs) = (P x ∧ listall P xs)" apply (rule iffI (*‹⟦?P ⟹ ?Q; ?Q ⟹ ?P⟧ ⟹ ?P = ?Q›*)) (*goals: 1. ‹listall P (x # xs) ⟹ P x ∧ listall P xs› 2. ‹P x ∧ listall P xs ⟹ listall P (x # xs)› discuss goal 1*) apply ((unfold listall_def (*‹listall ?P ?xs ≡ ∀i<length ?xs. ?P (?xs ! i)›*))[1]) (*top goal: ‹listall P (x # xs) ⟹ P x ∧ listall P xs› and 1 goal remains*) apply (rule conjI (*‹⟦?P; ?Q⟧ ⟹ ?P ∧ ?Q›*)) (*goals: 1. ‹∀i<length (x # xs). P ((x # xs) ! i) ⟹ P x› 2. ‹∀i<length (x # xs). P ((x # xs) ! i) ⟹ ∀i<length xs. P (xs ! i)› discuss goal 1*) apply ((erule_tac x=0 in allE (*‹⟦∀x::?'a::type. (?P::?'a::type ⇒ bool) x; ?P (?x::?'a::type) ⟹ ?R::bool⟧ ⟹ ?R›*))[1]) (*top goal: ‹∀i<length (x # xs). P ((x # xs) ! i) ⟹ P x› and 2 goals remain*) apply simp (*discuss goal 2*) apply simp (*top goal: ‹∀i<length (x # xs). P ((x # xs) ! i) ⟹ ∀i<length xs. P (xs ! i)› and 1 goal remains*) apply (rule allI (*‹(⋀x. ?P x) ⟹ ∀x. ?P x›*)) (*top goal: ‹∀i<Suc (length xs). P ((x # xs) ! i) ⟹ ∀i<length xs. P (xs ! i)› and 1 goal remains*) apply ((erule_tac x="Suc i" in allE (*‹⟦∀x::?'a. (?P::?'a ⇒ bool) x; ?P (?x::?'a) ⟹ ?R::bool⟧ ⟹ ?R›*))[1]) (*top goal: ‹⋀i::nat. ∀i<Suc (length (xs::'a::type list)). (P::'a::type ⇒ bool) (((x::'a::type) # xs) ! i) ⟹ i < length xs ⟶ P (xs ! i)› and 1 goal remains*) apply simp (*proven 2 subgoals*) (*discuss goal 2*) apply ((erule conjE (*‹⟦?P ∧ ?Q; ⟦?P; ?Q⟧ ⟹ ?R⟧ ⟹ ?R›*))[1]) (*goal: ‹P x ∧ listall P xs ⟹ listall P (x # xs)›*) apply ((erule listall_cons (*‹⟦?P ?x; listall ?P ?xs⟧ ⟹ listall ?P (?x # ?xs)›*))[1]) (*goal: ‹⟦(P::'a ⇒ bool) (x::'a); listall P (xs::'a list)⟧ ⟹ listall P (x # xs)›*) apply ((assumption)[1]) (*proven 2 subgoals*) . lemma listall_conj1: "listall (λx. P x ∧ Q x) xs ⟹ listall P xs" apply (induct xs) (*goals: 1. ‹listall (λx. P x ∧ Q x) [] ⟹ listall P []› 2. ‹⋀a xs. ⟦listall (λx. P x ∧ Q x) xs ⟹ listall P xs; listall (λx. P x ∧ Q x) (a # xs)⟧ ⟹ listall P (a # xs)› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) . lemma listall_conj2: "listall (λx. P x ∧ Q x) xs ⟹ listall Q xs" apply (induct xs) (*goals: 1. ‹listall (λx. P x ∧ Q x) [] ⟹ listall Q []› 2. ‹⋀a xs. ⟦listall (λx. P x ∧ Q x) xs ⟹ listall Q xs; listall (λx. P x ∧ Q x) (a # xs)⟧ ⟹ listall Q (a # xs)› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) . lemma listall_app: "listall P (xs @ ys) = (listall P xs ∧ listall P ys)" apply (induct xs) (*goals: 1. ‹listall P ([] @ ys) = (listall P [] ∧ listall P ys)› 2. ‹⋀a xs. listall P (xs @ ys) = (listall P xs ∧ listall P ys) ⟹ listall P ((a # xs) @ ys) = (listall P (a # xs) ∧ listall P ys)› discuss goal 1*) apply (rule iffI (*‹⟦?P ⟹ ?Q; ?Q ⟹ ?P⟧ ⟹ ?P = ?Q›*)) (*goals: 1. ‹listall P ([] @ ys) ⟹ listall P [] ∧ listall P ys› 2. ‹listall P [] ∧ listall P ys ⟹ listall P ([] @ ys)› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) (*discuss goal 2*) apply (rule iffI (*‹⟦?P ⟹ ?Q; ?Q ⟹ ?P⟧ ⟹ ?P = ?Q›*)) (*goals: 1. ‹⋀a xs. ⟦listall P (xs @ ys) = (listall P xs ∧ listall P ys); listall P ((a # xs) @ ys)⟧ ⟹ listall P (a # xs) ∧ listall P ys› 2. ‹⋀a xs. ⟦listall P (xs @ ys) = (listall P xs ∧ listall P ys); listall P (a # xs) ∧ listall P ys⟧ ⟹ listall P ((a # xs) @ ys)› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) (*proven 2 subgoals*) . lemma listall_snoc [simp]: "listall P (xs @ [x]) = (listall P xs ∧ P x)" apply (rule iffI (*‹⟦?P ⟹ ?Q; ?Q ⟹ ?P⟧ ⟹ ?P = ?Q›*)) (*goals: 1. ‹listall (P::'a ⇒ bool) ((xs::'a list) @ [x::'a]) ⟹ listall P xs ∧ P x› 2. ‹listall (P::'a ⇒ bool) (xs::'a list) ∧ P (x::'a) ⟹ listall P (xs @ [x])› discuss goal 1*) apply (simp add: listall_app (*‹listall ?P (?xs @ ?ys) = (listall ?P ?xs ∧ listall ?P ?ys)›*)) (*discuss goal 2*) apply (simp add: listall_app (*‹listall ?P (?xs @ ?ys) = (listall ?P ?xs ∧ listall ?P ?ys)›*)) (*proven 2 subgoals*) . lemma listall_cong [cong, extraction_expand]: "xs = ys ⟹ listall P xs = listall P ys" ― ‹Currently needed for strange technical reasons› apply (unfold listall_def (*‹listall ?P ?xs ≡ ∀i<length ?xs. ?P (?xs ! i)›*)) (*goal: ‹(xs::'a::type list) = (ys::'a::type list) ⟹ listall (P::'a::type ⇒ bool) xs = listall P ys›*) by simp text ‹ \<^term>‹listsp› is equivalent to \<^term>‹listall›, but cannot be used for program extraction. › lemma listall_listsp_eq: "listall P xs = listsp P xs" apply (induct xs) (*goals: 1. ‹listall (P::'a ⇒ bool) [] = listsp P []› 2. ‹⋀(a::'a) xs::'a list. listall (P::'a ⇒ bool) xs = listsp P xs ⟹ listall P (a # xs) = listsp P (a # xs)› discuss goal 1*) apply ((auto intro: listsp.intros (*‹listsp ?A []› ‹⟦?A ?a; listsp ?A ?l⟧ ⟹ listsp ?A (?a # ?l)›*))[1]) (*discuss goal 2*) apply ((auto intro: listsp.intros (*‹listsp ?A []› ‹⟦?A ?a; listsp ?A ?l⟧ ⟹ listsp ?A (?a # ?l)›*))[1]) (*proven 2 subgoals*) . inductive NF :: "dB ⇒ bool" where App: "listall NF ts ⟹ NF (Var x °° ts)" | Abs: "NF t ⟹ NF (Abs t)" monos listall_def lemma nat_eq_dec: "⋀n::nat. m = n ∨ m ≠ n" apply (induct m) (*goal: ‹⋀n. m = n ∨ m ≠ n›*) apply (case_tac n) (*top goal: ‹⋀n. 0 = n ∨ 0 ≠ n› and 1 goal remains*) apply (case_tac [3] n) (*top goal: ‹⋀n. n = 0 ⟹ 0 = n ∨ 0 ≠ n› and 2 goals remain*) by ((simp only: nat.simps (*‹(Suc (?x2.0::nat) = Suc (?y2.0::nat)) = (?x2.0 = ?y2.0)› ‹(0::nat) ≠ Suc (?x2.0::nat)› ‹Suc (?x2.0::nat) ≠ (0::nat)› ‹(case 0::nat of 0::nat ⇒ ?f1.0::?'a::type | Suc (x::nat) ⇒ (?f2.0::nat ⇒ ?'a::type) x) = ?f1.0› ‹(case Suc (?x2.0::nat) of 0::nat ⇒ ?f1.0::?'a::type | Suc (x::nat) ⇒ (?f2.0::nat ⇒ ?'a::type) x) = ?f2.0 ?x2.0› ‹rec_nat (?f1.0::?'t::type) (?f2.0::nat ⇒ ?'t::type ⇒ ?'t::type) (0::nat) = ?f1.0› ‹rec_nat (?f1.0::?'t::type) (?f2.0::nat ⇒ ?'t::type ⇒ ?'t::type) (Suc (?nat::nat)) = ?f2.0 ?nat (rec_nat ?f1.0 ?f2.0 ?nat)›*), (iprover)?)+) lemma nat_le_dec: "⋀n::nat. m < n ∨ ¬ (m < n)" apply (induct m) (*goal: ‹⋀n. m < n ∨ ¬ m < n›*) apply (case_tac n) (*top goal: ‹⋀n. 0 < n ∨ ¬ 0 < n› and 1 goal remains*) apply (case_tac [3] n) (*top goal: ‹⋀n. n = 0 ⟹ 0 < n ∨ ¬ 0 < n› and 2 goals remain*) by ((simp del: simp_thms (*‹(¬ ¬ ?P) = ?P› ‹((¬ ?P) = (¬ ?Q)) = (?P = ?Q)› ‹(?P ≠ ?Q) = (?P = (¬ ?Q))› ‹(?P ∨ ¬ ?P) = True› ‹(¬ ?P ∨ ?P) = True› ‹(?x = ?x) = True› ‹(¬ True) = False› ‹(¬ False) = True› ‹(¬ ?P) ≠ ?P› ‹?P ≠ (¬ ?P)› ‹(True = ?P) = ?P› ‹(?P = True) = ?P› and more 32 facts*) subst_all (*‹(⋀x. x = ?a ⟹ PROP ?P x) ≡ PROP ?P ?a› ‹(⋀x. ?a = x ⟹ PROP ?P x) ≡ PROP ?P ?a›*), (iprover)?)+) lemma App_NF_D: assumes NF: "NF (Var n °° ts)" shows "listall NF ts" using NF (*‹NF (Var n °° ts)›*) apply cases (*goals: 1. ‹⋀tsa x. ⟦Var n °° ts = Var x °° tsa; listall NF tsa⟧ ⟹ listall NF ts› 2. ‹⋀t. ⟦Var n °° ts = Abs t; NF t⟧ ⟹ listall NF ts› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) . subsection ‹Properties of ‹NF›› lemma Var_NF: "NF (Var n)" apply (subgoal_tac "NF (Var n °° [])") (*goals: 1. ‹NF (Var n °° []) ⟹ NF (Var n)› 2. ‹NF (Var n °° [])› discuss goal 1*) apply simp (*discuss goal 2*) apply (rule NF.App (*‹listall NF ?ts ⟹ NF (Var ?x °° ?ts)›*)) (*goal: ‹NF (Var n °° [])›*) apply simp (*proven 2 subgoals*) . lemma Abs_NF: assumes NF: "NF (Abs t °° ts)" shows "ts = []" using NF (*‹NF (Abs t °° ts)›*) proof (cases) (*goals: 1. ‹⋀tsa x. ⟦Abs t °° ts = Var x °° tsa; listall NF tsa⟧ ⟹ ts = []› 2. ‹⋀ta. ⟦Abs t °° ts = Abs ta; NF ta⟧ ⟹ ts = []›*) case (App us i) (*‹Abs (t::dB) °° (ts::dB list) = Var (i::nat) °° (us::dB list)› ‹listall NF (us::dB list)›*) thus "?thesis" (*goal: ‹ts = []›*) by (simp add: Var_apps_neq_Abs_apps [THEN not_sym] (*‹Abs (?r1::dB) °° (?ss1::dB list) ≠ Var (?n1::nat) °° (?ts1::dB list)›*)) next (*goal: ‹⋀ta. ⟦Abs t °° ts = Abs ta; NF ta⟧ ⟹ ts = []›*) case (Abs u) (*‹Abs t °° ts = Abs u› ‹NF u›*) thus "?thesis" (*goal: ‹ts = []›*) by simp qed lemma subst_terms_NF: "listall NF ts ⟹ listall (λt. ∀i j. NF (t[Var i/j])) ts ⟹ listall NF (map (λt. t[Var i/j]) ts)" apply (induct ts) (*goals: 1. ‹⟦listall NF []; listall (λt. ∀i j. NF (t[Var i/j])) []⟧ ⟹ listall NF (map (λt. t[Var i/j]) [])› 2. ‹⋀a ts. ⟦⟦listall NF ts; listall (λt. ∀i j. NF (t[Var i/j])) ts⟧ ⟹ listall NF (map (λt. t[Var i/j]) ts); listall NF (a # ts); listall (λt. ∀i j. NF (t[Var i/j])) (a # ts)⟧ ⟹ listall NF (map (λt. t[Var i/j]) (a # ts))› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) . lemma subst_Var_NF: "NF t ⟹ NF (t[Var i/j])" apply (induct arbitrary: i j set: NF) (*goals: 1. ‹⋀(ts::dB list) (x::nat) (i::nat) j::nat. listall (λx::dB. NF x ∧ (∀(xa::nat) xb::nat. NF (x[Var xa/xb]))) ts ⟹ NF ((Var x °° ts)[Var i/j])› 2. ‹⋀(t::dB) (i::nat) j::nat. ⟦NF t; ⋀(i::nat) j::nat. NF (t[Var i/j])⟧ ⟹ NF (Abs t[Var i/j])› discuss goal 1*) apply simp (*top goal: ‹⋀ts x i j. listall (λx. NF x ∧ (∀xa xb. NF (x[Var xa/xb]))) ts ⟹ NF ((Var x °° ts)[Var i/j])› and 1 goal remains*) apply (frule listall_conj1 (*‹listall (λx. ?P x ∧ ?Q x) ?xs ⟹ listall ?P ?xs›*)) (*top goal: ‹⋀ts x i j. listall (λx. NF x ∧ (∀xa xb. NF (x[Var xa/xb]))) ts ⟹ NF (Var x[Var i/j] °° map (λt. t[Var i/j]) ts)› and 1 goal remains*) apply (drule listall_conj2 (*‹listall (λx. ?P x ∧ ?Q x) ?xs ⟹ listall ?Q ?xs›*)) (*top goal: ‹⋀ts x i j. ⟦listall (λx. NF x ∧ (∀xa xb. NF (x[Var xa/xb]))) ts; listall NF ts⟧ ⟹ NF (Var x[Var i/j] °° map (λt. t[Var i/j]) ts)› and 1 goal remains*) apply (drule_tac i=i and j=j in subst_terms_NF (*‹⟦listall NF (?ts::dB list); listall (λt::dB. ∀(i::nat) j::nat. NF (t[Var i/j])) ?ts⟧ ⟹ listall NF (map (λt::dB. t[Var (?i::nat)/?j::nat]) ?ts)›*)) (*goals: 1. ‹⋀ts x i j. listall (λx. ∀xa xb. NF (x[Var xa/xb])) ts ⟹ listall (λt. ∀i j. NF (t[Var i/j])) ts› 2. ‹⋀ts x i j. ⟦listall (λx. ∀xa xb. NF (x[Var xa/xb])) ts; listall NF (map (λt. t[Var i/j]) ts)⟧ ⟹ NF (Var x[Var i/j] °° map (λt. t[Var i/j]) ts)› discuss goal 1*) apply assumption (*discuss goal 2*) apply (rule_tac m1=x and n1=j in nat_eq_dec [THEN disjE] (*‹⟦?m1 = ?n1 ⟹ ?R; ?m1 ≠ ?n1 ⟹ ?R⟧ ⟹ ?R›*)) (*goals: 1. ‹⋀(ts::dB list) (x::nat) (i::nat) j::nat. ⟦listall (λx::dB. ∀(xa::nat) xb::nat. NF (x[Var xa/xb])) ts; listall NF (map (λt::dB. t[Var i/j]) ts); x = j⟧ ⟹ NF (Var x[Var i/j] °° map (λt::dB. t[Var i/j]) ts)› 2. ‹⋀(ts::dB list) (x::nat) (i::nat) j::nat. ⟦listall (λx::dB. ∀(xa::nat) xb::nat. NF (x[Var xa/xb])) ts; listall NF (map (λt::dB. t[Var i/j]) ts); x ≠ j⟧ ⟹ NF (Var x[Var i/j] °° map (λt::dB. t[Var i/j]) ts)› discuss goal 1*) apply simp (*top goal: ‹⋀(ts::dB list) (x::nat) (i::nat) j::nat. ⟦listall (λx::dB. ∀(xa::nat) xb::nat. NF (x[Var xa/xb])) ts; listall NF (map (λt::dB. t[Var i/j]) ts); x = j⟧ ⟹ NF (Var x[Var i/j] °° map (λt::dB. t[Var i/j]) ts)› and 2 goals remain*) apply (erule NF.App (*‹listall NF ?ts ⟹ NF (Var ?x °° ?ts)›*)) (*discuss goal 2*) apply (rule_tac m1=j and n1=x in nat_le_dec [THEN disjE] (*‹⟦?m1 < ?n1 ⟹ ?R; ¬ ?m1 < ?n1 ⟹ ?R⟧ ⟹ ?R›*)) (*goals: 1. ‹⋀ts x i j. ⟦listall (λx. ∀xa xb. NF (x[Var xa/xb])) ts; listall NF (map (λt. t[Var i/j]) ts); x ≠ j; j < x⟧ ⟹ NF (Var x[Var i/j] °° map (λt. t[Var i/j]) ts)› 2. ‹⋀ts x i j. ⟦listall (λx. ∀xa xb. NF (x[Var xa/xb])) ts; listall NF (map (λt. t[Var i/j]) ts); x ≠ j; ¬ j < x⟧ ⟹ NF (Var x[Var i/j] °° map (λt. t[Var i/j]) ts)› discuss goal 1*) apply simp (*top goal: ‹⋀(ts::dB list) (x::nat) (i::nat) j::nat. ⟦listall (λx::dB. ∀(xa::nat) xb::nat. NF (x[Var xa/xb])) ts; listall NF (map (λt::dB. t[Var i/j]) ts); x ≠ j; j < x⟧ ⟹ NF (Var x[Var i/j] °° map (λt::dB. t[Var i/j]) ts)› and 2 goals remain*) apply (iprover intro: NF.App) (*discuss goal 2*) apply simp (*top goal: ‹⋀ts x i j. ⟦listall (λx. ∀xa xb. NF (x[Var xa/xb])) ts; listall NF (map (λt. t[Var i/j]) ts); x ≠ j; ¬ j < x⟧ ⟹ NF (Var x[Var i/j] °° map (λt. t[Var i/j]) ts)› and 1 goal remains*) apply (iprover intro: NF.App) (*proven 2 subgoals*) (*proven 2 subgoals*) (*proven 2 subgoals*) (*discuss goal 2*) apply simp (*goal: ‹⋀(t::dB) (i::nat) j::nat. ⟦NF t; ⋀(i::nat) j::nat. NF (t[Var i/j])⟧ ⟹ NF (Abs t[Var i/j])›*) apply (iprover intro: NF.Abs) (*proven 2 subgoals*) . lemma app_Var_NF: "NF t ⟹ ∃t'. t ° Var i →⇩β⇧* t' ∧ NF t'" apply (induct set: NF) (*goals: 1. ‹⋀ts x. listall (λx. NF x ∧ (∃t'. x ° Var i →⇩β⇧* t' ∧ NF t')) ts ⟹ ∃t'. (Var x °° ts) ° Var i →⇩β⇧* t' ∧ NF t'› 2. ‹⋀t. ⟦NF t; ∃t'. t ° Var i →⇩β⇧* t' ∧ NF t'⟧ ⟹ ∃t'. Abs t ° Var i →⇩β⇧* t' ∧ NF t'› discuss goal 1*) apply (simplesubst app_last) (*top goal: ‹⋀ts x. listall (λx. NF x ∧ (∃t'. x ° Var i →⇩β⇧* t' ∧ NF t')) ts ⟹ ∃t'. (Var x °° ts) ° Var i →⇩β⇧* t' ∧ NF t'› and 1 goal remains*) apply (rule exI (*‹(?P::?'a ⇒ bool) (?x::?'a) ⟹ ∃x::?'a. ?P x›*)) (*top goal: ‹⋀ts x. listall (λx. NF x ∧ (∃t'. x ° Var i →⇩β⇧* t' ∧ NF t')) ts ⟹ ∃t'. Var x °° (ts @ [Var i]) →⇩β⇧* t' ∧ NF t'› and 1 goal remains*) apply (rule conjI (*‹⟦?P; ?Q⟧ ⟹ ?P ∧ ?Q›*)) (*goals: 1. ‹⋀(ts::dB list) x::nat. listall (λx::dB. NF x ∧ (∃t'::dB. x ° Var (i::nat) →⇩β⇧* t' ∧ NF t')) ts ⟹ Var x °° (ts @ [Var i]) →⇩β⇧* (?t'4::dB list ⇒ nat ⇒ dB) ts x› 2. ‹⋀(ts::dB list) x::nat. listall (λx::dB. NF x ∧ (∃t'::dB. x ° Var (i::nat) →⇩β⇧* t' ∧ NF t')) ts ⟹ NF ((?t'4::dB list ⇒ nat ⇒ dB) ts x)› discuss goal 1*) apply (rule rtranclp.rtrancl_refl (*‹(?r::?'a ⇒ ?'a ⇒ bool)⇧*⇧* (?a::?'a) ?a›*)) (*discuss goal 2*) apply (rule NF.App (*‹listall NF ?ts ⟹ NF (Var ?x °° ?ts)›*)) (*top goal: ‹⋀(ts::dB list) x::nat. listall (λx::dB. NF x ∧ (∃t'::dB. x ° Var (i::nat) →⇩β⇧* t' ∧ NF t')) ts ⟹ NF (Var x °° (ts @ [Var i]))› and 1 goal remains*) apply (drule listall_conj1 (*‹listall (λx. ?P x ∧ ?Q x) ?xs ⟹ listall ?P ?xs›*)) (*top goal: ‹⋀ts x. listall (λx. NF x ∧ (∃t'. x ° Var i →⇩β⇧* t' ∧ NF t')) ts ⟹ listall NF (ts @ [Var i])› and 1 goal remains*) apply (simp add: listall_app (*‹listall ?P (?xs @ ?ys) = (listall ?P ?xs ∧ listall ?P ?ys)›*)) (*top goal: ‹⋀ts x. listall NF ts ⟹ listall NF (ts @ [Var i])› and 1 goal remains*) apply (rule Var_NF (*‹NF (Var ?n)›*)) (*proven 2 subgoals*) (*discuss goal 2*) apply (rule exI (*‹?P ?x ⟹ ∃x. ?P x›*)) (*goal: ‹⋀t::dB. ⟦NF t; ∃t'::dB. t ° Var (i::nat) →⇩β⇧* t' ∧ NF t'⟧ ⟹ ∃t'::dB. Abs t ° Var i →⇩β⇧* t' ∧ NF t'›*) apply (rule conjI (*‹⟦?P; ?Q⟧ ⟹ ?P ∧ ?Q›*)) (*goals: 1. ‹⋀t::dB. ⟦NF t; ∃t'::dB. t ° Var (i::nat) →⇩β⇧* t' ∧ NF t'⟧ ⟹ Abs t ° Var i →⇩β⇧* (?t'15::dB ⇒ dB) t› 2. ‹⋀t::dB. ⟦NF t; ∃t'::dB. t ° Var (i::nat) →⇩β⇧* t' ∧ NF t'⟧ ⟹ NF ((?t'15::dB ⇒ dB) t)› discuss goal 1*) apply (rule rtranclp.rtrancl_into_rtrancl (*‹⟦(?r::?'a ⇒ ?'a ⇒ bool)⇧*⇧* (?a::?'a) (?b::?'a); ?r ?b (?c::?'a)⟧ ⟹ ?r⇧*⇧* ?a ?c›*)) (*goals: 1. ‹⋀t. ⟦NF t; ∃t'. t ° Var i →⇩β⇧* t' ∧ NF t'⟧ ⟹ Abs t ° Var i →⇩β⇧* ?b20 t› 2. ‹⋀t. ⟦NF t; ∃t'. t ° Var i →⇩β⇧* t' ∧ NF t'⟧ ⟹ ?b20 t →⇩β ?t'15 t› discuss goal 1*) apply (rule rtranclp.rtrancl_refl (*‹(?r::?'a::type ⇒ ?'a::type ⇒ bool)⇧*⇧* (?a::?'a::type) ?a›*)) (*discuss goal 2*) apply (rule beta (*‹Abs ?s ° ?t →⇩β ?s[?t/0]›*)) (*proven 2 subgoals*) (*discuss goal 2*) apply (erule subst_Var_NF (*‹NF ?t ⟹ NF (?t[Var ?i/?j])›*)) (*proven 2 subgoals*) (*proven 2 subgoals*) . lemma lift_terms_NF: "listall NF ts ⟹ listall (λt. ∀i. NF (lift t i)) ts ⟹ listall NF (map (λt. lift t i) ts)" apply (induct ts) (*goals: 1. ‹⟦listall NF []; listall (λt. ∀i. NF (lift t i)) []⟧ ⟹ listall NF (map (λt. lift t i) [])› 2. ‹⋀a ts. ⟦⟦listall NF ts; listall (λt. ∀i. NF (lift t i)) ts⟧ ⟹ listall NF (map (λt. lift t i) ts); listall NF (a # ts); listall (λt. ∀i. NF (lift t i)) (a # ts)⟧ ⟹ listall NF (map (λt. lift t i) (a # ts))› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) . lemma lift_NF: "NF t ⟹ NF (lift t i)" apply (induct arbitrary: i set: NF) (*goals: 1. ‹⋀(ts::dB list) (x::nat) i::nat. listall (λx::dB. NF x ∧ (∀xa::nat. NF (lift x xa))) ts ⟹ NF (lift (Var x °° ts) i)› 2. ‹⋀(t::dB) i::nat. ⟦NF t; ⋀i::nat. NF (lift t i)⟧ ⟹ NF (lift (Abs t) i)› discuss goal 1*) apply (frule listall_conj1 (*‹listall (λx. ?P x ∧ ?Q x) ?xs ⟹ listall ?P ?xs›*)) (*top goal: ‹⋀ts x i. listall (λx. NF x ∧ (∀xa. NF (lift x xa))) ts ⟹ NF (lift (Var x °° ts) i)› and 1 goal remains*) apply (drule listall_conj2 (*‹listall (λx::?'a::type. (?P::?'a::type ⇒ bool) x ∧ (?Q::?'a::type ⇒ bool) x) (?xs::?'a::type list) ⟹ listall ?Q ?xs›*)) (*top goal: ‹⋀(ts::dB list) (x::nat) i::nat. ⟦listall (λx::dB. NF x ∧ (∀xa::nat. NF (lift x xa))) ts; listall NF ts⟧ ⟹ NF (lift (Var x °° ts) i)› and 1 goal remains*) apply (drule_tac i=i in lift_terms_NF (*‹⟦listall NF ?ts; listall (λt. ∀i. NF (lift t i)) ?ts⟧ ⟹ listall NF (map (λt. lift t ?i) ?ts)›*)) (*goals: 1. ‹⋀ts x i. listall (λx. ∀xa. NF (lift x xa)) ts ⟹ listall (λt. ∀i. NF (lift t i)) ts› 2. ‹⋀ts x i. ⟦listall (λx. ∀xa. NF (lift x xa)) ts; listall NF (map (λt. lift t i) ts)⟧ ⟹ NF (lift (Var x °° ts) i)› discuss goal 1*) apply assumption (*discuss goal 2*) apply (rule_tac m1=x and n1=i in nat_le_dec [THEN disjE] (*‹⟦?m1 < ?n1 ⟹ ?R; ¬ ?m1 < ?n1 ⟹ ?R⟧ ⟹ ?R›*)) (*goals: 1. ‹⋀ts x i. ⟦listall (λx. ∀xa. NF (lift x xa)) ts; listall NF (map (λt. lift t i) ts); x < i⟧ ⟹ NF (lift (Var x °° ts) i)› 2. ‹⋀ts x i. ⟦listall (λx. ∀xa. NF (lift x xa)) ts; listall NF (map (λt. lift t i) ts); ¬ x < i⟧ ⟹ NF (lift (Var x °° ts) i)› discuss goal 1*) apply simp (*top goal: ‹⋀ts x i. ⟦listall (λx. ∀xa. NF (lift x xa)) ts; listall NF (map (λt. lift t i) ts); x < i⟧ ⟹ NF (lift (Var x °° ts) i)› and 2 goals remain*) apply (rule NF.App (*‹listall NF ?ts ⟹ NF (Var ?x °° ?ts)›*)) (*top goal: ‹⋀ts x i. ⟦listall (λx. ∀xa. NF (lift x xa)) ts; listall NF (map (λt. lift t i) ts); x < i⟧ ⟹ NF (Var x °° map (λt. lift t i) ts)› and 2 goals remain*) apply assumption (*discuss goal 2*) apply simp (*top goal: ‹⋀ts x i. ⟦listall (λx. ∀xa. NF (lift x xa)) ts; listall NF (map (λt. lift t i) ts); ¬ x < i⟧ ⟹ NF (lift (Var x °° ts) i)› and 1 goal remains*) apply (rule NF.App (*‹listall NF ?ts ⟹ NF (Var ?x °° ?ts)›*)) (*top goal: ‹⋀ts x i. ⟦listall (λx. ∀xa. NF (lift x xa)) ts; listall NF (map (λt. lift t i) ts); i < Suc x⟧ ⟹ NF (Var (Suc x) °° map (λt. lift t i) ts)› and 1 goal remains*) apply assumption (*proven 2 subgoals*) (*proven 2 subgoals*) (*discuss goal 2*) apply simp (*goal: ‹⋀(t::dB) i::nat. ⟦NF t; ⋀i::nat. NF (lift t i)⟧ ⟹ NF (lift (Abs t) i)›*) apply (rule NF.Abs (*‹NF ?t ⟹ NF (Abs ?t)›*)) (*goal: ‹⋀t i. ⟦NF t; ⋀i. NF (lift t i)⟧ ⟹ NF (Abs (lift t (Suc i)))›*) apply simp (*proven 2 subgoals*) . text ‹ \<^term>‹NF› characterizes exactly the terms that are in normal form. › lemma NF_eq: "NF t = (∀t'. ¬ t →⇩β t')" proof (standard) (*goals: 1. ‹NF t ⟹ ∀t'. ¬ t →⇩β t'› 2. ‹∀t'. ¬ t →⇩β t' ⟹ NF t›*) assume "NF t" (*‹NF (t::dB)›*) then have "⋀t'. ¬ t →⇩β t'" proof (induct) (*goals: 1. ‹⋀ts x t'. listall (λx. NF x ∧ (∀xa. ¬ x →⇩β xa)) ts ⟹ ¬ Var x °° ts →⇩β t'› 2. ‹⋀t t'. ⟦NF t; ⋀t'. ¬ t →⇩β t'⟧ ⟹ ¬ Abs t →⇩β t'›*) case (App ts t) (*‹listall (λx. NF x ∧ (∀xa. ¬ x →⇩β xa)) ts›*) show "?case" (*goal: ‹¬ Var t °° ts →⇩β t'›*) proof (standard) (*goal: ‹Var t °° ts →⇩β t' ⟹ False›*) assume "Var t °° ts →⇩β t'" (*‹Var (t::nat) °° (ts::dB list) →⇩β (t'::dB)›*) then obtain rs where "ts => rs" (*goal: ‹(⋀rs::dB list. (ts::dB list) => rs ⟹ thesis::bool) ⟹ thesis›*) by (iprover dest: head_Var_reduction) with App (*‹listall (λx. NF x ∧ (∀xa. ¬ x →⇩β xa)) ts›*) show False apply (induct rs arbitrary: ts) (*goals: 1. ‹⋀ts::dB list. ⟦listall (λx::dB. NF x ∧ (∀xa::dB. ¬ x →⇩β xa)) ts; ts => []⟧ ⟹ False› 2. ‹⋀(a::dB) (rs::dB list) ts::dB list. ⟦⋀ts::dB list. ⟦listall (λx::dB. NF x ∧ (∀xa::dB. ¬ x →⇩β xa)) ts; ts => rs⟧ ⟹ False; listall (λx::dB. NF x ∧ (∀xa::dB. ¬ x →⇩β xa)) ts; ts => a # rs⟧ ⟹ False› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) by ((auto)[1]) (*proven 2 subgoals*) qed next (*goal: ‹⋀t t'. ⟦NF t; ⋀t'. ¬ t →⇩β t'⟧ ⟹ ¬ Abs t →⇩β t'›*) case (Abs t) (*‹NF t› ‹¬ t →⇩β ?t'›*) show "?case" (*goal: ‹¬ Abs t →⇩β t'›*) proof (standard) (*goal: ‹Abs (t::dB) →⇩β (t'::dB) ⟹ False›*) assume "Abs t →⇩β t'" (*‹Abs (t::dB) →⇩β (t'::dB)›*) then show False using Abs (*‹NF (t::dB)› ‹¬ t →⇩β ?t'›*) apply cases (*goal: ‹False›*) by simp qed qed then show "∀t'. ¬ t →⇩β t'" by standard next (*goal: ‹∀t'. ¬ t →⇩β t' ⟹ NF t›*) assume H: "∀t'. ¬ t →⇩β t'" (*‹∀t'::dB. ¬ (t::dB) →⇩β t'›*) then show "NF t" proof (induct t rule: Apps_dB_induct (*‹⟦⋀n ts. ∀t∈set ts. ?P t ⟹ ?P (Var n °° ts); ⋀u ts. ⟦?P u; ∀t∈set ts. ?P t⟧ ⟹ ?P (Abs u °° ts)⟧ ⟹ ?P ?t›*)) (*goals: 1. ‹⋀n ts. ⟦∀t∈set ts. (∀t'. ¬ t →⇩β t') ⟶ NF t; ∀t'. ¬ Var n °° ts →⇩β t'⟧ ⟹ NF (Var n °° ts)› 2. ‹⋀u ts. ⟦∀t'. ¬ u →⇩β t' ⟹ NF u; ∀t∈set ts. (∀t'. ¬ t →⇩β t') ⟶ NF t; ∀t'. ¬ Abs u °° ts →⇩β t'⟧ ⟹ NF (Abs u °° ts)›*) case (1 n ts) (*‹∀t∈set ts. (∀t'. ¬ t →⇩β t') ⟶ NF t› ‹∀t'. ¬ Var n °° ts →⇩β t'›*) then have "∀ts'. ¬ ts => ts'" by (iprover intro: apps_preserves_betas) with "1"(1) (*‹∀t∈set ts. (∀t'. ¬ t →⇩β t') ⟶ NF t›*) have "listall NF ts" apply (induct ts) (*goals: 1. ‹⟦∀t∈set []. (∀t'. ¬ t →⇩β t') ⟶ NF t; ∀ts'. ¬ [] => ts'⟧ ⟹ listall NF []› 2. ‹⋀a ts. ⟦⟦∀t∈set ts. (∀t'. ¬ t →⇩β t') ⟶ NF t; ∀ts'. ¬ ts => ts'⟧ ⟹ listall NF ts; ∀t∈set (a # ts). (∀t'. ¬ t →⇩β t') ⟶ NF t; ∀ts'. ¬ a # ts => ts'⟧ ⟹ listall NF (a # ts)› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . then show "?case" (*goal: ‹NF (Var n °° ts)›*) by (rule NF.App (*‹listall NF ?ts ⟹ NF (Var ?x °° ?ts)›*)) next (*goal: ‹⋀u ts. ⟦∀t'. ¬ u →⇩β t' ⟹ NF u; ∀t∈set ts. (∀t'. ¬ t →⇩β t') ⟶ NF t; ∀t'. ¬ Abs u °° ts →⇩β t'⟧ ⟹ NF (Abs u °° ts)›*) case (2 u ts) (*‹∀t'::dB. ¬ (u::dB) →⇩β t' ⟹ NF u› ‹∀t∈set ts. (∀t'. ¬ t →⇩β t') ⟶ NF t› ‹∀t'. ¬ Abs u °° ts →⇩β t'›*) show "?case" (*goal: ‹NF (Abs u °° ts)›*) proof (cases ts) (*goals: 1. ‹ts = [] ⟹ NF (Abs u °° ts)› 2. ‹⋀a list. ts = a # list ⟹ NF (Abs u °° ts)›*) case Nil (*‹(ts::dB list) = []›*) from "2" (*‹∀t'::dB. ¬ (u::dB) →⇩β t' ⟹ NF u› ‹∀t∈set ts. (∀t'. ¬ t →⇩β t') ⟶ NF t› ‹∀t'. ¬ Abs u °° ts →⇩β t'›*) have "∀u'. ¬ u →⇩β u'" by (auto intro: apps_preserves_beta (*‹?r →⇩β ?s ⟹ ?r °° ?ss →⇩β ?s °° ?ss›*)) then have "NF u" by (rule 2 (*‹∀t'. ¬ u →⇩β t' ⟹ NF u› ‹∀t∈set ts. (∀t'. ¬ t →⇩β t') ⟶ NF t› ‹∀t'. ¬ Abs u °° ts →⇩β t'›*)) then have "NF (Abs u)" by (rule NF.Abs (*‹NF ?t ⟹ NF (Abs ?t)›*)) with Nil (*‹ts = []›*) show "?thesis" (*goal: ‹NF (Abs u °° ts)›*) by simp next (*goal: ‹⋀(a::dB) list::dB list. (ts::dB list) = a # list ⟹ NF (Abs (u::dB) °° ts)›*) case (Cons r rs) (*‹ts = r # rs›*) have "Abs u ° r →⇩β u[r/0]" by standard then have "Abs u ° r °° rs →⇩β u[r/0] °° rs" by (rule apps_preserves_beta (*‹?r →⇩β ?s ⟹ ?r °° ?ss →⇩β ?s °° ?ss›*)) with Cons (*‹ts = r # rs›*) have "Abs u °° ts →⇩β u[r/0] °° rs" by simp with "2" (*‹∀t'. ¬ u →⇩β t' ⟹ NF u› ‹∀t∈set ts. (∀t'. ¬ t →⇩β t') ⟶ NF t› ‹∀t'. ¬ Abs u °° ts →⇩β t'›*) show "?thesis" (*goal: ‹NF (Abs (u::dB) °° (ts::dB list))›*) by iprover qed qed qed end
{ "path": "Isabelle2024/src/HOL/Proofs/Lambda/NormalForm.thy", "repo": "Isabelle2024", "sha": "0e4026f44142b737f7eaa92340eb52c4c19af8bff3ae7596d7b0b16804e8facb" }
subsection‹ScottVariantHOMLposs.thy (Figure 19 of \cite{J75})› text‹Scott’s variant of Gödel’s ontological proof is still valid when using possibilist quantifiers only.› theory ScottVariantHOMLposs imports HOMLinHOL ModalFilter begin consts PositiveProperty::"(e⇒σ)⇒σ" ("P") axiomatization where A1: "⌊❙¬P φ ❙↔ P ❙~φ⌋" axiomatization where A2: "⌊P φ ❙∧ ❙□(❙∀y. φ y ❙⊃ ψ y) ❙⊃ P ψ⌋" theorem T1: "⌊P φ ❙⊃ ❙◇(❙∃x. φ x)⌋" using A1 (*‹⌊λw::i. (❙¬(?φ::e ⇒ i ⇒ bool) ❙∈ P) w = (❙~?φ ❙∈ P) w⌋›*) A2 (*‹⌊?φ ❙∈ P ❙∧ ❙□(λv. ∀x. (?φ x ❙⊃ ?ψ x) v) ❙⊃ ?ψ ❙∈ P⌋›*) by blast definition God ("G") where "G x ≡ ❙∀φ. P φ ❙⊃ φ x" axiomatization where A3: "⌊P G⌋" theorem Coro: "⌊❙◇(❙∃x. G x)⌋" using A3 (*‹⌊G ❙∈ P⌋›*) T1 (*‹⌊?φ ❙∈ P ❙⊃ ❙◇?φ ❙∈ Mexipossb⌋›*) by blast axiomatization where A4: "⌊P φ ❙⊃ ❙□ P φ⌋" definition Ess ("_Ess._") where "φ Ess. x ≡ φ x ❙∧ (❙∀ψ. ψ x ❙⊃ ❙□(❙∀y::e. φ y ❙⊃ ψ y))" theorem T2: "⌊G x ❙⊃ G Ess. x⌋" using A1 (*‹⌊λw. (❙¬?φ ❙∈ P) w = (❙~?φ ❙∈ P) w⌋›*) A4 (*‹⌊?φ ❙∈ P ❙⊃ ❙□?φ ❙∈ P⌋›*) Ess_def (*‹?φEss.?x ≡ λw. ?φ ?x w ∧ (∀x. (x ?x ❙⊃ ❙□(λv. ∀xa. (?φ xa ❙⊃ x xa) v)) w)›*) God_def (*‹G ?x ≡ λw. ∀x. (x ❙∈ P ❙⊃ x ?x) w›*) by fastforce definition NecExist ("NE") where "NE x ≡ ❙∀φ. φ Ess. x ❙⊃ ❙□(❙∃x. φ x)" axiomatization where A5: "⌊P NE⌋" lemma True nitpick[satisfy,card=1,eval="⌊P (λx.❙⊥)⌋"] oops ―‹One model found of cardinality one› theorem T3: "⌊❙□(❙∃x. G x)⌋" ―‹sledgehammer(A5 Coro God\_def NecExist\_def Rsymm T2)› ―‹Proof found› proof (-) (*goal: ‹⌊❙□G ❙∈ Mexipossb⌋›*) have 1: "⌊(G x ❙⊃ NE x) ❙∧ (G Ess. x ❙⊃ ❙□(❙∃x. G x))⌋" using A5 (*‹⌊NE ❙∈ P⌋›*) Ess_def (*‹?φ::e ⇒ i ⇒ boolEss.?x::e ≡ λw::i. ?φ ?x w ∧ (∀x::e ⇒ i ⇒ bool. (x ?x ❙⊃ ❙□(λv::i. ∀xa::e. (?φ xa ❙⊃ x xa) v)) w)›*) God_def (*‹G (?x::e) ≡ λw::i. ∀x::e ⇒ i ⇒ bool. (x ❙∈ P ❙⊃ x ?x) w›*) NecExist_def (*‹NE ?x ≡ λw. ∀x. (xEss.?x ❙⊃ ❙□x ❙∈ Mexipossb) w›*) by smt hence 2: "⌊(❙∃x. G x) ❙⊃ ❙□(❙∃x. G x)⌋" using A5 (*‹⌊NE ❙∈ P⌋›*) God_def (*‹G ?x ≡ λw. ∀x. (x ❙∈ P ❙⊃ x ?x) w›*) NecExist_def (*‹NE ?x ≡ λw. ∀x. (xEss.?x ❙⊃ ❙□x ❙∈ Mexipossb) w›*) T2 (*‹⌊G ?x ❙⊃ GEss.?x⌋›*) by smt hence 3: "⌊❙◇(❙∃x. G x) ❙⊃ (❙◇(❙□(❙∃x. G x)) ❙⊃ ❙□(❙∃x. G x))⌋" using Rsymm (*‹⌊λx. (❙□(λy. y❙rx)) x⌋›*) by blast thus "?thesis" (*goal: ‹⌊❙□G ❙∈ Mexipossb⌋›*) using "2" (*‹⌊G ❙∈ Mexipossb ❙⊃ ❙□G ❙∈ Mexipossb⌋›*) Coro (*‹⌊❙◇G ❙∈ Mexipossb⌋›*) by blast qed lemma MC: "⌊φ ❙⊃ ❙□φ⌋" ―‹sledgehammer(A1 A4 God\_def Rsymm T3)› ―‹Proof found› proof (-) (*goal: ‹⌊(φ::i ⇒ bool) ❙⊃ ❙□φ⌋›*) { fix w fix Q have 1: "∀x.(G x w ⟶ (❙∀Z. Z x ❙⊃ ❙□(❙∀z.((G z) ❙⊃ (Z z)))) w)" using A1 (*‹⌊λw. (❙¬?φ ❙∈ P) w = (❙~?φ ❙∈ P) w⌋›*) A4 (*‹⌊?φ ❙∈ P ❙⊃ ❙□?φ ❙∈ P⌋›*) God_def (*‹G ?x ≡ λw. ∀x. (x ❙∈ P ❙⊃ x ?x) w›*) by smt have 2: "(∃x. G x w)⟶((Q ❙⊃ ❙□(❙∀z.((G z) ❙⊃ Q))) w)" using "1" (*‹∀x::e. G x (w::i) ⟶ (∀xa::e ⇒ i ⇒ bool. (xa x ❙⊃ ❙□(λv::i. ∀x::e. (G x ❙⊃ xa x) v)) w)›*) by force have 3: "(Q ❙⊃ ❙□Q) w" using "2" (*‹(G ❙∈ Mexipossb ❙⊃ Q ❙⊃ ❙□(λv. ∀x. (G x ❙⊃ Q) v)) w›*) T3 (*‹⌊❙□G ❙∈ Mexipossb⌋›*) Rsymm (*‹⌊λx. (❙□(λy. y❙rx)) x⌋›*) by blast } thus "?thesis" (*goal: ‹⌊(φ::i ⇒ bool) ❙⊃ ❙□φ⌋›*) by auto qed lemma PosProps: "⌊P (λx.❙⊤) ❙∧ P (λx. x ❙= x)⌋" using A1 (*‹⌊λw::i. (❙¬(?φ::e ⇒ i ⇒ bool) ❙∈ P) w = (❙~?φ ❙∈ P) w⌋›*) A2 (*‹⌊?φ ❙∈ P ❙∧ ❙□(λv. ∀x. (?φ x ❙⊃ ?ψ x) v) ❙⊃ ?ψ ❙∈ P⌋›*) by blast lemma NegProps: "⌊❙¬P(λx.❙⊥) ❙∧ ❙¬P(λx. x ❙≠ x)⌋" using A1 (*‹⌊λw. (❙¬?φ ❙∈ P) w = (❙~?φ ❙∈ P) w⌋›*) A2 (*‹⌊?φ ❙∈ P ❙∧ ❙□(λv. ∀x. (?φ x ❙⊃ ?ψ x) v) ❙⊃ ?ψ ❙∈ P⌋›*) by blast lemma UniqueEss1: "⌊φ Ess. x ❙∧ ψ Ess. x ❙⊃ ❙□(❙∀y. φ y ❙↔ ψ y)⌋" using Ess_def (*‹?φEss.?x ≡ λw. ?φ ?x w ∧ (∀x. (x ?x ❙⊃ ❙□(λv. ∀xa. (?φ xa ❙⊃ x xa) v)) w)›*) by smt lemma UniqueEss2: "⌊φ Ess. x ❙∧ ψ Ess. x ❙⊃ ❙□(φ ❙≡ ψ)⌋" nitpick[card i=2] oops ―‹Countermodel found› lemma UniqueEss3: "⌊φ Ess. x ❙⊃ ❙□(❙∀y. φ y ❙⊃ y ❙≡ x)⌋" using Ess_def (*‹?φEss.?x ≡ λw. ?φ ?x w ∧ (∀x. (x ?x ❙⊃ ❙□(λv. ∀xa. (?φ xa ❙⊃ x xa) v)) w)›*) MC (*‹⌊?φ ❙⊃ ❙□?φ⌋›*) by auto lemma Monotheism: "⌊G x ❙∧ G y ❙⊃ x ❙≡ y⌋" using A1 (*‹⌊λw. (❙¬?φ ❙∈ P) w = (❙~?φ ❙∈ P) w⌋›*) God_def (*‹G ?x ≡ λw. ∀x. (x ❙∈ P ❙⊃ x ?x) w›*) by smt lemma Filter: "⌊FilterP P⌋" using A1 (*‹⌊λw. (❙¬?φ ❙∈ P) w = (❙~?φ ❙∈ P) w⌋›*) God_def (*‹G (?x::e) ≡ λw::i. ∀x::e ⇒ i ⇒ bool. (x ❙∈ P ❙⊃ x ?x) w›*) Rsymm (*‹⌊λx. (❙□(λy. y❙rx)) x⌋›*) T1 (*‹⌊?φ ❙∈ P ❙⊃ ❙◇?φ ❙∈ Mexipossb⌋›*) T3 (*‹⌊❙□G ❙∈ Mexipossb⌋›*) by (smt (verit, best)) lemma UltraFilter: "⌊UFilterP P⌋" using Filter (*‹⌊λw. ((❙U ❙∈ P ❙∧ ❙¬❙∅ ❙∈ P) w ∧ (∀x xa. (x ❙∈ P) w ∧ (∀xb. (x xb ❙⊃ xa xb) w) ⟶ (xa ❙∈ P) w)) ∧ (∀x xa. (x ❙∈ P ❙∧ xa ❙∈ P ❙⊃ (x ❙. xa) ❙∈ P) w)⌋›*) A1 (*‹⌊λw. (❙¬?φ ❙∈ P) w = (❙~?φ ❙∈ P) w⌋›*) by blast lemma True nitpick[satisfy,card=1,eval="⌊P (λx.❙⊥)⌋"] oops ―‹One model found of cardinality one› end
{ "path": "afp-2025-02-12/thys/Notes_On_Goedels_Ontological_Argument/ScottVariantHOMLposs.thy", "repo": "afp-2025-02-12", "sha": "5d65ca116fc95244ff8ed5d290c57e02f1e2faebdb1067701fb66c4db604cd89" }
(* Title: HOL/MicroJava/DFA/LBVSpec.thy Author: Gerwin Klein Copyright 1999 Technische Universitaet Muenchen *) section ‹The Lightweight Bytecode Verifier› theory LBVSpec imports SemilatAlg Opt begin type_synonym 's certificate = "'s list" primrec merge :: "'s certificate ⇒ 's binop ⇒ 's ord ⇒ 's ⇒ nat ⇒ (nat × 's) list ⇒ 's ⇒ 's" where "merge cert f r T pc [] x = x" | "merge cert f r T pc (s#ss) x = merge cert f r T pc ss (let (pc',s') = s in if pc'=pc+1 then s' +_f x else if s' <=_r (cert!pc') then x else T)" definition wtl_inst :: "'s certificate ⇒ 's binop ⇒ 's ord ⇒ 's ⇒ 's step_type ⇒ nat ⇒ 's ⇒ 's" where "wtl_inst cert f r T step pc s ≡ merge cert f r T pc (step pc s) (cert!(pc+1))" definition wtl_cert :: "'s certificate ⇒ 's binop ⇒ 's ord ⇒ 's ⇒ 's ⇒ 's step_type ⇒ nat ⇒ 's ⇒ 's" where "wtl_cert cert f r T B step pc s ≡ if cert!pc = B then wtl_inst cert f r T step pc s else if s <=_r (cert!pc) then wtl_inst cert f r T step pc (cert!pc) else T" primrec wtl_inst_list :: "'a list ⇒ 's certificate ⇒ 's binop ⇒ 's ord ⇒ 's ⇒ 's ⇒ 's step_type ⇒ nat ⇒ 's ⇒ 's" where "wtl_inst_list [] cert f r T B step pc s = s" | "wtl_inst_list (i#is) cert f r T B step pc s = (let s' = wtl_cert cert f r T B step pc s in if s' = T ∨ s = T then T else wtl_inst_list is cert f r T B step (pc+1) s')" definition cert_ok :: "'s certificate ⇒ nat ⇒ 's ⇒ 's ⇒ 's set ⇒ bool" where "cert_ok cert n T B A ≡ (∀i < n. cert!i ∈ A ∧ cert!i ≠ T) ∧ (cert!n = B)" definition bottom :: "'a ord ⇒ 'a ⇒ bool" where "bottom r B ≡ ∀x. B <=_r x" locale lbv = Semilat + fixes T :: "'a" ("⊤") fixes B :: "'a" ("⊥") fixes step :: "'a step_type" assumes top: "top r ⊤" assumes T_A: "⊤ ∈ A" assumes bot: "bottom r ⊥" assumes B_A: "⊥ ∈ A" fixes merge :: "'a certificate ⇒ nat ⇒ (nat × 'a) list ⇒ 'a ⇒ 'a" defines mrg_def: "merge cert ≡ LBVSpec.merge cert f r ⊤" fixes wti :: "'a certificate ⇒ nat ⇒ 'a ⇒ 'a" defines wti_def: "wti cert ≡ wtl_inst cert f r ⊤ step" fixes wtc :: "'a certificate ⇒ nat ⇒ 'a ⇒ 'a" defines wtc_def: "wtc cert ≡ wtl_cert cert f r ⊤ ⊥ step" fixes wtl :: "'b list ⇒ 'a certificate ⇒ nat ⇒ 'a ⇒ 'a" defines wtl_def: "wtl ins cert ≡ wtl_inst_list ins cert f r ⊤ ⊥ step" lemma (in lbv) wti: "wti c pc s ≡ merge c pc (step pc s) (c!(pc+1))" by (simp add: wti_def (*‹wti ?cert ≡ wtl_inst ?cert f r ⊤ step›*) mrg_def (*‹merge ?cert ≡ merge ?cert f r ⊤›*) wtl_inst_def (*‹wtl_inst ?cert ?f ?r ?T ?step ?pc ?s ≡ merge ?cert ?f ?r ?T ?pc (?step ?pc ?s) (?cert ! (?pc + 1))›*)) lemma (in lbv) wtc: "wtc c pc s ≡ if c!pc = ⊥ then wti c pc s else if s <=_r c!pc then wti c pc (c!pc) else ⊤" by (unfold wtc_def (*‹wtc ?cert ≡ wtl_cert ?cert f r ⊤ ⊥ step›*) wti_def (*‹wti ?cert ≡ wtl_inst ?cert f r ⊤ step›*) wtl_cert_def (*‹wtl_cert ?cert ?f ?r ?T ?B ?step ?pc ?s ≡ if ?cert ! ?pc = ?B then wtl_inst ?cert ?f ?r ?T ?step ?pc ?s else if ?s ⊑⇘?r⇙ ?cert ! ?pc then wtl_inst ?cert ?f ?r ?T ?step ?pc (?cert ! ?pc) else ?T›*)) lemma cert_okD1 [intro?]: "cert_ok c n T B A ⟹ pc < n ⟹ c!pc ∈ A" apply (unfold cert_ok_def (*‹cert_ok ?cert ?n ?T ?B ?A ≡ (∀i<?n. ?cert ! i ∈ ?A ∧ ?cert ! i ≠ ?T) ∧ ?cert ! ?n = ?B›*)) (*goal: ‹⟦cert_ok c n T B A; pc < n⟧ ⟹ c ! pc ∈ A›*) by fast lemma cert_okD2 [intro?]: "cert_ok c n T B A ⟹ c!n = B" by (simp add: cert_ok_def (*‹cert_ok (?cert::?'s list) (?n::nat) (?T::?'s) (?B::?'s) (?A::?'s set) ≡ (∀i<?n. ?cert ! i ∈ ?A ∧ ?cert ! i ≠ ?T) ∧ ?cert ! ?n = ?B›*)) lemma cert_okD3 [intro?]: "cert_ok c n T B A ⟹ B ∈ A ⟹ pc < n ⟹ c!Suc pc ∈ A" apply (drule Suc_leI (*‹?m < ?n ⟹ Suc ?m ≤ ?n›*)) (*goal: ‹⟦cert_ok c n T B A; B ∈ A; pc < n⟧ ⟹ c ! Suc pc ∈ A›*) by (auto simp add: le_eq_less_or_eq (*‹((?m::nat) ≤ (?n::nat)) = (?m < ?n ∨ ?m = ?n)›*) dest: cert_okD1 (*‹⟦cert_ok (?c::?'a list) (?n::nat) (?T::?'a) (?B::?'a) (?A::?'a set); (?pc::nat) < ?n⟧ ⟹ ?c ! ?pc ∈ ?A›*) cert_okD2 (*‹cert_ok (?c::?'a list) (?n::nat) (?T::?'a) (?B::?'a) (?A::?'a set) ⟹ ?c ! ?n = ?B›*)) lemma cert_okD4 [intro?]: "cert_ok c n T B A ⟹ pc < n ⟹ c!pc ≠ T" by (simp add: cert_ok_def (*‹cert_ok ?cert ?n ?T ?B ?A ≡ (∀i<?n. ?cert ! i ∈ ?A ∧ ?cert ! i ≠ ?T) ∧ ?cert ! ?n = ?B›*)) declare Let_def [simp] subsection "more semilattice lemmas" lemma (in lbv) sup_top [simp, elim]: assumes x: "x ∈ A" shows "x +_f ⊤ = ⊤" proof (-) (*goal: ‹x ⊔⇘f⇙ ⊤ = ⊤›*) from top (*‹Semilat.top (r::'a ⇒ 'a ⇒ bool) ⊤›*) have "x +_f ⊤ <=_r ⊤" by standard moreover from x (*‹x ∈ A›*) T_A (*‹⊤ ∈ (A::'a::type set)›*) have "⊤ <=_r x +_f ⊤" by standard ultimately show "?thesis" (*goal: ‹x ⊔⇘f⇙ ⊤ = ⊤›*) by standard qed lemma (in lbv) plusplussup_top [simp, elim]: "set xs ⊆ A ⟹ xs ++_f ⊤ = ⊤" apply (induct xs) (*goals: 1. ‹set [] ⊆ A ⟹ [] ++_f ⊤ = ⊤› 2. ‹⋀a xs. ⟦set xs ⊆ A ⟹ xs ++_f ⊤ = ⊤; set (a # xs) ⊆ A⟧ ⟹ a # xs ++_f ⊤ = ⊤› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . lemma (in Semilat) pp_ub1': assumes S: "snd`set S ⊆ A" assumes y: "y ∈ A" and ab: "(a, b) ∈ set S" shows "b <=_r map snd [(p', t') ← S . p' = a] ++_f y" proof (-) (*goal: ‹(b::'a) ⊑⇘r::'a ⇒ 'a ⇒ bool⇙ map snd (filter (λ(p'::'b, t'::'a). p' = (a::'b)) (S::('b × 'a) list)) ++_(f::'a ⇒ 'a ⇒ 'a) (y::'a)›*) from S (*‹snd ` set S ⊆ A›*) have "∀(x,y) ∈ set S. y ∈ A" by auto with semilat (*‹semilat (A, r, f)›*) y (*‹y ∈ A›*) ab (*‹(a, b) ∈ set S›*) show "?thesis" (*goal: ‹(b::'a::type) ⊑⇘r::'a::type ⇒ 'a::type ⇒ bool⇙ map snd (filter (λ(p'::'b::type, t'::'a::type). p' = (a::'b::type)) (S::('b::type × 'a::type) list)) ++_(f::'a::type ⇒ 'a::type ⇒ 'a::type) (y::'a::type)›*) apply - (*goal: ‹b ⊑⇘r⇙ map snd (filter (λ(p', t'). p' = a) S) ++_f y›*) apply (rule ub1' (*‹⟦semilat (?A::?'a set, ?r::?'a ⇒ ?'a ⇒ bool, ?f::?'a ⇒ ?'a ⇒ ?'a); ∀(p::?'b, s::?'a)∈set (?S::(?'b × ?'a) list). s ∈ ?A; (?y::?'a) ∈ ?A; (?a::?'b, ?b::?'a) ∈ set ?S⟧ ⟹ ?b ⊑⇘?r⇙ map snd (filter (λ(p'::?'b, t'::?'a). p' = ?a) ?S) ++_?f ?y›*)) (*goals: 1. ‹⟦semilat (A, r, f); y ∈ A; (a, b) ∈ set S; ∀(x, y)∈set S. y ∈ A⟧ ⟹ semilat (?A4, r, f)› 2. ‹⟦semilat (A, r, f); y ∈ A; (a, b) ∈ set S; ∀(x, y)∈set S. y ∈ A⟧ ⟹ ∀(p, s)∈set S. s ∈ ?A4› 3. ‹⟦semilat (A, r, f); y ∈ A; (a, b) ∈ set S; ∀(x, y)∈set S. y ∈ A⟧ ⟹ y ∈ ?A4› 4. ‹⟦semilat (A, r, f); y ∈ A; (a, b) ∈ set S; ∀(x, y)∈set S. y ∈ A⟧ ⟹ (a, b) ∈ set S› 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 (in lbv) bottom_le [simp, intro]: "⊥ <=_r x" using bot (*‹bottom r ⊥›*) by (simp add: bottom_def (*‹bottom (?r::?'a ⇒ ?'a ⇒ bool) (?B::?'a) ≡ ∀x::?'a. ?B ⊑⇘?r⇙ x›*)) lemma (in lbv) le_bottom [simp]: "x <=_r ⊥ = (x = ⊥)" by (blast intro: antisym_r (*‹⟦?x ⊑⇘r⇙ ?y; ?y ⊑⇘r⇙ ?x⟧ ⟹ ?x = ?y›*)) subsection "merge" lemma (in lbv) merge_Nil [simp]: "merge c pc [] x = x" by (simp add: mrg_def (*‹merge ?cert ≡ merge ?cert f r ⊤›*)) lemma (in lbv) merge_Cons [simp]: "merge c pc (l#ls) x = merge c pc ls (if fst l=pc+1 then snd l +_f x else if snd l <=_r (c!fst l) then x else ⊤)" by (simp add: mrg_def (*‹(merge::'a list ⇒ nat ⇒ (nat × 'a) list ⇒ 'a ⇒ 'a) (?cert::'a list) ≡ merge ?cert (f::'a ⇒ 'a ⇒ 'a) (r::'a ⇒ 'a ⇒ bool) ⊤›*) split_beta (*‹(case ?prod::?'a × ?'b of (x::?'a, xa::?'b) ⇒ (?f::?'a ⇒ ?'b ⇒ ?'c) x xa) = ?f (fst ?prod) (snd ?prod)›*)) lemma (in lbv) merge_Err [simp]: "snd`set ss ⊆ A ⟹ merge c pc ss ⊤ = ⊤" apply (induct ss) (*goals: 1. ‹snd ` set [] ⊆ A ⟹ merge c pc [] ⊤ = ⊤› 2. ‹⋀a ss. ⟦snd ` set ss ⊆ A ⟹ merge c pc ss ⊤ = ⊤; snd ` set (a # ss) ⊆ A⟧ ⟹ merge c pc (a # ss) ⊤ = ⊤› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . lemma (in lbv) merge_not_top: "⋀x. snd`set ss ⊆ A ⟹ merge c pc ss x ≠ ⊤ ⟹ ∀(pc',s') ∈ set ss. (pc' ≠ pc+1 ⟶ s' <=_r (c!pc'))" (is "⋀x. ?set ss ⟹ ?merge ss x ⟹ ?P ss") proof (induct ss) (*goals: 1. ‹⋀x. ⟦snd ` set [] ⊆ A; merge c pc [] x ≠ ⊤⟧ ⟹ ∀(pc', s')∈set []. pc' ≠ pc + 1 ⟶ s' ⊑⇘r⇙ c ! pc'› 2. ‹⋀a ss x. ⟦⋀x. ⟦snd ` set ss ⊆ A; merge c pc ss x ≠ ⊤⟧ ⟹ ∀(pc', s')∈set ss. pc' ≠ pc + 1 ⟶ s' ⊑⇘r⇙ c ! pc'; snd ` set (a # ss) ⊆ A; merge c pc (a # ss) x ≠ ⊤⟧ ⟹ ∀(pc', s')∈set (a # ss). pc' ≠ pc + 1 ⟶ s' ⊑⇘r⇙ c ! pc'›*) show "?P []" by simp next (*goal: ‹⋀a ss x. ⟦⋀x. ⟦snd ` set ss ⊆ A; merge c pc ss x ≠ ⊤⟧ ⟹ ∀(pc', s')∈set ss. pc' ≠ pc + 1 ⟶ s' ⊑⇘r⇙ c ! pc'; snd ` set (a # ss) ⊆ A; merge c pc (a # ss) x ≠ ⊤⟧ ⟹ ∀(pc', s')∈set (a # ss). pc' ≠ pc + 1 ⟶ s' ⊑⇘r⇙ c ! pc'›*) fix x and ls and l assume "?set (l#ls)" (*‹snd ` set ((l::nat × 'a) # (ls::(nat × 'a) list)) ⊆ (A::'a set)›*) then obtain set: "snd`set ls ⊆ A" (*goal: ‹(snd ` set ls ⊆ A ⟹ thesis) ⟹ thesis›*) by simp assume merge: "?merge (l#ls) x" (*‹(merge::'a list ⇒ nat ⇒ (nat × 'a) list ⇒ 'a ⇒ 'a) (c::'a list) (pc::nat) ((l::nat × 'a) # (ls::(nat × 'a) list)) (x::'a) ≠ ⊤›*) moreover obtain pc' and s' where l: "l = (pc',s')" (*goal: ‹(⋀pc' s'. l = (pc', s') ⟹ thesis) ⟹ thesis›*) by (cases l) ultimately obtain x' where merge': "?merge ls x'" (*goal: ‹(⋀x'. merge c pc ls x' ≠ ⊤ ⟹ thesis) ⟹ thesis›*) by simp assume "⋀x. ?set ls ⟹ ?merge ls x ⟹ ?P ls" (*‹⟦snd ` set (ls::(nat × 'a) list) ⊆ (A::'a set); (merge::'a list ⇒ nat ⇒ (nat × 'a) list ⇒ 'a ⇒ 'a) (c::'a list) (pc::nat) ls (?x::'a) ≠ ⊤⟧ ⟹ ∀a::nat × 'a∈set ls. case a of (pc'::nat, s'::'a) ⇒ pc' ≠ pc + (1::nat) ⟶ s' ⊑⇘r::'a ⇒ 'a ⇒ bool⇙ c ! pc'›*) hence "?P ls" using set (*‹snd ` set (ls::(nat × 'a) list) ⊆ (A::'a set)›*) merge' (*‹merge c pc ls x' ≠ ⊤›*) . moreover from merge (*‹merge c pc (l # ls) x ≠ ⊤›*) set (*‹snd ` set ls ⊆ A›*) have "pc' ≠ pc+1 ⟶ s' <=_r (c!pc')" by (simp add: l (*‹l = (pc', s')›*) split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*)) ultimately show "?P (l#ls)" by (simp add: l (*‹(l::nat × 'a) = (pc'::nat, s'::'a)›*)) qed lemma (in lbv) merge_def: shows "⋀x. x ∈ A ⟹ snd`set ss ⊆ A ⟹ merge c pc ss x = (if ∀(pc',s') ∈ set ss. pc'≠pc+1 ⟶ s' <=_r c!pc' then map snd [(p',t') ← ss. p'=pc+1] ++_f x else ⊤)" (is "⋀x. _ ⟹ _ ⟹ ?merge ss x = ?if ss x" is "⋀x. _ ⟹ _ ⟹ ?P ss x") proof (induct ss) (*goals: 1. ‹⋀x. ⟦x ∈ A; snd ` set [] ⊆ A⟧ ⟹ merge c pc [] x = (if ∀(pc', s')∈set []. pc' ≠ pc + 1 ⟶ s' ⊑⇘r⇙ c ! pc' then map snd (filter (λ(p', t'). p' = pc + 1) []) ++_f x else ⊤)› 2. ‹⋀a ss x. ⟦⋀x. ⟦x ∈ A; snd ` set ss ⊆ A⟧ ⟹ merge c pc ss x = (if ∀(pc', s')∈set ss. pc' ≠ pc + 1 ⟶ s' ⊑⇘r⇙ c ! pc' then map snd (filter (λ(p', t'). p' = pc + 1) ss) ++_f x else ⊤); x ∈ A; snd ` set (a # ss) ⊆ A⟧ ⟹ merge c pc (a # ss) x = (if ∀(pc', s')∈set (a # ss). pc' ≠ pc + 1 ⟶ s' ⊑⇘r⇙ c ! pc' then map snd (filter (λ(p', t'). p' = pc + 1) (a # ss)) ++_f x else ⊤)›*) fix x show "?P [] x" by simp next (*goal: ‹⋀a ss x. ⟦⋀x. ⟦x ∈ A; snd ` set ss ⊆ A⟧ ⟹ merge c pc ss x = (if ∀(pc', s')∈set ss. pc' ≠ pc + 1 ⟶ s' ⊑⇘r⇙ c ! pc' then map snd (filter (λ(p', t'). p' = pc + 1) ss) ++_f x else ⊤); x ∈ A; snd ` set (a # ss) ⊆ A⟧ ⟹ merge c pc (a # ss) x = (if ∀(pc', s')∈set (a # ss). pc' ≠ pc + 1 ⟶ s' ⊑⇘r⇙ c ! pc' then map snd (filter (λ(p', t'). p' = pc + 1) (a # ss)) ++_f x else ⊤)›*) fix x assume x: "x ∈ A" (*‹(x::'a) ∈ (A::'a set)›*) fix l :: "nat × 'a" and ls assume "snd`set (l#ls) ⊆ A" (*‹snd ` set ((l::nat × 'a) # (ls::(nat × 'a) list)) ⊆ (A::'a set)›*) then obtain l: "snd l ∈ A" and ls: "snd`set ls ⊆ A" (*goal: ‹(⟦snd l ∈ A; snd ` set ls ⊆ A⟧ ⟹ thesis) ⟹ thesis›*) by auto assume "⋀x. x ∈ A ⟹ snd`set ls ⊆ A ⟹ ?P ls x" (*‹⟦(?x::'a) ∈ (A::'a set); snd ` set (ls::(nat × 'a) list) ⊆ A⟧ ⟹ (merge::'a list ⇒ nat ⇒ (nat × 'a) list ⇒ 'a ⇒ 'a) (c::'a list) (pc::nat) ls ?x = (if ∀a::nat × 'a∈set ls. case a of (pc'::nat, s'::'a) ⇒ pc' ≠ pc + (1::nat) ⟶ s' ⊑⇘r::'a ⇒ 'a ⇒ bool⇙ c ! pc' then map snd (filter (λa::nat × 'a. case a of (p'::nat, t'::'a) ⇒ p' = pc + (1::nat)) ls) ++_(f::'a ⇒ 'a ⇒ 'a) ?x else ⊤)›*) hence IH: "⋀x. x ∈ A ⟹ ?P ls x" using ls (*‹snd ` set ls ⊆ A›*) by iprover obtain pc' and s' where [simp]: "l = (pc',s')" (*goal: ‹(⋀pc' s'. l = (pc', s') ⟹ thesis) ⟹ thesis›*) by (cases l) hence "?merge (l#ls) x = ?merge ls (if pc'=pc+1 then s' +_f x else if s' <=_r c!pc' then x else ⊤)" (is "?merge (l#ls) x = ?merge ls ?if'") by simp also (*calculation: ‹merge c pc (l # ls) x = merge c pc ls (if pc' = pc + 1 then s' ⊔⇘f⇙ x else if s' ⊑⇘r⇙ c ! pc' then x else ⊤)›*) have "… = ?if ls ?if'" proof (-) (*goal: ‹merge c pc ls (if pc' = pc + 1 then s' ⊔⇘f⇙ x else if s' ⊑⇘r⇙ c ! pc' then x else ⊤) = (if ∀a∈set ls. case a of (pc', s') ⇒ pc' ≠ pc + 1 ⟶ s' ⊑⇘r⇙ c ! pc' then map snd (filter (λa. case a of (p', t') ⇒ p' = pc + 1) ls) ++_f (if pc' = pc + 1 then s' ⊔⇘f⇙ x else if s' ⊑⇘r⇙ c ! pc' then x else ⊤) else ⊤)›*) from l (*‹snd l ∈ A›*) have "s' ∈ A" by simp with x (*‹(x::'a::type) ∈ (A::'a::type set)›*) have "s' +_f x ∈ A" by simp with x (*‹x ∈ A›*) T_A (*‹⊤ ∈ A›*) have "?if' ∈ A" by auto hence "?P ls ?if'" by (rule IH (*‹?x ∈ A ⟹ merge c pc ls ?x = (if ∀a∈set ls. case a of (pc', s') ⇒ pc' ≠ pc + 1 ⟶ s' ⊑⇘r⇙ c ! pc' then map snd (filter (λa. case a of (p', t') ⇒ p' = pc + 1) ls) ++_f ?x else ⊤)›*)) thus "?thesis" (*goal: ‹(merge::'a list ⇒ nat ⇒ (nat × 'a) list ⇒ 'a ⇒ 'a) (c::'a list) (pc::nat) (ls::(nat × 'a) list) (if (pc'::nat) = pc + (1::nat) then (s'::'a) ⊔⇘f::'a ⇒ 'a ⇒ 'a⇙ (x::'a) else if s' ⊑⇘r::'a ⇒ 'a ⇒ bool⇙ c ! pc' then x else ⊤) = (if ∀a::nat × 'a∈set ls. case a of (pc'::nat, s'::'a) ⇒ pc' ≠ pc + (1::nat) ⟶ s' ⊑⇘r⇙ c ! pc' then map snd (filter (λa::nat × 'a. case a of (p'::nat, t'::'a) ⇒ p' = pc + (1::nat)) ls) ++_f (if pc' = pc + (1::nat) then s' ⊔⇘f⇙ x else if s' ⊑⇘r⇙ c ! pc' then x else ⊤) else ⊤)›*) by simp qed also (*calculation: ‹merge c pc (l # ls) x = (if ∀a∈set ls. case a of (pc', s') ⇒ pc' ≠ pc + 1 ⟶ s' ⊑⇘r⇙ c ! pc' then map snd (filter (λa. case a of (p', t') ⇒ p' = pc + 1) ls) ++_f (if pc' = pc + 1 then s' ⊔⇘f⇙ x else if s' ⊑⇘r⇙ c ! pc' then x else ⊤) else ⊤)›*) have "… = ?if (l#ls) x" proof (cases "∀(pc', s')∈set (l#ls). pc'≠pc+1 ⟶ s' <=_r c!pc'") (*goals: 1. ‹∀(pc', s')∈set (l # ls). pc' ≠ pc + 1 ⟶ s' ⊑⇘r⇙ c ! pc' ⟹ (if ∀a∈set ls. case a of (pc', s') ⇒ pc' ≠ pc + 1 ⟶ s' ⊑⇘r⇙ c ! pc' then map snd (filter (λa. case a of (p', t') ⇒ p' = pc + 1) ls) ++_f (if pc' = pc + 1 then s' ⊔⇘f⇙ x else if s' ⊑⇘r⇙ c ! pc' then x else ⊤) else ⊤) = (if ∀a∈set (l # ls). case a of (pc', s') ⇒ pc' ≠ pc + 1 ⟶ s' ⊑⇘r⇙ c ! pc' then map snd (filter (λa. case a of (p', t') ⇒ p' = pc + 1) (l # ls)) ++_f x else ⊤)› 2. ‹¬ (∀(pc', s')∈set (l # ls). pc' ≠ pc + 1 ⟶ s' ⊑⇘r⇙ c ! pc') ⟹ (if ∀a∈set ls. case a of (pc', s') ⇒ pc' ≠ pc + 1 ⟶ s' ⊑⇘r⇙ c ! pc' then map snd (filter (λa. case a of (p', t') ⇒ p' = pc + 1) ls) ++_f (if pc' = pc + 1 then s' ⊔⇘f⇙ x else if s' ⊑⇘r⇙ c ! pc' then x else ⊤) else ⊤) = (if ∀a∈set (l # ls). case a of (pc', s') ⇒ pc' ≠ pc + 1 ⟶ s' ⊑⇘r⇙ c ! pc' then map snd (filter (λa. case a of (p', t') ⇒ p' = pc + 1) (l # ls)) ++_f x else ⊤)›*) case True (*‹∀(pc'::nat, s'::'a)∈set ((l::nat × 'a) # (ls::(nat × 'a) list)). pc' ≠ (pc::nat) + (1::nat) ⟶ s' ⊑⇘r::'a ⇒ 'a ⇒ bool⇙ (c::'a list) ! pc'›*) hence "∀(pc', s')∈set ls. pc'≠pc+1 ⟶ s' <=_r c!pc'" by auto moreover from True (*‹∀(pc', s')∈set (l # ls). pc' ≠ pc + 1 ⟶ s' ⊑⇘r⇙ c ! pc'›*) have "map snd [(p',t')←ls . p'=pc+1] ++_f ?if' = (map snd [(p',t')←l#ls . p'=pc+1] ++_f x)" by simp ultimately show "?thesis" (*goal: ‹(if ∀a∈set ls. case a of (pc', s') ⇒ pc' ≠ pc + 1 ⟶ s' ⊑⇘r⇙ c ! pc' then map snd (filter (λa. case a of (p', t') ⇒ p' = pc + 1) ls) ++_f (if pc' = pc + 1 then s' ⊔⇘f⇙ x else if s' ⊑⇘r⇙ c ! pc' then x else ⊤) else ⊤) = (if ∀a∈set (l # ls). case a of (pc', s') ⇒ pc' ≠ pc + 1 ⟶ s' ⊑⇘r⇙ c ! pc' then map snd (filter (λa. case a of (p', t') ⇒ p' = pc + 1) (l # ls)) ++_f x else ⊤)›*) using True (*‹∀(pc', s')∈set (l # ls). pc' ≠ pc + 1 ⟶ s' ⊑⇘r⇙ c ! pc'›*) by simp next (*goal: ‹¬ (∀(pc', s')∈set (l # ls). pc' ≠ pc + 1 ⟶ s' ⊑⇘r⇙ c ! pc') ⟹ (if ∀a∈set ls. case a of (pc', s') ⇒ pc' ≠ pc + 1 ⟶ s' ⊑⇘r⇙ c ! pc' then map snd (filter (λa. case a of (p', t') ⇒ p' = pc + 1) ls) ++_f (if pc' = pc + 1 then s' ⊔⇘f⇙ x else if s' ⊑⇘r⇙ c ! pc' then x else ⊤) else ⊤) = (if ∀a∈set (l # ls). case a of (pc', s') ⇒ pc' ≠ pc + 1 ⟶ s' ⊑⇘r⇙ c ! pc' then map snd (filter (λa. case a of (p', t') ⇒ p' = pc + 1) (l # ls)) ++_f x else ⊤)›*) case False (*‹¬ (∀(pc', s')∈set (l # ls). pc' ≠ pc + 1 ⟶ s' ⊑⇘r⇙ c ! pc')›*) moreover from ls (*‹snd ` set ls ⊆ A›*) have "set (map snd [(p', t')←ls . p' = Suc pc]) ⊆ A" by auto ultimately show "?thesis" (*goal: ‹(if ∀a∈set ls. case a of (pc', s') ⇒ pc' ≠ pc + 1 ⟶ s' ⊑⇘r⇙ c ! pc' then map snd (filter (λa. case a of (p', t') ⇒ p' = pc + 1) ls) ++_f (if pc' = pc + 1 then s' ⊔⇘f⇙ x else if s' ⊑⇘r⇙ c ! pc' then x else ⊤) else ⊤) = (if ∀a∈set (l # ls). case a of (pc', s') ⇒ pc' ≠ pc + 1 ⟶ s' ⊑⇘r⇙ c ! pc' then map snd (filter (λa. case a of (p', t') ⇒ p' = pc + 1) (l # ls)) ++_f x else ⊤)›*) by auto qed finally (*calculation: ‹merge c pc (l # ls) x = (if ∀a∈set (l # ls). case a of (pc', s') ⇒ pc' ≠ pc + 1 ⟶ s' ⊑⇘r⇙ c ! pc' then map snd (filter (λa. case a of (p', t') ⇒ p' = pc + 1) (l # ls)) ++_f x else ⊤)›*) show "?P (l#ls) x" . qed lemma (in lbv) merge_not_top_s: assumes x: "x ∈ A" and ss: "snd`set ss ⊆ A" assumes m: "merge c pc ss x ≠ ⊤" shows "merge c pc ss x = (map snd [(p',t') ← ss. p'=pc+1] ++_f x)" proof (-) (*goal: ‹merge c pc ss x = map snd (filter (λ(p', t'). p' = pc + 1) ss) ++_f x›*) from ss (*‹snd ` set (ss::(nat × 'a) list) ⊆ (A::'a set)›*) m (*‹(merge::'a list ⇒ nat ⇒ (nat × 'a) list ⇒ 'a ⇒ 'a) (c::'a list) (pc::nat) (ss::(nat × 'a) list) (x::'a) ≠ ⊤›*) have "∀(pc',s') ∈ set ss. (pc' ≠ pc+1 ⟶ s' <=_r c!pc')" by (rule merge_not_top (*‹⟦snd ` set (?ss::(nat × 'a) list) ⊆ (A::'a set); (merge::'a list ⇒ nat ⇒ (nat × 'a) list ⇒ 'a ⇒ 'a) (?c::'a list) (?pc::nat) ?ss (?x::'a) ≠ ⊤⟧ ⟹ ∀(pc'::nat, s'::'a)∈set ?ss. pc' ≠ ?pc + (1::nat) ⟶ s' ⊑⇘r::'a ⇒ 'a ⇒ bool⇙ ?c ! pc'›*)) with x (*‹x ∈ A›*) ss (*‹snd ` set ss ⊆ A›*) m (*‹merge c pc ss x ≠ ⊤›*) show "?thesis" (*goal: ‹merge c pc ss x = map snd (filter (λ(p', t'). p' = pc + 1) ss) ++_f x›*) apply - (*goal: ‹merge c pc ss x = map snd (filter (λ(p', t'). p' = pc + 1) ss) ++_f x›*) apply (drule merge_def (*‹⟦(?x::'a::type) ∈ (A::'a::type set); snd ` set (?ss::(nat × 'a::type) list) ⊆ A⟧ ⟹ (merge::'a::type list ⇒ nat ⇒ (nat × 'a::type) list ⇒ 'a::type ⇒ 'a::type) (?c::'a::type list) (?pc::nat) ?ss ?x = (if ∀(pc'::nat, s'::'a::type)∈set ?ss. pc' ≠ ?pc + (1::nat) ⟶ s' ⊑⇘r::'a::type ⇒ 'a::type ⇒ bool⇙ ?c ! pc' then map snd (filter (λ(p'::nat, t'::'a::type). p' = ?pc + (1::nat)) ?ss) ++_(f::'a::type ⇒ 'a::type ⇒ 'a::type) ?x else ⊤)›*)) (*goals: 1. ‹⟦snd ` set ss ⊆ A; merge c pc ss x ≠ ⊤; ∀(pc', s')∈set ss. pc' ≠ pc + 1 ⟶ s' ⊑⇘r⇙ c ! pc'⟧ ⟹ snd ` set ?ss4 ⊆ A› 2. ‹⟦snd ` set ss ⊆ A; merge c pc ss x ≠ ⊤; ∀(pc', s')∈set ss. pc' ≠ pc + 1 ⟶ s' ⊑⇘r⇙ c ! pc'; merge ?c4 ?pc4 ?ss4 x = (if ∀(pc', s')∈set ?ss4. pc' ≠ ?pc4 + 1 ⟶ s' ⊑⇘r⇙ ?c4 ! pc' then map snd (filter (λ(p', t'). p' = ?pc4 + 1) ?ss4) ++_f x else ⊤)⟧ ⟹ merge c pc ss x = map snd (filter (λ(p', t'). p' = pc + 1) ss) ++_f x› discuss goal 1*) apply ((auto split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*))[1]) (*discuss goal 2*) apply ((auto split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*))[1]) (*proven 2 subgoals*) . qed subsection "wtl-inst-list" lemmas [iff] = not_Err_eq lemma (in lbv) wtl_Nil [simp]: "wtl [] c pc s = s" by (simp add: wtl_def (*‹(wtl::'b list ⇒ 'a list ⇒ nat ⇒ 'a ⇒ 'a) (?ins::'b list) (?cert::'a list) ≡ wtl_inst_list ?ins ?cert (f::'a ⇒ 'a ⇒ 'a) (r::'a ⇒ 'a ⇒ bool) ⊤ ⊥ (step::nat ⇒ 'a ⇒ (nat × 'a) list)›*)) lemma (in lbv) wtl_Cons [simp]: "wtl (i#is) c pc s = (let s' = wtc c pc s in if s' = ⊤ ∨ s = ⊤ then ⊤ else wtl is c (pc+1) s')" by (simp add: wtl_def (*‹wtl ?ins ?cert ≡ wtl_inst_list ?ins ?cert f r ⊤ ⊥ step›*) wtc_def (*‹wtc ?cert ≡ wtl_cert ?cert f r ⊤ ⊥ step›*)) lemma (in lbv) wtl_Cons_not_top: "wtl (i#is) c pc s ≠ ⊤ = (wtc c pc s ≠ ⊤ ∧ s ≠ T ∧ wtl is c (pc+1) (wtc c pc s) ≠ ⊤)" by (auto simp del: split_paired_Ex (*‹(∃x. ?P x) = (∃a b. ?P (a, b))›*)) lemma (in lbv) wtl_top [simp]: "wtl ls c pc ⊤ = ⊤" apply (cases ls) (*goals: 1. ‹ls = [] ⟹ wtl ls c pc ⊤ = ⊤› 2. ‹⋀a list. ls = a # list ⟹ wtl ls c pc ⊤ = ⊤› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . lemma (in lbv) wtl_not_top: "wtl ls c pc s ≠ ⊤ ⟹ s ≠ ⊤" apply (cases "s=⊤") (*goals: 1. ‹⟦(wtl::'b::type list ⇒ 'a::type list ⇒ nat ⇒ 'a::type ⇒ 'a::type) (ls::'b::type list) (c::'a::type list) (pc::nat) (s::'a::type) ≠ ⊤; s = ⊤⟧ ⟹ s ≠ ⊤› 2. ‹⟦(wtl::'b::type list ⇒ 'a::type list ⇒ nat ⇒ 'a::type ⇒ 'a::type) (ls::'b::type list) (c::'a::type list) (pc::nat) (s::'a::type) ≠ ⊤; s ≠ ⊤⟧ ⟹ s ≠ ⊤› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . lemma (in lbv) wtl_append [simp]: "⋀pc s. wtl (a@b) c pc s = wtl b c (pc+length a) (wtl a c pc s)" apply (induct a) (*goals: 1. ‹⋀pc s. wtl ([] @ b) c pc s = wtl b c (pc + length []) (wtl [] c pc s)› 2. ‹⋀a1 a2 pc s. (⋀pc s. wtl (a2 @ b) c pc s = wtl b c (pc + length a2) (wtl a2 c pc s)) ⟹ wtl ((a1 # a2) @ b) c pc s = wtl b c (pc + length (a1 # a2)) (wtl (a1 # a2) c pc s)› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . lemma (in lbv) wtl_take: "wtl is c pc s ≠ ⊤ ⟹ wtl (take pc' is) c pc s ≠ ⊤" (is "?wtl is ≠ _ ⟹ _") proof (-) (*goal: ‹(wtl::'b list ⇒ 'a list ⇒ nat ⇒ 'a ⇒ 'a) (is::'b list) (c::'a list) (pc::nat) (s::'a) ≠ ⊤ ⟹ wtl (take (pc'::nat) is) c pc s ≠ ⊤›*) assume "?wtl is ≠ ⊤" (*‹(wtl::'b list ⇒ 'a list ⇒ nat ⇒ 'a ⇒ 'a) (is::'b list) (c::'a list) (pc::nat) (s::'a) ≠ ⊤›*) hence "?wtl (take pc' is @ drop pc' is) ≠ ⊤" by simp thus "?thesis" (*goal: ‹wtl (take pc' is) c pc s ≠ ⊤›*) by (auto dest!: wtl_not_top (*‹wtl ?ls ?c ?pc ?s ≠ ⊤ ⟹ ?s ≠ ⊤›*) simp del: append_take_drop_id (*‹take ?n ?xs @ drop ?n ?xs = ?xs›*)) qed lemma take_Suc: "∀n. n < length l ⟶ take (Suc n) l = (take n l)@[l!n]" (is "?P l") proof (induct l) (*goals: 1. ‹∀n<length []. take (Suc n) [] = take n [] @ [[] ! n]› 2. ‹⋀a l. ∀n<length l. take (Suc n) l = take n l @ [l ! n] ⟹ ∀n<length (a # l). take (Suc n) (a # l) = take n (a # l) @ [(a # l) ! n]›*) show "?P []" by simp next (*goal: ‹⋀(a::'a) l::'a list. ∀n<length l. take (Suc n) l = take n l @ [l ! n] ⟹ ∀n<length (a # l). take (Suc n) (a # l) = take n (a # l) @ [(a # l) ! n]›*) fix x and xs assume IH: "?P xs" (*‹∀n<length (xs::'a list). take (Suc n) xs = take n xs @ [xs ! n]›*) show "?P (x#xs)" proof (intro strip (*‹(?P ⟹ ?Q) ⟹ ?P ⟶ ?Q› ‹(⋀x. ?P x) ⟹ ∀x. ?P x› ‹(⋀x. x ∈ ?A ⟹ ?P x) ⟹ ∀x∈?A. ?P x›*)) (*goal: ‹⋀n. n < length (x # xs) ⟹ take (Suc n) (x # xs) = take n (x # xs) @ [(x # xs) ! n]›*) fix n assume "n < length (x#xs)" (*‹(n::nat) < length ((x::'a) # (xs::'a list))›*) with IH (*‹∀n<length (xs::'a list). take (Suc n) xs = take n xs @ [xs ! n]›*) show "take (Suc n) (x # xs) = take n (x # xs) @ [(x # xs) ! n]" apply (cases n) (*goals: 1. ‹⟦∀n<length (xs::'a::type list). take (Suc n) xs = take n xs @ [xs ! n]; (n::nat) < length ((x::'a::type) # xs); n = (0::nat)⟧ ⟹ take (Suc n) (x # xs) = take n (x # xs) @ [(x # xs) ! n]› 2. ‹⋀nat::nat. ⟦∀n<length (xs::'a::type list). take (Suc n) xs = take n xs @ [xs ! n]; (n::nat) < length ((x::'a::type) # xs); n = Suc nat⟧ ⟹ take (Suc n) (x # xs) = take n (x # xs) @ [(x # xs) ! n]› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . qed qed lemma (in lbv) wtl_Suc: assumes suc: "pc+1 < length is" assumes wtl: "wtl (take pc is) c 0 s ≠ ⊤" shows "wtl (take (pc+1) is) c 0 s = wtc c pc (wtl (take pc is) c 0 s)" proof (-) (*goal: ‹(wtl::'b list ⇒ 'a list ⇒ nat ⇒ 'a ⇒ 'a) (take ((pc::nat) + (1::nat)) (is::'b list)) (c::'a list) (0::nat) (s::'a) = (wtc::'a list ⇒ nat ⇒ 'a ⇒ 'a) c pc (wtl (take pc is) c (0::nat) s)›*) from suc (*‹pc + 1 < length is›*) have "take (pc+1) is=(take pc is)@[is!pc]" by (simp add: take_Suc (*‹∀n<length ?l. take (Suc n) ?l = take n ?l @ [?l ! n]›*)) with suc (*‹pc + 1 < length is›*) wtl (*‹wtl (take pc is) c 0 s ≠ ⊤›*) show "?thesis" (*goal: ‹wtl (take (pc + 1) is) c 0 s = wtc c pc (wtl (take pc is) c 0 s)›*) by (simp add: min.absorb2 (*‹?b ≤ ?a ⟹ min ?a ?b = ?b›*)) qed lemma (in lbv) wtl_all: assumes all: "wtl is c 0 s ≠ ⊤" (is "?wtl is ≠ _") assumes pc: "pc < length is" shows "wtc c pc (wtl (take pc is) c 0 s) ≠ ⊤" proof (-) (*goal: ‹wtc c pc (wtl (take pc is) c 0 s) ≠ ⊤›*) from pc (*‹(pc::nat) < length (is::'b list)›*) have "0 < length (drop pc is)" by simp then obtain i and r where Cons: "drop pc is = i#r" (*goal: ‹(⋀i r. drop pc is = i # r ⟹ thesis) ⟹ thesis›*) by (auto simp add: neq_Nil_conv (*‹(?xs ≠ []) = (∃y ys. ?xs = y # ys)›*) simp del: length_drop (*‹length (drop ?n ?xs) = length ?xs - ?n›*) drop_eq_Nil (*‹(drop ?n ?xs = []) = (length ?xs ≤ ?n)›*)) hence "i#r = drop pc is" by standard with all (*‹wtl is c 0 s ≠ ⊤›*) have take: "?wtl (take pc is@i#r) ≠ ⊤" by simp from pc (*‹pc < length is›*) have "is!pc = drop pc is ! 0" by simp with Cons (*‹drop pc is = i # r›*) have "is!pc = i" by simp with take (*‹wtl (take pc is @ i # r) c 0 s ≠ ⊤›*) pc (*‹(pc::nat) < length (is::'b list)›*) show "?thesis" (*goal: ‹(wtc::'a list ⇒ nat ⇒ 'a ⇒ 'a) (c::'a list) (pc::nat) ((wtl::'b list ⇒ 'a list ⇒ nat ⇒ 'a ⇒ 'a) (take pc (is::'b list)) c (0::nat) (s::'a)) ≠ ⊤›*) by (auto simp add: min.absorb2 (*‹?b ≤ ?a ⟹ min ?a ?b = ?b›*)) qed subsection "preserves-type" lemma (in lbv) merge_pres: assumes s0: "snd`set ss ⊆ A" and x: "x ∈ A" shows "merge c pc ss x ∈ A" proof (-) (*goal: ‹merge c pc ss x ∈ A›*) from s0 (*‹snd ` set ss ⊆ A›*) have "set (map snd [(p', t')←ss . p'=pc+1]) ⊆ A" by auto with x (*‹x ∈ A›*) have "(map snd [(p', t')←ss . p'=pc+1] ++_f x) ∈ A" by (auto intro!: plusplus_closed (*‹⟦semilat (?A, ?r, ?f); set ?x ⊆ ?A; ?y ∈ ?A⟧ ⟹ ?x ++_?f ?y ∈ ?A›*) semilat (*‹semilat (A, r, f)›*)) with s0 (*‹snd ` set ss ⊆ A›*) x (*‹x ∈ A›*) show "?thesis" (*goal: ‹(merge::'a list ⇒ nat ⇒ (nat × 'a) list ⇒ 'a ⇒ 'a) (c::'a list) (pc::nat) (ss::(nat × 'a) list) (x::'a) ∈ (A::'a set)›*) by (simp add: merge_def (*‹⟦?x ∈ A; snd ` set ?ss ⊆ A⟧ ⟹ merge ?c ?pc ?ss ?x = (if ∀(pc', s')∈set ?ss. pc' ≠ ?pc + 1 ⟶ s' ⊑⇘r⇙ ?c ! pc' then map snd (filter (λ(p', t'). p' = ?pc + 1) ?ss) ++_f ?x else ⊤)›*) T_A (*‹⊤ ∈ A›*)) qed lemma pres_typeD2: "pres_type step n A ⟹ s ∈ A ⟹ p < n ⟹ snd`set (step p s) ⊆ A" apply auto (*goal: ‹⟦pres_type step n A; s ∈ A; p < n⟧ ⟹ snd ` set (step p s) ⊆ A›*) apply (drule pres_typeD (*‹⟦pres_type ?step ?n ?A; ?s ∈ ?A; ?p < ?n; (?q, ?s') ∈ set (?step ?p ?s)⟧ ⟹ ?s' ∈ ?A›*)) (*goals: 1. ‹⋀a b. ⟦s ∈ A; p < n; (a, b) ∈ set (step p s)⟧ ⟹ ?s7 a b ∈ A› 2. ‹⋀a b. ⟦s ∈ A; p < n; (a, b) ∈ set (step p s)⟧ ⟹ ?p7 a b < n› 3. ‹⋀a b. ⟦s ∈ A; p < n; (a, b) ∈ set (step p s)⟧ ⟹ (?q7 a b, ?s'7 a b) ∈ set (step (?p7 a b) (?s7 a b))› 4. ‹⋀a b. ⟦s ∈ A; p < n; (a, b) ∈ set (step p s); ?s'7 a b ∈ A⟧ ⟹ b ∈ A› discuss goal 1*) apply ((assumption)[1]) (*discuss goal 2*) apply ((assumption)[1]) (*discuss goal 3*) apply ((assumption)[1]) (*discuss goal 4*) . (*proven 4 subgoals*) lemma (in lbv) wti_pres [intro?]: assumes pres: "pres_type step n A" assumes cert: "c!(pc+1) ∈ A" assumes s_pc: "s ∈ A" "pc < n" shows "wti c pc s ∈ A" proof (-) (*goal: ‹wti c pc s ∈ A›*) from pres (*‹pres_type step n A›*) s_pc (*‹s ∈ A› ‹pc < n›*) have "snd`set (step pc s) ⊆ A" by (rule pres_typeD2 (*‹⟦pres_type ?step ?n ?A; ?s ∈ ?A; ?p < ?n⟧ ⟹ snd ` set (?step ?p ?s) ⊆ ?A›*)) with cert (*‹c ! (pc + 1) ∈ A›*) show "?thesis" (*goal: ‹wti c pc s ∈ A›*) by (simp add: wti (*‹wti ?c ?pc ?s ≡ merge ?c ?pc (step ?pc ?s) (?c ! (?pc + 1))›*) merge_pres (*‹⟦snd ` set ?ss ⊆ A; ?x ∈ A⟧ ⟹ merge ?c ?pc ?ss ?x ∈ A›*)) qed lemma (in lbv) wtc_pres: assumes pres: "pres_type step n A" assumes cert: "c!pc ∈ A" and cert': "c!(pc+1) ∈ A" assumes s: "s ∈ A" and pc: "pc < n" shows "wtc c pc s ∈ A" proof (-) (*goal: ‹wtc c pc s ∈ A›*) have "wti c pc s ∈ A" using pres (*‹pres_type step n A›*) cert' (*‹c ! (pc + 1) ∈ A›*) s (*‹s ∈ A›*) pc (*‹(pc::nat) < (n::nat)›*) by standard moreover have "wti c pc (c!pc) ∈ A" using pres (*‹pres_type step n A›*) cert' (*‹c ! (pc + 1) ∈ A›*) cert (*‹c ! pc ∈ A›*) pc (*‹pc < n›*) by standard ultimately show "?thesis" (*goal: ‹wtc c pc s ∈ A›*) using T_A (*‹⊤ ∈ A›*) by (simp add: wtc (*‹wtc ?c ?pc ?s ≡ if ?c ! ?pc = ⊥ then wti ?c ?pc ?s else if ?s ⊑⇘r⇙ ?c ! ?pc then wti ?c ?pc (?c ! ?pc) else ⊤›*)) qed lemma (in lbv) wtl_pres: assumes pres: "pres_type step (length is) A" assumes cert: "cert_ok c (length is) ⊤ ⊥ A" assumes s: "s ∈ A" assumes all: "wtl is c 0 s ≠ ⊤" shows "pc < length is ⟹ wtl (take pc is) c 0 s ∈ A" (is "?len pc ⟹ ?wtl pc ∈ A") proof (induct pc) (*goals: 1. ‹(0::nat) < length (is::'b list) ⟹ (wtl::'b list ⇒ 'a list ⇒ nat ⇒ 'a ⇒ 'a) (take (0::nat) is) (c::'a list) (0::nat) (s::'a) ∈ (A::'a set)› 2. ‹⋀pc::nat. ⟦pc < length (is::'b list) ⟹ (wtl::'b list ⇒ 'a list ⇒ nat ⇒ 'a ⇒ 'a) (take pc is) (c::'a list) (0::nat) (s::'a) ∈ (A::'a set); Suc pc < length is⟧ ⟹ wtl (take (Suc pc) is) c (0::nat) s ∈ A›*) from s (*‹s ∈ A›*) show "?wtl 0 ∈ A" by simp next (*goal: ‹⋀pc. ⟦pc < length is ⟹ wtl (take pc is) c 0 s ∈ A; Suc pc < length is⟧ ⟹ wtl (take (Suc pc) is) c 0 s ∈ A›*) fix n assume IH: "Suc n < length is" (*‹Suc (n::nat) < length (is::'b list)›*) then have n: "n < length is" by simp from IH (*‹Suc n < length is›*) have n1: "n+1 < length is" by simp assume prem: "n < length is ⟹ ?wtl n ∈ A" (*‹(n::nat) < length (is::'b list) ⟹ (wtl::'b list ⇒ 'a list ⇒ nat ⇒ 'a ⇒ 'a) (take n is) (c::'a list) (0::nat) (s::'a) ∈ (A::'a set)›*) have "wtc c n (?wtl n) ∈ A" using pres (*‹pres_type step (length is) A›*) "_" (*‹PROP ?psi ⟹ PROP ?psi›*) "_" (*‹PROP ?psi ⟹ PROP ?psi›*) "_" (*‹PROP ?psi ⟹ PROP ?psi›*) n (*‹n < length is›*) proof (rule wtc_pres (*‹⟦pres_type step ?n A; ?c ! ?pc ∈ A; ?c ! (?pc + 1) ∈ A; ?s ∈ A; ?pc < ?n⟧ ⟹ wtc ?c ?pc ?s ∈ A›*)) (*goals: 1. ‹c ! n ∈ A› 2. ‹c ! (n + 1) ∈ A› 3. ‹wtl (take n is) c 0 s ∈ A›*) from prem (*‹n < length is ⟹ wtl (take n is) c 0 s ∈ A›*) n (*‹n < length is›*) show "?wtl n ∈ A" . from cert (*‹cert_ok c (length is) ⊤ ⊥ A›*) n (*‹(n::nat) < length (is::'b list)›*) show "c!n ∈ A" by (rule cert_okD1 (*‹⟦cert_ok ?c ?n ?T ?B ?A; ?pc < ?n⟧ ⟹ ?c ! ?pc ∈ ?A›*)) from cert (*‹cert_ok c (length is) ⊤ ⊥ A›*) n1 (*‹n + 1 < length is›*) show "c!(n+1) ∈ A" by (rule cert_okD1 (*‹⟦cert_ok ?c ?n ?T ?B ?A; ?pc < ?n⟧ ⟹ ?c ! ?pc ∈ ?A›*)) qed also (*calculation: ‹wtc c n (wtl (take n is) c 0 s) ∈ A›*) from all (*‹wtl is c 0 s ≠ ⊤›*) n (*‹(n::nat) < length (is::'b list)›*) have "?wtl n ≠ ⊤" apply - (*goal: ‹wtl (take n is) c 0 s ≠ ⊤›*) by (rule wtl_take (*‹(wtl::'b::type list ⇒ 'a::type list ⇒ nat ⇒ 'a::type ⇒ 'a::type) (?is::'b::type list) (?c::'a::type list) (?pc::nat) (?s::'a::type) ≠ ⊤ ⟹ wtl (take (?pc'::nat) ?is) ?c ?pc ?s ≠ ⊤›*)) with n1 (*‹(n::nat) + (1::nat) < length (is::'b list)›*) have "wtc c n (?wtl n) = ?wtl (n+1)" by (rule wtl_Suc [symmetric] (*‹⟦?pc + 1 < length ?is; wtl (take ?pc ?is) ?c 0 ?s ≠ ⊤⟧ ⟹ wtc ?c ?pc (wtl (take ?pc ?is) ?c 0 ?s) = wtl (take (?pc + 1) ?is) ?c 0 ?s›*)) finally (*calculation: ‹wtl (take (n + 1) is) c 0 s ∈ A›*) show "?wtl (Suc n) ∈ A" by simp qed end
{ "path": "Isabelle2024/src/HOL/MicroJava/DFA/LBVSpec.thy", "repo": "Isabelle2024", "sha": "688ba0438200aa63af7994c6eb1259cc2d4442bbc271c8e5eba4a451f3864c00" }
(* Title: variants/a_norreqid/Aodv_Message.thy License: BSD 2-Clause. See LICENSE. Author: Timothy Bourke, Inria Author: Peter Höfner, NICTA *) section "AODV protocol messages" theory A_Aodv_Message imports A_Norreqid begin datatype msg = Rreq nat ip sqn k ip sqn ip | Rrep nat ip sqn ip ip | Rerr "ip ⇀ sqn" ip | Newpkt data ip | Pkt data ip ip instantiation msg :: msg begin definition newpkt_def [simp]: "newpkt ≡ λ(d, dip). Newpkt d dip" definition eq_newpkt_def: "eq_newpkt m ≡ case m of Newpkt d dip ⇒ True | _ ⇒ False" instance by intro_classes (simp add: eq_newpkt_def) end text ‹The @{type msg} type models the different messages used within AODV. The instantiation as a @{class msg} is a technicality due to the special treatment of @{term newpkt} messages in the AWN SOS rules. This use of classes allows a clean separation of the AWN-specific definitions and these AODV-specific definitions.› definition rreq :: "nat × ip × sqn × k × ip × sqn × ip ⇒ msg" where "rreq ≡ λ(hops, dip, dsn, dsk, oip, osn, sip). Rreq hops dip dsn dsk oip osn sip" lemma rreq_simp [simp]: "rreq(hops, dip, dsn, dsk, oip, osn, sip) = Rreq hops dip dsn dsk oip osn sip" unfolding rreq_def (*goal: ‹(case (hops::nat, dip::nat, dsn::nat, dsk::k, oip::nat, osn::nat, sip::nat) of (hops::nat, dip::nat, dsn::nat, dsk::k, oip::nat, osn::nat, sip::nat) ⇒ Rreq hops dip dsn dsk oip osn sip) = Rreq hops dip dsn dsk oip osn sip›*) by simp definition rrep :: "nat × ip × sqn × ip × ip ⇒ msg" where "rrep ≡ λ(hops, dip, dsn, oip, sip). Rrep hops dip dsn oip sip" lemma rrep_simp [simp]: "rrep(hops, dip, dsn, oip, sip) = Rrep hops dip dsn oip sip" unfolding rrep_def (*goal: ‹(case (hops, dip, dsn, oip, sip) of (hops, dip, dsn, oip, sip) ⇒ Rrep hops dip dsn oip sip) = Rrep hops dip dsn oip sip›*) by simp definition rerr :: "(ip ⇀ sqn) × ip ⇒ msg" where "rerr ≡ λ(dests, sip). Rerr dests sip" lemma rerr_simp [simp]: "rerr(dests, sip) = Rerr dests sip" unfolding rerr_def (*goal: ‹(case (dests, sip) of (dests, sip) ⇒ Rerr dests sip) = Rerr dests sip›*) by simp lemma not_eq_newpkt_rreq [simp]: "¬eq_newpkt (Rreq hops dip dsn dsk oip osn sip)" unfolding eq_newpkt_def (*goal: ‹¬ (case Rreq hops dip dsn dsk oip osn sip of Newpkt d dip ⇒ True | _ ⇒ False)›*) by simp lemma not_eq_newpkt_rrep [simp]: "¬eq_newpkt (Rrep hops dip dsn oip sip)" unfolding eq_newpkt_def (*goal: ‹¬ (case Rrep hops dip dsn oip sip of Newpkt d dip ⇒ True | _ ⇒ False)›*) by simp lemma not_eq_newpkt_rerr [simp]: "¬eq_newpkt (Rerr dests sip)" unfolding eq_newpkt_def (*goal: ‹¬ (case Rerr (dests::nat ⇒ nat option) (sip::nat) of Newpkt (d::nat) (dip::nat) ⇒ True | _ ⇒ False)›*) by simp lemma not_eq_newpkt_pkt [simp]: "¬eq_newpkt (Pkt d dip sip)" unfolding eq_newpkt_def (*goal: ‹¬ (case Pkt d dip sip of Newpkt d dip ⇒ True | _ ⇒ False)›*) by simp definition pkt :: "data × ip × ip ⇒ msg" where "pkt ≡ λ(d, dip, sip). Pkt d dip sip" lemma pkt_simp [simp]: "pkt(d, dip, sip) = Pkt d dip sip" unfolding pkt_def (*goal: ‹(case (d::nat, dip::nat, sip::nat) of (d::nat, dip::nat, sip::nat) ⇒ Pkt d dip sip) = Pkt d dip sip›*) by simp end
{ "path": "afp-2025-02-12/thys/AODV/variants/a_norreqid/A_Aodv_Message.thy", "repo": "afp-2025-02-12", "sha": "0a4470b0ae710960dc17279b39158893d31e1afb89f6d09f391e90975e683e57" }
theory PAC_Assoc_Map_Rel imports PAC_Map_Rel begin section ‹Hash Map as association list› type_synonym ('k, 'v) hash_assoc = ‹('k × 'v) list› definition hassoc_map_rel_raw :: ‹(('k, 'v) hash_assoc × _) set› where ‹hassoc_map_rel_raw = br map_of (λ_. True)› abbreviation hassoc_map_assn :: ‹('k ⇒ 'v option) ⇒ ('k, 'v) hash_assoc ⇒ assn› where ‹hassoc_map_assn ≡ pure (hassoc_map_rel_raw)› lemma hassoc_map_rel_raw_empty[simp]: ‹([], m) ∈ hassoc_map_rel_raw ⟷ m = Map.empty› ‹(p, Map.empty) ∈ hassoc_map_rel_raw ⟷ p = []› ‹hassoc_map_assn Map.empty [] = emp› (*goals: 1. ‹(([], m) ∈ hassoc_map_rel_raw) = (m = (λx. None))› 2. ‹((p, λx. None) ∈ hassoc_map_rel_raw) = (p = [])› 3. ‹hassoc_map_assn (λx. None) [] = emp› discuss goal 1*) apply ((auto simp: hassoc_map_rel_raw_def (*‹hassoc_map_rel_raw = br map_of (λ_. True)›*) br_def (*‹br ?α ?I ≡ {(c, a). a = ?α c ∧ ?I c}›*) pure_def (*‹pure ?R ≡ λa c. ↑ ((c, a) ∈ ?R)›*))[1]) (*discuss goal 2*) apply ((auto simp: hassoc_map_rel_raw_def (*‹hassoc_map_rel_raw = br map_of (λ_. True)›*) br_def (*‹br ?α ?I ≡ {(c, a). a = ?α c ∧ ?I c}›*) pure_def (*‹pure ?R ≡ λa c. ↑ ((c, a) ∈ ?R)›*))[1]) (*discuss goal 3*) apply ((auto simp: hassoc_map_rel_raw_def (*‹hassoc_map_rel_raw = br map_of (λ_::(?'k × ?'v) list. True)›*) br_def (*‹br (?α::?'a ⇒ ?'b) (?I::?'a ⇒ bool) ≡ {(c::?'a, a::?'b). a = ?α c ∧ ?I c}›*) pure_def (*‹pure (?R::(?'b × ?'a) set) ≡ λ(a::?'a) c::?'b. ↑ ((c, a) ∈ ?R)›*))[1]) (*proven 3 subgoals*) . definition hassoc_new :: ‹('k, 'v) hash_assoc Heap›where ‹hassoc_new = return []› lemma precise_hassoc_map_assn: ‹precise hassoc_map_assn› apply (auto intro!: precise_pure (*‹single_valued ?R ⟹ precise (pure ?R)›*)) (*goal: ‹precise hassoc_map_assn›*) by (auto simp: single_valued_def (*‹single_valued ?r = (∀x y. (x, y) ∈ ?r ⟶ (∀z. (x, z) ∈ ?r ⟶ y = z))›*) hassoc_map_rel_raw_def (*‹hassoc_map_rel_raw = br map_of (λ_. True)›*) br_def (*‹br ?α ?I ≡ {(c, a). a = ?α c ∧ ?I c}›*)) definition hassoc_isEmpty :: "('k × 'v) list ⇒ bool Heap" where "hassoc_isEmpty ht ≡ return (length ht = 0)" interpretation hassoc: bind_map_empty hassoc_map_assn hassoc_new apply unfold_locales (*goals: 1. ‹precise hassoc_map_assn› 2. ‹<emp> hassoc_new <hassoc_map_assn (λx. None)>⇩t› discuss goal 1*) apply ((auto intro: precise_hassoc_map_assn (*‹precise hassoc_map_assn›*) simp: ent_refl_true (*‹?A ⟹⇩A ?A * true›*) hassoc_new_def (*‹hassoc_new = return []›*) intro!: return_cons_rule (*‹?P ⟹⇩A ?Q ?x ⟹ <?P> return ?x <?Q>›*))[1]) (*discuss goal 2*) apply ((auto intro: precise_hassoc_map_assn (*‹precise hassoc_map_assn›*) simp: ent_refl_true (*‹?A ⟹⇩A ?A * true›*) hassoc_new_def (*‹hassoc_new = return []›*) intro!: return_cons_rule (*‹?P ⟹⇩A ?Q ?x ⟹ <?P> return ?x <?Q>›*))[1]) (*proven 2 subgoals*) . interpretation hassoc: bind_map_is_empty hassoc_map_assn hassoc_isEmpty apply unfold_locales (*goal: ‹bind_map_is_empty hassoc_map_assn hassoc_isEmpty›*) by (auto simp: precise_hassoc_map_assn (*‹precise hassoc_map_assn›*) hassoc_isEmpty_def (*‹hassoc_isEmpty ?ht ≡ return (length ?ht = 0)›*) ent_refl_true (*‹?A ⟹⇩A ?A * true›*) intro!: precise_pure (*‹single_valued ?R ⟹ precise (pure ?R)›*) return_cons_rule (*‹?P ⟹⇩A ?Q ?x ⟹ <?P> return ?x <?Q>›*)) definition "op_assoc_empty ≡ IICF_Map.op_map_empty" interpretation hassoc: map_custom_empty op_assoc_empty apply unfold_locales (*goal: ‹map_custom_empty op_assoc_empty›*) by (simp add: op_assoc_empty_def (*‹op_assoc_empty ≡ op_map_empty›*)) lemmas [sepref_fr_rules] = hassoc.empty_hnr[folded op_assoc_empty_def] definition hassoc_update :: "'k ⇒ 'v ⇒ ('k, 'v) hash_assoc ⇒ ('k, 'v) hash_assoc Heap" where "hassoc_update k v ht = return ((k, v ) # ht)" lemma hassoc_map_assn_Cons: ‹hassoc_map_assn (m) (p) ⟹⇩A hassoc_map_assn (m(k ↦ v)) ((k, v) # p) * true› by (auto simp: hassoc_map_rel_raw_def (*‹hassoc_map_rel_raw = br map_of (λ_. True)›*) pure_def (*‹pure ?R ≡ λa c. ↑ ((c, a) ∈ ?R)›*) br_def (*‹br ?α ?I ≡ {(c, a). a = ?α c ∧ ?I c}›*)) interpretation hassoc: bind_map_update hassoc_map_assn hassoc_update apply unfold_locales (*goal: ‹bind_map_update hassoc_map_assn hassoc_update›*) by (auto intro!: return_cons_rule (*‹?P ⟹⇩A ?Q ?x ⟹ <?P> return ?x <?Q>›*) simp: hassoc_update_def (*‹hassoc_update ?k ?v ?ht = return ((?k, ?v) # ?ht)›*) hassoc_map_assn_Cons (*‹hassoc_map_assn ?m ?p ⟹⇩A hassoc_map_assn (?m(?k ↦ ?v)) ((?k, ?v) # ?p) * true›*)) definition hassoc_delete :: ‹'k ⇒ ('k, 'v) hash_assoc ⇒ ('k, 'v) hash_assoc Heap› where ‹hassoc_delete k ht = return (filter (λ(a, b). a ≠ k) ht)› lemma hassoc_map_of_filter_all: ‹map_of p |` (- {k}) = map_of (filter (λ(a, b). a ≠ k) p)› apply (induction p) (*goals: 1. ‹map_of [] |` (- {k}) = map_of (filter (λa. case a of (a, b) ⇒ a ≠ k) [])› 2. ‹⋀a p. map_of p |` (- {k}) = map_of (filter (λa. case a of (a, b) ⇒ a ≠ k) p) ⟹ map_of (a # p) |` (- {k}) = map_of (filter (λa. case a of (a, b) ⇒ a ≠ k) (a # p))› discuss goal 1*) apply ((auto simp: restrict_map_def (*‹?m |` ?A = (λx. if x ∈ ?A then ?m x else None)›*) fun_eq_iff (*‹(?f = ?g) = (∀x. ?f x = ?g x)›*) split: if_split (*‹?P (if ?Q then ?x else ?y) = ((?Q ⟶ ?P ?x) ∧ (¬ ?Q ⟶ ?P ?y))›*))[1]) (*discuss goal 2*) apply ((auto simp: restrict_map_def (*‹(?m::?'a::type ⇒ ?'b::type option) |` (?A::?'a::type set) = (λx::?'a::type. if x ∈ ?A then ?m x else None)›*) fun_eq_iff (*‹((?f::?'a::type ⇒ ?'b::type) = (?g::?'a::type ⇒ ?'b::type)) = (∀x::?'a::type. ?f x = ?g x)›*) split: if_split (*‹(?P::?'a::type ⇒ bool) (if ?Q::bool then ?x::?'a::type else (?y::?'a::type)) = ((?Q ⟶ ?P ?x) ∧ (¬ ?Q ⟶ ?P ?y))›*))[1]) (*goals: 1. ‹⋀(a::'a) p::('a × 'b) list. ⟦∀x::'a. (if x = (k::'a) then None else map_of p x) = map_of (filter (λ(a::'a, b::'b). a ≠ k) p) x; a ≠ k⟧ ⟹ None = map_of (filter (λ(a::'a, b::'b). a ≠ k) p) k› 2. ‹⋀(a::'a) (p::('a × 'b) list) x::'a. ⟦∀x::'a. (if x = (k::'a) then None else map_of p x) = map_of (filter (λ(a::'a, b::'b). a ≠ k) p) x; a ≠ k; x ≠ k; x ≠ a⟧ ⟹ map_of p x = map_of (filter (λ(a::'a, b::'b). a ≠ k) p) x› 3. ‹⋀p::('a × 'b) list. ∀x::'a. (if x = (k::'a) then None else map_of p x) = map_of (filter (λ(a::'a, b::'b). a ≠ k) p) x ⟹ None = map_of (filter (λ(a::'a, b::'b). a ≠ k) p) k› 4. ‹⋀(p::('a × 'b) list) x::'a. ⟦∀x::'a. (if x = (k::'a) then None else map_of p x) = map_of (filter (λ(a::'a, b::'b). a ≠ k) p) x; x ≠ k⟧ ⟹ map_of p x = map_of (filter (λ(a::'a, b::'b). a ≠ k) p) x› discuss goal 1*) apply presburger (*discuss goal 2*) apply presburger (*discuss goal 3*) apply presburger (*discuss goal 4*) apply presburger (*proven 4 subgoals*) (*proven 2 subgoals*) . lemma hassoc_map_assn_hassoc_delete: ‹<hassoc_map_assn m p> hassoc_delete k p <hassoc_map_assn (m |` (- {k}))>⇩t› by (auto simp: hassoc_delete_def (*‹hassoc_delete ?k ?ht = return (filter (λ(a, b). a ≠ ?k) ?ht)›*) hassoc_map_rel_raw_def (*‹hassoc_map_rel_raw = br map_of (λ_. True)›*) pure_def (*‹pure ?R ≡ λa c. ↑ ((c, a) ∈ ?R)›*) br_def (*‹br ?α ?I ≡ {(c, a). a = ?α c ∧ ?I c}›*) hassoc_map_of_filter_all (*‹map_of ?p |` (- {?k}) = map_of (filter (λ(a, b). a ≠ ?k) ?p)›*) intro!: return_cons_rule (*‹?P ⟹⇩A ?Q ?x ⟹ <?P> return ?x <?Q>›*)) interpretation hassoc: bind_map_delete hassoc_map_assn hassoc_delete apply unfold_locales (*goal: ‹bind_map_delete hassoc_map_assn hassoc_delete›*) by (auto intro: hassoc_map_assn_hassoc_delete (*‹<hassoc_map_assn ?m ?p> hassoc_delete ?k ?p <hassoc_map_assn (?m |` (- {?k}))>⇩t›*)) definition hassoc_lookup :: ‹'k ⇒ ('k, 'v) hash_assoc ⇒ 'v option Heap› where ‹hassoc_lookup k ht = return (map_of ht k)› lemma hassoc_map_assn_hassoc_lookup: ‹<hassoc_map_assn m p> hassoc_lookup k p <λr. hassoc_map_assn m p * ↑ (r = m k)>⇩t› by (auto simp: hassoc_lookup_def (*‹hassoc_lookup ?k ?ht = return (map_of ?ht ?k)›*) hassoc_map_rel_raw_def (*‹hassoc_map_rel_raw = br map_of (λ_. True)›*) pure_def (*‹pure ?R ≡ λa c. ↑ ((c, a) ∈ ?R)›*) br_def (*‹br ?α ?I ≡ {(c, a). a = ?α c ∧ ?I c}›*) hassoc_map_of_filter_all (*‹map_of ?p |` (- {?k}) = map_of (filter (λ(a, b). a ≠ ?k) ?p)›*) intro!: return_cons_rule (*‹?P ⟹⇩A ?Q ?x ⟹ <?P> return ?x <?Q>›*)) interpretation hassoc: bind_map_lookup hassoc_map_assn hassoc_lookup apply unfold_locales (*goal: ‹bind_map_lookup hassoc_map_assn hassoc_lookup›*) by (rule hassoc_map_assn_hassoc_lookup (*‹<hassoc_map_assn ?m ?p> hassoc_lookup ?k ?p <λr. hassoc_map_assn ?m ?p * ↑ (r = ?m ?k)>⇩t›*)) setup Locale_Code.open_block interpretation hassoc: gen_contains_key_by_lookup hassoc_map_assn hassoc_lookup by unfold_locales setup Locale_Code.close_block interpretation hassoc: bind_map_contains_key hassoc_map_assn hassoc.contains_key by unfold_locales subsection ‹Conversion from assoc to other map› definition hash_of_assoc_map where ‹hash_of_assoc_map xs = fold (λ(k, v) m. if m k ≠ None then m else m(k ↦ v)) xs Map.empty› lemma map_upd_map_add_left: ‹m(a ↦ b) ++ m' = m ++ (if a ∉ dom m' then m'(a ↦ b) else m')› proof (-) (*goal: ‹m(a ↦ b) ++ m' = m ++ (if a ∉ dom m' then m'(a ↦ b) else m')›*) have "m' a = Some y ⟹ m(a ↦ b) ++ m' = m ++ m'" for y by (metis (no_types) fun_upd_triv (*‹?f(?x := ?f ?x) = ?f›*) fun_upd_upd (*‹?f(?x := ?y, ?x := ?z) = ?f(?x := ?z)›*) map_add_assoc (*‹?m1.0 ++ (?m2.0 ++ ?m3.0) = ?m1.0 ++ ?m2.0 ++ ?m3.0›*) map_add_empty (*‹?m ++ (λx. None) = ?m›*) map_add_upd (*‹?f ++ ?g(?x ↦ ?y) = (?f ++ ?g)(?x ↦ ?y)›*) map_le_iff_map_add_commute (*‹(?f ⊆⇩m ?f ++ ?g) = (?f ++ ?g = ?g ++ ?f)›*)) then show "?thesis" (*goal: ‹m(a ↦ b) ++ m' = m ++ (if a ∉ dom m' then m'(a ↦ b) else m')›*) by auto qed lemma fold_map_of_alt: ‹fold (λ(k, v) m. if m k ≠ None then m else m(k ↦ v)) xs m' = map_of xs ++ m'› apply (induction xs arbitrary: m') (*goals: 1. ‹⋀m'. fold (λ(k, v) m. if m k ≠ None then m else m(k ↦ v)) [] m' = map_of [] ++ m'› 2. ‹⋀a xs m'. (⋀m'. fold (λ(k, v) m. if m k ≠ None then m else m(k ↦ v)) xs m' = map_of xs ++ m') ⟹ fold (λ(k, v) m. if m k ≠ None then m else m(k ↦ v)) (a # xs) m' = map_of (a # xs) ++ m'› discuss goal 1*) apply ((auto simp: map_upd_map_add_left (*‹?m(?a ↦ ?b) ++ ?m' = ?m ++ (if ?a ∉ dom ?m' then ?m'(?a ↦ ?b) else ?m')›*))[1]) (*discuss goal 2*) apply ((auto simp: map_upd_map_add_left (*‹(?m::?'a::type ⇒ ?'b::type option)(?a::?'a::type ↦ ?b::?'b::type) ++ (?m'::?'a::type ⇒ ?'b::type option) = ?m ++ (if ?a ∉ dom ?m' then ?m'(?a ↦ ?b) else ?m')›*))[1]) (*proven 2 subgoals*) . lemma map_of_alt_def: ‹map_of xs = hash_of_assoc_map xs› using fold_map_of_alt[of xs Map.empty] (*‹fold (λ(k, v) m. if m k ≠ None then m else m(k ↦ v)) xs (λx. None) = map_of xs ++ (λx. None)›*) unfolding hash_of_assoc_map_def (*goal: ‹map_of xs = fold (λ(k, v) m. if m k ≠ None then m else m(k ↦ v)) xs (λx. None)›*) by auto definition hashmap_conv where [simp]: ‹hashmap_conv x = x› lemma hash_of_assoc_map_id: ‹(hash_of_assoc_map, hashmap_conv) ∈ hassoc_map_rel_raw → Id› by (auto intro!: fun_relI (*‹(⋀a a'. (a, a') ∈ ?A ⟹ (?f a, ?f' a') ∈ ?B) ⟹ (?f, ?f') ∈ ?A → ?B›*) simp: hassoc_map_rel_raw_def (*‹hassoc_map_rel_raw = br map_of (λ_. True)›*) br_def (*‹br ?α ?I ≡ {(c, a). a = ?α c ∧ ?I c}›*) map_of_alt_def (*‹map_of ?xs = hash_of_assoc_map ?xs›*)) definition hassoc_map_rel where hassoc_map_rel_internal_def: ‹hassoc_map_rel K V = hassoc_map_rel_raw O ⟨K,V⟩map_rel› lemma hassoc_map_rel_def: ‹⟨K,V⟩ hassoc_map_rel = hassoc_map_rel_raw O ⟨K,V⟩map_rel› unfolding relAPP_def hassoc_map_rel_internal_def (*goal: ‹hassoc_map_rel_raw O map_rel K V = hassoc_map_rel_raw O map_rel K V›*) by auto end
{ "path": "afp-2025-02-12/thys/PAC_Checker/PAC_Assoc_Map_Rel.thy", "repo": "afp-2025-02-12", "sha": "1693005a4e6c4a4c0e4b4e76b7034a7a1dff3447a31f8c9fe8eda5c351e3613c" }
theory CHERI_C_Global_Environment imports CHERI_C_Concrete_Memory_Model begin text ‹Here, we define the global environment. The Global Environment does the following: \begin{enumerate} \item Creates a mapping from variables to locations (or rather, the capabilities) \item Sets global variables by invoking alloc. These variables cannot be freed by design \end{enumerate}› type_synonym genv = "(String.literal, cap) mapping" definition alloc_glob_var :: "heap ⇒ bool ⇒ nat ⇒ (heap × cap) result" where "alloc_glob_var h c s ≡ let h' = alloc h c s in Success (fst (res h'), snd (res h') ⦇ perm_global := True ⦈)" definition set_glob_var :: "heap ⇒ bool ⇒ nat ⇒ String.literal ⇒ genv ⇒ (heap × cap × genv) result" where "set_glob_var h c s v g ≡ let (h', cap) = res (alloc_glob_var h c s) in let g' = Mapping.update v cap g in Success (h', cap, g')" lemma set_glob_var_glob_bit: assumes "alloc_glob_var h c s = Success (h', cap)" shows "perm_global cap" using assms (*‹alloc_glob_var (h::heap) (c::bool) (s::nat) = Success (h'::heap, cap::integer capability)›*) unfolding alloc_glob_var_def alloc_def (*goal: ‹perm_global cap›*) by fastforce lemma set_glob_var_glob_bit_lift: assumes "set_glob_var h c s v g = Success (h', cap, g')" shows "perm_global cap" using assms (*‹set_glob_var h c s v g = Success (h', cap, g')›*) unfolding alloc_glob_var_def set_glob_var_def alloc_def (*goal: ‹perm_global cap›*) by fastforce (* It is worth noting that other operations such as load and store still work. *) (* However, free should only work on values returned by m?alloc. *) lemma free_fails_on_glob_var: assumes "alloc_glob_var h c s = Success (h', cap)" shows "free h' cap = Error (LogicErr (Unhandled 0))" by (metis alloc_updated_heap_and_cap (*‹alloc ?h ?c ?s = Success (?h⦇next_block := next_block ?h + 1, heap_map := Mapping.update (next_block ?h) (Map ⦇bounds = (0, ?s), content = Mapping.empty, tags = Mapping.empty⦈) (heap_map ?h)⦈, ⦇block_id = next_block ?h, offset = 0, base = 0, len = ?s, perm_load = True, perm_cap_load = ?c, perm_store = True, perm_cap_store = ?c, perm_cap_store_local = ?c, perm_global = False, tag = True⦈)›*) assms (*‹alloc_glob_var h c s = Success (h', cap)›*) capability.select_convs( (*‹tag ⦇block_id = ?block_id, offset = ?offset, base = ?base, len = ?len, perm_load = ?perm_load, perm_cap_load = ?perm_cap_load, perm_store = ?perm_store, perm_cap_store = ?perm_cap_store, perm_cap_store_local = ?perm_cap_store_local, perm_global = ?perm_global, tag = ?tag, … = ?more⦈ = ?tag›*) 1) free_global_cap (*‹⟦?c ≠ NULL; tag ?c = True; perm_global ?c = True⟧ ⟹ free ?h ?c = Error (LogicErr (Unhandled STR ''''))›*) mem_capability.select_convs( (*‹perm_global ⦇block_id = ?block_id, offset = ?offset, base = ?base, len = ?len, perm_load = ?perm_load, perm_cap_load = ?perm_cap_load, perm_store = ?perm_store, perm_cap_store = ?perm_cap_store, perm_cap_store_local = ?perm_cap_store_local, perm_global = ?perm_global, … = ?more⦈ = ?perm_global›*) 10) mem_capability.simps( (*‹perm_global_update ?perm_global' ⦇block_id = ?block_id, offset = ?offset, base = ?base, len = ?len, perm_load = ?perm_load, perm_cap_load = ?perm_cap_load, perm_store = ?perm_store, perm_cap_store = ?perm_cap_store, perm_cap_store_local = ?perm_cap_store_local, perm_global = ?perm_global, … = ?more⦈ = ⦇block_id = ?block_id, offset = ?offset, base = ?base, len = ?len, perm_load = ?perm_load, perm_cap_load = ?perm_cap_load, perm_store = ?perm_store, perm_cap_store = ?perm_cap_store, perm_cap_store_local = ?perm_cap_store_local, perm_global = ?perm_global' ?perm_global, … = ?more⦈›*) 21) null_capability_def (*‹NULL ≡ 0›*) result.sel( (*‹res (Success ?x1.0) = ?x1.0›*) 1) alloc_glob_var_def (*‹alloc_glob_var ?h ?c ?s ≡ let h' = alloc ?h ?c ?s in Success (fst (res h'), snd (res h')⦇perm_global := True⦈)›*) snd_conv (*‹snd (?x1.0, ?x2.0) = ?x2.0›*) zero_mem_capability_ext_def (*‹0 ≡ ⦇block_id = 0, offset = 0, base = 0, len = 0, perm_load = False, perm_cap_load = False, perm_store = False, perm_cap_store = False, perm_cap_store_local = False, perm_global = False, … = 0⦈›*)) lemma free_fails_on_glob_lift: assumes "set_glob_var h c s v g = Success (h', cap, g')" shows "free h' cap = Error (LogicErr (Unhandled 0))" proof (-) (*goal: ‹free h' cap = Error (LogicErr (Unhandled STR ''''))›*) have res: "alloc_glob_var h c s = Success (h', cap)" using assms (*‹set_glob_var h c s v g = Success (h', cap, g')›*) unfolding set_glob_var_def alloc_glob_var_def alloc_def (*goal: ‹(let h' = let cap = ⦇block_id = next_block h, offset = 0, base = 0, len = s, perm_load = True, perm_cap_load = c, perm_store = True, perm_cap_store = c, perm_cap_store_local = c, perm_global = False, tag = True⦈; h' = h⦇next_block := next_block h + 1, heap_map := Mapping.update (next_block h) (Map ⦇bounds = (0, s), content = Mapping.empty, tags = Mapping.empty⦈) (heap_map h)⦈ in Success (h', cap) in Success (fst (res h'), snd (res h')⦇perm_global := True⦈)) = Success (h', cap)›*) by fastforce show "?thesis" (*goal: ‹free h' cap = Error (LogicErr (Unhandled STR ''''))›*) using free_fails_on_glob_var[OF res] (*‹free h' cap = Error (LogicErr (Unhandled STR ''''))›*) by blast qed section ‹Code Generation› text ‹Here we generate an OCaml instance of the memory model that will be used for Gillian.› export_code null_capability init_heap next_block get_memory_leak_size get_unfreed_blocks (* Utility Functions *) alloc free load store (* Memory Actions *) memcpy set_glob_var (* Global Environment Actions *) word8_of_integer word16_of_integer word32_of_integer word64_of_integer (* Value Conversions *) integer_of_word8 integer_of_word16 integer_of_word32 integer_of_word64 sword8_of_integer sword16_of_integer sword32_of_integer sword64_of_integer integer_of_sword8 integer_of_sword16 integer_of_sword32 integer_of_sword64 integer_of_nat cast_val C2Err LogicErr (* Error Types *) TagViolation PermitLoadViolation PermitStoreViolation PermitStoreCapViolation PermitStoreLocalCapViolation LengthViolation BadAddressViolation UseAfterFree BufferOverrun MissingResource WrongMemVal MemoryNotFreed Unhandled in OCaml file_prefix CHERI_C_Memory_Model end
{ "path": "afp-2025-02-12/thys/CHERI-C_Memory_Model/CHERI_C_Global_Environment.thy", "repo": "afp-2025-02-12", "sha": "0a5c2b7de87f0dd745699b3a675d0cd49cef76ca50fc54597d639f58926de007" }
theory Invariants imports SCL_FOL begin text ‹The following lemma restate existing invariants in a compact, paper-friendly way.› lemma (in scl_fol_calculus) scl_state_invariants: shows inv_trail_lits_ground: "trail_lits_ground initial_state" "scl N β S S' ⟹ trail_lits_ground S ⟹ trail_lits_ground S'" and inv_trail_atoms_lt: "trail_atoms_lt β initial_state" "scl N β S S' ⟹ trail_atoms_lt β S ⟹ trail_atoms_lt β S'" and inv_undefined_trail_lits: "∀Γ' Ln Γ''. state_trail initial_state = Γ'' @ Ln # Γ' ⟶ ¬ trail_defined_lit Γ' (fst Ln)" "scl N β S S' ⟹ (∀Γ' Ln Γ''. state_trail S = Γ'' @ Ln # Γ' ⟶ ¬ trail_defined_lit Γ' (fst Ln)) ⟹ (∀Γ' Ln Γ''. state_trail S' = Γ'' @ Ln # Γ' ⟶ ¬ trail_defined_lit Γ' (fst Ln))" and inv_ground_closures: "ground_closures initial_state" "scl N β S S' ⟹ ground_closures S ⟹ ground_closures S'" and inv_ground_false_closures: "ground_false_closures initial_state" "scl N β S S' ⟹ ground_false_closures S ⟹ ground_false_closures S'" and inv_trail_propagated_lits_wf: "∀𝒦∈set (state_trail initial_state). ∀D K γ. snd 𝒦 = Some (D, K, γ) ⟶ fst 𝒦 = K ⋅l γ" "scl N β S S' ⟹ (∀𝒦∈set (state_trail S). ∀D K γ. snd 𝒦 = Some (D, K, γ) ⟶ fst 𝒦 = K ⋅l γ) ⟹ (∀𝒦∈set (state_trail S'). ∀D K γ. snd 𝒦 = Some (D, K, γ) ⟶ fst 𝒦 = K ⋅l γ)" and inv_trail_resolved_lits_pol: "trail_resolved_lits_pol initial_state" "scl N β S S' ⟹ trail_resolved_lits_pol S ⟹ trail_resolved_lits_pol S'" and inv_initial_lits_generalize_learned_trail_conflict: "initial_lits_generalize_learned_trail_conflict N initial_state" "scl N β S S' ⟹ initial_lits_generalize_learned_trail_conflict N S ⟹ initial_lits_generalize_learned_trail_conflict N S'" and inv_sound_state: "sound_state N β initial_state" "scl N β S S' ⟹ sound_state N β S ⟹ sound_state N β S'" using trail_lits_ground_initial_state (*‹trail_lits_ground initial_state›*) scl_preserves_trail_lits_ground (*‹⟦scl (?N::('f, 'v) Term.term literal multiset fset) (?β::('f, 'v) Term.term) (?S::(('f, 'v) Term.term literal × (('f, 'v) Term.term literal multiset × ('f, 'v) Term.term literal × ('v ⇒ ('f, 'v) Term.term)) option) list × ('f, 'v) Term.term literal multiset fset × (('f, 'v) Term.term literal multiset × ('v ⇒ ('f, 'v) Term.term)) option) (?S'::(('f, 'v) Term.term literal × (('f, 'v) Term.term literal multiset × ('f, 'v) Term.term literal × ('v ⇒ ('f, 'v) Term.term)) option) list × ('f, 'v) Term.term literal multiset fset × (('f, 'v) Term.term literal multiset × ('v ⇒ ('f, 'v) Term.term)) option); trail_lits_ground ?S⟧ ⟹ trail_lits_ground ?S'›*) using trail_atoms_lt_initial_state (*‹trail_atoms_lt (?β::('f, 'v) Term.term) initial_state›*) scl_preserves_trail_atoms_lt (*‹⟦scl (?N::('f::type, 'v::type) Term.term literal multiset fset) (?β::('f::type, 'v::type) Term.term) (?S::(('f::type, 'v::type) Term.term literal × (('f::type, 'v::type) Term.term literal multiset × ('f::type, 'v::type) Term.term literal × ('v::type ⇒ ('f::type, 'v::type) Term.term)) option) list × ('f::type, 'v::type) Term.term literal multiset fset × (('f::type, 'v::type) Term.term literal multiset × ('v::type ⇒ ('f::type, 'v::type) Term.term)) option) (?S'::(('f::type, 'v::type) Term.term literal × (('f::type, 'v::type) Term.term literal multiset × ('f::type, 'v::type) Term.term literal × ('v::type ⇒ ('f::type, 'v::type) Term.term)) option) list × ('f::type, 'v::type) Term.term literal multiset fset × (('f::type, 'v::type) Term.term literal multiset × ('v::type ⇒ ('f::type, 'v::type) Term.term)) option); trail_atoms_lt ?β ?S⟧ ⟹ trail_atoms_lt ?β ?S'›*) using trail_lits_consistent_initial_state[unfolded trail_lits_consistent_def trail_consistent_iff] (*‹∀(Γ'::((?'a::type, ?'b::type) Term.term literal × ((?'a::type, ?'b::type) Term.term literal multiset × (?'a::type, ?'b::type) Term.term literal × (?'b::type ⇒ (?'a::type, ?'b::type) Term.term)) option) list) (Ln::(?'a::type, ?'b::type) Term.term literal × ((?'a::type, ?'b::type) Term.term literal multiset × (?'a::type, ?'b::type) Term.term literal × (?'b::type ⇒ (?'a::type, ?'b::type) Term.term)) option) Γ''::((?'a::type, ?'b::type) Term.term literal × ((?'a::type, ?'b::type) Term.term literal multiset × (?'a::type, ?'b::type) Term.term literal × (?'b::type ⇒ (?'a::type, ?'b::type) Term.term)) option) list. state_trail initial_state = Γ'' @ Ln # Γ' ⟶ ¬ trail_defined_lit Γ' (fst Ln)›*) scl_preserves_trail_lits_consistent[unfolded trail_lits_consistent_def trail_consistent_iff] (*‹⟦scl ?N ?β ?S ?S'; ∀Γ' Ln Γ''. state_trail ?S = Γ'' @ Ln # Γ' ⟶ ¬ trail_defined_lit Γ' (fst Ln)⟧ ⟹ ∀Γ' Ln Γ''. state_trail ?S' = Γ'' @ Ln # Γ' ⟶ ¬ trail_defined_lit Γ' (fst Ln)›*) using ground_closures_initial_state (*‹ground_closures initial_state›*) scl_preserves_ground_closures (*‹⟦scl ?N ?β ?S ?S'; ground_closures ?S⟧ ⟹ ground_closures ?S'›*) using ground_false_closures_initial_state (*‹ground_false_closures initial_state›*) scl_preserves_ground_false_closures (*‹⟦scl ?N ?β ?S ?S'; ground_false_closures ?S⟧ ⟹ ground_false_closures ?S'›*) using trail_propagated_lit_wf_initial_state (*‹∀𝒦∈set (state_trail initial_state). ∀D K γ. snd 𝒦 = Some (D, K, γ) ⟶ fst 𝒦 = K ⋅l γ›*) scl_preserves_trail_propagated_lit_wf (*‹⟦scl ?N ?β ?S ?S'; ∀𝒦∈set (state_trail ?S). ∀D K γ. snd 𝒦 = Some (D, K, γ) ⟶ fst 𝒦 = K ⋅l γ⟧ ⟹ ∀𝒦∈set (state_trail ?S'). ∀D K γ. snd 𝒦 = Some (D, K, γ) ⟶ fst 𝒦 = K ⋅l γ›*) using trail_resolved_lits_pol_initial_state (*‹trail_resolved_lits_pol initial_state›*) scl_preserves_trail_resolved_lits_pol (*‹⟦scl ?N ?β ?S ?S'; trail_resolved_lits_pol ?S⟧ ⟹ trail_resolved_lits_pol ?S'›*) using initial_lits_generalize_learned_trail_conflict_initial_state (*‹initial_lits_generalize_learned_trail_conflict ?N initial_state›*) scl_preserves_initial_lits_generalize_learned_trail_conflict (*‹⟦scl ?N ?β ?S ?S'; initial_lits_generalize_learned_trail_conflict ?N ?S⟧ ⟹ initial_lits_generalize_learned_trail_conflict ?N ?S'›*) using sound_initial_state (*‹sound_state (?N::('f, 'v) Term.term literal multiset fset) (?β::('f, 'v) Term.term) initial_state›*) scl_preserves_sound_state (*‹⟦scl ?N ?β ?S ?S'; sound_state ?N ?β ?S⟧ ⟹ sound_state ?N ?β ?S'›*) by ((metis)+) end
{ "path": "afp-2025-02-12/thys/Simple_Clause_Learning/Invariants.thy", "repo": "afp-2025-02-12", "sha": "b8f7c19519f00c715342b6a55aec31e47b0a60685a21c5e899e9cd3ad51ec51e" }
section "Sorts" (* Some stuff on sorts. Mostly from Sort.ML I think. *) theory Sorts imports Term begin definition [simp]: "empty_osig = ({}, Map.empty)" definition "sort_les cs s1 s2 = (sort_leq cs s1 s2 ∧ ¬ sort_leq cs s2 s1)" definition "sort_eqv cs s1 s2 = (sort_leq cs s1 s2 ∧ sort_leq cs s2 s1)" lemmas class_defs = class_leq_def class_les_def class_ex_def lemmas sort_defs = sort_leq_def sort_les_def sort_eqv_def sort_ex_def lemma sort_ex_class_ex: "sort_ex cs S ≡ ∀c ∈ S. class_ex cs c" by (auto simp add: sort_ex_def (*‹sort_ex ?rel ?S = (?S ⊆ Field ?rel)›*) class_ex_def (*‹class_ex ?rel ?c = (?c ∈ Field ?rel)›*) subset_eq (*‹(?A ⊆ ?B) = (∀x∈?A. x ∈ ?B)›*)) (* Did not want to write the wf_subclass cs assumption each time + allowed type class instances inside Now probably more trouble than help *) locale wf_subclass_loc = fixes cs :: "class rel" assumes wf[simp]: "wf_subclass cs" begin lemma class_les_irrefl: "¬ class_les cs c c" using wf (*‹wf_subclass cs›*) by (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)›*)) lemma class_les_trans: "class_les cs x y ⟹ class_les cs y z ⟹ class_les cs x z" using wf (*‹wf_subclass cs›*) 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)›*) trans_def (*‹trans ?r = (∀x y z. (x, y) ∈ ?r ⟶ (y, z) ∈ ?r ⟶ (x, z) ∈ ?r)›*)) lemma class_leq_refl[iff]: "class_ex cs c ⟹ class_leq cs c c" using wf (*‹wf_subclass cs›*) by (simp add: class_leq_def (*‹class_leq ?sub ?c1.0 ?c2.0 = ((?c1.0, ?c2.0) ∈ ?sub)›*) class_ex_def (*‹class_ex ?rel ?c = (?c ∈ Field ?rel)›*) refl_on_def (*‹refl_on ?A ?r = (?r ⊆ ?A × ?A ∧ (∀x∈?A. (x, x) ∈ ?r))›*)) lemma class_leq_trans: "class_leq cs x y ⟹ class_leq cs y z ⟹ class_leq cs x z" using wf (*‹wf_subclass cs›*) by (auto simp add: class_leq_def (*‹class_leq ?sub ?c1.0 ?c2.0 = ((?c1.0, ?c2.0) ∈ ?sub)›*) elim: transE (*‹⟦trans ?r; (?x, ?y) ∈ ?r; (?y, ?z) ∈ ?r; (?x, ?z) ∈ ?r ⟹ ?thesis⟧ ⟹ ?thesis›*)) lemma class_leq_antisym: "class_leq cs c1 c2 ⟹ class_leq cs c2 c1 ⟹ c1=c2" using wf (*‹wf_subclass (cs::(String.literal × String.literal) set)›*) by (auto intro: antisymD (*‹⟦antisym ?r; (?x, ?y) ∈ ?r; (?y, ?x) ∈ ?r⟧ ⟹ ?x = ?y›*) simp: trans_def (*‹trans ?r = (∀x y z. (x, y) ∈ ?r ⟶ (y, z) ∈ ?r ⟶ (x, z) ∈ ?r)›*) class_leq_def (*‹class_leq ?sub ?c1.0 ?c2.0 = ((?c1.0, ?c2.0) ∈ ?sub)›*)) (* classes form a ~ partial order with class_les/class_leq a for a well-formed a*) lemma sort_leq_refl[iff]: "sort_ex cs s ⟹ sort_leq cs s s" using class_leq_refl (*‹class_ex cs ?c ⟹ class_leq cs ?c ?c›*) by (auto simp add: sort_ex_class_ex (*‹sort_ex ?cs ?S ≡ ∀c∈?S. class_ex ?cs c›*) sort_leq_def (*‹sort_leq ?sub ?s1.0 ?s2.0 = (∀c₂∈?s2.0. ∃c₁∈?s1.0. class_leq ?sub c₁ c₂)›*)) lemma sort_leq_trans: "sort_leq cs x y ⟹ sort_leq cs y z ⟹ sort_leq cs x z" by (meson class_leq_trans (*‹⟦class_leq (cs::(String.literal × String.literal) set) (?x::String.literal) (?y::String.literal); class_leq cs ?y (?z::String.literal)⟧ ⟹ class_leq cs ?x ?z›*) 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₂)›*)) lemma sort_leq_ex: "sort_leq cs s1 s2 ⟹ sort_ex cs s2" by (auto simp add: sort_ex_def (*‹sort_ex (?rel::(?'a::type × ?'a::type) set) (?S::?'a::type set) = (?S ⊆ Field ?rel)›*) class_leq_def (*‹class_leq (?sub::(?'a::type × ?'b::type) set) (?c1.0::?'a::type) (?c2.0::?'b::type) = ((?c1.0, ?c2.0) ∈ ?sub)›*) sort_leq_def (*‹sort_leq (?sub::(?'a::type × ?'b::type) set) (?s1.0::?'a::type set) (?s2.0::?'b::type set) = (∀c₂::?'b::type∈?s2.0. ∃c₁::?'a::type∈?s1.0. class_leq ?sub c₁ c₂)›*) intro: FieldI2 (*‹(?i::?'a::type, ?j::?'a::type) ∈ (?R::(?'a::type × ?'a::type) set) ⟹ ?j ∈ Field ?R›*)) (* ... *) lemma sort_leq_minimize: "sort_leq cs s1 s2 ⟹ ∃s1'. (∀c1 ∈ s1' . ∃c2 ∈ s2. class_leq cs c1 c2) ∧ sort_leq cs s1' s2" by (meson class_leq_refl (*‹class_ex cs ?c ⟹ class_leq cs ?c ?c›*) sort_ex_class_ex (*‹sort_ex ?cs ?S ≡ ∀c∈?S. class_ex ?cs c›*) sort_leq_ex (*‹sort_leq cs ?s1.0 ?s2.0 ⟹ sort_ex cs ?s2.0›*) sort_leq_refl (*‹sort_ex cs ?s ⟹ sort_leq cs ?s ?s›*)) lemma "sort_ex cs s2 ⟹ s1 ⊆ s2 ⟹ sort_ex cs s1" by (meson sort_ex_def (*‹sort_ex ?rel ?S = (?S ⊆ Field ?rel)›*) subset_trans (*‹⟦?A ⊆ ?B; ?B ⊆ ?C⟧ ⟹ ?A ⊆ ?C›*)) lemma superset_imp_sort_leq: "sort_ex cs s2 ⟹ s1 ⊇ s2 ⟹ sort_leq cs s1 s2" by (auto simp add: sort_ex_class_ex (*‹sort_ex ?cs ?S ≡ ∀c∈?S. class_ex ?cs c›*) sort_leq_def (*‹sort_leq ?sub ?s1.0 ?s2.0 = (∀c₂∈?s2.0. ∃c₁∈?s1.0. class_leq ?sub c₁ c₂)›*) sort_ex_def (*‹sort_ex ?rel ?S = (?S ⊆ Field ?rel)›*)) lemma full_sort_top: "sort_ex cs s ⟹ sort_leq cs s full_sort" by (simp add: sort_leq_def (*‹sort_leq ?sub ?s1.0 ?s2.0 = (∀c₂∈?s2.0. ∃c₁∈?s1.0. class_leq ?sub c₁ c₂)›*)) (* Is this even useful? *) lemma sort_les_trans: "sort_les cs x y ⟹ sort_les cs y z ⟹ sort_les cs x z" using sort_les_def (*‹sort_les ?cs ?s1.0 ?s2.0 = (sort_leq ?cs ?s1.0 ?s2.0 ∧ ¬ sort_leq ?cs ?s2.0 ?s1.0)›*) sort_leq_trans (*‹⟦sort_leq (cs::(String.literal × String.literal) set) (?x::String.literal set) (?y::String.literal set); sort_leq cs ?y (?z::String.literal set)⟧ ⟹ sort_leq cs ?x ?z›*) by blast lemma sort_eqvI: "sort_leq cs s1 s2 ⟹ sort_leq cs s2 s1 ⟹ sort_eqv cs s1 s2" by (simp add: sort_eqv_def (*‹sort_eqv ?cs ?s1.0 ?s2.0 = (sort_leq ?cs ?s1.0 ?s2.0 ∧ sort_leq ?cs ?s2.0 ?s1.0)›*)) lemma sort_eqv_refl: "sort_ex cs s ⟹ sort_eqv cs s s" using sort_leq_refl (*‹sort_ex cs ?s ⟹ sort_leq cs ?s ?s›*) by (auto simp add: sort_eqv_def (*‹sort_eqv ?cs ?s1.0 ?s2.0 = (sort_leq ?cs ?s1.0 ?s2.0 ∧ sort_leq ?cs ?s2.0 ?s1.0)›*)) lemma sort_eqv_trans: "sort_eqv cs x y ⟹ sort_eqv cs y z ⟹ sort_eqv cs x z" using sort_eqv_def (*‹sort_eqv ?cs ?s1.0 ?s2.0 = (sort_leq ?cs ?s1.0 ?s2.0 ∧ sort_leq ?cs ?s2.0 ?s1.0)›*) sort_leq_trans (*‹⟦sort_leq (cs::(String.literal × String.literal) set) (?x::String.literal set) (?y::String.literal set); sort_leq cs ?y (?z::String.literal set)⟧ ⟹ sort_leq cs ?x ?z›*) by blast lemma sort_eqv_sym: "sort_eqv cs x y ⟹ sort_eqv cs y x" by (auto simp add: sort_eqv_def (*‹sort_eqv ?cs ?s1.0 ?s2.0 = (sort_leq ?cs ?s1.0 ?s2.0 ∧ sort_leq ?cs ?s2.0 ?s1.0)›*)) (* sort_eqv a is ~ equivalence relation.. *) lemma normalize_sort_empty[simp]: "normalize_sort cs full_sort = full_sort" by (simp add: normalize_sort_def (*‹normalize_sort (?sub::(String.literal × String.literal) set) (?S::String.literal set) = {c::String.literal ∈ ?S. ¬ (∃c'::String.literal∈?S. class_les ?sub c' c)}›*)) lemma normalize_sort_normalize_sort[simp]: "normalize_sort cs (normalize_sort cs s) = normalize_sort cs s" by (auto simp add: normalize_sort_def (*‹normalize_sort (?sub::(String.literal × String.literal) set) (?S::String.literal set) = {c::String.literal ∈ ?S. ¬ (∃c'::String.literal∈?S. class_les ?sub c' c)}›*)) lemma sort_ex_norm_sort: "sort_ex cs s ⟹ sort_ex cs (normalize_sort cs s)" by (simp add: normalize_sort_def (*‹normalize_sort ?sub ?S = {c ∈ ?S. ¬ (∃c'∈?S. class_les ?sub c' c)}›*) sort_ex_class_ex (*‹sort_ex ?cs ?S ≡ ∀c∈?S. class_ex ?cs c›*)) lemma normalized_sort_subset: "normalize_sort cs s ⊆ s" by (auto simp add: normalize_sort_def (*‹normalize_sort ?sub ?S = {c ∈ ?S. ¬ (∃c'∈?S. class_les ?sub c' c)}›*)) lemma normalize_sort_removed_elem_irrelevant': assumes "sort_ex cs (insert c s)" assumes "c ∉ (normalize_sort cs (insert c s))" shows "normalize_sort cs (insert c s) = normalize_sort cs s" proof (-) (*goal: ‹normalize_sort cs (insert c s) = normalize_sort cs s›*) have "class_ex cs c" using assms(1) (*‹sort_ex cs (insert c s)›*) by (auto simp add: sort_ex_class_ex (*‹sort_ex (?cs::(?'a × ?'a) set) (?S::?'a set) ≡ ∀c::?'a∈?S. class_ex ?cs c›*)) from this (*‹class_ex cs c›*) assms(2) (*‹c ∉ normalize_sort cs (insert c s)›*) obtain c' where "class_les cs c' c" "c' ∈ s" (*goal: ‹(⋀c'. ⟦class_les cs c' c; c' ∈ s⟧ ⟹ thesis) ⟹ thesis›*) using class_les_irrefl (*‹¬ class_les cs ?c ?c›*) by (auto simp add: normalize_sort_def (*‹normalize_sort ?sub ?S = {c ∈ ?S. ¬ (∃c'∈?S. class_les ?sub c' c)}›*)) thus "?thesis" (*goal: ‹normalize_sort cs (insert c s) = normalize_sort cs s›*) using ‹class_ex cs c› (*‹class_ex cs c›*) class_les_irrefl (*‹¬ class_les cs ?c ?c›*) class_les_trans (*‹⟦class_les cs ?x ?y; class_les cs ?y ?z⟧ ⟹ class_les cs ?x ?z›*) apply (simp add: normalize_sort_def (*‹normalize_sort ?sub ?S = {c ∈ ?S. ¬ (∃c'∈?S. class_les ?sub c' c)}›*)) (*goal: ‹normalize_sort cs (insert c s) = normalize_sort cs s›*) by blast qed corollary normalize_sort_removed_elem_irrelevant: assumes "sort_ex cs (insert c s)" assumes "c ∉ (normalize_sort cs (insert c s))" shows "normalize_sort cs (insert c s) = normalize_sort cs s" using assms (*‹sort_ex cs (insert c s)› ‹(c::String.literal) ∉ normalize_sort (cs::(String.literal × String.literal) set) (insert c (s::String.literal set))›*) normalize_sort_removed_elem_irrelevant' (*‹⟦sort_ex cs (insert ?c ?s); ?c ∉ normalize_sort cs (insert ?c ?s)⟧ ⟹ normalize_sort cs (insert ?c ?s) = normalize_sort cs ?s›*) by (simp add: normalize_sort_def (*‹normalize_sort ?sub ?S = {c ∈ ?S. ¬ (∃c'∈?S. class_les ?sub c' c)}›*)) lemma normalize_sort_nempt_is_nempty: assumes finite: "finite s" assumes nempty: "s ≠ full_sort" assumes "sort_ex cs s" shows "normalize_sort cs s ≠ full_sort" using assms (*‹finite s› ‹s ≠ full_sort› ‹sort_ex cs s›*) proof (induction s rule: finite_induct (*‹⟦finite ?F; ?P {}; ⋀x F. ⟦finite F; x ∉ F; ?P F⟧ ⟹ ?P (insert x F)⟧ ⟹ ?P ?F›*)) (*goals: 1. ‹⟦full_sort ≠ full_sort; sort_ex (cs::(String.literal × String.literal) set) full_sort⟧ ⟹ normalize_sort cs full_sort ≠ full_sort› 2. ‹⋀(x::String.literal) F::String.literal set. ⟦finite F; x ∉ F; ⟦F ≠ full_sort; sort_ex (cs::(String.literal × String.literal) set) F⟧ ⟹ normalize_sort cs F ≠ full_sort; insert x F ≠ full_sort; sort_ex cs (insert x F)⟧ ⟹ normalize_sort cs (insert x F) ≠ full_sort›*) case empty (*‹full_sort ≠ full_sort› ‹sort_ex (cs::(String.literal × String.literal) set) full_sort›*) then show "?case" (*goal: ‹normalize_sort (cs::(String.literal × String.literal) set) full_sort ≠ full_sort›*) by simp next (*goal: ‹⋀(x::String.literal) F::String.literal set. ⟦finite F; x ∉ F; ⟦F ≠ full_sort; sort_ex (cs::(String.literal × String.literal) set) F⟧ ⟹ normalize_sort cs F ≠ full_sort; insert x F ≠ full_sort; sort_ex cs (insert x F)⟧ ⟹ normalize_sort cs (insert x F) ≠ full_sort›*) case (insert c s) (*‹finite s› ‹c ∉ s› ‹⟦s ≠ full_sort; sort_ex cs s⟧ ⟹ normalize_sort cs s ≠ full_sort› ‹insert c s ≠ full_sort› ‹sort_ex cs (insert c s)›*) note ICons = this (*‹finite (s::String.literal set)› ‹c ∉ s› ‹⟦s ≠ full_sort; sort_ex cs s⟧ ⟹ normalize_sort cs s ≠ full_sort› ‹insert c s ≠ full_sort› ‹sort_ex cs (insert c s)›*) then show "?case" (*goal: ‹normalize_sort cs (insert c s) ≠ full_sort›*) proof (cases s) (*goals: 1. ‹⟦c ∉ s; ⟦s ≠ full_sort; sort_ex cs s⟧ ⟹ normalize_sort cs s ≠ full_sort; insert c s ≠ full_sort; sort_ex cs (insert c s); s = full_sort⟧ ⟹ normalize_sort cs (insert c s) ≠ full_sort› 2. ‹⋀A a. ⟦c ∉ s; ⟦s ≠ full_sort; sort_ex cs s⟧ ⟹ normalize_sort cs s ≠ full_sort; insert c s ≠ full_sort; sort_ex cs (insert c s); s = insert a A; finite A⟧ ⟹ normalize_sort cs (insert c s) ≠ full_sort›*) case emptyI (*‹s = full_sort›*) hence "normalize_sort cs (insert c s) = {c}" using insert (*‹finite s› ‹c ∉ s› ‹⟦s ≠ full_sort; sort_ex cs s⟧ ⟹ normalize_sort cs s ≠ full_sort› ‹insert c s ≠ full_sort› ‹sort_ex cs (insert c s)›*) class_les_irrefl (*‹¬ class_les cs ?c ?c›*) by (auto simp add: normalize_sort_def (*‹normalize_sort ?sub ?S = {c ∈ ?S. ¬ (∃c'∈?S. class_les ?sub c' c)}›*) sort_ex_class_ex (*‹sort_ex ?cs ?S ≡ ∀c∈?S. class_ex ?cs c›*)) then show "?thesis" (*goal: ‹normalize_sort cs (insert c s) ≠ full_sort›*) by simp next (*goal: ‹⋀A a. ⟦c ∉ s; ⟦s ≠ full_sort; sort_ex cs s⟧ ⟹ normalize_sort cs s ≠ full_sort; insert c s ≠ full_sort; sort_ex cs (insert c s); s = insert a A; finite A⟧ ⟹ normalize_sort cs (insert c s) ≠ full_sort›*) case (insertI c' s') (*‹(s::String.literal set) = insert (s'::String.literal) (c'::String.literal set)› ‹finite c'›*) hence "normalize_sort cs s ≠ full_sort" using ICons (*‹finite s› ‹c ∉ s› ‹⟦s ≠ full_sort; sort_ex cs s⟧ ⟹ normalize_sort cs s ≠ full_sort› ‹insert c s ≠ full_sort› ‹sort_ex cs (insert c s)›*) by (auto simp add: normalize_sort_def (*‹normalize_sort ?sub ?S = {c ∈ ?S. ¬ (∃c'∈?S. class_les ?sub c' c)}›*) sort_ex_class_ex (*‹sort_ex ?cs ?S ≡ ∀c∈?S. class_ex ?cs c›*)) then show "?thesis" (*goal: ‹normalize_sort (cs::(String.literal × String.literal) set) (insert (c::String.literal) (s::String.literal set)) ≠ full_sort›*) proof (cases "c ∈ (normalize_sort cs s)") (*goals: 1. ‹⟦normalize_sort cs s ≠ full_sort; c ∈ normalize_sort cs s⟧ ⟹ normalize_sort cs (insert c s) ≠ full_sort› 2. ‹⟦normalize_sort cs s ≠ full_sort; c ∉ normalize_sort cs s⟧ ⟹ normalize_sort cs (insert c s) ≠ full_sort›*) case True (*‹c ∈ normalize_sort cs s›*) hence "insert c s = s" using normalized_sort_subset (*‹normalize_sort cs ?s ⊆ ?s›*) by fastforce then show "?thesis" (*goal: ‹normalize_sort cs (insert c s) ≠ full_sort›*) using ICons (*‹finite s› ‹(c::String.literal) ∉ (s::String.literal set)› ‹⟦s ≠ full_sort; sort_ex cs s⟧ ⟹ normalize_sort cs s ≠ full_sort› ‹insert c s ≠ full_sort› ‹sort_ex cs (insert c s)›*) by (auto simp add: normalize_sort_def (*‹normalize_sort (?sub::(String.literal × String.literal) set) (?S::String.literal set) = {c::String.literal ∈ ?S. ¬ (∃c'::String.literal∈?S. class_les ?sub c' c)}›*) sort_ex_class_ex (*‹sort_ex (?cs::(?'a::type × ?'a::type) set) (?S::?'a::type set) ≡ ∀c::?'a::type∈?S. class_ex ?cs c›*) class_les_def (*‹class_les (?sub::(?'a::type × ?'a::type) set) (?c1.0::?'a::type) (?c2.0::?'a::type) = (class_leq ?sub ?c1.0 ?c2.0 ∧ ¬ class_leq ?sub ?c2.0 ?c1.0)›*)) next (*goal: ‹⟦normalize_sort cs s ≠ full_sort; c ∉ normalize_sort cs s⟧ ⟹ normalize_sort cs (insert c s) ≠ full_sort›*) case False (*‹c ∉ normalize_sort cs s›*) then show "?thesis" (*goal: ‹normalize_sort cs (insert c s) ≠ full_sort›*) using normalize_sort_removed_elem_irrelevant (*‹⟦sort_ex cs (insert ?c ?s); ?c ∉ normalize_sort cs (insert ?c ?s)⟧ ⟹ normalize_sort cs (insert ?c ?s) = normalize_sort cs ?s›*) using insert.prems(2) (*‹sort_ex cs (insert c s)›*) ICons(3) (*‹⟦(s::String.literal set) ≠ full_sort; sort_ex (cs::(String.literal × String.literal) set) s⟧ ⟹ normalize_sort cs s ≠ full_sort›*) ‹normalize_sort cs s ≠ full_sort› (*‹normalize_sort (cs::(String.literal × String.literal) set) (s::String.literal set) ≠ full_sort›*) by auto qed qed qed lemma choose_smaller_in_sort: assumes elem: "c ∈ s" and nelem: "c ∉ (normalize_sort cs s)" and "sort_ex cs s" obtains c' where "c' ∈ s" and "class_les cs c' c" using assms (*‹(c::String.literal) ∈ (s::String.literal set)› ‹c ∉ normalize_sort cs s› ‹sort_ex cs s›*) by (auto simp add: normalize_sort_def (*‹normalize_sort ?sub ?S = {c ∈ ?S. ¬ (∃c'∈?S. class_les ?sub c' c)}›*) sort_ex_class_ex (*‹sort_ex ?cs ?S ≡ ∀c∈?S. class_ex ?cs c›*)) lemma normalize_ex_bound': assumes finite: "finite s" and elem: "c ∈ s" and nelem: "c ∉ (normalize_sort cs s)" and "sort_ex cs s" shows "∃c' ∈ (normalize_sort cs s) . class_les cs c' c" using assms (*‹finite s› ‹(c::String.literal) ∈ (s::String.literal set)› ‹(c::String.literal) ∉ normalize_sort (cs::(String.literal × String.literal) set) (s::String.literal set)› ‹sort_ex cs s›*) proof (induction s arbitrary: c) (*goals: 1. ‹⋀c. ⟦c ∈ full_sort; c ∉ normalize_sort cs full_sort; sort_ex cs full_sort⟧ ⟹ ∃c'∈normalize_sort cs full_sort. class_les cs c' c› 2. ‹⋀x F c. ⟦finite F; x ∉ F; ⋀c. ⟦c ∈ F; c ∉ normalize_sort cs F; sort_ex cs F⟧ ⟹ ∃c'∈normalize_sort cs F. class_les cs c' c; c ∈ insert x F; c ∉ normalize_sort cs (insert x F); sort_ex cs (insert x F)⟧ ⟹ ∃c'∈normalize_sort cs (insert x F). class_les cs c' c›*) case empty (*‹c ∈ full_sort› ‹c ∉ normalize_sort cs full_sort› ‹sort_ex (cs::(String.literal × String.literal) set) full_sort›*) then show "?case" (*goal: ‹∃c'∈normalize_sort cs full_sort. class_les cs c' c›*) by simp next (*goal: ‹⋀x F c. ⟦finite F; x ∉ F; ⋀c. ⟦c ∈ F; c ∉ normalize_sort cs F; sort_ex cs F⟧ ⟹ ∃c'∈normalize_sort cs F. class_les cs c' c; c ∈ insert x F; c ∉ normalize_sort cs (insert x F); sort_ex cs (insert x F)⟧ ⟹ ∃c'∈normalize_sort cs (insert x F). class_les cs c' c›*) case (insert ic s) (*‹finite s› ‹(ic::String.literal) ∉ (s::String.literal set)› ‹⟦(?c::String.literal) ∈ (s::String.literal set); ?c ∉ normalize_sort (cs::(String.literal × String.literal) set) s; sort_ex cs s⟧ ⟹ ∃c'::String.literal∈normalize_sort cs s. class_les cs c' ?c› ‹c ∈ insert ic s› ‹c ∉ normalize_sort cs (insert ic s)› ‹sort_ex cs (insert ic s)›*) then show "?case" (*goal: ‹∃c'∈normalize_sort cs (insert ic s). class_les cs c' c›*) proof (cases "ic=c") (*goals: 1. ‹⟦finite (s::String.literal set); (ic::String.literal) ∉ s; ⋀c::String.literal. ⟦c ∈ s; c ∉ normalize_sort (cs::(String.literal × String.literal) set) s; sort_ex cs s⟧ ⟹ ∃c'::String.literal∈normalize_sort cs s. class_les cs c' c; (c::String.literal) ∈ insert ic s; c ∉ normalize_sort cs (insert ic s); sort_ex cs (insert ic s); ic = c⟧ ⟹ ∃c'::String.literal∈normalize_sort cs (insert ic s). class_les cs c' c› 2. ‹⟦finite (s::String.literal set); (ic::String.literal) ∉ s; ⋀c::String.literal. ⟦c ∈ s; c ∉ normalize_sort (cs::(String.literal × String.literal) set) s; sort_ex cs s⟧ ⟹ ∃c'::String.literal∈normalize_sort cs s. class_les cs c' c; (c::String.literal) ∈ insert ic s; c ∉ normalize_sort cs (insert ic s); sort_ex cs (insert ic s); ic ≠ c⟧ ⟹ ∃c'::String.literal∈normalize_sort cs (insert ic s). class_les cs c' c›*) case True (*‹ic = c›*) then show "?thesis" (*goal: ‹∃c'∈normalize_sort cs (insert ic s). class_les cs c' c›*) by (smt choose_smaller_in_sort (*‹⟦?c ∈ ?s; ?c ∉ normalize_sort cs ?s; sort_ex cs ?s; ⋀c'. ⟦c' ∈ ?s; class_les cs c' ?c⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*) class_les_irrefl (*‹¬ class_les cs ?c ?c›*) class_les_trans (*‹⟦class_les cs ?x ?y; class_les cs ?y ?z⟧ ⟹ class_les cs ?x ?z›*) insert.IH (*‹⟦?c ∈ s; ?c ∉ normalize_sort cs s; sort_ex cs s⟧ ⟹ ∃c'∈normalize_sort cs s. class_les cs c' ?c›*) insert.prems( (*‹c ∉ normalize_sort cs (insert ic s)›*) 2) insert.prems( (*‹sort_ex cs (insert ic s)›*) 3) insert_iff (*‹(?a ∈ insert ?b ?A) = (?a = ?b ∨ ?a ∈ ?A)›*) insert_subset (*‹(insert ?x ?A ⊆ ?B) = (?x ∈ ?B ∧ ?A ⊆ ?B)›*) normalize_sort_removed_elem_irrelevant' (*‹⟦sort_ex cs (insert ?c ?s); ?c ∉ normalize_sort cs (insert ?c ?s)⟧ ⟹ normalize_sort cs (insert ?c ?s) = normalize_sort cs ?s›*) sort_ex_def (*‹sort_ex ?rel ?S = (?S ⊆ Field ?rel)›*)) next (*goal: ‹⟦finite s; ic ∉ s; ⋀c. ⟦c ∈ s; c ∉ normalize_sort cs s; sort_ex cs s⟧ ⟹ ∃c'∈normalize_sort cs s. class_les cs c' c; c ∈ insert ic s; c ∉ normalize_sort cs (insert ic s); sort_ex cs (insert ic s); ic ≠ c⟧ ⟹ ∃c'∈normalize_sort cs (insert ic s). class_les cs c' c›*) case False (*‹(ic::String.literal) ≠ (c::String.literal)›*) hence "c ∈ s" using insert.prems (*‹c ∈ insert ic s› ‹(c::String.literal) ∉ normalize_sort (cs::(String.literal × String.literal) set) (insert (ic::String.literal) (s::String.literal set))› ‹sort_ex cs (insert ic s)›*) by simp then show "?thesis" (*goal: ‹∃c'::String.literal∈normalize_sort (cs::(String.literal × String.literal) set) (insert (ic::String.literal) (s::String.literal set)). class_les cs c' (c::String.literal)›*) proof (cases "ic ∈ (normalize_sort cs (insert ic s))") (*goals: 1. ‹⟦c ∈ s; ic ∈ normalize_sort cs (insert ic s)⟧ ⟹ ∃c'∈normalize_sort cs (insert ic s). class_les cs c' c› 2. ‹⟦c ∈ s; ic ∉ normalize_sort cs (insert ic s)⟧ ⟹ ∃c'∈normalize_sort cs (insert ic s). class_les cs c' c›*) case True (*‹ic ∈ normalize_sort cs (insert ic s)›*) then show "?thesis" (*goal: ‹∃c'∈normalize_sort cs (insert ic s). class_les cs c' c›*) proof (cases "class_les cs ic c") (*goals: 1. ‹⟦ic ∈ normalize_sort cs (insert ic s); class_les cs ic c⟧ ⟹ ∃c'∈normalize_sort cs (insert ic s). class_les cs c' c› 2. ‹⟦ic ∈ normalize_sort cs (insert ic s); ¬ class_les cs ic c⟧ ⟹ ∃c'∈normalize_sort cs (insert ic s). class_les cs c' c›*) case True (*‹class_les cs ic c›*) then show "?thesis" (*goal: ‹∃c'∈normalize_sort cs (insert ic s). class_les cs c' c›*) using insert (*‹finite s› ‹ic ∉ s› ‹⟦?c ∈ s; ?c ∉ normalize_sort cs s; sort_ex cs s⟧ ⟹ ∃c'∈normalize_sort cs s. class_les cs c' ?c› ‹c ∈ insert ic s› ‹c ∉ normalize_sort cs (insert ic s)› ‹sort_ex cs (insert ic s)›*) ‹c ∈ s› (*‹c ∈ s›*) normalize_sort_removed_elem_irrelevant' (*‹⟦sort_ex cs (insert ?c ?s); ?c ∉ normalize_sort cs (insert ?c ?s)⟧ ⟹ normalize_sort cs (insert ?c ?s) = normalize_sort cs ?s›*) sort_ex_def (*‹sort_ex ?rel ?S = (?S ⊆ Field ?rel)›*) by (metis insert_subset (*‹(insert ?x ?A ⊆ ?B) = (?x ∈ ?B ∧ ?A ⊆ ?B)›*)) next (*goal: ‹⟦(ic::String.literal) ∈ normalize_sort (cs::(String.literal × String.literal) set) (insert ic (s::String.literal set)); ¬ class_les cs ic (c::String.literal)⟧ ⟹ ∃c'::String.literal∈normalize_sort cs (insert ic s). class_les cs c' c›*) case False (*‹¬ class_les cs ic c›*) obtain c'' where c'': "c'' ∈ (normalize_sort cs s)" "class_les cs c'' c" (*goal: ‹(⋀c''. ⟦c'' ∈ normalize_sort cs s; class_les cs c'' c⟧ ⟹ thesis) ⟹ thesis›*) using insert (*‹finite s› ‹ic ∉ s› ‹⟦?c ∈ s; ?c ∉ normalize_sort cs s; sort_ex cs s⟧ ⟹ ∃c'∈normalize_sort cs s. class_les cs c' ?c› ‹c ∈ insert ic s› ‹c ∉ normalize_sort cs (insert ic s)› ‹sort_ex cs (insert ic s)›*) ‹c ∈ s› (*‹c ∈ s›*) normalize_sort_removed_elem_irrelevant' (*‹⟦sort_ex cs (insert ?c ?s); ?c ∉ normalize_sort cs (insert ?c ?s)⟧ ⟹ normalize_sort cs (insert ?c ?s) = normalize_sort cs ?s›*) sort_ex_def (*‹sort_ex ?rel ?S = (?S ⊆ Field ?rel)›*) by (metis False (*‹¬ class_les (cs::(String.literal × String.literal) set) (ic::String.literal) (c::String.literal)›*) choose_smaller_in_sort (*‹⟦(?c::String.literal) ∈ (?s::String.literal set); ?c ∉ normalize_sort (cs::(String.literal × String.literal) set) ?s; sort_ex cs ?s; ⋀c'::String.literal. ⟦c' ∈ ?s; class_les cs c' ?c⟧ ⟹ ?thesis::bool⟧ ⟹ ?thesis›*) class_les_trans (*‹⟦class_les (cs::(String.literal × String.literal) set) (?x::String.literal) (?y::String.literal); class_les cs ?y (?z::String.literal)⟧ ⟹ class_les cs ?x ?z›*) insert_iff (*‹((?a::?'a) ∈ insert (?b::?'a) (?A::?'a set)) = (?a = ?b ∨ ?a ∈ ?A)›*) insert_subset (*‹(insert (?x::?'a) (?A::?'a set) ⊆ (?B::?'a set)) = (?x ∈ ?B ∧ ?A ⊆ ?B)›*)) moreover have "(c'', c) ∈ cs" "(c, c'') ∉ cs" using c'' (*‹c'' ∈ normalize_sort cs s› ‹class_les cs c'' c›*) apply - (*goals: 1. ‹⟦c'' ∈ normalize_sort cs s; class_les cs c'' c⟧ ⟹ (c'', c) ∈ cs› 2. ‹⟦c'' ∈ normalize_sort cs s; class_les cs c'' c⟧ ⟹ (c, c'') ∉ cs› discuss goal 1*) apply (simp add: class_leq_def (*‹class_leq ?sub ?c1.0 ?c2.0 = ((?c1.0, ?c2.0) ∈ ?sub)›*) class_les_def (*‹class_les ?sub ?c1.0 ?c2.0 = (class_leq ?sub ?c1.0 ?c2.0 ∧ ¬ class_leq ?sub ?c2.0 ?c1.0)›*)) (*discuss goal 2*) apply (simp add: class_leq_def (*‹class_leq ?sub ?c1.0 ?c2.0 = ((?c1.0, ?c2.0) ∈ ?sub)›*) class_les_def (*‹class_les ?sub ?c1.0 ?c2.0 = (class_leq ?sub ?c1.0 ?c2.0 ∧ ¬ class_leq ?sub ?c2.0 ?c1.0)›*)) (*proven 2 subgoals*) . moreover hence "¬ class_les cs ic c''" by (meson False (*‹¬ class_les cs ic c›*) class_leq_def (*‹class_leq ?sub ?c1.0 ?c2.0 = ((?c1.0, ?c2.0) ∈ ?sub)›*) 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_les_trans (*‹⟦class_les cs ?x ?y; class_les cs ?y ?z⟧ ⟹ class_les cs ?x ?z›*)) ultimately show "?thesis" (*goal: ‹∃c'∈normalize_sort cs (insert ic s). class_les cs c' c›*) by (auto simp add: normalize_sort_def (*‹normalize_sort ?sub ?S = {c ∈ ?S. ¬ (∃c'∈?S. class_les ?sub c' c)}›*) sort_ex_class_ex (*‹sort_ex ?cs ?S ≡ ∀c∈?S. class_ex ?cs c›*) class_ex_def (*‹class_ex ?rel ?c = (?c ∈ Field ?rel)›*) class_leq_def (*‹class_leq ?sub ?c1.0 ?c2.0 = ((?c1.0, ?c2.0) ∈ ?sub)›*) class_les_def (*‹class_les ?sub ?c1.0 ?c2.0 = (class_leq ?sub ?c1.0 ?c2.0 ∧ ¬ class_leq ?sub ?c2.0 ?c1.0)›*)) qed next (*goal: ‹⟦c ∈ s; ic ∉ normalize_sort cs (insert ic s)⟧ ⟹ ∃c'∈normalize_sort cs (insert ic s). class_les cs c' c›*) case False (*‹(ic::String.literal) ∉ normalize_sort (cs::(String.literal × String.literal) set) (insert ic (s::String.literal set))›*) then show "?thesis" (*goal: ‹∃c'∈normalize_sort cs (insert ic s). class_les cs c' c›*) by (metis (full_types) insert.IH (*‹⟦?c ∈ s; ?c ∉ normalize_sort cs s; sort_ex cs s⟧ ⟹ ∃c'∈normalize_sort cs s. class_les cs c' ?c›*) insert.prems( (*‹c ∉ normalize_sort cs (insert ic s)›*) 2) insert.prems( (*‹sort_ex cs (insert ic s)›*) 3) ‹c ∈ s› normalize_sort_removed_elem_irrelevant (*‹⟦sort_ex cs (insert ?c ?s); ?c ∉ normalize_sort cs (insert ?c ?s)⟧ ⟹ normalize_sort cs (insert ?c ?s) = normalize_sort cs ?s›*) sort_ex_def (*‹sort_ex ?rel ?S = (?S ⊆ Field ?rel)›*) insert_subset (*‹(insert ?x ?A ⊆ ?B) = (?x ∈ ?B ∧ ?A ⊆ ?B)›*)) qed qed qed corollary normalize_ex_bound: assumes finite: "finite s" and elem: "c ∈ s" and nelem: "c ∉ (normalize_sort cs s)" and "sort_ex cs s" obtains c' where "c' ∈ (normalize_sort cs s)" and "class_les cs c' c" using assms (*‹finite s› ‹c ∈ s› ‹c ∉ normalize_sort cs s› ‹sort_ex (cs::(String.literal × String.literal) set) (s::String.literal set)›*) normalize_ex_bound' (*‹⟦finite (?s::String.literal set); (?c::String.literal) ∈ ?s; ?c ∉ normalize_sort (cs::(String.literal × String.literal) set) ?s; sort_ex cs ?s⟧ ⟹ ∃c'::String.literal∈normalize_sort cs ?s. class_les cs c' ?c›*) by auto lemma "sort_ex cs s ⟹ sort_leq cs s (normalize_sort cs s)" by (auto simp add: normalize_sort_def (*‹normalize_sort ?sub ?S = {c ∈ ?S. ¬ (∃c'∈?S. class_les ?sub c' c)}›*) sort_leq_def (*‹sort_leq ?sub ?s1.0 ?s2.0 = (∀c₂∈?s2.0. ∃c₁∈?s1.0. class_leq ?sub c₁ c₂)›*) sort_ex_class_ex (*‹sort_ex ?cs ?S ≡ ∀c∈?S. class_ex ?cs c›*)) lemma sort_eqv_normalize_sort: assumes "finite s" assumes "sort_ex cs s" shows "sort_eqv cs s (normalize_sort cs s)" proof (intro sort_eqvI (*‹⟦sort_leq (cs::(String.literal × String.literal) set) (?s1.0::String.literal set) (?s2.0::String.literal set); sort_leq cs ?s2.0 ?s1.0⟧ ⟹ sort_eqv cs ?s1.0 ?s2.0›*)) (*goals: 1. ‹sort_leq (cs::(String.literal × String.literal) set) (s::String.literal set) (normalize_sort cs s)› 2. ‹sort_leq (cs::(String.literal × String.literal) set) (normalize_sort cs (s::String.literal set)) s›*) show "sort_leq cs s (normalize_sort cs s)" using assms(2) (*‹sort_ex cs s›*) by (auto simp add: normalize_sort_def (*‹normalize_sort ?sub ?S = {c ∈ ?S. ¬ (∃c'∈?S. class_les ?sub c' c)}›*) sort_leq_def (*‹sort_leq ?sub ?s1.0 ?s2.0 = (∀c₂∈?s2.0. ∃c₁∈?s1.0. class_leq ?sub c₁ c₂)›*) sort_ex_class_ex (*‹sort_ex ?cs ?S ≡ ∀c∈?S. class_ex ?cs c›*)) next (*goal: ‹sort_leq cs (normalize_sort cs s) s›*) show "sort_leq cs (normalize_sort cs s) s" apply (unfold 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₂)›*)) (*goal: ‹sort_leq cs (normalize_sort cs s) s›*) proof (intro ballI (*‹(⋀x. x ∈ ?A ⟹ ?P x) ⟹ ∀x∈?A. ?P x›*)) (*goal: ‹⋀c₂. c₂ ∈ s ⟹ ∃c₁∈normalize_sort cs s. class_leq cs c₁ c₂›*) fix c2 assume "c2 ∈ s" (*‹(c2::String.literal) ∈ (s::String.literal set)›*) show "∃c1 ∈ normalize_sort cs s. class_leq cs c1 c2" proof (cases "c2 ∈ normalize_sort cs s") (*goals: 1. ‹c2 ∈ normalize_sort cs s ⟹ ∃c1∈normalize_sort cs s. class_leq cs c1 c2› 2. ‹c2 ∉ normalize_sort cs s ⟹ ∃c1∈normalize_sort cs s. class_leq cs c1 c2›*) case True (*‹(c2::String.literal) ∈ normalize_sort (cs::(String.literal × String.literal) set) (s::String.literal set)›*) then show "?thesis" (*goal: ‹∃c1∈normalize_sort cs s. class_leq cs c1 c2›*) using ‹c2 ∈ s› (*‹(c2::String.literal) ∈ (s::String.literal set)›*) assms (*‹finite s› ‹sort_ex (cs::(String.literal × String.literal) set) (s::String.literal set)›*) sort_ex_class_ex (*‹sort_ex ?cs ?S ≡ ∀c∈?S. class_ex ?cs c›*) by fast next (*goal: ‹(c2::String.literal) ∉ normalize_sort (cs::(String.literal × String.literal) set) (s::String.literal set) ⟹ ∃c1::String.literal∈normalize_sort cs s. class_leq cs c1 c2›*) case False (*‹c2 ∉ normalize_sort cs s›*) from this (*‹c2 ∉ normalize_sort cs s›*) obtain c' where "c' ∈ normalize_sort cs s" and "class_les cs c' c2" (*goal: ‹(⋀c'. ⟦c' ∈ normalize_sort cs s; class_les cs c' c2⟧ ⟹ thesis) ⟹ thesis›*) using ‹c2 ∈ s› (*‹c2 ∈ s›*) normalize_ex_bound (*‹⟦finite ?s; ?c ∈ ?s; ?c ∉ normalize_sort cs ?s; sort_ex cs ?s; ⋀c'. ⟦c' ∈ normalize_sort cs ?s; class_les cs c' ?c⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*) assms (*‹finite (s::String.literal set)› ‹sort_ex cs s›*) by metis then show "?thesis" (*goal: ‹∃c1∈normalize_sort cs s. class_leq cs c1 c2›*) using class_les_def (*‹class_les (?sub::(?'a::type × ?'a::type) set) (?c1.0::?'a::type) (?c2.0::?'a::type) = (class_leq ?sub ?c1.0 ?c2.0 ∧ ¬ class_leq ?sub ?c2.0 ?c1.0)›*) by metis qed qed qed lemma normalize_sort_eq_imp_sort_eqv: "sort_ex cs s1 ⟹ sort_ex cs s2 ⟹ finite s1 ⟹ finite s2 ⟹ normalize_sort cs s1 = normalize_sort cs s2 ⟹ sort_eqv cs s1 s2" by (metis sort_eqv_sym (*‹sort_eqv (cs::(String.literal × String.literal) set) (?x::String.literal set) (?y::String.literal set) ⟹ sort_eqv cs ?y ?x›*) sort_eqv_trans (*‹⟦sort_eqv (cs::(String.literal × String.literal) set) (?x::String.literal set) (?y::String.literal set); sort_eqv cs ?y (?z::String.literal set)⟧ ⟹ sort_eqv cs ?x ?z›*) wf_subclass_loc.sort_eqv_normalize_sort (*‹⟦wf_subclass_loc (?cs::(String.literal × String.literal) set); finite (?s::String.literal set); sort_ex ?cs ?s⟧ ⟹ sort_eqv ?cs ?s (normalize_sort ?cs ?s)›*) wf_subclass_loc_axioms (*‹wf_subclass_loc (cs::(String.literal × String.literal) set)›*)) lemma "class_leq cs c1 c2 ⟷ class_les cs c1 c2 ∨ (c1=c2 ∧ class_ex cs c1)" by (meson FieldI1 (*‹(?i, ?j) ∈ ?R ⟹ ?i ∈ Field ?R›*) class_ex_def (*‹class_ex ?rel ?c = (?c ∈ Field ?rel)›*) class_leq_antisym (*‹⟦class_leq cs ?c1.0 ?c2.0; class_leq cs ?c2.0 ?c1.0⟧ ⟹ ?c1.0 = ?c2.0›*) class_leq_def (*‹class_leq ?sub ?c1.0 ?c2.0 = ((?c1.0, ?c2.0) ∈ ?sub)›*) class_leq_refl (*‹class_ex cs ?c ⟹ class_leq cs ?c ?c›*) class_les_def (*‹class_les ?sub ?c1.0 ?c2.0 = (class_leq ?sub ?c1.0 ?c2.0 ∧ ¬ class_leq ?sub ?c2.0 ?c1.0)›*)) lemma sort_eqv_imp_normalize_sort_eq: assumes "sort_ex cs s1" "sort_ex cs s2" "sort_eqv cs s1 s2" shows "normalize_sort cs s1 = normalize_sort cs s2" proof (rule ccontr (*‹(¬ ?P ⟹ False) ⟹ ?P›*)) (*goal: ‹normalize_sort (cs::(String.literal × String.literal) set) (s1::String.literal set) ≠ normalize_sort cs (s2::String.literal set) ⟹ False›*) have "sort_leq cs s1 s2" "sort_leq cs s2 s1" using assms(3) (*‹sort_eqv (cs::(String.literal × String.literal) set) (s1::String.literal set) (s2::String.literal set)›*) apply - (*goals: 1. ‹sort_eqv cs s1 s2 ⟹ sort_leq cs s1 s2› 2. ‹sort_eqv cs s1 s2 ⟹ sort_leq cs s2 s1› discuss goal 1*) apply ((auto simp add: sort_eqv_def (*‹sort_eqv ?cs ?s1.0 ?s2.0 = (sort_leq ?cs ?s1.0 ?s2.0 ∧ sort_leq ?cs ?s2.0 ?s1.0)›*))[1]) (*discuss goal 2*) apply ((auto simp add: sort_eqv_def (*‹sort_eqv ?cs ?s1.0 ?s2.0 = (sort_leq ?cs ?s1.0 ?s2.0 ∧ sort_leq ?cs ?s2.0 ?s1.0)›*))[1]) (*proven 2 subgoals*) . assume "normalize_sort cs s1 ≠ normalize_sort cs s2" (*‹normalize_sort (cs::(String.literal × String.literal) set) (s1::String.literal set) ≠ normalize_sort cs (s2::String.literal set)›*) hence "¬ normalize_sort cs s1 ⊆ normalize_sort cs s2 ∨ ¬ normalize_sort cs s2 ⊆ normalize_sort cs s1" by simp from this (*‹¬ normalize_sort cs s1 ⊆ normalize_sort cs s2 ∨ ¬ normalize_sort cs s2 ⊆ normalize_sort cs s1›*) consider "¬ normalize_sort cs s1 ⊆ normalize_sort cs s2" | "normalize_sort cs s1 ⊆ normalize_sort cs s2" and "¬ normalize_sort cs s2 ⊆ normalize_sort cs s1" (*goal: ‹⟦¬ normalize_sort cs s1 ⊆ normalize_sort cs s2 ⟹ thesis; ⟦normalize_sort cs s1 ⊆ normalize_sort cs s2; ¬ normalize_sort cs s2 ⊆ normalize_sort cs s1⟧ ⟹ thesis⟧ ⟹ thesis›*) by blast thus False proof (cases) (*goals: 1. ‹¬ normalize_sort cs s1 ⊆ normalize_sort cs s2 ⟹ False› 2. ‹⟦normalize_sort cs s1 ⊆ normalize_sort cs s2; ¬ normalize_sort cs s2 ⊆ normalize_sort cs s1⟧ ⟹ False›*) case 1 (*‹¬ normalize_sort cs s1 ⊆ normalize_sort cs s2›*) from this (*‹¬ normalize_sort cs s1 ⊆ normalize_sort cs s2›*) obtain c where c: "c ∈ normalize_sort cs s1" "c ∉ normalize_sort cs s2" (*goal: ‹(⋀c. ⟦c ∈ normalize_sort cs s1; c ∉ normalize_sort cs s2⟧ ⟹ thesis) ⟹ thesis›*) by blast from this (*‹c ∈ normalize_sort cs s1› ‹c ∉ normalize_sort cs s2›*) obtain c' where c': "c' ∈ normalize_sort cs s2" "class_les cs c' c" (*goal: ‹(⋀c'. ⟦c' ∈ normalize_sort cs s2; class_les cs c' c⟧ ⟹ thesis) ⟹ thesis›*) by (smt ‹sort_leq cs s1 s2› ‹sort_leq cs s2 s1› class_les_def (*‹class_les ?sub ?c1.0 ?c2.0 = (class_leq ?sub ?c1.0 ?c2.0 ∧ ¬ class_leq ?sub ?c2.0 ?c1.0)›*) mem_Collect_eq (*‹(?a ∈ Collect ?P) = ?P ?a›*) normalize_sort_def (*‹normalize_sort ?sub ?S = {c ∈ ?S. ¬ (∃c'∈?S. class_les ?sub c' c)}›*) sort_leq_def (*‹sort_leq ?sub ?s1.0 ?s2.0 = (∀c₂∈?s2.0. ∃c₁∈?s1.0. class_leq ?sub c₁ c₂)›*) wf_subclass_loc.class_leq_antisym (*‹⟦wf_subclass_loc ?cs; class_leq ?cs ?c1.0 ?c2.0; class_leq ?cs ?c2.0 ?c1.0⟧ ⟹ ?c1.0 = ?c2.0›*) wf_subclass_loc.class_leq_trans (*‹⟦wf_subclass_loc ?cs; class_leq ?cs ?x ?y; class_leq ?cs ?y ?z⟧ ⟹ class_leq ?cs ?x ?z›*) wf_subclass_loc_axioms (*‹wf_subclass_loc cs›*)) then show "?thesis" (*goal: ‹False›*) proof (cases "c' ∈ normalize_sort cs s1") (*goals: 1. ‹⟦c' ∈ normalize_sort cs s2; class_les cs c' c; c' ∈ normalize_sort cs s1⟧ ⟹ False› 2. ‹⟦c' ∈ normalize_sort cs s2; class_les cs c' c; c' ∉ normalize_sort cs s1⟧ ⟹ False›*) case True (*‹c' ∈ normalize_sort cs s1›*) hence "c ∉ normalize_sort cs s1" using c (*‹(c::String.literal) ∈ normalize_sort (cs::(String.literal × String.literal) set) (s1::String.literal set)› ‹c ∉ normalize_sort cs s2›*) c' (*‹c' ∈ normalize_sort cs s2› ‹class_les cs c' c›*) by (auto simp add: normalize_sort_def (*‹normalize_sort ?sub ?S = {c ∈ ?S. ¬ (∃c'∈?S. class_les ?sub c' c)}›*)) then show "?thesis" (*goal: ‹False›*) using c(1) (*‹c ∈ normalize_sort cs s1›*) by simp next (*goal: ‹⟦(c'::String.literal) ∈ normalize_sort (cs::(String.literal × String.literal) set) (s2::String.literal set); class_les cs c' (c::String.literal); c' ∉ normalize_sort cs (s1::String.literal set)⟧ ⟹ False›*) case False (*‹c' ∉ normalize_sort cs s1›*) from False (*‹c' ∉ normalize_sort cs s1›*) c' (*‹c' ∈ normalize_sort cs s2› ‹class_les cs c' c›*) obtain c'' where c'': "c'' ∈ normalize_sort cs s1" "class_les cs c'' c'" (*goal: ‹(⋀c''. ⟦c'' ∈ normalize_sort cs s1; class_les cs c'' c'⟧ ⟹ thesis) ⟹ thesis›*) by (smt ‹sort_leq cs s1 s2› ‹sort_leq cs s2 s1› class_les_def (*‹class_les ?sub ?c1.0 ?c2.0 = (class_leq ?sub ?c1.0 ?c2.0 ∧ ¬ class_leq ?sub ?c2.0 ?c1.0)›*) mem_Collect_eq (*‹(?a ∈ Collect ?P) = ?P ?a›*) normalize_sort_def (*‹normalize_sort ?sub ?S = {c ∈ ?S. ¬ (∃c'∈?S. class_les ?sub c' c)}›*) sort_leq_def (*‹sort_leq ?sub ?s1.0 ?s2.0 = (∀c₂∈?s2.0. ∃c₁∈?s1.0. class_leq ?sub c₁ c₂)›*) wf_subclass_loc.class_leq_antisym (*‹⟦wf_subclass_loc ?cs; class_leq ?cs ?c1.0 ?c2.0; class_leq ?cs ?c2.0 ?c1.0⟧ ⟹ ?c1.0 = ?c2.0›*) wf_subclass_loc.class_leq_trans (*‹⟦wf_subclass_loc ?cs; class_leq ?cs ?x ?y; class_leq ?cs ?y ?z⟧ ⟹ class_leq ?cs ?x ?z›*) wf_subclass_loc_axioms (*‹wf_subclass_loc cs›*)) hence "class_les cs c'' c" using c'(2) (*‹class_les cs c' c›*) class_les_trans (*‹⟦class_les cs ?x ?y; class_les cs ?y ?z⟧ ⟹ class_les cs ?x ?z›*) by blast hence "c ∉ normalize_sort cs s1" using c (*‹c ∈ normalize_sort cs s1› ‹c ∉ normalize_sort cs s2›*) c'' (*‹c'' ∈ normalize_sort cs s1› ‹class_les cs c'' c'›*) by (auto simp add: normalize_sort_def (*‹normalize_sort ?sub ?S = {c ∈ ?S. ¬ (∃c'∈?S. class_les ?sub c' c)}›*)) then show "?thesis" (*goal: ‹False›*) using c(1) (*‹c ∈ normalize_sort cs s1›*) by simp qed next (*goal: ‹⟦normalize_sort cs s1 ⊆ normalize_sort cs s2; ¬ normalize_sort cs s2 ⊆ normalize_sort cs s1⟧ ⟹ False›*) case 2 (*‹normalize_sort cs s1 ⊆ normalize_sort cs s2› ‹¬ normalize_sort (cs::(String.literal × String.literal) set) (s2::String.literal set) ⊆ normalize_sort cs (s1::String.literal set)›*) from this (*‹normalize_sort cs s1 ⊆ normalize_sort cs s2› ‹¬ normalize_sort (cs::(String.literal × String.literal) set) (s2::String.literal set) ⊆ normalize_sort cs (s1::String.literal set)›*) obtain c where c: "c ∈ normalize_sort cs s2" "c ∉ normalize_sort cs s1" (*goal: ‹(⋀c. ⟦c ∈ normalize_sort cs s2; c ∉ normalize_sort cs s1⟧ ⟹ thesis) ⟹ thesis›*) by blast from this (*‹c ∈ normalize_sort cs s2› ‹c ∉ normalize_sort cs s1›*) obtain c' where c': "c' ∈ normalize_sort cs s1" "class_les cs c' c" (*goal: ‹(⋀c'. ⟦c' ∈ normalize_sort cs s1; class_les cs c' c⟧ ⟹ thesis) ⟹ thesis›*) by (smt ‹sort_leq cs s1 s2› ‹sort_leq cs s2 s1› 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)›*) mem_Collect_eq (*‹((?a::?'a) ∈ Collect (?P::?'a ⇒ bool)) = ?P ?a›*) normalize_sort_def (*‹normalize_sort (?sub::(String.literal × String.literal) set) (?S::String.literal set) = {c::String.literal ∈ ?S. ¬ (∃c'::String.literal∈?S. class_les ?sub c' c)}›*) 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₂)›*) 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›*) wf_subclass_loc.class_leq_trans (*‹⟦wf_subclass_loc (?cs::(String.literal × String.literal) set); class_leq ?cs (?x::String.literal) (?y::String.literal); class_leq ?cs ?y (?z::String.literal)⟧ ⟹ class_leq ?cs ?x ?z›*) wf_subclass_loc_axioms (*‹wf_subclass_loc (cs::(String.literal × String.literal) set)›*)) then show "?thesis" (*goal: ‹False›*) proof (cases "c' ∈ normalize_sort cs s2") (*goals: 1. ‹⟦c' ∈ normalize_sort cs s1; class_les cs c' c; c' ∈ normalize_sort cs s2⟧ ⟹ False› 2. ‹⟦c' ∈ normalize_sort cs s1; class_les cs c' c; c' ∉ normalize_sort cs s2⟧ ⟹ False›*) case True (*‹c' ∈ normalize_sort cs s2›*) hence "c ∉ normalize_sort cs s2" using c (*‹c ∈ normalize_sort cs s2› ‹(c::String.literal) ∉ normalize_sort (cs::(String.literal × String.literal) set) (s1::String.literal set)›*) c' (*‹c' ∈ normalize_sort cs s1› ‹class_les cs c' c›*) by (auto simp add: normalize_sort_def (*‹normalize_sort ?sub ?S = {c ∈ ?S. ¬ (∃c'∈?S. class_les ?sub c' c)}›*)) then show "?thesis" (*goal: ‹False›*) using c(1) (*‹c ∈ normalize_sort cs s2›*) by simp next (*goal: ‹⟦(c'::String.literal) ∈ normalize_sort (cs::(String.literal × String.literal) set) (s1::String.literal set); class_les cs c' (c::String.literal); c' ∉ normalize_sort cs (s2::String.literal set)⟧ ⟹ False›*) case False (*‹c' ∉ normalize_sort cs s2›*) from False (*‹c' ∉ normalize_sort cs s2›*) c' (*‹(c'::String.literal) ∈ normalize_sort (cs::(String.literal × String.literal) set) (s1::String.literal set)› ‹class_les cs c' c›*) obtain c'' where c'': "c''∈ normalize_sort cs s2" "class_les cs c'' c'" (*goal: ‹(⋀c''. ⟦c'' ∈ normalize_sort cs s2; class_les cs c'' c'⟧ ⟹ thesis) ⟹ thesis›*) by (smt ‹sort_leq cs s1 s2› ‹sort_leq cs s2 s1› class_les_def (*‹class_les ?sub ?c1.0 ?c2.0 = (class_leq ?sub ?c1.0 ?c2.0 ∧ ¬ class_leq ?sub ?c2.0 ?c1.0)›*) mem_Collect_eq (*‹(?a ∈ Collect ?P) = ?P ?a›*) normalize_sort_def (*‹normalize_sort ?sub ?S = {c ∈ ?S. ¬ (∃c'∈?S. class_les ?sub c' c)}›*) sort_leq_def (*‹sort_leq ?sub ?s1.0 ?s2.0 = (∀c₂∈?s2.0. ∃c₁∈?s1.0. class_leq ?sub c₁ c₂)›*) wf_subclass_loc.class_leq_antisym (*‹⟦wf_subclass_loc ?cs; class_leq ?cs ?c1.0 ?c2.0; class_leq ?cs ?c2.0 ?c1.0⟧ ⟹ ?c1.0 = ?c2.0›*) wf_subclass_loc.class_leq_trans (*‹⟦wf_subclass_loc ?cs; class_leq ?cs ?x ?y; class_leq ?cs ?y ?z⟧ ⟹ class_leq ?cs ?x ?z›*) wf_subclass_loc_axioms (*‹wf_subclass_loc cs›*)) hence "class_les cs c'' c" using c'(2) (*‹class_les cs c' c›*) class_les_trans (*‹⟦class_les cs ?x ?y; class_les cs ?y ?z⟧ ⟹ class_les cs ?x ?z›*) by blast hence "c ∉ normalize_sort cs s2" using c (*‹c ∈ normalize_sort cs s2› ‹c ∉ normalize_sort cs s1›*) c'' (*‹c'' ∈ normalize_sort cs s2› ‹class_les cs c'' c'›*) by (auto simp add: normalize_sort_def (*‹normalize_sort (?sub::(String.literal × String.literal) set) (?S::String.literal set) = {c::String.literal ∈ ?S. ¬ (∃c'::String.literal∈?S. class_les ?sub c' c)}›*)) then show "?thesis" (*goal: ‹False›*) using c(1) (*‹c ∈ normalize_sort cs s2›*) by simp qed qed qed corollary sort_eqv_iff_normalize_sort_eq: assumes "finite s1" "finite s2" assumes "sort_ex cs s1" "sort_ex cs s2" shows "sort_eqv cs s1 s2 ⟷ normalize_sort cs s1 = normalize_sort cs s2" using assms (*‹finite s1› ‹finite (s2::String.literal set)› ‹sort_ex cs s1› ‹sort_ex cs s2›*) normalize_sort_eq_imp_sort_eqv (*‹⟦sort_ex cs ?s1.0; sort_ex cs ?s2.0; finite ?s1.0; finite ?s2.0; normalize_sort cs ?s1.0 = normalize_sort cs ?s2.0⟧ ⟹ sort_eqv cs ?s1.0 ?s2.0›*) sort_eqv_imp_normalize_sort_eq (*‹⟦sort_ex cs ?s1.0; sort_ex cs ?s2.0; sort_eqv cs ?s1.0 ?s2.0⟧ ⟹ normalize_sort cs ?s1.0 = normalize_sort cs ?s2.0›*) by blast end lemma tcsigs_sorts_defined: "wf_osig oss ⟹ (∀ars ∈ ran (tcsigs oss) . ∀ss ∈ ran ars . ∀s ∈ set ss. sort_ex (subclass oss) s)" apply (cases oss) (*goal: ‹wf_osig oss ⟹ ∀ars∈ran (tcsigs oss). ∀ss∈ran ars. ∀s∈set ss. sort_ex (subclass oss) s›*) by (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)›*) all_normalized_and_ex_tcsigs_def (*‹all_normalized_and_ex_tcsigs (?sub::(String.literal × String.literal) set) (?tcs::?'a::type ⇒ (?'b::type ⇒ String.literal set list option) option) ≡ ∀ars::?'b::type ⇒ String.literal set list option∈ran ?tcs. ∀ss::String.literal set list∈ran ars. ∀s::String.literal set∈set ss. wf_sort ?sub s›*)) lemma osig_subclass_loc: "wf_osig oss ⟹ wf_subclass_loc (subclass oss)" using wf_subclass_loc.intro (*‹wf_subclass ?cs ⟹ wf_subclass_loc ?cs›*) apply (cases oss) (*goal: ‹wf_osig oss ⟹ wf_subclass_loc (subclass oss)›*) by simp lemma wf_osig_imp_wf_subclass_loc: "wf_osig oss ⟹ wf_subclass_loc (subclass oss)" apply (cases oss) (*goal: ‹wf_osig oss ⟹ wf_subclass_loc (subclass oss)›*) by (simp add: wf_subclass_loc_def (*‹wf_subclass_loc (?cs::(String.literal × String.literal) set) ≡ wf_subclass ?cs›*)) lemma has_sort_Tv_imp_sort_leq: "has_sort oss (Tv idn S) S' ⟹ sort_leq (subclass oss) S S'" by (auto simp add: 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)))›*)) end
{ "path": "afp-2025-02-12/thys/Metalogic_ProofChecker/Sorts.thy", "repo": "afp-2025-02-12", "sha": "ff9cf32010ff6bf6ce3e3fa9cb505f232c4e3f1ea2eab6facd5882c85e0debf8" }
theory Grounded_First_Order_Superposition imports First_Order_Superposition Ground_Superposition_Completeness begin context ground_superposition_calculus begin abbreviation eq_resolution_inferences where "eq_resolution_inferences ≡ {Infer [P] C | P C. ground_eq_resolution P C}" abbreviation eq_factoring_inferences where "eq_factoring_inferences ≡ {Infer [P] C | P C. ground_eq_factoring P C}" abbreviation superposition_inferences where "superposition_inferences ≡ {Infer [P2, P1] C | P1 P2 C. ground_superposition P2 P1 C}" end locale grounded_first_order_superposition_calculus = first_order_superposition_calculus select _ _ typeof_fun + grounded_first_order_select select for select :: "('f, 'v :: infinite) select" and typeof_fun :: "('f, 'ty) fun_types" begin sublocale ground: ground_superposition_calculus where less_trm = "(≺⇩t⇩G)" and select = select⇩G apply unfold_locales (*goal: ‹ground_superposition_calculus (≺⇩t⇩G) select⇩G›*) by (rule ground_critical_pair_theorem (*‹WCR (rewrite_inside_gctxt ?R) = (ground_critical_pairs ?R ⊆ (rewrite_inside_gctxt ?R)⇧↓)›*)) definition is_inference_grounding where "is_inference_grounding ι ι⇩G γ ρ₁ ρ₂ ≡ (case ι of Infer [(premise, 𝒱')] (conclusion, 𝒱) ⇒ term_subst.is_ground_subst γ ∧ ι⇩G = Infer [clause.to_ground (premise ⋅ γ)] (clause.to_ground (conclusion ⋅ γ)) ∧ welltyped⇩c typeof_fun 𝒱 premise ∧ welltyped⇩σ_on (clause.vars conclusion) typeof_fun 𝒱 γ ∧ welltyped⇩c typeof_fun 𝒱 conclusion ∧ 𝒱 = 𝒱' ∧ all_types 𝒱 | Infer [(premise₂, 𝒱₂), (premise₁, 𝒱₁)] (conclusion, 𝒱₃) ⇒ term_subst.is_renaming ρ₁ ∧ term_subst.is_renaming ρ₂ ∧ clause.vars (premise₁ ⋅ ρ₁) ∩ clause.vars (premise₂ ⋅ ρ₂) = {} ∧ term_subst.is_ground_subst γ ∧ ι⇩G = Infer [clause.to_ground (premise₂ ⋅ ρ₂ ⋅ γ), clause.to_ground (premise₁ ⋅ ρ₁ ⋅ γ)] (clause.to_ground (conclusion ⋅ γ)) ∧ welltyped⇩c typeof_fun 𝒱₁ premise₁ ∧ welltyped⇩c typeof_fun 𝒱₂ premise₂ ∧ welltyped⇩σ_on (clause.vars conclusion) typeof_fun 𝒱₃ γ ∧ welltyped⇩c typeof_fun 𝒱₃ conclusion ∧ all_types 𝒱₁ ∧ all_types 𝒱₂ ∧ all_types 𝒱₃ | _ ⇒ False ) ∧ ι⇩G ∈ ground.G_Inf" definition inference_groundings where "inference_groundings ι = { ι⇩G | ι⇩G γ ρ₁ ρ₂. is_inference_grounding ι ι⇩G γ ρ₁ ρ₂ }" lemma is_inference_grounding_inference_groundings: "is_inference_grounding ι ι⇩G γ ρ₁ ρ₂ ⟹ ι⇩G ∈ inference_groundings ι" unfolding inference_groundings_def (*goal: ‹is_inference_grounding (ι::(('f, 'a) Term.term uprod literal multiset × ('a ⇒ 'ty)) inference) (ι⇩G::'f gterm uprod literal multiset inference) (γ::'a ⇒ ('f, 'a) Term.term) (ρ₁::'a ⇒ ('f, 'a) Term.term) (ρ₂::'a ⇒ ('f, 'a) Term.term) ⟹ ι⇩G ∈ {uu_::'f gterm uprod literal multiset inference. ∃(ι⇩G::'f gterm uprod literal multiset inference) (γ::'a ⇒ ('f, 'a) Term.term) (ρ₁::'a ⇒ ('f, 'a) Term.term) ρ₂::'a ⇒ ('f, 'a) Term.term. uu_ = ι⇩G ∧ is_inference_grounding ι ι⇩G γ ρ₁ ρ₂}›*) by blast lemma inference⇩G_concl_in_clause_grounding: assumes "ι⇩G ∈ inference_groundings ι" shows "concl_of ι⇩G ∈ clause_groundings typeof_fun (concl_of ι)" proof (-) (*goal: ‹concl_of ι⇩G ∈ clause_groundings typeof_fun (concl_of ι)›*) obtain premises⇩G and conlcusion⇩G where "ι⇩G": "ι⇩G = Infer premises⇩G conlcusion⇩G" (*goal: ‹(⋀(premises⇩G::'f::type gterm uprod literal multiset list) conlcusion⇩G::'f::type gterm uprod literal multiset. (ι⇩G::'f::type gterm uprod literal multiset inference) = Infer premises⇩G conlcusion⇩G ⟹ thesis::bool) ⟹ thesis›*) using Calculus.inference.exhaust (*‹(⋀(x1::?'f list) x2::?'f. (?y::?'f inference) = Infer x1 x2 ⟹ ?P::bool) ⟹ ?P›*) by blast obtain premises and conclusion and 𝒱 where "ι": "ι = Infer premises (conclusion, 𝒱)" (*goal: ‹(⋀(premises::(('f, 'a) Term.term uprod literal multiset × ('a ⇒ 'ty)) list) (conclusion::('f, 'a) Term.term uprod literal multiset) 𝒱::'a ⇒ 'ty. (ι::(('f, 'a) Term.term uprod literal multiset × ('a ⇒ 'ty)) inference) = Infer premises (conclusion, 𝒱) ⟹ thesis::bool) ⟹ thesis›*) using Calculus.inference.exhaust (*‹(⋀x1 x2. ?y = Infer x1 x2 ⟹ ?P) ⟹ ?P›*) by (metis prod.collapse (*‹(fst ?prod, snd ?prod) = ?prod›*)) obtain γ where "clause.is_ground (conclusion ⋅ γ)" "conlcusion⇩G = clause.to_ground (conclusion ⋅ γ)" "welltyped⇩c typeof_fun 𝒱 conclusion ∧ welltyped⇩σ_on (clause.vars conclusion) typeof_fun 𝒱 γ ∧ term_subst.is_ground_subst γ ∧ all_types 𝒱" (*goal: ‹(⋀γ. ⟦clause.vars (conclusion ⋅ γ) = {}; conlcusion⇩G = clause.to_ground (conclusion ⋅ γ); First_Order_Type_System.welltyped⇩c typeof_fun 𝒱 conclusion ∧ welltyped⇩σ_on (clause.vars conclusion) typeof_fun 𝒱 γ ∧ term_subst.is_ground_subst γ ∧ all_types 𝒱⟧ ⟹ thesis) ⟹ thesis›*) proof (-) (*goal: ‹(⋀γ. ⟦clause.vars (conclusion ⋅ γ) = {}; conlcusion⇩G = clause.to_ground (conclusion ⋅ γ); First_Order_Type_System.welltyped⇩c typeof_fun 𝒱 conclusion ∧ welltyped⇩σ_on (clause.vars conclusion) typeof_fun 𝒱 γ ∧ term_subst.is_ground_subst γ ∧ all_types 𝒱⟧ ⟹ thesis) ⟹ thesis›*) have "⋀γ ρ₁ ρ₂. ⟦⋀γ. ⟦clause.vars (conclusion ⋅ γ) = {}; conlcusion⇩G = clause.to_ground (conclusion ⋅ γ); First_Order_Type_System.welltyped⇩c typeof_fun 𝒱 conclusion ∧ welltyped⇩σ_on (clause.vars conclusion) typeof_fun 𝒱 γ ∧ term_subst.is_ground_subst γ ∧ all_types 𝒱⟧ ⟹ thesis; Infer premises⇩G conlcusion⇩G ∈ ground.G_Inf; case premises of [] ⇒ False | [(premise, 𝒱')] ⇒ term_subst.is_ground_subst γ ∧ Infer premises⇩G conlcusion⇩G = Infer [clause.to_ground (premise ⋅ γ)] (clause.to_ground (conclusion ⋅ γ)) ∧ First_Order_Type_System.welltyped⇩c typeof_fun 𝒱 premise ∧ welltyped⇩σ_on (clause.vars conclusion) typeof_fun 𝒱 γ ∧ First_Order_Type_System.welltyped⇩c typeof_fun 𝒱 conclusion ∧ 𝒱 = 𝒱' ∧ all_types 𝒱 | [(premise, 𝒱'), (premise₁, 𝒱₁)] ⇒ clause.is_renaming ρ₁ ∧ clause.is_renaming ρ₂ ∧ clause.vars (premise₁ ⋅ ρ₁) ∩ clause.vars (premise ⋅ ρ₂) = {} ∧ term_subst.is_ground_subst γ ∧ Infer premises⇩G conlcusion⇩G = Infer [clause.to_ground (premise ⋅ ρ₂ ⋅ γ), clause.to_ground (premise₁ ⋅ ρ₁ ⋅ γ)] (clause.to_ground (conclusion ⋅ γ)) ∧ First_Order_Type_System.welltyped⇩c typeof_fun 𝒱₁ premise₁ ∧ First_Order_Type_System.welltyped⇩c typeof_fun 𝒱' premise ∧ welltyped⇩σ_on (clause.vars conclusion) typeof_fun 𝒱 γ ∧ First_Order_Type_System.welltyped⇩c typeof_fun 𝒱 conclusion ∧ all_types 𝒱₁ ∧ all_types 𝒱' ∧ all_types 𝒱 | (premise, 𝒱') # (premise₁, 𝒱₁) # a # lista ⇒ False⟧ ⟹ thesis" apply (auto simp: clause.is_ground_subst_is_ground (*‹clause.is_ground_subst ?γ ⟹ clause.vars (?t ⋅ ?γ) = {}›*) split: list.splits (*‹?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)))› ‹?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))))›*)) (*goal: ‹⋀γ ρ₁ ρ₂. ⟦⋀γ. ⟦clause.vars (conclusion ⋅ γ) = {}; conlcusion⇩G = clause.to_ground (conclusion ⋅ γ); First_Order_Type_System.welltyped⇩c typeof_fun 𝒱 conclusion ∧ welltyped⇩σ_on (clause.vars conclusion) typeof_fun 𝒱 γ ∧ term_subst.is_ground_subst γ ∧ all_types 𝒱⟧ ⟹ thesis; Infer premises⇩G conlcusion⇩G ∈ ground.G_Inf; case premises of [] ⇒ False | [(premise, 𝒱')] ⇒ term_subst.is_ground_subst γ ∧ Infer premises⇩G conlcusion⇩G = Infer [clause.to_ground (premise ⋅ γ)] (clause.to_ground (conclusion ⋅ γ)) ∧ First_Order_Type_System.welltyped⇩c typeof_fun 𝒱 premise ∧ welltyped⇩σ_on (clause.vars conclusion) typeof_fun 𝒱 γ ∧ First_Order_Type_System.welltyped⇩c typeof_fun 𝒱 conclusion ∧ 𝒱 = 𝒱' ∧ all_types 𝒱 | [(premise, 𝒱'), (premise₁, 𝒱₁)] ⇒ clause.is_renaming ρ₁ ∧ clause.is_renaming ρ₂ ∧ clause.vars (premise₁ ⋅ ρ₁) ∩ clause.vars (premise ⋅ ρ₂) = {} ∧ term_subst.is_ground_subst γ ∧ Infer premises⇩G conlcusion⇩G = Infer [clause.to_ground (premise ⋅ ρ₂ ⋅ γ), clause.to_ground (premise₁ ⋅ ρ₁ ⋅ γ)] (clause.to_ground (conclusion ⋅ γ)) ∧ First_Order_Type_System.welltyped⇩c typeof_fun 𝒱₁ premise₁ ∧ First_Order_Type_System.welltyped⇩c typeof_fun 𝒱' premise ∧ welltyped⇩σ_on (clause.vars conclusion) typeof_fun 𝒱 γ ∧ First_Order_Type_System.welltyped⇩c typeof_fun 𝒱 conclusion ∧ all_types 𝒱₁ ∧ all_types 𝒱' ∧ all_types 𝒱 | (premise, 𝒱') # (premise₁, 𝒱₁) # a # lista ⇒ False⟧ ⟹ thesis›*) by (metis list_4_cases (*‹⟦?xs = [] ⟹ ?P; ⋀x. ?xs = [x] ⟹ ?P; ⋀x y. ?xs = [x, y] ⟹ ?P; ⋀x y z zs. ?xs = x # y # z # zs ⟹ ?P⟧ ⟹ ?P›*) prod.exhaust_sel (*‹(?prod = (fst ?prod, snd ?prod) ⟹ ?P) ⟹ ?P›*)) then show "?thesis" (*goal: ‹thesis›*) using that (*‹⟦clause.vars (conclusion ⋅ ?γ4) = {}; conlcusion⇩G = clause.to_ground (conclusion ⋅ ?γ4); First_Order_Type_System.welltyped⇩c typeof_fun 𝒱 conclusion ∧ welltyped⇩σ_on (clause.vars conclusion) typeof_fun 𝒱 ?γ4 ∧ term_subst.is_ground_subst ?γ4 ∧ all_types 𝒱⟧ ⟹ thesis›*) assms (*‹ι⇩G ∈ inference_groundings ι›*) unfolding inference_groundings_def "ι" "ι⇩G" Calculus.inference.case (*goal: ‹thesis›*) by (auto simp: is_inference_grounding_def (*‹is_inference_grounding ?ι ?ι⇩G ?γ ?ρ₁ ?ρ₂ ≡ (case ?ι of Infer [] f ⇒ False | Infer [(premise, 𝒱')] (conclusion, 𝒱) ⇒ term_subst.is_ground_subst ?γ ∧ ?ι⇩G = Infer [clause.to_ground (premise ⋅ ?γ)] (clause.to_ground (conclusion ⋅ ?γ)) ∧ First_Order_Type_System.welltyped⇩c typeof_fun 𝒱 premise ∧ welltyped⇩σ_on (clause.vars conclusion) typeof_fun 𝒱 ?γ ∧ First_Order_Type_System.welltyped⇩c typeof_fun 𝒱 conclusion ∧ 𝒱 = 𝒱' ∧ all_types 𝒱 | Infer [(premise, 𝒱'), (premise₁, 𝒱₁)] (conclusion, 𝒱₃) ⇒ clause.is_renaming ?ρ₁ ∧ clause.is_renaming ?ρ₂ ∧ clause.vars (premise₁ ⋅ ?ρ₁) ∩ clause.vars (premise ⋅ ?ρ₂) = {} ∧ term_subst.is_ground_subst ?γ ∧ ?ι⇩G = Infer [clause.to_ground (premise ⋅ ?ρ₂ ⋅ ?γ), clause.to_ground (premise₁ ⋅ ?ρ₁ ⋅ ?γ)] (clause.to_ground (conclusion ⋅ ?γ)) ∧ First_Order_Type_System.welltyped⇩c typeof_fun 𝒱₁ premise₁ ∧ First_Order_Type_System.welltyped⇩c typeof_fun 𝒱' premise ∧ welltyped⇩σ_on (clause.vars conclusion) typeof_fun 𝒱₃ ?γ ∧ First_Order_Type_System.welltyped⇩c typeof_fun 𝒱₃ conclusion ∧ all_types 𝒱₁ ∧ all_types 𝒱' ∧ all_types 𝒱₃ | Infer ((premise, 𝒱') # (premise₁, 𝒱₁) # a # lista) f ⇒ False) ∧ ?ι⇩G ∈ ground.G_Inf›*)) qed then show "?thesis" (*goal: ‹concl_of ι⇩G ∈ clause_groundings typeof_fun (concl_of ι)›*) unfolding "ι" "ι⇩G" clause_groundings_def (*goal: ‹concl_of (Infer premises⇩G conlcusion⇩G) ∈ {clause.to_ground (fst (concl_of (Infer premises (conclusion, 𝒱))) ⋅ γ) |γ. term_subst.is_ground_subst γ ∧ First_Order_Type_System.welltyped⇩c typeof_fun (snd (concl_of (Infer premises (conclusion, 𝒱)))) (fst (concl_of (Infer premises (conclusion, 𝒱)))) ∧ welltyped⇩σ_on (clause.vars (fst (concl_of (Infer premises (conclusion, 𝒱))))) typeof_fun (snd (concl_of (Infer premises (conclusion, 𝒱)))) γ ∧ all_types (snd (concl_of (Infer premises (conclusion, 𝒱))))}›*) by auto qed lemma inference⇩G_red_in_clause_grounding_of_concl: assumes "ι⇩G ∈ inference_groundings ι" shows "ι⇩G ∈ ground.Red_I (clause_groundings typeof_fun (concl_of ι))" proof (-) (*goal: ‹ι⇩G ∈ ground.GRed_I (clause_groundings typeof_fun (concl_of ι))›*) from assms (*‹ι⇩G ∈ inference_groundings ι›*) have "ι⇩G ∈ ground.G_Inf" unfolding inference_groundings_def is_inference_grounding_def (*goal: ‹(ι⇩G::'f gterm uprod literal multiset inference) ∈ ground.G_Inf›*) by blast moreover have "concl_of ι⇩G ∈ clause_groundings typeof_fun (concl_of ι)" using assms (*‹ι⇩G ∈ inference_groundings ι›*) "inference⇩G_concl_in_clause_grounding" (*‹?ι⇩G ∈ inference_groundings ?ι ⟹ concl_of ?ι⇩G ∈ clause_groundings typeof_fun (concl_of ?ι)›*) by auto ultimately show "ι⇩G ∈ ground.Red_I (clause_groundings typeof_fun (concl_of ι))" using ground.Red_I_of_Inf_to_N (*‹⟦(?ι::'f::type gterm uprod literal multiset inference) ∈ ground.G_Inf; concl_of ?ι ∈ (?N::'f::type gterm uprod literal multiset set)⟧ ⟹ ?ι ∈ ground.GRed_I ?N›*) by blast qed lemma obtain_welltyped_ground_subst: obtains γ :: "('f, 'v) subst" and ℱ⇩G :: "('f, 'ty) fun_types" where "welltyped⇩σ typeof_fun 𝒱 γ" "term_subst.is_ground_subst γ" proof (-) (*goal: ‹(⋀γ. ⟦welltyped⇩σ typeof_fun 𝒱 γ; term_subst.is_ground_subst γ⟧ ⟹ thesis) ⟹ thesis›*) define γ :: "('f, 'v) subst" where "⋀x. γ x ≡ Fun (SOME f. typeof_fun f = ([], 𝒱 x)) []" moreover have "welltyped⇩σ typeof_fun 𝒱 γ" proof (-) (*goal: ‹welltyped⇩σ typeof_fun 𝒱 γ›*) have "⋀x. First_Order_Type_System.welltyped typeof_fun 𝒱 (Fun (SOME f. typeof_fun f = ([], 𝒱 x)) []) (𝒱 x)" by (meson function_symbols (*‹∃f::'f::type. (typeof_fun::'f::type ⇒ 'ty::type list × 'ty::type) f = ([], ?τ::'ty::type)›*) list_all2_Nil (*‹list_all2 (?P::?'a::type ⇒ ?'b::type ⇒ bool) [] (?ys::?'b::type list) = (?ys = [])›*) someI_ex (*‹∃x::?'a::type. (?P::?'a::type ⇒ bool) x ⟹ ?P (SOME x::?'a::type. ?P x)›*) welltyped.Fun (*‹⟦(?ℱ::?'f::type ⇒ ?'ty::type list × ?'ty::type) (?f::?'f::type) = (?τs::?'ty::type list, ?τ::?'ty::type); list_all2 (First_Order_Type_System.welltyped ?ℱ (?𝒱::?'v::type ⇒ ?'ty::type)) (?ts::(?'f::type, ?'v::type) Term.term list) ?τs⟧ ⟹ First_Order_Type_System.welltyped ?ℱ ?𝒱 (Fun ?f ?ts) ?τ›*)) then show "?thesis" (*goal: ‹welltyped⇩σ typeof_fun 𝒱 γ›*) unfolding "welltyped⇩σ_def" "γ_def" (*goal: ‹∀x. First_Order_Type_System.welltyped typeof_fun 𝒱 (Fun (SOME f. typeof_fun f = ([], 𝒱 x)) []) (𝒱 x)›*) by auto qed moreover have "term_subst.is_ground_subst γ" unfolding term_subst.is_ground_subst_def "γ_def" (*goal: ‹∀x. term.vars (x ⋅t (λx. Fun (SOME f. typeof_fun f = ([], 𝒱 x)) [])) = {}›*) by (smt (verit) Nil_is_map_conv (*‹([] = map (?f::?'b ⇒ ?'a) (?xs::?'b list)) = (?xs = [])›*) equals0D (*‹(?A::?'a set) = {} ⟹ (?a::?'a) ∉ ?A›*) eval_term.simps( (*‹(?I::?'a ⇒ ?'b list ⇒ ?'b)⟦Fun (?f::?'a) (?ss::(?'a, ?'c) Term.term list)⟧(?α::?'c ⇒ ?'b) = ?I ?f (map (λs::(?'a, ?'c) Term.term. ?I⟦s⟧?α) ?ss)›*) 2) is_ground_iff (*‹(term.vars ((?t::(?'b, ?'c) Term.term) ⋅t (?γ::?'c ⇒ (?'b, ?'a) Term.term)) = {}) = (∀x::?'c∈term.vars ?t. term.vars (?γ x) = {})›*) is_ground_trm_iff_ident_forall_subst (*‹(term.vars (?t::(?'b, ?'a) Term.term) = {}) = (∀σ::?'a ⇒ (?'b, ?'a) Term.term. ?t ⋅t σ = ?t)›*)) ultimately show "?thesis" (*goal: ‹thesis›*) using that (*‹⟦welltyped⇩σ typeof_fun 𝒱 ?γ4; term_subst.is_ground_subst ?γ4⟧ ⟹ thesis›*) by blast qed lemma welltyped⇩σ_on_empty: "welltyped⇩σ_on {} ℱ 𝒱 σ" unfolding "welltyped⇩σ_on_def" (*goal: ‹∀x∈{}. First_Order_Type_System.welltyped ℱ 𝒱 (σ x) (𝒱 x)›*) by simp sublocale lifting: tiebreaker_lifting "⊥⇩F" inferences ground.G_Bot ground.G_entails ground.G_Inf ground.GRed_I ground.GRed_F "clause_groundings typeof_fun" "(Some ∘ inference_groundings)" typed_tiebreakers proof (unfold_locales) (*goals: 1. ‹⊥⇩F ≠ {}› 2. ‹⋀B. B ∈ ⊥⇩F ⟹ clause_groundings typeof_fun B ≠ {}› 3. ‹⋀B. B ∈ ⊥⇩F ⟹ clause_groundings typeof_fun B ⊆ ground.G_Bot› 4. ‹⋀C. clause_groundings typeof_fun C ∩ ground.G_Bot ≠ {} ⟶ C ∈ ⊥⇩F› 5. ‹⋀ι. ⟦ι ∈ inferences; (Some ∘ inference_groundings) ι ≠ None⟧ ⟹ the ((Some ∘ inference_groundings) ι) ⊆ ground.GRed_I (clause_groundings typeof_fun (concl_of ι))› 6. ‹⋀g. po_on (typed_tiebreakers g) UNIV› 7. ‹⋀g. Restricted_Predicates.wfp_on (typed_tiebreakers g) UNIV›*) show "⊥⇩F ≠ {}" using all_types'[OF variables] (*‹∃𝒱. all_types 𝒱›*) by blast next (*goals: 1. ‹⋀B. B ∈ ⊥⇩F ⟹ clause_groundings typeof_fun B ≠ {}› 2. ‹⋀B. B ∈ ⊥⇩F ⟹ clause_groundings typeof_fun B ⊆ ground.G_Bot› 3. ‹⋀C. clause_groundings typeof_fun C ∩ ground.G_Bot ≠ {} ⟶ C ∈ ⊥⇩F› 4. ‹⋀ι. ⟦ι ∈ inferences; (Some ∘ inference_groundings) ι ≠ None⟧ ⟹ the ((Some ∘ inference_groundings) ι) ⊆ ground.GRed_I (clause_groundings typeof_fun (concl_of ι))› 5. ‹⋀g. po_on (typed_tiebreakers g) UNIV› 6. ‹⋀g. Restricted_Predicates.wfp_on (typed_tiebreakers g) UNIV›*) fix bottom assume "bottom ∈ ⊥⇩F" (*‹(bottom::('f, 'v) Term.term uprod literal multiset × ('v ⇒ 'ty)) ∈ ⊥⇩F›*) then show "clause_groundings typeof_fun bottom ≠ {}" unfolding clause_groundings_def (*goal: ‹{clause.to_ground (fst (bottom::('f, 'v) Term.term uprod literal multiset × ('v ⇒ 'ty)) ⋅ γ) |γ::'v ⇒ ('f, 'v) Term.term. term_subst.is_ground_subst γ ∧ First_Order_Type_System.welltyped⇩c (typeof_fun::'f ⇒ 'ty list × 'ty) (snd bottom) (fst bottom) ∧ welltyped⇩σ_on (clause.vars (fst bottom)) typeof_fun (snd bottom) γ ∧ all_types (snd bottom)} ≠ {}›*) using "welltyped⇩σ_Var" (*‹welltyped⇩σ ?ℱ ?𝒱 Var›*) proof (-) (*goal: ‹⟦bottom ∈ ⊥⇩F; ⋀ℱ 𝒱. welltyped⇩σ ℱ 𝒱 Var⟧ ⟹ {clause.to_ground (fst bottom ⋅ γ) |γ. term_subst.is_ground_subst γ ∧ First_Order_Type_System.welltyped⇩c typeof_fun (snd bottom) (fst bottom) ∧ welltyped⇩σ_on (clause.vars (fst bottom)) typeof_fun (snd bottom) γ ∧ all_types (snd bottom)} ≠ {}›*) have "∃f. welltyped⇩σ_on (clause.vars {#}) typeof_fun (snd bottom) f ∧ First_Order_Type_System.welltyped⇩c typeof_fun (snd bottom) {#} ∧ term_subst.is_ground_subst f" by (metis First_Order_Type_System.welltyped⇩c_def (*‹First_Order_Type_System.welltyped⇩c (?ℱ::?'a ⇒ ?'b list × ?'b) (?𝒱::?'c ⇒ ?'b) (?C::(?'a, ?'c) Term.term uprod literal multiset) = (∀L::(?'a, ?'c) Term.term uprod literal∈#?C. First_Order_Type_System.welltyped⇩l ?ℱ ?𝒱 L)›*) empty_clause_is_ground (*‹clause.vars {#} = {}›*) ex_in_conv (*‹(∃x::?'a. x ∈ (?A::?'a set)) = (?A ≠ {})›*) set_mset_eq_empty_iff (*‹(set_mset (?M::?'a multiset) = {}) = (?M = {#})›*) term.obtain_ground_subst (*‹(⋀γ::?'v ⇒ (?'f, ?'v) Term.term. term_subst.is_ground_subst γ ⟹ ?thesis::bool) ⟹ ?thesis›*) welltyped⇩σ_on_empty (*‹welltyped⇩σ_on {} (?ℱ::?'b ⇒ ?'c list × ?'c) (?𝒱::?'a ⇒ ?'c) (?σ::?'a ⇒ (?'b, ?'a) Term.term)›*)) then show "{clause.to_ground (fst bottom ⋅ f) |f. term_subst.is_ground_subst f ∧ First_Order_Type_System.welltyped⇩c typeof_fun (snd bottom) (fst bottom) ∧ welltyped⇩σ_on (clause.vars (fst bottom)) typeof_fun (snd bottom) f ∧ all_types (snd bottom)} ≠ {}" using ‹bottom ∈ ⊥⇩F› (*‹(bottom::('f, 'v) Term.term uprod literal multiset × ('v ⇒ 'ty)) ∈ ⊥⇩F›*) by force qed next (*goals: 1. ‹⋀B. B ∈ ⊥⇩F ⟹ clause_groundings typeof_fun B ⊆ ground.G_Bot› 2. ‹⋀C. clause_groundings typeof_fun C ∩ ground.G_Bot ≠ {} ⟶ C ∈ ⊥⇩F› 3. ‹⋀ι. ⟦ι ∈ inferences; (Some ∘ inference_groundings) ι ≠ None⟧ ⟹ the ((Some ∘ inference_groundings) ι) ⊆ ground.GRed_I (clause_groundings typeof_fun (concl_of ι))› 4. ‹⋀g. po_on (typed_tiebreakers g) UNIV› 5. ‹⋀g. Restricted_Predicates.wfp_on (typed_tiebreakers g) UNIV›*) fix bottom assume "bottom ∈ ⊥⇩F" (*‹(bottom::('f, 'v) Term.term uprod literal multiset × ('v ⇒ 'ty)) ∈ ⊥⇩F›*) then show "clause_groundings typeof_fun bottom ⊆ ground.G_Bot" unfolding clause_groundings_def (*goal: ‹{clause.to_ground (fst bottom ⋅ γ) |γ. term_subst.is_ground_subst γ ∧ First_Order_Type_System.welltyped⇩c typeof_fun (snd bottom) (fst bottom) ∧ welltyped⇩σ_on (clause.vars (fst bottom)) typeof_fun (snd bottom) γ ∧ all_types (snd bottom)} ⊆ ground.G_Bot›*) by clause_auto next (*goals: 1. ‹⋀C. clause_groundings typeof_fun C ∩ ground.G_Bot ≠ {} ⟶ C ∈ ⊥⇩F› 2. ‹⋀ι. ⟦ι ∈ inferences; (Some ∘ inference_groundings) ι ≠ None⟧ ⟹ the ((Some ∘ inference_groundings) ι) ⊆ ground.GRed_I (clause_groundings typeof_fun (concl_of ι))› 3. ‹⋀g. po_on (typed_tiebreakers g) UNIV› 4. ‹⋀g. Restricted_Predicates.wfp_on (typed_tiebreakers g) UNIV›*) fix clause show "clause_groundings typeof_fun clause ∩ ground.G_Bot ≠ {} ⟶ clause ∈ ⊥⇩F" unfolding clause_groundings_def clause.to_ground_def clause.subst_def (*goal: ‹{image_mset literal.to_ground {#c ⋅l γ. c ∈# fst clause#} |γ. term_subst.is_ground_subst γ ∧ First_Order_Type_System.welltyped⇩c typeof_fun (snd clause) (fst clause) ∧ welltyped⇩σ_on (clause.vars (fst clause)) typeof_fun (snd clause) γ ∧ all_types (snd clause)} ∩ ground.G_Bot ≠ {} ⟶ clause ∈ ⊥⇩F›*) by (smt (verit) disjoint_insert( (*‹(?B ∩ insert ?a ?A = {}) = (?a ∉ ?B ∧ ?B ∩ ?A = {})›*) 1) image_mset_is_empty_iff (*‹(image_mset ?f ?M = {#}) = (?M = {#})›*) inf_bot_right (*‹?x ⊓ ⊥ = ⊥›*) mem_Collect_eq (*‹(?a ∈ Collect ?P) = ?P ?a›*) prod.exhaust_sel (*‹(?prod = (fst ?prod, snd ?prod) ⟹ ?P) ⟹ ?P›*)) next (*goals: 1. ‹⋀ι. ⟦ι ∈ inferences; (Some ∘ inference_groundings) ι ≠ None⟧ ⟹ the ((Some ∘ inference_groundings) ι) ⊆ ground.GRed_I (clause_groundings typeof_fun (concl_of ι))› 2. ‹⋀g. po_on (typed_tiebreakers g) UNIV› 3. ‹⋀g. Restricted_Predicates.wfp_on (typed_tiebreakers g) UNIV›*) fix ι :: "('f, 'v, 'ty) typed_clause inference" show "the ((Some ∘ inference_groundings) ι) ⊆ ground.GRed_I (clause_groundings typeof_fun (concl_of ι))" using "inference⇩G_red_in_clause_grounding_of_concl" (*‹?ι⇩G ∈ inference_groundings ?ι ⟹ ?ι⇩G ∈ ground.GRed_I (clause_groundings typeof_fun (concl_of ?ι))›*) by auto next (*goals: 1. ‹⋀g. po_on (typed_tiebreakers g) UNIV› 2. ‹⋀g. Restricted_Predicates.wfp_on (typed_tiebreakers g) UNIV›*) show "⋀clause⇩G. po_on (typed_tiebreakers clause⇩G) UNIV" unfolding po_on_def (*goal: ‹⋀clause⇩G. irreflp (typed_tiebreakers clause⇩G) ∧ transp (typed_tiebreakers clause⇩G)›*) using wellfounded_typed_tiebreakers (*‹wfp (typed_tiebreakers ?clause⇩G) ∧ transp (typed_tiebreakers ?clause⇩G) ∧ asymp (typed_tiebreakers ?clause⇩G)›*) by simp next (*goal: ‹⋀g::'f gterm uprod literal multiset. Restricted_Predicates.wfp_on (typed_tiebreakers g) UNIV›*) show "⋀clause⇩G. Restricted_Predicates.wfp_on (typed_tiebreakers clause⇩G) UNIV" using wellfounded_typed_tiebreakers (*‹wfp (typed_tiebreakers ?clause⇩G) ∧ transp (typed_tiebreakers ?clause⇩G) ∧ asymp (typed_tiebreakers ?clause⇩G)›*) by simp qed end sublocale first_order_superposition_calculus ⊆ lifting_intersection inferences "{{#}}" select⇩G⇩s "ground_superposition_calculus.G_Inf (≺⇩t⇩G)" "λ_. ground_superposition_calculus.G_entails" "ground_superposition_calculus.GRed_I (≺⇩t⇩G)" "λ_. ground_superposition_calculus.GRed_F(≺⇩t⇩G)" "⊥⇩F" "λ_. clause_groundings typeof_fun" "λselect⇩G. Some ∘ (grounded_first_order_superposition_calculus.inference_groundings (≺⇩t) select⇩G typeof_fun)" typed_tiebreakers proof (unfold_locales; (intro ballI (*‹(⋀x. x ∈ ?A ⟹ ?P x) ⟹ ∀x∈?A. ?P x›*))?) (*goals: 1. ‹select⇩G⇩s ≠ {}› 2. ‹⋀q. q ∈ select⇩G⇩s ⟹ consequence_relation {{#}} ground_superposition_calculus.G_entails› 3. ‹⋀q. q ∈ select⇩G⇩s ⟹ tiebreaker_lifting ⊥⇩F inferences {{#}} ground_superposition_calculus.G_entails (ground_superposition_calculus.G_Inf (≺⇩t⇩G) q) (ground_superposition_calculus.GRed_I (≺⇩t⇩G) q) (ground_superposition_calculus.GRed_F (≺⇩t⇩G)) (clause_groundings typeof_fun) (Some ∘ grounded_first_order_superposition_calculus.inference_groundings (≺⇩t) q typeof_fun) typed_tiebreakers›*) show "select⇩G⇩s ≠ {}" using "select⇩G_simple" (*‹is_grounding select⇩G_simple›*) unfolding "select⇩G⇩s_def" (*goal: ‹Collect is_grounding ≠ {}›*) by blast next (*goals: 1. ‹⋀q. q ∈ select⇩G⇩s ⟹ consequence_relation {{#}} ground_superposition_calculus.G_entails› 2. ‹⋀q. q ∈ select⇩G⇩s ⟹ tiebreaker_lifting ⊥⇩F inferences {{#}} ground_superposition_calculus.G_entails (ground_superposition_calculus.G_Inf (≺⇩t⇩G) q) (ground_superposition_calculus.GRed_I (≺⇩t⇩G) q) (ground_superposition_calculus.GRed_F (≺⇩t⇩G)) (clause_groundings typeof_fun) (Some ∘ grounded_first_order_superposition_calculus.inference_groundings (≺⇩t) q typeof_fun) typed_tiebreakers›*) fix select⇩G assume "select⇩G ∈ select⇩G⇩s" (*‹(select⇩G::'f gterm uprod literal multiset ⇒ 'f gterm uprod literal multiset) ∈ select⇩G⇩s›*) then interpret grounded_first_order_superposition_calculus where select⇩G = "select⇩G" apply unfold_locales (*goal: ‹grounded_first_order_superposition_calculus (≺⇩t) tiebreakers select⇩G select typeof_fun›*) by (simp add: select⇩G⇩s_def (*‹select⇩G⇩s = Collect is_grounding›*)) show "consequence_relation ground.G_Bot ground.G_entails" using ground.consequence_relation_axioms (*‹consequence_relation ground.G_Bot ground.G_entails›*) . next (*goal: ‹⋀q. q ∈ select⇩G⇩s ⟹ tiebreaker_lifting ⊥⇩F inferences {{#}} ground_superposition_calculus.G_entails (ground_superposition_calculus.G_Inf (≺⇩t⇩G) q) (ground_superposition_calculus.GRed_I (≺⇩t⇩G) q) (ground_superposition_calculus.GRed_F (≺⇩t⇩G)) (clause_groundings typeof_fun) (Some ∘ grounded_first_order_superposition_calculus.inference_groundings (≺⇩t) q typeof_fun) typed_tiebreakers›*) fix select⇩G assume "select⇩G ∈ select⇩G⇩s" (*‹(select⇩G::'f gterm uprod literal multiset ⇒ 'f gterm uprod literal multiset) ∈ select⇩G⇩s›*) then interpret grounded_first_order_superposition_calculus where select⇩G = "select⇩G" apply unfold_locales (*goal: ‹grounded_first_order_superposition_calculus (≺⇩t) (tiebreakers::'f gterm uprod literal multiset ⇒ ('f, 'v) Term.term uprod literal multiset ⇒ ('f, 'v) Term.term uprod literal multiset ⇒ bool) (select⇩G::'f gterm uprod literal multiset ⇒ 'f gterm uprod literal multiset) (select::('f, 'v) Term.term uprod literal multiset ⇒ ('f, 'v) Term.term uprod literal multiset) (typeof_fun::'f ⇒ 'ty list × 'ty)›*) by (simp add: select⇩G⇩s_def (*‹select⇩G⇩s = Collect is_grounding›*)) show "tiebreaker_lifting ⊥⇩F inferences ground.G_Bot ground.G_entails ground.G_Inf ground.GRed_I ground.GRed_F (clause_groundings typeof_fun) (Some ∘ inference_groundings) typed_tiebreakers" by unfold_locales qed end
{ "path": "afp-2025-02-12/thys/Superposition_Calculus/Grounded_First_Order_Superposition.thy", "repo": "afp-2025-02-12", "sha": "c2422bc0a25449eecddd140b38799f7c85ec503b8f6d92b0ff3e30a4a2d7bd9e" }
(* Title: 2-Catoids Author: Georg Struth Maintainer: Georg Struth <g.struth at sheffield.ac.uk> *) section ‹2-Catoids› theory Two_Catoid imports Catoids.Catoid begin text‹We define 2-catoids and in particular (strict) 2-categories as local functional 2-catoids. With Isabelle we first need to make two copies of catoids for the 0-structure and 1-structure.› subsection ‹0-Structures and 1-structures.› class multimagma0 = fixes mcomp0 :: "'a ⇒ 'a ⇒ 'a set" (infixl "⊙₀" 70) begin sublocale mm0: multimagma mcomp0. abbreviation "Δ₀ ≡ mm0.Δ" abbreviation conv0 :: "'a set ⇒ 'a set ⇒ 'a set" (infixl "*₀" 70) where "X *₀ Y ≡ mm0.conv X Y" lemma "X *₀ Y = (⋃x ∈ X. ⋃y ∈ Y. x ⊙₀ y)" by (simp add: mm0.conv_def (*‹?X *₀ ?Y = (⋃x∈?X. ⋃ ((⊙₀) x ` ?Y))›*)) end class multimagma1 = fixes mcomp1 :: "'a ⇒ 'a ⇒ 'a set" (infixl "⊙₁" 70) begin sublocale mm1: multimagma mcomp1. abbreviation "Δ₁ ≡ mm1.Δ" abbreviation conv1 :: "'a set ⇒ 'a set ⇒ 'a set" (infixl "*₁" 70) where "X *₁ Y ≡ mm1.conv X Y" end class multisemigroup0 = multimagma0 + assumes assoc: "(⋃v ∈ y ⊙₀ z. x ⊙₀ v) = (⋃v ∈ x ⊙₀ y. v ⊙₀ z)" sublocale multisemigroup0 ⊆ msg0: multisemigroup mcomp0 apply unfold_locales (*goal: ‹class.multisemigroup (⊙₀)›*) by (simp add: local.assoc (*‹⋃ ((⊙₀) ?x ` (?y ⊙₀ ?z)) = (⋃v∈?x ⊙₀ ?y. v ⊙₀ ?z)›*)) class multisemigroup1 = multimagma1 + assumes assoc: "(⋃v ∈ y ⊙₁ z. x ⊙₁ v) = (⋃v ∈ x ⊙₁ y. v ⊙₁ z)" sublocale multisemigroup1 ⊆ msg1: multisemigroup mcomp1 apply unfold_locales (*goal: ‹class.multisemigroup (⊙₁)›*) by (simp add: local.assoc (*‹⋃ ((⊙₁) (?x::'a::type) ` ((?y::'a::type) ⊙₁ (?z::'a::type))) = (⋃v::'a::type∈?x ⊙₁ ?y. v ⊙₁ ?z)›*)) class st_multimagma0 = multimagma0 + fixes σ₀ :: "'a ⇒ 'a" and τ₀ :: "'a ⇒ 'a" assumes Dst0: "x ⊙₀ y ≠ {} ⟹ τ₀ x = σ₀ y" and src0_absorb [simp]: "σ₀ x ⊙₀ x = {x}" and tgt0_absorb [simp]: "x ⊙₀ τ₀ x = {x}" begin sublocale stmm0: st_multimagma mcomp0 σ₀ τ₀ apply unfold_locales (*goals: 1. ‹⋀x y. Δ₀ x y ⟹ τ₀ x = σ₀ y› 2. ‹⋀x. σ₀ x ⊙₀ x = {x}› 3. ‹⋀x. x ⊙₀ τ₀ x = {x}› discuss goal 1*) apply (simp add: local.Dst0 (*‹Δ₀ ?x ?y ⟹ τ₀ ?x = σ₀ ?y›*)) (*discuss goal 2*) apply (simp add: local.Dst0 (*‹Δ₀ ?x ?y ⟹ τ₀ ?x = σ₀ ?y›*)) (*discuss goal 3*) apply (simp add: local.Dst0 (*‹Δ₀ ?x ?y ⟹ τ₀ ?x = σ₀ ?y›*)) (*proven 3 subgoals*) . abbreviation "s0fix ≡ stmm0.sfix" abbreviation "t0fix ≡ stmm0.tfix" abbreviation "Src₀ ≡ stmm0.Src" abbreviation "Tgt₀ ≡ stmm0.Tgt" end class st_multimagma1 = multimagma1 + fixes σ₁ :: "'a ⇒ 'a" and τ₁ :: "'a ⇒ 'a" assumes Dst1: "x ⊙₁ y ≠ {} ⟹ τ₁ x = σ₁ y" and src1_absorb [simp]: "σ₁ x ⊙₁ x = {x}" and tgt1_absorb [simp]: "x ⊙₁ τ₁ x = {x}" begin sublocale stmm1: st_multimagma mcomp1 σ₁ τ₁ apply unfold_locales (*goals: 1. ‹⋀x y. Δ₁ x y ⟹ τ₁ x = σ₁ y› 2. ‹⋀x. σ₁ x ⊙₁ x = {x}› 3. ‹⋀x. x ⊙₁ τ₁ x = {x}› discuss goal 1*) apply (simp add: local.Dst1 (*‹Δ₁ (?x::'a) (?y::'a) ⟹ τ₁ ?x = σ₁ ?y›*)) (*discuss goal 2*) apply (simp add: local.Dst1 (*‹Δ₁ ?x ?y ⟹ τ₁ ?x = σ₁ ?y›*)) (*discuss goal 3*) apply (simp add: local.Dst1 (*‹Δ₁ ?x ?y ⟹ τ₁ ?x = σ₁ ?y›*)) (*proven 3 subgoals*) . abbreviation "s1fix ≡ stmm1.sfix" abbreviation "t1fix ≡ stmm1.tfix" abbreviation "Src₁ ≡ stmm1.Src" abbreviation "Tgt₁ ≡ stmm1.Tgt" end class catoid0 = st_multimagma0 + multisemigroup0 sublocale catoid0 ⊆ stmsg0: catoid mcomp0 σ₀ τ₀by standard class catoid1 = st_multimagma1 + multisemigroup1 sublocale catoid1 ⊆ stmsg1: catoid mcomp1 σ₁ τ₁by standard class local_catoid0 = catoid0 + assumes src0_local: "Src₀ (x ⊙₀ σ₀ y) ⊆ Src₀ (x ⊙₀ y)" and tgt0_local: "Tgt₀ (τ₀ x ⊙₀ y) ⊆ Tgt₀ (x ⊙₀ y)" class local_catoid1 = catoid1 + assumes l1_local: "Src₁ (x ⊙₁ σ₁ y) ⊆ Src₁ (x ⊙₁ y)" and r1_local: "Tgt₁ (τ₁ x ⊙₁ y) ⊆ Tgt₁ (x ⊙₁ y)" sublocale local_catoid0 ⊆ ssmsg0: local_catoid mcomp0 σ₀ τ₀ apply unfold_locales (*goal: ‹class.local_catoid (⊙₀) σ₀ τ₀›*) using local.src0_local (*‹Src₀ (?x ⊙₀ σ₀ ?y) ⊆ Src₀ (?x ⊙₀ ?y)›*) local.tgt0_local (*‹Tgt₀ (τ₀ ?x ⊙₀ ?y) ⊆ Tgt₀ (?x ⊙₀ ?y)›*) apply - (*goals: 1. ‹⋀x y. ⟦⋀x y. Src₀ (x ⊙₀ σ₀ y) ⊆ Src₀ (x ⊙₀ y); ⋀x y. Tgt₀ (τ₀ x ⊙₀ y) ⊆ Tgt₀ (x ⊙₀ y)⟧ ⟹ Src₀ (x ⊙₀ σ₀ y) ⊆ Src₀ (x ⊙₀ y)› 2. ‹⋀x y. ⟦⋀x y. Src₀ (x ⊙₀ σ₀ y) ⊆ Src₀ (x ⊙₀ y); ⋀x y. Tgt₀ (τ₀ x ⊙₀ y) ⊆ Tgt₀ (x ⊙₀ y)⟧ ⟹ Tgt₀ (τ₀ x ⊙₀ y) ⊆ Tgt₀ (x ⊙₀ y)› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . sublocale local_catoid1 ⊆ stmsg1: local_catoid mcomp1 σ₁ τ₁ apply unfold_locales (*goal: ‹class.local_catoid (⊙₁) σ₁ τ₁›*) using local.l1_local (*‹Src₁ (?x ⊙₁ σ₁ ?y) ⊆ Src₁ (?x ⊙₁ ?y)›*) local.r1_local (*‹Tgt₁ (τ₁ ?x ⊙₁ ?y) ⊆ Tgt₁ (?x ⊙₁ ?y)›*) apply - (*goals: 1. ‹⋀x y. ⟦⋀x y. Src₁ (x ⊙₁ σ₁ y) ⊆ Src₁ (x ⊙₁ y); ⋀x y. Tgt₁ (τ₁ x ⊙₁ y) ⊆ Tgt₁ (x ⊙₁ y)⟧ ⟹ Src₁ (x ⊙₁ σ₁ y) ⊆ Src₁ (x ⊙₁ y)› 2. ‹⋀x y. ⟦⋀x y. Src₁ (x ⊙₁ σ₁ y) ⊆ Src₁ (x ⊙₁ y); ⋀x y. Tgt₁ (τ₁ x ⊙₁ y) ⊆ Tgt₁ (x ⊙₁ y)⟧ ⟹ Tgt₁ (τ₁ x ⊙₁ y) ⊆ Tgt₁ (x ⊙₁ y)› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . class functional_magma0 = multimagma0 + assumes functionality0: "x ∈ y ⊙₀ z ⟹ x' ∈ y ⊙₀ z ⟹ x = x'" sublocale functional_magma0 ⊆ pm0: functional_magma mcomp0 apply unfold_locales (*goal: ‹class.functional_magma (⊙₀)›*) by (simp add: local.functionality0 (*‹⟦(?x::'a) ∈ (?y::'a) ⊙₀ (?z::'a); (?x'::'a) ∈ ?y ⊙₀ ?z⟧ ⟹ ?x = ?x'›*)) class functional_magma1 = multimagma1 + assumes functionality1: "x ∈ y ⊙₁ z ⟹ x' ∈ y ⊙₁ z ⟹ x = x'" sublocale functional_magma1 ⊆ pm1: functional_magma mcomp1 apply unfold_locales (*goal: ‹class.functional_magma (⊙₁)›*) by (simp add: local.functionality1 (*‹⟦?x ∈ ?y ⊙₁ ?z; ?x' ∈ ?y ⊙₁ ?z⟧ ⟹ ?x = ?x'›*)) class functional_semigroup0 = functional_magma0 + multisemigroup0 sublocale functional_semigroup0 ⊆ psg0: functional_semigroup mcomp0by standard class functional_semigroup1 = functional_magma1 + multisemigroup1 sublocale functional_semigroup1 ⊆ psg1: functional_semigroup mcomp1by standard class functional_catoid0 = functional_semigroup0 + catoid0 sublocale functional_catoid0 ⊆ psg0: functional_catoid mcomp0 σ₀ τ₀by standard class functional_catoid1 = functional_semigroup1 + catoid1 sublocale functional_catoid1 ⊆ psg1: functional_catoid mcomp1 σ₁ τ₁by standard class single_set_category0 = functional_catoid0 + local_catoid0 sublocale single_set_category0 ⊆ sscat0: single_set_category mcomp0 σ₀ τ₀by standard class single_set_category1 = functional_catoid1 + local_catoid1 sublocale single_set_category1 ⊆ sscat1: single_set_category mcomp1 σ₁ τ₁by standard subsection ‹2-Catoids› text ‹We define 2-catoids and 2-categories.› class two_st_multimagma = st_multimagma0 + st_multimagma1 + assumes comm_s0s1: "σ₀ (σ₁ x) = σ₁ (σ₀ x)" and comm_s0t1: "σ₀ (τ₁ x) = τ₁ (σ₀ x)" and comm_t0s1: "τ₀ (σ₁ x) = σ₁ (τ₀ x)" and comm_t0t1: "τ₀ (τ₁ x) = τ₁ (τ₀ x)" assumes interchange: "(w ⊙₁ x) *₀ (y ⊙₁ z) ⊆ (w ⊙₀ y) *₁ (x ⊙₀ z)" and s1_hom: "Src₁ (x ⊙₀ y) ⊆ σ₁ x ⊙₀ σ₁ y" and t1_hom: "Tgt₁ (x ⊙₀ y) ⊆ τ₁ x ⊙₀ τ₁ y" and s0_hom: "Src₀ (x ⊙₁ y) ⊆ σ₀ x ⊙₁ σ₀ y" and t0_hom: "Tgt₀ (x ⊙₁ y) ⊆ τ₀ x ⊙₁ τ₀ y" and s1s0 [simp]: "σ₁ (σ₀ x) = σ₀ x" and s1t0 [simp]: "σ₁ (τ₀ x) = τ₀ x" and t1s0 [simp]: "τ₁ (σ₀ x) = σ₀ x" and t1t0 [simp]: "τ₁ (τ₀ x) = τ₀ x" class two_st_multimagma_strong = two_st_multimagma + assumes s1_hom_strong: "Src₁ (x ⊙₀ y) = σ₁ x ⊙₀ σ₁ y" and t1_hom_strong: "Tgt₁ (x ⊙₀ y) = τ₁ x ⊙₀ τ₁ y" context two_st_multimagma begin sublocale twolropp: two_st_multimagma "λx y. y ⊙₀ x" "τ₀" "σ₀" "λx y. y ⊙₁ x" "τ₁" "σ₁" apply unfold_locales (*goals: 1. ‹⋀x y. Δ₀ y x ⟹ σ₀ x = τ₀ y› 2. ‹⋀x. x ⊙₀ τ₀ x = {x}› 3. ‹⋀x. σ₀ x ⊙₀ x = {x}› 4. ‹⋀x y. Δ₁ y x ⟹ σ₁ x = τ₁ y› 5. ‹⋀x. x ⊙₁ τ₁ x = {x}› 6. ‹⋀x. σ₁ x ⊙₁ x = {x}› 7. ‹⋀x. τ₀ (τ₁ x) = τ₁ (τ₀ x)› 8. ‹⋀x. τ₀ (σ₁ x) = σ₁ (τ₀ x)› 9. ‹⋀x. σ₀ (τ₁ x) = τ₁ (σ₀ x)› 10. ‹⋀x. σ₀ (σ₁ x) = σ₁ (σ₀ x)› 11. ‹⋀w x y z. multimagma.conv (λx y. y ⊙₀ x) (x ⊙₁ w) (z ⊙₁ y) ⊆ multimagma.conv (λx y. y ⊙₁ x) (y ⊙₀ w) (z ⊙₀ x)› 12. ‹⋀x y. Tgt₁ (y ⊙₀ x) ⊆ τ₁ y ⊙₀ τ₁ x› 13. ‹⋀x y. Src₁ (y ⊙₀ x) ⊆ σ₁ y ⊙₀ σ₁ x› 14. ‹⋀x y. Tgt₀ (y ⊙₁ x) ⊆ τ₀ y ⊙₁ τ₀ x› 15. ‹⋀x y. Src₀ (y ⊙₁ x) ⊆ σ₀ y ⊙₁ σ₀ x› 16. ‹⋀x. τ₁ (τ₀ x) = τ₀ x› 17. ‹⋀x. τ₁ (σ₀ x) = σ₀ x› 18. ‹⋀x. σ₁ (τ₀ x) = τ₀ x› 19. ‹⋀x. σ₁ (σ₀ x) = σ₀ x› discuss goal 1*) apply (simp add: stmm0.stopp.Dst (*‹Δ₀ ?y ?x ⟹ σ₀ ?x = τ₀ ?y›*) stmm1.stopp.Dst (*‹Δ₁ ?y ?x ⟹ σ₁ ?x = τ₁ ?y›*) comm_t0t1 (*‹τ₀ (τ₁ ?x) = τ₁ (τ₀ ?x)›*) comm_t0s1 (*‹τ₀ (σ₁ ?x) = σ₁ (τ₀ ?x)›*) comm_s0t1 (*‹σ₀ (τ₁ ?x) = τ₁ (σ₀ ?x)›*) comm_s0s1 (*‹σ₀ (σ₁ ?x) = σ₁ (σ₀ ?x)›*) s1_hom (*‹Src₁ (?x ⊙₀ ?y) ⊆ σ₁ ?x ⊙₀ σ₁ ?y›*) t1_hom (*‹Tgt₁ (?x ⊙₀ ?y) ⊆ τ₁ ?x ⊙₀ τ₁ ?y›*) s0_hom (*‹Src₀ (?x ⊙₁ ?y) ⊆ σ₀ ?x ⊙₁ σ₀ ?y›*) t0_hom (*‹Tgt₀ (?x ⊙₁ ?y) ⊆ τ₀ ?x ⊙₁ τ₀ ?y›*)) (*discuss goal 2*) apply (simp add: stmm0.stopp.Dst (*‹Δ₀ ?y ?x ⟹ σ₀ ?x = τ₀ ?y›*) stmm1.stopp.Dst (*‹Δ₁ ?y ?x ⟹ σ₁ ?x = τ₁ ?y›*) comm_t0t1 (*‹τ₀ (τ₁ ?x) = τ₁ (τ₀ ?x)›*) comm_t0s1 (*‹τ₀ (σ₁ ?x) = σ₁ (τ₀ ?x)›*) comm_s0t1 (*‹σ₀ (τ₁ ?x) = τ₁ (σ₀ ?x)›*) comm_s0s1 (*‹σ₀ (σ₁ ?x) = σ₁ (σ₀ ?x)›*) s1_hom (*‹Src₁ (?x ⊙₀ ?y) ⊆ σ₁ ?x ⊙₀ σ₁ ?y›*) t1_hom (*‹Tgt₁ (?x ⊙₀ ?y) ⊆ τ₁ ?x ⊙₀ τ₁ ?y›*) s0_hom (*‹Src₀ (?x ⊙₁ ?y) ⊆ σ₀ ?x ⊙₁ σ₀ ?y›*) t0_hom (*‹Tgt₀ (?x ⊙₁ ?y) ⊆ τ₀ ?x ⊙₁ τ₀ ?y›*)) (*discuss goal 3*) apply (simp add: stmm0.stopp.Dst (*‹Δ₀ ?y ?x ⟹ σ₀ ?x = τ₀ ?y›*) stmm1.stopp.Dst (*‹Δ₁ ?y ?x ⟹ σ₁ ?x = τ₁ ?y›*) comm_t0t1 (*‹τ₀ (τ₁ ?x) = τ₁ (τ₀ ?x)›*) comm_t0s1 (*‹τ₀ (σ₁ ?x) = σ₁ (τ₀ ?x)›*) comm_s0t1 (*‹σ₀ (τ₁ ?x) = τ₁ (σ₀ ?x)›*) comm_s0s1 (*‹σ₀ (σ₁ ?x) = σ₁ (σ₀ ?x)›*) s1_hom (*‹Src₁ (?x ⊙₀ ?y) ⊆ σ₁ ?x ⊙₀ σ₁ ?y›*) t1_hom (*‹Tgt₁ (?x ⊙₀ ?y) ⊆ τ₁ ?x ⊙₀ τ₁ ?y›*) s0_hom (*‹Src₀ (?x ⊙₁ ?y) ⊆ σ₀ ?x ⊙₁ σ₀ ?y›*) t0_hom (*‹Tgt₀ (?x ⊙₁ ?y) ⊆ τ₀ ?x ⊙₁ τ₀ ?y›*)) (*discuss goal 4*) apply (simp add: stmm0.stopp.Dst (*‹Δ₀ ?y ?x ⟹ σ₀ ?x = τ₀ ?y›*) stmm1.stopp.Dst (*‹Δ₁ ?y ?x ⟹ σ₁ ?x = τ₁ ?y›*) comm_t0t1 (*‹τ₀ (τ₁ ?x) = τ₁ (τ₀ ?x)›*) comm_t0s1 (*‹τ₀ (σ₁ ?x) = σ₁ (τ₀ ?x)›*) comm_s0t1 (*‹σ₀ (τ₁ ?x) = τ₁ (σ₀ ?x)›*) comm_s0s1 (*‹σ₀ (σ₁ ?x) = σ₁ (σ₀ ?x)›*) s1_hom (*‹Src₁ (?x ⊙₀ ?y) ⊆ σ₁ ?x ⊙₀ σ₁ ?y›*) t1_hom (*‹Tgt₁ (?x ⊙₀ ?y) ⊆ τ₁ ?x ⊙₀ τ₁ ?y›*) s0_hom (*‹Src₀ (?x ⊙₁ ?y) ⊆ σ₀ ?x ⊙₁ σ₀ ?y›*) t0_hom (*‹Tgt₀ (?x ⊙₁ ?y) ⊆ τ₀ ?x ⊙₁ τ₀ ?y›*)) (*discuss goal 5*) apply (simp add: stmm0.stopp.Dst (*‹Δ₀ ?y ?x ⟹ σ₀ ?x = τ₀ ?y›*) stmm1.stopp.Dst (*‹Δ₁ ?y ?x ⟹ σ₁ ?x = τ₁ ?y›*) comm_t0t1 (*‹τ₀ (τ₁ ?x) = τ₁ (τ₀ ?x)›*) comm_t0s1 (*‹τ₀ (σ₁ ?x) = σ₁ (τ₀ ?x)›*) comm_s0t1 (*‹σ₀ (τ₁ ?x) = τ₁ (σ₀ ?x)›*) comm_s0s1 (*‹σ₀ (σ₁ ?x) = σ₁ (σ₀ ?x)›*) s1_hom (*‹Src₁ (?x ⊙₀ ?y) ⊆ σ₁ ?x ⊙₀ σ₁ ?y›*) t1_hom (*‹Tgt₁ (?x ⊙₀ ?y) ⊆ τ₁ ?x ⊙₀ τ₁ ?y›*) s0_hom (*‹Src₀ (?x ⊙₁ ?y) ⊆ σ₀ ?x ⊙₁ σ₀ ?y›*) t0_hom (*‹Tgt₀ (?x ⊙₁ ?y) ⊆ τ₀ ?x ⊙₁ τ₀ ?y›*)) (*discuss goal 6*) apply (simp add: stmm0.stopp.Dst (*‹Δ₀ ?y ?x ⟹ σ₀ ?x = τ₀ ?y›*) stmm1.stopp.Dst (*‹Δ₁ ?y ?x ⟹ σ₁ ?x = τ₁ ?y›*) comm_t0t1 (*‹τ₀ (τ₁ ?x) = τ₁ (τ₀ ?x)›*) comm_t0s1 (*‹τ₀ (σ₁ ?x) = σ₁ (τ₀ ?x)›*) comm_s0t1 (*‹σ₀ (τ₁ ?x) = τ₁ (σ₀ ?x)›*) comm_s0s1 (*‹σ₀ (σ₁ ?x) = σ₁ (σ₀ ?x)›*) s1_hom (*‹Src₁ (?x ⊙₀ ?y) ⊆ σ₁ ?x ⊙₀ σ₁ ?y›*) t1_hom (*‹Tgt₁ (?x ⊙₀ ?y) ⊆ τ₁ ?x ⊙₀ τ₁ ?y›*) s0_hom (*‹Src₀ (?x ⊙₁ ?y) ⊆ σ₀ ?x ⊙₁ σ₀ ?y›*) t0_hom (*‹Tgt₀ (?x ⊙₁ ?y) ⊆ τ₀ ?x ⊙₁ τ₀ ?y›*)) (*discuss goal 7*) apply (simp add: stmm0.stopp.Dst (*‹Δ₀ ?y ?x ⟹ σ₀ ?x = τ₀ ?y›*) stmm1.stopp.Dst (*‹Δ₁ ?y ?x ⟹ σ₁ ?x = τ₁ ?y›*) comm_t0t1 (*‹τ₀ (τ₁ ?x) = τ₁ (τ₀ ?x)›*) comm_t0s1 (*‹τ₀ (σ₁ ?x) = σ₁ (τ₀ ?x)›*) comm_s0t1 (*‹σ₀ (τ₁ ?x) = τ₁ (σ₀ ?x)›*) comm_s0s1 (*‹σ₀ (σ₁ ?x) = σ₁ (σ₀ ?x)›*) s1_hom (*‹Src₁ (?x ⊙₀ ?y) ⊆ σ₁ ?x ⊙₀ σ₁ ?y›*) t1_hom (*‹Tgt₁ (?x ⊙₀ ?y) ⊆ τ₁ ?x ⊙₀ τ₁ ?y›*) s0_hom (*‹Src₀ (?x ⊙₁ ?y) ⊆ σ₀ ?x ⊙₁ σ₀ ?y›*) t0_hom (*‹Tgt₀ (?x ⊙₁ ?y) ⊆ τ₀ ?x ⊙₁ τ₀ ?y›*)) (*discuss goal 8*) apply (simp add: stmm0.stopp.Dst (*‹Δ₀ ?y ?x ⟹ σ₀ ?x = τ₀ ?y›*) stmm1.stopp.Dst (*‹Δ₁ ?y ?x ⟹ σ₁ ?x = τ₁ ?y›*) comm_t0t1 (*‹τ₀ (τ₁ ?x) = τ₁ (τ₀ ?x)›*) comm_t0s1 (*‹τ₀ (σ₁ ?x) = σ₁ (τ₀ ?x)›*) comm_s0t1 (*‹σ₀ (τ₁ ?x) = τ₁ (σ₀ ?x)›*) comm_s0s1 (*‹σ₀ (σ₁ ?x) = σ₁ (σ₀ ?x)›*) s1_hom (*‹Src₁ (?x ⊙₀ ?y) ⊆ σ₁ ?x ⊙₀ σ₁ ?y›*) t1_hom (*‹Tgt₁ (?x ⊙₀ ?y) ⊆ τ₁ ?x ⊙₀ τ₁ ?y›*) s0_hom (*‹Src₀ (?x ⊙₁ ?y) ⊆ σ₀ ?x ⊙₁ σ₀ ?y›*) t0_hom (*‹Tgt₀ (?x ⊙₁ ?y) ⊆ τ₀ ?x ⊙₁ τ₀ ?y›*)) (*discuss goal 9*) apply (simp add: stmm0.stopp.Dst (*‹Δ₀ (?y::'a) (?x::'a) ⟹ σ₀ ?x = τ₀ ?y›*) stmm1.stopp.Dst (*‹Δ₁ (?y::'a) (?x::'a) ⟹ σ₁ ?x = τ₁ ?y›*) comm_t0t1 (*‹τ₀ (τ₁ (?x::'a)) = τ₁ (τ₀ ?x)›*) comm_t0s1 (*‹τ₀ (σ₁ (?x::'a)) = σ₁ (τ₀ ?x)›*) comm_s0t1 (*‹σ₀ (τ₁ (?x::'a)) = τ₁ (σ₀ ?x)›*) comm_s0s1 (*‹σ₀ (σ₁ (?x::'a)) = σ₁ (σ₀ ?x)›*) s1_hom (*‹Src₁ ((?x::'a) ⊙₀ (?y::'a)) ⊆ σ₁ ?x ⊙₀ σ₁ ?y›*) t1_hom (*‹Tgt₁ ((?x::'a) ⊙₀ (?y::'a)) ⊆ τ₁ ?x ⊙₀ τ₁ ?y›*) s0_hom (*‹Src₀ ((?x::'a) ⊙₁ (?y::'a)) ⊆ σ₀ ?x ⊙₁ σ₀ ?y›*) t0_hom (*‹Tgt₀ ((?x::'a) ⊙₁ (?y::'a)) ⊆ τ₀ ?x ⊙₁ τ₀ ?y›*)) (*discuss goal 10*) apply (simp add: stmm0.stopp.Dst (*‹Δ₀ ?y ?x ⟹ σ₀ ?x = τ₀ ?y›*) stmm1.stopp.Dst (*‹Δ₁ ?y ?x ⟹ σ₁ ?x = τ₁ ?y›*) comm_t0t1 (*‹τ₀ (τ₁ ?x) = τ₁ (τ₀ ?x)›*) comm_t0s1 (*‹τ₀ (σ₁ ?x) = σ₁ (τ₀ ?x)›*) comm_s0t1 (*‹σ₀ (τ₁ ?x) = τ₁ (σ₀ ?x)›*) comm_s0s1 (*‹σ₀ (σ₁ ?x) = σ₁ (σ₀ ?x)›*) s1_hom (*‹Src₁ (?x ⊙₀ ?y) ⊆ σ₁ ?x ⊙₀ σ₁ ?y›*) t1_hom (*‹Tgt₁ (?x ⊙₀ ?y) ⊆ τ₁ ?x ⊙₀ τ₁ ?y›*) s0_hom (*‹Src₀ (?x ⊙₁ ?y) ⊆ σ₀ ?x ⊙₁ σ₀ ?y›*) t0_hom (*‹Tgt₀ (?x ⊙₁ ?y) ⊆ τ₀ ?x ⊙₁ τ₀ ?y›*)) (*discuss goal 11*) apply (metis local.interchange (*‹?w ⊙₁ ?x *₀ (?y ⊙₁ ?z) ⊆ ?w ⊙₀ ?y *₁ (?x ⊙₀ ?z)›*) local.stmm0.stopp.conv_exp (*‹?Y *₀ ?X = {z. ∃x y. z ∈ y ⊙₀ x ∧ x ∈ ?X ∧ y ∈ ?Y}›*) local.stmm1.stopp.conv_exp (*‹?Y *₁ ?X = {z. ∃x y. z ∈ y ⊙₁ x ∧ x ∈ ?X ∧ y ∈ ?Y}›*) multimagma.conv_exp (*‹multimagma.conv ?mcomp ?X ?Y = {z. ∃x y. z ∈ ?mcomp x y ∧ x ∈ ?X ∧ y ∈ ?Y}›*)) (*discuss goal 12*) apply (simp add: stmm0.stopp.Dst (*‹Δ₀ (?y::'a) (?x::'a) ⟹ σ₀ ?x = τ₀ ?y›*) stmm1.stopp.Dst (*‹Δ₁ (?y::'a) (?x::'a) ⟹ σ₁ ?x = τ₁ ?y›*) comm_t0t1 (*‹τ₀ (τ₁ (?x::'a)) = τ₁ (τ₀ ?x)›*) comm_t0s1 (*‹τ₀ (σ₁ (?x::'a)) = σ₁ (τ₀ ?x)›*) comm_s0t1 (*‹σ₀ (τ₁ (?x::'a)) = τ₁ (σ₀ ?x)›*) comm_s0s1 (*‹σ₀ (σ₁ (?x::'a)) = σ₁ (σ₀ ?x)›*) s1_hom (*‹Src₁ ((?x::'a) ⊙₀ (?y::'a)) ⊆ σ₁ ?x ⊙₀ σ₁ ?y›*) t1_hom (*‹Tgt₁ ((?x::'a) ⊙₀ (?y::'a)) ⊆ τ₁ ?x ⊙₀ τ₁ ?y›*) s0_hom (*‹Src₀ ((?x::'a) ⊙₁ (?y::'a)) ⊆ σ₀ ?x ⊙₁ σ₀ ?y›*) t0_hom (*‹Tgt₀ ((?x::'a) ⊙₁ (?y::'a)) ⊆ τ₀ ?x ⊙₁ τ₀ ?y›*)) (*discuss goal 13*) apply (simp add: stmm0.stopp.Dst (*‹Δ₀ ?y ?x ⟹ σ₀ ?x = τ₀ ?y›*) stmm1.stopp.Dst (*‹Δ₁ ?y ?x ⟹ σ₁ ?x = τ₁ ?y›*) comm_t0t1 (*‹τ₀ (τ₁ ?x) = τ₁ (τ₀ ?x)›*) comm_t0s1 (*‹τ₀ (σ₁ ?x) = σ₁ (τ₀ ?x)›*) comm_s0t1 (*‹σ₀ (τ₁ ?x) = τ₁ (σ₀ ?x)›*) comm_s0s1 (*‹σ₀ (σ₁ ?x) = σ₁ (σ₀ ?x)›*) s1_hom (*‹Src₁ (?x ⊙₀ ?y) ⊆ σ₁ ?x ⊙₀ σ₁ ?y›*) t1_hom (*‹Tgt₁ (?x ⊙₀ ?y) ⊆ τ₁ ?x ⊙₀ τ₁ ?y›*) s0_hom (*‹Src₀ (?x ⊙₁ ?y) ⊆ σ₀ ?x ⊙₁ σ₀ ?y›*) t0_hom (*‹Tgt₀ (?x ⊙₁ ?y) ⊆ τ₀ ?x ⊙₁ τ₀ ?y›*)) (*discuss goal 14*) apply (simp add: stmm0.stopp.Dst (*‹Δ₀ (?y::'a) (?x::'a) ⟹ σ₀ ?x = τ₀ ?y›*) stmm1.stopp.Dst (*‹Δ₁ (?y::'a) (?x::'a) ⟹ σ₁ ?x = τ₁ ?y›*) comm_t0t1 (*‹τ₀ (τ₁ (?x::'a)) = τ₁ (τ₀ ?x)›*) comm_t0s1 (*‹τ₀ (σ₁ (?x::'a)) = σ₁ (τ₀ ?x)›*) comm_s0t1 (*‹σ₀ (τ₁ (?x::'a)) = τ₁ (σ₀ ?x)›*) comm_s0s1 (*‹σ₀ (σ₁ (?x::'a)) = σ₁ (σ₀ ?x)›*) s1_hom (*‹Src₁ ((?x::'a) ⊙₀ (?y::'a)) ⊆ σ₁ ?x ⊙₀ σ₁ ?y›*) t1_hom (*‹Tgt₁ ((?x::'a) ⊙₀ (?y::'a)) ⊆ τ₁ ?x ⊙₀ τ₁ ?y›*) s0_hom (*‹Src₀ ((?x::'a) ⊙₁ (?y::'a)) ⊆ σ₀ ?x ⊙₁ σ₀ ?y›*) t0_hom (*‹Tgt₀ ((?x::'a) ⊙₁ (?y::'a)) ⊆ τ₀ ?x ⊙₁ τ₀ ?y›*)) (*discuss goal 15*) apply (simp add: stmm0.stopp.Dst (*‹Δ₀ (?y::'a::type) (?x::'a::type) ⟹ σ₀ ?x = τ₀ ?y›*) stmm1.stopp.Dst (*‹Δ₁ (?y::'a::type) (?x::'a::type) ⟹ σ₁ ?x = τ₁ ?y›*) comm_t0t1 (*‹τ₀ (τ₁ (?x::'a::type)) = τ₁ (τ₀ ?x)›*) comm_t0s1 (*‹τ₀ (σ₁ (?x::'a::type)) = σ₁ (τ₀ ?x)›*) comm_s0t1 (*‹σ₀ (τ₁ (?x::'a::type)) = τ₁ (σ₀ ?x)›*) comm_s0s1 (*‹σ₀ (σ₁ (?x::'a::type)) = σ₁ (σ₀ ?x)›*) s1_hom (*‹Src₁ ((?x::'a::type) ⊙₀ (?y::'a::type)) ⊆ σ₁ ?x ⊙₀ σ₁ ?y›*) t1_hom (*‹Tgt₁ ((?x::'a::type) ⊙₀ (?y::'a::type)) ⊆ τ₁ ?x ⊙₀ τ₁ ?y›*) s0_hom (*‹Src₀ ((?x::'a::type) ⊙₁ (?y::'a::type)) ⊆ σ₀ ?x ⊙₁ σ₀ ?y›*) t0_hom (*‹Tgt₀ ((?x::'a::type) ⊙₁ (?y::'a::type)) ⊆ τ₀ ?x ⊙₁ τ₀ ?y›*)) (*discuss goal 16*) apply (simp add: stmm0.stopp.Dst (*‹Δ₀ ?y ?x ⟹ σ₀ ?x = τ₀ ?y›*) stmm1.stopp.Dst (*‹Δ₁ ?y ?x ⟹ σ₁ ?x = τ₁ ?y›*) comm_t0t1 (*‹τ₀ (τ₁ ?x) = τ₁ (τ₀ ?x)›*) comm_t0s1 (*‹τ₀ (σ₁ ?x) = σ₁ (τ₀ ?x)›*) comm_s0t1 (*‹σ₀ (τ₁ ?x) = τ₁ (σ₀ ?x)›*) comm_s0s1 (*‹σ₀ (σ₁ ?x) = σ₁ (σ₀ ?x)›*) s1_hom (*‹Src₁ (?x ⊙₀ ?y) ⊆ σ₁ ?x ⊙₀ σ₁ ?y›*) t1_hom (*‹Tgt₁ (?x ⊙₀ ?y) ⊆ τ₁ ?x ⊙₀ τ₁ ?y›*) s0_hom (*‹Src₀ (?x ⊙₁ ?y) ⊆ σ₀ ?x ⊙₁ σ₀ ?y›*) t0_hom (*‹Tgt₀ (?x ⊙₁ ?y) ⊆ τ₀ ?x ⊙₁ τ₀ ?y›*)) (*discuss goal 17*) apply (simp add: stmm0.stopp.Dst (*‹Δ₀ ?y ?x ⟹ σ₀ ?x = τ₀ ?y›*) stmm1.stopp.Dst (*‹Δ₁ ?y ?x ⟹ σ₁ ?x = τ₁ ?y›*) comm_t0t1 (*‹τ₀ (τ₁ ?x) = τ₁ (τ₀ ?x)›*) comm_t0s1 (*‹τ₀ (σ₁ ?x) = σ₁ (τ₀ ?x)›*) comm_s0t1 (*‹σ₀ (τ₁ ?x) = τ₁ (σ₀ ?x)›*) comm_s0s1 (*‹σ₀ (σ₁ ?x) = σ₁ (σ₀ ?x)›*) s1_hom (*‹Src₁ (?x ⊙₀ ?y) ⊆ σ₁ ?x ⊙₀ σ₁ ?y›*) t1_hom (*‹Tgt₁ (?x ⊙₀ ?y) ⊆ τ₁ ?x ⊙₀ τ₁ ?y›*) s0_hom (*‹Src₀ (?x ⊙₁ ?y) ⊆ σ₀ ?x ⊙₁ σ₀ ?y›*) t0_hom (*‹Tgt₀ (?x ⊙₁ ?y) ⊆ τ₀ ?x ⊙₁ τ₀ ?y›*)) (*discuss goal 18*) apply (simp add: stmm0.stopp.Dst (*‹Δ₀ ?y ?x ⟹ σ₀ ?x = τ₀ ?y›*) stmm1.stopp.Dst (*‹Δ₁ ?y ?x ⟹ σ₁ ?x = τ₁ ?y›*) comm_t0t1 (*‹τ₀ (τ₁ ?x) = τ₁ (τ₀ ?x)›*) comm_t0s1 (*‹τ₀ (σ₁ ?x) = σ₁ (τ₀ ?x)›*) comm_s0t1 (*‹σ₀ (τ₁ ?x) = τ₁ (σ₀ ?x)›*) comm_s0s1 (*‹σ₀ (σ₁ ?x) = σ₁ (σ₀ ?x)›*) s1_hom (*‹Src₁ (?x ⊙₀ ?y) ⊆ σ₁ ?x ⊙₀ σ₁ ?y›*) t1_hom (*‹Tgt₁ (?x ⊙₀ ?y) ⊆ τ₁ ?x ⊙₀ τ₁ ?y›*) s0_hom (*‹Src₀ (?x ⊙₁ ?y) ⊆ σ₀ ?x ⊙₁ σ₀ ?y›*) t0_hom (*‹Tgt₀ (?x ⊙₁ ?y) ⊆ τ₀ ?x ⊙₁ τ₀ ?y›*)) (*discuss goal 19*) apply (simp add: stmm0.stopp.Dst (*‹Δ₀ ?y ?x ⟹ σ₀ ?x = τ₀ ?y›*) stmm1.stopp.Dst (*‹Δ₁ ?y ?x ⟹ σ₁ ?x = τ₁ ?y›*) comm_t0t1 (*‹τ₀ (τ₁ ?x) = τ₁ (τ₀ ?x)›*) comm_t0s1 (*‹τ₀ (σ₁ ?x) = σ₁ (τ₀ ?x)›*) comm_s0t1 (*‹σ₀ (τ₁ ?x) = τ₁ (σ₀ ?x)›*) comm_s0s1 (*‹σ₀ (σ₁ ?x) = σ₁ (σ₀ ?x)›*) s1_hom (*‹Src₁ (?x ⊙₀ ?y) ⊆ σ₁ ?x ⊙₀ σ₁ ?y›*) t1_hom (*‹Tgt₁ (?x ⊙₀ ?y) ⊆ τ₁ ?x ⊙₀ τ₁ ?y›*) s0_hom (*‹Src₀ (?x ⊙₁ ?y) ⊆ σ₀ ?x ⊙₁ σ₀ ?y›*) t0_hom (*‹Tgt₀ (?x ⊙₁ ?y) ⊆ τ₀ ?x ⊙₁ τ₀ ?y›*)) (*proven 19 subgoals*) . lemma s0s1 [simp]: "σ₀ (σ₁ x) = σ₀ x" by (simp add: local.comm_s0s1 (*‹σ₀ (σ₁ ?x) = σ₁ (σ₀ ?x)›*)) lemma s0t1 [simp]: "σ₀ (τ₁ x) = σ₀ x" by (simp add: local.comm_s0t1 (*‹σ₀ (τ₁ (?x::'a::type)) = τ₁ (σ₀ ?x)›*)) lemma t0s1 [simp]: "τ₀ (σ₁ x) = τ₀ x" by (simp add: local.comm_t0s1 (*‹τ₀ (σ₁ ?x) = σ₁ (τ₀ ?x)›*)) lemma t1t1 [simp]: "τ₀ (τ₁ x) = τ₀ x" by (simp add: local.comm_t0t1 (*‹τ₀ (τ₁ ?x) = τ₁ (τ₀ ?x)›*)) lemma src0_comp1: "Δ₁ x y ⟹ Src₀ (x ⊙₁ y) = {σ₀ x}" by (metis empty_is_image (*‹({} = (?f::?'b ⇒ ?'a) ` (?A::?'b set)) = (?A = {})›*) local.Dst1 (*‹Δ₁ (?x::'a) (?y::'a) ⟹ τ₁ ?x = σ₁ ?y›*) local.comm_s0t1 (*‹σ₀ (τ₁ (?x::'a)) = τ₁ (σ₀ ?x)›*) local.s1s0 (*‹σ₁ (σ₀ (?x::'a)) = σ₀ ?x›*) local.src1_absorb (*‹σ₁ (?x::'a) ⊙₁ ?x = {?x}›*) local.t1s0 (*‹τ₁ (σ₀ (?x::'a)) = σ₀ ?x›*) s0s1 (*‹σ₀ (σ₁ (?x::'a)) = σ₀ ?x›*) subset_singleton_iff (*‹((?X::?'a set) ⊆ {?a::?'a}) = (?X = {} ∨ ?X = {?a})›*) twolropp.t0_hom (*‹Src₀ ((?y::'a) ⊙₁ (?x::'a)) ⊆ σ₀ ?y ⊙₁ σ₀ ?x›*)) lemma src0_comp1_var: "Δ₁ x y ⟹ Src₀ (x ⊙₁ y) = {σ₀ y}" by (metis local.Dst1 (*‹Δ₁ (?x::'a) (?y::'a) ⟹ τ₁ ?x = σ₁ ?y›*) s0s1 (*‹σ₀ (σ₁ (?x::'a)) = σ₀ ?x›*) s0t1 (*‹σ₀ (τ₁ (?x::'a)) = σ₀ ?x›*) src0_comp1 (*‹Δ₁ (?x::'a) (?y::'a) ⟹ Src₀ (?x ⊙₁ ?y) = {σ₀ ?x}›*)) lemma tgt0_comp1: "Δ₁ x y ⟹ Tgt₀ (x ⊙₁ y) = {τ₀ x}" by (metis empty_is_image (*‹({} = ?f ` ?A) = (?A = {})›*) local.Dst1 (*‹Δ₁ ?x ?y ⟹ τ₁ ?x = σ₁ ?y›*) local.comm_t0t1 (*‹τ₀ (τ₁ ?x) = τ₁ (τ₀ ?x)›*) local.s1t0 (*‹σ₁ (τ₀ ?x) = τ₀ ?x›*) local.src1_absorb (*‹σ₁ ?x ⊙₁ ?x = {?x}›*) local.t1t0 (*‹τ₁ (τ₀ ?x) = τ₀ ?x›*) subset_singleton_iff (*‹(?X ⊆ {?a}) = (?X = {} ∨ ?X = {?a})›*) t0s1 (*‹τ₀ (σ₁ ?x) = τ₀ ?x›*) twolropp.s0_hom (*‹Tgt₀ (?y ⊙₁ ?x) ⊆ τ₀ ?y ⊙₁ τ₀ ?x›*)) lemma tgt0_comp1_var:"Δ₁ x y ⟹ Tgt₀ (x ⊙₁ y) = {τ₀ y}" by (metis local.Dst1 (*‹Δ₁ ?x ?y ⟹ τ₁ ?x = σ₁ ?y›*) t0s1 (*‹τ₀ (σ₁ ?x) = τ₀ ?x›*) t1t1 (*‹τ₀ (τ₁ ?x) = τ₀ ?x›*) tgt0_comp1 (*‹Δ₁ ?x ?y ⟹ Tgt₀ (?x ⊙₁ ?y) = {τ₀ ?x}›*)) text ‹We lift the axioms to the powerset level.› lemma comm_S0S1: "Src₀ (Src₁ X) = Src₁ (Src₀ X)" by (simp add: image_image (*‹?f ` ?g ` ?A = (λx. ?f (?g x)) ` ?A›*)) lemma comm_T0T1: "Tgt₀ (Tgt₁ X) = Tgt₁ (Tgt₀ X)" by (metis (mono_tags, lifting) image_cong (*‹⟦?M = ?N; ⋀x. x ∈ ?N ⟹ ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*) image_image (*‹?f ` ?g ` ?A = (λx. ?f (?g x)) ` ?A›*) local.comm_t0t1 (*‹τ₀ (τ₁ ?x) = τ₁ (τ₀ ?x)›*)) lemma comm_S0T1: "Src₀ (Tgt₁ x) = Tgt₁ (Src₀ x)" by (simp add: image_image (*‹?f ` ?g ` ?A = (λx. ?f (?g x)) ` ?A›*)) lemma comm_T0S1: "Tgt₀ (Src₁ x) = Src₁ (Tgt₀ x)" by (metis (mono_tags, lifting) image_cong (*‹⟦?M = ?N; ⋀x. x ∈ ?N ⟹ ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*) image_image (*‹?f ` ?g ` ?A = (λx. ?f (?g x)) ` ?A›*) local.comm_t0s1 (*‹τ₀ (σ₁ ?x) = σ₁ (τ₀ ?x)›*)) lemma interchange_lifting: "(W *₁ X) *₀ (Y *₁ Z) ⊆ (W *₀ Y) *₁ (X *₀ Z)" proof (-) (*goal: ‹W *₁ X *₀ (Y *₁ Z) ⊆ W *₀ Y *₁ (X *₀ Z)›*) { fix a assume "a ∈ (W *₁ X) *₀ (Y *₁ Z)" (*‹(a::'a) ∈ (W::'a set) *₁ (X::'a set) *₀ ((Y::'a set) *₁ (Z::'a set))›*) hence "∃w ∈ W. ∃x ∈ X. ∃y ∈ Y. ∃z ∈ Z. a ∈ (w ⊙₁ x) *₀ (y ⊙₁ z)" using local.mm0.conv_exp2 (*‹(?z ∈ ?X *₀ ?Y) = (∃x y. ?z ∈ x ⊙₀ y ∧ x ∈ ?X ∧ y ∈ ?Y)›*) local.mm1.conv_exp2 (*‹(?z ∈ ?X *₁ ?Y) = (∃x y. ?z ∈ x ⊙₁ y ∧ x ∈ ?X ∧ y ∈ ?Y)›*) by fastforce hence "∃w ∈ W. ∃x ∈ X. ∃y ∈ Y. ∃z ∈ Z. a ∈ (w ⊙₀ y) *₁ (x ⊙₀ z)" using local.interchange (*‹(?w::'a) ⊙₁ (?x::'a) *₀ ((?y::'a) ⊙₁ (?z::'a)) ⊆ ?w ⊙₀ ?y *₁ (?x ⊙₀ ?z)›*) by blast hence "a ∈ (W *₀ Y) *₁ (X *₀ Z)" using local.mm0.conv_exp2 (*‹(?z ∈ ?X *₀ ?Y) = (∃x y. ?z ∈ x ⊙₀ y ∧ x ∈ ?X ∧ y ∈ ?Y)›*) local.mm1.conv_exp2 (*‹(?z ∈ ?X *₁ ?Y) = (∃x y. ?z ∈ x ⊙₁ y ∧ x ∈ ?X ∧ y ∈ ?Y)›*) by auto } thus "?thesis" (*goal: ‹W *₁ X *₀ (Y *₁ Z) ⊆ W *₀ Y *₁ (X *₀ Z)›*) by standard qed lemma Src1_hom: "Src₁ (X *₀ Y) ⊆ Src₁ X *₀ Src₁ Y" proof (-) (*goal: ‹Src₁ (X *₀ Y) ⊆ Src₁ X *₀ Src₁ Y›*) { fix a have "(a ∈ Src₁ (X *₀ Y)) = (∃b ∈ X *₀ Y. a = σ₁ b)" by blast also (*calculation: ‹(a ∈ Src₁ (X *₀ Y)) = (∃b∈X *₀ Y. a = σ₁ b)›*) have "… = (∃b. ∃c ∈ X. ∃d ∈ Y. a = σ₁ b ∧ b ∈ c ⊙₀ d)" by (metis multimagma.conv_exp2 (*‹(?z ∈ multimagma.conv ?mcomp ?X ?Y) = (∃x y. ?z ∈ ?mcomp x y ∧ x ∈ ?X ∧ y ∈ ?Y)›*)) also (*calculation: ‹(a ∈ Src₁ (X *₀ Y)) = (∃b. ∃c∈X. ∃d∈Y. a = σ₁ b ∧ b ∈ c ⊙₀ d)›*) have "… = (∃c ∈ X. ∃d ∈ Y. a ∈ Src₁ (c ⊙₀ d))" by blast also (*calculation: ‹(a ∈ Src₁ (X *₀ Y)) = (∃c∈X. ∃d∈Y. a ∈ Src₁ (c ⊙₀ d))›*) have "… ⟶ (∃c ∈ X. ∃d ∈ Y. a ∈ σ₁ c ⊙₀ σ₁ d)" using local.s1_hom (*‹Src₁ ((?x::'a) ⊙₀ (?y::'a)) ⊆ σ₁ ?x ⊙₀ σ₁ ?y›*) by fastforce also (*calculation: ‹a ∈ Src₁ (X *₀ Y) ⟶ (∃c∈X. ∃d∈Y. a ∈ σ₁ c ⊙₀ σ₁ d)›*) have "… = (∃c ∈ Src₁ X. ∃d ∈ Src₁ Y. a ∈ c ⊙₀ d)" by blast also (*calculation: ‹a ∈ Src₁ (X *₀ Y) ⟶ (∃c∈Src₁ X. ∃d∈Src₁ Y. a ∈ c ⊙₀ d)›*) have "… = (a ∈ Src₁ X *₀ Src₁ Y)" using local.mm0.conv_exp2 (*‹(?z ∈ ?X *₀ ?Y) = (∃x y. ?z ∈ x ⊙₀ y ∧ x ∈ ?X ∧ y ∈ ?Y)›*) by auto finally (*calculation: ‹a ∈ Src₁ (X *₀ Y) ⟶ a ∈ Src₁ X *₀ Src₁ Y›*) have "(a ∈ Src₁ (X *₀ Y)) ⟶ (a ∈ Src₁ X *₀ Src₁ Y)" . } thus "?thesis" (*goal: ‹Src₁ ((X::'a set) *₀ (Y::'a set)) ⊆ Src₁ X *₀ Src₁ Y›*) by force qed lemma Tgt1_hom: "Tgt₁ (X *₀ Y) ⊆ Tgt₁ X *₀ Tgt₁ Y" proof (-) (*goal: ‹Tgt₁ (X *₀ Y) ⊆ Tgt₁ X *₀ Tgt₁ Y›*) { fix a have "(a ∈ Tgt₁ (X *₀ Y)) = (∃c ∈ X. ∃d ∈ Y. a ∈ Tgt₁ (c ⊙₀ d))" by (smt (verit, best) image_iff (*‹(?z ∈ ?f ` ?A) = (∃x∈?A. ?z = ?f x)›*) multimagma.conv_exp2 (*‹(?z ∈ multimagma.conv ?mcomp ?X ?Y) = (∃x y. ?z ∈ ?mcomp x y ∧ x ∈ ?X ∧ y ∈ ?Y)›*)) also (*calculation: ‹(a ∈ Tgt₁ (X *₀ Y)) = (∃c∈X. ∃d∈Y. a ∈ Tgt₁ (c ⊙₀ d))›*) have "… ⟶ (∃c ∈ X. ∃d ∈ Y. a ∈ τ₁ c ⊙₀ τ₁ d)" using local.t1_hom (*‹Tgt₁ (?x ⊙₀ ?y) ⊆ τ₁ ?x ⊙₀ τ₁ ?y›*) by fastforce also (*calculation: ‹a ∈ Tgt₁ (X *₀ Y) ⟶ (∃c∈X. ∃d∈Y. a ∈ τ₁ c ⊙₀ τ₁ d)›*) have "… = (a ∈ Tgt₁ X *₀ Tgt₁ Y)" using local.mm0.conv_exp2 (*‹((?z::'a) ∈ (?X::'a set) *₀ (?Y::'a set)) = (∃(x::'a) y::'a. ?z ∈ x ⊙₀ y ∧ x ∈ ?X ∧ y ∈ ?Y)›*) by auto finally (*calculation: ‹(a::'a) ∈ Tgt₁ ((X::'a set) *₀ (Y::'a set)) ⟶ a ∈ Tgt₁ X *₀ Tgt₁ Y›*) have "(a ∈ Tgt₁ (X *₀ Y)) ⟶ (a ∈ Tgt₁ X *₀ Tgt₁ Y)" . } thus "?thesis" (*goal: ‹Tgt₁ (X *₀ Y) ⊆ Tgt₁ X *₀ Tgt₁ Y›*) by force qed lemma Src0_hom: "Src₀ (X *₁ Y) ⊆ Src₀ X *₁ Src₀ Y" proof (-) (*goal: ‹Src₀ (X *₁ Y) ⊆ Src₀ X *₁ Src₀ Y›*) { fix a assume "a ∈ Src₀ (X *₁ Y)" (*‹(a::'a) ∈ Src₀ ((X::'a set) *₁ (Y::'a set))›*) hence "∃c ∈ X. ∃d ∈ Y. a ∈ Src₀ (c ⊙₁ d)" using local.mm1.conv_exp2 (*‹((?z::'a) ∈ (?X::'a set) *₁ (?Y::'a set)) = (∃(x::'a) y::'a. ?z ∈ x ⊙₁ y ∧ x ∈ ?X ∧ y ∈ ?Y)›*) by fastforce hence "∃c ∈ X. ∃d ∈ Y. a ∈ σ₀ c ⊙₁ σ₀ d" using local.s0_hom (*‹Src₀ (?x ⊙₁ ?y) ⊆ σ₀ ?x ⊙₁ σ₀ ?y›*) by blast hence "a ∈ Src₀ X *₁ Src₀ Y" using local.mm1.conv_exp2 (*‹(?z ∈ ?X *₁ ?Y) = (∃x y. ?z ∈ x ⊙₁ y ∧ x ∈ ?X ∧ y ∈ ?Y)›*) by auto } thus "?thesis" (*goal: ‹Src₀ (X *₁ Y) ⊆ Src₀ X *₁ Src₀ Y›*) by force qed lemma Tgt0_hom: "Tgt₀ (X *₁ Y) ⊆ Tgt₀ X *₁ Tgt₀ Y" proof (-) (*goal: ‹Tgt₀ (X *₁ Y) ⊆ Tgt₀ X *₁ Tgt₀ Y›*) { fix a assume "a ∈ Tgt₀ (X *₁ Y)" (*‹(a::'a) ∈ Tgt₀ ((X::'a set) *₁ (Y::'a set))›*) hence "∃c ∈ X. ∃d ∈ Y. a ∈ Tgt₀ (c ⊙₁ d)" using local.mm1.conv_exp2 (*‹(?z ∈ ?X *₁ ?Y) = (∃x y. ?z ∈ x ⊙₁ y ∧ x ∈ ?X ∧ y ∈ ?Y)›*) by fastforce hence "∃c ∈ X. ∃d ∈ Y. a ∈ τ₀ c ⊙₁ τ₀ d" using local.t0_hom (*‹Tgt₀ ((?x::'a) ⊙₁ (?y::'a)) ⊆ τ₀ ?x ⊙₁ τ₀ ?y›*) by blast hence "a ∈ Tgt₀ X *₁ Tgt₀ Y" using local.mm1.conv_exp2 (*‹(?z ∈ ?X *₁ ?Y) = (∃x y. ?z ∈ x ⊙₁ y ∧ x ∈ ?X ∧ y ∈ ?Y)›*) by auto } thus "?thesis" (*goal: ‹Tgt₀ (X *₁ Y) ⊆ Tgt₀ X *₁ Tgt₀ Y›*) by force qed lemma S1S0 [simp]: "Src₁ (Src₀ X) = Src₀ X" by force lemma S1T0 [simp]: "Src₁ (Tgt₀ X) = Tgt₀ X" by force lemma T1S0 [simp]: "Tgt₁ (Src₀ X) = Src₀ X" by force lemma T1T0 [simp]: "Tgt₁ (Tgt₀ X) = Tgt₀ X" by force lemma (in two_st_multimagma) "s1fix *₀ s1fix ⊆ s1fix" (*nitpick [expect = genuine]*) oops lemma id1_comp0_eq: "s1fix ⊆ s1fix *₀ s1fix" by (metis S1S0 (*‹Src₁ (Src₀ (?X::'a set)) = Src₀ ?X›*) local.stmm0.stopp.conv_isor (*‹(?X::'a set) ⊆ (?Y::'a set) ⟹ (?Z::'a set) *₀ ?X ⊆ ?Z *₀ ?Y›*) local.stmm0.stopp.conv_uns (*‹(?X::'a set) *₀ t0fix = ?X›*) local.stmm0.stopp.stfix_set (*‹t0fix = s0fix›*) local.stmm0.stopp.tfix_im (*‹s0fix = Src₀ UNIV›*) local.stmm1.stopp.Tgt_subid (*‹Src₁ (?X::'a set) ⊆ s1fix›*)) lemma (in two_st_multimagma) id01: "s0fix ⊆ s1fix" proof (-) (*goal: ‹s0fix ⊆ s1fix›*) { fix a have "(a ∈ s0fix) = (∃b. a = σ₀ b)" by (metis imageE (*‹⟦?b ∈ ?f ` ?A; ⋀x. ⟦?b = ?f x; x ∈ ?A⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*) local.stmm0.stopp.tfix_im (*‹s0fix = Src₀ UNIV›*) rangeI (*‹?f ?x ∈ range ?f›*)) hence "(a ∈ s0fix) = (∃b. a = σ₁ (σ₀ b))" by fastforce hence "(a ∈ s0fix) ⟹ (∃b. a = σ₁ b)" by blast hence "(a ∈ s0fix) ⟹ (a ∈ s1fix)" using local.stmm1.stopp.tfix_im (*‹s1fix = Src₁ UNIV›*) by blast } thus "?thesis" (*goal: ‹s0fix ⊆ s1fix›*) by blast qed end context two_st_multimagma_strong begin lemma Src1_hom_strong: "Src₁ (X *₀ Y) = Src₁ X *₀ Src₁ Y" proof (-) (*goal: ‹Src₁ (X *₀ Y) = Src₁ X *₀ Src₁ Y›*) { fix a have "(a ∈ Src₁ (X *₀ Y)) = (∃b ∈ X *₀ Y. a = σ₁ b)" by blast also (*calculation: ‹(a ∈ Src₁ (X *₀ Y)) = (∃b∈X *₀ Y. a = σ₁ b)›*) have "… = (∃b. ∃c ∈ X. ∃d ∈ Y. a = σ₁ b ∧ b ∈ c ⊙₀ d)" by (metis multimagma.conv_exp2 (*‹(?z ∈ multimagma.conv ?mcomp ?X ?Y) = (∃x y. ?z ∈ ?mcomp x y ∧ x ∈ ?X ∧ y ∈ ?Y)›*)) also (*calculation: ‹(a ∈ Src₁ (X *₀ Y)) = (∃b. ∃c∈X. ∃d∈Y. a = σ₁ b ∧ b ∈ c ⊙₀ d)›*) have "… = (∃c ∈ X. ∃d ∈ Y. a ∈ Src₁ (c ⊙₀ d))" by blast also (*calculation: ‹(a ∈ Src₁ (X *₀ Y)) = (∃c∈X. ∃d∈Y. a ∈ Src₁ (c ⊙₀ d))›*) have "… = (∃c ∈ X. ∃d ∈ Y. a ∈ σ₁ c ⊙₀ σ₁ d)" using local.s1_hom_strong (*‹Src₁ (?x ⊙₀ ?y) = σ₁ ?x ⊙₀ σ₁ ?y›*) by fastforce also (*calculation: ‹(a ∈ Src₁ (X *₀ Y)) = (∃c∈X. ∃d∈Y. a ∈ σ₁ c ⊙₀ σ₁ d)›*) have "… = (∃c ∈ Src₁ X. ∃d ∈ Src₁ Y. a ∈ c ⊙₀ d)" by blast also (*calculation: ‹(a ∈ Src₁ (X *₀ Y)) = (∃c∈Src₁ X. ∃d∈Src₁ Y. a ∈ c ⊙₀ d)›*) have "… = (a ∈ Src₁ X *₀ Src₁ Y)" using local.mm0.conv_exp2 (*‹(?z ∈ ?X *₀ ?Y) = (∃x y. ?z ∈ x ⊙₀ y ∧ x ∈ ?X ∧ y ∈ ?Y)›*) by auto finally (*calculation: ‹(a ∈ Src₁ (X *₀ Y)) = (a ∈ Src₁ X *₀ Src₁ Y)›*) have "(a ∈ Src₁ (X *₀ Y)) = (a ∈ Src₁ X *₀ Src₁ Y)" . } thus "?thesis" (*goal: ‹Src₁ (X *₀ Y) = Src₁ X *₀ Src₁ Y›*) by force qed lemma Tgt1_hom_strong: "Tgt₁ (X *₀ Y) = Tgt₁ X *₀ Tgt₁ Y" proof (-) (*goal: ‹Tgt₁ (X *₀ Y) = Tgt₁ X *₀ Tgt₁ Y›*) { fix a have "(a ∈ Tgt₁ (X *₀ Y)) = (∃c ∈ X. ∃d ∈ Y. a ∈ Tgt₁ (c ⊙₀ d))" by (smt (verit, best) image_iff (*‹(?z ∈ ?f ` ?A) = (∃x∈?A. ?z = ?f x)›*) multimagma.conv_exp2 (*‹(?z ∈ multimagma.conv ?mcomp ?X ?Y) = (∃x y. ?z ∈ ?mcomp x y ∧ x ∈ ?X ∧ y ∈ ?Y)›*)) also (*calculation: ‹(a ∈ Tgt₁ (X *₀ Y)) = (∃c∈X. ∃d∈Y. a ∈ Tgt₁ (c ⊙₀ d))›*) have "… = (∃c ∈ X. ∃d ∈ Y. a ∈ τ₁ c ⊙₀ τ₁ d)" using local.t1_hom_strong (*‹Tgt₁ (?x ⊙₀ ?y) = τ₁ ?x ⊙₀ τ₁ ?y›*) by fastforce also (*calculation: ‹((a::'a) ∈ Tgt₁ ((X::'a set) *₀ (Y::'a set))) = (∃c::'a∈X. ∃d::'a∈Y. a ∈ τ₁ c ⊙₀ τ₁ d)›*) have "… = (a ∈ Tgt₁ X *₀ Tgt₁ Y)" using local.mm0.conv_exp2 (*‹(?z ∈ ?X *₀ ?Y) = (∃x y. ?z ∈ x ⊙₀ y ∧ x ∈ ?X ∧ y ∈ ?Y)›*) by auto finally (*calculation: ‹(a ∈ Tgt₁ (X *₀ Y)) = (a ∈ Tgt₁ X *₀ Tgt₁ Y)›*) have "(a ∈ Tgt₁ (X *₀ Y)) = (a ∈ Tgt₁ X *₀ Tgt₁ Y)" . } thus "?thesis" (*goal: ‹Tgt₁ (X *₀ Y) = Tgt₁ X *₀ Tgt₁ Y›*) by force qed lemma id1_comp0: "s1fix *₀ s1fix ⊆ s1fix" proof (-) (*goal: ‹s1fix *₀ s1fix ⊆ s1fix›*) { fix a have "(a ∈ s1fix *₀ s1fix) = (∃b ∈ s1fix.∃c ∈ s1fix. a ∈ b ⊙₀ c)" by (meson local.mm0.conv_exp2 (*‹((?z::'a::type) ∈ (?X::'a::type set) *₀ (?Y::'a::type set)) = (∃(x::'a::type) y::'a::type. ?z ∈ x ⊙₀ y ∧ x ∈ ?X ∧ y ∈ ?Y)›*)) also (*calculation: ‹((a::'a) ∈ s1fix *₀ s1fix) = (∃b::'a∈s1fix. ∃c::'a∈s1fix. a ∈ b ⊙₀ c)›*) have "… = (∃b c. a ∈ σ₁ b ⊙₀ σ₁ c)" by (metis image_iff (*‹(?z ∈ ?f ` ?A) = (∃x∈?A. ?z = ?f x)›*) local.stmm1.stopp.tfix_im (*‹s1fix = Src₁ UNIV›*) rangeI (*‹?f ?x ∈ range ?f›*)) finally (*calculation: ‹(a ∈ s1fix *₀ s1fix) = (∃b c. a ∈ σ₁ b ⊙₀ σ₁ c)›*) have "(a ∈ s1fix *₀ s1fix) = (∃b c. a ∈ Src₁ (b ⊙₀ c))" using local.s1_hom_strong (*‹Src₁ (?x ⊙₀ ?y) = σ₁ ?x ⊙₀ σ₁ ?y›*) by presburger hence "(a ∈ s1fix *₀ s1fix) ⟹ (∃b. a = σ₁ b)" by blast hence "(a ∈ s1fix *₀ s1fix) ⟹ (a ∈ s1fix)" using local.stmm1.stopp.Tgt_subid (*‹Src₁ ?X ⊆ s1fix›*) by blast } thus "?thesis" (*goal: ‹s1fix *₀ s1fix ⊆ s1fix›*) by blast qed lemma id1_comp0_eq [simp]: "s1fix *₀ s1fix = s1fix" using local.id1_comp0 (*‹s1fix *₀ s1fix ⊆ s1fix›*) local.id1_comp0_eq (*‹s1fix ⊆ s1fix *₀ s1fix›*) by force end subsection‹2-Catoids and single-set 2-categories› class two_catoid = two_st_multimagma + catoid0 + catoid1 lemma (in two_catoid) "Δ₀ x y ⟹ Src₁ (x ⊙₀ y) = {σ₁ x}" (*nitpick[expect = genuine]*) oops lemma (in two_catoid) "Δ₀ x y ⟹ Tgt₁ (x ⊙₀ y) = {τ₁ x}" (*nitpick[expect = genuine]*) oops class two_catoid_strong = two_st_multimagma_strong + catoid0 + catoid1 class local_two_catoid = two_st_multimagma + local_catoid0 + local_catoid1 begin text ‹local 2-catoids need not be strong› lemma "Src₁ (x ⊙₀ y) = σ₁ x ⊙₀ σ₁ y" (*nitpick[expect = genuine]*) oops lemma "Tgt₁ (x ⊙₀ y) = τ₁ x ⊙₀ τ₁ y" (*nitpick[expect = genuine]*) oops lemma "Src₁ (x ⊙₀ y) = σ₁ x ⊙₀ σ₁ y ∨ Tgt₁ (x ⊙₀ y) = τ₁ x ⊙₀ τ₁ y" (*nitpick[expect = genuine]*) oops end class functional_two_catoid = two_st_multimagma + functional_catoid0 + functional_catoid1 begin lemma "Src₁ (x ⊙₀ y) = σ₁ x ⊙₀ σ₁ y" (*nitpick[expect = genuine]*) oops lemma "Tgt₁ (x ⊙₀ y) = τ₁ x ⊙₀ τ₁ y" (*nitpick[expect = genuine]*) oops lemma "Src₁ (x ⊙₀ y) = σ₁ x ⊙₀ σ₁ y ∨ Tgt₁ (x ⊙₀ y) = τ₁ x ⊙₀ τ₁ y" (*nitpick[expect = genuine]*) oops end class local_two_catoid_strong = two_st_multimagma_strong + local_catoid0 + local_catoid1 class two_category = two_st_multimagma + single_set_category0 + single_set_category1 begin lemma s1_hom_strong [simp]: "Src₁ (x ⊙₀ y) = σ₁ x ⊙₀ σ₁ y" proof (cases) (*goals: 1. ‹?P ⟹ Src₁ (x ⊙₀ y) = σ₁ x ⊙₀ σ₁ y› 2. ‹¬ ?P ⟹ Src₁ (x ⊙₀ y) = σ₁ x ⊙₀ σ₁ y›*) assume "σ₁ x ⊙₀ σ₁ y = {}" (*‹σ₁ (x::'a) ⊙₀ σ₁ (y::'a) = {}›*) thus "?thesis" (*goal: ‹Src₁ (x ⊙₀ y) = σ₁ x ⊙₀ σ₁ y›*) using local.twolropp.t1_hom (*‹Src₁ (?y ⊙₀ ?x) ⊆ σ₁ ?y ⊙₀ σ₁ ?x›*) by blast next (*goal: ‹Δ₀ (σ₁ x) (σ₁ y) ⟹ Src₁ (x ⊙₀ y) = σ₁ x ⊙₀ σ₁ y›*) assume h: "σ₁ x ⊙₀ σ₁ y ≠ {}" (*‹Δ₀ (σ₁ (x::'a)) (σ₁ (y::'a))›*) hence "(τ₀ (σ₁ x) = σ₀ (σ₁ y))" using local.Dst0 (*‹Δ₀ ?x ?y ⟹ τ₀ ?x = σ₀ ?y›*) by blast hence "τ₀ x = σ₀ y" by auto hence "x ⊙₀ y ≠ {}" by (simp add: ssmsg0.st_local (*‹Δ₀ (?x::'a) (?y::'a) = (τ₀ ?x = σ₀ ?y)›*)) thus "?thesis" (*goal: ‹Src₁ (x ⊙₀ y) = σ₁ x ⊙₀ σ₁ y›*) by (metis h (*‹Δ₀ (σ₁ x) (σ₁ y)›*) image_is_empty (*‹(?f ` ?A = {}) = (?A = {})›*) local.pm0.fun_in_sgl (*‹(?x ∈ ?y ⊙₀ ?z) = ({?x} = ?y ⊙₀ ?z)›*) local.pm0.functionality_lem (*‹(∃!z. z ∈ ?x ⊙₀ ?y) ∨ ?x ⊙₀ ?y = {}›*) local.twolropp.t1_hom (*‹Src₁ (?y ⊙₀ ?x) ⊆ σ₁ ?y ⊙₀ σ₁ ?x›*) subset_singletonD (*‹?A ⊆ {?x} ⟹ ?A = {} ∨ ?A = {?x}›*)) qed lemma s1_hom_strong_delta: "Δ₀ x y = Δ₀ (σ₁ x) (σ₁ y)" by (simp add: ssmsg0.st_local (*‹Δ₀ (?x::'a::type) (?y::'a::type) = (τ₀ ?x = σ₀ ?y)›*)) lemma t1_hom_strong [simp]: "Tgt₁ (x ⊙₀ y) = τ₁ x ⊙₀ τ₁ y" by (metis (no_types, lifting) empty_is_image (*‹({} = ?f ` ?A) = (?A = {})›*) local.pm0.functionality_lem_var (*‹Δ₀ ?x ?y = (∃z. {z} = ?x ⊙₀ ?y)›*) local.s0t1 (*‹σ₀ (τ₁ ?x) = σ₀ ?x›*) local.t1t1 (*‹τ₀ (τ₁ ?x) = τ₀ ?x›*) local.twolropp.s1_hom (*‹Tgt₁ (?y ⊙₀ ?x) ⊆ τ₁ ?y ⊙₀ τ₁ ?x›*) ssmsg0.st_local (*‹Δ₀ ?x ?y = (τ₀ ?x = σ₀ ?y)›*) subset_singleton_iff (*‹(?X ⊆ {?a}) = (?X = {} ∨ ?X = {?a})›*)) lemma t1_hom_strong_delta: "Δ₀ x y = Δ₀ (τ₁ x) (τ₁ y)" by (simp add: ssmsg0.st_local (*‹Δ₀ ?x ?y = (τ₀ ?x = σ₀ ?y)›*)) lemma conv0_sgl: "a ∈ x ⊙₀ y ⟹ {a} = x ⊙₀ y" using local.functionality0 (*‹⟦?x ∈ ?y ⊙₀ ?z; ?x' ∈ ?y ⊙₀ ?z⟧ ⟹ ?x = ?x'›*) by fastforce lemma conv1_sgl: "a ∈ {x} *₁ {y} ⟹ {a} = {x} *₁ {y}" using local.functionality1 (*‹⟦?x ∈ ?y ⊙₁ ?z; ?x' ∈ ?y ⊙₁ ?z⟧ ⟹ ?x = ?x'›*) local.mm1.conv_exp (*‹?X *₁ ?Y = {z. ∃x y. z ∈ x ⊙₁ y ∧ x ∈ ?X ∧ y ∈ ?Y}›*) by force text ‹Next we derive some simple globular properties.› lemma strong_interchange_St1: assumes "a ∈ (w ⊙₀ x) *₁ (y ⊙₀ z)" shows "Tgt₁ (w ⊙₀ x) = Src₁ (y ⊙₀ z)" by (smt (verit, ccfv_threshold) assms (*‹a ∈ w ⊙₀ x *₁ (y ⊙₀ z)›*) empty_iff (*‹(?c ∈ {}) = False›*) image_insert (*‹?f ` insert ?a ?B = insert (?f ?a) (?f ` ?B)›*) image_is_empty (*‹(?f ` ?A = {}) = (?A = {})›*) insertE (*‹⟦?a ∈ insert ?b ?A; ?a = ?b ⟹ ?P; ?a ∈ ?A ⟹ ?P⟧ ⟹ ?P›*) local.Dst1 (*‹Δ₁ ?x ?y ⟹ τ₁ ?x = σ₁ ?y›*) local.mm1.conv_exp2 (*‹(?z ∈ ?X *₁ ?Y) = (∃x y. ?z ∈ x ⊙₁ y ∧ x ∈ ?X ∧ y ∈ ?Y)›*) local.pm0.functionality_lem_var (*‹Δ₀ ?x ?y = (∃z. {z} = ?x ⊙₀ ?y)›*)) lemma strong_interchange_ll0: assumes "a ∈ (w ⊙₀ x) *₁ (y ⊙₀ z)" shows "σ₀ w = σ₀ y" by (metis assms (*‹a ∈ w ⊙₀ x *₁ (y ⊙₀ z)›*) empty_iff (*‹(?c ∈ {}) = False›*) local.Dst1 (*‹Δ₁ ?x ?y ⟹ τ₁ ?x = σ₁ ?y›*) local.s0s1 (*‹σ₀ (σ₁ ?x) = σ₀ ?x›*) local.s0t1 (*‹σ₀ (τ₁ ?x) = σ₀ ?x›*) local.stmm1.stopp.conv_exp2 (*‹(?z ∈ ?Y *₁ ?X) = (∃x y. ?z ∈ y ⊙₁ x ∧ x ∈ ?X ∧ y ∈ ?Y)›*) stmsg0.src_comp_aux (*‹?v ∈ ?x ⊙₀ ?y ⟹ σ₀ ?v = σ₀ ?x›*)) text ‹There is no strong interchange law, and the homomorphism laws for zero sources and targets stay weak, too.› lemma "(w ⊙₁ y) *₀ (x ⊙₁ z) = (w ⊙₀ x) *₁ (y ⊙₀ z)" (*nitpick [expect = genuine]*) oops lemma "R₀ (x ⊙₁ y) = r₀ x ⊙₁ r₀ y" (*nitpick [expect = genuine]*) oops lemma "L₀ (x ⊙₁ y) = l₀ x ⊙₁ l₀ y" (*nitpick [expect = genuine]*) oops lemma "(W *₀ Y) *₁ (X *₀ Z) = (W *₁ X) *₀ (Y *₁ Z)" (*nitpick [expect = genuine]*) oops lemma "Δ₀ x y ⟹ Src₁ (x ⊙₀ y) = {σ₁ x}" (*nitpick [expect = genuine]*) oops lemma "Δ₀ x y ⟹ Tgt₁ (x ⊙₀ y) = {τ₁ x}" (*nitpick [expect = genuine]*) oops end subsection ‹Reduced axiomatisations› class two_st_multimagma_red = st_multimagma0 + st_multimagma1 + assumes interchange: "(w ⊙₁ x) *₀ (y ⊙₁ z) ⊆ (w ⊙₀ y) *₁ (x ⊙₀ z)" (* irredundant *) assumes src1_hom: "Src₁ (x ⊙₀ y) = σ₁ x ⊙₀ σ₁ y" (* irredundant *) and tgt1_hom: "Tgt₁ (x ⊙₀ y) = τ₁ x ⊙₀ τ₁ y" (* irredundant *) and src0_weak_hom: "Src₀ (x ⊙₁ y) ⊆ σ₀ x ⊙₁ σ₀ y" (* no proof no counterexample *) and tgt0_weak_hom: "Tgt₀ (x ⊙₁ y) ⊆ σ₀ x ⊙₁ σ₀ y" (* no proof no counterexample *) begin lemma s0t1s0 [simp]: "σ₀ (τ₁ (σ₀ x)) = σ₀ x" proof (-) (*goal: ‹σ₀ (τ₁ (σ₀ x)) = σ₀ x›*) have "{τ₁ (σ₀ x)} = Tgt₁ (σ₀ x ⊙₀ σ₀ x)" by simp also (*calculation: ‹{τ₁ (σ₀ x)} = Tgt₁ (σ₀ x ⊙₀ σ₀ x)›*) have "… = τ₁ (σ₀ x) ⊙₀ τ₁ (σ₀ x)" by (meson local.tgt1_hom (*‹Tgt₁ ((?x::'a::type) ⊙₀ (?y::'a::type)) = τ₁ ?x ⊙₀ τ₁ ?y›*)) also (*calculation: ‹{τ₁ (σ₀ x)} = τ₁ (σ₀ x) ⊙₀ τ₁ (σ₀ x)›*) have "… = τ₁ (σ₀ x) ⊙₀ τ₁ (τ₁ (σ₀ x))" by simp also (*calculation: ‹{τ₁ (σ₀ x)} = τ₁ (σ₀ x) ⊙₀ τ₁ (τ₁ (σ₀ x))›*) have "… = Tgt₁ (σ₀ x ⊙₀ τ₁ (σ₀ x))" by (simp add: local.tgt1_hom (*‹Tgt₁ (?x ⊙₀ ?y) = τ₁ ?x ⊙₀ τ₁ ?y›*)) finally (*calculation: ‹{τ₁ (σ₀ x)} = Tgt₁ (σ₀ x ⊙₀ τ₁ (σ₀ x))›*) have "Tgt₁ (σ₀ x ⊙₀ τ₁ (σ₀ x)) ≠ {}" by force hence "σ₀ x ⊙₀ τ₁ (σ₀ x) ≠ {}" by blast thus "?thesis" (*goal: ‹σ₀ (τ₁ (σ₀ x)) = σ₀ x›*) using stmm0.s_absorb_var3 (*‹(σ₀ ?y = σ₀ ?x) = Δ₀ (σ₀ ?x) ?y›*) by auto qed lemma t0s1s0 [simp]: "τ₀ (σ₁ (σ₀ x)) = σ₀ x" proof (-) (*goal: ‹τ₀ (σ₁ (σ₀ x)) = σ₀ x›*) have "{σ₁ (σ₀ x)} = Src₁ (σ₀ x ⊙₀ σ₀ x)" by simp also (*calculation: ‹{σ₁ (σ₀ x)} = Src₁ (σ₀ x ⊙₀ σ₀ x)›*) have "… = σ₁ (σ₀ x) ⊙₀ σ₁ (σ₀ x)" by (meson local.src1_hom (*‹Src₁ (?x ⊙₀ ?y) = σ₁ ?x ⊙₀ σ₁ ?y›*)) also (*calculation: ‹{σ₁ (σ₀ x)} = σ₁ (σ₀ x) ⊙₀ σ₁ (σ₀ x)›*) have "… = σ₁ (σ₁ (σ₀ x)) ⊙₀ σ₁ (σ₀ x)" by simp also (*calculation: ‹{σ₁ (σ₀ (x::'a))} = σ₁ (σ₁ (σ₀ x)) ⊙₀ σ₁ (σ₀ x)›*) have "… = Src₁ (σ₁ (σ₀ x) ⊙₀ σ₀ x)" using local.src1_hom (*‹Src₁ (?x ⊙₀ ?y) = σ₁ ?x ⊙₀ σ₁ ?y›*) by force finally (*calculation: ‹{σ₁ (σ₀ x)} = Src₁ (σ₁ (σ₀ x) ⊙₀ σ₀ x)›*) have "Src₁ (σ₁ (σ₀ x) ⊙₀ σ₀ x) ≠ {}" by force hence "σ₁ (σ₀ x) ⊙₀ σ₀ x ≠ {}" by blast thus "?thesis" (*goal: ‹τ₀ (σ₁ (σ₀ x)) = σ₀ x›*) by (simp add: local.Dst0 (*‹Δ₀ ?x ?y ⟹ τ₀ ?x = σ₀ ?y›*)) qed lemma s1s0 [simp]: "σ₁ (σ₀ x) = σ₀ x" proof (-) (*goal: ‹σ₁ (σ₀ (x::'a)) = σ₀ x›*) have "{σ₀ x} = σ₀ x ⊙₀ σ₀ x" by simp also (*calculation: ‹{σ₀ (x::'a)} = σ₀ x ⊙₀ σ₀ x›*) have "… = (σ₁ (σ₀ x) ⊙₁ σ₀ x) *₀ (σ₀ x ⊙₁ τ₁ (σ₀ x))" by (simp add: multimagma.conv_atom (*‹multimagma.conv ?mcomp {?x} {?y} = ?mcomp ?x ?y›*)) also (*calculation: ‹{σ₀ x} = σ₁ (σ₀ x) ⊙₁ σ₀ x *₀ (σ₀ x ⊙₁ τ₁ (σ₀ x))›*) have "… ⊆ (σ₁ (σ₀ x) ⊙₀ σ₀ x) *₁ (σ₀ x ⊙₀ τ₁ (σ₀ x))" using local.interchange (*‹?w ⊙₁ ?x *₀ (?y ⊙₁ ?z) ⊆ ?w ⊙₀ ?y *₁ (?x ⊙₀ ?z)›*) by blast also (*calculation: ‹{σ₀ (x::'a)} ⊆ σ₁ (σ₀ x) ⊙₀ σ₀ x *₁ (σ₀ x ⊙₀ τ₁ (σ₀ x))›*) have "… = (σ₁ (σ₀ x) ⊙₀ τ₀ (σ₁ (σ₀ x))) *₁ (σ₀ (τ₁ (σ₀ x)) ⊙₀ τ₁ (σ₀ x))" by simp also (*calculation: ‹{σ₀ x} ⊆ σ₁ (σ₀ x) ⊙₀ τ₀ (σ₁ (σ₀ x)) *₁ (σ₀ (τ₁ (σ₀ x)) ⊙₀ τ₁ (σ₀ x))›*) have "… = σ₁ (σ₀ x) ⊙₁ τ₁ (σ₀ x)" using local.mm1.conv_atom (*‹{?x} *₁ {?y} = ?x ⊙₁ ?y›*) local.src0_absorb (*‹σ₀ ?x ⊙₀ ?x = {?x}›*) local.tgt0_absorb (*‹?x ⊙₀ τ₀ ?x = {?x}›*) by presburger finally (*calculation: ‹{σ₀ x} ⊆ σ₁ (σ₀ x) ⊙₁ τ₁ (σ₀ x)›*) have "{σ₀ x} ⊆ σ₁ (σ₀ x) ⊙₁ τ₁ (σ₀ x)" . thus "?thesis" (*goal: ‹σ₁ (σ₀ x) = σ₀ x›*) by (metis empty_iff (*‹(?c ∈ {}) = False›*) insert_subset (*‹(insert ?x ?A ⊆ ?B) = (?x ∈ ?B ∧ ?A ⊆ ?B)›*) singletonD (*‹?b ∈ {?a} ⟹ ?b = ?a›*) stmm1.st_comm (*‹τ₁ ?x ⊙₁ σ₁ ?y = σ₁ ?y ⊙₁ τ₁ ?x›*) stmm1.st_prop (*‹(τ₁ ?x = σ₁ ?y) = Δ₁ (τ₁ ?x) (σ₁ ?y)›*) stmm1.t_idem (*‹τ₁ ?x ⊙₁ τ₁ ?x = {τ₁ ?x}›*)) qed lemma s1t0 [simp]: "σ₁ (τ₀ x) = τ₀ x" by (metis local.s1s0 (*‹σ₁ (σ₀ ?x) = σ₀ ?x›*) local.stmm0.stopp.ts_compat (*‹σ₀ (τ₀ ?x) = τ₀ ?x›*)) lemma t1s0 [simp]: "τ₁ (σ₀ x) = σ₀ x" by (simp add: stmm1.st_fix (*‹(τ₁ ?x = ?x) = (σ₁ ?x = ?x)›*)) lemma t1t0 [simp]: "τ₁ (τ₀ x) = τ₀ x" by (simp add: stmm1.st_fix (*‹(τ₁ ?x = ?x) = (σ₁ ?x = ?x)›*)) lemma comm_s0s1: "σ₀ (σ₁ x) = σ₁ (σ₀ x)" proof (-) (*goal: ‹σ₀ (σ₁ x) = σ₁ (σ₀ x)›*) have "{σ₁ x} = σ₁ (σ₀ x) ⊙₀ σ₁ x" by (metis image_empty (*‹?f ` {} = {}›*) image_insert (*‹?f ` insert ?a ?B = insert (?f ?a) (?f ` ?B)›*) local.src0_absorb (*‹σ₀ ?x ⊙₀ ?x = {?x}›*) local.src1_hom (*‹Src₁ (?x ⊙₀ ?y) = σ₁ ?x ⊙₀ σ₁ ?y›*)) also (*calculation: ‹{σ₁ x} = σ₁ (σ₀ x) ⊙₀ σ₁ x›*) have "… = σ₀ x ⊙₀ σ₁ x" by simp finally (*calculation: ‹{σ₁ x} = σ₀ x ⊙₀ σ₁ x›*) have "σ₀ x ⊙₀ σ₁ x ≠ {}" by force hence "τ₀ (σ₀ x) = σ₀ (σ₁ x)" by (meson local.Dst0 (*‹Δ₀ ?x ?y ⟹ τ₀ ?x = σ₀ ?y›*)) hence "σ₀ x = σ₀ (σ₁ x)" by simp thus "?thesis" (*goal: ‹σ₀ (σ₁ (x::'a)) = σ₁ (σ₀ x)›*) by simp qed lemma comm_s0t1: "σ₀ (τ₁ x) = τ₁ (σ₀ x)" proof (-) (*goal: ‹σ₀ (τ₁ x) = τ₁ (σ₀ x)›*) have "{τ₁ x} = τ₁ (σ₀ x) ⊙₀ τ₁ x" by (metis local.src0_absorb (*‹σ₀ ?x ⊙₀ ?x = {?x}›*) local.t1s0 (*‹τ₁ (σ₀ ?x) = σ₀ ?x›*) local.tgt1_hom (*‹Tgt₁ (?x ⊙₀ ?y) = τ₁ ?x ⊙₀ τ₁ ?y›*) stmm0.s_absorb_var (*‹(σ₀ ?y ≠ σ₀ ?x) = (σ₀ ?y ⊙₀ ?x = {})›*)) hence "τ₁ (σ₀ x) ⊙₀ τ₁ x ≠ {}" by force hence "τ₀ (τ₁ (σ₀ x)) = σ₀ (τ₁ x)" using local.Dst0 (*‹Δ₀ ?x ?y ⟹ τ₀ ?x = σ₀ ?y›*) by blast thus "?thesis" (*goal: ‹σ₀ (τ₁ (x::'a::type)) = τ₁ (σ₀ x)›*) by simp qed lemma comm_t0s1: "τ₀ (σ₁ x) = σ₁ (τ₀ x)" proof (-) (*goal: ‹τ₀ (σ₁ x) = σ₁ (τ₀ x)›*) have "{σ₁ x} = σ₁ x ⊙₀ σ₁ (τ₀ x)" by (metis local.s1t0 (*‹σ₁ (τ₀ (?x::'a)) = τ₀ ?x›*) local.src1_hom (*‹Src₁ ((?x::'a) ⊙₀ (?y::'a)) = σ₁ ?x ⊙₀ σ₁ ?y›*) local.stmm0.stopp.s_absorb_var (*‹(τ₀ (?y::'a) ≠ τ₀ (?x::'a)) = (?x ⊙₀ τ₀ ?y = {})›*) local.tgt0_absorb (*‹(?x::'a) ⊙₀ τ₀ ?x = {?x}›*)) hence "σ₁ x ⊙₀ σ₁ (τ₀ x) ≠ {}" by force hence "τ₀ (σ₁ x) = τ₀ (σ₁ (τ₀ x))" by (metis local.s1t0 (*‹σ₁ (τ₀ ?x) = τ₀ ?x›*) local.stmm0.stopp.s_absorb_var (*‹(τ₀ ?y ≠ τ₀ ?x) = (?x ⊙₀ τ₀ ?y = {})›*) stmm0.tt_idem (*‹τ₀ (τ₀ ?x) = τ₀ ?x›*)) thus "?thesis" (*goal: ‹τ₀ (σ₁ x) = σ₁ (τ₀ x)›*) by simp qed lemma comm_t0t1: "τ₀ (τ₁ x) = τ₁ (τ₀ x)" by (metis local.s1t0 (*‹σ₁ (τ₀ ?x) = τ₀ ?x›*) local.stmm0.stopp.s_absorb_var3 (*‹(τ₀ ?y = τ₀ ?x) = Δ₀ ?y (τ₀ ?x)›*) local.tgt1_hom (*‹Tgt₁ (?x ⊙₀ ?y) = τ₁ ?x ⊙₀ τ₁ ?y›*) stmm1.st_fix (*‹(τ₁ ?x = ?x) = (σ₁ ?x = ?x)›*)) lemma "σ₀ x = σ₁ x" (*nitpick [expect = genuine]*) oops lemma "σ₀ x = τ₁ x" (*nitpick [expect = genuine]*) oops lemma "τ₀ x = τ₁ x" (*nitpick [expect = genuine]*) oops lemma "σ₀ x = τ₀ x" (*nitpick [expect = genuine]*) oops lemma "σ₁ x = τ₁ x" (*nitpick [expect = genuine]*) oops lemma "x ⊙₀ y = x ⊙₁ y" (*nitpick [expect = genuine]*) oops lemma "x ⊙₀ y = y ⊙₀ x" (*nitpick [expect = genuine]*) oops lemma "x ⊙₁ y = y ⊙₁ x" (*nitpick [expect = genuine]*) oops end class two_catoid_red = catoid0 + catoid1 + assumes interchange: "(w ⊙₁ x) *₀ (y ⊙₁ z) ⊆ (w ⊙₀ y) *₁ (x ⊙₀ z)" (* irredundant *) and s1_hom: "Src₁ (x ⊙₀ y) ⊆ σ₁ x ⊙₀ σ₁ y" (* irredundant *) and t1_hom: "Tgt₁ (x ⊙₀ y) ⊆ τ₁ x ⊙₀ τ₁ y" (* irredundant *) begin lemma s0t1s0 [simp]: "σ₀ (τ₁ (σ₀ x)) = σ₀ x" proof (-) (*goal: ‹σ₀ (τ₁ (σ₀ (x::'a))) = σ₀ x›*) have "{σ₀ x} = (σ₁ (σ₀ x) ⊙₁ σ₀ x) *₀ (σ₀ x ⊙₁ τ₁ (σ₀ x))" by simp also (*calculation: ‹{σ₀ x} = σ₁ (σ₀ x) ⊙₁ σ₀ x *₀ (σ₀ x ⊙₁ τ₁ (σ₀ x))›*) have "… ⊆ (σ₁ (σ₀ x) ⊙₀ σ₀ x) *₁ (σ₀ x ⊙₀ τ₁ (σ₀ x))" using local.interchange (*‹?w ⊙₁ ?x *₀ (?y ⊙₁ ?z) ⊆ ?w ⊙₀ ?y *₁ (?x ⊙₀ ?z)›*) by blast finally (*calculation: ‹{σ₀ x} ⊆ σ₁ (σ₀ x) ⊙₀ σ₀ x *₁ (σ₀ x ⊙₀ τ₁ (σ₀ x))›*) have "{σ₀ x} ⊆ (σ₁ (σ₀ x) ⊙₀ σ₀ x) *₁ (σ₀ x ⊙₀ τ₁ (σ₀ x))" . hence "(σ₁ (σ₀ x) ⊙₀ σ₀ x) *₁ (σ₀ x ⊙₀ τ₁ (σ₀ x)) ≠ {}" by fastforce hence "σ₀ x ⊙₀ τ₁ (σ₀ x) ≠ {}" using local.mm1.conv_exp2 (*‹((?z::'a) ∈ (?X::'a set) *₁ (?Y::'a set)) = (∃(x::'a) y::'a. ?z ∈ x ⊙₁ y ∧ x ∈ ?X ∧ y ∈ ?Y)›*) by force thus "?thesis" (*goal: ‹σ₀ (τ₁ (σ₀ x)) = σ₀ x›*) by (simp add: stmm0.s_absorb_var3 (*‹(σ₀ ?y = σ₀ ?x) = Δ₀ (σ₀ ?x) ?y›*)) qed lemma t0s1s0 [simp]: "τ₀ (σ₁ (σ₀ x)) = σ₀ x" proof (-) (*goal: ‹τ₀ (σ₁ (σ₀ x)) = σ₀ x›*) have "{σ₀ x} = (σ₁ (σ₀ x) ⊙₁ σ₀ x) *₀ (σ₀ x ⊙₁ τ₁ (σ₀ x))" by simp also (*calculation: ‹{σ₀ (x::'a)} = σ₁ (σ₀ x) ⊙₁ σ₀ x *₀ (σ₀ x ⊙₁ τ₁ (σ₀ x))›*) have "… ⊆ (σ₁ (σ₀ x) ⊙₀ σ₀ x) *₁ (σ₀ x ⊙₀ τ₁ (σ₀ x))" using local.interchange (*‹?w ⊙₁ ?x *₀ (?y ⊙₁ ?z) ⊆ ?w ⊙₀ ?y *₁ (?x ⊙₀ ?z)›*) by blast finally (*calculation: ‹{σ₀ x} ⊆ σ₁ (σ₀ x) ⊙₀ σ₀ x *₁ (σ₀ x ⊙₀ τ₁ (σ₀ x))›*) have "{σ₀ x} ⊆ (σ₁ (σ₀ x) ⊙₀ σ₀ x) *₁ (σ₀ x ⊙₀ τ₁ (σ₀ x))" . hence "(σ₁ (σ₀ x) ⊙₀ σ₀ x) *₁ (σ₀ x ⊙₀ τ₁ (σ₀ x)) ≠ {}" by fastforce hence "σ₁ (σ₀ x) ⊙₀ σ₀ x ≠ {}" using local.mm1.conv_exp2 (*‹(?z ∈ ?X *₁ ?Y) = (∃x y. ?z ∈ x ⊙₁ y ∧ x ∈ ?X ∧ y ∈ ?Y)›*) by force thus "?thesis" (*goal: ‹τ₀ (σ₁ (σ₀ x)) = σ₀ x›*) by (simp add: local.Dst0 (*‹Δ₀ ?x ?y ⟹ τ₀ ?x = σ₀ ?y›*)) qed lemma s1s0 [simp]: "σ₁ (σ₀ x) = σ₀ x" proof (-) (*goal: ‹σ₁ (σ₀ x) = σ₀ x›*) have "{σ₀ x} = σ₀ x ⊙₀ σ₀ x" by simp also (*calculation: ‹{σ₀ x} = σ₀ x ⊙₀ σ₀ x›*) have "… = (σ₁ (σ₀ x) ⊙₁ σ₀ x) *₀ (σ₀ x ⊙₁ τ₁ (σ₀ x))" by (simp add: multimagma.conv_atom (*‹multimagma.conv ?mcomp {?x} {?y} = ?mcomp ?x ?y›*)) also (*calculation: ‹{σ₀ x} = σ₁ (σ₀ x) ⊙₁ σ₀ x *₀ (σ₀ x ⊙₁ τ₁ (σ₀ x))›*) have "… ⊆ (σ₁ (σ₀ x) ⊙₀ σ₀ x) *₁ (σ₀ x ⊙₀ τ₁ (σ₀ x))" using local.interchange (*‹?w ⊙₁ ?x *₀ (?y ⊙₁ ?z) ⊆ ?w ⊙₀ ?y *₁ (?x ⊙₀ ?z)›*) by blast also (*calculation: ‹{σ₀ (x::'a)} ⊆ σ₁ (σ₀ x) ⊙₀ σ₀ x *₁ (σ₀ x ⊙₀ τ₁ (σ₀ x))›*) have "… = (σ₁ (σ₀ x) ⊙₀ τ₀ (σ₁ (σ₀ x))) *₁ (σ₀ (τ₁ (σ₀ x)) ⊙₀ τ₁ (σ₀ x))" by (metis calculation (*‹{σ₀ x} ⊆ σ₁ (σ₀ x) ⊙₀ σ₀ x *₁ (σ₀ x ⊙₀ τ₁ (σ₀ x))›*) empty_iff (*‹(?c ∈ {}) = False›*) insert_subset (*‹(insert ?x ?A ⊆ ?B) = (?x ∈ ?B ∧ ?A ⊆ ?B)›*) local.t0s1s0 (*‹τ₀ (σ₁ (σ₀ ?x)) = σ₀ ?x›*) multimagma.conv_exp2 (*‹(?z ∈ multimagma.conv ?mcomp ?X ?Y) = (∃x y. ?z ∈ ?mcomp x y ∧ x ∈ ?X ∧ y ∈ ?Y)›*) stmm0.s_absorb_var (*‹(σ₀ ?y ≠ σ₀ ?x) = (σ₀ ?y ⊙₀ ?x = {})›*)) also (*calculation: ‹{σ₀ x} ⊆ σ₁ (σ₀ x) ⊙₀ τ₀ (σ₁ (σ₀ x)) *₁ (σ₀ (τ₁ (σ₀ x)) ⊙₀ τ₁ (σ₀ x))›*) have "… = σ₁ (σ₀ x) ⊙₁ τ₁ (σ₀ x)" using local.mm1.conv_atom (*‹{?x::'a} *₁ {?y::'a} = ?x ⊙₁ ?y›*) local.src0_absorb (*‹σ₀ ?x ⊙₀ ?x = {?x}›*) local.tgt0_absorb (*‹?x ⊙₀ τ₀ ?x = {?x}›*) by presburger finally (*calculation: ‹{σ₀ x} ⊆ σ₁ (σ₀ x) ⊙₁ τ₁ (σ₀ x)›*) have "{σ₀ x} ⊆ σ₁ (σ₀ x) ⊙₁ τ₁ (σ₀ x)" . thus "?thesis" (*goal: ‹σ₁ (σ₀ x) = σ₀ x›*) using local.stmm1.stopp.Dst (*‹Δ₁ ?y ?x ⟹ σ₁ ?x = τ₁ ?y›*) by fastforce qed lemma s1t0 [simp]: "σ₁ (τ₀ x) = τ₀ x" by (metis local.s1s0 (*‹σ₁ (σ₀ (?x::'a::type)) = σ₀ ?x›*) local.stmm0.stopp.ts_compat (*‹σ₀ (τ₀ (?x::'a::type)) = τ₀ ?x›*)) lemma t1s0 [simp]: "τ₁ (σ₀ x) = σ₀ x" by (simp add: stmm1.st_fix (*‹(τ₁ ?x = ?x) = (σ₁ ?x = ?x)›*)) lemma t1t0 [simp]: "τ₁ (τ₀ x) = τ₀ x" by (simp add: stmm1.st_fix (*‹(τ₁ ?x = ?x) = (σ₁ ?x = ?x)›*)) lemma comm_s0s1: "σ₀ (σ₁ x) = σ₁ (σ₀ x)" by (metis image_empty (*‹?f ` {} = {}›*) image_insert (*‹?f ` insert ?a ?B = insert (?f ?a) (?f ` ?B)›*) local.s1_hom (*‹Src₁ (?x ⊙₀ ?y) ⊆ σ₁ ?x ⊙₀ σ₁ ?y›*) local.s1s0 (*‹σ₁ (σ₀ ?x) = σ₀ ?x›*) local.src0_absorb (*‹σ₀ ?x ⊙₀ ?x = {?x}›*) order_class.order_eq_iff (*‹(?x = ?y) = (?x ≤ ?y ∧ ?y ≤ ?x)›*) stmm0.s_absorb_var3 (*‹(σ₀ ?y = σ₀ ?x) = Δ₀ (σ₀ ?x) ?y›*)) lemma comm_s0t1: "σ₀ (τ₁ x) = τ₁ (σ₀ x)" by (metis local.src0_absorb (*‹σ₀ ?x ⊙₀ ?x = {?x}›*) local.src1_absorb (*‹σ₁ ?x ⊙₁ ?x = {?x}›*) local.stmsg1.ts_msg.src_comp_cond (*‹Δ₁ ?y ?x ⟹ Tgt₁ (?y ⊙₁ ?x) = {τ₁ ?x}›*) local.t1_hom (*‹Tgt₁ (?x ⊙₀ ?y) ⊆ τ₁ ?x ⊙₀ τ₁ ?y›*) local.t1s0 (*‹τ₁ (σ₀ ?x) = σ₀ ?x›*) order_antisym_conv (*‹?y ≤ ?x ⟹ (?x ≤ ?y) = (?x = ?y)›*) stmm0.s_absorb_var3 (*‹(σ₀ ?y = σ₀ ?x) = Δ₀ (σ₀ ?x) ?y›*) subset_insertI (*‹?B ⊆ insert ?a ?B›*)) lemma comm_t0s1: "τ₀ (σ₁ x) = σ₁ (τ₀ x)" by (metis equalityI (*‹⟦?A ⊆ ?B; ?B ⊆ ?A⟧ ⟹ ?A = ?B›*) image_empty (*‹?f ` {} = {}›*) image_insert (*‹?f ` insert ?a ?B = insert (?f ?a) (?f ` ?B)›*) local.s1_hom (*‹Src₁ (?x ⊙₀ ?y) ⊆ σ₁ ?x ⊙₀ σ₁ ?y›*) local.s1t0 (*‹σ₁ (τ₀ ?x) = τ₀ ?x›*) local.stmm0.stopp.s_absorb (*‹?x ⊙₀ τ₀ ?x = {?x}›*) local.stmm0.stopp.s_absorb_var2 (*‹(τ₀ ?y = τ₀ ?x) = Δ₀ ?x (τ₀ ?y)›*)) lemma comm_t0t1: "τ₀ (τ₁ x) = τ₁ (τ₀ x)" by (metis empty_is_image (*‹({} = (?f::?'b ⇒ ?'a) ` (?A::?'b set)) = (?A = {})›*) local.src1_absorb (*‹σ₁ (?x::'a) ⊙₁ ?x = {?x}›*) local.stmm0.stopp.s_absorb_var2 (*‹(τ₀ (?y::'a) = τ₀ (?x::'a)) = Δ₀ ?x (τ₀ ?y)›*) local.stmsg1.ts_msg.src_comp_cond (*‹Δ₁ (?y::'a) (?x::'a) ⟹ Tgt₁ (?y ⊙₁ ?x) = {τ₁ ?x}›*) local.t1_hom (*‹Tgt₁ ((?x::'a) ⊙₀ (?y::'a)) ⊆ τ₁ ?x ⊙₀ τ₁ ?y›*) local.t1t0 (*‹τ₁ (τ₀ (?x::'a)) = τ₀ ?x›*) local.tgt0_absorb (*‹(?x::'a) ⊙₀ τ₀ ?x = {?x}›*) subset_antisym (*‹⟦(?A::?'a set) ⊆ (?B::?'a set); ?B ⊆ ?A⟧ ⟹ ?A = ?B›*)) lemma s0_hom: "Src₀ (x ⊙₁ y) ⊆ σ₀ x ⊙₁ σ₀ y" proof (cases) (*goals: 1. ‹?P ⟹ Src₀ (x ⊙₁ y) ⊆ σ₀ x ⊙₁ σ₀ y› 2. ‹¬ ?P ⟹ Src₀ (x ⊙₁ y) ⊆ σ₀ x ⊙₁ σ₀ y›*) assume "Src₀ (x ⊙₁ y) = {}" (*‹Src₀ ((x::'a) ⊙₁ (y::'a)) = {}›*) thus "?thesis" (*goal: ‹Src₀ (x ⊙₁ y) ⊆ σ₀ x ⊙₁ σ₀ y›*) by auto next (*goal: ‹Src₀ (x ⊙₁ y) ≠ {} ⟹ Src₀ (x ⊙₁ y) ⊆ σ₀ x ⊙₁ σ₀ y›*) assume h: "Src₀ (x ⊙₁ y) ≠ {}" (*‹Src₀ ((x::'a) ⊙₁ (y::'a)) ≠ {}›*) hence h1: "τ₁ x = σ₁ y" by (simp add: local.Dst1 (*‹Δ₁ ?x ?y ⟹ τ₁ ?x = σ₁ ?y›*)) hence "Src₀ (x ⊙₁ y) = Src₀ (Src₁ (x ⊙₁ y))" unfolding image_def (*goal: ‹{ya. ∃x∈x ⊙₁ y. ya = σ₀ x} = {ya. ∃x∈{ya. ∃x∈x ⊙₁ y. ya = σ₁ x}. ya = σ₀ x}›*) using local.comm_s0s1 (*‹σ₀ (σ₁ ?x) = σ₁ (σ₀ ?x)›*) by auto also (*calculation: ‹Src₀ (x ⊙₁ y) = Src₀ (Src₁ (x ⊙₁ y))›*) have "… = Src₀ (Src₁ (x ⊙₁ σ₁ y))" using h (*‹Src₀ (x ⊙₁ y) ≠ {}›*) stmsg1.src_local_cond (*‹Δ₁ ?x ?y ⟹ Src₁ (?x ⊙₁ ?y) = Src₁ (?x ⊙₁ σ₁ ?y)›*) by auto also (*calculation: ‹Src₀ ((x::'a) ⊙₁ (y::'a)) = Src₀ (Src₁ (x ⊙₁ σ₁ y))›*) have "… = Src₀ (Src₁ (x ⊙₁ τ₁ x))" using h1 (*‹τ₁ x = σ₁ y›*) by presburger also (*calculation: ‹Src₀ (x ⊙₁ y) = Src₀ (Src₁ (x ⊙₁ τ₁ x))›*) have "… = {σ₀ x}" by (simp add: local.comm_s0s1 (*‹σ₀ (σ₁ ?x) = σ₁ (σ₀ ?x)›*)) also (*calculation: ‹Src₀ (x ⊙₁ y) = {σ₀ x}›*) have "… = σ₀ x ⊙₁ τ₁ (σ₀ x)" using local.tgt1_absorb (*‹?x ⊙₁ τ₁ ?x = {?x}›*) by presburger also (*calculation: ‹Src₀ ((x::'a) ⊙₁ (y::'a)) = σ₀ x ⊙₁ τ₁ (σ₀ x)›*) have "… = σ₀ x ⊙₁ σ₀ (τ₁ x)" by (simp add: local.comm_s0t1 (*‹σ₀ (τ₁ (?x::'a)) = τ₁ (σ₀ ?x)›*)) also (*calculation: ‹Src₀ (x ⊙₁ y) = σ₀ x ⊙₁ σ₀ (τ₁ x)›*) have "… = σ₀ x ⊙₁ σ₀ (σ₁ y)" by (simp add: h1 (*‹τ₁ x = σ₁ y›*)) also (*calculation: ‹Src₀ (x ⊙₁ y) = σ₀ x ⊙₁ σ₀ (σ₁ y)›*) have "… = σ₀ x ⊙₁ σ₀ y" by (simp add: local.comm_s0s1 (*‹σ₀ (σ₁ ?x) = σ₁ (σ₀ ?x)›*)) finally (*calculation: ‹Src₀ (x ⊙₁ y) = σ₀ x ⊙₁ σ₀ y›*) show "?thesis" (*goal: ‹Src₀ ((x::'a::type) ⊙₁ (y::'a::type)) ⊆ σ₀ x ⊙₁ σ₀ y›*) by blast qed lemma t0_hom: "Tgt₀ (x ⊙₁ y) ⊆ τ₀ x ⊙₁ τ₀ y" by (metis equals0D (*‹?A = {} ⟹ ?a ∉ ?A›*) image_subsetI (*‹(⋀x. x ∈ ?A ⟹ ?f x ∈ ?B) ⟹ ?f ` ?A ⊆ ?B›*) local.Dst1 (*‹Δ₁ ?x ?y ⟹ τ₁ ?x = σ₁ ?y›*) local.comm_t0s1 (*‹τ₀ (σ₁ ?x) = σ₁ (τ₀ ?x)›*) local.comm_t0t1 (*‹τ₀ (τ₁ ?x) = τ₁ (τ₀ ?x)›*) local.stmsg1.ts_msg.src_comp_aux (*‹?v ∈ ?y ⊙₁ ?x ⟹ τ₁ ?v = τ₁ ?x›*) local.t1t0 (*‹τ₁ (τ₀ ?x) = τ₀ ?x›*) local.tgt1_absorb (*‹?x ⊙₁ τ₁ ?x = {?x}›*) singletonI (*‹?a ∈ {?a}›*)) end class two_catoid_red_strong = catoid0 + catoid1 + assumes interchange: "(w ⊙₁ x) *₀ (y ⊙₁ z) ⊆ (w ⊙₀ y) *₁ (x ⊙₀ z)" (* irredundant *) and s1_hom_strong: "Src₁ (x ⊙₀ y) = σ₁ x ⊙₀ σ₁ y" (* irredundant *) and t1_hom_strong: "Tgt₁ (x ⊙₀ y) = τ₁ x ⊙₀ τ₁ y" (* irredundant *) begin lemma s0t1s0 [simp]: "σ₀ (τ₁ (σ₀ x)) = σ₀ x" proof (-) (*goal: ‹σ₀ (τ₁ (σ₀ x)) = σ₀ x›*) have "{τ₁ (σ₀ x)} = Tgt₁ (σ₀ x ⊙₀ σ₀ x)" by simp also (*calculation: ‹{τ₁ (σ₀ x)} = Tgt₁ (σ₀ x ⊙₀ σ₀ x)›*) have "… = τ₁ (σ₀ x) ⊙₀ τ₁ (σ₀ x)" using local.t1_hom_strong (*‹Tgt₁ (?x ⊙₀ ?y) = τ₁ ?x ⊙₀ τ₁ ?y›*) by blast also (*calculation: ‹{τ₁ (σ₀ x)} = τ₁ (σ₀ x) ⊙₀ τ₁ (σ₀ x)›*) have "… = τ₁ (σ₀ x) ⊙₀ τ₁ (τ₁ (σ₀ x))" by simp also (*calculation: ‹{τ₁ (σ₀ x)} = τ₁ (σ₀ x) ⊙₀ τ₁ (τ₁ (σ₀ x))›*) have "… = Tgt₁ (σ₀ x ⊙₀ τ₁ (σ₀ x))" by (simp add: local.t1_hom_strong (*‹Tgt₁ (?x ⊙₀ ?y) = τ₁ ?x ⊙₀ τ₁ ?y›*)) finally (*calculation: ‹{τ₁ (σ₀ x)} = Tgt₁ (σ₀ x ⊙₀ τ₁ (σ₀ x))›*) have "Tgt₁ (σ₀ x ⊙₀ τ₁ (σ₀ x)) ≠ {}" by force hence "σ₀ x ⊙₀ τ₁ (σ₀ x) ≠ {}" by blast thus "?thesis" (*goal: ‹σ₀ (τ₁ (σ₀ x)) = σ₀ x›*) using stmm0.s_absorb_var3 (*‹(σ₀ ?y = σ₀ ?x) = Δ₀ (σ₀ ?x) ?y›*) by blast qed lemma t0s1s0 [simp]: "τ₀ (σ₁ (σ₀ x)) = σ₀ x" proof (-) (*goal: ‹τ₀ (σ₁ (σ₀ x)) = σ₀ x›*) have "{σ₁ (σ₀ x)} = Src₁ (σ₀ x ⊙₀ σ₀ x)" by simp also (*calculation: ‹{σ₁ (σ₀ x)} = Src₁ (σ₀ x ⊙₀ σ₀ x)›*) have "… = σ₁ (σ₀ x) ⊙₀ σ₁ (σ₀ x)" using local.s1_hom_strong (*‹Src₁ ((?x::'a::type) ⊙₀ (?y::'a::type)) = σ₁ ?x ⊙₀ σ₁ ?y›*) by blast also (*calculation: ‹{σ₁ (σ₀ x)} = σ₁ (σ₀ x) ⊙₀ σ₁ (σ₀ x)›*) have "… = σ₁ (σ₁ (σ₀ x)) ⊙₀ σ₁ (σ₀ x)" by simp also (*calculation: ‹{σ₁ (σ₀ (x::'a))} = σ₁ (σ₁ (σ₀ x)) ⊙₀ σ₁ (σ₀ x)›*) have "… = Src₁ (σ₁ (σ₀ x) ⊙₀ σ₀ x)" using local.s1_hom_strong (*‹Src₁ (?x ⊙₀ ?y) = σ₁ ?x ⊙₀ σ₁ ?y›*) by auto finally (*calculation: ‹{σ₁ (σ₀ x)} = Src₁ (σ₁ (σ₀ x) ⊙₀ σ₀ x)›*) have "Src₁ (σ₁ (σ₀ x) ⊙₀ σ₀ x) ≠ {}" by force hence "σ₁ (σ₀ x) ⊙₀ σ₀ x ≠ {}" by blast thus "?thesis" (*goal: ‹τ₀ (σ₁ (σ₀ x)) = σ₀ x›*) by (simp add: local.Dst0 (*‹Δ₀ ?x ?y ⟹ τ₀ ?x = σ₀ ?y›*)) qed lemma s1s0 [simp]: "σ₁ (σ₀ x) = σ₀ x" proof (-) (*goal: ‹σ₁ (σ₀ x) = σ₀ x›*) have "{σ₀ x} = σ₀ x ⊙₀ σ₀ x" by simp also (*calculation: ‹{σ₀ x} = σ₀ x ⊙₀ σ₀ x›*) have "… = (σ₁ (σ₀ x) ⊙₁ σ₀ x) *₀ (σ₀ x ⊙₁ τ₁ (σ₀ x))" by (simp add: multimagma.conv_atom (*‹multimagma.conv ?mcomp {?x} {?y} = ?mcomp ?x ?y›*)) also (*calculation: ‹{σ₀ (x::'a)} = σ₁ (σ₀ x) ⊙₁ σ₀ x *₀ (σ₀ x ⊙₁ τ₁ (σ₀ x))›*) have "… ⊆ (σ₁ (σ₀ x) ⊙₀ σ₀ x) *₁ (σ₀ x ⊙₀ τ₁ (σ₀ x))" using local.interchange (*‹?w ⊙₁ ?x *₀ (?y ⊙₁ ?z) ⊆ ?w ⊙₀ ?y *₁ (?x ⊙₀ ?z)›*) by blast also (*calculation: ‹{σ₀ (x::'a)} ⊆ σ₁ (σ₀ x) ⊙₀ σ₀ x *₁ (σ₀ x ⊙₀ τ₁ (σ₀ x))›*) have "… = (σ₁ (σ₀ x) ⊙₀ τ₀ (σ₁ (σ₀ x))) *₁ (σ₀ (τ₁ (σ₀ x)) ⊙₀ τ₁ (σ₀ x))" by simp also (*calculation: ‹{σ₀ x} ⊆ σ₁ (σ₀ x) ⊙₀ τ₀ (σ₁ (σ₀ x)) *₁ (σ₀ (τ₁ (σ₀ x)) ⊙₀ τ₁ (σ₀ x))›*) have "… = σ₁ (σ₀ x) ⊙₁ τ₁ (σ₀ x)" using local.mm1.conv_atom (*‹{?x} *₁ {?y} = ?x ⊙₁ ?y›*) local.src0_absorb (*‹σ₀ (?x::'a) ⊙₀ ?x = {?x}›*) local.tgt0_absorb (*‹?x ⊙₀ τ₀ ?x = {?x}›*) by presburger finally (*calculation: ‹{σ₀ (x::'a)} ⊆ σ₁ (σ₀ x) ⊙₁ τ₁ (σ₀ x)›*) have "{σ₀ x} ⊆ σ₁ (σ₀ x) ⊙₁ τ₁ (σ₀ x)" . thus "?thesis" (*goal: ‹σ₁ (σ₀ x) = σ₀ x›*) using local.stmm1.stopp.Dst (*‹Δ₁ ?y ?x ⟹ σ₁ ?x = τ₁ ?y›*) by fastforce qed lemma s1t0 [simp]: "σ₁ (τ₀ x) = τ₀ x" by (metis local.s1s0 (*‹σ₁ (σ₀ ?x) = σ₀ ?x›*) local.stmm0.stopp.ts_compat (*‹σ₀ (τ₀ ?x) = τ₀ ?x›*)) lemma t1s0 [simp]: "τ₁ (σ₀ x) = σ₀ x" by (simp add: stmm1.st_fix (*‹(τ₁ (?x::'a) = ?x) = (σ₁ ?x = ?x)›*)) lemma t1t0 [simp]: "τ₁ (τ₀ x) = τ₀ x" by (simp add: stmm1.st_fix (*‹(τ₁ ?x = ?x) = (σ₁ ?x = ?x)›*)) lemma comm_s0s1: "σ₀ (σ₁ x) = σ₁ (σ₀ x)" by (metis local.s1_hom_strong (*‹Src₁ (?x ⊙₀ ?y) = σ₁ ?x ⊙₀ σ₁ ?y›*) local.s1s0 (*‹σ₁ (σ₀ ?x) = σ₀ ?x›*) stmm0.s_absorb_var (*‹(σ₀ ?y ≠ σ₀ ?x) = (σ₀ ?y ⊙₀ ?x = {})›*)) lemma comm_s0t1: "σ₀ (τ₁ x) = τ₁ (σ₀ x)" by (metis local.t1_hom_strong (*‹Tgt₁ (?x ⊙₀ ?y) = τ₁ ?x ⊙₀ τ₁ ?y›*) local.t1s0 (*‹τ₁ (σ₀ ?x) = σ₀ ?x›*) stmm0.s_absorb_var (*‹(σ₀ ?y ≠ σ₀ ?x) = (σ₀ ?y ⊙₀ ?x = {})›*)) lemma comm_t0s1: "τ₀ (σ₁ x) = σ₁ (τ₀ x)" by (metis empty_not_insert (*‹{} ≠ insert ?a ?A›*) local.Dst0 (*‹Δ₀ ?x ?y ⟹ τ₀ ?x = σ₀ ?y›*) local.s1_hom_strong (*‹Src₁ (?x ⊙₀ ?y) = σ₁ ?x ⊙₀ σ₁ ?y›*) local.s1t0 (*‹σ₁ (τ₀ ?x) = τ₀ ?x›*) local.tgt0_absorb (*‹?x ⊙₀ τ₀ ?x = {?x}›*)) lemma comm_t0t1: "τ₀ (τ₁ x) = τ₁ (τ₀ x)" using local.t1_hom_strong (*‹Tgt₁ (?x ⊙₀ ?y) = τ₁ ?x ⊙₀ τ₁ ?y›*) local.stmm0.stopp.s_absorb_var2 (*‹(τ₀ ?y = τ₀ ?x) = Δ₀ ?x (τ₀ ?y)›*) by fastforce lemma s0_weak_hom: "Src₀ (x ⊙₁ y) ⊆ σ₀ x ⊙₁ σ₀ y" proof (cases) (*goals: 1. ‹?P ⟹ Src₀ (x ⊙₁ y) ⊆ σ₀ x ⊙₁ σ₀ y› 2. ‹¬ ?P ⟹ Src₀ (x ⊙₁ y) ⊆ σ₀ x ⊙₁ σ₀ y›*) assume "Src₀ (x ⊙₁ y) = {}" (*‹Src₀ ((x::'a) ⊙₁ (y::'a)) = {}›*) thus "?thesis" (*goal: ‹Src₀ (x ⊙₁ y) ⊆ σ₀ x ⊙₁ σ₀ y›*) by auto next (*goal: ‹Src₀ (x ⊙₁ y) ≠ {} ⟹ Src₀ (x ⊙₁ y) ⊆ σ₀ x ⊙₁ σ₀ y›*) assume h: "Src₀ (x ⊙₁ y) ≠ {}" (*‹Src₀ ((x::'a) ⊙₁ (y::'a)) ≠ {}›*) hence h1: "τ₁ x = σ₁ y" by (simp add: local.Dst1 (*‹Δ₁ ?x ?y ⟹ τ₁ ?x = σ₁ ?y›*)) hence "Src₀ (x ⊙₁ y) = Src₀ (Src₁ (x ⊙₁ y))" unfolding image_def (*goal: ‹{ya. ∃x∈x ⊙₁ y. ya = σ₀ x} = {ya. ∃x∈{ya. ∃x∈x ⊙₁ y. ya = σ₁ x}. ya = σ₀ x}›*) using local.comm_s0s1 (*‹σ₀ (σ₁ ?x) = σ₁ (σ₀ ?x)›*) by auto also (*calculation: ‹Src₀ (x ⊙₁ y) = Src₀ (Src₁ (x ⊙₁ y))›*) have "… = Src₀ (Src₁ (x ⊙₁ σ₁ y))" using h (*‹Src₀ (x ⊙₁ y) ≠ {}›*) stmsg1.src_local_cond (*‹Δ₁ ?x ?y ⟹ Src₁ (?x ⊙₁ ?y) = Src₁ (?x ⊙₁ σ₁ ?y)›*) by auto also (*calculation: ‹Src₀ (x ⊙₁ y) = Src₀ (Src₁ (x ⊙₁ σ₁ y))›*) have "… = Src₀ (Src₁ (x ⊙₁ τ₁ x))" using h1 (*‹τ₁ x = σ₁ y›*) by presburger also (*calculation: ‹Src₀ (x ⊙₁ y) = Src₀ (Src₁ (x ⊙₁ τ₁ x))›*) have "… = {σ₀ x}" by (simp add: local.comm_s0s1 (*‹σ₀ (σ₁ (?x::'a::type)) = σ₁ (σ₀ ?x)›*)) also (*calculation: ‹Src₀ ((x::'a) ⊙₁ (y::'a)) = {σ₀ x}›*) have "… = σ₀ x ⊙₁ τ₁ (σ₀ x)" using local.tgt1_absorb (*‹?x ⊙₁ τ₁ ?x = {?x}›*) by presburger also (*calculation: ‹Src₀ (x ⊙₁ y) = σ₀ x ⊙₁ τ₁ (σ₀ x)›*) have "… = σ₀ x ⊙₁ σ₀ (τ₁ x)" by (simp add: local.comm_s0t1 (*‹σ₀ (τ₁ (?x::'a)) = τ₁ (σ₀ ?x)›*)) also (*calculation: ‹Src₀ (x ⊙₁ y) = σ₀ x ⊙₁ σ₀ (τ₁ x)›*) have "… = σ₀ x ⊙₁ σ₀ (σ₁ y)" by (simp add: h1 (*‹τ₁ x = σ₁ y›*)) also (*calculation: ‹Src₀ (x ⊙₁ y) = σ₀ x ⊙₁ σ₀ (σ₁ y)›*) have "… = σ₀ x ⊙₁ σ₀ y" by (simp add: local.comm_s0s1 (*‹σ₀ (σ₁ ?x) = σ₁ (σ₀ ?x)›*)) finally (*calculation: ‹Src₀ ((x::'a::type) ⊙₁ (y::'a::type)) = σ₀ x ⊙₁ σ₀ y›*) show "?thesis" (*goal: ‹Src₀ (x ⊙₁ y) ⊆ σ₀ x ⊙₁ σ₀ y›*) by blast qed lemma t0_weak_hom: "Tgt₀ (x ⊙₁ y) ⊆ τ₀ x ⊙₁ τ₀ y" by (metis equals0D (*‹?A = {} ⟹ ?a ∉ ?A›*) image_subsetI (*‹(⋀x. x ∈ ?A ⟹ ?f x ∈ ?B) ⟹ ?f ` ?A ⊆ ?B›*) local.Dst1 (*‹Δ₁ ?x ?y ⟹ τ₁ ?x = σ₁ ?y›*) local.comm_t0s1 (*‹τ₀ (σ₁ ?x) = σ₁ (τ₀ ?x)›*) local.comm_t0t1 (*‹τ₀ (τ₁ ?x) = τ₁ (τ₀ ?x)›*) local.stmsg1.ts_msg.src_comp_aux (*‹?v ∈ ?y ⊙₁ ?x ⟹ τ₁ ?v = τ₁ ?x›*) local.t1t0 (*‹τ₁ (τ₀ ?x) = τ₀ ?x›*) local.tgt1_absorb (*‹?x ⊙₁ τ₁ ?x = {?x}›*) singletonI (*‹?a ∈ {?a}›*)) end class two_catoid_red2 = single_set_category0 + single_set_category1 + assumes comm_s0s1: "σ₀ (σ₁ x) = σ₁ (σ₀ x)" and comm_s0t1: "σ₀ (τ₁ x) = τ₁ (σ₀ x)" and comm_t0s1: "τ₀ (σ₁ x) = σ₁ (τ₀ x)" and comm_t0t1: "τ₀ (τ₁ x) = τ₁ (τ₀ x)" and s1s0 [simp]: "σ₁ (σ₀ x) = σ₀ x" and s1t0 [simp]: "σ₁ (τ₀ x) = τ₀ x" and t1s0 [simp]: "τ₁ (σ₀ x) = σ₀ x" and t1t0 [simp]: "τ₁ (τ₀ x) = τ₀ x" begin lemma "(w ⊙₁ x) *₀ (y ⊙₁ z) ⊆ (w ⊙₀ y) *₁ (x ⊙₀ z)" (*nitpick [expect = genuine]*) oops lemma "Src₁ (x ⊙₀ y) ⊆ σ₁ x ⊙₀ σ₁ y" (*nitpick [expect = genuine]*) oops lemma "Tgt₁ (x ⊙₀ y) ⊆ τ₁ x ⊙₀ τ₁ y" (*nitpick [expect = genuine]*) oops lemma s0_hom: "Src₀ (x ⊙₁ y) ⊆ σ₀ x ⊙₁ σ₀ y" by (smt (verit, ccfv_SIG) image_subsetI (*‹(⋀x. x ∈ ?A ⟹ ?f x ∈ ?B) ⟹ ?f ` ?A ⊆ ?B›*) insertCI (*‹(?a ∉ ?B ⟹ ?a = ?b) ⟹ ?a ∈ insert ?b ?B›*) local.Dst1 (*‹Δ₁ ?x ?y ⟹ τ₁ ?x = σ₁ ?y›*) local.comm_s0s1 (*‹σ₀ (σ₁ ?x) = σ₁ (σ₀ ?x)›*) local.comm_s0t1 (*‹σ₀ (τ₁ ?x) = τ₁ (σ₀ ?x)›*) local.src0_absorb (*‹σ₀ ?x ⊙₀ ?x = {?x}›*) local.t1s0 (*‹τ₁ (σ₀ ?x) = σ₀ ?x›*) local.tgt1_absorb (*‹?x ⊙₁ τ₁ ?x = {?x}›*) stmm0.s_absorb_var3 (*‹(σ₀ ?y = σ₀ ?x) = Δ₀ (σ₀ ?x) ?y›*) stmsg1.src_twisted_aux (*‹?u ∈ ?x ⊙₁ ?y ⟹ ?x ⊙₁ σ₁ ?y = σ₁ ?u ⊙₁ ?x›*)) lemma t0_hom: "Tgt₀ (x ⊙₁ y) ⊆ τ₀ x ⊙₁ τ₀ y" by (metis equals0D (*‹?A = {} ⟹ ?a ∉ ?A›*) image_subsetI (*‹(⋀x. x ∈ ?A ⟹ ?f x ∈ ?B) ⟹ ?f ` ?A ⊆ ?B›*) insertI1 (*‹?a ∈ insert ?a ?B›*) local.comm_t0s1 (*‹τ₀ (σ₁ ?x) = σ₁ (τ₀ ?x)›*) local.comm_t0t1 (*‹τ₀ (τ₁ ?x) = τ₁ (τ₀ ?x)›*) local.stmm1.stopp.Dst (*‹Δ₁ ?y ?x ⟹ σ₁ ?x = τ₁ ?y›*) local.t1t0 (*‹τ₁ (τ₀ ?x) = τ₀ ?x›*) local.tgt1_absorb (*‹?x ⊙₁ τ₁ ?x = {?x}›*) stmsg1.tgt_comp_aux (*‹?v ∈ ?x ⊙₁ ?y ⟹ τ₁ ?v = τ₁ ?y›*)) end class two_catoid_red3 = catoid0 + catoid1 + assumes interchange: "(w ⊙₁ x) *₀ (y ⊙₁ z) ⊆ (w ⊙₀ y) *₁ (x ⊙₀ z)" and s1_hom: "Src₀ (x ⊙₁ y) ⊆ σ₀ x ⊙₁ σ₀ y" and t1_hom: "Tgt₀ (x ⊙₁ y) ⊆ τ₀ x ⊙₁ τ₀ y" lemma (in two_catoid_red3) "Src₁ (x ⊙₀ y) ⊆ σ₁ x ⊙₀ σ₁ y" (*nitpick [expect = genuine]*) oops lemma (in two_catoid_red3) "Tgt₁ (x ⊙₀ y) ⊆ τ₁ x ⊙₀ τ₁ y" (*nitpick [expect = genuine]*) oops end
{ "path": "afp-2025-02-12/thys/OmegaCatoidsQuantales/Two_Catoid.thy", "repo": "afp-2025-02-12", "sha": "ac6a9abb05ace6aa41af8bd45bcb8faf85f2b1692dbf9c690f5e46833fef9763" }
(* File: Akra_Bazzi_Library.thy Author: Manuel Eberl <manuel@pruvisto.org> Lemma bucket for the Akra-Bazzi theorem. *) section ‹Auxiliary lemmas› theory Akra_Bazzi_Library imports Complex_Main "Landau_Symbols.Landau_More" "Pure-ex.Guess" begin (* TODO: Move? *) lemma ln_mono: "0 < x ⟹ 0 < y ⟹ x ≤ y ⟹ ln (x::real) ≤ ln y" apply (subst ln_le_cancel_iff (*‹⟦0 < ?x; 0 < ?y⟧ ⟹ (ln ?x ≤ ln ?y) = (?x ≤ ?y)›*)) (*goals: 1. ‹⟦(0::real) < (x::real); (0::real) < (y::real); x ≤ y⟧ ⟹ (0::real) < x› 2. ‹⟦(0::real) < (x::real); (0::real) < (y::real); x ≤ y⟧ ⟹ (0::real) < y› 3. ‹⟦(0::real) < (x::real); (0::real) < (y::real); x ≤ y⟧ ⟹ x ≤ y› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*discuss goal 3*) apply simp (*proven 3 subgoals*) . lemma ln_mono_strict: "0 < x ⟹ 0 < y ⟹ x < y ⟹ ln (x::real) < ln y" apply (subst ln_less_cancel_iff (*‹⟦0 < ?x; 0 < ?y⟧ ⟹ (ln ?x < ln ?y) = (?x < ?y)›*)) (*goals: 1. ‹⟦0 < x; 0 < y; x < y⟧ ⟹ 0 < x› 2. ‹⟦0 < x; 0 < y; x < y⟧ ⟹ 0 < y› 3. ‹⟦0 < x; 0 < y; x < y⟧ ⟹ x < y› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*discuss goal 3*) apply simp (*proven 3 subgoals*) . declare DERIV_powr[THEN DERIV_chain2, derivative_intros] lemma sum_pos': assumes "finite I" assumes "∃x∈I. f x > (0 :: _ :: linordered_ab_group_add)" assumes "⋀x. x ∈ I ⟹ f x ≥ 0" shows "sum f I > 0" proof- from assms(2) guess x by (elim bexE) note x = this from x have "I = insert x I" by blast also from assms(1) have "sum f ... = f x + sum f (I - {x})" by (rule sum.insert_remove) also from x assms have "... > 0" by (intro add_pos_nonneg sum_nonneg) simp_all finally show ?thesis . qed lemma min_mult_left: assumes "(x::real) > 0" shows "x * min y z = min (x*y) (x*z)" using assms (*‹0 < x›*) by (auto simp add: min_def (*‹min ?a ?b = (if ?a ≤ ?b then ?a else ?b)›*) 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*)) lemma max_mult_left: assumes "(x::real) > 0" shows "x * max y z = max (x*y) (x*z)" using assms (*‹0 < x›*) by (auto simp add: max_def (*‹max ?a ?b = (if ?a ≤ ?b then ?b 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 15 facts*)) lemma DERIV_nonneg_imp_mono: assumes "⋀t. t∈{x..y} ⟹ (f has_field_derivative f' t) (at t)" assumes "⋀t. t∈{x..y} ⟹ f' t ≥ 0" assumes "(x::real) ≤ y" shows "(f x :: real) ≤ f y" proof (cases x y rule: linorder_cases) assume xy: "x < y" hence "∃z. x < z ∧ z < y ∧ f y - f x = (y - x) * f' z" by (rule MVT2) (insert assms(1), simp) then guess z by (elim exE conjE) note z = this from z(1,2) assms(2) xy have "0 ≤ (y - x) * f' z" by (intro mult_nonneg_nonneg) simp_all also note z(3)[symmetric] finally show "f x ≤ f y" by simp qed (insert assms(3), simp_all) lemma eventually_conjE: "eventually (λx. P x ∧ Q x) F ⟹ (eventually P F ⟹ eventually Q F ⟹ R) ⟹ R" apply (frule eventually_rev_mp[of _ _ P] (*‹⟦eventually ?P ?F; ∀⇩F x in ?F. ?P x ⟶ P x⟧ ⟹ eventually P ?F›*)) (*goals: 1. ‹⟦∀⇩F x in F. P x ∧ Q x; ⟦eventually P F; eventually Q F⟧ ⟹ R⟧ ⟹ ∀⇩F x in F. P x ∧ Q x ⟶ P x› 2. ‹⟦∀⇩F x in F. P x ∧ Q x; ⟦eventually P F; eventually Q F⟧ ⟹ R; eventually P F⟧ ⟹ R› discuss goal 1*) apply simp (*discuss goal 2*) apply (drule eventually_rev_mp[of _ _ Q] (*‹⟦eventually ?P ?F; ∀⇩F x in ?F. ?P x ⟶ Q x⟧ ⟹ eventually Q ?F›*)) (*goals: 1. ‹⟦⟦eventually P F; eventually Q F⟧ ⟹ R; eventually P F⟧ ⟹ ∀⇩F x in F. P x ∧ Q x ⟶ Q x› 2. ‹⟦⟦eventually P F; eventually Q F⟧ ⟹ R; eventually P F; eventually Q F⟧ ⟹ R› discuss goal 1*) apply simp (*discuss goal 2*) apply assumption (*proven 2 subgoals*) (*proven 2 subgoals*) . lemma real_natfloor_nat: "x ∈ ℕ ⟹ real (nat ⌊x⌋) = x" apply (elim Nats_cases (*‹⟦?x ∈ ℕ; ⋀n. ?x = of_nat n ⟹ ?thesis⟧ ⟹ ?thesis›*)) (*goal: ‹x ∈ ℕ ⟹ real (nat ⌊x⌋) = x›*) by simp lemma eventually_natfloor: assumes "eventually P (at_top :: nat filter)" shows "eventually (λx. P (nat ⌊x⌋)) (at_top :: real filter)" proof (-) (*goal: ‹∀⇩F x in at_top. P (nat ⌊x⌋)›*) from assms (*‹eventually P sequentially›*) obtain N where N: "⋀n. n ≥ N ⟹ P n" (*goal: ‹(⋀N. (⋀n. N ≤ n ⟹ P n) ⟹ thesis) ⟹ thesis›*) using eventually_at_top_linorder (*‹eventually ?P at_top = (∃N. ∀n≥N. ?P n)›*) by blast have "∀n≥real N. P (nat ⌊n⌋)" apply (intro allI (*‹(⋀x. ?P x) ⟹ ∀x. ?P x›*) impI (*‹(?P ⟹ ?Q) ⟹ ?P ⟶ ?Q›*) N (*‹N ≤ ?n ⟹ P ?n›*) le_nat_floor (*‹real ?x ≤ ?a ⟹ ?x ≤ nat ⌊?a⌋›*)) (*goal: ‹∀n≥real N. P (nat ⌊n⌋)›*) by simp thus "?thesis" (*goal: ‹∀⇩F x in at_top. P (nat ⌊x⌋)›*) using eventually_at_top_linorder (*‹eventually ?P at_top = (∃N. ∀n≥N. ?P n)›*) by blast qed lemma tendsto_0_smallo_1: "f ∈ o(λx. 1 :: real) ⟹ (f ⤏ 0) at_top" apply (drule smalloD_tendsto (*‹?f ∈ o[?F](?g) ⟹ ((λx. ?f x / ?g x) ⤏ 0) ?F›*)) (*goal: ‹f ∈ o(λx. 1) ⟹ (f ⤏ 0) at_top›*) by simp lemma smallo_1_tendsto_0: "(f ⤏ 0) at_top ⟹ f ∈ o(λx. 1 :: real)" sorry lemma filterlim_at_top_smallomega_1: assumes "f ∈ ω[F](λx. 1 :: real)" "eventually (λx. f x > 0) F" shows "filterlim f at_top F" proof (-) (*goal: ‹filterlim f at_top F›*) from assms (*‹f ∈ ω[F](λx. 1)› ‹∀⇩F x in F. 0 < f x›*) have "filterlim (λx. norm (f x / 1)) at_top F" apply (intro smallomegaD_filterlim_at_top_norm (*‹⟦?f ∈ ω[?F](?g); ∀⇩F x in ?F. ?g x ≠ 0⟧ ⟹ LIM x ?F. norm (?f x / ?g x) :> at_top›*)) (*goals: 1. ‹⟦f ∈ ω[F](λx. 1); ∀⇩F x in F. 0 < f x⟧ ⟹ f ∈ ω[F](λx. 1)› 2. ‹⟦f ∈ ω[F](λx. 1); ∀⇩F x in F. 0 < f x⟧ ⟹ ∀⇩F x in F. 1 ≠ 0› discuss goal 1*) apply ((auto elim: eventually_mono (*‹⟦eventually ?P ?F; ⋀x. ?P x ⟹ ?Q x⟧ ⟹ eventually ?Q ?F›*))[1]) (*discuss goal 2*) apply ((auto elim: eventually_mono (*‹⟦eventually ?P ?F; ⋀x. ?P x ⟹ ?Q x⟧ ⟹ eventually ?Q ?F›*))[1]) (*proven 2 subgoals*) . also (*calculation: ‹LIM x F. norm (f x / 1) :> at_top›*) have "?this ⟷ ?thesis" using assms (*‹f ∈ ω[F](λx. 1)› ‹∀⇩F x in F. 0 < f x›*) apply (intro filterlim_cong (*‹⟦?F1.0 = ?F1'; ?F2.0 = ?F2'; ∀⇩F x in ?F2.0. ?f x = ?g x⟧ ⟹ filterlim ?f ?F1.0 ?F2.0 = filterlim ?g ?F1' ?F2'›*) refl (*‹?t = ?t›*)) (*goal: ‹(LIM x F. norm (f x / 1) :> at_top) = filterlim f at_top F›*) by (auto elim!: eventually_mono (*‹⟦eventually ?P ?F; ⋀x. ?P x ⟹ ?Q x⟧ ⟹ eventually ?Q ?F›*)) finally (*calculation: ‹filterlim f at_top F›*) show "?thesis" (*goal: ‹filterlim f at_top F›*) . qed lemma smallo_imp_abs_less_real: assumes "f ∈ o[F](g)" "eventually (λx. g x > (0::real)) F" shows "eventually (λx. ¦f x¦ < g x) F" proof (-) (*goal: ‹∀⇩F x in F. ¦f x¦ < g x›*) have "1/2 > (0::real)" by simp from landau_o.smallD[OF assms ( 1 ) this] (*‹∀⇩F x in F. norm (f x) ≤ 1 / 2 * norm (g x)›*) assms(2) (*‹∀⇩F x in F. 0 < g x›*) show "?thesis" (*goal: ‹∀⇩F x::'a in F::'a filter. ¦(f::'a ⇒ real) x¦ < (g::'a ⇒ real) x›*) apply eventually_elim (*goal: ‹∀⇩F x in F. ¦f x¦ < g x›*) by auto qed lemma smallo_imp_less_real: assumes "f ∈ o[F](g)" "eventually (λx. g x > (0::real)) F" shows "eventually (λx. f x < g x) F" using smallo_imp_abs_less_real[OF assms] (*‹∀⇩F x in F. ¦f x¦ < g x›*) apply eventually_elim (*goal: ‹∀⇩F x in F. f x < g x›*) by simp lemma smallo_imp_le_real: assumes "f ∈ o[F](g)" "eventually (λx. g x ≥ (0::real)) F" shows "eventually (λx. f x ≤ g x) F" using landau_o.smallD[OF assms ( 1 ) zero_less_one] (*‹∀⇩F x in F. norm (f x) ≤ 1 * norm (g x)›*) assms(2) (*‹∀⇩F x in F. 0 ≤ g x›*) apply eventually_elim (*goal: ‹∀⇩F x in F. f x ≤ g x›*) by simp (* TODO MOVE *) lemma filterlim_at_right: "filterlim f (at_right a) F ⟷ eventually (λx. f x > a) F ∧ filterlim f (nhds a) F" sorry (* END TODO *) lemma one_plus_x_powr_approx_ex: assumes x: "abs (x::real) ≤ 1/2" obtains t where "abs t < 1/2" "(1 + x) powr p = 1 + p * x + p * (p - 1) * (1 + t) powr (p - 2) / 2 * x ^ 2" proof (cases "x = 0") assume x': "x ≠ 0" let ?f = "λx. (1 + x) powr p" let ?f' = "λx. p * (1 + x) powr (p - 1)" let ?f'' = "λx. p * (p - 1) * (1 + x) powr (p - 2)" let ?fs = "(!) [?f, ?f', ?f'']" have A: "∀m t. m < 2 ∧ t ≥ -0.5 ∧ t ≤ 0.5 ⟶ (?fs m has_real_derivative ?fs (Suc m) t) (at t)" proof (clarify) fix m :: nat and t :: real assume m: "m < 2" and t: "t ≥ -0.5" "t ≤ 0.5" thus "(?fs m has_real_derivative ?fs (Suc m) t) (at t)" using m by (cases m) (force intro: derivative_eq_intros algebra_simps)+ qed have "∃t. (if x < 0 then x < t ∧ t < 0 else 0 < t ∧ t < x) ∧ (1 + x) powr p = (∑m<2. ?fs m 0 / (fact m) * (x - 0)^m) + ?fs 2 t / (fact 2) * (x - 0)²" using assms x' by (intro Taylor[OF _ _ A]) simp_all then guess t by (elim exE conjE) note t = this with assms have "abs t < 1/2" by (auto split: if_split_asm) moreover from t(2) have "(1 + x) powr p = 1 + p * x + p * (p - 1) * (1 + t) powr (p - 2) / 2 * x ^ 2" by (simp add: numeral_2_eq_2 of_nat_Suc) ultimately show ?thesis by (rule that) next assume "x = 0" with that[of 0] show ?thesis by simp qed lemma powr_lower_bound: "⟦(l::real) > 0; l ≤ x; x ≤ u⟧ ⟹ min (l powr z) (u powr z) ≤ x powr z" apply (cases "z ≥ 0") (*goals: 1. ‹⟦0 < l; l ≤ x; x ≤ u; 0 ≤ z⟧ ⟹ min (l powr z) (u powr z) ≤ x powr z› 2. ‹⟦0 < l; l ≤ x; x ≤ u; ¬ 0 ≤ z⟧ ⟹ min (l powr z) (u powr z) ≤ x powr z› discuss goal 1*) apply (rule order.trans[OF min.cobounded1 powr_mono2] (*‹⟦0 ≤ ?a1; 0 ≤ ?x1; ?x1 ≤ ?y1⟧ ⟹ min (?x1 powr ?a1) ?b2 ≤ ?y1 powr ?a1›*)) (*goals: 1. ‹⟦0 < l; l ≤ x; x ≤ u; 0 ≤ z⟧ ⟹ 0 ≤ z› 2. ‹⟦0 < l; l ≤ x; x ≤ u; 0 ≤ z⟧ ⟹ 0 ≤ l› 3. ‹⟦0 < l; l ≤ x; x ≤ u; 0 ≤ z⟧ ⟹ l ≤ x› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*discuss goal 3*) apply simp (*proven 3 subgoals*) (*discuss goal 2*) apply (rule order.trans[OF min.cobounded2 powr_mono2'] (*‹⟦(?a1::real) ≤ (0::real); (0::real) < (?x1::real); ?x1 ≤ (?y1::real)⟧ ⟹ min (?a2::real) (?y1 powr ?a1) ≤ ?x1 powr ?a1›*)) (*goals: 1. ‹⟦0 < l; l ≤ x; x ≤ u; ¬ 0 ≤ z⟧ ⟹ z ≤ 0› 2. ‹⟦0 < l; l ≤ x; x ≤ u; ¬ 0 ≤ z⟧ ⟹ 0 < x› 3. ‹⟦0 < l; l ≤ x; x ≤ u; ¬ 0 ≤ z⟧ ⟹ x ≤ u› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*discuss goal 3*) apply simp (*proven 3 subgoals*) (*proven 2 subgoals*) . lemma powr_upper_bound: "⟦(l::real) > 0; l ≤ x; x ≤ u⟧ ⟹ max (l powr z) (u powr z) ≥ x powr z" apply (cases "z ≥ 0") (*goals: 1. ‹⟦(0::real) < (l::real); l ≤ (x::real); x ≤ (u::real); (0::real) ≤ (z::real)⟧ ⟹ x powr z ≤ max (l powr z) (u powr z)› 2. ‹⟦(0::real) < (l::real); l ≤ (x::real); x ≤ (u::real); ¬ (0::real) ≤ (z::real)⟧ ⟹ x powr z ≤ max (l powr z) (u powr z)› discuss goal 1*) apply (rule order.trans[OF powr_mono2 max.cobounded2] (*‹⟦(0::real) ≤ (?a2::real); (0::real) ≤ (?x2::real); ?x2 ≤ (?y2::real)⟧ ⟹ ?x2 powr ?a2 ≤ max (?a1::real) (?y2 powr ?a2)›*)) (*goals: 1. ‹⟦0 < l; l ≤ x; x ≤ u; 0 ≤ z⟧ ⟹ 0 ≤ z› 2. ‹⟦0 < l; l ≤ x; x ≤ u; 0 ≤ z⟧ ⟹ 0 ≤ x› 3. ‹⟦0 < l; l ≤ x; x ≤ u; 0 ≤ z⟧ ⟹ x ≤ u› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*discuss goal 3*) apply simp (*proven 3 subgoals*) (*discuss goal 2*) apply (rule order.trans[OF powr_mono2' max.cobounded1] (*‹⟦?a2 ≤ 0; 0 < ?x2; ?x2 ≤ ?y2⟧ ⟹ ?y2 powr ?a2 ≤ max (?x2 powr ?a2) ?b1›*)) (*goals: 1. ‹⟦0 < l; l ≤ x; x ≤ u; ¬ 0 ≤ z⟧ ⟹ z ≤ 0› 2. ‹⟦0 < l; l ≤ x; x ≤ u; ¬ 0 ≤ z⟧ ⟹ 0 < l› 3. ‹⟦0 < l; l ≤ x; x ≤ u; ¬ 0 ≤ z⟧ ⟹ l ≤ x› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*discuss goal 3*) apply simp (*proven 3 subgoals*) (*proven 2 subgoals*) . lemma one_plus_x_powr_Taylor2: obtains k where "⋀x. abs (x::real) ≤ 1/2 ⟹ abs ((1 + x) powr p - 1 - p*x) ≤ k*x^2" proof- define k where "k = ¦p*(p - 1)¦ * max ((1/2) powr (p - 2)) ((3/2) powr (p - 2)) / 2" show ?thesis proof (rule that[of k]) fix x :: real assume "abs x ≤ 1/2" from one_plus_x_powr_approx_ex[OF this, of p] guess t . note t = this from t have "abs ((1 + x) powr p - 1 - p*x) = ¦p*(p - 1)¦ * (1 + t) powr (p - 2)/2 * x²" by (simp add: abs_mult) also from t(1) have "(1 + t) powr (p - 2) ≤ max ((1/2) powr (p - 2)) ((3/2) powr (p - 2))" by (intro powr_upper_bound) simp_all finally show "abs ((1 + x) powr p - 1 - p*x) ≤ k*x^2" by (simp add: mult_left_mono mult_right_mono k_def) qed qed lemma one_plus_x_powr_Taylor2_bigo: assumes lim: "(f ⤏ 0) F" shows "(λx. (1 + f x) powr (p::real) - 1 - p * f x) ∈ O[F](λx. f x ^ 2)" proof - from one_plus_x_powr_Taylor2[of p] guess k . moreover from tendstoD[OF lim, of "1/2"] have "eventually (λx. abs (f x) < 1/2) F" by (simp add: dist_real_def) ultimately have "eventually (λx. norm ((1 + f x) powr p - 1 - p * f x) ≤ k * norm (f x ^ 2)) F" by (auto elim!: eventually_mono) thus ?thesis by (rule bigoI) qed lemma one_plus_x_powr_Taylor1_bigo: assumes lim: "(f ⤏ 0) F" shows "(λx. (1 + f x) powr (p::real) - 1) ∈ O[F](λx. f x)" proof (-) (*goal: ‹(λx. (1 + f x) powr p - 1) ∈ O[F](f)›*) from assms (*‹(f ⤏ 0) F›*) have "(λx. (1 + f x) powr p - 1 - p * f x) ∈ O[F](λx. (f x)²)" by (rule one_plus_x_powr_Taylor2_bigo (*‹(?f ⤏ 0) ?F ⟹ (λx. (1 + ?f x) powr ?p - 1 - ?p * ?f x) ∈ O[?F](λx. (?f x)²)›*)) also (*calculation: ‹(λx. (1 + f x) powr p - 1 - p * f x) ∈ O[F](λx. (f x)²)›*) from assms (*‹((f::'a::type ⇒ real) ⤏ (0::real)) (F::'a::type filter)›*) have "f ∈ O[F](λ_. 1)" apply (intro bigoI_tendsto (*‹⟦((λx. ?f x / ?g x) ⤏ ?c) ?F; ∀⇩F x in ?F. ?g x ≠ 0⟧ ⟹ ?f ∈ O[?F](?g)›*)) (*goals: 1. ‹((f::'a ⇒ real) ⤏ (0::real)) (F::'a filter) ⟹ ((λx::'a. f x / (1::real)) ⤏ (?c1::real)) F› 2. ‹((f::'a ⇒ real) ⤏ (0::real)) (F::'a filter) ⟹ ∀⇩F x::'a in F. (1::real) ≠ (0::real)› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) . from landau_o.big.mult[of f F f, OF _ this] (*‹f ∈ O[F](f) ⟹ (λx. f x * f x) ∈ O[F](λx. f x * 1)›*) have "(λx. (f x)^2) ∈ O[F](λx. f x)" by (simp add: power2_eq_square (*‹?a² = ?a * ?a›*)) finally (*calculation: ‹(λx. (1 + f x) powr p - 1 - p * f x) ∈ O[F](f)›*) have A: "(λx. (1 + f x) powr p - 1 - p * f x) ∈ O[F](f)" . have B: "(λx. p * f x) ∈ O[F](f)" by simp from sum_in_bigo(1)[OF A B] (*‹(λx::'a::type. ((1::real) + (f::'a::type ⇒ real) x) powr (p::real) - (1::real) - p * f x + p * f x) ∈ O[F::'a::type filter](f)›*) show "?thesis" (*goal: ‹(λx. (1 + f x) powr p - 1) ∈ O[F](f)›*) by simp qed lemma x_times_x_minus_1_nonneg: "x ≤ 0 ∨ x ≥ 1 ⟹ (x::_::linordered_idom) * (x - 1) ≥ 0" proof (elim disjE (*‹⟦?P ∨ ?Q; ?P ⟹ ?R; ?Q ⟹ ?R⟧ ⟹ ?R›*)) (*goals: 1. ‹x ≤ 0 ⟹ 0 ≤ x * (x - 1)› 2. ‹1 ≤ x ⟹ 0 ≤ x * (x - 1)›*) assume x: "x ≤ 0" (*‹(x::'a) ≤ (0::'a)›*) also (*calculation: ‹x ≤ 0›*) have "0 ≤ x^2" by simp finally (*calculation: ‹x ≤ x²›*) show "x * (x - 1) ≥ 0" by (simp add: power2_eq_square (*‹?a² = ?a * ?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 15 facts*)) qed (simp) (*solved the remaining goal: ‹1 ≤ x ⟹ 0 ≤ x * (x - 1)›*) lemma x_times_x_minus_1_nonpos: "x ≥ 0 ⟹ x ≤ 1 ⟹ (x::_::linordered_idom) * (x - 1) ≤ 0" apply (intro mult_nonneg_nonpos (*‹⟦0 ≤ ?a; ?b ≤ 0⟧ ⟹ ?a * ?b ≤ 0›*)) (*goals: 1. ‹⟦0 ≤ x; x ≤ 1⟧ ⟹ 0 ≤ x› 2. ‹⟦0 ≤ x; x ≤ 1⟧ ⟹ x - 1 ≤ 0› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) . lemma real_powr_at_bot: assumes "(a::real) > 1" shows "((λx. a powr x) ⤏ 0) at_bot" proof (-) (*goal: ‹((powr) a ⤏ 0) at_bot›*) from assms (*‹1 < a›*) have "filterlim (λx. ln a * x) at_bot at_bot" apply (intro filterlim_tendsto_pos_mult_at_bot[OF tendsto_const _ filterlim_ident] (*‹(0::real) < (?c::real) ⟹ filterlim ((*) ?c) at_bot at_bot›*)) (*goal: ‹filterlim ((*) (ln (a::real))) at_bot at_bot›*) by auto hence "((λx. exp (x * ln a)) ⤏ 0) at_bot" apply (intro filterlim_compose[OF exp_at_bot] (*‹filterlim ?f at_bot ?F1.0 ⟹ ((λx. exp (?f x)) ⤏ 0) ?F1.0›*)) (*goal: ‹((λx::real. exp (x * ln (a::real))) ⤏ (0::real)) at_bot›*) 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*)) thus "?thesis" (*goal: ‹((powr) a ⤏ 0) at_bot›*) using assms (*‹(1::real) < (a::real)›*) unfolding powr_def (*goal: ‹((λx. if a = 0 then 0 else exp (x * ln a)) ⤏ 0) at_bot›*) by simp qed lemma real_powr_at_bot_neg: assumes "(a::real) > 0" "a < 1" shows "filterlim (λx. a powr x) at_top at_bot" proof (-) (*goal: ‹filterlim ((powr) a) at_top at_bot›*) from assms (*‹0 < a› ‹a < 1›*) have "LIM x at_bot. ln (inverse a) * -x :> at_top" apply (intro filterlim_tendsto_pos_mult_at_top[OF tendsto_const] (*‹⟦(0::real) < (?c::real); filterlim (?g::?'a ⇒ real) at_top (?F::?'a filter)⟧ ⟹ LIM (x::?'a) ?F. ?c * ?g x :> at_top›*) filterlim_uminus_at_top_at_bot (*‹filterlim uminus at_top at_bot›*)) (*goal: ‹LIM (x::real) at_bot. ln (inverse (a::real)) * - x :> at_top›*) by (simp add: ln_inverse (*‹0 < ?x ⟹ ln (inverse ?x) = - ln ?x›*)) with assms (*‹0 < a› ‹a < 1›*) have "LIM x at_bot. x * ln a :> at_top" apply (subst (asm) ln_inverse (*‹(0::real) < (?x::real) ⟹ ln (inverse ?x) = - ln ?x›*)) (*goals: 1. ‹⟦0 < a; a < 1⟧ ⟹ 0 < a› 2. ‹⟦0 < a; a < 1; LIM x at_bot. - ln a * - x :> at_top⟧ ⟹ LIM x at_bot. x * ln a :> at_top› discuss goal 1*) apply (simp add: mult.commute (*‹?a * ?b = ?b * ?a›*)) (*discuss goal 2*) apply (simp add: mult.commute (*‹?a * ?b = ?b * ?a›*)) (*proven 2 subgoals*) . hence "LIM x at_bot. exp (x * ln a) :> at_top" apply (intro filterlim_compose[OF exp_at_top] (*‹filterlim (?f::?'c::type ⇒ real) at_top (?F1.0::?'c::type filter) ⟹ LIM (x::?'c::type) ?F1.0. exp (?f x) :> at_top›*)) (*goal: ‹LIM x at_bot. exp (x * ln a) :> at_top›*) by simp thus "?thesis" (*goal: ‹filterlim ((powr) a) at_top at_bot›*) using assms (*‹0 < a› ‹a < 1›*) unfolding powr_def (*goal: ‹LIM (x::real) at_bot. if (a::real) = (0::real) then 0::real else exp (x * ln a) :> at_top›*) by simp qed lemma real_powr_at_top_neg: assumes "(a::real) > 0" "a < 1" shows "((λx. a powr x) ⤏ 0) at_top" proof (-) (*goal: ‹((powr) (a::real) ⤏ (0::real)) at_top›*) from assms (*‹0 < a› ‹a < 1›*) have "LIM x at_top. ln (inverse a) * x :> at_top" apply (intro filterlim_tendsto_pos_mult_at_top[OF tendsto_const] (*‹⟦0 < ?c; filterlim ?g at_top ?F⟧ ⟹ LIM x ?F. ?c * ?g x :> at_top›*)) (*goals: 1. ‹⟦0 < a; a < 1⟧ ⟹ 0 < ln (inverse a)› 2. ‹⟦0 < a; a < 1⟧ ⟹ LIM x at_top. x :> at_top› discuss goal 1*) apply (simp add: filterlim_ident (*‹LIM x ?F. x :> ?F›*) 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*)) (*discuss goal 2*) apply (simp add: filterlim_ident (*‹LIM x ?F. x :> ?F›*) 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*)) (*proven 2 subgoals*) . with assms (*‹0 < a› ‹(a::real) < (1::real)›*) have "LIM x at_top. ln a * x :> at_bot" apply (subst filterlim_uminus_at_bot (*‹filterlim ?f at_bot ?F = (LIM x ?F. - ?f x :> at_top)›*)) (*goal: ‹filterlim ((*) (ln a)) at_bot at_top›*) by (simp add: ln_inverse (*‹(0::real) < (?x::real) ⟹ ln (inverse ?x) = - ln ?x›*)) hence "((λx. exp (x * ln a)) ⤏ 0) at_top" apply (intro filterlim_compose[OF exp_at_bot] (*‹filterlim ?f at_bot ?F1.0 ⟹ ((λx. exp (?f x)) ⤏ 0) ?F1.0›*)) (*goal: ‹((λx. exp (x * ln a)) ⤏ 0) at_top›*) by (simp add: mult.commute (*‹?a * ?b = ?b * ?a›*)) with assms (*‹0 < a› ‹a < 1›*) show "?thesis" (*goal: ‹((powr) a ⤏ 0) at_top›*) unfolding powr_def (*goal: ‹((λx. if a = 0 then 0 else exp (x * ln a)) ⤏ 0) at_top›*) by simp qed lemma eventually_nat_real: assumes "eventually P (at_top :: real filter)" shows "eventually (λx. P (real x)) (at_top :: nat filter)" using assms (*‹eventually P at_top›*) filterlim_real_sequentially (*‹filterlim real at_top sequentially›*) unfolding filterlim_def le_filter_def eventually_filtermap (*goal: ‹∀⇩F x in sequentially. P (real x)›*) by auto end
{ "path": "afp-2025-02-12/thys/Akra_Bazzi/Akra_Bazzi_Library.thy", "repo": "afp-2025-02-12", "sha": "863cf3bd6cdfd428cceac420bc492da1e6876cbab16e4f668ce954591491bb3e" }
(* * Copyright (C) 2014 NICTA * All rights reserved. *) (* Author: David Cock - David.Cock@nicta.com.au *) section "Structured Reasoning" theory StructuredReasoning imports Algebra begin text ‹By linking the algebraic, the syntactic, and the semantic views of computation, we derive a set of rules for decomposing expectation entailment proofs, firstly over the syntactic structure of a program, and secondly over the refinement relation. These rules also form the basis for automated reasoning.› subsection ‹Syntactic Decomposition› lemma wp_Abort: "(λs. 0) ⊩ wp Abort Q" unfolding wp_eval (*goal: ‹λs. 0 ⊩ λs. 0›*) by simp lemma wlp_Abort: "(λs. 1) ⊩ wlp Abort Q" unfolding wp_eval (*goal: ‹λs. 1 ⊩ λs. 1›*) by simp lemma wp_Skip: "P ⊩ wp Skip P" unfolding wp_eval (*goal: ‹P ⊩ P›*) by blast lemma wlp_Skip: "P ⊩ wlp Skip P" unfolding wp_eval (*goal: ‹P ⊩ P›*) by blast lemma wp_Apply: "Q o f ⊩ wp (Apply f) Q" unfolding wp_eval (*goal: ‹Q ∘ f ⊩ Q ∘ f›*) by simp lemma wlp_Apply: "Q o f ⊩ wlp (Apply f) Q" unfolding wp_eval (*goal: ‹Q ∘ f ⊩ Q ∘ f›*) by simp lemma wp_Seq: assumes ent_a: "P ⊩ wp a Q" and ent_b: "Q ⊩ wp b R" and wa: "well_def a" and wb: "well_def b" and s_Q: "sound Q" and s_R: "sound R" shows "P ⊩ wp (a ;; b) R" proof (-) (*goal: ‹P::'a::type ⇒ real ⊩ wp ((a::bool ⇒ ('a::type ⇒ real) ⇒ 'a::type ⇒ real) ;; (b::bool ⇒ ('a::type ⇒ real) ⇒ 'a::type ⇒ real)) (R::'a::type ⇒ real)›*) note ha = well_def_wp_healthy[OF wa] (*‹healthy (wp a)›*) note hb = well_def_wp_healthy[OF wb] (*‹healthy (wp b)›*) note ent_a (*‹P ⊩ wp a Q›*) also (*calculation: ‹P ⊩ wp a Q›*) from ent_b (*‹Q ⊩ wp b R›*) ha (*‹healthy (wp a)›*) hb (*‹healthy (wp (b::bool ⇒ ('a ⇒ real) ⇒ 'a ⇒ real))›*) s_Q (*‹sound Q›*) s_R (*‹sound R›*) have "wp a Q ⊩ wp a (wp b R)" by (blast intro:healthy_monoD2 (*‹⟦healthy ?t; sound ?P; sound ?Q; ?P ⊩ ?Q⟧ ⟹ ?t ?P ⊩ ?t ?Q›*)) finally (*calculation: ‹P ⊩ wp a (wp b R)›*) show "?thesis" (*goal: ‹P::'a ⇒ real ⊩ wp ((a::bool ⇒ ('a ⇒ real) ⇒ 'a ⇒ real) ;; (b::bool ⇒ ('a ⇒ real) ⇒ 'a ⇒ real)) (R::'a ⇒ real)›*) by (simp add:wp_eval (*‹wp Abort ?P = (λs. 0)› ‹wlp Abort ?P = (λs. 1)› ‹wp Skip ?P = ?P› ‹wlp Skip ?P = ?P› ‹wp (Apply ?f) ?P = ?P ∘ ?f› ‹wlp (Apply ?f) ?P = ?P ∘ ?f› ‹wp (?a ;; ?b) ?P = (wp ?a ∘ wp ?b) ?P› ‹wlp (?a ;; ?b) ?P = (wlp ?a ∘ wlp ?b) ?P› ‹wp (?a ⇘?Q⇙⊕ ?b) ?P = (λs. ?Q s * wp ?a ?P s + (1 - ?Q s) * wp ?b ?P s)› ‹wlp (?a ⇘?Q⇙⊕ ?b) ?P = (λs. ?Q s * wlp ?a ?P s + (1 - ?Q s) * wlp ?b ?P s)› ‹wp (?a ⨅ ?b) ?P = (λs. min (wp ?a ?P s) (wp ?b ?P s))› ‹wlp (?a ⨅ ?b) ?P = (λs. min (wlp ?a ?P s) (wlp ?b ?P s))› and more 12 facts*)) qed lemma wlp_Seq: assumes ent_a: "P ⊩ wlp a Q" and ent_b: "Q ⊩ wlp b R" and wa: "well_def a" and wb: "well_def b" and u_Q: "unitary Q" and u_R: "unitary R" shows "P ⊩ wlp (a ;; b) R" sorry lemma wp_PC: "(λs. P s * wp a Q s + (1 - P s) * wp b Q s) ⊩ wp (a ⇘P⇙⊕ b) Q" by (simp add:wp_eval (*‹wp Abort (?P::?'a ⇒ real) = (λs::?'a. 0::real)› ‹wlp Abort (?P::?'a ⇒ real) = (λs::?'a. 1::real)› ‹wp Skip (?P::?'a ⇒ real) = ?P› ‹wlp Skip (?P::?'a ⇒ real) = ?P› ‹wp (Apply (?f::?'a ⇒ ?'a)) (?P::?'a ⇒ real) = ?P ∘ ?f› ‹wlp (Apply (?f::?'a ⇒ ?'a)) (?P::?'a ⇒ real) = ?P ∘ ?f› ‹wp ((?a::bool ⇒ (?'a ⇒ real) ⇒ ?'a ⇒ real) ;; (?b::bool ⇒ (?'a ⇒ real) ⇒ ?'a ⇒ real)) (?P::?'a ⇒ real) = (wp ?a ∘ wp ?b) ?P› ‹wlp ((?a::bool ⇒ (?'a ⇒ real) ⇒ ?'a ⇒ real) ;; (?b::bool ⇒ (?'a ⇒ real) ⇒ ?'a ⇒ real)) (?P::?'a ⇒ real) = (wlp ?a ∘ wlp ?b) ?P› ‹wp ((?a::bool ⇒ (?'a ⇒ real) ⇒ ?'a ⇒ real) ⇘(?Q::?'a ⇒ real)⇙⊕ (?b::bool ⇒ (?'a ⇒ real) ⇒ ?'a ⇒ real)) (?P::?'a ⇒ real) = (λs::?'a. ?Q s * wp ?a ?P s + ((1::real) - ?Q s) * wp ?b ?P s)› ‹wlp ((?a::bool ⇒ (?'a ⇒ real) ⇒ ?'a ⇒ real) ⇘(?Q::?'a ⇒ real)⇙⊕ (?b::bool ⇒ (?'a ⇒ real) ⇒ ?'a ⇒ real)) (?P::?'a ⇒ real) = (λs::?'a. ?Q s * wlp ?a ?P s + ((1::real) - ?Q s) * wlp ?b ?P s)› ‹wp ((?a::bool ⇒ (?'a ⇒ real) ⇒ ?'a ⇒ real) ⨅ (?b::bool ⇒ (?'a ⇒ real) ⇒ ?'a ⇒ real)) (?P::?'a ⇒ real) = (λs::?'a. min (wp ?a ?P s) (wp ?b ?P s))› ‹wlp ((?a::bool ⇒ (?'a ⇒ real) ⇒ ?'a ⇒ real) ⨅ (?b::bool ⇒ (?'a ⇒ real) ⇒ ?'a ⇒ real)) (?P::?'a ⇒ real) = (λs::?'a. min (wlp ?a ?P s) (wlp ?b ?P s))› and more 12 facts*)) lemma wlp_PC: "(λs. P s * wlp a Q s + (1 - P s) * wlp b Q s) ⊩ wlp (a ⇘P⇙⊕ b) Q" by (simp add:wp_eval (*‹wp Abort ?P = (λs. 0)› ‹wlp Abort ?P = (λs. 1)› ‹wp Skip ?P = ?P› ‹wlp Skip ?P = ?P› ‹wp (Apply ?f) ?P = ?P ∘ ?f› ‹wlp (Apply ?f) ?P = ?P ∘ ?f› ‹wp (?a ;; ?b) ?P = (wp ?a ∘ wp ?b) ?P› ‹wlp (?a ;; ?b) ?P = (wlp ?a ∘ wlp ?b) ?P› ‹wp (?a ⇘?Q⇙⊕ ?b) ?P = (λs. ?Q s * wp ?a ?P s + (1 - ?Q s) * wp ?b ?P s)› ‹wlp (?a ⇘?Q⇙⊕ ?b) ?P = (λs. ?Q s * wlp ?a ?P s + (1 - ?Q s) * wlp ?b ?P s)› ‹wp (?a ⨅ ?b) ?P = (λs. min (wp ?a ?P s) (wp ?b ?P s))› ‹wlp (?a ⨅ ?b) ?P = (λs. min (wlp ?a ?P s) (wlp ?b ?P s))› and more 12 facts*)) text ‹A simpler rule for when the probability does not depend on the state.› lemma PC_fixed: assumes wpa: "P ⊩ a ab R" and wpb: "Q ⊩ b ab R" and np: "0 ≤ p" and bp: "p ≤ 1" shows "(λs. p * P s + (1 - p) * Q s) ⊩ (a ⇘(λs. p)⇙⊕ b) ab R" unfolding PC_def (*goal: ‹λs. p * P s + (1 - p) * Q s ⊩ λs. p * a ab R s + (1 - p) * b ab R s›*) proof (rule le_funI (*‹(⋀x. ?f x ≤ ?g x) ⟹ ?f ≤ ?g›*)) (*goal: ‹⋀x. p * P x + (1 - p) * Q x ≤ p * a ab R x + (1 - p) * b ab R x›*) fix s from wpa (*‹P ⊩ a ab R›*) np (*‹0 ≤ p›*) have "p * P s ≤ p * a ab R s" by (auto intro:mult_left_mono (*‹⟦?a ≤ ?b; 0 ≤ ?c⟧ ⟹ ?c * ?a ≤ ?c * ?b›*)) moreover { from bp (*‹p ≤ 1›*) have "0 ≤ 1 - p" by simp with wpb (*‹Q ⊩ b ab R›*) have "(1 - p) * Q s ≤ (1 - p) * b ab R s" by (auto intro:mult_left_mono (*‹⟦?a ≤ ?b; 0 ≤ ?c⟧ ⟹ ?c * ?a ≤ ?c * ?b›*)) } ultimately show "p * P s + (1 - p) * Q s ≤ p * a ab R s + (1 - p) * b ab R s" by (rule add_mono (*‹⟦?a ≤ ?b; ?c ≤ ?d⟧ ⟹ ?a + ?c ≤ ?b + ?d›*)) qed lemma wp_PC_fixed: "⟦ P ⊩ wp a R; Q ⊩ wp b R; 0 ≤ p; p ≤ 1 ⟧ ⟹ (λs. p * P s + (1 - p) * Q s) ⊩ wp (a ⇘(λs. p)⇙⊕ b) R" by (simp add:wp_def (*‹wp ?pr ≡ ?pr True›*) PC_fixed (*‹⟦?P ⊩ ?a ?ab ?R; ?Q ⊩ ?b ?ab ?R; 0 ≤ ?p; ?p ≤ 1⟧ ⟹ λs. ?p * ?P s + (1 - ?p) * ?Q s ⊩ (?a ⇘(λs. ?p)⇙⊕ ?b) ?ab ?R›*)) lemma wlp_PC_fixed: "⟦ P ⊩ wlp a R; Q ⊩ wlp b R; 0 ≤ p; p ≤ 1 ⟧ ⟹ (λs. p * P s + (1 - p) * Q s) ⊩ wlp (a ⇘(λs. p)⇙⊕ b) R" by (simp add:wlp_def (*‹wlp ?pr ≡ ?pr False›*) PC_fixed (*‹⟦?P ⊩ ?a ?ab ?R; ?Q ⊩ ?b ?ab ?R; 0 ≤ ?p; ?p ≤ 1⟧ ⟹ λs. ?p * ?P s + (1 - ?p) * ?Q s ⊩ (?a ⇘(λs. ?p)⇙⊕ ?b) ?ab ?R›*)) lemma wp_DC: "(λs. min (wp a Q s) (wp b Q s)) ⊩ wp (a ⨅ b) Q" unfolding wp_eval (*goal: ‹λs::'a. min (wp (a::bool ⇒ ('a ⇒ real) ⇒ 'a ⇒ real) (Q::'a ⇒ real) s) (wp (b::bool ⇒ ('a ⇒ real) ⇒ 'a ⇒ real) Q s) ⊩ λs::'a. min (wp a Q s) (wp b Q s)›*) by simp lemma wlp_DC: "(λs. min (wlp a Q s) (wlp b Q s)) ⊩ wlp (a ⨅ b) Q" unfolding wp_eval (*goal: ‹λs::'a::type. min (wlp (a::bool ⇒ ('a::type ⇒ real) ⇒ 'a::type ⇒ real) (Q::'a::type ⇒ real) s) (wlp (b::bool ⇒ ('a::type ⇒ real) ⇒ 'a::type ⇒ real) Q s) ⊩ λs::'a::type. min (wlp a Q s) (wlp b Q s)›*) by simp text ‹Combining annotations for both branches:› lemma DC_split: fixes a::"'s prog" and b assumes wpa: "P ⊩ a ab R" and wpb: "Q ⊩ b ab R" shows "(λs. min (P s) (Q s)) ⊩ (a ⨅ b) ab R" unfolding DC_def (*goal: ‹λs. min (P s) (Q s) ⊩ λs. min (a ab R s) (b ab R s)›*) proof (rule le_funI (*‹(⋀x. ?f x ≤ ?g x) ⟹ ?f ≤ ?g›*)) (*goal: ‹⋀x::'s. min ((P::'s ⇒ real) x) ((Q::'s ⇒ real) x) ≤ min ((a::bool ⇒ ('s ⇒ real) ⇒ 's ⇒ real) (ab::bool) (R::'s ⇒ real) x) ((b::bool ⇒ ('s ⇒ real) ⇒ 's ⇒ real) ab R x)›*) fix s from wpa (*‹P ⊩ a ab R›*) wpb (*‹Q ⊩ b ab R›*) have "P s ≤ a ab R s" and "Q s ≤ b ab R s" apply - (*goals: 1. ‹⟦P ⊩ a ab R; Q ⊩ b ab R⟧ ⟹ P s ≤ a ab R s› 2. ‹⟦P ⊩ a ab R; Q ⊩ b ab R⟧ ⟹ Q s ≤ b ab R s› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . thus "min (P s) (Q s) ≤ min (a ab R s) (b ab R s)" by auto qed lemma wp_DC_split: "⟦ P ⊩ wp prog R; Q ⊩ wp prog' R ⟧ ⟹ (λs. min (P s) (Q s)) ⊩ wp (prog ⨅ prog') R" by (simp add:wp_def (*‹wp ?pr ≡ ?pr True›*) DC_split (*‹⟦?P ⊩ ?a ?ab ?R; ?Q ⊩ ?b ?ab ?R⟧ ⟹ λs. min (?P s) (?Q s) ⊩ (?a ⨅ ?b) ?ab ?R›*)) lemma wlp_DC_split: "⟦ P ⊩ wlp prog R; Q ⊩ wlp prog' R ⟧ ⟹ (λs. min (P s) (Q s)) ⊩ wlp (prog ⨅ prog') R" by (simp add:wlp_def (*‹wlp ?pr ≡ ?pr False›*) DC_split (*‹⟦?P ⊩ ?a ?ab ?R; ?Q ⊩ ?b ?ab ?R⟧ ⟹ λs. min (?P s) (?Q s) ⊩ (?a ⨅ ?b) ?ab ?R›*)) lemma wp_DC_split_same: "⟦ P ⊩ wp prog Q; P ⊩ wp prog' Q ⟧ ⟹ P ⊩ wp (prog ⨅ prog') Q" unfolding wp_eval (*goal: ‹⟦P ⊩ wp prog Q; P ⊩ wp prog' Q⟧ ⟹ P ⊩ λs. min (wp prog Q s) (wp prog' Q s)›*) by (blast intro:min.boundedI (*‹⟦?a ≤ ?b; ?a ≤ ?c⟧ ⟹ ?a ≤ min ?b ?c›*)) lemma wlp_DC_split_same: "⟦ P ⊩ wlp prog Q; P ⊩ wlp prog' Q ⟧ ⟹ P ⊩ wlp (prog ⨅ prog') Q" unfolding wp_eval (*goal: ‹⟦P ⊩ wlp prog Q; P ⊩ wlp prog' Q⟧ ⟹ P ⊩ λs. min (wlp prog Q s) (wlp prog' Q s)›*) by (blast intro:min.boundedI (*‹⟦?a ≤ ?b; ?a ≤ ?c⟧ ⟹ ?a ≤ min ?b ?c›*)) lemma SetPC_split: fixes f::"'x ⇒ 'y prog" and p::"'y ⇒ 'x ⇒ real" assumes rec: "⋀x s. x ∈ supp (p s) ⟹ P x ⊩ f x ab Q" and nnp: "⋀s. nneg (p s)" shows "(λs. ∑x ∈ supp (p s). p s x * P x s) ⊩ SetPC f p ab Q" unfolding SetPC_def (*goal: ‹λs. ∑x∈supp (p s). p s x * P x s ⊩ λs. ∑a∈supp (p s). p s a * f a ab Q s›*) proof (rule le_funI (*‹(⋀x. ?f x ≤ ?g x) ⟹ ?f ≤ ?g›*)) (*goal: ‹⋀x. (∑xa∈supp (p x). p x xa * P xa x) ≤ (∑a∈supp (p x). p x a * f a ab Q x)›*) fix s from rec (*‹?x ∈ supp (p ?s) ⟹ P ?x ⊩ f ?x ab Q›*) have "⋀x. x ∈ supp (p s) ⟹ P x s ≤ f x ab Q s" by blast moreover from nnp (*‹nneg (p ?s)›*) have "⋀x. 0 ≤ p s x" by blast ultimately have "⋀x. x ∈ supp (p s) ⟹ p s x * P x s ≤ p s x * f x ab Q s" by (blast intro:mult_left_mono (*‹⟦?a ≤ ?b; 0 ≤ ?c⟧ ⟹ ?c * ?a ≤ ?c * ?b›*)) thus "(∑x ∈ supp (p s). p s x * P x s) ≤ (∑x ∈ supp (p s). p s x * f x ab Q s)" by (rule sum_mono (*‹(⋀i. i ∈ ?K ⟹ ?f i ≤ ?g i) ⟹ sum ?f ?K ≤ sum ?g ?K›*)) qed lemma wp_SetPC_split: "⟦ ⋀x s. x ∈ supp (p s) ⟹ P x ⊩ wp (f x) Q; ⋀s. nneg (p s) ⟧ ⟹ (λs. ∑x ∈ supp (p s). p s x * P x s) ⊩ wp (SetPC f p) Q" by (simp add:wp_def (*‹wp (?pr::bool ⇒ (?'s ⇒ real) ⇒ ?'s ⇒ real) ≡ ?pr True›*) SetPC_split (*‹⟦⋀(x::?'x) s::?'y. x ∈ supp ((?p::?'y ⇒ ?'x ⇒ real) s) ⟹ (?P::?'x ⇒ ?'y ⇒ real) x ⊩ (?f::?'x ⇒ bool ⇒ (?'y ⇒ real) ⇒ ?'y ⇒ real) x (?ab::bool) (?Q::?'y ⇒ real); ⋀s::?'y. nneg (?p s)⟧ ⟹ λs::?'y. ∑x::?'x∈supp (?p s). ?p s x * ?P x s ⊩ SetPC ?f ?p ?ab ?Q›*)) lemma wlp_SetPC_split: "⟦ ⋀x s. x ∈ supp (p s) ⟹ P x ⊩ wlp (f x) Q; ⋀s. nneg (p s) ⟧ ⟹ (λs. ∑x ∈ supp (p s). p s x * P x s) ⊩ wlp (SetPC f p) Q" by (simp add:wlp_def (*‹wlp (?pr::bool ⇒ (?'s::type ⇒ real) ⇒ ?'s::type ⇒ real) ≡ ?pr False›*) SetPC_split (*‹⟦⋀(x::?'x::type) s::?'y::type. x ∈ supp ((?p::?'y::type ⇒ ?'x::type ⇒ real) s) ⟹ (?P::?'x::type ⇒ ?'y::type ⇒ real) x ⊩ (?f::?'x::type ⇒ bool ⇒ (?'y::type ⇒ real) ⇒ ?'y::type ⇒ real) x (?ab::bool) (?Q::?'y::type ⇒ real); ⋀s::?'y::type. nneg (?p s)⟧ ⟹ λs::?'y::type. ∑x::?'x::type∈supp (?p s). ?p s x * ?P x s ⊩ SetPC ?f ?p ?ab ?Q›*)) lemma wp_SetDC_split: "⟦ ⋀s x. x ∈ S s ⟹ P ⊩ wp (f x) Q; ⋀s. S s ≠ {} ⟧ ⟹ P ⊩ wp (SetDC f S) Q" apply (rule le_funI (*‹(⋀x. ?f x ≤ ?g x) ⟹ ?f ≤ ?g›*)) (*goal: ‹⟦⋀s x. x ∈ S s ⟹ P ⊩ wp (f x) Q; ⋀s. S s ≠ {}⟧ ⟹ P ⊩ wp (SetDC f S) Q›*) apply (unfold wp_eval (*‹wp Abort ?P = (λs. 0)› ‹wlp Abort ?P = (λs. 1)› ‹wp Skip ?P = ?P› ‹wlp Skip ?P = ?P› ‹wp (Apply ?f) ?P = ?P ∘ ?f› ‹wlp (Apply ?f) ?P = ?P ∘ ?f› ‹wp (?a ;; ?b) ?P = (wp ?a ∘ wp ?b) ?P› ‹wlp (?a ;; ?b) ?P = (wlp ?a ∘ wlp ?b) ?P› ‹wp (?a ⇘?Q⇙⊕ ?b) ?P = (λs. ?Q s * wp ?a ?P s + (1 - ?Q s) * wp ?b ?P s)› ‹wlp (?a ⇘?Q⇙⊕ ?b) ?P = (λs. ?Q s * wlp ?a ?P s + (1 - ?Q s) * wlp ?b ?P s)› ‹wp (?a ⨅ ?b) ?P = (λs. min (wp ?a ?P s) (wp ?b ?P s))› ‹wlp (?a ⨅ ?b) ?P = (λs. min (wlp ?a ?P s) (wlp ?b ?P s))› and more 12 facts*)) (*goal: ‹⋀x. ⟦⋀s x. x ∈ S s ⟹ P ⊩ wp (f x) Q; ⋀s. S s ≠ {}⟧ ⟹ P x ≤ wp (SetDC f S) Q x›*) by (blast intro!:cInf_greatest (*‹⟦?X ≠ {}; ⋀x. x ∈ ?X ⟹ ?z ≤ x⟧ ⟹ ?z ≤ Inf ?X›*)) lemma wlp_SetDC_split: "⟦ ⋀s x. x ∈ S s ⟹ P ⊩ wlp (f x) Q; ⋀s. S s ≠ {} ⟧ ⟹ P ⊩ wlp (SetDC f S) Q" apply (rule le_funI (*‹(⋀x::?'a. (?f::?'a ⇒ ?'b) x ≤ (?g::?'a ⇒ ?'b) x) ⟹ ?f ≤ ?g›*)) (*goal: ‹⟦⋀s x. x ∈ S s ⟹ P ⊩ wlp (f x) Q; ⋀s. S s ≠ {}⟧ ⟹ P ⊩ wlp (SetDC f S) Q›*) apply (unfold wp_eval (*‹wp Abort ?P = (λs. 0)› ‹wlp Abort ?P = (λs. 1)› ‹wp Skip ?P = ?P› ‹wlp Skip ?P = ?P› ‹wp (Apply ?f) ?P = ?P ∘ ?f› ‹wlp (Apply ?f) ?P = ?P ∘ ?f› ‹wp (?a ;; ?b) ?P = (wp ?a ∘ wp ?b) ?P› ‹wlp (?a ;; ?b) ?P = (wlp ?a ∘ wlp ?b) ?P› ‹wp (?a ⇘?Q⇙⊕ ?b) ?P = (λs. ?Q s * wp ?a ?P s + (1 - ?Q s) * wp ?b ?P s)› ‹wlp (?a ⇘?Q⇙⊕ ?b) ?P = (λs. ?Q s * wlp ?a ?P s + (1 - ?Q s) * wlp ?b ?P s)› ‹wp (?a ⨅ ?b) ?P = (λs. min (wp ?a ?P s) (wp ?b ?P s))› ‹wlp (?a ⨅ ?b) ?P = (λs. min (wlp ?a ?P s) (wlp ?b ?P s))› and more 12 facts*)) (*goal: ‹⋀x. ⟦⋀s x. x ∈ S s ⟹ P ⊩ wlp (f x) Q; ⋀s. S s ≠ {}⟧ ⟹ P x ≤ wlp (SetDC f S) Q x›*) by (blast intro!:cInf_greatest (*‹⟦(?X::?'a set) ≠ {}; ⋀x::?'a. x ∈ ?X ⟹ (?z::?'a) ≤ x⟧ ⟹ ?z ≤ Inf ?X›*)) lemma wp_SetDC: assumes wp: "⋀s x. x ∈ S s ⟹ P x ⊩ wp (f x) Q" and ne: "⋀s. S s ≠ {}" and sP: "⋀x. sound (P x)" shows "(λs. Inf ((λx. P x s) ` S s)) ⊩ wp (SetDC f S) Q" using assms (*‹?x ∈ S ?s ⟹ P ?x ⊩ wp (f ?x) Q› ‹S ?s ≠ {}› ‹sound (P ?x)›*) apply (intro le_funI (*‹(⋀x. ?f x ≤ ?g x) ⟹ ?f ≤ ?g›*)) (*goal: ‹λs. INF x∈S s. P x s ⊩ wp (SetDC f S) Q›*) apply (simp add:wp_eval (*‹wp Abort ?P = (λs. 0)› ‹wlp Abort ?P = (λs. 1)› ‹wp Skip ?P = ?P› ‹wlp Skip ?P = ?P› ‹wp (Apply ?f) ?P = ?P ∘ ?f› ‹wlp (Apply ?f) ?P = ?P ∘ ?f› ‹wp (?a ;; ?b) ?P = (wp ?a ∘ wp ?b) ?P› ‹wlp (?a ;; ?b) ?P = (wlp ?a ∘ wlp ?b) ?P› ‹wp (?a ⇘?Q⇙⊕ ?b) ?P = (λs. ?Q s * wp ?a ?P s + (1 - ?Q s) * wp ?b ?P s)› ‹wlp (?a ⇘?Q⇙⊕ ?b) ?P = (λs. ?Q s * wlp ?a ?P s + (1 - ?Q s) * wlp ?b ?P s)› ‹wp (?a ⨅ ?b) ?P = (λs. min (wp ?a ?P s) (wp ?b ?P s))› ‹wlp (?a ⨅ ?b) ?P = (λs. min (wlp ?a ?P s) (wlp ?b ?P s))› and more 12 facts*)) (*goal: ‹⋀x. ⟦⋀x s. x ∈ S s ⟹ P x ⊩ wp (f x) Q; ⋀s. S s ≠ {}; ⋀x. sound (P x)⟧ ⟹ (INF xa∈S x. P xa x) ≤ wp (SetDC f S) Q x›*) by (blast intro!:cInf_mono (*‹⟦⋀b. b ∈ ?B ⟹ ∃a∈?A. a ≤ b; ⋀a. a ∈ ?A ⟹ ?c ≤ a; ?B ≠ {}⟧ ⟹ Inf ?A ≤ Inf ?B›*)) lemma wlp_SetDC: assumes wp: "⋀s x. x ∈ S s ⟹ P x ⊩ wlp (f x) Q" and ne: "⋀s. S s ≠ {}" and sP: "⋀x. sound (P x)" shows "(λs. Inf ((λx. P x s) ` S s)) ⊩ wlp (SetDC f S) Q" using assms (*‹?x ∈ S ?s ⟹ P ?x ⊩ wlp (f ?x) Q› ‹S ?s ≠ {}› ‹sound (P ?x)›*) apply (intro le_funI (*‹(⋀x. ?f x ≤ ?g x) ⟹ ?f ≤ ?g›*)) (*goal: ‹λs::'a. INF x::'b∈(S::'a ⇒ 'b set) s. (P::'b ⇒ 'a ⇒ real) x s ⊩ wlp (SetDC (f::'b ⇒ bool ⇒ ('a ⇒ real) ⇒ 'a ⇒ real) S) (Q::'a ⇒ real)›*) apply (simp add:wp_eval (*‹wp Abort (?P::?'a ⇒ real) = (λs::?'a. 0::real)› ‹wlp Abort (?P::?'a ⇒ real) = (λs::?'a. 1::real)› ‹wp Skip (?P::?'a ⇒ real) = ?P› ‹wlp Skip (?P::?'a ⇒ real) = ?P› ‹wp (Apply (?f::?'a ⇒ ?'a)) (?P::?'a ⇒ real) = ?P ∘ ?f› ‹wlp (Apply (?f::?'a ⇒ ?'a)) (?P::?'a ⇒ real) = ?P ∘ ?f› ‹wp ((?a::bool ⇒ (?'a ⇒ real) ⇒ ?'a ⇒ real) ;; (?b::bool ⇒ (?'a ⇒ real) ⇒ ?'a ⇒ real)) (?P::?'a ⇒ real) = (wp ?a ∘ wp ?b) ?P› ‹wlp ((?a::bool ⇒ (?'a ⇒ real) ⇒ ?'a ⇒ real) ;; (?b::bool ⇒ (?'a ⇒ real) ⇒ ?'a ⇒ real)) (?P::?'a ⇒ real) = (wlp ?a ∘ wlp ?b) ?P› ‹wp ((?a::bool ⇒ (?'a ⇒ real) ⇒ ?'a ⇒ real) ⇘(?Q::?'a ⇒ real)⇙⊕ (?b::bool ⇒ (?'a ⇒ real) ⇒ ?'a ⇒ real)) (?P::?'a ⇒ real) = (λs::?'a. ?Q s * wp ?a ?P s + ((1::real) - ?Q s) * wp ?b ?P s)› ‹wlp ((?a::bool ⇒ (?'a ⇒ real) ⇒ ?'a ⇒ real) ⇘(?Q::?'a ⇒ real)⇙⊕ (?b::bool ⇒ (?'a ⇒ real) ⇒ ?'a ⇒ real)) (?P::?'a ⇒ real) = (λs::?'a. ?Q s * wlp ?a ?P s + ((1::real) - ?Q s) * wlp ?b ?P s)› ‹wp ((?a::bool ⇒ (?'a ⇒ real) ⇒ ?'a ⇒ real) ⨅ (?b::bool ⇒ (?'a ⇒ real) ⇒ ?'a ⇒ real)) (?P::?'a ⇒ real) = (λs::?'a. min (wp ?a ?P s) (wp ?b ?P s))› ‹wlp ((?a::bool ⇒ (?'a ⇒ real) ⇒ ?'a ⇒ real) ⨅ (?b::bool ⇒ (?'a ⇒ real) ⇒ ?'a ⇒ real)) (?P::?'a ⇒ real) = (λs::?'a. min (wlp ?a ?P s) (wlp ?b ?P s))› and more 12 facts*)) (*goal: ‹⋀x. ⟦⋀x s. x ∈ S s ⟹ P x ⊩ wlp (f x) Q; ⋀s. S s ≠ {}; ⋀x. sound (P x)⟧ ⟹ (INF xa∈S x. P xa x) ≤ wlp (SetDC f S) Q x›*) by (blast intro!:cInf_mono (*‹⟦⋀b::?'a::conditionally_complete_lattice. b ∈ (?B::?'a::conditionally_complete_lattice set) ⟹ ∃a::?'a::conditionally_complete_lattice∈?A::?'a::conditionally_complete_lattice set. a ≤ b; ⋀a::?'a::conditionally_complete_lattice. a ∈ ?A ⟹ (?c::?'a::conditionally_complete_lattice) ≤ a; ?B ≠ {}⟧ ⟹ Inf ?A ≤ Inf ?B›*)) lemma wp_Embed: "P ⊩ t Q ⟹ P ⊩ wp (Embed t) Q" by (simp add:wp_def (*‹wp ?pr ≡ ?pr True›*) Embed_def (*‹Embed ?t = (λab. ?t)›*)) lemma wlp_Embed: "P ⊩ t Q ⟹ P ⊩ wlp (Embed t) Q" by (simp add:wlp_def (*‹wlp ?pr ≡ ?pr False›*) Embed_def (*‹Embed ?t = (λab. ?t)›*)) lemma wp_Bind: "⟦ ⋀s. P s ≤ wp (a (f s)) Q s ⟧ ⟹ P ⊩ wp (Bind f a) Q" by (auto simp:wp_def (*‹wp (?pr::bool ⇒ (?'s ⇒ real) ⇒ ?'s ⇒ real) ≡ ?pr True›*) Bind_def (*‹Bind (?g::?'s ⇒ ?'a) (?f::?'a ⇒ bool ⇒ (?'s ⇒ real) ⇒ ?'s ⇒ real) (?ab::bool) ≡ λ(P::?'s ⇒ real) s::?'s. let a::?'a = ?g s in ?f a ?ab P s›*)) lemma wlp_Bind: "⟦ ⋀s. P s ≤ wlp (a (f s)) Q s ⟧ ⟹ P ⊩ wlp (Bind f a) Q" by (auto simp:wlp_def (*‹wlp ?pr ≡ ?pr False›*) Bind_def (*‹Bind ?g ?f ?ab ≡ λP s. let a = ?g s in ?f a ?ab P s›*)) lemma wp_repeat: "⟦ P ⊩ wp a Q; Q ⊩ wp (repeat n a) R; well_def a; sound Q; sound R ⟧ ⟹ P ⊩ wp (repeat (Suc n) a) R" by (auto intro!:wp_Seq (*‹⟦?P::?'a ⇒ real ⊩ wp (?a::bool ⇒ (?'a ⇒ real) ⇒ ?'a ⇒ real) (?Q::?'a ⇒ real); ?Q ⊩ wp (?b::bool ⇒ (?'a ⇒ real) ⇒ ?'a ⇒ real) (?R::?'a ⇒ real); well_def ?a; well_def ?b; sound ?Q; sound ?R⟧ ⟹ ?P ⊩ wp (?a ;; ?b) ?R›*) wd_intros (*‹well_def Abort› ‹well_def Skip› ‹well_def (Apply (?f::?'a ⇒ ?'a))› ‹⟦healthy (?t::(?'s ⇒ real) ⇒ ?'s ⇒ real); sublinear ?t; bd_cts ?t⟧ ⟹ well_def (Embed ?t)› ‹⟦well_def (?a::bool ⇒ (?'a ⇒ real) ⇒ ?'a ⇒ real); well_def (?b::bool ⇒ (?'a ⇒ real) ⇒ ?'a ⇒ real)⟧ ⟹ well_def (?a ;; ?b)› ‹⟦well_def (?a::bool ⇒ (?'a ⇒ real) ⇒ ?'a ⇒ real); well_def (?b::bool ⇒ (?'a ⇒ real) ⇒ ?'a ⇒ real); unitary (?P::?'a ⇒ real)⟧ ⟹ well_def (?a ⇘?P⇙⊕ ?b)› ‹⟦well_def (?a::bool ⇒ (?'a ⇒ real) ⇒ ?'a ⇒ real); well_def (?b::bool ⇒ (?'a ⇒ real) ⇒ ?'a ⇒ real)⟧ ⟹ well_def (?a ⨅ ?b)› ‹⟦⋀(x::?'a) s::?'b. x ∈ supp ((?p::?'b ⇒ ?'a ⇒ real) s) ⟹ well_def ((?a::?'a ⇒ bool ⇒ (?'b ⇒ real) ⇒ ?'b ⇒ real) x); ⋀s::?'b. unitary (?p s); ⋀s::?'b. finite (supp (?p s)); ⋀s::?'b. sum (?p s) (supp (?p s)) ≤ (1::real)⟧ ⟹ well_def (SetPC ?a ?p)› ‹⟦⋀(x::?'a) s::?'b. x ∈ (?S::?'b ⇒ ?'a set) s ⟹ well_def ((?a::?'a ⇒ bool ⇒ (?'b ⇒ real) ⇒ ?'b ⇒ real) x); ⋀s::?'b. ?S s ≠ {}; ⋀s::?'b. finite (?S s)⟧ ⟹ well_def (SetDC ?a ?S)› ‹(⋀s::?'a. well_def ((?a::?'b ⇒ bool ⇒ (?'a ⇒ real) ⇒ ?'a ⇒ real) ((?f::?'a ⇒ ?'b) s))) ⟹ well_def (Bind ?f ?a)› ‹well_def (?a::bool ⇒ (?'a ⇒ real) ⇒ ?'a ⇒ real) ⟹ well_def (repeat (?n::nat) ?a)› ‹well_def (?body::bool ⇒ (?'a ⇒ real) ⇒ ?'a ⇒ real) ⟹ well_def (μx::bool ⇒ (?'a ⇒ real) ⇒ ?'a ⇒ real. ?body ;; x ⇘« ?G::?'a ⇒ bool »⇙⊕ Skip)›*)) lemma wlp_repeat: "⟦ P ⊩ wlp a Q; Q ⊩ wlp (repeat n a) R; well_def a; unitary Q; unitary R ⟧ ⟹ P ⊩ wlp (repeat (Suc n) a) R" by (auto intro!:wlp_Seq (*‹⟦?P ⊩ wlp ?a ?Q; ?Q ⊩ wlp ?b ?R; well_def ?a; well_def ?b; unitary ?Q; unitary ?R⟧ ⟹ ?P ⊩ wlp (?a ;; ?b) ?R›*) wd_intros (*‹well_def Abort› ‹well_def Skip› ‹well_def (Apply ?f)› ‹⟦healthy ?t; sublinear ?t; bd_cts ?t⟧ ⟹ well_def (Embed ?t)› ‹⟦well_def ?a; well_def ?b⟧ ⟹ well_def (?a ;; ?b)› ‹⟦well_def ?a; well_def ?b; unitary ?P⟧ ⟹ well_def (?a ⇘?P⇙⊕ ?b)› ‹⟦well_def ?a; well_def ?b⟧ ⟹ well_def (?a ⨅ ?b)› ‹⟦⋀x s. x ∈ supp (?p s) ⟹ well_def (?a x); ⋀s. unitary (?p s); ⋀s. finite (supp (?p s)); ⋀s. sum (?p s) (supp (?p s)) ≤ 1⟧ ⟹ well_def (SetPC ?a ?p)› ‹⟦⋀x s. x ∈ ?S s ⟹ well_def (?a x); ⋀s. ?S s ≠ {}; ⋀s. finite (?S s)⟧ ⟹ well_def (SetDC ?a ?S)› ‹(⋀s. well_def (?a (?f s))) ⟹ well_def (Bind ?f ?a)› ‹well_def ?a ⟹ well_def (repeat ?n ?a)› ‹well_def ?body ⟹ well_def (μx. ?body ;; x ⇘« ?G »⇙⊕ Skip)›*)) text ‹Note that the loop rules presented in section \autoref{s:loop_rules} are of the same form, and would belong here, had they not already been stated.› text ‹The following rules are specialisations of those for general transformers, and are easier for the unifier to match.› lemmas wp_strengthen_post= entails_strengthen_post[where t="wp a" for a] lemma wlp_strengthen_post: "P ⊩ wlp a Q ⟹ nearly_healthy (wlp a) ⟹ unitary R ⟹ Q ⊩ R ⟹ unitary Q ⟹ P ⊩ wlp a R" by (blast intro:entails_trans (*‹⟦?P ⊩ ?Q; ?Q ⊩ ?R⟧ ⟹ ?P ⊩ ?R›*)) lemmas wp_weaken_pre= entails_weaken_pre[where t="wp a" for a] lemmas wlp_weaken_pre= entails_weaken_pre[where t="wlp a" for a] lemmas wp_scale= entails_scale[where t="wp a" for a, OF _ well_def_wp_healthy] subsection ‹Algebraic Decomposition› text ‹Refinement is a powerful tool for decomposition, belied by the simplicity of the rule. This is an \emph{axiomatic} formulation of refinement (all annotations of the @{term a} are annotations of @{term b}), rather than an operational version (all traces of @{term b} are traces of @{term a}.› lemma wp_refines: "⟦ a ⊑ b; P ⊩ wp a Q; sound Q ⟧ ⟹ P ⊩ wp b Q" by (auto intro:entails_trans (*‹⟦?P ⊩ ?Q; ?Q ⊩ ?R⟧ ⟹ ?P ⊩ ?R›*)) lemmas wp_drefines = drefinesD subsection ‹Hoare triples› text ‹The Hoare triple, or validity predicate, is logically equivalent to the weakest-precondition entailment form. The benefit is that it allows us to define transitivity rules for computational (also/finally) reasoning.› definition wp_valid :: "('a ⇒ real) ⇒ 'a prog ⇒ ('a ⇒ real) ⇒ bool" ("⦃_⦄ _ ⦃_⦄p") where "wp_valid P prog Q ≡ P ⊩ wp prog Q" lemma wp_validI: "P ⊩ wp prog Q ⟹ ⦃P⦄ prog ⦃Q⦄p" unfolding wp_valid_def (*goal: ‹P ⊩ wp prog Q ⟹ P ⊩ wp prog Q›*) by assumption lemma wp_validD: "⦃P⦄ prog ⦃Q⦄p ⟹ P ⊩ wp prog Q" unfolding wp_valid_def (*goal: ‹P ⊩ wp prog Q ⟹ P ⊩ wp prog Q›*) by assumption lemma valid_Seq: "⟦ ⦃P⦄ a ⦃Q⦄p; ⦃Q⦄ b ⦃R⦄p; well_def a; well_def b; sound Q; sound R ⟧ ⟹ ⦃P⦄ a ;; b ⦃R⦄p" unfolding wp_valid_def (*goal: ‹⟦P::'a::type ⇒ real ⊩ wp (a::bool ⇒ ('a::type ⇒ real) ⇒ 'a::type ⇒ real) (Q::'a::type ⇒ real); Q ⊩ wp (b::bool ⇒ ('a::type ⇒ real) ⇒ 'a::type ⇒ real) (R::'a::type ⇒ real); well_def a; well_def b; sound Q; sound R⟧ ⟹ P ⊩ wp (a ;; b) R›*) apply (rule wp_Seq (*‹⟦?P ⊩ wp ?a ?Q; ?Q ⊩ wp ?b ?R; well_def ?a; well_def ?b; sound ?Q; sound ?R⟧ ⟹ ?P ⊩ wp (?a ;; ?b) ?R›*)) (*goals: 1. ‹⟦P ⊩ wp a Q; Q ⊩ wp b R; well_def a; well_def b; sound Q; sound R⟧ ⟹ P ⊩ wp a ?Q› 2. ‹⟦P ⊩ wp a Q; Q ⊩ wp b R; well_def a; well_def b; sound Q; sound R⟧ ⟹ ?Q ⊩ wp b R› 3. ‹⟦P ⊩ wp a Q; Q ⊩ wp b R; well_def a; well_def b; sound Q; sound R⟧ ⟹ well_def a› 4. ‹⟦P ⊩ wp a Q; Q ⊩ wp b R; well_def a; well_def b; sound Q; sound R⟧ ⟹ well_def b› 5. ‹⟦P ⊩ wp a Q; Q ⊩ wp b R; well_def a; well_def b; sound Q; sound R⟧ ⟹ sound ?Q› 6. ‹⟦P ⊩ wp a Q; Q ⊩ wp b R; well_def a; well_def b; sound Q; sound R⟧ ⟹ sound R› 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*) text ‹We make it available to the computational reasoner:› declare valid_Seq[trans] end
{ "path": "afp-2025-02-12/thys/pGCL/StructuredReasoning.thy", "repo": "afp-2025-02-12", "sha": "dc98056404baa5c7f6ddd31638757c2f1756fd5665fe76a29c9ce12b14d8e2b4" }
(***************************************************************************** * Featherweight-OCL --- A Formal Semantics for UML-OCL Version OCL 2.5 * for the OMG Standard. * http://www.brucker.ch/projects/hol-testgen/ * * UML_String.thy --- Library definitions. * This file is part of HOL-TestGen. * * Copyright (c) 2012-2015 Université Paris-Saclay, Univ. Paris-Sud, France * 2013-2015 IRT SystemX, France * * 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. * * * Neither the name of the copyright holders nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * 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 * OWNER 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. ******************************************************************************) theory UML_String imports "../UML_PropertyProfiles" begin section‹Basic Type String: Operations› subsection‹Fundamental Properties on Strings: Strict Equality \label{sec:string-strict-eq}› text‹The last basic operation belonging to the fundamental infrastructure of a value-type in OCL is the weak equality, which is defined similar to the @{typ "('𝔄)Boolean"}-case as strict extension of the strong equality:› overloading StrictRefEq ≡ "StrictRefEq :: [('𝔄)String,('𝔄)String] ⇒ ('𝔄)Boolean" begin definition StrictRefEq⇩S⇩t⇩r⇩i⇩n⇩g[code_unfold] : "(x::('𝔄)String) ≐ y ≡ λ τ. if (υ x) τ = true τ ∧ (υ y) τ = true τ then (x ≜ y) τ else invalid τ" end text‹Property proof in terms of @{term "profile_bin⇩S⇩t⇩r⇩o⇩n⇩g⇩E⇩q_⇩v_⇩v"}› interpretation StrictRefEq⇩S⇩t⇩r⇩i⇩n⇩g : profile_bin⇩S⇩t⇩r⇩o⇩n⇩g⇩E⇩q_⇩v_⇩v "λ x y. (x::('𝔄)String) ≐ y" apply unfold_locales (*goal: ‹profile_bin⇩S⇩t⇩r⇩o⇩n⇩g⇩E⇩q_⇩v_⇩v (≐)›*) by (auto simp: StrictRefEq⇩S⇩t⇩r⇩i⇩n⇩g (*‹?x ≐ ?y ≡ λτ. if (υ ?x) τ = true τ ∧ (υ ?y) τ = true τ then (?x ≜ ?y) τ else invalid τ›*)) subsection‹Basic String Constants› text‹Although the remaining part of this library reasons about integers abstractly, we provide here as example some convenient shortcuts.› definition OclStringa ::"('𝔄)String" ("𝖺") where "𝖺 = (λ _ . ⌊⌊''a''⌋⌋)" definition OclStringb ::"('𝔄)String" ("𝖻") where "𝖻 = (λ _ . ⌊⌊''b''⌋⌋)" definition OclStringc ::"('𝔄)String" ("𝖼") where "𝖼 = (λ _ . ⌊⌊''c''⌋⌋)" text‹Etc.› text_raw‹\isatagafp› subsection‹Validity and Definedness Properties› lemma "δ(null::('𝔄)String) = false" by simp lemma "υ(null::('𝔄)String) = true" by simp lemma [simp,code_unfold]: "δ (λ_. ⌊⌊n⌋⌋) = true" by (simp add:defined_def (*‹δ ?X ≡ λτ. if ?X τ = ⊥ τ ∨ ?X τ = null τ then false τ else true τ›*) true_def (*‹true ≡ λτ. ⌊⌊True⌋⌋›*) bot_fun_def (*‹⊥ ≡ λx. ⊥›*) bot_option_def (*‹⊥ ≡ ⊥›*) null_fun_def (*‹null ≡ λx. null›*) null_option_def (*‹null ≡ ⌊⊥⌋›*)) lemma [simp,code_unfold]: "υ (λ_. ⌊⌊n⌋⌋) = true" by (simp add:valid_def (*‹υ (?X::?'𝔄 state × ?'𝔄 state ⇒ ?'a) ≡ λτ::?'𝔄 state × ?'𝔄 state. if ?X τ = ⊥ τ then false τ else true τ›*) true_def (*‹true ≡ λτ::?'𝔄 state × ?'𝔄 state. ⌊⌊True⌋⌋›*) bot_fun_def (*‹⊥ ≡ λx::?'a. ⊥›*) bot_option_def (*‹⊥ ≡ ⊥›*)) (* ecclectic proofs to make examples executable *) lemma [simp,code_unfold]: "δ 𝖺 = true" by (simp add:OclStringa_def (*‹𝖺 = (λ_. ⌊⌊''a''⌋⌋)›*)) lemma [simp,code_unfold]: "υ 𝖺 = true" by (simp add:OclStringa_def (*‹𝖺 = (λ_. ⌊⌊''a''⌋⌋)›*)) text_raw‹\endisatagafp› subsection‹String Operations› subsubsection‹Definition› text‹Here is a common case of a built-in operation on built-in types. Note that the arguments must be both defined (non-null, non-bot).› text‹Note that we can not follow the lexis of the OCL Standard for Isabelle technical reasons; these operators are heavily overloaded in the HOL library that a further overloading would lead to heavy technical buzz in this document. › definition OclAdd⇩S⇩t⇩r⇩i⇩n⇩g ::"('𝔄)String ⇒ ('𝔄)String ⇒ ('𝔄)String" (infix "+⇩s⇩t⇩r⇩i⇩n⇩g" 40) where "x +⇩s⇩t⇩r⇩i⇩n⇩g y ≡ λ τ. if (δ x) τ = true τ ∧ (δ y) τ = true τ then ⌊⌊concat [⌈⌈x τ⌉⌉, ⌈⌈y τ⌉⌉]⌋⌋ else invalid τ " interpretation OclAdd⇩S⇩t⇩r⇩i⇩n⇩g : profile_bin⇩d_⇩d "(+⇩s⇩t⇩r⇩i⇩n⇩g)" "λ x y. ⌊⌊concat [⌈⌈x⌉⌉, ⌈⌈y⌉⌉]⌋⌋" apply unfold_locales (*goals: 1. ‹⋀X Y. bin (+⇩s⇩t⇩r⇩i⇩n⇩g) (λx y. ⌊⌊concat [⌈⌈x⌉⌉, ⌈⌈y⌉⌉]⌋⌋) defined defined X Y› 2. ‹⋀x y. ⟦x ≠ ⊥; x ≠ null; y ≠ ⊥; y ≠ null⟧ ⟹ ⌊⌊concat [⌈⌈x⌉⌉, ⌈⌈y⌉⌉]⌋⌋ ≠ ⊥ ∧ ⌊⌊concat [⌈⌈x⌉⌉, ⌈⌈y⌉⌉]⌋⌋ ≠ null› discuss goal 1*) apply ((auto simp:OclAdd⇩S⇩t⇩r⇩i⇩n⇩g_def (*‹?x +⇩s⇩t⇩r⇩i⇩n⇩g ?y ≡ λτ. if (δ ?x) τ = true τ ∧ (δ ?y) τ = true τ then ⌊⌊concat [⌈⌈?x τ⌉⌉, ⌈⌈?y τ⌉⌉]⌋⌋ else invalid τ›*) bot_option_def (*‹⊥ ≡ ⊥›*) null_option_def (*‹null ≡ ⌊⊥⌋›*))[1]) (*discuss goal 2*) apply ((auto simp:OclAdd⇩S⇩t⇩r⇩i⇩n⇩g_def (*‹?x +⇩s⇩t⇩r⇩i⇩n⇩g ?y ≡ λτ. if (δ ?x) τ = true τ ∧ (δ ?y) τ = true τ then ⌊⌊concat [⌈⌈?x τ⌉⌉, ⌈⌈?y τ⌉⌉]⌋⌋ else invalid τ›*) bot_option_def (*‹⊥ ≡ ⊥›*) null_option_def (*‹null ≡ ⌊⊥⌋›*))[1]) (*proven 2 subgoals*) . (* TODO : size(), concat, substring(s:string) toInteger, toReal, at(i:Integer), characters() etc. *) subsubsection‹Basic Properties› lemma OclAdd⇩S⇩t⇩r⇩i⇩n⇩g_not_commute: "∃X Y. (X +⇩s⇩t⇩r⇩i⇩n⇩g Y) ≠ (Y +⇩s⇩t⇩r⇩i⇩n⇩g X)" apply (rule_tac x = "λ_. ⌊⌊''b''⌋⌋" in exI (*‹?P ?x ⟹ ∃x. ?P x›*)) (*goal: ‹∃X Y. (X +⇩s⇩t⇩r⇩i⇩n⇩g Y) ≠ (Y +⇩s⇩t⇩r⇩i⇩n⇩g X)›*) apply (rule_tac x = "λ_. ⌊⌊''a''⌋⌋" in exI (*‹?P ?x ⟹ ∃x. ?P x›*)) (*goal: ‹∃Y. ((λ_. ⌊⌊''b''⌋⌋) +⇩s⇩t⇩r⇩i⇩n⇩g Y) ≠ (Y +⇩s⇩t⇩r⇩i⇩n⇩g (λ_. ⌊⌊''b''⌋⌋))›*) apply (simp add:OclAdd⇩S⇩t⇩r⇩i⇩n⇩g_def (*‹?x +⇩s⇩t⇩r⇩i⇩n⇩g ?y ≡ λτ. if (δ ?x) τ = true τ ∧ (δ ?y) τ = true τ then ⌊⌊concat [⌈⌈?x τ⌉⌉, ⌈⌈?y τ⌉⌉]⌋⌋ else invalid τ›*)) (*goal: ‹((λ_::'a state × 'a state. ⌊⌊''b''⌋⌋) +⇩s⇩t⇩r⇩i⇩n⇩g (λ_::'a state × 'a state. ⌊⌊''a''⌋⌋)) ≠ ((λ_::'a state × 'a state. ⌊⌊''a''⌋⌋) +⇩s⇩t⇩r⇩i⇩n⇩g (λ_::'a state × 'a state. ⌊⌊''b''⌋⌋))›*) apply auto (*goal: ‹(λτ. ⌊⌊''ba''⌋⌋) ≠ (λτ. ⌊⌊''ab''⌋⌋)›*) apply (drule fun_cong (*‹?f = ?g ⟹ ?f ?x = ?g ?x›*)) (*goal: ‹(λτ. ⌊⌊''ba''⌋⌋) = (λτ. ⌊⌊''ab''⌋⌋) ⟹ False›*) by auto subsection‹Test Statements› text‹Here follows a list of code-examples, that explain the meanings of the above definitions by compilation to code and execution to @{term "True"}.› (* Assert "τ ⊨ ( 𝟵 ≤⇩s⇩t⇩r⇩i⇩n⇩g 𝟭𝟬 )" Assert "τ ⊨ (( 𝟰 +⇩s⇩t⇩r⇩i⇩n⇩g 𝟰 ) ≤⇩s⇩t⇩r⇩i⇩n⇩g 𝟭𝟬 )" Assert "τ |≠ (( 𝟰 +⇩s⇩t⇩r⇩i⇩n⇩g ( 𝟰 +⇩s⇩t⇩r⇩i⇩n⇩g 𝟰 )) <⇩s⇩t⇩r⇩i⇩n⇩g 𝟭𝟬 )" Assert "τ ⊨ not (υ (null +⇩s⇩t⇩r⇩i⇩n⇩g 𝟭)) " *) text‹Here follows a list of code-examples, that explain the meanings of the above definitions by compilation to code and execution to @{term "True"}.› text‹Elementary computations on String› Assert "τ ⊨ 𝖺 <> 𝖻" Assert "τ ⊨ 𝖻 <> 𝖺" Assert "τ ⊨ 𝖻 ≐ 𝖻" Assert "τ ⊨ υ 𝖺" Assert "τ ⊨ δ 𝖺" Assert "τ ⊨ υ (null::('𝔄)String)" Assert "τ ⊨ (invalid ≜ invalid)" Assert "τ ⊨ (null ≜ null)" Assert "τ ⊨ (𝖺 ≜ 𝖺)" Assert "τ |≠ (𝖺 ≜ 𝖻)" Assert "τ |≠ (invalid ≜ 𝖻)" Assert "τ |≠ (null ≜ 𝖻)" Assert "τ |≠ (invalid ≐ (invalid::('𝔄)String))" (* Without typeconstraint not executable.*) Assert "τ |≠ υ (invalid ≐ (invalid::('𝔄)String))" (* Without typeconstraint not executable.*) Assert "τ |≠ (invalid <> (invalid::('𝔄)String))" (* Without typeconstraint not executable.*) Assert "τ |≠ υ (invalid <> (invalid::('𝔄)String))" (* Without typeconstraint not executable.*) Assert "τ ⊨ (null ≐ (null::('𝔄)String) )" (* Without typeconstraint not executable.*) Assert "τ ⊨ (null ≐ (null::('𝔄)String) )" (* Without typeconstraint not executable.*) Assert "τ ⊨ (𝖻 ≐ 𝖻)" Assert "τ |≠ (𝖻 <> 𝖻)" Assert "τ |≠ (𝖻 ≐ 𝖼)" Assert "τ ⊨ (𝖻 <> 𝖼)" (*Assert "τ |≠ (𝟬 <⇩s⇩t⇩r⇩i⇩n⇩g null)" Assert "τ |≠ (δ (𝟬 <⇩s⇩t⇩r⇩i⇩n⇩g null))" *) end
{ "path": "afp-2025-02-12/thys/Featherweight_OCL/basic_types/UML_String.thy", "repo": "afp-2025-02-12", "sha": "c3f9162bd478e65dfb9b7f9ec6157b17522b35e02e89745c8478faf6e9a94057" }
(* Title: Safe OCL Author: Denis Nikiforov, March 2019 Maintainer: Denis Nikiforov <denis.nikif at gmail.com> License: LGPL *) chapter ‹Normalization› theory OCL_Normalization imports OCL_Typing begin (*** Normalization Rules ****************************************************) section ‹Normalization Rules› text ‹ The following expression normalization rules includes two kinds of an abstract syntax tree transformations: \begin{itemize} \item determination of implicit types of variables, iterators, and tuple elements, \item unfolding of navigation shorthands and safe navigation operators, described in \autoref{tab:norm_rules}. \end{itemize} The following variables are used in the table: \begin{itemize} \item ▩‹x› is a non-nullable value, \item ▩‹n› is a nullable value, \item ▩‹xs› is a collection of non-nullable values, \item ▩‹ns› is a collection of nullable values. \end{itemize} \begin{table}[h!] \begin{center} \caption{Expression Normalization Rules} \label{tab:norm_rules} \begin{threeparttable} \begin{tabular}{c|c} \textbf{Orig. expr.} & \textbf{Normalized expression}\\ \hline ▩‹x.op()› & ▩‹x.op()›\\ ▩‹n.op()› & ▩‹n.op()›\tnote{*}\\ ▩‹x?.op()› & ---\\ ▩‹n?.op()› & ▩‹if n <> null then n.oclAsType(T[1]).op() else null endif›\tnote{**}\\ ▩‹x->op()› & ▩‹x.oclAsSet()->op()›\\ ▩‹n->op()› & ▩‹n.oclAsSet()->op()›\\ ▩‹x?->op()› & ---\\ ▩‹n?->op()› & ---\\ \hline ▩‹xs.op()› & ▩‹xs->collect(x | x.op())›\\ ▩‹ns.op()› & ▩‹ns->collect(n | n.op())›\tnote{*}\\ ▩‹xs?.op()› & ---\\ ▩‹ns?.op()› & ▩‹ns->selectByKind(T[1])->collect(x | x.op())›\\ ▩‹xs->op()› & ▩‹xs->op()›\\ ▩‹ns->op()› & ▩‹ns->op()›\\ ▩‹xs?->op()› & ---\\ ▩‹ns?->op()› & ▩‹ns->selectByKind(T[1])->op()›\\ \end{tabular} \begin{tablenotes} \item[*] The resulting expression will be ill-typed if the operation is unsafe. An unsafe operation is an operation which is well-typed for a non-nullable source only. \item[**] It would be a good idea to prohibit such a transformation for safe operations. A safe operation is an operation which is well-typed for a nullable source. However, it is hard to define safe operations formally considering operations overloading, complex relations between operation parameters types (please see the typing rules for the equality operator), and user-defined operations. \end{tablenotes} \end{threeparttable} \end{center} \end{table} Please take a note that name resolution of variables, types, attributes, and associations is out of scope of this section. It should be done on a previous phase during transformation of a concrete syntax tree to an abstract syntax tree.› fun string_of_nat :: "nat ⇒ string" where "string_of_nat n = (if n < 10 then [char_of (48 + n)] else string_of_nat (n div 10) @ [char_of (48 + (n mod 10))])" definition "new_vname ≡ String.implode ∘ string_of_nat ∘ fcard ∘ fmdom" inductive normalize :: "('a :: ocl_object_model) type env ⇒ 'a expr ⇒ 'a expr ⇒ bool" ("_ ⊢ _ ⇛/ _" [51,51,51] 50) and normalize_call ("_ ⊢⇩C _ ⇛/ _" [51,51,51] 50) and normalize_expr_list ("_ ⊢⇩L _ ⇛/ _" [51,51,51] 50) where LiteralN: "Γ ⊢ Literal a ⇛ Literal a" |ExplicitlyTypedLetN: "Γ ⊢ init₁ ⇛ init₂ ⟹ Γ(v ↦⇩f τ) ⊢ body₁ ⇛ body₂ ⟹ Γ ⊢ Let v (Some τ) init₁ body₁ ⇛ Let v (Some τ) init₂ body₂" |ImplicitlyTypedLetN: "Γ ⊢ init₁ ⇛ init₂ ⟹ Γ ⊢⇩E init₂ : τ ⟹ Γ(v ↦⇩f τ) ⊢ body₁ ⇛ body₂ ⟹ Γ ⊢ Let v None init₁ body₁ ⇛ Let v (Some τ) init₂ body₂" |VarN: "Γ ⊢ Var v ⇛ Var v" |IfN: "Γ ⊢ a₁ ⇛ a₂ ⟹ Γ ⊢ b₁ ⇛ b₂ ⟹ Γ ⊢ c₁ ⇛ c₂ ⟹ Γ ⊢ If a₁ b₁ c₁ ⇛ If a₂ b₂ c₂" |MetaOperationCallN: "Γ ⊢ MetaOperationCall τ op ⇛ MetaOperationCall τ op" |StaticOperationCallN: "Γ ⊢⇩L params₁ ⇛ params₂ ⟹ Γ ⊢ StaticOperationCall τ op params₁ ⇛ StaticOperationCall τ op params₂" |OclAnyDotCallN: "Γ ⊢ src₁ ⇛ src₂ ⟹ Γ ⊢⇩E src₂ : τ ⟹ τ ≤ OclAny[?] ∨ τ ≤ Tuple fmempty ⟹ (Γ, τ) ⊢⇩C call₁ ⇛ call₂ ⟹ Γ ⊢ Call src₁ DotCall call₁ ⇛ Call src₂ DotCall call₂" |OclAnySafeDotCallN: "Γ ⊢ src₁ ⇛ src₂ ⟹ Γ ⊢⇩E src₂ : τ ⟹ OclVoid[?] ≤ τ ⟹ (Γ, to_required_type τ) ⊢⇩C call₁ ⇛ call₂ ⟹ src₃ = TypeOperationCall src₂ DotCall OclAsTypeOp (to_required_type τ) ⟹ Γ ⊢ Call src₁ SafeDotCall call₁ ⇛ If (OperationCall src₂ DotCall NotEqualOp [NullLiteral]) (Call src₃ DotCall call₂) NullLiteral" |OclAnyArrowCallN: "Γ ⊢ src₁ ⇛ src₂ ⟹ Γ ⊢⇩E src₂ : τ ⟹ τ ≤ OclAny[?] ∨ τ ≤ Tuple fmempty ⟹ src₃ = OperationCall src₂ DotCall OclAsSetOp [] ⟹ Γ ⊢⇩E src₃ : σ ⟹ (Γ, σ) ⊢⇩C call₁ ⇛ call₂ ⟹ Γ ⊢ Call src₁ ArrowCall call₁ ⇛ Call src₃ ArrowCall call₂" |CollectionArrowCallN: "Γ ⊢ src₁ ⇛ src₂ ⟹ Γ ⊢⇩E src₂ : τ ⟹ element_type τ _ ⟹ (Γ, τ) ⊢⇩C call₁ ⇛ call₂ ⟹ Γ ⊢ Call src₁ ArrowCall call₁ ⇛ Call src₂ ArrowCall call₂" |CollectionSafeArrowCallN: "Γ ⊢ src₁ ⇛ src₂ ⟹ Γ ⊢⇩E src₂ : τ ⟹ element_type τ σ ⟹ OclVoid[?] ≤ σ ⟹ src₃ = TypeOperationCall src₂ ArrowCall SelectByKindOp (to_required_type σ) ⟹ Γ ⊢⇩E src₃ : ρ ⟹ (Γ, ρ) ⊢⇩C call₁ ⇛ call₂ ⟹ Γ ⊢ Call src₁ SafeArrowCall call₁ ⇛ Call src₃ ArrowCall call₂" |CollectionDotCallN: "Γ ⊢ src₁ ⇛ src₂ ⟹ Γ ⊢⇩E src₂ : τ ⟹ element_type τ σ ⟹ (Γ, σ) ⊢⇩C call₁ ⇛ call₂ ⟹ it = new_vname Γ ⟹ Γ ⊢ Call src₁ DotCall call₁ ⇛ CollectIteratorCall src₂ ArrowCall [it] (Some σ) (Call (Var it) DotCall call₂)" |CollectionSafeDotCallN: "Γ ⊢ src₁ ⇛ src₂ ⟹ Γ ⊢⇩E src₂ : τ ⟹ element_type τ σ ⟹ OclVoid[?] ≤ σ ⟹ ρ = to_required_type σ ⟹ src₃ = TypeOperationCall src₂ ArrowCall SelectByKindOp ρ ⟹ (Γ, ρ) ⊢⇩C call₁ ⇛ call₂ ⟹ it = new_vname Γ ⟹ Γ ⊢ Call src₁ SafeDotCall call₁ ⇛ CollectIteratorCall src₃ ArrowCall [it] (Some ρ) (Call (Var it) DotCall call₂)" |TypeOperationN: "(Γ, τ) ⊢⇩C TypeOperation op ty ⇛ TypeOperation op ty" |AttributeN: "(Γ, τ) ⊢⇩C Attribute attr ⇛ Attribute attr" |AssociationEndN: "(Γ, τ) ⊢⇩C AssociationEnd role from ⇛ AssociationEnd role from" |AssociationClassN: "(Γ, τ) ⊢⇩C AssociationClass 𝒜 from ⇛ AssociationClass 𝒜 from" |AssociationClassEndN: "(Γ, τ) ⊢⇩C AssociationClassEnd role ⇛ AssociationClassEnd role" |OperationN: "Γ ⊢⇩L params₁ ⇛ params₂ ⟹ (Γ, τ) ⊢⇩C Operation op params₁ ⇛ Operation op params₂" |TupleElementN: "(Γ, τ) ⊢⇩C TupleElement elem ⇛ TupleElement elem" |ExplicitlyTypedIterateN: "Γ ⊢ res_init₁ ⇛ res_init₂ ⟹ Γ ++⇩f fmap_of_list (map (λit. (it, σ)) its) ⊢ Let res res_t₁ res_init₁ body₁ ⇛ Let res res_t₂ res_init₂ body₂ ⟹ (Γ, τ) ⊢⇩C Iterate its (Some σ) res res_t₁ res_init₁ body₁ ⇛ Iterate its (Some σ) res res_t₂ res_init₂ body₂" |ImplicitlyTypedIterateN: "element_type τ σ ⟹ Γ ⊢ res_init₁ ⇛ res_init₂ ⟹ Γ ++⇩f fmap_of_list (map (λit. (it, σ)) its) ⊢ Let res res_t₁ res_init₁ body₁ ⇛ Let res res_t₂ res_init₂ body₂ ⟹ (Γ, τ) ⊢⇩C Iterate its None res res_t₁ res_init₁ body₁ ⇛ Iterate its (Some σ) res res_t₂ res_init₂ body₂" |ExplicitlyTypedIteratorN: "Γ ++⇩f fmap_of_list (map (λit. (it, σ)) its) ⊢ body₁ ⇛ body₂ ⟹ (Γ, τ) ⊢⇩C Iterator iter its (Some σ) body₁ ⇛ Iterator iter its (Some σ) body₂" |ImplicitlyTypedIteratorN: "element_type τ σ ⟹ Γ ++⇩f fmap_of_list (map (λit. (it, σ)) its) ⊢ body₁ ⇛ body₂ ⟹ (Γ, τ) ⊢⇩C Iterator iter its None body₁ ⇛ Iterator iter its (Some σ) body₂" |ExprListNilN: "Γ ⊢⇩L [] ⇛ []" |ExprListConsN: "Γ ⊢ x ⇛ y ⟹ Γ ⊢⇩L xs ⇛ ys ⟹ Γ ⊢⇩L x # xs ⇛ y # ys" (*** Elimination Rules ******************************************************) section ‹Elimination Rules› inductive_cases LiteralNE [elim]: "Γ ⊢ Literal a ⇛ b" inductive_cases LetNE [elim]: "Γ ⊢ Let v t init body ⇛ b" inductive_cases VarNE [elim]: "Γ ⊢ Var v ⇛ b" inductive_cases IfNE [elim]: "Γ ⊢ If a b c ⇛ d" inductive_cases MetaOperationCallNE [elim]: "Γ ⊢ MetaOperationCall τ op ⇛ b" inductive_cases StaticOperationCallNE [elim]: "Γ ⊢ StaticOperationCall τ op as ⇛ b" inductive_cases DotCallNE [elim]: "Γ ⊢ Call src DotCall call ⇛ b" inductive_cases SafeDotCallNE [elim]: "Γ ⊢ Call src SafeDotCall call ⇛ b" inductive_cases ArrowCallNE [elim]: "Γ ⊢ Call src ArrowCall call ⇛ b" inductive_cases SafeArrowCallNE [elim]: "Γ ⊢ Call src SafeArrowCall call ⇛ b" inductive_cases CallNE [elim]: "(Γ, τ) ⊢⇩C call ⇛ b" inductive_cases OperationCallNE [elim]: "(Γ, τ) ⊢⇩C Operation op as ⇛ call" inductive_cases IterateCallNE [elim]: "(Γ, τ) ⊢⇩C Iterate its its_ty res res_t res_init body ⇛ call" inductive_cases IteratorCallNE [elim]: "(Γ, τ) ⊢⇩C Iterator iter its its_ty body ⇛ call" inductive_cases ExprListNE [elim]: "Γ ⊢⇩L xs ⇛ ys" (*** Simplification Rules ***************************************************) section ‹Simplification Rules› inductive_simps normalize_alt_simps: "Γ ⊢ Literal a ⇛ b" "Γ ⊢ Let v t init body ⇛ b" "Γ ⊢ Var v ⇛ b" "Γ ⊢ If a b c ⇛ d" "Γ ⊢ MetaOperationCall τ op ⇛ b" "Γ ⊢ StaticOperationCall τ op as ⇛ b" "Γ ⊢ Call src DotCall call ⇛ b" "Γ ⊢ Call src SafeDotCall call ⇛ b" "Γ ⊢ Call src ArrowCall call ⇛ b" "Γ ⊢ Call src SafeArrowCall call ⇛ b" "(Γ, τ) ⊢⇩C call ⇛ b" "(Γ, τ) ⊢⇩C Operation op as ⇛ call" "(Γ, τ) ⊢⇩C Iterate its its_ty res res_t res_init body ⇛ call" "(Γ, τ) ⊢⇩C Iterator iter its its_ty body ⇛ call" "Γ ⊢⇩L [] ⇛ ys" "Γ ⊢⇩L x # xs ⇛ ys" (*** Determinism ************************************************************) section ‹Determinism› lemma any_has_not_element_type: "element_type τ σ ⟹ τ ≤ OclAny[?] ∨ τ ≤ Tuple fmempty ⟹ False" apply ((erule element_type.cases (*‹⟦element_type ?a1.0 ?a2.0; ⋀τ. ⟦?a1.0 = Collection τ; ?a2.0 = τ⟧ ⟹ ?P; ⋀τ. ⟦?a1.0 = Set τ; ?a2.0 = τ⟧ ⟹ ?P; ⋀τ. ⟦?a1.0 = OrderedSet τ; ?a2.0 = τ⟧ ⟹ ?P; ⋀τ. ⟦?a1.0 = Bag τ; ?a2.0 = τ⟧ ⟹ ?P; ⋀τ. ⟦?a1.0 = Sequence τ; ?a2.0 = τ⟧ ⟹ ?P⟧ ⟹ ?P›*))[1]) (*goals: 1. ‹⋀τ'. ⟦τ ≤ OclAny[?] ∨ τ ≤ Tuple fmempty; τ = Collection τ'; σ = τ'⟧ ⟹ False› 2. ‹⋀τ'. ⟦τ ≤ OclAny[?] ∨ τ ≤ Tuple fmempty; τ = Set τ'; σ = τ'⟧ ⟹ False› 3. ‹⋀τ'. ⟦τ ≤ OclAny[?] ∨ τ ≤ Tuple fmempty; τ = OrderedSet τ'; σ = τ'⟧ ⟹ False› 4. ‹⋀τ'. ⟦τ ≤ OclAny[?] ∨ τ ≤ Tuple fmempty; τ = Bag τ'; σ = τ'⟧ ⟹ False› 5. ‹⋀τ'. ⟦τ ≤ OclAny[?] ∨ τ ≤ Tuple fmempty; τ = Sequence τ'; σ = τ'⟧ ⟹ 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]) (*proven 5 subgoals*) . lemma any_has_not_element_type': "element_type τ σ ⟹ OclVoid[?] ≤ τ ⟹ False" apply ((erule element_type.cases (*‹⟦element_type ?a1.0 ?a2.0; ⋀τ. ⟦?a1.0 = Collection τ; ?a2.0 = τ⟧ ⟹ ?P; ⋀τ. ⟦?a1.0 = Set τ; ?a2.0 = τ⟧ ⟹ ?P; ⋀τ. ⟦?a1.0 = OrderedSet τ; ?a2.0 = τ⟧ ⟹ ?P; ⋀τ. ⟦?a1.0 = Bag τ; ?a2.0 = τ⟧ ⟹ ?P; ⋀τ. ⟦?a1.0 = Sequence τ; ?a2.0 = τ⟧ ⟹ ?P⟧ ⟹ ?P›*))[1]) (*goals: 1. ‹⋀τ'. ⟦OclVoid[?] ≤ τ; τ = Collection τ'; σ = τ'⟧ ⟹ False› 2. ‹⋀τ'. ⟦OclVoid[?] ≤ τ; τ = Set τ'; σ = τ'⟧ ⟹ False› 3. ‹⋀τ'. ⟦OclVoid[?] ≤ τ; τ = OrderedSet τ'; σ = τ'⟧ ⟹ False› 4. ‹⋀τ'. ⟦OclVoid[?] ≤ τ; τ = Bag τ'; σ = τ'⟧ ⟹ False› 5. ‹⋀τ'. ⟦OclVoid[?] ≤ τ; τ = Sequence τ'; σ = τ'⟧ ⟹ 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]) (*proven 5 subgoals*) . lemma normalize_det: "Γ ⊢ expr ⇛ expr₁ ⟹ Γ ⊢ expr ⇛ expr₂ ⟹ expr₁ = expr₂" and normalize_call_det: "Γ_τ ⊢⇩C call ⇛ call₁ ⟹ Γ_τ ⊢⇩C call ⇛ call₂ ⟹ call₁ = call₂" and normalize_expr_list_det: "Γ ⊢⇩L xs ⇛ ys ⟹ Γ ⊢⇩L xs ⇛ zs ⟹ ys = zs" for Γ :: "('a :: ocl_object_model) type env" and Γ_τ :: "('a :: ocl_object_model) type env × 'a type" proof (induct arbitrary: expr₂ and call₂ and zs rule: normalize_normalize_call_normalize_expr_list.inducts) (*goals: 1. ‹⋀(Γ::String.literal ⇀⇩f 'a::ocl_object_model OCL_Types.type) (a::'a::ocl_object_model literal_expr) expr₂::'a::ocl_object_model expr. Γ ⊢ Literal a ⇛ expr₂ ⟹ Literal a = expr₂› 2. ‹⋀(Γ::String.literal ⇀⇩f 'a::ocl_object_model OCL_Types.type) (init₁::'a::ocl_object_model expr) (init₂::'a::ocl_object_model expr) (v::String.literal) (τ::'a::ocl_object_model OCL_Types.type) (body₁::'a::ocl_object_model expr) (body₂::'a::ocl_object_model expr) expr₂::'a::ocl_object_model expr. ⟦Γ ⊢ init₁ ⇛ init₂; ⋀expr₂::'a::ocl_object_model expr. Γ ⊢ init₁ ⇛ expr₂ ⟹ init₂ = expr₂; Γ(v ↦⇩f τ) ⊢ body₁ ⇛ body₂; ⋀expr₂::'a::ocl_object_model expr. Γ(v ↦⇩f τ) ⊢ body₁ ⇛ expr₂ ⟹ body₂ = expr₂; Γ ⊢ expr.Let v (Some τ) init₁ body₁ ⇛ expr₂⟧ ⟹ expr.Let v (Some τ) init₂ body₂ = expr₂› 3. ‹⋀(Γ::String.literal ⇀⇩f 'a::ocl_object_model OCL_Types.type) (init₁::'a::ocl_object_model expr) (init₂::'a::ocl_object_model expr) (τ::'a::ocl_object_model OCL_Types.type) (v::String.literal) (body₁::'a::ocl_object_model expr) (body₂::'a::ocl_object_model expr) expr₂::'a::ocl_object_model expr. ⟦Γ ⊢ init₁ ⇛ init₂; ⋀expr₂::'a::ocl_object_model expr. Γ ⊢ init₁ ⇛ expr₂ ⟹ init₂ = expr₂; Γ ⊢⇩E init₂ : τ; Γ(v ↦⇩f τ) ⊢ body₁ ⇛ body₂; ⋀expr₂::'a::ocl_object_model expr. Γ(v ↦⇩f τ) ⊢ body₁ ⇛ expr₂ ⟹ body₂ = expr₂; Γ ⊢ expr.Let v None init₁ body₁ ⇛ expr₂⟧ ⟹ expr.Let v (Some τ) init₂ body₂ = expr₂› 4. ‹⋀(Γ::String.literal ⇀⇩f 'a::ocl_object_model OCL_Types.type) (v::String.literal) expr₂::'a::ocl_object_model expr. Γ ⊢ Var v ⇛ expr₂ ⟹ Var v = expr₂› 5. ‹⋀(Γ::String.literal ⇀⇩f 'a::ocl_object_model OCL_Types.type) (a₁::'a::ocl_object_model expr) (a₂::'a::ocl_object_model expr) (b₁::'a::ocl_object_model expr) (b₂::'a::ocl_object_model expr) (c₁::'a::ocl_object_model expr) (c₂::'a::ocl_object_model expr) expr₂::'a::ocl_object_model expr. ⟦Γ ⊢ a₁ ⇛ a₂; ⋀expr₂::'a::ocl_object_model expr. Γ ⊢ a₁ ⇛ expr₂ ⟹ a₂ = expr₂; Γ ⊢ b₁ ⇛ b₂; ⋀expr₂::'a::ocl_object_model expr. Γ ⊢ b₁ ⇛ expr₂ ⟹ b₂ = expr₂; Γ ⊢ c₁ ⇛ c₂; ⋀expr₂::'a::ocl_object_model expr. Γ ⊢ c₁ ⇛ expr₂ ⟹ c₂ = expr₂; Γ ⊢ expr.If a₁ b₁ c₁ ⇛ expr₂⟧ ⟹ expr.If a₂ b₂ c₂ = expr₂› 6. ‹⋀(Γ::String.literal ⇀⇩f 'a::ocl_object_model OCL_Types.type) (τ::'a::ocl_object_model OCL_Types.type) (op::metaop) expr₂::'a::ocl_object_model expr. Γ ⊢ MetaOperationCall τ op ⇛ expr₂ ⟹ MetaOperationCall τ op = expr₂› 7. ‹⋀(Γ::String.literal ⇀⇩f 'a::ocl_object_model OCL_Types.type) (params₁::'a::ocl_object_model expr list) (params₂::'a::ocl_object_model expr list) (τ::'a::ocl_object_model OCL_Types.type) (op::String.literal) expr₂::'a::ocl_object_model expr. ⟦Γ ⊢⇩L params₁ ⇛ params₂; ⋀zs::'a::ocl_object_model expr list. Γ ⊢⇩L params₁ ⇛ zs ⟹ params₂ = zs; Γ ⊢ StaticOperationCall τ op params₁ ⇛ expr₂⟧ ⟹ StaticOperationCall τ op params₂ = expr₂› 8. ‹⋀(Γ::String.literal ⇀⇩f 'a::ocl_object_model OCL_Types.type) (src₁::'a::ocl_object_model expr) (src₂::'a::ocl_object_model expr) (τ::'a::ocl_object_model OCL_Types.type) (call₁::'a::ocl_object_model call_expr) (call₂::'a::ocl_object_model call_expr) expr₂::'a::ocl_object_model expr. ⟦Γ ⊢ src₁ ⇛ src₂; ⋀expr₂::'a::ocl_object_model expr. Γ ⊢ src₁ ⇛ expr₂ ⟹ src₂ = expr₂; Γ ⊢⇩E src₂ : τ; τ ≤ OclAny[?] ∨ τ ≤ Tuple fmempty; (Γ, τ) ⊢⇩C call₁ ⇛ call₂; ⋀call₂'::'a::ocl_object_model call_expr. (Γ, τ) ⊢⇩C call₁ ⇛ call₂' ⟹ call₂ = call₂'; Γ ⊢ Call src₁ DotCall call₁ ⇛ expr₂⟧ ⟹ Call src₂ DotCall call₂ = expr₂› 9. ‹⋀(Γ::String.literal ⇀⇩f 'a::ocl_object_model OCL_Types.type) (src₁::'a::ocl_object_model expr) (src₂::'a::ocl_object_model expr) (τ::'a::ocl_object_model OCL_Types.type) (call₁::'a::ocl_object_model call_expr) (call₂::'a::ocl_object_model call_expr) (src₃::'a::ocl_object_model expr) expr₂::'a::ocl_object_model expr. ⟦Γ ⊢ src₁ ⇛ src₂; ⋀expr₂::'a::ocl_object_model expr. Γ ⊢ src₁ ⇛ expr₂ ⟹ src₂ = expr₂; Γ ⊢⇩E src₂ : τ; OclVoid[?] ≤ τ; (Γ, to_required_type τ) ⊢⇩C call₁ ⇛ call₂; ⋀call₂'::'a::ocl_object_model call_expr. (Γ, to_required_type τ) ⊢⇩C call₁ ⇛ call₂' ⟹ call₂ = call₂'; src₃ = TypeOperationCall src₂ DotCall OclAsTypeOp (to_required_type τ); Γ ⊢ Call src₁ SafeDotCall call₁ ⇛ expr₂⟧ ⟹ expr.If (OperationCall src₂ DotCall ((Inr ∘ Inl ∘ Inl) NotEqualOp) (map Literal [NullLiteral])) (Call src₃ DotCall call₂) (Literal NullLiteral) = expr₂› 10. ‹⋀(Γ::String.literal ⇀⇩f 'a::ocl_object_model OCL_Types.type) (src₁::'a::ocl_object_model expr) (src₂::'a::ocl_object_model expr) (τ::'a::ocl_object_model OCL_Types.type) (src₃::'a::ocl_object_model expr) (σ::'a::ocl_object_model OCL_Types.type) (call₁::'a::ocl_object_model call_expr) (call₂::'a::ocl_object_model call_expr) expr₂::'a::ocl_object_model expr. ⟦Γ ⊢ src₁ ⇛ src₂; ⋀expr₂::'a::ocl_object_model expr. Γ ⊢ src₁ ⇛ expr₂ ⟹ src₂ = expr₂; Γ ⊢⇩E src₂ : τ; τ ≤ OclAny[?] ∨ τ ≤ Tuple fmempty; src₃ = OperationCall src₂ DotCall ((Inl ∘ Inl) OclAsSetOp) []; Γ ⊢⇩E src₃ : σ; (Γ, σ) ⊢⇩C call₁ ⇛ call₂; ⋀call₂'::'a::ocl_object_model call_expr. (Γ, σ) ⊢⇩C call₁ ⇛ call₂' ⟹ call₂ = call₂'; Γ ⊢ Call src₁ ArrowCall call₁ ⇛ expr₂⟧ ⟹ Call src₃ ArrowCall call₂ = expr₂› 11. ‹⋀(Γ::String.literal ⇀⇩f 'a::ocl_object_model OCL_Types.type) (src₁::'a::ocl_object_model expr) (src₂::'a::ocl_object_model expr) (τ::'a::ocl_object_model OCL_Types.type) (uu_::'a::ocl_object_model OCL_Types.type) (call₁::'a::ocl_object_model call_expr) (call₂::'a::ocl_object_model call_expr) expr₂::'a::ocl_object_model expr. ⟦Γ ⊢ src₁ ⇛ src₂; ⋀expr₂::'a::ocl_object_model expr. Γ ⊢ src₁ ⇛ expr₂ ⟹ src₂ = expr₂; Γ ⊢⇩E src₂ : τ; element_type τ uu_; (Γ, τ) ⊢⇩C call₁ ⇛ call₂; ⋀call₂'::'a::ocl_object_model call_expr. (Γ, τ) ⊢⇩C call₁ ⇛ call₂' ⟹ call₂ = call₂'; Γ ⊢ Call src₁ ArrowCall call₁ ⇛ expr₂⟧ ⟹ Call src₂ ArrowCall call₂ = expr₂› 12. ‹⋀(Γ::String.literal ⇀⇩f 'a::ocl_object_model OCL_Types.type) (src₁::'a::ocl_object_model expr) (src₂::'a::ocl_object_model expr) (τ::'a::ocl_object_model OCL_Types.type) (σ::'a::ocl_object_model OCL_Types.type) (src₃::'a::ocl_object_model expr) (ρ::'a::ocl_object_model OCL_Types.type) (call₁::'a::ocl_object_model call_expr) (call₂::'a::ocl_object_model call_expr) expr₂::'a::ocl_object_model expr. ⟦Γ ⊢ src₁ ⇛ src₂; ⋀expr₂::'a::ocl_object_model expr. Γ ⊢ src₁ ⇛ expr₂ ⟹ src₂ = expr₂; Γ ⊢⇩E src₂ : τ; element_type τ σ; OclVoid[?] ≤ σ; src₃ = TypeOperationCall src₂ ArrowCall SelectByKindOp (to_required_type σ); Γ ⊢⇩E src₃ : ρ; (Γ, ρ) ⊢⇩C call₁ ⇛ call₂; ⋀call₂'::'a::ocl_object_model call_expr. (Γ, ρ) ⊢⇩C call₁ ⇛ call₂' ⟹ call₂ = call₂'; Γ ⊢ Call src₁ SafeArrowCall call₁ ⇛ expr₂⟧ ⟹ Call src₃ ArrowCall call₂ = expr₂› 13. ‹⋀(Γ::String.literal ⇀⇩f 'a::ocl_object_model OCL_Types.type) (src₁::'a::ocl_object_model expr) (src₂::'a::ocl_object_model expr) (τ::'a::ocl_object_model OCL_Types.type) (σ::'a::ocl_object_model OCL_Types.type) (call₁::'a::ocl_object_model call_expr) (call₂::'a::ocl_object_model call_expr) (it::String.literal) expr₂::'a::ocl_object_model expr. ⟦Γ ⊢ src₁ ⇛ src₂; ⋀expr₂::'a::ocl_object_model expr. Γ ⊢ src₁ ⇛ expr₂ ⟹ src₂ = expr₂; Γ ⊢⇩E src₂ : τ; element_type τ σ; (Γ, σ) ⊢⇩C call₁ ⇛ call₂; ⋀call₂'::'a::ocl_object_model call_expr. (Γ, σ) ⊢⇩C call₁ ⇛ call₂' ⟹ call₂ = call₂'; it = new_vname Γ; Γ ⊢ Call src₁ DotCall call₁ ⇛ expr₂⟧ ⟹ CollectIteratorCall src₂ ArrowCall [it] (Some σ) (Call (Var it) DotCall call₂) = expr₂› 14. ‹⋀(Γ::String.literal ⇀⇩f 'a::ocl_object_model OCL_Types.type) (src₁::'a::ocl_object_model expr) (src₂::'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) (src₃::'a::ocl_object_model expr) (call₁::'a::ocl_object_model call_expr) (call₂::'a::ocl_object_model call_expr) (it::String.literal) expr₂::'a::ocl_object_model expr. ⟦Γ ⊢ src₁ ⇛ src₂; ⋀expr₂::'a::ocl_object_model expr. Γ ⊢ src₁ ⇛ expr₂ ⟹ src₂ = expr₂; Γ ⊢⇩E src₂ : τ; element_type τ σ; OclVoid[?] ≤ σ; ρ = to_required_type σ; src₃ = TypeOperationCall src₂ ArrowCall SelectByKindOp ρ; (Γ, ρ) ⊢⇩C call₁ ⇛ call₂; ⋀call₂'::'a::ocl_object_model call_expr. (Γ, ρ) ⊢⇩C call₁ ⇛ call₂' ⟹ call₂ = call₂'; it = new_vname Γ; Γ ⊢ Call src₁ SafeDotCall call₁ ⇛ expr₂⟧ ⟹ CollectIteratorCall src₃ ArrowCall [it] (Some ρ) (Call (Var it) DotCall call₂) = expr₂› 15. ‹⋀(Γ::String.literal ⇀⇩f 'a::ocl_object_model OCL_Types.type) (τ::'a::ocl_object_model OCL_Types.type) (op::typeop) (ty::'a::ocl_object_model OCL_Types.type) call₂::'a::ocl_object_model call_expr. (Γ, τ) ⊢⇩C TypeOperation op ty ⇛ call₂ ⟹ TypeOperation op ty = call₂› 16. ‹⋀(Γ::String.literal ⇀⇩f 'a::ocl_object_model OCL_Types.type) (τ::'a::ocl_object_model OCL_Types.type) (attr::String.literal) call₂::'a::ocl_object_model call_expr. (Γ, τ) ⊢⇩C Attribute attr ⇛ call₂ ⟹ Attribute attr = call₂› 17. ‹⋀(Γ::String.literal ⇀⇩f 'a::ocl_object_model OCL_Types.type) (τ::'a::ocl_object_model OCL_Types.type) (role::String.literal option) (from::String.literal) call₂::'a::ocl_object_model call_expr. (Γ, τ) ⊢⇩C AssociationEnd role from ⇛ call₂ ⟹ AssociationEnd role from = call₂› 18. ‹⋀(Γ::String.literal ⇀⇩f 'a::ocl_object_model OCL_Types.type) (τ::'a::ocl_object_model OCL_Types.type) (𝒜::String.literal option) (from::'a::ocl_object_model) call₂::'a::ocl_object_model call_expr. (Γ, τ) ⊢⇩C AssociationClass 𝒜 from ⇛ call₂ ⟹ AssociationClass 𝒜 from = call₂› 19. ‹⋀(Γ::String.literal ⇀⇩f 'a::ocl_object_model OCL_Types.type) (τ::'a::ocl_object_model OCL_Types.type) (role::String.literal) call₂::'a::ocl_object_model call_expr. (Γ, τ) ⊢⇩C AssociationClassEnd role ⇛ call₂ ⟹ AssociationClassEnd role = call₂› 20. ‹⋀(Γ::String.literal ⇀⇩f 'a::ocl_object_model OCL_Types.type) (params₁::'a::ocl_object_model expr list) (params₂::'a::ocl_object_model expr list) (τ::'a::ocl_object_model OCL_Types.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) call₂::'a::ocl_object_model call_expr. ⟦Γ ⊢⇩L params₁ ⇛ params₂; ⋀zs::'a::ocl_object_model expr list. Γ ⊢⇩L params₁ ⇛ zs ⟹ params₂ = zs; (Γ, τ) ⊢⇩C Operation op params₁ ⇛ call₂⟧ ⟹ Operation op params₂ = call₂› 21. ‹⋀(Γ::String.literal ⇀⇩f 'a::ocl_object_model OCL_Types.type) (τ::'a::ocl_object_model OCL_Types.type) (elem::String.literal) call₂::'a::ocl_object_model call_expr. (Γ, τ) ⊢⇩C TupleElement elem ⇛ call₂ ⟹ TupleElement elem = call₂› 22. ‹⋀(Γ::String.literal ⇀⇩f 'a::ocl_object_model OCL_Types.type) (res_init₁::'a::ocl_object_model expr) (res_init₂::'a::ocl_object_model expr) (σ::'a::ocl_object_model OCL_Types.type) (its::String.literal list) (res::String.literal) (res_t₁::'a::ocl_object_model OCL_Types.type option) (body₁::'a::ocl_object_model expr) (res_t₂::'a::ocl_object_model OCL_Types.type option) (body₂::'a::ocl_object_model expr) (τ::'a::ocl_object_model OCL_Types.type) call₂::'a::ocl_object_model call_expr. ⟦Γ ⊢ res_init₁ ⇛ res_init₂; ⋀expr₂::'a::ocl_object_model expr. Γ ⊢ res_init₁ ⇛ expr₂ ⟹ res_init₂ = expr₂; Γ ++⇩f fmap_of_list (map (λit::String.literal. (it, σ)) its) ⊢ expr.Let res res_t₁ res_init₁ body₁ ⇛ expr.Let res res_t₂ res_init₂ body₂; ⋀expr₂::'a::ocl_object_model expr. Γ ++⇩f fmap_of_list (map (λit::String.literal. (it, σ)) its) ⊢ expr.Let res res_t₁ res_init₁ body₁ ⇛ expr₂ ⟹ expr.Let res res_t₂ res_init₂ body₂ = expr₂; (Γ, τ) ⊢⇩C Iterate its (Some σ) res res_t₁ res_init₁ body₁ ⇛ call₂⟧ ⟹ Iterate its (Some σ) res res_t₂ res_init₂ body₂ = call₂› 23. ‹⋀(τ::'a::ocl_object_model OCL_Types.type) (σ::'a::ocl_object_model OCL_Types.type) (Γ::String.literal ⇀⇩f 'a::ocl_object_model OCL_Types.type) (res_init₁::'a::ocl_object_model expr) (res_init₂::'a::ocl_object_model expr) (its::String.literal list) (res::String.literal) (res_t₁::'a::ocl_object_model OCL_Types.type option) (body₁::'a::ocl_object_model expr) (res_t₂::'a::ocl_object_model OCL_Types.type option) (body₂::'a::ocl_object_model expr) call₂::'a::ocl_object_model call_expr. ⟦element_type τ σ; Γ ⊢ res_init₁ ⇛ res_init₂; ⋀expr₂::'a::ocl_object_model expr. Γ ⊢ res_init₁ ⇛ expr₂ ⟹ res_init₂ = expr₂; Γ ++⇩f fmap_of_list (map (λit::String.literal. (it, σ)) its) ⊢ expr.Let res res_t₁ res_init₁ body₁ ⇛ expr.Let res res_t₂ res_init₂ body₂; ⋀expr₂::'a::ocl_object_model expr. Γ ++⇩f fmap_of_list (map (λit::String.literal. (it, σ)) its) ⊢ expr.Let res res_t₁ res_init₁ body₁ ⇛ expr₂ ⟹ expr.Let res res_t₂ res_init₂ body₂ = expr₂; (Γ, τ) ⊢⇩C Iterate its None res res_t₁ res_init₁ body₁ ⇛ call₂⟧ ⟹ Iterate its (Some σ) res res_t₂ res_init₂ body₂ = call₂› 24. ‹⋀(Γ::String.literal ⇀⇩f 'a::ocl_object_model OCL_Types.type) (σ::'a::ocl_object_model OCL_Types.type) (its::String.literal list) (body₁::'a::ocl_object_model expr) (body₂::'a::ocl_object_model expr) (τ::'a::ocl_object_model OCL_Types.type) (iter::iterator) call₂::'a::ocl_object_model call_expr. ⟦Γ ++⇩f fmap_of_list (map (λit::String.literal. (it, σ)) its) ⊢ body₁ ⇛ body₂; ⋀expr₂::'a::ocl_object_model expr. Γ ++⇩f fmap_of_list (map (λit::String.literal. (it, σ)) its) ⊢ body₁ ⇛ expr₂ ⟹ body₂ = expr₂; (Γ, τ) ⊢⇩C Iterator iter its (Some σ) body₁ ⇛ call₂⟧ ⟹ Iterator iter its (Some σ) body₂ = call₂› 25. ‹⋀(τ::'a::ocl_object_model OCL_Types.type) (σ::'a::ocl_object_model OCL_Types.type) (Γ::String.literal ⇀⇩f 'a::ocl_object_model OCL_Types.type) (its::String.literal list) (body₁::'a::ocl_object_model expr) (body₂::'a::ocl_object_model expr) (iter::iterator) call₂::'a::ocl_object_model call_expr. ⟦element_type τ σ; Γ ++⇩f fmap_of_list (map (λit::String.literal. (it, σ)) its) ⊢ body₁ ⇛ body₂; ⋀expr₂::'a::ocl_object_model expr. Γ ++⇩f fmap_of_list (map (λit::String.literal. (it, σ)) its) ⊢ body₁ ⇛ expr₂ ⟹ body₂ = expr₂; (Γ, τ) ⊢⇩C Iterator iter its None body₁ ⇛ call₂⟧ ⟹ Iterator iter its (Some σ) body₂ = call₂› 26. ‹⋀(Γ::String.literal ⇀⇩f 'a::ocl_object_model OCL_Types.type) zs::'a::ocl_object_model expr list. Γ ⊢⇩L [] ⇛ zs ⟹ [] = zs› 27. ‹⋀(Γ::String.literal ⇀⇩f 'a::ocl_object_model OCL_Types.type) (x::'a::ocl_object_model expr) (y::'a::ocl_object_model expr) (xs::'a::ocl_object_model expr list) (ys::'a::ocl_object_model expr list) zs::'a::ocl_object_model expr list. ⟦Γ ⊢ x ⇛ y; ⋀expr₂::'a::ocl_object_model expr. Γ ⊢ x ⇛ expr₂ ⟹ y = expr₂; Γ ⊢⇩L xs ⇛ ys; ⋀zs::'a::ocl_object_model expr list. Γ ⊢⇩L xs ⇛ zs ⟹ ys = zs; Γ ⊢⇩L x # xs ⇛ zs⟧ ⟹ y # ys = zs›*) case (LiteralN Γ a) (*‹Γ ⊢ Literal a ⇛ expr₂›*) thus "?case" (*goal: ‹Literal a = expr₂›*) by auto next (*goals: 1. ‹⋀Γ init₁ init₂ v τ body₁ body₂ expr₂. ⟦Γ ⊢ init₁ ⇛ init₂; ⋀expr₂. Γ ⊢ init₁ ⇛ expr₂ ⟹ init₂ = expr₂; Γ(v ↦⇩f τ) ⊢ body₁ ⇛ body₂; ⋀expr₂. Γ(v ↦⇩f τ) ⊢ body₁ ⇛ expr₂ ⟹ body₂ = expr₂; Γ ⊢ expr.Let v (Some τ) init₁ body₁ ⇛ expr₂⟧ ⟹ expr.Let v (Some τ) init₂ body₂ = expr₂› 2. ‹⋀Γ init₁ init₂ τ v body₁ body₂ expr₂. ⟦Γ ⊢ init₁ ⇛ init₂; ⋀expr₂. Γ ⊢ init₁ ⇛ expr₂ ⟹ init₂ = expr₂; Γ ⊢⇩E init₂ : τ; Γ(v ↦⇩f τ) ⊢ body₁ ⇛ body₂; ⋀expr₂. Γ(v ↦⇩f τ) ⊢ body₁ ⇛ expr₂ ⟹ body₂ = expr₂; Γ ⊢ expr.Let v None init₁ body₁ ⇛ expr₂⟧ ⟹ expr.Let v (Some τ) init₂ body₂ = expr₂› 3. ‹⋀Γ v expr₂. Γ ⊢ Var v ⇛ expr₂ ⟹ Var v = expr₂› 4. ‹⋀Γ a₁ a₂ b₁ b₂ c₁ c₂ expr₂. ⟦Γ ⊢ a₁ ⇛ a₂; ⋀expr₂. Γ ⊢ a₁ ⇛ expr₂ ⟹ a₂ = expr₂; Γ ⊢ b₁ ⇛ b₂; ⋀expr₂. Γ ⊢ b₁ ⇛ expr₂ ⟹ b₂ = expr₂; Γ ⊢ c₁ ⇛ c₂; ⋀expr₂. Γ ⊢ c₁ ⇛ expr₂ ⟹ c₂ = expr₂; Γ ⊢ expr.If a₁ b₁ c₁ ⇛ expr₂⟧ ⟹ expr.If a₂ b₂ c₂ = expr₂› 5. ‹⋀Γ τ op expr₂. Γ ⊢ MetaOperationCall τ op ⇛ expr₂ ⟹ MetaOperationCall τ op = expr₂› 6. ‹⋀Γ params₁ params₂ τ op expr₂. ⟦Γ ⊢⇩L params₁ ⇛ params₂; ⋀zs. Γ ⊢⇩L params₁ ⇛ zs ⟹ params₂ = zs; Γ ⊢ StaticOperationCall τ op params₁ ⇛ expr₂⟧ ⟹ StaticOperationCall τ op params₂ = expr₂› 7. ‹⋀Γ src₁ src₂ τ call₁ call₂ expr₂. ⟦Γ ⊢ src₁ ⇛ src₂; ⋀expr₂. Γ ⊢ src₁ ⇛ expr₂ ⟹ src₂ = expr₂; Γ ⊢⇩E src₂ : τ; τ ≤ OclAny[?] ∨ τ ≤ Tuple fmempty; (Γ, τ) ⊢⇩C call₁ ⇛ call₂; ⋀call₂'. (Γ, τ) ⊢⇩C call₁ ⇛ call₂' ⟹ call₂ = call₂'; Γ ⊢ Call src₁ DotCall call₁ ⇛ expr₂⟧ ⟹ Call src₂ DotCall call₂ = expr₂› 8. ‹⋀Γ src₁ src₂ τ call₁ call₂ src₃ expr₂. ⟦Γ ⊢ src₁ ⇛ src₂; ⋀expr₂. Γ ⊢ src₁ ⇛ expr₂ ⟹ src₂ = expr₂; Γ ⊢⇩E src₂ : τ; OclVoid[?] ≤ τ; (Γ, to_required_type τ) ⊢⇩C call₁ ⇛ call₂; ⋀call₂'. (Γ, to_required_type τ) ⊢⇩C call₁ ⇛ call₂' ⟹ call₂ = call₂'; src₃ = TypeOperationCall src₂ DotCall OclAsTypeOp (to_required_type τ); Γ ⊢ Call src₁ SafeDotCall call₁ ⇛ expr₂⟧ ⟹ expr.If (OperationCall src₂ DotCall ((Inr ∘ Inl ∘ Inl) NotEqualOp) (map Literal [NullLiteral])) (Call src₃ DotCall call₂) (Literal NullLiteral) = expr₂› 9. ‹⋀Γ src₁ src₂ τ src₃ σ call₁ call₂ expr₂. ⟦Γ ⊢ src₁ ⇛ src₂; ⋀expr₂. Γ ⊢ src₁ ⇛ expr₂ ⟹ src₂ = expr₂; Γ ⊢⇩E src₂ : τ; τ ≤ OclAny[?] ∨ τ ≤ Tuple fmempty; src₃ = OperationCall src₂ DotCall ((Inl ∘ Inl) OclAsSetOp) []; Γ ⊢⇩E src₃ : σ; (Γ, σ) ⊢⇩C call₁ ⇛ call₂; ⋀call₂'. (Γ, σ) ⊢⇩C call₁ ⇛ call₂' ⟹ call₂ = call₂'; Γ ⊢ Call src₁ ArrowCall call₁ ⇛ expr₂⟧ ⟹ Call src₃ ArrowCall call₂ = expr₂› 10. ‹⋀Γ src₁ src₂ τ uu_ call₁ call₂ expr₂. ⟦Γ ⊢ src₁ ⇛ src₂; ⋀expr₂. Γ ⊢ src₁ ⇛ expr₂ ⟹ src₂ = expr₂; Γ ⊢⇩E src₂ : τ; element_type τ uu_; (Γ, τ) ⊢⇩C call₁ ⇛ call₂; ⋀call₂'. (Γ, τ) ⊢⇩C call₁ ⇛ call₂' ⟹ call₂ = call₂'; Γ ⊢ Call src₁ ArrowCall call₁ ⇛ expr₂⟧ ⟹ Call src₂ ArrowCall call₂ = expr₂› 11. ‹⋀Γ src₁ src₂ τ σ src₃ ρ call₁ call₂ expr₂. ⟦Γ ⊢ src₁ ⇛ src₂; ⋀expr₂. Γ ⊢ src₁ ⇛ expr₂ ⟹ src₂ = expr₂; Γ ⊢⇩E src₂ : τ; element_type τ σ; OclVoid[?] ≤ σ; src₃ = TypeOperationCall src₂ ArrowCall SelectByKindOp (to_required_type σ); Γ ⊢⇩E src₃ : ρ; (Γ, ρ) ⊢⇩C call₁ ⇛ call₂; ⋀call₂'. (Γ, ρ) ⊢⇩C call₁ ⇛ call₂' ⟹ call₂ = call₂'; Γ ⊢ Call src₁ SafeArrowCall call₁ ⇛ expr₂⟧ ⟹ Call src₃ ArrowCall call₂ = expr₂› 12. ‹⋀Γ src₁ src₂ τ σ call₁ call₂ it expr₂. ⟦Γ ⊢ src₁ ⇛ src₂; ⋀expr₂. Γ ⊢ src₁ ⇛ expr₂ ⟹ src₂ = expr₂; Γ ⊢⇩E src₂ : τ; element_type τ σ; (Γ, σ) ⊢⇩C call₁ ⇛ call₂; ⋀call₂'. (Γ, σ) ⊢⇩C call₁ ⇛ call₂' ⟹ call₂ = call₂'; it = new_vname Γ; Γ ⊢ Call src₁ DotCall call₁ ⇛ expr₂⟧ ⟹ CollectIteratorCall src₂ ArrowCall [it] (Some σ) (Call (Var it) DotCall call₂) = expr₂› 13. ‹⋀Γ src₁ src₂ τ σ ρ src₃ call₁ call₂ it expr₂. ⟦Γ ⊢ src₁ ⇛ src₂; ⋀expr₂. Γ ⊢ src₁ ⇛ expr₂ ⟹ src₂ = expr₂; Γ ⊢⇩E src₂ : τ; element_type τ σ; OclVoid[?] ≤ σ; ρ = to_required_type σ; src₃ = TypeOperationCall src₂ ArrowCall SelectByKindOp ρ; (Γ, ρ) ⊢⇩C call₁ ⇛ call₂; ⋀call₂'. (Γ, ρ) ⊢⇩C call₁ ⇛ call₂' ⟹ call₂ = call₂'; it = new_vname Γ; Γ ⊢ Call src₁ SafeDotCall call₁ ⇛ expr₂⟧ ⟹ CollectIteratorCall src₃ ArrowCall [it] (Some ρ) (Call (Var it) DotCall call₂) = expr₂› 14. ‹⋀Γ τ op ty call₂. (Γ, τ) ⊢⇩C TypeOperation op ty ⇛ call₂ ⟹ TypeOperation op ty = call₂› 15. ‹⋀Γ τ attr call₂. (Γ, τ) ⊢⇩C Attribute attr ⇛ call₂ ⟹ Attribute attr = call₂› 16. ‹⋀Γ τ role from call₂. (Γ, τ) ⊢⇩C AssociationEnd role from ⇛ call₂ ⟹ AssociationEnd role from = call₂› 17. ‹⋀Γ τ 𝒜 from call₂. (Γ, τ) ⊢⇩C AssociationClass 𝒜 from ⇛ call₂ ⟹ AssociationClass 𝒜 from = call₂› 18. ‹⋀Γ τ role call₂. (Γ, τ) ⊢⇩C AssociationClassEnd role ⇛ call₂ ⟹ AssociationClassEnd role = call₂› 19. ‹⋀Γ params₁ params₂ τ op call₂. ⟦Γ ⊢⇩L params₁ ⇛ params₂; ⋀zs. Γ ⊢⇩L params₁ ⇛ zs ⟹ params₂ = zs; (Γ, τ) ⊢⇩C Operation op params₁ ⇛ call₂⟧ ⟹ Operation op params₂ = call₂› 20. ‹⋀Γ τ elem call₂. (Γ, τ) ⊢⇩C TupleElement elem ⇛ call₂ ⟹ TupleElement elem = call₂› 21. ‹⋀Γ res_init₁ res_init₂ σ its res res_t₁ body₁ res_t₂ body₂ τ call₂. ⟦Γ ⊢ res_init₁ ⇛ res_init₂; ⋀expr₂. Γ ⊢ res_init₁ ⇛ expr₂ ⟹ res_init₂ = expr₂; Γ ++⇩f fmap_of_list (map (λit. (it, σ)) its) ⊢ expr.Let res res_t₁ res_init₁ body₁ ⇛ expr.Let res res_t₂ res_init₂ body₂; ⋀expr₂. Γ ++⇩f fmap_of_list (map (λit. (it, σ)) its) ⊢ expr.Let res res_t₁ res_init₁ body₁ ⇛ expr₂ ⟹ expr.Let res res_t₂ res_init₂ body₂ = expr₂; (Γ, τ) ⊢⇩C Iterate its (Some σ) res res_t₁ res_init₁ body₁ ⇛ call₂⟧ ⟹ Iterate its (Some σ) res res_t₂ res_init₂ body₂ = call₂› 22. ‹⋀τ σ Γ res_init₁ res_init₂ its res res_t₁ body₁ res_t₂ body₂ call₂. ⟦element_type τ σ; Γ ⊢ res_init₁ ⇛ res_init₂; ⋀expr₂. Γ ⊢ res_init₁ ⇛ expr₂ ⟹ res_init₂ = expr₂; Γ ++⇩f fmap_of_list (map (λit. (it, σ)) its) ⊢ expr.Let res res_t₁ res_init₁ body₁ ⇛ expr.Let res res_t₂ res_init₂ body₂; ⋀expr₂. Γ ++⇩f fmap_of_list (map (λit. (it, σ)) its) ⊢ expr.Let res res_t₁ res_init₁ body₁ ⇛ expr₂ ⟹ expr.Let res res_t₂ res_init₂ body₂ = expr₂; (Γ, τ) ⊢⇩C Iterate its None res res_t₁ res_init₁ body₁ ⇛ call₂⟧ ⟹ Iterate its (Some σ) res res_t₂ res_init₂ body₂ = call₂› 23. ‹⋀Γ σ its body₁ body₂ τ iter call₂. ⟦Γ ++⇩f fmap_of_list (map (λit. (it, σ)) its) ⊢ body₁ ⇛ body₂; ⋀expr₂. Γ ++⇩f fmap_of_list (map (λit. (it, σ)) its) ⊢ body₁ ⇛ expr₂ ⟹ body₂ = expr₂; (Γ, τ) ⊢⇩C Iterator iter its (Some σ) body₁ ⇛ call₂⟧ ⟹ Iterator iter its (Some σ) body₂ = call₂› 24. ‹⋀τ σ Γ its body₁ body₂ iter call₂. ⟦element_type τ σ; Γ ++⇩f fmap_of_list (map (λit. (it, σ)) its) ⊢ body₁ ⇛ body₂; ⋀expr₂. Γ ++⇩f fmap_of_list (map (λit. (it, σ)) its) ⊢ body₁ ⇛ expr₂ ⟹ body₂ = expr₂; (Γ, τ) ⊢⇩C Iterator iter its None body₁ ⇛ call₂⟧ ⟹ Iterator iter its (Some σ) body₂ = call₂› 25. ‹⋀Γ zs. Γ ⊢⇩L [] ⇛ zs ⟹ [] = zs› 26. ‹⋀Γ x y xs ys zs. ⟦Γ ⊢ x ⇛ y; ⋀expr₂. Γ ⊢ x ⇛ expr₂ ⟹ y = expr₂; Γ ⊢⇩L xs ⇛ ys; ⋀zs. Γ ⊢⇩L xs ⇛ zs ⟹ ys = zs; Γ ⊢⇩L x # xs ⇛ zs⟧ ⟹ y # ys = zs›*) case (ExplicitlyTypedLetN Γ init₁ init₂ v τ body₁ body₂) (*‹(Γ::String.literal ⇀⇩f 'a::ocl_object_model OCL_Types.type) ⊢ (init₁::'a::ocl_object_model expr) ⇛ (init₂::'a::ocl_object_model expr)› ‹(Γ::String.literal ⇀⇩f 'a::ocl_object_model OCL_Types.type) ⊢ (init₁::'a::ocl_object_model expr) ⇛ (?expr₂::'a::ocl_object_model expr) ⟹ (init₂::'a::ocl_object_model expr) = ?expr₂› ‹(Γ::String.literal ⇀⇩f 'a OCL_Types.type)(v::String.literal ↦⇩f τ::'a OCL_Types.type) ⊢ (body₁::'a expr) ⇛ (body₂::'a expr)› ‹Γ(v ↦⇩f τ) ⊢ body₁ ⇛ ?expr₂ ⟹ body₂ = ?expr₂› ‹Γ ⊢ expr.Let v (Some τ) init₁ body₁ ⇛ expr₂›*) thus "?case" (*goal: ‹expr.Let (v::String.literal) (Some (τ::'a OCL_Types.type)) (init₂::'a expr) (body₂::'a expr) = (expr₂::'a expr)›*) by blast next (*goals: 1. ‹⋀Γ init₁ init₂ τ v body₁ body₂ expr₂. ⟦Γ ⊢ init₁ ⇛ init₂; ⋀expr₂. Γ ⊢ init₁ ⇛ expr₂ ⟹ init₂ = expr₂; Γ ⊢⇩E init₂ : τ; Γ(v ↦⇩f τ) ⊢ body₁ ⇛ body₂; ⋀expr₂. Γ(v ↦⇩f τ) ⊢ body₁ ⇛ expr₂ ⟹ body₂ = expr₂; Γ ⊢ expr.Let v None init₁ body₁ ⇛ expr₂⟧ ⟹ expr.Let v (Some τ) init₂ body₂ = expr₂› 2. ‹⋀Γ v expr₂. Γ ⊢ Var v ⇛ expr₂ ⟹ Var v = expr₂› 3. ‹⋀Γ a₁ a₂ b₁ b₂ c₁ c₂ expr₂. ⟦Γ ⊢ a₁ ⇛ a₂; ⋀expr₂. Γ ⊢ a₁ ⇛ expr₂ ⟹ a₂ = expr₂; Γ ⊢ b₁ ⇛ b₂; ⋀expr₂. Γ ⊢ b₁ ⇛ expr₂ ⟹ b₂ = expr₂; Γ ⊢ c₁ ⇛ c₂; ⋀expr₂. Γ ⊢ c₁ ⇛ expr₂ ⟹ c₂ = expr₂; Γ ⊢ expr.If a₁ b₁ c₁ ⇛ expr₂⟧ ⟹ expr.If a₂ b₂ c₂ = expr₂› 4. ‹⋀Γ τ op expr₂. Γ ⊢ MetaOperationCall τ op ⇛ expr₂ ⟹ MetaOperationCall τ op = expr₂› 5. ‹⋀Γ params₁ params₂ τ op expr₂. ⟦Γ ⊢⇩L params₁ ⇛ params₂; ⋀zs. Γ ⊢⇩L params₁ ⇛ zs ⟹ params₂ = zs; Γ ⊢ StaticOperationCall τ op params₁ ⇛ expr₂⟧ ⟹ StaticOperationCall τ op params₂ = expr₂› 6. ‹⋀Γ src₁ src₂ τ call₁ call₂ expr₂. ⟦Γ ⊢ src₁ ⇛ src₂; ⋀expr₂. Γ ⊢ src₁ ⇛ expr₂ ⟹ src₂ = expr₂; Γ ⊢⇩E src₂ : τ; τ ≤ OclAny[?] ∨ τ ≤ Tuple fmempty; (Γ, τ) ⊢⇩C call₁ ⇛ call₂; ⋀call₂'. (Γ, τ) ⊢⇩C call₁ ⇛ call₂' ⟹ call₂ = call₂'; Γ ⊢ Call src₁ DotCall call₁ ⇛ expr₂⟧ ⟹ Call src₂ DotCall call₂ = expr₂› 7. ‹⋀Γ src₁ src₂ τ call₁ call₂ src₃ expr₂. ⟦Γ ⊢ src₁ ⇛ src₂; ⋀expr₂. Γ ⊢ src₁ ⇛ expr₂ ⟹ src₂ = expr₂; Γ ⊢⇩E src₂ : τ; OclVoid[?] ≤ τ; (Γ, to_required_type τ) ⊢⇩C call₁ ⇛ call₂; ⋀call₂'. (Γ, to_required_type τ) ⊢⇩C call₁ ⇛ call₂' ⟹ call₂ = call₂'; src₃ = TypeOperationCall src₂ DotCall OclAsTypeOp (to_required_type τ); Γ ⊢ Call src₁ SafeDotCall call₁ ⇛ expr₂⟧ ⟹ expr.If (OperationCall src₂ DotCall ((Inr ∘ Inl ∘ Inl) NotEqualOp) (map Literal [NullLiteral])) (Call src₃ DotCall call₂) (Literal NullLiteral) = expr₂› 8. ‹⋀Γ src₁ src₂ τ src₃ σ call₁ call₂ expr₂. ⟦Γ ⊢ src₁ ⇛ src₂; ⋀expr₂. Γ ⊢ src₁ ⇛ expr₂ ⟹ src₂ = expr₂; Γ ⊢⇩E src₂ : τ; τ ≤ OclAny[?] ∨ τ ≤ Tuple fmempty; src₃ = OperationCall src₂ DotCall ((Inl ∘ Inl) OclAsSetOp) []; Γ ⊢⇩E src₃ : σ; (Γ, σ) ⊢⇩C call₁ ⇛ call₂; ⋀call₂'. (Γ, σ) ⊢⇩C call₁ ⇛ call₂' ⟹ call₂ = call₂'; Γ ⊢ Call src₁ ArrowCall call₁ ⇛ expr₂⟧ ⟹ Call src₃ ArrowCall call₂ = expr₂› 9. ‹⋀Γ src₁ src₂ τ uu_ call₁ call₂ expr₂. ⟦Γ ⊢ src₁ ⇛ src₂; ⋀expr₂. Γ ⊢ src₁ ⇛ expr₂ ⟹ src₂ = expr₂; Γ ⊢⇩E src₂ : τ; element_type τ uu_; (Γ, τ) ⊢⇩C call₁ ⇛ call₂; ⋀call₂'. (Γ, τ) ⊢⇩C call₁ ⇛ call₂' ⟹ call₂ = call₂'; Γ ⊢ Call src₁ ArrowCall call₁ ⇛ expr₂⟧ ⟹ Call src₂ ArrowCall call₂ = expr₂› 10. ‹⋀Γ src₁ src₂ τ σ src₃ ρ call₁ call₂ expr₂. ⟦Γ ⊢ src₁ ⇛ src₂; ⋀expr₂. Γ ⊢ src₁ ⇛ expr₂ ⟹ src₂ = expr₂; Γ ⊢⇩E src₂ : τ; element_type τ σ; OclVoid[?] ≤ σ; src₃ = TypeOperationCall src₂ ArrowCall SelectByKindOp (to_required_type σ); Γ ⊢⇩E src₃ : ρ; (Γ, ρ) ⊢⇩C call₁ ⇛ call₂; ⋀call₂'. (Γ, ρ) ⊢⇩C call₁ ⇛ call₂' ⟹ call₂ = call₂'; Γ ⊢ Call src₁ SafeArrowCall call₁ ⇛ expr₂⟧ ⟹ Call src₃ ArrowCall call₂ = expr₂› 11. ‹⋀Γ src₁ src₂ τ σ call₁ call₂ it expr₂. ⟦Γ ⊢ src₁ ⇛ src₂; ⋀expr₂. Γ ⊢ src₁ ⇛ expr₂ ⟹ src₂ = expr₂; Γ ⊢⇩E src₂ : τ; element_type τ σ; (Γ, σ) ⊢⇩C call₁ ⇛ call₂; ⋀call₂'. (Γ, σ) ⊢⇩C call₁ ⇛ call₂' ⟹ call₂ = call₂'; it = new_vname Γ; Γ ⊢ Call src₁ DotCall call₁ ⇛ expr₂⟧ ⟹ CollectIteratorCall src₂ ArrowCall [it] (Some σ) (Call (Var it) DotCall call₂) = expr₂› 12. ‹⋀Γ src₁ src₂ τ σ ρ src₃ call₁ call₂ it expr₂. ⟦Γ ⊢ src₁ ⇛ src₂; ⋀expr₂. Γ ⊢ src₁ ⇛ expr₂ ⟹ src₂ = expr₂; Γ ⊢⇩E src₂ : τ; element_type τ σ; OclVoid[?] ≤ σ; ρ = to_required_type σ; src₃ = TypeOperationCall src₂ ArrowCall SelectByKindOp ρ; (Γ, ρ) ⊢⇩C call₁ ⇛ call₂; ⋀call₂'. (Γ, ρ) ⊢⇩C call₁ ⇛ call₂' ⟹ call₂ = call₂'; it = new_vname Γ; Γ ⊢ Call src₁ SafeDotCall call₁ ⇛ expr₂⟧ ⟹ CollectIteratorCall src₃ ArrowCall [it] (Some ρ) (Call (Var it) DotCall call₂) = expr₂› 13. ‹⋀Γ τ op ty call₂. (Γ, τ) ⊢⇩C TypeOperation op ty ⇛ call₂ ⟹ TypeOperation op ty = call₂› 14. ‹⋀Γ τ attr call₂. (Γ, τ) ⊢⇩C Attribute attr ⇛ call₂ ⟹ Attribute attr = call₂› 15. ‹⋀Γ τ role from call₂. (Γ, τ) ⊢⇩C AssociationEnd role from ⇛ call₂ ⟹ AssociationEnd role from = call₂› 16. ‹⋀Γ τ 𝒜 from call₂. (Γ, τ) ⊢⇩C AssociationClass 𝒜 from ⇛ call₂ ⟹ AssociationClass 𝒜 from = call₂› 17. ‹⋀Γ τ role call₂. (Γ, τ) ⊢⇩C AssociationClassEnd role ⇛ call₂ ⟹ AssociationClassEnd role = call₂› 18. ‹⋀Γ params₁ params₂ τ op call₂. ⟦Γ ⊢⇩L params₁ ⇛ params₂; ⋀zs. Γ ⊢⇩L params₁ ⇛ zs ⟹ params₂ = zs; (Γ, τ) ⊢⇩C Operation op params₁ ⇛ call₂⟧ ⟹ Operation op params₂ = call₂› 19. ‹⋀Γ τ elem call₂. (Γ, τ) ⊢⇩C TupleElement elem ⇛ call₂ ⟹ TupleElement elem = call₂› 20. ‹⋀Γ res_init₁ res_init₂ σ its res res_t₁ body₁ res_t₂ body₂ τ call₂. ⟦Γ ⊢ res_init₁ ⇛ res_init₂; ⋀expr₂. Γ ⊢ res_init₁ ⇛ expr₂ ⟹ res_init₂ = expr₂; Γ ++⇩f fmap_of_list (map (λit. (it, σ)) its) ⊢ expr.Let res res_t₁ res_init₁ body₁ ⇛ expr.Let res res_t₂ res_init₂ body₂; ⋀expr₂. Γ ++⇩f fmap_of_list (map (λit. (it, σ)) its) ⊢ expr.Let res res_t₁ res_init₁ body₁ ⇛ expr₂ ⟹ expr.Let res res_t₂ res_init₂ body₂ = expr₂; (Γ, τ) ⊢⇩C Iterate its (Some σ) res res_t₁ res_init₁ body₁ ⇛ call₂⟧ ⟹ Iterate its (Some σ) res res_t₂ res_init₂ body₂ = call₂› 21. ‹⋀τ σ Γ res_init₁ res_init₂ its res res_t₁ body₁ res_t₂ body₂ call₂. ⟦element_type τ σ; Γ ⊢ res_init₁ ⇛ res_init₂; ⋀expr₂. Γ ⊢ res_init₁ ⇛ expr₂ ⟹ res_init₂ = expr₂; Γ ++⇩f fmap_of_list (map (λit. (it, σ)) its) ⊢ expr.Let res res_t₁ res_init₁ body₁ ⇛ expr.Let res res_t₂ res_init₂ body₂; ⋀expr₂. Γ ++⇩f fmap_of_list (map (λit. (it, σ)) its) ⊢ expr.Let res res_t₁ res_init₁ body₁ ⇛ expr₂ ⟹ expr.Let res res_t₂ res_init₂ body₂ = expr₂; (Γ, τ) ⊢⇩C Iterate its None res res_t₁ res_init₁ body₁ ⇛ call₂⟧ ⟹ Iterate its (Some σ) res res_t₂ res_init₂ body₂ = call₂› 22. ‹⋀Γ σ its body₁ body₂ τ iter call₂. ⟦Γ ++⇩f fmap_of_list (map (λit. (it, σ)) its) ⊢ body₁ ⇛ body₂; ⋀expr₂. Γ ++⇩f fmap_of_list (map (λit. (it, σ)) its) ⊢ body₁ ⇛ expr₂ ⟹ body₂ = expr₂; (Γ, τ) ⊢⇩C Iterator iter its (Some σ) body₁ ⇛ call₂⟧ ⟹ Iterator iter its (Some σ) body₂ = call₂› 23. ‹⋀τ σ Γ its body₁ body₂ iter call₂. ⟦element_type τ σ; Γ ++⇩f fmap_of_list (map (λit. (it, σ)) its) ⊢ body₁ ⇛ body₂; ⋀expr₂. Γ ++⇩f fmap_of_list (map (λit. (it, σ)) its) ⊢ body₁ ⇛ expr₂ ⟹ body₂ = expr₂; (Γ, τ) ⊢⇩C Iterator iter its None body₁ ⇛ call₂⟧ ⟹ Iterator iter its (Some σ) body₂ = call₂› 24. ‹⋀Γ zs. Γ ⊢⇩L [] ⇛ zs ⟹ [] = zs› 25. ‹⋀Γ x y xs ys zs. ⟦Γ ⊢ x ⇛ y; ⋀expr₂. Γ ⊢ x ⇛ expr₂ ⟹ y = expr₂; Γ ⊢⇩L xs ⇛ ys; ⋀zs. Γ ⊢⇩L xs ⇛ zs ⟹ ys = zs; Γ ⊢⇩L x # xs ⇛ zs⟧ ⟹ y # ys = zs›*) case (ImplicitlyTypedLetN Γ init₁ init₂ τ v body₁ body₂) (*‹(Γ::String.literal ⇀⇩f 'a OCL_Types.type) ⊢ (init₁::'a expr) ⇛ (init₂::'a expr)› ‹Γ ⊢ init₁ ⇛ ?expr₂ ⟹ init₂ = ?expr₂› ‹Γ ⊢⇩E init₂ : τ› ‹Γ(v ↦⇩f τ) ⊢ body₁ ⇛ body₂› ‹Γ(v ↦⇩f τ) ⊢ body₁ ⇛ ?expr₂ ⟹ body₂ = ?expr₂› ‹Γ ⊢ expr.Let v None init₁ body₁ ⇛ expr₂›*) thus "?case" (*goal: ‹expr.Let v (Some τ) init₂ body₂ = expr₂›*) by (metis (mono_tags, lifting) LetNE (*‹⟦?Γ ⊢ expr.Let ?v ?t ?init ?body ⇛ ?b; ⋀init₂ τ body₂. ⟦?t = Some τ; ?b = expr.Let ?v (Some τ) init₂ body₂; ?Γ ⊢ ?init ⇛ init₂; ?Γ(?v ↦⇩f τ) ⊢ ?body ⇛ body₂⟧ ⟹ ?P; ⋀init₂ τ body₂. ⟦?t = None; ?b = expr.Let ?v (Some τ) init₂ body₂; ?Γ ⊢ ?init ⇛ init₂; ?Γ ⊢⇩E init₂ : τ; ?Γ(?v ↦⇩f τ) ⊢ ?body ⇛ body₂⟧ ⟹ ?P⟧ ⟹ ?P›*) option.distinct( (*‹None ≠ Some ?x2.0›*) 1) typing_det (*‹⟦?Γ ⊢⇩E ?expr : ?τ; ?Γ ⊢⇩E ?expr : ?σ⟧ ⟹ ?τ = ?σ›*)) next (*goals: 1. ‹⋀Γ v expr₂. Γ ⊢ Var v ⇛ expr₂ ⟹ Var v = expr₂› 2. ‹⋀Γ a₁ a₂ b₁ b₂ c₁ c₂ expr₂. ⟦Γ ⊢ a₁ ⇛ a₂; ⋀expr₂. Γ ⊢ a₁ ⇛ expr₂ ⟹ a₂ = expr₂; Γ ⊢ b₁ ⇛ b₂; ⋀expr₂. Γ ⊢ b₁ ⇛ expr₂ ⟹ b₂ = expr₂; Γ ⊢ c₁ ⇛ c₂; ⋀expr₂. Γ ⊢ c₁ ⇛ expr₂ ⟹ c₂ = expr₂; Γ ⊢ expr.If a₁ b₁ c₁ ⇛ expr₂⟧ ⟹ expr.If a₂ b₂ c₂ = expr₂› 3. ‹⋀Γ τ op expr₂. Γ ⊢ MetaOperationCall τ op ⇛ expr₂ ⟹ MetaOperationCall τ op = expr₂› 4. ‹⋀Γ params₁ params₂ τ op expr₂. ⟦Γ ⊢⇩L params₁ ⇛ params₂; ⋀zs. Γ ⊢⇩L params₁ ⇛ zs ⟹ params₂ = zs; Γ ⊢ StaticOperationCall τ op params₁ ⇛ expr₂⟧ ⟹ StaticOperationCall τ op params₂ = expr₂› 5. ‹⋀Γ src₁ src₂ τ call₁ call₂ expr₂. ⟦Γ ⊢ src₁ ⇛ src₂; ⋀expr₂. Γ ⊢ src₁ ⇛ expr₂ ⟹ src₂ = expr₂; Γ ⊢⇩E src₂ : τ; τ ≤ OclAny[?] ∨ τ ≤ Tuple fmempty; (Γ, τ) ⊢⇩C call₁ ⇛ call₂; ⋀call₂'. (Γ, τ) ⊢⇩C call₁ ⇛ call₂' ⟹ call₂ = call₂'; Γ ⊢ Call src₁ DotCall call₁ ⇛ expr₂⟧ ⟹ Call src₂ DotCall call₂ = expr₂› 6. ‹⋀Γ src₁ src₂ τ call₁ call₂ src₃ expr₂. ⟦Γ ⊢ src₁ ⇛ src₂; ⋀expr₂. Γ ⊢ src₁ ⇛ expr₂ ⟹ src₂ = expr₂; Γ ⊢⇩E src₂ : τ; OclVoid[?] ≤ τ; (Γ, to_required_type τ) ⊢⇩C call₁ ⇛ call₂; ⋀call₂'. (Γ, to_required_type τ) ⊢⇩C call₁ ⇛ call₂' ⟹ call₂ = call₂'; src₃ = TypeOperationCall src₂ DotCall OclAsTypeOp (to_required_type τ); Γ ⊢ Call src₁ SafeDotCall call₁ ⇛ expr₂⟧ ⟹ expr.If (OperationCall src₂ DotCall ((Inr ∘ Inl ∘ Inl) NotEqualOp) (map Literal [NullLiteral])) (Call src₃ DotCall call₂) (Literal NullLiteral) = expr₂› 7. ‹⋀Γ src₁ src₂ τ src₃ σ call₁ call₂ expr₂. ⟦Γ ⊢ src₁ ⇛ src₂; ⋀expr₂. Γ ⊢ src₁ ⇛ expr₂ ⟹ src₂ = expr₂; Γ ⊢⇩E src₂ : τ; τ ≤ OclAny[?] ∨ τ ≤ Tuple fmempty; src₃ = OperationCall src₂ DotCall ((Inl ∘ Inl) OclAsSetOp) []; Γ ⊢⇩E src₃ : σ; (Γ, σ) ⊢⇩C call₁ ⇛ call₂; ⋀call₂'. (Γ, σ) ⊢⇩C call₁ ⇛ call₂' ⟹ call₂ = call₂'; Γ ⊢ Call src₁ ArrowCall call₁ ⇛ expr₂⟧ ⟹ Call src₃ ArrowCall call₂ = expr₂› 8. ‹⋀Γ src₁ src₂ τ uu_ call₁ call₂ expr₂. ⟦Γ ⊢ src₁ ⇛ src₂; ⋀expr₂. Γ ⊢ src₁ ⇛ expr₂ ⟹ src₂ = expr₂; Γ ⊢⇩E src₂ : τ; element_type τ uu_; (Γ, τ) ⊢⇩C call₁ ⇛ call₂; ⋀call₂'. (Γ, τ) ⊢⇩C call₁ ⇛ call₂' ⟹ call₂ = call₂'; Γ ⊢ Call src₁ ArrowCall call₁ ⇛ expr₂⟧ ⟹ Call src₂ ArrowCall call₂ = expr₂› 9. ‹⋀Γ src₁ src₂ τ σ src₃ ρ call₁ call₂ expr₂. ⟦Γ ⊢ src₁ ⇛ src₂; ⋀expr₂. Γ ⊢ src₁ ⇛ expr₂ ⟹ src₂ = expr₂; Γ ⊢⇩E src₂ : τ; element_type τ σ; OclVoid[?] ≤ σ; src₃ = TypeOperationCall src₂ ArrowCall SelectByKindOp (to_required_type σ); Γ ⊢⇩E src₃ : ρ; (Γ, ρ) ⊢⇩C call₁ ⇛ call₂; ⋀call₂'. (Γ, ρ) ⊢⇩C call₁ ⇛ call₂' ⟹ call₂ = call₂'; Γ ⊢ Call src₁ SafeArrowCall call₁ ⇛ expr₂⟧ ⟹ Call src₃ ArrowCall call₂ = expr₂› 10. ‹⋀Γ src₁ src₂ τ σ call₁ call₂ it expr₂. ⟦Γ ⊢ src₁ ⇛ src₂; ⋀expr₂. Γ ⊢ src₁ ⇛ expr₂ ⟹ src₂ = expr₂; Γ ⊢⇩E src₂ : τ; element_type τ σ; (Γ, σ) ⊢⇩C call₁ ⇛ call₂; ⋀call₂'. (Γ, σ) ⊢⇩C call₁ ⇛ call₂' ⟹ call₂ = call₂'; it = new_vname Γ; Γ ⊢ Call src₁ DotCall call₁ ⇛ expr₂⟧ ⟹ CollectIteratorCall src₂ ArrowCall [it] (Some σ) (Call (Var it) DotCall call₂) = expr₂› 11. ‹⋀Γ src₁ src₂ τ σ ρ src₃ call₁ call₂ it expr₂. ⟦Γ ⊢ src₁ ⇛ src₂; ⋀expr₂. Γ ⊢ src₁ ⇛ expr₂ ⟹ src₂ = expr₂; Γ ⊢⇩E src₂ : τ; element_type τ σ; OclVoid[?] ≤ σ; ρ = to_required_type σ; src₃ = TypeOperationCall src₂ ArrowCall SelectByKindOp ρ; (Γ, ρ) ⊢⇩C call₁ ⇛ call₂; ⋀call₂'. (Γ, ρ) ⊢⇩C call₁ ⇛ call₂' ⟹ call₂ = call₂'; it = new_vname Γ; Γ ⊢ Call src₁ SafeDotCall call₁ ⇛ expr₂⟧ ⟹ CollectIteratorCall src₃ ArrowCall [it] (Some ρ) (Call (Var it) DotCall call₂) = expr₂› 12. ‹⋀Γ τ op ty call₂. (Γ, τ) ⊢⇩C TypeOperation op ty ⇛ call₂ ⟹ TypeOperation op ty = call₂› 13. ‹⋀Γ τ attr call₂. (Γ, τ) ⊢⇩C Attribute attr ⇛ call₂ ⟹ Attribute attr = call₂› 14. ‹⋀Γ τ role from call₂. (Γ, τ) ⊢⇩C AssociationEnd role from ⇛ call₂ ⟹ AssociationEnd role from = call₂› 15. ‹⋀Γ τ 𝒜 from call₂. (Γ, τ) ⊢⇩C AssociationClass 𝒜 from ⇛ call₂ ⟹ AssociationClass 𝒜 from = call₂› 16. ‹⋀Γ τ role call₂. (Γ, τ) ⊢⇩C AssociationClassEnd role ⇛ call₂ ⟹ AssociationClassEnd role = call₂› 17. ‹⋀Γ params₁ params₂ τ op call₂. ⟦Γ ⊢⇩L params₁ ⇛ params₂; ⋀zs. Γ ⊢⇩L params₁ ⇛ zs ⟹ params₂ = zs; (Γ, τ) ⊢⇩C Operation op params₁ ⇛ call₂⟧ ⟹ Operation op params₂ = call₂› 18. ‹⋀Γ τ elem call₂. (Γ, τ) ⊢⇩C TupleElement elem ⇛ call₂ ⟹ TupleElement elem = call₂› 19. ‹⋀Γ res_init₁ res_init₂ σ its res res_t₁ body₁ res_t₂ body₂ τ call₂. ⟦Γ ⊢ res_init₁ ⇛ res_init₂; ⋀expr₂. Γ ⊢ res_init₁ ⇛ expr₂ ⟹ res_init₂ = expr₂; Γ ++⇩f fmap_of_list (map (λit. (it, σ)) its) ⊢ expr.Let res res_t₁ res_init₁ body₁ ⇛ expr.Let res res_t₂ res_init₂ body₂; ⋀expr₂. Γ ++⇩f fmap_of_list (map (λit. (it, σ)) its) ⊢ expr.Let res res_t₁ res_init₁ body₁ ⇛ expr₂ ⟹ expr.Let res res_t₂ res_init₂ body₂ = expr₂; (Γ, τ) ⊢⇩C Iterate its (Some σ) res res_t₁ res_init₁ body₁ ⇛ call₂⟧ ⟹ Iterate its (Some σ) res res_t₂ res_init₂ body₂ = call₂› 20. ‹⋀τ σ Γ res_init₁ res_init₂ its res res_t₁ body₁ res_t₂ body₂ call₂. ⟦element_type τ σ; Γ ⊢ res_init₁ ⇛ res_init₂; ⋀expr₂. Γ ⊢ res_init₁ ⇛ expr₂ ⟹ res_init₂ = expr₂; Γ ++⇩f fmap_of_list (map (λit. (it, σ)) its) ⊢ expr.Let res res_t₁ res_init₁ body₁ ⇛ expr.Let res res_t₂ res_init₂ body₂; ⋀expr₂. Γ ++⇩f fmap_of_list (map (λit. (it, σ)) its) ⊢ expr.Let res res_t₁ res_init₁ body₁ ⇛ expr₂ ⟹ expr.Let res res_t₂ res_init₂ body₂ = expr₂; (Γ, τ) ⊢⇩C Iterate its None res res_t₁ res_init₁ body₁ ⇛ call₂⟧ ⟹ Iterate its (Some σ) res res_t₂ res_init₂ body₂ = call₂› 21. ‹⋀Γ σ its body₁ body₂ τ iter call₂. ⟦Γ ++⇩f fmap_of_list (map (λit. (it, σ)) its) ⊢ body₁ ⇛ body₂; ⋀expr₂. Γ ++⇩f fmap_of_list (map (λit. (it, σ)) its) ⊢ body₁ ⇛ expr₂ ⟹ body₂ = expr₂; (Γ, τ) ⊢⇩C Iterator iter its (Some σ) body₁ ⇛ call₂⟧ ⟹ Iterator iter its (Some σ) body₂ = call₂› 22. ‹⋀τ σ Γ its body₁ body₂ iter call₂. ⟦element_type τ σ; Γ ++⇩f fmap_of_list (map (λit. (it, σ)) its) ⊢ body₁ ⇛ body₂; ⋀expr₂. Γ ++⇩f fmap_of_list (map (λit. (it, σ)) its) ⊢ body₁ ⇛ expr₂ ⟹ body₂ = expr₂; (Γ, τ) ⊢⇩C Iterator iter its None body₁ ⇛ call₂⟧ ⟹ Iterator iter its (Some σ) body₂ = call₂› 23. ‹⋀Γ zs. Γ ⊢⇩L [] ⇛ zs ⟹ [] = zs› 24. ‹⋀Γ x y xs ys zs. ⟦Γ ⊢ x ⇛ y; ⋀expr₂. Γ ⊢ x ⇛ expr₂ ⟹ y = expr₂; Γ ⊢⇩L xs ⇛ ys; ⋀zs. Γ ⊢⇩L xs ⇛ zs ⟹ ys = zs; Γ ⊢⇩L x # xs ⇛ zs⟧ ⟹ y # ys = zs›*) case (VarN Γ v) (*‹Γ ⊢ Var v ⇛ expr₂›*) thus "?case" (*goal: ‹Var v = expr₂›*) by auto next (*goals: 1. ‹⋀Γ a₁ a₂ b₁ b₂ c₁ c₂ expr₂. ⟦Γ ⊢ a₁ ⇛ a₂; ⋀expr₂. Γ ⊢ a₁ ⇛ expr₂ ⟹ a₂ = expr₂; Γ ⊢ b₁ ⇛ b₂; ⋀expr₂. Γ ⊢ b₁ ⇛ expr₂ ⟹ b₂ = expr₂; Γ ⊢ c₁ ⇛ c₂; ⋀expr₂. Γ ⊢ c₁ ⇛ expr₂ ⟹ c₂ = expr₂; Γ ⊢ expr.If a₁ b₁ c₁ ⇛ expr₂⟧ ⟹ expr.If a₂ b₂ c₂ = expr₂› 2. ‹⋀Γ τ op expr₂. Γ ⊢ MetaOperationCall τ op ⇛ expr₂ ⟹ MetaOperationCall τ op = expr₂› 3. ‹⋀Γ params₁ params₂ τ op expr₂. ⟦Γ ⊢⇩L params₁ ⇛ params₂; ⋀zs. Γ ⊢⇩L params₁ ⇛ zs ⟹ params₂ = zs; Γ ⊢ StaticOperationCall τ op params₁ ⇛ expr₂⟧ ⟹ StaticOperationCall τ op params₂ = expr₂› 4. ‹⋀Γ src₁ src₂ τ call₁ call₂ expr₂. ⟦Γ ⊢ src₁ ⇛ src₂; ⋀expr₂. Γ ⊢ src₁ ⇛ expr₂ ⟹ src₂ = expr₂; Γ ⊢⇩E src₂ : τ; τ ≤ OclAny[?] ∨ τ ≤ Tuple fmempty; (Γ, τ) ⊢⇩C call₁ ⇛ call₂; ⋀call₂'. (Γ, τ) ⊢⇩C call₁ ⇛ call₂' ⟹ call₂ = call₂'; Γ ⊢ Call src₁ DotCall call₁ ⇛ expr₂⟧ ⟹ Call src₂ DotCall call₂ = expr₂› 5. ‹⋀Γ src₁ src₂ τ call₁ call₂ src₃ expr₂. ⟦Γ ⊢ src₁ ⇛ src₂; ⋀expr₂. Γ ⊢ src₁ ⇛ expr₂ ⟹ src₂ = expr₂; Γ ⊢⇩E src₂ : τ; OclVoid[?] ≤ τ; (Γ, to_required_type τ) ⊢⇩C call₁ ⇛ call₂; ⋀call₂'. (Γ, to_required_type τ) ⊢⇩C call₁ ⇛ call₂' ⟹ call₂ = call₂'; src₃ = TypeOperationCall src₂ DotCall OclAsTypeOp (to_required_type τ); Γ ⊢ Call src₁ SafeDotCall call₁ ⇛ expr₂⟧ ⟹ expr.If (OperationCall src₂ DotCall ((Inr ∘ Inl ∘ Inl) NotEqualOp) (map Literal [NullLiteral])) (Call src₃ DotCall call₂) (Literal NullLiteral) = expr₂› 6. ‹⋀Γ src₁ src₂ τ src₃ σ call₁ call₂ expr₂. ⟦Γ ⊢ src₁ ⇛ src₂; ⋀expr₂. Γ ⊢ src₁ ⇛ expr₂ ⟹ src₂ = expr₂; Γ ⊢⇩E src₂ : τ; τ ≤ OclAny[?] ∨ τ ≤ Tuple fmempty; src₃ = OperationCall src₂ DotCall ((Inl ∘ Inl) OclAsSetOp) []; Γ ⊢⇩E src₃ : σ; (Γ, σ) ⊢⇩C call₁ ⇛ call₂; ⋀call₂'. (Γ, σ) ⊢⇩C call₁ ⇛ call₂' ⟹ call₂ = call₂'; Γ ⊢ Call src₁ ArrowCall call₁ ⇛ expr₂⟧ ⟹ Call src₃ ArrowCall call₂ = expr₂› 7. ‹⋀Γ src₁ src₂ τ uu_ call₁ call₂ expr₂. ⟦Γ ⊢ src₁ ⇛ src₂; ⋀expr₂. Γ ⊢ src₁ ⇛ expr₂ ⟹ src₂ = expr₂; Γ ⊢⇩E src₂ : τ; element_type τ uu_; (Γ, τ) ⊢⇩C call₁ ⇛ call₂; ⋀call₂'. (Γ, τ) ⊢⇩C call₁ ⇛ call₂' ⟹ call₂ = call₂'; Γ ⊢ Call src₁ ArrowCall call₁ ⇛ expr₂⟧ ⟹ Call src₂ ArrowCall call₂ = expr₂› 8. ‹⋀Γ src₁ src₂ τ σ src₃ ρ call₁ call₂ expr₂. ⟦Γ ⊢ src₁ ⇛ src₂; ⋀expr₂. Γ ⊢ src₁ ⇛ expr₂ ⟹ src₂ = expr₂; Γ ⊢⇩E src₂ : τ; element_type τ σ; OclVoid[?] ≤ σ; src₃ = TypeOperationCall src₂ ArrowCall SelectByKindOp (to_required_type σ); Γ ⊢⇩E src₃ : ρ; (Γ, ρ) ⊢⇩C call₁ ⇛ call₂; ⋀call₂'. (Γ, ρ) ⊢⇩C call₁ ⇛ call₂' ⟹ call₂ = call₂'; Γ ⊢ Call src₁ SafeArrowCall call₁ ⇛ expr₂⟧ ⟹ Call src₃ ArrowCall call₂ = expr₂› 9. ‹⋀Γ src₁ src₂ τ σ call₁ call₂ it expr₂. ⟦Γ ⊢ src₁ ⇛ src₂; ⋀expr₂. Γ ⊢ src₁ ⇛ expr₂ ⟹ src₂ = expr₂; Γ ⊢⇩E src₂ : τ; element_type τ σ; (Γ, σ) ⊢⇩C call₁ ⇛ call₂; ⋀call₂'. (Γ, σ) ⊢⇩C call₁ ⇛ call₂' ⟹ call₂ = call₂'; it = new_vname Γ; Γ ⊢ Call src₁ DotCall call₁ ⇛ expr₂⟧ ⟹ CollectIteratorCall src₂ ArrowCall [it] (Some σ) (Call (Var it) DotCall call₂) = expr₂› 10. ‹⋀Γ src₁ src₂ τ σ ρ src₃ call₁ call₂ it expr₂. ⟦Γ ⊢ src₁ ⇛ src₂; ⋀expr₂. Γ ⊢ src₁ ⇛ expr₂ ⟹ src₂ = expr₂; Γ ⊢⇩E src₂ : τ; element_type τ σ; OclVoid[?] ≤ σ; ρ = to_required_type σ; src₃ = TypeOperationCall src₂ ArrowCall SelectByKindOp ρ; (Γ, ρ) ⊢⇩C call₁ ⇛ call₂; ⋀call₂'. (Γ, ρ) ⊢⇩C call₁ ⇛ call₂' ⟹ call₂ = call₂'; it = new_vname Γ; Γ ⊢ Call src₁ SafeDotCall call₁ ⇛ expr₂⟧ ⟹ CollectIteratorCall src₃ ArrowCall [it] (Some ρ) (Call (Var it) DotCall call₂) = expr₂› 11. ‹⋀Γ τ op ty call₂. (Γ, τ) ⊢⇩C TypeOperation op ty ⇛ call₂ ⟹ TypeOperation op ty = call₂› 12. ‹⋀Γ τ attr call₂. (Γ, τ) ⊢⇩C Attribute attr ⇛ call₂ ⟹ Attribute attr = call₂› 13. ‹⋀Γ τ role from call₂. (Γ, τ) ⊢⇩C AssociationEnd role from ⇛ call₂ ⟹ AssociationEnd role from = call₂› 14. ‹⋀Γ τ 𝒜 from call₂. (Γ, τ) ⊢⇩C AssociationClass 𝒜 from ⇛ call₂ ⟹ AssociationClass 𝒜 from = call₂› 15. ‹⋀Γ τ role call₂. (Γ, τ) ⊢⇩C AssociationClassEnd role ⇛ call₂ ⟹ AssociationClassEnd role = call₂› 16. ‹⋀Γ params₁ params₂ τ op call₂. ⟦Γ ⊢⇩L params₁ ⇛ params₂; ⋀zs. Γ ⊢⇩L params₁ ⇛ zs ⟹ params₂ = zs; (Γ, τ) ⊢⇩C Operation op params₁ ⇛ call₂⟧ ⟹ Operation op params₂ = call₂› 17. ‹⋀Γ τ elem call₂. (Γ, τ) ⊢⇩C TupleElement elem ⇛ call₂ ⟹ TupleElement elem = call₂› 18. ‹⋀Γ res_init₁ res_init₂ σ its res res_t₁ body₁ res_t₂ body₂ τ call₂. ⟦Γ ⊢ res_init₁ ⇛ res_init₂; ⋀expr₂. Γ ⊢ res_init₁ ⇛ expr₂ ⟹ res_init₂ = expr₂; Γ ++⇩f fmap_of_list (map (λit. (it, σ)) its) ⊢ expr.Let res res_t₁ res_init₁ body₁ ⇛ expr.Let res res_t₂ res_init₂ body₂; ⋀expr₂. Γ ++⇩f fmap_of_list (map (λit. (it, σ)) its) ⊢ expr.Let res res_t₁ res_init₁ body₁ ⇛ expr₂ ⟹ expr.Let res res_t₂ res_init₂ body₂ = expr₂; (Γ, τ) ⊢⇩C Iterate its (Some σ) res res_t₁ res_init₁ body₁ ⇛ call₂⟧ ⟹ Iterate its (Some σ) res res_t₂ res_init₂ body₂ = call₂› 19. ‹⋀τ σ Γ res_init₁ res_init₂ its res res_t₁ body₁ res_t₂ body₂ call₂. ⟦element_type τ σ; Γ ⊢ res_init₁ ⇛ res_init₂; ⋀expr₂. Γ ⊢ res_init₁ ⇛ expr₂ ⟹ res_init₂ = expr₂; Γ ++⇩f fmap_of_list (map (λit. (it, σ)) its) ⊢ expr.Let res res_t₁ res_init₁ body₁ ⇛ expr.Let res res_t₂ res_init₂ body₂; ⋀expr₂. Γ ++⇩f fmap_of_list (map (λit. (it, σ)) its) ⊢ expr.Let res res_t₁ res_init₁ body₁ ⇛ expr₂ ⟹ expr.Let res res_t₂ res_init₂ body₂ = expr₂; (Γ, τ) ⊢⇩C Iterate its None res res_t₁ res_init₁ body₁ ⇛ call₂⟧ ⟹ Iterate its (Some σ) res res_t₂ res_init₂ body₂ = call₂› 20. ‹⋀Γ σ its body₁ body₂ τ iter call₂. ⟦Γ ++⇩f fmap_of_list (map (λit. (it, σ)) its) ⊢ body₁ ⇛ body₂; ⋀expr₂. Γ ++⇩f fmap_of_list (map (λit. (it, σ)) its) ⊢ body₁ ⇛ expr₂ ⟹ body₂ = expr₂; (Γ, τ) ⊢⇩C Iterator iter its (Some σ) body₁ ⇛ call₂⟧ ⟹ Iterator iter its (Some σ) body₂ = call₂› 21. ‹⋀τ σ Γ its body₁ body₂ iter call₂. ⟦element_type τ σ; Γ ++⇩f fmap_of_list (map (λit. (it, σ)) its) ⊢ body₁ ⇛ body₂; ⋀expr₂. Γ ++⇩f fmap_of_list (map (λit. (it, σ)) its) ⊢ body₁ ⇛ expr₂ ⟹ body₂ = expr₂; (Γ, τ) ⊢⇩C Iterator iter its None body₁ ⇛ call₂⟧ ⟹ Iterator iter its (Some σ) body₂ = call₂› 22. ‹⋀Γ zs. Γ ⊢⇩L [] ⇛ zs ⟹ [] = zs› 23. ‹⋀Γ x y xs ys zs. ⟦Γ ⊢ x ⇛ y; ⋀expr₂. Γ ⊢ x ⇛ expr₂ ⟹ y = expr₂; Γ ⊢⇩L xs ⇛ ys; ⋀zs. Γ ⊢⇩L xs ⇛ zs ⟹ ys = zs; Γ ⊢⇩L x # xs ⇛ zs⟧ ⟹ y # ys = zs›*) case (IfN Γ a₁ a₂ b₁ b₂ c₁ c₂) (*‹Γ ⊢ a₁ ⇛ a₂› ‹Γ ⊢ a₁ ⇛ ?expr₂ ⟹ a₂ = ?expr₂› ‹Γ ⊢ b₁ ⇛ b₂› ‹Γ ⊢ b₁ ⇛ ?expr₂ ⟹ b₂ = ?expr₂› ‹Γ ⊢ c₁ ⇛ c₂› ‹(Γ::String.literal ⇀⇩f 'a::ocl_object_model OCL_Types.type) ⊢ (c₁::'a::ocl_object_model expr) ⇛ (?expr₂::'a::ocl_object_model expr) ⟹ (c₂::'a::ocl_object_model expr) = ?expr₂› ‹Γ ⊢ expr.If a₁ b₁ c₁ ⇛ expr₂›*) thus "?case" (*goal: ‹expr.If a₂ b₂ c₂ = expr₂›*) apply (insert IfN.prems (*‹Γ ⊢ expr.If a₁ b₁ c₁ ⇛ expr₂›*)) (*goal: ‹expr.If a₂ b₂ c₂ = expr₂›*) apply (erule IfNE (*‹⟦(?Γ::String.literal ⇀⇩f ?'a OCL_Types.type) ⊢ expr.If (?a::?'a expr) (?b::?'a expr) (?c::?'a expr) ⇛ (?d::?'a expr); ⋀(a₂::?'a expr) (b₂::?'a expr) c₂::?'a expr. ⟦?d = expr.If a₂ b₂ c₂; ?Γ ⊢ ?a ⇛ a₂; ?Γ ⊢ ?b ⇛ b₂; ?Γ ⊢ ?c ⇛ c₂⟧ ⟹ ?P::bool⟧ ⟹ ?P›*)) (*goal: ‹Γ ⊢ expr.If a₁ b₁ c₁ ⇛ expr₂ ⟹ expr.If a₂ b₂ c₂ = expr₂›*) by (simp add: IfN.hyps (*‹Γ ⊢ a₁ ⇛ a₂› ‹Γ ⊢ a₁ ⇛ ?expr₂ ⟹ a₂ = ?expr₂› ‹Γ ⊢ b₁ ⇛ b₂› ‹Γ ⊢ b₁ ⇛ ?expr₂ ⟹ b₂ = ?expr₂› ‹Γ ⊢ c₁ ⇛ c₂› ‹Γ ⊢ c₁ ⇛ ?expr₂ ⟹ c₂ = ?expr₂›*)) next (*goals: 1. ‹⋀(Γ::String.literal ⇀⇩f 'a OCL_Types.type) (τ::'a OCL_Types.type) (op::metaop) expr₂::'a expr. Γ ⊢ MetaOperationCall τ op ⇛ expr₂ ⟹ MetaOperationCall τ op = expr₂› 2. ‹⋀(Γ::String.literal ⇀⇩f 'a OCL_Types.type) (params₁::'a expr list) (params₂::'a expr list) (τ::'a OCL_Types.type) (op::String.literal) expr₂::'a expr. ⟦Γ ⊢⇩L params₁ ⇛ params₂; ⋀zs::'a expr list. Γ ⊢⇩L params₁ ⇛ zs ⟹ params₂ = zs; Γ ⊢ StaticOperationCall τ op params₁ ⇛ expr₂⟧ ⟹ StaticOperationCall τ op params₂ = expr₂› 3. ‹⋀(Γ::String.literal ⇀⇩f 'a OCL_Types.type) (src₁::'a expr) (src₂::'a expr) (τ::'a OCL_Types.type) (call₁::'a call_expr) (call₂::'a call_expr) expr₂::'a expr. ⟦Γ ⊢ src₁ ⇛ src₂; ⋀expr₂::'a expr. Γ ⊢ src₁ ⇛ expr₂ ⟹ src₂ = expr₂; Γ ⊢⇩E src₂ : τ; τ ≤ OclAny[?] ∨ τ ≤ Tuple fmempty; (Γ, τ) ⊢⇩C call₁ ⇛ call₂; ⋀call₂'::'a call_expr. (Γ, τ) ⊢⇩C call₁ ⇛ call₂' ⟹ call₂ = call₂'; Γ ⊢ Call src₁ DotCall call₁ ⇛ expr₂⟧ ⟹ Call src₂ DotCall call₂ = expr₂› 4. ‹⋀(Γ::String.literal ⇀⇩f 'a OCL_Types.type) (src₁::'a expr) (src₂::'a expr) (τ::'a OCL_Types.type) (call₁::'a call_expr) (call₂::'a call_expr) (src₃::'a expr) expr₂::'a expr. ⟦Γ ⊢ src₁ ⇛ src₂; ⋀expr₂::'a expr. Γ ⊢ src₁ ⇛ expr₂ ⟹ src₂ = expr₂; Γ ⊢⇩E src₂ : τ; OclVoid[?] ≤ τ; (Γ, to_required_type τ) ⊢⇩C call₁ ⇛ call₂; ⋀call₂'::'a call_expr. (Γ, to_required_type τ) ⊢⇩C call₁ ⇛ call₂' ⟹ call₂ = call₂'; src₃ = TypeOperationCall src₂ DotCall OclAsTypeOp (to_required_type τ); Γ ⊢ Call src₁ SafeDotCall call₁ ⇛ expr₂⟧ ⟹ expr.If (OperationCall src₂ DotCall ((Inr ∘ Inl ∘ Inl) NotEqualOp) (map Literal [NullLiteral])) (Call src₃ DotCall call₂) (Literal NullLiteral) = expr₂› 5. ‹⋀(Γ::String.literal ⇀⇩f 'a OCL_Types.type) (src₁::'a expr) (src₂::'a expr) (τ::'a OCL_Types.type) (src₃::'a expr) (σ::'a OCL_Types.type) (call₁::'a call_expr) (call₂::'a call_expr) expr₂::'a expr. ⟦Γ ⊢ src₁ ⇛ src₂; ⋀expr₂::'a expr. Γ ⊢ src₁ ⇛ expr₂ ⟹ src₂ = expr₂; Γ ⊢⇩E src₂ : τ; τ ≤ OclAny[?] ∨ τ ≤ Tuple fmempty; src₃ = OperationCall src₂ DotCall ((Inl ∘ Inl) OclAsSetOp) []; Γ ⊢⇩E src₃ : σ; (Γ, σ) ⊢⇩C call₁ ⇛ call₂; ⋀call₂'::'a call_expr. (Γ, σ) ⊢⇩C call₁ ⇛ call₂' ⟹ call₂ = call₂'; Γ ⊢ Call src₁ ArrowCall call₁ ⇛ expr₂⟧ ⟹ Call src₃ ArrowCall call₂ = expr₂› 6. ‹⋀(Γ::String.literal ⇀⇩f 'a OCL_Types.type) (src₁::'a expr) (src₂::'a expr) (τ::'a OCL_Types.type) (uu_::'a OCL_Types.type) (call₁::'a call_expr) (call₂::'a call_expr) expr₂::'a expr. ⟦Γ ⊢ src₁ ⇛ src₂; ⋀expr₂::'a expr. Γ ⊢ src₁ ⇛ expr₂ ⟹ src₂ = expr₂; Γ ⊢⇩E src₂ : τ; element_type τ uu_; (Γ, τ) ⊢⇩C call₁ ⇛ call₂; ⋀call₂'::'a call_expr. (Γ, τ) ⊢⇩C call₁ ⇛ call₂' ⟹ call₂ = call₂'; Γ ⊢ Call src₁ ArrowCall call₁ ⇛ expr₂⟧ ⟹ Call src₂ ArrowCall call₂ = expr₂› 7. ‹⋀(Γ::String.literal ⇀⇩f 'a OCL_Types.type) (src₁::'a expr) (src₂::'a expr) (τ::'a OCL_Types.type) (σ::'a OCL_Types.type) (src₃::'a expr) (ρ::'a OCL_Types.type) (call₁::'a call_expr) (call₂::'a call_expr) expr₂::'a expr. ⟦Γ ⊢ src₁ ⇛ src₂; ⋀expr₂::'a expr. Γ ⊢ src₁ ⇛ expr₂ ⟹ src₂ = expr₂; Γ ⊢⇩E src₂ : τ; element_type τ σ; OclVoid[?] ≤ σ; src₃ = TypeOperationCall src₂ ArrowCall SelectByKindOp (to_required_type σ); Γ ⊢⇩E src₃ : ρ; (Γ, ρ) ⊢⇩C call₁ ⇛ call₂; ⋀call₂'::'a call_expr. (Γ, ρ) ⊢⇩C call₁ ⇛ call₂' ⟹ call₂ = call₂'; Γ ⊢ Call src₁ SafeArrowCall call₁ ⇛ expr₂⟧ ⟹ Call src₃ ArrowCall call₂ = expr₂› 8. ‹⋀(Γ::String.literal ⇀⇩f 'a OCL_Types.type) (src₁::'a expr) (src₂::'a expr) (τ::'a OCL_Types.type) (σ::'a OCL_Types.type) (call₁::'a call_expr) (call₂::'a call_expr) (it::String.literal) expr₂::'a expr. ⟦Γ ⊢ src₁ ⇛ src₂; ⋀expr₂::'a expr. Γ ⊢ src₁ ⇛ expr₂ ⟹ src₂ = expr₂; Γ ⊢⇩E src₂ : τ; element_type τ σ; (Γ, σ) ⊢⇩C call₁ ⇛ call₂; ⋀call₂'::'a call_expr. (Γ, σ) ⊢⇩C call₁ ⇛ call₂' ⟹ call₂ = call₂'; it = new_vname Γ; Γ ⊢ Call src₁ DotCall call₁ ⇛ expr₂⟧ ⟹ CollectIteratorCall src₂ ArrowCall [it] (Some σ) (Call (Var it) DotCall call₂) = expr₂› 9. ‹⋀(Γ::String.literal ⇀⇩f 'a OCL_Types.type) (src₁::'a expr) (src₂::'a expr) (τ::'a OCL_Types.type) (σ::'a OCL_Types.type) (ρ::'a OCL_Types.type) (src₃::'a expr) (call₁::'a call_expr) (call₂::'a call_expr) (it::String.literal) expr₂::'a expr. ⟦Γ ⊢ src₁ ⇛ src₂; ⋀expr₂::'a expr. Γ ⊢ src₁ ⇛ expr₂ ⟹ src₂ = expr₂; Γ ⊢⇩E src₂ : τ; element_type τ σ; OclVoid[?] ≤ σ; ρ = to_required_type σ; src₃ = TypeOperationCall src₂ ArrowCall SelectByKindOp ρ; (Γ, ρ) ⊢⇩C call₁ ⇛ call₂; ⋀call₂'::'a call_expr. (Γ, ρ) ⊢⇩C call₁ ⇛ call₂' ⟹ call₂ = call₂'; it = new_vname Γ; Γ ⊢ Call src₁ SafeDotCall call₁ ⇛ expr₂⟧ ⟹ CollectIteratorCall src₃ ArrowCall [it] (Some ρ) (Call (Var it) DotCall call₂) = expr₂› 10. ‹⋀(Γ::String.literal ⇀⇩f 'a OCL_Types.type) (τ::'a OCL_Types.type) (op::typeop) (ty::'a OCL_Types.type) call₂::'a call_expr. (Γ, τ) ⊢⇩C TypeOperation op ty ⇛ call₂ ⟹ TypeOperation op ty = call₂› 11. ‹⋀(Γ::String.literal ⇀⇩f 'a OCL_Types.type) (τ::'a OCL_Types.type) (attr::String.literal) call₂::'a call_expr. (Γ, τ) ⊢⇩C Attribute attr ⇛ call₂ ⟹ Attribute attr = call₂› 12. ‹⋀(Γ::String.literal ⇀⇩f 'a OCL_Types.type) (τ::'a OCL_Types.type) (role::String.literal option) (from::String.literal) call₂::'a call_expr. (Γ, τ) ⊢⇩C AssociationEnd role from ⇛ call₂ ⟹ AssociationEnd role from = call₂› 13. ‹⋀(Γ::String.literal ⇀⇩f 'a OCL_Types.type) (τ::'a OCL_Types.type) (𝒜::String.literal option) (from::'a) call₂::'a call_expr. (Γ, τ) ⊢⇩C AssociationClass 𝒜 from ⇛ call₂ ⟹ AssociationClass 𝒜 from = call₂› 14. ‹⋀(Γ::String.literal ⇀⇩f 'a OCL_Types.type) (τ::'a OCL_Types.type) (role::String.literal) call₂::'a call_expr. (Γ, τ) ⊢⇩C AssociationClassEnd role ⇛ call₂ ⟹ AssociationClassEnd role = call₂› 15. ‹⋀(Γ::String.literal ⇀⇩f 'a OCL_Types.type) (params₁::'a expr list) (params₂::'a expr list) (τ::'a OCL_Types.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) call₂::'a call_expr. ⟦Γ ⊢⇩L params₁ ⇛ params₂; ⋀zs::'a expr list. Γ ⊢⇩L params₁ ⇛ zs ⟹ params₂ = zs; (Γ, τ) ⊢⇩C Operation op params₁ ⇛ call₂⟧ ⟹ Operation op params₂ = call₂› 16. ‹⋀(Γ::String.literal ⇀⇩f 'a OCL_Types.type) (τ::'a OCL_Types.type) (elem::String.literal) call₂::'a call_expr. (Γ, τ) ⊢⇩C TupleElement elem ⇛ call₂ ⟹ TupleElement elem = call₂› 17. ‹⋀(Γ::String.literal ⇀⇩f 'a OCL_Types.type) (res_init₁::'a expr) (res_init₂::'a expr) (σ::'a OCL_Types.type) (its::String.literal list) (res::String.literal) (res_t₁::'a OCL_Types.type option) (body₁::'a expr) (res_t₂::'a OCL_Types.type option) (body₂::'a expr) (τ::'a OCL_Types.type) call₂::'a call_expr. ⟦Γ ⊢ res_init₁ ⇛ res_init₂; ⋀expr₂::'a expr. Γ ⊢ res_init₁ ⇛ expr₂ ⟹ res_init₂ = expr₂; Γ ++⇩f fmap_of_list (map (λit::String.literal. (it, σ)) its) ⊢ expr.Let res res_t₁ res_init₁ body₁ ⇛ expr.Let res res_t₂ res_init₂ body₂; ⋀expr₂::'a expr. Γ ++⇩f fmap_of_list (map (λit::String.literal. (it, σ)) its) ⊢ expr.Let res res_t₁ res_init₁ body₁ ⇛ expr₂ ⟹ expr.Let res res_t₂ res_init₂ body₂ = expr₂; (Γ, τ) ⊢⇩C Iterate its (Some σ) res res_t₁ res_init₁ body₁ ⇛ call₂⟧ ⟹ Iterate its (Some σ) res res_t₂ res_init₂ body₂ = call₂› 18. ‹⋀(τ::'a OCL_Types.type) (σ::'a OCL_Types.type) (Γ::String.literal ⇀⇩f 'a OCL_Types.type) (res_init₁::'a expr) (res_init₂::'a expr) (its::String.literal list) (res::String.literal) (res_t₁::'a OCL_Types.type option) (body₁::'a expr) (res_t₂::'a OCL_Types.type option) (body₂::'a expr) call₂::'a call_expr. ⟦element_type τ σ; Γ ⊢ res_init₁ ⇛ res_init₂; ⋀expr₂::'a expr. Γ ⊢ res_init₁ ⇛ expr₂ ⟹ res_init₂ = expr₂; Γ ++⇩f fmap_of_list (map (λit::String.literal. (it, σ)) its) ⊢ expr.Let res res_t₁ res_init₁ body₁ ⇛ expr.Let res res_t₂ res_init₂ body₂; ⋀expr₂::'a expr. Γ ++⇩f fmap_of_list (map (λit::String.literal. (it, σ)) its) ⊢ expr.Let res res_t₁ res_init₁ body₁ ⇛ expr₂ ⟹ expr.Let res res_t₂ res_init₂ body₂ = expr₂; (Γ, τ) ⊢⇩C Iterate its None res res_t₁ res_init₁ body₁ ⇛ call₂⟧ ⟹ Iterate its (Some σ) res res_t₂ res_init₂ body₂ = call₂› 19. ‹⋀(Γ::String.literal ⇀⇩f 'a OCL_Types.type) (σ::'a OCL_Types.type) (its::String.literal list) (body₁::'a expr) (body₂::'a expr) (τ::'a OCL_Types.type) (iter::iterator) call₂::'a call_expr. ⟦Γ ++⇩f fmap_of_list (map (λit::String.literal. (it, σ)) its) ⊢ body₁ ⇛ body₂; ⋀expr₂::'a expr. Γ ++⇩f fmap_of_list (map (λit::String.literal. (it, σ)) its) ⊢ body₁ ⇛ expr₂ ⟹ body₂ = expr₂; (Γ, τ) ⊢⇩C Iterator iter its (Some σ) body₁ ⇛ call₂⟧ ⟹ Iterator iter its (Some σ) body₂ = call₂› 20. ‹⋀(τ::'a OCL_Types.type) (σ::'a OCL_Types.type) (Γ::String.literal ⇀⇩f 'a OCL_Types.type) (its::String.literal list) (body₁::'a expr) (body₂::'a expr) (iter::iterator) call₂::'a call_expr. ⟦element_type τ σ; Γ ++⇩f fmap_of_list (map (λit::String.literal. (it, σ)) its) ⊢ body₁ ⇛ body₂; ⋀expr₂::'a expr. Γ ++⇩f fmap_of_list (map (λit::String.literal. (it, σ)) its) ⊢ body₁ ⇛ expr₂ ⟹ body₂ = expr₂; (Γ, τ) ⊢⇩C Iterator iter its None body₁ ⇛ call₂⟧ ⟹ Iterator iter its (Some σ) body₂ = call₂› 21. ‹⋀(Γ::String.literal ⇀⇩f 'a OCL_Types.type) zs::'a expr list. Γ ⊢⇩L [] ⇛ zs ⟹ [] = zs› 22. ‹⋀(Γ::String.literal ⇀⇩f 'a OCL_Types.type) (x::'a expr) (y::'a expr) (xs::'a expr list) (ys::'a expr list) zs::'a expr list. ⟦Γ ⊢ x ⇛ y; ⋀expr₂::'a expr. Γ ⊢ x ⇛ expr₂ ⟹ y = expr₂; Γ ⊢⇩L xs ⇛ ys; ⋀zs::'a expr list. Γ ⊢⇩L xs ⇛ zs ⟹ ys = zs; Γ ⊢⇩L x # xs ⇛ zs⟧ ⟹ y # ys = zs›*) case (MetaOperationCallN Γ τ op) (*‹Γ ⊢ MetaOperationCall τ op ⇛ expr₂›*) thus "?case" (*goal: ‹MetaOperationCall τ op = expr₂›*) by auto next (*goals: 1. ‹⋀Γ params₁ params₂ τ op expr₂. ⟦Γ ⊢⇩L params₁ ⇛ params₂; ⋀zs. Γ ⊢⇩L params₁ ⇛ zs ⟹ params₂ = zs; Γ ⊢ StaticOperationCall τ op params₁ ⇛ expr₂⟧ ⟹ StaticOperationCall τ op params₂ = expr₂› 2. ‹⋀Γ src₁ src₂ τ call₁ call₂ expr₂. ⟦Γ ⊢ src₁ ⇛ src₂; ⋀expr₂. Γ ⊢ src₁ ⇛ expr₂ ⟹ src₂ = expr₂; Γ ⊢⇩E src₂ : τ; τ ≤ OclAny[?] ∨ τ ≤ Tuple fmempty; (Γ, τ) ⊢⇩C call₁ ⇛ call₂; ⋀call₂'. (Γ, τ) ⊢⇩C call₁ ⇛ call₂' ⟹ call₂ = call₂'; Γ ⊢ Call src₁ DotCall call₁ ⇛ expr₂⟧ ⟹ Call src₂ DotCall call₂ = expr₂› 3. ‹⋀Γ src₁ src₂ τ call₁ call₂ src₃ expr₂. ⟦Γ ⊢ src₁ ⇛ src₂; ⋀expr₂. Γ ⊢ src₁ ⇛ expr₂ ⟹ src₂ = expr₂; Γ ⊢⇩E src₂ : τ; OclVoid[?] ≤ τ; (Γ, to_required_type τ) ⊢⇩C call₁ ⇛ call₂; ⋀call₂'. (Γ, to_required_type τ) ⊢⇩C call₁ ⇛ call₂' ⟹ call₂ = call₂'; src₃ = TypeOperationCall src₂ DotCall OclAsTypeOp (to_required_type τ); Γ ⊢ Call src₁ SafeDotCall call₁ ⇛ expr₂⟧ ⟹ expr.If (OperationCall src₂ DotCall ((Inr ∘ Inl ∘ Inl) NotEqualOp) (map Literal [NullLiteral])) (Call src₃ DotCall call₂) (Literal NullLiteral) = expr₂› 4. ‹⋀Γ src₁ src₂ τ src₃ σ call₁ call₂ expr₂. ⟦Γ ⊢ src₁ ⇛ src₂; ⋀expr₂. Γ ⊢ src₁ ⇛ expr₂ ⟹ src₂ = expr₂; Γ ⊢⇩E src₂ : τ; τ ≤ OclAny[?] ∨ τ ≤ Tuple fmempty; src₃ = OperationCall src₂ DotCall ((Inl ∘ Inl) OclAsSetOp) []; Γ ⊢⇩E src₃ : σ; (Γ, σ) ⊢⇩C call₁ ⇛ call₂; ⋀call₂'. (Γ, σ) ⊢⇩C call₁ ⇛ call₂' ⟹ call₂ = call₂'; Γ ⊢ Call src₁ ArrowCall call₁ ⇛ expr₂⟧ ⟹ Call src₃ ArrowCall call₂ = expr₂› 5. ‹⋀Γ src₁ src₂ τ uu_ call₁ call₂ expr₂. ⟦Γ ⊢ src₁ ⇛ src₂; ⋀expr₂. Γ ⊢ src₁ ⇛ expr₂ ⟹ src₂ = expr₂; Γ ⊢⇩E src₂ : τ; element_type τ uu_; (Γ, τ) ⊢⇩C call₁ ⇛ call₂; ⋀call₂'. (Γ, τ) ⊢⇩C call₁ ⇛ call₂' ⟹ call₂ = call₂'; Γ ⊢ Call src₁ ArrowCall call₁ ⇛ expr₂⟧ ⟹ Call src₂ ArrowCall call₂ = expr₂› 6. ‹⋀Γ src₁ src₂ τ σ src₃ ρ call₁ call₂ expr₂. ⟦Γ ⊢ src₁ ⇛ src₂; ⋀expr₂. Γ ⊢ src₁ ⇛ expr₂ ⟹ src₂ = expr₂; Γ ⊢⇩E src₂ : τ; element_type τ σ; OclVoid[?] ≤ σ; src₃ = TypeOperationCall src₂ ArrowCall SelectByKindOp (to_required_type σ); Γ ⊢⇩E src₃ : ρ; (Γ, ρ) ⊢⇩C call₁ ⇛ call₂; ⋀call₂'. (Γ, ρ) ⊢⇩C call₁ ⇛ call₂' ⟹ call₂ = call₂'; Γ ⊢ Call src₁ SafeArrowCall call₁ ⇛ expr₂⟧ ⟹ Call src₃ ArrowCall call₂ = expr₂› 7. ‹⋀Γ src₁ src₂ τ σ call₁ call₂ it expr₂. ⟦Γ ⊢ src₁ ⇛ src₂; ⋀expr₂. Γ ⊢ src₁ ⇛ expr₂ ⟹ src₂ = expr₂; Γ ⊢⇩E src₂ : τ; element_type τ σ; (Γ, σ) ⊢⇩C call₁ ⇛ call₂; ⋀call₂'. (Γ, σ) ⊢⇩C call₁ ⇛ call₂' ⟹ call₂ = call₂'; it = new_vname Γ; Γ ⊢ Call src₁ DotCall call₁ ⇛ expr₂⟧ ⟹ CollectIteratorCall src₂ ArrowCall [it] (Some σ) (Call (Var it) DotCall call₂) = expr₂› 8. ‹⋀Γ src₁ src₂ τ σ ρ src₃ call₁ call₂ it expr₂. ⟦Γ ⊢ src₁ ⇛ src₂; ⋀expr₂. Γ ⊢ src₁ ⇛ expr₂ ⟹ src₂ = expr₂; Γ ⊢⇩E src₂ : τ; element_type τ σ; OclVoid[?] ≤ σ; ρ = to_required_type σ; src₃ = TypeOperationCall src₂ ArrowCall SelectByKindOp ρ; (Γ, ρ) ⊢⇩C call₁ ⇛ call₂; ⋀call₂'. (Γ, ρ) ⊢⇩C call₁ ⇛ call₂' ⟹ call₂ = call₂'; it = new_vname Γ; Γ ⊢ Call src₁ SafeDotCall call₁ ⇛ expr₂⟧ ⟹ CollectIteratorCall src₃ ArrowCall [it] (Some ρ) (Call (Var it) DotCall call₂) = expr₂› 9. ‹⋀Γ τ op ty call₂. (Γ, τ) ⊢⇩C TypeOperation op ty ⇛ call₂ ⟹ TypeOperation op ty = call₂› 10. ‹⋀Γ τ attr call₂. (Γ, τ) ⊢⇩C Attribute attr ⇛ call₂ ⟹ Attribute attr = call₂› 11. ‹⋀Γ τ role from call₂. (Γ, τ) ⊢⇩C AssociationEnd role from ⇛ call₂ ⟹ AssociationEnd role from = call₂› 12. ‹⋀Γ τ 𝒜 from call₂. (Γ, τ) ⊢⇩C AssociationClass 𝒜 from ⇛ call₂ ⟹ AssociationClass 𝒜 from = call₂› 13. ‹⋀Γ τ role call₂. (Γ, τ) ⊢⇩C AssociationClassEnd role ⇛ call₂ ⟹ AssociationClassEnd role = call₂› 14. ‹⋀Γ params₁ params₂ τ op call₂. ⟦Γ ⊢⇩L params₁ ⇛ params₂; ⋀zs. Γ ⊢⇩L params₁ ⇛ zs ⟹ params₂ = zs; (Γ, τ) ⊢⇩C Operation op params₁ ⇛ call₂⟧ ⟹ Operation op params₂ = call₂› 15. ‹⋀Γ τ elem call₂. (Γ, τ) ⊢⇩C TupleElement elem ⇛ call₂ ⟹ TupleElement elem = call₂› 16. ‹⋀Γ res_init₁ res_init₂ σ its res res_t₁ body₁ res_t₂ body₂ τ call₂. ⟦Γ ⊢ res_init₁ ⇛ res_init₂; ⋀expr₂. Γ ⊢ res_init₁ ⇛ expr₂ ⟹ res_init₂ = expr₂; Γ ++⇩f fmap_of_list (map (λit. (it, σ)) its) ⊢ expr.Let res res_t₁ res_init₁ body₁ ⇛ expr.Let res res_t₂ res_init₂ body₂; ⋀expr₂. Γ ++⇩f fmap_of_list (map (λit. (it, σ)) its) ⊢ expr.Let res res_t₁ res_init₁ body₁ ⇛ expr₂ ⟹ expr.Let res res_t₂ res_init₂ body₂ = expr₂; (Γ, τ) ⊢⇩C Iterate its (Some σ) res res_t₁ res_init₁ body₁ ⇛ call₂⟧ ⟹ Iterate its (Some σ) res res_t₂ res_init₂ body₂ = call₂› 17. ‹⋀τ σ Γ res_init₁ res_init₂ its res res_t₁ body₁ res_t₂ body₂ call₂. ⟦element_type τ σ; Γ ⊢ res_init₁ ⇛ res_init₂; ⋀expr₂. Γ ⊢ res_init₁ ⇛ expr₂ ⟹ res_init₂ = expr₂; Γ ++⇩f fmap_of_list (map (λit. (it, σ)) its) ⊢ expr.Let res res_t₁ res_init₁ body₁ ⇛ expr.Let res res_t₂ res_init₂ body₂; ⋀expr₂. Γ ++⇩f fmap_of_list (map (λit. (it, σ)) its) ⊢ expr.Let res res_t₁ res_init₁ body₁ ⇛ expr₂ ⟹ expr.Let res res_t₂ res_init₂ body₂ = expr₂; (Γ, τ) ⊢⇩C Iterate its None res res_t₁ res_init₁ body₁ ⇛ call₂⟧ ⟹ Iterate its (Some σ) res res_t₂ res_init₂ body₂ = call₂› 18. ‹⋀Γ σ its body₁ body₂ τ iter call₂. ⟦Γ ++⇩f fmap_of_list (map (λit. (it, σ)) its) ⊢ body₁ ⇛ body₂; ⋀expr₂. Γ ++⇩f fmap_of_list (map (λit. (it, σ)) its) ⊢ body₁ ⇛ expr₂ ⟹ body₂ = expr₂; (Γ, τ) ⊢⇩C Iterator iter its (Some σ) body₁ ⇛ call₂⟧ ⟹ Iterator iter its (Some σ) body₂ = call₂› 19. ‹⋀τ σ Γ its body₁ body₂ iter call₂. ⟦element_type τ σ; Γ ++⇩f fmap_of_list (map (λit. (it, σ)) its) ⊢ body₁ ⇛ body₂; ⋀expr₂. Γ ++⇩f fmap_of_list (map (λit. (it, σ)) its) ⊢ body₁ ⇛ expr₂ ⟹ body₂ = expr₂; (Γ, τ) ⊢⇩C Iterator iter its None body₁ ⇛ call₂⟧ ⟹ Iterator iter its (Some σ) body₂ = call₂› 20. ‹⋀Γ zs. Γ ⊢⇩L [] ⇛ zs ⟹ [] = zs› 21. ‹⋀Γ x y xs ys zs. ⟦Γ ⊢ x ⇛ y; ⋀expr₂. Γ ⊢ x ⇛ expr₂ ⟹ y = expr₂; Γ ⊢⇩L xs ⇛ ys; ⋀zs. Γ ⊢⇩L xs ⇛ zs ⟹ ys = zs; Γ ⊢⇩L x # xs ⇛ zs⟧ ⟹ y # ys = zs›*) case (StaticOperationCallN Γ params₁ params₂ τ op) (*‹Γ ⊢⇩L params₁ ⇛ params₂› ‹(Γ::String.literal ⇀⇩f 'a OCL_Types.type) ⊢⇩L (params₁::'a expr list) ⇛ (?zs::'a expr list) ⟹ (params₂::'a expr list) = ?zs› ‹Γ ⊢ StaticOperationCall τ op params₁ ⇛ expr₂›*) thus "?case" (*goal: ‹StaticOperationCall τ op params₂ = expr₂›*) by blast next (*goals: 1. ‹⋀Γ src₁ src₂ τ call₁ call₂ expr₂. ⟦Γ ⊢ src₁ ⇛ src₂; ⋀expr₂. Γ ⊢ src₁ ⇛ expr₂ ⟹ src₂ = expr₂; Γ ⊢⇩E src₂ : τ; τ ≤ OclAny[?] ∨ τ ≤ Tuple fmempty; (Γ, τ) ⊢⇩C call₁ ⇛ call₂; ⋀call₂'. (Γ, τ) ⊢⇩C call₁ ⇛ call₂' ⟹ call₂ = call₂'; Γ ⊢ Call src₁ DotCall call₁ ⇛ expr₂⟧ ⟹ Call src₂ DotCall call₂ = expr₂› 2. ‹⋀Γ src₁ src₂ τ call₁ call₂ src₃ expr₂. ⟦Γ ⊢ src₁ ⇛ src₂; ⋀expr₂. Γ ⊢ src₁ ⇛ expr₂ ⟹ src₂ = expr₂; Γ ⊢⇩E src₂ : τ; OclVoid[?] ≤ τ; (Γ, to_required_type τ) ⊢⇩C call₁ ⇛ call₂; ⋀call₂'. (Γ, to_required_type τ) ⊢⇩C call₁ ⇛ call₂' ⟹ call₂ = call₂'; src₃ = TypeOperationCall src₂ DotCall OclAsTypeOp (to_required_type τ); Γ ⊢ Call src₁ SafeDotCall call₁ ⇛ expr₂⟧ ⟹ expr.If (OperationCall src₂ DotCall ((Inr ∘ Inl ∘ Inl) NotEqualOp) (map Literal [NullLiteral])) (Call src₃ DotCall call₂) (Literal NullLiteral) = expr₂› 3. ‹⋀Γ src₁ src₂ τ src₃ σ call₁ call₂ expr₂. ⟦Γ ⊢ src₁ ⇛ src₂; ⋀expr₂. Γ ⊢ src₁ ⇛ expr₂ ⟹ src₂ = expr₂; Γ ⊢⇩E src₂ : τ; τ ≤ OclAny[?] ∨ τ ≤ Tuple fmempty; src₃ = OperationCall src₂ DotCall ((Inl ∘ Inl) OclAsSetOp) []; Γ ⊢⇩E src₃ : σ; (Γ, σ) ⊢⇩C call₁ ⇛ call₂; ⋀call₂'. (Γ, σ) ⊢⇩C call₁ ⇛ call₂' ⟹ call₂ = call₂'; Γ ⊢ Call src₁ ArrowCall call₁ ⇛ expr₂⟧ ⟹ Call src₃ ArrowCall call₂ = expr₂› 4. ‹⋀Γ src₁ src₂ τ uu_ call₁ call₂ expr₂. ⟦Γ ⊢ src₁ ⇛ src₂; ⋀expr₂. Γ ⊢ src₁ ⇛ expr₂ ⟹ src₂ = expr₂; Γ ⊢⇩E src₂ : τ; element_type τ uu_; (Γ, τ) ⊢⇩C call₁ ⇛ call₂; ⋀call₂'. (Γ, τ) ⊢⇩C call₁ ⇛ call₂' ⟹ call₂ = call₂'; Γ ⊢ Call src₁ ArrowCall call₁ ⇛ expr₂⟧ ⟹ Call src₂ ArrowCall call₂ = expr₂› 5. ‹⋀Γ src₁ src₂ τ σ src₃ ρ call₁ call₂ expr₂. ⟦Γ ⊢ src₁ ⇛ src₂; ⋀expr₂. Γ ⊢ src₁ ⇛ expr₂ ⟹ src₂ = expr₂; Γ ⊢⇩E src₂ : τ; element_type τ σ; OclVoid[?] ≤ σ; src₃ = TypeOperationCall src₂ ArrowCall SelectByKindOp (to_required_type σ); Γ ⊢⇩E src₃ : ρ; (Γ, ρ) ⊢⇩C call₁ ⇛ call₂; ⋀call₂'. (Γ, ρ) ⊢⇩C call₁ ⇛ call₂' ⟹ call₂ = call₂'; Γ ⊢ Call src₁ SafeArrowCall call₁ ⇛ expr₂⟧ ⟹ Call src₃ ArrowCall call₂ = expr₂› 6. ‹⋀Γ src₁ src₂ τ σ call₁ call₂ it expr₂. ⟦Γ ⊢ src₁ ⇛ src₂; ⋀expr₂. Γ ⊢ src₁ ⇛ expr₂ ⟹ src₂ = expr₂; Γ ⊢⇩E src₂ : τ; element_type τ σ; (Γ, σ) ⊢⇩C call₁ ⇛ call₂; ⋀call₂'. (Γ, σ) ⊢⇩C call₁ ⇛ call₂' ⟹ call₂ = call₂'; it = new_vname Γ; Γ ⊢ Call src₁ DotCall call₁ ⇛ expr₂⟧ ⟹ CollectIteratorCall src₂ ArrowCall [it] (Some σ) (Call (Var it) DotCall call₂) = expr₂› 7. ‹⋀Γ src₁ src₂ τ σ ρ src₃ call₁ call₂ it expr₂. ⟦Γ ⊢ src₁ ⇛ src₂; ⋀expr₂. Γ ⊢ src₁ ⇛ expr₂ ⟹ src₂ = expr₂; Γ ⊢⇩E src₂ : τ; element_type τ σ; OclVoid[?] ≤ σ; ρ = to_required_type σ; src₃ = TypeOperationCall src₂ ArrowCall SelectByKindOp ρ; (Γ, ρ) ⊢⇩C call₁ ⇛ call₂; ⋀call₂'. (Γ, ρ) ⊢⇩C call₁ ⇛ call₂' ⟹ call₂ = call₂'; it = new_vname Γ; Γ ⊢ Call src₁ SafeDotCall call₁ ⇛ expr₂⟧ ⟹ CollectIteratorCall src₃ ArrowCall [it] (Some ρ) (Call (Var it) DotCall call₂) = expr₂› 8. ‹⋀Γ τ op ty call₂. (Γ, τ) ⊢⇩C TypeOperation op ty ⇛ call₂ ⟹ TypeOperation op ty = call₂› 9. ‹⋀Γ τ attr call₂. (Γ, τ) ⊢⇩C Attribute attr ⇛ call₂ ⟹ Attribute attr = call₂› 10. ‹⋀Γ τ role from call₂. (Γ, τ) ⊢⇩C AssociationEnd role from ⇛ call₂ ⟹ AssociationEnd role from = call₂› 11. ‹⋀Γ τ 𝒜 from call₂. (Γ, τ) ⊢⇩C AssociationClass 𝒜 from ⇛ call₂ ⟹ AssociationClass 𝒜 from = call₂› 12. ‹⋀Γ τ role call₂. (Γ, τ) ⊢⇩C AssociationClassEnd role ⇛ call₂ ⟹ AssociationClassEnd role = call₂› 13. ‹⋀Γ params₁ params₂ τ op call₂. ⟦Γ ⊢⇩L params₁ ⇛ params₂; ⋀zs. Γ ⊢⇩L params₁ ⇛ zs ⟹ params₂ = zs; (Γ, τ) ⊢⇩C Operation op params₁ ⇛ call₂⟧ ⟹ Operation op params₂ = call₂› 14. ‹⋀Γ τ elem call₂. (Γ, τ) ⊢⇩C TupleElement elem ⇛ call₂ ⟹ TupleElement elem = call₂› 15. ‹⋀Γ res_init₁ res_init₂ σ its res res_t₁ body₁ res_t₂ body₂ τ call₂. ⟦Γ ⊢ res_init₁ ⇛ res_init₂; ⋀expr₂. Γ ⊢ res_init₁ ⇛ expr₂ ⟹ res_init₂ = expr₂; Γ ++⇩f fmap_of_list (map (λit. (it, σ)) its) ⊢ expr.Let res res_t₁ res_init₁ body₁ ⇛ expr.Let res res_t₂ res_init₂ body₂; ⋀expr₂. Γ ++⇩f fmap_of_list (map (λit. (it, σ)) its) ⊢ expr.Let res res_t₁ res_init₁ body₁ ⇛ expr₂ ⟹ expr.Let res res_t₂ res_init₂ body₂ = expr₂; (Γ, τ) ⊢⇩C Iterate its (Some σ) res res_t₁ res_init₁ body₁ ⇛ call₂⟧ ⟹ Iterate its (Some σ) res res_t₂ res_init₂ body₂ = call₂› 16. ‹⋀τ σ Γ res_init₁ res_init₂ its res res_t₁ body₁ res_t₂ body₂ call₂. ⟦element_type τ σ; Γ ⊢ res_init₁ ⇛ res_init₂; ⋀expr₂. Γ ⊢ res_init₁ ⇛ expr₂ ⟹ res_init₂ = expr₂; Γ ++⇩f fmap_of_list (map (λit. (it, σ)) its) ⊢ expr.Let res res_t₁ res_init₁ body₁ ⇛ expr.Let res res_t₂ res_init₂ body₂; ⋀expr₂. Γ ++⇩f fmap_of_list (map (λit. (it, σ)) its) ⊢ expr.Let res res_t₁ res_init₁ body₁ ⇛ expr₂ ⟹ expr.Let res res_t₂ res_init₂ body₂ = expr₂; (Γ, τ) ⊢⇩C Iterate its None res res_t₁ res_init₁ body₁ ⇛ call₂⟧ ⟹ Iterate its (Some σ) res res_t₂ res_init₂ body₂ = call₂› 17. ‹⋀Γ σ its body₁ body₂ τ iter call₂. ⟦Γ ++⇩f fmap_of_list (map (λit. (it, σ)) its) ⊢ body₁ ⇛ body₂; ⋀expr₂. Γ ++⇩f fmap_of_list (map (λit. (it, σ)) its) ⊢ body₁ ⇛ expr₂ ⟹ body₂ = expr₂; (Γ, τ) ⊢⇩C Iterator iter its (Some σ) body₁ ⇛ call₂⟧ ⟹ Iterator iter its (Some σ) body₂ = call₂› 18. ‹⋀τ σ Γ its body₁ body₂ iter call₂. ⟦element_type τ σ; Γ ++⇩f fmap_of_list (map (λit. (it, σ)) its) ⊢ body₁ ⇛ body₂; ⋀expr₂. Γ ++⇩f fmap_of_list (map (λit. (it, σ)) its) ⊢ body₁ ⇛ expr₂ ⟹ body₂ = expr₂; (Γ, τ) ⊢⇩C Iterator iter its None body₁ ⇛ call₂⟧ ⟹ Iterator iter its (Some σ) body₂ = call₂› 19. ‹⋀Γ zs. Γ ⊢⇩L [] ⇛ zs ⟹ [] = zs› 20. ‹⋀Γ x y xs ys zs. ⟦Γ ⊢ x ⇛ y; ⋀expr₂. Γ ⊢ x ⇛ expr₂ ⟹ y = expr₂; Γ ⊢⇩L xs ⇛ ys; ⋀zs. Γ ⊢⇩L xs ⇛ zs ⟹ ys = zs; Γ ⊢⇩L x # xs ⇛ zs⟧ ⟹ y # ys = zs›*) case (OclAnyDotCallN Γ src₁ src₂ τ call₁ call₂) (*‹Γ ⊢ src₁ ⇛ src₂› ‹Γ ⊢ src₁ ⇛ ?expr₂ ⟹ src₂ = ?expr₂› ‹Γ ⊢⇩E src₂ : τ› ‹τ ≤ OclAny[?] ∨ τ ≤ Tuple fmempty› ‹(Γ, τ) ⊢⇩C call₁ ⇛ call₂› ‹(Γ, τ) ⊢⇩C call₁ ⇛ ?call₂ ⟹ call₂ = ?call₂› ‹(Γ::String.literal ⇀⇩f 'a OCL_Types.type) ⊢ Call (src₁::'a expr) DotCall (call₁::'a call_expr) ⇛ (expr₂::'a expr)›*) show "?case" (*goal: ‹Call (src₂::'a::ocl_object_model expr) DotCall (call₂::'a::ocl_object_model call_expr) = (expr₂::'a::ocl_object_model expr)›*) apply (insert OclAnyDotCallN.prems (*‹Γ ⊢ Call src₁ DotCall call₁ ⇛ expr₂›*)) (*goal: ‹Call src₂ DotCall call₂ = expr₂›*) apply (erule DotCallNE (*‹⟦?Γ ⊢ Call ?src DotCall ?call ⇛ ?b; ⋀src₂ τ call₂. ⟦?b = Call src₂ DotCall call₂; ?Γ ⊢ ?src ⇛ src₂; ?Γ ⊢⇩E src₂ : τ; τ ≤ OclAny[?] ∨ τ ≤ Tuple fmempty; (?Γ, τ) ⊢⇩C ?call ⇛ call₂⟧ ⟹ ?P; ⋀src₂ τ σ call₂. ⟦?b = CollectIteratorCall src₂ ArrowCall [new_vname ?Γ] (Some σ) (Call (Var (new_vname ?Γ)) DotCall call₂); ?Γ ⊢ ?src ⇛ src₂; ?Γ ⊢⇩E src₂ : τ; element_type τ σ; (?Γ, σ) ⊢⇩C ?call ⇛ call₂⟧ ⟹ ?P⟧ ⟹ ?P›*)) (*goal: ‹(Γ::String.literal ⇀⇩f 'a::ocl_object_model OCL_Types.type) ⊢ Call (src₁::'a::ocl_object_model expr) DotCall (call₁::'a::ocl_object_model call_expr) ⇛ (expr₂::'a::ocl_object_model expr) ⟹ Call (src₂::'a::ocl_object_model expr) DotCall (call₂::'a::ocl_object_model call_expr) = expr₂›*) using OclAnyDotCallN.hyps (*‹Γ ⊢ src₁ ⇛ src₂› ‹(Γ::String.literal ⇀⇩f 'a OCL_Types.type) ⊢ (src₁::'a expr) ⇛ (?expr₂::'a expr) ⟹ (src₂::'a expr) = ?expr₂› ‹Γ ⊢⇩E src₂ : τ› ‹τ ≤ OclAny[?] ∨ τ ≤ Tuple fmempty› ‹(Γ, τ) ⊢⇩C call₁ ⇛ call₂› ‹(Γ::String.literal ⇀⇩f 'a::ocl_object_model OCL_Types.type, τ::'a::ocl_object_model OCL_Types.type) ⊢⇩C (call₁::'a::ocl_object_model call_expr) ⇛ (?call₂::'a::ocl_object_model call_expr) ⟹ (call₂::'a::ocl_object_model call_expr) = ?call₂›*) typing_det (*‹⟦?Γ ⊢⇩E ?expr : ?τ; ?Γ ⊢⇩E ?expr : ?σ⟧ ⟹ ?τ = ?σ›*) apply metis (*top goal: ‹⋀src₂' τ call₂. ⟦expr₂ = Call src₂' DotCall call₂; Γ ⊢ src₁ ⇛ src₂'; Γ ⊢⇩E src₂' : τ; τ ≤ OclAny[?] ∨ τ ≤ Tuple fmempty; (Γ, τ) ⊢⇩C call₁ ⇛ call₂⟧ ⟹ Call src₂ DotCall call₂ = expr₂› and 1 goal remains*) using OclAnyDotCallN.hyps (*‹Γ ⊢ src₁ ⇛ src₂› ‹Γ ⊢ src₁ ⇛ ?expr₂ ⟹ src₂ = ?expr₂› ‹Γ ⊢⇩E src₂ : τ› ‹τ ≤ OclAny[?] ∨ τ ≤ Tuple fmempty› ‹(Γ, τ) ⊢⇩C call₁ ⇛ call₂› ‹(Γ, τ) ⊢⇩C call₁ ⇛ ?call₂ ⟹ call₂ = ?call₂›*) any_has_not_element_type (*‹⟦element_type ?τ ?σ; ?τ ≤ OclAny[?] ∨ ?τ ≤ Tuple fmempty⟧ ⟹ False›*) typing_det (*‹⟦?Γ ⊢⇩E ?expr : ?τ; ?Γ ⊢⇩E ?expr : ?σ⟧ ⟹ ?τ = ?σ›*) by metis next (*goals: 1. ‹⋀Γ src₁ src₂ τ call₁ call₂ src₃ expr₂. ⟦Γ ⊢ src₁ ⇛ src₂; ⋀expr₂. Γ ⊢ src₁ ⇛ expr₂ ⟹ src₂ = expr₂; Γ ⊢⇩E src₂ : τ; OclVoid[?] ≤ τ; (Γ, to_required_type τ) ⊢⇩C call₁ ⇛ call₂; ⋀call₂'. (Γ, to_required_type τ) ⊢⇩C call₁ ⇛ call₂' ⟹ call₂ = call₂'; src₃ = TypeOperationCall src₂ DotCall OclAsTypeOp (to_required_type τ); Γ ⊢ Call src₁ SafeDotCall call₁ ⇛ expr₂⟧ ⟹ expr.If (OperationCall src₂ DotCall ((Inr ∘ Inl ∘ Inl) NotEqualOp) (map Literal [NullLiteral])) (Call src₃ DotCall call₂) (Literal NullLiteral) = expr₂› 2. ‹⋀Γ src₁ src₂ τ src₃ σ call₁ call₂ expr₂. ⟦Γ ⊢ src₁ ⇛ src₂; ⋀expr₂. Γ ⊢ src₁ ⇛ expr₂ ⟹ src₂ = expr₂; Γ ⊢⇩E src₂ : τ; τ ≤ OclAny[?] ∨ τ ≤ Tuple fmempty; src₃ = OperationCall src₂ DotCall ((Inl ∘ Inl) OclAsSetOp) []; Γ ⊢⇩E src₃ : σ; (Γ, σ) ⊢⇩C call₁ ⇛ call₂; ⋀call₂'. (Γ, σ) ⊢⇩C call₁ ⇛ call₂' ⟹ call₂ = call₂'; Γ ⊢ Call src₁ ArrowCall call₁ ⇛ expr₂⟧ ⟹ Call src₃ ArrowCall call₂ = expr₂› 3. ‹⋀Γ src₁ src₂ τ uu_ call₁ call₂ expr₂. ⟦Γ ⊢ src₁ ⇛ src₂; ⋀expr₂. Γ ⊢ src₁ ⇛ expr₂ ⟹ src₂ = expr₂; Γ ⊢⇩E src₂ : τ; element_type τ uu_; (Γ, τ) ⊢⇩C call₁ ⇛ call₂; ⋀call₂'. (Γ, τ) ⊢⇩C call₁ ⇛ call₂' ⟹ call₂ = call₂'; Γ ⊢ Call src₁ ArrowCall call₁ ⇛ expr₂⟧ ⟹ Call src₂ ArrowCall call₂ = expr₂› 4. ‹⋀Γ src₁ src₂ τ σ src₃ ρ call₁ call₂ expr₂. ⟦Γ ⊢ src₁ ⇛ src₂; ⋀expr₂. Γ ⊢ src₁ ⇛ expr₂ ⟹ src₂ = expr₂; Γ ⊢⇩E src₂ : τ; element_type τ σ; OclVoid[?] ≤ σ; src₃ = TypeOperationCall src₂ ArrowCall SelectByKindOp (to_required_type σ); Γ ⊢⇩E src₃ : ρ; (Γ, ρ) ⊢⇩C call₁ ⇛ call₂; ⋀call₂'. (Γ, ρ) ⊢⇩C call₁ ⇛ call₂' ⟹ call₂ = call₂'; Γ ⊢ Call src₁ SafeArrowCall call₁ ⇛ expr₂⟧ ⟹ Call src₃ ArrowCall call₂ = expr₂› 5. ‹⋀Γ src₁ src₂ τ σ call₁ call₂ it expr₂. ⟦Γ ⊢ src₁ ⇛ src₂; ⋀expr₂. Γ ⊢ src₁ ⇛ expr₂ ⟹ src₂ = expr₂; Γ ⊢⇩E src₂ : τ; element_type τ σ; (Γ, σ) ⊢⇩C call₁ ⇛ call₂; ⋀call₂'. (Γ, σ) ⊢⇩C call₁ ⇛ call₂' ⟹ call₂ = call₂'; it = new_vname Γ; Γ ⊢ Call src₁ DotCall call₁ ⇛ expr₂⟧ ⟹ CollectIteratorCall src₂ ArrowCall [it] (Some σ) (Call (Var it) DotCall call₂) = expr₂› 6. ‹⋀Γ src₁ src₂ τ σ ρ src₃ call₁ call₂ it expr₂. ⟦Γ ⊢ src₁ ⇛ src₂; ⋀expr₂. Γ ⊢ src₁ ⇛ expr₂ ⟹ src₂ = expr₂; Γ ⊢⇩E src₂ : τ; element_type τ σ; OclVoid[?] ≤ σ; ρ = to_required_type σ; src₃ = TypeOperationCall src₂ ArrowCall SelectByKindOp ρ; (Γ, ρ) ⊢⇩C call₁ ⇛ call₂; ⋀call₂'. (Γ, ρ) ⊢⇩C call₁ ⇛ call₂' ⟹ call₂ = call₂'; it = new_vname Γ; Γ ⊢ Call src₁ SafeDotCall call₁ ⇛ expr₂⟧ ⟹ CollectIteratorCall src₃ ArrowCall [it] (Some ρ) (Call (Var it) DotCall call₂) = expr₂› 7. ‹⋀Γ τ op ty call₂. (Γ, τ) ⊢⇩C TypeOperation op ty ⇛ call₂ ⟹ TypeOperation op ty = call₂› 8. ‹⋀Γ τ attr call₂. (Γ, τ) ⊢⇩C Attribute attr ⇛ call₂ ⟹ Attribute attr = call₂› 9. ‹⋀Γ τ role from call₂. (Γ, τ) ⊢⇩C AssociationEnd role from ⇛ call₂ ⟹ AssociationEnd role from = call₂› 10. ‹⋀Γ τ 𝒜 from call₂. (Γ, τ) ⊢⇩C AssociationClass 𝒜 from ⇛ call₂ ⟹ AssociationClass 𝒜 from = call₂› 11. ‹⋀Γ τ role call₂. (Γ, τ) ⊢⇩C AssociationClassEnd role ⇛ call₂ ⟹ AssociationClassEnd role = call₂› 12. ‹⋀Γ params₁ params₂ τ op call₂. ⟦Γ ⊢⇩L params₁ ⇛ params₂; ⋀zs. Γ ⊢⇩L params₁ ⇛ zs ⟹ params₂ = zs; (Γ, τ) ⊢⇩C Operation op params₁ ⇛ call₂⟧ ⟹ Operation op params₂ = call₂› 13. ‹⋀Γ τ elem call₂. (Γ, τ) ⊢⇩C TupleElement elem ⇛ call₂ ⟹ TupleElement elem = call₂› 14. ‹⋀Γ res_init₁ res_init₂ σ its res res_t₁ body₁ res_t₂ body₂ τ call₂. ⟦Γ ⊢ res_init₁ ⇛ res_init₂; ⋀expr₂. Γ ⊢ res_init₁ ⇛ expr₂ ⟹ res_init₂ = expr₂; Γ ++⇩f fmap_of_list (map (λit. (it, σ)) its) ⊢ expr.Let res res_t₁ res_init₁ body₁ ⇛ expr.Let res res_t₂ res_init₂ body₂; ⋀expr₂. Γ ++⇩f fmap_of_list (map (λit. (it, σ)) its) ⊢ expr.Let res res_t₁ res_init₁ body₁ ⇛ expr₂ ⟹ expr.Let res res_t₂ res_init₂ body₂ = expr₂; (Γ, τ) ⊢⇩C Iterate its (Some σ) res res_t₁ res_init₁ body₁ ⇛ call₂⟧ ⟹ Iterate its (Some σ) res res_t₂ res_init₂ body₂ = call₂› 15. ‹⋀τ σ Γ res_init₁ res_init₂ its res res_t₁ body₁ res_t₂ body₂ call₂. ⟦element_type τ σ; Γ ⊢ res_init₁ ⇛ res_init₂; ⋀expr₂. Γ ⊢ res_init₁ ⇛ expr₂ ⟹ res_init₂ = expr₂; Γ ++⇩f fmap_of_list (map (λit. (it, σ)) its) ⊢ expr.Let res res_t₁ res_init₁ body₁ ⇛ expr.Let res res_t₂ res_init₂ body₂; ⋀expr₂. Γ ++⇩f fmap_of_list (map (λit. (it, σ)) its) ⊢ expr.Let res res_t₁ res_init₁ body₁ ⇛ expr₂ ⟹ expr.Let res res_t₂ res_init₂ body₂ = expr₂; (Γ, τ) ⊢⇩C Iterate its None res res_t₁ res_init₁ body₁ ⇛ call₂⟧ ⟹ Iterate its (Some σ) res res_t₂ res_init₂ body₂ = call₂› 16. ‹⋀Γ σ its body₁ body₂ τ iter call₂. ⟦Γ ++⇩f fmap_of_list (map (λit. (it, σ)) its) ⊢ body₁ ⇛ body₂; ⋀expr₂. Γ ++⇩f fmap_of_list (map (λit. (it, σ)) its) ⊢ body₁ ⇛ expr₂ ⟹ body₂ = expr₂; (Γ, τ) ⊢⇩C Iterator iter its (Some σ) body₁ ⇛ call₂⟧ ⟹ Iterator iter its (Some σ) body₂ = call₂› 17. ‹⋀τ σ Γ its body₁ body₂ iter call₂. ⟦element_type τ σ; Γ ++⇩f fmap_of_list (map (λit. (it, σ)) its) ⊢ body₁ ⇛ body₂; ⋀expr₂. Γ ++⇩f fmap_of_list (map (λit. (it, σ)) its) ⊢ body₁ ⇛ expr₂ ⟹ body₂ = expr₂; (Γ, τ) ⊢⇩C Iterator iter its None body₁ ⇛ call₂⟧ ⟹ Iterator iter its (Some σ) body₂ = call₂› 18. ‹⋀Γ zs. Γ ⊢⇩L [] ⇛ zs ⟹ [] = zs› 19. ‹⋀Γ x y xs ys zs. ⟦Γ ⊢ x ⇛ y; ⋀expr₂. Γ ⊢ x ⇛ expr₂ ⟹ y = expr₂; Γ ⊢⇩L xs ⇛ ys; ⋀zs. Γ ⊢⇩L xs ⇛ zs ⟹ ys = zs; Γ ⊢⇩L x # xs ⇛ zs⟧ ⟹ y # ys = zs›*) case (OclAnySafeDotCallN Γ src₁ src₂ τ call₁ call₂) (*‹Γ ⊢ src₁ ⇛ src₂› ‹Γ ⊢ src₁ ⇛ ?expr₂ ⟹ src₂ = ?expr₂› ‹Γ ⊢⇩E src₂ : τ› ‹OclVoid[?] ≤ τ› ‹(Γ::String.literal ⇀⇩f 'a OCL_Types.type, to_required_type (τ::'a OCL_Types.type)) ⊢⇩C (call₁::'a call_expr) ⇛ (call₂::'a call_expr)› ‹(Γ::String.literal ⇀⇩f 'a OCL_Types.type, to_required_type (τ::'a OCL_Types.type)) ⊢⇩C (call₁::'a call_expr) ⇛ (?call₂::'a call_expr) ⟹ (call₂::'a call_expr) = ?call₂› ‹src₃_ = TypeOperationCall src₂ DotCall OclAsTypeOp (to_required_type τ)› ‹Γ ⊢ Call src₁ SafeDotCall call₁ ⇛ expr₂›*) show "?case" (*goal: ‹expr.If (OperationCall src₂ DotCall ((Inr ∘ Inl ∘ Inl) NotEqualOp) (map Literal [NullLiteral])) (Call src₃_ DotCall call₂) (Literal NullLiteral) = expr₂›*) apply (insert OclAnySafeDotCallN.prems (*‹(Γ::String.literal ⇀⇩f 'a OCL_Types.type) ⊢ Call (src₁::'a expr) SafeDotCall (call₁::'a call_expr) ⇛ (expr₂::'a expr)›*)) (*goal: ‹expr.If (OperationCall (src₂::'a expr) DotCall ((Inr ∘ Inl ∘ Inl) NotEqualOp) (map Literal [NullLiteral])) (Call (src₃_::'a expr) DotCall (call₂::'a call_expr)) (Literal NullLiteral) = (expr₂::'a expr)›*) apply (erule SafeDotCallNE (*‹⟦?Γ ⊢ Call ?src SafeDotCall ?call ⇛ ?b; ⋀src₂ τ call₂. ⟦?b = expr.If (OperationCall src₂ DotCall (Inr (Inl (Inl NotEqualOp))) [Literal NullLiteral]) (Call (TypeOperationCall src₂ DotCall OclAsTypeOp (to_required_type τ)) DotCall call₂) (Literal NullLiteral); ?Γ ⊢ ?src ⇛ src₂; ?Γ ⊢⇩E src₂ : τ; OclVoid[?] ≤ τ; (?Γ, to_required_type τ) ⊢⇩C ?call ⇛ call₂⟧ ⟹ ?P; ⋀src₂ τ σ call₂. ⟦?b = CollectIteratorCall (TypeOperationCall src₂ ArrowCall SelectByKindOp (to_required_type σ)) ArrowCall [new_vname ?Γ] (Some (to_required_type σ)) (Call (Var (new_vname ?Γ)) DotCall call₂); ?Γ ⊢ ?src ⇛ src₂; ?Γ ⊢⇩E src₂ : τ; element_type τ σ; OclVoid[?] ≤ σ; (?Γ, to_required_type σ) ⊢⇩C ?call ⇛ call₂⟧ ⟹ ?P⟧ ⟹ ?P›*)) (*goal: ‹Γ ⊢ Call src₁ SafeDotCall call₁ ⇛ expr₂ ⟹ expr.If (OperationCall src₂ DotCall ((Inr ∘ Inl ∘ Inl) NotEqualOp) (map Literal [NullLiteral])) (Call src₃_ DotCall call₂) (Literal NullLiteral) = expr₂›*) using OclAnySafeDotCallN.hyps (*‹Γ ⊢ src₁ ⇛ src₂› ‹Γ ⊢ src₁ ⇛ ?expr₂ ⟹ src₂ = ?expr₂› ‹Γ ⊢⇩E src₂ : τ› ‹OclVoid[?] ≤ τ› ‹(Γ, to_required_type τ) ⊢⇩C call₁ ⇛ call₂› ‹(Γ, to_required_type τ) ⊢⇩C call₁ ⇛ ?call₂ ⟹ call₂ = ?call₂› ‹src₃_ = TypeOperationCall src₂ DotCall OclAsTypeOp (to_required_type τ)›*) typing_det (*‹⟦(?Γ::String.literal ⇀⇩f ?'a OCL_Types.type) ⊢⇩E (?expr::?'a expr) : (?τ::?'a OCL_Types.type); ?Γ ⊢⇩E ?expr : (?σ::?'a OCL_Types.type)⟧ ⟹ ?τ = ?σ›*) comp_apply (*‹(?f ∘ ?g) ?x = ?f (?g ?x)›*) apply (metis (no_types, lifting) list.simps( (*‹map ?f [] = []›*) 8) list.simps( (*‹map ?f (?x21.0 # ?x22.0) = ?f ?x21.0 # map ?f ?x22.0›*) 9)) (*top goal: ‹⋀src₂' τ call₂. ⟦expr₂ = expr.If (OperationCall src₂' DotCall (Inr (Inl (Inl NotEqualOp))) [Literal NullLiteral]) (Call (TypeOperationCall src₂' DotCall OclAsTypeOp (to_required_type τ)) DotCall call₂) (Literal NullLiteral); Γ ⊢ src₁ ⇛ src₂'; Γ ⊢⇩E src₂' : τ; OclVoid[?] ≤ τ; (Γ, to_required_type τ) ⊢⇩C call₁ ⇛ call₂⟧ ⟹ expr.If (OperationCall src₂ DotCall ((Inr ∘ Inl ∘ Inl) NotEqualOp) (map Literal [NullLiteral])) (Call src₃_ DotCall call₂) (Literal NullLiteral) = expr₂› and 1 goal remains*) using OclAnySafeDotCallN.hyps (*‹Γ ⊢ src₁ ⇛ src₂› ‹Γ ⊢ src₁ ⇛ ?expr₂ ⟹ src₂ = ?expr₂› ‹Γ ⊢⇩E src₂ : τ› ‹OclVoid[?] ≤ τ› ‹(Γ::String.literal ⇀⇩f 'a OCL_Types.type, to_required_type (τ::'a OCL_Types.type)) ⊢⇩C (call₁::'a call_expr) ⇛ (call₂::'a call_expr)› ‹(Γ, to_required_type τ) ⊢⇩C call₁ ⇛ ?call₂ ⟹ call₂ = ?call₂› ‹(src₃_::'a expr) = TypeOperationCall (src₂::'a expr) DotCall OclAsTypeOp (to_required_type (τ::'a OCL_Types.type))›*) typing_det (*‹⟦?Γ ⊢⇩E ?expr : ?τ; ?Γ ⊢⇩E ?expr : ?σ⟧ ⟹ ?τ = ?σ›*) any_has_not_element_type' (*‹⟦element_type ?τ ?σ; OclVoid[?] ≤ ?τ⟧ ⟹ False›*) by metis next (*goals: 1. ‹⋀Γ src₁ src₂ τ src₃ σ call₁ call₂ expr₂. ⟦Γ ⊢ src₁ ⇛ src₂; ⋀expr₂. Γ ⊢ src₁ ⇛ expr₂ ⟹ src₂ = expr₂; Γ ⊢⇩E src₂ : τ; τ ≤ OclAny[?] ∨ τ ≤ Tuple fmempty; src₃ = OperationCall src₂ DotCall ((Inl ∘ Inl) OclAsSetOp) []; Γ ⊢⇩E src₃ : σ; (Γ, σ) ⊢⇩C call₁ ⇛ call₂; ⋀call₂'. (Γ, σ) ⊢⇩C call₁ ⇛ call₂' ⟹ call₂ = call₂'; Γ ⊢ Call src₁ ArrowCall call₁ ⇛ expr₂⟧ ⟹ Call src₃ ArrowCall call₂ = expr₂› 2. ‹⋀Γ src₁ src₂ τ uu_ call₁ call₂ expr₂. ⟦Γ ⊢ src₁ ⇛ src₂; ⋀expr₂. Γ ⊢ src₁ ⇛ expr₂ ⟹ src₂ = expr₂; Γ ⊢⇩E src₂ : τ; element_type τ uu_; (Γ, τ) ⊢⇩C call₁ ⇛ call₂; ⋀call₂'. (Γ, τ) ⊢⇩C call₁ ⇛ call₂' ⟹ call₂ = call₂'; Γ ⊢ Call src₁ ArrowCall call₁ ⇛ expr₂⟧ ⟹ Call src₂ ArrowCall call₂ = expr₂› 3. ‹⋀Γ src₁ src₂ τ σ src₃ ρ call₁ call₂ expr₂. ⟦Γ ⊢ src₁ ⇛ src₂; ⋀expr₂. Γ ⊢ src₁ ⇛ expr₂ ⟹ src₂ = expr₂; Γ ⊢⇩E src₂ : τ; element_type τ σ; OclVoid[?] ≤ σ; src₃ = TypeOperationCall src₂ ArrowCall SelectByKindOp (to_required_type σ); Γ ⊢⇩E src₃ : ρ; (Γ, ρ) ⊢⇩C call₁ ⇛ call₂; ⋀call₂'. (Γ, ρ) ⊢⇩C call₁ ⇛ call₂' ⟹ call₂ = call₂'; Γ ⊢ Call src₁ SafeArrowCall call₁ ⇛ expr₂⟧ ⟹ Call src₃ ArrowCall call₂ = expr₂› 4. ‹⋀Γ src₁ src₂ τ σ call₁ call₂ it expr₂. ⟦Γ ⊢ src₁ ⇛ src₂; ⋀expr₂. Γ ⊢ src₁ ⇛ expr₂ ⟹ src₂ = expr₂; Γ ⊢⇩E src₂ : τ; element_type τ σ; (Γ, σ) ⊢⇩C call₁ ⇛ call₂; ⋀call₂'. (Γ, σ) ⊢⇩C call₁ ⇛ call₂' ⟹ call₂ = call₂'; it = new_vname Γ; Γ ⊢ Call src₁ DotCall call₁ ⇛ expr₂⟧ ⟹ CollectIteratorCall src₂ ArrowCall [it] (Some σ) (Call (Var it) DotCall call₂) = expr₂› 5. ‹⋀Γ src₁ src₂ τ σ ρ src₃ call₁ call₂ it expr₂. ⟦Γ ⊢ src₁ ⇛ src₂; ⋀expr₂. Γ ⊢ src₁ ⇛ expr₂ ⟹ src₂ = expr₂; Γ ⊢⇩E src₂ : τ; element_type τ σ; OclVoid[?] ≤ σ; ρ = to_required_type σ; src₃ = TypeOperationCall src₂ ArrowCall SelectByKindOp ρ; (Γ, ρ) ⊢⇩C call₁ ⇛ call₂; ⋀call₂'. (Γ, ρ) ⊢⇩C call₁ ⇛ call₂' ⟹ call₂ = call₂'; it = new_vname Γ; Γ ⊢ Call src₁ SafeDotCall call₁ ⇛ expr₂⟧ ⟹ CollectIteratorCall src₃ ArrowCall [it] (Some ρ) (Call (Var it) DotCall call₂) = expr₂› 6. ‹⋀Γ τ op ty call₂. (Γ, τ) ⊢⇩C TypeOperation op ty ⇛ call₂ ⟹ TypeOperation op ty = call₂› 7. ‹⋀Γ τ attr call₂. (Γ, τ) ⊢⇩C Attribute attr ⇛ call₂ ⟹ Attribute attr = call₂› 8. ‹⋀Γ τ role from call₂. (Γ, τ) ⊢⇩C AssociationEnd role from ⇛ call₂ ⟹ AssociationEnd role from = call₂› 9. ‹⋀Γ τ 𝒜 from call₂. (Γ, τ) ⊢⇩C AssociationClass 𝒜 from ⇛ call₂ ⟹ AssociationClass 𝒜 from = call₂› 10. ‹⋀Γ τ role call₂. (Γ, τ) ⊢⇩C AssociationClassEnd role ⇛ call₂ ⟹ AssociationClassEnd role = call₂› 11. ‹⋀Γ params₁ params₂ τ op call₂. ⟦Γ ⊢⇩L params₁ ⇛ params₂; ⋀zs. Γ ⊢⇩L params₁ ⇛ zs ⟹ params₂ = zs; (Γ, τ) ⊢⇩C Operation op params₁ ⇛ call₂⟧ ⟹ Operation op params₂ = call₂› 12. ‹⋀Γ τ elem call₂. (Γ, τ) ⊢⇩C TupleElement elem ⇛ call₂ ⟹ TupleElement elem = call₂› 13. ‹⋀Γ res_init₁ res_init₂ σ its res res_t₁ body₁ res_t₂ body₂ τ call₂. ⟦Γ ⊢ res_init₁ ⇛ res_init₂; ⋀expr₂. Γ ⊢ res_init₁ ⇛ expr₂ ⟹ res_init₂ = expr₂; Γ ++⇩f fmap_of_list (map (λit. (it, σ)) its) ⊢ expr.Let res res_t₁ res_init₁ body₁ ⇛ expr.Let res res_t₂ res_init₂ body₂; ⋀expr₂. Γ ++⇩f fmap_of_list (map (λit. (it, σ)) its) ⊢ expr.Let res res_t₁ res_init₁ body₁ ⇛ expr₂ ⟹ expr.Let res res_t₂ res_init₂ body₂ = expr₂; (Γ, τ) ⊢⇩C Iterate its (Some σ) res res_t₁ res_init₁ body₁ ⇛ call₂⟧ ⟹ Iterate its (Some σ) res res_t₂ res_init₂ body₂ = call₂› 14. ‹⋀τ σ Γ res_init₁ res_init₂ its res res_t₁ body₁ res_t₂ body₂ call₂. ⟦element_type τ σ; Γ ⊢ res_init₁ ⇛ res_init₂; ⋀expr₂. Γ ⊢ res_init₁ ⇛ expr₂ ⟹ res_init₂ = expr₂; Γ ++⇩f fmap_of_list (map (λit. (it, σ)) its) ⊢ expr.Let res res_t₁ res_init₁ body₁ ⇛ expr.Let res res_t₂ res_init₂ body₂; ⋀expr₂. Γ ++⇩f fmap_of_list (map (λit. (it, σ)) its) ⊢ expr.Let res res_t₁ res_init₁ body₁ ⇛ expr₂ ⟹ expr.Let res res_t₂ res_init₂ body₂ = expr₂; (Γ, τ) ⊢⇩C Iterate its None res res_t₁ res_init₁ body₁ ⇛ call₂⟧ ⟹ Iterate its (Some σ) res res_t₂ res_init₂ body₂ = call₂› 15. ‹⋀Γ σ its body₁ body₂ τ iter call₂. ⟦Γ ++⇩f fmap_of_list (map (λit. (it, σ)) its) ⊢ body₁ ⇛ body₂; ⋀expr₂. Γ ++⇩f fmap_of_list (map (λit. (it, σ)) its) ⊢ body₁ ⇛ expr₂ ⟹ body₂ = expr₂; (Γ, τ) ⊢⇩C Iterator iter its (Some σ) body₁ ⇛ call₂⟧ ⟹ Iterator iter its (Some σ) body₂ = call₂› 16. ‹⋀τ σ Γ its body₁ body₂ iter call₂. ⟦element_type τ σ; Γ ++⇩f fmap_of_list (map (λit. (it, σ)) its) ⊢ body₁ ⇛ body₂; ⋀expr₂. Γ ++⇩f fmap_of_list (map (λit. (it, σ)) its) ⊢ body₁ ⇛ expr₂ ⟹ body₂ = expr₂; (Γ, τ) ⊢⇩C Iterator iter its None body₁ ⇛ call₂⟧ ⟹ Iterator iter its (Some σ) body₂ = call₂› 17. ‹⋀Γ zs. Γ ⊢⇩L [] ⇛ zs ⟹ [] = zs› 18. ‹⋀Γ x y xs ys zs. ⟦Γ ⊢ x ⇛ y; ⋀expr₂. Γ ⊢ x ⇛ expr₂ ⟹ y = expr₂; Γ ⊢⇩L xs ⇛ ys; ⋀zs. Γ ⊢⇩L xs ⇛ zs ⟹ ys = zs; Γ ⊢⇩L x # xs ⇛ zs⟧ ⟹ y # ys = zs›*) case (OclAnyArrowCallN Γ src₁ src₂ τ src₃ σ call₁ call₂) (*‹Γ ⊢ src₁ ⇛ src₂› ‹(Γ::String.literal ⇀⇩f 'a::ocl_object_model OCL_Types.type) ⊢ (src₁::'a::ocl_object_model expr) ⇛ (?expr₂::'a::ocl_object_model expr) ⟹ (src₂::'a::ocl_object_model expr) = ?expr₂› ‹Γ ⊢⇩E src₂ : τ› ‹τ ≤ OclAny[?] ∨ τ ≤ Tuple fmempty› ‹src₃ = OperationCall src₂ DotCall ((Inl ∘ Inl) OclAsSetOp) []› ‹(Γ::String.literal ⇀⇩f 'a OCL_Types.type) ⊢⇩E (src₃::'a expr) : (σ::'a OCL_Types.type)› ‹(Γ, σ) ⊢⇩C call₁ ⇛ call₂› ‹(Γ, σ) ⊢⇩C call₁ ⇛ ?call₂ ⟹ call₂ = ?call₂› ‹(Γ::String.literal ⇀⇩f 'a OCL_Types.type) ⊢ Call (src₁::'a expr) ArrowCall (call₁::'a call_expr) ⇛ (expr₂::'a expr)›*) show "?case" (*goal: ‹Call (src₃::'a expr) ArrowCall (call₂::'a call_expr) = (expr₂::'a expr)›*) apply (insert OclAnyArrowCallN.prems (*‹Γ ⊢ Call src₁ ArrowCall call₁ ⇛ expr₂›*)) (*goal: ‹Call src₃ ArrowCall call₂ = expr₂›*) apply (erule ArrowCallNE (*‹⟦?Γ ⊢ Call ?src ArrowCall ?call ⇛ ?b; ⋀src₂ τ σ call₂. ⟦?b = Call (OperationCall src₂ DotCall (Inl (Inl OclAsSetOp)) []) ArrowCall call₂; ?Γ ⊢ ?src ⇛ src₂; ?Γ ⊢⇩E src₂ : τ; τ ≤ OclAny[?] ∨ τ ≤ Tuple fmempty; ?Γ ⊢⇩E OperationCall src₂ DotCall (Inl (Inl OclAsSetOp)) [] : σ; (?Γ, σ) ⊢⇩C ?call ⇛ call₂⟧ ⟹ ?P; ⋀src₂ τ uu_ call₂. ⟦?b = Call src₂ ArrowCall call₂; ?Γ ⊢ ?src ⇛ src₂; ?Γ ⊢⇩E src₂ : τ; element_type τ uu_; (?Γ, τ) ⊢⇩C ?call ⇛ call₂⟧ ⟹ ?P⟧ ⟹ ?P›*)) (*goal: ‹Γ ⊢ Call src₁ ArrowCall call₁ ⇛ expr₂ ⟹ Call src₃ ArrowCall call₂ = expr₂›*) using OclAnyArrowCallN.hyps (*‹Γ ⊢ src₁ ⇛ src₂› ‹Γ ⊢ src₁ ⇛ ?expr₂ ⟹ src₂ = ?expr₂› ‹Γ ⊢⇩E src₂ : τ› ‹τ ≤ OclAny[?] ∨ τ ≤ Tuple fmempty› ‹src₃ = OperationCall src₂ DotCall ((Inl ∘ Inl) OclAsSetOp) []› ‹(Γ::String.literal ⇀⇩f 'a::ocl_object_model OCL_Types.type) ⊢⇩E (src₃::'a::ocl_object_model expr) : (σ::'a::ocl_object_model OCL_Types.type)› ‹(Γ::String.literal ⇀⇩f 'a OCL_Types.type, σ::'a OCL_Types.type) ⊢⇩C (call₁::'a call_expr) ⇛ (call₂::'a call_expr)› ‹(Γ::String.literal ⇀⇩f 'a OCL_Types.type, σ::'a OCL_Types.type) ⊢⇩C (call₁::'a call_expr) ⇛ (?call₂::'a call_expr) ⟹ (call₂::'a call_expr) = ?call₂›*) typing_det (*‹⟦?Γ ⊢⇩E ?expr : ?τ; ?Γ ⊢⇩E ?expr : ?σ⟧ ⟹ ?τ = ?σ›*) comp_apply (*‹(?f ∘ ?g) ?x = ?f (?g ?x)›*) apply metis (*top goal: ‹⋀src₂ τ σ call₂. ⟦expr₂ = Call (OperationCall src₂ DotCall (Inl (Inl OclAsSetOp)) []) ArrowCall call₂; Γ ⊢ src₁ ⇛ src₂; Γ ⊢⇩E src₂ : τ; τ ≤ OclAny[?] ∨ τ ≤ Tuple fmempty; Γ ⊢⇩E OperationCall src₂ DotCall (Inl (Inl OclAsSetOp)) [] : σ; (Γ, σ) ⊢⇩C call₁ ⇛ call₂⟧ ⟹ Call src₃ ArrowCall call₂ = expr₂› and 1 goal remains*) using OclAnyArrowCallN.hyps (*‹Γ ⊢ src₁ ⇛ src₂› ‹Γ ⊢ src₁ ⇛ ?expr₂ ⟹ src₂ = ?expr₂› ‹(Γ::String.literal ⇀⇩f 'a OCL_Types.type) ⊢⇩E (src₂::'a expr) : (τ::'a OCL_Types.type)› ‹(τ::'a::ocl_object_model OCL_Types.type) ≤ OclAny[?] ∨ τ ≤ Tuple fmempty› ‹src₃ = OperationCall src₂ DotCall ((Inl ∘ Inl) OclAsSetOp) []› ‹Γ ⊢⇩E src₃ : σ› ‹(Γ, σ) ⊢⇩C call₁ ⇛ call₂› ‹(Γ, σ) ⊢⇩C call₁ ⇛ ?call₂ ⟹ call₂ = ?call₂›*) typing_det (*‹⟦?Γ ⊢⇩E ?expr : ?τ; ?Γ ⊢⇩E ?expr : ?σ⟧ ⟹ ?τ = ?σ›*) any_has_not_element_type (*‹⟦element_type (?τ::?'a::order OCL_Types.type) (?σ::?'a::order OCL_Types.type); ?τ ≤ OclAny[?] ∨ ?τ ≤ Tuple fmempty⟧ ⟹ False›*) by metis next (*goals: 1. ‹⋀Γ src₁ src₂ τ uu_ call₁ call₂ expr₂. ⟦Γ ⊢ src₁ ⇛ src₂; ⋀expr₂. Γ ⊢ src₁ ⇛ expr₂ ⟹ src₂ = expr₂; Γ ⊢⇩E src₂ : τ; element_type τ uu_; (Γ, τ) ⊢⇩C call₁ ⇛ call₂; ⋀call₂'. (Γ, τ) ⊢⇩C call₁ ⇛ call₂' ⟹ call₂ = call₂'; Γ ⊢ Call src₁ ArrowCall call₁ ⇛ expr₂⟧ ⟹ Call src₂ ArrowCall call₂ = expr₂› 2. ‹⋀Γ src₁ src₂ τ σ src₃ ρ call₁ call₂ expr₂. ⟦Γ ⊢ src₁ ⇛ src₂; ⋀expr₂. Γ ⊢ src₁ ⇛ expr₂ ⟹ src₂ = expr₂; Γ ⊢⇩E src₂ : τ; element_type τ σ; OclVoid[?] ≤ σ; src₃ = TypeOperationCall src₂ ArrowCall SelectByKindOp (to_required_type σ); Γ ⊢⇩E src₃ : ρ; (Γ, ρ) ⊢⇩C call₁ ⇛ call₂; ⋀call₂'. (Γ, ρ) ⊢⇩C call₁ ⇛ call₂' ⟹ call₂ = call₂'; Γ ⊢ Call src₁ SafeArrowCall call₁ ⇛ expr₂⟧ ⟹ Call src₃ ArrowCall call₂ = expr₂› 3. ‹⋀Γ src₁ src₂ τ σ call₁ call₂ it expr₂. ⟦Γ ⊢ src₁ ⇛ src₂; ⋀expr₂. Γ ⊢ src₁ ⇛ expr₂ ⟹ src₂ = expr₂; Γ ⊢⇩E src₂ : τ; element_type τ σ; (Γ, σ) ⊢⇩C call₁ ⇛ call₂; ⋀call₂'. (Γ, σ) ⊢⇩C call₁ ⇛ call₂' ⟹ call₂ = call₂'; it = new_vname Γ; Γ ⊢ Call src₁ DotCall call₁ ⇛ expr₂⟧ ⟹ CollectIteratorCall src₂ ArrowCall [it] (Some σ) (Call (Var it) DotCall call₂) = expr₂› 4. ‹⋀Γ src₁ src₂ τ σ ρ src₃ call₁ call₂ it expr₂. ⟦Γ ⊢ src₁ ⇛ src₂; ⋀expr₂. Γ ⊢ src₁ ⇛ expr₂ ⟹ src₂ = expr₂; Γ ⊢⇩E src₂ : τ; element_type τ σ; OclVoid[?] ≤ σ; ρ = to_required_type σ; src₃ = TypeOperationCall src₂ ArrowCall SelectByKindOp ρ; (Γ, ρ) ⊢⇩C call₁ ⇛ call₂; ⋀call₂'. (Γ, ρ) ⊢⇩C call₁ ⇛ call₂' ⟹ call₂ = call₂'; it = new_vname Γ; Γ ⊢ Call src₁ SafeDotCall call₁ ⇛ expr₂⟧ ⟹ CollectIteratorCall src₃ ArrowCall [it] (Some ρ) (Call (Var it) DotCall call₂) = expr₂› 5. ‹⋀Γ τ op ty call₂. (Γ, τ) ⊢⇩C TypeOperation op ty ⇛ call₂ ⟹ TypeOperation op ty = call₂› 6. ‹⋀Γ τ attr call₂. (Γ, τ) ⊢⇩C Attribute attr ⇛ call₂ ⟹ Attribute attr = call₂› 7. ‹⋀Γ τ role from call₂. (Γ, τ) ⊢⇩C AssociationEnd role from ⇛ call₂ ⟹ AssociationEnd role from = call₂› 8. ‹⋀Γ τ 𝒜 from call₂. (Γ, τ) ⊢⇩C AssociationClass 𝒜 from ⇛ call₂ ⟹ AssociationClass 𝒜 from = call₂› 9. ‹⋀Γ τ role call₂. (Γ, τ) ⊢⇩C AssociationClassEnd role ⇛ call₂ ⟹ AssociationClassEnd role = call₂› 10. ‹⋀Γ params₁ params₂ τ op call₂. ⟦Γ ⊢⇩L params₁ ⇛ params₂; ⋀zs. Γ ⊢⇩L params₁ ⇛ zs ⟹ params₂ = zs; (Γ, τ) ⊢⇩C Operation op params₁ ⇛ call₂⟧ ⟹ Operation op params₂ = call₂› 11. ‹⋀Γ τ elem call₂. (Γ, τ) ⊢⇩C TupleElement elem ⇛ call₂ ⟹ TupleElement elem = call₂› 12. ‹⋀Γ res_init₁ res_init₂ σ its res res_t₁ body₁ res_t₂ body₂ τ call₂. ⟦Γ ⊢ res_init₁ ⇛ res_init₂; ⋀expr₂. Γ ⊢ res_init₁ ⇛ expr₂ ⟹ res_init₂ = expr₂; Γ ++⇩f fmap_of_list (map (λit. (it, σ)) its) ⊢ expr.Let res res_t₁ res_init₁ body₁ ⇛ expr.Let res res_t₂ res_init₂ body₂; ⋀expr₂. Γ ++⇩f fmap_of_list (map (λit. (it, σ)) its) ⊢ expr.Let res res_t₁ res_init₁ body₁ ⇛ expr₂ ⟹ expr.Let res res_t₂ res_init₂ body₂ = expr₂; (Γ, τ) ⊢⇩C Iterate its (Some σ) res res_t₁ res_init₁ body₁ ⇛ call₂⟧ ⟹ Iterate its (Some σ) res res_t₂ res_init₂ body₂ = call₂› 13. ‹⋀τ σ Γ res_init₁ res_init₂ its res res_t₁ body₁ res_t₂ body₂ call₂. ⟦element_type τ σ; Γ ⊢ res_init₁ ⇛ res_init₂; ⋀expr₂. Γ ⊢ res_init₁ ⇛ expr₂ ⟹ res_init₂ = expr₂; Γ ++⇩f fmap_of_list (map (λit. (it, σ)) its) ⊢ expr.Let res res_t₁ res_init₁ body₁ ⇛ expr.Let res res_t₂ res_init₂ body₂; ⋀expr₂. Γ ++⇩f fmap_of_list (map (λit. (it, σ)) its) ⊢ expr.Let res res_t₁ res_init₁ body₁ ⇛ expr₂ ⟹ expr.Let res res_t₂ res_init₂ body₂ = expr₂; (Γ, τ) ⊢⇩C Iterate its None res res_t₁ res_init₁ body₁ ⇛ call₂⟧ ⟹ Iterate its (Some σ) res res_t₂ res_init₂ body₂ = call₂› 14. ‹⋀Γ σ its body₁ body₂ τ iter call₂. ⟦Γ ++⇩f fmap_of_list (map (λit. (it, σ)) its) ⊢ body₁ ⇛ body₂; ⋀expr₂. Γ ++⇩f fmap_of_list (map (λit. (it, σ)) its) ⊢ body₁ ⇛ expr₂ ⟹ body₂ = expr₂; (Γ, τ) ⊢⇩C Iterator iter its (Some σ) body₁ ⇛ call₂⟧ ⟹ Iterator iter its (Some σ) body₂ = call₂› 15. ‹⋀τ σ Γ its body₁ body₂ iter call₂. ⟦element_type τ σ; Γ ++⇩f fmap_of_list (map (λit. (it, σ)) its) ⊢ body₁ ⇛ body₂; ⋀expr₂. Γ ++⇩f fmap_of_list (map (λit. (it, σ)) its) ⊢ body₁ ⇛ expr₂ ⟹ body₂ = expr₂; (Γ, τ) ⊢⇩C Iterator iter its None body₁ ⇛ call₂⟧ ⟹ Iterator iter its (Some σ) body₂ = call₂› 16. ‹⋀Γ zs. Γ ⊢⇩L [] ⇛ zs ⟹ [] = zs› 17. ‹⋀Γ x y xs ys zs. ⟦Γ ⊢ x ⇛ y; ⋀expr₂. Γ ⊢ x ⇛ expr₂ ⟹ y = expr₂; Γ ⊢⇩L xs ⇛ ys; ⋀zs. Γ ⊢⇩L xs ⇛ zs ⟹ ys = zs; Γ ⊢⇩L x # xs ⇛ zs⟧ ⟹ y # ys = zs›*) case (CollectionArrowCallN Γ src₁ src₂ τ uu call₁ call₂) (*‹Γ ⊢ src₁ ⇛ src₂› ‹Γ ⊢ src₁ ⇛ ?expr₂ ⟹ src₂ = ?expr₂› ‹(Γ::String.literal ⇀⇩f 'a::ocl_object_model OCL_Types.type) ⊢⇩E (src₂::'a::ocl_object_model expr) : (τ::'a::ocl_object_model OCL_Types.type)› ‹element_type τ uu› ‹(Γ, τ) ⊢⇩C call₁ ⇛ call₂› ‹(Γ, τ) ⊢⇩C call₁ ⇛ ?call₂ ⟹ call₂ = ?call₂› ‹Γ ⊢ Call src₁ ArrowCall call₁ ⇛ expr₂›*) show "?case" (*goal: ‹Call src₂ ArrowCall call₂ = expr₂›*) apply (insert CollectionArrowCallN.prems (*‹Γ ⊢ Call src₁ ArrowCall call₁ ⇛ expr₂›*)) (*goal: ‹Call src₂ ArrowCall call₂ = expr₂›*) apply (erule ArrowCallNE (*‹⟦?Γ ⊢ Call ?src ArrowCall ?call ⇛ ?b; ⋀src₂ τ σ call₂. ⟦?b = Call (OperationCall src₂ DotCall (Inl (Inl OclAsSetOp)) []) ArrowCall call₂; ?Γ ⊢ ?src ⇛ src₂; ?Γ ⊢⇩E src₂ : τ; τ ≤ OclAny[?] ∨ τ ≤ Tuple fmempty; ?Γ ⊢⇩E OperationCall src₂ DotCall (Inl (Inl OclAsSetOp)) [] : σ; (?Γ, σ) ⊢⇩C ?call ⇛ call₂⟧ ⟹ ?P; ⋀src₂ τ uu_ call₂. ⟦?b = Call src₂ ArrowCall call₂; ?Γ ⊢ ?src ⇛ src₂; ?Γ ⊢⇩E src₂ : τ; element_type τ uu_; (?Γ, τ) ⊢⇩C ?call ⇛ call₂⟧ ⟹ ?P⟧ ⟹ ?P›*)) (*goal: ‹Γ ⊢ Call src₁ ArrowCall call₁ ⇛ expr₂ ⟹ Call src₂ ArrowCall call₂ = expr₂›*) using CollectionArrowCallN.hyps (*‹Γ ⊢ src₁ ⇛ src₂› ‹Γ ⊢ src₁ ⇛ ?expr₂ ⟹ src₂ = ?expr₂› ‹Γ ⊢⇩E src₂ : τ› ‹element_type (τ::'a OCL_Types.type) (uu::'a OCL_Types.type)› ‹(Γ, τ) ⊢⇩C call₁ ⇛ call₂› ‹(Γ, τ) ⊢⇩C call₁ ⇛ ?call₂ ⟹ call₂ = ?call₂›*) typing_det (*‹⟦?Γ ⊢⇩E ?expr : ?τ; ?Γ ⊢⇩E ?expr : ?σ⟧ ⟹ ?τ = ?σ›*) any_has_not_element_type (*‹⟦element_type ?τ ?σ; ?τ ≤ OclAny[?] ∨ ?τ ≤ Tuple fmempty⟧ ⟹ False›*) apply metis (*top goal: ‹⋀(src₂'::'a expr) (τ::'a OCL_Types.type) (σ::'a OCL_Types.type) call₂::'a call_expr. ⟦(expr₂::'a expr) = Call (OperationCall src₂' DotCall (Inl (Inl OclAsSetOp)) []) ArrowCall call₂; (Γ::String.literal ⇀⇩f 'a OCL_Types.type) ⊢ (src₁::'a expr) ⇛ src₂'; Γ ⊢⇩E src₂' : τ; τ ≤ OclAny[?] ∨ τ ≤ Tuple fmempty; Γ ⊢⇩E OperationCall src₂' DotCall (Inl (Inl OclAsSetOp)) [] : σ; (Γ, σ) ⊢⇩C (call₁::'a call_expr) ⇛ call₂⟧ ⟹ Call (src₂::'a expr) ArrowCall (call₂::'a call_expr) = expr₂› and 1 goal remains*) using CollectionArrowCallN.hyps (*‹Γ ⊢ src₁ ⇛ src₂› ‹Γ ⊢ src₁ ⇛ ?expr₂ ⟹ src₂ = ?expr₂› ‹Γ ⊢⇩E src₂ : τ› ‹element_type τ uu› ‹(Γ, τ) ⊢⇩C call₁ ⇛ call₂› ‹(Γ::String.literal ⇀⇩f 'a OCL_Types.type, τ::'a OCL_Types.type) ⊢⇩C (call₁::'a call_expr) ⇛ (?call₂::'a call_expr) ⟹ (call₂::'a call_expr) = ?call₂›*) typing_det (*‹⟦?Γ ⊢⇩E ?expr : ?τ; ?Γ ⊢⇩E ?expr : ?σ⟧ ⟹ ?τ = ?σ›*) by metis next (*goals: 1. ‹⋀(Γ::String.literal ⇀⇩f 'a OCL_Types.type) (src₁::'a expr) (src₂::'a expr) (τ::'a OCL_Types.type) (σ::'a OCL_Types.type) (src₃::'a expr) (ρ::'a OCL_Types.type) (call₁::'a call_expr) (call₂::'a call_expr) expr₂::'a expr. ⟦Γ ⊢ src₁ ⇛ src₂; ⋀expr₂::'a expr. Γ ⊢ src₁ ⇛ expr₂ ⟹ src₂ = expr₂; Γ ⊢⇩E src₂ : τ; element_type τ σ; OclVoid[?] ≤ σ; src₃ = TypeOperationCall src₂ ArrowCall SelectByKindOp (to_required_type σ); Γ ⊢⇩E src₃ : ρ; (Γ, ρ) ⊢⇩C call₁ ⇛ call₂; ⋀call₂'::'a call_expr. (Γ, ρ) ⊢⇩C call₁ ⇛ call₂' ⟹ call₂ = call₂'; Γ ⊢ Call src₁ SafeArrowCall call₁ ⇛ expr₂⟧ ⟹ Call src₃ ArrowCall call₂ = expr₂› 2. ‹⋀(Γ::String.literal ⇀⇩f 'a OCL_Types.type) (src₁::'a expr) (src₂::'a expr) (τ::'a OCL_Types.type) (σ::'a OCL_Types.type) (call₁::'a call_expr) (call₂::'a call_expr) (it::String.literal) expr₂::'a expr. ⟦Γ ⊢ src₁ ⇛ src₂; ⋀expr₂::'a expr. Γ ⊢ src₁ ⇛ expr₂ ⟹ src₂ = expr₂; Γ ⊢⇩E src₂ : τ; element_type τ σ; (Γ, σ) ⊢⇩C call₁ ⇛ call₂; ⋀call₂'::'a call_expr. (Γ, σ) ⊢⇩C call₁ ⇛ call₂' ⟹ call₂ = call₂'; it = new_vname Γ; Γ ⊢ Call src₁ DotCall call₁ ⇛ expr₂⟧ ⟹ CollectIteratorCall src₂ ArrowCall [it] (Some σ) (Call (Var it) DotCall call₂) = expr₂› 3. ‹⋀(Γ::String.literal ⇀⇩f 'a OCL_Types.type) (src₁::'a expr) (src₂::'a expr) (τ::'a OCL_Types.type) (σ::'a OCL_Types.type) (ρ::'a OCL_Types.type) (src₃::'a expr) (call₁::'a call_expr) (call₂::'a call_expr) (it::String.literal) expr₂::'a expr. ⟦Γ ⊢ src₁ ⇛ src₂; ⋀expr₂::'a expr. Γ ⊢ src₁ ⇛ expr₂ ⟹ src₂ = expr₂; Γ ⊢⇩E src₂ : τ; element_type τ σ; OclVoid[?] ≤ σ; ρ = to_required_type σ; src₃ = TypeOperationCall src₂ ArrowCall SelectByKindOp ρ; (Γ, ρ) ⊢⇩C call₁ ⇛ call₂; ⋀call₂'::'a call_expr. (Γ, ρ) ⊢⇩C call₁ ⇛ call₂' ⟹ call₂ = call₂'; it = new_vname Γ; Γ ⊢ Call src₁ SafeDotCall call₁ ⇛ expr₂⟧ ⟹ CollectIteratorCall src₃ ArrowCall [it] (Some ρ) (Call (Var it) DotCall call₂) = expr₂› 4. ‹⋀(Γ::String.literal ⇀⇩f 'a OCL_Types.type) (τ::'a OCL_Types.type) (op::typeop) (ty::'a OCL_Types.type) call₂::'a call_expr. (Γ, τ) ⊢⇩C TypeOperation op ty ⇛ call₂ ⟹ TypeOperation op ty = call₂› 5. ‹⋀(Γ::String.literal ⇀⇩f 'a OCL_Types.type) (τ::'a OCL_Types.type) (attr::String.literal) call₂::'a call_expr. (Γ, τ) ⊢⇩C Attribute attr ⇛ call₂ ⟹ Attribute attr = call₂› 6. ‹⋀(Γ::String.literal ⇀⇩f 'a OCL_Types.type) (τ::'a OCL_Types.type) (role::String.literal option) (from::String.literal) call₂::'a call_expr. (Γ, τ) ⊢⇩C AssociationEnd role from ⇛ call₂ ⟹ AssociationEnd role from = call₂› 7. ‹⋀(Γ::String.literal ⇀⇩f 'a OCL_Types.type) (τ::'a OCL_Types.type) (𝒜::String.literal option) (from::'a) call₂::'a call_expr. (Γ, τ) ⊢⇩C AssociationClass 𝒜 from ⇛ call₂ ⟹ AssociationClass 𝒜 from = call₂› 8. ‹⋀(Γ::String.literal ⇀⇩f 'a OCL_Types.type) (τ::'a OCL_Types.type) (role::String.literal) call₂::'a call_expr. (Γ, τ) ⊢⇩C AssociationClassEnd role ⇛ call₂ ⟹ AssociationClassEnd role = call₂› 9. ‹⋀(Γ::String.literal ⇀⇩f 'a OCL_Types.type) (params₁::'a expr list) (params₂::'a expr list) (τ::'a OCL_Types.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) call₂::'a call_expr. ⟦Γ ⊢⇩L params₁ ⇛ params₂; ⋀zs::'a expr list. Γ ⊢⇩L params₁ ⇛ zs ⟹ params₂ = zs; (Γ, τ) ⊢⇩C Operation op params₁ ⇛ call₂⟧ ⟹ Operation op params₂ = call₂› 10. ‹⋀(Γ::String.literal ⇀⇩f 'a OCL_Types.type) (τ::'a OCL_Types.type) (elem::String.literal) call₂::'a call_expr. (Γ, τ) ⊢⇩C TupleElement elem ⇛ call₂ ⟹ TupleElement elem = call₂› 11. ‹⋀(Γ::String.literal ⇀⇩f 'a OCL_Types.type) (res_init₁::'a expr) (res_init₂::'a expr) (σ::'a OCL_Types.type) (its::String.literal list) (res::String.literal) (res_t₁::'a OCL_Types.type option) (body₁::'a expr) (res_t₂::'a OCL_Types.type option) (body₂::'a expr) (τ::'a OCL_Types.type) call₂::'a call_expr. ⟦Γ ⊢ res_init₁ ⇛ res_init₂; ⋀expr₂::'a expr. Γ ⊢ res_init₁ ⇛ expr₂ ⟹ res_init₂ = expr₂; Γ ++⇩f fmap_of_list (map (λit::String.literal. (it, σ)) its) ⊢ expr.Let res res_t₁ res_init₁ body₁ ⇛ expr.Let res res_t₂ res_init₂ body₂; ⋀expr₂::'a expr. Γ ++⇩f fmap_of_list (map (λit::String.literal. (it, σ)) its) ⊢ expr.Let res res_t₁ res_init₁ body₁ ⇛ expr₂ ⟹ expr.Let res res_t₂ res_init₂ body₂ = expr₂; (Γ, τ) ⊢⇩C Iterate its (Some σ) res res_t₁ res_init₁ body₁ ⇛ call₂⟧ ⟹ Iterate its (Some σ) res res_t₂ res_init₂ body₂ = call₂› 12. ‹⋀(τ::'a OCL_Types.type) (σ::'a OCL_Types.type) (Γ::String.literal ⇀⇩f 'a OCL_Types.type) (res_init₁::'a expr) (res_init₂::'a expr) (its::String.literal list) (res::String.literal) (res_t₁::'a OCL_Types.type option) (body₁::'a expr) (res_t₂::'a OCL_Types.type option) (body₂::'a expr) call₂::'a call_expr. ⟦element_type τ σ; Γ ⊢ res_init₁ ⇛ res_init₂; ⋀expr₂::'a expr. Γ ⊢ res_init₁ ⇛ expr₂ ⟹ res_init₂ = expr₂; Γ ++⇩f fmap_of_list (map (λit::String.literal. (it, σ)) its) ⊢ expr.Let res res_t₁ res_init₁ body₁ ⇛ expr.Let res res_t₂ res_init₂ body₂; ⋀expr₂::'a expr. Γ ++⇩f fmap_of_list (map (λit::String.literal. (it, σ)) its) ⊢ expr.Let res res_t₁ res_init₁ body₁ ⇛ expr₂ ⟹ expr.Let res res_t₂ res_init₂ body₂ = expr₂; (Γ, τ) ⊢⇩C Iterate its None res res_t₁ res_init₁ body₁ ⇛ call₂⟧ ⟹ Iterate its (Some σ) res res_t₂ res_init₂ body₂ = call₂› 13. ‹⋀(Γ::String.literal ⇀⇩f 'a OCL_Types.type) (σ::'a OCL_Types.type) (its::String.literal list) (body₁::'a expr) (body₂::'a expr) (τ::'a OCL_Types.type) (iter::iterator) call₂::'a call_expr. ⟦Γ ++⇩f fmap_of_list (map (λit::String.literal. (it, σ)) its) ⊢ body₁ ⇛ body₂; ⋀expr₂::'a expr. Γ ++⇩f fmap_of_list (map (λit::String.literal. (it, σ)) its) ⊢ body₁ ⇛ expr₂ ⟹ body₂ = expr₂; (Γ, τ) ⊢⇩C Iterator iter its (Some σ) body₁ ⇛ call₂⟧ ⟹ Iterator iter its (Some σ) body₂ = call₂› 14. ‹⋀(τ::'a OCL_Types.type) (σ::'a OCL_Types.type) (Γ::String.literal ⇀⇩f 'a OCL_Types.type) (its::String.literal list) (body₁::'a expr) (body₂::'a expr) (iter::iterator) call₂::'a call_expr. ⟦element_type τ σ; Γ ++⇩f fmap_of_list (map (λit::String.literal. (it, σ)) its) ⊢ body₁ ⇛ body₂; ⋀expr₂::'a expr. Γ ++⇩f fmap_of_list (map (λit::String.literal. (it, σ)) its) ⊢ body₁ ⇛ expr₂ ⟹ body₂ = expr₂; (Γ, τ) ⊢⇩C Iterator iter its None body₁ ⇛ call₂⟧ ⟹ Iterator iter its (Some σ) body₂ = call₂› 15. ‹⋀(Γ::String.literal ⇀⇩f 'a OCL_Types.type) zs::'a expr list. Γ ⊢⇩L [] ⇛ zs ⟹ [] = zs› 16. ‹⋀(Γ::String.literal ⇀⇩f 'a OCL_Types.type) (x::'a expr) (y::'a expr) (xs::'a expr list) (ys::'a expr list) zs::'a expr list. ⟦Γ ⊢ x ⇛ y; ⋀expr₂::'a expr. Γ ⊢ x ⇛ expr₂ ⟹ y = expr₂; Γ ⊢⇩L xs ⇛ ys; ⋀zs::'a expr list. Γ ⊢⇩L xs ⇛ zs ⟹ ys = zs; Γ ⊢⇩L x # xs ⇛ zs⟧ ⟹ y # ys = zs›*) case (CollectionSafeArrowCallN Γ src₁ src₂ τ σ src₃ ρ call₁ call₂) (*‹Γ ⊢ src₁ ⇛ src₂› ‹Γ ⊢ src₁ ⇛ ?expr₂ ⟹ src₂ = ?expr₂› ‹Γ ⊢⇩E src₂ : τ› ‹element_type τ σ› ‹OclVoid[?] ≤ (σ::'a::ocl_object_model OCL_Types.type)› ‹src₃ = TypeOperationCall src₂ ArrowCall SelectByKindOp (to_required_type σ)› ‹Γ ⊢⇩E src₃ : ρ› ‹(Γ, ρ) ⊢⇩C call₁ ⇛ call₂› ‹(Γ, ρ) ⊢⇩C call₁ ⇛ ?call₂ ⟹ call₂ = ?call₂› ‹Γ ⊢ Call src₁ SafeArrowCall call₁ ⇛ expr₂›*) show "?case" (*goal: ‹Call (src₃::'a expr) ArrowCall (call₂::'a call_expr) = (expr₂::'a expr)›*) apply (insert CollectionSafeArrowCallN.prems (*‹(Γ::String.literal ⇀⇩f 'a OCL_Types.type) ⊢ Call (src₁::'a expr) SafeArrowCall (call₁::'a call_expr) ⇛ (expr₂::'a expr)›*)) (*goal: ‹Call (src₃::'a expr) ArrowCall (call₂::'a call_expr) = (expr₂::'a expr)›*) apply (erule SafeArrowCallNE (*‹⟦?Γ ⊢ Call ?src SafeArrowCall ?call ⇛ ?b; ⋀src₂ τ σ ρ call₂. ⟦?b = Call (TypeOperationCall src₂ ArrowCall SelectByKindOp (to_required_type σ)) ArrowCall call₂; ?Γ ⊢ ?src ⇛ src₂; ?Γ ⊢⇩E src₂ : τ; element_type τ σ; OclVoid[?] ≤ σ; ?Γ ⊢⇩E TypeOperationCall src₂ ArrowCall SelectByKindOp (to_required_type σ) : ρ; (?Γ, ρ) ⊢⇩C ?call ⇛ call₂⟧ ⟹ ?P⟧ ⟹ ?P›*)) (*goal: ‹Γ ⊢ Call src₁ SafeArrowCall call₁ ⇛ expr₂ ⟹ Call src₃ ArrowCall call₂ = expr₂›*) using CollectionSafeArrowCallN.hyps (*‹(Γ::String.literal ⇀⇩f 'a OCL_Types.type) ⊢ (src₁::'a expr) ⇛ (src₂::'a expr)› ‹Γ ⊢ src₁ ⇛ ?expr₂ ⟹ src₂ = ?expr₂› ‹Γ ⊢⇩E src₂ : τ› ‹element_type τ σ› ‹OclVoid[?] ≤ σ› ‹src₃ = TypeOperationCall src₂ ArrowCall SelectByKindOp (to_required_type σ)› ‹Γ ⊢⇩E src₃ : ρ› ‹(Γ, ρ) ⊢⇩C call₁ ⇛ call₂› ‹(Γ, ρ) ⊢⇩C call₁ ⇛ ?call₂ ⟹ call₂ = ?call₂›*) typing_det (*‹⟦?Γ ⊢⇩E ?expr : ?τ; ?Γ ⊢⇩E ?expr : ?σ⟧ ⟹ ?τ = ?σ›*) element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) by metis next (*goals: 1. ‹⋀Γ src₁ src₂ τ σ call₁ call₂ it expr₂. ⟦Γ ⊢ src₁ ⇛ src₂; ⋀expr₂. Γ ⊢ src₁ ⇛ expr₂ ⟹ src₂ = expr₂; Γ ⊢⇩E src₂ : τ; element_type τ σ; (Γ, σ) ⊢⇩C call₁ ⇛ call₂; ⋀call₂'. (Γ, σ) ⊢⇩C call₁ ⇛ call₂' ⟹ call₂ = call₂'; it = new_vname Γ; Γ ⊢ Call src₁ DotCall call₁ ⇛ expr₂⟧ ⟹ CollectIteratorCall src₂ ArrowCall [it] (Some σ) (Call (Var it) DotCall call₂) = expr₂› 2. ‹⋀Γ src₁ src₂ τ σ ρ src₃ call₁ call₂ it expr₂. ⟦Γ ⊢ src₁ ⇛ src₂; ⋀expr₂. Γ ⊢ src₁ ⇛ expr₂ ⟹ src₂ = expr₂; Γ ⊢⇩E src₂ : τ; element_type τ σ; OclVoid[?] ≤ σ; ρ = to_required_type σ; src₃ = TypeOperationCall src₂ ArrowCall SelectByKindOp ρ; (Γ, ρ) ⊢⇩C call₁ ⇛ call₂; ⋀call₂'. (Γ, ρ) ⊢⇩C call₁ ⇛ call₂' ⟹ call₂ = call₂'; it = new_vname Γ; Γ ⊢ Call src₁ SafeDotCall call₁ ⇛ expr₂⟧ ⟹ CollectIteratorCall src₃ ArrowCall [it] (Some ρ) (Call (Var it) DotCall call₂) = expr₂› 3. ‹⋀Γ τ op ty call₂. (Γ, τ) ⊢⇩C TypeOperation op ty ⇛ call₂ ⟹ TypeOperation op ty = call₂› 4. ‹⋀Γ τ attr call₂. (Γ, τ) ⊢⇩C Attribute attr ⇛ call₂ ⟹ Attribute attr = call₂› 5. ‹⋀Γ τ role from call₂. (Γ, τ) ⊢⇩C AssociationEnd role from ⇛ call₂ ⟹ AssociationEnd role from = call₂› 6. ‹⋀Γ τ 𝒜 from call₂. (Γ, τ) ⊢⇩C AssociationClass 𝒜 from ⇛ call₂ ⟹ AssociationClass 𝒜 from = call₂› 7. ‹⋀Γ τ role call₂. (Γ, τ) ⊢⇩C AssociationClassEnd role ⇛ call₂ ⟹ AssociationClassEnd role = call₂› 8. ‹⋀Γ params₁ params₂ τ op call₂. ⟦Γ ⊢⇩L params₁ ⇛ params₂; ⋀zs. Γ ⊢⇩L params₁ ⇛ zs ⟹ params₂ = zs; (Γ, τ) ⊢⇩C Operation op params₁ ⇛ call₂⟧ ⟹ Operation op params₂ = call₂› 9. ‹⋀Γ τ elem call₂. (Γ, τ) ⊢⇩C TupleElement elem ⇛ call₂ ⟹ TupleElement elem = call₂› 10. ‹⋀Γ res_init₁ res_init₂ σ its res res_t₁ body₁ res_t₂ body₂ τ call₂. ⟦Γ ⊢ res_init₁ ⇛ res_init₂; ⋀expr₂. Γ ⊢ res_init₁ ⇛ expr₂ ⟹ res_init₂ = expr₂; Γ ++⇩f fmap_of_list (map (λit. (it, σ)) its) ⊢ expr.Let res res_t₁ res_init₁ body₁ ⇛ expr.Let res res_t₂ res_init₂ body₂; ⋀expr₂. Γ ++⇩f fmap_of_list (map (λit. (it, σ)) its) ⊢ expr.Let res res_t₁ res_init₁ body₁ ⇛ expr₂ ⟹ expr.Let res res_t₂ res_init₂ body₂ = expr₂; (Γ, τ) ⊢⇩C Iterate its (Some σ) res res_t₁ res_init₁ body₁ ⇛ call₂⟧ ⟹ Iterate its (Some σ) res res_t₂ res_init₂ body₂ = call₂› 11. ‹⋀τ σ Γ res_init₁ res_init₂ its res res_t₁ body₁ res_t₂ body₂ call₂. ⟦element_type τ σ; Γ ⊢ res_init₁ ⇛ res_init₂; ⋀expr₂. Γ ⊢ res_init₁ ⇛ expr₂ ⟹ res_init₂ = expr₂; Γ ++⇩f fmap_of_list (map (λit. (it, σ)) its) ⊢ expr.Let res res_t₁ res_init₁ body₁ ⇛ expr.Let res res_t₂ res_init₂ body₂; ⋀expr₂. Γ ++⇩f fmap_of_list (map (λit. (it, σ)) its) ⊢ expr.Let res res_t₁ res_init₁ body₁ ⇛ expr₂ ⟹ expr.Let res res_t₂ res_init₂ body₂ = expr₂; (Γ, τ) ⊢⇩C Iterate its None res res_t₁ res_init₁ body₁ ⇛ call₂⟧ ⟹ Iterate its (Some σ) res res_t₂ res_init₂ body₂ = call₂› 12. ‹⋀Γ σ its body₁ body₂ τ iter call₂. ⟦Γ ++⇩f fmap_of_list (map (λit. (it, σ)) its) ⊢ body₁ ⇛ body₂; ⋀expr₂. Γ ++⇩f fmap_of_list (map (λit. (it, σ)) its) ⊢ body₁ ⇛ expr₂ ⟹ body₂ = expr₂; (Γ, τ) ⊢⇩C Iterator iter its (Some σ) body₁ ⇛ call₂⟧ ⟹ Iterator iter its (Some σ) body₂ = call₂› 13. ‹⋀τ σ Γ its body₁ body₂ iter call₂. ⟦element_type τ σ; Γ ++⇩f fmap_of_list (map (λit. (it, σ)) its) ⊢ body₁ ⇛ body₂; ⋀expr₂. Γ ++⇩f fmap_of_list (map (λit. (it, σ)) its) ⊢ body₁ ⇛ expr₂ ⟹ body₂ = expr₂; (Γ, τ) ⊢⇩C Iterator iter its None body₁ ⇛ call₂⟧ ⟹ Iterator iter its (Some σ) body₂ = call₂› 14. ‹⋀Γ zs. Γ ⊢⇩L [] ⇛ zs ⟹ [] = zs› 15. ‹⋀Γ x y xs ys zs. ⟦Γ ⊢ x ⇛ y; ⋀expr₂. Γ ⊢ x ⇛ expr₂ ⟹ y = expr₂; Γ ⊢⇩L xs ⇛ ys; ⋀zs. Γ ⊢⇩L xs ⇛ zs ⟹ ys = zs; Γ ⊢⇩L x # xs ⇛ zs⟧ ⟹ y # ys = zs›*) case (CollectionDotCallN Γ src₁ src₂ τ σ call₁ call₂ it) (*‹Γ ⊢ src₁ ⇛ src₂› ‹Γ ⊢ src₁ ⇛ ?expr₂ ⟹ src₂ = ?expr₂› ‹(Γ::String.literal ⇀⇩f 'a::ocl_object_model OCL_Types.type) ⊢⇩E (src₂::'a::ocl_object_model expr) : (τ::'a::ocl_object_model OCL_Types.type)› ‹element_type (τ::'a::ocl_object_model OCL_Types.type) (σ::'a::ocl_object_model OCL_Types.type)› ‹(Γ::String.literal ⇀⇩f 'a::ocl_object_model OCL_Types.type, σ::'a::ocl_object_model OCL_Types.type) ⊢⇩C (call₁::'a::ocl_object_model call_expr) ⇛ (call₂::'a::ocl_object_model call_expr)› ‹(Γ, σ) ⊢⇩C call₁ ⇛ ?call₂ ⟹ call₂ = ?call₂› ‹it = new_vname Γ› ‹Γ ⊢ Call src₁ DotCall call₁ ⇛ expr₂›*) show "?case" (*goal: ‹CollectIteratorCall src₂ ArrowCall [it] (Some σ) (Call (Var it) DotCall call₂) = expr₂›*) apply (insert CollectionDotCallN.prems (*‹(Γ::String.literal ⇀⇩f 'a OCL_Types.type) ⊢ Call (src₁::'a expr) DotCall (call₁::'a call_expr) ⇛ (expr₂::'a expr)›*)) (*goal: ‹CollectIteratorCall src₂ ArrowCall [it] (Some σ) (Call (Var it) DotCall call₂) = expr₂›*) apply (erule DotCallNE (*‹⟦?Γ ⊢ Call ?src DotCall ?call ⇛ ?b; ⋀src₂ τ call₂. ⟦?b = Call src₂ DotCall call₂; ?Γ ⊢ ?src ⇛ src₂; ?Γ ⊢⇩E src₂ : τ; τ ≤ OclAny[?] ∨ τ ≤ Tuple fmempty; (?Γ, τ) ⊢⇩C ?call ⇛ call₂⟧ ⟹ ?P; ⋀src₂ τ σ call₂. ⟦?b = CollectIteratorCall src₂ ArrowCall [new_vname ?Γ] (Some σ) (Call (Var (new_vname ?Γ)) DotCall call₂); ?Γ ⊢ ?src ⇛ src₂; ?Γ ⊢⇩E src₂ : τ; element_type τ σ; (?Γ, σ) ⊢⇩C ?call ⇛ call₂⟧ ⟹ ?P⟧ ⟹ ?P›*)) (*goal: ‹Γ ⊢ Call src₁ DotCall call₁ ⇛ expr₂ ⟹ CollectIteratorCall src₂ ArrowCall [it] (Some σ) (Call (Var it) DotCall call₂) = expr₂›*) using CollectionDotCallN.hyps (*‹(Γ::String.literal ⇀⇩f 'a OCL_Types.type) ⊢ (src₁::'a expr) ⇛ (src₂::'a expr)› ‹Γ ⊢ src₁ ⇛ ?expr₂ ⟹ src₂ = ?expr₂› ‹Γ ⊢⇩E src₂ : τ› ‹element_type (τ::'a OCL_Types.type) (σ::'a OCL_Types.type)› ‹(Γ, σ) ⊢⇩C call₁ ⇛ call₂› ‹(Γ, σ) ⊢⇩C call₁ ⇛ ?call₂ ⟹ call₂ = ?call₂› ‹it = new_vname Γ›*) typing_det (*‹⟦?Γ ⊢⇩E ?expr : ?τ; ?Γ ⊢⇩E ?expr : ?σ⟧ ⟹ ?τ = ?σ›*) any_has_not_element_type (*‹⟦element_type ?τ ?σ; ?τ ≤ OclAny[?] ∨ ?τ ≤ Tuple fmempty⟧ ⟹ False›*) apply metis (*top goal: ‹⋀(src₂'::'a expr) (τ::'a OCL_Types.type) call₂::'a call_expr. ⟦(expr₂::'a expr) = Call src₂' DotCall call₂; (Γ::String.literal ⇀⇩f 'a OCL_Types.type) ⊢ (src₁::'a expr) ⇛ src₂'; Γ ⊢⇩E src₂' : τ; τ ≤ OclAny[?] ∨ τ ≤ Tuple fmempty; (Γ, τ) ⊢⇩C (call₁::'a call_expr) ⇛ call₂⟧ ⟹ CollectIteratorCall (src₂::'a expr) ArrowCall [it::String.literal] (Some (σ::'a OCL_Types.type)) (Call (Var it) DotCall (call₂::'a call_expr)) = expr₂› and 1 goal remains*) using CollectionDotCallN.hyps (*‹Γ ⊢ src₁ ⇛ src₂› ‹Γ ⊢ src₁ ⇛ ?expr₂ ⟹ src₂ = ?expr₂› ‹Γ ⊢⇩E src₂ : τ› ‹element_type τ σ› ‹(Γ, σ) ⊢⇩C call₁ ⇛ call₂› ‹(Γ, σ) ⊢⇩C call₁ ⇛ ?call₂ ⟹ call₂ = ?call₂› ‹(it::String.literal) = new_vname (Γ::String.literal ⇀⇩f 'a OCL_Types.type)›*) typing_det (*‹⟦(?Γ::String.literal ⇀⇩f ?'a OCL_Types.type) ⊢⇩E (?expr::?'a expr) : (?τ::?'a OCL_Types.type); ?Γ ⊢⇩E ?expr : (?σ::?'a OCL_Types.type)⟧ ⟹ ?τ = ?σ›*) element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) by metis next (*goals: 1. ‹⋀Γ src₁ src₂ τ σ ρ src₃ call₁ call₂ it expr₂. ⟦Γ ⊢ src₁ ⇛ src₂; ⋀expr₂. Γ ⊢ src₁ ⇛ expr₂ ⟹ src₂ = expr₂; Γ ⊢⇩E src₂ : τ; element_type τ σ; OclVoid[?] ≤ σ; ρ = to_required_type σ; src₃ = TypeOperationCall src₂ ArrowCall SelectByKindOp ρ; (Γ, ρ) ⊢⇩C call₁ ⇛ call₂; ⋀call₂'. (Γ, ρ) ⊢⇩C call₁ ⇛ call₂' ⟹ call₂ = call₂'; it = new_vname Γ; Γ ⊢ Call src₁ SafeDotCall call₁ ⇛ expr₂⟧ ⟹ CollectIteratorCall src₃ ArrowCall [it] (Some ρ) (Call (Var it) DotCall call₂) = expr₂› 2. ‹⋀Γ τ op ty call₂. (Γ, τ) ⊢⇩C TypeOperation op ty ⇛ call₂ ⟹ TypeOperation op ty = call₂› 3. ‹⋀Γ τ attr call₂. (Γ, τ) ⊢⇩C Attribute attr ⇛ call₂ ⟹ Attribute attr = call₂› 4. ‹⋀Γ τ role from call₂. (Γ, τ) ⊢⇩C AssociationEnd role from ⇛ call₂ ⟹ AssociationEnd role from = call₂› 5. ‹⋀Γ τ 𝒜 from call₂. (Γ, τ) ⊢⇩C AssociationClass 𝒜 from ⇛ call₂ ⟹ AssociationClass 𝒜 from = call₂› 6. ‹⋀Γ τ role call₂. (Γ, τ) ⊢⇩C AssociationClassEnd role ⇛ call₂ ⟹ AssociationClassEnd role = call₂› 7. ‹⋀Γ params₁ params₂ τ op call₂. ⟦Γ ⊢⇩L params₁ ⇛ params₂; ⋀zs. Γ ⊢⇩L params₁ ⇛ zs ⟹ params₂ = zs; (Γ, τ) ⊢⇩C Operation op params₁ ⇛ call₂⟧ ⟹ Operation op params₂ = call₂› 8. ‹⋀Γ τ elem call₂. (Γ, τ) ⊢⇩C TupleElement elem ⇛ call₂ ⟹ TupleElement elem = call₂› 9. ‹⋀Γ res_init₁ res_init₂ σ its res res_t₁ body₁ res_t₂ body₂ τ call₂. ⟦Γ ⊢ res_init₁ ⇛ res_init₂; ⋀expr₂. Γ ⊢ res_init₁ ⇛ expr₂ ⟹ res_init₂ = expr₂; Γ ++⇩f fmap_of_list (map (λit. (it, σ)) its) ⊢ expr.Let res res_t₁ res_init₁ body₁ ⇛ expr.Let res res_t₂ res_init₂ body₂; ⋀expr₂. Γ ++⇩f fmap_of_list (map (λit. (it, σ)) its) ⊢ expr.Let res res_t₁ res_init₁ body₁ ⇛ expr₂ ⟹ expr.Let res res_t₂ res_init₂ body₂ = expr₂; (Γ, τ) ⊢⇩C Iterate its (Some σ) res res_t₁ res_init₁ body₁ ⇛ call₂⟧ ⟹ Iterate its (Some σ) res res_t₂ res_init₂ body₂ = call₂› 10. ‹⋀τ σ Γ res_init₁ res_init₂ its res res_t₁ body₁ res_t₂ body₂ call₂. ⟦element_type τ σ; Γ ⊢ res_init₁ ⇛ res_init₂; ⋀expr₂. Γ ⊢ res_init₁ ⇛ expr₂ ⟹ res_init₂ = expr₂; Γ ++⇩f fmap_of_list (map (λit. (it, σ)) its) ⊢ expr.Let res res_t₁ res_init₁ body₁ ⇛ expr.Let res res_t₂ res_init₂ body₂; ⋀expr₂. Γ ++⇩f fmap_of_list (map (λit. (it, σ)) its) ⊢ expr.Let res res_t₁ res_init₁ body₁ ⇛ expr₂ ⟹ expr.Let res res_t₂ res_init₂ body₂ = expr₂; (Γ, τ) ⊢⇩C Iterate its None res res_t₁ res_init₁ body₁ ⇛ call₂⟧ ⟹ Iterate its (Some σ) res res_t₂ res_init₂ body₂ = call₂› 11. ‹⋀Γ σ its body₁ body₂ τ iter call₂. ⟦Γ ++⇩f fmap_of_list (map (λit. (it, σ)) its) ⊢ body₁ ⇛ body₂; ⋀expr₂. Γ ++⇩f fmap_of_list (map (λit. (it, σ)) its) ⊢ body₁ ⇛ expr₂ ⟹ body₂ = expr₂; (Γ, τ) ⊢⇩C Iterator iter its (Some σ) body₁ ⇛ call₂⟧ ⟹ Iterator iter its (Some σ) body₂ = call₂› 12. ‹⋀τ σ Γ its body₁ body₂ iter call₂. ⟦element_type τ σ; Γ ++⇩f fmap_of_list (map (λit. (it, σ)) its) ⊢ body₁ ⇛ body₂; ⋀expr₂. Γ ++⇩f fmap_of_list (map (λit. (it, σ)) its) ⊢ body₁ ⇛ expr₂ ⟹ body₂ = expr₂; (Γ, τ) ⊢⇩C Iterator iter its None body₁ ⇛ call₂⟧ ⟹ Iterator iter its (Some σ) body₂ = call₂› 13. ‹⋀Γ zs. Γ ⊢⇩L [] ⇛ zs ⟹ [] = zs› 14. ‹⋀Γ x y xs ys zs. ⟦Γ ⊢ x ⇛ y; ⋀expr₂. Γ ⊢ x ⇛ expr₂ ⟹ y = expr₂; Γ ⊢⇩L xs ⇛ ys; ⋀zs. Γ ⊢⇩L xs ⇛ zs ⟹ ys = zs; Γ ⊢⇩L x # xs ⇛ zs⟧ ⟹ y # ys = zs›*) case (CollectionSafeDotCallN Γ src₁ src₂ τ σ src₃ call₁ call₂ it) (*‹Γ ⊢ src₁ ⇛ src₂› ‹Γ ⊢ src₁ ⇛ ?expr₂ ⟹ src₂ = ?expr₂› ‹(Γ::String.literal ⇀⇩f 'a OCL_Types.type) ⊢⇩E (src₂::'a expr) : (τ::'a OCL_Types.type)› ‹element_type (τ::'a::ocl_object_model OCL_Types.type) (σ::'a::ocl_object_model OCL_Types.type)› ‹OclVoid[?] ≤ σ› ‹src₃ = to_required_type σ› ‹(call₁::'a expr) = TypeOperationCall (src₂::'a expr) ArrowCall SelectByKindOp (src₃::'a OCL_Types.type)› ‹(Γ, src₃) ⊢⇩C call₂ ⇛ it› ‹(Γ, src₃) ⊢⇩C call₂ ⇛ ?call₂ ⟹ it = ?call₂› ‹it_ = new_vname Γ› ‹Γ ⊢ Call src₁ SafeDotCall call₂ ⇛ expr₂›*) show "?case" (*goal: ‹CollectIteratorCall call₁ ArrowCall [it_] (Some src₃) (Call (Var it_) DotCall it) = expr₂›*) apply (insert CollectionSafeDotCallN.prems (*‹Γ ⊢ Call src₁ SafeDotCall call₂ ⇛ expr₂›*)) (*goal: ‹CollectIteratorCall (call₁::'a expr) ArrowCall [it_::String.literal] (Some (src₃::'a OCL_Types.type)) (Call (Var it_) DotCall (it::'a call_expr)) = (expr₂::'a expr)›*) apply (erule SafeDotCallNE (*‹⟦(?Γ::String.literal ⇀⇩f ?'a OCL_Types.type) ⊢ Call (?src::?'a expr) SafeDotCall (?call::?'a call_expr) ⇛ (?b::?'a expr); ⋀(src₂::?'a expr) (τ::?'a OCL_Types.type) call₂::?'a call_expr. ⟦?b = expr.If (OperationCall src₂ DotCall (Inr (Inl (Inl NotEqualOp))) [Literal NullLiteral]) (Call (TypeOperationCall src₂ DotCall OclAsTypeOp (to_required_type τ)) DotCall call₂) (Literal NullLiteral); ?Γ ⊢ ?src ⇛ src₂; ?Γ ⊢⇩E src₂ : τ; OclVoid[?] ≤ τ; (?Γ, to_required_type τ) ⊢⇩C ?call ⇛ call₂⟧ ⟹ ?P::bool; ⋀(src₂::?'a expr) (τ::?'a OCL_Types.type) (σ::?'a OCL_Types.type) call₂::?'a call_expr. ⟦?b = CollectIteratorCall (TypeOperationCall src₂ ArrowCall SelectByKindOp (to_required_type σ)) ArrowCall [new_vname ?Γ] (Some (to_required_type σ)) (Call (Var (new_vname ?Γ)) DotCall call₂); ?Γ ⊢ ?src ⇛ src₂; ?Γ ⊢⇩E src₂ : τ; element_type τ σ; OclVoid[?] ≤ σ; (?Γ, to_required_type σ) ⊢⇩C ?call ⇛ call₂⟧ ⟹ ?P⟧ ⟹ ?P›*)) (*goal: ‹Γ ⊢ Call src₁ SafeDotCall call₂ ⇛ expr₂ ⟹ CollectIteratorCall call₁ ArrowCall [it_] (Some src₃) (Call (Var it_) DotCall it) = expr₂›*) using CollectionSafeDotCallN.hyps (*‹Γ ⊢ src₁ ⇛ src₂› ‹Γ ⊢ src₁ ⇛ ?expr₂ ⟹ src₂ = ?expr₂› ‹Γ ⊢⇩E src₂ : τ› ‹element_type τ σ› ‹OclVoid[?] ≤ σ› ‹(src₃::'a::ocl_object_model OCL_Types.type) = to_required_type (σ::'a::ocl_object_model OCL_Types.type)› ‹call₁ = TypeOperationCall src₂ ArrowCall SelectByKindOp src₃› ‹(Γ, src₃) ⊢⇩C call₂ ⇛ it› ‹(Γ::String.literal ⇀⇩f 'a OCL_Types.type, src₃::'a OCL_Types.type) ⊢⇩C (call₂::'a call_expr) ⇛ (?call₂::'a call_expr) ⟹ (it::'a call_expr) = ?call₂› ‹it_ = new_vname Γ›*) typing_det (*‹⟦(?Γ::String.literal ⇀⇩f ?'a OCL_Types.type) ⊢⇩E (?expr::?'a expr) : (?τ::?'a OCL_Types.type); ?Γ ⊢⇩E ?expr : (?σ::?'a OCL_Types.type)⟧ ⟹ ?τ = ?σ›*) any_has_not_element_type' (*‹⟦element_type ?τ ?σ; OclVoid[?] ≤ ?τ⟧ ⟹ False›*) apply metis (*top goal: ‹⋀(src₂::'a::ocl_object_model expr) (τ::'a::ocl_object_model OCL_Types.type) call₂::'a::ocl_object_model call_expr. ⟦(expr₂::'a::ocl_object_model expr) = expr.If (OperationCall src₂ DotCall (Inr (Inl (Inl NotEqualOp))) [Literal NullLiteral]) (Call (TypeOperationCall src₂ DotCall OclAsTypeOp (to_required_type τ)) DotCall call₂) (Literal NullLiteral); (Γ::String.literal ⇀⇩f 'a::ocl_object_model OCL_Types.type) ⊢ (src₁::'a::ocl_object_model expr) ⇛ src₂; Γ ⊢⇩E src₂ : τ; OclVoid[?] ≤ τ; (Γ, to_required_type τ) ⊢⇩C (call₂::'a::ocl_object_model call_expr) ⇛ call₂⟧ ⟹ CollectIteratorCall (call₁::'a::ocl_object_model expr) ArrowCall [it_::String.literal] (Some (src₃::'a::ocl_object_model OCL_Types.type)) (Call (Var it_) DotCall (it::'a::ocl_object_model call_expr)) = expr₂› and 1 goal remains*) using CollectionSafeDotCallN.hyps (*‹Γ ⊢ src₁ ⇛ src₂› ‹Γ ⊢ src₁ ⇛ ?expr₂ ⟹ src₂ = ?expr₂› ‹(Γ::String.literal ⇀⇩f 'a OCL_Types.type) ⊢⇩E (src₂::'a expr) : (τ::'a OCL_Types.type)› ‹element_type τ σ› ‹OclVoid[?] ≤ σ› ‹src₃ = to_required_type σ› ‹call₁ = TypeOperationCall src₂ ArrowCall SelectByKindOp src₃› ‹(Γ, src₃) ⊢⇩C call₂ ⇛ it› ‹(Γ, src₃) ⊢⇩C call₂ ⇛ ?call₂ ⟹ it = ?call₂› ‹it_ = new_vname Γ›*) typing_det (*‹⟦?Γ ⊢⇩E ?expr : ?τ; ?Γ ⊢⇩E ?expr : ?σ⟧ ⟹ ?τ = ?σ›*) element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) by metis next (*goals: 1. ‹⋀Γ τ op ty call₂. (Γ, τ) ⊢⇩C TypeOperation op ty ⇛ call₂ ⟹ TypeOperation op ty = call₂› 2. ‹⋀Γ τ attr call₂. (Γ, τ) ⊢⇩C Attribute attr ⇛ call₂ ⟹ Attribute attr = call₂› 3. ‹⋀Γ τ role from call₂. (Γ, τ) ⊢⇩C AssociationEnd role from ⇛ call₂ ⟹ AssociationEnd role from = call₂› 4. ‹⋀Γ τ 𝒜 from call₂. (Γ, τ) ⊢⇩C AssociationClass 𝒜 from ⇛ call₂ ⟹ AssociationClass 𝒜 from = call₂› 5. ‹⋀Γ τ role call₂. (Γ, τ) ⊢⇩C AssociationClassEnd role ⇛ call₂ ⟹ AssociationClassEnd role = call₂› 6. ‹⋀Γ params₁ params₂ τ op call₂. ⟦Γ ⊢⇩L params₁ ⇛ params₂; ⋀zs. Γ ⊢⇩L params₁ ⇛ zs ⟹ params₂ = zs; (Γ, τ) ⊢⇩C Operation op params₁ ⇛ call₂⟧ ⟹ Operation op params₂ = call₂› 7. ‹⋀Γ τ elem call₂. (Γ, τ) ⊢⇩C TupleElement elem ⇛ call₂ ⟹ TupleElement elem = call₂› 8. ‹⋀Γ res_init₁ res_init₂ σ its res res_t₁ body₁ res_t₂ body₂ τ call₂. ⟦Γ ⊢ res_init₁ ⇛ res_init₂; ⋀expr₂. Γ ⊢ res_init₁ ⇛ expr₂ ⟹ res_init₂ = expr₂; Γ ++⇩f fmap_of_list (map (λit. (it, σ)) its) ⊢ expr.Let res res_t₁ res_init₁ body₁ ⇛ expr.Let res res_t₂ res_init₂ body₂; ⋀expr₂. Γ ++⇩f fmap_of_list (map (λit. (it, σ)) its) ⊢ expr.Let res res_t₁ res_init₁ body₁ ⇛ expr₂ ⟹ expr.Let res res_t₂ res_init₂ body₂ = expr₂; (Γ, τ) ⊢⇩C Iterate its (Some σ) res res_t₁ res_init₁ body₁ ⇛ call₂⟧ ⟹ Iterate its (Some σ) res res_t₂ res_init₂ body₂ = call₂› 9. ‹⋀τ σ Γ res_init₁ res_init₂ its res res_t₁ body₁ res_t₂ body₂ call₂. ⟦element_type τ σ; Γ ⊢ res_init₁ ⇛ res_init₂; ⋀expr₂. Γ ⊢ res_init₁ ⇛ expr₂ ⟹ res_init₂ = expr₂; Γ ++⇩f fmap_of_list (map (λit. (it, σ)) its) ⊢ expr.Let res res_t₁ res_init₁ body₁ ⇛ expr.Let res res_t₂ res_init₂ body₂; ⋀expr₂. Γ ++⇩f fmap_of_list (map (λit. (it, σ)) its) ⊢ expr.Let res res_t₁ res_init₁ body₁ ⇛ expr₂ ⟹ expr.Let res res_t₂ res_init₂ body₂ = expr₂; (Γ, τ) ⊢⇩C Iterate its None res res_t₁ res_init₁ body₁ ⇛ call₂⟧ ⟹ Iterate its (Some σ) res res_t₂ res_init₂ body₂ = call₂› 10. ‹⋀Γ σ its body₁ body₂ τ iter call₂. ⟦Γ ++⇩f fmap_of_list (map (λit. (it, σ)) its) ⊢ body₁ ⇛ body₂; ⋀expr₂. Γ ++⇩f fmap_of_list (map (λit. (it, σ)) its) ⊢ body₁ ⇛ expr₂ ⟹ body₂ = expr₂; (Γ, τ) ⊢⇩C Iterator iter its (Some σ) body₁ ⇛ call₂⟧ ⟹ Iterator iter its (Some σ) body₂ = call₂› 11. ‹⋀τ σ Γ its body₁ body₂ iter call₂. ⟦element_type τ σ; Γ ++⇩f fmap_of_list (map (λit. (it, σ)) its) ⊢ body₁ ⇛ body₂; ⋀expr₂. Γ ++⇩f fmap_of_list (map (λit. (it, σ)) its) ⊢ body₁ ⇛ expr₂ ⟹ body₂ = expr₂; (Γ, τ) ⊢⇩C Iterator iter its None body₁ ⇛ call₂⟧ ⟹ Iterator iter its (Some σ) body₂ = call₂› 12. ‹⋀Γ zs. Γ ⊢⇩L [] ⇛ zs ⟹ [] = zs› 13. ‹⋀Γ x y xs ys zs. ⟦Γ ⊢ x ⇛ y; ⋀expr₂. Γ ⊢ x ⇛ expr₂ ⟹ y = expr₂; Γ ⊢⇩L xs ⇛ ys; ⋀zs. Γ ⊢⇩L xs ⇛ zs ⟹ ys = zs; Γ ⊢⇩L x # xs ⇛ zs⟧ ⟹ y # ys = zs›*) case (TypeOperationN Γ τ op ty) (*‹(Γ, τ) ⊢⇩C TypeOperation op ty ⇛ call₂›*) thus "?case" (*goal: ‹TypeOperation op ty = call₂›*) by auto next (*goals: 1. ‹⋀Γ τ attr call₂. (Γ, τ) ⊢⇩C Attribute attr ⇛ call₂ ⟹ Attribute attr = call₂› 2. ‹⋀Γ τ role from call₂. (Γ, τ) ⊢⇩C AssociationEnd role from ⇛ call₂ ⟹ AssociationEnd role from = call₂› 3. ‹⋀Γ τ 𝒜 from call₂. (Γ, τ) ⊢⇩C AssociationClass 𝒜 from ⇛ call₂ ⟹ AssociationClass 𝒜 from = call₂› 4. ‹⋀Γ τ role call₂. (Γ, τ) ⊢⇩C AssociationClassEnd role ⇛ call₂ ⟹ AssociationClassEnd role = call₂› 5. ‹⋀Γ params₁ params₂ τ op call₂. ⟦Γ ⊢⇩L params₁ ⇛ params₂; ⋀zs. Γ ⊢⇩L params₁ ⇛ zs ⟹ params₂ = zs; (Γ, τ) ⊢⇩C Operation op params₁ ⇛ call₂⟧ ⟹ Operation op params₂ = call₂› 6. ‹⋀Γ τ elem call₂. (Γ, τ) ⊢⇩C TupleElement elem ⇛ call₂ ⟹ TupleElement elem = call₂› 7. ‹⋀Γ res_init₁ res_init₂ σ its res res_t₁ body₁ res_t₂ body₂ τ call₂. ⟦Γ ⊢ res_init₁ ⇛ res_init₂; ⋀expr₂. Γ ⊢ res_init₁ ⇛ expr₂ ⟹ res_init₂ = expr₂; Γ ++⇩f fmap_of_list (map (λit. (it, σ)) its) ⊢ expr.Let res res_t₁ res_init₁ body₁ ⇛ expr.Let res res_t₂ res_init₂ body₂; ⋀expr₂. Γ ++⇩f fmap_of_list (map (λit. (it, σ)) its) ⊢ expr.Let res res_t₁ res_init₁ body₁ ⇛ expr₂ ⟹ expr.Let res res_t₂ res_init₂ body₂ = expr₂; (Γ, τ) ⊢⇩C Iterate its (Some σ) res res_t₁ res_init₁ body₁ ⇛ call₂⟧ ⟹ Iterate its (Some σ) res res_t₂ res_init₂ body₂ = call₂› 8. ‹⋀τ σ Γ res_init₁ res_init₂ its res res_t₁ body₁ res_t₂ body₂ call₂. ⟦element_type τ σ; Γ ⊢ res_init₁ ⇛ res_init₂; ⋀expr₂. Γ ⊢ res_init₁ ⇛ expr₂ ⟹ res_init₂ = expr₂; Γ ++⇩f fmap_of_list (map (λit. (it, σ)) its) ⊢ expr.Let res res_t₁ res_init₁ body₁ ⇛ expr.Let res res_t₂ res_init₂ body₂; ⋀expr₂. Γ ++⇩f fmap_of_list (map (λit. (it, σ)) its) ⊢ expr.Let res res_t₁ res_init₁ body₁ ⇛ expr₂ ⟹ expr.Let res res_t₂ res_init₂ body₂ = expr₂; (Γ, τ) ⊢⇩C Iterate its None res res_t₁ res_init₁ body₁ ⇛ call₂⟧ ⟹ Iterate its (Some σ) res res_t₂ res_init₂ body₂ = call₂› 9. ‹⋀Γ σ its body₁ body₂ τ iter call₂. ⟦Γ ++⇩f fmap_of_list (map (λit. (it, σ)) its) ⊢ body₁ ⇛ body₂; ⋀expr₂. Γ ++⇩f fmap_of_list (map (λit. (it, σ)) its) ⊢ body₁ ⇛ expr₂ ⟹ body₂ = expr₂; (Γ, τ) ⊢⇩C Iterator iter its (Some σ) body₁ ⇛ call₂⟧ ⟹ Iterator iter its (Some σ) body₂ = call₂› 10. ‹⋀τ σ Γ its body₁ body₂ iter call₂. ⟦element_type τ σ; Γ ++⇩f fmap_of_list (map (λit. (it, σ)) its) ⊢ body₁ ⇛ body₂; ⋀expr₂. Γ ++⇩f fmap_of_list (map (λit. (it, σ)) its) ⊢ body₁ ⇛ expr₂ ⟹ body₂ = expr₂; (Γ, τ) ⊢⇩C Iterator iter its None body₁ ⇛ call₂⟧ ⟹ Iterator iter its (Some σ) body₂ = call₂› 11. ‹⋀Γ zs. Γ ⊢⇩L [] ⇛ zs ⟹ [] = zs› 12. ‹⋀Γ x y xs ys zs. ⟦Γ ⊢ x ⇛ y; ⋀expr₂. Γ ⊢ x ⇛ expr₂ ⟹ y = expr₂; Γ ⊢⇩L xs ⇛ ys; ⋀zs. Γ ⊢⇩L xs ⇛ zs ⟹ ys = zs; Γ ⊢⇩L x # xs ⇛ zs⟧ ⟹ y # ys = zs›*) case (AttributeN Γ τ attr) (*‹(Γ, τ) ⊢⇩C Attribute attr ⇛ call₂›*) thus "?case" (*goal: ‹Attribute (attr::String.literal) = (call₂::'a::ocl_object_model call_expr)›*) by auto next (*goals: 1. ‹⋀Γ τ role from call₂. (Γ, τ) ⊢⇩C AssociationEnd role from ⇛ call₂ ⟹ AssociationEnd role from = call₂› 2. ‹⋀Γ τ 𝒜 from call₂. (Γ, τ) ⊢⇩C AssociationClass 𝒜 from ⇛ call₂ ⟹ AssociationClass 𝒜 from = call₂› 3. ‹⋀Γ τ role call₂. (Γ, τ) ⊢⇩C AssociationClassEnd role ⇛ call₂ ⟹ AssociationClassEnd role = call₂› 4. ‹⋀Γ params₁ params₂ τ op call₂. ⟦Γ ⊢⇩L params₁ ⇛ params₂; ⋀zs. Γ ⊢⇩L params₁ ⇛ zs ⟹ params₂ = zs; (Γ, τ) ⊢⇩C Operation op params₁ ⇛ call₂⟧ ⟹ Operation op params₂ = call₂› 5. ‹⋀Γ τ elem call₂. (Γ, τ) ⊢⇩C TupleElement elem ⇛ call₂ ⟹ TupleElement elem = call₂› 6. ‹⋀Γ res_init₁ res_init₂ σ its res res_t₁ body₁ res_t₂ body₂ τ call₂. ⟦Γ ⊢ res_init₁ ⇛ res_init₂; ⋀expr₂. Γ ⊢ res_init₁ ⇛ expr₂ ⟹ res_init₂ = expr₂; Γ ++⇩f fmap_of_list (map (λit. (it, σ)) its) ⊢ expr.Let res res_t₁ res_init₁ body₁ ⇛ expr.Let res res_t₂ res_init₂ body₂; ⋀expr₂. Γ ++⇩f fmap_of_list (map (λit. (it, σ)) its) ⊢ expr.Let res res_t₁ res_init₁ body₁ ⇛ expr₂ ⟹ expr.Let res res_t₂ res_init₂ body₂ = expr₂; (Γ, τ) ⊢⇩C Iterate its (Some σ) res res_t₁ res_init₁ body₁ ⇛ call₂⟧ ⟹ Iterate its (Some σ) res res_t₂ res_init₂ body₂ = call₂› 7. ‹⋀τ σ Γ res_init₁ res_init₂ its res res_t₁ body₁ res_t₂ body₂ call₂. ⟦element_type τ σ; Γ ⊢ res_init₁ ⇛ res_init₂; ⋀expr₂. Γ ⊢ res_init₁ ⇛ expr₂ ⟹ res_init₂ = expr₂; Γ ++⇩f fmap_of_list (map (λit. (it, σ)) its) ⊢ expr.Let res res_t₁ res_init₁ body₁ ⇛ expr.Let res res_t₂ res_init₂ body₂; ⋀expr₂. Γ ++⇩f fmap_of_list (map (λit. (it, σ)) its) ⊢ expr.Let res res_t₁ res_init₁ body₁ ⇛ expr₂ ⟹ expr.Let res res_t₂ res_init₂ body₂ = expr₂; (Γ, τ) ⊢⇩C Iterate its None res res_t₁ res_init₁ body₁ ⇛ call₂⟧ ⟹ Iterate its (Some σ) res res_t₂ res_init₂ body₂ = call₂› 8. ‹⋀Γ σ its body₁ body₂ τ iter call₂. ⟦Γ ++⇩f fmap_of_list (map (λit. (it, σ)) its) ⊢ body₁ ⇛ body₂; ⋀expr₂. Γ ++⇩f fmap_of_list (map (λit. (it, σ)) its) ⊢ body₁ ⇛ expr₂ ⟹ body₂ = expr₂; (Γ, τ) ⊢⇩C Iterator iter its (Some σ) body₁ ⇛ call₂⟧ ⟹ Iterator iter its (Some σ) body₂ = call₂› 9. ‹⋀τ σ Γ its body₁ body₂ iter call₂. ⟦element_type τ σ; Γ ++⇩f fmap_of_list (map (λit. (it, σ)) its) ⊢ body₁ ⇛ body₂; ⋀expr₂. Γ ++⇩f fmap_of_list (map (λit. (it, σ)) its) ⊢ body₁ ⇛ expr₂ ⟹ body₂ = expr₂; (Γ, τ) ⊢⇩C Iterator iter its None body₁ ⇛ call₂⟧ ⟹ Iterator iter its (Some σ) body₂ = call₂› 10. ‹⋀Γ zs. Γ ⊢⇩L [] ⇛ zs ⟹ [] = zs› 11. ‹⋀Γ x y xs ys zs. ⟦Γ ⊢ x ⇛ y; ⋀expr₂. Γ ⊢ x ⇛ expr₂ ⟹ y = expr₂; Γ ⊢⇩L xs ⇛ ys; ⋀zs. Γ ⊢⇩L xs ⇛ zs ⟹ ys = zs; Γ ⊢⇩L x # xs ⇛ zs⟧ ⟹ y # ys = zs›*) case (AssociationEndN Γ τ role from) (*‹(Γ, τ) ⊢⇩C AssociationEnd role from ⇛ call₂›*) thus "?case" (*goal: ‹AssociationEnd role from = call₂›*) by auto next (*goals: 1. ‹⋀(Γ::String.literal ⇀⇩f 'a::ocl_object_model OCL_Types.type) (τ::'a::ocl_object_model OCL_Types.type) (𝒜::String.literal option) (from::'a::ocl_object_model) call₂::'a::ocl_object_model call_expr. (Γ, τ) ⊢⇩C AssociationClass 𝒜 from ⇛ call₂ ⟹ AssociationClass 𝒜 from = call₂› 2. ‹⋀(Γ::String.literal ⇀⇩f 'a::ocl_object_model OCL_Types.type) (τ::'a::ocl_object_model OCL_Types.type) (role::String.literal) call₂::'a::ocl_object_model call_expr. (Γ, τ) ⊢⇩C AssociationClassEnd role ⇛ call₂ ⟹ AssociationClassEnd role = call₂› 3. ‹⋀(Γ::String.literal ⇀⇩f 'a::ocl_object_model OCL_Types.type) (params₁::'a::ocl_object_model expr list) (params₂::'a::ocl_object_model expr list) (τ::'a::ocl_object_model OCL_Types.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) call₂::'a::ocl_object_model call_expr. ⟦Γ ⊢⇩L params₁ ⇛ params₂; ⋀zs::'a::ocl_object_model expr list. Γ ⊢⇩L params₁ ⇛ zs ⟹ params₂ = zs; (Γ, τ) ⊢⇩C Operation op params₁ ⇛ call₂⟧ ⟹ Operation op params₂ = call₂› 4. ‹⋀(Γ::String.literal ⇀⇩f 'a::ocl_object_model OCL_Types.type) (τ::'a::ocl_object_model OCL_Types.type) (elem::String.literal) call₂::'a::ocl_object_model call_expr. (Γ, τ) ⊢⇩C TupleElement elem ⇛ call₂ ⟹ TupleElement elem = call₂› 5. ‹⋀(Γ::String.literal ⇀⇩f 'a::ocl_object_model OCL_Types.type) (res_init₁::'a::ocl_object_model expr) (res_init₂::'a::ocl_object_model expr) (σ::'a::ocl_object_model OCL_Types.type) (its::String.literal list) (res::String.literal) (res_t₁::'a::ocl_object_model OCL_Types.type option) (body₁::'a::ocl_object_model expr) (res_t₂::'a::ocl_object_model OCL_Types.type option) (body₂::'a::ocl_object_model expr) (τ::'a::ocl_object_model OCL_Types.type) call₂::'a::ocl_object_model call_expr. ⟦Γ ⊢ res_init₁ ⇛ res_init₂; ⋀expr₂::'a::ocl_object_model expr. Γ ⊢ res_init₁ ⇛ expr₂ ⟹ res_init₂ = expr₂; Γ ++⇩f fmap_of_list (map (λit::String.literal. (it, σ)) its) ⊢ expr.Let res res_t₁ res_init₁ body₁ ⇛ expr.Let res res_t₂ res_init₂ body₂; ⋀expr₂::'a::ocl_object_model expr. Γ ++⇩f fmap_of_list (map (λit::String.literal. (it, σ)) its) ⊢ expr.Let res res_t₁ res_init₁ body₁ ⇛ expr₂ ⟹ expr.Let res res_t₂ res_init₂ body₂ = expr₂; (Γ, τ) ⊢⇩C Iterate its (Some σ) res res_t₁ res_init₁ body₁ ⇛ call₂⟧ ⟹ Iterate its (Some σ) res res_t₂ res_init₂ body₂ = call₂› 6. ‹⋀(τ::'a::ocl_object_model OCL_Types.type) (σ::'a::ocl_object_model OCL_Types.type) (Γ::String.literal ⇀⇩f 'a::ocl_object_model OCL_Types.type) (res_init₁::'a::ocl_object_model expr) (res_init₂::'a::ocl_object_model expr) (its::String.literal list) (res::String.literal) (res_t₁::'a::ocl_object_model OCL_Types.type option) (body₁::'a::ocl_object_model expr) (res_t₂::'a::ocl_object_model OCL_Types.type option) (body₂::'a::ocl_object_model expr) call₂::'a::ocl_object_model call_expr. ⟦element_type τ σ; Γ ⊢ res_init₁ ⇛ res_init₂; ⋀expr₂::'a::ocl_object_model expr. Γ ⊢ res_init₁ ⇛ expr₂ ⟹ res_init₂ = expr₂; Γ ++⇩f fmap_of_list (map (λit::String.literal. (it, σ)) its) ⊢ expr.Let res res_t₁ res_init₁ body₁ ⇛ expr.Let res res_t₂ res_init₂ body₂; ⋀expr₂::'a::ocl_object_model expr. Γ ++⇩f fmap_of_list (map (λit::String.literal. (it, σ)) its) ⊢ expr.Let res res_t₁ res_init₁ body₁ ⇛ expr₂ ⟹ expr.Let res res_t₂ res_init₂ body₂ = expr₂; (Γ, τ) ⊢⇩C Iterate its None res res_t₁ res_init₁ body₁ ⇛ call₂⟧ ⟹ Iterate its (Some σ) res res_t₂ res_init₂ body₂ = call₂› 7. ‹⋀(Γ::String.literal ⇀⇩f 'a::ocl_object_model OCL_Types.type) (σ::'a::ocl_object_model OCL_Types.type) (its::String.literal list) (body₁::'a::ocl_object_model expr) (body₂::'a::ocl_object_model expr) (τ::'a::ocl_object_model OCL_Types.type) (iter::iterator) call₂::'a::ocl_object_model call_expr. ⟦Γ ++⇩f fmap_of_list (map (λit::String.literal. (it, σ)) its) ⊢ body₁ ⇛ body₂; ⋀expr₂::'a::ocl_object_model expr. Γ ++⇩f fmap_of_list (map (λit::String.literal. (it, σ)) its) ⊢ body₁ ⇛ expr₂ ⟹ body₂ = expr₂; (Γ, τ) ⊢⇩C Iterator iter its (Some σ) body₁ ⇛ call₂⟧ ⟹ Iterator iter its (Some σ) body₂ = call₂› 8. ‹⋀(τ::'a::ocl_object_model OCL_Types.type) (σ::'a::ocl_object_model OCL_Types.type) (Γ::String.literal ⇀⇩f 'a::ocl_object_model OCL_Types.type) (its::String.literal list) (body₁::'a::ocl_object_model expr) (body₂::'a::ocl_object_model expr) (iter::iterator) call₂::'a::ocl_object_model call_expr. ⟦element_type τ σ; Γ ++⇩f fmap_of_list (map (λit::String.literal. (it, σ)) its) ⊢ body₁ ⇛ body₂; ⋀expr₂::'a::ocl_object_model expr. Γ ++⇩f fmap_of_list (map (λit::String.literal. (it, σ)) its) ⊢ body₁ ⇛ expr₂ ⟹ body₂ = expr₂; (Γ, τ) ⊢⇩C Iterator iter its None body₁ ⇛ call₂⟧ ⟹ Iterator iter its (Some σ) body₂ = call₂› 9. ‹⋀(Γ::String.literal ⇀⇩f 'a::ocl_object_model OCL_Types.type) zs::'a::ocl_object_model expr list. Γ ⊢⇩L [] ⇛ zs ⟹ [] = zs› 10. ‹⋀(Γ::String.literal ⇀⇩f 'a::ocl_object_model OCL_Types.type) (x::'a::ocl_object_model expr) (y::'a::ocl_object_model expr) (xs::'a::ocl_object_model expr list) (ys::'a::ocl_object_model expr list) zs::'a::ocl_object_model expr list. ⟦Γ ⊢ x ⇛ y; ⋀expr₂::'a::ocl_object_model expr. Γ ⊢ x ⇛ expr₂ ⟹ y = expr₂; Γ ⊢⇩L xs ⇛ ys; ⋀zs::'a::ocl_object_model expr list. Γ ⊢⇩L xs ⇛ zs ⟹ ys = zs; Γ ⊢⇩L x # xs ⇛ zs⟧ ⟹ y # ys = zs›*) case (AssociationClassN Γ τ 𝒜 from) (*‹(Γ, τ) ⊢⇩C AssociationClass 𝒜 from ⇛ call₂›*) thus "?case" (*goal: ‹AssociationClass 𝒜 from = call₂›*) by auto next (*goals: 1. ‹⋀(Γ::String.literal ⇀⇩f 'a::ocl_object_model OCL_Types.type) (τ::'a::ocl_object_model OCL_Types.type) (role::String.literal) call₂::'a::ocl_object_model call_expr. (Γ, τ) ⊢⇩C AssociationClassEnd role ⇛ call₂ ⟹ AssociationClassEnd role = call₂› 2. ‹⋀(Γ::String.literal ⇀⇩f 'a::ocl_object_model OCL_Types.type) (params₁::'a::ocl_object_model expr list) (params₂::'a::ocl_object_model expr list) (τ::'a::ocl_object_model OCL_Types.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) call₂::'a::ocl_object_model call_expr. ⟦Γ ⊢⇩L params₁ ⇛ params₂; ⋀zs::'a::ocl_object_model expr list. Γ ⊢⇩L params₁ ⇛ zs ⟹ params₂ = zs; (Γ, τ) ⊢⇩C Operation op params₁ ⇛ call₂⟧ ⟹ Operation op params₂ = call₂› 3. ‹⋀(Γ::String.literal ⇀⇩f 'a::ocl_object_model OCL_Types.type) (τ::'a::ocl_object_model OCL_Types.type) (elem::String.literal) call₂::'a::ocl_object_model call_expr. (Γ, τ) ⊢⇩C TupleElement elem ⇛ call₂ ⟹ TupleElement elem = call₂› 4. ‹⋀(Γ::String.literal ⇀⇩f 'a::ocl_object_model OCL_Types.type) (res_init₁::'a::ocl_object_model expr) (res_init₂::'a::ocl_object_model expr) (σ::'a::ocl_object_model OCL_Types.type) (its::String.literal list) (res::String.literal) (res_t₁::'a::ocl_object_model OCL_Types.type option) (body₁::'a::ocl_object_model expr) (res_t₂::'a::ocl_object_model OCL_Types.type option) (body₂::'a::ocl_object_model expr) (τ::'a::ocl_object_model OCL_Types.type) call₂::'a::ocl_object_model call_expr. ⟦Γ ⊢ res_init₁ ⇛ res_init₂; ⋀expr₂::'a::ocl_object_model expr. Γ ⊢ res_init₁ ⇛ expr₂ ⟹ res_init₂ = expr₂; Γ ++⇩f fmap_of_list (map (λit::String.literal. (it, σ)) its) ⊢ expr.Let res res_t₁ res_init₁ body₁ ⇛ expr.Let res res_t₂ res_init₂ body₂; ⋀expr₂::'a::ocl_object_model expr. Γ ++⇩f fmap_of_list (map (λit::String.literal. (it, σ)) its) ⊢ expr.Let res res_t₁ res_init₁ body₁ ⇛ expr₂ ⟹ expr.Let res res_t₂ res_init₂ body₂ = expr₂; (Γ, τ) ⊢⇩C Iterate its (Some σ) res res_t₁ res_init₁ body₁ ⇛ call₂⟧ ⟹ Iterate its (Some σ) res res_t₂ res_init₂ body₂ = call₂› 5. ‹⋀(τ::'a::ocl_object_model OCL_Types.type) (σ::'a::ocl_object_model OCL_Types.type) (Γ::String.literal ⇀⇩f 'a::ocl_object_model OCL_Types.type) (res_init₁::'a::ocl_object_model expr) (res_init₂::'a::ocl_object_model expr) (its::String.literal list) (res::String.literal) (res_t₁::'a::ocl_object_model OCL_Types.type option) (body₁::'a::ocl_object_model expr) (res_t₂::'a::ocl_object_model OCL_Types.type option) (body₂::'a::ocl_object_model expr) call₂::'a::ocl_object_model call_expr. ⟦element_type τ σ; Γ ⊢ res_init₁ ⇛ res_init₂; ⋀expr₂::'a::ocl_object_model expr. Γ ⊢ res_init₁ ⇛ expr₂ ⟹ res_init₂ = expr₂; Γ ++⇩f fmap_of_list (map (λit::String.literal. (it, σ)) its) ⊢ expr.Let res res_t₁ res_init₁ body₁ ⇛ expr.Let res res_t₂ res_init₂ body₂; ⋀expr₂::'a::ocl_object_model expr. Γ ++⇩f fmap_of_list (map (λit::String.literal. (it, σ)) its) ⊢ expr.Let res res_t₁ res_init₁ body₁ ⇛ expr₂ ⟹ expr.Let res res_t₂ res_init₂ body₂ = expr₂; (Γ, τ) ⊢⇩C Iterate its None res res_t₁ res_init₁ body₁ ⇛ call₂⟧ ⟹ Iterate its (Some σ) res res_t₂ res_init₂ body₂ = call₂› 6. ‹⋀(Γ::String.literal ⇀⇩f 'a::ocl_object_model OCL_Types.type) (σ::'a::ocl_object_model OCL_Types.type) (its::String.literal list) (body₁::'a::ocl_object_model expr) (body₂::'a::ocl_object_model expr) (τ::'a::ocl_object_model OCL_Types.type) (iter::iterator) call₂::'a::ocl_object_model call_expr. ⟦Γ ++⇩f fmap_of_list (map (λit::String.literal. (it, σ)) its) ⊢ body₁ ⇛ body₂; ⋀expr₂::'a::ocl_object_model expr. Γ ++⇩f fmap_of_list (map (λit::String.literal. (it, σ)) its) ⊢ body₁ ⇛ expr₂ ⟹ body₂ = expr₂; (Γ, τ) ⊢⇩C Iterator iter its (Some σ) body₁ ⇛ call₂⟧ ⟹ Iterator iter its (Some σ) body₂ = call₂› 7. ‹⋀(τ::'a::ocl_object_model OCL_Types.type) (σ::'a::ocl_object_model OCL_Types.type) (Γ::String.literal ⇀⇩f 'a::ocl_object_model OCL_Types.type) (its::String.literal list) (body₁::'a::ocl_object_model expr) (body₂::'a::ocl_object_model expr) (iter::iterator) call₂::'a::ocl_object_model call_expr. ⟦element_type τ σ; Γ ++⇩f fmap_of_list (map (λit::String.literal. (it, σ)) its) ⊢ body₁ ⇛ body₂; ⋀expr₂::'a::ocl_object_model expr. Γ ++⇩f fmap_of_list (map (λit::String.literal. (it, σ)) its) ⊢ body₁ ⇛ expr₂ ⟹ body₂ = expr₂; (Γ, τ) ⊢⇩C Iterator iter its None body₁ ⇛ call₂⟧ ⟹ Iterator iter its (Some σ) body₂ = call₂› 8. ‹⋀(Γ::String.literal ⇀⇩f 'a::ocl_object_model OCL_Types.type) zs::'a::ocl_object_model expr list. Γ ⊢⇩L [] ⇛ zs ⟹ [] = zs› 9. ‹⋀(Γ::String.literal ⇀⇩f 'a::ocl_object_model OCL_Types.type) (x::'a::ocl_object_model expr) (y::'a::ocl_object_model expr) (xs::'a::ocl_object_model expr list) (ys::'a::ocl_object_model expr list) zs::'a::ocl_object_model expr list. ⟦Γ ⊢ x ⇛ y; ⋀expr₂::'a::ocl_object_model expr. Γ ⊢ x ⇛ expr₂ ⟹ y = expr₂; Γ ⊢⇩L xs ⇛ ys; ⋀zs::'a::ocl_object_model expr list. Γ ⊢⇩L xs ⇛ zs ⟹ ys = zs; Γ ⊢⇩L x # xs ⇛ zs⟧ ⟹ y # ys = zs›*) case (AssociationClassEndN Γ τ role) (*‹(Γ, τ) ⊢⇩C AssociationClassEnd role ⇛ call₂›*) thus "?case" (*goal: ‹AssociationClassEnd role = call₂›*) by auto next (*goals: 1. ‹⋀(Γ::String.literal ⇀⇩f 'a OCL_Types.type) (params₁::'a expr list) (params₂::'a expr list) (τ::'a OCL_Types.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) call₂::'a call_expr. ⟦Γ ⊢⇩L params₁ ⇛ params₂; ⋀zs::'a expr list. Γ ⊢⇩L params₁ ⇛ zs ⟹ params₂ = zs; (Γ, τ) ⊢⇩C Operation op params₁ ⇛ call₂⟧ ⟹ Operation op params₂ = call₂› 2. ‹⋀(Γ::String.literal ⇀⇩f 'a OCL_Types.type) (τ::'a OCL_Types.type) (elem::String.literal) call₂::'a call_expr. (Γ, τ) ⊢⇩C TupleElement elem ⇛ call₂ ⟹ TupleElement elem = call₂› 3. ‹⋀(Γ::String.literal ⇀⇩f 'a OCL_Types.type) (res_init₁::'a expr) (res_init₂::'a expr) (σ::'a OCL_Types.type) (its::String.literal list) (res::String.literal) (res_t₁::'a OCL_Types.type option) (body₁::'a expr) (res_t₂::'a OCL_Types.type option) (body₂::'a expr) (τ::'a OCL_Types.type) call₂::'a call_expr. ⟦Γ ⊢ res_init₁ ⇛ res_init₂; ⋀expr₂::'a expr. Γ ⊢ res_init₁ ⇛ expr₂ ⟹ res_init₂ = expr₂; Γ ++⇩f fmap_of_list (map (λit::String.literal. (it, σ)) its) ⊢ expr.Let res res_t₁ res_init₁ body₁ ⇛ expr.Let res res_t₂ res_init₂ body₂; ⋀expr₂::'a expr. Γ ++⇩f fmap_of_list (map (λit::String.literal. (it, σ)) its) ⊢ expr.Let res res_t₁ res_init₁ body₁ ⇛ expr₂ ⟹ expr.Let res res_t₂ res_init₂ body₂ = expr₂; (Γ, τ) ⊢⇩C Iterate its (Some σ) res res_t₁ res_init₁ body₁ ⇛ call₂⟧ ⟹ Iterate its (Some σ) res res_t₂ res_init₂ body₂ = call₂› 4. ‹⋀(τ::'a OCL_Types.type) (σ::'a OCL_Types.type) (Γ::String.literal ⇀⇩f 'a OCL_Types.type) (res_init₁::'a expr) (res_init₂::'a expr) (its::String.literal list) (res::String.literal) (res_t₁::'a OCL_Types.type option) (body₁::'a expr) (res_t₂::'a OCL_Types.type option) (body₂::'a expr) call₂::'a call_expr. ⟦element_type τ σ; Γ ⊢ res_init₁ ⇛ res_init₂; ⋀expr₂::'a expr. Γ ⊢ res_init₁ ⇛ expr₂ ⟹ res_init₂ = expr₂; Γ ++⇩f fmap_of_list (map (λit::String.literal. (it, σ)) its) ⊢ expr.Let res res_t₁ res_init₁ body₁ ⇛ expr.Let res res_t₂ res_init₂ body₂; ⋀expr₂::'a expr. Γ ++⇩f fmap_of_list (map (λit::String.literal. (it, σ)) its) ⊢ expr.Let res res_t₁ res_init₁ body₁ ⇛ expr₂ ⟹ expr.Let res res_t₂ res_init₂ body₂ = expr₂; (Γ, τ) ⊢⇩C Iterate its None res res_t₁ res_init₁ body₁ ⇛ call₂⟧ ⟹ Iterate its (Some σ) res res_t₂ res_init₂ body₂ = call₂› 5. ‹⋀(Γ::String.literal ⇀⇩f 'a OCL_Types.type) (σ::'a OCL_Types.type) (its::String.literal list) (body₁::'a expr) (body₂::'a expr) (τ::'a OCL_Types.type) (iter::iterator) call₂::'a call_expr. ⟦Γ ++⇩f fmap_of_list (map (λit::String.literal. (it, σ)) its) ⊢ body₁ ⇛ body₂; ⋀expr₂::'a expr. Γ ++⇩f fmap_of_list (map (λit::String.literal. (it, σ)) its) ⊢ body₁ ⇛ expr₂ ⟹ body₂ = expr₂; (Γ, τ) ⊢⇩C Iterator iter its (Some σ) body₁ ⇛ call₂⟧ ⟹ Iterator iter its (Some σ) body₂ = call₂› 6. ‹⋀(τ::'a OCL_Types.type) (σ::'a OCL_Types.type) (Γ::String.literal ⇀⇩f 'a OCL_Types.type) (its::String.literal list) (body₁::'a expr) (body₂::'a expr) (iter::iterator) call₂::'a call_expr. ⟦element_type τ σ; Γ ++⇩f fmap_of_list (map (λit::String.literal. (it, σ)) its) ⊢ body₁ ⇛ body₂; ⋀expr₂::'a expr. Γ ++⇩f fmap_of_list (map (λit::String.literal. (it, σ)) its) ⊢ body₁ ⇛ expr₂ ⟹ body₂ = expr₂; (Γ, τ) ⊢⇩C Iterator iter its None body₁ ⇛ call₂⟧ ⟹ Iterator iter its (Some σ) body₂ = call₂› 7. ‹⋀(Γ::String.literal ⇀⇩f 'a OCL_Types.type) zs::'a expr list. Γ ⊢⇩L [] ⇛ zs ⟹ [] = zs› 8. ‹⋀(Γ::String.literal ⇀⇩f 'a OCL_Types.type) (x::'a expr) (y::'a expr) (xs::'a expr list) (ys::'a expr list) zs::'a expr list. ⟦Γ ⊢ x ⇛ y; ⋀expr₂::'a expr. Γ ⊢ x ⇛ expr₂ ⟹ y = expr₂; Γ ⊢⇩L xs ⇛ ys; ⋀zs::'a expr list. Γ ⊢⇩L xs ⇛ zs ⟹ ys = zs; Γ ⊢⇩L x # xs ⇛ zs⟧ ⟹ y # ys = zs›*) case (OperationN Γ params₁ params₂ τ op) (*‹Γ ⊢⇩L params₁ ⇛ params₂› ‹Γ ⊢⇩L params₁ ⇛ ?zs ⟹ params₂ = ?zs› ‹(Γ, τ) ⊢⇩C Operation op params₁ ⇛ call₂›*) thus "?case" (*goal: ‹Operation op params₂ = call₂›*) by blast next (*goals: 1. ‹⋀Γ τ elem call₂. (Γ, τ) ⊢⇩C TupleElement elem ⇛ call₂ ⟹ TupleElement elem = call₂› 2. ‹⋀Γ res_init₁ res_init₂ σ its res res_t₁ body₁ res_t₂ body₂ τ call₂. ⟦Γ ⊢ res_init₁ ⇛ res_init₂; ⋀expr₂. Γ ⊢ res_init₁ ⇛ expr₂ ⟹ res_init₂ = expr₂; Γ ++⇩f fmap_of_list (map (λit. (it, σ)) its) ⊢ expr.Let res res_t₁ res_init₁ body₁ ⇛ expr.Let res res_t₂ res_init₂ body₂; ⋀expr₂. Γ ++⇩f fmap_of_list (map (λit. (it, σ)) its) ⊢ expr.Let res res_t₁ res_init₁ body₁ ⇛ expr₂ ⟹ expr.Let res res_t₂ res_init₂ body₂ = expr₂; (Γ, τ) ⊢⇩C Iterate its (Some σ) res res_t₁ res_init₁ body₁ ⇛ call₂⟧ ⟹ Iterate its (Some σ) res res_t₂ res_init₂ body₂ = call₂› 3. ‹⋀τ σ Γ res_init₁ res_init₂ its res res_t₁ body₁ res_t₂ body₂ call₂. ⟦element_type τ σ; Γ ⊢ res_init₁ ⇛ res_init₂; ⋀expr₂. Γ ⊢ res_init₁ ⇛ expr₂ ⟹ res_init₂ = expr₂; Γ ++⇩f fmap_of_list (map (λit. (it, σ)) its) ⊢ expr.Let res res_t₁ res_init₁ body₁ ⇛ expr.Let res res_t₂ res_init₂ body₂; ⋀expr₂. Γ ++⇩f fmap_of_list (map (λit. (it, σ)) its) ⊢ expr.Let res res_t₁ res_init₁ body₁ ⇛ expr₂ ⟹ expr.Let res res_t₂ res_init₂ body₂ = expr₂; (Γ, τ) ⊢⇩C Iterate its None res res_t₁ res_init₁ body₁ ⇛ call₂⟧ ⟹ Iterate its (Some σ) res res_t₂ res_init₂ body₂ = call₂› 4. ‹⋀Γ σ its body₁ body₂ τ iter call₂. ⟦Γ ++⇩f fmap_of_list (map (λit. (it, σ)) its) ⊢ body₁ ⇛ body₂; ⋀expr₂. Γ ++⇩f fmap_of_list (map (λit. (it, σ)) its) ⊢ body₁ ⇛ expr₂ ⟹ body₂ = expr₂; (Γ, τ) ⊢⇩C Iterator iter its (Some σ) body₁ ⇛ call₂⟧ ⟹ Iterator iter its (Some σ) body₂ = call₂› 5. ‹⋀τ σ Γ its body₁ body₂ iter call₂. ⟦element_type τ σ; Γ ++⇩f fmap_of_list (map (λit. (it, σ)) its) ⊢ body₁ ⇛ body₂; ⋀expr₂. Γ ++⇩f fmap_of_list (map (λit. (it, σ)) its) ⊢ body₁ ⇛ expr₂ ⟹ body₂ = expr₂; (Γ, τ) ⊢⇩C Iterator iter its None body₁ ⇛ call₂⟧ ⟹ Iterator iter its (Some σ) body₂ = call₂› 6. ‹⋀Γ zs. Γ ⊢⇩L [] ⇛ zs ⟹ [] = zs› 7. ‹⋀Γ x y xs ys zs. ⟦Γ ⊢ x ⇛ y; ⋀expr₂. Γ ⊢ x ⇛ expr₂ ⟹ y = expr₂; Γ ⊢⇩L xs ⇛ ys; ⋀zs. Γ ⊢⇩L xs ⇛ zs ⟹ ys = zs; Γ ⊢⇩L x # xs ⇛ zs⟧ ⟹ y # ys = zs›*) case (TupleElementN Γ τ elem) (*‹(Γ, τ) ⊢⇩C TupleElement elem ⇛ call₂›*) thus "?case" (*goal: ‹TupleElement elem = call₂›*) by auto next (*goals: 1. ‹⋀Γ res_init₁ res_init₂ σ its res res_t₁ body₁ res_t₂ body₂ τ call₂. ⟦Γ ⊢ res_init₁ ⇛ res_init₂; ⋀expr₂. Γ ⊢ res_init₁ ⇛ expr₂ ⟹ res_init₂ = expr₂; Γ ++⇩f fmap_of_list (map (λit. (it, σ)) its) ⊢ expr.Let res res_t₁ res_init₁ body₁ ⇛ expr.Let res res_t₂ res_init₂ body₂; ⋀expr₂. Γ ++⇩f fmap_of_list (map (λit. (it, σ)) its) ⊢ expr.Let res res_t₁ res_init₁ body₁ ⇛ expr₂ ⟹ expr.Let res res_t₂ res_init₂ body₂ = expr₂; (Γ, τ) ⊢⇩C Iterate its (Some σ) res res_t₁ res_init₁ body₁ ⇛ call₂⟧ ⟹ Iterate its (Some σ) res res_t₂ res_init₂ body₂ = call₂› 2. ‹⋀τ σ Γ res_init₁ res_init₂ its res res_t₁ body₁ res_t₂ body₂ call₂. ⟦element_type τ σ; Γ ⊢ res_init₁ ⇛ res_init₂; ⋀expr₂. Γ ⊢ res_init₁ ⇛ expr₂ ⟹ res_init₂ = expr₂; Γ ++⇩f fmap_of_list (map (λit. (it, σ)) its) ⊢ expr.Let res res_t₁ res_init₁ body₁ ⇛ expr.Let res res_t₂ res_init₂ body₂; ⋀expr₂. Γ ++⇩f fmap_of_list (map (λit. (it, σ)) its) ⊢ expr.Let res res_t₁ res_init₁ body₁ ⇛ expr₂ ⟹ expr.Let res res_t₂ res_init₂ body₂ = expr₂; (Γ, τ) ⊢⇩C Iterate its None res res_t₁ res_init₁ body₁ ⇛ call₂⟧ ⟹ Iterate its (Some σ) res res_t₂ res_init₂ body₂ = call₂› 3. ‹⋀Γ σ its body₁ body₂ τ iter call₂. ⟦Γ ++⇩f fmap_of_list (map (λit. (it, σ)) its) ⊢ body₁ ⇛ body₂; ⋀expr₂. Γ ++⇩f fmap_of_list (map (λit. (it, σ)) its) ⊢ body₁ ⇛ expr₂ ⟹ body₂ = expr₂; (Γ, τ) ⊢⇩C Iterator iter its (Some σ) body₁ ⇛ call₂⟧ ⟹ Iterator iter its (Some σ) body₂ = call₂› 4. ‹⋀τ σ Γ its body₁ body₂ iter call₂. ⟦element_type τ σ; Γ ++⇩f fmap_of_list (map (λit. (it, σ)) its) ⊢ body₁ ⇛ body₂; ⋀expr₂. Γ ++⇩f fmap_of_list (map (λit. (it, σ)) its) ⊢ body₁ ⇛ expr₂ ⟹ body₂ = expr₂; (Γ, τ) ⊢⇩C Iterator iter its None body₁ ⇛ call₂⟧ ⟹ Iterator iter its (Some σ) body₂ = call₂› 5. ‹⋀Γ zs. Γ ⊢⇩L [] ⇛ zs ⟹ [] = zs› 6. ‹⋀Γ x y xs ys zs. ⟦Γ ⊢ x ⇛ y; ⋀expr₂. Γ ⊢ x ⇛ expr₂ ⟹ y = expr₂; Γ ⊢⇩L xs ⇛ ys; ⋀zs. Γ ⊢⇩L xs ⇛ zs ⟹ ys = zs; Γ ⊢⇩L x # xs ⇛ zs⟧ ⟹ y # ys = zs›*) case (ExplicitlyTypedIterateN Γ res_init₁ res_init₂ σ its res res_t₁ body₁ res_t₂ body₂ τ) (*‹Γ ⊢ res_init₁ ⇛ res_init₂› ‹Γ ⊢ res_init₁ ⇛ ?expr₂ ⟹ res_init₂ = ?expr₂› ‹Γ ++⇩f fmap_of_list (map (λit. (it, σ)) its) ⊢ expr.Let res res_t₁ res_init₁ body₁ ⇛ expr.Let res res_t₂ res_init₂ body₂› ‹Γ ++⇩f fmap_of_list (map (λit. (it, σ)) its) ⊢ expr.Let res res_t₁ res_init₁ body₁ ⇛ ?expr₂ ⟹ expr.Let res res_t₂ res_init₂ body₂ = ?expr₂› ‹(Γ::String.literal ⇀⇩f 'a::ocl_object_model OCL_Types.type, τ::'a::ocl_object_model OCL_Types.type) ⊢⇩C Iterate (its::String.literal list) (Some (σ::'a::ocl_object_model OCL_Types.type)) (res::String.literal) (res_t₁::'a::ocl_object_model OCL_Types.type option) (res_init₁::'a::ocl_object_model expr) (body₁::'a::ocl_object_model expr) ⇛ (call₂::'a::ocl_object_model call_expr)›*) show "?case" (*goal: ‹Iterate its (Some σ) res res_t₂ res_init₂ body₂ = call₂›*) apply (insert ExplicitlyTypedIterateN.prems (*‹(Γ, τ) ⊢⇩C Iterate its (Some σ) res res_t₁ res_init₁ body₁ ⇛ call₂›*)) (*goal: ‹Iterate its (Some σ) res res_t₂ res_init₂ body₂ = call₂›*) apply (erule IterateCallNE (*‹⟦(?Γ, ?τ) ⊢⇩C Iterate ?its ?its_ty ?res ?res_t ?res_init ?body ⇛ ?call; ⋀res_init₂ σ res_t₂ body₂. ⟦?its_ty = Some σ; ?call = Iterate ?its (Some σ) ?res res_t₂ res_init₂ body₂; ?Γ ⊢ ?res_init ⇛ res_init₂; ?Γ ++⇩f fmap_of_list (map (λit. (it, σ)) ?its) ⊢ expr.Let ?res ?res_t ?res_init ?body ⇛ expr.Let ?res res_t₂ res_init₂ body₂⟧ ⟹ ?P; ⋀σ res_init₂ res_t₂ body₂. ⟦?its_ty = None; ?call = Iterate ?its (Some σ) ?res res_t₂ res_init₂ body₂; element_type ?τ σ; ?Γ ⊢ ?res_init ⇛ res_init₂; ?Γ ++⇩f fmap_of_list (map (λit. (it, σ)) ?its) ⊢ expr.Let ?res ?res_t ?res_init ?body ⇛ expr.Let ?res res_t₂ res_init₂ body₂⟧ ⟹ ?P⟧ ⟹ ?P›*)) (*goal: ‹(Γ, τ) ⊢⇩C Iterate its (Some σ) res res_t₁ res_init₁ body₁ ⇛ call₂ ⟹ Iterate its (Some σ) res res_t₂ res_init₂ body₂ = call₂›*) using ExplicitlyTypedIterateN.hyps (*‹Γ ⊢ res_init₁ ⇛ res_init₂› ‹Γ ⊢ res_init₁ ⇛ ?expr₂ ⟹ res_init₂ = ?expr₂› ‹Γ ++⇩f fmap_of_list (map (λit. (it, σ)) its) ⊢ expr.Let res res_t₁ res_init₁ body₁ ⇛ expr.Let res res_t₂ res_init₂ body₂› ‹Γ ++⇩f fmap_of_list (map (λit. (it, σ)) its) ⊢ expr.Let res res_t₁ res_init₁ body₁ ⇛ ?expr₂ ⟹ expr.Let res res_t₂ res_init₂ body₂ = ?expr₂›*) element_type_det (*‹⟦element_type (?τ::?'a OCL_Types.type) (?σ₁::?'a OCL_Types.type); element_type ?τ (?σ₂::?'a OCL_Types.type)⟧ ⟹ ?σ₁ = ?σ₂›*) (*goals: 1. ‹⋀(res_init₂'::'a expr) (σ'::'a OCL_Types.type) (res_t₂'::'a OCL_Types.type option) body₂'::'a expr. ⟦Some (σ::'a OCL_Types.type) = Some σ'; (call₂::'a call_expr) = Iterate (its::String.literal list) (Some σ') (res::String.literal) res_t₂' res_init₂' body₂'; (Γ::String.literal ⇀⇩f 'a OCL_Types.type) ⊢ (res_init₁::'a expr) ⇛ res_init₂'; Γ ++⇩f fmap_of_list (map (λit::String.literal. (it, σ')) its) ⊢ expr.Let res (res_t₁::'a OCL_Types.type option) res_init₁ (body₁::'a expr) ⇛ expr.Let res res_t₂' res_init₂' body₂'⟧ ⟹ Iterate its (Some σ) res (res_t₂::'a OCL_Types.type option) (res_init₂::'a expr) (body₂::'a expr) = call₂› 2. ‹⋀(σ'::'a OCL_Types.type) (res_init₂'::'a expr) (res_t₂'::'a OCL_Types.type option) body₂'::'a expr. ⟦Some (σ::'a OCL_Types.type) = None; (call₂::'a call_expr) = Iterate (its::String.literal list) (Some σ') (res::String.literal) res_t₂' res_init₂' body₂'; element_type (τ::'a OCL_Types.type) σ'; (Γ::String.literal ⇀⇩f 'a OCL_Types.type) ⊢ (res_init₁::'a expr) ⇛ res_init₂'; Γ ++⇩f fmap_of_list (map (λit::String.literal. (it, σ')) its) ⊢ expr.Let res (res_t₁::'a OCL_Types.type option) res_init₁ (body₁::'a expr) ⇛ expr.Let res res_t₂' res_init₂' body₂'⟧ ⟹ Iterate its (Some σ) res (res_t₂::'a OCL_Types.type option) (res_init₂::'a expr) (body₂::'a expr) = call₂› discuss goal 1*) apply blast (*discuss goal 2*) apply blast (*proven 2 subgoals*) . next (*goals: 1. ‹⋀τ σ Γ res_init₁ res_init₂ its res res_t₁ body₁ res_t₂ body₂ call₂. ⟦element_type τ σ; Γ ⊢ res_init₁ ⇛ res_init₂; ⋀expr₂. Γ ⊢ res_init₁ ⇛ expr₂ ⟹ res_init₂ = expr₂; Γ ++⇩f fmap_of_list (map (λit. (it, σ)) its) ⊢ expr.Let res res_t₁ res_init₁ body₁ ⇛ expr.Let res res_t₂ res_init₂ body₂; ⋀expr₂. Γ ++⇩f fmap_of_list (map (λit. (it, σ)) its) ⊢ expr.Let res res_t₁ res_init₁ body₁ ⇛ expr₂ ⟹ expr.Let res res_t₂ res_init₂ body₂ = expr₂; (Γ, τ) ⊢⇩C Iterate its None res res_t₁ res_init₁ body₁ ⇛ call₂⟧ ⟹ Iterate its (Some σ) res res_t₂ res_init₂ body₂ = call₂› 2. ‹⋀Γ σ its body₁ body₂ τ iter call₂. ⟦Γ ++⇩f fmap_of_list (map (λit. (it, σ)) its) ⊢ body₁ ⇛ body₂; ⋀expr₂. Γ ++⇩f fmap_of_list (map (λit. (it, σ)) its) ⊢ body₁ ⇛ expr₂ ⟹ body₂ = expr₂; (Γ, τ) ⊢⇩C Iterator iter its (Some σ) body₁ ⇛ call₂⟧ ⟹ Iterator iter its (Some σ) body₂ = call₂› 3. ‹⋀τ σ Γ its body₁ body₂ iter call₂. ⟦element_type τ σ; Γ ++⇩f fmap_of_list (map (λit. (it, σ)) its) ⊢ body₁ ⇛ body₂; ⋀expr₂. Γ ++⇩f fmap_of_list (map (λit. (it, σ)) its) ⊢ body₁ ⇛ expr₂ ⟹ body₂ = expr₂; (Γ, τ) ⊢⇩C Iterator iter its None body₁ ⇛ call₂⟧ ⟹ Iterator iter its (Some σ) body₂ = call₂› 4. ‹⋀Γ zs. Γ ⊢⇩L [] ⇛ zs ⟹ [] = zs› 5. ‹⋀Γ x y xs ys zs. ⟦Γ ⊢ x ⇛ y; ⋀expr₂. Γ ⊢ x ⇛ expr₂ ⟹ y = expr₂; Γ ⊢⇩L xs ⇛ ys; ⋀zs. Γ ⊢⇩L xs ⇛ zs ⟹ ys = zs; Γ ⊢⇩L x # xs ⇛ zs⟧ ⟹ y # ys = zs›*) case (ImplicitlyTypedIterateN τ σ Γ res_init₁ res_init₂ its res res_t₁ body₁ res_t₂ body₂) (*‹element_type τ σ› ‹Γ ⊢ res_init₁ ⇛ res_init₂› ‹Γ ⊢ res_init₁ ⇛ ?expr₂ ⟹ res_init₂ = ?expr₂› ‹Γ ++⇩f fmap_of_list (map (λit. (it, σ)) its) ⊢ expr.Let res res_t₁ res_init₁ body₁ ⇛ expr.Let res res_t₂ res_init₂ body₂› ‹(Γ::String.literal ⇀⇩f 'a OCL_Types.type) ++⇩f fmap_of_list (map (λit::String.literal. (it, σ::'a OCL_Types.type)) (its::String.literal list)) ⊢ expr.Let (res::String.literal) (res_t₁::'a OCL_Types.type option) (res_init₁::'a expr) (body₁::'a expr) ⇛ (?expr₂::'a expr) ⟹ expr.Let res (res_t₂::'a OCL_Types.type option) (res_init₂::'a expr) (body₂::'a expr) = ?expr₂› ‹(Γ, τ) ⊢⇩C Iterate its None res res_t₁ res_init₁ body₁ ⇛ call₂›*) show "?case" (*goal: ‹Iterate its (Some σ) res res_t₂ res_init₂ body₂ = call₂›*) apply (insert ImplicitlyTypedIterateN.prems (*‹(Γ, τ) ⊢⇩C Iterate its None res res_t₁ res_init₁ body₁ ⇛ call₂›*)) (*goal: ‹Iterate its (Some σ) res res_t₂ res_init₂ body₂ = call₂›*) apply (erule IterateCallNE (*‹⟦(?Γ, ?τ) ⊢⇩C Iterate ?its ?its_ty ?res ?res_t ?res_init ?body ⇛ ?call; ⋀res_init₂ σ res_t₂ body₂. ⟦?its_ty = Some σ; ?call = Iterate ?its (Some σ) ?res res_t₂ res_init₂ body₂; ?Γ ⊢ ?res_init ⇛ res_init₂; ?Γ ++⇩f fmap_of_list (map (λit. (it, σ)) ?its) ⊢ expr.Let ?res ?res_t ?res_init ?body ⇛ expr.Let ?res res_t₂ res_init₂ body₂⟧ ⟹ ?P; ⋀σ res_init₂ res_t₂ body₂. ⟦?its_ty = None; ?call = Iterate ?its (Some σ) ?res res_t₂ res_init₂ body₂; element_type ?τ σ; ?Γ ⊢ ?res_init ⇛ res_init₂; ?Γ ++⇩f fmap_of_list (map (λit. (it, σ)) ?its) ⊢ expr.Let ?res ?res_t ?res_init ?body ⇛ expr.Let ?res res_t₂ res_init₂ body₂⟧ ⟹ ?P⟧ ⟹ ?P›*)) (*goal: ‹(Γ, τ) ⊢⇩C Iterate its None res res_t₁ res_init₁ body₁ ⇛ call₂ ⟹ Iterate its (Some σ) res res_t₂ res_init₂ body₂ = call₂›*) using ImplicitlyTypedIterateN.hyps (*‹element_type τ σ› ‹Γ ⊢ res_init₁ ⇛ res_init₂› ‹Γ ⊢ res_init₁ ⇛ ?expr₂ ⟹ res_init₂ = ?expr₂› ‹Γ ++⇩f fmap_of_list (map (λit. (it, σ)) its) ⊢ expr.Let res res_t₁ res_init₁ body₁ ⇛ expr.Let res res_t₂ res_init₂ body₂› ‹(Γ::String.literal ⇀⇩f 'a OCL_Types.type) ++⇩f fmap_of_list (map (λit::String.literal. (it, σ::'a OCL_Types.type)) (its::String.literal list)) ⊢ expr.Let (res::String.literal) (res_t₁::'a OCL_Types.type option) (res_init₁::'a expr) (body₁::'a expr) ⇛ (?expr₂::'a expr) ⟹ expr.Let res (res_t₂::'a OCL_Types.type option) (res_init₂::'a expr) (body₂::'a expr) = ?expr₂›*) element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) apply - (*goals: 1. ‹⋀res_init₂' σ' res_t₂' body₂'. ⟦None = Some σ'; call₂ = Iterate its (Some σ') res res_t₂' res_init₂' body₂'; Γ ⊢ res_init₁ ⇛ res_init₂'; Γ ++⇩f fmap_of_list (map (λit. (it, σ')) its) ⊢ expr.Let res res_t₁ res_init₁ body₁ ⇛ expr.Let res res_t₂' res_init₂' body₂'; element_type τ σ; Γ ⊢ res_init₁ ⇛ res_init₂; ⋀expr₂. Γ ⊢ res_init₁ ⇛ expr₂ ⟹ res_init₂ = expr₂; Γ ++⇩f fmap_of_list (map (λit. (it, σ)) its) ⊢ expr.Let res res_t₁ res_init₁ body₁ ⇛ expr.Let res res_t₂ res_init₂ body₂; ⋀expr₂. Γ ++⇩f fmap_of_list (map (λit. (it, σ)) its) ⊢ expr.Let res res_t₁ res_init₁ body₁ ⇛ expr₂ ⟹ expr.Let res res_t₂ res_init₂ body₂ = expr₂; ⋀τ σ₁ σ₂. ⟦element_type τ σ₁; element_type τ σ₂⟧ ⟹ σ₁ = σ₂⟧ ⟹ Iterate its (Some σ) res res_t₂ res_init₂ body₂ = call₂› 2. ‹⋀σ' res_init₂' res_t₂' body₂'. ⟦None = None; call₂ = Iterate its (Some σ') res res_t₂' res_init₂' body₂'; element_type τ σ'; Γ ⊢ res_init₁ ⇛ res_init₂'; Γ ++⇩f fmap_of_list (map (λit. (it, σ')) its) ⊢ expr.Let res res_t₁ res_init₁ body₁ ⇛ expr.Let res res_t₂' res_init₂' body₂'; element_type τ σ; Γ ⊢ res_init₁ ⇛ res_init₂; ⋀expr₂. Γ ⊢ res_init₁ ⇛ expr₂ ⟹ res_init₂ = expr₂; Γ ++⇩f fmap_of_list (map (λit. (it, σ)) its) ⊢ expr.Let res res_t₁ res_init₁ body₁ ⇛ expr.Let res res_t₂ res_init₂ body₂; ⋀expr₂. Γ ++⇩f fmap_of_list (map (λit. (it, σ)) its) ⊢ expr.Let res res_t₁ res_init₁ body₁ ⇛ expr₂ ⟹ expr.Let res res_t₂ res_init₂ body₂ = expr₂; ⋀τ σ₁ σ₂. ⟦element_type τ σ₁; element_type τ σ₂⟧ ⟹ σ₁ = σ₂⟧ ⟹ Iterate its (Some σ) res res_t₂ res_init₂ body₂ = call₂› discuss goal 1*) apply blast (*discuss goal 2*) apply blast (*proven 2 subgoals*) . next (*goals: 1. ‹⋀Γ σ its body₁ body₂ τ iter call₂. ⟦Γ ++⇩f fmap_of_list (map (λit. (it, σ)) its) ⊢ body₁ ⇛ body₂; ⋀expr₂. Γ ++⇩f fmap_of_list (map (λit. (it, σ)) its) ⊢ body₁ ⇛ expr₂ ⟹ body₂ = expr₂; (Γ, τ) ⊢⇩C Iterator iter its (Some σ) body₁ ⇛ call₂⟧ ⟹ Iterator iter its (Some σ) body₂ = call₂› 2. ‹⋀τ σ Γ its body₁ body₂ iter call₂. ⟦element_type τ σ; Γ ++⇩f fmap_of_list (map (λit. (it, σ)) its) ⊢ body₁ ⇛ body₂; ⋀expr₂. Γ ++⇩f fmap_of_list (map (λit. (it, σ)) its) ⊢ body₁ ⇛ expr₂ ⟹ body₂ = expr₂; (Γ, τ) ⊢⇩C Iterator iter its None body₁ ⇛ call₂⟧ ⟹ Iterator iter its (Some σ) body₂ = call₂› 3. ‹⋀Γ zs. Γ ⊢⇩L [] ⇛ zs ⟹ [] = zs› 4. ‹⋀Γ x y xs ys zs. ⟦Γ ⊢ x ⇛ y; ⋀expr₂. Γ ⊢ x ⇛ expr₂ ⟹ y = expr₂; Γ ⊢⇩L xs ⇛ ys; ⋀zs. Γ ⊢⇩L xs ⇛ zs ⟹ ys = zs; Γ ⊢⇩L x # xs ⇛ zs⟧ ⟹ y # ys = zs›*) case (ExplicitlyTypedIteratorN Γ σ its body₁ body₂ τ iter) (*‹Γ ++⇩f fmap_of_list (map (λit. (it, σ)) its) ⊢ body₁ ⇛ body₂› ‹Γ ++⇩f fmap_of_list (map (λit. (it, σ)) its) ⊢ body₁ ⇛ ?expr₂ ⟹ body₂ = ?expr₂› ‹(Γ, τ) ⊢⇩C Iterator iter its (Some σ) body₁ ⇛ call₂›*) show "?case" (*goal: ‹Iterator iter its (Some σ) body₂ = call₂›*) apply (insert ExplicitlyTypedIteratorN.prems (*‹(Γ, τ) ⊢⇩C Iterator iter its (Some σ) body₁ ⇛ call₂›*)) (*goal: ‹Iterator iter its (Some σ) body₂ = call₂›*) apply (erule IteratorCallNE (*‹⟦(?Γ, ?τ) ⊢⇩C Iterator ?iter ?its ?its_ty ?body ⇛ ?call; ⋀σ body₂. ⟦?its_ty = Some σ; ?call = Iterator ?iter ?its (Some σ) body₂; ?Γ ++⇩f fmap_of_list (map (λit. (it, σ)) ?its) ⊢ ?body ⇛ body₂⟧ ⟹ ?P; ⋀σ body₂. ⟦?its_ty = None; ?call = Iterator ?iter ?its (Some σ) body₂; element_type ?τ σ; ?Γ ++⇩f fmap_of_list (map (λit. (it, σ)) ?its) ⊢ ?body ⇛ body₂⟧ ⟹ ?P⟧ ⟹ ?P›*)) (*goal: ‹(Γ, τ) ⊢⇩C Iterator iter its (Some σ) body₁ ⇛ call₂ ⟹ Iterator iter its (Some σ) body₂ = call₂›*) using ExplicitlyTypedIteratorN.hyps (*‹Γ ++⇩f fmap_of_list (map (λit. (it, σ)) its) ⊢ body₁ ⇛ body₂› ‹Γ ++⇩f fmap_of_list (map (λit. (it, σ)) its) ⊢ body₁ ⇛ ?expr₂ ⟹ body₂ = ?expr₂›*) element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) (*goals: 1. ‹⋀σ' body₂'. ⟦Some σ = Some σ'; call₂ = Iterator iter its (Some σ') body₂'; Γ ++⇩f fmap_of_list (map (λit. (it, σ')) its) ⊢ body₁ ⇛ body₂'⟧ ⟹ Iterator iter its (Some σ) body₂ = call₂› 2. ‹⋀σ' body₂'. ⟦Some σ = None; call₂ = Iterator iter its (Some σ') body₂'; element_type τ σ'; Γ ++⇩f fmap_of_list (map (λit. (it, σ')) its) ⊢ body₁ ⇛ body₂'⟧ ⟹ Iterator iter its (Some σ) body₂ = call₂› discuss goal 1*) apply blast (*discuss goal 2*) apply blast (*proven 2 subgoals*) . next (*goals: 1. ‹⋀(τ::'a::ocl_object_model OCL_Types.type) (σ::'a::ocl_object_model OCL_Types.type) (Γ::String.literal ⇀⇩f 'a::ocl_object_model OCL_Types.type) (its::String.literal list) (body₁::'a::ocl_object_model expr) (body₂::'a::ocl_object_model expr) (iter::iterator) call₂::'a::ocl_object_model call_expr. ⟦element_type τ σ; Γ ++⇩f fmap_of_list (map (λit::String.literal. (it, σ)) its) ⊢ body₁ ⇛ body₂; ⋀expr₂::'a::ocl_object_model expr. Γ ++⇩f fmap_of_list (map (λit::String.literal. (it, σ)) its) ⊢ body₁ ⇛ expr₂ ⟹ body₂ = expr₂; (Γ, τ) ⊢⇩C Iterator iter its None body₁ ⇛ call₂⟧ ⟹ Iterator iter its (Some σ) body₂ = call₂› 2. ‹⋀(Γ::String.literal ⇀⇩f 'a::ocl_object_model OCL_Types.type) zs::'a::ocl_object_model expr list. Γ ⊢⇩L [] ⇛ zs ⟹ [] = zs› 3. ‹⋀(Γ::String.literal ⇀⇩f 'a::ocl_object_model OCL_Types.type) (x::'a::ocl_object_model expr) (y::'a::ocl_object_model expr) (xs::'a::ocl_object_model expr list) (ys::'a::ocl_object_model expr list) zs::'a::ocl_object_model expr list. ⟦Γ ⊢ x ⇛ y; ⋀expr₂::'a::ocl_object_model expr. Γ ⊢ x ⇛ expr₂ ⟹ y = expr₂; Γ ⊢⇩L xs ⇛ ys; ⋀zs::'a::ocl_object_model expr list. Γ ⊢⇩L xs ⇛ zs ⟹ ys = zs; Γ ⊢⇩L x # xs ⇛ zs⟧ ⟹ y # ys = zs›*) case (ImplicitlyTypedIteratorN τ σ Γ its body₁ body₂ iter) (*‹element_type τ σ› ‹Γ ++⇩f fmap_of_list (map (λit. (it, σ)) its) ⊢ body₁ ⇛ body₂› ‹Γ ++⇩f fmap_of_list (map (λit. (it, σ)) its) ⊢ body₁ ⇛ ?expr₂ ⟹ body₂ = ?expr₂› ‹(Γ::String.literal ⇀⇩f 'a OCL_Types.type, τ::'a OCL_Types.type) ⊢⇩C Iterator (iter::iterator) (its::String.literal list) None (body₁::'a expr) ⇛ (call₂::'a call_expr)›*) show "?case" (*goal: ‹Iterator iter its (Some σ) body₂ = call₂›*) apply (insert ImplicitlyTypedIteratorN.prems (*‹(Γ::String.literal ⇀⇩f 'a OCL_Types.type, τ::'a OCL_Types.type) ⊢⇩C Iterator (iter::iterator) (its::String.literal list) None (body₁::'a expr) ⇛ (call₂::'a call_expr)›*)) (*goal: ‹Iterator iter its (Some σ) body₂ = call₂›*) apply (erule IteratorCallNE (*‹⟦(?Γ, ?τ) ⊢⇩C Iterator ?iter ?its ?its_ty ?body ⇛ ?call; ⋀σ body₂. ⟦?its_ty = Some σ; ?call = Iterator ?iter ?its (Some σ) body₂; ?Γ ++⇩f fmap_of_list (map (λit. (it, σ)) ?its) ⊢ ?body ⇛ body₂⟧ ⟹ ?P; ⋀σ body₂. ⟦?its_ty = None; ?call = Iterator ?iter ?its (Some σ) body₂; element_type ?τ σ; ?Γ ++⇩f fmap_of_list (map (λit. (it, σ)) ?its) ⊢ ?body ⇛ body₂⟧ ⟹ ?P⟧ ⟹ ?P›*)) (*goal: ‹(Γ, τ) ⊢⇩C Iterator iter its None body₁ ⇛ call₂ ⟹ Iterator iter its (Some σ) body₂ = call₂›*) using ImplicitlyTypedIteratorN.hyps (*‹element_type (τ::'a::ocl_object_model OCL_Types.type) (σ::'a::ocl_object_model OCL_Types.type)› ‹Γ ++⇩f fmap_of_list (map (λit. (it, σ)) its) ⊢ body₁ ⇛ body₂› ‹Γ ++⇩f fmap_of_list (map (λit. (it, σ)) its) ⊢ body₁ ⇛ ?expr₂ ⟹ body₂ = ?expr₂›*) element_type_det (*‹⟦element_type (?τ::?'a OCL_Types.type) (?σ₁::?'a OCL_Types.type); element_type ?τ (?σ₂::?'a OCL_Types.type)⟧ ⟹ ?σ₁ = ?σ₂›*) apply - (*goals: 1. ‹⋀(σ'::'a OCL_Types.type) body₂'::'a expr. ⟦None = Some σ'; (call₂::'a call_expr) = Iterator (iter::iterator) (its::String.literal list) (Some σ') body₂'; (Γ::String.literal ⇀⇩f 'a OCL_Types.type) ++⇩f fmap_of_list (map (λit::String.literal. (it, σ')) its) ⊢ (body₁::'a expr) ⇛ body₂'; element_type (τ::'a OCL_Types.type) (σ::'a OCL_Types.type); Γ ++⇩f fmap_of_list (map (λit::String.literal. (it, σ)) its) ⊢ body₁ ⇛ (body₂::'a expr); ⋀expr₂::'a expr. Γ ++⇩f fmap_of_list (map (λit::String.literal. (it, σ)) its) ⊢ body₁ ⇛ expr₂ ⟹ body₂ = expr₂; ⋀(τ::?'a14 OCL_Types.type) (σ₁::?'a14 OCL_Types.type) σ₂::?'a14 OCL_Types.type. ⟦element_type τ σ₁; element_type τ σ₂⟧ ⟹ σ₁ = σ₂⟧ ⟹ Iterator iter its (Some σ) body₂ = call₂› 2. ‹⋀(σ'::'a OCL_Types.type) body₂'::'a expr. ⟦None = None; (call₂::'a call_expr) = Iterator (iter::iterator) (its::String.literal list) (Some σ') body₂'; element_type (τ::'a OCL_Types.type) σ'; (Γ::String.literal ⇀⇩f 'a OCL_Types.type) ++⇩f fmap_of_list (map (λit::String.literal. (it, σ')) its) ⊢ (body₁::'a expr) ⇛ body₂'; element_type τ (σ::'a OCL_Types.type); Γ ++⇩f fmap_of_list (map (λit::String.literal. (it, σ)) its) ⊢ body₁ ⇛ (body₂::'a expr); ⋀expr₂::'a expr. Γ ++⇩f fmap_of_list (map (λit::String.literal. (it, σ)) its) ⊢ body₁ ⇛ expr₂ ⟹ body₂ = expr₂; ⋀(τ::?'a8 OCL_Types.type) (σ₁::?'a8 OCL_Types.type) σ₂::?'a8 OCL_Types.type. ⟦element_type τ σ₁; element_type τ σ₂⟧ ⟹ σ₁ = σ₂⟧ ⟹ Iterator iter its (Some σ) body₂ = call₂› discuss goal 1*) apply blast (*discuss goal 2*) apply blast (*proven 2 subgoals*) . next (*goals: 1. ‹⋀(Γ::String.literal ⇀⇩f 'a OCL_Types.type) zs::'a expr list. Γ ⊢⇩L [] ⇛ zs ⟹ [] = zs› 2. ‹⋀(Γ::String.literal ⇀⇩f 'a OCL_Types.type) (x::'a expr) (y::'a expr) (xs::'a expr list) (ys::'a expr list) zs::'a expr list. ⟦Γ ⊢ x ⇛ y; ⋀expr₂::'a expr. Γ ⊢ x ⇛ expr₂ ⟹ y = expr₂; Γ ⊢⇩L xs ⇛ ys; ⋀zs::'a expr list. Γ ⊢⇩L xs ⇛ zs ⟹ ys = zs; Γ ⊢⇩L x # xs ⇛ zs⟧ ⟹ y # ys = zs›*) case (ExprListNilN Γ) (*‹(Γ::String.literal ⇀⇩f 'a::ocl_object_model OCL_Types.type) ⊢⇩L [] ⇛ (zs::'a::ocl_object_model expr list)›*) thus "?case" (*goal: ‹[] = zs›*) using normalize_expr_list.cases (*‹⟦?a1.0 ⊢⇩L ?a2.0 ⇛ ?a3.0; ⋀Γ. ⟦?a1.0 = Γ; ?a2.0 = []; ?a3.0 = []⟧ ⟹ ?P; ⋀Γ x y xs ys. ⟦?a1.0 = Γ; ?a2.0 = x # xs; ?a3.0 = y # ys; Γ ⊢ x ⇛ y; Γ ⊢⇩L xs ⇛ ys⟧ ⟹ ?P⟧ ⟹ ?P›*) by auto next (*goal: ‹⋀Γ x y xs ys zs. ⟦Γ ⊢ x ⇛ y; ⋀expr₂. Γ ⊢ x ⇛ expr₂ ⟹ y = expr₂; Γ ⊢⇩L xs ⇛ ys; ⋀zs. Γ ⊢⇩L xs ⇛ zs ⟹ ys = zs; Γ ⊢⇩L x # xs ⇛ zs⟧ ⟹ y # ys = zs›*) case (ExprListConsN Γ x y xs ys) (*‹Γ ⊢ x ⇛ y› ‹Γ ⊢ x ⇛ ?expr₂ ⟹ y = ?expr₂› ‹Γ ⊢⇩L xs ⇛ ys› ‹Γ ⊢⇩L xs ⇛ ?zs ⟹ ys = ?zs› ‹Γ ⊢⇩L x # xs ⇛ zs›*) thus "?case" (*goal: ‹y # ys = zs›*) by blast qed (*** Normalized Expressions Typing ******************************************) section ‹Normalized Expressions Typing› text ‹ Here is the final typing rules.› inductive nf_typing ("(1_/ ⊢/ (_ :/ _))" [51,51,51] 50) where "Γ ⊢ expr ⇛ expr⇩N ⟹ Γ ⊢⇩E expr⇩N : τ ⟹ Γ ⊢ expr : τ" lemma nf_typing_det: "Γ ⊢ expr : τ ⟹ Γ ⊢ expr : σ ⟹ τ = σ" by (metis nf_typing.cases (*‹⟦(?a1.0::String.literal ⇀⇩f ?'a OCL_Types.type) ⊢ (?a2.0::?'a expr) : (?a3.0::?'a OCL_Types.type); ⋀(Γ::String.literal ⇀⇩f ?'a OCL_Types.type) (expr::?'a expr) (expr⇩N::?'a expr) τ::?'a OCL_Types.type. ⟦?a1.0 = Γ; ?a2.0 = expr; ?a3.0 = τ; Γ ⊢ expr ⇛ expr⇩N; Γ ⊢⇩E expr⇩N : τ⟧ ⟹ ?P::bool⟧ ⟹ ?P›*) normalize_det (*‹⟦(?Γ::String.literal ⇀⇩f ?'a OCL_Types.type) ⊢ (?expr::?'a expr) ⇛ (?expr₁::?'a expr); ?Γ ⊢ ?expr ⇛ (?expr₂::?'a expr)⟧ ⟹ ?expr₁ = ?expr₂›*) typing_det (*‹⟦(?Γ::String.literal ⇀⇩f ?'a OCL_Types.type) ⊢⇩E (?expr::?'a expr) : (?τ::?'a OCL_Types.type); ?Γ ⊢⇩E ?expr : (?σ::?'a OCL_Types.type)⟧ ⟹ ?τ = ?σ›*)) (*** Code Setup *************************************************************) section ‹Code Setup› code_pred normalize . code_pred nf_typing . definition "check_type Γ expr τ ≡ Predicate.eval (nf_typing_i_i_i Γ expr τ) ()" definition "synthesize_type Γ expr ≡ Predicate.singleton (λ_. OclInvalid) (Predicate.map errorable (nf_typing_i_i_o Γ expr))" text ‹ It is the only usage of the @{text OclInvalid} type. This type is not required to define typing rules. It is only required to make the typing function total.› end
{ "path": "afp-2025-02-12/thys/Safe_OCL/OCL_Normalization.thy", "repo": "afp-2025-02-12", "sha": "9e473953895e48e1813c04ae42527d27ba80a3a5f61a1713a00b92f801fdbdac" }
theory InductRules imports Main begin lemma disjCases2[consumes 1, case_names 1 2]: assumes AB: "A ∨ B" and AP: "A ⟹ P" and BP: "B ⟹ P" shows "P" proof (-) (*goal: ‹P›*) from AB (*‹A ∨ B›*) AP (*‹A ⟹ P›*) BP (*‹B ⟹ P›*) show "?thesis" (*goal: ‹P::bool›*) by blast qed lemma disjCases3[consumes 1, case_names 1 2 3]: assumes AB: "A ∨ B ∨ C" and AP: "A ⟹ P" and BP: "B ⟹ P" and CP: "C ⟹ P" shows "P" proof (-) (*goal: ‹P›*) from AB (*‹A ∨ B ∨ C›*) AP (*‹A ⟹ P›*) BP (*‹B ⟹ P›*) CP (*‹C::bool ⟹ P::bool›*) show "?thesis" (*goal: ‹P›*) by blast qed lemma disjCases4[consumes 1, case_names 1 2 3 4]: assumes AB: "A ∨ B ∨ C ∨ D" and AP: "A ⟹ P" and BP: "B ⟹ P" and CP: "C ⟹ P" and DP: "D ⟹ P" shows "P" proof (-) (*goal: ‹P›*) from AB (*‹A ∨ B ∨ C ∨ D›*) AP (*‹A ⟹ P›*) BP (*‹B::bool ⟹ P::bool›*) CP (*‹C ⟹ P›*) DP (*‹D::bool ⟹ P::bool›*) show "?thesis" (*goal: ‹P::bool›*) by blast qed lemma disjCases5[consumes 1, case_names 1 2 3 4 5]: assumes AB: "A ∨ B ∨ C ∨ D ∨ E" and AP: "A ⟹ P" and BP: "B ⟹ P" and CP: "C ⟹ P" and DP: "D ⟹ P" and EP: "E ⟹ P" shows "P" proof (-) (*goal: ‹P::bool›*) from AB (*‹A ∨ B ∨ C ∨ D ∨ E›*) AP (*‹A ⟹ P›*) BP (*‹B ⟹ P›*) CP (*‹C::bool ⟹ P::bool›*) DP (*‹D ⟹ P›*) EP (*‹E ⟹ P›*) show "?thesis" (*goal: ‹P›*) by blast qed lemma minimal_witness_ex: assumes k: "P (k::nat)" shows "∃ k0. k0 ≤ k ∧ P k0 ∧ (∀ k. k < k0 ⟶ ¬ (P k))" proof (-) (*goal: ‹∃k0≤k::nat. (P::nat ⇒ bool) k0 ∧ (∀k<k0. ¬ P k)›*) let ?K = "{ h. h ≤ k ∧ P h }" have finite_K: "finite ?K" by auto have "k ∈ ?K" by (simp add: k (*‹P k›*)) then have nonempty_K: "?K ≠ {}" by auto let ?k = "Min ?K" have witness: "?k ≤ k ∧ P ?k" by (metis (mono_tags, lifting) Min_in (*‹⟦finite ?A; ?A ≠ {}⟧ ⟹ Min ?A ∈ ?A›*) finite_K (*‹finite {h. h ≤ k ∧ P h}›*) mem_Collect_eq (*‹(?a ∈ Collect ?P) = ?P ?a›*) nonempty_K (*‹{h. h ≤ k ∧ P h} ≠ {}›*)) have minimal: "∀ h. h < ?k ⟶ ¬ (P h)" by (metis Min_le (*‹⟦finite ?A; ?x ∈ ?A⟧ ⟹ Min ?A ≤ ?x›*) witness (*‹Min {h. h ≤ k ∧ P h} ≤ k ∧ P (Min {h. h ≤ k ∧ P h})›*) dual_order.strict_implies_order (*‹?b < ?a ⟹ ?b ≤ ?a›*) dual_order.trans (*‹⟦?b ≤ ?a; ?c ≤ ?b⟧ ⟹ ?c ≤ ?a›*) finite_K (*‹finite {h. h ≤ k ∧ P h}›*) leD (*‹?y ≤ ?x ⟹ ¬ ?x < ?y›*) mem_Collect_eq (*‹(?a ∈ Collect ?P) = ?P ?a›*)) from witness (*‹Min {h. h ≤ k ∧ P h} ≤ k ∧ P (Min {h. h ≤ k ∧ P h})›*) minimal (*‹∀h<Min {h. h ≤ k ∧ P h}. ¬ P h›*) show "?thesis" (*goal: ‹∃k0≤k. P k0 ∧ (∀k<k0. ¬ P k)›*) by metis qed lemma minimal_witness[consumes 1, case_names Minimal]: assumes "P (k::nat)" and "⋀ K. K ≤ k ⟹ P K ⟹ (⋀ k. k < K ⟹ ¬ (P k)) ⟹ Q" shows "Q" proof (-) (*goal: ‹Q›*) from assms (*‹P k› ‹⟦?K ≤ k; P ?K; ⋀k. k < ?K ⟹ ¬ P k⟧ ⟹ Q›*) minimal_witness_ex (*‹(?P::nat ⇒ bool) (?k::nat) ⟹ ∃k0≤?k. ?P k0 ∧ (∀k<k0. ¬ ?P k)›*) show "?thesis" (*goal: ‹Q›*) by metis qed lemma ex_minimal_witness[consumes 1, case_names Minimal]: assumes "∃ k. P (k::nat)" and "⋀ K. P K ⟹ (⋀ k. k < K ⟹ ¬ (P k)) ⟹ Q" shows "Q" proof (-) (*goal: ‹Q›*) from assms (*‹∃k::nat. (P::nat ⇒ bool) k› ‹⟦P ?K; ⋀k. k < ?K ⟹ ¬ P k⟧ ⟹ Q›*) minimal_witness_ex (*‹?P ?k ⟹ ∃k0≤?k. ?P k0 ∧ (∀k<k0. ¬ ?P k)›*) show "?thesis" (*goal: ‹Q›*) by metis qed end
{ "path": "afp-2025-02-12/thys/LocalLexing/InductRules.thy", "repo": "afp-2025-02-12", "sha": "1ab36d6cd27fcb09a3bcfc50ede8c3999a6a0ce9c242543e4f60bc0742525ea2" }
section ‹Counting Irreducible Polynomials \label{sec:card_irred}› subsection ‹The polynomial $X^n - X$› theory Card_Irreducible_Polynomials_Aux imports "HOL-Algebra.Multiplicative_Group" Formal_Polynomial_Derivatives Monic_Polynomial_Factorization begin lemma (in domain) assumes "subfield K R" assumes "f ∈ carrier (K[X])" "degree f > 0" shows embed_inj: "inj_on (rupture_surj K f ∘ poly_of_const) K" and rupture_order: "order (Rupt K f) = card K^degree f" and rupture_char: "char (Rupt K f) = char R" proof (-) (*goals: 1. ‹inj_on (rupture_surj K f ∘ poly_of_const) K› 2. ‹order (Rupt K f) = card K ^ degree f› 3. ‹char (Rupt K f) = char R›*) interpret p: principal_domain "K[X]" using univ_poly_is_principal[OF assms ( 1 )] (*‹principal_domain (K [X])›*) by simp interpret I: ideal "PIdl⇘K[X]⇙ f" "K[X]" using p.cgenideal_ideal[OF assms ( 2 )] (*‹ideal (PIdl⇘K [X]⇙ f) (K [X])›*) by simp interpret d: ring "Rupt K f" unfolding rupture_def (*goal: ‹ring (K [X] Quot PIdl⇘K [X]⇙ f)›*) using I.quotient_is_ring (*‹ring (K [X] Quot PIdl⇘K [X]⇙ f)›*) by simp have e: "subring K R" using assms(1) (*‹subfield K R›*) subfieldE(1) (*‹subfield (?K::?'a set) (?R::(?'a, ?'b) ring_scheme) ⟹ subring ?K ?R›*) by auto interpret h: ring_hom_ring "R ⦇ carrier := K ⦈" "Rupt K f" "rupture_surj K f ∘ poly_of_const" using rupture_surj_norm_is_hom[OF e assms ( 2 )] (*‹rupture_surj K f ∘ poly_of_const ∈ ring_hom (R⦇carrier := K⦈) (Rupt K f)›*) using ring_hom_ringI2 (*‹⟦ring ?R; ring ?S; ?h ∈ ring_hom ?R ?S⟧ ⟹ ring_hom_ring ?R ?S ?h›*) subring_is_ring (*‹subring ?H R ⟹ ring (R⦇carrier := ?H⦈)›*) d.ring_axioms (*‹ring (Rupt K f)›*) e (*‹subring K R›*) by blast have "field (R ⦇carrier := K⦈)" using assms(1) (*‹subfield K R›*) subfield_iff(2) (*‹subfield ?K R ⟹ field (R⦇carrier := ?K⦈)›*) by simp hence "subfield K (R⦇carrier := K⦈)" using ring.subfield_iff[OF subring_is_ring [ OF e ]] (*‹⟦field (R⦇carrier := K, carrier := ?K⦈); ?K ⊆ carrier (R⦇carrier := K⦈)⟧ ⟹ subfield ?K (R⦇carrier := K⦈)› ‹subfield ?K (R⦇carrier := K⦈) ⟹ field (R⦇carrier := K, carrier := ?K⦈)›*) by simp hence b: "subfield (rupture_surj K f ` poly_of_const ` K) (Rupt K f)" unfolding image_image comp_def[symmetric] (*goal: ‹subfield ((rupture_surj K f ∘ poly_of_const) ` K) (Rupt K f)›*) apply (intro h.img_is_subfield (*‹⟦subfield ?K (R⦇carrier := K⦈); 𝟭⇘Rupt K f⇙ ≠ 𝟬⇘Rupt K f⇙⟧ ⟹ inj_on (rupture_surj K f ∘ poly_of_const) ?K› ‹⟦subfield ?K (R⦇carrier := K⦈); 𝟭⇘Rupt K f⇙ ≠ 𝟬⇘Rupt K f⇙⟧ ⟹ subfield ((rupture_surj K f ∘ poly_of_const) ` ?K) (Rupt K f)›*) rupture_one_not_zero (*‹⟦subfield ?K R; ?p ∈ carrier (?K [X]); 0 < degree ?p⟧ ⟹ 𝟭⇘Rupt ?K ?p⇙ ≠ 𝟬⇘Rupt ?K ?p⇙›*) assms (*‹subfield K R› ‹f ∈ carrier (K [X])› ‹0 < degree f›*)) (*goal: ‹subfield ((rupture_surj K f ∘ poly_of_const) ` K) (Rupt K f)›*) by simp have "inj_on poly_of_const K" using poly_of_const_inj (*‹inj poly_of_const›*) inj_on_subset (*‹⟦inj_on (?f::?'a ⇒ ?'b) (?A::?'a set); (?B::?'a set) ⊆ ?A⟧ ⟹ inj_on ?f ?B›*) by auto moreover have "poly_of_const ` K ⊆ ((λq. q pmod f) ` carrier (K [X]))" proof (rule image_subsetI (*‹(⋀x. x ∈ ?A ⟹ ?f x ∈ ?B) ⟹ ?f ` ?A ⊆ ?B›*)) (*goal: ‹⋀x. x ∈ K ⟹ poly_of_const x ∈ (λq. q pmod f) ` carrier (K [X])›*) fix x assume "x ∈ K" (*‹(x::'a) ∈ (K::'a set)›*) hence f: "poly_of_const x ∈ carrier (K[X])" "degree (poly_of_const x) = 0" using poly_of_const_over_subfield[OF assms ( 1 )] (*‹poly_of_const ` K = {p ∈ carrier (K [X]). degree p = 0}›*) apply - (*goals: 1. ‹⟦x ∈ K; poly_of_const ` K = {p ∈ carrier (K [X]). degree p = 0}⟧ ⟹ poly_of_const x ∈ carrier (K [X])› 2. ‹⟦x ∈ K; poly_of_const ` K = {p ∈ carrier (K [X]). degree p = 0}⟧ ⟹ degree (poly_of_const x) = 0› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . moreover have "degree (poly_of_const x) < degree f" using f(2) (*‹degree (poly_of_const (x::'a::type)) = (0::nat)›*) assms (*‹subfield (K::'a set) R› ‹f ∈ carrier (K [X])› ‹0 < degree f›*) by simp hence "poly_of_const x pmod f = poly_of_const x" apply (intro pmod_const(2)[OF assms(1)] (*‹⟦(?p::'a list) ∈ carrier (K::'a set [X]); (?q::'a list) ∈ carrier (K [X]); degree ?p < degree ?q⟧ ⟹ ?p pmod ?q = ?p›*) f (*‹poly_of_const (x::'a) ∈ carrier (K::'a set [X])› ‹degree (poly_of_const (x::'a)) = (0::nat)›*) assms( (*‹(f::'a list) ∈ carrier (K::'a set [X])›*) 2)) (*goal: ‹poly_of_const x pmod f = poly_of_const x›*) by simp ultimately show "poly_of_const x ∈ ((λq. q pmod f) ` carrier (K [X]))" by force qed hence "inj_on (rupture_surj K f) (poly_of_const ` K)" using rupture_surj_inj_on[OF assms ( 1 , 2 )] (*‹inj_on (rupture_surj (K::'a set) (f::'a list)) ((λq::'a list. q pmod f) ` carrier (K [X]))›*) inj_on_subset (*‹⟦inj_on ?f ?A; ?B ⊆ ?A⟧ ⟹ inj_on ?f ?B›*) by blast ultimately show d: "inj_on (rupture_surj K f ∘ poly_of_const) K" using comp_inj_on (*‹⟦inj_on ?f ?A; inj_on ?g (?f ` ?A)⟧ ⟹ inj_on (?g ∘ ?f) ?A›*) by auto have a: "d.dimension (degree f) (rupture_surj K f ` poly_of_const ` K) (carrier (Rupt K f))" using rupture_dimension[OF assms ( 1 - 3 )] (*‹d.dimension (degree f) (rupture_surj K f ` poly_of_const ` K) (carrier (Rupt K f))›*) by auto then obtain base where base_def: "set base ⊆ carrier (Rupt K f)" "d.independent (rupture_surj K f ` poly_of_const ` K) base" "length base = degree f" "d.Span (rupture_surj K f ` poly_of_const ` K) base = carrier (Rupt K f)" (*goal: ‹(⋀base. ⟦set base ⊆ carrier (Rupt K f); d.independent (rupture_surj K f ` poly_of_const ` K) base; length base = degree f; d.Span (rupture_surj K f ` poly_of_const ` K) base = carrier (Rupt K f)⟧ ⟹ thesis) ⟹ thesis›*) using d.exists_base[OF b a] (*‹∃Vs. set Vs ⊆ carrier (Rupt K f) ∧ d.independent (rupture_surj K f ` poly_of_const ` K) Vs ∧ length Vs = degree f ∧ d.Span (rupture_surj K f ` poly_of_const ` K) Vs = carrier (Rupt K f)›*) by auto have "order (Rupt K f) = card (d.Span (rupture_surj K f ` poly_of_const ` K) base)" unfolding order_def base_def(4) (*goal: ‹card (carrier (Rupt K f)) = card (carrier (Rupt K f))›*) by simp also (*calculation: ‹order (Rupt K f) = card (d.Span (rupture_surj K f ` poly_of_const ` K) base)›*) have "... = card (rupture_surj K f ` poly_of_const ` K) ^ length base" using d.card_span[OF b base_def ( 2 , 1 )] (*‹card (d.Span (rupture_surj (K::'a set) (f::'a list) ` poly_of_const ` K) (base::'a list set list)) = card (rupture_surj K f ` poly_of_const ` K) ^ length base›*) by simp also (*calculation: ‹order (Rupt K f) = card (rupture_surj K f ` poly_of_const ` K) ^ length base›*) have "... = card ((rupture_surj K f ∘ poly_of_const) ` K) ^ degree f" using base_def(3) (*‹length (base::'a list set list) = degree (f::'a list)›*) image_image (*‹?f ` ?g ` ?A = (λx. ?f (?g x)) ` ?A›*) unfolding comp_def (*goal: ‹card (rupture_surj K f ` poly_of_const ` K) ^ length base = card ((λx. rupture_surj K f (poly_of_const x)) ` K) ^ degree f›*) by metis also (*calculation: ‹order (Rupt (K::'a set) (f::'a list)) = card ((rupture_surj K f ∘ poly_of_const) ` K) ^ degree f›*) have "... = card K^degree f" apply (subst card_image[OF d] (*‹card ((rupture_surj (K::'a set) (f::'a list) ∘ poly_of_const) ` K) = card K›*)) (*goal: ‹card ((rupture_surj K f ∘ poly_of_const) ` K) ^ degree f = card K ^ degree f›*) by simp finally (*calculation: ‹order (Rupt K f) = card K ^ degree f›*) show "order (Rupt K f) = card K^degree f" by simp have "char (Rupt K f) = char (R ⦇ carrier := K ⦈)" using h.char_consistent (*‹inj_on (rupture_surj K f ∘ poly_of_const) (carrier (R⦇carrier := K⦈)) ⟹ char (R⦇carrier := K⦈) = char (Rupt K f)›*) d (*‹inj_on (rupture_surj K f ∘ poly_of_const) K›*) by simp also (*calculation: ‹char (Rupt K f) = char (R⦇carrier := K⦈)›*) have "... = char R" using char_consistent[OF subfieldE ( 1 ) [ OF assms ( 1 ) ]] (*‹char (R⦇carrier := K⦈) = char R›*) by simp finally (*calculation: ‹char (Rupt K f) = char R›*) show "char (Rupt K f) = char R" by simp qed definition gauss_poly where "gauss_poly K n = X⇘K⇙ [^]⇘poly_ring K⇙ (n::nat) ⊖⇘poly_ring K⇙ X⇘K⇙" context field begin interpretation polynomial_ring "R" "carrier R" unfolding polynomial_ring_def polynomial_ring_axioms_def (*goal: ‹field R ∧ subfield (carrier R) R›*) using field_axioms (*‹field R›*) carrier_is_subfield (*‹subfield (carrier R) R›*) by simp text ‹The following lemma can be found in Ireland and Rosen~\<^cite>‹‹\textsection 7.1, Lemma 2› in "ireland1982"›.› lemma gauss_poly_div_gauss_poly_iff_1: fixes l m :: nat assumes "l > 0" shows "(X [^]⇘P⇙ l ⊖⇘P⇙ 𝟭⇘P⇙) pdivides (X [^]⇘P⇙ m ⊖⇘P⇙ 𝟭⇘P⇙) ⟷ l dvd m" (is "?lhs ⟷ ?rhs") proof (-) (*goal: ‹(X [^]⇘P⇙ l ⊖⇘P⇙ 𝟭⇘P⇙) pdivides (X [^]⇘P⇙ m ⊖⇘P⇙ 𝟭⇘P⇙) = (l dvd m)›*) define q where "q = m div l" define r where "r = m mod l" have m_def: "m = q * l + r" and r_range: "r < l" using assms (*‹0 < l›*) apply - (*goals: 1. ‹0 < l ⟹ m = q * l + r› 2. ‹0 < l ⟹ r < l› discuss goal 1*) apply ((auto simp add:q_def (*‹q = m div l›*) r_def (*‹r = m mod l›*))[1]) (*discuss goal 2*) apply ((auto simp add:q_def (*‹q = m div l›*) r_def (*‹r = m mod l›*))[1]) (*proven 2 subgoals*) . have pow_sum_carr: "(⨁⇘P⇙i∈{..<q}. (X [^]⇘P⇙ l)[^]⇘P⇙ i) ∈ carrier P" using var_pow_closed (*‹X [^]⇘P⇙ ?n ∈ carrier P›*) apply (intro p.finsum_closed (*‹(?f::?'c ⇒ 'a list) ∈ (?A::?'c set) → carrier P ⟹ finsum P ?f ?A ∈ carrier P›*)) (*goal: ‹finsum P (([^]⇘P⇙) (X [^]⇘P⇙ l)) {..<q} ∈ carrier P›*) by simp have "(X [^]⇘P⇙ (q*l) ⊖⇘P⇙ 𝟭⇘P⇙) = ((X [^]⇘P⇙ l)[^]⇘P⇙ q) ⊖⇘P⇙ 𝟭⇘P⇙" using var_closed (*‹X ∈ carrier P› ‹polynomial (carrier R) X›*) apply (subst p.nat_pow_pow (*‹?x ∈ carrier P ⟹ (?x [^]⇘P⇙ ?n) [^]⇘P⇙ ?m = ?x [^]⇘P⇙ (?n * ?m)›*)) (*goals: 1. ‹⟦X ∈ carrier P; polynomial (carrier R) X⟧ ⟹ X ∈ carrier P› 2. ‹⟦X ∈ carrier P; polynomial (carrier R) X⟧ ⟹ X [^]⇘P⇙ ((q::nat) * (l::nat)) ⊖⇘P⇙ 𝟭⇘P⇙ = X [^]⇘P⇙ (l * q) ⊖⇘P⇙ 𝟭⇘P⇙› discuss goal 1*) apply (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*)) (*discuss goal 2*) apply (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*)) (*proven 2 subgoals*) . also (*calculation: ‹X [^]⇘P⇙ (q * l) ⊖⇘P⇙ 𝟭⇘P⇙ = (X [^]⇘P⇙ l) [^]⇘P⇙ q ⊖⇘P⇙ 𝟭⇘P⇙›*) have "... = (X [^]⇘P⇙ l ⊖⇘P⇙ 𝟭⇘P⇙) ⊗⇘P⇙ (⨁⇘P⇙i∈{..<q}. (X [^]⇘P⇙ l) [^]⇘P⇙ i)" using var_pow_closed (*‹X [^]⇘P⇙ ?n ∈ carrier P›*) apply (subst p.geom[symmetric] (*‹?a ∈ carrier P ⟹ ?a [^]⇘P⇙ ?q ⊖⇘P⇙ 𝟭⇘P⇙ = (?a ⊖⇘P⇙ 𝟭⇘P⇙) ⊗⇘P⇙ finsum P (([^]⇘P⇙) ?a) {..<?q}›*)) (*goals: 1. ‹(⋀n::nat. X [^]⇘P⇙ n ∈ carrier P) ⟹ X [^]⇘P⇙ (l::nat) ∈ carrier P› 2. ‹(⋀n::nat. X [^]⇘P⇙ n ∈ carrier P) ⟹ (X [^]⇘P⇙ (l::nat) ⊖⇘P⇙ 𝟭⇘P⇙) ⊗⇘P⇙ finsum P (([^]⇘P⇙) (X [^]⇘P⇙ l)) {..<q::nat} = (X [^]⇘P⇙ l ⊖⇘P⇙ 𝟭⇘P⇙) ⊗⇘P⇙ finsum P (([^]⇘P⇙) (X [^]⇘P⇙ l)) {..<q}› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) . finally (*calculation: ‹X [^]⇘P⇙ (q * l) ⊖⇘P⇙ 𝟭⇘P⇙ = (X [^]⇘P⇙ l ⊖⇘P⇙ 𝟭⇘P⇙) ⊗⇘P⇙ finsum P (([^]⇘P⇙) (X [^]⇘P⇙ l)) {..<q}›*) have pow_sum_fact: "(X [^]⇘P⇙ (q*l) ⊖⇘P⇙ 𝟭⇘P⇙) = (X [^]⇘P⇙ l ⊖⇘P⇙ 𝟭⇘P⇙) ⊗⇘P⇙ (⨁⇘P⇙i∈{..<q}. (X⇘R⇙ [^]⇘P⇙ l) [^]⇘P⇙ i)" by simp have "(X [^]⇘P⇙ l ⊖⇘P⇙ 𝟭⇘P⇙) divides⇘P⇙ (X [^]⇘P⇙ (q*l) ⊖⇘P⇙ 𝟭⇘P⇙)" by (rule dividesI[OF pow_sum_carr pow_sum_fact] (*‹(X [^]⇘P⇙ l ⊖⇘P⇙ 𝟭⇘P⇙) divides⇘P⇙ (X [^]⇘P⇙ (q * l) ⊖⇘P⇙ 𝟭⇘P⇙)›*)) hence c: "(X [^]⇘P⇙ l ⊖⇘P⇙ 𝟭⇘P⇙) divides⇘P⇙ X [^]⇘P⇙ r ⊗⇘P⇙ (X [^]⇘P⇙ (q * l) ⊖⇘P⇙ 𝟭⇘P⇙)" using var_pow_closed (*‹X [^]⇘P⇙ ?n ∈ carrier P›*) apply (intro p.divides_prod_l (*‹⟦?a ∈ carrier P; ?b ∈ carrier P; ?c ∈ carrier P; ?a divides⇘P⇙ ?b⟧ ⟹ ?a divides⇘P⇙ ?c ⊗⇘P⇙ ?b›*)) (*goals: 1. ‹⟦(X [^]⇘P⇙ l ⊖⇘P⇙ 𝟭⇘P⇙) divides⇘P⇙ (X [^]⇘P⇙ (q * l) ⊖⇘P⇙ 𝟭⇘P⇙); ⋀n. X [^]⇘P⇙ n ∈ carrier P⟧ ⟹ X [^]⇘P⇙ l ⊖⇘P⇙ 𝟭⇘P⇙ ∈ carrier P› 2. ‹⟦(X [^]⇘P⇙ l ⊖⇘P⇙ 𝟭⇘P⇙) divides⇘P⇙ (X [^]⇘P⇙ (q * l) ⊖⇘P⇙ 𝟭⇘P⇙); ⋀n. X [^]⇘P⇙ n ∈ carrier P⟧ ⟹ X [^]⇘P⇙ (q * l) ⊖⇘P⇙ 𝟭⇘P⇙ ∈ carrier P› 3. ‹⟦(X [^]⇘P⇙ l ⊖⇘P⇙ 𝟭⇘P⇙) divides⇘P⇙ (X [^]⇘P⇙ (q * l) ⊖⇘P⇙ 𝟭⇘P⇙); ⋀n. X [^]⇘P⇙ n ∈ carrier P⟧ ⟹ X [^]⇘P⇙ r ∈ carrier P› 4. ‹⟦(X [^]⇘P⇙ l ⊖⇘P⇙ 𝟭⇘P⇙) divides⇘P⇙ (X [^]⇘P⇙ (q * l) ⊖⇘P⇙ 𝟭⇘P⇙); ⋀n. X [^]⇘P⇙ n ∈ carrier P⟧ ⟹ (X [^]⇘P⇙ l ⊖⇘P⇙ 𝟭⇘P⇙) divides⇘P⇙ (X [^]⇘P⇙ (q * l) ⊖⇘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*) . have "(X [^]⇘P⇙ m ⊖⇘P⇙ 𝟭⇘P⇙) = X [^]⇘P⇙ (r + q * l) ⊖⇘P⇙ 𝟭⇘P⇙" unfolding m_def (*goal: ‹X [^]⇘P⇙ ((q::nat) * (l::nat) + (r::nat)) ⊖⇘P⇙ 𝟭⇘P⇙ = X [^]⇘P⇙ (r + q * l) ⊖⇘P⇙ 𝟭⇘P⇙›*) using add.commute (*‹?a + ?b = ?b + ?a›*) by metis also (*calculation: ‹X [^]⇘P⇙ m ⊖⇘P⇙ 𝟭⇘P⇙ = X [^]⇘P⇙ (r + q * l) ⊖⇘P⇙ 𝟭⇘P⇙›*) have "... = (X [^]⇘P⇙ r) ⊗⇘P⇙ (X [^]⇘P⇙ (q*l)) ⊕⇘P⇙ (⊖⇘P⇙ 𝟭⇘P⇙)" using var_closed (*‹X ∈ carrier P› ‹polynomial (carrier R) X›*) apply (subst p.nat_pow_mult (*‹?x ∈ carrier P ⟹ ?x [^]⇘P⇙ ?n ⊗⇘P⇙ ?x [^]⇘P⇙ ?m = ?x [^]⇘P⇙ (?n + ?m)›*)) (*goals: 1. ‹⟦X ∈ carrier P; polynomial (carrier R) X⟧ ⟹ X ∈ carrier P› 2. ‹⟦X ∈ carrier P; polynomial (carrier R) X⟧ ⟹ X [^]⇘P⇙ (r + q * l) ⊖⇘P⇙ 𝟭⇘P⇙ = X [^]⇘P⇙ (r + q * l) ⊕⇘P⇙ ⊖⇘P⇙ 𝟭⇘P⇙› discuss goal 1*) apply ((auto simp add:a_minus_def (*‹(?x::?'a) ⊖⇘?R::(?'a, ?'m) ring_scheme⇙ (?y::?'a) = ?x ⊕⇘?R⇙ ⊖⇘?R⇙ ?y›*))[1]) (*discuss goal 2*) apply ((auto simp add:a_minus_def (*‹(?x::?'a::type) ⊖⇘?R::(?'a, ?'m) ring_scheme⇙ (?y::?'a::type) = ?x ⊕⇘?R⇙ ⊖⇘?R⇙ ?y›*))[1]) (*proven 2 subgoals*) . also (*calculation: ‹X [^]⇘P⇙ m ⊖⇘P⇙ 𝟭⇘P⇙ = X [^]⇘P⇙ r ⊗⇘P⇙ X [^]⇘P⇙ (q * l) ⊕⇘P⇙ ⊖⇘P⇙ 𝟭⇘P⇙›*) have "... = ((X [^]⇘P⇙ r) ⊗⇘P⇙ (X [^]⇘P⇙ (q*l) ⊕⇘P⇙ (⊖⇘P⇙ 𝟭⇘P⇙)) ⊕⇘P⇙ (X [^]⇘P⇙ r)) ⊖⇘P⇙ 𝟭⇘P⇙" using var_pow_closed (*‹X [^]⇘P⇙ ?n ∈ carrier P›*) by algebra also (*calculation: ‹X [^]⇘P⇙ m ⊖⇘P⇙ 𝟭⇘P⇙ = X [^]⇘P⇙ r ⊗⇘P⇙ (X [^]⇘P⇙ (q * l) ⊕⇘P⇙ ⊖⇘P⇙ 𝟭⇘P⇙) ⊕⇘P⇙ X [^]⇘P⇙ r ⊖⇘P⇙ 𝟭⇘P⇙›*) have "... = (X [^]⇘P⇙ r) ⊗⇘P⇙ (X [^]⇘P⇙ (q*l) ⊖⇘P⇙ 𝟭⇘P⇙) ⊕⇘P⇙ (X [^]⇘P⇙ r) ⊖⇘P⇙ 𝟭⇘P⇙" by algebra also (*calculation: ‹X [^]⇘P⇙ m ⊖⇘P⇙ 𝟭⇘P⇙ = X [^]⇘P⇙ r ⊗⇘P⇙ (X [^]⇘P⇙ (q * l) ⊖⇘P⇙ 𝟭⇘P⇙) ⊕⇘P⇙ X [^]⇘P⇙ r ⊖⇘P⇙ 𝟭⇘P⇙›*) have "... = (X [^]⇘P⇙ r) ⊗⇘P⇙ (X [^]⇘P⇙ (q*l) ⊖⇘P⇙ 𝟭⇘P⇙) ⊕⇘P⇙ ((X [^]⇘P⇙ r) ⊖⇘P⇙ 𝟭⇘P⇙)" unfolding a_minus_def (*goal: ‹X [^]⇘P⇙ r ⊗⇘P⇙ (X [^]⇘P⇙ (q * l) ⊕⇘P⇙ ⊖⇘P⇙ 𝟭⇘P⇙) ⊕⇘P⇙ X [^]⇘P⇙ r ⊕⇘P⇙ ⊖⇘P⇙ 𝟭⇘P⇙ = X [^]⇘P⇙ r ⊗⇘P⇙ (X [^]⇘P⇙ (q * l) ⊕⇘P⇙ ⊖⇘P⇙ 𝟭⇘P⇙) ⊕⇘P⇙ (X [^]⇘P⇙ r ⊕⇘P⇙ ⊖⇘P⇙ 𝟭⇘P⇙)›*) using var_pow_closed (*‹X [^]⇘P⇙ ?n ∈ carrier P›*) apply (subst p.a_assoc (*‹⟦?x ∈ carrier P; ?y ∈ carrier P; ?z ∈ carrier P⟧ ⟹ ?x ⊕⇘P⇙ ?y ⊕⇘P⇙ ?z = ?x ⊕⇘P⇙ (?y ⊕⇘P⇙ ?z)›*)) (*goals: 1. ‹(⋀n. X [^]⇘P⇙ n ∈ carrier P) ⟹ X [^]⇘P⇙ r ⊗⇘P⇙ (X [^]⇘P⇙ (q * l) ⊕⇘P⇙ ⊖⇘P⇙ 𝟭⇘P⇙) ∈ carrier P› 2. ‹(⋀n. X [^]⇘P⇙ n ∈ carrier P) ⟹ X [^]⇘P⇙ r ∈ carrier P› 3. ‹(⋀n. X [^]⇘P⇙ n ∈ carrier P) ⟹ ⊖⇘P⇙ 𝟭⇘P⇙ ∈ carrier P› 4. ‹(⋀n. X [^]⇘P⇙ n ∈ carrier P) ⟹ X [^]⇘P⇙ r ⊗⇘P⇙ (X [^]⇘P⇙ (q * l) ⊕⇘P⇙ ⊖⇘P⇙ 𝟭⇘P⇙) ⊕⇘P⇙ (X [^]⇘P⇙ r ⊕⇘P⇙ ⊖⇘P⇙ 𝟭⇘P⇙) = X [^]⇘P⇙ r ⊗⇘P⇙ (X [^]⇘P⇙ (q * l) ⊕⇘P⇙ ⊖⇘P⇙ 𝟭⇘P⇙) ⊕⇘P⇙ (X [^]⇘P⇙ r ⊕⇘P⇙ ⊖⇘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*) . finally (*calculation: ‹X [^]⇘P⇙ (m::nat) ⊖⇘P⇙ 𝟭⇘P⇙ = X [^]⇘P⇙ (r::nat) ⊗⇘P⇙ (X [^]⇘P⇙ ((q::nat) * (l::nat)) ⊖⇘P⇙ 𝟭⇘P⇙) ⊕⇘P⇙ (X [^]⇘P⇙ r ⊖⇘P⇙ 𝟭⇘P⇙)›*) have a: "(X [^]⇘P⇙ m ⊖⇘P⇙ 𝟭⇘P⇙) = (X [^]⇘P⇙ r) ⊗⇘P⇙ (X [^]⇘P⇙ (q*l) ⊖⇘P⇙ 𝟭⇘P⇙) ⊕⇘P⇙ (X [^]⇘P⇙ r ⊖⇘P⇙ 𝟭⇘P⇙)" (is "_ = ?x") by simp have xn_m_1_deg': "degree (X [^]⇘P⇙ n ⊖⇘P⇙ 𝟭⇘P⇙) = n" if "n > 0" for n :: nat proof (-) (*goal: ‹degree (X [^]⇘P⇙ (n::nat) ⊖⇘P⇙ 𝟭⇘P⇙) = n›*) have "degree (X [^]⇘P⇙ n ⊖⇘P⇙ 𝟭⇘P⇙) = degree (X [^]⇘P⇙ n ⊕⇘P⇙ ⊖⇘P⇙ 𝟭⇘P⇙)" by (simp add:a_minus_def (*‹(?x::?'a) ⊖⇘?R::(?'a, ?'m) ring_scheme⇙ (?y::?'a) = ?x ⊕⇘?R⇙ ⊖⇘?R⇙ ?y›*)) also (*calculation: ‹degree (X [^]⇘P⇙ n ⊖⇘P⇙ 𝟭⇘P⇙) = degree (X [^]⇘P⇙ n ⊕⇘P⇙ ⊖⇘P⇙ 𝟭⇘P⇙)›*) have "... = max (degree (X [^]⇘P⇙ n)) (degree (⊖⇘P⇙ 𝟭⇘P⇙))" using var_pow_closed (*‹X [^]⇘P⇙ ?n ∈ carrier P›*) var_pow_carr (*‹X [^]⇘P⇙ ?n ∈ carrier P - {𝟬⇘P⇙}›*) var_pow_degree (*‹degree (X [^]⇘P⇙ ?n) = ?n›*) using univ_poly_a_inv_degree (*‹?p ∈ carrier P ⟹ degree (⊖⇘P⇙ ?p) = degree ?p›*) degree_one (*‹degree 𝟭⇘?K::'a set [X]⇙ = (0::nat)›*) that (*‹0 < n›*) apply (subst degree_add_distinct (*‹⟦(?f::'a list) ∈ carrier P - {𝟬⇘P⇙}; (?g::'a list) ∈ carrier P - {𝟬⇘P⇙}; degree ?f ≠ degree ?g⟧ ⟹ degree (?f ⊕⇘P⇙ ?g) = max (degree ?f) (degree ?g)›*)) (*goals: 1. ‹⟦⋀n. X [^]⇘P⇙ n ∈ carrier P; ⋀n. X [^]⇘P⇙ n ∈ carrier P - {𝟬⇘P⇙}; ⋀n. degree (X [^]⇘P⇙ n) = n; ⋀p. p ∈ carrier P ⟹ degree (⊖⇘P⇙ p) = degree p; ⋀K. degree 𝟭⇘K [X]⇙ = 0; 0 < n⟧ ⟹ X [^]⇘P⇙ n ∈ carrier P - {𝟬⇘P⇙}› 2. ‹⟦⋀n. X [^]⇘P⇙ n ∈ carrier P; ⋀n. X [^]⇘P⇙ n ∈ carrier P - {𝟬⇘P⇙}; ⋀n. degree (X [^]⇘P⇙ n) = n; ⋀p. p ∈ carrier P ⟹ degree (⊖⇘P⇙ p) = degree p; ⋀K. degree 𝟭⇘K [X]⇙ = 0; 0 < n⟧ ⟹ ⊖⇘P⇙ 𝟭⇘P⇙ ∈ carrier P - {𝟬⇘P⇙}› 3. ‹⟦⋀n. X [^]⇘P⇙ n ∈ carrier P; ⋀n. X [^]⇘P⇙ n ∈ carrier P - {𝟬⇘P⇙}; ⋀n. degree (X [^]⇘P⇙ n) = n; ⋀p. p ∈ carrier P ⟹ degree (⊖⇘P⇙ p) = degree p; ⋀K. degree 𝟭⇘K [X]⇙ = 0; 0 < n⟧ ⟹ degree (X [^]⇘P⇙ n) ≠ degree (⊖⇘P⇙ 𝟭⇘P⇙)› 4. ‹⟦⋀n. X [^]⇘P⇙ n ∈ carrier P; ⋀n. X [^]⇘P⇙ n ∈ carrier P - {𝟬⇘P⇙}; ⋀n. degree (X [^]⇘P⇙ n) = n; ⋀p. p ∈ carrier P ⟹ degree (⊖⇘P⇙ p) = degree p; ⋀K. degree 𝟭⇘K [X]⇙ = 0; 0 < n⟧ ⟹ max (degree (X [^]⇘P⇙ n)) (degree (⊖⇘P⇙ 𝟭⇘P⇙)) = max (degree (X [^]⇘P⇙ n)) (degree (⊖⇘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*) . also (*calculation: ‹degree (X [^]⇘P⇙ n ⊖⇘P⇙ 𝟭⇘P⇙) = max (degree (X [^]⇘P⇙ n)) (degree (⊖⇘P⇙ 𝟭⇘P⇙))›*) have "... = n" using var_pow_degree (*‹degree (X [^]⇘P⇙ (?n::nat)) = ?n›*) degree_one (*‹degree 𝟭⇘?K::'a set [X]⇙ = (0::nat)›*) univ_poly_a_inv_degree (*‹?p ∈ carrier P ⟹ degree (⊖⇘P⇙ ?p) = degree ?p›*) by simp finally (*calculation: ‹degree (X [^]⇘P⇙ n ⊖⇘P⇙ 𝟭⇘P⇙) = n›*) show "?thesis" (*goal: ‹degree (X [^]⇘P⇙ (n::nat) ⊖⇘P⇙ 𝟭⇘P⇙) = n›*) by simp qed have xn_m_1_deg: "degree (X [^]⇘P⇙ n ⊖⇘P⇙ 𝟭⇘P⇙) = n" for n :: nat proof (cases "n > 0") (*goals: 1. ‹0 < n ⟹ degree (X [^]⇘P⇙ n ⊖⇘P⇙ 𝟭⇘P⇙) = n› 2. ‹¬ 0 < n ⟹ degree (X [^]⇘P⇙ n ⊖⇘P⇙ 𝟭⇘P⇙) = n›*) case True (*‹0 < n›*) then show "?thesis" (*goal: ‹degree (X [^]⇘P⇙ n ⊖⇘P⇙ 𝟭⇘P⇙) = n›*) using xn_m_1_deg' (*‹0 < ?n ⟹ degree (X [^]⇘P⇙ ?n ⊖⇘P⇙ 𝟭⇘P⇙) = ?n›*) by auto next (*goal: ‹¬ 0 < n ⟹ degree (X [^]⇘P⇙ n ⊖⇘P⇙ 𝟭⇘P⇙) = n›*) case False (*‹¬ 0 < n›*) hence "n = 0" by simp hence "degree (X [^]⇘P⇙ n ⊖⇘P⇙ 𝟭⇘P⇙) = degree (𝟬⇘P⇙)" apply (intro arg_cong[where f="degree"] (*‹?x = ?y ⟹ degree ?x = degree ?y›*)) (*goal: ‹degree (X [^]⇘P⇙ n ⊖⇘P⇙ 𝟭⇘P⇙) = degree 𝟬⇘P⇙›*) by simp then show "?thesis" (*goal: ‹degree (X [^]⇘P⇙ n ⊖⇘P⇙ 𝟭⇘P⇙) = n›*) using False (*‹¬ 0 < n›*) by (simp add:univ_poly_zero (*‹𝟬⇘?K [X]⇘?R⇙⇙ = []›*)) qed have b: "degree (X [^]⇘P⇙ l ⊖⇘P⇙ 𝟭⇘P⇙) > degree (X⇘R⇙ [^]⇘P⇙ r ⊖⇘P⇙ 𝟭⇘P⇙)" using r_range (*‹r < l›*) unfolding xn_m_1_deg (*goal: ‹r < l›*) by simp have xn_m_1_carr: "X [^]⇘P⇙ n ⊖⇘P⇙ 𝟭⇘P⇙ ∈ carrier P" for n :: nat unfolding a_minus_def (*goal: ‹X [^]⇘P⇙ n ⊕⇘P⇙ ⊖⇘P⇙ 𝟭⇘P⇙ ∈ carrier P›*) apply (intro p.a_closed (*‹⟦(?x::'a list) ∈ carrier P; (?y::'a list) ∈ carrier P⟧ ⟹ ?x ⊕⇘P⇙ ?y ∈ carrier P›*) var_pow_closed (*‹X [^]⇘P⇙ (?n::nat) ∈ carrier P›*)) (*goal: ‹X [^]⇘P⇙ n ⊕⇘P⇙ ⊖⇘P⇙ 𝟭⇘P⇙ ∈ carrier P›*) by simp have "?lhs ⟷ (X [^]⇘P⇙ l ⊖⇘P⇙ 𝟭⇘P⇙) pdivides ?x" apply (subst a (*‹X [^]⇘P⇙ m ⊖⇘P⇙ 𝟭⇘P⇙ = X [^]⇘P⇙ r ⊗⇘P⇙ (X [^]⇘P⇙ (q * l) ⊖⇘P⇙ 𝟭⇘P⇙) ⊕⇘P⇙ (X [^]⇘P⇙ r ⊖⇘P⇙ 𝟭⇘P⇙)›*)) (*goal: ‹(X [^]⇘P⇙ (l::nat) ⊖⇘P⇙ 𝟭⇘P⇙) pdivides (X [^]⇘P⇙ (m::nat) ⊖⇘P⇙ 𝟭⇘P⇙) = (X [^]⇘P⇙ l ⊖⇘P⇙ 𝟭⇘P⇙) pdivides (X [^]⇘P⇙ (r::nat) ⊗⇘P⇙ (X [^]⇘P⇙ ((q::nat) * l) ⊖⇘P⇙ 𝟭⇘P⇙) ⊕⇘P⇙ (X [^]⇘P⇙ r ⊖⇘P⇙ 𝟭⇘P⇙))›*) by simp also (*calculation: ‹(X [^]⇘P⇙ l ⊖⇘P⇙ 𝟭⇘P⇙) pdivides (X [^]⇘P⇙ m ⊖⇘P⇙ 𝟭⇘P⇙) = (X [^]⇘P⇙ l ⊖⇘P⇙ 𝟭⇘P⇙) pdivides (X [^]⇘P⇙ r ⊗⇘P⇙ (X [^]⇘P⇙ (q * l) ⊖⇘P⇙ 𝟭⇘P⇙) ⊕⇘P⇙ (X [^]⇘P⇙ r ⊖⇘P⇙ 𝟭⇘P⇙))›*) have "... ⟷ (X [^]⇘P⇙ l ⊖⇘P⇙ 𝟭⇘P⇙) pdivides (X [^]⇘P⇙ r ⊖⇘P⇙ 𝟭⇘P⇙)" unfolding pdivides_def (*goal: ‹(X [^]⇘P⇙ l ⊖⇘P⇙ 𝟭⇘P⇙) divides⇘P⇙ (X [^]⇘P⇙ r ⊗⇘P⇙ (X [^]⇘P⇙ (q * l) ⊖⇘P⇙ 𝟭⇘P⇙) ⊕⇘P⇙ (X [^]⇘P⇙ r ⊖⇘P⇙ 𝟭⇘P⇙)) = (X [^]⇘P⇙ l ⊖⇘P⇙ 𝟭⇘P⇙) divides⇘P⇙ (X [^]⇘P⇙ r ⊖⇘P⇙ 𝟭⇘P⇙)›*) by (intro p.div_sum_iff (*‹⟦?a ∈ carrier P; ?b ∈ carrier P; ?c ∈ carrier P; ?a divides⇘P⇙ ?b⟧ ⟹ ?a divides⇘P⇙ (?b ⊕⇘P⇙ ?c) = ?a divides⇘P⇙ ?c›*) c (*‹(X [^]⇘P⇙ l ⊖⇘P⇙ 𝟭⇘P⇙) divides⇘P⇙ X [^]⇘P⇙ r ⊗⇘P⇙ (X [^]⇘P⇙ (q * l) ⊖⇘P⇙ 𝟭⇘P⇙)›*) var_pow_closed (*‹X [^]⇘P⇙ ?n ∈ carrier P›*) xn_m_1_carr (*‹X [^]⇘P⇙ ?n ⊖⇘P⇙ 𝟭⇘P⇙ ∈ carrier P›*) p.a_closed (*‹⟦?x ∈ carrier P; ?y ∈ carrier P⟧ ⟹ ?x ⊕⇘P⇙ ?y ∈ carrier P›*) p.m_closed (*‹⟦?x ∈ carrier P; ?y ∈ carrier P⟧ ⟹ ?x ⊗⇘P⇙ ?y ∈ carrier P›*)) also (*calculation: ‹(X [^]⇘P⇙ l ⊖⇘P⇙ 𝟭⇘P⇙) pdivides (X [^]⇘P⇙ m ⊖⇘P⇙ 𝟭⇘P⇙) = (X [^]⇘P⇙ l ⊖⇘P⇙ 𝟭⇘P⇙) pdivides (X [^]⇘P⇙ r ⊖⇘P⇙ 𝟭⇘P⇙)›*) have "... ⟷ r = 0" proof (cases "r = 0") (*goals: 1. ‹r = 0 ⟹ (X [^]⇘P⇙ l ⊖⇘P⇙ 𝟭⇘P⇙) pdivides (X [^]⇘P⇙ r ⊖⇘P⇙ 𝟭⇘P⇙) = (r = 0)› 2. ‹r ≠ 0 ⟹ (X [^]⇘P⇙ l ⊖⇘P⇙ 𝟭⇘P⇙) pdivides (X [^]⇘P⇙ r ⊖⇘P⇙ 𝟭⇘P⇙) = (r = 0)›*) case True (*‹r = 0›*) have "(X [^]⇘P⇙ l ⊖⇘P⇙ 𝟭⇘P⇙) pdivides 𝟬⇘P⇙" unfolding univ_poly_zero (*goal: ‹(X [^]⇘P⇙ l ⊖⇘P⇙ 𝟭⇘P⇙) pdivides []›*) by (intro pdivides_zero (*‹?p ∈ carrier P ⟹ ?p pdivides []›*) xn_m_1_carr (*‹X [^]⇘P⇙ ?n ⊖⇘P⇙ 𝟭⇘P⇙ ∈ carrier P›*)) also (*calculation: ‹(X [^]⇘P⇙ l ⊖⇘P⇙ 𝟭⇘P⇙) pdivides 𝟬⇘P⇙›*) have "... = (X [^]⇘P⇙ r ⊖⇘P⇙ 𝟭⇘P⇙)" apply (simp add:a_minus_def (*‹(?x::?'a) ⊖⇘?R::(?'a, ?'m) ring_scheme⇙ (?y::?'a) = ?x ⊕⇘?R⇙ ⊖⇘?R⇙ ?y›*) True (*‹(r::nat) = (0::nat)›*)) (*goal: ‹𝟬⇘P⇙ = X [^]⇘P⇙ r ⊖⇘P⇙ 𝟭⇘P⇙›*) by algebra finally (*calculation: ‹(X [^]⇘P⇙ l ⊖⇘P⇙ 𝟭⇘P⇙) pdivides (X [^]⇘P⇙ r ⊖⇘P⇙ 𝟭⇘P⇙)›*) show "?thesis" (*goal: ‹(X [^]⇘P⇙ l ⊖⇘P⇙ 𝟭⇘P⇙) pdivides (X [^]⇘P⇙ r ⊖⇘P⇙ 𝟭⇘P⇙) = (r = 0)›*) using True (*‹r = 0›*) by simp next (*goal: ‹r ≠ 0 ⟹ (X [^]⇘P⇙ l ⊖⇘P⇙ 𝟭⇘P⇙) pdivides (X [^]⇘P⇙ r ⊖⇘P⇙ 𝟭⇘P⇙) = (r = 0)›*) case False (*‹r ≠ 0›*) hence "degree (X [^]⇘P⇙ r ⊖⇘P⇙ 𝟭⇘P⇙) > 0" using xn_m_1_deg (*‹degree (X [^]⇘P⇙ (?n::nat) ⊖⇘P⇙ 𝟭⇘P⇙) = ?n›*) by simp hence "X [^]⇘P⇙ r ⊖⇘P⇙ 𝟭⇘P⇙ ≠ []" by auto hence "¬(X [^]⇘P⇙ l ⊖⇘P⇙ 𝟭⇘P⇙) pdivides (X [^]⇘P⇙ r ⊖⇘P⇙ 𝟭⇘P⇙)" using pdivides_imp_degree_le (*‹⟦?p ∈ carrier P; ?q ∈ carrier P; ?q ≠ []; ?p pdivides ?q⟧ ⟹ degree ?p ≤ degree ?q›*) b (*‹degree (X [^]⇘P⇙ (r::nat) ⊖⇘P⇙ 𝟭⇘P⇙) < degree (X [^]⇘P⇙ (l::nat) ⊖⇘P⇙ 𝟭⇘P⇙)›*) xn_m_1_carr (*‹X [^]⇘P⇙ ?n ⊖⇘P⇙ 𝟭⇘P⇙ ∈ carrier P›*) by (metis le_antisym (*‹⟦?m ≤ ?n; ?n ≤ ?m⟧ ⟹ ?m = ?n›*) less_or_eq_imp_le (*‹?m < ?n ∨ ?m = ?n ⟹ ?m ≤ ?n›*) nat_neq_iff (*‹(?m ≠ ?n) = (?m < ?n ∨ ?n < ?m)›*)) thus "?thesis" (*goal: ‹(X [^]⇘P⇙ (l::nat) ⊖⇘P⇙ 𝟭⇘P⇙) pdivides (X [^]⇘P⇙ (r::nat) ⊖⇘P⇙ 𝟭⇘P⇙) = (r = (0::nat))›*) using False (*‹r ≠ 0›*) by simp qed also (*calculation: ‹(X [^]⇘P⇙ l ⊖⇘P⇙ 𝟭⇘P⇙) pdivides (X [^]⇘P⇙ m ⊖⇘P⇙ 𝟭⇘P⇙) = (r = 0)›*) have "... ⟷ l dvd m" unfolding m_def (*goal: ‹((r::nat) = (0::nat)) = ((l::nat) dvd (q::nat) * l + r)›*) using r_range (*‹r < l›*) assms (*‹0 < l›*) by auto finally (*calculation: ‹(X [^]⇘P⇙ l ⊖⇘P⇙ 𝟭⇘P⇙) pdivides (X [^]⇘P⇙ m ⊖⇘P⇙ 𝟭⇘P⇙) = (l dvd m)›*) show "?thesis" (*goal: ‹(X [^]⇘P⇙ (l::nat) ⊖⇘P⇙ 𝟭⇘P⇙) pdivides (X [^]⇘P⇙ (m::nat) ⊖⇘P⇙ 𝟭⇘P⇙) = (l dvd m)›*) by simp qed lemma gauss_poly_factor: assumes "n > 0" shows "gauss_poly R n = (X [^]⇘P⇙ (n-1) ⊖⇘P⇙ 𝟭⇘P⇙) ⊗⇘P⇙ X" (is "_ = ?rhs") proof (-) (*goal: ‹gauss_poly R n = (X [^]⇘P⇙ (n - 1) ⊖⇘P⇙ 𝟭⇘P⇙) ⊗⇘P⇙ X›*) have a: "1 + (n - 1) = n" using assms (*‹0 < n›*) by simp have "gauss_poly R n = X [^]⇘P⇙ (1+(n-1)) ⊖⇘P⇙ X" unfolding gauss_poly_def (*goal: ‹X [^]⇘P⇙ n ⊖⇘P⇙ X = X [^]⇘P⇙ (1 + (n - 1)) ⊖⇘P⇙ X›*) apply (subst a (*‹1 + (n - 1) = n›*)) (*goal: ‹X [^]⇘P⇙ n ⊖⇘P⇙ X = X [^]⇘P⇙ (1 + (n - 1)) ⊖⇘P⇙ X›*) by simp also (*calculation: ‹gauss_poly R (n::nat) = X [^]⇘P⇙ ((1::nat) + (n - (1::nat))) ⊖⇘P⇙ X›*) have "... = (X [^]⇘P⇙ (n-1)) ⊗⇘P⇙ X ⊖⇘P⇙ 𝟭⇘P⇙ ⊗⇘P⇙ X" using var_closed (*‹X ∈ carrier P› ‹polynomial (carrier R) X›*) by simp also (*calculation: ‹gauss_poly R (n::nat) = X [^]⇘P⇙ (n - (1::nat)) ⊗⇘P⇙ X ⊖⇘P⇙ 𝟭⇘P⇙ ⊗⇘P⇙ X›*) have "... = ?rhs" unfolding a_minus_def (*goal: ‹X [^]⇘P⇙ (n - 1) ⊗⇘P⇙ X ⊕⇘P⇙ ⊖⇘P⇙ (𝟭⇘P⇙ ⊗⇘P⇙ X) = (X [^]⇘P⇙ (n - 1) ⊕⇘P⇙ ⊖⇘P⇙ 𝟭⇘P⇙) ⊗⇘P⇙ X›*) using var_closed (*‹X ∈ carrier P› ‹polynomial (carrier R) X›*) l_one (*‹?x ∈ carrier R ⟹ 𝟭 ⊗ ?x = ?x›*) apply (subst p.l_distr (*‹⟦?x ∈ carrier P; ?y ∈ carrier P; ?z ∈ carrier P⟧ ⟹ (?x ⊕⇘P⇙ ?y) ⊗⇘P⇙ ?z = ?x ⊗⇘P⇙ ?z ⊕⇘P⇙ ?y ⊗⇘P⇙ ?z›*)) (*goals: 1. ‹⟦X ∈ carrier P; polynomial (carrier R) X; ⋀x. x ∈ carrier R ⟹ 𝟭 ⊗ x = x⟧ ⟹ X [^]⇘P⇙ (n - 1) ∈ carrier P› 2. ‹⟦X ∈ carrier P; polynomial (carrier R) X; ⋀x. x ∈ carrier R ⟹ 𝟭 ⊗ x = x⟧ ⟹ ⊖⇘P⇙ 𝟭⇘P⇙ ∈ carrier P› 3. ‹⟦X ∈ carrier P; polynomial (carrier R) X; ⋀x. x ∈ carrier R ⟹ 𝟭 ⊗ x = x⟧ ⟹ X ∈ carrier P› 4. ‹⟦X ∈ carrier P; polynomial (carrier R) X; ⋀x. x ∈ carrier R ⟹ 𝟭 ⊗ x = x⟧ ⟹ X [^]⇘P⇙ (n - 1) ⊗⇘P⇙ X ⊕⇘P⇙ ⊖⇘P⇙ (𝟭⇘P⇙ ⊗⇘P⇙ X) = X [^]⇘P⇙ (n - 1) ⊗⇘P⇙ X ⊕⇘P⇙ ⊖⇘P⇙ 𝟭⇘P⇙ ⊗⇘P⇙ 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]) (*goal: ‹⟦X ∈ carrier P; polynomial (carrier R) X; ⋀x. x ∈ carrier R ⟹ 𝟭 ⊗ x = x⟧ ⟹ X [^]⇘P⇙ (n - 1) ⊗⇘P⇙ X ⊕⇘P⇙ ⊖⇘P⇙ (𝟭⇘P⇙ ⊗⇘P⇙ X) = X [^]⇘P⇙ (n - 1) ⊗⇘P⇙ X ⊕⇘P⇙ ⊖⇘P⇙ 𝟭⇘P⇙ ⊗⇘P⇙ X›*) apply algebra (*proven 4 subgoals*) . finally (*calculation: ‹gauss_poly R (n::nat) = (X [^]⇘P⇙ (n - (1::nat)) ⊖⇘P⇙ 𝟭⇘P⇙) ⊗⇘P⇙ X›*) show "?thesis" (*goal: ‹gauss_poly R n = (X [^]⇘P⇙ (n - 1) ⊖⇘P⇙ 𝟭⇘P⇙) ⊗⇘P⇙ X›*) by simp qed lemma var_neq_zero: "X ≠ 𝟬⇘P⇙" by (simp add:var_def (*‹X⇘?R⇙ = [𝟭⇘?R⇙, 𝟬⇘?R⇙]›*) univ_poly_zero (*‹𝟬⇘?K [X]⇘?R⇙⇙ = []›*)) lemma var_pow_eq_one_iff: "X [^]⇘P⇙ k = 𝟭⇘P⇙ ⟷ k = (0::nat)" proof (cases "k=0") (*goals: 1. ‹(k::nat) = (0::nat) ⟹ (X [^]⇘P⇙ k = 𝟭⇘P⇙) = (k = (0::nat))› 2. ‹(k::nat) ≠ (0::nat) ⟹ (X [^]⇘P⇙ k = 𝟭⇘P⇙) = (k = (0::nat))›*) case True (*‹(k::nat) = (0::nat)›*) then show "?thesis" (*goal: ‹(X [^]⇘P⇙ k = 𝟭⇘P⇙) = (k = 0)›*) using var_closed(1) (*‹X ∈ carrier P›*) by simp next (*goal: ‹k ≠ 0 ⟹ (X [^]⇘P⇙ k = 𝟭⇘P⇙) = (k = 0)›*) case False (*‹(k::nat) ≠ (0::nat)›*) have "degree (X⇘R⇙ [^]⇘P⇙ k) = k " using var_pow_degree (*‹degree (X [^]⇘P⇙ ?n) = ?n›*) by simp also (*calculation: ‹degree (X [^]⇘P⇙ k) = k›*) have "... ≠ degree (𝟭⇘P⇙)" using False (*‹k ≠ 0›*) degree_one (*‹degree 𝟭⇘?K::'a::type set [X]⇙ = (0::nat)›*) by simp finally (*calculation: ‹degree (X [^]⇘P⇙ k) ≠ degree 𝟭⇘P⇙›*) have "degree (X⇘R⇙ [^]⇘P⇙ k) ≠ degree 𝟭⇘P⇙" by simp then show "?thesis" (*goal: ‹(X [^]⇘P⇙ k = 𝟭⇘P⇙) = (k = 0)›*) by auto qed lemma gauss_poly_carr: "gauss_poly R n ∈ carrier P" using var_closed(1) (*‹X ∈ carrier P›*) unfolding gauss_poly_def (*goal: ‹X [^]⇘P⇙ n ⊖⇘P⇙ X ∈ carrier P›*) by simp lemma gauss_poly_degree: assumes "n > 1" shows "degree (gauss_poly R n) = n" proof (-) (*goal: ‹degree (gauss_poly R n) = n›*) have "degree (gauss_poly R n) = max n 1" unfolding gauss_poly_def a_minus_def (*goal: ‹degree (X [^]⇘P⇙ n ⊕⇘P⇙ ⊖⇘P⇙ X) = max n 1›*) using var_pow_carr (*‹X [^]⇘P⇙ ?n ∈ carrier P - {𝟬⇘P⇙}›*) var_carr (*‹X ∈ carrier P - {𝟬⇘P⇙}›*) degree_var (*‹degree X = 1›*) using var_pow_degree (*‹degree (X [^]⇘P⇙ ?n) = ?n›*) univ_poly_a_inv_degree (*‹(?p::'a::type list) ∈ carrier P ⟹ degree (⊖⇘P⇙ ?p) = degree ?p›*) using assms (*‹(1::nat) < (n::nat)›*) apply (subst degree_add_distinct (*‹⟦?f ∈ carrier P - {𝟬⇘P⇙}; ?g ∈ carrier P - {𝟬⇘P⇙}; degree ?f ≠ degree ?g⟧ ⟹ degree (?f ⊕⇘P⇙ ?g) = max (degree ?f) (degree ?g)›*)) (*goals: 1. ‹⟦⋀n::nat. X [^]⇘P⇙ n ∈ carrier P - {𝟬⇘P⇙}; X ∈ carrier P - {𝟬⇘P⇙}; degree X = (1::nat); ⋀n::nat. degree (X [^]⇘P⇙ n) = n; ⋀p::'a list. p ∈ carrier P ⟹ degree (⊖⇘P⇙ p) = degree p; (1::nat) < (n::nat)⟧ ⟹ X [^]⇘P⇙ n ∈ carrier P - {𝟬⇘P⇙}› 2. ‹⟦⋀n::nat. X [^]⇘P⇙ n ∈ carrier P - {𝟬⇘P⇙}; X ∈ carrier P - {𝟬⇘P⇙}; degree X = (1::nat); ⋀n::nat. degree (X [^]⇘P⇙ n) = n; ⋀p::'a list. p ∈ carrier P ⟹ degree (⊖⇘P⇙ p) = degree p; (1::nat) < (n::nat)⟧ ⟹ ⊖⇘P⇙ X ∈ carrier P - {𝟬⇘P⇙}› 3. ‹⟦⋀n::nat. X [^]⇘P⇙ n ∈ carrier P - {𝟬⇘P⇙}; X ∈ carrier P - {𝟬⇘P⇙}; degree X = (1::nat); ⋀n::nat. degree (X [^]⇘P⇙ n) = n; ⋀p::'a list. p ∈ carrier P ⟹ degree (⊖⇘P⇙ p) = degree p; (1::nat) < (n::nat)⟧ ⟹ degree (X [^]⇘P⇙ n) ≠ degree (⊖⇘P⇙ X)› 4. ‹⟦⋀n::nat. X [^]⇘P⇙ n ∈ carrier P - {𝟬⇘P⇙}; X ∈ carrier P - {𝟬⇘P⇙}; degree X = (1::nat); ⋀n::nat. degree (X [^]⇘P⇙ n) = n; ⋀p::'a list. p ∈ carrier P ⟹ degree (⊖⇘P⇙ p) = degree p; (1::nat) < (n::nat)⟧ ⟹ max (degree (X [^]⇘P⇙ n)) (degree (⊖⇘P⇙ X)) = max n (1::nat)› 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*) . also (*calculation: ‹degree (gauss_poly R (n::nat)) = max n (1::nat)›*) have "... = n" using assms (*‹1 < n›*) by simp finally (*calculation: ‹degree (gauss_poly R n) = n›*) show "?thesis" (*goal: ‹degree (gauss_poly R n) = n›*) by simp qed lemma gauss_poly_not_zero: assumes "n > 1" shows "gauss_poly R n ≠ 𝟬⇘P⇙" proof (-) (*goal: ‹gauss_poly R n ≠ 𝟬⇘P⇙›*) have "degree (gauss_poly R n) ≠ degree ( 𝟬⇘P⇙)" using assms (*‹1 < n›*) apply (subst gauss_poly_degree (*‹1 < ?n ⟹ degree (gauss_poly R ?n) = ?n›*)) (*goals: 1. ‹(1::nat) < (n::nat) ⟹ (1::nat) < n› 2. ‹(1::nat) < (n::nat) ⟹ n ≠ degree 𝟬⇘P⇙› discuss goal 1*) apply (simp add:univ_poly_zero (*‹𝟬⇘?K [X]⇘?R⇙⇙ = []›*)) (*discuss goal 2*) apply (simp add:univ_poly_zero (*‹𝟬⇘?K [X]⇘?R⇙⇙ = []›*)) (*proven 2 subgoals*) . thus "?thesis" (*goal: ‹gauss_poly R (n::nat) ≠ 𝟬⇘P⇙›*) by auto qed lemma gauss_poly_monic: assumes "n > 1" shows "monic_poly R (gauss_poly R n)" proof (-) (*goal: ‹monic_poly R (gauss_poly R n)›*) have "monic_poly R (X [^]⇘P⇙ n)" by (intro monic_poly_pow (*‹monic_poly R ?f ⟹ monic_poly R (?f [^]⇘P⇙ ?n)›*) monic_poly_var (*‹monic_poly R X›*)) moreover have "⊖⇘P⇙ X ∈ carrier P" using var_closed (*‹X ∈ carrier P› ‹polynomial (carrier R) X›*) by simp moreover have "degree (⊖⇘P⇙ X) < degree (X [^]⇘P⇙ n)" using assms (*‹(1::nat) < (n::nat)›*) univ_poly_a_inv_degree (*‹?p ∈ carrier P ⟹ degree (⊖⇘P⇙ ?p) = degree ?p›*) var_closed (*‹X ∈ carrier P› ‹polynomial (carrier R) X›*) using degree_var (*‹degree X = (1::nat)›*) unfolding var_pow_degree (*goal: ‹degree (⊖⇘P⇙ X) < n›*) by simp ultimately show "?thesis" (*goal: ‹monic_poly R (gauss_poly R (n::nat))›*) unfolding gauss_poly_def a_minus_def (*goal: ‹monic_poly R (X [^]⇘P⇙ n ⊕⇘P⇙ ⊖⇘P⇙ X)›*) apply (intro monic_poly_add_distinct (*‹⟦monic_poly R ?f; ?g ∈ carrier P; degree ?g < degree ?f⟧ ⟹ monic_poly R (?f ⊕⇘P⇙ ?g)›*)) (*goals: 1. ‹⟦monic_poly R (X [^]⇘P⇙ (n::nat)); ⊖⇘P⇙ X ∈ carrier P; degree (⊖⇘P⇙ X) < degree (X [^]⇘P⇙ n)⟧ ⟹ monic_poly R (X [^]⇘P⇙ n)› 2. ‹⟦monic_poly R (X [^]⇘P⇙ (n::nat)); ⊖⇘P⇙ X ∈ carrier P; degree (⊖⇘P⇙ X) < degree (X [^]⇘P⇙ n)⟧ ⟹ ⊖⇘P⇙ X ∈ carrier P› 3. ‹⟦monic_poly R (X [^]⇘P⇙ (n::nat)); ⊖⇘P⇙ X ∈ carrier P; degree (⊖⇘P⇙ X) < degree (X [^]⇘P⇙ n)⟧ ⟹ degree (⊖⇘P⇙ X) < degree (X [^]⇘P⇙ n)› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*proven 3 subgoals*) . qed lemma geom_nat: fixes q :: nat fixes x :: "_ :: {comm_ring,monoid_mult}" shows "(x-1) * (∑i ∈ {..<q}. x^i) = x^q-1" apply (induction q) (*goals: 1. ‹((x::'d) - (1::'d)) * sum ((^) x) {..<0::nat} = x ^ (0::nat) - (1::'d)› 2. ‹⋀q::nat. ((x::'d) - (1::'d)) * sum ((^) x) {..<q} = x ^ q - (1::'d) ⟹ (x - (1::'d)) * sum ((^) x) {..<Suc q} = x ^ Suc q - (1::'d)› 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]) (*proven 2 subgoals*) . text ‹The following lemma can be found in Ireland and Rosen~\<^cite>‹‹\textsection 7.1, Lemma 3› in "ireland1982"›.› lemma gauss_poly_div_gauss_poly_iff_2: fixes a :: int fixes l m :: nat assumes "l > 0" "a > 1" shows "(a ^ l - 1) dvd (a ^ m - 1) ⟷ l dvd m" (is "?lhs ⟷ ?rhs") proof (-) (*goal: ‹(a ^ l - 1 dvd a ^ m - 1) = (l dvd m)›*) define q where "q = m div l" define r where "r = m mod l" have m_def: "m = q * l + r" and r_range: "r < l" "r ≥ 0" using assms (*‹0 < l› ‹(1::int) < (a::int)›*) apply - (*goals: 1. ‹⟦(0::nat) < (l::nat); (1::int) < (a::int)⟧ ⟹ (m::nat) = (q::nat) * l + (r::nat)› 2. ‹⟦(0::nat) < (l::nat); (1::int) < (a::int)⟧ ⟹ (r::nat) < l› 3. ‹⟦(0::nat) < (l::nat); (1::int) < (a::int)⟧ ⟹ (0::nat) ≤ (r::nat)› discuss goal 1*) apply ((auto simp add:q_def (*‹q = m div l›*) r_def (*‹r = m mod l›*))[1]) (*discuss goal 2*) apply ((auto simp add:q_def (*‹q = m div l›*) r_def (*‹r = m mod l›*))[1]) (*discuss goal 3*) apply ((auto simp add:q_def (*‹q = m div l›*) r_def (*‹r = m mod l›*))[1]) (*proven 3 subgoals*) . have "a ^ (l * q) - 1 = (a ^ l) ^ q - 1" by (simp add: power_mult (*‹?a ^ (?m * ?n) = (?a ^ ?m) ^ ?n›*)) also (*calculation: ‹(a::int) ^ ((l::nat) * (q::nat)) - (1::int) = (a ^ l) ^ q - (1::int)›*) have "... = (a^l - 1) * (∑i ∈ {..<q}. (a^l)^i)" apply (subst geom_nat[symmetric] (*‹?x ^ ?q - 1 = (?x - 1) * sum ((^) ?x) {..<?q}›*)) (*goal: ‹(a ^ l) ^ q - 1 = (a ^ l - 1) * sum ((^) (a ^ l)) {..<q}›*) by simp finally (*calculation: ‹a ^ (l * q) - 1 = (a ^ l - 1) * sum ((^) (a ^ l)) {..<q}›*) have "a ^ (l * q) - 1 = (a^l - 1) * (∑i ∈ {..<q}. (a^l)^i)" by simp hence c: "a ^ l - 1 dvd a^ r * (a ^ (q * l) - 1)" by (simp add:mult.commute (*‹?a * ?b = ?b * ?a›*)) have "a ^ m - 1 = a ^ (r + q * l) - 1" unfolding m_def (*goal: ‹a ^ (q * l + r) - 1 = a ^ (r + q * l) - 1›*) using add.commute (*‹?a + ?b = ?b + ?a›*) by metis also (*calculation: ‹(a::int) ^ (m::nat) - (1::int) = a ^ ((r::nat) + (q::nat) * (l::nat)) - (1::int)›*) have "... = (a ^ r) * (a ^ (q*l)) -1" by (simp add: power_add (*‹?a ^ (?m + ?n) = ?a ^ ?m * ?a ^ ?n›*)) also (*calculation: ‹(a::int) ^ (m::nat) - (1::int) = a ^ (r::nat) * a ^ ((q::nat) * (l::nat)) - (1::int)›*) have "... = ((a ^ r) * (a ^ (q*l) -1)) + (a ^ r) - 1" by (simp add: right_diff_distrib (*‹(?a::?'a) * ((?b::?'a) - (?c::?'a)) = ?a * ?b - ?a * ?c›*)) also (*calculation: ‹a ^ m - 1 = a ^ r * (a ^ (q * l) - 1) + a ^ r - 1›*) have "... = (a ^ r) * (a ^ (q*l) - 1) + ((a ^ r) - 1)" by simp finally (*calculation: ‹a ^ m - 1 = a ^ r * (a ^ (q * l) - 1) + (a ^ r - 1)›*) have a: "a ^ m - 1 = (a ^ r) * (a ^ (q*l) - 1) + ((a ^ r) - 1)" (is "_ = ?x") by simp have "?lhs ⟷ (a^l -1) dvd ?x" apply (subst a (*‹a ^ m - 1 = a ^ r * (a ^ (q * l) - 1) + (a ^ r - 1)›*)) (*goal: ‹(a ^ l - 1 dvd a ^ m - 1) = (a ^ l - 1 dvd a ^ r * (a ^ (q * l) - 1) + (a ^ r - 1))›*) by simp also (*calculation: ‹(a ^ l - 1 dvd a ^ m - 1) = (a ^ l - 1 dvd a ^ r * (a ^ (q * l) - 1) + (a ^ r - 1))›*) have "... ⟷ (a^l -1) dvd (a^r -1)" using c (*‹a ^ l - 1 dvd a ^ r * (a ^ (q * l) - 1)›*) dvd_add_right_iff (*‹?a dvd ?b ⟹ (?a dvd ?b + ?c) = (?a dvd ?c)›*) by auto also (*calculation: ‹((a::int) ^ (l::nat) - (1::int) dvd a ^ (m::nat) - (1::int)) = (a ^ l - (1::int) dvd a ^ (r::nat) - (1::int))›*) have "... ⟷ r = 0" proof (standard) (*goals: 1. ‹a ^ l - 1 dvd a ^ r - 1 ⟹ r = 0› 2. ‹r = 0 ⟹ a ^ l - 1 dvd a ^ r - 1›*) assume "a ^ l - 1 dvd a ^ r - 1" (*‹(a::int) ^ (l::nat) - (1::int) dvd a ^ (r::nat) - (1::int)›*) hence "a ^ l - 1 ≤ a ^ r -1 ∨ r = 0 " using assms (*‹0 < l› ‹1 < a›*) r_range (*‹(r::nat) < (l::nat)› ‹0 ≤ r›*) zdvd_not_zless (*‹⟦0 < ?m; ?m < ?n⟧ ⟹ ¬ ?n dvd ?m›*) by force moreover have "a ^ r < a^l" using assms (*‹(0::nat) < (l::nat)› ‹1 < a›*) r_range (*‹r < l› ‹0 ≤ r›*) by simp ultimately show "r= 0" by simp next (*goal: ‹r = 0 ⟹ a ^ l - 1 dvd a ^ r - 1›*) assume "r = 0" (*‹(r::nat) = (0::nat)›*) thus "a ^ l - 1 dvd a ^ r - 1" by simp qed also (*calculation: ‹(a ^ l - 1 dvd a ^ m - 1) = (r = 0)›*) have "... ⟷ l dvd m" using r_def (*‹r = m mod l›*) by auto finally (*calculation: ‹(a ^ l - 1 dvd a ^ m - 1) = (l dvd m)›*) show "?thesis" (*goal: ‹(a ^ l - 1 dvd a ^ m - 1) = (l dvd m)›*) by simp qed lemma gauss_poly_div_gauss_poly_iff: assumes "m > 0" "n > 0" "a > 1" shows "gauss_poly R (a^n) pdivides⇘R⇙ gauss_poly R (a^m) ⟷ n dvd m" (is "?lhs=?rhs") proof (-) (*goal: ‹gauss_poly R (a ^ n) pdivides gauss_poly R (a ^ m) = (n dvd m)›*) have a: "a^m > 1" using assms (*‹0 < m› ‹0 < n› ‹(1::nat) < (a::nat)›*) one_less_power (*‹⟦1 < ?a; 0 < ?n⟧ ⟹ 1 < ?a ^ ?n›*) by blast hence a1: "a^m > 0" by linarith have b: "a^n > 1" using assms (*‹0 < m› ‹0 < n› ‹1 < a›*) one_less_power (*‹⟦1 < ?a; 0 < ?n⟧ ⟹ 1 < ?a ^ ?n›*) by blast hence b1: "a^n > 0" by linarith have "?lhs ⟷ (X [^]⇘P⇙ (a^n-1) ⊖⇘P⇙ 𝟭⇘P⇙) ⊗⇘P⇙ X pdivides (X [^]⇘P⇙ (a^m-1) ⊖⇘P⇙ 𝟭⇘P⇙) ⊗⇘P⇙ X" using gauss_poly_factor (*‹(0::nat) < (?n::nat) ⟹ gauss_poly R ?n = (X [^]⇘P⇙ (?n - (1::nat)) ⊖⇘P⇙ 𝟭⇘P⇙) ⊗⇘P⇙ X›*) a1 (*‹0 < a ^ m›*) b1 (*‹0 < a ^ n›*) by simp also (*calculation: ‹gauss_poly R (a ^ n) pdivides gauss_poly R (a ^ m) = (X [^]⇘P⇙ (a ^ n - 1) ⊖⇘P⇙ 𝟭⇘P⇙) ⊗⇘P⇙ X pdivides (X [^]⇘P⇙ (a ^ m - 1) ⊖⇘P⇙ 𝟭⇘P⇙) ⊗⇘P⇙ X›*) have "... ⟷ (X [^]⇘P⇙ (a^n-1) ⊖⇘P⇙ 𝟭⇘P⇙) pdivides (X [^]⇘P⇙ (a^m-1) ⊖⇘P⇙ 𝟭⇘P⇙)" using var_closed (*‹X ∈ carrier P› ‹polynomial (carrier R) X›*) a (*‹(1::nat) < (a::nat) ^ (m::nat)›*) b (*‹1 < a ^ n›*) var_neq_zero (*‹X ≠ 𝟬⇘P⇙›*) apply (subst pdivides_mult_r (*‹⟦?a ∈ carrier (Ring_Divisibility.mult_of P); ?b ∈ carrier (Ring_Divisibility.mult_of P); ?c ∈ carrier (Ring_Divisibility.mult_of P)⟧ ⟹ ?a ⊗⇘P⇙ ?c pdivides ?b ⊗⇘P⇙ ?c = ?a pdivides ?b›*)) (*goals: 1. ‹⟦X ∈ carrier P; polynomial (carrier R) X; 1 < a ^ m; 1 < a ^ n; X ≠ 𝟬⇘P⇙⟧ ⟹ X [^]⇘P⇙ (a ^ n - 1) ⊖⇘P⇙ 𝟭⇘P⇙ ∈ carrier (Ring_Divisibility.mult_of P)› 2. ‹⟦X ∈ carrier P; polynomial (carrier R) X; 1 < a ^ m; 1 < a ^ n; X ≠ 𝟬⇘P⇙⟧ ⟹ X [^]⇘P⇙ (a ^ m - 1) ⊖⇘P⇙ 𝟭⇘P⇙ ∈ carrier (Ring_Divisibility.mult_of P)› 3. ‹⟦X ∈ carrier P; polynomial (carrier R) X; 1 < a ^ m; 1 < a ^ n; X ≠ 𝟬⇘P⇙⟧ ⟹ X ∈ carrier (Ring_Divisibility.mult_of P)› 4. ‹⟦X ∈ carrier P; polynomial (carrier R) X; 1 < a ^ m; 1 < a ^ n; X ≠ 𝟬⇘P⇙⟧ ⟹ (X [^]⇘P⇙ (a ^ n - 1) ⊖⇘P⇙ 𝟭⇘P⇙) pdivides (X [^]⇘P⇙ (a ^ m - 1) ⊖⇘P⇙ 𝟭⇘P⇙) = (X [^]⇘P⇙ (a ^ n - 1) ⊖⇘P⇙ 𝟭⇘P⇙) pdivides (X [^]⇘P⇙ (a ^ m - 1) ⊖⇘P⇙ 𝟭⇘P⇙)› discuss goal 1*) apply (simp add:var_pow_eq_one_iff (*‹(X [^]⇘P⇙ (?k::nat) = 𝟭⇘P⇙) = (?k = (0::nat))›*)) (*discuss goal 2*) apply (simp add:var_pow_eq_one_iff (*‹(X [^]⇘P⇙ ?k = 𝟭⇘P⇙) = (?k = 0)›*)) (*discuss goal 3*) apply (simp add:var_pow_eq_one_iff (*‹(X [^]⇘P⇙ (?k::nat) = 𝟭⇘P⇙) = (?k = (0::nat))›*)) (*discuss goal 4*) apply (simp add:var_pow_eq_one_iff (*‹(X [^]⇘P⇙ ?k = 𝟭⇘P⇙) = (?k = 0)›*)) (*proven 4 subgoals*) . also (*calculation: ‹gauss_poly R (a ^ n) pdivides gauss_poly R (a ^ m) = (X [^]⇘P⇙ (a ^ n - 1) ⊖⇘P⇙ 𝟭⇘P⇙) pdivides (X [^]⇘P⇙ (a ^ m - 1) ⊖⇘P⇙ 𝟭⇘P⇙)›*) have "... ⟷ a^n-1 dvd a^m-1" using b (*‹1 < a ^ n›*) apply (subst gauss_poly_div_gauss_poly_iff_1 (*‹0 < ?l ⟹ (X [^]⇘P⇙ ?l ⊖⇘P⇙ 𝟭⇘P⇙) pdivides (X [^]⇘P⇙ ?m ⊖⇘P⇙ 𝟭⇘P⇙) = (?l dvd ?m)›*)) (*goals: 1. ‹1 < a ^ n ⟹ 0 < a ^ n - 1› 2. ‹1 < a ^ n ⟹ (a ^ n - 1 dvd a ^ m - 1) = (a ^ n - 1 dvd a ^ m - 1)› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) . also (*calculation: ‹gauss_poly R ((a::nat) ^ (n::nat)) pdivides gauss_poly R (a ^ (m::nat)) = (a ^ n - (1::nat) dvd a ^ m - (1::nat))›*) have "... ⟷ int (a^n-1) dvd int (a^m-1)" apply (subst of_nat_dvd_iff (*‹(of_nat ?m dvd of_nat ?n) = (?m dvd ?n)›*)) (*goal: ‹(a ^ n - 1 dvd a ^ m - 1) = (int (a ^ n - 1) dvd int (a ^ m - 1))›*) by simp also (*calculation: ‹gauss_poly R (a ^ n) pdivides gauss_poly R (a ^ m) = (int (a ^ n - 1) dvd int (a ^ m - 1))›*) have "... ⟷ int a^n-1 dvd int a^m-1" using a (*‹1 < a ^ m›*) b (*‹1 < a ^ n›*) by (simp add:of_nat_diff (*‹(?n::nat) ≤ (?m::nat) ⟹ of_nat (?m - ?n) = of_nat ?m - of_nat ?n›*)) also (*calculation: ‹gauss_poly R (a ^ n) pdivides gauss_poly R (a ^ m) = (int a ^ n - 1 dvd int a ^ m - 1)›*) have "... ⟷ n dvd m" using assms (*‹0 < m› ‹(0::nat) < (n::nat)› ‹1 < a›*) apply (subst gauss_poly_div_gauss_poly_iff_2 (*‹⟦0 < ?l; 1 < ?a⟧ ⟹ (?a ^ ?l - 1 dvd ?a ^ ?m - 1) = (?l dvd ?m)›*)) (*goals: 1. ‹⟦0 < m; 0 < n; 1 < a⟧ ⟹ 0 < n› 2. ‹⟦0 < m; 0 < n; 1 < a⟧ ⟹ 1 < int a› 3. ‹⟦0 < m; 0 < n; 1 < a⟧ ⟹ (n dvd m) = (n dvd m)› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*discuss goal 3*) apply simp (*proven 3 subgoals*) . finally (*calculation: ‹gauss_poly R (a ^ n) pdivides gauss_poly R (a ^ m) = (n dvd m)›*) show "?thesis" (*goal: ‹gauss_poly R (a ^ n) pdivides gauss_poly R (a ^ m) = (n dvd m)›*) by simp qed end context finite_field begin interpretation polynomial_ring "R" "carrier R" unfolding polynomial_ring_def polynomial_ring_axioms_def (*goal: ‹field R ∧ subfield (carrier R) R›*) using field_axioms (*‹field R›*) carrier_is_subfield (*‹subfield (carrier R) R›*) by simp lemma div_gauss_poly_iff: assumes "n > 0" assumes "monic_irreducible_poly R f" shows "f pdivides⇘R⇙ gauss_poly R (order R^n) ⟷ degree f dvd n" proof (-) (*goal: ‹f pdivides gauss_poly R (order R ^ n) = (degree f dvd n)›*) have f_carr: "f ∈ carrier P" using assms(2) (*‹m_i_p R f›*) unfolding monic_irreducible_poly_def (*goal: ‹f ∈ carrier P›*) unfolding monic_poly_def (*goal: ‹f ∈ carrier P›*) by simp have f_deg: "degree f > 0" using assms(2) (*‹m_i_p R f›*) monic_poly_min_degree (*‹m_i_p R ?f ⟹ 1 ≤ degree ?f›*) by fastforce define K where "K = Rupt⇘R⇙ (carrier R) f" have field_K: "field K" using assms(2) (*‹m_i_p R f›*) unfolding K_def monic_irreducible_poly_def (*goal: ‹field (Rupt (carrier R) f)›*) unfolding monic_poly_def (*goal: ‹field (Rupt (carrier R) f)›*) apply (subst rupture_is_field_iff_pirreducible (*‹(?p::'a::type list) ∈ carrier P ⟹ field (Rupt (carrier R) ?p) = pirreducible (carrier R) ?p›*)) (*goals: 1. ‹(f ≠ [] ∧ lead_coeff f = 𝟭 ∧ f ∈ carrier P) ∧ pirreducible (carrier R) f ⟹ f ∈ carrier P› 2. ‹(f ≠ [] ∧ lead_coeff f = 𝟭 ∧ f ∈ carrier P) ∧ pirreducible (carrier R) f ⟹ pirreducible (carrier R) f› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . have a: "order K = order R^degree f" using rupture_order[OF carrier_is_subfield] (*‹⟦?f ∈ carrier P; 0 < degree ?f⟧ ⟹ order (Rupt (carrier R) ?f) = card (carrier R) ^ degree ?f›*) f_carr (*‹f ∈ carrier P›*) f_deg (*‹(0::nat) < degree (f::'a::type list)›*) unfolding K_def order_def (*goal: ‹card (carrier (Rupt (carrier R) f)) = card (carrier R) ^ degree f›*) by simp have char_K: "char K = char R" using rupture_char[OF carrier_is_subfield] (*‹⟦(?f::'a list) ∈ carrier P; (0::nat) < degree ?f⟧ ⟹ char (Rupt (carrier R) ?f) = char R›*) f_carr (*‹f ∈ carrier P›*) f_deg (*‹0 < degree f›*) unfolding K_def (*goal: ‹char (Rupt (carrier R) f) = char R›*) by simp have "card (carrier K) > 0" using a (*‹order K = order R ^ degree f›*) f_deg (*‹0 < degree f›*) finite_field_min_order (*‹1 < order R›*) unfolding order_def (*goal: ‹(0::nat) < card (carrier (K::'a list set ring))›*) by simp hence d: "finite (carrier K)" using card_ge_0_finite (*‹0 < card ?A ⟹ finite ?A›*) by auto interpret f: finite_field K using field_K (*‹field K›*) d (*‹finite (carrier K)›*) apply (intro finite_fieldI (*‹⟦field (?R::(?'a, ?'b) ring_scheme); finite (carrier ?R)⟧ ⟹ finite_field ?R›*)) (*goals: 1. ‹⟦field K; finite (carrier K)⟧ ⟹ field K› 2. ‹⟦field K; finite (carrier K)⟧ ⟹ finite (carrier K)› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) . interpret fp: polynomial_ring K "(carrier K)" unfolding polynomial_ring_def polynomial_ring_axioms_def (*goal: ‹field (K::'a list set ring) ∧ subfield (carrier K) K›*) using f.field_axioms (*‹field K›*) f.carrier_is_subfield (*‹subfield (carrier K) K›*) by simp define φ where "φ = rupture_surj (carrier R) f" interpret h: ring_hom_ring P K "φ" unfolding K_def "φ_def" (*goal: ‹ring_hom_ring P (Rupt (carrier R) f) (rupture_surj (carrier R) f)›*) using f_carr (*‹(f::'a list) ∈ carrier P›*) rupture_surj_hom (*‹(?p::'a list) ∈ carrier P ⟹ rupture_surj (carrier R) ?p ∈ ring_hom P (Rupt (carrier R) ?p)› ‹(?p::'a list) ∈ carrier P ⟹ ring_hom_ring P (Rupt (carrier R) ?p) (rupture_surj (carrier R) ?p)›*) by simp have embed_inj: "inj_on (φ ∘ poly_of_const) (carrier R)" unfolding "φ_def" (*goal: ‹inj_on (rupture_surj (carrier R) f ∘ poly_of_const) (carrier R)›*) using embed_inj[OF carrier_is_subfield f_carr f_deg] (*‹inj_on (rupture_surj (carrier R) f ∘ poly_of_const) (carrier R)›*) by simp interpret r: ring_hom_ring R P poly_of_const using canonical_embedding_ring_hom (*‹ring_hom_ring (R⦇carrier := carrier R⦈) P poly_of_const›*) by simp obtain rn where "order R = char K^rn" "rn > 0" (*goal: ‹(⋀rn. ⟦order R = char K ^ rn; 0 < rn⟧ ⟹ thesis) ⟹ thesis›*) unfolding char_K (*goal: ‹(⋀rn::nat. ⟦order R = char R ^ rn; (0::nat) < rn⟧ ⟹ thesis::bool) ⟹ thesis›*) using finite_field_order (*‹∃n. order R = char R ^ n ∧ 0 < n›*) by auto hence ord_rn: "order R ^n = char K^(rn * n)" using assms(1) (*‹0 < n›*) by (simp add: power_mult (*‹?a ^ (?m * ?n) = (?a ^ ?m) ^ ?n›*)) interpret q: ring_hom_cring K K "λx. x [^]⇘K⇙ order R^n" using ord_rn (*‹order R ^ n = char K ^ (rn * n)›*) apply (intro f.frobenius_hom (*‹⟦0 < char K; ?m = char K ^ ?k⟧ ⟹ ring_hom_cring K K (λx. x [^]⇘K⇙ ?m)›*) f.finite_carr_imp_char_ge_0 (*‹finite (carrier K) ⟹ 0 < char K›*) d (*‹finite (carrier K)›*)) (*goal: ‹ring_hom_cring (K::'a list set ring) K (λx::'a list set. x [^]⇘K⇙ order R ^ (n::nat))›*) by simp have o1: "order R^degree f > 1" using f_deg (*‹0 < degree f›*) finite_field_min_order (*‹(1::nat) < order R›*) one_less_power (*‹⟦1 < ?a; 0 < ?n⟧ ⟹ 1 < ?a ^ ?n›*) by blast hence o11: "order R^degree f > 0" by linarith have o2: "order R^n > 1" using assms(1) (*‹0 < n›*) finite_field_min_order (*‹1 < order R›*) one_less_power (*‹⟦1 < ?a; 0 < ?n⟧ ⟹ 1 < ?a ^ ?n›*) by blast hence o21: "order R^n > 0" by linarith let ?g1 = "gauss_poly K (order R^degree f)" let ?g2 = "gauss_poly K (order R^n)" have g1_monic: "monic_poly K ?g1" using f.gauss_poly_monic[OF o1] (*‹monic_poly K (gauss_poly K (order R ^ degree f))›*) by simp have c: "x [^]⇘K⇙ (order R^degree f) = x" if b: "x ∈ carrier K" for x using b (*‹x ∈ carrier K›*) d (*‹finite (carrier K)›*) order_pow_eq_self (*‹?x ∈ carrier R ⟹ ?x [^] order R = ?x›*) unfolding a[symmetric] (*goal: ‹(x::'a list set) [^]⇘K::'a list set ring⇙ order K = x›*) apply (intro f.order_pow_eq_self (*‹?x ∈ carrier K ⟹ ?x [^]⇘K⇙ order K = ?x›*)) (*goal: ‹(x::'a list set) [^]⇘K::'a list set ring⇙ order K = x›*) by auto have k_cycle: "φ (poly_of_const x) [^]⇘K⇙ (order R^n) = φ(poly_of_const x)" if k_cycle_1: "x ∈ carrier R" for x proof (-) (*goal: ‹φ (poly_of_const x) [^]⇘K⇙ order R ^ n = φ (poly_of_const x)›*) have "φ (poly_of_const x) [^]⇘K⇙ (order R^n) = φ (poly_of_const (x [^]⇘R⇙ (order R^n)))" using k_cycle_1 (*‹x ∈ carrier R›*) by (simp add: h.hom_nat_pow (*‹?x ∈ carrier P ⟹ φ (?x [^]⇘P⇙ ?n) = φ ?x [^]⇘K⇙ ?n›*) r.hom_nat_pow (*‹?x ∈ carrier R ⟹ poly_of_const (?x [^] ?n) = poly_of_const ?x [^]⇘P⇙ ?n›*)) also (*calculation: ‹φ (poly_of_const x) [^]⇘K⇙ order R ^ n = φ (poly_of_const (x [^] order R ^ n))›*) have "... = φ (poly_of_const x)" using order_pow_eq_self' (*‹?x ∈ carrier R ⟹ ?x [^] order R ^ ?d = ?x›*) k_cycle_1 (*‹x ∈ carrier R›*) by simp finally (*calculation: ‹φ (poly_of_const x) [^]⇘K⇙ order R ^ n = φ (poly_of_const x)›*) show "?thesis" (*goal: ‹φ (poly_of_const x) [^]⇘K⇙ order R ^ n = φ (poly_of_const x)›*) by simp qed have roots_g1: "pmult⇘K⇙ d ?g1 ≥ 1" if roots_g1_assms: "degree d = 1" "monic_irreducible_poly K d" for d proof (-) (*goal: ‹1 ≤ pmult⇘K⇙ d (gauss_poly K (order R ^ degree f))›*) obtain x where x_def: "x ∈ carrier K" "d = [𝟭⇘K⇙, ⊖⇘K⇙ x]" (*goal: ‹(⋀x. ⟦x ∈ carrier K; d = [𝟭⇘K⇙, ⊖⇘K⇙ x]⟧ ⟹ thesis) ⟹ thesis›*) using f.degree_one_monic_poly (*‹(m_i_p K ?f ∧ degree ?f = 1) = (∃x∈carrier K. ?f = [𝟭⇘K⇙, ⊖⇘K⇙ x])›*) roots_g1_assms (*‹degree d = 1› ‹m_i_p K d›*) by auto interpret x: ring_hom_cring "poly_ring K" K "(λp. f.eval p x)" by (intro fp.eval_cring_hom (*‹?a ∈ carrier K ⟹ ring_hom_cring fp.P K (λp. f.eval p ?a)›*) x_def (*‹x ∈ carrier K› ‹d = [𝟭⇘K⇙, ⊖⇘K⇙ x]›*)) have "ring.eval K ?g1 x = 𝟬⇘K⇙" unfolding gauss_poly_def a_minus_def (*goal: ‹f.eval (X⇘K⇙ [^]⇘fp.P⇙ order R ^ degree f ⊕⇘fp.P⇙ ⊖⇘fp.P⇙ X⇘K⇙) x = 𝟬⇘K⇙›*) using fp.var_closed (*‹X⇘K⇙ ∈ carrier fp.P› ‹polynomial⇘K⇙ (carrier K) X⇘K⇙›*) f.eval_var (*‹?x ∈ carrier K ⟹ f.eval X⇘K⇙ ?x = ?x›*) x_def (*‹x ∈ carrier K› ‹d = [𝟭⇘K⇙, ⊖⇘K⇙ x]›*) c (*‹?x ∈ carrier K ⟹ ?x [^]⇘K⇙ order R ^ degree f = ?x›*) apply simp (*goal: ‹f.eval (X⇘K⇙ [^]⇘fp.P⇙ order R ^ degree f ⊕⇘fp.P⇙ ⊖⇘fp.P⇙ X⇘K⇙) x = 𝟬⇘K⇙›*) by algebra hence "f.is_root ?g1 x" using x_def (*‹x ∈ carrier K› ‹(d::'a list set list) = [𝟭⇘K::'a list set ring⇙, ⊖⇘K⇙ (x::'a list set)]›*) f.gauss_poly_not_zero[OF o1] (*‹gauss_poly K (order R ^ degree f) ≠ 𝟬⇘fp.P⇙›*) unfolding f.is_root_def univ_poly_zero (*goal: ‹(x::'a::type list set) ∈ carrier (K::'a list set ring) ∧ f.eval (gauss_poly K (order R ^ degree (f::'a::type list))) x = 𝟬⇘K⇙ ∧ gauss_poly K (order R ^ degree f) ≠ []›*) by simp hence "[𝟭⇘K⇙, ⊖⇘K⇙ x] pdivides⇘K⇙ ?g1" using f.is_root_imp_pdivides (*‹⟦(?p::'a list set list) ∈ carrier fp.P; f.is_root ?p (?x::'a list set)⟧ ⟹ [𝟭⇘K⇙, ⊖⇘K⇙ ?x] pdivides⇘K::'a list set ring⇙ ?p›*) f.gauss_poly_carr (*‹gauss_poly K ?n ∈ carrier fp.P›*) by simp hence "d pdivides⇘K⇙ ?g1" by (simp add:x_def (*‹x ∈ carrier K› ‹d = [𝟭⇘K⇙, ⊖⇘K⇙ x]›*)) thus "pmult⇘K⇙ d ?g1 ≥ 1" using that (*‹degree d = 1› ‹m_i_p K d›*) f.gauss_poly_not_zero (*‹1 < ?n ⟹ gauss_poly K ?n ≠ 𝟬⇘fp.P⇙›*) f.gauss_poly_carr (*‹gauss_poly K ?n ∈ carrier fp.P›*) o1 (*‹(1::nat) < order R ^ degree (f::'a::type list)›*) apply (subst f.multiplicity_ge_1_iff_pdivides (*‹⟦m_i_p K ?d; ?f ∈ carrier fp.P - {𝟬⇘fp.P⇙}⟧ ⟹ (1 ≤ pmult⇘K⇙ ?d ?f) = ?d pdivides⇘K⇙ ?f›*)) (*goals: 1. ‹⟦(d::'a list set list) pdivides⇘K::'a list set ring⇙ gauss_poly K (order R ^ degree (f::'a list)); degree d = (1::nat); m_i_p K d; ⋀n::nat. (1::nat) < n ⟹ gauss_poly K n ≠ 𝟬⇘fp.P⇙; ⋀n::nat. gauss_poly K n ∈ carrier fp.P; (1::nat) < order R ^ degree f⟧ ⟹ m_i_p K d› 2. ‹⟦(d::'a list set list) pdivides⇘K::'a list set ring⇙ gauss_poly K (order R ^ degree (f::'a list)); degree d = (1::nat); m_i_p K d; ⋀n::nat. (1::nat) < n ⟹ gauss_poly K n ≠ 𝟬⇘fp.P⇙; ⋀n::nat. gauss_poly K n ∈ carrier fp.P; (1::nat) < order R ^ degree f⟧ ⟹ gauss_poly K (order R ^ degree f) ∈ carrier fp.P - {𝟬⇘fp.P⇙}› 3. ‹⟦(d::'a list set list) pdivides⇘K::'a list set ring⇙ gauss_poly K (order R ^ degree (f::'a list)); degree d = (1::nat); m_i_p K d; ⋀n::nat. (1::nat) < n ⟹ gauss_poly K n ≠ 𝟬⇘fp.P⇙; ⋀n::nat. gauss_poly K n ∈ carrier fp.P; (1::nat) < order R ^ degree f⟧ ⟹ d pdivides⇘K⇙ gauss_poly K (order R ^ degree f)› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*discuss goal 3*) apply simp (*proven 3 subgoals*) . qed show "?thesis" (*goal: ‹f pdivides gauss_poly R (order R ^ n) = (degree f dvd n)›*) proof (standard) (*goals: 1. ‹(f::'a::type list) pdivides gauss_poly R (order R ^ (n::nat)) ⟹ degree f dvd n› 2. ‹degree (f::'a::type list) dvd (n::nat) ⟹ f pdivides gauss_poly R (order R ^ n)›*) assume f: "f pdivides⇘R⇙ gauss_poly R (order R^n)" (*‹(f::'a list) pdivides gauss_poly R (order R ^ (n::nat))›*) have "(φ X) [^]⇘K⇙ (order R^n) ⊖⇘K⇙ (φ X⇘R⇙) = φ (gauss_poly R (order R^n))" unfolding gauss_poly_def a_minus_def (*goal: ‹φ X [^]⇘K⇙ order R ^ n ⊕⇘K⇙ ⊖⇘K⇙ φ X = φ (X [^]⇘P⇙ order R ^ n ⊕⇘P⇙ ⊖⇘P⇙ X)›*) using var_closed (*‹X ∈ carrier P› ‹polynomial (carrier R) X›*) by (simp add: h.hom_nat_pow (*‹?x ∈ carrier P ⟹ φ (?x [^]⇘P⇙ ?n) = φ ?x [^]⇘K⇙ ?n›*)) also (*calculation: ‹φ X [^]⇘K⇙ order R ^ n ⊖⇘K⇙ φ X = φ (gauss_poly R (order R ^ n))›*) have "... = 𝟬⇘K⇙" unfolding K_def "φ_def" (*goal: ‹rupture_surj (carrier R) f (gauss_poly R (order R ^ n)) = 𝟬⇘Rupt (carrier R) f⇙›*) using f_carr (*‹(f::'a list) ∈ carrier P›*) gauss_poly_carr (*‹gauss_poly R ?n ∈ carrier P›*) f (*‹f pdivides gauss_poly R (order R ^ n)›*) apply (subst rupture_eq_0_iff (*‹⟦?p ∈ carrier P; ?q ∈ carrier P⟧ ⟹ (rupture_surj (carrier R) ?p ?q = 𝟬⇘Rupt (carrier R) ?p⇙) = ?p pdivides ?q›*)) (*goals: 1. ‹⟦(f::'a::type list) ∈ carrier P; ⋀n::nat. gauss_poly R n ∈ carrier P; f pdivides gauss_poly R (order R ^ (n::nat))⟧ ⟹ f ∈ carrier P› 2. ‹⟦(f::'a::type list) ∈ carrier P; ⋀n::nat. gauss_poly R n ∈ carrier P; f pdivides gauss_poly R (order R ^ (n::nat))⟧ ⟹ gauss_poly R (order R ^ n) ∈ carrier P› 3. ‹⟦(f::'a::type list) ∈ carrier P; ⋀n::nat. gauss_poly R n ∈ carrier P; f pdivides gauss_poly R (order R ^ (n::nat))⟧ ⟹ f pdivides gauss_poly R (order R ^ n)› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*discuss goal 3*) apply simp (*proven 3 subgoals*) . finally (*calculation: ‹(φ::'a list ⇒ 'a list set) X [^]⇘K⇙ order R ^ (n::nat) ⊖⇘K::'a list set ring⇙ φ X = 𝟬⇘K⇙›*) have "(φ X⇘R⇙) [^]⇘K⇙ (order R^n) ⊖⇘K⇙ (φ X⇘R⇙) = 𝟬⇘K⇙" by simp hence g: "(φ X) [^]⇘K⇙ (order R^n) = (φ X)" using var_closed (*‹X ∈ carrier P› ‹polynomial (carrier R) X›*) by simp have roots_g2: "pmult⇘K⇙ d ?g2 ≥ 1" if roots_g2_assms: "degree d = 1" "monic_irreducible_poly K d" for d proof (-) (*goal: ‹1 ≤ pmult⇘K⇙ d (gauss_poly K (order R ^ n))›*) obtain y where y_def: "y ∈ carrier K" "d = [𝟭⇘K⇙, ⊖⇘K⇙ y]" (*goal: ‹(⋀y::'a list set. ⟦y ∈ carrier (K::'a list set ring); (d::'a list set list) = [𝟭⇘K⇙, ⊖⇘K⇙ y]⟧ ⟹ thesis::bool) ⟹ thesis›*) using f.degree_one_monic_poly (*‹(m_i_p K ?f ∧ degree ?f = 1) = (∃x∈carrier K. ?f = [𝟭⇘K⇙, ⊖⇘K⇙ x])›*) roots_g2_assms (*‹degree d = 1› ‹m_i_p K d›*) by auto interpret x: ring_hom_cring "poly_ring K" K "(λp. f.eval p y)" by (intro fp.eval_cring_hom (*‹(?a::'a list set) ∈ carrier (K::'a list set ring) ⟹ ring_hom_cring fp.P K (λp::'a list set list. f.eval p ?a)›*) y_def (*‹(y::'a list set) ∈ carrier (K::'a list set ring)› ‹(d::'a list set list) = [𝟭⇘K::'a list set ring⇙, ⊖⇘K⇙ (y::'a list set)]›*)) obtain x where x_def: "x ∈ carrier P" "y = φ x" (*goal: ‹(⋀x. ⟦x ∈ carrier P; y = φ x⟧ ⟹ thesis) ⟹ thesis›*) using y_def (*‹y ∈ carrier K› ‹d = [𝟭⇘K⇙, ⊖⇘K⇙ y]›*) unfolding "φ_def" K_def rupture_def (*goal: ‹(⋀x. ⟦x ∈ carrier P; y = rupture_surj (carrier R) f x⟧ ⟹ thesis) ⟹ thesis›*) unfolding FactRing_def A_RCOSETS_def' (*goal: ‹(⋀x. ⟦x ∈ carrier P; y = rupture_surj (carrier R) f x⟧ ⟹ thesis) ⟹ thesis›*) by auto let ?τ = "λi. poly_of_const (coeff x i)" have test: "?τ i ∈ carrier P" for i by (intro r.hom_closed (*‹(?x::'a) ∈ carrier R ⟹ poly_of_const ?x ∈ carrier P›*) coeff_range (*‹(?f::'a list) ∈ carrier P ⟹ local.coeff ?f (?i::nat) ∈ carrier R›*) x_def (*‹(x::'a list) ∈ carrier P› ‹(y::'a list set) = (φ::'a list ⇒ 'a list set) (x::'a list)›*)) have test_2: "coeff x i ∈ carrier R" for i by (intro coeff_range (*‹?f ∈ carrier P ⟹ local.coeff ?f ?i ∈ carrier R›*) x_def (*‹x ∈ carrier P› ‹y = φ x›*)) have x_coeff_carr: "i ∈ set x ⟹ i ∈ carrier R" for i using x_def(1) (*‹x ∈ carrier P›*) by (auto simp add:univ_poly_carrier[symmetric] (*‹(?p ∈ carrier (?K [X]⇘?R⇙)) = polynomial⇘?R⇙ ?K ?p›*) polynomial_def (*‹polynomial⇘?R⇙ ?K ?p = (?p = [] ∨ set ?p ⊆ ?K ∧ lead_coeff ?p ≠ 𝟬⇘?R⇙)›*)) have a: "map (φ ∘ poly_of_const) x ∈ carrier (poly_ring K)" using rupture_surj_norm_is_hom[OF f_carr] (*‹rupture_surj (carrier R) f ∘ poly_of_const ∈ ring_hom (R⦇carrier := carrier R⦈) (Rupt (carrier R) f)›*) using domain_axioms (*‹domain R›*) f.domain_axioms (*‹domain K›*) embed_inj (*‹inj_on (φ ∘ poly_of_const) (carrier R)›*) apply (intro carrier_hom'[OF x_def(1)] (*‹⟦(?h::'a ⇒ ?'c) ∈ ring_hom R (?S::(?'c, ?'d) ring_scheme); domain R; domain ?S; inj_on ?h (carrier R)⟧ ⟹ map ?h (x::'a list) ∈ carrier (poly_ring ?S)›*)) (*goals: 1. ‹⟦rupture_surj (carrier R) f ∘ poly_of_const ∈ ring_hom (R⦇carrier := carrier R⦈) (Rupt (carrier R) f); domain R; domain K; inj_on (φ ∘ poly_of_const) (carrier R)⟧ ⟹ φ ∘ poly_of_const ∈ ring_hom R K› 2. ‹⟦rupture_surj (carrier R) f ∘ poly_of_const ∈ ring_hom (R⦇carrier := carrier R⦈) (Rupt (carrier R) f); domain R; domain K; inj_on (φ ∘ poly_of_const) (carrier R)⟧ ⟹ domain R› 3. ‹⟦rupture_surj (carrier R) f ∘ poly_of_const ∈ ring_hom (R⦇carrier := carrier R⦈) (Rupt (carrier R) f); domain R; domain K; inj_on (φ ∘ poly_of_const) (carrier R)⟧ ⟹ domain K› 4. ‹⟦rupture_surj (carrier R) f ∘ poly_of_const ∈ ring_hom (R⦇carrier := carrier R⦈) (Rupt (carrier R) f); domain R; domain K; inj_on (φ ∘ poly_of_const) (carrier R)⟧ ⟹ inj_on (φ ∘ poly_of_const) (carrier R)› discuss goal 1*) apply (simp add:φ_def (*‹(φ::'a::type list ⇒ 'a::type list set) = rupture_surj (carrier R) (f::'a::type list)›*) K_def (*‹(K::'a list set ring) = Rupt (carrier R) (f::'a::type list)›*)) (*discuss goal 2*) apply (simp add:φ_def (*‹φ = rupture_surj (carrier R) f›*) K_def (*‹K = Rupt (carrier R) f›*)) (*discuss goal 3*) apply (simp add:φ_def (*‹φ = rupture_surj (carrier R) f›*) K_def (*‹K = Rupt (carrier R) f›*)) (*discuss goal 4*) apply (simp add:φ_def (*‹φ = rupture_surj (carrier R) f›*) K_def (*‹K = Rupt (carrier R) f›*)) (*proven 4 subgoals*) . have "(φ x) [^]⇘K⇙ (order R^n) = f.eval (map (φ ∘ poly_of_const) x) (φ X) [^]⇘K⇙ (order R^n)" unfolding "φ_def" K_def (*goal: ‹rupture_surj (carrier R) f x [^]⇘Rupt (carrier R) f⇙ order R ^ n = ring.eval (Rupt (carrier R) f) (map (rupture_surj (carrier R) f ∘ poly_of_const) x) (rupture_surj (carrier R) f X) [^]⇘Rupt (carrier R) f⇙ order R ^ n›*) apply (subst rupture_surj_as_eval[OF f_carr x_def(1)] (*‹rupture_surj (carrier R) (f::'a::type list) (x::'a::type list) = ring.eval (Rupt (carrier R) f) (map (rupture_surj (carrier R) f ∘ poly_of_const) x) (rupture_surj (carrier R) f X)›*)) (*goal: ‹rupture_surj (carrier R) f x [^]⇘Rupt (carrier R) f⇙ order R ^ n = ring.eval (Rupt (carrier R) f) (map (rupture_surj (carrier R) f ∘ poly_of_const) x) (rupture_surj (carrier R) f X) [^]⇘Rupt (carrier R) f⇙ order R ^ n›*) by simp also (*calculation: ‹φ x [^]⇘K⇙ order R ^ n = f.eval (map (φ ∘ poly_of_const) x) (φ X) [^]⇘K⇙ order R ^ n›*) have "... = f.eval (map (λx. φ (poly_of_const x) [^]⇘K⇙ order R ^ n) x) (φ X)" using a (*‹map (φ ∘ poly_of_const) x ∈ carrier fp.P›*) h.hom_closed (*‹?x ∈ carrier P ⟹ φ ?x ∈ carrier K›*) var_closed(1) (*‹X ∈ carrier P›*) apply (subst q.ring.eval_hom[OF f.carrier_is_subring] (*‹⟦?a ∈ carrier K; ?p ∈ carrier fp.P⟧ ⟹ f.eval ?p ?a [^]⇘K⇙ order R ^ n = f.eval (map (λx. x [^]⇘K⇙ order R ^ n) ?p) (?a [^]⇘K⇙ order R ^ n)›*)) (*goals: 1. ‹⟦map (φ ∘ poly_of_const) x ∈ carrier fp.P; ⋀x. x ∈ carrier P ⟹ φ x ∈ carrier K; X ∈ carrier P⟧ ⟹ φ X ∈ carrier K› 2. ‹⟦map (φ ∘ poly_of_const) x ∈ carrier fp.P; ⋀x. x ∈ carrier P ⟹ φ x ∈ carrier K; X ∈ carrier P⟧ ⟹ map (φ ∘ poly_of_const) x ∈ carrier fp.P› 3. ‹⟦map (φ ∘ poly_of_const) x ∈ carrier fp.P; ⋀x. x ∈ carrier P ⟹ φ x ∈ carrier K; X ∈ carrier P⟧ ⟹ f.eval (map (λx. x [^]⇘K⇙ order R ^ n) (map (φ ∘ poly_of_const) x)) (φ X [^]⇘K⇙ order R ^ n) = f.eval (map (λx. φ (poly_of_const x) [^]⇘K⇙ order R ^ n) x) (φ X)› discuss goal 1*) apply (simp add:comp_def (*‹?f ∘ ?g = (λx. ?f (?g x))›*) g (*‹φ X [^]⇘K⇙ order R ^ n = φ X›*)) (*discuss goal 2*) apply (simp add:comp_def (*‹?f ∘ ?g = (λx. ?f (?g x))›*) g (*‹φ X [^]⇘K⇙ order R ^ n = φ X›*)) (*discuss goal 3*) apply (simp add:comp_def (*‹(?f::?'b::type ⇒ ?'c::type) ∘ (?g::?'a::type ⇒ ?'b::type) = (λx::?'a::type. ?f (?g x))›*) g (*‹(φ::'a::type list ⇒ 'a::type list set) X [^]⇘K::'a list set ring⇙ order R ^ (n::nat) = φ X›*)) (*proven 3 subgoals*) . also (*calculation: ‹φ x [^]⇘K⇙ order R ^ n = f.eval (map (λx. φ (poly_of_const x) [^]⇘K⇙ order R ^ n) x) (φ X)›*) have "... = f.eval (map (λx. φ (poly_of_const x)) x) (φ X)" using k_cycle (*‹(?x::'a) ∈ carrier R ⟹ (φ::'a list ⇒ 'a list set) (poly_of_const ?x) [^]⇘K::'a list set ring⇙ order R ^ (n::nat) = φ (poly_of_const ?x)›*) x_coeff_carr (*‹?i ∈ set x ⟹ ?i ∈ carrier R›*) apply (intro arg_cong2[where f="f.eval"] (*‹⟦?a = ?b; ?c = ?d⟧ ⟹ f.eval ?a ?c = f.eval ?b ?d›*) map_cong (*‹⟦?xs = ?ys; ⋀x. x ∈ set ?ys ⟹ ?f x = ?g x⟧ ⟹ map ?f ?xs = map ?g ?ys›*)) (*goals: 1. ‹⟦⋀x. x ∈ carrier R ⟹ φ (poly_of_const x) [^]⇘K⇙ order R ^ n = φ (poly_of_const x); ⋀i. i ∈ set x ⟹ i ∈ carrier R⟧ ⟹ x = x› 2. ‹⋀xa. ⟦⋀x. x ∈ carrier R ⟹ φ (poly_of_const x) [^]⇘K⇙ order R ^ n = φ (poly_of_const x); ⋀i. i ∈ set x ⟹ i ∈ carrier R; xa ∈ set x⟧ ⟹ φ (poly_of_const xa) [^]⇘K⇙ order R ^ n = φ (poly_of_const xa)› 3. ‹⟦⋀x. x ∈ carrier R ⟹ φ (poly_of_const x) [^]⇘K⇙ order R ^ n = φ (poly_of_const x); ⋀i. i ∈ set x ⟹ i ∈ carrier R⟧ ⟹ φ X = φ X› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*discuss goal 3*) apply simp (*proven 3 subgoals*) . also (*calculation: ‹φ x [^]⇘K⇙ order R ^ n = f.eval (map (λx. φ (poly_of_const x)) x) (φ X)›*) have "... = (φ x)" unfolding "φ_def" K_def (*goal: ‹ring.eval (Rupt (carrier R) f) (map (λx. rupture_surj (carrier R) f (poly_of_const x)) x) (rupture_surj (carrier R) f X) = rupture_surj (carrier R) f x›*) apply (subst rupture_surj_as_eval[OF f_carr x_def(1)] (*‹rupture_surj (carrier R) f x = ring.eval (Rupt (carrier R) f) (map (rupture_surj (carrier R) f ∘ poly_of_const) x) (rupture_surj (carrier R) f X)›*)) (*goal: ‹ring.eval (Rupt (carrier R) f) (map (λx. rupture_surj (carrier R) f (poly_of_const x)) x) (rupture_surj (carrier R) f X) = rupture_surj (carrier R) f x›*) by (simp add:comp_def (*‹(?f::?'b::type ⇒ ?'c::type) ∘ (?g::?'a::type ⇒ ?'b::type) = (λx::?'a::type. ?f (?g x))›*)) finally (*calculation: ‹φ x [^]⇘K⇙ order R ^ n = φ x›*) have "φ x [^]⇘K⇙ order R ^ n = φ x" by simp hence "y [^]⇘K⇙ (order R^n) = y" using x_def (*‹x ∈ carrier P› ‹(y::'a list set) = (φ::'a list ⇒ 'a list set) (x::'a list)›*) by simp hence "ring.eval K ?g2 y = 𝟬⇘K⇙" unfolding gauss_poly_def a_minus_def (*goal: ‹f.eval (X⇘K⇙ [^]⇘fp.P⇙ order R ^ n ⊕⇘fp.P⇙ ⊖⇘fp.P⇙ X⇘K⇙) y = 𝟬⇘K⇙›*) using fp.var_closed (*‹X⇘K⇙ ∈ carrier fp.P› ‹polynomial⇘K::'a list set ring⇙ (carrier K) X⇘K⇙›*) f.eval_var (*‹?x ∈ carrier K ⟹ f.eval X⇘K⇙ ?x = ?x›*) y_def (*‹y ∈ carrier K› ‹(d::'a list set list) = [𝟭⇘K::'a list set ring⇙, ⊖⇘K⇙ (y::'a list set)]›*) apply simp (*goal: ‹f.eval (X⇘K⇙ [^]⇘fp.P⇙ order R ^ n ⊕⇘fp.P⇙ ⊖⇘fp.P⇙ X⇘K⇙) y = 𝟬⇘K⇙›*) by algebra hence "f.is_root ?g2 y" using y_def (*‹y ∈ carrier K› ‹d = [𝟭⇘K⇙, ⊖⇘K⇙ y]›*) f.gauss_poly_not_zero[OF o2] (*‹gauss_poly K (order R ^ n) ≠ 𝟬⇘fp.P⇙›*) unfolding f.is_root_def univ_poly_zero (*goal: ‹y ∈ carrier K ∧ f.eval (gauss_poly K (order R ^ n)) y = 𝟬⇘K⇙ ∧ gauss_poly K (order R ^ n) ≠ []›*) by simp hence "d pdivides⇘K⇙ ?g2" unfolding y_def (*goal: ‹[𝟭⇘K⇙, ⊖⇘K⇙ (y::'a list set)] pdivides⇘K::'a list set ring⇙ gauss_poly K (order R ^ (n::nat))›*) apply (intro f.is_root_imp_pdivides (*‹⟦?p ∈ carrier fp.P; f.is_root ?p ?x⟧ ⟹ [𝟭⇘K⇙, ⊖⇘K⇙ ?x] pdivides⇘K⇙ ?p›*) f.gauss_poly_carr (*‹gauss_poly K ?n ∈ carrier fp.P›*)) (*goal: ‹[𝟭⇘K⇙, ⊖⇘K⇙ y] pdivides⇘K⇙ gauss_poly K (order R ^ n)›*) by simp thus "pmult⇘K⇙ d ?g2 ≥ 1" using that (*‹degree d = 1› ‹m_i_p (K::'a list set ring) (d::'a::type list set list)›*) f.gauss_poly_carr (*‹gauss_poly (K::'a list set ring) (?n::nat) ∈ carrier fp.P›*) f.gauss_poly_not_zero (*‹(1::nat) < (?n::nat) ⟹ gauss_poly (K::'a list set ring) ?n ≠ 𝟬⇘fp.P⇙›*) o2 (*‹(1::nat) < order R ^ (n::nat)›*) apply (subst f.multiplicity_ge_1_iff_pdivides (*‹⟦m_i_p K ?d; ?f ∈ carrier fp.P - {𝟬⇘fp.P⇙}⟧ ⟹ (1 ≤ pmult⇘K⇙ ?d ?f) = ?d pdivides⇘K⇙ ?f›*)) (*goals: 1. ‹⟦d pdivides⇘K⇙ gauss_poly K (order R ^ n); degree d = 1; m_i_p K d; ⋀n. gauss_poly K n ∈ carrier fp.P; ⋀n. 1 < n ⟹ gauss_poly K n ≠ 𝟬⇘fp.P⇙; 1 < order R ^ n⟧ ⟹ m_i_p K d› 2. ‹⟦d pdivides⇘K⇙ gauss_poly K (order R ^ n); degree d = 1; m_i_p K d; ⋀n. gauss_poly K n ∈ carrier fp.P; ⋀n. 1 < n ⟹ gauss_poly K n ≠ 𝟬⇘fp.P⇙; 1 < order R ^ n⟧ ⟹ gauss_poly K (order R ^ n) ∈ carrier fp.P - {𝟬⇘fp.P⇙}› 3. ‹⟦d pdivides⇘K⇙ gauss_poly K (order R ^ n); degree d = 1; m_i_p K d; ⋀n. gauss_poly K n ∈ carrier fp.P; ⋀n. 1 < n ⟹ gauss_poly K n ≠ 𝟬⇘fp.P⇙; 1 < order R ^ n⟧ ⟹ d pdivides⇘K⇙ gauss_poly K (order R ^ n)› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*proven 3 subgoals*) . qed have inv_k_inj: "inj_on (λx. ⊖⇘K⇙ x) (carrier K)" apply (intro inj_onI (*‹(⋀x y. ⟦x ∈ ?A; y ∈ ?A; ?f x = ?f y⟧ ⟹ x = y) ⟹ inj_on ?f ?A›*)) (*goal: ‹inj_on (a_inv K) (carrier K)›*) by (metis f.minus_minus (*‹?x ∈ carrier K ⟹ ⊖⇘K⇙ (⊖⇘K⇙ ?x) = ?x›*)) let ?mip = "monic_irreducible_poly K" have "sum' (λd. pmult⇘K⇙ d ?g1 * degree d) {d. ?mip d} = degree ?g1" using f.gauss_poly_monic (*‹1 < ?n ⟹ monic_poly K (gauss_poly K ?n)›*) o1 (*‹1 < order R ^ degree f›*) apply (subst f.degree_monic_poly' (*‹monic_poly K ?f ⟹ sum' (λd. pmult⇘K⇙ d ?f * degree d) {d. m_i_p K d} = degree ?f›*)) (*goals: 1. ‹⟦⋀n. 1 < n ⟹ monic_poly K (gauss_poly K n); 1 < order R ^ degree f⟧ ⟹ monic_poly K (gauss_poly K (order R ^ degree f))› 2. ‹⟦⋀n. 1 < n ⟹ monic_poly K (gauss_poly K n); 1 < order R ^ degree f⟧ ⟹ degree (gauss_poly K (order R ^ degree f)) = degree (gauss_poly K (order R ^ degree f))› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) . also (*calculation: ‹sum' (λd. pmult⇘K⇙ d (gauss_poly K (order R ^ degree f)) * degree d) {d. m_i_p K d} = degree (gauss_poly K (order R ^ degree f))›*) have "... = order K" using f.gauss_poly_degree (*‹1 < ?n ⟹ degree (gauss_poly K ?n) = ?n›*) o1 (*‹1 < order R ^ degree f›*) a (*‹order K = order R ^ degree f›*) by simp also (*calculation: ‹sum' (λd. pmult⇘K⇙ d (gauss_poly K (order R ^ degree f)) * degree d) {d. m_i_p K d} = order K›*) have "... = card ((λk. [𝟭⇘K⇙, ⊖⇘K⇙ k]) ` carrier K)" unfolding order_def (*goal: ‹card (carrier K) = card ((λk. [𝟭⇘K⇙, ⊖⇘K⇙ k]) ` carrier K)›*) using inj_onD[OF inv_k_inj] (*‹⟦⊖⇘K⇙ ?x = ⊖⇘K⇙ ?y; ?x ∈ carrier K; ?y ∈ carrier K⟧ ⟹ ?x = ?y›*) apply (intro card_image[symmetric] (*‹inj_on ?f ?A ⟹ card ?A = card (?f ` ?A)›*) inj_onI (*‹(⋀x y. ⟦x ∈ ?A; y ∈ ?A; ?f x = ?f y⟧ ⟹ x = y) ⟹ inj_on ?f ?A›*)) (*goal: ‹card (carrier K) = card ((λk. [𝟭⇘K⇙, ⊖⇘K⇙ k]) ` carrier K)›*) by simp also (*calculation: ‹sum' (λd. pmult⇘K⇙ d (gauss_poly K (order R ^ degree f)) * degree d) {d. m_i_p K d} = card ((λk. [𝟭⇘K⇙, ⊖⇘K⇙ k]) ` carrier K)›*) have "... = card {d. ?mip d ∧ degree d = 1}" using f.degree_one_monic_poly (*‹(m_i_p K ?f ∧ degree ?f = 1) = (∃x∈carrier K. ?f = [𝟭⇘K⇙, ⊖⇘K⇙ x])›*) apply (intro arg_cong[where f="card"] (*‹?x = ?y ⟹ card ?x = card ?y›*)) (*goal: ‹card ((λk. [𝟭⇘K⇙, ⊖⇘K⇙ k]) ` carrier K) = card {d. m_i_p K d ∧ degree d = 1}›*) by (simp add:set_eq_iff (*‹(?A = ?B) = (∀x. (x ∈ ?A) = (x ∈ ?B))›*) image_iff (*‹(?z ∈ ?f ` ?A) = (∃x∈?A. ?z = ?f x)›*)) also (*calculation: ‹sum' (λd. pmult⇘K⇙ d (gauss_poly K (order R ^ degree f)) * degree d) {d. m_i_p K d} = card {d. m_i_p K d ∧ degree d = 1}›*) have "... = sum (λd. 1) {d. ?mip d ∧ degree d = 1}" by simp also (*calculation: ‹sum' (λd. pmult⇘K⇙ d (gauss_poly K (order R ^ degree f)) * degree d) {d. m_i_p K d} = (∑d | m_i_p K d ∧ degree d = 1. 1)›*) have "... = sum' (λd. 1) {d. ?mip d ∧ degree d = 1}" apply (intro sum.eq_sum[symmetric] (*‹finite ?I ⟹ sum ?p ?I = sum' ?p ?I›*) finite_subset[OF _ fp.finite_poly(1)[OF d]] (*‹?A ⊆ {f ∈ carrier fp.P. degree f = ?n1} ⟹ finite ?A›*)) (*goal: ‹(∑d | m_i_p K d ∧ degree d = 1. 1) = sum' (λd. 1) {d. m_i_p K d ∧ degree d = 1}›*) by (auto simp:monic_irreducible_poly_def (*‹m_i_p ?R ?f = (monic_poly ?R ?f ∧ pirreducible⇘?R⇙ (carrier ?R) ?f)›*) monic_poly_def (*‹monic_poly ?R ?f = (?f ≠ [] ∧ lead_coeff ?f = 𝟭⇘?R⇙ ∧ ?f ∈ carrier (poly_ring ?R))›*)) also (*calculation: ‹sum' (λd. pmult⇘K⇙ d (gauss_poly K (order R ^ degree f)) * degree d) {d. m_i_p K d} = sum' (λd. 1) {d. m_i_p K d ∧ degree d = 1}›*) have "... = sum' (λd. of_bool (degree d = 1)) {d. ?mip d}" apply (intro sum.mono_neutral_cong_left' (*‹⟦(?S::?'b set) ⊆ (?T::?'b set); ⋀i::?'b. i ∈ ?T - ?S ⟹ (?h::?'b ⇒ ?'a) i = (0::?'a); ⋀x::?'b. x ∈ ?S ⟹ (?g::?'b ⇒ ?'a) x = ?h x⟧ ⟹ sum' ?g ?S = sum' ?h ?T›*) subsetI (*‹(⋀x::?'a. x ∈ (?A::?'a set) ⟹ x ∈ (?B::?'a set)) ⟹ ?A ⊆ ?B›*)) (*goals: 1. ‹⋀x. x ∈ {d. m_i_p K d ∧ degree d = 1} ⟹ x ∈ {d. m_i_p K d}› 2. ‹⋀i. i ∈ {d. m_i_p K d} - {d. m_i_p K d ∧ degree d = 1} ⟹ of_bool (degree i = 1) = 0› 3. ‹⋀x. x ∈ {d. m_i_p K d ∧ degree d = 1} ⟹ 1 = of_bool (degree x = 1)› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*discuss goal 3*) apply simp (*proven 3 subgoals*) . also (*calculation: ‹sum' (λd. pmult⇘K⇙ d (gauss_poly K (order R ^ degree f)) * degree d) {d. m_i_p K d} = sum' (λd. of_bool (degree d = 1)) {d. m_i_p K d}›*) have "... ≤ sum' (λd. of_bool (degree d = 1)) {d. ?mip d}" by simp finally (*calculation: ‹sum' (λd. pmult⇘K⇙ d (gauss_poly K (order R ^ degree f)) * degree d) {d. m_i_p K d} ≤ sum' (λd. of_bool (degree d = 1)) {d. m_i_p K d}›*) have "sum' (λd. pmult⇘K⇙ d ?g1 * degree d) {d. ?mip d} ≤ sum' (λd. of_bool (degree d = 1)) {d. ?mip d}" by simp moreover have "pmult⇘K⇙ d ?g1 * degree d ≥ of_bool (degree d = 1)" if v: "monic_irreducible_poly K d" for d proof (cases "degree d = 1") (*goals: 1. ‹degree (d::'a list set list) = (1::nat) ⟹ of_bool (degree d = (1::nat)) ≤ pmult⇘K::'a list set ring⇙ d (gauss_poly K (order R ^ degree (f::'a list))) * degree d› 2. ‹degree (d::'a list set list) ≠ (1::nat) ⟹ of_bool (degree d = (1::nat)) ≤ pmult⇘K::'a list set ring⇙ d (gauss_poly K (order R ^ degree (f::'a list))) * degree d›*) case True (*‹degree d = 1›*) then obtain x where "x ∈ carrier K" "d = [𝟭⇘K⇙, ⊖⇘K⇙ x]" (*goal: ‹(⋀x. ⟦x ∈ carrier K; d = [𝟭⇘K⇙, ⊖⇘K⇙ x]⟧ ⟹ thesis) ⟹ thesis›*) using f.degree_one_monic_poly (*‹(m_i_p K ?f ∧ degree ?f = 1) = (∃x∈carrier K. ?f = [𝟭⇘K⇙, ⊖⇘K⇙ x])›*) v (*‹m_i_p K d›*) by auto hence "pmult⇘K⇙ d ?g1 ≥ 1" using roots_g1 (*‹⟦degree ?d = 1; m_i_p K ?d⟧ ⟹ 1 ≤ pmult⇘K⇙ ?d (gauss_poly K (order R ^ degree f))›*) v (*‹m_i_p K d›*) by simp then show "?thesis" (*goal: ‹of_bool (degree d = 1) ≤ pmult⇘K⇙ d (gauss_poly K (order R ^ degree f)) * degree d›*) using True (*‹degree d = 1›*) by simp next (*goal: ‹degree d ≠ 1 ⟹ of_bool (degree d = 1) ≤ pmult⇘K⇙ d (gauss_poly K (order R ^ degree f)) * degree d›*) case False (*‹degree d ≠ 1›*) then show "?thesis" (*goal: ‹of_bool (degree d = 1) ≤ pmult⇘K⇙ d (gauss_poly K (order R ^ degree f)) * degree d›*) by simp qed moreover have "finite {d. ?mip d ∧ pmult⇘K⇙ d ?g1 * degree d > 0}" apply (intro finite_subset[OF _ f.factor_monic_poly_fin[OF g1_monic]] (*‹?A ⊆ {d. m_i_p K d ∧ 0 < pmult⇘K⇙ d (gauss_poly K (order R ^ degree f))} ⟹ finite ?A›*) subsetI (*‹(⋀x. x ∈ ?A ⟹ x ∈ ?B) ⟹ ?A ⊆ ?B›*)) (*goal: ‹finite {d. m_i_p K d ∧ 0 < pmult⇘K⇙ d (gauss_poly K (order R ^ degree f)) * degree d}›*) by simp ultimately have v2: "∀d ∈ {d. ?mip d}. pmult⇘K⇙ d ?g1 * degree d = of_bool (degree d = 1)" apply (intro sum'_eq_iff (*‹⟦finite {i::?'a::type ∈ ?A::?'a::type set. (?f::?'a::type ⇒ nat) i ≠ (0::nat)}; ⋀i::?'a::type. i ∈ ?A ⟹ (?g::?'a::type ⇒ nat) i ≤ ?f i; sum' ?f ?A ≤ sum' ?g ?A⟧ ⟹ ∀i::?'a::type∈?A. ?f i = ?g i›*)) (*goals: 1. ‹⟦sum' (λd::'a list set list. pmult⇘K::'a list set ring⇙ d (gauss_poly K (order R ^ degree (f::'a list))) * degree d) {d::'a list set list. m_i_p K d} ≤ sum' (λd::'a list set list. of_bool (degree d = (1::nat))) {d::'a list set list. m_i_p K d}; ⋀d::'a list set list. m_i_p K d ⟹ of_bool (degree d = (1::nat)) ≤ pmult⇘K⇙ d (gauss_poly K (order R ^ degree f)) * degree d; finite {d::'a list set list. m_i_p K d ∧ (0::nat) < pmult⇘K⇙ d (gauss_poly K (order R ^ degree f)) * degree d}⟧ ⟹ finite {d::'a list set list ∈ {d::'a list set list. m_i_p K d}. pmult⇘K⇙ d (gauss_poly K (order R ^ degree f)) * degree d ≠ (0::nat)}› 2. ‹⋀d::'a list set list. ⟦sum' (λd::'a list set list. pmult⇘K::'a list set ring⇙ d (gauss_poly K (order R ^ degree (f::'a list))) * degree d) {d::'a list set list. m_i_p K d} ≤ sum' (λd::'a list set list. of_bool (degree d = (1::nat))) {d::'a list set list. m_i_p K d}; ⋀d::'a list set list. m_i_p K d ⟹ of_bool (degree d = (1::nat)) ≤ pmult⇘K⇙ d (gauss_poly K (order R ^ degree f)) * degree d; finite {d::'a list set list. m_i_p K d ∧ (0::nat) < pmult⇘K⇙ d (gauss_poly K (order R ^ degree f)) * degree d}; d ∈ {d::'a list set list. m_i_p K d}⟧ ⟹ of_bool (degree d = (1::nat)) ≤ pmult⇘K⇙ d (gauss_poly K (order R ^ degree f)) * degree d› 3. ‹⟦sum' (λd::'a list set list. pmult⇘K::'a list set ring⇙ d (gauss_poly K (order R ^ degree (f::'a list))) * degree d) {d::'a list set list. m_i_p K d} ≤ sum' (λd::'a list set list. of_bool (degree d = (1::nat))) {d::'a list set list. m_i_p K d}; ⋀d::'a list set list. m_i_p K d ⟹ of_bool (degree d = (1::nat)) ≤ pmult⇘K⇙ d (gauss_poly K (order R ^ degree f)) * degree d; finite {d::'a list set list. m_i_p K d ∧ (0::nat) < pmult⇘K⇙ d (gauss_poly K (order R ^ degree f)) * degree d}⟧ ⟹ sum' (λi::'a list set list. pmult⇘K⇙ i (gauss_poly K (order R ^ degree f)) * degree i) {d::'a list set list. m_i_p K d} ≤ sum' (λi::'a list set list. of_bool (degree i = (1::nat))) {d::'a list set list. m_i_p K d}› discuss goal 1*) apply (simp add:not_le (*‹(¬ ?x ≤ ?y) = (?y < ?x)›*)) (*discuss goal 2*) apply (simp add:not_le (*‹(¬ ?x ≤ ?y) = (?y < ?x)›*)) (*discuss goal 3*) apply (simp add:not_le (*‹(¬ ?x ≤ ?y) = (?y < ?x)›*)) (*proven 3 subgoals*) . have "pmult⇘K⇙ d ?g1 ≤ pmult⇘K⇙ d ?g2" if "?mip d" for d proof (cases "degree d = 1") (*goals: 1. ‹degree d = 1 ⟹ pmult⇘K⇙ d (gauss_poly K (order R ^ degree f)) ≤ pmult⇘K⇙ d (gauss_poly K (order R ^ n))› 2. ‹degree d ≠ 1 ⟹ pmult⇘K⇙ d (gauss_poly K (order R ^ degree f)) ≤ pmult⇘K⇙ d (gauss_poly K (order R ^ n))›*) case True (*‹degree d = 1›*) hence "pmult⇘K⇙ d ?g1 = 1" using v2 (*‹∀d∈{d. m_i_p K d}. pmult⇘K⇙ d (gauss_poly K (order R ^ degree f)) * degree d = of_bool (degree d = 1)›*) that (*‹m_i_p K d›*) by auto also (*calculation: ‹pmult⇘K⇙ d (gauss_poly K (order R ^ degree f)) = 1›*) have "... ≤ pmult⇘K⇙ d ?g2" by (intro roots_g2 (*‹⟦degree ?d = 1; m_i_p K ?d⟧ ⟹ 1 ≤ pmult⇘K⇙ ?d (gauss_poly K (order R ^ n))›*) True (*‹degree d = 1›*) that (*‹m_i_p K d›*)) finally (*calculation: ‹pmult⇘K⇙ d (gauss_poly K (order R ^ degree f)) ≤ pmult⇘K⇙ d (gauss_poly K (order R ^ n))›*) show "?thesis" (*goal: ‹pmult⇘K⇙ d (gauss_poly K (order R ^ degree f)) ≤ pmult⇘K⇙ d (gauss_poly K (order R ^ n))›*) by simp next (*goal: ‹degree d ≠ 1 ⟹ pmult⇘K⇙ d (gauss_poly K (order R ^ degree f)) ≤ pmult⇘K⇙ d (gauss_poly K (order R ^ n))›*) case False (*‹degree (d::'a list set list) ≠ (1::nat)›*) hence "degree d > 1" using f.monic_poly_min_degree[OF that] (*‹1 ≤ degree d›*) by simp hence "pmult⇘K⇙ d ?g1 = 0" using v2 (*‹∀d∈{d. m_i_p K d}. pmult⇘K⇙ d (gauss_poly K (order R ^ degree f)) * degree d = of_bool (degree d = 1)›*) that (*‹m_i_p K d›*) by force then show "?thesis" (*goal: ‹pmult⇘K::'a list set ring⇙ (d::'a::type list set list) (gauss_poly K (order R ^ degree (f::'a::type list))) ≤ pmult⇘K⇙ d (gauss_poly K (order R ^ (n::nat)))›*) by simp qed hence "?g1 pdivides⇘K⇙ ?g2" using o1 (*‹1 < order R ^ degree f›*) o2 (*‹(1::nat) < order R ^ (n::nat)›*) f.divides_monic_poly (*‹⟦monic_poly K ?f; monic_poly K ?g; ⋀d. m_i_p K d ⟹ pmult⇘K⇙ d ?f ≤ pmult⇘K⇙ d ?g⟧ ⟹ ?f pdivides⇘K⇙ ?g›*) f.gauss_poly_monic (*‹1 < ?n ⟹ monic_poly K (gauss_poly K ?n)›*) by simp thus "degree f dvd n" apply (subst (asm) f.gauss_poly_div_gauss_poly_iff [OF assms(1) f_deg finite_field_min_order] (*‹gauss_poly K (order R ^ degree f) pdivides⇘K⇙ gauss_poly K (order R ^ n) = (degree f dvd n)›*)) (*goal: ‹degree f dvd n›*) by simp next (*goal: ‹degree f dvd n ⟹ f pdivides gauss_poly R (order R ^ n)›*) have d: "φ X⇘R⇙ ∈ carrier K" by (intro h.hom_closed (*‹?x ∈ carrier P ⟹ φ ?x ∈ carrier K›*) var_closed (*‹X ∈ carrier P› ‹polynomial (carrier R) X›*)) have "φ (gauss_poly R (order R^degree f)) = (φ X⇘R⇙) [^]⇘K⇙ (order R^degree f) ⊖⇘K⇙ (φ X⇘R⇙)" unfolding gauss_poly_def a_minus_def (*goal: ‹φ (X [^]⇘P⇙ order R ^ degree f ⊕⇘P⇙ ⊖⇘P⇙ X) = φ X [^]⇘K⇙ order R ^ degree f ⊕⇘K⇙ ⊖⇘K⇙ φ X›*) using var_closed (*‹X ∈ carrier P› ‹polynomial (carrier R) X›*) by (simp add: h.hom_nat_pow (*‹?x ∈ carrier P ⟹ φ (?x [^]⇘P⇙ ?n) = φ ?x [^]⇘K⇙ ?n›*)) also (*calculation: ‹(φ::'a list ⇒ 'a list set) (gauss_poly R (order R ^ degree (f::'a list))) = φ X [^]⇘K⇙ order R ^ degree f ⊖⇘K::'a list set ring⇙ φ X›*) have "... = 𝟬⇘K⇙" using c (*‹?x ∈ carrier K ⟹ ?x [^]⇘K⇙ order R ^ degree f = ?x›*) d (*‹(φ::'a list ⇒ 'a list set) X ∈ carrier (K::'a list set ring)›*) by simp finally (*calculation: ‹φ (gauss_poly R (order R ^ degree f)) = 𝟬⇘K⇙›*) have "φ (gauss_poly R (order R^degree f)) = 𝟬⇘K⇙" by simp hence "f pdivides⇘R⇙ gauss_poly R (order R^degree f)" unfolding K_def "φ_def" (*goal: ‹f pdivides gauss_poly R (order R ^ degree f)›*) using f_carr (*‹f ∈ carrier P›*) gauss_poly_carr (*‹gauss_poly R ?n ∈ carrier P›*) apply (subst (asm) rupture_eq_0_iff (*‹⟦?p ∈ carrier P; ?q ∈ carrier P⟧ ⟹ (rupture_surj (carrier R) ?p ?q = 𝟬⇘Rupt (carrier R) ?p⇙) = ?p pdivides ?q›*)) (*goals: 1. ‹⟦(f::'a::type list) ∈ carrier P; ⋀n::nat. gauss_poly R n ∈ carrier P⟧ ⟹ f ∈ carrier P› 2. ‹⟦(f::'a::type list) ∈ carrier P; ⋀n::nat. gauss_poly R n ∈ carrier P⟧ ⟹ gauss_poly R (order R ^ degree f) ∈ carrier P› 3. ‹⟦(f::'a::type list) pdivides gauss_poly R (order R ^ degree f); f ∈ carrier P; ⋀n::nat. gauss_poly R n ∈ carrier P⟧ ⟹ f pdivides gauss_poly R (order R ^ degree f)› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*discuss goal 3*) apply simp (*proven 3 subgoals*) . moreover assume "degree f dvd n" (*‹degree (f::'a list) dvd (n::nat)›*) hence "gauss_poly R (order R^degree f) pdivides (gauss_poly R (order R^n))" using gauss_poly_div_gauss_poly_iff[OF assms ( 1 ) f_deg finite_field_min_order] (*‹gauss_poly R (order R ^ degree f) pdivides gauss_poly R (order R ^ n) = (degree f dvd n)›*) by simp ultimately show "f pdivides⇘R⇙ gauss_poly R (order R^n)" using f_carr (*‹(f::'a list) ∈ carrier P›*) a (*‹order K = order R ^ degree f›*) p.divides_trans (*‹⟦(?a::'a list) divides⇘P⇙ (?b::'a list); ?b divides⇘P⇙ (?c::'a list); ?a ∈ carrier P⟧ ⟹ ?a divides⇘P⇙ ?c›*) unfolding pdivides_def (*goal: ‹(f::'a::type list) divides⇘P⇙ gauss_poly R (order R ^ (n::nat))›*) by blast qed qed lemma gauss_poly_splitted: "splitted (gauss_poly R (order R))" proof (-) (*goal: ‹splitted (gauss_poly R (order R))›*) have "degree q ≤ 1" if "q ∈ carrier P" "pirreducible (carrier R) q" "q pdivides gauss_poly R (order R)" for q proof (-) (*goal: ‹degree (q::'a::type list) ≤ (1::nat)›*) have q_carr: "q ∈ carrier (mult_of P)" using that (*‹(q::'a::type list) ∈ carrier P› ‹pirreducible (carrier R) q› ‹q pdivides gauss_poly R (order R)›*) unfolding ring_irreducible_def (*goal: ‹q ∈ carrier (Ring_Divisibility.mult_of P)›*) by simp moreover have "irreducible (mult_of P) q" using that (*‹q ∈ carrier P› ‹pirreducible (carrier R) q› ‹q pdivides gauss_poly R (order R)›*) unfolding ring_irreducible_def (*goal: ‹irreducible (Ring_Divisibility.mult_of P) q›*) apply (intro p.irreducible_imp_irreducible_mult (*‹⟦?a ∈ carrier P; irreducible P ?a⟧ ⟹ irreducible (Ring_Divisibility.mult_of P) ?a›*) that (*‹q ∈ carrier P› ‹pirreducible (carrier R) q› ‹q pdivides gauss_poly R (order R)›*)) (*goal: ‹irreducible (Ring_Divisibility.mult_of P) (q::'a::type list)›*) by simp ultimately obtain p where p_def: "monic_irreducible_poly R p" "q ∼⇘mult_of P⇙ p" (*goal: ‹(⋀p. ⟦m_i_p R p; q ∼⇘Ring_Divisibility.mult_of P⇙ p⟧ ⟹ thesis) ⟹ thesis›*) using monic_poly_span (*‹⟦(?x::'a::type list) ∈ carrier (Ring_Divisibility.mult_of P); irreducible (Ring_Divisibility.mult_of P) ?x⟧ ⟹ ∃y::'a::type list. m_i_p R y ∧ ?x ∼⇘Ring_Divisibility.mult_of P⇙ y›*) by auto have p_carr: "p ∈ carrier P" "p ≠ []" using p_def(1) (*‹m_i_p R p›*) unfolding monic_irreducible_poly_def monic_poly_def (*goals: 1. ‹p ∈ carrier P› 2. ‹p ≠ []›*) apply - (*goals: 1. ‹(p ≠ [] ∧ lead_coeff p = 𝟭 ∧ p ∈ carrier P) ∧ pirreducible (carrier R) p ⟹ p ∈ carrier P› 2. ‹(p ≠ [] ∧ lead_coeff p = 𝟭 ∧ p ∈ carrier P) ∧ pirreducible (carrier R) p ⟹ p ≠ []› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . moreover have "p divides⇘mult_of P⇙ q" using associatedE[OF p_def ( 2 )] (*‹(⟦(q::'a list) divides⇘Ring_Divisibility.mult_of P⇙ (p::'a list); p divides⇘Ring_Divisibility.mult_of P⇙ q⟧ ⟹ ?P::bool) ⟹ ?P›*) by auto hence "p pdivides q" unfolding pdivides_def (*goal: ‹p divides⇘P⇙ q›*) using divides_mult_imp_divides (*‹?a divides⇘Ring_Divisibility.mult_of ?R⇙ ?b ⟹ ?a divides⇘?R⇙ ?b›*) by simp moreover have "q pdivides gauss_poly R (order R^1)" using that (*‹q ∈ carrier P› ‹pirreducible (carrier R) (q::'a list)› ‹q pdivides gauss_poly R (order R)›*) by simp ultimately have "p pdivides gauss_poly R (order R^1)" unfolding pdivides_def (*goal: ‹p divides⇘P⇙ gauss_poly R (order R ^ 1)›*) using p.divides_trans (*‹⟦?a divides⇘P⇙ ?b; ?b divides⇘P⇙ ?c; ?a ∈ carrier P⟧ ⟹ ?a divides⇘P⇙ ?c›*) by blast hence "degree p dvd 1" using div_gauss_poly_iff[where n = "1"] (*‹⟦0 < 1; m_i_p R ?f⟧ ⟹ ?f pdivides gauss_poly R (order R ^ 1) = is_unit (degree ?f)›*) p_def(1) (*‹m_i_p R p›*) by simp hence "degree p = 1" by simp moreover have "q divides⇘mult_of P⇙ p" using associatedE[OF p_def ( 2 )] (*‹(⟦q divides⇘Ring_Divisibility.mult_of P⇙ p; p divides⇘Ring_Divisibility.mult_of P⇙ q⟧ ⟹ ?P) ⟹ ?P›*) by auto hence "q pdivides p" unfolding pdivides_def (*goal: ‹q divides⇘P⇙ p›*) using divides_mult_imp_divides (*‹(?a::?'a) divides⇘Ring_Divisibility.mult_of (?R::(?'a, ?'b) ring_scheme)⇙ (?b::?'a) ⟹ ?a divides⇘?R⇙ ?b›*) by simp hence "degree q ≤ degree p" using that (*‹q ∈ carrier P› ‹pirreducible (carrier R) q› ‹q pdivides gauss_poly R (order R)›*) p_carr (*‹p ∈ carrier P› ‹p ≠ []›*) apply (intro pdivides_imp_degree_le (*‹⟦?p ∈ carrier P; ?q ∈ carrier P; ?q ≠ []; ?p pdivides ?q⟧ ⟹ degree ?p ≤ degree ?q›*)) (*goals: 1. ‹⟦q pdivides p; q ∈ carrier P; pirreducible (carrier R) q; q pdivides gauss_poly R (order R); p ∈ carrier P; p ≠ []⟧ ⟹ q ∈ carrier P› 2. ‹⟦q pdivides p; q ∈ carrier P; pirreducible (carrier R) q; q pdivides gauss_poly R (order R); p ∈ carrier P; p ≠ []⟧ ⟹ p ∈ carrier P› 3. ‹⟦q pdivides p; q ∈ carrier P; pirreducible (carrier R) q; q pdivides gauss_poly R (order R); p ∈ carrier P; p ≠ []⟧ ⟹ p ≠ []› 4. ‹⟦q pdivides p; q ∈ carrier P; pirreducible (carrier R) q; q pdivides gauss_poly R (order R); p ∈ carrier P; p ≠ []⟧ ⟹ q pdivides 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*) . ultimately show "?thesis" (*goal: ‹degree (q::'a::type list) ≤ (1::nat)›*) by simp qed thus "?thesis" (*goal: ‹splitted (gauss_poly R (order R))›*) using gauss_poly_carr (*‹gauss_poly R (?n::nat) ∈ carrier P›*) apply (intro trivial_factors_imp_splitted (*‹⟦?p ∈ carrier P; ⋀q. ⟦q ∈ carrier P; pirreducible (carrier R) q; q pdivides ?p⟧ ⟹ degree q ≤ 1⟧ ⟹ splitted ?p›*)) (*goals: 1. ‹⟦⋀q. ⟦q ∈ carrier P; pirreducible (carrier R) q; q pdivides gauss_poly R (order R)⟧ ⟹ degree q ≤ 1; ⋀n. gauss_poly R n ∈ carrier P⟧ ⟹ gauss_poly R (order R) ∈ carrier P› 2. ‹⋀q. ⟦⋀q. ⟦q ∈ carrier P; pirreducible (carrier R) q; q pdivides gauss_poly R (order R)⟧ ⟹ degree q ≤ 1; ⋀n. gauss_poly R n ∈ carrier P; q ∈ carrier P; pirreducible (carrier R) q; q pdivides gauss_poly R (order R)⟧ ⟹ degree q ≤ 1› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . qed text ‹The following lemma, for the case when @{term "R"} is a simple prime field, can be found in Ireland and Rosen~\<^cite>‹‹\textsection 7.1, Theorem 2› in "ireland1982"›. Here the result is verified even for arbitrary finite fields.› lemma multiplicity_of_factor_of_gauss_poly: assumes "n > 0" assumes "monic_irreducible_poly R f" shows "pmult⇘R⇙ f (gauss_poly R (order R^n)) = of_bool (degree f dvd n)" proof (cases "degree f dvd n") (*goals: 1. ‹degree f dvd n ⟹ pmult f (gauss_poly R (order R ^ n)) = of_bool (degree f dvd n)› 2. ‹¬ degree f dvd n ⟹ pmult f (gauss_poly R (order R ^ n)) = of_bool (degree f dvd n)›*) case True (*‹degree (f::'a list) dvd (n::nat)›*) let ?g = "gauss_poly R (order R^n)" have f_carr: "f ∈ carrier P" "f ≠ []" using assms(2) (*‹m_i_p R (f::'a list)›*) unfolding monic_irreducible_poly_def monic_poly_def (*goals: 1. ‹f ∈ carrier P› 2. ‹f ≠ []›*) apply - (*goals: 1. ‹(f ≠ [] ∧ lead_coeff f = 𝟭 ∧ f ∈ carrier P) ∧ pirreducible (carrier R) f ⟹ f ∈ carrier P› 2. ‹(f ≠ [] ∧ lead_coeff f = 𝟭 ∧ f ∈ carrier P) ∧ pirreducible (carrier R) f ⟹ f ≠ []› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . have o2: "order R^n > 1" using finite_field_min_order (*‹1 < order R›*) assms(1) (*‹0 < n›*) one_less_power (*‹⟦1 < ?a; 0 < ?n⟧ ⟹ 1 < ?a ^ ?n›*) by blast hence o21: "order R^n > 0" by linarith obtain d :: nat where order_dim: "order R = char R ^ d" "d > 0" (*goal: ‹(⋀d. ⟦order R = char R ^ d; 0 < d⟧ ⟹ thesis) ⟹ thesis›*) using finite_field_order (*‹∃n. order R = char R ^ n ∧ 0 < n›*) by blast have "d * n > 0" using order_dim (*‹order R = char R ^ d› ‹(0::nat) < (d::nat)›*) assms (*‹0 < n› ‹m_i_p R f›*) by simp hence char_dvd_order: "int (char R) dvd int (order R ^ n)" unfolding order_dim (*goal: ‹int (char R) dvd int ((char R ^ d) ^ n)›*) using finite_carr_imp_char_ge_0[OF finite_carrier] (*‹0 < char R›*) by (simp add:power_mult[symmetric] (*‹(?a ^ ?m) ^ ?n = ?a ^ (?m * ?n)›*)) interpret h: ring_hom_ring R P poly_of_const using canonical_embedding_ring_hom (*‹ring_hom_ring (R⦇carrier := carrier R⦈) P poly_of_const›*) by simp have "f pdivides⇘R⇙ ?g" using True (*‹degree f dvd n›*) div_gauss_poly_iff[OF assms] (*‹f pdivides gauss_poly R (order R ^ n) = (degree f dvd n)›*) by simp hence "pmult⇘R⇙ f ?g ≥ 1" using multiplicity_ge_1_iff_pdivides[OF assms ( 2 )] (*‹?f ∈ carrier P - {𝟬⇘P⇙} ⟹ (1 ≤ pmult f ?f) = f pdivides ?f›*) using gauss_poly_carr (*‹gauss_poly R ?n ∈ carrier P›*) gauss_poly_not_zero[OF o2] (*‹gauss_poly R (order R ^ n) ≠ 𝟬⇘P⇙›*) by auto moreover have "pmult⇘R⇙ f ?g < 2" proof (rule ccontr (*‹(¬ ?P ⟹ False) ⟹ ?P›*)) (*goal: ‹¬ pmult f (gauss_poly R (order R ^ n)) < 2 ⟹ False›*) assume "¬ pmult⇘R⇙ f ?g < 2" (*‹¬ pmult (f::'a list) (gauss_poly R (order R ^ (n::nat))) < (2::nat)›*) hence "pmult⇘R⇙ f ?g ≥ 2" by simp hence "(f [^]⇘P⇙ (2::nat)) pdivides⇘R⇙ ?g" using gauss_poly_carr (*‹gauss_poly R ?n ∈ carrier P›*) gauss_poly_not_zero[OF o2] (*‹gauss_poly R (order R ^ (n::nat)) ≠ 𝟬⇘P⇙›*) apply (subst (asm) multiplicity_ge_iff[OF assms(2)] (*‹?f ∈ carrier P - {𝟬⇘P⇙} ⟹ (?k ≤ pmult f ?f) = f [^]⇘P⇙ ?k pdivides ?f›*)) (*goals: 1. ‹⟦⋀n. gauss_poly R n ∈ carrier P; gauss_poly R (order R ^ n) ≠ 𝟬⇘P⇙⟧ ⟹ gauss_poly R (order R ^ n) ∈ carrier P - {𝟬⇘P⇙}› 2. ‹⟦f [^]⇘P⇙ 2 pdivides gauss_poly R (order R ^ n); ⋀n. gauss_poly R n ∈ carrier P; gauss_poly R (order R ^ n) ≠ 𝟬⇘P⇙⟧ ⟹ f [^]⇘P⇙ 2 pdivides gauss_poly R (order R ^ n)› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) . hence "(f [^]⇘P⇙ (2::nat)) divides⇘mult_of P⇙ ?g" unfolding pdivides_def (*goal: ‹f [^]⇘P⇙ 2 divides⇘Ring_Divisibility.mult_of P⇙ gauss_poly R (order R ^ n)›*) using f_carr (*‹f ∈ carrier P› ‹(f::'a list) ≠ []›*) gauss_poly_not_zero (*‹1 < ?n ⟹ gauss_poly R ?n ≠ 𝟬⇘P⇙›*) o2 (*‹1 < order R ^ n›*) gauss_poly_carr (*‹gauss_poly R ?n ∈ carrier P›*) apply (intro p.divides_imp_divides_mult (*‹⟦?a ∈ carrier P; ?b ∈ carrier P - {𝟬⇘P⇙}; ?a divides⇘P⇙ ?b⟧ ⟹ ?a divides⇘Ring_Divisibility.mult_of P⇙ ?b›*)) (*goals: 1. ‹⟦(f::'a list) [^]⇘P⇙ (2::nat) divides⇘P⇙ gauss_poly R (order R ^ (n::nat)); f ∈ carrier P; f ≠ []; ⋀n::nat. (1::nat) < n ⟹ gauss_poly R n ≠ 𝟬⇘P⇙; (1::nat) < order R ^ n; ⋀n::nat. gauss_poly R n ∈ carrier P⟧ ⟹ f [^]⇘P⇙ (2::nat) ∈ carrier P› 2. ‹⟦(f::'a list) [^]⇘P⇙ (2::nat) divides⇘P⇙ gauss_poly R (order R ^ (n::nat)); f ∈ carrier P; f ≠ []; ⋀n::nat. (1::nat) < n ⟹ gauss_poly R n ≠ 𝟬⇘P⇙; (1::nat) < order R ^ n; ⋀n::nat. gauss_poly R n ∈ carrier P⟧ ⟹ gauss_poly R (order R ^ n) ∈ carrier P - {𝟬⇘P⇙}› 3. ‹⟦(f::'a list) [^]⇘P⇙ (2::nat) divides⇘P⇙ gauss_poly R (order R ^ (n::nat)); f ∈ carrier P; f ≠ []; ⋀n::nat. (1::nat) < n ⟹ gauss_poly R n ≠ 𝟬⇘P⇙; (1::nat) < order R ^ n; ⋀n::nat. gauss_poly R n ∈ carrier P⟧ ⟹ f [^]⇘P⇙ (2::nat) divides⇘P⇙ gauss_poly R (order R ^ n)› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*discuss goal 3*) apply simp (*proven 3 subgoals*) . then obtain h where h_def: "h ∈ carrier (mult_of P)" "?g = f [^]⇘P⇙ (2::nat) ⊗⇘P⇙ h" (*goal: ‹(⋀h. ⟦h ∈ carrier (Ring_Divisibility.mult_of P); gauss_poly R (order R ^ n) = f [^]⇘P⇙ 2 ⊗⇘P⇙ h⟧ ⟹ thesis) ⟹ thesis›*) using dividesD (*‹?a divides⇘?G⇙ ?b ⟹ ∃c∈carrier ?G. ?b = ?a ⊗⇘?G⇙ c›*) by auto have "⊖⇘P⇙ 𝟭⇘P⇙ = int_embed P (order R ^ n) ⊗⇘P⇙ (X⇘R⇙ [^]⇘P⇙ (order R ^ n-1)) ⊖⇘P⇙ 𝟭⇘P⇙" using var_closed (*‹X ∈ carrier P› ‹polynomial (carrier R) X›*) apply (subst int_embed_consistent_with_poly_of_const (*‹int_embed P ?m = poly_of_const (int_embed R ?m)›*)) (*goal: ‹⊖⇘P⇙ 𝟭⇘P⇙ = int_embed P (int (order R ^ n)) ⊗⇘P⇙ X [^]⇘P⇙ (order R ^ n - 1) ⊖⇘P⇙ 𝟭⇘P⇙›*) apply (subst iffD2[OF embed_char_eq_0_iff char_dvd_order] (*‹int_embed R (int (order R ^ n)) = 𝟬›*)) (*goal: ‹⟦X ∈ carrier P; polynomial (carrier R) X⟧ ⟹ ⊖⇘P⇙ 𝟭⇘P⇙ = poly_of_const (int_embed R (int (order R ^ n))) ⊗⇘P⇙ X [^]⇘P⇙ (order R ^ n - 1) ⊖⇘P⇙ 𝟭⇘P⇙›*) by (simp add:a_minus_def (*‹(?x::?'a) ⊖⇘?R::(?'a, ?'m) ring_scheme⇙ (?y::?'a) = ?x ⊕⇘?R⇙ ⊖⇘?R⇙ ?y›*)) also (*calculation: ‹⊖⇘P⇙ 𝟭⇘P⇙ = int_embed P (int (order R ^ n)) ⊗⇘P⇙ X [^]⇘P⇙ (order R ^ n - 1) ⊖⇘P⇙ 𝟭⇘P⇙›*) have "... = pderiv⇘R⇙ (X⇘R⇙ [^]⇘P⇙ order R ^ n) ⊖⇘P⇙ pderiv⇘R⇙ X⇘R⇙" using pderiv_var (*‹pderiv X = 𝟭⇘?K [X]⇙›*) apply (subst pderiv_var_pow[OF o21] (*‹pderiv (X [^]⇘P⇙ order R ^ n) = int_embed P (int (order R ^ n)) ⊗⇘P⇙ X [^]⇘P⇙ (order R ^ n - 1)›*)) (*goal: ‹int_embed P (int (order R ^ (n::nat))) ⊗⇘P⇙ X [^]⇘P⇙ (order R ^ n - (1::nat)) ⊖⇘P⇙ 𝟭⇘P⇙ = pderiv (X [^]⇘P⇙ order R ^ n) ⊖⇘P⇙ pderiv X›*) by simp also (*calculation: ‹⊖⇘P⇙ 𝟭⇘P⇙ = pderiv (X [^]⇘P⇙ order R ^ n) ⊖⇘P⇙ pderiv X›*) have "... = pderiv⇘R⇙ ?g" unfolding gauss_poly_def a_minus_def (*goal: ‹pderiv (X [^]⇘P⇙ order R ^ n) ⊕⇘P⇙ ⊖⇘P⇙ pderiv X = pderiv (X [^]⇘P⇙ order R ^ n ⊕⇘P⇙ ⊖⇘P⇙ X)›*) using var_closed (*‹X ∈ carrier P› ‹polynomial (carrier R) X›*) apply (subst pderiv_add (*‹⟦(?f::'a::type list) ∈ carrier P; (?g::'a::type list) ∈ carrier P⟧ ⟹ pderiv (?f ⊕⇘P⇙ ?g) = pderiv ?f ⊕⇘P⇙ pderiv ?g›*)) (*goals: 1. ‹⟦X ∈ carrier P; polynomial (carrier R) X⟧ ⟹ X [^]⇘P⇙ order R ^ n ∈ carrier P› 2. ‹⟦X ∈ carrier P; polynomial (carrier R) X⟧ ⟹ ⊖⇘P⇙ X ∈ carrier P› 3. ‹⟦X ∈ carrier P; polynomial (carrier R) X⟧ ⟹ pderiv (X [^]⇘P⇙ order R ^ n) ⊕⇘P⇙ ⊖⇘P⇙ pderiv X = pderiv (X [^]⇘P⇙ order R ^ n) ⊕⇘P⇙ pderiv (⊖⇘P⇙ X)› discuss goal 1*) apply (simp add:pderiv_inv (*‹(?f::'a list) ∈ carrier P ⟹ pderiv (⊖⇘P⇙ ?f) = ⊖⇘P⇙ pderiv ?f›*)) (*discuss goal 2*) apply (simp add:pderiv_inv (*‹?f ∈ carrier P ⟹ pderiv (⊖⇘P⇙ ?f) = ⊖⇘P⇙ pderiv ?f›*)) (*discuss goal 3*) apply (simp add:pderiv_inv (*‹?f ∈ carrier P ⟹ pderiv (⊖⇘P⇙ ?f) = ⊖⇘P⇙ pderiv ?f›*)) (*proven 3 subgoals*) . also (*calculation: ‹⊖⇘P⇙ 𝟭⇘P⇙ = pderiv (gauss_poly R (order R ^ n))›*) have "... = pderiv⇘R⇙ (f [^]⇘P⇙ (2::nat) ⊗⇘P⇙ h)" using h_def(2) (*‹gauss_poly R (order R ^ n) = f [^]⇘P⇙ 2 ⊗⇘P⇙ h›*) by simp also (*calculation: ‹⊖⇘P⇙ 𝟭⇘P⇙ = pderiv (f [^]⇘P⇙ 2 ⊗⇘P⇙ h)›*) have "... = pderiv⇘R⇙ (f [^]⇘P⇙ (2::nat)) ⊗⇘P⇙ h ⊕⇘P⇙ (f [^]⇘P⇙ (2::nat)) ⊗⇘P⇙ pderiv⇘R⇙ h" using f_carr (*‹f ∈ carrier P› ‹(f::'a list) ≠ []›*) h_def (*‹(h::'a::type list) ∈ carrier (Ring_Divisibility.mult_of P)› ‹gauss_poly R (order R ^ n) = f [^]⇘P⇙ 2 ⊗⇘P⇙ h›*) apply (intro pderiv_mult (*‹⟦(?f::'a list) ∈ carrier P; (?g::'a list) ∈ carrier P⟧ ⟹ pderiv (?f ⊗⇘P⇙ ?g) = pderiv ?f ⊗⇘P⇙ ?g ⊕⇘P⇙ ?f ⊗⇘P⇙ pderiv ?g›*)) (*goals: 1. ‹⟦(f::'a list) ∈ carrier P; f ≠ []; (h::'a list) ∈ carrier (Ring_Divisibility.mult_of P); gauss_poly R (order R ^ (n::nat)) = f [^]⇘P⇙ (2::nat) ⊗⇘P⇙ h⟧ ⟹ f [^]⇘P⇙ (2::nat) ∈ carrier P› 2. ‹⟦(f::'a list) ∈ carrier P; f ≠ []; (h::'a list) ∈ carrier (Ring_Divisibility.mult_of P); gauss_poly R (order R ^ (n::nat)) = f [^]⇘P⇙ (2::nat) ⊗⇘P⇙ h⟧ ⟹ h ∈ carrier P› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) . also (*calculation: ‹⊖⇘P⇙ 𝟭⇘P⇙ = pderiv (f [^]⇘P⇙ 2) ⊗⇘P⇙ h ⊕⇘P⇙ f [^]⇘P⇙ 2 ⊗⇘P⇙ pderiv h›*) have "... = int_embed P 2 ⊗⇘P⇙ f ⊗⇘P⇙ pderiv⇘R⇙ f ⊗⇘P⇙ h ⊕⇘P⇙ f ⊗⇘P⇙ f ⊗⇘P⇙ pderiv⇘R⇙ h" using f_carr (*‹f ∈ carrier P› ‹f ≠ []›*) apply (subst pderiv_pow (*‹⟦0 < ?n; ?f ∈ carrier P⟧ ⟹ pderiv (?f [^]⇘P⇙ ?n) = int_embed P (int ?n) ⊗⇘P⇙ ?f [^]⇘P⇙ (?n - 1) ⊗⇘P⇙ pderiv ?f›*)) (*goals: 1. ‹⟦f ∈ carrier P; f ≠ []⟧ ⟹ 0 < 2› 2. ‹⟦f ∈ carrier P; f ≠ []⟧ ⟹ f ∈ carrier P› 3. ‹⟦f ∈ carrier P; f ≠ []⟧ ⟹ int_embed P (int 2) ⊗⇘P⇙ f [^]⇘P⇙ (2 - 1) ⊗⇘P⇙ pderiv f ⊗⇘P⇙ h ⊕⇘P⇙ f [^]⇘P⇙ 2 ⊗⇘P⇙ pderiv h = int_embed P 2 ⊗⇘P⇙ f ⊗⇘P⇙ pderiv f ⊗⇘P⇙ h ⊕⇘P⇙ f ⊗⇘P⇙ f ⊗⇘P⇙ pderiv h› discuss goal 1*) apply (simp add:numeral_eq_Suc (*‹numeral ?k = Suc (pred_numeral ?k)›*)) (*discuss goal 2*) apply (simp add:numeral_eq_Suc (*‹numeral ?k = Suc (pred_numeral ?k)›*)) (*discuss goal 3*) apply (simp add:numeral_eq_Suc (*‹numeral ?k = Suc (pred_numeral ?k)›*)) (*proven 3 subgoals*) . also (*calculation: ‹⊖⇘P⇙ 𝟭⇘P⇙ = int_embed P 2 ⊗⇘P⇙ f ⊗⇘P⇙ pderiv f ⊗⇘P⇙ h ⊕⇘P⇙ f ⊗⇘P⇙ f ⊗⇘P⇙ pderiv h›*) have "... = f ⊗⇘P⇙ (int_embed P 2 ⊗⇘P⇙ pderiv⇘R⇙ f ⊗⇘P⇙ h) ⊕⇘P⇙ f ⊗⇘P⇙ (f ⊗⇘P⇙ pderiv⇘R⇙ h)" using f_carr (*‹f ∈ carrier P› ‹f ≠ []›*) pderiv_carr (*‹?f ∈ carrier P ⟹ pderiv ?f ∈ carrier P›*) h_def (*‹(h::'a::type list) ∈ carrier (Ring_Divisibility.mult_of P)› ‹gauss_poly R (order R ^ n) = f [^]⇘P⇙ 2 ⊗⇘P⇙ h›*) p.int_embed_closed (*‹int_embed P ?k ∈ carrier P›*) apply (intro arg_cong2[where f="(⊕⇘P⇙)"] (*‹⟦(?a::'a list) = (?b::'a list); (?c::'a list) = (?d::'a list)⟧ ⟹ ?a ⊕⇘P⇙ ?c = ?b ⊕⇘P⇙ ?d›*)) (*goals: 1. ‹⟦f ∈ carrier P; f ≠ []; ⋀f. f ∈ carrier P ⟹ pderiv f ∈ carrier P; h ∈ carrier (Ring_Divisibility.mult_of P); gauss_poly R (order R ^ n) = f [^]⇘P⇙ 2 ⊗⇘P⇙ h; ⋀k. int_embed P k ∈ carrier P⟧ ⟹ int_embed P 2 ⊗⇘P⇙ f ⊗⇘P⇙ pderiv f ⊗⇘P⇙ h = f ⊗⇘P⇙ (int_embed P 2 ⊗⇘P⇙ pderiv f ⊗⇘P⇙ h)› 2. ‹⟦f ∈ carrier P; f ≠ []; ⋀f. f ∈ carrier P ⟹ pderiv f ∈ carrier P; h ∈ carrier (Ring_Divisibility.mult_of P); gauss_poly R (order R ^ n) = f [^]⇘P⇙ 2 ⊗⇘P⇙ h; ⋀k. int_embed P k ∈ carrier P⟧ ⟹ f ⊗⇘P⇙ f ⊗⇘P⇙ pderiv h = f ⊗⇘P⇙ (f ⊗⇘P⇙ pderiv h)› discuss goal 1*) apply (subst p.m_comm (*‹⟦?x ∈ carrier P; ?y ∈ carrier P⟧ ⟹ ?x ⊗⇘P⇙ ?y = ?y ⊗⇘P⇙ ?x›*)) (*goals: 1. ‹⟦f ∈ carrier P; f ≠ []; ⋀f. f ∈ carrier P ⟹ pderiv f ∈ carrier P; h ∈ carrier (Ring_Divisibility.mult_of P); gauss_poly R (order R ^ n) = f [^]⇘P⇙ 2 ⊗⇘P⇙ h; ⋀k. int_embed P k ∈ carrier P⟧ ⟹ int_embed P 2 ∈ carrier P› 2. ‹⟦f ∈ carrier P; f ≠ []; ⋀f. f ∈ carrier P ⟹ pderiv f ∈ carrier P; h ∈ carrier (Ring_Divisibility.mult_of P); gauss_poly R (order R ^ n) = f [^]⇘P⇙ 2 ⊗⇘P⇙ h; ⋀k. int_embed P k ∈ carrier P⟧ ⟹ f ∈ carrier P› 3. ‹⟦f ∈ carrier P; f ≠ []; ⋀f. f ∈ carrier P ⟹ pderiv f ∈ carrier P; h ∈ carrier (Ring_Divisibility.mult_of P); gauss_poly R (order R ^ n) = f [^]⇘P⇙ 2 ⊗⇘P⇙ h; ⋀k. int_embed P k ∈ carrier P⟧ ⟹ f ⊗⇘P⇙ int_embed P 2 ⊗⇘P⇙ pderiv f ⊗⇘P⇙ h = f ⊗⇘P⇙ (int_embed P 2 ⊗⇘P⇙ pderiv f ⊗⇘P⇙ h)› discuss goal 1*) apply (simp add:p.m_assoc (*‹⟦(?x::'a::type list) ∈ carrier P; (?y::'a::type list) ∈ carrier P; (?z::'a::type list) ∈ carrier P⟧ ⟹ ?x ⊗⇘P⇙ ?y ⊗⇘P⇙ ?z = ?x ⊗⇘P⇙ (?y ⊗⇘P⇙ ?z)›*)) (*discuss goal 2*) apply (simp add:p.m_assoc (*‹⟦?x ∈ carrier P; ?y ∈ carrier P; ?z ∈ carrier P⟧ ⟹ ?x ⊗⇘P⇙ ?y ⊗⇘P⇙ ?z = ?x ⊗⇘P⇙ (?y ⊗⇘P⇙ ?z)›*)) (*discuss goal 3*) apply (simp add:p.m_assoc (*‹⟦?x ∈ carrier P; ?y ∈ carrier P; ?z ∈ carrier P⟧ ⟹ ?x ⊗⇘P⇙ ?y ⊗⇘P⇙ ?z = ?x ⊗⇘P⇙ (?y ⊗⇘P⇙ ?z)›*)) (*proven 3 subgoals*) (*discuss goal 2*) apply (simp add:p.m_assoc (*‹⟦?x ∈ carrier P; ?y ∈ carrier P; ?z ∈ carrier P⟧ ⟹ ?x ⊗⇘P⇙ ?y ⊗⇘P⇙ ?z = ?x ⊗⇘P⇙ (?y ⊗⇘P⇙ ?z)›*)) (*proven 2 subgoals*) . also (*calculation: ‹⊖⇘P⇙ 𝟭⇘P⇙ = f ⊗⇘P⇙ (int_embed P 2 ⊗⇘P⇙ pderiv f ⊗⇘P⇙ h) ⊕⇘P⇙ f ⊗⇘P⇙ (f ⊗⇘P⇙ pderiv h)›*) have "... = f ⊗⇘P⇙ (int_embed P 2 ⊗⇘P⇙ pderiv⇘R⇙ f ⊗⇘P⇙ h ⊕⇘P⇙ f ⊗⇘P⇙ pderiv⇘R⇙ h)" using f_carr (*‹f ∈ carrier P› ‹f ≠ []›*) pderiv_carr (*‹?f ∈ carrier P ⟹ pderiv ?f ∈ carrier P›*) h_def (*‹h ∈ carrier (Ring_Divisibility.mult_of P)› ‹gauss_poly R (order R ^ n) = f [^]⇘P⇙ 2 ⊗⇘P⇙ h›*) p.int_embed_closed (*‹int_embed P ?k ∈ carrier P›*) apply (subst p.r_distr (*‹⟦?x ∈ carrier P; ?y ∈ carrier P; ?z ∈ carrier P⟧ ⟹ ?z ⊗⇘P⇙ (?x ⊕⇘P⇙ ?y) = ?z ⊗⇘P⇙ ?x ⊕⇘P⇙ ?z ⊗⇘P⇙ ?y›*)) (*goals: 1. ‹⟦f ∈ carrier P; f ≠ []; ⋀f. f ∈ carrier P ⟹ pderiv f ∈ carrier P; h ∈ carrier (Ring_Divisibility.mult_of P); gauss_poly R (order R ^ n) = f [^]⇘P⇙ 2 ⊗⇘P⇙ h; ⋀k. int_embed P k ∈ carrier P⟧ ⟹ int_embed P 2 ⊗⇘P⇙ pderiv f ⊗⇘P⇙ h ∈ carrier P› 2. ‹⟦f ∈ carrier P; f ≠ []; ⋀f. f ∈ carrier P ⟹ pderiv f ∈ carrier P; h ∈ carrier (Ring_Divisibility.mult_of P); gauss_poly R (order R ^ n) = f [^]⇘P⇙ 2 ⊗⇘P⇙ h; ⋀k. int_embed P k ∈ carrier P⟧ ⟹ f ⊗⇘P⇙ pderiv h ∈ carrier P› 3. ‹⟦f ∈ carrier P; f ≠ []; ⋀f. f ∈ carrier P ⟹ pderiv f ∈ carrier P; h ∈ carrier (Ring_Divisibility.mult_of P); gauss_poly R (order R ^ n) = f [^]⇘P⇙ 2 ⊗⇘P⇙ h; ⋀k. int_embed P k ∈ carrier P⟧ ⟹ f ∈ carrier P› 4. ‹⟦f ∈ carrier P; f ≠ []; ⋀f. f ∈ carrier P ⟹ pderiv f ∈ carrier P; h ∈ carrier (Ring_Divisibility.mult_of P); gauss_poly R (order R ^ n) = f [^]⇘P⇙ 2 ⊗⇘P⇙ h; ⋀k. int_embed P k ∈ carrier P⟧ ⟹ f ⊗⇘P⇙ (int_embed P 2 ⊗⇘P⇙ pderiv f ⊗⇘P⇙ h) ⊕⇘P⇙ f ⊗⇘P⇙ (f ⊗⇘P⇙ pderiv h) = f ⊗⇘P⇙ (int_embed P 2 ⊗⇘P⇙ pderiv f ⊗⇘P⇙ h) ⊕⇘P⇙ f ⊗⇘P⇙ (f ⊗⇘P⇙ pderiv h)› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*discuss goal 3*) apply simp (*discuss goal 4*) apply simp (*proven 4 subgoals*) . finally (*calculation: ‹⊖⇘P⇙ 𝟭⇘P⇙ = f ⊗⇘P⇙ (int_embed P 2 ⊗⇘P⇙ pderiv f ⊗⇘P⇙ h ⊕⇘P⇙ f ⊗⇘P⇙ pderiv h)›*) have "⊖⇘P⇙ 𝟭⇘P⇙ = f ⊗⇘P⇙ (int_embed P 2 ⊗⇘P⇙ pderiv⇘R⇙ f ⊗⇘P⇙ h ⊕⇘P⇙ f ⊗⇘P⇙ pderiv⇘R⇙ h)" (is "_ = f ⊗⇘P⇙ ?q") by simp hence "f pdivides⇘R⇙ ⊖⇘P⇙ 𝟭⇘P⇙" unfolding factor_def pdivides_def (*goal: ‹∃c∈carrier P. ⊖⇘P⇙ 𝟭⇘P⇙ = f ⊗⇘P⇙ c›*) using f_carr (*‹f ∈ carrier P› ‹f ≠ []›*) pderiv_carr (*‹?f ∈ carrier P ⟹ pderiv ?f ∈ carrier P›*) h_def (*‹h ∈ carrier (Ring_Divisibility.mult_of P)› ‹gauss_poly R (order R ^ (n::nat)) = (f::'a list) [^]⇘P⇙ (2::nat) ⊗⇘P⇙ (h::'a list)›*) p.int_embed_closed (*‹int_embed P ?k ∈ carrier P›*) by auto moreover have "⊖⇘P⇙ 𝟭⇘P⇙ ≠ 𝟬⇘P⇙" by simp ultimately have "degree f ≤ degree (⊖⇘P⇙ 𝟭⇘P⇙)" using f_carr (*‹f ∈ carrier P› ‹f ≠ []›*) apply (intro pdivides_imp_degree_le (*‹⟦?p ∈ carrier P; ?q ∈ carrier P; ?q ≠ []; ?p pdivides ?q⟧ ⟹ degree ?p ≤ degree ?q›*)) (*goals: 1. ‹⟦f pdivides ⊖⇘P⇙ 𝟭⇘P⇙; ⊖⇘P⇙ 𝟭⇘P⇙ ≠ 𝟬⇘P⇙; f ∈ carrier P; f ≠ []⟧ ⟹ f ∈ carrier P› 2. ‹⟦f pdivides ⊖⇘P⇙ 𝟭⇘P⇙; ⊖⇘P⇙ 𝟭⇘P⇙ ≠ 𝟬⇘P⇙; f ∈ carrier P; f ≠ []⟧ ⟹ ⊖⇘P⇙ 𝟭⇘P⇙ ∈ carrier P› 3. ‹⟦f pdivides ⊖⇘P⇙ 𝟭⇘P⇙; ⊖⇘P⇙ 𝟭⇘P⇙ ≠ 𝟬⇘P⇙; f ∈ carrier P; f ≠ []⟧ ⟹ ⊖⇘P⇙ 𝟭⇘P⇙ ≠ []› 4. ‹⟦f pdivides ⊖⇘P⇙ 𝟭⇘P⇙; ⊖⇘P⇙ 𝟭⇘P⇙ ≠ 𝟬⇘P⇙; f ∈ carrier P; f ≠ []⟧ ⟹ f pdivides ⊖⇘P⇙ 𝟭⇘P⇙› discuss goal 1*) apply (simp add:univ_poly_zero (*‹𝟬⇘?K [X]⇘?R⇙⇙ = []›*)) (*discuss goal 2*) apply (simp add:univ_poly_zero (*‹𝟬⇘?K [X]⇘?R⇙⇙ = []›*)) (*discuss goal 3*) apply (simp add:univ_poly_zero (*‹𝟬⇘?K [X]⇘?R⇙⇙ = []›*)) (*discuss goal 4*) apply (simp add:univ_poly_zero (*‹𝟬⇘?K [X]⇘?R⇙⇙ = []›*)) (*proven 4 subgoals*) . also (*calculation: ‹degree f ≤ degree (⊖⇘P⇙ 𝟭⇘P⇙)›*) have "... = 0" apply (subst univ_poly_a_inv_degree (*‹?p ∈ carrier P ⟹ degree (⊖⇘P⇙ ?p) = degree ?p›*)) (*goals: 1. ‹𝟭⇘P⇙ ∈ carrier P› 2. ‹degree 𝟭⇘P⇙ = (0::nat)› discuss goal 1*) apply simp (*discuss goal 2*) apply (simp add:univ_poly_one (*‹𝟭⇘?K::?'a::type set [X]⇘?R::(?'a, ?'b) ring_scheme⇙⇙ = [𝟭⇘?R⇙]›*)) (*proven 2 subgoals*) . finally (*calculation: ‹degree f ≤ 0›*) have "degree f = 0" by simp then show False using pirreducible_degree (*‹⟦?p ∈ carrier P; pirreducible (carrier R) ?p⟧ ⟹ 1 ≤ degree ?p›*) assms(2) (*‹m_i_p R f›*) unfolding monic_irreducible_poly_def monic_poly_def (*goal: ‹False›*) by fastforce qed ultimately have "pmult⇘R⇙ f ?g = 1" by simp then show "?thesis" (*goal: ‹pmult f (gauss_poly R (order R ^ n)) = of_bool (degree f dvd n)›*) using True (*‹degree f dvd n›*) by simp next (*goal: ‹¬ degree f dvd n ⟹ pmult f (gauss_poly R (order R ^ n)) = of_bool (degree f dvd n)›*) case False (*‹¬ degree f dvd n›*) have o2: "order R^n > 1" using finite_field_min_order (*‹1 < order R›*) assms(1) (*‹0 < n›*) one_less_power (*‹⟦1 < ?a; 0 < ?n⟧ ⟹ 1 < ?a ^ ?n›*) by blast have "¬(f pdivides⇘R⇙ gauss_poly R (order R^n))" using div_gauss_poly_iff[OF assms] (*‹(f::'a::type list) pdivides gauss_poly R (order R ^ (n::nat)) = (degree f dvd n)›*) False (*‹¬ degree f dvd n›*) by simp hence "pmult⇘R⇙ f (gauss_poly R (order R^n)) = 0" using multiplicity_ge_1_iff_pdivides[OF assms ( 2 )] (*‹?f ∈ carrier P - {𝟬⇘P⇙} ⟹ (1 ≤ pmult f ?f) = f pdivides ?f›*) using gauss_poly_carr (*‹gauss_poly R (?n::nat) ∈ carrier P›*) gauss_poly_not_zero[OF o2] (*‹gauss_poly R (order R ^ n) ≠ 𝟬⇘P⇙›*) leI (*‹¬ ?x < ?y ⟹ ?y ≤ ?x›*) less_one (*‹(?n < 1) = (?n = 0)›*) by blast then show "?thesis" (*goal: ‹pmult (f::'a list) (gauss_poly R (order R ^ (n::nat))) = of_bool (degree f dvd n)›*) using False (*‹¬ degree f dvd n›*) by simp qed text ‹The following lemma, for the case when @{term "R"} is a simple prime field, can be found in Ireland and Rosen~\<^cite>‹‹\textsection 7.1, Corollary 1› in "ireland1982"›. Here the result is verified even for arbitrary finite fields.› lemma card_irred_aux: assumes "n > 0" shows "order R^n = (∑d | d dvd n. d * card {f. monic_irreducible_poly R f ∧ degree f = d})" (is "?lhs = ?rhs") proof (-) (*goal: ‹order R ^ n = (∑d | d dvd n. d * card {f. m_i_p R f ∧ degree f = d})›*) let ?G = "{f. monic_irreducible_poly R f ∧ degree f dvd n}" let ?D = "{f. monic_irreducible_poly R f}" have a: "finite {d. d dvd n}" using finite_divisors_nat (*‹(0::nat) < (?m::nat) ⟹ finite {d::nat. d dvd ?m}›*) assms (*‹0 < n›*) by simp have b: "finite {f. monic_irreducible_poly R f ∧ degree f = k}" for k proof (-) (*goal: ‹finite {f::'a list. m_i_p R f ∧ degree f = (k::nat)}›*) have "{f. monic_irreducible_poly R f ∧ degree f = k} ⊆ {f. f ∈ carrier P ∧ degree f ≤ k}" unfolding monic_irreducible_poly_def monic_poly_def (*goal: ‹{f. ((f ≠ [] ∧ lead_coeff f = 𝟭 ∧ f ∈ carrier P) ∧ pirreducible (carrier R) f) ∧ degree f = k} ⊆ {f ∈ carrier P. degree f ≤ k}›*) by auto moreover have "finite {f. f ∈ carrier P ∧ degree f ≤ k}" using finite_poly[OF finite_carrier] (*‹finite {f::'a list ∈ carrier P. degree f = (?n::nat)}› ‹finite {f ∈ carrier P. degree f ≤ ?n}›*) by simp ultimately show "?thesis" (*goal: ‹finite {f. m_i_p R f ∧ degree f = k}›*) using finite_subset (*‹⟦?A ⊆ ?B; finite ?B⟧ ⟹ finite ?A›*) by simp qed have G_split: "?G = ⋃ {{f. monic_irreducible_poly R f ∧ degree f = d} | d. d dvd n}" by auto have c: "finite ?G" using a (*‹finite {d. d dvd n}›*) b (*‹finite {f. m_i_p R f ∧ degree f = ?k}›*) apply (subst G_split (*‹{f. m_i_p R f ∧ degree f dvd n} = ⋃ {{f. m_i_p R f ∧ degree f = d} |d. d dvd n}›*)) (*goal: ‹finite {f. m_i_p R f ∧ degree f dvd n}›*) by auto have d: "order R^n > 1" using assms (*‹(0::nat) < (n::nat)›*) finite_field_min_order (*‹1 < order R›*) one_less_power (*‹⟦(1::?'a) < (?a::?'a); (0::nat) < (?n::nat)⟧ ⟹ (1::?'a) < ?a ^ ?n›*) by blast have "?lhs = degree (gauss_poly R (order R^n))" using d (*‹1 < order R ^ n›*) apply (subst gauss_poly_degree (*‹1 < ?n ⟹ degree (gauss_poly R ?n) = ?n›*)) (*goals: 1. ‹(1::nat) < order R ^ (n::nat) ⟹ (1::nat) < order R ^ n› 2. ‹(1::nat) < order R ^ (n::nat) ⟹ order R ^ n = order R ^ n› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) . also (*calculation: ‹order R ^ n = degree (gauss_poly R (order R ^ n))›*) have "... = sum' (λd. pmult⇘R⇙ d (gauss_poly R (order R^n)) * degree d) ?D" using d (*‹(1::nat) < order R ^ (n::nat)›*) by (intro degree_monic_poly'[symmetric] (*‹monic_poly R ?f ⟹ degree ?f = sum' (λd. pmult d ?f * degree d) {d. m_i_p R d}›*) gauss_poly_monic (*‹1 < ?n ⟹ monic_poly R (gauss_poly R ?n)›*)) also (*calculation: ‹order R ^ (n::nat) = sum' (λd::'a list. pmult d (gauss_poly R (order R ^ n)) * degree d) {f::'a list. m_i_p R f}›*) have "... = sum' (λd. of_bool (degree d dvd n) * degree d) ?D" using multiplicity_of_factor_of_gauss_poly[OF assms] (*‹m_i_p R ?f ⟹ pmult ?f (gauss_poly R (order R ^ n)) = of_bool (degree ?f dvd n)›*) apply (intro sum.cong' (*‹⟦?A = ?B; ⋀x. x ∈ ?B ⟹ ?g x = ?h x⟧ ⟹ sum' ?g ?A = sum' ?h ?B›*)) (*goals: 1. ‹(⋀f. m_i_p R f ⟹ pmult f (gauss_poly R (order R ^ n)) = of_bool (degree f dvd n)) ⟹ {f. m_i_p R f} = {f. m_i_p R f}› 2. ‹⋀x. ⟦⋀f. m_i_p R f ⟹ pmult f (gauss_poly R (order R ^ n)) = of_bool (degree f dvd n); x ∈ {f. m_i_p R f}⟧ ⟹ pmult x (gauss_poly R (order R ^ n)) * degree x = of_bool (degree x dvd n) * degree x› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . also (*calculation: ‹order R ^ n = sum' (λd. of_bool (degree d dvd n) * degree d) {f. m_i_p R f}›*) have "... = sum' (λd. degree d) ?G" apply (intro sum.mono_neutral_cong_right' (*‹⟦?S ⊆ ?T; ∀i∈?T - ?S. ?g i = 0; ⋀x. x ∈ ?S ⟹ ?g x = ?h x⟧ ⟹ sum' ?g ?T = sum' ?h ?S›*) subsetI (*‹(⋀x. x ∈ ?A ⟹ x ∈ ?B) ⟹ ?A ⊆ ?B›*)) (*goals: 1. ‹⋀x. x ∈ {f. m_i_p R f ∧ degree f dvd n} ⟹ x ∈ {f. m_i_p R f}› 2. ‹∀i∈{f. m_i_p R f} - {f. m_i_p R f ∧ degree f dvd n}. of_bool (degree i dvd n) * degree i = 0› 3. ‹⋀x. x ∈ {f. m_i_p R f ∧ degree f dvd n} ⟹ of_bool (degree x dvd n) * degree x = degree x› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*proven 3 subgoals*) . also (*calculation: ‹order R ^ n = sum' degree {f. m_i_p R f ∧ degree f dvd n}›*) have "... = (∑ d ∈ ?G. degree d)" using c (*‹finite {f. m_i_p R f ∧ degree f dvd n}›*) apply (intro sum.eq_sum (*‹finite ?I ⟹ sum' ?p ?I = sum ?p ?I›*)) (*goal: ‹sum' degree {f. m_i_p R f ∧ degree f dvd n} = sum degree {f. m_i_p R f ∧ degree f dvd n}›*) by simp also (*calculation: ‹order R ^ n = sum degree {f. m_i_p R f ∧ degree f dvd n}›*) have "... = (∑ f ∈ (⋃ d ∈ {d. d dvd n}. {f. monic_irreducible_poly R f ∧ degree f = d}). degree f)" apply (intro sum.cong (*‹⟦?A = ?B; ⋀x. x ∈ ?B ⟹ ?g x = ?h x⟧ ⟹ sum ?g ?A = sum ?h ?B›*)) (*goals: 1. ‹{f. m_i_p R f ∧ degree f dvd n} = (⋃d∈{d. d dvd n}. {f. m_i_p R f ∧ degree f = d})› 2. ‹⋀x. x ∈ (⋃d∈{d. d dvd n}. {f. m_i_p R f ∧ degree f = d}) ⟹ degree x = degree x› discuss goal 1*) apply ((auto simp add:set_eq_iff (*‹(?A = ?B) = (∀x. (x ∈ ?A) = (x ∈ ?B))›*))[1]) (*discuss goal 2*) apply ((auto simp add:set_eq_iff (*‹(?A = ?B) = (∀x. (x ∈ ?A) = (x ∈ ?B))›*))[1]) (*proven 2 subgoals*) . also (*calculation: ‹order R ^ n = sum degree (⋃d∈{d. d dvd n}. {f. m_i_p R f ∧ degree f = d})›*) have "... = (∑d | d dvd n. sum degree {f. monic_irreducible_poly R f ∧ degree f = d})" using a (*‹finite {d. d dvd n}›*) b (*‹finite {f. m_i_p R f ∧ degree f = ?k}›*) apply (subst sum.UNION_disjoint (*‹⟦finite ?I; ∀i∈?I. finite (?A i); ∀i∈?I. ∀j∈?I. i ≠ j ⟶ ?A i ∩ ?A j = {}⟧ ⟹ sum ?g (⋃ (?A ` ?I)) = (∑x∈?I. sum ?g (?A x))›*)) (*goals: 1. ‹⟦finite {d. d dvd n}; ⋀k. finite {f. m_i_p R f ∧ degree f = k}⟧ ⟹ finite {d. d dvd n}› 2. ‹⟦finite {d. d dvd n}; ⋀k. finite {f. m_i_p R f ∧ degree f = k}⟧ ⟹ ∀i∈{d. d dvd n}. finite {f. m_i_p R f ∧ degree f = i}› 3. ‹⟦finite {d. d dvd n}; ⋀k. finite {f. m_i_p R f ∧ degree f = k}⟧ ⟹ ∀i∈{d. d dvd n}. ∀j∈{d. d dvd n}. i ≠ j ⟶ {f. m_i_p R f ∧ degree f = i} ∩ {f. m_i_p R f ∧ degree f = j} = {}› 4. ‹⟦finite {d. d dvd n}; ⋀k. finite {f. m_i_p R f ∧ degree f = k}⟧ ⟹ (∑x∈{d. d dvd n}. ∑f | m_i_p R f ∧ degree f = x. degree f) = (∑d | d dvd n. sum degree {f. m_i_p R f ∧ degree f = d})› discuss goal 1*) apply ((auto simp add:set_eq_iff (*‹(?A = ?B) = (∀x. (x ∈ ?A) = (x ∈ ?B))›*))[1]) (*discuss goal 2*) apply ((auto simp add:set_eq_iff (*‹((?A::?'a::type set) = (?B::?'a::type set)) = (∀x::?'a::type. (x ∈ ?A) = (x ∈ ?B))›*))[1]) (*discuss goal 3*) apply ((auto simp add:set_eq_iff (*‹((?A::?'a set) = (?B::?'a set)) = (∀x::?'a. (x ∈ ?A) = (x ∈ ?B))›*))[1]) (*discuss goal 4*) apply ((auto simp add:set_eq_iff (*‹(?A = ?B) = (∀x. (x ∈ ?A) = (x ∈ ?B))›*))[1]) (*proven 4 subgoals*) . also (*calculation: ‹order R ^ n = (∑d | d dvd n. sum degree {f. m_i_p R f ∧ degree f = d})›*) have "... = (∑d | d dvd n. sum (λ_. d) {f. monic_irreducible_poly R f ∧ degree f = d})" apply (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›*)) (*goals: 1. ‹{d. d dvd n} = {d. d dvd n}› 2. ‹⋀x. x ∈ {d. d dvd n} ⟹ {f. m_i_p R f ∧ degree f = x} = {f. m_i_p R f ∧ degree f = x}› 3. ‹⋀x xa. ⟦x ∈ {d. d dvd n}; xa ∈ {f. m_i_p R f ∧ degree f = x}⟧ ⟹ degree xa = x› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*discuss goal 3*) apply simp (*proven 3 subgoals*) . also (*calculation: ‹order R ^ n = (∑d | d dvd n. ∑_∈{f. m_i_p R f ∧ degree f = d}. d)›*) have "... = ?rhs" by (simp add:mult.commute (*‹?a * ?b = ?b * ?a›*)) finally (*calculation: ‹order R ^ n = (∑d | d dvd n. d * card {f. m_i_p R f ∧ degree f = d})›*) show "?thesis" (*goal: ‹order R ^ n = (∑d | d dvd n. d * card {f. m_i_p R f ∧ degree f = d})›*) by simp qed end end
{ "path": "afp-2025-02-12/thys/Finite_Fields/Card_Irreducible_Polynomials_Aux.thy", "repo": "afp-2025-02-12", "sha": "06eb303763faa5a2f4c8e27f8b99f35021fcd31f4944c7e30583a9459e356ca6" }
theory NDFS_Benchmark imports Collections_Examples.Nested_DFS "../../../Examples/Sepref_NDFS" Separation_Logic_Imperative_HOL.From_List_GA begin (* We re-do some of the refinement here, to have a more direct control of the exact data-structures that are used *) (* Purely functional version *) locale bm_fun begin schematic_goal succ_of_list_impl: notes [autoref_tyrel] = ty_REL[where 'a="nat⇀nat set" and R="⟨nat_rel,R⟩dflt_rm_rel" for R] ty_REL[where 'a="nat set" and R="⟨nat_rel⟩list_set_rel"] shows "(?f::?'c,succ_of_list) ∈ ?R" unfolding succ_of_list_def[abs_def] (*goal: ‹(?f, λl. let m = fold (λ(u, v) g. case g u of None ⇒ g(u ↦ {v}) | Some s ⇒ g(u ↦ insert v s)) l (λx. None) in (λu. case m u of None ⇒ {} | Some s ⇒ s)) ∈ ?R›*) by (autoref (keep_goal)) concrete_definition succ_of_list_impl uses succ_of_list_impl schematic_goal acc_of_list_impl: notes [autoref_tyrel] = ty_REL[where 'a="nat set" and R="⟨nat_rel⟩dflt_rs_rel" for R] shows "(?f::?'c,acc_of_list) ∈ ?R" unfolding acc_of_list_def[abs_def] (*goal: ‹(?f::?'c, λl::nat list. fold insert l {}) ∈ (?R::(?'c × (nat list ⇒ nat set)) set)›*) by (autoref (keep_goal)) concrete_definition acc_of_list_impl uses acc_of_list_impl schematic_goal red_dfs_impl_refine_aux: (*notes [[goals_limit = 1]]*) fixes u'::"nat" and V'::"nat set" notes [autoref_tyrel] = ty_REL[where 'a="nat set" and R="⟨nat_rel⟩dflt_rs_rel"] assumes [autoref_rules]: "(u,u')∈nat_rel" "(V,V')∈⟨nat_rel⟩dflt_rs_rel" "(onstack,onstack')∈⟨nat_rel⟩dflt_rs_rel" "(E,E')∈⟨nat_rel⟩slg_rel" shows "(RETURN (?f::?'c), red_dfs E' onstack' V' u') ∈ ?R" apply - (*goal: ‹(RETURN ?f, red_dfs E' onstack' V' u') ∈ ?R›*) unfolding red_dfs_def (*goal: ‹(RETURN ?f, REC⇩T (λD (V, u). let V = insert u V in FOREACH⇩C (E' `` {u}) (λbrk. brk = None) (λt _. if t ∈ onstack' then RETURN (red_init_witness u t) else RETURN None) None ⤜ (λbrk. case brk of None ⇒ FOREACH⇩C (E' `` {u}) (λ(V, brk). brk = None) (λt (V, uu_). if t ∉ V then D (V, t) ⤜ (λ(V, brk). RETURN (V, prep_wit_red u brk)) else RETURN (V, None)) (V, None) | Some a ⇒ RETURN (V, brk))) (V', u')) ∈ ?R›*) by autoref_monadic concrete_definition red_dfs_impl uses red_dfs_impl_refine_aux prepare_code_thms red_dfs_impl_def declare red_dfs_impl.refine[autoref_higher_order_rule, autoref_rules] schematic_goal ndfs_impl_refine_aux: fixes s::"nat" and succi notes [autoref_tyrel] = ty_REL[where 'a="nat set" and R="⟨nat_rel⟩dflt_rs_rel"] assumes [autoref_rules]: "(succi,E)∈⟨nat_rel⟩slg_rel" "(Ai,A)∈⟨nat_rel⟩dflt_rs_rel" notes [autoref_rules] = IdI[of s] shows "(RETURN (?f::?'c), blue_dfs E A s) ∈ ⟨?R⟩nres_rel" unfolding blue_dfs_def (*goal: ‹(RETURN ?f, REC⇩T (λD (blues, reds, onstack, s). let blues = insert s blues; onstack = insert s onstack in FOREACH⇩C (E `` {s}) (λ(uu_, uu_, uu_, cyc). cyc = NO_CYC) (λt (blues, reds, onstack, cyc). if t ∉ blues then D (blues, reds, onstack, t) ⤜ (λ(blues, reds, onstack, cyc). RETURN (blues, reds, onstack, prep_wit_blue s cyc)) else RETURN (blues, reds, onstack, cyc)) (blues, reds, onstack, NO_CYC) ⤜ (λ(blues, reds, onstack, cyc). (if cyc = NO_CYC ∧ s ∈ A then red_dfs E onstack reds s ⤜ (λ(reds, rcyc). RETURN (reds, init_wit_blue s rcyc)) else RETURN (reds, cyc)) ⤜ (λ(reds, cyc). let onstack = onstack - {s} in RETURN (blues, reds, onstack, cyc)))) ({}, {}, {}, s) ⤜ (λ(uu_, uu_, uu_, cyc). RETURN (extract_res cyc))) ∈ ⟨?R⟩nres_rel›*) by (autoref_monadic (trace)) concrete_definition fun_ndfs_impl for succi Ai s uses ndfs_impl_refine_aux prepare_code_thms fun_ndfs_impl_def definition "fun_succ_of_list ≡ succ_of_list_impl o map (λ(u,v). (nat_of_integer u, nat_of_integer v))" definition "fun_acc_of_list ≡ acc_of_list_impl o map nat_of_integer" end interpretation "fun": bm_fun . (* Purely functional version *) locale bm_funs begin schematic_goal succ_of_list_impl: notes [autoref_tyrel] = ty_REL[where 'a="nat⇀nat set" and R="⟨nat_rel,R⟩iam_map_rel" for R] ty_REL[where 'a="nat set" and R="⟨nat_rel⟩list_set_rel"] shows "(?f::?'c,succ_of_list) ∈ ?R" unfolding succ_of_list_def[abs_def] (*goal: ‹(?f, λl. let m = fold (λ(u, v) g. case g u of None ⇒ g(u ↦ {v}) | Some s ⇒ g(u ↦ insert v s)) l (λx. None) in (λu. case m u of None ⇒ {} | Some s ⇒ s)) ∈ ?R›*) by (autoref (keep_goal)) concrete_definition succ_of_list_impl uses succ_of_list_impl schematic_goal acc_of_list_impl: notes [autoref_tyrel] = ty_REL[where 'a="nat set" and R="⟨nat_rel⟩iam_set_rel" for R] shows "(?f::?'c,acc_of_list) ∈ ?R" unfolding acc_of_list_def[abs_def] (*goal: ‹(?f, λl. fold insert l {}) ∈ ?R›*) by (autoref (keep_goal)) concrete_definition acc_of_list_impl uses acc_of_list_impl schematic_goal red_dfs_impl_refine_aux: (*notes [[goals_limit = 1]]*) fixes u'::"nat" and V'::"nat set" notes [autoref_tyrel] = ty_REL[where 'a="nat set" and R="⟨nat_rel⟩iam_set_rel"] assumes [autoref_rules]: "(u,u')∈nat_rel" "(V,V')∈⟨nat_rel⟩iam_set_rel" "(onstack,onstack')∈⟨nat_rel⟩iam_set_rel" "(E,E')∈⟨nat_rel⟩slg_rel" shows "(RETURN (?f::?'c), red_dfs E' onstack' V' u') ∈ ?R" apply - (*goal: ‹(RETURN (?f::?'c), red_dfs (E'::(nat × nat) set) (onstack'::nat set) (V'::nat set) (u'::nat)) ∈ (?R::(?'c nres × (nat set × (nat list × nat) option) nres) set)›*) unfolding red_dfs_def (*goal: ‹(RETURN ?f, REC⇩T (λD (V, u). let V = insert u V in FOREACH⇩C (E' `` {u}) (λbrk. brk = None) (λt _. if t ∈ onstack' then RETURN (red_init_witness u t) else RETURN None) None ⤜ (λbrk. case brk of None ⇒ FOREACH⇩C (E' `` {u}) (λ(V, brk). brk = None) (λt (V, uu_). if t ∉ V then D (V, t) ⤜ (λ(V, brk). RETURN (V, prep_wit_red u brk)) else RETURN (V, None)) (V, None) | Some a ⇒ RETURN (V, brk))) (V', u')) ∈ ?R›*) by autoref_monadic concrete_definition red_dfs_impl uses red_dfs_impl_refine_aux prepare_code_thms red_dfs_impl_def declare red_dfs_impl.refine[autoref_higher_order_rule, autoref_rules] schematic_goal ndfs_impl_refine_aux: fixes s::"nat" and succi notes [autoref_tyrel] = ty_REL[where 'a="nat set" and R="⟨nat_rel⟩iam_set_rel"] assumes [autoref_rules]: "(succi,E)∈⟨nat_rel⟩slg_rel" "(Ai,A)∈⟨nat_rel⟩iam_set_rel" notes [autoref_rules] = IdI[of s] shows "(RETURN (?f::?'c), blue_dfs E A s) ∈ ⟨?R⟩nres_rel" unfolding blue_dfs_def (*goal: ‹(RETURN (?f::?'c), REC⇩T (λ(D::nat set × nat set × nat set × nat ⇒ (nat set × nat set × nat set × nat blue_witness) nres) (blues::nat set, reds::nat set, onstack::nat set, s::nat). let blues::nat set = insert s blues; onstack::nat set = insert s onstack in FOREACH⇩C ((E::(nat × nat) set) `` {s}) (λ(uu_::nat set, uu_::nat set, uu_::nat set, cyc::nat blue_witness). cyc = NO_CYC) (λ(t::nat) (blues::nat set, reds::nat set, onstack::nat set, cyc::nat blue_witness). if t ∉ blues then D (blues, reds, onstack, t) ⤜ (λ(blues::nat set, reds::nat set, onstack::nat set, cyc::nat blue_witness). RETURN (blues, reds, onstack, prep_wit_blue s cyc)) else RETURN (blues, reds, onstack, cyc)) (blues, reds, onstack, NO_CYC) ⤜ (λ(blues::nat set, reds::nat set, onstack::nat set, cyc::nat blue_witness). (if cyc = NO_CYC ∧ s ∈ (A::nat set) then red_dfs E onstack reds s ⤜ (λ(reds::nat set, rcyc::(nat list × nat) option). RETURN (reds, init_wit_blue s rcyc)) else RETURN (reds, cyc)) ⤜ (λ(reds::nat set, cyc::nat blue_witness). let onstack::nat set = onstack - {s} in RETURN (blues, reds, onstack, cyc)))) ({}, {}, {}, s::nat) ⤜ (λ(uu_::nat set, uu_::nat set, uu_::nat set, cyc::nat blue_witness). RETURN (extract_res cyc))) ∈ ⟨?R::(?'c × (nat × nat list × nat list) option) set⟩nres_rel›*) by (autoref_monadic (trace)) concrete_definition funs_ndfs_impl for succi Ai s uses ndfs_impl_refine_aux prepare_code_thms funs_ndfs_impl_def definition "funs_succ_of_list ≡ succ_of_list_impl o map (λ(u,v). (nat_of_integer u, nat_of_integer v))" definition "funs_acc_of_list ≡ acc_of_list_impl o map nat_of_integer" end interpretation "funs": bm_funs . definition "imp_ndfs_impl ≡ blue_dfs_impl" definition "imp_ndfs_sz_impl ≡ blue_dfs_impl_sz" definition "imp_acc_of_list l ≡ From_List_GA.ias_from_list (map nat_of_integer l)" definition "imp_graph_of_list n l ≡ cr_graph (nat_of_integer n) (map (pairself nat_of_integer) l)" export_code nat_of_integer integer_of_nat fun.fun_ndfs_impl fun.fun_succ_of_list fun.fun_acc_of_list funs.funs_ndfs_impl funs.funs_succ_of_list funs.funs_acc_of_list imp_ndfs_impl imp_ndfs_sz_impl imp_acc_of_list imp_graph_of_list in SML_imp module_name NDFS_Benchmark file ‹NDFS_Benchmark_export.sml› ML_val ‹open Time› end
{ "path": "afp-2025-02-12/thys/Refine_Imperative_HOL/benchmarks/NestedDFS/isabelle/NDFS_Benchmark.thy", "repo": "afp-2025-02-12", "sha": "7efea1f81a654fdc262ee33135c2bbbcbc43d4a4e74d70a53e5d55ef785dc58c" }
section‹The main theorem› theory Forcing_Main imports Internal_ZFC_Axioms Choice_Axiom Ordinals_In_MG Succession_Poset begin subsection‹The generic extension is countable› (* ― ‹Useful missing lemma› lemma surj_imp_well_ord: assumes "well_ord(A,r)" "h ∈ surj(A,B)" shows "∃s. well_ord(B,r)" *) definition minimum :: "i ⇒ i ⇒ i" where "minimum(r,B) ≡ THE b. b∈B ∧ (∀y∈B. y ≠ b ⟶ ⟨b, y⟩ ∈ r)" lemma well_ord_imp_min: assumes "well_ord(A,r)" "B ⊆ A" "B ≠ 0" shows "minimum(r,B) ∈ B" proof (-) (*goal: ‹minimum(r, B) ∈ B›*) from ‹well_ord(A,r)› (*‹well_ord(A, r)›*) have "wf[A](r)" using well_ord_is_wf[OF ‹well_ord(A,r)›] (*‹wf[A](r)›*) by simp with ‹B⊆A› (*‹B ⊆ A›*) have "wf[B](r)" using Sigma_mono (*‹⟦?A ⊆ ?C; ⋀x. x ∈ ?A ⟹ ?B(x) ⊆ ?D(x)⟧ ⟹ Sigma(?A, ?B) ⊆ Sigma(?C, ?D)›*) Int_mono (*‹⟦?A ⊆ ?C; ?B ⊆ ?D⟧ ⟹ ?A ∩ ?B ⊆ ?C ∩ ?D›*) wf_subset (*‹⟦wf(?s); ?r ⊆ ?s⟧ ⟹ wf(?r)›*) unfolding wf_on_def (*goal: ‹wf(r ∩ B × B)›*) by simp then have "∀ x. x ∈ B ⟶ (∃z∈B. ∀y. ⟨y, z⟩ ∈ r∩B×B ⟶ y ∉ B)" unfolding wf_on_def (*goal: ‹∀x. x ∈ B ⟶ (∃z∈B. ∀y. ⟨y, z⟩ ∈ r ∩ B × B ⟶ y ∉ B)›*) using wf_eq_minimal (*‹wf(?r) ⟷ (∀Q x. x ∈ Q ⟶ (∃z∈Q. ∀y. ⟨y, z⟩ ∈ ?r ⟶ y ∉ Q))›*) by blast with ‹B≠0› (*‹B ≠ 0›*) obtain z where B: "z∈B ∧ (∀y. ⟨y,z⟩∈r∩B×B ⟶ y∉B)" (*goal: ‹(⋀z. z ∈ B ∧ (∀y. ⟨y, z⟩ ∈ r ∩ B × B ⟶ y ∉ B) ⟹ thesis) ⟹ thesis›*) by blast then have "z∈B ∧ (∀y∈B. y ≠ z ⟶ ⟨z, y⟩ ∈ r)" proof (-) (*goal: ‹z ∈ B ∧ (∀y. ⟨y, z⟩ ∈ r ∩ B × B ⟶ y ∉ B) ⟹ z ∈ B ∧ (∀y∈B. y ≠ z ⟶ ⟨z, y⟩ ∈ r)›*) { fix y assume "y∈B" "y≠z" (*‹(y::i) ∈ (B::i)› ‹(y::i) ≠ (z::i)›*) with ‹well_ord(A,r)› (*‹well_ord(A, r)›*) B (*‹(z::i) ∈ (B::i) ∧ (∀y::i. ⟨y, z⟩ ∈ (r::i) ∩ B × B ⟶ y ∉ B)›*) ‹B⊆A› (*‹B ⊆ A›*) have "⟨z,y⟩∈r|⟨y,z⟩∈r|y=z" unfolding well_ord_def tot_ord_def linear_def (*goal: ‹⟨z, y⟩ ∈ r ∨ ⟨y, z⟩ ∈ r ∨ y = z›*) by auto with B (*‹z ∈ B ∧ (∀y. ⟨y, z⟩ ∈ r ∩ B × B ⟶ y ∉ B)›*) ‹y∈B› (*‹(y::i) ∈ (B::i)›*) ‹y≠z› (*‹y ≠ z›*) have "⟨z,y⟩∈r" apply ((cases)[1]) (*goals: 1. ‹⟦(z::i) ∈ (B::i) ∧ (∀y::i. ⟨y, z⟩ ∈ (r::i) ∩ B × B ⟶ y ∉ B); (y::i) ∈ B; y ≠ z; ⟨z, y⟩ ∈ r ∨ ⟨y, z⟩ ∈ r ∨ y = z; ?P5::o⟧ ⟹ ⟨z, y⟩ ∈ r› 2. ‹⟦(z::i) ∈ (B::i) ∧ (∀y::i. ⟨y, z⟩ ∈ (r::i) ∩ B × B ⟶ y ∉ B); (y::i) ∈ B; y ≠ z; ⟨z, y⟩ ∈ r ∨ ⟨y, z⟩ ∈ r ∨ y = z; ¬ (?P5::o)⟧ ⟹ ⟨z, y⟩ ∈ r› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . } with B (*‹z ∈ B ∧ (∀y. ⟨y, z⟩ ∈ r ∩ B × B ⟶ y ∉ B)›*) show "?thesis" (*goal: ‹z ∈ B ∧ (∀y∈B. y ≠ z ⟶ ⟨z, y⟩ ∈ r)›*) by blast qed have "v = z" if "v∈B ∧ (∀y∈B. y ≠ v ⟶ ⟨v, y⟩ ∈ r)" for v using that (*‹v ∈ B ∧ (∀y∈B. y ≠ v ⟶ ⟨v, y⟩ ∈ r)›*) B (*‹z ∈ B ∧ (∀y. ⟨y, z⟩ ∈ r ∩ B × B ⟶ y ∉ B)›*) by auto with ‹z∈B ∧ (∀y∈B. y ≠ z ⟶ ⟨z, y⟩ ∈ r)› (*‹z ∈ B ∧ (∀y∈B. y ≠ z ⟶ ⟨z, y⟩ ∈ r)›*) show "?thesis" (*goal: ‹minimum(r, B) ∈ B›*) unfolding minimum_def (*goal: ‹(THE b. b ∈ B ∧ (∀y∈B. y ≠ b ⟶ ⟨b, y⟩ ∈ r)) ∈ B›*) using the_equality2[OF ex1I [ of "λx .x∈B ∧ (∀y∈B. y ≠ x ⟶ ⟨x, y⟩ ∈ r)" z ]] (*‹⟦z ∈ B ∧ (∀y∈B. y ≠ z ⟶ ⟨z, y⟩ ∈ r); ⋀x. x ∈ B ∧ (∀y∈B. y ≠ x ⟶ ⟨x, y⟩ ∈ r) ⟹ x = z; ?a ∈ B ∧ (∀y∈B. y ≠ ?a ⟶ ⟨?a, y⟩ ∈ r)⟧ ⟹ (THE x. x ∈ B ∧ (∀y∈B. y ≠ x ⟶ ⟨x, y⟩ ∈ r)) = ?a›*) by auto qed lemma well_ord_surj_imp_lepoll: assumes "well_ord(A,r)" "h ∈ surj(A,B)" shows "B ≲ A" proof (-) (*goal: ‹B ≲ A›*) let ?f = "λb∈B. minimum(r, {a∈A. h`a=b})" have "b ∈ B ⟹ minimum(r, {a ∈ A . h ` a = b}) ∈ {a∈A. h`a=b}" for b proof (-) (*goal: ‹b ∈ B ⟹ minimum(r, {a ∈ A . h ` a = b}) ∈ {a ∈ A . h ` a = b}›*) fix b assume "b∈B" (*‹(b::i) ∈ (B::i)›*) with ‹h ∈ surj(A,B)› (*‹h ∈ surj(A, B)›*) have "∃a∈A. h`a=b" unfolding surj_def (*goal: ‹∃a::i∈A::i. (h::i) ` a = (b::i)›*) by blast then have "{a∈A. h`a=b} ≠ 0" by auto with assms (*‹well_ord(A, r)› ‹h ∈ surj(A, B)›*) show "minimum(r,{a∈A. h`a=b}) ∈ {a∈A. h`a=b}" using well_ord_imp_min (*‹⟦well_ord(?A, ?r); ?B ⊆ ?A; ?B ≠ 0⟧ ⟹ minimum(?r, ?B) ∈ ?B›*) by blast qed moreover from this (*‹?b ∈ B ⟹ minimum(r, {a ∈ A . h ` a = ?b}) ∈ {a ∈ A . h ` a = ?b}›*) have "?f : B → A" using lam_type[of B _ "λ_.A"] (*‹(⋀x. x ∈ B ⟹ ?b(x) ∈ A) ⟹ (λx∈B. ?b(x)) ∈ B → A›*) by simp moreover have "?f ` w = ?f ` x ⟹ w = x" if "w∈B" "x∈B" for w and x proof (-) (*goal: ‹(λb∈B. minimum(r, {a ∈ A . h ` a = b})) ` w = (λb∈B. minimum(r, {a ∈ A . h ` a = b})) ` x ⟹ w = x›*) from calculation(1)[OF that ( 1 )] (*‹minimum(r::i, {a::i ∈ A::i . (h::i) ` a = (w::i)}) ∈ {a::i ∈ A . h ` a = w}›*) calculation(1)[OF that ( 2 )] (*‹minimum(r::i, {a::i ∈ A::i . (h::i) ` a = (x::i)}) ∈ {a::i ∈ A . h ` a = x}›*) have "w = h ` minimum(r, {a ∈ A . h ` a = w})" "x = h ` minimum(r, {a ∈ A . h ` a = x})" apply - (*goals: 1. ‹⟦minimum(r, {a ∈ A . h ` a = w}) ∈ {a ∈ A . h ` a = w}; minimum(r, {a ∈ A . h ` a = x}) ∈ {a ∈ A . h ` a = x}⟧ ⟹ w = h ` minimum(r, {a ∈ A . h ` a = w})› 2. ‹⟦minimum(r, {a ∈ A . h ` a = w}) ∈ {a ∈ A . h ` a = w}; minimum(r, {a ∈ A . h ` a = x}) ∈ {a ∈ A . h ` a = x}⟧ ⟹ x = h ` minimum(r, {a ∈ A . h ` a = x})› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) . moreover assume "?f ` w = ?f ` x" (*‹(λb::i∈B::i. minimum(r::i, {a::i ∈ A::i . (h::i) ` a = b})) ` (w::i) = (λb::i∈B. minimum(r, {a::i ∈ A . h ` a = b})) ` (x::i)›*) moreover from this (*‹(λb::i∈B::i. minimum(r::i, {a::i ∈ A::i . (h::i) ` a = b})) ` (w::i) = (λb::i∈B. minimum(r, {a::i ∈ A . h ` a = b})) ` (x::i)›*) that (*‹w ∈ B› ‹x ∈ B›*) have "minimum(r, {a ∈ A . h ` a = w}) = minimum(r, {a ∈ A . h ` a = x})" by simp moreover from calculation(1,2,4) (*‹(w::i) = (h::i) ` minimum(r::i, {a::i ∈ A::i . h ` a = w})› ‹x = h ` minimum(r, {a ∈ A . h ` a = x})› ‹minimum(r, {a ∈ A . h ` a = w}) = minimum(r, {a ∈ A . h ` a = x})›*) show "w=x" by simp qed ultimately show "?thesis" (*goal: ‹B ≲ A›*) unfolding lepoll_def inj_def (*goal: ‹∃f. f ∈ {f ∈ B → A . ∀w∈B. ∀x∈B. f ` w = f ` x ⟶ w = x}›*) by blast qed lemma (in forcing_data) surj_nat_MG : "∃f. f ∈ surj(nat,M[G])" proof (-) (*goal: ‹∃f. f ∈ surj(nat, M[G])›*) let ?f = "λn∈nat. val(G,enum`n)" have "x ∈ nat ⟹ val(G, enum ` x)∈ M[G]" for x using GenExtD[THEN iffD2, of _ G] (*‹∃τ∈M. ?x1 = val(G, τ) ⟹ ?x1 ∈ M[G]›*) bij_is_fun[OF M_countable] (*‹enum ∈ nat → M›*) by force then have "?f: nat → M[G]" using lam_type[of nat "λn. val(G,enum`n)" "λ_.M[G]"] (*‹(⋀x. x ∈ nat ⟹ val(G, enum ` x) ∈ M[G]) ⟹ (λx∈nat. val(G, enum ` x)) ∈ nat → M[G]›*) by simp moreover have "∃n∈nat. ?f`n = x" if "x∈M[G]" for x using that (*‹x ∈ M[G]›*) GenExtD[of _ G] (*‹(?x::i) ∈ M[G::i] ⟷ (∃τ::i∈M::i. ?x = val(G, τ))›*) bij_is_surj[OF M_countable] (*‹enum ∈ surj(nat, M)›*) unfolding surj_def (*goal: ‹∃n::i∈nat. (λn::i∈nat. val(G::i, (enum::i) ` n)) ` n = (x::i)›*) by auto ultimately show "?thesis" (*goal: ‹∃f. f ∈ surj(nat, M[G])›*) unfolding surj_def (*goal: ‹∃f. f ∈ {f ∈ nat → M[G] . ∀y∈M[G]. ∃x∈nat. f ` x = y}›*) by blast qed lemma (in G_generic) MG_eqpoll_nat: "M[G] ≈ nat" proof (-) (*goal: ‹M[G::i] ≈ nat›*) interpret MG: M_ZF_trans "M[G]" using Transset_MG (*‹Transset(M[?G])›*) generic (*‹M_generic(G)›*) pairing_in_MG (*‹M_generic(?G) ⟹ upair_ax(##M[?G])›*) Union_MG (*‹M_generic(?G) ⟹ Union_ax(##M[?G])›*) extensionality_in_MG (*‹extensionality(##M[?G])›*) power_in_MG (*‹power_ax(##M[G::i])›*) foundation_in_MG (*‹foundation_ax(##M[?G])›*) strong_replacement_in_MG[simplified] (*‹⟦?φ ∈ formula; arity(?φ) ≤ succ(succ(natify(length(?env)))); ?env ∈ list(M[G])⟧ ⟹ strong_replacement(##M[G], λx v. M[G], Cons(x, Cons(v, ?env)) ⊨ ?φ)›*) separation_in_MG[simplified] (*‹⟦?φ ∈ formula; arity(?φ) ≤ succ(natify(length(?env))); ?env ∈ list(M[G])⟧ ⟹ separation(##M[G], λx. M[G], Cons(x, ?env) ⊨ ?φ)›*) infinity_in_MG (*‹infinity_ax(##M[G::i])›*) apply unfold_locales (*goals: 1. ‹⟦⋀G::i. Transset(M[G]); M_generic(G::i); ⋀G::i. M_generic(G) ⟹ upair_ax(##M[G]); ⋀G::i. M_generic(G) ⟹ Union_ax(##M[G]); ⋀G::i. extensionality(##M[G]); power_ax(##M[G]); ⋀G::i. foundation_ax(##M[G]); ⋀(φ::i) env::i. ⟦φ ∈ formula; arity(φ) ≤ succ(succ(natify(length(env)))); env ∈ list(M[G])⟧ ⟹ strong_replacement(##M[G], λ(x::i) v::i. M[G], Cons(x, Cons(v, env)) ⊨ φ); ⋀(φ::i) env::i. ⟦φ ∈ formula; arity(φ) ≤ succ(natify(length(env))); env ∈ list(M[G])⟧ ⟹ separation(##M[G], λx::i. M[G], Cons(x, env) ⊨ φ); infinity_ax(##M[G])⟧ ⟹ upair_ax(##M[G])› 2. ‹⟦⋀G::i. Transset(M[G]); M_generic(G::i); ⋀G::i. M_generic(G) ⟹ upair_ax(##M[G]); ⋀G::i. M_generic(G) ⟹ Union_ax(##M[G]); ⋀G::i. extensionality(##M[G]); power_ax(##M[G]); ⋀G::i. foundation_ax(##M[G]); ⋀(φ::i) env::i. ⟦φ ∈ formula; arity(φ) ≤ succ(succ(natify(length(env)))); env ∈ list(M[G])⟧ ⟹ strong_replacement(##M[G], λ(x::i) v::i. M[G], Cons(x, Cons(v, env)) ⊨ φ); ⋀(φ::i) env::i. ⟦φ ∈ formula; arity(φ) ≤ succ(natify(length(env))); env ∈ list(M[G])⟧ ⟹ separation(##M[G], λx::i. M[G], Cons(x, env) ⊨ φ); infinity_ax(##M[G])⟧ ⟹ Union_ax(##M[G])› 3. ‹⟦⋀G::i. Transset(M[G]); M_generic(G::i); ⋀G::i. M_generic(G) ⟹ upair_ax(##M[G]); ⋀G::i. M_generic(G) ⟹ Union_ax(##M[G]); ⋀G::i. extensionality(##M[G]); power_ax(##M[G]); ⋀G::i. foundation_ax(##M[G]); ⋀(φ::i) env::i. ⟦φ ∈ formula; arity(φ) ≤ succ(succ(natify(length(env)))); env ∈ list(M[G])⟧ ⟹ strong_replacement(##M[G], λ(x::i) v::i. M[G], Cons(x, Cons(v, env)) ⊨ φ); ⋀(φ::i) env::i. ⟦φ ∈ formula; arity(φ) ≤ succ(natify(length(env))); env ∈ list(M[G])⟧ ⟹ separation(##M[G], λx::i. M[G], Cons(x, env) ⊨ φ); infinity_ax(##M[G])⟧ ⟹ power_ax(##M[G])› 4. ‹⟦⋀G::i. Transset(M[G]); M_generic(G::i); ⋀G::i. M_generic(G) ⟹ upair_ax(##M[G]); ⋀G::i. M_generic(G) ⟹ Union_ax(##M[G]); ⋀G::i. extensionality(##M[G]); power_ax(##M[G]); ⋀G::i. foundation_ax(##M[G]); ⋀(φ::i) env::i. ⟦φ ∈ formula; arity(φ) ≤ succ(succ(natify(length(env)))); env ∈ list(M[G])⟧ ⟹ strong_replacement(##M[G], λ(x::i) v::i. M[G], Cons(x, Cons(v, env)) ⊨ φ); ⋀(φ::i) env::i. ⟦φ ∈ formula; arity(φ) ≤ succ(natify(length(env))); env ∈ list(M[G])⟧ ⟹ separation(##M[G], λx::i. M[G], Cons(x, env) ⊨ φ); infinity_ax(##M[G])⟧ ⟹ extensionality(##M[G])› 5. ‹⟦⋀G::i. Transset(M[G]); M_generic(G::i); ⋀G::i. M_generic(G) ⟹ upair_ax(##M[G]); ⋀G::i. M_generic(G) ⟹ Union_ax(##M[G]); ⋀G::i. extensionality(##M[G]); power_ax(##M[G]); ⋀G::i. foundation_ax(##M[G]); ⋀(φ::i) env::i. ⟦φ ∈ formula; arity(φ) ≤ succ(succ(natify(length(env)))); env ∈ list(M[G])⟧ ⟹ strong_replacement(##M[G], λ(x::i) v::i. M[G], Cons(x, Cons(v, env)) ⊨ φ); ⋀(φ::i) env::i. ⟦φ ∈ formula; arity(φ) ≤ succ(natify(length(env))); env ∈ list(M[G])⟧ ⟹ separation(##M[G], λx::i. M[G], Cons(x, env) ⊨ φ); infinity_ax(##M[G])⟧ ⟹ foundation_ax(##M[G])› 6. ‹⟦⋀G::i. Transset(M[G]); M_generic(G::i); ⋀G::i. M_generic(G) ⟹ upair_ax(##M[G]); ⋀G::i. M_generic(G) ⟹ Union_ax(##M[G]); ⋀G::i. extensionality(##M[G]); power_ax(##M[G]); ⋀G::i. foundation_ax(##M[G]); ⋀(φ::i) env::i. ⟦φ ∈ formula; arity(φ) ≤ succ(succ(natify(length(env)))); env ∈ list(M[G])⟧ ⟹ strong_replacement(##M[G], λ(x::i) v::i. M[G], Cons(x, Cons(v, env)) ⊨ φ); ⋀(φ::i) env::i. ⟦φ ∈ formula; arity(φ) ≤ succ(natify(length(env))); env ∈ list(M[G])⟧ ⟹ separation(##M[G], λx::i. M[G], Cons(x, env) ⊨ φ); infinity_ax(##M[G])⟧ ⟹ infinity_ax(##M[G])› 7. ‹⋀(φ::i) env::i. ⟦⋀G::i. Transset(M[G]); M_generic(G::i); ⋀G::i. M_generic(G) ⟹ upair_ax(##M[G]); ⋀G::i. M_generic(G) ⟹ Union_ax(##M[G]); ⋀G::i. extensionality(##M[G]); power_ax(##M[G]); ⋀G::i. foundation_ax(##M[G]); ⋀(φ::i) env::i. ⟦φ ∈ formula; arity(φ) ≤ succ(succ(natify(length(env)))); env ∈ list(M[G])⟧ ⟹ strong_replacement(##M[G], λ(x::i) v::i. M[G], Cons(x, Cons(v, env)) ⊨ φ); ⋀(φ::i) env::i. ⟦φ ∈ formula; arity(φ) ≤ succ(natify(length(env))); env ∈ list(M[G])⟧ ⟹ separation(##M[G], λx::i. M[G], Cons(x, env) ⊨ φ); infinity_ax(##M[G]); φ ∈ formula; env ∈ list(M[G]); arity(φ) ≤ 1 #+ length(env)⟧ ⟹ separation(##M[G], λx::i. M[G], [x] @ env ⊨ φ)› 8. ‹⋀(φ::i) env::i. ⟦⋀G::i. Transset(M[G]); M_generic(G::i); ⋀G::i. M_generic(G) ⟹ upair_ax(##M[G]); ⋀G::i. M_generic(G) ⟹ Union_ax(##M[G]); ⋀G::i. extensionality(##M[G]); power_ax(##M[G]); ⋀G::i. foundation_ax(##M[G]); ⋀(φ::i) env::i. ⟦φ ∈ formula; arity(φ) ≤ succ(succ(natify(length(env)))); env ∈ list(M[G])⟧ ⟹ strong_replacement(##M[G], λ(x::i) v::i. M[G], Cons(x, Cons(v, env)) ⊨ φ); ⋀(φ::i) env::i. ⟦φ ∈ formula; arity(φ) ≤ succ(natify(length(env))); env ∈ list(M[G])⟧ ⟹ separation(##M[G], λx::i. M[G], Cons(x, env) ⊨ φ); infinity_ax(##M[G]); φ ∈ formula; env ∈ list(M[G]); arity(φ) ≤ 2 #+ length(env)⟧ ⟹ strong_replacement(##M[G], λ(x::i) y::i. M[G], [x, y] @ env ⊨ φ)› 9. ‹⟦⋀G::i. Transset(M[G]); M_generic(G::i); ⋀G::i. M_generic(G) ⟹ upair_ax(##M[G]); ⋀G::i. M_generic(G) ⟹ Union_ax(##M[G]); ⋀G::i. extensionality(##M[G]); power_ax(##M[G]); ⋀G::i. foundation_ax(##M[G]); ⋀(φ::i) env::i. ⟦φ ∈ formula; arity(φ) ≤ succ(succ(natify(length(env)))); env ∈ list(M[G])⟧ ⟹ strong_replacement(##M[G], λ(x::i) v::i. M[G], Cons(x, Cons(v, env)) ⊨ φ); ⋀(φ::i) env::i. ⟦φ ∈ formula; arity(φ) ≤ succ(natify(length(env))); env ∈ list(M[G])⟧ ⟹ separation(##M[G], λx::i. M[G], Cons(x, env) ⊨ φ); infinity_ax(##M[G])⟧ ⟹ Transset(M[G])› 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 (*proven 9 subgoals*) . obtain f where "f ∈ surj(nat,M[G])" (*goal: ‹(⋀f. f ∈ surj(nat, M[G]) ⟹ thesis) ⟹ thesis›*) using surj_nat_MG (*‹∃f. f ∈ surj(nat, M[?G])›*) by blast then have "M[G] ≲ nat" using well_ord_surj_imp_lepoll (*‹⟦well_ord(?A, ?r); ?h ∈ surj(?A, ?B)⟧ ⟹ ?B ≲ ?A›*) well_ord_Memrel[of nat] (*‹Ord(nat) ⟹ well_ord(nat, Memrel(nat))›*) by simp moreover have "nat ≲ M[G]" using MG.nat_into_M (*‹?n ∈ nat ⟹ (##M[G])(?n)›*) subset_imp_lepoll (*‹?X ⊆ ?Y ⟹ ?X ≲ ?Y›*) by auto ultimately show "?thesis" (*goal: ‹M[G] ≈ nat›*) using eqpollI (*‹⟦?X ≲ ?Y; ?Y ≲ ?X⟧ ⟹ ?X ≈ ?Y›*) by simp qed subsection‹The main result› theorem extensions_of_ctms: assumes "M ≈ nat" "Transset(M)" "M ⊨ ZF" shows "∃N. M ⊆ N ∧ N ≈ nat ∧ Transset(N) ∧ N ⊨ ZF ∧ M≠N ∧ (∀α. Ord(α) ⟶ (α ∈ M ⟷ α ∈ N)) ∧ (M, []⊨ AC ⟶ N ⊨ ZFC)" proof (-) (*goal: ‹∃N. M ⊆ N ∧ N ≈ nat ∧ Transset(N) ∧ N ⊨ ZF ∧ M ≠ N ∧ (∀α. Ord(α) ⟶ α ∈ M ⟷ α ∈ N) ∧ (M, [] ⊨ ZF_choice_fm ⟶ N ⊨ ZFC)›*) from ‹M ≈ nat› (*‹M ≈ nat›*) obtain enum where "enum ∈ bij(nat,M)" (*goal: ‹(⋀enum::i. enum ∈ bij(nat, M::i) ⟹ thesis::o) ⟹ thesis›*) using eqpoll_sym (*‹?X ≈ ?Y ⟹ ?Y ≈ ?X›*) unfolding eqpoll_def (*goal: ‹(⋀enum. enum ∈ bij(nat, M) ⟹ thesis) ⟹ thesis›*) by blast with assms (*‹M ≈ nat› ‹Transset(M::i)› ‹M ⊨ ZF›*) interpret M_ctm M enum using M_ZF_iff_M_satT (*‹M_ZF(?M) ⟷ ?M ⊨ ZF›*) apply intro_locales (*goals: 1. ‹⟦M ≈ nat; Transset(M); M ⊨ ZF; enum ∈ bij(nat, M); ⋀M. M_ZF(M) ⟷ M ⊨ ZF⟧ ⟹ M_ZF(M)› 2. ‹⟦M ≈ nat; Transset(M); M ⊨ ZF; enum ∈ bij(nat, M); ⋀M. M_ZF(M) ⟷ M ⊨ ZF⟧ ⟹ M_ctm_axioms(M, enum)› discuss goal 1*) apply (simp add:M_ctm_axioms_def (*‹M_ctm_axioms(?M, ?enum) ≡ ?enum ∈ bij(nat, ?M) ∧ Transset(?M)›*)) (*discuss goal 2*) apply (simp add:M_ctm_axioms_def (*‹M_ctm_axioms(?M::i, ?enum::i) ≡ ?enum ∈ bij(nat, ?M) ∧ Transset(?M)›*)) (*proven 2 subgoals*) . interpret ctm_separative "2^<ω" seqle 0 M enum proof (unfold_locales) (*goals: 1. ‹2^<ω ∈ M› 2. ‹seqle ∈ M› 3. ‹⋀p. p ∈ 2^<ω ⟹ ∃q∈2^<ω. ∃r∈2^<ω. q ≼s p ∧ r ≼s p ∧ q ⊥s r›*) fix f let ?q = "seq_upd(f,0)" and ?r = "seq_upd(f,1)" assume "f ∈ 2^<ω" (*‹(f::i) ∈ 2^<ω›*) then have "?q ≼s f ∧ ?r ≼s f ∧ ?q ⊥s ?r" using upd_leI (*‹⟦?f ∈ 2^<ω; ?a ∈ 2⟧ ⟹ seq_upd(?f, ?a) ≼s ?f›*) seqspace_separative (*‹?f ∈ 2^<ω ⟹ seq_upd(?f, 0) ⊥s seq_upd(?f, 1)›*) by auto moreover from calculation (*‹seq_upd(f, 0) ≼s f ∧ seq_upd(f, 1) ≼s f ∧ seq_upd(f, 0) ⊥s seq_upd(f, 1)›*) have "?q ∈ 2^<ω" "?r ∈ 2^<ω" using seq_upd_type[of f 2] (*‹⟦f ∈ 2^<ω; ?a ∈ 2⟧ ⟹ seq_upd(f, ?a) ∈ 2^<ω›*) apply - (*goals: 1. ‹⟦seq_upd(f::i, 0) ≼s f ∧ seq_upd(f, 1) ≼s f ∧ seq_upd(f, 0) ⊥s seq_upd(f, 1); ⋀a::i. ⟦f ∈ 2^<ω; a ∈ 2⟧ ⟹ seq_upd(f, a) ∈ 2^<ω⟧ ⟹ seq_upd(f, 0) ∈ 2^<ω› 2. ‹⟦seq_upd(f::i, 0) ≼s f ∧ seq_upd(f, 1) ≼s f ∧ seq_upd(f, 0) ⊥s seq_upd(f, 1); ⋀a::i. ⟦f ∈ 2^<ω; a ∈ 2⟧ ⟹ seq_upd(f, a) ∈ 2^<ω⟧ ⟹ seq_upd(f, 1) ∈ 2^<ω› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . ultimately show "∃q∈2^<ω. ∃r∈2^<ω. q ≼s f ∧ r ≼s f ∧ q ⊥s r" apply (rule_tac bexI (*‹⟦(?P::i ⇒ o)(?x::i); ?x ∈ (?A::i)⟧ ⟹ ∃x::i∈?A. ?P(x)›*)) (*goals: 1. ‹⟦seq_upd(f, 0) ≼s f ∧ seq_upd(f, 1) ≼s f ∧ seq_upd(f, 0) ⊥s seq_upd(f, 1); seq_upd(f, 0) ∈ 2^<ω; seq_upd(f, 1) ∈ 2^<ω⟧ ⟹ ∃r∈2^<ω. ?q3 ≼s f ∧ r ≼s f ∧ ?q3 ⊥s r› 2. ‹⟦seq_upd(f, 0) ≼s f ∧ seq_upd(f, 1) ≼s f ∧ seq_upd(f, 0) ⊥s seq_upd(f, 1); seq_upd(f, 0) ∈ 2^<ω; seq_upd(f, 1) ∈ 2^<ω⟧ ⟹ ?q3 ∈ 2^<ω› discuss goal 1*) apply (rule_tac bexI (*‹⟦?P(?x); ?x ∈ ?A⟧ ⟹ ∃x∈?A. ?P(x)›*)) (*goals: 1. ‹⟦seq_upd(f, 0) ≼s f ∧ seq_upd(f, 1) ≼s f ∧ seq_upd(f, 0) ⊥s seq_upd(f, 1); seq_upd(f, 0) ∈ 2^<ω; seq_upd(f, 1) ∈ 2^<ω⟧ ⟹ ?q3 ≼s f ∧ ?r4 ≼s f ∧ ?q3 ⊥s ?r4› 2. ‹⟦seq_upd(f, 0) ≼s f ∧ seq_upd(f, 1) ≼s f ∧ seq_upd(f, 0) ⊥s seq_upd(f, 1); seq_upd(f, 0) ∈ 2^<ω; seq_upd(f, 1) ∈ 2^<ω⟧ ⟹ ?r4 ∈ 2^<ω› discuss goal 1*) apply ((assumption)[1]) (*discuss goal 2*) apply ((assumption)[1]) (*proven 2 subgoals*) (*discuss goal 2*) . (*proven 2 subgoals*) next (*goals: 1. ‹2^<ω ∈ M› 2. ‹seqle ∈ M›*) show "2^<ω ∈ M" using nat_into_M (*‹(?n::i) ∈ nat ⟹ (##(M::i))(?n)›*) seqspace_closed (*‹(##M)(?B) ⟹ (##M)(?B^<ω)›*) by simp next (*goal: ‹seqle ∈ (M::i)›*) show "seqle ∈ M" using seqle_in_M (*‹seqle ∈ (M::i)›*) . qed from cohen_extension_is_proper (*‹∃G. M_generic(G) ∧ M ≠ GenExt(G)›*) obtain G where "M_generic(G)" "M ≠ GenExt(G)" (is "M≠?N") (*goal: ‹(⋀G. ⟦M_generic(G); M ≠ GenExt(G)⟧ ⟹ thesis) ⟹ thesis›*) by blast then interpret G_generic "2^<ω" seqle 0 _ enum G by unfold_locales interpret MG: M_ZF "?N" using generic (*‹M_generic(G)›*) pairing_in_MG (*‹M_generic(?G) ⟹ upair_ax(##GenExt(?G))›*) Union_MG (*‹M_generic(?G) ⟹ Union_ax(##GenExt(?G))›*) extensionality_in_MG (*‹extensionality(##GenExt(?G))›*) power_in_MG (*‹power_ax(##GenExt(G))›*) foundation_in_MG (*‹foundation_ax(##GenExt(?G))›*) strong_replacement_in_MG[simplified] (*‹⟦?φ ∈ formula; arity(?φ) ≤ succ(succ(natify(length(?env)))); ?env ∈ list(GenExt(G))⟧ ⟹ strong_replacement(##GenExt(G), λx v. GenExt(G), Cons(x, Cons(v, ?env)) ⊨ ?φ)›*) separation_in_MG[simplified] (*‹⟦?φ ∈ formula; arity(?φ) ≤ succ(natify(length(?env))); ?env ∈ list(GenExt(G))⟧ ⟹ separation(##GenExt(G), λx. GenExt(G), Cons(x, ?env) ⊨ ?φ)›*) infinity_in_MG (*‹infinity_ax(##GenExt(G))›*) apply unfold_locales (*goals: 1. ‹⟦M_generic(G); ⋀G. M_generic(G) ⟹ upair_ax(##GenExt(G)); ⋀G. M_generic(G) ⟹ Union_ax(##GenExt(G)); ⋀G. extensionality(##GenExt(G)); power_ax(##GenExt(G)); ⋀G. foundation_ax(##GenExt(G)); ⋀φ env. ⟦φ ∈ formula; arity(φ) ≤ succ(succ(natify(length(env)))); env ∈ list(GenExt(G))⟧ ⟹ strong_replacement(##GenExt(G), λx v. GenExt(G), Cons(x, Cons(v, env)) ⊨ φ); ⋀φ env. ⟦φ ∈ formula; arity(φ) ≤ succ(natify(length(env))); env ∈ list(GenExt(G))⟧ ⟹ separation(##GenExt(G), λx. GenExt(G), Cons(x, env) ⊨ φ); infinity_ax(##GenExt(G))⟧ ⟹ upair_ax(##GenExt(G))› 2. ‹⟦M_generic(G); ⋀G. M_generic(G) ⟹ upair_ax(##GenExt(G)); ⋀G. M_generic(G) ⟹ Union_ax(##GenExt(G)); ⋀G. extensionality(##GenExt(G)); power_ax(##GenExt(G)); ⋀G. foundation_ax(##GenExt(G)); ⋀φ env. ⟦φ ∈ formula; arity(φ) ≤ succ(succ(natify(length(env)))); env ∈ list(GenExt(G))⟧ ⟹ strong_replacement(##GenExt(G), λx v. GenExt(G), Cons(x, Cons(v, env)) ⊨ φ); ⋀φ env. ⟦φ ∈ formula; arity(φ) ≤ succ(natify(length(env))); env ∈ list(GenExt(G))⟧ ⟹ separation(##GenExt(G), λx. GenExt(G), Cons(x, env) ⊨ φ); infinity_ax(##GenExt(G))⟧ ⟹ Union_ax(##GenExt(G))› 3. ‹⟦M_generic(G); ⋀G. M_generic(G) ⟹ upair_ax(##GenExt(G)); ⋀G. M_generic(G) ⟹ Union_ax(##GenExt(G)); ⋀G. extensionality(##GenExt(G)); power_ax(##GenExt(G)); ⋀G. foundation_ax(##GenExt(G)); ⋀φ env. ⟦φ ∈ formula; arity(φ) ≤ succ(succ(natify(length(env)))); env ∈ list(GenExt(G))⟧ ⟹ strong_replacement(##GenExt(G), λx v. GenExt(G), Cons(x, Cons(v, env)) ⊨ φ); ⋀φ env. ⟦φ ∈ formula; arity(φ) ≤ succ(natify(length(env))); env ∈ list(GenExt(G))⟧ ⟹ separation(##GenExt(G), λx. GenExt(G), Cons(x, env) ⊨ φ); infinity_ax(##GenExt(G))⟧ ⟹ power_ax(##GenExt(G))› 4. ‹⟦M_generic(G); ⋀G. M_generic(G) ⟹ upair_ax(##GenExt(G)); ⋀G. M_generic(G) ⟹ Union_ax(##GenExt(G)); ⋀G. extensionality(##GenExt(G)); power_ax(##GenExt(G)); ⋀G. foundation_ax(##GenExt(G)); ⋀φ env. ⟦φ ∈ formula; arity(φ) ≤ succ(succ(natify(length(env)))); env ∈ list(GenExt(G))⟧ ⟹ strong_replacement(##GenExt(G), λx v. GenExt(G), Cons(x, Cons(v, env)) ⊨ φ); ⋀φ env. ⟦φ ∈ formula; arity(φ) ≤ succ(natify(length(env))); env ∈ list(GenExt(G))⟧ ⟹ separation(##GenExt(G), λx. GenExt(G), Cons(x, env) ⊨ φ); infinity_ax(##GenExt(G))⟧ ⟹ extensionality(##GenExt(G))› 5. ‹⟦M_generic(G); ⋀G. M_generic(G) ⟹ upair_ax(##GenExt(G)); ⋀G. M_generic(G) ⟹ Union_ax(##GenExt(G)); ⋀G. extensionality(##GenExt(G)); power_ax(##GenExt(G)); ⋀G. foundation_ax(##GenExt(G)); ⋀φ env. ⟦φ ∈ formula; arity(φ) ≤ succ(succ(natify(length(env)))); env ∈ list(GenExt(G))⟧ ⟹ strong_replacement(##GenExt(G), λx v. GenExt(G), Cons(x, Cons(v, env)) ⊨ φ); ⋀φ env. ⟦φ ∈ formula; arity(φ) ≤ succ(natify(length(env))); env ∈ list(GenExt(G))⟧ ⟹ separation(##GenExt(G), λx. GenExt(G), Cons(x, env) ⊨ φ); infinity_ax(##GenExt(G))⟧ ⟹ foundation_ax(##GenExt(G))› 6. ‹⟦M_generic(G); ⋀G. M_generic(G) ⟹ upair_ax(##GenExt(G)); ⋀G. M_generic(G) ⟹ Union_ax(##GenExt(G)); ⋀G. extensionality(##GenExt(G)); power_ax(##GenExt(G)); ⋀G. foundation_ax(##GenExt(G)); ⋀φ env. ⟦φ ∈ formula; arity(φ) ≤ succ(succ(natify(length(env)))); env ∈ list(GenExt(G))⟧ ⟹ strong_replacement(##GenExt(G), λx v. GenExt(G), Cons(x, Cons(v, env)) ⊨ φ); ⋀φ env. ⟦φ ∈ formula; arity(φ) ≤ succ(natify(length(env))); env ∈ list(GenExt(G))⟧ ⟹ separation(##GenExt(G), λx. GenExt(G), Cons(x, env) ⊨ φ); infinity_ax(##GenExt(G))⟧ ⟹ infinity_ax(##GenExt(G))› 7. ‹⋀φ env. ⟦M_generic(G); ⋀G. M_generic(G) ⟹ upair_ax(##GenExt(G)); ⋀G. M_generic(G) ⟹ Union_ax(##GenExt(G)); ⋀G. extensionality(##GenExt(G)); power_ax(##GenExt(G)); ⋀G. foundation_ax(##GenExt(G)); ⋀φ env. ⟦φ ∈ formula; arity(φ) ≤ succ(succ(natify(length(env)))); env ∈ list(GenExt(G))⟧ ⟹ strong_replacement(##GenExt(G), λx v. GenExt(G), Cons(x, Cons(v, env)) ⊨ φ); ⋀φ env. ⟦φ ∈ formula; arity(φ) ≤ succ(natify(length(env))); env ∈ list(GenExt(G))⟧ ⟹ separation(##GenExt(G), λx. GenExt(G), Cons(x, env) ⊨ φ); infinity_ax(##GenExt(G)); φ ∈ formula; env ∈ list(GenExt(G)); arity(φ) ≤ 1 #+ length(env)⟧ ⟹ separation(##GenExt(G), λx. GenExt(G), [x] @ env ⊨ φ)› 8. ‹⋀φ env. ⟦M_generic(G); ⋀G. M_generic(G) ⟹ upair_ax(##GenExt(G)); ⋀G. M_generic(G) ⟹ Union_ax(##GenExt(G)); ⋀G. extensionality(##GenExt(G)); power_ax(##GenExt(G)); ⋀G. foundation_ax(##GenExt(G)); ⋀φ env. ⟦φ ∈ formula; arity(φ) ≤ succ(succ(natify(length(env)))); env ∈ list(GenExt(G))⟧ ⟹ strong_replacement(##GenExt(G), λx v. GenExt(G), Cons(x, Cons(v, env)) ⊨ φ); ⋀φ env. ⟦φ ∈ formula; arity(φ) ≤ succ(natify(length(env))); env ∈ list(GenExt(G))⟧ ⟹ separation(##GenExt(G), λx. GenExt(G), Cons(x, env) ⊨ φ); infinity_ax(##GenExt(G)); φ ∈ formula; env ∈ list(GenExt(G)); arity(φ) ≤ 2 #+ length(env)⟧ ⟹ strong_replacement(##GenExt(G), λx y. GenExt(G), [x, y] @ env ⊨ φ)› 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*) . have "?N ⊨ ZF" using M_ZF_iff_M_satT[of ?N] (*‹M_ZF(GenExt(G)) ⟷ GenExt(G) ⊨ ZF›*) MG.M_ZF_axioms (*‹M_ZF(GenExt(G))›*) by simp moreover have "M, []⊨ AC ⟹ ?N ⊨ ZFC" proof (-) (*goal: ‹M, [] ⊨ ZF_choice_fm ⟹ GenExt(G) ⊨ ZFC›*) assume "M, [] ⊨ AC" (*‹(M::i), [] ⊨ ZF_choice_fm›*) then have "choice_ax(##M)" unfolding ZF_choice_fm_def (*goal: ‹choice_ax(##M)›*) using ZF_choice_auto (*‹choice_ax(##?A) ⟷ ?A, [] ⊨ Forall(Exists(And(ordinal_fm(0), Exists(surjection_fm(1, 2, 0)))))›*) by simp then have "choice_ax(##?N)" using choice_in_MG (*‹choice_ax(##M) ⟹ choice_ax(##GenExt(G))›*) by simp with ‹?N ⊨ ZF› (*‹GenExt(G) ⊨ ZF›*) show "?N ⊨ ZFC" using ZF_choice_auto (*‹choice_ax(##?A) ⟷ ?A, [] ⊨ Forall(Exists(And(ordinal_fm(0), Exists(surjection_fm(1, 2, 0)))))›*) sats_ZFC_iff_sats_ZF_AC (*‹(?N::i) ⊨ ZFC ⟷ ?N ⊨ ZF ∧ ?N, [] ⊨ ZF_choice_fm›*) unfolding ZF_choice_fm_def (*goal: ‹GenExt(G::i) ⊨ ZFC›*) by simp qed moreover note ‹M ≠ ?N› (*‹(M::i) ≠ GenExt(G::i)›*) moreover have "Transset(?N)" using Transset_MG (*‹Transset(GenExt(?G))›*) . moreover have "M ⊆ ?N" using M_subset_MG[OF one_in_G] (*‹M_generic(?G) ⟹ M ⊆ GenExt(?G)›*) generic (*‹M_generic(G)›*) by simp ultimately show "?thesis" (*goal: ‹∃N. M ⊆ N ∧ N ≈ nat ∧ Transset(N) ∧ N ⊨ ZF ∧ M ≠ N ∧ (∀α. Ord(α) ⟶ α ∈ M ⟷ α ∈ N) ∧ (M, [] ⊨ ZF_choice_fm ⟶ N ⊨ ZFC)›*) using Ord_MG_iff (*‹Ord(?α) ⟹ ?α ∈ M ⟷ ?α ∈ GenExt(G)›*) MG_eqpoll_nat (*‹GenExt(G) ≈ nat›*) apply (rule_tac x="?N" in exI (*‹?P(?x) ⟹ ∃x. ?P(x)›*)) (*goal: ‹∃N. M ⊆ N ∧ N ≈ nat ∧ Transset(N) ∧ N ⊨ ZF ∧ M ≠ N ∧ (∀α. Ord(α) ⟶ α ∈ M ⟷ α ∈ N) ∧ (M, [] ⊨ ZF_choice_fm ⟶ N ⊨ ZFC)›*) by simp qed end
{ "path": "afp-2025-02-12/thys/Forcing/Forcing_Main.thy", "repo": "afp-2025-02-12", "sha": "73c78e26c5e72cc5c455ce9ba942a89a1e60c6fad630350aa8581b064c86b1eb" }
theory EtaExpansion imports Launchbury.Terms Launchbury.Substitution begin definition fresh_var :: "exp ⇒ var" where "fresh_var e = (SOME v. v ∉ fv e)" lemma fresh_var_not_free: "fresh_var e ∉ fv e" proof (-) (*goal: ‹fresh_var e ∉ fv e›*) obtain v :: var where "atom v ♯ e" (*goal: ‹(⋀v::Vars.var. atom v ♯ (e::exp) ⟹ thesis::bool) ⟹ thesis›*) by (rule obtain_fresh (*‹(⋀a::?'a::at_base. atom a ♯ (?x::?'b::fs) ⟹ ?thesis::bool) ⟹ ?thesis›*)) hence "v ∉ fv e" by (metis fv_not_fresh (*‹atom ?x ♯ ?e = (?x ∉ fv ?e)›*)) thus "?thesis" (*goal: ‹fresh_var e ∉ fv e›*) unfolding fresh_var_def (*goal: ‹(SOME v. v ∉ fv e) ∉ fv e›*) by (rule someI (*‹?P ?x ⟹ ?P (Eps ?P)›*)) qed lemma fresh_var_fresh[simp]: "atom (fresh_var e) ♯ e" by (metis fresh_var_not_free (*‹fresh_var ?e ∉ fv ?e›*) fv_not_fresh (*‹atom ?x ♯ ?e = (?x ∉ fv ?e)›*)) lemma fresh_var_subst[simp]: "e[fresh_var e::=x] = e" by (metis fresh_var_fresh (*‹atom (fresh_var (?e::exp)) ♯ ?e›*) subst_fresh_noop (*‹atom (?x::Vars.var) ♯ (?e::exp) ⟹ ?e[?x::=(?y::Vars.var)] = ?e›*)) fun eta_expand :: "nat ⇒ exp ⇒ exp" where "eta_expand 0 e = e" | "eta_expand (Suc n) e = (Lam [fresh_var e]. eta_expand n (App e (fresh_var e)))" lemma eta_expand_eqvt[eqvt]: "π ∙ (eta_expand n e) = eta_expand (π ∙ n) (π ∙ e)" apply (induction n arbitrary: e π) (*goals: 1. ‹⋀e π. π ∙ eta_expand 0 e = eta_expand (π ∙ 0) (π ∙ e)› 2. ‹⋀n e π. (⋀e π. π ∙ eta_expand n e = eta_expand (π ∙ n) (π ∙ e)) ⟹ π ∙ eta_expand (Suc n) e = eta_expand (π ∙ Suc n) (π ∙ e)› discuss goal 1*) apply ((auto simp add: fresh_Pair (*‹?a ♯ (?x, ?y) = (?a ♯ ?x ∧ ?a ♯ ?y)›*) permute_pure (*‹?p ∙ ?x = ?x›*))[1]) (*discuss goal 2*) apply ((auto simp add: fresh_Pair (*‹?a ♯ (?x, ?y) = (?a ♯ ?x ∧ ?a ♯ ?y)›*) permute_pure (*‹?p ∙ ?x = ?x›*))[1]) (*goal: ‹⋀n e π. (⋀e π. π ∙ eta_expand n e = eta_expand (π ∙ n) (π ∙ e)) ⟹ π ∙ eta_expand (Suc n) e = eta_expand (π ∙ Suc n) (π ∙ e)›*) apply (metis fresh_at_base_permI (*‹atom (?a::?'a) ♯ (?p::perm) ⟹ ?p ∙ ?a = ?a›*) fresh_at_base_permute_iff (*‹atom ((?p::perm) ∙ (?a::?'a)) ♯ ?p ∙ (?x::?'b) = atom ?a ♯ ?x›*) fresh_var_fresh (*‹atom (fresh_var (?e::exp)) ♯ ?e›*) subst_fresh_noop (*‹atom (?x::Vars.var) ♯ (?e::exp) ⟹ ?e[?x::=(?y::Vars.var)] = ?e›*) subst_swap_same (*‹atom (?x::Vars.var) ♯ (?e::exp) ⟹ (?x ↔ ?y::Vars.var) ∙ ?e = ?e[?y::=?x]›*)) (*proven 2 subgoals*) . lemma fresh_eta_expand[simp]: "a ♯ eta_expand n e ⟷ a ♯ e" apply (induction n arbitrary: e) (*goals: 1. ‹⋀e. a ♯ eta_expand 0 e = a ♯ e› 2. ‹⋀n e. (⋀e. a ♯ eta_expand n e = a ♯ e) ⟹ a ♯ eta_expand (Suc n) e = a ♯ e› discuss goal 1*) apply (simp add: fresh_Pair (*‹?a ♯ (?x, ?y) = (?a ♯ ?x ∧ ?a ♯ ?y)›*)) (*discuss goal 2*) apply (clarsimp simp add: fresh_Pair (*‹?a ♯ (?x, ?y) = (?a ♯ ?x ∧ ?a ♯ ?y)›*) fresh_at_base (*‹sort_of ?a ≠ sort_of (atom ?b) ⟹ ?a ♯ ?b› ‹?a ♯ ?b = (?a ≠ atom ?b)›*)) (*goal: ‹⋀(n::nat) e::exp. (⋀e::exp. (a::atom) ♯ eta_expand n e = a ♯ e) ⟹ a ♯ eta_expand (Suc n) e = a ♯ e›*) apply (metis fresh_var_fresh (*‹atom (fresh_var ?e) ♯ ?e›*)) (*proven 2 subgoals*) . lemma subst_eta_expand: "(eta_expand n e)[x ::= y] = eta_expand n (e[x ::= y])" proof (induction n arbitrary: e) (*goals: 1. ‹⋀e. (eta_expand 0 e)[x::=y] = eta_expand 0 e[x::=y]› 2. ‹⋀n e. (⋀e. (eta_expand n e)[x::=y] = eta_expand n e[x::=y]) ⟹ (eta_expand (Suc n) e)[x::=y] = eta_expand (Suc n) e[x::=y]›*) case 0 (*no hyothesis introduced yet*) thus "?case" (*goal: ‹(eta_expand 0 e)[x::=y] = eta_expand 0 e[x::=y]›*) by simp next (*goal: ‹⋀n e. (⋀e. (eta_expand n e)[x::=y] = eta_expand n e[x::=y]) ⟹ (eta_expand (Suc n) e)[x::=y] = eta_expand (Suc n) e[x::=y]›*) case (Suc n) (*‹(eta_expand n ?e)[x::=y] = eta_expand n ?e[x::=y]›*) obtain z :: var where "atom z ♯ (e, fresh_var e, x, y)" (*goal: ‹(⋀z. atom z ♯ (e, fresh_var e, x, y) ⟹ thesis) ⟹ thesis›*) by (rule obtain_fresh (*‹(⋀a. atom a ♯ ?x ⟹ ?thesis) ⟹ ?thesis›*)) have "(eta_expand (Suc n) e)[x::=y] = (Lam [fresh_var e]. eta_expand n (App e (fresh_var e)))[x::=y]" by simp also (*calculation: ‹(eta_expand (Suc n) e)[x::=y] = (Lam [fresh_var e]. eta_expand n (App e (fresh_var e)))[x::=y]›*) have "… = (Lam [z]. eta_expand n (App e z))[x::=y]" apply (subst change_Lam_Variable[where y' = z] (*‹(z ≠ ?y ⟹ atom z ♯ (?e, ?y)) ⟹ Lam [?y]. ?e = Lam [z]. ((?y ↔ z) ∙ ?e)›*)) (*goal: ‹(Lam [fresh_var e]. eta_expand n (App e (fresh_var e)))[x::=y] = (Lam [z]. eta_expand n (App e z))[x::=y]›*) using ‹atom z ♯ _› (*‹atom z ♯ (e, fresh_var e, x, y)›*) apply - (*goals: 1. ‹⟦z ≠ fresh_var e; atom z ♯ (e, fresh_var e, x, y)⟧ ⟹ atom z ♯ (eta_expand n (App e (fresh_var e)), fresh_var e)› 2. ‹atom z ♯ (e, fresh_var e, x, y) ⟹ (Lam [z]. ((fresh_var e ↔ z) ∙ eta_expand n (App e (fresh_var e))))[x::=y] = (Lam [z]. eta_expand n (App e z))[x::=y]› discuss goal 1*) apply ((auto simp add: fresh_Pair (*‹?a ♯ (?x, ?y) = (?a ♯ ?x ∧ ?a ♯ ?y)›*) eta_expand_eqvt (*‹?π ∙ eta_expand ?n ?e = eta_expand (?π ∙ ?n) (?π ∙ ?e)›*) pure_fresh (*‹?a ♯ ?x›*) permute_pure (*‹?p ∙ ?x = ?x›*) flip_fresh_fresh (*‹⟦atom ?a ♯ ?x; atom ?b ♯ ?x⟧ ⟹ (?a ↔ ?b) ∙ ?x = ?x›*) intro!: eqvt_fresh_cong2[where f = eta_expand, OF eta_expand_eqvt] (*‹⟦?a ♯ ?x; ?a ♯ ?y⟧ ⟹ ?a ♯ eta_expand ?x ?y›*))[1]) (*discuss goal 2*) apply ((auto simp add: fresh_Pair (*‹(?a::atom) ♯ (?x::?'a::pt, ?y::?'b::pt) = (?a ♯ ?x ∧ ?a ♯ ?y)›*) eta_expand_eqvt (*‹(?π::perm) ∙ eta_expand (?n::nat) (?e::exp) = eta_expand (?π ∙ ?n) (?π ∙ ?e)›*) pure_fresh (*‹(?a::atom) ♯ (?x::?'a::pure)›*) permute_pure (*‹(?p::perm) ∙ (?x::?'a::pure) = ?x›*) flip_fresh_fresh (*‹⟦atom (?a::?'b::at_base) ♯ (?x::?'a::pt); atom (?b::?'b::at_base) ♯ ?x⟧ ⟹ (?a ↔ ?b) ∙ ?x = ?x›*) intro!: eqvt_fresh_cong2[where f = eta_expand, OF eta_expand_eqvt] (*‹⟦(?a::atom) ♯ (?x::nat); ?a ♯ (?y::exp)⟧ ⟹ ?a ♯ eta_expand ?x ?y›*))[1]) (*proven 2 subgoals*) . also (*calculation: ‹(eta_expand (Suc n) e)[x::=y] = (Lam [z]. eta_expand n (App e z))[x::=y]›*) have "… = Lam [z]. (eta_expand n (App e z))[x::=y]" using ‹atom z ♯ _› (*‹atom z ♯ (e, fresh_var e, x, y)›*) by simp also (*calculation: ‹(eta_expand (Suc n) e)[x::=y] = Lam [z]. (eta_expand n (App e z))[x::=y]›*) have "… = Lam [z]. eta_expand n (App e z)[x::=y]" unfolding Suc.IH (*goal: ‹Lam [(z::Vars.var)]. eta_expand (n::nat) (App (e::exp) z)[(x::Vars.var)::=(y::Vars.var)] = Lam [z]. eta_expand n (App e z)[x::=y]›*) by standard also (*calculation: ‹(eta_expand (Suc n) e)[x::=y] = Lam [z]. eta_expand n (App e z)[x::=y]›*) have "… = Lam [z]. eta_expand n (App e[x::=y] z)" using ‹atom z ♯ _› (*‹atom (z::Vars.var) ♯ (e::exp, fresh_var e, x::Vars.var, y::Vars.var)›*) by simp also (*calculation: ‹(eta_expand (Suc n) e)[x::=y] = Lam [z]. eta_expand n (App e[x::=y] z)›*) have "… = Lam [fresh_var (e[x::=y])]. eta_expand n (App e[x::=y] (fresh_var (e[x::=y])))" apply (subst change_Lam_Variable[where y' = "fresh_var (e[x::=y])"] (*‹(fresh_var (e::exp)[(x::Vars.var)::=(y::Vars.var)] ≠ (?y::Vars.var) ⟹ atom (fresh_var e[x::=y]) ♯ (?e::exp, ?y)) ⟹ Lam [?y]. ?e = Lam [fresh_var e[x::=y]]. ((?y ↔ fresh_var e[x::=y]) ∙ ?e)›*)) (*goal: ‹Lam [z]. eta_expand n (App e[x::=y] z) = Lam [fresh_var e[x::=y]]. eta_expand n (App e[x::=y] (fresh_var e[x::=y]))›*) using ‹atom z ♯ _› (*‹atom z ♯ (e, fresh_var e, x, y)›*) apply - (*goals: 1. ‹⟦fresh_var e[x::=y] ≠ z; atom z ♯ (e, fresh_var e, x, y)⟧ ⟹ atom (fresh_var e[x::=y]) ♯ (eta_expand n (App e[x::=y] z), z)› 2. ‹atom z ♯ (e, fresh_var e, x, y) ⟹ Lam [fresh_var e[x::=y]]. ((z ↔ fresh_var e[x::=y]) ∙ eta_expand n (App e[x::=y] z)) = Lam [fresh_var e[x::=y]]. eta_expand n (App e[x::=y] (fresh_var e[x::=y]))› discuss goal 1*) apply ((auto simp add: fresh_Pair (*‹?a ♯ (?x, ?y) = (?a ♯ ?x ∧ ?a ♯ ?y)›*) eqvt_fresh_cong2[where f = eta_expand, OF eta_expand_eqvt] (*‹⟦?a ♯ ?x; ?a ♯ ?y⟧ ⟹ ?a ♯ eta_expand ?x ?y›*) pure_fresh (*‹?a ♯ ?x›*) eta_expand_eqvt (*‹?π ∙ eta_expand ?n ?e = eta_expand (?π ∙ ?n) (?π ∙ ?e)›*) flip_fresh_fresh (*‹⟦atom ?a ♯ ?x; atom ?b ♯ ?x⟧ ⟹ (?a ↔ ?b) ∙ ?x = ?x›*) subst_pres_fresh (*‹⟦atom ?x ♯ ?e ∨ ?x = ?y; atom ?x ♯ ?z⟧ ⟹ atom ?x ♯ ?e[?y::=?z]›*) simp del: exp_assn.eq_iff (*‹(Var ?var = Var ?vara) = (?var = ?vara)› ‹(App ?exp ?var = App ?expa ?vara) = (?exp = ?expa ∧ ?var = ?vara)› ‹(LetA ?assn ?exp = LetA ?assna ?expa) = ([bn ?assn]lst. (?exp, ?assn) = [bn ?assna]lst. (?expa, ?assna))› ‹(Lam [?var]. ?exp = Lam [?vara]. ?expa) = ([[atom ?var]]lst. ?exp = [[atom ?vara]]lst. ?expa)› ‹(Bool ?bool = Bool ?boola) = (?bool = ?boola)› ‹((?exp1.0 ? ?exp2.0 : ?exp3.0) = (?exp1a ? ?exp2a : ?exp3a)) = (?exp1.0 = ?exp1a ∧ ?exp2.0 = ?exp2a ∧ ?exp3.0 = ?exp3a)› ‹(ANil = ANil) = True› ‹(ACons ?var ?exp ?assn = ACons ?vara ?expa ?assna) = (?var = ?vara ∧ ?exp = ?expa ∧ ?assn = ?assna)› ‹alpha_bn ANil ANil = True› ‹alpha_bn (ACons ?var ?exp ?assn) (ACons ?vara ?expa ?assna) = (?exp = ?expa ∧ alpha_bn ?assn ?assna)›*))[1]) (*discuss goal 2*) apply ((auto simp add: fresh_Pair (*‹(?a::atom) ♯ (?x::?'a, ?y::?'b) = (?a ♯ ?x ∧ ?a ♯ ?y)›*) eqvt_fresh_cong2[where f = eta_expand, OF eta_expand_eqvt] (*‹⟦(?a::atom) ♯ (?x::nat); ?a ♯ (?y::exp)⟧ ⟹ ?a ♯ eta_expand ?x ?y›*) pure_fresh (*‹(?a::atom) ♯ (?x::?'a)›*) eta_expand_eqvt (*‹(?π::perm) ∙ eta_expand (?n::nat) (?e::exp) = eta_expand (?π ∙ ?n) (?π ∙ ?e)›*) flip_fresh_fresh (*‹⟦atom (?a::?'b) ♯ (?x::?'a); atom (?b::?'b) ♯ ?x⟧ ⟹ (?a ↔ ?b) ∙ ?x = ?x›*) subst_pres_fresh (*‹⟦atom (?x::Vars.var) ♯ (?e::exp) ∨ ?x = (?y::Vars.var); atom ?x ♯ (?z::Vars.var)⟧ ⟹ atom ?x ♯ ?e[?y::=?z]›*) simp del: exp_assn.eq_iff (*‹(Var (?var::Vars.var) = Var (?vara::Vars.var)) = (?var = ?vara)› ‹(App (?exp::exp) (?var::Vars.var) = App (?expa::exp) (?vara::Vars.var)) = (?exp = ?expa ∧ ?var = ?vara)› ‹(LetA (?assn::assn) (?exp::exp) = LetA (?assna::assn) (?expa::exp)) = ([bn ?assn]lst. (?exp, ?assn) = [bn ?assna]lst. (?expa, ?assna))› ‹(Lam [(?var::Vars.var)]. (?exp::exp) = Lam [(?vara::Vars.var)]. (?expa::exp)) = ([[atom ?var]]lst. ?exp = [[atom ?vara]]lst. ?expa)› ‹(Bool (?bool::bool) = Bool (?boola::bool)) = (?bool = ?boola)› ‹((?exp1.0::exp ? ?exp2.0::exp : (?exp3.0::exp)) = (?exp1a::exp ? ?exp2a::exp : (?exp3a::exp))) = (?exp1.0 = ?exp1a ∧ ?exp2.0 = ?exp2a ∧ ?exp3.0 = ?exp3a)› ‹(ANil = ANil) = True› ‹(ACons (?var::Vars.var) (?exp::exp) (?assn::assn) = ACons (?vara::Vars.var) (?expa::exp) (?assna::assn)) = (?var = ?vara ∧ ?exp = ?expa ∧ ?assn = ?assna)› ‹alpha_bn ANil ANil = True› ‹alpha_bn (ACons (?var::Vars.var) (?exp::exp) (?assn::assn)) (ACons (?vara::Vars.var) (?expa::exp) (?assna::assn)) = (?exp = ?expa ∧ alpha_bn ?assn ?assna)›*))[1]) (*proven 2 subgoals*) . also (*calculation: ‹(eta_expand (Suc n) e)[x::=y] = Lam [fresh_var e[x::=y]]. eta_expand n (App e[x::=y] (fresh_var e[x::=y]))›*) have "… = eta_expand (Suc n) e[x::=y]" by simp finally (*calculation: ‹(eta_expand (Suc (n::nat)) (e::exp))[(x::Vars.var)::=(y::Vars.var)] = eta_expand (Suc n) e[x::=y]›*) show "?case" (*goal: ‹(eta_expand (Suc n) e)[x::=y] = eta_expand (Suc n) e[x::=y]›*) . qed lemma isLam_eta_expand: "isLam e ⟹ isLam (eta_expand n e)" and "n > 0 ⟹ isLam (eta_expand n e)" apply (induction n) (*top goal: ‹isLam e ⟹ isLam (eta_expand n e)› and 1 goal remains*) by auto lemma isVal_eta_expand: "isVal e ⟹ isVal (eta_expand n e)" and "n > 0 ⟹ isVal (eta_expand n e)" apply (induction n) (*top goal: ‹isVal (e::exp) ⟹ isVal (eta_expand (n::nat) e)› and 1 goal remains*) by auto end
{ "path": "afp-2025-02-12/thys/Call_Arity/EtaExpansion.thy", "repo": "afp-2025-02-12", "sha": "1a92caebb16663e4552115dbf7cd10f7735ff2e4c5bb8a360482af7692866d02" }
(* Title: HOL/Int.thy Author: Lawrence C Paulson, Cambridge University Computer Laboratory Author: Tobias Nipkow, Florian Haftmann, TU Muenchen *) section ‹The Integers as Equivalence Classes over Pairs of Natural Numbers› theory Int imports Quotient Groups_Big Fun_Def begin subsection ‹Definition of integers as a quotient type› definition intrel :: "(nat × nat) ⇒ (nat × nat) ⇒ bool" where "intrel = (λ(x, y) (u, v). x + v = u + y)" lemma intrel_iff [simp]: "intrel (x, y) (u, v) ⟷ x + v = u + y" by (simp add: intrel_def (*‹intrel = (λ(x::nat, y::nat) (u::nat, v::nat). x + v = u + y)›*)) quotient_type int = "nat × nat" / "intrel" morphisms Rep_Integ Abs_Integ proof (rule equivpI) show "reflp intrel" by (auto simp: reflp_def) show "symp intrel" by (auto simp: symp_def) show "transp intrel" by (auto simp: transp_def) qed subsection ‹Integers form a commutative ring› instantiation int :: comm_ring_1 begin lift_definition zero_int :: "int" is "(0, 0)" . lift_definition one_int :: "int" is "(1, 0)" . lift_definition plus_int :: "int ⇒ int ⇒ int" is "λ(x, y) (u, v). (x + u, y + v)" by clarsimp lift_definition uminus_int :: "int ⇒ int" is "λ(x, y). (y, x)" by clarsimp lift_definition minus_int :: "int ⇒ int ⇒ int" is "λ(x, y) (u, v). (x + v, y + u)" by clarsimp lift_definition times_int :: "int ⇒ int ⇒ int" is "λ(x, y) (u, v). (x*u + y*v, x*v + y*u)" proof (unfold intrel_def, clarify) fix s t u v w x y z :: nat assume "s + v = u + t" and "w + z = y + x" then have "(s + v) * w + (u + t) * x + u * (w + z) + v * (y + x) = (u + t) * w + (s + v) * x + u * (y + x) + v * (w + z)" by simp then show "(s * w + t * x) + (u * z + v * y) = (u * y + v * z) + (s * x + t * w)" by (simp add: algebra_simps) qed instance by standard (transfer; clarsimp simp: algebra_simps)+ end abbreviation int :: "nat ⇒ int" where "int ≡ of_nat" lemma int_def: "int n = Abs_Integ (n, 0)" apply (induct n) (*goals: 1. ‹int 0 = Abs_Integ (0, 0)› 2. ‹⋀n. int n = Abs_Integ (n, 0) ⟹ int (Suc n) = Abs_Integ (Suc n, 0)› discuss goal 1*) apply (simp add: zero_int.abs_eq (*‹0 = Abs_Integ (0, 0)›*)) (*discuss goal 2*) apply (simp add: one_int.abs_eq (*‹(1::int) = Abs_Integ (1::nat, 0::nat)›*) plus_int.abs_eq (*‹Abs_Integ (?xa::nat × nat) + Abs_Integ (?x::nat × nat) = Abs_Integ ((case ?xa of (x::nat, y::nat) ⇒ λ(u::nat, v::nat). (x + u, y + v)) ?x)›*)) (*proven 2 subgoals*) . lemma int_transfer [transfer_rule]: includes lifting_syntax shows "rel_fun (=) pcr_int (λn. (n, 0)) int" by (simp add: rel_fun_def (*‹?A ===> ?B = (λf g. ∀x y. ?A x y ⟶ ?B (f x) (g y))›*) int.pcr_cr_eq (*‹pcr_int = cr_int›*) cr_int_def (*‹cr_int ≡ λx. (=) (Abs_Integ x)›*) int_def (*‹int ?n = Abs_Integ (?n, 0)›*)) lemma int_diff_cases: obtains (diff) m n where "z = int m - int n" apply transfer (*goal: ‹(⋀m n. z = int m - int n ⟹ thesis) ⟹ thesis›*) by clarsimp subsection ‹Integers are totally ordered› instantiation int :: linorder begin lift_definition less_eq_int :: "int ⇒ int ⇒ bool" is "λ(x, y) (u, v). x + v ≤ u + y" by auto lift_definition less_int :: "int ⇒ int ⇒ bool" is "λ(x, y) (u, v). x + v < u + y" by auto instance by standard (transfer, force)+ end instantiation int :: distrib_lattice begin definition "(inf :: int ⇒ int ⇒ int) = min" definition "(sup :: int ⇒ int ⇒ int) = max" instance by standard (auto simp add: inf_int_def sup_int_def max_min_distrib2) end subsection ‹Ordering properties of arithmetic operations› instance int :: ordered_cancel_ab_semigroup_add proof fix i j k :: int show "i ≤ j ⟹ k + i ≤ k + j" by transfer clarsimp qed text ‹Strict Monotonicity of Multiplication.› text ‹Strict, in 1st argument; proof is by induction on ‹k > 0›.› lemma zmult_zless_mono2_lemma: "i < j ⟹ 0 < k ⟹ int k * i < int k * j" for i j :: int proof (induct k) (*goals: 1. ‹⟦i < j; 0 < 0⟧ ⟹ int 0 * i < int 0 * j› 2. ‹⋀k. ⟦⟦i < j; 0 < k⟧ ⟹ int k * i < int k * j; i < j; 0 < Suc k⟧ ⟹ int (Suc k) * i < int (Suc k) * j›*) case 0 (*‹(i::int) < (j::int)› ‹0 < 0›*) then show "?case" (*goal: ‹int 0 * i < int 0 * j›*) by simp next (*goal: ‹⋀k::nat. ⟦⟦(i::int) < (j::int); (0::nat) < k⟧ ⟹ int k * i < int k * j; i < j; (0::nat) < Suc k⟧ ⟹ int (Suc k) * i < int (Suc k) * j›*) case (Suc k) (*‹⟦i < j; 0 < k⟧ ⟹ int k * i < int k * j› ‹i < j› ‹(0::nat) < Suc (k::nat)›*) then show "?case" (*goal: ‹int (Suc (k::nat)) * (i::int) < int (Suc k) * (j::int)›*) apply (cases "k = 0") (*goals: 1. ‹⟦⟦i < j; 0 < k⟧ ⟹ int k * i < int k * j; i < j; 0 < Suc k; k = 0⟧ ⟹ int (Suc k) * i < int (Suc k) * j› 2. ‹⟦⟦i < j; 0 < k⟧ ⟹ int k * i < int k * j; i < j; 0 < Suc k; k ≠ 0⟧ ⟹ int (Suc k) * i < int (Suc k) * j› discuss goal 1*) apply (simp add: distrib_right (*‹((?a::?'a) + (?b::?'a)) * (?c::?'a) = ?a * ?c + ?b * ?c›*) add_strict_mono (*‹⟦(?a::?'a) < (?b::?'a); (?c::?'a) < (?d::?'a)⟧ ⟹ ?a + ?c < ?b + ?d›*)) (*discuss goal 2*) apply (simp add: distrib_right (*‹((?a::?'a) + (?b::?'a)) * (?c::?'a) = ?a * ?c + ?b * ?c›*) add_strict_mono (*‹⟦(?a::?'a) < (?b::?'a); (?c::?'a) < (?d::?'a)⟧ ⟹ ?a + ?c < ?b + ?d›*)) (*proven 2 subgoals*) . qed lemma zero_le_imp_eq_int: assumes "k ≥ (0::int)" shows "∃n. k = int n" proof (-) (*goal: ‹∃n. k = int n›*) have "b ≤ a ⟹ ∃n::nat. a = n + b" for a and b using exI[of _ "a - b"] (*‹?P (a - b) ⟹ ∃x. ?P x›*) by simp with assms (*‹(0::int) ≤ (k::int)›*) show "?thesis" (*goal: ‹∃n. k = int n›*) apply transfer (*goal: ‹∃n. k = int n›*) by auto qed lemma zero_less_imp_eq_int: assumes "k > (0::int)" shows "∃n>0. k = int n" proof (-) (*goal: ‹∃n>0. k = int n›*) have "b < a ⟹ ∃n::nat. n>0 ∧ a = n + b" for a and b using exI[of _ "a - b"] (*‹?P (a - b) ⟹ ∃x. ?P x›*) by simp with assms (*‹0 < k›*) show "?thesis" (*goal: ‹∃n>0. k = int n›*) apply transfer (*goal: ‹∃n>0. k = int n›*) by auto qed lemma zmult_zless_mono2: "i < j ⟹ 0 < k ⟹ k * i < k * j" for i j k :: int apply (drule zero_less_imp_eq_int (*‹0 < ?k ⟹ ∃n>0. ?k = int n›*)) (*goal: ‹⟦i < j; 0 < k⟧ ⟹ k * i < k * j›*) by (auto simp add: zmult_zless_mono2_lemma (*‹⟦?i < ?j; 0 < ?k⟧ ⟹ int ?k * ?i < int ?k * ?j›*)) text ‹The integers form an ordered integral domain.› instantiation int :: linordered_idom begin definition zabs_def: "¦i::int¦ = (if i < 0 then - i else i)" definition zsgn_def: "sgn (i::int) = (if i = 0 then 0 else if 0 < i then 1 else - 1)" instance proof fix i j k :: int show "i < j ⟹ 0 < k ⟹ k * i < k * j" by (rule zmult_zless_mono2) show "¦i¦ = (if i < 0 then -i else i)" by (simp only: zabs_def) show "sgn (i::int) = (if i=0 then 0 else if 0<i then 1 else - 1)" by (simp only: zsgn_def) qed end instance int :: discrete_linordered_semidom proof fix k l :: int show ‹k < l ⟷ k + 1 ≤ l› (is ‹?P ⟷ ?Q›) proof assume ?Q then show ?P by simp next assume ?P then have ‹l - k > 0› by simp with zero_less_imp_eq_int obtain n where ‹l - k = int n› by blast then have ‹n > 0› using ‹l - k > 0› by simp then have ‹n ≥ 1› by simp then have ‹int n ≥ int 1› by (rule of_nat_mono) with ‹l - k = int n› show ?Q by simp qed qed lemma zless_imp_add1_zle: "w < z ⟹ w + 1 ≤ z" for w z :: int apply transfer (*goal: ‹w < z ⟹ w + 1 ≤ z›*) by clarsimp lemma zless_iff_Suc_zadd: "w < z ⟷ (∃n. z = w + int (Suc n))" for w z :: int proof (-) (*goal: ‹((w::int) < (z::int)) = (∃n::nat. z = w + int (Suc n))›*) have "⋀a b c d. a + d < c + b ⟹ ∃n. c + b = Suc (a + n + d)" proof (-) (*goal: ‹⋀a b c d. a + d < c + b ⟹ ∃n. c + b = Suc (a + n + d)›*) fix a :: nat and b :: nat and c :: nat and d :: nat assume "a + d < c + b" (*‹(a::nat) + (d::nat) < (c::nat) + (b::nat)›*) then have "c + b = Suc (a + (c + b - Suc (a + d)) + d) " by arith then show "∃n. c + b = Suc (a + n + d)" by (rule exI (*‹?P ?x ⟹ ∃x. ?P x›*)) qed then show "?thesis" (*goal: ‹(w < z) = (∃n. z = w + int (Suc n))›*) apply transfer (*goal: ‹(w < z) = (∃n. z = w + int (Suc n))›*) by auto qed lemma zabs_less_one_iff [simp]: "¦z¦ < 1 ⟷ z = 0" (is "?lhs ⟷ ?rhs") for z :: int proof (standard) (*goals: 1. ‹¦z¦ < 1 ⟹ z = 0› 2. ‹z = 0 ⟹ ¦z¦ < 1›*) assume "?rhs" (*‹(z::int) = (0::int)›*) then show "?lhs" by simp next (*goal: ‹¦z¦ < 1 ⟹ z = 0›*) assume "?lhs" (*‹¦z::int¦ < (1::int)›*) with zless_imp_add1_zle[of "¦z¦" 1] (*‹¦z¦ < 1 ⟹ ¦z¦ + 1 ≤ 1›*) have "¦z¦ + 1 ≤ 1" by simp then have "¦z¦ ≤ 0" by simp then show "?rhs" by simp qed subsection ‹Embedding of the Integers into any ‹ring_1›: ‹of_int›› context ring_1 begin lift_definition of_int :: "int ⇒ 'a" is "λ(i, j). of_nat i - of_nat j" by (clarsimp simp add: diff_eq_eq eq_diff_eq diff_add_eq of_nat_add [symmetric] simp del: of_nat_add) lemma of_int_0 [simp]: "of_int 0 = 0" apply transfer (*goal: ‹of_int 0 = 0›*) by simp lemma of_int_1 [simp]: "of_int 1 = 1" apply transfer (*goal: ‹of_int 1 = 1›*) by simp lemma of_int_add [simp]: "of_int (w + z) = of_int w + of_int z" apply transfer (*goal: ‹of_int (w + z) = of_int w + of_int z›*) by (clarsimp 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 25 facts*)) lemma of_int_minus [simp]: "of_int (- z) = - (of_int z)" apply (transfer fixing: uminus) (*goal: ‹of_int (- (z::int)) = - of_int z›*) by clarsimp lemma of_int_diff [simp]: "of_int (w - z) = of_int w - of_int z" using of_int_add[of w "- z"] (*‹of_int (w + - z) = of_int w + of_int (- z)›*) by simp lemma of_int_mult [simp]: "of_int (w*z) = of_int w * of_int z" apply (transfer fixing: times) (*goal: ‹of_int (w * z) = of_int w * of_int z›*) by (clarsimp 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 25 facts*)) lemma mult_of_int_commute: "of_int x * y = y * of_int x" apply (transfer fixing: times) (*goal: ‹of_int x * y = y * of_int 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 25 facts*) mult_of_nat_commute (*‹of_nat ?x * ?y = ?y * of_nat ?x›*)) text ‹Collapse nested embeddings.› lemma of_int_of_nat_eq [simp]: "of_int (int n) = of_nat n" apply (induct n) (*goals: 1. ‹of_int (int (0::nat)) = of_nat (0::nat)› 2. ‹⋀n::nat. of_int (int n) = of_nat n ⟹ of_int (int (Suc n)) = of_nat (Suc n)› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . lemma of_int_numeral [simp, code_post]: "of_int (numeral k) = numeral k" by (simp add: of_nat_numeral [symmetric] (*‹numeral ?n = of_nat (numeral ?n)›*) of_int_of_nat_eq [symmetric] (*‹of_nat ?n = of_int (int ?n)›*)) lemma of_int_neg_numeral [code_post]: "of_int (- numeral k) = - numeral k" by simp lemma of_int_power [simp]: "of_int (z ^ n) = of_int z ^ n" apply (induct n) (*goals: 1. ‹of_int (z ^ 0) = of_int z ^ 0› 2. ‹⋀n. of_int (z ^ n) = of_int z ^ n ⟹ of_int (z ^ Suc n) = of_int z ^ Suc n› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) . lemma of_int_of_bool [simp]: "of_int (of_bool P) = of_bool P" by auto end context ring_char_0 begin lemma of_int_eq_iff [simp]: "of_int w = of_int z ⟷ w = z" apply transfer (*goal: ‹(of_int (w::int) = of_int (z::int)) = (w = z)›*) by (clarsimp 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 25 facts*) of_nat_add [symmetric] (*‹of_nat (?m::nat) + of_nat (?n::nat) = of_nat (?m + ?n)›*) simp del: of_nat_add (*‹of_nat ((?m::nat) + (?n::nat)) = of_nat ?m + of_nat ?n›*)) text ‹Special cases where either operand is zero.› lemma of_int_eq_0_iff [simp]: "of_int z = 0 ⟷ z = 0" using of_int_eq_iff[of z 0] (*‹(of_int (z::int) = of_int (0::int)) = (z = (0::int))›*) by simp lemma of_int_0_eq_iff [simp]: "0 = of_int z ⟷ z = 0" using of_int_eq_iff[of 0 z] (*‹(of_int 0 = of_int z) = (0 = z)›*) by simp lemma of_int_eq_1_iff [iff]: "of_int z = 1 ⟷ z = 1" using of_int_eq_iff[of z 1] (*‹(of_int z = of_int 1) = (z = 1)›*) by simp lemma numeral_power_eq_of_int_cancel_iff [simp]: "numeral x ^ n = of_int y ⟷ numeral x ^ n = y" using of_int_eq_iff[of "numeral x ^ n" y, unfolded of_int_numeral of_int_power] (*‹(numeral x ^ n = of_int y) = (numeral x ^ n = y)›*) . lemma of_int_eq_numeral_power_cancel_iff [simp]: "of_int y = numeral x ^ n ⟷ y = numeral x ^ n" using numeral_power_eq_of_int_cancel_iff[of x n y] (*‹(numeral x ^ n = of_int y) = (numeral x ^ n = y)›*) by (metis (mono_tags)) lemma neg_numeral_power_eq_of_int_cancel_iff [simp]: "(- numeral x) ^ n = of_int y ⟷ (- numeral x) ^ n = y" using of_int_eq_iff[of "(- numeral x) ^ n" y] (*‹(of_int ((- numeral (x::num)) ^ (n::nat)) = of_int (y::int)) = ((- numeral x) ^ n = y)›*) by simp lemma of_int_eq_neg_numeral_power_cancel_iff [simp]: "of_int y = (- numeral x) ^ n ⟷ y = (- numeral x) ^ n" using neg_numeral_power_eq_of_int_cancel_iff[of x n y] (*‹((- numeral x) ^ n = of_int y) = ((- numeral x) ^ n = y)›*) by (metis (mono_tags)) lemma of_int_eq_of_int_power_cancel_iff[simp]: "(of_int b) ^ w = of_int x ⟷ b ^ w = x" by (metis of_int_power (*‹of_int (?z ^ ?n) = of_int ?z ^ ?n›*) of_int_eq_iff (*‹(of_int ?w = of_int ?z) = (?w = ?z)›*)) lemma of_int_power_eq_of_int_cancel_iff[simp]: "of_int x = (of_int b) ^ w ⟷ x = b ^ w" by (metis of_int_eq_of_int_power_cancel_iff (*‹(of_int ?b ^ ?w = of_int ?x) = (?b ^ ?w = ?x)›*)) end context linordered_idom begin text ‹Every ‹linordered_idom› has characteristic zero.› subclass ring_char_0 .. lemma of_int_le_iff [simp]: "of_int w ≤ of_int z ⟷ w ≤ z" apply (transfer fixing: less_eq) (*goal: ‹(of_int w ≤ of_int z) = (w ≤ z)›*) by (clarsimp 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*) of_nat_add [symmetric] (*‹of_nat (?m::nat) + of_nat (?n::nat) = of_nat (?m + ?n)›*) simp del: of_nat_add (*‹of_nat ((?m::nat) + (?n::nat)) = of_nat ?m + of_nat ?n›*)) lemma of_int_less_iff [simp]: "of_int w < of_int z ⟷ w < z" by (simp add: less_le (*‹(?x < ?y) = (?x ≤ ?y ∧ ?x ≠ ?y)›*) order_less_le (*‹(?x < ?y) = (?x ≤ ?y ∧ ?x ≠ ?y)›*)) lemma of_int_0_le_iff [simp]: "0 ≤ of_int z ⟷ 0 ≤ z" using of_int_le_iff[of 0 z] (*‹(of_int 0 ≤ of_int z) = (0 ≤ z)›*) by simp lemma of_int_le_0_iff [simp]: "of_int z ≤ 0 ⟷ z ≤ 0" using of_int_le_iff[of z 0] (*‹(of_int z ≤ of_int 0) = (z ≤ 0)›*) by simp lemma of_int_0_less_iff [simp]: "0 < of_int z ⟷ 0 < z" using of_int_less_iff[of 0 z] (*‹(of_int 0 < of_int z) = (0 < z)›*) by simp lemma of_int_less_0_iff [simp]: "of_int z < 0 ⟷ z < 0" using of_int_less_iff[of z 0] (*‹(of_int (z::int) < of_int (0::int)) = (z < (0::int))›*) by simp lemma of_int_1_le_iff [simp]: "1 ≤ of_int z ⟷ 1 ≤ z" using of_int_le_iff[of 1 z] (*‹(of_int 1 ≤ of_int z) = (1 ≤ z)›*) by simp lemma of_int_le_1_iff [simp]: "of_int z ≤ 1 ⟷ z ≤ 1" using of_int_le_iff[of z 1] (*‹(of_int z ≤ of_int 1) = (z ≤ 1)›*) by simp lemma of_int_1_less_iff [simp]: "1 < of_int z ⟷ 1 < z" using of_int_less_iff[of 1 z] (*‹(of_int 1 < of_int z) = (1 < z)›*) by simp lemma of_int_less_1_iff [simp]: "of_int z < 1 ⟷ z < 1" using of_int_less_iff[of z 1] (*‹(of_int z < of_int 1) = (z < 1)›*) by simp lemma of_int_pos: "z > 0 ⟹ of_int z > 0" by simp lemma of_int_nonneg: "z ≥ 0 ⟹ of_int z ≥ 0" by simp lemma of_int_abs [simp]: "of_int ¦x¦ = ¦of_int x¦" by (auto simp add: abs_if (*‹¦?a¦ = (if ?a < 0 then - ?a else ?a)›*)) lemma of_int_lessD: assumes "¦of_int n¦ < x" shows "n = 0 ∨ x > 1" proof (cases "n = 0") (*goals: 1. ‹n = 0 ⟹ n = 0 ∨ 1 < x› 2. ‹n ≠ 0 ⟹ n = 0 ∨ 1 < x›*) case True (*‹n = 0›*) then show "?thesis" (*goal: ‹n = 0 ∨ 1 < x›*) by simp next (*goal: ‹n ≠ 0 ⟹ n = 0 ∨ 1 < x›*) case False (*‹n ≠ 0›*) then have "¦n¦ ≠ 0" by simp then have "¦n¦ > 0" by simp then have "¦n¦ ≥ 1" using zless_imp_add1_zle[of 0 "¦n¦"] (*‹0 < ¦n¦ ⟹ 0 + 1 ≤ ¦n¦›*) by simp then have "¦of_int n¦ ≥ 1" unfolding of_int_1_le_iff[of "¦n¦", symmetric] (*goal: ‹(1::'a) ≤ ¦of_int (n::int)¦›*) by simp then have "1 < x" using assms (*‹¦of_int (n::int)¦ < (x::'a)›*) by (rule le_less_trans (*‹⟦?x ≤ ?y; ?y < ?z⟧ ⟹ ?x < ?z›*)) then show "?thesis" (*goal: ‹(n::int) = (0::int) ∨ (1::'a::type) < (x::'a::type)›*) by standard qed lemma of_int_leD: assumes "¦of_int n¦ ≤ x" shows "n = 0 ∨ 1 ≤ x" proof (cases "n = 0") (*goals: 1. ‹n = 0 ⟹ n = 0 ∨ 1 ≤ x› 2. ‹n ≠ 0 ⟹ n = 0 ∨ 1 ≤ x›*) case True (*‹n = 0›*) then show "?thesis" (*goal: ‹n = 0 ∨ 1 ≤ x›*) by simp next (*goal: ‹(n::int) ≠ (0::int) ⟹ n = (0::int) ∨ (1::'a) ≤ (x::'a)›*) case False (*‹n ≠ 0›*) then have "¦n¦ ≠ 0" by simp then have "¦n¦ > 0" by simp then have "¦n¦ ≥ 1" using zless_imp_add1_zle[of 0 "¦n¦"] (*‹0 < ¦n¦ ⟹ 0 + 1 ≤ ¦n¦›*) by simp then have "¦of_int n¦ ≥ 1" unfolding of_int_1_le_iff[of "¦n¦", symmetric] (*goal: ‹1 ≤ ¦of_int n¦›*) by simp then have "1 ≤ x" using assms (*‹¦of_int n¦ ≤ x›*) by (rule order_trans (*‹⟦(?x::'a) ≤ (?y::'a); ?y ≤ (?z::'a)⟧ ⟹ ?x ≤ ?z›*)) then show "?thesis" (*goal: ‹n = 0 ∨ 1 ≤ x›*) by standard qed lemma numeral_power_le_of_int_cancel_iff [simp]: "numeral x ^ n ≤ of_int a ⟷ numeral x ^ n ≤ a" by (metis (mono_tags) local.of_int_eq_numeral_power_cancel_iff (*‹(of_int ?y = numeral ?x ^ ?n) = (?y = numeral ?x ^ ?n)›*) of_int_le_iff (*‹(of_int ?w ≤ of_int ?z) = (?w ≤ ?z)›*)) lemma of_int_le_numeral_power_cancel_iff [simp]: "of_int a ≤ numeral x ^ n ⟷ a ≤ numeral x ^ n" by (metis (mono_tags) local.numeral_power_eq_of_int_cancel_iff (*‹(numeral ?x ^ ?n = of_int ?y) = (numeral ?x ^ ?n = ?y)›*) of_int_le_iff (*‹(of_int ?w ≤ of_int ?z) = (?w ≤ ?z)›*)) lemma numeral_power_less_of_int_cancel_iff [simp]: "numeral x ^ n < of_int a ⟷ numeral x ^ n < a" by (metis (mono_tags) local.of_int_eq_numeral_power_cancel_iff (*‹(of_int (?y::int) = numeral (?x::num) ^ (?n::nat)) = (?y = numeral ?x ^ ?n)›*) of_int_less_iff (*‹(of_int (?w::int) < of_int (?z::int)) = (?w < ?z)›*)) lemma of_int_less_numeral_power_cancel_iff [simp]: "of_int a < numeral x ^ n ⟷ a < numeral x ^ n" by (metis (mono_tags) local.of_int_eq_numeral_power_cancel_iff (*‹(of_int ?y = numeral ?x ^ ?n) = (?y = numeral ?x ^ ?n)›*) of_int_less_iff (*‹(of_int ?w < of_int ?z) = (?w < ?z)›*)) lemma neg_numeral_power_le_of_int_cancel_iff [simp]: "(- numeral x) ^ n ≤ of_int a ⟷ (- numeral x) ^ n ≤ a" by (metis (mono_tags) of_int_le_iff (*‹(of_int ?w ≤ of_int ?z) = (?w ≤ ?z)›*) of_int_neg_numeral (*‹of_int (- numeral ?k) = - numeral ?k›*) of_int_power (*‹of_int (?z ^ ?n) = of_int ?z ^ ?n›*)) lemma of_int_le_neg_numeral_power_cancel_iff [simp]: "of_int a ≤ (- numeral x) ^ n ⟷ a ≤ (- numeral x) ^ n" by (metis (mono_tags) of_int_le_iff (*‹(of_int ?w ≤ of_int ?z) = (?w ≤ ?z)›*) of_int_neg_numeral (*‹of_int (- numeral ?k) = - numeral ?k›*) of_int_power (*‹of_int (?z ^ ?n) = of_int ?z ^ ?n›*)) lemma neg_numeral_power_less_of_int_cancel_iff [simp]: "(- numeral x) ^ n < of_int a ⟷ (- numeral x) ^ n < a" using of_int_less_iff[of "(- numeral x) ^ n" a] (*‹(of_int ((- numeral x) ^ n) < of_int a) = ((- numeral x) ^ n < a)›*) by simp lemma of_int_less_neg_numeral_power_cancel_iff [simp]: "of_int a < (- numeral x) ^ n ⟷ a < (- numeral x::int) ^ n" using of_int_less_iff[of a "(- numeral x) ^ n"] (*‹(of_int a < of_int ((- numeral x) ^ n)) = (a < (- numeral x) ^ n)›*) by simp lemma of_int_le_of_int_power_cancel_iff[simp]: "(of_int b) ^ w ≤ of_int x ⟷ b ^ w ≤ x" by (metis (mono_tags) of_int_le_iff (*‹(of_int (?w::int) ≤ of_int (?z::int)) = (?w ≤ ?z)›*) of_int_power (*‹of_int ((?z::int) ^ (?n::nat)) = of_int ?z ^ ?n›*)) lemma of_int_power_le_of_int_cancel_iff[simp]: "of_int x ≤ (of_int b) ^ w⟷ x ≤ b ^ w" by (metis (mono_tags) of_int_le_iff (*‹(of_int ?w ≤ of_int ?z) = (?w ≤ ?z)›*) of_int_power (*‹of_int (?z ^ ?n) = of_int ?z ^ ?n›*)) lemma of_int_less_of_int_power_cancel_iff[simp]: "(of_int b) ^ w < of_int x ⟷ b ^ w < x" by (metis (mono_tags) of_int_less_iff (*‹(of_int ?w < of_int ?z) = (?w < ?z)›*) of_int_power (*‹of_int (?z ^ ?n) = of_int ?z ^ ?n›*)) lemma of_int_power_less_of_int_cancel_iff[simp]: "of_int x < (of_int b) ^ w⟷ x < b ^ w" by (metis (mono_tags) of_int_less_iff (*‹(of_int (?w::int) < of_int (?z::int)) = (?w < ?z)›*) of_int_power (*‹of_int ((?z::int) ^ (?n::nat)) = of_int ?z ^ ?n›*)) lemma of_int_max: "of_int (max x y) = max (of_int x) (of_int y)" by (auto simp: max_def (*‹max ?a ?b = (if ?a ≤ ?b then ?b else ?a)›*)) lemma of_int_min: "of_int (min x y) = min (of_int x) (of_int y)" by (auto simp: min_def (*‹min ?a ?b = (if ?a ≤ ?b then ?a else ?b)›*)) end context division_ring begin lemmas mult_inverse_of_int_commute = mult_commute_imp_mult_inverse_commute[OF mult_of_int_commute] end text ‹Comparisons involving \<^term>‹of_int›.› lemma of_int_eq_numeral_iff [iff]: "of_int z = (numeral n :: 'a::ring_char_0) ⟷ z = numeral n" using of_int_eq_iff (*‹(of_int ?w = of_int ?z) = (?w = ?z)›*) by fastforce lemma of_int_le_numeral_iff [simp]: "of_int z ≤ (numeral n :: 'a::linordered_idom) ⟷ z ≤ numeral n" using of_int_le_iff[of z "numeral n"] (*‹(of_int z ≤ of_int (numeral n)) = (z ≤ numeral n)›*) by simp lemma of_int_numeral_le_iff [simp]: "(numeral n :: 'a::linordered_idom) ≤ of_int z ⟷ numeral n ≤ z" using of_int_le_iff[of "numeral n"] (*‹(of_int (numeral n) ≤ of_int ?z) = (numeral n ≤ ?z)›*) by simp lemma of_int_less_numeral_iff [simp]: "of_int z < (numeral n :: 'a::linordered_idom) ⟷ z < numeral n" using of_int_less_iff[of z "numeral n"] (*‹(of_int (z::int) < of_int (numeral (n::num))) = (z < numeral n)›*) by simp lemma of_int_numeral_less_iff [simp]: "(numeral n :: 'a::linordered_idom) < of_int z ⟷ numeral n < z" using of_int_less_iff[of "numeral n" z] (*‹(of_int (numeral n) < of_int z) = (numeral n < z)›*) by simp lemma of_nat_less_of_int_iff: "(of_nat n::'a::linordered_idom) < of_int x ⟷ int n < x" by (metis of_int_of_nat_eq (*‹of_int (int (?n::nat)) = of_nat ?n›*) of_int_less_iff (*‹(of_int (?w::int) < of_int (?z::int)) = (?w < ?z)›*)) lemma of_int_eq_id [simp]: "of_int = id" proof (standard) (*goal: ‹⋀x. of_int x = id x›*) show "of_int z = id z" for z apply (cases z rule: int_diff_cases (*‹(⋀m n. ?z = int m - int n ⟹ ?thesis) ⟹ ?thesis›*)) (*goal: ‹of_int z = id z›*) by simp qed instance int :: no_top proof fix x::int have "x < x + 1" by simp then show "∃y. x < y" by (rule exI) qed instance int :: no_bot proof fix x::int have "x - 1< x" by simp then show "∃y. y < x" by (rule exI) qed subsection ‹Magnitude of an Integer, as a Natural Number: ‹nat›› lift_definition nat :: "int ⇒ nat" is "λ(x, y). x - y" by auto lemma nat_int [simp]: "nat (int n) = n" apply transfer (*goal: ‹nat (int n) = n›*) by simp lemma int_nat_eq [simp]: "int (nat z) = (if 0 ≤ z then z else 0)" apply transfer (*goal: ‹int (nat z) = (if 0 ≤ z then z else 0)›*) by clarsimp lemma nat_0_le: "0 ≤ z ⟹ int (nat z) = z" by simp lemma nat_le_0 [simp]: "z ≤ 0 ⟹ nat z = 0" apply transfer (*goal: ‹z ≤ 0 ⟹ nat z = 0›*) by clarsimp lemma nat_le_eq_zle: "0 < w ∨ 0 ≤ z ⟹ nat w ≤ nat z ⟷ w ≤ z" apply transfer (*goal: ‹(0::int) < (w::int) ∨ (0::int) ≤ (z::int) ⟹ (nat w ≤ nat z) = (w ≤ z)›*) apply clarsimp (*goal: ‹⋀w z. (case (0, 0) of (x, y) ⇒ λ(u, v). x + v < u + y) w ∨ (case (0, 0) of (x, y) ⇒ λ(u, v). x + v ≤ u + y) z ⟹ ((case w of (x, xa) ⇒ x - xa) ≤ (case z of (x, xa) ⇒ x - xa)) = (case w of (x, y) ⇒ λ(u, v). x + v ≤ u + y) z›*) by arith text ‹An alternative condition is \<^term>‹0 ≤ w›.› lemma nat_mono_iff: "0 < z ⟹ nat w < nat z ⟷ w < z" by (simp add: nat_le_eq_zle (*‹0 < ?w ∨ 0 ≤ ?z ⟹ (nat ?w ≤ nat ?z) = (?w ≤ ?z)›*) linorder_not_le [symmetric] (*‹(?y < ?x) = (¬ ?x ≤ ?y)›*)) lemma nat_less_eq_zless: "0 ≤ w ⟹ nat w < nat z ⟷ w < z" by (simp add: nat_le_eq_zle (*‹0 < ?w ∨ 0 ≤ ?z ⟹ (nat ?w ≤ nat ?z) = (?w ≤ ?z)›*) linorder_not_le [symmetric] (*‹(?y < ?x) = (¬ ?x ≤ ?y)›*)) lemma zless_nat_conj [simp]: "nat w < nat z ⟷ 0 < z ∧ w < z" apply transfer (*goal: ‹(nat (w::int) < nat (z::int)) = ((0::int) < z ∧ w < z)›*) apply clarsimp (*goal: ‹⋀w z. ((case w of (x, xa) ⇒ x - xa) < (case z of (x, xa) ⇒ x - xa)) = ((case (0, 0) of (x, y) ⇒ λ(u, v). x + v < u + y) z ∧ (case w of (x, y) ⇒ λ(u, v). x + v < u + y) z)›*) by arith lemma nonneg_int_cases: assumes "0 ≤ k" obtains n where "k = int n" proof (-) (*goal: ‹(⋀n::nat. (k::int) = int n ⟹ thesis::bool) ⟹ thesis›*) from assms (*‹0 ≤ k›*) have "k = int (nat k)" by simp then show thesis by (rule that (*‹k = int ?n ⟹ thesis›*)) qed lemma pos_int_cases: assumes "0 < k" obtains n where "k = int n" and "n > 0" proof (-) (*goal: ‹(⋀n. ⟦k = int n; 0 < n⟧ ⟹ thesis) ⟹ thesis›*) from assms (*‹0 < k›*) have "0 ≤ k" by simp then obtain n where "k = int n" (*goal: ‹(⋀n::nat. (k::int) = int n ⟹ thesis::bool) ⟹ thesis›*) by (rule nonneg_int_cases (*‹⟦0 ≤ ?k; ⋀n. ?k = int n ⟹ ?thesis⟧ ⟹ ?thesis›*)) moreover have "n > 0" using ‹k = int n› (*‹k = int n›*) assms (*‹0 < k›*) by simp ultimately show thesis by (rule that (*‹⟦k = int ?n; 0 < ?n⟧ ⟹ thesis›*)) qed lemma nonpos_int_cases: assumes "k ≤ 0" obtains n where "k = - int n" proof (-) (*goal: ‹(⋀n. k = - int n ⟹ thesis) ⟹ thesis›*) from assms (*‹k ≤ 0›*) have "- k ≥ 0" by simp then obtain n where "- k = int n" (*goal: ‹(⋀n. - k = int n ⟹ thesis) ⟹ thesis›*) by (rule nonneg_int_cases (*‹⟦(0::int) ≤ (?k::int); ⋀n::nat. ?k = int n ⟹ ?thesis::bool⟧ ⟹ ?thesis›*)) then have "k = - int n" by simp then show thesis by (rule that (*‹k = - int ?n ⟹ thesis›*)) qed lemma neg_int_cases: assumes "k < 0" obtains n where "k = - int n" and "n > 0" proof (-) (*goal: ‹(⋀n. ⟦k = - int n; 0 < n⟧ ⟹ thesis) ⟹ thesis›*) from assms (*‹k < 0›*) have "- k > 0" by simp then obtain n where "- k = int n" and "- k > 0" (*goal: ‹(⋀n. ⟦- k = int n; 0 < - k⟧ ⟹ thesis) ⟹ thesis›*) by (blast elim: pos_int_cases (*‹⟦0 < ?k; ⋀n. ⟦?k = int n; 0 < n⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*)) then have "k = - int n" and "n > 0" apply - (*goals: 1. ‹⟦- (k::int) = int (n::nat); (0::int) < - k⟧ ⟹ k = - int n› 2. ‹⟦- (k::int) = int (n::nat); (0::int) < - k⟧ ⟹ (0::nat) < n› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) . then show thesis by (rule that (*‹⟦k = - int ?n; 0 < ?n⟧ ⟹ thesis›*)) qed lemma nat_eq_iff: "nat w = m ⟷ (if 0 ≤ w then w = int m else m = 0)" apply transfer (*goal: ‹(nat (w::int) = (m::nat)) = (if (0::int) ≤ w then w = int m else m = (0::nat))›*) by (clarsimp simp add: le_imp_diff_is_add (*‹?i ≤ ?j ⟹ (?j - ?i = ?k) = (?j = ?k + ?i)›*)) lemma nat_eq_iff2: "m = nat w ⟷ (if 0 ≤ w then w = int m else m = 0)" using nat_eq_iff[of w m] (*‹(nat w = m) = (if 0 ≤ w then w = int m else m = 0)›*) by auto lemma nat_0 [simp]: "nat 0 = 0" by (simp add: nat_eq_iff (*‹(nat ?w = ?m) = (if 0 ≤ ?w then ?w = int ?m else ?m = 0)›*)) lemma nat_1 [simp]: "nat 1 = Suc 0" by (simp add: nat_eq_iff (*‹(nat ?w = ?m) = (if 0 ≤ ?w then ?w = int ?m else ?m = 0)›*)) lemma nat_numeral [simp]: "nat (numeral k) = numeral k" by (simp add: nat_eq_iff (*‹(nat ?w = ?m) = (if 0 ≤ ?w then ?w = int ?m else ?m = 0)›*)) lemma nat_neg_numeral [simp]: "nat (- numeral k) = 0" by simp lemma nat_2: "nat 2 = Suc (Suc 0)" by simp lemma nat_less_iff: "0 ≤ w ⟹ nat w < m ⟷ w < of_nat m" apply transfer (*goal: ‹0 ≤ w ⟹ (nat w < m) = (w < int m)›*) apply clarsimp (*goal: ‹⋀w m. (case (0, 0) of (x, y) ⇒ λ(u, v). x + v ≤ u + y) w ⟹ ((case w of (x, xa) ⇒ x - xa) < m) = (case w of (x, y) ⇒ λ(u, v). x + v < u + y) (m, 0)›*) by arith lemma nat_le_iff: "nat x ≤ n ⟷ x ≤ int n" apply transfer (*goal: ‹(nat x ≤ n) = (x ≤ int n)›*) by (clarsimp simp add: le_diff_conv (*‹(?j - ?k ≤ ?i) = (?j ≤ ?i + ?k)›*)) lemma nat_mono: "x ≤ y ⟹ nat x ≤ nat y" apply transfer (*goal: ‹x ≤ y ⟹ nat x ≤ nat y›*) by auto lemma nat_0_iff[simp]: "nat i = 0 ⟷ i ≤ 0" for i :: int apply transfer (*goal: ‹(nat (i::int) = (0::nat)) = (i ≤ (0::int))›*) by clarsimp lemma int_eq_iff: "of_nat m = z ⟷ m = nat z ∧ 0 ≤ z" by (auto simp add: nat_eq_iff2 (*‹((?m::nat) = nat (?w::int)) = (if (0::int) ≤ ?w then ?w = int ?m else ?m = (0::nat))›*)) lemma zero_less_nat_eq [simp]: "0 < nat z ⟷ 0 < z" using zless_nat_conj[of 0] (*‹(nat 0 < nat ?z) = (0 < ?z ∧ 0 < ?z)›*) by auto lemma nat_add_distrib: "0 ≤ z ⟹ 0 ≤ z' ⟹ nat (z + z') = nat z + nat z'" apply transfer (*goal: ‹⟦0 ≤ z; 0 ≤ z'⟧ ⟹ nat (z + z') = nat z + nat z'›*) by clarsimp lemma nat_diff_distrib': "0 ≤ x ⟹ 0 ≤ y ⟹ nat (x - y) = nat x - nat y" apply transfer (*goal: ‹⟦0 ≤ x; 0 ≤ y⟧ ⟹ nat (x - y) = nat x - nat y›*) by clarsimp lemma nat_diff_distrib: "0 ≤ z' ⟹ z' ≤ z ⟹ nat (z - z') = nat z - nat z'" apply (rule nat_diff_distrib' (*‹⟦0 ≤ ?x; 0 ≤ ?y⟧ ⟹ nat (?x - ?y) = nat ?x - nat ?y›*)) (*goals: 1. ‹⟦0 ≤ z'; z' ≤ z⟧ ⟹ 0 ≤ z› 2. ‹⟦0 ≤ z'; z' ≤ z⟧ ⟹ 0 ≤ z'› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . lemma nat_zminus_int [simp]: "nat (- int n) = 0" apply transfer (*goal: ‹nat (- int (n::nat)) = (0::nat)›*) by simp lemma le_nat_iff: "k ≥ 0 ⟹ n ≤ nat k ⟷ int n ≤ k" apply transfer (*goal: ‹0 ≤ k ⟹ (n ≤ nat k) = (int n ≤ k)›*) by auto lemma zless_nat_eq_int_zless: "m < nat z ⟷ int m < z" apply transfer (*goal: ‹(m < nat z) = (int m < z)›*) by (clarsimp simp add: less_diff_conv (*‹(?i < ?j - ?k) = (?i + ?k < ?j)›*)) lemma (in ring_1) of_nat_nat [simp]: "0 ≤ z ⟹ of_nat (nat z) = of_int z" apply transfer (*goal: ‹0 ≤ z ⟹ of_nat (nat z) = of_int z›*) by (clarsimp simp add: of_nat_diff (*‹?n ≤ ?m ⟹ of_nat (?m - ?n) = of_nat ?m - of_nat ?n›*)) lemma diff_nat_numeral [simp]: "(numeral v :: nat) - numeral v' = nat (numeral v - numeral v')" by (simp only: nat_diff_distrib' (*‹⟦0 ≤ ?x; 0 ≤ ?y⟧ ⟹ nat (?x - ?y) = nat ?x - nat ?y›*) zero_le_numeral (*‹0 ≤ numeral ?n›*) nat_numeral (*‹nat (numeral ?k) = numeral ?k›*)) lemma nat_abs_triangle_ineq: "nat ¦k + l¦ ≤ nat ¦k¦ + nat ¦l¦" by (simp add: nat_add_distrib [symmetric] (*‹⟦0 ≤ ?z; 0 ≤ ?z'⟧ ⟹ nat ?z + nat ?z' = nat (?z + ?z')›*) nat_le_eq_zle (*‹0 < ?w ∨ 0 ≤ ?z ⟹ (nat ?w ≤ nat ?z) = (?w ≤ ?z)›*) abs_triangle_ineq (*‹¦?a + ?b¦ ≤ ¦?a¦ + ¦?b¦›*)) lemma nat_of_bool [simp]: "nat (of_bool P) = of_bool P" by auto lemma split_nat [linarith_split]: "P (nat i) ⟷ ((∀n. i = int n ⟶ P n) ∧ (i < 0 ⟶ P 0))" (is "?P = (?L ∧ ?R)") for i :: int proof (cases "i < 0") (*goals: 1. ‹i < 0 ⟹ P (nat i) = ((∀n. i = int n ⟶ P n) ∧ (i < 0 ⟶ P 0))› 2. ‹¬ i < 0 ⟹ P (nat i) = ((∀n. i = int n ⟶ P n) ∧ (i < 0 ⟶ P 0))›*) case True (*‹i < 0›*) then show "?thesis" (*goal: ‹P (nat i) = ((∀n. i = int n ⟶ P n) ∧ (i < 0 ⟶ P 0))›*) by auto next (*goal: ‹¬ i < 0 ⟹ P (nat i) = ((∀n. i = int n ⟶ P n) ∧ (i < 0 ⟶ P 0))›*) case False (*‹¬ i < 0›*) have "?P = ?L" proof (standard) (*goals: 1. ‹P (nat i) ⟹ ∀n. i = int n ⟶ P n› 2. ‹∀n. i = int n ⟶ P n ⟹ P (nat i)›*) assume "?P" (*‹(P::nat ⇒ bool) (nat (i::int))›*) then show "?L" using False (*‹¬ i < 0›*) by auto next (*goal: ‹∀n::nat. (i::int) = int n ⟶ (P::nat ⇒ bool) n ⟹ P (nat i)›*) assume "?L" (*‹∀n::nat. (i::int) = int n ⟶ (P::nat ⇒ bool) n›*) moreover from False (*‹¬ i < 0›*) have "int (nat i) = i" by (simp add: not_less (*‹(¬ ?x < ?y) = (?y ≤ ?x)›*)) ultimately show "?P" by simp qed with False (*‹¬ i < 0›*) show "?thesis" (*goal: ‹P (nat i) = ((∀n. i = int n ⟶ P n) ∧ (i < 0 ⟶ P 0))›*) by simp qed lemma all_nat: "(∀x. P x) ⟷ (∀x≥0. P (nat x))" by (auto split: split_nat (*‹?P (nat ?i) = ((∀n. ?i = int n ⟶ ?P n) ∧ (?i < 0 ⟶ ?P 0))›*)) lemma ex_nat: "(∃x. P x) ⟷ (∃x. 0 ≤ x ∧ P (nat x))" proof (standard) (*goals: 1. ‹∃x. P x ⟹ ∃x≥0. P (nat x)› 2. ‹∃x≥0. P (nat x) ⟹ ∃x. P x›*) assume "∃x. P x" (*‹∃x::nat. (P::nat ⇒ bool) x›*) then obtain x where "P x" (*goal: ‹(⋀x. P x ⟹ thesis) ⟹ thesis›*) by standard then have "int x ≥ 0 ∧ P (nat (int x))" by simp then show "∃x≥0. P (nat x)" apply - (*goal: ‹∃x≥0::int. (P::nat ⇒ bool) (nat x)›*) by standard next (*goal: ‹∃x≥0. P (nat x) ⟹ ∃x. P x›*) assume "∃x≥0. P (nat x)" (*‹∃x≥0::int. (P::nat ⇒ bool) (nat x)›*) then show "∃x. P x" by auto qed text ‹For termination proofs:› lemma measure_function_int[measure_function]: "is_measure (nat ∘ abs)" by standard subsection ‹Lemmas about the Function \<^term>‹of_nat› and Orderings› lemma negative_zless_0: "- (int (Suc n)) < (0 :: int)" by (simp add: order_less_le (*‹(?x < ?y) = (?x ≤ ?y ∧ ?x ≠ ?y)›*) del: of_nat_Suc (*‹of_nat (Suc ?m) = 1 + of_nat ?m›*)) lemma negative_zless [iff]: "- (int (Suc n)) < int m" apply (rule negative_zless_0 [THEN order_less_le_trans] (*‹0 ≤ ?z ⟹ - int (Suc ?n1) < ?z›*)) (*goal: ‹- int (Suc (n::nat)) < int (m::nat)›*) by simp lemma negative_zle_0: "- int n ≤ 0" by (simp add: minus_le_iff (*‹(- ?a ≤ ?b) = (- ?b ≤ ?a)›*)) lemma negative_zle [iff]: "- int n ≤ int m" by (rule order_trans [OF negative_zle_0 of_nat_0_le_iff] (*‹- int ?n2 ≤ int ?n1›*)) lemma not_zle_0_negative [simp]: "¬ 0 ≤ - int (Suc n)" apply (subst le_minus_iff (*‹(?a ≤ - ?b) = (?b ≤ - ?a)›*)) (*goal: ‹¬ (0::int) ≤ - int (Suc (n::nat))›*) by (simp del: of_nat_Suc (*‹of_nat (Suc ?m) = 1 + of_nat ?m›*)) lemma int_zle_neg: "int n ≤ - int m ⟷ n = 0 ∧ m = 0" apply transfer (*goal: ‹(int (n::nat) ≤ - int (m::nat)) = (n = (0::nat) ∧ m = (0::nat))›*) by simp lemma not_int_zless_negative [simp]: "¬ int n < - int m" by (simp add: linorder_not_less (*‹(¬ ?x < ?y) = (?y ≤ ?x)›*)) lemma negative_eq_positive [simp]: "- int n = of_nat m ⟷ n = 0 ∧ m = 0" by (force simp add: order_eq_iff [of "- of_nat n"] (*‹(- of_nat n = ?b) = (- of_nat n ≤ ?b ∧ ?b ≤ - of_nat n)›*) int_zle_neg (*‹(int ?n ≤ - int ?m) = (?n = 0 ∧ ?m = 0)›*)) lemma zle_iff_zadd: "w ≤ z ⟷ (∃n. z = w + int n)" (is "?lhs ⟷ ?rhs") proof (standard) (*goals: 1. ‹w ≤ z ⟹ ∃n. z = w + int n› 2. ‹∃n. z = w + int n ⟹ w ≤ z›*) assume "?rhs" (*‹∃n::nat. (z::int) = (w::int) + int n›*) then show "?lhs" by auto next (*goal: ‹w ≤ z ⟹ ∃n. z = w + int n›*) assume "?lhs" (*‹(w::int) ≤ (z::int)›*) then have "0 ≤ z - w" by simp then obtain n where "z - w = int n" (*goal: ‹(⋀n. z - w = int n ⟹ thesis) ⟹ thesis›*) using zero_le_imp_eq_int[of "z - w"] (*‹0 ≤ z - w ⟹ ∃n. z - w = int n›*) by blast then have "z = w + int n" by simp then show "?rhs" by standard qed lemma zadd_int_left: "int m + (int n + z) = int (m + n) + z" by simp lemma negD: assumes "x < 0" shows "∃n. x = - (int (Suc n))" proof (-) (*goal: ‹∃n. x = - int (Suc n)›*) have "⋀a b. a < b ⟹ ∃n. Suc (a + n) = b" proof (-) (*goal: ‹⋀a b. a < b ⟹ ∃n. Suc (a + n) = b›*) fix a :: nat and b :: nat assume "a < b" (*‹(a::nat) < (b::nat)›*) then have "Suc (a + (b - Suc a)) = b" by arith then show "∃n. Suc (a + n) = b" by (rule exI (*‹?P ?x ⟹ ∃x. ?P x›*)) qed with assms (*‹x < 0›*) show "?thesis" (*goal: ‹∃n. x = - int (Suc n)›*) apply transfer (*goal: ‹∃n. x = - int (Suc n)›*) by auto qed subsection ‹Cases and induction› text ‹ Now we replace the case analysis rule by a more conventional one: whether an integer is negative or not. › text ‹This version is symmetric in the two subgoals.› lemma int_cases2 [case_names nonneg nonpos, cases type: int]: "(⋀n. z = int n ⟹ P) ⟹ (⋀n. z = - (int n) ⟹ P) ⟹ P" apply (cases "z < 0") (*goals: 1. ‹⟦⋀n::nat. (z::int) = int n ⟹ P::bool; ⋀n::nat. z = - int n ⟹ P; z < (0::int)⟧ ⟹ P› 2. ‹⟦⋀n::nat. (z::int) = int n ⟹ P::bool; ⋀n::nat. z = - int n ⟹ P; ¬ z < (0::int)⟧ ⟹ P› discuss goal 1*) apply ((auto simp add: linorder_not_less (*‹(¬ ?x < ?y) = (?y ≤ ?x)›*) dest!: negD (*‹?x < 0 ⟹ ∃n. ?x = - int (Suc n)›*) nat_0_le [THEN sym] (*‹0 ≤ ?t ⟹ ?t = int (nat ?t)›*))[1]) (*discuss goal 2*) apply ((auto simp add: linorder_not_less (*‹(¬ ?x < ?y) = (?y ≤ ?x)›*) dest!: negD (*‹?x < 0 ⟹ ∃n. ?x = - int (Suc n)›*) nat_0_le [THEN sym] (*‹0 ≤ ?t ⟹ ?t = int (nat ?t)›*))[1]) (*proven 2 subgoals*) . text ‹This is the default, with a negative case.› lemma int_cases [case_names nonneg neg, cases type: int]: assumes pos: "⋀n. z = int n ⟹ P" and neg: "⋀n. z = - (int (Suc n)) ⟹ P" shows P proof (cases "z < 0") (*goals: 1. ‹z < 0 ⟹ P› 2. ‹¬ z < 0 ⟹ P›*) case True (*‹(z::int) < (0::int)›*) with neg (*‹(z::int) = - int (Suc (?n::nat)) ⟹ P::bool›*) show "?thesis" (*goal: ‹P::bool›*) by (blast dest!: negD (*‹(?x::int) < (0::int) ⟹ ∃n::nat. ?x = - int (Suc n)›*)) next (*goal: ‹¬ (z::int) < (0::int) ⟹ P::bool›*) case False (*‹¬ z < 0›*) with pos (*‹z = int ?n ⟹ P›*) show "?thesis" (*goal: ‹P›*) by (force simp add: linorder_not_less (*‹(¬ ?x < ?y) = (?y ≤ ?x)›*) dest: nat_0_le [THEN sym] (*‹0 ≤ ?t ⟹ ?t = int (nat ?t)›*)) qed lemma int_cases3 [case_names zero pos neg]: fixes k :: int assumes "k = 0 ⟹ P" and "⋀n. k = int n ⟹ n > 0 ⟹ P" and "⋀n. k = - int n ⟹ n > 0 ⟹ P" shows "P" proof (cases k "0::int" rule: linorder_cases (*‹⟦?x < ?y ⟹ ?P; ?x = ?y ⟹ ?P; ?y < ?x ⟹ ?P⟧ ⟹ ?P›*)) (*goals: 1. ‹k < 0 ⟹ P› 2. ‹k = 0 ⟹ P› 3. ‹0 < k ⟹ P›*) case equal (*‹k = 0›*) with assms(1) (*‹k = 0 ⟹ P›*) show P by simp next (*goals: 1. ‹(k::int) < (0::int) ⟹ P::bool› 2. ‹(0::int) < (k::int) ⟹ P::bool›*) case greater (*‹0 < k›*) then have "*": "nat k > 0" by simp moreover from "*" (*‹0 < nat k›*) have "k = int (nat k)" by auto ultimately show P using assms(2) (*‹⟦(k::int) = int (?n::nat); (0::nat) < ?n⟧ ⟹ P::bool›*) by blast next (*goal: ‹k < 0 ⟹ P›*) case less (*‹k < 0›*) then have "*": "nat (- k) > 0" by simp moreover from "*" (*‹(0::nat) < nat (- (k::int))›*) have "k = - int (nat (- k))" by auto ultimately show P using assms(3) (*‹⟦k = - int ?n; 0 < ?n⟧ ⟹ P›*) by blast qed lemma int_of_nat_induct [case_names nonneg neg, induct type: int]: "(⋀n. P (int n)) ⟹ (⋀n. P (- (int (Suc n)))) ⟹ P z" apply (cases z) (*goals: 1. ‹⋀n. ⟦⋀n. P (int n); ⋀n. P (- int (Suc n)); z = int n⟧ ⟹ P z› 2. ‹⋀n. ⟦⋀n. P (int n); ⋀n. P (- int (Suc n)); z = - int (Suc n)⟧ ⟹ P z› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . lemma sgn_mult_dvd_iff [simp]: "sgn r * l dvd k ⟷ l dvd k ∧ (r = 0 ⟶ k = 0)" for k l r :: int apply (cases r rule: int_cases3 (*‹⟦?k = 0 ⟹ ?P; ⋀n. ⟦?k = int n; 0 < n⟧ ⟹ ?P; ⋀n. ⟦?k = - int n; 0 < n⟧ ⟹ ?P⟧ ⟹ ?P›*)) (*goals: 1. ‹r = 0 ⟹ (sgn r * l dvd k) = (l dvd k ∧ (r = 0 ⟶ k = 0))› 2. ‹⋀n. ⟦r = int n; 0 < n⟧ ⟹ (sgn r * l dvd k) = (l dvd k ∧ (r = 0 ⟶ k = 0))› 3. ‹⋀n. ⟦r = - int n; 0 < n⟧ ⟹ (sgn r * l dvd k) = (l dvd k ∧ (r = 0 ⟶ k = 0))› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*proven 3 subgoals*) . lemma mult_sgn_dvd_iff [simp]: "l * sgn r dvd k ⟷ l dvd k ∧ (r = 0 ⟶ k = 0)" for k l r :: int using sgn_mult_dvd_iff[of r l k] (*‹(sgn r * l dvd k) = (l dvd k ∧ (r = 0 ⟶ k = 0))›*) by (simp add: 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 13 facts*)) lemma dvd_sgn_mult_iff [simp]: "l dvd sgn r * k ⟷ l dvd k ∨ r = 0" for k l r :: int apply (cases r rule: int_cases3 (*‹⟦?k = 0 ⟹ ?P; ⋀n. ⟦?k = int n; 0 < n⟧ ⟹ ?P; ⋀n. ⟦?k = - int n; 0 < n⟧ ⟹ ?P⟧ ⟹ ?P›*)) (*goals: 1. ‹r = 0 ⟹ (l dvd sgn r * k) = (l dvd k ∨ r = 0)› 2. ‹⋀n. ⟦r = int n; 0 < n⟧ ⟹ (l dvd sgn r * k) = (l dvd k ∨ r = 0)› 3. ‹⋀n. ⟦r = - int n; 0 < n⟧ ⟹ (l dvd sgn r * k) = (l dvd k ∨ r = 0)› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*discuss goal 3*) apply simp (*proven 3 subgoals*) . lemma dvd_mult_sgn_iff [simp]: "l dvd k * sgn r ⟷ l dvd k ∨ r = 0" for k l r :: int using dvd_sgn_mult_iff[of l r k] (*‹(l dvd sgn r * k) = (l dvd k ∨ r = 0)›*) by (simp add: 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 13 facts*)) lemma int_sgnE: fixes k :: int obtains n and l where "k = sgn l * int n" proof (-) (*goal: ‹(⋀l n. k = sgn l * int n ⟹ thesis) ⟹ thesis›*) have "k = sgn k * int (nat ¦k¦)" by (simp add: sgn_mult_abs (*‹sgn (?a::?'a) * ¦?a¦ = ?a›*)) then show "?thesis" (*goal: ‹thesis›*) by standard qed subsubsection ‹Binary comparisons› text ‹Preliminaries› lemma le_imp_0_less: fixes z :: int assumes le: "0 ≤ z" shows "0 < 1 + z" proof (-) (*goal: ‹(0::int) < (1::int) + (z::int)›*) have "0 ≤ z" by fact also (*calculation: ‹0 ≤ z›*) have "… < z + 1" by (rule less_add_one (*‹?a < ?a + 1›*)) also (*calculation: ‹0 < z + 1›*) have "… = 1 + z" by (simp add: 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 13 facts*)) finally (*calculation: ‹0 < 1 + z›*) show "0 < 1 + z" . qed lemma odd_less_0_iff: "1 + z + z < 0 ⟷ z < 0" for z :: int proof (cases z) (*goals: 1. ‹⋀n. z = int n ⟹ (1 + z + z < 0) = (z < 0)› 2. ‹⋀n. z = - int (Suc n) ⟹ (1 + z + z < 0) = (z < 0)›*) case (nonneg n) (*‹(z::int) = int (n::nat)›*) then show "?thesis" (*goal: ‹(1 + z + z < 0) = (z < 0)›*) by (simp add: linorder_not_less (*‹(¬ ?x < ?y) = (?y ≤ ?x)›*) add.assoc (*‹?a + ?b + ?c = ?a + (?b + ?c)›*) add_increasing (*‹⟦0 ≤ ?a; ?b ≤ ?c⟧ ⟹ ?b ≤ ?a + ?c›*) le_imp_0_less [THEN order_less_imp_le] (*‹0 ≤ ?z1 ⟹ 0 ≤ 1 + ?z1›*)) next (*goal: ‹⋀n. z = - int (Suc n) ⟹ (1 + z + z < 0) = (z < 0)›*) case (neg n) (*‹(z::int) = - int (Suc (n::nat))›*) then show "?thesis" (*goal: ‹(1 + z + z < 0) = (z < 0)›*) by (simp del: of_nat_Suc (*‹of_nat (Suc ?m) = 1 + of_nat ?m›*) of_nat_add (*‹of_nat (?m + ?n) = of_nat ?m + of_nat ?n›*) of_nat_1 (*‹of_nat 1 = 1›*) 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*) of_nat_1 [where 'a=int, symmetric] (*‹1 = int 1›*) of_nat_add [symmetric] (*‹of_nat ?m + of_nat ?n = of_nat (?m + ?n)›*)) qed subsubsection ‹Comparisons, for Ordered Rings› lemma odd_nonzero: "1 + z + z ≠ 0" for z :: int proof (cases z) (*goals: 1. ‹⋀n. z = int n ⟹ 1 + z + z ≠ 0› 2. ‹⋀n. z = - int (Suc n) ⟹ 1 + z + z ≠ 0›*) case (nonneg n) (*‹(z::int) = int (n::nat)›*) have le: "0 ≤ z + z" by (simp add: nonneg (*‹z = int n›*) add_increasing (*‹⟦0 ≤ ?a; ?b ≤ ?c⟧ ⟹ ?b ≤ ?a + ?c›*)) then show "?thesis" (*goal: ‹1 + z + z ≠ 0›*) using le_imp_0_less[OF le] (*‹0 < 1 + (z + z)›*) 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 13 facts*)) next (*goal: ‹⋀n. z = - int (Suc n) ⟹ 1 + z + z ≠ 0›*) case (neg n) (*‹z = - int (Suc n)›*) show "?thesis" (*goal: ‹1 + z + z ≠ 0›*) proof (standard) (*goal: ‹1 + z + z = 0 ⟹ False›*) assume eq: "1 + z + z = 0" (*‹(1::int) + (z::int) + z = (0::int)›*) have "0 < 1 + (int n + int n)" by (simp add: le_imp_0_less (*‹0 ≤ ?z ⟹ 0 < 1 + ?z›*) add_increasing (*‹⟦0 ≤ ?a; ?b ≤ ?c⟧ ⟹ ?b ≤ ?a + ?c›*)) also (*calculation: ‹(0::int) < (1::int) + (int (n::nat) + int n)›*) have "… = - (1 + z + z)" by (simp add: neg (*‹z = - int (Suc n)›*) add.assoc [symmetric] (*‹?a + (?b + ?c) = ?a + ?b + ?c›*)) also (*calculation: ‹0 < - (1 + z + z)›*) have "… = 0" by (simp add: eq (*‹1 + z + z = 0›*)) finally (*calculation: ‹0 < 0›*) have "0<0" by standard then show False by blast qed qed subsection ‹The Set of Integers› context ring_1 begin definition Ints :: "'a set" ("ℤ") where "ℤ = range of_int" lemma Ints_of_int [simp]: "of_int z ∈ ℤ" by (simp add: Ints_def (*‹ℤ = range of_int›*)) lemma Ints_of_nat [simp]: "of_nat n ∈ ℤ" using Ints_of_int[of "of_nat n"] (*‹of_int (int (n::nat)) ∈ ℤ›*) by simp lemma Ints_0 [simp]: "0 ∈ ℤ" using Ints_of_int[of "0"] (*‹of_int 0 ∈ ℤ›*) by simp lemma Ints_1 [simp]: "1 ∈ ℤ" using Ints_of_int[of "1"] (*‹of_int 1 ∈ ℤ›*) by simp lemma Ints_numeral [simp]: "numeral n ∈ ℤ" apply (subst of_nat_numeral [symmetric] (*‹numeral ?n = of_nat (numeral ?n)›*)) (*goal: ‹numeral n ∈ ℤ›*) by (rule Ints_of_nat (*‹of_nat ?n ∈ ℤ›*)) lemma Ints_add [simp]: "a ∈ ℤ ⟹ b ∈ ℤ ⟹ a + b ∈ ℤ" by (force simp add: Ints_def (*‹ℤ = range of_int›*) simp flip: of_int_add (*‹of_int (?w + ?z) = of_int ?w + of_int ?z›*) intro: range_eqI (*‹?b = ?f ?x ⟹ ?b ∈ range ?f›*)) lemma Ints_minus [simp]: "a ∈ ℤ ⟹ -a ∈ ℤ" by (force simp add: Ints_def (*‹ℤ = range of_int›*) simp flip: of_int_minus (*‹of_int (- ?z) = - of_int ?z›*) intro: range_eqI (*‹?b = ?f ?x ⟹ ?b ∈ range ?f›*)) lemma minus_in_Ints_iff: "-x ∈ ℤ ⟷ x ∈ ℤ" using Ints_minus[of x] (*‹(x::'a) ∈ ℤ ⟹ - x ∈ ℤ›*) Ints_minus[of "-x"] (*‹- x ∈ ℤ ⟹ - (- x) ∈ ℤ›*) by auto lemma Ints_diff [simp]: "a ∈ ℤ ⟹ b ∈ ℤ ⟹ a - b ∈ ℤ" by (force simp add: Ints_def (*‹ℤ = range of_int›*) simp flip: of_int_diff (*‹of_int (?w - ?z) = of_int ?w - of_int ?z›*) intro: range_eqI (*‹?b = ?f ?x ⟹ ?b ∈ range ?f›*)) lemma Ints_mult [simp]: "a ∈ ℤ ⟹ b ∈ ℤ ⟹ a * b ∈ ℤ" by (force simp add: Ints_def (*‹ℤ = range of_int›*) simp flip: of_int_mult (*‹of_int ((?w::int) * (?z::int)) = of_int ?w * of_int ?z›*) intro: range_eqI (*‹(?b::?'a) = (?f::?'b ⇒ ?'a) (?x::?'b) ⟹ ?b ∈ range ?f›*)) lemma Ints_power [simp]: "a ∈ ℤ ⟹ a ^ n ∈ ℤ" apply (induct n) (*goals: 1. ‹a ∈ ℤ ⟹ a ^ 0 ∈ ℤ› 2. ‹⋀n. ⟦a ∈ ℤ ⟹ a ^ n ∈ ℤ; a ∈ ℤ⟧ ⟹ a ^ Suc n ∈ ℤ› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) . lemma Ints_cases [cases set: Ints]: assumes "q ∈ ℤ" obtains (of_int) z where "q = of_int z" unfolding Ints_def (*goal: ‹(⋀z. q = of_int z ⟹ thesis) ⟹ thesis›*) proof (-) (*goal: ‹(⋀z. q = of_int z ⟹ thesis) ⟹ thesis›*) from ‹q ∈ ℤ› (*‹q ∈ ℤ›*) have "q ∈ range of_int" unfolding Ints_def (*goal: ‹(q::'a) ∈ range of_int›*) . then obtain z where "q = of_int z" (*goal: ‹(⋀z. q = of_int z ⟹ thesis) ⟹ thesis›*) by standard then show thesis by standard qed lemma Ints_induct [case_names of_int, induct set: Ints]: "q ∈ ℤ ⟹ (⋀z. P (of_int z)) ⟹ P q" apply (rule Ints_cases (*‹⟦?q ∈ ℤ; ⋀z. ?q = of_int z ⟹ ?thesis⟧ ⟹ ?thesis›*)) (*goal: ‹⟦q ∈ ℤ; ⋀z. P (of_int z)⟧ ⟹ P q›*) by auto lemma Nats_subset_Ints: "ℕ ⊆ ℤ" unfolding Nats_def Ints_def (*goal: ‹range of_nat ⊆ range of_int›*) apply (rule subsetI (*‹(⋀x. x ∈ ?A ⟹ x ∈ ?B) ⟹ ?A ⊆ ?B›*)) (*goal: ‹range of_nat ⊆ range of_int›*) apply (elim imageE (*‹⟦(?b::?'a) ∈ (?f::?'b ⇒ ?'a) ` (?A::?'b set); ⋀x::?'b. ⟦?b = ?f x; x ∈ ?A⟧ ⟹ ?thesis::bool⟧ ⟹ ?thesis›*)) (*goal: ‹⋀x::'a. x ∈ range of_nat ⟹ x ∈ range of_int›*) apply hypsubst (*goal: ‹⋀x xa. ⟦x = of_nat xa; xa ∈ UNIV⟧ ⟹ x ∈ range of_int›*) apply (subst of_int_of_nat_eq[symmetric] (*‹of_nat (?n::nat) = of_int (int ?n)›*)) (*goal: ‹⋀x xa. xa ∈ UNIV ⟹ of_nat xa ∈ range of_int›*) apply (rule imageI (*‹?x ∈ ?A ⟹ ?f ?x ∈ ?f ` ?A›*)) (*goal: ‹⋀x xa. xa ∈ UNIV ⟹ of_int (int xa) ∈ range of_int›*) by simp lemma Nats_altdef1: "ℕ = {of_int n |n. n ≥ 0}" proof (intro subsetI (*‹(⋀x. x ∈ ?A ⟹ x ∈ ?B) ⟹ ?A ⊆ ?B›*) equalityI (*‹⟦?A ⊆ ?B; ?B ⊆ ?A⟧ ⟹ ?A = ?B›*)) (*goals: 1. ‹⋀x. x ∈ ℕ ⟹ x ∈ {of_int n |n. 0 ≤ n}› 2. ‹⋀x. x ∈ {of_int n |n. 0 ≤ n} ⟹ x ∈ ℕ›*) fix x :: 'a assume "x ∈ {of_int n |n. n ≥ 0}" (*‹(x::'a) ∈ {of_int n |n::int. (0::int) ≤ n}›*) then obtain n where "x = of_int n" "n ≥ 0" (*goal: ‹(⋀n. ⟦x = of_int n; 0 ≤ n⟧ ⟹ thesis) ⟹ thesis›*) by (auto elim!: Ints_cases (*‹⟦(?q::'a) ∈ ℤ; ⋀z::int. ?q = of_int z ⟹ ?thesis::bool⟧ ⟹ ?thesis›*)) then have "x = of_nat (nat n)" apply (subst of_nat_nat (*‹0 ≤ ?z ⟹ of_nat (nat ?z) = of_int ?z›*)) (*goals: 1. ‹⟦x = of_int n; 0 ≤ n⟧ ⟹ 0 ≤ n› 2. ‹⟦x = of_int n; 0 ≤ n⟧ ⟹ x = of_int n› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) . then show "x ∈ ℕ" by simp next (*goal: ‹⋀x. x ∈ ℕ ⟹ x ∈ {of_int n |n. 0 ≤ n}›*) fix x :: 'a assume "x ∈ ℕ" (*‹(x::'a) ∈ ℕ›*) then obtain n where "x = of_nat n" (*goal: ‹(⋀n. x = of_nat n ⟹ thesis) ⟹ thesis›*) by (auto elim!: Nats_cases (*‹⟦?x ∈ ℕ; ⋀n. ?x = of_nat n ⟹ ?thesis⟧ ⟹ ?thesis›*)) then have "x = of_int (int n)" by simp also (*calculation: ‹x = of_int (int n)›*) have "int n ≥ 0" by simp then have "of_int (int n) ∈ {of_int n |n. n ≥ 0}" by blast finally (*calculation: ‹(x::'a) ∈ {of_int n |n::int. (0::int) ≤ n}›*) show "x ∈ {of_int n |n. n ≥ 0}" . qed end lemma Ints_sum [intro]: "(⋀x. x ∈ A ⟹ f x ∈ ℤ) ⟹ sum f A ∈ ℤ" apply (induction 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; ⋀x. x ∈ A ⟹ f x ∈ ℤ⟧ ⟹ sum f A ∈ ℤ› 2. ‹(⋀x. x ∈ {} ⟹ f x ∈ ℤ) ⟹ sum f {} ∈ ℤ› 3. ‹⋀x F. ⟦finite F; x ∉ F; (⋀x. x ∈ F ⟹ f x ∈ ℤ) ⟹ sum f F ∈ ℤ; ⋀xa. xa ∈ insert x F ⟹ f xa ∈ ℤ⟧ ⟹ 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*) . lemma Ints_prod [intro]: "(⋀x. x ∈ A ⟹ f x ∈ ℤ) ⟹ prod f A ∈ ℤ" apply (induction 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; ⋀x. x ∈ A ⟹ f x ∈ ℤ⟧ ⟹ prod f A ∈ ℤ› 2. ‹(⋀x. x ∈ {} ⟹ f x ∈ ℤ) ⟹ prod f {} ∈ ℤ› 3. ‹⋀x F. ⟦finite F; x ∉ F; (⋀x. x ∈ F ⟹ f x ∈ ℤ) ⟹ prod f F ∈ ℤ; ⋀xa. xa ∈ insert x F ⟹ f xa ∈ ℤ⟧ ⟹ 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*) . lemma (in linordered_idom) Ints_abs [simp]: shows "a ∈ ℤ ⟹ abs a ∈ ℤ" by (auto simp: abs_if (*‹¦?a¦ = (if ?a < 0 then - ?a else ?a)›*)) lemma (in linordered_idom) Nats_altdef2: "ℕ = {n ∈ ℤ. n ≥ 0}" proof (intro subsetI (*‹(⋀x. x ∈ ?A ⟹ x ∈ ?B) ⟹ ?A ⊆ ?B›*) equalityI (*‹⟦?A ⊆ ?B; ?B ⊆ ?A⟧ ⟹ ?A = ?B›*)) (*goals: 1. ‹⋀x. x ∈ ℕ ⟹ x ∈ {n ∈ ℤ. 0 ≤ n}› 2. ‹⋀x. x ∈ {n ∈ ℤ. 0 ≤ n} ⟹ x ∈ ℕ›*) fix x :: 'a assume "x ∈ {n ∈ ℤ. n ≥ 0}" (*‹(x::'a) ∈ {n::'a ∈ ℤ. (0::'a) ≤ n}›*) then obtain n where "x = of_int n" "n ≥ 0" (*goal: ‹(⋀n. ⟦x = of_int n; 0 ≤ n⟧ ⟹ thesis) ⟹ thesis›*) by (auto elim!: Ints_cases (*‹⟦?q ∈ ℤ; ⋀z. ?q = of_int z ⟹ ?thesis⟧ ⟹ ?thesis›*)) then have "x = of_nat (nat n)" apply (subst of_nat_nat (*‹0 ≤ ?z ⟹ of_nat (nat ?z) = of_int ?z›*)) (*goals: 1. ‹⟦x = of_int n; 0 ≤ n⟧ ⟹ 0 ≤ n› 2. ‹⟦x = of_int n; 0 ≤ n⟧ ⟹ x = of_int n› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) . then show "x ∈ ℕ" by simp qed (auto elim!: Nats_cases (*‹⟦(?x::'a) ∈ ℕ; ⋀n::nat. ?x = of_nat n ⟹ ?thesis::bool⟧ ⟹ ?thesis›*)) (*solved the remaining goal: ‹⋀x. x ∈ ℕ ⟹ x ∈ {n ∈ ℤ. 0 ≤ n}›*) lemma (in idom_divide) of_int_divide_in_Ints: "of_int a div of_int b ∈ ℤ" if "b dvd a" proof (-) (*goal: ‹of_int (a::int) div of_int (b::int) ∈ ℤ›*) from that (*‹(b::int) dvd (a::int)›*) obtain c where "a = b * c" (*goal: ‹(⋀c. a = b * c ⟹ thesis) ⟹ thesis›*) by standard then show "?thesis" (*goal: ‹of_int (a::int) div of_int (b::int) ∈ ℤ›*) apply (cases "of_int b = 0") (*goals: 1. ‹⟦a = b * c; of_int b = 0⟧ ⟹ of_int a div of_int b ∈ ℤ› 2. ‹⟦a = b * c; of_int b ≠ 0⟧ ⟹ of_int a div of_int b ∈ ℤ› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) . qed text ‹The premise involving \<^term>‹Ints› prevents \<^term>‹a = 1/2›.› lemma Ints_double_eq_0_iff: fixes a :: "'a::ring_char_0" assumes in_Ints: "a ∈ ℤ" shows "a + a = 0 ⟷ a = 0" (is "?lhs ⟷ ?rhs") proof (-) (*goal: ‹(a + a = 0) = (a = 0)›*) from in_Ints (*‹a ∈ ℤ›*) have "a ∈ range of_int" unfolding Ints_def[symmetric] (*goal: ‹a ∈ ℤ›*) . then obtain z where a: "a = of_int z" (*goal: ‹(⋀z. a = of_int z ⟹ thesis) ⟹ thesis›*) by standard show "?thesis" (*goal: ‹(a + a = 0) = (a = 0)›*) proof (standard) (*goals: 1. ‹a + a = 0 ⟹ a = 0› 2. ‹a = 0 ⟹ a + a = 0›*) assume "?rhs" (*‹(a::'a) = (0::'a)›*) then show "?lhs" by simp next (*goal: ‹a + a = 0 ⟹ a = 0›*) assume "?lhs" (*‹(a::'a) + a = (0::'a)›*) with a (*‹(a::'a) = of_int (z::int)›*) have "of_int (z + z) = (of_int 0 :: 'a)" by simp then have "z + z = 0" by (simp only: of_int_eq_iff (*‹(of_int ?w = of_int ?z) = (?w = ?z)›*)) then have "z = 0" by (simp only: double_zero (*‹(?a + ?a = 0) = (?a = 0)›*)) with a (*‹a = of_int z›*) show "?rhs" by simp qed qed lemma Ints_odd_nonzero: fixes a :: "'a::ring_char_0" assumes in_Ints: "a ∈ ℤ" shows "1 + a + a ≠ 0" proof (-) (*goal: ‹1 + a + a ≠ 0›*) from in_Ints (*‹a ∈ ℤ›*) have "a ∈ range of_int" unfolding Ints_def[symmetric] (*goal: ‹a ∈ ℤ›*) . then obtain z where a: "a = of_int z" (*goal: ‹(⋀z. a = of_int z ⟹ thesis) ⟹ thesis›*) by standard show "?thesis" (*goal: ‹1 + a + a ≠ 0›*) proof (standard) (*goal: ‹1 + a + a = 0 ⟹ False›*) assume "1 + a + a = 0" (*‹(1::'a) + (a::'a) + a = (0::'a)›*) with a (*‹a = of_int z›*) have "of_int (1 + z + z) = (of_int 0 :: 'a)" by simp then have "1 + z + z = 0" by (simp only: of_int_eq_iff (*‹(of_int ?w = of_int ?z) = (?w = ?z)›*)) with odd_nonzero (*‹1 + ?z + ?z ≠ 0›*) show False by blast qed qed lemma Nats_numeral [simp]: "numeral w ∈ ℕ" using of_nat_in_Nats[of "numeral w"] (*‹of_nat (numeral w) ∈ ℕ›*) by simp lemma Ints_odd_less_0: fixes a :: "'a::linordered_idom" assumes in_Ints: "a ∈ ℤ" shows "1 + a + a < 0 ⟷ a < 0" proof (-) (*goal: ‹(1 + a + a < 0) = (a < 0)›*) from in_Ints (*‹a ∈ ℤ›*) have "a ∈ range of_int" unfolding Ints_def[symmetric] (*goal: ‹a ∈ ℤ›*) . then obtain z where a: "a = of_int z" (*goal: ‹(⋀z. a = of_int z ⟹ thesis) ⟹ thesis›*) by standard with a (*‹a = of_int z›*) have "1 + a + a < 0 ⟷ of_int (1 + z + z) < (of_int 0 :: 'a)" by simp also (*calculation: ‹(1 + a + a < 0) = (of_int (1 + z + z) < of_int 0)›*) have "… ⟷ z < 0" by (simp only: of_int_less_iff (*‹(of_int ?w < of_int ?z) = (?w < ?z)›*) odd_less_0_iff (*‹(1 + ?z + ?z < 0) = (?z < 0)›*)) also (*calculation: ‹(1 + a + a < 0) = (z < 0)›*) have "… ⟷ a < 0" by (simp add: a (*‹a = of_int z›*)) finally (*calculation: ‹(1 + a + a < 0) = (a < 0)›*) show "?thesis" (*goal: ‹(1 + a + a < 0) = (a < 0)›*) . qed subsection ‹\<^term>‹sum› and \<^term>‹prod›› context semiring_1 begin lemma of_nat_sum [simp]: "of_nat (sum f A) = (∑x∈A. of_nat (f x))" apply (induction 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 ⟹ of_nat (sum f A) = (∑x∈A. of_nat (f x))› 2. ‹of_nat (sum f {}) = (∑x∈{}. of_nat (f x))› 3. ‹⋀x F. ⟦finite F; x ∉ F; of_nat (sum f F) = (∑x∈F. of_nat (f x))⟧ ⟹ of_nat (sum f (insert x F)) = (∑x∈insert x F. of_nat (f x))› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*proven 3 subgoals*) . end context ring_1 begin lemma of_int_sum [simp]: "of_int (sum f A) = (∑x∈A. of_int (f x))" apply (induction 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 ⟹ of_int (sum f A) = (∑x∈A. of_int (f x))› 2. ‹of_int (sum f {}) = (∑x∈{}. of_int (f x))› 3. ‹⋀x F. ⟦finite F; x ∉ F; of_int (sum f F) = (∑x∈F. of_int (f x))⟧ ⟹ of_int (sum f (insert x F)) = (∑x∈insert x F. of_int (f x))› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*proven 3 subgoals*) . end context comm_semiring_1 begin lemma of_nat_prod [simp]: "of_nat (prod f A) = (∏x∈A. of_nat (f x))" apply (induction A 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::'b::type set. infinite A ⟹ of_nat (prod (f::'b::type ⇒ nat) A) = (∏x::'b::type∈A. of_nat (f x))› 2. ‹of_nat (prod (f::'b::type ⇒ nat) {}) = (∏x::'b::type∈{}. of_nat (f x))› 3. ‹⋀(x::'b::type) F::'b::type set. ⟦finite F; x ∉ F; of_nat (prod (f::'b::type ⇒ nat) F) = (∏x::'b::type∈F. of_nat (f x))⟧ ⟹ of_nat (prod f (insert x F)) = (∏x::'b::type∈insert x F. of_nat (f x))› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*proven 3 subgoals*) . end context comm_ring_1 begin lemma of_int_prod [simp]: "of_int (prod f A) = (∏x∈A. of_int (f x))" apply (induction 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 ⟹ of_int (prod f A) = (∏x∈A. of_int (f x))› 2. ‹of_int (prod f {}) = (∏x∈{}. of_int (f x))› 3. ‹⋀x F. ⟦finite F; x ∉ F; of_int (prod f F) = (∏x∈F. of_int (f x))⟧ ⟹ of_int (prod f (insert x F)) = (∏x∈insert x F. of_int (f x))› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*proven 3 subgoals*) . end subsection ‹Setting up simplification procedures› ML_file ‹Tools/int_arith.ML› declaration ‹K ( Lin_Arith.add_discrete_type \<^type_name>‹Int.int› #> Lin_Arith.add_lessD @{thm zless_imp_add1_zle} #> Lin_Arith.add_inj_thms @{thms of_nat_le_iff [THEN iffD2] of_nat_eq_iff [THEN iffD2]} #> Lin_Arith.add_inj_const (\<^const_name>‹of_nat›, \<^typ>‹nat ⇒ int›) #> Lin_Arith.add_simps @{thms of_int_0 of_int_1 of_int_add of_int_mult of_int_numeral of_int_neg_numeral nat_0 nat_1 diff_nat_numeral nat_numeral neg_less_iff_less True_implies_equals distrib_left [where a = "numeral v" for v] distrib_left [where a = "- numeral v" for v] div_by_1 div_0 times_divide_eq_right times_divide_eq_left minus_divide_left [THEN sym] minus_divide_right [THEN sym] add_divide_distrib diff_divide_distrib of_int_minus of_int_diff of_int_of_nat_eq} #> Lin_Arith.add_simprocs [Int_Arith.zero_one_idom_simproc] )› simproc_setup fast_arith ("(m::'a::linordered_idom) < n" | "(m::'a::linordered_idom) ≤ n" | "(m::'a::linordered_idom) = n") = ‹K Lin_Arith.simproc› subsection‹More Inequality Reasoning› lemma zless_add1_eq: "w < z + 1 ⟷ w < z ∨ w = z" for w z :: int by arith lemma add1_zle_eq: "w + 1 ≤ z ⟷ w < z" for w z :: int by arith lemma zle_diff1_eq [simp]: "w ≤ z - 1 ⟷ w < z" for w z :: int by arith lemma zle_add1_eq_le [simp]: "w < z + 1 ⟷ w ≤ z" for w z :: int by arith lemma int_one_le_iff_zero_less: "1 ≤ z ⟷ 0 < z" for z :: int by arith lemma Ints_nonzero_abs_ge1: fixes x:: "'a :: linordered_idom" assumes "x ∈ Ints" "x ≠ 0" shows "1 ≤ abs x" proof (rule Ints_cases [OF ‹x ∈ Ints›] (*‹(⋀z. x = of_int z ⟹ ?thesis) ⟹ ?thesis›*)) (*goal: ‹⋀z. x = of_int z ⟹ 1 ≤ ¦x¦›*) fix z :: int assume "x = of_int z" (*‹(x::'a) = of_int (z::int)›*) with ‹x ≠ 0› (*‹x ≠ 0›*) show "1 ≤ ¦x¦" apply (auto simp: abs_if (*‹¦?a::?'a¦ = (if ?a < (0::?'a) then - ?a else ?a)›*)) (*goal: ‹1 ≤ ¦x¦›*) by (metis diff_0 (*‹(0::?'a) - (?a::?'a) = - ?a›*) of_int_1 (*‹of_int (1::int) = (1::?'a)›*) of_int_le_iff (*‹(of_int (?w::int) ≤ of_int (?z::int)) = (?w ≤ ?z)›*) of_int_minus (*‹of_int (- (?z::int)) = - of_int ?z›*) zle_diff1_eq (*‹((?w::int) ≤ (?z::int) - (1::int)) = (?w < ?z)›*)) qed lemma Ints_nonzero_abs_less1: fixes x:: "'a :: linordered_idom" shows "⟦x ∈ Ints; abs x < 1⟧ ⟹ x = 0" using Ints_nonzero_abs_ge1[of x] (*‹⟦x ∈ ℤ; x ≠ 0⟧ ⟹ 1 ≤ ¦x¦›*) by auto lemma Ints_eq_abs_less1: fixes x:: "'a :: linordered_idom" shows "⟦x ∈ Ints; y ∈ Ints⟧ ⟹ x = y ⟷ abs (x-y) < 1" using eq_iff_diff_eq_0 (*‹(?a = ?b) = (?a - ?b = 0)›*) by (fastforce intro: Ints_nonzero_abs_less1 (*‹⟦?x ∈ ℤ; ¦?x¦ < 1⟧ ⟹ ?x = 0›*)) subsection ‹The functions \<^term>‹nat› and \<^term>‹int›› text ‹Simplify the term \<^term>‹w + - z›.› lemma one_less_nat_eq [simp]: "Suc 0 < nat z ⟷ 1 < z" using zless_nat_conj[of 1 z] (*‹(nat 1 < nat z) = (0 < z ∧ 1 < z)›*) by auto lemma int_eq_iff_numeral [simp]: "int m = numeral v ⟷ m = numeral v" by (simp add: int_eq_iff (*‹(int ?m = ?z) = (?m = nat ?z ∧ 0 ≤ ?z)›*)) lemma nat_abs_int_diff: "nat ¦int a - int b¦ = (if a ≤ b then b - a else a - b)" by auto lemma nat_int_add: "nat (int a + int b) = a + b" by auto context ring_1 begin lemma of_int_of_nat [nitpick_simp]: "of_int k = (if k < 0 then - of_nat (nat (- k)) else of_nat (nat k))" proof (cases "k < 0") (*goals: 1. ‹k < 0 ⟹ of_int k = (if k < 0 then - of_nat (nat (- k)) else of_nat (nat k))› 2. ‹¬ k < 0 ⟹ of_int k = (if k < 0 then - of_nat (nat (- k)) else of_nat (nat k))›*) case True (*‹k < 0›*) then have "0 ≤ - k" by simp then have "of_nat (nat (- k)) = of_int (- k)" by (rule of_nat_nat (*‹(0::int) ≤ (?z::int) ⟹ of_nat (nat ?z) = of_int ?z›*)) with True (*‹k < 0›*) show "?thesis" (*goal: ‹of_int k = (if k < 0 then - of_nat (nat (- k)) else of_nat (nat k))›*) by simp next (*goal: ‹¬ k < 0 ⟹ of_int k = (if k < 0 then - of_nat (nat (- k)) else of_nat (nat k))›*) case False (*‹¬ (k::int) < (0::int)›*) then show "?thesis" (*goal: ‹of_int k = (if k < 0 then - of_nat (nat (- k)) else of_nat (nat k))›*) by (simp add: not_less (*‹(¬ ?x < ?y) = (?y ≤ ?x)›*)) qed end lemma transfer_rule_of_int: includes lifting_syntax fixes R :: "'a::ring_1 ⇒ 'b::ring_1 ⇒ bool" assumes [transfer_rule]: "R 0 0" "R 1 1" "(R ===> R ===> R) (+) (+)" "(R ===> R) uminus uminus" shows "((=) ===> R) of_int of_int" proof (-) (*goal: ‹((=) ===> R) of_int of_int›*) note assms (*‹R 0 0› ‹R 1 1› ‹((R::'a::ring_1 ⇒ 'b::ring_1 ⇒ bool) ===> R ===> R) (+) (+)› ‹((R::'a::ring_1 ⇒ 'b::ring_1 ⇒ bool) ===> R) uminus uminus›*) note transfer_rule_of_nat[transfer_rule] (*‹⟦?R 0 0; ?R 1 1; (?R ===> ?R ===> ?R) (+) (+)⟧ ⟹ ((=) ===> ?R) of_nat of_nat›*) have [transfer_rule]: "((=) ===> R) of_nat of_nat" by transfer_prover show "?thesis" (*goal: ‹((=) ===> R) of_int of_int›*) apply (unfold of_int_of_nat [abs_def] (*‹of_int ≡ λk::int. if k < (0::int) then - of_nat (nat (- k)) else of_nat (nat k)›*)) (*goal: ‹((=) ===> R) of_int of_int›*) by transfer_prover qed lemma nat_mult_distrib: fixes z z' :: int assumes "0 ≤ z" shows "nat (z * z') = nat z * nat z'" proof (cases "0 ≤ z'") (*goals: 1. ‹0 ≤ z' ⟹ nat (z * z') = nat z * nat z'› 2. ‹¬ 0 ≤ z' ⟹ nat (z * z') = nat z * nat z'›*) case False (*‹¬ 0 ≤ z'›*) with assms (*‹(0::int) ≤ (z::int)›*) have "z * z' ≤ 0" by (simp add: not_le (*‹(¬ ?x ≤ ?y) = (?y < ?x)›*) mult_le_0_iff (*‹(?a * ?b ≤ 0) = (0 ≤ ?a ∧ ?b ≤ 0 ∨ ?a ≤ 0 ∧ 0 ≤ ?b)›*)) then have "nat (z * z') = 0" by simp moreover from False (*‹¬ 0 ≤ z'›*) have "nat z' = 0" by simp ultimately show "?thesis" (*goal: ‹nat ((z::int) * (z'::int)) = nat z * nat z'›*) by simp next (*goal: ‹0 ≤ z' ⟹ nat (z * z') = nat z * nat z'›*) case True (*‹0 ≤ z'›*) with assms (*‹0 ≤ z›*) have ge_0: "z * z' ≥ 0" by (simp add: zero_le_mult_iff (*‹(0 ≤ ?a * ?b) = (0 ≤ ?a ∧ 0 ≤ ?b ∨ ?a ≤ 0 ∧ ?b ≤ 0)›*)) show "?thesis" (*goal: ‹nat (z * z') = nat z * nat z'›*) apply (rule injD [of "of_nat :: nat ⇒ int", OF inj_of_nat] (*‹int ?x = int ?y ⟹ ?x = ?y›*)) (*goal: ‹nat (z * z') = nat z * nat z'›*) apply (simp only: of_nat_mult (*‹of_nat ((?m::nat) * (?n::nat)) = of_nat ?m * of_nat ?n›*) of_nat_nat [OF True] (*‹of_nat (nat (z'::int)) = of_int z'›*) of_nat_nat [OF assms] (*‹of_nat (nat (z::int)) = of_int z›*) of_nat_nat [OF ge_0] (*‹of_nat (nat ((z::int) * (z'::int))) = of_int (z * z')›*)) (*goal: ‹int (nat (z * z')) = int (nat z * nat z')›*) by simp qed lemma nat_mult_distrib_neg: assumes "z ≤ (0::int)" shows "nat (z * z') = nat (- z) * nat (- z')" (is "?L = ?R") proof (-) (*goal: ‹nat (z * z') = nat (- z) * nat (- z')›*) have "?L = nat (- z * - z')" using assms (*‹z ≤ 0›*) by auto also (*calculation: ‹nat (z * z') = nat (- z * - z')›*) have "... = ?R" apply (rule nat_mult_distrib (*‹0 ≤ ?z ⟹ nat (?z * ?z') = nat ?z * nat ?z'›*)) (*goal: ‹nat (- z * - z') = nat (- z) * nat (- z')›*) by (use assms in auto) finally (*calculation: ‹nat (z * z') = nat (- z) * nat (- z')›*) show "?thesis" (*goal: ‹nat (z * z') = nat (- z) * nat (- z')›*) . qed lemma nat_abs_mult_distrib: "nat ¦w * z¦ = nat ¦w¦ * nat ¦z¦" apply (cases "z = 0 ∨ w = 0") (*goals: 1. ‹z = 0 ∨ w = 0 ⟹ nat ¦w * z¦ = nat ¦w¦ * nat ¦z¦› 2. ‹¬ (z = 0 ∨ w = 0) ⟹ nat ¦w * z¦ = nat ¦w¦ * nat ¦z¦› discuss goal 1*) apply ((auto simp add: abs_if (*‹¦?a::?'a¦ = (if ?a < (0::?'a) then - ?a else ?a)›*) nat_mult_distrib [symmetric] (*‹(0::int) ≤ (?z::int) ⟹ nat ?z * nat (?z'::int) = nat (?z * ?z')›*) nat_mult_distrib_neg [symmetric] (*‹(?z::int) ≤ (0::int) ⟹ nat (- ?z) * nat (- (?z'::int)) = nat (?z * ?z')›*) mult_less_0_iff (*‹((?a::?'a) * (?b::?'a) < (0::?'a)) = ((0::?'a) < ?a ∧ ?b < (0::?'a) ∨ ?a < (0::?'a) ∧ (0::?'a) < ?b)›*))[1]) (*discuss goal 2*) apply ((auto simp add: abs_if (*‹¦?a¦ = (if ?a < 0 then - ?a else ?a)›*) nat_mult_distrib [symmetric] (*‹0 ≤ ?z ⟹ nat ?z * nat ?z' = nat (?z * ?z')›*) nat_mult_distrib_neg [symmetric] (*‹?z ≤ 0 ⟹ nat (- ?z) * nat (- ?z') = nat (?z * ?z')›*) mult_less_0_iff (*‹(?a * ?b < 0) = (0 < ?a ∧ ?b < 0 ∨ ?a < 0 ∧ 0 < ?b)›*))[1]) (*proven 2 subgoals*) . lemma int_in_range_abs [simp]: "int n ∈ range abs" proof (rule range_eqI (*‹?b = ?f ?x ⟹ ?b ∈ range ?f›*)) (*goal: ‹int n = ¦?x¦›*) show "int n = ¦int n¦" by simp qed lemma range_abs_Nats [simp]: "range abs = (ℕ :: int set)" proof (-) (*goal: ‹range abs = ℕ›*) have "¦k¦ ∈ ℕ" for k :: int apply (cases k) (*goals: 1. ‹⋀n. k = int n ⟹ ¦k¦ ∈ ℕ› 2. ‹⋀n. k = - int (Suc n) ⟹ ¦k¦ ∈ ℕ› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) . moreover have "k ∈ range abs" if "k ∈ ℕ" for k :: int using that (*‹(k::int) ∈ ℕ›*) apply induct (*goal: ‹(k::int) ∈ range abs›*) by simp ultimately show "?thesis" (*goal: ‹range abs = ℕ›*) by blast qed lemma Suc_nat_eq_nat_zadd1: "0 ≤ z ⟹ Suc (nat z) = nat (1 + z)" for z :: int apply (rule sym (*‹?s = ?t ⟹ ?t = ?s›*)) (*goal: ‹0 ≤ z ⟹ Suc (nat z) = nat (1 + z)›*) by (simp add: nat_eq_iff (*‹(nat ?w = ?m) = (if 0 ≤ ?w then ?w = int ?m else ?m = 0)›*)) lemma diff_nat_eq_if: "nat z - nat z' = (if z' < 0 then nat z else let d = z - z' in if d < 0 then 0 else nat d)" by (simp add: Let_def (*‹Let (?s::?'a) (?f::?'a ⇒ ?'b) ≡ ?f ?s›*) nat_diff_distrib [symmetric] (*‹⟦(0::int) ≤ (?z'::int); ?z' ≤ (?z::int)⟧ ⟹ nat ?z - nat ?z' = nat (?z - ?z')›*)) lemma nat_numeral_diff_1 [simp]: "numeral v - (1::nat) = nat (numeral v - 1)" using diff_nat_numeral[of v Num.One] (*‹numeral v - Numeral1 = nat (numeral v - Numeral1)›*) by simp subsection ‹Induction principles for int› text ‹Well-founded segments of the integers.› definition int_ge_less_than :: "int ⇒ (int × int) set" where "int_ge_less_than d = {(z', z). d ≤ z' ∧ z' < z}" lemma wf_int_ge_less_than: "wf (int_ge_less_than d)" proof (-) (*goal: ‹wf (int_ge_less_than d)›*) have "int_ge_less_than d ⊆ measure (λz. nat (z - d))" by (auto simp add: int_ge_less_than_def (*‹int_ge_less_than ?d = {(z', z). ?d ≤ z' ∧ z' < z}›*)) then show "?thesis" (*goal: ‹wf (int_ge_less_than d)›*) by (rule wf_subset [OF wf_measure] (*‹?p ⊆ measure ?f1 ⟹ wf ?p›*)) qed text ‹ This variant looks odd, but is typical of the relations suggested by RankFinder.› definition int_ge_less_than2 :: "int ⇒ (int × int) set" where "int_ge_less_than2 d = {(z',z). d ≤ z ∧ z' < z}" lemma wf_int_ge_less_than2: "wf (int_ge_less_than2 d)" proof (-) (*goal: ‹wf (int_ge_less_than2 d)›*) have "int_ge_less_than2 d ⊆ measure (λz. nat (1 + z - d))" by (auto simp add: int_ge_less_than2_def (*‹int_ge_less_than2 ?d = {(z', z). ?d ≤ z ∧ z' < z}›*)) then show "?thesis" (*goal: ‹wf (int_ge_less_than2 (d::int))›*) by (rule wf_subset [OF wf_measure] (*‹?p ⊆ measure ?f1 ⟹ wf ?p›*)) qed (* `set:int': dummy construction *) theorem int_ge_induct [case_names base step, induct set: int]: fixes i :: int assumes ge: "k ≤ i" and base: "P k" and step: "⋀i. k ≤ i ⟹ P i ⟹ P (i + 1)" shows "P i" proof (-) (*goal: ‹P i›*) have "⋀i::int. n = nat (i - k) ⟹ k ≤ i ⟹ P i" for n proof (induct n) (*goals: 1. ‹⋀i::int. ⟦(0::nat) = nat (i - (k::int)); k ≤ i⟧ ⟹ (P::int ⇒ bool) i› 2. ‹⋀(n::nat) i::int. ⟦⋀i::int. ⟦n = nat (i - (k::int)); k ≤ i⟧ ⟹ (P::int ⇒ bool) i; Suc n = nat (i - k); k ≤ i⟧ ⟹ P i›*) case 0 (*‹0 = nat (i - k)› ‹k ≤ i›*) then have "i = k" by arith with base (*‹P k›*) show "P i" by simp next (*goal: ‹⋀n i. ⟦⋀i. ⟦n = nat (i - k); k ≤ i⟧ ⟹ P i; Suc n = nat (i - k); k ≤ i⟧ ⟹ P i›*) case (Suc n) (*‹⟦n = nat (?i - k); k ≤ ?i⟧ ⟹ P ?i› ‹Suc n = nat (i - k)› ‹(k::int) ≤ (i::int)›*) then have "n = nat ((i - 1) - k)" by arith moreover have k: "k ≤ i - 1" using Suc.prems (*‹Suc n = nat (i - k)› ‹k ≤ i›*) by arith ultimately have "P (i - 1)" by (rule Suc.hyps (*‹⟦n = nat (?i - k); k ≤ ?i⟧ ⟹ P ?i›*)) from step[OF k this] (*‹P (i - 1 + 1)›*) show "?case" (*goal: ‹P i›*) by simp qed with ge (*‹k ≤ i›*) show "?thesis" (*goal: ‹P i›*) by fast qed (* `set:int': dummy construction *) theorem int_gr_induct [case_names base step, induct set: int]: fixes i k :: int assumes "k < i" "P (k + 1)" "⋀i. k < i ⟹ P i ⟹ P (i + 1)" shows "P i" proof (-) (*goal: ‹P i›*) have "k+1 ≤ i" using assms (*‹k < i› ‹(P::int ⇒ bool) ((k::int) + (1::int))› ‹⟦(k::int) < (?i::int); (P::int ⇒ bool) ?i⟧ ⟹ P (?i + (1::int))›*) by auto then show "?thesis" (*goal: ‹P i›*) apply (induction i rule: int_ge_induct (*‹⟦?k ≤ ?i; ?P ?k; ⋀i. ⟦?k ≤ i; ?P i⟧ ⟹ ?P (i + 1)⟧ ⟹ ?P ?i›*)) (*goals: 1. ‹(P::int ⇒ bool) ((k::int) + (1::int))› 2. ‹⋀i::int. ⟦(k::int) + (1::int) ≤ i; (P::int ⇒ bool) i⟧ ⟹ P (i + (1::int))› discuss goal 1*) apply ((auto simp: assms (*‹k < i› ‹P (k + 1)› ‹⟦k < ?i; P ?i⟧ ⟹ P (?i + 1)›*))[1]) (*discuss goal 2*) apply ((auto simp: assms (*‹(k::int) < (i::int)› ‹(P::int ⇒ bool) ((k::int) + (1::int))› ‹⟦(k::int) < (?i::int); (P::int ⇒ bool) ?i⟧ ⟹ P (?i + (1::int))›*))[1]) (*proven 2 subgoals*) . qed theorem int_le_induct [consumes 1, case_names base step]: fixes i k :: int assumes le: "i ≤ k" and base: "P k" and step: "⋀i. i ≤ k ⟹ P i ⟹ P (i - 1)" shows "P i" proof (-) (*goal: ‹P i›*) have "⋀i::int. n = nat(k-i) ⟹ i ≤ k ⟹ P i" for n proof (induct n) (*goals: 1. ‹⋀i::int. ⟦(0::nat) = nat ((k::int) - i); i ≤ k⟧ ⟹ (P::int ⇒ bool) i› 2. ‹⋀(n::nat) i::int. ⟦⋀i::int. ⟦n = nat ((k::int) - i); i ≤ k⟧ ⟹ (P::int ⇒ bool) i; Suc n = nat (k - i); i ≤ k⟧ ⟹ P i›*) case 0 (*‹(0::nat) = nat ((k::int) - (i::int))› ‹i ≤ k›*) then have "i = k" by arith with base (*‹P k›*) show "P i" by simp next (*goal: ‹⋀(n::nat) i::int. ⟦⋀i::int. ⟦n = nat ((k::int) - i); i ≤ k⟧ ⟹ (P::int ⇒ bool) i; Suc n = nat (k - i); i ≤ k⟧ ⟹ P i›*) case (Suc n) (*‹⟦(n::nat) = nat ((k::int) - (?i::int)); ?i ≤ k⟧ ⟹ (P::int ⇒ bool) ?i› ‹Suc n = nat (k - i)› ‹i ≤ k›*) then have "n = nat (k - (i + 1))" by arith moreover have k: "i + 1 ≤ k" using Suc.prems (*‹Suc n = nat (k - i)› ‹i ≤ k›*) by arith ultimately have "P (i + 1)" by (rule Suc.hyps (*‹⟦(n::nat) = nat ((k::int) - (?i::int)); ?i ≤ k⟧ ⟹ (P::int ⇒ bool) ?i›*)) from step[OF k this] (*‹P (i + 1 - 1)›*) show "?case" (*goal: ‹P i›*) by simp qed with le (*‹i ≤ k›*) show "?thesis" (*goal: ‹P i›*) by fast qed theorem int_less_induct [consumes 1, case_names base step]: fixes i k :: int assumes "i < k" "P (k - 1)" "⋀i. i < k ⟹ P i ⟹ P (i - 1)" shows "P i" proof (-) (*goal: ‹P i›*) have "i ≤ k-1" using assms (*‹(i::int) < (k::int)› ‹P (k - 1)› ‹⟦?i < k; P ?i⟧ ⟹ P (?i - 1)›*) by auto then show "?thesis" (*goal: ‹P i›*) apply (induction i rule: int_le_induct (*‹⟦?i ≤ ?k; ?P ?k; ⋀i. ⟦i ≤ ?k; ?P i⟧ ⟹ ?P (i - 1)⟧ ⟹ ?P ?i›*)) (*goals: 1. ‹(P::int ⇒ bool) ((k::int) - (1::int))› 2. ‹⋀i::int. ⟦i ≤ (k::int) - (1::int); (P::int ⇒ bool) i⟧ ⟹ P (i - (1::int))› discuss goal 1*) apply ((auto simp: assms (*‹i < k› ‹P (k - 1)› ‹⟦?i < k; P ?i⟧ ⟹ P (?i - 1)›*))[1]) (*discuss goal 2*) apply ((auto simp: assms (*‹i < k› ‹P (k - 1)› ‹⟦?i < k; P ?i⟧ ⟹ P (?i - 1)›*))[1]) (*proven 2 subgoals*) . qed theorem int_induct [case_names base step1 step2]: fixes k :: int assumes base: "P k" and step1: "⋀i. k ≤ i ⟹ P i ⟹ P (i + 1)" and step2: "⋀i. k ≥ i ⟹ P i ⟹ P (i - 1)" shows "P i" proof (-) (*goal: ‹P i›*) have "i ≤ k ∨ i ≥ k" by arith then show "?thesis" (*goal: ‹P i›*) proof (standard) (*goals: 1. ‹i ≤ k ⟹ P i› 2. ‹k ≤ i ⟹ P i›*) assume "i ≥ k" (*‹(k::int) ≤ (i::int)›*) then show "?thesis" (*goal: ‹P i›*) using base (*‹(P::int ⇒ bool) (k::int)›*) apply (rule int_ge_induct (*‹⟦?k ≤ ?i; ?P ?k; ⋀i. ⟦?k ≤ i; ?P i⟧ ⟹ ?P (i + 1)⟧ ⟹ ?P ?i›*)) (*goal: ‹P i›*) by (fact step1 (*‹⟦k ≤ ?i; P ?i⟧ ⟹ P (?i + 1)›*)) next (*goal: ‹i ≤ k ⟹ P i›*) assume "i ≤ k" (*‹(i::int) ≤ (k::int)›*) then show "?thesis" (*goal: ‹P i›*) using base (*‹(P::int ⇒ bool) (k::int)›*) apply (rule int_le_induct (*‹⟦?i ≤ ?k; ?P ?k; ⋀i. ⟦i ≤ ?k; ?P i⟧ ⟹ ?P (i - 1)⟧ ⟹ ?P ?i›*)) (*goal: ‹P i›*) by (fact step2 (*‹⟦?i ≤ k; P ?i⟧ ⟹ P (?i - 1)›*)) qed qed subsection ‹Intermediate value theorems› lemma nat_ivt_aux: "⟦∀i<n. ¦f (Suc i) - f i¦ ≤ 1; f 0 ≤ k; k ≤ f n⟧ ⟹ ∃i ≤ n. f i = k" for m n :: nat and k :: int proof (induct n) (*goals: 1. ‹⟦∀i<0. ¦f (Suc i) - f i¦ ≤ 1; f 0 ≤ k; k ≤ f 0⟧ ⟹ ∃i≤0. f i = k› 2. ‹⋀n. ⟦⟦∀i<n. ¦f (Suc i) - f i¦ ≤ 1; f 0 ≤ k; k ≤ f n⟧ ⟹ ∃i≤n. f i = k; ∀i<Suc n. ¦f (Suc i) - f i¦ ≤ 1; f 0 ≤ k; k ≤ f (Suc n)⟧ ⟹ ∃i≤Suc n. f i = k›*) case (Suc n) (*‹⟦∀i<n. ¦f (Suc i) - f i¦ ≤ 1; f 0 ≤ k; k ≤ f n⟧ ⟹ ∃i≤n. f i = k› ‹∀i<Suc n. ¦f (Suc i) - f i¦ ≤ 1› ‹f 0 ≤ k› ‹(k::int) ≤ (f::nat ⇒ int) (Suc (n::nat))›*) show "?case" (*goal: ‹∃i≤Suc n. f i = k›*) proof (cases "k = f (Suc n)") (*goals: 1. ‹k = f (Suc n) ⟹ ∃i≤Suc n. f i = k› 2. ‹k ≠ f (Suc n) ⟹ ∃i≤Suc n. f i = k›*) case False (*‹k ≠ f (Suc n)›*) with Suc (*‹⟦∀i<n. ¦f (Suc i) - f i¦ ≤ 1; f 0 ≤ k; k ≤ f n⟧ ⟹ ∃i≤n. f i = k› ‹∀i<Suc n. ¦f (Suc i) - f i¦ ≤ 1› ‹f 0 ≤ k› ‹k ≤ f (Suc n)›*) have "k ≤ f n" by auto with Suc (*‹⟦∀i<n. ¦f (Suc i) - f i¦ ≤ 1; f 0 ≤ k; k ≤ f n⟧ ⟹ ∃i≤n. f i = k› ‹∀i<Suc n. ¦f (Suc i) - f i¦ ≤ 1› ‹f 0 ≤ k› ‹k ≤ f (Suc n)›*) show "?thesis" (*goal: ‹∃i≤Suc n. f i = k›*) by (auto simp add: abs_if (*‹¦?a::?'a::abs_if¦ = (if ?a < (0::?'a::abs_if) then - ?a else ?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))›*) intro: le_SucI (*‹(?m::nat) ≤ (?n::nat) ⟹ ?m ≤ Suc ?n›*)) qed (use Suc in auto) (*solved the remaining goal: ‹k = f (Suc n) ⟹ ∃i≤Suc n. f i = k›*) qed (auto) (*solved the remaining goal: ‹⟦∀i<0. ¦f (Suc i) - f i¦ ≤ 1; f 0 ≤ k; k ≤ f 0⟧ ⟹ ∃i≤0. f i = k›*) lemma nat_intermed_int_val: fixes m n :: nat and k :: int assumes "∀i. m ≤ i ∧ i < n ⟶ ¦f (Suc i) - f i¦ ≤ 1" "m ≤ n" "f m ≤ k" "k ≤ f n" shows "∃i. m ≤ i ∧ i ≤ n ∧ f i = k" proof (-) (*goal: ‹∃i≥m. i ≤ n ∧ f i = k›*) obtain i where "i ≤ n - m" "k = f (m + i)" (*goal: ‹(⋀i. ⟦i ≤ n - m; k = f (m + i)⟧ ⟹ thesis) ⟹ thesis›*) using nat_ivt_aux[of "n - m" "f ∘ plus m" k] (*‹⟦∀i<n - m. ¦(f ∘ (+) m) (Suc i) - (f ∘ (+) m) i¦ ≤ 1; (f ∘ (+) m) 0 ≤ k; k ≤ (f ∘ (+) m) (n - m)⟧ ⟹ ∃i≤n - m. (f ∘ (+) m) i = k›*) assms (*‹∀i::nat. (m::nat) ≤ i ∧ i < (n::nat) ⟶ ¦(f::nat ⇒ int) (Suc i) - f i¦ ≤ (1::int)› ‹m ≤ n› ‹f m ≤ k› ‹(k::int) ≤ (f::nat ⇒ int) (n::nat)›*) by auto with assms (*‹∀i::nat. (m::nat) ≤ i ∧ i < (n::nat) ⟶ ¦(f::nat ⇒ int) (Suc i) - f i¦ ≤ (1::int)› ‹m ≤ n› ‹(f::nat ⇒ int) (m::nat) ≤ (k::int)› ‹k ≤ f n›*) show "?thesis" (*goal: ‹∃i≥m. i ≤ n ∧ f i = k›*) using exI[of _ "m + i"] (*‹?P (m + i) ⟹ ∃x. ?P x›*) by auto qed lemma nat0_intermed_int_val: "∃i≤n. f i = k" if "∀i<n. ¦f (i + 1) - f i¦ ≤ 1" "f 0 ≤ k" "k ≤ f n" for n :: nat and k :: int using nat_intermed_int_val[of 0 n f k] (*‹⟦∀i. 0 ≤ i ∧ i < n ⟶ ¦f (Suc i) - f i¦ ≤ 1; 0 ≤ n; f 0 ≤ k; k ≤ f n⟧ ⟹ ∃i≥0. i ≤ n ∧ f i = k›*) that (*‹∀i<n::nat. ¦(f::nat ⇒ int) (i + (1::nat)) - f i¦ ≤ (1::int)› ‹(f::nat ⇒ int) (0::nat) ≤ (k::int)› ‹(k::int) ≤ (f::nat ⇒ int) (n::nat)›*) by auto subsection ‹Products and 1, by T. M. Rasmussen› lemma abs_zmult_eq_1: fixes m n :: int assumes mn: "¦m * n¦ = 1" shows "¦m¦ = 1" proof (-) (*goal: ‹¦m¦ = 1›*) from mn (*‹¦m * n¦ = 1›*) have 0: "m ≠ 0" "n ≠ 0" apply - (*goals: 1. ‹¦m * n¦ = 1 ⟹ m ≠ 0› 2. ‹¦m * n¦ = 1 ⟹ n ≠ 0› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . have "¬ 2 ≤ ¦m¦" proof (standard) (*goal: ‹2 ≤ ¦m¦ ⟹ False›*) assume "2 ≤ ¦m¦" (*‹(2::int) ≤ ¦m::int¦›*) then have "2 * ¦n¦ ≤ ¦m¦ * ¦n¦" by (simp add: mult_mono (*‹⟦?a ≤ ?b; ?c ≤ ?d; 0 ≤ ?b; 0 ≤ ?c⟧ ⟹ ?a * ?c ≤ ?b * ?d›*) 0 (*‹m ≠ 0› ‹n ≠ 0›*)) also (*calculation: ‹2 * ¦n¦ ≤ ¦m¦ * ¦n¦›*) have "… = ¦m * n¦" by (simp add: abs_mult (*‹¦?a * ?b¦ = ¦?a¦ * ¦?b¦›*)) also (*calculation: ‹2 * ¦n¦ ≤ ¦m * n¦›*) from mn (*‹¦m * n¦ = 1›*) have "… = 1" by simp finally (*calculation: ‹2 * ¦n¦ ≤ 1›*) have "2 * ¦n¦ ≤ 1" . with "0" (*‹m ≠ 0› ‹n ≠ 0›*) show False by arith qed with "0" (*‹m ≠ 0› ‹(n::int) ≠ (0::int)›*) show "?thesis" (*goal: ‹¦m¦ = 1›*) by auto qed lemma pos_zmult_eq_1_iff_lemma: "m * n = 1 ⟹ m = 1 ∨ m = - 1" for m n :: int using abs_zmult_eq_1[of m n] (*‹¦(m::int) * (n::int)¦ = (1::int) ⟹ ¦m¦ = (1::int)›*) by arith lemma pos_zmult_eq_1_iff: fixes m n :: int assumes "0 < m" shows "m * n = 1 ⟷ m = 1 ∧ n = 1" proof (-) (*goal: ‹(m * n = 1) = (m = 1 ∧ n = 1)›*) from assms (*‹0 < m›*) have "m * n = 1 ⟹ m = 1" by (auto dest: pos_zmult_eq_1_iff_lemma (*‹?m * ?n = 1 ⟹ ?m = 1 ∨ ?m = - 1›*)) then show "?thesis" (*goal: ‹(m * n = 1) = (m = 1 ∧ n = 1)›*) by (auto dest: pos_zmult_eq_1_iff_lemma (*‹(?m::int) * (?n::int) = (1::int) ⟹ ?m = (1::int) ∨ ?m = - (1::int)›*)) qed lemma zmult_eq_1_iff: "m * n = 1 ⟷ (m = 1 ∧ n = 1) ∨ (m = - 1 ∧ n = - 1)" (is "?L = ?R") for m n :: int proof (standard) (*goals: 1. ‹m * n = 1 ⟹ m = 1 ∧ n = 1 ∨ m = - 1 ∧ n = - 1› 2. ‹m = 1 ∧ n = 1 ∨ m = - 1 ∧ n = - 1 ⟹ m * n = 1›*) assume L: "?L" (*‹(m::int) * (n::int) = (1::int)›*) show "?R" using pos_zmult_eq_1_iff_lemma[OF L] (*‹(m::int) = (1::int) ∨ m = - (1::int)›*) L (*‹m * n = 1›*) by force qed (auto) (*solved the remaining goal: ‹m = 1 ∧ n = 1 ∨ m = - 1 ∧ n = - 1 ⟹ m * n = 1›*) lemma zmult_eq_neg1_iff: "a * b = (-1 :: int) ⟷ a = 1 ∧ b = -1 ∨ a = -1 ∧ b = 1" using zmult_eq_1_iff[of a "-b"] (*‹(a * - b = 1) = (a = 1 ∧ - b = 1 ∨ a = - 1 ∧ - b = - 1)›*) by auto lemma infinite_UNIV_int [simp]: "¬ finite (UNIV::int set)" proof (standard) (*goal: ‹finite UNIV ⟹ False›*) assume "finite (UNIV::int set)" (*‹finite UNIV›*) moreover have "inj (λi::int. 2 * i)" apply (rule injI (*‹(⋀x y. ?f x = ?f y ⟹ x = y) ⟹ inj ?f›*)) (*goal: ‹inj ((*) 2)›*) by simp ultimately have "surj (λi::int. 2 * i)" by (rule finite_UNIV_inj_surj (*‹⟦finite UNIV; inj (?f::?'a::type ⇒ ?'a::type)⟧ ⟹ surj ?f›*)) then obtain i :: int where "1 = 2 * i" (*goal: ‹(⋀i. 1 = 2 * i ⟹ thesis) ⟹ thesis›*) by (rule surjE (*‹⟦surj (?f::?'b ⇒ ?'a); ⋀x::?'b. (?y::?'a) = ?f x ⟹ ?C::bool⟧ ⟹ ?C›*)) then show False by (simp add: pos_zmult_eq_1_iff (*‹0 < ?m ⟹ (?m * ?n = 1) = (?m = 1 ∧ ?n = 1)›*)) qed subsection ‹The divides relation› lemma zdvd_antisym_nonneg: "0 ≤ m ⟹ 0 ≤ n ⟹ m dvd n ⟹ n dvd m ⟹ m = n" for m n :: int by (auto simp add: dvd_def (*‹((?b::?'a::dvd) dvd (?a::?'a::dvd)) = (∃k::?'a::dvd. ?a = ?b * k)›*) mult.assoc (*‹(?a::?'a::semigroup_mult) * (?b::?'a::semigroup_mult) * (?c::?'a::semigroup_mult) = ?a * (?b * ?c)›*) zero_le_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))›*) zmult_eq_1_iff (*‹((?m::int) * (?n::int) = (1::int)) = (?m = (1::int) ∧ ?n = (1::int) ∨ ?m = - (1::int) ∧ ?n = - (1::int))›*)) lemma zdvd_antisym_abs: fixes a b :: int assumes "a dvd b" and "b dvd a" shows "¦a¦ = ¦b¦" proof (cases "a = 0") (*goals: 1. ‹a = 0 ⟹ ¦a¦ = ¦b¦› 2. ‹a ≠ 0 ⟹ ¦a¦ = ¦b¦›*) case True (*‹a = 0›*) with assms (*‹a dvd b› ‹b dvd a›*) show "?thesis" (*goal: ‹¦a¦ = ¦b¦›*) by simp next (*goal: ‹a ≠ 0 ⟹ ¦a¦ = ¦b¦›*) case False (*‹a ≠ 0›*) from ‹a dvd b› (*‹a dvd b›*) obtain k where k: "b = a * k" (*goal: ‹(⋀k. b = a * k ⟹ thesis) ⟹ thesis›*) unfolding dvd_def (*goal: ‹(⋀k::int. (b::int) = (a::int) * k ⟹ thesis::bool) ⟹ thesis›*) by blast from ‹b dvd a› (*‹b dvd a›*) obtain k' where k': "a = b * k'" (*goal: ‹(⋀k'. a = b * k' ⟹ thesis) ⟹ thesis›*) unfolding dvd_def (*goal: ‹(⋀k'::int. (a::int) = (b::int) * k' ⟹ thesis::bool) ⟹ thesis›*) by blast from k (*‹b = a * k›*) k' (*‹a = b * k'›*) have "a = a * k * k'" by simp with mult_cancel_left1[where c = "a" and b = "k*k'"] (*‹(a = a * (k * k')) = (a = 0 ∨ k * k' = 1)›*) have kk': "k * k' = 1" using ‹a ≠ 0› (*‹a ≠ 0›*) by (simp add: mult.assoc (*‹?a * ?b * ?c = ?a * (?b * ?c)›*)) then have "k = 1 ∧ k' = 1 ∨ k = -1 ∧ k' = -1" by (simp add: zmult_eq_1_iff (*‹(?m * ?n = 1) = (?m = 1 ∧ ?n = 1 ∨ ?m = - 1 ∧ ?n = - 1)›*)) with k (*‹b = a * k›*) k' (*‹a = b * k'›*) show "?thesis" (*goal: ‹¦a¦ = ¦b¦›*) by auto qed lemma zdvd_zdiffD: "k dvd m - n ⟹ k dvd n ⟹ k dvd m" for k m n :: int using dvd_add_right_iff[of k "- n" m] (*‹k dvd - n ⟹ (k dvd - n + m) = (k dvd m)›*) by simp lemma zdvd_reduce: "k dvd n + k * m ⟷ k dvd n" for k m n :: int using dvd_add_times_triv_right_iff[of k n m] (*‹(k dvd n + m * k) = (k dvd n)›*) by (simp add: 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 13 facts*)) lemma dvd_imp_le_int: fixes d i :: int assumes "i ≠ 0" and "d dvd i" shows "¦d¦ ≤ ¦i¦" proof (-) (*goal: ‹¦d¦ ≤ ¦i¦›*) from ‹d dvd i› (*‹(d::int) dvd (i::int)›*) obtain k where "i = d * k" (*goal: ‹(⋀k. i = d * k ⟹ thesis) ⟹ thesis›*) by standard with ‹i ≠ 0› (*‹(i::int) ≠ (0::int)›*) have "k ≠ 0" by auto then have "1 ≤ ¦k¦" and "0 ≤ ¦d¦" apply - (*goals: 1. ‹k ≠ 0 ⟹ 1 ≤ ¦k¦› 2. ‹k ≠ 0 ⟹ 0 ≤ ¦d¦› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . then have "¦d¦ * 1 ≤ ¦d¦ * ¦k¦" by (rule mult_left_mono (*‹⟦?a ≤ ?b; 0 ≤ ?c⟧ ⟹ ?c * ?a ≤ ?c * ?b›*)) with ‹i = d * k› (*‹(i::int) = (d::int) * (k::int)›*) show "?thesis" (*goal: ‹¦d¦ ≤ ¦i¦›*) by (simp add: abs_mult (*‹¦(?a::?'a::idom_abs_sgn) * (?b::?'a::idom_abs_sgn)¦ = ¦?a¦ * ¦?b¦›*)) qed lemma zdvd_not_zless: fixes m n :: int assumes "0 < m" and "m < n" shows "¬ n dvd m" proof (standard) (*goal: ‹n dvd m ⟹ False›*) from assms (*‹0 < m› ‹m < n›*) have "0 < n" by auto assume "n dvd m" (*‹(n::int) dvd (m::int)›*) then obtain k where k: "m = n * k" (*goal: ‹(⋀k. m = n * k ⟹ thesis) ⟹ thesis›*) by standard with ‹0 < m› (*‹0 < m›*) have "0 < n * k" by auto with ‹0 < n› (*‹0 < n›*) have "0 < k" by (simp add: 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))›*)) with k (*‹m = n * k›*) ‹0 < n› (*‹0 < n›*) ‹m < n› (*‹m < n›*) have "n * k < n * 1" by simp with ‹0 < n› (*‹0 < n›*) ‹0 < k› (*‹0 < k›*) show False unfolding mult_less_cancel_left (*goal: ‹False›*) by auto qed lemma zdvd_mult_cancel: fixes k m n :: int assumes d: "k * m dvd k * n" and "k ≠ 0" shows "m dvd n" proof (-) (*goal: ‹m dvd n›*) from d (*‹k * m dvd k * n›*) obtain h where h: "k * n = k * m * h" (*goal: ‹(⋀h. k * n = k * m * h ⟹ thesis) ⟹ thesis›*) unfolding dvd_def (*goal: ‹(⋀h. k * n = k * m * h ⟹ thesis) ⟹ thesis›*) by blast have "n = m * h" proof (rule ccontr (*‹(¬ (?P::bool) ⟹ False) ⟹ ?P›*)) (*goal: ‹n ≠ m * h ⟹ False›*) assume "¬ ?thesis" (*‹(n::int) ≠ (m::int) * (h::int)›*) with ‹k ≠ 0› (*‹k ≠ 0›*) have "k * n ≠ k * (m * h)" by simp with h (*‹k * n = k * m * h›*) show False by (simp add: mult.assoc (*‹?a * ?b * ?c = ?a * (?b * ?c)›*)) qed then show "?thesis" (*goal: ‹m dvd n›*) by simp qed lemma int_dvd_int_iff [simp]: "int m dvd int n ⟷ m dvd n" proof (-) (*goal: ‹(int m dvd int n) = (m dvd n)›*) have "m dvd n" if "int n = int m * k" for k proof (cases k) (*goals: 1. ‹⋀na. k = int na ⟹ m dvd n› 2. ‹⋀na. k = - int (Suc na) ⟹ m dvd n›*) case (nonneg q) (*‹k = int q›*) with that (*‹int (n::nat) = int (m::nat) * (k::int)›*) have "n = m * q" by (simp del: of_nat_mult (*‹of_nat (?m * ?n) = of_nat ?m * of_nat ?n›*) add: of_nat_mult [symmetric] (*‹of_nat ?m * of_nat ?n = of_nat (?m * ?n)›*)) then show "?thesis" (*goal: ‹(m::nat) dvd (n::nat)›*) by standard next (*goal: ‹⋀na::nat. (k::int) = - int (Suc na) ⟹ (m::nat) dvd (n::nat)›*) case (neg q) (*‹k = - int (Suc q)›*) with that (*‹int n = int m * k›*) have "int n = int m * (- int (Suc q))" by simp also (*calculation: ‹int n = int m * - int (Suc q)›*) have "… = - (int m * int (Suc q))" by (simp only: mult_minus_right (*‹?a * - ?b = - (?a * ?b)›*)) also (*calculation: ‹int n = - (int m * int (Suc q))›*) have "… = - int (m * Suc q)" by (simp only: of_nat_mult [symmetric] (*‹of_nat ?m * of_nat ?n = of_nat (?m * ?n)›*)) finally (*calculation: ‹int (n::nat) = - int ((m::nat) * Suc (q::nat))›*) have "- int (m * Suc q) = int n" by standard then show "?thesis" (*goal: ‹(m::nat) dvd (n::nat)›*) apply (simp only: negative_eq_positive (*‹(- int (?n::nat) = int (?m::nat)) = (?n = (0::nat) ∧ ?m = (0::nat))›*)) (*goal: ‹m dvd n›*) by auto qed then show "?thesis" (*goal: ‹(int (m::nat) dvd int (n::nat)) = (m dvd n)›*) by (auto simp add: dvd_def (*‹(?b dvd ?a) = (∃k. ?a = ?b * k)›*)) qed lemma dvd_nat_abs_iff [simp]: "n dvd nat ¦k¦ ⟷ int n dvd k" proof (-) (*goal: ‹(n dvd nat ¦k¦) = (int n dvd k)›*) have "n dvd nat ¦k¦ ⟷ int n dvd int (nat ¦k¦)" by (simp only: int_dvd_int_iff (*‹(int ?m dvd int ?n) = (?m dvd ?n)›*)) then show "?thesis" (*goal: ‹(n dvd nat ¦k¦) = (int n dvd k)›*) by simp qed lemma nat_abs_dvd_iff [simp]: "nat ¦k¦ dvd n ⟷ k dvd int n" proof (-) (*goal: ‹(nat ¦k¦ dvd n) = (k dvd int n)›*) have "nat ¦k¦ dvd n ⟷ int (nat ¦k¦) dvd int n" by (simp only: int_dvd_int_iff (*‹(int ?m dvd int ?n) = (?m dvd ?n)›*)) then show "?thesis" (*goal: ‹(nat ¦k¦ dvd n) = (k dvd int n)›*) by simp qed lemma zdvd1_eq [simp]: "x dvd 1 ⟷ ¦x¦ = 1" (is "?lhs ⟷ ?rhs") for x :: int proof (standard) (*goals: 1. ‹x dvd 1 ⟹ ¦x¦ = 1› 2. ‹¦x¦ = 1 ⟹ x dvd 1›*) assume "?lhs" (*‹(x::int) dvd (1::int)›*) then have "nat ¦x¦ dvd nat ¦1¦" apply (simp only: nat_abs_dvd_iff (*‹(nat ¦?k¦ dvd ?n) = (?k dvd int ?n)›*)) (*goal: ‹nat ¦x¦ dvd nat ¦1¦›*) by simp then have "nat ¦x¦ = 1" by simp then show "?rhs" apply (cases "x < 0") (*goals: 1. ‹⟦nat ¦x¦ = 1; x < 0⟧ ⟹ ¦x¦ = 1› 2. ‹⟦nat ¦x¦ = 1; ¬ x < 0⟧ ⟹ ¦x¦ = 1› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) . next (*goal: ‹¦x¦ = 1 ⟹ x dvd 1›*) assume "?rhs" (*‹¦x::int¦ = (1::int)›*) then have "x = 1 ∨ x = - 1" by auto then show "?lhs" by (auto intro: dvdI (*‹?a = ?b * ?k ⟹ ?b dvd ?a›*)) qed lemma zdvd_mult_cancel1: fixes m :: int assumes mp: "m ≠ 0" shows "m * n dvd m ⟷ ¦n¦ = 1" (is "?lhs ⟷ ?rhs") proof (standard) (*goals: 1. ‹m * n dvd m ⟹ ¦n¦ = 1› 2. ‹¦n¦ = 1 ⟹ m * n dvd m›*) assume "?rhs" (*‹¦n::int¦ = (1::int)›*) then show "?lhs" apply (cases "n > 0") (*goals: 1. ‹⟦¦n¦ = 1; 0 < n⟧ ⟹ m * n dvd m› 2. ‹⟦¦n¦ = 1; ¬ 0 < n⟧ ⟹ m * n dvd m› discuss goal 1*) apply ((auto simp add: minus_equation_iff (*‹(- ?a = ?b) = (- ?b = ?a)›*))[1]) (*discuss goal 2*) apply ((auto simp add: minus_equation_iff (*‹(- ?a = ?b) = (- ?b = ?a)›*))[1]) (*proven 2 subgoals*) . next (*goal: ‹m * n dvd m ⟹ ¦n¦ = 1›*) assume "?lhs" (*‹(m::int) * (n::int) dvd m›*) then have "m * n dvd m * 1" by simp from zdvd_mult_cancel[OF this mp] (*‹n dvd 1›*) show "?rhs" by (simp only: zdvd1_eq (*‹(?x dvd 1) = (¦?x¦ = 1)›*)) qed lemma nat_dvd_iff: "nat z dvd m ⟷ (if 0 ≤ z then z dvd int m else m = 0)" using nat_abs_dvd_iff[of z m] (*‹(nat ¦z¦ dvd m) = (z dvd int m)›*) apply (cases "z ≥ 0") (*goals: 1. ‹⟦(nat ¦z¦ dvd m) = (z dvd int m); 0 ≤ z⟧ ⟹ (nat z dvd m) = (if 0 ≤ z then z dvd int m else m = 0)› 2. ‹⟦(nat ¦z¦ dvd m) = (z dvd int m); ¬ 0 ≤ z⟧ ⟹ (nat z dvd m) = (if 0 ≤ z then z dvd int m else m = 0)› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . lemma eq_nat_nat_iff: "0 ≤ z ⟹ 0 ≤ z' ⟹ nat z = nat z' ⟷ z = z'" by (auto elim: nonneg_int_cases (*‹⟦0 ≤ ?k; ⋀n. ?k = int n ⟹ ?thesis⟧ ⟹ ?thesis›*)) lemma nat_power_eq: "0 ≤ z ⟹ nat (z ^ n) = nat z ^ n" apply (induct n) (*goals: 1. ‹0 ≤ z ⟹ nat (z ^ 0) = nat z ^ 0› 2. ‹⋀n. ⟦0 ≤ z ⟹ nat (z ^ n) = nat z ^ n; 0 ≤ z⟧ ⟹ nat (z ^ Suc n) = nat z ^ Suc n› discuss goal 1*) apply (simp add: nat_mult_distrib (*‹(0::int) ≤ (?z::int) ⟹ nat (?z * (?z'::int)) = nat ?z * nat ?z'›*)) (*discuss goal 2*) apply (simp add: nat_mult_distrib (*‹(0::int) ≤ (?z::int) ⟹ nat (?z * (?z'::int)) = nat ?z * nat ?z'›*)) (*proven 2 subgoals*) . lemma numeral_power_eq_nat_cancel_iff [simp]: "numeral x ^ n = nat y ⟷ numeral x ^ n = y" using nat_eq_iff2 (*‹(?m = nat ?w) = (if 0 ≤ ?w then ?w = int ?m else ?m = 0)›*) by auto lemma nat_eq_numeral_power_cancel_iff [simp]: "nat y = numeral x ^ n ⟷ y = numeral x ^ n" using numeral_power_eq_nat_cancel_iff[of x n y] (*‹(numeral x ^ n = nat y) = (numeral x ^ n = y)›*) by (metis (mono_tags)) lemma numeral_power_le_nat_cancel_iff [simp]: "numeral x ^ n ≤ nat a ⟷ numeral x ^ n ≤ a" using nat_le_eq_zle[of "numeral x ^ n" a] (*‹0 < numeral x ^ n ∨ 0 ≤ a ⟹ (nat (numeral x ^ n) ≤ nat a) = (numeral x ^ n ≤ a)›*) by (auto simp: nat_power_eq (*‹0 ≤ ?z ⟹ nat (?z ^ ?n) = nat ?z ^ ?n›*)) lemma nat_le_numeral_power_cancel_iff [simp]: "nat a ≤ numeral x ^ n ⟷ a ≤ numeral x ^ n" by (simp add: nat_le_iff (*‹(nat ?x ≤ ?n) = (?x ≤ int ?n)›*)) lemma numeral_power_less_nat_cancel_iff [simp]: "numeral x ^ n < nat a ⟷ numeral x ^ n < a" using nat_less_eq_zless[of "numeral x ^ n" a] (*‹(0::int) ≤ numeral (x::num) ^ (n::nat) ⟹ (nat (numeral x ^ n) < nat (a::int)) = (numeral x ^ n < a)›*) by (auto simp: nat_power_eq (*‹0 ≤ ?z ⟹ nat (?z ^ ?n) = nat ?z ^ ?n›*)) lemma nat_less_numeral_power_cancel_iff [simp]: "nat a < numeral x ^ n ⟷ a < numeral x ^ n" using nat_less_eq_zless[of a "numeral x ^ n"] (*‹0 ≤ a ⟹ (nat a < nat (numeral x ^ n)) = (a < numeral x ^ n)›*) apply (cases "a < 0") (*goals: 1. ‹⟦0 ≤ a ⟹ (nat a < nat (numeral x ^ n)) = (a < numeral x ^ n); a < 0⟧ ⟹ (nat a < numeral x ^ n) = (a < numeral x ^ n)› 2. ‹⟦0 ≤ a ⟹ (nat a < nat (numeral x ^ n)) = (a < numeral x ^ n); ¬ a < 0⟧ ⟹ (nat a < numeral x ^ n) = (a < numeral x ^ n)› discuss goal 1*) apply ((auto simp: nat_power_eq (*‹0 ≤ ?z ⟹ nat (?z ^ ?n) = nat ?z ^ ?n›*) less_le_trans[where y=0] (*‹⟦?x < 0; 0 ≤ ?z⟧ ⟹ ?x < ?z›*))[1]) (*discuss goal 2*) apply ((auto simp: nat_power_eq (*‹0 ≤ ?z ⟹ nat (?z ^ ?n) = nat ?z ^ ?n›*) less_le_trans[where y=0] (*‹⟦?x < 0; 0 ≤ ?z⟧ ⟹ ?x < ?z›*))[1]) (*proven 2 subgoals*) . lemma zdvd_imp_le: "z ≤ n" if "z dvd n" "0 < n" for n z :: int proof (cases n) (*goals: 1. ‹⋀na. n = int na ⟹ z ≤ n› 2. ‹⋀na. n = - int (Suc na) ⟹ z ≤ n›*) case (nonneg n) (*‹n = int n›*) show "?thesis" (*goal: ‹z ≤ n›*) apply (cases z) (*goals: 1. ‹⋀na. z = int na ⟹ z ≤ n› 2. ‹⋀na. z = - int (Suc na) ⟹ z ≤ n› discuss goal 1*) apply ((use nonneg dvd_imp_le that in auto)[1]) (*discuss goal 2*) apply ((use nonneg dvd_imp_le that in auto)[1]) (*proven 2 subgoals*) . qed (use that in auto) (*solved the remaining goal: ‹⋀na. n = - int (Suc na) ⟹ z ≤ n›*) lemma zdvd_period: fixes a d :: int assumes "a dvd d" shows "a dvd (x + t) ⟷ a dvd ((x + c * d) + t)" (is "?lhs ⟷ ?rhs") proof (-) (*goal: ‹((a::int) dvd (x::int) + (t::int)) = (a dvd x + (c::int) * (d::int) + t)›*) from assms (*‹(a::int) dvd (d::int)›*) have "a dvd (x + t) ⟷ a dvd ((x + t) + c * d)" by (simp add: dvd_add_left_iff (*‹?a dvd ?c ⟹ (?a dvd ?b + ?c) = (?a dvd ?b)›*)) then show "?thesis" (*goal: ‹(a dvd x + t) = (a dvd x + c * d + t)›*) by (simp add: 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 13 facts*)) qed subsection ‹Powers with integer exponents› text ‹ The following allows writing powers with an integer exponent. While the type signature is very generic, most theorems will assume that the underlying type is a division ring or a field. The notation `powi' is inspired by the `powr' notation for real/complex exponentiation. › definition power_int :: "'a :: {inverse, power} ⇒ int ⇒ 'a" (infixr "powi" 80) where "power_int x n = (if n ≥ 0 then x ^ nat n else inverse x ^ (nat (-n)))" lemma power_int_0_right [simp]: "power_int x 0 = 1" and power_int_1_right [simp]: "power_int (y :: 'a :: {power, inverse, monoid_mult}) 1 = y" and power_int_minus1_right [simp]: "power_int (y :: 'a :: {power, inverse, monoid_mult}) (-1) = inverse y" (*goals: 1. ‹x powi 0 = 1› 2. ‹y powi 1 = y› 3. ‹y powi - 1 = inverse y› discuss goal 1*) apply (simp add: power_int_def (*‹(?x::?'a) powi (?n::int) = (if (0::int) ≤ ?n then ?x ^ nat ?n else inverse ?x ^ nat (- ?n))›*)) (*discuss goal 2*) apply (simp add: power_int_def (*‹?x powi ?n = (if 0 ≤ ?n then ?x ^ nat ?n else inverse ?x ^ nat (- ?n))›*)) (*discuss goal 3*) apply (simp add: power_int_def (*‹?x powi ?n = (if 0 ≤ ?n then ?x ^ nat ?n else inverse ?x ^ nat (- ?n))›*)) (*proven 3 subgoals*) . lemma power_int_of_nat [simp]: "power_int x (int n) = x ^ n" by (simp add: power_int_def (*‹(?x::?'a) powi (?n::int) = (if (0::int) ≤ ?n then ?x ^ nat ?n else inverse ?x ^ nat (- ?n))›*)) lemma power_int_numeral [simp]: "power_int x (numeral n) = x ^ numeral n" by (simp add: power_int_def (*‹(?x::?'a::{inverse,power}) powi (?n::int) = (if (0::int) ≤ ?n then ?x ^ nat ?n else inverse ?x ^ nat (- ?n))›*)) lemma powi_numeral_reduce: "x powi numeral n = x * x powi int (pred_numeral n)" by (simp add: numeral_eq_Suc (*‹numeral ?k = Suc (pred_numeral ?k)›*)) lemma powi_minus_numeral_reduce: "x powi - (numeral n) = inverse x * x powi - int(pred_numeral n)" by (simp add: numeral_eq_Suc (*‹numeral ?k = Suc (pred_numeral ?k)›*) power_int_def (*‹?x powi ?n = (if 0 ≤ ?n then ?x ^ nat ?n else inverse ?x ^ nat (- ?n))›*)) lemma int_cases4 [case_names nonneg neg]: fixes m :: int obtains n where "m = int n" | n where "n > 0" "m = -int n" proof (cases "m ≥ 0") (*goals: 1. ‹⟦⋀n::nat. (m::int) = int n ⟹ thesis::bool; ⋀n::nat. ⟦(0::nat) < n; m = - int n⟧ ⟹ thesis; (0::int) ≤ m⟧ ⟹ thesis› 2. ‹⟦⋀n::nat. (m::int) = int n ⟹ thesis::bool; ⋀n::nat. ⟦(0::nat) < n; m = - int n⟧ ⟹ thesis; ¬ (0::int) ≤ m⟧ ⟹ thesis›*) case True (*‹0 ≤ m›*) thus "?thesis" (*goal: ‹thesis›*) using that(1)[of "nat m"] (*‹m = int (nat m) ⟹ thesis›*) by auto next (*goal: ‹⟦⋀n::nat. (m::int) = int n ⟹ thesis::bool; ⋀n::nat. ⟦(0::nat) < n; m = - int n⟧ ⟹ thesis; ¬ (0::int) ≤ m⟧ ⟹ thesis›*) case False (*‹¬ 0 ≤ m›*) thus "?thesis" (*goal: ‹thesis›*) using that(2)[of "nat (-m)"] (*‹⟦0 < nat (- m); m = - int (nat (- m))⟧ ⟹ thesis›*) by auto qed context assumes "SORT_CONSTRAINT('a::division_ring)" begin lemma power_int_minus: "power_int (x::'a) (-n) = inverse (power_int x n)" by (auto simp: 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)›*)) lemma power_int_minus_divide: "power_int (x::'a) (-n) = 1 / (power_int x n)" by (simp add: divide_inverse (*‹?a / ?b = ?a * inverse ?b›*) power_int_minus (*‹?x powi - ?n = inverse (?x powi ?n)›*)) lemma power_int_eq_0_iff [simp]: "power_int (x::'a) n = 0 ⟷ x = 0 ∧ n ≠ 0" by (auto simp: power_int_def (*‹?x powi ?n = (if 0 ≤ ?n then ?x ^ nat ?n else inverse ?x ^ nat (- ?n))›*)) lemma power_int_0_left_If: "power_int (0 :: 'a) m = (if m = 0 then 1 else 0)" by (auto simp: power_int_def (*‹(?x::?'a::{inverse,power}) powi (?n::int) = (if (0::int) ≤ ?n then ?x ^ nat ?n else inverse ?x ^ nat (- ?n))›*)) lemma power_int_0_left [simp]: "m ≠ 0 ⟹ power_int (0 :: 'a) m = 0" by (simp add: power_int_0_left_If (*‹0 powi ?m = (if ?m = 0 then 1 else 0)›*)) lemma power_int_1_left [simp]: "power_int 1 n = (1 :: 'a :: division_ring)" by (auto simp: power_int_def (*‹?x powi ?n = (if 0 ≤ ?n then ?x ^ nat ?n else inverse ?x ^ nat (- ?n))›*)) lemma power_diff_conv_inverse: "x ≠ 0 ⟹ m ≤ n ⟹ (x :: 'a) ^ (n - m) = x ^ n * inverse x ^ m" 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 39 facts*) flip: power_add (*‹(?a::?'a::monoid_mult) ^ ((?m::nat) + (?n::nat)) = ?a ^ ?m * ?a ^ ?n›*)) lemma power_mult_inverse_distrib: "x ^ m * inverse (x :: 'a) = inverse x * x ^ m" proof (cases "x = 0") (*goals: 1. ‹x = 0 ⟹ x ^ m * inverse x = inverse x * x ^ m› 2. ‹x ≠ 0 ⟹ x ^ m * inverse x = inverse x * x ^ m›*) case [simp]: False (*‹x ≠ 0›*) show "?thesis" (*goal: ‹(x::'a::division_ring) ^ (m::nat) * inverse x = inverse x * x ^ m›*) proof (cases m) (*goals: 1. ‹(m::nat) = (0::nat) ⟹ (x::'a) ^ m * inverse x = inverse x * x ^ m› 2. ‹⋀nat::nat. (m::nat) = Suc nat ⟹ (x::'a) ^ m * inverse x = inverse x * x ^ m›*) case (Suc m') (*‹m = Suc m'›*) have "x ^ Suc m' * inverse x = x ^ m'" apply (subst power_Suc2 (*‹?a ^ Suc ?n = ?a ^ ?n * ?a›*)) (*goal: ‹(x::'a) ^ Suc (m'::nat) * inverse x = x ^ m'›*) by (auto simp: mult.assoc (*‹?a * ?b * ?c = ?a * (?b * ?c)›*)) also (*calculation: ‹x ^ Suc m' * inverse x = x ^ m'›*) have "… = inverse x * x ^ Suc m'" apply (subst power_Suc (*‹(?a::?'a) ^ Suc (?n::nat) = ?a * ?a ^ ?n›*)) (*goal: ‹(x::'a) ^ (m'::nat) = inverse x * x ^ Suc m'›*) by (auto simp: mult.assoc [symmetric] (*‹?a * (?b * ?c) = ?a * ?b * ?c›*)) finally (*calculation: ‹x ^ Suc m' * inverse x = inverse x * x ^ Suc m'›*) show "?thesis" (*goal: ‹x ^ m * inverse x = inverse x * x ^ m›*) using Suc (*‹m = Suc m'›*) by simp qed (auto) (*solved the remaining goal: ‹m = 0 ⟹ x ^ m * inverse x = inverse x * x ^ m›*) qed (auto) (*solved the remaining goal: ‹x = 0 ⟹ x ^ m * inverse x = inverse x * x ^ m›*) lemma power_mult_power_inverse_commute: "x ^ m * inverse (x :: 'a) ^ n = inverse x ^ n * x ^ m" proof (induction n) (*goals: 1. ‹x ^ m * inverse x ^ 0 = inverse x ^ 0 * x ^ m› 2. ‹⋀n. x ^ m * inverse x ^ n = inverse x ^ n * x ^ m ⟹ x ^ m * inverse x ^ Suc n = inverse x ^ Suc n * x ^ m›*) case (Suc n) (*‹x ^ m * inverse x ^ n = inverse x ^ n * x ^ m›*) have "x ^ m * inverse x ^ Suc n = (x ^ m * inverse x ^ n) * inverse x" by (simp only: power_Suc2 (*‹?a ^ Suc ?n = ?a ^ ?n * ?a›*) mult.assoc (*‹?a * ?b * ?c = ?a * (?b * ?c)›*)) also (*calculation: ‹x ^ m * inverse x ^ Suc n = x ^ m * inverse x ^ n * inverse x›*) have "x ^ m * inverse x ^ n = inverse x ^ n * x ^ m" by (rule Suc (*‹(x::'a::division_ring) ^ (m::nat) * inverse x ^ (n::nat) = inverse x ^ n * x ^ m›*)) also (*calculation: ‹x ^ m * inverse x ^ Suc n = inverse x ^ n * x ^ m * inverse x›*) have "… * inverse x = (inverse x ^ n * inverse x) * x ^ m" by (simp add: mult.assoc (*‹?a * ?b * ?c = ?a * (?b * ?c)›*) power_mult_inverse_distrib (*‹?x ^ ?m * inverse ?x = inverse ?x * ?x ^ ?m›*)) also (*calculation: ‹x ^ m * inverse x ^ Suc n = inverse x ^ n * inverse x * x ^ m›*) have "… = inverse x ^ (Suc n) * x ^ m" by (simp only: power_Suc2 (*‹?a ^ Suc ?n = ?a ^ ?n * ?a›*)) finally (*calculation: ‹x ^ m * inverse x ^ Suc n = inverse x ^ Suc n * x ^ m›*) show "?case" (*goal: ‹x ^ m * inverse x ^ Suc n = inverse x ^ Suc n * x ^ m›*) . qed (auto) (*solved the remaining goal: ‹x ^ m * inverse x ^ 0 = inverse x ^ 0 * x ^ m›*) lemma power_int_add: assumes "x ≠ 0 ∨ m + n ≠ 0" shows "power_int (x::'a) (m + n) = power_int x m * power_int x n" proof (cases "x = 0") (*goals: 1. ‹x = 0 ⟹ x powi (m + n) = x powi m * x powi n› 2. ‹x ≠ 0 ⟹ x powi (m + n) = x powi m * x powi n›*) case True (*‹x = 0›*) thus "?thesis" (*goal: ‹x powi (m + n) = x powi m * x powi n›*) using assms (*‹x ≠ 0 ∨ m + n ≠ 0›*) by (auto simp: power_int_0_left_If (*‹0 powi ?m = (if ?m = 0 then 1 else 0)›*)) next (*goal: ‹(x::'a) ≠ (0::'a) ⟹ x powi ((m::int) + (n::int)) = x powi m * x powi n›*) case [simp]: False (*‹x ≠ 0›*) show "?thesis" (*goal: ‹x powi (m + n) = x powi m * x powi n›*) proof (cases m n rule: int_cases4[case_product int_cases4] (*‹⟦⋀na__ nb__. ⟦?ma2 = int na__; ?mb2 = int nb__⟧ ⟹ ?thesis2; ⋀na__ nb__. ⟦?ma2 = int na__; 0 < nb__; ?mb2 = - int nb__⟧ ⟹ ?thesis2; ⋀na__ nb__. ⟦0 < na__; ?ma2 = - int na__; ?mb2 = int nb__⟧ ⟹ ?thesis2; ⋀na__ nb__. ⟦0 < na__; ?ma2 = - int na__; 0 < nb__; ?mb2 = - int nb__⟧ ⟹ ?thesis2⟧ ⟹ ?thesis2›*)) (*goals: 1. ‹⋀na__ nb__. ⟦m = int na__; n = int nb__⟧ ⟹ x powi (m + n) = x powi m * x powi n› 2. ‹⋀na__ nb__. ⟦m = int na__; 0 < nb__; n = - int nb__⟧ ⟹ x powi (m + n) = x powi m * x powi n› 3. ‹⋀na__ nb__. ⟦0 < na__; m = - int na__; n = int nb__⟧ ⟹ x powi (m + n) = x powi m * x powi n› 4. ‹⋀na__ nb__. ⟦0 < na__; m = - int na__; 0 < nb__; n = - int nb__⟧ ⟹ x powi (m + n) = x powi m * x powi n›*) case (nonneg_nonneg a b) (*‹m = int a› ‹(n::int) = int (b::nat)›*) thus "?thesis" (*goal: ‹x powi (m + n) = x powi m * x powi n›*) by (auto simp: power_int_def (*‹(?x::?'a::{inverse,power}) powi (?n::int) = (if (0::int) ≤ ?n then ?x ^ nat ?n else inverse ?x ^ nat (- ?n))›*) nat_add_distrib (*‹⟦(0::int) ≤ (?z::int); (0::int) ≤ (?z'::int)⟧ ⟹ nat (?z + ?z') = nat ?z + nat ?z'›*) power_add (*‹(?a::?'a::monoid_mult) ^ ((?m::nat) + (?n::nat)) = ?a ^ ?m * ?a ^ ?n›*)) next (*goals: 1. ‹⋀na__ nb__. ⟦m = int na__; 0 < nb__; n = - int nb__⟧ ⟹ x powi (m + n) = x powi m * x powi n› 2. ‹⋀na__ nb__. ⟦0 < na__; m = - int na__; n = int nb__⟧ ⟹ x powi (m + n) = x powi m * x powi n› 3. ‹⋀na__ nb__. ⟦0 < na__; m = - int na__; 0 < nb__; n = - int nb__⟧ ⟹ x powi (m + n) = x powi m * x powi n›*) case (nonneg_neg a b) (*‹(m::int) = int (a::nat)› ‹0 < b› ‹n = - int b›*) thus "?thesis" (*goal: ‹x powi (m + n) = x powi m * x powi n›*) by (auto simp: power_int_def (*‹?x powi ?n = (if 0 ≤ ?n then ?x ^ nat ?n else inverse ?x ^ nat (- ?n))›*) nat_diff_distrib (*‹⟦0 ≤ ?z'; ?z' ≤ ?z⟧ ⟹ nat (?z - ?z') = nat ?z - nat ?z'›*) not_le (*‹(¬ ?x ≤ ?y) = (?y < ?x)›*) power_diff_conv_inverse (*‹⟦?x ≠ 0; ?m ≤ ?n⟧ ⟹ ?x ^ (?n - ?m) = ?x ^ ?n * inverse ?x ^ ?m›*) power_mult_power_inverse_commute (*‹?x ^ ?m * inverse ?x ^ ?n = inverse ?x ^ ?n * ?x ^ ?m›*)) next (*goals: 1. ‹⋀na__ nb__. ⟦0 < na__; m = - int na__; n = int nb__⟧ ⟹ x powi (m + n) = x powi m * x powi n› 2. ‹⋀na__ nb__. ⟦0 < na__; m = - int na__; 0 < nb__; n = - int nb__⟧ ⟹ x powi (m + n) = x powi m * x powi n›*) case (neg_nonneg a b) (*‹0 < a› ‹m = - int a› ‹n = int b›*) thus "?thesis" (*goal: ‹x powi (m + n) = x powi m * x powi n›*) by (auto simp: power_int_def (*‹?x powi ?n = (if 0 ≤ ?n then ?x ^ nat ?n else inverse ?x ^ nat (- ?n))›*) nat_diff_distrib (*‹⟦0 ≤ ?z'; ?z' ≤ ?z⟧ ⟹ nat (?z - ?z') = nat ?z - nat ?z'›*) not_le (*‹(¬ ?x ≤ ?y) = (?y < ?x)›*) power_diff_conv_inverse (*‹⟦?x ≠ 0; ?m ≤ ?n⟧ ⟹ ?x ^ (?n - ?m) = ?x ^ ?n * inverse ?x ^ ?m›*) power_mult_power_inverse_commute (*‹?x ^ ?m * inverse ?x ^ ?n = inverse ?x ^ ?n * ?x ^ ?m›*)) next (*goal: ‹⋀na__ nb__. ⟦0 < na__; m = - int na__; 0 < nb__; n = - int nb__⟧ ⟹ x powi (m + n) = x powi m * x powi n›*) case (neg_neg a b) (*‹0 < a› ‹m = - int a› ‹0 < b› ‹n = - int b›*) thus "?thesis" (*goal: ‹(x::'a) powi ((m::int) + (n::int)) = x powi m * x powi n›*) by (auto simp: power_int_def (*‹?x powi ?n = (if 0 ≤ ?n then ?x ^ nat ?n else inverse ?x ^ nat (- ?n))›*) nat_add_distrib (*‹⟦0 ≤ ?z; 0 ≤ ?z'⟧ ⟹ nat (?z + ?z') = nat ?z + nat ?z'›*) add.commute (*‹?a + ?b = ?b + ?a›*) simp flip: power_add (*‹?a ^ (?m + ?n) = ?a ^ ?m * ?a ^ ?n›*)) qed qed lemma power_int_add_1: assumes "x ≠ 0 ∨ m ≠ -1" shows "power_int (x::'a) (m + 1) = power_int x m * x" using assms (*‹x ≠ 0 ∨ m ≠ - 1›*) apply (subst power_int_add (*‹?x ≠ 0 ∨ ?m + ?n ≠ 0 ⟹ ?x powi (?m + ?n) = ?x powi ?m * ?x powi ?n›*)) (*goals: 1. ‹x ≠ 0 ∨ m ≠ - 1 ⟹ x ≠ 0 ∨ m + 1 ≠ 0› 2. ‹x ≠ 0 ∨ m ≠ - 1 ⟹ x powi m * x powi 1 = x powi m * x› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . lemma power_int_add_1': assumes "x ≠ 0 ∨ m ≠ -1" shows "power_int (x::'a) (m + 1) = x * power_int x m" using assms (*‹(x::'a) ≠ (0::'a) ∨ (m::int) ≠ - (1::int)›*) apply (subst add.commute (*‹?a + ?b = ?b + ?a›*)) (*goal: ‹(x::'a) powi ((m::int) + (1::int)) = x * x powi m›*) apply (subst power_int_add (*‹?x ≠ 0 ∨ ?m + ?n ≠ 0 ⟹ ?x powi (?m + ?n) = ?x powi ?m * ?x powi ?n›*)) (*goals: 1. ‹x ≠ 0 ∨ m ≠ - 1 ⟹ x ≠ 0 ∨ 1 + m ≠ 0› 2. ‹x ≠ 0 ∨ m ≠ - 1 ⟹ x powi 1 * x powi m = x * x powi m› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . lemma power_int_commutes: "power_int (x :: 'a) n * x = x * power_int x n" apply (cases "x = 0") (*goals: 1. ‹(x::'a) = (0::'a) ⟹ x powi (n::int) * x = x * x powi n› 2. ‹(x::'a) ≠ (0::'a) ⟹ x powi (n::int) * x = x * x powi n› discuss goal 1*) apply ((auto simp flip: power_int_add_1 (*‹?x ≠ 0 ∨ ?m ≠ - 1 ⟹ ?x powi (?m + 1) = ?x powi ?m * ?x›*) power_int_add_1' (*‹?x ≠ 0 ∨ ?m ≠ - 1 ⟹ ?x powi (?m + 1) = ?x * ?x powi ?m›*))[1]) (*discuss goal 2*) apply ((auto simp flip: power_int_add_1 (*‹?x ≠ 0 ∨ ?m ≠ - 1 ⟹ ?x powi (?m + 1) = ?x powi ?m * ?x›*) power_int_add_1' (*‹?x ≠ 0 ∨ ?m ≠ - 1 ⟹ ?x powi (?m + 1) = ?x * ?x powi ?m›*))[1]) (*proven 2 subgoals*) . lemma power_int_inverse [field_simps, field_split_simps, divide_simps]: "power_int (inverse (x :: 'a)) n = inverse (power_int x n)" by (auto simp: 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)›*)) lemma power_int_mult: "power_int (x :: 'a) (m * n) = power_int (power_int x m) n" by (auto simp: power_int_def (*‹(?x::?'a) powi (?n::int) = (if (0::int) ≤ ?n then ?x ^ nat ?n else inverse ?x ^ nat (- ?n))›*) zero_le_mult_iff (*‹((0::?'a) ≤ (?a::?'a) * (?b::?'a)) = ((0::?'a) ≤ ?a ∧ (0::?'a) ≤ ?b ∨ ?a ≤ (0::?'a) ∧ ?b ≤ (0::?'a))›*) simp flip: power_mult (*‹(?a::?'a) ^ ((?m::nat) * (?n::nat)) = (?a ^ ?m) ^ ?n›*) power_inverse (*‹inverse (?a::?'a) ^ (?n::nat) = inverse (?a ^ ?n)›*) nat_mult_distrib (*‹(0::int) ≤ (?z::int) ⟹ nat (?z * (?z'::int)) = nat ?z * nat ?z'›*)) end context assumes "SORT_CONSTRAINT('a::field)" begin lemma power_int_diff: assumes "x ≠ 0 ∨ m ≠ n" shows "power_int (x::'a) (m - n) = power_int x m / power_int x n" using power_int_add[of x m "-n"] (*‹x ≠ 0 ∨ m + - n ≠ 0 ⟹ x powi (m + - n) = x powi m * x powi - n›*) assms (*‹x ≠ 0 ∨ m ≠ n›*) 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 40 facts*) power_int_minus (*‹?x powi - ?n = inverse (?x powi ?n)›*)) lemma power_int_minus_mult: "x ≠ 0 ∨ n ≠ 0 ⟹ power_int (x :: 'a) (n - 1) * x = power_int x n" by (auto simp flip: power_int_add_1 (*‹?x ≠ 0 ∨ ?m ≠ - 1 ⟹ ?x powi (?m + 1) = ?x powi ?m * ?x›*)) lemma power_int_mult_distrib: "power_int (x * y :: 'a) m = power_int x m * power_int y m" by (auto simp: power_int_def (*‹?x powi ?n = (if 0 ≤ ?n then ?x ^ nat ?n else inverse ?x ^ nat (- ?n))›*) power_mult_distrib (*‹(?a * ?b) ^ ?n = ?a ^ ?n * ?b ^ ?n›*)) lemmas power_int_mult_distrib_numeral1 = power_int_mult_distrib [where x = "numeral w" for w, simp] lemmas power_int_mult_distrib_numeral2 = power_int_mult_distrib [where y = "numeral w" for w, simp] lemma power_int_divide_distrib: "power_int (x / y :: 'a) m = power_int x m / power_int y m" using power_int_mult_distrib[of x "inverse y" m] (*‹((x::'a::field) * inverse (y::'a::field)) powi (m::int) = x powi m * inverse y powi m›*) unfolding power_int_inverse (*goal: ‹(x / y) powi m = x powi m / y powi m›*) 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 40 facts*)) end lemma power_int_add_numeral [simp]: "power_int x (numeral m) * power_int x (numeral n) = power_int x (numeral (m + n))" for x :: "'a :: division_ring" by (simp add: power_int_add [symmetric] (*‹?x ≠ 0 ∨ ?m + ?n ≠ 0 ⟹ ?x powi ?m * ?x powi ?n = ?x powi (?m + ?n)›*)) lemma power_int_add_numeral2 [simp]: "power_int x (numeral m) * (power_int x (numeral n) * b) = power_int x (numeral (m + n)) * b" for x :: "'a :: division_ring" by (simp add: mult.assoc [symmetric] (*‹(?a::?'a::semigroup_mult) * ((?b::?'a::semigroup_mult) * (?c::?'a::semigroup_mult)) = ?a * ?b * ?c›*)) lemma power_int_mult_numeral [simp]: "power_int (power_int x (numeral m)) (numeral n) = power_int x (numeral (m * n))" for x :: "'a :: division_ring" by (simp only: numeral_mult (*‹numeral (?m * ?n) = numeral ?m * numeral ?n›*) power_int_mult (*‹?x powi (?m * ?n) = (?x powi ?m) powi ?n›*)) lemma power_int_not_zero: "(x :: 'a :: division_ring) ≠ 0 ∨ n = 0 ⟹ power_int x n ≠ 0" apply (subst power_int_eq_0_iff (*‹(?x powi ?n = 0) = (?x = 0 ∧ ?n ≠ 0)›*)) (*goal: ‹x ≠ 0 ∨ n = 0 ⟹ x powi n ≠ 0›*) by auto lemma power_int_one_over [field_simps, field_split_simps, divide_simps]: "power_int (1 / x :: 'a :: division_ring) n = 1 / power_int x n" using power_int_inverse[of x] (*‹inverse x powi ?n = inverse (x powi ?n)›*) by (simp add: divide_inverse (*‹?a / ?b = ?a * inverse ?b›*)) context assumes "SORT_CONSTRAINT('a :: linordered_field)" begin lemma power_int_numeral_neg_numeral [simp]: "power_int (numeral m) (-numeral n) = (inverse (numeral (Num.pow m n)) :: 'a)" by (simp add: power_int_minus (*‹?x powi - ?n = inverse (?x powi ?n)›*)) lemma zero_less_power_int [simp]: "0 < (x :: 'a) ⟹ 0 < power_int x n" by (auto simp: power_int_def (*‹?x powi ?n = (if 0 ≤ ?n then ?x ^ nat ?n else inverse ?x ^ nat (- ?n))›*)) lemma zero_le_power_int [simp]: "0 ≤ (x :: 'a) ⟹ 0 ≤ power_int x n" by (auto simp: power_int_def (*‹?x powi ?n = (if 0 ≤ ?n then ?x ^ nat ?n else inverse ?x ^ nat (- ?n))›*)) lemma power_int_mono: "(x :: 'a) ≤ y ⟹ n ≥ 0 ⟹ 0 ≤ x ⟹ power_int x n ≤ power_int y n" apply (cases n rule: int_cases4 (*‹⟦⋀n. ?m = int n ⟹ ?thesis; ⋀n. ⟦0 < n; ?m = - int n⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*)) (*goals: 1. ‹⋀na::nat. ⟦(x::'a::linordered_field) ≤ (y::'a::linordered_field); (0::int) ≤ (n::int); (0::'a::linordered_field) ≤ x; n = int na⟧ ⟹ x powi n ≤ y powi n› 2. ‹⋀na::nat. ⟦(x::'a::linordered_field) ≤ (y::'a::linordered_field); (0::int) ≤ (n::int); (0::'a::linordered_field) ≤ x; (0::nat) < na; n = - int na⟧ ⟹ x powi n ≤ y powi n› discuss goal 1*) apply ((auto intro: power_mono (*‹⟦?a ≤ ?b; 0 ≤ ?a⟧ ⟹ ?a ^ ?n ≤ ?b ^ ?n›*))[1]) (*discuss goal 2*) apply ((auto intro: power_mono (*‹⟦?a ≤ ?b; 0 ≤ ?a⟧ ⟹ ?a ^ ?n ≤ ?b ^ ?n›*))[1]) (*proven 2 subgoals*) . lemma one_le_power_int [simp]: "1 ≤ (x :: 'a) ⟹ n ≥ 0 ⟹ 1 ≤ power_int x n" using power_int_mono[of 1 x n] (*‹⟦1 ≤ x; 0 ≤ n; 0 ≤ 1⟧ ⟹ 1 powi n ≤ x powi n›*) by simp lemma power_int_le_one: "0 ≤ (x :: 'a) ⟹ n ≥ 0 ⟹ x ≤ 1 ⟹ power_int x n ≤ 1" using power_int_mono[of x 1 n] (*‹⟦x ≤ 1; 0 ≤ n; 0 ≤ x⟧ ⟹ x powi n ≤ 1 powi n›*) by simp lemma power_int_le_imp_le_exp: assumes gt1: "1 < (x :: 'a :: linordered_field)" assumes "power_int x m ≤ power_int x n" "n ≥ 0" shows "m ≤ n" proof (cases "m < 0") (*goals: 1. ‹m < 0 ⟹ m ≤ n› 2. ‹¬ m < 0 ⟹ m ≤ n›*) case True (*‹m < 0›*) with ‹n ≥ 0› (*‹0 ≤ n›*) show "?thesis" (*goal: ‹m ≤ n›*) by simp next (*goal: ‹¬ m < 0 ⟹ m ≤ n›*) case False (*‹¬ (m::int) < (0::int)›*) with assms (*‹1 < x› ‹x powi m ≤ x powi n› ‹0 ≤ n›*) have "x ^ nat m ≤ x ^ nat n" by (simp add: power_int_def (*‹(?x::?'a) powi (?n::int) = (if (0::int) ≤ ?n then ?x ^ nat ?n else inverse ?x ^ nat (- ?n))›*)) from gt1 (*‹1 < x›*) this (*‹(x::'a) ^ nat (m::int) ≤ x ^ nat (n::int)›*) show "?thesis" (*goal: ‹m ≤ n›*) using False (*‹¬ m < 0›*) ‹n ≥ 0› (*‹0 ≤ n›*) by auto qed lemma power_int_le_imp_less_exp: assumes gt1: "1 < (x :: 'a :: linordered_field)" assumes "power_int x m < power_int x n" "n ≥ 0" shows "m < n" proof (cases "m < 0") (*goals: 1. ‹m < 0 ⟹ m < n› 2. ‹¬ m < 0 ⟹ m < n›*) case True (*‹m < 0›*) with ‹n ≥ 0› (*‹0 ≤ n›*) show "?thesis" (*goal: ‹m < n›*) by simp next (*goal: ‹¬ m < 0 ⟹ m < n›*) case False (*‹¬ m < 0›*) with assms (*‹1 < x› ‹x powi m < x powi n› ‹0 ≤ n›*) have "x ^ nat m < x ^ nat n" by (simp add: power_int_def (*‹?x powi ?n = (if 0 ≤ ?n then ?x ^ nat ?n else inverse ?x ^ nat (- ?n))›*)) from gt1 (*‹1 < x›*) this (*‹x ^ nat m < x ^ nat n›*) show "?thesis" (*goal: ‹m < n›*) using False (*‹¬ m < 0›*) ‹n ≥ 0› (*‹0 ≤ n›*) by auto qed lemma power_int_strict_mono: "(a :: 'a :: linordered_field) < b ⟹ 0 ≤ a ⟹ 0 < n ⟹ power_int a n < power_int b n" by (auto simp: power_int_def (*‹?x powi ?n = (if 0 ≤ ?n then ?x ^ nat ?n else inverse ?x ^ nat (- ?n))›*) intro!: power_strict_mono (*‹⟦?a < ?b; 0 ≤ ?a; 0 < ?n⟧ ⟹ ?a ^ ?n < ?b ^ ?n›*)) lemma power_int_mono_iff [simp]: fixes a b :: "'a :: linordered_field" shows "⟦a ≥ 0; b ≥ 0; n > 0⟧ ⟹ power_int a n ≤ power_int b n ⟷ a ≤ b" by (auto simp: power_int_def (*‹?x powi ?n = (if 0 ≤ ?n then ?x ^ nat ?n else inverse ?x ^ nat (- ?n))›*) intro!: power_strict_mono (*‹⟦?a < ?b; 0 ≤ ?a; 0 < ?n⟧ ⟹ ?a ^ ?n < ?b ^ ?n›*)) lemma power_int_strict_increasing: fixes a :: "'a :: linordered_field" assumes "n < N" "1 < a" shows "power_int a N > power_int a n" proof (-) (*goal: ‹(a::'a) powi (n::int) < a powi (N::int)›*) have "*": "a ^ nat (N - n) > a ^ 0" using assms (*‹n < N› ‹1 < a›*) apply (intro power_strict_increasing (*‹⟦(?n::nat) < (?N::nat); (1::?'a) < (?a::?'a)⟧ ⟹ ?a ^ ?n < ?a ^ ?N›*)) (*goals: 1. ‹⟦(n::int) < (N::int); (1::'a::linordered_field) < (a::'a::linordered_field)⟧ ⟹ (0::nat) < nat (N - n)› 2. ‹⟦(n::int) < (N::int); (1::'a::linordered_field) < (a::'a::linordered_field)⟧ ⟹ (1::'a::linordered_field) < a› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . have "power_int a N = power_int a n * power_int a (N - n)" using assms (*‹n < N› ‹(1::'a) < (a::'a)›*) by (simp flip: power_int_add (*‹?x ≠ 0 ∨ ?m + ?n ≠ 0 ⟹ ?x powi (?m + ?n) = ?x powi ?m * ?x powi ?n›*)) also (*calculation: ‹a powi N = a powi n * a powi (N - n)›*) have "… > power_int a n * 1" using assms (*‹n < N› ‹1 < a›*) "*" (*‹a ^ 0 < a ^ nat (N - n)›*) apply (intro mult_strict_left_mono (*‹⟦?a < ?b; 0 < ?c⟧ ⟹ ?c * ?a < ?c * ?b›*) zero_less_power_int (*‹0 < ?x ⟹ 0 < ?x powi ?n›*)) (*goals: 1. ‹⟦n < N; 1 < a; a ^ 0 < a ^ nat (N - n)⟧ ⟹ 1 < a powi (N - n)› 2. ‹⟦n < N; 1 < a; a ^ 0 < a ^ nat (N - n)⟧ ⟹ 0 < a› discuss goal 1*) apply ((auto simp: power_int_def (*‹(?x::?'a::{inverse,power}) powi (?n::int) = (if (0::int) ≤ ?n then ?x ^ nat ?n else inverse ?x ^ nat (- ?n))›*))[1]) (*discuss goal 2*) apply ((auto simp: power_int_def (*‹?x powi ?n = (if 0 ≤ ?n then ?x ^ nat ?n else inverse ?x ^ nat (- ?n))›*))[1]) (*proven 2 subgoals*) . finally (*calculation: ‹(a::'a::linordered_field) powi (n::int) * (1::'a::linordered_field) < a powi (N::int)›*) show "?thesis" (*goal: ‹a powi n < a powi N›*) by simp qed lemma power_int_increasing: fixes a :: "'a :: linordered_field" assumes "n ≤ N" "a ≥ 1" shows "power_int a N ≥ power_int a n" proof (-) (*goal: ‹a powi n ≤ a powi N›*) have "*": "a ^ nat (N - n) ≥ a ^ 0" using assms (*‹n ≤ N› ‹1 ≤ a›*) apply (intro power_increasing (*‹⟦?n ≤ ?N; 1 ≤ ?a⟧ ⟹ ?a ^ ?n ≤ ?a ^ ?N›*)) (*goals: 1. ‹⟦(n::int) ≤ (N::int); (1::'a::linordered_field) ≤ (a::'a::linordered_field)⟧ ⟹ (0::nat) ≤ nat (N - n)› 2. ‹⟦(n::int) ≤ (N::int); (1::'a::linordered_field) ≤ (a::'a::linordered_field)⟧ ⟹ (1::'a::linordered_field) ≤ a› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . have "power_int a N = power_int a n * power_int a (N - n)" using assms (*‹n ≤ N› ‹1 ≤ a›*) by (simp flip: power_int_add (*‹?x ≠ 0 ∨ ?m + ?n ≠ 0 ⟹ ?x powi (?m + ?n) = ?x powi ?m * ?x powi ?n›*)) also (*calculation: ‹a powi N = a powi n * a powi (N - n)›*) have "… ≥ power_int a n * 1" using assms (*‹n ≤ N› ‹(1::'a) ≤ (a::'a)›*) "*" (*‹a ^ 0 ≤ a ^ nat (N - n)›*) apply (intro mult_left_mono (*‹⟦?a ≤ ?b; 0 ≤ ?c⟧ ⟹ ?c * ?a ≤ ?c * ?b›*)) (*goals: 1. ‹⟦n ≤ N; 1 ≤ a; a ^ 0 ≤ a ^ nat (N - n)⟧ ⟹ 1 ≤ a powi (N - n)› 2. ‹⟦n ≤ N; 1 ≤ a; a ^ 0 ≤ a ^ nat (N - n)⟧ ⟹ 0 ≤ a powi n› discuss goal 1*) apply ((auto simp: power_int_def (*‹?x powi ?n = (if 0 ≤ ?n then ?x ^ nat ?n else inverse ?x ^ nat (- ?n))›*))[1]) (*discuss goal 2*) apply ((auto simp: power_int_def (*‹?x powi ?n = (if 0 ≤ ?n then ?x ^ nat ?n else inverse ?x ^ nat (- ?n))›*))[1]) (*proven 2 subgoals*) . finally (*calculation: ‹a powi n * 1 ≤ a powi N›*) show "?thesis" (*goal: ‹a powi n ≤ a powi N›*) by simp qed lemma power_int_strict_decreasing: fixes a :: "'a :: linordered_field" assumes "n < N" "0 < a" "a < 1" shows "power_int a N < power_int a n" proof (-) (*goal: ‹a powi N < a powi n›*) have "*": "a ^ nat (N - n) < a ^ 0" using assms (*‹n < N› ‹0 < a› ‹a < 1›*) apply (intro power_strict_decreasing (*‹⟦?n < ?N; 0 < ?a; ?a < 1⟧ ⟹ ?a ^ ?N < ?a ^ ?n›*)) (*goals: 1. ‹⟦n < N; 0 < a; a < 1⟧ ⟹ 0 < nat (N - n)› 2. ‹⟦n < N; 0 < a; a < 1⟧ ⟹ 0 < a› 3. ‹⟦n < N; 0 < a; a < 1⟧ ⟹ a < 1› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*proven 3 subgoals*) . have "power_int a N = power_int a n * power_int a (N - n)" using assms (*‹n < N› ‹0 < a› ‹a < 1›*) by (simp flip: power_int_add (*‹?x ≠ 0 ∨ ?m + ?n ≠ 0 ⟹ ?x powi (?m + ?n) = ?x powi ?m * ?x powi ?n›*)) also (*calculation: ‹a powi N = a powi n * a powi (N - n)›*) have "… < power_int a n * 1" using assms (*‹n < N› ‹0 < a› ‹a < 1›*) "*" (*‹a ^ nat (N - n) < a ^ 0›*) apply (intro mult_strict_left_mono (*‹⟦?a < ?b; 0 < ?c⟧ ⟹ ?c * ?a < ?c * ?b›*) zero_less_power_int (*‹0 < ?x ⟹ 0 < ?x powi ?n›*)) (*goals: 1. ‹⟦n < N; 0 < a; a < 1; a ^ nat (N - n) < a ^ 0⟧ ⟹ a powi (N - n) < 1› 2. ‹⟦n < N; 0 < a; a < 1; a ^ nat (N - n) < a ^ 0⟧ ⟹ 0 < a› discuss goal 1*) apply ((auto simp: power_int_def (*‹?x powi ?n = (if 0 ≤ ?n then ?x ^ nat ?n else inverse ?x ^ nat (- ?n))›*))[1]) (*discuss goal 2*) apply ((auto simp: power_int_def (*‹?x powi ?n = (if 0 ≤ ?n then ?x ^ nat ?n else inverse ?x ^ nat (- ?n))›*))[1]) (*proven 2 subgoals*) . finally (*calculation: ‹a powi N < a powi n * 1›*) show "?thesis" (*goal: ‹(a::'a) powi (N::int) < a powi (n::int)›*) by simp qed lemma power_int_decreasing: fixes a :: "'a :: linordered_field" assumes "n ≤ N" "0 ≤ a" "a ≤ 1" "a ≠ 0 ∨ N ≠ 0 ∨ n = 0" shows "power_int a N ≤ power_int a n" proof (cases "a = 0") (*goals: 1. ‹a = 0 ⟹ a powi N ≤ a powi n› 2. ‹a ≠ 0 ⟹ a powi N ≤ a powi n›*) case False (*‹a ≠ 0›*) have "*": "a ^ nat (N - n) ≤ a ^ 0" using assms (*‹n ≤ N› ‹0 ≤ a› ‹a ≤ 1› ‹a ≠ 0 ∨ N ≠ 0 ∨ n = 0›*) apply (intro power_decreasing (*‹⟦?n ≤ ?N; 0 ≤ ?a; ?a ≤ 1⟧ ⟹ ?a ^ ?N ≤ ?a ^ ?n›*)) (*goals: 1. ‹⟦n ≤ N; 0 ≤ a; a ≤ 1; a ≠ 0 ∨ N ≠ 0 ∨ n = 0⟧ ⟹ 0 ≤ nat (N - n)› 2. ‹⟦n ≤ N; 0 ≤ a; a ≤ 1; a ≠ 0 ∨ N ≠ 0 ∨ n = 0⟧ ⟹ 0 ≤ a› 3. ‹⟦n ≤ N; 0 ≤ a; a ≤ 1; a ≠ 0 ∨ N ≠ 0 ∨ n = 0⟧ ⟹ a ≤ 1› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*proven 3 subgoals*) . have "power_int a N = power_int a n * power_int a (N - n)" using assms (*‹n ≤ N› ‹0 ≤ a› ‹a ≤ 1› ‹a ≠ 0 ∨ N ≠ 0 ∨ n = 0›*) False (*‹a ≠ 0›*) by (simp flip: power_int_add (*‹(?x::?'a) ≠ (0::?'a) ∨ (?m::int) + (?n::int) ≠ (0::int) ⟹ ?x powi (?m + ?n) = ?x powi ?m * ?x powi ?n›*)) also (*calculation: ‹a powi N = a powi n * a powi (N - n)›*) have "… ≤ power_int a n * 1" using assms (*‹n ≤ N› ‹0 ≤ a› ‹a ≤ 1› ‹(a::'a) ≠ (0::'a) ∨ (N::int) ≠ (0::int) ∨ (n::int) = (0::int)›*) "*" (*‹a ^ nat (N - n) ≤ a ^ 0›*) apply (intro mult_left_mono (*‹⟦(?a::?'a::ordered_semiring) ≤ (?b::?'a::ordered_semiring); (0::?'a::ordered_semiring) ≤ (?c::?'a::ordered_semiring)⟧ ⟹ ?c * ?a ≤ ?c * ?b›*)) (*goals: 1. ‹⟦n ≤ N; 0 ≤ a; a ≤ 1; a ≠ 0 ∨ N ≠ 0 ∨ n = 0; a ^ nat (N - n) ≤ a ^ 0⟧ ⟹ a powi (N - n) ≤ 1› 2. ‹⟦n ≤ N; 0 ≤ a; a ≤ 1; a ≠ 0 ∨ N ≠ 0 ∨ n = 0; a ^ nat (N - n) ≤ a ^ 0⟧ ⟹ 0 ≤ a powi n› discuss goal 1*) apply ((auto simp: power_int_def (*‹?x powi ?n = (if 0 ≤ ?n then ?x ^ nat ?n else inverse ?x ^ nat (- ?n))›*))[1]) (*discuss goal 2*) apply ((auto simp: power_int_def (*‹?x powi ?n = (if 0 ≤ ?n then ?x ^ nat ?n else inverse ?x ^ nat (- ?n))›*))[1]) (*proven 2 subgoals*) . finally (*calculation: ‹a powi N ≤ a powi n * 1›*) show "?thesis" (*goal: ‹a powi N ≤ a powi n›*) by simp qed (use assms in ‹auto simp: power_int_0_left_If›) (*solved the remaining goal: ‹a = 0 ⟹ a powi N ≤ a powi n›*) lemma one_less_power_int: "1 < (a :: 'a) ⟹ 0 < n ⟹ 1 < power_int a n" using power_int_strict_increasing[of 0 n a] (*‹⟦0 < n; 1 < a⟧ ⟹ a powi 0 < a powi n›*) by simp lemma power_int_abs: "¦power_int a n :: 'a¦ = power_int ¦a¦ n" by (auto simp: power_int_def (*‹?x powi ?n = (if 0 ≤ ?n then ?x ^ nat ?n else inverse ?x ^ nat (- ?n))›*) power_abs (*‹¦?a ^ ?n¦ = ¦?a¦ ^ ?n›*)) lemma power_int_sgn [simp]: "sgn (power_int a n :: 'a) = power_int (sgn a) n" by (auto simp: power_int_def (*‹?x powi ?n = (if 0 ≤ ?n then ?x ^ nat ?n else inverse ?x ^ nat (- ?n))›*)) lemma abs_power_int_minus [simp]: "¦power_int (- a) n :: 'a¦ = ¦power_int a n¦" by (simp add: power_int_abs (*‹¦?a powi ?n¦ = ¦?a¦ powi ?n›*)) lemma power_int_strict_antimono: assumes "(a :: 'a :: linordered_field) < b" "0 < a" "n < 0" shows "power_int a n > power_int b n" proof (-) (*goal: ‹b powi n < a powi n›*) have "inverse (power_int a (-n)) > inverse (power_int b (-n))" using assms (*‹a < b› ‹0 < a› ‹(n::int) < (0::int)›*) apply (intro less_imp_inverse_less (*‹⟦?a < ?b; 0 < ?a⟧ ⟹ inverse ?b < inverse ?a›*) power_int_strict_mono (*‹⟦?a < ?b; 0 ≤ ?a; 0 < ?n⟧ ⟹ ?a powi ?n < ?b powi ?n›*) zero_less_power_int (*‹0 < ?x ⟹ 0 < ?x powi ?n›*)) (*goals: 1. ‹⟦a < b; 0 < a; n < 0⟧ ⟹ a < b› 2. ‹⟦a < b; 0 < a; n < 0⟧ ⟹ 0 ≤ a› 3. ‹⟦a < b; 0 < a; n < 0⟧ ⟹ 0 < - n› 4. ‹⟦a < b; 0 < a; n < 0⟧ ⟹ 0 < 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*) . thus "?thesis" (*goal: ‹b powi n < a powi n›*) by (simp add: power_int_minus (*‹(?x::?'a) powi - (?n::int) = inverse (?x powi ?n)›*)) qed lemma power_int_antimono: assumes "(a :: 'a :: linordered_field) ≤ b" "0 < a" "n < 0" shows "power_int a n ≥ power_int b n" using power_int_strict_antimono[of a b n] (*‹⟦(a::'a) < (b::'a); (0::'a) < a; (n::int) < (0::int)⟧ ⟹ b powi n < a powi n›*) assms (*‹a ≤ b› ‹0 < a› ‹n < 0›*) apply (cases "a = b") (*goals: 1. ‹⟦⟦(a::'a) < (b::'a); (0::'a) < a; (n::int) < (0::int)⟧ ⟹ b powi n < a powi n; a ≤ b; (0::'a) < a; n < (0::int); a = b⟧ ⟹ b powi n ≤ a powi n› 2. ‹⟦⟦(a::'a) < (b::'a); (0::'a) < a; (n::int) < (0::int)⟧ ⟹ b powi n < a powi n; a ≤ b; (0::'a) < a; n < (0::int); a ≠ b⟧ ⟹ b powi n ≤ a powi n› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . end subsection ‹Finiteness of intervals› lemma finite_interval_int1 [iff]: "finite {i :: int. a ≤ i ∧ i ≤ b}" proof (cases "a ≤ b") (*goals: 1. ‹(a::int) ≤ (b::int) ⟹ finite {i::int. a ≤ i ∧ i ≤ b}› 2. ‹¬ (a::int) ≤ (b::int) ⟹ finite {i::int. a ≤ i ∧ i ≤ b}›*) case True (*‹a ≤ b›*) then show "?thesis" (*goal: ‹finite {i. a ≤ i ∧ i ≤ b}›*) proof (induct b rule: int_ge_induct (*‹⟦?k ≤ ?i; ?P ?k; ⋀i. ⟦?k ≤ i; ?P i⟧ ⟹ ?P (i + 1)⟧ ⟹ ?P ?i›*)) (*goals: 1. ‹finite {i. a ≤ i ∧ i ≤ a}› 2. ‹⋀i. ⟦a ≤ i; finite {ia. a ≤ ia ∧ ia ≤ i}⟧ ⟹ finite {ia. a ≤ ia ∧ ia ≤ i + 1}›*) case base (*no hyothesis introduced yet*) have "{i. a ≤ i ∧ i ≤ a} = {a}" by auto then show "?case" (*goal: ‹finite {i. a ≤ i ∧ i ≤ a}›*) by simp next (*goal: ‹⋀i. ⟦a ≤ i; finite {ia. a ≤ ia ∧ ia ≤ i}⟧ ⟹ finite {ia. a ≤ ia ∧ ia ≤ i + 1}›*) case (step b) (*‹a ≤ b› ‹finite {i. a ≤ i ∧ i ≤ b}›*) then have "{i. a ≤ i ∧ i ≤ b + 1} = {i. a ≤ i ∧ i ≤ b} ∪ {b + 1}" by auto with step (*‹a ≤ b› ‹finite {i. a ≤ i ∧ i ≤ b}›*) show "?case" (*goal: ‹finite {i. a ≤ i ∧ i ≤ b + 1}›*) by simp qed next (*goal: ‹¬ (a::int) ≤ (b::int) ⟹ finite {i::int. a ≤ i ∧ i ≤ b}›*) case False (*‹¬ a ≤ b›*) then show "?thesis" (*goal: ‹finite {i. a ≤ i ∧ i ≤ b}›*) by (metis (lifting, no_types) Collect_empty_eq (*‹(Collect ?P = {}) = (∀x. ¬ ?P x)›*) finite.emptyI (*‹finite {}›*) order_trans (*‹⟦?x ≤ ?y; ?y ≤ ?z⟧ ⟹ ?x ≤ ?z›*)) qed lemma finite_interval_int2 [iff]: "finite {i :: int. a ≤ i ∧ i < b}" apply (rule rev_finite_subset[OF finite_interval_int1[of "a" "b"]] (*‹(?A::int set) ⊆ {i::int. (a::int) ≤ i ∧ i ≤ (b::int)} ⟹ finite ?A›*)) (*goal: ‹finite {i. a ≤ i ∧ i < b}›*) by auto lemma finite_interval_int3 [iff]: "finite {i :: int. a < i ∧ i ≤ b}" apply (rule rev_finite_subset[OF finite_interval_int1[of "a" "b"]] (*‹?A ⊆ {i. a ≤ i ∧ i ≤ b} ⟹ finite ?A›*)) (*goal: ‹finite {i. a < i ∧ i ≤ b}›*) by auto lemma finite_interval_int4 [iff]: "finite {i :: int. a < i ∧ i < b}" apply (rule rev_finite_subset[OF finite_interval_int1[of "a" "b"]] (*‹?A ⊆ {i. a ≤ i ∧ i ≤ b} ⟹ finite ?A›*)) (*goal: ‹finite {i. a < i ∧ i < b}›*) by auto subsection ‹Configuration of the code generator› text ‹Constructors› definition Pos :: "num ⇒ int" where [simp, code_abbrev]: "Pos = numeral" definition Neg :: "num ⇒ int" where [simp, code_abbrev]: "Neg n = - (Pos n)" code_datatype "0::int" Pos Neg text ‹Auxiliary operations.› definition dup :: "int ⇒ int" where [simp]: "dup k = k + k" lemma dup_code [code]: "dup 0 = 0" "dup (Pos n) = Pos (Num.Bit0 n)" "dup (Neg n) = Neg (Num.Bit0 n)" (*goals: 1. ‹dup 0 = 0› 2. ‹dup (Pos n) = Pos (num.Bit0 n)› 3. ‹dup (Neg n) = Neg (num.Bit0 n)› discuss goal 1*) apply (simp add: numeral_Bit0 (*‹numeral (num.Bit0 ?n) = numeral ?n + numeral ?n›*)) (*discuss goal 2*) apply (simp add: numeral_Bit0 (*‹numeral (num.Bit0 (?n::num)) = numeral ?n + numeral ?n›*)) (*discuss goal 3*) apply (simp add: numeral_Bit0 (*‹numeral (num.Bit0 ?n) = numeral ?n + numeral ?n›*)) (*proven 3 subgoals*) . definition sub :: "num ⇒ num ⇒ int" where [simp]: "sub m n = numeral m - numeral n" lemma sub_code [code]: "sub Num.One Num.One = 0" "sub (Num.Bit0 m) Num.One = Pos (Num.BitM m)" "sub (Num.Bit1 m) Num.One = Pos (Num.Bit0 m)" "sub Num.One (Num.Bit0 n) = Neg (Num.BitM n)" "sub Num.One (Num.Bit1 n) = Neg (Num.Bit0 n)" "sub (Num.Bit0 m) (Num.Bit0 n) = dup (sub m n)" "sub (Num.Bit1 m) (Num.Bit1 n) = dup (sub m n)" "sub (Num.Bit1 m) (Num.Bit0 n) = dup (sub m n) + 1" "sub (Num.Bit0 m) (Num.Bit1 n) = dup (sub m n) - 1" (*goals: 1. ‹sub num.One num.One = (0::int)› 2. ‹sub (num.Bit0 (m::num)) num.One = Pos (Num.BitM m)› 3. ‹sub (num.Bit1 (m::num)) num.One = Pos (num.Bit0 m)› 4. ‹sub num.One (num.Bit0 (n::num)) = Neg (Num.BitM n)› 5. ‹sub num.One (num.Bit1 (n::num)) = Neg (num.Bit0 n)› 6. ‹sub (num.Bit0 (m::num)) (num.Bit0 (n::num)) = dup (sub m n)› 7. ‹sub (num.Bit1 (m::num)) (num.Bit1 (n::num)) = dup (sub m n)› 8. ‹sub (num.Bit1 (m::num)) (num.Bit0 (n::num)) = dup (sub m n) + (1::int)› 9. ‹sub (num.Bit0 (m::num)) (num.Bit1 (n::num)) = dup (sub m n) - (1::int)› discuss goal 1*) apply (simp only: sub_def (*‹sub ?m ?n = numeral ?m - numeral ?n›*) dup_def (*‹dup ?k = ?k + ?k›*) numeral.simps (*‹Numeral1 = 1› ‹numeral (num.Bit0 ?n) = numeral ?n + numeral ?n› ‹numeral (num.Bit1 ?n) = numeral ?n + numeral ?n + 1›*) Pos_def (*‹Pos = numeral›*) Neg_def (*‹Neg ?n = - Pos ?n›*) numeral_BitM (*‹numeral (Num.BitM ?n) = numeral (num.Bit0 ?n) - 1›*)) (*discuss goal 2*) apply (simp only: sub_def (*‹sub ?m ?n = numeral ?m - numeral ?n›*) dup_def (*‹dup ?k = ?k + ?k›*) numeral.simps (*‹Numeral1 = 1› ‹numeral (num.Bit0 ?n) = numeral ?n + numeral ?n› ‹numeral (num.Bit1 ?n) = numeral ?n + numeral ?n + 1›*) Pos_def (*‹Pos = numeral›*) Neg_def (*‹Neg ?n = - Pos ?n›*) numeral_BitM (*‹numeral (Num.BitM ?n) = numeral (num.Bit0 ?n) - 1›*)) (*discuss goal 3*) apply (simp only: sub_def (*‹sub ?m ?n = numeral ?m - numeral ?n›*) dup_def (*‹dup ?k = ?k + ?k›*) numeral.simps (*‹Numeral1 = 1› ‹numeral (num.Bit0 ?n) = numeral ?n + numeral ?n› ‹numeral (num.Bit1 ?n) = numeral ?n + numeral ?n + 1›*) Pos_def (*‹Pos = numeral›*) Neg_def (*‹Neg ?n = - Pos ?n›*) numeral_BitM (*‹numeral (Num.BitM ?n) = numeral (num.Bit0 ?n) - 1›*)) (*discuss goal 4*) apply (simp only: sub_def (*‹sub (?m::num) (?n::num) = numeral ?m - numeral ?n›*) dup_def (*‹dup (?k::int) = ?k + ?k›*) numeral.simps (*‹Numeral1 = (1::?'a)› ‹numeral (num.Bit0 (?n::num)) = numeral ?n + numeral ?n› ‹numeral (num.Bit1 (?n::num)) = numeral ?n + numeral ?n + (1::?'a)›*) Pos_def (*‹Pos = numeral›*) Neg_def (*‹Neg (?n::num) = - Pos ?n›*) numeral_BitM (*‹numeral (Num.BitM (?n::num)) = numeral (num.Bit0 ?n) - (1::?'a)›*)) (*discuss goal 5*) apply (simp only: sub_def (*‹sub (?m::num) (?n::num) = numeral ?m - numeral ?n›*) dup_def (*‹dup (?k::int) = ?k + ?k›*) numeral.simps (*‹Numeral1 = (1::?'a::numeral)› ‹numeral (num.Bit0 (?n::num)) = numeral ?n + numeral ?n› ‹numeral (num.Bit1 (?n::num)) = numeral ?n + numeral ?n + (1::?'a::numeral)›*) Pos_def (*‹Pos = numeral›*) Neg_def (*‹Neg (?n::num) = - Pos ?n›*) numeral_BitM (*‹numeral (Num.BitM (?n::num)) = numeral (num.Bit0 ?n) - (1::?'a::neg_numeral)›*)) (*discuss goal 6*) apply (simp only: sub_def (*‹sub ?m ?n = numeral ?m - numeral ?n›*) dup_def (*‹dup ?k = ?k + ?k›*) numeral.simps (*‹Numeral1 = 1› ‹numeral (num.Bit0 ?n) = numeral ?n + numeral ?n› ‹numeral (num.Bit1 ?n) = numeral ?n + numeral ?n + 1›*) Pos_def (*‹Pos = numeral›*) Neg_def (*‹Neg ?n = - Pos ?n›*) numeral_BitM (*‹numeral (Num.BitM ?n) = numeral (num.Bit0 ?n) - 1›*)) (*discuss goal 7*) apply (simp only: sub_def (*‹sub ?m ?n = numeral ?m - numeral ?n›*) dup_def (*‹dup ?k = ?k + ?k›*) numeral.simps (*‹Numeral1 = 1› ‹numeral (num.Bit0 ?n) = numeral ?n + numeral ?n› ‹numeral (num.Bit1 ?n) = numeral ?n + numeral ?n + 1›*) Pos_def (*‹Pos = numeral›*) Neg_def (*‹Neg ?n = - Pos ?n›*) numeral_BitM (*‹numeral (Num.BitM ?n) = numeral (num.Bit0 ?n) - 1›*)) (*discuss goal 8*) apply (simp only: sub_def (*‹sub (?m::num) (?n::num) = numeral ?m - numeral ?n›*) dup_def (*‹dup (?k::int) = ?k + ?k›*) numeral.simps (*‹Numeral1 = (1::?'a::numeral)› ‹numeral (num.Bit0 (?n::num)) = numeral ?n + numeral ?n› ‹numeral (num.Bit1 (?n::num)) = numeral ?n + numeral ?n + (1::?'a::numeral)›*) Pos_def (*‹Pos = numeral›*) Neg_def (*‹Neg (?n::num) = - Pos ?n›*) numeral_BitM (*‹numeral (Num.BitM (?n::num)) = numeral (num.Bit0 ?n) - (1::?'a::neg_numeral)›*)) (*discuss goal 9*) apply (simp only: sub_def (*‹sub ?m ?n = numeral ?m - numeral ?n›*) dup_def (*‹dup ?k = ?k + ?k›*) numeral.simps (*‹Numeral1 = 1› ‹numeral (num.Bit0 ?n) = numeral ?n + numeral ?n› ‹numeral (num.Bit1 ?n) = numeral ?n + numeral ?n + 1›*) Pos_def (*‹Pos = numeral›*) Neg_def (*‹Neg ?n = - Pos ?n›*) numeral_BitM (*‹numeral (Num.BitM ?n) = numeral (num.Bit0 ?n) - 1›*)) (*proven 9 subgoals*) . lemma sub_BitM_One_eq: ‹(Num.sub (Num.BitM n) num.One) = 2 * (Num.sub n Num.One :: int)› apply (cases n) (*goals: 1. ‹n = num.One ⟹ neg_numeral_class.sub (Num.BitM n) num.One = 2 * neg_numeral_class.sub n num.One› 2. ‹⋀x2. n = num.Bit0 x2 ⟹ neg_numeral_class.sub (Num.BitM n) num.One = 2 * neg_numeral_class.sub n num.One› 3. ‹⋀x3. n = num.Bit1 x3 ⟹ neg_numeral_class.sub (Num.BitM n) num.One = 2 * neg_numeral_class.sub n num.One› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*discuss goal 3*) apply simp (*proven 3 subgoals*) . text ‹Implementations.› lemma one_int_code [code]: "1 = Pos Num.One" by simp lemma plus_int_code [code]: "k + 0 = k" "0 + l = l" "Pos m + Pos n = Pos (m + n)" "Pos m + Neg n = sub m n" "Neg m + Pos n = sub n m" "Neg m + Neg n = Neg (m + n)" for k l :: int (*goals: 1. ‹k + 0 = k› 2. ‹0 + l = l› 3. ‹Pos m + Pos n = Pos (m + n)› 4. ‹Pos m + Neg n = sub m n› 5. ‹Neg m + Pos n = sub n m› 6. ‹Neg m + Neg n = Neg (m + 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 (*discuss goal 6*) apply simp (*proven 6 subgoals*) . lemma uminus_int_code [code]: "uminus 0 = (0::int)" "uminus (Pos m) = Neg m" "uminus (Neg m) = Pos m" (*goals: 1. ‹- 0 = 0› 2. ‹- Pos m = Neg m› 3. ‹- Neg m = Pos m› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*discuss goal 3*) apply simp (*proven 3 subgoals*) . lemma minus_int_code [code]: "k - 0 = k" "0 - l = uminus l" "Pos m - Pos n = sub m n" "Pos m - Neg n = Pos (m + n)" "Neg m - Pos n = Neg (m + n)" "Neg m - Neg n = sub n m" for k l :: int (*goals: 1. ‹(k::int) - (0::int) = k› 2. ‹(0::int) - (l::int) = - l› 3. ‹Pos (m::num) - Pos (n::num) = sub m n› 4. ‹Pos (m::num) - Neg (n::num) = Pos (m + n)› 5. ‹Neg (m::num) - Pos (n::num) = Neg (m + n)› 6. ‹Neg (m::num) - Neg (n::num) = sub n m› 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*) . lemma times_int_code [code]: "k * 0 = 0" "0 * l = 0" "Pos m * Pos n = Pos (m * n)" "Pos m * Neg n = Neg (m * n)" "Neg m * Pos n = Neg (m * n)" "Neg m * Neg n = Pos (m * n)" for k l :: int (*goals: 1. ‹k * 0 = 0› 2. ‹0 * l = 0› 3. ‹Pos m * Pos n = Pos (m * n)› 4. ‹Pos m * Neg n = Neg (m * n)› 5. ‹Neg m * Pos n = Neg (m * n)› 6. ‹Neg m * Neg n = Pos (m * 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 (*discuss goal 6*) apply simp (*proven 6 subgoals*) . instantiation int :: equal begin definition "HOL.equal k l ⟷ k = (l::int)" instance by standard (rule equal_int_def) end lemma equal_int_code [code]: "HOL.equal 0 (0::int) ⟷ True" "HOL.equal 0 (Pos l) ⟷ False" "HOL.equal 0 (Neg l) ⟷ False" "HOL.equal (Pos k) 0 ⟷ False" "HOL.equal (Pos k) (Pos l) ⟷ HOL.equal k l" "HOL.equal (Pos k) (Neg l) ⟷ False" "HOL.equal (Neg k) 0 ⟷ False" "HOL.equal (Neg k) (Pos l) ⟷ False" "HOL.equal (Neg k) (Neg l) ⟷ HOL.equal k l" (*goals: 1. ‹equal_class.equal 0 0 = True› 2. ‹equal_class.equal 0 (Pos l) = False› 3. ‹equal_class.equal 0 (Neg l) = False› 4. ‹equal_class.equal (Pos k) 0 = False› 5. ‹equal_class.equal (Pos k) (Pos l) = equal_class.equal k l› 6. ‹equal_class.equal (Pos k) (Neg l) = False› 7. ‹equal_class.equal (Neg k) 0 = False› 8. ‹equal_class.equal (Neg k) (Pos l) = False› 9. ‹equal_class.equal (Neg k) (Neg l) = equal_class.equal k l› discuss goal 1*) apply ((auto simp add: equal (*‹equal_class.equal = (=)›*))[1]) (*discuss goal 2*) apply ((auto simp add: equal (*‹equal_class.equal = (=)›*))[1]) (*discuss goal 3*) apply ((auto simp add: equal (*‹equal_class.equal = (=)›*))[1]) (*discuss goal 4*) apply ((auto simp add: equal (*‹equal_class.equal = (=)›*))[1]) (*discuss goal 5*) apply ((auto simp add: equal (*‹equal_class.equal = (=)›*))[1]) (*discuss goal 6*) apply ((auto simp add: equal (*‹equal_class.equal = (=)›*))[1]) (*discuss goal 7*) apply ((auto simp add: equal (*‹equal_class.equal = (=)›*))[1]) (*discuss goal 8*) apply ((auto simp add: equal (*‹equal_class.equal = (=)›*))[1]) (*discuss goal 9*) apply ((auto simp add: equal (*‹equal_class.equal = (=)›*))[1]) (*proven 9 subgoals*) . lemma equal_int_refl [code nbe]: "HOL.equal k k ⟷ True" for k :: int by (fact equal_refl (*‹equal_class.equal (?x::?'a::equal) ?x = True›*)) lemma less_eq_int_code [code]: "0 ≤ (0::int) ⟷ True" "0 ≤ Pos l ⟷ True" "0 ≤ Neg l ⟷ False" "Pos k ≤ 0 ⟷ False" "Pos k ≤ Pos l ⟷ k ≤ l" "Pos k ≤ Neg l ⟷ False" "Neg k ≤ 0 ⟷ True" "Neg k ≤ Pos l ⟷ True" "Neg k ≤ Neg l ⟷ l ≤ k" (*goals: 1. ‹(0 ≤ 0) = True› 2. ‹(0 ≤ Pos l) = True› 3. ‹(0 ≤ Neg l) = False› 4. ‹(Pos k ≤ 0) = False› 5. ‹(Pos k ≤ Pos l) = (k ≤ l)› 6. ‹(Pos k ≤ Neg l) = False› 7. ‹(Neg k ≤ 0) = True› 8. ‹(Neg k ≤ Pos l) = True› 9. ‹(Neg k ≤ Neg l) = (l ≤ k)› 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 (*proven 9 subgoals*) . lemma less_int_code [code]: "0 < (0::int) ⟷ False" "0 < Pos l ⟷ True" "0 < Neg l ⟷ False" "Pos k < 0 ⟷ False" "Pos k < Pos l ⟷ k < l" "Pos k < Neg l ⟷ False" "Neg k < 0 ⟷ True" "Neg k < Pos l ⟷ True" "Neg k < Neg l ⟷ l < k" (*goals: 1. ‹(0 < 0) = False› 2. ‹(0 < Pos l) = True› 3. ‹(0 < Neg l) = False› 4. ‹(Pos k < 0) = False› 5. ‹(Pos k < Pos l) = (k < l)› 6. ‹(Pos k < Neg l) = False› 7. ‹(Neg k < 0) = True› 8. ‹(Neg k < Pos l) = True› 9. ‹(Neg k < Neg l) = (l < k)› 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 (*proven 9 subgoals*) . lemma nat_code [code]: "nat (Int.Neg k) = 0" "nat 0 = 0" "nat (Int.Pos k) = nat_of_num k" (*goals: 1. ‹nat (Neg (k::num)) = (0::nat)› 2. ‹nat (0::int) = (0::nat)› 3. ‹nat (Pos (k::num)) = nat_of_num k› discuss goal 1*) apply (simp add: nat_of_num_numeral (*‹nat_of_num = numeral›*)) (*discuss goal 2*) apply (simp add: nat_of_num_numeral (*‹nat_of_num = numeral›*)) (*discuss goal 3*) apply (simp add: nat_of_num_numeral (*‹nat_of_num = numeral›*)) (*proven 3 subgoals*) . lemma (in ring_1) of_int_code [code]: "of_int (Int.Neg k) = - numeral k" "of_int 0 = 0" "of_int (Int.Pos k) = numeral k" (*goals: 1. ‹of_int (Neg k) = - numeral k› 2. ‹of_int 0 = 0› 3. ‹of_int (Pos k) = numeral k› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*discuss goal 3*) apply simp (*proven 3 subgoals*) . text ‹Serializer setup.› code_identifier code_module Int ⇀ (SML) Arith and (OCaml) Arith and (Haskell) Arith quickcheck_params [default_type = int] hide_const (open) Pos Neg sub dup text ‹De-register ‹int› as a quotient type:› lifting_update int.lifting lifting_forget int.lifting subsection ‹Duplicates› lemmas int_sum = of_nat_sum [where 'a=int] lemmas int_prod = of_nat_prod [where 'a=int] lemmas zle_int = of_nat_le_iff [where 'a=int] lemmas int_int_eq = of_nat_eq_iff [where 'a=int] lemmas nonneg_eq_int = nonneg_int_cases lemmas double_eq_0_iff = double_zero lemmas int_distrib = distrib_right [of z1 z2 w] distrib_left [of w z1 z2] left_diff_distrib [of z1 z2 w] right_diff_distrib [of w z1 z2] for z1 z2 w :: int end
{ "path": "Isabelle2024/src/HOL/Int.thy", "repo": "Isabelle2024", "sha": "755ba7a1a30108f02b17618142a8cb1e6ba95d1df4f1d05d564398483aa17334" }
theory More_Missing_Multiset imports "HOL-Combinatorics.Permutations" Polynomial_Factorization.Missing_Multiset begin lemma rel_mset_free: assumes rel: "rel_mset rel X Y" and xs: "mset xs = X" shows "∃ys. mset ys = Y ∧ list_all2 rel xs ys" proof (-) (*goal: ‹∃ys. mset ys = Y ∧ list_all2 rel xs ys›*) from rel[unfolded rel_mset_def] (*‹∃xs ys. mset xs = X ∧ mset ys = Y ∧ list_all2 rel xs ys›*) obtain xs' and ys' where xs': "mset xs' = X" and ys': "mset ys' = Y" and xsys': "list_all2 rel xs' ys'" (*goal: ‹(⋀(xs'::'a::type list) ys'::'b::type list. ⟦mset xs' = (X::'a::type multiset); mset ys' = (Y::'b::type multiset); list_all2 (rel::'a::type ⇒ 'b::type ⇒ bool) xs' ys'⟧ ⟹ thesis::bool) ⟹ thesis›*) by auto from xs' (*‹mset xs' = X›*) xs (*‹mset xs = X›*) have "mset xs = mset xs'" by auto from mset_eq_permutation[OF this] (*‹(⋀p. ⟦p permutes {..<length xs'}; permute_list p xs' = xs⟧ ⟹ ?thesis) ⟹ ?thesis›*) obtain f where perm: "f permutes {..<length xs'}" and xs': "permute_list f xs' = xs" (*goal: ‹(⋀f. ⟦f permutes {..<length xs'}; permute_list f xs' = xs⟧ ⟹ thesis) ⟹ thesis›*) . then have [simp]: "length xs' = length xs" by auto from permute_list_nth[OF perm, unfolded xs'] (*‹?i < length xs' ⟹ xs ! ?i = xs' ! f ?i›*) have "*": "⋀i. i < length xs ⟹ xs ! i = xs' ! f i" by auto note [simp] = list_all2_lengthD[OF xsys', symmetric] (*‹length ys' = length xs'›*) note [simp] = atLeast0LessThan[symmetric] (*‹{..<?n} = {0..<?n}›*) note bij = permutes_bij[OF perm] (*‹bij f›*) define ys where "ys ≡ map (nth ys' ∘ f) [0..<length ys']" then have [simp]: "length ys = length ys'" by auto have "mset ys = mset (map (nth ys') (map f [0..<length ys']))" unfolding ys_def (*goal: ‹mset (map ((!) (ys'::'b list) ∘ (f::nat ⇒ nat)) [0::nat..<length ys']) = mset (map ((!) ys') (map f [0::nat..<length ys']))›*) by auto also (*calculation: ‹mset ys = mset (map ((!) ys') (map f [0..<length ys']))›*) have "... = image_mset (nth ys') (image_mset f (mset [0..<length ys']))" by (simp add: multiset.map_comp (*‹image_mset ?g (image_mset ?f ?v) = image_mset (?g ∘ ?f) ?v›*)) also (*calculation: ‹mset ys = image_mset ((!) ys') (image_mset f (mset [0..<length ys']))›*) have "(mset [0..<length ys']) = mset_set {0..<length ys'}" by (metis mset_sorted_list_of_multiset (*‹mset (sorted_list_of_multiset (?M::?'a multiset)) = ?M›*) sorted_list_of_mset_set (*‹sorted_list_of_multiset (mset_set (?A::?'a set)) = sorted_list_of_set ?A›*) sorted_list_of_set_range (*‹sorted_list_of_set {?m::nat..<?n::nat} = [?m..<?n]›*)) also (*calculation: ‹mset ys = image_mset ((!) ys') (image_mset f (mset_set {0..<length ys'}))›*) have "image_mset f (...) = mset_set (f ` {..<length ys'})" using subset_inj_on[OF bij_is_inj [ OF bij ]] (*‹(?A::nat set) ⊆ UNIV ⟹ inj_on (f::nat ⇒ nat) ?A›*) apply (subst image_mset_mset_set (*‹inj_on ?f ?A ⟹ image_mset ?f (mset_set ?A) = mset_set (?f ` ?A)›*)) (*goals: 1. ‹(⋀A::nat set. A ⊆ UNIV ⟹ inj_on (f::nat ⇒ nat) A) ⟹ inj_on f {0::nat..<length (ys'::'b list)}› 2. ‹(⋀A::nat set. A ⊆ UNIV ⟹ inj_on (f::nat ⇒ nat) A) ⟹ mset_set (f ` {0::nat..<length (ys'::'b list)}) = mset_set (f ` {..<length ys'})› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . also (*calculation: ‹mset ys = image_mset ((!) ys') (mset_set (f ` {..<length ys'}))›*) have "... = mset [0..<length ys']" using perm (*‹f permutes {..<length xs'}›*) by (simp add: permutes_image (*‹?p permutes ?S ⟹ ?p ` ?S = ?S›*)) also (*calculation: ‹mset ys = image_mset ((!) ys') (mset [0..<length ys'])›*) have "image_mset (nth ys') ... = mset ys'" apply (fold mset_map) (*goal: ‹image_mset ((!) ys') (mset [0..<length ys']) = mset ys'›*) apply (unfold map_nth (*‹map ((!) ?xs) [0..<length ?xs] = ?xs›*)) (*goal: ‹mset (map ((!) ys') [0..<length ys']) = mset ys'›*) by auto finally (*calculation: ‹mset ys = mset ys'›*) have "mset ys = Y" using ys' (*‹mset (ys'::'b::type list) = (Y::'b::type multiset)›*) by auto moreover have "list_all2 rel xs ys" 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 xs = length ys› 2. ‹⋀n. n < length xs ⟹ rel (xs ! n) (ys ! n)›*) fix i assume i: "i < length xs" (*‹(i::nat) < length (xs::'a list)›*) with "*" (*‹?i < length xs ⟹ xs ! ?i = xs' ! f ?i›*) have "xs ! i = xs' ! f i" by auto also (*calculation: ‹xs ! i = xs' ! f i›*) from i (*‹i < length xs›*) permutes_in_image[OF perm] (*‹(f ?x ∈ {..<length xs'}) = (?x ∈ {..<length xs'})›*) have "rel (xs' ! f i) (ys' ! f i)" apply (intro list_all2_nthD[OF xsys'] (*‹?p < length xs' ⟹ rel (xs' ! ?p) (ys' ! ?p)›*)) (*goal: ‹rel (xs' ! f i) (ys' ! f i)›*) by auto finally (*calculation: ‹rel (xs ! i) (ys' ! f i)›*) show "rel (xs ! i) (ys ! i)" unfolding ys_def (*goal: ‹(rel::'a::type ⇒ 'b::type ⇒ bool) ((xs::'a::type list) ! (i::nat)) (map ((!) (ys'::'b::type list) ∘ (f::nat ⇒ nat)) [0::nat..<length ys'] ! i)›*) using i (*‹i < length xs›*) by simp qed (simp) (*solved the remaining goal: ‹length (xs::'a list) = length (ys::'b list)›*) ultimately show "?thesis" (*goal: ‹∃ys. mset ys = Y ∧ list_all2 rel xs ys›*) by auto qed lemma rel_mset_split: assumes rel: "rel_mset rel (X1+X2) Y" shows "∃Y1 Y2. Y = Y1 + Y2 ∧ rel_mset rel X1 Y1 ∧ rel_mset rel X2 Y2" proof (-) (*goal: ‹∃Y1 Y2. Y = Y1 + Y2 ∧ rel_mset rel X1 Y1 ∧ rel_mset rel X2 Y2›*) obtain xs1 where xs1: "mset xs1 = X1" (*goal: ‹(⋀xs1. mset xs1 = X1 ⟹ thesis) ⟹ thesis›*) using ex_mset (*‹∃xs. mset xs = ?X›*) by auto obtain xs2 where xs2: "mset xs2 = X2" (*goal: ‹(⋀xs2. mset xs2 = X2 ⟹ thesis) ⟹ thesis›*) using ex_mset (*‹∃xs. mset xs = ?X›*) by auto from xs1 (*‹mset xs1 = X1›*) xs2 (*‹mset xs2 = X2›*) have "mset (xs1 @ xs2) = X1 + X2" by auto from rel_mset_free[OF rel this] (*‹∃ys. mset ys = Y ∧ list_all2 rel (xs1 @ xs2) ys›*) obtain ys where ys: "mset ys = Y" "list_all2 rel (xs1 @ xs2) ys" (*goal: ‹(⋀ys. ⟦mset ys = Y; list_all2 rel (xs1 @ xs2) ys⟧ ⟹ thesis) ⟹ thesis›*) by auto then obtain ys1 and ys2 where ys12: "ys = ys1 @ ys2" and xs1ys1: "list_all2 rel xs1 ys1" and xs2ys2: "list_all2 rel xs2 ys2" (*goal: ‹(⋀ys1 ys2. ⟦ys = ys1 @ ys2; list_all2 rel xs1 ys1; list_all2 rel xs2 ys2⟧ ⟹ thesis) ⟹ thesis›*) using list_all2_append1 (*‹list_all2 (?P::?'a ⇒ ?'b ⇒ bool) ((?xs::?'a list) @ (?ys::?'a list)) (?zs::?'b list) = (∃(us::?'b list) vs::?'b list. ?zs = us @ vs ∧ length us = length ?xs ∧ length vs = length ?ys ∧ list_all2 ?P ?xs us ∧ list_all2 ?P ?ys vs)›*) by blast from ys12 (*‹ys = ys1 @ ys2›*) ys (*‹mset ys = Y› ‹list_all2 rel (xs1 @ xs2) ys›*) have "Y = mset ys1 + mset ys2" by auto moreover from xs1 (*‹mset xs1 = X1›*) xs1ys1 (*‹list_all2 rel xs1 ys1›*) have "rel_mset rel X1 (mset ys1)" unfolding rel_mset_def (*goal: ‹∃xs ys. mset xs = X1 ∧ mset ys = mset ys1 ∧ list_all2 rel xs ys›*) by auto moreover from xs2 (*‹mset (xs2::'a list) = (X2::'a multiset)›*) xs2ys2 (*‹list_all2 rel xs2 ys2›*) have "rel_mset rel X2 (mset ys2)" unfolding rel_mset_def (*goal: ‹∃xs ys. mset xs = X2 ∧ mset ys = mset ys2 ∧ list_all2 rel xs ys›*) by auto ultimately show "?thesis" (*goal: ‹∃Y1 Y2. Y = Y1 + Y2 ∧ rel_mset rel X1 Y1 ∧ rel_mset rel X2 Y2›*) apply (subst exI[of _ "mset ys1"] (*‹?P (mset ys1) ⟹ ∃x. ?P x›*)) (*goals: 1. ‹⟦Y = mset ys1 + mset ys2; rel_mset rel X1 (mset ys1); rel_mset rel X2 (mset ys2)⟧ ⟹ ∃Y2. Y = mset ys1 + Y2 ∧ rel_mset rel X1 (mset ys1) ∧ rel_mset rel X2 Y2› 2. ‹⟦Y = mset ys1 + mset ys2; rel_mset rel X1 (mset ys1); rel_mset rel X2 (mset ys2)⟧ ⟹ True› discuss goal 1*) apply (subst exI[of _ "mset ys2"] (*‹?P (mset ys2) ⟹ ∃x. ?P x›*)) (*goals: 1. ‹⟦(Y::'b multiset) = mset (ys1::'b list) + mset (ys2::'b list); rel_mset (rel::'a ⇒ 'b ⇒ bool) (X1::'a multiset) (mset ys1); rel_mset rel (X2::'a multiset) (mset ys2)⟧ ⟹ Y = mset ys1 + mset ys2 ∧ rel_mset rel X1 (mset ys1) ∧ rel_mset rel X2 (mset ys2)› 2. ‹⟦(Y::'b multiset) = mset (ys1::'b list) + mset (ys2::'b list); rel_mset (rel::'a ⇒ 'b ⇒ bool) (X1::'a multiset) (mset ys1); rel_mset rel (X2::'a multiset) (mset ys2)⟧ ⟹ True› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . qed lemma rel_mset_OO: assumes AB: "rel_mset R A B" and BC: "rel_mset S B C" shows "rel_mset (R OO S) A C" proof (-) (*goal: ‹rel_mset (R OO S) A C›*) from AB (*‹rel_mset R A B›*) obtain as and bs where A_as: "A = mset as" and B_bs: "B = mset bs" and as_bs: "list_all2 R as bs" (*goal: ‹(⋀as bs. ⟦A = mset as; B = mset bs; list_all2 R as bs⟧ ⟹ thesis) ⟹ thesis›*) by (auto simp: rel_mset_def (*‹rel_mset ?R ?X ?Y = (∃xs ys. mset xs = ?X ∧ mset ys = ?Y ∧ list_all2 ?R xs ys)›*)) from rel_mset_free[OF BC] (*‹mset (?xs::'b list) = (B::'b multiset) ⟹ ∃ys::'c list. mset ys = (C::'c multiset) ∧ list_all2 (S::'b ⇒ 'c ⇒ bool) ?xs ys›*) B_bs (*‹B = mset bs›*) obtain cs where C_cs: "C = mset cs" and bs_cs: "list_all2 S bs cs" (*goal: ‹(⋀cs. ⟦C = mset cs; list_all2 S bs cs⟧ ⟹ thesis) ⟹ thesis›*) by auto from list_all2_trans[OF _ as_bs bs_cs, of "R OO S"] (*‹(⋀a b c. ⟦R a b; S b c⟧ ⟹ (R OO S) a c) ⟹ list_all2 (R OO S) as cs›*) A_as (*‹(A::'a multiset) = mset (as::'a list)›*) C_cs (*‹C = mset cs›*) show "?thesis" (*goal: ‹rel_mset (R OO S) A C›*) by (auto simp: rel_mset_def (*‹rel_mset ?R ?X ?Y = (∃xs ys. mset xs = ?X ∧ mset ys = ?Y ∧ list_all2 ?R xs ys)›*)) qed (* a variant for "right" *) lemma ex_mset_zip_right: assumes "length xs = length ys" "mset ys' = mset ys" shows "∃xs'. length ys' = length xs' ∧ mset (zip xs' ys') = mset (zip xs ys)" sorry lemma list_all2_reorder_right_invariance: assumes rel: "list_all2 R xs ys" and ms_y: "mset ys' = mset ys" shows "∃xs'. list_all2 R xs' ys' ∧ mset xs' = mset xs" proof (-) (*goal: ‹∃xs'. list_all2 R xs' ys' ∧ mset xs' = mset xs›*) have len: "length xs = length ys" using rel (*‹list_all2 R xs ys›*) list_all2_conv_all_nth (*‹list_all2 ?P ?xs ?ys = (length ?xs = length ?ys ∧ (∀i<length ?xs. ?P (?xs ! i) (?ys ! i)))›*) by auto obtain xs' where len': "length xs' = length ys'" and ms_xy: "mset (zip xs' ys') = mset (zip xs ys)" (*goal: ‹(⋀xs'::'a::type list. ⟦length xs' = length (ys'::'b::type list); mset (zip xs' ys') = mset (zip (xs::'a::type list) (ys::'b::type list))⟧ ⟹ thesis::bool) ⟹ thesis›*) using len (*‹length (xs::'a list) = length (ys::'b list)›*) ms_y (*‹mset ys' = mset ys›*) by (metis ex_mset_zip_right (*‹⟦length (?xs::?'a list) = length (?ys::?'b list); mset (?ys'::?'b list) = mset ?ys⟧ ⟹ ∃xs'::?'a list. length ?ys' = length xs' ∧ mset (zip xs' ?ys') = mset (zip ?xs ?ys)›*)) have "list_all2 R xs' ys'" using assms(1) (*‹list_all2 R xs ys›*) len' (*‹length xs' = length ys'›*) ms_xy (*‹mset (zip xs' ys') = mset (zip xs ys)›*) unfolding list_all2_iff (*goal: ‹length xs' = length ys' ∧ (∀(x, y)∈set (zip xs' ys'). R x y)›*) by (blast dest: mset_eq_setD (*‹mset ?xs = mset ?ys ⟹ set ?xs = set ?ys›*)) moreover have "mset xs' = mset xs" using len (*‹length xs = length ys›*) len' (*‹length xs' = length ys'›*) ms_xy (*‹mset (zip xs' ys') = mset (zip xs ys)›*) map_fst_zip (*‹length ?xs = length ?ys ⟹ map fst (zip ?xs ?ys) = ?xs›*) mset_map (*‹mset (map ?f ?xs) = image_mset ?f (mset ?xs)›*) by metis ultimately show "?thesis" (*goal: ‹∃xs'::'a::type list. list_all2 (R::'a::type ⇒ 'b::type ⇒ bool) xs' (ys'::'b::type list) ∧ mset xs' = mset (xs::'a::type list)›*) by blast qed lemma rel_mset_via_perm: "rel_mset rel (mset xs) (mset ys) ⟷ (∃zs. mset xs = mset zs ∧ list_all2 rel zs ys)" proof (unfold rel_mset_def (*‹rel_mset (?R::?'a ⇒ ?'b ⇒ bool) (?X::?'a multiset) (?Y::?'b multiset) = (∃(xs::?'a list) ys::?'b list. mset xs = ?X ∧ mset ys = ?Y ∧ list_all2 ?R xs ys)›*), intro iffI (*‹⟦?P ⟹ ?Q; ?Q ⟹ ?P⟧ ⟹ ?P = ?Q›*), goal_cases) (*goals: 1. ‹∃xsa ysa. mset xsa = mset xs ∧ mset ysa = mset ys ∧ list_all2 rel xsa ysa ⟹ ∃zs. mset xs = mset zs ∧ list_all2 rel zs ys› 2. ‹∃zs. mset xs = mset zs ∧ list_all2 rel zs ys ⟹ ∃xsa ysa. mset xsa = mset xs ∧ mset ysa = mset ys ∧ list_all2 rel xsa ysa›*) case 1 (*‹∃xsa ysa. mset xsa = mset xs ∧ mset ysa = mset ys ∧ list_all2 rel xsa ysa›*) then obtain zs and ws where zs: "mset zs = mset xs" and ws: "mset ws = mset ys" and zsws: "list_all2 rel zs ws" (*goal: ‹(⋀zs ws. ⟦mset zs = mset xs; mset ws = mset ys; list_all2 rel zs ws⟧ ⟹ thesis) ⟹ thesis›*) by auto note list_all2_reorder_right_invariance[OF zsws ws [ symmetric ], unfolded zs] (*‹∃xs'. list_all2 rel xs' ys ∧ mset xs' = mset xs›*) then show "?case" (*goal: ‹∃zs. mset xs = mset zs ∧ list_all2 rel zs ys›*) by (auto dest: sym (*‹?s = ?t ⟹ ?t = ?s›*)) next (*goal: ‹∃zs. mset xs = mset zs ∧ list_all2 rel zs ys ⟹ ∃xsa ysa. mset xsa = mset xs ∧ mset ysa = mset ys ∧ list_all2 rel xsa ysa›*) case 2 (*‹∃zs. mset xs = mset zs ∧ list_all2 rel zs ys›*) from this (*‹∃zs. mset xs = mset zs ∧ list_all2 rel zs ys›*) show "?case" (*goal: ‹∃xsa ysa. mset xsa = mset xs ∧ mset ysa = mset ys ∧ list_all2 rel xsa ysa›*) by force qed end
{ "path": "afp-2025-02-12/thys/Berlekamp_Zassenhaus/More_Missing_Multiset.thy", "repo": "afp-2025-02-12", "sha": "80d40e0b45d7b21db2511a8b84671ef93caef8f636e32f3900859fb04ab0270d" }
section ‹Functions› theory Functions imports "../Extensions/Set_Extensions" begin locale bounded_function = fixes A :: "'a set" fixes B :: "'b set" fixes f :: "'a ⇒ 'b" assumes wellformed[intro?, simp]: "x ∈ A ⟹ f x ∈ B" locale bounded_function_pair = f: bounded_function A B f + g: bounded_function B A g for A :: "'a set" and B :: "'b set" and f :: "'a ⇒ 'b" and g :: "'b ⇒ 'a" locale injection = bounded_function_pair + assumes left_inverse[simp]: "x ∈ A ⟹ g (f x) = x" begin lemma inj_on[intro]: "inj_on f A" using inj_onI (*‹(⋀(x::?'a) y::?'a. ⟦x ∈ (?A::?'a set); y ∈ ?A; (?f::?'a ⇒ ?'b) x = ?f y⟧ ⟹ x = y) ⟹ inj_on ?f ?A›*) left_inverse (*‹?x ∈ A ⟹ g (f ?x) = ?x›*) by metis lemma injective_on: assumes "x ∈ A" "y ∈ A" "f x = f y" shows "x = y" using assms (*‹x ∈ A› ‹y ∈ A› ‹f x = f y›*) left_inverse (*‹?x ∈ A ⟹ g (f ?x) = ?x›*) by metis end locale injective = bounded_function + assumes injection: "∃ g. injection A B f g" begin definition "g ≡ SOME g. injection A B f g" sublocale injection A B f g unfolding g_def (*goal: ‹injection A B f (SOME g. injection A B f g)›*) using someI_ex[OF injection] (*‹injection A B f (SOME x. injection A B f x)›*) by this end locale surjection = bounded_function_pair + assumes right_inverse[simp]: "y ∈ B ⟹ f (g y) = y" begin lemma image_superset[intro]: "f ` A ⊇ B" using g.wellformed (*‹?x ∈ B ⟹ g ?x ∈ A›*) image_iff (*‹(?z ∈ ?f ` ?A) = (∃x∈?A. ?z = ?f x)›*) right_inverse (*‹?y ∈ B ⟹ f (g ?y) = ?y›*) subsetI (*‹(⋀x. x ∈ ?A ⟹ x ∈ ?B) ⟹ ?A ⊆ ?B›*) by metis lemma image_eq[simp]: "f ` A = B" using image_superset (*‹B ⊆ f ` A›*) by auto end locale surjective = bounded_function + assumes surjection: "∃ g. surjection A B f g" begin definition "g ≡ SOME g. surjection A B f g" sublocale surjection A B f g unfolding g_def (*goal: ‹surjection A B f (SOME g. surjection A B f g)›*) using someI_ex[OF surjection] (*‹surjection (A::'a set) (B::'b set) (f::'a ⇒ 'b) (SOME x::'b ⇒ 'a. surjection A B f x)›*) by this end locale bijection = injection + surjection lemma inj_on_bijection: assumes "inj_on f A" shows "bijection A (f ` A) f (inv_into A f)" proof (standard) (*goals: 1. ‹⋀x::'a. x ∈ (A::'a set) ⟹ (f::'a ⇒ 'b) x ∈ f ` A› 2. ‹⋀x::'b. x ∈ (f::'a ⇒ 'b) ` (A::'a set) ⟹ inv_into A f x ∈ A› 3. ‹⋀x::'a. x ∈ (A::'a set) ⟹ inv_into A (f::'a ⇒ 'b) (f x) = x› 4. ‹⋀y::'b. y ∈ (f::'a ⇒ 'b) ` (A::'a set) ⟹ f (inv_into A f y) = y›*) show "⋀ x. x ∈ A ⟹ f x ∈ f ` A" using imageI (*‹?x ∈ ?A ⟹ ?f ?x ∈ ?f ` ?A›*) by this show "⋀ y. y ∈ f ` A ⟹ inv_into A f y ∈ A" using inv_into_into (*‹?x ∈ ?f ` ?A ⟹ inv_into ?A ?f ?x ∈ ?A›*) by this show "⋀ x. x ∈ A ⟹ inv_into A f (f x) = x" using inv_into_f_f (*‹⟦inj_on ?f ?A; ?x ∈ ?A⟧ ⟹ inv_into ?A ?f (?f ?x) = ?x›*) assms (*‹inj_on f A›*) by this show "⋀ y. y ∈ f ` A ⟹ f (inv_into A f y) = y" using f_inv_into_f (*‹?y ∈ ?f ` ?A ⟹ ?f (inv_into ?A ?f ?y) = ?y›*) by this qed end
{ "path": "afp-2025-02-12/thys/Partial_Order_Reduction/Basics/Functions.thy", "repo": "afp-2025-02-12", "sha": "bed49ed30693fbf9934ce027af0630e325a69997154d38d7be464e366e5958ac" }
theory Weak_Validity imports Weak_Formula Validity begin section ‹Weak Validity› text ‹Weak formulas are a subset of (strong) formulas, and the definition of validity is simply taken from the latter. Here we prove some useful lemmas about the validity of weak modalities. These are similar to corresponding lemmas about the validity of the (strong) action modality.› context indexed_weak_nominal_ts begin lemma valid_weak_tau_modality_iff_tau_steps: "P ⊨ weak_tau_modality x ⟷ (∃n. P ⊨ tau_steps x n)" unfolding weak_tau_modality_def (*goal: ‹P ⊨ Disj (map_bset (tau_steps x) (Abs_bset UNIV)) = (∃n. P ⊨ tau_steps x n)›*) by (auto simp add: map_bset.rep_eq (*‹set_bset (map_bset ?x ?xa) = ?x ` set_bset ?xa›*)) lemma tau_steps_iff_tau_transition: "(∃n. P ⊨ tau_steps x n) ⟷ (∃P'. P ⇒ P' ∧ P' ⊨ x)" proof (standard) (*goals: 1. ‹∃n. P ⊨ tau_steps x n ⟹ ∃P'. P ⇒ P' ∧ P' ⊨ x› 2. ‹∃P'. P ⇒ P' ∧ P' ⊨ x ⟹ ∃n. P ⊨ tau_steps x n›*) assume "∃n. P ⊨ tau_steps x n" (*‹∃n::nat. (P::'state) ⊨ tau_steps (x::('idx, 'pred, 'act) formula) n›*) then obtain n where "P ⊨ tau_steps x n" (*goal: ‹(⋀n. P ⊨ tau_steps x n ⟹ thesis) ⟹ thesis›*) by meson then show "∃P'. P ⇒ P' ∧ P' ⊨ x" proof (induct n arbitrary: P) (*goals: 1. ‹⋀P. P ⊨ tau_steps x 0 ⟹ ∃P'. P ⇒ P' ∧ P' ⊨ x› 2. ‹⋀n P. ⟦⋀P. P ⊨ tau_steps x n ⟹ ∃P'. P ⇒ P' ∧ P' ⊨ x; P ⊨ tau_steps x (Suc n)⟧ ⟹ ∃P'. P ⇒ P' ∧ P' ⊨ x›*) case 0 (*‹P ⊨ tau_steps x 0›*) then show "?case" (*goal: ‹∃P'. P ⇒ P' ∧ P' ⊨ x›*) apply simp (*goal: ‹∃P'. P ⇒ P' ∧ P' ⊨ x›*) by (metis tau_refl (*‹?P ⇒ ?P›*)) next (*goal: ‹⋀n P. ⟦⋀P. P ⊨ tau_steps x n ⟹ ∃P'. P ⇒ P' ∧ P' ⊨ x; P ⊨ tau_steps x (Suc n)⟧ ⟹ ∃P'. P ⇒ P' ∧ P' ⊨ x›*) case (Suc n) (*‹?P7 ⊨ tau_steps x n ⟹ ∃P'. ?P7 ⇒ P' ∧ P' ⊨ x› ‹P ⊨ tau_steps x (Suc n)›*) then obtain P' where "P → ⟨τ, P'⟩" and "P' ⊨ tau_steps x n" (*goal: ‹(⋀P'. ⟦P → ⟨τ,P'⟩; P' ⊨ tau_steps x n⟧ ⟹ thesis) ⟹ thesis›*) by (auto simp add: valid_Act_fresh[OF bn_tau_fresh] (*‹?P ⊨ Act τ ?x = (∃P'. ?P → ⟨τ,P'⟩ ∧ P' ⊨ ?x)›*)) with Suc.hyps (*‹?P7 ⊨ tau_steps x n ⟹ ∃P'. ?P7 ⇒ P' ∧ P' ⊨ x›*) show "?case" (*goal: ‹∃P'. P ⇒ P' ∧ P' ⊨ x›*) using tau_step (*‹⟦?P → ⟨τ,?P'⟩; ?P' ⇒ ?P''⟧ ⟹ ?P ⇒ ?P''›*) by blast qed next (*goal: ‹∃P'. P ⇒ P' ∧ P' ⊨ x ⟹ ∃n. P ⊨ tau_steps x n›*) assume "∃P'. P ⇒ P' ∧ P' ⊨ x" (*‹∃P'::'state. (P::'state) ⇒ P' ∧ P' ⊨ (x::('idx, 'pred, 'act) formula)›*) then obtain P' where "P ⇒ P'" and "P' ⊨ x" (*goal: ‹(⋀P'. ⟦P ⇒ P'; P' ⊨ x⟧ ⟹ thesis) ⟹ thesis›*) by meson then show "∃n. P ⊨ tau_steps x n" proof (induct) (*goals: 1. ‹⋀P. P ⊨ x ⟹ ∃n. P ⊨ tau_steps x n› 2. ‹⋀P P' P''. ⟦P → ⟨τ,P'⟩; P' ⇒ P''; P'' ⊨ x ⟹ ∃n. P' ⊨ tau_steps x n; P'' ⊨ x⟧ ⟹ ∃n. P ⊨ tau_steps x n›*) case (tau_refl P) (*‹P ⊨ x›*) then have "P ⊨ tau_steps x 0" by simp then show "?case" (*goal: ‹∃n. P ⊨ tau_steps x n›*) by meson next (*goal: ‹⋀P P' P''. ⟦P → ⟨τ,P'⟩; P' ⇒ P''; P'' ⊨ x ⟹ ∃n. P' ⊨ tau_steps x n; P'' ⊨ x⟧ ⟹ ∃n. P ⊨ tau_steps x n›*) case (tau_step P P' P'') (*‹P → ⟨τ,P'⟩› ‹P' ⇒ P''› ‹P'' ⊨ x ⟹ ∃n. P' ⊨ tau_steps x n› ‹P'' ⊨ x›*) then obtain n where "P' ⊨ tau_steps x n" (*goal: ‹(⋀n. P' ⊨ tau_steps x n ⟹ thesis) ⟹ thesis›*) by meson with ‹P → ⟨τ,P'⟩› (*‹P → ⟨τ,P'⟩›*) have "P ⊨ tau_steps x (Suc n)" by (auto simp add: valid_Act_fresh[OF bn_tau_fresh] (*‹?P ⊨ Act τ ?x = (∃P'. ?P → ⟨τ,P'⟩ ∧ P' ⊨ ?x)›*)) then show "?case" (*goal: ‹∃n. P ⊨ tau_steps x n›*) by meson qed qed lemma valid_weak_tau_modality: "P ⊨ weak_tau_modality x ⟷ (∃P'. P ⇒ P' ∧ P' ⊨ x)" by (metis valid_weak_tau_modality_iff_tau_steps (*‹?P ⊨ weak_tau_modality ?x = (∃n. ?P ⊨ tau_steps ?x n)›*) tau_steps_iff_tau_transition (*‹(∃n. ?P ⊨ tau_steps ?x n) = (∃P'. ?P ⇒ P' ∧ P' ⊨ ?x)›*)) lemma valid_weak_action_modality: "P ⊨ (⟨⟨α⟩⟩x) ⟷ (∃α' x' P'. Act α x = Act α' x' ∧ P ⇒⟨α'⟩ P' ∧ P' ⊨ x')" (is "?l ⟷ ?r") proof (cases "α = τ") (*goals: 1. ‹α = τ ⟹ P ⊨ ⟨⟨α⟩⟩x = (∃α' x' P'. Act α x = Act α' x' ∧ P ⇒⟨α'⟩ P' ∧ P' ⊨ x')› 2. ‹α ≠ τ ⟹ P ⊨ ⟨⟨α⟩⟩x = (∃α' x' P'. Act α x = Act α' x' ∧ P ⇒⟨α'⟩ P' ∧ P' ⊨ x')›*) case True (*‹α = τ›*) show "?thesis" (*goal: ‹P ⊨ ⟨⟨α⟩⟩x = (∃α' x' P'. Act α x = Act α' x' ∧ P ⇒⟨α'⟩ P' ∧ P' ⊨ x')›*) proof (standard) (*goals: 1. ‹P ⊨ ⟨⟨α⟩⟩x ⟹ ∃α' x' P'. Act α x = Act α' x' ∧ P ⇒⟨α'⟩ P' ∧ P' ⊨ x'› 2. ‹∃α' x' P'. Act α x = Act α' x' ∧ P ⇒⟨α'⟩ P' ∧ P' ⊨ x' ⟹ P ⊨ ⟨⟨α⟩⟩x›*) assume "?l" (*‹(P::'state) ⊨ ⟨⟨α::'act⟩⟩x::('idx, 'pred, 'act) formula›*) with ‹α = τ› (*‹(α::'act::bn) = (τ::'act::bn)›*) obtain P' where trans: "P ⇒ P'" and valid: "P' ⊨ x" (*goal: ‹(⋀P'::'state::fs. ⟦(P::'state::fs) ⇒ P'; P' ⊨ (x::('idx::type, 'pred::fs, 'act::bn) formula)⟧ ⟹ thesis::bool) ⟹ thesis›*) by (metis valid_weak_tau_modality (*‹?P ⊨ weak_tau_modality ?x = (∃P'. ?P ⇒ P' ∧ P' ⊨ ?x)›*) weak_action_modality_tau (*‹⟨⟨τ⟩⟩?x = weak_tau_modality ?x›*)) from trans (*‹P ⇒ P'›*) have "P ⇒⟨τ⟩ P'" by simp with ‹α = τ› (*‹α = τ›*) valid (*‹P' ⊨ x›*) show "?r" by blast next (*goal: ‹∃α' x' P'. Act α x = Act α' x' ∧ P ⇒⟨α'⟩ P' ∧ P' ⊨ x' ⟹ P ⊨ ⟨⟨α⟩⟩x›*) assume "?r" (*‹∃(α'::'act) (x'::('idx, 'pred, 'act) formula) P'::'state. Act (α::'act) (x::('idx, 'pred, 'act) formula) = Act α' x' ∧ (P::'state) ⇒⟨α'⟩ P' ∧ P' ⊨ x'›*) then obtain α' and x' and P' where eq: "Act α x = Act α' x'" and trans: "P ⇒⟨α'⟩ P'" and valid: "P' ⊨ x'" (*goal: ‹(⋀α' x' P'. ⟦Act α x = Act α' x'; P ⇒⟨α'⟩ P'; P' ⊨ x'⟧ ⟹ thesis) ⟹ thesis›*) by blast from eq (*‹Act α x = Act α' x'›*) have "α' = τ ∧ x' = x" using ‹α = τ› (*‹(α::'act) = (τ::'act)›*) by simp with trans (*‹P ⇒⟨α'⟩ P'›*) valid (*‹P' ⊨ x'›*) have "P ⇒ P'" and "P' ⊨ x" apply - (*goals: 1. ‹⟦P ⇒⟨α'⟩ P'; P' ⊨ x'; α' = τ ∧ x' = x⟧ ⟹ P ⇒ P'› 2. ‹⟦P ⇒⟨α'⟩ P'; P' ⊨ x'; α' = τ ∧ x' = x⟧ ⟹ P' ⊨ x› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) . with ‹α = τ› (*‹α = τ›*) show "?l" by (metis valid_weak_tau_modality (*‹?P ⊨ weak_tau_modality ?x = (∃P'. ?P ⇒ P' ∧ P' ⊨ ?x)›*) weak_action_modality_tau (*‹⟨⟨τ⟩⟩?x = weak_tau_modality ?x›*)) qed next (*goal: ‹α ≠ τ ⟹ P ⊨ ⟨⟨α⟩⟩x = (∃α' x' P'. Act α x = Act α' x' ∧ P ⇒⟨α'⟩ P' ∧ P' ⊨ x')›*) case False (*‹α ≠ τ›*) show "?thesis" (*goal: ‹P ⊨ ⟨⟨α⟩⟩x = (∃α' x' P'. Act α x = Act α' x' ∧ P ⇒⟨α'⟩ P' ∧ P' ⊨ x')›*) proof (standard) (*goals: 1. ‹P ⊨ ⟨⟨α⟩⟩x ⟹ ∃α' x' P'. Act α x = Act α' x' ∧ P ⇒⟨α'⟩ P' ∧ P' ⊨ x'› 2. ‹∃α' x' P'. Act α x = Act α' x' ∧ P ⇒⟨α'⟩ P' ∧ P' ⊨ x' ⟹ P ⊨ ⟨⟨α⟩⟩x›*) assume "?l" (*‹(P::'state) ⊨ ⟨⟨α::'act⟩⟩x::('idx, 'pred, 'act) formula›*) with ‹α ≠ τ› (*‹α ≠ τ›*) obtain Q where trans: "P ⇒ Q" and valid: "Q ⊨ Act α (weak_tau_modality x)" (*goal: ‹(⋀Q. ⟦P ⇒ Q; Q ⊨ Act α (weak_tau_modality x)⟧ ⟹ thesis) ⟹ thesis›*) by (metis valid_weak_tau_modality (*‹?P ⊨ weak_tau_modality ?x = (∃P'. ?P ⇒ P' ∧ P' ⊨ ?x)›*) weak_action_modality_not_tau (*‹?α ≠ τ ⟹ ⟨⟨?α⟩⟩?x = weak_tau_modality (Act ?α (weak_tau_modality ?x))›*)) from valid (*‹Q ⊨ Act α (weak_tau_modality x)›*) obtain α' and x' and Q' where eq: "Act α (weak_tau_modality x) = Act α' x'" and trans': "Q → ⟨α',Q'⟩" and valid': "Q' ⊨ x'" (*goal: ‹(⋀α' x' Q'. ⟦Act α (weak_tau_modality x) = Act α' x'; Q → ⟨α',Q'⟩; Q' ⊨ x'⟧ ⟹ thesis) ⟹ thesis›*) by (metis valid_Act (*‹?P ⊨ Act ?α ?x = (∃α' x' P'. Act ?α ?x = Act α' x' ∧ ?P → ⟨α',P'⟩ ∧ P' ⊨ x')›*)) from eq (*‹Act α (weak_tau_modality x) = Act α' x'›*) obtain p where "p_α": "α' = p ∙ α" and p_x: "x' = p ∙ weak_tau_modality x" (*goal: ‹(⋀p. ⟦α' = p ∙ α; x' = p ∙ weak_tau_modality x⟧ ⟹ thesis) ⟹ thesis›*) by (metis Act_eq_iff_perm (*‹(Act ?α1.0 ?x1.0 = Act ?α2.0 ?x2.0) = (∃p. supp ?x1.0 - bn ?α1.0 = supp ?x2.0 - bn ?α2.0 ∧ (supp ?x1.0 - bn ?α1.0) ♯* p ∧ p ∙ ?x1.0 = ?x2.0 ∧ supp ?α1.0 - bn ?α1.0 = supp ?α2.0 - bn ?α2.0 ∧ (supp ?α1.0 - bn ?α1.0) ♯* p ∧ p ∙ ?α1.0 = ?α2.0)›*)) with eq (*‹Act α (weak_tau_modality x) = Act α' x'›*) have "Act α x = Act α' (p ∙ x)" using Act_weak_tau_modality_eq_iff (*‹(Act ?α1.0 (weak_tau_modality ?x1.0) = Act ?α2.0 (weak_tau_modality ?x2.0)) = (Act ?α1.0 ?x1.0 = Act ?α2.0 ?x2.0)›*) by simp moreover from valid' (*‹Q' ⊨ x'›*) p_x (*‹x' = p ∙ weak_tau_modality x›*) have "Q' ⊨ weak_tau_modality (p ∙ x)" by simp then obtain P' where trans'': "Q' ⇒ P'" and valid'': "P' ⊨ p ∙ x" (*goal: ‹(⋀P'. ⟦Q' ⇒ P'; P' ⊨ p ∙ x⟧ ⟹ thesis) ⟹ thesis›*) by (metis valid_weak_tau_modality (*‹?P ⊨ weak_tau_modality ?x = (∃P'. ?P ⇒ P' ∧ P' ⊨ ?x)›*)) from trans (*‹P ⇒ Q›*) trans' (*‹Q → ⟨α',Q'⟩›*) trans'' (*‹Q' ⇒ P'›*) have "P ⇒⟨α'⟩ P'" by (metis observable_transitionI (*‹⟦?P ⇒ ?Q; ?Q → ⟨?α,?Q'⟩; ?Q' ⇒ ?P'⟧ ⟹ ?P ⇒{?α} ?P'›*) weak_transition_stepI (*‹?P ⇒{?α} ?P' ⟹ ?P ⇒⟨?α⟩ ?P'›*)) ultimately show "?r" using valid'' (*‹P' ⊨ p ∙ x›*) by blast next (*goal: ‹∃α' x' P'. Act α x = Act α' x' ∧ P ⇒⟨α'⟩ P' ∧ P' ⊨ x' ⟹ P ⊨ ⟨⟨α⟩⟩x›*) assume "?r" (*‹∃(α'::'act) (x'::('idx, 'pred, 'act) formula) P'::'state. Act (α::'act) (x::('idx, 'pred, 'act) formula) = Act α' x' ∧ (P::'state) ⇒⟨α'⟩ P' ∧ P' ⊨ x'›*) then obtain α' and x' and P' where eq: "Act α x = Act α' x'" and trans: "P ⇒⟨α'⟩ P'" and valid: "P' ⊨ x'" (*goal: ‹(⋀(α'::'act::bn) (x'::('idx::type, 'pred::fs, 'act::bn) formula) P'::'state::fs. ⟦Act (α::'act::bn) (x::('idx::type, 'pred::fs, 'act::bn) formula) = Act α' x'; (P::'state::fs) ⇒⟨α'⟩ P'; P' ⊨ x'⟧ ⟹ thesis::bool) ⟹ thesis›*) by blast with ‹α ≠ τ› (*‹α ≠ τ›*) have "α'": "α' ≠ τ" using eq (*‹Act α x = Act α' x'›*) by (metis Act_tau_eq_iff (*‹(Act τ ?x1.0 = Act ?α ?x2.0) = (?α = τ ∧ ?x2.0 = ?x1.0)›*)) with trans (*‹P ⇒⟨α'⟩ P'›*) obtain Q and Q' where trans': "P ⇒ Q" and trans'': "Q → ⟨α',Q'⟩" and trans''': "Q' ⇒ P'" (*goal: ‹(⋀Q Q'. ⟦P ⇒ Q; Q → ⟨α',Q'⟩; Q' ⇒ P'⟧ ⟹ thesis) ⟹ thesis›*) by (meson observable_transition_def (*‹?P ⇒{?α} ?P' ≡ ∃Q Q'. ?P ⇒ Q ∧ Q → ⟨?α,Q'⟩ ∧ Q' ⇒ ?P'›*) weak_transition_def (*‹?P ⇒⟨?α⟩ ?P' ≡ if ?α = τ then ?P ⇒ ?P' else ?P ⇒{?α} ?P'›*)) from trans''' (*‹Q' ⇒ P'›*) valid (*‹P' ⊨ x'›*) have "Q' ⊨ weak_tau_modality x'" by (metis valid_weak_tau_modality (*‹?P ⊨ weak_tau_modality ?x = (∃P'. ?P ⇒ P' ∧ P' ⊨ ?x)›*)) with trans'' (*‹Q → ⟨α',Q'⟩›*) have "Q ⊨ Act α' (weak_tau_modality x')" by (metis valid_Act (*‹(?P::'state) ⊨ Act (?α::'act) (?x::(?'a, 'pred, 'act) formula) = (∃(α'::'act) (x'::(?'a, 'pred, 'act) formula) P'::'state. Act ?α ?x = Act α' x' ∧ ?P → ⟨α',P'⟩ ∧ P' ⊨ x')›*)) with trans' (*‹(P::'state) ⇒ (Q::'state)›*) "α'" (*‹α' ≠ τ›*) have "P ⊨ ⟨⟨α'⟩⟩x'" by (metis valid_weak_tau_modality (*‹?P ⊨ weak_tau_modality ?x = (∃P'. ?P ⇒ P' ∧ P' ⊨ ?x)›*) weak_action_modality_not_tau (*‹?α ≠ τ ⟹ ⟨⟨?α⟩⟩?x = weak_tau_modality (Act ?α (weak_tau_modality ?x))›*)) moreover from eq (*‹Act (α::'act) (x::('idx, 'pred, 'act) formula) = Act (α'::'act) (x'::('idx, 'pred, 'act) formula)›*) have "(⟨⟨α⟩⟩x) = (⟨⟨α'⟩⟩x')" by (metis weak_action_modality_eq (*‹Act ?α1.0 ?x1.0 = Act ?α2.0 ?x2.0 ⟹ ⟨⟨?α1.0⟩⟩?x1.0 = ⟨⟨?α2.0⟩⟩?x2.0›*)) ultimately show "?l" by simp qed qed text ‹The binding names in the alpha-variant that witnesses validity may be chosen fresh for any finitely supported context.› lemma valid_weak_action_modality_strong: assumes "finite (supp X)" shows "P ⊨ (⟨⟨α⟩⟩x) ⟷ (∃α' x' P'. Act α x = Act α' x' ∧ P ⇒⟨α'⟩ P' ∧ P' ⊨ x' ∧ bn α' ♯* X)" proof (standard) (*goals: 1. ‹P ⊨ ⟨⟨α⟩⟩x ⟹ ∃α' x' P'. Act α x = Act α' x' ∧ P ⇒⟨α'⟩ P' ∧ P' ⊨ x' ∧ bn α' ♯* X› 2. ‹∃α' x' P'. Act α x = Act α' x' ∧ P ⇒⟨α'⟩ P' ∧ P' ⊨ x' ∧ bn α' ♯* X ⟹ P ⊨ ⟨⟨α⟩⟩x›*) assume "P ⊨ ⟨⟨α⟩⟩x" (*‹(P::'state) ⊨ ⟨⟨α::'act⟩⟩x::('idx, 'pred, 'act) formula›*) then obtain α' and x' and P' where eq: "Act α x = Act α' x'" and trans: "P ⇒⟨α'⟩ P'" and valid: "P' ⊨ x'" (*goal: ‹(⋀(α'::'act) (x'::('idx, 'pred, 'act) formula) P'::'state. ⟦Act (α::'act) (x::('idx, 'pred, 'act) formula) = Act α' x'; (P::'state) ⇒⟨α'⟩ P'; P' ⊨ x'⟧ ⟹ thesis::bool) ⟹ thesis›*) by (metis valid_weak_action_modality (*‹?P ⊨ ⟨⟨?α⟩⟩?x = (∃α' x' P'. Act ?α ?x = Act α' x' ∧ ?P ⇒⟨α'⟩ P' ∧ P' ⊨ x')›*)) show "∃α' x' P'. Act α x = Act α' x' ∧ P ⇒⟨α'⟩ P' ∧ P' ⊨ x' ∧ bn α' ♯* X" proof (cases "α' = τ") (*goals: 1. ‹α' = τ ⟹ ∃α' x' P'. Act α x = Act α' x' ∧ P ⇒⟨α'⟩ P' ∧ P' ⊨ x' ∧ bn α' ♯* X› 2. ‹α' ≠ τ ⟹ ∃α' x' P'. Act α x = Act α' x' ∧ P ⇒⟨α'⟩ P' ∧ P' ⊨ x' ∧ bn α' ♯* X›*) case True (*‹(α'::'act::bn) = (τ::'act::bn)›*) then show "?thesis" (*goal: ‹∃α' x' P'. Act α x = Act α' x' ∧ P ⇒⟨α'⟩ P' ∧ P' ⊨ x' ∧ bn α' ♯* X›*) using eq (*‹Act (α::'act) (x::('idx, 'pred, 'act) formula) = Act (α'::'act) (x'::('idx, 'pred, 'act) formula)›*) trans (*‹P ⇒⟨α'⟩ P'›*) valid (*‹P' ⊨ x'›*) bn_tau_fresh (*‹bn τ ♯* ?P›*) by blast next (*goal: ‹α' ≠ τ ⟹ ∃α' x' P'. Act α x = Act α' x' ∧ P ⇒⟨α'⟩ P' ∧ P' ⊨ x' ∧ bn α' ♯* X›*) case False (*‹α' ≠ τ›*) with trans (*‹P ⇒⟨α'⟩ P'›*) obtain Q and Q' where trans': "P ⇒ Q" and trans'': "Q → ⟨α', Q'⟩" and trans''': "Q' ⇒ P'" (*goal: ‹(⋀Q Q'. ⟦P ⇒ Q; Q → ⟨α',Q'⟩; Q' ⇒ P'⟧ ⟹ thesis) ⟹ thesis›*) by (metis weak_transition_def (*‹?P ⇒⟨?α⟩ ?P' ≡ if ?α = τ then ?P ⇒ ?P' else ?P ⇒{?α} ?P'›*) observable_transition_def (*‹?P ⇒{?α} ?P' ≡ ∃Q Q'. ?P ⇒ Q ∧ Q → ⟨?α,Q'⟩ ∧ Q' ⇒ ?P'›*)) have "finite (bn α')" by (fact bn_finite (*‹finite (bn ?α)›*)) moreover note ‹finite (supp X)› (*‹finite (supp X)›*) moreover have "finite (supp (Act α' x', ⟨α',Q'⟩))" by (metis finite_Diff (*‹finite ?A ⟹ finite (?A - ?B)›*) finite_UnI (*‹⟦finite ?F; finite ?G⟧ ⟹ finite (?F ∪ ?G)›*) finite_supp (*‹finite (supp ?x)›*) supp_Pair (*‹supp (?x, ?y) = supp ?x ∪ supp ?y›*) supp_abs_residual_pair (*‹supp ⟨?α,?P⟩ = supp (?α, ?P) - bn ?α›*)) moreover have "bn α' ♯* (Act α' x', ⟨α',Q'⟩)" by (auto simp add: fresh_star_def (*‹?as ♯* ?x ≡ ∀a∈?as. a ♯ ?x›*) fresh_def (*‹?a ♯ ?x ≡ ?a ∉ supp ?x›*) supp_Pair (*‹supp (?x, ?y) = supp ?x ∪ supp ?y›*) supp_abs_residual_pair (*‹supp ⟨?α,?P⟩ = supp (?α, ?P) - bn ?α›*)) ultimately obtain p where fresh_X: "(p ∙ bn α') ♯* X" and "supp (Act α' x', ⟨α',Q'⟩) ♯* p" (*goal: ‹(⋀p. ⟦(p ∙ bn α') ♯* X; supp (Act α' x', ⟨α',Q'⟩) ♯* p⟧ ⟹ thesis) ⟹ thesis›*) by (metis at_set_avoiding2 (*‹⟦finite (?xs::atom set); finite (supp (?c::?'a)); finite (supp (?x::?'b)); ?xs ♯* ?x⟧ ⟹ ∃p::perm. (p ∙ ?xs) ♯* ?c ∧ supp ?x ♯* p›*)) then have "supp (Act α' x') ♯* p" and "supp ⟨α',Q'⟩ ♯* p" apply - (*goals: 1. ‹⟦(p ∙ bn α') ♯* X; supp (Act α' x', ⟨α',Q'⟩) ♯* p⟧ ⟹ supp (Act α' x') ♯* p› 2. ‹⟦(p ∙ bn α') ♯* X; supp (Act α' x', ⟨α',Q'⟩) ♯* p⟧ ⟹ supp ⟨α',Q'⟩ ♯* p› discuss goal 1*) apply (metis fresh_star_Un (*‹(?as ∪ ?bs) ♯* ?x = (?as ♯* ?x ∧ ?bs ♯* ?x)›*) supp_Pair (*‹supp (?x, ?y) = supp ?x ∪ supp ?y›*)) (*discuss goal 2*) apply (metis fresh_star_Un (*‹(?as ∪ ?bs) ♯* ?x = (?as ♯* ?x ∧ ?bs ♯* ?x)›*) supp_Pair (*‹supp (?x, ?y) = supp ?x ∪ supp ?y›*)) (*proven 2 subgoals*) . then have 1: "Act (p ∙ α') (p ∙ x') = Act α' x'" and 2: "⟨p ∙ α', p ∙ Q'⟩ = ⟨α',Q'⟩" apply - (*goals: 1. ‹⟦supp (Act (α'::'act) (x'::('idx, 'pred, 'act) formula)) ♯* (p::perm); supp ⟨α',Q'::'state⟩ ♯* p⟧ ⟹ Act (p ∙ α') (p ∙ x') = Act α' x'› 2. ‹⟦supp (Act (α'::'act) (x'::('idx, 'pred, 'act) formula)) ♯* (p::perm); supp ⟨α',Q'::'state⟩ ♯* p⟧ ⟹ ⟨p ∙ α',p ∙ Q'⟩ = ⟨α',Q'⟩› discuss goal 1*) apply (metis Act_eqvt (*‹?p ∙ Act ?α ?x = Act (?p ∙ ?α) (?p ∙ ?x)›*) supp_perm_eq (*‹supp ?x ♯* ?p ⟹ ?p ∙ ?x = ?x›*)) (*discuss goal 2*) apply (metis abs_residual_pair_eqvt (*‹?p ∙ ⟨?α,?P⟩ = ⟨?p ∙ ?α,?p ∙ ?P⟩›*) supp_perm_eq (*‹supp ?x ♯* ?p ⟹ ?p ∙ ?x = ?x›*)) (*proven 2 subgoals*) . from trans' (*‹(P::'state) ⇒ (Q::'state)›*) trans'' (*‹Q → ⟨α',Q'⟩›*) trans''' (*‹Q' ⇒ P'›*) have "P ⇒⟨p ∙ α'⟩ (p ∙ P')" using "2" (*‹⟨(p::perm) ∙ (α'::'act),p ∙ (Q'::'state)⟩ = ⟨α',Q'⟩›*) by (metis observable_transitionI (*‹⟦?P ⇒ ?Q; ?Q → ⟨?α,?Q'⟩; ?Q' ⇒ ?P'⟧ ⟹ ?P ⇒{?α} ?P'›*) tau_transition_eqvt (*‹?P ⇒ ?P' ⟹ ?p ∙ ?P ⇒ ?p ∙ ?P'›*) weak_transition_stepI (*‹?P ⇒{?α} ?P' ⟹ ?P ⇒⟨?α⟩ ?P'›*)) then show "?thesis" (*goal: ‹∃(α'::'act) (x'::('idx, 'pred, 'act) formula) P'::'state. Act (α::'act) (x::('idx, 'pred, 'act) formula) = Act α' x' ∧ (P::'state) ⇒⟨α'⟩ P' ∧ P' ⊨ x' ∧ bn α' ♯* (X::'a)›*) using eq (*‹Act α x = Act α' x'›*) "1" (*‹Act (p ∙ α') (p ∙ x') = Act α' x'›*) valid (*‹P' ⊨ x'›*) fresh_X (*‹(p ∙ bn α') ♯* X›*) by (metis bn_eqvt (*‹?p ∙ bn ?α = bn (?p ∙ ?α)›*) valid_eqvt (*‹?P ⊨ ?x ⟹ ?p ∙ ?P ⊨ ?p ∙ ?x›*)) qed next (*goal: ‹∃α' x' P'. Act α x = Act α' x' ∧ P ⇒⟨α'⟩ P' ∧ P' ⊨ x' ∧ bn α' ♯* X ⟹ P ⊨ ⟨⟨α⟩⟩x›*) assume "∃α' x' P'. Act α x = Act α' x' ∧ P ⇒⟨α'⟩ P' ∧ P' ⊨ x' ∧ bn α' ♯* X" (*‹∃(α'::'act) (x'::('idx, 'pred, 'act) formula) P'::'state. Act (α::'act) (x::('idx, 'pred, 'act) formula) = Act α' x' ∧ (P::'state) ⇒⟨α'⟩ P' ∧ P' ⊨ x' ∧ bn α' ♯* (X::'a)›*) then show "P ⊨ ⟨⟨α⟩⟩x" by (metis valid_weak_action_modality (*‹?P ⊨ ⟨⟨?α⟩⟩?x = (∃α' x' P'. Act ?α ?x = Act α' x' ∧ ?P ⇒⟨α'⟩ P' ∧ P' ⊨ x')›*)) qed lemma valid_weak_action_modality_fresh: assumes "bn α ♯* P" shows "P ⊨ (⟨⟨α⟩⟩x) ⟷ (∃P'. P ⇒⟨α⟩ P' ∧ P' ⊨ x)" proof (standard) (*goals: 1. ‹(P::'state::fs) ⊨ ⟨⟨α::'act::bn⟩⟩x::('idx::type, 'pred::fs, 'act::bn) formula ⟹ ∃P'::'state::fs. P ⇒⟨α⟩ P' ∧ P' ⊨ x› 2. ‹∃P'::'state::fs. (P::'state::fs) ⇒⟨(α::'act::bn)⟩ P' ∧ P' ⊨ (x::('idx::type, 'pred::fs, 'act::bn) formula) ⟹ P ⊨ ⟨⟨α⟩⟩x›*) assume "P ⊨ ⟨⟨α⟩⟩x" (*‹(P::'state) ⊨ ⟨⟨α::'act⟩⟩x::('idx, 'pred, 'act) formula›*) moreover have "finite (supp P)" by (fact finite_supp (*‹finite (supp ?x)›*)) ultimately obtain α' and x' and P' where eq: "Act α x = Act α' x'" and trans: "P ⇒⟨α'⟩ P'" and valid: "P' ⊨ x'" and fresh: "bn α' ♯* P" (*goal: ‹(⋀α' x' P'. ⟦Act α x = Act α' x'; P ⇒⟨α'⟩ P'; P' ⊨ x'; bn α' ♯* P⟧ ⟹ thesis) ⟹ thesis›*) by (metis valid_weak_action_modality_strong (*‹finite (supp (?X::?'a)) ⟹ (?P::'state) ⊨ ⟨⟨?α::'act⟩⟩?x::('idx, 'pred, 'act) formula = (∃(α'::'act) (x'::('idx, 'pred, 'act) formula) P'::'state. Act ?α ?x = Act α' x' ∧ ?P ⇒⟨α'⟩ P' ∧ P' ⊨ x' ∧ bn α' ♯* ?X)›*)) from eq (*‹Act α x = Act α' x'›*) obtain p where "p_α": "α' = p ∙ α" and p_x: "x' = p ∙ x" and supp_p: "supp p ⊆ bn α ∪ p ∙ bn α" (*goal: ‹(⋀p. ⟦α' = p ∙ α; x' = p ∙ x; supp p ⊆ bn α ∪ p ∙ bn α⟧ ⟹ thesis) ⟹ thesis›*) by (metis Act_eq_iff_perm_renaming (*‹(Act ?α1.0 ?x1.0 = Act ?α2.0 ?x2.0) = (∃p. supp ?x1.0 - bn ?α1.0 = supp ?x2.0 - bn ?α2.0 ∧ (supp ?x1.0 - bn ?α1.0) ♯* p ∧ p ∙ ?x1.0 = ?x2.0 ∧ supp ?α1.0 - bn ?α1.0 = supp ?α2.0 - bn ?α2.0 ∧ (supp ?α1.0 - bn ?α1.0) ♯* p ∧ p ∙ ?α1.0 = ?α2.0 ∧ supp p ⊆ bn ?α1.0 ∪ p ∙ bn ?α1.0)›*)) from assms (*‹bn α ♯* P›*) fresh (*‹bn α' ♯* P›*) have "(bn α ∪ p ∙ bn α) ♯* P" using "p_α" (*‹α' = p ∙ α›*) by (metis bn_eqvt (*‹(?p::perm) ∙ bn (?α::?'a::bn) = bn (?p ∙ ?α)›*) fresh_star_Un (*‹((?as::atom set) ∪ (?bs::atom set)) ♯* (?x::?'a::pt) = (?as ♯* ?x ∧ ?bs ♯* ?x)›*)) then have "supp p ♯* P" using supp_p (*‹supp p ⊆ bn α ∪ p ∙ bn α›*) by (metis fresh_star_def (*‹(?as::atom set) ♯* (?x::?'a) ≡ ∀a::atom∈?as. a ♯ ?x›*) subset_eq (*‹((?A::?'a set) ⊆ (?B::?'a set)) = (∀x::?'a∈?A. x ∈ ?B)›*)) then have p_P: "-p ∙ P = P" by (metis perm_supp_eq (*‹supp ?p ♯* ?x ⟹ ?p ∙ ?x = ?x›*) supp_minus_perm (*‹supp (- ?p) = supp ?p›*)) from trans (*‹P ⇒⟨α'⟩ P'›*) have "P ⇒⟨α⟩ (-p ∙ P')" using p_P (*‹- p ∙ P = P›*) "p_α" (*‹α' = p ∙ α›*) by (metis permute_minus_cancel( (*‹(?p::perm) ∙ - ?p ∙ (?x::?'a::pt) = ?x›*) 1) weak_transition_eqvt (*‹(?P::'state::fs) ⇒⟨(?α::'act::bn)⟩ (?P'::'state::fs) ⟹ (?p::perm) ∙ ?P ⇒⟨?p ∙ ?α⟩ ?p ∙ ?P'›*)) moreover from valid (*‹P' ⊨ x'›*) have "-p ∙ P' ⊨ x" using p_x (*‹x' = p ∙ x›*) by (metis permute_minus_cancel( (*‹(?p::perm) ∙ - ?p ∙ (?x::?'a) = ?x›*) 1) valid_eqvt (*‹(?P::'state) ⊨ (?x::(?'a, 'pred, 'act) formula) ⟹ (?p::perm) ∙ ?P ⊨ ?p ∙ ?x›*)) ultimately show "∃P'. P ⇒⟨α⟩ P' ∧ P' ⊨ x" by meson next (*goal: ‹∃P'. P ⇒⟨α⟩ P' ∧ P' ⊨ x ⟹ P ⊨ ⟨⟨α⟩⟩x›*) assume "∃P'. P ⇒⟨α⟩ P' ∧ P' ⊨ x" (*‹∃P'::'state. (P::'state) ⇒⟨(α::'act)⟩ P' ∧ P' ⊨ (x::('idx, 'pred, 'act) formula)›*) then show "P ⊨ ⟨⟨α⟩⟩x" by (metis valid_weak_action_modality (*‹?P ⊨ ⟨⟨?α⟩⟩?x = (∃α' x' P'. Act ?α ?x = Act α' x' ∧ ?P ⇒⟨α'⟩ P' ∧ P' ⊨ x')›*)) qed end end
{ "path": "afp-2025-02-12/thys/Modal_Logics_for_NTS/Weak_Validity.thy", "repo": "afp-2025-02-12", "sha": "404ad05a20be29add5165488279f3b3b1c17fe4786282ed1cd6ffc7175003562" }
(* Title: HOL/Bali/Decl.thy Author: David von Oheimb and Norbert Schirmer *) subsection ‹Field, method, interface, and class declarations, whole Java programs › theory Decl imports Term Table (** order is significant, because of clash for "var" **) begin text ‹ improvements: \begin{itemize} \item clarification and correction of some aspects of the package/access concept (Also submitted as bug report to the Java Bug Database: Bug Id: 4485402 and Bug Id: 4493343 🌐‹http://developer.java.sun.com/developer/bugParade/index.jshtml› ) \end{itemize} simplifications: \begin{itemize} \item the only field and method modifiers are static and the access modifiers \item no constructors, which may be simulated by new + suitable methods \item there is just one global initializer per class, which can simulate all others \item no throws clause \item a void method is replaced by one that returns Unit (of dummy type Void) \item no interface fields \item every class has an explicit superclass (unused for Object) \item the (standard) methods of Object and of standard exceptions are not specified \item no main method \end{itemize} › subsection ‹Modifier› subsubsection ‹Access modifier› datatype acc_modi (* access modifier *) = Private | Package | Protected | Public text ‹ We can define a linear order for the access modifiers. With Private yielding the most restrictive access and public the most liberal access policy: Private < Package < Protected < Public › instantiation acc_modi :: linorder begin definition less_acc_def: "a < b ⟷ (case a of Private ⇒ (b=Package ∨ b=Protected ∨ b=Public) | Package ⇒ (b=Protected ∨ b=Public) | Protected ⇒ (b=Public) | Public ⇒ False)" definition le_acc_def: "(a :: acc_modi) ≤ b ⟷ a < b ∨ a = b" instance proof fix x y z::acc_modi show "(x < y) = (x ≤ y ∧ ¬ y ≤ x)" by (auto simp add: le_acc_def less_acc_def split: acc_modi.split) show "x ≤ x" ― ‹reflexivity› by (auto simp add: le_acc_def) { assume "x ≤ y" "y ≤ z" ― ‹transitivity› then show "x ≤ z" by (auto simp add: le_acc_def less_acc_def split: acc_modi.split) next assume "x ≤ y" "y ≤ x" ― ‹antisymmetry› moreover have "∀ x y. x < (y::acc_modi) ∧ y < x ⟶ False" by (auto simp add: less_acc_def split: acc_modi.split) ultimately show "x = y" by (unfold le_acc_def) iprover next fix x y:: acc_modi show "x ≤ y ∨ y ≤ x" by (auto simp add: less_acc_def le_acc_def split: acc_modi.split) } qed end lemma acc_modi_top [simp]: "Public ≤ a ⟹ a = Public" by (auto simp add: le_acc_def (*‹(?a ≤ ?b) = (?a < ?b ∨ ?a = ?b)›*) less_acc_def (*‹(?a < ?b) = (case ?a of Private ⇒ ?b = Package ∨ ?b = Protected ∨ ?b = Public | Package ⇒ ?b = Protected ∨ ?b = Public | Protected ⇒ ?b = Public | Public ⇒ False)›*) split: acc_modi.splits (*‹?P (case ?acc_modi of Private ⇒ ?f1.0 | Package ⇒ ?f2.0 | Protected ⇒ ?f3.0 | Public ⇒ ?f4.0) = ((?acc_modi = Private ⟶ ?P ?f1.0) ∧ (?acc_modi = Package ⟶ ?P ?f2.0) ∧ (?acc_modi = Protected ⟶ ?P ?f3.0) ∧ (?acc_modi = Public ⟶ ?P ?f4.0))› ‹?P (case ?acc_modi of Private ⇒ ?f1.0 | Package ⇒ ?f2.0 | Protected ⇒ ?f3.0 | Public ⇒ ?f4.0) = (¬ (?acc_modi = Private ∧ ¬ ?P ?f1.0 ∨ ?acc_modi = Package ∧ ¬ ?P ?f2.0 ∨ ?acc_modi = Protected ∧ ¬ ?P ?f3.0 ∨ ?acc_modi = Public ∧ ¬ ?P ?f4.0))›*)) lemma acc_modi_top1 [simp, intro!]: "a ≤ Public" by (auto simp add: le_acc_def (*‹((?a::acc_modi) ≤ (?b::acc_modi)) = (?a < ?b ∨ ?a = ?b)›*) less_acc_def (*‹((?a::acc_modi) < (?b::acc_modi)) = (case ?a of Private ⇒ ?b = Package ∨ ?b = Protected ∨ ?b = Public | Package ⇒ ?b = Protected ∨ ?b = Public | Protected ⇒ ?b = Public | Public ⇒ False)›*) split: acc_modi.splits (*‹(?P::?'a ⇒ bool) (case ?acc_modi::acc_modi of Private ⇒ ?f1.0::?'a | Package ⇒ ?f2.0::?'a | Protected ⇒ ?f3.0::?'a | Public ⇒ ?f4.0::?'a) = ((?acc_modi = Private ⟶ ?P ?f1.0) ∧ (?acc_modi = Package ⟶ ?P ?f2.0) ∧ (?acc_modi = Protected ⟶ ?P ?f3.0) ∧ (?acc_modi = Public ⟶ ?P ?f4.0))› ‹(?P::?'a ⇒ bool) (case ?acc_modi::acc_modi of Private ⇒ ?f1.0::?'a | Package ⇒ ?f2.0::?'a | Protected ⇒ ?f3.0::?'a | Public ⇒ ?f4.0::?'a) = (¬ (?acc_modi = Private ∧ ¬ ?P ?f1.0 ∨ ?acc_modi = Package ∧ ¬ ?P ?f2.0 ∨ ?acc_modi = Protected ∧ ¬ ?P ?f3.0 ∨ ?acc_modi = Public ∧ ¬ ?P ?f4.0))›*)) lemma acc_modi_le_Public: "a ≤ Public ⟹ a=Private ∨ a = Package ∨ a=Protected ∨ a=Public" by (auto simp add: le_acc_def (*‹(?a ≤ ?b) = (?a < ?b ∨ ?a = ?b)›*) less_acc_def (*‹(?a < ?b) = (case ?a of Private ⇒ ?b = Package ∨ ?b = Protected ∨ ?b = Public | Package ⇒ ?b = Protected ∨ ?b = Public | Protected ⇒ ?b = Public | Public ⇒ False)›*) split: acc_modi.splits (*‹?P (case ?acc_modi of Private ⇒ ?f1.0 | Package ⇒ ?f2.0 | Protected ⇒ ?f3.0 | Public ⇒ ?f4.0) = ((?acc_modi = Private ⟶ ?P ?f1.0) ∧ (?acc_modi = Package ⟶ ?P ?f2.0) ∧ (?acc_modi = Protected ⟶ ?P ?f3.0) ∧ (?acc_modi = Public ⟶ ?P ?f4.0))› ‹?P (case ?acc_modi of Private ⇒ ?f1.0 | Package ⇒ ?f2.0 | Protected ⇒ ?f3.0 | Public ⇒ ?f4.0) = (¬ (?acc_modi = Private ∧ ¬ ?P ?f1.0 ∨ ?acc_modi = Package ∧ ¬ ?P ?f2.0 ∨ ?acc_modi = Protected ∧ ¬ ?P ?f3.0 ∨ ?acc_modi = Public ∧ ¬ ?P ?f4.0))›*)) lemma acc_modi_bottom: "a ≤ Private ⟹ a = Private" by (auto simp add: le_acc_def (*‹(?a ≤ ?b) = (?a < ?b ∨ ?a = ?b)›*) less_acc_def (*‹(?a < ?b) = (case ?a of Private ⇒ ?b = Package ∨ ?b = Protected ∨ ?b = Public | Package ⇒ ?b = Protected ∨ ?b = Public | Protected ⇒ ?b = Public | Public ⇒ False)›*) split: acc_modi.splits (*‹?P (case ?acc_modi of Private ⇒ ?f1.0 | Package ⇒ ?f2.0 | Protected ⇒ ?f3.0 | Public ⇒ ?f4.0) = ((?acc_modi = Private ⟶ ?P ?f1.0) ∧ (?acc_modi = Package ⟶ ?P ?f2.0) ∧ (?acc_modi = Protected ⟶ ?P ?f3.0) ∧ (?acc_modi = Public ⟶ ?P ?f4.0))› ‹?P (case ?acc_modi of Private ⇒ ?f1.0 | Package ⇒ ?f2.0 | Protected ⇒ ?f3.0 | Public ⇒ ?f4.0) = (¬ (?acc_modi = Private ∧ ¬ ?P ?f1.0 ∨ ?acc_modi = Package ∧ ¬ ?P ?f2.0 ∨ ?acc_modi = Protected ∧ ¬ ?P ?f3.0 ∨ ?acc_modi = Public ∧ ¬ ?P ?f4.0))›*)) lemma acc_modi_Private_le: "Private ≤ a ⟹ a=Private ∨ a = Package ∨ a=Protected ∨ a=Public" by (auto simp add: le_acc_def (*‹(?a ≤ ?b) = (?a < ?b ∨ ?a = ?b)›*) less_acc_def (*‹(?a < ?b) = (case ?a of Private ⇒ ?b = Package ∨ ?b = Protected ∨ ?b = Public | Package ⇒ ?b = Protected ∨ ?b = Public | Protected ⇒ ?b = Public | Public ⇒ False)›*) split: acc_modi.splits (*‹?P (case ?acc_modi of Private ⇒ ?f1.0 | Package ⇒ ?f2.0 | Protected ⇒ ?f3.0 | Public ⇒ ?f4.0) = ((?acc_modi = Private ⟶ ?P ?f1.0) ∧ (?acc_modi = Package ⟶ ?P ?f2.0) ∧ (?acc_modi = Protected ⟶ ?P ?f3.0) ∧ (?acc_modi = Public ⟶ ?P ?f4.0))› ‹?P (case ?acc_modi of Private ⇒ ?f1.0 | Package ⇒ ?f2.0 | Protected ⇒ ?f3.0 | Public ⇒ ?f4.0) = (¬ (?acc_modi = Private ∧ ¬ ?P ?f1.0 ∨ ?acc_modi = Package ∧ ¬ ?P ?f2.0 ∨ ?acc_modi = Protected ∧ ¬ ?P ?f3.0 ∨ ?acc_modi = Public ∧ ¬ ?P ?f4.0))›*)) lemma acc_modi_Package_le: "Package ≤ a ⟹ a = Package ∨ a=Protected ∨ a=Public" by (auto simp add: le_acc_def (*‹((?a::acc_modi) ≤ (?b::acc_modi)) = (?a < ?b ∨ ?a = ?b)›*) less_acc_def (*‹((?a::acc_modi) < (?b::acc_modi)) = (case ?a of Private ⇒ ?b = Package ∨ ?b = Protected ∨ ?b = Public | Package ⇒ ?b = Protected ∨ ?b = Public | Protected ⇒ ?b = Public | Public ⇒ False)›*) split: acc_modi.split (*‹(?P::?'a ⇒ bool) (case ?acc_modi::acc_modi of Private ⇒ ?f1.0::?'a | Package ⇒ ?f2.0::?'a | Protected ⇒ ?f3.0::?'a | Public ⇒ ?f4.0::?'a) = ((?acc_modi = Private ⟶ ?P ?f1.0) ∧ (?acc_modi = Package ⟶ ?P ?f2.0) ∧ (?acc_modi = Protected ⟶ ?P ?f3.0) ∧ (?acc_modi = Public ⟶ ?P ?f4.0))›*)) lemma acc_modi_le_Package: "a ≤ Package ⟹ a=Private ∨ a = Package" by (auto simp add: le_acc_def (*‹((?a::acc_modi) ≤ (?b::acc_modi)) = (?a < ?b ∨ ?a = ?b)›*) less_acc_def (*‹((?a::acc_modi) < (?b::acc_modi)) = (case ?a of Private ⇒ ?b = Package ∨ ?b = Protected ∨ ?b = Public | Package ⇒ ?b = Protected ∨ ?b = Public | Protected ⇒ ?b = Public | Public ⇒ False)›*) split: acc_modi.splits (*‹(?P::?'a ⇒ bool) (case ?acc_modi::acc_modi of Private ⇒ ?f1.0::?'a | Package ⇒ ?f2.0::?'a | Protected ⇒ ?f3.0::?'a | Public ⇒ ?f4.0::?'a) = ((?acc_modi = Private ⟶ ?P ?f1.0) ∧ (?acc_modi = Package ⟶ ?P ?f2.0) ∧ (?acc_modi = Protected ⟶ ?P ?f3.0) ∧ (?acc_modi = Public ⟶ ?P ?f4.0))› ‹(?P::?'a ⇒ bool) (case ?acc_modi::acc_modi of Private ⇒ ?f1.0::?'a | Package ⇒ ?f2.0::?'a | Protected ⇒ ?f3.0::?'a | Public ⇒ ?f4.0::?'a) = (¬ (?acc_modi = Private ∧ ¬ ?P ?f1.0 ∨ ?acc_modi = Package ∧ ¬ ?P ?f2.0 ∨ ?acc_modi = Protected ∧ ¬ ?P ?f3.0 ∨ ?acc_modi = Public ∧ ¬ ?P ?f4.0))›*)) lemma acc_modi_Protected_le: "Protected ≤ a ⟹ a=Protected ∨ a=Public" by (auto simp add: le_acc_def (*‹(?a ≤ ?b) = (?a < ?b ∨ ?a = ?b)›*) less_acc_def (*‹(?a < ?b) = (case ?a of Private ⇒ ?b = Package ∨ ?b = Protected ∨ ?b = Public | Package ⇒ ?b = Protected ∨ ?b = Public | Protected ⇒ ?b = Public | Public ⇒ False)›*) split: acc_modi.splits (*‹?P (case ?acc_modi of Private ⇒ ?f1.0 | Package ⇒ ?f2.0 | Protected ⇒ ?f3.0 | Public ⇒ ?f4.0) = ((?acc_modi = Private ⟶ ?P ?f1.0) ∧ (?acc_modi = Package ⟶ ?P ?f2.0) ∧ (?acc_modi = Protected ⟶ ?P ?f3.0) ∧ (?acc_modi = Public ⟶ ?P ?f4.0))› ‹?P (case ?acc_modi of Private ⇒ ?f1.0 | Package ⇒ ?f2.0 | Protected ⇒ ?f3.0 | Public ⇒ ?f4.0) = (¬ (?acc_modi = Private ∧ ¬ ?P ?f1.0 ∨ ?acc_modi = Package ∧ ¬ ?P ?f2.0 ∨ ?acc_modi = Protected ∧ ¬ ?P ?f3.0 ∨ ?acc_modi = Public ∧ ¬ ?P ?f4.0))›*)) lemma acc_modi_le_Protected: "a ≤ Protected ⟹ a=Private ∨ a = Package ∨ a = Protected" by (auto simp add: le_acc_def (*‹(?a ≤ ?b) = (?a < ?b ∨ ?a = ?b)›*) less_acc_def (*‹(?a < ?b) = (case ?a of Private ⇒ ?b = Package ∨ ?b = Protected ∨ ?b = Public | Package ⇒ ?b = Protected ∨ ?b = Public | Protected ⇒ ?b = Public | Public ⇒ False)›*) split: acc_modi.splits (*‹?P (case ?acc_modi of Private ⇒ ?f1.0 | Package ⇒ ?f2.0 | Protected ⇒ ?f3.0 | Public ⇒ ?f4.0) = ((?acc_modi = Private ⟶ ?P ?f1.0) ∧ (?acc_modi = Package ⟶ ?P ?f2.0) ∧ (?acc_modi = Protected ⟶ ?P ?f3.0) ∧ (?acc_modi = Public ⟶ ?P ?f4.0))› ‹?P (case ?acc_modi of Private ⇒ ?f1.0 | Package ⇒ ?f2.0 | Protected ⇒ ?f3.0 | Public ⇒ ?f4.0) = (¬ (?acc_modi = Private ∧ ¬ ?P ?f1.0 ∨ ?acc_modi = Package ∧ ¬ ?P ?f2.0 ∨ ?acc_modi = Protected ∧ ¬ ?P ?f3.0 ∨ ?acc_modi = Public ∧ ¬ ?P ?f4.0))›*)) lemmas acc_modi_le_Dests = acc_modi_top acc_modi_le_Public acc_modi_Private_le acc_modi_bottom acc_modi_Package_le acc_modi_le_Package acc_modi_Protected_le acc_modi_le_Protected lemma acc_modi_Package_le_cases: assumes "Package ≤ m" obtains (Package) "m = Package" | (Protected) "m = Protected" | (Public) "m = Public" using assms (*‹Package ≤ m›*) by (auto dest: acc_modi_Package_le (*‹Package ≤ ?a ⟹ ?a = Package ∨ ?a = Protected ∨ ?a = Public›*)) subsubsection ‹Static Modifier› type_synonym stat_modi = bool (* modifier: static *) subsection ‹Declaration (base "class" for member,interface and class declarations› record decl = access :: acc_modi translations (type) "decl" <= (type) "⦇access::acc_modi⦈" (type) "decl" <= (type) "⦇access::acc_modi,…::'a⦈" subsection ‹Member (field or method)› record member = decl + static :: stat_modi translations (type) "member" <= (type) "⦇access::acc_modi,static::bool⦈" (type) "member" <= (type) "⦇access::acc_modi,static::bool,…::'a⦈" subsection ‹Field› record field = member + type :: ty translations (type) "field" <= (type) "⦇access::acc_modi, static::bool, type::ty⦈" (type) "field" <= (type) "⦇access::acc_modi, static::bool, type::ty,…::'a⦈" type_synonym fdecl (* field declaration, cf. 8.3 *) = "vname × field" translations (type) "fdecl" <= (type) "vname × field" subsection ‹Method› record mhead = member + (* method head (excluding signature) *) pars ::"vname list" (* parameter names *) resT ::ty (* result type *) record mbody = (* method body *) lcls:: "(vname × ty) list" (* local variables *) stmt:: stmt (* the body statement *) record methd = mhead + (* method in a class *) mbody::mbody type_synonym mdecl = "sig × methd" (* method declaration in a class *) translations (type) "mhead" <= (type) "⦇access::acc_modi, static::bool, pars::vname list, resT::ty⦈" (type) "mhead" <= (type) "⦇access::acc_modi, static::bool, pars::vname list, resT::ty,…::'a⦈" (type) "mbody" <= (type) "⦇lcls::(vname × ty) list,stmt::stmt⦈" (type) "mbody" <= (type) "⦇lcls::(vname × ty) list,stmt::stmt,…::'a⦈" (type) "methd" <= (type) "⦇access::acc_modi, static::bool, pars::vname list, resT::ty,mbody::mbody⦈" (type) "methd" <= (type) "⦇access::acc_modi, static::bool, pars::vname list, resT::ty,mbody::mbody,…::'a⦈" (type) "mdecl" <= (type) "sig × methd" definition mhead :: "methd ⇒ mhead" where "mhead m = ⦇access=access m, static=static m, pars=pars m, resT=resT m⦈" lemma access_mhead [simp]:"access (mhead m) = access m" by (simp add: mhead_def (*‹mhead ?m = ⦇access = access ?m, static = static ?m, pars = pars ?m, resT = resT ?m⦈›*)) lemma static_mhead [simp]:"static (mhead m) = static m" by (simp add: mhead_def (*‹mhead (?m::methd) = ⦇access = access ?m, static = static ?m, pars = pars ?m, resT = resT ?m⦈›*)) lemma pars_mhead [simp]:"pars (mhead m) = pars m" by (simp add: mhead_def (*‹mhead (?m::methd) = ⦇access = access ?m, static = static ?m, pars = pars ?m, resT = resT ?m⦈›*)) lemma resT_mhead [simp]:"resT (mhead m) = resT m" by (simp add: mhead_def (*‹mhead ?m = ⦇access = access ?m, static = static ?m, pars = pars ?m, resT = resT ?m⦈›*)) text ‹To be able to talk uniformaly about field and method declarations we introduce the notion of a member declaration (e.g. useful to define accessiblity )› datatype memberdecl = fdecl fdecl | mdecl mdecl datatype memberid = fid vname | mid sig class has_memberid = fixes memberid :: "'a ⇒ memberid" instantiation memberdecl :: has_memberid begin definition memberdecl_memberid_def: "memberid m = (case m of fdecl (vn,f) ⇒ fid vn | mdecl (sig,m) ⇒ mid sig)" instance .. end lemma memberid_fdecl_simp[simp]: "memberid (fdecl (vn,f)) = fid vn" by (simp add: memberdecl_memberid_def (*‹memberid ?m = (case ?m of fdecl (vn, f) ⇒ fid vn | mdecl (sig, m) ⇒ mid sig)›*)) lemma memberid_fdecl_simp1: "memberid (fdecl f) = fid (fst f)" apply (cases f) (*goal: ‹memberid (fdecl f) = fid (fst f)›*) by (simp add: memberdecl_memberid_def (*‹memberid ?m = (case ?m of fdecl (vn, f) ⇒ fid vn | mdecl (sig, m) ⇒ mid sig)›*)) lemma memberid_mdecl_simp[simp]: "memberid (mdecl (sig,m)) = mid sig" by (simp add: memberdecl_memberid_def (*‹memberid ?m = (case ?m of fdecl (vn, f) ⇒ fid vn | mdecl (sig, m) ⇒ mid sig)›*)) lemma memberid_mdecl_simp1: "memberid (mdecl m) = mid (fst m)" apply (cases m) (*goal: ‹memberid (mdecl m) = mid (fst m)›*) by (simp add: memberdecl_memberid_def (*‹memberid ?m = (case ?m of fdecl (vn, f) ⇒ fid vn | mdecl (sig, m) ⇒ mid sig)›*)) instantiation prod :: (type, has_memberid) has_memberid begin definition pair_memberid_def: "memberid p = memberid (snd p)" instance .. end lemma memberid_pair_simp[simp]: "memberid (c,m) = memberid m" by (simp add: pair_memberid_def (*‹memberid ?p = memberid (snd ?p)›*)) lemma memberid_pair_simp1: "memberid p = memberid (snd p)" by (simp add: pair_memberid_def (*‹memberid (?p::?'a × ?'b) = memberid (snd ?p)›*)) definition is_field :: "qtname × memberdecl ⇒ bool" where "is_field m = (∃ declC f. m=(declC,fdecl f))" lemma is_fieldD: "is_field m ⟹ ∃ declC f. m=(declC,fdecl f)" by (simp add: is_field_def (*‹is_field ?m = (∃declC f. ?m = (declC, fdecl f))›*)) lemma is_fieldI: "is_field (C,fdecl f)" by (simp add: is_field_def (*‹is_field ?m = (∃declC f. ?m = (declC, fdecl f))›*)) definition is_method :: "qtname × memberdecl ⇒ bool" where "is_method membr = (∃declC m. membr=(declC,mdecl m))" lemma is_methodD: "is_method membr ⟹ ∃ declC m. membr=(declC,mdecl m)" by (simp add: is_method_def (*‹is_method ?membr = (∃declC m. ?membr = (declC, mdecl m))›*)) lemma is_methodI: "is_method (C,mdecl m)" by (simp add: is_method_def (*‹is_method (?membr::qtname × memberdecl) = (∃(declC::qtname) m::mdecl. ?membr = (declC, mdecl m))›*)) subsection ‹Interface› record ibody = decl + ― ‹interface body› imethods :: "(sig × mhead) list" ― ‹method heads› record iface = ibody + ― ‹interface› isuperIfs:: "qtname list" ― ‹superinterface list› type_synonym idecl ― ‹interface declaration, cf. 9.1› = "qtname × iface" translations (type) "ibody" <= (type) "⦇access::acc_modi,imethods::(sig × mhead) list⦈" (type) "ibody" <= (type) "⦇access::acc_modi,imethods::(sig × mhead) list,…::'a⦈" (type) "iface" <= (type) "⦇access::acc_modi,imethods::(sig × mhead) list, isuperIfs::qtname list⦈" (type) "iface" <= (type) "⦇access::acc_modi,imethods::(sig × mhead) list, isuperIfs::qtname list,…::'a⦈" (type) "idecl" <= (type) "qtname × iface" definition ibody :: "iface ⇒ ibody" where "ibody i = ⦇access=access i,imethods=imethods i⦈" lemma access_ibody [simp]: "(access (ibody i)) = access i" by (simp add: ibody_def (*‹ibody ?i = ⦇access = access ?i, imethods = imethods ?i⦈›*)) lemma imethods_ibody [simp]: "(imethods (ibody i)) = imethods i" by (simp add: ibody_def (*‹ibody ?i = ⦇access = access ?i, imethods = imethods ?i⦈›*)) subsection ‹Class› record cbody = decl + ― ‹class body› cfields:: "fdecl list" methods:: "mdecl list" init :: "stmt" ― ‹initializer› record "class" = cbody + ― ‹class› super :: "qtname" ― ‹superclass› superIfs:: "qtname list" ― ‹implemented interfaces› type_synonym cdecl ― ‹class declaration, cf. 8.1› = "qtname × class" translations (type) "cbody" <= (type) "⦇access::acc_modi,cfields::fdecl list, methods::mdecl list,init::stmt⦈" (type) "cbody" <= (type) "⦇access::acc_modi,cfields::fdecl list, methods::mdecl list,init::stmt,…::'a⦈" (type) "class" <= (type) "⦇access::acc_modi,cfields::fdecl list, methods::mdecl list,init::stmt, super::qtname,superIfs::qtname list⦈" (type) "class" <= (type) "⦇access::acc_modi,cfields::fdecl list, methods::mdecl list,init::stmt, super::qtname,superIfs::qtname list,…::'a⦈" (type) "cdecl" <= (type) "qtname × class" definition cbody :: "class ⇒ cbody" where "cbody c = ⦇access=access c, cfields=cfields c,methods=methods c,init=init c⦈" lemma access_cbody [simp]:"access (cbody c) = access c" by (simp add: cbody_def (*‹cbody (?c::class) = ⦇access = access ?c, cfields = cfields ?c, methods = methods ?c, init = init ?c⦈›*)) lemma cfields_cbody [simp]:"cfields (cbody c) = cfields c" by (simp add: cbody_def (*‹cbody ?c = ⦇access = access ?c, cfields = cfields ?c, methods = methods ?c, init = init ?c⦈›*)) lemma methods_cbody [simp]:"methods (cbody c) = methods c" by (simp add: cbody_def (*‹cbody (?c::class) = ⦇access = access ?c, cfields = cfields ?c, methods = methods ?c, init = init ?c⦈›*)) lemma init_cbody [simp]:"init (cbody c) = init c" by (simp add: cbody_def (*‹cbody ?c = ⦇access = access ?c, cfields = cfields ?c, methods = methods ?c, init = init ?c⦈›*)) subsubsection "standard classes" consts Object_mdecls :: "mdecl list" ― ‹methods of Object› SXcpt_mdecls :: "mdecl list" ― ‹methods of SXcpts› definition ObjectC :: "cdecl" ― ‹declaration of root class› where "ObjectC = (Object,⦇access=Public,cfields=[],methods=Object_mdecls, init=Skip,super=undefined,superIfs=[]⦈)" definition SXcptC ::"xname ⇒ cdecl" ― ‹declarations of throwable classes› where "SXcptC xn = (SXcpt xn,⦇access=Public,cfields=[],methods=SXcpt_mdecls, init=Skip, super=if xn = Throwable then Object else SXcpt Throwable, superIfs=[]⦈)" lemma ObjectC_neq_SXcptC [simp]: "ObjectC ≠ SXcptC xn" by (simp add: ObjectC_def (*‹ObjectC = (Object, ⦇access = Public, cfields = [], methods = Object_mdecls, init = Skip, super = undefined, superIfs = []⦈)›*) SXcptC_def (*‹SXcptC ?xn = (SXcpt ?xn, ⦇access = Public, cfields = [], methods = SXcpt_mdecls, init = Skip, super = if ?xn = Throwable then Object else SXcpt Throwable, superIfs = []⦈)›*) Object_def (*‹Object = ⦇pid = java_lang, tid = Object'⦈›*) SXcpt_def (*‹SXcpt = (λx. ⦇pid = java_lang, tid = SXcpt' x⦈)›*)) lemma SXcptC_inject [simp]: "(SXcptC xn = SXcptC xm) = (xn = xm)" by (simp add: SXcptC_def (*‹SXcptC ?xn = (SXcpt ?xn, ⦇access = Public, cfields = [], methods = SXcpt_mdecls, init = Skip, super = if ?xn = Throwable then Object else SXcpt Throwable, superIfs = []⦈)›*)) definition standard_classes :: "cdecl list" where "standard_classes = [ObjectC, SXcptC Throwable, SXcptC NullPointer, SXcptC OutOfMemory, SXcptC ClassCast, SXcptC NegArrSize , SXcptC IndOutBound, SXcptC ArrStore]" subsubsection "programs" record prog = ifaces ::"idecl list" "classes"::"cdecl list" translations (type) "prog" <= (type) "⦇ifaces::idecl list,classes::cdecl list⦈" (type) "prog" <= (type) "⦇ifaces::idecl list,classes::cdecl list,…::'a⦈" abbreviation iface :: "prog ⇒ (qtname, iface) table" where "iface G I == table_of (ifaces G) I" abbreviation "class" :: "prog ⇒ (qtname, class) table" where "class G C == table_of (classes G) C" abbreviation is_iface :: "prog ⇒ qtname ⇒ bool" where "is_iface G I == iface G I ≠ None" abbreviation is_class :: "prog ⇒ qtname ⇒ bool" where "is_class G C == class G C ≠ None" subsubsection "is type" primrec is_type :: "prog ⇒ ty ⇒ bool" and isrtype :: "prog ⇒ ref_ty ⇒ bool" where "is_type G (PrimT pt) = True" | "is_type G (RefT rt) = isrtype G rt" | "isrtype G (NullT) = True" | "isrtype G (IfaceT tn) = is_iface G tn" | "isrtype G (ClassT tn) = is_class G tn" | "isrtype G (ArrayT T ) = is_type G T" lemma type_is_iface: "is_type G (Iface I) ⟹ is_iface G I" by auto lemma type_is_class: "is_type G (Class C) ⟹ is_class G C" by auto subsubsection "subinterface and subclass relation, in anticipation of TypeRel.thy" definition subint1 :: "prog ⇒ (qtname × qtname) set" ― ‹direct subinterface› where "subint1 G = {(I,J). ∃i∈iface G I: J∈set (isuperIfs i)}" definition subcls1 :: "prog ⇒ (qtname × qtname) set" ― ‹direct subclass› where "subcls1 G = {(C,D). C≠Object ∧ (∃c∈class G C: super c = D)}" abbreviation subcls1_syntax :: "prog => [qtname, qtname] => bool" ("_⊢_≺⇩C1_" [71,71,71] 70) where "G⊢C ≺⇩C1 D == (C,D) ∈ subcls1 G" abbreviation subclseq_syntax :: "prog => [qtname, qtname] => bool" ("_⊢_≼⇩C _" [71,71,71] 70) where "G⊢C ≼⇩C D == (C,D) ∈(subcls1 G)⇧*" (* cf. 8.1.3 *) abbreviation subcls_syntax :: "prog => [qtname, qtname] => bool" ("_⊢_≺⇩C _" [71,71,71] 70) where "G⊢C ≺⇩C D == (C,D) ∈(subcls1 G)⁺" notation (ASCII) subcls1_syntax ("_|-_<:C1_" [71,71,71] 70) and subclseq_syntax ("_|-_<=:C _"[71,71,71] 70) and subcls_syntax ("_|-_<:C _"[71,71,71] 70) lemma subint1I: "⟦iface G I = Some i; J ∈ set (isuperIfs i)⟧ ⟹ (I,J) ∈ subint1 G" by (simp add: subint1_def (*‹subint1 (?G::prog) = {(I::qtname, J::qtname). ? i::iface:iface ?G I: J ∈ set (isuperIfs i)}›*)) lemma subcls1I:"⟦class G C = Some c; C ≠ Object⟧ ⟹ (C,(super c)) ∈ subcls1 G" by (simp add: subcls1_def (*‹subcls1 ?G = {(C, D). C ≠ Object ∧ (? c:class ?G C: super c = D)}›*)) lemma subint1D: "(I,J)∈subint1 G⟹ ∃i∈iface G I: J∈set (isuperIfs i)" by (simp add: subint1_def (*‹subint1 ?G = {(I, J). ? i:iface ?G I: J ∈ set (isuperIfs i)}›*)) lemma subcls1D: "(C,D)∈subcls1 G ⟹ C≠Object ∧ (∃c. class G C = Some c ∧ (super c = D))" apply (simp add: subcls1_def (*‹subcls1 ?G = {(C, D). C ≠ Object ∧ (? c:class ?G C: super c = D)}›*)) (*goal: ‹(G::prog)⊢(C::qtname)≺⇩C1(D::qtname) ⟹ C ≠ Object ∧ (∃c::class. class G C = Some c ∧ super c = D)›*) by auto lemma subint1_def2: "subint1 G = (SIGMA I: {I. is_iface G I}. set (isuperIfs (the (iface G I))))" apply (unfold subint1_def (*‹subint1 ?G = {(I, J). ? i:iface ?G I: J ∈ set (isuperIfs i)}›*)) (*goal: ‹subint1 G = (SIGMA I:{I. is_iface G I}. set (isuperIfs (the (iface G I))))›*) by auto lemma subcls1_def2: "subcls1 G = (SIGMA C: {C. is_class G C}. {D. C≠Object ∧ super (the(class G C))=D})" apply (unfold subcls1_def (*‹subcls1 ?G = {(C, D). C ≠ Object ∧ (? c:class ?G C: super c = D)}›*)) (*goal: ‹subcls1 (G::prog) = (SIGMA C::qtname:{C::qtname. is_class G C}. {D::qtname. C ≠ Object ∧ super (the (class G C)) = D})›*) by auto lemma subcls_is_class: "⟦G⊢C ≺⇩C D⟧ ⟹ ∃ c. class G C = Some c" by (auto simp add: subcls1_def (*‹subcls1 ?G = {(C, D). C ≠ Object ∧ (? c:class ?G C: super c = D)}›*) dest: tranclD (*‹(?x, ?y) ∈ ?R⁺ ⟹ ∃z. (?x, z) ∈ ?R ∧ (z, ?y) ∈ ?R⇧*›*)) lemma no_subcls1_Object:"G⊢Object≺⇩C1 D ⟹ P" by (auto simp add: subcls1_def (*‹subcls1 ?G = {(C, D). C ≠ Object ∧ (? c:class ?G C: super c = D)}›*)) lemma no_subcls_Object: "G⊢Object≺⇩C D ⟹ P" apply (erule trancl_induct (*‹⟦(?a, ?b) ∈ ?r⁺; ⋀y. (?a, y) ∈ ?r ⟹ ?P y; ⋀y z. ⟦(?a, y) ∈ ?r⁺; (y, z) ∈ ?r; ?P y⟧ ⟹ ?P z⟧ ⟹ ?P ?b›*)) (*goals: 1. ‹⋀y. G⊢Object≺⇩C1y ⟹ P› 2. ‹⋀y z. ⟦G⊢Object≺⇩C y; G⊢y≺⇩C1z; P⟧ ⟹ P› discuss goal 1*) apply ((auto intro: no_subcls1_Object (*‹?G⊢Object≺⇩C1?D ⟹ ?P›*))[1]) (*discuss goal 2*) apply ((auto intro: no_subcls1_Object (*‹?G⊢Object≺⇩C1?D ⟹ ?P›*))[1]) (*proven 2 subgoals*) . subsubsection "well-structured programs" definition ws_idecl :: "prog ⇒ qtname ⇒ qtname list ⇒ bool" where "ws_idecl G I si = (∀J∈set si. is_iface G J ∧ (J,I)∉(subint1 G)⁺)" definition ws_cdecl :: "prog ⇒ qtname ⇒ qtname ⇒ bool" where "ws_cdecl G C sc = (C≠Object ⟶ is_class G sc ∧ (sc,C)∉(subcls1 G)⁺)" definition ws_prog :: "prog ⇒ bool" where "ws_prog G = ((∀(I,i)∈set (ifaces G). ws_idecl G I (isuperIfs i)) ∧ (∀(C,c)∈set (classes G). ws_cdecl G C (super c)))" lemma ws_progI: "⟦∀(I,i)∈set (ifaces G). ∀J∈set (isuperIfs i). is_iface G J ∧ (J,I) ∉ (subint1 G)⁺; ∀(C,c)∈set (classes G). C≠Object ⟶ is_class G (super c) ∧ ((super c),C) ∉ (subcls1 G)⁺ ⟧ ⟹ ws_prog G" apply (unfold ws_prog_def (*‹ws_prog ?G = ((∀(I, i)∈set (ifaces ?G). ws_idecl ?G I (isuperIfs i)) ∧ (∀(C, c)∈set (classes ?G). ws_cdecl ?G C (super c)))›*) ws_idecl_def (*‹ws_idecl ?G ?I ?si = (∀J∈set ?si. is_iface ?G J ∧ (J, ?I) ∉ (subint1 ?G)⁺)›*) ws_cdecl_def (*‹ws_cdecl ?G ?C ?sc = (?C ≠ Object ⟶ is_class ?G ?sc ∧ (?sc, ?C) ∉ (subcls1 ?G)⁺)›*)) (*goal: ‹⟦∀(I, i)∈set (ifaces G). ∀J∈set (isuperIfs i). is_iface G J ∧ (J, I) ∉ (subint1 G)⁺; ∀(C, c)∈set (classes G). C ≠ Object ⟶ is_class G (super c) ∧ (super c, C) ∉ (subcls1 G)⁺⟧ ⟹ ws_prog G›*) apply (erule_tac conjI (*‹⟦?P; ?Q⟧ ⟹ ?P ∧ ?Q›*)) (*goal: ‹⟦∀(I, i)∈set (ifaces G). ∀J∈set (isuperIfs i). is_iface G J ∧ (J, I) ∉ (subint1 G)⁺; ∀(C, c)∈set (classes G). C ≠ Object ⟶ is_class G (super c) ∧ (super c, C) ∉ (subcls1 G)⁺⟧ ⟹ (∀(I, i)∈set (ifaces G). ∀J∈set (isuperIfs i). is_iface G J ∧ (J, I) ∉ (subint1 G)⁺) ∧ (∀(C, c)∈set (classes G). C ≠ Object ⟶ is_class G (super c) ∧ (super c, C) ∉ (subcls1 G)⁺)›*) by blast lemma ws_prog_ideclD: "⟦iface G I = Some i; J∈set (isuperIfs i); ws_prog G⟧ ⟹ is_iface G J ∧ (J,I)∉(subint1 G)⁺" apply (unfold ws_prog_def (*‹ws_prog ?G = ((∀(I, i)∈set (ifaces ?G). ws_idecl ?G I (isuperIfs i)) ∧ (∀(C, c)∈set (classes ?G). ws_cdecl ?G C (super c)))›*) ws_idecl_def (*‹ws_idecl ?G ?I ?si = (∀J∈set ?si. is_iface ?G J ∧ (J, ?I) ∉ (subint1 ?G)⁺)›*)) (*goal: ‹⟦iface (G::prog) (I::qtname) = Some (i::iface); (J::qtname) ∈ set (isuperIfs i); ws_prog G⟧ ⟹ is_iface G J ∧ (J, I) ∉ (subint1 G)⁺›*) apply clarify (*goal: ‹⟦iface (G::prog) (I::qtname) = Some (i::iface); (J::qtname) ∈ set (isuperIfs i); (∀(I::qtname, i::iface)∈set (ifaces G). ∀J::qtname∈set (isuperIfs i). is_iface G J ∧ (J, I) ∉ (subint1 G)⁺) ∧ (∀(C::qtname, c::class)∈set (classes G). ws_cdecl G C (super c))⟧ ⟹ is_iface G J ∧ (J, I) ∉ (subint1 G)⁺›*) apply (drule_tac map_of_SomeD (*‹table_of ?xs ?k = Some ?y ⟹ (?k, ?y) ∈ set ?xs›*)) (*goal: ‹⟦iface G I = Some i; J ∈ set (isuperIfs i); ∀(I, i)∈set (ifaces G). ∀J∈set (isuperIfs i). is_iface G J ∧ (J, I) ∉ (subint1 G)⁺; ∀(C, c)∈set (classes G). ws_cdecl G C (super c)⟧ ⟹ is_iface G J ∧ (J, I) ∉ (subint1 G)⁺›*) by auto lemma ws_prog_cdeclD: "⟦class G C = Some c; C≠Object; ws_prog G⟧ ⟹ is_class G (super c) ∧ (super c,C)∉(subcls1 G)⁺" apply (unfold ws_prog_def (*‹ws_prog (?G::prog) = ((∀(I::qtname, i::iface)∈set (ifaces ?G). ws_idecl ?G I (isuperIfs i)) ∧ (∀(C::qtname, c::class)∈set (classes ?G). ws_cdecl ?G C (super c)))›*) ws_cdecl_def (*‹ws_cdecl (?G::prog) (?C::qtname) (?sc::qtname) = (?C ≠ Object ⟶ is_class ?G ?sc ∧ (?sc, ?C) ∉ (subcls1 ?G)⁺)›*)) (*goal: ‹⟦class G C = Some c; C ≠ Object; ws_prog G⟧ ⟹ is_class G (super c) ∧ (super c, C) ∉ (subcls1 G)⁺›*) apply clarify (*goal: ‹⟦class G C = Some c; C ≠ Object; (∀(I, i)∈set (ifaces G). ws_idecl G I (isuperIfs i)) ∧ (∀(C, c)∈set (classes G). C ≠ Object ⟶ is_class G (super c) ∧ (super c, C) ∉ (subcls1 G)⁺)⟧ ⟹ is_class G (super c) ∧ (super c, C) ∉ (subcls1 G)⁺›*) apply (drule_tac map_of_SomeD (*‹table_of ?xs ?k = Some ?y ⟹ (?k, ?y) ∈ set ?xs›*)) (*goal: ‹⟦class G C = Some c; C ≠ Object; ∀(I, i)∈set (ifaces G). ws_idecl G I (isuperIfs i); ∀(C, c)∈set (classes G). C ≠ Object ⟶ is_class G (super c) ∧ (super c, C) ∉ (subcls1 G)⁺⟧ ⟹ is_class G (super c) ∧ (super c, C) ∉ (subcls1 G)⁺›*) by auto subsubsection "well-foundedness" lemma finite_is_iface: "finite {I. is_iface G I}" apply (fold dom_def) (*goal: ‹finite {I. is_iface G I}›*) by (rule_tac finite_dom_map_of (*‹finite (dom (table_of ?l))›*)) lemma finite_is_class: "finite {C. is_class G C}" apply (fold dom_def) (*goal: ‹finite {C. is_class G C}›*) by (rule_tac finite_dom_map_of (*‹finite (dom (table_of ?l))›*)) lemma finite_subint1: "finite (subint1 G)" apply (subst subint1_def2 (*‹subint1 ?G = (SIGMA I:{I. is_iface ?G I}. set (isuperIfs (the (iface ?G I))))›*)) (*goal: ‹finite (subint1 G)›*) apply (rule finite_SigmaI (*‹⟦finite ?A; ⋀a. a ∈ ?A ⟹ finite (?B a)⟧ ⟹ finite (Sigma ?A ?B)›*)) (*goals: 1. ‹finite {I::qtname. is_iface (G::prog) I}› 2. ‹⋀I::qtname. I ∈ {I::qtname. is_iface (G::prog) I} ⟹ finite (set (isuperIfs (the (iface G I))))› discuss goal 1*) apply (rule finite_is_iface (*‹finite {I. is_iface ?G I}›*)) (*discuss goal 2*) apply (simp (no_asm)) (*proven 2 subgoals*) . lemma finite_subcls1: "finite (subcls1 G)" apply (subst subcls1_def2 (*‹subcls1 ?G = (SIGMA C:{C. is_class ?G C}. {D. C ≠ Object ∧ super (the (class ?G C)) = D})›*)) (*goal: ‹finite (subcls1 G)›*) apply (rule finite_SigmaI (*‹⟦finite ?A; ⋀a. a ∈ ?A ⟹ finite (?B a)⟧ ⟹ finite (Sigma ?A ?B)›*)) (*goals: 1. ‹finite {C. is_class G C}› 2. ‹⋀C. C ∈ {C. is_class G C} ⟹ finite {D. C ≠ Object ∧ super (the (class G C)) = D}› discuss goal 1*) apply (rule finite_is_class (*‹finite {C. is_class ?G C}›*)) (*discuss goal 2*) apply (rule_tac B = "{super (the (class G C))}" in finite_subset (*‹⟦?A ⊆ ?B; finite ?B⟧ ⟹ finite ?A›*)) (*goals: 1. ‹⋀C. C ∈ {C. is_class G C} ⟹ {D. C ≠ Object ∧ super (the (class G C)) = D} ⊆ {super (the (class G C))}› 2. ‹⋀C. C ∈ {C. is_class G C} ⟹ finite {super (the (class G C))}› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) (*proven 2 subgoals*) . lemma subint1_irrefl_lemma1: "ws_prog G ⟹ (subint1 G)¯ ∩ (subint1 G)⁺ = {}" by (force dest: subint1D (*‹(?I, ?J) ∈ subint1 ?G ⟹ ? i:iface ?G ?I: ?J ∈ set (isuperIfs i)›*) ws_prog_ideclD (*‹⟦iface ?G ?I = Some ?i; ?J ∈ set (isuperIfs ?i); ws_prog ?G⟧ ⟹ is_iface ?G ?J ∧ (?J, ?I) ∉ (subint1 ?G)⁺›*) conjunct2 (*‹?P ∧ ?Q ⟹ ?Q›*)) lemma subcls1_irrefl_lemma1: "ws_prog G ⟹ (subcls1 G)¯ ∩ (subcls1 G)⁺ = {}" by (force dest: subcls1D (*‹?G⊢?C≺⇩C1?D ⟹ ?C ≠ Object ∧ (∃c. class ?G ?C = Some c ∧ super c = ?D)›*) ws_prog_cdeclD (*‹⟦class ?G ?C = Some ?c; ?C ≠ Object; ws_prog ?G⟧ ⟹ is_class ?G (super ?c) ∧ (super ?c, ?C) ∉ (subcls1 ?G)⁺›*) conjunct2 (*‹?P ∧ ?Q ⟹ ?Q›*)) lemmas subint1_irrefl_lemma2 = subint1_irrefl_lemma1 [THEN irrefl_tranclI'] lemmas subcls1_irrefl_lemma2 = subcls1_irrefl_lemma1 [THEN irrefl_tranclI'] lemma subint1_irrefl: "⟦(x, y) ∈ subint1 G; ws_prog G⟧ ⟹ x ≠ y" apply (rule irrefl_trancl_rD (*‹⟦∀x. (x, x) ∉ ?r⁺; (?x, ?y) ∈ ?r⟧ ⟹ ?x ≠ ?y›*)) (*goals: 1. ‹⟦(x::qtname, y::qtname) ∈ subint1 (G::prog); ws_prog G⟧ ⟹ ∀x::qtname. (x, x) ∉ (?r::(qtname × qtname) set)⁺› 2. ‹⟦(x::qtname, y::qtname) ∈ subint1 (G::prog); ws_prog G⟧ ⟹ (x, y) ∈ (?r::(qtname × qtname) set)› discuss goal 1*) apply (rule subint1_irrefl_lemma2 (*‹ws_prog (?G::prog) ⟹ ∀x::qtname. (x, x) ∉ (subint1 ?G)⁺›*)) (*top goal: ‹⟦(x, y) ∈ subint1 G; ws_prog G⟧ ⟹ ∀x. (x, x) ∉ ?r⁺› and 1 goal remains*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . lemma subcls1_irrefl: "⟦(x, y) ∈ subcls1 G; ws_prog G⟧ ⟹ x ≠ y" apply (rule irrefl_trancl_rD (*‹⟦∀x. (x, x) ∉ ?r⁺; (?x, ?y) ∈ ?r⟧ ⟹ ?x ≠ ?y›*)) (*goals: 1. ‹⟦G⊢x≺⇩C1y; ws_prog G⟧ ⟹ ∀x. (x, x) ∉ ?r⁺› 2. ‹⟦G⊢x≺⇩C1y; ws_prog G⟧ ⟹ (x, y) ∈ ?r› discuss goal 1*) apply (rule subcls1_irrefl_lemma2 (*‹ws_prog ?G ⟹ ∀x. (x, x) ∉ (subcls1 ?G)⁺›*)) (*top goal: ‹⟦G⊢x≺⇩C1y; ws_prog G⟧ ⟹ ∀x. (x, x) ∉ ?r⁺› and 1 goal remains*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . lemmas subint1_acyclic = subint1_irrefl_lemma2 [THEN acyclicI] lemmas subcls1_acyclic = subcls1_irrefl_lemma2 [THEN acyclicI] lemma wf_subint1: "ws_prog G ⟹ wf ((subint1 G)¯)" by (auto intro: finite_acyclic_wf_converse (*‹⟦finite ?r; acyclic ?r⟧ ⟹ wf (?r¯)›*) finite_subint1 (*‹finite (subint1 ?G)›*) subint1_acyclic (*‹ws_prog ?G ⟹ acyclic (subint1 ?G)›*)) lemma wf_subcls1: "ws_prog G ⟹ wf ((subcls1 G)¯)" by (auto intro: finite_acyclic_wf_converse (*‹⟦finite ?r; acyclic ?r⟧ ⟹ wf (?r¯)›*) finite_subcls1 (*‹finite (subcls1 ?G)›*) subcls1_acyclic (*‹ws_prog ?G ⟹ acyclic (subcls1 ?G)›*)) lemma subint1_induct: "⟦ws_prog G; ⋀x. ∀y. (x, y) ∈ subint1 G ⟶ P y ⟹ P x⟧ ⟹ P a" apply (frule wf_subint1 (*‹ws_prog ?G ⟹ wf ((subint1 ?G)¯)›*)) (*goal: ‹⟦ws_prog G; ⋀x. ∀y. (x, y) ∈ subint1 G ⟶ P y ⟹ P x⟧ ⟹ P a›*) apply (erule wf_induct (*‹⟦wf (?r::(?'a × ?'a) set); ⋀x::?'a. ∀y::?'a. (y, x) ∈ ?r ⟶ (?P::?'a ⇒ bool) y ⟹ ?P x⟧ ⟹ ?P (?a::?'a)›*)) (*goal: ‹⟦ws_prog G; ⋀x. ∀y. (x, y) ∈ subint1 G ⟶ P y ⟹ P x; wf ((subint1 G)¯)⟧ ⟹ P a›*) apply (simp (no_asm_use) only: converse_iff (*‹((?a::?'a, ?b::?'b) ∈ (?r::(?'b × ?'a) set)¯) = ((?b, ?a) ∈ ?r)›*)) (*goal: ‹⋀x. ⟦ws_prog G; ⋀x. ∀y. (x, y) ∈ subint1 G ⟶ P y ⟹ P x; ∀y. (y, x) ∈ (subint1 G)¯ ⟶ P y⟧ ⟹ P x›*) by blast lemma subcls1_induct [consumes 1]: "⟦ws_prog G; ⋀x. ∀y. (x, y) ∈ subcls1 G ⟶ P y ⟹ P x⟧ ⟹ P a" apply (frule wf_subcls1 (*‹ws_prog ?G ⟹ wf ((subcls1 ?G)¯)›*)) (*goal: ‹⟦ws_prog (G::prog); ⋀x::qtname. ∀y::qtname. G⊢x≺⇩C1y ⟶ (P::qtname ⇒ bool) y ⟹ P x⟧ ⟹ P (a::qtname)›*) apply (erule wf_induct (*‹⟦wf (?r::(?'a × ?'a) set); ⋀x::?'a. ∀y::?'a. (y, x) ∈ ?r ⟶ (?P::?'a ⇒ bool) y ⟹ ?P x⟧ ⟹ ?P (?a::?'a)›*)) (*goal: ‹⟦ws_prog G; ⋀x. ∀y. G⊢x≺⇩C1y ⟶ P y ⟹ P x; wf ((subcls1 G)¯)⟧ ⟹ P a›*) apply (simp (no_asm_use) only: converse_iff (*‹((?a, ?b) ∈ ?r¯) = ((?b, ?a) ∈ ?r)›*)) (*goal: ‹⋀x. ⟦ws_prog G; ⋀x. ∀y. G⊢x≺⇩C1y ⟶ P y ⟹ P x; ∀y. (y, x) ∈ (subcls1 G)¯ ⟶ P y⟧ ⟹ P x›*) by blast lemma ws_subint1_induct: "⟦is_iface G I; ws_prog G; ⋀I i. ⟦iface G I = Some i ∧ (∀J ∈ set (isuperIfs i). (I,J)∈subint1 G ∧ P J ∧ is_iface G J)⟧ ⟹ P I ⟧ ⟹ P I" apply (erule rev_mp (*‹⟦?P; ?P ⟶ ?Q⟧ ⟹ ?Q›*)) (*goal: ‹⟦is_iface G I; ws_prog G; ⋀I i. iface G I = Some i ∧ (∀J∈set (isuperIfs i). (I, J) ∈ subint1 G ∧ P J ∧ is_iface G J) ⟹ P I⟧ ⟹ P I›*) apply (rule subint1_induct (*‹⟦ws_prog ?G; ⋀x. ∀y. (x, y) ∈ subint1 ?G ⟶ ?P y ⟹ ?P x⟧ ⟹ ?P ?a›*)) (*goals: 1. ‹⟦ws_prog G; ⋀I i. iface G I = Some i ∧ (∀J∈set (isuperIfs i). (I, J) ∈ subint1 G ∧ P J ∧ is_iface G J) ⟹ P I⟧ ⟹ ws_prog ?G2› 2. ‹⋀x. ⟦ws_prog G; ⋀I i. iface G I = Some i ∧ (∀J∈set (isuperIfs i). (I, J) ∈ subint1 G ∧ P J ∧ is_iface G J) ⟹ P I; ∀y. (x, y) ∈ subint1 ?G2 ⟶ is_iface G y ⟶ P y⟧ ⟹ is_iface G x ⟶ P x› discuss goal 1*) apply assumption (*discuss goal 2*) apply (simp (no_asm)) (*goal: ‹⋀x. ⟦ws_prog G; ⋀I i. iface G I = Some i ∧ (∀J∈set (isuperIfs i). (I, J) ∈ subint1 G ∧ P J ∧ is_iface G J) ⟹ P I; ∀y. (x, y) ∈ subint1 G ⟶ is_iface G y ⟶ P y⟧ ⟹ is_iface G x ⟶ P x›*) apply safe (*goal: ‹⋀x::qtname. ⟦ws_prog (G::prog); ⋀(I::qtname) i::iface. iface G I = Some i ∧ (∀J::qtname∈set (isuperIfs i). (I, J) ∈ subint1 G ∧ (P::qtname ⇒ bool) J ∧ is_iface G J) ⟹ P I; ∀y::qtname. (x, y) ∈ subint1 G ⟶ is_iface G y ⟶ P y⟧ ⟹ (∃y::iface. iface G x = Some y) ⟶ P x›*) apply (blast dest: subint1I (*‹⟦iface ?G ?I = Some ?i; ?J ∈ set (isuperIfs ?i)⟧ ⟹ (?I, ?J) ∈ subint1 ?G›*) ws_prog_ideclD (*‹⟦iface ?G ?I = Some ?i; ?J ∈ set (isuperIfs ?i); ws_prog ?G⟧ ⟹ is_iface ?G ?J ∧ (?J, ?I) ∉ (subint1 ?G)⁺›*)) (*proven 2 subgoals*) . lemma ws_subcls1_induct: "⟦is_class G C; ws_prog G; ⋀C c. ⟦class G C = Some c; (C ≠ Object ⟶ (C,(super c))∈subcls1 G ∧ P (super c) ∧ is_class G (super c))⟧ ⟹ P C ⟧ ⟹ P C" apply (erule rev_mp (*‹⟦?P; ?P ⟶ ?Q⟧ ⟹ ?Q›*)) (*goal: ‹⟦is_class G C; ws_prog G; ⋀C c. ⟦class G C = Some c; C ≠ Object ⟶ G⊢C≺⇩C1super c ∧ P (super c) ∧ is_class G (super c)⟧ ⟹ P C⟧ ⟹ P C›*) apply (rule subcls1_induct (*‹⟦ws_prog ?G; ⋀x. ∀y. ?G⊢x≺⇩C1y ⟶ ?P y ⟹ ?P x⟧ ⟹ ?P ?a›*)) (*goals: 1. ‹⟦ws_prog G; ⋀C c. ⟦class G C = Some c; C ≠ Object ⟶ G⊢C≺⇩C1super c ∧ P (super c) ∧ is_class G (super c)⟧ ⟹ P C⟧ ⟹ ws_prog ?G2› 2. ‹⋀x. ⟦ws_prog G; ⋀C c. ⟦class G C = Some c; C ≠ Object ⟶ G⊢C≺⇩C1super c ∧ P (super c) ∧ is_class G (super c)⟧ ⟹ P C; ∀y. ?G2⊢x≺⇩C1y ⟶ is_class G y ⟶ P y⟧ ⟹ is_class G x ⟶ P x› discuss goal 1*) apply assumption (*discuss goal 2*) apply (simp (no_asm)) (*goal: ‹⋀x. ⟦ws_prog G; ⋀C c. ⟦class G C = Some c; C ≠ Object ⟶ G⊢C≺⇩C1super c ∧ P (super c) ∧ is_class G (super c)⟧ ⟹ P C; ∀y. G⊢x≺⇩C1y ⟶ is_class G y ⟶ P y⟧ ⟹ is_class G x ⟶ P x›*) apply safe (*goal: ‹⋀x. ⟦ws_prog G; ⋀C c. ⟦class G C = Some c; C ≠ Object ⟶ G⊢C≺⇩C1super c ∧ P (super c) ∧ is_class G (super c)⟧ ⟹ P C; ∀y. G⊢x≺⇩C1y ⟶ is_class G y ⟶ P y⟧ ⟹ (∃y. class G x = Some y) ⟶ P x›*) apply (fast dest: subcls1I (*‹⟦class ?G ?C = Some ?c; ?C ≠ Object⟧ ⟹ ?G⊢?C≺⇩C1super ?c›*) ws_prog_cdeclD (*‹⟦class ?G ?C = Some ?c; ?C ≠ Object; ws_prog ?G⟧ ⟹ is_class ?G (super ?c) ∧ (super ?c, ?C) ∉ (subcls1 ?G)⁺›*)) (*proven 2 subgoals*) . lemma ws_class_induct [consumes 2, case_names Object Subcls]: "⟦class G C = Some c; ws_prog G; ⋀ co. class G Object = Some co ⟹ P Object; ⋀ C c. ⟦class G C = Some c; C ≠ Object; P (super c)⟧ ⟹ P C ⟧ ⟹ P C" proof (-) (*goal: ‹⟦class (G::prog) (C::qtname) = Some (c::class); ws_prog G; ⋀co::class. class G Object = Some co ⟹ (P::qtname ⇒ bool) Object; ⋀(C::qtname) c::class. ⟦class G C = Some c; C ≠ Object; P (super c)⟧ ⟹ P C⟧ ⟹ P C›*) assume clsC: "class G C = Some c" and init: "⋀ co. class G Object = Some co ⟹ P Object" and step: "⋀ C c. ⟦class G C = Some c; C ≠ Object; P (super c)⟧ ⟹ P C" (*‹class (G::prog) (C::qtname) = Some (c::class)› ‹class (G::prog) Object = Some (?co::class) ⟹ (P::qtname ⇒ bool) Object› ‹⟦class (G::prog) (?C::qtname) = Some (?c::class); ?C ≠ Object; (P::qtname ⇒ bool) (super ?c)⟧ ⟹ P ?C›*) assume ws: "ws_prog G" (*‹ws_prog (G::prog)›*) then have "is_class G C ⟹ P C" proof (induct rule: subcls1_induct (*‹⟦ws_prog ?G; ⋀x. ∀y. ?G⊢x≺⇩C1y ⟶ ?P y ⟹ ?P x⟧ ⟹ ?P ?a›*)) (*goal: ‹⋀x. ⟦∀y. G⊢x≺⇩C1y ⟶ is_class G y ⟶ P y; is_class G x⟧ ⟹ P x›*) fix C assume hyp: "∀ S. G⊢C ≺⇩C1 S ⟶ is_class G S ⟶ P S" and iscls: "is_class G C" (*‹∀S::qtname. (G::prog)⊢(C::qtname)≺⇩C1S ⟶ is_class G S ⟶ (P::qtname ⇒ bool) S› ‹is_class (G::prog) (C::qtname)›*) show "P C" proof (cases "C=Object") (*goals: 1. ‹C = Object ⟹ P C› 2. ‹C ≠ Object ⟹ P C›*) case True (*‹(C::qtname) = Object›*) with iscls (*‹is_class G C›*) init (*‹class G Object = Some ?co ⟹ P Object›*) show "P C" by auto next (*goal: ‹C ≠ Object ⟹ P C›*) case False (*‹C ≠ Object›*) with ws (*‹ws_prog (G::prog)›*) step (*‹⟦class G ?C = Some ?c; ?C ≠ Object; P (super ?c)⟧ ⟹ P ?C›*) hyp (*‹∀S. G⊢C≺⇩C1S ⟶ is_class G S ⟶ P S›*) iscls (*‹is_class G C›*) show "P C" by (auto dest: subcls1I (*‹⟦class ?G ?C = Some ?c; ?C ≠ Object⟧ ⟹ ?G⊢?C≺⇩C1super ?c›*) ws_prog_cdeclD (*‹⟦class ?G ?C = Some ?c; ?C ≠ Object; ws_prog ?G⟧ ⟹ is_class ?G (super ?c) ∧ (super ?c, ?C) ∉ (subcls1 ?G)⁺›*)) qed qed with clsC (*‹class G C = Some c›*) show "?thesis" (*goal: ‹(P::qtname ⇒ bool) (C::qtname)›*) by simp qed lemma ws_class_induct' [consumes 2, case_names Object Subcls]: "⟦is_class G C; ws_prog G; ⋀ co. class G Object = Some co ⟹ P Object; ⋀ C c. ⟦class G C = Some c; C ≠ Object; P (super c)⟧ ⟹ P C ⟧ ⟹ P C" by (auto intro: ws_class_induct (*‹⟦class ?G ?C = Some ?c; ws_prog ?G; ⋀co. class ?G Object = Some co ⟹ ?P Object; ⋀C c. ⟦class ?G C = Some c; C ≠ Object; ?P (super c)⟧ ⟹ ?P C⟧ ⟹ ?P ?C›*)) lemma ws_class_induct'' [consumes 2, case_names Object Subcls]: "⟦class G C = Some c; ws_prog G; ⋀ co. class G Object = Some co ⟹ P Object co; ⋀ C c sc. ⟦class G C = Some c; class G (super c) = Some sc; C ≠ Object; P (super c) sc⟧ ⟹ P C c ⟧ ⟹ P C c" proof (-) (*goal: ‹⟦class G C = Some c; ws_prog G; ⋀co. class G Object = Some co ⟹ P Object co; ⋀C c sc. ⟦class G C = Some c; class G (super c) = Some sc; C ≠ Object; P (super c) sc⟧ ⟹ P C c⟧ ⟹ P C c›*) assume clsC: "class G C = Some c" and init: "⋀ co. class G Object = Some co ⟹ P Object co" and step: "⋀ C c sc . ⟦class G C = Some c; class G (super c) = Some sc; C ≠ Object; P (super c) sc⟧ ⟹ P C c" (*‹class (G::prog) (C::qtname) = Some (c::class)› ‹class (G::prog) Object = Some (?co::class) ⟹ (P::qtname ⇒ class ⇒ bool) Object ?co› ‹⟦class (G::prog) (?C::qtname) = Some (?c::class); class G (super ?c) = Some (?sc::class); ?C ≠ Object; (P::qtname ⇒ class ⇒ bool) (super ?c) ?sc⟧ ⟹ P ?C ?c›*) assume ws: "ws_prog G" (*‹ws_prog (G::prog)›*) then have "⋀ c. class G C = Some c⟹ P C c" proof (induct rule: subcls1_induct (*‹⟦ws_prog (?G::prog); ⋀x::qtname. ∀y::qtname. ?G⊢x≺⇩C1y ⟶ (?P::qtname ⇒ bool) y ⟹ ?P x⟧ ⟹ ?P (?a::qtname)›*)) (*goal: ‹⋀x c. ⟦∀y. G⊢x≺⇩C1y ⟶ (∀x. class G y = Some x ⟶ P y x); class G x = Some c⟧ ⟹ P x c›*) fix C and c assume hyp: "∀ S. G⊢C ≺⇩C1 S ⟶ (∀ s. class G S = Some s ⟶ P S s)" and iscls: "class G C = Some c" (*‹∀S::qtname. (G::prog)⊢(C::qtname)≺⇩C1S ⟶ (∀s::class. class G S = Some s ⟶ (P::qtname ⇒ class ⇒ bool) S s)› ‹class (G::prog) (C::qtname) = Some (c::class)›*) show "P C c" proof (cases "C=Object") (*goals: 1. ‹C = Object ⟹ P C c› 2. ‹C ≠ Object ⟹ P C c›*) case True (*‹C = Object›*) with iscls (*‹class G C = Some c›*) init (*‹class G Object = Some ?co ⟹ P Object ?co›*) show "P C c" by auto next (*goal: ‹C ≠ Object ⟹ P C c›*) case False (*‹C ≠ Object›*) with ws (*‹ws_prog G›*) iscls (*‹class G C = Some c›*) obtain sc where sc: "class G (super c) = Some sc" (*goal: ‹(⋀sc::class. class (G::prog) (super (c::class)) = Some sc ⟹ thesis::bool) ⟹ thesis›*) by (auto dest: ws_prog_cdeclD (*‹⟦class ?G ?C = Some ?c; ?C ≠ Object; ws_prog ?G⟧ ⟹ is_class ?G (super ?c) ∧ (super ?c, ?C) ∉ (subcls1 ?G)⁺›*)) from iscls (*‹class (G::prog) (C::qtname) = Some (c::class)›*) False (*‹C ≠ Object›*) have "G⊢C ≺⇩C1 (super c)" by (rule subcls1I (*‹⟦class (?G::prog) (?C::qtname) = Some (?c::class); ?C ≠ Object⟧ ⟹ ?G⊢?C≺⇩C1super ?c›*)) with False (*‹C ≠ Object›*) ws (*‹ws_prog G›*) step (*‹⟦class G ?C = Some ?c; class G (super ?c) = Some ?sc; ?C ≠ Object; P (super ?c) ?sc⟧ ⟹ P ?C ?c›*) hyp (*‹∀S. G⊢C≺⇩C1S ⟶ (∀s. class G S = Some s ⟶ P S s)›*) iscls (*‹class G C = Some c›*) sc (*‹class G (super c) = Some sc›*) show "P C c" by auto qed qed with clsC (*‹class G C = Some c›*) show "P C c" by auto qed lemma ws_interface_induct [consumes 2, case_names Step]: assumes is_if_I: "is_iface G I" and ws: "ws_prog G" and hyp_sub: "⋀I i. ⟦iface G I = Some i; ∀ J ∈ set (isuperIfs i). (I,J)∈subint1 G ∧ P J ∧ is_iface G J⟧ ⟹ P I" shows "P I" proof (-) (*goal: ‹P I›*) from is_if_I (*‹is_iface G I›*) ws (*‹ws_prog G›*) show "P I" proof (rule ws_subint1_induct (*‹⟦is_iface (?G::prog) (?I::qtname); ws_prog ?G; ⋀(I::qtname) i::iface. iface ?G I = Some i ∧ (∀J::qtname∈set (isuperIfs i). (I, J) ∈ subint1 ?G ∧ (?P::qtname ⇒ bool) J ∧ is_iface ?G J) ⟹ ?P I⟧ ⟹ ?P ?I›*)) (*goal: ‹⋀I i. iface G I = Some i ∧ (∀J∈set (isuperIfs i). (I, J) ∈ subint1 G ∧ P J ∧ is_iface G J) ⟹ P I›*) fix I and i assume hyp: "iface G I = Some i ∧ (∀J∈set (isuperIfs i). (I,J) ∈subint1 G ∧ P J ∧ is_iface G J)" (*‹iface (G::prog) (I::qtname) = Some (i::iface) ∧ (∀J::qtname∈set (isuperIfs i). (I, J) ∈ subint1 G ∧ (P::qtname ⇒ bool) J ∧ is_iface G J)›*) then have if_I: "iface G I = Some i" by blast show "P I" proof (cases "isuperIfs i") (*goals: 1. ‹isuperIfs i = [] ⟹ P I› 2. ‹⋀a list. isuperIfs i = a # list ⟹ P I›*) case Nil (*‹isuperIfs i = []›*) with if_I (*‹iface G I = Some i›*) hyp_sub (*‹⟦iface (G::prog) (?I::qtname) = Some (?i::iface); ∀J::qtname∈set (isuperIfs ?i). (?I, J) ∈ subint1 G ∧ (P::qtname ⇒ bool) J ∧ is_iface G J⟧ ⟹ P ?I›*) show "P I" by auto next (*goal: ‹⋀a list. isuperIfs i = a # list ⟹ P I›*) case (Cons hd tl) (*‹isuperIfs (i::iface) = (hd::qtname) # (tl::qtname list)›*) with hyp (*‹iface G I = Some i ∧ (∀J∈set (isuperIfs i). (I, J) ∈ subint1 G ∧ P J ∧ is_iface G J)›*) if_I (*‹iface G I = Some i›*) hyp_sub (*‹⟦iface G ?I = Some ?i; ∀J∈set (isuperIfs ?i). (?I, J) ∈ subint1 G ∧ P J ∧ is_iface G J⟧ ⟹ P ?I›*) show "P I" by auto qed qed qed subsubsection "general recursion operators for the interface and class hiearchies" function iface_rec :: "prog ⇒ qtname ⇒ (qtname ⇒ iface ⇒ 'a set ⇒ 'a) ⇒ 'a" where [simp del]: "iface_rec G I f = (case iface G I of None ⇒ undefined | Some i ⇒ if ws_prog G then f I i ((λJ. iface_rec G J f)`set (isuperIfs i)) else undefined)" by auto termination by (relation "inv_image (same_fst ws_prog (λG. (subint1 G)¯)) (%(x,y,z). (x,y))") (auto simp: wf_subint1 subint1I wf_same_fst) lemma iface_rec: "⟦iface G I = Some i; ws_prog G⟧ ⟹ iface_rec G I f = f I i ((λJ. iface_rec G J f)`set (isuperIfs i))" apply (subst iface_rec.simps (*‹iface_rec ?G ?I ?f = (case iface ?G ?I of Some i ⇒ if ws_prog ?G then ?f ?I i ((λJ. iface_rec ?G J ?f) ` set (isuperIfs i)) else undefined)›*)) (*goal: ‹⟦iface G I = Some i; ws_prog G⟧ ⟹ iface_rec G I f = f I i ((λJ. iface_rec G J f) ` set (isuperIfs i))›*) by simp function class_rec :: "prog ⇒ qtname ⇒ 'a ⇒ (qtname ⇒ class ⇒ 'a ⇒ 'a) ⇒ 'a" where [simp del]: "class_rec G C t f = (case class G C of None ⇒ undefined | Some c ⇒ if ws_prog G then f C c (if C = Object then t else class_rec G (super c) t f) else undefined)" by auto termination by (relation "inv_image (same_fst ws_prog (λG. (subcls1 G)¯)) (%(x,y,z,w). (x,y))") (auto simp: wf_subcls1 subcls1I wf_same_fst) lemma class_rec: "⟦class G C = Some c; ws_prog G⟧ ⟹ class_rec G C t f = f C c (if C = Object then t else class_rec G (super c) t f)" apply (subst class_rec.simps (*‹class_rec ?G ?C ?t ?f = (case class ?G ?C of Some c ⇒ if ws_prog ?G then ?f ?C c (if ?C = Object then ?t else class_rec ?G (super c) ?t ?f) else undefined)›*)) (*goal: ‹⟦class G C = Some c; ws_prog G⟧ ⟹ class_rec G C t f = f C c (if C = Object then t else class_rec G (super c) t f)›*) by simp definition imethds :: "prog ⇒ qtname ⇒ (sig,qtname × mhead) tables" where ― ‹methods of an interface, with overriding and inheritance, cf. 9.2› "imethds G I = iface_rec G I (λI i ts. (Un_tables ts) ⊕⊕ (set_option ∘ table_of (map (λ(s,m). (s,I,m)) (imethods i))))" end
{ "path": "Isabelle2024/src/HOL/Bali/Decl.thy", "repo": "Isabelle2024", "sha": "dfafb4961b1247163675611012744287cebdf0d51f431d1d2dbeda059760f593" }
theory "Ids" imports Complex_Main begin section ‹Identifier locale› text ‹The differential dynamic logic formalization is parameterized by the type of identifiers. The identifier type(s) must be finite and have at least 3-4 distinct elements. Distinctness is required for soundness of some axioms. › locale ids = fixes vid1 :: "('sz::{finite,linorder})" fixes vid2 :: 'sz fixes vid3 :: 'sz fixes fid1 :: "('sf::finite)" fixes fid2 :: 'sf fixes fid3 :: 'sf fixes pid1 :: "('sc::finite)" fixes pid2 :: 'sc fixes pid3 :: 'sc fixes pid4 :: 'sc assumes vne12:"vid1 ≠ vid2" assumes vne23:"vid2 ≠ vid3" assumes vne13:"vid1 ≠ vid3" assumes fne12:"fid1 ≠ fid2" assumes fne23:"fid2 ≠ fid3" assumes fne13:"fid1 ≠ fid3" assumes pne12:"pid1 ≠ pid2" assumes pne23:"pid2 ≠ pid3" assumes pne13:"pid1 ≠ pid3" assumes pne14:"pid1 ≠ pid4" assumes pne24:"pid2 ≠ pid4" assumes pne34:"pid3 ≠ pid4" context ids begin lemma id_simps: "(vid1 = vid2) = False" "(vid2 = vid3) = False" "(vid1 = vid3) = False" "(fid1 = fid2) = False" "(fid2 = fid3) = False" "(fid1 = fid3) = False" "(pid1 = pid2) = False" "(pid2 = pid3) = False" "(pid1 = pid3) = False" "(pid1 = pid4) = False" "(pid2 = pid4) = False" "(pid3 = pid4) = False" "(vid2 = vid1) = False" "(vid3 = vid2) = False" "(vid3 = vid1) = False" "(fid2 = fid1) = False" "(fid3 = fid2) = False" "(fid3 = fid1) = False" "(pid2 = pid1) = False" "(pid3 = pid2) = False" "(pid3 = pid1) = False" "(pid4 = pid1) = False" "(pid4 = pid2) = False" "(pid4 = pid3) = False" using vne12 (*‹(vid1::'sz) ≠ (vid2::'sz)›*) vne23 (*‹vid2 ≠ vid3›*) vne13 (*‹vid1 ≠ vid3›*) fne12 (*‹fid1 ≠ fid2›*) fne23 (*‹fid2 ≠ fid3›*) fne13 (*‹fid1 ≠ fid3›*) pne12 (*‹(pid1::'sc::finite) ≠ (pid2::'sc::finite)›*) pne23 (*‹pid2 ≠ pid3›*) pne13 (*‹pid1 ≠ pid3›*) pne14 (*‹pid1 ≠ pid4›*) pne24 (*‹pid2 ≠ pid4›*) pne34 (*‹(pid3::'sc::finite) ≠ (pid4::'sc::finite)›*) apply - (*goals: 1. ‹⟦vid1 ≠ vid2; vid2 ≠ vid3; vid1 ≠ vid3; fid1 ≠ fid2; fid2 ≠ fid3; fid1 ≠ fid3; pid1 ≠ pid2; pid2 ≠ pid3; pid1 ≠ pid3; pid1 ≠ pid4; pid2 ≠ pid4; pid3 ≠ pid4⟧ ⟹ (vid1 = vid2) = False› 2. ‹⟦vid1 ≠ vid2; vid2 ≠ vid3; vid1 ≠ vid3; fid1 ≠ fid2; fid2 ≠ fid3; fid1 ≠ fid3; pid1 ≠ pid2; pid2 ≠ pid3; pid1 ≠ pid3; pid1 ≠ pid4; pid2 ≠ pid4; pid3 ≠ pid4⟧ ⟹ (vid2 = vid3) = False› 3. ‹⟦vid1 ≠ vid2; vid2 ≠ vid3; vid1 ≠ vid3; fid1 ≠ fid2; fid2 ≠ fid3; fid1 ≠ fid3; pid1 ≠ pid2; pid2 ≠ pid3; pid1 ≠ pid3; pid1 ≠ pid4; pid2 ≠ pid4; pid3 ≠ pid4⟧ ⟹ (vid1 = vid3) = False› 4. ‹⟦vid1 ≠ vid2; vid2 ≠ vid3; vid1 ≠ vid3; fid1 ≠ fid2; fid2 ≠ fid3; fid1 ≠ fid3; pid1 ≠ pid2; pid2 ≠ pid3; pid1 ≠ pid3; pid1 ≠ pid4; pid2 ≠ pid4; pid3 ≠ pid4⟧ ⟹ (fid1 = fid2) = False› 5. ‹⟦vid1 ≠ vid2; vid2 ≠ vid3; vid1 ≠ vid3; fid1 ≠ fid2; fid2 ≠ fid3; fid1 ≠ fid3; pid1 ≠ pid2; pid2 ≠ pid3; pid1 ≠ pid3; pid1 ≠ pid4; pid2 ≠ pid4; pid3 ≠ pid4⟧ ⟹ (fid2 = fid3) = False› 6. ‹⟦vid1 ≠ vid2; vid2 ≠ vid3; vid1 ≠ vid3; fid1 ≠ fid2; fid2 ≠ fid3; fid1 ≠ fid3; pid1 ≠ pid2; pid2 ≠ pid3; pid1 ≠ pid3; pid1 ≠ pid4; pid2 ≠ pid4; pid3 ≠ pid4⟧ ⟹ (fid1 = fid3) = False› 7. ‹⟦vid1 ≠ vid2; vid2 ≠ vid3; vid1 ≠ vid3; fid1 ≠ fid2; fid2 ≠ fid3; fid1 ≠ fid3; pid1 ≠ pid2; pid2 ≠ pid3; pid1 ≠ pid3; pid1 ≠ pid4; pid2 ≠ pid4; pid3 ≠ pid4⟧ ⟹ (pid1 = pid2) = False› 8. ‹⟦vid1 ≠ vid2; vid2 ≠ vid3; vid1 ≠ vid3; fid1 ≠ fid2; fid2 ≠ fid3; fid1 ≠ fid3; pid1 ≠ pid2; pid2 ≠ pid3; pid1 ≠ pid3; pid1 ≠ pid4; pid2 ≠ pid4; pid3 ≠ pid4⟧ ⟹ (pid2 = pid3) = False› 9. ‹⟦vid1 ≠ vid2; vid2 ≠ vid3; vid1 ≠ vid3; fid1 ≠ fid2; fid2 ≠ fid3; fid1 ≠ fid3; pid1 ≠ pid2; pid2 ≠ pid3; pid1 ≠ pid3; pid1 ≠ pid4; pid2 ≠ pid4; pid3 ≠ pid4⟧ ⟹ (pid1 = pid3) = False› 10. ‹⟦vid1 ≠ vid2; vid2 ≠ vid3; vid1 ≠ vid3; fid1 ≠ fid2; fid2 ≠ fid3; fid1 ≠ fid3; pid1 ≠ pid2; pid2 ≠ pid3; pid1 ≠ pid3; pid1 ≠ pid4; pid2 ≠ pid4; pid3 ≠ pid4⟧ ⟹ (pid1 = pid4) = False› 11. ‹⟦vid1 ≠ vid2; vid2 ≠ vid3; vid1 ≠ vid3; fid1 ≠ fid2; fid2 ≠ fid3; fid1 ≠ fid3; pid1 ≠ pid2; pid2 ≠ pid3; pid1 ≠ pid3; pid1 ≠ pid4; pid2 ≠ pid4; pid3 ≠ pid4⟧ ⟹ (pid2 = pid4) = False› 12. ‹⟦vid1 ≠ vid2; vid2 ≠ vid3; vid1 ≠ vid3; fid1 ≠ fid2; fid2 ≠ fid3; fid1 ≠ fid3; pid1 ≠ pid2; pid2 ≠ pid3; pid1 ≠ pid3; pid1 ≠ pid4; pid2 ≠ pid4; pid3 ≠ pid4⟧ ⟹ (pid3 = pid4) = False› 13. ‹⟦vid1 ≠ vid2; vid2 ≠ vid3; vid1 ≠ vid3; fid1 ≠ fid2; fid2 ≠ fid3; fid1 ≠ fid3; pid1 ≠ pid2; pid2 ≠ pid3; pid1 ≠ pid3; pid1 ≠ pid4; pid2 ≠ pid4; pid3 ≠ pid4⟧ ⟹ (vid2 = vid1) = False› 14. ‹⟦vid1 ≠ vid2; vid2 ≠ vid3; vid1 ≠ vid3; fid1 ≠ fid2; fid2 ≠ fid3; fid1 ≠ fid3; pid1 ≠ pid2; pid2 ≠ pid3; pid1 ≠ pid3; pid1 ≠ pid4; pid2 ≠ pid4; pid3 ≠ pid4⟧ ⟹ (vid3 = vid2) = False› 15. ‹⟦vid1 ≠ vid2; vid2 ≠ vid3; vid1 ≠ vid3; fid1 ≠ fid2; fid2 ≠ fid3; fid1 ≠ fid3; pid1 ≠ pid2; pid2 ≠ pid3; pid1 ≠ pid3; pid1 ≠ pid4; pid2 ≠ pid4; pid3 ≠ pid4⟧ ⟹ (vid3 = vid1) = False› 16. ‹⟦vid1 ≠ vid2; vid2 ≠ vid3; vid1 ≠ vid3; fid1 ≠ fid2; fid2 ≠ fid3; fid1 ≠ fid3; pid1 ≠ pid2; pid2 ≠ pid3; pid1 ≠ pid3; pid1 ≠ pid4; pid2 ≠ pid4; pid3 ≠ pid4⟧ ⟹ (fid2 = fid1) = False› 17. ‹⟦vid1 ≠ vid2; vid2 ≠ vid3; vid1 ≠ vid3; fid1 ≠ fid2; fid2 ≠ fid3; fid1 ≠ fid3; pid1 ≠ pid2; pid2 ≠ pid3; pid1 ≠ pid3; pid1 ≠ pid4; pid2 ≠ pid4; pid3 ≠ pid4⟧ ⟹ (fid3 = fid2) = False› 18. ‹⟦vid1 ≠ vid2; vid2 ≠ vid3; vid1 ≠ vid3; fid1 ≠ fid2; fid2 ≠ fid3; fid1 ≠ fid3; pid1 ≠ pid2; pid2 ≠ pid3; pid1 ≠ pid3; pid1 ≠ pid4; pid2 ≠ pid4; pid3 ≠ pid4⟧ ⟹ (fid3 = fid1) = False› 19. ‹⟦vid1 ≠ vid2; vid2 ≠ vid3; vid1 ≠ vid3; fid1 ≠ fid2; fid2 ≠ fid3; fid1 ≠ fid3; pid1 ≠ pid2; pid2 ≠ pid3; pid1 ≠ pid3; pid1 ≠ pid4; pid2 ≠ pid4; pid3 ≠ pid4⟧ ⟹ (pid2 = pid1) = False› 20. ‹⟦vid1 ≠ vid2; vid2 ≠ vid3; vid1 ≠ vid3; fid1 ≠ fid2; fid2 ≠ fid3; fid1 ≠ fid3; pid1 ≠ pid2; pid2 ≠ pid3; pid1 ≠ pid3; pid1 ≠ pid4; pid2 ≠ pid4; pid3 ≠ pid4⟧ ⟹ (pid3 = pid2) = False› 21. ‹⟦vid1 ≠ vid2; vid2 ≠ vid3; vid1 ≠ vid3; fid1 ≠ fid2; fid2 ≠ fid3; fid1 ≠ fid3; pid1 ≠ pid2; pid2 ≠ pid3; pid1 ≠ pid3; pid1 ≠ pid4; pid2 ≠ pid4; pid3 ≠ pid4⟧ ⟹ (pid3 = pid1) = False› 22. ‹⟦vid1 ≠ vid2; vid2 ≠ vid3; vid1 ≠ vid3; fid1 ≠ fid2; fid2 ≠ fid3; fid1 ≠ fid3; pid1 ≠ pid2; pid2 ≠ pid3; pid1 ≠ pid3; pid1 ≠ pid4; pid2 ≠ pid4; pid3 ≠ pid4⟧ ⟹ (pid4 = pid1) = False› 23. ‹⟦vid1 ≠ vid2; vid2 ≠ vid3; vid1 ≠ vid3; fid1 ≠ fid2; fid2 ≠ fid3; fid1 ≠ fid3; pid1 ≠ pid2; pid2 ≠ pid3; pid1 ≠ pid3; pid1 ≠ pid4; pid2 ≠ pid4; pid3 ≠ pid4⟧ ⟹ (pid4 = pid2) = False› 24. ‹⟦vid1 ≠ vid2; vid2 ≠ vid3; vid1 ≠ vid3; fid1 ≠ fid2; fid2 ≠ fid3; fid1 ≠ fid3; pid1 ≠ pid2; pid2 ≠ pid3; pid1 ≠ pid3; pid1 ≠ pid4; pid2 ≠ pid4; pid3 ≠ pid4⟧ ⟹ (pid4 = pid3) = 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]) (*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*) . end end
{ "path": "afp-2025-02-12/thys/Differential_Dynamic_Logic/Ids.thy", "repo": "afp-2025-02-12", "sha": "7f5a227d2cc407d670d1d17fdb30783f1a7328f711a8d5b8ad0fc6cbd8927c69" }
(******************************************************************************) (* Project: Isabelle/UTP Toolkit *) (* File: List_Lexord_Alt.thy *) (* Authors: Simon Foster and Frank Zeyda *) (* Emails: simon.foster@york.ac.uk and frank.zeyda@york.ac.uk *) (******************************************************************************) section ‹Alternative List Lexicographic Order› theory List_Lexord_Alt imports Main begin text ‹ Since we can't instantiate the order class twice for lists, and we want prefix as the default order for the UTP we here add syntax for the lexicographic order relation. › definition list_lex_less :: "'a::linorder list ⇒ 'a list ⇒ bool" (infix "<⇩l" 50) where "xs <⇩l ys ⟷ (xs, ys) ∈ lexord {(u, v). u < v}" lemma list_lex_less_neq [simp]: "x <⇩l y ⟹ x ≠ y" apply (simp add: list_lex_less_def (*‹(?xs <⇩l ?ys) = ((?xs, ?ys) ∈ lexord {(u, v). u < v})›*)) (*goal: ‹(x::'a::linorder list) <⇩l (y::'a::linorder list) ⟹ x ≠ y›*) by (meson case_prodD (*‹case (?a, ?b) of (c, d) ⇒ ?f c d ⟹ ?f ?a ?b›*) less_irrefl (*‹¬ ?x < ?x›*) lexord_irreflexive (*‹∀x. (x, x) ∉ ?r ⟹ (?xs, ?xs) ∉ lexord ?r›*) mem_Collect_eq (*‹(?a ∈ Collect ?P) = ?P ?a›*)) lemma not_less_Nil [simp]: "¬ x <⇩l []" by (simp add: list_lex_less_def (*‹(?xs <⇩l ?ys) = ((?xs, ?ys) ∈ lexord {(u, v). u < v})›*)) lemma Nil_less_Cons [simp]: "[] <⇩l a # x" by (simp add: list_lex_less_def (*‹(?xs <⇩l ?ys) = ((?xs, ?ys) ∈ lexord {(u, v). u < v})›*)) lemma Cons_less_Cons [simp]: "a # x <⇩l b # y ⟷ a < b ∨ a = b ∧ x <⇩l y" by (simp add: list_lex_less_def (*‹(?xs <⇩l ?ys) = ((?xs, ?ys) ∈ lexord {(u, v). u < v})›*)) end
{ "path": "afp-2025-02-12/thys/UTP/toolkit/List_Lexord_Alt.thy", "repo": "afp-2025-02-12", "sha": "2450d81fb08d9a1616d29659cc06178e7442ffc43b7c0e86d697b80ca7ed547f" }
chapter‹Uniqueness Results: Syntactic Relations are Functions› theory Functions imports Coding_Predicates begin subsection ‹SeqStTermP› lemma not_IndP_VarP: "{IndP x, VarP x} ⊢ A" proof (-) (*goal: ‹{IndP x, VarP x} ⊢ A›*) obtain m :: name where "atom m ♯ (x,A)" (*goal: ‹(⋀m. atom m ♯ (x, A) ⟹ thesis) ⟹ thesis›*) by (metis obtain_fresh (*‹(⋀a. atom a ♯ ?x ⟹ ?thesis) ⟹ ?thesis›*)) thus "?thesis" (*goal: ‹{IndP x, VarP x} ⊢ A›*) apply (auto simp: fresh_Pair (*‹?a ♯ (?x, ?y) = (?a ♯ ?x ∧ ?a ♯ ?y)›*)) (*goal: ‹{IndP x, VarP x} ⊢ A›*) by (blast intro: ExFalso (*‹?H ⊢ Fls ⟹ ?H ⊢ ?A›*) cut_same [OF VarP_cong [THEN Iff_MP_same]] (*‹⟦?H ⊢ ?x2 EQ ?x'2; ?H ⊢ VarP ?x2; insert (VarP ?x'2) ?H ⊢ ?B⟧ ⟹ ?H ⊢ ?B›*)) qed text‹It IS a pair, but not just any pair.› lemma IndP_HPairE: "insert (IndP (HPair (HPair Zero (HPair Zero Zero)) x)) H ⊢ A" proof (-) (*goal: ‹insert (IndP (HPair (HPair Zero (HPair Zero Zero)) x)) H ⊢ A›*) obtain m :: name where "atom m ♯ (x,A)" (*goal: ‹(⋀m. atom m ♯ (x, A) ⟹ thesis) ⟹ thesis›*) by (metis obtain_fresh (*‹(⋀a. atom a ♯ ?x ⟹ ?thesis) ⟹ ?thesis›*)) hence "{ IndP (HPair (HPair Zero (HPair Zero Zero)) x) } ⊢ A" by (auto simp: IndP.simps [of m] (*‹atom m ♯ ?x ⟹ IndP ?x = SyntaxN.Ex m (OrdP (Var m) AND ?x EQ Q_Ind (Var m))›*) HTuple_minus_1 (*‹0 < ?n ⟹ HTuple ?n = HPair Zero (HTuple (?n - 1))›*) intro: thin1 (*‹?H ⊢ ?B ⟹ insert ?A ?H ⊢ ?B›*)) thus "?thesis" (*goal: ‹insert (IndP (HPair (HPair Zero (HPair Zero Zero)) (x::tm))) (H::fm set) ⊢ (A::fm)›*) by (metis Assume (*‹insert (?A::fm) (?H::fm set) ⊢ ?A›*) cut1 (*‹⟦{?A::fm} ⊢ (?B::fm); (?H::fm set) ⊢ ?A⟧ ⟹ ?H ⊢ ?B›*)) qed lemma atom_HPairE: assumes "H ⊢ x EQ HPair (HPair Zero (HPair Zero Zero)) y" shows "insert (IndP x OR x NEQ v) H ⊢ A" proof (-) (*goal: ‹insert (IndP (x::tm) OR x NEQ (v::tm)) (H::fm set) ⊢ (A::fm)›*) have "{ IndP x OR x NEQ v, x EQ HPair (HPair Zero (HPair Zero Zero)) y } ⊢ A" by (auto intro!: OrdNotEqP_OrdP_E (*‹insert (OrdP ?x) (insert (OrdP ?y) ?H) ⊢ ?A ⟹ insert (?x NEQ ?y) ?H ⊢ ?A›*) IndP_HPairE (*‹insert (IndP (HPair (HPair Zero (HPair Zero Zero)) ?x)) ?H ⊢ ?A›*) intro: cut_same [OF IndP_cong [THEN Iff_MP_same]] (*‹⟦?H ⊢ ?x2 EQ ?x'2; ?H ⊢ IndP ?x2; insert (IndP ?x'2) ?H ⊢ ?B⟧ ⟹ ?H ⊢ ?B›*) cut_same [OF OrdP_cong [THEN Iff_MP_same]] (*‹⟦?H ⊢ ?x2 EQ ?x'2; ?H ⊢ OrdP ?x2; insert (OrdP ?x'2) ?H ⊢ ?B⟧ ⟹ ?H ⊢ ?B›*)) thus "?thesis" (*goal: ‹insert (IndP (x::tm) OR x NEQ (v::tm)) (H::fm set) ⊢ (A::fm)›*) by (metis Assume (*‹insert ?A ?H ⊢ ?A›*) assms (*‹H ⊢ x EQ HPair (HPair Zero (HPair Zero Zero)) y›*) rcut2 (*‹⟦{?A, ?B} ⊢ ?C; insert ?C ?H ⊢ ?D; ?H ⊢ ?B⟧ ⟹ insert ?A ?H ⊢ ?D›*)) qed lemma SeqStTermP_lemma: assumes "atom m ♯ (v,i,t,u,s,k,n,sm,sm',sn,sn')" "atom n ♯ (v,i,t,u,s,k,sm,sm',sn,sn')" "atom sm ♯ (v,i,t,u,s,k,sm',sn,sn')" "atom sm' ♯ (v,i,t,u,s,k,sn,sn')" "atom sn ♯ (v,i,t,u,s,k,sn')" "atom sn' ♯ (v,i,t,u,s,k)" shows "{ SeqStTermP v i t u s k } ⊢ ((t EQ v AND u EQ i) OR ((IndP t OR t NEQ v) AND u EQ t)) OR Ex m (Ex n (Ex sm (Ex sm' (Ex sn (Ex sn' (Var m IN k AND Var n IN k AND SeqStTermP v i (Var sm) (Var sm') s (Var m) AND SeqStTermP v i (Var sn) (Var sn') s (Var n) AND t EQ Q_Eats (Var sm) (Var sn) AND u EQ Q_Eats (Var sm') (Var sn')))))))" proof (-) (*goal: ‹{SeqStTermP (v::tm) (i::tm) (t::tm) (u::tm) (s::tm) (k::tm)} ⊢ (t EQ v AND u EQ i OR (IndP t OR t NEQ v) AND u EQ t) OR SyntaxN.Ex (m::name) (SyntaxN.Ex (n::name) (SyntaxN.Ex (sm::name) (SyntaxN.Ex (sm'::name) (SyntaxN.Ex (sn::name) (SyntaxN.Ex (sn'::name) (Var m IN k AND Var n IN k AND SeqStTermP v i (Var sm) (Var sm') s (Var m) AND SeqStTermP v i (Var sn) (Var sn') s (Var n) AND t EQ Q_Eats (Var sm) (Var sn) AND u EQ Q_Eats (Var sm') (Var sn')))))))›*) obtain l :: name and sl :: name and sl' :: name where "atom l ♯ (v,i,t,u,s,k,sl,sl',m,n,sm,sm',sn,sn')" "atom sl ♯ (v,i,t,u,s,k,sl',m,n,sm,sm',sn,sn')" "atom sl' ♯ (v,i,t,u,s,k,m,n,sm,sm',sn,sn')" (*goal: ‹(⋀(l::name) (sl::name) sl'::name. ⟦atom l ♯ (v::tm, i::tm, t::tm, u::tm, s::tm, k::tm, sl, sl', m::name, n::name, sm::name, sm'::name, sn::name, sn'::name); atom sl ♯ (v, i, t, u, s, k, sl', m, n, sm, sm', sn, sn'); atom sl' ♯ (v, i, t, u, s, k, m, n, sm, sm', sn, sn')⟧ ⟹ thesis::bool) ⟹ thesis›*) by (metis obtain_fresh (*‹(⋀a. atom a ♯ ?x ⟹ ?thesis) ⟹ ?thesis›*)) thus "?thesis" (*goal: ‹{SeqStTermP v i t u s k} ⊢ (t EQ v AND u EQ i OR (IndP t OR t NEQ v) AND u EQ t) OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN k AND Var n IN k AND SeqStTermP v i (Var sm) (Var sm') s (Var m) AND SeqStTermP v i (Var sn) (Var sn') s (Var n) AND t EQ Q_Eats (Var sm) (Var sn) AND u EQ Q_Eats (Var sm') (Var sn')))))))›*) using assms (*‹atom m ♯ (v, i, t, u, s, k, n, sm, sm', sn, sn')› ‹atom n ♯ (v, i, t, u, s, k, sm, sm', sn, sn')› ‹atom sm ♯ (v, i, t, u, s, k, sm', sn, sn')› ‹atom sm' ♯ (v, i, t, u, s, k, sn, sn')› ‹atom sn ♯ (v, i, t, u, s, k, sn')› ‹atom sn' ♯ (v, i, t, u, s, k)›*) apply (simp add: SeqStTermP.simps [of l s k v i sl sl' m n sm sm' sn sn'] (*‹⟦atom l ♯ (s, k, v, i, sl, sl', m, n, sm, sm', sn, sn'); atom sl ♯ (s, v, i, sl', m, n, sm, sm', sn, sn'); atom sl' ♯ (s, v, i, m, n, sm, sm', sn, sn'); atom m ♯ (s, n, sm, sm', sn, sn'); atom n ♯ (s, sm, sm', sn, sn'); atom sm ♯ (s, sm', sn, sn'); atom sm' ♯ (s, sn, sn'); atom sn ♯ (s, sn'); atom sn' ♯ s⟧ ⟹ SeqStTermP v i ?t ?u s k = VarP v AND LstSeqP s k (HPair ?t ?u) AND All2 l (SUCC k) (SyntaxN.Ex sl (SyntaxN.Ex sl' (HPair (Var l) (HPair (Var sl) (Var sl')) IN s AND ((Var sl EQ v AND Var sl' EQ i OR (IndP (Var sl) OR Var sl NEQ v) AND Var sl' EQ Var sl) OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN Var l AND Var n IN Var l AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND Var sl EQ Q_Eats (Var sm) (Var sn) AND Var sl' EQ Q_Eats (Var sm') (Var sn')))))))))))›*)) (*goal: ‹{SeqStTermP v i t u s k} ⊢ (t EQ v AND u EQ i OR (IndP t OR t NEQ v) AND u EQ t) OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN k AND Var n IN k AND SeqStTermP v i (Var sm) (Var sm') s (Var m) AND SeqStTermP v i (Var sn) (Var sn') s (Var n) AND t EQ Q_Eats (Var sm) (Var sn) AND u EQ Q_Eats (Var sm') (Var sn')))))))›*) apply (rule Conj_EH (*‹insert ?A (insert ?B ?H) ⊢ ?C ⟹ insert (?A AND ?B) ?H ⊢ ?C› ‹insert ?A (insert ?Ba (insert ?A1.0 ?H)) ⊢ ?B ⟹ insert ?A1.0 (insert (?A AND ?Ba) ?H) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 ?H))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert (?A AND ?Ba) ?H)) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 ?H)))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert (?A AND ?Ba) ?H))) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 ?H))))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert (?A AND ?Ba) ?H)))) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 ?H)))))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert (?A AND ?Ba) ?H))))) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 ?H))))))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert (?A AND ?Ba) ?H)))))) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 ?H)))))))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 (insert (?A AND ?Ba) ?H))))))) ⊢ ?B› ‹insert ?A (insert ?Ba (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))))))))) ⊢ ?B ⟹ 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 (?A AND ?Ba) ?H)))))))) ⊢ ?B› ‹insert ?A (insert ?Ba (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)))))))))) ⊢ ?B ⟹ 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 (?A AND ?Ba) ?H))))))))) ⊢ ?B›*) Ex_EH (*‹⟦insert ?A ?H ⊢ ?B; atom ?i ♯ ?B; ∀C∈?H. atom ?i ♯ C⟧ ⟹ insert (SyntaxN.Ex ?i ?A) ?H ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 ?H) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 ?H. atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert (SyntaxN.Ex ?i ?A) ?H) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 ?H)) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 ?H). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert (SyntaxN.Ex ?i ?A) ?H)) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 ?H))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 ?H)). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert (SyntaxN.Ex ?i ?A) ?H))) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 ?H)))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 ?H))). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert (SyntaxN.Ex ?i ?A) ?H)))) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 ?H))))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 ?H)))). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert (SyntaxN.Ex ?i ?A) ?H))))) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 ?H)))))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 ?H))))). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert (SyntaxN.Ex ?i ?A) ?H)))))) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 ?H))))))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 ?H)))))). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 (insert (SyntaxN.Ex ?i ?A) ?H))))))) ⊢ ?B› ‹⟦insert ?A (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)))))))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈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))))))). atom ?i ♯ C⟧ ⟹ 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 (SyntaxN.Ex ?i ?A) ?H)))))))) ⊢ ?B› ‹⟦insert ?A (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))))))))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈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)))))))). atom ?i ♯ C⟧ ⟹ 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 (SyntaxN.Ex ?i ?A) ?H))))))))) ⊢ ?B›*) All2_SUCC_E [THEN rotate2] (*‹⟦atom ?i1 ♯ ?t1; insert (All2 ?i1 ?t1 ?A1) (insert (?A1(?i1::=?t1)) (insert ?A1.0 ?H)) ⊢ ?B⟧ ⟹ insert ?A1.0 (insert (All2 ?i1 (SUCC ?t1) ?A1) ?H) ⊢ ?B›*)) (*goal: ‹⟦atom l ♯ (v, i, t, u, s, k, sl, sl', m, n, sm, sm', sn, sn'); atom sl ♯ (v, i, t, u, s, k, sl', m, n, sm, sm', sn, sn'); atom sl' ♯ (v, i, t, u, s, k, m, n, sm, sm', sn, sn'); atom m ♯ (v, i, t, u, s, k, n, sm, sm', sn, sn'); atom n ♯ (v, i, t, u, s, k, sm, sm', sn, sn'); atom sm ♯ (v, i, t, u, s, k, sm', sn, sn'); atom sm' ♯ (v, i, t, u, s, k, sn, sn'); atom sn ♯ (v, i, t, u, s, k, sn'); atom sn' ♯ (v, i, t, u, s, k)⟧ ⟹ {VarP v AND LstSeqP s k (HPair t u) AND All2 l (SUCC k) (SyntaxN.Ex sl (SyntaxN.Ex sl' (HPair (Var l) (HPair (Var sl) (Var sl')) IN s AND ((Var sl EQ v AND Var sl' EQ i OR (IndP (Var sl) OR Var sl NEQ v) AND Var sl' EQ Var sl) OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN Var l AND Var n IN Var l AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND Var sl EQ Q_Eats (Var sm) (Var sn) AND Var sl' EQ Q_Eats (Var sm') (Var sn')))))))))))} ⊢ (t EQ v AND u EQ i OR (IndP t OR t NEQ v) AND u EQ t) OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN k AND Var n IN k AND SeqStTermP v i (Var sm) (Var sm') s (Var m) AND SeqStTermP v i (Var sn) (Var sn') s (Var n) AND t EQ Q_Eats (Var sm) (Var sn) AND u EQ Q_Eats (Var sm') (Var sn')))))))›*) apply (rule Conj_EH (*‹insert (?A::fm) (insert (?B::fm) (?H::fm set)) ⊢ (?C::fm) ⟹ insert (?A AND ?B) ?H ⊢ ?C› ‹insert (?A::fm) (insert (?Ba::fm) (insert (?A1.0::fm) (?H::fm set))) ⊢ (?B::fm) ⟹ insert ?A1.0 (insert (?A AND ?Ba) ?H) ⊢ ?B› ‹insert (?A::fm) (insert (?Ba::fm) (insert (?A1.0::fm) (insert (?A2.0::fm) (?H::fm set)))) ⊢ (?B::fm) ⟹ insert ?A1.0 (insert ?A2.0 (insert (?A AND ?Ba) ?H)) ⊢ ?B› ‹insert (?A::fm) (insert (?Ba::fm) (insert (?A1.0::fm) (insert (?A2.0::fm) (insert (?A3.0::fm) (?H::fm set))))) ⊢ (?B::fm) ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert (?A AND ?Ba) ?H))) ⊢ ?B› ‹insert (?A::fm) (insert (?Ba::fm) (insert (?A1.0::fm) (insert (?A2.0::fm) (insert (?A3.0::fm) (insert (?A4.0::fm) (?H::fm set)))))) ⊢ (?B::fm) ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert (?A AND ?Ba) ?H)))) ⊢ ?B› ‹insert (?A::fm) (insert (?Ba::fm) (insert (?A1.0::fm) (insert (?A2.0::fm) (insert (?A3.0::fm) (insert (?A4.0::fm) (insert (?A5.0::fm) (?H::fm set))))))) ⊢ (?B::fm) ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert (?A AND ?Ba) ?H))))) ⊢ ?B› ‹insert (?A::fm) (insert (?Ba::fm) (insert (?A1.0::fm) (insert (?A2.0::fm) (insert (?A3.0::fm) (insert (?A4.0::fm) (insert (?A5.0::fm) (insert (?A6.0::fm) (?H::fm set)))))))) ⊢ (?B::fm) ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert (?A AND ?Ba) ?H)))))) ⊢ ?B› ‹insert (?A::fm) (insert (?Ba::fm) (insert (?A1.0::fm) (insert (?A2.0::fm) (insert (?A3.0::fm) (insert (?A4.0::fm) (insert (?A5.0::fm) (insert (?A6.0::fm) (insert (?A7.0::fm) (?H::fm set))))))))) ⊢ (?B::fm) ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 (insert (?A AND ?Ba) ?H))))))) ⊢ ?B› ‹insert (?A::fm) (insert (?Ba::fm) (insert (?A1.0::fm) (insert (?A2.0::fm) (insert (?A3.0::fm) (insert (?A4.0::fm) (insert (?A5.0::fm) (insert (?A6.0::fm) (insert (?A7.0::fm) (insert (?A8.0::fm) (?H::fm set)))))))))) ⊢ (?B::fm) ⟹ 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 (?A AND ?Ba) ?H)))))))) ⊢ ?B› ‹insert (?A::fm) (insert (?Ba::fm) (insert (?A1.0::fm) (insert (?A2.0::fm) (insert (?A3.0::fm) (insert (?A4.0::fm) (insert (?A5.0::fm) (insert (?A6.0::fm) (insert (?A7.0::fm) (insert (?A8.0::fm) (insert (?A9.0::fm) (?H::fm set))))))))))) ⊢ (?B::fm) ⟹ 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 (?A AND ?Ba) ?H))))))))) ⊢ ?B›*) Ex_EH (*‹⟦insert (?A::fm) (?H::fm set) ⊢ (?B::fm); atom (?i::name) ♯ ?B; ∀C::fm∈?H. atom ?i ♯ C⟧ ⟹ insert (SyntaxN.Ex ?i ?A) ?H ⊢ ?B› ‹⟦insert (?A::fm) (insert (?A1.0::fm) (?H::fm set)) ⊢ (?B::fm); atom (?i::name) ♯ ?B; ∀C::fm∈insert ?A1.0 ?H. atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert (SyntaxN.Ex ?i ?A) ?H) ⊢ ?B› ‹⟦insert (?A::fm) (insert (?A1.0::fm) (insert (?A2.0::fm) (?H::fm set))) ⊢ (?B::fm); atom (?i::name) ♯ ?B; ∀C::fm∈insert ?A1.0 (insert ?A2.0 ?H). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert (SyntaxN.Ex ?i ?A) ?H)) ⊢ ?B› ‹⟦insert (?A::fm) (insert (?A1.0::fm) (insert (?A2.0::fm) (insert (?A3.0::fm) (?H::fm set)))) ⊢ (?B::fm); atom (?i::name) ♯ ?B; ∀C::fm∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 ?H)). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert (SyntaxN.Ex ?i ?A) ?H))) ⊢ ?B› ‹⟦insert (?A::fm) (insert (?A1.0::fm) (insert (?A2.0::fm) (insert (?A3.0::fm) (insert (?A4.0::fm) (?H::fm set))))) ⊢ (?B::fm); atom (?i::name) ♯ ?B; ∀C::fm∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 ?H))). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert (SyntaxN.Ex ?i ?A) ?H)))) ⊢ ?B› ‹⟦insert (?A::fm) (insert (?A1.0::fm) (insert (?A2.0::fm) (insert (?A3.0::fm) (insert (?A4.0::fm) (insert (?A5.0::fm) (?H::fm set)))))) ⊢ (?B::fm); atom (?i::name) ♯ ?B; ∀C::fm∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 ?H)))). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert (SyntaxN.Ex ?i ?A) ?H))))) ⊢ ?B› ‹⟦insert (?A::fm) (insert (?A1.0::fm) (insert (?A2.0::fm) (insert (?A3.0::fm) (insert (?A4.0::fm) (insert (?A5.0::fm) (insert (?A6.0::fm) (?H::fm set))))))) ⊢ (?B::fm); atom (?i::name) ♯ ?B; ∀C::fm∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 ?H))))). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert (SyntaxN.Ex ?i ?A) ?H)))))) ⊢ ?B› ‹⟦insert (?A::fm) (insert (?A1.0::fm) (insert (?A2.0::fm) (insert (?A3.0::fm) (insert (?A4.0::fm) (insert (?A5.0::fm) (insert (?A6.0::fm) (insert (?A7.0::fm) (?H::fm set)))))))) ⊢ (?B::fm); atom (?i::name) ♯ ?B; ∀C::fm∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 ?H)))))). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 (insert (SyntaxN.Ex ?i ?A) ?H))))))) ⊢ ?B› ‹⟦insert (?A::fm) (insert (?A1.0::fm) (insert (?A2.0::fm) (insert (?A3.0::fm) (insert (?A4.0::fm) (insert (?A5.0::fm) (insert (?A6.0::fm) (insert (?A7.0::fm) (insert (?A8.0::fm) (?H::fm set))))))))) ⊢ (?B::fm); atom (?i::name) ♯ ?B; ∀C::fm∈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))))))). atom ?i ♯ C⟧ ⟹ 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 (SyntaxN.Ex ?i ?A) ?H)))))))) ⊢ ?B› ‹⟦insert (?A::fm) (insert (?A1.0::fm) (insert (?A2.0::fm) (insert (?A3.0::fm) (insert (?A4.0::fm) (insert (?A5.0::fm) (insert (?A6.0::fm) (insert (?A7.0::fm) (insert (?A8.0::fm) (insert (?A9.0::fm) (?H::fm set)))))))))) ⊢ (?B::fm); atom (?i::name) ♯ ?B; ∀C::fm∈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)))))))). atom ?i ♯ C⟧ ⟹ 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 (SyntaxN.Ex ?i ?A) ?H))))))))) ⊢ ?B›*) All2_SUCC_E [THEN rotate2] (*‹⟦atom (?i1::name) ♯ (?t1::tm); insert (All2 ?i1 ?t1 (?A1::fm)) (insert (?A1(?i1::=?t1)) (insert (?A1.0::fm) (?H::fm set))) ⊢ (?B::fm)⟧ ⟹ insert ?A1.0 (insert (All2 ?i1 (SUCC ?t1) ?A1) ?H) ⊢ ?B›*)) (*goal: ‹⟦atom l ♯ (v, i, t, u, s, k, sl, sl', m, n, sm, sm', sn, sn'); atom sl ♯ (v, i, t, u, s, k, sl', m, n, sm, sm', sn, sn'); atom sl' ♯ (v, i, t, u, s, k, m, n, sm, sm', sn, sn'); atom m ♯ (v, i, t, u, s, k, n, sm, sm', sn, sn'); atom n ♯ (v, i, t, u, s, k, sm, sm', sn, sn'); atom sm ♯ (v, i, t, u, s, k, sm', sn, sn'); atom sm' ♯ (v, i, t, u, s, k, sn, sn'); atom sn ♯ (v, i, t, u, s, k, sn'); atom sn' ♯ (v, i, t, u, s, k)⟧ ⟹ {VarP v, LstSeqP s k (HPair t u) AND All2 l (SUCC k) (SyntaxN.Ex sl (SyntaxN.Ex sl' (HPair (Var l) (HPair (Var sl) (Var sl')) IN s AND ((Var sl EQ v AND Var sl' EQ i OR (IndP (Var sl) OR Var sl NEQ v) AND Var sl' EQ Var sl) OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN Var l AND Var n IN Var l AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND Var sl EQ Q_Eats (Var sm) (Var sn) AND Var sl' EQ Q_Eats (Var sm') (Var sn')))))))))))} ⊢ (t EQ v AND u EQ i OR (IndP t OR t NEQ v) AND u EQ t) OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN k AND Var n IN k AND SeqStTermP v i (Var sm) (Var sm') s (Var m) AND SeqStTermP v i (Var sn) (Var sn') s (Var n) AND t EQ Q_Eats (Var sm) (Var sn) AND u EQ Q_Eats (Var sm') (Var sn')))))))›*) apply (rule Conj_EH (*‹insert ?A (insert ?B ?H) ⊢ ?C ⟹ insert (?A AND ?B) ?H ⊢ ?C› ‹insert ?A (insert ?Ba (insert ?A1.0 ?H)) ⊢ ?B ⟹ insert ?A1.0 (insert (?A AND ?Ba) ?H) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 ?H))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert (?A AND ?Ba) ?H)) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 ?H)))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert (?A AND ?Ba) ?H))) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 ?H))))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert (?A AND ?Ba) ?H)))) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 ?H)))))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert (?A AND ?Ba) ?H))))) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 ?H))))))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert (?A AND ?Ba) ?H)))))) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 ?H)))))))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 (insert (?A AND ?Ba) ?H))))))) ⊢ ?B› ‹insert ?A (insert ?Ba (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))))))))) ⊢ ?B ⟹ 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 (?A AND ?Ba) ?H)))))))) ⊢ ?B› ‹insert ?A (insert ?Ba (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)))))))))) ⊢ ?B ⟹ 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 (?A AND ?Ba) ?H))))))))) ⊢ ?B›*) Ex_EH (*‹⟦insert ?A ?H ⊢ ?B; atom ?i ♯ ?B; ∀C∈?H. atom ?i ♯ C⟧ ⟹ insert (SyntaxN.Ex ?i ?A) ?H ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 ?H) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 ?H. atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert (SyntaxN.Ex ?i ?A) ?H) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 ?H)) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 ?H). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert (SyntaxN.Ex ?i ?A) ?H)) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 ?H))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 ?H)). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert (SyntaxN.Ex ?i ?A) ?H))) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 ?H)))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 ?H))). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert (SyntaxN.Ex ?i ?A) ?H)))) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 ?H))))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 ?H)))). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert (SyntaxN.Ex ?i ?A) ?H))))) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 ?H)))))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 ?H))))). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert (SyntaxN.Ex ?i ?A) ?H)))))) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 ?H))))))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 ?H)))))). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 (insert (SyntaxN.Ex ?i ?A) ?H))))))) ⊢ ?B› ‹⟦insert ?A (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)))))))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈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))))))). atom ?i ♯ C⟧ ⟹ 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 (SyntaxN.Ex ?i ?A) ?H)))))))) ⊢ ?B› ‹⟦insert ?A (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))))))))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈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)))))))). atom ?i ♯ C⟧ ⟹ 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 (SyntaxN.Ex ?i ?A) ?H))))))))) ⊢ ?B›*) All2_SUCC_E [THEN rotate2] (*‹⟦atom ?i1 ♯ ?t1; insert (All2 ?i1 ?t1 ?A1) (insert (?A1(?i1::=?t1)) (insert ?A1.0 ?H)) ⊢ ?B⟧ ⟹ insert ?A1.0 (insert (All2 ?i1 (SUCC ?t1) ?A1) ?H) ⊢ ?B›*)) (*goals: 1. ‹⟦atom (l::name) ♯ (v::tm, i::tm, t::tm, u::tm, s::tm, k::tm, sl::name, sl'::name, m::name, n::name, sm::name, sm'::name, sn::name, sn'::name); atom sl ♯ (v, i, t, u, s, k, sl', m, n, sm, sm', sn, sn'); atom sl' ♯ (v, i, t, u, s, k, m, n, sm, sm', sn, sn'); atom m ♯ (v, i, t, u, s, k, n, sm, sm', sn, sn'); atom n ♯ (v, i, t, u, s, k, sm, sm', sn, sn'); atom sm ♯ (v, i, t, u, s, k, sm', sn, sn'); atom sm' ♯ (v, i, t, u, s, k, sn, sn'); atom sn ♯ (v, i, t, u, s, k, sn'); atom sn' ♯ (v, i, t, u, s, k)⟧ ⟹ atom l ♯ k› 2. ‹⟦atom (l::name) ♯ (v::tm, i::tm, t::tm, u::tm, s::tm, k::tm, sl::name, sl'::name, m::name, n::name, sm::name, sm'::name, sn::name, sn'::name); atom sl ♯ (v, i, t, u, s, k, sl', m, n, sm, sm', sn, sn'); atom sl' ♯ (v, i, t, u, s, k, m, n, sm, sm', sn, sn'); atom m ♯ (v, i, t, u, s, k, n, sm, sm', sn, sn'); atom n ♯ (v, i, t, u, s, k, sm, sm', sn, sn'); atom sm ♯ (v, i, t, u, s, k, sm', sn, sn'); atom sm' ♯ (v, i, t, u, s, k, sn, sn'); atom sn ♯ (v, i, t, u, s, k, sn'); atom sn' ♯ (v, i, t, u, s, k)⟧ ⟹ {All2 l k (SyntaxN.Ex sl (SyntaxN.Ex sl' (HPair (Var l) (HPair (Var sl) (Var sl')) IN s AND ((Var sl EQ v AND Var sl' EQ i OR (IndP (Var sl) OR Var sl NEQ v) AND Var sl' EQ Var sl) OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN Var l AND Var n IN Var l AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND Var sl EQ Q_Eats (Var sm) (Var sn) AND Var sl' EQ Q_Eats (Var sm') (Var sn'))))))))))), (SyntaxN.Ex sl (SyntaxN.Ex sl' (HPair (Var l) (HPair (Var sl) (Var sl')) IN s AND ((Var sl EQ v AND Var sl' EQ i OR (IndP (Var sl) OR Var sl NEQ v) AND Var sl' EQ Var sl) OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN Var l AND Var n IN Var l AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND Var sl EQ Q_Eats (Var sm) (Var sn) AND Var sl' EQ Q_Eats (Var sm') (Var sn')))))))))))(l::=k), LstSeqP s k (HPair t u), VarP v} ⊢ (t EQ v AND u EQ i OR (IndP t OR t NEQ v) AND u EQ t) OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN k AND Var n IN k AND SeqStTermP v i (Var sm) (Var sm') s (Var m) AND SeqStTermP v i (Var sn) (Var sn') s (Var n) AND t EQ Q_Eats (Var sm) (Var sn) AND u EQ Q_Eats (Var sm') (Var sn')))))))› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*goal: ‹⟦atom l ♯ (v, i, t, u, s, k, sl, sl', m, n, sm, sm', sn, sn'); atom sl ♯ (v, i, t, u, s, k, sl', m, n, sm, sm', sn, sn'); atom sl' ♯ (v, i, t, u, s, k, m, n, sm, sm', sn, sn'); atom m ♯ (v, i, t, u, s, k, n, sm, sm', sn, sn'); atom n ♯ (v, i, t, u, s, k, sm, sm', sn, sn'); atom sm ♯ (v, i, t, u, s, k, sm', sn, sn'); atom sm' ♯ (v, i, t, u, s, k, sn, sn'); atom sn ♯ (v, i, t, u, s, k, sn'); atom sn' ♯ (v, i, t, u, s, k)⟧ ⟹ {All2 l k (SyntaxN.Ex sl (SyntaxN.Ex sl' (HPair (Var l) (HPair (Var sl) (Var sl')) IN s AND ((Var sl EQ v AND Var sl' EQ i OR (IndP (Var sl) OR Var sl NEQ v) AND Var sl' EQ Var sl) OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN Var l AND Var n IN Var l AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND Var sl EQ Q_Eats (Var sm) (Var sn) AND Var sl' EQ Q_Eats (Var sm') (Var sn'))))))))))), (SyntaxN.Ex sl (SyntaxN.Ex sl' (HPair (Var l) (HPair (Var sl) (Var sl')) IN s AND ((Var sl EQ v AND Var sl' EQ i OR (IndP (Var sl) OR Var sl NEQ v) AND Var sl' EQ Var sl) OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN Var l AND Var n IN Var l AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND Var sl EQ Q_Eats (Var sm) (Var sn) AND Var sl' EQ Q_Eats (Var sm') (Var sn')))))))))))(l::=k), LstSeqP s k (HPair t u), VarP v} ⊢ (t EQ v AND u EQ i OR (IndP t OR t NEQ v) AND u EQ t) OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN k AND Var n IN k AND SeqStTermP v i (Var sm) (Var sm') s (Var m) AND SeqStTermP v i (Var sn) (Var sn') s (Var n) AND t EQ Q_Eats (Var sm) (Var sn) AND u EQ Q_Eats (Var sm') (Var sn')))))))›*) apply (rule Conj_EH (*‹insert ?A (insert ?B ?H) ⊢ ?C ⟹ insert (?A AND ?B) ?H ⊢ ?C› ‹insert ?A (insert ?Ba (insert ?A1.0 ?H)) ⊢ ?B ⟹ insert ?A1.0 (insert (?A AND ?Ba) ?H) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 ?H))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert (?A AND ?Ba) ?H)) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 ?H)))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert (?A AND ?Ba) ?H))) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 ?H))))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert (?A AND ?Ba) ?H)))) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 ?H)))))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert (?A AND ?Ba) ?H))))) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 ?H))))))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert (?A AND ?Ba) ?H)))))) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 ?H)))))))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 (insert (?A AND ?Ba) ?H))))))) ⊢ ?B› ‹insert ?A (insert ?Ba (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))))))))) ⊢ ?B ⟹ 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 (?A AND ?Ba) ?H)))))))) ⊢ ?B› ‹insert ?A (insert ?Ba (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)))))))))) ⊢ ?B ⟹ 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 (?A AND ?Ba) ?H))))))))) ⊢ ?B›*) Ex_EH (*‹⟦insert ?A ?H ⊢ ?B; atom ?i ♯ ?B; ∀C∈?H. atom ?i ♯ C⟧ ⟹ insert (SyntaxN.Ex ?i ?A) ?H ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 ?H) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 ?H. atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert (SyntaxN.Ex ?i ?A) ?H) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 ?H)) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 ?H). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert (SyntaxN.Ex ?i ?A) ?H)) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 ?H))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 ?H)). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert (SyntaxN.Ex ?i ?A) ?H))) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 ?H)))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 ?H))). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert (SyntaxN.Ex ?i ?A) ?H)))) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 ?H))))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 ?H)))). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert (SyntaxN.Ex ?i ?A) ?H))))) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 ?H)))))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 ?H))))). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert (SyntaxN.Ex ?i ?A) ?H)))))) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 ?H))))))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 ?H)))))). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 (insert (SyntaxN.Ex ?i ?A) ?H))))))) ⊢ ?B› ‹⟦insert ?A (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)))))))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈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))))))). atom ?i ♯ C⟧ ⟹ 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 (SyntaxN.Ex ?i ?A) ?H)))))))) ⊢ ?B› ‹⟦insert ?A (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))))))))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈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)))))))). atom ?i ♯ C⟧ ⟹ 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 (SyntaxN.Ex ?i ?A) ?H))))))))) ⊢ ?B›*) All2_SUCC_E [THEN rotate2] (*‹⟦atom ?i1 ♯ ?t1; insert (All2 ?i1 ?t1 ?A1) (insert (?A1(?i1::=?t1)) (insert ?A1.0 ?H)) ⊢ ?B⟧ ⟹ insert ?A1.0 (insert (All2 ?i1 (SUCC ?t1) ?A1) ?H) ⊢ ?B›*)) (*goals: 1. ‹⟦atom l ♯ (v, i, t, u, s, k, sl, sl', m, n, sm, sm', sn, sn'); atom sl ♯ (v, i, t, u, s, k, sl', m, n, sm, sm', sn, sn'); atom sl' ♯ (v, i, t, u, s, k, m, n, sm, sm', sn, sn'); atom m ♯ (v, i, t, u, s, k, n, sm, sm', sn, sn'); atom n ♯ (v, i, t, u, s, k, sm, sm', sn, sn'); atom sm ♯ (v, i, t, u, s, k, sm', sn, sn'); atom sm' ♯ (v, i, t, u, s, k, sn, sn'); atom sn ♯ (v, i, t, u, s, k, sn'); atom sn' ♯ (v, i, t, u, s, k)⟧ ⟹ {SyntaxN.Ex sl' (HPair k (HPair (Var sl) (Var sl')) IN s AND ((Var sl EQ v AND Var sl' EQ i OR (IndP (Var sl) OR Var sl NEQ v) AND Var sl' EQ Var sl) OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN k AND Var n IN k AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND Var sl EQ Q_Eats (Var sm) (Var sn) AND Var sl' EQ Q_Eats (Var sm') (Var sn'))))))))), All2 l k (SyntaxN.Ex sl (SyntaxN.Ex sl' (HPair (Var l) (HPair (Var sl) (Var sl')) IN s AND ((Var sl EQ v AND Var sl' EQ i OR (IndP (Var sl) OR Var sl NEQ v) AND Var sl' EQ Var sl) OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN Var l AND Var n IN Var l AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND Var sl EQ Q_Eats (Var sm) (Var sn) AND Var sl' EQ Q_Eats (Var sm') (Var sn'))))))))))), LstSeqP s k (HPair t u), VarP v} ⊢ (t EQ v AND u EQ i OR (IndP t OR t NEQ v) AND u EQ t) OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN k AND Var n IN k AND SeqStTermP v i (Var sm) (Var sm') s (Var m) AND SeqStTermP v i (Var sn) (Var sn') s (Var n) AND t EQ Q_Eats (Var sm) (Var sn) AND u EQ Q_Eats (Var sm') (Var sn')))))))› 2. ‹⟦atom l ♯ (v, i, t, u, s, k, sl, sl', m, n, sm, sm', sn, sn'); atom sl ♯ (v, i, t, u, s, k, sl', m, n, sm, sm', sn, sn'); atom sl' ♯ (v, i, t, u, s, k, m, n, sm, sm', sn, sn'); atom m ♯ (v, i, t, u, s, k, n, sm, sm', sn, sn'); atom n ♯ (v, i, t, u, s, k, sm, sm', sn, sn'); atom sm ♯ (v, i, t, u, s, k, sm', sn, sn'); atom sm' ♯ (v, i, t, u, s, k, sn, sn'); atom sn ♯ (v, i, t, u, s, k, sn'); atom sn' ♯ (v, i, t, u, s, k)⟧ ⟹ atom sl ♯ (t EQ v AND u EQ i OR (IndP t OR t NEQ v) AND u EQ t) OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN k AND Var n IN k AND SeqStTermP v i (Var sm) (Var sm') s (Var m) AND SeqStTermP v i (Var sn) (Var sn') s (Var n) AND t EQ Q_Eats (Var sm) (Var sn) AND u EQ Q_Eats (Var sm') (Var sn')))))))› 3. ‹⟦atom l ♯ (v, i, t, u, s, k, sl, sl', m, n, sm, sm', sn, sn'); atom sl ♯ (v, i, t, u, s, k, sl', m, n, sm, sm', sn, sn'); atom sl' ♯ (v, i, t, u, s, k, m, n, sm, sm', sn, sn'); atom m ♯ (v, i, t, u, s, k, n, sm, sm', sn, sn'); atom n ♯ (v, i, t, u, s, k, sm, sm', sn, sn'); atom sm ♯ (v, i, t, u, s, k, sm', sn, sn'); atom sm' ♯ (v, i, t, u, s, k, sn, sn'); atom sn ♯ (v, i, t, u, s, k, sn'); atom sn' ♯ (v, i, t, u, s, k)⟧ ⟹ ∀C∈{All2 l k (SyntaxN.Ex sl (SyntaxN.Ex sl' (HPair (Var l) (HPair (Var sl) (Var sl')) IN s AND ((Var sl EQ v AND Var sl' EQ i OR (IndP (Var sl) OR Var sl NEQ v) AND Var sl' EQ Var sl) OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN Var l AND Var n IN Var l AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND Var sl EQ Q_Eats (Var sm) (Var sn) AND Var sl' EQ Q_Eats (Var sm') (Var sn'))))))))))), LstSeqP s k (HPair t u), VarP v}. atom sl ♯ C› discuss goal 1*) apply (rule Conj_EH (*‹insert ?A (insert ?B ?H) ⊢ ?C ⟹ insert (?A AND ?B) ?H ⊢ ?C› ‹insert ?A (insert ?Ba (insert ?A1.0 ?H)) ⊢ ?B ⟹ insert ?A1.0 (insert (?A AND ?Ba) ?H) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 ?H))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert (?A AND ?Ba) ?H)) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 ?H)))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert (?A AND ?Ba) ?H))) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 ?H))))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert (?A AND ?Ba) ?H)))) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 ?H)))))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert (?A AND ?Ba) ?H))))) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 ?H))))))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert (?A AND ?Ba) ?H)))))) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 ?H)))))))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 (insert (?A AND ?Ba) ?H))))))) ⊢ ?B› ‹insert ?A (insert ?Ba (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))))))))) ⊢ ?B ⟹ 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 (?A AND ?Ba) ?H)))))))) ⊢ ?B› ‹insert ?A (insert ?Ba (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)))))))))) ⊢ ?B ⟹ 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 (?A AND ?Ba) ?H))))))))) ⊢ ?B›*) Ex_EH (*‹⟦insert ?A ?H ⊢ ?B; atom ?i ♯ ?B; ∀C∈?H. atom ?i ♯ C⟧ ⟹ insert (SyntaxN.Ex ?i ?A) ?H ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 ?H) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 ?H. atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert (SyntaxN.Ex ?i ?A) ?H) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 ?H)) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 ?H). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert (SyntaxN.Ex ?i ?A) ?H)) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 ?H))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 ?H)). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert (SyntaxN.Ex ?i ?A) ?H))) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 ?H)))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 ?H))). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert (SyntaxN.Ex ?i ?A) ?H)))) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 ?H))))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 ?H)))). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert (SyntaxN.Ex ?i ?A) ?H))))) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 ?H)))))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 ?H))))). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert (SyntaxN.Ex ?i ?A) ?H)))))) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 ?H))))))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 ?H)))))). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 (insert (SyntaxN.Ex ?i ?A) ?H))))))) ⊢ ?B› ‹⟦insert ?A (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)))))))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈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))))))). atom ?i ♯ C⟧ ⟹ 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 (SyntaxN.Ex ?i ?A) ?H)))))))) ⊢ ?B› ‹⟦insert ?A (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))))))))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈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)))))))). atom ?i ♯ C⟧ ⟹ 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 (SyntaxN.Ex ?i ?A) ?H))))))))) ⊢ ?B›*) All2_SUCC_E [THEN rotate2] (*‹⟦atom ?i1 ♯ ?t1; insert (All2 ?i1 ?t1 ?A1) (insert (?A1(?i1::=?t1)) (insert ?A1.0 ?H)) ⊢ ?B⟧ ⟹ insert ?A1.0 (insert (All2 ?i1 (SUCC ?t1) ?A1) ?H) ⊢ ?B›*)) (*goals: 1. ‹⟦atom l ♯ (v, i, t, u, s, k, sl, sl', m, n, sm, sm', sn, sn'); atom sl ♯ (v, i, t, u, s, k, sl', m, n, sm, sm', sn, sn'); atom sl' ♯ (v, i, t, u, s, k, m, n, sm, sm', sn, sn'); atom m ♯ (v, i, t, u, s, k, n, sm, sm', sn, sn'); atom n ♯ (v, i, t, u, s, k, sm, sm', sn, sn'); atom sm ♯ (v, i, t, u, s, k, sm', sn, sn'); atom sm' ♯ (v, i, t, u, s, k, sn, sn'); atom sn ♯ (v, i, t, u, s, k, sn'); atom sn' ♯ (v, i, t, u, s, k)⟧ ⟹ {HPair k (HPair (Var sl) (Var sl')) IN s AND ((Var sl EQ v AND Var sl' EQ i OR (IndP (Var sl) OR Var sl NEQ v) AND Var sl' EQ Var sl) OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN k AND Var n IN k AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND Var sl EQ Q_Eats (Var sm) (Var sn) AND Var sl' EQ Q_Eats (Var sm') (Var sn')))))))), All2 l k (SyntaxN.Ex sl (SyntaxN.Ex sl' (HPair (Var l) (HPair (Var sl) (Var sl')) IN s AND ((Var sl EQ v AND Var sl' EQ i OR (IndP (Var sl) OR Var sl NEQ v) AND Var sl' EQ Var sl) OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN Var l AND Var n IN Var l AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND Var sl EQ Q_Eats (Var sm) (Var sn) AND Var sl' EQ Q_Eats (Var sm') (Var sn'))))))))))), LstSeqP s k (HPair t u), VarP v} ⊢ (t EQ v AND u EQ i OR (IndP t OR t NEQ v) AND u EQ t) OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN k AND Var n IN k AND SeqStTermP v i (Var sm) (Var sm') s (Var m) AND SeqStTermP v i (Var sn) (Var sn') s (Var n) AND t EQ Q_Eats (Var sm) (Var sn) AND u EQ Q_Eats (Var sm') (Var sn')))))))› 2. ‹⟦atom l ♯ (v, i, t, u, s, k, sl, sl', m, n, sm, sm', sn, sn'); atom sl ♯ (v, i, t, u, s, k, sl', m, n, sm, sm', sn, sn'); atom sl' ♯ (v, i, t, u, s, k, m, n, sm, sm', sn, sn'); atom m ♯ (v, i, t, u, s, k, n, sm, sm', sn, sn'); atom n ♯ (v, i, t, u, s, k, sm, sm', sn, sn'); atom sm ♯ (v, i, t, u, s, k, sm', sn, sn'); atom sm' ♯ (v, i, t, u, s, k, sn, sn'); atom sn ♯ (v, i, t, u, s, k, sn'); atom sn' ♯ (v, i, t, u, s, k)⟧ ⟹ atom sl' ♯ (t EQ v AND u EQ i OR (IndP t OR t NEQ v) AND u EQ t) OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN k AND Var n IN k AND SeqStTermP v i (Var sm) (Var sm') s (Var m) AND SeqStTermP v i (Var sn) (Var sn') s (Var n) AND t EQ Q_Eats (Var sm) (Var sn) AND u EQ Q_Eats (Var sm') (Var sn')))))))› 3. ‹⟦atom l ♯ (v, i, t, u, s, k, sl, sl', m, n, sm, sm', sn, sn'); atom sl ♯ (v, i, t, u, s, k, sl', m, n, sm, sm', sn, sn'); atom sl' ♯ (v, i, t, u, s, k, m, n, sm, sm', sn, sn'); atom m ♯ (v, i, t, u, s, k, n, sm, sm', sn, sn'); atom n ♯ (v, i, t, u, s, k, sm, sm', sn, sn'); atom sm ♯ (v, i, t, u, s, k, sm', sn, sn'); atom sm' ♯ (v, i, t, u, s, k, sn, sn'); atom sn ♯ (v, i, t, u, s, k, sn'); atom sn' ♯ (v, i, t, u, s, k)⟧ ⟹ ∀C∈{All2 l k (SyntaxN.Ex sl (SyntaxN.Ex sl' (HPair (Var l) (HPair (Var sl) (Var sl')) IN s AND ((Var sl EQ v AND Var sl' EQ i OR (IndP (Var sl) OR Var sl NEQ v) AND Var sl' EQ Var sl) OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN Var l AND Var n IN Var l AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND Var sl EQ Q_Eats (Var sm) (Var sn) AND Var sl' EQ Q_Eats (Var sm') (Var sn'))))))))))), LstSeqP s k (HPair t u), VarP v}. atom sl' ♯ C› discuss goal 1*) apply (rule Conj_EH (*‹insert (?A::fm) (insert (?B::fm) (?H::fm set)) ⊢ (?C::fm) ⟹ insert (?A AND ?B) ?H ⊢ ?C› ‹insert (?A::fm) (insert (?Ba::fm) (insert (?A1.0::fm) (?H::fm set))) ⊢ (?B::fm) ⟹ insert ?A1.0 (insert (?A AND ?Ba) ?H) ⊢ ?B› ‹insert (?A::fm) (insert (?Ba::fm) (insert (?A1.0::fm) (insert (?A2.0::fm) (?H::fm set)))) ⊢ (?B::fm) ⟹ insert ?A1.0 (insert ?A2.0 (insert (?A AND ?Ba) ?H)) ⊢ ?B› ‹insert (?A::fm) (insert (?Ba::fm) (insert (?A1.0::fm) (insert (?A2.0::fm) (insert (?A3.0::fm) (?H::fm set))))) ⊢ (?B::fm) ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert (?A AND ?Ba) ?H))) ⊢ ?B› ‹insert (?A::fm) (insert (?Ba::fm) (insert (?A1.0::fm) (insert (?A2.0::fm) (insert (?A3.0::fm) (insert (?A4.0::fm) (?H::fm set)))))) ⊢ (?B::fm) ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert (?A AND ?Ba) ?H)))) ⊢ ?B› ‹insert (?A::fm) (insert (?Ba::fm) (insert (?A1.0::fm) (insert (?A2.0::fm) (insert (?A3.0::fm) (insert (?A4.0::fm) (insert (?A5.0::fm) (?H::fm set))))))) ⊢ (?B::fm) ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert (?A AND ?Ba) ?H))))) ⊢ ?B› ‹insert (?A::fm) (insert (?Ba::fm) (insert (?A1.0::fm) (insert (?A2.0::fm) (insert (?A3.0::fm) (insert (?A4.0::fm) (insert (?A5.0::fm) (insert (?A6.0::fm) (?H::fm set)))))))) ⊢ (?B::fm) ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert (?A AND ?Ba) ?H)))))) ⊢ ?B› ‹insert (?A::fm) (insert (?Ba::fm) (insert (?A1.0::fm) (insert (?A2.0::fm) (insert (?A3.0::fm) (insert (?A4.0::fm) (insert (?A5.0::fm) (insert (?A6.0::fm) (insert (?A7.0::fm) (?H::fm set))))))))) ⊢ (?B::fm) ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 (insert (?A AND ?Ba) ?H))))))) ⊢ ?B› ‹insert (?A::fm) (insert (?Ba::fm) (insert (?A1.0::fm) (insert (?A2.0::fm) (insert (?A3.0::fm) (insert (?A4.0::fm) (insert (?A5.0::fm) (insert (?A6.0::fm) (insert (?A7.0::fm) (insert (?A8.0::fm) (?H::fm set)))))))))) ⊢ (?B::fm) ⟹ 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 (?A AND ?Ba) ?H)))))))) ⊢ ?B› ‹insert (?A::fm) (insert (?Ba::fm) (insert (?A1.0::fm) (insert (?A2.0::fm) (insert (?A3.0::fm) (insert (?A4.0::fm) (insert (?A5.0::fm) (insert (?A6.0::fm) (insert (?A7.0::fm) (insert (?A8.0::fm) (insert (?A9.0::fm) (?H::fm set))))))))))) ⊢ (?B::fm) ⟹ 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 (?A AND ?Ba) ?H))))))))) ⊢ ?B›*) Ex_EH (*‹⟦insert (?A::fm) (?H::fm set) ⊢ (?B::fm); atom (?i::name) ♯ ?B; ∀C::fm∈?H. atom ?i ♯ C⟧ ⟹ insert (SyntaxN.Ex ?i ?A) ?H ⊢ ?B› ‹⟦insert (?A::fm) (insert (?A1.0::fm) (?H::fm set)) ⊢ (?B::fm); atom (?i::name) ♯ ?B; ∀C::fm∈insert ?A1.0 ?H. atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert (SyntaxN.Ex ?i ?A) ?H) ⊢ ?B› ‹⟦insert (?A::fm) (insert (?A1.0::fm) (insert (?A2.0::fm) (?H::fm set))) ⊢ (?B::fm); atom (?i::name) ♯ ?B; ∀C::fm∈insert ?A1.0 (insert ?A2.0 ?H). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert (SyntaxN.Ex ?i ?A) ?H)) ⊢ ?B› ‹⟦insert (?A::fm) (insert (?A1.0::fm) (insert (?A2.0::fm) (insert (?A3.0::fm) (?H::fm set)))) ⊢ (?B::fm); atom (?i::name) ♯ ?B; ∀C::fm∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 ?H)). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert (SyntaxN.Ex ?i ?A) ?H))) ⊢ ?B› ‹⟦insert (?A::fm) (insert (?A1.0::fm) (insert (?A2.0::fm) (insert (?A3.0::fm) (insert (?A4.0::fm) (?H::fm set))))) ⊢ (?B::fm); atom (?i::name) ♯ ?B; ∀C::fm∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 ?H))). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert (SyntaxN.Ex ?i ?A) ?H)))) ⊢ ?B› ‹⟦insert (?A::fm) (insert (?A1.0::fm) (insert (?A2.0::fm) (insert (?A3.0::fm) (insert (?A4.0::fm) (insert (?A5.0::fm) (?H::fm set)))))) ⊢ (?B::fm); atom (?i::name) ♯ ?B; ∀C::fm∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 ?H)))). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert (SyntaxN.Ex ?i ?A) ?H))))) ⊢ ?B› ‹⟦insert (?A::fm) (insert (?A1.0::fm) (insert (?A2.0::fm) (insert (?A3.0::fm) (insert (?A4.0::fm) (insert (?A5.0::fm) (insert (?A6.0::fm) (?H::fm set))))))) ⊢ (?B::fm); atom (?i::name) ♯ ?B; ∀C::fm∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 ?H))))). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert (SyntaxN.Ex ?i ?A) ?H)))))) ⊢ ?B› ‹⟦insert (?A::fm) (insert (?A1.0::fm) (insert (?A2.0::fm) (insert (?A3.0::fm) (insert (?A4.0::fm) (insert (?A5.0::fm) (insert (?A6.0::fm) (insert (?A7.0::fm) (?H::fm set)))))))) ⊢ (?B::fm); atom (?i::name) ♯ ?B; ∀C::fm∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 ?H)))))). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 (insert (SyntaxN.Ex ?i ?A) ?H))))))) ⊢ ?B› ‹⟦insert (?A::fm) (insert (?A1.0::fm) (insert (?A2.0::fm) (insert (?A3.0::fm) (insert (?A4.0::fm) (insert (?A5.0::fm) (insert (?A6.0::fm) (insert (?A7.0::fm) (insert (?A8.0::fm) (?H::fm set))))))))) ⊢ (?B::fm); atom (?i::name) ♯ ?B; ∀C::fm∈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))))))). atom ?i ♯ C⟧ ⟹ 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 (SyntaxN.Ex ?i ?A) ?H)))))))) ⊢ ?B› ‹⟦insert (?A::fm) (insert (?A1.0::fm) (insert (?A2.0::fm) (insert (?A3.0::fm) (insert (?A4.0::fm) (insert (?A5.0::fm) (insert (?A6.0::fm) (insert (?A7.0::fm) (insert (?A8.0::fm) (insert (?A9.0::fm) (?H::fm set)))))))))) ⊢ (?B::fm); atom (?i::name) ♯ ?B; ∀C::fm∈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)))))))). atom ?i ♯ C⟧ ⟹ 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 (SyntaxN.Ex ?i ?A) ?H))))))))) ⊢ ?B›*) All2_SUCC_E [THEN rotate2] (*‹⟦atom (?i1::name) ♯ (?t1::tm); insert (All2 ?i1 ?t1 (?A1::fm)) (insert (?A1(?i1::=?t1)) (insert (?A1.0::fm) (?H::fm set))) ⊢ (?B::fm)⟧ ⟹ insert ?A1.0 (insert (All2 ?i1 (SUCC ?t1) ?A1) ?H) ⊢ ?B›*)) (*top goal: ‹⟦atom l ♯ (v, i, t, u, s, k, sl, sl', m, n, sm, sm', sn, sn'); atom sl ♯ (v, i, t, u, s, k, sl', m, n, sm, sm', sn, sn'); atom sl' ♯ (v, i, t, u, s, k, m, n, sm, sm', sn, sn'); atom m ♯ (v, i, t, u, s, k, n, sm, sm', sn, sn'); atom n ♯ (v, i, t, u, s, k, sm, sm', sn, sn'); atom sm ♯ (v, i, t, u, s, k, sm', sn, sn'); atom sm' ♯ (v, i, t, u, s, k, sn, sn'); atom sn ♯ (v, i, t, u, s, k, sn'); atom sn' ♯ (v, i, t, u, s, k)⟧ ⟹ {HPair k (HPair (Var sl) (Var sl')) IN s AND ((Var sl EQ v AND Var sl' EQ i OR (IndP (Var sl) OR Var sl NEQ v) AND Var sl' EQ Var sl) OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN k AND Var n IN k AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND Var sl EQ Q_Eats (Var sm) (Var sn) AND Var sl' EQ Q_Eats (Var sm') (Var sn')))))))), All2 l k (SyntaxN.Ex sl (SyntaxN.Ex sl' (HPair (Var l) (HPair (Var sl) (Var sl')) IN s AND ((Var sl EQ v AND Var sl' EQ i OR (IndP (Var sl) OR Var sl NEQ v) AND Var sl' EQ Var sl) OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN Var l AND Var n IN Var l AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND Var sl EQ Q_Eats (Var sm) (Var sn) AND Var sl' EQ Q_Eats (Var sm') (Var sn'))))))))))), LstSeqP s k (HPair t u), VarP v} ⊢ (t EQ v AND u EQ i OR (IndP t OR t NEQ v) AND u EQ t) OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN k AND Var n IN k AND SeqStTermP v i (Var sm) (Var sm') s (Var m) AND SeqStTermP v i (Var sn) (Var sn') s (Var n) AND t EQ Q_Eats (Var sm) (Var sn) AND u EQ Q_Eats (Var sm') (Var sn')))))))› and 4 goals remain*) apply (rule cut_same [where A = "HPair t u EQ HPair (Var sl) (Var sl')"] (*‹⟦?H ⊢ HPair t u EQ HPair (Var sl) (Var sl'); insert (HPair t u EQ HPair (Var sl) (Var sl')) ?H ⊢ ?B⟧ ⟹ ?H ⊢ ?B›*)) (*goals: 1. ‹⟦atom (l::name) ♯ (v::tm, i::tm, t::tm, u::tm, s::tm, k::tm, sl::name, sl'::name, m::name, n::name, sm::name, sm'::name, sn::name, sn'::name); atom sl ♯ (v, i, t, u, s, k, sl', m, n, sm, sm', sn, sn'); atom sl' ♯ (v, i, t, u, s, k, m, n, sm, sm', sn, sn'); atom m ♯ (v, i, t, u, s, k, n, sm, sm', sn, sn'); atom n ♯ (v, i, t, u, s, k, sm, sm', sn, sn'); atom sm ♯ (v, i, t, u, s, k, sm', sn, sn'); atom sm' ♯ (v, i, t, u, s, k, sn, sn'); atom sn ♯ (v, i, t, u, s, k, sn'); atom sn' ♯ (v, i, t, u, s, k)⟧ ⟹ {HPair k (HPair (Var sl) (Var sl')) IN s, (Var sl EQ v AND Var sl' EQ i OR (IndP (Var sl) OR Var sl NEQ v) AND Var sl' EQ Var sl) OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN k AND Var n IN k AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND Var sl EQ Q_Eats (Var sm) (Var sn) AND Var sl' EQ Q_Eats (Var sm') (Var sn'))))))), All2 l k (SyntaxN.Ex sl (SyntaxN.Ex sl' (HPair (Var l) (HPair (Var sl) (Var sl')) IN s AND ((Var sl EQ v AND Var sl' EQ i OR (IndP (Var sl) OR Var sl NEQ v) AND Var sl' EQ Var sl) OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN Var l AND Var n IN Var l AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND Var sl EQ Q_Eats (Var sm) (Var sn) AND Var sl' EQ Q_Eats (Var sm') (Var sn'))))))))))), LstSeqP s k (HPair t u), VarP v} ⊢ HPair t u EQ HPair (Var sl) (Var sl')› 2. ‹⟦atom (l::name) ♯ (v::tm, i::tm, t::tm, u::tm, s::tm, k::tm, sl::name, sl'::name, m::name, n::name, sm::name, sm'::name, sn::name, sn'::name); atom sl ♯ (v, i, t, u, s, k, sl', m, n, sm, sm', sn, sn'); atom sl' ♯ (v, i, t, u, s, k, m, n, sm, sm', sn, sn'); atom m ♯ (v, i, t, u, s, k, n, sm, sm', sn, sn'); atom n ♯ (v, i, t, u, s, k, sm, sm', sn, sn'); atom sm ♯ (v, i, t, u, s, k, sm', sn, sn'); atom sm' ♯ (v, i, t, u, s, k, sn, sn'); atom sn ♯ (v, i, t, u, s, k, sn'); atom sn' ♯ (v, i, t, u, s, k)⟧ ⟹ {HPair t u EQ HPair (Var sl) (Var sl'), HPair k (HPair (Var sl) (Var sl')) IN s, (Var sl EQ v AND Var sl' EQ i OR (IndP (Var sl) OR Var sl NEQ v) AND Var sl' EQ Var sl) OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN k AND Var n IN k AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND Var sl EQ Q_Eats (Var sm) (Var sn) AND Var sl' EQ Q_Eats (Var sm') (Var sn'))))))), All2 l k (SyntaxN.Ex sl (SyntaxN.Ex sl' (HPair (Var l) (HPair (Var sl) (Var sl')) IN s AND ((Var sl EQ v AND Var sl' EQ i OR (IndP (Var sl) OR Var sl NEQ v) AND Var sl' EQ Var sl) OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN Var l AND Var n IN Var l AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND Var sl EQ Q_Eats (Var sm) (Var sn) AND Var sl' EQ Q_Eats (Var sm') (Var sn'))))))))))), LstSeqP s k (HPair t u), VarP v} ⊢ (t EQ v AND u EQ i OR (IndP t OR t NEQ v) AND u EQ t) OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN k AND Var n IN k AND SeqStTermP v i (Var sm) (Var sm') s (Var m) AND SeqStTermP v i (Var sn) (Var sn') s (Var n) AND t EQ Q_Eats (Var sm) (Var sn) AND u EQ Q_Eats (Var sm') (Var sn')))))))› discuss goal 1*) apply (metis Assume (*‹insert ?A ?H ⊢ ?A›*) AssumeH( (*‹insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 ?H))) ⊢ ?A4.0›*) 4) LstSeqP_EQ (*‹⟦?H ⊢ LstSeqP ?s ?k ?y; ?H ⊢ HPair ?k ?y' IN ?s⟧ ⟹ ?H ⊢ ?y EQ ?y'›*)) (*discuss goal 2*) apply clarify (*top goal: ‹⟦atom l ♯ (v, i, t, u, s, k, sl, sl', m, n, sm, sm', sn, sn'); atom sl ♯ (v, i, t, u, s, k, sl', m, n, sm, sm', sn, sn'); atom sl' ♯ (v, i, t, u, s, k, m, n, sm, sm', sn, sn'); atom m ♯ (v, i, t, u, s, k, n, sm, sm', sn, sn'); atom n ♯ (v, i, t, u, s, k, sm, sm', sn, sn'); atom sm ♯ (v, i, t, u, s, k, sm', sn, sn'); atom sm' ♯ (v, i, t, u, s, k, sn, sn'); atom sn ♯ (v, i, t, u, s, k, sn'); atom sn' ♯ (v, i, t, u, s, k)⟧ ⟹ {HPair t u EQ HPair (Var sl) (Var sl'), HPair k (HPair (Var sl) (Var sl')) IN s, (Var sl EQ v AND Var sl' EQ i OR (IndP (Var sl) OR Var sl NEQ v) AND Var sl' EQ Var sl) OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN k AND Var n IN k AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND Var sl EQ Q_Eats (Var sm) (Var sn) AND Var sl' EQ Q_Eats (Var sm') (Var sn'))))))), All2 l k (SyntaxN.Ex sl (SyntaxN.Ex sl' (HPair (Var l) (HPair (Var sl) (Var sl')) IN s AND ((Var sl EQ v AND Var sl' EQ i OR (IndP (Var sl) OR Var sl NEQ v) AND Var sl' EQ Var sl) OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN Var l AND Var n IN Var l AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND Var sl EQ Q_Eats (Var sm) (Var sn) AND Var sl' EQ Q_Eats (Var sm') (Var sn'))))))))))), LstSeqP s k (HPair t u), VarP v} ⊢ (t EQ v AND u EQ i OR (IndP t OR t NEQ v) AND u EQ t) OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN k AND Var n IN k AND SeqStTermP v i (Var sm) (Var sm') s (Var m) AND SeqStTermP v i (Var sn) (Var sn') s (Var n) AND t EQ Q_Eats (Var sm) (Var sn) AND u EQ Q_Eats (Var sm') (Var sn')))))))› and 4 goals remain*) apply (rule Disj_EH (*‹⟦insert ?A ?H ⊢ ?C; insert ?B ?H ⊢ ?C⟧ ⟹ insert (?A OR ?B) ?H ⊢ ?C› ‹⟦insert ?A (insert ?A1.0 ?H) ⊢ ?B; insert ?Ba (insert ?A1.0 ?H) ⊢ ?B⟧ ⟹ insert ?A1.0 (insert (?A OR ?Ba) ?H) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 ?H)) ⊢ ?B; insert ?Ba (insert ?A1.0 (insert ?A2.0 ?H)) ⊢ ?B⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert (?A OR ?Ba) ?H)) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 ?H))) ⊢ ?B; insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 ?H))) ⊢ ?B⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert (?A OR ?Ba) ?H))) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 ?H)))) ⊢ ?B; insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 ?H)))) ⊢ ?B⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert (?A OR ?Ba) ?H)))) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 ?H))))) ⊢ ?B; insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 ?H))))) ⊢ ?B⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert (?A OR ?Ba) ?H))))) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 ?H)))))) ⊢ ?B; insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 ?H)))))) ⊢ ?B⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert (?A OR ?Ba) ?H)))))) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 ?H))))))) ⊢ ?B; insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 ?H))))))) ⊢ ?B⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 (insert (?A OR ?Ba) ?H))))))) ⊢ ?B› ‹⟦insert ?A (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)))))))) ⊢ ?B; insert ?Ba (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)))))))) ⊢ ?B⟧ ⟹ 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 (?A OR ?Ba) ?H)))))))) ⊢ ?B› ‹⟦insert ?A (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))))))))) ⊢ ?B; insert ?Ba (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))))))))) ⊢ ?B⟧ ⟹ 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 (?A OR ?Ba) ?H))))))))) ⊢ ?B›*)) (*goals: 1. ‹⟦atom (l::name) ♯ (v::tm, i::tm, t::tm, u::tm, s::tm, k::tm, sl::name, sl'::name, m::name, n::name, sm::name, sm'::name, sn::name, sn'::name); atom sl ♯ (v, i, t, u, s, k, sl', m, n, sm, sm', sn, sn'); atom sl' ♯ (v, i, t, u, s, k, m, n, sm, sm', sn, sn'); atom m ♯ (v, i, t, u, s, k, n, sm, sm', sn, sn'); atom n ♯ (v, i, t, u, s, k, sm, sm', sn, sn'); atom sm ♯ (v, i, t, u, s, k, sm', sn, sn'); atom sm' ♯ (v, i, t, u, s, k, sn, sn'); atom sn ♯ (v, i, t, u, s, k, sn'); atom sn' ♯ (v, i, t, u, s, k)⟧ ⟹ {Var sl EQ v AND Var sl' EQ i OR (IndP (Var sl) OR Var sl NEQ v) AND Var sl' EQ Var sl, t EQ Var sl, u EQ Var sl', HPair k (HPair (Var sl) (Var sl')) IN s, All2 l k (SyntaxN.Ex sl (SyntaxN.Ex sl' (HPair (Var l) (HPair (Var sl) (Var sl')) IN s AND ((Var sl EQ v AND Var sl' EQ i OR (IndP (Var sl) OR Var sl NEQ v) AND Var sl' EQ Var sl) OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN Var l AND Var n IN Var l AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND Var sl EQ Q_Eats (Var sm) (Var sn) AND Var sl' EQ Q_Eats (Var sm') (Var sn'))))))))))), LstSeqP s k (HPair t u), VarP v} ⊢ (t EQ v AND u EQ i OR (IndP t OR t NEQ v) AND u EQ t) OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN k AND Var n IN k AND SeqStTermP v i (Var sm) (Var sm') s (Var m) AND SeqStTermP v i (Var sn) (Var sn') s (Var n) AND t EQ Q_Eats (Var sm) (Var sn) AND u EQ Q_Eats (Var sm') (Var sn')))))))› 2. ‹⟦atom (l::name) ♯ (v::tm, i::tm, t::tm, u::tm, s::tm, k::tm, sl::name, sl'::name, m::name, n::name, sm::name, sm'::name, sn::name, sn'::name); atom sl ♯ (v, i, t, u, s, k, sl', m, n, sm, sm', sn, sn'); atom sl' ♯ (v, i, t, u, s, k, m, n, sm, sm', sn, sn'); atom m ♯ (v, i, t, u, s, k, n, sm, sm', sn, sn'); atom n ♯ (v, i, t, u, s, k, sm, sm', sn, sn'); atom sm ♯ (v, i, t, u, s, k, sm', sn, sn'); atom sm' ♯ (v, i, t, u, s, k, sn, sn'); atom sn ♯ (v, i, t, u, s, k, sn'); atom sn' ♯ (v, i, t, u, s, k)⟧ ⟹ {SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN k AND Var n IN k AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND Var sl EQ Q_Eats (Var sm) (Var sn) AND Var sl' EQ Q_Eats (Var sm') (Var sn'))))))), t EQ Var sl, u EQ Var sl', HPair k (HPair (Var sl) (Var sl')) IN s, All2 l k (SyntaxN.Ex sl (SyntaxN.Ex sl' (HPair (Var l) (HPair (Var sl) (Var sl')) IN s AND ((Var sl EQ v AND Var sl' EQ i OR (IndP (Var sl) OR Var sl NEQ v) AND Var sl' EQ Var sl) OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN Var l AND Var n IN Var l AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND Var sl EQ Q_Eats (Var sm) (Var sn) AND Var sl' EQ Q_Eats (Var sm') (Var sn'))))))))))), LstSeqP s k (HPair t u), VarP v} ⊢ (t EQ v AND u EQ i OR (IndP t OR t NEQ v) AND u EQ t) OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN k AND Var n IN k AND SeqStTermP v i (Var sm) (Var sm') s (Var m) AND SeqStTermP v i (Var sn) (Var sn') s (Var n) AND t EQ Q_Eats (Var sm) (Var sn) AND u EQ Q_Eats (Var sm') (Var sn')))))))› discuss goal 1*) apply (rule Disj_I1 (*‹?H ⊢ ?A ⟹ ?H ⊢ ?A OR ?B›*)) (*top goal: ‹⟦atom l ♯ (v, i, t, u, s, k, sl, sl', m, n, sm, sm', sn, sn'); atom sl ♯ (v, i, t, u, s, k, sl', m, n, sm, sm', sn, sn'); atom sl' ♯ (v, i, t, u, s, k, m, n, sm, sm', sn, sn'); atom m ♯ (v, i, t, u, s, k, n, sm, sm', sn, sn'); atom n ♯ (v, i, t, u, s, k, sm, sm', sn, sn'); atom sm ♯ (v, i, t, u, s, k, sm', sn, sn'); atom sm' ♯ (v, i, t, u, s, k, sn, sn'); atom sn ♯ (v, i, t, u, s, k, sn'); atom sn' ♯ (v, i, t, u, s, k)⟧ ⟹ {Var sl EQ v AND Var sl' EQ i OR (IndP (Var sl) OR Var sl NEQ v) AND Var sl' EQ Var sl, t EQ Var sl, u EQ Var sl', HPair k (HPair (Var sl) (Var sl')) IN s, All2 l k (SyntaxN.Ex sl (SyntaxN.Ex sl' (HPair (Var l) (HPair (Var sl) (Var sl')) IN s AND ((Var sl EQ v AND Var sl' EQ i OR (IndP (Var sl) OR Var sl NEQ v) AND Var sl' EQ Var sl) OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN Var l AND Var n IN Var l AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND Var sl EQ Q_Eats (Var sm) (Var sn) AND Var sl' EQ Q_Eats (Var sm') (Var sn'))))))))))), LstSeqP s k (HPair t u), VarP v} ⊢ (t EQ v AND u EQ i OR (IndP t OR t NEQ v) AND u EQ t) OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN k AND Var n IN k AND SeqStTermP v i (Var sm) (Var sm') s (Var m) AND SeqStTermP v i (Var sn) (Var sn') s (Var n) AND t EQ Q_Eats (Var sm) (Var sn) AND u EQ Q_Eats (Var sm') (Var sn')))))))› and 5 goals remain*) apply (rule anti_deduction (*‹?H ⊢ ?A IMP ?B ⟹ insert ?A ?H ⊢ ?B›*)) (*top goal: ‹⟦atom l ♯ (v, i, t, u, s, k, sl, sl', m, n, sm, sm', sn, sn'); atom sl ♯ (v, i, t, u, s, k, sl', m, n, sm, sm', sn, sn'); atom sl' ♯ (v, i, t, u, s, k, m, n, sm, sm', sn, sn'); atom m ♯ (v, i, t, u, s, k, n, sm, sm', sn, sn'); atom n ♯ (v, i, t, u, s, k, sm, sm', sn, sn'); atom sm ♯ (v, i, t, u, s, k, sm', sn, sn'); atom sm' ♯ (v, i, t, u, s, k, sn, sn'); atom sn ♯ (v, i, t, u, s, k, sn'); atom sn' ♯ (v, i, t, u, s, k)⟧ ⟹ {Var sl EQ v AND Var sl' EQ i OR (IndP (Var sl) OR Var sl NEQ v) AND Var sl' EQ Var sl, t EQ Var sl, u EQ Var sl', HPair k (HPair (Var sl) (Var sl')) IN s, All2 l k (SyntaxN.Ex sl (SyntaxN.Ex sl' (HPair (Var l) (HPair (Var sl) (Var sl')) IN s AND ((Var sl EQ v AND Var sl' EQ i OR (IndP (Var sl) OR Var sl NEQ v) AND Var sl' EQ Var sl) OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN Var l AND Var n IN Var l AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND Var sl EQ Q_Eats (Var sm) (Var sn) AND Var sl' EQ Q_Eats (Var sm') (Var sn'))))))))))), LstSeqP s k (HPair t u), VarP v} ⊢ t EQ v AND u EQ i OR (IndP t OR t NEQ v) AND u EQ t› and 5 goals remain*) apply (rule Var_Eq_subst_Iff [THEN Sym_L, THEN Iff_MP_same] (*‹insert ((?u1::tm) EQ Var (?i2::name)) (?H1::fm set) ⊢ (?B::fm)(?i2::=?u1) ⟹ insert (?u1 EQ Var ?i2) ?H1 ⊢ ?B›*)) (*top goal: ‹⟦atom l ♯ (v, i, t, u, s, k, sl, sl', m, n, sm, sm', sn, sn'); atom sl ♯ (v, i, t, u, s, k, sl', m, n, sm, sm', sn, sn'); atom sl' ♯ (v, i, t, u, s, k, m, n, sm, sm', sn, sn'); atom m ♯ (v, i, t, u, s, k, n, sm, sm', sn, sn'); atom n ♯ (v, i, t, u, s, k, sm, sm', sn, sn'); atom sm ♯ (v, i, t, u, s, k, sm', sn, sn'); atom sm' ♯ (v, i, t, u, s, k, sn, sn'); atom sn ♯ (v, i, t, u, s, k, sn'); atom sn' ♯ (v, i, t, u, s, k)⟧ ⟹ {t EQ Var sl, u EQ Var sl', HPair k (HPair (Var sl) (Var sl')) IN s, All2 l k (SyntaxN.Ex sl (SyntaxN.Ex sl' (HPair (Var l) (HPair (Var sl) (Var sl')) IN s AND ((Var sl EQ v AND Var sl' EQ i OR (IndP (Var sl) OR Var sl NEQ v) AND Var sl' EQ Var sl) OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN Var l AND Var n IN Var l AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND Var sl EQ Q_Eats (Var sm) (Var sn) AND Var sl' EQ Q_Eats (Var sm') (Var sn'))))))))))), LstSeqP s k (HPair t u), VarP v} ⊢ Var sl EQ v AND Var sl' EQ i OR (IndP (Var sl) OR Var sl NEQ v) AND Var sl' EQ Var sl IMP t EQ v AND u EQ i OR (IndP t OR t NEQ v) AND u EQ t› and 5 goals remain*) apply (rule Sym_L [THEN rotate2] (*‹insert (?t1 EQ ?u1) (insert ?A1.0 ?H) ⊢ ?B ⟹ insert ?A1.0 (insert (?u1 EQ ?t1) ?H) ⊢ ?B›*)) (*top goal: ‹⟦atom (l::name) ♯ (v::tm, i::tm, t::tm, u::tm, s::tm, k::tm, sl::name, sl'::name, m::name, n::name, sm::name, sm'::name, sn::name, sn'::name); atom sl ♯ (v, i, t, u, s, k, sl', m, n, sm, sm', sn, sn'); atom sl' ♯ (v, i, t, u, s, k, m, n, sm, sm', sn, sn'); atom m ♯ (v, i, t, u, s, k, n, sm, sm', sn, sn'); atom n ♯ (v, i, t, u, s, k, sm, sm', sn, sn'); atom sm ♯ (v, i, t, u, s, k, sm', sn, sn'); atom sm' ♯ (v, i, t, u, s, k, sn, sn'); atom sn ♯ (v, i, t, u, s, k, sn'); atom sn' ♯ (v, i, t, u, s, k)⟧ ⟹ {t EQ Var sl, u EQ Var sl', HPair k (HPair (Var sl) (Var sl')) IN s, All2 l k (SyntaxN.Ex sl (SyntaxN.Ex sl' (HPair (Var l) (HPair (Var sl) (Var sl')) IN s AND ((Var sl EQ v AND Var sl' EQ i OR (IndP (Var sl) OR Var sl NEQ v) AND Var sl' EQ Var sl) OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN Var l AND Var n IN Var l AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND Var sl EQ Q_Eats (Var sm) (Var sn) AND Var sl' EQ Q_Eats (Var sm') (Var sn'))))))))))), LstSeqP s k (HPair t u), VarP v} ⊢ (Var sl EQ v AND Var sl' EQ i OR (IndP (Var sl) OR Var sl NEQ v) AND Var sl' EQ Var sl IMP t EQ v AND u EQ i OR (IndP t OR t NEQ v) AND u EQ t)(sl::=t)› and 5 goals remain*) apply (rule Var_Eq_subst_Iff [THEN Iff_MP_same] (*‹insert (Var ?i1 EQ ?t1) ?H1 ⊢ ?B(?i1::=?t1) ⟹ insert (Var ?i1 EQ ?t1) ?H1 ⊢ ?B›*)) (*top goal: ‹⟦atom l ♯ (v, i, t, u, s, k, sl, sl', m, n, sm, sm', sn, sn'); atom sl ♯ (v, i, t, u, s, k, sl', m, n, sm, sm', sn, sn'); atom sl' ♯ (v, i, t, u, s, k, m, n, sm, sm', sn, sn'); atom m ♯ (v, i, t, u, s, k, n, sm, sm', sn, sn'); atom n ♯ (v, i, t, u, s, k, sm, sm', sn, sn'); atom sm ♯ (v, i, t, u, s, k, sm', sn, sn'); atom sm' ♯ (v, i, t, u, s, k, sn, sn'); atom sn ♯ (v, i, t, u, s, k, sn'); atom sn' ♯ (v, i, t, u, s, k)⟧ ⟹ {Var sl' EQ u, t EQ Var sl, HPair k (HPair (Var sl) (Var sl')) IN s, All2 l k (SyntaxN.Ex sl (SyntaxN.Ex sl' (HPair (Var l) (HPair (Var sl) (Var sl')) IN s AND ((Var sl EQ v AND Var sl' EQ i OR (IndP (Var sl) OR Var sl NEQ v) AND Var sl' EQ Var sl) OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN Var l AND Var n IN Var l AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND Var sl EQ Q_Eats (Var sm) (Var sn) AND Var sl' EQ Q_Eats (Var sm') (Var sn'))))))))))), LstSeqP s k (HPair t u), VarP v} ⊢ (Var sl EQ v AND Var sl' EQ i OR (IndP (Var sl) OR Var sl NEQ v) AND Var sl' EQ Var sl IMP t EQ v AND u EQ i OR (IndP t OR t NEQ v) AND u EQ t)(sl::=t)› and 5 goals remain*) apply force (*discuss goal 2*) apply (rule Ex_EH (*‹⟦insert ?A ?H ⊢ ?B; atom ?i ♯ ?B; ∀C∈?H. atom ?i ♯ C⟧ ⟹ insert (SyntaxN.Ex ?i ?A) ?H ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 ?H) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 ?H. atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert (SyntaxN.Ex ?i ?A) ?H) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 ?H)) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 ?H). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert (SyntaxN.Ex ?i ?A) ?H)) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 ?H))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 ?H)). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert (SyntaxN.Ex ?i ?A) ?H))) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 ?H)))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 ?H))). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert (SyntaxN.Ex ?i ?A) ?H)))) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 ?H))))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 ?H)))). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert (SyntaxN.Ex ?i ?A) ?H))))) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 ?H)))))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 ?H))))). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert (SyntaxN.Ex ?i ?A) ?H)))))) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 ?H))))))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 ?H)))))). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 (insert (SyntaxN.Ex ?i ?A) ?H))))))) ⊢ ?B› ‹⟦insert ?A (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)))))))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈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))))))). atom ?i ♯ C⟧ ⟹ 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 (SyntaxN.Ex ?i ?A) ?H)))))))) ⊢ ?B› ‹⟦insert ?A (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))))))))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈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)))))))). atom ?i ♯ C⟧ ⟹ 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 (SyntaxN.Ex ?i ?A) ?H))))))))) ⊢ ?B›*) Conj_EH (*‹insert ?A (insert ?B ?H) ⊢ ?C ⟹ insert (?A AND ?B) ?H ⊢ ?C› ‹insert ?A (insert ?Ba (insert ?A1.0 ?H)) ⊢ ?B ⟹ insert ?A1.0 (insert (?A AND ?Ba) ?H) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 ?H))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert (?A AND ?Ba) ?H)) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 ?H)))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert (?A AND ?Ba) ?H))) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 ?H))))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert (?A AND ?Ba) ?H)))) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 ?H)))))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert (?A AND ?Ba) ?H))))) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 ?H))))))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert (?A AND ?Ba) ?H)))))) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 ?H)))))))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 (insert (?A AND ?Ba) ?H))))))) ⊢ ?B› ‹insert ?A (insert ?Ba (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))))))))) ⊢ ?B ⟹ 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 (?A AND ?Ba) ?H)))))))) ⊢ ?B› ‹insert ?A (insert ?Ba (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)))))))))) ⊢ ?B ⟹ 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 (?A AND ?Ba) ?H))))))))) ⊢ ?B›*)) (*goals: 1. ‹⟦atom l ♯ (v, i, t, u, s, k, sl, sl', m, n, sm, sm', sn, sn'); atom sl ♯ (v, i, t, u, s, k, sl', m, n, sm, sm', sn, sn'); atom sl' ♯ (v, i, t, u, s, k, m, n, sm, sm', sn, sn'); atom m ♯ (v, i, t, u, s, k, n, sm, sm', sn, sn'); atom n ♯ (v, i, t, u, s, k, sm, sm', sn, sn'); atom sm ♯ (v, i, t, u, s, k, sm', sn, sn'); atom sm' ♯ (v, i, t, u, s, k, sn, sn'); atom sn ♯ (v, i, t, u, s, k, sn'); atom sn' ♯ (v, i, t, u, s, k)⟧ ⟹ {SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN k AND Var n IN k AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND Var sl EQ Q_Eats (Var sm) (Var sn) AND Var sl' EQ Q_Eats (Var sm') (Var sn')))))), t EQ Var sl, u EQ Var sl', HPair k (HPair (Var sl) (Var sl')) IN s, All2 l k (SyntaxN.Ex sl (SyntaxN.Ex sl' (HPair (Var l) (HPair (Var sl) (Var sl')) IN s AND ((Var sl EQ v AND Var sl' EQ i OR (IndP (Var sl) OR Var sl NEQ v) AND Var sl' EQ Var sl) OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN Var l AND Var n IN Var l AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND Var sl EQ Q_Eats (Var sm) (Var sn) AND Var sl' EQ Q_Eats (Var sm') (Var sn'))))))))))), LstSeqP s k (HPair t u), VarP v} ⊢ (t EQ v AND u EQ i OR (IndP t OR t NEQ v) AND u EQ t) OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN k AND Var n IN k AND SeqStTermP v i (Var sm) (Var sm') s (Var m) AND SeqStTermP v i (Var sn) (Var sn') s (Var n) AND t EQ Q_Eats (Var sm) (Var sn) AND u EQ Q_Eats (Var sm') (Var sn')))))))› 2. ‹⟦atom l ♯ (v, i, t, u, s, k, sl, sl', m, n, sm, sm', sn, sn'); atom sl ♯ (v, i, t, u, s, k, sl', m, n, sm, sm', sn, sn'); atom sl' ♯ (v, i, t, u, s, k, m, n, sm, sm', sn, sn'); atom m ♯ (v, i, t, u, s, k, n, sm, sm', sn, sn'); atom n ♯ (v, i, t, u, s, k, sm, sm', sn, sn'); atom sm ♯ (v, i, t, u, s, k, sm', sn, sn'); atom sm' ♯ (v, i, t, u, s, k, sn, sn'); atom sn ♯ (v, i, t, u, s, k, sn'); atom sn' ♯ (v, i, t, u, s, k)⟧ ⟹ atom m ♯ (t EQ v AND u EQ i OR (IndP t OR t NEQ v) AND u EQ t) OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN k AND Var n IN k AND SeqStTermP v i (Var sm) (Var sm') s (Var m) AND SeqStTermP v i (Var sn) (Var sn') s (Var n) AND t EQ Q_Eats (Var sm) (Var sn) AND u EQ Q_Eats (Var sm') (Var sn')))))))› 3. ‹⟦atom l ♯ (v, i, t, u, s, k, sl, sl', m, n, sm, sm', sn, sn'); atom sl ♯ (v, i, t, u, s, k, sl', m, n, sm, sm', sn, sn'); atom sl' ♯ (v, i, t, u, s, k, m, n, sm, sm', sn, sn'); atom m ♯ (v, i, t, u, s, k, n, sm, sm', sn, sn'); atom n ♯ (v, i, t, u, s, k, sm, sm', sn, sn'); atom sm ♯ (v, i, t, u, s, k, sm', sn, sn'); atom sm' ♯ (v, i, t, u, s, k, sn, sn'); atom sn ♯ (v, i, t, u, s, k, sn'); atom sn' ♯ (v, i, t, u, s, k)⟧ ⟹ ∀C∈{t EQ Var sl, u EQ Var sl', HPair k (HPair (Var sl) (Var sl')) IN s, All2 l k (SyntaxN.Ex sl (SyntaxN.Ex sl' (HPair (Var l) (HPair (Var sl) (Var sl')) IN s AND ((Var sl EQ v AND Var sl' EQ i OR (IndP (Var sl) OR Var sl NEQ v) AND Var sl' EQ Var sl) OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN Var l AND Var n IN Var l AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND Var sl EQ Q_Eats (Var sm) (Var sn) AND Var sl' EQ Q_Eats (Var sm') (Var sn'))))))))))), LstSeqP s k (HPair t u), VarP v}. atom m ♯ C› discuss goal 1*) apply (rule Ex_EH (*‹⟦insert ?A ?H ⊢ ?B; atom ?i ♯ ?B; ∀C∈?H. atom ?i ♯ C⟧ ⟹ insert (SyntaxN.Ex ?i ?A) ?H ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 ?H) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 ?H. atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert (SyntaxN.Ex ?i ?A) ?H) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 ?H)) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 ?H). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert (SyntaxN.Ex ?i ?A) ?H)) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 ?H))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 ?H)). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert (SyntaxN.Ex ?i ?A) ?H))) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 ?H)))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 ?H))). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert (SyntaxN.Ex ?i ?A) ?H)))) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 ?H))))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 ?H)))). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert (SyntaxN.Ex ?i ?A) ?H))))) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 ?H)))))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 ?H))))). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert (SyntaxN.Ex ?i ?A) ?H)))))) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 ?H))))))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 ?H)))))). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 (insert (SyntaxN.Ex ?i ?A) ?H))))))) ⊢ ?B› ‹⟦insert ?A (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)))))))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈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))))))). atom ?i ♯ C⟧ ⟹ 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 (SyntaxN.Ex ?i ?A) ?H)))))))) ⊢ ?B› ‹⟦insert ?A (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))))))))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈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)))))))). atom ?i ♯ C⟧ ⟹ 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 (SyntaxN.Ex ?i ?A) ?H))))))))) ⊢ ?B›*) Conj_EH (*‹insert ?A (insert ?B ?H) ⊢ ?C ⟹ insert (?A AND ?B) ?H ⊢ ?C› ‹insert ?A (insert ?Ba (insert ?A1.0 ?H)) ⊢ ?B ⟹ insert ?A1.0 (insert (?A AND ?Ba) ?H) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 ?H))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert (?A AND ?Ba) ?H)) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 ?H)))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert (?A AND ?Ba) ?H))) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 ?H))))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert (?A AND ?Ba) ?H)))) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 ?H)))))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert (?A AND ?Ba) ?H))))) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 ?H))))))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert (?A AND ?Ba) ?H)))))) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 ?H)))))))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 (insert (?A AND ?Ba) ?H))))))) ⊢ ?B› ‹insert ?A (insert ?Ba (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))))))))) ⊢ ?B ⟹ 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 (?A AND ?Ba) ?H)))))))) ⊢ ?B› ‹insert ?A (insert ?Ba (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)))))))))) ⊢ ?B ⟹ 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 (?A AND ?Ba) ?H))))))))) ⊢ ?B›*)) (*goals: 1. ‹⟦atom l ♯ (v, i, t, u, s, k, sl, sl', m, n, sm, sm', sn, sn'); atom sl ♯ (v, i, t, u, s, k, sl', m, n, sm, sm', sn, sn'); atom sl' ♯ (v, i, t, u, s, k, m, n, sm, sm', sn, sn'); atom m ♯ (v, i, t, u, s, k, n, sm, sm', sn, sn'); atom n ♯ (v, i, t, u, s, k, sm, sm', sn, sn'); atom sm ♯ (v, i, t, u, s, k, sm', sn, sn'); atom sm' ♯ (v, i, t, u, s, k, sn, sn'); atom sn ♯ (v, i, t, u, s, k, sn'); atom sn' ♯ (v, i, t, u, s, k)⟧ ⟹ {SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN k AND Var n IN k AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND Var sl EQ Q_Eats (Var sm) (Var sn) AND Var sl' EQ Q_Eats (Var sm') (Var sn'))))), t EQ Var sl, u EQ Var sl', HPair k (HPair (Var sl) (Var sl')) IN s, All2 l k (SyntaxN.Ex sl (SyntaxN.Ex sl' (HPair (Var l) (HPair (Var sl) (Var sl')) IN s AND ((Var sl EQ v AND Var sl' EQ i OR (IndP (Var sl) OR Var sl NEQ v) AND Var sl' EQ Var sl) OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN Var l AND Var n IN Var l AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND Var sl EQ Q_Eats (Var sm) (Var sn) AND Var sl' EQ Q_Eats (Var sm') (Var sn'))))))))))), LstSeqP s k (HPair t u), VarP v} ⊢ (t EQ v AND u EQ i OR (IndP t OR t NEQ v) AND u EQ t) OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN k AND Var n IN k AND SeqStTermP v i (Var sm) (Var sm') s (Var m) AND SeqStTermP v i (Var sn) (Var sn') s (Var n) AND t EQ Q_Eats (Var sm) (Var sn) AND u EQ Q_Eats (Var sm') (Var sn')))))))› 2. ‹⟦atom l ♯ (v, i, t, u, s, k, sl, sl', m, n, sm, sm', sn, sn'); atom sl ♯ (v, i, t, u, s, k, sl', m, n, sm, sm', sn, sn'); atom sl' ♯ (v, i, t, u, s, k, m, n, sm, sm', sn, sn'); atom m ♯ (v, i, t, u, s, k, n, sm, sm', sn, sn'); atom n ♯ (v, i, t, u, s, k, sm, sm', sn, sn'); atom sm ♯ (v, i, t, u, s, k, sm', sn, sn'); atom sm' ♯ (v, i, t, u, s, k, sn, sn'); atom sn ♯ (v, i, t, u, s, k, sn'); atom sn' ♯ (v, i, t, u, s, k)⟧ ⟹ atom n ♯ (t EQ v AND u EQ i OR (IndP t OR t NEQ v) AND u EQ t) OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN k AND Var n IN k AND SeqStTermP v i (Var sm) (Var sm') s (Var m) AND SeqStTermP v i (Var sn) (Var sn') s (Var n) AND t EQ Q_Eats (Var sm) (Var sn) AND u EQ Q_Eats (Var sm') (Var sn')))))))› 3. ‹⟦atom l ♯ (v, i, t, u, s, k, sl, sl', m, n, sm, sm', sn, sn'); atom sl ♯ (v, i, t, u, s, k, sl', m, n, sm, sm', sn, sn'); atom sl' ♯ (v, i, t, u, s, k, m, n, sm, sm', sn, sn'); atom m ♯ (v, i, t, u, s, k, n, sm, sm', sn, sn'); atom n ♯ (v, i, t, u, s, k, sm, sm', sn, sn'); atom sm ♯ (v, i, t, u, s, k, sm', sn, sn'); atom sm' ♯ (v, i, t, u, s, k, sn, sn'); atom sn ♯ (v, i, t, u, s, k, sn'); atom sn' ♯ (v, i, t, u, s, k)⟧ ⟹ ∀C∈{t EQ Var sl, u EQ Var sl', HPair k (HPair (Var sl) (Var sl')) IN s, All2 l k (SyntaxN.Ex sl (SyntaxN.Ex sl' (HPair (Var l) (HPair (Var sl) (Var sl')) IN s AND ((Var sl EQ v AND Var sl' EQ i OR (IndP (Var sl) OR Var sl NEQ v) AND Var sl' EQ Var sl) OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN Var l AND Var n IN Var l AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND Var sl EQ Q_Eats (Var sm) (Var sn) AND Var sl' EQ Q_Eats (Var sm') (Var sn'))))))))))), LstSeqP s k (HPair t u), VarP v}. atom n ♯ C› discuss goal 1*) apply (rule Ex_EH (*‹⟦insert ?A ?H ⊢ ?B; atom ?i ♯ ?B; ∀C∈?H. atom ?i ♯ C⟧ ⟹ insert (SyntaxN.Ex ?i ?A) ?H ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 ?H) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 ?H. atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert (SyntaxN.Ex ?i ?A) ?H) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 ?H)) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 ?H). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert (SyntaxN.Ex ?i ?A) ?H)) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 ?H))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 ?H)). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert (SyntaxN.Ex ?i ?A) ?H))) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 ?H)))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 ?H))). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert (SyntaxN.Ex ?i ?A) ?H)))) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 ?H))))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 ?H)))). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert (SyntaxN.Ex ?i ?A) ?H))))) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 ?H)))))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 ?H))))). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert (SyntaxN.Ex ?i ?A) ?H)))))) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 ?H))))))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 ?H)))))). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 (insert (SyntaxN.Ex ?i ?A) ?H))))))) ⊢ ?B› ‹⟦insert ?A (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)))))))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈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))))))). atom ?i ♯ C⟧ ⟹ 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 (SyntaxN.Ex ?i ?A) ?H)))))))) ⊢ ?B› ‹⟦insert ?A (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))))))))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈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)))))))). atom ?i ♯ C⟧ ⟹ 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 (SyntaxN.Ex ?i ?A) ?H))))))))) ⊢ ?B›*) Conj_EH (*‹insert ?A (insert ?B ?H) ⊢ ?C ⟹ insert (?A AND ?B) ?H ⊢ ?C› ‹insert ?A (insert ?Ba (insert ?A1.0 ?H)) ⊢ ?B ⟹ insert ?A1.0 (insert (?A AND ?Ba) ?H) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 ?H))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert (?A AND ?Ba) ?H)) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 ?H)))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert (?A AND ?Ba) ?H))) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 ?H))))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert (?A AND ?Ba) ?H)))) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 ?H)))))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert (?A AND ?Ba) ?H))))) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 ?H))))))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert (?A AND ?Ba) ?H)))))) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 ?H)))))))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 (insert (?A AND ?Ba) ?H))))))) ⊢ ?B› ‹insert ?A (insert ?Ba (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))))))))) ⊢ ?B ⟹ 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 (?A AND ?Ba) ?H)))))))) ⊢ ?B› ‹insert ?A (insert ?Ba (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)))))))))) ⊢ ?B ⟹ 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 (?A AND ?Ba) ?H))))))))) ⊢ ?B›*)) (*goals: 1. ‹⟦atom l ♯ (v, i, t, u, s, k, sl, sl', m, n, sm, sm', sn, sn'); atom sl ♯ (v, i, t, u, s, k, sl', m, n, sm, sm', sn, sn'); atom sl' ♯ (v, i, t, u, s, k, m, n, sm, sm', sn, sn'); atom m ♯ (v, i, t, u, s, k, n, sm, sm', sn, sn'); atom n ♯ (v, i, t, u, s, k, sm, sm', sn, sn'); atom sm ♯ (v, i, t, u, s, k, sm', sn, sn'); atom sm' ♯ (v, i, t, u, s, k, sn, sn'); atom sn ♯ (v, i, t, u, s, k, sn'); atom sn' ♯ (v, i, t, u, s, k)⟧ ⟹ {SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN k AND Var n IN k AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND Var sl EQ Q_Eats (Var sm) (Var sn) AND Var sl' EQ Q_Eats (Var sm') (Var sn')))), t EQ Var sl, u EQ Var sl', HPair k (HPair (Var sl) (Var sl')) IN s, All2 l k (SyntaxN.Ex sl (SyntaxN.Ex sl' (HPair (Var l) (HPair (Var sl) (Var sl')) IN s AND ((Var sl EQ v AND Var sl' EQ i OR (IndP (Var sl) OR Var sl NEQ v) AND Var sl' EQ Var sl) OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN Var l AND Var n IN Var l AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND Var sl EQ Q_Eats (Var sm) (Var sn) AND Var sl' EQ Q_Eats (Var sm') (Var sn'))))))))))), LstSeqP s k (HPair t u), VarP v} ⊢ (t EQ v AND u EQ i OR (IndP t OR t NEQ v) AND u EQ t) OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN k AND Var n IN k AND SeqStTermP v i (Var sm) (Var sm') s (Var m) AND SeqStTermP v i (Var sn) (Var sn') s (Var n) AND t EQ Q_Eats (Var sm) (Var sn) AND u EQ Q_Eats (Var sm') (Var sn')))))))› 2. ‹⟦atom l ♯ (v, i, t, u, s, k, sl, sl', m, n, sm, sm', sn, sn'); atom sl ♯ (v, i, t, u, s, k, sl', m, n, sm, sm', sn, sn'); atom sl' ♯ (v, i, t, u, s, k, m, n, sm, sm', sn, sn'); atom m ♯ (v, i, t, u, s, k, n, sm, sm', sn, sn'); atom n ♯ (v, i, t, u, s, k, sm, sm', sn, sn'); atom sm ♯ (v, i, t, u, s, k, sm', sn, sn'); atom sm' ♯ (v, i, t, u, s, k, sn, sn'); atom sn ♯ (v, i, t, u, s, k, sn'); atom sn' ♯ (v, i, t, u, s, k)⟧ ⟹ atom sm ♯ (t EQ v AND u EQ i OR (IndP t OR t NEQ v) AND u EQ t) OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN k AND Var n IN k AND SeqStTermP v i (Var sm) (Var sm') s (Var m) AND SeqStTermP v i (Var sn) (Var sn') s (Var n) AND t EQ Q_Eats (Var sm) (Var sn) AND u EQ Q_Eats (Var sm') (Var sn')))))))› 3. ‹⟦atom l ♯ (v, i, t, u, s, k, sl, sl', m, n, sm, sm', sn, sn'); atom sl ♯ (v, i, t, u, s, k, sl', m, n, sm, sm', sn, sn'); atom sl' ♯ (v, i, t, u, s, k, m, n, sm, sm', sn, sn'); atom m ♯ (v, i, t, u, s, k, n, sm, sm', sn, sn'); atom n ♯ (v, i, t, u, s, k, sm, sm', sn, sn'); atom sm ♯ (v, i, t, u, s, k, sm', sn, sn'); atom sm' ♯ (v, i, t, u, s, k, sn, sn'); atom sn ♯ (v, i, t, u, s, k, sn'); atom sn' ♯ (v, i, t, u, s, k)⟧ ⟹ ∀C∈{t EQ Var sl, u EQ Var sl', HPair k (HPair (Var sl) (Var sl')) IN s, All2 l k (SyntaxN.Ex sl (SyntaxN.Ex sl' (HPair (Var l) (HPair (Var sl) (Var sl')) IN s AND ((Var sl EQ v AND Var sl' EQ i OR (IndP (Var sl) OR Var sl NEQ v) AND Var sl' EQ Var sl) OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN Var l AND Var n IN Var l AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND Var sl EQ Q_Eats (Var sm) (Var sn) AND Var sl' EQ Q_Eats (Var sm') (Var sn'))))))))))), LstSeqP s k (HPair t u), VarP v}. atom sm ♯ C› discuss goal 1*) apply (rule Ex_EH (*‹⟦insert ?A ?H ⊢ ?B; atom ?i ♯ ?B; ∀C∈?H. atom ?i ♯ C⟧ ⟹ insert (SyntaxN.Ex ?i ?A) ?H ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 ?H) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 ?H. atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert (SyntaxN.Ex ?i ?A) ?H) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 ?H)) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 ?H). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert (SyntaxN.Ex ?i ?A) ?H)) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 ?H))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 ?H)). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert (SyntaxN.Ex ?i ?A) ?H))) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 ?H)))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 ?H))). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert (SyntaxN.Ex ?i ?A) ?H)))) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 ?H))))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 ?H)))). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert (SyntaxN.Ex ?i ?A) ?H))))) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 ?H)))))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 ?H))))). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert (SyntaxN.Ex ?i ?A) ?H)))))) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 ?H))))))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 ?H)))))). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 (insert (SyntaxN.Ex ?i ?A) ?H))))))) ⊢ ?B› ‹⟦insert ?A (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)))))))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈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))))))). atom ?i ♯ C⟧ ⟹ 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 (SyntaxN.Ex ?i ?A) ?H)))))))) ⊢ ?B› ‹⟦insert ?A (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))))))))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈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)))))))). atom ?i ♯ C⟧ ⟹ 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 (SyntaxN.Ex ?i ?A) ?H))))))))) ⊢ ?B›*) Conj_EH (*‹insert ?A (insert ?B ?H) ⊢ ?C ⟹ insert (?A AND ?B) ?H ⊢ ?C› ‹insert ?A (insert ?Ba (insert ?A1.0 ?H)) ⊢ ?B ⟹ insert ?A1.0 (insert (?A AND ?Ba) ?H) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 ?H))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert (?A AND ?Ba) ?H)) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 ?H)))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert (?A AND ?Ba) ?H))) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 ?H))))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert (?A AND ?Ba) ?H)))) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 ?H)))))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert (?A AND ?Ba) ?H))))) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 ?H))))))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert (?A AND ?Ba) ?H)))))) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 ?H)))))))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 (insert (?A AND ?Ba) ?H))))))) ⊢ ?B› ‹insert ?A (insert ?Ba (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))))))))) ⊢ ?B ⟹ 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 (?A AND ?Ba) ?H)))))))) ⊢ ?B› ‹insert ?A (insert ?Ba (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)))))))))) ⊢ ?B ⟹ 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 (?A AND ?Ba) ?H))))))))) ⊢ ?B›*)) (*goals: 1. ‹⟦atom l ♯ (v, i, t, u, s, k, sl, sl', m, n, sm, sm', sn, sn'); atom sl ♯ (v, i, t, u, s, k, sl', m, n, sm, sm', sn, sn'); atom sl' ♯ (v, i, t, u, s, k, m, n, sm, sm', sn, sn'); atom m ♯ (v, i, t, u, s, k, n, sm, sm', sn, sn'); atom n ♯ (v, i, t, u, s, k, sm, sm', sn, sn'); atom sm ♯ (v, i, t, u, s, k, sm', sn, sn'); atom sm' ♯ (v, i, t, u, s, k, sn, sn'); atom sn ♯ (v, i, t, u, s, k, sn'); atom sn' ♯ (v, i, t, u, s, k)⟧ ⟹ {SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN k AND Var n IN k AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND Var sl EQ Q_Eats (Var sm) (Var sn) AND Var sl' EQ Q_Eats (Var sm') (Var sn'))), t EQ Var sl, u EQ Var sl', HPair k (HPair (Var sl) (Var sl')) IN s, All2 l k (SyntaxN.Ex sl (SyntaxN.Ex sl' (HPair (Var l) (HPair (Var sl) (Var sl')) IN s AND ((Var sl EQ v AND Var sl' EQ i OR (IndP (Var sl) OR Var sl NEQ v) AND Var sl' EQ Var sl) OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN Var l AND Var n IN Var l AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND Var sl EQ Q_Eats (Var sm) (Var sn) AND Var sl' EQ Q_Eats (Var sm') (Var sn'))))))))))), LstSeqP s k (HPair t u), VarP v} ⊢ (t EQ v AND u EQ i OR (IndP t OR t NEQ v) AND u EQ t) OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN k AND Var n IN k AND SeqStTermP v i (Var sm) (Var sm') s (Var m) AND SeqStTermP v i (Var sn) (Var sn') s (Var n) AND t EQ Q_Eats (Var sm) (Var sn) AND u EQ Q_Eats (Var sm') (Var sn')))))))› 2. ‹⟦atom l ♯ (v, i, t, u, s, k, sl, sl', m, n, sm, sm', sn, sn'); atom sl ♯ (v, i, t, u, s, k, sl', m, n, sm, sm', sn, sn'); atom sl' ♯ (v, i, t, u, s, k, m, n, sm, sm', sn, sn'); atom m ♯ (v, i, t, u, s, k, n, sm, sm', sn, sn'); atom n ♯ (v, i, t, u, s, k, sm, sm', sn, sn'); atom sm ♯ (v, i, t, u, s, k, sm', sn, sn'); atom sm' ♯ (v, i, t, u, s, k, sn, sn'); atom sn ♯ (v, i, t, u, s, k, sn'); atom sn' ♯ (v, i, t, u, s, k)⟧ ⟹ atom sm' ♯ (t EQ v AND u EQ i OR (IndP t OR t NEQ v) AND u EQ t) OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN k AND Var n IN k AND SeqStTermP v i (Var sm) (Var sm') s (Var m) AND SeqStTermP v i (Var sn) (Var sn') s (Var n) AND t EQ Q_Eats (Var sm) (Var sn) AND u EQ Q_Eats (Var sm') (Var sn')))))))› 3. ‹⟦atom l ♯ (v, i, t, u, s, k, sl, sl', m, n, sm, sm', sn, sn'); atom sl ♯ (v, i, t, u, s, k, sl', m, n, sm, sm', sn, sn'); atom sl' ♯ (v, i, t, u, s, k, m, n, sm, sm', sn, sn'); atom m ♯ (v, i, t, u, s, k, n, sm, sm', sn, sn'); atom n ♯ (v, i, t, u, s, k, sm, sm', sn, sn'); atom sm ♯ (v, i, t, u, s, k, sm', sn, sn'); atom sm' ♯ (v, i, t, u, s, k, sn, sn'); atom sn ♯ (v, i, t, u, s, k, sn'); atom sn' ♯ (v, i, t, u, s, k)⟧ ⟹ ∀C∈{t EQ Var sl, u EQ Var sl', HPair k (HPair (Var sl) (Var sl')) IN s, All2 l k (SyntaxN.Ex sl (SyntaxN.Ex sl' (HPair (Var l) (HPair (Var sl) (Var sl')) IN s AND ((Var sl EQ v AND Var sl' EQ i OR (IndP (Var sl) OR Var sl NEQ v) AND Var sl' EQ Var sl) OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN Var l AND Var n IN Var l AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND Var sl EQ Q_Eats (Var sm) (Var sn) AND Var sl' EQ Q_Eats (Var sm') (Var sn'))))))))))), LstSeqP s k (HPair t u), VarP v}. atom sm' ♯ C› discuss goal 1*) apply (rule Ex_EH (*‹⟦insert ?A ?H ⊢ ?B; atom ?i ♯ ?B; ∀C∈?H. atom ?i ♯ C⟧ ⟹ insert (SyntaxN.Ex ?i ?A) ?H ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 ?H) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 ?H. atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert (SyntaxN.Ex ?i ?A) ?H) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 ?H)) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 ?H). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert (SyntaxN.Ex ?i ?A) ?H)) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 ?H))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 ?H)). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert (SyntaxN.Ex ?i ?A) ?H))) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 ?H)))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 ?H))). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert (SyntaxN.Ex ?i ?A) ?H)))) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 ?H))))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 ?H)))). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert (SyntaxN.Ex ?i ?A) ?H))))) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 ?H)))))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 ?H))))). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert (SyntaxN.Ex ?i ?A) ?H)))))) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 ?H))))))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 ?H)))))). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 (insert (SyntaxN.Ex ?i ?A) ?H))))))) ⊢ ?B› ‹⟦insert ?A (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)))))))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈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))))))). atom ?i ♯ C⟧ ⟹ 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 (SyntaxN.Ex ?i ?A) ?H)))))))) ⊢ ?B› ‹⟦insert ?A (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))))))))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈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)))))))). atom ?i ♯ C⟧ ⟹ 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 (SyntaxN.Ex ?i ?A) ?H))))))))) ⊢ ?B›*) Conj_EH (*‹insert ?A (insert ?B ?H) ⊢ ?C ⟹ insert (?A AND ?B) ?H ⊢ ?C› ‹insert ?A (insert ?Ba (insert ?A1.0 ?H)) ⊢ ?B ⟹ insert ?A1.0 (insert (?A AND ?Ba) ?H) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 ?H))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert (?A AND ?Ba) ?H)) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 ?H)))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert (?A AND ?Ba) ?H))) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 ?H))))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert (?A AND ?Ba) ?H)))) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 ?H)))))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert (?A AND ?Ba) ?H))))) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 ?H))))))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert (?A AND ?Ba) ?H)))))) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 ?H)))))))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 (insert (?A AND ?Ba) ?H))))))) ⊢ ?B› ‹insert ?A (insert ?Ba (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))))))))) ⊢ ?B ⟹ 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 (?A AND ?Ba) ?H)))))))) ⊢ ?B› ‹insert ?A (insert ?Ba (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)))))))))) ⊢ ?B ⟹ 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 (?A AND ?Ba) ?H))))))))) ⊢ ?B›*)) (*goals: 1. ‹⟦atom l ♯ (v, i, t, u, s, k, sl, sl', m, n, sm, sm', sn, sn'); atom sl ♯ (v, i, t, u, s, k, sl', m, n, sm, sm', sn, sn'); atom sl' ♯ (v, i, t, u, s, k, m, n, sm, sm', sn, sn'); atom m ♯ (v, i, t, u, s, k, n, sm, sm', sn, sn'); atom n ♯ (v, i, t, u, s, k, sm, sm', sn, sn'); atom sm ♯ (v, i, t, u, s, k, sm', sn, sn'); atom sm' ♯ (v, i, t, u, s, k, sn, sn'); atom sn ♯ (v, i, t, u, s, k, sn'); atom sn' ♯ (v, i, t, u, s, k)⟧ ⟹ {SyntaxN.Ex sn' (Var m IN k AND Var n IN k AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND Var sl EQ Q_Eats (Var sm) (Var sn) AND Var sl' EQ Q_Eats (Var sm') (Var sn')), t EQ Var sl, u EQ Var sl', HPair k (HPair (Var sl) (Var sl')) IN s, All2 l k (SyntaxN.Ex sl (SyntaxN.Ex sl' (HPair (Var l) (HPair (Var sl) (Var sl')) IN s AND ((Var sl EQ v AND Var sl' EQ i OR (IndP (Var sl) OR Var sl NEQ v) AND Var sl' EQ Var sl) OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN Var l AND Var n IN Var l AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND Var sl EQ Q_Eats (Var sm) (Var sn) AND Var sl' EQ Q_Eats (Var sm') (Var sn'))))))))))), LstSeqP s k (HPair t u), VarP v} ⊢ (t EQ v AND u EQ i OR (IndP t OR t NEQ v) AND u EQ t) OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN k AND Var n IN k AND SeqStTermP v i (Var sm) (Var sm') s (Var m) AND SeqStTermP v i (Var sn) (Var sn') s (Var n) AND t EQ Q_Eats (Var sm) (Var sn) AND u EQ Q_Eats (Var sm') (Var sn')))))))› 2. ‹⟦atom l ♯ (v, i, t, u, s, k, sl, sl', m, n, sm, sm', sn, sn'); atom sl ♯ (v, i, t, u, s, k, sl', m, n, sm, sm', sn, sn'); atom sl' ♯ (v, i, t, u, s, k, m, n, sm, sm', sn, sn'); atom m ♯ (v, i, t, u, s, k, n, sm, sm', sn, sn'); atom n ♯ (v, i, t, u, s, k, sm, sm', sn, sn'); atom sm ♯ (v, i, t, u, s, k, sm', sn, sn'); atom sm' ♯ (v, i, t, u, s, k, sn, sn'); atom sn ♯ (v, i, t, u, s, k, sn'); atom sn' ♯ (v, i, t, u, s, k)⟧ ⟹ atom sn ♯ (t EQ v AND u EQ i OR (IndP t OR t NEQ v) AND u EQ t) OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN k AND Var n IN k AND SeqStTermP v i (Var sm) (Var sm') s (Var m) AND SeqStTermP v i (Var sn) (Var sn') s (Var n) AND t EQ Q_Eats (Var sm) (Var sn) AND u EQ Q_Eats (Var sm') (Var sn')))))))› 3. ‹⟦atom l ♯ (v, i, t, u, s, k, sl, sl', m, n, sm, sm', sn, sn'); atom sl ♯ (v, i, t, u, s, k, sl', m, n, sm, sm', sn, sn'); atom sl' ♯ (v, i, t, u, s, k, m, n, sm, sm', sn, sn'); atom m ♯ (v, i, t, u, s, k, n, sm, sm', sn, sn'); atom n ♯ (v, i, t, u, s, k, sm, sm', sn, sn'); atom sm ♯ (v, i, t, u, s, k, sm', sn, sn'); atom sm' ♯ (v, i, t, u, s, k, sn, sn'); atom sn ♯ (v, i, t, u, s, k, sn'); atom sn' ♯ (v, i, t, u, s, k)⟧ ⟹ ∀C∈{t EQ Var sl, u EQ Var sl', HPair k (HPair (Var sl) (Var sl')) IN s, All2 l k (SyntaxN.Ex sl (SyntaxN.Ex sl' (HPair (Var l) (HPair (Var sl) (Var sl')) IN s AND ((Var sl EQ v AND Var sl' EQ i OR (IndP (Var sl) OR Var sl NEQ v) AND Var sl' EQ Var sl) OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN Var l AND Var n IN Var l AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND Var sl EQ Q_Eats (Var sm) (Var sn) AND Var sl' EQ Q_Eats (Var sm') (Var sn'))))))))))), LstSeqP s k (HPair t u), VarP v}. atom sn ♯ C› discuss goal 1*) apply (rule Ex_EH (*‹⟦insert ?A ?H ⊢ ?B; atom ?i ♯ ?B; ∀C∈?H. atom ?i ♯ C⟧ ⟹ insert (SyntaxN.Ex ?i ?A) ?H ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 ?H) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 ?H. atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert (SyntaxN.Ex ?i ?A) ?H) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 ?H)) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 ?H). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert (SyntaxN.Ex ?i ?A) ?H)) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 ?H))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 ?H)). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert (SyntaxN.Ex ?i ?A) ?H))) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 ?H)))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 ?H))). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert (SyntaxN.Ex ?i ?A) ?H)))) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 ?H))))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 ?H)))). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert (SyntaxN.Ex ?i ?A) ?H))))) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 ?H)))))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 ?H))))). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert (SyntaxN.Ex ?i ?A) ?H)))))) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 ?H))))))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 ?H)))))). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 (insert (SyntaxN.Ex ?i ?A) ?H))))))) ⊢ ?B› ‹⟦insert ?A (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)))))))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈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))))))). atom ?i ♯ C⟧ ⟹ 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 (SyntaxN.Ex ?i ?A) ?H)))))))) ⊢ ?B› ‹⟦insert ?A (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))))))))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈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)))))))). atom ?i ♯ C⟧ ⟹ 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 (SyntaxN.Ex ?i ?A) ?H))))))))) ⊢ ?B›*) Conj_EH (*‹insert ?A (insert ?B ?H) ⊢ ?C ⟹ insert (?A AND ?B) ?H ⊢ ?C› ‹insert ?A (insert ?Ba (insert ?A1.0 ?H)) ⊢ ?B ⟹ insert ?A1.0 (insert (?A AND ?Ba) ?H) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 ?H))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert (?A AND ?Ba) ?H)) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 ?H)))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert (?A AND ?Ba) ?H))) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 ?H))))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert (?A AND ?Ba) ?H)))) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 ?H)))))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert (?A AND ?Ba) ?H))))) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 ?H))))))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert (?A AND ?Ba) ?H)))))) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 ?H)))))))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 (insert (?A AND ?Ba) ?H))))))) ⊢ ?B› ‹insert ?A (insert ?Ba (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))))))))) ⊢ ?B ⟹ 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 (?A AND ?Ba) ?H)))))))) ⊢ ?B› ‹insert ?A (insert ?Ba (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)))))))))) ⊢ ?B ⟹ 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 (?A AND ?Ba) ?H))))))))) ⊢ ?B›*)) (*goals: 1. ‹⟦atom (l::name) ♯ (v::tm, i::tm, t::tm, u::tm, s::tm, k::tm, sl::name, sl'::name, m::name, n::name, sm::name, sm'::name, sn::name, sn'::name); atom sl ♯ (v, i, t, u, s, k, sl', m, n, sm, sm', sn, sn'); atom sl' ♯ (v, i, t, u, s, k, m, n, sm, sm', sn, sn'); atom m ♯ (v, i, t, u, s, k, n, sm, sm', sn, sn'); atom n ♯ (v, i, t, u, s, k, sm, sm', sn, sn'); atom sm ♯ (v, i, t, u, s, k, sm', sn, sn'); atom sm' ♯ (v, i, t, u, s, k, sn, sn'); atom sn ♯ (v, i, t, u, s, k, sn'); atom sn' ♯ (v, i, t, u, s, k)⟧ ⟹ {Var m IN k AND Var n IN k AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND Var sl EQ Q_Eats (Var sm) (Var sn) AND Var sl' EQ Q_Eats (Var sm') (Var sn'), t EQ Var sl, u EQ Var sl', HPair k (HPair (Var sl) (Var sl')) IN s, All2 l k (SyntaxN.Ex sl (SyntaxN.Ex sl' (HPair (Var l) (HPair (Var sl) (Var sl')) IN s AND ((Var sl EQ v AND Var sl' EQ i OR (IndP (Var sl) OR Var sl NEQ v) AND Var sl' EQ Var sl) OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN Var l AND Var n IN Var l AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND Var sl EQ Q_Eats (Var sm) (Var sn) AND Var sl' EQ Q_Eats (Var sm') (Var sn'))))))))))), LstSeqP s k (HPair t u), VarP v} ⊢ (t EQ v AND u EQ i OR (IndP t OR t NEQ v) AND u EQ t) OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN k AND Var n IN k AND SeqStTermP v i (Var sm) (Var sm') s (Var m) AND SeqStTermP v i (Var sn) (Var sn') s (Var n) AND t EQ Q_Eats (Var sm) (Var sn) AND u EQ Q_Eats (Var sm') (Var sn')))))))› 2. ‹⟦atom (l::name) ♯ (v::tm, i::tm, t::tm, u::tm, s::tm, k::tm, sl::name, sl'::name, m::name, n::name, sm::name, sm'::name, sn::name, sn'::name); atom sl ♯ (v, i, t, u, s, k, sl', m, n, sm, sm', sn, sn'); atom sl' ♯ (v, i, t, u, s, k, m, n, sm, sm', sn, sn'); atom m ♯ (v, i, t, u, s, k, n, sm, sm', sn, sn'); atom n ♯ (v, i, t, u, s, k, sm, sm', sn, sn'); atom sm ♯ (v, i, t, u, s, k, sm', sn, sn'); atom sm' ♯ (v, i, t, u, s, k, sn, sn'); atom sn ♯ (v, i, t, u, s, k, sn'); atom sn' ♯ (v, i, t, u, s, k)⟧ ⟹ atom sn' ♯ (t EQ v AND u EQ i OR (IndP t OR t NEQ v) AND u EQ t) OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN k AND Var n IN k AND SeqStTermP v i (Var sm) (Var sm') s (Var m) AND SeqStTermP v i (Var sn) (Var sn') s (Var n) AND t EQ Q_Eats (Var sm) (Var sn) AND u EQ Q_Eats (Var sm') (Var sn')))))))› 3. ‹⟦atom (l::name) ♯ (v::tm, i::tm, t::tm, u::tm, s::tm, k::tm, sl::name, sl'::name, m::name, n::name, sm::name, sm'::name, sn::name, sn'::name); atom sl ♯ (v, i, t, u, s, k, sl', m, n, sm, sm', sn, sn'); atom sl' ♯ (v, i, t, u, s, k, m, n, sm, sm', sn, sn'); atom m ♯ (v, i, t, u, s, k, n, sm, sm', sn, sn'); atom n ♯ (v, i, t, u, s, k, sm, sm', sn, sn'); atom sm ♯ (v, i, t, u, s, k, sm', sn, sn'); atom sm' ♯ (v, i, t, u, s, k, sn, sn'); atom sn ♯ (v, i, t, u, s, k, sn'); atom sn' ♯ (v, i, t, u, s, k)⟧ ⟹ ∀C::fm∈{t EQ Var sl, u EQ Var sl', HPair k (HPair (Var sl) (Var sl')) IN s, All2 l k (SyntaxN.Ex sl (SyntaxN.Ex sl' (HPair (Var l) (HPair (Var sl) (Var sl')) IN s AND ((Var sl EQ v AND Var sl' EQ i OR (IndP (Var sl) OR Var sl NEQ v) AND Var sl' EQ Var sl) OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN Var l AND Var n IN Var l AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND Var sl EQ Q_Eats (Var sm) (Var sn) AND Var sl' EQ Q_Eats (Var sm') (Var sn'))))))))))), LstSeqP s k (HPair t u), VarP v}. atom sn' ♯ C› discuss goal 1*) apply (rule Ex_EH (*‹⟦insert ?A ?H ⊢ ?B; atom ?i ♯ ?B; ∀C∈?H. atom ?i ♯ C⟧ ⟹ insert (SyntaxN.Ex ?i ?A) ?H ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 ?H) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 ?H. atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert (SyntaxN.Ex ?i ?A) ?H) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 ?H)) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 ?H). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert (SyntaxN.Ex ?i ?A) ?H)) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 ?H))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 ?H)). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert (SyntaxN.Ex ?i ?A) ?H))) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 ?H)))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 ?H))). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert (SyntaxN.Ex ?i ?A) ?H)))) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 ?H))))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 ?H)))). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert (SyntaxN.Ex ?i ?A) ?H))))) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 ?H)))))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 ?H))))). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert (SyntaxN.Ex ?i ?A) ?H)))))) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 ?H))))))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 ?H)))))). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 (insert (SyntaxN.Ex ?i ?A) ?H))))))) ⊢ ?B› ‹⟦insert ?A (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)))))))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈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))))))). atom ?i ♯ C⟧ ⟹ 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 (SyntaxN.Ex ?i ?A) ?H)))))))) ⊢ ?B› ‹⟦insert ?A (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))))))))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈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)))))))). atom ?i ♯ C⟧ ⟹ 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 (SyntaxN.Ex ?i ?A) ?H))))))))) ⊢ ?B›*) Conj_EH (*‹insert ?A (insert ?B ?H) ⊢ ?C ⟹ insert (?A AND ?B) ?H ⊢ ?C› ‹insert ?A (insert ?Ba (insert ?A1.0 ?H)) ⊢ ?B ⟹ insert ?A1.0 (insert (?A AND ?Ba) ?H) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 ?H))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert (?A AND ?Ba) ?H)) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 ?H)))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert (?A AND ?Ba) ?H))) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 ?H))))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert (?A AND ?Ba) ?H)))) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 ?H)))))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert (?A AND ?Ba) ?H))))) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 ?H))))))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert (?A AND ?Ba) ?H)))))) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 ?H)))))))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 (insert (?A AND ?Ba) ?H))))))) ⊢ ?B› ‹insert ?A (insert ?Ba (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))))))))) ⊢ ?B ⟹ 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 (?A AND ?Ba) ?H)))))))) ⊢ ?B› ‹insert ?A (insert ?Ba (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)))))))))) ⊢ ?B ⟹ 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 (?A AND ?Ba) ?H))))))))) ⊢ ?B›*)) (*top goal: ‹⟦atom l ♯ (v, i, t, u, s, k, sl, sl', m, n, sm, sm', sn, sn'); atom sl ♯ (v, i, t, u, s, k, sl', m, n, sm, sm', sn, sn'); atom sl' ♯ (v, i, t, u, s, k, m, n, sm, sm', sn, sn'); atom m ♯ (v, i, t, u, s, k, n, sm, sm', sn, sn'); atom n ♯ (v, i, t, u, s, k, sm, sm', sn, sn'); atom sm ♯ (v, i, t, u, s, k, sm', sn, sn'); atom sm' ♯ (v, i, t, u, s, k, sn, sn'); atom sn ♯ (v, i, t, u, s, k, sn'); atom sn' ♯ (v, i, t, u, s, k)⟧ ⟹ {Var m IN k AND Var n IN k AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND Var sl EQ Q_Eats (Var sm) (Var sn) AND Var sl' EQ Q_Eats (Var sm') (Var sn'), t EQ Var sl, u EQ Var sl', HPair k (HPair (Var sl) (Var sl')) IN s, All2 l k (SyntaxN.Ex sl (SyntaxN.Ex sl' (HPair (Var l) (HPair (Var sl) (Var sl')) IN s AND ((Var sl EQ v AND Var sl' EQ i OR (IndP (Var sl) OR Var sl NEQ v) AND Var sl' EQ Var sl) OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN Var l AND Var n IN Var l AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND Var sl EQ Q_Eats (Var sm) (Var sn) AND Var sl' EQ Q_Eats (Var sm') (Var sn'))))))))))), LstSeqP s k (HPair t u), VarP v} ⊢ (t EQ v AND u EQ i OR (IndP t OR t NEQ v) AND u EQ t) OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN k AND Var n IN k AND SeqStTermP v i (Var sm) (Var sm') s (Var m) AND SeqStTermP v i (Var sn) (Var sn') s (Var n) AND t EQ Q_Eats (Var sm) (Var sn) AND u EQ Q_Eats (Var sm') (Var sn')))))))› and 16 goals remain*) apply (rule Ex_EH (*‹⟦insert ?A ?H ⊢ ?B; atom ?i ♯ ?B; ∀C∈?H. atom ?i ♯ C⟧ ⟹ insert (SyntaxN.Ex ?i ?A) ?H ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 ?H) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 ?H. atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert (SyntaxN.Ex ?i ?A) ?H) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 ?H)) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 ?H). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert (SyntaxN.Ex ?i ?A) ?H)) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 ?H))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 ?H)). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert (SyntaxN.Ex ?i ?A) ?H))) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 ?H)))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 ?H))). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert (SyntaxN.Ex ?i ?A) ?H)))) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 ?H))))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 ?H)))). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert (SyntaxN.Ex ?i ?A) ?H))))) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 ?H)))))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 ?H))))). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert (SyntaxN.Ex ?i ?A) ?H)))))) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 ?H))))))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 ?H)))))). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 (insert (SyntaxN.Ex ?i ?A) ?H))))))) ⊢ ?B› ‹⟦insert ?A (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)))))))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈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))))))). atom ?i ♯ C⟧ ⟹ 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 (SyntaxN.Ex ?i ?A) ?H)))))))) ⊢ ?B› ‹⟦insert ?A (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))))))))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈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)))))))). atom ?i ♯ C⟧ ⟹ 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 (SyntaxN.Ex ?i ?A) ?H))))))))) ⊢ ?B›*) Conj_EH (*‹insert ?A (insert ?B ?H) ⊢ ?C ⟹ insert (?A AND ?B) ?H ⊢ ?C› ‹insert ?A (insert ?Ba (insert ?A1.0 ?H)) ⊢ ?B ⟹ insert ?A1.0 (insert (?A AND ?Ba) ?H) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 ?H))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert (?A AND ?Ba) ?H)) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 ?H)))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert (?A AND ?Ba) ?H))) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 ?H))))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert (?A AND ?Ba) ?H)))) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 ?H)))))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert (?A AND ?Ba) ?H))))) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 ?H))))))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert (?A AND ?Ba) ?H)))))) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 ?H)))))))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 (insert (?A AND ?Ba) ?H))))))) ⊢ ?B› ‹insert ?A (insert ?Ba (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))))))))) ⊢ ?B ⟹ 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 (?A AND ?Ba) ?H)))))))) ⊢ ?B› ‹insert ?A (insert ?Ba (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)))))))))) ⊢ ?B ⟹ 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 (?A AND ?Ba) ?H))))))))) ⊢ ?B›*)) (*top goal: ‹⟦atom l ♯ (v, i, t, u, s, k, sl, sl', m, n, sm, sm', sn, sn'); atom sl ♯ (v, i, t, u, s, k, sl', m, n, sm, sm', sn, sn'); atom sl' ♯ (v, i, t, u, s, k, m, n, sm, sm', sn, sn'); atom m ♯ (v, i, t, u, s, k, n, sm, sm', sn, sn'); atom n ♯ (v, i, t, u, s, k, sm, sm', sn, sn'); atom sm ♯ (v, i, t, u, s, k, sm', sn, sn'); atom sm' ♯ (v, i, t, u, s, k, sn, sn'); atom sn ♯ (v, i, t, u, s, k, sn'); atom sn' ♯ (v, i, t, u, s, k)⟧ ⟹ {Var m IN k, Var n IN k AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND Var sl EQ Q_Eats (Var sm) (Var sn) AND Var sl' EQ Q_Eats (Var sm') (Var sn'), t EQ Var sl, u EQ Var sl', HPair k (HPair (Var sl) (Var sl')) IN s, All2 l k (SyntaxN.Ex sl (SyntaxN.Ex sl' (HPair (Var l) (HPair (Var sl) (Var sl')) IN s AND ((Var sl EQ v AND Var sl' EQ i OR (IndP (Var sl) OR Var sl NEQ v) AND Var sl' EQ Var sl) OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN Var l AND Var n IN Var l AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND Var sl EQ Q_Eats (Var sm) (Var sn) AND Var sl' EQ Q_Eats (Var sm') (Var sn'))))))))))), LstSeqP s k (HPair t u), VarP v} ⊢ (t EQ v AND u EQ i OR (IndP t OR t NEQ v) AND u EQ t) OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN k AND Var n IN k AND SeqStTermP v i (Var sm) (Var sm') s (Var m) AND SeqStTermP v i (Var sn) (Var sn') s (Var n) AND t EQ Q_Eats (Var sm) (Var sn) AND u EQ Q_Eats (Var sm') (Var sn')))))))› and 16 goals remain*) apply (rule Ex_EH (*‹⟦insert (?A::fm) (?H::fm set) ⊢ (?B::fm); atom (?i::name) ♯ ?B; ∀C::fm∈?H. atom ?i ♯ C⟧ ⟹ insert (SyntaxN.Ex ?i ?A) ?H ⊢ ?B› ‹⟦insert (?A::fm) (insert (?A1.0::fm) (?H::fm set)) ⊢ (?B::fm); atom (?i::name) ♯ ?B; ∀C::fm∈insert ?A1.0 ?H. atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert (SyntaxN.Ex ?i ?A) ?H) ⊢ ?B› ‹⟦insert (?A::fm) (insert (?A1.0::fm) (insert (?A2.0::fm) (?H::fm set))) ⊢ (?B::fm); atom (?i::name) ♯ ?B; ∀C::fm∈insert ?A1.0 (insert ?A2.0 ?H). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert (SyntaxN.Ex ?i ?A) ?H)) ⊢ ?B› ‹⟦insert (?A::fm) (insert (?A1.0::fm) (insert (?A2.0::fm) (insert (?A3.0::fm) (?H::fm set)))) ⊢ (?B::fm); atom (?i::name) ♯ ?B; ∀C::fm∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 ?H)). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert (SyntaxN.Ex ?i ?A) ?H))) ⊢ ?B› ‹⟦insert (?A::fm) (insert (?A1.0::fm) (insert (?A2.0::fm) (insert (?A3.0::fm) (insert (?A4.0::fm) (?H::fm set))))) ⊢ (?B::fm); atom (?i::name) ♯ ?B; ∀C::fm∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 ?H))). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert (SyntaxN.Ex ?i ?A) ?H)))) ⊢ ?B› ‹⟦insert (?A::fm) (insert (?A1.0::fm) (insert (?A2.0::fm) (insert (?A3.0::fm) (insert (?A4.0::fm) (insert (?A5.0::fm) (?H::fm set)))))) ⊢ (?B::fm); atom (?i::name) ♯ ?B; ∀C::fm∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 ?H)))). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert (SyntaxN.Ex ?i ?A) ?H))))) ⊢ ?B› ‹⟦insert (?A::fm) (insert (?A1.0::fm) (insert (?A2.0::fm) (insert (?A3.0::fm) (insert (?A4.0::fm) (insert (?A5.0::fm) (insert (?A6.0::fm) (?H::fm set))))))) ⊢ (?B::fm); atom (?i::name) ♯ ?B; ∀C::fm∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 ?H))))). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert (SyntaxN.Ex ?i ?A) ?H)))))) ⊢ ?B› ‹⟦insert (?A::fm) (insert (?A1.0::fm) (insert (?A2.0::fm) (insert (?A3.0::fm) (insert (?A4.0::fm) (insert (?A5.0::fm) (insert (?A6.0::fm) (insert (?A7.0::fm) (?H::fm set)))))))) ⊢ (?B::fm); atom (?i::name) ♯ ?B; ∀C::fm∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 ?H)))))). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 (insert (SyntaxN.Ex ?i ?A) ?H))))))) ⊢ ?B› ‹⟦insert (?A::fm) (insert (?A1.0::fm) (insert (?A2.0::fm) (insert (?A3.0::fm) (insert (?A4.0::fm) (insert (?A5.0::fm) (insert (?A6.0::fm) (insert (?A7.0::fm) (insert (?A8.0::fm) (?H::fm set))))))))) ⊢ (?B::fm); atom (?i::name) ♯ ?B; ∀C::fm∈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))))))). atom ?i ♯ C⟧ ⟹ 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 (SyntaxN.Ex ?i ?A) ?H)))))))) ⊢ ?B› ‹⟦insert (?A::fm) (insert (?A1.0::fm) (insert (?A2.0::fm) (insert (?A3.0::fm) (insert (?A4.0::fm) (insert (?A5.0::fm) (insert (?A6.0::fm) (insert (?A7.0::fm) (insert (?A8.0::fm) (insert (?A9.0::fm) (?H::fm set)))))))))) ⊢ (?B::fm); atom (?i::name) ♯ ?B; ∀C::fm∈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)))))))). atom ?i ♯ C⟧ ⟹ 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 (SyntaxN.Ex ?i ?A) ?H))))))))) ⊢ ?B›*) Conj_EH (*‹insert (?A::fm) (insert (?B::fm) (?H::fm set)) ⊢ (?C::fm) ⟹ insert (?A AND ?B) ?H ⊢ ?C› ‹insert (?A::fm) (insert (?Ba::fm) (insert (?A1.0::fm) (?H::fm set))) ⊢ (?B::fm) ⟹ insert ?A1.0 (insert (?A AND ?Ba) ?H) ⊢ ?B› ‹insert (?A::fm) (insert (?Ba::fm) (insert (?A1.0::fm) (insert (?A2.0::fm) (?H::fm set)))) ⊢ (?B::fm) ⟹ insert ?A1.0 (insert ?A2.0 (insert (?A AND ?Ba) ?H)) ⊢ ?B› ‹insert (?A::fm) (insert (?Ba::fm) (insert (?A1.0::fm) (insert (?A2.0::fm) (insert (?A3.0::fm) (?H::fm set))))) ⊢ (?B::fm) ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert (?A AND ?Ba) ?H))) ⊢ ?B› ‹insert (?A::fm) (insert (?Ba::fm) (insert (?A1.0::fm) (insert (?A2.0::fm) (insert (?A3.0::fm) (insert (?A4.0::fm) (?H::fm set)))))) ⊢ (?B::fm) ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert (?A AND ?Ba) ?H)))) ⊢ ?B› ‹insert (?A::fm) (insert (?Ba::fm) (insert (?A1.0::fm) (insert (?A2.0::fm) (insert (?A3.0::fm) (insert (?A4.0::fm) (insert (?A5.0::fm) (?H::fm set))))))) ⊢ (?B::fm) ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert (?A AND ?Ba) ?H))))) ⊢ ?B› ‹insert (?A::fm) (insert (?Ba::fm) (insert (?A1.0::fm) (insert (?A2.0::fm) (insert (?A3.0::fm) (insert (?A4.0::fm) (insert (?A5.0::fm) (insert (?A6.0::fm) (?H::fm set)))))))) ⊢ (?B::fm) ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert (?A AND ?Ba) ?H)))))) ⊢ ?B› ‹insert (?A::fm) (insert (?Ba::fm) (insert (?A1.0::fm) (insert (?A2.0::fm) (insert (?A3.0::fm) (insert (?A4.0::fm) (insert (?A5.0::fm) (insert (?A6.0::fm) (insert (?A7.0::fm) (?H::fm set))))))))) ⊢ (?B::fm) ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 (insert (?A AND ?Ba) ?H))))))) ⊢ ?B› ‹insert (?A::fm) (insert (?Ba::fm) (insert (?A1.0::fm) (insert (?A2.0::fm) (insert (?A3.0::fm) (insert (?A4.0::fm) (insert (?A5.0::fm) (insert (?A6.0::fm) (insert (?A7.0::fm) (insert (?A8.0::fm) (?H::fm set)))))))))) ⊢ (?B::fm) ⟹ 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 (?A AND ?Ba) ?H)))))))) ⊢ ?B› ‹insert (?A::fm) (insert (?Ba::fm) (insert (?A1.0::fm) (insert (?A2.0::fm) (insert (?A3.0::fm) (insert (?A4.0::fm) (insert (?A5.0::fm) (insert (?A6.0::fm) (insert (?A7.0::fm) (insert (?A8.0::fm) (insert (?A9.0::fm) (?H::fm set))))))))))) ⊢ (?B::fm) ⟹ 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 (?A AND ?Ba) ?H))))))))) ⊢ ?B›*)) (*top goal: ‹⟦atom (l::name) ♯ (v::tm, i::tm, t::tm, u::tm, s::tm, k::tm, sl::name, sl'::name, m::name, n::name, sm::name, sm'::name, sn::name, sn'::name); atom sl ♯ (v, i, t, u, s, k, sl', m, n, sm, sm', sn, sn'); atom sl' ♯ (v, i, t, u, s, k, m, n, sm, sm', sn, sn'); atom m ♯ (v, i, t, u, s, k, n, sm, sm', sn, sn'); atom n ♯ (v, i, t, u, s, k, sm, sm', sn, sn'); atom sm ♯ (v, i, t, u, s, k, sm', sn, sn'); atom sm' ♯ (v, i, t, u, s, k, sn, sn'); atom sn ♯ (v, i, t, u, s, k, sn'); atom sn' ♯ (v, i, t, u, s, k)⟧ ⟹ {Var n IN k, HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND Var sl EQ Q_Eats (Var sm) (Var sn) AND Var sl' EQ Q_Eats (Var sm') (Var sn'), Var m IN k, t EQ Var sl, u EQ Var sl', HPair k (HPair (Var sl) (Var sl')) IN s, All2 l k (SyntaxN.Ex sl (SyntaxN.Ex sl' (HPair (Var l) (HPair (Var sl) (Var sl')) IN s AND ((Var sl EQ v AND Var sl' EQ i OR (IndP (Var sl) OR Var sl NEQ v) AND Var sl' EQ Var sl) OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN Var l AND Var n IN Var l AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND Var sl EQ Q_Eats (Var sm) (Var sn) AND Var sl' EQ Q_Eats (Var sm') (Var sn'))))))))))), LstSeqP s k (HPair t u), VarP v} ⊢ (t EQ v AND u EQ i OR (IndP t OR t NEQ v) AND u EQ t) OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN k AND Var n IN k AND SeqStTermP v i (Var sm) (Var sm') s (Var m) AND SeqStTermP v i (Var sn) (Var sn') s (Var n) AND t EQ Q_Eats (Var sm) (Var sn) AND u EQ Q_Eats (Var sm') (Var sn')))))))› and 16 goals remain*) apply (rule Ex_EH (*‹⟦insert (?A::fm) (?H::fm set) ⊢ (?B::fm); atom (?i::name) ♯ ?B; ∀C::fm∈?H. atom ?i ♯ C⟧ ⟹ insert (SyntaxN.Ex ?i ?A) ?H ⊢ ?B› ‹⟦insert (?A::fm) (insert (?A1.0::fm) (?H::fm set)) ⊢ (?B::fm); atom (?i::name) ♯ ?B; ∀C::fm∈insert ?A1.0 ?H. atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert (SyntaxN.Ex ?i ?A) ?H) ⊢ ?B› ‹⟦insert (?A::fm) (insert (?A1.0::fm) (insert (?A2.0::fm) (?H::fm set))) ⊢ (?B::fm); atom (?i::name) ♯ ?B; ∀C::fm∈insert ?A1.0 (insert ?A2.0 ?H). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert (SyntaxN.Ex ?i ?A) ?H)) ⊢ ?B› ‹⟦insert (?A::fm) (insert (?A1.0::fm) (insert (?A2.0::fm) (insert (?A3.0::fm) (?H::fm set)))) ⊢ (?B::fm); atom (?i::name) ♯ ?B; ∀C::fm∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 ?H)). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert (SyntaxN.Ex ?i ?A) ?H))) ⊢ ?B› ‹⟦insert (?A::fm) (insert (?A1.0::fm) (insert (?A2.0::fm) (insert (?A3.0::fm) (insert (?A4.0::fm) (?H::fm set))))) ⊢ (?B::fm); atom (?i::name) ♯ ?B; ∀C::fm∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 ?H))). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert (SyntaxN.Ex ?i ?A) ?H)))) ⊢ ?B› ‹⟦insert (?A::fm) (insert (?A1.0::fm) (insert (?A2.0::fm) (insert (?A3.0::fm) (insert (?A4.0::fm) (insert (?A5.0::fm) (?H::fm set)))))) ⊢ (?B::fm); atom (?i::name) ♯ ?B; ∀C::fm∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 ?H)))). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert (SyntaxN.Ex ?i ?A) ?H))))) ⊢ ?B› ‹⟦insert (?A::fm) (insert (?A1.0::fm) (insert (?A2.0::fm) (insert (?A3.0::fm) (insert (?A4.0::fm) (insert (?A5.0::fm) (insert (?A6.0::fm) (?H::fm set))))))) ⊢ (?B::fm); atom (?i::name) ♯ ?B; ∀C::fm∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 ?H))))). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert (SyntaxN.Ex ?i ?A) ?H)))))) ⊢ ?B› ‹⟦insert (?A::fm) (insert (?A1.0::fm) (insert (?A2.0::fm) (insert (?A3.0::fm) (insert (?A4.0::fm) (insert (?A5.0::fm) (insert (?A6.0::fm) (insert (?A7.0::fm) (?H::fm set)))))))) ⊢ (?B::fm); atom (?i::name) ♯ ?B; ∀C::fm∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 ?H)))))). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 (insert (SyntaxN.Ex ?i ?A) ?H))))))) ⊢ ?B› ‹⟦insert (?A::fm) (insert (?A1.0::fm) (insert (?A2.0::fm) (insert (?A3.0::fm) (insert (?A4.0::fm) (insert (?A5.0::fm) (insert (?A6.0::fm) (insert (?A7.0::fm) (insert (?A8.0::fm) (?H::fm set))))))))) ⊢ (?B::fm); atom (?i::name) ♯ ?B; ∀C::fm∈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))))))). atom ?i ♯ C⟧ ⟹ 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 (SyntaxN.Ex ?i ?A) ?H)))))))) ⊢ ?B› ‹⟦insert (?A::fm) (insert (?A1.0::fm) (insert (?A2.0::fm) (insert (?A3.0::fm) (insert (?A4.0::fm) (insert (?A5.0::fm) (insert (?A6.0::fm) (insert (?A7.0::fm) (insert (?A8.0::fm) (insert (?A9.0::fm) (?H::fm set)))))))))) ⊢ (?B::fm); atom (?i::name) ♯ ?B; ∀C::fm∈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)))))))). atom ?i ♯ C⟧ ⟹ 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 (SyntaxN.Ex ?i ?A) ?H))))))))) ⊢ ?B›*) Conj_EH (*‹insert (?A::fm) (insert (?B::fm) (?H::fm set)) ⊢ (?C::fm) ⟹ insert (?A AND ?B) ?H ⊢ ?C› ‹insert (?A::fm) (insert (?Ba::fm) (insert (?A1.0::fm) (?H::fm set))) ⊢ (?B::fm) ⟹ insert ?A1.0 (insert (?A AND ?Ba) ?H) ⊢ ?B› ‹insert (?A::fm) (insert (?Ba::fm) (insert (?A1.0::fm) (insert (?A2.0::fm) (?H::fm set)))) ⊢ (?B::fm) ⟹ insert ?A1.0 (insert ?A2.0 (insert (?A AND ?Ba) ?H)) ⊢ ?B› ‹insert (?A::fm) (insert (?Ba::fm) (insert (?A1.0::fm) (insert (?A2.0::fm) (insert (?A3.0::fm) (?H::fm set))))) ⊢ (?B::fm) ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert (?A AND ?Ba) ?H))) ⊢ ?B› ‹insert (?A::fm) (insert (?Ba::fm) (insert (?A1.0::fm) (insert (?A2.0::fm) (insert (?A3.0::fm) (insert (?A4.0::fm) (?H::fm set)))))) ⊢ (?B::fm) ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert (?A AND ?Ba) ?H)))) ⊢ ?B› ‹insert (?A::fm) (insert (?Ba::fm) (insert (?A1.0::fm) (insert (?A2.0::fm) (insert (?A3.0::fm) (insert (?A4.0::fm) (insert (?A5.0::fm) (?H::fm set))))))) ⊢ (?B::fm) ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert (?A AND ?Ba) ?H))))) ⊢ ?B› ‹insert (?A::fm) (insert (?Ba::fm) (insert (?A1.0::fm) (insert (?A2.0::fm) (insert (?A3.0::fm) (insert (?A4.0::fm) (insert (?A5.0::fm) (insert (?A6.0::fm) (?H::fm set)))))))) ⊢ (?B::fm) ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert (?A AND ?Ba) ?H)))))) ⊢ ?B› ‹insert (?A::fm) (insert (?Ba::fm) (insert (?A1.0::fm) (insert (?A2.0::fm) (insert (?A3.0::fm) (insert (?A4.0::fm) (insert (?A5.0::fm) (insert (?A6.0::fm) (insert (?A7.0::fm) (?H::fm set))))))))) ⊢ (?B::fm) ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 (insert (?A AND ?Ba) ?H))))))) ⊢ ?B› ‹insert (?A::fm) (insert (?Ba::fm) (insert (?A1.0::fm) (insert (?A2.0::fm) (insert (?A3.0::fm) (insert (?A4.0::fm) (insert (?A5.0::fm) (insert (?A6.0::fm) (insert (?A7.0::fm) (insert (?A8.0::fm) (?H::fm set)))))))))) ⊢ (?B::fm) ⟹ 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 (?A AND ?Ba) ?H)))))))) ⊢ ?B› ‹insert (?A::fm) (insert (?Ba::fm) (insert (?A1.0::fm) (insert (?A2.0::fm) (insert (?A3.0::fm) (insert (?A4.0::fm) (insert (?A5.0::fm) (insert (?A6.0::fm) (insert (?A7.0::fm) (insert (?A8.0::fm) (insert (?A9.0::fm) (?H::fm set))))))))))) ⊢ (?B::fm) ⟹ 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 (?A AND ?Ba) ?H))))))))) ⊢ ?B›*)) (*top goal: ‹⟦atom l ♯ (v, i, t, u, s, k, sl, sl', m, n, sm, sm', sn, sn'); atom sl ♯ (v, i, t, u, s, k, sl', m, n, sm, sm', sn, sn'); atom sl' ♯ (v, i, t, u, s, k, m, n, sm, sm', sn, sn'); atom m ♯ (v, i, t, u, s, k, n, sm, sm', sn, sn'); atom n ♯ (v, i, t, u, s, k, sm, sm', sn, sn'); atom sm ♯ (v, i, t, u, s, k, sm', sn, sn'); atom sm' ♯ (v, i, t, u, s, k, sn, sn'); atom sn ♯ (v, i, t, u, s, k, sn'); atom sn' ♯ (v, i, t, u, s, k)⟧ ⟹ {HPair (Var m) (HPair (Var sm) (Var sm')) IN s, HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND Var sl EQ Q_Eats (Var sm) (Var sn) AND Var sl' EQ Q_Eats (Var sm') (Var sn'), Var n IN k, Var m IN k, t EQ Var sl, u EQ Var sl', HPair k (HPair (Var sl) (Var sl')) IN s, All2 l k (SyntaxN.Ex sl (SyntaxN.Ex sl' (HPair (Var l) (HPair (Var sl) (Var sl')) IN s AND ((Var sl EQ v AND Var sl' EQ i OR (IndP (Var sl) OR Var sl NEQ v) AND Var sl' EQ Var sl) OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN Var l AND Var n IN Var l AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND Var sl EQ Q_Eats (Var sm) (Var sn) AND Var sl' EQ Q_Eats (Var sm') (Var sn'))))))))))), LstSeqP s k (HPair t u), VarP v} ⊢ (t EQ v AND u EQ i OR (IndP t OR t NEQ v) AND u EQ t) OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN k AND Var n IN k AND SeqStTermP v i (Var sm) (Var sm') s (Var m) AND SeqStTermP v i (Var sn) (Var sn') s (Var n) AND t EQ Q_Eats (Var sm) (Var sn) AND u EQ Q_Eats (Var sm') (Var sn')))))))› and 16 goals remain*) apply (rule Ex_EH (*‹⟦insert ?A ?H ⊢ ?B; atom ?i ♯ ?B; ∀C∈?H. atom ?i ♯ C⟧ ⟹ insert (SyntaxN.Ex ?i ?A) ?H ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 ?H) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 ?H. atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert (SyntaxN.Ex ?i ?A) ?H) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 ?H)) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 ?H). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert (SyntaxN.Ex ?i ?A) ?H)) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 ?H))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 ?H)). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert (SyntaxN.Ex ?i ?A) ?H))) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 ?H)))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 ?H))). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert (SyntaxN.Ex ?i ?A) ?H)))) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 ?H))))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 ?H)))). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert (SyntaxN.Ex ?i ?A) ?H))))) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 ?H)))))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 ?H))))). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert (SyntaxN.Ex ?i ?A) ?H)))))) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 ?H))))))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 ?H)))))). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 (insert (SyntaxN.Ex ?i ?A) ?H))))))) ⊢ ?B› ‹⟦insert ?A (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)))))))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈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))))))). atom ?i ♯ C⟧ ⟹ 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 (SyntaxN.Ex ?i ?A) ?H)))))))) ⊢ ?B› ‹⟦insert ?A (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))))))))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈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)))))))). atom ?i ♯ C⟧ ⟹ 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 (SyntaxN.Ex ?i ?A) ?H))))))))) ⊢ ?B›*) Conj_EH (*‹insert ?A (insert ?B ?H) ⊢ ?C ⟹ insert (?A AND ?B) ?H ⊢ ?C› ‹insert ?A (insert ?Ba (insert ?A1.0 ?H)) ⊢ ?B ⟹ insert ?A1.0 (insert (?A AND ?Ba) ?H) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 ?H))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert (?A AND ?Ba) ?H)) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 ?H)))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert (?A AND ?Ba) ?H))) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 ?H))))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert (?A AND ?Ba) ?H)))) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 ?H)))))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert (?A AND ?Ba) ?H))))) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 ?H))))))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert (?A AND ?Ba) ?H)))))) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 ?H)))))))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 (insert (?A AND ?Ba) ?H))))))) ⊢ ?B› ‹insert ?A (insert ?Ba (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))))))))) ⊢ ?B ⟹ 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 (?A AND ?Ba) ?H)))))))) ⊢ ?B› ‹insert ?A (insert ?Ba (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)))))))))) ⊢ ?B ⟹ 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 (?A AND ?Ba) ?H))))))))) ⊢ ?B›*)) (*top goal: ‹⟦atom l ♯ (v, i, t, u, s, k, sl, sl', m, n, sm, sm', sn, sn'); atom sl ♯ (v, i, t, u, s, k, sl', m, n, sm, sm', sn, sn'); atom sl' ♯ (v, i, t, u, s, k, m, n, sm, sm', sn, sn'); atom m ♯ (v, i, t, u, s, k, n, sm, sm', sn, sn'); atom n ♯ (v, i, t, u, s, k, sm, sm', sn, sn'); atom sm ♯ (v, i, t, u, s, k, sm', sn, sn'); atom sm' ♯ (v, i, t, u, s, k, sn, sn'); atom sn ♯ (v, i, t, u, s, k, sn'); atom sn' ♯ (v, i, t, u, s, k)⟧ ⟹ {HPair (Var n) (HPair (Var sn) (Var sn')) IN s, Var sl EQ Q_Eats (Var sm) (Var sn) AND Var sl' EQ Q_Eats (Var sm') (Var sn'), HPair (Var m) (HPair (Var sm) (Var sm')) IN s, Var n IN k, Var m IN k, t EQ Var sl, u EQ Var sl', HPair k (HPair (Var sl) (Var sl')) IN s, All2 l k (SyntaxN.Ex sl (SyntaxN.Ex sl' (HPair (Var l) (HPair (Var sl) (Var sl')) IN s AND ((Var sl EQ v AND Var sl' EQ i OR (IndP (Var sl) OR Var sl NEQ v) AND Var sl' EQ Var sl) OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN Var l AND Var n IN Var l AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND Var sl EQ Q_Eats (Var sm) (Var sn) AND Var sl' EQ Q_Eats (Var sm') (Var sn'))))))))))), LstSeqP s k (HPair t u), VarP v} ⊢ (t EQ v AND u EQ i OR (IndP t OR t NEQ v) AND u EQ t) OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN k AND Var n IN k AND SeqStTermP v i (Var sm) (Var sm') s (Var m) AND SeqStTermP v i (Var sn) (Var sn') s (Var n) AND t EQ Q_Eats (Var sm) (Var sn) AND u EQ Q_Eats (Var sm') (Var sn')))))))› and 16 goals remain*) apply (rule Disj_I2 (*‹?H ⊢ ?B ⟹ ?H ⊢ ?A OR ?B›*)) (*top goal: ‹⟦atom l ♯ (v, i, t, u, s, k, sl, sl', m, n, sm, sm', sn, sn'); atom sl ♯ (v, i, t, u, s, k, sl', m, n, sm, sm', sn, sn'); atom sl' ♯ (v, i, t, u, s, k, m, n, sm, sm', sn, sn'); atom m ♯ (v, i, t, u, s, k, n, sm, sm', sn, sn'); atom n ♯ (v, i, t, u, s, k, sm, sm', sn, sn'); atom sm ♯ (v, i, t, u, s, k, sm', sn, sn'); atom sm' ♯ (v, i, t, u, s, k, sn, sn'); atom sn ♯ (v, i, t, u, s, k, sn'); atom sn' ♯ (v, i, t, u, s, k)⟧ ⟹ {Var sl EQ Q_Eats (Var sm) (Var sn), Var sl' EQ Q_Eats (Var sm') (Var sn'), HPair (Var n) (HPair (Var sn) (Var sn')) IN s, HPair (Var m) (HPair (Var sm) (Var sm')) IN s, Var n IN k, Var m IN k, t EQ Var sl, u EQ Var sl', HPair k (HPair (Var sl) (Var sl')) IN s, All2 l k (SyntaxN.Ex sl (SyntaxN.Ex sl' (HPair (Var l) (HPair (Var sl) (Var sl')) IN s AND ((Var sl EQ v AND Var sl' EQ i OR (IndP (Var sl) OR Var sl NEQ v) AND Var sl' EQ Var sl) OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN Var l AND Var n IN Var l AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND Var sl EQ Q_Eats (Var sm) (Var sn) AND Var sl' EQ Q_Eats (Var sm') (Var sn'))))))))))), LstSeqP s k (HPair t u), VarP v} ⊢ (t EQ v AND u EQ i OR (IndP t OR t NEQ v) AND u EQ t) OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN k AND Var n IN k AND SeqStTermP v i (Var sm) (Var sm') s (Var m) AND SeqStTermP v i (Var sn) (Var sn') s (Var n) AND t EQ Q_Eats (Var sm) (Var sn) AND u EQ Q_Eats (Var sm') (Var sn')))))))› and 16 goals remain*) apply (rule Ex_I [where x = "Var m"] (*‹?H ⊢ ?A(?i::=Var m) ⟹ ?H ⊢ SyntaxN.Ex ?i ?A›*)) (*top goal: ‹⟦atom l ♯ (v, i, t, u, s, k, sl, sl', m, n, sm, sm', sn, sn'); atom sl ♯ (v, i, t, u, s, k, sl', m, n, sm, sm', sn, sn'); atom sl' ♯ (v, i, t, u, s, k, m, n, sm, sm', sn, sn'); atom m ♯ (v, i, t, u, s, k, n, sm, sm', sn, sn'); atom n ♯ (v, i, t, u, s, k, sm, sm', sn, sn'); atom sm ♯ (v, i, t, u, s, k, sm', sn, sn'); atom sm' ♯ (v, i, t, u, s, k, sn, sn'); atom sn ♯ (v, i, t, u, s, k, sn'); atom sn' ♯ (v, i, t, u, s, k)⟧ ⟹ {Var sl EQ Q_Eats (Var sm) (Var sn), Var sl' EQ Q_Eats (Var sm') (Var sn'), HPair (Var n) (HPair (Var sn) (Var sn')) IN s, HPair (Var m) (HPair (Var sm) (Var sm')) IN s, Var n IN k, Var m IN k, t EQ Var sl, u EQ Var sl', HPair k (HPair (Var sl) (Var sl')) IN s, All2 l k (SyntaxN.Ex sl (SyntaxN.Ex sl' (HPair (Var l) (HPair (Var sl) (Var sl')) IN s AND ((Var sl EQ v AND Var sl' EQ i OR (IndP (Var sl) OR Var sl NEQ v) AND Var sl' EQ Var sl) OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN Var l AND Var n IN Var l AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND Var sl EQ Q_Eats (Var sm) (Var sn) AND Var sl' EQ Q_Eats (Var sm') (Var sn'))))))))))), LstSeqP s k (HPair t u), VarP v} ⊢ SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN k AND Var n IN k AND SeqStTermP v i (Var sm) (Var sm') s (Var m) AND SeqStTermP v i (Var sn) (Var sn') s (Var n) AND t EQ Q_Eats (Var sm) (Var sn) AND u EQ Q_Eats (Var sm') (Var sn')))))))› and 16 goals remain*) apply simp (*top goal: ‹⟦atom l ♯ (v, i, t, u, s, k, sl, sl', m, n, sm, sm', sn, sn'); atom sl ♯ (v, i, t, u, s, k, sl', m, n, sm, sm', sn, sn'); atom sl' ♯ (v, i, t, u, s, k, m, n, sm, sm', sn, sn'); atom m ♯ (v, i, t, u, s, k, n, sm, sm', sn, sn'); atom n ♯ (v, i, t, u, s, k, sm, sm', sn, sn'); atom sm ♯ (v, i, t, u, s, k, sm', sn, sn'); atom sm' ♯ (v, i, t, u, s, k, sn, sn'); atom sn ♯ (v, i, t, u, s, k, sn'); atom sn' ♯ (v, i, t, u, s, k)⟧ ⟹ {Var sl EQ Q_Eats (Var sm) (Var sn), Var sl' EQ Q_Eats (Var sm') (Var sn'), HPair (Var n) (HPair (Var sn) (Var sn')) IN s, HPair (Var m) (HPair (Var sm) (Var sm')) IN s, Var n IN k, Var m IN k, t EQ Var sl, u EQ Var sl', HPair k (HPair (Var sl) (Var sl')) IN s, All2 l k (SyntaxN.Ex sl (SyntaxN.Ex sl' (HPair (Var l) (HPair (Var sl) (Var sl')) IN s AND ((Var sl EQ v AND Var sl' EQ i OR (IndP (Var sl) OR Var sl NEQ v) AND Var sl' EQ Var sl) OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN Var l AND Var n IN Var l AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND Var sl EQ Q_Eats (Var sm) (Var sn) AND Var sl' EQ Q_Eats (Var sm') (Var sn'))))))))))), LstSeqP s k (HPair t u), VarP v} ⊢ (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN k AND Var n IN k AND SeqStTermP v i (Var sm) (Var sm') s (Var m) AND SeqStTermP v i (Var sn) (Var sn') s (Var n) AND t EQ Q_Eats (Var sm) (Var sn) AND u EQ Q_Eats (Var sm') (Var sn')))))))(m::=Var m)› and 16 goals remain*) apply (rule Ex_I [where x = "Var n"] (*‹?H ⊢ ?A(?i::=Var n) ⟹ ?H ⊢ SyntaxN.Ex ?i ?A›*)) (*top goal: ‹⟦atom l ♯ (v, i, t, u, s, k, sl, sl', m, n, sm, sm', sn, sn'); atom sl ♯ (v, i, t, u, s, k, sl', m, n, sm, sm', sn, sn'); atom sl' ♯ (v, i, t, u, s, k, m, n, sm, sm', sn, sn'); atom m ♯ (v, i, t, u, s, k, n, sm, sm', sn, sn'); atom n ♯ (v, i, t, u, s, k, sm, sm', sn, sn'); atom sm ♯ (v, i, t, u, s, k, sm', sn, sn'); atom sm' ♯ (v, i, t, u, s, k, sn, sn'); atom sn ♯ (v, i, t, u, s, k, sn'); atom sn' ♯ (v, i, t, u, s, k)⟧ ⟹ {Var sl EQ Q_Eats (Var sm) (Var sn), Var sl' EQ Q_Eats (Var sm') (Var sn'), HPair (Var n) (HPair (Var sn) (Var sn')) IN s, HPair (Var m) (HPair (Var sm) (Var sm')) IN s, Var n IN k, Var m IN k, t EQ Var sl, u EQ Var sl', HPair k (HPair (Var sl) (Var sl')) IN s, All2 l k (SyntaxN.Ex sl (SyntaxN.Ex sl' (HPair (Var l) (HPair (Var sl) (Var sl')) IN s AND ((Var sl EQ v AND Var sl' EQ i OR (IndP (Var sl) OR Var sl NEQ v) AND Var sl' EQ Var sl) OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN Var l AND Var n IN Var l AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND Var sl EQ Q_Eats (Var sm) (Var sn) AND Var sl' EQ Q_Eats (Var sm') (Var sn'))))))))))), LstSeqP s k (HPair t u), VarP v} ⊢ SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN k AND Var n IN k AND SeqStTermP v i (Var sm) (Var sm') s (Var m) AND SeqStTermP v i (Var sn) (Var sn') s (Var n) AND t EQ Q_Eats (Var sm) (Var sn) AND u EQ Q_Eats (Var sm') (Var sn'))))))› and 16 goals remain*) apply simp (*top goal: ‹⟦atom l ♯ (v, i, t, u, s, k, sl, sl', m, n, sm, sm', sn, sn'); atom sl ♯ (v, i, t, u, s, k, sl', m, n, sm, sm', sn, sn'); atom sl' ♯ (v, i, t, u, s, k, m, n, sm, sm', sn, sn'); atom m ♯ (v, i, t, u, s, k, n, sm, sm', sn, sn'); atom n ♯ (v, i, t, u, s, k, sm, sm', sn, sn'); atom sm ♯ (v, i, t, u, s, k, sm', sn, sn'); atom sm' ♯ (v, i, t, u, s, k, sn, sn'); atom sn ♯ (v, i, t, u, s, k, sn'); atom sn' ♯ (v, i, t, u, s, k)⟧ ⟹ {Var sl EQ Q_Eats (Var sm) (Var sn), Var sl' EQ Q_Eats (Var sm') (Var sn'), HPair (Var n) (HPair (Var sn) (Var sn')) IN s, HPair (Var m) (HPair (Var sm) (Var sm')) IN s, Var n IN k, Var m IN k, t EQ Var sl, u EQ Var sl', HPair k (HPair (Var sl) (Var sl')) IN s, All2 l k (SyntaxN.Ex sl (SyntaxN.Ex sl' (HPair (Var l) (HPair (Var sl) (Var sl')) IN s AND ((Var sl EQ v AND Var sl' EQ i OR (IndP (Var sl) OR Var sl NEQ v) AND Var sl' EQ Var sl) OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN Var l AND Var n IN Var l AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND Var sl EQ Q_Eats (Var sm) (Var sn) AND Var sl' EQ Q_Eats (Var sm') (Var sn'))))))))))), LstSeqP s k (HPair t u), VarP v} ⊢ (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN k AND Var n IN k AND SeqStTermP v i (Var sm) (Var sm') s (Var m) AND SeqStTermP v i (Var sn) (Var sn') s (Var n) AND t EQ Q_Eats (Var sm) (Var sn) AND u EQ Q_Eats (Var sm') (Var sn'))))))(n::=Var n)› and 16 goals remain*) apply (rule Ex_I [where x = "Var sm"] (*‹?H ⊢ ?A(?i::=Var sm) ⟹ ?H ⊢ SyntaxN.Ex ?i ?A›*)) (*top goal: ‹⟦atom (l::name) ♯ (v::tm, i::tm, t::tm, u::tm, s::tm, k::tm, sl::name, sl'::name, m::name, n::name, sm::name, sm'::name, sn::name, sn'::name); atom sl ♯ (v, i, t, u, s, k, sl', m, n, sm, sm', sn, sn'); atom sl' ♯ (v, i, t, u, s, k, m, n, sm, sm', sn, sn'); atom m ♯ (v, i, t, u, s, k, n, sm, sm', sn, sn'); atom n ♯ (v, i, t, u, s, k, sm, sm', sn, sn'); atom sm ♯ (v, i, t, u, s, k, sm', sn, sn'); atom sm' ♯ (v, i, t, u, s, k, sn, sn'); atom sn ♯ (v, i, t, u, s, k, sn'); atom sn' ♯ (v, i, t, u, s, k)⟧ ⟹ {Var sl EQ Q_Eats (Var sm) (Var sn), Var sl' EQ Q_Eats (Var sm') (Var sn'), HPair (Var n) (HPair (Var sn) (Var sn')) IN s, HPair (Var m) (HPair (Var sm) (Var sm')) IN s, Var n IN k, Var m IN k, t EQ Var sl, u EQ Var sl', HPair k (HPair (Var sl) (Var sl')) IN s, All2 l k (SyntaxN.Ex sl (SyntaxN.Ex sl' (HPair (Var l) (HPair (Var sl) (Var sl')) IN s AND ((Var sl EQ v AND Var sl' EQ i OR (IndP (Var sl) OR Var sl NEQ v) AND Var sl' EQ Var sl) OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN Var l AND Var n IN Var l AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND Var sl EQ Q_Eats (Var sm) (Var sn) AND Var sl' EQ Q_Eats (Var sm') (Var sn'))))))))))), LstSeqP s k (HPair t u), VarP v} ⊢ SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN k AND Var n IN k AND SeqStTermP v i (Var sm) (Var sm') s (Var m) AND SeqStTermP v i (Var sn) (Var sn') s (Var n) AND t EQ Q_Eats (Var sm) (Var sn) AND u EQ Q_Eats (Var sm') (Var sn')))))› and 16 goals remain*) apply simp (*top goal: ‹⟦atom (l::name) ♯ (v::tm, i::tm, t::tm, u::tm, s::tm, k::tm, sl::name, sl'::name, m::name, n::name, sm::name, sm'::name, sn::name, sn'::name); atom sl ♯ (v, i, t, u, s, k, sl', m, n, sm, sm', sn, sn'); atom sl' ♯ (v, i, t, u, s, k, m, n, sm, sm', sn, sn'); atom m ♯ (v, i, t, u, s, k, n, sm, sm', sn, sn'); atom n ♯ (v, i, t, u, s, k, sm, sm', sn, sn'); atom sm ♯ (v, i, t, u, s, k, sm', sn, sn'); atom sm' ♯ (v, i, t, u, s, k, sn, sn'); atom sn ♯ (v, i, t, u, s, k, sn'); atom sn' ♯ (v, i, t, u, s, k)⟧ ⟹ {Var sl EQ Q_Eats (Var sm) (Var sn), Var sl' EQ Q_Eats (Var sm') (Var sn'), HPair (Var n) (HPair (Var sn) (Var sn')) IN s, HPair (Var m) (HPair (Var sm) (Var sm')) IN s, Var n IN k, Var m IN k, t EQ Var sl, u EQ Var sl', HPair k (HPair (Var sl) (Var sl')) IN s, All2 l k (SyntaxN.Ex sl (SyntaxN.Ex sl' (HPair (Var l) (HPair (Var sl) (Var sl')) IN s AND ((Var sl EQ v AND Var sl' EQ i OR (IndP (Var sl) OR Var sl NEQ v) AND Var sl' EQ Var sl) OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN Var l AND Var n IN Var l AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND Var sl EQ Q_Eats (Var sm) (Var sn) AND Var sl' EQ Q_Eats (Var sm') (Var sn'))))))))))), LstSeqP s k (HPair t u), VarP v} ⊢ (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN k AND Var n IN k AND SeqStTermP v i (Var sm) (Var sm') s (Var m) AND SeqStTermP v i (Var sn) (Var sn') s (Var n) AND t EQ Q_Eats (Var sm) (Var sn) AND u EQ Q_Eats (Var sm') (Var sn')))))(sm::=Var sm)› and 16 goals remain*) apply (rule Ex_I [where x = "Var sm'"] (*‹?H ⊢ ?A(?i::=Var sm') ⟹ ?H ⊢ SyntaxN.Ex ?i ?A›*)) (*top goal: ‹⟦atom l ♯ (v, i, t, u, s, k, sl, sl', m, n, sm, sm', sn, sn'); atom sl ♯ (v, i, t, u, s, k, sl', m, n, sm, sm', sn, sn'); atom sl' ♯ (v, i, t, u, s, k, m, n, sm, sm', sn, sn'); atom m ♯ (v, i, t, u, s, k, n, sm, sm', sn, sn'); atom n ♯ (v, i, t, u, s, k, sm, sm', sn, sn'); atom sm ♯ (v, i, t, u, s, k, sm', sn, sn'); atom sm' ♯ (v, i, t, u, s, k, sn, sn'); atom sn ♯ (v, i, t, u, s, k, sn'); atom sn' ♯ (v, i, t, u, s, k)⟧ ⟹ {Var sl EQ Q_Eats (Var sm) (Var sn), Var sl' EQ Q_Eats (Var sm') (Var sn'), HPair (Var n) (HPair (Var sn) (Var sn')) IN s, HPair (Var m) (HPair (Var sm) (Var sm')) IN s, Var n IN k, Var m IN k, t EQ Var sl, u EQ Var sl', HPair k (HPair (Var sl) (Var sl')) IN s, All2 l k (SyntaxN.Ex sl (SyntaxN.Ex sl' (HPair (Var l) (HPair (Var sl) (Var sl')) IN s AND ((Var sl EQ v AND Var sl' EQ i OR (IndP (Var sl) OR Var sl NEQ v) AND Var sl' EQ Var sl) OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN Var l AND Var n IN Var l AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND Var sl EQ Q_Eats (Var sm) (Var sn) AND Var sl' EQ Q_Eats (Var sm') (Var sn'))))))))))), LstSeqP s k (HPair t u), VarP v} ⊢ SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN k AND Var n IN k AND SeqStTermP v i (Var sm) (Var sm') s (Var m) AND SeqStTermP v i (Var sn) (Var sn') s (Var n) AND t EQ Q_Eats (Var sm) (Var sn) AND u EQ Q_Eats (Var sm') (Var sn'))))› and 16 goals remain*) apply simp (*top goal: ‹⟦atom l ♯ (v, i, t, u, s, k, sl, sl', m, n, sm, sm', sn, sn'); atom sl ♯ (v, i, t, u, s, k, sl', m, n, sm, sm', sn, sn'); atom sl' ♯ (v, i, t, u, s, k, m, n, sm, sm', sn, sn'); atom m ♯ (v, i, t, u, s, k, n, sm, sm', sn, sn'); atom n ♯ (v, i, t, u, s, k, sm, sm', sn, sn'); atom sm ♯ (v, i, t, u, s, k, sm', sn, sn'); atom sm' ♯ (v, i, t, u, s, k, sn, sn'); atom sn ♯ (v, i, t, u, s, k, sn'); atom sn' ♯ (v, i, t, u, s, k)⟧ ⟹ {Var sl EQ Q_Eats (Var sm) (Var sn), Var sl' EQ Q_Eats (Var sm') (Var sn'), HPair (Var n) (HPair (Var sn) (Var sn')) IN s, HPair (Var m) (HPair (Var sm) (Var sm')) IN s, Var n IN k, Var m IN k, t EQ Var sl, u EQ Var sl', HPair k (HPair (Var sl) (Var sl')) IN s, All2 l k (SyntaxN.Ex sl (SyntaxN.Ex sl' (HPair (Var l) (HPair (Var sl) (Var sl')) IN s AND ((Var sl EQ v AND Var sl' EQ i OR (IndP (Var sl) OR Var sl NEQ v) AND Var sl' EQ Var sl) OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN Var l AND Var n IN Var l AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND Var sl EQ Q_Eats (Var sm) (Var sn) AND Var sl' EQ Q_Eats (Var sm') (Var sn'))))))))))), LstSeqP s k (HPair t u), VarP v} ⊢ (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN k AND Var n IN k AND SeqStTermP v i (Var sm) (Var sm') s (Var m) AND SeqStTermP v i (Var sn) (Var sn') s (Var n) AND t EQ Q_Eats (Var sm) (Var sn) AND u EQ Q_Eats (Var sm') (Var sn'))))(sm'::=Var sm')› and 16 goals remain*) apply (rule Ex_I [where x = "Var sn"] (*‹?H ⊢ ?A(?i::=Var sn) ⟹ ?H ⊢ SyntaxN.Ex ?i ?A›*)) (*top goal: ‹⟦atom l ♯ (v, i, t, u, s, k, sl, sl', m, n, sm, sm', sn, sn'); atom sl ♯ (v, i, t, u, s, k, sl', m, n, sm, sm', sn, sn'); atom sl' ♯ (v, i, t, u, s, k, m, n, sm, sm', sn, sn'); atom m ♯ (v, i, t, u, s, k, n, sm, sm', sn, sn'); atom n ♯ (v, i, t, u, s, k, sm, sm', sn, sn'); atom sm ♯ (v, i, t, u, s, k, sm', sn, sn'); atom sm' ♯ (v, i, t, u, s, k, sn, sn'); atom sn ♯ (v, i, t, u, s, k, sn'); atom sn' ♯ (v, i, t, u, s, k)⟧ ⟹ {Var sl EQ Q_Eats (Var sm) (Var sn), Var sl' EQ Q_Eats (Var sm') (Var sn'), HPair (Var n) (HPair (Var sn) (Var sn')) IN s, HPair (Var m) (HPair (Var sm) (Var sm')) IN s, Var n IN k, Var m IN k, t EQ Var sl, u EQ Var sl', HPair k (HPair (Var sl) (Var sl')) IN s, All2 l k (SyntaxN.Ex sl (SyntaxN.Ex sl' (HPair (Var l) (HPair (Var sl) (Var sl')) IN s AND ((Var sl EQ v AND Var sl' EQ i OR (IndP (Var sl) OR Var sl NEQ v) AND Var sl' EQ Var sl) OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN Var l AND Var n IN Var l AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND Var sl EQ Q_Eats (Var sm) (Var sn) AND Var sl' EQ Q_Eats (Var sm') (Var sn'))))))))))), LstSeqP s k (HPair t u), VarP v} ⊢ SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN k AND Var n IN k AND SeqStTermP v i (Var sm) (Var sm') s (Var m) AND SeqStTermP v i (Var sn) (Var sn') s (Var n) AND t EQ Q_Eats (Var sm) (Var sn) AND u EQ Q_Eats (Var sm') (Var sn')))› and 16 goals remain*) apply simp (*top goal: ‹⟦atom l ♯ (v, i, t, u, s, k, sl, sl', m, n, sm, sm', sn, sn'); atom sl ♯ (v, i, t, u, s, k, sl', m, n, sm, sm', sn, sn'); atom sl' ♯ (v, i, t, u, s, k, m, n, sm, sm', sn, sn'); atom m ♯ (v, i, t, u, s, k, n, sm, sm', sn, sn'); atom n ♯ (v, i, t, u, s, k, sm, sm', sn, sn'); atom sm ♯ (v, i, t, u, s, k, sm', sn, sn'); atom sm' ♯ (v, i, t, u, s, k, sn, sn'); atom sn ♯ (v, i, t, u, s, k, sn'); atom sn' ♯ (v, i, t, u, s, k)⟧ ⟹ {Var sl EQ Q_Eats (Var sm) (Var sn), Var sl' EQ Q_Eats (Var sm') (Var sn'), HPair (Var n) (HPair (Var sn) (Var sn')) IN s, HPair (Var m) (HPair (Var sm) (Var sm')) IN s, Var n IN k, Var m IN k, t EQ Var sl, u EQ Var sl', HPair k (HPair (Var sl) (Var sl')) IN s, All2 l k (SyntaxN.Ex sl (SyntaxN.Ex sl' (HPair (Var l) (HPair (Var sl) (Var sl')) IN s AND ((Var sl EQ v AND Var sl' EQ i OR (IndP (Var sl) OR Var sl NEQ v) AND Var sl' EQ Var sl) OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN Var l AND Var n IN Var l AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND Var sl EQ Q_Eats (Var sm) (Var sn) AND Var sl' EQ Q_Eats (Var sm') (Var sn'))))))))))), LstSeqP s k (HPair t u), VarP v} ⊢ (SyntaxN.Ex sn' (Var m IN k AND Var n IN k AND SeqStTermP v i (Var sm) (Var sm') s (Var m) AND SeqStTermP v i (Var sn) (Var sn') s (Var n) AND t EQ Q_Eats (Var sm) (Var sn) AND u EQ Q_Eats (Var sm') (Var sn')))(sn::=Var sn)› and 16 goals remain*) apply (rule Ex_I [where x = "Var sn'"] (*‹(?H::fm set) ⊢ (?A::fm)(?i::name::=Var (sn'::name)) ⟹ ?H ⊢ SyntaxN.Ex ?i ?A›*)) (*top goal: ‹⟦atom l ♯ (v, i, t, u, s, k, sl, sl', m, n, sm, sm', sn, sn'); atom sl ♯ (v, i, t, u, s, k, sl', m, n, sm, sm', sn, sn'); atom sl' ♯ (v, i, t, u, s, k, m, n, sm, sm', sn, sn'); atom m ♯ (v, i, t, u, s, k, n, sm, sm', sn, sn'); atom n ♯ (v, i, t, u, s, k, sm, sm', sn, sn'); atom sm ♯ (v, i, t, u, s, k, sm', sn, sn'); atom sm' ♯ (v, i, t, u, s, k, sn, sn'); atom sn ♯ (v, i, t, u, s, k, sn'); atom sn' ♯ (v, i, t, u, s, k)⟧ ⟹ {Var sl EQ Q_Eats (Var sm) (Var sn), Var sl' EQ Q_Eats (Var sm') (Var sn'), HPair (Var n) (HPair (Var sn) (Var sn')) IN s, HPair (Var m) (HPair (Var sm) (Var sm')) IN s, Var n IN k, Var m IN k, t EQ Var sl, u EQ Var sl', HPair k (HPair (Var sl) (Var sl')) IN s, All2 l k (SyntaxN.Ex sl (SyntaxN.Ex sl' (HPair (Var l) (HPair (Var sl) (Var sl')) IN s AND ((Var sl EQ v AND Var sl' EQ i OR (IndP (Var sl) OR Var sl NEQ v) AND Var sl' EQ Var sl) OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN Var l AND Var n IN Var l AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND Var sl EQ Q_Eats (Var sm) (Var sn) AND Var sl' EQ Q_Eats (Var sm') (Var sn'))))))))))), LstSeqP s k (HPair t u), VarP v} ⊢ SyntaxN.Ex sn' (Var m IN k AND Var n IN k AND SeqStTermP v i (Var sm) (Var sm') s (Var m) AND SeqStTermP v i (Var sn) (Var sn') s (Var n) AND t EQ Q_Eats (Var sm) (Var sn) AND u EQ Q_Eats (Var sm') (Var sn'))› and 16 goals remain*) apply simp (*top goal: ‹⟦atom l ♯ (v, i, t, u, s, k, sl, sl', m, n, sm, sm', sn, sn'); atom sl ♯ (v, i, t, u, s, k, sl', m, n, sm, sm', sn, sn'); atom sl' ♯ (v, i, t, u, s, k, m, n, sm, sm', sn, sn'); atom m ♯ (v, i, t, u, s, k, n, sm, sm', sn, sn'); atom n ♯ (v, i, t, u, s, k, sm, sm', sn, sn'); atom sm ♯ (v, i, t, u, s, k, sm', sn, sn'); atom sm' ♯ (v, i, t, u, s, k, sn, sn'); atom sn ♯ (v, i, t, u, s, k, sn'); atom sn' ♯ (v, i, t, u, s, k)⟧ ⟹ {Var sl EQ Q_Eats (Var sm) (Var sn), Var sl' EQ Q_Eats (Var sm') (Var sn'), HPair (Var n) (HPair (Var sn) (Var sn')) IN s, HPair (Var m) (HPair (Var sm) (Var sm')) IN s, Var n IN k, Var m IN k, t EQ Var sl, u EQ Var sl', HPair k (HPair (Var sl) (Var sl')) IN s, All2 l k (SyntaxN.Ex sl (SyntaxN.Ex sl' (HPair (Var l) (HPair (Var sl) (Var sl')) IN s AND ((Var sl EQ v AND Var sl' EQ i OR (IndP (Var sl) OR Var sl NEQ v) AND Var sl' EQ Var sl) OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN Var l AND Var n IN Var l AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND Var sl EQ Q_Eats (Var sm) (Var sn) AND Var sl' EQ Q_Eats (Var sm') (Var sn'))))))))))), LstSeqP s k (HPair t u), VarP v} ⊢ (Var m IN k AND Var n IN k AND SeqStTermP v i (Var sm) (Var sm') s (Var m) AND SeqStTermP v i (Var sn) (Var sn') s (Var n) AND t EQ Q_Eats (Var sm) (Var sn) AND u EQ Q_Eats (Var sm') (Var sn'))(sn'::=Var sn')› and 16 goals remain*) apply (simp add: SeqStTermP.simps [of l s _ v i sl sl' m n sm sm' sn sn'] (*‹⟦atom l ♯ (s, ?k, v, i, sl, sl', m, n, sm, sm', sn, sn'); atom sl ♯ (s, v, i, sl', m, n, sm, sm', sn, sn'); atom sl' ♯ (s, v, i, m, n, sm, sm', sn, sn'); atom m ♯ (s, n, sm, sm', sn, sn'); atom n ♯ (s, sm, sm', sn, sn'); atom sm ♯ (s, sm', sn, sn'); atom sm' ♯ (s, sn, sn'); atom sn ♯ (s, sn'); atom sn' ♯ s⟧ ⟹ SeqStTermP v i ?t ?u s ?k = VarP v AND LstSeqP s ?k (HPair ?t ?u) AND All2 l (SUCC ?k) (SyntaxN.Ex sl (SyntaxN.Ex sl' (HPair (Var l) (HPair (Var sl) (Var sl')) IN s AND ((Var sl EQ v AND Var sl' EQ i OR (IndP (Var sl) OR Var sl NEQ v) AND Var sl' EQ Var sl) OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN Var l AND Var n IN Var l AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND Var sl EQ Q_Eats (Var sm) (Var sn) AND Var sl' EQ Q_Eats (Var sm') (Var sn')))))))))))›*)) (*top goal: ‹⟦atom l ♯ (v, i, t, u, s, k, sl, sl', m, n, sm, sm', sn, sn'); atom sl ♯ (v, i, t, u, s, k, sl', m, n, sm, sm', sn, sn'); atom sl' ♯ (v, i, t, u, s, k, m, n, sm, sm', sn, sn'); atom m ♯ (v, i, t, u, s, k, n, sm, sm', sn, sn'); atom n ♯ (v, i, t, u, s, k, sm, sm', sn, sn'); atom sm ♯ (v, i, t, u, s, k, sm', sn, sn'); atom sm' ♯ (v, i, t, u, s, k, sn, sn'); atom sn ♯ (v, i, t, u, s, k, sn'); atom sn' ♯ (v, i, t, u, s, k)⟧ ⟹ {Var sl EQ Q_Eats (Var sm) (Var sn), Var sl' EQ Q_Eats (Var sm') (Var sn'), HPair (Var n) (HPair (Var sn) (Var sn')) IN s, HPair (Var m) (HPair (Var sm) (Var sm')) IN s, Var n IN k, Var m IN k, t EQ Var sl, u EQ Var sl', HPair k (HPair (Var sl) (Var sl')) IN s, All2 l k (SyntaxN.Ex sl (SyntaxN.Ex sl' (HPair (Var l) (HPair (Var sl) (Var sl')) IN s AND ((Var sl EQ v AND Var sl' EQ i OR (IndP (Var sl) OR Var sl NEQ v) AND Var sl' EQ Var sl) OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN Var l AND Var n IN Var l AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND Var sl EQ Q_Eats (Var sm) (Var sn) AND Var sl' EQ Q_Eats (Var sm') (Var sn'))))))))))), LstSeqP s k (HPair t u), VarP v} ⊢ Var m IN k AND Var n IN k AND SeqStTermP v i (Var sm) (Var sm') s (Var m) AND SeqStTermP v i (Var sn) (Var sn') s (Var n) AND t EQ Q_Eats (Var sm) (Var sn) AND u EQ Q_Eats (Var sm') (Var sn')› and 16 goals remain*) apply (rule Conj_I (*‹⟦?H ⊢ ?A; ?H ⊢ ?B⟧ ⟹ ?H ⊢ ?A AND ?B›*)) (*goals: 1. ‹⟦atom l ♯ (v, i, t, u, s, k, sl, sl', m, n, sm, sm', sn, sn'); atom sl ♯ (v, i, t, u, s, k, sl', m, n, sm, sm', sn, sn'); atom sl' ♯ (v, i, t, u, s, k, m, n, sm, sm', sn, sn'); atom m ♯ (v, i, t, u, s, k, n, sm, sm', sn, sn'); atom n ♯ (v, i, t, u, s, k, sm, sm', sn, sn'); atom sm ♯ (v, i, t, u, s, k, sm', sn, sn'); atom sm' ♯ (v, i, t, u, s, k, sn, sn'); atom sn ♯ (v, i, t, u, s, k, sn'); atom sn' ♯ (v, i, t, u, s, k)⟧ ⟹ {Var sl EQ Q_Eats (Var sm) (Var sn), Var sl' EQ Q_Eats (Var sm') (Var sn'), HPair (Var n) (HPair (Var sn) (Var sn')) IN s, HPair (Var m) (HPair (Var sm) (Var sm')) IN s, Var n IN k, Var m IN k, t EQ Var sl, u EQ Var sl', HPair k (HPair (Var sl) (Var sl')) IN s, All2 l k (SyntaxN.Ex sl (SyntaxN.Ex sl' (HPair (Var l) (HPair (Var sl) (Var sl')) IN s AND ((Var sl EQ v AND Var sl' EQ i OR (IndP (Var sl) OR Var sl NEQ v) AND Var sl' EQ Var sl) OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN Var l AND Var n IN Var l AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND Var sl EQ Q_Eats (Var sm) (Var sn) AND Var sl' EQ Q_Eats (Var sm') (Var sn'))))))))))), LstSeqP s k (HPair t u), VarP v} ⊢ Var m IN k› 2. ‹⟦atom l ♯ (v, i, t, u, s, k, sl, sl', m, n, sm, sm', sn, sn'); atom sl ♯ (v, i, t, u, s, k, sl', m, n, sm, sm', sn, sn'); atom sl' ♯ (v, i, t, u, s, k, m, n, sm, sm', sn, sn'); atom m ♯ (v, i, t, u, s, k, n, sm, sm', sn, sn'); atom n ♯ (v, i, t, u, s, k, sm, sm', sn, sn'); atom sm ♯ (v, i, t, u, s, k, sm', sn, sn'); atom sm' ♯ (v, i, t, u, s, k, sn, sn'); atom sn ♯ (v, i, t, u, s, k, sn'); atom sn' ♯ (v, i, t, u, s, k)⟧ ⟹ {Var sl EQ Q_Eats (Var sm) (Var sn), Var sl' EQ Q_Eats (Var sm') (Var sn'), HPair (Var n) (HPair (Var sn) (Var sn')) IN s, HPair (Var m) (HPair (Var sm) (Var sm')) IN s, Var n IN k, Var m IN k, t EQ Var sl, u EQ Var sl', HPair k (HPair (Var sl) (Var sl')) IN s, All2 l k (SyntaxN.Ex sl (SyntaxN.Ex sl' (HPair (Var l) (HPair (Var sl) (Var sl')) IN s AND ((Var sl EQ v AND Var sl' EQ i OR (IndP (Var sl) OR Var sl NEQ v) AND Var sl' EQ Var sl) OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN Var l AND Var n IN Var l AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND Var sl EQ Q_Eats (Var sm) (Var sn) AND Var sl' EQ Q_Eats (Var sm') (Var sn'))))))))))), LstSeqP s k (HPair t u), VarP v} ⊢ Var n IN k AND (VarP v AND LstSeqP s (Var m) (HPair (Var sm) (Var sm')) AND All2 l (SUCC (Var m)) (SyntaxN.Ex sl (SyntaxN.Ex sl' (HPair (Var l) (HPair (Var sl) (Var sl')) IN s AND ((Var sl EQ v AND Var sl' EQ i OR (IndP (Var sl) OR Var sl NEQ v) AND Var sl' EQ Var sl) OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN Var l AND Var n IN Var l AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND Var sl EQ Q_Eats (Var sm) (Var sn) AND Var sl' EQ Q_Eats (Var sm') (Var sn')))))))))))) AND (VarP v AND LstSeqP s (Var n) (HPair (Var sn) (Var sn')) AND All2 l (SUCC (Var n)) (SyntaxN.Ex sl (SyntaxN.Ex sl' (HPair (Var l) (HPair (Var sl) (Var sl')) IN s AND ((Var sl EQ v AND Var sl' EQ i OR (IndP (Var sl) OR Var sl NEQ v) AND Var sl' EQ Var sl) OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN Var l AND Var n IN Var l AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND Var sl EQ Q_Eats (Var sm) (Var sn) AND Var sl' EQ Q_Eats (Var sm') (Var sn')))))))))))) AND t EQ Q_Eats (Var sm) (Var sn) AND u EQ Q_Eats (Var sm') (Var sn')› discuss goal 1*) apply (blast intro: LstSeqP_Mem (*‹⟦?H ⊢ LstSeqP ?r ?k ?y; ?H ⊢ HPair ?k' ?z IN ?r; ?H ⊢ ?k' IN ?k⟧ ⟹ ?H ⊢ LstSeqP ?r ?k' ?z›*)) (*discuss goal 2*) apply (rule Conj_I (*‹⟦?H ⊢ ?A; ?H ⊢ ?B⟧ ⟹ ?H ⊢ ?A AND ?B›*)) (*goals: 1. ‹⟦atom l ♯ (v, i, t, u, s, k, sl, sl', m, n, sm, sm', sn, sn'); atom sl ♯ (v, i, t, u, s, k, sl', m, n, sm, sm', sn, sn'); atom sl' ♯ (v, i, t, u, s, k, m, n, sm, sm', sn, sn'); atom m ♯ (v, i, t, u, s, k, n, sm, sm', sn, sn'); atom n ♯ (v, i, t, u, s, k, sm, sm', sn, sn'); atom sm ♯ (v, i, t, u, s, k, sm', sn, sn'); atom sm' ♯ (v, i, t, u, s, k, sn, sn'); atom sn ♯ (v, i, t, u, s, k, sn'); atom sn' ♯ (v, i, t, u, s, k)⟧ ⟹ {Var sl EQ Q_Eats (Var sm) (Var sn), Var sl' EQ Q_Eats (Var sm') (Var sn'), HPair (Var n) (HPair (Var sn) (Var sn')) IN s, HPair (Var m) (HPair (Var sm) (Var sm')) IN s, Var n IN k, Var m IN k, t EQ Var sl, u EQ Var sl', HPair k (HPair (Var sl) (Var sl')) IN s, All2 l k (SyntaxN.Ex sl (SyntaxN.Ex sl' (HPair (Var l) (HPair (Var sl) (Var sl')) IN s AND ((Var sl EQ v AND Var sl' EQ i OR (IndP (Var sl) OR Var sl NEQ v) AND Var sl' EQ Var sl) OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN Var l AND Var n IN Var l AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND Var sl EQ Q_Eats (Var sm) (Var sn) AND Var sl' EQ Q_Eats (Var sm') (Var sn'))))))))))), LstSeqP s k (HPair t u), VarP v} ⊢ Var n IN k› 2. ‹⟦atom l ♯ (v, i, t, u, s, k, sl, sl', m, n, sm, sm', sn, sn'); atom sl ♯ (v, i, t, u, s, k, sl', m, n, sm, sm', sn, sn'); atom sl' ♯ (v, i, t, u, s, k, m, n, sm, sm', sn, sn'); atom m ♯ (v, i, t, u, s, k, n, sm, sm', sn, sn'); atom n ♯ (v, i, t, u, s, k, sm, sm', sn, sn'); atom sm ♯ (v, i, t, u, s, k, sm', sn, sn'); atom sm' ♯ (v, i, t, u, s, k, sn, sn'); atom sn ♯ (v, i, t, u, s, k, sn'); atom sn' ♯ (v, i, t, u, s, k)⟧ ⟹ {Var sl EQ Q_Eats (Var sm) (Var sn), Var sl' EQ Q_Eats (Var sm') (Var sn'), HPair (Var n) (HPair (Var sn) (Var sn')) IN s, HPair (Var m) (HPair (Var sm) (Var sm')) IN s, Var n IN k, Var m IN k, t EQ Var sl, u EQ Var sl', HPair k (HPair (Var sl) (Var sl')) IN s, All2 l k (SyntaxN.Ex sl (SyntaxN.Ex sl' (HPair (Var l) (HPair (Var sl) (Var sl')) IN s AND ((Var sl EQ v AND Var sl' EQ i OR (IndP (Var sl) OR Var sl NEQ v) AND Var sl' EQ Var sl) OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN Var l AND Var n IN Var l AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND Var sl EQ Q_Eats (Var sm) (Var sn) AND Var sl' EQ Q_Eats (Var sm') (Var sn'))))))))))), LstSeqP s k (HPair t u), VarP v} ⊢ (VarP v AND LstSeqP s (Var m) (HPair (Var sm) (Var sm')) AND All2 l (SUCC (Var m)) (SyntaxN.Ex sl (SyntaxN.Ex sl' (HPair (Var l) (HPair (Var sl) (Var sl')) IN s AND ((Var sl EQ v AND Var sl' EQ i OR (IndP (Var sl) OR Var sl NEQ v) AND Var sl' EQ Var sl) OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN Var l AND Var n IN Var l AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND Var sl EQ Q_Eats (Var sm) (Var sn) AND Var sl' EQ Q_Eats (Var sm') (Var sn')))))))))))) AND (VarP v AND LstSeqP s (Var n) (HPair (Var sn) (Var sn')) AND All2 l (SUCC (Var n)) (SyntaxN.Ex sl (SyntaxN.Ex sl' (HPair (Var l) (HPair (Var sl) (Var sl')) IN s AND ((Var sl EQ v AND Var sl' EQ i OR (IndP (Var sl) OR Var sl NEQ v) AND Var sl' EQ Var sl) OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN Var l AND Var n IN Var l AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND Var sl EQ Q_Eats (Var sm) (Var sn) AND Var sl' EQ Q_Eats (Var sm') (Var sn')))))))))))) AND t EQ Q_Eats (Var sm) (Var sn) AND u EQ Q_Eats (Var sm') (Var sn')› discuss goal 1*) apply (blast intro: LstSeqP_Mem (*‹⟦?H ⊢ LstSeqP ?r ?k ?y; ?H ⊢ HPair ?k' ?z IN ?r; ?H ⊢ ?k' IN ?k⟧ ⟹ ?H ⊢ LstSeqP ?r ?k' ?z›*)) (*discuss goal 2*) apply (rule Conj_I (*‹⟦?H ⊢ ?A; ?H ⊢ ?B⟧ ⟹ ?H ⊢ ?A AND ?B›*)) (*goals: 1. ‹⟦atom l ♯ (v, i, t, u, s, k, sl, sl', m, n, sm, sm', sn, sn'); atom sl ♯ (v, i, t, u, s, k, sl', m, n, sm, sm', sn, sn'); atom sl' ♯ (v, i, t, u, s, k, m, n, sm, sm', sn, sn'); atom m ♯ (v, i, t, u, s, k, n, sm, sm', sn, sn'); atom n ♯ (v, i, t, u, s, k, sm, sm', sn, sn'); atom sm ♯ (v, i, t, u, s, k, sm', sn, sn'); atom sm' ♯ (v, i, t, u, s, k, sn, sn'); atom sn ♯ (v, i, t, u, s, k, sn'); atom sn' ♯ (v, i, t, u, s, k)⟧ ⟹ {Var sl EQ Q_Eats (Var sm) (Var sn), Var sl' EQ Q_Eats (Var sm') (Var sn'), HPair (Var n) (HPair (Var sn) (Var sn')) IN s, HPair (Var m) (HPair (Var sm) (Var sm')) IN s, Var n IN k, Var m IN k, t EQ Var sl, u EQ Var sl', HPair k (HPair (Var sl) (Var sl')) IN s, All2 l k (SyntaxN.Ex sl (SyntaxN.Ex sl' (HPair (Var l) (HPair (Var sl) (Var sl')) IN s AND ((Var sl EQ v AND Var sl' EQ i OR (IndP (Var sl) OR Var sl NEQ v) AND Var sl' EQ Var sl) OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN Var l AND Var n IN Var l AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND Var sl EQ Q_Eats (Var sm) (Var sn) AND Var sl' EQ Q_Eats (Var sm') (Var sn'))))))))))), LstSeqP s k (HPair t u), VarP v} ⊢ VarP v AND LstSeqP s (Var m) (HPair (Var sm) (Var sm')) AND All2 l (SUCC (Var m)) (SyntaxN.Ex sl (SyntaxN.Ex sl' (HPair (Var l) (HPair (Var sl) (Var sl')) IN s AND ((Var sl EQ v AND Var sl' EQ i OR (IndP (Var sl) OR Var sl NEQ v) AND Var sl' EQ Var sl) OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN Var l AND Var n IN Var l AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND Var sl EQ Q_Eats (Var sm) (Var sn) AND Var sl' EQ Q_Eats (Var sm') (Var sn')))))))))))› 2. ‹⟦atom l ♯ (v, i, t, u, s, k, sl, sl', m, n, sm, sm', sn, sn'); atom sl ♯ (v, i, t, u, s, k, sl', m, n, sm, sm', sn, sn'); atom sl' ♯ (v, i, t, u, s, k, m, n, sm, sm', sn, sn'); atom m ♯ (v, i, t, u, s, k, n, sm, sm', sn, sn'); atom n ♯ (v, i, t, u, s, k, sm, sm', sn, sn'); atom sm ♯ (v, i, t, u, s, k, sm', sn, sn'); atom sm' ♯ (v, i, t, u, s, k, sn, sn'); atom sn ♯ (v, i, t, u, s, k, sn'); atom sn' ♯ (v, i, t, u, s, k)⟧ ⟹ {Var sl EQ Q_Eats (Var sm) (Var sn), Var sl' EQ Q_Eats (Var sm') (Var sn'), HPair (Var n) (HPair (Var sn) (Var sn')) IN s, HPair (Var m) (HPair (Var sm) (Var sm')) IN s, Var n IN k, Var m IN k, t EQ Var sl, u EQ Var sl', HPair k (HPair (Var sl) (Var sl')) IN s, All2 l k (SyntaxN.Ex sl (SyntaxN.Ex sl' (HPair (Var l) (HPair (Var sl) (Var sl')) IN s AND ((Var sl EQ v AND Var sl' EQ i OR (IndP (Var sl) OR Var sl NEQ v) AND Var sl' EQ Var sl) OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN Var l AND Var n IN Var l AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND Var sl EQ Q_Eats (Var sm) (Var sn) AND Var sl' EQ Q_Eats (Var sm') (Var sn'))))))))))), LstSeqP s k (HPair t u), VarP v} ⊢ (VarP v AND LstSeqP s (Var n) (HPair (Var sn) (Var sn')) AND All2 l (SUCC (Var n)) (SyntaxN.Ex sl (SyntaxN.Ex sl' (HPair (Var l) (HPair (Var sl) (Var sl')) IN s AND ((Var sl EQ v AND Var sl' EQ i OR (IndP (Var sl) OR Var sl NEQ v) AND Var sl' EQ Var sl) OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN Var l AND Var n IN Var l AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND Var sl EQ Q_Eats (Var sm) (Var sn) AND Var sl' EQ Q_Eats (Var sm') (Var sn')))))))))))) AND t EQ Q_Eats (Var sm) (Var sn) AND u EQ Q_Eats (Var sm') (Var sn')› discuss goal 1*) apply (rule Conj_I (*‹⟦?H ⊢ ?A; ?H ⊢ ?B⟧ ⟹ ?H ⊢ ?A AND ?B›*)) (*goals: 1. ‹⟦atom l ♯ (v, i, t, u, s, k, sl, sl', m, n, sm, sm', sn, sn'); atom sl ♯ (v, i, t, u, s, k, sl', m, n, sm, sm', sn, sn'); atom sl' ♯ (v, i, t, u, s, k, m, n, sm, sm', sn, sn'); atom m ♯ (v, i, t, u, s, k, n, sm, sm', sn, sn'); atom n ♯ (v, i, t, u, s, k, sm, sm', sn, sn'); atom sm ♯ (v, i, t, u, s, k, sm', sn, sn'); atom sm' ♯ (v, i, t, u, s, k, sn, sn'); atom sn ♯ (v, i, t, u, s, k, sn'); atom sn' ♯ (v, i, t, u, s, k)⟧ ⟹ {Var sl EQ Q_Eats (Var sm) (Var sn), Var sl' EQ Q_Eats (Var sm') (Var sn'), HPair (Var n) (HPair (Var sn) (Var sn')) IN s, HPair (Var m) (HPair (Var sm) (Var sm')) IN s, Var n IN k, Var m IN k, t EQ Var sl, u EQ Var sl', HPair k (HPair (Var sl) (Var sl')) IN s, All2 l k (SyntaxN.Ex sl (SyntaxN.Ex sl' (HPair (Var l) (HPair (Var sl) (Var sl')) IN s AND ((Var sl EQ v AND Var sl' EQ i OR (IndP (Var sl) OR Var sl NEQ v) AND Var sl' EQ Var sl) OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN Var l AND Var n IN Var l AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND Var sl EQ Q_Eats (Var sm) (Var sn) AND Var sl' EQ Q_Eats (Var sm') (Var sn'))))))))))), LstSeqP s k (HPair t u), VarP v} ⊢ VarP v› 2. ‹⟦atom l ♯ (v, i, t, u, s, k, sl, sl', m, n, sm, sm', sn, sn'); atom sl ♯ (v, i, t, u, s, k, sl', m, n, sm, sm', sn, sn'); atom sl' ♯ (v, i, t, u, s, k, m, n, sm, sm', sn, sn'); atom m ♯ (v, i, t, u, s, k, n, sm, sm', sn, sn'); atom n ♯ (v, i, t, u, s, k, sm, sm', sn, sn'); atom sm ♯ (v, i, t, u, s, k, sm', sn, sn'); atom sm' ♯ (v, i, t, u, s, k, sn, sn'); atom sn ♯ (v, i, t, u, s, k, sn'); atom sn' ♯ (v, i, t, u, s, k)⟧ ⟹ {Var sl EQ Q_Eats (Var sm) (Var sn), Var sl' EQ Q_Eats (Var sm') (Var sn'), HPair (Var n) (HPair (Var sn) (Var sn')) IN s, HPair (Var m) (HPair (Var sm) (Var sm')) IN s, Var n IN k, Var m IN k, t EQ Var sl, u EQ Var sl', HPair k (HPair (Var sl) (Var sl')) IN s, All2 l k (SyntaxN.Ex sl (SyntaxN.Ex sl' (HPair (Var l) (HPair (Var sl) (Var sl')) IN s AND ((Var sl EQ v AND Var sl' EQ i OR (IndP (Var sl) OR Var sl NEQ v) AND Var sl' EQ Var sl) OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN Var l AND Var n IN Var l AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND Var sl EQ Q_Eats (Var sm) (Var sn) AND Var sl' EQ Q_Eats (Var sm') (Var sn'))))))))))), LstSeqP s k (HPair t u), VarP v} ⊢ LstSeqP s (Var m) (HPair (Var sm) (Var sm')) AND All2 l (SUCC (Var m)) (SyntaxN.Ex sl (SyntaxN.Ex sl' (HPair (Var l) (HPair (Var sl) (Var sl')) IN s AND ((Var sl EQ v AND Var sl' EQ i OR (IndP (Var sl) OR Var sl NEQ v) AND Var sl' EQ Var sl) OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN Var l AND Var n IN Var l AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND Var sl EQ Q_Eats (Var sm) (Var sn) AND Var sl' EQ Q_Eats (Var sm') (Var sn')))))))))))› discuss goal 1*) apply (blast intro: LstSeqP_Mem (*‹⟦?H ⊢ LstSeqP ?r ?k ?y; ?H ⊢ HPair ?k' ?z IN ?r; ?H ⊢ ?k' IN ?k⟧ ⟹ ?H ⊢ LstSeqP ?r ?k' ?z›*)) (*discuss goal 2*) apply (rule Conj_I (*‹⟦?H ⊢ ?A; ?H ⊢ ?B⟧ ⟹ ?H ⊢ ?A AND ?B›*)) (*goals: 1. ‹⟦atom l ♯ (v, i, t, u, s, k, sl, sl', m, n, sm, sm', sn, sn'); atom sl ♯ (v, i, t, u, s, k, sl', m, n, sm, sm', sn, sn'); atom sl' ♯ (v, i, t, u, s, k, m, n, sm, sm', sn, sn'); atom m ♯ (v, i, t, u, s, k, n, sm, sm', sn, sn'); atom n ♯ (v, i, t, u, s, k, sm, sm', sn, sn'); atom sm ♯ (v, i, t, u, s, k, sm', sn, sn'); atom sm' ♯ (v, i, t, u, s, k, sn, sn'); atom sn ♯ (v, i, t, u, s, k, sn'); atom sn' ♯ (v, i, t, u, s, k)⟧ ⟹ {Var sl EQ Q_Eats (Var sm) (Var sn), Var sl' EQ Q_Eats (Var sm') (Var sn'), HPair (Var n) (HPair (Var sn) (Var sn')) IN s, HPair (Var m) (HPair (Var sm) (Var sm')) IN s, Var n IN k, Var m IN k, t EQ Var sl, u EQ Var sl', HPair k (HPair (Var sl) (Var sl')) IN s, All2 l k (SyntaxN.Ex sl (SyntaxN.Ex sl' (HPair (Var l) (HPair (Var sl) (Var sl')) IN s AND ((Var sl EQ v AND Var sl' EQ i OR (IndP (Var sl) OR Var sl NEQ v) AND Var sl' EQ Var sl) OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN Var l AND Var n IN Var l AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND Var sl EQ Q_Eats (Var sm) (Var sn) AND Var sl' EQ Q_Eats (Var sm') (Var sn'))))))))))), LstSeqP s k (HPair t u), VarP v} ⊢ LstSeqP s (Var m) (HPair (Var sm) (Var sm'))› 2. ‹⟦atom l ♯ (v, i, t, u, s, k, sl, sl', m, n, sm, sm', sn, sn'); atom sl ♯ (v, i, t, u, s, k, sl', m, n, sm, sm', sn, sn'); atom sl' ♯ (v, i, t, u, s, k, m, n, sm, sm', sn, sn'); atom m ♯ (v, i, t, u, s, k, n, sm, sm', sn, sn'); atom n ♯ (v, i, t, u, s, k, sm, sm', sn, sn'); atom sm ♯ (v, i, t, u, s, k, sm', sn, sn'); atom sm' ♯ (v, i, t, u, s, k, sn, sn'); atom sn ♯ (v, i, t, u, s, k, sn'); atom sn' ♯ (v, i, t, u, s, k)⟧ ⟹ {Var sl EQ Q_Eats (Var sm) (Var sn), Var sl' EQ Q_Eats (Var sm') (Var sn'), HPair (Var n) (HPair (Var sn) (Var sn')) IN s, HPair (Var m) (HPair (Var sm) (Var sm')) IN s, Var n IN k, Var m IN k, t EQ Var sl, u EQ Var sl', HPair k (HPair (Var sl) (Var sl')) IN s, All2 l k (SyntaxN.Ex sl (SyntaxN.Ex sl' (HPair (Var l) (HPair (Var sl) (Var sl')) IN s AND ((Var sl EQ v AND Var sl' EQ i OR (IndP (Var sl) OR Var sl NEQ v) AND Var sl' EQ Var sl) OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN Var l AND Var n IN Var l AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND Var sl EQ Q_Eats (Var sm) (Var sn) AND Var sl' EQ Q_Eats (Var sm') (Var sn'))))))))))), LstSeqP s k (HPair t u), VarP v} ⊢ All2 l (SUCC (Var m)) (SyntaxN.Ex sl (SyntaxN.Ex sl' (HPair (Var l) (HPair (Var sl) (Var sl')) IN s AND ((Var sl EQ v AND Var sl' EQ i OR (IndP (Var sl) OR Var sl NEQ v) AND Var sl' EQ Var sl) OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN Var l AND Var n IN Var l AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND Var sl EQ Q_Eats (Var sm) (Var sn) AND Var sl' EQ Q_Eats (Var sm') (Var sn')))))))))))› discuss goal 1*) apply (blast intro: LstSeqP_Mem (*‹⟦(?H::fm set) ⊢ LstSeqP (?r::tm) (?k::tm) (?y::tm); ?H ⊢ HPair (?k'::tm) (?z::tm) IN ?r; ?H ⊢ ?k' IN ?k⟧ ⟹ ?H ⊢ LstSeqP ?r ?k' ?z›*)) (*discuss goal 2*) apply (rule All2_Subset [OF Hyp] (*‹⟦All2 (?l::name) (?k::tm) (?P::fm) ∈ (?H::fm set); ?H ⊢ (?k'::tm) SUBS ?k; {?P} ⊢ (?P'::fm); atom ?l ♯ (?k', ?k)⟧ ⟹ ?H ⊢ All2 ?l ?k' ?P'›*)) (*goals: 1. ‹⟦atom (l::name) ♯ (v::tm, i::tm, t::tm, u::tm, s::tm, k::tm, sl::name, sl'::name, m::name, n::name, sm::name, sm'::name, sn::name, sn'::name); atom sl ♯ (v, i, t, u, s, k, sl', m, n, sm, sm', sn, sn'); atom sl' ♯ (v, i, t, u, s, k, m, n, sm, sm', sn, sn'); atom m ♯ (v, i, t, u, s, k, n, sm, sm', sn, sn'); atom n ♯ (v, i, t, u, s, k, sm, sm', sn, sn'); atom sm ♯ (v, i, t, u, s, k, sm', sn, sn'); atom sm' ♯ (v, i, t, u, s, k, sn, sn'); atom sn ♯ (v, i, t, u, s, k, sn'); atom sn' ♯ (v, i, t, u, s, k)⟧ ⟹ All2 l (?k144::tm) (?P144::fm) ∈ {Var sl EQ Q_Eats (Var sm) (Var sn), Var sl' EQ Q_Eats (Var sm') (Var sn'), HPair (Var n) (HPair (Var sn) (Var sn')) IN s, HPair (Var m) (HPair (Var sm) (Var sm')) IN s, Var n IN k, Var m IN k, t EQ Var sl, u EQ Var sl', HPair k (HPair (Var sl) (Var sl')) IN s, All2 l k (SyntaxN.Ex sl (SyntaxN.Ex sl' (HPair (Var l) (HPair (Var sl) (Var sl')) IN s AND ((Var sl EQ v AND Var sl' EQ i OR (IndP (Var sl) OR Var sl NEQ v) AND Var sl' EQ Var sl) OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN Var l AND Var n IN Var l AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND Var sl EQ Q_Eats (Var sm) (Var sn) AND Var sl' EQ Q_Eats (Var sm') (Var sn'))))))))))), LstSeqP s k (HPair t u), VarP v}› 2. ‹⟦atom (l::name) ♯ (v::tm, i::tm, t::tm, u::tm, s::tm, k::tm, sl::name, sl'::name, m::name, n::name, sm::name, sm'::name, sn::name, sn'::name); atom sl ♯ (v, i, t, u, s, k, sl', m, n, sm, sm', sn, sn'); atom sl' ♯ (v, i, t, u, s, k, m, n, sm, sm', sn, sn'); atom m ♯ (v, i, t, u, s, k, n, sm, sm', sn, sn'); atom n ♯ (v, i, t, u, s, k, sm, sm', sn, sn'); atom sm ♯ (v, i, t, u, s, k, sm', sn, sn'); atom sm' ♯ (v, i, t, u, s, k, sn, sn'); atom sn ♯ (v, i, t, u, s, k, sn'); atom sn' ♯ (v, i, t, u, s, k)⟧ ⟹ {Var sl EQ Q_Eats (Var sm) (Var sn), Var sl' EQ Q_Eats (Var sm') (Var sn'), HPair (Var n) (HPair (Var sn) (Var sn')) IN s, HPair (Var m) (HPair (Var sm) (Var sm')) IN s, Var n IN k, Var m IN k, t EQ Var sl, u EQ Var sl', HPair k (HPair (Var sl) (Var sl')) IN s, All2 l k (SyntaxN.Ex sl (SyntaxN.Ex sl' (HPair (Var l) (HPair (Var sl) (Var sl')) IN s AND ((Var sl EQ v AND Var sl' EQ i OR (IndP (Var sl) OR Var sl NEQ v) AND Var sl' EQ Var sl) OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN Var l AND Var n IN Var l AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND Var sl EQ Q_Eats (Var sm) (Var sn) AND Var sl' EQ Q_Eats (Var sm') (Var sn'))))))))))), LstSeqP s k (HPair t u), VarP v} ⊢ SUCC (Var m) SUBS (?k144::tm)› 3. ‹⟦atom (l::name) ♯ (v::tm, i::tm, t::tm, u::tm, s::tm, k::tm, sl::name, sl'::name, m::name, n::name, sm::name, sm'::name, sn::name, sn'::name); atom sl ♯ (v, i, t, u, s, k, sl', m, n, sm, sm', sn, sn'); atom sl' ♯ (v, i, t, u, s, k, m, n, sm, sm', sn, sn'); atom m ♯ (v, i, t, u, s, k, n, sm, sm', sn, sn'); atom n ♯ (v, i, t, u, s, k, sm, sm', sn, sn'); atom sm ♯ (v, i, t, u, s, k, sm', sn, sn'); atom sm' ♯ (v, i, t, u, s, k, sn, sn'); atom sn ♯ (v, i, t, u, s, k, sn'); atom sn' ♯ (v, i, t, u, s, k)⟧ ⟹ {?P144::fm} ⊢ SyntaxN.Ex sl (SyntaxN.Ex sl' (HPair (Var l) (HPair (Var sl) (Var sl')) IN s AND ((Var sl EQ v AND Var sl' EQ i OR (IndP (Var sl) OR Var sl NEQ v) AND Var sl' EQ Var sl) OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN Var l AND Var n IN Var l AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND Var sl EQ Q_Eats (Var sm) (Var sn) AND Var sl' EQ Q_Eats (Var sm') (Var sn'))))))))))› 4. ‹⟦atom (l::name) ♯ (v::tm, i::tm, t::tm, u::tm, s::tm, k::tm, sl::name, sl'::name, m::name, n::name, sm::name, sm'::name, sn::name, sn'::name); atom sl ♯ (v, i, t, u, s, k, sl', m, n, sm, sm', sn, sn'); atom sl' ♯ (v, i, t, u, s, k, m, n, sm, sm', sn, sn'); atom m ♯ (v, i, t, u, s, k, n, sm, sm', sn, sn'); atom n ♯ (v, i, t, u, s, k, sm, sm', sn, sn'); atom sm ♯ (v, i, t, u, s, k, sm', sn, sn'); atom sm' ♯ (v, i, t, u, s, k, sn, sn'); atom sn ♯ (v, i, t, u, s, k, sn'); atom sn' ♯ (v, i, t, u, s, k)⟧ ⟹ atom l ♯ (SUCC (Var m), ?k144::tm)› discuss goal 1*) apply blast (*discuss goal 2*) apply (blast intro!: SUCC_Subset_Ord (*‹⟦?H ⊢ ?k' IN ?k; ?H ⊢ OrdP ?k⟧ ⟹ ?H ⊢ SUCC ?k' SUBS ?k›*) LstSeqP_OrdP (*‹?H ⊢ LstSeqP ?r ?k ?y ⟹ ?H ⊢ OrdP ?k›*)) (*discuss goal 3*) apply blast (*discuss goal 4*) apply simp (*proven 4 subgoals*) (*proven 2 subgoals*) (*proven 2 subgoals*) (*discuss goal 2*) apply (rule Conj_I (*‹⟦?H ⊢ ?A; ?H ⊢ ?B⟧ ⟹ ?H ⊢ ?A AND ?B›*)) (*goals: 1. ‹⟦atom l ♯ (v, i, t, u, s, k, sl, sl', m, n, sm, sm', sn, sn'); atom sl ♯ (v, i, t, u, s, k, sl', m, n, sm, sm', sn, sn'); atom sl' ♯ (v, i, t, u, s, k, m, n, sm, sm', sn, sn'); atom m ♯ (v, i, t, u, s, k, n, sm, sm', sn, sn'); atom n ♯ (v, i, t, u, s, k, sm, sm', sn, sn'); atom sm ♯ (v, i, t, u, s, k, sm', sn, sn'); atom sm' ♯ (v, i, t, u, s, k, sn, sn'); atom sn ♯ (v, i, t, u, s, k, sn'); atom sn' ♯ (v, i, t, u, s, k)⟧ ⟹ {Var sl EQ Q_Eats (Var sm) (Var sn), Var sl' EQ Q_Eats (Var sm') (Var sn'), HPair (Var n) (HPair (Var sn) (Var sn')) IN s, HPair (Var m) (HPair (Var sm) (Var sm')) IN s, Var n IN k, Var m IN k, t EQ Var sl, u EQ Var sl', HPair k (HPair (Var sl) (Var sl')) IN s, All2 l k (SyntaxN.Ex sl (SyntaxN.Ex sl' (HPair (Var l) (HPair (Var sl) (Var sl')) IN s AND ((Var sl EQ v AND Var sl' EQ i OR (IndP (Var sl) OR Var sl NEQ v) AND Var sl' EQ Var sl) OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN Var l AND Var n IN Var l AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND Var sl EQ Q_Eats (Var sm) (Var sn) AND Var sl' EQ Q_Eats (Var sm') (Var sn'))))))))))), LstSeqP s k (HPair t u), VarP v} ⊢ VarP v AND LstSeqP s (Var n) (HPair (Var sn) (Var sn')) AND All2 l (SUCC (Var n)) (SyntaxN.Ex sl (SyntaxN.Ex sl' (HPair (Var l) (HPair (Var sl) (Var sl')) IN s AND ((Var sl EQ v AND Var sl' EQ i OR (IndP (Var sl) OR Var sl NEQ v) AND Var sl' EQ Var sl) OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN Var l AND Var n IN Var l AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND Var sl EQ Q_Eats (Var sm) (Var sn) AND Var sl' EQ Q_Eats (Var sm') (Var sn')))))))))))› 2. ‹⟦atom l ♯ (v, i, t, u, s, k, sl, sl', m, n, sm, sm', sn, sn'); atom sl ♯ (v, i, t, u, s, k, sl', m, n, sm, sm', sn, sn'); atom sl' ♯ (v, i, t, u, s, k, m, n, sm, sm', sn, sn'); atom m ♯ (v, i, t, u, s, k, n, sm, sm', sn, sn'); atom n ♯ (v, i, t, u, s, k, sm, sm', sn, sn'); atom sm ♯ (v, i, t, u, s, k, sm', sn, sn'); atom sm' ♯ (v, i, t, u, s, k, sn, sn'); atom sn ♯ (v, i, t, u, s, k, sn'); atom sn' ♯ (v, i, t, u, s, k)⟧ ⟹ {Var sl EQ Q_Eats (Var sm) (Var sn), Var sl' EQ Q_Eats (Var sm') (Var sn'), HPair (Var n) (HPair (Var sn) (Var sn')) IN s, HPair (Var m) (HPair (Var sm) (Var sm')) IN s, Var n IN k, Var m IN k, t EQ Var sl, u EQ Var sl', HPair k (HPair (Var sl) (Var sl')) IN s, All2 l k (SyntaxN.Ex sl (SyntaxN.Ex sl' (HPair (Var l) (HPair (Var sl) (Var sl')) IN s AND ((Var sl EQ v AND Var sl' EQ i OR (IndP (Var sl) OR Var sl NEQ v) AND Var sl' EQ Var sl) OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN Var l AND Var n IN Var l AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND Var sl EQ Q_Eats (Var sm) (Var sn) AND Var sl' EQ Q_Eats (Var sm') (Var sn'))))))))))), LstSeqP s k (HPair t u), VarP v} ⊢ t EQ Q_Eats (Var sm) (Var sn) AND u EQ Q_Eats (Var sm') (Var sn')› discuss goal 1*) apply (rule Conj_I (*‹⟦?H ⊢ ?A; ?H ⊢ ?B⟧ ⟹ ?H ⊢ ?A AND ?B›*)) (*goals: 1. ‹⟦atom l ♯ (v, i, t, u, s, k, sl, sl', m, n, sm, sm', sn, sn'); atom sl ♯ (v, i, t, u, s, k, sl', m, n, sm, sm', sn, sn'); atom sl' ♯ (v, i, t, u, s, k, m, n, sm, sm', sn, sn'); atom m ♯ (v, i, t, u, s, k, n, sm, sm', sn, sn'); atom n ♯ (v, i, t, u, s, k, sm, sm', sn, sn'); atom sm ♯ (v, i, t, u, s, k, sm', sn, sn'); atom sm' ♯ (v, i, t, u, s, k, sn, sn'); atom sn ♯ (v, i, t, u, s, k, sn'); atom sn' ♯ (v, i, t, u, s, k)⟧ ⟹ {Var sl EQ Q_Eats (Var sm) (Var sn), Var sl' EQ Q_Eats (Var sm') (Var sn'), HPair (Var n) (HPair (Var sn) (Var sn')) IN s, HPair (Var m) (HPair (Var sm) (Var sm')) IN s, Var n IN k, Var m IN k, t EQ Var sl, u EQ Var sl', HPair k (HPair (Var sl) (Var sl')) IN s, All2 l k (SyntaxN.Ex sl (SyntaxN.Ex sl' (HPair (Var l) (HPair (Var sl) (Var sl')) IN s AND ((Var sl EQ v AND Var sl' EQ i OR (IndP (Var sl) OR Var sl NEQ v) AND Var sl' EQ Var sl) OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN Var l AND Var n IN Var l AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND Var sl EQ Q_Eats (Var sm) (Var sn) AND Var sl' EQ Q_Eats (Var sm') (Var sn'))))))))))), LstSeqP s k (HPair t u), VarP v} ⊢ VarP v› 2. ‹⟦atom l ♯ (v, i, t, u, s, k, sl, sl', m, n, sm, sm', sn, sn'); atom sl ♯ (v, i, t, u, s, k, sl', m, n, sm, sm', sn, sn'); atom sl' ♯ (v, i, t, u, s, k, m, n, sm, sm', sn, sn'); atom m ♯ (v, i, t, u, s, k, n, sm, sm', sn, sn'); atom n ♯ (v, i, t, u, s, k, sm, sm', sn, sn'); atom sm ♯ (v, i, t, u, s, k, sm', sn, sn'); atom sm' ♯ (v, i, t, u, s, k, sn, sn'); atom sn ♯ (v, i, t, u, s, k, sn'); atom sn' ♯ (v, i, t, u, s, k)⟧ ⟹ {Var sl EQ Q_Eats (Var sm) (Var sn), Var sl' EQ Q_Eats (Var sm') (Var sn'), HPair (Var n) (HPair (Var sn) (Var sn')) IN s, HPair (Var m) (HPair (Var sm) (Var sm')) IN s, Var n IN k, Var m IN k, t EQ Var sl, u EQ Var sl', HPair k (HPair (Var sl) (Var sl')) IN s, All2 l k (SyntaxN.Ex sl (SyntaxN.Ex sl' (HPair (Var l) (HPair (Var sl) (Var sl')) IN s AND ((Var sl EQ v AND Var sl' EQ i OR (IndP (Var sl) OR Var sl NEQ v) AND Var sl' EQ Var sl) OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN Var l AND Var n IN Var l AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND Var sl EQ Q_Eats (Var sm) (Var sn) AND Var sl' EQ Q_Eats (Var sm') (Var sn'))))))))))), LstSeqP s k (HPair t u), VarP v} ⊢ LstSeqP s (Var n) (HPair (Var sn) (Var sn')) AND All2 l (SUCC (Var n)) (SyntaxN.Ex sl (SyntaxN.Ex sl' (HPair (Var l) (HPair (Var sl) (Var sl')) IN s AND ((Var sl EQ v AND Var sl' EQ i OR (IndP (Var sl) OR Var sl NEQ v) AND Var sl' EQ Var sl) OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN Var l AND Var n IN Var l AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND Var sl EQ Q_Eats (Var sm) (Var sn) AND Var sl' EQ Q_Eats (Var sm') (Var sn')))))))))))› discuss goal 1*) apply (blast intro: LstSeqP_Mem (*‹⟦?H ⊢ LstSeqP ?r ?k ?y; ?H ⊢ HPair ?k' ?z IN ?r; ?H ⊢ ?k' IN ?k⟧ ⟹ ?H ⊢ LstSeqP ?r ?k' ?z›*)) (*discuss goal 2*) apply (rule Conj_I (*‹⟦?H ⊢ ?A; ?H ⊢ ?B⟧ ⟹ ?H ⊢ ?A AND ?B›*)) (*goals: 1. ‹⟦atom l ♯ (v, i, t, u, s, k, sl, sl', m, n, sm, sm', sn, sn'); atom sl ♯ (v, i, t, u, s, k, sl', m, n, sm, sm', sn, sn'); atom sl' ♯ (v, i, t, u, s, k, m, n, sm, sm', sn, sn'); atom m ♯ (v, i, t, u, s, k, n, sm, sm', sn, sn'); atom n ♯ (v, i, t, u, s, k, sm, sm', sn, sn'); atom sm ♯ (v, i, t, u, s, k, sm', sn, sn'); atom sm' ♯ (v, i, t, u, s, k, sn, sn'); atom sn ♯ (v, i, t, u, s, k, sn'); atom sn' ♯ (v, i, t, u, s, k)⟧ ⟹ {Var sl EQ Q_Eats (Var sm) (Var sn), Var sl' EQ Q_Eats (Var sm') (Var sn'), HPair (Var n) (HPair (Var sn) (Var sn')) IN s, HPair (Var m) (HPair (Var sm) (Var sm')) IN s, Var n IN k, Var m IN k, t EQ Var sl, u EQ Var sl', HPair k (HPair (Var sl) (Var sl')) IN s, All2 l k (SyntaxN.Ex sl (SyntaxN.Ex sl' (HPair (Var l) (HPair (Var sl) (Var sl')) IN s AND ((Var sl EQ v AND Var sl' EQ i OR (IndP (Var sl) OR Var sl NEQ v) AND Var sl' EQ Var sl) OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN Var l AND Var n IN Var l AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND Var sl EQ Q_Eats (Var sm) (Var sn) AND Var sl' EQ Q_Eats (Var sm') (Var sn'))))))))))), LstSeqP s k (HPair t u), VarP v} ⊢ LstSeqP s (Var n) (HPair (Var sn) (Var sn'))› 2. ‹⟦atom l ♯ (v, i, t, u, s, k, sl, sl', m, n, sm, sm', sn, sn'); atom sl ♯ (v, i, t, u, s, k, sl', m, n, sm, sm', sn, sn'); atom sl' ♯ (v, i, t, u, s, k, m, n, sm, sm', sn, sn'); atom m ♯ (v, i, t, u, s, k, n, sm, sm', sn, sn'); atom n ♯ (v, i, t, u, s, k, sm, sm', sn, sn'); atom sm ♯ (v, i, t, u, s, k, sm', sn, sn'); atom sm' ♯ (v, i, t, u, s, k, sn, sn'); atom sn ♯ (v, i, t, u, s, k, sn'); atom sn' ♯ (v, i, t, u, s, k)⟧ ⟹ {Var sl EQ Q_Eats (Var sm) (Var sn), Var sl' EQ Q_Eats (Var sm') (Var sn'), HPair (Var n) (HPair (Var sn) (Var sn')) IN s, HPair (Var m) (HPair (Var sm) (Var sm')) IN s, Var n IN k, Var m IN k, t EQ Var sl, u EQ Var sl', HPair k (HPair (Var sl) (Var sl')) IN s, All2 l k (SyntaxN.Ex sl (SyntaxN.Ex sl' (HPair (Var l) (HPair (Var sl) (Var sl')) IN s AND ((Var sl EQ v AND Var sl' EQ i OR (IndP (Var sl) OR Var sl NEQ v) AND Var sl' EQ Var sl) OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN Var l AND Var n IN Var l AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND Var sl EQ Q_Eats (Var sm) (Var sn) AND Var sl' EQ Q_Eats (Var sm') (Var sn'))))))))))), LstSeqP s k (HPair t u), VarP v} ⊢ All2 l (SUCC (Var n)) (SyntaxN.Ex sl (SyntaxN.Ex sl' (HPair (Var l) (HPair (Var sl) (Var sl')) IN s AND ((Var sl EQ v AND Var sl' EQ i OR (IndP (Var sl) OR Var sl NEQ v) AND Var sl' EQ Var sl) OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN Var l AND Var n IN Var l AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND Var sl EQ Q_Eats (Var sm) (Var sn) AND Var sl' EQ Q_Eats (Var sm') (Var sn')))))))))))› discuss goal 1*) apply (blast intro: LstSeqP_Mem (*‹⟦?H ⊢ LstSeqP ?r ?k ?y; ?H ⊢ HPair ?k' ?z IN ?r; ?H ⊢ ?k' IN ?k⟧ ⟹ ?H ⊢ LstSeqP ?r ?k' ?z›*)) (*discuss goal 2*) apply (rule All2_Subset [OF Hyp] (*‹⟦All2 ?l ?k ?P ∈ ?H; ?H ⊢ ?k' SUBS ?k; {?P} ⊢ ?P'; atom ?l ♯ (?k', ?k)⟧ ⟹ ?H ⊢ All2 ?l ?k' ?P'›*)) (*goals: 1. ‹⟦atom (l::name) ♯ (v::tm, i::tm, t::tm, u::tm, s::tm, k::tm, sl::name, sl'::name, m::name, n::name, sm::name, sm'::name, sn::name, sn'::name); atom sl ♯ (v, i, t, u, s, k, sl', m, n, sm, sm', sn, sn'); atom sl' ♯ (v, i, t, u, s, k, m, n, sm, sm', sn, sn'); atom m ♯ (v, i, t, u, s, k, n, sm, sm', sn, sn'); atom n ♯ (v, i, t, u, s, k, sm, sm', sn, sn'); atom sm ♯ (v, i, t, u, s, k, sm', sn, sn'); atom sm' ♯ (v, i, t, u, s, k, sn, sn'); atom sn ♯ (v, i, t, u, s, k, sn'); atom sn' ♯ (v, i, t, u, s, k)⟧ ⟹ All2 l (?k211::tm) (?P211::fm) ∈ {Var sl EQ Q_Eats (Var sm) (Var sn), Var sl' EQ Q_Eats (Var sm') (Var sn'), HPair (Var n) (HPair (Var sn) (Var sn')) IN s, HPair (Var m) (HPair (Var sm) (Var sm')) IN s, Var n IN k, Var m IN k, t EQ Var sl, u EQ Var sl', HPair k (HPair (Var sl) (Var sl')) IN s, All2 l k (SyntaxN.Ex sl (SyntaxN.Ex sl' (HPair (Var l) (HPair (Var sl) (Var sl')) IN s AND ((Var sl EQ v AND Var sl' EQ i OR (IndP (Var sl) OR Var sl NEQ v) AND Var sl' EQ Var sl) OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN Var l AND Var n IN Var l AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND Var sl EQ Q_Eats (Var sm) (Var sn) AND Var sl' EQ Q_Eats (Var sm') (Var sn'))))))))))), LstSeqP s k (HPair t u), VarP v}› 2. ‹⟦atom (l::name) ♯ (v::tm, i::tm, t::tm, u::tm, s::tm, k::tm, sl::name, sl'::name, m::name, n::name, sm::name, sm'::name, sn::name, sn'::name); atom sl ♯ (v, i, t, u, s, k, sl', m, n, sm, sm', sn, sn'); atom sl' ♯ (v, i, t, u, s, k, m, n, sm, sm', sn, sn'); atom m ♯ (v, i, t, u, s, k, n, sm, sm', sn, sn'); atom n ♯ (v, i, t, u, s, k, sm, sm', sn, sn'); atom sm ♯ (v, i, t, u, s, k, sm', sn, sn'); atom sm' ♯ (v, i, t, u, s, k, sn, sn'); atom sn ♯ (v, i, t, u, s, k, sn'); atom sn' ♯ (v, i, t, u, s, k)⟧ ⟹ {Var sl EQ Q_Eats (Var sm) (Var sn), Var sl' EQ Q_Eats (Var sm') (Var sn'), HPair (Var n) (HPair (Var sn) (Var sn')) IN s, HPair (Var m) (HPair (Var sm) (Var sm')) IN s, Var n IN k, Var m IN k, t EQ Var sl, u EQ Var sl', HPair k (HPair (Var sl) (Var sl')) IN s, All2 l k (SyntaxN.Ex sl (SyntaxN.Ex sl' (HPair (Var l) (HPair (Var sl) (Var sl')) IN s AND ((Var sl EQ v AND Var sl' EQ i OR (IndP (Var sl) OR Var sl NEQ v) AND Var sl' EQ Var sl) OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN Var l AND Var n IN Var l AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND Var sl EQ Q_Eats (Var sm) (Var sn) AND Var sl' EQ Q_Eats (Var sm') (Var sn'))))))))))), LstSeqP s k (HPair t u), VarP v} ⊢ SUCC (Var n) SUBS (?k211::tm)› 3. ‹⟦atom (l::name) ♯ (v::tm, i::tm, t::tm, u::tm, s::tm, k::tm, sl::name, sl'::name, m::name, n::name, sm::name, sm'::name, sn::name, sn'::name); atom sl ♯ (v, i, t, u, s, k, sl', m, n, sm, sm', sn, sn'); atom sl' ♯ (v, i, t, u, s, k, m, n, sm, sm', sn, sn'); atom m ♯ (v, i, t, u, s, k, n, sm, sm', sn, sn'); atom n ♯ (v, i, t, u, s, k, sm, sm', sn, sn'); atom sm ♯ (v, i, t, u, s, k, sm', sn, sn'); atom sm' ♯ (v, i, t, u, s, k, sn, sn'); atom sn ♯ (v, i, t, u, s, k, sn'); atom sn' ♯ (v, i, t, u, s, k)⟧ ⟹ {?P211::fm} ⊢ SyntaxN.Ex sl (SyntaxN.Ex sl' (HPair (Var l) (HPair (Var sl) (Var sl')) IN s AND ((Var sl EQ v AND Var sl' EQ i OR (IndP (Var sl) OR Var sl NEQ v) AND Var sl' EQ Var sl) OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN Var l AND Var n IN Var l AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND Var sl EQ Q_Eats (Var sm) (Var sn) AND Var sl' EQ Q_Eats (Var sm') (Var sn'))))))))))› 4. ‹⟦atom (l::name) ♯ (v::tm, i::tm, t::tm, u::tm, s::tm, k::tm, sl::name, sl'::name, m::name, n::name, sm::name, sm'::name, sn::name, sn'::name); atom sl ♯ (v, i, t, u, s, k, sl', m, n, sm, sm', sn, sn'); atom sl' ♯ (v, i, t, u, s, k, m, n, sm, sm', sn, sn'); atom m ♯ (v, i, t, u, s, k, n, sm, sm', sn, sn'); atom n ♯ (v, i, t, u, s, k, sm, sm', sn, sn'); atom sm ♯ (v, i, t, u, s, k, sm', sn, sn'); atom sm' ♯ (v, i, t, u, s, k, sn, sn'); atom sn ♯ (v, i, t, u, s, k, sn'); atom sn' ♯ (v, i, t, u, s, k)⟧ ⟹ atom l ♯ (SUCC (Var n), ?k211::tm)› discuss goal 1*) apply blast (*discuss goal 2*) apply (blast intro!: SUCC_Subset_Ord (*‹⟦?H ⊢ ?k' IN ?k; ?H ⊢ OrdP ?k⟧ ⟹ ?H ⊢ SUCC ?k' SUBS ?k›*) LstSeqP_OrdP (*‹?H ⊢ LstSeqP ?r ?k ?y ⟹ ?H ⊢ OrdP ?k›*)) (*discuss goal 3*) apply blast (*discuss goal 4*) apply simp (*proven 4 subgoals*) (*proven 2 subgoals*) (*proven 2 subgoals*) (*discuss goal 2*) apply (blast intro: Trans (*‹⟦?H ⊢ ?x EQ ?y; ?H ⊢ ?y EQ ?z⟧ ⟹ ?H ⊢ ?x EQ ?z›*)) (*proven 2 subgoals*) (*proven 2 subgoals*) (*proven 2 subgoals*) (*proven 2 subgoals*) (*discuss goal 2*) apply simp (*discuss goal 3*) apply simp (*proven 3 subgoals*) (*discuss goal 2*) apply simp (*discuss goal 3*) apply simp (*proven 3 subgoals*) (*discuss goal 2*) apply simp (*discuss goal 3*) apply simp (*proven 3 subgoals*) (*discuss goal 2*) apply simp (*discuss goal 3*) apply simp (*proven 3 subgoals*) (*discuss goal 2*) apply simp (*discuss goal 3*) apply simp (*proven 3 subgoals*) (*discuss goal 2*) apply simp (*discuss goal 3*) apply simp (*proven 3 subgoals*) (*proven 2 subgoals*) (*proven 2 subgoals*) (*discuss goal 2*) apply simp (*discuss goal 3*) apply simp (*proven 3 subgoals*) (*discuss goal 2*) apply simp (*discuss goal 3*) apply simp (*proven 3 subgoals*) (*proven 2 subgoals*) . qed lemma SeqStTermP_unique: "{SeqStTermP v a t u s kk, SeqStTermP v a t u' s' kk'} ⊢ u' EQ u" proof - obtain i::name and j::name and j'::name and k::name and k'::name and l::name and m::name and n::name and sm::name and sn::name and sm'::name and sn'::name and m2::name and n2::name and sm2::name and sn2::name and sm2'::name and sn2'::name where atoms: "atom i ♯ (s,s',v,a,t,u,u')" "atom j ♯ (s,s',v,a,t,i,t,u,u')" "atom j' ♯ (s,s',v,a,t,i,j,t,u,u')" "atom k ♯ (s,s',v,a,t,u,u',kk',i,j,j')" "atom k' ♯ (s,s',v,a,t,u,u',k,i,j,j')" "atom l ♯ (s,s',v,a,t,i,j,j',k,k')" "atom m ♯ (s,s',v,a,i,j,j',k,k',l)" "atom n ♯ (s,s',v,a,i,j,j',k,k',l,m)" "atom sm ♯ (s,s',v,a,i,j,j',k,k',l,m,n)" "atom sn ♯ (s,s',v,a,i,j,j',k,k',l,m,n,sm)" "atom sm' ♯ (s,s',v,a,i,j,j',k,k',l,m,n,sm,sn)" "atom sn' ♯ (s,s',v,a,i,j,j',k,k',l,m,n,sm,sn,sm')" "atom m2 ♯ (s,s',v,a,i,j,j',k,k',l,m,n,sm,sn,sm',sn')" "atom n2 ♯ (s,s',v,a,i,j,j',k,k',l,m,n,sm,sn,sm',sn',m2)" "atom sm2 ♯ (s,s',v,a,i,j,j',k,k',l,m,n,sm,sn,sm',sn',m2,n2)" "atom sn2 ♯ (s,s',v,a,i,j,j',k,k',l,m,n,sm,sn,sm',sn',m2,n2,sm2)" "atom sm2' ♯ (s,s',v,a,i,j,j',k,k',l,m,n,sm,sn,sm',sn',m2,n2,sm2,sn2)" "atom sn2' ♯ (s,s',v,a,i,j,j',k,k',l,m,n,sm,sn,sm',sn',m2,n2,sm2,sn2,sm2')" by (metis obtain_fresh) have "{ OrdP (Var k), VarP v } ⊢ All i (All j (All j' (All k' (SeqStTermP v a (Var i) (Var j) s (Var k) IMP (SeqStTermP v a (Var i) (Var j') s' (Var k') IMP Var j' EQ Var j)))))" apply (rule OrdIndH [where j=l]) using atoms apply auto apply (rule Swap) apply (rule cut_same) apply (rule cut1 [OF SeqStTermP_lemma [of m v a "Var i" "Var j" s "Var k" n sm sm' sn sn']], simp_all, blast) apply (rule cut_same) apply (rule cut1 [OF SeqStTermP_lemma [of m2 v a "Var i" "Var j'" s' "Var k'" n2 sm2 sm2' sn2 sn2']], simp_all, blast) apply (rule Disj_EH Conj_EH)+ ― ‹case 1, both sides equal "v"› apply (blast intro: Trans Sym) ― ‹case 2, @{term "Var i EQ v"} and also @{term "IndP (Var i) OR Var i NEQ v"}› apply (rule Conj_EH Disj_EH)+ apply (blast intro: IndP_cong [THEN Iff_MP_same] not_IndP_VarP [THEN cut2]) apply (metis Assume OrdNotEqP_E) ― ‹case 3, both a variable and a pair› apply (rule Ex_EH Conj_EH)+ apply simp_all apply (rule cut_same [where A = "VarP (Q_Eats (Var sm) (Var sn))"]) apply (blast intro: Trans Sym VarP_cong [where x=v, THEN Iff_MP_same] Hyp, blast) ― ‹towards remaining cases› apply (rule Disj_EH Ex_EH)+ ― ‹case 4, @{term "Var i EQ v"} and also @{term "IndP (Var i) OR Var i NEQ v"}› apply (blast intro: IndP_cong [THEN Iff_MP_same] not_IndP_VarP [THEN cut2] OrdNotEqP_E) ― ‹case 5, @{term "Var i EQ v"} for both› apply (blast intro: Trans Sym) ― ‹case 6, both an atom and a pair› apply (rule Ex_EH Conj_EH)+ apply simp_all apply (rule atom_HPairE) apply (simp add: HTuple.simps) apply (blast intro: Trans) ― ‹towards remaining cases› apply (rule Conj_EH Disj_EH Ex_EH)+ apply simp_all ― ‹case 7, both an atom and a pair› apply (rule cut_same [where A = "VarP (Q_Eats (Var sm2) (Var sn2))"]) apply (blast intro: Trans Sym VarP_cong [where x=v, THEN Iff_MP_same] Hyp, blast) ― ‹case 8, both an atom and a pair› apply (rule Ex_EH Conj_EH)+ apply simp_all apply (rule atom_HPairE) apply (simp add: HTuple.simps) apply (blast intro: Trans) ― ‹case 9, two Eats terms› apply (rule Ex_EH Disj_EH Conj_EH)+ apply simp_all apply (rule All_E' [OF Hyp, where x="Var m"], blast) apply (rule All_E' [OF Hyp, where x="Var n"], blast, simp) apply (rule Disj_EH, blast intro: thin1 ContraProve)+ apply (rule All_E [where x="Var sm"], simp) apply (rule All_E [where x="Var sm'"], simp) apply (rule All_E [where x="Var sm2'"], simp) apply (rule All_E [where x="Var m2"], simp) apply (rule All_E [where x="Var sn", THEN rotate2], simp) apply (rule All_E [where x="Var sn'"], simp) apply (rule All_E [where x="Var sn2'"], simp) apply (rule All_E [where x="Var n2"], simp) apply (rule cut_same [where A = "Q_Eats (Var sm) (Var sn) EQ Q_Eats (Var sm2) (Var sn2)"]) apply (blast intro: Sym Trans, clarify) apply (rule cut_same [where A = "SeqStTermP v a (Var sn) (Var sn2') s' (Var n2)"]) apply (blast intro: Hyp SeqStTermP_cong [OF Hyp Refl Refl, THEN Iff_MP2_same]) apply (rule cut_same [where A = "SeqStTermP v a (Var sm) (Var sm2') s' (Var m2)"]) apply (blast intro: Hyp SeqStTermP_cong [OF Hyp Refl Refl, THEN Iff_MP2_same]) apply (rule Disj_EH, blast intro: thin1 ContraProve)+ apply (blast intro: HPair_cong Trans [OF Hyp Sym]) done hence p1: "{OrdP (Var k), VarP v} ⊢ (All j (All j' (All k' (SeqStTermP v a (Var i) (Var j) s (Var k) IMP (SeqStTermP v a (Var i) (Var j') s' (Var k') IMP Var j' EQ Var j)))))(i::=t)" by (metis All_D) have p2: "{OrdP (Var k), VarP v} ⊢ (All j' (All k' (SeqStTermP v a t (Var j) s (Var k) IMP (SeqStTermP v a t (Var j') s' (Var k') IMP Var j' EQ Var j))))(j::=u)" apply (rule All_D) using atoms p1 by simp have p3: "{OrdP (Var k), VarP v} ⊢ (All k' (SeqStTermP v a t u s (Var k) IMP (SeqStTermP v a t (Var j') s' (Var k') IMP Var j' EQ u)))(j'::=u')" apply (rule All_D) using atoms p2 by simp have p4: "{OrdP (Var k), VarP v} ⊢ (SeqStTermP v a t u s (Var k) IMP (SeqStTermP v a t u' s' (Var k') IMP u' EQ u))(k'::=kk')" apply (rule All_D) using atoms p3 by simp hence "{SeqStTermP v a t u s (Var k), VarP v} ⊢ SeqStTermP v a t u s (Var k) IMP (SeqStTermP v a t u' s' kk' IMP u' EQ u)" using atoms apply simp by (metis SeqStTermP_imp_OrdP rcut1) hence "{VarP v} ⊢ ((SeqStTermP v a t u s (Var k) IMP (SeqStTermP v a t u' s' kk' IMP u' EQ u)))" by (metis Assume MP_same Imp_I) hence "{VarP v} ⊢ ((SeqStTermP v a t u s (Var k) IMP (SeqStTermP v a t u' s' kk' IMP u' EQ u)))(k::=kk)" using atoms by (force intro!: Subst) hence "{VarP v} ⊢ SeqStTermP v a t u s kk IMP (SeqStTermP v a t u' s' kk' IMP u' EQ u)" using atoms by simp hence "{SeqStTermP v a t u s kk} ⊢ SeqStTermP v a t u s kk IMP (SeqStTermP v a t u' s' kk' IMP u' EQ u)" by (metis SeqStTermP_imp_VarP rcut1) thus ?thesis by (metis Assume AssumeH(2) MP_same rcut1) qed theorem SubstTermP_unique: "{SubstTermP v tm t u, SubstTermP v tm t u'} ⊢ u' EQ u" proof (-) (*goal: ‹{SubstTermP v tm t u, SubstTermP v tm t u'} ⊢ u' EQ u›*) obtain s :: name and s' :: name and k :: name and k' :: name where "atom s ♯ (v,tm,t,u,u',k,k')" "atom s' ♯ (v,tm,t,u,u',k,k',s)" "atom k ♯ (v,tm,t,u,u')" "atom k' ♯ (v,tm,t,u,u',k)" (*goal: ‹(⋀s k k' s'. ⟦atom s ♯ (v, tm, t, u, u', k, k'); atom s' ♯ (v, tm, t, u, u', k, k', s); atom k ♯ (v, tm, t, u, u'); atom k' ♯ (v, tm, t, u, u', k)⟧ ⟹ thesis) ⟹ thesis›*) by (metis obtain_fresh (*‹(⋀a. atom a ♯ ?x ⟹ ?thesis) ⟹ ?thesis›*)) thus "?thesis" (*goal: ‹{SubstTermP (v::tm) (tm::tm) (t::tm) (u::tm), SubstTermP v tm t (u'::tm)} ⊢ u' EQ u›*) apply (auto simp: SubstTermP.simps [of s v tm t u k] (*‹⟦atom s ♯ (v, tm, t, u, k); atom k ♯ (v, tm, t, u)⟧ ⟹ SubstTermP v tm t u = TermP tm AND SyntaxN.Ex s (SyntaxN.Ex k (SeqStTermP v tm t u (Var s) (Var k)))›*) SubstTermP.simps [of s' v tm t u' k'] (*‹⟦atom s' ♯ (v, tm, t, u', k'); atom k' ♯ (v, tm, t, u')⟧ ⟹ SubstTermP v tm t u' = TermP tm AND SyntaxN.Ex s' (SyntaxN.Ex k' (SeqStTermP v tm t u' (Var s') (Var k')))›*)) (*goal: ‹{SubstTermP v tm t u, SubstTermP v tm t u'} ⊢ u' EQ u›*) by (metis SeqStTermP_unique (*‹{SeqStTermP ?v ?a ?t ?u ?s ?kk, SeqStTermP ?v ?a ?t ?u' ?s' ?kk'} ⊢ ?u' EQ ?u›*) rotate3 (*‹insert ?A3.0 (insert ?A1.0 (insert ?A2.0 ?H)) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 ?H)) ⊢ ?B›*) thin1 (*‹?H ⊢ ?B ⟹ insert ?A ?H ⊢ ?B›*)) qed subsection‹@{term SubstAtomicP}› lemma SubstTermP_eq: "⟦H ⊢ SubstTermP v tm x z; insert (SubstTermP v tm y z) H ⊢ A⟧ ⟹ insert (x EQ y) H ⊢ A" by (metis Assume (*‹insert ?A ?H ⊢ ?A›*) rotate2 (*‹insert ?A2.0 (insert ?A1.0 ?H) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 ?H) ⊢ ?B›*) Iff_E1 (*‹⟦?H ⊢ ?A; insert ?B ?H ⊢ ?C⟧ ⟹ insert (?A IFF ?B) ?H ⊢ ?C›*) cut_same (*‹⟦?H ⊢ ?A; insert ?A ?H ⊢ ?B⟧ ⟹ ?H ⊢ ?B›*) thin1 (*‹?H ⊢ ?B ⟹ insert ?A ?H ⊢ ?B›*) SubstTermP_cong [OF Refl Refl _ Refl] (*‹?H ⊢ ?t EQ ?t' ⟹ ?H ⊢ SubstTermP ?v ?i ?t ?u IFF SubstTermP ?v ?i ?t' ?u›*)) lemma SubstAtomicP_unique: "{SubstAtomicP v tm x y, SubstAtomicP v tm x y'} ⊢ y' EQ y" proof (-) (*goal: ‹{SubstAtomicP v tm x y, SubstAtomicP v tm x y'} ⊢ y' EQ y›*) obtain t :: name and ts :: name and u :: name and us :: name and t' :: name and ts' :: name and u' :: name and us' :: name where "atom t ♯ (v,tm,x,y,y',ts,u,us)" "atom ts ♯ (v,tm,x,y,y',u,us)" "atom u ♯ (v,tm,x,y,y',us)" "atom us ♯ (v,tm,x,y,y')" "atom t' ♯ (v,tm,x,y,y',t,ts,u,us,ts',u',us')" "atom ts' ♯ (v,tm,x,y,y',t,ts,u,us,u',us')" "atom u' ♯ (v,tm,x,y,y',t,ts,u,us,us')" "atom us' ♯ (v,tm,x,y,y',t,ts,u,us)" (*goal: ‹(⋀t ts u us t' ts' u' us'. ⟦atom t ♯ (v, tm, x, y, y', ts, u, us); atom ts ♯ (v, tm, x, y, y', u, us); atom u ♯ (v, tm, x, y, y', us); atom us ♯ (v, tm, x, y, y'); atom t' ♯ (v, tm, x, y, y', t, ts, u, us, ts', u', us'); atom ts' ♯ (v, tm, x, y, y', t, ts, u, us, u', us'); atom u' ♯ (v, tm, x, y, y', t, ts, u, us, us'); atom us' ♯ (v, tm, x, y, y', t, ts, u, us)⟧ ⟹ thesis) ⟹ thesis›*) by (metis obtain_fresh (*‹(⋀a. atom a ♯ ?x ⟹ ?thesis) ⟹ ?thesis›*)) thus "?thesis" (*goal: ‹{SubstAtomicP v tm x y, SubstAtomicP v tm x y'} ⊢ y' EQ y›*) apply (simp add: SubstAtomicP.simps [of t v tm x y ts u us] (*‹⟦atom t ♯ (v, tm, x, y, ts, u, us); atom ts ♯ (v, tm, x, y, u, us); atom u ♯ (v, tm, x, y, us); atom us ♯ (v, tm, x, y)⟧ ⟹ SubstAtomicP v tm x y = SyntaxN.Ex t (SyntaxN.Ex u (SyntaxN.Ex ts (SyntaxN.Ex us (SubstTermP v tm (Var t) (Var ts) AND SubstTermP v tm (Var u) (Var us) AND (x EQ Q_Eq (Var t) (Var u) AND y EQ Q_Eq (Var ts) (Var us) OR x EQ Q_Mem (Var t) (Var u) AND y EQ Q_Mem (Var ts) (Var us))))))›*) SubstAtomicP.simps [of t' v tm x y' ts' u' us'] (*‹⟦atom t' ♯ (v, tm, x, y', ts', u', us'); atom ts' ♯ (v, tm, x, y', u', us'); atom u' ♯ (v, tm, x, y', us'); atom us' ♯ (v, tm, x, y')⟧ ⟹ SubstAtomicP v tm x y' = SyntaxN.Ex t' (SyntaxN.Ex u' (SyntaxN.Ex ts' (SyntaxN.Ex us' (SubstTermP v tm (Var t') (Var ts') AND SubstTermP v tm (Var u') (Var us') AND (x EQ Q_Eq (Var t') (Var u') AND y' EQ Q_Eq (Var ts') (Var us') OR x EQ Q_Mem (Var t') (Var u') AND y' EQ Q_Mem (Var ts') (Var us'))))))›*)) (*goal: ‹{SubstAtomicP v tm x y, SubstAtomicP v tm x y'} ⊢ y' EQ y›*) apply ((rule Ex_EH (*‹⟦insert ?A ?H ⊢ ?B; atom ?i ♯ ?B; ∀C∈?H. atom ?i ♯ C⟧ ⟹ insert (SyntaxN.Ex ?i ?A) ?H ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 ?H) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 ?H. atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert (SyntaxN.Ex ?i ?A) ?H) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 ?H)) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 ?H). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert (SyntaxN.Ex ?i ?A) ?H)) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 ?H))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 ?H)). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert (SyntaxN.Ex ?i ?A) ?H))) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 ?H)))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 ?H))). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert (SyntaxN.Ex ?i ?A) ?H)))) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 ?H))))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 ?H)))). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert (SyntaxN.Ex ?i ?A) ?H))))) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 ?H)))))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 ?H))))). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert (SyntaxN.Ex ?i ?A) ?H)))))) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 ?H))))))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 ?H)))))). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 (insert (SyntaxN.Ex ?i ?A) ?H))))))) ⊢ ?B› ‹⟦insert ?A (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)))))))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈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))))))). atom ?i ♯ C⟧ ⟹ 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 (SyntaxN.Ex ?i ?A) ?H)))))))) ⊢ ?B› ‹⟦insert ?A (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))))))))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈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)))))))). atom ?i ♯ C⟧ ⟹ 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 (SyntaxN.Ex ?i ?A) ?H))))))))) ⊢ ?B›*) Disj_EH (*‹⟦insert ?A ?H ⊢ ?C; insert ?B ?H ⊢ ?C⟧ ⟹ insert (?A OR ?B) ?H ⊢ ?C› ‹⟦insert ?A (insert ?A1.0 ?H) ⊢ ?B; insert ?Ba (insert ?A1.0 ?H) ⊢ ?B⟧ ⟹ insert ?A1.0 (insert (?A OR ?Ba) ?H) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 ?H)) ⊢ ?B; insert ?Ba (insert ?A1.0 (insert ?A2.0 ?H)) ⊢ ?B⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert (?A OR ?Ba) ?H)) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 ?H))) ⊢ ?B; insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 ?H))) ⊢ ?B⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert (?A OR ?Ba) ?H))) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 ?H)))) ⊢ ?B; insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 ?H)))) ⊢ ?B⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert (?A OR ?Ba) ?H)))) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 ?H))))) ⊢ ?B; insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 ?H))))) ⊢ ?B⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert (?A OR ?Ba) ?H))))) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 ?H)))))) ⊢ ?B; insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 ?H)))))) ⊢ ?B⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert (?A OR ?Ba) ?H)))))) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 ?H))))))) ⊢ ?B; insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 ?H))))))) ⊢ ?B⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 (insert (?A OR ?Ba) ?H))))))) ⊢ ?B› ‹⟦insert ?A (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)))))))) ⊢ ?B; insert ?Ba (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)))))))) ⊢ ?B⟧ ⟹ 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 (?A OR ?Ba) ?H)))))))) ⊢ ?B› ‹⟦insert ?A (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))))))))) ⊢ ?B; insert ?Ba (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))))))))) ⊢ ?B⟧ ⟹ 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 (?A OR ?Ba) ?H))))))))) ⊢ ?B›*) Conj_EH (*‹insert ?A (insert ?B ?H) ⊢ ?C ⟹ insert (?A AND ?B) ?H ⊢ ?C› ‹insert ?A (insert ?Ba (insert ?A1.0 ?H)) ⊢ ?B ⟹ insert ?A1.0 (insert (?A AND ?Ba) ?H) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 ?H))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert (?A AND ?Ba) ?H)) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 ?H)))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert (?A AND ?Ba) ?H))) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 ?H))))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert (?A AND ?Ba) ?H)))) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 ?H)))))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert (?A AND ?Ba) ?H))))) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 ?H))))))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert (?A AND ?Ba) ?H)))))) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 ?H)))))))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 (insert (?A AND ?Ba) ?H))))))) ⊢ ?B› ‹insert ?A (insert ?Ba (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))))))))) ⊢ ?B ⟹ 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 (?A AND ?Ba) ?H)))))))) ⊢ ?B› ‹insert ?A (insert ?Ba (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)))))))))) ⊢ ?B ⟹ 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 (?A AND ?Ba) ?H))))))))) ⊢ ?B›*))+) (*goal: ‹⟦atom t ♯ (v, tm, x, y, y', ts, u, us); atom ts ♯ (v, tm, x, y, y', u, us); atom u ♯ (v, tm, x, y, y', us); atom us ♯ (v, tm, x, y, y'); atom t' ♯ (v, tm, x, y, y', t, ts, u, us, ts', u', us'); atom ts' ♯ (v, tm, x, y, y', t, ts, u, us, u', us'); atom u' ♯ (v, tm, x, y, y', t, ts, u, us, us'); atom us' ♯ (v, tm, x, y, y', t, ts, u, us)⟧ ⟹ {SyntaxN.Ex t (SyntaxN.Ex u (SyntaxN.Ex ts (SyntaxN.Ex us (SubstTermP v tm (Var t) (Var ts) AND SubstTermP v tm (Var u) (Var us) AND (x EQ Q_Eq (Var t) (Var u) AND y EQ Q_Eq (Var ts) (Var us) OR x EQ Q_Mem (Var t) (Var u) AND y EQ Q_Mem (Var ts) (Var us)))))), SyntaxN.Ex t' (SyntaxN.Ex u' (SyntaxN.Ex ts' (SyntaxN.Ex us' (SubstTermP v tm (Var t') (Var ts') AND SubstTermP v tm (Var u') (Var us') AND (x EQ Q_Eq (Var t') (Var u') AND y' EQ Q_Eq (Var ts') (Var us') OR x EQ Q_Mem (Var t') (Var u') AND y' EQ Q_Mem (Var ts') (Var us'))))))} ⊢ y' EQ y›*) apply simp_all (*top goal: ‹⟦atom t ♯ (v, tm, x, y, y', ts, u, us); atom ts ♯ (v, tm, x, y, y', u, us); atom u ♯ (v, tm, x, y, y', us); atom us ♯ (v, tm, x, y, y'); atom t' ♯ (v, tm, x, y, y', t, ts, u, us, ts', u', us'); atom ts' ♯ (v, tm, x, y, y', t, ts, u, us, u', us'); atom u' ♯ (v, tm, x, y, y', t, ts, u, us, us'); atom us' ♯ (v, tm, x, y, y', t, ts, u, us)⟧ ⟹ {x EQ Q_Eq (Var t) (Var u), y EQ Q_Eq (Var ts) (Var us), SubstTermP v tm (Var u) (Var us), SubstTermP v tm (Var t) (Var ts), x EQ Q_Eq (Var t') (Var u'), y' EQ Q_Eq (Var ts') (Var us'), SubstTermP v tm (Var u') (Var us'), SubstTermP v tm (Var t') (Var ts')} ⊢ y' EQ y› and 18 goals remain*) apply (rule Eq_Trans_E [OF Hyp] (*‹⟦?x EQ ?u ∈ ?H; insert (?t EQ ?u) ?H ⊢ ?A⟧ ⟹ insert (?x EQ ?t) ?H ⊢ ?A›*), auto simp: HTS (*‹0 < ?n ⟹ HTuple ?n = HPair Zero (HTuple (?n - 1))› ‹HTuple 0 = HPair Zero Zero› ‹HTuple (Suc ?k) = HPair Zero (HTuple ?k)›*)) (*top goal: ‹⟦atom t ♯ (v, tm, x, y, y', ts, u, us); atom ts ♯ (v, tm, x, y, y', u, us); atom u ♯ (v, tm, x, y, y', us); atom us ♯ (v, tm, x, y, y'); atom t' ♯ (v, tm, x, y, y', t, ts, u, us, ts', u', us'); atom ts' ♯ (v, tm, x, y, y', t, ts, u, us, u', us'); atom u' ♯ (v, tm, x, y, y', t, ts, u, us, us'); atom us' ♯ (v, tm, x, y, y', t, ts, u, us)⟧ ⟹ {x EQ Q_Eq (Var t) (Var u), y EQ Q_Eq (Var ts) (Var us), SubstTermP v tm (Var u) (Var us), SubstTermP v tm (Var t) (Var ts), x EQ Q_Eq (Var t') (Var u'), y' EQ Q_Eq (Var ts') (Var us'), SubstTermP v tm (Var u') (Var us'), SubstTermP v tm (Var t') (Var ts')} ⊢ y' EQ y› and 2 goals remain*) apply (rule SubstTermP_eq [THEN thin1] (*‹⟦?H1 ⊢ SubstTermP ?v1 ?tm1 ?x1 ?z1; insert (SubstTermP ?v1 ?tm1 ?y1 ?z1) ?H1 ⊢ ?B⟧ ⟹ insert ?A (insert (?x1 EQ ?y1) ?H1) ⊢ ?B›*), blast) (*top goal: ‹⟦atom t ♯ (v, tm, x, y, y', ts, u, us); atom ts ♯ (v, tm, x, y, y', u, us); atom u ♯ (v, tm, x, y, y', us); atom us ♯ (v, tm, x, y, y'); atom t' ♯ (v, tm, x, y, y', t, ts, u, us, ts', u', us'); atom ts' ♯ (v, tm, x, y, y', t, ts, u, us, u', us'); atom u' ♯ (v, tm, x, y, y', t, ts, u, us, us'); atom us' ♯ (v, tm, x, y, y', t, ts, u, us)⟧ ⟹ {Zero EQ Zero, Var t EQ Var t', Var u EQ Var u', y EQ HPair (HPair Zero (HPair Zero (HPair Zero Zero))) (HPair (Var ts) (Var us)), SubstTermP v tm (Var u) (Var us), SubstTermP v tm (Var t) (Var ts), x EQ HPair (HPair Zero (HPair Zero (HPair Zero Zero))) (HPair (Var t') (Var u')), y' EQ HPair (HPair Zero (HPair Zero (HPair Zero Zero))) (HPair (Var ts') (Var us')), SubstTermP v tm (Var u') (Var us'), SubstTermP v tm (Var t') (Var ts')} ⊢ y' EQ y› and 3 goals remain*) apply (rule SubstTermP_eq [THEN rotate2] (*‹⟦insert ?A1.0 ?H ⊢ SubstTermP ?v1 ?tm1 ?x1 ?z1; insert (SubstTermP ?v1 ?tm1 ?y1 ?z1) (insert ?A1.0 ?H) ⊢ ?B⟧ ⟹ insert ?A1.0 (insert (?x1 EQ ?y1) ?H) ⊢ ?B›*), blast) (*top goal: ‹⟦atom t ♯ (v, tm, x, y, y', ts, u, us); atom ts ♯ (v, tm, x, y, y', u, us); atom u ♯ (v, tm, x, y, y', us); atom us ♯ (v, tm, x, y, y'); atom t' ♯ (v, tm, x, y, y', t, ts, u, us, ts', u', us'); atom ts' ♯ (v, tm, x, y, y', t, ts, u, us, u', us'); atom u' ♯ (v, tm, x, y, y', t, ts, u, us, us'); atom us' ♯ (v, tm, x, y, y', t, ts, u, us)⟧ ⟹ {SubstTermP v tm (Var t') (Var ts), Var u EQ Var u', y EQ HPair (HPair Zero (HPair Zero (HPair Zero Zero))) (HPair (Var ts) (Var us)), SubstTermP v tm (Var u) (Var us), SubstTermP v tm (Var t) (Var ts), x EQ HPair (HPair Zero (HPair Zero (HPair Zero Zero))) (HPair (Var t') (Var u')), y' EQ HPair (HPair Zero (HPair Zero (HPair Zero Zero))) (HPair (Var ts') (Var us')), SubstTermP v tm (Var u') (Var us'), SubstTermP v tm (Var t') (Var ts')} ⊢ y' EQ y› and 3 goals remain*) apply (rule Trans [OF Hyp Sym] (*‹⟦?x EQ ?y ∈ ?H; ?H ⊢ ?z EQ ?y⟧ ⟹ ?H ⊢ ?x EQ ?z›*), blast) (*top goal: ‹⟦atom t ♯ (v, tm, x, y, y', ts, u, us); atom ts ♯ (v, tm, x, y, y', u, us); atom u ♯ (v, tm, x, y, y', us); atom us ♯ (v, tm, x, y, y'); atom t' ♯ (v, tm, x, y, y', t, ts, u, us, ts', u', us'); atom ts' ♯ (v, tm, x, y, y', t, ts, u, us, u', us'); atom u' ♯ (v, tm, x, y, y', t, ts, u, us, us'); atom us' ♯ (v, tm, x, y, y', t, ts, u, us)⟧ ⟹ {SubstTermP v tm (Var u') (Var us), SubstTermP v tm (Var t') (Var ts), y EQ HPair (HPair Zero (HPair Zero (HPair Zero Zero))) (HPair (Var ts) (Var us)), SubstTermP v tm (Var u) (Var us), SubstTermP v tm (Var t) (Var ts), x EQ HPair (HPair Zero (HPair Zero (HPair Zero Zero))) (HPair (Var t') (Var u')), y' EQ HPair (HPair Zero (HPair Zero (HPair Zero Zero))) (HPair (Var ts') (Var us')), SubstTermP v tm (Var u') (Var us'), SubstTermP v tm (Var t') (Var ts')} ⊢ y' EQ y› and 3 goals remain*) apply (rule Trans [OF Hyp] (*‹⟦?x EQ ?y ∈ ?H; ?H ⊢ ?y EQ ?z⟧ ⟹ ?H ⊢ ?x EQ ?z›*), blast) (*top goal: ‹⟦atom t ♯ (v, tm, x, y, y', ts, u, us); atom ts ♯ (v, tm, x, y, y', u, us); atom u ♯ (v, tm, x, y, y', us); atom us ♯ (v, tm, x, y, y'); atom t' ♯ (v, tm, x, y, y', t, ts, u, us, ts', u', us'); atom ts' ♯ (v, tm, x, y, y', t, ts, u, us, u', us'); atom u' ♯ (v, tm, x, y, y', t, ts, u, us, us'); atom us' ♯ (v, tm, x, y, y', t, ts, u, us)⟧ ⟹ {SubstTermP v tm (Var u') (Var us), SubstTermP v tm (Var t') (Var ts), y EQ HPair (HPair Zero (HPair Zero (HPair Zero Zero))) (HPair (Var ts) (Var us)), SubstTermP v tm (Var u) (Var us), SubstTermP v tm (Var t) (Var ts), x EQ HPair (HPair Zero (HPair Zero (HPair Zero Zero))) (HPair (Var t') (Var u')), y' EQ HPair (HPair Zero (HPair Zero (HPair Zero Zero))) (HPair (Var ts') (Var us')), SubstTermP v tm (Var u') (Var us'), SubstTermP v tm (Var t') (Var ts')} ⊢ y EQ HPair (HPair Zero (HPair Zero (HPair Zero Zero))) (HPair (Var ts') (Var us'))› and 3 goals remain*) apply (metis Assume (*‹insert ?A ?H ⊢ ?A›*) AssumeH( (*‹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›*) 8) HPair_cong (*‹⟦?H ⊢ ?t EQ ?t'; ?H ⊢ ?u EQ ?u'⟧ ⟹ ?H ⊢ HPair ?t ?u EQ HPair ?t' ?u'›*) Refl (*‹?H ⊢ ?t EQ ?t›*) cut2 [OF SubstTermP_unique] (*‹⟦?H ⊢ SubstTermP ?v1 ?tm1 ?t1 ?u1; ?H ⊢ SubstTermP ?v1 ?tm1 ?t1 ?u'1⟧ ⟹ ?H ⊢ ?u'1 EQ ?u1›*) thin1 (*‹?H ⊢ ?B ⟹ insert ?A ?H ⊢ ?B›*)) (*top goal: ‹⟦atom t ♯ (v, tm, x, y, y', ts, u, us); atom ts ♯ (v, tm, x, y, y', u, us); atom u ♯ (v, tm, x, y, y', us); atom us ♯ (v, tm, x, y, y'); atom t' ♯ (v, tm, x, y, y', t, ts, u, us, ts', u', us'); atom ts' ♯ (v, tm, x, y, y', t, ts, u, us, u', us'); atom u' ♯ (v, tm, x, y, y', t, ts, u, us, us'); atom us' ♯ (v, tm, x, y, y', t, ts, u, us)⟧ ⟹ {SubstTermP v tm (Var u') (Var us), SubstTermP v tm (Var t') (Var ts), y EQ HPair (HPair Zero (HPair Zero (HPair Zero Zero))) (HPair (Var ts) (Var us)), SubstTermP v tm (Var u) (Var us), SubstTermP v tm (Var t) (Var ts), x EQ HPair (HPair Zero (HPair Zero (HPair Zero Zero))) (HPair (Var t') (Var u')), y' EQ HPair (HPair Zero (HPair Zero (HPair Zero Zero))) (HPair (Var ts') (Var us')), SubstTermP v tm (Var u') (Var us'), SubstTermP v tm (Var t') (Var ts')} ⊢ HPair (HPair Zero (HPair Zero (HPair Zero Zero))) (HPair (Var ts) (Var us)) EQ HPair (HPair Zero (HPair Zero (HPair Zero Zero))) (HPair (Var ts') (Var us'))› and 3 goals remain*) apply (rule Eq_Trans_E [OF Hyp] (*‹⟦(?x::tm) EQ (?u::tm) ∈ (?H::fm set); insert ((?t::tm) EQ ?u) ?H ⊢ (?A::fm)⟧ ⟹ insert (?x EQ ?t) ?H ⊢ ?A›*), blast, force simp add: HTS (*‹0 < ?n ⟹ HTuple ?n = HPair Zero (HTuple (?n - 1))› ‹HTuple 0 = HPair Zero Zero› ‹HTuple (Suc ?k) = HPair Zero (HTuple ?k)›*)) (*top goal: ‹⟦atom t ♯ (v, tm, x, y, y', ts, u, us); atom ts ♯ (v, tm, x, y, y', u, us); atom u ♯ (v, tm, x, y, y', us); atom us ♯ (v, tm, x, y, y'); atom t' ♯ (v, tm, x, y, y', t, ts, u, us, ts', u', us'); atom ts' ♯ (v, tm, x, y, y', t, ts, u, us, u', us'); atom u' ♯ (v, tm, x, y, y', t, ts, u, us, us'); atom us' ♯ (v, tm, x, y, y', t, ts, u, us)⟧ ⟹ {x EQ HPair (HPair Zero Zero) (HPair (Var t) (Var u)), y EQ HPair (HPair Zero Zero) (HPair (Var ts) (Var us)), SubstTermP v tm (Var u) (Var us), SubstTermP v tm (Var t) (Var ts), x EQ HPair (HPair Zero (HPair Zero (HPair Zero Zero))) (HPair (Var t') (Var u')), y' EQ HPair (HPair Zero (HPair Zero (HPair Zero Zero))) (HPair (Var ts') (Var us')), SubstTermP v tm (Var u') (Var us'), SubstTermP v tm (Var t') (Var ts')} ⊢ y' EQ y› and 2 goals remain*) apply (rule Eq_Trans_E [OF Hyp] (*‹⟦?x EQ ?u ∈ ?H; insert (?t EQ ?u) ?H ⊢ ?A⟧ ⟹ insert (?x EQ ?t) ?H ⊢ ?A›*), blast, force simp add: HTS (*‹(0::nat) < (?n::nat) ⟹ HTuple ?n = HPair Zero (HTuple (?n - (1::nat)))› ‹HTuple (0::nat) = HPair Zero Zero› ‹HTuple (Suc (?k::nat)) = HPair Zero (HTuple ?k)›*)) (*top goal: ‹⟦atom (t::name) ♯ (v::tm, tm::tm, x::tm, y::tm, y'::tm, ts::name, u::name, us::name); atom ts ♯ (v, tm, x, y, y', u, us); atom u ♯ (v, tm, x, y, y', us); atom us ♯ (v, tm, x, y, y'); atom (t'::name) ♯ (v, tm, x, y, y', t, ts, u, us, ts'::name, u'::name, us'::name); atom ts' ♯ (v, tm, x, y, y', t, ts, u, us, u', us'); atom u' ♯ (v, tm, x, y, y', t, ts, u, us, us'); atom us' ♯ (v, tm, x, y, y', t, ts, u, us)⟧ ⟹ {x EQ HPair (HPair Zero (HPair Zero (HPair Zero Zero))) (HPair (Var t) (Var u)), y EQ HPair (HPair Zero (HPair Zero (HPair Zero Zero))) (HPair (Var ts) (Var us)), SubstTermP v tm (Var u) (Var us), x EQ HPair (HPair Zero Zero) (HPair (Var t') (Var u')), y' EQ HPair (HPair Zero Zero) (HPair (Var ts') (Var us')), SubstTermP v tm (Var t) (Var ts), SubstTermP v tm (Var u') (Var us'), SubstTermP v tm (Var t') (Var ts')} ⊢ y' EQ y› and 1 goal remains*) apply (rule Eq_Trans_E [OF Hyp] (*‹⟦?x EQ ?u ∈ ?H; insert (?t EQ ?u) ?H ⊢ ?A⟧ ⟹ insert (?x EQ ?t) ?H ⊢ ?A›*), auto simp: HTS (*‹0 < ?n ⟹ HTuple ?n = HPair Zero (HTuple (?n - 1))› ‹HTuple 0 = HPair Zero Zero› ‹HTuple (Suc ?k) = HPair Zero (HTuple ?k)›*)) (*goal: ‹⟦atom t ♯ (v, tm, x, y, y', ts, u, us); atom ts ♯ (v, tm, x, y, y', u, us); atom u ♯ (v, tm, x, y, y', us); atom us ♯ (v, tm, x, y, y'); atom t' ♯ (v, tm, x, y, y', t, ts, u, us, ts', u', us'); atom ts' ♯ (v, tm, x, y, y', t, ts, u, us, u', us'); atom u' ♯ (v, tm, x, y, y', t, ts, u, us, us'); atom us' ♯ (v, tm, x, y, y', t, ts, u, us)⟧ ⟹ {x EQ HPair (HPair Zero Zero) (HPair (Var t) (Var u)), y EQ HPair (HPair Zero Zero) (HPair (Var ts) (Var us)), SubstTermP v tm (Var u) (Var us), x EQ HPair (HPair Zero Zero) (HPair (Var t') (Var u')), y' EQ HPair (HPair Zero Zero) (HPair (Var ts') (Var us')), SubstTermP v tm (Var t) (Var ts), SubstTermP v tm (Var u') (Var us'), SubstTermP v tm (Var t') (Var ts')} ⊢ y' EQ y›*) apply (rule SubstTermP_eq [THEN thin1] (*‹⟦(?H1::fm set) ⊢ SubstTermP (?v1::tm) (?tm1::tm) (?x1::tm) (?z1::tm); insert (SubstTermP ?v1 ?tm1 (?y1::tm) ?z1) ?H1 ⊢ (?B::fm)⟧ ⟹ insert (?A::fm) (insert (?x1 EQ ?y1) ?H1) ⊢ ?B›*), blast) (*goal: ‹⟦atom t ♯ (v, tm, x, y, y', ts, u, us); atom ts ♯ (v, tm, x, y, y', u, us); atom u ♯ (v, tm, x, y, y', us); atom us ♯ (v, tm, x, y, y'); atom t' ♯ (v, tm, x, y, y', t, ts, u, us, ts', u', us'); atom ts' ♯ (v, tm, x, y, y', t, ts, u, us, u', us'); atom u' ♯ (v, tm, x, y, y', t, ts, u, us, us'); atom us' ♯ (v, tm, x, y, y', t, ts, u, us)⟧ ⟹ {Zero EQ Zero, Var t EQ Var t', Var u EQ Var u', y EQ HPair (HPair Zero Zero) (HPair (Var ts) (Var us)), SubstTermP v tm (Var u) (Var us), x EQ HPair (HPair Zero Zero) (HPair (Var t') (Var u')), y' EQ HPair (HPair Zero Zero) (HPair (Var ts') (Var us')), SubstTermP v tm (Var t) (Var ts), SubstTermP v tm (Var u') (Var us'), SubstTermP v tm (Var t') (Var ts')} ⊢ y' EQ y›*) apply (rule SubstTermP_eq [THEN rotate2] (*‹⟦insert ?A1.0 ?H ⊢ SubstTermP ?v1 ?tm1 ?x1 ?z1; insert (SubstTermP ?v1 ?tm1 ?y1 ?z1) (insert ?A1.0 ?H) ⊢ ?B⟧ ⟹ insert ?A1.0 (insert (?x1 EQ ?y1) ?H) ⊢ ?B›*), blast) (*goal: ‹⟦atom t ♯ (v, tm, x, y, y', ts, u, us); atom ts ♯ (v, tm, x, y, y', u, us); atom u ♯ (v, tm, x, y, y', us); atom us ♯ (v, tm, x, y, y'); atom t' ♯ (v, tm, x, y, y', t, ts, u, us, ts', u', us'); atom ts' ♯ (v, tm, x, y, y', t, ts, u, us, u', us'); atom u' ♯ (v, tm, x, y, y', t, ts, u, us, us'); atom us' ♯ (v, tm, x, y, y', t, ts, u, us)⟧ ⟹ {SubstTermP v tm (Var t') (Var ts), Var u EQ Var u', y EQ HPair (HPair Zero Zero) (HPair (Var ts) (Var us)), SubstTermP v tm (Var u) (Var us), x EQ HPair (HPair Zero Zero) (HPair (Var t') (Var u')), y' EQ HPair (HPair Zero Zero) (HPair (Var ts') (Var us')), SubstTermP v tm (Var t) (Var ts), SubstTermP v tm (Var u') (Var us'), SubstTermP v tm (Var t') (Var ts')} ⊢ y' EQ y›*) apply (rule Trans [OF Hyp Sym] (*‹⟦(?x::tm) EQ (?y::tm) ∈ (?H::fm set); ?H ⊢ (?z::tm) EQ ?y⟧ ⟹ ?H ⊢ ?x EQ ?z›*), blast) (*goal: ‹⟦atom t ♯ (v, tm, x, y, y', ts, u, us); atom ts ♯ (v, tm, x, y, y', u, us); atom u ♯ (v, tm, x, y, y', us); atom us ♯ (v, tm, x, y, y'); atom t' ♯ (v, tm, x, y, y', t, ts, u, us, ts', u', us'); atom ts' ♯ (v, tm, x, y, y', t, ts, u, us, u', us'); atom u' ♯ (v, tm, x, y, y', t, ts, u, us, us'); atom us' ♯ (v, tm, x, y, y', t, ts, u, us)⟧ ⟹ {SubstTermP v tm (Var u') (Var us), SubstTermP v tm (Var t') (Var ts), y EQ HPair (HPair Zero Zero) (HPair (Var ts) (Var us)), SubstTermP v tm (Var u) (Var us), x EQ HPair (HPair Zero Zero) (HPair (Var t') (Var u')), y' EQ HPair (HPair Zero Zero) (HPair (Var ts') (Var us')), SubstTermP v tm (Var t) (Var ts), SubstTermP v tm (Var u') (Var us'), SubstTermP v tm (Var t') (Var ts')} ⊢ y' EQ y›*) apply (rule Trans [OF Hyp] (*‹⟦?x EQ ?y ∈ ?H; ?H ⊢ ?y EQ ?z⟧ ⟹ ?H ⊢ ?x EQ ?z›*), blast) (*goal: ‹⟦atom t ♯ (v, tm, x, y, y', ts, u, us); atom ts ♯ (v, tm, x, y, y', u, us); atom u ♯ (v, tm, x, y, y', us); atom us ♯ (v, tm, x, y, y'); atom t' ♯ (v, tm, x, y, y', t, ts, u, us, ts', u', us'); atom ts' ♯ (v, tm, x, y, y', t, ts, u, us, u', us'); atom u' ♯ (v, tm, x, y, y', t, ts, u, us, us'); atom us' ♯ (v, tm, x, y, y', t, ts, u, us)⟧ ⟹ {SubstTermP v tm (Var u') (Var us), SubstTermP v tm (Var t') (Var ts), y EQ HPair (HPair Zero Zero) (HPair (Var ts) (Var us)), SubstTermP v tm (Var u) (Var us), x EQ HPair (HPair Zero Zero) (HPair (Var t') (Var u')), y' EQ HPair (HPair Zero Zero) (HPair (Var ts') (Var us')), SubstTermP v tm (Var t) (Var ts), SubstTermP v tm (Var u') (Var us'), SubstTermP v tm (Var t') (Var ts')} ⊢ y EQ HPair (HPair Zero Zero) (HPair (Var ts') (Var us'))›*) by (metis Assume (*‹insert ?A ?H ⊢ ?A›*) AssumeH( (*‹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›*) 8) HPair_cong (*‹⟦?H ⊢ ?t EQ ?t'; ?H ⊢ ?u EQ ?u'⟧ ⟹ ?H ⊢ HPair ?t ?u EQ HPair ?t' ?u'›*) Refl (*‹?H ⊢ ?t EQ ?t›*) cut2 [OF SubstTermP_unique] (*‹⟦?H ⊢ SubstTermP ?v1 ?tm1 ?t1 ?u1; ?H ⊢ SubstTermP ?v1 ?tm1 ?t1 ?u'1⟧ ⟹ ?H ⊢ ?u'1 EQ ?u1›*) thin1 (*‹?H ⊢ ?B ⟹ insert ?A ?H ⊢ ?B›*)) qed subsection‹@{term SeqSubstFormP}› lemma SeqSubstFormP_lemma: assumes "atom m ♯ (v,u,x,y,s,k,n,sm,sm',sn,sn')" "atom n ♯ (v,u,x,y,s,k,sm,sm',sn,sn')" "atom sm ♯ (v,u,x,y,s,k,sm',sn,sn')" "atom sm' ♯ (v,u,x,y,s,k,sn,sn')" "atom sn ♯ (v,u,x,y,s,k,sn')" "atom sn' ♯ (v,u,x,y,s,k)" shows "{ SeqSubstFormP v u x y s k } ⊢ SubstAtomicP v u x y OR Ex m (Ex n (Ex sm (Ex sm' (Ex sn (Ex sn' (Var m IN k AND Var n IN k AND SeqSubstFormP v u (Var sm) (Var sm') s (Var m) AND SeqSubstFormP v u (Var sn) (Var sn') s (Var n) AND (((x EQ Q_Disj (Var sm) (Var sn) AND y EQ Q_Disj (Var sm') (Var sn')) OR (x EQ Q_Neg (Var sm) AND y EQ Q_Neg (Var sm')) OR (x EQ Q_Ex (Var sm) AND y EQ Q_Ex (Var sm'))))))))))" proof (-) (*goal: ‹{SeqSubstFormP v u x y s k} ⊢ SubstAtomicP v u x y OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN k AND Var n IN k AND SeqSubstFormP v u (Var sm) (Var sm') s (Var m) AND SeqSubstFormP v u (Var sn) (Var sn') s (Var n) AND (x EQ Q_Disj (Var sm) (Var sn) AND y EQ Q_Disj (Var sm') (Var sn') OR x EQ Q_Neg (Var sm) AND y EQ Q_Neg (Var sm') OR x EQ Q_Ex (Var sm) AND y EQ Q_Ex (Var sm'))))))))›*) obtain l :: name and sl :: name and sl' :: name where "atom l ♯ (v,u,x,y,s,k,sl,sl',m,n,sm,sm',sn,sn')" "atom sl ♯ (v,u,x,y,s,k,sl',m,n,sm,sm',sn,sn')" "atom sl' ♯ (v,u,x,y,s,k,m,n,sm,sm',sn,sn')" (*goal: ‹(⋀l sl sl'. ⟦atom l ♯ (v, u, x, y, s, k, sl, sl', m, n, sm, sm', sn, sn'); atom sl ♯ (v, u, x, y, s, k, sl', m, n, sm, sm', sn, sn'); atom sl' ♯ (v, u, x, y, s, k, m, n, sm, sm', sn, sn')⟧ ⟹ thesis) ⟹ thesis›*) by (metis obtain_fresh (*‹(⋀a::?'a::at_base. atom a ♯ (?x::?'b::fs) ⟹ ?thesis::bool) ⟹ ?thesis›*)) thus "?thesis" (*goal: ‹{SeqSubstFormP v u x y s k} ⊢ SubstAtomicP v u x y OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN k AND Var n IN k AND SeqSubstFormP v u (Var sm) (Var sm') s (Var m) AND SeqSubstFormP v u (Var sn) (Var sn') s (Var n) AND (x EQ Q_Disj (Var sm) (Var sn) AND y EQ Q_Disj (Var sm') (Var sn') OR x EQ Q_Neg (Var sm) AND y EQ Q_Neg (Var sm') OR x EQ Q_Ex (Var sm) AND y EQ Q_Ex (Var sm'))))))))›*) using assms (*‹atom m ♯ (v, u, x, y, s, k, n, sm, sm', sn, sn')› ‹atom n ♯ (v, u, x, y, s, k, sm, sm', sn, sn')› ‹atom (sm::name) ♯ (v::tm, u::tm, x::tm, y::tm, s::tm, k::tm, sm'::name, sn::name, sn'::name)› ‹atom sm' ♯ (v, u, x, y, s, k, sn, sn')› ‹atom sn ♯ (v, u, x, y, s, k, sn')› ‹atom sn' ♯ (v, u, x, y, s, k)›*) apply (simp add: SeqSubstFormP.simps [of l s k v u sl sl' m n sm sm' sn sn'] (*‹⟦atom l ♯ (s, k, v, u, sl, sl', m, n, sm, sm', sn, sn'); atom sl ♯ (s, v, u, sl', m, n, sm, sm', sn, sn'); atom sl' ♯ (s, v, u, m, n, sm, sm', sn, sn'); atom m ♯ (s, n, sm, sm', sn, sn'); atom n ♯ (s, sm, sm', sn, sn'); atom sm ♯ (s, sm', sn, sn'); atom sm' ♯ (s, sn, sn'); atom sn ♯ (s, sn'); atom sn' ♯ s⟧ ⟹ SeqSubstFormP v u ?x ?x' s k = LstSeqP s k (HPair ?x ?x') AND All2 l (SUCC k) (SyntaxN.Ex sl (SyntaxN.Ex sl' (HPair (Var l) (HPair (Var sl) (Var sl')) IN s AND (SubstAtomicP v u (Var sl) (Var sl') OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN Var l AND Var n IN Var l AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND (Var sl EQ Q_Disj (Var sm) (Var sn) AND Var sl' EQ Q_Disj (Var sm') (Var sn') OR Var sl EQ Q_Neg (Var sm) AND Var sl' EQ Q_Neg (Var sm') OR Var sl EQ Q_Ex (Var sm) AND Var sl' EQ Q_Ex (Var sm'))))))))))))›*)) (*goal: ‹{SeqSubstFormP v u x y s k} ⊢ SubstAtomicP v u x y OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN k AND Var n IN k AND SeqSubstFormP v u (Var sm) (Var sm') s (Var m) AND SeqSubstFormP v u (Var sn) (Var sn') s (Var n) AND (x EQ Q_Disj (Var sm) (Var sn) AND y EQ Q_Disj (Var sm') (Var sn') OR x EQ Q_Neg (Var sm) AND y EQ Q_Neg (Var sm') OR x EQ Q_Ex (Var sm) AND y EQ Q_Ex (Var sm'))))))))›*) apply (rule Conj_EH (*‹insert ?A (insert ?B ?H) ⊢ ?C ⟹ insert (?A AND ?B) ?H ⊢ ?C› ‹insert ?A (insert ?Ba (insert ?A1.0 ?H)) ⊢ ?B ⟹ insert ?A1.0 (insert (?A AND ?Ba) ?H) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 ?H))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert (?A AND ?Ba) ?H)) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 ?H)))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert (?A AND ?Ba) ?H))) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 ?H))))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert (?A AND ?Ba) ?H)))) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 ?H)))))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert (?A AND ?Ba) ?H))))) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 ?H))))))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert (?A AND ?Ba) ?H)))))) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 ?H)))))))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 (insert (?A AND ?Ba) ?H))))))) ⊢ ?B› ‹insert ?A (insert ?Ba (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))))))))) ⊢ ?B ⟹ 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 (?A AND ?Ba) ?H)))))))) ⊢ ?B› ‹insert ?A (insert ?Ba (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)))))))))) ⊢ ?B ⟹ 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 (?A AND ?Ba) ?H))))))))) ⊢ ?B›*) Ex_EH (*‹⟦insert ?A ?H ⊢ ?B; atom ?i ♯ ?B; ∀C∈?H. atom ?i ♯ C⟧ ⟹ insert (SyntaxN.Ex ?i ?A) ?H ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 ?H) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 ?H. atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert (SyntaxN.Ex ?i ?A) ?H) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 ?H)) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 ?H). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert (SyntaxN.Ex ?i ?A) ?H)) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 ?H))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 ?H)). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert (SyntaxN.Ex ?i ?A) ?H))) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 ?H)))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 ?H))). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert (SyntaxN.Ex ?i ?A) ?H)))) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 ?H))))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 ?H)))). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert (SyntaxN.Ex ?i ?A) ?H))))) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 ?H)))))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 ?H))))). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert (SyntaxN.Ex ?i ?A) ?H)))))) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 ?H))))))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 ?H)))))). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 (insert (SyntaxN.Ex ?i ?A) ?H))))))) ⊢ ?B› ‹⟦insert ?A (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)))))))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈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))))))). atom ?i ♯ C⟧ ⟹ 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 (SyntaxN.Ex ?i ?A) ?H)))))))) ⊢ ?B› ‹⟦insert ?A (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))))))))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈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)))))))). atom ?i ♯ C⟧ ⟹ 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 (SyntaxN.Ex ?i ?A) ?H))))))))) ⊢ ?B›*) All2_SUCC_E [THEN rotate2] (*‹⟦atom ?i1 ♯ ?t1; insert (All2 ?i1 ?t1 ?A1) (insert (?A1(?i1::=?t1)) (insert ?A1.0 ?H)) ⊢ ?B⟧ ⟹ insert ?A1.0 (insert (All2 ?i1 (SUCC ?t1) ?A1) ?H) ⊢ ?B›*)) (*goal: ‹⟦atom l ♯ (v, u, x, y, s, k, sl, sl', m, n, sm, sm', sn, sn'); atom sl ♯ (v, u, x, y, s, k, sl', m, n, sm, sm', sn, sn'); atom sl' ♯ (v, u, x, y, s, k, m, n, sm, sm', sn, sn'); atom m ♯ (v, u, x, y, s, k, n, sm, sm', sn, sn'); atom n ♯ (v, u, x, y, s, k, sm, sm', sn, sn'); atom sm ♯ (v, u, x, y, s, k, sm', sn, sn'); atom sm' ♯ (v, u, x, y, s, k, sn, sn'); atom sn ♯ (v, u, x, y, s, k, sn'); atom sn' ♯ (v, u, x, y, s, k)⟧ ⟹ {LstSeqP s k (HPair x y) AND All2 l (SUCC k) (SyntaxN.Ex sl (SyntaxN.Ex sl' (HPair (Var l) (HPair (Var sl) (Var sl')) IN s AND (SubstAtomicP v u (Var sl) (Var sl') OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN Var l AND Var n IN Var l AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND (Var sl EQ Q_Disj (Var sm) (Var sn) AND Var sl' EQ Q_Disj (Var sm') (Var sn') OR Var sl EQ Q_Neg (Var sm) AND Var sl' EQ Q_Neg (Var sm') OR Var sl EQ Q_Ex (Var sm) AND Var sl' EQ Q_Ex (Var sm'))))))))))))} ⊢ SubstAtomicP v u x y OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN k AND Var n IN k AND SeqSubstFormP v u (Var sm) (Var sm') s (Var m) AND SeqSubstFormP v u (Var sn) (Var sn') s (Var n) AND (x EQ Q_Disj (Var sm) (Var sn) AND y EQ Q_Disj (Var sm') (Var sn') OR x EQ Q_Neg (Var sm) AND y EQ Q_Neg (Var sm') OR x EQ Q_Ex (Var sm) AND y EQ Q_Ex (Var sm'))))))))›*) apply (rule Conj_EH (*‹insert (?A::fm) (insert (?B::fm) (?H::fm set)) ⊢ (?C::fm) ⟹ insert (?A AND ?B) ?H ⊢ ?C› ‹insert (?A::fm) (insert (?Ba::fm) (insert (?A1.0::fm) (?H::fm set))) ⊢ (?B::fm) ⟹ insert ?A1.0 (insert (?A AND ?Ba) ?H) ⊢ ?B› ‹insert (?A::fm) (insert (?Ba::fm) (insert (?A1.0::fm) (insert (?A2.0::fm) (?H::fm set)))) ⊢ (?B::fm) ⟹ insert ?A1.0 (insert ?A2.0 (insert (?A AND ?Ba) ?H)) ⊢ ?B› ‹insert (?A::fm) (insert (?Ba::fm) (insert (?A1.0::fm) (insert (?A2.0::fm) (insert (?A3.0::fm) (?H::fm set))))) ⊢ (?B::fm) ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert (?A AND ?Ba) ?H))) ⊢ ?B› ‹insert (?A::fm) (insert (?Ba::fm) (insert (?A1.0::fm) (insert (?A2.0::fm) (insert (?A3.0::fm) (insert (?A4.0::fm) (?H::fm set)))))) ⊢ (?B::fm) ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert (?A AND ?Ba) ?H)))) ⊢ ?B› ‹insert (?A::fm) (insert (?Ba::fm) (insert (?A1.0::fm) (insert (?A2.0::fm) (insert (?A3.0::fm) (insert (?A4.0::fm) (insert (?A5.0::fm) (?H::fm set))))))) ⊢ (?B::fm) ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert (?A AND ?Ba) ?H))))) ⊢ ?B› ‹insert (?A::fm) (insert (?Ba::fm) (insert (?A1.0::fm) (insert (?A2.0::fm) (insert (?A3.0::fm) (insert (?A4.0::fm) (insert (?A5.0::fm) (insert (?A6.0::fm) (?H::fm set)))))))) ⊢ (?B::fm) ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert (?A AND ?Ba) ?H)))))) ⊢ ?B› ‹insert (?A::fm) (insert (?Ba::fm) (insert (?A1.0::fm) (insert (?A2.0::fm) (insert (?A3.0::fm) (insert (?A4.0::fm) (insert (?A5.0::fm) (insert (?A6.0::fm) (insert (?A7.0::fm) (?H::fm set))))))))) ⊢ (?B::fm) ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 (insert (?A AND ?Ba) ?H))))))) ⊢ ?B› ‹insert (?A::fm) (insert (?Ba::fm) (insert (?A1.0::fm) (insert (?A2.0::fm) (insert (?A3.0::fm) (insert (?A4.0::fm) (insert (?A5.0::fm) (insert (?A6.0::fm) (insert (?A7.0::fm) (insert (?A8.0::fm) (?H::fm set)))))))))) ⊢ (?B::fm) ⟹ 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 (?A AND ?Ba) ?H)))))))) ⊢ ?B› ‹insert (?A::fm) (insert (?Ba::fm) (insert (?A1.0::fm) (insert (?A2.0::fm) (insert (?A3.0::fm) (insert (?A4.0::fm) (insert (?A5.0::fm) (insert (?A6.0::fm) (insert (?A7.0::fm) (insert (?A8.0::fm) (insert (?A9.0::fm) (?H::fm set))))))))))) ⊢ (?B::fm) ⟹ 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 (?A AND ?Ba) ?H))))))))) ⊢ ?B›*) Ex_EH (*‹⟦insert (?A::fm) (?H::fm set) ⊢ (?B::fm); atom (?i::name) ♯ ?B; ∀C::fm∈?H. atom ?i ♯ C⟧ ⟹ insert (SyntaxN.Ex ?i ?A) ?H ⊢ ?B› ‹⟦insert (?A::fm) (insert (?A1.0::fm) (?H::fm set)) ⊢ (?B::fm); atom (?i::name) ♯ ?B; ∀C::fm∈insert ?A1.0 ?H. atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert (SyntaxN.Ex ?i ?A) ?H) ⊢ ?B› ‹⟦insert (?A::fm) (insert (?A1.0::fm) (insert (?A2.0::fm) (?H::fm set))) ⊢ (?B::fm); atom (?i::name) ♯ ?B; ∀C::fm∈insert ?A1.0 (insert ?A2.0 ?H). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert (SyntaxN.Ex ?i ?A) ?H)) ⊢ ?B› ‹⟦insert (?A::fm) (insert (?A1.0::fm) (insert (?A2.0::fm) (insert (?A3.0::fm) (?H::fm set)))) ⊢ (?B::fm); atom (?i::name) ♯ ?B; ∀C::fm∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 ?H)). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert (SyntaxN.Ex ?i ?A) ?H))) ⊢ ?B› ‹⟦insert (?A::fm) (insert (?A1.0::fm) (insert (?A2.0::fm) (insert (?A3.0::fm) (insert (?A4.0::fm) (?H::fm set))))) ⊢ (?B::fm); atom (?i::name) ♯ ?B; ∀C::fm∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 ?H))). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert (SyntaxN.Ex ?i ?A) ?H)))) ⊢ ?B› ‹⟦insert (?A::fm) (insert (?A1.0::fm) (insert (?A2.0::fm) (insert (?A3.0::fm) (insert (?A4.0::fm) (insert (?A5.0::fm) (?H::fm set)))))) ⊢ (?B::fm); atom (?i::name) ♯ ?B; ∀C::fm∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 ?H)))). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert (SyntaxN.Ex ?i ?A) ?H))))) ⊢ ?B› ‹⟦insert (?A::fm) (insert (?A1.0::fm) (insert (?A2.0::fm) (insert (?A3.0::fm) (insert (?A4.0::fm) (insert (?A5.0::fm) (insert (?A6.0::fm) (?H::fm set))))))) ⊢ (?B::fm); atom (?i::name) ♯ ?B; ∀C::fm∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 ?H))))). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert (SyntaxN.Ex ?i ?A) ?H)))))) ⊢ ?B› ‹⟦insert (?A::fm) (insert (?A1.0::fm) (insert (?A2.0::fm) (insert (?A3.0::fm) (insert (?A4.0::fm) (insert (?A5.0::fm) (insert (?A6.0::fm) (insert (?A7.0::fm) (?H::fm set)))))))) ⊢ (?B::fm); atom (?i::name) ♯ ?B; ∀C::fm∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 ?H)))))). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 (insert (SyntaxN.Ex ?i ?A) ?H))))))) ⊢ ?B› ‹⟦insert (?A::fm) (insert (?A1.0::fm) (insert (?A2.0::fm) (insert (?A3.0::fm) (insert (?A4.0::fm) (insert (?A5.0::fm) (insert (?A6.0::fm) (insert (?A7.0::fm) (insert (?A8.0::fm) (?H::fm set))))))))) ⊢ (?B::fm); atom (?i::name) ♯ ?B; ∀C::fm∈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))))))). atom ?i ♯ C⟧ ⟹ 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 (SyntaxN.Ex ?i ?A) ?H)))))))) ⊢ ?B› ‹⟦insert (?A::fm) (insert (?A1.0::fm) (insert (?A2.0::fm) (insert (?A3.0::fm) (insert (?A4.0::fm) (insert (?A5.0::fm) (insert (?A6.0::fm) (insert (?A7.0::fm) (insert (?A8.0::fm) (insert (?A9.0::fm) (?H::fm set)))))))))) ⊢ (?B::fm); atom (?i::name) ♯ ?B; ∀C::fm∈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)))))))). atom ?i ♯ C⟧ ⟹ 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 (SyntaxN.Ex ?i ?A) ?H))))))))) ⊢ ?B›*) All2_SUCC_E [THEN rotate2] (*‹⟦atom (?i1::name) ♯ (?t1::tm); insert (All2 ?i1 ?t1 (?A1::fm)) (insert (?A1(?i1::=?t1)) (insert (?A1.0::fm) (?H::fm set))) ⊢ (?B::fm)⟧ ⟹ insert ?A1.0 (insert (All2 ?i1 (SUCC ?t1) ?A1) ?H) ⊢ ?B›*)) (*goals: 1. ‹⟦atom l ♯ (v, u, x, y, s, k, sl, sl', m, n, sm, sm', sn, sn'); atom sl ♯ (v, u, x, y, s, k, sl', m, n, sm, sm', sn, sn'); atom sl' ♯ (v, u, x, y, s, k, m, n, sm, sm', sn, sn'); atom m ♯ (v, u, x, y, s, k, n, sm, sm', sn, sn'); atom n ♯ (v, u, x, y, s, k, sm, sm', sn, sn'); atom sm ♯ (v, u, x, y, s, k, sm', sn, sn'); atom sm' ♯ (v, u, x, y, s, k, sn, sn'); atom sn ♯ (v, u, x, y, s, k, sn'); atom sn' ♯ (v, u, x, y, s, k)⟧ ⟹ atom l ♯ k› 2. ‹⟦atom l ♯ (v, u, x, y, s, k, sl, sl', m, n, sm, sm', sn, sn'); atom sl ♯ (v, u, x, y, s, k, sl', m, n, sm, sm', sn, sn'); atom sl' ♯ (v, u, x, y, s, k, m, n, sm, sm', sn, sn'); atom m ♯ (v, u, x, y, s, k, n, sm, sm', sn, sn'); atom n ♯ (v, u, x, y, s, k, sm, sm', sn, sn'); atom sm ♯ (v, u, x, y, s, k, sm', sn, sn'); atom sm' ♯ (v, u, x, y, s, k, sn, sn'); atom sn ♯ (v, u, x, y, s, k, sn'); atom sn' ♯ (v, u, x, y, s, k)⟧ ⟹ {All2 l k (SyntaxN.Ex sl (SyntaxN.Ex sl' (HPair (Var l) (HPair (Var sl) (Var sl')) IN s AND (SubstAtomicP v u (Var sl) (Var sl') OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN Var l AND Var n IN Var l AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND (Var sl EQ Q_Disj (Var sm) (Var sn) AND Var sl' EQ Q_Disj (Var sm') (Var sn') OR Var sl EQ Q_Neg (Var sm) AND Var sl' EQ Q_Neg (Var sm') OR Var sl EQ Q_Ex (Var sm) AND Var sl' EQ Q_Ex (Var sm')))))))))))), (SyntaxN.Ex sl (SyntaxN.Ex sl' (HPair (Var l) (HPair (Var sl) (Var sl')) IN s AND (SubstAtomicP v u (Var sl) (Var sl') OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN Var l AND Var n IN Var l AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND (Var sl EQ Q_Disj (Var sm) (Var sn) AND Var sl' EQ Q_Disj (Var sm') (Var sn') OR Var sl EQ Q_Neg (Var sm) AND Var sl' EQ Q_Neg (Var sm') OR Var sl EQ Q_Ex (Var sm) AND Var sl' EQ Q_Ex (Var sm'))))))))))))(l::=k), LstSeqP s k (HPair x y)} ⊢ SubstAtomicP v u x y OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN k AND Var n IN k AND SeqSubstFormP v u (Var sm) (Var sm') s (Var m) AND SeqSubstFormP v u (Var sn) (Var sn') s (Var n) AND (x EQ Q_Disj (Var sm) (Var sn) AND y EQ Q_Disj (Var sm') (Var sn') OR x EQ Q_Neg (Var sm) AND y EQ Q_Neg (Var sm') OR x EQ Q_Ex (Var sm) AND y EQ Q_Ex (Var sm'))))))))› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*goal: ‹⟦atom l ♯ (v, u, x, y, s, k, sl, sl', m, n, sm, sm', sn, sn'); atom sl ♯ (v, u, x, y, s, k, sl', m, n, sm, sm', sn, sn'); atom sl' ♯ (v, u, x, y, s, k, m, n, sm, sm', sn, sn'); atom m ♯ (v, u, x, y, s, k, n, sm, sm', sn, sn'); atom n ♯ (v, u, x, y, s, k, sm, sm', sn, sn'); atom sm ♯ (v, u, x, y, s, k, sm', sn, sn'); atom sm' ♯ (v, u, x, y, s, k, sn, sn'); atom sn ♯ (v, u, x, y, s, k, sn'); atom sn' ♯ (v, u, x, y, s, k)⟧ ⟹ {All2 l k (SyntaxN.Ex sl (SyntaxN.Ex sl' (HPair (Var l) (HPair (Var sl) (Var sl')) IN s AND (SubstAtomicP v u (Var sl) (Var sl') OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN Var l AND Var n IN Var l AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND (Var sl EQ Q_Disj (Var sm) (Var sn) AND Var sl' EQ Q_Disj (Var sm') (Var sn') OR Var sl EQ Q_Neg (Var sm) AND Var sl' EQ Q_Neg (Var sm') OR Var sl EQ Q_Ex (Var sm) AND Var sl' EQ Q_Ex (Var sm')))))))))))), (SyntaxN.Ex sl (SyntaxN.Ex sl' (HPair (Var l) (HPair (Var sl) (Var sl')) IN s AND (SubstAtomicP v u (Var sl) (Var sl') OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN Var l AND Var n IN Var l AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND (Var sl EQ Q_Disj (Var sm) (Var sn) AND Var sl' EQ Q_Disj (Var sm') (Var sn') OR Var sl EQ Q_Neg (Var sm) AND Var sl' EQ Q_Neg (Var sm') OR Var sl EQ Q_Ex (Var sm) AND Var sl' EQ Q_Ex (Var sm'))))))))))))(l::=k), LstSeqP s k (HPair x y)} ⊢ SubstAtomicP v u x y OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN k AND Var n IN k AND SeqSubstFormP v u (Var sm) (Var sm') s (Var m) AND SeqSubstFormP v u (Var sn) (Var sn') s (Var n) AND (x EQ Q_Disj (Var sm) (Var sn) AND y EQ Q_Disj (Var sm') (Var sn') OR x EQ Q_Neg (Var sm) AND y EQ Q_Neg (Var sm') OR x EQ Q_Ex (Var sm) AND y EQ Q_Ex (Var sm'))))))))›*) apply (rule Conj_EH (*‹insert ?A (insert ?B ?H) ⊢ ?C ⟹ insert (?A AND ?B) ?H ⊢ ?C› ‹insert ?A (insert ?Ba (insert ?A1.0 ?H)) ⊢ ?B ⟹ insert ?A1.0 (insert (?A AND ?Ba) ?H) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 ?H))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert (?A AND ?Ba) ?H)) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 ?H)))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert (?A AND ?Ba) ?H))) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 ?H))))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert (?A AND ?Ba) ?H)))) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 ?H)))))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert (?A AND ?Ba) ?H))))) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 ?H))))))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert (?A AND ?Ba) ?H)))))) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 ?H)))))))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 (insert (?A AND ?Ba) ?H))))))) ⊢ ?B› ‹insert ?A (insert ?Ba (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))))))))) ⊢ ?B ⟹ 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 (?A AND ?Ba) ?H)))))))) ⊢ ?B› ‹insert ?A (insert ?Ba (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)))))))))) ⊢ ?B ⟹ 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 (?A AND ?Ba) ?H))))))))) ⊢ ?B›*) Ex_EH (*‹⟦insert ?A ?H ⊢ ?B; atom ?i ♯ ?B; ∀C∈?H. atom ?i ♯ C⟧ ⟹ insert (SyntaxN.Ex ?i ?A) ?H ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 ?H) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 ?H. atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert (SyntaxN.Ex ?i ?A) ?H) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 ?H)) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 ?H). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert (SyntaxN.Ex ?i ?A) ?H)) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 ?H))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 ?H)). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert (SyntaxN.Ex ?i ?A) ?H))) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 ?H)))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 ?H))). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert (SyntaxN.Ex ?i ?A) ?H)))) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 ?H))))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 ?H)))). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert (SyntaxN.Ex ?i ?A) ?H))))) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 ?H)))))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 ?H))))). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert (SyntaxN.Ex ?i ?A) ?H)))))) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 ?H))))))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 ?H)))))). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 (insert (SyntaxN.Ex ?i ?A) ?H))))))) ⊢ ?B› ‹⟦insert ?A (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)))))))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈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))))))). atom ?i ♯ C⟧ ⟹ 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 (SyntaxN.Ex ?i ?A) ?H)))))))) ⊢ ?B› ‹⟦insert ?A (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))))))))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈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)))))))). atom ?i ♯ C⟧ ⟹ 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 (SyntaxN.Ex ?i ?A) ?H))))))))) ⊢ ?B›*) All2_SUCC_E [THEN rotate2] (*‹⟦atom ?i1 ♯ ?t1; insert (All2 ?i1 ?t1 ?A1) (insert (?A1(?i1::=?t1)) (insert ?A1.0 ?H)) ⊢ ?B⟧ ⟹ insert ?A1.0 (insert (All2 ?i1 (SUCC ?t1) ?A1) ?H) ⊢ ?B›*)) (*goals: 1. ‹⟦atom l ♯ (v, u, x, y, s, k, sl, sl', m, n, sm, sm', sn, sn'); atom sl ♯ (v, u, x, y, s, k, sl', m, n, sm, sm', sn, sn'); atom sl' ♯ (v, u, x, y, s, k, m, n, sm, sm', sn, sn'); atom m ♯ (v, u, x, y, s, k, n, sm, sm', sn, sn'); atom n ♯ (v, u, x, y, s, k, sm, sm', sn, sn'); atom sm ♯ (v, u, x, y, s, k, sm', sn, sn'); atom sm' ♯ (v, u, x, y, s, k, sn, sn'); atom sn ♯ (v, u, x, y, s, k, sn'); atom sn' ♯ (v, u, x, y, s, k)⟧ ⟹ {SyntaxN.Ex sl' (HPair k (HPair (Var sl) (Var sl')) IN s AND (SubstAtomicP v u (Var sl) (Var sl') OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN k AND Var n IN k AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND (Var sl EQ Q_Disj (Var sm) (Var sn) AND Var sl' EQ Q_Disj (Var sm') (Var sn') OR Var sl EQ Q_Neg (Var sm) AND Var sl' EQ Q_Neg (Var sm') OR Var sl EQ Q_Ex (Var sm) AND Var sl' EQ Q_Ex (Var sm')))))))))), All2 l k (SyntaxN.Ex sl (SyntaxN.Ex sl' (HPair (Var l) (HPair (Var sl) (Var sl')) IN s AND (SubstAtomicP v u (Var sl) (Var sl') OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN Var l AND Var n IN Var l AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND (Var sl EQ Q_Disj (Var sm) (Var sn) AND Var sl' EQ Q_Disj (Var sm') (Var sn') OR Var sl EQ Q_Neg (Var sm) AND Var sl' EQ Q_Neg (Var sm') OR Var sl EQ Q_Ex (Var sm) AND Var sl' EQ Q_Ex (Var sm')))))))))))), LstSeqP s k (HPair x y)} ⊢ SubstAtomicP v u x y OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN k AND Var n IN k AND SeqSubstFormP v u (Var sm) (Var sm') s (Var m) AND SeqSubstFormP v u (Var sn) (Var sn') s (Var n) AND (x EQ Q_Disj (Var sm) (Var sn) AND y EQ Q_Disj (Var sm') (Var sn') OR x EQ Q_Neg (Var sm) AND y EQ Q_Neg (Var sm') OR x EQ Q_Ex (Var sm) AND y EQ Q_Ex (Var sm'))))))))› 2. ‹⟦atom l ♯ (v, u, x, y, s, k, sl, sl', m, n, sm, sm', sn, sn'); atom sl ♯ (v, u, x, y, s, k, sl', m, n, sm, sm', sn, sn'); atom sl' ♯ (v, u, x, y, s, k, m, n, sm, sm', sn, sn'); atom m ♯ (v, u, x, y, s, k, n, sm, sm', sn, sn'); atom n ♯ (v, u, x, y, s, k, sm, sm', sn, sn'); atom sm ♯ (v, u, x, y, s, k, sm', sn, sn'); atom sm' ♯ (v, u, x, y, s, k, sn, sn'); atom sn ♯ (v, u, x, y, s, k, sn'); atom sn' ♯ (v, u, x, y, s, k)⟧ ⟹ atom sl ♯ SubstAtomicP v u x y OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN k AND Var n IN k AND SeqSubstFormP v u (Var sm) (Var sm') s (Var m) AND SeqSubstFormP v u (Var sn) (Var sn') s (Var n) AND (x EQ Q_Disj (Var sm) (Var sn) AND y EQ Q_Disj (Var sm') (Var sn') OR x EQ Q_Neg (Var sm) AND y EQ Q_Neg (Var sm') OR x EQ Q_Ex (Var sm) AND y EQ Q_Ex (Var sm'))))))))› 3. ‹⟦atom l ♯ (v, u, x, y, s, k, sl, sl', m, n, sm, sm', sn, sn'); atom sl ♯ (v, u, x, y, s, k, sl', m, n, sm, sm', sn, sn'); atom sl' ♯ (v, u, x, y, s, k, m, n, sm, sm', sn, sn'); atom m ♯ (v, u, x, y, s, k, n, sm, sm', sn, sn'); atom n ♯ (v, u, x, y, s, k, sm, sm', sn, sn'); atom sm ♯ (v, u, x, y, s, k, sm', sn, sn'); atom sm' ♯ (v, u, x, y, s, k, sn, sn'); atom sn ♯ (v, u, x, y, s, k, sn'); atom sn' ♯ (v, u, x, y, s, k)⟧ ⟹ ∀C∈{All2 l k (SyntaxN.Ex sl (SyntaxN.Ex sl' (HPair (Var l) (HPair (Var sl) (Var sl')) IN s AND (SubstAtomicP v u (Var sl) (Var sl') OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN Var l AND Var n IN Var l AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND (Var sl EQ Q_Disj (Var sm) (Var sn) AND Var sl' EQ Q_Disj (Var sm') (Var sn') OR Var sl EQ Q_Neg (Var sm) AND Var sl' EQ Q_Neg (Var sm') OR Var sl EQ Q_Ex (Var sm) AND Var sl' EQ Q_Ex (Var sm')))))))))))), LstSeqP s k (HPair x y)}. atom sl ♯ C› discuss goal 1*) apply (rule Conj_EH (*‹insert ?A (insert ?B ?H) ⊢ ?C ⟹ insert (?A AND ?B) ?H ⊢ ?C› ‹insert ?A (insert ?Ba (insert ?A1.0 ?H)) ⊢ ?B ⟹ insert ?A1.0 (insert (?A AND ?Ba) ?H) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 ?H))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert (?A AND ?Ba) ?H)) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 ?H)))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert (?A AND ?Ba) ?H))) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 ?H))))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert (?A AND ?Ba) ?H)))) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 ?H)))))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert (?A AND ?Ba) ?H))))) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 ?H))))))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert (?A AND ?Ba) ?H)))))) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 ?H)))))))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 (insert (?A AND ?Ba) ?H))))))) ⊢ ?B› ‹insert ?A (insert ?Ba (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))))))))) ⊢ ?B ⟹ 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 (?A AND ?Ba) ?H)))))))) ⊢ ?B› ‹insert ?A (insert ?Ba (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)))))))))) ⊢ ?B ⟹ 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 (?A AND ?Ba) ?H))))))))) ⊢ ?B›*) Ex_EH (*‹⟦insert ?A ?H ⊢ ?B; atom ?i ♯ ?B; ∀C∈?H. atom ?i ♯ C⟧ ⟹ insert (SyntaxN.Ex ?i ?A) ?H ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 ?H) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 ?H. atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert (SyntaxN.Ex ?i ?A) ?H) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 ?H)) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 ?H). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert (SyntaxN.Ex ?i ?A) ?H)) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 ?H))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 ?H)). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert (SyntaxN.Ex ?i ?A) ?H))) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 ?H)))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 ?H))). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert (SyntaxN.Ex ?i ?A) ?H)))) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 ?H))))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 ?H)))). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert (SyntaxN.Ex ?i ?A) ?H))))) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 ?H)))))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 ?H))))). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert (SyntaxN.Ex ?i ?A) ?H)))))) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 ?H))))))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 ?H)))))). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 (insert (SyntaxN.Ex ?i ?A) ?H))))))) ⊢ ?B› ‹⟦insert ?A (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)))))))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈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))))))). atom ?i ♯ C⟧ ⟹ 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 (SyntaxN.Ex ?i ?A) ?H)))))))) ⊢ ?B› ‹⟦insert ?A (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))))))))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈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)))))))). atom ?i ♯ C⟧ ⟹ 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 (SyntaxN.Ex ?i ?A) ?H))))))))) ⊢ ?B›*) All2_SUCC_E [THEN rotate2] (*‹⟦atom ?i1 ♯ ?t1; insert (All2 ?i1 ?t1 ?A1) (insert (?A1(?i1::=?t1)) (insert ?A1.0 ?H)) ⊢ ?B⟧ ⟹ insert ?A1.0 (insert (All2 ?i1 (SUCC ?t1) ?A1) ?H) ⊢ ?B›*)) (*goals: 1. ‹⟦atom l ♯ (v, u, x, y, s, k, sl, sl', m, n, sm, sm', sn, sn'); atom sl ♯ (v, u, x, y, s, k, sl', m, n, sm, sm', sn, sn'); atom sl' ♯ (v, u, x, y, s, k, m, n, sm, sm', sn, sn'); atom m ♯ (v, u, x, y, s, k, n, sm, sm', sn, sn'); atom n ♯ (v, u, x, y, s, k, sm, sm', sn, sn'); atom sm ♯ (v, u, x, y, s, k, sm', sn, sn'); atom sm' ♯ (v, u, x, y, s, k, sn, sn'); atom sn ♯ (v, u, x, y, s, k, sn'); atom sn' ♯ (v, u, x, y, s, k)⟧ ⟹ {HPair k (HPair (Var sl) (Var sl')) IN s AND (SubstAtomicP v u (Var sl) (Var sl') OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN k AND Var n IN k AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND (Var sl EQ Q_Disj (Var sm) (Var sn) AND Var sl' EQ Q_Disj (Var sm') (Var sn') OR Var sl EQ Q_Neg (Var sm) AND Var sl' EQ Q_Neg (Var sm') OR Var sl EQ Q_Ex (Var sm) AND Var sl' EQ Q_Ex (Var sm'))))))))), All2 l k (SyntaxN.Ex sl (SyntaxN.Ex sl' (HPair (Var l) (HPair (Var sl) (Var sl')) IN s AND (SubstAtomicP v u (Var sl) (Var sl') OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN Var l AND Var n IN Var l AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND (Var sl EQ Q_Disj (Var sm) (Var sn) AND Var sl' EQ Q_Disj (Var sm') (Var sn') OR Var sl EQ Q_Neg (Var sm) AND Var sl' EQ Q_Neg (Var sm') OR Var sl EQ Q_Ex (Var sm) AND Var sl' EQ Q_Ex (Var sm')))))))))))), LstSeqP s k (HPair x y)} ⊢ SubstAtomicP v u x y OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN k AND Var n IN k AND SeqSubstFormP v u (Var sm) (Var sm') s (Var m) AND SeqSubstFormP v u (Var sn) (Var sn') s (Var n) AND (x EQ Q_Disj (Var sm) (Var sn) AND y EQ Q_Disj (Var sm') (Var sn') OR x EQ Q_Neg (Var sm) AND y EQ Q_Neg (Var sm') OR x EQ Q_Ex (Var sm) AND y EQ Q_Ex (Var sm'))))))))› 2. ‹⟦atom l ♯ (v, u, x, y, s, k, sl, sl', m, n, sm, sm', sn, sn'); atom sl ♯ (v, u, x, y, s, k, sl', m, n, sm, sm', sn, sn'); atom sl' ♯ (v, u, x, y, s, k, m, n, sm, sm', sn, sn'); atom m ♯ (v, u, x, y, s, k, n, sm, sm', sn, sn'); atom n ♯ (v, u, x, y, s, k, sm, sm', sn, sn'); atom sm ♯ (v, u, x, y, s, k, sm', sn, sn'); atom sm' ♯ (v, u, x, y, s, k, sn, sn'); atom sn ♯ (v, u, x, y, s, k, sn'); atom sn' ♯ (v, u, x, y, s, k)⟧ ⟹ atom sl' ♯ SubstAtomicP v u x y OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN k AND Var n IN k AND SeqSubstFormP v u (Var sm) (Var sm') s (Var m) AND SeqSubstFormP v u (Var sn) (Var sn') s (Var n) AND (x EQ Q_Disj (Var sm) (Var sn) AND y EQ Q_Disj (Var sm') (Var sn') OR x EQ Q_Neg (Var sm) AND y EQ Q_Neg (Var sm') OR x EQ Q_Ex (Var sm) AND y EQ Q_Ex (Var sm'))))))))› 3. ‹⟦atom l ♯ (v, u, x, y, s, k, sl, sl', m, n, sm, sm', sn, sn'); atom sl ♯ (v, u, x, y, s, k, sl', m, n, sm, sm', sn, sn'); atom sl' ♯ (v, u, x, y, s, k, m, n, sm, sm', sn, sn'); atom m ♯ (v, u, x, y, s, k, n, sm, sm', sn, sn'); atom n ♯ (v, u, x, y, s, k, sm, sm', sn, sn'); atom sm ♯ (v, u, x, y, s, k, sm', sn, sn'); atom sm' ♯ (v, u, x, y, s, k, sn, sn'); atom sn ♯ (v, u, x, y, s, k, sn'); atom sn' ♯ (v, u, x, y, s, k)⟧ ⟹ ∀C∈{All2 l k (SyntaxN.Ex sl (SyntaxN.Ex sl' (HPair (Var l) (HPair (Var sl) (Var sl')) IN s AND (SubstAtomicP v u (Var sl) (Var sl') OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN Var l AND Var n IN Var l AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND (Var sl EQ Q_Disj (Var sm) (Var sn) AND Var sl' EQ Q_Disj (Var sm') (Var sn') OR Var sl EQ Q_Neg (Var sm) AND Var sl' EQ Q_Neg (Var sm') OR Var sl EQ Q_Ex (Var sm) AND Var sl' EQ Q_Ex (Var sm')))))))))))), LstSeqP s k (HPair x y)}. atom sl' ♯ C› discuss goal 1*) apply (rule Conj_EH (*‹insert ?A (insert ?B ?H) ⊢ ?C ⟹ insert (?A AND ?B) ?H ⊢ ?C› ‹insert ?A (insert ?Ba (insert ?A1.0 ?H)) ⊢ ?B ⟹ insert ?A1.0 (insert (?A AND ?Ba) ?H) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 ?H))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert (?A AND ?Ba) ?H)) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 ?H)))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert (?A AND ?Ba) ?H))) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 ?H))))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert (?A AND ?Ba) ?H)))) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 ?H)))))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert (?A AND ?Ba) ?H))))) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 ?H))))))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert (?A AND ?Ba) ?H)))))) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 ?H)))))))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 (insert (?A AND ?Ba) ?H))))))) ⊢ ?B› ‹insert ?A (insert ?Ba (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))))))))) ⊢ ?B ⟹ 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 (?A AND ?Ba) ?H)))))))) ⊢ ?B› ‹insert ?A (insert ?Ba (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)))))))))) ⊢ ?B ⟹ 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 (?A AND ?Ba) ?H))))))))) ⊢ ?B›*) Ex_EH (*‹⟦insert ?A ?H ⊢ ?B; atom ?i ♯ ?B; ∀C∈?H. atom ?i ♯ C⟧ ⟹ insert (SyntaxN.Ex ?i ?A) ?H ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 ?H) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 ?H. atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert (SyntaxN.Ex ?i ?A) ?H) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 ?H)) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 ?H). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert (SyntaxN.Ex ?i ?A) ?H)) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 ?H))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 ?H)). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert (SyntaxN.Ex ?i ?A) ?H))) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 ?H)))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 ?H))). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert (SyntaxN.Ex ?i ?A) ?H)))) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 ?H))))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 ?H)))). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert (SyntaxN.Ex ?i ?A) ?H))))) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 ?H)))))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 ?H))))). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert (SyntaxN.Ex ?i ?A) ?H)))))) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 ?H))))))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 ?H)))))). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 (insert (SyntaxN.Ex ?i ?A) ?H))))))) ⊢ ?B› ‹⟦insert ?A (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)))))))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈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))))))). atom ?i ♯ C⟧ ⟹ 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 (SyntaxN.Ex ?i ?A) ?H)))))))) ⊢ ?B› ‹⟦insert ?A (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))))))))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈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)))))))). atom ?i ♯ C⟧ ⟹ 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 (SyntaxN.Ex ?i ?A) ?H))))))))) ⊢ ?B›*) All2_SUCC_E [THEN rotate2] (*‹⟦atom ?i1 ♯ ?t1; insert (All2 ?i1 ?t1 ?A1) (insert (?A1(?i1::=?t1)) (insert ?A1.0 ?H)) ⊢ ?B⟧ ⟹ insert ?A1.0 (insert (All2 ?i1 (SUCC ?t1) ?A1) ?H) ⊢ ?B›*)) (*top goal: ‹⟦atom l ♯ (v, u, x, y, s, k, sl, sl', m, n, sm, sm', sn, sn'); atom sl ♯ (v, u, x, y, s, k, sl', m, n, sm, sm', sn, sn'); atom sl' ♯ (v, u, x, y, s, k, m, n, sm, sm', sn, sn'); atom m ♯ (v, u, x, y, s, k, n, sm, sm', sn, sn'); atom n ♯ (v, u, x, y, s, k, sm, sm', sn, sn'); atom sm ♯ (v, u, x, y, s, k, sm', sn, sn'); atom sm' ♯ (v, u, x, y, s, k, sn, sn'); atom sn ♯ (v, u, x, y, s, k, sn'); atom sn' ♯ (v, u, x, y, s, k)⟧ ⟹ {HPair k (HPair (Var sl) (Var sl')) IN s AND (SubstAtomicP v u (Var sl) (Var sl') OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN k AND Var n IN k AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND (Var sl EQ Q_Disj (Var sm) (Var sn) AND Var sl' EQ Q_Disj (Var sm') (Var sn') OR Var sl EQ Q_Neg (Var sm) AND Var sl' EQ Q_Neg (Var sm') OR Var sl EQ Q_Ex (Var sm) AND Var sl' EQ Q_Ex (Var sm'))))))))), All2 l k (SyntaxN.Ex sl (SyntaxN.Ex sl' (HPair (Var l) (HPair (Var sl) (Var sl')) IN s AND (SubstAtomicP v u (Var sl) (Var sl') OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN Var l AND Var n IN Var l AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND (Var sl EQ Q_Disj (Var sm) (Var sn) AND Var sl' EQ Q_Disj (Var sm') (Var sn') OR Var sl EQ Q_Neg (Var sm) AND Var sl' EQ Q_Neg (Var sm') OR Var sl EQ Q_Ex (Var sm) AND Var sl' EQ Q_Ex (Var sm')))))))))))), LstSeqP s k (HPair x y)} ⊢ SubstAtomicP v u x y OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN k AND Var n IN k AND SeqSubstFormP v u (Var sm) (Var sm') s (Var m) AND SeqSubstFormP v u (Var sn) (Var sn') s (Var n) AND (x EQ Q_Disj (Var sm) (Var sn) AND y EQ Q_Disj (Var sm') (Var sn') OR x EQ Q_Neg (Var sm) AND y EQ Q_Neg (Var sm') OR x EQ Q_Ex (Var sm) AND y EQ Q_Ex (Var sm'))))))))› and 4 goals remain*) apply (rule cut_same [where A = "HPair x y EQ HPair (Var sl) (Var sl')"] (*‹⟦(?H::fm set) ⊢ HPair (x::tm) (y::tm) EQ HPair (Var (sl::name)) (Var (sl'::name)); insert (HPair x y EQ HPair (Var sl) (Var sl')) ?H ⊢ (?B::fm)⟧ ⟹ ?H ⊢ ?B›*)) (*goals: 1. ‹⟦atom l ♯ (v, u, x, y, s, k, sl, sl', m, n, sm, sm', sn, sn'); atom sl ♯ (v, u, x, y, s, k, sl', m, n, sm, sm', sn, sn'); atom sl' ♯ (v, u, x, y, s, k, m, n, sm, sm', sn, sn'); atom m ♯ (v, u, x, y, s, k, n, sm, sm', sn, sn'); atom n ♯ (v, u, x, y, s, k, sm, sm', sn, sn'); atom sm ♯ (v, u, x, y, s, k, sm', sn, sn'); atom sm' ♯ (v, u, x, y, s, k, sn, sn'); atom sn ♯ (v, u, x, y, s, k, sn'); atom sn' ♯ (v, u, x, y, s, k)⟧ ⟹ {HPair k (HPair (Var sl) (Var sl')) IN s, SubstAtomicP v u (Var sl) (Var sl') OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN k AND Var n IN k AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND (Var sl EQ Q_Disj (Var sm) (Var sn) AND Var sl' EQ Q_Disj (Var sm') (Var sn') OR Var sl EQ Q_Neg (Var sm) AND Var sl' EQ Q_Neg (Var sm') OR Var sl EQ Q_Ex (Var sm) AND Var sl' EQ Q_Ex (Var sm')))))))), All2 l k (SyntaxN.Ex sl (SyntaxN.Ex sl' (HPair (Var l) (HPair (Var sl) (Var sl')) IN s AND (SubstAtomicP v u (Var sl) (Var sl') OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN Var l AND Var n IN Var l AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND (Var sl EQ Q_Disj (Var sm) (Var sn) AND Var sl' EQ Q_Disj (Var sm') (Var sn') OR Var sl EQ Q_Neg (Var sm) AND Var sl' EQ Q_Neg (Var sm') OR Var sl EQ Q_Ex (Var sm) AND Var sl' EQ Q_Ex (Var sm')))))))))))), LstSeqP s k (HPair x y)} ⊢ HPair x y EQ HPair (Var sl) (Var sl')› 2. ‹⟦atom l ♯ (v, u, x, y, s, k, sl, sl', m, n, sm, sm', sn, sn'); atom sl ♯ (v, u, x, y, s, k, sl', m, n, sm, sm', sn, sn'); atom sl' ♯ (v, u, x, y, s, k, m, n, sm, sm', sn, sn'); atom m ♯ (v, u, x, y, s, k, n, sm, sm', sn, sn'); atom n ♯ (v, u, x, y, s, k, sm, sm', sn, sn'); atom sm ♯ (v, u, x, y, s, k, sm', sn, sn'); atom sm' ♯ (v, u, x, y, s, k, sn, sn'); atom sn ♯ (v, u, x, y, s, k, sn'); atom sn' ♯ (v, u, x, y, s, k)⟧ ⟹ {HPair x y EQ HPair (Var sl) (Var sl'), HPair k (HPair (Var sl) (Var sl')) IN s, SubstAtomicP v u (Var sl) (Var sl') OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN k AND Var n IN k AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND (Var sl EQ Q_Disj (Var sm) (Var sn) AND Var sl' EQ Q_Disj (Var sm') (Var sn') OR Var sl EQ Q_Neg (Var sm) AND Var sl' EQ Q_Neg (Var sm') OR Var sl EQ Q_Ex (Var sm) AND Var sl' EQ Q_Ex (Var sm')))))))), All2 l k (SyntaxN.Ex sl (SyntaxN.Ex sl' (HPair (Var l) (HPair (Var sl) (Var sl')) IN s AND (SubstAtomicP v u (Var sl) (Var sl') OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN Var l AND Var n IN Var l AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND (Var sl EQ Q_Disj (Var sm) (Var sn) AND Var sl' EQ Q_Disj (Var sm') (Var sn') OR Var sl EQ Q_Neg (Var sm) AND Var sl' EQ Q_Neg (Var sm') OR Var sl EQ Q_Ex (Var sm) AND Var sl' EQ Q_Ex (Var sm')))))))))))), LstSeqP s k (HPair x y)} ⊢ SubstAtomicP v u x y OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN k AND Var n IN k AND SeqSubstFormP v u (Var sm) (Var sm') s (Var m) AND SeqSubstFormP v u (Var sn) (Var sn') s (Var n) AND (x EQ Q_Disj (Var sm) (Var sn) AND y EQ Q_Disj (Var sm') (Var sn') OR x EQ Q_Neg (Var sm) AND y EQ Q_Neg (Var sm') OR x EQ Q_Ex (Var sm) AND y EQ Q_Ex (Var sm'))))))))› discuss goal 1*) apply (metis Assume (*‹insert (?A::fm) (?H::fm set) ⊢ ?A›*) AssumeH( (*‹insert (?A1.0::fm) (insert (?A2.0::fm) (insert (?A3.0::fm) (insert (?A4.0::fm) (?H::fm set)))) ⊢ ?A4.0›*) 4) LstSeqP_EQ (*‹⟦(?H::fm set) ⊢ LstSeqP (?s::tm) (?k::tm) (?y::tm); ?H ⊢ HPair ?k (?y'::tm) IN ?s⟧ ⟹ ?H ⊢ ?y EQ ?y'›*)) (*discuss goal 2*) apply clarify (*top goal: ‹⟦atom (l::name) ♯ (v::tm, u::tm, x::tm, y::tm, s::tm, k::tm, sl::name, sl'::name, m::name, n::name, sm::name, sm'::name, sn::name, sn'::name); atom sl ♯ (v, u, x, y, s, k, sl', m, n, sm, sm', sn, sn'); atom sl' ♯ (v, u, x, y, s, k, m, n, sm, sm', sn, sn'); atom m ♯ (v, u, x, y, s, k, n, sm, sm', sn, sn'); atom n ♯ (v, u, x, y, s, k, sm, sm', sn, sn'); atom sm ♯ (v, u, x, y, s, k, sm', sn, sn'); atom sm' ♯ (v, u, x, y, s, k, sn, sn'); atom sn ♯ (v, u, x, y, s, k, sn'); atom sn' ♯ (v, u, x, y, s, k)⟧ ⟹ {HPair x y EQ HPair (Var sl) (Var sl'), HPair k (HPair (Var sl) (Var sl')) IN s, SubstAtomicP v u (Var sl) (Var sl') OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN k AND Var n IN k AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND (Var sl EQ Q_Disj (Var sm) (Var sn) AND Var sl' EQ Q_Disj (Var sm') (Var sn') OR Var sl EQ Q_Neg (Var sm) AND Var sl' EQ Q_Neg (Var sm') OR Var sl EQ Q_Ex (Var sm) AND Var sl' EQ Q_Ex (Var sm')))))))), All2 l k (SyntaxN.Ex sl (SyntaxN.Ex sl' (HPair (Var l) (HPair (Var sl) (Var sl')) IN s AND (SubstAtomicP v u (Var sl) (Var sl') OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN Var l AND Var n IN Var l AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND (Var sl EQ Q_Disj (Var sm) (Var sn) AND Var sl' EQ Q_Disj (Var sm') (Var sn') OR Var sl EQ Q_Neg (Var sm) AND Var sl' EQ Q_Neg (Var sm') OR Var sl EQ Q_Ex (Var sm) AND Var sl' EQ Q_Ex (Var sm')))))))))))), LstSeqP s k (HPair x y)} ⊢ SubstAtomicP v u x y OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN k AND Var n IN k AND SeqSubstFormP v u (Var sm) (Var sm') s (Var m) AND SeqSubstFormP v u (Var sn) (Var sn') s (Var n) AND (x EQ Q_Disj (Var sm) (Var sn) AND y EQ Q_Disj (Var sm') (Var sn') OR x EQ Q_Neg (Var sm) AND y EQ Q_Neg (Var sm') OR x EQ Q_Ex (Var sm) AND y EQ Q_Ex (Var sm'))))))))› and 4 goals remain*) apply (rule Disj_EH (*‹⟦insert (?A::fm) (?H::fm set) ⊢ (?C::fm); insert (?B::fm) ?H ⊢ ?C⟧ ⟹ insert (?A OR ?B) ?H ⊢ ?C› ‹⟦insert (?A::fm) (insert (?A1.0::fm) (?H::fm set)) ⊢ (?B::fm); insert (?Ba::fm) (insert ?A1.0 ?H) ⊢ ?B⟧ ⟹ insert ?A1.0 (insert (?A OR ?Ba) ?H) ⊢ ?B› ‹⟦insert (?A::fm) (insert (?A1.0::fm) (insert (?A2.0::fm) (?H::fm set))) ⊢ (?B::fm); insert (?Ba::fm) (insert ?A1.0 (insert ?A2.0 ?H)) ⊢ ?B⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert (?A OR ?Ba) ?H)) ⊢ ?B› ‹⟦insert (?A::fm) (insert (?A1.0::fm) (insert (?A2.0::fm) (insert (?A3.0::fm) (?H::fm set)))) ⊢ (?B::fm); insert (?Ba::fm) (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 ?H))) ⊢ ?B⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert (?A OR ?Ba) ?H))) ⊢ ?B› ‹⟦insert (?A::fm) (insert (?A1.0::fm) (insert (?A2.0::fm) (insert (?A3.0::fm) (insert (?A4.0::fm) (?H::fm set))))) ⊢ (?B::fm); insert (?Ba::fm) (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 ?H)))) ⊢ ?B⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert (?A OR ?Ba) ?H)))) ⊢ ?B› ‹⟦insert (?A::fm) (insert (?A1.0::fm) (insert (?A2.0::fm) (insert (?A3.0::fm) (insert (?A4.0::fm) (insert (?A5.0::fm) (?H::fm set)))))) ⊢ (?B::fm); insert (?Ba::fm) (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 ?H))))) ⊢ ?B⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert (?A OR ?Ba) ?H))))) ⊢ ?B› ‹⟦insert (?A::fm) (insert (?A1.0::fm) (insert (?A2.0::fm) (insert (?A3.0::fm) (insert (?A4.0::fm) (insert (?A5.0::fm) (insert (?A6.0::fm) (?H::fm set))))))) ⊢ (?B::fm); insert (?Ba::fm) (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 ?H)))))) ⊢ ?B⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert (?A OR ?Ba) ?H)))))) ⊢ ?B› ‹⟦insert (?A::fm) (insert (?A1.0::fm) (insert (?A2.0::fm) (insert (?A3.0::fm) (insert (?A4.0::fm) (insert (?A5.0::fm) (insert (?A6.0::fm) (insert (?A7.0::fm) (?H::fm set)))))))) ⊢ (?B::fm); insert (?Ba::fm) (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 ?H))))))) ⊢ ?B⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 (insert (?A OR ?Ba) ?H))))))) ⊢ ?B› ‹⟦insert (?A::fm) (insert (?A1.0::fm) (insert (?A2.0::fm) (insert (?A3.0::fm) (insert (?A4.0::fm) (insert (?A5.0::fm) (insert (?A6.0::fm) (insert (?A7.0::fm) (insert (?A8.0::fm) (?H::fm set))))))))) ⊢ (?B::fm); insert (?Ba::fm) (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)))))))) ⊢ ?B⟧ ⟹ 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 (?A OR ?Ba) ?H)))))))) ⊢ ?B› ‹⟦insert (?A::fm) (insert (?A1.0::fm) (insert (?A2.0::fm) (insert (?A3.0::fm) (insert (?A4.0::fm) (insert (?A5.0::fm) (insert (?A6.0::fm) (insert (?A7.0::fm) (insert (?A8.0::fm) (insert (?A9.0::fm) (?H::fm set)))))))))) ⊢ (?B::fm); insert (?Ba::fm) (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))))))))) ⊢ ?B⟧ ⟹ 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 (?A OR ?Ba) ?H))))))))) ⊢ ?B›*)) (*goals: 1. ‹⟦atom l ♯ (v, u, x, y, s, k, sl, sl', m, n, sm, sm', sn, sn'); atom sl ♯ (v, u, x, y, s, k, sl', m, n, sm, sm', sn, sn'); atom sl' ♯ (v, u, x, y, s, k, m, n, sm, sm', sn, sn'); atom m ♯ (v, u, x, y, s, k, n, sm, sm', sn, sn'); atom n ♯ (v, u, x, y, s, k, sm, sm', sn, sn'); atom sm ♯ (v, u, x, y, s, k, sm', sn, sn'); atom sm' ♯ (v, u, x, y, s, k, sn, sn'); atom sn ♯ (v, u, x, y, s, k, sn'); atom sn' ♯ (v, u, x, y, s, k)⟧ ⟹ {SubstAtomicP v u (Var sl) (Var sl'), x EQ Var sl, y EQ Var sl', HPair k (HPair (Var sl) (Var sl')) IN s, All2 l k (SyntaxN.Ex sl (SyntaxN.Ex sl' (HPair (Var l) (HPair (Var sl) (Var sl')) IN s AND (SubstAtomicP v u (Var sl) (Var sl') OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN Var l AND Var n IN Var l AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND (Var sl EQ Q_Disj (Var sm) (Var sn) AND Var sl' EQ Q_Disj (Var sm') (Var sn') OR Var sl EQ Q_Neg (Var sm) AND Var sl' EQ Q_Neg (Var sm') OR Var sl EQ Q_Ex (Var sm) AND Var sl' EQ Q_Ex (Var sm')))))))))))), LstSeqP s k (HPair x y)} ⊢ SubstAtomicP v u x y OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN k AND Var n IN k AND SeqSubstFormP v u (Var sm) (Var sm') s (Var m) AND SeqSubstFormP v u (Var sn) (Var sn') s (Var n) AND (x EQ Q_Disj (Var sm) (Var sn) AND y EQ Q_Disj (Var sm') (Var sn') OR x EQ Q_Neg (Var sm) AND y EQ Q_Neg (Var sm') OR x EQ Q_Ex (Var sm) AND y EQ Q_Ex (Var sm'))))))))› 2. ‹⟦atom l ♯ (v, u, x, y, s, k, sl, sl', m, n, sm, sm', sn, sn'); atom sl ♯ (v, u, x, y, s, k, sl', m, n, sm, sm', sn, sn'); atom sl' ♯ (v, u, x, y, s, k, m, n, sm, sm', sn, sn'); atom m ♯ (v, u, x, y, s, k, n, sm, sm', sn, sn'); atom n ♯ (v, u, x, y, s, k, sm, sm', sn, sn'); atom sm ♯ (v, u, x, y, s, k, sm', sn, sn'); atom sm' ♯ (v, u, x, y, s, k, sn, sn'); atom sn ♯ (v, u, x, y, s, k, sn'); atom sn' ♯ (v, u, x, y, s, k)⟧ ⟹ {SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN k AND Var n IN k AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND (Var sl EQ Q_Disj (Var sm) (Var sn) AND Var sl' EQ Q_Disj (Var sm') (Var sn') OR Var sl EQ Q_Neg (Var sm) AND Var sl' EQ Q_Neg (Var sm') OR Var sl EQ Q_Ex (Var sm) AND Var sl' EQ Q_Ex (Var sm')))))))), x EQ Var sl, y EQ Var sl', HPair k (HPair (Var sl) (Var sl')) IN s, All2 l k (SyntaxN.Ex sl (SyntaxN.Ex sl' (HPair (Var l) (HPair (Var sl) (Var sl')) IN s AND (SubstAtomicP v u (Var sl) (Var sl') OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN Var l AND Var n IN Var l AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND (Var sl EQ Q_Disj (Var sm) (Var sn) AND Var sl' EQ Q_Disj (Var sm') (Var sn') OR Var sl EQ Q_Neg (Var sm) AND Var sl' EQ Q_Neg (Var sm') OR Var sl EQ Q_Ex (Var sm) AND Var sl' EQ Q_Ex (Var sm')))))))))))), LstSeqP s k (HPair x y)} ⊢ SubstAtomicP v u x y OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN k AND Var n IN k AND SeqSubstFormP v u (Var sm) (Var sm') s (Var m) AND SeqSubstFormP v u (Var sn) (Var sn') s (Var n) AND (x EQ Q_Disj (Var sm) (Var sn) AND y EQ Q_Disj (Var sm') (Var sn') OR x EQ Q_Neg (Var sm) AND y EQ Q_Neg (Var sm') OR x EQ Q_Ex (Var sm) AND y EQ Q_Ex (Var sm'))))))))› discuss goal 1*) apply (blast intro: Disj_I1 (*‹?H ⊢ ?A ⟹ ?H ⊢ ?A OR ?B›*) SubstAtomicP_cong [THEN Iff_MP2_same] (*‹⟦?H ⊢ ?v1 EQ ?v'1; ?H ⊢ ?tm1 EQ ?tm'1; ?H ⊢ ?x1 EQ ?x'1; ?H ⊢ ?y1 EQ ?y'1; ?H ⊢ SubstAtomicP ?v'1 ?tm'1 ?x'1 ?y'1⟧ ⟹ ?H ⊢ SubstAtomicP ?v1 ?tm1 ?x1 ?y1›*)) (*discuss goal 2*) apply (rule Ex_EH (*‹⟦insert (?A::fm) (?H::fm set) ⊢ (?B::fm); atom (?i::name) ♯ ?B; ∀C::fm∈?H. atom ?i ♯ C⟧ ⟹ insert (SyntaxN.Ex ?i ?A) ?H ⊢ ?B› ‹⟦insert (?A::fm) (insert (?A1.0::fm) (?H::fm set)) ⊢ (?B::fm); atom (?i::name) ♯ ?B; ∀C::fm∈insert ?A1.0 ?H. atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert (SyntaxN.Ex ?i ?A) ?H) ⊢ ?B› ‹⟦insert (?A::fm) (insert (?A1.0::fm) (insert (?A2.0::fm) (?H::fm set))) ⊢ (?B::fm); atom (?i::name) ♯ ?B; ∀C::fm∈insert ?A1.0 (insert ?A2.0 ?H). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert (SyntaxN.Ex ?i ?A) ?H)) ⊢ ?B› ‹⟦insert (?A::fm) (insert (?A1.0::fm) (insert (?A2.0::fm) (insert (?A3.0::fm) (?H::fm set)))) ⊢ (?B::fm); atom (?i::name) ♯ ?B; ∀C::fm∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 ?H)). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert (SyntaxN.Ex ?i ?A) ?H))) ⊢ ?B› ‹⟦insert (?A::fm) (insert (?A1.0::fm) (insert (?A2.0::fm) (insert (?A3.0::fm) (insert (?A4.0::fm) (?H::fm set))))) ⊢ (?B::fm); atom (?i::name) ♯ ?B; ∀C::fm∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 ?H))). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert (SyntaxN.Ex ?i ?A) ?H)))) ⊢ ?B› ‹⟦insert (?A::fm) (insert (?A1.0::fm) (insert (?A2.0::fm) (insert (?A3.0::fm) (insert (?A4.0::fm) (insert (?A5.0::fm) (?H::fm set)))))) ⊢ (?B::fm); atom (?i::name) ♯ ?B; ∀C::fm∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 ?H)))). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert (SyntaxN.Ex ?i ?A) ?H))))) ⊢ ?B› ‹⟦insert (?A::fm) (insert (?A1.0::fm) (insert (?A2.0::fm) (insert (?A3.0::fm) (insert (?A4.0::fm) (insert (?A5.0::fm) (insert (?A6.0::fm) (?H::fm set))))))) ⊢ (?B::fm); atom (?i::name) ♯ ?B; ∀C::fm∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 ?H))))). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert (SyntaxN.Ex ?i ?A) ?H)))))) ⊢ ?B› ‹⟦insert (?A::fm) (insert (?A1.0::fm) (insert (?A2.0::fm) (insert (?A3.0::fm) (insert (?A4.0::fm) (insert (?A5.0::fm) (insert (?A6.0::fm) (insert (?A7.0::fm) (?H::fm set)))))))) ⊢ (?B::fm); atom (?i::name) ♯ ?B; ∀C::fm∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 ?H)))))). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 (insert (SyntaxN.Ex ?i ?A) ?H))))))) ⊢ ?B› ‹⟦insert (?A::fm) (insert (?A1.0::fm) (insert (?A2.0::fm) (insert (?A3.0::fm) (insert (?A4.0::fm) (insert (?A5.0::fm) (insert (?A6.0::fm) (insert (?A7.0::fm) (insert (?A8.0::fm) (?H::fm set))))))))) ⊢ (?B::fm); atom (?i::name) ♯ ?B; ∀C::fm∈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))))))). atom ?i ♯ C⟧ ⟹ 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 (SyntaxN.Ex ?i ?A) ?H)))))))) ⊢ ?B› ‹⟦insert (?A::fm) (insert (?A1.0::fm) (insert (?A2.0::fm) (insert (?A3.0::fm) (insert (?A4.0::fm) (insert (?A5.0::fm) (insert (?A6.0::fm) (insert (?A7.0::fm) (insert (?A8.0::fm) (insert (?A9.0::fm) (?H::fm set)))))))))) ⊢ (?B::fm); atom (?i::name) ♯ ?B; ∀C::fm∈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)))))))). atom ?i ♯ C⟧ ⟹ 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 (SyntaxN.Ex ?i ?A) ?H))))))))) ⊢ ?B›*) Conj_EH (*‹insert (?A::fm) (insert (?B::fm) (?H::fm set)) ⊢ (?C::fm) ⟹ insert (?A AND ?B) ?H ⊢ ?C› ‹insert (?A::fm) (insert (?Ba::fm) (insert (?A1.0::fm) (?H::fm set))) ⊢ (?B::fm) ⟹ insert ?A1.0 (insert (?A AND ?Ba) ?H) ⊢ ?B› ‹insert (?A::fm) (insert (?Ba::fm) (insert (?A1.0::fm) (insert (?A2.0::fm) (?H::fm set)))) ⊢ (?B::fm) ⟹ insert ?A1.0 (insert ?A2.0 (insert (?A AND ?Ba) ?H)) ⊢ ?B› ‹insert (?A::fm) (insert (?Ba::fm) (insert (?A1.0::fm) (insert (?A2.0::fm) (insert (?A3.0::fm) (?H::fm set))))) ⊢ (?B::fm) ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert (?A AND ?Ba) ?H))) ⊢ ?B› ‹insert (?A::fm) (insert (?Ba::fm) (insert (?A1.0::fm) (insert (?A2.0::fm) (insert (?A3.0::fm) (insert (?A4.0::fm) (?H::fm set)))))) ⊢ (?B::fm) ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert (?A AND ?Ba) ?H)))) ⊢ ?B› ‹insert (?A::fm) (insert (?Ba::fm) (insert (?A1.0::fm) (insert (?A2.0::fm) (insert (?A3.0::fm) (insert (?A4.0::fm) (insert (?A5.0::fm) (?H::fm set))))))) ⊢ (?B::fm) ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert (?A AND ?Ba) ?H))))) ⊢ ?B› ‹insert (?A::fm) (insert (?Ba::fm) (insert (?A1.0::fm) (insert (?A2.0::fm) (insert (?A3.0::fm) (insert (?A4.0::fm) (insert (?A5.0::fm) (insert (?A6.0::fm) (?H::fm set)))))))) ⊢ (?B::fm) ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert (?A AND ?Ba) ?H)))))) ⊢ ?B› ‹insert (?A::fm) (insert (?Ba::fm) (insert (?A1.0::fm) (insert (?A2.0::fm) (insert (?A3.0::fm) (insert (?A4.0::fm) (insert (?A5.0::fm) (insert (?A6.0::fm) (insert (?A7.0::fm) (?H::fm set))))))))) ⊢ (?B::fm) ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 (insert (?A AND ?Ba) ?H))))))) ⊢ ?B› ‹insert (?A::fm) (insert (?Ba::fm) (insert (?A1.0::fm) (insert (?A2.0::fm) (insert (?A3.0::fm) (insert (?A4.0::fm) (insert (?A5.0::fm) (insert (?A6.0::fm) (insert (?A7.0::fm) (insert (?A8.0::fm) (?H::fm set)))))))))) ⊢ (?B::fm) ⟹ 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 (?A AND ?Ba) ?H)))))))) ⊢ ?B› ‹insert (?A::fm) (insert (?Ba::fm) (insert (?A1.0::fm) (insert (?A2.0::fm) (insert (?A3.0::fm) (insert (?A4.0::fm) (insert (?A5.0::fm) (insert (?A6.0::fm) (insert (?A7.0::fm) (insert (?A8.0::fm) (insert (?A9.0::fm) (?H::fm set))))))))))) ⊢ (?B::fm) ⟹ 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 (?A AND ?Ba) ?H))))))))) ⊢ ?B›*)) (*goals: 1. ‹⟦atom (l::name) ♯ (v::tm, u::tm, x::tm, y::tm, s::tm, k::tm, sl::name, sl'::name, m::name, n::name, sm::name, sm'::name, sn::name, sn'::name); atom sl ♯ (v, u, x, y, s, k, sl', m, n, sm, sm', sn, sn'); atom sl' ♯ (v, u, x, y, s, k, m, n, sm, sm', sn, sn'); atom m ♯ (v, u, x, y, s, k, n, sm, sm', sn, sn'); atom n ♯ (v, u, x, y, s, k, sm, sm', sn, sn'); atom sm ♯ (v, u, x, y, s, k, sm', sn, sn'); atom sm' ♯ (v, u, x, y, s, k, sn, sn'); atom sn ♯ (v, u, x, y, s, k, sn'); atom sn' ♯ (v, u, x, y, s, k)⟧ ⟹ {SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN k AND Var n IN k AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND (Var sl EQ Q_Disj (Var sm) (Var sn) AND Var sl' EQ Q_Disj (Var sm') (Var sn') OR Var sl EQ Q_Neg (Var sm) AND Var sl' EQ Q_Neg (Var sm') OR Var sl EQ Q_Ex (Var sm) AND Var sl' EQ Q_Ex (Var sm'))))))), x EQ Var sl, y EQ Var sl', HPair k (HPair (Var sl) (Var sl')) IN s, All2 l k (SyntaxN.Ex sl (SyntaxN.Ex sl' (HPair (Var l) (HPair (Var sl) (Var sl')) IN s AND (SubstAtomicP v u (Var sl) (Var sl') OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN Var l AND Var n IN Var l AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND (Var sl EQ Q_Disj (Var sm) (Var sn) AND Var sl' EQ Q_Disj (Var sm') (Var sn') OR Var sl EQ Q_Neg (Var sm) AND Var sl' EQ Q_Neg (Var sm') OR Var sl EQ Q_Ex (Var sm) AND Var sl' EQ Q_Ex (Var sm')))))))))))), LstSeqP s k (HPair x y)} ⊢ SubstAtomicP v u x y OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN k AND Var n IN k AND SeqSubstFormP v u (Var sm) (Var sm') s (Var m) AND SeqSubstFormP v u (Var sn) (Var sn') s (Var n) AND (x EQ Q_Disj (Var sm) (Var sn) AND y EQ Q_Disj (Var sm') (Var sn') OR x EQ Q_Neg (Var sm) AND y EQ Q_Neg (Var sm') OR x EQ Q_Ex (Var sm) AND y EQ Q_Ex (Var sm'))))))))› 2. ‹⟦atom (l::name) ♯ (v::tm, u::tm, x::tm, y::tm, s::tm, k::tm, sl::name, sl'::name, m::name, n::name, sm::name, sm'::name, sn::name, sn'::name); atom sl ♯ (v, u, x, y, s, k, sl', m, n, sm, sm', sn, sn'); atom sl' ♯ (v, u, x, y, s, k, m, n, sm, sm', sn, sn'); atom m ♯ (v, u, x, y, s, k, n, sm, sm', sn, sn'); atom n ♯ (v, u, x, y, s, k, sm, sm', sn, sn'); atom sm ♯ (v, u, x, y, s, k, sm', sn, sn'); atom sm' ♯ (v, u, x, y, s, k, sn, sn'); atom sn ♯ (v, u, x, y, s, k, sn'); atom sn' ♯ (v, u, x, y, s, k)⟧ ⟹ atom m ♯ SubstAtomicP v u x y OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN k AND Var n IN k AND SeqSubstFormP v u (Var sm) (Var sm') s (Var m) AND SeqSubstFormP v u (Var sn) (Var sn') s (Var n) AND (x EQ Q_Disj (Var sm) (Var sn) AND y EQ Q_Disj (Var sm') (Var sn') OR x EQ Q_Neg (Var sm) AND y EQ Q_Neg (Var sm') OR x EQ Q_Ex (Var sm) AND y EQ Q_Ex (Var sm'))))))))› 3. ‹⟦atom (l::name) ♯ (v::tm, u::tm, x::tm, y::tm, s::tm, k::tm, sl::name, sl'::name, m::name, n::name, sm::name, sm'::name, sn::name, sn'::name); atom sl ♯ (v, u, x, y, s, k, sl', m, n, sm, sm', sn, sn'); atom sl' ♯ (v, u, x, y, s, k, m, n, sm, sm', sn, sn'); atom m ♯ (v, u, x, y, s, k, n, sm, sm', sn, sn'); atom n ♯ (v, u, x, y, s, k, sm, sm', sn, sn'); atom sm ♯ (v, u, x, y, s, k, sm', sn, sn'); atom sm' ♯ (v, u, x, y, s, k, sn, sn'); atom sn ♯ (v, u, x, y, s, k, sn'); atom sn' ♯ (v, u, x, y, s, k)⟧ ⟹ ∀C::fm∈{x EQ Var sl, y EQ Var sl', HPair k (HPair (Var sl) (Var sl')) IN s, All2 l k (SyntaxN.Ex sl (SyntaxN.Ex sl' (HPair (Var l) (HPair (Var sl) (Var sl')) IN s AND (SubstAtomicP v u (Var sl) (Var sl') OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN Var l AND Var n IN Var l AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND (Var sl EQ Q_Disj (Var sm) (Var sn) AND Var sl' EQ Q_Disj (Var sm') (Var sn') OR Var sl EQ Q_Neg (Var sm) AND Var sl' EQ Q_Neg (Var sm') OR Var sl EQ Q_Ex (Var sm) AND Var sl' EQ Q_Ex (Var sm')))))))))))), LstSeqP s k (HPair x y)}. atom m ♯ C› discuss goal 1*) apply (rule Ex_EH (*‹⟦insert ?A ?H ⊢ ?B; atom ?i ♯ ?B; ∀C∈?H. atom ?i ♯ C⟧ ⟹ insert (SyntaxN.Ex ?i ?A) ?H ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 ?H) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 ?H. atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert (SyntaxN.Ex ?i ?A) ?H) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 ?H)) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 ?H). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert (SyntaxN.Ex ?i ?A) ?H)) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 ?H))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 ?H)). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert (SyntaxN.Ex ?i ?A) ?H))) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 ?H)))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 ?H))). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert (SyntaxN.Ex ?i ?A) ?H)))) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 ?H))))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 ?H)))). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert (SyntaxN.Ex ?i ?A) ?H))))) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 ?H)))))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 ?H))))). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert (SyntaxN.Ex ?i ?A) ?H)))))) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 ?H))))))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 ?H)))))). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 (insert (SyntaxN.Ex ?i ?A) ?H))))))) ⊢ ?B› ‹⟦insert ?A (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)))))))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈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))))))). atom ?i ♯ C⟧ ⟹ 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 (SyntaxN.Ex ?i ?A) ?H)))))))) ⊢ ?B› ‹⟦insert ?A (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))))))))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈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)))))))). atom ?i ♯ C⟧ ⟹ 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 (SyntaxN.Ex ?i ?A) ?H))))))))) ⊢ ?B›*) Conj_EH (*‹insert ?A (insert ?B ?H) ⊢ ?C ⟹ insert (?A AND ?B) ?H ⊢ ?C› ‹insert ?A (insert ?Ba (insert ?A1.0 ?H)) ⊢ ?B ⟹ insert ?A1.0 (insert (?A AND ?Ba) ?H) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 ?H))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert (?A AND ?Ba) ?H)) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 ?H)))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert (?A AND ?Ba) ?H))) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 ?H))))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert (?A AND ?Ba) ?H)))) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 ?H)))))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert (?A AND ?Ba) ?H))))) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 ?H))))))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert (?A AND ?Ba) ?H)))))) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 ?H)))))))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 (insert (?A AND ?Ba) ?H))))))) ⊢ ?B› ‹insert ?A (insert ?Ba (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))))))))) ⊢ ?B ⟹ 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 (?A AND ?Ba) ?H)))))))) ⊢ ?B› ‹insert ?A (insert ?Ba (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)))))))))) ⊢ ?B ⟹ 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 (?A AND ?Ba) ?H))))))))) ⊢ ?B›*)) (*goals: 1. ‹⟦atom l ♯ (v, u, x, y, s, k, sl, sl', m, n, sm, sm', sn, sn'); atom sl ♯ (v, u, x, y, s, k, sl', m, n, sm, sm', sn, sn'); atom sl' ♯ (v, u, x, y, s, k, m, n, sm, sm', sn, sn'); atom m ♯ (v, u, x, y, s, k, n, sm, sm', sn, sn'); atom n ♯ (v, u, x, y, s, k, sm, sm', sn, sn'); atom sm ♯ (v, u, x, y, s, k, sm', sn, sn'); atom sm' ♯ (v, u, x, y, s, k, sn, sn'); atom sn ♯ (v, u, x, y, s, k, sn'); atom sn' ♯ (v, u, x, y, s, k)⟧ ⟹ {SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN k AND Var n IN k AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND (Var sl EQ Q_Disj (Var sm) (Var sn) AND Var sl' EQ Q_Disj (Var sm') (Var sn') OR Var sl EQ Q_Neg (Var sm) AND Var sl' EQ Q_Neg (Var sm') OR Var sl EQ Q_Ex (Var sm) AND Var sl' EQ Q_Ex (Var sm')))))), x EQ Var sl, y EQ Var sl', HPair k (HPair (Var sl) (Var sl')) IN s, All2 l k (SyntaxN.Ex sl (SyntaxN.Ex sl' (HPair (Var l) (HPair (Var sl) (Var sl')) IN s AND (SubstAtomicP v u (Var sl) (Var sl') OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN Var l AND Var n IN Var l AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND (Var sl EQ Q_Disj (Var sm) (Var sn) AND Var sl' EQ Q_Disj (Var sm') (Var sn') OR Var sl EQ Q_Neg (Var sm) AND Var sl' EQ Q_Neg (Var sm') OR Var sl EQ Q_Ex (Var sm) AND Var sl' EQ Q_Ex (Var sm')))))))))))), LstSeqP s k (HPair x y)} ⊢ SubstAtomicP v u x y OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN k AND Var n IN k AND SeqSubstFormP v u (Var sm) (Var sm') s (Var m) AND SeqSubstFormP v u (Var sn) (Var sn') s (Var n) AND (x EQ Q_Disj (Var sm) (Var sn) AND y EQ Q_Disj (Var sm') (Var sn') OR x EQ Q_Neg (Var sm) AND y EQ Q_Neg (Var sm') OR x EQ Q_Ex (Var sm) AND y EQ Q_Ex (Var sm'))))))))› 2. ‹⟦atom l ♯ (v, u, x, y, s, k, sl, sl', m, n, sm, sm', sn, sn'); atom sl ♯ (v, u, x, y, s, k, sl', m, n, sm, sm', sn, sn'); atom sl' ♯ (v, u, x, y, s, k, m, n, sm, sm', sn, sn'); atom m ♯ (v, u, x, y, s, k, n, sm, sm', sn, sn'); atom n ♯ (v, u, x, y, s, k, sm, sm', sn, sn'); atom sm ♯ (v, u, x, y, s, k, sm', sn, sn'); atom sm' ♯ (v, u, x, y, s, k, sn, sn'); atom sn ♯ (v, u, x, y, s, k, sn'); atom sn' ♯ (v, u, x, y, s, k)⟧ ⟹ atom n ♯ SubstAtomicP v u x y OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN k AND Var n IN k AND SeqSubstFormP v u (Var sm) (Var sm') s (Var m) AND SeqSubstFormP v u (Var sn) (Var sn') s (Var n) AND (x EQ Q_Disj (Var sm) (Var sn) AND y EQ Q_Disj (Var sm') (Var sn') OR x EQ Q_Neg (Var sm) AND y EQ Q_Neg (Var sm') OR x EQ Q_Ex (Var sm) AND y EQ Q_Ex (Var sm'))))))))› 3. ‹⟦atom l ♯ (v, u, x, y, s, k, sl, sl', m, n, sm, sm', sn, sn'); atom sl ♯ (v, u, x, y, s, k, sl', m, n, sm, sm', sn, sn'); atom sl' ♯ (v, u, x, y, s, k, m, n, sm, sm', sn, sn'); atom m ♯ (v, u, x, y, s, k, n, sm, sm', sn, sn'); atom n ♯ (v, u, x, y, s, k, sm, sm', sn, sn'); atom sm ♯ (v, u, x, y, s, k, sm', sn, sn'); atom sm' ♯ (v, u, x, y, s, k, sn, sn'); atom sn ♯ (v, u, x, y, s, k, sn'); atom sn' ♯ (v, u, x, y, s, k)⟧ ⟹ ∀C∈{x EQ Var sl, y EQ Var sl', HPair k (HPair (Var sl) (Var sl')) IN s, All2 l k (SyntaxN.Ex sl (SyntaxN.Ex sl' (HPair (Var l) (HPair (Var sl) (Var sl')) IN s AND (SubstAtomicP v u (Var sl) (Var sl') OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN Var l AND Var n IN Var l AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND (Var sl EQ Q_Disj (Var sm) (Var sn) AND Var sl' EQ Q_Disj (Var sm') (Var sn') OR Var sl EQ Q_Neg (Var sm) AND Var sl' EQ Q_Neg (Var sm') OR Var sl EQ Q_Ex (Var sm) AND Var sl' EQ Q_Ex (Var sm')))))))))))), LstSeqP s k (HPair x y)}. atom n ♯ C› discuss goal 1*) apply (rule Ex_EH (*‹⟦insert ?A ?H ⊢ ?B; atom ?i ♯ ?B; ∀C∈?H. atom ?i ♯ C⟧ ⟹ insert (SyntaxN.Ex ?i ?A) ?H ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 ?H) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 ?H. atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert (SyntaxN.Ex ?i ?A) ?H) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 ?H)) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 ?H). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert (SyntaxN.Ex ?i ?A) ?H)) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 ?H))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 ?H)). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert (SyntaxN.Ex ?i ?A) ?H))) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 ?H)))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 ?H))). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert (SyntaxN.Ex ?i ?A) ?H)))) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 ?H))))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 ?H)))). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert (SyntaxN.Ex ?i ?A) ?H))))) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 ?H)))))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 ?H))))). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert (SyntaxN.Ex ?i ?A) ?H)))))) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 ?H))))))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 ?H)))))). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 (insert (SyntaxN.Ex ?i ?A) ?H))))))) ⊢ ?B› ‹⟦insert ?A (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)))))))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈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))))))). atom ?i ♯ C⟧ ⟹ 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 (SyntaxN.Ex ?i ?A) ?H)))))))) ⊢ ?B› ‹⟦insert ?A (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))))))))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈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)))))))). atom ?i ♯ C⟧ ⟹ 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 (SyntaxN.Ex ?i ?A) ?H))))))))) ⊢ ?B›*) Conj_EH (*‹insert ?A (insert ?B ?H) ⊢ ?C ⟹ insert (?A AND ?B) ?H ⊢ ?C› ‹insert ?A (insert ?Ba (insert ?A1.0 ?H)) ⊢ ?B ⟹ insert ?A1.0 (insert (?A AND ?Ba) ?H) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 ?H))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert (?A AND ?Ba) ?H)) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 ?H)))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert (?A AND ?Ba) ?H))) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 ?H))))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert (?A AND ?Ba) ?H)))) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 ?H)))))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert (?A AND ?Ba) ?H))))) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 ?H))))))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert (?A AND ?Ba) ?H)))))) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 ?H)))))))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 (insert (?A AND ?Ba) ?H))))))) ⊢ ?B› ‹insert ?A (insert ?Ba (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))))))))) ⊢ ?B ⟹ 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 (?A AND ?Ba) ?H)))))))) ⊢ ?B› ‹insert ?A (insert ?Ba (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)))))))))) ⊢ ?B ⟹ 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 (?A AND ?Ba) ?H))))))))) ⊢ ?B›*)) (*goals: 1. ‹⟦atom (l::name) ♯ (v::tm, u::tm, x::tm, y::tm, s::tm, k::tm, sl::name, sl'::name, m::name, n::name, sm::name, sm'::name, sn::name, sn'::name); atom sl ♯ (v, u, x, y, s, k, sl', m, n, sm, sm', sn, sn'); atom sl' ♯ (v, u, x, y, s, k, m, n, sm, sm', sn, sn'); atom m ♯ (v, u, x, y, s, k, n, sm, sm', sn, sn'); atom n ♯ (v, u, x, y, s, k, sm, sm', sn, sn'); atom sm ♯ (v, u, x, y, s, k, sm', sn, sn'); atom sm' ♯ (v, u, x, y, s, k, sn, sn'); atom sn ♯ (v, u, x, y, s, k, sn'); atom sn' ♯ (v, u, x, y, s, k)⟧ ⟹ {SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN k AND Var n IN k AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND (Var sl EQ Q_Disj (Var sm) (Var sn) AND Var sl' EQ Q_Disj (Var sm') (Var sn') OR Var sl EQ Q_Neg (Var sm) AND Var sl' EQ Q_Neg (Var sm') OR Var sl EQ Q_Ex (Var sm) AND Var sl' EQ Q_Ex (Var sm'))))), x EQ Var sl, y EQ Var sl', HPair k (HPair (Var sl) (Var sl')) IN s, All2 l k (SyntaxN.Ex sl (SyntaxN.Ex sl' (HPair (Var l) (HPair (Var sl) (Var sl')) IN s AND (SubstAtomicP v u (Var sl) (Var sl') OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN Var l AND Var n IN Var l AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND (Var sl EQ Q_Disj (Var sm) (Var sn) AND Var sl' EQ Q_Disj (Var sm') (Var sn') OR Var sl EQ Q_Neg (Var sm) AND Var sl' EQ Q_Neg (Var sm') OR Var sl EQ Q_Ex (Var sm) AND Var sl' EQ Q_Ex (Var sm')))))))))))), LstSeqP s k (HPair x y)} ⊢ SubstAtomicP v u x y OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN k AND Var n IN k AND SeqSubstFormP v u (Var sm) (Var sm') s (Var m) AND SeqSubstFormP v u (Var sn) (Var sn') s (Var n) AND (x EQ Q_Disj (Var sm) (Var sn) AND y EQ Q_Disj (Var sm') (Var sn') OR x EQ Q_Neg (Var sm) AND y EQ Q_Neg (Var sm') OR x EQ Q_Ex (Var sm) AND y EQ Q_Ex (Var sm'))))))))› 2. ‹⟦atom (l::name) ♯ (v::tm, u::tm, x::tm, y::tm, s::tm, k::tm, sl::name, sl'::name, m::name, n::name, sm::name, sm'::name, sn::name, sn'::name); atom sl ♯ (v, u, x, y, s, k, sl', m, n, sm, sm', sn, sn'); atom sl' ♯ (v, u, x, y, s, k, m, n, sm, sm', sn, sn'); atom m ♯ (v, u, x, y, s, k, n, sm, sm', sn, sn'); atom n ♯ (v, u, x, y, s, k, sm, sm', sn, sn'); atom sm ♯ (v, u, x, y, s, k, sm', sn, sn'); atom sm' ♯ (v, u, x, y, s, k, sn, sn'); atom sn ♯ (v, u, x, y, s, k, sn'); atom sn' ♯ (v, u, x, y, s, k)⟧ ⟹ atom sm ♯ SubstAtomicP v u x y OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN k AND Var n IN k AND SeqSubstFormP v u (Var sm) (Var sm') s (Var m) AND SeqSubstFormP v u (Var sn) (Var sn') s (Var n) AND (x EQ Q_Disj (Var sm) (Var sn) AND y EQ Q_Disj (Var sm') (Var sn') OR x EQ Q_Neg (Var sm) AND y EQ Q_Neg (Var sm') OR x EQ Q_Ex (Var sm) AND y EQ Q_Ex (Var sm'))))))))› 3. ‹⟦atom (l::name) ♯ (v::tm, u::tm, x::tm, y::tm, s::tm, k::tm, sl::name, sl'::name, m::name, n::name, sm::name, sm'::name, sn::name, sn'::name); atom sl ♯ (v, u, x, y, s, k, sl', m, n, sm, sm', sn, sn'); atom sl' ♯ (v, u, x, y, s, k, m, n, sm, sm', sn, sn'); atom m ♯ (v, u, x, y, s, k, n, sm, sm', sn, sn'); atom n ♯ (v, u, x, y, s, k, sm, sm', sn, sn'); atom sm ♯ (v, u, x, y, s, k, sm', sn, sn'); atom sm' ♯ (v, u, x, y, s, k, sn, sn'); atom sn ♯ (v, u, x, y, s, k, sn'); atom sn' ♯ (v, u, x, y, s, k)⟧ ⟹ ∀C::fm∈{x EQ Var sl, y EQ Var sl', HPair k (HPair (Var sl) (Var sl')) IN s, All2 l k (SyntaxN.Ex sl (SyntaxN.Ex sl' (HPair (Var l) (HPair (Var sl) (Var sl')) IN s AND (SubstAtomicP v u (Var sl) (Var sl') OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN Var l AND Var n IN Var l AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND (Var sl EQ Q_Disj (Var sm) (Var sn) AND Var sl' EQ Q_Disj (Var sm') (Var sn') OR Var sl EQ Q_Neg (Var sm) AND Var sl' EQ Q_Neg (Var sm') OR Var sl EQ Q_Ex (Var sm) AND Var sl' EQ Q_Ex (Var sm')))))))))))), LstSeqP s k (HPair x y)}. atom sm ♯ C› discuss goal 1*) apply (rule Ex_EH (*‹⟦insert ?A ?H ⊢ ?B; atom ?i ♯ ?B; ∀C∈?H. atom ?i ♯ C⟧ ⟹ insert (SyntaxN.Ex ?i ?A) ?H ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 ?H) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 ?H. atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert (SyntaxN.Ex ?i ?A) ?H) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 ?H)) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 ?H). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert (SyntaxN.Ex ?i ?A) ?H)) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 ?H))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 ?H)). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert (SyntaxN.Ex ?i ?A) ?H))) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 ?H)))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 ?H))). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert (SyntaxN.Ex ?i ?A) ?H)))) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 ?H))))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 ?H)))). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert (SyntaxN.Ex ?i ?A) ?H))))) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 ?H)))))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 ?H))))). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert (SyntaxN.Ex ?i ?A) ?H)))))) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 ?H))))))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 ?H)))))). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 (insert (SyntaxN.Ex ?i ?A) ?H))))))) ⊢ ?B› ‹⟦insert ?A (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)))))))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈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))))))). atom ?i ♯ C⟧ ⟹ 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 (SyntaxN.Ex ?i ?A) ?H)))))))) ⊢ ?B› ‹⟦insert ?A (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))))))))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈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)))))))). atom ?i ♯ C⟧ ⟹ 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 (SyntaxN.Ex ?i ?A) ?H))))))))) ⊢ ?B›*) Conj_EH (*‹insert ?A (insert ?B ?H) ⊢ ?C ⟹ insert (?A AND ?B) ?H ⊢ ?C› ‹insert ?A (insert ?Ba (insert ?A1.0 ?H)) ⊢ ?B ⟹ insert ?A1.0 (insert (?A AND ?Ba) ?H) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 ?H))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert (?A AND ?Ba) ?H)) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 ?H)))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert (?A AND ?Ba) ?H))) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 ?H))))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert (?A AND ?Ba) ?H)))) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 ?H)))))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert (?A AND ?Ba) ?H))))) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 ?H))))))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert (?A AND ?Ba) ?H)))))) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 ?H)))))))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 (insert (?A AND ?Ba) ?H))))))) ⊢ ?B› ‹insert ?A (insert ?Ba (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))))))))) ⊢ ?B ⟹ 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 (?A AND ?Ba) ?H)))))))) ⊢ ?B› ‹insert ?A (insert ?Ba (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)))))))))) ⊢ ?B ⟹ 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 (?A AND ?Ba) ?H))))))))) ⊢ ?B›*)) (*goals: 1. ‹⟦atom l ♯ (v, u, x, y, s, k, sl, sl', m, n, sm, sm', sn, sn'); atom sl ♯ (v, u, x, y, s, k, sl', m, n, sm, sm', sn, sn'); atom sl' ♯ (v, u, x, y, s, k, m, n, sm, sm', sn, sn'); atom m ♯ (v, u, x, y, s, k, n, sm, sm', sn, sn'); atom n ♯ (v, u, x, y, s, k, sm, sm', sn, sn'); atom sm ♯ (v, u, x, y, s, k, sm', sn, sn'); atom sm' ♯ (v, u, x, y, s, k, sn, sn'); atom sn ♯ (v, u, x, y, s, k, sn'); atom sn' ♯ (v, u, x, y, s, k)⟧ ⟹ {SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN k AND Var n IN k AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND (Var sl EQ Q_Disj (Var sm) (Var sn) AND Var sl' EQ Q_Disj (Var sm') (Var sn') OR Var sl EQ Q_Neg (Var sm) AND Var sl' EQ Q_Neg (Var sm') OR Var sl EQ Q_Ex (Var sm) AND Var sl' EQ Q_Ex (Var sm')))), x EQ Var sl, y EQ Var sl', HPair k (HPair (Var sl) (Var sl')) IN s, All2 l k (SyntaxN.Ex sl (SyntaxN.Ex sl' (HPair (Var l) (HPair (Var sl) (Var sl')) IN s AND (SubstAtomicP v u (Var sl) (Var sl') OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN Var l AND Var n IN Var l AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND (Var sl EQ Q_Disj (Var sm) (Var sn) AND Var sl' EQ Q_Disj (Var sm') (Var sn') OR Var sl EQ Q_Neg (Var sm) AND Var sl' EQ Q_Neg (Var sm') OR Var sl EQ Q_Ex (Var sm) AND Var sl' EQ Q_Ex (Var sm')))))))))))), LstSeqP s k (HPair x y)} ⊢ SubstAtomicP v u x y OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN k AND Var n IN k AND SeqSubstFormP v u (Var sm) (Var sm') s (Var m) AND SeqSubstFormP v u (Var sn) (Var sn') s (Var n) AND (x EQ Q_Disj (Var sm) (Var sn) AND y EQ Q_Disj (Var sm') (Var sn') OR x EQ Q_Neg (Var sm) AND y EQ Q_Neg (Var sm') OR x EQ Q_Ex (Var sm) AND y EQ Q_Ex (Var sm'))))))))› 2. ‹⟦atom l ♯ (v, u, x, y, s, k, sl, sl', m, n, sm, sm', sn, sn'); atom sl ♯ (v, u, x, y, s, k, sl', m, n, sm, sm', sn, sn'); atom sl' ♯ (v, u, x, y, s, k, m, n, sm, sm', sn, sn'); atom m ♯ (v, u, x, y, s, k, n, sm, sm', sn, sn'); atom n ♯ (v, u, x, y, s, k, sm, sm', sn, sn'); atom sm ♯ (v, u, x, y, s, k, sm', sn, sn'); atom sm' ♯ (v, u, x, y, s, k, sn, sn'); atom sn ♯ (v, u, x, y, s, k, sn'); atom sn' ♯ (v, u, x, y, s, k)⟧ ⟹ atom sm' ♯ SubstAtomicP v u x y OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN k AND Var n IN k AND SeqSubstFormP v u (Var sm) (Var sm') s (Var m) AND SeqSubstFormP v u (Var sn) (Var sn') s (Var n) AND (x EQ Q_Disj (Var sm) (Var sn) AND y EQ Q_Disj (Var sm') (Var sn') OR x EQ Q_Neg (Var sm) AND y EQ Q_Neg (Var sm') OR x EQ Q_Ex (Var sm) AND y EQ Q_Ex (Var sm'))))))))› 3. ‹⟦atom l ♯ (v, u, x, y, s, k, sl, sl', m, n, sm, sm', sn, sn'); atom sl ♯ (v, u, x, y, s, k, sl', m, n, sm, sm', sn, sn'); atom sl' ♯ (v, u, x, y, s, k, m, n, sm, sm', sn, sn'); atom m ♯ (v, u, x, y, s, k, n, sm, sm', sn, sn'); atom n ♯ (v, u, x, y, s, k, sm, sm', sn, sn'); atom sm ♯ (v, u, x, y, s, k, sm', sn, sn'); atom sm' ♯ (v, u, x, y, s, k, sn, sn'); atom sn ♯ (v, u, x, y, s, k, sn'); atom sn' ♯ (v, u, x, y, s, k)⟧ ⟹ ∀C∈{x EQ Var sl, y EQ Var sl', HPair k (HPair (Var sl) (Var sl')) IN s, All2 l k (SyntaxN.Ex sl (SyntaxN.Ex sl' (HPair (Var l) (HPair (Var sl) (Var sl')) IN s AND (SubstAtomicP v u (Var sl) (Var sl') OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN Var l AND Var n IN Var l AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND (Var sl EQ Q_Disj (Var sm) (Var sn) AND Var sl' EQ Q_Disj (Var sm') (Var sn') OR Var sl EQ Q_Neg (Var sm) AND Var sl' EQ Q_Neg (Var sm') OR Var sl EQ Q_Ex (Var sm) AND Var sl' EQ Q_Ex (Var sm')))))))))))), LstSeqP s k (HPair x y)}. atom sm' ♯ C› discuss goal 1*) apply (rule Ex_EH (*‹⟦insert ?A ?H ⊢ ?B; atom ?i ♯ ?B; ∀C∈?H. atom ?i ♯ C⟧ ⟹ insert (SyntaxN.Ex ?i ?A) ?H ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 ?H) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 ?H. atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert (SyntaxN.Ex ?i ?A) ?H) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 ?H)) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 ?H). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert (SyntaxN.Ex ?i ?A) ?H)) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 ?H))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 ?H)). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert (SyntaxN.Ex ?i ?A) ?H))) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 ?H)))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 ?H))). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert (SyntaxN.Ex ?i ?A) ?H)))) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 ?H))))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 ?H)))). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert (SyntaxN.Ex ?i ?A) ?H))))) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 ?H)))))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 ?H))))). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert (SyntaxN.Ex ?i ?A) ?H)))))) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 ?H))))))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 ?H)))))). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 (insert (SyntaxN.Ex ?i ?A) ?H))))))) ⊢ ?B› ‹⟦insert ?A (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)))))))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈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))))))). atom ?i ♯ C⟧ ⟹ 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 (SyntaxN.Ex ?i ?A) ?H)))))))) ⊢ ?B› ‹⟦insert ?A (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))))))))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈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)))))))). atom ?i ♯ C⟧ ⟹ 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 (SyntaxN.Ex ?i ?A) ?H))))))))) ⊢ ?B›*) Conj_EH (*‹insert ?A (insert ?B ?H) ⊢ ?C ⟹ insert (?A AND ?B) ?H ⊢ ?C› ‹insert ?A (insert ?Ba (insert ?A1.0 ?H)) ⊢ ?B ⟹ insert ?A1.0 (insert (?A AND ?Ba) ?H) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 ?H))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert (?A AND ?Ba) ?H)) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 ?H)))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert (?A AND ?Ba) ?H))) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 ?H))))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert (?A AND ?Ba) ?H)))) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 ?H)))))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert (?A AND ?Ba) ?H))))) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 ?H))))))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert (?A AND ?Ba) ?H)))))) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 ?H)))))))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 (insert (?A AND ?Ba) ?H))))))) ⊢ ?B› ‹insert ?A (insert ?Ba (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))))))))) ⊢ ?B ⟹ 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 (?A AND ?Ba) ?H)))))))) ⊢ ?B› ‹insert ?A (insert ?Ba (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)))))))))) ⊢ ?B ⟹ 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 (?A AND ?Ba) ?H))))))))) ⊢ ?B›*)) (*goals: 1. ‹⟦atom (l::name) ♯ (v::tm, u::tm, x::tm, y::tm, s::tm, k::tm, sl::name, sl'::name, m::name, n::name, sm::name, sm'::name, sn::name, sn'::name); atom sl ♯ (v, u, x, y, s, k, sl', m, n, sm, sm', sn, sn'); atom sl' ♯ (v, u, x, y, s, k, m, n, sm, sm', sn, sn'); atom m ♯ (v, u, x, y, s, k, n, sm, sm', sn, sn'); atom n ♯ (v, u, x, y, s, k, sm, sm', sn, sn'); atom sm ♯ (v, u, x, y, s, k, sm', sn, sn'); atom sm' ♯ (v, u, x, y, s, k, sn, sn'); atom sn ♯ (v, u, x, y, s, k, sn'); atom sn' ♯ (v, u, x, y, s, k)⟧ ⟹ {SyntaxN.Ex sn' (Var m IN k AND Var n IN k AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND (Var sl EQ Q_Disj (Var sm) (Var sn) AND Var sl' EQ Q_Disj (Var sm') (Var sn') OR Var sl EQ Q_Neg (Var sm) AND Var sl' EQ Q_Neg (Var sm') OR Var sl EQ Q_Ex (Var sm) AND Var sl' EQ Q_Ex (Var sm'))), x EQ Var sl, y EQ Var sl', HPair k (HPair (Var sl) (Var sl')) IN s, All2 l k (SyntaxN.Ex sl (SyntaxN.Ex sl' (HPair (Var l) (HPair (Var sl) (Var sl')) IN s AND (SubstAtomicP v u (Var sl) (Var sl') OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN Var l AND Var n IN Var l AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND (Var sl EQ Q_Disj (Var sm) (Var sn) AND Var sl' EQ Q_Disj (Var sm') (Var sn') OR Var sl EQ Q_Neg (Var sm) AND Var sl' EQ Q_Neg (Var sm') OR Var sl EQ Q_Ex (Var sm) AND Var sl' EQ Q_Ex (Var sm')))))))))))), LstSeqP s k (HPair x y)} ⊢ SubstAtomicP v u x y OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN k AND Var n IN k AND SeqSubstFormP v u (Var sm) (Var sm') s (Var m) AND SeqSubstFormP v u (Var sn) (Var sn') s (Var n) AND (x EQ Q_Disj (Var sm) (Var sn) AND y EQ Q_Disj (Var sm') (Var sn') OR x EQ Q_Neg (Var sm) AND y EQ Q_Neg (Var sm') OR x EQ Q_Ex (Var sm) AND y EQ Q_Ex (Var sm'))))))))› 2. ‹⟦atom (l::name) ♯ (v::tm, u::tm, x::tm, y::tm, s::tm, k::tm, sl::name, sl'::name, m::name, n::name, sm::name, sm'::name, sn::name, sn'::name); atom sl ♯ (v, u, x, y, s, k, sl', m, n, sm, sm', sn, sn'); atom sl' ♯ (v, u, x, y, s, k, m, n, sm, sm', sn, sn'); atom m ♯ (v, u, x, y, s, k, n, sm, sm', sn, sn'); atom n ♯ (v, u, x, y, s, k, sm, sm', sn, sn'); atom sm ♯ (v, u, x, y, s, k, sm', sn, sn'); atom sm' ♯ (v, u, x, y, s, k, sn, sn'); atom sn ♯ (v, u, x, y, s, k, sn'); atom sn' ♯ (v, u, x, y, s, k)⟧ ⟹ atom sn ♯ SubstAtomicP v u x y OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN k AND Var n IN k AND SeqSubstFormP v u (Var sm) (Var sm') s (Var m) AND SeqSubstFormP v u (Var sn) (Var sn') s (Var n) AND (x EQ Q_Disj (Var sm) (Var sn) AND y EQ Q_Disj (Var sm') (Var sn') OR x EQ Q_Neg (Var sm) AND y EQ Q_Neg (Var sm') OR x EQ Q_Ex (Var sm) AND y EQ Q_Ex (Var sm'))))))))› 3. ‹⟦atom (l::name) ♯ (v::tm, u::tm, x::tm, y::tm, s::tm, k::tm, sl::name, sl'::name, m::name, n::name, sm::name, sm'::name, sn::name, sn'::name); atom sl ♯ (v, u, x, y, s, k, sl', m, n, sm, sm', sn, sn'); atom sl' ♯ (v, u, x, y, s, k, m, n, sm, sm', sn, sn'); atom m ♯ (v, u, x, y, s, k, n, sm, sm', sn, sn'); atom n ♯ (v, u, x, y, s, k, sm, sm', sn, sn'); atom sm ♯ (v, u, x, y, s, k, sm', sn, sn'); atom sm' ♯ (v, u, x, y, s, k, sn, sn'); atom sn ♯ (v, u, x, y, s, k, sn'); atom sn' ♯ (v, u, x, y, s, k)⟧ ⟹ ∀C::fm∈{x EQ Var sl, y EQ Var sl', HPair k (HPair (Var sl) (Var sl')) IN s, All2 l k (SyntaxN.Ex sl (SyntaxN.Ex sl' (HPair (Var l) (HPair (Var sl) (Var sl')) IN s AND (SubstAtomicP v u (Var sl) (Var sl') OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN Var l AND Var n IN Var l AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND (Var sl EQ Q_Disj (Var sm) (Var sn) AND Var sl' EQ Q_Disj (Var sm') (Var sn') OR Var sl EQ Q_Neg (Var sm) AND Var sl' EQ Q_Neg (Var sm') OR Var sl EQ Q_Ex (Var sm) AND Var sl' EQ Q_Ex (Var sm')))))))))))), LstSeqP s k (HPair x y)}. atom sn ♯ C› discuss goal 1*) apply (rule Ex_EH (*‹⟦insert ?A ?H ⊢ ?B; atom ?i ♯ ?B; ∀C∈?H. atom ?i ♯ C⟧ ⟹ insert (SyntaxN.Ex ?i ?A) ?H ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 ?H) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 ?H. atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert (SyntaxN.Ex ?i ?A) ?H) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 ?H)) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 ?H). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert (SyntaxN.Ex ?i ?A) ?H)) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 ?H))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 ?H)). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert (SyntaxN.Ex ?i ?A) ?H))) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 ?H)))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 ?H))). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert (SyntaxN.Ex ?i ?A) ?H)))) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 ?H))))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 ?H)))). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert (SyntaxN.Ex ?i ?A) ?H))))) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 ?H)))))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 ?H))))). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert (SyntaxN.Ex ?i ?A) ?H)))))) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 ?H))))))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 ?H)))))). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 (insert (SyntaxN.Ex ?i ?A) ?H))))))) ⊢ ?B› ‹⟦insert ?A (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)))))))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈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))))))). atom ?i ♯ C⟧ ⟹ 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 (SyntaxN.Ex ?i ?A) ?H)))))))) ⊢ ?B› ‹⟦insert ?A (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))))))))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈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)))))))). atom ?i ♯ C⟧ ⟹ 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 (SyntaxN.Ex ?i ?A) ?H))))))))) ⊢ ?B›*) Conj_EH (*‹insert ?A (insert ?B ?H) ⊢ ?C ⟹ insert (?A AND ?B) ?H ⊢ ?C› ‹insert ?A (insert ?Ba (insert ?A1.0 ?H)) ⊢ ?B ⟹ insert ?A1.0 (insert (?A AND ?Ba) ?H) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 ?H))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert (?A AND ?Ba) ?H)) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 ?H)))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert (?A AND ?Ba) ?H))) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 ?H))))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert (?A AND ?Ba) ?H)))) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 ?H)))))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert (?A AND ?Ba) ?H))))) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 ?H))))))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert (?A AND ?Ba) ?H)))))) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 ?H)))))))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 (insert (?A AND ?Ba) ?H))))))) ⊢ ?B› ‹insert ?A (insert ?Ba (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))))))))) ⊢ ?B ⟹ 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 (?A AND ?Ba) ?H)))))))) ⊢ ?B› ‹insert ?A (insert ?Ba (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)))))))))) ⊢ ?B ⟹ 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 (?A AND ?Ba) ?H))))))))) ⊢ ?B›*)) (*goals: 1. ‹⟦atom (l::name) ♯ (v::tm, u::tm, x::tm, y::tm, s::tm, k::tm, sl::name, sl'::name, m::name, n::name, sm::name, sm'::name, sn::name, sn'::name); atom sl ♯ (v, u, x, y, s, k, sl', m, n, sm, sm', sn, sn'); atom sl' ♯ (v, u, x, y, s, k, m, n, sm, sm', sn, sn'); atom m ♯ (v, u, x, y, s, k, n, sm, sm', sn, sn'); atom n ♯ (v, u, x, y, s, k, sm, sm', sn, sn'); atom sm ♯ (v, u, x, y, s, k, sm', sn, sn'); atom sm' ♯ (v, u, x, y, s, k, sn, sn'); atom sn ♯ (v, u, x, y, s, k, sn'); atom sn' ♯ (v, u, x, y, s, k)⟧ ⟹ {Var m IN k AND Var n IN k AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND (Var sl EQ Q_Disj (Var sm) (Var sn) AND Var sl' EQ Q_Disj (Var sm') (Var sn') OR Var sl EQ Q_Neg (Var sm) AND Var sl' EQ Q_Neg (Var sm') OR Var sl EQ Q_Ex (Var sm) AND Var sl' EQ Q_Ex (Var sm')), x EQ Var sl, y EQ Var sl', HPair k (HPair (Var sl) (Var sl')) IN s, All2 l k (SyntaxN.Ex sl (SyntaxN.Ex sl' (HPair (Var l) (HPair (Var sl) (Var sl')) IN s AND (SubstAtomicP v u (Var sl) (Var sl') OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN Var l AND Var n IN Var l AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND (Var sl EQ Q_Disj (Var sm) (Var sn) AND Var sl' EQ Q_Disj (Var sm') (Var sn') OR Var sl EQ Q_Neg (Var sm) AND Var sl' EQ Q_Neg (Var sm') OR Var sl EQ Q_Ex (Var sm) AND Var sl' EQ Q_Ex (Var sm')))))))))))), LstSeqP s k (HPair x y)} ⊢ SubstAtomicP v u x y OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN k AND Var n IN k AND SeqSubstFormP v u (Var sm) (Var sm') s (Var m) AND SeqSubstFormP v u (Var sn) (Var sn') s (Var n) AND (x EQ Q_Disj (Var sm) (Var sn) AND y EQ Q_Disj (Var sm') (Var sn') OR x EQ Q_Neg (Var sm) AND y EQ Q_Neg (Var sm') OR x EQ Q_Ex (Var sm) AND y EQ Q_Ex (Var sm'))))))))› 2. ‹⟦atom (l::name) ♯ (v::tm, u::tm, x::tm, y::tm, s::tm, k::tm, sl::name, sl'::name, m::name, n::name, sm::name, sm'::name, sn::name, sn'::name); atom sl ♯ (v, u, x, y, s, k, sl', m, n, sm, sm', sn, sn'); atom sl' ♯ (v, u, x, y, s, k, m, n, sm, sm', sn, sn'); atom m ♯ (v, u, x, y, s, k, n, sm, sm', sn, sn'); atom n ♯ (v, u, x, y, s, k, sm, sm', sn, sn'); atom sm ♯ (v, u, x, y, s, k, sm', sn, sn'); atom sm' ♯ (v, u, x, y, s, k, sn, sn'); atom sn ♯ (v, u, x, y, s, k, sn'); atom sn' ♯ (v, u, x, y, s, k)⟧ ⟹ atom sn' ♯ SubstAtomicP v u x y OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN k AND Var n IN k AND SeqSubstFormP v u (Var sm) (Var sm') s (Var m) AND SeqSubstFormP v u (Var sn) (Var sn') s (Var n) AND (x EQ Q_Disj (Var sm) (Var sn) AND y EQ Q_Disj (Var sm') (Var sn') OR x EQ Q_Neg (Var sm) AND y EQ Q_Neg (Var sm') OR x EQ Q_Ex (Var sm) AND y EQ Q_Ex (Var sm'))))))))› 3. ‹⟦atom (l::name) ♯ (v::tm, u::tm, x::tm, y::tm, s::tm, k::tm, sl::name, sl'::name, m::name, n::name, sm::name, sm'::name, sn::name, sn'::name); atom sl ♯ (v, u, x, y, s, k, sl', m, n, sm, sm', sn, sn'); atom sl' ♯ (v, u, x, y, s, k, m, n, sm, sm', sn, sn'); atom m ♯ (v, u, x, y, s, k, n, sm, sm', sn, sn'); atom n ♯ (v, u, x, y, s, k, sm, sm', sn, sn'); atom sm ♯ (v, u, x, y, s, k, sm', sn, sn'); atom sm' ♯ (v, u, x, y, s, k, sn, sn'); atom sn ♯ (v, u, x, y, s, k, sn'); atom sn' ♯ (v, u, x, y, s, k)⟧ ⟹ ∀C::fm∈{x EQ Var sl, y EQ Var sl', HPair k (HPair (Var sl) (Var sl')) IN s, All2 l k (SyntaxN.Ex sl (SyntaxN.Ex sl' (HPair (Var l) (HPair (Var sl) (Var sl')) IN s AND (SubstAtomicP v u (Var sl) (Var sl') OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN Var l AND Var n IN Var l AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND (Var sl EQ Q_Disj (Var sm) (Var sn) AND Var sl' EQ Q_Disj (Var sm') (Var sn') OR Var sl EQ Q_Neg (Var sm) AND Var sl' EQ Q_Neg (Var sm') OR Var sl EQ Q_Ex (Var sm) AND Var sl' EQ Q_Ex (Var sm')))))))))))), LstSeqP s k (HPair x y)}. atom sn' ♯ C› discuss goal 1*) apply (rule Ex_EH (*‹⟦insert ?A ?H ⊢ ?B; atom ?i ♯ ?B; ∀C∈?H. atom ?i ♯ C⟧ ⟹ insert (SyntaxN.Ex ?i ?A) ?H ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 ?H) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 ?H. atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert (SyntaxN.Ex ?i ?A) ?H) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 ?H)) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 ?H). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert (SyntaxN.Ex ?i ?A) ?H)) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 ?H))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 ?H)). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert (SyntaxN.Ex ?i ?A) ?H))) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 ?H)))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 ?H))). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert (SyntaxN.Ex ?i ?A) ?H)))) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 ?H))))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 ?H)))). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert (SyntaxN.Ex ?i ?A) ?H))))) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 ?H)))))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 ?H))))). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert (SyntaxN.Ex ?i ?A) ?H)))))) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 ?H))))))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 ?H)))))). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 (insert (SyntaxN.Ex ?i ?A) ?H))))))) ⊢ ?B› ‹⟦insert ?A (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)))))))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈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))))))). atom ?i ♯ C⟧ ⟹ 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 (SyntaxN.Ex ?i ?A) ?H)))))))) ⊢ ?B› ‹⟦insert ?A (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))))))))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈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)))))))). atom ?i ♯ C⟧ ⟹ 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 (SyntaxN.Ex ?i ?A) ?H))))))))) ⊢ ?B›*) Conj_EH (*‹insert ?A (insert ?B ?H) ⊢ ?C ⟹ insert (?A AND ?B) ?H ⊢ ?C› ‹insert ?A (insert ?Ba (insert ?A1.0 ?H)) ⊢ ?B ⟹ insert ?A1.0 (insert (?A AND ?Ba) ?H) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 ?H))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert (?A AND ?Ba) ?H)) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 ?H)))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert (?A AND ?Ba) ?H))) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 ?H))))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert (?A AND ?Ba) ?H)))) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 ?H)))))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert (?A AND ?Ba) ?H))))) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 ?H))))))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert (?A AND ?Ba) ?H)))))) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 ?H)))))))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 (insert (?A AND ?Ba) ?H))))))) ⊢ ?B› ‹insert ?A (insert ?Ba (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))))))))) ⊢ ?B ⟹ 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 (?A AND ?Ba) ?H)))))))) ⊢ ?B› ‹insert ?A (insert ?Ba (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)))))))))) ⊢ ?B ⟹ 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 (?A AND ?Ba) ?H))))))))) ⊢ ?B›*)) (*top goal: ‹⟦atom l ♯ (v, u, x, y, s, k, sl, sl', m, n, sm, sm', sn, sn'); atom sl ♯ (v, u, x, y, s, k, sl', m, n, sm, sm', sn, sn'); atom sl' ♯ (v, u, x, y, s, k, m, n, sm, sm', sn, sn'); atom m ♯ (v, u, x, y, s, k, n, sm, sm', sn, sn'); atom n ♯ (v, u, x, y, s, k, sm, sm', sn, sn'); atom sm ♯ (v, u, x, y, s, k, sm', sn, sn'); atom sm' ♯ (v, u, x, y, s, k, sn, sn'); atom sn ♯ (v, u, x, y, s, k, sn'); atom sn' ♯ (v, u, x, y, s, k)⟧ ⟹ {Var m IN k AND Var n IN k AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND (Var sl EQ Q_Disj (Var sm) (Var sn) AND Var sl' EQ Q_Disj (Var sm') (Var sn') OR Var sl EQ Q_Neg (Var sm) AND Var sl' EQ Q_Neg (Var sm') OR Var sl EQ Q_Ex (Var sm) AND Var sl' EQ Q_Ex (Var sm')), x EQ Var sl, y EQ Var sl', HPair k (HPair (Var sl) (Var sl')) IN s, All2 l k (SyntaxN.Ex sl (SyntaxN.Ex sl' (HPair (Var l) (HPair (Var sl) (Var sl')) IN s AND (SubstAtomicP v u (Var sl) (Var sl') OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN Var l AND Var n IN Var l AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND (Var sl EQ Q_Disj (Var sm) (Var sn) AND Var sl' EQ Q_Disj (Var sm') (Var sn') OR Var sl EQ Q_Neg (Var sm) AND Var sl' EQ Q_Neg (Var sm') OR Var sl EQ Q_Ex (Var sm) AND Var sl' EQ Q_Ex (Var sm')))))))))))), LstSeqP s k (HPair x y)} ⊢ SubstAtomicP v u x y OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN k AND Var n IN k AND SeqSubstFormP v u (Var sm) (Var sm') s (Var m) AND SeqSubstFormP v u (Var sn) (Var sn') s (Var n) AND (x EQ Q_Disj (Var sm) (Var sn) AND y EQ Q_Disj (Var sm') (Var sn') OR x EQ Q_Neg (Var sm) AND y EQ Q_Neg (Var sm') OR x EQ Q_Ex (Var sm) AND y EQ Q_Ex (Var sm'))))))))› and 16 goals remain*) apply (rule Ex_EH (*‹⟦insert (?A::fm) (?H::fm set) ⊢ (?B::fm); atom (?i::name) ♯ ?B; ∀C::fm∈?H. atom ?i ♯ C⟧ ⟹ insert (SyntaxN.Ex ?i ?A) ?H ⊢ ?B› ‹⟦insert (?A::fm) (insert (?A1.0::fm) (?H::fm set)) ⊢ (?B::fm); atom (?i::name) ♯ ?B; ∀C::fm∈insert ?A1.0 ?H. atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert (SyntaxN.Ex ?i ?A) ?H) ⊢ ?B› ‹⟦insert (?A::fm) (insert (?A1.0::fm) (insert (?A2.0::fm) (?H::fm set))) ⊢ (?B::fm); atom (?i::name) ♯ ?B; ∀C::fm∈insert ?A1.0 (insert ?A2.0 ?H). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert (SyntaxN.Ex ?i ?A) ?H)) ⊢ ?B› ‹⟦insert (?A::fm) (insert (?A1.0::fm) (insert (?A2.0::fm) (insert (?A3.0::fm) (?H::fm set)))) ⊢ (?B::fm); atom (?i::name) ♯ ?B; ∀C::fm∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 ?H)). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert (SyntaxN.Ex ?i ?A) ?H))) ⊢ ?B› ‹⟦insert (?A::fm) (insert (?A1.0::fm) (insert (?A2.0::fm) (insert (?A3.0::fm) (insert (?A4.0::fm) (?H::fm set))))) ⊢ (?B::fm); atom (?i::name) ♯ ?B; ∀C::fm∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 ?H))). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert (SyntaxN.Ex ?i ?A) ?H)))) ⊢ ?B› ‹⟦insert (?A::fm) (insert (?A1.0::fm) (insert (?A2.0::fm) (insert (?A3.0::fm) (insert (?A4.0::fm) (insert (?A5.0::fm) (?H::fm set)))))) ⊢ (?B::fm); atom (?i::name) ♯ ?B; ∀C::fm∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 ?H)))). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert (SyntaxN.Ex ?i ?A) ?H))))) ⊢ ?B› ‹⟦insert (?A::fm) (insert (?A1.0::fm) (insert (?A2.0::fm) (insert (?A3.0::fm) (insert (?A4.0::fm) (insert (?A5.0::fm) (insert (?A6.0::fm) (?H::fm set))))))) ⊢ (?B::fm); atom (?i::name) ♯ ?B; ∀C::fm∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 ?H))))). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert (SyntaxN.Ex ?i ?A) ?H)))))) ⊢ ?B› ‹⟦insert (?A::fm) (insert (?A1.0::fm) (insert (?A2.0::fm) (insert (?A3.0::fm) (insert (?A4.0::fm) (insert (?A5.0::fm) (insert (?A6.0::fm) (insert (?A7.0::fm) (?H::fm set)))))))) ⊢ (?B::fm); atom (?i::name) ♯ ?B; ∀C::fm∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 ?H)))))). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 (insert (SyntaxN.Ex ?i ?A) ?H))))))) ⊢ ?B› ‹⟦insert (?A::fm) (insert (?A1.0::fm) (insert (?A2.0::fm) (insert (?A3.0::fm) (insert (?A4.0::fm) (insert (?A5.0::fm) (insert (?A6.0::fm) (insert (?A7.0::fm) (insert (?A8.0::fm) (?H::fm set))))))))) ⊢ (?B::fm); atom (?i::name) ♯ ?B; ∀C::fm∈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))))))). atom ?i ♯ C⟧ ⟹ 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 (SyntaxN.Ex ?i ?A) ?H)))))))) ⊢ ?B› ‹⟦insert (?A::fm) (insert (?A1.0::fm) (insert (?A2.0::fm) (insert (?A3.0::fm) (insert (?A4.0::fm) (insert (?A5.0::fm) (insert (?A6.0::fm) (insert (?A7.0::fm) (insert (?A8.0::fm) (insert (?A9.0::fm) (?H::fm set)))))))))) ⊢ (?B::fm); atom (?i::name) ♯ ?B; ∀C::fm∈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)))))))). atom ?i ♯ C⟧ ⟹ 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 (SyntaxN.Ex ?i ?A) ?H))))))))) ⊢ ?B›*) Conj_EH (*‹insert (?A::fm) (insert (?B::fm) (?H::fm set)) ⊢ (?C::fm) ⟹ insert (?A AND ?B) ?H ⊢ ?C› ‹insert (?A::fm) (insert (?Ba::fm) (insert (?A1.0::fm) (?H::fm set))) ⊢ (?B::fm) ⟹ insert ?A1.0 (insert (?A AND ?Ba) ?H) ⊢ ?B› ‹insert (?A::fm) (insert (?Ba::fm) (insert (?A1.0::fm) (insert (?A2.0::fm) (?H::fm set)))) ⊢ (?B::fm) ⟹ insert ?A1.0 (insert ?A2.0 (insert (?A AND ?Ba) ?H)) ⊢ ?B› ‹insert (?A::fm) (insert (?Ba::fm) (insert (?A1.0::fm) (insert (?A2.0::fm) (insert (?A3.0::fm) (?H::fm set))))) ⊢ (?B::fm) ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert (?A AND ?Ba) ?H))) ⊢ ?B› ‹insert (?A::fm) (insert (?Ba::fm) (insert (?A1.0::fm) (insert (?A2.0::fm) (insert (?A3.0::fm) (insert (?A4.0::fm) (?H::fm set)))))) ⊢ (?B::fm) ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert (?A AND ?Ba) ?H)))) ⊢ ?B› ‹insert (?A::fm) (insert (?Ba::fm) (insert (?A1.0::fm) (insert (?A2.0::fm) (insert (?A3.0::fm) (insert (?A4.0::fm) (insert (?A5.0::fm) (?H::fm set))))))) ⊢ (?B::fm) ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert (?A AND ?Ba) ?H))))) ⊢ ?B› ‹insert (?A::fm) (insert (?Ba::fm) (insert (?A1.0::fm) (insert (?A2.0::fm) (insert (?A3.0::fm) (insert (?A4.0::fm) (insert (?A5.0::fm) (insert (?A6.0::fm) (?H::fm set)))))))) ⊢ (?B::fm) ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert (?A AND ?Ba) ?H)))))) ⊢ ?B› ‹insert (?A::fm) (insert (?Ba::fm) (insert (?A1.0::fm) (insert (?A2.0::fm) (insert (?A3.0::fm) (insert (?A4.0::fm) (insert (?A5.0::fm) (insert (?A6.0::fm) (insert (?A7.0::fm) (?H::fm set))))))))) ⊢ (?B::fm) ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 (insert (?A AND ?Ba) ?H))))))) ⊢ ?B› ‹insert (?A::fm) (insert (?Ba::fm) (insert (?A1.0::fm) (insert (?A2.0::fm) (insert (?A3.0::fm) (insert (?A4.0::fm) (insert (?A5.0::fm) (insert (?A6.0::fm) (insert (?A7.0::fm) (insert (?A8.0::fm) (?H::fm set)))))))))) ⊢ (?B::fm) ⟹ 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 (?A AND ?Ba) ?H)))))))) ⊢ ?B› ‹insert (?A::fm) (insert (?Ba::fm) (insert (?A1.0::fm) (insert (?A2.0::fm) (insert (?A3.0::fm) (insert (?A4.0::fm) (insert (?A5.0::fm) (insert (?A6.0::fm) (insert (?A7.0::fm) (insert (?A8.0::fm) (insert (?A9.0::fm) (?H::fm set))))))))))) ⊢ (?B::fm) ⟹ 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 (?A AND ?Ba) ?H))))))))) ⊢ ?B›*)) (*top goal: ‹⟦atom l ♯ (v, u, x, y, s, k, sl, sl', m, n, sm, sm', sn, sn'); atom sl ♯ (v, u, x, y, s, k, sl', m, n, sm, sm', sn, sn'); atom sl' ♯ (v, u, x, y, s, k, m, n, sm, sm', sn, sn'); atom m ♯ (v, u, x, y, s, k, n, sm, sm', sn, sn'); atom n ♯ (v, u, x, y, s, k, sm, sm', sn, sn'); atom sm ♯ (v, u, x, y, s, k, sm', sn, sn'); atom sm' ♯ (v, u, x, y, s, k, sn, sn'); atom sn ♯ (v, u, x, y, s, k, sn'); atom sn' ♯ (v, u, x, y, s, k)⟧ ⟹ {Var m IN k, Var n IN k AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND (Var sl EQ Q_Disj (Var sm) (Var sn) AND Var sl' EQ Q_Disj (Var sm') (Var sn') OR Var sl EQ Q_Neg (Var sm) AND Var sl' EQ Q_Neg (Var sm') OR Var sl EQ Q_Ex (Var sm) AND Var sl' EQ Q_Ex (Var sm')), x EQ Var sl, y EQ Var sl', HPair k (HPair (Var sl) (Var sl')) IN s, All2 l k (SyntaxN.Ex sl (SyntaxN.Ex sl' (HPair (Var l) (HPair (Var sl) (Var sl')) IN s AND (SubstAtomicP v u (Var sl) (Var sl') OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN Var l AND Var n IN Var l AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND (Var sl EQ Q_Disj (Var sm) (Var sn) AND Var sl' EQ Q_Disj (Var sm') (Var sn') OR Var sl EQ Q_Neg (Var sm) AND Var sl' EQ Q_Neg (Var sm') OR Var sl EQ Q_Ex (Var sm) AND Var sl' EQ Q_Ex (Var sm')))))))))))), LstSeqP s k (HPair x y)} ⊢ SubstAtomicP v u x y OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN k AND Var n IN k AND SeqSubstFormP v u (Var sm) (Var sm') s (Var m) AND SeqSubstFormP v u (Var sn) (Var sn') s (Var n) AND (x EQ Q_Disj (Var sm) (Var sn) AND y EQ Q_Disj (Var sm') (Var sn') OR x EQ Q_Neg (Var sm) AND y EQ Q_Neg (Var sm') OR x EQ Q_Ex (Var sm) AND y EQ Q_Ex (Var sm'))))))))› and 16 goals remain*) apply (rule Ex_EH (*‹⟦insert ?A ?H ⊢ ?B; atom ?i ♯ ?B; ∀C∈?H. atom ?i ♯ C⟧ ⟹ insert (SyntaxN.Ex ?i ?A) ?H ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 ?H) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 ?H. atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert (SyntaxN.Ex ?i ?A) ?H) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 ?H)) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 ?H). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert (SyntaxN.Ex ?i ?A) ?H)) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 ?H))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 ?H)). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert (SyntaxN.Ex ?i ?A) ?H))) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 ?H)))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 ?H))). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert (SyntaxN.Ex ?i ?A) ?H)))) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 ?H))))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 ?H)))). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert (SyntaxN.Ex ?i ?A) ?H))))) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 ?H)))))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 ?H))))). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert (SyntaxN.Ex ?i ?A) ?H)))))) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 ?H))))))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 ?H)))))). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 (insert (SyntaxN.Ex ?i ?A) ?H))))))) ⊢ ?B› ‹⟦insert ?A (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)))))))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈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))))))). atom ?i ♯ C⟧ ⟹ 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 (SyntaxN.Ex ?i ?A) ?H)))))))) ⊢ ?B› ‹⟦insert ?A (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))))))))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈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)))))))). atom ?i ♯ C⟧ ⟹ 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 (SyntaxN.Ex ?i ?A) ?H))))))))) ⊢ ?B›*) Conj_EH (*‹insert ?A (insert ?B ?H) ⊢ ?C ⟹ insert (?A AND ?B) ?H ⊢ ?C› ‹insert ?A (insert ?Ba (insert ?A1.0 ?H)) ⊢ ?B ⟹ insert ?A1.0 (insert (?A AND ?Ba) ?H) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 ?H))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert (?A AND ?Ba) ?H)) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 ?H)))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert (?A AND ?Ba) ?H))) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 ?H))))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert (?A AND ?Ba) ?H)))) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 ?H)))))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert (?A AND ?Ba) ?H))))) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 ?H))))))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert (?A AND ?Ba) ?H)))))) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 ?H)))))))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 (insert (?A AND ?Ba) ?H))))))) ⊢ ?B› ‹insert ?A (insert ?Ba (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))))))))) ⊢ ?B ⟹ 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 (?A AND ?Ba) ?H)))))))) ⊢ ?B› ‹insert ?A (insert ?Ba (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)))))))))) ⊢ ?B ⟹ 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 (?A AND ?Ba) ?H))))))))) ⊢ ?B›*)) (*top goal: ‹⟦atom (l::name) ♯ (v::tm, u::tm, x::tm, y::tm, s::tm, k::tm, sl::name, sl'::name, m::name, n::name, sm::name, sm'::name, sn::name, sn'::name); atom sl ♯ (v, u, x, y, s, k, sl', m, n, sm, sm', sn, sn'); atom sl' ♯ (v, u, x, y, s, k, m, n, sm, sm', sn, sn'); atom m ♯ (v, u, x, y, s, k, n, sm, sm', sn, sn'); atom n ♯ (v, u, x, y, s, k, sm, sm', sn, sn'); atom sm ♯ (v, u, x, y, s, k, sm', sn, sn'); atom sm' ♯ (v, u, x, y, s, k, sn, sn'); atom sn ♯ (v, u, x, y, s, k, sn'); atom sn' ♯ (v, u, x, y, s, k)⟧ ⟹ {Var n IN k, HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND (Var sl EQ Q_Disj (Var sm) (Var sn) AND Var sl' EQ Q_Disj (Var sm') (Var sn') OR Var sl EQ Q_Neg (Var sm) AND Var sl' EQ Q_Neg (Var sm') OR Var sl EQ Q_Ex (Var sm) AND Var sl' EQ Q_Ex (Var sm')), Var m IN k, x EQ Var sl, y EQ Var sl', HPair k (HPair (Var sl) (Var sl')) IN s, All2 l k (SyntaxN.Ex sl (SyntaxN.Ex sl' (HPair (Var l) (HPair (Var sl) (Var sl')) IN s AND (SubstAtomicP v u (Var sl) (Var sl') OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN Var l AND Var n IN Var l AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND (Var sl EQ Q_Disj (Var sm) (Var sn) AND Var sl' EQ Q_Disj (Var sm') (Var sn') OR Var sl EQ Q_Neg (Var sm) AND Var sl' EQ Q_Neg (Var sm') OR Var sl EQ Q_Ex (Var sm) AND Var sl' EQ Q_Ex (Var sm')))))))))))), LstSeqP s k (HPair x y)} ⊢ SubstAtomicP v u x y OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN k AND Var n IN k AND SeqSubstFormP v u (Var sm) (Var sm') s (Var m) AND SeqSubstFormP v u (Var sn) (Var sn') s (Var n) AND (x EQ Q_Disj (Var sm) (Var sn) AND y EQ Q_Disj (Var sm') (Var sn') OR x EQ Q_Neg (Var sm) AND y EQ Q_Neg (Var sm') OR x EQ Q_Ex (Var sm) AND y EQ Q_Ex (Var sm'))))))))› and 16 goals remain*) apply (rule Ex_EH (*‹⟦insert ?A ?H ⊢ ?B; atom ?i ♯ ?B; ∀C∈?H. atom ?i ♯ C⟧ ⟹ insert (SyntaxN.Ex ?i ?A) ?H ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 ?H) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 ?H. atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert (SyntaxN.Ex ?i ?A) ?H) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 ?H)) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 ?H). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert (SyntaxN.Ex ?i ?A) ?H)) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 ?H))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 ?H)). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert (SyntaxN.Ex ?i ?A) ?H))) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 ?H)))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 ?H))). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert (SyntaxN.Ex ?i ?A) ?H)))) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 ?H))))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 ?H)))). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert (SyntaxN.Ex ?i ?A) ?H))))) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 ?H)))))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 ?H))))). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert (SyntaxN.Ex ?i ?A) ?H)))))) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 ?H))))))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 ?H)))))). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 (insert (SyntaxN.Ex ?i ?A) ?H))))))) ⊢ ?B› ‹⟦insert ?A (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)))))))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈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))))))). atom ?i ♯ C⟧ ⟹ 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 (SyntaxN.Ex ?i ?A) ?H)))))))) ⊢ ?B› ‹⟦insert ?A (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))))))))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈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)))))))). atom ?i ♯ C⟧ ⟹ 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 (SyntaxN.Ex ?i ?A) ?H))))))))) ⊢ ?B›*) Conj_EH (*‹insert ?A (insert ?B ?H) ⊢ ?C ⟹ insert (?A AND ?B) ?H ⊢ ?C› ‹insert ?A (insert ?Ba (insert ?A1.0 ?H)) ⊢ ?B ⟹ insert ?A1.0 (insert (?A AND ?Ba) ?H) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 ?H))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert (?A AND ?Ba) ?H)) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 ?H)))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert (?A AND ?Ba) ?H))) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 ?H))))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert (?A AND ?Ba) ?H)))) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 ?H)))))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert (?A AND ?Ba) ?H))))) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 ?H))))))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert (?A AND ?Ba) ?H)))))) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 ?H)))))))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 (insert (?A AND ?Ba) ?H))))))) ⊢ ?B› ‹insert ?A (insert ?Ba (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))))))))) ⊢ ?B ⟹ 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 (?A AND ?Ba) ?H)))))))) ⊢ ?B› ‹insert ?A (insert ?Ba (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)))))))))) ⊢ ?B ⟹ 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 (?A AND ?Ba) ?H))))))))) ⊢ ?B›*)) (*top goal: ‹⟦atom l ♯ (v, u, x, y, s, k, sl, sl', m, n, sm, sm', sn, sn'); atom sl ♯ (v, u, x, y, s, k, sl', m, n, sm, sm', sn, sn'); atom sl' ♯ (v, u, x, y, s, k, m, n, sm, sm', sn, sn'); atom m ♯ (v, u, x, y, s, k, n, sm, sm', sn, sn'); atom n ♯ (v, u, x, y, s, k, sm, sm', sn, sn'); atom sm ♯ (v, u, x, y, s, k, sm', sn, sn'); atom sm' ♯ (v, u, x, y, s, k, sn, sn'); atom sn ♯ (v, u, x, y, s, k, sn'); atom sn' ♯ (v, u, x, y, s, k)⟧ ⟹ {HPair (Var m) (HPair (Var sm) (Var sm')) IN s, HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND (Var sl EQ Q_Disj (Var sm) (Var sn) AND Var sl' EQ Q_Disj (Var sm') (Var sn') OR Var sl EQ Q_Neg (Var sm) AND Var sl' EQ Q_Neg (Var sm') OR Var sl EQ Q_Ex (Var sm) AND Var sl' EQ Q_Ex (Var sm')), Var n IN k, Var m IN k, x EQ Var sl, y EQ Var sl', HPair k (HPair (Var sl) (Var sl')) IN s, All2 l k (SyntaxN.Ex sl (SyntaxN.Ex sl' (HPair (Var l) (HPair (Var sl) (Var sl')) IN s AND (SubstAtomicP v u (Var sl) (Var sl') OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN Var l AND Var n IN Var l AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND (Var sl EQ Q_Disj (Var sm) (Var sn) AND Var sl' EQ Q_Disj (Var sm') (Var sn') OR Var sl EQ Q_Neg (Var sm) AND Var sl' EQ Q_Neg (Var sm') OR Var sl EQ Q_Ex (Var sm) AND Var sl' EQ Q_Ex (Var sm')))))))))))), LstSeqP s k (HPair x y)} ⊢ SubstAtomicP v u x y OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN k AND Var n IN k AND SeqSubstFormP v u (Var sm) (Var sm') s (Var m) AND SeqSubstFormP v u (Var sn) (Var sn') s (Var n) AND (x EQ Q_Disj (Var sm) (Var sn) AND y EQ Q_Disj (Var sm') (Var sn') OR x EQ Q_Neg (Var sm) AND y EQ Q_Neg (Var sm') OR x EQ Q_Ex (Var sm) AND y EQ Q_Ex (Var sm'))))))))› and 16 goals remain*) apply (rule Disj_I2 (*‹?H ⊢ ?B ⟹ ?H ⊢ ?A OR ?B›*)) (*top goal: ‹⟦atom l ♯ (v, u, x, y, s, k, sl, sl', m, n, sm, sm', sn, sn'); atom sl ♯ (v, u, x, y, s, k, sl', m, n, sm, sm', sn, sn'); atom sl' ♯ (v, u, x, y, s, k, m, n, sm, sm', sn, sn'); atom m ♯ (v, u, x, y, s, k, n, sm, sm', sn, sn'); atom n ♯ (v, u, x, y, s, k, sm, sm', sn, sn'); atom sm ♯ (v, u, x, y, s, k, sm', sn, sn'); atom sm' ♯ (v, u, x, y, s, k, sn, sn'); atom sn ♯ (v, u, x, y, s, k, sn'); atom sn' ♯ (v, u, x, y, s, k)⟧ ⟹ {HPair (Var n) (HPair (Var sn) (Var sn')) IN s, Var sl EQ Q_Disj (Var sm) (Var sn) AND Var sl' EQ Q_Disj (Var sm') (Var sn') OR Var sl EQ Q_Neg (Var sm) AND Var sl' EQ Q_Neg (Var sm') OR Var sl EQ Q_Ex (Var sm) AND Var sl' EQ Q_Ex (Var sm'), HPair (Var m) (HPair (Var sm) (Var sm')) IN s, Var n IN k, Var m IN k, x EQ Var sl, y EQ Var sl', HPair k (HPair (Var sl) (Var sl')) IN s, All2 l k (SyntaxN.Ex sl (SyntaxN.Ex sl' (HPair (Var l) (HPair (Var sl) (Var sl')) IN s AND (SubstAtomicP v u (Var sl) (Var sl') OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN Var l AND Var n IN Var l AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND (Var sl EQ Q_Disj (Var sm) (Var sn) AND Var sl' EQ Q_Disj (Var sm') (Var sn') OR Var sl EQ Q_Neg (Var sm) AND Var sl' EQ Q_Neg (Var sm') OR Var sl EQ Q_Ex (Var sm) AND Var sl' EQ Q_Ex (Var sm')))))))))))), LstSeqP s k (HPair x y)} ⊢ SubstAtomicP v u x y OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN k AND Var n IN k AND SeqSubstFormP v u (Var sm) (Var sm') s (Var m) AND SeqSubstFormP v u (Var sn) (Var sn') s (Var n) AND (x EQ Q_Disj (Var sm) (Var sn) AND y EQ Q_Disj (Var sm') (Var sn') OR x EQ Q_Neg (Var sm) AND y EQ Q_Neg (Var sm') OR x EQ Q_Ex (Var sm) AND y EQ Q_Ex (Var sm'))))))))› and 16 goals remain*) apply (rule Ex_I [where x = "Var m"] (*‹?H ⊢ ?A(?i::=Var m) ⟹ ?H ⊢ SyntaxN.Ex ?i ?A›*)) (*top goal: ‹⟦atom (l::name) ♯ (v::tm, u::tm, x::tm, y::tm, s::tm, k::tm, sl::name, sl'::name, m::name, n::name, sm::name, sm'::name, sn::name, sn'::name); atom sl ♯ (v, u, x, y, s, k, sl', m, n, sm, sm', sn, sn'); atom sl' ♯ (v, u, x, y, s, k, m, n, sm, sm', sn, sn'); atom m ♯ (v, u, x, y, s, k, n, sm, sm', sn, sn'); atom n ♯ (v, u, x, y, s, k, sm, sm', sn, sn'); atom sm ♯ (v, u, x, y, s, k, sm', sn, sn'); atom sm' ♯ (v, u, x, y, s, k, sn, sn'); atom sn ♯ (v, u, x, y, s, k, sn'); atom sn' ♯ (v, u, x, y, s, k)⟧ ⟹ {HPair (Var n) (HPair (Var sn) (Var sn')) IN s, Var sl EQ Q_Disj (Var sm) (Var sn) AND Var sl' EQ Q_Disj (Var sm') (Var sn') OR Var sl EQ Q_Neg (Var sm) AND Var sl' EQ Q_Neg (Var sm') OR Var sl EQ Q_Ex (Var sm) AND Var sl' EQ Q_Ex (Var sm'), HPair (Var m) (HPair (Var sm) (Var sm')) IN s, Var n IN k, Var m IN k, x EQ Var sl, y EQ Var sl', HPair k (HPair (Var sl) (Var sl')) IN s, All2 l k (SyntaxN.Ex sl (SyntaxN.Ex sl' (HPair (Var l) (HPair (Var sl) (Var sl')) IN s AND (SubstAtomicP v u (Var sl) (Var sl') OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN Var l AND Var n IN Var l AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND (Var sl EQ Q_Disj (Var sm) (Var sn) AND Var sl' EQ Q_Disj (Var sm') (Var sn') OR Var sl EQ Q_Neg (Var sm) AND Var sl' EQ Q_Neg (Var sm') OR Var sl EQ Q_Ex (Var sm) AND Var sl' EQ Q_Ex (Var sm')))))))))))), LstSeqP s k (HPair x y)} ⊢ SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN k AND Var n IN k AND SeqSubstFormP v u (Var sm) (Var sm') s (Var m) AND SeqSubstFormP v u (Var sn) (Var sn') s (Var n) AND (x EQ Q_Disj (Var sm) (Var sn) AND y EQ Q_Disj (Var sm') (Var sn') OR x EQ Q_Neg (Var sm) AND y EQ Q_Neg (Var sm') OR x EQ Q_Ex (Var sm) AND y EQ Q_Ex (Var sm'))))))))› and 16 goals remain*) apply simp (*top goal: ‹⟦atom l ♯ (v, u, x, y, s, k, sl, sl', m, n, sm, sm', sn, sn'); atom sl ♯ (v, u, x, y, s, k, sl', m, n, sm, sm', sn, sn'); atom sl' ♯ (v, u, x, y, s, k, m, n, sm, sm', sn, sn'); atom m ♯ (v, u, x, y, s, k, n, sm, sm', sn, sn'); atom n ♯ (v, u, x, y, s, k, sm, sm', sn, sn'); atom sm ♯ (v, u, x, y, s, k, sm', sn, sn'); atom sm' ♯ (v, u, x, y, s, k, sn, sn'); atom sn ♯ (v, u, x, y, s, k, sn'); atom sn' ♯ (v, u, x, y, s, k)⟧ ⟹ {HPair (Var n) (HPair (Var sn) (Var sn')) IN s, Var sl EQ Q_Disj (Var sm) (Var sn) AND Var sl' EQ Q_Disj (Var sm') (Var sn') OR Var sl EQ Q_Neg (Var sm) AND Var sl' EQ Q_Neg (Var sm') OR Var sl EQ Q_Ex (Var sm) AND Var sl' EQ Q_Ex (Var sm'), HPair (Var m) (HPair (Var sm) (Var sm')) IN s, Var n IN k, Var m IN k, x EQ Var sl, y EQ Var sl', HPair k (HPair (Var sl) (Var sl')) IN s, All2 l k (SyntaxN.Ex sl (SyntaxN.Ex sl' (HPair (Var l) (HPair (Var sl) (Var sl')) IN s AND (SubstAtomicP v u (Var sl) (Var sl') OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN Var l AND Var n IN Var l AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND (Var sl EQ Q_Disj (Var sm) (Var sn) AND Var sl' EQ Q_Disj (Var sm') (Var sn') OR Var sl EQ Q_Neg (Var sm) AND Var sl' EQ Q_Neg (Var sm') OR Var sl EQ Q_Ex (Var sm) AND Var sl' EQ Q_Ex (Var sm')))))))))))), LstSeqP s k (HPair x y)} ⊢ (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN k AND Var n IN k AND SeqSubstFormP v u (Var sm) (Var sm') s (Var m) AND SeqSubstFormP v u (Var sn) (Var sn') s (Var n) AND (x EQ Q_Disj (Var sm) (Var sn) AND y EQ Q_Disj (Var sm') (Var sn') OR x EQ Q_Neg (Var sm) AND y EQ Q_Neg (Var sm') OR x EQ Q_Ex (Var sm) AND y EQ Q_Ex (Var sm'))))))))(m::=Var m)› and 16 goals remain*) apply (rule Ex_I [where x = "Var n"] (*‹?H ⊢ ?A(?i::=Var n) ⟹ ?H ⊢ SyntaxN.Ex ?i ?A›*)) (*top goal: ‹⟦atom l ♯ (v, u, x, y, s, k, sl, sl', m, n, sm, sm', sn, sn'); atom sl ♯ (v, u, x, y, s, k, sl', m, n, sm, sm', sn, sn'); atom sl' ♯ (v, u, x, y, s, k, m, n, sm, sm', sn, sn'); atom m ♯ (v, u, x, y, s, k, n, sm, sm', sn, sn'); atom n ♯ (v, u, x, y, s, k, sm, sm', sn, sn'); atom sm ♯ (v, u, x, y, s, k, sm', sn, sn'); atom sm' ♯ (v, u, x, y, s, k, sn, sn'); atom sn ♯ (v, u, x, y, s, k, sn'); atom sn' ♯ (v, u, x, y, s, k)⟧ ⟹ {HPair (Var n) (HPair (Var sn) (Var sn')) IN s, Var sl EQ Q_Disj (Var sm) (Var sn) AND Var sl' EQ Q_Disj (Var sm') (Var sn') OR Var sl EQ Q_Neg (Var sm) AND Var sl' EQ Q_Neg (Var sm') OR Var sl EQ Q_Ex (Var sm) AND Var sl' EQ Q_Ex (Var sm'), HPair (Var m) (HPair (Var sm) (Var sm')) IN s, Var n IN k, Var m IN k, x EQ Var sl, y EQ Var sl', HPair k (HPair (Var sl) (Var sl')) IN s, All2 l k (SyntaxN.Ex sl (SyntaxN.Ex sl' (HPair (Var l) (HPair (Var sl) (Var sl')) IN s AND (SubstAtomicP v u (Var sl) (Var sl') OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN Var l AND Var n IN Var l AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND (Var sl EQ Q_Disj (Var sm) (Var sn) AND Var sl' EQ Q_Disj (Var sm') (Var sn') OR Var sl EQ Q_Neg (Var sm) AND Var sl' EQ Q_Neg (Var sm') OR Var sl EQ Q_Ex (Var sm) AND Var sl' EQ Q_Ex (Var sm')))))))))))), LstSeqP s k (HPair x y)} ⊢ SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN k AND Var n IN k AND SeqSubstFormP v u (Var sm) (Var sm') s (Var m) AND SeqSubstFormP v u (Var sn) (Var sn') s (Var n) AND (x EQ Q_Disj (Var sm) (Var sn) AND y EQ Q_Disj (Var sm') (Var sn') OR x EQ Q_Neg (Var sm) AND y EQ Q_Neg (Var sm') OR x EQ Q_Ex (Var sm) AND y EQ Q_Ex (Var sm')))))))› and 16 goals remain*) apply simp (*top goal: ‹⟦atom l ♯ (v, u, x, y, s, k, sl, sl', m, n, sm, sm', sn, sn'); atom sl ♯ (v, u, x, y, s, k, sl', m, n, sm, sm', sn, sn'); atom sl' ♯ (v, u, x, y, s, k, m, n, sm, sm', sn, sn'); atom m ♯ (v, u, x, y, s, k, n, sm, sm', sn, sn'); atom n ♯ (v, u, x, y, s, k, sm, sm', sn, sn'); atom sm ♯ (v, u, x, y, s, k, sm', sn, sn'); atom sm' ♯ (v, u, x, y, s, k, sn, sn'); atom sn ♯ (v, u, x, y, s, k, sn'); atom sn' ♯ (v, u, x, y, s, k)⟧ ⟹ {HPair (Var n) (HPair (Var sn) (Var sn')) IN s, Var sl EQ Q_Disj (Var sm) (Var sn) AND Var sl' EQ Q_Disj (Var sm') (Var sn') OR Var sl EQ Q_Neg (Var sm) AND Var sl' EQ Q_Neg (Var sm') OR Var sl EQ Q_Ex (Var sm) AND Var sl' EQ Q_Ex (Var sm'), HPair (Var m) (HPair (Var sm) (Var sm')) IN s, Var n IN k, Var m IN k, x EQ Var sl, y EQ Var sl', HPair k (HPair (Var sl) (Var sl')) IN s, All2 l k (SyntaxN.Ex sl (SyntaxN.Ex sl' (HPair (Var l) (HPair (Var sl) (Var sl')) IN s AND (SubstAtomicP v u (Var sl) (Var sl') OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN Var l AND Var n IN Var l AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND (Var sl EQ Q_Disj (Var sm) (Var sn) AND Var sl' EQ Q_Disj (Var sm') (Var sn') OR Var sl EQ Q_Neg (Var sm) AND Var sl' EQ Q_Neg (Var sm') OR Var sl EQ Q_Ex (Var sm) AND Var sl' EQ Q_Ex (Var sm')))))))))))), LstSeqP s k (HPair x y)} ⊢ (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN k AND Var n IN k AND SeqSubstFormP v u (Var sm) (Var sm') s (Var m) AND SeqSubstFormP v u (Var sn) (Var sn') s (Var n) AND (x EQ Q_Disj (Var sm) (Var sn) AND y EQ Q_Disj (Var sm') (Var sn') OR x EQ Q_Neg (Var sm) AND y EQ Q_Neg (Var sm') OR x EQ Q_Ex (Var sm) AND y EQ Q_Ex (Var sm')))))))(n::=Var n)› and 16 goals remain*) apply (rule Ex_I [where x = "Var sm"] (*‹?H ⊢ ?A(?i::=Var sm) ⟹ ?H ⊢ SyntaxN.Ex ?i ?A›*)) (*top goal: ‹⟦atom l ♯ (v, u, x, y, s, k, sl, sl', m, n, sm, sm', sn, sn'); atom sl ♯ (v, u, x, y, s, k, sl', m, n, sm, sm', sn, sn'); atom sl' ♯ (v, u, x, y, s, k, m, n, sm, sm', sn, sn'); atom m ♯ (v, u, x, y, s, k, n, sm, sm', sn, sn'); atom n ♯ (v, u, x, y, s, k, sm, sm', sn, sn'); atom sm ♯ (v, u, x, y, s, k, sm', sn, sn'); atom sm' ♯ (v, u, x, y, s, k, sn, sn'); atom sn ♯ (v, u, x, y, s, k, sn'); atom sn' ♯ (v, u, x, y, s, k)⟧ ⟹ {HPair (Var n) (HPair (Var sn) (Var sn')) IN s, Var sl EQ Q_Disj (Var sm) (Var sn) AND Var sl' EQ Q_Disj (Var sm') (Var sn') OR Var sl EQ Q_Neg (Var sm) AND Var sl' EQ Q_Neg (Var sm') OR Var sl EQ Q_Ex (Var sm) AND Var sl' EQ Q_Ex (Var sm'), HPair (Var m) (HPair (Var sm) (Var sm')) IN s, Var n IN k, Var m IN k, x EQ Var sl, y EQ Var sl', HPair k (HPair (Var sl) (Var sl')) IN s, All2 l k (SyntaxN.Ex sl (SyntaxN.Ex sl' (HPair (Var l) (HPair (Var sl) (Var sl')) IN s AND (SubstAtomicP v u (Var sl) (Var sl') OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN Var l AND Var n IN Var l AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND (Var sl EQ Q_Disj (Var sm) (Var sn) AND Var sl' EQ Q_Disj (Var sm') (Var sn') OR Var sl EQ Q_Neg (Var sm) AND Var sl' EQ Q_Neg (Var sm') OR Var sl EQ Q_Ex (Var sm) AND Var sl' EQ Q_Ex (Var sm')))))))))))), LstSeqP s k (HPair x y)} ⊢ SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN k AND Var n IN k AND SeqSubstFormP v u (Var sm) (Var sm') s (Var m) AND SeqSubstFormP v u (Var sn) (Var sn') s (Var n) AND (x EQ Q_Disj (Var sm) (Var sn) AND y EQ Q_Disj (Var sm') (Var sn') OR x EQ Q_Neg (Var sm) AND y EQ Q_Neg (Var sm') OR x EQ Q_Ex (Var sm) AND y EQ Q_Ex (Var sm'))))))› and 16 goals remain*) apply simp (*top goal: ‹⟦atom (l::name) ♯ (v::tm, u::tm, x::tm, y::tm, s::tm, k::tm, sl::name, sl'::name, m::name, n::name, sm::name, sm'::name, sn::name, sn'::name); atom sl ♯ (v, u, x, y, s, k, sl', m, n, sm, sm', sn, sn'); atom sl' ♯ (v, u, x, y, s, k, m, n, sm, sm', sn, sn'); atom m ♯ (v, u, x, y, s, k, n, sm, sm', sn, sn'); atom n ♯ (v, u, x, y, s, k, sm, sm', sn, sn'); atom sm ♯ (v, u, x, y, s, k, sm', sn, sn'); atom sm' ♯ (v, u, x, y, s, k, sn, sn'); atom sn ♯ (v, u, x, y, s, k, sn'); atom sn' ♯ (v, u, x, y, s, k)⟧ ⟹ {HPair (Var n) (HPair (Var sn) (Var sn')) IN s, Var sl EQ Q_Disj (Var sm) (Var sn) AND Var sl' EQ Q_Disj (Var sm') (Var sn') OR Var sl EQ Q_Neg (Var sm) AND Var sl' EQ Q_Neg (Var sm') OR Var sl EQ Q_Ex (Var sm) AND Var sl' EQ Q_Ex (Var sm'), HPair (Var m) (HPair (Var sm) (Var sm')) IN s, Var n IN k, Var m IN k, x EQ Var sl, y EQ Var sl', HPair k (HPair (Var sl) (Var sl')) IN s, All2 l k (SyntaxN.Ex sl (SyntaxN.Ex sl' (HPair (Var l) (HPair (Var sl) (Var sl')) IN s AND (SubstAtomicP v u (Var sl) (Var sl') OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN Var l AND Var n IN Var l AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND (Var sl EQ Q_Disj (Var sm) (Var sn) AND Var sl' EQ Q_Disj (Var sm') (Var sn') OR Var sl EQ Q_Neg (Var sm) AND Var sl' EQ Q_Neg (Var sm') OR Var sl EQ Q_Ex (Var sm) AND Var sl' EQ Q_Ex (Var sm')))))))))))), LstSeqP s k (HPair x y)} ⊢ (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN k AND Var n IN k AND SeqSubstFormP v u (Var sm) (Var sm') s (Var m) AND SeqSubstFormP v u (Var sn) (Var sn') s (Var n) AND (x EQ Q_Disj (Var sm) (Var sn) AND y EQ Q_Disj (Var sm') (Var sn') OR x EQ Q_Neg (Var sm) AND y EQ Q_Neg (Var sm') OR x EQ Q_Ex (Var sm) AND y EQ Q_Ex (Var sm'))))))(sm::=Var sm)› and 16 goals remain*) apply (rule Ex_I [where x = "Var sm'"] (*‹(?H::fm set) ⊢ (?A::fm)(?i::name::=Var (sm'::name)) ⟹ ?H ⊢ SyntaxN.Ex ?i ?A›*)) (*top goal: ‹⟦atom l ♯ (v, u, x, y, s, k, sl, sl', m, n, sm, sm', sn, sn'); atom sl ♯ (v, u, x, y, s, k, sl', m, n, sm, sm', sn, sn'); atom sl' ♯ (v, u, x, y, s, k, m, n, sm, sm', sn, sn'); atom m ♯ (v, u, x, y, s, k, n, sm, sm', sn, sn'); atom n ♯ (v, u, x, y, s, k, sm, sm', sn, sn'); atom sm ♯ (v, u, x, y, s, k, sm', sn, sn'); atom sm' ♯ (v, u, x, y, s, k, sn, sn'); atom sn ♯ (v, u, x, y, s, k, sn'); atom sn' ♯ (v, u, x, y, s, k)⟧ ⟹ {HPair (Var n) (HPair (Var sn) (Var sn')) IN s, Var sl EQ Q_Disj (Var sm) (Var sn) AND Var sl' EQ Q_Disj (Var sm') (Var sn') OR Var sl EQ Q_Neg (Var sm) AND Var sl' EQ Q_Neg (Var sm') OR Var sl EQ Q_Ex (Var sm) AND Var sl' EQ Q_Ex (Var sm'), HPair (Var m) (HPair (Var sm) (Var sm')) IN s, Var n IN k, Var m IN k, x EQ Var sl, y EQ Var sl', HPair k (HPair (Var sl) (Var sl')) IN s, All2 l k (SyntaxN.Ex sl (SyntaxN.Ex sl' (HPair (Var l) (HPair (Var sl) (Var sl')) IN s AND (SubstAtomicP v u (Var sl) (Var sl') OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN Var l AND Var n IN Var l AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND (Var sl EQ Q_Disj (Var sm) (Var sn) AND Var sl' EQ Q_Disj (Var sm') (Var sn') OR Var sl EQ Q_Neg (Var sm) AND Var sl' EQ Q_Neg (Var sm') OR Var sl EQ Q_Ex (Var sm) AND Var sl' EQ Q_Ex (Var sm')))))))))))), LstSeqP s k (HPair x y)} ⊢ SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN k AND Var n IN k AND SeqSubstFormP v u (Var sm) (Var sm') s (Var m) AND SeqSubstFormP v u (Var sn) (Var sn') s (Var n) AND (x EQ Q_Disj (Var sm) (Var sn) AND y EQ Q_Disj (Var sm') (Var sn') OR x EQ Q_Neg (Var sm) AND y EQ Q_Neg (Var sm') OR x EQ Q_Ex (Var sm) AND y EQ Q_Ex (Var sm')))))› and 16 goals remain*) apply simp (*top goal: ‹⟦atom l ♯ (v, u, x, y, s, k, sl, sl', m, n, sm, sm', sn, sn'); atom sl ♯ (v, u, x, y, s, k, sl', m, n, sm, sm', sn, sn'); atom sl' ♯ (v, u, x, y, s, k, m, n, sm, sm', sn, sn'); atom m ♯ (v, u, x, y, s, k, n, sm, sm', sn, sn'); atom n ♯ (v, u, x, y, s, k, sm, sm', sn, sn'); atom sm ♯ (v, u, x, y, s, k, sm', sn, sn'); atom sm' ♯ (v, u, x, y, s, k, sn, sn'); atom sn ♯ (v, u, x, y, s, k, sn'); atom sn' ♯ (v, u, x, y, s, k)⟧ ⟹ {HPair (Var n) (HPair (Var sn) (Var sn')) IN s, Var sl EQ Q_Disj (Var sm) (Var sn) AND Var sl' EQ Q_Disj (Var sm') (Var sn') OR Var sl EQ Q_Neg (Var sm) AND Var sl' EQ Q_Neg (Var sm') OR Var sl EQ Q_Ex (Var sm) AND Var sl' EQ Q_Ex (Var sm'), HPair (Var m) (HPair (Var sm) (Var sm')) IN s, Var n IN k, Var m IN k, x EQ Var sl, y EQ Var sl', HPair k (HPair (Var sl) (Var sl')) IN s, All2 l k (SyntaxN.Ex sl (SyntaxN.Ex sl' (HPair (Var l) (HPair (Var sl) (Var sl')) IN s AND (SubstAtomicP v u (Var sl) (Var sl') OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN Var l AND Var n IN Var l AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND (Var sl EQ Q_Disj (Var sm) (Var sn) AND Var sl' EQ Q_Disj (Var sm') (Var sn') OR Var sl EQ Q_Neg (Var sm) AND Var sl' EQ Q_Neg (Var sm') OR Var sl EQ Q_Ex (Var sm) AND Var sl' EQ Q_Ex (Var sm')))))))))))), LstSeqP s k (HPair x y)} ⊢ (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN k AND Var n IN k AND SeqSubstFormP v u (Var sm) (Var sm') s (Var m) AND SeqSubstFormP v u (Var sn) (Var sn') s (Var n) AND (x EQ Q_Disj (Var sm) (Var sn) AND y EQ Q_Disj (Var sm') (Var sn') OR x EQ Q_Neg (Var sm) AND y EQ Q_Neg (Var sm') OR x EQ Q_Ex (Var sm) AND y EQ Q_Ex (Var sm')))))(sm'::=Var sm')› and 16 goals remain*) apply (rule Ex_I [where x = "Var sn"] (*‹?H ⊢ ?A(?i::=Var sn) ⟹ ?H ⊢ SyntaxN.Ex ?i ?A›*)) (*top goal: ‹⟦atom l ♯ (v, u, x, y, s, k, sl, sl', m, n, sm, sm', sn, sn'); atom sl ♯ (v, u, x, y, s, k, sl', m, n, sm, sm', sn, sn'); atom sl' ♯ (v, u, x, y, s, k, m, n, sm, sm', sn, sn'); atom m ♯ (v, u, x, y, s, k, n, sm, sm', sn, sn'); atom n ♯ (v, u, x, y, s, k, sm, sm', sn, sn'); atom sm ♯ (v, u, x, y, s, k, sm', sn, sn'); atom sm' ♯ (v, u, x, y, s, k, sn, sn'); atom sn ♯ (v, u, x, y, s, k, sn'); atom sn' ♯ (v, u, x, y, s, k)⟧ ⟹ {HPair (Var n) (HPair (Var sn) (Var sn')) IN s, Var sl EQ Q_Disj (Var sm) (Var sn) AND Var sl' EQ Q_Disj (Var sm') (Var sn') OR Var sl EQ Q_Neg (Var sm) AND Var sl' EQ Q_Neg (Var sm') OR Var sl EQ Q_Ex (Var sm) AND Var sl' EQ Q_Ex (Var sm'), HPair (Var m) (HPair (Var sm) (Var sm')) IN s, Var n IN k, Var m IN k, x EQ Var sl, y EQ Var sl', HPair k (HPair (Var sl) (Var sl')) IN s, All2 l k (SyntaxN.Ex sl (SyntaxN.Ex sl' (HPair (Var l) (HPair (Var sl) (Var sl')) IN s AND (SubstAtomicP v u (Var sl) (Var sl') OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN Var l AND Var n IN Var l AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND (Var sl EQ Q_Disj (Var sm) (Var sn) AND Var sl' EQ Q_Disj (Var sm') (Var sn') OR Var sl EQ Q_Neg (Var sm) AND Var sl' EQ Q_Neg (Var sm') OR Var sl EQ Q_Ex (Var sm) AND Var sl' EQ Q_Ex (Var sm')))))))))))), LstSeqP s k (HPair x y)} ⊢ SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN k AND Var n IN k AND SeqSubstFormP v u (Var sm) (Var sm') s (Var m) AND SeqSubstFormP v u (Var sn) (Var sn') s (Var n) AND (x EQ Q_Disj (Var sm) (Var sn) AND y EQ Q_Disj (Var sm') (Var sn') OR x EQ Q_Neg (Var sm) AND y EQ Q_Neg (Var sm') OR x EQ Q_Ex (Var sm) AND y EQ Q_Ex (Var sm'))))› and 16 goals remain*) apply simp (*top goal: ‹⟦atom l ♯ (v, u, x, y, s, k, sl, sl', m, n, sm, sm', sn, sn'); atom sl ♯ (v, u, x, y, s, k, sl', m, n, sm, sm', sn, sn'); atom sl' ♯ (v, u, x, y, s, k, m, n, sm, sm', sn, sn'); atom m ♯ (v, u, x, y, s, k, n, sm, sm', sn, sn'); atom n ♯ (v, u, x, y, s, k, sm, sm', sn, sn'); atom sm ♯ (v, u, x, y, s, k, sm', sn, sn'); atom sm' ♯ (v, u, x, y, s, k, sn, sn'); atom sn ♯ (v, u, x, y, s, k, sn'); atom sn' ♯ (v, u, x, y, s, k)⟧ ⟹ {HPair (Var n) (HPair (Var sn) (Var sn')) IN s, Var sl EQ Q_Disj (Var sm) (Var sn) AND Var sl' EQ Q_Disj (Var sm') (Var sn') OR Var sl EQ Q_Neg (Var sm) AND Var sl' EQ Q_Neg (Var sm') OR Var sl EQ Q_Ex (Var sm) AND Var sl' EQ Q_Ex (Var sm'), HPair (Var m) (HPair (Var sm) (Var sm')) IN s, Var n IN k, Var m IN k, x EQ Var sl, y EQ Var sl', HPair k (HPair (Var sl) (Var sl')) IN s, All2 l k (SyntaxN.Ex sl (SyntaxN.Ex sl' (HPair (Var l) (HPair (Var sl) (Var sl')) IN s AND (SubstAtomicP v u (Var sl) (Var sl') OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN Var l AND Var n IN Var l AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND (Var sl EQ Q_Disj (Var sm) (Var sn) AND Var sl' EQ Q_Disj (Var sm') (Var sn') OR Var sl EQ Q_Neg (Var sm) AND Var sl' EQ Q_Neg (Var sm') OR Var sl EQ Q_Ex (Var sm) AND Var sl' EQ Q_Ex (Var sm')))))))))))), LstSeqP s k (HPair x y)} ⊢ (SyntaxN.Ex sn' (Var m IN k AND Var n IN k AND SeqSubstFormP v u (Var sm) (Var sm') s (Var m) AND SeqSubstFormP v u (Var sn) (Var sn') s (Var n) AND (x EQ Q_Disj (Var sm) (Var sn) AND y EQ Q_Disj (Var sm') (Var sn') OR x EQ Q_Neg (Var sm) AND y EQ Q_Neg (Var sm') OR x EQ Q_Ex (Var sm) AND y EQ Q_Ex (Var sm'))))(sn::=Var sn)› and 16 goals remain*) apply (rule Ex_I [where x = "Var sn'"] (*‹?H ⊢ ?A(?i::=Var sn') ⟹ ?H ⊢ SyntaxN.Ex ?i ?A›*)) (*top goal: ‹⟦atom (l::name) ♯ (v::tm, u::tm, x::tm, y::tm, s::tm, k::tm, sl::name, sl'::name, m::name, n::name, sm::name, sm'::name, sn::name, sn'::name); atom sl ♯ (v, u, x, y, s, k, sl', m, n, sm, sm', sn, sn'); atom sl' ♯ (v, u, x, y, s, k, m, n, sm, sm', sn, sn'); atom m ♯ (v, u, x, y, s, k, n, sm, sm', sn, sn'); atom n ♯ (v, u, x, y, s, k, sm, sm', sn, sn'); atom sm ♯ (v, u, x, y, s, k, sm', sn, sn'); atom sm' ♯ (v, u, x, y, s, k, sn, sn'); atom sn ♯ (v, u, x, y, s, k, sn'); atom sn' ♯ (v, u, x, y, s, k)⟧ ⟹ {HPair (Var n) (HPair (Var sn) (Var sn')) IN s, Var sl EQ Q_Disj (Var sm) (Var sn) AND Var sl' EQ Q_Disj (Var sm') (Var sn') OR Var sl EQ Q_Neg (Var sm) AND Var sl' EQ Q_Neg (Var sm') OR Var sl EQ Q_Ex (Var sm) AND Var sl' EQ Q_Ex (Var sm'), HPair (Var m) (HPair (Var sm) (Var sm')) IN s, Var n IN k, Var m IN k, x EQ Var sl, y EQ Var sl', HPair k (HPair (Var sl) (Var sl')) IN s, All2 l k (SyntaxN.Ex sl (SyntaxN.Ex sl' (HPair (Var l) (HPair (Var sl) (Var sl')) IN s AND (SubstAtomicP v u (Var sl) (Var sl') OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN Var l AND Var n IN Var l AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND (Var sl EQ Q_Disj (Var sm) (Var sn) AND Var sl' EQ Q_Disj (Var sm') (Var sn') OR Var sl EQ Q_Neg (Var sm) AND Var sl' EQ Q_Neg (Var sm') OR Var sl EQ Q_Ex (Var sm) AND Var sl' EQ Q_Ex (Var sm')))))))))))), LstSeqP s k (HPair x y)} ⊢ SyntaxN.Ex sn' (Var m IN k AND Var n IN k AND SeqSubstFormP v u (Var sm) (Var sm') s (Var m) AND SeqSubstFormP v u (Var sn) (Var sn') s (Var n) AND (x EQ Q_Disj (Var sm) (Var sn) AND y EQ Q_Disj (Var sm') (Var sn') OR x EQ Q_Neg (Var sm) AND y EQ Q_Neg (Var sm') OR x EQ Q_Ex (Var sm) AND y EQ Q_Ex (Var sm')))› and 16 goals remain*) apply simp (*top goal: ‹⟦atom l ♯ (v, u, x, y, s, k, sl, sl', m, n, sm, sm', sn, sn'); atom sl ♯ (v, u, x, y, s, k, sl', m, n, sm, sm', sn, sn'); atom sl' ♯ (v, u, x, y, s, k, m, n, sm, sm', sn, sn'); atom m ♯ (v, u, x, y, s, k, n, sm, sm', sn, sn'); atom n ♯ (v, u, x, y, s, k, sm, sm', sn, sn'); atom sm ♯ (v, u, x, y, s, k, sm', sn, sn'); atom sm' ♯ (v, u, x, y, s, k, sn, sn'); atom sn ♯ (v, u, x, y, s, k, sn'); atom sn' ♯ (v, u, x, y, s, k)⟧ ⟹ {HPair (Var n) (HPair (Var sn) (Var sn')) IN s, Var sl EQ Q_Disj (Var sm) (Var sn) AND Var sl' EQ Q_Disj (Var sm') (Var sn') OR Var sl EQ Q_Neg (Var sm) AND Var sl' EQ Q_Neg (Var sm') OR Var sl EQ Q_Ex (Var sm) AND Var sl' EQ Q_Ex (Var sm'), HPair (Var m) (HPair (Var sm) (Var sm')) IN s, Var n IN k, Var m IN k, x EQ Var sl, y EQ Var sl', HPair k (HPair (Var sl) (Var sl')) IN s, All2 l k (SyntaxN.Ex sl (SyntaxN.Ex sl' (HPair (Var l) (HPair (Var sl) (Var sl')) IN s AND (SubstAtomicP v u (Var sl) (Var sl') OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN Var l AND Var n IN Var l AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND (Var sl EQ Q_Disj (Var sm) (Var sn) AND Var sl' EQ Q_Disj (Var sm') (Var sn') OR Var sl EQ Q_Neg (Var sm) AND Var sl' EQ Q_Neg (Var sm') OR Var sl EQ Q_Ex (Var sm) AND Var sl' EQ Q_Ex (Var sm')))))))))))), LstSeqP s k (HPair x y)} ⊢ (Var m IN k AND Var n IN k AND SeqSubstFormP v u (Var sm) (Var sm') s (Var m) AND SeqSubstFormP v u (Var sn) (Var sn') s (Var n) AND (x EQ Q_Disj (Var sm) (Var sn) AND y EQ Q_Disj (Var sm') (Var sn') OR x EQ Q_Neg (Var sm) AND y EQ Q_Neg (Var sm') OR x EQ Q_Ex (Var sm) AND y EQ Q_Ex (Var sm')))(sn'::=Var sn')› and 16 goals remain*) apply (simp add: SeqSubstFormP.simps [of l s _ v u sl sl' m n sm sm' sn sn'] (*‹⟦atom (l::name) ♯ (s::tm, ?k::tm, v::tm, u::tm, sl::name, sl'::name, m::name, n::name, sm::name, sm'::name, sn::name, sn'::name); atom sl ♯ (s, v, u, sl', m, n, sm, sm', sn, sn'); atom sl' ♯ (s, v, u, m, n, sm, sm', sn, sn'); atom m ♯ (s, n, sm, sm', sn, sn'); atom n ♯ (s, sm, sm', sn, sn'); atom sm ♯ (s, sm', sn, sn'); atom sm' ♯ (s, sn, sn'); atom sn ♯ (s, sn'); atom sn' ♯ s⟧ ⟹ SeqSubstFormP v u (?x::tm) (?x'::tm) s ?k = LstSeqP s ?k (HPair ?x ?x') AND All2 l (SUCC ?k) (SyntaxN.Ex sl (SyntaxN.Ex sl' (HPair (Var l) (HPair (Var sl) (Var sl')) IN s AND (SubstAtomicP v u (Var sl) (Var sl') OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN Var l AND Var n IN Var l AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND (Var sl EQ Q_Disj (Var sm) (Var sn) AND Var sl' EQ Q_Disj (Var sm') (Var sn') OR Var sl EQ Q_Neg (Var sm) AND Var sl' EQ Q_Neg (Var sm') OR Var sl EQ Q_Ex (Var sm) AND Var sl' EQ Q_Ex (Var sm'))))))))))))›*)) (*top goal: ‹⟦atom l ♯ (v, u, x, y, s, k, sl, sl', m, n, sm, sm', sn, sn'); atom sl ♯ (v, u, x, y, s, k, sl', m, n, sm, sm', sn, sn'); atom sl' ♯ (v, u, x, y, s, k, m, n, sm, sm', sn, sn'); atom m ♯ (v, u, x, y, s, k, n, sm, sm', sn, sn'); atom n ♯ (v, u, x, y, s, k, sm, sm', sn, sn'); atom sm ♯ (v, u, x, y, s, k, sm', sn, sn'); atom sm' ♯ (v, u, x, y, s, k, sn, sn'); atom sn ♯ (v, u, x, y, s, k, sn'); atom sn' ♯ (v, u, x, y, s, k)⟧ ⟹ {HPair (Var n) (HPair (Var sn) (Var sn')) IN s, Var sl EQ Q_Disj (Var sm) (Var sn) AND Var sl' EQ Q_Disj (Var sm') (Var sn') OR Var sl EQ Q_Neg (Var sm) AND Var sl' EQ Q_Neg (Var sm') OR Var sl EQ Q_Ex (Var sm) AND Var sl' EQ Q_Ex (Var sm'), HPair (Var m) (HPair (Var sm) (Var sm')) IN s, Var n IN k, Var m IN k, x EQ Var sl, y EQ Var sl', HPair k (HPair (Var sl) (Var sl')) IN s, All2 l k (SyntaxN.Ex sl (SyntaxN.Ex sl' (HPair (Var l) (HPair (Var sl) (Var sl')) IN s AND (SubstAtomicP v u (Var sl) (Var sl') OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN Var l AND Var n IN Var l AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND (Var sl EQ Q_Disj (Var sm) (Var sn) AND Var sl' EQ Q_Disj (Var sm') (Var sn') OR Var sl EQ Q_Neg (Var sm) AND Var sl' EQ Q_Neg (Var sm') OR Var sl EQ Q_Ex (Var sm) AND Var sl' EQ Q_Ex (Var sm')))))))))))), LstSeqP s k (HPair x y)} ⊢ Var m IN k AND Var n IN k AND SeqSubstFormP v u (Var sm) (Var sm') s (Var m) AND SeqSubstFormP v u (Var sn) (Var sn') s (Var n) AND (x EQ Q_Disj (Var sm) (Var sn) AND y EQ Q_Disj (Var sm') (Var sn') OR x EQ Q_Neg (Var sm) AND y EQ Q_Neg (Var sm') OR x EQ Q_Ex (Var sm) AND y EQ Q_Ex (Var sm'))› and 16 goals remain*) apply (rule Conj_I (*‹⟦(?H::fm set) ⊢ (?A::fm); ?H ⊢ (?B::fm)⟧ ⟹ ?H ⊢ ?A AND ?B›*)) (*goals: 1. ‹⟦atom l ♯ (v, u, x, y, s, k, sl, sl', m, n, sm, sm', sn, sn'); atom sl ♯ (v, u, x, y, s, k, sl', m, n, sm, sm', sn, sn'); atom sl' ♯ (v, u, x, y, s, k, m, n, sm, sm', sn, sn'); atom m ♯ (v, u, x, y, s, k, n, sm, sm', sn, sn'); atom n ♯ (v, u, x, y, s, k, sm, sm', sn, sn'); atom sm ♯ (v, u, x, y, s, k, sm', sn, sn'); atom sm' ♯ (v, u, x, y, s, k, sn, sn'); atom sn ♯ (v, u, x, y, s, k, sn'); atom sn' ♯ (v, u, x, y, s, k)⟧ ⟹ {HPair (Var n) (HPair (Var sn) (Var sn')) IN s, Var sl EQ Q_Disj (Var sm) (Var sn) AND Var sl' EQ Q_Disj (Var sm') (Var sn') OR Var sl EQ Q_Neg (Var sm) AND Var sl' EQ Q_Neg (Var sm') OR Var sl EQ Q_Ex (Var sm) AND Var sl' EQ Q_Ex (Var sm'), HPair (Var m) (HPair (Var sm) (Var sm')) IN s, Var n IN k, Var m IN k, x EQ Var sl, y EQ Var sl', HPair k (HPair (Var sl) (Var sl')) IN s, All2 l k (SyntaxN.Ex sl (SyntaxN.Ex sl' (HPair (Var l) (HPair (Var sl) (Var sl')) IN s AND (SubstAtomicP v u (Var sl) (Var sl') OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN Var l AND Var n IN Var l AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND (Var sl EQ Q_Disj (Var sm) (Var sn) AND Var sl' EQ Q_Disj (Var sm') (Var sn') OR Var sl EQ Q_Neg (Var sm) AND Var sl' EQ Q_Neg (Var sm') OR Var sl EQ Q_Ex (Var sm) AND Var sl' EQ Q_Ex (Var sm')))))))))))), LstSeqP s k (HPair x y)} ⊢ Var m IN k› 2. ‹⟦atom l ♯ (v, u, x, y, s, k, sl, sl', m, n, sm, sm', sn, sn'); atom sl ♯ (v, u, x, y, s, k, sl', m, n, sm, sm', sn, sn'); atom sl' ♯ (v, u, x, y, s, k, m, n, sm, sm', sn, sn'); atom m ♯ (v, u, x, y, s, k, n, sm, sm', sn, sn'); atom n ♯ (v, u, x, y, s, k, sm, sm', sn, sn'); atom sm ♯ (v, u, x, y, s, k, sm', sn, sn'); atom sm' ♯ (v, u, x, y, s, k, sn, sn'); atom sn ♯ (v, u, x, y, s, k, sn'); atom sn' ♯ (v, u, x, y, s, k)⟧ ⟹ {HPair (Var n) (HPair (Var sn) (Var sn')) IN s, Var sl EQ Q_Disj (Var sm) (Var sn) AND Var sl' EQ Q_Disj (Var sm') (Var sn') OR Var sl EQ Q_Neg (Var sm) AND Var sl' EQ Q_Neg (Var sm') OR Var sl EQ Q_Ex (Var sm) AND Var sl' EQ Q_Ex (Var sm'), HPair (Var m) (HPair (Var sm) (Var sm')) IN s, Var n IN k, Var m IN k, x EQ Var sl, y EQ Var sl', HPair k (HPair (Var sl) (Var sl')) IN s, All2 l k (SyntaxN.Ex sl (SyntaxN.Ex sl' (HPair (Var l) (HPair (Var sl) (Var sl')) IN s AND (SubstAtomicP v u (Var sl) (Var sl') OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN Var l AND Var n IN Var l AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND (Var sl EQ Q_Disj (Var sm) (Var sn) AND Var sl' EQ Q_Disj (Var sm') (Var sn') OR Var sl EQ Q_Neg (Var sm) AND Var sl' EQ Q_Neg (Var sm') OR Var sl EQ Q_Ex (Var sm) AND Var sl' EQ Q_Ex (Var sm')))))))))))), LstSeqP s k (HPair x y)} ⊢ Var n IN k AND (LstSeqP s (Var m) (HPair (Var sm) (Var sm')) AND All2 l (SUCC (Var m)) (SyntaxN.Ex sl (SyntaxN.Ex sl' (HPair (Var l) (HPair (Var sl) (Var sl')) IN s AND (SubstAtomicP v u (Var sl) (Var sl') OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN Var l AND Var n IN Var l AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND (Var sl EQ Q_Disj (Var sm) (Var sn) AND Var sl' EQ Q_Disj (Var sm') (Var sn') OR Var sl EQ Q_Neg (Var sm) AND Var sl' EQ Q_Neg (Var sm') OR Var sl EQ Q_Ex (Var sm) AND Var sl' EQ Q_Ex (Var sm'))))))))))))) AND (LstSeqP s (Var n) (HPair (Var sn) (Var sn')) AND All2 l (SUCC (Var n)) (SyntaxN.Ex sl (SyntaxN.Ex sl' (HPair (Var l) (HPair (Var sl) (Var sl')) IN s AND (SubstAtomicP v u (Var sl) (Var sl') OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN Var l AND Var n IN Var l AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND (Var sl EQ Q_Disj (Var sm) (Var sn) AND Var sl' EQ Q_Disj (Var sm') (Var sn') OR Var sl EQ Q_Neg (Var sm) AND Var sl' EQ Q_Neg (Var sm') OR Var sl EQ Q_Ex (Var sm) AND Var sl' EQ Q_Ex (Var sm'))))))))))))) AND (x EQ Q_Disj (Var sm) (Var sn) AND y EQ Q_Disj (Var sm') (Var sn') OR x EQ Q_Neg (Var sm) AND y EQ Q_Neg (Var sm') OR x EQ Q_Ex (Var sm) AND y EQ Q_Ex (Var sm'))› discuss goal 1*) apply (blast intro: LstSeqP_Mem (*‹⟦?H ⊢ LstSeqP ?r ?k ?y; ?H ⊢ HPair ?k' ?z IN ?r; ?H ⊢ ?k' IN ?k⟧ ⟹ ?H ⊢ LstSeqP ?r ?k' ?z›*)) (*discuss goal 2*) apply (rule Conj_I (*‹⟦?H ⊢ ?A; ?H ⊢ ?B⟧ ⟹ ?H ⊢ ?A AND ?B›*)) (*goals: 1. ‹⟦atom l ♯ (v, u, x, y, s, k, sl, sl', m, n, sm, sm', sn, sn'); atom sl ♯ (v, u, x, y, s, k, sl', m, n, sm, sm', sn, sn'); atom sl' ♯ (v, u, x, y, s, k, m, n, sm, sm', sn, sn'); atom m ♯ (v, u, x, y, s, k, n, sm, sm', sn, sn'); atom n ♯ (v, u, x, y, s, k, sm, sm', sn, sn'); atom sm ♯ (v, u, x, y, s, k, sm', sn, sn'); atom sm' ♯ (v, u, x, y, s, k, sn, sn'); atom sn ♯ (v, u, x, y, s, k, sn'); atom sn' ♯ (v, u, x, y, s, k)⟧ ⟹ {HPair (Var n) (HPair (Var sn) (Var sn')) IN s, Var sl EQ Q_Disj (Var sm) (Var sn) AND Var sl' EQ Q_Disj (Var sm') (Var sn') OR Var sl EQ Q_Neg (Var sm) AND Var sl' EQ Q_Neg (Var sm') OR Var sl EQ Q_Ex (Var sm) AND Var sl' EQ Q_Ex (Var sm'), HPair (Var m) (HPair (Var sm) (Var sm')) IN s, Var n IN k, Var m IN k, x EQ Var sl, y EQ Var sl', HPair k (HPair (Var sl) (Var sl')) IN s, All2 l k (SyntaxN.Ex sl (SyntaxN.Ex sl' (HPair (Var l) (HPair (Var sl) (Var sl')) IN s AND (SubstAtomicP v u (Var sl) (Var sl') OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN Var l AND Var n IN Var l AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND (Var sl EQ Q_Disj (Var sm) (Var sn) AND Var sl' EQ Q_Disj (Var sm') (Var sn') OR Var sl EQ Q_Neg (Var sm) AND Var sl' EQ Q_Neg (Var sm') OR Var sl EQ Q_Ex (Var sm) AND Var sl' EQ Q_Ex (Var sm')))))))))))), LstSeqP s k (HPair x y)} ⊢ Var n IN k› 2. ‹⟦atom l ♯ (v, u, x, y, s, k, sl, sl', m, n, sm, sm', sn, sn'); atom sl ♯ (v, u, x, y, s, k, sl', m, n, sm, sm', sn, sn'); atom sl' ♯ (v, u, x, y, s, k, m, n, sm, sm', sn, sn'); atom m ♯ (v, u, x, y, s, k, n, sm, sm', sn, sn'); atom n ♯ (v, u, x, y, s, k, sm, sm', sn, sn'); atom sm ♯ (v, u, x, y, s, k, sm', sn, sn'); atom sm' ♯ (v, u, x, y, s, k, sn, sn'); atom sn ♯ (v, u, x, y, s, k, sn'); atom sn' ♯ (v, u, x, y, s, k)⟧ ⟹ {HPair (Var n) (HPair (Var sn) (Var sn')) IN s, Var sl EQ Q_Disj (Var sm) (Var sn) AND Var sl' EQ Q_Disj (Var sm') (Var sn') OR Var sl EQ Q_Neg (Var sm) AND Var sl' EQ Q_Neg (Var sm') OR Var sl EQ Q_Ex (Var sm) AND Var sl' EQ Q_Ex (Var sm'), HPair (Var m) (HPair (Var sm) (Var sm')) IN s, Var n IN k, Var m IN k, x EQ Var sl, y EQ Var sl', HPair k (HPair (Var sl) (Var sl')) IN s, All2 l k (SyntaxN.Ex sl (SyntaxN.Ex sl' (HPair (Var l) (HPair (Var sl) (Var sl')) IN s AND (SubstAtomicP v u (Var sl) (Var sl') OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN Var l AND Var n IN Var l AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND (Var sl EQ Q_Disj (Var sm) (Var sn) AND Var sl' EQ Q_Disj (Var sm') (Var sn') OR Var sl EQ Q_Neg (Var sm) AND Var sl' EQ Q_Neg (Var sm') OR Var sl EQ Q_Ex (Var sm) AND Var sl' EQ Q_Ex (Var sm')))))))))))), LstSeqP s k (HPair x y)} ⊢ (LstSeqP s (Var m) (HPair (Var sm) (Var sm')) AND All2 l (SUCC (Var m)) (SyntaxN.Ex sl (SyntaxN.Ex sl' (HPair (Var l) (HPair (Var sl) (Var sl')) IN s AND (SubstAtomicP v u (Var sl) (Var sl') OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN Var l AND Var n IN Var l AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND (Var sl EQ Q_Disj (Var sm) (Var sn) AND Var sl' EQ Q_Disj (Var sm') (Var sn') OR Var sl EQ Q_Neg (Var sm) AND Var sl' EQ Q_Neg (Var sm') OR Var sl EQ Q_Ex (Var sm) AND Var sl' EQ Q_Ex (Var sm'))))))))))))) AND (LstSeqP s (Var n) (HPair (Var sn) (Var sn')) AND All2 l (SUCC (Var n)) (SyntaxN.Ex sl (SyntaxN.Ex sl' (HPair (Var l) (HPair (Var sl) (Var sl')) IN s AND (SubstAtomicP v u (Var sl) (Var sl') OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN Var l AND Var n IN Var l AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND (Var sl EQ Q_Disj (Var sm) (Var sn) AND Var sl' EQ Q_Disj (Var sm') (Var sn') OR Var sl EQ Q_Neg (Var sm) AND Var sl' EQ Q_Neg (Var sm') OR Var sl EQ Q_Ex (Var sm) AND Var sl' EQ Q_Ex (Var sm'))))))))))))) AND (x EQ Q_Disj (Var sm) (Var sn) AND y EQ Q_Disj (Var sm') (Var sn') OR x EQ Q_Neg (Var sm) AND y EQ Q_Neg (Var sm') OR x EQ Q_Ex (Var sm) AND y EQ Q_Ex (Var sm'))› discuss goal 1*) apply (blast intro: LstSeqP_Mem (*‹⟦?H ⊢ LstSeqP ?r ?k ?y; ?H ⊢ HPair ?k' ?z IN ?r; ?H ⊢ ?k' IN ?k⟧ ⟹ ?H ⊢ LstSeqP ?r ?k' ?z›*)) (*discuss goal 2*) apply (rule Conj_I (*‹⟦?H ⊢ ?A; ?H ⊢ ?B⟧ ⟹ ?H ⊢ ?A AND ?B›*)) (*goals: 1. ‹⟦atom (l::name) ♯ (v::tm, u::tm, x::tm, y::tm, s::tm, k::tm, sl::name, sl'::name, m::name, n::name, sm::name, sm'::name, sn::name, sn'::name); atom sl ♯ (v, u, x, y, s, k, sl', m, n, sm, sm', sn, sn'); atom sl' ♯ (v, u, x, y, s, k, m, n, sm, sm', sn, sn'); atom m ♯ (v, u, x, y, s, k, n, sm, sm', sn, sn'); atom n ♯ (v, u, x, y, s, k, sm, sm', sn, sn'); atom sm ♯ (v, u, x, y, s, k, sm', sn, sn'); atom sm' ♯ (v, u, x, y, s, k, sn, sn'); atom sn ♯ (v, u, x, y, s, k, sn'); atom sn' ♯ (v, u, x, y, s, k)⟧ ⟹ {HPair (Var n) (HPair (Var sn) (Var sn')) IN s, Var sl EQ Q_Disj (Var sm) (Var sn) AND Var sl' EQ Q_Disj (Var sm') (Var sn') OR Var sl EQ Q_Neg (Var sm) AND Var sl' EQ Q_Neg (Var sm') OR Var sl EQ Q_Ex (Var sm) AND Var sl' EQ Q_Ex (Var sm'), HPair (Var m) (HPair (Var sm) (Var sm')) IN s, Var n IN k, Var m IN k, x EQ Var sl, y EQ Var sl', HPair k (HPair (Var sl) (Var sl')) IN s, All2 l k (SyntaxN.Ex sl (SyntaxN.Ex sl' (HPair (Var l) (HPair (Var sl) (Var sl')) IN s AND (SubstAtomicP v u (Var sl) (Var sl') OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN Var l AND Var n IN Var l AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND (Var sl EQ Q_Disj (Var sm) (Var sn) AND Var sl' EQ Q_Disj (Var sm') (Var sn') OR Var sl EQ Q_Neg (Var sm) AND Var sl' EQ Q_Neg (Var sm') OR Var sl EQ Q_Ex (Var sm) AND Var sl' EQ Q_Ex (Var sm')))))))))))), LstSeqP s k (HPair x y)} ⊢ LstSeqP s (Var m) (HPair (Var sm) (Var sm')) AND All2 l (SUCC (Var m)) (SyntaxN.Ex sl (SyntaxN.Ex sl' (HPair (Var l) (HPair (Var sl) (Var sl')) IN s AND (SubstAtomicP v u (Var sl) (Var sl') OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN Var l AND Var n IN Var l AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND (Var sl EQ Q_Disj (Var sm) (Var sn) AND Var sl' EQ Q_Disj (Var sm') (Var sn') OR Var sl EQ Q_Neg (Var sm) AND Var sl' EQ Q_Neg (Var sm') OR Var sl EQ Q_Ex (Var sm) AND Var sl' EQ Q_Ex (Var sm'))))))))))))› 2. ‹⟦atom (l::name) ♯ (v::tm, u::tm, x::tm, y::tm, s::tm, k::tm, sl::name, sl'::name, m::name, n::name, sm::name, sm'::name, sn::name, sn'::name); atom sl ♯ (v, u, x, y, s, k, sl', m, n, sm, sm', sn, sn'); atom sl' ♯ (v, u, x, y, s, k, m, n, sm, sm', sn, sn'); atom m ♯ (v, u, x, y, s, k, n, sm, sm', sn, sn'); atom n ♯ (v, u, x, y, s, k, sm, sm', sn, sn'); atom sm ♯ (v, u, x, y, s, k, sm', sn, sn'); atom sm' ♯ (v, u, x, y, s, k, sn, sn'); atom sn ♯ (v, u, x, y, s, k, sn'); atom sn' ♯ (v, u, x, y, s, k)⟧ ⟹ {HPair (Var n) (HPair (Var sn) (Var sn')) IN s, Var sl EQ Q_Disj (Var sm) (Var sn) AND Var sl' EQ Q_Disj (Var sm') (Var sn') OR Var sl EQ Q_Neg (Var sm) AND Var sl' EQ Q_Neg (Var sm') OR Var sl EQ Q_Ex (Var sm) AND Var sl' EQ Q_Ex (Var sm'), HPair (Var m) (HPair (Var sm) (Var sm')) IN s, Var n IN k, Var m IN k, x EQ Var sl, y EQ Var sl', HPair k (HPair (Var sl) (Var sl')) IN s, All2 l k (SyntaxN.Ex sl (SyntaxN.Ex sl' (HPair (Var l) (HPair (Var sl) (Var sl')) IN s AND (SubstAtomicP v u (Var sl) (Var sl') OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN Var l AND Var n IN Var l AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND (Var sl EQ Q_Disj (Var sm) (Var sn) AND Var sl' EQ Q_Disj (Var sm') (Var sn') OR Var sl EQ Q_Neg (Var sm) AND Var sl' EQ Q_Neg (Var sm') OR Var sl EQ Q_Ex (Var sm) AND Var sl' EQ Q_Ex (Var sm')))))))))))), LstSeqP s k (HPair x y)} ⊢ (LstSeqP s (Var n) (HPair (Var sn) (Var sn')) AND All2 l (SUCC (Var n)) (SyntaxN.Ex sl (SyntaxN.Ex sl' (HPair (Var l) (HPair (Var sl) (Var sl')) IN s AND (SubstAtomicP v u (Var sl) (Var sl') OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN Var l AND Var n IN Var l AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND (Var sl EQ Q_Disj (Var sm) (Var sn) AND Var sl' EQ Q_Disj (Var sm') (Var sn') OR Var sl EQ Q_Neg (Var sm) AND Var sl' EQ Q_Neg (Var sm') OR Var sl EQ Q_Ex (Var sm) AND Var sl' EQ Q_Ex (Var sm'))))))))))))) AND (x EQ Q_Disj (Var sm) (Var sn) AND y EQ Q_Disj (Var sm') (Var sn') OR x EQ Q_Neg (Var sm) AND y EQ Q_Neg (Var sm') OR x EQ Q_Ex (Var sm) AND y EQ Q_Ex (Var sm'))› discuss goal 1*) apply (rule Conj_I (*‹⟦?H ⊢ ?A; ?H ⊢ ?B⟧ ⟹ ?H ⊢ ?A AND ?B›*)) (*goals: 1. ‹⟦atom l ♯ (v, u, x, y, s, k, sl, sl', m, n, sm, sm', sn, sn'); atom sl ♯ (v, u, x, y, s, k, sl', m, n, sm, sm', sn, sn'); atom sl' ♯ (v, u, x, y, s, k, m, n, sm, sm', sn, sn'); atom m ♯ (v, u, x, y, s, k, n, sm, sm', sn, sn'); atom n ♯ (v, u, x, y, s, k, sm, sm', sn, sn'); atom sm ♯ (v, u, x, y, s, k, sm', sn, sn'); atom sm' ♯ (v, u, x, y, s, k, sn, sn'); atom sn ♯ (v, u, x, y, s, k, sn'); atom sn' ♯ (v, u, x, y, s, k)⟧ ⟹ {HPair (Var n) (HPair (Var sn) (Var sn')) IN s, Var sl EQ Q_Disj (Var sm) (Var sn) AND Var sl' EQ Q_Disj (Var sm') (Var sn') OR Var sl EQ Q_Neg (Var sm) AND Var sl' EQ Q_Neg (Var sm') OR Var sl EQ Q_Ex (Var sm) AND Var sl' EQ Q_Ex (Var sm'), HPair (Var m) (HPair (Var sm) (Var sm')) IN s, Var n IN k, Var m IN k, x EQ Var sl, y EQ Var sl', HPair k (HPair (Var sl) (Var sl')) IN s, All2 l k (SyntaxN.Ex sl (SyntaxN.Ex sl' (HPair (Var l) (HPair (Var sl) (Var sl')) IN s AND (SubstAtomicP v u (Var sl) (Var sl') OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN Var l AND Var n IN Var l AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND (Var sl EQ Q_Disj (Var sm) (Var sn) AND Var sl' EQ Q_Disj (Var sm') (Var sn') OR Var sl EQ Q_Neg (Var sm) AND Var sl' EQ Q_Neg (Var sm') OR Var sl EQ Q_Ex (Var sm) AND Var sl' EQ Q_Ex (Var sm')))))))))))), LstSeqP s k (HPair x y)} ⊢ LstSeqP s (Var m) (HPair (Var sm) (Var sm'))› 2. ‹⟦atom l ♯ (v, u, x, y, s, k, sl, sl', m, n, sm, sm', sn, sn'); atom sl ♯ (v, u, x, y, s, k, sl', m, n, sm, sm', sn, sn'); atom sl' ♯ (v, u, x, y, s, k, m, n, sm, sm', sn, sn'); atom m ♯ (v, u, x, y, s, k, n, sm, sm', sn, sn'); atom n ♯ (v, u, x, y, s, k, sm, sm', sn, sn'); atom sm ♯ (v, u, x, y, s, k, sm', sn, sn'); atom sm' ♯ (v, u, x, y, s, k, sn, sn'); atom sn ♯ (v, u, x, y, s, k, sn'); atom sn' ♯ (v, u, x, y, s, k)⟧ ⟹ {HPair (Var n) (HPair (Var sn) (Var sn')) IN s, Var sl EQ Q_Disj (Var sm) (Var sn) AND Var sl' EQ Q_Disj (Var sm') (Var sn') OR Var sl EQ Q_Neg (Var sm) AND Var sl' EQ Q_Neg (Var sm') OR Var sl EQ Q_Ex (Var sm) AND Var sl' EQ Q_Ex (Var sm'), HPair (Var m) (HPair (Var sm) (Var sm')) IN s, Var n IN k, Var m IN k, x EQ Var sl, y EQ Var sl', HPair k (HPair (Var sl) (Var sl')) IN s, All2 l k (SyntaxN.Ex sl (SyntaxN.Ex sl' (HPair (Var l) (HPair (Var sl) (Var sl')) IN s AND (SubstAtomicP v u (Var sl) (Var sl') OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN Var l AND Var n IN Var l AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND (Var sl EQ Q_Disj (Var sm) (Var sn) AND Var sl' EQ Q_Disj (Var sm') (Var sn') OR Var sl EQ Q_Neg (Var sm) AND Var sl' EQ Q_Neg (Var sm') OR Var sl EQ Q_Ex (Var sm) AND Var sl' EQ Q_Ex (Var sm')))))))))))), LstSeqP s k (HPair x y)} ⊢ All2 l (SUCC (Var m)) (SyntaxN.Ex sl (SyntaxN.Ex sl' (HPair (Var l) (HPair (Var sl) (Var sl')) IN s AND (SubstAtomicP v u (Var sl) (Var sl') OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN Var l AND Var n IN Var l AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND (Var sl EQ Q_Disj (Var sm) (Var sn) AND Var sl' EQ Q_Disj (Var sm') (Var sn') OR Var sl EQ Q_Neg (Var sm) AND Var sl' EQ Q_Neg (Var sm') OR Var sl EQ Q_Ex (Var sm) AND Var sl' EQ Q_Ex (Var sm'))))))))))))› discuss goal 1*) apply (blast intro: LstSeqP_Mem (*‹⟦?H ⊢ LstSeqP ?r ?k ?y; ?H ⊢ HPair ?k' ?z IN ?r; ?H ⊢ ?k' IN ?k⟧ ⟹ ?H ⊢ LstSeqP ?r ?k' ?z›*)) (*discuss goal 2*) apply (rule All2_Subset [OF Hyp] (*‹⟦All2 ?l ?k ?P ∈ ?H; ?H ⊢ ?k' SUBS ?k; {?P} ⊢ ?P'; atom ?l ♯ (?k', ?k)⟧ ⟹ ?H ⊢ All2 ?l ?k' ?P'›*)) (*goals: 1. ‹⟦atom (l::name) ♯ (v::tm, u::tm, x::tm, y::tm, s::tm, k::tm, sl::name, sl'::name, m::name, n::name, sm::name, sm'::name, sn::name, sn'::name); atom sl ♯ (v, u, x, y, s, k, sl', m, n, sm, sm', sn, sn'); atom sl' ♯ (v, u, x, y, s, k, m, n, sm, sm', sn, sn'); atom m ♯ (v, u, x, y, s, k, n, sm, sm', sn, sn'); atom n ♯ (v, u, x, y, s, k, sm, sm', sn, sn'); atom sm ♯ (v, u, x, y, s, k, sm', sn, sn'); atom sm' ♯ (v, u, x, y, s, k, sn, sn'); atom sn ♯ (v, u, x, y, s, k, sn'); atom sn' ♯ (v, u, x, y, s, k)⟧ ⟹ All2 l (?k150::tm) (?P150::fm) ∈ {HPair (Var n) (HPair (Var sn) (Var sn')) IN s, Var sl EQ Q_Disj (Var sm) (Var sn) AND Var sl' EQ Q_Disj (Var sm') (Var sn') OR Var sl EQ Q_Neg (Var sm) AND Var sl' EQ Q_Neg (Var sm') OR Var sl EQ Q_Ex (Var sm) AND Var sl' EQ Q_Ex (Var sm'), HPair (Var m) (HPair (Var sm) (Var sm')) IN s, Var n IN k, Var m IN k, x EQ Var sl, y EQ Var sl', HPair k (HPair (Var sl) (Var sl')) IN s, All2 l k (SyntaxN.Ex sl (SyntaxN.Ex sl' (HPair (Var l) (HPair (Var sl) (Var sl')) IN s AND (SubstAtomicP v u (Var sl) (Var sl') OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN Var l AND Var n IN Var l AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND (Var sl EQ Q_Disj (Var sm) (Var sn) AND Var sl' EQ Q_Disj (Var sm') (Var sn') OR Var sl EQ Q_Neg (Var sm) AND Var sl' EQ Q_Neg (Var sm') OR Var sl EQ Q_Ex (Var sm) AND Var sl' EQ Q_Ex (Var sm')))))))))))), LstSeqP s k (HPair x y)}› 2. ‹⟦atom (l::name) ♯ (v::tm, u::tm, x::tm, y::tm, s::tm, k::tm, sl::name, sl'::name, m::name, n::name, sm::name, sm'::name, sn::name, sn'::name); atom sl ♯ (v, u, x, y, s, k, sl', m, n, sm, sm', sn, sn'); atom sl' ♯ (v, u, x, y, s, k, m, n, sm, sm', sn, sn'); atom m ♯ (v, u, x, y, s, k, n, sm, sm', sn, sn'); atom n ♯ (v, u, x, y, s, k, sm, sm', sn, sn'); atom sm ♯ (v, u, x, y, s, k, sm', sn, sn'); atom sm' ♯ (v, u, x, y, s, k, sn, sn'); atom sn ♯ (v, u, x, y, s, k, sn'); atom sn' ♯ (v, u, x, y, s, k)⟧ ⟹ {HPair (Var n) (HPair (Var sn) (Var sn')) IN s, Var sl EQ Q_Disj (Var sm) (Var sn) AND Var sl' EQ Q_Disj (Var sm') (Var sn') OR Var sl EQ Q_Neg (Var sm) AND Var sl' EQ Q_Neg (Var sm') OR Var sl EQ Q_Ex (Var sm) AND Var sl' EQ Q_Ex (Var sm'), HPair (Var m) (HPair (Var sm) (Var sm')) IN s, Var n IN k, Var m IN k, x EQ Var sl, y EQ Var sl', HPair k (HPair (Var sl) (Var sl')) IN s, All2 l k (SyntaxN.Ex sl (SyntaxN.Ex sl' (HPair (Var l) (HPair (Var sl) (Var sl')) IN s AND (SubstAtomicP v u (Var sl) (Var sl') OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN Var l AND Var n IN Var l AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND (Var sl EQ Q_Disj (Var sm) (Var sn) AND Var sl' EQ Q_Disj (Var sm') (Var sn') OR Var sl EQ Q_Neg (Var sm) AND Var sl' EQ Q_Neg (Var sm') OR Var sl EQ Q_Ex (Var sm) AND Var sl' EQ Q_Ex (Var sm')))))))))))), LstSeqP s k (HPair x y)} ⊢ SUCC (Var m) SUBS (?k150::tm)› 3. ‹⟦atom (l::name) ♯ (v::tm, u::tm, x::tm, y::tm, s::tm, k::tm, sl::name, sl'::name, m::name, n::name, sm::name, sm'::name, sn::name, sn'::name); atom sl ♯ (v, u, x, y, s, k, sl', m, n, sm, sm', sn, sn'); atom sl' ♯ (v, u, x, y, s, k, m, n, sm, sm', sn, sn'); atom m ♯ (v, u, x, y, s, k, n, sm, sm', sn, sn'); atom n ♯ (v, u, x, y, s, k, sm, sm', sn, sn'); atom sm ♯ (v, u, x, y, s, k, sm', sn, sn'); atom sm' ♯ (v, u, x, y, s, k, sn, sn'); atom sn ♯ (v, u, x, y, s, k, sn'); atom sn' ♯ (v, u, x, y, s, k)⟧ ⟹ {?P150::fm} ⊢ SyntaxN.Ex sl (SyntaxN.Ex sl' (HPair (Var l) (HPair (Var sl) (Var sl')) IN s AND (SubstAtomicP v u (Var sl) (Var sl') OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN Var l AND Var n IN Var l AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND (Var sl EQ Q_Disj (Var sm) (Var sn) AND Var sl' EQ Q_Disj (Var sm') (Var sn') OR Var sl EQ Q_Neg (Var sm) AND Var sl' EQ Q_Neg (Var sm') OR Var sl EQ Q_Ex (Var sm) AND Var sl' EQ Q_Ex (Var sm')))))))))))› 4. ‹⟦atom (l::name) ♯ (v::tm, u::tm, x::tm, y::tm, s::tm, k::tm, sl::name, sl'::name, m::name, n::name, sm::name, sm'::name, sn::name, sn'::name); atom sl ♯ (v, u, x, y, s, k, sl', m, n, sm, sm', sn, sn'); atom sl' ♯ (v, u, x, y, s, k, m, n, sm, sm', sn, sn'); atom m ♯ (v, u, x, y, s, k, n, sm, sm', sn, sn'); atom n ♯ (v, u, x, y, s, k, sm, sm', sn, sn'); atom sm ♯ (v, u, x, y, s, k, sm', sn, sn'); atom sm' ♯ (v, u, x, y, s, k, sn, sn'); atom sn ♯ (v, u, x, y, s, k, sn'); atom sn' ♯ (v, u, x, y, s, k)⟧ ⟹ atom l ♯ (SUCC (Var m), ?k150::tm)› discuss goal 1*) apply blast (*discuss goal 2*) apply (blast intro!: SUCC_Subset_Ord (*‹⟦?H ⊢ ?k' IN ?k; ?H ⊢ OrdP ?k⟧ ⟹ ?H ⊢ SUCC ?k' SUBS ?k›*) LstSeqP_OrdP (*‹?H ⊢ LstSeqP ?r ?k ?y ⟹ ?H ⊢ OrdP ?k›*)) (*discuss goal 3*) apply blast (*discuss goal 4*) apply simp (*proven 4 subgoals*) (*proven 2 subgoals*) (*discuss goal 2*) apply (rule Conj_I (*‹⟦?H ⊢ ?A; ?H ⊢ ?B⟧ ⟹ ?H ⊢ ?A AND ?B›*)) (*goals: 1. ‹⟦atom l ♯ (v, u, x, y, s, k, sl, sl', m, n, sm, sm', sn, sn'); atom sl ♯ (v, u, x, y, s, k, sl', m, n, sm, sm', sn, sn'); atom sl' ♯ (v, u, x, y, s, k, m, n, sm, sm', sn, sn'); atom m ♯ (v, u, x, y, s, k, n, sm, sm', sn, sn'); atom n ♯ (v, u, x, y, s, k, sm, sm', sn, sn'); atom sm ♯ (v, u, x, y, s, k, sm', sn, sn'); atom sm' ♯ (v, u, x, y, s, k, sn, sn'); atom sn ♯ (v, u, x, y, s, k, sn'); atom sn' ♯ (v, u, x, y, s, k)⟧ ⟹ {HPair (Var n) (HPair (Var sn) (Var sn')) IN s, Var sl EQ Q_Disj (Var sm) (Var sn) AND Var sl' EQ Q_Disj (Var sm') (Var sn') OR Var sl EQ Q_Neg (Var sm) AND Var sl' EQ Q_Neg (Var sm') OR Var sl EQ Q_Ex (Var sm) AND Var sl' EQ Q_Ex (Var sm'), HPair (Var m) (HPair (Var sm) (Var sm')) IN s, Var n IN k, Var m IN k, x EQ Var sl, y EQ Var sl', HPair k (HPair (Var sl) (Var sl')) IN s, All2 l k (SyntaxN.Ex sl (SyntaxN.Ex sl' (HPair (Var l) (HPair (Var sl) (Var sl')) IN s AND (SubstAtomicP v u (Var sl) (Var sl') OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN Var l AND Var n IN Var l AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND (Var sl EQ Q_Disj (Var sm) (Var sn) AND Var sl' EQ Q_Disj (Var sm') (Var sn') OR Var sl EQ Q_Neg (Var sm) AND Var sl' EQ Q_Neg (Var sm') OR Var sl EQ Q_Ex (Var sm) AND Var sl' EQ Q_Ex (Var sm')))))))))))), LstSeqP s k (HPair x y)} ⊢ LstSeqP s (Var n) (HPair (Var sn) (Var sn')) AND All2 l (SUCC (Var n)) (SyntaxN.Ex sl (SyntaxN.Ex sl' (HPair (Var l) (HPair (Var sl) (Var sl')) IN s AND (SubstAtomicP v u (Var sl) (Var sl') OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN Var l AND Var n IN Var l AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND (Var sl EQ Q_Disj (Var sm) (Var sn) AND Var sl' EQ Q_Disj (Var sm') (Var sn') OR Var sl EQ Q_Neg (Var sm) AND Var sl' EQ Q_Neg (Var sm') OR Var sl EQ Q_Ex (Var sm) AND Var sl' EQ Q_Ex (Var sm'))))))))))))› 2. ‹⟦atom l ♯ (v, u, x, y, s, k, sl, sl', m, n, sm, sm', sn, sn'); atom sl ♯ (v, u, x, y, s, k, sl', m, n, sm, sm', sn, sn'); atom sl' ♯ (v, u, x, y, s, k, m, n, sm, sm', sn, sn'); atom m ♯ (v, u, x, y, s, k, n, sm, sm', sn, sn'); atom n ♯ (v, u, x, y, s, k, sm, sm', sn, sn'); atom sm ♯ (v, u, x, y, s, k, sm', sn, sn'); atom sm' ♯ (v, u, x, y, s, k, sn, sn'); atom sn ♯ (v, u, x, y, s, k, sn'); atom sn' ♯ (v, u, x, y, s, k)⟧ ⟹ {HPair (Var n) (HPair (Var sn) (Var sn')) IN s, Var sl EQ Q_Disj (Var sm) (Var sn) AND Var sl' EQ Q_Disj (Var sm') (Var sn') OR Var sl EQ Q_Neg (Var sm) AND Var sl' EQ Q_Neg (Var sm') OR Var sl EQ Q_Ex (Var sm) AND Var sl' EQ Q_Ex (Var sm'), HPair (Var m) (HPair (Var sm) (Var sm')) IN s, Var n IN k, Var m IN k, x EQ Var sl, y EQ Var sl', HPair k (HPair (Var sl) (Var sl')) IN s, All2 l k (SyntaxN.Ex sl (SyntaxN.Ex sl' (HPair (Var l) (HPair (Var sl) (Var sl')) IN s AND (SubstAtomicP v u (Var sl) (Var sl') OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN Var l AND Var n IN Var l AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND (Var sl EQ Q_Disj (Var sm) (Var sn) AND Var sl' EQ Q_Disj (Var sm') (Var sn') OR Var sl EQ Q_Neg (Var sm) AND Var sl' EQ Q_Neg (Var sm') OR Var sl EQ Q_Ex (Var sm) AND Var sl' EQ Q_Ex (Var sm')))))))))))), LstSeqP s k (HPair x y)} ⊢ x EQ Q_Disj (Var sm) (Var sn) AND y EQ Q_Disj (Var sm') (Var sn') OR x EQ Q_Neg (Var sm) AND y EQ Q_Neg (Var sm') OR x EQ Q_Ex (Var sm) AND y EQ Q_Ex (Var sm')› discuss goal 1*) apply (rule Conj_I (*‹⟦?H ⊢ ?A; ?H ⊢ ?B⟧ ⟹ ?H ⊢ ?A AND ?B›*)) (*goals: 1. ‹⟦atom (l::name) ♯ (v::tm, u::tm, x::tm, y::tm, s::tm, k::tm, sl::name, sl'::name, m::name, n::name, sm::name, sm'::name, sn::name, sn'::name); atom sl ♯ (v, u, x, y, s, k, sl', m, n, sm, sm', sn, sn'); atom sl' ♯ (v, u, x, y, s, k, m, n, sm, sm', sn, sn'); atom m ♯ (v, u, x, y, s, k, n, sm, sm', sn, sn'); atom n ♯ (v, u, x, y, s, k, sm, sm', sn, sn'); atom sm ♯ (v, u, x, y, s, k, sm', sn, sn'); atom sm' ♯ (v, u, x, y, s, k, sn, sn'); atom sn ♯ (v, u, x, y, s, k, sn'); atom sn' ♯ (v, u, x, y, s, k)⟧ ⟹ {HPair (Var n) (HPair (Var sn) (Var sn')) IN s, Var sl EQ Q_Disj (Var sm) (Var sn) AND Var sl' EQ Q_Disj (Var sm') (Var sn') OR Var sl EQ Q_Neg (Var sm) AND Var sl' EQ Q_Neg (Var sm') OR Var sl EQ Q_Ex (Var sm) AND Var sl' EQ Q_Ex (Var sm'), HPair (Var m) (HPair (Var sm) (Var sm')) IN s, Var n IN k, Var m IN k, x EQ Var sl, y EQ Var sl', HPair k (HPair (Var sl) (Var sl')) IN s, All2 l k (SyntaxN.Ex sl (SyntaxN.Ex sl' (HPair (Var l) (HPair (Var sl) (Var sl')) IN s AND (SubstAtomicP v u (Var sl) (Var sl') OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN Var l AND Var n IN Var l AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND (Var sl EQ Q_Disj (Var sm) (Var sn) AND Var sl' EQ Q_Disj (Var sm') (Var sn') OR Var sl EQ Q_Neg (Var sm) AND Var sl' EQ Q_Neg (Var sm') OR Var sl EQ Q_Ex (Var sm) AND Var sl' EQ Q_Ex (Var sm')))))))))))), LstSeqP s k (HPair x y)} ⊢ LstSeqP s (Var n) (HPair (Var sn) (Var sn'))› 2. ‹⟦atom (l::name) ♯ (v::tm, u::tm, x::tm, y::tm, s::tm, k::tm, sl::name, sl'::name, m::name, n::name, sm::name, sm'::name, sn::name, sn'::name); atom sl ♯ (v, u, x, y, s, k, sl', m, n, sm, sm', sn, sn'); atom sl' ♯ (v, u, x, y, s, k, m, n, sm, sm', sn, sn'); atom m ♯ (v, u, x, y, s, k, n, sm, sm', sn, sn'); atom n ♯ (v, u, x, y, s, k, sm, sm', sn, sn'); atom sm ♯ (v, u, x, y, s, k, sm', sn, sn'); atom sm' ♯ (v, u, x, y, s, k, sn, sn'); atom sn ♯ (v, u, x, y, s, k, sn'); atom sn' ♯ (v, u, x, y, s, k)⟧ ⟹ {HPair (Var n) (HPair (Var sn) (Var sn')) IN s, Var sl EQ Q_Disj (Var sm) (Var sn) AND Var sl' EQ Q_Disj (Var sm') (Var sn') OR Var sl EQ Q_Neg (Var sm) AND Var sl' EQ Q_Neg (Var sm') OR Var sl EQ Q_Ex (Var sm) AND Var sl' EQ Q_Ex (Var sm'), HPair (Var m) (HPair (Var sm) (Var sm')) IN s, Var n IN k, Var m IN k, x EQ Var sl, y EQ Var sl', HPair k (HPair (Var sl) (Var sl')) IN s, All2 l k (SyntaxN.Ex sl (SyntaxN.Ex sl' (HPair (Var l) (HPair (Var sl) (Var sl')) IN s AND (SubstAtomicP v u (Var sl) (Var sl') OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN Var l AND Var n IN Var l AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND (Var sl EQ Q_Disj (Var sm) (Var sn) AND Var sl' EQ Q_Disj (Var sm') (Var sn') OR Var sl EQ Q_Neg (Var sm) AND Var sl' EQ Q_Neg (Var sm') OR Var sl EQ Q_Ex (Var sm) AND Var sl' EQ Q_Ex (Var sm')))))))))))), LstSeqP s k (HPair x y)} ⊢ All2 l (SUCC (Var n)) (SyntaxN.Ex sl (SyntaxN.Ex sl' (HPair (Var l) (HPair (Var sl) (Var sl')) IN s AND (SubstAtomicP v u (Var sl) (Var sl') OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN Var l AND Var n IN Var l AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND (Var sl EQ Q_Disj (Var sm) (Var sn) AND Var sl' EQ Q_Disj (Var sm') (Var sn') OR Var sl EQ Q_Neg (Var sm) AND Var sl' EQ Q_Neg (Var sm') OR Var sl EQ Q_Ex (Var sm) AND Var sl' EQ Q_Ex (Var sm'))))))))))))› discuss goal 1*) apply (blast intro: LstSeqP_Mem (*‹⟦?H ⊢ LstSeqP ?r ?k ?y; ?H ⊢ HPair ?k' ?z IN ?r; ?H ⊢ ?k' IN ?k⟧ ⟹ ?H ⊢ LstSeqP ?r ?k' ?z›*)) (*discuss goal 2*) apply (rule All2_Subset [OF Hyp] (*‹⟦All2 ?l ?k ?P ∈ ?H; ?H ⊢ ?k' SUBS ?k; {?P} ⊢ ?P'; atom ?l ♯ (?k', ?k)⟧ ⟹ ?H ⊢ All2 ?l ?k' ?P'›*)) (*goals: 1. ‹⟦atom l ♯ (v, u, x, y, s, k, sl, sl', m, n, sm, sm', sn, sn'); atom sl ♯ (v, u, x, y, s, k, sl', m, n, sm, sm', sn, sn'); atom sl' ♯ (v, u, x, y, s, k, m, n, sm, sm', sn, sn'); atom m ♯ (v, u, x, y, s, k, n, sm, sm', sn, sn'); atom n ♯ (v, u, x, y, s, k, sm, sm', sn, sn'); atom sm ♯ (v, u, x, y, s, k, sm', sn, sn'); atom sm' ♯ (v, u, x, y, s, k, sn, sn'); atom sn ♯ (v, u, x, y, s, k, sn'); atom sn' ♯ (v, u, x, y, s, k)⟧ ⟹ All2 l ?k227 ?P227 ∈ {HPair (Var n) (HPair (Var sn) (Var sn')) IN s, Var sl EQ Q_Disj (Var sm) (Var sn) AND Var sl' EQ Q_Disj (Var sm') (Var sn') OR Var sl EQ Q_Neg (Var sm) AND Var sl' EQ Q_Neg (Var sm') OR Var sl EQ Q_Ex (Var sm) AND Var sl' EQ Q_Ex (Var sm'), HPair (Var m) (HPair (Var sm) (Var sm')) IN s, Var n IN k, Var m IN k, x EQ Var sl, y EQ Var sl', HPair k (HPair (Var sl) (Var sl')) IN s, All2 l k (SyntaxN.Ex sl (SyntaxN.Ex sl' (HPair (Var l) (HPair (Var sl) (Var sl')) IN s AND (SubstAtomicP v u (Var sl) (Var sl') OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN Var l AND Var n IN Var l AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND (Var sl EQ Q_Disj (Var sm) (Var sn) AND Var sl' EQ Q_Disj (Var sm') (Var sn') OR Var sl EQ Q_Neg (Var sm) AND Var sl' EQ Q_Neg (Var sm') OR Var sl EQ Q_Ex (Var sm) AND Var sl' EQ Q_Ex (Var sm')))))))))))), LstSeqP s k (HPair x y)}› 2. ‹⟦atom l ♯ (v, u, x, y, s, k, sl, sl', m, n, sm, sm', sn, sn'); atom sl ♯ (v, u, x, y, s, k, sl', m, n, sm, sm', sn, sn'); atom sl' ♯ (v, u, x, y, s, k, m, n, sm, sm', sn, sn'); atom m ♯ (v, u, x, y, s, k, n, sm, sm', sn, sn'); atom n ♯ (v, u, x, y, s, k, sm, sm', sn, sn'); atom sm ♯ (v, u, x, y, s, k, sm', sn, sn'); atom sm' ♯ (v, u, x, y, s, k, sn, sn'); atom sn ♯ (v, u, x, y, s, k, sn'); atom sn' ♯ (v, u, x, y, s, k)⟧ ⟹ {HPair (Var n) (HPair (Var sn) (Var sn')) IN s, Var sl EQ Q_Disj (Var sm) (Var sn) AND Var sl' EQ Q_Disj (Var sm') (Var sn') OR Var sl EQ Q_Neg (Var sm) AND Var sl' EQ Q_Neg (Var sm') OR Var sl EQ Q_Ex (Var sm) AND Var sl' EQ Q_Ex (Var sm'), HPair (Var m) (HPair (Var sm) (Var sm')) IN s, Var n IN k, Var m IN k, x EQ Var sl, y EQ Var sl', HPair k (HPair (Var sl) (Var sl')) IN s, All2 l k (SyntaxN.Ex sl (SyntaxN.Ex sl' (HPair (Var l) (HPair (Var sl) (Var sl')) IN s AND (SubstAtomicP v u (Var sl) (Var sl') OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN Var l AND Var n IN Var l AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND (Var sl EQ Q_Disj (Var sm) (Var sn) AND Var sl' EQ Q_Disj (Var sm') (Var sn') OR Var sl EQ Q_Neg (Var sm) AND Var sl' EQ Q_Neg (Var sm') OR Var sl EQ Q_Ex (Var sm) AND Var sl' EQ Q_Ex (Var sm')))))))))))), LstSeqP s k (HPair x y)} ⊢ SUCC (Var n) SUBS ?k227› 3. ‹⟦atom l ♯ (v, u, x, y, s, k, sl, sl', m, n, sm, sm', sn, sn'); atom sl ♯ (v, u, x, y, s, k, sl', m, n, sm, sm', sn, sn'); atom sl' ♯ (v, u, x, y, s, k, m, n, sm, sm', sn, sn'); atom m ♯ (v, u, x, y, s, k, n, sm, sm', sn, sn'); atom n ♯ (v, u, x, y, s, k, sm, sm', sn, sn'); atom sm ♯ (v, u, x, y, s, k, sm', sn, sn'); atom sm' ♯ (v, u, x, y, s, k, sn, sn'); atom sn ♯ (v, u, x, y, s, k, sn'); atom sn' ♯ (v, u, x, y, s, k)⟧ ⟹ {?P227} ⊢ SyntaxN.Ex sl (SyntaxN.Ex sl' (HPair (Var l) (HPair (Var sl) (Var sl')) IN s AND (SubstAtomicP v u (Var sl) (Var sl') OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN Var l AND Var n IN Var l AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND (Var sl EQ Q_Disj (Var sm) (Var sn) AND Var sl' EQ Q_Disj (Var sm') (Var sn') OR Var sl EQ Q_Neg (Var sm) AND Var sl' EQ Q_Neg (Var sm') OR Var sl EQ Q_Ex (Var sm) AND Var sl' EQ Q_Ex (Var sm')))))))))))› 4. ‹⟦atom l ♯ (v, u, x, y, s, k, sl, sl', m, n, sm, sm', sn, sn'); atom sl ♯ (v, u, x, y, s, k, sl', m, n, sm, sm', sn, sn'); atom sl' ♯ (v, u, x, y, s, k, m, n, sm, sm', sn, sn'); atom m ♯ (v, u, x, y, s, k, n, sm, sm', sn, sn'); atom n ♯ (v, u, x, y, s, k, sm, sm', sn, sn'); atom sm ♯ (v, u, x, y, s, k, sm', sn, sn'); atom sm' ♯ (v, u, x, y, s, k, sn, sn'); atom sn ♯ (v, u, x, y, s, k, sn'); atom sn' ♯ (v, u, x, y, s, k)⟧ ⟹ atom l ♯ (SUCC (Var n), ?k227)› discuss goal 1*) apply blast (*discuss goal 2*) apply (blast intro!: SUCC_Subset_Ord (*‹⟦?H ⊢ ?k' IN ?k; ?H ⊢ OrdP ?k⟧ ⟹ ?H ⊢ SUCC ?k' SUBS ?k›*) LstSeqP_OrdP (*‹?H ⊢ LstSeqP ?r ?k ?y ⟹ ?H ⊢ OrdP ?k›*)) (*discuss goal 3*) apply blast (*discuss goal 4*) apply simp (*proven 4 subgoals*) (*proven 2 subgoals*) (*discuss goal 2*) apply (rule anti_deduction [THEN thin1] (*‹(?H1::fm set) ⊢ (?A1::fm) IMP (?B::fm) ⟹ insert (?A::fm) (insert ?A1 ?H1) ⊢ ?B›*)) (*top goal: ‹⟦atom l ♯ (v, u, x, y, s, k, sl, sl', m, n, sm, sm', sn, sn'); atom sl ♯ (v, u, x, y, s, k, sl', m, n, sm, sm', sn, sn'); atom sl' ♯ (v, u, x, y, s, k, m, n, sm, sm', sn, sn'); atom m ♯ (v, u, x, y, s, k, n, sm, sm', sn, sn'); atom n ♯ (v, u, x, y, s, k, sm, sm', sn, sn'); atom sm ♯ (v, u, x, y, s, k, sm', sn, sn'); atom sm' ♯ (v, u, x, y, s, k, sn, sn'); atom sn ♯ (v, u, x, y, s, k, sn'); atom sn' ♯ (v, u, x, y, s, k)⟧ ⟹ {HPair (Var n) (HPair (Var sn) (Var sn')) IN s, Var sl EQ Q_Disj (Var sm) (Var sn) AND Var sl' EQ Q_Disj (Var sm') (Var sn') OR Var sl EQ Q_Neg (Var sm) AND Var sl' EQ Q_Neg (Var sm') OR Var sl EQ Q_Ex (Var sm) AND Var sl' EQ Q_Ex (Var sm'), HPair (Var m) (HPair (Var sm) (Var sm')) IN s, Var n IN k, Var m IN k, x EQ Var sl, y EQ Var sl', HPair k (HPair (Var sl) (Var sl')) IN s, All2 l k (SyntaxN.Ex sl (SyntaxN.Ex sl' (HPair (Var l) (HPair (Var sl) (Var sl')) IN s AND (SubstAtomicP v u (Var sl) (Var sl') OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN Var l AND Var n IN Var l AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND (Var sl EQ Q_Disj (Var sm) (Var sn) AND Var sl' EQ Q_Disj (Var sm') (Var sn') OR Var sl EQ Q_Neg (Var sm) AND Var sl' EQ Q_Neg (Var sm') OR Var sl EQ Q_Ex (Var sm) AND Var sl' EQ Q_Ex (Var sm')))))))))))), LstSeqP s k (HPair x y)} ⊢ x EQ Q_Disj (Var sm) (Var sn) AND y EQ Q_Disj (Var sm') (Var sn') OR x EQ Q_Neg (Var sm) AND y EQ Q_Neg (Var sm') OR x EQ Q_Ex (Var sm) AND y EQ Q_Ex (Var sm')› and 16 goals remain*) apply (rule Sym_L [THEN rotate4] (*‹insert (?t1 EQ ?u1) (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 ?H))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert (?u1 EQ ?t1) ?H))) ⊢ ?B›*)) (*top goal: ‹⟦atom l ♯ (v, u, x, y, s, k, sl, sl', m, n, sm, sm', sn, sn'); atom sl ♯ (v, u, x, y, s, k, sl', m, n, sm, sm', sn, sn'); atom sl' ♯ (v, u, x, y, s, k, m, n, sm, sm', sn, sn'); atom m ♯ (v, u, x, y, s, k, n, sm, sm', sn, sn'); atom n ♯ (v, u, x, y, s, k, sm, sm', sn, sn'); atom sm ♯ (v, u, x, y, s, k, sm', sn, sn'); atom sm' ♯ (v, u, x, y, s, k, sn, sn'); atom sn ♯ (v, u, x, y, s, k, sn'); atom sn' ♯ (v, u, x, y, s, k)⟧ ⟹ {HPair (Var m) (HPair (Var sm) (Var sm')) IN s, Var n IN k, Var m IN k, x EQ Var sl, y EQ Var sl', HPair k (HPair (Var sl) (Var sl')) IN s, All2 l k (SyntaxN.Ex sl (SyntaxN.Ex sl' (HPair (Var l) (HPair (Var sl) (Var sl')) IN s AND (SubstAtomicP v u (Var sl) (Var sl') OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN Var l AND Var n IN Var l AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND (Var sl EQ Q_Disj (Var sm) (Var sn) AND Var sl' EQ Q_Disj (Var sm') (Var sn') OR Var sl EQ Q_Neg (Var sm) AND Var sl' EQ Q_Neg (Var sm') OR Var sl EQ Q_Ex (Var sm) AND Var sl' EQ Q_Ex (Var sm')))))))))))), LstSeqP s k (HPair x y)} ⊢ Var sl EQ Q_Disj (Var sm) (Var sn) AND Var sl' EQ Q_Disj (Var sm') (Var sn') OR Var sl EQ Q_Neg (Var sm) AND Var sl' EQ Q_Neg (Var sm') OR Var sl EQ Q_Ex (Var sm) AND Var sl' EQ Q_Ex (Var sm') IMP x EQ Q_Disj (Var sm) (Var sn) AND y EQ Q_Disj (Var sm') (Var sn') OR x EQ Q_Neg (Var sm) AND y EQ Q_Neg (Var sm') OR x EQ Q_Ex (Var sm) AND y EQ Q_Ex (Var sm')› and 16 goals remain*) apply (rule Var_Eq_subst_Iff [THEN Iff_MP_same] (*‹insert (Var ?i1 EQ ?t1) ?H1 ⊢ ?B(?i1::=?t1) ⟹ insert (Var ?i1 EQ ?t1) ?H1 ⊢ ?B›*)) (*top goal: ‹⟦atom l ♯ (v, u, x, y, s, k, sl, sl', m, n, sm, sm', sn, sn'); atom sl ♯ (v, u, x, y, s, k, sl', m, n, sm, sm', sn, sn'); atom sl' ♯ (v, u, x, y, s, k, m, n, sm, sm', sn, sn'); atom m ♯ (v, u, x, y, s, k, n, sm, sm', sn, sn'); atom n ♯ (v, u, x, y, s, k, sm, sm', sn, sn'); atom sm ♯ (v, u, x, y, s, k, sm', sn, sn'); atom sm' ♯ (v, u, x, y, s, k, sn, sn'); atom sn ♯ (v, u, x, y, s, k, sn'); atom sn' ♯ (v, u, x, y, s, k)⟧ ⟹ {Var sl EQ x, HPair (Var m) (HPair (Var sm) (Var sm')) IN s, Var n IN k, Var m IN k, y EQ Var sl', HPair k (HPair (Var sl) (Var sl')) IN s, All2 l k (SyntaxN.Ex sl (SyntaxN.Ex sl' (HPair (Var l) (HPair (Var sl) (Var sl')) IN s AND (SubstAtomicP v u (Var sl) (Var sl') OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN Var l AND Var n IN Var l AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND (Var sl EQ Q_Disj (Var sm) (Var sn) AND Var sl' EQ Q_Disj (Var sm') (Var sn') OR Var sl EQ Q_Neg (Var sm) AND Var sl' EQ Q_Neg (Var sm') OR Var sl EQ Q_Ex (Var sm) AND Var sl' EQ Q_Ex (Var sm')))))))))))), LstSeqP s k (HPair x y)} ⊢ Var sl EQ Q_Disj (Var sm) (Var sn) AND Var sl' EQ Q_Disj (Var sm') (Var sn') OR Var sl EQ Q_Neg (Var sm) AND Var sl' EQ Q_Neg (Var sm') OR Var sl EQ Q_Ex (Var sm) AND Var sl' EQ Q_Ex (Var sm') IMP x EQ Q_Disj (Var sm) (Var sn) AND y EQ Q_Disj (Var sm') (Var sn') OR x EQ Q_Neg (Var sm) AND y EQ Q_Neg (Var sm') OR x EQ Q_Ex (Var sm) AND y EQ Q_Ex (Var sm')› and 16 goals remain*) apply (rule Sym_L [THEN rotate5] (*‹insert (?t1 EQ ?u1) (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 ?H)))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert (?u1 EQ ?t1) ?H)))) ⊢ ?B›*)) (*top goal: ‹⟦atom l ♯ (v, u, x, y, s, k, sl, sl', m, n, sm, sm', sn, sn'); atom sl ♯ (v, u, x, y, s, k, sl', m, n, sm, sm', sn, sn'); atom sl' ♯ (v, u, x, y, s, k, m, n, sm, sm', sn, sn'); atom m ♯ (v, u, x, y, s, k, n, sm, sm', sn, sn'); atom n ♯ (v, u, x, y, s, k, sm, sm', sn, sn'); atom sm ♯ (v, u, x, y, s, k, sm', sn, sn'); atom sm' ♯ (v, u, x, y, s, k, sn, sn'); atom sn ♯ (v, u, x, y, s, k, sn'); atom sn' ♯ (v, u, x, y, s, k)⟧ ⟹ {Var sl EQ x, HPair (Var m) (HPair (Var sm) (Var sm')) IN s, Var n IN k, Var m IN k, y EQ Var sl', HPair k (HPair (Var sl) (Var sl')) IN s, All2 l k (SyntaxN.Ex sl (SyntaxN.Ex sl' (HPair (Var l) (HPair (Var sl) (Var sl')) IN s AND (SubstAtomicP v u (Var sl) (Var sl') OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN Var l AND Var n IN Var l AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND (Var sl EQ Q_Disj (Var sm) (Var sn) AND Var sl' EQ Q_Disj (Var sm') (Var sn') OR Var sl EQ Q_Neg (Var sm) AND Var sl' EQ Q_Neg (Var sm') OR Var sl EQ Q_Ex (Var sm) AND Var sl' EQ Q_Ex (Var sm')))))))))))), LstSeqP s k (HPair x y)} ⊢ (Var sl EQ Q_Disj (Var sm) (Var sn) AND Var sl' EQ Q_Disj (Var sm') (Var sn') OR Var sl EQ Q_Neg (Var sm) AND Var sl' EQ Q_Neg (Var sm') OR Var sl EQ Q_Ex (Var sm) AND Var sl' EQ Q_Ex (Var sm') IMP x EQ Q_Disj (Var sm) (Var sn) AND y EQ Q_Disj (Var sm') (Var sn') OR x EQ Q_Neg (Var sm) AND y EQ Q_Neg (Var sm') OR x EQ Q_Ex (Var sm) AND y EQ Q_Ex (Var sm'))(sl::=x)› and 16 goals remain*) apply (rule Var_Eq_subst_Iff [THEN Iff_MP_same] (*‹insert (Var (?i1::name) EQ (?t1::tm)) (?H1::fm set) ⊢ (?B::fm)(?i1::=?t1) ⟹ insert (Var ?i1 EQ ?t1) ?H1 ⊢ ?B›*)) (*top goal: ‹⟦atom l ♯ (v, u, x, y, s, k, sl, sl', m, n, sm, sm', sn, sn'); atom sl ♯ (v, u, x, y, s, k, sl', m, n, sm, sm', sn, sn'); atom sl' ♯ (v, u, x, y, s, k, m, n, sm, sm', sn, sn'); atom m ♯ (v, u, x, y, s, k, n, sm, sm', sn, sn'); atom n ♯ (v, u, x, y, s, k, sm, sm', sn, sn'); atom sm ♯ (v, u, x, y, s, k, sm', sn, sn'); atom sm' ♯ (v, u, x, y, s, k, sn, sn'); atom sn ♯ (v, u, x, y, s, k, sn'); atom sn' ♯ (v, u, x, y, s, k)⟧ ⟹ {Var sl' EQ y, Var sl EQ x, HPair (Var m) (HPair (Var sm) (Var sm')) IN s, Var n IN k, Var m IN k, HPair k (HPair (Var sl) (Var sl')) IN s, All2 l k (SyntaxN.Ex sl (SyntaxN.Ex sl' (HPair (Var l) (HPair (Var sl) (Var sl')) IN s AND (SubstAtomicP v u (Var sl) (Var sl') OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN Var l AND Var n IN Var l AND HPair (Var m) (HPair (Var sm) (Var sm')) IN s AND HPair (Var n) (HPair (Var sn) (Var sn')) IN s AND (Var sl EQ Q_Disj (Var sm) (Var sn) AND Var sl' EQ Q_Disj (Var sm') (Var sn') OR Var sl EQ Q_Neg (Var sm) AND Var sl' EQ Q_Neg (Var sm') OR Var sl EQ Q_Ex (Var sm) AND Var sl' EQ Q_Ex (Var sm')))))))))))), LstSeqP s k (HPair x y)} ⊢ (Var sl EQ Q_Disj (Var sm) (Var sn) AND Var sl' EQ Q_Disj (Var sm') (Var sn') OR Var sl EQ Q_Neg (Var sm) AND Var sl' EQ Q_Neg (Var sm') OR Var sl EQ Q_Ex (Var sm) AND Var sl' EQ Q_Ex (Var sm') IMP x EQ Q_Disj (Var sm) (Var sn) AND y EQ Q_Disj (Var sm') (Var sn') OR x EQ Q_Neg (Var sm) AND y EQ Q_Neg (Var sm') OR x EQ Q_Ex (Var sm) AND y EQ Q_Ex (Var sm'))(sl::=x)› and 16 goals remain*) apply force (*proven 2 subgoals*) (*proven 2 subgoals*) (*proven 2 subgoals*) (*proven 2 subgoals*) (*discuss goal 2*) apply simp (*discuss goal 3*) apply simp (*proven 3 subgoals*) (*discuss goal 2*) apply simp (*discuss goal 3*) apply simp (*proven 3 subgoals*) (*discuss goal 2*) apply simp (*discuss goal 3*) apply simp (*proven 3 subgoals*) (*discuss goal 2*) apply simp (*discuss goal 3*) apply simp (*proven 3 subgoals*) (*discuss goal 2*) apply simp (*discuss goal 3*) apply simp (*proven 3 subgoals*) (*discuss goal 2*) apply simp (*discuss goal 3*) apply simp (*proven 3 subgoals*) (*proven 2 subgoals*) (*proven 2 subgoals*) (*discuss goal 2*) apply simp (*discuss goal 3*) apply simp (*proven 3 subgoals*) (*discuss goal 2*) apply simp (*discuss goal 3*) apply simp (*proven 3 subgoals*) (*proven 2 subgoals*) . qed lemma shows Neg_SubstAtomicP_Fls: "{y EQ Q_Neg z, SubstAtomicP v tm y y'} ⊢ Fls" (is ?thesis1) and Disj_SubstAtomicP_Fls: "{y EQ Q_Disj z w, SubstAtomicP v tm y y'} ⊢ Fls" (is ?thesis2) and Ex_SubstAtomicP_Fls: "{y EQ Q_Ex z, SubstAtomicP v tm y y'} ⊢ Fls" (is ?thesis3) proof (-) (*goals: 1. ‹{y EQ Q_Neg z, SubstAtomicP v tm y y'} ⊢ Fls› 2. ‹{y EQ Q_Disj z w, SubstAtomicP v tm y y'} ⊢ Fls› 3. ‹{y EQ Q_Ex z, SubstAtomicP v tm y y'} ⊢ Fls›*) obtain t :: name and u :: name and t' :: name and u' :: name where "atom t ♯ (z,w,v,tm,y,y',t',u,u')" "atom t' ♯ (z,w,v,tm,y,y',u,u')" "atom u ♯ (z,w,v,tm,y,y',u')" "atom u' ♯ (z,w,v,tm,y,y')" (*goal: ‹(⋀t t' u u'. ⟦atom t ♯ (z, w, v, tm, y, y', t', u, u'); atom t' ♯ (z, w, v, tm, y, y', u, u'); atom u ♯ (z, w, v, tm, y, y', u'); atom u' ♯ (z, w, v, tm, y, y')⟧ ⟹ thesis) ⟹ thesis›*) by (metis obtain_fresh (*‹(⋀a. atom a ♯ ?x ⟹ ?thesis) ⟹ ?thesis›*)) thus "?thesis1" "?thesis2" "?thesis3" (*goals: 1. ‹{y EQ Q_Neg z, SubstAtomicP v tm y y'} ⊢ Fls› 2. ‹{y EQ Q_Disj z w, SubstAtomicP v tm y y'} ⊢ Fls› 3. ‹{y EQ Q_Ex z, SubstAtomicP v tm y y'} ⊢ Fls›*) apply - (*goals: 1. ‹⟦atom t ♯ (z, w, v, tm, y, y', t', u, u'); atom t' ♯ (z, w, v, tm, y, y', u, u'); atom u ♯ (z, w, v, tm, y, y', u'); atom u' ♯ (z, w, v, tm, y, y')⟧ ⟹ {y EQ Q_Neg z, SubstAtomicP v tm y y'} ⊢ Fls› 2. ‹⟦atom t ♯ (z, w, v, tm, y, y', t', u, u'); atom t' ♯ (z, w, v, tm, y, y', u, u'); atom u ♯ (z, w, v, tm, y, y', u'); atom u' ♯ (z, w, v, tm, y, y')⟧ ⟹ {y EQ Q_Disj z w, SubstAtomicP v tm y y'} ⊢ Fls› 3. ‹⟦atom t ♯ (z, w, v, tm, y, y', t', u, u'); atom t' ♯ (z, w, v, tm, y, y', u, u'); atom u ♯ (z, w, v, tm, y, y', u'); atom u' ♯ (z, w, v, tm, y, y')⟧ ⟹ {y EQ Q_Ex z, SubstAtomicP v tm y y'} ⊢ Fls› discuss goal 1*) apply ((auto simp: SubstAtomicP.simps [of t v tm y y' t' u u'] (*‹⟦atom t ♯ (v, tm, y, y', t', u, u'); atom t' ♯ (v, tm, y, y', u, u'); atom u ♯ (v, tm, y, y', u'); atom u' ♯ (v, tm, y, y')⟧ ⟹ SubstAtomicP v tm y y' = SyntaxN.Ex t (SyntaxN.Ex u (SyntaxN.Ex t' (SyntaxN.Ex u' (SubstTermP v tm (Var t) (Var t') AND SubstTermP v tm (Var u) (Var u') AND (y EQ Q_Eq (Var t) (Var u) AND y' EQ Q_Eq (Var t') (Var u') OR y EQ Q_Mem (Var t) (Var u) AND y' EQ Q_Mem (Var t') (Var u'))))))›*) HTS (*‹0 < ?n ⟹ HTuple ?n = HPair Zero (HTuple (?n - 1))› ‹HTuple 0 = HPair Zero Zero› ‹HTuple (Suc ?k) = HPair Zero (HTuple ?k)›*) intro: Eq_Trans_E [OF Hyp] (*‹⟦?x EQ ?u ∈ ?H; insert (?t EQ ?u) ?H ⊢ ?A⟧ ⟹ insert (?x EQ ?t) ?H ⊢ ?A›*))[1]) (*discuss goal 2*) apply ((auto simp: SubstAtomicP.simps [of t v tm y y' t' u u'] (*‹⟦atom t ♯ (v, tm, y, y', t', u, u'); atom t' ♯ (v, tm, y, y', u, u'); atom u ♯ (v, tm, y, y', u'); atom u' ♯ (v, tm, y, y')⟧ ⟹ SubstAtomicP v tm y y' = SyntaxN.Ex t (SyntaxN.Ex u (SyntaxN.Ex t' (SyntaxN.Ex u' (SubstTermP v tm (Var t) (Var t') AND SubstTermP v tm (Var u) (Var u') AND (y EQ Q_Eq (Var t) (Var u) AND y' EQ Q_Eq (Var t') (Var u') OR y EQ Q_Mem (Var t) (Var u) AND y' EQ Q_Mem (Var t') (Var u'))))))›*) HTS (*‹0 < ?n ⟹ HTuple ?n = HPair Zero (HTuple (?n - 1))› ‹HTuple 0 = HPair Zero Zero› ‹HTuple (Suc ?k) = HPair Zero (HTuple ?k)›*) intro: Eq_Trans_E [OF Hyp] (*‹⟦?x EQ ?u ∈ ?H; insert (?t EQ ?u) ?H ⊢ ?A⟧ ⟹ insert (?x EQ ?t) ?H ⊢ ?A›*))[1]) (*discuss goal 3*) apply ((auto simp: SubstAtomicP.simps [of t v tm y y' t' u u'] (*‹⟦atom t ♯ (v, tm, y, y', t', u, u'); atom t' ♯ (v, tm, y, y', u, u'); atom u ♯ (v, tm, y, y', u'); atom u' ♯ (v, tm, y, y')⟧ ⟹ SubstAtomicP v tm y y' = SyntaxN.Ex t (SyntaxN.Ex u (SyntaxN.Ex t' (SyntaxN.Ex u' (SubstTermP v tm (Var t) (Var t') AND SubstTermP v tm (Var u) (Var u') AND (y EQ Q_Eq (Var t) (Var u) AND y' EQ Q_Eq (Var t') (Var u') OR y EQ Q_Mem (Var t) (Var u) AND y' EQ Q_Mem (Var t') (Var u'))))))›*) HTS (*‹0 < ?n ⟹ HTuple ?n = HPair Zero (HTuple (?n - 1))› ‹HTuple 0 = HPair Zero Zero› ‹HTuple (Suc ?k) = HPair Zero (HTuple ?k)›*) intro: Eq_Trans_E [OF Hyp] (*‹⟦?x EQ ?u ∈ ?H; insert (?t EQ ?u) ?H ⊢ ?A⟧ ⟹ insert (?x EQ ?t) ?H ⊢ ?A›*))[1]) (*proven 3 subgoals*) . qed lemma SeqSubstFormP_eq: "⟦H ⊢ SeqSubstFormP v tm x z s k; insert (SeqSubstFormP v tm y z s k) H ⊢ A⟧ ⟹ insert (x EQ y) H ⊢ A" apply (rule cut_same [OF SeqSubstFormP_cong [OF Assume Refl Refl Refl, THEN Iff_MP_same]] (*‹⟦insert (?t2 EQ ?t'2) ?H6 ⊢ SeqSubstFormP ?v2 ?i2 ?t2 ?u2 ?s2 ?k2; insert (SeqSubstFormP ?v2 ?i2 ?t'2 ?u2 ?s2 ?k2) (insert (?t2 EQ ?t'2) ?H6) ⊢ ?B⟧ ⟹ insert (?t2 EQ ?t'2) ?H6 ⊢ ?B›*)) (*goals: 1. ‹⟦H ⊢ SeqSubstFormP v tm x z s k; insert (SeqSubstFormP v tm y z s k) H ⊢ A⟧ ⟹ insert (x EQ y) H ⊢ SeqSubstFormP ?v2 ?i2 x ?u2 ?s2 ?k2› 2. ‹⟦H ⊢ SeqSubstFormP v tm x z s k; insert (SeqSubstFormP v tm y z s k) H ⊢ A⟧ ⟹ insert (SeqSubstFormP ?v2 ?i2 y ?u2 ?s2 ?k2) (insert (x EQ y) H) ⊢ A› discuss goal 1*) apply ((auto simp: insert_commute (*‹insert ?x (insert ?y ?A) = insert ?y (insert ?x ?A)›*) intro: thin1 (*‹?H ⊢ ?B ⟹ insert ?A ?H ⊢ ?B›*))[1]) (*discuss goal 2*) apply ((auto simp: insert_commute (*‹insert ?x (insert ?y ?A) = insert ?y (insert ?x ?A)›*) intro: thin1 (*‹?H ⊢ ?B ⟹ insert ?A ?H ⊢ ?B›*))[1]) (*proven 2 subgoals*) . lemma SeqSubstFormP_unique: "{SeqSubstFormP v a x y s kk, SeqSubstFormP v a x y' s' kk'} ⊢ y' EQ y" proof (-) (*goal: ‹{SeqSubstFormP v a x y s kk, SeqSubstFormP v a x y' s' kk'} ⊢ y' EQ y›*) obtain i :: name and j :: name and j' :: name and k :: name and k' :: name and l :: name and m :: name and n :: name and sm :: name and sn :: name and sm' :: name and sn' :: name and m2 :: name and n2 :: name and sm2 :: name and sn2 :: name and sm2' :: name and sn2' :: name where atoms: "atom i ♯ (s,s',v,a,x,y,y')" "atom j ♯ (s,s',v,a,x,i,x,y,y')" "atom j' ♯ (s,s',v,a,x,i,j,x,y,y')" "atom k ♯ (s,s',v,a,x,y,y',kk',i,j,j')" "atom k' ♯ (s,s',v,a,x,y,y',k,i,j,j')" "atom l ♯ (s,s',v,a,x,i,j,j',k,k')" "atom m ♯ (s,s',v,a,i,j,j',k,k',l)" "atom n ♯ (s,s',v,a,i,j,j',k,k',l,m)" "atom sm ♯ (s,s',v,a,i,j,j',k,k',l,m,n)" "atom sn ♯ (s,s',v,a,i,j,j',k,k',l,m,n,sm)" "atom sm' ♯ (s,s',v,a,i,j,j',k,k',l,m,n,sm,sn)" "atom sn' ♯ (s,s',v,a,i,j,j',k,k',l,m,n,sm,sn,sm')" "atom m2 ♯ (s,s',v,a,i,j,j',k,k',l,m,n,sm,sn,sm',sn')" "atom n2 ♯ (s,s',v,a,i,j,j',k,k',l,m,n,sm,sn,sm',sn',m2)" "atom sm2 ♯ (s,s',v,a,i,j,j',k,k',l,m,n,sm,sn,sm',sn',m2,n2)" "atom sn2 ♯ (s,s',v,a,i,j,j',k,k',l,m,n,sm,sn,sm',sn',m2,n2,sm2)" "atom sm2' ♯ (s,s',v,a,i,j,j',k,k',l,m,n,sm,sn,sm',sn',m2,n2,sm2,sn2)" "atom sn2' ♯ (s,s',v,a,i,j,j',k,k',l,m,n,sm,sn,sm',sn',m2,n2,sm2,sn2,sm2')" (*goal: ‹(⋀(i::name) (j::name) (j'::name) (k::name) (k'::name) (l::name) (m::name) (n::name) (sm::name) (sn::name) (sm'::name) (sn'::name) (m2::name) (n2::name) (sm2::name) (sn2::name) (sm2'::name) sn2'::name. ⟦atom i ♯ (s::tm, s'::tm, v::tm, a::tm, x::tm, y::tm, y'::tm); atom j ♯ (s, s', v, a, x, i, x, y, y'); atom j' ♯ (s, s', v, a, x, i, j, x, y, y'); atom k ♯ (s, s', v, a, x, y, y', kk'::tm, i, j, j'); atom k' ♯ (s, s', v, a, x, y, y', k, i, j, j'); atom l ♯ (s, s', v, a, x, i, j, j', k, k'); atom m ♯ (s, s', v, a, i, j, j', k, k', l); atom n ♯ (s, s', v, a, i, j, j', k, k', l, m); atom sm ♯ (s, s', v, a, i, j, j', k, k', l, m, n); atom sn ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm); atom sm' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn); atom sn' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm'); atom m2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn'); atom n2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2); atom sm2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2); atom sn2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2); atom sm2' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2, sn2); atom sn2' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2, sn2, sm2')⟧ ⟹ thesis::bool) ⟹ thesis›*) by (metis obtain_fresh (*‹(⋀a. atom a ♯ ?x ⟹ ?thesis) ⟹ ?thesis›*)) have "{ OrdP (Var k) } ⊢ All i (All j (All j' (All k' (SeqSubstFormP v a (Var i) (Var j) s (Var k) IMP (SeqSubstFormP v a (Var i) (Var j') s' (Var k') IMP Var j' EQ Var j)))))" apply (rule OrdIndH [where j=l] (*‹⟦atom l ♯ (?i, ?A); ?H ⊢ SyntaxN.All ?i (OrdP (Var ?i) IMP All2 l (Var ?i) (?A(?i::=Var l)) IMP ?A)⟧ ⟹ insert (OrdP (Var ?i)) ?H ⊢ ?A›*)) (*goal: ‹{OrdP (Var k)} ⊢ SyntaxN.All i (SyntaxN.All j (SyntaxN.All j' (SyntaxN.All k' (SeqSubstFormP v a (Var i) (Var j) s (Var k) IMP SeqSubstFormP v a (Var i) (Var j') s' (Var k') IMP Var j' EQ Var j))))›*) using atoms (*‹atom i ♯ (s, s', v, a, x, y, y')› ‹atom j ♯ (s, s', v, a, x, i, x, y, y')› ‹atom (j'::name) ♯ (s::tm, s'::tm, v::tm, a::tm, x::tm, i::name, j::name, x, y::tm, y'::tm)› ‹atom k ♯ (s, s', v, a, x, y, y', kk', i, j, j')› ‹atom k' ♯ (s, s', v, a, x, y, y', k, i, j, j')› ‹atom (l::name) ♯ (s::tm, s'::tm, v::tm, a::tm, x::tm, i::name, j::name, j'::name, k::name, k'::name)› ‹atom m ♯ (s, s', v, a, i, j, j', k, k', l)› ‹atom (n::name) ♯ (s::tm, s'::tm, v::tm, a::tm, i::name, j::name, j'::name, k::name, k'::name, l::name, m::name)› ‹atom sm ♯ (s, s', v, a, i, j, j', k, k', l, m, n)› ‹atom sn ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm)› ‹atom sm' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn)› ‹atom sn' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm')› and more 6 facts*) apply auto (*top goal: ‹atom l ♯ (k, SyntaxN.All i (SyntaxN.All j (SyntaxN.All j' (SyntaxN.All k' (SeqSubstFormP v a (Var i) (Var j) s (Var k) IMP SeqSubstFormP v a (Var i) (Var j') s' (Var k') IMP Var j' EQ Var j)))))› and 1 goal remains*) apply (rule Swap (*‹insert (Neg ?B) ?H ⊢ ?A ⟹ insert (Neg ?A) ?H ⊢ ?B›*)) (*goal: ‹⟦atom i ♯ (s, s', v, a, x, y, y'); atom j ♯ (s, s', v, a, x, i, x, y, y'); atom j' ♯ (s, s', v, a, x, i, j, x, y, y'); atom k ♯ (s, s', v, a, x, y, y', kk', i, j, j'); atom k' ♯ (s, s', v, a, x, y, y', k, i, j, j'); atom l ♯ (s, s', v, a, x, i, j, j', k, k'); atom m ♯ (s, s', v, a, i, j, j', k, k', l); atom n ♯ (s, s', v, a, i, j, j', k, k', l, m); atom sm ♯ (s, s', v, a, i, j, j', k, k', l, m, n); atom sn ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm); atom sm' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn); atom sn' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm'); atom m2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn'); atom n2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2); atom sm2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2); atom sn2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2); atom sm2' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2, sn2); atom sn2' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2, sn2, sm2')⟧ ⟹ {Neg (Var j' EQ Var j), SeqSubstFormP v a (Var i) (Var j') s' (Var k'), SeqSubstFormP v a (Var i) (Var j) s (Var k), OrdP (Var k)} ⊢ SyntaxN.Ex l (Neg (Var l IN Var k IMP SyntaxN.All i (SyntaxN.All j (SyntaxN.All j' (SyntaxN.All k' (SeqSubstFormP v a (Var i) (Var j) s (Var l) IMP SeqSubstFormP v a (Var i) (Var j') s' (Var k') IMP Var j' EQ Var j))))))›*) apply (rule cut_same (*‹⟦?H ⊢ ?A; insert ?A ?H ⊢ ?B⟧ ⟹ ?H ⊢ ?B›*)) (*goal: ‹⟦atom i ♯ (s, s', v, a, x, y, y'); atom j ♯ (s, s', v, a, x, i, x, y, y'); atom j' ♯ (s, s', v, a, x, i, j, x, y, y'); atom k ♯ (s, s', v, a, x, y, y', kk', i, j, j'); atom k' ♯ (s, s', v, a, x, y, y', k, i, j, j'); atom l ♯ (s, s', v, a, x, i, j, j', k, k'); atom m ♯ (s, s', v, a, i, j, j', k, k', l); atom n ♯ (s, s', v, a, i, j, j', k, k', l, m); atom sm ♯ (s, s', v, a, i, j, j', k, k', l, m, n); atom sn ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm); atom sm' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn); atom sn' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm'); atom m2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn'); atom n2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2); atom sm2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2); atom sn2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2); atom sm2' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2, sn2); atom sn2' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2, sn2, sm2')⟧ ⟹ {All2 l (Var k) (SyntaxN.All i (SyntaxN.All j (SyntaxN.All j' (SyntaxN.All k' (SeqSubstFormP v a (Var i) (Var j) s (Var l) IMP SeqSubstFormP v a (Var i) (Var j') s' (Var k') IMP Var j' EQ Var j))))), SeqSubstFormP v a (Var i) (Var j') s' (Var k'), SeqSubstFormP v a (Var i) (Var j) s (Var k), OrdP (Var k)} ⊢ Var j' EQ Var j›*) apply (rule cut1 [OF SeqSubstFormP_lemma [of m v a "Var i" "Var j" s "Var k" n sm sm' sn sn']] (*‹⟦atom m ♯ (v, a, Var i, Var j, s, Var k, n, sm, sm', sn, sn'); atom n ♯ (v, a, Var i, Var j, s, Var k, sm, sm', sn, sn'); atom sm ♯ (v, a, Var i, Var j, s, Var k, sm', sn, sn'); atom sm' ♯ (v, a, Var i, Var j, s, Var k, sn, sn'); atom sn ♯ (v, a, Var i, Var j, s, Var k, sn'); atom sn' ♯ (v, a, Var i, Var j, s, Var k); ?H ⊢ SeqSubstFormP v a (Var i) (Var j) s (Var k)⟧ ⟹ ?H ⊢ SubstAtomicP v a (Var i) (Var j) OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN Var k AND Var n IN Var k AND SeqSubstFormP v a (Var sm) (Var sm') s (Var m) AND SeqSubstFormP v a (Var sn) (Var sn') s (Var n) AND (Var i EQ Q_Disj (Var sm) (Var sn) AND Var j EQ Q_Disj (Var sm') (Var sn') OR Var i EQ Q_Neg (Var sm) AND Var j EQ Q_Neg (Var sm') OR Var i EQ Q_Ex (Var sm) AND Var j EQ Q_Ex (Var sm'))))))))›*), simp_all, blast) (*top goal: ‹⟦atom i ♯ (s, s', v, a, x, y, y'); atom j ♯ (s, s', v, a, x, i, x, y, y'); atom j' ♯ (s, s', v, a, x, i, j, x, y, y'); atom k ♯ (s, s', v, a, x, y, y', kk', i, j, j'); atom k' ♯ (s, s', v, a, x, y, y', k, i, j, j'); atom l ♯ (s, s', v, a, x, i, j, j', k, k'); atom m ♯ (s, s', v, a, i, j, j', k, k', l); atom n ♯ (s, s', v, a, i, j, j', k, k', l, m); atom sm ♯ (s, s', v, a, i, j, j', k, k', l, m, n); atom sn ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm); atom sm' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn); atom sn' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm'); atom m2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn'); atom n2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2); atom sm2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2); atom sn2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2); atom sm2' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2, sn2); atom sn2' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2, sn2, sm2')⟧ ⟹ {All2 l (Var k) (SyntaxN.All i (SyntaxN.All j (SyntaxN.All j' (SyntaxN.All k' (SeqSubstFormP v a (Var i) (Var j) s (Var l) IMP SeqSubstFormP v a (Var i) (Var j') s' (Var k') IMP Var j' EQ Var j))))), SeqSubstFormP v a (Var i) (Var j') s' (Var k'), SeqSubstFormP v a (Var i) (Var j) s (Var k), OrdP (Var k)} ⊢ ?A88› and 1 goal remains*) apply (rule cut_same (*‹⟦?H ⊢ ?A; insert ?A ?H ⊢ ?B⟧ ⟹ ?H ⊢ ?B›*)) (*goal: ‹⟦atom i ♯ (s, s', v, a, x, y, y'); atom j ♯ (s, s', v, a, x, i, x, y, y'); atom j' ♯ (s, s', v, a, x, i, j, x, y, y'); atom k ♯ (s, s', v, a, x, y, y', kk', i, j, j'); atom k' ♯ (s, s', v, a, x, y, y', k, i, j, j'); atom l ♯ (s, s', v, a, x, i, j, j', k, k'); atom m ♯ (s, s', v, a, i, j, j', k, k', l); atom n ♯ (s, s', v, a, i, j, j', k, k', l, m); atom sm ♯ (s, s', v, a, i, j, j', k, k', l, m, n); atom sn ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm); atom sm' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn); atom sn' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm'); atom m2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn'); atom n2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2); atom sm2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2); atom sn2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2); atom sm2' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2, sn2); atom sn2' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2, sn2, sm2')⟧ ⟹ {SubstAtomicP v a (Var i) (Var j) OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN Var k AND Var n IN Var k AND SeqSubstFormP v a (Var sm) (Var sm') s (Var m) AND SeqSubstFormP v a (Var sn) (Var sn') s (Var n) AND (Var i EQ Q_Disj (Var sm) (Var sn) AND Var j EQ Q_Disj (Var sm') (Var sn') OR Var i EQ Q_Neg (Var sm) AND Var j EQ Q_Neg (Var sm') OR Var i EQ Q_Ex (Var sm) AND Var j EQ Q_Ex (Var sm')))))))), All2 l (Var k) (SyntaxN.All i (SyntaxN.All j (SyntaxN.All j' (SyntaxN.All k' (SeqSubstFormP v a (Var i) (Var j) s (Var l) IMP SeqSubstFormP v a (Var i) (Var j') s' (Var k') IMP Var j' EQ Var j))))), SeqSubstFormP v a (Var i) (Var j') s' (Var k'), SeqSubstFormP v a (Var i) (Var j) s (Var k), OrdP (Var k)} ⊢ Var j' EQ Var j›*) apply (rule cut1 [OF SeqSubstFormP_lemma [of m2 v a "Var i" "Var j'" s' "Var k'" n2 sm2 sm2' sn2 sn2']] (*‹⟦atom (m2::name) ♯ (v::tm, a::tm, Var (i::name), Var (j'::name), s'::tm, Var (k'::name), n2::name, sm2::name, sm2'::name, sn2::name, sn2'::name); atom n2 ♯ (v, a, Var i, Var j', s', Var k', sm2, sm2', sn2, sn2'); atom sm2 ♯ (v, a, Var i, Var j', s', Var k', sm2', sn2, sn2'); atom sm2' ♯ (v, a, Var i, Var j', s', Var k', sn2, sn2'); atom sn2 ♯ (v, a, Var i, Var j', s', Var k', sn2'); atom sn2' ♯ (v, a, Var i, Var j', s', Var k'); (?H::fm set) ⊢ SeqSubstFormP v a (Var i) (Var j') s' (Var k')⟧ ⟹ ?H ⊢ SubstAtomicP v a (Var i) (Var j') OR SyntaxN.Ex m2 (SyntaxN.Ex n2 (SyntaxN.Ex sm2 (SyntaxN.Ex sm2' (SyntaxN.Ex sn2 (SyntaxN.Ex sn2' (Var m2 IN Var k' AND Var n2 IN Var k' AND SeqSubstFormP v a (Var sm2) (Var sm2') s' (Var m2) AND SeqSubstFormP v a (Var sn2) (Var sn2') s' (Var n2) AND (Var i EQ Q_Disj (Var sm2) (Var sn2) AND Var j' EQ Q_Disj (Var sm2') (Var sn2') OR Var i EQ Q_Neg (Var sm2) AND Var j' EQ Q_Neg (Var sm2') OR Var i EQ Q_Ex (Var sm2) AND Var j' EQ Q_Ex (Var sm2'))))))))›*), simp_all, blast) (*top goal: ‹⟦atom (i::name) ♯ (s::tm, s'::tm, v::tm, a::tm, x::tm, y::tm, y'::tm); atom (j::name) ♯ (s, s', v, a, x, i, x, y, y'); atom (j'::name) ♯ (s, s', v, a, x, i, j, x, y, y'); atom (k::name) ♯ (s, s', v, a, x, y, y', kk'::tm, i, j, j'); atom (k'::name) ♯ (s, s', v, a, x, y, y', k, i, j, j'); atom (l::name) ♯ (s, s', v, a, x, i, j, j', k, k'); atom (m::name) ♯ (s, s', v, a, i, j, j', k, k', l); atom (n::name) ♯ (s, s', v, a, i, j, j', k, k', l, m); atom (sm::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n); atom (sn::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm); atom (sm'::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn); atom (sn'::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm'); atom (m2::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn'); atom (n2::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2); atom (sm2::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2); atom (sn2::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2); atom (sm2'::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2, sn2); atom (sn2'::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2, sn2, sm2')⟧ ⟹ {SubstAtomicP v a (Var i) (Var j) OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN Var k AND Var n IN Var k AND SeqSubstFormP v a (Var sm) (Var sm') s (Var m) AND SeqSubstFormP v a (Var sn) (Var sn') s (Var n) AND (Var i EQ Q_Disj (Var sm) (Var sn) AND Var j EQ Q_Disj (Var sm') (Var sn') OR Var i EQ Q_Neg (Var sm) AND Var j EQ Q_Neg (Var sm') OR Var i EQ Q_Ex (Var sm) AND Var j EQ Q_Ex (Var sm')))))))), All2 l (Var k) (SyntaxN.All i (SyntaxN.All j (SyntaxN.All j' (SyntaxN.All k' (SeqSubstFormP v a (Var i) (Var j) s (Var l) IMP SeqSubstFormP v a (Var i) (Var j') s' (Var k') IMP Var j' EQ Var j))))), SeqSubstFormP v a (Var i) (Var j') s' (Var k'), SeqSubstFormP v a (Var i) (Var j) s (Var k), OrdP (Var k)} ⊢ (?A102::fm)› and 1 goal remains*) apply ((rule Disj_EH (*‹⟦insert (?A::fm) (?H::fm set) ⊢ (?C::fm); insert (?B::fm) ?H ⊢ ?C⟧ ⟹ insert (?A OR ?B) ?H ⊢ ?C› ‹⟦insert (?A::fm) (insert (?A1.0::fm) (?H::fm set)) ⊢ (?B::fm); insert (?Ba::fm) (insert ?A1.0 ?H) ⊢ ?B⟧ ⟹ insert ?A1.0 (insert (?A OR ?Ba) ?H) ⊢ ?B› ‹⟦insert (?A::fm) (insert (?A1.0::fm) (insert (?A2.0::fm) (?H::fm set))) ⊢ (?B::fm); insert (?Ba::fm) (insert ?A1.0 (insert ?A2.0 ?H)) ⊢ ?B⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert (?A OR ?Ba) ?H)) ⊢ ?B› ‹⟦insert (?A::fm) (insert (?A1.0::fm) (insert (?A2.0::fm) (insert (?A3.0::fm) (?H::fm set)))) ⊢ (?B::fm); insert (?Ba::fm) (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 ?H))) ⊢ ?B⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert (?A OR ?Ba) ?H))) ⊢ ?B› ‹⟦insert (?A::fm) (insert (?A1.0::fm) (insert (?A2.0::fm) (insert (?A3.0::fm) (insert (?A4.0::fm) (?H::fm set))))) ⊢ (?B::fm); insert (?Ba::fm) (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 ?H)))) ⊢ ?B⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert (?A OR ?Ba) ?H)))) ⊢ ?B› ‹⟦insert (?A::fm) (insert (?A1.0::fm) (insert (?A2.0::fm) (insert (?A3.0::fm) (insert (?A4.0::fm) (insert (?A5.0::fm) (?H::fm set)))))) ⊢ (?B::fm); insert (?Ba::fm) (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 ?H))))) ⊢ ?B⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert (?A OR ?Ba) ?H))))) ⊢ ?B› ‹⟦insert (?A::fm) (insert (?A1.0::fm) (insert (?A2.0::fm) (insert (?A3.0::fm) (insert (?A4.0::fm) (insert (?A5.0::fm) (insert (?A6.0::fm) (?H::fm set))))))) ⊢ (?B::fm); insert (?Ba::fm) (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 ?H)))))) ⊢ ?B⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert (?A OR ?Ba) ?H)))))) ⊢ ?B› ‹⟦insert (?A::fm) (insert (?A1.0::fm) (insert (?A2.0::fm) (insert (?A3.0::fm) (insert (?A4.0::fm) (insert (?A5.0::fm) (insert (?A6.0::fm) (insert (?A7.0::fm) (?H::fm set)))))))) ⊢ (?B::fm); insert (?Ba::fm) (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 ?H))))))) ⊢ ?B⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 (insert (?A OR ?Ba) ?H))))))) ⊢ ?B› ‹⟦insert (?A::fm) (insert (?A1.0::fm) (insert (?A2.0::fm) (insert (?A3.0::fm) (insert (?A4.0::fm) (insert (?A5.0::fm) (insert (?A6.0::fm) (insert (?A7.0::fm) (insert (?A8.0::fm) (?H::fm set))))))))) ⊢ (?B::fm); insert (?Ba::fm) (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)))))))) ⊢ ?B⟧ ⟹ 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 (?A OR ?Ba) ?H)))))))) ⊢ ?B› ‹⟦insert (?A::fm) (insert (?A1.0::fm) (insert (?A2.0::fm) (insert (?A3.0::fm) (insert (?A4.0::fm) (insert (?A5.0::fm) (insert (?A6.0::fm) (insert (?A7.0::fm) (insert (?A8.0::fm) (insert (?A9.0::fm) (?H::fm set)))))))))) ⊢ (?B::fm); insert (?Ba::fm) (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))))))))) ⊢ ?B⟧ ⟹ 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 (?A OR ?Ba) ?H))))))))) ⊢ ?B›*) Conj_EH (*‹insert (?A::fm) (insert (?B::fm) (?H::fm set)) ⊢ (?C::fm) ⟹ insert (?A AND ?B) ?H ⊢ ?C› ‹insert (?A::fm) (insert (?Ba::fm) (insert (?A1.0::fm) (?H::fm set))) ⊢ (?B::fm) ⟹ insert ?A1.0 (insert (?A AND ?Ba) ?H) ⊢ ?B› ‹insert (?A::fm) (insert (?Ba::fm) (insert (?A1.0::fm) (insert (?A2.0::fm) (?H::fm set)))) ⊢ (?B::fm) ⟹ insert ?A1.0 (insert ?A2.0 (insert (?A AND ?Ba) ?H)) ⊢ ?B› ‹insert (?A::fm) (insert (?Ba::fm) (insert (?A1.0::fm) (insert (?A2.0::fm) (insert (?A3.0::fm) (?H::fm set))))) ⊢ (?B::fm) ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert (?A AND ?Ba) ?H))) ⊢ ?B› ‹insert (?A::fm) (insert (?Ba::fm) (insert (?A1.0::fm) (insert (?A2.0::fm) (insert (?A3.0::fm) (insert (?A4.0::fm) (?H::fm set)))))) ⊢ (?B::fm) ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert (?A AND ?Ba) ?H)))) ⊢ ?B› ‹insert (?A::fm) (insert (?Ba::fm) (insert (?A1.0::fm) (insert (?A2.0::fm) (insert (?A3.0::fm) (insert (?A4.0::fm) (insert (?A5.0::fm) (?H::fm set))))))) ⊢ (?B::fm) ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert (?A AND ?Ba) ?H))))) ⊢ ?B› ‹insert (?A::fm) (insert (?Ba::fm) (insert (?A1.0::fm) (insert (?A2.0::fm) (insert (?A3.0::fm) (insert (?A4.0::fm) (insert (?A5.0::fm) (insert (?A6.0::fm) (?H::fm set)))))))) ⊢ (?B::fm) ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert (?A AND ?Ba) ?H)))))) ⊢ ?B› ‹insert (?A::fm) (insert (?Ba::fm) (insert (?A1.0::fm) (insert (?A2.0::fm) (insert (?A3.0::fm) (insert (?A4.0::fm) (insert (?A5.0::fm) (insert (?A6.0::fm) (insert (?A7.0::fm) (?H::fm set))))))))) ⊢ (?B::fm) ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 (insert (?A AND ?Ba) ?H))))))) ⊢ ?B› ‹insert (?A::fm) (insert (?Ba::fm) (insert (?A1.0::fm) (insert (?A2.0::fm) (insert (?A3.0::fm) (insert (?A4.0::fm) (insert (?A5.0::fm) (insert (?A6.0::fm) (insert (?A7.0::fm) (insert (?A8.0::fm) (?H::fm set)))))))))) ⊢ (?B::fm) ⟹ 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 (?A AND ?Ba) ?H)))))))) ⊢ ?B› ‹insert (?A::fm) (insert (?Ba::fm) (insert (?A1.0::fm) (insert (?A2.0::fm) (insert (?A3.0::fm) (insert (?A4.0::fm) (insert (?A5.0::fm) (insert (?A6.0::fm) (insert (?A7.0::fm) (insert (?A8.0::fm) (insert (?A9.0::fm) (?H::fm set))))))))))) ⊢ (?B::fm) ⟹ 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 (?A AND ?Ba) ?H))))))))) ⊢ ?B›*))+) (*goal: ‹⟦atom i ♯ (s, s', v, a, x, y, y'); atom j ♯ (s, s', v, a, x, i, x, y, y'); atom j' ♯ (s, s', v, a, x, i, j, x, y, y'); atom k ♯ (s, s', v, a, x, y, y', kk', i, j, j'); atom k' ♯ (s, s', v, a, x, y, y', k, i, j, j'); atom l ♯ (s, s', v, a, x, i, j, j', k, k'); atom m ♯ (s, s', v, a, i, j, j', k, k', l); atom n ♯ (s, s', v, a, i, j, j', k, k', l, m); atom sm ♯ (s, s', v, a, i, j, j', k, k', l, m, n); atom sn ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm); atom sm' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn); atom sn' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm'); atom m2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn'); atom n2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2); atom sm2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2); atom sn2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2); atom sm2' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2, sn2); atom sn2' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2, sn2, sm2')⟧ ⟹ {SubstAtomicP v a (Var i) (Var j') OR SyntaxN.Ex m2 (SyntaxN.Ex n2 (SyntaxN.Ex sm2 (SyntaxN.Ex sm2' (SyntaxN.Ex sn2 (SyntaxN.Ex sn2' (Var m2 IN Var k' AND Var n2 IN Var k' AND SeqSubstFormP v a (Var sm2) (Var sm2') s' (Var m2) AND SeqSubstFormP v a (Var sn2) (Var sn2') s' (Var n2) AND (Var i EQ Q_Disj (Var sm2) (Var sn2) AND Var j' EQ Q_Disj (Var sm2') (Var sn2') OR Var i EQ Q_Neg (Var sm2) AND Var j' EQ Q_Neg (Var sm2') OR Var i EQ Q_Ex (Var sm2) AND Var j' EQ Q_Ex (Var sm2')))))))), SubstAtomicP v a (Var i) (Var j) OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN Var k AND Var n IN Var k AND SeqSubstFormP v a (Var sm) (Var sm') s (Var m) AND SeqSubstFormP v a (Var sn) (Var sn') s (Var n) AND (Var i EQ Q_Disj (Var sm) (Var sn) AND Var j EQ Q_Disj (Var sm') (Var sn') OR Var i EQ Q_Neg (Var sm) AND Var j EQ Q_Neg (Var sm') OR Var i EQ Q_Ex (Var sm) AND Var j EQ Q_Ex (Var sm')))))))), All2 l (Var k) (SyntaxN.All i (SyntaxN.All j (SyntaxN.All j' (SyntaxN.All k' (SeqSubstFormP v a (Var i) (Var j) s (Var l) IMP SeqSubstFormP v a (Var i) (Var j') s' (Var k') IMP Var j' EQ Var j))))), SeqSubstFormP v a (Var i) (Var j') s' (Var k'), SeqSubstFormP v a (Var i) (Var j) s (Var k), OrdP (Var k)} ⊢ Var j' EQ Var j›*) apply (blast intro: cut2 [OF SubstAtomicP_unique] (*‹⟦?H ⊢ SubstAtomicP ?v1 ?tm1 ?x1 ?y1; ?H ⊢ SubstAtomicP ?v1 ?tm1 ?x1 ?y'1⟧ ⟹ ?H ⊢ ?y'1 EQ ?y1›*)) (*top goal: ‹⟦atom i ♯ (s, s', v, a, x, y, y'); atom j ♯ (s, s', v, a, x, i, x, y, y'); atom j' ♯ (s, s', v, a, x, i, j, x, y, y'); atom k ♯ (s, s', v, a, x, y, y', kk', i, j, j'); atom k' ♯ (s, s', v, a, x, y, y', k, i, j, j'); atom l ♯ (s, s', v, a, x, i, j, j', k, k'); atom m ♯ (s, s', v, a, i, j, j', k, k', l); atom n ♯ (s, s', v, a, i, j, j', k, k', l, m); atom sm ♯ (s, s', v, a, i, j, j', k, k', l, m, n); atom sn ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm); atom sm' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn); atom sn' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm'); atom m2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn'); atom n2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2); atom sm2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2); atom sn2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2); atom sm2' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2, sn2); atom sn2' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2, sn2, sm2')⟧ ⟹ {SubstAtomicP v a (Var i) (Var j), SubstAtomicP v a (Var i) (Var j'), All2 l (Var k) (SyntaxN.All i (SyntaxN.All j (SyntaxN.All j' (SyntaxN.All k' (SeqSubstFormP v a (Var i) (Var j) s (Var l) IMP SeqSubstFormP v a (Var i) (Var j') s' (Var k') IMP Var j' EQ Var j))))), SeqSubstFormP v a (Var i) (Var j') s' (Var k'), SeqSubstFormP v a (Var i) (Var j) s (Var k), OrdP (Var k)} ⊢ Var j' EQ Var j› and 2 goals remain*) apply ((rule Ex_EH (*‹⟦insert ?A ?H ⊢ ?B; atom ?i ♯ ?B; ∀C∈?H. atom ?i ♯ C⟧ ⟹ insert (SyntaxN.Ex ?i ?A) ?H ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 ?H) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 ?H. atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert (SyntaxN.Ex ?i ?A) ?H) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 ?H)) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 ?H). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert (SyntaxN.Ex ?i ?A) ?H)) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 ?H))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 ?H)). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert (SyntaxN.Ex ?i ?A) ?H))) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 ?H)))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 ?H))). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert (SyntaxN.Ex ?i ?A) ?H)))) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 ?H))))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 ?H)))). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert (SyntaxN.Ex ?i ?A) ?H))))) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 ?H)))))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 ?H))))). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert (SyntaxN.Ex ?i ?A) ?H)))))) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 ?H))))))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 ?H)))))). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 (insert (SyntaxN.Ex ?i ?A) ?H))))))) ⊢ ?B› ‹⟦insert ?A (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)))))))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈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))))))). atom ?i ♯ C⟧ ⟹ 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 (SyntaxN.Ex ?i ?A) ?H)))))))) ⊢ ?B› ‹⟦insert ?A (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))))))))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈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)))))))). atom ?i ♯ C⟧ ⟹ 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 (SyntaxN.Ex ?i ?A) ?H))))))))) ⊢ ?B›*) Conj_EH (*‹insert ?A (insert ?B ?H) ⊢ ?C ⟹ insert (?A AND ?B) ?H ⊢ ?C› ‹insert ?A (insert ?Ba (insert ?A1.0 ?H)) ⊢ ?B ⟹ insert ?A1.0 (insert (?A AND ?Ba) ?H) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 ?H))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert (?A AND ?Ba) ?H)) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 ?H)))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert (?A AND ?Ba) ?H))) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 ?H))))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert (?A AND ?Ba) ?H)))) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 ?H)))))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert (?A AND ?Ba) ?H))))) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 ?H))))))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert (?A AND ?Ba) ?H)))))) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 ?H)))))))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 (insert (?A AND ?Ba) ?H))))))) ⊢ ?B› ‹insert ?A (insert ?Ba (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))))))))) ⊢ ?B ⟹ 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 (?A AND ?Ba) ?H)))))))) ⊢ ?B› ‹insert ?A (insert ?Ba (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)))))))))) ⊢ ?B ⟹ 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 (?A AND ?Ba) ?H))))))))) ⊢ ?B›*) Disj_EH (*‹⟦insert ?A ?H ⊢ ?C; insert ?B ?H ⊢ ?C⟧ ⟹ insert (?A OR ?B) ?H ⊢ ?C› ‹⟦insert ?A (insert ?A1.0 ?H) ⊢ ?B; insert ?Ba (insert ?A1.0 ?H) ⊢ ?B⟧ ⟹ insert ?A1.0 (insert (?A OR ?Ba) ?H) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 ?H)) ⊢ ?B; insert ?Ba (insert ?A1.0 (insert ?A2.0 ?H)) ⊢ ?B⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert (?A OR ?Ba) ?H)) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 ?H))) ⊢ ?B; insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 ?H))) ⊢ ?B⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert (?A OR ?Ba) ?H))) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 ?H)))) ⊢ ?B; insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 ?H)))) ⊢ ?B⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert (?A OR ?Ba) ?H)))) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 ?H))))) ⊢ ?B; insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 ?H))))) ⊢ ?B⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert (?A OR ?Ba) ?H))))) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 ?H)))))) ⊢ ?B; insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 ?H)))))) ⊢ ?B⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert (?A OR ?Ba) ?H)))))) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 ?H))))))) ⊢ ?B; insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 ?H))))))) ⊢ ?B⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 (insert (?A OR ?Ba) ?H))))))) ⊢ ?B› ‹⟦insert ?A (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)))))))) ⊢ ?B; insert ?Ba (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)))))))) ⊢ ?B⟧ ⟹ 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 (?A OR ?Ba) ?H)))))))) ⊢ ?B› ‹⟦insert ?A (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))))))))) ⊢ ?B; insert ?Ba (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))))))))) ⊢ ?B⟧ ⟹ 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 (?A OR ?Ba) ?H))))))))) ⊢ ?B›*))+) (*top goal: ‹⟦atom i ♯ (s, s', v, a, x, y, y'); atom j ♯ (s, s', v, a, x, i, x, y, y'); atom j' ♯ (s, s', v, a, x, i, j, x, y, y'); atom k ♯ (s, s', v, a, x, y, y', kk', i, j, j'); atom k' ♯ (s, s', v, a, x, y, y', k, i, j, j'); atom l ♯ (s, s', v, a, x, i, j, j', k, k'); atom m ♯ (s, s', v, a, i, j, j', k, k', l); atom n ♯ (s, s', v, a, i, j, j', k, k', l, m); atom sm ♯ (s, s', v, a, i, j, j', k, k', l, m, n); atom sn ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm); atom sm' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn); atom sn' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm'); atom m2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn'); atom n2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2); atom sm2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2); atom sn2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2); atom sm2' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2, sn2); atom sn2' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2, sn2, sm2')⟧ ⟹ {SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN Var k AND Var n IN Var k AND SeqSubstFormP v a (Var sm) (Var sm') s (Var m) AND SeqSubstFormP v a (Var sn) (Var sn') s (Var n) AND (Var i EQ Q_Disj (Var sm) (Var sn) AND Var j EQ Q_Disj (Var sm') (Var sn') OR Var i EQ Q_Neg (Var sm) AND Var j EQ Q_Neg (Var sm') OR Var i EQ Q_Ex (Var sm) AND Var j EQ Q_Ex (Var sm')))))))), SubstAtomicP v a (Var i) (Var j'), All2 l (Var k) (SyntaxN.All i (SyntaxN.All j (SyntaxN.All j' (SyntaxN.All k' (SeqSubstFormP v a (Var i) (Var j) s (Var l) IMP SeqSubstFormP v a (Var i) (Var j') s' (Var k') IMP Var j' EQ Var j))))), SeqSubstFormP v a (Var i) (Var j') s' (Var k'), SeqSubstFormP v a (Var i) (Var j) s (Var k), OrdP (Var k)} ⊢ Var j' EQ Var j› and 1 goal remains*) apply simp_all (*top goal: ‹⟦atom (i::name) ♯ (s::tm, s'::tm, v::tm, a::tm, x::tm, y::tm, y'::tm); atom (j::name) ♯ (s, s', v, a, x, i, x, y, y'); atom (j'::name) ♯ (s, s', v, a, x, i, j, x, y, y'); atom (k::name) ♯ (s, s', v, a, x, y, y', kk'::tm, i, j, j'); atom (k'::name) ♯ (s, s', v, a, x, y, y', k, i, j, j'); atom (l::name) ♯ (s, s', v, a, x, i, j, j', k, k'); atom (m::name) ♯ (s, s', v, a, i, j, j', k, k', l); atom (n::name) ♯ (s, s', v, a, i, j, j', k, k', l, m); atom (sm::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n); atom (sn::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm); atom (sm'::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn); atom (sn'::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm'); atom (m2::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn'); atom (n2::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2); atom (sm2::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2); atom (sn2::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2); atom (sm2'::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2, sn2); atom (sn2'::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2, sn2, sm2')⟧ ⟹ {Var i EQ Q_Disj (Var sm) (Var sn), Var j EQ Q_Disj (Var sm') (Var sn'), SeqSubstFormP v a (Var sn) (Var sn') s (Var n), SeqSubstFormP v a (Var sm) (Var sm') s (Var m), Var n IN Var k, Var m IN Var k, SubstAtomicP v a (Var i) (Var j'), All2 l (Var k) (SyntaxN.All i (SyntaxN.All j (SyntaxN.All j' (SyntaxN.All k' (SeqSubstFormP v a (Var i) (Var j) s (Var l) IMP SeqSubstFormP v a (Var i) (Var j') s' (Var k') IMP Var j' EQ Var j))))), SeqSubstFormP v a (Var i) (Var j') s' (Var k'), SeqSubstFormP v a (Var i) (Var j) s (Var k), OrdP (Var k)} ⊢ Var j' EQ Var j› and 14 goals remain*) apply (metis Assume (*‹insert ?A ?H ⊢ ?A›*) AssumeH( (*‹insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 ?H)))))) ⊢ ?A7.0›*) 7) Disj_I1 (*‹?H ⊢ ?A ⟹ ?H ⊢ ?A OR ?B›*) Neg_I (*‹insert ?A ?H ⊢ Fls ⟹ ?H ⊢ Neg ?A›*) anti_deduction (*‹?H ⊢ ?A IMP ?B ⟹ insert ?A ?H ⊢ ?B›*) cut2 [OF Disj_SubstAtomicP_Fls] (*‹⟦?H ⊢ ?y1 EQ Q_Disj ?z1 ?w1; ?H ⊢ SubstAtomicP ?v1 ?tm1 ?y1 ?y'1⟧ ⟹ ?H ⊢ Fls›*)) (*top goal: ‹⟦atom i ♯ (s, s', v, a, x, y, y'); atom j ♯ (s, s', v, a, x, i, x, y, y'); atom j' ♯ (s, s', v, a, x, i, j, x, y, y'); atom k ♯ (s, s', v, a, x, y, y', kk', i, j, j'); atom k' ♯ (s, s', v, a, x, y, y', k, i, j, j'); atom l ♯ (s, s', v, a, x, i, j, j', k, k'); atom m ♯ (s, s', v, a, i, j, j', k, k', l); atom n ♯ (s, s', v, a, i, j, j', k, k', l, m); atom sm ♯ (s, s', v, a, i, j, j', k, k', l, m, n); atom sn ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm); atom sm' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn); atom sn' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm'); atom m2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn'); atom n2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2); atom sm2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2); atom sn2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2); atom sm2' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2, sn2); atom sn2' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2, sn2, sm2')⟧ ⟹ {Var i EQ Q_Disj (Var sm) (Var sn), Var j EQ Q_Disj (Var sm') (Var sn'), SeqSubstFormP v a (Var sn) (Var sn') s (Var n), SeqSubstFormP v a (Var sm) (Var sm') s (Var m), Var n IN Var k, Var m IN Var k, SubstAtomicP v a (Var i) (Var j'), All2 l (Var k) (SyntaxN.All i (SyntaxN.All j (SyntaxN.All j' (SyntaxN.All k' (SeqSubstFormP v a (Var i) (Var j) s (Var l) IMP SeqSubstFormP v a (Var i) (Var j') s' (Var k') IMP Var j' EQ Var j))))), SeqSubstFormP v a (Var i) (Var j') s' (Var k'), SeqSubstFormP v a (Var i) (Var j) s (Var k), OrdP (Var k)} ⊢ Var j' EQ Var j› and 2 goals remain*) apply ((rule Conj_EH (*‹insert ?A (insert ?B ?H) ⊢ ?C ⟹ insert (?A AND ?B) ?H ⊢ ?C› ‹insert ?A (insert ?Ba (insert ?A1.0 ?H)) ⊢ ?B ⟹ insert ?A1.0 (insert (?A AND ?Ba) ?H) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 ?H))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert (?A AND ?Ba) ?H)) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 ?H)))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert (?A AND ?Ba) ?H))) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 ?H))))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert (?A AND ?Ba) ?H)))) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 ?H)))))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert (?A AND ?Ba) ?H))))) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 ?H))))))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert (?A AND ?Ba) ?H)))))) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 ?H)))))))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 (insert (?A AND ?Ba) ?H))))))) ⊢ ?B› ‹insert ?A (insert ?Ba (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))))))))) ⊢ ?B ⟹ 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 (?A AND ?Ba) ?H)))))))) ⊢ ?B› ‹insert ?A (insert ?Ba (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)))))))))) ⊢ ?B ⟹ 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 (?A AND ?Ba) ?H))))))))) ⊢ ?B›*) Disj_EH (*‹⟦insert ?A ?H ⊢ ?C; insert ?B ?H ⊢ ?C⟧ ⟹ insert (?A OR ?B) ?H ⊢ ?C› ‹⟦insert ?A (insert ?A1.0 ?H) ⊢ ?B; insert ?Ba (insert ?A1.0 ?H) ⊢ ?B⟧ ⟹ insert ?A1.0 (insert (?A OR ?Ba) ?H) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 ?H)) ⊢ ?B; insert ?Ba (insert ?A1.0 (insert ?A2.0 ?H)) ⊢ ?B⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert (?A OR ?Ba) ?H)) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 ?H))) ⊢ ?B; insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 ?H))) ⊢ ?B⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert (?A OR ?Ba) ?H))) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 ?H)))) ⊢ ?B; insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 ?H)))) ⊢ ?B⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert (?A OR ?Ba) ?H)))) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 ?H))))) ⊢ ?B; insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 ?H))))) ⊢ ?B⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert (?A OR ?Ba) ?H))))) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 ?H)))))) ⊢ ?B; insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 ?H)))))) ⊢ ?B⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert (?A OR ?Ba) ?H)))))) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 ?H))))))) ⊢ ?B; insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 ?H))))))) ⊢ ?B⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 (insert (?A OR ?Ba) ?H))))))) ⊢ ?B› ‹⟦insert ?A (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)))))))) ⊢ ?B; insert ?Ba (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)))))))) ⊢ ?B⟧ ⟹ 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 (?A OR ?Ba) ?H)))))))) ⊢ ?B› ‹⟦insert ?A (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))))))))) ⊢ ?B; insert ?Ba (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))))))))) ⊢ ?B⟧ ⟹ 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 (?A OR ?Ba) ?H))))))))) ⊢ ?B›*))+) (*top goal: ‹⟦atom (i::name) ♯ (s::tm, s'::tm, v::tm, a::tm, x::tm, y::tm, y'::tm); atom (j::name) ♯ (s, s', v, a, x, i, x, y, y'); atom (j'::name) ♯ (s, s', v, a, x, i, j, x, y, y'); atom (k::name) ♯ (s, s', v, a, x, y, y', kk'::tm, i, j, j'); atom (k'::name) ♯ (s, s', v, a, x, y, y', k, i, j, j'); atom (l::name) ♯ (s, s', v, a, x, i, j, j', k, k'); atom (m::name) ♯ (s, s', v, a, i, j, j', k, k', l); atom (n::name) ♯ (s, s', v, a, i, j, j', k, k', l, m); atom (sm::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n); atom (sn::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm); atom (sm'::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn); atom (sn'::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm'); atom (m2::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn'); atom (n2::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2); atom (sm2::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2); atom (sn2::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2); atom (sm2'::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2, sn2); atom (sn2'::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2, sn2, sm2')⟧ ⟹ {Var i EQ Q_Neg (Var sm) AND Var j EQ Q_Neg (Var sm') OR Var i EQ Q_Ex (Var sm) AND Var j EQ Q_Ex (Var sm'), SeqSubstFormP v a (Var sn) (Var sn') s (Var n), SeqSubstFormP v a (Var sm) (Var sm') s (Var m), Var n IN Var k, Var m IN Var k, SubstAtomicP v a (Var i) (Var j'), All2 l (Var k) (SyntaxN.All i (SyntaxN.All j (SyntaxN.All j' (SyntaxN.All k' (SeqSubstFormP v a (Var i) (Var j) s (Var l) IMP SeqSubstFormP v a (Var i) (Var j') s' (Var k') IMP Var j' EQ Var j))))), SeqSubstFormP v a (Var i) (Var j') s' (Var k'), SeqSubstFormP v a (Var i) (Var j) s (Var k), OrdP (Var k)} ⊢ Var j' EQ Var j› and 1 goal remains*) apply (metis Assume (*‹insert ?A ?H ⊢ ?A›*) AssumeH( (*‹insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 ?H)))))) ⊢ ?A7.0›*) 7) Disj_I1 (*‹?H ⊢ ?A ⟹ ?H ⊢ ?A OR ?B›*) Neg_I (*‹insert ?A ?H ⊢ Fls ⟹ ?H ⊢ Neg ?A›*) anti_deduction (*‹?H ⊢ ?A IMP ?B ⟹ insert ?A ?H ⊢ ?B›*) cut2 [OF Neg_SubstAtomicP_Fls] (*‹⟦?H ⊢ ?y1 EQ Q_Neg ?z1; ?H ⊢ SubstAtomicP ?v1 ?tm1 ?y1 ?y'1⟧ ⟹ ?H ⊢ Fls›*)) (*top goal: ‹⟦atom i ♯ (s, s', v, a, x, y, y'); atom j ♯ (s, s', v, a, x, i, x, y, y'); atom j' ♯ (s, s', v, a, x, i, j, x, y, y'); atom k ♯ (s, s', v, a, x, y, y', kk', i, j, j'); atom k' ♯ (s, s', v, a, x, y, y', k, i, j, j'); atom l ♯ (s, s', v, a, x, i, j, j', k, k'); atom m ♯ (s, s', v, a, i, j, j', k, k', l); atom n ♯ (s, s', v, a, i, j, j', k, k', l, m); atom sm ♯ (s, s', v, a, i, j, j', k, k', l, m, n); atom sn ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm); atom sm' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn); atom sn' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm'); atom m2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn'); atom n2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2); atom sm2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2); atom sn2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2); atom sm2' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2, sn2); atom sn2' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2, sn2, sm2')⟧ ⟹ {Var i EQ Q_Neg (Var sm), Var j EQ Q_Neg (Var sm'), SeqSubstFormP v a (Var sn) (Var sn') s (Var n), SeqSubstFormP v a (Var sm) (Var sm') s (Var m), Var n IN Var k, Var m IN Var k, SubstAtomicP v a (Var i) (Var j'), All2 l (Var k) (SyntaxN.All i (SyntaxN.All j (SyntaxN.All j' (SyntaxN.All k' (SeqSubstFormP v a (Var i) (Var j) s (Var l) IMP SeqSubstFormP v a (Var i) (Var j') s' (Var k') IMP Var j' EQ Var j))))), SeqSubstFormP v a (Var i) (Var j') s' (Var k'), SeqSubstFormP v a (Var i) (Var j) s (Var k), OrdP (Var k)} ⊢ Var j' EQ Var j› and 2 goals remain*) apply ((rule Conj_EH (*‹insert ?A (insert ?B ?H) ⊢ ?C ⟹ insert (?A AND ?B) ?H ⊢ ?C› ‹insert ?A (insert ?Ba (insert ?A1.0 ?H)) ⊢ ?B ⟹ insert ?A1.0 (insert (?A AND ?Ba) ?H) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 ?H))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert (?A AND ?Ba) ?H)) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 ?H)))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert (?A AND ?Ba) ?H))) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 ?H))))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert (?A AND ?Ba) ?H)))) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 ?H)))))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert (?A AND ?Ba) ?H))))) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 ?H))))))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert (?A AND ?Ba) ?H)))))) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 ?H)))))))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 (insert (?A AND ?Ba) ?H))))))) ⊢ ?B› ‹insert ?A (insert ?Ba (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))))))))) ⊢ ?B ⟹ 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 (?A AND ?Ba) ?H)))))))) ⊢ ?B› ‹insert ?A (insert ?Ba (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)))))))))) ⊢ ?B ⟹ 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 (?A AND ?Ba) ?H))))))))) ⊢ ?B›*))+) (*top goal: ‹⟦atom (i::name) ♯ (s::tm, s'::tm, v::tm, a::tm, x::tm, y::tm, y'::tm); atom (j::name) ♯ (s, s', v, a, x, i, x, y, y'); atom (j'::name) ♯ (s, s', v, a, x, i, j, x, y, y'); atom (k::name) ♯ (s, s', v, a, x, y, y', kk'::tm, i, j, j'); atom (k'::name) ♯ (s, s', v, a, x, y, y', k, i, j, j'); atom (l::name) ♯ (s, s', v, a, x, i, j, j', k, k'); atom (m::name) ♯ (s, s', v, a, i, j, j', k, k', l); atom (n::name) ♯ (s, s', v, a, i, j, j', k, k', l, m); atom (sm::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n); atom (sn::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm); atom (sm'::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn); atom (sn'::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm'); atom (m2::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn'); atom (n2::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2); atom (sm2::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2); atom (sn2::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2); atom (sm2'::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2, sn2); atom (sn2'::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2, sn2, sm2')⟧ ⟹ {Var i EQ Q_Ex (Var sm) AND Var j EQ Q_Ex (Var sm'), SeqSubstFormP v a (Var sn) (Var sn') s (Var n), SeqSubstFormP v a (Var sm) (Var sm') s (Var m), Var n IN Var k, Var m IN Var k, SubstAtomicP v a (Var i) (Var j'), All2 l (Var k) (SyntaxN.All i (SyntaxN.All j (SyntaxN.All j' (SyntaxN.All k' (SeqSubstFormP v a (Var i) (Var j) s (Var l) IMP SeqSubstFormP v a (Var i) (Var j') s' (Var k') IMP Var j' EQ Var j))))), SeqSubstFormP v a (Var i) (Var j') s' (Var k'), SeqSubstFormP v a (Var i) (Var j) s (Var k), OrdP (Var k)} ⊢ Var j' EQ Var j› and 1 goal remains*) apply (metis Assume (*‹insert ?A ?H ⊢ ?A›*) AssumeH( (*‹insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 ?H)))))) ⊢ ?A7.0›*) 7) Disj_I1 (*‹?H ⊢ ?A ⟹ ?H ⊢ ?A OR ?B›*) Neg_I (*‹insert ?A ?H ⊢ Fls ⟹ ?H ⊢ Neg ?A›*) anti_deduction (*‹?H ⊢ ?A IMP ?B ⟹ insert ?A ?H ⊢ ?B›*) cut2 [OF Ex_SubstAtomicP_Fls] (*‹⟦?H ⊢ ?y1 EQ Q_Ex ?z1; ?H ⊢ SubstAtomicP ?v1 ?tm1 ?y1 ?y'1⟧ ⟹ ?H ⊢ Fls›*)) (*top goal: ‹⟦atom i ♯ (s, s', v, a, x, y, y'); atom j ♯ (s, s', v, a, x, i, x, y, y'); atom j' ♯ (s, s', v, a, x, i, j, x, y, y'); atom k ♯ (s, s', v, a, x, y, y', kk', i, j, j'); atom k' ♯ (s, s', v, a, x, y, y', k, i, j, j'); atom l ♯ (s, s', v, a, x, i, j, j', k, k'); atom m ♯ (s, s', v, a, i, j, j', k, k', l); atom n ♯ (s, s', v, a, i, j, j', k, k', l, m); atom sm ♯ (s, s', v, a, i, j, j', k, k', l, m, n); atom sn ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm); atom sm' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn); atom sn' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm'); atom m2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn'); atom n2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2); atom sm2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2); atom sn2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2); atom sm2' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2, sn2); atom sn2' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2, sn2, sm2')⟧ ⟹ {Var i EQ Q_Ex (Var sm), Var j EQ Q_Ex (Var sm'), SeqSubstFormP v a (Var sn) (Var sn') s (Var n), SeqSubstFormP v a (Var sm) (Var sm') s (Var m), Var n IN Var k, Var m IN Var k, SubstAtomicP v a (Var i) (Var j'), All2 l (Var k) (SyntaxN.All i (SyntaxN.All j (SyntaxN.All j' (SyntaxN.All k' (SeqSubstFormP v a (Var i) (Var j) s (Var l) IMP SeqSubstFormP v a (Var i) (Var j') s' (Var k') IMP Var j' EQ Var j))))), SeqSubstFormP v a (Var i) (Var j') s' (Var k'), SeqSubstFormP v a (Var i) (Var j) s (Var k), OrdP (Var k)} ⊢ Var j' EQ Var j› and 1 goal remains*) apply ((rule Conj_EH (*‹insert ?A (insert ?B ?H) ⊢ ?C ⟹ insert (?A AND ?B) ?H ⊢ ?C› ‹insert ?A (insert ?Ba (insert ?A1.0 ?H)) ⊢ ?B ⟹ insert ?A1.0 (insert (?A AND ?Ba) ?H) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 ?H))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert (?A AND ?Ba) ?H)) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 ?H)))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert (?A AND ?Ba) ?H))) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 ?H))))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert (?A AND ?Ba) ?H)))) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 ?H)))))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert (?A AND ?Ba) ?H))))) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 ?H))))))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert (?A AND ?Ba) ?H)))))) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 ?H)))))))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 (insert (?A AND ?Ba) ?H))))))) ⊢ ?B› ‹insert ?A (insert ?Ba (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))))))))) ⊢ ?B ⟹ 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 (?A AND ?Ba) ?H)))))))) ⊢ ?B› ‹insert ?A (insert ?Ba (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)))))))))) ⊢ ?B ⟹ 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 (?A AND ?Ba) ?H))))))))) ⊢ ?B›*) Disj_EH (*‹⟦insert ?A ?H ⊢ ?C; insert ?B ?H ⊢ ?C⟧ ⟹ insert (?A OR ?B) ?H ⊢ ?C› ‹⟦insert ?A (insert ?A1.0 ?H) ⊢ ?B; insert ?Ba (insert ?A1.0 ?H) ⊢ ?B⟧ ⟹ insert ?A1.0 (insert (?A OR ?Ba) ?H) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 ?H)) ⊢ ?B; insert ?Ba (insert ?A1.0 (insert ?A2.0 ?H)) ⊢ ?B⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert (?A OR ?Ba) ?H)) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 ?H))) ⊢ ?B; insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 ?H))) ⊢ ?B⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert (?A OR ?Ba) ?H))) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 ?H)))) ⊢ ?B; insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 ?H)))) ⊢ ?B⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert (?A OR ?Ba) ?H)))) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 ?H))))) ⊢ ?B; insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 ?H))))) ⊢ ?B⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert (?A OR ?Ba) ?H))))) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 ?H)))))) ⊢ ?B; insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 ?H)))))) ⊢ ?B⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert (?A OR ?Ba) ?H)))))) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 ?H))))))) ⊢ ?B; insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 ?H))))))) ⊢ ?B⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 (insert (?A OR ?Ba) ?H))))))) ⊢ ?B› ‹⟦insert ?A (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)))))))) ⊢ ?B; insert ?Ba (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)))))))) ⊢ ?B⟧ ⟹ 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 (?A OR ?Ba) ?H)))))))) ⊢ ?B› ‹⟦insert ?A (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))))))))) ⊢ ?B; insert ?Ba (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))))))))) ⊢ ?B⟧ ⟹ 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 (?A OR ?Ba) ?H))))))))) ⊢ ?B›*) Ex_EH (*‹⟦insert ?A ?H ⊢ ?B; atom ?i ♯ ?B; ∀C∈?H. atom ?i ♯ C⟧ ⟹ insert (SyntaxN.Ex ?i ?A) ?H ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 ?H) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 ?H. atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert (SyntaxN.Ex ?i ?A) ?H) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 ?H)) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 ?H). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert (SyntaxN.Ex ?i ?A) ?H)) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 ?H))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 ?H)). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert (SyntaxN.Ex ?i ?A) ?H))) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 ?H)))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 ?H))). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert (SyntaxN.Ex ?i ?A) ?H)))) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 ?H))))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 ?H)))). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert (SyntaxN.Ex ?i ?A) ?H))))) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 ?H)))))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 ?H))))). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert (SyntaxN.Ex ?i ?A) ?H)))))) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 ?H))))))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 ?H)))))). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 (insert (SyntaxN.Ex ?i ?A) ?H))))))) ⊢ ?B› ‹⟦insert ?A (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)))))))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈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))))))). atom ?i ♯ C⟧ ⟹ 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 (SyntaxN.Ex ?i ?A) ?H)))))))) ⊢ ?B› ‹⟦insert ?A (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))))))))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈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)))))))). atom ?i ♯ C⟧ ⟹ 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 (SyntaxN.Ex ?i ?A) ?H))))))))) ⊢ ?B›*))+) (*goal: ‹⟦atom i ♯ (s, s', v, a, x, y, y'); atom j ♯ (s, s', v, a, x, i, x, y, y'); atom j' ♯ (s, s', v, a, x, i, j, x, y, y'); atom k ♯ (s, s', v, a, x, y, y', kk', i, j, j'); atom k' ♯ (s, s', v, a, x, y, y', k, i, j, j'); atom l ♯ (s, s', v, a, x, i, j, j', k, k'); atom m ♯ (s, s', v, a, i, j, j', k, k', l); atom n ♯ (s, s', v, a, i, j, j', k, k', l, m); atom sm ♯ (s, s', v, a, i, j, j', k, k', l, m, n); atom sn ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm); atom sm' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn); atom sn' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm'); atom m2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn'); atom n2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2); atom sm2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2); atom sn2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2); atom sm2' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2, sn2); atom sn2' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2, sn2, sm2')⟧ ⟹ {SyntaxN.Ex m2 (SyntaxN.Ex n2 (SyntaxN.Ex sm2 (SyntaxN.Ex sm2' (SyntaxN.Ex sn2 (SyntaxN.Ex sn2' (Var m2 IN Var k' AND Var n2 IN Var k' AND SeqSubstFormP v a (Var sm2) (Var sm2') s' (Var m2) AND SeqSubstFormP v a (Var sn2) (Var sn2') s' (Var n2) AND (Var i EQ Q_Disj (Var sm2) (Var sn2) AND Var j' EQ Q_Disj (Var sm2') (Var sn2') OR Var i EQ Q_Neg (Var sm2) AND Var j' EQ Q_Neg (Var sm2') OR Var i EQ Q_Ex (Var sm2) AND Var j' EQ Q_Ex (Var sm2')))))))), SubstAtomicP v a (Var i) (Var j) OR SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN Var k AND Var n IN Var k AND SeqSubstFormP v a (Var sm) (Var sm') s (Var m) AND SeqSubstFormP v a (Var sn) (Var sn') s (Var n) AND (Var i EQ Q_Disj (Var sm) (Var sn) AND Var j EQ Q_Disj (Var sm') (Var sn') OR Var i EQ Q_Neg (Var sm) AND Var j EQ Q_Neg (Var sm') OR Var i EQ Q_Ex (Var sm) AND Var j EQ Q_Ex (Var sm')))))))), All2 l (Var k) (SyntaxN.All i (SyntaxN.All j (SyntaxN.All j' (SyntaxN.All k' (SeqSubstFormP v a (Var i) (Var j) s (Var l) IMP SeqSubstFormP v a (Var i) (Var j') s' (Var k') IMP Var j' EQ Var j))))), SeqSubstFormP v a (Var i) (Var j') s' (Var k'), SeqSubstFormP v a (Var i) (Var j) s (Var k), OrdP (Var k)} ⊢ Var j' EQ Var j›*) apply simp_all (*top goal: ‹⟦atom i ♯ (s, s', v, a, x, y, y'); atom j ♯ (s, s', v, a, x, i, x, y, y'); atom j' ♯ (s, s', v, a, x, i, j, x, y, y'); atom k ♯ (s, s', v, a, x, y, y', kk', i, j, j'); atom k' ♯ (s, s', v, a, x, y, y', k, i, j, j'); atom l ♯ (s, s', v, a, x, i, j, j', k, k'); atom m ♯ (s, s', v, a, i, j, j', k, k', l); atom n ♯ (s, s', v, a, i, j, j', k, k', l, m); atom sm ♯ (s, s', v, a, i, j, j', k, k', l, m, n); atom sn ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm); atom sm' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn); atom sn' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm'); atom m2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn'); atom n2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2); atom sm2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2); atom sn2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2); atom sm2' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2, sn2); atom sn2' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2, sn2, sm2')⟧ ⟹ {Var i EQ Q_Disj (Var sm2) (Var sn2), Var j' EQ Q_Disj (Var sm2') (Var sn2'), SeqSubstFormP v a (Var sn2) (Var sn2') s' (Var n2), SeqSubstFormP v a (Var sm2) (Var sm2') s' (Var m2), Var n2 IN Var k', Var m2 IN Var k', SubstAtomicP v a (Var i) (Var j), All2 l (Var k) (SyntaxN.All i (SyntaxN.All j (SyntaxN.All j' (SyntaxN.All k' (SeqSubstFormP v a (Var i) (Var j) s (Var l) IMP SeqSubstFormP v a (Var i) (Var j') s' (Var k') IMP Var j' EQ Var j))))), SeqSubstFormP v a (Var i) (Var j') s' (Var k'), SeqSubstFormP v a (Var i) (Var j) s (Var k), OrdP (Var k)} ⊢ Var j' EQ Var j› and 14 goals remain*) apply (metis Assume (*‹insert (?A::fm) (?H::fm set) ⊢ ?A›*) AssumeH( (*‹insert (?A1.0::fm) (insert (?A2.0::fm) (insert (?A3.0::fm) (insert (?A4.0::fm) (insert (?A5.0::fm) (insert (?A6.0::fm) (insert (?A7.0::fm) (?H::fm set))))))) ⊢ ?A7.0›*) 7) Disj_I1 (*‹(?H::fm set) ⊢ (?A::fm) ⟹ ?H ⊢ ?A OR (?B::fm)›*) Neg_I (*‹insert (?A::fm) (?H::fm set) ⊢ Fls ⟹ ?H ⊢ Neg ?A›*) anti_deduction (*‹(?H::fm set) ⊢ (?A::fm) IMP (?B::fm) ⟹ insert ?A ?H ⊢ ?B›*) cut2 [OF Disj_SubstAtomicP_Fls] (*‹⟦(?H::fm set) ⊢ (?y1::tm) EQ Q_Disj (?z1::tm) (?w1::tm); ?H ⊢ SubstAtomicP (?v1::tm) (?tm1::tm) ?y1 (?y'1::tm)⟧ ⟹ ?H ⊢ Fls›*)) (*top goal: ‹⟦atom i ♯ (s, s', v, a, x, y, y'); atom j ♯ (s, s', v, a, x, i, x, y, y'); atom j' ♯ (s, s', v, a, x, i, j, x, y, y'); atom k ♯ (s, s', v, a, x, y, y', kk', i, j, j'); atom k' ♯ (s, s', v, a, x, y, y', k, i, j, j'); atom l ♯ (s, s', v, a, x, i, j, j', k, k'); atom m ♯ (s, s', v, a, i, j, j', k, k', l); atom n ♯ (s, s', v, a, i, j, j', k, k', l, m); atom sm ♯ (s, s', v, a, i, j, j', k, k', l, m, n); atom sn ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm); atom sm' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn); atom sn' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm'); atom m2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn'); atom n2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2); atom sm2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2); atom sn2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2); atom sm2' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2, sn2); atom sn2' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2, sn2, sm2')⟧ ⟹ {Var i EQ Q_Disj (Var sm2) (Var sn2), Var j' EQ Q_Disj (Var sm2') (Var sn2'), SeqSubstFormP v a (Var sn2) (Var sn2') s' (Var n2), SeqSubstFormP v a (Var sm2) (Var sm2') s' (Var m2), Var n2 IN Var k', Var m2 IN Var k', SubstAtomicP v a (Var i) (Var j), All2 l (Var k) (SyntaxN.All i (SyntaxN.All j (SyntaxN.All j' (SyntaxN.All k' (SeqSubstFormP v a (Var i) (Var j) s (Var l) IMP SeqSubstFormP v a (Var i) (Var j') s' (Var k') IMP Var j' EQ Var j))))), SeqSubstFormP v a (Var i) (Var j') s' (Var k'), SeqSubstFormP v a (Var i) (Var j) s (Var k), OrdP (Var k)} ⊢ Var j' EQ Var j› and 2 goals remain*) apply ((rule Conj_EH (*‹insert (?A::fm) (insert (?B::fm) (?H::fm set)) ⊢ (?C::fm) ⟹ insert (?A AND ?B) ?H ⊢ ?C› ‹insert (?A::fm) (insert (?Ba::fm) (insert (?A1.0::fm) (?H::fm set))) ⊢ (?B::fm) ⟹ insert ?A1.0 (insert (?A AND ?Ba) ?H) ⊢ ?B› ‹insert (?A::fm) (insert (?Ba::fm) (insert (?A1.0::fm) (insert (?A2.0::fm) (?H::fm set)))) ⊢ (?B::fm) ⟹ insert ?A1.0 (insert ?A2.0 (insert (?A AND ?Ba) ?H)) ⊢ ?B› ‹insert (?A::fm) (insert (?Ba::fm) (insert (?A1.0::fm) (insert (?A2.0::fm) (insert (?A3.0::fm) (?H::fm set))))) ⊢ (?B::fm) ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert (?A AND ?Ba) ?H))) ⊢ ?B› ‹insert (?A::fm) (insert (?Ba::fm) (insert (?A1.0::fm) (insert (?A2.0::fm) (insert (?A3.0::fm) (insert (?A4.0::fm) (?H::fm set)))))) ⊢ (?B::fm) ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert (?A AND ?Ba) ?H)))) ⊢ ?B› ‹insert (?A::fm) (insert (?Ba::fm) (insert (?A1.0::fm) (insert (?A2.0::fm) (insert (?A3.0::fm) (insert (?A4.0::fm) (insert (?A5.0::fm) (?H::fm set))))))) ⊢ (?B::fm) ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert (?A AND ?Ba) ?H))))) ⊢ ?B› ‹insert (?A::fm) (insert (?Ba::fm) (insert (?A1.0::fm) (insert (?A2.0::fm) (insert (?A3.0::fm) (insert (?A4.0::fm) (insert (?A5.0::fm) (insert (?A6.0::fm) (?H::fm set)))))))) ⊢ (?B::fm) ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert (?A AND ?Ba) ?H)))))) ⊢ ?B› ‹insert (?A::fm) (insert (?Ba::fm) (insert (?A1.0::fm) (insert (?A2.0::fm) (insert (?A3.0::fm) (insert (?A4.0::fm) (insert (?A5.0::fm) (insert (?A6.0::fm) (insert (?A7.0::fm) (?H::fm set))))))))) ⊢ (?B::fm) ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 (insert (?A AND ?Ba) ?H))))))) ⊢ ?B› ‹insert (?A::fm) (insert (?Ba::fm) (insert (?A1.0::fm) (insert (?A2.0::fm) (insert (?A3.0::fm) (insert (?A4.0::fm) (insert (?A5.0::fm) (insert (?A6.0::fm) (insert (?A7.0::fm) (insert (?A8.0::fm) (?H::fm set)))))))))) ⊢ (?B::fm) ⟹ 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 (?A AND ?Ba) ?H)))))))) ⊢ ?B› ‹insert (?A::fm) (insert (?Ba::fm) (insert (?A1.0::fm) (insert (?A2.0::fm) (insert (?A3.0::fm) (insert (?A4.0::fm) (insert (?A5.0::fm) (insert (?A6.0::fm) (insert (?A7.0::fm) (insert (?A8.0::fm) (insert (?A9.0::fm) (?H::fm set))))))))))) ⊢ (?B::fm) ⟹ 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 (?A AND ?Ba) ?H))))))))) ⊢ ?B›*) Disj_EH (*‹⟦insert (?A::fm) (?H::fm set) ⊢ (?C::fm); insert (?B::fm) ?H ⊢ ?C⟧ ⟹ insert (?A OR ?B) ?H ⊢ ?C› ‹⟦insert (?A::fm) (insert (?A1.0::fm) (?H::fm set)) ⊢ (?B::fm); insert (?Ba::fm) (insert ?A1.0 ?H) ⊢ ?B⟧ ⟹ insert ?A1.0 (insert (?A OR ?Ba) ?H) ⊢ ?B› ‹⟦insert (?A::fm) (insert (?A1.0::fm) (insert (?A2.0::fm) (?H::fm set))) ⊢ (?B::fm); insert (?Ba::fm) (insert ?A1.0 (insert ?A2.0 ?H)) ⊢ ?B⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert (?A OR ?Ba) ?H)) ⊢ ?B› ‹⟦insert (?A::fm) (insert (?A1.0::fm) (insert (?A2.0::fm) (insert (?A3.0::fm) (?H::fm set)))) ⊢ (?B::fm); insert (?Ba::fm) (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 ?H))) ⊢ ?B⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert (?A OR ?Ba) ?H))) ⊢ ?B› ‹⟦insert (?A::fm) (insert (?A1.0::fm) (insert (?A2.0::fm) (insert (?A3.0::fm) (insert (?A4.0::fm) (?H::fm set))))) ⊢ (?B::fm); insert (?Ba::fm) (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 ?H)))) ⊢ ?B⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert (?A OR ?Ba) ?H)))) ⊢ ?B› ‹⟦insert (?A::fm) (insert (?A1.0::fm) (insert (?A2.0::fm) (insert (?A3.0::fm) (insert (?A4.0::fm) (insert (?A5.0::fm) (?H::fm set)))))) ⊢ (?B::fm); insert (?Ba::fm) (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 ?H))))) ⊢ ?B⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert (?A OR ?Ba) ?H))))) ⊢ ?B› ‹⟦insert (?A::fm) (insert (?A1.0::fm) (insert (?A2.0::fm) (insert (?A3.0::fm) (insert (?A4.0::fm) (insert (?A5.0::fm) (insert (?A6.0::fm) (?H::fm set))))))) ⊢ (?B::fm); insert (?Ba::fm) (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 ?H)))))) ⊢ ?B⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert (?A OR ?Ba) ?H)))))) ⊢ ?B› ‹⟦insert (?A::fm) (insert (?A1.0::fm) (insert (?A2.0::fm) (insert (?A3.0::fm) (insert (?A4.0::fm) (insert (?A5.0::fm) (insert (?A6.0::fm) (insert (?A7.0::fm) (?H::fm set)))))))) ⊢ (?B::fm); insert (?Ba::fm) (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 ?H))))))) ⊢ ?B⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 (insert (?A OR ?Ba) ?H))))))) ⊢ ?B› ‹⟦insert (?A::fm) (insert (?A1.0::fm) (insert (?A2.0::fm) (insert (?A3.0::fm) (insert (?A4.0::fm) (insert (?A5.0::fm) (insert (?A6.0::fm) (insert (?A7.0::fm) (insert (?A8.0::fm) (?H::fm set))))))))) ⊢ (?B::fm); insert (?Ba::fm) (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)))))))) ⊢ ?B⟧ ⟹ 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 (?A OR ?Ba) ?H)))))))) ⊢ ?B› ‹⟦insert (?A::fm) (insert (?A1.0::fm) (insert (?A2.0::fm) (insert (?A3.0::fm) (insert (?A4.0::fm) (insert (?A5.0::fm) (insert (?A6.0::fm) (insert (?A7.0::fm) (insert (?A8.0::fm) (insert (?A9.0::fm) (?H::fm set)))))))))) ⊢ (?B::fm); insert (?Ba::fm) (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))))))))) ⊢ ?B⟧ ⟹ 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 (?A OR ?Ba) ?H))))))))) ⊢ ?B›*))+) (*top goal: ‹⟦atom i ♯ (s, s', v, a, x, y, y'); atom j ♯ (s, s', v, a, x, i, x, y, y'); atom j' ♯ (s, s', v, a, x, i, j, x, y, y'); atom k ♯ (s, s', v, a, x, y, y', kk', i, j, j'); atom k' ♯ (s, s', v, a, x, y, y', k, i, j, j'); atom l ♯ (s, s', v, a, x, i, j, j', k, k'); atom m ♯ (s, s', v, a, i, j, j', k, k', l); atom n ♯ (s, s', v, a, i, j, j', k, k', l, m); atom sm ♯ (s, s', v, a, i, j, j', k, k', l, m, n); atom sn ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm); atom sm' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn); atom sn' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm'); atom m2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn'); atom n2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2); atom sm2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2); atom sn2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2); atom sm2' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2, sn2); atom sn2' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2, sn2, sm2')⟧ ⟹ {Var i EQ Q_Neg (Var sm2) AND Var j' EQ Q_Neg (Var sm2') OR Var i EQ Q_Ex (Var sm2) AND Var j' EQ Q_Ex (Var sm2'), SeqSubstFormP v a (Var sn2) (Var sn2') s' (Var n2), SeqSubstFormP v a (Var sm2) (Var sm2') s' (Var m2), Var n2 IN Var k', Var m2 IN Var k', SubstAtomicP v a (Var i) (Var j), All2 l (Var k) (SyntaxN.All i (SyntaxN.All j (SyntaxN.All j' (SyntaxN.All k' (SeqSubstFormP v a (Var i) (Var j) s (Var l) IMP SeqSubstFormP v a (Var i) (Var j') s' (Var k') IMP Var j' EQ Var j))))), SeqSubstFormP v a (Var i) (Var j') s' (Var k'), SeqSubstFormP v a (Var i) (Var j) s (Var k), OrdP (Var k)} ⊢ Var j' EQ Var j› and 1 goal remains*) apply (metis Assume (*‹insert ?A ?H ⊢ ?A›*) AssumeH( (*‹insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 ?H)))))) ⊢ ?A7.0›*) 7) Disj_I1 (*‹?H ⊢ ?A ⟹ ?H ⊢ ?A OR ?B›*) Neg_I (*‹insert ?A ?H ⊢ Fls ⟹ ?H ⊢ Neg ?A›*) anti_deduction (*‹?H ⊢ ?A IMP ?B ⟹ insert ?A ?H ⊢ ?B›*) cut2 [OF Neg_SubstAtomicP_Fls] (*‹⟦?H ⊢ ?y1 EQ Q_Neg ?z1; ?H ⊢ SubstAtomicP ?v1 ?tm1 ?y1 ?y'1⟧ ⟹ ?H ⊢ Fls›*)) (*top goal: ‹⟦atom (i::name) ♯ (s::tm, s'::tm, v::tm, a::tm, x::tm, y::tm, y'::tm); atom (j::name) ♯ (s, s', v, a, x, i, x, y, y'); atom (j'::name) ♯ (s, s', v, a, x, i, j, x, y, y'); atom (k::name) ♯ (s, s', v, a, x, y, y', kk'::tm, i, j, j'); atom (k'::name) ♯ (s, s', v, a, x, y, y', k, i, j, j'); atom (l::name) ♯ (s, s', v, a, x, i, j, j', k, k'); atom (m::name) ♯ (s, s', v, a, i, j, j', k, k', l); atom (n::name) ♯ (s, s', v, a, i, j, j', k, k', l, m); atom (sm::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n); atom (sn::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm); atom (sm'::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn); atom (sn'::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm'); atom (m2::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn'); atom (n2::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2); atom (sm2::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2); atom (sn2::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2); atom (sm2'::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2, sn2); atom (sn2'::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2, sn2, sm2')⟧ ⟹ {Var i EQ Q_Neg (Var sm2), Var j' EQ Q_Neg (Var sm2'), SeqSubstFormP v a (Var sn2) (Var sn2') s' (Var n2), SeqSubstFormP v a (Var sm2) (Var sm2') s' (Var m2), Var n2 IN Var k', Var m2 IN Var k', SubstAtomicP v a (Var i) (Var j), All2 l (Var k) (SyntaxN.All i (SyntaxN.All j (SyntaxN.All j' (SyntaxN.All k' (SeqSubstFormP v a (Var i) (Var j) s (Var l) IMP SeqSubstFormP v a (Var i) (Var j') s' (Var k') IMP Var j' EQ Var j))))), SeqSubstFormP v a (Var i) (Var j') s' (Var k'), SeqSubstFormP v a (Var i) (Var j) s (Var k), OrdP (Var k)} ⊢ Var j' EQ Var j› and 2 goals remain*) apply ((rule Conj_EH (*‹insert (?A::fm) (insert (?B::fm) (?H::fm set)) ⊢ (?C::fm) ⟹ insert (?A AND ?B) ?H ⊢ ?C› ‹insert (?A::fm) (insert (?Ba::fm) (insert (?A1.0::fm) (?H::fm set))) ⊢ (?B::fm) ⟹ insert ?A1.0 (insert (?A AND ?Ba) ?H) ⊢ ?B› ‹insert (?A::fm) (insert (?Ba::fm) (insert (?A1.0::fm) (insert (?A2.0::fm) (?H::fm set)))) ⊢ (?B::fm) ⟹ insert ?A1.0 (insert ?A2.0 (insert (?A AND ?Ba) ?H)) ⊢ ?B› ‹insert (?A::fm) (insert (?Ba::fm) (insert (?A1.0::fm) (insert (?A2.0::fm) (insert (?A3.0::fm) (?H::fm set))))) ⊢ (?B::fm) ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert (?A AND ?Ba) ?H))) ⊢ ?B› ‹insert (?A::fm) (insert (?Ba::fm) (insert (?A1.0::fm) (insert (?A2.0::fm) (insert (?A3.0::fm) (insert (?A4.0::fm) (?H::fm set)))))) ⊢ (?B::fm) ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert (?A AND ?Ba) ?H)))) ⊢ ?B› ‹insert (?A::fm) (insert (?Ba::fm) (insert (?A1.0::fm) (insert (?A2.0::fm) (insert (?A3.0::fm) (insert (?A4.0::fm) (insert (?A5.0::fm) (?H::fm set))))))) ⊢ (?B::fm) ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert (?A AND ?Ba) ?H))))) ⊢ ?B› ‹insert (?A::fm) (insert (?Ba::fm) (insert (?A1.0::fm) (insert (?A2.0::fm) (insert (?A3.0::fm) (insert (?A4.0::fm) (insert (?A5.0::fm) (insert (?A6.0::fm) (?H::fm set)))))))) ⊢ (?B::fm) ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert (?A AND ?Ba) ?H)))))) ⊢ ?B› ‹insert (?A::fm) (insert (?Ba::fm) (insert (?A1.0::fm) (insert (?A2.0::fm) (insert (?A3.0::fm) (insert (?A4.0::fm) (insert (?A5.0::fm) (insert (?A6.0::fm) (insert (?A7.0::fm) (?H::fm set))))))))) ⊢ (?B::fm) ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 (insert (?A AND ?Ba) ?H))))))) ⊢ ?B› ‹insert (?A::fm) (insert (?Ba::fm) (insert (?A1.0::fm) (insert (?A2.0::fm) (insert (?A3.0::fm) (insert (?A4.0::fm) (insert (?A5.0::fm) (insert (?A6.0::fm) (insert (?A7.0::fm) (insert (?A8.0::fm) (?H::fm set)))))))))) ⊢ (?B::fm) ⟹ 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 (?A AND ?Ba) ?H)))))))) ⊢ ?B› ‹insert (?A::fm) (insert (?Ba::fm) (insert (?A1.0::fm) (insert (?A2.0::fm) (insert (?A3.0::fm) (insert (?A4.0::fm) (insert (?A5.0::fm) (insert (?A6.0::fm) (insert (?A7.0::fm) (insert (?A8.0::fm) (insert (?A9.0::fm) (?H::fm set))))))))))) ⊢ (?B::fm) ⟹ 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 (?A AND ?Ba) ?H))))))))) ⊢ ?B›*))+) (*top goal: ‹⟦atom i ♯ (s, s', v, a, x, y, y'); atom j ♯ (s, s', v, a, x, i, x, y, y'); atom j' ♯ (s, s', v, a, x, i, j, x, y, y'); atom k ♯ (s, s', v, a, x, y, y', kk', i, j, j'); atom k' ♯ (s, s', v, a, x, y, y', k, i, j, j'); atom l ♯ (s, s', v, a, x, i, j, j', k, k'); atom m ♯ (s, s', v, a, i, j, j', k, k', l); atom n ♯ (s, s', v, a, i, j, j', k, k', l, m); atom sm ♯ (s, s', v, a, i, j, j', k, k', l, m, n); atom sn ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm); atom sm' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn); atom sn' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm'); atom m2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn'); atom n2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2); atom sm2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2); atom sn2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2); atom sm2' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2, sn2); atom sn2' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2, sn2, sm2')⟧ ⟹ {Var i EQ Q_Ex (Var sm2) AND Var j' EQ Q_Ex (Var sm2'), SeqSubstFormP v a (Var sn2) (Var sn2') s' (Var n2), SeqSubstFormP v a (Var sm2) (Var sm2') s' (Var m2), Var n2 IN Var k', Var m2 IN Var k', SubstAtomicP v a (Var i) (Var j), All2 l (Var k) (SyntaxN.All i (SyntaxN.All j (SyntaxN.All j' (SyntaxN.All k' (SeqSubstFormP v a (Var i) (Var j) s (Var l) IMP SeqSubstFormP v a (Var i) (Var j') s' (Var k') IMP Var j' EQ Var j))))), SeqSubstFormP v a (Var i) (Var j') s' (Var k'), SeqSubstFormP v a (Var i) (Var j) s (Var k), OrdP (Var k)} ⊢ Var j' EQ Var j› and 1 goal remains*) apply (metis Assume (*‹insert ?A ?H ⊢ ?A›*) AssumeH( (*‹insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 ?H)))))) ⊢ ?A7.0›*) 7) Disj_I1 (*‹?H ⊢ ?A ⟹ ?H ⊢ ?A OR ?B›*) Neg_I (*‹insert ?A ?H ⊢ Fls ⟹ ?H ⊢ Neg ?A›*) anti_deduction (*‹?H ⊢ ?A IMP ?B ⟹ insert ?A ?H ⊢ ?B›*) cut2 [OF Ex_SubstAtomicP_Fls] (*‹⟦?H ⊢ ?y1 EQ Q_Ex ?z1; ?H ⊢ SubstAtomicP ?v1 ?tm1 ?y1 ?y'1⟧ ⟹ ?H ⊢ Fls›*)) (*top goal: ‹⟦atom i ♯ (s, s', v, a, x, y, y'); atom j ♯ (s, s', v, a, x, i, x, y, y'); atom j' ♯ (s, s', v, a, x, i, j, x, y, y'); atom k ♯ (s, s', v, a, x, y, y', kk', i, j, j'); atom k' ♯ (s, s', v, a, x, y, y', k, i, j, j'); atom l ♯ (s, s', v, a, x, i, j, j', k, k'); atom m ♯ (s, s', v, a, i, j, j', k, k', l); atom n ♯ (s, s', v, a, i, j, j', k, k', l, m); atom sm ♯ (s, s', v, a, i, j, j', k, k', l, m, n); atom sn ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm); atom sm' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn); atom sn' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm'); atom m2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn'); atom n2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2); atom sm2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2); atom sn2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2); atom sm2' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2, sn2); atom sn2' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2, sn2, sm2')⟧ ⟹ {Var i EQ Q_Ex (Var sm2), Var j' EQ Q_Ex (Var sm2'), SeqSubstFormP v a (Var sn2) (Var sn2') s' (Var n2), SeqSubstFormP v a (Var sm2) (Var sm2') s' (Var m2), Var n2 IN Var k', Var m2 IN Var k', SubstAtomicP v a (Var i) (Var j), All2 l (Var k) (SyntaxN.All i (SyntaxN.All j (SyntaxN.All j' (SyntaxN.All k' (SeqSubstFormP v a (Var i) (Var j) s (Var l) IMP SeqSubstFormP v a (Var i) (Var j') s' (Var k') IMP Var j' EQ Var j))))), SeqSubstFormP v a (Var i) (Var j') s' (Var k'), SeqSubstFormP v a (Var i) (Var j) s (Var k), OrdP (Var k)} ⊢ Var j' EQ Var j› and 1 goal remains*) apply ((rule Conj_EH (*‹insert ?A (insert ?B ?H) ⊢ ?C ⟹ insert (?A AND ?B) ?H ⊢ ?C› ‹insert ?A (insert ?Ba (insert ?A1.0 ?H)) ⊢ ?B ⟹ insert ?A1.0 (insert (?A AND ?Ba) ?H) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 ?H))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert (?A AND ?Ba) ?H)) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 ?H)))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert (?A AND ?Ba) ?H))) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 ?H))))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert (?A AND ?Ba) ?H)))) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 ?H)))))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert (?A AND ?Ba) ?H))))) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 ?H))))))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert (?A AND ?Ba) ?H)))))) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 ?H)))))))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 (insert (?A AND ?Ba) ?H))))))) ⊢ ?B› ‹insert ?A (insert ?Ba (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))))))))) ⊢ ?B ⟹ 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 (?A AND ?Ba) ?H)))))))) ⊢ ?B› ‹insert ?A (insert ?Ba (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)))))))))) ⊢ ?B ⟹ 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 (?A AND ?Ba) ?H))))))))) ⊢ ?B›*) Disj_EH (*‹⟦insert ?A ?H ⊢ ?C; insert ?B ?H ⊢ ?C⟧ ⟹ insert (?A OR ?B) ?H ⊢ ?C› ‹⟦insert ?A (insert ?A1.0 ?H) ⊢ ?B; insert ?Ba (insert ?A1.0 ?H) ⊢ ?B⟧ ⟹ insert ?A1.0 (insert (?A OR ?Ba) ?H) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 ?H)) ⊢ ?B; insert ?Ba (insert ?A1.0 (insert ?A2.0 ?H)) ⊢ ?B⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert (?A OR ?Ba) ?H)) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 ?H))) ⊢ ?B; insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 ?H))) ⊢ ?B⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert (?A OR ?Ba) ?H))) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 ?H)))) ⊢ ?B; insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 ?H)))) ⊢ ?B⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert (?A OR ?Ba) ?H)))) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 ?H))))) ⊢ ?B; insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 ?H))))) ⊢ ?B⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert (?A OR ?Ba) ?H))))) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 ?H)))))) ⊢ ?B; insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 ?H)))))) ⊢ ?B⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert (?A OR ?Ba) ?H)))))) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 ?H))))))) ⊢ ?B; insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 ?H))))))) ⊢ ?B⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 (insert (?A OR ?Ba) ?H))))))) ⊢ ?B› ‹⟦insert ?A (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)))))))) ⊢ ?B; insert ?Ba (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)))))))) ⊢ ?B⟧ ⟹ 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 (?A OR ?Ba) ?H)))))))) ⊢ ?B› ‹⟦insert ?A (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))))))))) ⊢ ?B; insert ?Ba (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))))))))) ⊢ ?B⟧ ⟹ 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 (?A OR ?Ba) ?H))))))))) ⊢ ?B›*) Ex_EH (*‹⟦insert ?A ?H ⊢ ?B; atom ?i ♯ ?B; ∀C∈?H. atom ?i ♯ C⟧ ⟹ insert (SyntaxN.Ex ?i ?A) ?H ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 ?H) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 ?H. atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert (SyntaxN.Ex ?i ?A) ?H) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 ?H)) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 ?H). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert (SyntaxN.Ex ?i ?A) ?H)) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 ?H))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 ?H)). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert (SyntaxN.Ex ?i ?A) ?H))) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 ?H)))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 ?H))). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert (SyntaxN.Ex ?i ?A) ?H)))) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 ?H))))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 ?H)))). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert (SyntaxN.Ex ?i ?A) ?H))))) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 ?H)))))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 ?H))))). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert (SyntaxN.Ex ?i ?A) ?H)))))) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 ?H))))))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 ?H)))))). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 (insert (SyntaxN.Ex ?i ?A) ?H))))))) ⊢ ?B› ‹⟦insert ?A (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)))))))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈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))))))). atom ?i ♯ C⟧ ⟹ 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 (SyntaxN.Ex ?i ?A) ?H)))))))) ⊢ ?B› ‹⟦insert ?A (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))))))))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈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)))))))). atom ?i ♯ C⟧ ⟹ 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 (SyntaxN.Ex ?i ?A) ?H))))))))) ⊢ ?B›*))+) (*goal: ‹⟦atom i ♯ (s, s', v, a, x, y, y'); atom j ♯ (s, s', v, a, x, i, x, y, y'); atom j' ♯ (s, s', v, a, x, i, j, x, y, y'); atom k ♯ (s, s', v, a, x, y, y', kk', i, j, j'); atom k' ♯ (s, s', v, a, x, y, y', k, i, j, j'); atom l ♯ (s, s', v, a, x, i, j, j', k, k'); atom m ♯ (s, s', v, a, i, j, j', k, k', l); atom n ♯ (s, s', v, a, i, j, j', k, k', l, m); atom sm ♯ (s, s', v, a, i, j, j', k, k', l, m, n); atom sn ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm); atom sm' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn); atom sn' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm'); atom m2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn'); atom n2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2); atom sm2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2); atom sn2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2); atom sm2' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2, sn2); atom sn2' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2, sn2, sm2')⟧ ⟹ {SyntaxN.Ex m (SyntaxN.Ex n (SyntaxN.Ex sm (SyntaxN.Ex sm' (SyntaxN.Ex sn (SyntaxN.Ex sn' (Var m IN Var k AND Var n IN Var k AND SeqSubstFormP v a (Var sm) (Var sm') s (Var m) AND SeqSubstFormP v a (Var sn) (Var sn') s (Var n) AND (Var i EQ Q_Disj (Var sm) (Var sn) AND Var j EQ Q_Disj (Var sm') (Var sn') OR Var i EQ Q_Neg (Var sm) AND Var j EQ Q_Neg (Var sm') OR Var i EQ Q_Ex (Var sm) AND Var j EQ Q_Ex (Var sm')))))))), SyntaxN.Ex m2 (SyntaxN.Ex n2 (SyntaxN.Ex sm2 (SyntaxN.Ex sm2' (SyntaxN.Ex sn2 (SyntaxN.Ex sn2' (Var m2 IN Var k' AND Var n2 IN Var k' AND SeqSubstFormP v a (Var sm2) (Var sm2') s' (Var m2) AND SeqSubstFormP v a (Var sn2) (Var sn2') s' (Var n2) AND (Var i EQ Q_Disj (Var sm2) (Var sn2) AND Var j' EQ Q_Disj (Var sm2') (Var sn2') OR Var i EQ Q_Neg (Var sm2) AND Var j' EQ Q_Neg (Var sm2') OR Var i EQ Q_Ex (Var sm2) AND Var j' EQ Q_Ex (Var sm2')))))))), All2 l (Var k) (SyntaxN.All i (SyntaxN.All j (SyntaxN.All j' (SyntaxN.All k' (SeqSubstFormP v a (Var i) (Var j) s (Var l) IMP SeqSubstFormP v a (Var i) (Var j') s' (Var k') IMP Var j' EQ Var j))))), SeqSubstFormP v a (Var i) (Var j') s' (Var k'), SeqSubstFormP v a (Var i) (Var j) s (Var k), OrdP (Var k)} ⊢ Var j' EQ Var j›*) apply simp_all (*top goal: ‹⟦atom i ♯ (s, s', v, a, x, y, y'); atom j ♯ (s, s', v, a, x, i, x, y, y'); atom j' ♯ (s, s', v, a, x, i, j, x, y, y'); atom k ♯ (s, s', v, a, x, y, y', kk', i, j, j'); atom k' ♯ (s, s', v, a, x, y, y', k, i, j, j'); atom l ♯ (s, s', v, a, x, i, j, j', k, k'); atom m ♯ (s, s', v, a, i, j, j', k, k', l); atom n ♯ (s, s', v, a, i, j, j', k, k', l, m); atom sm ♯ (s, s', v, a, i, j, j', k, k', l, m, n); atom sn ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm); atom sm' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn); atom sn' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm'); atom m2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn'); atom n2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2); atom sm2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2); atom sn2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2); atom sm2' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2, sn2); atom sn2' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2, sn2, sm2')⟧ ⟹ {Var i EQ Q_Disj (Var sm2) (Var sn2), Var j' EQ Q_Disj (Var sm2') (Var sn2'), SeqSubstFormP v a (Var sn2) (Var sn2') s' (Var n2), SeqSubstFormP v a (Var sm2) (Var sm2') s' (Var m2), Var n2 IN Var k', Var m2 IN Var k', Var i EQ Q_Disj (Var sm) (Var sn), Var j EQ Q_Disj (Var sm') (Var sn'), SeqSubstFormP v a (Var sn) (Var sn') s (Var n), SeqSubstFormP v a (Var sm) (Var sm') s (Var m), Var n IN Var k, Var m IN Var k, All2 l (Var k) (SyntaxN.All i (SyntaxN.All j (SyntaxN.All j' (SyntaxN.All k' (SeqSubstFormP v a (Var i) (Var j) s (Var l) IMP SeqSubstFormP v a (Var i) (Var j') s' (Var k') IMP Var j' EQ Var j))))), SeqSubstFormP v a (Var i) (Var j') s' (Var k'), SeqSubstFormP v a (Var i) (Var j) s (Var k), OrdP (Var k)} ⊢ Var j' EQ Var j› and 26 goals remain*) apply (rule All_E' [OF Hyp, where x="Var m"] (*‹⟦SyntaxN.All (?i::name) (?A::fm) ∈ (?H::fm set); insert (?A(?i::=Var (m::name))) ?H ⊢ (?B::fm)⟧ ⟹ ?H ⊢ ?B›*), blast) (*top goal: ‹⟦atom i ♯ (s, s', v, a, x, y, y'); atom j ♯ (s, s', v, a, x, i, x, y, y'); atom j' ♯ (s, s', v, a, x, i, j, x, y, y'); atom k ♯ (s, s', v, a, x, y, y', kk', i, j, j'); atom k' ♯ (s, s', v, a, x, y, y', k, i, j, j'); atom l ♯ (s, s', v, a, x, i, j, j', k, k'); atom m ♯ (s, s', v, a, i, j, j', k, k', l); atom n ♯ (s, s', v, a, i, j, j', k, k', l, m); atom sm ♯ (s, s', v, a, i, j, j', k, k', l, m, n); atom sn ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm); atom sm' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn); atom sn' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm'); atom m2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn'); atom n2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2); atom sm2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2); atom sn2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2); atom sm2' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2, sn2); atom sn2' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2, sn2, sm2')⟧ ⟹ {Var i EQ Q_Disj (Var sm2) (Var sn2), Var j' EQ Q_Disj (Var sm2') (Var sn2'), SeqSubstFormP v a (Var sn2) (Var sn2') s' (Var n2), SeqSubstFormP v a (Var sm2) (Var sm2') s' (Var m2), Var n2 IN Var k', Var m2 IN Var k', Var i EQ Q_Disj (Var sm) (Var sn), Var j EQ Q_Disj (Var sm') (Var sn'), SeqSubstFormP v a (Var sn) (Var sn') s (Var n), SeqSubstFormP v a (Var sm) (Var sm') s (Var m), Var n IN Var k, Var m IN Var k, All2 l (Var k) (SyntaxN.All i (SyntaxN.All j (SyntaxN.All j' (SyntaxN.All k' (SeqSubstFormP v a (Var i) (Var j) s (Var l) IMP SeqSubstFormP v a (Var i) (Var j') s' (Var k') IMP Var j' EQ Var j))))), SeqSubstFormP v a (Var i) (Var j') s' (Var k'), SeqSubstFormP v a (Var i) (Var j) s (Var k), OrdP (Var k)} ⊢ Var j' EQ Var j› and 2 goals remain*) apply (rule All_E' [OF Hyp, where x="Var n"] (*‹⟦SyntaxN.All ?i ?A ∈ ?H; insert (?A(?i::=Var n)) ?H ⊢ ?B⟧ ⟹ ?H ⊢ ?B›*), blast, simp) (*top goal: ‹⟦atom (i::name) ♯ (s::tm, s'::tm, v::tm, a::tm, x::tm, y::tm, y'::tm); atom (j::name) ♯ (s, s', v, a, x, i, x, y, y'); atom (j'::name) ♯ (s, s', v, a, x, i, j, x, y, y'); atom (k::name) ♯ (s, s', v, a, x, y, y', kk'::tm, i, j, j'); atom (k'::name) ♯ (s, s', v, a, x, y, y', k, i, j, j'); atom (l::name) ♯ (s, s', v, a, x, i, j, j', k, k'); atom (m::name) ♯ (s, s', v, a, i, j, j', k, k', l); atom (n::name) ♯ (s, s', v, a, i, j, j', k, k', l, m); atom (sm::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n); atom (sn::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm); atom (sm'::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn); atom (sn'::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm'); atom (m2::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn'); atom (n2::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2); atom (sm2::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2); atom (sn2::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2); atom (sm2'::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2, sn2); atom (sn2'::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2, sn2, sm2')⟧ ⟹ {(Var l IN Var k IMP SyntaxN.All i (SyntaxN.All j (SyntaxN.All j' (SyntaxN.All k' (SeqSubstFormP v a (Var i) (Var j) s (Var l) IMP SeqSubstFormP v a (Var i) (Var j') s' (Var k') IMP Var j' EQ Var j)))))(l::=Var m), Var i EQ Q_Disj (Var sm2) (Var sn2), Var j' EQ Q_Disj (Var sm2') (Var sn2'), SeqSubstFormP v a (Var sn2) (Var sn2') s' (Var n2), SeqSubstFormP v a (Var sm2) (Var sm2') s' (Var m2), Var n2 IN Var k', Var m2 IN Var k', Var i EQ Q_Disj (Var sm) (Var sn), Var j EQ Q_Disj (Var sm') (Var sn'), SeqSubstFormP v a (Var sn) (Var sn') s (Var n), SeqSubstFormP v a (Var sm) (Var sm') s (Var m), Var n IN Var k, Var m IN Var k, All2 l (Var k) (SyntaxN.All i (SyntaxN.All j (SyntaxN.All j' (SyntaxN.All k' (SeqSubstFormP v a (Var i) (Var j) s (Var l) IMP SeqSubstFormP v a (Var i) (Var j') s' (Var k') IMP Var j' EQ Var j))))), SeqSubstFormP v a (Var i) (Var j') s' (Var k'), SeqSubstFormP v a (Var i) (Var j) s (Var k), OrdP (Var k)} ⊢ Var j' EQ Var j› and 2 goals remain*) apply ((rule Disj_EH (*‹⟦insert ?A ?H ⊢ ?C; insert ?B ?H ⊢ ?C⟧ ⟹ insert (?A OR ?B) ?H ⊢ ?C› ‹⟦insert ?A (insert ?A1.0 ?H) ⊢ ?B; insert ?Ba (insert ?A1.0 ?H) ⊢ ?B⟧ ⟹ insert ?A1.0 (insert (?A OR ?Ba) ?H) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 ?H)) ⊢ ?B; insert ?Ba (insert ?A1.0 (insert ?A2.0 ?H)) ⊢ ?B⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert (?A OR ?Ba) ?H)) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 ?H))) ⊢ ?B; insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 ?H))) ⊢ ?B⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert (?A OR ?Ba) ?H))) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 ?H)))) ⊢ ?B; insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 ?H)))) ⊢ ?B⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert (?A OR ?Ba) ?H)))) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 ?H))))) ⊢ ?B; insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 ?H))))) ⊢ ?B⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert (?A OR ?Ba) ?H))))) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 ?H)))))) ⊢ ?B; insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 ?H)))))) ⊢ ?B⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert (?A OR ?Ba) ?H)))))) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 ?H))))))) ⊢ ?B; insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 ?H))))))) ⊢ ?B⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 (insert (?A OR ?Ba) ?H))))))) ⊢ ?B› ‹⟦insert ?A (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)))))))) ⊢ ?B; insert ?Ba (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)))))))) ⊢ ?B⟧ ⟹ 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 (?A OR ?Ba) ?H)))))))) ⊢ ?B› ‹⟦insert ?A (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))))))))) ⊢ ?B; insert ?Ba (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))))))))) ⊢ ?B⟧ ⟹ 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 (?A OR ?Ba) ?H))))))))) ⊢ ?B›*), blast intro: thin1 (*‹?H ⊢ ?B ⟹ insert ?A ?H ⊢ ?B›*) ContraProve (*‹?H ⊢ ?B ⟹ insert (Neg ?B) ?H ⊢ ?A›*))+) (*top goal: ‹⟦atom i ♯ (s, s', v, a, x, y, y'); atom j ♯ (s, s', v, a, x, i, x, y, y'); atom j' ♯ (s, s', v, a, x, i, j, x, y, y'); atom k ♯ (s, s', v, a, x, y, y', kk', i, j, j'); atom k' ♯ (s, s', v, a, x, y, y', k, i, j, j'); atom l ♯ (s, s', v, a, x, i, j, j', k, k'); atom m ♯ (s, s', v, a, i, j, j', k, k', l); atom n ♯ (s, s', v, a, i, j, j', k, k', l, m); atom sm ♯ (s, s', v, a, i, j, j', k, k', l, m, n); atom sn ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm); atom sm' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn); atom sn' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm'); atom m2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn'); atom n2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2); atom sm2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2); atom sn2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2); atom sm2' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2, sn2); atom sn2' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2, sn2, sm2')⟧ ⟹ {Var n IN Var k IMP SyntaxN.All i (SyntaxN.All j (SyntaxN.All j' (SyntaxN.All k' (SeqSubstFormP v a (Var i) (Var j) s (Var n) IMP SeqSubstFormP v a (Var i) (Var j') s' (Var k') IMP Var j' EQ Var j)))), Var m IN Var k IMP SyntaxN.All i (SyntaxN.All j (SyntaxN.All j' (SyntaxN.All k' (SeqSubstFormP v a (Var i) (Var j) s (Var m) IMP SeqSubstFormP v a (Var i) (Var j') s' (Var k') IMP Var j' EQ Var j)))), Var i EQ Q_Disj (Var sm2) (Var sn2), Var j' EQ Q_Disj (Var sm2') (Var sn2'), SeqSubstFormP v a (Var sn2) (Var sn2') s' (Var n2), SeqSubstFormP v a (Var sm2) (Var sm2') s' (Var m2), Var n2 IN Var k', Var m2 IN Var k', Var i EQ Q_Disj (Var sm) (Var sn), Var j EQ Q_Disj (Var sm') (Var sn'), SeqSubstFormP v a (Var sn) (Var sn') s (Var n), SeqSubstFormP v a (Var sm) (Var sm') s (Var m), Var n IN Var k, Var m IN Var k, All2 l (Var k) (SyntaxN.All i (SyntaxN.All j (SyntaxN.All j' (SyntaxN.All k' (SeqSubstFormP v a (Var i) (Var j) s (Var l) IMP SeqSubstFormP v a (Var i) (Var j') s' (Var k') IMP Var j' EQ Var j))))), SeqSubstFormP v a (Var i) (Var j') s' (Var k'), SeqSubstFormP v a (Var i) (Var j) s (Var k), OrdP (Var k)} ⊢ Var j' EQ Var j› and 2 goals remain*) apply (rule All_E [where x="Var sm"] (*‹insert ((?A::fm)(?i::name::=Var (sm::name))) (?H::fm set) ⊢ (?B::fm) ⟹ insert (SyntaxN.All ?i ?A) ?H ⊢ ?B›*), simp) (*top goal: ‹⟦atom (i::name) ♯ (s::tm, s'::tm, v::tm, a::tm, x::tm, y::tm, y'::tm); atom (j::name) ♯ (s, s', v, a, x, i, x, y, y'); atom (j'::name) ♯ (s, s', v, a, x, i, j, x, y, y'); atom (k::name) ♯ (s, s', v, a, x, y, y', kk'::tm, i, j, j'); atom (k'::name) ♯ (s, s', v, a, x, y, y', k, i, j, j'); atom (l::name) ♯ (s, s', v, a, x, i, j, j', k, k'); atom (m::name) ♯ (s, s', v, a, i, j, j', k, k', l); atom (n::name) ♯ (s, s', v, a, i, j, j', k, k', l, m); atom (sm::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n); atom (sn::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm); atom (sm'::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn); atom (sn'::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm'); atom (m2::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn'); atom (n2::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2); atom (sm2::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2); atom (sn2::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2); atom (sm2'::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2, sn2); atom (sn2'::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2, sn2, sm2')⟧ ⟹ {SyntaxN.All i (SyntaxN.All j (SyntaxN.All j' (SyntaxN.All k' (SeqSubstFormP v a (Var i) (Var j) s (Var m) IMP SeqSubstFormP v a (Var i) (Var j') s' (Var k') IMP Var j' EQ Var j)))), SyntaxN.All i (SyntaxN.All j (SyntaxN.All j' (SyntaxN.All k' (SeqSubstFormP v a (Var i) (Var j) s (Var n) IMP SeqSubstFormP v a (Var i) (Var j') s' (Var k') IMP Var j' EQ Var j)))), Var i EQ Q_Disj (Var sm2) (Var sn2), Var j' EQ Q_Disj (Var sm2') (Var sn2'), SeqSubstFormP v a (Var sn2) (Var sn2') s' (Var n2), SeqSubstFormP v a (Var sm2) (Var sm2') s' (Var m2), Var n2 IN Var k', Var m2 IN Var k', Var i EQ Q_Disj (Var sm) (Var sn), Var j EQ Q_Disj (Var sm') (Var sn'), SeqSubstFormP v a (Var sn) (Var sn') s (Var n), SeqSubstFormP v a (Var sm) (Var sm') s (Var m), Var n IN Var k, Var m IN Var k, All2 l (Var k) (SyntaxN.All i (SyntaxN.All j (SyntaxN.All j' (SyntaxN.All k' (SeqSubstFormP v a (Var i) (Var j) s (Var l) IMP SeqSubstFormP v a (Var i) (Var j') s' (Var k') IMP Var j' EQ Var j))))), SeqSubstFormP v a (Var i) (Var j') s' (Var k'), SeqSubstFormP v a (Var i) (Var j) s (Var k), OrdP (Var k)} ⊢ Var j' EQ Var j› and 2 goals remain*) apply (rule All_E [where x="Var sm'"] (*‹insert (?A(?i::=Var sm')) ?H ⊢ ?B ⟹ insert (SyntaxN.All ?i ?A) ?H ⊢ ?B›*), simp) (*top goal: ‹⟦atom i ♯ (s, s', v, a, x, y, y'); atom j ♯ (s, s', v, a, x, i, x, y, y'); atom j' ♯ (s, s', v, a, x, i, j, x, y, y'); atom k ♯ (s, s', v, a, x, y, y', kk', i, j, j'); atom k' ♯ (s, s', v, a, x, y, y', k, i, j, j'); atom l ♯ (s, s', v, a, x, i, j, j', k, k'); atom m ♯ (s, s', v, a, i, j, j', k, k', l); atom n ♯ (s, s', v, a, i, j, j', k, k', l, m); atom sm ♯ (s, s', v, a, i, j, j', k, k', l, m, n); atom sn ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm); atom sm' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn); atom sn' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm'); atom m2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn'); atom n2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2); atom sm2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2); atom sn2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2); atom sm2' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2, sn2); atom sn2' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2, sn2, sm2')⟧ ⟹ {SyntaxN.All j (SyntaxN.All j' (SyntaxN.All k' (SeqSubstFormP v a (Var sm) (Var j) s (Var m) IMP SeqSubstFormP v a (Var sm) (Var j') s' (Var k') IMP Var j' EQ Var j))), SyntaxN.All i (SyntaxN.All j (SyntaxN.All j' (SyntaxN.All k' (SeqSubstFormP v a (Var i) (Var j) s (Var n) IMP SeqSubstFormP v a (Var i) (Var j') s' (Var k') IMP Var j' EQ Var j)))), Var i EQ Q_Disj (Var sm2) (Var sn2), Var j' EQ Q_Disj (Var sm2') (Var sn2'), SeqSubstFormP v a (Var sn2) (Var sn2') s' (Var n2), SeqSubstFormP v a (Var sm2) (Var sm2') s' (Var m2), Var n2 IN Var k', Var m2 IN Var k', Var i EQ Q_Disj (Var sm) (Var sn), Var j EQ Q_Disj (Var sm') (Var sn'), SeqSubstFormP v a (Var sn) (Var sn') s (Var n), SeqSubstFormP v a (Var sm) (Var sm') s (Var m), Var n IN Var k, Var m IN Var k, All2 l (Var k) (SyntaxN.All i (SyntaxN.All j (SyntaxN.All j' (SyntaxN.All k' (SeqSubstFormP v a (Var i) (Var j) s (Var l) IMP SeqSubstFormP v a (Var i) (Var j') s' (Var k') IMP Var j' EQ Var j))))), SeqSubstFormP v a (Var i) (Var j') s' (Var k'), SeqSubstFormP v a (Var i) (Var j) s (Var k), OrdP (Var k)} ⊢ Var j' EQ Var j› and 2 goals remain*) apply (rule All_E [where x="Var sm2'"] (*‹insert (?A(?i::=Var sm2')) ?H ⊢ ?B ⟹ insert (SyntaxN.All ?i ?A) ?H ⊢ ?B›*), simp) (*top goal: ‹⟦atom (i::name) ♯ (s::tm, s'::tm, v::tm, a::tm, x::tm, y::tm, y'::tm); atom (j::name) ♯ (s, s', v, a, x, i, x, y, y'); atom (j'::name) ♯ (s, s', v, a, x, i, j, x, y, y'); atom (k::name) ♯ (s, s', v, a, x, y, y', kk'::tm, i, j, j'); atom (k'::name) ♯ (s, s', v, a, x, y, y', k, i, j, j'); atom (l::name) ♯ (s, s', v, a, x, i, j, j', k, k'); atom (m::name) ♯ (s, s', v, a, i, j, j', k, k', l); atom (n::name) ♯ (s, s', v, a, i, j, j', k, k', l, m); atom (sm::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n); atom (sn::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm); atom (sm'::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn); atom (sn'::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm'); atom (m2::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn'); atom (n2::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2); atom (sm2::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2); atom (sn2::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2); atom (sm2'::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2, sn2); atom (sn2'::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2, sn2, sm2')⟧ ⟹ {SyntaxN.All j' (SyntaxN.All k' (SeqSubstFormP v a (Var sm) (Var sm') s (Var m) IMP SeqSubstFormP v a (Var sm) (Var j') s' (Var k') IMP Var j' EQ Var sm')), SyntaxN.All i (SyntaxN.All j (SyntaxN.All j' (SyntaxN.All k' (SeqSubstFormP v a (Var i) (Var j) s (Var n) IMP SeqSubstFormP v a (Var i) (Var j') s' (Var k') IMP Var j' EQ Var j)))), Var i EQ Q_Disj (Var sm2) (Var sn2), Var j' EQ Q_Disj (Var sm2') (Var sn2'), SeqSubstFormP v a (Var sn2) (Var sn2') s' (Var n2), SeqSubstFormP v a (Var sm2) (Var sm2') s' (Var m2), Var n2 IN Var k', Var m2 IN Var k', Var i EQ Q_Disj (Var sm) (Var sn), Var j EQ Q_Disj (Var sm') (Var sn'), SeqSubstFormP v a (Var sn) (Var sn') s (Var n), SeqSubstFormP v a (Var sm) (Var sm') s (Var m), Var n IN Var k, Var m IN Var k, All2 l (Var k) (SyntaxN.All i (SyntaxN.All j (SyntaxN.All j' (SyntaxN.All k' (SeqSubstFormP v a (Var i) (Var j) s (Var l) IMP SeqSubstFormP v a (Var i) (Var j') s' (Var k') IMP Var j' EQ Var j))))), SeqSubstFormP v a (Var i) (Var j') s' (Var k'), SeqSubstFormP v a (Var i) (Var j) s (Var k), OrdP (Var k)} ⊢ Var j' EQ Var j› and 2 goals remain*) apply (rule All_E [where x="Var m2"] (*‹insert ((?A::fm)(?i::name::=Var (m2::name))) (?H::fm set) ⊢ (?B::fm) ⟹ insert (SyntaxN.All ?i ?A) ?H ⊢ ?B›*), simp) (*top goal: ‹⟦atom i ♯ (s, s', v, a, x, y, y'); atom j ♯ (s, s', v, a, x, i, x, y, y'); atom j' ♯ (s, s', v, a, x, i, j, x, y, y'); atom k ♯ (s, s', v, a, x, y, y', kk', i, j, j'); atom k' ♯ (s, s', v, a, x, y, y', k, i, j, j'); atom l ♯ (s, s', v, a, x, i, j, j', k, k'); atom m ♯ (s, s', v, a, i, j, j', k, k', l); atom n ♯ (s, s', v, a, i, j, j', k, k', l, m); atom sm ♯ (s, s', v, a, i, j, j', k, k', l, m, n); atom sn ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm); atom sm' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn); atom sn' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm'); atom m2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn'); atom n2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2); atom sm2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2); atom sn2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2); atom sm2' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2, sn2); atom sn2' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2, sn2, sm2')⟧ ⟹ {SyntaxN.All k' (SeqSubstFormP v a (Var sm) (Var sm') s (Var m) IMP SeqSubstFormP v a (Var sm) (Var sm2') s' (Var k') IMP Var sm2' EQ Var sm'), SyntaxN.All i (SyntaxN.All j (SyntaxN.All j' (SyntaxN.All k' (SeqSubstFormP v a (Var i) (Var j) s (Var n) IMP SeqSubstFormP v a (Var i) (Var j') s' (Var k') IMP Var j' EQ Var j)))), Var i EQ Q_Disj (Var sm2) (Var sn2), Var j' EQ Q_Disj (Var sm2') (Var sn2'), SeqSubstFormP v a (Var sn2) (Var sn2') s' (Var n2), SeqSubstFormP v a (Var sm2) (Var sm2') s' (Var m2), Var n2 IN Var k', Var m2 IN Var k', Var i EQ Q_Disj (Var sm) (Var sn), Var j EQ Q_Disj (Var sm') (Var sn'), SeqSubstFormP v a (Var sn) (Var sn') s (Var n), SeqSubstFormP v a (Var sm) (Var sm') s (Var m), Var n IN Var k, Var m IN Var k, All2 l (Var k) (SyntaxN.All i (SyntaxN.All j (SyntaxN.All j' (SyntaxN.All k' (SeqSubstFormP v a (Var i) (Var j) s (Var l) IMP SeqSubstFormP v a (Var i) (Var j') s' (Var k') IMP Var j' EQ Var j))))), SeqSubstFormP v a (Var i) (Var j') s' (Var k'), SeqSubstFormP v a (Var i) (Var j) s (Var k), OrdP (Var k)} ⊢ Var j' EQ Var j› and 2 goals remain*) apply (rule All_E [where x="Var sn", THEN rotate2] (*‹insert (?A1(?i1::=Var sn)) (insert ?A1.0 ?H) ⊢ ?B ⟹ insert ?A1.0 (insert (SyntaxN.All ?i1 ?A1) ?H) ⊢ ?B›*), simp) (*top goal: ‹⟦atom (i::name) ♯ (s::tm, s'::tm, v::tm, a::tm, x::tm, y::tm, y'::tm); atom (j::name) ♯ (s, s', v, a, x, i, x, y, y'); atom (j'::name) ♯ (s, s', v, a, x, i, j, x, y, y'); atom (k::name) ♯ (s, s', v, a, x, y, y', kk'::tm, i, j, j'); atom (k'::name) ♯ (s, s', v, a, x, y, y', k, i, j, j'); atom (l::name) ♯ (s, s', v, a, x, i, j, j', k, k'); atom (m::name) ♯ (s, s', v, a, i, j, j', k, k', l); atom (n::name) ♯ (s, s', v, a, i, j, j', k, k', l, m); atom (sm::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n); atom (sn::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm); atom (sm'::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn); atom (sn'::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm'); atom (m2::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn'); atom (n2::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2); atom (sm2::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2); atom (sn2::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2); atom (sm2'::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2, sn2); atom (sn2'::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2, sn2, sm2')⟧ ⟹ {SeqSubstFormP v a (Var sm) (Var sm') s (Var m) IMP SeqSubstFormP v a (Var sm) (Var sm2') s' (Var m2) IMP Var sm2' EQ Var sm', SyntaxN.All i (SyntaxN.All j (SyntaxN.All j' (SyntaxN.All k' (SeqSubstFormP v a (Var i) (Var j) s (Var n) IMP SeqSubstFormP v a (Var i) (Var j') s' (Var k') IMP Var j' EQ Var j)))), Var i EQ Q_Disj (Var sm2) (Var sn2), Var j' EQ Q_Disj (Var sm2') (Var sn2'), SeqSubstFormP v a (Var sn2) (Var sn2') s' (Var n2), SeqSubstFormP v a (Var sm2) (Var sm2') s' (Var m2), Var n2 IN Var k', Var m2 IN Var k', Var i EQ Q_Disj (Var sm) (Var sn), Var j EQ Q_Disj (Var sm') (Var sn'), SeqSubstFormP v a (Var sn) (Var sn') s (Var n), SeqSubstFormP v a (Var sm) (Var sm') s (Var m), Var n IN Var k, Var m IN Var k, All2 l (Var k) (SyntaxN.All i (SyntaxN.All j (SyntaxN.All j' (SyntaxN.All k' (SeqSubstFormP v a (Var i) (Var j) s (Var l) IMP SeqSubstFormP v a (Var i) (Var j') s' (Var k') IMP Var j' EQ Var j))))), SeqSubstFormP v a (Var i) (Var j') s' (Var k'), SeqSubstFormP v a (Var i) (Var j) s (Var k), OrdP (Var k)} ⊢ Var j' EQ Var j› and 2 goals remain*) apply (rule All_E [where x="Var sn'"] (*‹insert (?A(?i::=Var sn')) ?H ⊢ ?B ⟹ insert (SyntaxN.All ?i ?A) ?H ⊢ ?B›*), simp) (*top goal: ‹⟦atom i ♯ (s, s', v, a, x, y, y'); atom j ♯ (s, s', v, a, x, i, x, y, y'); atom j' ♯ (s, s', v, a, x, i, j, x, y, y'); atom k ♯ (s, s', v, a, x, y, y', kk', i, j, j'); atom k' ♯ (s, s', v, a, x, y, y', k, i, j, j'); atom l ♯ (s, s', v, a, x, i, j, j', k, k'); atom m ♯ (s, s', v, a, i, j, j', k, k', l); atom n ♯ (s, s', v, a, i, j, j', k, k', l, m); atom sm ♯ (s, s', v, a, i, j, j', k, k', l, m, n); atom sn ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm); atom sm' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn); atom sn' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm'); atom m2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn'); atom n2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2); atom sm2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2); atom sn2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2); atom sm2' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2, sn2); atom sn2' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2, sn2, sm2')⟧ ⟹ {SyntaxN.All j (SyntaxN.All j' (SyntaxN.All k' (SeqSubstFormP v a (Var sn) (Var j) s (Var n) IMP SeqSubstFormP v a (Var sn) (Var j') s' (Var k') IMP Var j' EQ Var j))), SeqSubstFormP v a (Var sm) (Var sm') s (Var m) IMP SeqSubstFormP v a (Var sm) (Var sm2') s' (Var m2) IMP Var sm2' EQ Var sm', Var i EQ Q_Disj (Var sm2) (Var sn2), Var j' EQ Q_Disj (Var sm2') (Var sn2'), SeqSubstFormP v a (Var sn2) (Var sn2') s' (Var n2), SeqSubstFormP v a (Var sm2) (Var sm2') s' (Var m2), Var n2 IN Var k', Var m2 IN Var k', Var i EQ Q_Disj (Var sm) (Var sn), Var j EQ Q_Disj (Var sm') (Var sn'), SeqSubstFormP v a (Var sn) (Var sn') s (Var n), SeqSubstFormP v a (Var sm) (Var sm') s (Var m), Var n IN Var k, Var m IN Var k, All2 l (Var k) (SyntaxN.All i (SyntaxN.All j (SyntaxN.All j' (SyntaxN.All k' (SeqSubstFormP v a (Var i) (Var j) s (Var l) IMP SeqSubstFormP v a (Var i) (Var j') s' (Var k') IMP Var j' EQ Var j))))), SeqSubstFormP v a (Var i) (Var j') s' (Var k'), SeqSubstFormP v a (Var i) (Var j) s (Var k), OrdP (Var k)} ⊢ Var j' EQ Var j› and 2 goals remain*) apply (rule All_E [where x="Var sn2'"] (*‹insert (?A(?i::=Var sn2')) ?H ⊢ ?B ⟹ insert (SyntaxN.All ?i ?A) ?H ⊢ ?B›*), simp) (*top goal: ‹⟦atom (i::name) ♯ (s::tm, s'::tm, v::tm, a::tm, x::tm, y::tm, y'::tm); atom (j::name) ♯ (s, s', v, a, x, i, x, y, y'); atom (j'::name) ♯ (s, s', v, a, x, i, j, x, y, y'); atom (k::name) ♯ (s, s', v, a, x, y, y', kk'::tm, i, j, j'); atom (k'::name) ♯ (s, s', v, a, x, y, y', k, i, j, j'); atom (l::name) ♯ (s, s', v, a, x, i, j, j', k, k'); atom (m::name) ♯ (s, s', v, a, i, j, j', k, k', l); atom (n::name) ♯ (s, s', v, a, i, j, j', k, k', l, m); atom (sm::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n); atom (sn::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm); atom (sm'::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn); atom (sn'::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm'); atom (m2::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn'); atom (n2::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2); atom (sm2::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2); atom (sn2::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2); atom (sm2'::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2, sn2); atom (sn2'::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2, sn2, sm2')⟧ ⟹ {SyntaxN.All j' (SyntaxN.All k' (SeqSubstFormP v a (Var sn) (Var sn') s (Var n) IMP SeqSubstFormP v a (Var sn) (Var j') s' (Var k') IMP Var j' EQ Var sn')), SeqSubstFormP v a (Var sm) (Var sm') s (Var m) IMP SeqSubstFormP v a (Var sm) (Var sm2') s' (Var m2) IMP Var sm2' EQ Var sm', Var i EQ Q_Disj (Var sm2) (Var sn2), Var j' EQ Q_Disj (Var sm2') (Var sn2'), SeqSubstFormP v a (Var sn2) (Var sn2') s' (Var n2), SeqSubstFormP v a (Var sm2) (Var sm2') s' (Var m2), Var n2 IN Var k', Var m2 IN Var k', Var i EQ Q_Disj (Var sm) (Var sn), Var j EQ Q_Disj (Var sm') (Var sn'), SeqSubstFormP v a (Var sn) (Var sn') s (Var n), SeqSubstFormP v a (Var sm) (Var sm') s (Var m), Var n IN Var k, Var m IN Var k, All2 l (Var k) (SyntaxN.All i (SyntaxN.All j (SyntaxN.All j' (SyntaxN.All k' (SeqSubstFormP v a (Var i) (Var j) s (Var l) IMP SeqSubstFormP v a (Var i) (Var j') s' (Var k') IMP Var j' EQ Var j))))), SeqSubstFormP v a (Var i) (Var j') s' (Var k'), SeqSubstFormP v a (Var i) (Var j) s (Var k), OrdP (Var k)} ⊢ Var j' EQ Var j› and 2 goals remain*) apply (rule All_E [where x="Var n2"] (*‹insert (?A(?i::=Var n2)) ?H ⊢ ?B ⟹ insert (SyntaxN.All ?i ?A) ?H ⊢ ?B›*), simp) (*top goal: ‹⟦atom i ♯ (s, s', v, a, x, y, y'); atom j ♯ (s, s', v, a, x, i, x, y, y'); atom j' ♯ (s, s', v, a, x, i, j, x, y, y'); atom k ♯ (s, s', v, a, x, y, y', kk', i, j, j'); atom k' ♯ (s, s', v, a, x, y, y', k, i, j, j'); atom l ♯ (s, s', v, a, x, i, j, j', k, k'); atom m ♯ (s, s', v, a, i, j, j', k, k', l); atom n ♯ (s, s', v, a, i, j, j', k, k', l, m); atom sm ♯ (s, s', v, a, i, j, j', k, k', l, m, n); atom sn ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm); atom sm' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn); atom sn' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm'); atom m2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn'); atom n2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2); atom sm2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2); atom sn2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2); atom sm2' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2, sn2); atom sn2' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2, sn2, sm2')⟧ ⟹ {SyntaxN.All k' (SeqSubstFormP v a (Var sn) (Var sn') s (Var n) IMP SeqSubstFormP v a (Var sn) (Var sn2') s' (Var k') IMP Var sn2' EQ Var sn'), SeqSubstFormP v a (Var sm) (Var sm') s (Var m) IMP SeqSubstFormP v a (Var sm) (Var sm2') s' (Var m2) IMP Var sm2' EQ Var sm', Var i EQ Q_Disj (Var sm2) (Var sn2), Var j' EQ Q_Disj (Var sm2') (Var sn2'), SeqSubstFormP v a (Var sn2) (Var sn2') s' (Var n2), SeqSubstFormP v a (Var sm2) (Var sm2') s' (Var m2), Var n2 IN Var k', Var m2 IN Var k', Var i EQ Q_Disj (Var sm) (Var sn), Var j EQ Q_Disj (Var sm') (Var sn'), SeqSubstFormP v a (Var sn) (Var sn') s (Var n), SeqSubstFormP v a (Var sm) (Var sm') s (Var m), Var n IN Var k, Var m IN Var k, All2 l (Var k) (SyntaxN.All i (SyntaxN.All j (SyntaxN.All j' (SyntaxN.All k' (SeqSubstFormP v a (Var i) (Var j) s (Var l) IMP SeqSubstFormP v a (Var i) (Var j') s' (Var k') IMP Var j' EQ Var j))))), SeqSubstFormP v a (Var i) (Var j') s' (Var k'), SeqSubstFormP v a (Var i) (Var j) s (Var k), OrdP (Var k)} ⊢ Var j' EQ Var j› and 2 goals remain*) apply (rule rotate3 (*‹insert ?A3.0 (insert ?A1.0 (insert ?A2.0 ?H)) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 ?H)) ⊢ ?B›*)) (*top goal: ‹⟦atom i ♯ (s, s', v, a, x, y, y'); atom j ♯ (s, s', v, a, x, i, x, y, y'); atom j' ♯ (s, s', v, a, x, i, j, x, y, y'); atom k ♯ (s, s', v, a, x, y, y', kk', i, j, j'); atom k' ♯ (s, s', v, a, x, y, y', k, i, j, j'); atom l ♯ (s, s', v, a, x, i, j, j', k, k'); atom m ♯ (s, s', v, a, i, j, j', k, k', l); atom n ♯ (s, s', v, a, i, j, j', k, k', l, m); atom sm ♯ (s, s', v, a, i, j, j', k, k', l, m, n); atom sn ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm); atom sm' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn); atom sn' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm'); atom m2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn'); atom n2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2); atom sm2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2); atom sn2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2); atom sm2' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2, sn2); atom sn2' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2, sn2, sm2')⟧ ⟹ {SeqSubstFormP v a (Var sn) (Var sn') s (Var n) IMP SeqSubstFormP v a (Var sn) (Var sn2') s' (Var n2) IMP Var sn2' EQ Var sn', SeqSubstFormP v a (Var sm) (Var sm') s (Var m) IMP SeqSubstFormP v a (Var sm) (Var sm2') s' (Var m2) IMP Var sm2' EQ Var sm', Var i EQ Q_Disj (Var sm2) (Var sn2), Var j' EQ Q_Disj (Var sm2') (Var sn2'), SeqSubstFormP v a (Var sn2) (Var sn2') s' (Var n2), SeqSubstFormP v a (Var sm2) (Var sm2') s' (Var m2), Var n2 IN Var k', Var m2 IN Var k', Var i EQ Q_Disj (Var sm) (Var sn), Var j EQ Q_Disj (Var sm') (Var sn'), SeqSubstFormP v a (Var sn) (Var sn') s (Var n), SeqSubstFormP v a (Var sm) (Var sm') s (Var m), Var n IN Var k, Var m IN Var k, All2 l (Var k) (SyntaxN.All i (SyntaxN.All j (SyntaxN.All j' (SyntaxN.All k' (SeqSubstFormP v a (Var i) (Var j) s (Var l) IMP SeqSubstFormP v a (Var i) (Var j') s' (Var k') IMP Var j' EQ Var j))))), SeqSubstFormP v a (Var i) (Var j') s' (Var k'), SeqSubstFormP v a (Var i) (Var j) s (Var k), OrdP (Var k)} ⊢ Var j' EQ Var j› and 2 goals remain*) apply (rule Eq_Trans_E [OF Hyp] (*‹⟦?x EQ ?u ∈ ?H; insert (?t EQ ?u) ?H ⊢ ?A⟧ ⟹ insert (?x EQ ?t) ?H ⊢ ?A›*), blast) (*top goal: ‹⟦atom i ♯ (s, s', v, a, x, y, y'); atom j ♯ (s, s', v, a, x, i, x, y, y'); atom j' ♯ (s, s', v, a, x, i, j, x, y, y'); atom k ♯ (s, s', v, a, x, y, y', kk', i, j, j'); atom k' ♯ (s, s', v, a, x, y, y', k, i, j, j'); atom l ♯ (s, s', v, a, x, i, j, j', k, k'); atom m ♯ (s, s', v, a, i, j, j', k, k', l); atom n ♯ (s, s', v, a, i, j, j', k, k', l, m); atom sm ♯ (s, s', v, a, i, j, j', k, k', l, m, n); atom sn ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm); atom sm' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn); atom sn' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm'); atom m2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn'); atom n2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2); atom sm2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2); atom sn2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2); atom sm2' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2, sn2); atom sn2' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2, sn2, sm2')⟧ ⟹ {Var i EQ Q_Disj (Var sm2) (Var sn2), SeqSubstFormP v a (Var sn) (Var sn') s (Var n) IMP SeqSubstFormP v a (Var sn) (Var sn2') s' (Var n2) IMP Var sn2' EQ Var sn', SeqSubstFormP v a (Var sm) (Var sm') s (Var m) IMP SeqSubstFormP v a (Var sm) (Var sm2') s' (Var m2) IMP Var sm2' EQ Var sm', Var j' EQ Q_Disj (Var sm2') (Var sn2'), SeqSubstFormP v a (Var sn2) (Var sn2') s' (Var n2), SeqSubstFormP v a (Var sm2) (Var sm2') s' (Var m2), Var n2 IN Var k', Var m2 IN Var k', Var i EQ Q_Disj (Var sm) (Var sn), Var j EQ Q_Disj (Var sm') (Var sn'), SeqSubstFormP v a (Var sn) (Var sn') s (Var n), SeqSubstFormP v a (Var sm) (Var sm') s (Var m), Var n IN Var k, Var m IN Var k, All2 l (Var k) (SyntaxN.All i (SyntaxN.All j (SyntaxN.All j' (SyntaxN.All k' (SeqSubstFormP v a (Var i) (Var j) s (Var l) IMP SeqSubstFormP v a (Var i) (Var j') s' (Var k') IMP Var j' EQ Var j))))), SeqSubstFormP v a (Var i) (Var j') s' (Var k'), SeqSubstFormP v a (Var i) (Var j) s (Var k), OrdP (Var k)} ⊢ Var j' EQ Var j› and 2 goals remain*) apply (clarsimp simp add: HTS (*‹0 < ?n ⟹ HTuple ?n = HPair Zero (HTuple (?n - 1))› ‹HTuple 0 = HPair Zero Zero› ‹HTuple (Suc ?k) = HPair Zero (HTuple ?k)›*)) (*top goal: ‹⟦atom (i::name) ♯ (s::tm, s'::tm, v::tm, a::tm, x::tm, y::tm, y'::tm); atom (j::name) ♯ (s, s', v, a, x, i, x, y, y'); atom (j'::name) ♯ (s, s', v, a, x, i, j, x, y, y'); atom (k::name) ♯ (s, s', v, a, x, y, y', kk'::tm, i, j, j'); atom (k'::name) ♯ (s, s', v, a, x, y, y', k, i, j, j'); atom (l::name) ♯ (s, s', v, a, x, i, j, j', k, k'); atom (m::name) ♯ (s, s', v, a, i, j, j', k, k', l); atom (n::name) ♯ (s, s', v, a, i, j, j', k, k', l, m); atom (sm::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n); atom (sn::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm); atom (sm'::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn); atom (sn'::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm'); atom (m2::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn'); atom (n2::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2); atom (sm2::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2); atom (sn2::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2); atom (sm2'::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2, sn2); atom (sn2'::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2, sn2, sm2')⟧ ⟹ {Q_Disj (Var sm2) (Var sn2) EQ Q_Disj (Var sm) (Var sn), SeqSubstFormP v a (Var sn) (Var sn') s (Var n) IMP SeqSubstFormP v a (Var sn) (Var sn2') s' (Var n2) IMP Var sn2' EQ Var sn', SeqSubstFormP v a (Var sm) (Var sm') s (Var m) IMP SeqSubstFormP v a (Var sm) (Var sm2') s' (Var m2) IMP Var sm2' EQ Var sm', Var j' EQ Q_Disj (Var sm2') (Var sn2'), SeqSubstFormP v a (Var sn2) (Var sn2') s' (Var n2), SeqSubstFormP v a (Var sm2) (Var sm2') s' (Var m2), Var n2 IN Var k', Var m2 IN Var k', Var i EQ Q_Disj (Var sm) (Var sn), Var j EQ Q_Disj (Var sm') (Var sn'), SeqSubstFormP v a (Var sn) (Var sn') s (Var n), SeqSubstFormP v a (Var sm) (Var sm') s (Var m), Var n IN Var k, Var m IN Var k, All2 l (Var k) (SyntaxN.All i (SyntaxN.All j (SyntaxN.All j' (SyntaxN.All k' (SeqSubstFormP v a (Var i) (Var j) s (Var l) IMP SeqSubstFormP v a (Var i) (Var j') s' (Var k') IMP Var j' EQ Var j))))), SeqSubstFormP v a (Var i) (Var j') s' (Var k'), SeqSubstFormP v a (Var i) (Var j) s (Var k), OrdP (Var k)} ⊢ Var j' EQ Var j› and 2 goals remain*) apply (rule thin1 (*‹?H ⊢ ?B ⟹ insert ?A ?H ⊢ ?B›*)) (*top goal: ‹⟦atom i ♯ (s, s', v, a, x, y, y'); atom j ♯ (s, s', v, a, x, i, x, y, y'); atom j' ♯ (s, s', v, a, x, i, j, x, y, y'); atom k ♯ (s, s', v, a, x, y, y', kk', i, j, j'); atom k' ♯ (s, s', v, a, x, y, y', k, i, j, j'); atom l ♯ (s, s', v, a, x, i, j, j', k, k'); atom m ♯ (s, s', v, a, i, j, j', k, k', l); atom n ♯ (s, s', v, a, i, j, j', k, k', l, m); atom sm ♯ (s, s', v, a, i, j, j', k, k', l, m, n); atom sn ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm); atom sm' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn); atom sn' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm'); atom m2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn'); atom n2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2); atom sm2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2); atom sn2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2); atom sm2' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2, sn2); atom sn2' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2, sn2, sm2')⟧ ⟹ {Zero EQ Zero, Var sm2 EQ Var sm, Var sn2 EQ Var sn, SeqSubstFormP v a (Var sn) (Var sn') s (Var n) IMP SeqSubstFormP v a (Var sn) (Var sn2') s' (Var n2) IMP Var sn2' EQ Var sn', SeqSubstFormP v a (Var sm) (Var sm') s (Var m) IMP SeqSubstFormP v a (Var sm) (Var sm2') s' (Var m2) IMP Var sm2' EQ Var sm', Var j' EQ HPair (HPair Zero (HPair Zero (HPair Zero (HPair Zero Zero)))) (HPair (Var sm2') (Var sn2')), SeqSubstFormP v a (Var sn2) (Var sn2') s' (Var n2), SeqSubstFormP v a (Var sm2) (Var sm2') s' (Var m2), Var n2 IN Var k', Var m2 IN Var k', Var i EQ HPair (HPair Zero (HPair Zero (HPair Zero (HPair Zero Zero)))) (HPair (Var sm) (Var sn)), Var j EQ HPair (HPair Zero (HPair Zero (HPair Zero (HPair Zero Zero)))) (HPair (Var sm') (Var sn')), SeqSubstFormP v a (Var sn) (Var sn') s (Var n), SeqSubstFormP v a (Var sm) (Var sm') s (Var m), Var n IN Var k, Var m IN Var k, All2 l (Var k) (SyntaxN.All i (SyntaxN.All j (SyntaxN.All j' (SyntaxN.All k' (SeqSubstFormP v a (Var i) (Var j) s (Var l) IMP SeqSubstFormP v a (Var i) (Var j') s' (Var k') IMP Var j' EQ Var j))))), SeqSubstFormP v a (Var i) (Var j') s' (Var k'), SeqSubstFormP v a (Var i) (Var j) s (Var k), OrdP (Var k)} ⊢ Var j' EQ Var j› and 2 goals remain*) apply ((rule Disj_EH [OF ContraProve] (*‹⟦?H ⊢ ?B1; insert ?B ?H ⊢ ?C⟧ ⟹ insert (?B1 IMP ?B) ?H ⊢ ?C› ‹⟦insert ?A1.0 ?H ⊢ ?B1; insert ?Ba (insert ?A1.0 ?H) ⊢ ?B⟧ ⟹ insert ?A1.0 (insert (?B1 IMP ?Ba) ?H) ⊢ ?B› ‹⟦insert ?A1.0 (insert ?A2.0 ?H) ⊢ ?B1; insert ?Ba (insert ?A1.0 (insert ?A2.0 ?H)) ⊢ ?B⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert (?B1 IMP ?Ba) ?H)) ⊢ ?B› ‹⟦insert ?A1.0 (insert ?A2.0 (insert ?A3.0 ?H)) ⊢ ?B1; insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 ?H))) ⊢ ?B⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert (?B1 IMP ?Ba) ?H))) ⊢ ?B› ‹⟦insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 ?H))) ⊢ ?B1; insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 ?H)))) ⊢ ?B⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert (?B1 IMP ?Ba) ?H)))) ⊢ ?B› ‹⟦insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 ?H)))) ⊢ ?B1; insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 ?H))))) ⊢ ?B⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert (?B1 IMP ?Ba) ?H))))) ⊢ ?B› ‹⟦insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 ?H))))) ⊢ ?B1; insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 ?H)))))) ⊢ ?B⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert (?B1 IMP ?Ba) ?H)))))) ⊢ ?B› ‹⟦insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 ?H)))))) ⊢ ?B1; insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 ?H))))))) ⊢ ?B⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 (insert (?B1 IMP ?Ba) ?H))))))) ⊢ ?B› ‹⟦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))))))) ⊢ ?B1; insert ?Ba (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)))))))) ⊢ ?B⟧ ⟹ 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 (?B1 IMP ?Ba) ?H)))))))) ⊢ ?B› ‹⟦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)))))))) ⊢ ?B1; insert ?Ba (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))))))))) ⊢ ?B⟧ ⟹ 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 (?B1 IMP ?Ba) ?H))))))))) ⊢ ?B›*), blast intro: thin1 (*‹?H ⊢ ?B ⟹ insert ?A ?H ⊢ ?B›*) SeqSubstFormP_eq (*‹⟦?H ⊢ SeqSubstFormP ?v ?tm ?x ?z ?s ?k; insert (SeqSubstFormP ?v ?tm ?y ?z ?s ?k) ?H ⊢ ?A⟧ ⟹ insert (?x EQ ?y) ?H ⊢ ?A›*))+) (*top goal: ‹⟦atom (i::name) ♯ (s::tm, s'::tm, v::tm, a::tm, x::tm, y::tm, y'::tm); atom (j::name) ♯ (s, s', v, a, x, i, x, y, y'); atom (j'::name) ♯ (s, s', v, a, x, i, j, x, y, y'); atom (k::name) ♯ (s, s', v, a, x, y, y', kk'::tm, i, j, j'); atom (k'::name) ♯ (s, s', v, a, x, y, y', k, i, j, j'); atom (l::name) ♯ (s, s', v, a, x, i, j, j', k, k'); atom (m::name) ♯ (s, s', v, a, i, j, j', k, k', l); atom (n::name) ♯ (s, s', v, a, i, j, j', k, k', l, m); atom (sm::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n); atom (sn::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm); atom (sm'::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn); atom (sn'::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm'); atom (m2::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn'); atom (n2::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2); atom (sm2::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2); atom (sn2::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2); atom (sm2'::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2, sn2); atom (sn2'::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2, sn2, sm2')⟧ ⟹ {Var sm2 EQ Var sm, Var sn2 EQ Var sn, SeqSubstFormP v a (Var sn) (Var sn') s (Var n) IMP SeqSubstFormP v a (Var sn) (Var sn2') s' (Var n2) IMP Var sn2' EQ Var sn', SeqSubstFormP v a (Var sm) (Var sm') s (Var m) IMP SeqSubstFormP v a (Var sm) (Var sm2') s' (Var m2) IMP Var sm2' EQ Var sm', Var j' EQ HPair (HPair Zero (HPair Zero (HPair Zero (HPair Zero Zero)))) (HPair (Var sm2') (Var sn2')), SeqSubstFormP v a (Var sn2) (Var sn2') s' (Var n2), SeqSubstFormP v a (Var sm2) (Var sm2') s' (Var m2), Var n2 IN Var k', Var m2 IN Var k', Var i EQ HPair (HPair Zero (HPair Zero (HPair Zero (HPair Zero Zero)))) (HPair (Var sm) (Var sn)), Var j EQ HPair (HPair Zero (HPair Zero (HPair Zero (HPair Zero Zero)))) (HPair (Var sm') (Var sn')), SeqSubstFormP v a (Var sn) (Var sn') s (Var n), SeqSubstFormP v a (Var sm) (Var sm') s (Var m), Var n IN Var k, Var m IN Var k, All2 l (Var k) (SyntaxN.All i (SyntaxN.All j (SyntaxN.All j' (SyntaxN.All k' (SeqSubstFormP v a (Var i) (Var j) s (Var l) IMP SeqSubstFormP v a (Var i) (Var j') s' (Var k') IMP Var j' EQ Var j))))), SeqSubstFormP v a (Var i) (Var j') s' (Var k'), SeqSubstFormP v a (Var i) (Var j) s (Var k), OrdP (Var k)} ⊢ Var j' EQ Var j› and 2 goals remain*) apply (blast intro: HPair_cong (*‹⟦(?H::fm set) ⊢ (?t::tm) EQ (?t'::tm); ?H ⊢ (?u::tm) EQ (?u'::tm)⟧ ⟹ ?H ⊢ HPair ?t ?u EQ HPair ?t' ?u'›*) Trans [OF Hyp Sym] (*‹⟦(?x::tm) EQ (?y::tm) ∈ (?H::fm set); ?H ⊢ (?z::tm) EQ ?y⟧ ⟹ ?H ⊢ ?x EQ ?z›*)) (*top goal: ‹⟦atom i ♯ (s, s', v, a, x, y, y'); atom j ♯ (s, s', v, a, x, i, x, y, y'); atom j' ♯ (s, s', v, a, x, i, j, x, y, y'); atom k ♯ (s, s', v, a, x, y, y', kk', i, j, j'); atom k' ♯ (s, s', v, a, x, y, y', k, i, j, j'); atom l ♯ (s, s', v, a, x, i, j, j', k, k'); atom m ♯ (s, s', v, a, i, j, j', k, k', l); atom n ♯ (s, s', v, a, i, j, j', k, k', l, m); atom sm ♯ (s, s', v, a, i, j, j', k, k', l, m, n); atom sn ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm); atom sm' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn); atom sn' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm'); atom m2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn'); atom n2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2); atom sm2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2); atom sn2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2); atom sm2' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2, sn2); atom sn2' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2, sn2, sm2')⟧ ⟹ {Var sm2' EQ Var sm', Var sn2' EQ Var sn', Var sm2 EQ Var sm, Var sn2 EQ Var sn, Var j' EQ HPair (HPair Zero (HPair Zero (HPair Zero (HPair Zero Zero)))) (HPair (Var sm2') (Var sn2')), SeqSubstFormP v a (Var sn2) (Var sn2') s' (Var n2), SeqSubstFormP v a (Var sm2) (Var sm2') s' (Var m2), Var n2 IN Var k', Var m2 IN Var k', Var i EQ HPair (HPair Zero (HPair Zero (HPair Zero (HPair Zero Zero)))) (HPair (Var sm) (Var sn)), Var j EQ HPair (HPair Zero (HPair Zero (HPair Zero (HPair Zero Zero)))) (HPair (Var sm') (Var sn')), SeqSubstFormP v a (Var sn) (Var sn') s (Var n), SeqSubstFormP v a (Var sm) (Var sm') s (Var m), Var n IN Var k, Var m IN Var k, All2 l (Var k) (SyntaxN.All i (SyntaxN.All j (SyntaxN.All j' (SyntaxN.All k' (SeqSubstFormP v a (Var i) (Var j) s (Var l) IMP SeqSubstFormP v a (Var i) (Var j') s' (Var k') IMP Var j' EQ Var j))))), SeqSubstFormP v a (Var i) (Var j') s' (Var k'), SeqSubstFormP v a (Var i) (Var j) s (Var k), OrdP (Var k)} ⊢ Var j' EQ Var j› and 2 goals remain*) apply ((rule Conj_EH (*‹insert ?A (insert ?B ?H) ⊢ ?C ⟹ insert (?A AND ?B) ?H ⊢ ?C› ‹insert ?A (insert ?Ba (insert ?A1.0 ?H)) ⊢ ?B ⟹ insert ?A1.0 (insert (?A AND ?Ba) ?H) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 ?H))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert (?A AND ?Ba) ?H)) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 ?H)))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert (?A AND ?Ba) ?H))) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 ?H))))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert (?A AND ?Ba) ?H)))) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 ?H)))))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert (?A AND ?Ba) ?H))))) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 ?H))))))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert (?A AND ?Ba) ?H)))))) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 ?H)))))))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 (insert (?A AND ?Ba) ?H))))))) ⊢ ?B› ‹insert ?A (insert ?Ba (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))))))))) ⊢ ?B ⟹ 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 (?A AND ?Ba) ?H)))))))) ⊢ ?B› ‹insert ?A (insert ?Ba (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)))))))))) ⊢ ?B ⟹ 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 (?A AND ?Ba) ?H))))))))) ⊢ ?B›*) Disj_EH (*‹⟦insert ?A ?H ⊢ ?C; insert ?B ?H ⊢ ?C⟧ ⟹ insert (?A OR ?B) ?H ⊢ ?C› ‹⟦insert ?A (insert ?A1.0 ?H) ⊢ ?B; insert ?Ba (insert ?A1.0 ?H) ⊢ ?B⟧ ⟹ insert ?A1.0 (insert (?A OR ?Ba) ?H) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 ?H)) ⊢ ?B; insert ?Ba (insert ?A1.0 (insert ?A2.0 ?H)) ⊢ ?B⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert (?A OR ?Ba) ?H)) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 ?H))) ⊢ ?B; insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 ?H))) ⊢ ?B⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert (?A OR ?Ba) ?H))) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 ?H)))) ⊢ ?B; insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 ?H)))) ⊢ ?B⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert (?A OR ?Ba) ?H)))) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 ?H))))) ⊢ ?B; insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 ?H))))) ⊢ ?B⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert (?A OR ?Ba) ?H))))) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 ?H)))))) ⊢ ?B; insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 ?H)))))) ⊢ ?B⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert (?A OR ?Ba) ?H)))))) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 ?H))))))) ⊢ ?B; insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 ?H))))))) ⊢ ?B⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 (insert (?A OR ?Ba) ?H))))))) ⊢ ?B› ‹⟦insert ?A (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)))))))) ⊢ ?B; insert ?Ba (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)))))))) ⊢ ?B⟧ ⟹ 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 (?A OR ?Ba) ?H)))))))) ⊢ ?B› ‹⟦insert ?A (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))))))))) ⊢ ?B; insert ?Ba (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))))))))) ⊢ ?B⟧ ⟹ 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 (?A OR ?Ba) ?H))))))))) ⊢ ?B›*))+) (*top goal: ‹⟦atom (i::name) ♯ (s::tm, s'::tm, v::tm, a::tm, x::tm, y::tm, y'::tm); atom (j::name) ♯ (s, s', v, a, x, i, x, y, y'); atom (j'::name) ♯ (s, s', v, a, x, i, j, x, y, y'); atom (k::name) ♯ (s, s', v, a, x, y, y', kk'::tm, i, j, j'); atom (k'::name) ♯ (s, s', v, a, x, y, y', k, i, j, j'); atom (l::name) ♯ (s, s', v, a, x, i, j, j', k, k'); atom (m::name) ♯ (s, s', v, a, i, j, j', k, k', l); atom (n::name) ♯ (s, s', v, a, i, j, j', k, k', l, m); atom (sm::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n); atom (sn::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm); atom (sm'::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn); atom (sn'::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm'); atom (m2::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn'); atom (n2::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2); atom (sm2::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2); atom (sn2::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2); atom (sm2'::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2, sn2); atom (sn2'::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2, sn2, sm2')⟧ ⟹ {Var i EQ Q_Neg (Var sm2) AND Var j' EQ Q_Neg (Var sm2') OR Var i EQ Q_Ex (Var sm2) AND Var j' EQ Q_Ex (Var sm2'), SeqSubstFormP v a (Var sn2) (Var sn2') s' (Var n2), SeqSubstFormP v a (Var sm2) (Var sm2') s' (Var m2), Var n2 IN Var k', Var m2 IN Var k', Var i EQ Q_Disj (Var sm) (Var sn), Var j EQ Q_Disj (Var sm') (Var sn'), SeqSubstFormP v a (Var sn) (Var sn') s (Var n), SeqSubstFormP v a (Var sm) (Var sm') s (Var m), Var n IN Var k, Var m IN Var k, All2 l (Var k) (SyntaxN.All i (SyntaxN.All j (SyntaxN.All j' (SyntaxN.All k' (SeqSubstFormP v a (Var i) (Var j) s (Var l) IMP SeqSubstFormP v a (Var i) (Var j') s' (Var k') IMP Var j' EQ Var j))))), SeqSubstFormP v a (Var i) (Var j') s' (Var k'), SeqSubstFormP v a (Var i) (Var j) s (Var k), OrdP (Var k)} ⊢ Var j' EQ Var j› and 1 goal remains*) apply (rule Eq_Trans_E [OF Hyp] (*‹⟦?x EQ ?u ∈ ?H; insert (?t EQ ?u) ?H ⊢ ?A⟧ ⟹ insert (?x EQ ?t) ?H ⊢ ?A›*), blast, force simp add: HTS (*‹0 < ?n ⟹ HTuple ?n = HPair Zero (HTuple (?n - 1))› ‹HTuple 0 = HPair Zero Zero› ‹HTuple (Suc ?k) = HPair Zero (HTuple ?k)›*)) (*top goal: ‹⟦atom i ♯ (s, s', v, a, x, y, y'); atom j ♯ (s, s', v, a, x, i, x, y, y'); atom j' ♯ (s, s', v, a, x, i, j, x, y, y'); atom k ♯ (s, s', v, a, x, y, y', kk', i, j, j'); atom k' ♯ (s, s', v, a, x, y, y', k, i, j, j'); atom l ♯ (s, s', v, a, x, i, j, j', k, k'); atom m ♯ (s, s', v, a, i, j, j', k, k', l); atom n ♯ (s, s', v, a, i, j, j', k, k', l, m); atom sm ♯ (s, s', v, a, i, j, j', k, k', l, m, n); atom sn ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm); atom sm' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn); atom sn' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm'); atom m2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn'); atom n2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2); atom sm2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2); atom sn2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2); atom sm2' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2, sn2); atom sn2' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2, sn2, sm2')⟧ ⟹ {Var i EQ Q_Neg (Var sm2), Var j' EQ Q_Neg (Var sm2'), SeqSubstFormP v a (Var sn2) (Var sn2') s' (Var n2), SeqSubstFormP v a (Var sm2) (Var sm2') s' (Var m2), Var n2 IN Var k', Var m2 IN Var k', Var i EQ Q_Disj (Var sm) (Var sn), Var j EQ Q_Disj (Var sm') (Var sn'), SeqSubstFormP v a (Var sn) (Var sn') s (Var n), SeqSubstFormP v a (Var sm) (Var sm') s (Var m), Var n IN Var k, Var m IN Var k, All2 l (Var k) (SyntaxN.All i (SyntaxN.All j (SyntaxN.All j' (SyntaxN.All k' (SeqSubstFormP v a (Var i) (Var j) s (Var l) IMP SeqSubstFormP v a (Var i) (Var j') s' (Var k') IMP Var j' EQ Var j))))), SeqSubstFormP v a (Var i) (Var j') s' (Var k'), SeqSubstFormP v a (Var i) (Var j) s (Var k), OrdP (Var k)} ⊢ Var j' EQ Var j› and 2 goals remain*) apply (rule Conj_EH (*‹insert ?A (insert ?B ?H) ⊢ ?C ⟹ insert (?A AND ?B) ?H ⊢ ?C› ‹insert ?A (insert ?Ba (insert ?A1.0 ?H)) ⊢ ?B ⟹ insert ?A1.0 (insert (?A AND ?Ba) ?H) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 ?H))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert (?A AND ?Ba) ?H)) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 ?H)))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert (?A AND ?Ba) ?H))) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 ?H))))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert (?A AND ?Ba) ?H)))) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 ?H)))))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert (?A AND ?Ba) ?H))))) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 ?H))))))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert (?A AND ?Ba) ?H)))))) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 ?H)))))))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 (insert (?A AND ?Ba) ?H))))))) ⊢ ?B› ‹insert ?A (insert ?Ba (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))))))))) ⊢ ?B ⟹ 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 (?A AND ?Ba) ?H)))))))) ⊢ ?B› ‹insert ?A (insert ?Ba (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)))))))))) ⊢ ?B ⟹ 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 (?A AND ?Ba) ?H))))))))) ⊢ ?B›*)) (*top goal: ‹⟦atom i ♯ (s, s', v, a, x, y, y'); atom j ♯ (s, s', v, a, x, i, x, y, y'); atom j' ♯ (s, s', v, a, x, i, j, x, y, y'); atom k ♯ (s, s', v, a, x, y, y', kk', i, j, j'); atom k' ♯ (s, s', v, a, x, y, y', k, i, j, j'); atom l ♯ (s, s', v, a, x, i, j, j', k, k'); atom m ♯ (s, s', v, a, i, j, j', k, k', l); atom n ♯ (s, s', v, a, i, j, j', k, k', l, m); atom sm ♯ (s, s', v, a, i, j, j', k, k', l, m, n); atom sn ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm); atom sm' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn); atom sn' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm'); atom m2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn'); atom n2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2); atom sm2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2); atom sn2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2); atom sm2' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2, sn2); atom sn2' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2, sn2, sm2')⟧ ⟹ {Var i EQ Q_Ex (Var sm2) AND Var j' EQ Q_Ex (Var sm2'), SeqSubstFormP v a (Var sn2) (Var sn2') s' (Var n2), SeqSubstFormP v a (Var sm2) (Var sm2') s' (Var m2), Var n2 IN Var k', Var m2 IN Var k', Var i EQ Q_Disj (Var sm) (Var sn), Var j EQ Q_Disj (Var sm') (Var sn'), SeqSubstFormP v a (Var sn) (Var sn') s (Var n), SeqSubstFormP v a (Var sm) (Var sm') s (Var m), Var n IN Var k, Var m IN Var k, All2 l (Var k) (SyntaxN.All i (SyntaxN.All j (SyntaxN.All j' (SyntaxN.All k' (SeqSubstFormP v a (Var i) (Var j) s (Var l) IMP SeqSubstFormP v a (Var i) (Var j') s' (Var k') IMP Var j' EQ Var j))))), SeqSubstFormP v a (Var i) (Var j') s' (Var k'), SeqSubstFormP v a (Var i) (Var j) s (Var k), OrdP (Var k)} ⊢ Var j' EQ Var j› and 1 goal remains*) apply (rule Eq_Trans_E [OF Hyp] (*‹⟦?x EQ ?u ∈ ?H; insert (?t EQ ?u) ?H ⊢ ?A⟧ ⟹ insert (?x EQ ?t) ?H ⊢ ?A›*), blast, force simp add: HTS (*‹0 < ?n ⟹ HTuple ?n = HPair Zero (HTuple (?n - 1))› ‹HTuple 0 = HPair Zero Zero› ‹HTuple (Suc ?k) = HPair Zero (HTuple ?k)›*)) (*top goal: ‹⟦atom i ♯ (s, s', v, a, x, y, y'); atom j ♯ (s, s', v, a, x, i, x, y, y'); atom j' ♯ (s, s', v, a, x, i, j, x, y, y'); atom k ♯ (s, s', v, a, x, y, y', kk', i, j, j'); atom k' ♯ (s, s', v, a, x, y, y', k, i, j, j'); atom l ♯ (s, s', v, a, x, i, j, j', k, k'); atom m ♯ (s, s', v, a, i, j, j', k, k', l); atom n ♯ (s, s', v, a, i, j, j', k, k', l, m); atom sm ♯ (s, s', v, a, i, j, j', k, k', l, m, n); atom sn ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm); atom sm' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn); atom sn' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm'); atom m2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn'); atom n2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2); atom sm2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2); atom sn2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2); atom sm2' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2, sn2); atom sn2' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2, sn2, sm2')⟧ ⟹ {Var i EQ Q_Ex (Var sm2), Var j' EQ Q_Ex (Var sm2'), SeqSubstFormP v a (Var sn2) (Var sn2') s' (Var n2), SeqSubstFormP v a (Var sm2) (Var sm2') s' (Var m2), Var n2 IN Var k', Var m2 IN Var k', Var i EQ Q_Disj (Var sm) (Var sn), Var j EQ Q_Disj (Var sm') (Var sn'), SeqSubstFormP v a (Var sn) (Var sn') s (Var n), SeqSubstFormP v a (Var sm) (Var sm') s (Var m), Var n IN Var k, Var m IN Var k, All2 l (Var k) (SyntaxN.All i (SyntaxN.All j (SyntaxN.All j' (SyntaxN.All k' (SeqSubstFormP v a (Var i) (Var j) s (Var l) IMP SeqSubstFormP v a (Var i) (Var j') s' (Var k') IMP Var j' EQ Var j))))), SeqSubstFormP v a (Var i) (Var j') s' (Var k'), SeqSubstFormP v a (Var i) (Var j) s (Var k), OrdP (Var k)} ⊢ Var j' EQ Var j› and 1 goal remains*) apply ((rule Conj_EH (*‹insert ?A (insert ?B ?H) ⊢ ?C ⟹ insert (?A AND ?B) ?H ⊢ ?C› ‹insert ?A (insert ?Ba (insert ?A1.0 ?H)) ⊢ ?B ⟹ insert ?A1.0 (insert (?A AND ?Ba) ?H) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 ?H))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert (?A AND ?Ba) ?H)) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 ?H)))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert (?A AND ?Ba) ?H))) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 ?H))))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert (?A AND ?Ba) ?H)))) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 ?H)))))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert (?A AND ?Ba) ?H))))) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 ?H))))))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert (?A AND ?Ba) ?H)))))) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 ?H)))))))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 (insert (?A AND ?Ba) ?H))))))) ⊢ ?B› ‹insert ?A (insert ?Ba (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))))))))) ⊢ ?B ⟹ 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 (?A AND ?Ba) ?H)))))))) ⊢ ?B› ‹insert ?A (insert ?Ba (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)))))))))) ⊢ ?B ⟹ 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 (?A AND ?Ba) ?H))))))))) ⊢ ?B›*) Disj_EH (*‹⟦insert ?A ?H ⊢ ?C; insert ?B ?H ⊢ ?C⟧ ⟹ insert (?A OR ?B) ?H ⊢ ?C› ‹⟦insert ?A (insert ?A1.0 ?H) ⊢ ?B; insert ?Ba (insert ?A1.0 ?H) ⊢ ?B⟧ ⟹ insert ?A1.0 (insert (?A OR ?Ba) ?H) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 ?H)) ⊢ ?B; insert ?Ba (insert ?A1.0 (insert ?A2.0 ?H)) ⊢ ?B⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert (?A OR ?Ba) ?H)) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 ?H))) ⊢ ?B; insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 ?H))) ⊢ ?B⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert (?A OR ?Ba) ?H))) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 ?H)))) ⊢ ?B; insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 ?H)))) ⊢ ?B⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert (?A OR ?Ba) ?H)))) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 ?H))))) ⊢ ?B; insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 ?H))))) ⊢ ?B⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert (?A OR ?Ba) ?H))))) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 ?H)))))) ⊢ ?B; insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 ?H)))))) ⊢ ?B⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert (?A OR ?Ba) ?H)))))) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 ?H))))))) ⊢ ?B; insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 ?H))))))) ⊢ ?B⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 (insert (?A OR ?Ba) ?H))))))) ⊢ ?B› ‹⟦insert ?A (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)))))))) ⊢ ?B; insert ?Ba (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)))))))) ⊢ ?B⟧ ⟹ 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 (?A OR ?Ba) ?H)))))))) ⊢ ?B› ‹⟦insert ?A (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))))))))) ⊢ ?B; insert ?Ba (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))))))))) ⊢ ?B⟧ ⟹ 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 (?A OR ?Ba) ?H))))))))) ⊢ ?B›*) Ex_EH (*‹⟦insert ?A ?H ⊢ ?B; atom ?i ♯ ?B; ∀C∈?H. atom ?i ♯ C⟧ ⟹ insert (SyntaxN.Ex ?i ?A) ?H ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 ?H) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 ?H. atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert (SyntaxN.Ex ?i ?A) ?H) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 ?H)) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 ?H). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert (SyntaxN.Ex ?i ?A) ?H)) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 ?H))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 ?H)). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert (SyntaxN.Ex ?i ?A) ?H))) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 ?H)))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 ?H))). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert (SyntaxN.Ex ?i ?A) ?H)))) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 ?H))))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 ?H)))). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert (SyntaxN.Ex ?i ?A) ?H))))) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 ?H)))))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 ?H))))). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert (SyntaxN.Ex ?i ?A) ?H)))))) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 ?H))))))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 ?H)))))). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 (insert (SyntaxN.Ex ?i ?A) ?H))))))) ⊢ ?B› ‹⟦insert ?A (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)))))))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈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))))))). atom ?i ♯ C⟧ ⟹ 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 (SyntaxN.Ex ?i ?A) ?H)))))))) ⊢ ?B› ‹⟦insert ?A (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))))))))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈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)))))))). atom ?i ♯ C⟧ ⟹ 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 (SyntaxN.Ex ?i ?A) ?H))))))))) ⊢ ?B›*))+) (*goal: ‹⟦atom (i::name) ♯ (s::tm, s'::tm, v::tm, a::tm, x::tm, y::tm, y'::tm); atom (j::name) ♯ (s, s', v, a, x, i, x, y, y'); atom (j'::name) ♯ (s, s', v, a, x, i, j, x, y, y'); atom (k::name) ♯ (s, s', v, a, x, y, y', kk'::tm, i, j, j'); atom (k'::name) ♯ (s, s', v, a, x, y, y', k, i, j, j'); atom (l::name) ♯ (s, s', v, a, x, i, j, j', k, k'); atom (m::name) ♯ (s, s', v, a, i, j, j', k, k', l); atom (n::name) ♯ (s, s', v, a, i, j, j', k, k', l, m); atom (sm::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n); atom (sn::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm); atom (sm'::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn); atom (sn'::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm'); atom (m2::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn'); atom (n2::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2); atom (sm2::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2); atom (sn2::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2); atom (sm2'::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2, sn2); atom (sn2'::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2, sn2, sm2')⟧ ⟹ {Var i EQ Q_Neg (Var sm) AND Var j EQ Q_Neg (Var sm') OR Var i EQ Q_Ex (Var sm) AND Var j EQ Q_Ex (Var sm'), SeqSubstFormP v a (Var sn) (Var sn') s (Var n), SeqSubstFormP v a (Var sm) (Var sm') s (Var m), Var n IN Var k, Var m IN Var k, SyntaxN.Ex m2 (SyntaxN.Ex n2 (SyntaxN.Ex sm2 (SyntaxN.Ex sm2' (SyntaxN.Ex sn2 (SyntaxN.Ex sn2' (Var m2 IN Var k' AND Var n2 IN Var k' AND SeqSubstFormP v a (Var sm2) (Var sm2') s' (Var m2) AND SeqSubstFormP v a (Var sn2) (Var sn2') s' (Var n2) AND (Var i EQ Q_Disj (Var sm2) (Var sn2) AND Var j' EQ Q_Disj (Var sm2') (Var sn2') OR Var i EQ Q_Neg (Var sm2) AND Var j' EQ Q_Neg (Var sm2') OR Var i EQ Q_Ex (Var sm2) AND Var j' EQ Q_Ex (Var sm2')))))))), All2 l (Var k) (SyntaxN.All i (SyntaxN.All j (SyntaxN.All j' (SyntaxN.All k' (SeqSubstFormP v a (Var i) (Var j) s (Var l) IMP SeqSubstFormP v a (Var i) (Var j') s' (Var k') IMP Var j' EQ Var j))))), SeqSubstFormP v a (Var i) (Var j') s' (Var k'), SeqSubstFormP v a (Var i) (Var j) s (Var k), OrdP (Var k)} ⊢ Var j' EQ Var j›*) apply simp_all (*top goal: ‹⟦atom i ♯ (s, s', v, a, x, y, y'); atom j ♯ (s, s', v, a, x, i, x, y, y'); atom j' ♯ (s, s', v, a, x, i, j, x, y, y'); atom k ♯ (s, s', v, a, x, y, y', kk', i, j, j'); atom k' ♯ (s, s', v, a, x, y, y', k, i, j, j'); atom l ♯ (s, s', v, a, x, i, j, j', k, k'); atom m ♯ (s, s', v, a, i, j, j', k, k', l); atom n ♯ (s, s', v, a, i, j, j', k, k', l, m); atom sm ♯ (s, s', v, a, i, j, j', k, k', l, m, n); atom sn ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm); atom sm' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn); atom sn' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm'); atom m2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn'); atom n2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2); atom sm2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2); atom sn2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2); atom sm2' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2, sn2); atom sn2' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2, sn2, sm2')⟧ ⟹ {Var i EQ Q_Disj (Var sm2) (Var sn2), Var j' EQ Q_Disj (Var sm2') (Var sn2'), SeqSubstFormP v a (Var sn2) (Var sn2') s' (Var n2), SeqSubstFormP v a (Var sm2) (Var sm2') s' (Var m2), Var n2 IN Var k', Var m2 IN Var k', Var i EQ Q_Neg (Var sm), Var j EQ Q_Neg (Var sm'), SeqSubstFormP v a (Var sn) (Var sn') s (Var n), SeqSubstFormP v a (Var sm) (Var sm') s (Var m), Var n IN Var k, Var m IN Var k, All2 l (Var k) (SyntaxN.All i (SyntaxN.All j (SyntaxN.All j' (SyntaxN.All k' (SeqSubstFormP v a (Var i) (Var j) s (Var l) IMP SeqSubstFormP v a (Var i) (Var j') s' (Var k') IMP Var j' EQ Var j))))), SeqSubstFormP v a (Var i) (Var j') s' (Var k'), SeqSubstFormP v a (Var i) (Var j) s (Var k), OrdP (Var k)} ⊢ Var j' EQ Var j› and 14 goals remain*) apply (rule Eq_Trans_E [OF Hyp] (*‹⟦?x EQ ?u ∈ ?H; insert (?t EQ ?u) ?H ⊢ ?A⟧ ⟹ insert (?x EQ ?t) ?H ⊢ ?A›*), blast, force simp add: HTS (*‹0 < ?n ⟹ HTuple ?n = HPair Zero (HTuple (?n - 1))› ‹HTuple 0 = HPair Zero Zero› ‹HTuple (Suc ?k) = HPair Zero (HTuple ?k)›*)) (*top goal: ‹⟦atom i ♯ (s, s', v, a, x, y, y'); atom j ♯ (s, s', v, a, x, i, x, y, y'); atom j' ♯ (s, s', v, a, x, i, j, x, y, y'); atom k ♯ (s, s', v, a, x, y, y', kk', i, j, j'); atom k' ♯ (s, s', v, a, x, y, y', k, i, j, j'); atom l ♯ (s, s', v, a, x, i, j, j', k, k'); atom m ♯ (s, s', v, a, i, j, j', k, k', l); atom n ♯ (s, s', v, a, i, j, j', k, k', l, m); atom sm ♯ (s, s', v, a, i, j, j', k, k', l, m, n); atom sn ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm); atom sm' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn); atom sn' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm'); atom m2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn'); atom n2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2); atom sm2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2); atom sn2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2); atom sm2' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2, sn2); atom sn2' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2, sn2, sm2')⟧ ⟹ {Var i EQ Q_Disj (Var sm2) (Var sn2), Var j' EQ Q_Disj (Var sm2') (Var sn2'), SeqSubstFormP v a (Var sn2) (Var sn2') s' (Var n2), SeqSubstFormP v a (Var sm2) (Var sm2') s' (Var m2), Var n2 IN Var k', Var m2 IN Var k', Var i EQ Q_Neg (Var sm), Var j EQ Q_Neg (Var sm'), SeqSubstFormP v a (Var sn) (Var sn') s (Var n), SeqSubstFormP v a (Var sm) (Var sm') s (Var m), Var n IN Var k, Var m IN Var k, All2 l (Var k) (SyntaxN.All i (SyntaxN.All j (SyntaxN.All j' (SyntaxN.All k' (SeqSubstFormP v a (Var i) (Var j) s (Var l) IMP SeqSubstFormP v a (Var i) (Var j') s' (Var k') IMP Var j' EQ Var j))))), SeqSubstFormP v a (Var i) (Var j') s' (Var k'), SeqSubstFormP v a (Var i) (Var j) s (Var k), OrdP (Var k)} ⊢ Var j' EQ Var j› and 2 goals remain*) apply ((rule Conj_EH (*‹insert ?A (insert ?B ?H) ⊢ ?C ⟹ insert (?A AND ?B) ?H ⊢ ?C› ‹insert ?A (insert ?Ba (insert ?A1.0 ?H)) ⊢ ?B ⟹ insert ?A1.0 (insert (?A AND ?Ba) ?H) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 ?H))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert (?A AND ?Ba) ?H)) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 ?H)))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert (?A AND ?Ba) ?H))) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 ?H))))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert (?A AND ?Ba) ?H)))) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 ?H)))))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert (?A AND ?Ba) ?H))))) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 ?H))))))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert (?A AND ?Ba) ?H)))))) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 ?H)))))))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 (insert (?A AND ?Ba) ?H))))))) ⊢ ?B› ‹insert ?A (insert ?Ba (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))))))))) ⊢ ?B ⟹ 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 (?A AND ?Ba) ?H)))))))) ⊢ ?B› ‹insert ?A (insert ?Ba (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)))))))))) ⊢ ?B ⟹ 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 (?A AND ?Ba) ?H))))))))) ⊢ ?B›*) Disj_EH (*‹⟦insert ?A ?H ⊢ ?C; insert ?B ?H ⊢ ?C⟧ ⟹ insert (?A OR ?B) ?H ⊢ ?C› ‹⟦insert ?A (insert ?A1.0 ?H) ⊢ ?B; insert ?Ba (insert ?A1.0 ?H) ⊢ ?B⟧ ⟹ insert ?A1.0 (insert (?A OR ?Ba) ?H) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 ?H)) ⊢ ?B; insert ?Ba (insert ?A1.0 (insert ?A2.0 ?H)) ⊢ ?B⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert (?A OR ?Ba) ?H)) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 ?H))) ⊢ ?B; insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 ?H))) ⊢ ?B⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert (?A OR ?Ba) ?H))) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 ?H)))) ⊢ ?B; insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 ?H)))) ⊢ ?B⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert (?A OR ?Ba) ?H)))) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 ?H))))) ⊢ ?B; insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 ?H))))) ⊢ ?B⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert (?A OR ?Ba) ?H))))) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 ?H)))))) ⊢ ?B; insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 ?H)))))) ⊢ ?B⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert (?A OR ?Ba) ?H)))))) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 ?H))))))) ⊢ ?B; insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 ?H))))))) ⊢ ?B⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 (insert (?A OR ?Ba) ?H))))))) ⊢ ?B› ‹⟦insert ?A (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)))))))) ⊢ ?B; insert ?Ba (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)))))))) ⊢ ?B⟧ ⟹ 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 (?A OR ?Ba) ?H)))))))) ⊢ ?B› ‹⟦insert ?A (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))))))))) ⊢ ?B; insert ?Ba (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))))))))) ⊢ ?B⟧ ⟹ 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 (?A OR ?Ba) ?H))))))))) ⊢ ?B›*))+) (*top goal: ‹⟦atom (i::name) ♯ (s::tm, s'::tm, v::tm, a::tm, x::tm, y::tm, y'::tm); atom (j::name) ♯ (s, s', v, a, x, i, x, y, y'); atom (j'::name) ♯ (s, s', v, a, x, i, j, x, y, y'); atom (k::name) ♯ (s, s', v, a, x, y, y', kk'::tm, i, j, j'); atom (k'::name) ♯ (s, s', v, a, x, y, y', k, i, j, j'); atom (l::name) ♯ (s, s', v, a, x, i, j, j', k, k'); atom (m::name) ♯ (s, s', v, a, i, j, j', k, k', l); atom (n::name) ♯ (s, s', v, a, i, j, j', k, k', l, m); atom (sm::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n); atom (sn::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm); atom (sm'::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn); atom (sn'::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm'); atom (m2::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn'); atom (n2::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2); atom (sm2::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2); atom (sn2::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2); atom (sm2'::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2, sn2); atom (sn2'::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2, sn2, sm2')⟧ ⟹ {Var i EQ Q_Neg (Var sm2) AND Var j' EQ Q_Neg (Var sm2') OR Var i EQ Q_Ex (Var sm2) AND Var j' EQ Q_Ex (Var sm2'), SeqSubstFormP v a (Var sn2) (Var sn2') s' (Var n2), SeqSubstFormP v a (Var sm2) (Var sm2') s' (Var m2), Var n2 IN Var k', Var m2 IN Var k', Var i EQ Q_Neg (Var sm), Var j EQ Q_Neg (Var sm'), SeqSubstFormP v a (Var sn) (Var sn') s (Var n), SeqSubstFormP v a (Var sm) (Var sm') s (Var m), Var n IN Var k, Var m IN Var k, All2 l (Var k) (SyntaxN.All i (SyntaxN.All j (SyntaxN.All j' (SyntaxN.All k' (SeqSubstFormP v a (Var i) (Var j) s (Var l) IMP SeqSubstFormP v a (Var i) (Var j') s' (Var k') IMP Var j' EQ Var j))))), SeqSubstFormP v a (Var i) (Var j') s' (Var k'), SeqSubstFormP v a (Var i) (Var j) s (Var k), OrdP (Var k)} ⊢ Var j' EQ Var j› and 1 goal remains*) apply (rule Eq_Trans_E [OF Hyp] (*‹⟦?x EQ ?u ∈ ?H; insert (?t EQ ?u) ?H ⊢ ?A⟧ ⟹ insert (?x EQ ?t) ?H ⊢ ?A›*), blast, clarify) (*top goal: ‹⟦atom i ♯ (s, s', v, a, x, y, y'); atom j ♯ (s, s', v, a, x, i, x, y, y'); atom j' ♯ (s, s', v, a, x, i, j, x, y, y'); atom k ♯ (s, s', v, a, x, y, y', kk', i, j, j'); atom k' ♯ (s, s', v, a, x, y, y', k, i, j, j'); atom l ♯ (s, s', v, a, x, i, j, j', k, k'); atom m ♯ (s, s', v, a, i, j, j', k, k', l); atom n ♯ (s, s', v, a, i, j, j', k, k', l, m); atom sm ♯ (s, s', v, a, i, j, j', k, k', l, m, n); atom sn ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm); atom sm' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn); atom sn' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm'); atom m2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn'); atom n2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2); atom sm2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2); atom sn2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2); atom sm2' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2, sn2); atom sn2' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2, sn2, sm2')⟧ ⟹ {Var i EQ Q_Neg (Var sm2), Var j' EQ Q_Neg (Var sm2'), SeqSubstFormP v a (Var sn2) (Var sn2') s' (Var n2), SeqSubstFormP v a (Var sm2) (Var sm2') s' (Var m2), Var n2 IN Var k', Var m2 IN Var k', Var i EQ Q_Neg (Var sm), Var j EQ Q_Neg (Var sm'), SeqSubstFormP v a (Var sn) (Var sn') s (Var n), SeqSubstFormP v a (Var sm) (Var sm') s (Var m), Var n IN Var k, Var m IN Var k, All2 l (Var k) (SyntaxN.All i (SyntaxN.All j (SyntaxN.All j' (SyntaxN.All k' (SeqSubstFormP v a (Var i) (Var j) s (Var l) IMP SeqSubstFormP v a (Var i) (Var j') s' (Var k') IMP Var j' EQ Var j))))), SeqSubstFormP v a (Var i) (Var j') s' (Var k'), SeqSubstFormP v a (Var i) (Var j) s (Var k), OrdP (Var k)} ⊢ Var j' EQ Var j› and 2 goals remain*) apply (rule thin1 (*‹?H ⊢ ?B ⟹ insert ?A ?H ⊢ ?B›*)) (*top goal: ‹⟦atom i ♯ (s, s', v, a, x, y, y'); atom j ♯ (s, s', v, a, x, i, x, y, y'); atom j' ♯ (s, s', v, a, x, i, j, x, y, y'); atom k ♯ (s, s', v, a, x, y, y', kk', i, j, j'); atom k' ♯ (s, s', v, a, x, y, y', k, i, j, j'); atom l ♯ (s, s', v, a, x, i, j, j', k, k'); atom m ♯ (s, s', v, a, i, j, j', k, k', l); atom n ♯ (s, s', v, a, i, j, j', k, k', l, m); atom sm ♯ (s, s', v, a, i, j, j', k, k', l, m, n); atom sn ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm); atom sm' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn); atom sn' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm'); atom m2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn'); atom n2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2); atom sm2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2); atom sn2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2); atom sm2' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2, sn2); atom sn2' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2, sn2, sm2')⟧ ⟹ {HTuple 4 EQ HTuple 4, Var sm2 EQ Var sm, Var j' EQ Q_Neg (Var sm2'), SeqSubstFormP v a (Var sn2) (Var sn2') s' (Var n2), SeqSubstFormP v a (Var sm2) (Var sm2') s' (Var m2), Var n2 IN Var k', Var m2 IN Var k', Var i EQ Q_Neg (Var sm), Var j EQ Q_Neg (Var sm'), SeqSubstFormP v a (Var sn) (Var sn') s (Var n), SeqSubstFormP v a (Var sm) (Var sm') s (Var m), Var n IN Var k, Var m IN Var k, All2 l (Var k) (SyntaxN.All i (SyntaxN.All j (SyntaxN.All j' (SyntaxN.All k' (SeqSubstFormP v a (Var i) (Var j) s (Var l) IMP SeqSubstFormP v a (Var i) (Var j') s' (Var k') IMP Var j' EQ Var j))))), SeqSubstFormP v a (Var i) (Var j') s' (Var k'), SeqSubstFormP v a (Var i) (Var j) s (Var k), OrdP (Var k)} ⊢ Var j' EQ Var j› and 2 goals remain*) apply (rule All_E' [OF Hyp, where x="Var m"] (*‹⟦SyntaxN.All ?i ?A ∈ ?H; insert (?A(?i::=Var m)) ?H ⊢ ?B⟧ ⟹ ?H ⊢ ?B›*), blast, simp) (*top goal: ‹⟦atom i ♯ (s, s', v, a, x, y, y'); atom j ♯ (s, s', v, a, x, i, x, y, y'); atom j' ♯ (s, s', v, a, x, i, j, x, y, y'); atom k ♯ (s, s', v, a, x, y, y', kk', i, j, j'); atom k' ♯ (s, s', v, a, x, y, y', k, i, j, j'); atom l ♯ (s, s', v, a, x, i, j, j', k, k'); atom m ♯ (s, s', v, a, i, j, j', k, k', l); atom n ♯ (s, s', v, a, i, j, j', k, k', l, m); atom sm ♯ (s, s', v, a, i, j, j', k, k', l, m, n); atom sn ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm); atom sm' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn); atom sn' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm'); atom m2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn'); atom n2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2); atom sm2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2); atom sn2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2); atom sm2' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2, sn2); atom sn2' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2, sn2, sm2')⟧ ⟹ {Var sm2 EQ Var sm, Var j' EQ Q_Neg (Var sm2'), SeqSubstFormP v a (Var sn2) (Var sn2') s' (Var n2), SeqSubstFormP v a (Var sm2) (Var sm2') s' (Var m2), Var n2 IN Var k', Var m2 IN Var k', Var i EQ Q_Neg (Var sm), Var j EQ Q_Neg (Var sm'), SeqSubstFormP v a (Var sn) (Var sn') s (Var n), SeqSubstFormP v a (Var sm) (Var sm') s (Var m), Var n IN Var k, Var m IN Var k, All2 l (Var k) (SyntaxN.All i (SyntaxN.All j (SyntaxN.All j' (SyntaxN.All k' (SeqSubstFormP v a (Var i) (Var j) s (Var l) IMP SeqSubstFormP v a (Var i) (Var j') s' (Var k') IMP Var j' EQ Var j))))), SeqSubstFormP v a (Var i) (Var j') s' (Var k'), SeqSubstFormP v a (Var i) (Var j) s (Var k), OrdP (Var k)} ⊢ Var j' EQ Var j› and 2 goals remain*) apply ((rule Disj_EH (*‹⟦insert (?A::fm) (?H::fm set) ⊢ (?C::fm); insert (?B::fm) ?H ⊢ ?C⟧ ⟹ insert (?A OR ?B) ?H ⊢ ?C› ‹⟦insert (?A::fm) (insert (?A1.0::fm) (?H::fm set)) ⊢ (?B::fm); insert (?Ba::fm) (insert ?A1.0 ?H) ⊢ ?B⟧ ⟹ insert ?A1.0 (insert (?A OR ?Ba) ?H) ⊢ ?B› ‹⟦insert (?A::fm) (insert (?A1.0::fm) (insert (?A2.0::fm) (?H::fm set))) ⊢ (?B::fm); insert (?Ba::fm) (insert ?A1.0 (insert ?A2.0 ?H)) ⊢ ?B⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert (?A OR ?Ba) ?H)) ⊢ ?B› ‹⟦insert (?A::fm) (insert (?A1.0::fm) (insert (?A2.0::fm) (insert (?A3.0::fm) (?H::fm set)))) ⊢ (?B::fm); insert (?Ba::fm) (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 ?H))) ⊢ ?B⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert (?A OR ?Ba) ?H))) ⊢ ?B› ‹⟦insert (?A::fm) (insert (?A1.0::fm) (insert (?A2.0::fm) (insert (?A3.0::fm) (insert (?A4.0::fm) (?H::fm set))))) ⊢ (?B::fm); insert (?Ba::fm) (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 ?H)))) ⊢ ?B⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert (?A OR ?Ba) ?H)))) ⊢ ?B› ‹⟦insert (?A::fm) (insert (?A1.0::fm) (insert (?A2.0::fm) (insert (?A3.0::fm) (insert (?A4.0::fm) (insert (?A5.0::fm) (?H::fm set)))))) ⊢ (?B::fm); insert (?Ba::fm) (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 ?H))))) ⊢ ?B⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert (?A OR ?Ba) ?H))))) ⊢ ?B› ‹⟦insert (?A::fm) (insert (?A1.0::fm) (insert (?A2.0::fm) (insert (?A3.0::fm) (insert (?A4.0::fm) (insert (?A5.0::fm) (insert (?A6.0::fm) (?H::fm set))))))) ⊢ (?B::fm); insert (?Ba::fm) (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 ?H)))))) ⊢ ?B⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert (?A OR ?Ba) ?H)))))) ⊢ ?B› ‹⟦insert (?A::fm) (insert (?A1.0::fm) (insert (?A2.0::fm) (insert (?A3.0::fm) (insert (?A4.0::fm) (insert (?A5.0::fm) (insert (?A6.0::fm) (insert (?A7.0::fm) (?H::fm set)))))))) ⊢ (?B::fm); insert (?Ba::fm) (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 ?H))))))) ⊢ ?B⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 (insert (?A OR ?Ba) ?H))))))) ⊢ ?B› ‹⟦insert (?A::fm) (insert (?A1.0::fm) (insert (?A2.0::fm) (insert (?A3.0::fm) (insert (?A4.0::fm) (insert (?A5.0::fm) (insert (?A6.0::fm) (insert (?A7.0::fm) (insert (?A8.0::fm) (?H::fm set))))))))) ⊢ (?B::fm); insert (?Ba::fm) (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)))))))) ⊢ ?B⟧ ⟹ 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 (?A OR ?Ba) ?H)))))))) ⊢ ?B› ‹⟦insert (?A::fm) (insert (?A1.0::fm) (insert (?A2.0::fm) (insert (?A3.0::fm) (insert (?A4.0::fm) (insert (?A5.0::fm) (insert (?A6.0::fm) (insert (?A7.0::fm) (insert (?A8.0::fm) (insert (?A9.0::fm) (?H::fm set)))))))))) ⊢ (?B::fm); insert (?Ba::fm) (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))))))))) ⊢ ?B⟧ ⟹ 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 (?A OR ?Ba) ?H))))))))) ⊢ ?B›*), blast intro: thin1 (*‹?H ⊢ ?B ⟹ insert ?A ?H ⊢ ?B›*) ContraProve (*‹?H ⊢ ?B ⟹ insert (Neg ?B) ?H ⊢ ?A›*))+) (*top goal: ‹⟦atom (i::name) ♯ (s::tm, s'::tm, v::tm, a::tm, x::tm, y::tm, y'::tm); atom (j::name) ♯ (s, s', v, a, x, i, x, y, y'); atom (j'::name) ♯ (s, s', v, a, x, i, j, x, y, y'); atom (k::name) ♯ (s, s', v, a, x, y, y', kk'::tm, i, j, j'); atom (k'::name) ♯ (s, s', v, a, x, y, y', k, i, j, j'); atom (l::name) ♯ (s, s', v, a, x, i, j, j', k, k'); atom (m::name) ♯ (s, s', v, a, i, j, j', k, k', l); atom (n::name) ♯ (s, s', v, a, i, j, j', k, k', l, m); atom (sm::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n); atom (sn::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm); atom (sm'::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn); atom (sn'::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm'); atom (m2::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn'); atom (n2::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2); atom (sm2::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2); atom (sn2::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2); atom (sm2'::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2, sn2); atom (sn2'::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2, sn2, sm2')⟧ ⟹ {Var m IN Var k IMP SyntaxN.All i (SyntaxN.All j (SyntaxN.All j' (SyntaxN.All k' (SeqSubstFormP v a (Var i) (Var j) s (Var m) IMP SeqSubstFormP v a (Var i) (Var j') s' (Var k') IMP Var j' EQ Var j)))), Var sm2 EQ Var sm, Var j' EQ Q_Neg (Var sm2'), SeqSubstFormP v a (Var sn2) (Var sn2') s' (Var n2), SeqSubstFormP v a (Var sm2) (Var sm2') s' (Var m2), Var n2 IN Var k', Var m2 IN Var k', Var i EQ Q_Neg (Var sm), Var j EQ Q_Neg (Var sm'), SeqSubstFormP v a (Var sn) (Var sn') s (Var n), SeqSubstFormP v a (Var sm) (Var sm') s (Var m), Var n IN Var k, Var m IN Var k, All2 l (Var k) (SyntaxN.All i (SyntaxN.All j (SyntaxN.All j' (SyntaxN.All k' (SeqSubstFormP v a (Var i) (Var j) s (Var l) IMP SeqSubstFormP v a (Var i) (Var j') s' (Var k') IMP Var j' EQ Var j))))), SeqSubstFormP v a (Var i) (Var j') s' (Var k'), SeqSubstFormP v a (Var i) (Var j) s (Var k), OrdP (Var k)} ⊢ Var j' EQ Var j› and 2 goals remain*) apply (rule All_E [where x="Var sm"] (*‹insert (?A(?i::=Var sm)) ?H ⊢ ?B ⟹ insert (SyntaxN.All ?i ?A) ?H ⊢ ?B›*), simp) (*top goal: ‹⟦atom i ♯ (s, s', v, a, x, y, y'); atom j ♯ (s, s', v, a, x, i, x, y, y'); atom j' ♯ (s, s', v, a, x, i, j, x, y, y'); atom k ♯ (s, s', v, a, x, y, y', kk', i, j, j'); atom k' ♯ (s, s', v, a, x, y, y', k, i, j, j'); atom l ♯ (s, s', v, a, x, i, j, j', k, k'); atom m ♯ (s, s', v, a, i, j, j', k, k', l); atom n ♯ (s, s', v, a, i, j, j', k, k', l, m); atom sm ♯ (s, s', v, a, i, j, j', k, k', l, m, n); atom sn ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm); atom sm' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn); atom sn' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm'); atom m2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn'); atom n2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2); atom sm2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2); atom sn2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2); atom sm2' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2, sn2); atom sn2' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2, sn2, sm2')⟧ ⟹ {SyntaxN.All i (SyntaxN.All j (SyntaxN.All j' (SyntaxN.All k' (SeqSubstFormP v a (Var i) (Var j) s (Var m) IMP SeqSubstFormP v a (Var i) (Var j') s' (Var k') IMP Var j' EQ Var j)))), Var sm2 EQ Var sm, Var j' EQ Q_Neg (Var sm2'), SeqSubstFormP v a (Var sn2) (Var sn2') s' (Var n2), SeqSubstFormP v a (Var sm2) (Var sm2') s' (Var m2), Var n2 IN Var k', Var m2 IN Var k', Var i EQ Q_Neg (Var sm), Var j EQ Q_Neg (Var sm'), SeqSubstFormP v a (Var sn) (Var sn') s (Var n), SeqSubstFormP v a (Var sm) (Var sm') s (Var m), Var n IN Var k, Var m IN Var k, All2 l (Var k) (SyntaxN.All i (SyntaxN.All j (SyntaxN.All j' (SyntaxN.All k' (SeqSubstFormP v a (Var i) (Var j) s (Var l) IMP SeqSubstFormP v a (Var i) (Var j') s' (Var k') IMP Var j' EQ Var j))))), SeqSubstFormP v a (Var i) (Var j') s' (Var k'), SeqSubstFormP v a (Var i) (Var j) s (Var k), OrdP (Var k)} ⊢ Var j' EQ Var j› and 2 goals remain*) apply (rule All_E [where x="Var sm'"] (*‹insert (?A(?i::=Var sm')) ?H ⊢ ?B ⟹ insert (SyntaxN.All ?i ?A) ?H ⊢ ?B›*), simp) (*top goal: ‹⟦atom i ♯ (s, s', v, a, x, y, y'); atom j ♯ (s, s', v, a, x, i, x, y, y'); atom j' ♯ (s, s', v, a, x, i, j, x, y, y'); atom k ♯ (s, s', v, a, x, y, y', kk', i, j, j'); atom k' ♯ (s, s', v, a, x, y, y', k, i, j, j'); atom l ♯ (s, s', v, a, x, i, j, j', k, k'); atom m ♯ (s, s', v, a, i, j, j', k, k', l); atom n ♯ (s, s', v, a, i, j, j', k, k', l, m); atom sm ♯ (s, s', v, a, i, j, j', k, k', l, m, n); atom sn ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm); atom sm' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn); atom sn' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm'); atom m2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn'); atom n2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2); atom sm2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2); atom sn2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2); atom sm2' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2, sn2); atom sn2' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2, sn2, sm2')⟧ ⟹ {SyntaxN.All j (SyntaxN.All j' (SyntaxN.All k' (SeqSubstFormP v a (Var sm) (Var j) s (Var m) IMP SeqSubstFormP v a (Var sm) (Var j') s' (Var k') IMP Var j' EQ Var j))), Var sm2 EQ Var sm, Var j' EQ Q_Neg (Var sm2'), SeqSubstFormP v a (Var sn2) (Var sn2') s' (Var n2), SeqSubstFormP v a (Var sm2) (Var sm2') s' (Var m2), Var n2 IN Var k', Var m2 IN Var k', Var i EQ Q_Neg (Var sm), Var j EQ Q_Neg (Var sm'), SeqSubstFormP v a (Var sn) (Var sn') s (Var n), SeqSubstFormP v a (Var sm) (Var sm') s (Var m), Var n IN Var k, Var m IN Var k, All2 l (Var k) (SyntaxN.All i (SyntaxN.All j (SyntaxN.All j' (SyntaxN.All k' (SeqSubstFormP v a (Var i) (Var j) s (Var l) IMP SeqSubstFormP v a (Var i) (Var j') s' (Var k') IMP Var j' EQ Var j))))), SeqSubstFormP v a (Var i) (Var j') s' (Var k'), SeqSubstFormP v a (Var i) (Var j) s (Var k), OrdP (Var k)} ⊢ Var j' EQ Var j› and 2 goals remain*) apply (rule All_E [where x="Var sm2'"] (*‹insert ((?A::fm)(?i::name::=Var (sm2'::name))) (?H::fm set) ⊢ (?B::fm) ⟹ insert (SyntaxN.All ?i ?A) ?H ⊢ ?B›*), simp) (*top goal: ‹⟦atom i ♯ (s, s', v, a, x, y, y'); atom j ♯ (s, s', v, a, x, i, x, y, y'); atom j' ♯ (s, s', v, a, x, i, j, x, y, y'); atom k ♯ (s, s', v, a, x, y, y', kk', i, j, j'); atom k' ♯ (s, s', v, a, x, y, y', k, i, j, j'); atom l ♯ (s, s', v, a, x, i, j, j', k, k'); atom m ♯ (s, s', v, a, i, j, j', k, k', l); atom n ♯ (s, s', v, a, i, j, j', k, k', l, m); atom sm ♯ (s, s', v, a, i, j, j', k, k', l, m, n); atom sn ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm); atom sm' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn); atom sn' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm'); atom m2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn'); atom n2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2); atom sm2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2); atom sn2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2); atom sm2' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2, sn2); atom sn2' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2, sn2, sm2')⟧ ⟹ {SyntaxN.All j' (SyntaxN.All k' (SeqSubstFormP v a (Var sm) (Var sm') s (Var m) IMP SeqSubstFormP v a (Var sm) (Var j') s' (Var k') IMP Var j' EQ Var sm')), Var sm2 EQ Var sm, Var j' EQ Q_Neg (Var sm2'), SeqSubstFormP v a (Var sn2) (Var sn2') s' (Var n2), SeqSubstFormP v a (Var sm2) (Var sm2') s' (Var m2), Var n2 IN Var k', Var m2 IN Var k', Var i EQ Q_Neg (Var sm), Var j EQ Q_Neg (Var sm'), SeqSubstFormP v a (Var sn) (Var sn') s (Var n), SeqSubstFormP v a (Var sm) (Var sm') s (Var m), Var n IN Var k, Var m IN Var k, All2 l (Var k) (SyntaxN.All i (SyntaxN.All j (SyntaxN.All j' (SyntaxN.All k' (SeqSubstFormP v a (Var i) (Var j) s (Var l) IMP SeqSubstFormP v a (Var i) (Var j') s' (Var k') IMP Var j' EQ Var j))))), SeqSubstFormP v a (Var i) (Var j') s' (Var k'), SeqSubstFormP v a (Var i) (Var j) s (Var k), OrdP (Var k)} ⊢ Var j' EQ Var j› and 2 goals remain*) apply (rule All_E [where x="Var m2"] (*‹insert (?A(?i::=Var m2)) ?H ⊢ ?B ⟹ insert (SyntaxN.All ?i ?A) ?H ⊢ ?B›*), simp) (*top goal: ‹⟦atom i ♯ (s, s', v, a, x, y, y'); atom j ♯ (s, s', v, a, x, i, x, y, y'); atom j' ♯ (s, s', v, a, x, i, j, x, y, y'); atom k ♯ (s, s', v, a, x, y, y', kk', i, j, j'); atom k' ♯ (s, s', v, a, x, y, y', k, i, j, j'); atom l ♯ (s, s', v, a, x, i, j, j', k, k'); atom m ♯ (s, s', v, a, i, j, j', k, k', l); atom n ♯ (s, s', v, a, i, j, j', k, k', l, m); atom sm ♯ (s, s', v, a, i, j, j', k, k', l, m, n); atom sn ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm); atom sm' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn); atom sn' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm'); atom m2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn'); atom n2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2); atom sm2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2); atom sn2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2); atom sm2' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2, sn2); atom sn2' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2, sn2, sm2')⟧ ⟹ {SyntaxN.All k' (SeqSubstFormP v a (Var sm) (Var sm') s (Var m) IMP SeqSubstFormP v a (Var sm) (Var sm2') s' (Var k') IMP Var sm2' EQ Var sm'), Var sm2 EQ Var sm, Var j' EQ Q_Neg (Var sm2'), SeqSubstFormP v a (Var sn2) (Var sn2') s' (Var n2), SeqSubstFormP v a (Var sm2) (Var sm2') s' (Var m2), Var n2 IN Var k', Var m2 IN Var k', Var i EQ Q_Neg (Var sm), Var j EQ Q_Neg (Var sm'), SeqSubstFormP v a (Var sn) (Var sn') s (Var n), SeqSubstFormP v a (Var sm) (Var sm') s (Var m), Var n IN Var k, Var m IN Var k, All2 l (Var k) (SyntaxN.All i (SyntaxN.All j (SyntaxN.All j' (SyntaxN.All k' (SeqSubstFormP v a (Var i) (Var j) s (Var l) IMP SeqSubstFormP v a (Var i) (Var j') s' (Var k') IMP Var j' EQ Var j))))), SeqSubstFormP v a (Var i) (Var j') s' (Var k'), SeqSubstFormP v a (Var i) (Var j) s (Var k), OrdP (Var k)} ⊢ Var j' EQ Var j› and 2 goals remain*) apply ((rule Disj_EH [OF ContraProve] (*‹⟦?H ⊢ ?B1; insert ?B ?H ⊢ ?C⟧ ⟹ insert (?B1 IMP ?B) ?H ⊢ ?C› ‹⟦insert ?A1.0 ?H ⊢ ?B1; insert ?Ba (insert ?A1.0 ?H) ⊢ ?B⟧ ⟹ insert ?A1.0 (insert (?B1 IMP ?Ba) ?H) ⊢ ?B› ‹⟦insert ?A1.0 (insert ?A2.0 ?H) ⊢ ?B1; insert ?Ba (insert ?A1.0 (insert ?A2.0 ?H)) ⊢ ?B⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert (?B1 IMP ?Ba) ?H)) ⊢ ?B› ‹⟦insert ?A1.0 (insert ?A2.0 (insert ?A3.0 ?H)) ⊢ ?B1; insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 ?H))) ⊢ ?B⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert (?B1 IMP ?Ba) ?H))) ⊢ ?B› ‹⟦insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 ?H))) ⊢ ?B1; insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 ?H)))) ⊢ ?B⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert (?B1 IMP ?Ba) ?H)))) ⊢ ?B› ‹⟦insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 ?H)))) ⊢ ?B1; insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 ?H))))) ⊢ ?B⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert (?B1 IMP ?Ba) ?H))))) ⊢ ?B› ‹⟦insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 ?H))))) ⊢ ?B1; insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 ?H)))))) ⊢ ?B⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert (?B1 IMP ?Ba) ?H)))))) ⊢ ?B› ‹⟦insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 ?H)))))) ⊢ ?B1; insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 ?H))))))) ⊢ ?B⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 (insert (?B1 IMP ?Ba) ?H))))))) ⊢ ?B› ‹⟦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))))))) ⊢ ?B1; insert ?Ba (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)))))))) ⊢ ?B⟧ ⟹ 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 (?B1 IMP ?Ba) ?H)))))))) ⊢ ?B› ‹⟦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)))))))) ⊢ ?B1; insert ?Ba (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))))))))) ⊢ ?B⟧ ⟹ 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 (?B1 IMP ?Ba) ?H))))))))) ⊢ ?B›*), blast intro: SeqSubstFormP_eq (*‹⟦?H ⊢ SeqSubstFormP ?v ?tm ?x ?z ?s ?k; insert (SeqSubstFormP ?v ?tm ?y ?z ?s ?k) ?H ⊢ ?A⟧ ⟹ insert (?x EQ ?y) ?H ⊢ ?A›*) Sym_L (*‹insert (?t EQ ?u) ?H ⊢ ?A ⟹ insert (?u EQ ?t) ?H ⊢ ?A›*))+) (*top goal: ‹⟦atom i ♯ (s, s', v, a, x, y, y'); atom j ♯ (s, s', v, a, x, i, x, y, y'); atom j' ♯ (s, s', v, a, x, i, j, x, y, y'); atom k ♯ (s, s', v, a, x, y, y', kk', i, j, j'); atom k' ♯ (s, s', v, a, x, y, y', k, i, j, j'); atom l ♯ (s, s', v, a, x, i, j, j', k, k'); atom m ♯ (s, s', v, a, i, j, j', k, k', l); atom n ♯ (s, s', v, a, i, j, j', k, k', l, m); atom sm ♯ (s, s', v, a, i, j, j', k, k', l, m, n); atom sn ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm); atom sm' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn); atom sn' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm'); atom m2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn'); atom n2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2); atom sm2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2); atom sn2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2); atom sm2' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2, sn2); atom sn2' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2, sn2, sm2')⟧ ⟹ {SeqSubstFormP v a (Var sm) (Var sm') s (Var m) IMP SeqSubstFormP v a (Var sm) (Var sm2') s' (Var m2) IMP Var sm2' EQ Var sm', Var sm2 EQ Var sm, Var j' EQ Q_Neg (Var sm2'), SeqSubstFormP v a (Var sn2) (Var sn2') s' (Var n2), SeqSubstFormP v a (Var sm2) (Var sm2') s' (Var m2), Var n2 IN Var k', Var m2 IN Var k', Var i EQ Q_Neg (Var sm), Var j EQ Q_Neg (Var sm'), SeqSubstFormP v a (Var sn) (Var sn') s (Var n), SeqSubstFormP v a (Var sm) (Var sm') s (Var m), Var n IN Var k, Var m IN Var k, All2 l (Var k) (SyntaxN.All i (SyntaxN.All j (SyntaxN.All j' (SyntaxN.All k' (SeqSubstFormP v a (Var i) (Var j) s (Var l) IMP SeqSubstFormP v a (Var i) (Var j') s' (Var k') IMP Var j' EQ Var j))))), SeqSubstFormP v a (Var i) (Var j') s' (Var k'), SeqSubstFormP v a (Var i) (Var j) s (Var k), OrdP (Var k)} ⊢ Var j' EQ Var j› and 2 goals remain*) apply (blast intro: HPair_cong (*‹⟦?H ⊢ ?t EQ ?t'; ?H ⊢ ?u EQ ?u'⟧ ⟹ ?H ⊢ HPair ?t ?u EQ HPair ?t' ?u'›*) Sym (*‹?H ⊢ ?t EQ ?u ⟹ ?H ⊢ ?u EQ ?t›*) Trans [OF Hyp] (*‹⟦?x EQ ?y ∈ ?H; ?H ⊢ ?y EQ ?z⟧ ⟹ ?H ⊢ ?x EQ ?z›*)) (*top goal: ‹⟦atom (i::name) ♯ (s::tm, s'::tm, v::tm, a::tm, x::tm, y::tm, y'::tm); atom (j::name) ♯ (s, s', v, a, x, i, x, y, y'); atom (j'::name) ♯ (s, s', v, a, x, i, j, x, y, y'); atom (k::name) ♯ (s, s', v, a, x, y, y', kk'::tm, i, j, j'); atom (k'::name) ♯ (s, s', v, a, x, y, y', k, i, j, j'); atom (l::name) ♯ (s, s', v, a, x, i, j, j', k, k'); atom (m::name) ♯ (s, s', v, a, i, j, j', k, k', l); atom (n::name) ♯ (s, s', v, a, i, j, j', k, k', l, m); atom (sm::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n); atom (sn::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm); atom (sm'::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn); atom (sn'::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm'); atom (m2::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn'); atom (n2::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2); atom (sm2::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2); atom (sn2::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2); atom (sm2'::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2, sn2); atom (sn2'::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2, sn2, sm2')⟧ ⟹ {Var sm2' EQ Var sm', Var sm2 EQ Var sm, Var j' EQ Q_Neg (Var sm2'), SeqSubstFormP v a (Var sn2) (Var sn2') s' (Var n2), SeqSubstFormP v a (Var sm2) (Var sm2') s' (Var m2), Var n2 IN Var k', Var m2 IN Var k', Var i EQ Q_Neg (Var sm), Var j EQ Q_Neg (Var sm'), SeqSubstFormP v a (Var sn) (Var sn') s (Var n), SeqSubstFormP v a (Var sm) (Var sm') s (Var m), Var n IN Var k, Var m IN Var k, All2 l (Var k) (SyntaxN.All i (SyntaxN.All j (SyntaxN.All j' (SyntaxN.All k' (SeqSubstFormP v a (Var i) (Var j) s (Var l) IMP SeqSubstFormP v a (Var i) (Var j') s' (Var k') IMP Var j' EQ Var j))))), SeqSubstFormP v a (Var i) (Var j') s' (Var k'), SeqSubstFormP v a (Var i) (Var j) s (Var k), OrdP (Var k)} ⊢ Var j' EQ Var j› and 2 goals remain*) apply ((rule Conj_EH (*‹insert ?A (insert ?B ?H) ⊢ ?C ⟹ insert (?A AND ?B) ?H ⊢ ?C› ‹insert ?A (insert ?Ba (insert ?A1.0 ?H)) ⊢ ?B ⟹ insert ?A1.0 (insert (?A AND ?Ba) ?H) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 ?H))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert (?A AND ?Ba) ?H)) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 ?H)))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert (?A AND ?Ba) ?H))) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 ?H))))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert (?A AND ?Ba) ?H)))) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 ?H)))))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert (?A AND ?Ba) ?H))))) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 ?H))))))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert (?A AND ?Ba) ?H)))))) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 ?H)))))))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 (insert (?A AND ?Ba) ?H))))))) ⊢ ?B› ‹insert ?A (insert ?Ba (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))))))))) ⊢ ?B ⟹ 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 (?A AND ?Ba) ?H)))))))) ⊢ ?B› ‹insert ?A (insert ?Ba (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)))))))))) ⊢ ?B ⟹ 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 (?A AND ?Ba) ?H))))))))) ⊢ ?B›*))+) (*top goal: ‹⟦atom i ♯ (s, s', v, a, x, y, y'); atom j ♯ (s, s', v, a, x, i, x, y, y'); atom j' ♯ (s, s', v, a, x, i, j, x, y, y'); atom k ♯ (s, s', v, a, x, y, y', kk', i, j, j'); atom k' ♯ (s, s', v, a, x, y, y', k, i, j, j'); atom l ♯ (s, s', v, a, x, i, j, j', k, k'); atom m ♯ (s, s', v, a, i, j, j', k, k', l); atom n ♯ (s, s', v, a, i, j, j', k, k', l, m); atom sm ♯ (s, s', v, a, i, j, j', k, k', l, m, n); atom sn ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm); atom sm' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn); atom sn' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm'); atom m2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn'); atom n2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2); atom sm2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2); atom sn2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2); atom sm2' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2, sn2); atom sn2' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2, sn2, sm2')⟧ ⟹ {Var i EQ Q_Ex (Var sm2) AND Var j' EQ Q_Ex (Var sm2'), SeqSubstFormP v a (Var sn2) (Var sn2') s' (Var n2), SeqSubstFormP v a (Var sm2) (Var sm2') s' (Var m2), Var n2 IN Var k', Var m2 IN Var k', Var i EQ Q_Neg (Var sm), Var j EQ Q_Neg (Var sm'), SeqSubstFormP v a (Var sn) (Var sn') s (Var n), SeqSubstFormP v a (Var sm) (Var sm') s (Var m), Var n IN Var k, Var m IN Var k, All2 l (Var k) (SyntaxN.All i (SyntaxN.All j (SyntaxN.All j' (SyntaxN.All k' (SeqSubstFormP v a (Var i) (Var j) s (Var l) IMP SeqSubstFormP v a (Var i) (Var j') s' (Var k') IMP Var j' EQ Var j))))), SeqSubstFormP v a (Var i) (Var j') s' (Var k'), SeqSubstFormP v a (Var i) (Var j) s (Var k), OrdP (Var k)} ⊢ Var j' EQ Var j› and 1 goal remains*) apply (rule Eq_Trans_E [OF Hyp] (*‹⟦?x EQ ?u ∈ ?H; insert (?t EQ ?u) ?H ⊢ ?A⟧ ⟹ insert (?x EQ ?t) ?H ⊢ ?A›*), blast, force simp add: HTS (*‹0 < ?n ⟹ HTuple ?n = HPair Zero (HTuple (?n - 1))› ‹HTuple 0 = HPair Zero Zero› ‹HTuple (Suc ?k) = HPair Zero (HTuple ?k)›*)) (*top goal: ‹⟦atom (i::name) ♯ (s::tm, s'::tm, v::tm, a::tm, x::tm, y::tm, y'::tm); atom (j::name) ♯ (s, s', v, a, x, i, x, y, y'); atom (j'::name) ♯ (s, s', v, a, x, i, j, x, y, y'); atom (k::name) ♯ (s, s', v, a, x, y, y', kk'::tm, i, j, j'); atom (k'::name) ♯ (s, s', v, a, x, y, y', k, i, j, j'); atom (l::name) ♯ (s, s', v, a, x, i, j, j', k, k'); atom (m::name) ♯ (s, s', v, a, i, j, j', k, k', l); atom (n::name) ♯ (s, s', v, a, i, j, j', k, k', l, m); atom (sm::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n); atom (sn::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm); atom (sm'::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn); atom (sn'::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm'); atom (m2::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn'); atom (n2::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2); atom (sm2::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2); atom (sn2::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2); atom (sm2'::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2, sn2); atom (sn2'::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2, sn2, sm2')⟧ ⟹ {Var i EQ Q_Ex (Var sm2), Var j' EQ Q_Ex (Var sm2'), SeqSubstFormP v a (Var sn2) (Var sn2') s' (Var n2), SeqSubstFormP v a (Var sm2) (Var sm2') s' (Var m2), Var n2 IN Var k', Var m2 IN Var k', Var i EQ Q_Neg (Var sm), Var j EQ Q_Neg (Var sm'), SeqSubstFormP v a (Var sn) (Var sn') s (Var n), SeqSubstFormP v a (Var sm) (Var sm') s (Var m), Var n IN Var k, Var m IN Var k, All2 l (Var k) (SyntaxN.All i (SyntaxN.All j (SyntaxN.All j' (SyntaxN.All k' (SeqSubstFormP v a (Var i) (Var j) s (Var l) IMP SeqSubstFormP v a (Var i) (Var j') s' (Var k') IMP Var j' EQ Var j))))), SeqSubstFormP v a (Var i) (Var j') s' (Var k'), SeqSubstFormP v a (Var i) (Var j) s (Var k), OrdP (Var k)} ⊢ Var j' EQ Var j› and 1 goal remains*) apply ((rule Conj_EH (*‹insert ?A (insert ?B ?H) ⊢ ?C ⟹ insert (?A AND ?B) ?H ⊢ ?C› ‹insert ?A (insert ?Ba (insert ?A1.0 ?H)) ⊢ ?B ⟹ insert ?A1.0 (insert (?A AND ?Ba) ?H) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 ?H))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert (?A AND ?Ba) ?H)) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 ?H)))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert (?A AND ?Ba) ?H))) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 ?H))))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert (?A AND ?Ba) ?H)))) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 ?H)))))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert (?A AND ?Ba) ?H))))) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 ?H))))))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert (?A AND ?Ba) ?H)))))) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 ?H)))))))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 (insert (?A AND ?Ba) ?H))))))) ⊢ ?B› ‹insert ?A (insert ?Ba (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))))))))) ⊢ ?B ⟹ 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 (?A AND ?Ba) ?H)))))))) ⊢ ?B› ‹insert ?A (insert ?Ba (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)))))))))) ⊢ ?B ⟹ 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 (?A AND ?Ba) ?H))))))))) ⊢ ?B›*) Disj_EH (*‹⟦insert ?A ?H ⊢ ?C; insert ?B ?H ⊢ ?C⟧ ⟹ insert (?A OR ?B) ?H ⊢ ?C› ‹⟦insert ?A (insert ?A1.0 ?H) ⊢ ?B; insert ?Ba (insert ?A1.0 ?H) ⊢ ?B⟧ ⟹ insert ?A1.0 (insert (?A OR ?Ba) ?H) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 ?H)) ⊢ ?B; insert ?Ba (insert ?A1.0 (insert ?A2.0 ?H)) ⊢ ?B⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert (?A OR ?Ba) ?H)) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 ?H))) ⊢ ?B; insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 ?H))) ⊢ ?B⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert (?A OR ?Ba) ?H))) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 ?H)))) ⊢ ?B; insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 ?H)))) ⊢ ?B⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert (?A OR ?Ba) ?H)))) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 ?H))))) ⊢ ?B; insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 ?H))))) ⊢ ?B⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert (?A OR ?Ba) ?H))))) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 ?H)))))) ⊢ ?B; insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 ?H)))))) ⊢ ?B⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert (?A OR ?Ba) ?H)))))) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 ?H))))))) ⊢ ?B; insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 ?H))))))) ⊢ ?B⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 (insert (?A OR ?Ba) ?H))))))) ⊢ ?B› ‹⟦insert ?A (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)))))))) ⊢ ?B; insert ?Ba (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)))))))) ⊢ ?B⟧ ⟹ 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 (?A OR ?Ba) ?H)))))))) ⊢ ?B› ‹⟦insert ?A (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))))))))) ⊢ ?B; insert ?Ba (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))))))))) ⊢ ?B⟧ ⟹ 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 (?A OR ?Ba) ?H))))))))) ⊢ ?B›*) Ex_EH (*‹⟦insert ?A ?H ⊢ ?B; atom ?i ♯ ?B; ∀C∈?H. atom ?i ♯ C⟧ ⟹ insert (SyntaxN.Ex ?i ?A) ?H ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 ?H) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 ?H. atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert (SyntaxN.Ex ?i ?A) ?H) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 ?H)) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 ?H). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert (SyntaxN.Ex ?i ?A) ?H)) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 ?H))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 ?H)). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert (SyntaxN.Ex ?i ?A) ?H))) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 ?H)))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 ?H))). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert (SyntaxN.Ex ?i ?A) ?H)))) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 ?H))))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 ?H)))). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert (SyntaxN.Ex ?i ?A) ?H))))) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 ?H)))))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 ?H))))). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert (SyntaxN.Ex ?i ?A) ?H)))))) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 ?H))))))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 ?H)))))). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 (insert (SyntaxN.Ex ?i ?A) ?H))))))) ⊢ ?B› ‹⟦insert ?A (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)))))))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈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))))))). atom ?i ♯ C⟧ ⟹ 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 (SyntaxN.Ex ?i ?A) ?H)))))))) ⊢ ?B› ‹⟦insert ?A (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))))))))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈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)))))))). atom ?i ♯ C⟧ ⟹ 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 (SyntaxN.Ex ?i ?A) ?H))))))))) ⊢ ?B›*))+) (*goal: ‹⟦atom i ♯ (s, s', v, a, x, y, y'); atom j ♯ (s, s', v, a, x, i, x, y, y'); atom j' ♯ (s, s', v, a, x, i, j, x, y, y'); atom k ♯ (s, s', v, a, x, y, y', kk', i, j, j'); atom k' ♯ (s, s', v, a, x, y, y', k, i, j, j'); atom l ♯ (s, s', v, a, x, i, j, j', k, k'); atom m ♯ (s, s', v, a, i, j, j', k, k', l); atom n ♯ (s, s', v, a, i, j, j', k, k', l, m); atom sm ♯ (s, s', v, a, i, j, j', k, k', l, m, n); atom sn ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm); atom sm' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn); atom sn' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm'); atom m2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn'); atom n2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2); atom sm2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2); atom sn2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2); atom sm2' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2, sn2); atom sn2' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2, sn2, sm2')⟧ ⟹ {Var i EQ Q_Ex (Var sm) AND Var j EQ Q_Ex (Var sm'), SeqSubstFormP v a (Var sn) (Var sn') s (Var n), SeqSubstFormP v a (Var sm) (Var sm') s (Var m), Var n IN Var k, Var m IN Var k, SyntaxN.Ex m2 (SyntaxN.Ex n2 (SyntaxN.Ex sm2 (SyntaxN.Ex sm2' (SyntaxN.Ex sn2 (SyntaxN.Ex sn2' (Var m2 IN Var k' AND Var n2 IN Var k' AND SeqSubstFormP v a (Var sm2) (Var sm2') s' (Var m2) AND SeqSubstFormP v a (Var sn2) (Var sn2') s' (Var n2) AND (Var i EQ Q_Disj (Var sm2) (Var sn2) AND Var j' EQ Q_Disj (Var sm2') (Var sn2') OR Var i EQ Q_Neg (Var sm2) AND Var j' EQ Q_Neg (Var sm2') OR Var i EQ Q_Ex (Var sm2) AND Var j' EQ Q_Ex (Var sm2')))))))), All2 l (Var k) (SyntaxN.All i (SyntaxN.All j (SyntaxN.All j' (SyntaxN.All k' (SeqSubstFormP v a (Var i) (Var j) s (Var l) IMP SeqSubstFormP v a (Var i) (Var j') s' (Var k') IMP Var j' EQ Var j))))), SeqSubstFormP v a (Var i) (Var j') s' (Var k'), SeqSubstFormP v a (Var i) (Var j) s (Var k), OrdP (Var k)} ⊢ Var j' EQ Var j›*) apply simp_all (*top goal: ‹⟦atom (i::name) ♯ (s::tm, s'::tm, v::tm, a::tm, x::tm, y::tm, y'::tm); atom (j::name) ♯ (s, s', v, a, x, i, x, y, y'); atom (j'::name) ♯ (s, s', v, a, x, i, j, x, y, y'); atom (k::name) ♯ (s, s', v, a, x, y, y', kk'::tm, i, j, j'); atom (k'::name) ♯ (s, s', v, a, x, y, y', k, i, j, j'); atom (l::name) ♯ (s, s', v, a, x, i, j, j', k, k'); atom (m::name) ♯ (s, s', v, a, i, j, j', k, k', l); atom (n::name) ♯ (s, s', v, a, i, j, j', k, k', l, m); atom (sm::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n); atom (sn::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm); atom (sm'::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn); atom (sn'::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm'); atom (m2::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn'); atom (n2::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2); atom (sm2::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2); atom (sn2::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2); atom (sm2'::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2, sn2); atom (sn2'::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2, sn2, sm2')⟧ ⟹ {Var i EQ Q_Disj (Var sm2) (Var sn2), Var j' EQ Q_Disj (Var sm2') (Var sn2'), SeqSubstFormP v a (Var sn2) (Var sn2') s' (Var n2), SeqSubstFormP v a (Var sm2) (Var sm2') s' (Var m2), Var n2 IN Var k', Var m2 IN Var k', Var i EQ Q_Ex (Var sm), Var j EQ Q_Ex (Var sm'), SeqSubstFormP v a (Var sn) (Var sn') s (Var n), SeqSubstFormP v a (Var sm) (Var sm') s (Var m), Var n IN Var k, Var m IN Var k, All2 l (Var k) (SyntaxN.All i (SyntaxN.All j (SyntaxN.All j' (SyntaxN.All k' (SeqSubstFormP v a (Var i) (Var j) s (Var l) IMP SeqSubstFormP v a (Var i) (Var j') s' (Var k') IMP Var j' EQ Var j))))), SeqSubstFormP v a (Var i) (Var j') s' (Var k'), SeqSubstFormP v a (Var i) (Var j) s (Var k), OrdP (Var k)} ⊢ Var j' EQ Var j› and 13 goals remain*) apply (rule Eq_Trans_E [OF Hyp] (*‹⟦?x EQ ?u ∈ ?H; insert (?t EQ ?u) ?H ⊢ ?A⟧ ⟹ insert (?x EQ ?t) ?H ⊢ ?A›*), blast, force simp add: HTS (*‹0 < ?n ⟹ HTuple ?n = HPair Zero (HTuple (?n - 1))› ‹HTuple 0 = HPair Zero Zero› ‹HTuple (Suc ?k) = HPair Zero (HTuple ?k)›*)) (*top goal: ‹⟦atom i ♯ (s, s', v, a, x, y, y'); atom j ♯ (s, s', v, a, x, i, x, y, y'); atom j' ♯ (s, s', v, a, x, i, j, x, y, y'); atom k ♯ (s, s', v, a, x, y, y', kk', i, j, j'); atom k' ♯ (s, s', v, a, x, y, y', k, i, j, j'); atom l ♯ (s, s', v, a, x, i, j, j', k, k'); atom m ♯ (s, s', v, a, i, j, j', k, k', l); atom n ♯ (s, s', v, a, i, j, j', k, k', l, m); atom sm ♯ (s, s', v, a, i, j, j', k, k', l, m, n); atom sn ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm); atom sm' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn); atom sn' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm'); atom m2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn'); atom n2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2); atom sm2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2); atom sn2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2); atom sm2' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2, sn2); atom sn2' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2, sn2, sm2')⟧ ⟹ {Var i EQ Q_Disj (Var sm2) (Var sn2), Var j' EQ Q_Disj (Var sm2') (Var sn2'), SeqSubstFormP v a (Var sn2) (Var sn2') s' (Var n2), SeqSubstFormP v a (Var sm2) (Var sm2') s' (Var m2), Var n2 IN Var k', Var m2 IN Var k', Var i EQ Q_Ex (Var sm), Var j EQ Q_Ex (Var sm'), SeqSubstFormP v a (Var sn) (Var sn') s (Var n), SeqSubstFormP v a (Var sm) (Var sm') s (Var m), Var n IN Var k, Var m IN Var k, All2 l (Var k) (SyntaxN.All i (SyntaxN.All j (SyntaxN.All j' (SyntaxN.All k' (SeqSubstFormP v a (Var i) (Var j) s (Var l) IMP SeqSubstFormP v a (Var i) (Var j') s' (Var k') IMP Var j' EQ Var j))))), SeqSubstFormP v a (Var i) (Var j') s' (Var k'), SeqSubstFormP v a (Var i) (Var j) s (Var k), OrdP (Var k)} ⊢ Var j' EQ Var j› and 1 goal remains*) apply ((rule Conj_EH (*‹insert ?A (insert ?B ?H) ⊢ ?C ⟹ insert (?A AND ?B) ?H ⊢ ?C› ‹insert ?A (insert ?Ba (insert ?A1.0 ?H)) ⊢ ?B ⟹ insert ?A1.0 (insert (?A AND ?Ba) ?H) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 ?H))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert (?A AND ?Ba) ?H)) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 ?H)))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert (?A AND ?Ba) ?H))) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 ?H))))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert (?A AND ?Ba) ?H)))) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 ?H)))))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert (?A AND ?Ba) ?H))))) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 ?H))))))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert (?A AND ?Ba) ?H)))))) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 ?H)))))))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 (insert (?A AND ?Ba) ?H))))))) ⊢ ?B› ‹insert ?A (insert ?Ba (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))))))))) ⊢ ?B ⟹ 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 (?A AND ?Ba) ?H)))))))) ⊢ ?B› ‹insert ?A (insert ?Ba (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)))))))))) ⊢ ?B ⟹ 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 (?A AND ?Ba) ?H))))))))) ⊢ ?B›*) Disj_EH (*‹⟦insert ?A ?H ⊢ ?C; insert ?B ?H ⊢ ?C⟧ ⟹ insert (?A OR ?B) ?H ⊢ ?C› ‹⟦insert ?A (insert ?A1.0 ?H) ⊢ ?B; insert ?Ba (insert ?A1.0 ?H) ⊢ ?B⟧ ⟹ insert ?A1.0 (insert (?A OR ?Ba) ?H) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 ?H)) ⊢ ?B; insert ?Ba (insert ?A1.0 (insert ?A2.0 ?H)) ⊢ ?B⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert (?A OR ?Ba) ?H)) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 ?H))) ⊢ ?B; insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 ?H))) ⊢ ?B⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert (?A OR ?Ba) ?H))) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 ?H)))) ⊢ ?B; insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 ?H)))) ⊢ ?B⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert (?A OR ?Ba) ?H)))) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 ?H))))) ⊢ ?B; insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 ?H))))) ⊢ ?B⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert (?A OR ?Ba) ?H))))) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 ?H)))))) ⊢ ?B; insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 ?H)))))) ⊢ ?B⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert (?A OR ?Ba) ?H)))))) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 ?H))))))) ⊢ ?B; insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 ?H))))))) ⊢ ?B⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 (insert (?A OR ?Ba) ?H))))))) ⊢ ?B› ‹⟦insert ?A (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)))))))) ⊢ ?B; insert ?Ba (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)))))))) ⊢ ?B⟧ ⟹ 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 (?A OR ?Ba) ?H)))))))) ⊢ ?B› ‹⟦insert ?A (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))))))))) ⊢ ?B; insert ?Ba (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))))))))) ⊢ ?B⟧ ⟹ 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 (?A OR ?Ba) ?H))))))))) ⊢ ?B›*) Ex_EH (*‹⟦insert ?A ?H ⊢ ?B; atom ?i ♯ ?B; ∀C∈?H. atom ?i ♯ C⟧ ⟹ insert (SyntaxN.Ex ?i ?A) ?H ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 ?H) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 ?H. atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert (SyntaxN.Ex ?i ?A) ?H) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 ?H)) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 ?H). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert (SyntaxN.Ex ?i ?A) ?H)) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 ?H))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 ?H)). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert (SyntaxN.Ex ?i ?A) ?H))) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 ?H)))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 ?H))). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert (SyntaxN.Ex ?i ?A) ?H)))) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 ?H))))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 ?H)))). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert (SyntaxN.Ex ?i ?A) ?H))))) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 ?H)))))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 ?H))))). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert (SyntaxN.Ex ?i ?A) ?H)))))) ⊢ ?B› ‹⟦insert ?A (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 ?H))))))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 ?H)))))). atom ?i ♯ C⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 (insert (SyntaxN.Ex ?i ?A) ?H))))))) ⊢ ?B› ‹⟦insert ?A (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)))))))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈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))))))). atom ?i ♯ C⟧ ⟹ 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 (SyntaxN.Ex ?i ?A) ?H)))))))) ⊢ ?B› ‹⟦insert ?A (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))))))))) ⊢ ?B; atom ?i ♯ ?B; ∀C∈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)))))))). atom ?i ♯ C⟧ ⟹ 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 (SyntaxN.Ex ?i ?A) ?H))))))))) ⊢ ?B›*))+) (*goal: ‹⟦atom (i::name) ♯ (s::tm, s'::tm, v::tm, a::tm, x::tm, y::tm, y'::tm); atom (j::name) ♯ (s, s', v, a, x, i, x, y, y'); atom (j'::name) ♯ (s, s', v, a, x, i, j, x, y, y'); atom (k::name) ♯ (s, s', v, a, x, y, y', kk'::tm, i, j, j'); atom (k'::name) ♯ (s, s', v, a, x, y, y', k, i, j, j'); atom (l::name) ♯ (s, s', v, a, x, i, j, j', k, k'); atom (m::name) ♯ (s, s', v, a, i, j, j', k, k', l); atom (n::name) ♯ (s, s', v, a, i, j, j', k, k', l, m); atom (sm::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n); atom (sn::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm); atom (sm'::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn); atom (sn'::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm'); atom (m2::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn'); atom (n2::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2); atom (sm2::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2); atom (sn2::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2); atom (sm2'::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2, sn2); atom (sn2'::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2, sn2, sm2')⟧ ⟹ {Var i EQ Q_Neg (Var sm2) AND Var j' EQ Q_Neg (Var sm2') OR Var i EQ Q_Ex (Var sm2) AND Var j' EQ Q_Ex (Var sm2'), SeqSubstFormP v a (Var sn2) (Var sn2') s' (Var n2), SeqSubstFormP v a (Var sm2) (Var sm2') s' (Var m2), Var n2 IN Var k', Var m2 IN Var k', Var i EQ Q_Ex (Var sm), Var j EQ Q_Ex (Var sm'), SeqSubstFormP v a (Var sn) (Var sn') s (Var n), SeqSubstFormP v a (Var sm) (Var sm') s (Var m), Var n IN Var k, Var m IN Var k, All2 l (Var k) (SyntaxN.All i (SyntaxN.All j (SyntaxN.All j' (SyntaxN.All k' (SeqSubstFormP v a (Var i) (Var j) s (Var l) IMP SeqSubstFormP v a (Var i) (Var j') s' (Var k') IMP Var j' EQ Var j))))), SeqSubstFormP v a (Var i) (Var j') s' (Var k'), SeqSubstFormP v a (Var i) (Var j) s (Var k), OrdP (Var k)} ⊢ Var j' EQ Var j›*) apply (rule Eq_Trans_E [OF Hyp] (*‹⟦?x EQ ?u ∈ ?H; insert (?t EQ ?u) ?H ⊢ ?A⟧ ⟹ insert (?x EQ ?t) ?H ⊢ ?A›*), blast, force simp add: HTS (*‹0 < ?n ⟹ HTuple ?n = HPair Zero (HTuple (?n - 1))› ‹HTuple 0 = HPair Zero Zero› ‹HTuple (Suc ?k) = HPair Zero (HTuple ?k)›*)) (*top goal: ‹⟦atom i ♯ (s, s', v, a, x, y, y'); atom j ♯ (s, s', v, a, x, i, x, y, y'); atom j' ♯ (s, s', v, a, x, i, j, x, y, y'); atom k ♯ (s, s', v, a, x, y, y', kk', i, j, j'); atom k' ♯ (s, s', v, a, x, y, y', k, i, j, j'); atom l ♯ (s, s', v, a, x, i, j, j', k, k'); atom m ♯ (s, s', v, a, i, j, j', k, k', l); atom n ♯ (s, s', v, a, i, j, j', k, k', l, m); atom sm ♯ (s, s', v, a, i, j, j', k, k', l, m, n); atom sn ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm); atom sm' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn); atom sn' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm'); atom m2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn'); atom n2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2); atom sm2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2); atom sn2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2); atom sm2' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2, sn2); atom sn2' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2, sn2, sm2')⟧ ⟹ {Var i EQ Q_Neg (Var sm2), Var j' EQ Q_Neg (Var sm2'), SeqSubstFormP v a (Var sn2) (Var sn2') s' (Var n2), SeqSubstFormP v a (Var sm2) (Var sm2') s' (Var m2), Var n2 IN Var k', Var m2 IN Var k', Var i EQ Q_Ex (Var sm), Var j EQ Q_Ex (Var sm'), SeqSubstFormP v a (Var sn) (Var sn') s (Var n), SeqSubstFormP v a (Var sm) (Var sm') s (Var m), Var n IN Var k, Var m IN Var k, All2 l (Var k) (SyntaxN.All i (SyntaxN.All j (SyntaxN.All j' (SyntaxN.All k' (SeqSubstFormP v a (Var i) (Var j) s (Var l) IMP SeqSubstFormP v a (Var i) (Var j') s' (Var k') IMP Var j' EQ Var j))))), SeqSubstFormP v a (Var i) (Var j') s' (Var k'), SeqSubstFormP v a (Var i) (Var j) s (Var k), OrdP (Var k)} ⊢ Var j' EQ Var j› and 1 goal remains*) apply ((rule Conj_EH (*‹insert ?A (insert ?B ?H) ⊢ ?C ⟹ insert (?A AND ?B) ?H ⊢ ?C› ‹insert ?A (insert ?Ba (insert ?A1.0 ?H)) ⊢ ?B ⟹ insert ?A1.0 (insert (?A AND ?Ba) ?H) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 ?H))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert (?A AND ?Ba) ?H)) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 ?H)))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert (?A AND ?Ba) ?H))) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 ?H))))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert (?A AND ?Ba) ?H)))) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 ?H)))))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert (?A AND ?Ba) ?H))))) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 ?H))))))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert (?A AND ?Ba) ?H)))))) ⊢ ?B› ‹insert ?A (insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 ?H)))))))) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 (insert (?A AND ?Ba) ?H))))))) ⊢ ?B› ‹insert ?A (insert ?Ba (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))))))))) ⊢ ?B ⟹ 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 (?A AND ?Ba) ?H)))))))) ⊢ ?B› ‹insert ?A (insert ?Ba (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)))))))))) ⊢ ?B ⟹ 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 (?A AND ?Ba) ?H))))))))) ⊢ ?B›*))+) (*goal: ‹⟦atom (i::name) ♯ (s::tm, s'::tm, v::tm, a::tm, x::tm, y::tm, y'::tm); atom (j::name) ♯ (s, s', v, a, x, i, x, y, y'); atom (j'::name) ♯ (s, s', v, a, x, i, j, x, y, y'); atom (k::name) ♯ (s, s', v, a, x, y, y', kk'::tm, i, j, j'); atom (k'::name) ♯ (s, s', v, a, x, y, y', k, i, j, j'); atom (l::name) ♯ (s, s', v, a, x, i, j, j', k, k'); atom (m::name) ♯ (s, s', v, a, i, j, j', k, k', l); atom (n::name) ♯ (s, s', v, a, i, j, j', k, k', l, m); atom (sm::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n); atom (sn::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm); atom (sm'::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn); atom (sn'::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm'); atom (m2::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn'); atom (n2::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2); atom (sm2::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2); atom (sn2::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2); atom (sm2'::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2, sn2); atom (sn2'::name) ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2, sn2, sm2')⟧ ⟹ {Var i EQ Q_Ex (Var sm2) AND Var j' EQ Q_Ex (Var sm2'), SeqSubstFormP v a (Var sn2) (Var sn2') s' (Var n2), SeqSubstFormP v a (Var sm2) (Var sm2') s' (Var m2), Var n2 IN Var k', Var m2 IN Var k', Var i EQ Q_Ex (Var sm), Var j EQ Q_Ex (Var sm'), SeqSubstFormP v a (Var sn) (Var sn') s (Var n), SeqSubstFormP v a (Var sm) (Var sm') s (Var m), Var n IN Var k, Var m IN Var k, All2 l (Var k) (SyntaxN.All i (SyntaxN.All j (SyntaxN.All j' (SyntaxN.All k' (SeqSubstFormP v a (Var i) (Var j) s (Var l) IMP SeqSubstFormP v a (Var i) (Var j') s' (Var k') IMP Var j' EQ Var j))))), SeqSubstFormP v a (Var i) (Var j') s' (Var k'), SeqSubstFormP v a (Var i) (Var j) s (Var k), OrdP (Var k)} ⊢ Var j' EQ Var j›*) apply (rule Eq_Trans_E [OF Hyp] (*‹⟦?x EQ ?u ∈ ?H; insert (?t EQ ?u) ?H ⊢ ?A⟧ ⟹ insert (?x EQ ?t) ?H ⊢ ?A›*), blast, clarify) (*goal: ‹⟦atom i ♯ (s, s', v, a, x, y, y'); atom j ♯ (s, s', v, a, x, i, x, y, y'); atom j' ♯ (s, s', v, a, x, i, j, x, y, y'); atom k ♯ (s, s', v, a, x, y, y', kk', i, j, j'); atom k' ♯ (s, s', v, a, x, y, y', k, i, j, j'); atom l ♯ (s, s', v, a, x, i, j, j', k, k'); atom m ♯ (s, s', v, a, i, j, j', k, k', l); atom n ♯ (s, s', v, a, i, j, j', k, k', l, m); atom sm ♯ (s, s', v, a, i, j, j', k, k', l, m, n); atom sn ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm); atom sm' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn); atom sn' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm'); atom m2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn'); atom n2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2); atom sm2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2); atom sn2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2); atom sm2' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2, sn2); atom sn2' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2, sn2, sm2')⟧ ⟹ {Var i EQ Q_Ex (Var sm2), Var j' EQ Q_Ex (Var sm2'), SeqSubstFormP v a (Var sn2) (Var sn2') s' (Var n2), SeqSubstFormP v a (Var sm2) (Var sm2') s' (Var m2), Var n2 IN Var k', Var m2 IN Var k', Var i EQ Q_Ex (Var sm), Var j EQ Q_Ex (Var sm'), SeqSubstFormP v a (Var sn) (Var sn') s (Var n), SeqSubstFormP v a (Var sm) (Var sm') s (Var m), Var n IN Var k, Var m IN Var k, All2 l (Var k) (SyntaxN.All i (SyntaxN.All j (SyntaxN.All j' (SyntaxN.All k' (SeqSubstFormP v a (Var i) (Var j) s (Var l) IMP SeqSubstFormP v a (Var i) (Var j') s' (Var k') IMP Var j' EQ Var j))))), SeqSubstFormP v a (Var i) (Var j') s' (Var k'), SeqSubstFormP v a (Var i) (Var j) s (Var k), OrdP (Var k)} ⊢ Var j' EQ Var j›*) apply (rule thin1 (*‹?H ⊢ ?B ⟹ insert ?A ?H ⊢ ?B›*)) (*goal: ‹⟦atom i ♯ (s, s', v, a, x, y, y'); atom j ♯ (s, s', v, a, x, i, x, y, y'); atom j' ♯ (s, s', v, a, x, i, j, x, y, y'); atom k ♯ (s, s', v, a, x, y, y', kk', i, j, j'); atom k' ♯ (s, s', v, a, x, y, y', k, i, j, j'); atom l ♯ (s, s', v, a, x, i, j, j', k, k'); atom m ♯ (s, s', v, a, i, j, j', k, k', l); atom n ♯ (s, s', v, a, i, j, j', k, k', l, m); atom sm ♯ (s, s', v, a, i, j, j', k, k', l, m, n); atom sn ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm); atom sm' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn); atom sn' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm'); atom m2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn'); atom n2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2); atom sm2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2); atom sn2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2); atom sm2' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2, sn2); atom sn2' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2, sn2, sm2')⟧ ⟹ {HTuple 5 EQ HTuple 5, Var sm2 EQ Var sm, Var j' EQ Q_Ex (Var sm2'), SeqSubstFormP v a (Var sn2) (Var sn2') s' (Var n2), SeqSubstFormP v a (Var sm2) (Var sm2') s' (Var m2), Var n2 IN Var k', Var m2 IN Var k', Var i EQ Q_Ex (Var sm), Var j EQ Q_Ex (Var sm'), SeqSubstFormP v a (Var sn) (Var sn') s (Var n), SeqSubstFormP v a (Var sm) (Var sm') s (Var m), Var n IN Var k, Var m IN Var k, All2 l (Var k) (SyntaxN.All i (SyntaxN.All j (SyntaxN.All j' (SyntaxN.All k' (SeqSubstFormP v a (Var i) (Var j) s (Var l) IMP SeqSubstFormP v a (Var i) (Var j') s' (Var k') IMP Var j' EQ Var j))))), SeqSubstFormP v a (Var i) (Var j') s' (Var k'), SeqSubstFormP v a (Var i) (Var j) s (Var k), OrdP (Var k)} ⊢ Var j' EQ Var j›*) apply (rule All_E' [OF Hyp, where x="Var m"] (*‹⟦SyntaxN.All ?i ?A ∈ ?H; insert (?A(?i::=Var m)) ?H ⊢ ?B⟧ ⟹ ?H ⊢ ?B›*), blast, simp) (*goal: ‹⟦atom i ♯ (s, s', v, a, x, y, y'); atom j ♯ (s, s', v, a, x, i, x, y, y'); atom j' ♯ (s, s', v, a, x, i, j, x, y, y'); atom k ♯ (s, s', v, a, x, y, y', kk', i, j, j'); atom k' ♯ (s, s', v, a, x, y, y', k, i, j, j'); atom l ♯ (s, s', v, a, x, i, j, j', k, k'); atom m ♯ (s, s', v, a, i, j, j', k, k', l); atom n ♯ (s, s', v, a, i, j, j', k, k', l, m); atom sm ♯ (s, s', v, a, i, j, j', k, k', l, m, n); atom sn ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm); atom sm' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn); atom sn' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm'); atom m2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn'); atom n2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2); atom sm2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2); atom sn2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2); atom sm2' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2, sn2); atom sn2' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2, sn2, sm2')⟧ ⟹ {Var sm2 EQ Var sm, Var j' EQ Q_Ex (Var sm2'), SeqSubstFormP v a (Var sn2) (Var sn2') s' (Var n2), SeqSubstFormP v a (Var sm2) (Var sm2') s' (Var m2), Var n2 IN Var k', Var m2 IN Var k', Var i EQ Q_Ex (Var sm), Var j EQ Q_Ex (Var sm'), SeqSubstFormP v a (Var sn) (Var sn') s (Var n), SeqSubstFormP v a (Var sm) (Var sm') s (Var m), Var n IN Var k, Var m IN Var k, All2 l (Var k) (SyntaxN.All i (SyntaxN.All j (SyntaxN.All j' (SyntaxN.All k' (SeqSubstFormP v a (Var i) (Var j) s (Var l) IMP SeqSubstFormP v a (Var i) (Var j') s' (Var k') IMP Var j' EQ Var j))))), SeqSubstFormP v a (Var i) (Var j') s' (Var k'), SeqSubstFormP v a (Var i) (Var j) s (Var k), OrdP (Var k)} ⊢ Var j' EQ Var j›*) apply ((rule Disj_EH (*‹⟦insert (?A::fm) (?H::fm set) ⊢ (?C::fm); insert (?B::fm) ?H ⊢ ?C⟧ ⟹ insert (?A OR ?B) ?H ⊢ ?C› ‹⟦insert (?A::fm) (insert (?A1.0::fm) (?H::fm set)) ⊢ (?B::fm); insert (?Ba::fm) (insert ?A1.0 ?H) ⊢ ?B⟧ ⟹ insert ?A1.0 (insert (?A OR ?Ba) ?H) ⊢ ?B› ‹⟦insert (?A::fm) (insert (?A1.0::fm) (insert (?A2.0::fm) (?H::fm set))) ⊢ (?B::fm); insert (?Ba::fm) (insert ?A1.0 (insert ?A2.0 ?H)) ⊢ ?B⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert (?A OR ?Ba) ?H)) ⊢ ?B› ‹⟦insert (?A::fm) (insert (?A1.0::fm) (insert (?A2.0::fm) (insert (?A3.0::fm) (?H::fm set)))) ⊢ (?B::fm); insert (?Ba::fm) (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 ?H))) ⊢ ?B⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert (?A OR ?Ba) ?H))) ⊢ ?B› ‹⟦insert (?A::fm) (insert (?A1.0::fm) (insert (?A2.0::fm) (insert (?A3.0::fm) (insert (?A4.0::fm) (?H::fm set))))) ⊢ (?B::fm); insert (?Ba::fm) (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 ?H)))) ⊢ ?B⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert (?A OR ?Ba) ?H)))) ⊢ ?B› ‹⟦insert (?A::fm) (insert (?A1.0::fm) (insert (?A2.0::fm) (insert (?A3.0::fm) (insert (?A4.0::fm) (insert (?A5.0::fm) (?H::fm set)))))) ⊢ (?B::fm); insert (?Ba::fm) (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 ?H))))) ⊢ ?B⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert (?A OR ?Ba) ?H))))) ⊢ ?B› ‹⟦insert (?A::fm) (insert (?A1.0::fm) (insert (?A2.0::fm) (insert (?A3.0::fm) (insert (?A4.0::fm) (insert (?A5.0::fm) (insert (?A6.0::fm) (?H::fm set))))))) ⊢ (?B::fm); insert (?Ba::fm) (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 ?H)))))) ⊢ ?B⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert (?A OR ?Ba) ?H)))))) ⊢ ?B› ‹⟦insert (?A::fm) (insert (?A1.0::fm) (insert (?A2.0::fm) (insert (?A3.0::fm) (insert (?A4.0::fm) (insert (?A5.0::fm) (insert (?A6.0::fm) (insert (?A7.0::fm) (?H::fm set)))))))) ⊢ (?B::fm); insert (?Ba::fm) (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 ?H))))))) ⊢ ?B⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 (insert (?A OR ?Ba) ?H))))))) ⊢ ?B› ‹⟦insert (?A::fm) (insert (?A1.0::fm) (insert (?A2.0::fm) (insert (?A3.0::fm) (insert (?A4.0::fm) (insert (?A5.0::fm) (insert (?A6.0::fm) (insert (?A7.0::fm) (insert (?A8.0::fm) (?H::fm set))))))))) ⊢ (?B::fm); insert (?Ba::fm) (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)))))))) ⊢ ?B⟧ ⟹ 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 (?A OR ?Ba) ?H)))))))) ⊢ ?B› ‹⟦insert (?A::fm) (insert (?A1.0::fm) (insert (?A2.0::fm) (insert (?A3.0::fm) (insert (?A4.0::fm) (insert (?A5.0::fm) (insert (?A6.0::fm) (insert (?A7.0::fm) (insert (?A8.0::fm) (insert (?A9.0::fm) (?H::fm set)))))))))) ⊢ (?B::fm); insert (?Ba::fm) (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))))))))) ⊢ ?B⟧ ⟹ 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 (?A OR ?Ba) ?H))))))))) ⊢ ?B›*), blast intro: thin1 (*‹?H ⊢ ?B ⟹ insert ?A ?H ⊢ ?B›*) ContraProve (*‹?H ⊢ ?B ⟹ insert (Neg ?B) ?H ⊢ ?A›*))+) (*goal: ‹⟦atom i ♯ (s, s', v, a, x, y, y'); atom j ♯ (s, s', v, a, x, i, x, y, y'); atom j' ♯ (s, s', v, a, x, i, j, x, y, y'); atom k ♯ (s, s', v, a, x, y, y', kk', i, j, j'); atom k' ♯ (s, s', v, a, x, y, y', k, i, j, j'); atom l ♯ (s, s', v, a, x, i, j, j', k, k'); atom m ♯ (s, s', v, a, i, j, j', k, k', l); atom n ♯ (s, s', v, a, i, j, j', k, k', l, m); atom sm ♯ (s, s', v, a, i, j, j', k, k', l, m, n); atom sn ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm); atom sm' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn); atom sn' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm'); atom m2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn'); atom n2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2); atom sm2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2); atom sn2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2); atom sm2' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2, sn2); atom sn2' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2, sn2, sm2')⟧ ⟹ {Var m IN Var k IMP SyntaxN.All i (SyntaxN.All j (SyntaxN.All j' (SyntaxN.All k' (SeqSubstFormP v a (Var i) (Var j) s (Var m) IMP SeqSubstFormP v a (Var i) (Var j') s' (Var k') IMP Var j' EQ Var j)))), Var sm2 EQ Var sm, Var j' EQ Q_Ex (Var sm2'), SeqSubstFormP v a (Var sn2) (Var sn2') s' (Var n2), SeqSubstFormP v a (Var sm2) (Var sm2') s' (Var m2), Var n2 IN Var k', Var m2 IN Var k', Var i EQ Q_Ex (Var sm), Var j EQ Q_Ex (Var sm'), SeqSubstFormP v a (Var sn) (Var sn') s (Var n), SeqSubstFormP v a (Var sm) (Var sm') s (Var m), Var n IN Var k, Var m IN Var k, All2 l (Var k) (SyntaxN.All i (SyntaxN.All j (SyntaxN.All j' (SyntaxN.All k' (SeqSubstFormP v a (Var i) (Var j) s (Var l) IMP SeqSubstFormP v a (Var i) (Var j') s' (Var k') IMP Var j' EQ Var j))))), SeqSubstFormP v a (Var i) (Var j') s' (Var k'), SeqSubstFormP v a (Var i) (Var j) s (Var k), OrdP (Var k)} ⊢ Var j' EQ Var j›*) apply (rule All_E [where x="Var sm"] (*‹insert (?A(?i::=Var sm)) ?H ⊢ ?B ⟹ insert (SyntaxN.All ?i ?A) ?H ⊢ ?B›*), simp) (*goal: ‹⟦atom i ♯ (s, s', v, a, x, y, y'); atom j ♯ (s, s', v, a, x, i, x, y, y'); atom j' ♯ (s, s', v, a, x, i, j, x, y, y'); atom k ♯ (s, s', v, a, x, y, y', kk', i, j, j'); atom k' ♯ (s, s', v, a, x, y, y', k, i, j, j'); atom l ♯ (s, s', v, a, x, i, j, j', k, k'); atom m ♯ (s, s', v, a, i, j, j', k, k', l); atom n ♯ (s, s', v, a, i, j, j', k, k', l, m); atom sm ♯ (s, s', v, a, i, j, j', k, k', l, m, n); atom sn ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm); atom sm' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn); atom sn' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm'); atom m2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn'); atom n2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2); atom sm2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2); atom sn2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2); atom sm2' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2, sn2); atom sn2' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2, sn2, sm2')⟧ ⟹ {SyntaxN.All i (SyntaxN.All j (SyntaxN.All j' (SyntaxN.All k' (SeqSubstFormP v a (Var i) (Var j) s (Var m) IMP SeqSubstFormP v a (Var i) (Var j') s' (Var k') IMP Var j' EQ Var j)))), Var sm2 EQ Var sm, Var j' EQ Q_Ex (Var sm2'), SeqSubstFormP v a (Var sn2) (Var sn2') s' (Var n2), SeqSubstFormP v a (Var sm2) (Var sm2') s' (Var m2), Var n2 IN Var k', Var m2 IN Var k', Var i EQ Q_Ex (Var sm), Var j EQ Q_Ex (Var sm'), SeqSubstFormP v a (Var sn) (Var sn') s (Var n), SeqSubstFormP v a (Var sm) (Var sm') s (Var m), Var n IN Var k, Var m IN Var k, All2 l (Var k) (SyntaxN.All i (SyntaxN.All j (SyntaxN.All j' (SyntaxN.All k' (SeqSubstFormP v a (Var i) (Var j) s (Var l) IMP SeqSubstFormP v a (Var i) (Var j') s' (Var k') IMP Var j' EQ Var j))))), SeqSubstFormP v a (Var i) (Var j') s' (Var k'), SeqSubstFormP v a (Var i) (Var j) s (Var k), OrdP (Var k)} ⊢ Var j' EQ Var j›*) apply (rule All_E [where x="Var sm'"] (*‹insert (?A(?i::=Var sm')) ?H ⊢ ?B ⟹ insert (SyntaxN.All ?i ?A) ?H ⊢ ?B›*), simp) (*goal: ‹⟦atom i ♯ (s, s', v, a, x, y, y'); atom j ♯ (s, s', v, a, x, i, x, y, y'); atom j' ♯ (s, s', v, a, x, i, j, x, y, y'); atom k ♯ (s, s', v, a, x, y, y', kk', i, j, j'); atom k' ♯ (s, s', v, a, x, y, y', k, i, j, j'); atom l ♯ (s, s', v, a, x, i, j, j', k, k'); atom m ♯ (s, s', v, a, i, j, j', k, k', l); atom n ♯ (s, s', v, a, i, j, j', k, k', l, m); atom sm ♯ (s, s', v, a, i, j, j', k, k', l, m, n); atom sn ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm); atom sm' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn); atom sn' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm'); atom m2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn'); atom n2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2); atom sm2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2); atom sn2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2); atom sm2' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2, sn2); atom sn2' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2, sn2, sm2')⟧ ⟹ {SyntaxN.All j (SyntaxN.All j' (SyntaxN.All k' (SeqSubstFormP v a (Var sm) (Var j) s (Var m) IMP SeqSubstFormP v a (Var sm) (Var j') s' (Var k') IMP Var j' EQ Var j))), Var sm2 EQ Var sm, Var j' EQ Q_Ex (Var sm2'), SeqSubstFormP v a (Var sn2) (Var sn2') s' (Var n2), SeqSubstFormP v a (Var sm2) (Var sm2') s' (Var m2), Var n2 IN Var k', Var m2 IN Var k', Var i EQ Q_Ex (Var sm), Var j EQ Q_Ex (Var sm'), SeqSubstFormP v a (Var sn) (Var sn') s (Var n), SeqSubstFormP v a (Var sm) (Var sm') s (Var m), Var n IN Var k, Var m IN Var k, All2 l (Var k) (SyntaxN.All i (SyntaxN.All j (SyntaxN.All j' (SyntaxN.All k' (SeqSubstFormP v a (Var i) (Var j) s (Var l) IMP SeqSubstFormP v a (Var i) (Var j') s' (Var k') IMP Var j' EQ Var j))))), SeqSubstFormP v a (Var i) (Var j') s' (Var k'), SeqSubstFormP v a (Var i) (Var j) s (Var k), OrdP (Var k)} ⊢ Var j' EQ Var j›*) apply (rule All_E [where x="Var sm2'"] (*‹insert (?A(?i::=Var sm2')) ?H ⊢ ?B ⟹ insert (SyntaxN.All ?i ?A) ?H ⊢ ?B›*), simp) (*goal: ‹⟦atom i ♯ (s, s', v, a, x, y, y'); atom j ♯ (s, s', v, a, x, i, x, y, y'); atom j' ♯ (s, s', v, a, x, i, j, x, y, y'); atom k ♯ (s, s', v, a, x, y, y', kk', i, j, j'); atom k' ♯ (s, s', v, a, x, y, y', k, i, j, j'); atom l ♯ (s, s', v, a, x, i, j, j', k, k'); atom m ♯ (s, s', v, a, i, j, j', k, k', l); atom n ♯ (s, s', v, a, i, j, j', k, k', l, m); atom sm ♯ (s, s', v, a, i, j, j', k, k', l, m, n); atom sn ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm); atom sm' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn); atom sn' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm'); atom m2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn'); atom n2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2); atom sm2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2); atom sn2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2); atom sm2' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2, sn2); atom sn2' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2, sn2, sm2')⟧ ⟹ {SyntaxN.All j' (SyntaxN.All k' (SeqSubstFormP v a (Var sm) (Var sm') s (Var m) IMP SeqSubstFormP v a (Var sm) (Var j') s' (Var k') IMP Var j' EQ Var sm')), Var sm2 EQ Var sm, Var j' EQ Q_Ex (Var sm2'), SeqSubstFormP v a (Var sn2) (Var sn2') s' (Var n2), SeqSubstFormP v a (Var sm2) (Var sm2') s' (Var m2), Var n2 IN Var k', Var m2 IN Var k', Var i EQ Q_Ex (Var sm), Var j EQ Q_Ex (Var sm'), SeqSubstFormP v a (Var sn) (Var sn') s (Var n), SeqSubstFormP v a (Var sm) (Var sm') s (Var m), Var n IN Var k, Var m IN Var k, All2 l (Var k) (SyntaxN.All i (SyntaxN.All j (SyntaxN.All j' (SyntaxN.All k' (SeqSubstFormP v a (Var i) (Var j) s (Var l) IMP SeqSubstFormP v a (Var i) (Var j') s' (Var k') IMP Var j' EQ Var j))))), SeqSubstFormP v a (Var i) (Var j') s' (Var k'), SeqSubstFormP v a (Var i) (Var j) s (Var k), OrdP (Var k)} ⊢ Var j' EQ Var j›*) apply (rule All_E [where x="Var m2"] (*‹insert (?A(?i::=Var m2)) ?H ⊢ ?B ⟹ insert (SyntaxN.All ?i ?A) ?H ⊢ ?B›*), simp) (*goal: ‹⟦atom i ♯ (s, s', v, a, x, y, y'); atom j ♯ (s, s', v, a, x, i, x, y, y'); atom j' ♯ (s, s', v, a, x, i, j, x, y, y'); atom k ♯ (s, s', v, a, x, y, y', kk', i, j, j'); atom k' ♯ (s, s', v, a, x, y, y', k, i, j, j'); atom l ♯ (s, s', v, a, x, i, j, j', k, k'); atom m ♯ (s, s', v, a, i, j, j', k, k', l); atom n ♯ (s, s', v, a, i, j, j', k, k', l, m); atom sm ♯ (s, s', v, a, i, j, j', k, k', l, m, n); atom sn ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm); atom sm' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn); atom sn' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm'); atom m2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn'); atom n2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2); atom sm2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2); atom sn2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2); atom sm2' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2, sn2); atom sn2' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2, sn2, sm2')⟧ ⟹ {SyntaxN.All k' (SeqSubstFormP v a (Var sm) (Var sm') s (Var m) IMP SeqSubstFormP v a (Var sm) (Var sm2') s' (Var k') IMP Var sm2' EQ Var sm'), Var sm2 EQ Var sm, Var j' EQ Q_Ex (Var sm2'), SeqSubstFormP v a (Var sn2) (Var sn2') s' (Var n2), SeqSubstFormP v a (Var sm2) (Var sm2') s' (Var m2), Var n2 IN Var k', Var m2 IN Var k', Var i EQ Q_Ex (Var sm), Var j EQ Q_Ex (Var sm'), SeqSubstFormP v a (Var sn) (Var sn') s (Var n), SeqSubstFormP v a (Var sm) (Var sm') s (Var m), Var n IN Var k, Var m IN Var k, All2 l (Var k) (SyntaxN.All i (SyntaxN.All j (SyntaxN.All j' (SyntaxN.All k' (SeqSubstFormP v a (Var i) (Var j) s (Var l) IMP SeqSubstFormP v a (Var i) (Var j') s' (Var k') IMP Var j' EQ Var j))))), SeqSubstFormP v a (Var i) (Var j') s' (Var k'), SeqSubstFormP v a (Var i) (Var j) s (Var k), OrdP (Var k)} ⊢ Var j' EQ Var j›*) apply ((rule Disj_EH [OF ContraProve] (*‹⟦?H ⊢ ?B1; insert ?B ?H ⊢ ?C⟧ ⟹ insert (?B1 IMP ?B) ?H ⊢ ?C› ‹⟦insert ?A1.0 ?H ⊢ ?B1; insert ?Ba (insert ?A1.0 ?H) ⊢ ?B⟧ ⟹ insert ?A1.0 (insert (?B1 IMP ?Ba) ?H) ⊢ ?B› ‹⟦insert ?A1.0 (insert ?A2.0 ?H) ⊢ ?B1; insert ?Ba (insert ?A1.0 (insert ?A2.0 ?H)) ⊢ ?B⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert (?B1 IMP ?Ba) ?H)) ⊢ ?B› ‹⟦insert ?A1.0 (insert ?A2.0 (insert ?A3.0 ?H)) ⊢ ?B1; insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 ?H))) ⊢ ?B⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert (?B1 IMP ?Ba) ?H))) ⊢ ?B› ‹⟦insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 ?H))) ⊢ ?B1; insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 ?H)))) ⊢ ?B⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert (?B1 IMP ?Ba) ?H)))) ⊢ ?B› ‹⟦insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 ?H)))) ⊢ ?B1; insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 ?H))))) ⊢ ?B⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert (?B1 IMP ?Ba) ?H))))) ⊢ ?B› ‹⟦insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 ?H))))) ⊢ ?B1; insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 ?H)))))) ⊢ ?B⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert (?B1 IMP ?Ba) ?H)))))) ⊢ ?B› ‹⟦insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 ?H)))))) ⊢ ?B1; insert ?Ba (insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 ?H))))))) ⊢ ?B⟧ ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 (insert (?B1 IMP ?Ba) ?H))))))) ⊢ ?B› ‹⟦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))))))) ⊢ ?B1; insert ?Ba (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)))))))) ⊢ ?B⟧ ⟹ 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 (?B1 IMP ?Ba) ?H)))))))) ⊢ ?B› ‹⟦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)))))))) ⊢ ?B1; insert ?Ba (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))))))))) ⊢ ?B⟧ ⟹ 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 (?B1 IMP ?Ba) ?H))))))))) ⊢ ?B›*), blast intro: SeqSubstFormP_eq (*‹⟦(?H::fm set) ⊢ SeqSubstFormP (?v::tm) (?tm::tm) (?x::tm) (?z::tm) (?s::tm) (?k::tm); insert (SeqSubstFormP ?v ?tm (?y::tm) ?z ?s ?k) ?H ⊢ (?A::fm)⟧ ⟹ insert (?x EQ ?y) ?H ⊢ ?A›*) Sym_L (*‹insert ((?t::tm) EQ (?u::tm)) (?H::fm set) ⊢ (?A::fm) ⟹ insert (?u EQ ?t) ?H ⊢ ?A›*))+) (*goal: ‹⟦atom i ♯ (s, s', v, a, x, y, y'); atom j ♯ (s, s', v, a, x, i, x, y, y'); atom j' ♯ (s, s', v, a, x, i, j, x, y, y'); atom k ♯ (s, s', v, a, x, y, y', kk', i, j, j'); atom k' ♯ (s, s', v, a, x, y, y', k, i, j, j'); atom l ♯ (s, s', v, a, x, i, j, j', k, k'); atom m ♯ (s, s', v, a, i, j, j', k, k', l); atom n ♯ (s, s', v, a, i, j, j', k, k', l, m); atom sm ♯ (s, s', v, a, i, j, j', k, k', l, m, n); atom sn ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm); atom sm' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn); atom sn' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm'); atom m2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn'); atom n2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2); atom sm2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2); atom sn2 ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2); atom sm2' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2, sn2); atom sn2' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm', sn', m2, n2, sm2, sn2, sm2')⟧ ⟹ {SeqSubstFormP v a (Var sm) (Var sm') s (Var m) IMP SeqSubstFormP v a (Var sm) (Var sm2') s' (Var m2) IMP Var sm2' EQ Var sm', Var sm2 EQ Var sm, Var j' EQ Q_Ex (Var sm2'), SeqSubstFormP v a (Var sn2) (Var sn2') s' (Var n2), SeqSubstFormP v a (Var sm2) (Var sm2') s' (Var m2), Var n2 IN Var k', Var m2 IN Var k', Var i EQ Q_Ex (Var sm), Var j EQ Q_Ex (Var sm'), SeqSubstFormP v a (Var sn) (Var sn') s (Var n), SeqSubstFormP v a (Var sm) (Var sm') s (Var m), Var n IN Var k, Var m IN Var k, All2 l (Var k) (SyntaxN.All i (SyntaxN.All j (SyntaxN.All j' (SyntaxN.All k' (SeqSubstFormP v a (Var i) (Var j) s (Var l) IMP SeqSubstFormP v a (Var i) (Var j') s' (Var k') IMP Var j' EQ Var j))))), SeqSubstFormP v a (Var i) (Var j') s' (Var k'), SeqSubstFormP v a (Var i) (Var j) s (Var k), OrdP (Var k)} ⊢ Var j' EQ Var j›*) by (blast intro: HPair_cong (*‹⟦?H ⊢ ?t EQ ?t'; ?H ⊢ ?u EQ ?u'⟧ ⟹ ?H ⊢ HPair ?t ?u EQ HPair ?t' ?u'›*) Sym (*‹?H ⊢ ?t EQ ?u ⟹ ?H ⊢ ?u EQ ?t›*) Trans [OF Hyp] (*‹⟦?x EQ ?y ∈ ?H; ?H ⊢ ?y EQ ?z⟧ ⟹ ?H ⊢ ?x EQ ?z›*)) hence p1: "{OrdP (Var k)} ⊢ (All j (All j' (All k' (SeqSubstFormP v a (Var i) (Var j) s (Var k) IMP (SeqSubstFormP v a (Var i) (Var j') s' (Var k') IMP Var j' EQ Var j)))))(i::=x)" by (metis All_D (*‹?H ⊢ SyntaxN.All ?i ?A ⟹ ?H ⊢ ?A(?i::=?x)›*)) have p2: "{OrdP (Var k)} ⊢ (All j' (All k' (SeqSubstFormP v a x (Var j) s (Var k) IMP (SeqSubstFormP v a x (Var j') s' (Var k') IMP Var j' EQ Var j))))(j::=y)" apply (rule All_D (*‹(?H::fm set) ⊢ SyntaxN.All (?i::name) (?A::fm) ⟹ ?H ⊢ ?A(?i::=?x::tm)›*)) (*goal: ‹{OrdP (Var k)} ⊢ (SyntaxN.All j' (SyntaxN.All k' (SeqSubstFormP v a x (Var j) s (Var k) IMP SeqSubstFormP v a x (Var j') s' (Var k') IMP Var j' EQ Var j)))(j::=y)›*) using atoms (*‹atom (i::name) ♯ (s::tm, s'::tm, v::tm, a::tm, x::tm, y::tm, y'::tm)› ‹atom (j::name) ♯ (s::tm, s'::tm, v::tm, a::tm, x::tm, i::name, x, y::tm, y'::tm)› ‹atom (j'::name) ♯ (s::tm, s'::tm, v::tm, a::tm, x::tm, i::name, j::name, x, y::tm, y'::tm)› ‹atom k ♯ (s, s', v, a, x, y, y', kk', i, j, j')› ‹atom k' ♯ (s, s', v, a, x, y, y', k, i, j, j')› ‹atom l ♯ (s, s', v, a, x, i, j, j', k, k')› ‹atom m ♯ (s, s', v, a, i, j, j', k, k', l)› ‹atom n ♯ (s, s', v, a, i, j, j', k, k', l, m)› ‹atom sm ♯ (s, s', v, a, i, j, j', k, k', l, m, n)› ‹atom sn ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm)› ‹atom sm' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn)› ‹atom sn' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm')› and more 6 facts*) p1 (*‹{OrdP (Var k)} ⊢ (SyntaxN.All j (SyntaxN.All j' (SyntaxN.All k' (SeqSubstFormP v a (Var i) (Var j) s (Var k) IMP SeqSubstFormP v a (Var i) (Var j') s' (Var k') IMP Var j' EQ Var j))))(i::=x)›*) by simp have p3: "{OrdP (Var k)} ⊢ (All k' (SeqSubstFormP v a x y s (Var k) IMP (SeqSubstFormP v a x (Var j') s' (Var k') IMP Var j' EQ y)))(j'::=y')" apply (rule All_D (*‹?H ⊢ SyntaxN.All ?i ?A ⟹ ?H ⊢ ?A(?i::=?x)›*)) (*goal: ‹{OrdP (Var k)} ⊢ (SyntaxN.All k' (SeqSubstFormP v a x y s (Var k) IMP SeqSubstFormP v a x (Var j') s' (Var k') IMP Var j' EQ y))(j'::=y')›*) using atoms (*‹atom i ♯ (s, s', v, a, x, y, y')› ‹atom j ♯ (s, s', v, a, x, i, x, y, y')› ‹atom (j'::name) ♯ (s::tm, s'::tm, v::tm, a::tm, x::tm, i::name, j::name, x, y::tm, y'::tm)› ‹atom k ♯ (s, s', v, a, x, y, y', kk', i, j, j')› ‹atom (k'::name) ♯ (s::tm, s'::tm, v::tm, a::tm, x::tm, y::tm, y'::tm, k::name, i::name, j::name, j'::name)› ‹atom l ♯ (s, s', v, a, x, i, j, j', k, k')› ‹atom m ♯ (s, s', v, a, i, j, j', k, k', l)› ‹atom (n::name) ♯ (s::tm, s'::tm, v::tm, a::tm, i::name, j::name, j'::name, k::name, k'::name, l::name, m::name)› ‹atom sm ♯ (s, s', v, a, i, j, j', k, k', l, m, n)› ‹atom sn ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm)› ‹atom sm' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn)› ‹atom sn' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm')› and more 6 facts*) p2 (*‹{OrdP (Var k)} ⊢ (SyntaxN.All j' (SyntaxN.All k' (SeqSubstFormP v a x (Var j) s (Var k) IMP SeqSubstFormP v a x (Var j') s' (Var k') IMP Var j' EQ Var j)))(j::=y)›*) by simp have p4: "{OrdP (Var k)} ⊢ (SeqSubstFormP v a x y s (Var k) IMP (SeqSubstFormP v a x y' s' (Var k') IMP y' EQ y))(k'::=kk')" apply (rule All_D (*‹?H ⊢ SyntaxN.All ?i ?A ⟹ ?H ⊢ ?A(?i::=?x)›*)) (*goal: ‹{OrdP (Var k)} ⊢ (SeqSubstFormP v a x y s (Var k) IMP SeqSubstFormP v a x y' s' (Var k') IMP y' EQ y)(k'::=kk')›*) using atoms (*‹atom i ♯ (s, s', v, a, x, y, y')› ‹atom j ♯ (s, s', v, a, x, i, x, y, y')› ‹atom j' ♯ (s, s', v, a, x, i, j, x, y, y')› ‹atom k ♯ (s, s', v, a, x, y, y', kk', i, j, j')› ‹atom (k'::name) ♯ (s::tm, s'::tm, v::tm, a::tm, x::tm, y::tm, y'::tm, k::name, i::name, j::name, j'::name)› ‹atom l ♯ (s, s', v, a, x, i, j, j', k, k')› ‹atom m ♯ (s, s', v, a, i, j, j', k, k', l)› ‹atom n ♯ (s, s', v, a, i, j, j', k, k', l, m)› ‹atom (sm::name) ♯ (s::tm, s'::tm, v::tm, a::tm, i::name, j::name, j'::name, k::name, k'::name, l::name, m::name, n::name)› ‹atom sn ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm)› ‹atom sm' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn)› ‹atom sn' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm')› and more 6 facts*) p3 (*‹{OrdP (Var (k::name))} ⊢ (SyntaxN.All (k'::name) (SeqSubstFormP (v::tm) (a::tm) (x::tm) (y::tm) (s::tm) (Var k) IMP SeqSubstFormP v a x (Var (j'::name)) (s'::tm) (Var k') IMP Var j' EQ y))(j'::=y'::tm)›*) by simp hence "{OrdP (Var k)} ⊢ SeqSubstFormP v a x y s (Var k) IMP (SeqSubstFormP v a x y' s' kk' IMP y' EQ y)" using atoms (*‹atom i ♯ (s, s', v, a, x, y, y')› ‹atom j ♯ (s, s', v, a, x, i, x, y, y')› ‹atom j' ♯ (s, s', v, a, x, i, j, x, y, y')› ‹atom k ♯ (s, s', v, a, x, y, y', kk', i, j, j')› ‹atom k' ♯ (s, s', v, a, x, y, y', k, i, j, j')› ‹atom l ♯ (s, s', v, a, x, i, j, j', k, k')› ‹atom m ♯ (s, s', v, a, i, j, j', k, k', l)› ‹atom (n::name) ♯ (s::tm, s'::tm, v::tm, a::tm, i::name, j::name, j'::name, k::name, k'::name, l::name, m::name)› ‹atom sm ♯ (s, s', v, a, i, j, j', k, k', l, m, n)› ‹atom (sn::name) ♯ (s::tm, s'::tm, v::tm, a::tm, i::name, j::name, j'::name, k::name, k'::name, l::name, m::name, n::name, sm::name)› ‹atom sm' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn)› ‹atom sn' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm')› and more 6 facts*) by simp hence "{SeqSubstFormP v a x y s (Var k)} ⊢ SeqSubstFormP v a x y s (Var k) IMP (SeqSubstFormP v a x y' s' kk' IMP y' EQ y)" by (metis SeqSubstFormP_imp_OrdP (*‹{SeqSubstFormP ?v ?u ?x ?x' ?s ?k} ⊢ OrdP ?k›*) rcut1 (*‹⟦{?A} ⊢ ?B; insert ?B ?H ⊢ ?C⟧ ⟹ insert ?A ?H ⊢ ?C›*)) hence "{} ⊢ SeqSubstFormP v a x y s (Var k) IMP (SeqSubstFormP v a x y' s' kk' IMP y' EQ y)" by (metis Assume (*‹insert (?A::fm) (?H::fm set) ⊢ ?A›*) Disj_Neg_2 (*‹⟦(?H::fm set) ⊢ (?A::fm) OR (?B::fm); ?H ⊢ Neg ?A⟧ ⟹ ?H ⊢ ?B›*) Disj_commute (*‹(?H::fm set) ⊢ (?B::fm) OR (?A::fm) ⟹ ?H ⊢ ?A OR ?B›*) anti_deduction (*‹(?H::fm set) ⊢ (?A::fm) IMP (?B::fm) ⟹ insert ?A ?H ⊢ ?B›*) Imp_I (*‹insert (?A::fm) (?H::fm set) ⊢ (?B::fm) ⟹ ?H ⊢ ?A IMP ?B›*)) hence "{} ⊢ ((SeqSubstFormP v a x y s (Var k) IMP (SeqSubstFormP v a x y' s' kk' IMP y' EQ y)))(k::=kk)" using atoms (*‹atom (i::name) ♯ (s::tm, s'::tm, v::tm, a::tm, x::tm, y::tm, y'::tm)› ‹atom j ♯ (s, s', v, a, x, i, x, y, y')› ‹atom j' ♯ (s, s', v, a, x, i, j, x, y, y')› ‹atom k ♯ (s, s', v, a, x, y, y', kk', i, j, j')› ‹atom k' ♯ (s, s', v, a, x, y, y', k, i, j, j')› ‹atom l ♯ (s, s', v, a, x, i, j, j', k, k')› ‹atom m ♯ (s, s', v, a, i, j, j', k, k', l)› ‹atom n ♯ (s, s', v, a, i, j, j', k, k', l, m)› ‹atom (sm::name) ♯ (s::tm, s'::tm, v::tm, a::tm, i::name, j::name, j'::name, k::name, k'::name, l::name, m::name, n::name)› ‹atom sn ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm)› ‹atom sm' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn)› ‹atom sn' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn, sm')› and more 6 facts*) by (force intro!: Subst (*‹⟦?H ⊢ ?A; ∀B∈?H. atom ?i ♯ B⟧ ⟹ ?H ⊢ ?A(?i::=?x)›*)) thus "?thesis" (*goal: ‹{SeqSubstFormP v a x y s kk, SeqSubstFormP v a x y' s' kk'} ⊢ y' EQ y›*) using atoms (*‹atom i ♯ (s, s', v, a, x, y, y')› ‹atom (j::name) ♯ (s::tm, s'::tm, v::tm, a::tm, x::tm, i::name, x, y::tm, y'::tm)› ‹atom j' ♯ (s, s', v, a, x, i, j, x, y, y')› ‹atom k ♯ (s, s', v, a, x, y, y', kk', i, j, j')› ‹atom k' ♯ (s, s', v, a, x, y, y', k, i, j, j')› ‹atom l ♯ (s, s', v, a, x, i, j, j', k, k')› ‹atom m ♯ (s, s', v, a, i, j, j', k, k', l)› ‹atom (n::name) ♯ (s::tm, s'::tm, v::tm, a::tm, i::name, j::name, j'::name, k::name, k'::name, l::name, m::name)› ‹atom (sm::name) ♯ (s::tm, s'::tm, v::tm, a::tm, i::name, j::name, j'::name, k::name, k'::name, l::name, m::name, n::name)› ‹atom sn ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm)› ‹atom sm' ♯ (s, s', v, a, i, j, j', k, k', l, m, n, sm, sn)› ‹atom (sn'::name) ♯ (s::tm, s'::tm, v::tm, a::tm, i::name, j::name, j'::name, k::name, k'::name, l::name, m::name, n::name, sm::name, sn::name, sm'::name)› and more 6 facts*) apply simp (*goal: ‹{SeqSubstFormP v a x y s kk, SeqSubstFormP v a x y' s' kk'} ⊢ y' EQ y›*) by (metis DisjAssoc2 (*‹(?H::fm set) ⊢ ((?A::fm) OR (?B::fm)) OR (?C::fm) ⟹ ?H ⊢ ?A OR ?B OR ?C›*) Disj_commute (*‹(?H::fm set) ⊢ (?B::fm) OR (?A::fm) ⟹ ?H ⊢ ?A OR ?B›*) anti_deduction (*‹(?H::fm set) ⊢ (?A::fm) IMP (?B::fm) ⟹ insert ?A ?H ⊢ ?B›*)) qed subsection‹@{term SubstFormP}› theorem SubstFormP_unique: "{SubstFormP v tm x y, SubstFormP v tm x y'} ⊢ y' EQ y" proof (-) (*goal: ‹{SubstFormP v tm x y, SubstFormP v tm x y'} ⊢ y' EQ y›*) obtain s :: name and s' :: name and k :: name and k' :: name where "atom s ♯ (v,tm,x,y,y',k,k')" "atom s' ♯ (v,tm,x,y,y',k,k',s)" "atom k ♯ (v,tm,x,y,y')" "atom k' ♯ (v,tm,x,y,y',k)" (*goal: ‹(⋀s k k' s'. ⟦atom s ♯ (v, tm, x, y, y', k, k'); atom s' ♯ (v, tm, x, y, y', k, k', s); atom k ♯ (v, tm, x, y, y'); atom k' ♯ (v, tm, x, y, y', k)⟧ ⟹ thesis) ⟹ thesis›*) by (metis obtain_fresh (*‹(⋀a. atom a ♯ ?x ⟹ ?thesis) ⟹ ?thesis›*)) thus "?thesis" (*goal: ‹{SubstFormP v tm x y, SubstFormP v tm x y'} ⊢ y' EQ y›*) by (force simp: SubstFormP.simps [of s v tm x y k] (*‹⟦atom s ♯ (v, tm, x, y, k); atom k ♯ (v, tm, x, y)⟧ ⟹ SubstFormP v tm x y = VarP v AND TermP tm AND SyntaxN.Ex s (SyntaxN.Ex k (SeqSubstFormP v tm x y (Var s) (Var k)))›*) SubstFormP.simps [of s' v tm x y' k'] (*‹⟦atom s' ♯ (v, tm, x, y', k'); atom k' ♯ (v, tm, x, y')⟧ ⟹ SubstFormP v tm x y' = VarP v AND TermP tm AND SyntaxN.Ex s' (SyntaxN.Ex k' (SeqSubstFormP v tm x y' (Var s') (Var k')))›*) SeqSubstFormP_unique (*‹{SeqSubstFormP ?v ?a ?x ?y ?s ?kk, SeqSubstFormP ?v ?a ?x ?y' ?s' ?kk'} ⊢ ?y' EQ ?y›*) rotate3 (*‹insert ?A3.0 (insert ?A1.0 (insert ?A2.0 ?H)) ⊢ ?B ⟹ insert ?A1.0 (insert ?A2.0 (insert ?A3.0 ?H)) ⊢ ?B›*) thin1 (*‹?H ⊢ ?B ⟹ insert ?A ?H ⊢ ?B›*)) qed end
{ "path": "afp-2025-02-12/thys/Goedel_HFSet_Semanticless/Functions.thy", "repo": "afp-2025-02-12", "sha": "37beb192d8d55036b5190d1cba5b488d66e4994f4927d78bad738b11f33d36b6" }
(******************************************************************************* Project: Development of Security Protocols by Refinement Module: Key_establish/m3_ds.thy (Isabelle/HOL 2016-1) ID: $Id: m3_ds.thy 132890 2016-12-24 10:25:57Z csprenge $ Authors: Christoph Sprenger, ETH Zurich <sprenger@inf.ethz.ch> Ivano Somaini, ETH Zurich <somainii@student.ethz.ch> Key distribution protocols Level 3: Denning-Sacco protocol Copyright (c) 2009-2016 Christoph Sprenger, Ivano Somaini Licence: LGPL *******************************************************************************) section ‹Denning-Sacco protocol (L3)› theory m3_ds imports m2_ds "../Refinement/Message" begin text ‹ We model the Denning-Sacco protocol: \[ \begin{array}{lll} \mathrm{M1.} & A \rightarrow S: & A, B \\ \mathrm{M2.} & S \rightarrow A: & \{Kab, B, Ts, Na, \{Kab, A, Ts\}_{Kbs} \}_{Kas} \\ \mathrm{M3.} & A \rightarrow B: & \{Kab, A, Ts\}_{Kbs} \end{array} \] › text ‹Proof tool configuration. Avoid annoying automatic unfolding of ‹dom›.› declare domIff [simp, iff del] (******************************************************************************) subsection ‹Setup› (******************************************************************************) text ‹Now we can define the initial key knowledge.› overloading ltkeySetup' ≡ ltkeySetup begin definition ltkeySetup_def: "ltkeySetup' ≡ {(sharK C, A) | C A. A = C ∨ A = Sv}" end lemma corrKey_shrK_bad [simp]: "corrKey = shrK`bad" by (auto simp add: keySetup_def (*‹keySetup ≡ {(ltK K, A) |K A. (K, A) ∈ ltkeySetup}›*) ltkeySetup_def (*‹ltkeySetup ≡ {(sharK C, A) |C A. A = C ∨ A = Sv}›*) corrKey_def (*‹corrKey ≡ keySetup¯ `` bad›*)) (******************************************************************************) subsection ‹State› (******************************************************************************) text ‹The secure channels are star-shaped to/from the server. Therefore, we have only one agent in the relation.› record m3_state = "m1_state" + IK :: "msg set" ― ‹intruder knowledge› text ‹Observable state: @{term "runs"}, @{term "leak"}, @{term "clk"}, and @{term "cache"}.› type_synonym m3_obs = "m2_obs" definition m3_obs :: "m3_state ⇒ m3_obs" where "m3_obs s ≡ ⦇ runs = runs s, leak = leak s, clk = clk s ⦈" type_synonym m3_pred = "m3_state set" type_synonym m3_trans = "(m3_state × m3_state) set" (******************************************************************************) subsection ‹Events› (******************************************************************************) text ‹Protocol events.› definition ― ‹by @{term "A"}, refines @{term "m2_step1"}› m3_step1 :: "[rid_t, agent, agent] ⇒ m3_trans" where "m3_step1 Ra A B ≡ {(s, s1). ― ‹guards:› Ra ∉ dom (runs s) ∧ ― ‹‹Ra› is fresh› ― ‹actions:› s1 = s⦇ runs := (runs s)(Ra ↦ (Init, [A, B], [])), IK := insert ⦃Agent A, Agent B⦄ (IK s) ― ‹send ‹M1›› ⦈ }" definition ― ‹by @{term "B"}, refines @{term "m2_step2"}› m3_step2 :: "[rid_t, agent, agent] ⇒ m3_trans" where "m3_step2 ≡ m1_step2" definition ― ‹by @{text "Server"}, refines @{term m2_step3}› m3_step3 :: "[rid_t, agent, agent, key, time] ⇒ m3_trans" where "m3_step3 Rs A B Kab Ts ≡ {(s, s1). ― ‹guards:› Rs ∉ dom (runs s) ∧ ― ‹fresh server run› Kab = sesK (Rs$sk) ∧ ― ‹fresh session key› ⦃Agent A, Agent B⦄ ∈ IK s ∧ ― ‹recv ‹M1›› Ts = clk s ∧ ― ‹fresh timestamp› ― ‹actions:› ― ‹record session key and send ‹M2›› s1 = s⦇ runs := (runs s)(Rs ↦ (Serv, [A, B], [aNum Ts])), IK := insert (Crypt (shrK A) ― ‹send ‹M2›› ⦃Key Kab, Agent B, Number Ts, Crypt (shrK B) ⦃Key Kab, Agent A, Number Ts⦄⦄) (IK s) ⦈ }" definition ― ‹by @{term "A"}, refines @{term m2_step4}› m3_step4 :: "[rid_t, agent, agent, key, time, msg] ⇒ m3_trans" where "m3_step4 Ra A B Kab Ts X ≡ {(s, s1). ― ‹guards:› runs s Ra = Some (Init, [A, B], []) ∧ ― ‹key not yet recv'd› Crypt (shrK A) ― ‹recv ‹M2›› ⦃Key Kab, Agent B, Number Ts, X⦄ ∈ IK s ∧ ― ‹check freshness of session key› clk s < Ts + Ls ∧ ― ‹actions:› ― ‹record session key and send ‹M3›› s1 = s⦇ runs := (runs s)(Ra ↦ (Init, [A, B], [aKey Kab, aNum Ts])), IK := insert X (IK s) ― ‹send ‹M3›› ⦈ }" definition ― ‹by @{term "B"}, refines @{term m2_step5}› m3_step5 :: "[rid_t, agent, agent, key, time] ⇒ m3_trans" where "m3_step5 Rb A B Kab Ts ≡ {(s, s1). ― ‹guards:› runs s Rb = Some (Resp, [A, B], []) ∧ ― ‹key not yet recv'd› Crypt (shrK B) ⦃Key Kab, Agent A, Number Ts⦄ ∈ IK s ∧ ― ‹recv ‹M3›› ― ‹ensure freshness of session key; replays with fresh authenticator ok!› clk s < Ts + Ls ∧ ― ‹actions:› ― ‹record session key› s1 = s⦇ runs := (runs s)(Rb ↦ (Resp, [A, B], [aKey Kab, aNum Ts])) ⦈ }" text ‹Clock tick event› definition ― ‹refines @{term "m2_tick"}› m3_tick :: "time ⇒ m3_trans" where "m3_tick ≡ m1_tick" text ‹Session key compromise.› definition ― ‹refines @{term m2_leak}› m3_leak :: "rid_t ⇒ m3_trans" where "m3_leak Rs ≡ {(s, s1). ― ‹guards:› Rs ∈ dom (runs s) ∧ fst (the (runs s Rs)) = Serv ∧ ― ‹compromise server run ‹Rs›› ― ‹actions:› ― ‹record session key as leaked and add it to intruder knowledge› s1 = s⦇ leak := insert (sesK (Rs$sk)) (leak s), IK := insert (Key (sesK (Rs$sk))) (IK s) ⦈ }" text ‹Intruder fake event. The following "Dolev-Yao" event generates all intruder-derivable messages.› definition ― ‹refines @{term "m2_fake"}› m3_DY_fake :: "m3_trans" where "m3_DY_fake ≡ {(s, s1). ― ‹actions:› s1 = s⦇ IK := synth (analz (IK s)) ⦈ ― ‹take DY closure› }" (******************************************************************************) subsection ‹Transition system› (******************************************************************************) definition m3_init :: "m3_pred" where "m3_init ≡ { ⦇ runs = Map.empty, leak = shrK`bad, clk = 0, IK = Key`shrK`bad ⦈ }" definition m3_trans :: "m3_trans" where "m3_trans ≡ (⋃A B Ra Rb Rs Kab Ts T X. m3_step1 Ra A B ∪ m3_step2 Rb A B ∪ m3_step3 Rs A B Kab Ts ∪ m3_step4 Ra A B Kab Ts X ∪ m3_step5 Rb A B Kab Ts ∪ m3_tick T ∪ m3_leak Rs ∪ m3_DY_fake ∪ Id )" definition m3 :: "(m3_state, m3_obs) spec" where "m3 ≡ ⦇ init = m3_init, trans = m3_trans, obs = m3_obs ⦈" lemmas m3_loc_defs = m3_def m3_init_def m3_trans_def m3_obs_def m3_step1_def m3_step2_def m3_step3_def m3_step4_def m3_step5_def m3_tick_def m3_leak_def m3_DY_fake_def lemmas m3_defs = m3_loc_defs m2_defs (******************************************************************************) subsection ‹Invariants› (******************************************************************************) text ‹Specialized injection that we can apply more aggressively.› lemmas analz_Inj_IK = analz.Inj [where H="IK s" for s] lemmas parts_Inj_IK = parts.Inj [where H="IK s" for s] declare parts_Inj_IK [dest!] declare analz_into_parts [dest] subsubsection ‹inv1: Secrecy of pre-distributed shared keys› (******************************************************************************) definition m3_inv1_lkeysec :: "m3_pred" where "m3_inv1_lkeysec ≡ {s. ∀C. (Key (shrK C) ∈ parts (IK s) ⟶ C ∈ bad) ∧ (C ∈ bad ⟶ Key (shrK C) ∈ IK s) }" lemmas m3_inv1_lkeysecI = m3_inv1_lkeysec_def [THEN setc_def_to_intro, rule_format] lemmas m3_inv1_lkeysecE [elim] = m3_inv1_lkeysec_def [THEN setc_def_to_elim, rule_format] lemmas m3_inv1_lkeysecD = m3_inv1_lkeysec_def [THEN setc_def_to_dest, rule_format] text ‹Invariance proof.› lemma PO_m3_inv1_lkeysec_init [iff]: "init m3 ⊆ m3_inv1_lkeysec" by (auto simp add: m3_defs (*‹m3 ≡ ⦇init = m3_init, trans = m3_trans, obs = m3_obs⦈› ‹m3_init ≡ {⦇runs = λx. None, leak = shrK ` bad, clk = 0, IK = Key ` shrK ` bad⦈}› ‹m3_trans ≡ ⋃A B Ra Rb Rs Kab Ts T X. (m3_step1 Ra A B ∪ m3_step2 Rb A B ∪ m3_step3 Rs A B Kab Ts ∪ m3_step4 Ra A B Kab Ts X ∪ m3_step5 Rb A B Kab Ts ∪ m3_tick T ∪ m3_leak Rs ∪ m3_DY_fake)⁼› ‹m3_obs ?s ≡ ⦇runs = runs ?s, leak = leak ?s, clk = clk ?s⦈› ‹m3_step1 ?Ra ?A ?B ≡ {(s, s1). ?Ra ∉ dom (runs s) ∧ s1 = s⦇runs := (runs s)(?Ra ↦ (Init, [?A, ?B], [])), IK := insert ⦃msg.Agent ?A, msg.Agent ?B⦄ (IK s)⦈}› ‹m3_step2 ≡ m1_step2› ‹m3_step3 ?Rs ?A ?B ?Kab ?Ts ≡ {(s, s1). ?Rs ∉ dom (runs s) ∧ ?Kab = sesK (?Rs $ sk) ∧ ⦃msg.Agent ?A, msg.Agent ?B⦄ ∈ IK s ∧ ?Ts = clk s ∧ s1 = s⦇runs := (runs s)(?Rs ↦ (Serv, [?A, ?B], [aNum ?Ts])), IK := insert (Crypt (shrK ?A) ⦃Key ?Kab, msg.Agent ?B, Number ?Ts, Crypt (shrK ?B) ⦃Key ?Kab, msg.Agent ?A, Number ?Ts⦄⦄) (IK s)⦈}› ‹m3_step4 ?Ra ?A ?B ?Kab ?Ts ?X ≡ {(s, s1). runs s ?Ra = Some (Init, [?A, ?B], []) ∧ Crypt (shrK ?A) ⦃Key ?Kab, msg.Agent ?B, Number ?Ts, ?X⦄ ∈ IK s ∧ clk s < ?Ts + Ls ∧ s1 = s⦇runs := (runs s)(?Ra ↦ (Init, [?A, ?B], [aKey ?Kab, aNum ?Ts])), IK := insert ?X (IK s)⦈}› ‹m3_step5 ?Rb ?A ?B ?Kab ?Ts ≡ {(s, s1). runs s ?Rb = Some (Resp, [?A, ?B], []) ∧ Crypt (shrK ?B) ⦃Key ?Kab, msg.Agent ?A, Number ?Ts⦄ ∈ IK s ∧ clk s < ?Ts + Ls ∧ s1 = s⦇runs := (runs s)(?Rb ↦ (Resp, [?A, ?B], [aKey ?Kab, aNum ?Ts]))⦈}› ‹m3_tick ≡ m1_tick› ‹m3_leak ?Rs ≡ {(s, s1). ?Rs ∈ dom (runs s) ∧ fst (the (runs s ?Rs)) = Serv ∧ s1 = s⦇leak := insert (sesK (?Rs $ sk)) (leak s), IK := insert (Key (sesK (?Rs $ sk))) (IK s)⦈}› ‹m3_DY_fake ≡ {(s, s1). s1 = s⦇IK := synth (analz (IK s))⦈}› and more 40 facts*) intro!: m3_inv1_lkeysecI (*‹(⋀C. (Key (shrK C) ∈ parts (IK ?x) ⟶ C ∈ bad) ∧ (C ∈ bad ⟶ Key (shrK C) ∈ IK ?x)) ⟹ ?x ∈ m3_inv1_lkeysec›*)) lemma PO_m3_inv1_lkeysec_trans [iff]: "{m3_inv1_lkeysec} trans m3 {> m3_inv1_lkeysec}" apply (auto simp add: PO_hoare_defs (*‹{?pre::?'s set} ?R::(?'s × ?'s) set {> ?post::?'s set} ≡ ?R `` ?pre ⊆ ?post› ‹(?r::(?'a × ?'b) set) `` (?s::?'a set) = {y::?'b. ∃x::?'a∈?s. (x, y) ∈ ?r}›*) m3_defs (*‹m3 ≡ ⦇init = m3_init, trans = m3_trans, obs = m3_obs⦈› ‹m3_init ≡ {⦇runs = λx::fid_t. None, leak = shrK ` bad, clk = 0::nat, IK = Key ` shrK ` bad⦈}› ‹m3_trans ≡ ⋃(A::agent) (B::agent) (Ra::fid_t) (Rb::fid_t) (Rs::fid_t) (Kab::key) (Ts::nat) (T::nat) X::msg. (m3_step1 Ra A B ∪ m3_step2 Rb A B ∪ m3_step3 Rs A B Kab Ts ∪ m3_step4 Ra A B Kab Ts X ∪ m3_step5 Rb A B Kab Ts ∪ m3_tick T ∪ m3_leak Rs ∪ m3_DY_fake)⁼› ‹m3_obs (?s::m3_state) ≡ ⦇runs = runs ?s, leak = leak ?s, clk = clk ?s⦈› ‹m3_step1 (?Ra::fid_t) (?A::agent) (?B::agent) ≡ {(s::m3_state, s1::m3_state). ?Ra ∉ dom (runs s) ∧ s1 = s⦇runs := (runs s)(?Ra ↦ (Init, [?A, ?B], [])), IK := insert ⦃msg.Agent ?A, msg.Agent ?B⦄ (IK s)⦈}› ‹m3_step2 ≡ m1_step2› ‹m3_step3 (?Rs::fid_t) (?A::agent) (?B::agent) (?Kab::key) (?Ts::nat) ≡ {(s::m3_state, s1::m3_state). ?Rs ∉ dom (runs s) ∧ ?Kab = sesK (?Rs $ sk) ∧ ⦃msg.Agent ?A, msg.Agent ?B⦄ ∈ IK s ∧ ?Ts = clk s ∧ s1 = s⦇runs := (runs s)(?Rs ↦ (Serv, [?A, ?B], [aNum ?Ts])), IK := insert (Crypt (shrK ?A) ⦃Key ?Kab, msg.Agent ?B, Number ?Ts, Crypt (shrK ?B) ⦃Key ?Kab, msg.Agent ?A, Number ?Ts⦄⦄) (IK s)⦈}› ‹m3_step4 (?Ra::fid_t) (?A::agent) (?B::agent) (?Kab::key) (?Ts::nat) (?X::msg) ≡ {(s::m3_state, s1::m3_state). runs s ?Ra = Some (Init, [?A, ?B], []) ∧ Crypt (shrK ?A) ⦃Key ?Kab, msg.Agent ?B, Number ?Ts, ?X⦄ ∈ IK s ∧ clk s < ?Ts + Ls ∧ s1 = s⦇runs := (runs s)(?Ra ↦ (Init, [?A, ?B], [aKey ?Kab, aNum ?Ts])), IK := insert ?X (IK s)⦈}› ‹m3_step5 (?Rb::fid_t) (?A::agent) (?B::agent) (?Kab::key) (?Ts::nat) ≡ {(s::m3_state, s1::m3_state). runs s ?Rb = Some (Resp, [?A, ?B], []) ∧ Crypt (shrK ?B) ⦃Key ?Kab, msg.Agent ?A, Number ?Ts⦄ ∈ IK s ∧ clk s < ?Ts + Ls ∧ s1 = s⦇runs := (runs s)(?Rb ↦ (Resp, [?A, ?B], [aKey ?Kab, aNum ?Ts]))⦈}› ‹m3_tick ≡ m1_tick› ‹m3_leak (?Rs::fid_t) ≡ {(s::m3_state, s1::m3_state). ?Rs ∈ dom (runs s) ∧ fst (the (runs s ?Rs)) = Serv ∧ s1 = s⦇leak := insert (sesK (?Rs $ sk)) (leak s), IK := insert (Key (sesK (?Rs $ sk))) (IK s)⦈}› ‹m3_DY_fake ≡ {(s::m3_state, s1::m3_state). s1 = s⦇IK := synth (analz (IK s))⦈}› and more 40 facts*) intro!: m3_inv1_lkeysecI (*‹(⋀C::agent. (Key (shrK C) ∈ parts (IK (?x::m3_state)) ⟶ C ∈ bad) ∧ (C ∈ bad ⟶ Key (shrK C) ∈ IK ?x)) ⟹ ?x ∈ m3_inv1_lkeysec›*)) (*goals: 1. ‹⋀C xa xb xc xd xg xh xi. ⟦xa ∈ m3_inv1_lkeysec; runs xa xd = Some (Init, [xb, xc], []); Crypt (shrK xb) ⦃Key xg, msg.Agent xc, Number xh, xi⦄ ∈ parts (IK xa); clk xa < xh + Ls; Key (shrK C) ∈ parts (insert xi (IK xa))⟧ ⟹ C ∈ bad› 2. ‹⋀C xa. ⟦xa ∈ m3_inv1_lkeysec; Key (shrK C) ∈ parts (IK xa)⟧ ⟹ C ∈ bad› 3. ‹⋀C xa. ⟦xa ∈ m3_inv1_lkeysec; Key (shrK C) ∈ analz (IK xa)⟧ ⟹ C ∈ bad› discuss goal 1*) apply ((auto dest!: Body (*‹Crypt ?K ?X ∈ parts ?H ⟹ ?X ∈ parts ?H›*))[1]) (*discuss goal 2*) apply ((auto dest!: Body (*‹Crypt ?K ?X ∈ parts ?H ⟹ ?X ∈ parts ?H›*))[1]) (*discuss goal 3*) apply ((auto dest!: Body (*‹Crypt ?K ?X ∈ parts ?H ⟹ ?X ∈ parts ?H›*))[1]) (*proven 3 subgoals*) . lemma PO_m3_inv1_lkeysec [iff]: "reach m3 ⊆ m3_inv1_lkeysec" apply (rule inv_rule_incr (*‹⟦init (?T::(?'a, ?'b) TS_scheme) ⊆ (?I::?'a::type set); {?I ∩ (?J::?'a::type set)} TS.trans ?T {> ?I}; reach ?T ⊆ ?J⟧ ⟹ reach ?T ⊆ ?I›*)) (*goals: 1. ‹init m3 ⊆ m3_inv1_lkeysec› 2. ‹{m3_inv1_lkeysec ∩ ?J} TS.trans m3 {> m3_inv1_lkeysec}› 3. ‹reach m3 ⊆ ?J› discuss goal 1*) apply fast (*discuss goal 2*) apply fast (*discuss goal 3*) apply fast (*proven 3 subgoals*) . text ‹Useful simplifier lemmas› lemma m3_inv1_lkeysec_for_parts [simp]: "⟦ s ∈ m3_inv1_lkeysec ⟧ ⟹ Key (shrK C) ∈ parts (IK s) ⟷ C ∈ bad" by auto lemma m3_inv1_lkeysec_for_analz [simp]: "⟦ s ∈ m3_inv1_lkeysec ⟧ ⟹ Key (shrK C) ∈ analz (IK s) ⟷ C ∈ bad" by auto subsubsection ‹inv2: Ticket shape for honestly encrypted M2› (******************************************************************************) definition m3_inv2_ticket :: "m3_pred" where "m3_inv2_ticket ≡ {s. ∀A B T K X. A ∉ bad ⟶ Crypt (shrK A) ⦃Key K, Agent B, Number T, X⦄ ∈ parts (IK s) ⟶ X = Crypt (shrK B) ⦃Key K, Agent A, Number T⦄ ∧ K ∈ range sesK }" lemmas m3_inv2_ticketI = m3_inv2_ticket_def [THEN setc_def_to_intro, rule_format] lemmas m3_inv2_ticketE [elim] = m3_inv2_ticket_def [THEN setc_def_to_elim, rule_format] lemmas m3_inv2_ticketD = m3_inv2_ticket_def [THEN setc_def_to_dest, rule_format, rotated -1] text ‹Invariance proof.› lemma PO_m3_inv2_ticket_init [iff]: "init m3 ⊆ m3_inv2_ticket" by (auto simp add: m3_defs (*‹m3 ≡ ⦇init = m3_init, trans = m3_trans, obs = m3_obs⦈› ‹m3_init ≡ {⦇runs = λx. None, leak = shrK ` bad, clk = 0, IK = Key ` shrK ` bad⦈}› ‹m3_trans ≡ ⋃A B Ra Rb Rs Kab Ts T X. (m3_step1 Ra A B ∪ m3_step2 Rb A B ∪ m3_step3 Rs A B Kab Ts ∪ m3_step4 Ra A B Kab Ts X ∪ m3_step5 Rb A B Kab Ts ∪ m3_tick T ∪ m3_leak Rs ∪ m3_DY_fake)⁼› ‹m3_obs ?s ≡ ⦇runs = runs ?s, leak = leak ?s, clk = clk ?s⦈› ‹m3_step1 ?Ra ?A ?B ≡ {(s, s1). ?Ra ∉ dom (runs s) ∧ s1 = s⦇runs := (runs s)(?Ra ↦ (Init, [?A, ?B], [])), IK := insert ⦃msg.Agent ?A, msg.Agent ?B⦄ (IK s)⦈}› ‹m3_step2 ≡ m1_step2› ‹m3_step3 ?Rs ?A ?B ?Kab ?Ts ≡ {(s, s1). ?Rs ∉ dom (runs s) ∧ ?Kab = sesK (?Rs $ sk) ∧ ⦃msg.Agent ?A, msg.Agent ?B⦄ ∈ IK s ∧ ?Ts = clk s ∧ s1 = s⦇runs := (runs s)(?Rs ↦ (Serv, [?A, ?B], [aNum ?Ts])), IK := insert (Crypt (shrK ?A) ⦃Key ?Kab, msg.Agent ?B, Number ?Ts, Crypt (shrK ?B) ⦃Key ?Kab, msg.Agent ?A, Number ?Ts⦄⦄) (IK s)⦈}› ‹m3_step4 ?Ra ?A ?B ?Kab ?Ts ?X ≡ {(s, s1). runs s ?Ra = Some (Init, [?A, ?B], []) ∧ Crypt (shrK ?A) ⦃Key ?Kab, msg.Agent ?B, Number ?Ts, ?X⦄ ∈ IK s ∧ clk s < ?Ts + Ls ∧ s1 = s⦇runs := (runs s)(?Ra ↦ (Init, [?A, ?B], [aKey ?Kab, aNum ?Ts])), IK := insert ?X (IK s)⦈}› ‹m3_step5 ?Rb ?A ?B ?Kab ?Ts ≡ {(s, s1). runs s ?Rb = Some (Resp, [?A, ?B], []) ∧ Crypt (shrK ?B) ⦃Key ?Kab, msg.Agent ?A, Number ?Ts⦄ ∈ IK s ∧ clk s < ?Ts + Ls ∧ s1 = s⦇runs := (runs s)(?Rb ↦ (Resp, [?A, ?B], [aKey ?Kab, aNum ?Ts]))⦈}› ‹m3_tick ≡ m1_tick› ‹m3_leak ?Rs ≡ {(s, s1). ?Rs ∈ dom (runs s) ∧ fst (the (runs s ?Rs)) = Serv ∧ s1 = s⦇leak := insert (sesK (?Rs $ sk)) (leak s), IK := insert (Key (sesK (?Rs $ sk))) (IK s)⦈}› ‹m3_DY_fake ≡ {(s, s1). s1 = s⦇IK := synth (analz (IK s))⦈}› and more 40 facts*) intro!: m3_inv2_ticketI (*‹(⋀A B T K X. ⟦A ∉ bad; Crypt (shrK A) ⦃Key K, msg.Agent B, Number T, X⦄ ∈ parts (IK ?x)⟧ ⟹ X = Crypt (shrK B) ⦃Key K, msg.Agent A, Number T⦄ ∧ K ∈ range sesK) ⟹ ?x ∈ m3_inv2_ticket›*)) lemma PO_m3_inv2_ticket_trans [iff]: "{m3_inv2_ticket ∩ m3_inv1_lkeysec} trans m3 {> m3_inv2_ticket}" apply (auto simp add: PO_hoare_defs (*‹{?pre} ?R {> ?post} ≡ ?R `` ?pre ⊆ ?post› ‹?r `` ?s = {y. ∃x∈?s. (x, y) ∈ ?r}›*) m3_defs (*‹m3 ≡ ⦇init = m3_init, trans = m3_trans, obs = m3_obs⦈› ‹m3_init ≡ {⦇runs = λx. None, leak = shrK ` bad, clk = 0, IK = Key ` shrK ` bad⦈}› ‹m3_trans ≡ ⋃A B Ra Rb Rs Kab Ts T X. (m3_step1 Ra A B ∪ m3_step2 Rb A B ∪ m3_step3 Rs A B Kab Ts ∪ m3_step4 Ra A B Kab Ts X ∪ m3_step5 Rb A B Kab Ts ∪ m3_tick T ∪ m3_leak Rs ∪ m3_DY_fake)⁼› ‹m3_obs ?s ≡ ⦇runs = runs ?s, leak = leak ?s, clk = clk ?s⦈› ‹m3_step1 ?Ra ?A ?B ≡ {(s, s1). ?Ra ∉ dom (runs s) ∧ s1 = s⦇runs := (runs s)(?Ra ↦ (Init, [?A, ?B], [])), IK := insert ⦃msg.Agent ?A, msg.Agent ?B⦄ (IK s)⦈}› ‹m3_step2 ≡ m1_step2› ‹m3_step3 ?Rs ?A ?B ?Kab ?Ts ≡ {(s, s1). ?Rs ∉ dom (runs s) ∧ ?Kab = sesK (?Rs $ sk) ∧ ⦃msg.Agent ?A, msg.Agent ?B⦄ ∈ IK s ∧ ?Ts = clk s ∧ s1 = s⦇runs := (runs s)(?Rs ↦ (Serv, [?A, ?B], [aNum ?Ts])), IK := insert (Crypt (shrK ?A) ⦃Key ?Kab, msg.Agent ?B, Number ?Ts, Crypt (shrK ?B) ⦃Key ?Kab, msg.Agent ?A, Number ?Ts⦄⦄) (IK s)⦈}› ‹m3_step4 ?Ra ?A ?B ?Kab ?Ts ?X ≡ {(s, s1). runs s ?Ra = Some (Init, [?A, ?B], []) ∧ Crypt (shrK ?A) ⦃Key ?Kab, msg.Agent ?B, Number ?Ts, ?X⦄ ∈ IK s ∧ clk s < ?Ts + Ls ∧ s1 = s⦇runs := (runs s)(?Ra ↦ (Init, [?A, ?B], [aKey ?Kab, aNum ?Ts])), IK := insert ?X (IK s)⦈}› ‹m3_step5 ?Rb ?A ?B ?Kab ?Ts ≡ {(s, s1). runs s ?Rb = Some (Resp, [?A, ?B], []) ∧ Crypt (shrK ?B) ⦃Key ?Kab, msg.Agent ?A, Number ?Ts⦄ ∈ IK s ∧ clk s < ?Ts + Ls ∧ s1 = s⦇runs := (runs s)(?Rb ↦ (Resp, [?A, ?B], [aKey ?Kab, aNum ?Ts]))⦈}› ‹m3_tick ≡ m1_tick› ‹m3_leak ?Rs ≡ {(s, s1). ?Rs ∈ dom (runs s) ∧ fst (the (runs s ?Rs)) = Serv ∧ s1 = s⦇leak := insert (sesK (?Rs $ sk)) (leak s), IK := insert (Key (sesK (?Rs $ sk))) (IK s)⦈}› ‹m3_DY_fake ≡ {(s, s1). s1 = s⦇IK := synth (analz (IK s))⦈}› and more 40 facts*) intro!: m3_inv2_ticketI (*‹(⋀A B T K X. ⟦A ∉ bad; Crypt (shrK A) ⦃Key K, msg.Agent B, Number T, X⦄ ∈ parts (IK ?x)⟧ ⟹ X = Crypt (shrK B) ⦃Key K, msg.Agent A, Number T⦄ ∧ K ∈ range sesK) ⟹ ?x ∈ m3_inv2_ticket›*)) (*goal: ‹{m3_inv2_ticket ∩ m3_inv1_lkeysec} TS.trans m3 {> m3_inv2_ticket}›*) apply (auto dest: m3_inv2_ticketD (*‹⟦Crypt (shrK ?A) ⦃Key ?K, msg.Agent ?B, Number ?T, ?X⦄ ∈ parts (IK ?x); ?x ∈ m3_inv2_ticket; ?A ∉ bad⟧ ⟹ ?X = Crypt (shrK ?B) ⦃Key ?K, msg.Agent ?A, Number ?T⦄ ∧ ?K ∈ range sesK›*)) (*top goal: ‹⋀A B T K X xa xb xc xf. ⟦A ∉ bad; xa ∈ m3_inv2_ticket; xa ∈ m3_inv1_lkeysec; xf ∉ dom (runs xa); msg.Agent xb ∈ parts (IK xa); msg.Agent xc ∈ parts (IK xa); Crypt (shrK A) ⦃Key K, msg.Agent B, Number T, X⦄ ∈ parts (IK xa)⟧ ⟹ X = Crypt (shrK B) ⦃Key K, msg.Agent A, Number T⦄› and 7 goals remain*) by ((drule parts_cut (*‹⟦?Y ∈ parts (insert ?X ?G); ?X ∈ parts ?H⟧ ⟹ ?Y ∈ parts (?G ∪ ?H)›*), drule Body (*‹Crypt (?K::key) (?X::msg) ∈ parts (?H::msg set) ⟹ ?X ∈ parts ?H›*), auto dest: m3_inv2_ticketD (*‹⟦Crypt (shrK ?A) ⦃Key ?K, msg.Agent ?B, Number ?T, ?X⦄ ∈ parts (IK ?x); ?x ∈ m3_inv2_ticket; ?A ∉ bad⟧ ⟹ ?X = Crypt (shrK ?B) ⦃Key ?K, msg.Agent ?A, Number ?T⦄ ∧ ?K ∈ range sesK›*))+) lemma PO_m3_inv2_ticket [iff]: "reach m3 ⊆ m3_inv2_ticket" apply (rule inv_rule_incr (*‹⟦init ?T ⊆ ?I; {?I ∩ ?J} TS.trans ?T {> ?I}; reach ?T ⊆ ?J⟧ ⟹ reach ?T ⊆ ?I›*)) (*goals: 1. ‹init m3 ⊆ m3_inv2_ticket› 2. ‹{m3_inv2_ticket ∩ ?J} TS.trans m3 {> m3_inv2_ticket}› 3. ‹reach m3 ⊆ ?J› discuss goal 1*) apply ((auto del: subsetI (*‹(⋀x. x ∈ ?A ⟹ x ∈ ?B) ⟹ ?A ⊆ ?B›*))[1]) (*discuss goal 2*) apply ((auto del: subsetI (*‹(⋀x. x ∈ ?A ⟹ x ∈ ?B) ⟹ ?A ⊆ ?B›*))[1]) (*discuss goal 3*) apply ((auto del: subsetI (*‹(⋀x. x ∈ ?A ⟹ x ∈ ?B) ⟹ ?A ⊆ ?B›*))[1]) (*proven 3 subgoals*) . subsubsection ‹inv3: Session keys not used to encrypt other session keys› (******************************************************************************) text ‹Session keys are not used to encrypt other keys. Proof requires generalization to sets of session keys.› definition m3_inv3_sesK_compr :: "m3_pred" where "m3_inv3_sesK_compr ≡ {s. ∀K KK. KK ⊆ range sesK ⟶ (Key K ∈ analz (Key`KK ∪ (IK s))) = (K ∈ KK ∨ Key K ∈ analz (IK s)) }" lemmas m3_inv3_sesK_comprI = m3_inv3_sesK_compr_def [THEN setc_def_to_intro, rule_format] lemmas m3_inv3_sesK_comprE = m3_inv3_sesK_compr_def [THEN setc_def_to_elim, rule_format] lemmas m3_inv3_sesK_comprD = m3_inv3_sesK_compr_def [THEN setc_def_to_dest, rule_format] text ‹Additional lemma› lemmas insert_commute_Key = insert_commute [where x="Key K" for K] lemmas m3_inv3_sesK_compr_simps = m3_inv3_sesK_comprD m3_inv3_sesK_comprD [where KK="{Kab}" for Kab, simplified] m3_inv3_sesK_comprD [where KK="insert Kab KK" for Kab KK, simplified] insert_commute_Key ― ‹to get the keys to the front› text ‹Invariance proof.› lemma PO_m3_inv3_sesK_compr_step4: "{m3_inv3_sesK_compr ∩ m3_inv2_ticket ∩ m3_inv1_lkeysec} m3_step4 Ra A B Kab Ts X {> m3_inv3_sesK_compr}" proof (-) (*goal: ‹{m3_inv3_sesK_compr ∩ m3_inv2_ticket ∩ m3_inv1_lkeysec} m3_step4 (Ra::fid_t) (A::agent) (B::agent) (Kab::key) (Ts::nat) (X::msg) {> m3_inv3_sesK_compr}›*) { fix K and KK and s assume H: "s ∈ m3_inv1_lkeysec" "s ∈ m3_inv3_sesK_compr" "s ∈ m3_inv2_ticket" "runs s Ra = Some (Init, [A, B], [])" "KK ⊆ range sesK" "Crypt (shrK A) ⦃Key Kab, Agent B, Number Ts, X⦄ ∈ analz (IK s)" (*‹(s::m3_state) ∈ m3_inv1_lkeysec› ‹(s::m3_state) ∈ m3_inv3_sesK_compr› ‹(s::m3_state) ∈ m3_inv2_ticket› ‹runs (s::m3_state) (Ra::fid_t) = Some (Init, [A::agent, B::agent], [])› ‹(KK::key set) ⊆ range sesK› ‹Crypt (shrK (A::agent)) ⦃Key (Kab::key), msg.Agent (B::agent), Number (Ts::nat), X::msg⦄ ∈ analz (IK (s::m3_state))›*) have "(Key K ∈ analz (insert X (Key ` KK ∪ IK s))) = (K ∈ KK ∨ Key K ∈ analz (insert X (IK s)))" proof (cases "A ∈ bad") (*goals: 1. ‹A ∈ bad ⟹ (Key K ∈ analz (insert X (Key ` KK ∪ IK s))) = (K ∈ KK ∨ Key K ∈ analz (insert X (IK s)))› 2. ‹A ∉ bad ⟹ (Key K ∈ analz (insert X (Key ` KK ∪ IK s))) = (K ∈ KK ∨ Key K ∈ analz (insert X (IK s)))›*) case True (*‹A ∈ bad›*) show "?thesis" (*goal: ‹(Key K ∈ analz (insert X (Key ` KK ∪ IK s))) = (K ∈ KK ∨ Key K ∈ analz (insert X (IK s)))›*) proof (-) (*goal: ‹(Key K ∈ analz (insert X (Key ` KK ∪ IK s))) = (K ∈ KK ∨ Key K ∈ analz (insert X (IK s)))›*) note H (*‹s ∈ m3_inv1_lkeysec› ‹s ∈ m3_inv3_sesK_compr› ‹(s::m3_state) ∈ m3_inv2_ticket› ‹runs s Ra = Some (Init, [A, B], [])› ‹(KK::key set) ⊆ range sesK› ‹Crypt (shrK A) ⦃Key Kab, msg.Agent B, Number Ts, X⦄ ∈ analz (IK s)›*) moreover with ‹A ∈ bad› (*‹A ∈ bad›*) have "X ∈ analz (IK s)" by (auto dest!: Decrypt (*‹⟦Crypt ?K ?X ∈ analz ?H; Key (invKey ?K) ∈ analz ?H⟧ ⟹ ?X ∈ analz ?H›*)) moreover hence "X ∈ analz (Key ` KK ∪ IK s)" by (auto intro: analz_mono [THEN [2] rev_subsetD] (*‹⟦(?c::msg) ∈ analz (?G1::msg set); ?G1 ⊆ (?H1::msg set)⟧ ⟹ ?c ∈ analz ?H1›*)) ultimately show "?thesis" (*goal: ‹(Key (K::key) ∈ analz (insert (X::msg) (Key ` (KK::key set) ∪ IK (s::m3_state)))) = (K ∈ KK ∨ Key K ∈ analz (insert X (IK s)))›*) by (auto simp add: m3_inv3_sesK_compr_simps (*‹⟦?x ∈ m3_inv3_sesK_compr; ?KK ⊆ range sesK⟧ ⟹ (Key ?K ∈ analz (Key ` ?KK ∪ IK ?x)) = (?K ∈ ?KK ∨ Key ?K ∈ analz (IK ?x))› ‹⟦?x ∈ m3_inv3_sesK_compr; ?Kab ∈ range sesK⟧ ⟹ (Key ?K ∈ analz (insert (Key ?Kab) (IK ?x))) = (?K = ?Kab ∨ Key ?K ∈ analz (IK ?x))› ‹⟦?x ∈ m3_inv3_sesK_compr; ?Kab ∈ range sesK ∧ ?KK ⊆ range sesK⟧ ⟹ (Key ?K ∈ analz (insert (Key ?Kab) (Key ` ?KK ∪ IK ?x))) = (?K = ?Kab ∨ ?K ∈ ?KK ∨ Key ?K ∈ analz (IK ?x))› ‹insert (Key ?K) (insert ?y ?A) = insert ?y (insert (Key ?K) ?A)›*) analz_insert_eq (*‹?X ∈ analz ?H ⟹ analz (insert ?X ?H) = analz ?H›*)) qed next (*goal: ‹A ∉ bad ⟹ (Key K ∈ analz (insert X (Key ` KK ∪ IK s))) = (K ∈ KK ∨ Key K ∈ analz (insert X (IK s)))›*) case False (*‹A ∉ bad›*) thus "?thesis" (*goal: ‹(Key K ∈ analz (insert X (Key ` KK ∪ IK s))) = (K ∈ KK ∨ Key K ∈ analz (insert X (IK s)))›*) using H (*‹s ∈ m3_inv1_lkeysec› ‹(s::m3_state) ∈ m3_inv3_sesK_compr› ‹s ∈ m3_inv2_ticket› ‹runs (s::m3_state) (Ra::fid_t) = Some (Init, [A::agent, B::agent], [])› ‹(KK::key set) ⊆ range sesK› ‹Crypt (shrK A) ⦃Key Kab, msg.Agent B, Number Ts, X⦄ ∈ analz (IK s)›*) by (fastforce simp add: m3_inv3_sesK_compr_simps (*‹⟦?x ∈ m3_inv3_sesK_compr; ?KK ⊆ range sesK⟧ ⟹ (Key ?K ∈ analz (Key ` ?KK ∪ IK ?x)) = (?K ∈ ?KK ∨ Key ?K ∈ analz (IK ?x))› ‹⟦?x ∈ m3_inv3_sesK_compr; ?Kab ∈ range sesK⟧ ⟹ (Key ?K ∈ analz (insert (Key ?Kab) (IK ?x))) = (?K = ?Kab ∨ Key ?K ∈ analz (IK ?x))› ‹⟦?x ∈ m3_inv3_sesK_compr; ?Kab ∈ range sesK ∧ ?KK ⊆ range sesK⟧ ⟹ (Key ?K ∈ analz (insert (Key ?Kab) (Key ` ?KK ∪ IK ?x))) = (?K = ?Kab ∨ ?K ∈ ?KK ∨ Key ?K ∈ analz (IK ?x))› ‹insert (Key ?K) (insert ?y ?A) = insert ?y (insert (Key ?K) ?A)›*) dest!: m3_inv2_ticketD [OF analz_into_parts] (*‹⟦Crypt (shrK ?A) ⦃Key ?K, msg.Agent ?B, Number ?T, ?X⦄ ∈ analz (IK ?x); ?x ∈ m3_inv2_ticket; ?A ∉ bad⟧ ⟹ ?X = Crypt (shrK ?B) ⦃Key ?K, msg.Agent ?A, Number ?T⦄ ∧ ?K ∈ range sesK›*)) qed } thus "?thesis" (*goal: ‹{m3_inv3_sesK_compr ∩ m3_inv2_ticket ∩ m3_inv1_lkeysec} m3_step4 Ra A B Kab Ts X {> m3_inv3_sesK_compr}›*) by (auto simp add: PO_hoare_defs (*‹{?pre} ?R {> ?post} ≡ ?R `` ?pre ⊆ ?post› ‹?r `` ?s = {y. ∃x∈?s. (x, y) ∈ ?r}›*) m3_defs (*‹m3 ≡ ⦇init = m3_init, trans = m3_trans, obs = m3_obs⦈› ‹m3_init ≡ {⦇runs = λx. None, leak = shrK ` bad, clk = 0, IK = Key ` shrK ` bad⦈}› ‹m3_trans ≡ ⋃A B Ra Rb Rs Kab Ts T X. (m3_step1 Ra A B ∪ m3_step2 Rb A B ∪ m3_step3 Rs A B Kab Ts ∪ m3_step4 Ra A B Kab Ts X ∪ m3_step5 Rb A B Kab Ts ∪ m3_tick T ∪ m3_leak Rs ∪ m3_DY_fake)⁼› ‹m3_obs ?s ≡ ⦇runs = runs ?s, leak = leak ?s, clk = clk ?s⦈› ‹m3_step1 ?Ra ?A ?B ≡ {(s, s1). ?Ra ∉ dom (runs s) ∧ s1 = s⦇runs := (runs s)(?Ra ↦ (Init, [?A, ?B], [])), IK := insert ⦃msg.Agent ?A, msg.Agent ?B⦄ (IK s)⦈}› ‹m3_step2 ≡ m1_step2› ‹m3_step3 ?Rs ?A ?B ?Kab ?Ts ≡ {(s, s1). ?Rs ∉ dom (runs s) ∧ ?Kab = sesK (?Rs $ sk) ∧ ⦃msg.Agent ?A, msg.Agent ?B⦄ ∈ IK s ∧ ?Ts = clk s ∧ s1 = s⦇runs := (runs s)(?Rs ↦ (Serv, [?A, ?B], [aNum ?Ts])), IK := insert (Crypt (shrK ?A) ⦃Key ?Kab, msg.Agent ?B, Number ?Ts, Crypt (shrK ?B) ⦃Key ?Kab, msg.Agent ?A, Number ?Ts⦄⦄) (IK s)⦈}› ‹m3_step4 ?Ra ?A ?B ?Kab ?Ts ?X ≡ {(s, s1). runs s ?Ra = Some (Init, [?A, ?B], []) ∧ Crypt (shrK ?A) ⦃Key ?Kab, msg.Agent ?B, Number ?Ts, ?X⦄ ∈ IK s ∧ clk s < ?Ts + Ls ∧ s1 = s⦇runs := (runs s)(?Ra ↦ (Init, [?A, ?B], [aKey ?Kab, aNum ?Ts])), IK := insert ?X (IK s)⦈}› ‹m3_step5 ?Rb ?A ?B ?Kab ?Ts ≡ {(s, s1). runs s ?Rb = Some (Resp, [?A, ?B], []) ∧ Crypt (shrK ?B) ⦃Key ?Kab, msg.Agent ?A, Number ?Ts⦄ ∈ IK s ∧ clk s < ?Ts + Ls ∧ s1 = s⦇runs := (runs s)(?Rb ↦ (Resp, [?A, ?B], [aKey ?Kab, aNum ?Ts]))⦈}› ‹m3_tick ≡ m1_tick› ‹m3_leak ?Rs ≡ {(s, s1). ?Rs ∈ dom (runs s) ∧ fst (the (runs s ?Rs)) = Serv ∧ s1 = s⦇leak := insert (sesK (?Rs $ sk)) (leak s), IK := insert (Key (sesK (?Rs $ sk))) (IK s)⦈}› ‹m3_DY_fake ≡ {(s, s1). s1 = s⦇IK := synth (analz (IK s))⦈}› and more 40 facts*) intro!: m3_inv3_sesK_comprI (*‹(⋀K KK. KK ⊆ range sesK ⟹ (Key K ∈ analz (Key ` KK ∪ IK ?x)) = (K ∈ KK ∨ Key K ∈ analz (IK ?x))) ⟹ ?x ∈ m3_inv3_sesK_compr›*) dest!: analz_Inj_IK (*‹?X ∈ IK ?s ⟹ ?X ∈ analz (IK ?s)›*)) qed text ‹All together now.› lemmas PO_m3_inv3_sesK_compr_trans_lemmas = PO_m3_inv3_sesK_compr_step4 lemma PO_m3_inv3_sesK_compr_init [iff]: "init m3 ⊆ m3_inv3_sesK_compr" by (auto simp add: m3_defs (*‹m3 ≡ ⦇init = m3_init, trans = m3_trans, obs = m3_obs⦈› ‹m3_init ≡ {⦇runs = λx. None, leak = shrK ` bad, clk = 0, IK = Key ` shrK ` bad⦈}› ‹m3_trans ≡ ⋃A B Ra Rb Rs Kab Ts T X. (m3_step1 Ra A B ∪ m3_step2 Rb A B ∪ m3_step3 Rs A B Kab Ts ∪ m3_step4 Ra A B Kab Ts X ∪ m3_step5 Rb A B Kab Ts ∪ m3_tick T ∪ m3_leak Rs ∪ m3_DY_fake)⁼› ‹m3_obs ?s ≡ ⦇runs = runs ?s, leak = leak ?s, clk = clk ?s⦈› ‹m3_step1 ?Ra ?A ?B ≡ {(s, s1). ?Ra ∉ dom (runs s) ∧ s1 = s⦇runs := (runs s)(?Ra ↦ (Init, [?A, ?B], [])), IK := insert ⦃msg.Agent ?A, msg.Agent ?B⦄ (IK s)⦈}› ‹m3_step2 ≡ m1_step2› ‹m3_step3 ?Rs ?A ?B ?Kab ?Ts ≡ {(s, s1). ?Rs ∉ dom (runs s) ∧ ?Kab = sesK (?Rs $ sk) ∧ ⦃msg.Agent ?A, msg.Agent ?B⦄ ∈ IK s ∧ ?Ts = clk s ∧ s1 = s⦇runs := (runs s)(?Rs ↦ (Serv, [?A, ?B], [aNum ?Ts])), IK := insert (Crypt (shrK ?A) ⦃Key ?Kab, msg.Agent ?B, Number ?Ts, Crypt (shrK ?B) ⦃Key ?Kab, msg.Agent ?A, Number ?Ts⦄⦄) (IK s)⦈}› ‹m3_step4 ?Ra ?A ?B ?Kab ?Ts ?X ≡ {(s, s1). runs s ?Ra = Some (Init, [?A, ?B], []) ∧ Crypt (shrK ?A) ⦃Key ?Kab, msg.Agent ?B, Number ?Ts, ?X⦄ ∈ IK s ∧ clk s < ?Ts + Ls ∧ s1 = s⦇runs := (runs s)(?Ra ↦ (Init, [?A, ?B], [aKey ?Kab, aNum ?Ts])), IK := insert ?X (IK s)⦈}› ‹m3_step5 ?Rb ?A ?B ?Kab ?Ts ≡ {(s, s1). runs s ?Rb = Some (Resp, [?A, ?B], []) ∧ Crypt (shrK ?B) ⦃Key ?Kab, msg.Agent ?A, Number ?Ts⦄ ∈ IK s ∧ clk s < ?Ts + Ls ∧ s1 = s⦇runs := (runs s)(?Rb ↦ (Resp, [?A, ?B], [aKey ?Kab, aNum ?Ts]))⦈}› ‹m3_tick ≡ m1_tick› ‹m3_leak ?Rs ≡ {(s, s1). ?Rs ∈ dom (runs s) ∧ fst (the (runs s ?Rs)) = Serv ∧ s1 = s⦇leak := insert (sesK (?Rs $ sk)) (leak s), IK := insert (Key (sesK (?Rs $ sk))) (IK s)⦈}› ‹m3_DY_fake ≡ {(s, s1). s1 = s⦇IK := synth (analz (IK s))⦈}› and more 40 facts*) intro!: m3_inv3_sesK_comprI (*‹(⋀K KK. KK ⊆ range sesK ⟹ (Key K ∈ analz (Key ` KK ∪ IK ?x)) = (K ∈ KK ∨ Key K ∈ analz (IK ?x))) ⟹ ?x ∈ m3_inv3_sesK_compr›*)) lemma PO_m3_inv3_sesK_compr_trans [iff]: "{m3_inv3_sesK_compr ∩ m3_inv2_ticket ∩ m3_inv1_lkeysec} trans m3 {> m3_inv3_sesK_compr}" apply (auto simp add: m3_def (*‹m3 ≡ ⦇init = m3_init, trans = m3_trans, obs = m3_obs⦈›*) m3_trans_def (*‹m3_trans ≡ ⋃A B Ra Rb Rs Kab Ts T X. (m3_step1 Ra A B ∪ m3_step2 Rb A B ∪ m3_step3 Rs A B Kab Ts ∪ m3_step4 Ra A B Kab Ts X ∪ m3_step5 Rb A B Kab Ts ∪ m3_tick T ∪ m3_leak Rs ∪ m3_DY_fake)⁼›*) intro!: PO_m3_inv3_sesK_compr_trans_lemmas (*‹{m3_inv3_sesK_compr ∩ m3_inv2_ticket ∩ m3_inv1_lkeysec} m3_step4 ?Ra ?A ?B ?Kab ?Ts ?X {> m3_inv3_sesK_compr}›*)) (*goals: 1. ‹⋀x xa xb. {m3_inv3_sesK_compr ∩ m3_inv2_ticket ∩ m3_inv1_lkeysec} m3_step1 xb x xa {> m3_inv3_sesK_compr}› 2. ‹⋀x xa xc. {m3_inv3_sesK_compr ∩ m3_inv2_ticket ∩ m3_inv1_lkeysec} m3_step2 xc x xa {> m3_inv3_sesK_compr}› 3. ‹⋀x xa xd xe xf. {m3_inv3_sesK_compr ∩ m3_inv2_ticket ∩ m3_inv1_lkeysec} m3_step3 xd x xa xe xf {> m3_inv3_sesK_compr}› 4. ‹⋀x xa xc xe xf. {m3_inv3_sesK_compr ∩ m3_inv2_ticket ∩ m3_inv1_lkeysec} m3_step5 xc x xa xe xf {> m3_inv3_sesK_compr}› 5. ‹⋀xe. {m3_inv3_sesK_compr ∩ m3_inv2_ticket ∩ m3_inv1_lkeysec} m3_tick xe {> m3_inv3_sesK_compr}› 6. ‹⋀xd. {m3_inv3_sesK_compr ∩ m3_inv2_ticket ∩ m3_inv1_lkeysec} m3_leak xd {> m3_inv3_sesK_compr}› 7. ‹{m3_inv3_sesK_compr ∩ m3_inv2_ticket ∩ m3_inv1_lkeysec} m3_DY_fake {> m3_inv3_sesK_compr}› discuss goal 1*) apply ((auto simp add: PO_hoare_defs (*‹{?pre::?'s set} ?R::(?'s × ?'s) set {> ?post::?'s set} ≡ ?R `` ?pre ⊆ ?post› ‹(?r::(?'a × ?'b) set) `` (?s::?'a set) = {y::?'b. ∃x::?'a∈?s. (x, y) ∈ ?r}›*) m3_defs (*‹m3 ≡ ⦇init = m3_init, trans = m3_trans, obs = m3_obs⦈› ‹m3_init ≡ {⦇runs = λx::fid_t. None, leak = shrK ` bad, clk = 0::nat, IK = Key ` shrK ` bad⦈}› ‹m3_trans ≡ ⋃(A::agent) (B::agent) (Ra::fid_t) (Rb::fid_t) (Rs::fid_t) (Kab::key) (Ts::nat) (T::nat) X::msg. (m3_step1 Ra A B ∪ m3_step2 Rb A B ∪ m3_step3 Rs A B Kab Ts ∪ m3_step4 Ra A B Kab Ts X ∪ m3_step5 Rb A B Kab Ts ∪ m3_tick T ∪ m3_leak Rs ∪ m3_DY_fake)⁼› ‹m3_obs (?s::m3_state) ≡ ⦇runs = runs ?s, leak = leak ?s, clk = clk ?s⦈› ‹m3_step1 (?Ra::fid_t) (?A::agent) (?B::agent) ≡ {(s::m3_state, s1::m3_state). ?Ra ∉ dom (runs s) ∧ s1 = s⦇runs := (runs s)(?Ra ↦ (Init, [?A, ?B], [])), IK := insert ⦃msg.Agent ?A, msg.Agent ?B⦄ (IK s)⦈}› ‹m3_step2 ≡ m1_step2› ‹m3_step3 (?Rs::fid_t) (?A::agent) (?B::agent) (?Kab::key) (?Ts::nat) ≡ {(s::m3_state, s1::m3_state). ?Rs ∉ dom (runs s) ∧ ?Kab = sesK (?Rs $ sk) ∧ ⦃msg.Agent ?A, msg.Agent ?B⦄ ∈ IK s ∧ ?Ts = clk s ∧ s1 = s⦇runs := (runs s)(?Rs ↦ (Serv, [?A, ?B], [aNum ?Ts])), IK := insert (Crypt (shrK ?A) ⦃Key ?Kab, msg.Agent ?B, Number ?Ts, Crypt (shrK ?B) ⦃Key ?Kab, msg.Agent ?A, Number ?Ts⦄⦄) (IK s)⦈}› ‹m3_step4 (?Ra::fid_t) (?A::agent) (?B::agent) (?Kab::key) (?Ts::nat) (?X::msg) ≡ {(s::m3_state, s1::m3_state). runs s ?Ra = Some (Init, [?A, ?B], []) ∧ Crypt (shrK ?A) ⦃Key ?Kab, msg.Agent ?B, Number ?Ts, ?X⦄ ∈ IK s ∧ clk s < ?Ts + Ls ∧ s1 = s⦇runs := (runs s)(?Ra ↦ (Init, [?A, ?B], [aKey ?Kab, aNum ?Ts])), IK := insert ?X (IK s)⦈}› ‹m3_step5 (?Rb::fid_t) (?A::agent) (?B::agent) (?Kab::key) (?Ts::nat) ≡ {(s::m3_state, s1::m3_state). runs s ?Rb = Some (Resp, [?A, ?B], []) ∧ Crypt (shrK ?B) ⦃Key ?Kab, msg.Agent ?A, Number ?Ts⦄ ∈ IK s ∧ clk s < ?Ts + Ls ∧ s1 = s⦇runs := (runs s)(?Rb ↦ (Resp, [?A, ?B], [aKey ?Kab, aNum ?Ts]))⦈}› ‹m3_tick ≡ m1_tick› ‹m3_leak (?Rs::fid_t) ≡ {(s::m3_state, s1::m3_state). ?Rs ∈ dom (runs s) ∧ fst (the (runs s ?Rs)) = Serv ∧ s1 = s⦇leak := insert (sesK (?Rs $ sk)) (leak s), IK := insert (Key (sesK (?Rs $ sk))) (IK s)⦈}› ‹m3_DY_fake ≡ {(s::m3_state, s1::m3_state). s1 = s⦇IK := synth (analz (IK s))⦈}› and more 40 facts*) m3_inv3_sesK_compr_simps (*‹⟦(?x::m3_state) ∈ m3_inv3_sesK_compr; (?KK::key set) ⊆ range sesK⟧ ⟹ (Key (?K::key) ∈ analz (Key ` ?KK ∪ IK ?x)) = (?K ∈ ?KK ∨ Key ?K ∈ analz (IK ?x))› ‹⟦(?x::m3_state) ∈ m3_inv3_sesK_compr; (?Kab::key) ∈ range sesK⟧ ⟹ (Key (?K::key) ∈ analz (insert (Key ?Kab) (IK ?x))) = (?K = ?Kab ∨ Key ?K ∈ analz (IK ?x))› ‹⟦(?x::m3_state) ∈ m3_inv3_sesK_compr; (?Kab::key) ∈ range sesK ∧ (?KK::key set) ⊆ range sesK⟧ ⟹ (Key (?K::key) ∈ analz (insert (Key ?Kab) (Key ` ?KK ∪ IK ?x))) = (?K = ?Kab ∨ ?K ∈ ?KK ∨ Key ?K ∈ analz (IK ?x))› ‹insert (Key (?K::key)) (insert (?y::msg) (?A::msg set)) = insert ?y (insert (Key ?K) ?A)›*) intro!: m3_inv3_sesK_comprI (*‹(⋀(K::key) KK::key set. KK ⊆ range sesK ⟹ (Key K ∈ analz (Key ` KK ∪ IK (?x::m3_state))) = (K ∈ KK ∨ Key K ∈ analz (IK ?x))) ⟹ ?x ∈ m3_inv3_sesK_compr›*))[1]) (*discuss goal 2*) apply ((auto simp add: PO_hoare_defs (*‹{?pre} ?R {> ?post} ≡ ?R `` ?pre ⊆ ?post› ‹?r `` ?s = {y. ∃x∈?s. (x, y) ∈ ?r}›*) m3_defs (*‹m3 ≡ ⦇init = m3_init, trans = m3_trans, obs = m3_obs⦈› ‹m3_init ≡ {⦇runs = λx. None, leak = shrK ` bad, clk = 0, IK = Key ` shrK ` bad⦈}› ‹m3_trans ≡ ⋃A B Ra Rb Rs Kab Ts T X. (m3_step1 Ra A B ∪ m3_step2 Rb A B ∪ m3_step3 Rs A B Kab Ts ∪ m3_step4 Ra A B Kab Ts X ∪ m3_step5 Rb A B Kab Ts ∪ m3_tick T ∪ m3_leak Rs ∪ m3_DY_fake)⁼› ‹m3_obs ?s ≡ ⦇runs = runs ?s, leak = leak ?s, clk = clk ?s⦈› ‹m3_step1 ?Ra ?A ?B ≡ {(s, s1). ?Ra ∉ dom (runs s) ∧ s1 = s⦇runs := (runs s)(?Ra ↦ (Init, [?A, ?B], [])), IK := insert ⦃msg.Agent ?A, msg.Agent ?B⦄ (IK s)⦈}› ‹m3_step2 ≡ m1_step2› ‹m3_step3 ?Rs ?A ?B ?Kab ?Ts ≡ {(s, s1). ?Rs ∉ dom (runs s) ∧ ?Kab = sesK (?Rs $ sk) ∧ ⦃msg.Agent ?A, msg.Agent ?B⦄ ∈ IK s ∧ ?Ts = clk s ∧ s1 = s⦇runs := (runs s)(?Rs ↦ (Serv, [?A, ?B], [aNum ?Ts])), IK := insert (Crypt (shrK ?A) ⦃Key ?Kab, msg.Agent ?B, Number ?Ts, Crypt (shrK ?B) ⦃Key ?Kab, msg.Agent ?A, Number ?Ts⦄⦄) (IK s)⦈}› ‹m3_step4 ?Ra ?A ?B ?Kab ?Ts ?X ≡ {(s, s1). runs s ?Ra = Some (Init, [?A, ?B], []) ∧ Crypt (shrK ?A) ⦃Key ?Kab, msg.Agent ?B, Number ?Ts, ?X⦄ ∈ IK s ∧ clk s < ?Ts + Ls ∧ s1 = s⦇runs := (runs s)(?Ra ↦ (Init, [?A, ?B], [aKey ?Kab, aNum ?Ts])), IK := insert ?X (IK s)⦈}› ‹m3_step5 ?Rb ?A ?B ?Kab ?Ts ≡ {(s, s1). runs s ?Rb = Some (Resp, [?A, ?B], []) ∧ Crypt (shrK ?B) ⦃Key ?Kab, msg.Agent ?A, Number ?Ts⦄ ∈ IK s ∧ clk s < ?Ts + Ls ∧ s1 = s⦇runs := (runs s)(?Rb ↦ (Resp, [?A, ?B], [aKey ?Kab, aNum ?Ts]))⦈}› ‹m3_tick ≡ m1_tick› ‹m3_leak ?Rs ≡ {(s, s1). ?Rs ∈ dom (runs s) ∧ fst (the (runs s ?Rs)) = Serv ∧ s1 = s⦇leak := insert (sesK (?Rs $ sk)) (leak s), IK := insert (Key (sesK (?Rs $ sk))) (IK s)⦈}› ‹m3_DY_fake ≡ {(s, s1). s1 = s⦇IK := synth (analz (IK s))⦈}› and more 40 facts*) m3_inv3_sesK_compr_simps (*‹⟦?x ∈ m3_inv3_sesK_compr; ?KK ⊆ range sesK⟧ ⟹ (Key ?K ∈ analz (Key ` ?KK ∪ IK ?x)) = (?K ∈ ?KK ∨ Key ?K ∈ analz (IK ?x))› ‹⟦?x ∈ m3_inv3_sesK_compr; ?Kab ∈ range sesK⟧ ⟹ (Key ?K ∈ analz (insert (Key ?Kab) (IK ?x))) = (?K = ?Kab ∨ Key ?K ∈ analz (IK ?x))› ‹⟦?x ∈ m3_inv3_sesK_compr; ?Kab ∈ range sesK ∧ ?KK ⊆ range sesK⟧ ⟹ (Key ?K ∈ analz (insert (Key ?Kab) (Key ` ?KK ∪ IK ?x))) = (?K = ?Kab ∨ ?K ∈ ?KK ∨ Key ?K ∈ analz (IK ?x))› ‹insert (Key ?K) (insert ?y ?A) = insert ?y (insert (Key ?K) ?A)›*) intro!: m3_inv3_sesK_comprI (*‹(⋀K KK. KK ⊆ range sesK ⟹ (Key K ∈ analz (Key ` KK ∪ IK ?x)) = (K ∈ KK ∨ Key K ∈ analz (IK ?x))) ⟹ ?x ∈ m3_inv3_sesK_compr›*))[1]) (*discuss goal 3*) apply ((auto simp add: PO_hoare_defs (*‹{?pre} ?R {> ?post} ≡ ?R `` ?pre ⊆ ?post› ‹?r `` ?s = {y. ∃x∈?s. (x, y) ∈ ?r}›*) m3_defs (*‹m3 ≡ ⦇init = m3_init, trans = m3_trans, obs = m3_obs⦈› ‹m3_init ≡ {⦇runs = λx. None, leak = shrK ` bad, clk = 0, IK = Key ` shrK ` bad⦈}› ‹m3_trans ≡ ⋃A B Ra Rb Rs Kab Ts T X. (m3_step1 Ra A B ∪ m3_step2 Rb A B ∪ m3_step3 Rs A B Kab Ts ∪ m3_step4 Ra A B Kab Ts X ∪ m3_step5 Rb A B Kab Ts ∪ m3_tick T ∪ m3_leak Rs ∪ m3_DY_fake)⁼› ‹m3_obs ?s ≡ ⦇runs = runs ?s, leak = leak ?s, clk = clk ?s⦈› ‹m3_step1 ?Ra ?A ?B ≡ {(s, s1). ?Ra ∉ dom (runs s) ∧ s1 = s⦇runs := (runs s)(?Ra ↦ (Init, [?A, ?B], [])), IK := insert ⦃msg.Agent ?A, msg.Agent ?B⦄ (IK s)⦈}› ‹m3_step2 ≡ m1_step2› ‹m3_step3 ?Rs ?A ?B ?Kab ?Ts ≡ {(s, s1). ?Rs ∉ dom (runs s) ∧ ?Kab = sesK (?Rs $ sk) ∧ ⦃msg.Agent ?A, msg.Agent ?B⦄ ∈ IK s ∧ ?Ts = clk s ∧ s1 = s⦇runs := (runs s)(?Rs ↦ (Serv, [?A, ?B], [aNum ?Ts])), IK := insert (Crypt (shrK ?A) ⦃Key ?Kab, msg.Agent ?B, Number ?Ts, Crypt (shrK ?B) ⦃Key ?Kab, msg.Agent ?A, Number ?Ts⦄⦄) (IK s)⦈}› ‹m3_step4 ?Ra ?A ?B ?Kab ?Ts ?X ≡ {(s, s1). runs s ?Ra = Some (Init, [?A, ?B], []) ∧ Crypt (shrK ?A) ⦃Key ?Kab, msg.Agent ?B, Number ?Ts, ?X⦄ ∈ IK s ∧ clk s < ?Ts + Ls ∧ s1 = s⦇runs := (runs s)(?Ra ↦ (Init, [?A, ?B], [aKey ?Kab, aNum ?Ts])), IK := insert ?X (IK s)⦈}› ‹m3_step5 ?Rb ?A ?B ?Kab ?Ts ≡ {(s, s1). runs s ?Rb = Some (Resp, [?A, ?B], []) ∧ Crypt (shrK ?B) ⦃Key ?Kab, msg.Agent ?A, Number ?Ts⦄ ∈ IK s ∧ clk s < ?Ts + Ls ∧ s1 = s⦇runs := (runs s)(?Rb ↦ (Resp, [?A, ?B], [aKey ?Kab, aNum ?Ts]))⦈}› ‹m3_tick ≡ m1_tick› ‹m3_leak ?Rs ≡ {(s, s1). ?Rs ∈ dom (runs s) ∧ fst (the (runs s ?Rs)) = Serv ∧ s1 = s⦇leak := insert (sesK (?Rs $ sk)) (leak s), IK := insert (Key (sesK (?Rs $ sk))) (IK s)⦈}› ‹m3_DY_fake ≡ {(s, s1). s1 = s⦇IK := synth (analz (IK s))⦈}› and more 40 facts*) m3_inv3_sesK_compr_simps (*‹⟦?x ∈ m3_inv3_sesK_compr; ?KK ⊆ range sesK⟧ ⟹ (Key ?K ∈ analz (Key ` ?KK ∪ IK ?x)) = (?K ∈ ?KK ∨ Key ?K ∈ analz (IK ?x))› ‹⟦?x ∈ m3_inv3_sesK_compr; ?Kab ∈ range sesK⟧ ⟹ (Key ?K ∈ analz (insert (Key ?Kab) (IK ?x))) = (?K = ?Kab ∨ Key ?K ∈ analz (IK ?x))› ‹⟦?x ∈ m3_inv3_sesK_compr; ?Kab ∈ range sesK ∧ ?KK ⊆ range sesK⟧ ⟹ (Key ?K ∈ analz (insert (Key ?Kab) (Key ` ?KK ∪ IK ?x))) = (?K = ?Kab ∨ ?K ∈ ?KK ∨ Key ?K ∈ analz (IK ?x))› ‹insert (Key ?K) (insert ?y ?A) = insert ?y (insert (Key ?K) ?A)›*) intro!: m3_inv3_sesK_comprI (*‹(⋀K KK. KK ⊆ range sesK ⟹ (Key K ∈ analz (Key ` KK ∪ IK ?x)) = (K ∈ KK ∨ Key K ∈ analz (IK ?x))) ⟹ ?x ∈ m3_inv3_sesK_compr›*))[1]) (*discuss goal 4*) apply ((auto simp add: PO_hoare_defs (*‹{?pre} ?R {> ?post} ≡ ?R `` ?pre ⊆ ?post› ‹?r `` ?s = {y. ∃x∈?s. (x, y) ∈ ?r}›*) m3_defs (*‹m3 ≡ ⦇init = m3_init, trans = m3_trans, obs = m3_obs⦈› ‹m3_init ≡ {⦇runs = λx. None, leak = shrK ` bad, clk = 0, IK = Key ` shrK ` bad⦈}› ‹m3_trans ≡ ⋃A B Ra Rb Rs Kab Ts T X. (m3_step1 Ra A B ∪ m3_step2 Rb A B ∪ m3_step3 Rs A B Kab Ts ∪ m3_step4 Ra A B Kab Ts X ∪ m3_step5 Rb A B Kab Ts ∪ m3_tick T ∪ m3_leak Rs ∪ m3_DY_fake)⁼› ‹m3_obs ?s ≡ ⦇runs = runs ?s, leak = leak ?s, clk = clk ?s⦈› ‹m3_step1 ?Ra ?A ?B ≡ {(s, s1). ?Ra ∉ dom (runs s) ∧ s1 = s⦇runs := (runs s)(?Ra ↦ (Init, [?A, ?B], [])), IK := insert ⦃msg.Agent ?A, msg.Agent ?B⦄ (IK s)⦈}› ‹m3_step2 ≡ m1_step2› ‹m3_step3 ?Rs ?A ?B ?Kab ?Ts ≡ {(s, s1). ?Rs ∉ dom (runs s) ∧ ?Kab = sesK (?Rs $ sk) ∧ ⦃msg.Agent ?A, msg.Agent ?B⦄ ∈ IK s ∧ ?Ts = clk s ∧ s1 = s⦇runs := (runs s)(?Rs ↦ (Serv, [?A, ?B], [aNum ?Ts])), IK := insert (Crypt (shrK ?A) ⦃Key ?Kab, msg.Agent ?B, Number ?Ts, Crypt (shrK ?B) ⦃Key ?Kab, msg.Agent ?A, Number ?Ts⦄⦄) (IK s)⦈}› ‹m3_step4 ?Ra ?A ?B ?Kab ?Ts ?X ≡ {(s, s1). runs s ?Ra = Some (Init, [?A, ?B], []) ∧ Crypt (shrK ?A) ⦃Key ?Kab, msg.Agent ?B, Number ?Ts, ?X⦄ ∈ IK s ∧ clk s < ?Ts + Ls ∧ s1 = s⦇runs := (runs s)(?Ra ↦ (Init, [?A, ?B], [aKey ?Kab, aNum ?Ts])), IK := insert ?X (IK s)⦈}› ‹m3_step5 ?Rb ?A ?B ?Kab ?Ts ≡ {(s, s1). runs s ?Rb = Some (Resp, [?A, ?B], []) ∧ Crypt (shrK ?B) ⦃Key ?Kab, msg.Agent ?A, Number ?Ts⦄ ∈ IK s ∧ clk s < ?Ts + Ls ∧ s1 = s⦇runs := (runs s)(?Rb ↦ (Resp, [?A, ?B], [aKey ?Kab, aNum ?Ts]))⦈}› ‹m3_tick ≡ m1_tick› ‹m3_leak ?Rs ≡ {(s, s1). ?Rs ∈ dom (runs s) ∧ fst (the (runs s ?Rs)) = Serv ∧ s1 = s⦇leak := insert (sesK (?Rs $ sk)) (leak s), IK := insert (Key (sesK (?Rs $ sk))) (IK s)⦈}› ‹m3_DY_fake ≡ {(s, s1). s1 = s⦇IK := synth (analz (IK s))⦈}› and more 40 facts*) m3_inv3_sesK_compr_simps (*‹⟦?x ∈ m3_inv3_sesK_compr; ?KK ⊆ range sesK⟧ ⟹ (Key ?K ∈ analz (Key ` ?KK ∪ IK ?x)) = (?K ∈ ?KK ∨ Key ?K ∈ analz (IK ?x))› ‹⟦?x ∈ m3_inv3_sesK_compr; ?Kab ∈ range sesK⟧ ⟹ (Key ?K ∈ analz (insert (Key ?Kab) (IK ?x))) = (?K = ?Kab ∨ Key ?K ∈ analz (IK ?x))› ‹⟦?x ∈ m3_inv3_sesK_compr; ?Kab ∈ range sesK ∧ ?KK ⊆ range sesK⟧ ⟹ (Key ?K ∈ analz (insert (Key ?Kab) (Key ` ?KK ∪ IK ?x))) = (?K = ?Kab ∨ ?K ∈ ?KK ∨ Key ?K ∈ analz (IK ?x))› ‹insert (Key ?K) (insert ?y ?A) = insert ?y (insert (Key ?K) ?A)›*) intro!: m3_inv3_sesK_comprI (*‹(⋀K KK. KK ⊆ range sesK ⟹ (Key K ∈ analz (Key ` KK ∪ IK ?x)) = (K ∈ KK ∨ Key K ∈ analz (IK ?x))) ⟹ ?x ∈ m3_inv3_sesK_compr›*))[1]) (*discuss goal 5*) apply ((auto simp add: PO_hoare_defs (*‹{?pre} ?R {> ?post} ≡ ?R `` ?pre ⊆ ?post› ‹?r `` ?s = {y. ∃x∈?s. (x, y) ∈ ?r}›*) m3_defs (*‹m3 ≡ ⦇init = m3_init, trans = m3_trans, obs = m3_obs⦈› ‹m3_init ≡ {⦇runs = λx. None, leak = shrK ` bad, clk = 0, IK = Key ` shrK ` bad⦈}› ‹m3_trans ≡ ⋃A B Ra Rb Rs Kab Ts T X. (m3_step1 Ra A B ∪ m3_step2 Rb A B ∪ m3_step3 Rs A B Kab Ts ∪ m3_step4 Ra A B Kab Ts X ∪ m3_step5 Rb A B Kab Ts ∪ m3_tick T ∪ m3_leak Rs ∪ m3_DY_fake)⁼› ‹m3_obs ?s ≡ ⦇runs = runs ?s, leak = leak ?s, clk = clk ?s⦈› ‹m3_step1 ?Ra ?A ?B ≡ {(s, s1). ?Ra ∉ dom (runs s) ∧ s1 = s⦇runs := (runs s)(?Ra ↦ (Init, [?A, ?B], [])), IK := insert ⦃msg.Agent ?A, msg.Agent ?B⦄ (IK s)⦈}› ‹m3_step2 ≡ m1_step2› ‹m3_step3 ?Rs ?A ?B ?Kab ?Ts ≡ {(s, s1). ?Rs ∉ dom (runs s) ∧ ?Kab = sesK (?Rs $ sk) ∧ ⦃msg.Agent ?A, msg.Agent ?B⦄ ∈ IK s ∧ ?Ts = clk s ∧ s1 = s⦇runs := (runs s)(?Rs ↦ (Serv, [?A, ?B], [aNum ?Ts])), IK := insert (Crypt (shrK ?A) ⦃Key ?Kab, msg.Agent ?B, Number ?Ts, Crypt (shrK ?B) ⦃Key ?Kab, msg.Agent ?A, Number ?Ts⦄⦄) (IK s)⦈}› ‹m3_step4 ?Ra ?A ?B ?Kab ?Ts ?X ≡ {(s, s1). runs s ?Ra = Some (Init, [?A, ?B], []) ∧ Crypt (shrK ?A) ⦃Key ?Kab, msg.Agent ?B, Number ?Ts, ?X⦄ ∈ IK s ∧ clk s < ?Ts + Ls ∧ s1 = s⦇runs := (runs s)(?Ra ↦ (Init, [?A, ?B], [aKey ?Kab, aNum ?Ts])), IK := insert ?X (IK s)⦈}› ‹m3_step5 ?Rb ?A ?B ?Kab ?Ts ≡ {(s, s1). runs s ?Rb = Some (Resp, [?A, ?B], []) ∧ Crypt (shrK ?B) ⦃Key ?Kab, msg.Agent ?A, Number ?Ts⦄ ∈ IK s ∧ clk s < ?Ts + Ls ∧ s1 = s⦇runs := (runs s)(?Rb ↦ (Resp, [?A, ?B], [aKey ?Kab, aNum ?Ts]))⦈}› ‹m3_tick ≡ m1_tick› ‹m3_leak ?Rs ≡ {(s, s1). ?Rs ∈ dom (runs s) ∧ fst (the (runs s ?Rs)) = Serv ∧ s1 = s⦇leak := insert (sesK (?Rs $ sk)) (leak s), IK := insert (Key (sesK (?Rs $ sk))) (IK s)⦈}› ‹m3_DY_fake ≡ {(s, s1). s1 = s⦇IK := synth (analz (IK s))⦈}› and more 40 facts*) m3_inv3_sesK_compr_simps (*‹⟦?x ∈ m3_inv3_sesK_compr; ?KK ⊆ range sesK⟧ ⟹ (Key ?K ∈ analz (Key ` ?KK ∪ IK ?x)) = (?K ∈ ?KK ∨ Key ?K ∈ analz (IK ?x))› ‹⟦?x ∈ m3_inv3_sesK_compr; ?Kab ∈ range sesK⟧ ⟹ (Key ?K ∈ analz (insert (Key ?Kab) (IK ?x))) = (?K = ?Kab ∨ Key ?K ∈ analz (IK ?x))› ‹⟦?x ∈ m3_inv3_sesK_compr; ?Kab ∈ range sesK ∧ ?KK ⊆ range sesK⟧ ⟹ (Key ?K ∈ analz (insert (Key ?Kab) (Key ` ?KK ∪ IK ?x))) = (?K = ?Kab ∨ ?K ∈ ?KK ∨ Key ?K ∈ analz (IK ?x))› ‹insert (Key ?K) (insert ?y ?A) = insert ?y (insert (Key ?K) ?A)›*) intro!: m3_inv3_sesK_comprI (*‹(⋀K KK. KK ⊆ range sesK ⟹ (Key K ∈ analz (Key ` KK ∪ IK ?x)) = (K ∈ KK ∨ Key K ∈ analz (IK ?x))) ⟹ ?x ∈ m3_inv3_sesK_compr›*))[1]) (*discuss goal 6*) apply ((auto simp add: PO_hoare_defs (*‹{?pre} ?R {> ?post} ≡ ?R `` ?pre ⊆ ?post› ‹?r `` ?s = {y. ∃x∈?s. (x, y) ∈ ?r}›*) m3_defs (*‹m3 ≡ ⦇init = m3_init, trans = m3_trans, obs = m3_obs⦈› ‹m3_init ≡ {⦇runs = λx. None, leak = shrK ` bad, clk = 0, IK = Key ` shrK ` bad⦈}› ‹m3_trans ≡ ⋃A B Ra Rb Rs Kab Ts T X. (m3_step1 Ra A B ∪ m3_step2 Rb A B ∪ m3_step3 Rs A B Kab Ts ∪ m3_step4 Ra A B Kab Ts X ∪ m3_step5 Rb A B Kab Ts ∪ m3_tick T ∪ m3_leak Rs ∪ m3_DY_fake)⁼› ‹m3_obs ?s ≡ ⦇runs = runs ?s, leak = leak ?s, clk = clk ?s⦈› ‹m3_step1 ?Ra ?A ?B ≡ {(s, s1). ?Ra ∉ dom (runs s) ∧ s1 = s⦇runs := (runs s)(?Ra ↦ (Init, [?A, ?B], [])), IK := insert ⦃msg.Agent ?A, msg.Agent ?B⦄ (IK s)⦈}› ‹m3_step2 ≡ m1_step2› ‹m3_step3 ?Rs ?A ?B ?Kab ?Ts ≡ {(s, s1). ?Rs ∉ dom (runs s) ∧ ?Kab = sesK (?Rs $ sk) ∧ ⦃msg.Agent ?A, msg.Agent ?B⦄ ∈ IK s ∧ ?Ts = clk s ∧ s1 = s⦇runs := (runs s)(?Rs ↦ (Serv, [?A, ?B], [aNum ?Ts])), IK := insert (Crypt (shrK ?A) ⦃Key ?Kab, msg.Agent ?B, Number ?Ts, Crypt (shrK ?B) ⦃Key ?Kab, msg.Agent ?A, Number ?Ts⦄⦄) (IK s)⦈}› ‹m3_step4 ?Ra ?A ?B ?Kab ?Ts ?X ≡ {(s, s1). runs s ?Ra = Some (Init, [?A, ?B], []) ∧ Crypt (shrK ?A) ⦃Key ?Kab, msg.Agent ?B, Number ?Ts, ?X⦄ ∈ IK s ∧ clk s < ?Ts + Ls ∧ s1 = s⦇runs := (runs s)(?Ra ↦ (Init, [?A, ?B], [aKey ?Kab, aNum ?Ts])), IK := insert ?X (IK s)⦈}› ‹m3_step5 ?Rb ?A ?B ?Kab ?Ts ≡ {(s, s1). runs s ?Rb = Some (Resp, [?A, ?B], []) ∧ Crypt (shrK ?B) ⦃Key ?Kab, msg.Agent ?A, Number ?Ts⦄ ∈ IK s ∧ clk s < ?Ts + Ls ∧ s1 = s⦇runs := (runs s)(?Rb ↦ (Resp, [?A, ?B], [aKey ?Kab, aNum ?Ts]))⦈}› ‹m3_tick ≡ m1_tick› ‹m3_leak ?Rs ≡ {(s, s1). ?Rs ∈ dom (runs s) ∧ fst (the (runs s ?Rs)) = Serv ∧ s1 = s⦇leak := insert (sesK (?Rs $ sk)) (leak s), IK := insert (Key (sesK (?Rs $ sk))) (IK s)⦈}› ‹m3_DY_fake ≡ {(s, s1). s1 = s⦇IK := synth (analz (IK s))⦈}› and more 40 facts*) m3_inv3_sesK_compr_simps (*‹⟦?x ∈ m3_inv3_sesK_compr; ?KK ⊆ range sesK⟧ ⟹ (Key ?K ∈ analz (Key ` ?KK ∪ IK ?x)) = (?K ∈ ?KK ∨ Key ?K ∈ analz (IK ?x))› ‹⟦?x ∈ m3_inv3_sesK_compr; ?Kab ∈ range sesK⟧ ⟹ (Key ?K ∈ analz (insert (Key ?Kab) (IK ?x))) = (?K = ?Kab ∨ Key ?K ∈ analz (IK ?x))› ‹⟦?x ∈ m3_inv3_sesK_compr; ?Kab ∈ range sesK ∧ ?KK ⊆ range sesK⟧ ⟹ (Key ?K ∈ analz (insert (Key ?Kab) (Key ` ?KK ∪ IK ?x))) = (?K = ?Kab ∨ ?K ∈ ?KK ∨ Key ?K ∈ analz (IK ?x))› ‹insert (Key ?K) (insert ?y ?A) = insert ?y (insert (Key ?K) ?A)›*) intro!: m3_inv3_sesK_comprI (*‹(⋀K KK. KK ⊆ range sesK ⟹ (Key K ∈ analz (Key ` KK ∪ IK ?x)) = (K ∈ KK ∨ Key K ∈ analz (IK ?x))) ⟹ ?x ∈ m3_inv3_sesK_compr›*))[1]) (*discuss goal 7*) apply ((auto simp add: PO_hoare_defs (*‹{?pre} ?R {> ?post} ≡ ?R `` ?pre ⊆ ?post› ‹?r `` ?s = {y. ∃x∈?s. (x, y) ∈ ?r}›*) m3_defs (*‹m3 ≡ ⦇init = m3_init, trans = m3_trans, obs = m3_obs⦈› ‹m3_init ≡ {⦇runs = λx. None, leak = shrK ` bad, clk = 0, IK = Key ` shrK ` bad⦈}› ‹m3_trans ≡ ⋃A B Ra Rb Rs Kab Ts T X. (m3_step1 Ra A B ∪ m3_step2 Rb A B ∪ m3_step3 Rs A B Kab Ts ∪ m3_step4 Ra A B Kab Ts X ∪ m3_step5 Rb A B Kab Ts ∪ m3_tick T ∪ m3_leak Rs ∪ m3_DY_fake)⁼› ‹m3_obs ?s ≡ ⦇runs = runs ?s, leak = leak ?s, clk = clk ?s⦈› ‹m3_step1 ?Ra ?A ?B ≡ {(s, s1). ?Ra ∉ dom (runs s) ∧ s1 = s⦇runs := (runs s)(?Ra ↦ (Init, [?A, ?B], [])), IK := insert ⦃msg.Agent ?A, msg.Agent ?B⦄ (IK s)⦈}› ‹m3_step2 ≡ m1_step2› ‹m3_step3 ?Rs ?A ?B ?Kab ?Ts ≡ {(s, s1). ?Rs ∉ dom (runs s) ∧ ?Kab = sesK (?Rs $ sk) ∧ ⦃msg.Agent ?A, msg.Agent ?B⦄ ∈ IK s ∧ ?Ts = clk s ∧ s1 = s⦇runs := (runs s)(?Rs ↦ (Serv, [?A, ?B], [aNum ?Ts])), IK := insert (Crypt (shrK ?A) ⦃Key ?Kab, msg.Agent ?B, Number ?Ts, Crypt (shrK ?B) ⦃Key ?Kab, msg.Agent ?A, Number ?Ts⦄⦄) (IK s)⦈}› ‹m3_step4 ?Ra ?A ?B ?Kab ?Ts ?X ≡ {(s, s1). runs s ?Ra = Some (Init, [?A, ?B], []) ∧ Crypt (shrK ?A) ⦃Key ?Kab, msg.Agent ?B, Number ?Ts, ?X⦄ ∈ IK s ∧ clk s < ?Ts + Ls ∧ s1 = s⦇runs := (runs s)(?Ra ↦ (Init, [?A, ?B], [aKey ?Kab, aNum ?Ts])), IK := insert ?X (IK s)⦈}› ‹m3_step5 ?Rb ?A ?B ?Kab ?Ts ≡ {(s, s1). runs s ?Rb = Some (Resp, [?A, ?B], []) ∧ Crypt (shrK ?B) ⦃Key ?Kab, msg.Agent ?A, Number ?Ts⦄ ∈ IK s ∧ clk s < ?Ts + Ls ∧ s1 = s⦇runs := (runs s)(?Rb ↦ (Resp, [?A, ?B], [aKey ?Kab, aNum ?Ts]))⦈}› ‹m3_tick ≡ m1_tick› ‹m3_leak ?Rs ≡ {(s, s1). ?Rs ∈ dom (runs s) ∧ fst (the (runs s ?Rs)) = Serv ∧ s1 = s⦇leak := insert (sesK (?Rs $ sk)) (leak s), IK := insert (Key (sesK (?Rs $ sk))) (IK s)⦈}› ‹m3_DY_fake ≡ {(s, s1). s1 = s⦇IK := synth (analz (IK s))⦈}› and more 40 facts*) m3_inv3_sesK_compr_simps (*‹⟦?x ∈ m3_inv3_sesK_compr; ?KK ⊆ range sesK⟧ ⟹ (Key ?K ∈ analz (Key ` ?KK ∪ IK ?x)) = (?K ∈ ?KK ∨ Key ?K ∈ analz (IK ?x))› ‹⟦?x ∈ m3_inv3_sesK_compr; ?Kab ∈ range sesK⟧ ⟹ (Key ?K ∈ analz (insert (Key ?Kab) (IK ?x))) = (?K = ?Kab ∨ Key ?K ∈ analz (IK ?x))› ‹⟦?x ∈ m3_inv3_sesK_compr; ?Kab ∈ range sesK ∧ ?KK ⊆ range sesK⟧ ⟹ (Key ?K ∈ analz (insert (Key ?Kab) (Key ` ?KK ∪ IK ?x))) = (?K = ?Kab ∨ ?K ∈ ?KK ∨ Key ?K ∈ analz (IK ?x))› ‹insert (Key ?K) (insert ?y ?A) = insert ?y (insert (Key ?K) ?A)›*) intro!: m3_inv3_sesK_comprI (*‹(⋀K KK. KK ⊆ range sesK ⟹ (Key K ∈ analz (Key ` KK ∪ IK ?x)) = (K ∈ KK ∨ Key K ∈ analz (IK ?x))) ⟹ ?x ∈ m3_inv3_sesK_compr›*))[1]) (*proven 7 subgoals*) . lemma PO_m3_inv3_sesK_compr [iff]: "reach m3 ⊆ m3_inv3_sesK_compr" apply (rule_tac J="m3_inv2_ticket ∩ m3_inv1_lkeysec" in inv_rule_incr (*‹⟦init ?T ⊆ ?I; {?I ∩ ?J} TS.trans ?T {> ?I}; reach ?T ⊆ ?J⟧ ⟹ reach ?T ⊆ ?I›*)) (*goals: 1. ‹init m3 ⊆ m3_inv3_sesK_compr› 2. ‹{m3_inv3_sesK_compr ∩ (m3_inv2_ticket ∩ m3_inv1_lkeysec)} TS.trans m3 {> m3_inv3_sesK_compr}› 3. ‹reach m3 ⊆ m3_inv2_ticket ∩ m3_inv1_lkeysec› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*proven 3 subgoals*) . (******************************************************************************) subsection ‹Refinement› (******************************************************************************) subsubsection ‹Message abstraction and simulation relation› (******************************************************************************) text ‹Abstraction function on sets of messages.› inductive_set abs_msg :: "msg set ⇒ chmsg set" for H :: "msg set" where am_M1: "⦃Agent A, Agent B⦄ ∈ H ⟹ Insec A B (Msg []) ∈ abs_msg H" | am_M2a: "Crypt (shrK C) ⦃Key K, Agent B, Number T, X⦄ ∈ H ⟹ Secure Sv C (Msg [aAgt B, aKey K, aNum T]) ∈ abs_msg H" | am_M2b: "Crypt (shrK C) ⦃Key K, Agent A, Number T⦄ ∈ H ⟹ Secure Sv C (Msg [aKey K, aAgt A, aNum T]) ∈ abs_msg H" text ‹R23: The simulation relation. This is a data refinement of the insecure and secure channels of refinement 2.› definition R23_msgs :: "(m2_state × m3_state) set" where "R23_msgs ≡ {(s, t). abs_msg (parts (IK t)) ⊆ chan s }" definition R23_keys :: "(m2_state × m3_state) set" where "R23_keys ≡ {(s, t). ∀KK K. KK ⊆ range sesK ⟶ Key K ∈ analz (Key`KK ∪ (IK t)) ⟶ aKey K ∈ extr (aKey`KK ∪ ik0) (chan s) }" definition R23_pres :: "(m2_state × m3_state) set" where "R23_pres ≡ {(s, t). runs s = runs t ∧ clk s = clk t ∧ leak s = leak t}" definition R23 :: "(m2_state × m3_state) set" where "R23 ≡ R23_msgs ∩ R23_keys ∩ R23_pres" lemmas R23_defs = R23_def R23_msgs_def R23_keys_def R23_pres_def text ‹The mediator function is the identity here.› definition med32 :: "m3_obs ⇒ m2_obs" where "med32 ≡ id" lemmas R23_msgsI = R23_msgs_def [THEN rel_def_to_intro, simplified, rule_format] lemmas R23_msgsE [elim] = R23_msgs_def [THEN rel_def_to_elim, simplified, rule_format] lemmas R23_keysI = R23_keys_def [THEN rel_def_to_intro, simplified, rule_format] lemmas R23_keysE [elim] = R23_keys_def [THEN rel_def_to_elim, simplified, rule_format] lemmas R23_presI = R23_pres_def [THEN rel_def_to_intro, simplified, rule_format] lemmas R23_presE [elim] = R23_pres_def [THEN rel_def_to_elim, simplified, rule_format] lemmas R23_intros = R23_msgsI R23_keysI R23_presI text ‹Lemmas for various instantiations (for keys).› lemmas R23_keys_dest = R23_keys_def [THEN rel_def_to_dest, simplified, rule_format, rotated 2] lemmas R23_keys_dests = R23_keys_dest R23_keys_dest [where KK="{}", simplified] R23_keys_dest [where KK="{K'}" for K', simplified] R23_keys_dest [where KK="insert K' KK" for K' KK, simplified, OF _ _ conjI] subsubsection ‹General lemmas› (******************************************************************************) text ‹General facts about @{term "abs_msg"}› declare abs_msg.intros [intro!] declare abs_msg.cases [elim!] lemma abs_msg_empty: "abs_msg {} = {}" by auto lemma abs_msg_Un [simp]: "abs_msg (G ∪ H) = abs_msg G ∪ abs_msg H" by auto lemma abs_msg_mono [elim]: "⟦ m ∈ abs_msg G; G ⊆ H ⟧ ⟹ m ∈ abs_msg H" by auto lemma abs_msg_insert_mono [intro]: "⟦ m ∈ abs_msg H ⟧ ⟹ m ∈ abs_msg (insert m' H)" by auto text ‹Facts about @{term "abs_msg"} concerning abstraction of fakeable messages. This is crucial for proving the refinement of the intruder event.› lemma abs_msg_DY_subset_fakeable: "⟦ (s, t) ∈ R23_msgs; (s, t) ∈ R23_keys; (s, t) ∈ R23_non; t ∈ m3_inv1_lkeysec ⟧ ⟹ abs_msg (synth (analz (IK t))) ⊆ fake ik0 (dom (runs s)) (chan s)" apply auto (*goals: 1. ‹⋀(C::agent) (K::key) (B::agent) (T::nat) X::msg. ⟦(s::m2_state, t::m3_state) ∈ R23_msgs; (s, t) ∈ R23_keys; (s, t) ∈ (R23_non::(m2_state × m3_state) set); t ∈ m3_inv1_lkeysec; Crypt (shrK C) ⦃Key K, msg.Agent B, Number T, X⦄ ∈ analz (IK t)⟧ ⟹ StatCh secure Sv C (Msg [aAgt B, aKey K, aNum T]) ∈ fake ik0 (dom (runs s)) (chan s)› 2. ‹⋀(C::agent) (K::key) (B::agent) (T::nat) X::msg. ⟦(s::m2_state, t::m3_state) ∈ R23_msgs; (s, t) ∈ R23_keys; (s, t) ∈ (R23_non::(m2_state × m3_state) set); t ∈ m3_inv1_lkeysec; C ∈ bad; Key K ∈ analz (IK t); X ∈ synth (analz (IK t))⟧ ⟹ StatCh secure Sv C (Msg [aAgt B, aKey K, aNum T]) ∈ fake ik0 (dom (runs s)) (chan s)› 3. ‹⋀(C::agent) (K::key) (A::agent) T::nat. ⟦(s::m2_state, t::m3_state) ∈ R23_msgs; (s, t) ∈ R23_keys; (s, t) ∈ (R23_non::(m2_state × m3_state) set); t ∈ m3_inv1_lkeysec; Crypt (shrK C) ⦃Key K, msg.Agent A, Number T⦄ ∈ analz (IK t)⟧ ⟹ StatCh secure Sv C (Msg [aKey K, aAgt A, aNum T]) ∈ fake ik0 (dom (runs s)) (chan s)› 4. ‹⋀(C::agent) (K::key) (A::agent) T::nat. ⟦(s::m2_state, t::m3_state) ∈ R23_msgs; (s, t) ∈ R23_keys; (s, t) ∈ (R23_non::(m2_state × m3_state) set); t ∈ m3_inv1_lkeysec; C ∈ bad; Key K ∈ analz (IK t)⟧ ⟹ StatCh secure Sv C (Msg [aKey K, aAgt A, aNum T]) ∈ fake ik0 (dom (runs s)) (chan s)› discuss goal 1*) apply blast (*discuss goal 2*) apply (rule fake_StatCh (*‹⟦set ?M ⊆ extr ?T ?H; auth ∉ ?c ∨ ?A ∈ bad ∨ ?B ∈ bad⟧ ⟹ StatCh ?c ?A ?B (Msg ?M) ∈ fake ?T ?U ?H›*)) (*goals: 1. ‹⋀C K B T X. ⟦(s, t) ∈ R23_msgs; (s, t) ∈ R23_keys; (s, t) ∈ R23_non; t ∈ m3_inv1_lkeysec; C ∈ bad; Key K ∈ analz (IK t); X ∈ synth (analz (IK t))⟧ ⟹ set [aAgt B, aKey K, aNum T] ⊆ extr ik0 (chan s)› 2. ‹⋀C K B T X. ⟦(s, t) ∈ R23_msgs; (s, t) ∈ R23_keys; (s, t) ∈ R23_non; t ∈ m3_inv1_lkeysec; C ∈ bad; Key K ∈ analz (IK t); X ∈ synth (analz (IK t))⟧ ⟹ auth ∉ secure ∨ Sv ∈ bad ∨ C ∈ bad› discuss goal 1*) apply ((auto dest: R23_keys_dests (*‹⟦Key (?K::key) ∈ analz (Key ` (?KK::key set) ∪ IK (?t::m3_state)); (?s::m2_state, ?t) ∈ R23_keys; ?KK ⊆ range sesK⟧ ⟹ aKey ?K ∈ extr (aKey ` ?KK ∪ ik0) (chan ?s)› ‹⟦Key (?K::key) ∈ analz (IK (?t::m3_state)); (?s::m2_state, ?t) ∈ R23_keys⟧ ⟹ aKey ?K ∈ extr ik0 (chan ?s)› ‹⟦Key (?K::key) ∈ analz (insert (Key (?K'::key)) (IK (?t::m3_state))); (?s::m2_state, ?t) ∈ R23_keys; ?K' ∈ range sesK⟧ ⟹ aKey ?K ∈ extr (insert (aKey ?K') ik0) (chan ?s)› ‹⟦Key (?K::key) ∈ analz (insert (Key (?K'::key)) (Key ` (?KK::key set) ∪ IK (?t::m3_state))); (?s::m2_state, ?t) ∈ R23_keys; ?K' ∈ range sesK; ?KK ⊆ range sesK⟧ ⟹ aKey ?K ∈ extr (insert (aKey ?K') (aKey ` ?KK ∪ ik0)) (chan ?s)›*))[1]) (*discuss goal 2*) apply ((auto dest: R23_keys_dests (*‹⟦Key ?K ∈ analz (Key ` ?KK ∪ IK ?t); (?s, ?t) ∈ R23_keys; ?KK ⊆ range sesK⟧ ⟹ aKey ?K ∈ extr (aKey ` ?KK ∪ ik0) (chan ?s)› ‹⟦Key ?K ∈ analz (IK ?t); (?s, ?t) ∈ R23_keys⟧ ⟹ aKey ?K ∈ extr ik0 (chan ?s)› ‹⟦Key ?K ∈ analz (insert (Key ?K') (IK ?t)); (?s, ?t) ∈ R23_keys; ?K' ∈ range sesK⟧ ⟹ aKey ?K ∈ extr (insert (aKey ?K') ik0) (chan ?s)› ‹⟦Key ?K ∈ analz (insert (Key ?K') (Key ` ?KK ∪ IK ?t)); (?s, ?t) ∈ R23_keys; ?K' ∈ range sesK; ?KK ⊆ range sesK⟧ ⟹ aKey ?K ∈ extr (insert (aKey ?K') (aKey ` ?KK ∪ ik0)) (chan ?s)›*))[1]) (*proven 2 subgoals*) (*discuss goal 3*) apply blast (*discuss goal 4*) apply (rule fake_StatCh (*‹⟦set ?M ⊆ extr ?T ?H; auth ∉ ?c ∨ ?A ∈ bad ∨ ?B ∈ bad⟧ ⟹ StatCh ?c ?A ?B (Msg ?M) ∈ fake ?T ?U ?H›*)) (*goals: 1. ‹⋀C K A T. ⟦(s, t) ∈ R23_msgs; (s, t) ∈ R23_keys; (s, t) ∈ R23_non; t ∈ m3_inv1_lkeysec; C ∈ bad; Key K ∈ analz (IK t)⟧ ⟹ set [aKey K, aAgt A, aNum T] ⊆ extr ik0 (chan s)› 2. ‹⋀C K A T. ⟦(s, t) ∈ R23_msgs; (s, t) ∈ R23_keys; (s, t) ∈ R23_non; t ∈ m3_inv1_lkeysec; C ∈ bad; Key K ∈ analz (IK t)⟧ ⟹ auth ∉ secure ∨ Sv ∈ bad ∨ C ∈ bad› discuss goal 1*) apply ((auto dest: R23_keys_dests (*‹⟦Key ?K ∈ analz (Key ` ?KK ∪ IK ?t); (?s, ?t) ∈ R23_keys; ?KK ⊆ range sesK⟧ ⟹ aKey ?K ∈ extr (aKey ` ?KK ∪ ik0) (chan ?s)› ‹⟦Key ?K ∈ analz (IK ?t); (?s, ?t) ∈ R23_keys⟧ ⟹ aKey ?K ∈ extr ik0 (chan ?s)› ‹⟦Key ?K ∈ analz (insert (Key ?K') (IK ?t)); (?s, ?t) ∈ R23_keys; ?K' ∈ range sesK⟧ ⟹ aKey ?K ∈ extr (insert (aKey ?K') ik0) (chan ?s)› ‹⟦Key ?K ∈ analz (insert (Key ?K') (Key ` ?KK ∪ IK ?t)); (?s, ?t) ∈ R23_keys; ?K' ∈ range sesK; ?KK ⊆ range sesK⟧ ⟹ aKey ?K ∈ extr (insert (aKey ?K') (aKey ` ?KK ∪ ik0)) (chan ?s)›*))[1]) (*discuss goal 2*) apply ((auto dest: R23_keys_dests (*‹⟦Key ?K ∈ analz (Key ` ?KK ∪ IK ?t); (?s, ?t) ∈ R23_keys; ?KK ⊆ range sesK⟧ ⟹ aKey ?K ∈ extr (aKey ` ?KK ∪ ik0) (chan ?s)› ‹⟦Key ?K ∈ analz (IK ?t); (?s, ?t) ∈ R23_keys⟧ ⟹ aKey ?K ∈ extr ik0 (chan ?s)› ‹⟦Key ?K ∈ analz (insert (Key ?K') (IK ?t)); (?s, ?t) ∈ R23_keys; ?K' ∈ range sesK⟧ ⟹ aKey ?K ∈ extr (insert (aKey ?K') ik0) (chan ?s)› ‹⟦Key ?K ∈ analz (insert (Key ?K') (Key ` ?KK ∪ IK ?t)); (?s, ?t) ∈ R23_keys; ?K' ∈ range sesK; ?KK ⊆ range sesK⟧ ⟹ aKey ?K ∈ extr (insert (aKey ?K') (aKey ` ?KK ∪ ik0)) (chan ?s)›*))[1]) (*proven 2 subgoals*) (*proven 4 subgoals*) . subsubsection ‹Refinement proof› (******************************************************************************) text ‹Pair decomposition. These were set to \texttt{elim!}, which is too agressive here.› declare MPair_analz [rule del, elim] declare MPair_parts [rule del, elim] text ‹Protocol events.› lemma PO_m3_step1_refines_m2_step1: "{R23} (m2_step1 Ra A B), (m3_step1 Ra A B) {> R23}" apply (auto simp add: PO_rhoare_defs (*‹{?pre} ?Ra, ?Rc {> ?post} ≡ ?pre O ?Rc ⊆ ?Ra O ?post› ‹?r O ?s = {(x, z). ∃y. (x, y) ∈ ?r ∧ (y, z) ∈ ?s}›*) R23_def (*‹R23 ≡ R23_msgs ∩ R23_keys ∩ R23_pres›*) m3_defs (*‹m3 ≡ ⦇init = m3_init, trans = m3_trans, obs = m3_obs⦈› ‹m3_init ≡ {⦇runs = λx. None, leak = shrK ` bad, clk = 0, IK = Key ` shrK ` bad⦈}› ‹m3_trans ≡ ⋃A B Ra Rb Rs Kab Ts T X. (m3_step1 Ra A B ∪ m3_step2 Rb A B ∪ m3_step3 Rs A B Kab Ts ∪ m3_step4 Ra A B Kab Ts X ∪ m3_step5 Rb A B Kab Ts ∪ m3_tick T ∪ m3_leak Rs ∪ m3_DY_fake)⁼› ‹m3_obs ?s ≡ ⦇runs = runs ?s, leak = leak ?s, clk = clk ?s⦈› ‹m3_step1 ?Ra ?A ?B ≡ {(s, s1). ?Ra ∉ dom (runs s) ∧ s1 = s⦇runs := (runs s)(?Ra ↦ (Init, [?A, ?B], [])), IK := insert ⦃msg.Agent ?A, msg.Agent ?B⦄ (IK s)⦈}› ‹m3_step2 ≡ m1_step2› ‹m3_step3 ?Rs ?A ?B ?Kab ?Ts ≡ {(s, s1). ?Rs ∉ dom (runs s) ∧ ?Kab = sesK (?Rs $ sk) ∧ ⦃msg.Agent ?A, msg.Agent ?B⦄ ∈ IK s ∧ ?Ts = clk s ∧ s1 = s⦇runs := (runs s)(?Rs ↦ (Serv, [?A, ?B], [aNum ?Ts])), IK := insert (Crypt (shrK ?A) ⦃Key ?Kab, msg.Agent ?B, Number ?Ts, Crypt (shrK ?B) ⦃Key ?Kab, msg.Agent ?A, Number ?Ts⦄⦄) (IK s)⦈}› ‹m3_step4 ?Ra ?A ?B ?Kab ?Ts ?X ≡ {(s, s1). runs s ?Ra = Some (Init, [?A, ?B], []) ∧ Crypt (shrK ?A) ⦃Key ?Kab, msg.Agent ?B, Number ?Ts, ?X⦄ ∈ IK s ∧ clk s < ?Ts + Ls ∧ s1 = s⦇runs := (runs s)(?Ra ↦ (Init, [?A, ?B], [aKey ?Kab, aNum ?Ts])), IK := insert ?X (IK s)⦈}› ‹m3_step5 ?Rb ?A ?B ?Kab ?Ts ≡ {(s, s1). runs s ?Rb = Some (Resp, [?A, ?B], []) ∧ Crypt (shrK ?B) ⦃Key ?Kab, msg.Agent ?A, Number ?Ts⦄ ∈ IK s ∧ clk s < ?Ts + Ls ∧ s1 = s⦇runs := (runs s)(?Rb ↦ (Resp, [?A, ?B], [aKey ?Kab, aNum ?Ts]))⦈}› ‹m3_tick ≡ m1_tick› ‹m3_leak ?Rs ≡ {(s, s1). ?Rs ∈ dom (runs s) ∧ fst (the (runs s ?Rs)) = Serv ∧ s1 = s⦇leak := insert (sesK (?Rs $ sk)) (leak s), IK := insert (Key (sesK (?Rs $ sk))) (IK s)⦈}› ‹m3_DY_fake ≡ {(s, s1). s1 = s⦇IK := synth (analz (IK s))⦈}› and more 40 facts*) intro!: R23_intros (*‹abs_msg (parts (IK ?t)) ⊆ chan ?s ⟹ (?s, ?t) ∈ R23_msgs› ‹(⋀KK K. ⟦KK ⊆ range sesK; Key K ∈ analz (Key ` KK ∪ IK ?t)⟧ ⟹ aKey K ∈ extr (aKey ` KK ∪ ik0) (chan ?s)) ⟹ (?s, ?t) ∈ R23_keys› ‹runs ?s = runs ?t ∧ clk ?s = clk ?t ∧ leak ?s = leak ?t ⟹ (?s, ?t) ∈ R23_pres›*)) (*goals: 1. ‹⋀a y Aa B. ⟦(a, y) ∈ R23_msgs; (a, y) ∈ R23_keys; (a, y) ∈ R23_pres; Ra ∉ dom (runs y); Insec Aa B (Msg []) ∉ chan a; ⦃msg.Agent Aa, msg.Agent B⦄ ∈ parts (IK y)⟧ ⟹ Aa = A› 2. ‹⋀a y A Ba. ⟦(a, y) ∈ R23_msgs; (a, y) ∈ R23_keys; (a, y) ∈ R23_pres; Ra ∉ dom (runs y); Insec A Ba (Msg []) ∉ chan a; ⦃msg.Agent A, msg.Agent Ba⦄ ∈ parts (IK y)⟧ ⟹ Ba = B› 3. ‹⋀a y C K B T X. ⟦(a, y) ∈ R23_msgs; (a, y) ∈ R23_keys; (a, y) ∈ R23_pres; Ra ∉ dom (runs y); Crypt (shrK C) ⦃Key K, msg.Agent B, Number T, X⦄ ∈ parts (IK y)⟧ ⟹ StatCh secure Sv C (Msg [aAgt B, aKey K, aNum T]) ∈ chan a› 4. ‹⋀a y C K A T. ⟦(a, y) ∈ R23_msgs; (a, y) ∈ R23_keys; (a, y) ∈ R23_pres; Ra ∉ dom (runs y); Crypt (shrK C) ⦃Key K, msg.Agent A, Number T⦄ ∈ parts (IK y)⟧ ⟹ StatCh secure Sv C (Msg [aKey K, aAgt A, aNum T]) ∈ chan 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*) . lemma PO_m3_step2_refines_m2_step2: "{R23} (m2_step2 Rb A B), (m3_step2 Rb A B) {> R23}" apply (auto simp add: PO_rhoare_defs (*‹{?pre} ?Ra, ?Rc {> ?post} ≡ ?pre O ?Rc ⊆ ?Ra O ?post› ‹?r O ?s = {(x, z). ∃y. (x, y) ∈ ?r ∧ (y, z) ∈ ?s}›*) R23_def (*‹R23 ≡ R23_msgs ∩ R23_keys ∩ R23_pres›*) m3_defs (*‹m3 ≡ ⦇init = m3_init, trans = m3_trans, obs = m3_obs⦈› ‹m3_init ≡ {⦇runs = λx. None, leak = shrK ` bad, clk = 0, IK = Key ` shrK ` bad⦈}› ‹m3_trans ≡ ⋃A B Ra Rb Rs Kab Ts T X. (m3_step1 Ra A B ∪ m3_step2 Rb A B ∪ m3_step3 Rs A B Kab Ts ∪ m3_step4 Ra A B Kab Ts X ∪ m3_step5 Rb A B Kab Ts ∪ m3_tick T ∪ m3_leak Rs ∪ m3_DY_fake)⁼› ‹m3_obs ?s ≡ ⦇runs = runs ?s, leak = leak ?s, clk = clk ?s⦈› ‹m3_step1 ?Ra ?A ?B ≡ {(s, s1). ?Ra ∉ dom (runs s) ∧ s1 = s⦇runs := (runs s)(?Ra ↦ (Init, [?A, ?B], [])), IK := insert ⦃msg.Agent ?A, msg.Agent ?B⦄ (IK s)⦈}› ‹m3_step2 ≡ m1_step2› ‹m3_step3 ?Rs ?A ?B ?Kab ?Ts ≡ {(s, s1). ?Rs ∉ dom (runs s) ∧ ?Kab = sesK (?Rs $ sk) ∧ ⦃msg.Agent ?A, msg.Agent ?B⦄ ∈ IK s ∧ ?Ts = clk s ∧ s1 = s⦇runs := (runs s)(?Rs ↦ (Serv, [?A, ?B], [aNum ?Ts])), IK := insert (Crypt (shrK ?A) ⦃Key ?Kab, msg.Agent ?B, Number ?Ts, Crypt (shrK ?B) ⦃Key ?Kab, msg.Agent ?A, Number ?Ts⦄⦄) (IK s)⦈}› ‹m3_step4 ?Ra ?A ?B ?Kab ?Ts ?X ≡ {(s, s1). runs s ?Ra = Some (Init, [?A, ?B], []) ∧ Crypt (shrK ?A) ⦃Key ?Kab, msg.Agent ?B, Number ?Ts, ?X⦄ ∈ IK s ∧ clk s < ?Ts + Ls ∧ s1 = s⦇runs := (runs s)(?Ra ↦ (Init, [?A, ?B], [aKey ?Kab, aNum ?Ts])), IK := insert ?X (IK s)⦈}› ‹m3_step5 ?Rb ?A ?B ?Kab ?Ts ≡ {(s, s1). runs s ?Rb = Some (Resp, [?A, ?B], []) ∧ Crypt (shrK ?B) ⦃Key ?Kab, msg.Agent ?A, Number ?Ts⦄ ∈ IK s ∧ clk s < ?Ts + Ls ∧ s1 = s⦇runs := (runs s)(?Rb ↦ (Resp, [?A, ?B], [aKey ?Kab, aNum ?Ts]))⦈}› ‹m3_tick ≡ m1_tick› ‹m3_leak ?Rs ≡ {(s, s1). ?Rs ∈ dom (runs s) ∧ fst (the (runs s ?Rs)) = Serv ∧ s1 = s⦇leak := insert (sesK (?Rs $ sk)) (leak s), IK := insert (Key (sesK (?Rs $ sk))) (IK s)⦈}› ‹m3_DY_fake ≡ {(s, s1). s1 = s⦇IK := synth (analz (IK s))⦈}› and more 40 facts*) intro!: R23_intros (*‹abs_msg (parts (IK ?t)) ⊆ chan ?s ⟹ (?s, ?t) ∈ R23_msgs› ‹(⋀KK K. ⟦KK ⊆ range sesK; Key K ∈ analz (Key ` KK ∪ IK ?t)⟧ ⟹ aKey K ∈ extr (aKey ` KK ∪ ik0) (chan ?s)) ⟹ (?s, ?t) ∈ R23_keys› ‹runs ?s = runs ?t ∧ clk ?s = clk ?t ∧ leak ?s = leak ?t ⟹ (?s, ?t) ∈ R23_pres›*)) (*goals: 1. ‹⋀(a::m2_state) (y::m3_state) (A::agent) B::agent. ⟦(a, y) ∈ R23_msgs; (a, y) ∈ R23_keys; (a, y) ∈ R23_pres; (Rb::fid_t) ∉ dom (runs y); ⦃msg.Agent A, msg.Agent B⦄ ∈ parts (IK y)⟧ ⟹ Insec A B (Msg []) ∈ chan a› 2. ‹⋀(a::m2_state) (y::m3_state) (C::agent) (K::key) (B::agent) (T::nat) X::msg. ⟦(a, y) ∈ R23_msgs; (a, y) ∈ R23_keys; (a, y) ∈ R23_pres; (Rb::fid_t) ∉ dom (runs y); Crypt (shrK C) ⦃Key K, msg.Agent B, Number T, X⦄ ∈ parts (IK y)⟧ ⟹ StatCh secure Sv C (Msg [aAgt B, aKey K, aNum T]) ∈ chan a› 3. ‹⋀(a::m2_state) (y::m3_state) (C::agent) (K::key) (A::agent) T::nat. ⟦(a, y) ∈ R23_msgs; (a, y) ∈ R23_keys; (a, y) ∈ R23_pres; (Rb::fid_t) ∉ dom (runs y); Crypt (shrK C) ⦃Key K, msg.Agent A, Number T⦄ ∈ parts (IK y)⟧ ⟹ StatCh secure Sv C (Msg [aKey K, aAgt A, aNum T]) ∈ chan a› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*proven 3 subgoals*) . lemma PO_m3_step3_refines_m2_step3: "{R23 ∩ (m2_inv3a_sesK_compr) × (m3_inv3_sesK_compr ∩ m3_inv1_lkeysec)} (m2_step3 Rs A B Kab Ts), (m3_step3 Rs A B Kab Ts) {> R23}" proof (-) (*goal: ‹{R23 ∩ m2_inv3a_sesK_compr × (m3_inv3_sesK_compr ∩ m3_inv1_lkeysec)} m2_step3 (Rs::fid_t) (A::agent) (B::agent) (Kab::key) (Ts::nat), m3_step3 Rs A B Kab Ts {> R23}›*) { fix s and t assume H: "(s, t) ∈ R23_msgs" "(s, t) ∈ R23_keys" "(s, t) ∈ R23_pres" "s ∈ m2_inv3a_sesK_compr" "t ∈ m3_inv3_sesK_compr" "t ∈ m3_inv1_lkeysec" "Kab = sesK (Rs$sk)" "Rs ∉ dom (runs t)" "⦃Agent A, Agent B⦄ ∈ parts (IK t)" (*‹(s::m2_state, t::m3_state) ∈ R23_msgs› ‹(s::m2_state, t::m3_state) ∈ R23_keys› ‹(s::m2_state, t::m3_state) ∈ R23_pres› ‹(s::m2_state) ∈ m2_inv3a_sesK_compr› ‹(t::m3_state) ∈ m3_inv3_sesK_compr› ‹(t::m3_state) ∈ m3_inv1_lkeysec› ‹(Kab::key) = sesK ((Rs::fid_t) $ sk)› ‹(Rs::fid_t) ∉ dom (runs (t::m3_state))› ‹⦃msg.Agent (A::agent), msg.Agent (B::agent)⦄ ∈ parts (IK (t::m3_state))›*) let ?s' = "s⦇ runs := (runs s)(Rs ↦ (Serv, [A, B], [aNum (clk t)])), chan := insert (Secure Sv A (Msg [aAgt B, aKey Kab, aNum (clk t)])) (insert (Secure Sv B (Msg [aKey Kab, aAgt A, aNum (clk t)])) (chan s)) ⦈" let ?t' = "t⦇ runs := (runs t)(Rs ↦ (Serv, [A, B], [aNum (clk t)])), IK := insert (Crypt (shrK A) ⦃ Key Kab, Agent B, Number (clk t), Crypt (shrK B) ⦃ Key Kab, Agent A, Number (clk t) ⦄⦄) (IK t) ⦈" have "(?s', ?t') ∈ R23_msgs" using H (*‹(s, t) ∈ R23_msgs› ‹(s, t) ∈ R23_keys› ‹(s, t) ∈ R23_pres› ‹(s::m2_state) ∈ m2_inv3a_sesK_compr› ‹t ∈ m3_inv3_sesK_compr› ‹(t::m3_state) ∈ m3_inv1_lkeysec› ‹Kab = sesK (Rs $ sk)› ‹Rs ∉ dom (runs t)› ‹⦃msg.Agent A, msg.Agent B⦄ ∈ parts (IK t)›*) apply - (*goal: ‹(s⦇runs := (runs s)(Rs ↦ (Serv, [A, B], [aNum (clk t)])), chan := insert (StatCh secure Sv A (Msg [aAgt B, aKey Kab, aNum (clk t)])) (insert (StatCh secure Sv B (Msg [aKey Kab, aAgt A, aNum (clk t)])) (chan s))⦈, t⦇runs := (runs t)(Rs ↦ (Serv, [A, B], [aNum (clk t)])), IK := insert (Crypt (shrK A) ⦃Key Kab, msg.Agent B, Number (clk t), Crypt (shrK B) ⦃Key Kab, msg.Agent A, Number (clk t)⦄⦄) (IK t)⦈) ∈ R23_msgs›*) apply (rule R23_intros (*‹abs_msg (parts (IK ?t)) ⊆ chan ?s ⟹ (?s, ?t) ∈ R23_msgs› ‹(⋀KK K. ⟦KK ⊆ range sesK; Key K ∈ analz (Key ` KK ∪ IK ?t)⟧ ⟹ aKey K ∈ extr (aKey ` KK ∪ ik0) (chan ?s)) ⟹ (?s, ?t) ∈ R23_keys› ‹runs ?s = runs ?t ∧ clk ?s = clk ?t ∧ leak ?s = leak ?t ⟹ (?s, ?t) ∈ R23_pres›*)) (*goal: ‹⟦(s, t) ∈ R23_msgs; (s, t) ∈ R23_keys; (s, t) ∈ R23_pres; s ∈ m2_inv3a_sesK_compr; t ∈ m3_inv3_sesK_compr; t ∈ m3_inv1_lkeysec; Kab = sesK (Rs $ sk); Rs ∉ dom (runs t); ⦃msg.Agent A, msg.Agent B⦄ ∈ parts (IK t)⟧ ⟹ (s⦇runs := (runs s)(Rs ↦ (Serv, [A, B], [aNum (clk t)])), chan := insert (StatCh secure Sv A (Msg [aAgt B, aKey Kab, aNum (clk t)])) (insert (StatCh secure Sv B (Msg [aKey Kab, aAgt A, aNum (clk t)])) (chan s))⦈, t⦇runs := (runs t)(Rs ↦ (Serv, [A, B], [aNum (clk t)])), IK := insert (Crypt (shrK A) ⦃Key Kab, msg.Agent B, Number (clk t), Crypt (shrK B) ⦃Key Kab, msg.Agent A, Number (clk t)⦄⦄) (IK t)⦈) ∈ R23_msgs›*) by auto moreover have "(?s', ?t') ∈ R23_keys" using H (*‹(s, t) ∈ R23_msgs› ‹(s, t) ∈ R23_keys› ‹(s, t) ∈ R23_pres› ‹(s::m2_state) ∈ m2_inv3a_sesK_compr› ‹t ∈ m3_inv3_sesK_compr› ‹(t::m3_state) ∈ m3_inv1_lkeysec› ‹Kab = sesK (Rs $ sk)› ‹Rs ∉ dom (runs t)› ‹⦃msg.Agent A, msg.Agent B⦄ ∈ parts (IK t)›*) apply - (*goal: ‹(s⦇runs := (runs s)(Rs ↦ (Serv, [A, B], [aNum (clk t)])), chan := insert (StatCh secure Sv A (Msg [aAgt B, aKey Kab, aNum (clk t)])) (insert (StatCh secure Sv B (Msg [aKey Kab, aAgt A, aNum (clk t)])) (chan s))⦈, t⦇runs := (runs t)(Rs ↦ (Serv, [A, B], [aNum (clk t)])), IK := insert (Crypt (shrK A) ⦃Key Kab, msg.Agent B, Number (clk t), Crypt (shrK B) ⦃Key Kab, msg.Agent A, Number (clk t)⦄⦄) (IK t)⦈) ∈ R23_keys›*) apply (rule R23_intros (*‹abs_msg (parts (IK ?t)) ⊆ chan ?s ⟹ (?s, ?t) ∈ R23_msgs› ‹(⋀KK K. ⟦KK ⊆ range sesK; Key K ∈ analz (Key ` KK ∪ IK ?t)⟧ ⟹ aKey K ∈ extr (aKey ` KK ∪ ik0) (chan ?s)) ⟹ (?s, ?t) ∈ R23_keys› ‹runs ?s = runs ?t ∧ clk ?s = clk ?t ∧ leak ?s = leak ?t ⟹ (?s, ?t) ∈ R23_pres›*)) (*goal: ‹⟦(s, t) ∈ R23_msgs; (s, t) ∈ R23_keys; (s, t) ∈ R23_pres; s ∈ m2_inv3a_sesK_compr; t ∈ m3_inv3_sesK_compr; t ∈ m3_inv1_lkeysec; Kab = sesK (Rs $ sk); Rs ∉ dom (runs t); ⦃msg.Agent A, msg.Agent B⦄ ∈ parts (IK t)⟧ ⟹ (s⦇runs := (runs s)(Rs ↦ (Serv, [A, B], [aNum (clk t)])), chan := insert (StatCh secure Sv A (Msg [aAgt B, aKey Kab, aNum (clk t)])) (insert (StatCh secure Sv B (Msg [aKey Kab, aAgt A, aNum (clk t)])) (chan s))⦈, t⦇runs := (runs t)(Rs ↦ (Serv, [A, B], [aNum (clk t)])), IK := insert (Crypt (shrK A) ⦃Key Kab, msg.Agent B, Number (clk t), Crypt (shrK B) ⦃Key Kab, msg.Agent A, Number (clk t)⦄⦄) (IK t)⦈) ∈ R23_keys›*) by (auto simp add: m2_inv3a_sesK_compr_simps (*‹?x ∈ m2_inv3a_sesK_compr ⟹ (aKey ?K ∈ extr (aKey ` ?KK ∪ ik0) (chan ?x)) = (?K ∈ ?KK ∨ aKey ?K ∈ extr ik0 (chan ?x))› ‹?x ∈ m2_inv3a_sesK_compr ⟹ (aKey ?K ∈ extr (insert (aKey ?Kab) (aKey ` ?KK ∪ ik0)) (chan ?x)) = (?K = ?Kab ∨ ?K ∈ ?KK ∨ aKey ?K ∈ extr ik0 (chan ?x))› ‹?x ∈ m2_inv3a_sesK_compr ⟹ (aKey ?K ∈ extr (insert (aKey ?Kab) ik0) (chan ?x)) = (?K = ?Kab ∨ aKey ?K ∈ extr ik0 (chan ?x))› ‹insert (aKey ?K) (insert ?y ?A) = insert ?y (insert (aKey ?K) ?A)›*) m3_inv3_sesK_compr_simps (*‹⟦?x ∈ m3_inv3_sesK_compr; ?KK ⊆ range sesK⟧ ⟹ (Key ?K ∈ analz (Key ` ?KK ∪ IK ?x)) = (?K ∈ ?KK ∨ Key ?K ∈ analz (IK ?x))› ‹⟦?x ∈ m3_inv3_sesK_compr; ?Kab ∈ range sesK⟧ ⟹ (Key ?K ∈ analz (insert (Key ?Kab) (IK ?x))) = (?K = ?Kab ∨ Key ?K ∈ analz (IK ?x))› ‹⟦?x ∈ m3_inv3_sesK_compr; ?Kab ∈ range sesK ∧ ?KK ⊆ range sesK⟧ ⟹ (Key ?K ∈ analz (insert (Key ?Kab) (Key ` ?KK ∪ IK ?x))) = (?K = ?Kab ∨ ?K ∈ ?KK ∨ Key ?K ∈ analz (IK ?x))› ‹insert (Key ?K) (insert ?y ?A) = insert ?y (insert (Key ?K) ?A)›*) dest: R23_keys_dests (*‹⟦Key ?K ∈ analz (Key ` ?KK ∪ IK ?t); (?s, ?t) ∈ R23_keys; ?KK ⊆ range sesK⟧ ⟹ aKey ?K ∈ extr (aKey ` ?KK ∪ ik0) (chan ?s)› ‹⟦Key ?K ∈ analz (IK ?t); (?s, ?t) ∈ R23_keys⟧ ⟹ aKey ?K ∈ extr ik0 (chan ?s)› ‹⟦Key ?K ∈ analz (insert (Key ?K') (IK ?t)); (?s, ?t) ∈ R23_keys; ?K' ∈ range sesK⟧ ⟹ aKey ?K ∈ extr (insert (aKey ?K') ik0) (chan ?s)› ‹⟦Key ?K ∈ analz (insert (Key ?K') (Key ` ?KK ∪ IK ?t)); (?s, ?t) ∈ R23_keys; ?K' ∈ range sesK; ?KK ⊆ range sesK⟧ ⟹ aKey ?K ∈ extr (insert (aKey ?K') (aKey ` ?KK ∪ ik0)) (chan ?s)›*)) moreover have "(?s', ?t') ∈ R23_pres" using H (*‹(s, t) ∈ R23_msgs› ‹(s, t) ∈ R23_keys› ‹(s, t) ∈ R23_pres› ‹s ∈ m2_inv3a_sesK_compr› ‹(t::m3_state) ∈ m3_inv3_sesK_compr› ‹t ∈ m3_inv1_lkeysec› ‹Kab = sesK (Rs $ sk)› ‹Rs ∉ dom (runs t)› ‹⦃msg.Agent A, msg.Agent B⦄ ∈ parts (IK t)›*) apply - (*goal: ‹(s⦇runs := (runs s)(Rs ↦ (Serv, [A, B], [aNum (clk t)])), chan := insert (StatCh secure Sv A (Msg [aAgt B, aKey Kab, aNum (clk t)])) (insert (StatCh secure Sv B (Msg [aKey Kab, aAgt A, aNum (clk t)])) (chan s))⦈, t⦇runs := (runs t)(Rs ↦ (Serv, [A, B], [aNum (clk t)])), IK := insert (Crypt (shrK A) ⦃Key Kab, msg.Agent B, Number (clk t), Crypt (shrK B) ⦃Key Kab, msg.Agent A, Number (clk t)⦄⦄) (IK t)⦈) ∈ R23_pres›*) apply (rule R23_intros (*‹abs_msg (parts (IK ?t)) ⊆ chan ?s ⟹ (?s, ?t) ∈ R23_msgs› ‹(⋀KK K. ⟦KK ⊆ range sesK; Key K ∈ analz (Key ` KK ∪ IK ?t)⟧ ⟹ aKey K ∈ extr (aKey ` KK ∪ ik0) (chan ?s)) ⟹ (?s, ?t) ∈ R23_keys› ‹runs ?s = runs ?t ∧ clk ?s = clk ?t ∧ leak ?s = leak ?t ⟹ (?s, ?t) ∈ R23_pres›*)) (*goal: ‹⟦(s::m2_state, t::m3_state) ∈ R23_msgs; (s, t) ∈ R23_keys; (s, t) ∈ R23_pres; s ∈ m2_inv3a_sesK_compr; t ∈ m3_inv3_sesK_compr; t ∈ m3_inv1_lkeysec; (Kab::key) = sesK ((Rs::fid_t) $ sk); Rs ∉ dom (runs t); ⦃msg.Agent (A::agent), msg.Agent (B::agent)⦄ ∈ parts (IK t)⟧ ⟹ (s⦇runs := (runs s)(Rs ↦ (Serv, [A, B], [aNum (clk t)])), chan := insert (StatCh secure Sv A (Msg [aAgt B, aKey Kab, aNum (clk t)])) (insert (StatCh secure Sv B (Msg [aKey Kab, aAgt A, aNum (clk t)])) (chan s))⦈, t⦇runs := (runs t)(Rs ↦ (Serv, [A, B], [aNum (clk t)])), IK := insert (Crypt (shrK A) ⦃Key Kab, msg.Agent B, Number (clk t), Crypt (shrK B) ⦃Key Kab, msg.Agent A, Number (clk t)⦄⦄) (IK t)⦈) ∈ R23_pres›*) by auto moreover note calculation (*‹(s⦇runs := (runs s)(Rs ↦ (Serv, [A, B], [aNum (clk t)])), chan := insert (StatCh secure Sv A (Msg [aAgt B, aKey Kab, aNum (clk t)])) (insert (StatCh secure Sv B (Msg [aKey Kab, aAgt A, aNum (clk t)])) (chan s))⦈, t⦇runs := (runs t)(Rs ↦ (Serv, [A, B], [aNum (clk t)])), IK := insert (Crypt (shrK A) ⦃Key Kab, msg.Agent B, Number (clk t), Crypt (shrK B) ⦃Key Kab, msg.Agent A, Number (clk t)⦄⦄) (IK t)⦈) ∈ R23_msgs› ‹(s⦇runs := (runs s)(Rs ↦ (Serv, [A, B], [aNum (clk t)])), chan := insert (StatCh secure Sv A (Msg [aAgt B, aKey Kab, aNum (clk t)])) (insert (StatCh secure Sv B (Msg [aKey Kab, aAgt A, aNum (clk t)])) (chan s))⦈, t⦇runs := (runs t)(Rs ↦ (Serv, [A, B], [aNum (clk t)])), IK := insert (Crypt (shrK A) ⦃Key Kab, msg.Agent B, Number (clk t), Crypt (shrK B) ⦃Key Kab, msg.Agent A, Number (clk t)⦄⦄) (IK t)⦈) ∈ R23_keys› ‹(s⦇runs := (runs s)(Rs ↦ (Serv, [A, B], [aNum (clk t)])), chan := insert (StatCh secure Sv A (Msg [aAgt B, aKey Kab, aNum (clk t)])) (insert (StatCh secure Sv B (Msg [aKey Kab, aAgt A, aNum (clk t)])) (chan s))⦈, t⦇runs := (runs t)(Rs ↦ (Serv, [A, B], [aNum (clk t)])), IK := insert (Crypt (shrK A) ⦃Key Kab, msg.Agent B, Number (clk t), Crypt (shrK B) ⦃Key Kab, msg.Agent A, Number (clk t)⦄⦄) (IK t)⦈) ∈ R23_pres›*) } thus "?thesis" (*goal: ‹{R23 ∩ m2_inv3a_sesK_compr × (m3_inv3_sesK_compr ∩ m3_inv1_lkeysec)} m2_step3 (Rs::fid_t) (A::agent) (B::agent) (Kab::key) (Ts::nat), m3_step3 Rs A B Kab Ts {> R23}›*) by (auto simp add: PO_rhoare_defs (*‹{?pre} ?Ra, ?Rc {> ?post} ≡ ?pre O ?Rc ⊆ ?Ra O ?post› ‹?r O ?s = {(x, z). ∃y. (x, y) ∈ ?r ∧ (y, z) ∈ ?s}›*) R23_def (*‹R23 ≡ R23_msgs ∩ R23_keys ∩ R23_pres›*) m3_defs (*‹m3 ≡ ⦇init = m3_init, trans = m3_trans, obs = m3_obs⦈› ‹m3_init ≡ {⦇runs = λx. None, leak = shrK ` bad, clk = 0, IK = Key ` shrK ` bad⦈}› ‹m3_trans ≡ ⋃A B Ra Rb Rs Kab Ts T X. (m3_step1 Ra A B ∪ m3_step2 Rb A B ∪ m3_step3 Rs A B Kab Ts ∪ m3_step4 Ra A B Kab Ts X ∪ m3_step5 Rb A B Kab Ts ∪ m3_tick T ∪ m3_leak Rs ∪ m3_DY_fake)⁼› ‹m3_obs ?s ≡ ⦇runs = runs ?s, leak = leak ?s, clk = clk ?s⦈› ‹m3_step1 ?Ra ?A ?B ≡ {(s, s1). ?Ra ∉ dom (runs s) ∧ s1 = s⦇runs := (runs s)(?Ra ↦ (Init, [?A, ?B], [])), IK := insert ⦃msg.Agent ?A, msg.Agent ?B⦄ (IK s)⦈}› ‹m3_step2 ≡ m1_step2› ‹m3_step3 ?Rs ?A ?B ?Kab ?Ts ≡ {(s, s1). ?Rs ∉ dom (runs s) ∧ ?Kab = sesK (?Rs $ sk) ∧ ⦃msg.Agent ?A, msg.Agent ?B⦄ ∈ IK s ∧ ?Ts = clk s ∧ s1 = s⦇runs := (runs s)(?Rs ↦ (Serv, [?A, ?B], [aNum ?Ts])), IK := insert (Crypt (shrK ?A) ⦃Key ?Kab, msg.Agent ?B, Number ?Ts, Crypt (shrK ?B) ⦃Key ?Kab, msg.Agent ?A, Number ?Ts⦄⦄) (IK s)⦈}› ‹m3_step4 ?Ra ?A ?B ?Kab ?Ts ?X ≡ {(s, s1). runs s ?Ra = Some (Init, [?A, ?B], []) ∧ Crypt (shrK ?A) ⦃Key ?Kab, msg.Agent ?B, Number ?Ts, ?X⦄ ∈ IK s ∧ clk s < ?Ts + Ls ∧ s1 = s⦇runs := (runs s)(?Ra ↦ (Init, [?A, ?B], [aKey ?Kab, aNum ?Ts])), IK := insert ?X (IK s)⦈}› ‹m3_step5 ?Rb ?A ?B ?Kab ?Ts ≡ {(s, s1). runs s ?Rb = Some (Resp, [?A, ?B], []) ∧ Crypt (shrK ?B) ⦃Key ?Kab, msg.Agent ?A, Number ?Ts⦄ ∈ IK s ∧ clk s < ?Ts + Ls ∧ s1 = s⦇runs := (runs s)(?Rb ↦ (Resp, [?A, ?B], [aKey ?Kab, aNum ?Ts]))⦈}› ‹m3_tick ≡ m1_tick› ‹m3_leak ?Rs ≡ {(s, s1). ?Rs ∈ dom (runs s) ∧ fst (the (runs s ?Rs)) = Serv ∧ s1 = s⦇leak := insert (sesK (?Rs $ sk)) (leak s), IK := insert (Key (sesK (?Rs $ sk))) (IK s)⦈}› ‹m3_DY_fake ≡ {(s, s1). s1 = s⦇IK := synth (analz (IK s))⦈}› and more 40 facts*)) qed lemma PO_m3_step4_refines_m2_step4: "{R23 ∩ UNIV × (m3_inv3_sesK_compr ∩ m3_inv2_ticket ∩ m3_inv1_lkeysec)} (m2_step4 Ra A B Kab Ts), (m3_step4 Ra A B Kab Ts X) {> R23}" proof (-) (*goal: ‹{R23 ∩ UNIV × (m3_inv3_sesK_compr ∩ m3_inv2_ticket ∩ m3_inv1_lkeysec)} m2_step4 Ra A B Kab Ts, m3_step4 Ra A B Kab Ts X {> R23}›*) { fix s and t assume H: "(s, t) ∈ R23_msgs" "(s, t) ∈ R23_keys" "(s, t) ∈ R23_pres" "t ∈ m3_inv3_sesK_compr" "t ∈ m3_inv2_ticket" "t ∈ m3_inv1_lkeysec" "runs t Ra = Some (Init, [A, B], [])" "Crypt (shrK A) ⦃Key Kab, Agent B, Number Ts, X⦄ ∈ analz (IK t)" (*‹(s::m2_state, t::m3_state) ∈ R23_msgs› ‹(s::m2_state, t::m3_state) ∈ R23_keys› ‹(s::m2_state, t::m3_state) ∈ R23_pres› ‹(t::m3_state) ∈ m3_inv3_sesK_compr› ‹(t::m3_state) ∈ m3_inv2_ticket› ‹(t::m3_state) ∈ m3_inv1_lkeysec› ‹runs (t::m3_state) (Ra::fid_t) = Some (Init, [A::agent, B::agent], [])› ‹Crypt (shrK (A::agent)) ⦃Key (Kab::key), msg.Agent (B::agent), Number (Ts::nat), X::msg⦄ ∈ analz (IK (t::m3_state))›*) let ?s' = "s⦇ runs := (runs s)(Ra ↦ (Init, [A, B], [aKey Kab, aNum Ts])) ⦈" and ?t' = "t⦇ runs := (runs t)(Ra ↦ (Init, [A, B], [aKey Kab, aNum Ts])), IK := insert X (IK t) ⦈" from H (*‹(s, t) ∈ R23_msgs› ‹(s, t) ∈ R23_keys› ‹(s, t) ∈ R23_pres› ‹t ∈ m3_inv3_sesK_compr› ‹t ∈ m3_inv2_ticket› ‹t ∈ m3_inv1_lkeysec› ‹runs t Ra = Some (Init, [A, B], [])› ‹Crypt (shrK A) ⦃Key Kab, msg.Agent B, Number Ts, X⦄ ∈ analz (IK t)›*) have "Secure Sv A (Msg [aAgt B, aKey Kab, aNum Ts]) ∈ chan s" by auto moreover have "X ∈ parts (IK t)" using H (*‹(s, t) ∈ R23_msgs› ‹(s, t) ∈ R23_keys› ‹(s, t) ∈ R23_pres› ‹t ∈ m3_inv3_sesK_compr› ‹t ∈ m3_inv2_ticket› ‹t ∈ m3_inv1_lkeysec› ‹runs (t::m3_state) (Ra::fid_t) = Some (Init, [A::agent, B::agent], [])› ‹Crypt (shrK A) ⦃Key Kab, msg.Agent B, Number Ts, X⦄ ∈ analz (IK t)›*) by (auto dest!: Body (*‹Crypt ?K ?X ∈ parts ?H ⟹ ?X ∈ parts ?H›*) MPair_parts (*‹⟦⦃?X, ?Y⦄ ∈ parts ?H; ⟦?X ∈ parts ?H; ?Y ∈ parts ?H⟧ ⟹ ?P⟧ ⟹ ?P›*)) hence "(?s', ?t') ∈ R23_msgs" using H (*‹(s, t) ∈ R23_msgs› ‹(s, t) ∈ R23_keys› ‹(s::m2_state, t::m3_state) ∈ R23_pres› ‹t ∈ m3_inv3_sesK_compr› ‹t ∈ m3_inv2_ticket› ‹(t::m3_state) ∈ m3_inv1_lkeysec› ‹runs t Ra = Some (Init, [A, B], [])› ‹Crypt (shrK A) ⦃Key Kab, msg.Agent B, Number Ts, X⦄ ∈ analz (IK t)›*) apply (auto intro!: R23_intros (*‹abs_msg (parts (IK (?t::m3_state))) ⊆ chan (?s::m2_state) ⟹ (?s, ?t) ∈ R23_msgs› ‹(⋀(KK::key set) K::key. ⟦KK ⊆ range sesK; Key K ∈ analz (Key ` KK ∪ IK (?t::m3_state))⟧ ⟹ aKey K ∈ extr (aKey ` KK ∪ ik0) (chan (?s::m2_state))) ⟹ (?s, ?t) ∈ R23_keys› ‹runs (?s::m2_state) = runs (?t::m3_state) ∧ clk ?s = clk ?t ∧ leak ?s = leak ?t ⟹ (?s, ?t) ∈ R23_pres›*)) (*goals: 1. ‹⋀Aa Ba. ⟦X ∈ parts (IK t); (s, t) ∈ R23_msgs; (s, t) ∈ R23_keys; (s, t) ∈ R23_pres; t ∈ m3_inv3_sesK_compr; t ∈ m3_inv2_ticket; t ∈ m3_inv1_lkeysec; runs t Ra = Some (Init, [A, B], []); Crypt (shrK A) ⦃Key Kab, msg.Agent B, Number Ts, X⦄ ∈ analz (IK t); ⦃msg.Agent Aa, msg.Agent Ba⦄ ∈ parts (IK t)⟧ ⟹ Insec Aa Ba (Msg []) ∈ chan s› 2. ‹⋀C K Ba T Xa. ⟦X ∈ parts (IK t); (s, t) ∈ R23_msgs; (s, t) ∈ R23_keys; (s, t) ∈ R23_pres; t ∈ m3_inv3_sesK_compr; t ∈ m3_inv2_ticket; t ∈ m3_inv1_lkeysec; runs t Ra = Some (Init, [A, B], []); Crypt (shrK A) ⦃Key Kab, msg.Agent B, Number Ts, X⦄ ∈ analz (IK t); Crypt (shrK C) ⦃Key K, msg.Agent Ba, Number T, Xa⦄ ∈ parts (IK t)⟧ ⟹ StatCh secure Sv C (Msg [aAgt Ba, aKey K, aNum T]) ∈ chan s› 3. ‹⋀C K Aa T. ⟦X ∈ parts (IK t); (s, t) ∈ R23_msgs; (s, t) ∈ R23_keys; (s, t) ∈ R23_pres; t ∈ m3_inv3_sesK_compr; t ∈ m3_inv2_ticket; t ∈ m3_inv1_lkeysec; runs t Ra = Some (Init, [A, B], []); Crypt (shrK A) ⦃Key Kab, msg.Agent B, Number Ts, X⦄ ∈ analz (IK t); Crypt (shrK C) ⦃Key K, msg.Agent Aa, Number T⦄ ∈ parts (IK t)⟧ ⟹ StatCh secure Sv C (Msg [aKey K, aAgt Aa, aNum T]) ∈ chan s› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*proven 3 subgoals*) . moreover have "(?s', ?t') ∈ R23_keys" proof (cases) (*goals: 1. ‹?P::bool ⟹ (s⦇runs := (runs (s::m2_state))(Ra::fid_t ↦ (Init, [A::agent, B::agent], [aKey (Kab::key), aNum (Ts::nat)]))⦈, t⦇runs := (runs t)(Ra ↦ (Init, [A, B], [aKey Kab, aNum Ts])), IK := insert (X::msg) (IK (t::m3_state))⦈) ∈ R23_keys› 2. ‹¬ (?P::bool) ⟹ (s⦇runs := (runs (s::m2_state))(Ra::fid_t ↦ (Init, [A::agent, B::agent], [aKey (Kab::key), aNum (Ts::nat)]))⦈, t⦇runs := (runs t)(Ra ↦ (Init, [A, B], [aKey Kab, aNum Ts])), IK := insert (X::msg) (IK (t::m3_state))⦈) ∈ R23_keys›*) assume "A ∈ bad" (*‹(A::agent) ∈ bad›*) show "?thesis" (*goal: ‹(s⦇runs := (runs (s::m2_state))(Ra::fid_t ↦ (Init, [A::agent, B::agent], [aKey (Kab::key), aNum (Ts::nat)]))⦈, t⦇runs := (runs t)(Ra ↦ (Init, [A, B], [aKey Kab, aNum Ts])), IK := insert (X::msg) (IK (t::m3_state))⦈) ∈ R23_keys›*) proof (-) (*goal: ‹(s⦇runs := (runs s)(Ra ↦ (Init, [A, B], [aKey Kab, aNum Ts]))⦈, t⦇runs := (runs t)(Ra ↦ (Init, [A, B], [aKey Kab, aNum Ts])), IK := insert X (IK t)⦈) ∈ R23_keys›*) note H (*‹(s, t) ∈ R23_msgs› ‹(s, t) ∈ R23_keys› ‹(s, t) ∈ R23_pres› ‹t ∈ m3_inv3_sesK_compr› ‹t ∈ m3_inv2_ticket› ‹t ∈ m3_inv1_lkeysec› ‹runs (t::m3_state) (Ra::fid_t) = Some (Init, [A::agent, B::agent], [])› ‹Crypt (shrK (A::agent)) ⦃Key (Kab::key), msg.Agent (B::agent), Number (Ts::nat), X::msg⦄ ∈ analz (IK (t::m3_state))›*) moreover hence "X ∈ analz (IK t)" using ‹A ∈ bad› (*‹A ∈ bad›*) apply - (*goal: ‹X ∈ analz (IK t)›*) apply (drule Decrypt (*‹⟦Crypt ?K ?X ∈ analz ?H; Key (invKey ?K) ∈ analz ?H⟧ ⟹ ?X ∈ analz ?H›*)) (*goals: 1. ‹⟦(s, t) ∈ R23_msgs; (s, t) ∈ R23_keys; (s, t) ∈ R23_pres; t ∈ m3_inv3_sesK_compr; t ∈ m3_inv2_ticket; t ∈ m3_inv1_lkeysec; runs t Ra = Some (Init, [A, B], []); A ∈ bad⟧ ⟹ Key (invKey (shrK A)) ∈ analz (IK t)› 2. ‹⟦(s, t) ∈ R23_msgs; (s, t) ∈ R23_keys; (s, t) ∈ R23_pres; t ∈ m3_inv3_sesK_compr; t ∈ m3_inv2_ticket; t ∈ m3_inv1_lkeysec; runs t Ra = Some (Init, [A, B], []); A ∈ bad; ⦃Key Kab, msg.Agent B, Number Ts, X⦄ ∈ analz (IK t)⟧ ⟹ X ∈ analz (IK t)› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . ultimately show "?thesis" (*goal: ‹(s⦇runs := (runs s)(Ra ↦ (Init, [A, B], [aKey Kab, aNum Ts]))⦈, t⦇runs := (runs t)(Ra ↦ (Init, [A, B], [aKey Kab, aNum Ts])), IK := insert X (IK t)⦈) ∈ R23_keys›*) apply - (*goal: ‹(s⦇runs := (runs (s::m2_state))(Ra::fid_t ↦ (Init, [A::agent, B::agent], [aKey (Kab::key), aNum (Ts::nat)]))⦈, t⦇runs := (runs t)(Ra ↦ (Init, [A, B], [aKey Kab, aNum Ts])), IK := insert (X::msg) (IK (t::m3_state))⦈) ∈ R23_keys›*) apply (rule R23_intros (*‹abs_msg (parts (IK ?t)) ⊆ chan ?s ⟹ (?s, ?t) ∈ R23_msgs› ‹(⋀KK K. ⟦KK ⊆ range sesK; Key K ∈ analz (Key ` KK ∪ IK ?t)⟧ ⟹ aKey K ∈ extr (aKey ` KK ∪ ik0) (chan ?s)) ⟹ (?s, ?t) ∈ R23_keys› ‹runs ?s = runs ?t ∧ clk ?s = clk ?t ∧ leak ?s = leak ?t ⟹ (?s, ?t) ∈ R23_pres›*)) (*goal: ‹⟦(s, t) ∈ R23_msgs; (s, t) ∈ R23_keys; (s, t) ∈ R23_pres; t ∈ m3_inv3_sesK_compr; t ∈ m3_inv2_ticket; t ∈ m3_inv1_lkeysec; runs t Ra = Some (Init, [A, B], []); Crypt (shrK A) ⦃Key Kab, msg.Agent B, Number Ts, X⦄ ∈ analz (IK t); X ∈ analz (IK t)⟧ ⟹ (s⦇runs := (runs s)(Ra ↦ (Init, [A, B], [aKey Kab, aNum Ts]))⦈, t⦇runs := (runs t)(Ra ↦ (Init, [A, B], [aKey Kab, aNum Ts])), IK := insert X (IK t)⦈) ∈ R23_keys›*) by (auto dest!: analz_cut (*‹⟦(?Y::msg) ∈ analz (insert (?X::msg) (?H::msg set)); ?X ∈ analz ?H⟧ ⟹ ?Y ∈ analz ?H›*) intro: analz_monotonic (*‹⟦(?c::msg) ∈ analz (?G::msg set); ?G ⊆ (?H::msg set)⟧ ⟹ ?c ∈ analz ?H›*)) qed next (*goal: ‹(A::agent) ∉ bad ⟹ (s⦇runs := (runs (s::m2_state))(Ra::fid_t ↦ (Init, [A, B::agent], [aKey (Kab::key), aNum (Ts::nat)]))⦈, t⦇runs := (runs t)(Ra ↦ (Init, [A, B], [aKey Kab, aNum Ts])), IK := insert (X::msg) (IK (t::m3_state))⦈) ∈ R23_keys›*) assume "A ∉ bad" (*‹(A::agent) ∉ bad›*) show "?thesis" (*goal: ‹(s⦇runs := (runs s)(Ra ↦ (Init, [A, B], [aKey Kab, aNum Ts]))⦈, t⦇runs := (runs t)(Ra ↦ (Init, [A, B], [aKey Kab, aNum Ts])), IK := insert X (IK t)⦈) ∈ R23_keys›*) proof (-) (*goal: ‹(s⦇runs := (runs s)(Ra ↦ (Init, [A, B], [aKey Kab, aNum Ts]))⦈, t⦇runs := (runs t)(Ra ↦ (Init, [A, B], [aKey Kab, aNum Ts])), IK := insert X (IK t)⦈) ∈ R23_keys›*) note H (*‹(s, t) ∈ R23_msgs› ‹(s, t) ∈ R23_keys› ‹(s, t) ∈ R23_pres› ‹t ∈ m3_inv3_sesK_compr› ‹t ∈ m3_inv2_ticket› ‹t ∈ m3_inv1_lkeysec› ‹runs t Ra = Some (Init, [A, B], [])› ‹Crypt (shrK A) ⦃Key Kab, msg.Agent B, Number Ts, X⦄ ∈ analz (IK t)›*) moreover with ‹A ∉ bad› (*‹A ∉ bad›*) have "X = Crypt (shrK B) ⦃Key Kab, Agent A, Number Ts ⦄ ∧ Kab ∈ range sesK" by (auto dest!: m3_inv2_ticketD (*‹⟦Crypt (shrK ?A) ⦃Key ?K, msg.Agent ?B, Number ?T, ?X⦄ ∈ parts (IK ?x); ?x ∈ m3_inv2_ticket; ?A ∉ bad⟧ ⟹ ?X = Crypt (shrK ?B) ⦃Key ?K, msg.Agent ?A, Number ?T⦄ ∧ ?K ∈ range sesK›*)) moreover { assume H1: "Key (shrK B) ∈ analz (IK t)" (*‹Key (shrK (B::agent)) ∈ analz (IK (t::m3_state))›*) have "aKey Kab ∈ extr ik0 (chan s)" proof (-) (*goal: ‹aKey Kab ∈ extr ik0 (chan s)›*) note calculation (*‹(s, t) ∈ R23_msgs› ‹(s, t) ∈ R23_keys› ‹(s, t) ∈ R23_pres› ‹t ∈ m3_inv3_sesK_compr› ‹t ∈ m3_inv2_ticket› ‹t ∈ m3_inv1_lkeysec› ‹runs t Ra = Some (Init, [A, B], [])› ‹Crypt (shrK A) ⦃Key Kab, msg.Agent B, Number Ts, X⦄ ∈ analz (IK t)› ‹X = Crypt (shrK B) ⦃Key Kab, msg.Agent A, Number Ts⦄ ∧ Kab ∈ range sesK›*) moreover hence "Secure Sv B (Msg [aKey Kab, aAgt A, aNum Ts]) ∈ chan s" apply - (*goal: ‹StatCh secure Sv B (Msg [aKey Kab, aAgt A, aNum Ts]) ∈ chan s›*) apply (drule analz_into_parts (*‹?c ∈ analz ?H ⟹ ?c ∈ parts ?H›*)) (*goal: ‹⟦(s, t) ∈ R23_msgs; (s, t) ∈ R23_keys; (s, t) ∈ R23_pres; t ∈ m3_inv3_sesK_compr; t ∈ m3_inv2_ticket; t ∈ m3_inv1_lkeysec; runs t Ra = Some (Init, [A, B], []); Crypt (shrK A) ⦃Key Kab, msg.Agent B, Number Ts, X⦄ ∈ analz (IK t); X = Crypt (shrK B) ⦃Key Kab, msg.Agent A, Number Ts⦄ ∧ Kab ∈ range sesK⟧ ⟹ StatCh secure Sv B (Msg [aKey Kab, aAgt A, aNum Ts]) ∈ chan s›*) apply (drule Body (*‹Crypt (?K::key) (?X::msg) ∈ parts (?H::msg set) ⟹ ?X ∈ parts ?H›*)) (*goal: ‹⟦(s::m2_state, t::m3_state) ∈ R23_msgs; (s, t) ∈ R23_keys; (s, t) ∈ R23_pres; t ∈ m3_inv3_sesK_compr; t ∈ m3_inv2_ticket; t ∈ m3_inv1_lkeysec; runs t (Ra::fid_t) = Some (Init, [A::agent, B::agent], []); (X::msg) = Crypt (shrK B) ⦃Key (Kab::key), msg.Agent A, Number (Ts::nat)⦄ ∧ Kab ∈ range sesK; Crypt (shrK A) ⦃Key Kab, msg.Agent B, Number Ts, X⦄ ∈ parts (IK t)⟧ ⟹ StatCh secure Sv B (Msg [aKey Kab, aAgt A, aNum Ts]) ∈ chan s›*) apply (elim MPair_parts (*‹⟦⦃?X, ?Y⦄ ∈ parts ?H; ⟦?X ∈ parts ?H; ?Y ∈ parts ?H⟧ ⟹ ?P⟧ ⟹ ?P›*)) (*goal: ‹⟦(s, t) ∈ R23_msgs; (s, t) ∈ R23_keys; (s, t) ∈ R23_pres; t ∈ m3_inv3_sesK_compr; t ∈ m3_inv2_ticket; t ∈ m3_inv1_lkeysec; runs t Ra = Some (Init, [A, B], []); X = Crypt (shrK B) ⦃Key Kab, msg.Agent A, Number Ts⦄ ∧ Kab ∈ range sesK; ⦃Key Kab, msg.Agent B, Number Ts, X⦄ ∈ parts (IK t)⟧ ⟹ StatCh secure Sv B (Msg [aKey Kab, aAgt A, aNum Ts]) ∈ chan s›*) by auto ultimately show "?thesis" (*goal: ‹aKey Kab ∈ extr ik0 (chan s)›*) using H1 (*‹Key (shrK B) ∈ analz (IK t)›*) by auto qed } ultimately show "?thesis" (*goal: ‹(s⦇runs := (runs s)(Ra ↦ (Init, [A, B], [aKey Kab, aNum Ts]))⦈, t⦇runs := (runs t)(Ra ↦ (Init, [A, B], [aKey Kab, aNum Ts])), IK := insert X (IK t)⦈) ∈ R23_keys›*) apply - (*goal: ‹(s⦇runs := (runs s)(Ra ↦ (Init, [A, B], [aKey Kab, aNum Ts]))⦈, t⦇runs := (runs t)(Ra ↦ (Init, [A, B], [aKey Kab, aNum Ts])), IK := insert X (IK t)⦈) ∈ R23_keys›*) apply (rule R23_intros (*‹abs_msg (parts (IK ?t)) ⊆ chan ?s ⟹ (?s, ?t) ∈ R23_msgs› ‹(⋀KK K. ⟦KK ⊆ range sesK; Key K ∈ analz (Key ` KK ∪ IK ?t)⟧ ⟹ aKey K ∈ extr (aKey ` KK ∪ ik0) (chan ?s)) ⟹ (?s, ?t) ∈ R23_keys› ‹runs ?s = runs ?t ∧ clk ?s = clk ?t ∧ leak ?s = leak ?t ⟹ (?s, ?t) ∈ R23_pres›*)) (*goal: ‹⟦(s, t) ∈ R23_msgs; (s, t) ∈ R23_keys; (s, t) ∈ R23_pres; t ∈ m3_inv3_sesK_compr; t ∈ m3_inv2_ticket; t ∈ m3_inv1_lkeysec; runs t Ra = Some (Init, [A, B], []); Crypt (shrK A) ⦃Key Kab, msg.Agent B, Number Ts, X⦄ ∈ analz (IK t); X = Crypt (shrK B) ⦃Key Kab, msg.Agent A, Number Ts⦄ ∧ Kab ∈ range sesK; Key (shrK B) ∈ analz (IK t) ⟹ aKey Kab ∈ extr ik0 (chan s)⟧ ⟹ (s⦇runs := (runs s)(Ra ↦ (Init, [A, B], [aKey Kab, aNum Ts]))⦈, t⦇runs := (runs t)(Ra ↦ (Init, [A, B], [aKey Kab, aNum Ts])), IK := insert X (IK t)⦈) ∈ R23_keys›*) by (auto simp add: m3_inv3_sesK_compr_simps (*‹⟦?x ∈ m3_inv3_sesK_compr; ?KK ⊆ range sesK⟧ ⟹ (Key ?K ∈ analz (Key ` ?KK ∪ IK ?x)) = (?K ∈ ?KK ∨ Key ?K ∈ analz (IK ?x))› ‹⟦?x ∈ m3_inv3_sesK_compr; ?Kab ∈ range sesK⟧ ⟹ (Key ?K ∈ analz (insert (Key ?Kab) (IK ?x))) = (?K = ?Kab ∨ Key ?K ∈ analz (IK ?x))› ‹⟦?x ∈ m3_inv3_sesK_compr; ?Kab ∈ range sesK ∧ ?KK ⊆ range sesK⟧ ⟹ (Key ?K ∈ analz (insert (Key ?Kab) (Key ` ?KK ∪ IK ?x))) = (?K = ?Kab ∨ ?K ∈ ?KK ∨ Key ?K ∈ analz (IK ?x))› ‹insert (Key ?K) (insert ?y ?A) = insert ?y (insert (Key ?K) ?A)›*)) qed qed moreover have "(?s', ?t') ∈ R23_pres" using H (*‹(s::m2_state, t::m3_state) ∈ R23_msgs› ‹(s, t) ∈ R23_keys› ‹(s, t) ∈ R23_pres› ‹t ∈ m3_inv3_sesK_compr› ‹t ∈ m3_inv2_ticket› ‹(t::m3_state) ∈ m3_inv1_lkeysec› ‹runs (t::m3_state) (Ra::fid_t) = Some (Init, [A::agent, B::agent], [])› ‹Crypt (shrK A) ⦃Key Kab, msg.Agent B, Number Ts, X⦄ ∈ analz (IK t)›*) by (auto intro!: R23_intros (*‹abs_msg (parts (IK ?t)) ⊆ chan ?s ⟹ (?s, ?t) ∈ R23_msgs› ‹(⋀KK K. ⟦KK ⊆ range sesK; Key K ∈ analz (Key ` KK ∪ IK ?t)⟧ ⟹ aKey K ∈ extr (aKey ` KK ∪ ik0) (chan ?s)) ⟹ (?s, ?t) ∈ R23_keys› ‹runs ?s = runs ?t ∧ clk ?s = clk ?t ∧ leak ?s = leak ?t ⟹ (?s, ?t) ∈ R23_pres›*)) moreover note calculation (*‹StatCh secure Sv A (Msg [aAgt B, aKey Kab, aNum Ts]) ∈ chan s› ‹(s⦇runs := (runs (s::m2_state))(Ra::fid_t ↦ (Init, [A::agent, B::agent], [aKey (Kab::key), aNum (Ts::nat)]))⦈, t⦇runs := (runs t)(Ra ↦ (Init, [A, B], [aKey Kab, aNum Ts])), IK := insert (X::msg) (IK (t::m3_state))⦈) ∈ R23_msgs› ‹(s⦇runs := (runs s)(Ra ↦ (Init, [A, B], [aKey Kab, aNum Ts]))⦈, t⦇runs := (runs t)(Ra ↦ (Init, [A, B], [aKey Kab, aNum Ts])), IK := insert X (IK t)⦈) ∈ R23_keys› ‹(s⦇runs := (runs s)(Ra ↦ (Init, [A, B], [aKey Kab, aNum Ts]))⦈, t⦇runs := (runs t)(Ra ↦ (Init, [A, B], [aKey Kab, aNum Ts])), IK := insert X (IK t)⦈) ∈ R23_pres›*) } thus "?thesis" (*goal: ‹{R23 ∩ UNIV × (m3_inv3_sesK_compr ∩ m3_inv2_ticket ∩ m3_inv1_lkeysec)} m2_step4 Ra A B Kab Ts, m3_step4 Ra A B Kab Ts X {> R23}›*) by (auto simp add: PO_rhoare_defs (*‹{?pre} ?Ra, ?Rc {> ?post} ≡ ?pre O ?Rc ⊆ ?Ra O ?post› ‹?r O ?s = {(x, z). ∃y. (x, y) ∈ ?r ∧ (y, z) ∈ ?s}›*) R23_def (*‹R23 ≡ R23_msgs ∩ R23_keys ∩ R23_pres›*) m3_defs (*‹m3 ≡ ⦇init = m3_init, trans = m3_trans, obs = m3_obs⦈› ‹m3_init ≡ {⦇runs = λx. None, leak = shrK ` bad, clk = 0, IK = Key ` shrK ` bad⦈}› ‹m3_trans ≡ ⋃A B Ra Rb Rs Kab Ts T X. (m3_step1 Ra A B ∪ m3_step2 Rb A B ∪ m3_step3 Rs A B Kab Ts ∪ m3_step4 Ra A B Kab Ts X ∪ m3_step5 Rb A B Kab Ts ∪ m3_tick T ∪ m3_leak Rs ∪ m3_DY_fake)⁼› ‹m3_obs ?s ≡ ⦇runs = runs ?s, leak = leak ?s, clk = clk ?s⦈› ‹m3_step1 ?Ra ?A ?B ≡ {(s, s1). ?Ra ∉ dom (runs s) ∧ s1 = s⦇runs := (runs s)(?Ra ↦ (Init, [?A, ?B], [])), IK := insert ⦃msg.Agent ?A, msg.Agent ?B⦄ (IK s)⦈}› ‹m3_step2 ≡ m1_step2› ‹m3_step3 ?Rs ?A ?B ?Kab ?Ts ≡ {(s, s1). ?Rs ∉ dom (runs s) ∧ ?Kab = sesK (?Rs $ sk) ∧ ⦃msg.Agent ?A, msg.Agent ?B⦄ ∈ IK s ∧ ?Ts = clk s ∧ s1 = s⦇runs := (runs s)(?Rs ↦ (Serv, [?A, ?B], [aNum ?Ts])), IK := insert (Crypt (shrK ?A) ⦃Key ?Kab, msg.Agent ?B, Number ?Ts, Crypt (shrK ?B) ⦃Key ?Kab, msg.Agent ?A, Number ?Ts⦄⦄) (IK s)⦈}› ‹m3_step4 ?Ra ?A ?B ?Kab ?Ts ?X ≡ {(s, s1). runs s ?Ra = Some (Init, [?A, ?B], []) ∧ Crypt (shrK ?A) ⦃Key ?Kab, msg.Agent ?B, Number ?Ts, ?X⦄ ∈ IK s ∧ clk s < ?Ts + Ls ∧ s1 = s⦇runs := (runs s)(?Ra ↦ (Init, [?A, ?B], [aKey ?Kab, aNum ?Ts])), IK := insert ?X (IK s)⦈}› ‹m3_step5 ?Rb ?A ?B ?Kab ?Ts ≡ {(s, s1). runs s ?Rb = Some (Resp, [?A, ?B], []) ∧ Crypt (shrK ?B) ⦃Key ?Kab, msg.Agent ?A, Number ?Ts⦄ ∈ IK s ∧ clk s < ?Ts + Ls ∧ s1 = s⦇runs := (runs s)(?Rb ↦ (Resp, [?A, ?B], [aKey ?Kab, aNum ?Ts]))⦈}› ‹m3_tick ≡ m1_tick› ‹m3_leak ?Rs ≡ {(s, s1). ?Rs ∈ dom (runs s) ∧ fst (the (runs s ?Rs)) = Serv ∧ s1 = s⦇leak := insert (sesK (?Rs $ sk)) (leak s), IK := insert (Key (sesK (?Rs $ sk))) (IK s)⦈}› ‹m3_DY_fake ≡ {(s, s1). s1 = s⦇IK := synth (analz (IK s))⦈}› and more 40 facts*) dest!: analz_Inj_IK (*‹?X ∈ IK ?s ⟹ ?X ∈ analz (IK ?s)›*)) qed lemma PO_m3_step5_refines_m2_step5: "{R23} (m2_step5 Rb A B Kab Ts), (m3_step5 Rb A B Kab Ts) {> R23}" apply (auto simp add: PO_rhoare_defs (*‹{?pre} ?Ra, ?Rc {> ?post} ≡ ?pre O ?Rc ⊆ ?Ra O ?post› ‹?r O ?s = {(x, z). ∃y. (x, y) ∈ ?r ∧ (y, z) ∈ ?s}›*) R23_def (*‹R23 ≡ R23_msgs ∩ R23_keys ∩ R23_pres›*) m3_defs (*‹m3 ≡ ⦇init = m3_init, trans = m3_trans, obs = m3_obs⦈› ‹m3_init ≡ {⦇runs = λx. None, leak = shrK ` bad, clk = 0, IK = Key ` shrK ` bad⦈}› ‹m3_trans ≡ ⋃A B Ra Rb Rs Kab Ts T X. (m3_step1 Ra A B ∪ m3_step2 Rb A B ∪ m3_step3 Rs A B Kab Ts ∪ m3_step4 Ra A B Kab Ts X ∪ m3_step5 Rb A B Kab Ts ∪ m3_tick T ∪ m3_leak Rs ∪ m3_DY_fake)⁼› ‹m3_obs ?s ≡ ⦇runs = runs ?s, leak = leak ?s, clk = clk ?s⦈› ‹m3_step1 ?Ra ?A ?B ≡ {(s, s1). ?Ra ∉ dom (runs s) ∧ s1 = s⦇runs := (runs s)(?Ra ↦ (Init, [?A, ?B], [])), IK := insert ⦃msg.Agent ?A, msg.Agent ?B⦄ (IK s)⦈}› ‹m3_step2 ≡ m1_step2› ‹m3_step3 ?Rs ?A ?B ?Kab ?Ts ≡ {(s, s1). ?Rs ∉ dom (runs s) ∧ ?Kab = sesK (?Rs $ sk) ∧ ⦃msg.Agent ?A, msg.Agent ?B⦄ ∈ IK s ∧ ?Ts = clk s ∧ s1 = s⦇runs := (runs s)(?Rs ↦ (Serv, [?A, ?B], [aNum ?Ts])), IK := insert (Crypt (shrK ?A) ⦃Key ?Kab, msg.Agent ?B, Number ?Ts, Crypt (shrK ?B) ⦃Key ?Kab, msg.Agent ?A, Number ?Ts⦄⦄) (IK s)⦈}› ‹m3_step4 ?Ra ?A ?B ?Kab ?Ts ?X ≡ {(s, s1). runs s ?Ra = Some (Init, [?A, ?B], []) ∧ Crypt (shrK ?A) ⦃Key ?Kab, msg.Agent ?B, Number ?Ts, ?X⦄ ∈ IK s ∧ clk s < ?Ts + Ls ∧ s1 = s⦇runs := (runs s)(?Ra ↦ (Init, [?A, ?B], [aKey ?Kab, aNum ?Ts])), IK := insert ?X (IK s)⦈}› ‹m3_step5 ?Rb ?A ?B ?Kab ?Ts ≡ {(s, s1). runs s ?Rb = Some (Resp, [?A, ?B], []) ∧ Crypt (shrK ?B) ⦃Key ?Kab, msg.Agent ?A, Number ?Ts⦄ ∈ IK s ∧ clk s < ?Ts + Ls ∧ s1 = s⦇runs := (runs s)(?Rb ↦ (Resp, [?A, ?B], [aKey ?Kab, aNum ?Ts]))⦈}› ‹m3_tick ≡ m1_tick› ‹m3_leak ?Rs ≡ {(s, s1). ?Rs ∈ dom (runs s) ∧ fst (the (runs s ?Rs)) = Serv ∧ s1 = s⦇leak := insert (sesK (?Rs $ sk)) (leak s), IK := insert (Key (sesK (?Rs $ sk))) (IK s)⦈}› ‹m3_DY_fake ≡ {(s, s1). s1 = s⦇IK := synth (analz (IK s))⦈}› and more 40 facts*) intro!: R23_intros (*‹abs_msg (parts (IK ?t)) ⊆ chan ?s ⟹ (?s, ?t) ∈ R23_msgs› ‹(⋀KK K. ⟦KK ⊆ range sesK; Key K ∈ analz (Key ` KK ∪ IK ?t)⟧ ⟹ aKey K ∈ extr (aKey ` KK ∪ ik0) (chan ?s)) ⟹ (?s, ?t) ∈ R23_keys› ‹runs ?s = runs ?t ∧ clk ?s = clk ?t ∧ leak ?s = leak ?t ⟹ (?s, ?t) ∈ R23_pres›*)) (*goals: 1. ‹⋀a y Aa Ba. ⟦(a, y) ∈ R23_msgs; (a, y) ∈ R23_keys; (a, y) ∈ R23_pres; runs y Rb = Some (Resp, [A, B], []); Crypt (shrK B) ⦃Key Kab, msg.Agent A, Number Ts⦄ ∈ parts (IK y); clk y < Ts + Ls; ⦃msg.Agent Aa, msg.Agent Ba⦄ ∈ parts (IK y)⟧ ⟹ Insec Aa Ba (Msg []) ∈ chan a› 2. ‹⋀a y C K Ba T X. ⟦(a, y) ∈ R23_msgs; (a, y) ∈ R23_keys; (a, y) ∈ R23_pres; runs y Rb = Some (Resp, [A, B], []); Crypt (shrK B) ⦃Key Kab, msg.Agent A, Number Ts⦄ ∈ parts (IK y); clk y < Ts + Ls; Crypt (shrK C) ⦃Key K, msg.Agent Ba, Number T, X⦄ ∈ parts (IK y)⟧ ⟹ StatCh secure Sv C (Msg [aAgt Ba, aKey K, aNum T]) ∈ chan a› 3. ‹⋀a y C K Aa T. ⟦(a, y) ∈ R23_msgs; (a, y) ∈ R23_keys; (a, y) ∈ R23_pres; runs y Rb = Some (Resp, [A, B], []); Crypt (shrK B) ⦃Key Kab, msg.Agent A, Number Ts⦄ ∈ parts (IK y); clk y < Ts + Ls; Crypt (shrK C) ⦃Key K, msg.Agent Aa, Number T⦄ ∈ parts (IK y)⟧ ⟹ StatCh secure Sv C (Msg [aKey K, aAgt Aa, aNum T]) ∈ chan a› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*proven 3 subgoals*) . lemma PO_m3_tick_refines_m2_tick: "{R23} (m2_tick T), (m3_tick T) {>R23}" apply (auto simp add: PO_rhoare_defs (*‹{?pre} ?Ra, ?Rc {> ?post} ≡ ?pre O ?Rc ⊆ ?Ra O ?post› ‹?r O ?s = {(x, z). ∃y. (x, y) ∈ ?r ∧ (y, z) ∈ ?s}›*) R23_def (*‹R23 ≡ R23_msgs ∩ R23_keys ∩ R23_pres›*) m3_defs (*‹m3 ≡ ⦇init = m3_init, trans = m3_trans, obs = m3_obs⦈› ‹m3_init ≡ {⦇runs = λx. None, leak = shrK ` bad, clk = 0, IK = Key ` shrK ` bad⦈}› ‹m3_trans ≡ ⋃A B Ra Rb Rs Kab Ts T X. (m3_step1 Ra A B ∪ m3_step2 Rb A B ∪ m3_step3 Rs A B Kab Ts ∪ m3_step4 Ra A B Kab Ts X ∪ m3_step5 Rb A B Kab Ts ∪ m3_tick T ∪ m3_leak Rs ∪ m3_DY_fake)⁼› ‹m3_obs ?s ≡ ⦇runs = runs ?s, leak = leak ?s, clk = clk ?s⦈› ‹m3_step1 ?Ra ?A ?B ≡ {(s, s1). ?Ra ∉ dom (runs s) ∧ s1 = s⦇runs := (runs s)(?Ra ↦ (Init, [?A, ?B], [])), IK := insert ⦃msg.Agent ?A, msg.Agent ?B⦄ (IK s)⦈}› ‹m3_step2 ≡ m1_step2› ‹m3_step3 ?Rs ?A ?B ?Kab ?Ts ≡ {(s, s1). ?Rs ∉ dom (runs s) ∧ ?Kab = sesK (?Rs $ sk) ∧ ⦃msg.Agent ?A, msg.Agent ?B⦄ ∈ IK s ∧ ?Ts = clk s ∧ s1 = s⦇runs := (runs s)(?Rs ↦ (Serv, [?A, ?B], [aNum ?Ts])), IK := insert (Crypt (shrK ?A) ⦃Key ?Kab, msg.Agent ?B, Number ?Ts, Crypt (shrK ?B) ⦃Key ?Kab, msg.Agent ?A, Number ?Ts⦄⦄) (IK s)⦈}› ‹m3_step4 ?Ra ?A ?B ?Kab ?Ts ?X ≡ {(s, s1). runs s ?Ra = Some (Init, [?A, ?B], []) ∧ Crypt (shrK ?A) ⦃Key ?Kab, msg.Agent ?B, Number ?Ts, ?X⦄ ∈ IK s ∧ clk s < ?Ts + Ls ∧ s1 = s⦇runs := (runs s)(?Ra ↦ (Init, [?A, ?B], [aKey ?Kab, aNum ?Ts])), IK := insert ?X (IK s)⦈}› ‹m3_step5 ?Rb ?A ?B ?Kab ?Ts ≡ {(s, s1). runs s ?Rb = Some (Resp, [?A, ?B], []) ∧ Crypt (shrK ?B) ⦃Key ?Kab, msg.Agent ?A, Number ?Ts⦄ ∈ IK s ∧ clk s < ?Ts + Ls ∧ s1 = s⦇runs := (runs s)(?Rb ↦ (Resp, [?A, ?B], [aKey ?Kab, aNum ?Ts]))⦈}› ‹m3_tick ≡ m1_tick› ‹m3_leak ?Rs ≡ {(s, s1). ?Rs ∈ dom (runs s) ∧ fst (the (runs s ?Rs)) = Serv ∧ s1 = s⦇leak := insert (sesK (?Rs $ sk)) (leak s), IK := insert (Key (sesK (?Rs $ sk))) (IK s)⦈}› ‹m3_DY_fake ≡ {(s, s1). s1 = s⦇IK := synth (analz (IK s))⦈}› and more 40 facts*) intro!: R23_intros (*‹abs_msg (parts (IK ?t)) ⊆ chan ?s ⟹ (?s, ?t) ∈ R23_msgs› ‹(⋀KK K. ⟦KK ⊆ range sesK; Key K ∈ analz (Key ` KK ∪ IK ?t)⟧ ⟹ aKey K ∈ extr (aKey ` KK ∪ ik0) (chan ?s)) ⟹ (?s, ?t) ∈ R23_keys› ‹runs ?s = runs ?t ∧ clk ?s = clk ?t ∧ leak ?s = leak ?t ⟹ (?s, ?t) ∈ R23_pres›*)) (*goals: 1. ‹⋀a y A B. ⟦(a, y) ∈ R23_msgs; (a, y) ∈ R23_keys; (a, y) ∈ R23_pres; ⦃msg.Agent A, msg.Agent B⦄ ∈ parts (IK y)⟧ ⟹ Insec A B (Msg []) ∈ chan a› 2. ‹⋀a y C K B T X. ⟦(a, y) ∈ R23_msgs; (a, y) ∈ R23_keys; (a, y) ∈ R23_pres; Crypt (shrK C) ⦃Key K, msg.Agent B, Number T, X⦄ ∈ parts (IK y)⟧ ⟹ StatCh secure Sv C (Msg [aAgt B, aKey K, aNum T]) ∈ chan a› 3. ‹⋀a y C K A T. ⟦(a, y) ∈ R23_msgs; (a, y) ∈ R23_keys; (a, y) ∈ R23_pres; Crypt (shrK C) ⦃Key K, msg.Agent A, Number T⦄ ∈ parts (IK y)⟧ ⟹ StatCh secure Sv C (Msg [aKey K, aAgt A, aNum T]) ∈ chan a› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*proven 3 subgoals*) . text ‹Intruder events.› lemma PO_m3_leak_refines_m2_leak: "{R23} (m2_leak Rs), (m3_leak Rs) {>R23}" apply (auto simp add: PO_rhoare_defs (*‹{?pre} ?Ra, ?Rc {> ?post} ≡ ?pre O ?Rc ⊆ ?Ra O ?post› ‹?r O ?s = {(x, z). ∃y. (x, y) ∈ ?r ∧ (y, z) ∈ ?s}›*) R23_def (*‹R23 ≡ R23_msgs ∩ R23_keys ∩ R23_pres›*) m3_defs (*‹m3 ≡ ⦇init = m3_init, trans = m3_trans, obs = m3_obs⦈› ‹m3_init ≡ {⦇runs = λx. None, leak = shrK ` bad, clk = 0, IK = Key ` shrK ` bad⦈}› ‹m3_trans ≡ ⋃A B Ra Rb Rs Kab Ts T X. (m3_step1 Ra A B ∪ m3_step2 Rb A B ∪ m3_step3 Rs A B Kab Ts ∪ m3_step4 Ra A B Kab Ts X ∪ m3_step5 Rb A B Kab Ts ∪ m3_tick T ∪ m3_leak Rs ∪ m3_DY_fake)⁼› ‹m3_obs ?s ≡ ⦇runs = runs ?s, leak = leak ?s, clk = clk ?s⦈› ‹m3_step1 ?Ra ?A ?B ≡ {(s, s1). ?Ra ∉ dom (runs s) ∧ s1 = s⦇runs := (runs s)(?Ra ↦ (Init, [?A, ?B], [])), IK := insert ⦃msg.Agent ?A, msg.Agent ?B⦄ (IK s)⦈}› ‹m3_step2 ≡ m1_step2› ‹m3_step3 ?Rs ?A ?B ?Kab ?Ts ≡ {(s, s1). ?Rs ∉ dom (runs s) ∧ ?Kab = sesK (?Rs $ sk) ∧ ⦃msg.Agent ?A, msg.Agent ?B⦄ ∈ IK s ∧ ?Ts = clk s ∧ s1 = s⦇runs := (runs s)(?Rs ↦ (Serv, [?A, ?B], [aNum ?Ts])), IK := insert (Crypt (shrK ?A) ⦃Key ?Kab, msg.Agent ?B, Number ?Ts, Crypt (shrK ?B) ⦃Key ?Kab, msg.Agent ?A, Number ?Ts⦄⦄) (IK s)⦈}› ‹m3_step4 ?Ra ?A ?B ?Kab ?Ts ?X ≡ {(s, s1). runs s ?Ra = Some (Init, [?A, ?B], []) ∧ Crypt (shrK ?A) ⦃Key ?Kab, msg.Agent ?B, Number ?Ts, ?X⦄ ∈ IK s ∧ clk s < ?Ts + Ls ∧ s1 = s⦇runs := (runs s)(?Ra ↦ (Init, [?A, ?B], [aKey ?Kab, aNum ?Ts])), IK := insert ?X (IK s)⦈}› ‹m3_step5 ?Rb ?A ?B ?Kab ?Ts ≡ {(s, s1). runs s ?Rb = Some (Resp, [?A, ?B], []) ∧ Crypt (shrK ?B) ⦃Key ?Kab, msg.Agent ?A, Number ?Ts⦄ ∈ IK s ∧ clk s < ?Ts + Ls ∧ s1 = s⦇runs := (runs s)(?Rb ↦ (Resp, [?A, ?B], [aKey ?Kab, aNum ?Ts]))⦈}› ‹m3_tick ≡ m1_tick› ‹m3_leak ?Rs ≡ {(s, s1). ?Rs ∈ dom (runs s) ∧ fst (the (runs s ?Rs)) = Serv ∧ s1 = s⦇leak := insert (sesK (?Rs $ sk)) (leak s), IK := insert (Key (sesK (?Rs $ sk))) (IK s)⦈}› ‹m3_DY_fake ≡ {(s, s1). s1 = s⦇IK := synth (analz (IK s))⦈}› and more 40 facts*) intro!: R23_intros (*‹abs_msg (parts (IK ?t)) ⊆ chan ?s ⟹ (?s, ?t) ∈ R23_msgs› ‹(⋀KK K. ⟦KK ⊆ range sesK; Key K ∈ analz (Key ` KK ∪ IK ?t)⟧ ⟹ aKey K ∈ extr (aKey ` KK ∪ ik0) (chan ?s)) ⟹ (?s, ?t) ∈ R23_keys› ‹runs ?s = runs ?t ∧ clk ?s = clk ?t ∧ leak ?s = leak ?t ⟹ (?s, ?t) ∈ R23_pres›*)) (*goals: 1. ‹⋀a y A B. ⟦(a, y) ∈ R23_msgs; (a, y) ∈ R23_keys; (a, y) ∈ R23_pres; Rs ∈ dom (runs y); fst (the (runs y Rs)) = Serv; ⦃msg.Agent A, msg.Agent B⦄ ∈ parts (IK y)⟧ ⟹ Insec A B (Msg []) ∈ chan a› 2. ‹⋀a y C K B T X. ⟦(a, y) ∈ R23_msgs; (a, y) ∈ R23_keys; (a, y) ∈ R23_pres; Rs ∈ dom (runs y); fst (the (runs y Rs)) = Serv; Crypt (shrK C) ⦃Key K, msg.Agent B, Number T, X⦄ ∈ parts (IK y)⟧ ⟹ StatCh secure Sv C (Msg [aAgt B, aKey K, aNum T]) ∈ chan a› 3. ‹⋀a y C K A T. ⟦(a, y) ∈ R23_msgs; (a, y) ∈ R23_keys; (a, y) ∈ R23_pres; Rs ∈ dom (runs y); fst (the (runs y Rs)) = Serv; Crypt (shrK C) ⦃Key K, msg.Agent A, Number T⦄ ∈ parts (IK y)⟧ ⟹ StatCh secure Sv C (Msg [aKey K, aAgt A, aNum T]) ∈ chan a› 4. ‹⋀a y KK K. ⟦(a, y) ∈ R23_msgs; (a, y) ∈ R23_keys; (a, y) ∈ R23_pres; Rs ∈ dom (runs y); fst (the (runs y Rs)) = Serv; KK ⊆ range sesK; Key K ∈ analz (insert (Key (sesK (Rs $ sk))) (Key ` KK ∪ IK y))⟧ ⟹ aKey K ∈ extr (insert (aKey (sesK (Rs $ sk))) (aKey ` KK ∪ ik0)) (chan a)› discuss goal 1*) apply ((auto dest: R23_keys_dests (*‹⟦Key ?K ∈ analz (Key ` ?KK ∪ IK ?t); (?s, ?t) ∈ R23_keys; ?KK ⊆ range sesK⟧ ⟹ aKey ?K ∈ extr (aKey ` ?KK ∪ ik0) (chan ?s)› ‹⟦Key ?K ∈ analz (IK ?t); (?s, ?t) ∈ R23_keys⟧ ⟹ aKey ?K ∈ extr ik0 (chan ?s)› ‹⟦Key ?K ∈ analz (insert (Key ?K') (IK ?t)); (?s, ?t) ∈ R23_keys; ?K' ∈ range sesK⟧ ⟹ aKey ?K ∈ extr (insert (aKey ?K') ik0) (chan ?s)› ‹⟦Key ?K ∈ analz (insert (Key ?K') (Key ` ?KK ∪ IK ?t)); (?s, ?t) ∈ R23_keys; ?K' ∈ range sesK; ?KK ⊆ range sesK⟧ ⟹ aKey ?K ∈ extr (insert (aKey ?K') (aKey ` ?KK ∪ ik0)) (chan ?s)›*))[1]) (*discuss goal 2*) apply ((auto dest: R23_keys_dests (*‹⟦Key ?K ∈ analz (Key ` ?KK ∪ IK ?t); (?s, ?t) ∈ R23_keys; ?KK ⊆ range sesK⟧ ⟹ aKey ?K ∈ extr (aKey ` ?KK ∪ ik0) (chan ?s)› ‹⟦Key ?K ∈ analz (IK ?t); (?s, ?t) ∈ R23_keys⟧ ⟹ aKey ?K ∈ extr ik0 (chan ?s)› ‹⟦Key ?K ∈ analz (insert (Key ?K') (IK ?t)); (?s, ?t) ∈ R23_keys; ?K' ∈ range sesK⟧ ⟹ aKey ?K ∈ extr (insert (aKey ?K') ik0) (chan ?s)› ‹⟦Key ?K ∈ analz (insert (Key ?K') (Key ` ?KK ∪ IK ?t)); (?s, ?t) ∈ R23_keys; ?K' ∈ range sesK; ?KK ⊆ range sesK⟧ ⟹ aKey ?K ∈ extr (insert (aKey ?K') (aKey ` ?KK ∪ ik0)) (chan ?s)›*))[1]) (*discuss goal 3*) apply ((auto dest: R23_keys_dests (*‹⟦Key (?K::key) ∈ analz (Key ` (?KK::key set) ∪ IK (?t::m3_state)); (?s::m2_state, ?t) ∈ R23_keys; ?KK ⊆ range sesK⟧ ⟹ aKey ?K ∈ extr (aKey ` ?KK ∪ ik0) (chan ?s)› ‹⟦Key (?K::key) ∈ analz (IK (?t::m3_state)); (?s::m2_state, ?t) ∈ R23_keys⟧ ⟹ aKey ?K ∈ extr ik0 (chan ?s)› ‹⟦Key (?K::key) ∈ analz (insert (Key (?K'::key)) (IK (?t::m3_state))); (?s::m2_state, ?t) ∈ R23_keys; ?K' ∈ range sesK⟧ ⟹ aKey ?K ∈ extr (insert (aKey ?K') ik0) (chan ?s)› ‹⟦Key (?K::key) ∈ analz (insert (Key (?K'::key)) (Key ` (?KK::key set) ∪ IK (?t::m3_state))); (?s::m2_state, ?t) ∈ R23_keys; ?K' ∈ range sesK; ?KK ⊆ range sesK⟧ ⟹ aKey ?K ∈ extr (insert (aKey ?K') (aKey ` ?KK ∪ ik0)) (chan ?s)›*))[1]) (*discuss goal 4*) apply ((auto dest: R23_keys_dests (*‹⟦Key ?K ∈ analz (Key ` ?KK ∪ IK ?t); (?s, ?t) ∈ R23_keys; ?KK ⊆ range sesK⟧ ⟹ aKey ?K ∈ extr (aKey ` ?KK ∪ ik0) (chan ?s)› ‹⟦Key ?K ∈ analz (IK ?t); (?s, ?t) ∈ R23_keys⟧ ⟹ aKey ?K ∈ extr ik0 (chan ?s)› ‹⟦Key ?K ∈ analz (insert (Key ?K') (IK ?t)); (?s, ?t) ∈ R23_keys; ?K' ∈ range sesK⟧ ⟹ aKey ?K ∈ extr (insert (aKey ?K') ik0) (chan ?s)› ‹⟦Key ?K ∈ analz (insert (Key ?K') (Key ` ?KK ∪ IK ?t)); (?s, ?t) ∈ R23_keys; ?K' ∈ range sesK; ?KK ⊆ range sesK⟧ ⟹ aKey ?K ∈ extr (insert (aKey ?K') (aKey ` ?KK ∪ ik0)) (chan ?s)›*))[1]) (*proven 4 subgoals*) . lemma PO_m3_DY_fake_refines_m2_fake: "{R23 ∩ UNIV × (m3_inv1_lkeysec)} m2_fake, m3_DY_fake {> R23}" apply (auto simp add: PO_rhoare_defs (*‹{?pre} ?Ra, ?Rc {> ?post} ≡ ?pre O ?Rc ⊆ ?Ra O ?post› ‹?r O ?s = {(x, z). ∃y. (x, y) ∈ ?r ∧ (y, z) ∈ ?s}›*) R23_def (*‹R23 ≡ R23_msgs ∩ R23_keys ∩ R23_pres›*) m3_defs (*‹m3 ≡ ⦇init = m3_init, trans = m3_trans, obs = m3_obs⦈› ‹m3_init ≡ {⦇runs = λx. None, leak = shrK ` bad, clk = 0, IK = Key ` shrK ` bad⦈}› ‹m3_trans ≡ ⋃A B Ra Rb Rs Kab Ts T X. (m3_step1 Ra A B ∪ m3_step2 Rb A B ∪ m3_step3 Rs A B Kab Ts ∪ m3_step4 Ra A B Kab Ts X ∪ m3_step5 Rb A B Kab Ts ∪ m3_tick T ∪ m3_leak Rs ∪ m3_DY_fake)⁼› ‹m3_obs ?s ≡ ⦇runs = runs ?s, leak = leak ?s, clk = clk ?s⦈› ‹m3_step1 ?Ra ?A ?B ≡ {(s, s1). ?Ra ∉ dom (runs s) ∧ s1 = s⦇runs := (runs s)(?Ra ↦ (Init, [?A, ?B], [])), IK := insert ⦃msg.Agent ?A, msg.Agent ?B⦄ (IK s)⦈}› ‹m3_step2 ≡ m1_step2› ‹m3_step3 ?Rs ?A ?B ?Kab ?Ts ≡ {(s, s1). ?Rs ∉ dom (runs s) ∧ ?Kab = sesK (?Rs $ sk) ∧ ⦃msg.Agent ?A, msg.Agent ?B⦄ ∈ IK s ∧ ?Ts = clk s ∧ s1 = s⦇runs := (runs s)(?Rs ↦ (Serv, [?A, ?B], [aNum ?Ts])), IK := insert (Crypt (shrK ?A) ⦃Key ?Kab, msg.Agent ?B, Number ?Ts, Crypt (shrK ?B) ⦃Key ?Kab, msg.Agent ?A, Number ?Ts⦄⦄) (IK s)⦈}› ‹m3_step4 ?Ra ?A ?B ?Kab ?Ts ?X ≡ {(s, s1). runs s ?Ra = Some (Init, [?A, ?B], []) ∧ Crypt (shrK ?A) ⦃Key ?Kab, msg.Agent ?B, Number ?Ts, ?X⦄ ∈ IK s ∧ clk s < ?Ts + Ls ∧ s1 = s⦇runs := (runs s)(?Ra ↦ (Init, [?A, ?B], [aKey ?Kab, aNum ?Ts])), IK := insert ?X (IK s)⦈}› ‹m3_step5 ?Rb ?A ?B ?Kab ?Ts ≡ {(s, s1). runs s ?Rb = Some (Resp, [?A, ?B], []) ∧ Crypt (shrK ?B) ⦃Key ?Kab, msg.Agent ?A, Number ?Ts⦄ ∈ IK s ∧ clk s < ?Ts + Ls ∧ s1 = s⦇runs := (runs s)(?Rb ↦ (Resp, [?A, ?B], [aKey ?Kab, aNum ?Ts]))⦈}› ‹m3_tick ≡ m1_tick› ‹m3_leak ?Rs ≡ {(s, s1). ?Rs ∈ dom (runs s) ∧ fst (the (runs s ?Rs)) = Serv ∧ s1 = s⦇leak := insert (sesK (?Rs $ sk)) (leak s), IK := insert (Key (sesK (?Rs $ sk))) (IK s)⦈}› ‹m3_DY_fake ≡ {(s, s1). s1 = s⦇IK := synth (analz (IK s))⦈}› and more 40 facts*) intro!: R23_intros (*‹abs_msg (parts (IK ?t)) ⊆ chan ?s ⟹ (?s, ?t) ∈ R23_msgs› ‹(⋀KK K. ⟦KK ⊆ range sesK; Key K ∈ analz (Key ` KK ∪ IK ?t)⟧ ⟹ aKey K ∈ extr (aKey ` KK ∪ ik0) (chan ?s)) ⟹ (?s, ?t) ∈ R23_keys› ‹runs ?s = runs ?t ∧ clk ?s = clk ?t ∧ leak ?s = leak ?t ⟹ (?s, ?t) ∈ R23_pres›*) del: abs_msg.cases (*‹⟦?a ∈ abs_msg ?H; ⋀A B. ⟦?a = Insec A B (Msg []); ⦃msg.Agent A, msg.Agent B⦄ ∈ ?H⟧ ⟹ ?P; ⋀C K B T X. ⟦?a = StatCh secure Sv C (Msg [aAgt B, aKey K, aNum T]); Crypt (shrK C) ⦃Key K, msg.Agent B, Number T, X⦄ ∈ ?H⟧ ⟹ ?P; ⋀C K A T. ⟦?a = StatCh secure Sv C (Msg [aKey K, aAgt A, aNum T]); Crypt (shrK C) ⦃Key K, msg.Agent A, Number T⦄ ∈ ?H⟧ ⟹ ?P⟧ ⟹ ?P›*)) (*goals: 1. ‹⋀a y x. ⟦(a, y) ∈ R23_msgs; (a, y) ∈ R23_keys; (a, y) ∈ R23_pres; y ∈ m3_inv1_lkeysec; x ∈ abs_msg (parts (IK y))⟧ ⟹ x ∈ fake ik0 (dom (runs a)) (chan a)› 2. ‹⋀a y x. ⟦(a, y) ∈ R23_msgs; (a, y) ∈ R23_keys; (a, y) ∈ R23_pres; y ∈ m3_inv1_lkeysec; x ∈ abs_msg (synth (analz (IK y)))⟧ ⟹ x ∈ fake ik0 (dom (runs a)) (chan a)› 3. ‹⋀a y KK K. ⟦(a, y) ∈ R23_msgs; (a, y) ∈ R23_keys; (a, y) ∈ R23_pres; y ∈ m3_inv1_lkeysec; KK ⊆ range sesK; Key K ∈ analz (Key ` KK ∪ IK y)⟧ ⟹ aKey K ∈ extr (aKey ` KK ∪ ik0) (chan a)› 4. ‹⋀a y KK K. ⟦(a, y) ∈ R23_msgs; (a, y) ∈ R23_keys; (a, y) ∈ R23_pres; y ∈ m3_inv1_lkeysec; KK ⊆ range sesK; Key K ∈ analz (IK y)⟧ ⟹ aKey K ∈ extr (aKey ` KK ∪ ik0) (chan a)› discuss goal 1*) apply ((auto intro: abs_msg_DY_subset_fakeable [THEN subsetD] (*‹⟦(?s1, ?t1) ∈ R23_msgs; (?s1, ?t1) ∈ R23_keys; (?s1, ?t1) ∈ ?R23_non1; ?t1 ∈ m3_inv1_lkeysec; ?c ∈ abs_msg (synth (analz (IK ?t1)))⟧ ⟹ ?c ∈ fake ik0 (dom (runs ?s1)) (chan ?s1)›*) del: abs_msg.cases (*‹⟦?a ∈ abs_msg ?H; ⋀A B. ⟦?a = Insec A B (Msg []); ⦃msg.Agent A, msg.Agent B⦄ ∈ ?H⟧ ⟹ ?P; ⋀C K B T X. ⟦?a = StatCh secure Sv C (Msg [aAgt B, aKey K, aNum T]); Crypt (shrK C) ⦃Key K, msg.Agent B, Number T, X⦄ ∈ ?H⟧ ⟹ ?P; ⋀C K A T. ⟦?a = StatCh secure Sv C (Msg [aKey K, aAgt A, aNum T]); Crypt (shrK C) ⦃Key K, msg.Agent A, Number T⦄ ∈ ?H⟧ ⟹ ?P⟧ ⟹ ?P›*) dest: R23_keys_dests (*‹⟦Key ?K ∈ analz (Key ` ?KK ∪ IK ?t); (?s, ?t) ∈ R23_keys; ?KK ⊆ range sesK⟧ ⟹ aKey ?K ∈ extr (aKey ` ?KK ∪ ik0) (chan ?s)› ‹⟦Key ?K ∈ analz (IK ?t); (?s, ?t) ∈ R23_keys⟧ ⟹ aKey ?K ∈ extr ik0 (chan ?s)› ‹⟦Key ?K ∈ analz (insert (Key ?K') (IK ?t)); (?s, ?t) ∈ R23_keys; ?K' ∈ range sesK⟧ ⟹ aKey ?K ∈ extr (insert (aKey ?K') ik0) (chan ?s)› ‹⟦Key ?K ∈ analz (insert (Key ?K') (Key ` ?KK ∪ IK ?t)); (?s, ?t) ∈ R23_keys; ?K' ∈ range sesK; ?KK ⊆ range sesK⟧ ⟹ aKey ?K ∈ extr (insert (aKey ?K') (aKey ` ?KK ∪ ik0)) (chan ?s)›*))[1]) (*discuss goal 2*) apply ((auto intro: abs_msg_DY_subset_fakeable [THEN subsetD] (*‹⟦(?s1::m2_state, ?t1::m3_state) ∈ R23_msgs; (?s1, ?t1) ∈ R23_keys; (?s1, ?t1) ∈ (?R23_non1::(m2_state × m3_state) set); ?t1 ∈ m3_inv1_lkeysec; (?c::chmsg) ∈ abs_msg (synth (analz (IK ?t1)))⟧ ⟹ ?c ∈ fake ik0 (dom (runs ?s1)) (chan ?s1)›*) del: abs_msg.cases (*‹⟦(?a::chmsg) ∈ abs_msg (?H::msg set); ⋀(A::agent) B::agent. ⟦?a = Insec A B (Msg []); ⦃msg.Agent A, msg.Agent B⦄ ∈ ?H⟧ ⟹ ?P::bool; ⋀(C::agent) (K::key) (B::agent) (T::nat) X::msg. ⟦?a = StatCh secure Sv C (Msg [aAgt B, aKey K, aNum T]); Crypt (shrK C) ⦃Key K, msg.Agent B, Number T, X⦄ ∈ ?H⟧ ⟹ ?P; ⋀(C::agent) (K::key) (A::agent) T::nat. ⟦?a = StatCh secure Sv C (Msg [aKey K, aAgt A, aNum T]); Crypt (shrK C) ⦃Key K, msg.Agent A, Number T⦄ ∈ ?H⟧ ⟹ ?P⟧ ⟹ ?P›*) dest: R23_keys_dests (*‹⟦Key (?K::key) ∈ analz (Key ` (?KK::key set) ∪ IK (?t::m3_state)); (?s::m2_state, ?t) ∈ R23_keys; ?KK ⊆ range sesK⟧ ⟹ aKey ?K ∈ extr (aKey ` ?KK ∪ ik0) (chan ?s)› ‹⟦Key (?K::key) ∈ analz (IK (?t::m3_state)); (?s::m2_state, ?t) ∈ R23_keys⟧ ⟹ aKey ?K ∈ extr ik0 (chan ?s)› ‹⟦Key (?K::key) ∈ analz (insert (Key (?K'::key)) (IK (?t::m3_state))); (?s::m2_state, ?t) ∈ R23_keys; ?K' ∈ range sesK⟧ ⟹ aKey ?K ∈ extr (insert (aKey ?K') ik0) (chan ?s)› ‹⟦Key (?K::key) ∈ analz (insert (Key (?K'::key)) (Key ` (?KK::key set) ∪ IK (?t::m3_state))); (?s::m2_state, ?t) ∈ R23_keys; ?K' ∈ range sesK; ?KK ⊆ range sesK⟧ ⟹ aKey ?K ∈ extr (insert (aKey ?K') (aKey ` ?KK ∪ ik0)) (chan ?s)›*))[1]) (*discuss goal 3*) apply ((auto intro: abs_msg_DY_subset_fakeable [THEN subsetD] (*‹⟦(?s1, ?t1) ∈ R23_msgs; (?s1, ?t1) ∈ R23_keys; (?s1, ?t1) ∈ ?R23_non1; ?t1 ∈ m3_inv1_lkeysec; ?c ∈ abs_msg (synth (analz (IK ?t1)))⟧ ⟹ ?c ∈ fake ik0 (dom (runs ?s1)) (chan ?s1)›*) del: abs_msg.cases (*‹⟦?a ∈ abs_msg ?H; ⋀A B. ⟦?a = Insec A B (Msg []); ⦃msg.Agent A, msg.Agent B⦄ ∈ ?H⟧ ⟹ ?P; ⋀C K B T X. ⟦?a = StatCh secure Sv C (Msg [aAgt B, aKey K, aNum T]); Crypt (shrK C) ⦃Key K, msg.Agent B, Number T, X⦄ ∈ ?H⟧ ⟹ ?P; ⋀C K A T. ⟦?a = StatCh secure Sv C (Msg [aKey K, aAgt A, aNum T]); Crypt (shrK C) ⦃Key K, msg.Agent A, Number T⦄ ∈ ?H⟧ ⟹ ?P⟧ ⟹ ?P›*) dest: R23_keys_dests (*‹⟦Key ?K ∈ analz (Key ` ?KK ∪ IK ?t); (?s, ?t) ∈ R23_keys; ?KK ⊆ range sesK⟧ ⟹ aKey ?K ∈ extr (aKey ` ?KK ∪ ik0) (chan ?s)› ‹⟦Key ?K ∈ analz (IK ?t); (?s, ?t) ∈ R23_keys⟧ ⟹ aKey ?K ∈ extr ik0 (chan ?s)› ‹⟦Key ?K ∈ analz (insert (Key ?K') (IK ?t)); (?s, ?t) ∈ R23_keys; ?K' ∈ range sesK⟧ ⟹ aKey ?K ∈ extr (insert (aKey ?K') ik0) (chan ?s)› ‹⟦Key ?K ∈ analz (insert (Key ?K') (Key ` ?KK ∪ IK ?t)); (?s, ?t) ∈ R23_keys; ?K' ∈ range sesK; ?KK ⊆ range sesK⟧ ⟹ aKey ?K ∈ extr (insert (aKey ?K') (aKey ` ?KK ∪ ik0)) (chan ?s)›*))[1]) (*discuss goal 4*) apply ((auto intro: abs_msg_DY_subset_fakeable [THEN subsetD] (*‹⟦(?s1::m2_state, ?t1::m3_state) ∈ R23_msgs; (?s1, ?t1) ∈ R23_keys; (?s1, ?t1) ∈ (?R23_non1::(m2_state × m3_state) set); ?t1 ∈ m3_inv1_lkeysec; (?c::chmsg) ∈ abs_msg (synth (analz (IK ?t1)))⟧ ⟹ ?c ∈ fake ik0 (dom (runs ?s1)) (chan ?s1)›*) del: abs_msg.cases (*‹⟦(?a::chmsg) ∈ abs_msg (?H::msg set); ⋀(A::agent) B::agent. ⟦?a = Insec A B (Msg []); ⦃msg.Agent A, msg.Agent B⦄ ∈ ?H⟧ ⟹ ?P::bool; ⋀(C::agent) (K::key) (B::agent) (T::nat) X::msg. ⟦?a = StatCh secure Sv C (Msg [aAgt B, aKey K, aNum T]); Crypt (shrK C) ⦃Key K, msg.Agent B, Number T, X⦄ ∈ ?H⟧ ⟹ ?P; ⋀(C::agent) (K::key) (A::agent) T::nat. ⟦?a = StatCh secure Sv C (Msg [aKey K, aAgt A, aNum T]); Crypt (shrK C) ⦃Key K, msg.Agent A, Number T⦄ ∈ ?H⟧ ⟹ ?P⟧ ⟹ ?P›*) dest: R23_keys_dests (*‹⟦Key (?K::key) ∈ analz (Key ` (?KK::key set) ∪ IK (?t::m3_state)); (?s::m2_state, ?t) ∈ R23_keys; ?KK ⊆ range sesK⟧ ⟹ aKey ?K ∈ extr (aKey ` ?KK ∪ ik0) (chan ?s)› ‹⟦Key (?K::key) ∈ analz (IK (?t::m3_state)); (?s::m2_state, ?t) ∈ R23_keys⟧ ⟹ aKey ?K ∈ extr ik0 (chan ?s)› ‹⟦Key (?K::key) ∈ analz (insert (Key (?K'::key)) (IK (?t::m3_state))); (?s::m2_state, ?t) ∈ R23_keys; ?K' ∈ range sesK⟧ ⟹ aKey ?K ∈ extr (insert (aKey ?K') ik0) (chan ?s)› ‹⟦Key (?K::key) ∈ analz (insert (Key (?K'::key)) (Key ` (?KK::key set) ∪ IK (?t::m3_state))); (?s::m2_state, ?t) ∈ R23_keys; ?K' ∈ range sesK; ?KK ⊆ range sesK⟧ ⟹ aKey ?K ∈ extr (insert (aKey ?K') (aKey ` ?KK ∪ ik0)) (chan ?s)›*))[1]) (*proven 4 subgoals*) . text ‹All together now...› lemmas PO_m3_trans_refines_m2_trans = PO_m3_step1_refines_m2_step1 PO_m3_step2_refines_m2_step2 PO_m3_step3_refines_m2_step3 PO_m3_step4_refines_m2_step4 PO_m3_step5_refines_m2_step5 PO_m3_tick_refines_m2_tick PO_m3_leak_refines_m2_leak PO_m3_DY_fake_refines_m2_fake lemma PO_m3_refines_init_m2 [iff]: "init m3 ⊆ R23``(init m2)" by (auto simp add: R23_def (*‹R23 ≡ R23_msgs ∩ R23_keys ∩ R23_pres›*) m3_defs (*‹m3 ≡ ⦇init = m3_init, trans = m3_trans, obs = m3_obs⦈› ‹m3_init ≡ {⦇runs = λx. None, leak = shrK ` bad, clk = 0, IK = Key ` shrK ` bad⦈}› ‹m3_trans ≡ ⋃A B Ra Rb Rs Kab Ts T X. (m3_step1 Ra A B ∪ m3_step2 Rb A B ∪ m3_step3 Rs A B Kab Ts ∪ m3_step4 Ra A B Kab Ts X ∪ m3_step5 Rb A B Kab Ts ∪ m3_tick T ∪ m3_leak Rs ∪ m3_DY_fake)⁼› ‹m3_obs ?s ≡ ⦇runs = runs ?s, leak = leak ?s, clk = clk ?s⦈› ‹m3_step1 ?Ra ?A ?B ≡ {(s, s1). ?Ra ∉ dom (runs s) ∧ s1 = s⦇runs := (runs s)(?Ra ↦ (Init, [?A, ?B], [])), IK := insert ⦃msg.Agent ?A, msg.Agent ?B⦄ (IK s)⦈}› ‹m3_step2 ≡ m1_step2› ‹m3_step3 ?Rs ?A ?B ?Kab ?Ts ≡ {(s, s1). ?Rs ∉ dom (runs s) ∧ ?Kab = sesK (?Rs $ sk) ∧ ⦃msg.Agent ?A, msg.Agent ?B⦄ ∈ IK s ∧ ?Ts = clk s ∧ s1 = s⦇runs := (runs s)(?Rs ↦ (Serv, [?A, ?B], [aNum ?Ts])), IK := insert (Crypt (shrK ?A) ⦃Key ?Kab, msg.Agent ?B, Number ?Ts, Crypt (shrK ?B) ⦃Key ?Kab, msg.Agent ?A, Number ?Ts⦄⦄) (IK s)⦈}› ‹m3_step4 ?Ra ?A ?B ?Kab ?Ts ?X ≡ {(s, s1). runs s ?Ra = Some (Init, [?A, ?B], []) ∧ Crypt (shrK ?A) ⦃Key ?Kab, msg.Agent ?B, Number ?Ts, ?X⦄ ∈ IK s ∧ clk s < ?Ts + Ls ∧ s1 = s⦇runs := (runs s)(?Ra ↦ (Init, [?A, ?B], [aKey ?Kab, aNum ?Ts])), IK := insert ?X (IK s)⦈}› ‹m3_step5 ?Rb ?A ?B ?Kab ?Ts ≡ {(s, s1). runs s ?Rb = Some (Resp, [?A, ?B], []) ∧ Crypt (shrK ?B) ⦃Key ?Kab, msg.Agent ?A, Number ?Ts⦄ ∈ IK s ∧ clk s < ?Ts + Ls ∧ s1 = s⦇runs := (runs s)(?Rb ↦ (Resp, [?A, ?B], [aKey ?Kab, aNum ?Ts]))⦈}› ‹m3_tick ≡ m1_tick› ‹m3_leak ?Rs ≡ {(s, s1). ?Rs ∈ dom (runs s) ∧ fst (the (runs s ?Rs)) = Serv ∧ s1 = s⦇leak := insert (sesK (?Rs $ sk)) (leak s), IK := insert (Key (sesK (?Rs $ sk))) (IK s)⦈}› ‹m3_DY_fake ≡ {(s, s1). s1 = s⦇IK := synth (analz (IK s))⦈}› and more 40 facts*) ik0_def (*‹ik0 ≡ range aAgt ∪ range aNum ∪ aKey ` corrKey›*) intro!: R23_intros (*‹abs_msg (parts (IK ?t)) ⊆ chan ?s ⟹ (?s, ?t) ∈ R23_msgs› ‹(⋀KK K. ⟦KK ⊆ range sesK; Key K ∈ analz (Key ` KK ∪ IK ?t)⟧ ⟹ aKey K ∈ extr (aKey ` KK ∪ ik0) (chan ?s)) ⟹ (?s, ?t) ∈ R23_keys› ‹runs ?s = runs ?t ∧ clk ?s = clk ?t ∧ leak ?s = leak ?t ⟹ (?s, ?t) ∈ R23_pres›*)) lemma PO_m3_refines_trans_m2 [iff]: "{R23 ∩ (m2_inv3a_sesK_compr) × (m3_inv3_sesK_compr ∩ m3_inv2_ticket ∩ m3_inv1_lkeysec)} (trans m2), (trans m3) {> R23}" apply (auto simp add: m3_def (*‹m3 ≡ ⦇init = m3_init, trans = m3_trans, obs = m3_obs⦈›*) m3_trans_def (*‹m3_trans ≡ ⋃A B Ra Rb Rs Kab Ts T X. (m3_step1 Ra A B ∪ m3_step2 Rb A B ∪ m3_step3 Rs A B Kab Ts ∪ m3_step4 Ra A B Kab Ts X ∪ m3_step5 Rb A B Kab Ts ∪ m3_tick T ∪ m3_leak Rs ∪ m3_DY_fake)⁼›*) m2_def (*‹m2 ≡ ⦇init = m2_init, trans = m2_trans, obs = m2_obs⦈›*) m2_trans_def (*‹m2_trans ≡ ⋃A B Ra Rb Rs Kab Ts T. (m2_step1 Ra A B ∪ m2_step2 Rb A B ∪ m2_step3 Rs A B Kab Ts ∪ m2_step4 Ra A B Kab Ts ∪ m2_step5 Rb A B Kab Ts ∪ m2_tick T ∪ m2_leak Rs ∪ m2_fake)⁼›*)) (*goals: 1. ‹⋀x xa xb. {R23 ∩ m2_inv3a_sesK_compr × (m3_inv3_sesK_compr ∩ m3_inv2_ticket ∩ m3_inv1_lkeysec)} ((⋃x xa xb xc xd. (⋃xe xf. m2_step1 xb x xa ∪ m2_step2 xc x xa ∪ m2_step3 xd x xa xe xf ∪ m2_step4 xb x xa xe xf ∪ m2_step5 xc x xa xe xf) ∪ ⋃ (range m2_tick) ∪ m2_leak xd) ∪ m2_fake)⁼, m3_step1 xb x xa {> R23}› 2. ‹⋀x xa xc. {R23 ∩ m2_inv3a_sesK_compr × (m3_inv3_sesK_compr ∩ m3_inv2_ticket ∩ m3_inv1_lkeysec)} ((⋃x xa xb xc xd. (⋃xe xf. m2_step1 xb x xa ∪ m2_step2 xc x xa ∪ m2_step3 xd x xa xe xf ∪ m2_step4 xb x xa xe xf ∪ m2_step5 xc x xa xe xf) ∪ ⋃ (range m2_tick) ∪ m2_leak xd) ∪ m2_fake)⁼, m3_step2 xc x xa {> R23}› 3. ‹⋀x xa xd xe xf. {R23 ∩ m2_inv3a_sesK_compr × (m3_inv3_sesK_compr ∩ m3_inv2_ticket ∩ m3_inv1_lkeysec)} ((⋃x xa xb xc xd. (⋃xe xf. m2_step1 xb x xa ∪ m2_step2 xc x xa ∪ m2_step3 xd x xa xe xf ∪ m2_step4 xb x xa xe xf ∪ m2_step5 xc x xa xe xf) ∪ ⋃ (range m2_tick) ∪ m2_leak xd) ∪ m2_fake)⁼, m3_step3 xd x xa xe xf {> R23}› 4. ‹⋀x xa xb xe xf xg. {R23 ∩ m2_inv3a_sesK_compr × (m3_inv3_sesK_compr ∩ m3_inv2_ticket ∩ m3_inv1_lkeysec)} ((⋃x xa xb xc xd. (⋃xe xf. m2_step1 xb x xa ∪ m2_step2 xc x xa ∪ m2_step3 xd x xa xe xf ∪ m2_step4 xb x xa xe xf ∪ m2_step5 xc x xa xe xf) ∪ ⋃ (range m2_tick) ∪ m2_leak xd) ∪ m2_fake)⁼, m3_step4 xb x xa xe xf xg {> R23}› 5. ‹⋀x xa xc xe xf. {R23 ∩ m2_inv3a_sesK_compr × (m3_inv3_sesK_compr ∩ m3_inv2_ticket ∩ m3_inv1_lkeysec)} ((⋃x xa xb xc xd. (⋃xe xf. m2_step1 xb x xa ∪ m2_step2 xc x xa ∪ m2_step3 xd x xa xe xf ∪ m2_step4 xb x xa xe xf ∪ m2_step5 xc x xa xe xf) ∪ ⋃ (range m2_tick) ∪ m2_leak xd) ∪ m2_fake)⁼, m3_step5 xc x xa xe xf {> R23}› 6. ‹⋀xe. {R23 ∩ m2_inv3a_sesK_compr × (m3_inv3_sesK_compr ∩ m3_inv2_ticket ∩ m3_inv1_lkeysec)} ((⋃x xa xb xc xd. (⋃xe xf. m2_step1 xb x xa ∪ m2_step2 xc x xa ∪ m2_step3 xd x xa xe xf ∪ m2_step4 xb x xa xe xf ∪ m2_step5 xc x xa xe xf) ∪ ⋃ (range m2_tick) ∪ m2_leak xd) ∪ m2_fake)⁼, m3_tick xe {> R23}› 7. ‹⋀xd. {R23 ∩ m2_inv3a_sesK_compr × (m3_inv3_sesK_compr ∩ m3_inv2_ticket ∩ m3_inv1_lkeysec)} ((⋃x xa xb xc xd. (⋃xe xf. m2_step1 xb x xa ∪ m2_step2 xc x xa ∪ m2_step3 xd x xa xe xf ∪ m2_step4 xb x xa xe xf ∪ m2_step5 xc x xa xe xf) ∪ ⋃ (range m2_tick) ∪ m2_leak xd) ∪ m2_fake)⁼, m3_leak xd {> R23}› 8. ‹{R23 ∩ m2_inv3a_sesK_compr × (m3_inv3_sesK_compr ∩ m3_inv2_ticket ∩ m3_inv1_lkeysec)} ((⋃x xa xb xc xd. (⋃xe xf. m2_step1 xb x xa ∪ m2_step2 xc x xa ∪ m2_step3 xd x xa xe xf ∪ m2_step4 xb x xa xe xf ∪ m2_step5 xc x xa xe xf) ∪ ⋃ (range m2_tick) ∪ m2_leak xd) ∪ m2_fake)⁼, m3_DY_fake {> R23}› discuss goal 1*) apply (blast intro!: PO_m3_trans_refines_m2_trans (*‹{R23} m2_step1 ?Ra ?A ?B, m3_step1 ?Ra ?A ?B {> R23}› ‹{R23} m2_step2 ?Rb ?A ?B, m3_step2 ?Rb ?A ?B {> R23}› ‹{R23 ∩ m2_inv3a_sesK_compr × (m3_inv3_sesK_compr ∩ m3_inv1_lkeysec)} m2_step3 ?Rs ?A ?B ?Kab ?Ts, m3_step3 ?Rs ?A ?B ?Kab ?Ts {> R23}› ‹{R23 ∩ UNIV × (m3_inv3_sesK_compr ∩ m3_inv2_ticket ∩ m3_inv1_lkeysec)} m2_step4 ?Ra ?A ?B ?Kab ?Ts, m3_step4 ?Ra ?A ?B ?Kab ?Ts ?X {> R23}› ‹{R23} m2_step5 ?Rb ?A ?B ?Kab ?Ts, m3_step5 ?Rb ?A ?B ?Kab ?Ts {> R23}› ‹{R23} m2_tick ?T, m3_tick ?T {> R23}› ‹{R23} m2_leak ?Rs, m3_leak ?Rs {> R23}› ‹{R23 ∩ UNIV × m3_inv1_lkeysec} m2_fake, m3_DY_fake {> R23}›*)) (*discuss goal 2*) apply (blast intro!: PO_m3_trans_refines_m2_trans (*‹{R23} m2_step1 ?Ra ?A ?B, m3_step1 ?Ra ?A ?B {> R23}› ‹{R23} m2_step2 ?Rb ?A ?B, m3_step2 ?Rb ?A ?B {> R23}› ‹{R23 ∩ m2_inv3a_sesK_compr × (m3_inv3_sesK_compr ∩ m3_inv1_lkeysec)} m2_step3 ?Rs ?A ?B ?Kab ?Ts, m3_step3 ?Rs ?A ?B ?Kab ?Ts {> R23}› ‹{R23 ∩ UNIV × (m3_inv3_sesK_compr ∩ m3_inv2_ticket ∩ m3_inv1_lkeysec)} m2_step4 ?Ra ?A ?B ?Kab ?Ts, m3_step4 ?Ra ?A ?B ?Kab ?Ts ?X {> R23}› ‹{R23} m2_step5 ?Rb ?A ?B ?Kab ?Ts, m3_step5 ?Rb ?A ?B ?Kab ?Ts {> R23}› ‹{R23} m2_tick ?T, m3_tick ?T {> R23}› ‹{R23} m2_leak ?Rs, m3_leak ?Rs {> R23}› ‹{R23 ∩ UNIV × m3_inv1_lkeysec} m2_fake, m3_DY_fake {> R23}›*)) (*discuss goal 3*) apply (blast intro!: PO_m3_trans_refines_m2_trans (*‹{R23} m2_step1 ?Ra ?A ?B, m3_step1 ?Ra ?A ?B {> R23}› ‹{R23} m2_step2 ?Rb ?A ?B, m3_step2 ?Rb ?A ?B {> R23}› ‹{R23 ∩ m2_inv3a_sesK_compr × (m3_inv3_sesK_compr ∩ m3_inv1_lkeysec)} m2_step3 ?Rs ?A ?B ?Kab ?Ts, m3_step3 ?Rs ?A ?B ?Kab ?Ts {> R23}› ‹{R23 ∩ UNIV × (m3_inv3_sesK_compr ∩ m3_inv2_ticket ∩ m3_inv1_lkeysec)} m2_step4 ?Ra ?A ?B ?Kab ?Ts, m3_step4 ?Ra ?A ?B ?Kab ?Ts ?X {> R23}› ‹{R23} m2_step5 ?Rb ?A ?B ?Kab ?Ts, m3_step5 ?Rb ?A ?B ?Kab ?Ts {> R23}› ‹{R23} m2_tick ?T, m3_tick ?T {> R23}› ‹{R23} m2_leak ?Rs, m3_leak ?Rs {> R23}› ‹{R23 ∩ UNIV × m3_inv1_lkeysec} m2_fake, m3_DY_fake {> R23}›*)) (*discuss goal 4*) apply (blast intro!: PO_m3_trans_refines_m2_trans (*‹{R23} m2_step1 (?Ra::fid_t) (?A::agent) (?B::agent), m3_step1 ?Ra ?A ?B {> R23}› ‹{R23} m2_step2 (?Rb::fid_t) (?A::agent) (?B::agent), m3_step2 ?Rb ?A ?B {> R23}› ‹{R23 ∩ m2_inv3a_sesK_compr × (m3_inv3_sesK_compr ∩ m3_inv1_lkeysec)} m2_step3 (?Rs::fid_t) (?A::agent) (?B::agent) (?Kab::key) (?Ts::nat), m3_step3 ?Rs ?A ?B ?Kab ?Ts {> R23}› ‹{R23 ∩ UNIV × (m3_inv3_sesK_compr ∩ m3_inv2_ticket ∩ m3_inv1_lkeysec)} m2_step4 (?Ra::fid_t) (?A::agent) (?B::agent) (?Kab::key) (?Ts::nat), m3_step4 ?Ra ?A ?B ?Kab ?Ts (?X::msg) {> R23}› ‹{R23} m2_step5 (?Rb::fid_t) (?A::agent) (?B::agent) (?Kab::key) (?Ts::nat), m3_step5 ?Rb ?A ?B ?Kab ?Ts {> R23}› ‹{R23} m2_tick (?T::nat), m3_tick ?T {> R23}› ‹{R23} m2_leak (?Rs::fid_t), m3_leak ?Rs {> R23}› ‹{R23 ∩ UNIV × m3_inv1_lkeysec} m2_fake, m3_DY_fake {> R23}›*)) (*discuss goal 5*) apply (blast intro!: PO_m3_trans_refines_m2_trans (*‹{R23} m2_step1 ?Ra ?A ?B, m3_step1 ?Ra ?A ?B {> R23}› ‹{R23} m2_step2 ?Rb ?A ?B, m3_step2 ?Rb ?A ?B {> R23}› ‹{R23 ∩ m2_inv3a_sesK_compr × (m3_inv3_sesK_compr ∩ m3_inv1_lkeysec)} m2_step3 ?Rs ?A ?B ?Kab ?Ts, m3_step3 ?Rs ?A ?B ?Kab ?Ts {> R23}› ‹{R23 ∩ UNIV × (m3_inv3_sesK_compr ∩ m3_inv2_ticket ∩ m3_inv1_lkeysec)} m2_step4 ?Ra ?A ?B ?Kab ?Ts, m3_step4 ?Ra ?A ?B ?Kab ?Ts ?X {> R23}› ‹{R23} m2_step5 ?Rb ?A ?B ?Kab ?Ts, m3_step5 ?Rb ?A ?B ?Kab ?Ts {> R23}› ‹{R23} m2_tick ?T, m3_tick ?T {> R23}› ‹{R23} m2_leak ?Rs, m3_leak ?Rs {> R23}› ‹{R23 ∩ UNIV × m3_inv1_lkeysec} m2_fake, m3_DY_fake {> R23}›*)) (*discuss goal 6*) apply (blast intro!: PO_m3_trans_refines_m2_trans (*‹{R23} m2_step1 ?Ra ?A ?B, m3_step1 ?Ra ?A ?B {> R23}› ‹{R23} m2_step2 ?Rb ?A ?B, m3_step2 ?Rb ?A ?B {> R23}› ‹{R23 ∩ m2_inv3a_sesK_compr × (m3_inv3_sesK_compr ∩ m3_inv1_lkeysec)} m2_step3 ?Rs ?A ?B ?Kab ?Ts, m3_step3 ?Rs ?A ?B ?Kab ?Ts {> R23}› ‹{R23 ∩ UNIV × (m3_inv3_sesK_compr ∩ m3_inv2_ticket ∩ m3_inv1_lkeysec)} m2_step4 ?Ra ?A ?B ?Kab ?Ts, m3_step4 ?Ra ?A ?B ?Kab ?Ts ?X {> R23}› ‹{R23} m2_step5 ?Rb ?A ?B ?Kab ?Ts, m3_step5 ?Rb ?A ?B ?Kab ?Ts {> R23}› ‹{R23} m2_tick ?T, m3_tick ?T {> R23}› ‹{R23} m2_leak ?Rs, m3_leak ?Rs {> R23}› ‹{R23 ∩ UNIV × m3_inv1_lkeysec} m2_fake, m3_DY_fake {> R23}›*)) (*discuss goal 7*) apply (blast intro!: PO_m3_trans_refines_m2_trans (*‹{R23} m2_step1 ?Ra ?A ?B, m3_step1 ?Ra ?A ?B {> R23}› ‹{R23} m2_step2 ?Rb ?A ?B, m3_step2 ?Rb ?A ?B {> R23}› ‹{R23 ∩ m2_inv3a_sesK_compr × (m3_inv3_sesK_compr ∩ m3_inv1_lkeysec)} m2_step3 ?Rs ?A ?B ?Kab ?Ts, m3_step3 ?Rs ?A ?B ?Kab ?Ts {> R23}› ‹{R23 ∩ UNIV × (m3_inv3_sesK_compr ∩ m3_inv2_ticket ∩ m3_inv1_lkeysec)} m2_step4 ?Ra ?A ?B ?Kab ?Ts, m3_step4 ?Ra ?A ?B ?Kab ?Ts ?X {> R23}› ‹{R23} m2_step5 ?Rb ?A ?B ?Kab ?Ts, m3_step5 ?Rb ?A ?B ?Kab ?Ts {> R23}› ‹{R23} m2_tick ?T, m3_tick ?T {> R23}› ‹{R23} m2_leak ?Rs, m3_leak ?Rs {> R23}› ‹{R23 ∩ UNIV × m3_inv1_lkeysec} m2_fake, m3_DY_fake {> R23}›*)) (*discuss goal 8*) apply (blast intro!: PO_m3_trans_refines_m2_trans (*‹{R23} m2_step1 ?Ra ?A ?B, m3_step1 ?Ra ?A ?B {> R23}› ‹{R23} m2_step2 ?Rb ?A ?B, m3_step2 ?Rb ?A ?B {> R23}› ‹{R23 ∩ m2_inv3a_sesK_compr × (m3_inv3_sesK_compr ∩ m3_inv1_lkeysec)} m2_step3 ?Rs ?A ?B ?Kab ?Ts, m3_step3 ?Rs ?A ?B ?Kab ?Ts {> R23}› ‹{R23 ∩ UNIV × (m3_inv3_sesK_compr ∩ m3_inv2_ticket ∩ m3_inv1_lkeysec)} m2_step4 ?Ra ?A ?B ?Kab ?Ts, m3_step4 ?Ra ?A ?B ?Kab ?Ts ?X {> R23}› ‹{R23} m2_step5 ?Rb ?A ?B ?Kab ?Ts, m3_step5 ?Rb ?A ?B ?Kab ?Ts {> R23}› ‹{R23} m2_tick ?T, m3_tick ?T {> R23}› ‹{R23} m2_leak ?Rs, m3_leak ?Rs {> R23}› ‹{R23 ∩ UNIV × m3_inv1_lkeysec} m2_fake, m3_DY_fake {> R23}›*)) (*proven 8 subgoals*) . lemma PO_m3_observation_consistent [iff]: "obs_consistent R23 med32 m2 m3" by (auto simp add: obs_consistent_def (*‹obs_consistent ?R ?pi ?Sa ?Sc ≡ ∀s t. (s, t) ∈ ?R ⟶ ?pi (obs ?Sc t) = obs ?Sa s›*) R23_def (*‹R23 ≡ R23_msgs ∩ R23_keys ∩ R23_pres›*) med32_def (*‹med32 ≡ id›*) m3_defs (*‹m3 ≡ ⦇init = m3_init, trans = m3_trans, obs = m3_obs⦈› ‹m3_init ≡ {⦇runs = λx. None, leak = shrK ` bad, clk = 0, IK = Key ` shrK ` bad⦈}› ‹m3_trans ≡ ⋃A B Ra Rb Rs Kab Ts T X. (m3_step1 Ra A B ∪ m3_step2 Rb A B ∪ m3_step3 Rs A B Kab Ts ∪ m3_step4 Ra A B Kab Ts X ∪ m3_step5 Rb A B Kab Ts ∪ m3_tick T ∪ m3_leak Rs ∪ m3_DY_fake)⁼› ‹m3_obs ?s ≡ ⦇runs = runs ?s, leak = leak ?s, clk = clk ?s⦈› ‹m3_step1 ?Ra ?A ?B ≡ {(s, s1). ?Ra ∉ dom (runs s) ∧ s1 = s⦇runs := (runs s)(?Ra ↦ (Init, [?A, ?B], [])), IK := insert ⦃msg.Agent ?A, msg.Agent ?B⦄ (IK s)⦈}› ‹m3_step2 ≡ m1_step2› ‹m3_step3 ?Rs ?A ?B ?Kab ?Ts ≡ {(s, s1). ?Rs ∉ dom (runs s) ∧ ?Kab = sesK (?Rs $ sk) ∧ ⦃msg.Agent ?A, msg.Agent ?B⦄ ∈ IK s ∧ ?Ts = clk s ∧ s1 = s⦇runs := (runs s)(?Rs ↦ (Serv, [?A, ?B], [aNum ?Ts])), IK := insert (Crypt (shrK ?A) ⦃Key ?Kab, msg.Agent ?B, Number ?Ts, Crypt (shrK ?B) ⦃Key ?Kab, msg.Agent ?A, Number ?Ts⦄⦄) (IK s)⦈}› ‹m3_step4 ?Ra ?A ?B ?Kab ?Ts ?X ≡ {(s, s1). runs s ?Ra = Some (Init, [?A, ?B], []) ∧ Crypt (shrK ?A) ⦃Key ?Kab, msg.Agent ?B, Number ?Ts, ?X⦄ ∈ IK s ∧ clk s < ?Ts + Ls ∧ s1 = s⦇runs := (runs s)(?Ra ↦ (Init, [?A, ?B], [aKey ?Kab, aNum ?Ts])), IK := insert ?X (IK s)⦈}› ‹m3_step5 ?Rb ?A ?B ?Kab ?Ts ≡ {(s, s1). runs s ?Rb = Some (Resp, [?A, ?B], []) ∧ Crypt (shrK ?B) ⦃Key ?Kab, msg.Agent ?A, Number ?Ts⦄ ∈ IK s ∧ clk s < ?Ts + Ls ∧ s1 = s⦇runs := (runs s)(?Rb ↦ (Resp, [?A, ?B], [aKey ?Kab, aNum ?Ts]))⦈}› ‹m3_tick ≡ m1_tick› ‹m3_leak ?Rs ≡ {(s, s1). ?Rs ∈ dom (runs s) ∧ fst (the (runs s ?Rs)) = Serv ∧ s1 = s⦇leak := insert (sesK (?Rs $ sk)) (leak s), IK := insert (Key (sesK (?Rs $ sk))) (IK s)⦈}› ‹m3_DY_fake ≡ {(s, s1). s1 = s⦇IK := synth (analz (IK s))⦈}› and more 40 facts*)) text ‹Refinement result.› lemma m3_refines_m2 [iff]: "refines (R23 ∩ (m2_inv3a_sesK_compr) × (m3_inv3_sesK_compr ∩ m3_inv2_ticket ∩ m3_inv1_lkeysec)) med32 m2 m3" apply (rule Refinement_using_invariants (*‹⟦{?R ∩ ?I × ?J} TS.trans ?Sa, TS.trans ?Sc {> ?R}; {?I ∩ Domain (?R ∩ UNIV × ?J)} TS.trans ?Sa {> ?I}; {?J ∩ Range (?R ∩ ?I × UNIV)} TS.trans ?Sc {> ?J}; init ?Sc ⊆ ?R `` init ?Sa; init ?Sa ⊆ ?I; init ?Sc ⊆ ?J; obs_consistent (?R ∩ ?I × ?J) ?pi ?Sa ?Sc⟧ ⟹ refines (?R ∩ ?I × ?J) ?pi ?Sa ?Sc›*)) (*goals: 1. ‹{R23 ∩ m2_inv3a_sesK_compr × (m3_inv3_sesK_compr ∩ m3_inv2_ticket ∩ m3_inv1_lkeysec)} TS.trans m2, TS.trans m3 {> R23}› 2. ‹{m2_inv3a_sesK_compr ∩ Domain (R23 ∩ UNIV × (m3_inv3_sesK_compr ∩ m3_inv2_ticket ∩ m3_inv1_lkeysec))} TS.trans m2 {> m2_inv3a_sesK_compr}› 3. ‹{m3_inv3_sesK_compr ∩ m3_inv2_ticket ∩ m3_inv1_lkeysec ∩ Range (R23 ∩ m2_inv3a_sesK_compr × UNIV)} TS.trans m3 {> m3_inv3_sesK_compr ∩ m3_inv2_ticket ∩ m3_inv1_lkeysec}› 4. ‹init m3 ⊆ R23 `` init m2› 5. ‹init m2 ⊆ m2_inv3a_sesK_compr› 6. ‹init m3 ⊆ m3_inv3_sesK_compr ∩ m3_inv2_ticket ∩ m3_inv1_lkeysec› 7. ‹obs_consistent (R23 ∩ m2_inv3a_sesK_compr × (m3_inv3_sesK_compr ∩ m3_inv2_ticket ∩ m3_inv1_lkeysec)) med32 m2 m3› 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 m3_implements_m2 [iff]: "implements med32 m2 m3" apply (rule refinement_soundness (*‹refines ?R ?pi ?Sa ?Sc ⟹ implements ?pi ?Sa ?Sc›*)) (*goal: ‹implements med32 m2 m3›*) by auto end
{ "path": "afp-2025-02-12/thys/Security_Protocol_Refinement/Key_establish/m3_ds.thy", "repo": "afp-2025-02-12", "sha": "64174734e09c584a0c9345e810c75138d522b8dba656f1dba6a25d316258a185" }
section "Closest Pair Algorithm" theory Closest_Pair imports Common begin text‹ Formalization of a slightly optimized divide-and-conquer algorithm solving the Closest Pair Problem based on the presentation of Cormen \emph{et al.} \<^cite>‹"Introduction-to-Algorithms:2009"›. › subsection "Functional Correctness Proof" subsubsection "Combine Step" fun find_closest_tm :: "point ⇒ real ⇒ point list ⇒ point tm" where "find_closest_tm _ _ [] =1 return undefined" | "find_closest_tm _ _ [p] =1 return p" | "find_closest_tm p δ (p₀ # ps) =1 ( if δ ≤ snd p₀ - snd p then return p₀ else do { p₁ <- find_closest_tm p (min δ (dist p p₀)) ps; if dist p p₀ ≤ dist p p₁ then return p₀ else return p₁ } )" fun find_closest :: "point ⇒ real ⇒ point list ⇒ point" where "find_closest _ _ [] = undefined" | "find_closest _ _ [p] = p" | "find_closest p δ (p₀ # ps) = ( if δ ≤ snd p₀ - snd p then p₀ else let p₁ = find_closest p (min δ (dist p p₀)) ps in if dist p p₀ ≤ dist p p₁ then p₀ else p₁ )" lemma find_closest_eq_val_find_closest_tm: "val (find_closest_tm p δ ps) = find_closest p δ ps" apply (induction p δ ps rule: find_closest.induct (*‹⟦⋀uu_ uv_. ?P uu_ uv_ []; ⋀uw_ ux_ p. ?P uw_ ux_ [p]; ⋀p δ p₀ v va. (¬ δ ≤ real_of_int (snd p₀ - snd p) ⟹ ?P p (min δ (dist (case p of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₀ of (x, y) ⇒ (real_of_int x, real_of_int y)))) (v # va)) ⟹ ?P p δ (p₀ # v # va)⟧ ⟹ ?P ?a0.0 ?a1.0 ?a2.0›*)) (*goals: 1. ‹⋀uu_ uv_. Time_Monad.val (find_closest_tm uu_ uv_ []) = find_closest uu_ uv_ []› 2. ‹⋀uw_ ux_ p. Time_Monad.val (find_closest_tm uw_ ux_ [p]) = find_closest uw_ ux_ [p]› 3. ‹⋀p δ p₀ v va. (¬ δ ≤ real_of_int (snd p₀ - snd p) ⟹ Time_Monad.val (find_closest_tm p (min δ (dist (case p of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₀ of (x, y) ⇒ (real_of_int x, real_of_int y)))) (v # va)) = find_closest p (min δ (dist (case p of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₀ of (x, y) ⇒ (real_of_int x, real_of_int y)))) (v # va)) ⟹ Time_Monad.val (find_closest_tm p δ (p₀ # v # va)) = find_closest p δ (p₀ # v # va)› discuss goal 1*) apply ((auto simp: Let_def (*‹Let ?s ?f ≡ ?f ?s›*))[1]) (*discuss goal 2*) apply ((auto simp: Let_def (*‹Let ?s ?f ≡ ?f ?s›*))[1]) (*discuss goal 3*) apply ((auto simp: Let_def (*‹Let ?s ?f ≡ ?f ?s›*))[1]) (*proven 3 subgoals*) . lemma find_closest_set: "0 < length ps ⟹ find_closest p δ ps ∈ set ps" apply (induction p δ ps rule: find_closest.induct (*‹⟦⋀uu_ uv_. ?P uu_ uv_ []; ⋀uw_ ux_ p. ?P uw_ ux_ [p]; ⋀p δ p₀ v va. (¬ δ ≤ real_of_int (snd p₀ - snd p) ⟹ ?P p (min δ (dist (case p of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₀ of (x, y) ⇒ (real_of_int x, real_of_int y)))) (v # va)) ⟹ ?P p δ (p₀ # v # va)⟧ ⟹ ?P ?a0.0 ?a1.0 ?a2.0›*)) (*goals: 1. ‹⋀uu_ uv_. 0 < length [] ⟹ find_closest uu_ uv_ [] ∈ set []› 2. ‹⋀uw_ ux_ p. 0 < length [p] ⟹ find_closest uw_ ux_ [p] ∈ set [p]› 3. ‹⋀p δ p₀ v va. ⟦⟦¬ δ ≤ real_of_int (snd p₀ - snd p); 0 < length (v # va)⟧ ⟹ find_closest p (min δ (dist (case p of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₀ of (x, y) ⇒ (real_of_int x, real_of_int y)))) (v # va) ∈ set (v # va); 0 < length (p₀ # v # va)⟧ ⟹ find_closest p δ (p₀ # v # va) ∈ set (p₀ # v # va)› discuss goal 1*) apply ((auto simp: Let_def (*‹Let (?s::?'a) (?f::?'a ⇒ ?'b) ≡ ?f ?s›*))[1]) (*discuss goal 2*) apply ((auto simp: Let_def (*‹Let (?s::?'a) (?f::?'a ⇒ ?'b) ≡ ?f ?s›*))[1]) (*discuss goal 3*) apply ((auto simp: Let_def (*‹Let ?s ?f ≡ ?f ?s›*))[1]) (*proven 3 subgoals*) . lemma find_closest_dist: assumes "sorted_snd (p # ps)" "∃q ∈ set ps. dist p q < δ" shows "∀q ∈ set ps. dist p (find_closest p δ ps) ≤ dist p q" using assms (*‹sorted_snd ((p::int × int) # (ps::(int × int) list))› ‹∃q∈set ps. dist (case p of (x, y) ⇒ (real_of_int x, real_of_int y)) (case q of (x, y) ⇒ (real_of_int x, real_of_int y)) < δ›*) proof (induction p δ ps rule: find_closest.induct (*‹⟦⋀(uu_::int × int) uv_::real. (?P::int × int ⇒ real ⇒ (int × int) list ⇒ bool) uu_ uv_ []; ⋀(uw_::int × int) (ux_::real) p::int × int. ?P uw_ ux_ [p]; ⋀(p::int × int) (δ::real) (p₀::int × int) (v::int × int) va::(int × int) list. (¬ δ ≤ real_of_int (snd p₀ - snd p) ⟹ ?P p (min δ (dist (case p of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) (case p₀ of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)))) (v # va)) ⟹ ?P p δ (p₀ # v # va)⟧ ⟹ ?P (?a0.0::int × int) (?a1.0::real) (?a2.0::(int × int) list)›*)) (*goals: 1. ‹⋀uu_ uv_. ⟦sorted_snd [uu_]; ∃q∈set []. dist (case uu_ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case q of (x, y) ⇒ (real_of_int x, real_of_int y)) < uv_⟧ ⟹ ∀q∈set []. dist (case uu_ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case find_closest uu_ uv_ [] of (x, y) ⇒ (real_of_int x, real_of_int y)) ≤ dist (case uu_ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case q of (x, y) ⇒ (real_of_int x, real_of_int y))› 2. ‹⋀uw_ ux_ p. ⟦sorted_snd [uw_, p]; ∃q∈set [p]. dist (case uw_ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case q of (x, y) ⇒ (real_of_int x, real_of_int y)) < ux_⟧ ⟹ ∀q∈set [p]. dist (case uw_ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case find_closest uw_ ux_ [p] of (x, y) ⇒ (real_of_int x, real_of_int y)) ≤ dist (case uw_ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case q of (x, y) ⇒ (real_of_int x, real_of_int y))› 3. ‹⋀p δ p₀ v va. ⟦⟦¬ δ ≤ real_of_int (snd p₀ - snd p); sorted_snd (p # v # va); ∃q∈set (v # va). dist (case p of (x, y) ⇒ (real_of_int x, real_of_int y)) (case q of (x, y) ⇒ (real_of_int x, real_of_int y)) < min δ (dist (case p of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₀ of (x, y) ⇒ (real_of_int x, real_of_int y)))⟧ ⟹ ∀q∈set (v # va). dist (case p of (x, y) ⇒ (real_of_int x, real_of_int y)) (case find_closest p (min δ (dist (case p of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₀ of (x, y) ⇒ (real_of_int x, real_of_int y)))) (v # va) of (x, y) ⇒ (real_of_int x, real_of_int y)) ≤ dist (case p of (x, y) ⇒ (real_of_int x, real_of_int y)) (case q of (x, y) ⇒ (real_of_int x, real_of_int y)); sorted_snd (p # p₀ # v # va); ∃q∈set (p₀ # v # va). dist (case p of (x, y) ⇒ (real_of_int x, real_of_int y)) (case q of (x, y) ⇒ (real_of_int x, real_of_int y)) < δ⟧ ⟹ ∀q∈set (p₀ # v # va). dist (case p of (x, y) ⇒ (real_of_int x, real_of_int y)) (case find_closest p δ (p₀ # v # va) of (x, y) ⇒ (real_of_int x, real_of_int y)) ≤ dist (case p of (x, y) ⇒ (real_of_int x, real_of_int y)) (case q of (x, y) ⇒ (real_of_int x, real_of_int y))›*) case (3 p δ p₀ p₂ ps) (*‹⟦¬ δ ≤ real_of_int (snd p₀ - snd p); sorted_snd (p # p₂ # ps); ∃q∈set (p₂ # ps). dist (case p of (x, y) ⇒ (real_of_int x, real_of_int y)) (case q of (x, y) ⇒ (real_of_int x, real_of_int y)) < min δ (dist (case p of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₀ of (x, y) ⇒ (real_of_int x, real_of_int y)))⟧ ⟹ ∀q∈set (p₂ # ps). dist (case p of (x, y) ⇒ (real_of_int x, real_of_int y)) (case find_closest p (min δ (dist (case p of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₀ of (x, y) ⇒ (real_of_int x, real_of_int y)))) (p₂ # ps) of (x, y) ⇒ (real_of_int x, real_of_int y)) ≤ dist (case p of (x, y) ⇒ (real_of_int x, real_of_int y)) (case q of (x, y) ⇒ (real_of_int x, real_of_int y))› ‹sorted_snd (p # p₀ # p₂ # ps)› ‹∃q::int × int∈set ((p₀::int × int) # (p₂::int × int) # (ps::(int × int) list)). dist (case p::int × int of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) (case q of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) < (δ::real)›*) let ?ps = "p₀ # p₂ # ps" define p₁ where "p₁_def": "p₁ = find_closest p (min δ (dist p p₀)) (p₂ # ps)" have A: "¬ δ ≤ snd p₀ - snd p" proof (rule ccontr (*‹(¬ ?P ⟹ False) ⟹ ?P›*)) (*goal: ‹¬ ¬ δ ≤ real_of_int (snd p₀ - snd p) ⟹ False›*) assume B: "¬ ¬ δ ≤ snd p₀ - snd p" (*‹¬ ¬ (δ::real) ≤ real_of_int (snd (p₀::int × int) - snd (p::int × int))›*) have "∀q ∈ set ?ps. snd p ≤ snd q" using sorted_snd_def (*‹sorted_snd (?ps::(int × int) list) = sorted_wrt (λ(p₀::int × int) p₁::int × int. snd p₀ ≤ snd p₁) ?ps›*) "3.prems"(1) (*‹sorted_snd (p # p₀ # p₂ # ps)›*) by simp moreover have "∀q ∈ set ?ps. δ ≤ snd q - snd p" using sorted_snd_def (*‹sorted_snd ?ps = sorted_wrt (λp₀ p₁. snd p₀ ≤ snd p₁) ?ps›*) "3.prems"(1) (*‹sorted_snd (p # p₀ # p₂ # ps)›*) B (*‹¬ ¬ δ ≤ real_of_int (snd p₀ - snd p)›*) by auto ultimately have "∀q ∈ set ?ps. δ ≤ dist (snd p) (snd q)" using dist_real_def (*‹dist (?x::real) (?y::real) = ¦?x - ?y¦›*) by simp hence "∀q ∈ set ?ps. δ ≤ dist p q" using dist_snd_le (*‹dist (snd ?x) (snd ?y) ≤ dist ?x ?y›*) order_trans (*‹⟦?x ≤ ?y; ?y ≤ ?z⟧ ⟹ ?x ≤ ?z›*) apply (auto 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))›*)) (*goals: 1. ‹⋀x1 x2 x1a x2a x1b x2b. ⟦⋀a b aa ba. dist b ba ≤ dist (a, b) (aa, ba); ⋀x y z. ⟦x ≤ y; y ≤ z⟧ ⟹ x ≤ z; δ ≤ dist (real_of_int x2a) (real_of_int x2b); δ ≤ dist (real_of_int x2a) (real_of_int x2); ∀q∈set ps. δ ≤ dist (real_of_int x2a) (real_of_int (snd q)); p₂ = (x1, x2); p = (x1a, x2a); p₀ = (x1b, x2b)⟧ ⟹ δ ≤ dist (real_of_int x1a, real_of_int x2a) (real_of_int x1b, real_of_int x2b)› 2. ‹⋀x1 x2 x1a x2a x1b x2b. ⟦⋀a b aa ba. dist b ba ≤ dist (a, b) (aa, ba); ⋀x y z. ⟦x ≤ y; y ≤ z⟧ ⟹ x ≤ z; δ ≤ dist (real_of_int x2a) (real_of_int x2b); δ ≤ dist (real_of_int x2a) (real_of_int x2); ∀q∈set ps. δ ≤ dist (real_of_int x2a) (real_of_int (snd q)); p₂ = (x1, x2); p = (x1a, x2a); p₀ = (x1b, x2b)⟧ ⟹ δ ≤ dist (real_of_int x1a, real_of_int x2a) (real_of_int x1, real_of_int x2)› 3. ‹⋀x1 x2 x1a x2a x1b x2b x1c x2c. ⟦⋀a b aa ba. dist b ba ≤ dist (a, b) (aa, ba); ⋀x y z. ⟦x ≤ y; y ≤ z⟧ ⟹ x ≤ z; δ ≤ dist (real_of_int x2a) (real_of_int x2b); δ ≤ dist (real_of_int x2a) (real_of_int x2); ∀q∈set ps. δ ≤ dist (real_of_int x2a) (real_of_int (snd q)); p₂ = (x1, x2); p = (x1a, x2a); p₀ = (x1b, x2b); (x1c, x2c) ∈ set ps⟧ ⟹ δ ≤ dist (real_of_int x1a, real_of_int x2a) (real_of_int x1c, real_of_int x2c)› discuss goal 1*) apply fastforce (*discuss goal 2*) apply fastforce (*discuss goal 3*) apply fastforce (*proven 3 subgoals*) . thus False using "3.prems"(2) (*‹∃q::int × int∈set ((p₀::int × int) # (p₂::int × int) # (ps::(int × int) list)). dist (case p::int × int of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) (case q of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) < (δ::real)›*) by fastforce qed show "?case" (*goal: ‹∀q∈set (p₀ # p₂ # ps). dist (case p of (x, y) ⇒ (real_of_int x, real_of_int y)) (case find_closest p δ (p₀ # p₂ # ps) of (x, y) ⇒ (real_of_int x, real_of_int y)) ≤ dist (case p of (x, y) ⇒ (real_of_int x, real_of_int y)) (case q of (x, y) ⇒ (real_of_int x, real_of_int y))›*) proof (cases) (*goals: 1. ‹?P ⟹ ∀q∈set (p₀ # p₂ # ps). dist (case p of (x, y) ⇒ (real_of_int x, real_of_int y)) (case find_closest p δ (p₀ # p₂ # ps) of (x, y) ⇒ (real_of_int x, real_of_int y)) ≤ dist (case p of (x, y) ⇒ (real_of_int x, real_of_int y)) (case q of (x, y) ⇒ (real_of_int x, real_of_int y))› 2. ‹¬ ?P ⟹ ∀q∈set (p₀ # p₂ # ps). dist (case p of (x, y) ⇒ (real_of_int x, real_of_int y)) (case find_closest p δ (p₀ # p₂ # ps) of (x, y) ⇒ (real_of_int x, real_of_int y)) ≤ dist (case p of (x, y) ⇒ (real_of_int x, real_of_int y)) (case q of (x, y) ⇒ (real_of_int x, real_of_int y))›*) assume "∃q ∈ set (p₂ # ps). dist p q < min δ (dist p p₀)" (*‹∃q::int × int∈set ((p₂::int × int) # (ps::(int × int) list)). dist (case p::int × int of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) (case q of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) < min (δ::real) (dist (case p of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) (case p₀::int × int of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)))›*) hence "∀q ∈ set (p₂ # ps). dist p p₁ ≤ dist p q" using "3.IH" (*‹⟦¬ δ ≤ real_of_int (snd p₀ - snd p); sorted_snd (p # p₂ # ps); ∃q∈set (p₂ # ps). dist (case p of (x, y) ⇒ (real_of_int x, real_of_int y)) (case q of (x, y) ⇒ (real_of_int x, real_of_int y)) < min δ (dist (case p of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₀ of (x, y) ⇒ (real_of_int x, real_of_int y)))⟧ ⟹ ∀q∈set (p₂ # ps). dist (case p of (x, y) ⇒ (real_of_int x, real_of_int y)) (case find_closest p (min δ (dist (case p of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₀ of (x, y) ⇒ (real_of_int x, real_of_int y)))) (p₂ # ps) of (x, y) ⇒ (real_of_int x, real_of_int y)) ≤ dist (case p of (x, y) ⇒ (real_of_int x, real_of_int y)) (case q of (x, y) ⇒ (real_of_int x, real_of_int y))›*) "3.prems"(1) (*‹sorted_snd (p # p₀ # p₂ # ps)›*) A (*‹¬ (δ::real) ≤ real_of_int (snd (p₀::int × int) - snd (p::int × int))›*) "p₁_def" (*‹(p₁::int × int) = find_closest (p::int × int) (min (δ::real) (dist (case p of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) (case p₀::int × int of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)))) ((p₂::int × int) # (ps::(int × int) list))›*) sorted_snd_def (*‹sorted_snd ?ps = sorted_wrt (λp₀ p₁. snd p₀ ≤ snd p₁) ?ps›*) by simp thus "?thesis" (*goal: ‹∀q∈set (p₀ # p₂ # ps). dist (case p of (x, y) ⇒ (real_of_int x, real_of_int y)) (case find_closest p δ (p₀ # p₂ # ps) of (x, y) ⇒ (real_of_int x, real_of_int y)) ≤ dist (case p of (x, y) ⇒ (real_of_int x, real_of_int y)) (case q of (x, y) ⇒ (real_of_int x, real_of_int y))›*) using "p₁_def" (*‹p₁ = find_closest p (min δ (dist (case p of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₀ of (x, y) ⇒ (real_of_int x, real_of_int y)))) (p₂ # ps)›*) A (*‹¬ δ ≤ real_of_int (snd p₀ - snd p)›*) by (auto 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))›*)) next (*goal: ‹¬ (∃q∈set (p₂ # ps). dist (case p of (x, y) ⇒ (real_of_int x, real_of_int y)) (case q of (x, y) ⇒ (real_of_int x, real_of_int y)) < min δ (dist (case p of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₀ of (x, y) ⇒ (real_of_int x, real_of_int y)))) ⟹ ∀q∈set (p₀ # p₂ # ps). dist (case p of (x, y) ⇒ (real_of_int x, real_of_int y)) (case find_closest p δ (p₀ # p₂ # ps) of (x, y) ⇒ (real_of_int x, real_of_int y)) ≤ dist (case p of (x, y) ⇒ (real_of_int x, real_of_int y)) (case q of (x, y) ⇒ (real_of_int x, real_of_int y))›*) assume B: "¬ (∃q ∈ set (p₂ # ps). dist p q < min δ (dist p p₀))" (*‹¬ (∃q::int × int∈set ((p₂::int × int) # (ps::(int × int) list)). dist (case p::int × int of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) (case q of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) < min (δ::real) (dist (case p of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) (case p₀::int × int of (x::int, y::int) ⇒ (real_of_int x, real_of_int y))))›*) hence "dist p p₀ < δ" using "3.prems"(2) (*‹∃q::int × int∈set ((p₀::int × int) # (p₂::int × int) # (ps::(int × int) list)). dist (case p::int × int of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) (case q of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) < (δ::real)›*) "p₁_def" (*‹(p₁::int × int) = find_closest (p::int × int) (min (δ::real) (dist (case p of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) (case p₀::int × int of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)))) ((p₂::int × int) # (ps::(int × int) list))›*) by auto hence C: "∀q ∈ set ?ps. dist p p₀ ≤ dist p q" using "p₁_def" (*‹p₁ = find_closest p (min δ (dist (case p of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₀ of (x, y) ⇒ (real_of_int x, real_of_int y)))) (p₂ # ps)›*) B (*‹¬ (∃q::int × int∈set ((p₂::int × int) # (ps::(int × int) list)). dist (case p::int × int of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) (case q of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) < min (δ::real) (dist (case p of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) (case p₀::int × int of (x::int, y::int) ⇒ (real_of_int x, real_of_int y))))›*) by auto have "p₁ ∈ set (p₂ # ps)" using "p₁_def" (*‹p₁ = find_closest p (min δ (dist (case p of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₀ of (x, y) ⇒ (real_of_int x, real_of_int y)))) (p₂ # ps)›*) find_closest_set (*‹0 < length ?ps ⟹ find_closest ?p ?δ ?ps ∈ set ?ps›*) by blast hence "dist p p₀ ≤ dist p p₁" using "p₁_def" (*‹(p₁::int × int) = find_closest (p::int × int) (min (δ::real) (dist (case p of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) (case p₀::int × int of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)))) ((p₂::int × int) # (ps::(int × int) list))›*) C (*‹∀q∈set (p₀ # p₂ # ps). dist (case p of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) ≤ dist (case p of (x, y) ⇒ (real_of_int x, real_of_int y)) (case q of (x, y) ⇒ (real_of_int x, real_of_int y))›*) by auto thus "?thesis" (*goal: ‹∀q∈set (p₀ # p₂ # ps). dist (case p of (x, y) ⇒ (real_of_int x, real_of_int y)) (case find_closest p δ (p₀ # p₂ # ps) of (x, y) ⇒ (real_of_int x, real_of_int y)) ≤ dist (case p of (x, y) ⇒ (real_of_int x, real_of_int y)) (case q of (x, y) ⇒ (real_of_int x, real_of_int y))›*) using "p₁_def" (*‹p₁ = find_closest p (min δ (dist (case p of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₀ of (x, y) ⇒ (real_of_int x, real_of_int y)))) (p₂ # ps)›*) A (*‹¬ (δ::real) ≤ real_of_int (snd (p₀::int × int) - snd (p::int × int))›*) C (*‹∀q∈set (p₀ # p₂ # ps). dist (case p of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) ≤ dist (case p of (x, y) ⇒ (real_of_int x, real_of_int y)) (case q of (x, y) ⇒ (real_of_int x, real_of_int y))›*) by (auto 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 qed (auto) (*solves the remaining goals: 1. ‹⋀(uu_::int × int) uv_::real. ⟦sorted_snd [uu_]; ∃q::int × int∈set []. dist (case uu_ of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) (case q of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) < uv_⟧ ⟹ ∀q::int × int∈set []. dist (case uu_ of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) (case find_closest uu_ uv_ [] of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) ≤ dist (case uu_ of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) (case q of (x::int, y::int) ⇒ (real_of_int x, real_of_int y))› 2. ‹⋀(uw_::int × int) (ux_::real) p::int × int. ⟦sorted_snd [uw_, p]; ∃q::int × int∈set [p]. dist (case uw_ of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) (case q of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) < ux_⟧ ⟹ ∀q::int × int∈set [p]. dist (case uw_ of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) (case find_closest uw_ ux_ [p] of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) ≤ dist (case uw_ of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) (case q of (x::int, y::int) ⇒ (real_of_int x, real_of_int y))›*) declare find_closest.simps [simp del] fun find_closest_pair_tm :: "(point * point) ⇒ point list ⇒ (point × point) tm" where "find_closest_pair_tm (c₀, c₁) [] =1 return (c₀, c₁)" | "find_closest_pair_tm (c₀, c₁) [_] =1 return (c₀, c₁)" | "find_closest_pair_tm (c₀, c₁) (p₀ # ps) =1 ( do { p₁ <- find_closest_tm p₀ (dist c₀ c₁) ps; if dist c₀ c₁ ≤ dist p₀ p₁ then find_closest_pair_tm (c₀, c₁) ps else find_closest_pair_tm (p₀, p₁) ps } )" fun find_closest_pair :: "(point * point) ⇒ point list ⇒ (point × point)" where "find_closest_pair (c₀, c₁) [] = (c₀, c₁)" | "find_closest_pair (c₀, c₁) [_] = (c₀, c₁)" | "find_closest_pair (c₀, c₁) (p₀ # ps) = ( let p₁ = find_closest p₀ (dist c₀ c₁) ps in if dist c₀ c₁ ≤ dist p₀ p₁ then find_closest_pair (c₀, c₁) ps else find_closest_pair (p₀, p₁) ps )" lemma find_closest_pair_eq_val_find_closest_pair_tm: "val (find_closest_pair_tm (c₀, c₁) ps) = find_closest_pair (c₀, c₁) ps" apply (induction "(c₀, c₁)" ps arbitrary: c₀ c₁ rule: find_closest_pair.induct) (*goals: 1. ‹⋀c₀ c₁. Time_Monad.val (find_closest_pair_tm (c₀, c₁) []) = find_closest_pair (c₀, c₁) []› 2. ‹⋀c₀ c₁ uu_. Time_Monad.val (find_closest_pair_tm (c₀, c₁) [uu_]) = find_closest_pair (c₀, c₁) [uu_]› 3. ‹⋀c₀ c₁ p₀ v va. ⟦⋀x. ⟦x = find_closest p₀ (dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y))) (v # va); dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y)) ≤ dist (case p₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case x of (x, y) ⇒ (real_of_int x, real_of_int y))⟧ ⟹ Time_Monad.val (find_closest_pair_tm (c₀, c₁) (v # va)) = find_closest_pair (c₀, c₁) (v # va); ⋀x. ⟦x = find_closest p₀ (dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y))) (v # va); ¬ dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y)) ≤ dist (case p₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case x of (x, y) ⇒ (real_of_int x, real_of_int y))⟧ ⟹ Time_Monad.val (find_closest_pair_tm (p₀, x) (v # va)) = find_closest_pair (p₀, x) (v # va)⟧ ⟹ Time_Monad.val (find_closest_pair_tm (c₀, c₁) (p₀ # v # va)) = find_closest_pair (c₀, c₁) (p₀ # v # va)› discuss goal 1*) apply ((auto simp: Let_def (*‹Let ?s ?f ≡ ?f ?s›*) find_closest_eq_val_find_closest_tm (*‹Time_Monad.val (find_closest_tm ?p ?δ ?ps) = find_closest ?p ?δ ?ps›*))[1]) (*discuss goal 2*) apply ((auto simp: Let_def (*‹Let ?s ?f ≡ ?f ?s›*) find_closest_eq_val_find_closest_tm (*‹Time_Monad.val (find_closest_tm ?p ?δ ?ps) = find_closest ?p ?δ ?ps›*))[1]) (*discuss goal 3*) apply ((auto simp: Let_def (*‹Let ?s ?f ≡ ?f ?s›*) find_closest_eq_val_find_closest_tm (*‹Time_Monad.val (find_closest_tm ?p ?δ ?ps) = find_closest ?p ?δ ?ps›*))[1]) (*proven 3 subgoals*) . lemma find_closest_pair_set: assumes "(C₀, C₁) = find_closest_pair (c₀, c₁) ps" shows "(C₀ ∈ set ps ∧ C₁ ∈ set ps) ∨ (C₀ = c₀ ∧ C₁ = c₁)" using assms (*‹(C₀, C₁) = find_closest_pair (c₀, c₁) ps›*) proof (induction "(c₀, c₁)" ps arbitrary: c₀ c₁ C₀ C₁ rule: find_closest_pair.induct) (*goals: 1. ‹⋀c₀ c₁ C₀ C₁. (C₀, C₁) = find_closest_pair (c₀, c₁) [] ⟹ C₀ ∈ set [] ∧ C₁ ∈ set [] ∨ C₀ = c₀ ∧ C₁ = c₁› 2. ‹⋀c₀ c₁ uu_ C₀ C₁. (C₀, C₁) = find_closest_pair (c₀, c₁) [uu_] ⟹ C₀ ∈ set [uu_] ∧ C₁ ∈ set [uu_] ∨ C₀ = c₀ ∧ C₁ = c₁› 3. ‹⋀c₀ c₁ p₀ v va C₀ C₁. ⟦⋀x C₀ C₁. ⟦x = find_closest p₀ (dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y))) (v # va); dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y)) ≤ dist (case p₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case x of (x, y) ⇒ (real_of_int x, real_of_int y)); (C₀, C₁) = find_closest_pair (c₀, c₁) (v # va)⟧ ⟹ C₀ ∈ set (v # va) ∧ C₁ ∈ set (v # va) ∨ C₀ = c₀ ∧ C₁ = c₁; ⋀x C₀ C₁. ⟦x = find_closest p₀ (dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y))) (v # va); ¬ dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y)) ≤ dist (case p₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case x of (x, y) ⇒ (real_of_int x, real_of_int y)); (C₀, C₁) = find_closest_pair (p₀, x) (v # va)⟧ ⟹ C₀ ∈ set (v # va) ∧ C₁ ∈ set (v # va) ∨ C₀ = p₀ ∧ C₁ = x; (C₀, C₁) = find_closest_pair (c₀, c₁) (p₀ # v # va)⟧ ⟹ C₀ ∈ set (p₀ # v # va) ∧ C₁ ∈ set (p₀ # v # va) ∨ C₀ = c₀ ∧ C₁ = c₁›*) case (3 c₀ c₁ p₀ p₂ ps) (*‹⟦?x = find_closest p₀ (dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y))) (p₂ # ps); dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y)) ≤ dist (case p₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case ?x of (x, y) ⇒ (real_of_int x, real_of_int y)); (?C₀, ?C₁) = find_closest_pair (c₀, c₁) (p₂ # ps)⟧ ⟹ ?C₀ ∈ set (p₂ # ps) ∧ ?C₁ ∈ set (p₂ # ps) ∨ ?C₀ = c₀ ∧ ?C₁ = c₁› ‹⟦(?x::int × int) = find_closest (p₀::int × int) (dist (case c₀::int × int of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) (case c₁::int × int of (x::int, y::int) ⇒ (real_of_int x, real_of_int y))) ((p₂::int × int) # (ps::(int × int) list)); ¬ dist (case c₀ of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) ≤ dist (case p₀ of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) (case ?x of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)); (?C₀::int × int, ?C₁::int × int) = find_closest_pair (p₀, ?x) (p₂ # ps)⟧ ⟹ ?C₀ ∈ set (p₂ # ps) ∧ ?C₁ ∈ set (p₂ # ps) ∨ ?C₀ = p₀ ∧ ?C₁ = ?x› ‹(C₀::int × int, C₁::int × int) = find_closest_pair (c₀::int × int, c₁::int × int) ((p₀::int × int) # (p₂::int × int) # (ps::(int × int) list))›*) define p₁ where "p₁_def": "p₁ = find_closest p₀ (dist c₀ c₁) (p₂ # ps)" hence A: "p₁ ∈ set (p₂ # ps)" using find_closest_set (*‹0 < length ?ps ⟹ find_closest ?p ?δ ?ps ∈ set ?ps›*) by blast show "?case" (*goal: ‹(C₀::int × int) ∈ set ((p₀::int × int) # (p₂::int × int) # (ps::(int × int) list)) ∧ (C₁::int × int) ∈ set (p₀ # p₂ # ps) ∨ C₀ = (c₀::int × int) ∧ C₁ = (c₁::int × int)›*) proof (cases "dist c₀ c₁ ≤ dist p₀ p₁") (*goals: 1. ‹dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y)) ≤ dist (case p₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₁ of (x, y) ⇒ (real_of_int x, real_of_int y)) ⟹ C₀ ∈ set (p₀ # p₂ # ps) ∧ C₁ ∈ set (p₀ # p₂ # ps) ∨ C₀ = c₀ ∧ C₁ = c₁› 2. ‹¬ dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y)) ≤ dist (case p₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₁ of (x, y) ⇒ (real_of_int x, real_of_int y)) ⟹ C₀ ∈ set (p₀ # p₂ # ps) ∧ C₁ ∈ set (p₀ # p₂ # ps) ∨ C₀ = c₀ ∧ C₁ = c₁›*) case True (*‹dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y)) ≤ dist (case p₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₁ of (x, y) ⇒ (real_of_int x, real_of_int y))›*) obtain C₀' and C₁' where C'_def: "(C₀', C₁') = find_closest_pair (c₀, c₁) (p₂ # ps)" (*goal: ‹(⋀C₀' C₁'. (C₀', C₁') = find_closest_pair (c₀, c₁) (p₂ # ps) ⟹ thesis) ⟹ thesis›*) using prod.collapse (*‹(fst (?prod::?'a × ?'b), snd ?prod) = ?prod›*) by blast note defs = "p₁_def" (*‹p₁ = find_closest p₀ (dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y))) (p₂ # ps)›*) C'_def (*‹(C₀'::int × int, C₁'::int × int) = find_closest_pair (c₀::int × int, c₁::int × int) ((p₂::int × int) # (ps::(int × int) list))›*) hence "(C₀' ∈ set (p₂ # ps) ∧ C₁' ∈ set (p₂ # ps)) ∨ (C₀' = c₀ ∧ C₁' = c₁)" using "3.hyps"(1) (*‹⟦?x = find_closest p₀ (dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y))) (p₂ # ps); dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y)) ≤ dist (case p₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case ?x of (x, y) ⇒ (real_of_int x, real_of_int y)); (?C₀, ?C₁) = find_closest_pair (c₀, c₁) (p₂ # ps)⟧ ⟹ ?C₀ ∈ set (p₂ # ps) ∧ ?C₁ ∈ set (p₂ # ps) ∨ ?C₀ = c₀ ∧ ?C₁ = c₁›*) True (*‹dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y)) ≤ dist (case p₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₁ of (x, y) ⇒ (real_of_int x, real_of_int y))›*) "p₁_def" (*‹p₁ = find_closest p₀ (dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y))) (p₂ # ps)›*) by blast moreover have "C₀ = C₀'" "C₁ = C₁'" using defs (*‹(p₁::int × int) = find_closest (p₀::int × int) (dist (case c₀::int × int of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) (case c₁::int × int of (x::int, y::int) ⇒ (real_of_int x, real_of_int y))) ((p₂::int × int) # (ps::(int × int) list))› ‹(C₀', C₁') = find_closest_pair (c₀, c₁) (p₂ # ps)›*) True (*‹dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y)) ≤ dist (case p₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₁ of (x, y) ⇒ (real_of_int x, real_of_int y))›*) "3.prems" (*‹(C₀, C₁) = find_closest_pair (c₀, c₁) (p₀ # p₂ # ps)›*) apply - (*goals: 1. ‹⟦(p₁::int × int) = find_closest (p₀::int × int) (dist (case c₀::int × int of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) (case c₁::int × int of (x::int, y::int) ⇒ (real_of_int x, real_of_int y))) ((p₂::int × int) # (ps::(int × int) list)); (C₀'::int × int, C₁'::int × int) = find_closest_pair (c₀, c₁) (p₂ # ps); dist (case c₀ of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) ≤ dist (case p₀ of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) (case p₁ of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)); (C₀::int × int, C₁::int × int) = find_closest_pair (c₀, c₁) (p₀ # p₂ # ps)⟧ ⟹ C₀ = C₀'› 2. ‹⟦(p₁::int × int) = find_closest (p₀::int × int) (dist (case c₀::int × int of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) (case c₁::int × int of (x::int, y::int) ⇒ (real_of_int x, real_of_int y))) ((p₂::int × int) # (ps::(int × int) list)); (C₀'::int × int, C₁'::int × int) = find_closest_pair (c₀, c₁) (p₂ # ps); dist (case c₀ of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) ≤ dist (case p₀ of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) (case p₁ of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)); (C₀::int × int, C₁::int × int) = find_closest_pair (c₀, c₁) (p₀ # p₂ # ps)⟧ ⟹ C₁ = C₁'› discuss goal 1*) apply ((auto 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: ‹⟦p₁ = find_closest p₀ (dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y))) (p₂ # ps); (C₀', C₁') = find_closest_pair (c₀, c₁) (p₂ # ps); dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y)) ≤ dist (case p₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₁ of (x, y) ⇒ (real_of_int x, real_of_int y)); (C₀, C₁) = find_closest_pair (c₀, c₁) (p₀ # p₂ # ps)⟧ ⟹ C₀ = C₀'› and 1 goal remains*) apply (metis Pair_inject (*‹⟦(?a, ?b) = (?a', ?b'); ⟦?a = ?a'; ?b = ?b'⟧ ⟹ ?R⟧ ⟹ ?R›*)) (*discuss goal 2*) apply ((auto 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]) (*goal: ‹⟦p₁ = find_closest p₀ (dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y))) (p₂ # ps); (C₀', C₁') = find_closest_pair (c₀, c₁) (p₂ # ps); dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y)) ≤ dist (case p₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₁ of (x, y) ⇒ (real_of_int x, real_of_int y)); (C₀, C₁) = find_closest_pair (c₀, c₁) (p₀ # p₂ # ps)⟧ ⟹ C₁ = C₁'›*) apply (msorry) (*proven 2 subgoals*) . ultimately show "?thesis" (*goal: ‹C₀ ∈ set (p₀ # p₂ # ps) ∧ C₁ ∈ set (p₀ # p₂ # ps) ∨ C₀ = c₀ ∧ C₁ = c₁›*) by auto next (*goal: ‹¬ dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y)) ≤ dist (case p₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₁ of (x, y) ⇒ (real_of_int x, real_of_int y)) ⟹ C₀ ∈ set (p₀ # p₂ # ps) ∧ C₁ ∈ set (p₀ # p₂ # ps) ∨ C₀ = c₀ ∧ C₁ = c₁›*) case False (*‹¬ dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y)) ≤ dist (case p₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₁ of (x, y) ⇒ (real_of_int x, real_of_int y))›*) obtain C₀' and C₁' where C'_def: "(C₀', C₁') = find_closest_pair (p₀, p₁) (p₂ # ps)" (*goal: ‹(⋀C₀' C₁'. (C₀', C₁') = find_closest_pair (p₀, p₁) (p₂ # ps) ⟹ thesis) ⟹ thesis›*) using prod.collapse (*‹(fst ?prod, snd ?prod) = ?prod›*) by blast note defs = "p₁_def" (*‹p₁ = find_closest p₀ (dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y))) (p₂ # ps)›*) C'_def (*‹(C₀', C₁') = find_closest_pair (p₀, p₁) (p₂ # ps)›*) hence "(C₀' ∈ set (p₂ # ps) ∧ C₁' ∈ set (p₂ # ps)) ∨ (C₀' = p₀ ∧ C₁' = p₁)" using "3.hyps"(2) (*‹⟦(?x::int × int) = find_closest (p₀::int × int) (dist (case c₀::int × int of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) (case c₁::int × int of (x::int, y::int) ⇒ (real_of_int x, real_of_int y))) ((p₂::int × int) # (ps::(int × int) list)); ¬ dist (case c₀ of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) ≤ dist (case p₀ of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) (case ?x of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)); (?C₀::int × int, ?C₁::int × int) = find_closest_pair (p₀, ?x) (p₂ # ps)⟧ ⟹ ?C₀ ∈ set (p₂ # ps) ∧ ?C₁ ∈ set (p₂ # ps) ∨ ?C₀ = p₀ ∧ ?C₁ = ?x›*) "p₁_def" (*‹p₁ = find_closest p₀ (dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y))) (p₂ # ps)›*) False (*‹¬ dist (case c₀::int × int of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) (case c₁::int × int of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) ≤ dist (case p₀::int × int of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) (case p₁::int × int of (x::int, y::int) ⇒ (real_of_int x, real_of_int y))›*) by blast moreover have "C₀ = C₀'" "C₁ = C₁'" using defs (*‹p₁ = find_closest p₀ (dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y))) (p₂ # ps)› ‹(C₀', C₁') = find_closest_pair (p₀, p₁) (p₂ # ps)›*) False (*‹¬ dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y)) ≤ dist (case p₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₁ of (x, y) ⇒ (real_of_int x, real_of_int y))›*) "3.prems" (*‹(C₀::int × int, C₁::int × int) = find_closest_pair (c₀::int × int, c₁::int × int) ((p₀::int × int) # (p₂::int × int) # (ps::(int × int) list))›*) apply - (*goals: 1. ‹⟦p₁ = find_closest p₀ (dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y))) (p₂ # ps); (C₀', C₁') = find_closest_pair (p₀, p₁) (p₂ # ps); ¬ dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y)) ≤ dist (case p₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₁ of (x, y) ⇒ (real_of_int x, real_of_int y)); (C₀, C₁) = find_closest_pair (c₀, c₁) (p₀ # p₂ # ps)⟧ ⟹ C₀ = C₀'› 2. ‹⟦p₁ = find_closest p₀ (dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y))) (p₂ # ps); (C₀', C₁') = find_closest_pair (p₀, p₁) (p₂ # ps); ¬ dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y)) ≤ dist (case p₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₁ of (x, y) ⇒ (real_of_int x, real_of_int y)); (C₀, C₁) = find_closest_pair (c₀, c₁) (p₀ # p₂ # ps)⟧ ⟹ C₁ = C₁'› discuss goal 1*) apply ((auto 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: ‹⟦(p₁::int × int) = find_closest (p₀::int × int) (dist (case c₀::int × int of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) (case c₁::int × int of (x::int, y::int) ⇒ (real_of_int x, real_of_int y))) ((p₂::int × int) # (ps::(int × int) list)); (C₀'::int × int, C₁'::int × int) = find_closest_pair (p₀, p₁) (p₂ # ps); ¬ dist (case c₀ of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) ≤ dist (case p₀ of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) (case p₁ of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)); (C₀::int × int, C₁::int × int) = find_closest_pair (c₀, c₁) (p₀ # p₂ # ps)⟧ ⟹ C₀ = C₀'› and 1 goal remains*) apply (metis Pair_inject (*‹⟦(?a::?'a, ?b::?'b) = (?a'::?'a, ?b'::?'b); ⟦?a = ?a'; ?b = ?b'⟧ ⟹ ?R::bool⟧ ⟹ ?R›*)) (*discuss goal 2*) apply ((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))›*))[1]) (*goal: ‹⟦p₁ = find_closest p₀ (dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y))) (p₂ # ps); (C₀', C₁') = find_closest_pair (p₀, p₁) (p₂ # ps); ¬ dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y)) ≤ dist (case p₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₁ of (x, y) ⇒ (real_of_int x, real_of_int y)); (C₀, C₁) = find_closest_pair (c₀, c₁) (p₀ # p₂ # ps)⟧ ⟹ C₁ = C₁'›*) apply (msorry) (*proven 2 subgoals*) . ultimately show "?thesis" (*goal: ‹C₀ ∈ set (p₀ # p₂ # ps) ∧ C₁ ∈ set (p₀ # p₂ # ps) ∨ C₀ = c₀ ∧ C₁ = c₁›*) using A (*‹p₁ ∈ set (p₂ # ps)›*) by auto qed qed (auto) (*solves the remaining goals: 1. ‹⋀c₀ c₁ C₀ C₁. (C₀, C₁) = find_closest_pair (c₀, c₁) [] ⟹ C₀ ∈ set [] ∧ C₁ ∈ set [] ∨ C₀ = c₀ ∧ C₁ = c₁› 2. ‹⋀c₀ c₁ uu_ C₀ C₁. (C₀, C₁) = find_closest_pair (c₀, c₁) [uu_] ⟹ C₀ ∈ set [uu_] ∧ C₁ ∈ set [uu_] ∨ C₀ = c₀ ∧ C₁ = c₁›*) lemma find_closest_pair_c0_ne_c1: "c₀ ≠ c₁ ⟹ distinct ps ⟹ (C₀, C₁) = find_closest_pair (c₀, c₁) ps ⟹ C₀ ≠ C₁" proof (induction "(c₀, c₁)" ps arbitrary: c₀ c₁ C₀ C₁ rule: find_closest_pair.induct) (*goals: 1. ‹⋀c₀ c₁ C₀ C₁. ⟦c₀ ≠ c₁; distinct []; (C₀, C₁) = find_closest_pair (c₀, c₁) []⟧ ⟹ C₀ ≠ C₁› 2. ‹⋀c₀ c₁ uu_ C₀ C₁. ⟦c₀ ≠ c₁; distinct [uu_]; (C₀, C₁) = find_closest_pair (c₀, c₁) [uu_]⟧ ⟹ C₀ ≠ C₁› 3. ‹⋀c₀ c₁ p₀ v va C₀ C₁. ⟦⋀x C₀ C₁. ⟦x = find_closest p₀ (dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y))) (v # va); dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y)) ≤ dist (case p₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case x of (x, y) ⇒ (real_of_int x, real_of_int y)); c₀ ≠ c₁; distinct (v # va); (C₀, C₁) = find_closest_pair (c₀, c₁) (v # va)⟧ ⟹ C₀ ≠ C₁; ⋀x C₀ C₁. ⟦x = find_closest p₀ (dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y))) (v # va); ¬ dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y)) ≤ dist (case p₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case x of (x, y) ⇒ (real_of_int x, real_of_int y)); p₀ ≠ x; distinct (v # va); (C₀, C₁) = find_closest_pair (p₀, x) (v # va)⟧ ⟹ C₀ ≠ C₁; c₀ ≠ c₁; distinct (p₀ # v # va); (C₀, C₁) = find_closest_pair (c₀, c₁) (p₀ # v # va)⟧ ⟹ C₀ ≠ C₁›*) case (3 c₀ c₁ p₀ p₂ ps) (*‹⟦?x = find_closest p₀ (dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y))) (p₂ # ps); dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y)) ≤ dist (case p₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case ?x of (x, y) ⇒ (real_of_int x, real_of_int y)); c₀ ≠ c₁; distinct (p₂ # ps); (?C₀, ?C₁) = find_closest_pair (c₀, c₁) (p₂ # ps)⟧ ⟹ ?C₀ ≠ ?C₁› ‹⟦?x = find_closest p₀ (dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y))) (p₂ # ps); ¬ dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y)) ≤ dist (case p₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case ?x of (x, y) ⇒ (real_of_int x, real_of_int y)); p₀ ≠ ?x; distinct (p₂ # ps); (?C₀, ?C₁) = find_closest_pair (p₀, ?x) (p₂ # ps)⟧ ⟹ ?C₀ ≠ ?C₁› ‹c₀ ≠ c₁› ‹distinct (p₀ # p₂ # ps)› ‹(C₀, C₁) = find_closest_pair (c₀, c₁) (p₀ # p₂ # ps)›*) define p₁ where "p₁_def": "p₁ = find_closest p₀ (dist c₀ c₁) (p₂ # ps)" hence A: "p₀ ≠ p₁" using "3.prems"(1,2) (*‹c₀ ≠ c₁› ‹distinct (p₀ # p₂ # ps)›*) by (metis distinct.simps( (*‹distinct ((?x::?'a) # (?xs::?'a list)) = (?x ∉ set ?xs ∧ distinct ?xs)›*) 2) find_closest_set (*‹(0::nat) < length (?ps::(int × int) list) ⟹ find_closest (?p::int × int) (?δ::real) ?ps ∈ set ?ps›*) length_pos_if_in_set (*‹(?x::?'a) ∈ set (?xs::?'a list) ⟹ (0::nat) < length ?xs›*) list.set_intros( (*‹(?x21.0::?'a) ∈ set (?x21.0 # (?x22.0::?'a list))›*) 1)) show "?case" (*goal: ‹C₀ ≠ C₁›*) proof (cases "dist c₀ c₁ ≤ dist p₀ p₁") (*goals: 1. ‹dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y)) ≤ dist (case p₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₁ of (x, y) ⇒ (real_of_int x, real_of_int y)) ⟹ C₀ ≠ C₁› 2. ‹¬ dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y)) ≤ dist (case p₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₁ of (x, y) ⇒ (real_of_int x, real_of_int y)) ⟹ C₀ ≠ C₁›*) case True (*‹dist (case c₀::int × int of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) (case c₁::int × int of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) ≤ dist (case p₀::int × int of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) (case p₁::int × int of (x::int, y::int) ⇒ (real_of_int x, real_of_int y))›*) obtain C₀' and C₁' where C'_def: "(C₀', C₁') = find_closest_pair (c₀, c₁) (p₂ # ps)" (*goal: ‹(⋀(C₀'::int × int) C₁'::int × int. (C₀', C₁') = find_closest_pair (c₀::int × int, c₁::int × int) ((p₂::int × int) # (ps::(int × int) list)) ⟹ thesis::bool) ⟹ thesis›*) using prod.collapse (*‹(fst ?prod, snd ?prod) = ?prod›*) by blast note defs = "p₁_def" (*‹p₁ = find_closest p₀ (dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y))) (p₂ # ps)›*) C'_def (*‹(C₀', C₁') = find_closest_pair (c₀, c₁) (p₂ # ps)›*) hence "C₀' ≠ C₁'" using "3.hyps"(1) (*‹⟦(?x::int × int) = find_closest (p₀::int × int) (dist (case c₀::int × int of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) (case c₁::int × int of (x::int, y::int) ⇒ (real_of_int x, real_of_int y))) ((p₂::int × int) # (ps::(int × int) list)); dist (case c₀ of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) ≤ dist (case p₀ of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) (case ?x of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)); c₀ ≠ c₁; distinct (p₂ # ps); (?C₀::int × int, ?C₁::int × int) = find_closest_pair (c₀, c₁) (p₂ # ps)⟧ ⟹ ?C₀ ≠ ?C₁›*) "3.prems"(1,2) (*‹c₀ ≠ c₁› ‹distinct (p₀ # p₂ # ps)›*) True (*‹dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y)) ≤ dist (case p₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₁ of (x, y) ⇒ (real_of_int x, real_of_int y))›*) "p₁_def" (*‹(p₁::int × int) = find_closest (p₀::int × int) (dist (case c₀::int × int of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) (case c₁::int × int of (x::int, y::int) ⇒ (real_of_int x, real_of_int y))) ((p₂::int × int) # (ps::(int × int) list))›*) by simp moreover have "C₀ = C₀'" "C₁ = C₁'" using defs (*‹p₁ = find_closest p₀ (dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y))) (p₂ # ps)› ‹(C₀', C₁') = find_closest_pair (c₀, c₁) (p₂ # ps)›*) True (*‹dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y)) ≤ dist (case p₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₁ of (x, y) ⇒ (real_of_int x, real_of_int y))›*) "3.prems"(3) (*‹(C₀, C₁) = find_closest_pair (c₀, c₁) (p₀ # p₂ # ps)›*) apply - (*goals: 1. ‹⟦p₁ = find_closest p₀ (dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y))) (p₂ # ps); (C₀', C₁') = find_closest_pair (c₀, c₁) (p₂ # ps); dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y)) ≤ dist (case p₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₁ of (x, y) ⇒ (real_of_int x, real_of_int y)); (C₀, C₁) = find_closest_pair (c₀, c₁) (p₀ # p₂ # ps)⟧ ⟹ C₀ = C₀'› 2. ‹⟦p₁ = find_closest p₀ (dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y))) (p₂ # ps); (C₀', C₁') = find_closest_pair (c₀, c₁) (p₂ # ps); dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y)) ≤ dist (case p₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₁ of (x, y) ⇒ (real_of_int x, real_of_int y)); (C₀, C₁) = find_closest_pair (c₀, c₁) (p₀ # p₂ # ps)⟧ ⟹ C₁ = C₁'› discuss goal 1*) apply ((auto 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: ‹⟦p₁ = find_closest p₀ (dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y))) (p₂ # ps); (C₀', C₁') = find_closest_pair (c₀, c₁) (p₂ # ps); dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y)) ≤ dist (case p₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₁ of (x, y) ⇒ (real_of_int x, real_of_int y)); (C₀, C₁) = find_closest_pair (c₀, c₁) (p₀ # p₂ # ps)⟧ ⟹ C₀ = C₀'› and 1 goal remains*) apply (metis Pair_inject (*‹⟦(?a, ?b) = (?a', ?b'); ⟦?a = ?a'; ?b = ?b'⟧ ⟹ ?R⟧ ⟹ ?R›*)) (*discuss goal 2*) apply ((auto 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]) (*goal: ‹⟦p₁ = find_closest p₀ (dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y))) (p₂ # ps); (C₀', C₁') = find_closest_pair (c₀, c₁) (p₂ # ps); dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y)) ≤ dist (case p₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₁ of (x, y) ⇒ (real_of_int x, real_of_int y)); (C₀, C₁) = find_closest_pair (c₀, c₁) (p₀ # p₂ # ps)⟧ ⟹ C₁ = C₁'›*) apply (msorry) (*proven 2 subgoals*) . ultimately show "?thesis" (*goal: ‹(C₀::int × int) ≠ (C₁::int × int)›*) by simp next (*goal: ‹¬ dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y)) ≤ dist (case p₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₁ of (x, y) ⇒ (real_of_int x, real_of_int y)) ⟹ C₀ ≠ C₁›*) case False (*‹¬ dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y)) ≤ dist (case p₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₁ of (x, y) ⇒ (real_of_int x, real_of_int y))›*) obtain C₀' and C₁' where C'_def: "(C₀', C₁') = find_closest_pair (p₀, p₁) (p₂ # ps)" (*goal: ‹(⋀C₀' C₁'. (C₀', C₁') = find_closest_pair (p₀, p₁) (p₂ # ps) ⟹ thesis) ⟹ thesis›*) using prod.collapse (*‹(fst (?prod::?'a × ?'b), snd ?prod) = ?prod›*) by blast note defs = "p₁_def" (*‹(p₁::int × int) = find_closest (p₀::int × int) (dist (case c₀::int × int of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) (case c₁::int × int of (x::int, y::int) ⇒ (real_of_int x, real_of_int y))) ((p₂::int × int) # (ps::(int × int) list))›*) C'_def (*‹(C₀'::int × int, C₁'::int × int) = find_closest_pair (p₀::int × int, p₁::int × int) ((p₂::int × int) # (ps::(int × int) list))›*) hence "C₀' ≠ C₁'" using "3.hyps"(2) (*‹⟦?x = find_closest p₀ (dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y))) (p₂ # ps); ¬ dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y)) ≤ dist (case p₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case ?x of (x, y) ⇒ (real_of_int x, real_of_int y)); p₀ ≠ ?x; distinct (p₂ # ps); (?C₀, ?C₁) = find_closest_pair (p₀, ?x) (p₂ # ps)⟧ ⟹ ?C₀ ≠ ?C₁›*) "3.prems"(2) (*‹distinct (p₀ # p₂ # ps)›*) A (*‹p₀ ≠ p₁›*) False (*‹¬ dist (case c₀::int × int of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) (case c₁::int × int of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) ≤ dist (case p₀::int × int of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) (case p₁::int × int of (x::int, y::int) ⇒ (real_of_int x, real_of_int y))›*) "p₁_def" (*‹p₁ = find_closest p₀ (dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y))) (p₂ # ps)›*) by simp moreover have "C₀ = C₀'" "C₁ = C₁'" using defs (*‹p₁ = find_closest p₀ (dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y))) (p₂ # ps)› ‹(C₀', C₁') = find_closest_pair (p₀, p₁) (p₂ # ps)›*) False (*‹¬ dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y)) ≤ dist (case p₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₁ of (x, y) ⇒ (real_of_int x, real_of_int y))›*) "3.prems"(3) (*‹(C₀, C₁) = find_closest_pair (c₀, c₁) (p₀ # p₂ # ps)›*) apply - (*goals: 1. ‹⟦p₁ = find_closest p₀ (dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y))) (p₂ # ps); (C₀', C₁') = find_closest_pair (p₀, p₁) (p₂ # ps); ¬ dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y)) ≤ dist (case p₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₁ of (x, y) ⇒ (real_of_int x, real_of_int y)); (C₀, C₁) = find_closest_pair (c₀, c₁) (p₀ # p₂ # ps)⟧ ⟹ C₀ = C₀'› 2. ‹⟦p₁ = find_closest p₀ (dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y))) (p₂ # ps); (C₀', C₁') = find_closest_pair (p₀, p₁) (p₂ # ps); ¬ dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y)) ≤ dist (case p₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₁ of (x, y) ⇒ (real_of_int x, real_of_int y)); (C₀, C₁) = find_closest_pair (c₀, c₁) (p₀ # p₂ # ps)⟧ ⟹ C₁ = C₁'› discuss goal 1*) apply ((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))›*))[1]) (*top goal: ‹⟦p₁ = find_closest p₀ (dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y))) (p₂ # ps); (C₀', C₁') = find_closest_pair (p₀, p₁) (p₂ # ps); ¬ dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y)) ≤ dist (case p₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₁ of (x, y) ⇒ (real_of_int x, real_of_int y)); (C₀, C₁) = find_closest_pair (c₀, c₁) (p₀ # p₂ # ps)⟧ ⟹ C₀ = C₀'› and 1 goal remains*) apply (metis Pair_inject (*‹⟦(?a, ?b) = (?a', ?b'); ⟦?a = ?a'; ?b = ?b'⟧ ⟹ ?R⟧ ⟹ ?R›*)) (*discuss goal 2*) apply ((auto 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]) (*goal: ‹⟦p₁ = find_closest p₀ (dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y))) (p₂ # ps); (C₀', C₁') = find_closest_pair (p₀, p₁) (p₂ # ps); ¬ dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y)) ≤ dist (case p₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₁ of (x, y) ⇒ (real_of_int x, real_of_int y)); (C₀, C₁) = find_closest_pair (c₀, c₁) (p₀ # p₂ # ps)⟧ ⟹ C₁ = C₁'›*) apply (msorry) (*proven 2 subgoals*) . ultimately show "?thesis" (*goal: ‹C₀ ≠ C₁›*) by simp qed qed (auto) (*solves the remaining goals: 1. ‹⋀c₀ c₁ C₀ C₁. ⟦c₀ ≠ c₁; distinct []; (C₀, C₁) = find_closest_pair (c₀, c₁) []⟧ ⟹ C₀ ≠ C₁› 2. ‹⋀c₀ c₁ uu_ C₀ C₁. ⟦c₀ ≠ c₁; distinct [uu_]; (C₀, C₁) = find_closest_pair (c₀, c₁) [uu_]⟧ ⟹ C₀ ≠ C₁›*) lemma find_closest_pair_dist_mono: assumes "(C₀, C₁) = find_closest_pair (c₀, c₁) ps" shows "dist C₀ C₁ ≤ dist c₀ c₁" using assms (*‹(C₀::int × int, C₁::int × int) = find_closest_pair (c₀::int × int, c₁::int × int) (ps::(int × int) list)›*) proof (induction "(c₀, c₁)" ps arbitrary: c₀ c₁ C₀ C₁ rule: find_closest_pair.induct) (*goals: 1. ‹⋀c₀ c₁ C₀ C₁. (C₀, C₁) = find_closest_pair (c₀, c₁) [] ⟹ dist (case C₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case C₁ of (x, y) ⇒ (real_of_int x, real_of_int y)) ≤ dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y))› 2. ‹⋀c₀ c₁ uu_ C₀ C₁. (C₀, C₁) = find_closest_pair (c₀, c₁) [uu_] ⟹ dist (case C₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case C₁ of (x, y) ⇒ (real_of_int x, real_of_int y)) ≤ dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y))› 3. ‹⋀c₀ c₁ p₀ v va C₀ C₁. ⟦⋀x C₀ C₁. ⟦x = find_closest p₀ (dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y))) (v # va); dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y)) ≤ dist (case p₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case x of (x, y) ⇒ (real_of_int x, real_of_int y)); (C₀, C₁) = find_closest_pair (c₀, c₁) (v # va)⟧ ⟹ dist (case C₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case C₁ of (x, y) ⇒ (real_of_int x, real_of_int y)) ≤ dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y)); ⋀x C₀ C₁. ⟦x = find_closest p₀ (dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y))) (v # va); ¬ dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y)) ≤ dist (case p₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case x of (x, y) ⇒ (real_of_int x, real_of_int y)); (C₀, C₁) = find_closest_pair (p₀, x) (v # va)⟧ ⟹ dist (case C₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case C₁ of (x, y) ⇒ (real_of_int x, real_of_int y)) ≤ dist (case p₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case x of (x, y) ⇒ (real_of_int x, real_of_int y)); (C₀, C₁) = find_closest_pair (c₀, c₁) (p₀ # v # va)⟧ ⟹ dist (case C₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case C₁ of (x, y) ⇒ (real_of_int x, real_of_int y)) ≤ dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y))›*) case (3 c₀ c₁ p₀ p₂ ps) (*‹⟦?x = find_closest p₀ (dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y))) (p₂ # ps); dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y)) ≤ dist (case p₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case ?x of (x, y) ⇒ (real_of_int x, real_of_int y)); (?C₀, ?C₁) = find_closest_pair (c₀, c₁) (p₂ # ps)⟧ ⟹ dist (case ?C₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case ?C₁ of (x, y) ⇒ (real_of_int x, real_of_int y)) ≤ dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y))› ‹⟦?x = find_closest p₀ (dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y))) (p₂ # ps); ¬ dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y)) ≤ dist (case p₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case ?x of (x, y) ⇒ (real_of_int x, real_of_int y)); (?C₀, ?C₁) = find_closest_pair (p₀, ?x) (p₂ # ps)⟧ ⟹ dist (case ?C₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case ?C₁ of (x, y) ⇒ (real_of_int x, real_of_int y)) ≤ dist (case p₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case ?x of (x, y) ⇒ (real_of_int x, real_of_int y))› ‹(C₀, C₁) = find_closest_pair (c₀, c₁) (p₀ # p₂ # ps)›*) define p₁ where "p₁_def": "p₁ = find_closest p₀ (dist c₀ c₁) (p₂ # ps)" show "?case" (*goal: ‹dist (case C₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case C₁ of (x, y) ⇒ (real_of_int x, real_of_int y)) ≤ dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y))›*) proof (cases "dist c₀ c₁ ≤ dist p₀ p₁") (*goals: 1. ‹dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y)) ≤ dist (case p₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₁ of (x, y) ⇒ (real_of_int x, real_of_int y)) ⟹ dist (case C₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case C₁ of (x, y) ⇒ (real_of_int x, real_of_int y)) ≤ dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y))› 2. ‹¬ dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y)) ≤ dist (case p₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₁ of (x, y) ⇒ (real_of_int x, real_of_int y)) ⟹ dist (case C₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case C₁ of (x, y) ⇒ (real_of_int x, real_of_int y)) ≤ dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y))›*) case True (*‹dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y)) ≤ dist (case p₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₁ of (x, y) ⇒ (real_of_int x, real_of_int y))›*) obtain C₀' and C₁' where C'_def: "(C₀', C₁') = find_closest_pair (c₀, c₁) (p₂ # ps)" (*goal: ‹(⋀C₀' C₁'. (C₀', C₁') = find_closest_pair (c₀, c₁) (p₂ # ps) ⟹ thesis) ⟹ thesis›*) using prod.collapse (*‹(fst ?prod, snd ?prod) = ?prod›*) by blast note defs = "p₁_def" (*‹p₁ = find_closest p₀ (dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y))) (p₂ # ps)›*) C'_def (*‹(C₀', C₁') = find_closest_pair (c₀, c₁) (p₂ # ps)›*) hence "dist C₀' C₁' ≤ dist c₀ c₁" using "3.hyps"(1) (*‹⟦?x = find_closest p₀ (dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y))) (p₂ # ps); dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y)) ≤ dist (case p₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case ?x of (x, y) ⇒ (real_of_int x, real_of_int y)); (?C₀, ?C₁) = find_closest_pair (c₀, c₁) (p₂ # ps)⟧ ⟹ dist (case ?C₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case ?C₁ of (x, y) ⇒ (real_of_int x, real_of_int y)) ≤ dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y))›*) True (*‹dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y)) ≤ dist (case p₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₁ of (x, y) ⇒ (real_of_int x, real_of_int y))›*) "p₁_def" (*‹p₁ = find_closest p₀ (dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y))) (p₂ # ps)›*) by simp moreover have "C₀ = C₀'" "C₁ = C₁'" using defs (*‹p₁ = find_closest p₀ (dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y))) (p₂ # ps)› ‹(C₀', C₁') = find_closest_pair (c₀, c₁) (p₂ # ps)›*) True (*‹dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y)) ≤ dist (case p₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₁ of (x, y) ⇒ (real_of_int x, real_of_int y))›*) "3.prems" (*‹(C₀, C₁) = find_closest_pair (c₀, c₁) (p₀ # p₂ # ps)›*) apply - (*goals: 1. ‹⟦p₁ = find_closest p₀ (dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y))) (p₂ # ps); (C₀', C₁') = find_closest_pair (c₀, c₁) (p₂ # ps); dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y)) ≤ dist (case p₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₁ of (x, y) ⇒ (real_of_int x, real_of_int y)); (C₀, C₁) = find_closest_pair (c₀, c₁) (p₀ # p₂ # ps)⟧ ⟹ C₀ = C₀'› 2. ‹⟦p₁ = find_closest p₀ (dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y))) (p₂ # ps); (C₀', C₁') = find_closest_pair (c₀, c₁) (p₂ # ps); dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y)) ≤ dist (case p₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₁ of (x, y) ⇒ (real_of_int x, real_of_int y)); (C₀, C₁) = find_closest_pair (c₀, c₁) (p₀ # p₂ # ps)⟧ ⟹ C₁ = C₁'› discuss goal 1*) apply ((auto 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]) (*top goal: ‹⟦(p₁::int × int) = find_closest (p₀::int × int) (dist (case c₀::int × int of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) (case c₁::int × int of (x::int, y::int) ⇒ (real_of_int x, real_of_int y))) ((p₂::int × int) # (ps::(int × int) list)); (C₀'::int × int, C₁'::int × int) = find_closest_pair (c₀, c₁) (p₂ # ps); dist (case c₀ of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) ≤ dist (case p₀ of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) (case p₁ of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)); (C₀::int × int, C₁::int × int) = find_closest_pair (c₀, c₁) (p₀ # p₂ # ps)⟧ ⟹ C₀ = C₀'› and 1 goal remains*) apply (metis Pair_inject (*‹⟦(?a, ?b) = (?a', ?b'); ⟦?a = ?a'; ?b = ?b'⟧ ⟹ ?R⟧ ⟹ ?R›*)) (*discuss goal 2*) apply ((auto 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]) (*goal: ‹⟦p₁ = find_closest p₀ (dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y))) (p₂ # ps); (C₀', C₁') = find_closest_pair (c₀, c₁) (p₂ # ps); dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y)) ≤ dist (case p₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₁ of (x, y) ⇒ (real_of_int x, real_of_int y)); (C₀, C₁) = find_closest_pair (c₀, c₁) (p₀ # p₂ # ps)⟧ ⟹ C₁ = C₁'›*) apply (msorry) (*proven 2 subgoals*) . ultimately show "?thesis" (*goal: ‹dist (case C₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case C₁ of (x, y) ⇒ (real_of_int x, real_of_int y)) ≤ dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y))›*) by simp next (*goal: ‹¬ dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y)) ≤ dist (case p₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₁ of (x, y) ⇒ (real_of_int x, real_of_int y)) ⟹ dist (case C₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case C₁ of (x, y) ⇒ (real_of_int x, real_of_int y)) ≤ dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y))›*) case False (*‹¬ dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y)) ≤ dist (case p₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₁ of (x, y) ⇒ (real_of_int x, real_of_int y))›*) obtain C₀' and C₁' where C'_def: "(C₀', C₁') = find_closest_pair (p₀, p₁) (p₂ # ps)" (*goal: ‹(⋀C₀' C₁'. (C₀', C₁') = find_closest_pair (p₀, p₁) (p₂ # ps) ⟹ thesis) ⟹ thesis›*) using prod.collapse (*‹(fst ?prod, snd ?prod) = ?prod›*) by blast note defs = "p₁_def" (*‹p₁ = find_closest p₀ (dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y))) (p₂ # ps)›*) C'_def (*‹(C₀'::int × int, C₁'::int × int) = find_closest_pair (p₀::int × int, p₁::int × int) ((p₂::int × int) # (ps::(int × int) list))›*) hence "dist C₀' C₁' ≤ dist p₀ p₁" using "3.hyps"(2) (*‹⟦?x = find_closest p₀ (dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y))) (p₂ # ps); ¬ dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y)) ≤ dist (case p₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case ?x of (x, y) ⇒ (real_of_int x, real_of_int y)); (?C₀, ?C₁) = find_closest_pair (p₀, ?x) (p₂ # ps)⟧ ⟹ dist (case ?C₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case ?C₁ of (x, y) ⇒ (real_of_int x, real_of_int y)) ≤ dist (case p₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case ?x of (x, y) ⇒ (real_of_int x, real_of_int y))›*) False (*‹¬ dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y)) ≤ dist (case p₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₁ of (x, y) ⇒ (real_of_int x, real_of_int y))›*) "p₁_def" (*‹p₁ = find_closest p₀ (dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y))) (p₂ # ps)›*) by blast moreover have "C₀ = C₀'" "C₁ = C₁'" using defs (*‹p₁ = find_closest p₀ (dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y))) (p₂ # ps)› ‹(C₀'::int × int, C₁'::int × int) = find_closest_pair (p₀::int × int, p₁::int × int) ((p₂::int × int) # (ps::(int × int) list))›*) False (*‹¬ dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y)) ≤ dist (case p₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₁ of (x, y) ⇒ (real_of_int x, real_of_int y))›*) "3.prems"(1) (*‹(C₀, C₁) = find_closest_pair (c₀, c₁) (p₀ # p₂ # ps)›*) apply - (*goals: 1. ‹⟦p₁ = find_closest p₀ (dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y))) (p₂ # ps); (C₀', C₁') = find_closest_pair (p₀, p₁) (p₂ # ps); ¬ dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y)) ≤ dist (case p₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₁ of (x, y) ⇒ (real_of_int x, real_of_int y)); (C₀, C₁) = find_closest_pair (c₀, c₁) (p₀ # p₂ # ps)⟧ ⟹ C₀ = C₀'› 2. ‹⟦p₁ = find_closest p₀ (dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y))) (p₂ # ps); (C₀', C₁') = find_closest_pair (p₀, p₁) (p₂ # ps); ¬ dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y)) ≤ dist (case p₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₁ of (x, y) ⇒ (real_of_int x, real_of_int y)); (C₀, C₁) = find_closest_pair (c₀, c₁) (p₀ # p₂ # ps)⟧ ⟹ C₁ = C₁'› discuss goal 1*) apply ((auto 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: ‹⟦(p₁::int × int) = find_closest (p₀::int × int) (dist (case c₀::int × int of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) (case c₁::int × int of (x::int, y::int) ⇒ (real_of_int x, real_of_int y))) ((p₂::int × int) # (ps::(int × int) list)); (C₀'::int × int, C₁'::int × int) = find_closest_pair (p₀, p₁) (p₂ # ps); ¬ dist (case c₀ of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) ≤ dist (case p₀ of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) (case p₁ of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)); (C₀::int × int, C₁::int × int) = find_closest_pair (c₀, c₁) (p₀ # p₂ # ps)⟧ ⟹ C₀ = C₀'› and 1 goal remains*) apply (metis Pair_inject (*‹⟦(?a, ?b) = (?a', ?b'); ⟦?a = ?a'; ?b = ?b'⟧ ⟹ ?R⟧ ⟹ ?R›*)) (*discuss goal 2*) apply ((auto 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]) (*goal: ‹⟦p₁ = find_closest p₀ (dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y))) (p₂ # ps); (C₀', C₁') = find_closest_pair (p₀, p₁) (p₂ # ps); ¬ dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y)) ≤ dist (case p₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₁ of (x, y) ⇒ (real_of_int x, real_of_int y)); (C₀, C₁) = find_closest_pair (c₀, c₁) (p₀ # p₂ # ps)⟧ ⟹ C₁ = C₁'›*) apply (msorry) (*proven 2 subgoals*) . ultimately show "?thesis" (*goal: ‹dist (case C₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case C₁ of (x, y) ⇒ (real_of_int x, real_of_int y)) ≤ dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y))›*) using False (*‹¬ dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y)) ≤ dist (case p₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₁ of (x, y) ⇒ (real_of_int x, real_of_int y))›*) by simp qed qed (auto) (*solves the remaining goals: 1. ‹⋀(c₀::int × int) (c₁::int × int) (C₀::int × int) C₁::int × int. (C₀, C₁) = find_closest_pair (c₀, c₁) [] ⟹ dist (case C₀ of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) (case C₁ of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) ≤ dist (case c₀ of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x::int, y::int) ⇒ (real_of_int x, real_of_int y))› 2. ‹⋀(c₀::int × int) (c₁::int × int) (uu_::int × int) (C₀::int × int) C₁::int × int. (C₀, C₁) = find_closest_pair (c₀, c₁) [uu_] ⟹ dist (case C₀ of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) (case C₁ of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) ≤ dist (case c₀ of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x::int, y::int) ⇒ (real_of_int x, real_of_int y))›*) lemma find_closest_pair_dist: assumes "sorted_snd ps" "(C₀, C₁) = find_closest_pair (c₀, c₁) ps" shows "sparse (dist C₀ C₁) (set ps)" using assms (*‹sorted_snd ps› ‹(C₀, C₁) = find_closest_pair (c₀, c₁) ps›*) proof (induction "(c₀, c₁)" ps arbitrary: c₀ c₁ C₀ C₁ rule: find_closest_pair.induct) (*goals: 1. ‹⋀(c₀::int × int) (c₁::int × int) (C₀::int × int) C₁::int × int. ⟦sorted_snd []; (C₀, C₁) = find_closest_pair (c₀, c₁) []⟧ ⟹ sparse (dist (case C₀ of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) (case C₁ of (x::int, y::int) ⇒ (real_of_int x, real_of_int y))) (set [])› 2. ‹⋀(c₀::int × int) (c₁::int × int) (uu_::int × int) (C₀::int × int) C₁::int × int. ⟦sorted_snd [uu_]; (C₀, C₁) = find_closest_pair (c₀, c₁) [uu_]⟧ ⟹ sparse (dist (case C₀ of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) (case C₁ of (x::int, y::int) ⇒ (real_of_int x, real_of_int y))) (set [uu_])› 3. ‹⋀(c₀::int × int) (c₁::int × int) (p₀::int × int) (v::int × int) (va::(int × int) list) (C₀::int × int) C₁::int × int. ⟦⋀(x::int × int) (C₀::int × int) C₁::int × int. ⟦x = find_closest p₀ (dist (case c₀ of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x::int, y::int) ⇒ (real_of_int x, real_of_int y))) (v # va); dist (case c₀ of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) ≤ dist (case p₀ of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) (case x of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)); sorted_snd (v # va); (C₀, C₁) = find_closest_pair (c₀, c₁) (v # va)⟧ ⟹ sparse (dist (case C₀ of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) (case C₁ of (x::int, y::int) ⇒ (real_of_int x, real_of_int y))) (set (v # va)); ⋀(x::int × int) (C₀::int × int) C₁::int × int. ⟦x = find_closest p₀ (dist (case c₀ of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x::int, y::int) ⇒ (real_of_int x, real_of_int y))) (v # va); ¬ dist (case c₀ of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) ≤ dist (case p₀ of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) (case x of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)); sorted_snd (v # va); (C₀, C₁) = find_closest_pair (p₀, x) (v # va)⟧ ⟹ sparse (dist (case C₀ of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) (case C₁ of (x::int, y::int) ⇒ (real_of_int x, real_of_int y))) (set (v # va)); sorted_snd (p₀ # v # va); (C₀, C₁) = find_closest_pair (c₀, c₁) (p₀ # v # va)⟧ ⟹ sparse (dist (case C₀ of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) (case C₁ of (x::int, y::int) ⇒ (real_of_int x, real_of_int y))) (set (p₀ # v # va))›*) case (3 c₀ c₁ p₀ p₂ ps) (*‹⟦?x = find_closest p₀ (dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y))) (p₂ # ps); dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y)) ≤ dist (case p₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case ?x of (x, y) ⇒ (real_of_int x, real_of_int y)); sorted_snd (p₂ # ps); (?C₀, ?C₁) = find_closest_pair (c₀, c₁) (p₂ # ps)⟧ ⟹ sparse (dist (case ?C₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case ?C₁ of (x, y) ⇒ (real_of_int x, real_of_int y))) (set (p₂ # ps))› ‹⟦?x = find_closest p₀ (dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y))) (p₂ # ps); ¬ dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y)) ≤ dist (case p₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case ?x of (x, y) ⇒ (real_of_int x, real_of_int y)); sorted_snd (p₂ # ps); (?C₀, ?C₁) = find_closest_pair (p₀, ?x) (p₂ # ps)⟧ ⟹ sparse (dist (case ?C₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case ?C₁ of (x, y) ⇒ (real_of_int x, real_of_int y))) (set (p₂ # ps))› ‹sorted_snd (p₀ # p₂ # ps)› ‹(C₀::int × int, C₁::int × int) = find_closest_pair (c₀::int × int, c₁::int × int) ((p₀::int × int) # (p₂::int × int) # (ps::(int × int) list))›*) define p₁ where "p₁_def": "p₁ = find_closest p₀ (dist c₀ c₁) (p₂ # ps)" show "?case" (*goal: ‹sparse (dist (case C₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case C₁ of (x, y) ⇒ (real_of_int x, real_of_int y))) (set (p₀ # p₂ # ps))›*) proof (cases) (*goals: 1. ‹?P::bool ⟹ sparse (dist (case C₀::int × int of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) (case C₁::int × int of (x::int, y::int) ⇒ (real_of_int x, real_of_int y))) (set ((p₀::int × int) # (p₂::int × int) # (ps::(int × int) list)))› 2. ‹¬ (?P::bool) ⟹ sparse (dist (case C₀::int × int of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) (case C₁::int × int of (x::int, y::int) ⇒ (real_of_int x, real_of_int y))) (set ((p₀::int × int) # (p₂::int × int) # (ps::(int × int) list)))›*) assume "∃p ∈ set (p₂ # ps). dist p₀ p < dist c₀ c₁" (*‹∃p::int × int∈set ((p₂::int × int) # (ps::(int × int) list)). dist (case p₀::int × int of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) (case p of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) < dist (case c₀::int × int of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) (case c₁::int × int of (x::int, y::int) ⇒ (real_of_int x, real_of_int y))›*) hence A: "∀p ∈ set (p₂ # ps). dist p₀ p₁ ≤ dist p₀ p" "dist p₀ p₁ < dist c₀ c₁" using "p₁_def" (*‹p₁ = find_closest p₀ (dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y))) (p₂ # ps)›*) find_closest_dist (*‹⟦sorted_snd (?p # ?ps); ∃q∈set ?ps. dist (case ?p of (x, y) ⇒ (real_of_int x, real_of_int y)) (case q of (x, y) ⇒ (real_of_int x, real_of_int y)) < ?δ⟧ ⟹ ∀q∈set ?ps. dist (case ?p of (x, y) ⇒ (real_of_int x, real_of_int y)) (case find_closest ?p ?δ ?ps of (x, y) ⇒ (real_of_int x, real_of_int y)) ≤ dist (case ?p of (x, y) ⇒ (real_of_int x, real_of_int y)) (case q of (x, y) ⇒ (real_of_int x, real_of_int y))›*) "3.prems"(1) (*‹sorted_snd ((p₀::int × int) # (p₂::int × int) # (ps::(int × int) list))›*) le_less_trans (*‹⟦?x ≤ ?y; ?y < ?z⟧ ⟹ ?x < ?z›*) apply - (*goals: 1. ‹⟦∃p∈set (p₂ # ps). dist (case p₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p of (x, y) ⇒ (real_of_int x, real_of_int y)) < dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y)); p₁ = find_closest p₀ (dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y))) (p₂ # ps); ⋀p ps δ. ⟦sorted_snd (p # ps); ∃q∈set ps. dist (case p of (x, y) ⇒ (real_of_int x, real_of_int y)) (case q of (x, y) ⇒ (real_of_int x, real_of_int y)) < δ⟧ ⟹ ∀q∈set ps. dist (case p of (x, y) ⇒ (real_of_int x, real_of_int y)) (case find_closest p δ ps of (x, y) ⇒ (real_of_int x, real_of_int y)) ≤ dist (case p of (x, y) ⇒ (real_of_int x, real_of_int y)) (case q of (x, y) ⇒ (real_of_int x, real_of_int y)); sorted_snd (p₀ # p₂ # ps); ⋀x y z. ⟦x ≤ y; y < z⟧ ⟹ x < z⟧ ⟹ ∀p∈set (p₂ # ps). dist (case p₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₁ of (x, y) ⇒ (real_of_int x, real_of_int y)) ≤ dist (case p₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p of (x, y) ⇒ (real_of_int x, real_of_int y))› 2. ‹⟦∃p∈set (p₂ # ps). dist (case p₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p of (x, y) ⇒ (real_of_int x, real_of_int y)) < dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y)); p₁ = find_closest p₀ (dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y))) (p₂ # ps); ⋀p ps δ. ⟦sorted_snd (p # ps); ∃q∈set ps. dist (case p of (x, y) ⇒ (real_of_int x, real_of_int y)) (case q of (x, y) ⇒ (real_of_int x, real_of_int y)) < δ⟧ ⟹ ∀q∈set ps. dist (case p of (x, y) ⇒ (real_of_int x, real_of_int y)) (case find_closest p δ ps of (x, y) ⇒ (real_of_int x, real_of_int y)) ≤ dist (case p of (x, y) ⇒ (real_of_int x, real_of_int y)) (case q of (x, y) ⇒ (real_of_int x, real_of_int y)); sorted_snd (p₀ # p₂ # ps); ⋀x y z. ⟦x ≤ y; y < z⟧ ⟹ x < z⟧ ⟹ dist (case p₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₁ of (x, y) ⇒ (real_of_int x, real_of_int y)) < dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y))› discuss goal 1*) apply blast (*discuss goal 2*) apply blast (*proven 2 subgoals*) . obtain C₀' and C₁' where C'_def: "(C₀', C₁') = find_closest_pair (p₀, p₁) (p₂ # ps)" (*goal: ‹(⋀C₀' C₁'. (C₀', C₁') = find_closest_pair (p₀, p₁) (p₂ # ps) ⟹ thesis) ⟹ thesis›*) using prod.collapse (*‹(fst ?prod, snd ?prod) = ?prod›*) by blast hence B: "(C₀', C₁') = find_closest_pair (c₀, c₁) (p₀ # p₂ # ps)" using A(2) (*‹dist (case p₀::int × int of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) (case p₁::int × int of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) < dist (case c₀::int × int of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) (case c₁::int × int of (x::int, y::int) ⇒ (real_of_int x, real_of_int y))›*) "p₁_def" (*‹p₁ = find_closest p₀ (dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y))) (p₂ # ps)›*) by simp have "sparse (dist C₀' C₁') (set (p₂ # ps))" using "3.hyps"(2)[of p₁ C₀' C₁'] (*‹⟦p₁ = find_closest p₀ (dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y))) (p₂ # ps); ¬ dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y)) ≤ dist (case p₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₁ of (x, y) ⇒ (real_of_int x, real_of_int y)); sorted_snd (p₂ # ps); (C₀', C₁') = find_closest_pair (p₀, p₁) (p₂ # ps)⟧ ⟹ sparse (dist (case C₀' of (x, y) ⇒ (real_of_int x, real_of_int y)) (case C₁' of (x, y) ⇒ (real_of_int x, real_of_int y))) (set (p₂ # ps))›*) "p₁_def" (*‹p₁ = find_closest p₀ (dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y))) (p₂ # ps)›*) C'_def (*‹(C₀', C₁') = find_closest_pair (p₀, p₁) (p₂ # ps)›*) "3.prems"(1) (*‹sorted_snd (p₀ # p₂ # ps)›*) A(2) (*‹dist (case p₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₁ of (x, y) ⇒ (real_of_int x, real_of_int y)) < dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y))›*) sorted_snd_def (*‹sorted_snd ?ps = sorted_wrt (λp₀ p₁. snd p₀ ≤ snd p₁) ?ps›*) by fastforce moreover have "dist C₀' C₁' ≤ dist p₀ p₁" using C'_def (*‹(C₀', C₁') = find_closest_pair (p₀, p₁) (p₂ # ps)›*) find_closest_pair_dist_mono (*‹(?C₀, ?C₁) = find_closest_pair (?c₀, ?c₁) ?ps ⟹ dist (case ?C₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case ?C₁ of (x, y) ⇒ (real_of_int x, real_of_int y)) ≤ dist (case ?c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case ?c₁ of (x, y) ⇒ (real_of_int x, real_of_int y))›*) by blast ultimately have "sparse (dist C₀' C₁') (set (p₀ # p₂ # ps))" using A (*‹∀p∈set (p₂ # ps). dist (case p₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₁ of (x, y) ⇒ (real_of_int x, real_of_int y)) ≤ dist (case p₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p of (x, y) ⇒ (real_of_int x, real_of_int y))› ‹dist (case p₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₁ of (x, y) ⇒ (real_of_int x, real_of_int y)) < dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y))›*) sparse_identity (*‹⟦sparse ?δ (set ?ps); ∀p∈set ?ps. ?δ ≤ dist (case ?p₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p of (x, y) ⇒ (real_of_int x, real_of_int y))⟧ ⟹ sparse ?δ (set (?p₀ # ?ps))›*) order_trans (*‹⟦?x ≤ ?y; ?y ≤ ?z⟧ ⟹ ?x ≤ ?z›*) by blast thus "?thesis" (*goal: ‹sparse (dist (case C₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case C₁ of (x, y) ⇒ (real_of_int x, real_of_int y))) (set (p₀ # p₂ # ps))›*) using B (*‹(C₀'::int × int, C₁'::int × int) = find_closest_pair (c₀::int × int, c₁::int × int) ((p₀::int × int) # (p₂::int × int) # (ps::(int × int) list))›*) by (metis "3.prems" (*‹(C₀, C₁) = find_closest_pair (c₀, c₁) (p₀ # p₂ # ps)›*) (2) Pair_inject (*‹⟦(?a, ?b) = (?a', ?b'); ⟦?a = ?a'; ?b = ?b'⟧ ⟹ ?R⟧ ⟹ ?R›*)) next (*goal: ‹¬ (∃p∈set (p₂ # ps). dist (case p₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p of (x, y) ⇒ (real_of_int x, real_of_int y)) < dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y))) ⟹ sparse (dist (case C₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case C₁ of (x, y) ⇒ (real_of_int x, real_of_int y))) (set (p₀ # p₂ # ps))›*) assume A: "¬ (∃p ∈ set (p₂ # ps). dist p₀ p < dist c₀ c₁)" (*‹¬ (∃p::int × int∈set ((p₂::int × int) # (ps::(int × int) list)). dist (case p₀::int × int of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) (case p of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) < dist (case c₀::int × int of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) (case c₁::int × int of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)))›*) hence B: "dist c₀ c₁ ≤ dist p₀ p₁" using find_closest_set[of "p₂ # ps" p₀ "dist c₀ c₁"] (*‹0 < length (p₂ # ps) ⟹ find_closest p₀ (dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y))) (p₂ # ps) ∈ set (p₂ # ps)›*) "p₁_def" (*‹p₁ = find_closest p₀ (dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y))) (p₂ # ps)›*) by auto obtain C₀' and C₁' where C'_def: "(C₀', C₁') = find_closest_pair (c₀, c₁) (p₂ # ps)" (*goal: ‹(⋀C₀' C₁'. (C₀', C₁') = find_closest_pair (c₀, c₁) (p₂ # ps) ⟹ thesis) ⟹ thesis›*) using prod.collapse (*‹(fst ?prod, snd ?prod) = ?prod›*) by blast hence C: "(C₀', C₁') = find_closest_pair (c₀, c₁) (p₀ # p₂ # ps)" using B (*‹dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y)) ≤ dist (case p₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₁ of (x, y) ⇒ (real_of_int x, real_of_int y))›*) "p₁_def" (*‹p₁ = find_closest p₀ (dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y))) (p₂ # ps)›*) by simp have "sparse (dist C₀' C₁') (set (p₂ # ps))" using "3.hyps"(1)[of p₁ C₀' C₁'] (*‹⟦p₁ = find_closest p₀ (dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y))) (p₂ # ps); dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y)) ≤ dist (case p₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₁ of (x, y) ⇒ (real_of_int x, real_of_int y)); sorted_snd (p₂ # ps); (C₀', C₁') = find_closest_pair (c₀, c₁) (p₂ # ps)⟧ ⟹ sparse (dist (case C₀' of (x, y) ⇒ (real_of_int x, real_of_int y)) (case C₁' of (x, y) ⇒ (real_of_int x, real_of_int y))) (set (p₂ # ps))›*) "p₁_def" (*‹p₁ = find_closest p₀ (dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y))) (p₂ # ps)›*) C'_def (*‹(C₀', C₁') = find_closest_pair (c₀, c₁) (p₂ # ps)›*) B (*‹dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y)) ≤ dist (case p₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₁ of (x, y) ⇒ (real_of_int x, real_of_int y))›*) "3.prems" (*‹sorted_snd (p₀ # p₂ # ps)› ‹(C₀::int × int, C₁::int × int) = find_closest_pair (c₀::int × int, c₁::int × int) ((p₀::int × int) # (p₂::int × int) # (ps::(int × int) list))›*) sorted_snd_def (*‹sorted_snd (?ps::(int × int) list) = sorted_wrt (λ(p₀::int × int) p₁::int × int. snd p₀ ≤ snd p₁) ?ps›*) by simp moreover have "dist C₀' C₁' ≤ dist c₀ c₁" using C'_def (*‹(C₀', C₁') = find_closest_pair (c₀, c₁) (p₂ # ps)›*) find_closest_pair_dist_mono (*‹(?C₀::int × int, ?C₁::int × int) = find_closest_pair (?c₀::int × int, ?c₁::int × int) (?ps::(int × int) list) ⟹ dist (case ?C₀ of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) (case ?C₁ of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) ≤ dist (case ?c₀ of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) (case ?c₁ of (x::int, y::int) ⇒ (real_of_int x, real_of_int y))›*) by blast ultimately have "sparse (dist C₀' C₁') (set (p₀ # p₂ # ps))" using A (*‹¬ (∃p∈set (p₂ # ps). dist (case p₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p of (x, y) ⇒ (real_of_int x, real_of_int y)) < dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y)))›*) sparse_identity[of "dist C₀' C₁'" "p₂ # ps" p₀] (*‹⟦sparse (dist (case C₀' of (x, y) ⇒ (real_of_int x, real_of_int y)) (case C₁' of (x, y) ⇒ (real_of_int x, real_of_int y))) (set (p₂ # ps)); ∀p∈set (p₂ # ps). dist (case C₀' of (x, y) ⇒ (real_of_int x, real_of_int y)) (case C₁' of (x, y) ⇒ (real_of_int x, real_of_int y)) ≤ dist (case p₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p of (x, y) ⇒ (real_of_int x, real_of_int y))⟧ ⟹ sparse (dist (case C₀' of (x, y) ⇒ (real_of_int x, real_of_int y)) (case C₁' of (x, y) ⇒ (real_of_int x, real_of_int y))) (set (p₀ # p₂ # ps))›*) order_trans (*‹⟦?x ≤ ?y; ?y ≤ ?z⟧ ⟹ ?x ≤ ?z›*) by force thus "?thesis" (*goal: ‹sparse (dist (case C₀::int × int of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) (case C₁::int × int of (x::int, y::int) ⇒ (real_of_int x, real_of_int y))) (set ((p₀::int × int) # (p₂::int × int) # (ps::(int × int) list)))›*) using C (*‹(C₀'::int × int, C₁'::int × int) = find_closest_pair (c₀::int × int, c₁::int × int) ((p₀::int × int) # (p₂::int × int) # (ps::(int × int) list))›*) by (metis "3.prems" (*‹(C₀, C₁) = find_closest_pair (c₀, c₁) (p₀ # p₂ # ps)›*) (2) Pair_inject (*‹⟦(?a, ?b) = (?a', ?b'); ⟦?a = ?a'; ?b = ?b'⟧ ⟹ ?R⟧ ⟹ ?R›*)) qed qed (auto simp: sparse_def (*‹sparse ?δ ?ps = (∀p₀∈?ps. ∀p₁∈?ps. p₀ ≠ p₁ ⟶ ?δ ≤ dist (case p₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₁ of (x, y) ⇒ (real_of_int x, real_of_int y)))›*)) (*solves the remaining goals: 1. ‹⋀c₀ c₁ C₀ C₁. ⟦sorted_snd []; (C₀, C₁) = find_closest_pair (c₀, c₁) []⟧ ⟹ sparse (dist (case C₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case C₁ of (x, y) ⇒ (real_of_int x, real_of_int y))) (set [])› 2. ‹⋀c₀ c₁ uu_ C₀ C₁. ⟦sorted_snd [uu_]; (C₀, C₁) = find_closest_pair (c₀, c₁) [uu_]⟧ ⟹ sparse (dist (case C₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case C₁ of (x, y) ⇒ (real_of_int x, real_of_int y))) (set [uu_])›*) declare find_closest_pair.simps [simp del] fun combine_tm :: "(point × point) ⇒ (point × point) ⇒ int ⇒ point list ⇒ (point × point) tm" where "combine_tm (p₀⇩L, p₁⇩L) (p₀⇩R, p₁⇩R) l ps =1 ( let (c₀, c₁) = if dist p₀⇩L p₁⇩L < dist p₀⇩R p₁⇩R then (p₀⇩L, p₁⇩L) else (p₀⇩R, p₁⇩R) in do { ps' <- filter_tm (λp. dist p (l, snd p) < dist c₀ c₁) ps; find_closest_pair_tm (c₀, c₁) ps' } )" fun combine :: "(point × point) ⇒ (point × point) ⇒ int ⇒ point list ⇒ (point × point)" where "combine (p₀⇩L, p₁⇩L) (p₀⇩R, p₁⇩R) l ps = ( let (c₀, c₁) = if dist p₀⇩L p₁⇩L < dist p₀⇩R p₁⇩R then (p₀⇩L, p₁⇩L) else (p₀⇩R, p₁⇩R) in let ps' = filter (λp. dist p (l, snd p) < dist c₀ c₁) ps in find_closest_pair (c₀, c₁) ps' )" lemma combine_eq_val_combine_tm: "val (combine_tm (p₀⇩L, p₁⇩L) (p₀⇩R, p₁⇩R) l ps) = combine (p₀⇩L, p₁⇩L) (p₀⇩R, p₁⇩R) l ps" by (auto simp: filter_eq_val_filter_tm (*‹Time_Monad.val (filter_tm (?P::?'a::type ⇒ bool) (?xs::?'a::type list)) = filter ?P ?xs›*) find_closest_pair_eq_val_find_closest_pair_tm (*‹Time_Monad.val (find_closest_pair_tm (?c₀::int × int, ?c₁::int × int) (?ps::(int × int) list)) = find_closest_pair (?c₀, ?c₁) ?ps›*)) lemma combine_set: assumes "(c₀, c₁) = combine (p₀⇩L, p₁⇩L) (p₀⇩R, p₁⇩R) l ps" shows "(c₀ ∈ set ps ∧ c₁ ∈ set ps) ∨ (c₀ = p₀⇩L ∧ c₁ = p₁⇩L) ∨ (c₀ = p₀⇩R ∧ c₁ = p₁⇩R)" proof (-) (*goal: ‹c₀ ∈ set ps ∧ c₁ ∈ set ps ∨ c₀ = p₀⇩L ∧ c₁ = p₁⇩L ∨ c₀ = p₀⇩R ∧ c₁ = p₁⇩R›*) obtain C₀' and C₁' where C'_def: "(C₀', C₁') = (if dist p₀⇩L p₁⇩L < dist p₀⇩R p₁⇩R then (p₀⇩L, p₁⇩L) else (p₀⇩R, p₁⇩R))" (*goal: ‹(⋀C₀' C₁'. (C₀', C₁') = (if dist (case p₀⇩L of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₁⇩L of (x, y) ⇒ (real_of_int x, real_of_int y)) < dist (case p₀⇩R of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₁⇩R of (x, y) ⇒ (real_of_int x, real_of_int y)) then (p₀⇩L, p₁⇩L) else (p₀⇩R, p₁⇩R)) ⟹ thesis) ⟹ thesis›*) by metis define ps' where ps'_def: "ps' = filter (λp. dist p (l, snd p) < dist C₀' C₁') ps" obtain C₀ and C₁ where C_def: "(C₀, C₁) = find_closest_pair (C₀', C₁') ps'" (*goal: ‹(⋀C₀ C₁. (C₀, C₁) = find_closest_pair (C₀', C₁') ps' ⟹ thesis) ⟹ thesis›*) using prod.collapse (*‹(fst ?prod, snd ?prod) = ?prod›*) by blast note defs = C'_def (*‹(C₀', C₁') = (if dist (case p₀⇩L of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₁⇩L of (x, y) ⇒ (real_of_int x, real_of_int y)) < dist (case p₀⇩R of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₁⇩R of (x, y) ⇒ (real_of_int x, real_of_int y)) then (p₀⇩L, p₁⇩L) else (p₀⇩R, p₁⇩R))›*) ps'_def (*‹ps' = filter (λp. dist (case p of (x, y) ⇒ (real_of_int x, real_of_int y)) (case (l, snd p) of (x, y) ⇒ (real_of_int x, real_of_int y)) < dist (case C₀' of (x, y) ⇒ (real_of_int x, real_of_int y)) (case C₁' of (x, y) ⇒ (real_of_int x, real_of_int y))) ps›*) C_def (*‹(C₀, C₁) = find_closest_pair (C₀', C₁') ps'›*) have "(C₀ ∈ set ps' ∧ C₁ ∈ set ps') ∨ (C₀ = C₀' ∧ C₁ = C₁')" using C_def (*‹(C₀, C₁) = find_closest_pair (C₀', C₁') ps'›*) find_closest_pair_set (*‹(?C₀::int × int, ?C₁::int × int) = find_closest_pair (?c₀::int × int, ?c₁::int × int) (?ps::(int × int) list) ⟹ ?C₀ ∈ set ?ps ∧ ?C₁ ∈ set ?ps ∨ ?C₀ = ?c₀ ∧ ?C₁ = ?c₁›*) by blast hence "(C₀ ∈ set ps ∧ C₁ ∈ set ps)∨ (C₀ = C₀' ∧ C₁ = C₁')" using ps'_def (*‹ps' = filter (λp. dist (case p of (x, y) ⇒ (real_of_int x, real_of_int y)) (case (l, snd p) of (x, y) ⇒ (real_of_int x, real_of_int y)) < dist (case C₀' of (x, y) ⇒ (real_of_int x, real_of_int y)) (case C₁' of (x, y) ⇒ (real_of_int x, real_of_int y))) ps›*) by auto moreover have "C₀ = c₀" "C₁ = c₁" using assms (*‹(c₀, c₁) = combine (p₀⇩L, p₁⇩L) (p₀⇩R, p₁⇩R) l ps›*) defs (*‹(C₀', C₁') = (if dist (case p₀⇩L of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₁⇩L of (x, y) ⇒ (real_of_int x, real_of_int y)) < dist (case p₀⇩R of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₁⇩R of (x, y) ⇒ (real_of_int x, real_of_int y)) then (p₀⇩L, p₁⇩L) else (p₀⇩R, p₁⇩R))› ‹ps' = filter (λp. dist (case p of (x, y) ⇒ (real_of_int x, real_of_int y)) (case (l, snd p) of (x, y) ⇒ (real_of_int x, real_of_int y)) < dist (case C₀' of (x, y) ⇒ (real_of_int x, real_of_int y)) (case C₁' of (x, y) ⇒ (real_of_int x, real_of_int y))) ps› ‹(C₀, C₁) = find_closest_pair (C₀', C₁') ps'›*) apply - (*goals: 1. ‹⟦(c₀, c₁) = combine (p₀⇩L, p₁⇩L) (p₀⇩R, p₁⇩R) l ps; (C₀', C₁') = (if dist (case p₀⇩L of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₁⇩L of (x, y) ⇒ (real_of_int x, real_of_int y)) < dist (case p₀⇩R of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₁⇩R of (x, y) ⇒ (real_of_int x, real_of_int y)) then (p₀⇩L, p₁⇩L) else (p₀⇩R, p₁⇩R)); ps' = filter (λp. dist (case p of (x, y) ⇒ (real_of_int x, real_of_int y)) (case (l, snd p) of (x, y) ⇒ (real_of_int x, real_of_int y)) < dist (case C₀' of (x, y) ⇒ (real_of_int x, real_of_int y)) (case C₁' of (x, y) ⇒ (real_of_int x, real_of_int y))) ps; (C₀, C₁) = find_closest_pair (C₀', C₁') ps'⟧ ⟹ C₀ = c₀› 2. ‹⟦(c₀, c₁) = combine (p₀⇩L, p₁⇩L) (p₀⇩R, p₁⇩R) l ps; (C₀', C₁') = (if dist (case p₀⇩L of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₁⇩L of (x, y) ⇒ (real_of_int x, real_of_int y)) < dist (case p₀⇩R of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₁⇩R of (x, y) ⇒ (real_of_int x, real_of_int y)) then (p₀⇩L, p₁⇩L) else (p₀⇩R, p₁⇩R)); ps' = filter (λp. dist (case p of (x, y) ⇒ (real_of_int x, real_of_int y)) (case (l, snd p) of (x, y) ⇒ (real_of_int x, real_of_int y)) < dist (case C₀' of (x, y) ⇒ (real_of_int x, real_of_int y)) (case C₁' of (x, y) ⇒ (real_of_int x, real_of_int y))) ps; (C₀, C₁) = find_closest_pair (C₀', C₁') ps'⟧ ⟹ C₁ = c₁› 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]) (*goals: 1. ‹⋀x1 x2 x1a x2a x1b x2b x1c x2c. ⟦(c₀, c₁) = find_closest_pair ((x1a, x2a), x1, x2) (filter (λp. ∀x1b x2b. p = (x1b, x2b) ⟶ dist (real_of_int x1b, real_of_int x2b) (real_of_int l, real_of_int x2b) < dist (real_of_int x1a, real_of_int x2a) (real_of_int x1, real_of_int x2)) ps); C₀' = (x1a, x2a); C₁' = (x1, x2); p₁⇩L = (x1, x2); ps' = filter (λp. ∀x1b x2b. p = (x1b, x2b) ⟶ dist (real_of_int x1b, real_of_int x2b) (real_of_int l, real_of_int x2b) < dist (real_of_int x1a, real_of_int x2a) (real_of_int x1, real_of_int x2)) ps; p₀⇩L = (x1a, x2a); (C₀, C₁) = find_closest_pair ((x1a, x2a), x1, x2) (filter (λp. ∀x1b x2b. p = (x1b, x2b) ⟶ dist (real_of_int x1b, real_of_int x2b) (real_of_int l, real_of_int x2b) < dist (real_of_int x1a, real_of_int x2a) (real_of_int x1, real_of_int x2)) ps); p₁⇩R = (x1b, x2b); p₀⇩R = (x1c, x2c); dist (real_of_int x1a, real_of_int x2a) (real_of_int x1, real_of_int x2) < dist (real_of_int x1c, real_of_int x2c) (real_of_int x1b, real_of_int x2b)⟧ ⟹ C₀ = c₀› 2. ‹⋀x1 x2 x1a x2a x1b x2b x1c x2c. ⟦(c₀, c₁) = find_closest_pair ((x1a, x2a), x1, x2) (filter (λp. ∀x1b x2b. p = (x1b, x2b) ⟶ dist (real_of_int x1b, real_of_int x2b) (real_of_int l, real_of_int x2b) < dist (real_of_int x1a, real_of_int x2a) (real_of_int x1, real_of_int x2)) ps); C₀' = (x1a, x2a); C₁' = (x1, x2); p₁⇩R = (x1, x2); ps' = filter (λp. ∀x1b x2b. p = (x1b, x2b) ⟶ dist (real_of_int x1b, real_of_int x2b) (real_of_int l, real_of_int x2b) < dist (real_of_int x1a, real_of_int x2a) (real_of_int x1, real_of_int x2)) ps; p₀⇩R = (x1a, x2a); (C₀, C₁) = find_closest_pair ((x1a, x2a), x1, x2) (filter (λp. ∀x1b x2b. p = (x1b, x2b) ⟶ dist (real_of_int x1b, real_of_int x2b) (real_of_int l, real_of_int x2b) < dist (real_of_int x1a, real_of_int x2a) (real_of_int x1, real_of_int x2)) ps); p₁⇩L = (x1b, x2b); p₀⇩L = (x1c, x2c); ¬ dist (real_of_int x1c, real_of_int x2c) (real_of_int x1b, real_of_int x2b) < dist (real_of_int x1a, real_of_int x2a) (real_of_int x1, real_of_int x2)⟧ ⟹ C₀ = c₀› discuss goal 1*) apply (metis Pair_inject (*‹⟦(?a, ?b) = (?a', ?b'); ⟦?a = ?a'; ?b = ?b'⟧ ⟹ ?R⟧ ⟹ ?R›*)) (*discuss goal 2*) apply (metis Pair_inject (*‹⟦(?a, ?b) = (?a', ?b'); ⟦?a = ?a'; ?b = ?b'⟧ ⟹ ?R⟧ ⟹ ?R›*)) (*proven 2 subgoals*) (*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))›*) 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]) (*goals: 1. ‹⋀(x1::int) (x2::int) (x1a::int) (x2a::int) (x1b::int) (x2b::int) (x1c::int) x2c::int. ⟦(c₀::int × int, c₁::int × int) = find_closest_pair ((x1a, x2a), x1, x2) (filter (λp::int × int. ∀(x1b::int) x2b::int. p = (x1b, x2b) ⟶ dist (real_of_int x1b, real_of_int x2b) (real_of_int (l::int), real_of_int x2b) < dist (real_of_int x1a, real_of_int x2a) (real_of_int x1, real_of_int x2)) (ps::(int × int) list)); (C₀'::int × int) = (x1a, x2a); (C₁'::int × int) = (x1, x2); (p₁⇩L::int × int) = (x1, x2); (ps'::(int × int) list) = filter (λp::int × int. ∀(x1b::int) x2b::int. p = (x1b, x2b) ⟶ dist (real_of_int x1b, real_of_int x2b) (real_of_int l, real_of_int x2b) < dist (real_of_int x1a, real_of_int x2a) (real_of_int x1, real_of_int x2)) ps; (p₀⇩L::int × int) = (x1a, x2a); (C₀::int × int, C₁::int × int) = find_closest_pair ((x1a, x2a), x1, x2) (filter (λp::int × int. ∀(x1b::int) x2b::int. p = (x1b, x2b) ⟶ dist (real_of_int x1b, real_of_int x2b) (real_of_int l, real_of_int x2b) < dist (real_of_int x1a, real_of_int x2a) (real_of_int x1, real_of_int x2)) ps); (p₁⇩R::int × int) = (x1b, x2b); (p₀⇩R::int × int) = (x1c, x2c); dist (real_of_int x1a, real_of_int x2a) (real_of_int x1, real_of_int x2) < dist (real_of_int x1c, real_of_int x2c) (real_of_int x1b, real_of_int x2b)⟧ ⟹ C₁ = c₁› 2. ‹⋀(x1::int) (x2::int) (x1a::int) (x2a::int) (x1b::int) (x2b::int) (x1c::int) x2c::int. ⟦(c₀::int × int, c₁::int × int) = find_closest_pair ((x1a, x2a), x1, x2) (filter (λp::int × int. ∀(x1b::int) x2b::int. p = (x1b, x2b) ⟶ dist (real_of_int x1b, real_of_int x2b) (real_of_int (l::int), real_of_int x2b) < dist (real_of_int x1a, real_of_int x2a) (real_of_int x1, real_of_int x2)) (ps::(int × int) list)); (C₀'::int × int) = (x1a, x2a); (C₁'::int × int) = (x1, x2); (p₁⇩R::int × int) = (x1, x2); (ps'::(int × int) list) = filter (λp::int × int. ∀(x1b::int) x2b::int. p = (x1b, x2b) ⟶ dist (real_of_int x1b, real_of_int x2b) (real_of_int l, real_of_int x2b) < dist (real_of_int x1a, real_of_int x2a) (real_of_int x1, real_of_int x2)) ps; (p₀⇩R::int × int) = (x1a, x2a); (C₀::int × int, C₁::int × int) = find_closest_pair ((x1a, x2a), x1, x2) (filter (λp::int × int. ∀(x1b::int) x2b::int. p = (x1b, x2b) ⟶ dist (real_of_int x1b, real_of_int x2b) (real_of_int l, real_of_int x2b) < dist (real_of_int x1a, real_of_int x2a) (real_of_int x1, real_of_int x2)) ps); (p₁⇩L::int × int) = (x1b, x2b); (p₀⇩L::int × int) = (x1c, x2c); ¬ dist (real_of_int x1c, real_of_int x2c) (real_of_int x1b, real_of_int x2b) < dist (real_of_int x1a, real_of_int x2a) (real_of_int x1, real_of_int x2)⟧ ⟹ C₁ = c₁› discuss goal 1*) apply (metis Pair_inject (*‹⟦(?a, ?b) = (?a', ?b'); ⟦?a = ?a'; ?b = ?b'⟧ ⟹ ?R⟧ ⟹ ?R›*)) (*discuss goal 2*) apply (metis Pair_inject (*‹⟦(?a::?'a, ?b::?'b) = (?a'::?'a, ?b'::?'b); ⟦?a = ?a'; ?b = ?b'⟧ ⟹ ?R::bool⟧ ⟹ ?R›*)) (*proven 2 subgoals*) (*proven 2 subgoals*) . ultimately show "?thesis" (*goal: ‹c₀ ∈ set ps ∧ c₁ ∈ set ps ∨ c₀ = p₀⇩L ∧ c₁ = p₁⇩L ∨ c₀ = p₀⇩R ∧ c₁ = p₁⇩R›*) using C'_def (*‹(C₀', C₁') = (if dist (case p₀⇩L of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₁⇩L of (x, y) ⇒ (real_of_int x, real_of_int y)) < dist (case p₀⇩R of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₁⇩R of (x, y) ⇒ (real_of_int x, real_of_int y)) then (p₀⇩L, p₁⇩L) else (p₀⇩R, p₁⇩R))›*) 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 lemma combine_c0_ne_c1: assumes "p₀⇩L ≠ p₁⇩L" "p₀⇩R ≠ p₁⇩R" "distinct ps" assumes "(c₀, c₁) = combine (p₀⇩L, p₁⇩L) (p₀⇩R, p₁⇩R) l ps" shows "c₀ ≠ c₁" proof (-) (*goal: ‹c₀ ≠ c₁›*) obtain C₀' and C₁' where C'_def: "(C₀', C₁') = (if dist p₀⇩L p₁⇩L < dist p₀⇩R p₁⇩R then (p₀⇩L, p₁⇩L) else (p₀⇩R, p₁⇩R))" (*goal: ‹(⋀(C₀'::int × int) C₁'::int × int. (C₀', C₁') = (if dist (case p₀⇩L::int × int of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) (case p₁⇩L::int × int of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) < dist (case p₀⇩R::int × int of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) (case p₁⇩R::int × int of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) then (p₀⇩L, p₁⇩L) else (p₀⇩R, p₁⇩R)) ⟹ thesis::bool) ⟹ thesis›*) by metis define ps' where ps'_def: "ps' = filter (λp. dist p (l, snd p) < dist C₀' C₁') ps" obtain C₀ and C₁ where C_def: "(C₀, C₁) = find_closest_pair (C₀', C₁') ps'" (*goal: ‹(⋀C₀ C₁. (C₀, C₁) = find_closest_pair (C₀', C₁') ps' ⟹ thesis) ⟹ thesis›*) using prod.collapse (*‹(fst ?prod, snd ?prod) = ?prod›*) by blast note defs = C'_def (*‹(C₀', C₁') = (if dist (case p₀⇩L of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₁⇩L of (x, y) ⇒ (real_of_int x, real_of_int y)) < dist (case p₀⇩R of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₁⇩R of (x, y) ⇒ (real_of_int x, real_of_int y)) then (p₀⇩L, p₁⇩L) else (p₀⇩R, p₁⇩R))›*) ps'_def (*‹ps' = filter (λp. dist (case p of (x, y) ⇒ (real_of_int x, real_of_int y)) (case (l, snd p) of (x, y) ⇒ (real_of_int x, real_of_int y)) < dist (case C₀' of (x, y) ⇒ (real_of_int x, real_of_int y)) (case C₁' of (x, y) ⇒ (real_of_int x, real_of_int y))) ps›*) C_def (*‹(C₀, C₁) = find_closest_pair (C₀', C₁') ps'›*) have "C₀ ≠ C₁" using defs (*‹(C₀', C₁') = (if dist (case p₀⇩L of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₁⇩L of (x, y) ⇒ (real_of_int x, real_of_int y)) < dist (case p₀⇩R of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₁⇩R of (x, y) ⇒ (real_of_int x, real_of_int y)) then (p₀⇩L, p₁⇩L) else (p₀⇩R, p₁⇩R))› ‹ps' = filter (λp. dist (case p of (x, y) ⇒ (real_of_int x, real_of_int y)) (case (l, snd p) of (x, y) ⇒ (real_of_int x, real_of_int y)) < dist (case C₀' of (x, y) ⇒ (real_of_int x, real_of_int y)) (case C₁' of (x, y) ⇒ (real_of_int x, real_of_int y))) ps› ‹(C₀, C₁) = find_closest_pair (C₀', C₁') ps'›*) find_closest_pair_c0_ne_c1[of C₀' C₁' ps'] (*‹⟦C₀' ≠ C₁'; distinct ps'; (?C₀, ?C₁) = find_closest_pair (C₀', C₁') ps'⟧ ⟹ ?C₀ ≠ ?C₁›*) assms (*‹p₀⇩L ≠ p₁⇩L› ‹p₀⇩R ≠ p₁⇩R› ‹distinct (ps::(int × int) list)› ‹(c₀, c₁) = combine (p₀⇩L, p₁⇩L) (p₀⇩R, p₁⇩R) l ps›*) by (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))›*)) moreover have "C₀ = c₀" "C₁ = c₁" using assms(4) (*‹(c₀, c₁) = combine (p₀⇩L, p₁⇩L) (p₀⇩R, p₁⇩R) l ps›*) defs (*‹(C₀'::int × int, C₁'::int × int) = (if dist (case p₀⇩L::int × int of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) (case p₁⇩L::int × int of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) < dist (case p₀⇩R::int × int of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) (case p₁⇩R::int × int of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) then (p₀⇩L, p₁⇩L) else (p₀⇩R, p₁⇩R))› ‹ps' = filter (λp. dist (case p of (x, y) ⇒ (real_of_int x, real_of_int y)) (case (l, snd p) of (x, y) ⇒ (real_of_int x, real_of_int y)) < dist (case C₀' of (x, y) ⇒ (real_of_int x, real_of_int y)) (case C₁' of (x, y) ⇒ (real_of_int x, real_of_int y))) ps› ‹(C₀, C₁) = find_closest_pair (C₀', C₁') ps'›*) apply - (*goals: 1. ‹⟦(c₀, c₁) = combine (p₀⇩L, p₁⇩L) (p₀⇩R, p₁⇩R) l ps; (C₀', C₁') = (if dist (case p₀⇩L of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₁⇩L of (x, y) ⇒ (real_of_int x, real_of_int y)) < dist (case p₀⇩R of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₁⇩R of (x, y) ⇒ (real_of_int x, real_of_int y)) then (p₀⇩L, p₁⇩L) else (p₀⇩R, p₁⇩R)); ps' = filter (λp. dist (case p of (x, y) ⇒ (real_of_int x, real_of_int y)) (case (l, snd p) of (x, y) ⇒ (real_of_int x, real_of_int y)) < dist (case C₀' of (x, y) ⇒ (real_of_int x, real_of_int y)) (case C₁' of (x, y) ⇒ (real_of_int x, real_of_int y))) ps; (C₀, C₁) = find_closest_pair (C₀', C₁') ps'⟧ ⟹ C₀ = c₀› 2. ‹⟦(c₀, c₁) = combine (p₀⇩L, p₁⇩L) (p₀⇩R, p₁⇩R) l ps; (C₀', C₁') = (if dist (case p₀⇩L of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₁⇩L of (x, y) ⇒ (real_of_int x, real_of_int y)) < dist (case p₀⇩R of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₁⇩R of (x, y) ⇒ (real_of_int x, real_of_int y)) then (p₀⇩L, p₁⇩L) else (p₀⇩R, p₁⇩R)); ps' = filter (λp. dist (case p of (x, y) ⇒ (real_of_int x, real_of_int y)) (case (l, snd p) of (x, y) ⇒ (real_of_int x, real_of_int y)) < dist (case C₀' of (x, y) ⇒ (real_of_int x, real_of_int y)) (case C₁' of (x, y) ⇒ (real_of_int x, real_of_int y))) ps; (C₀, C₁) = find_closest_pair (C₀', C₁') ps'⟧ ⟹ C₁ = c₁› 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))›*) 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]) (*goals: 1. ‹⋀x1 x2 x1a x2a x1b x2b x1c x2c. ⟦(c₀, c₁) = find_closest_pair ((x1a, x2a), x1, x2) (filter (λp. ∀x1b x2b. p = (x1b, x2b) ⟶ dist (real_of_int x1b, real_of_int x2b) (real_of_int l, real_of_int x2b) < dist (real_of_int x1a, real_of_int x2a) (real_of_int x1, real_of_int x2)) ps); C₀' = (x1a, x2a); C₁' = (x1, x2); p₁⇩L = (x1, x2); ps' = filter (λp. ∀x1b x2b. p = (x1b, x2b) ⟶ dist (real_of_int x1b, real_of_int x2b) (real_of_int l, real_of_int x2b) < dist (real_of_int x1a, real_of_int x2a) (real_of_int x1, real_of_int x2)) ps; p₀⇩L = (x1a, x2a); (C₀, C₁) = find_closest_pair ((x1a, x2a), x1, x2) (filter (λp. ∀x1b x2b. p = (x1b, x2b) ⟶ dist (real_of_int x1b, real_of_int x2b) (real_of_int l, real_of_int x2b) < dist (real_of_int x1a, real_of_int x2a) (real_of_int x1, real_of_int x2)) ps); p₁⇩R = (x1b, x2b); p₀⇩R = (x1c, x2c); dist (real_of_int x1a, real_of_int x2a) (real_of_int x1, real_of_int x2) < dist (real_of_int x1c, real_of_int x2c) (real_of_int x1b, real_of_int x2b)⟧ ⟹ C₀ = c₀› 2. ‹⋀x1 x2 x1a x2a x1b x2b x1c x2c. ⟦(c₀, c₁) = find_closest_pair ((x1a, x2a), x1, x2) (filter (λp. ∀x1b x2b. p = (x1b, x2b) ⟶ dist (real_of_int x1b, real_of_int x2b) (real_of_int l, real_of_int x2b) < dist (real_of_int x1a, real_of_int x2a) (real_of_int x1, real_of_int x2)) ps); C₀' = (x1a, x2a); C₁' = (x1, x2); p₁⇩R = (x1, x2); ps' = filter (λp. ∀x1b x2b. p = (x1b, x2b) ⟶ dist (real_of_int x1b, real_of_int x2b) (real_of_int l, real_of_int x2b) < dist (real_of_int x1a, real_of_int x2a) (real_of_int x1, real_of_int x2)) ps; p₀⇩R = (x1a, x2a); (C₀, C₁) = find_closest_pair ((x1a, x2a), x1, x2) (filter (λp. ∀x1b x2b. p = (x1b, x2b) ⟶ dist (real_of_int x1b, real_of_int x2b) (real_of_int l, real_of_int x2b) < dist (real_of_int x1a, real_of_int x2a) (real_of_int x1, real_of_int x2)) ps); p₁⇩L = (x1b, x2b); p₀⇩L = (x1c, x2c); ¬ dist (real_of_int x1c, real_of_int x2c) (real_of_int x1b, real_of_int x2b) < dist (real_of_int x1a, real_of_int x2a) (real_of_int x1, real_of_int x2)⟧ ⟹ C₀ = c₀› discuss goal 1*) apply (metis Pair_inject (*‹⟦(?a, ?b) = (?a', ?b'); ⟦?a = ?a'; ?b = ?b'⟧ ⟹ ?R⟧ ⟹ ?R›*)) (*discuss goal 2*) apply (metis Pair_inject (*‹⟦(?a, ?b) = (?a', ?b'); ⟦?a = ?a'; ?b = ?b'⟧ ⟹ ?R⟧ ⟹ ?R›*)) (*proven 2 subgoals*) (*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))›*) 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]) (*goals: 1. ‹⋀(x1::int) (x2::int) (x1a::int) (x2a::int) (x1b::int) (x2b::int) (x1c::int) x2c::int. ⟦(c₀::int × int, c₁::int × int) = find_closest_pair ((x1a, x2a), x1, x2) (filter (λp::int × int. ∀(x1b::int) x2b::int. p = (x1b, x2b) ⟶ dist (real_of_int x1b, real_of_int x2b) (real_of_int (l::int), real_of_int x2b) < dist (real_of_int x1a, real_of_int x2a) (real_of_int x1, real_of_int x2)) (ps::(int × int) list)); (C₀'::int × int) = (x1a, x2a); (C₁'::int × int) = (x1, x2); (p₁⇩L::int × int) = (x1, x2); (ps'::(int × int) list) = filter (λp::int × int. ∀(x1b::int) x2b::int. p = (x1b, x2b) ⟶ dist (real_of_int x1b, real_of_int x2b) (real_of_int l, real_of_int x2b) < dist (real_of_int x1a, real_of_int x2a) (real_of_int x1, real_of_int x2)) ps; (p₀⇩L::int × int) = (x1a, x2a); (C₀::int × int, C₁::int × int) = find_closest_pair ((x1a, x2a), x1, x2) (filter (λp::int × int. ∀(x1b::int) x2b::int. p = (x1b, x2b) ⟶ dist (real_of_int x1b, real_of_int x2b) (real_of_int l, real_of_int x2b) < dist (real_of_int x1a, real_of_int x2a) (real_of_int x1, real_of_int x2)) ps); (p₁⇩R::int × int) = (x1b, x2b); (p₀⇩R::int × int) = (x1c, x2c); dist (real_of_int x1a, real_of_int x2a) (real_of_int x1, real_of_int x2) < dist (real_of_int x1c, real_of_int x2c) (real_of_int x1b, real_of_int x2b)⟧ ⟹ C₁ = c₁› 2. ‹⋀(x1::int) (x2::int) (x1a::int) (x2a::int) (x1b::int) (x2b::int) (x1c::int) x2c::int. ⟦(c₀::int × int, c₁::int × int) = find_closest_pair ((x1a, x2a), x1, x2) (filter (λp::int × int. ∀(x1b::int) x2b::int. p = (x1b, x2b) ⟶ dist (real_of_int x1b, real_of_int x2b) (real_of_int (l::int), real_of_int x2b) < dist (real_of_int x1a, real_of_int x2a) (real_of_int x1, real_of_int x2)) (ps::(int × int) list)); (C₀'::int × int) = (x1a, x2a); (C₁'::int × int) = (x1, x2); (p₁⇩R::int × int) = (x1, x2); (ps'::(int × int) list) = filter (λp::int × int. ∀(x1b::int) x2b::int. p = (x1b, x2b) ⟶ dist (real_of_int x1b, real_of_int x2b) (real_of_int l, real_of_int x2b) < dist (real_of_int x1a, real_of_int x2a) (real_of_int x1, real_of_int x2)) ps; (p₀⇩R::int × int) = (x1a, x2a); (C₀::int × int, C₁::int × int) = find_closest_pair ((x1a, x2a), x1, x2) (filter (λp::int × int. ∀(x1b::int) x2b::int. p = (x1b, x2b) ⟶ dist (real_of_int x1b, real_of_int x2b) (real_of_int l, real_of_int x2b) < dist (real_of_int x1a, real_of_int x2a) (real_of_int x1, real_of_int x2)) ps); (p₁⇩L::int × int) = (x1b, x2b); (p₀⇩L::int × int) = (x1c, x2c); ¬ dist (real_of_int x1c, real_of_int x2c) (real_of_int x1b, real_of_int x2b) < dist (real_of_int x1a, real_of_int x2a) (real_of_int x1, real_of_int x2)⟧ ⟹ C₁ = c₁› discuss goal 1*) apply (metis Pair_inject (*‹⟦(?a, ?b) = (?a', ?b'); ⟦?a = ?a'; ?b = ?b'⟧ ⟹ ?R⟧ ⟹ ?R›*)) (*discuss goal 2*) apply (metis Pair_inject (*‹⟦(?a, ?b) = (?a', ?b'); ⟦?a = ?a'; ?b = ?b'⟧ ⟹ ?R⟧ ⟹ ?R›*)) (*proven 2 subgoals*) (*proven 2 subgoals*) . ultimately show "?thesis" (*goal: ‹(c₀::int × int) ≠ (c₁::int × int)›*) by blast qed lemma combine_dist: assumes "sorted_snd ps" "set ps = ps⇩L ∪ ps⇩R" assumes "∀p ∈ ps⇩L. fst p ≤ l" "∀p ∈ ps⇩R. l ≤ fst p" assumes "sparse (dist p₀⇩L p₁⇩L) ps⇩L" "sparse (dist p₀⇩R p₁⇩R) ps⇩R" assumes "(c₀, c₁) = combine (p₀⇩L, p₁⇩L) (p₀⇩R, p₁⇩R) l ps" shows "sparse (dist c₀ c₁) (set ps)" proof (-) (*goal: ‹sparse (dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y))) (set ps)›*) obtain C₀' and C₁' where C'_def: "(C₀', C₁') = (if dist p₀⇩L p₁⇩L < dist p₀⇩R p₁⇩R then (p₀⇩L, p₁⇩L) else (p₀⇩R, p₁⇩R))" (*goal: ‹(⋀C₀' C₁'. (C₀', C₁') = (if dist (case p₀⇩L of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₁⇩L of (x, y) ⇒ (real_of_int x, real_of_int y)) < dist (case p₀⇩R of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₁⇩R of (x, y) ⇒ (real_of_int x, real_of_int y)) then (p₀⇩L, p₁⇩L) else (p₀⇩R, p₁⇩R)) ⟹ thesis) ⟹ thesis›*) by metis define ps' where ps'_def: "ps' = filter (λp. dist p (l, snd p) < dist C₀' C₁') ps" obtain C₀ and C₁ where C_def: "(C₀, C₁) = find_closest_pair (C₀', C₁') ps'" (*goal: ‹(⋀C₀ C₁. (C₀, C₁) = find_closest_pair (C₀', C₁') ps' ⟹ thesis) ⟹ thesis›*) using prod.collapse (*‹(fst ?prod, snd ?prod) = ?prod›*) by blast note defs = C'_def (*‹(C₀', C₁') = (if dist (case p₀⇩L of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₁⇩L of (x, y) ⇒ (real_of_int x, real_of_int y)) < dist (case p₀⇩R of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₁⇩R of (x, y) ⇒ (real_of_int x, real_of_int y)) then (p₀⇩L, p₁⇩L) else (p₀⇩R, p₁⇩R))›*) ps'_def (*‹(ps'::(int × int) list) = filter (λp::int × int. dist (case p of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) (case (l::int, snd p) of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) < dist (case C₀'::int × int of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) (case C₁'::int × int of (x::int, y::int) ⇒ (real_of_int x, real_of_int y))) (ps::(int × int) list)›*) C_def (*‹(C₀, C₁) = find_closest_pair (C₀', C₁') ps'›*) have EQ: "C₀ = c₀" "C₁ = c₁" using defs (*‹(C₀', C₁') = (if dist (case p₀⇩L of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₁⇩L of (x, y) ⇒ (real_of_int x, real_of_int y)) < dist (case p₀⇩R of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₁⇩R of (x, y) ⇒ (real_of_int x, real_of_int y)) then (p₀⇩L, p₁⇩L) else (p₀⇩R, p₁⇩R))› ‹ps' = filter (λp. dist (case p of (x, y) ⇒ (real_of_int x, real_of_int y)) (case (l, snd p) of (x, y) ⇒ (real_of_int x, real_of_int y)) < dist (case C₀' of (x, y) ⇒ (real_of_int x, real_of_int y)) (case C₁' of (x, y) ⇒ (real_of_int x, real_of_int y))) ps› ‹(C₀, C₁) = find_closest_pair (C₀', C₁') ps'›*) assms(7) (*‹(c₀, c₁) = combine (p₀⇩L, p₁⇩L) (p₀⇩R, p₁⇩R) l ps›*) apply - (*goals: 1. ‹⟦(C₀', C₁') = (if dist (case p₀⇩L of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₁⇩L of (x, y) ⇒ (real_of_int x, real_of_int y)) < dist (case p₀⇩R of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₁⇩R of (x, y) ⇒ (real_of_int x, real_of_int y)) then (p₀⇩L, p₁⇩L) else (p₀⇩R, p₁⇩R)); ps' = filter (λp. dist (case p of (x, y) ⇒ (real_of_int x, real_of_int y)) (case (l, snd p) of (x, y) ⇒ (real_of_int x, real_of_int y)) < dist (case C₀' of (x, y) ⇒ (real_of_int x, real_of_int y)) (case C₁' of (x, y) ⇒ (real_of_int x, real_of_int y))) ps; (C₀, C₁) = find_closest_pair (C₀', C₁') ps'; (c₀, c₁) = combine (p₀⇩L, p₁⇩L) (p₀⇩R, p₁⇩R) l ps⟧ ⟹ C₀ = c₀› 2. ‹⟦(C₀', C₁') = (if dist (case p₀⇩L of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₁⇩L of (x, y) ⇒ (real_of_int x, real_of_int y)) < dist (case p₀⇩R of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₁⇩R of (x, y) ⇒ (real_of_int x, real_of_int y)) then (p₀⇩L, p₁⇩L) else (p₀⇩R, p₁⇩R)); ps' = filter (λp. dist (case p of (x, y) ⇒ (real_of_int x, real_of_int y)) (case (l, snd p) of (x, y) ⇒ (real_of_int x, real_of_int y)) < dist (case C₀' of (x, y) ⇒ (real_of_int x, real_of_int y)) (case C₁' of (x, y) ⇒ (real_of_int x, real_of_int y))) ps; (C₀, C₁) = find_closest_pair (C₀', C₁') ps'; (c₀, c₁) = combine (p₀⇩L, p₁⇩L) (p₀⇩R, p₁⇩R) l ps⟧ ⟹ C₁ = c₁› 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]) (*goals: 1. ‹⋀(x1::int) (x2::int) (x1a::int) (x2a::int) (x1b::int) (x2b::int) (x1c::int) x2c::int. ⟦(C₀'::int × int) = (x1a, x2a); (C₁'::int × int) = (x1, x2); (p₁⇩L::int × int) = (x1, x2); (ps'::(int × int) list) = filter (λp::int × int. ∀(x1b::int) x2b::int. p = (x1b, x2b) ⟶ dist (real_of_int x1b, real_of_int x2b) (real_of_int (l::int), real_of_int x2b) < dist (real_of_int x1a, real_of_int x2a) (real_of_int x1, real_of_int x2)) (ps::(int × int) list); (p₀⇩L::int × int) = (x1a, x2a); (C₀::int × int, C₁::int × int) = find_closest_pair ((x1a, x2a), x1, x2) (filter (λp::int × int. ∀(x1b::int) x2b::int. p = (x1b, x2b) ⟶ dist (real_of_int x1b, real_of_int x2b) (real_of_int l, real_of_int x2b) < dist (real_of_int x1a, real_of_int x2a) (real_of_int x1, real_of_int x2)) ps); (c₀::int × int, c₁::int × int) = find_closest_pair ((x1a, x2a), x1, x2) (filter (λp::int × int. ∀(x1b::int) x2b::int. p = (x1b, x2b) ⟶ dist (real_of_int x1b, real_of_int x2b) (real_of_int l, real_of_int x2b) < dist (real_of_int x1a, real_of_int x2a) (real_of_int x1, real_of_int x2)) ps); (p₁⇩R::int × int) = (x1b, x2b); (p₀⇩R::int × int) = (x1c, x2c); dist (real_of_int x1a, real_of_int x2a) (real_of_int x1, real_of_int x2) < dist (real_of_int x1c, real_of_int x2c) (real_of_int x1b, real_of_int x2b)⟧ ⟹ C₀ = c₀› 2. ‹⋀(x1::int) (x2::int) (x1a::int) (x2a::int) (x1b::int) (x2b::int) (x1c::int) x2c::int. ⟦(C₀'::int × int) = (x1a, x2a); (C₁'::int × int) = (x1, x2); (p₁⇩R::int × int) = (x1, x2); (ps'::(int × int) list) = filter (λp::int × int. ∀(x1b::int) x2b::int. p = (x1b, x2b) ⟶ dist (real_of_int x1b, real_of_int x2b) (real_of_int (l::int), real_of_int x2b) < dist (real_of_int x1a, real_of_int x2a) (real_of_int x1, real_of_int x2)) (ps::(int × int) list); (p₀⇩R::int × int) = (x1a, x2a); (C₀::int × int, C₁::int × int) = find_closest_pair ((x1a, x2a), x1, x2) (filter (λp::int × int. ∀(x1b::int) x2b::int. p = (x1b, x2b) ⟶ dist (real_of_int x1b, real_of_int x2b) (real_of_int l, real_of_int x2b) < dist (real_of_int x1a, real_of_int x2a) (real_of_int x1, real_of_int x2)) ps); (c₀::int × int, c₁::int × int) = find_closest_pair ((x1a, x2a), x1, x2) (filter (λp::int × int. ∀(x1b::int) x2b::int. p = (x1b, x2b) ⟶ dist (real_of_int x1b, real_of_int x2b) (real_of_int l, real_of_int x2b) < dist (real_of_int x1a, real_of_int x2a) (real_of_int x1, real_of_int x2)) ps); (p₁⇩L::int × int) = (x1b, x2b); (p₀⇩L::int × int) = (x1c, x2c); ¬ dist (real_of_int x1c, real_of_int x2c) (real_of_int x1b, real_of_int x2b) < dist (real_of_int x1a, real_of_int x2a) (real_of_int x1, real_of_int x2)⟧ ⟹ C₀ = c₀› discuss goal 1*) apply (metis Pair_inject (*‹⟦(?a, ?b) = (?a', ?b'); ⟦?a = ?a'; ?b = ?b'⟧ ⟹ ?R⟧ ⟹ ?R›*)) (*discuss goal 2*) apply (metis Pair_inject (*‹⟦(?a, ?b) = (?a', ?b'); ⟦?a = ?a'; ?b = ?b'⟧ ⟹ ?R⟧ ⟹ ?R›*)) (*proven 2 subgoals*) (*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))›*) 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]) (*goals: 1. ‹⋀x1 x2 x1a x2a x1b x2b x1c x2c. ⟦C₀' = (x1a, x2a); C₁' = (x1, x2); p₁⇩L = (x1, x2); ps' = filter (λp. ∀x1b x2b. p = (x1b, x2b) ⟶ dist (real_of_int x1b, real_of_int x2b) (real_of_int l, real_of_int x2b) < dist (real_of_int x1a, real_of_int x2a) (real_of_int x1, real_of_int x2)) ps; p₀⇩L = (x1a, x2a); (C₀, C₁) = find_closest_pair ((x1a, x2a), x1, x2) (filter (λp. ∀x1b x2b. p = (x1b, x2b) ⟶ dist (real_of_int x1b, real_of_int x2b) (real_of_int l, real_of_int x2b) < dist (real_of_int x1a, real_of_int x2a) (real_of_int x1, real_of_int x2)) ps); (c₀, c₁) = find_closest_pair ((x1a, x2a), x1, x2) (filter (λp. ∀x1b x2b. p = (x1b, x2b) ⟶ dist (real_of_int x1b, real_of_int x2b) (real_of_int l, real_of_int x2b) < dist (real_of_int x1a, real_of_int x2a) (real_of_int x1, real_of_int x2)) ps); p₁⇩R = (x1b, x2b); p₀⇩R = (x1c, x2c); dist (real_of_int x1a, real_of_int x2a) (real_of_int x1, real_of_int x2) < dist (real_of_int x1c, real_of_int x2c) (real_of_int x1b, real_of_int x2b)⟧ ⟹ C₁ = c₁› 2. ‹⋀x1 x2 x1a x2a x1b x2b x1c x2c. ⟦C₀' = (x1a, x2a); C₁' = (x1, x2); p₁⇩R = (x1, x2); ps' = filter (λp. ∀x1b x2b. p = (x1b, x2b) ⟶ dist (real_of_int x1b, real_of_int x2b) (real_of_int l, real_of_int x2b) < dist (real_of_int x1a, real_of_int x2a) (real_of_int x1, real_of_int x2)) ps; p₀⇩R = (x1a, x2a); (C₀, C₁) = find_closest_pair ((x1a, x2a), x1, x2) (filter (λp. ∀x1b x2b. p = (x1b, x2b) ⟶ dist (real_of_int x1b, real_of_int x2b) (real_of_int l, real_of_int x2b) < dist (real_of_int x1a, real_of_int x2a) (real_of_int x1, real_of_int x2)) ps); (c₀, c₁) = find_closest_pair ((x1a, x2a), x1, x2) (filter (λp. ∀x1b x2b. p = (x1b, x2b) ⟶ dist (real_of_int x1b, real_of_int x2b) (real_of_int l, real_of_int x2b) < dist (real_of_int x1a, real_of_int x2a) (real_of_int x1, real_of_int x2)) ps); p₁⇩L = (x1b, x2b); p₀⇩L = (x1c, x2c); ¬ dist (real_of_int x1c, real_of_int x2c) (real_of_int x1b, real_of_int x2b) < dist (real_of_int x1a, real_of_int x2a) (real_of_int x1, real_of_int x2)⟧ ⟹ C₁ = c₁› discuss goal 1*) apply (metis Pair_inject (*‹⟦(?a, ?b) = (?a', ?b'); ⟦?a = ?a'; ?b = ?b'⟧ ⟹ ?R⟧ ⟹ ?R›*)) (*discuss goal 2*) apply (metis Pair_inject (*‹⟦(?a, ?b) = (?a', ?b'); ⟦?a = ?a'; ?b = ?b'⟧ ⟹ ?R⟧ ⟹ ?R›*)) (*proven 2 subgoals*) (*proven 2 subgoals*) . have ps': "ps' = filter (λp. l - dist C₀' C₁' < fst p ∧ fst p < l + dist C₀' C₁') ps" using ps'_def (*‹ps' = filter (λp. dist (case p of (x, y) ⇒ (real_of_int x, real_of_int y)) (case (l, snd p) of (x, y) ⇒ (real_of_int x, real_of_int y)) < dist (case C₀' of (x, y) ⇒ (real_of_int x, real_of_int y)) (case C₁' of (x, y) ⇒ (real_of_int x, real_of_int y))) ps›*) dist_transform (*‹(dist (case ?p of (x, y) ⇒ (real_of_int x, real_of_int y)) (case (?l, snd ?p) of (x, y) ⇒ (real_of_int x, real_of_int y)) < ?δ) = (real_of_int ?l - ?δ < real_of_int (fst ?p) ∧ real_of_int (fst ?p) < real_of_int ?l + ?δ)›*) by simp have "ps⇩L": "sparse (dist C₀' C₁') ps⇩L" using assms(3,5) (*‹∀p∈ps⇩L. fst p ≤ l› ‹sparse (dist (case p₀⇩L of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₁⇩L of (x, y) ⇒ (real_of_int x, real_of_int y))) ps⇩L›*) C'_def (*‹(C₀'::int × int, C₁'::int × int) = (if dist (case p₀⇩L::int × int of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) (case p₁⇩L::int × int of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) < dist (case p₀⇩R::int × int of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) (case p₁⇩R::int × int of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) then (p₀⇩L, p₁⇩L) else (p₀⇩R, p₁⇩R))›*) sparse_def (*‹sparse ?δ ?ps = (∀p₀∈?ps. ∀p₁∈?ps. p₀ ≠ p₁ ⟶ ?δ ≤ dist (case p₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₁ of (x, y) ⇒ (real_of_int x, real_of_int y)))›*) 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))›*)) (*goals: 1. ‹⋀a b aa ba. ⟦⋀δ ps. sparse δ ps = (∀p₀∈ps. ∀p₁∈ps. p₀ ≠ p₁ ⟶ δ ≤ dist (case p₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₁ of (x, y) ⇒ (real_of_int x, real_of_int y))); ∀p∈ps⇩L. fst p ≤ l; ∀p₀∈ps⇩L. ∀p₁∈ps⇩L. p₀ ≠ p₁ ⟶ dist (case p₀⇩L of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₁⇩L of (x, y) ⇒ (real_of_int x, real_of_int y)) ≤ dist (case p₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₁ of (x, y) ⇒ (real_of_int x, real_of_int y)); ¬ dist (case p₀⇩L of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₁⇩L of (x, y) ⇒ (real_of_int x, real_of_int y)) < dist (case p₀⇩R of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₁⇩R of (x, y) ⇒ (real_of_int x, real_of_int y)); (a, b) ∈ ps⇩L; (aa, ba) ∈ ps⇩L; C₀' = p₀⇩R; C₁' = p₁⇩R; ¬ dist (case p₀⇩R of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₁⇩R of (x, y) ⇒ (real_of_int x, real_of_int y)) ≤ dist (real_of_int a, real_of_int b) (real_of_int aa, real_of_int ba)⟧ ⟹ a = aa› 2. ‹⋀a b aa ba. ⟦⋀δ ps. sparse δ ps = (∀p₀∈ps. ∀p₁∈ps. p₀ ≠ p₁ ⟶ δ ≤ dist (case p₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₁ of (x, y) ⇒ (real_of_int x, real_of_int y))); ∀p∈ps⇩L. fst p ≤ l; ∀p₀∈ps⇩L. ∀p₁∈ps⇩L. p₀ ≠ p₁ ⟶ dist (case p₀⇩L of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₁⇩L of (x, y) ⇒ (real_of_int x, real_of_int y)) ≤ dist (case p₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₁ of (x, y) ⇒ (real_of_int x, real_of_int y)); ¬ dist (case p₀⇩L of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₁⇩L of (x, y) ⇒ (real_of_int x, real_of_int y)) < dist (case p₀⇩R of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₁⇩R of (x, y) ⇒ (real_of_int x, real_of_int y)); (a, b) ∈ ps⇩L; (aa, ba) ∈ ps⇩L; C₀' = p₀⇩R; C₁' = p₁⇩R; ¬ dist (case p₀⇩R of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₁⇩R of (x, y) ⇒ (real_of_int x, real_of_int y)) ≤ dist (real_of_int a, real_of_int b) (real_of_int aa, real_of_int ba)⟧ ⟹ b = ba› discuss goal 1*) apply force (*discuss goal 2*) apply force (*proven 2 subgoals*) . have "ps⇩R": "sparse (dist C₀' C₁') ps⇩R" using assms(4,6) (*‹∀p∈ps⇩R. l ≤ fst p› ‹sparse (dist (case p₀⇩R of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₁⇩R of (x, y) ⇒ (real_of_int x, real_of_int y))) ps⇩R›*) C'_def (*‹(C₀', C₁') = (if dist (case p₀⇩L of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₁⇩L of (x, y) ⇒ (real_of_int x, real_of_int y)) < dist (case p₀⇩R of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₁⇩R of (x, y) ⇒ (real_of_int x, real_of_int y)) then (p₀⇩L, p₁⇩L) else (p₀⇩R, p₁⇩R))›*) sparse_def (*‹sparse ?δ ?ps = (∀p₀∈?ps. ∀p₁∈?ps. p₀ ≠ p₁ ⟶ ?δ ≤ dist (case p₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₁ of (x, y) ⇒ (real_of_int x, real_of_int y)))›*) 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))›*)) (*goals: 1. ‹⋀a b aa ba. ⟦⋀δ ps. sparse δ ps = (∀p₀∈ps. ∀p₁∈ps. p₀ ≠ p₁ ⟶ δ ≤ dist (case p₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₁ of (x, y) ⇒ (real_of_int x, real_of_int y))); ∀p∈ps⇩R. l ≤ fst p; ∀p₀∈ps⇩R. ∀p₁∈ps⇩R. p₀ ≠ p₁ ⟶ dist (case p₀⇩R of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₁⇩R of (x, y) ⇒ (real_of_int x, real_of_int y)) ≤ dist (case p₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₁ of (x, y) ⇒ (real_of_int x, real_of_int y)); dist (case p₀⇩L of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₁⇩L of (x, y) ⇒ (real_of_int x, real_of_int y)) < dist (case p₀⇩R of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₁⇩R of (x, y) ⇒ (real_of_int x, real_of_int y)); (a, b) ∈ ps⇩R; (aa, ba) ∈ ps⇩R; C₀' = p₀⇩L; C₁' = p₁⇩L; ¬ dist (case p₀⇩L of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₁⇩L of (x, y) ⇒ (real_of_int x, real_of_int y)) ≤ dist (real_of_int a, real_of_int b) (real_of_int aa, real_of_int ba)⟧ ⟹ a = aa› 2. ‹⋀a b aa ba. ⟦⋀δ ps. sparse δ ps = (∀p₀∈ps. ∀p₁∈ps. p₀ ≠ p₁ ⟶ δ ≤ dist (case p₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₁ of (x, y) ⇒ (real_of_int x, real_of_int y))); ∀p∈ps⇩R. l ≤ fst p; ∀p₀∈ps⇩R. ∀p₁∈ps⇩R. p₀ ≠ p₁ ⟶ dist (case p₀⇩R of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₁⇩R of (x, y) ⇒ (real_of_int x, real_of_int y)) ≤ dist (case p₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₁ of (x, y) ⇒ (real_of_int x, real_of_int y)); dist (case p₀⇩L of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₁⇩L of (x, y) ⇒ (real_of_int x, real_of_int y)) < dist (case p₀⇩R of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₁⇩R of (x, y) ⇒ (real_of_int x, real_of_int y)); (a, b) ∈ ps⇩R; (aa, ba) ∈ ps⇩R; C₀' = p₀⇩L; C₁' = p₁⇩L; ¬ dist (case p₀⇩L of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₁⇩L of (x, y) ⇒ (real_of_int x, real_of_int y)) ≤ dist (real_of_int a, real_of_int b) (real_of_int aa, real_of_int ba)⟧ ⟹ b = ba› discuss goal 1*) apply force (*discuss goal 2*) apply force (*proven 2 subgoals*) . have "sorted_snd ps'" using ps'_def (*‹ps' = filter (λp. dist (case p of (x, y) ⇒ (real_of_int x, real_of_int y)) (case (l, snd p) of (x, y) ⇒ (real_of_int x, real_of_int y)) < dist (case C₀' of (x, y) ⇒ (real_of_int x, real_of_int y)) (case C₁' of (x, y) ⇒ (real_of_int x, real_of_int y))) ps›*) assms(1) (*‹sorted_snd ps›*) sorted_snd_def (*‹sorted_snd (?ps::(int × int) list) = sorted_wrt (λ(p₀::int × int) p₁::int × int. snd p₀ ≤ snd p₁) ?ps›*) sorted_wrt_filter (*‹sorted_wrt ?f ?xs ⟹ sorted_wrt ?f (filter ?P ?xs)›*) by blast hence "*": "sparse (dist C₀ C₁) (set ps')" using find_closest_pair_dist (*‹⟦sorted_snd ?ps; (?C₀, ?C₁) = find_closest_pair (?c₀, ?c₁) ?ps⟧ ⟹ sparse (dist (case ?C₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case ?C₁ of (x, y) ⇒ (real_of_int x, real_of_int y))) (set ?ps)›*) C_def (*‹(C₀::int × int, C₁::int × int) = find_closest_pair (C₀'::int × int, C₁'::int × int) (ps'::(int × int) list)›*) by simp have "∀p₀ ∈ set ps. ∀p₁ ∈ set ps. p₀ ≠ p₁ ∧ dist p₀ p₁ < dist C₀' C₁' ⟶ p₀ ∈ set ps' ∧ p₁ ∈ set ps'" using set_band_filter (*‹⟦?p₀ ∈ set ?ps; ?p₁ ∈ set ?ps; ?p₀ ≠ ?p₁; dist (case ?p₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case ?p₁ of (x, y) ⇒ (real_of_int x, real_of_int y)) < ?δ; set ?ps = ?ps⇩L ∪ ?ps⇩R; sparse ?δ ?ps⇩L; sparse ?δ ?ps⇩R; ∀p∈?ps⇩L. fst p ≤ ?l; ∀p∈?ps⇩R. ?l ≤ fst p; ?ps' = filter (λp. real_of_int ?l - ?δ < real_of_int (fst p) ∧ real_of_int (fst p) < real_of_int ?l + ?δ) ?ps⟧ ⟹ ?p₀ ∈ set ?ps' ∧ ?p₁ ∈ set ?ps'›*) ps' (*‹ps' = filter (λp. real_of_int l - dist (case C₀' of (x, y) ⇒ (real_of_int x, real_of_int y)) (case C₁' of (x, y) ⇒ (real_of_int x, real_of_int y)) < real_of_int (fst p) ∧ real_of_int (fst p) < real_of_int l + dist (case C₀' of (x, y) ⇒ (real_of_int x, real_of_int y)) (case C₁' of (x, y) ⇒ (real_of_int x, real_of_int y))) ps›*) "ps⇩L" (*‹sparse (dist (case C₀'::int × int of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) (case C₁'::int × int of (x::int, y::int) ⇒ (real_of_int x, real_of_int y))) (ps⇩L::(int × int) set)›*) "ps⇩R" (*‹sparse (dist (case C₀' of (x, y) ⇒ (real_of_int x, real_of_int y)) (case C₁' of (x, y) ⇒ (real_of_int x, real_of_int y))) ps⇩R›*) assms(2,3,4) (*‹set ps = ps⇩L ∪ ps⇩R› ‹∀p::int × int∈ps⇩L::(int × int) set. fst p ≤ (l::int)› ‹∀p∈ps⇩R. l ≤ fst p›*) by blast moreover have "dist C₀ C₁ ≤ dist C₀' C₁'" using C_def (*‹(C₀, C₁) = find_closest_pair (C₀', C₁') ps'›*) find_closest_pair_dist_mono (*‹(?C₀, ?C₁) = find_closest_pair (?c₀, ?c₁) ?ps ⟹ dist (case ?C₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case ?C₁ of (x, y) ⇒ (real_of_int x, real_of_int y)) ≤ dist (case ?c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case ?c₁ of (x, y) ⇒ (real_of_int x, real_of_int y))›*) by blast ultimately have "∀p₀ ∈ set ps. ∀p₁ ∈ set ps. p₀ ≠ p₁ ∧ dist p₀ p₁ < dist C₀ C₁ ⟶ p₀ ∈ set ps' ∧ p₁ ∈ set ps'" by simp hence "sparse (dist C₀ C₁) (set ps)" using sparse_def (*‹sparse ?δ ?ps = (∀p₀∈?ps. ∀p₁∈?ps. p₀ ≠ p₁ ⟶ ?δ ≤ dist (case p₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₁ of (x, y) ⇒ (real_of_int x, real_of_int y)))›*) "*" (*‹sparse (dist (case C₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case C₁ of (x, y) ⇒ (real_of_int x, real_of_int y))) (set ps')›*) by (meson not_less (*‹(¬ ?x < ?y) = (?y ≤ ?x)›*)) thus "?thesis" (*goal: ‹sparse (dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y))) (set ps)›*) using EQ (*‹C₀ = c₀› ‹C₁ = c₁›*) by blast qed declare combine.simps [simp del] declare combine_tm.simps[simp del] subsubsection "Divide and Conquer Algorithm" declare split_at_take_drop_conv [simp add] function closest_pair_rec_tm :: "point list ⇒ (point list × point × point) tm" where "closest_pair_rec_tm xs =1 ( do { n <- length_tm xs; if n ≤ 3 then do { ys <- mergesort_tm snd xs; p <- closest_pair_bf_tm xs; return (ys, p) } else do { (xs⇩L, xs⇩R) <- split_at_tm (n div 2) xs; (ys⇩L, p₀⇩L, p₁⇩L) <- closest_pair_rec_tm xs⇩L; (ys⇩R, p₀⇩R, p₁⇩R) <- closest_pair_rec_tm xs⇩R; ys <- merge_tm snd ys⇩L ys⇩R; (p₀, p₁) <- combine_tm (p₀⇩L, p₁⇩L) (p₀⇩R, p₁⇩R) (fst (hd xs⇩R)) ys; return (ys, p₀, p₁) } } )" by pat_completeness auto termination closest_pair_rec_tm by (relation "Wellfounded.measure (λxs. length xs)") (auto simp add: length_eq_val_length_tm split_at_eq_val_split_at_tm) function closest_pair_rec :: "point list ⇒ (point list * point * point)" where "closest_pair_rec xs = ( let n = length xs in if n ≤ 3 then (mergesort snd xs, closest_pair_bf xs) else let (xs⇩L, xs⇩R) = split_at (n div 2) xs in let (ys⇩L, p₀⇩L, p₁⇩L) = closest_pair_rec xs⇩L in let (ys⇩R, p₀⇩R, p₁⇩R) = closest_pair_rec xs⇩R in let ys = merge snd ys⇩L ys⇩R in (ys, combine (p₀⇩L, p₁⇩L) (p₀⇩R, p₁⇩R) (fst (hd xs⇩R)) ys) )" by pat_completeness auto termination closest_pair_rec by (relation "Wellfounded.measure (λxs. length xs)") (auto simp: Let_def) declare split_at_take_drop_conv [simp del] lemma closest_pair_rec_simps: assumes "n = length xs" "¬ (n ≤ 3)" shows "closest_pair_rec xs = ( let (xs⇩L, xs⇩R) = split_at (n div 2) xs in let (ys⇩L, p₀⇩L, p₁⇩L) = closest_pair_rec xs⇩L in let (ys⇩R, p₀⇩R, p₁⇩R) = closest_pair_rec xs⇩R in let ys = merge snd ys⇩L ys⇩R in (ys, combine (p₀⇩L, p₁⇩L) (p₀⇩R, p₁⇩R) (fst (hd xs⇩R)) ys) )" using assms (*‹(n::nat) = length (xs::(int × int) list)› ‹¬ n ≤ 3›*) by (auto simp: Let_def (*‹Let ?s ?f ≡ ?f ?s›*)) declare closest_pair_rec.simps [simp del] lemma closest_pair_rec_eq_val_closest_pair_rec_tm: "val (closest_pair_rec_tm xs) = closest_pair_rec xs" proof (induction rule: length_induct (*‹(⋀xs. ∀ys. length ys < length xs ⟶ ?P ys ⟹ ?P xs) ⟹ ?P ?xs›*)) (*goal: ‹⋀xs. ∀ys. length ys < length xs ⟶ Time_Monad.val (closest_pair_rec_tm ys) = closest_pair_rec ys ⟹ Time_Monad.val (closest_pair_rec_tm xs) = closest_pair_rec xs›*) case (1 xs) (*‹∀ys. length ys < length xs ⟶ Time_Monad.val (closest_pair_rec_tm ys) = closest_pair_rec ys›*) define n where "n = length xs" obtain xs⇩L and xs⇩R where xs_def: "(xs⇩L, xs⇩R) = split_at (n div 2) xs" (*goal: ‹(⋀(xs⇩L::(int × int) list) xs⇩R::(int × int) list. (xs⇩L, xs⇩R) = split_at ((n::nat) div (2::nat)) (xs::(int × int) list) ⟹ thesis::bool) ⟹ thesis›*) by (metis surj_pair (*‹∃(x::?'a) y::?'b. (?p::?'a × ?'b) = (x, y)›*)) note defs = n_def (*‹n = length xs›*) xs_def (*‹(xs⇩L::(int × int) list, xs⇩R::(int × int) list) = split_at ((n::nat) div (2::nat)) (xs::(int × int) list)›*) show "?case" (*goal: ‹Time_Monad.val (closest_pair_rec_tm xs) = closest_pair_rec xs›*) proof (cases) (*goals: 1. ‹?P ⟹ Time_Monad.val (closest_pair_rec_tm xs) = closest_pair_rec xs› 2. ‹¬ ?P ⟹ Time_Monad.val (closest_pair_rec_tm xs) = closest_pair_rec xs›*) assume "n ≤ 3" (*‹(n::nat) ≤ (3::nat)›*) then show "?thesis" (*goal: ‹Time_Monad.val (closest_pair_rec_tm xs) = closest_pair_rec xs›*) using defs (*‹n = length xs› ‹(xs⇩L::(int × int) list, xs⇩R::(int × int) list) = split_at ((n::nat) div (2::nat)) (xs::(int × int) list)›*) by (auto simp: length_eq_val_length_tm (*‹Time_Monad.val (length_tm ?xs) = length ?xs›*) mergesort_eq_val_mergesort_tm (*‹Time_Monad.val (mergesort_tm ?f ?xs) = mergesort ?f ?xs›*) closest_pair_bf_eq_val_closest_pair_bf_tm (*‹Time_Monad.val (closest_pair_bf_tm ?ps) = closest_pair_bf ?ps›*) closest_pair_rec.simps (*‹closest_pair_rec ?xs = (let n = length ?xs in if n ≤ 3 then (mergesort snd ?xs, closest_pair_bf ?xs) else let (xs⇩L, xs⇩R) = split_at (n div 2) ?xs; (ys⇩L, p₀⇩L, p₁⇩L) = closest_pair_rec xs⇩L; (ys⇩R, p₀⇩R, p₁⇩R) = closest_pair_rec xs⇩R; ys = Common.merge snd ys⇩L ys⇩R in (ys, combine (p₀⇩L, p₁⇩L) (p₀⇩R, p₁⇩R) (fst (hd xs⇩R)) ys))›*)) next (*goal: ‹¬ n ≤ 3 ⟹ Time_Monad.val (closest_pair_rec_tm xs) = closest_pair_rec xs›*) assume asm: "¬ n ≤ 3" (*‹¬ (n::nat) ≤ (3::nat)›*) have "length xs⇩L < length xs" "length xs⇩R < length xs" using asm (*‹¬ n ≤ 3›*) defs (*‹n = length xs› ‹(xs⇩L, xs⇩R) = split_at (n div 2) xs›*) apply - (*goals: 1. ‹⟦¬ n ≤ 3; n = length xs; (xs⇩L, xs⇩R) = split_at (n div 2) xs⟧ ⟹ length xs⇩L < length xs› 2. ‹⟦¬ n ≤ 3; n = length xs; (xs⇩L, xs⇩R) = split_at (n div 2) xs⟧ ⟹ length xs⇩R < length xs› discuss goal 1*) apply ((auto simp: split_at_take_drop_conv (*‹split_at ?n ?xs = (take ?n ?xs, drop ?n ?xs)›*))[1]) (*discuss goal 2*) apply ((auto simp: split_at_take_drop_conv (*‹split_at ?n ?xs = (take ?n ?xs, drop ?n ?xs)›*))[1]) (*proven 2 subgoals*) . hence "val (closest_pair_rec_tm xs⇩L) = closest_pair_rec xs⇩L" "val (closest_pair_rec_tm xs⇩R) = closest_pair_rec xs⇩R" using "1.IH" (*‹∀ys. length ys < length xs ⟶ Time_Monad.val (closest_pair_rec_tm ys) = closest_pair_rec ys›*) apply - (*goals: 1. ‹⟦length xs⇩L < length xs; length xs⇩R < length xs; ∀ys. length ys < length xs ⟶ Time_Monad.val (closest_pair_rec_tm ys) = closest_pair_rec ys⟧ ⟹ Time_Monad.val (closest_pair_rec_tm xs⇩L) = closest_pair_rec xs⇩L› 2. ‹⟦length xs⇩L < length xs; length xs⇩R < length xs; ∀ys. length ys < length xs ⟶ Time_Monad.val (closest_pair_rec_tm ys) = closest_pair_rec ys⟧ ⟹ Time_Monad.val (closest_pair_rec_tm xs⇩R) = closest_pair_rec xs⇩R› discuss goal 1*) apply blast (*discuss goal 2*) apply blast (*proven 2 subgoals*) . thus "?thesis" (*goal: ‹Time_Monad.val (closest_pair_rec_tm (xs::(int × int) list)) = closest_pair_rec xs›*) using asm (*‹¬ n ≤ 3›*) defs (*‹n = length xs› ‹(xs⇩L, xs⇩R) = split_at (n div 2) xs›*) apply (subst closest_pair_rec.simps (*‹closest_pair_rec (?xs::(int × int) list) = (let n::nat = length ?xs in if n ≤ (3::nat) then (mergesort snd ?xs, closest_pair_bf ?xs) else let (xs⇩L::(int × int) list, xs⇩R::(int × int) list) = split_at (n div (2::nat)) ?xs; (ys⇩L::(int × int) list, p₀⇩L::int × int, p₁⇩L::int × int) = closest_pair_rec xs⇩L; (ys⇩R::(int × int) list, p₀⇩R::int × int, p₁⇩R::int × int) = closest_pair_rec xs⇩R; ys::(int × int) list = Common.merge snd ys⇩L ys⇩R in (ys, combine (p₀⇩L, p₁⇩L) (p₀⇩R, p₁⇩R) (fst (hd xs⇩R)) ys))›*)) (*goal: ‹Time_Monad.val (closest_pair_rec_tm (xs::(int × int) list)) = closest_pair_rec xs›*) apply (subst closest_pair_rec_tm.simps (*‹closest_pair_rec_tm ?xs =1 length_tm ?xs ⤜ (λn. if n ≤ 3 then mergesort_tm snd ?xs ⤜ (λys. closest_pair_bf_tm ?xs ⤜ (λp. return (ys, p))) else split_at_tm (n div 2) ?xs ⤜ (λ(xs⇩L, xs⇩R). closest_pair_rec_tm xs⇩L ⤜ (λ(ys⇩L, p₀⇩L, p₁⇩L). closest_pair_rec_tm xs⇩R ⤜ (λ(ys⇩R, p₀⇩R, p₁⇩R). merge_tm snd ys⇩L ys⇩R ⤜ (λys. combine_tm (p₀⇩L, p₁⇩L) (p₀⇩R, p₁⇩R) (fst (hd xs⇩R)) ys ⤜ (λ(p₀, p₁). return (ys, p₀, p₁)))))))›*)) (*goal: ‹⟦Time_Monad.val (closest_pair_rec_tm xs⇩L) = closest_pair_rec xs⇩L; Time_Monad.val (closest_pair_rec_tm xs⇩R) = closest_pair_rec xs⇩R; ¬ n ≤ 3; n = length xs; (xs⇩L, xs⇩R) = split_at (n div 2) xs⟧ ⟹ Time_Monad.val (closest_pair_rec_tm xs) = (let n = length xs in if n ≤ 3 then (mergesort snd xs, closest_pair_bf xs) else let (xs⇩L, xs⇩R) = split_at (n div 2) xs; (ys⇩L, p₀⇩L, p₁⇩L) = closest_pair_rec xs⇩L; (ys⇩R, p₀⇩R, p₁⇩R) = closest_pair_rec xs⇩R; ys = Common.merge snd ys⇩L ys⇩R in (ys, combine (p₀⇩L, p₁⇩L) (p₀⇩R, p₁⇩R) (fst (hd xs⇩R)) ys))›*) by (auto simp del: closest_pair_rec_tm.simps (*‹closest_pair_rec_tm ?xs =1 length_tm ?xs ⤜ (λn. if n ≤ 3 then mergesort_tm snd ?xs ⤜ (λys. closest_pair_bf_tm ?xs ⤜ (λp. return (ys, p))) else split_at_tm (n div 2) ?xs ⤜ (λ(xs⇩L, xs⇩R). closest_pair_rec_tm xs⇩L ⤜ (λ(ys⇩L, p₀⇩L, p₁⇩L). closest_pair_rec_tm xs⇩R ⤜ (λ(ys⇩R, p₀⇩R, p₁⇩R). merge_tm snd ys⇩L ys⇩R ⤜ (λys. combine_tm (p₀⇩L, p₁⇩L) (p₀⇩R, p₁⇩R) (fst (hd xs⇩R)) ys ⤜ (λ(p₀, p₁). return (ys, p₀, p₁)))))))›*) simp add: Let_def (*‹Let ?s ?f ≡ ?f ?s›*) length_eq_val_length_tm (*‹Time_Monad.val (length_tm ?xs) = length ?xs›*) merge_eq_val_merge_tm (*‹Time_Monad.val (merge_tm ?f ?xs ?ys) = Common.merge ?f ?xs ?ys›*) split_at_eq_val_split_at_tm (*‹Time_Monad.val (split_at_tm ?n ?xs) = split_at ?n ?xs›*) combine_eq_val_combine_tm (*‹Time_Monad.val (combine_tm (?p₀⇩L, ?p₁⇩L) (?p₀⇩R, ?p₁⇩R) ?l ?ps) = combine (?p₀⇩L, ?p₁⇩L) (?p₀⇩R, ?p₁⇩R) ?l ?ps›*) split: prod.split (*‹?P (case ?prod of (x, xa) ⇒ ?f x xa) = (∀x1 x2. ?prod = (x1, x2) ⟶ ?P (?f x1 x2))›*)) qed qed lemma closest_pair_rec_set_length_sorted_snd: assumes "(ys, p) = closest_pair_rec xs" shows "set ys = set xs ∧ length ys = length xs ∧ sorted_snd ys" using assms (*‹(ys::(int × int) list, p::(int × int) × int × int) = closest_pair_rec (xs::(int × int) list)›*) proof (induction xs arbitrary: ys p rule: length_induct) (*goal: ‹⋀xs ys p. ⟦∀ys. length ys < length xs ⟶ (∀x xa. (x, xa) = closest_pair_rec ys ⟶ set x = set ys ∧ length x = length ys ∧ sorted_snd x); (ys, p) = closest_pair_rec xs⟧ ⟹ set ys = set xs ∧ length ys = length xs ∧ sorted_snd ys›*) case (1 xs) (*‹∀ys::(int × int) list. length ys < length (xs::(int × int) list) ⟶ (∀(x::(int × int) list) xa::(int × int) × int × int. (x, xa) = closest_pair_rec ys ⟶ set x = set ys ∧ length x = length ys ∧ sorted_snd x)› ‹(ys, p) = closest_pair_rec xs›*) let ?n = "length xs" show "?case" (*goal: ‹set ys = set xs ∧ length ys = length xs ∧ sorted_snd ys›*) proof (cases "?n ≤ 3") (*goals: 1. ‹length xs ≤ 3 ⟹ set ys = set xs ∧ length ys = length xs ∧ sorted_snd ys› 2. ‹¬ length xs ≤ 3 ⟹ set ys = set xs ∧ length ys = length xs ∧ sorted_snd ys›*) case True (*‹length xs ≤ 3›*) thus "?thesis" (*goal: ‹set (ys::(int × int) list) = set (xs::(int × int) list) ∧ length ys = length xs ∧ sorted_snd ys›*) using "1.prems" (*‹(ys, p) = closest_pair_rec xs›*) sorted_snd_def (*‹sorted_snd ?ps = sorted_wrt (λp₀ p₁. snd p₀ ≤ snd p₁) ?ps›*) by (auto simp: mergesort (*‹sorted_wrt (λ(x::?'a) y::?'a. (?f::?'a ⇒ ?'b) x ≤ ?f y) (mergesort ?f (?xs::?'a list))› ‹set (mergesort (?f::?'a ⇒ ?'b) (?xs::?'a list)) = set ?xs› ‹length (mergesort (?f::?'a ⇒ ?'b) (?xs::?'a list)) = length ?xs› ‹distinct (?xs::?'a list) ⟹ distinct (mergesort (?f::?'a ⇒ ?'b) ?xs)›*) closest_pair_rec.simps (*‹closest_pair_rec (?xs::(int × int) list) = (let n::nat = length ?xs in if n ≤ (3::nat) then (mergesort snd ?xs, closest_pair_bf ?xs) else let (xs⇩L::(int × int) list, xs⇩R::(int × int) list) = split_at (n div (2::nat)) ?xs; (ys⇩L::(int × int) list, p₀⇩L::int × int, p₁⇩L::int × int) = closest_pair_rec xs⇩L; (ys⇩R::(int × int) list, p₀⇩R::int × int, p₁⇩R::int × int) = closest_pair_rec xs⇩R; ys::(int × int) list = Common.merge snd ys⇩L ys⇩R in (ys, combine (p₀⇩L, p₁⇩L) (p₀⇩R, p₁⇩R) (fst (hd xs⇩R)) ys))›*)) next (*goal: ‹¬ length xs ≤ 3 ⟹ set ys = set xs ∧ length ys = length xs ∧ sorted_snd ys›*) case False (*‹¬ length xs ≤ 3›*) obtain XS⇩L and XS⇩R where "XS⇩L⇩R_def": "(XS⇩L, XS⇩R) = split_at (?n div 2) xs" (*goal: ‹(⋀XS⇩L XS⇩R. (XS⇩L, XS⇩R) = split_at (length xs div 2) xs ⟹ thesis) ⟹ thesis›*) using prod.collapse (*‹(fst ?prod, snd ?prod) = ?prod›*) by blast define L where "L = fst (hd XS⇩R)" obtain YS⇩L and P⇩L where "YSP⇩L_def": "(YS⇩L, P⇩L) = closest_pair_rec XS⇩L" (*goal: ‹(⋀YS⇩L P⇩L. (YS⇩L, P⇩L) = closest_pair_rec XS⇩L ⟹ thesis) ⟹ thesis›*) using prod.collapse (*‹(fst (?prod::?'a × ?'b), snd ?prod) = ?prod›*) by blast obtain YS⇩R and P⇩R where "YSP⇩R_def": "(YS⇩R, P⇩R) = closest_pair_rec XS⇩R" (*goal: ‹(⋀YS⇩R P⇩R. (YS⇩R, P⇩R) = closest_pair_rec XS⇩R ⟹ thesis) ⟹ thesis›*) using prod.collapse (*‹(fst ?prod, snd ?prod) = ?prod›*) by blast define YS where "YS = merge (λp. snd p) YS⇩L YS⇩R" define P where "P = combine P⇩L P⇩R L YS" note defs = "XS⇩L⇩R_def" (*‹(XS⇩L, XS⇩R) = split_at (length xs div 2) xs›*) L_def (*‹L = fst (hd XS⇩R)›*) "YSP⇩L_def" (*‹(YS⇩L, P⇩L) = closest_pair_rec XS⇩L›*) "YSP⇩R_def" (*‹(YS⇩R, P⇩R) = closest_pair_rec XS⇩R›*) YS_def (*‹YS = Common.merge snd YS⇩L YS⇩R›*) P_def (*‹P = combine P⇩L P⇩R L YS›*) have "length XS⇩L < length xs" "length XS⇩R < length xs" using False (*‹¬ length xs ≤ 3›*) defs (*‹(XS⇩L, XS⇩R) = split_at (length xs div 2) xs› ‹L = fst (hd XS⇩R)› ‹(YS⇩L, P⇩L) = closest_pair_rec XS⇩L› ‹(YS⇩R, P⇩R) = closest_pair_rec XS⇩R› ‹YS = Common.merge snd YS⇩L YS⇩R› ‹P = combine P⇩L P⇩R L YS›*) apply - (*goals: 1. ‹⟦¬ length xs ≤ 3; (XS⇩L, XS⇩R) = split_at (length xs div 2) xs; L = fst (hd XS⇩R); (YS⇩L, P⇩L) = closest_pair_rec XS⇩L; (YS⇩R, P⇩R) = closest_pair_rec XS⇩R; YS = Common.merge snd YS⇩L YS⇩R; P = combine P⇩L P⇩R L YS⟧ ⟹ length XS⇩L < length xs› 2. ‹⟦¬ length xs ≤ 3; (XS⇩L, XS⇩R) = split_at (length xs div 2) xs; L = fst (hd XS⇩R); (YS⇩L, P⇩L) = closest_pair_rec XS⇩L; (YS⇩R, P⇩R) = closest_pair_rec XS⇩R; YS = Common.merge snd YS⇩L YS⇩R; P = combine P⇩L P⇩R L YS⟧ ⟹ length XS⇩R < length xs› discuss goal 1*) apply ((auto simp: split_at_take_drop_conv (*‹split_at (?n::nat) (?xs::?'a::type list) = (take ?n ?xs, drop ?n ?xs)›*))[1]) (*discuss goal 2*) apply ((auto simp: split_at_take_drop_conv (*‹split_at ?n ?xs = (take ?n ?xs, drop ?n ?xs)›*))[1]) (*proven 2 subgoals*) . hence IH: "set XS⇩L = set YS⇩L" "set XS⇩R = set YS⇩R" "length XS⇩L = length YS⇩L" "length XS⇩R = length YS⇩R" "sorted_snd YS⇩L" "sorted_snd YS⇩R" using "1.IH" (*‹∀ys. length ys < length xs ⟶ (∀x xa. (x, xa) = closest_pair_rec ys ⟶ set x = set ys ∧ length x = length ys ∧ sorted_snd x)›*) defs (*‹(XS⇩L, XS⇩R) = split_at (length xs div 2) xs› ‹L = fst (hd XS⇩R)› ‹(YS⇩L, P⇩L) = closest_pair_rec XS⇩L› ‹(YS⇩R, P⇩R) = closest_pair_rec XS⇩R› ‹YS = Common.merge snd YS⇩L YS⇩R› ‹P = combine P⇩L P⇩R L YS›*) apply - (*goals: 1. ‹⟦length XS⇩L < length xs; length XS⇩R < length xs; ∀ys. length ys < length xs ⟶ (∀x xa. (x, xa) = closest_pair_rec ys ⟶ set x = set ys ∧ length x = length ys ∧ sorted_snd x); (XS⇩L, XS⇩R) = split_at (length xs div 2) xs; L = fst (hd XS⇩R); (YS⇩L, P⇩L) = closest_pair_rec XS⇩L; (YS⇩R, P⇩R) = closest_pair_rec XS⇩R; YS = Common.merge snd YS⇩L YS⇩R; P = combine P⇩L P⇩R L YS⟧ ⟹ set XS⇩L = set YS⇩L› 2. ‹⟦length XS⇩L < length xs; length XS⇩R < length xs; ∀ys. length ys < length xs ⟶ (∀x xa. (x, xa) = closest_pair_rec ys ⟶ set x = set ys ∧ length x = length ys ∧ sorted_snd x); (XS⇩L, XS⇩R) = split_at (length xs div 2) xs; L = fst (hd XS⇩R); (YS⇩L, P⇩L) = closest_pair_rec XS⇩L; (YS⇩R, P⇩R) = closest_pair_rec XS⇩R; YS = Common.merge snd YS⇩L YS⇩R; P = combine P⇩L P⇩R L YS⟧ ⟹ set XS⇩R = set YS⇩R› 3. ‹⟦length XS⇩L < length xs; length XS⇩R < length xs; ∀ys. length ys < length xs ⟶ (∀x xa. (x, xa) = closest_pair_rec ys ⟶ set x = set ys ∧ length x = length ys ∧ sorted_snd x); (XS⇩L, XS⇩R) = split_at (length xs div 2) xs; L = fst (hd XS⇩R); (YS⇩L, P⇩L) = closest_pair_rec XS⇩L; (YS⇩R, P⇩R) = closest_pair_rec XS⇩R; YS = Common.merge snd YS⇩L YS⇩R; P = combine P⇩L P⇩R L YS⟧ ⟹ length XS⇩L = length YS⇩L› 4. ‹⟦length XS⇩L < length xs; length XS⇩R < length xs; ∀ys. length ys < length xs ⟶ (∀x xa. (x, xa) = closest_pair_rec ys ⟶ set x = set ys ∧ length x = length ys ∧ sorted_snd x); (XS⇩L, XS⇩R) = split_at (length xs div 2) xs; L = fst (hd XS⇩R); (YS⇩L, P⇩L) = closest_pair_rec XS⇩L; (YS⇩R, P⇩R) = closest_pair_rec XS⇩R; YS = Common.merge snd YS⇩L YS⇩R; P = combine P⇩L P⇩R L YS⟧ ⟹ length XS⇩R = length YS⇩R› 5. ‹⟦length XS⇩L < length xs; length XS⇩R < length xs; ∀ys. length ys < length xs ⟶ (∀x xa. (x, xa) = closest_pair_rec ys ⟶ set x = set ys ∧ length x = length ys ∧ sorted_snd x); (XS⇩L, XS⇩R) = split_at (length xs div 2) xs; L = fst (hd XS⇩R); (YS⇩L, P⇩L) = closest_pair_rec XS⇩L; (YS⇩R, P⇩R) = closest_pair_rec XS⇩R; YS = Common.merge snd YS⇩L YS⇩R; P = combine P⇩L P⇩R L YS⟧ ⟹ sorted_snd YS⇩L› 6. ‹⟦length XS⇩L < length xs; length XS⇩R < length xs; ∀ys. length ys < length xs ⟶ (∀x xa. (x, xa) = closest_pair_rec ys ⟶ set x = set ys ∧ length x = length ys ∧ sorted_snd x); (XS⇩L, XS⇩R) = split_at (length xs div 2) xs; L = fst (hd XS⇩R); (YS⇩L, P⇩L) = closest_pair_rec XS⇩L; (YS⇩R, P⇩R) = closest_pair_rec XS⇩R; YS = Common.merge snd YS⇩L YS⇩R; P = combine P⇩L P⇩R L YS⟧ ⟹ sorted_snd YS⇩R› 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 (*discuss goal 6*) apply metis (*proven 6 subgoals*) . have "set xs = set XS⇩L ∪ set XS⇩R" using defs (*‹(XS⇩L, XS⇩R) = split_at (length xs div 2) xs› ‹L = fst (hd XS⇩R)› ‹(YS⇩L, P⇩L) = closest_pair_rec XS⇩L› ‹(YS⇩R, P⇩R) = closest_pair_rec XS⇩R› ‹YS = Common.merge snd YS⇩L YS⇩R› ‹P = combine P⇩L P⇩R L YS›*) by (auto simp: set_take_drop (*‹set ?xs = set (take ?n ?xs) ∪ set (drop ?n ?xs)›*) split_at_take_drop_conv (*‹split_at ?n ?xs = (take ?n ?xs, drop ?n ?xs)›*)) hence SET: "set xs = set YS" using set_merge (*‹set (Common.merge ?f ?xs ?ys) = set ?xs ∪ set ?ys›*) IH(1,2) (*‹set XS⇩L = set YS⇩L› ‹set XS⇩R = set YS⇩R›*) defs (*‹(XS⇩L, XS⇩R) = split_at (length xs div 2) xs› ‹(L::int) = fst (hd (XS⇩R::(int × int) list))› ‹(YS⇩L, P⇩L) = closest_pair_rec XS⇩L› ‹(YS⇩R, P⇩R) = closest_pair_rec XS⇩R› ‹YS = Common.merge snd YS⇩L YS⇩R› ‹P = combine P⇩L P⇩R L YS›*) by fast have "length xs = length XS⇩L + length XS⇩R" using defs (*‹(XS⇩L, XS⇩R) = split_at (length xs div 2) xs› ‹L = fst (hd XS⇩R)› ‹(YS⇩L, P⇩L) = closest_pair_rec XS⇩L› ‹(YS⇩R, P⇩R) = closest_pair_rec XS⇩R› ‹(YS::(int × int) list) = Common.merge snd (YS⇩L::(int × int) list) (YS⇩R::(int × int) list)› ‹P = combine P⇩L P⇩R L YS›*) by (auto simp: split_at_take_drop_conv (*‹split_at ?n ?xs = (take ?n ?xs, drop ?n ?xs)›*)) hence LENGTH: "length xs = length YS" using IH(3,4) (*‹length (XS⇩L::(int × int) list) = length (YS⇩L::(int × int) list)› ‹length (XS⇩R::(int × int) list) = length (YS⇩R::(int × int) list)›*) length_merge (*‹length (Common.merge ?f ?xs ?ys) = length ?xs + length ?ys›*) defs (*‹(XS⇩L, XS⇩R) = split_at (length xs div 2) xs› ‹(L::int) = fst (hd (XS⇩R::(int × int) list))› ‹(YS⇩L, P⇩L) = closest_pair_rec XS⇩L› ‹(YS⇩R::(int × int) list, P⇩R::(int × int) × int × int) = closest_pair_rec (XS⇩R::(int × int) list)› ‹YS = Common.merge snd YS⇩L YS⇩R› ‹P = combine P⇩L P⇩R L YS›*) by metis have SORTED: "sorted_snd YS" using IH(5,6) (*‹sorted_snd YS⇩L› ‹sorted_snd YS⇩R›*) by (simp add: defs (*‹(XS⇩L, XS⇩R) = split_at (length xs div 2) xs› ‹L = fst (hd XS⇩R)› ‹(YS⇩L, P⇩L) = closest_pair_rec XS⇩L› ‹(YS⇩R, P⇩R) = closest_pair_rec XS⇩R› ‹YS = Common.merge snd YS⇩L YS⇩R› ‹P = combine P⇩L P⇩R L YS›*) sorted_snd_def (*‹sorted_snd ?ps = sorted_wrt (λp₀ p₁. snd p₀ ≤ snd p₁) ?ps›*) sorted_merge (*‹?P = (λx y. ?f x ≤ ?f y) ⟹ sorted_wrt ?P (Common.merge ?f ?xs ?ys) = (sorted_wrt ?P ?xs ∧ sorted_wrt ?P ?ys)›*)) have "(YS, P) = closest_pair_rec xs" using False (*‹¬ length (xs::(int × int) list) ≤ (3::nat)›*) closest_pair_rec_simps (*‹⟦?n = length ?xs; ¬ ?n ≤ 3⟧ ⟹ closest_pair_rec ?xs = (let (xs⇩L, xs⇩R) = split_at (?n div 2) ?xs; (ys⇩L, p₀⇩L, p₁⇩L) = closest_pair_rec xs⇩L; (ys⇩R, p₀⇩R, p₁⇩R) = closest_pair_rec xs⇩R; ys = Common.merge snd ys⇩L ys⇩R in (ys, combine (p₀⇩L, p₁⇩L) (p₀⇩R, p₁⇩R) (fst (hd xs⇩R)) ys))›*) defs (*‹(XS⇩L, XS⇩R) = split_at (length xs div 2) xs› ‹L = fst (hd XS⇩R)› ‹(YS⇩L::(int × int) list, P⇩L::(int × int) × int × int) = closest_pair_rec (XS⇩L::(int × int) list)› ‹(YS⇩R::(int × int) list, P⇩R::(int × int) × int × int) = closest_pair_rec (XS⇩R::(int × int) list)› ‹YS = Common.merge snd YS⇩L YS⇩R› ‹P = combine P⇩L P⇩R L YS›*) by (auto simp: Let_def (*‹Let ?s ?f ≡ ?f ?s›*) split: prod.split (*‹?P (case ?prod of (x, xa) ⇒ ?f x xa) = (∀x1 x2. ?prod = (x1, x2) ⟶ ?P (?f x1 x2))›*)) hence "(ys, p) = (YS, P)" using "1.prems" (*‹(ys, p) = closest_pair_rec xs›*) by argo thus "?thesis" (*goal: ‹set ys = set xs ∧ length ys = length xs ∧ sorted_snd ys›*) using SET (*‹set xs = set YS›*) LENGTH (*‹length xs = length YS›*) SORTED (*‹sorted_snd YS›*) by simp qed qed lemma closest_pair_rec_distinct: assumes "distinct xs" "(ys, p) = closest_pair_rec xs" shows "distinct ys" using assms (*‹distinct xs› ‹(ys::(int × int) list, p::(int × int) × int × int) = closest_pair_rec (xs::(int × int) list)›*) proof (induction xs arbitrary: ys p rule: length_induct) (*goal: ‹⋀xs ys p. ⟦∀ys. length ys < length xs ⟶ distinct ys ⟶ (∀x xa. (x, xa) = closest_pair_rec ys ⟶ distinct x); distinct xs; (ys, p) = closest_pair_rec xs⟧ ⟹ distinct ys›*) case (1 xs) (*‹∀ys. length ys < length xs ⟶ distinct ys ⟶ (∀x xa. (x, xa) = closest_pair_rec ys ⟶ distinct x)› ‹distinct (xs::(int × int) list)› ‹(ys, p) = closest_pair_rec xs›*) let ?n = "length xs" show "?case" (*goal: ‹distinct (ys::(int × int) list)›*) proof (cases "?n ≤ 3") (*goals: 1. ‹length xs ≤ 3 ⟹ distinct ys› 2. ‹¬ length xs ≤ 3 ⟹ distinct ys›*) case True (*‹length xs ≤ 3›*) thus "?thesis" (*goal: ‹distinct ys›*) using "1.prems" (*‹distinct xs› ‹(ys::(int × int) list, p::(int × int) × int × int) = closest_pair_rec (xs::(int × int) list)›*) by (auto simp: mergesort (*‹sorted_wrt (λx y. ?f x ≤ ?f y) (mergesort ?f ?xs)› ‹set (mergesort ?f ?xs) = set ?xs› ‹length (mergesort ?f ?xs) = length ?xs› ‹distinct ?xs ⟹ distinct (mergesort ?f ?xs)›*) closest_pair_rec.simps (*‹closest_pair_rec ?xs = (let n = length ?xs in if n ≤ 3 then (mergesort snd ?xs, closest_pair_bf ?xs) else let (xs⇩L, xs⇩R) = split_at (n div 2) ?xs; (ys⇩L, p₀⇩L, p₁⇩L) = closest_pair_rec xs⇩L; (ys⇩R, p₀⇩R, p₁⇩R) = closest_pair_rec xs⇩R; ys = Common.merge snd ys⇩L ys⇩R in (ys, combine (p₀⇩L, p₁⇩L) (p₀⇩R, p₁⇩R) (fst (hd xs⇩R)) ys))›*)) next (*goal: ‹¬ length xs ≤ 3 ⟹ distinct ys›*) case False (*‹¬ length xs ≤ 3›*) obtain XS⇩L and XS⇩R where "XS⇩L⇩R_def": "(XS⇩L, XS⇩R) = split_at (?n div 2) xs" (*goal: ‹(⋀XS⇩L XS⇩R. (XS⇩L, XS⇩R) = split_at (length xs div 2) xs ⟹ thesis) ⟹ thesis›*) using prod.collapse (*‹(fst (?prod::?'a × ?'b), snd ?prod) = ?prod›*) by blast define L where "L = fst (hd XS⇩R)" obtain YS⇩L and P⇩L where "YSP⇩L_def": "(YS⇩L, P⇩L) = closest_pair_rec XS⇩L" (*goal: ‹(⋀(YS⇩L::(int × int) list) P⇩L::(int × int) × int × int. (YS⇩L, P⇩L) = closest_pair_rec (XS⇩L::(int × int) list) ⟹ thesis::bool) ⟹ thesis›*) using prod.collapse (*‹(fst (?prod::?'a × ?'b), snd ?prod) = ?prod›*) by blast obtain YS⇩R and P⇩R where "YSP⇩R_def": "(YS⇩R, P⇩R) = closest_pair_rec XS⇩R" (*goal: ‹(⋀YS⇩R P⇩R. (YS⇩R, P⇩R) = closest_pair_rec XS⇩R ⟹ thesis) ⟹ thesis›*) using prod.collapse (*‹(fst ?prod, snd ?prod) = ?prod›*) by blast define YS where "YS = merge (λp. snd p) YS⇩L YS⇩R" define P where "P = combine P⇩L P⇩R L YS" note defs = "XS⇩L⇩R_def" (*‹(XS⇩L, XS⇩R) = split_at (length xs div 2) xs›*) L_def (*‹L = fst (hd XS⇩R)›*) "YSP⇩L_def" (*‹(YS⇩L, P⇩L) = closest_pair_rec XS⇩L›*) "YSP⇩R_def" (*‹(YS⇩R, P⇩R) = closest_pair_rec XS⇩R›*) YS_def (*‹YS = Common.merge snd YS⇩L YS⇩R›*) P_def (*‹(P::(int × int) × int × int) = combine (P⇩L::(int × int) × int × int) (P⇩R::(int × int) × int × int) (L::int) (YS::(int × int) list)›*) have "length XS⇩L < length xs" "length XS⇩R < length xs" using False (*‹¬ length xs ≤ 3›*) defs (*‹(XS⇩L, XS⇩R) = split_at (length xs div 2) xs› ‹L = fst (hd XS⇩R)› ‹(YS⇩L, P⇩L) = closest_pair_rec XS⇩L› ‹(YS⇩R::(int × int) list, P⇩R::(int × int) × int × int) = closest_pair_rec (XS⇩R::(int × int) list)› ‹YS = Common.merge snd YS⇩L YS⇩R› ‹(P::(int × int) × int × int) = combine (P⇩L::(int × int) × int × int) (P⇩R::(int × int) × int × int) (L::int) (YS::(int × int) list)›*) apply - (*goals: 1. ‹⟦¬ length xs ≤ 3; (XS⇩L, XS⇩R) = split_at (length xs div 2) xs; L = fst (hd XS⇩R); (YS⇩L, P⇩L) = closest_pair_rec XS⇩L; (YS⇩R, P⇩R) = closest_pair_rec XS⇩R; YS = Common.merge snd YS⇩L YS⇩R; P = combine P⇩L P⇩R L YS⟧ ⟹ length XS⇩L < length xs› 2. ‹⟦¬ length xs ≤ 3; (XS⇩L, XS⇩R) = split_at (length xs div 2) xs; L = fst (hd XS⇩R); (YS⇩L, P⇩L) = closest_pair_rec XS⇩L; (YS⇩R, P⇩R) = closest_pair_rec XS⇩R; YS = Common.merge snd YS⇩L YS⇩R; P = combine P⇩L P⇩R L YS⟧ ⟹ length XS⇩R < length xs› discuss goal 1*) apply ((auto simp: split_at_take_drop_conv (*‹split_at ?n ?xs = (take ?n ?xs, drop ?n ?xs)›*))[1]) (*discuss goal 2*) apply ((auto simp: split_at_take_drop_conv (*‹split_at ?n ?xs = (take ?n ?xs, drop ?n ?xs)›*))[1]) (*proven 2 subgoals*) . moreover have "distinct XS⇩L" "distinct XS⇩R" using "1.prems"(1) (*‹distinct xs›*) defs (*‹(XS⇩L::(int × int) list, XS⇩R::(int × int) list) = split_at (length (xs::(int × int) list) div (2::nat)) xs› ‹L = fst (hd XS⇩R)› ‹(YS⇩L::(int × int) list, P⇩L::(int × int) × int × int) = closest_pair_rec (XS⇩L::(int × int) list)› ‹(YS⇩R, P⇩R) = closest_pair_rec XS⇩R› ‹YS = Common.merge snd YS⇩L YS⇩R› ‹P = combine P⇩L P⇩R L YS›*) apply - (*goals: 1. ‹⟦distinct xs; (XS⇩L, XS⇩R) = split_at (length xs div 2) xs; L = fst (hd XS⇩R); (YS⇩L, P⇩L) = closest_pair_rec XS⇩L; (YS⇩R, P⇩R) = closest_pair_rec XS⇩R; YS = Common.merge snd YS⇩L YS⇩R; P = combine P⇩L P⇩R L YS⟧ ⟹ distinct XS⇩L› 2. ‹⟦distinct xs; (XS⇩L, XS⇩R) = split_at (length xs div 2) xs; L = fst (hd XS⇩R); (YS⇩L, P⇩L) = closest_pair_rec XS⇩L; (YS⇩R, P⇩R) = closest_pair_rec XS⇩R; YS = Common.merge snd YS⇩L YS⇩R; P = combine P⇩L P⇩R L YS⟧ ⟹ distinct XS⇩R› discuss goal 1*) apply ((auto simp: split_at_take_drop_conv (*‹split_at ?n ?xs = (take ?n ?xs, drop ?n ?xs)›*))[1]) (*discuss goal 2*) apply ((auto simp: split_at_take_drop_conv (*‹split_at ?n ?xs = (take ?n ?xs, drop ?n ?xs)›*))[1]) (*proven 2 subgoals*) . ultimately have IH: "distinct YS⇩L" "distinct YS⇩R" using "1.IH" (*‹∀ys. length ys < length xs ⟶ distinct ys ⟶ (∀x xa. (x, xa) = closest_pair_rec ys ⟶ distinct x)›*) defs (*‹(XS⇩L, XS⇩R) = split_at (length xs div 2) xs› ‹L = fst (hd XS⇩R)› ‹(YS⇩L, P⇩L) = closest_pair_rec XS⇩L› ‹(YS⇩R, P⇩R) = closest_pair_rec XS⇩R› ‹YS = Common.merge snd YS⇩L YS⇩R› ‹P = combine P⇩L P⇩R L YS›*) apply - (*goals: 1. ‹⟦length XS⇩L < length xs; length XS⇩R < length xs; distinct XS⇩L; distinct XS⇩R; ∀ys. length ys < length xs ⟶ distinct ys ⟶ (∀x xa. (x, xa) = closest_pair_rec ys ⟶ distinct x); (XS⇩L, XS⇩R) = split_at (length xs div 2) xs; L = fst (hd XS⇩R); (YS⇩L, P⇩L) = closest_pair_rec XS⇩L; (YS⇩R, P⇩R) = closest_pair_rec XS⇩R; YS = Common.merge snd YS⇩L YS⇩R; P = combine P⇩L P⇩R L YS⟧ ⟹ distinct YS⇩L› 2. ‹⟦length XS⇩L < length xs; length XS⇩R < length xs; distinct XS⇩L; distinct XS⇩R; ∀ys. length ys < length xs ⟶ distinct ys ⟶ (∀x xa. (x, xa) = closest_pair_rec ys ⟶ distinct x); (XS⇩L, XS⇩R) = split_at (length xs div 2) xs; L = fst (hd XS⇩R); (YS⇩L, P⇩L) = closest_pair_rec XS⇩L; (YS⇩R, P⇩R) = closest_pair_rec XS⇩R; YS = Common.merge snd YS⇩L YS⇩R; P = combine P⇩L P⇩R L YS⟧ ⟹ distinct YS⇩R› discuss goal 1*) apply blast (*discuss goal 2*) apply blast (*proven 2 subgoals*) . have "set XS⇩L ∩ set XS⇩R = {}" using "1.prems"(1) (*‹distinct xs›*) defs (*‹(XS⇩L, XS⇩R) = split_at (length xs div 2) xs› ‹L = fst (hd XS⇩R)› ‹(YS⇩L, P⇩L) = closest_pair_rec XS⇩L› ‹(YS⇩R::(int × int) list, P⇩R::(int × int) × int × int) = closest_pair_rec (XS⇩R::(int × int) list)› ‹YS = Common.merge snd YS⇩L YS⇩R› ‹(P::(int × int) × int × int) = combine (P⇩L::(int × int) × int × int) (P⇩R::(int × int) × int × int) (L::int) (YS::(int × int) list)›*) by (auto simp: split_at_take_drop_conv (*‹split_at ?n ?xs = (take ?n ?xs, drop ?n ?xs)›*) set_take_disj_set_drop_if_distinct (*‹⟦distinct ?vs; ?i ≤ ?j⟧ ⟹ set (take ?i ?vs) ∩ set (drop ?j ?vs) = {}›*)) moreover have "set XS⇩L = set YS⇩L" "set XS⇩R = set YS⇩R" using closest_pair_rec_set_length_sorted_snd (*‹(?ys, ?p) = closest_pair_rec ?xs ⟹ set ?ys = set ?xs ∧ length ?ys = length ?xs ∧ sorted_snd ?ys›*) defs (*‹(XS⇩L, XS⇩R) = split_at (length xs div 2) xs› ‹L = fst (hd XS⇩R)› ‹(YS⇩L, P⇩L) = closest_pair_rec XS⇩L› ‹(YS⇩R::(int × int) list, P⇩R::(int × int) × int × int) = closest_pair_rec (XS⇩R::(int × int) list)› ‹YS = Common.merge snd YS⇩L YS⇩R› ‹P = combine P⇩L P⇩R L YS›*) apply - (*goals: 1. ‹⟦⋀ys p xs. (ys, p) = closest_pair_rec xs ⟹ set ys = set xs ∧ length ys = length xs ∧ sorted_snd ys; (XS⇩L, XS⇩R) = split_at (length xs div 2) xs; L = fst (hd XS⇩R); (YS⇩L, P⇩L) = closest_pair_rec XS⇩L; (YS⇩R, P⇩R) = closest_pair_rec XS⇩R; YS = Common.merge snd YS⇩L YS⇩R; P = combine P⇩L P⇩R L YS⟧ ⟹ set XS⇩L = set YS⇩L› 2. ‹⟦⋀ys p xs. (ys, p) = closest_pair_rec xs ⟹ set ys = set xs ∧ length ys = length xs ∧ sorted_snd ys; (XS⇩L, XS⇩R) = split_at (length xs div 2) xs; L = fst (hd XS⇩R); (YS⇩L, P⇩L) = closest_pair_rec XS⇩L; (YS⇩R, P⇩R) = closest_pair_rec XS⇩R; YS = Common.merge snd YS⇩L YS⇩R; P = combine P⇩L P⇩R L YS⟧ ⟹ set XS⇩R = set YS⇩R› discuss goal 1*) apply blast (*discuss goal 2*) apply blast (*proven 2 subgoals*) . ultimately have "set YS⇩L ∩ set YS⇩R = {}" by blast hence DISTINCT: "distinct YS" using distinct_merge (*‹⟦set ?xs ∩ set ?ys = {}; distinct ?xs; distinct ?ys⟧ ⟹ distinct (Common.merge ?f ?xs ?ys)›*) IH (*‹distinct YS⇩L› ‹distinct YS⇩R›*) defs (*‹(XS⇩L::(int × int) list, XS⇩R::(int × int) list) = split_at (length (xs::(int × int) list) div (2::nat)) xs› ‹L = fst (hd XS⇩R)› ‹(YS⇩L, P⇩L) = closest_pair_rec XS⇩L› ‹(YS⇩R, P⇩R) = closest_pair_rec XS⇩R› ‹YS = Common.merge snd YS⇩L YS⇩R› ‹P = combine P⇩L P⇩R L YS›*) by blast have "(YS, P) = closest_pair_rec xs" using False (*‹¬ length (xs::(int × int) list) ≤ (3::nat)›*) closest_pair_rec_simps (*‹⟦?n = length ?xs; ¬ ?n ≤ 3⟧ ⟹ closest_pair_rec ?xs = (let (xs⇩L, xs⇩R) = split_at (?n div 2) ?xs; (ys⇩L, p₀⇩L, p₁⇩L) = closest_pair_rec xs⇩L; (ys⇩R, p₀⇩R, p₁⇩R) = closest_pair_rec xs⇩R; ys = Common.merge snd ys⇩L ys⇩R in (ys, combine (p₀⇩L, p₁⇩L) (p₀⇩R, p₁⇩R) (fst (hd xs⇩R)) ys))›*) defs (*‹(XS⇩L, XS⇩R) = split_at (length xs div 2) xs› ‹L = fst (hd XS⇩R)› ‹(YS⇩L, P⇩L) = closest_pair_rec XS⇩L› ‹(YS⇩R, P⇩R) = closest_pair_rec XS⇩R› ‹YS = Common.merge snd YS⇩L YS⇩R› ‹P = combine P⇩L P⇩R L YS›*) by (auto simp: Let_def (*‹Let ?s ?f ≡ ?f ?s›*) split: prod.split (*‹?P (case ?prod of (x, xa) ⇒ ?f x xa) = (∀x1 x2. ?prod = (x1, x2) ⟶ ?P (?f x1 x2))›*)) hence "(ys, p) = (YS, P)" using "1.prems" (*‹distinct (xs::(int × int) list)› ‹(ys::(int × int) list, p::(int × int) × int × int) = closest_pair_rec (xs::(int × int) list)›*) by argo thus "?thesis" (*goal: ‹distinct ys›*) using DISTINCT (*‹distinct YS›*) by blast qed qed lemma closest_pair_rec_c0_c1: assumes "1 < length xs" "distinct xs" "(ys, c₀, c₁) = closest_pair_rec xs" shows "c₀ ∈ set xs ∧ c₁ ∈ set xs ∧ c₀ ≠ c₁" using assms (*‹1 < length xs› ‹distinct xs› ‹(ys, c₀, c₁) = closest_pair_rec xs›*) proof (induction xs arbitrary: ys c₀ c₁ rule: length_induct) (*goal: ‹⋀(xs::(int × int) list) (ys::(int × int) list) (c₀::int × int) c₁::int × int. ⟦∀ys::(int × int) list. length ys < length xs ⟶ (1::nat) < length ys ⟶ distinct ys ⟶ (∀(x::(int × int) list) (xa::int × int) xb::int × int. (x, xa, xb) = closest_pair_rec ys ⟶ xa ∈ set ys ∧ xb ∈ set ys ∧ xa ≠ xb); (1::nat) < length xs; distinct xs; (ys, c₀, c₁) = closest_pair_rec xs⟧ ⟹ c₀ ∈ set xs ∧ c₁ ∈ set xs ∧ c₀ ≠ c₁›*) case (1 xs) (*‹∀ys. length ys < length xs ⟶ 1 < length ys ⟶ distinct ys ⟶ (∀x xa xb. (x, xa, xb) = closest_pair_rec ys ⟶ xa ∈ set ys ∧ xb ∈ set ys ∧ xa ≠ xb)› ‹1 < length xs› ‹distinct xs› ‹(ys::(int × int) list, c₀::int × int, c₁::int × int) = closest_pair_rec (xs::(int × int) list)›*) let ?n = "length xs" show "?case" (*goal: ‹c₀ ∈ set xs ∧ c₁ ∈ set xs ∧ c₀ ≠ c₁›*) proof (cases "?n ≤ 3") (*goals: 1. ‹length xs ≤ 3 ⟹ c₀ ∈ set xs ∧ c₁ ∈ set xs ∧ c₀ ≠ c₁› 2. ‹¬ length xs ≤ 3 ⟹ c₀ ∈ set xs ∧ c₁ ∈ set xs ∧ c₀ ≠ c₁›*) case True (*‹length xs ≤ 3›*) hence "(c₀, c₁) = closest_pair_bf xs" using "1.prems"(3) (*‹(ys, c₀, c₁) = closest_pair_rec xs›*) closest_pair_rec.simps (*‹closest_pair_rec ?xs = (let n = length ?xs in if n ≤ 3 then (mergesort snd ?xs, closest_pair_bf ?xs) else let (xs⇩L, xs⇩R) = split_at (n div 2) ?xs; (ys⇩L, p₀⇩L, p₁⇩L) = closest_pair_rec xs⇩L; (ys⇩R, p₀⇩R, p₁⇩R) = closest_pair_rec xs⇩R; ys = Common.merge snd ys⇩L ys⇩R in (ys, combine (p₀⇩L, p₁⇩L) (p₀⇩R, p₁⇩R) (fst (hd xs⇩R)) ys))›*) by simp thus "?thesis" (*goal: ‹c₀ ∈ set xs ∧ c₁ ∈ set xs ∧ c₀ ≠ c₁›*) using "1.prems"(1,2) (*‹1 < length xs› ‹distinct (xs::(int × int) list)›*) closest_pair_bf_c0_c1 (*‹⟦1 < length ?ps; (?c₀, ?c₁) = closest_pair_bf ?ps⟧ ⟹ ?c₀ ∈ set ?ps› ‹⟦1 < length ?ps; (?c₀, ?c₁) = closest_pair_bf ?ps⟧ ⟹ ?c₁ ∈ set ?ps› ‹⟦1 < length ?ps; distinct ?ps; (?c₀, ?c₁) = closest_pair_bf ?ps⟧ ⟹ ?c₀ ≠ ?c₁›*) by simp next (*goal: ‹¬ length xs ≤ 3 ⟹ c₀ ∈ set xs ∧ c₁ ∈ set xs ∧ c₀ ≠ c₁›*) case False (*‹¬ length xs ≤ 3›*) obtain XS⇩L and XS⇩R where "XS⇩L⇩R_def": "(XS⇩L, XS⇩R) = split_at (?n div 2) xs" (*goal: ‹(⋀XS⇩L XS⇩R. (XS⇩L, XS⇩R) = split_at (length xs div 2) xs ⟹ thesis) ⟹ thesis›*) using prod.collapse (*‹(fst ?prod, snd ?prod) = ?prod›*) by blast define L where "L = fst (hd XS⇩R)" obtain YS⇩L and C₀⇩L and C₁⇩L where "YSC₀₁⇩L_def": "(YS⇩L, C₀⇩L, C₁⇩L) = closest_pair_rec XS⇩L" (*goal: ‹(⋀(YS⇩L::(int × int) list) (C₀⇩L::int × int) C₁⇩L::int × int. (YS⇩L, C₀⇩L, C₁⇩L) = closest_pair_rec (XS⇩L::(int × int) list) ⟹ thesis::bool) ⟹ thesis›*) using prod.collapse (*‹(fst ?prod, snd ?prod) = ?prod›*) by metis obtain YS⇩R and C₀⇩R and C₁⇩R where "YSC₀₁⇩R_def": "(YS⇩R, C₀⇩R, C₁⇩R) = closest_pair_rec XS⇩R" (*goal: ‹(⋀YS⇩R C₀⇩R C₁⇩R. (YS⇩R, C₀⇩R, C₁⇩R) = closest_pair_rec XS⇩R ⟹ thesis) ⟹ thesis›*) using prod.collapse (*‹(fst ?prod, snd ?prod) = ?prod›*) by metis define YS where "YS = merge (λp. snd p) YS⇩L YS⇩R" obtain C₀ and C₁ where "C₀₁_def": "(C₀, C₁) = combine (C₀⇩L, C₁⇩L) (C₀⇩R, C₁⇩R) L YS" (*goal: ‹(⋀C₀ C₁. (C₀, C₁) = combine (C₀⇩L, C₁⇩L) (C₀⇩R, C₁⇩R) L YS ⟹ thesis) ⟹ thesis›*) using prod.collapse (*‹(fst ?prod, snd ?prod) = ?prod›*) by metis note defs = "XS⇩L⇩R_def" (*‹(XS⇩L, XS⇩R) = split_at (length xs div 2) xs›*) L_def (*‹L = fst (hd XS⇩R)›*) "YSC₀₁⇩L_def" (*‹(YS⇩L, C₀⇩L, C₁⇩L) = closest_pair_rec XS⇩L›*) "YSC₀₁⇩R_def" (*‹(YS⇩R, C₀⇩R, C₁⇩R) = closest_pair_rec XS⇩R›*) YS_def (*‹(YS::(int × int) list) = Common.merge snd (YS⇩L::(int × int) list) (YS⇩R::(int × int) list)›*) "C₀₁_def" (*‹(C₀, C₁) = combine (C₀⇩L, C₁⇩L) (C₀⇩R, C₁⇩R) L YS›*) have "1 < length XS⇩L" "length XS⇩L < length xs" "distinct XS⇩L" using False (*‹¬ length xs ≤ 3›*) "1.prems"(2) (*‹distinct (xs::(int × int) list)›*) defs (*‹(XS⇩L, XS⇩R) = split_at (length xs div 2) xs› ‹L = fst (hd XS⇩R)› ‹(YS⇩L, C₀⇩L, C₁⇩L) = closest_pair_rec XS⇩L› ‹(YS⇩R::(int × int) list, C₀⇩R::int × int, C₁⇩R::int × int) = closest_pair_rec (XS⇩R::(int × int) list)› ‹YS = Common.merge snd YS⇩L YS⇩R› ‹(C₀, C₁) = combine (C₀⇩L, C₁⇩L) (C₀⇩R, C₁⇩R) L YS›*) apply - (*goals: 1. ‹⟦¬ length xs ≤ 3; distinct xs; (XS⇩L, XS⇩R) = split_at (length xs div 2) xs; L = fst (hd XS⇩R); (YS⇩L, C₀⇩L, C₁⇩L) = closest_pair_rec XS⇩L; (YS⇩R, C₀⇩R, C₁⇩R) = closest_pair_rec XS⇩R; YS = Common.merge snd YS⇩L YS⇩R; (C₀, C₁) = combine (C₀⇩L, C₁⇩L) (C₀⇩R, C₁⇩R) L YS⟧ ⟹ 1 < length XS⇩L› 2. ‹⟦¬ length xs ≤ 3; distinct xs; (XS⇩L, XS⇩R) = split_at (length xs div 2) xs; L = fst (hd XS⇩R); (YS⇩L, C₀⇩L, C₁⇩L) = closest_pair_rec XS⇩L; (YS⇩R, C₀⇩R, C₁⇩R) = closest_pair_rec XS⇩R; YS = Common.merge snd YS⇩L YS⇩R; (C₀, C₁) = combine (C₀⇩L, C₁⇩L) (C₀⇩R, C₁⇩R) L YS⟧ ⟹ length XS⇩L < length xs› 3. ‹⟦¬ length xs ≤ 3; distinct xs; (XS⇩L, XS⇩R) = split_at (length xs div 2) xs; L = fst (hd XS⇩R); (YS⇩L, C₀⇩L, C₁⇩L) = closest_pair_rec XS⇩L; (YS⇩R, C₀⇩R, C₁⇩R) = closest_pair_rec XS⇩R; YS = Common.merge snd YS⇩L YS⇩R; (C₀, C₁) = combine (C₀⇩L, C₁⇩L) (C₀⇩R, C₁⇩R) L YS⟧ ⟹ distinct XS⇩L› discuss goal 1*) apply ((auto simp: split_at_take_drop_conv (*‹split_at ?n ?xs = (take ?n ?xs, drop ?n ?xs)›*))[1]) (*discuss goal 2*) apply ((auto simp: split_at_take_drop_conv (*‹split_at (?n::nat) (?xs::?'a list) = (take ?n ?xs, drop ?n ?xs)›*))[1]) (*discuss goal 3*) apply ((auto simp: split_at_take_drop_conv (*‹split_at (?n::nat) (?xs::?'a list) = (take ?n ?xs, drop ?n ?xs)›*))[1]) (*proven 3 subgoals*) . hence "C₀⇩L ∈ set XS⇩L" "C₁⇩L ∈ set XS⇩L" and IHL1: "C₀⇩L ≠ C₁⇩L" using "1.IH" (*‹∀ys. length ys < length xs ⟶ 1 < length ys ⟶ distinct ys ⟶ (∀x xa xb. (x, xa, xb) = closest_pair_rec ys ⟶ xa ∈ set ys ∧ xb ∈ set ys ∧ xa ≠ xb)›*) defs (*‹(XS⇩L, XS⇩R) = split_at (length xs div 2) xs› ‹L = fst (hd XS⇩R)› ‹(YS⇩L, C₀⇩L, C₁⇩L) = closest_pair_rec XS⇩L› ‹(YS⇩R::(int × int) list, C₀⇩R::int × int, C₁⇩R::int × int) = closest_pair_rec (XS⇩R::(int × int) list)› ‹(YS::(int × int) list) = Common.merge snd (YS⇩L::(int × int) list) (YS⇩R::(int × int) list)› ‹(C₀::int × int, C₁::int × int) = combine (C₀⇩L::int × int, C₁⇩L::int × int) (C₀⇩R::int × int, C₁⇩R::int × int) (L::int) (YS::(int × int) list)›*) apply - (*goals: 1. ‹⟦1 < length XS⇩L; length XS⇩L < length xs; distinct XS⇩L; ∀ys. length ys < length xs ⟶ 1 < length ys ⟶ distinct ys ⟶ (∀x xa xb. (x, xa, xb) = closest_pair_rec ys ⟶ xa ∈ set ys ∧ xb ∈ set ys ∧ xa ≠ xb); (XS⇩L, XS⇩R) = split_at (length xs div 2) xs; L = fst (hd XS⇩R); (YS⇩L, C₀⇩L, C₁⇩L) = closest_pair_rec XS⇩L; (YS⇩R, C₀⇩R, C₁⇩R) = closest_pair_rec XS⇩R; YS = Common.merge snd YS⇩L YS⇩R; (C₀, C₁) = combine (C₀⇩L, C₁⇩L) (C₀⇩R, C₁⇩R) L YS⟧ ⟹ C₀⇩L ∈ set XS⇩L› 2. ‹⟦1 < length XS⇩L; length XS⇩L < length xs; distinct XS⇩L; ∀ys. length ys < length xs ⟶ 1 < length ys ⟶ distinct ys ⟶ (∀x xa xb. (x, xa, xb) = closest_pair_rec ys ⟶ xa ∈ set ys ∧ xb ∈ set ys ∧ xa ≠ xb); (XS⇩L, XS⇩R) = split_at (length xs div 2) xs; L = fst (hd XS⇩R); (YS⇩L, C₀⇩L, C₁⇩L) = closest_pair_rec XS⇩L; (YS⇩R, C₀⇩R, C₁⇩R) = closest_pair_rec XS⇩R; YS = Common.merge snd YS⇩L YS⇩R; (C₀, C₁) = combine (C₀⇩L, C₁⇩L) (C₀⇩R, C₁⇩R) L YS⟧ ⟹ C₁⇩L ∈ set XS⇩L› 3. ‹⟦1 < length XS⇩L; length XS⇩L < length xs; distinct XS⇩L; ∀ys. length ys < length xs ⟶ 1 < length ys ⟶ distinct ys ⟶ (∀x xa xb. (x, xa, xb) = closest_pair_rec ys ⟶ xa ∈ set ys ∧ xb ∈ set ys ∧ xa ≠ xb); (XS⇩L, XS⇩R) = split_at (length xs div 2) xs; L = fst (hd XS⇩R); (YS⇩L, C₀⇩L, C₁⇩L) = closest_pair_rec XS⇩L; (YS⇩R, C₀⇩R, C₁⇩R) = closest_pair_rec XS⇩R; YS = Common.merge snd YS⇩L YS⇩R; (C₀, C₁) = combine (C₀⇩L, C₁⇩L) (C₀⇩R, C₁⇩R) L YS⟧ ⟹ C₀⇩L ≠ C₁⇩L› discuss goal 1*) apply metis (*discuss goal 2*) apply metis (*discuss goal 3*) apply metis (*proven 3 subgoals*) . hence IHL2: "C₀⇩L ∈ set xs" "C₁⇩L ∈ set xs" using split_at_take_drop_conv (*‹split_at (?n::nat) (?xs::?'a::type list) = (take ?n ?xs, drop ?n ?xs)›*) in_set_takeD (*‹?x ∈ set (take ?n ?xs) ⟹ ?x ∈ set ?xs›*) fst_conv (*‹fst (?x1.0, ?x2.0) = ?x1.0›*) defs (*‹(XS⇩L, XS⇩R) = split_at (length xs div 2) xs› ‹L = fst (hd XS⇩R)› ‹(YS⇩L, C₀⇩L, C₁⇩L) = closest_pair_rec XS⇩L› ‹(YS⇩R, C₀⇩R, C₁⇩R) = closest_pair_rec XS⇩R› ‹YS = Common.merge snd YS⇩L YS⇩R› ‹(C₀::int × int, C₁::int × int) = combine (C₀⇩L::int × int, C₁⇩L::int × int) (C₀⇩R::int × int, C₁⇩R::int × int) (L::int) (YS::(int × int) list)›*) by ((metis)+) have "1 < length XS⇩R" "length XS⇩R < length xs" "distinct XS⇩R" using False (*‹¬ length xs ≤ 3›*) "1.prems"(2) (*‹distinct xs›*) defs (*‹(XS⇩L::(int × int) list, XS⇩R::(int × int) list) = split_at (length (xs::(int × int) list) div (2::nat)) xs› ‹(L::int) = fst (hd (XS⇩R::(int × int) list))› ‹(YS⇩L, C₀⇩L, C₁⇩L) = closest_pair_rec XS⇩L› ‹(YS⇩R, C₀⇩R, C₁⇩R) = closest_pair_rec XS⇩R› ‹YS = Common.merge snd YS⇩L YS⇩R› ‹(C₀::int × int, C₁::int × int) = combine (C₀⇩L::int × int, C₁⇩L::int × int) (C₀⇩R::int × int, C₁⇩R::int × int) (L::int) (YS::(int × int) list)›*) apply - (*goals: 1. ‹⟦¬ length (xs::(int × int) list) ≤ (3::nat); distinct xs; (XS⇩L::(int × int) list, XS⇩R::(int × int) list) = split_at (length xs div (2::nat)) xs; (L::int) = fst (hd XS⇩R); (YS⇩L::(int × int) list, C₀⇩L::int × int, C₁⇩L::int × int) = closest_pair_rec XS⇩L; (YS⇩R::(int × int) list, C₀⇩R::int × int, C₁⇩R::int × int) = closest_pair_rec XS⇩R; (YS::(int × int) list) = Common.merge snd YS⇩L YS⇩R; (C₀::int × int, C₁::int × int) = combine (C₀⇩L, C₁⇩L) (C₀⇩R, C₁⇩R) L YS⟧ ⟹ (1::nat) < length XS⇩R› 2. ‹⟦¬ length (xs::(int × int) list) ≤ (3::nat); distinct xs; (XS⇩L::(int × int) list, XS⇩R::(int × int) list) = split_at (length xs div (2::nat)) xs; (L::int) = fst (hd XS⇩R); (YS⇩L::(int × int) list, C₀⇩L::int × int, C₁⇩L::int × int) = closest_pair_rec XS⇩L; (YS⇩R::(int × int) list, C₀⇩R::int × int, C₁⇩R::int × int) = closest_pair_rec XS⇩R; (YS::(int × int) list) = Common.merge snd YS⇩L YS⇩R; (C₀::int × int, C₁::int × int) = combine (C₀⇩L, C₁⇩L) (C₀⇩R, C₁⇩R) L YS⟧ ⟹ length XS⇩R < length xs› 3. ‹⟦¬ length (xs::(int × int) list) ≤ (3::nat); distinct xs; (XS⇩L::(int × int) list, XS⇩R::(int × int) list) = split_at (length xs div (2::nat)) xs; (L::int) = fst (hd XS⇩R); (YS⇩L::(int × int) list, C₀⇩L::int × int, C₁⇩L::int × int) = closest_pair_rec XS⇩L; (YS⇩R::(int × int) list, C₀⇩R::int × int, C₁⇩R::int × int) = closest_pair_rec XS⇩R; (YS::(int × int) list) = Common.merge snd YS⇩L YS⇩R; (C₀::int × int, C₁::int × int) = combine (C₀⇩L, C₁⇩L) (C₀⇩R, C₁⇩R) L YS⟧ ⟹ distinct XS⇩R› discuss goal 1*) apply ((auto simp: split_at_take_drop_conv (*‹split_at ?n ?xs = (take ?n ?xs, drop ?n ?xs)›*))[1]) (*discuss goal 2*) apply ((auto simp: split_at_take_drop_conv (*‹split_at ?n ?xs = (take ?n ?xs, drop ?n ?xs)›*))[1]) (*discuss goal 3*) apply ((auto simp: split_at_take_drop_conv (*‹split_at (?n::nat) (?xs::?'a list) = (take ?n ?xs, drop ?n ?xs)›*))[1]) (*proven 3 subgoals*) . hence "C₀⇩R ∈ set XS⇩R" "C₁⇩R ∈ set XS⇩R" and IHR1: "C₀⇩R ≠ C₁⇩R" using "1.IH" (*‹∀ys. length ys < length xs ⟶ 1 < length ys ⟶ distinct ys ⟶ (∀x xa xb. (x, xa, xb) = closest_pair_rec ys ⟶ xa ∈ set ys ∧ xb ∈ set ys ∧ xa ≠ xb)›*) defs (*‹(XS⇩L, XS⇩R) = split_at (length xs div 2) xs› ‹L = fst (hd XS⇩R)› ‹(YS⇩L, C₀⇩L, C₁⇩L) = closest_pair_rec XS⇩L› ‹(YS⇩R, C₀⇩R, C₁⇩R) = closest_pair_rec XS⇩R› ‹YS = Common.merge snd YS⇩L YS⇩R› ‹(C₀, C₁) = combine (C₀⇩L, C₁⇩L) (C₀⇩R, C₁⇩R) L YS›*) apply - (*goals: 1. ‹⟦1 < length XS⇩R; length XS⇩R < length xs; distinct XS⇩R; ∀ys. length ys < length xs ⟶ 1 < length ys ⟶ distinct ys ⟶ (∀x xa xb. (x, xa, xb) = closest_pair_rec ys ⟶ xa ∈ set ys ∧ xb ∈ set ys ∧ xa ≠ xb); (XS⇩L, XS⇩R) = split_at (length xs div 2) xs; L = fst (hd XS⇩R); (YS⇩L, C₀⇩L, C₁⇩L) = closest_pair_rec XS⇩L; (YS⇩R, C₀⇩R, C₁⇩R) = closest_pair_rec XS⇩R; YS = Common.merge snd YS⇩L YS⇩R; (C₀, C₁) = combine (C₀⇩L, C₁⇩L) (C₀⇩R, C₁⇩R) L YS⟧ ⟹ C₀⇩R ∈ set XS⇩R› 2. ‹⟦1 < length XS⇩R; length XS⇩R < length xs; distinct XS⇩R; ∀ys. length ys < length xs ⟶ 1 < length ys ⟶ distinct ys ⟶ (∀x xa xb. (x, xa, xb) = closest_pair_rec ys ⟶ xa ∈ set ys ∧ xb ∈ set ys ∧ xa ≠ xb); (XS⇩L, XS⇩R) = split_at (length xs div 2) xs; L = fst (hd XS⇩R); (YS⇩L, C₀⇩L, C₁⇩L) = closest_pair_rec XS⇩L; (YS⇩R, C₀⇩R, C₁⇩R) = closest_pair_rec XS⇩R; YS = Common.merge snd YS⇩L YS⇩R; (C₀, C₁) = combine (C₀⇩L, C₁⇩L) (C₀⇩R, C₁⇩R) L YS⟧ ⟹ C₁⇩R ∈ set XS⇩R› 3. ‹⟦1 < length XS⇩R; length XS⇩R < length xs; distinct XS⇩R; ∀ys. length ys < length xs ⟶ 1 < length ys ⟶ distinct ys ⟶ (∀x xa xb. (x, xa, xb) = closest_pair_rec ys ⟶ xa ∈ set ys ∧ xb ∈ set ys ∧ xa ≠ xb); (XS⇩L, XS⇩R) = split_at (length xs div 2) xs; L = fst (hd XS⇩R); (YS⇩L, C₀⇩L, C₁⇩L) = closest_pair_rec XS⇩L; (YS⇩R, C₀⇩R, C₁⇩R) = closest_pair_rec XS⇩R; YS = Common.merge snd YS⇩L YS⇩R; (C₀, C₁) = combine (C₀⇩L, C₁⇩L) (C₀⇩R, C₁⇩R) L YS⟧ ⟹ C₀⇩R ≠ C₁⇩R› discuss goal 1*) apply metis (*discuss goal 2*) apply metis (*discuss goal 3*) apply metis (*proven 3 subgoals*) . hence IHR2: "C₀⇩R ∈ set xs" "C₁⇩R ∈ set xs" using split_at_take_drop_conv (*‹split_at (?n::nat) (?xs::?'a list) = (take ?n ?xs, drop ?n ?xs)›*) in_set_dropD (*‹?x ∈ set (drop ?n ?xs) ⟹ ?x ∈ set ?xs›*) snd_conv (*‹snd (?x1.0, ?x2.0) = ?x2.0›*) defs (*‹(XS⇩L, XS⇩R) = split_at (length xs div 2) xs› ‹L = fst (hd XS⇩R)› ‹(YS⇩L, C₀⇩L, C₁⇩L) = closest_pair_rec XS⇩L› ‹(YS⇩R, C₀⇩R, C₁⇩R) = closest_pair_rec XS⇩R› ‹YS = Common.merge snd YS⇩L YS⇩R› ‹(C₀, C₁) = combine (C₀⇩L, C₁⇩L) (C₀⇩R, C₁⇩R) L YS›*) by ((metis)+) have "*": "(YS, C₀, C₁) = closest_pair_rec xs" using False (*‹¬ length xs ≤ 3›*) closest_pair_rec_simps (*‹⟦?n = length ?xs; ¬ ?n ≤ 3⟧ ⟹ closest_pair_rec ?xs = (let (xs⇩L, xs⇩R) = split_at (?n div 2) ?xs; (ys⇩L, p₀⇩L, p₁⇩L) = closest_pair_rec xs⇩L; (ys⇩R, p₀⇩R, p₁⇩R) = closest_pair_rec xs⇩R; ys = Common.merge snd ys⇩L ys⇩R in (ys, combine (p₀⇩L, p₁⇩L) (p₀⇩R, p₁⇩R) (fst (hd xs⇩R)) ys))›*) defs (*‹(XS⇩L, XS⇩R) = split_at (length xs div 2) xs› ‹L = fst (hd XS⇩R)› ‹(YS⇩L, C₀⇩L, C₁⇩L) = closest_pair_rec XS⇩L› ‹(YS⇩R, C₀⇩R, C₁⇩R) = closest_pair_rec XS⇩R› ‹(YS::(int × int) list) = Common.merge snd (YS⇩L::(int × int) list) (YS⇩R::(int × int) list)› ‹(C₀, C₁) = combine (C₀⇩L, C₁⇩L) (C₀⇩R, C₁⇩R) L YS›*) by (auto simp: Let_def (*‹Let ?s ?f ≡ ?f ?s›*) split: prod.split (*‹?P (case ?prod of (x, xa) ⇒ ?f x xa) = (∀x1 x2. ?prod = (x1, x2) ⟶ ?P (?f x1 x2))›*)) have YS: "set xs = set YS" "distinct YS" using "1.prems"(2) (*‹distinct xs›*) closest_pair_rec_set_length_sorted_snd (*‹(?ys, ?p) = closest_pair_rec ?xs ⟹ set ?ys = set ?xs ∧ length ?ys = length ?xs ∧ sorted_snd ?ys›*) closest_pair_rec_distinct (*‹⟦distinct ?xs; (?ys, ?p) = closest_pair_rec ?xs⟧ ⟹ distinct ?ys›*) "*" (*‹(YS::(int × int) list, C₀::int × int, C₁::int × int) = closest_pair_rec (xs::(int × int) list)›*) apply - (*goals: 1. ‹⟦distinct xs; ⋀ys p xs. (ys, p) = closest_pair_rec xs ⟹ set ys = set xs ∧ length ys = length xs ∧ sorted_snd ys; ⋀xs ys p. ⟦distinct xs; (ys, p) = closest_pair_rec xs⟧ ⟹ distinct ys; (YS, C₀, C₁) = closest_pair_rec xs⟧ ⟹ set xs = set YS› 2. ‹⟦distinct xs; ⋀ys p xs. (ys, p) = closest_pair_rec xs ⟹ set ys = set xs ∧ length ys = length xs ∧ sorted_snd ys; ⋀xs ys p. ⟦distinct xs; (ys, p) = closest_pair_rec xs⟧ ⟹ distinct ys; (YS, C₀, C₁) = closest_pair_rec xs⟧ ⟹ distinct YS› discuss goal 1*) apply blast (*discuss goal 2*) apply blast (*proven 2 subgoals*) . have "C₀ ∈ set xs" "C₁ ∈ set xs" using combine_set (*‹(?c₀, ?c₁) = combine (?p₀⇩L, ?p₁⇩L) (?p₀⇩R, ?p₁⇩R) ?l ?ps ⟹ ?c₀ ∈ set ?ps ∧ ?c₁ ∈ set ?ps ∨ ?c₀ = ?p₀⇩L ∧ ?c₁ = ?p₁⇩L ∨ ?c₀ = ?p₀⇩R ∧ ?c₁ = ?p₁⇩R›*) IHL2 (*‹C₀⇩L ∈ set xs› ‹C₁⇩L ∈ set xs›*) IHR2 (*‹(C₀⇩R::int × int) ∈ set (xs::(int × int) list)› ‹C₁⇩R ∈ set xs›*) YS (*‹set xs = set YS› ‹distinct YS›*) defs (*‹(XS⇩L, XS⇩R) = split_at (length xs div 2) xs› ‹L = fst (hd XS⇩R)› ‹(YS⇩L, C₀⇩L, C₁⇩L) = closest_pair_rec XS⇩L› ‹(YS⇩R, C₀⇩R, C₁⇩R) = closest_pair_rec XS⇩R› ‹YS = Common.merge snd YS⇩L YS⇩R› ‹(C₀, C₁) = combine (C₀⇩L, C₁⇩L) (C₀⇩R, C₁⇩R) L YS›*) apply - (*goals: 1. ‹⟦⋀c₀ c₁ p₀⇩L p₁⇩L p₀⇩R p₁⇩R l ps. (c₀, c₁) = combine (p₀⇩L, p₁⇩L) (p₀⇩R, p₁⇩R) l ps ⟹ c₀ ∈ set ps ∧ c₁ ∈ set ps ∨ c₀ = p₀⇩L ∧ c₁ = p₁⇩L ∨ c₀ = p₀⇩R ∧ c₁ = p₁⇩R; C₀⇩L ∈ set xs; C₁⇩L ∈ set xs; C₀⇩R ∈ set xs; C₁⇩R ∈ set xs; set xs = set YS; distinct YS; (XS⇩L, XS⇩R) = split_at (length xs div 2) xs; L = fst (hd XS⇩R); (YS⇩L, C₀⇩L, C₁⇩L) = closest_pair_rec XS⇩L; (YS⇩R, C₀⇩R, C₁⇩R) = closest_pair_rec XS⇩R; YS = Common.merge snd YS⇩L YS⇩R; (C₀, C₁) = combine (C₀⇩L, C₁⇩L) (C₀⇩R, C₁⇩R) L YS⟧ ⟹ C₀ ∈ set xs› 2. ‹⟦⋀c₀ c₁ p₀⇩L p₁⇩L p₀⇩R p₁⇩R l ps. (c₀, c₁) = combine (p₀⇩L, p₁⇩L) (p₀⇩R, p₁⇩R) l ps ⟹ c₀ ∈ set ps ∧ c₁ ∈ set ps ∨ c₀ = p₀⇩L ∧ c₁ = p₁⇩L ∨ c₀ = p₀⇩R ∧ c₁ = p₁⇩R; C₀⇩L ∈ set xs; C₁⇩L ∈ set xs; C₀⇩R ∈ set xs; C₁⇩R ∈ set xs; set xs = set YS; distinct YS; (XS⇩L, XS⇩R) = split_at (length xs div 2) xs; L = fst (hd XS⇩R); (YS⇩L, C₀⇩L, C₁⇩L) = closest_pair_rec XS⇩L; (YS⇩R, C₀⇩R, C₁⇩R) = closest_pair_rec XS⇩R; YS = Common.merge snd YS⇩L YS⇩R; (C₀, C₁) = combine (C₀⇩L, C₁⇩L) (C₀⇩R, C₁⇩R) L YS⟧ ⟹ C₁ ∈ set xs› discuss goal 1*) apply blast (*discuss goal 2*) apply blast (*proven 2 subgoals*) . moreover have "C₀ ≠ C₁" using combine_c0_ne_c1 (*‹⟦?p₀⇩L ≠ ?p₁⇩L; ?p₀⇩R ≠ ?p₁⇩R; distinct ?ps; (?c₀, ?c₁) = combine (?p₀⇩L, ?p₁⇩L) (?p₀⇩R, ?p₁⇩R) ?l ?ps⟧ ⟹ ?c₀ ≠ ?c₁›*) IHL1(1) (*‹C₀⇩L ≠ C₁⇩L›*) IHR1(1) (*‹C₀⇩R ≠ C₁⇩R›*) YS (*‹set xs = set YS› ‹distinct (YS::(int × int) list)›*) defs (*‹(XS⇩L::(int × int) list, XS⇩R::(int × int) list) = split_at (length (xs::(int × int) list) div (2::nat)) xs› ‹L = fst (hd XS⇩R)› ‹(YS⇩L, C₀⇩L, C₁⇩L) = closest_pair_rec XS⇩L› ‹(YS⇩R, C₀⇩R, C₁⇩R) = closest_pair_rec XS⇩R› ‹YS = Common.merge snd YS⇩L YS⇩R› ‹(C₀, C₁) = combine (C₀⇩L, C₁⇩L) (C₀⇩R, C₁⇩R) L YS›*) by blast ultimately show "?thesis" (*goal: ‹c₀ ∈ set xs ∧ c₁ ∈ set xs ∧ c₀ ≠ c₁›*) using "1.prems"(3) (*‹(ys, c₀, c₁) = closest_pair_rec xs›*) "*" (*‹(YS, C₀, C₁) = closest_pair_rec xs›*) by (metis Pair_inject (*‹⟦(?a, ?b) = (?a', ?b'); ⟦?a = ?a'; ?b = ?b'⟧ ⟹ ?R⟧ ⟹ ?R›*)) qed qed lemma closest_pair_rec_dist: assumes "1 < length xs" "sorted_fst xs" "(ys, c₀, c₁) = closest_pair_rec xs" shows "sparse (dist c₀ c₁) (set xs)" using assms (*‹1 < length xs› ‹sorted_fst xs› ‹(ys, c₀, c₁) = closest_pair_rec xs›*) proof (induction xs arbitrary: ys c₀ c₁ rule: length_induct) (*goal: ‹⋀xs ys c₀ c₁. ⟦∀ys. length ys < length xs ⟶ 1 < length ys ⟶ sorted_fst ys ⟶ (∀x xa xb. (x, xa, xb) = closest_pair_rec ys ⟶ sparse (dist (case xa of (x, y) ⇒ (real_of_int x, real_of_int y)) (case xb of (x, y) ⇒ (real_of_int x, real_of_int y))) (set ys)); 1 < length xs; sorted_fst xs; (ys, c₀, c₁) = closest_pair_rec xs⟧ ⟹ sparse (dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y))) (set xs)›*) case (1 xs) (*‹∀ys::(int × int) list. length ys < length (xs::(int × int) list) ⟶ (1::nat) < length ys ⟶ sorted_fst ys ⟶ (∀(x::(int × int) list) (xa::int × int) xb::int × int. (x, xa, xb) = closest_pair_rec ys ⟶ sparse (dist (case xa of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) (case xb of (x::int, y::int) ⇒ (real_of_int x, real_of_int y))) (set ys))› ‹1 < length xs› ‹sorted_fst xs› ‹(ys, c₀, c₁) = closest_pair_rec xs›*) let ?n = "length xs" show "?case" (*goal: ‹sparse (dist (case c₀::int × int of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) (case c₁::int × int of (x::int, y::int) ⇒ (real_of_int x, real_of_int y))) (set (xs::(int × int) list))›*) proof (cases "?n ≤ 3") (*goals: 1. ‹length (xs::(int × int) list) ≤ (3::nat) ⟹ sparse (dist (case c₀::int × int of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) (case c₁::int × int of (x::int, y::int) ⇒ (real_of_int x, real_of_int y))) (set xs)› 2. ‹¬ length (xs::(int × int) list) ≤ (3::nat) ⟹ sparse (dist (case c₀::int × int of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) (case c₁::int × int of (x::int, y::int) ⇒ (real_of_int x, real_of_int y))) (set xs)›*) case True (*‹length (xs::(int × int) list) ≤ (3::nat)›*) hence "(c₀, c₁) = closest_pair_bf xs" using "1.prems"(3) (*‹(ys, c₀, c₁) = closest_pair_rec xs›*) closest_pair_rec.simps (*‹closest_pair_rec (?xs::(int × int) list) = (let n::nat = length ?xs in if n ≤ (3::nat) then (mergesort snd ?xs, closest_pair_bf ?xs) else let (xs⇩L::(int × int) list, xs⇩R::(int × int) list) = split_at (n div (2::nat)) ?xs; (ys⇩L::(int × int) list, p₀⇩L::int × int, p₁⇩L::int × int) = closest_pair_rec xs⇩L; (ys⇩R::(int × int) list, p₀⇩R::int × int, p₁⇩R::int × int) = closest_pair_rec xs⇩R; ys::(int × int) list = Common.merge snd ys⇩L ys⇩R in (ys, combine (p₀⇩L, p₁⇩L) (p₀⇩R, p₁⇩R) (fst (hd xs⇩R)) ys))›*) by simp thus "?thesis" (*goal: ‹sparse (dist (case c₀::int × int of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) (case c₁::int × int of (x::int, y::int) ⇒ (real_of_int x, real_of_int y))) (set (xs::(int × int) list))›*) using "1.prems"(1,3) (*‹1 < length xs› ‹(ys::(int × int) list, c₀::int × int, c₁::int × int) = closest_pair_rec (xs::(int × int) list)›*) closest_pair_bf_dist (*‹⟦1 < length ?ps; (?c₀, ?c₁) = closest_pair_bf ?ps⟧ ⟹ sparse (dist (case ?c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case ?c₁ of (x, y) ⇒ (real_of_int x, real_of_int y))) (set ?ps)›*) by metis next (*goal: ‹¬ length xs ≤ 3 ⟹ sparse (dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y))) (set xs)›*) case False (*‹¬ length xs ≤ 3›*) obtain XS⇩L and XS⇩R where "XS⇩L⇩R_def": "(XS⇩L, XS⇩R) = split_at (?n div 2) xs" (*goal: ‹(⋀XS⇩L XS⇩R. (XS⇩L, XS⇩R) = split_at (length xs div 2) xs ⟹ thesis) ⟹ thesis›*) using prod.collapse (*‹(fst ?prod, snd ?prod) = ?prod›*) by blast define L where "L = fst (hd XS⇩R)" obtain YS⇩L and C₀⇩L and C₁⇩L where "YSC₀₁⇩L_def": "(YS⇩L, C₀⇩L, C₁⇩L) = closest_pair_rec XS⇩L" (*goal: ‹(⋀YS⇩L C₀⇩L C₁⇩L. (YS⇩L, C₀⇩L, C₁⇩L) = closest_pair_rec XS⇩L ⟹ thesis) ⟹ thesis›*) using prod.collapse (*‹(fst ?prod, snd ?prod) = ?prod›*) by metis obtain YS⇩R and C₀⇩R and C₁⇩R where "YSC₀₁⇩R_def": "(YS⇩R, C₀⇩R, C₁⇩R) = closest_pair_rec XS⇩R" (*goal: ‹(⋀YS⇩R C₀⇩R C₁⇩R. (YS⇩R, C₀⇩R, C₁⇩R) = closest_pair_rec XS⇩R ⟹ thesis) ⟹ thesis›*) using prod.collapse (*‹(fst ?prod, snd ?prod) = ?prod›*) by metis define YS where "YS = merge (λp. snd p) YS⇩L YS⇩R" obtain C₀ and C₁ where "C₀₁_def": "(C₀, C₁) = combine (C₀⇩L, C₁⇩L) (C₀⇩R, C₁⇩R) L YS" (*goal: ‹(⋀C₀ C₁. (C₀, C₁) = combine (C₀⇩L, C₁⇩L) (C₀⇩R, C₁⇩R) L YS ⟹ thesis) ⟹ thesis›*) using prod.collapse (*‹(fst ?prod, snd ?prod) = ?prod›*) by metis note defs = "XS⇩L⇩R_def" (*‹(XS⇩L, XS⇩R) = split_at (length xs div 2) xs›*) L_def (*‹(L::int) = fst (hd (XS⇩R::(int × int) list))›*) "YSC₀₁⇩L_def" (*‹(YS⇩L, C₀⇩L, C₁⇩L) = closest_pair_rec XS⇩L›*) "YSC₀₁⇩R_def" (*‹(YS⇩R, C₀⇩R, C₁⇩R) = closest_pair_rec XS⇩R›*) YS_def (*‹(YS::(int × int) list) = Common.merge snd (YS⇩L::(int × int) list) (YS⇩R::(int × int) list)›*) "C₀₁_def" (*‹(C₀, C₁) = combine (C₀⇩L, C₁⇩L) (C₀⇩R, C₁⇩R) L YS›*) have XSLR: "XS⇩L = take (?n div 2) xs" "XS⇩R = drop (?n div 2) xs" using defs (*‹(XS⇩L, XS⇩R) = split_at (length xs div 2) xs› ‹L = fst (hd XS⇩R)› ‹(YS⇩L, C₀⇩L, C₁⇩L) = closest_pair_rec XS⇩L› ‹(YS⇩R, C₀⇩R, C₁⇩R) = closest_pair_rec XS⇩R› ‹YS = Common.merge snd YS⇩L YS⇩R› ‹(C₀, C₁) = combine (C₀⇩L, C₁⇩L) (C₀⇩R, C₁⇩R) L YS›*) apply - (*goals: 1. ‹⟦(XS⇩L, XS⇩R) = split_at (length xs div 2) xs; L = fst (hd XS⇩R); (YS⇩L, C₀⇩L, C₁⇩L) = closest_pair_rec XS⇩L; (YS⇩R, C₀⇩R, C₁⇩R) = closest_pair_rec XS⇩R; YS = Common.merge snd YS⇩L YS⇩R; (C₀, C₁) = combine (C₀⇩L, C₁⇩L) (C₀⇩R, C₁⇩R) L YS⟧ ⟹ XS⇩L = take (length xs div 2) xs› 2. ‹⟦(XS⇩L, XS⇩R) = split_at (length xs div 2) xs; L = fst (hd XS⇩R); (YS⇩L, C₀⇩L, C₁⇩L) = closest_pair_rec XS⇩L; (YS⇩R, C₀⇩R, C₁⇩R) = closest_pair_rec XS⇩R; YS = Common.merge snd YS⇩L YS⇩R; (C₀, C₁) = combine (C₀⇩L, C₁⇩L) (C₀⇩R, C₁⇩R) L YS⟧ ⟹ XS⇩R = drop (length xs div 2) xs› discuss goal 1*) apply ((auto simp: split_at_take_drop_conv (*‹split_at ?n ?xs = (take ?n ?xs, drop ?n ?xs)›*))[1]) (*discuss goal 2*) apply ((auto simp: split_at_take_drop_conv (*‹split_at ?n ?xs = (take ?n ?xs, drop ?n ?xs)›*))[1]) (*proven 2 subgoals*) . have "1 < length XS⇩L" "length XS⇩L < length xs" using False (*‹¬ length xs ≤ 3›*) XSLR (*‹XS⇩L = take (length xs div 2) xs› ‹XS⇩R = drop (length xs div 2) xs›*) apply - (*goals: 1. ‹⟦¬ length xs ≤ 3; XS⇩L = take (length xs div 2) xs; XS⇩R = drop (length xs div 2) xs⟧ ⟹ 1 < length XS⇩L› 2. ‹⟦¬ length xs ≤ 3; XS⇩L = take (length xs div 2) xs; XS⇩R = drop (length xs div 2) xs⟧ ⟹ length XS⇩L < length xs› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) . moreover have "sorted_fst XS⇩L" using "1.prems"(2) (*‹sorted_fst xs›*) XSLR (*‹XS⇩L = take (length xs div 2) xs› ‹XS⇩R = drop (length xs div 2) xs›*) by (auto simp: sorted_fst_def (*‹sorted_fst ?ps = sorted_wrt (λp₀ p₁. fst p₀ ≤ fst p₁) ?ps›*) sorted_wrt_take (*‹sorted_wrt ?f ?xs ⟹ sorted_wrt ?f (take ?n ?xs)›*)) ultimately have L: "sparse (dist C₀⇩L C₁⇩L) (set XS⇩L)" "set XS⇩L = set YS⇩L" using "1" (*‹∀ys::(int × int) list. length ys < length (xs::(int × int) list) ⟶ (1::nat) < length ys ⟶ sorted_fst ys ⟶ (∀(x::(int × int) list) (xa::int × int) xb::int × int. (x, xa, xb) = closest_pair_rec ys ⟶ sparse (dist (case xa of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) (case xb of (x::int, y::int) ⇒ (real_of_int x, real_of_int y))) (set ys))› ‹(1::nat) < length (xs::(int × int) list)› ‹sorted_fst xs› ‹(ys, c₀, c₁) = closest_pair_rec xs›*) closest_pair_rec_set_length_sorted_snd (*‹(?ys, ?p) = closest_pair_rec ?xs ⟹ set ?ys = set ?xs ∧ length ?ys = length ?xs ∧ sorted_snd ?ys›*) closest_pair_rec_c0_c1 (*‹⟦1 < length ?xs; distinct ?xs; (?ys, ?c₀, ?c₁) = closest_pair_rec ?xs⟧ ⟹ ?c₀ ∈ set ?xs ∧ ?c₁ ∈ set ?xs ∧ ?c₀ ≠ ?c₁›*) "YSC₀₁⇩L_def" (*‹(YS⇩L, C₀⇩L, C₁⇩L) = closest_pair_rec XS⇩L›*) apply - (*goals: 1. ‹⟦1 < length XS⇩L; length XS⇩L < length xs; sorted_fst XS⇩L; ∀ys. length ys < length xs ⟶ 1 < length ys ⟶ sorted_fst ys ⟶ (∀x xa xb. (x, xa, xb) = closest_pair_rec ys ⟶ sparse (dist (case xa of (x, y) ⇒ (real_of_int x, real_of_int y)) (case xb of (x, y) ⇒ (real_of_int x, real_of_int y))) (set ys)); 1 < length xs; sorted_fst xs; (ys, c₀, c₁) = closest_pair_rec xs; ⋀ys p xs. (ys, p) = closest_pair_rec xs ⟹ set ys = set xs ∧ length ys = length xs ∧ sorted_snd ys; ⋀xs ys c₀ c₁. ⟦1 < length xs; distinct xs; (ys, c₀, c₁) = closest_pair_rec xs⟧ ⟹ c₀ ∈ set xs ∧ c₁ ∈ set xs ∧ c₀ ≠ c₁; (YS⇩L, C₀⇩L, C₁⇩L) = closest_pair_rec XS⇩L⟧ ⟹ sparse (dist (case C₀⇩L of (x, y) ⇒ (real_of_int x, real_of_int y)) (case C₁⇩L of (x, y) ⇒ (real_of_int x, real_of_int y))) (set XS⇩L)› 2. ‹⟦1 < length XS⇩L; length XS⇩L < length xs; sorted_fst XS⇩L; ∀ys. length ys < length xs ⟶ 1 < length ys ⟶ sorted_fst ys ⟶ (∀x xa xb. (x, xa, xb) = closest_pair_rec ys ⟶ sparse (dist (case xa of (x, y) ⇒ (real_of_int x, real_of_int y)) (case xb of (x, y) ⇒ (real_of_int x, real_of_int y))) (set ys)); 1 < length xs; sorted_fst xs; (ys, c₀, c₁) = closest_pair_rec xs; ⋀ys p xs. (ys, p) = closest_pair_rec xs ⟹ set ys = set xs ∧ length ys = length xs ∧ sorted_snd ys; ⋀xs ys c₀ c₁. ⟦1 < length xs; distinct xs; (ys, c₀, c₁) = closest_pair_rec xs⟧ ⟹ c₀ ∈ set xs ∧ c₁ ∈ set xs ∧ c₀ ≠ c₁; (YS⇩L, C₀⇩L, C₁⇩L) = closest_pair_rec XS⇩L⟧ ⟹ set XS⇩L = set YS⇩L› discuss goal 1*) apply blast (*discuss goal 2*) apply blast (*proven 2 subgoals*) . hence IHL: "sparse (dist C₀⇩L C₁⇩L) (set YS⇩L)" by argo have "1 < length XS⇩R" "length XS⇩R < length xs" using False (*‹¬ length xs ≤ 3›*) XSLR (*‹(XS⇩L::(int × int) list) = take (length (xs::(int × int) list) div (2::nat)) xs› ‹XS⇩R = drop (length xs div 2) xs›*) apply - (*goals: 1. ‹⟦¬ length xs ≤ 3; XS⇩L = take (length xs div 2) xs; XS⇩R = drop (length xs div 2) xs⟧ ⟹ 1 < length XS⇩R› 2. ‹⟦¬ length xs ≤ 3; XS⇩L = take (length xs div 2) xs; XS⇩R = drop (length xs div 2) xs⟧ ⟹ length XS⇩R < length xs› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) . moreover have "sorted_fst XS⇩R" using "1.prems"(2) (*‹sorted_fst (xs::(int × int) list)›*) XSLR (*‹(XS⇩L::(int × int) list) = take (length (xs::(int × int) list) div (2::nat)) xs› ‹XS⇩R = drop (length xs div 2) xs›*) by (auto simp: sorted_fst_def (*‹sorted_fst ?ps = sorted_wrt (λp₀ p₁. fst p₀ ≤ fst p₁) ?ps›*) sorted_wrt_drop (*‹sorted_wrt ?f ?xs ⟹ sorted_wrt ?f (drop ?n ?xs)›*)) ultimately have R: "sparse (dist C₀⇩R C₁⇩R) (set XS⇩R)" "set XS⇩R = set YS⇩R" using "1" (*‹∀ys. length ys < length xs ⟶ 1 < length ys ⟶ sorted_fst ys ⟶ (∀x xa xb. (x, xa, xb) = closest_pair_rec ys ⟶ sparse (dist (case xa of (x, y) ⇒ (real_of_int x, real_of_int y)) (case xb of (x, y) ⇒ (real_of_int x, real_of_int y))) (set ys))› ‹1 < length xs› ‹sorted_fst xs› ‹(ys::(int × int) list, c₀::int × int, c₁::int × int) = closest_pair_rec (xs::(int × int) list)›*) closest_pair_rec_set_length_sorted_snd (*‹(?ys, ?p) = closest_pair_rec ?xs ⟹ set ?ys = set ?xs ∧ length ?ys = length ?xs ∧ sorted_snd ?ys›*) closest_pair_rec_c0_c1 (*‹⟦(1::nat) < length (?xs::(int × int) list); distinct ?xs; (?ys::(int × int) list, ?c₀::int × int, ?c₁::int × int) = closest_pair_rec ?xs⟧ ⟹ ?c₀ ∈ set ?xs ∧ ?c₁ ∈ set ?xs ∧ ?c₀ ≠ ?c₁›*) "YSC₀₁⇩R_def" (*‹(YS⇩R, C₀⇩R, C₁⇩R) = closest_pair_rec XS⇩R›*) apply - (*goals: 1. ‹⟦1 < length XS⇩R; length XS⇩R < length xs; sorted_fst XS⇩R; ∀ys. length ys < length xs ⟶ 1 < length ys ⟶ sorted_fst ys ⟶ (∀x xa xb. (x, xa, xb) = closest_pair_rec ys ⟶ sparse (dist (case xa of (x, y) ⇒ (real_of_int x, real_of_int y)) (case xb of (x, y) ⇒ (real_of_int x, real_of_int y))) (set ys)); 1 < length xs; sorted_fst xs; (ys, c₀, c₁) = closest_pair_rec xs; ⋀ys p xs. (ys, p) = closest_pair_rec xs ⟹ set ys = set xs ∧ length ys = length xs ∧ sorted_snd ys; ⋀xs ys c₀ c₁. ⟦1 < length xs; distinct xs; (ys, c₀, c₁) = closest_pair_rec xs⟧ ⟹ c₀ ∈ set xs ∧ c₁ ∈ set xs ∧ c₀ ≠ c₁; (YS⇩R, C₀⇩R, C₁⇩R) = closest_pair_rec XS⇩R⟧ ⟹ sparse (dist (case C₀⇩R of (x, y) ⇒ (real_of_int x, real_of_int y)) (case C₁⇩R of (x, y) ⇒ (real_of_int x, real_of_int y))) (set XS⇩R)› 2. ‹⟦1 < length XS⇩R; length XS⇩R < length xs; sorted_fst XS⇩R; ∀ys. length ys < length xs ⟶ 1 < length ys ⟶ sorted_fst ys ⟶ (∀x xa xb. (x, xa, xb) = closest_pair_rec ys ⟶ sparse (dist (case xa of (x, y) ⇒ (real_of_int x, real_of_int y)) (case xb of (x, y) ⇒ (real_of_int x, real_of_int y))) (set ys)); 1 < length xs; sorted_fst xs; (ys, c₀, c₁) = closest_pair_rec xs; ⋀ys p xs. (ys, p) = closest_pair_rec xs ⟹ set ys = set xs ∧ length ys = length xs ∧ sorted_snd ys; ⋀xs ys c₀ c₁. ⟦1 < length xs; distinct xs; (ys, c₀, c₁) = closest_pair_rec xs⟧ ⟹ c₀ ∈ set xs ∧ c₁ ∈ set xs ∧ c₀ ≠ c₁; (YS⇩R, C₀⇩R, C₁⇩R) = closest_pair_rec XS⇩R⟧ ⟹ set XS⇩R = set YS⇩R› discuss goal 1*) apply blast (*discuss goal 2*) apply blast (*proven 2 subgoals*) . hence IHR: "sparse (dist C₀⇩R C₁⇩R) (set YS⇩R)" by argo have "*": "(YS, C₀, C₁) = closest_pair_rec xs" using False (*‹¬ length (xs::(int × int) list) ≤ (3::nat)›*) closest_pair_rec_simps (*‹⟦(?n::nat) = length (?xs::(int × int) list); ¬ ?n ≤ (3::nat)⟧ ⟹ closest_pair_rec ?xs = (let (xs⇩L::(int × int) list, xs⇩R::(int × int) list) = split_at (?n div (2::nat)) ?xs; (ys⇩L::(int × int) list, p₀⇩L::int × int, p₁⇩L::int × int) = closest_pair_rec xs⇩L; (ys⇩R::(int × int) list, p₀⇩R::int × int, p₁⇩R::int × int) = closest_pair_rec xs⇩R; ys::(int × int) list = Common.merge snd ys⇩L ys⇩R in (ys, combine (p₀⇩L, p₁⇩L) (p₀⇩R, p₁⇩R) (fst (hd xs⇩R)) ys))›*) defs (*‹(XS⇩L, XS⇩R) = split_at (length xs div 2) xs› ‹L = fst (hd XS⇩R)› ‹(YS⇩L, C₀⇩L, C₁⇩L) = closest_pair_rec XS⇩L› ‹(YS⇩R, C₀⇩R, C₁⇩R) = closest_pair_rec XS⇩R› ‹YS = Common.merge snd YS⇩L YS⇩R› ‹(C₀::int × int, C₁::int × int) = combine (C₀⇩L::int × int, C₁⇩L::int × int) (C₀⇩R::int × int, C₁⇩R::int × int) (L::int) (YS::(int × int) list)›*) by (auto simp: Let_def (*‹Let (?s::?'a::type) (?f::?'a::type ⇒ ?'b::type) ≡ ?f ?s›*) split: prod.split (*‹(?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))›*)) have "set xs = set YS" "sorted_snd YS" using "1.prems"(2) (*‹sorted_fst (xs::(int × int) list)›*) closest_pair_rec_set_length_sorted_snd (*‹(?ys, ?p) = closest_pair_rec ?xs ⟹ set ?ys = set ?xs ∧ length ?ys = length ?xs ∧ sorted_snd ?ys›*) closest_pair_rec_distinct (*‹⟦distinct ?xs; (?ys, ?p) = closest_pair_rec ?xs⟧ ⟹ distinct ?ys›*) "*" (*‹(YS, C₀, C₁) = closest_pair_rec xs›*) apply - (*goals: 1. ‹⟦sorted_fst xs; ⋀ys p xs. (ys, p) = closest_pair_rec xs ⟹ set ys = set xs ∧ length ys = length xs ∧ sorted_snd ys; ⋀xs ys p. ⟦distinct xs; (ys, p) = closest_pair_rec xs⟧ ⟹ distinct ys; (YS, C₀, C₁) = closest_pair_rec xs⟧ ⟹ set xs = set YS› 2. ‹⟦sorted_fst xs; ⋀ys p xs. (ys, p) = closest_pair_rec xs ⟹ set ys = set xs ∧ length ys = length xs ∧ sorted_snd ys; ⋀xs ys p. ⟦distinct xs; (ys, p) = closest_pair_rec xs⟧ ⟹ distinct ys; (YS, C₀, C₁) = closest_pair_rec xs⟧ ⟹ sorted_snd YS› discuss goal 1*) apply blast (*discuss goal 2*) apply blast (*proven 2 subgoals*) . moreover have "∀p ∈ set YS⇩L. fst p ≤ L" using False (*‹¬ length xs ≤ 3›*) "1.prems"(2) (*‹sorted_fst xs›*) XSLR (*‹XS⇩L = take (length xs div 2) xs› ‹XS⇩R = drop (length xs div 2) xs›*) L_def (*‹L = fst (hd XS⇩R)›*) L(2) (*‹set XS⇩L = set YS⇩L›*) sorted_fst_take_less_hd_drop (*‹⟦sorted_fst ?ps; ?n < length ?ps⟧ ⟹ ∀p∈set (take ?n ?ps). fst p ≤ fst (hd (drop ?n ?ps))›*) by simp moreover have "∀p ∈ set YS⇩R. L ≤ fst p" using False (*‹¬ length xs ≤ 3›*) "1.prems"(2) (*‹sorted_fst xs›*) XSLR (*‹XS⇩L = take (length xs div 2) xs› ‹XS⇩R = drop (length xs div 2) xs›*) L_def (*‹L = fst (hd XS⇩R)›*) R(2) (*‹set (XS⇩R::(int × int) list) = set (YS⇩R::(int × int) list)›*) sorted_fst_hd_drop_less_drop (*‹sorted_fst ?ps ⟹ ∀p∈set (drop ?n ?ps). fst (hd (drop ?n ?ps)) ≤ fst p›*) by simp moreover have "set YS = set YS⇩L ∪ set YS⇩R" using set_merge (*‹set (Common.merge ?f ?xs ?ys) = set ?xs ∪ set ?ys›*) defs (*‹(XS⇩L::(int × int) list, XS⇩R::(int × int) list) = split_at (length (xs::(int × int) list) div (2::nat)) xs› ‹(L::int) = fst (hd (XS⇩R::(int × int) list))› ‹(YS⇩L, C₀⇩L, C₁⇩L) = closest_pair_rec XS⇩L› ‹(YS⇩R, C₀⇩R, C₁⇩R) = closest_pair_rec XS⇩R› ‹(YS::(int × int) list) = Common.merge snd (YS⇩L::(int × int) list) (YS⇩R::(int × int) list)› ‹(C₀, C₁) = combine (C₀⇩L, C₁⇩L) (C₀⇩R, C₁⇩R) L YS›*) by fast moreover have "(C₀, C₁) = combine (C₀⇩L, C₁⇩L) (C₀⇩R, C₁⇩R) L YS" by (auto simp add: defs (*‹(XS⇩L, XS⇩R) = split_at (length xs div 2) xs› ‹L = fst (hd XS⇩R)› ‹(YS⇩L, C₀⇩L, C₁⇩L) = closest_pair_rec XS⇩L› ‹(YS⇩R, C₀⇩R, C₁⇩R) = closest_pair_rec XS⇩R› ‹YS = Common.merge snd YS⇩L YS⇩R› ‹(C₀, C₁) = combine (C₀⇩L, C₁⇩L) (C₀⇩R, C₁⇩R) L YS›*)) ultimately have "sparse (dist C₀ C₁) (set xs)" using combine_dist (*‹⟦sorted_snd ?ps; set ?ps = ?ps⇩L ∪ ?ps⇩R; ∀p∈?ps⇩L. fst p ≤ ?l; ∀p∈?ps⇩R. ?l ≤ fst p; sparse (dist (case ?p₀⇩L of (x, y) ⇒ (real_of_int x, real_of_int y)) (case ?p₁⇩L of (x, y) ⇒ (real_of_int x, real_of_int y))) ?ps⇩L; sparse (dist (case ?p₀⇩R of (x, y) ⇒ (real_of_int x, real_of_int y)) (case ?p₁⇩R of (x, y) ⇒ (real_of_int x, real_of_int y))) ?ps⇩R; (?c₀, ?c₁) = combine (?p₀⇩L, ?p₁⇩L) (?p₀⇩R, ?p₁⇩R) ?l ?ps⟧ ⟹ sparse (dist (case ?c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case ?c₁ of (x, y) ⇒ (real_of_int x, real_of_int y))) (set ?ps)›*) IHL (*‹sparse (dist (case C₀⇩L of (x, y) ⇒ (real_of_int x, real_of_int y)) (case C₁⇩L of (x, y) ⇒ (real_of_int x, real_of_int y))) (set YS⇩L)›*) IHR (*‹sparse (dist (case C₀⇩R::int × int of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) (case C₁⇩R::int × int of (x::int, y::int) ⇒ (real_of_int x, real_of_int y))) (set (YS⇩R::(int × int) list))›*) by auto moreover have "(YS, C₀, C₁) = (ys, c₀, c₁)" using "1.prems"(3) (*‹(ys::(int × int) list, c₀::int × int, c₁::int × int) = closest_pair_rec (xs::(int × int) list)›*) "*" (*‹(YS::(int × int) list, C₀::int × int, C₁::int × int) = closest_pair_rec (xs::(int × int) list)›*) by simp ultimately show "?thesis" (*goal: ‹sparse (dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y))) (set xs)›*) by blast qed qed fun closest_pair_tm :: "point list ⇒ (point * point) tm" where "closest_pair_tm [] =1 return undefined" | "closest_pair_tm [_] =1 return undefined" | "closest_pair_tm ps =1 ( do { xs <- mergesort_tm fst ps; (_, p) <- closest_pair_rec_tm xs; return p } )" fun closest_pair :: "point list ⇒ (point * point)" where "closest_pair [] = undefined" | "closest_pair [_] = undefined" | "closest_pair ps = (let (_, p) = closest_pair_rec (mergesort fst ps) in p)" lemma closest_pair_eq_val_closest_pair_tm: "val (closest_pair_tm ps) = closest_pair ps" apply (induction ps rule: induct_list012 (*‹⟦?P []; ⋀x. ?P [x]; ⋀x y zs. ⟦?P zs; ?P (y # zs)⟧ ⟹ ?P (x # y # zs)⟧ ⟹ ?P ?xs›*)) (*goals: 1. ‹Time_Monad.val (closest_pair_tm []) = closest_pair []› 2. ‹⋀x. Time_Monad.val (closest_pair_tm [x]) = closest_pair [x]› 3. ‹⋀x y zs. ⟦Time_Monad.val (closest_pair_tm zs) = closest_pair zs; Time_Monad.val (closest_pair_tm (y # zs)) = closest_pair (y # zs)⟧ ⟹ Time_Monad.val (closest_pair_tm (x # y # zs)) = closest_pair (x # y # zs)› discuss goal 1*) apply ((auto simp del: closest_pair_rec_tm.simps (*‹closest_pair_rec_tm (?xs::(int × int) list) =1 length_tm ?xs ⤜ (λn::nat. if n ≤ (3::nat) then mergesort_tm snd ?xs ⤜ (λys::(int × int) list. closest_pair_bf_tm ?xs ⤜ (λp::(int × int) × int × int. return (ys, p))) else split_at_tm (n div (2::nat)) ?xs ⤜ (λ(xs⇩L::(int × int) list, xs⇩R::(int × int) list). closest_pair_rec_tm xs⇩L ⤜ (λ(ys⇩L::(int × int) list, p₀⇩L::int × int, p₁⇩L::int × int). closest_pair_rec_tm xs⇩R ⤜ (λ(ys⇩R::(int × int) list, p₀⇩R::int × int, p₁⇩R::int × int). merge_tm snd ys⇩L ys⇩R ⤜ (λys::(int × int) list. combine_tm (p₀⇩L, p₁⇩L) (p₀⇩R, p₁⇩R) (fst (hd xs⇩R)) ys ⤜ (λ(p₀::int × int, p₁::int × int). return (ys, p₀, p₁)))))))›*) mergesort_tm.simps (*‹mergesort_tm (?f::?'a::type ⇒ ?'b::linorder) [] =1 return []› ‹mergesort_tm (?f::?'a::type ⇒ ?'b::linorder) [?x::?'a::type] =1 return [?x]› ‹mergesort_tm (?f::?'a::type ⇒ ?'b::linorder) ((?v::?'a::type) # (?vb::?'a::type) # (?vc::?'a::type list)) =1 length_tm (?v # ?vb # ?vc) ⤜ (λn::nat. split_at_tm (n div (2::nat)) (?v # ?vb # ?vc) ⤜ (λ(xs⇩l::?'a::type list, xs⇩r::?'a::type list). mergesort_tm ?f xs⇩l ⤜ (λl::?'a::type list. mergesort_tm ?f xs⇩r ⤜ merge_tm ?f l)))›*) simp add: closest_pair_rec_eq_val_closest_pair_rec_tm (*‹Time_Monad.val (closest_pair_rec_tm (?xs::(int × int) list)) = closest_pair_rec ?xs›*) mergesort_eq_val_mergesort_tm (*‹Time_Monad.val (mergesort_tm (?f::?'a::type ⇒ ?'b::linorder) (?xs::?'a::type list)) = mergesort ?f ?xs›*) split: prod.split (*‹(?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]) (*discuss goal 2*) apply ((auto simp del: closest_pair_rec_tm.simps (*‹closest_pair_rec_tm ?xs =1 length_tm ?xs ⤜ (λn. if n ≤ 3 then mergesort_tm snd ?xs ⤜ (λys. closest_pair_bf_tm ?xs ⤜ (λp. return (ys, p))) else split_at_tm (n div 2) ?xs ⤜ (λ(xs⇩L, xs⇩R). closest_pair_rec_tm xs⇩L ⤜ (λ(ys⇩L, p₀⇩L, p₁⇩L). closest_pair_rec_tm xs⇩R ⤜ (λ(ys⇩R, p₀⇩R, p₁⇩R). merge_tm snd ys⇩L ys⇩R ⤜ (λys. combine_tm (p₀⇩L, p₁⇩L) (p₀⇩R, p₁⇩R) (fst (hd xs⇩R)) ys ⤜ (λ(p₀, p₁). return (ys, p₀, p₁)))))))›*) mergesort_tm.simps (*‹mergesort_tm ?f [] =1 return []› ‹mergesort_tm ?f [?x] =1 return [?x]› ‹mergesort_tm ?f (?v # ?vb # ?vc) =1 length_tm (?v # ?vb # ?vc) ⤜ (λn. split_at_tm (n div 2) (?v # ?vb # ?vc) ⤜ (λ(xs⇩l, xs⇩r). mergesort_tm ?f xs⇩l ⤜ (λl. mergesort_tm ?f xs⇩r ⤜ merge_tm ?f l)))›*) simp add: closest_pair_rec_eq_val_closest_pair_rec_tm (*‹Time_Monad.val (closest_pair_rec_tm ?xs) = closest_pair_rec ?xs›*) mergesort_eq_val_mergesort_tm (*‹Time_Monad.val (mergesort_tm ?f ?xs) = mergesort ?f ?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 3*) apply ((auto simp del: closest_pair_rec_tm.simps (*‹closest_pair_rec_tm ?xs =1 length_tm ?xs ⤜ (λn. if n ≤ 3 then mergesort_tm snd ?xs ⤜ (λys. closest_pair_bf_tm ?xs ⤜ (λp. return (ys, p))) else split_at_tm (n div 2) ?xs ⤜ (λ(xs⇩L, xs⇩R). closest_pair_rec_tm xs⇩L ⤜ (λ(ys⇩L, p₀⇩L, p₁⇩L). closest_pair_rec_tm xs⇩R ⤜ (λ(ys⇩R, p₀⇩R, p₁⇩R). merge_tm snd ys⇩L ys⇩R ⤜ (λys. combine_tm (p₀⇩L, p₁⇩L) (p₀⇩R, p₁⇩R) (fst (hd xs⇩R)) ys ⤜ (λ(p₀, p₁). return (ys, p₀, p₁)))))))›*) mergesort_tm.simps (*‹mergesort_tm ?f [] =1 return []› ‹mergesort_tm ?f [?x] =1 return [?x]› ‹mergesort_tm ?f (?v # ?vb # ?vc) =1 length_tm (?v # ?vb # ?vc) ⤜ (λn. split_at_tm (n div 2) (?v # ?vb # ?vc) ⤜ (λ(xs⇩l, xs⇩r). mergesort_tm ?f xs⇩l ⤜ (λl. mergesort_tm ?f xs⇩r ⤜ merge_tm ?f l)))›*) simp add: closest_pair_rec_eq_val_closest_pair_rec_tm (*‹Time_Monad.val (closest_pair_rec_tm ?xs) = closest_pair_rec ?xs›*) mergesort_eq_val_mergesort_tm (*‹Time_Monad.val (mergesort_tm ?f ?xs) = mergesort ?f ?xs›*) 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*) . lemma closest_pair_simps: "1 < length ps ⟹ closest_pair ps = (let (_, p) = closest_pair_rec (mergesort fst ps) in p)" apply (induction ps rule: induct_list012 (*‹⟦(?P::?'a list ⇒ bool) []; ⋀x::?'a. ?P [x]; ⋀(x::?'a) (y::?'a) zs::?'a list. ⟦?P zs; ?P (y # zs)⟧ ⟹ ?P (x # y # zs)⟧ ⟹ ?P (?xs::?'a list)›*)) (*goals: 1. ‹1 < length [] ⟹ closest_pair [] = (let (uu_, p) = closest_pair_rec (mergesort fst []) in p)› 2. ‹⋀x. 1 < length [x] ⟹ closest_pair [x] = (let (uu_, p) = closest_pair_rec (mergesort fst [x]) in p)› 3. ‹⋀x y zs. ⟦1 < length zs ⟹ closest_pair zs = (let (uu_, p) = closest_pair_rec (mergesort fst zs) in p); 1 < length (y # zs) ⟹ closest_pair (y # zs) = (let (uu_, p) = closest_pair_rec (mergesort fst (y # zs)) in p); 1 < length (x # y # zs)⟧ ⟹ closest_pair (x # y # zs) = (let (uu_, p) = closest_pair_rec (mergesort fst (x # y # zs)) in p)› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*proven 3 subgoals*) . declare closest_pair.simps [simp del] theorem closest_pair_c0_c1: assumes "1 < length ps" "distinct ps" "(c₀, c₁) = closest_pair ps" shows "c₀ ∈ set ps" "c₁ ∈ set ps" "c₀ ≠ c₁" using assms (*‹1 < length ps› ‹distinct (ps::(int × int) list)› ‹(c₀, c₁) = closest_pair ps›*) closest_pair_rec_c0_c1[of "mergesort fst ps"] (*‹⟦1 < length (mergesort fst ps); distinct (mergesort fst ps); (?ys, ?c₀, ?c₁) = closest_pair_rec (mergesort fst ps)⟧ ⟹ ?c₀ ∈ set (mergesort fst ps) ∧ ?c₁ ∈ set (mergesort fst ps) ∧ ?c₀ ≠ ?c₁›*) apply - (*goals: 1. ‹⟦1 < length ps; distinct ps; (c₀, c₁) = closest_pair ps; ⋀ys c₀ c₁. ⟦1 < length (mergesort fst ps); distinct (mergesort fst ps); (ys, c₀, c₁) = closest_pair_rec (mergesort fst ps)⟧ ⟹ c₀ ∈ set (mergesort fst ps) ∧ c₁ ∈ set (mergesort fst ps) ∧ c₀ ≠ c₁⟧ ⟹ c₀ ∈ set ps› 2. ‹⟦1 < length ps; distinct ps; (c₀, c₁) = closest_pair ps; ⋀ys c₀ c₁. ⟦1 < length (mergesort fst ps); distinct (mergesort fst ps); (ys, c₀, c₁) = closest_pair_rec (mergesort fst ps)⟧ ⟹ c₀ ∈ set (mergesort fst ps) ∧ c₁ ∈ set (mergesort fst ps) ∧ c₀ ≠ c₁⟧ ⟹ c₁ ∈ set ps› 3. ‹⟦1 < length ps; distinct ps; (c₀, c₁) = closest_pair ps; ⋀ys c₀ c₁. ⟦1 < length (mergesort fst ps); distinct (mergesort fst ps); (ys, c₀, c₁) = closest_pair_rec (mergesort fst ps)⟧ ⟹ c₀ ∈ set (mergesort fst ps) ∧ c₁ ∈ set (mergesort fst ps) ∧ c₀ ≠ c₁⟧ ⟹ c₀ ≠ c₁› discuss goal 1*) apply ((auto simp: closest_pair_simps (*‹1 < length ?ps ⟹ closest_pair ?ps = (let (uu_, p) = closest_pair_rec (mergesort fst ?ps) in p)›*) mergesort (*‹sorted_wrt (λx y. ?f x ≤ ?f y) (mergesort ?f ?xs)› ‹set (mergesort ?f ?xs) = set ?xs› ‹length (mergesort ?f ?xs) = length ?xs› ‹distinct ?xs ⟹ distinct (mergesort ?f ?xs)›*) 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: closest_pair_simps (*‹1 < length ?ps ⟹ closest_pair ?ps = (let (uu_, p) = closest_pair_rec (mergesort fst ?ps) in p)›*) mergesort (*‹sorted_wrt (λx y. ?f x ≤ ?f y) (mergesort ?f ?xs)› ‹set (mergesort ?f ?xs) = set ?xs› ‹length (mergesort ?f ?xs) = length ?xs› ‹distinct ?xs ⟹ distinct (mergesort ?f ?xs)›*) 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: closest_pair_simps (*‹1 < length ?ps ⟹ closest_pair ?ps = (let (uu_, p) = closest_pair_rec (mergesort fst ?ps) in p)›*) mergesort (*‹sorted_wrt (λx y. ?f x ≤ ?f y) (mergesort ?f ?xs)› ‹set (mergesort ?f ?xs) = set ?xs› ‹length (mergesort ?f ?xs) = length ?xs› ‹distinct ?xs ⟹ distinct (mergesort ?f ?xs)›*) 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*) . theorem closest_pair_dist: assumes "1 < length ps" "(c₀, c₁) = closest_pair ps" shows "sparse (dist c₀ c₁) (set ps)" using assms (*‹(1::nat) < length (ps::(int × int) list)› ‹(c₀, c₁) = closest_pair ps›*) sorted_fst_def (*‹sorted_fst ?ps = sorted_wrt (λp₀ p₁. fst p₀ ≤ fst p₁) ?ps›*) closest_pair_rec_dist[of "mergesort fst ps"] (*‹⟦1 < length (mergesort fst ps); sorted_fst (mergesort fst ps); (?ys, ?c₀, ?c₁) = closest_pair_rec (mergesort fst ps)⟧ ⟹ sparse (dist (case ?c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case ?c₁ of (x, y) ⇒ (real_of_int x, real_of_int y))) (set (mergesort fst ps))›*) closest_pair_rec_c0_c1[of "mergesort fst ps"] (*‹⟦1 < length (mergesort fst ps); distinct (mergesort fst ps); (?ys, ?c₀, ?c₁) = closest_pair_rec (mergesort fst ps)⟧ ⟹ ?c₀ ∈ set (mergesort fst ps) ∧ ?c₁ ∈ set (mergesort fst ps) ∧ ?c₀ ≠ ?c₁›*) by (auto simp: closest_pair_simps (*‹1 < length ?ps ⟹ closest_pair ?ps = (let (uu_, p) = closest_pair_rec (mergesort fst ?ps) in p)›*) mergesort (*‹sorted_wrt (λx y. ?f x ≤ ?f y) (mergesort ?f ?xs)› ‹set (mergesort ?f ?xs) = set ?xs› ‹length (mergesort ?f ?xs) = length ?xs› ‹distinct ?xs ⟹ distinct (mergesort ?f ?xs)›*) 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))›*)) subsection "Time Complexity Proof" subsubsection "Core Argument" lemma core_argument: fixes δ :: real and p :: point and ps :: "point list" assumes "distinct (p # ps)" "sorted_snd (p # ps)" "0 ≤ δ" "set (p # ps) = ps⇩L ∪ ps⇩R" assumes "∀q ∈ set (p # ps). l - δ < fst q ∧ fst q < l + δ" assumes "∀q ∈ ps⇩L. fst q ≤ l" "∀q ∈ ps⇩R. l ≤ fst q" assumes "sparse δ ps⇩L" "sparse δ ps⇩R" shows "length (filter (λq. snd q - snd p ≤ δ) ps) ≤ 7" proof (-) (*goal: ‹length (filter (λq. real_of_int (snd q - snd p) ≤ δ) ps) ≤ 7›*) define PS where "PS = p # ps" define R where "R = cbox (l - δ, snd p) (l + δ, snd p + δ)" define RPS where "RPS = { p ∈ set PS. p ∈ R }" define LSQ where "LSQ = cbox (l - δ, snd p) (l, snd p + δ)" define LSQPS where "LSQPS = { p ∈ ps⇩L. p ∈ LSQ }" define RSQ where "RSQ = cbox (l, snd p) (l + δ, snd p + δ)" define RSQPS where "RSQPS = { p ∈ ps⇩R. p ∈ RSQ }" note defs = PS_def (*‹(PS::(int × int) list) = (p::int × int) # (ps::(int × int) list)›*) R_def (*‹R = cbox (case (real_of_int l - δ, snd p) of (x, y) ⇒ (x, real_of_int y)) (real_of_int l + δ, real_of_int (snd p) + δ)›*) RPS_def (*‹RPS = {p ∈ set PS. (case p of (x, y) ⇒ (real_of_int x, real_of_int y)) ∈ R}›*) LSQ_def (*‹(LSQ::(real × real) set) = cbox (case (real_of_int (l::int) - (δ::real), snd (p::int × int)) of (x::real, y::int) ⇒ (x, real_of_int y)) (case (l, real_of_int (snd p) + δ) of (x::int, y::real) ⇒ (real_of_int x, y))›*) LSQPS_def (*‹LSQPS = {p ∈ ps⇩L. (case p of (x, y) ⇒ (real_of_int x, real_of_int y)) ∈ LSQ}›*) RSQ_def (*‹(RSQ::(real × real) set) = cbox (case (l::int, snd (p::int × int)) of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) (real_of_int l + (δ::real), real_of_int (snd p) + δ)›*) RSQPS_def (*‹RSQPS = {p ∈ ps⇩R. (case p of (x, y) ⇒ (real_of_int x, real_of_int y)) ∈ RSQ}›*) have "R = LSQ ∪ RSQ" using defs (*‹PS = p # ps› ‹R = cbox (case (real_of_int l - δ, snd p) of (x, y) ⇒ (x, real_of_int y)) (real_of_int l + δ, real_of_int (snd p) + δ)› ‹RPS = {p ∈ set PS. (case p of (x, y) ⇒ (real_of_int x, real_of_int y)) ∈ R}› ‹LSQ = cbox (case (real_of_int l - δ, snd p) of (x, y) ⇒ (x, real_of_int y)) (case (l, real_of_int (snd p) + δ) of (x, y) ⇒ (real_of_int x, y))› ‹LSQPS = {p ∈ ps⇩L. (case p of (x, y) ⇒ (real_of_int x, real_of_int y)) ∈ LSQ}› ‹(RSQ::(real × real) set) = cbox (case (l::int, snd (p::int × int)) of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) (real_of_int l + (δ::real), real_of_int (snd p) + δ)› ‹RSQPS = {p ∈ ps⇩R. (case p of (x, y) ⇒ (real_of_int x, real_of_int y)) ∈ RSQ}›*) cbox_right_un (*‹⟦?x₀ ≤ ?x₁; ?x₁ ≤ ?x₂⟧ ⟹ cbox (?x₀, ?y₀) (?x₁, ?y₁) ∪ cbox (?x₁, ?y₀) (?x₂, ?y₁) = cbox (?x₀, ?y₀) (?x₂, ?y₁)›*) by auto moreover have "∀p ∈ ps⇩L. p ∈ RSQ ⟶ p ∈ LSQ" using RSQ_def (*‹(RSQ::(real × real) set) = cbox (case (l::int, snd (p::int × int)) of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) (real_of_int l + (δ::real), real_of_int (snd p) + δ)›*) LSQ_def (*‹LSQ = cbox (case (real_of_int l - δ, snd p) of (x, y) ⇒ (x, real_of_int y)) (case (l, real_of_int (snd p) + δ) of (x, y) ⇒ (real_of_int x, y))›*) assms(6) (*‹∀q∈ps⇩L. fst q ≤ l›*) by auto moreover have "∀p ∈ ps⇩R. p ∈ LSQ ⟶ p ∈ RSQ" using RSQ_def (*‹RSQ = cbox (case (l, snd p) of (x, y) ⇒ (real_of_int x, real_of_int y)) (real_of_int l + δ, real_of_int (snd p) + δ)›*) LSQ_def (*‹(LSQ::(real × real) set) = cbox (case (real_of_int (l::int) - (δ::real), snd (p::int × int)) of (x::real, y::int) ⇒ (x, real_of_int y)) (case (l, real_of_int (snd p) + δ) of (x::int, y::real) ⇒ (real_of_int x, y))›*) assms(7) (*‹∀q∈ps⇩R. l ≤ fst q›*) by auto ultimately have "RPS = LSQPS ∪ RSQPS" using LSQPS_def (*‹LSQPS = {p ∈ ps⇩L. (case p of (x, y) ⇒ (real_of_int x, real_of_int y)) ∈ LSQ}›*) RSQPS_def (*‹RSQPS = {p ∈ ps⇩R. (case p of (x, y) ⇒ (real_of_int x, real_of_int y)) ∈ RSQ}›*) PS_def (*‹PS = p # ps›*) RPS_def (*‹RPS = {p ∈ set PS. (case p of (x, y) ⇒ (real_of_int x, real_of_int y)) ∈ R}›*) assms(4) (*‹set (p # ps) = ps⇩L ∪ ps⇩R›*) by blast have "sparse δ LSQPS" using assms(8) (*‹sparse δ ps⇩L›*) LSQPS_def (*‹LSQPS = {p ∈ ps⇩L. (case p of (x, y) ⇒ (real_of_int x, real_of_int y)) ∈ LSQ}›*) sparse_def (*‹sparse ?δ ?ps = (∀p₀∈?ps. ∀p₁∈?ps. p₀ ≠ p₁ ⟶ ?δ ≤ dist (case p₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₁ of (x, y) ⇒ (real_of_int x, real_of_int y)))›*) by simp hence CLSQPS: "card LSQPS ≤ 4" using max_points_square[of LSQPS "l - δ" "snd p" δ] (*‹⟦∀pa∈LSQPS. (case pa of (x, y) ⇒ (real_of_int x, real_of_int y)) ∈ cbox (real_of_int l - δ, real_of_int (snd p)) (real_of_int l - δ + δ, real_of_int (snd p) + δ); sparse δ LSQPS; 0 ≤ δ⟧ ⟹ card LSQPS ≤ 4›*) assms(3) (*‹0 ≤ δ›*) LSQ_def (*‹LSQ = cbox (case (real_of_int l - δ, snd p) of (x, y) ⇒ (x, real_of_int y)) (case (l, real_of_int (snd p) + δ) of (x, y) ⇒ (real_of_int x, y))›*) LSQPS_def (*‹LSQPS = {p ∈ ps⇩L. (case p of (x, y) ⇒ (real_of_int x, real_of_int y)) ∈ LSQ}›*) by auto have "sparse δ RSQPS" using assms(9) (*‹sparse δ ps⇩R›*) RSQPS_def (*‹RSQPS = {p ∈ ps⇩R. (case p of (x, y) ⇒ (real_of_int x, real_of_int y)) ∈ RSQ}›*) sparse_def (*‹sparse ?δ ?ps = (∀p₀∈?ps. ∀p₁∈?ps. p₀ ≠ p₁ ⟶ ?δ ≤ dist (case p₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₁ of (x, y) ⇒ (real_of_int x, real_of_int y)))›*) by simp hence CRSQPS: "card RSQPS ≤ 4" using max_points_square[of RSQPS l "snd p" δ] (*‹⟦∀pa∈RSQPS. (case pa of (x, y) ⇒ (real_of_int x, real_of_int y)) ∈ cbox (real_of_int l, real_of_int (snd p)) (real_of_int l + δ, real_of_int (snd p) + δ); sparse δ RSQPS; 0 ≤ δ⟧ ⟹ card RSQPS ≤ 4›*) assms(3) (*‹0 ≤ δ›*) RSQ_def (*‹RSQ = cbox (case (l, snd p) of (x, y) ⇒ (real_of_int x, real_of_int y)) (real_of_int l + δ, real_of_int (snd p) + δ)›*) RSQPS_def (*‹RSQPS = {p ∈ ps⇩R. (case p of (x, y) ⇒ (real_of_int x, real_of_int y)) ∈ RSQ}›*) by auto have CRPS: "card RPS ≤ 8" using CLSQPS (*‹card LSQPS ≤ 4›*) CRSQPS (*‹card RSQPS ≤ 4›*) card_Un_le[of LSQPS RSQPS] (*‹card ((LSQPS::(int × int) set) ∪ (RSQPS::(int × int) set)) ≤ card LSQPS + card RSQPS›*) ‹RPS = LSQPS ∪ RSQPS› (*‹(RPS::(int × int) set) = (LSQPS::(int × int) set) ∪ (RSQPS::(int × int) set)›*) by auto have "set (p # filter (λq. snd q - snd p ≤ δ) ps) ⊆ RPS" proof (standard) (*goal: ‹⋀x. x ∈ set (p # filter (λq. real_of_int (snd q - snd p) ≤ δ) ps) ⟹ x ∈ RPS›*) fix q assume "*": "q ∈ set (p # filter (λq. snd q - snd p ≤ δ) ps)" (*‹(q::int × int) ∈ set ((p::int × int) # filter (λq::int × int. real_of_int (snd q - snd p) ≤ (δ::real)) (ps::(int × int) list))›*) hence CPS: "q ∈ set PS" using PS_def (*‹(PS::(int × int) list) = (p::int × int) # (ps::(int × int) list)›*) by auto hence "snd p ≤ snd q" "snd q ≤ snd p + δ" using assms(2,3) (*‹sorted_snd (p # ps)› ‹0 ≤ δ›*) PS_def (*‹PS = p # ps›*) sorted_snd_def (*‹sorted_snd ?ps = sorted_wrt (λp₀ p₁. snd p₀ ≤ snd p₁) ?ps›*) "*" (*‹(q::int × int) ∈ set ((p::int × int) # filter (λq::int × int. real_of_int (snd q - snd p) ≤ (δ::real)) (ps::(int × int) list))›*) apply - (*goals: 1. ‹⟦q ∈ set PS; sorted_snd (p # ps); 0 ≤ δ; PS = p # ps; ⋀ps. sorted_snd ps = sorted_wrt (λp₀ p₁. snd p₀ ≤ snd p₁) ps; q ∈ set (p # filter (λq. real_of_int (snd q - snd p) ≤ δ) ps)⟧ ⟹ snd p ≤ snd q› 2. ‹⟦q ∈ set PS; sorted_snd (p # ps); 0 ≤ δ; PS = p # ps; ⋀ps. sorted_snd ps = sorted_wrt (λp₀ p₁. snd p₀ ≤ snd p₁) ps; q ∈ set (p # filter (λq. real_of_int (snd q - snd p) ≤ δ) ps)⟧ ⟹ real_of_int (snd q) ≤ real_of_int (snd p) + δ› 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*) . moreover have "l - δ < fst q" "fst q < l + δ" using CPS (*‹q ∈ set PS›*) assms(5) (*‹∀q∈set (p # ps). real_of_int l - δ < real_of_int (fst q) ∧ real_of_int (fst q) < real_of_int l + δ›*) PS_def (*‹PS = p # ps›*) apply - (*goals: 1. ‹⟦q ∈ set PS; ∀q∈set (p # ps). real_of_int l - δ < real_of_int (fst q) ∧ real_of_int (fst q) < real_of_int l + δ; PS = p # ps⟧ ⟹ real_of_int l - δ < real_of_int (fst q)› 2. ‹⟦q ∈ set PS; ∀q∈set (p # ps). real_of_int l - δ < real_of_int (fst q) ∧ real_of_int (fst q) < real_of_int l + δ; PS = p # ps⟧ ⟹ real_of_int (fst q) < real_of_int l + δ› discuss goal 1*) apply blast (*discuss goal 2*) apply blast (*proven 2 subgoals*) . ultimately have "q ∈ R" using R_def (*‹R = cbox (case (real_of_int l - δ, snd p) of (x, y) ⇒ (x, real_of_int y)) (real_of_int l + δ, real_of_int (snd p) + δ)›*) mem_cbox_2D[of "l - δ" "fst q" "l + δ" "snd p" "snd q" "snd p + δ"] (*‹(real_of_int (l::int) - (δ::real) ≤ real_of_int (fst (q::int × int)) ∧ real_of_int (fst q) ≤ real_of_int l + δ ∧ real_of_int (snd (p::int × int)) ≤ real_of_int (snd q) ∧ real_of_int (snd q) ≤ real_of_int (snd p) + δ) = ((real_of_int (fst q), real_of_int (snd q)) ∈ cbox (real_of_int l - δ, real_of_int (snd p)) (real_of_int l + δ, real_of_int (snd p) + δ))›*) by (simp add: prod.case_eq_if (*‹(case ?prod of (x, xa) ⇒ ?f x xa) = ?f (fst ?prod) (snd ?prod)›*)) thus "q ∈ RPS" using CPS (*‹q ∈ set PS›*) RPS_def (*‹RPS = {p ∈ set PS. (case p of (x, y) ⇒ (real_of_int x, real_of_int y)) ∈ R}›*) by simp qed moreover have "finite RPS" by (simp add: RPS_def (*‹(RPS::(int × int) set) = {p::int × int ∈ set (PS::(int × int) list). (case p of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) ∈ (R::(real × real) set)}›*)) ultimately have "card (set (p # filter (λq. snd q - snd p ≤ δ) ps)) ≤ 8" using CRPS (*‹card RPS ≤ 8›*) card_mono[of RPS "set (p # filter (λq. snd q - snd p ≤ δ) ps)"] (*‹⟦finite RPS; set (p # filter (λq. real_of_int (snd q - snd p) ≤ δ) ps) ⊆ RPS⟧ ⟹ card (set (p # filter (λq. real_of_int (snd q - snd p) ≤ δ) ps)) ≤ card RPS›*) by simp moreover have "distinct (p # filter (λq. snd q - snd p ≤ δ) ps)" using assms(1) (*‹distinct (p # ps)›*) by simp ultimately have "length (p # filter (λq. snd q - snd p ≤ δ) ps) ≤ 8" using assms(1) (*‹distinct (p # ps)›*) PS_def (*‹PS = p # ps›*) distinct_card (*‹distinct (?xs::?'a list) ⟹ card (set ?xs) = length ?xs›*) by metis thus "?thesis" (*goal: ‹length (filter (λq. real_of_int (snd q - snd p) ≤ δ) ps) ≤ 7›*) by simp qed subsubsection "Combine Step" fun t_find_closest :: "point ⇒ real ⇒ point list ⇒ nat" where "t_find_closest _ _ [] = 1" | "t_find_closest _ _ [_] = 1" | "t_find_closest p δ (p₀ # ps) = 1 + ( if δ ≤ snd p₀ - snd p then 0 else t_find_closest p (min δ (dist p p₀)) ps )" lemma t_find_closest_eq_time_find_closest_tm: "t_find_closest p δ ps = time (find_closest_tm p δ ps)" apply (induction p δ ps rule: t_find_closest.induct (*‹⟦⋀uu_ uv_. ?P uu_ uv_ []; ⋀uw_ ux_ uy_. ?P uw_ ux_ [uy_]; ⋀p δ p₀ v va. (¬ δ ≤ real_of_int (snd p₀ - snd p) ⟹ ?P p (min δ (dist (case p of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₀ of (x, y) ⇒ (real_of_int x, real_of_int y)))) (v # va)) ⟹ ?P p δ (p₀ # v # va)⟧ ⟹ ?P ?a0.0 ?a1.0 ?a2.0›*)) (*goals: 1. ‹⋀uu_ uv_. t_find_closest uu_ uv_ [] = time (find_closest_tm uu_ uv_ [])› 2. ‹⋀uw_ ux_ uy_. t_find_closest uw_ ux_ [uy_] = time (find_closest_tm uw_ ux_ [uy_])› 3. ‹⋀p δ p₀ v va. (¬ δ ≤ real_of_int (snd p₀ - snd p) ⟹ t_find_closest p (min δ (dist (case p of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₀ of (x, y) ⇒ (real_of_int x, real_of_int y)))) (v # va) = time (find_closest_tm p (min δ (dist (case p of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₀ of (x, y) ⇒ (real_of_int x, real_of_int y)))) (v # va))) ⟹ t_find_closest p δ (p₀ # v # va) = time (find_closest_tm p δ (p₀ # v # va))› discuss goal 1*) apply ((auto simp: time_simps (*‹time (?tm ⤜ ?f) = time ?tm + time (?f (Time_Monad.val ?tm))› ‹tick ?v = ??.Time_Monad.tm.TM ?v 1›*))[1]) (*discuss goal 2*) apply ((auto simp: time_simps (*‹time (?tm ⤜ ?f) = time ?tm + time (?f (Time_Monad.val ?tm))› ‹tick ?v = ??.Time_Monad.tm.TM ?v 1›*))[1]) (*discuss goal 3*) apply ((auto simp: time_simps (*‹time (?tm ⤜ ?f) = time ?tm + time (?f (Time_Monad.val ?tm))› ‹tick ?v = ??.Time_Monad.tm.TM ?v 1›*))[1]) (*proven 3 subgoals*) . lemma t_find_closest_mono: "δ' ≤ δ ⟹ t_find_closest p δ' ps ≤ t_find_closest p δ ps" apply (induction rule: t_find_closest.induct (*‹⟦⋀uu_ uv_. ?P uu_ uv_ []; ⋀uw_ ux_ uy_. ?P uw_ ux_ [uy_]; ⋀p δ p₀ v va. (¬ δ ≤ real_of_int (snd p₀ - snd p) ⟹ ?P p (min δ (dist (case p of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₀ of (x, y) ⇒ (real_of_int x, real_of_int y)))) (v # va)) ⟹ ?P p δ (p₀ # v # va)⟧ ⟹ ?P ?a0.0 ?a1.0 ?a2.0›*)) (*goals: 1. ‹⋀uu_ uv_. δ' ≤ uv_ ⟹ t_find_closest uu_ δ' [] ≤ t_find_closest uu_ uv_ []› 2. ‹⋀uw_ ux_ uy_. δ' ≤ ux_ ⟹ t_find_closest uw_ δ' [uy_] ≤ t_find_closest uw_ ux_ [uy_]› 3. ‹⋀p δ p₀ v va. ⟦⟦¬ δ ≤ real_of_int (snd p₀ - snd p); δ' ≤ min δ (dist (case p of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₀ of (x, y) ⇒ (real_of_int x, real_of_int y)))⟧ ⟹ t_find_closest p δ' (v # va) ≤ t_find_closest p (min δ (dist (case p of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₀ of (x, y) ⇒ (real_of_int x, real_of_int y)))) (v # va); δ' ≤ δ⟧ ⟹ t_find_closest p δ' (p₀ # v # va) ≤ t_find_closest p δ (p₀ # v # va)› discuss goal 1*) apply ((auto simp: Let_def (*‹Let ?s ?f ≡ ?f ?s›*) min_def (*‹min ?a ?b = (if ?a ≤ ?b then ?a else ?b)›*))[1]) (*discuss goal 2*) apply ((auto simp: Let_def (*‹Let ?s ?f ≡ ?f ?s›*) min_def (*‹min ?a ?b = (if ?a ≤ ?b then ?a else ?b)›*))[1]) (*discuss goal 3*) apply ((auto simp: Let_def (*‹Let ?s ?f ≡ ?f ?s›*) min_def (*‹min ?a ?b = (if ?a ≤ ?b then ?a else ?b)›*))[1]) (*proven 3 subgoals*) . lemma t_find_closest_cnt: "t_find_closest p δ ps ≤ 1 + length (filter (λq. snd q - snd p ≤ δ) ps)" proof (induction p δ ps rule: t_find_closest.induct (*‹⟦⋀uu_ uv_. ?P uu_ uv_ []; ⋀uw_ ux_ uy_. ?P uw_ ux_ [uy_]; ⋀p δ p₀ v va. (¬ δ ≤ real_of_int (snd p₀ - snd p) ⟹ ?P p (min δ (dist (case p of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₀ of (x, y) ⇒ (real_of_int x, real_of_int y)))) (v # va)) ⟹ ?P p δ (p₀ # v # va)⟧ ⟹ ?P ?a0.0 ?a1.0 ?a2.0›*)) (*goals: 1. ‹⋀uu_ uv_. t_find_closest uu_ uv_ [] ≤ 1 + length (filter (λq. real_of_int (snd q - snd uu_) ≤ uv_) [])› 2. ‹⋀uw_ ux_ uy_. t_find_closest uw_ ux_ [uy_] ≤ 1 + length (filter (λq. real_of_int (snd q - snd uw_) ≤ ux_) [uy_])› 3. ‹⋀p δ p₀ v va. (¬ δ ≤ real_of_int (snd p₀ - snd p) ⟹ t_find_closest p (min δ (dist (case p of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₀ of (x, y) ⇒ (real_of_int x, real_of_int y)))) (v # va) ≤ 1 + length (filter (λq. real_of_int (snd q - snd p) ≤ min δ (dist (case p of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₀ of (x, y) ⇒ (real_of_int x, real_of_int y)))) (v # va))) ⟹ t_find_closest p δ (p₀ # v # va) ≤ 1 + length (filter (λq. real_of_int (snd q - snd p) ≤ δ) (p₀ # v # va))›*) case (3 p δ p₀ p₂ ps) (*‹¬ δ ≤ real_of_int (snd p₀ - snd p) ⟹ t_find_closest p (min δ (dist (case p of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₀ of (x, y) ⇒ (real_of_int x, real_of_int y)))) (p₂ # ps) ≤ 1 + length (filter (λq. real_of_int (snd q - snd p) ≤ min δ (dist (case p of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₀ of (x, y) ⇒ (real_of_int x, real_of_int y)))) (p₂ # ps))›*) show "?case" (*goal: ‹t_find_closest p δ (p₀ # p₂ # ps) ≤ 1 + length (filter (λq. real_of_int (snd q - snd p) ≤ δ) (p₀ # p₂ # ps))›*) proof (cases "δ ≤ snd p₀ - snd p") (*goals: 1. ‹(δ::real) ≤ real_of_int (snd (p₀::int × int) - snd (p::int × int)) ⟹ t_find_closest p δ (p₀ # (p₂::int × int) # (ps::(int × int) list)) ≤ (1::nat) + length (filter (λq::int × int. real_of_int (snd q - snd p) ≤ δ) (p₀ # p₂ # ps))› 2. ‹¬ (δ::real) ≤ real_of_int (snd (p₀::int × int) - snd (p::int × int)) ⟹ t_find_closest p δ (p₀ # (p₂::int × int) # (ps::(int × int) list)) ≤ (1::nat) + length (filter (λq::int × int. real_of_int (snd q - snd p) ≤ δ) (p₀ # p₂ # ps))›*) case True (*‹δ ≤ real_of_int (snd p₀ - snd p)›*) thus "?thesis" (*goal: ‹t_find_closest p δ (p₀ # p₂ # ps) ≤ 1 + length (filter (λq. real_of_int (snd q - snd p) ≤ δ) (p₀ # p₂ # ps))›*) by simp next (*goal: ‹¬ δ ≤ real_of_int (snd p₀ - snd p) ⟹ t_find_closest p δ (p₀ # p₂ # ps) ≤ 1 + length (filter (λq. real_of_int (snd q - snd p) ≤ δ) (p₀ # p₂ # ps))›*) case False (*‹¬ δ ≤ real_of_int (snd p₀ - snd p)›*) hence "*": "snd p₀ - snd p ≤ δ" by simp have "t_find_closest p δ (p₀ # p₂ # ps) = 1 + t_find_closest p (min δ (dist p p₀)) (p₂ # ps)" using False (*‹¬ δ ≤ real_of_int (snd p₀ - snd p)›*) by simp also (*calculation: ‹t_find_closest (p::int × int) (δ::real) ((p₀::int × int) # (p₂::int × int) # (ps::(int × int) list)) = (1::nat) + t_find_closest p (min δ (dist (case p of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) (case p₀ of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)))) (p₂ # ps)›*) have "... ≤ 1 + 1 + length (filter (λq. snd q - snd p ≤ min δ (dist p p₀)) (p₂ # ps))" using False (*‹¬ δ ≤ real_of_int (snd p₀ - snd p)›*) "3" (*‹¬ δ ≤ real_of_int (snd p₀ - snd p) ⟹ t_find_closest p (min δ (dist (case p of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₀ of (x, y) ⇒ (real_of_int x, real_of_int y)))) (p₂ # ps) ≤ 1 + length (filter (λq. real_of_int (snd q - snd p) ≤ min δ (dist (case p of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₀ of (x, y) ⇒ (real_of_int x, real_of_int y)))) (p₂ # ps))›*) by simp also (*calculation: ‹t_find_closest p δ (p₀ # p₂ # ps) ≤ 1 + 1 + length (filter (λq. real_of_int (snd q - snd p) ≤ min δ (dist (case p of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₀ of (x, y) ⇒ (real_of_int x, real_of_int y)))) (p₂ # ps))›*) have "... ≤ 1 + 1 + length (filter (λq. snd q - snd p ≤ δ) (p₂ # ps))" using "*" (*‹real_of_int (snd p₀ - snd p) ≤ δ›*) by (meson add_le_cancel_left (*‹((?c::?'a) + (?a::?'a) ≤ ?c + (?b::?'a)) = (?a ≤ ?b)›*) length_filter_P_impl_Q (*‹(⋀x::?'a. (?P::?'a ⇒ bool) x ⟹ (?Q::?'a ⇒ bool) x) ⟹ length (filter ?P (?xs::?'a list)) ≤ length (filter ?Q ?xs)›*) min.bounded_iff (*‹((?a::?'a) ≤ min (?b::?'a) (?c::?'a)) = (?a ≤ ?b ∧ ?a ≤ ?c)›*)) also (*calculation: ‹t_find_closest p δ (p₀ # p₂ # ps) ≤ 1 + 1 + length (filter (λq. real_of_int (snd q - snd p) ≤ δ) (p₂ # ps))›*) have "... ≤ 1 + length (filter (λq. snd q - snd p ≤ δ) (p₀ # p₂ # ps))" using False (*‹¬ δ ≤ real_of_int (snd p₀ - snd p)›*) by simp ultimately show "?thesis" (*goal: ‹t_find_closest p δ (p₀ # p₂ # ps) ≤ 1 + length (filter (λq. real_of_int (snd q - snd p) ≤ δ) (p₀ # p₂ # ps))›*) by simp qed qed (auto) (*solves the remaining goals: 1. ‹⋀uu_ uv_. t_find_closest uu_ uv_ [] ≤ 1 + length (filter (λq. real_of_int (snd q - snd uu_) ≤ uv_) [])› 2. ‹⋀uw_ ux_ uy_. t_find_closest uw_ ux_ [uy_] ≤ 1 + length (filter (λq. real_of_int (snd q - snd uw_) ≤ ux_) [uy_])›*) corollary t_find_closest_bound: fixes δ :: real and p :: point and ps :: "point list" and l :: int assumes "distinct (p # ps)" "sorted_snd (p # ps)" "0 ≤ δ" "set (p # ps) = ps⇩L ∪ ps⇩R" assumes "∀p' ∈ set (p # ps). l - δ < fst p' ∧ fst p' < l + δ" assumes "∀p ∈ ps⇩L. fst p ≤ l" "∀p ∈ ps⇩R. l ≤ fst p" assumes "sparse δ ps⇩L" "sparse δ ps⇩R" shows "t_find_closest p δ ps ≤ 8" using assms (*‹distinct (p # ps)› ‹sorted_snd (p # ps)› ‹0 ≤ δ› ‹set (p # ps) = ps⇩L ∪ ps⇩R› ‹∀p'∈set (p # ps). real_of_int l - δ < real_of_int (fst p') ∧ real_of_int (fst p') < real_of_int l + δ› ‹∀p∈ps⇩L. fst p ≤ l› ‹∀p∈ps⇩R. l ≤ fst p› ‹sparse δ ps⇩L› ‹sparse δ ps⇩R›*) core_argument[of p ps δ ps⇩L ps⇩R l] (*‹⟦distinct (p # ps); sorted_snd (p # ps); 0 ≤ δ; set (p # ps) = ps⇩L ∪ ps⇩R; ∀q∈set (p # ps). real_of_int l - δ < real_of_int (fst q) ∧ real_of_int (fst q) < real_of_int l + δ; ∀q∈ps⇩L. fst q ≤ l; ∀q∈ps⇩R. l ≤ fst q; sparse δ ps⇩L; sparse δ ps⇩R⟧ ⟹ length (filter (λq. real_of_int (snd q - snd p) ≤ δ) ps) ≤ 7›*) t_find_closest_cnt[of p δ ps] (*‹t_find_closest (p::int × int) (δ::real) (ps::(int × int) list) ≤ (1::nat) + length (filter (λq::int × int. real_of_int (snd q - snd p) ≤ δ) ps)›*) by linarith fun t_find_closest_pair :: "(point * point) ⇒ point list ⇒ nat" where "t_find_closest_pair _ [] = 1" | "t_find_closest_pair _ [_] = 1" | "t_find_closest_pair (c₀, c₁) (p₀ # ps) = 1 + ( let p₁ = find_closest p₀ (dist c₀ c₁) ps in t_find_closest p₀ (dist c₀ c₁) ps + ( if dist c₀ c₁ ≤ dist p₀ p₁ then t_find_closest_pair (c₀, c₁) ps else t_find_closest_pair (p₀, p₁) ps ))" lemma t_find_closest_pair_eq_time_find_closest_pair_tm: "t_find_closest_pair (c₀, c₁) ps = time (find_closest_pair_tm (c₀, c₁) ps)" apply (induction "(c₀, c₁)" ps arbitrary: c₀ c₁ rule: t_find_closest_pair.induct) (*goals: 1. ‹⋀c₀ c₁. t_find_closest_pair (c₀, c₁) [] = time (find_closest_pair_tm (c₀, c₁) [])› 2. ‹⋀uw_ c₀ c₁. t_find_closest_pair (c₀, c₁) [uw_] = time (find_closest_pair_tm (c₀, c₁) [uw_])› 3. ‹⋀c₀ c₁ p₀ v va. ⟦⋀x. ⟦x = find_closest p₀ (dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y))) (v # va); dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y)) ≤ dist (case p₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case x of (x, y) ⇒ (real_of_int x, real_of_int y))⟧ ⟹ t_find_closest_pair (c₀, c₁) (v # va) = time (find_closest_pair_tm (c₀, c₁) (v # va)); ⋀x. ⟦x = find_closest p₀ (dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y))) (v # va); ¬ dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y)) ≤ dist (case p₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case x of (x, y) ⇒ (real_of_int x, real_of_int y))⟧ ⟹ t_find_closest_pair (p₀, x) (v # va) = time (find_closest_pair_tm (p₀, x) (v # va))⟧ ⟹ t_find_closest_pair (c₀, c₁) (p₀ # v # va) = time (find_closest_pair_tm (c₀, c₁) (p₀ # v # va))› discuss goal 1*) apply ((auto simp: time_simps (*‹time (?tm ⤜ ?f) = time ?tm + time (?f (Time_Monad.val ?tm))› ‹tick ?v = ??.Time_Monad.tm.TM ?v 1›*) find_closest_eq_val_find_closest_tm (*‹Time_Monad.val (find_closest_tm ?p ?δ ?ps) = find_closest ?p ?δ ?ps›*) t_find_closest_eq_time_find_closest_tm (*‹t_find_closest ?p ?δ ?ps = time (find_closest_tm ?p ?δ ?ps)›*))[1]) (*discuss goal 2*) apply ((auto simp: time_simps (*‹time (?tm ⤜ ?f) = time ?tm + time (?f (Time_Monad.val ?tm))› ‹tick ?v = ??.Time_Monad.tm.TM ?v 1›*) find_closest_eq_val_find_closest_tm (*‹Time_Monad.val (find_closest_tm ?p ?δ ?ps) = find_closest ?p ?δ ?ps›*) t_find_closest_eq_time_find_closest_tm (*‹t_find_closest ?p ?δ ?ps = time (find_closest_tm ?p ?δ ?ps)›*))[1]) (*discuss goal 3*) apply ((auto simp: time_simps (*‹time (?tm ⤜ ?f) = time ?tm + time (?f (Time_Monad.val ?tm))› ‹tick ?v = ??.Time_Monad.tm.TM ?v 1›*) find_closest_eq_val_find_closest_tm (*‹Time_Monad.val (find_closest_tm ?p ?δ ?ps) = find_closest ?p ?δ ?ps›*) t_find_closest_eq_time_find_closest_tm (*‹t_find_closest ?p ?δ ?ps = time (find_closest_tm ?p ?δ ?ps)›*))[1]) (*proven 3 subgoals*) . lemma t_find_closest_pair_bound: assumes "distinct ps" "sorted_snd ps" "δ = dist c₀ c₁" "set ps = ps⇩L ∪ ps⇩R" assumes "∀p ∈ set ps. l - Δ < fst p ∧ fst p < l + Δ" assumes "∀p ∈ ps⇩L. fst p ≤ l" "∀p ∈ ps⇩R. l ≤ fst p" assumes "sparse Δ ps⇩L" "sparse Δ ps⇩R" "δ ≤ Δ" shows "t_find_closest_pair (c₀, c₁) ps ≤ 9 * length ps + 1" using assms (*‹distinct ps› ‹sorted_snd ps› ‹δ = dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y))› ‹set (ps::(int × int) list) = (ps⇩L::(int × int) set) ∪ (ps⇩R::(int × int) set)› ‹∀p∈set ps. real_of_int l - Δ < real_of_int (fst p) ∧ real_of_int (fst p) < real_of_int l + Δ› ‹∀p∈ps⇩L. fst p ≤ l› ‹∀p::int × int∈ps⇩R::(int × int) set. (l::int) ≤ fst p› ‹sparse Δ ps⇩L› ‹sparse Δ ps⇩R› ‹δ ≤ Δ›*) proof (induction "(c₀, c₁)" ps arbitrary: δ c₀ c₁ ps⇩L ps⇩R rule: t_find_closest_pair.induct) (*goals: 1. ‹⋀c₀ c₁ δ ps⇩L ps⇩R. ⟦distinct []; sorted_snd []; δ = dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y)); set [] = ps⇩L ∪ ps⇩R; ∀p∈set []. real_of_int l - Δ < real_of_int (fst p) ∧ real_of_int (fst p) < real_of_int l + Δ; ∀p∈ps⇩L. fst p ≤ l; ∀p∈ps⇩R. l ≤ fst p; sparse Δ ps⇩L; sparse Δ ps⇩R; δ ≤ Δ⟧ ⟹ t_find_closest_pair (c₀, c₁) [] ≤ 9 * length [] + 1› 2. ‹⋀uw_ c₀ c₁ δ ps⇩L ps⇩R. ⟦distinct [uw_]; sorted_snd [uw_]; δ = dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y)); set [uw_] = ps⇩L ∪ ps⇩R; ∀p∈set [uw_]. real_of_int l - Δ < real_of_int (fst p) ∧ real_of_int (fst p) < real_of_int l + Δ; ∀p∈ps⇩L. fst p ≤ l; ∀p∈ps⇩R. l ≤ fst p; sparse Δ ps⇩L; sparse Δ ps⇩R; δ ≤ Δ⟧ ⟹ t_find_closest_pair (c₀, c₁) [uw_] ≤ 9 * length [uw_] + 1› 3. ‹⋀c₀ c₁ p₀ v va δ ps⇩L ps⇩R. ⟦⋀x δ ps⇩L ps⇩R. ⟦x = find_closest p₀ (dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y))) (v # va); dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y)) ≤ dist (case p₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case x of (x, y) ⇒ (real_of_int x, real_of_int y)); distinct (v # va); sorted_snd (v # va); δ = dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y)); set (v # va) = ps⇩L ∪ ps⇩R; ∀p∈set (v # va). real_of_int l - Δ < real_of_int (fst p) ∧ real_of_int (fst p) < real_of_int l + Δ; ∀p∈ps⇩L. fst p ≤ l; ∀p∈ps⇩R. l ≤ fst p; sparse Δ ps⇩L; sparse Δ ps⇩R; δ ≤ Δ⟧ ⟹ t_find_closest_pair (c₀, c₁) (v # va) ≤ 9 * length (v # va) + 1; ⋀x δ ps⇩L ps⇩R. ⟦x = find_closest p₀ (dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y))) (v # va); ¬ dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y)) ≤ dist (case p₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case x of (x, y) ⇒ (real_of_int x, real_of_int y)); distinct (v # va); sorted_snd (v # va); δ = dist (case p₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case x of (x, y) ⇒ (real_of_int x, real_of_int y)); set (v # va) = ps⇩L ∪ ps⇩R; ∀p∈set (v # va). real_of_int l - Δ < real_of_int (fst p) ∧ real_of_int (fst p) < real_of_int l + Δ; ∀p∈ps⇩L. fst p ≤ l; ∀p∈ps⇩R. l ≤ fst p; sparse Δ ps⇩L; sparse Δ ps⇩R; δ ≤ Δ⟧ ⟹ t_find_closest_pair (p₀, x) (v # va) ≤ 9 * length (v # va) + 1; distinct (p₀ # v # va); sorted_snd (p₀ # v # va); δ = dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y)); set (p₀ # v # va) = ps⇩L ∪ ps⇩R; ∀p∈set (p₀ # v # va). real_of_int l - Δ < real_of_int (fst p) ∧ real_of_int (fst p) < real_of_int l + Δ; ∀p∈ps⇩L. fst p ≤ l; ∀p∈ps⇩R. l ≤ fst p; sparse Δ ps⇩L; sparse Δ ps⇩R; δ ≤ Δ⟧ ⟹ t_find_closest_pair (c₀, c₁) (p₀ # v # va) ≤ 9 * length (p₀ # v # va) + 1›*) case (3 c₀ c₁ p₀ p₂ ps) (*‹⟦?x = find_closest p₀ (dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y))) (p₂ # ps); dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y)) ≤ dist (case p₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case ?x of (x, y) ⇒ (real_of_int x, real_of_int y)); distinct (p₂ # ps); sorted_snd (p₂ # ps); ?δ = dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y)); set (p₂ # ps) = ?ps⇩L ∪ ?ps⇩R; ∀p∈set (p₂ # ps). real_of_int l - Δ < real_of_int (fst p) ∧ real_of_int (fst p) < real_of_int l + Δ; ∀p∈?ps⇩L. fst p ≤ l; ∀p∈?ps⇩R. l ≤ fst p; sparse Δ ?ps⇩L; sparse Δ ?ps⇩R; ?δ ≤ Δ⟧ ⟹ t_find_closest_pair (c₀, c₁) (p₂ # ps) ≤ 9 * length (p₂ # ps) + 1› ‹⟦?x = find_closest p₀ (dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y))) (p₂ # ps); ¬ dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y)) ≤ dist (case p₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case ?x of (x, y) ⇒ (real_of_int x, real_of_int y)); distinct (p₂ # ps); sorted_snd (p₂ # ps); ?δ = dist (case p₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case ?x of (x, y) ⇒ (real_of_int x, real_of_int y)); set (p₂ # ps) = ?ps⇩L ∪ ?ps⇩R; ∀p∈set (p₂ # ps). real_of_int l - Δ < real_of_int (fst p) ∧ real_of_int (fst p) < real_of_int l + Δ; ∀p∈?ps⇩L. fst p ≤ l; ∀p∈?ps⇩R. l ≤ fst p; sparse Δ ?ps⇩L; sparse Δ ?ps⇩R; ?δ ≤ Δ⟧ ⟹ t_find_closest_pair (p₀, ?x) (p₂ # ps) ≤ 9 * length (p₂ # ps) + 1› ‹distinct (p₀ # p₂ # ps)› ‹sorted_snd (p₀ # p₂ # ps)› ‹(δ::real) = dist (case c₀::int × int of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) (case c₁::int × int of (x::int, y::int) ⇒ (real_of_int x, real_of_int y))› ‹set (p₀ # p₂ # ps) = ps⇩L ∪ ps⇩R› ‹∀p::int × int∈set ((p₀::int × int) # (p₂::int × int) # (ps::(int × int) list)). real_of_int (l::int) - (Δ::real) < real_of_int (fst p) ∧ real_of_int (fst p) < real_of_int l + Δ› ‹∀p∈ps⇩L. fst p ≤ l› ‹∀p∈ps⇩R. l ≤ fst p› ‹sparse Δ ps⇩L› ‹sparse (Δ::real) (ps⇩R::(int × int) set)› ‹(δ::real) ≤ (Δ::real)›*) let ?ps = "p₂ # ps" define p₁ where "p₁_def": "p₁ = find_closest p₀ (dist c₀ c₁) ?ps" define PS⇩L where "PS⇩L_def": "PS⇩L = ps⇩L - { p₀ }" define PS⇩R where "PS⇩R_def": "PS⇩R = ps⇩R - { p₀ }" note defs = "p₁_def" (*‹p₁ = find_closest p₀ (dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y))) (p₂ # ps)›*) "PS⇩L_def" (*‹PS⇩L = ps⇩L - {p₀}›*) "PS⇩R_def" (*‹(PS⇩R::(int × int) set) = (ps⇩R::(int × int) set) - {p₀::int × int}›*) have "*": "0 ≤ Δ" using "3.prems"(3,10) (*‹δ = dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y))› ‹δ ≤ Δ›*) zero_le_dist[of c₀ c₁] (*‹(0::real) ≤ dist (case c₀::int × int of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) (case c₁::int × int of (x::int, y::int) ⇒ (real_of_int x, real_of_int y))›*) by argo hence "t_find_closest p₀ Δ ?ps ≤ 8" using t_find_closest_bound[of p₀ ?ps Δ ps⇩L ps⇩R] (*‹⟦distinct (p₀ # p₂ # ps); sorted_snd (p₀ # p₂ # ps); 0 ≤ Δ; set (p₀ # p₂ # ps) = ps⇩L ∪ ps⇩R; ∀p'∈set (p₀ # p₂ # ps). real_of_int ?l - Δ < real_of_int (fst p') ∧ real_of_int (fst p') < real_of_int ?l + Δ; ∀p∈ps⇩L. fst p ≤ ?l; ∀p∈ps⇩R. ?l ≤ fst p; sparse Δ ps⇩L; sparse Δ ps⇩R⟧ ⟹ t_find_closest p₀ Δ (p₂ # ps) ≤ 8›*) "3.prems" (*‹distinct ((p₀::int × int) # (p₂::int × int) # (ps::(int × int) list))› ‹sorted_snd (p₀ # p₂ # ps)› ‹(δ::real) = dist (case c₀::int × int of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) (case c₁::int × int of (x::int, y::int) ⇒ (real_of_int x, real_of_int y))› ‹set (p₀ # p₂ # ps) = ps⇩L ∪ ps⇩R› ‹∀p::int × int∈set ((p₀::int × int) # (p₂::int × int) # (ps::(int × int) list)). real_of_int (l::int) - (Δ::real) < real_of_int (fst p) ∧ real_of_int (fst p) < real_of_int l + Δ› ‹∀p∈ps⇩L. fst p ≤ l› ‹∀p::int × int∈ps⇩R::(int × int) set. (l::int) ≤ fst p› ‹sparse Δ ps⇩L› ‹sparse Δ ps⇩R› ‹δ ≤ Δ›*) by blast hence A: "t_find_closest p₀ (dist c₀ c₁) ?ps ≤ 8" by (metis "3.prems" (*‹δ = dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y))› ‹δ ≤ Δ›*) (3,10) order_trans (*‹⟦?x ≤ ?y; ?y ≤ ?z⟧ ⟹ ?x ≤ ?z›*) t_find_closest_mono (*‹?δ' ≤ ?δ ⟹ t_find_closest ?p ?δ' ?ps ≤ t_find_closest ?p ?δ ?ps›*)) have B: "distinct ?ps" "sorted_snd ?ps" using "3.prems"(1,2) (*‹distinct (p₀ # p₂ # ps)› ‹sorted_snd ((p₀::int × int) # (p₂::int × int) # (ps::(int × int) list))›*) sorted_snd_def (*‹sorted_snd ?ps = sorted_wrt (λp₀ p₁. snd p₀ ≤ snd p₁) ?ps›*) apply - (*goals: 1. ‹⟦distinct (p₀ # p₂ # ps); sorted_snd (p₀ # p₂ # ps); ⋀ps. sorted_snd ps = sorted_wrt (λp₀ p₁. snd p₀ ≤ snd p₁) ps⟧ ⟹ distinct (p₂ # ps)› 2. ‹⟦distinct (p₀ # p₂ # ps); sorted_snd (p₀ # p₂ # ps); ⋀ps. sorted_snd ps = sorted_wrt (λp₀ p₁. snd p₀ ≤ snd p₁) ps⟧ ⟹ sorted_snd (p₂ # ps)› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) . have C: "set ?ps = PS⇩L ∪ PS⇩R" using defs (*‹p₁ = find_closest p₀ (dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y))) (p₂ # ps)› ‹PS⇩L = ps⇩L - {p₀}› ‹PS⇩R = ps⇩R - {p₀}›*) "3.prems"(1,4) (*‹distinct (p₀ # p₂ # ps)› ‹set (p₀ # p₂ # ps) = ps⇩L ∪ ps⇩R›*) by auto have D: "∀p ∈ set ?ps. l - Δ < fst p ∧ fst p < l + Δ" using "3.prems"(5) (*‹∀p∈set (p₀ # p₂ # ps). real_of_int l - Δ < real_of_int (fst p) ∧ real_of_int (fst p) < real_of_int l + Δ›*) by simp have E: "∀p ∈ PS⇩L. fst p ≤ l" "∀p ∈ PS⇩R. l ≤ fst p" using defs (*‹p₁ = find_closest p₀ (dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y))) (p₂ # ps)› ‹(PS⇩L::(int × int) set) = (ps⇩L::(int × int) set) - {p₀::int × int}› ‹PS⇩R = ps⇩R - {p₀}›*) "3.prems"(6,7) (*‹∀p∈ps⇩L. fst p ≤ l› ‹∀p∈ps⇩R. l ≤ fst p›*) apply - (*goals: 1. ‹⟦p₁ = find_closest p₀ (dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y))) (p₂ # ps); PS⇩L = ps⇩L - {p₀}; PS⇩R = ps⇩R - {p₀}; ∀p∈ps⇩L. fst p ≤ l; ∀p∈ps⇩R. l ≤ fst p⟧ ⟹ ∀p∈PS⇩L. fst p ≤ l› 2. ‹⟦p₁ = find_closest p₀ (dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y))) (p₂ # ps); PS⇩L = ps⇩L - {p₀}; PS⇩R = ps⇩R - {p₀}; ∀p∈ps⇩L. fst p ≤ l; ∀p∈ps⇩R. l ≤ fst p⟧ ⟹ ∀p∈PS⇩R. l ≤ fst p› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) . have F: "sparse Δ PS⇩L" "sparse Δ PS⇩R" using defs (*‹p₁ = find_closest p₀ (dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y))) (p₂ # ps)› ‹PS⇩L = ps⇩L - {p₀}› ‹PS⇩R = ps⇩R - {p₀}›*) "3.prems"(8,9) (*‹sparse (Δ::real) (ps⇩L::(int × int) set)› ‹sparse Δ ps⇩R›*) sparse_def (*‹sparse (?δ::real) (?ps::(int × int) set) = (∀p₀::int × int∈?ps. ∀p₁::int × int∈?ps. p₀ ≠ p₁ ⟶ ?δ ≤ dist (case p₀ of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) (case p₁ of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)))›*) apply - (*goals: 1. ‹⟦p₁ = find_closest p₀ (dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y))) (p₂ # ps); PS⇩L = ps⇩L - {p₀}; PS⇩R = ps⇩R - {p₀}; sparse Δ ps⇩L; sparse Δ ps⇩R; ⋀δ ps. sparse δ ps = (∀p₀∈ps. ∀p₁∈ps. p₀ ≠ p₁ ⟶ δ ≤ dist (case p₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₁ of (x, y) ⇒ (real_of_int x, real_of_int y)))⟧ ⟹ sparse Δ PS⇩L› 2. ‹⟦p₁ = find_closest p₀ (dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y))) (p₂ # ps); PS⇩L = ps⇩L - {p₀}; PS⇩R = ps⇩R - {p₀}; sparse Δ ps⇩L; sparse Δ ps⇩R; ⋀δ ps. sparse δ ps = (∀p₀∈ps. ∀p₁∈ps. p₀ ≠ p₁ ⟶ δ ≤ dist (case p₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₁ of (x, y) ⇒ (real_of_int x, real_of_int y)))⟧ ⟹ sparse Δ PS⇩R› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) . show "?case" (*goal: ‹t_find_closest_pair (c₀, c₁) (p₀ # p₂ # ps) ≤ 9 * length (p₀ # p₂ # ps) + 1›*) proof (cases "dist c₀ c₁ ≤ dist p₀ p₁") (*goals: 1. ‹dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y)) ≤ dist (case p₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₁ of (x, y) ⇒ (real_of_int x, real_of_int y)) ⟹ t_find_closest_pair (c₀, c₁) (p₀ # p₂ # ps) ≤ 9 * length (p₀ # p₂ # ps) + 1› 2. ‹¬ dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y)) ≤ dist (case p₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₁ of (x, y) ⇒ (real_of_int x, real_of_int y)) ⟹ t_find_closest_pair (c₀, c₁) (p₀ # p₂ # ps) ≤ 9 * length (p₀ # p₂ # ps) + 1›*) case True (*‹dist (case c₀::int × int of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) (case c₁::int × int of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) ≤ dist (case p₀::int × int of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) (case p₁::int × int of (x::int, y::int) ⇒ (real_of_int x, real_of_int y))›*) hence "t_find_closest_pair (c₀, c₁) ?ps ≤ 9 * length ?ps + 1" using "3.hyps"(1) (*‹⟦?x = find_closest p₀ (dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y))) (p₂ # ps); dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y)) ≤ dist (case p₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case ?x of (x, y) ⇒ (real_of_int x, real_of_int y)); distinct (p₂ # ps); sorted_snd (p₂ # ps); ?δ = dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y)); set (p₂ # ps) = ?ps⇩L ∪ ?ps⇩R; ∀p∈set (p₂ # ps). real_of_int l - Δ < real_of_int (fst p) ∧ real_of_int (fst p) < real_of_int l + Δ; ∀p∈?ps⇩L. fst p ≤ l; ∀p∈?ps⇩R. l ≤ fst p; sparse Δ ?ps⇩L; sparse Δ ?ps⇩R; ?δ ≤ Δ⟧ ⟹ t_find_closest_pair (c₀, c₁) (p₂ # ps) ≤ 9 * length (p₂ # ps) + 1›*) "3.prems"(3,10) (*‹δ = dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y))› ‹δ ≤ Δ›*) defs(1) (*‹(p₁::int × int) = find_closest (p₀::int × int) (dist (case c₀::int × int of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) (case c₁::int × int of (x::int, y::int) ⇒ (real_of_int x, real_of_int y))) ((p₂::int × int) # (ps::(int × int) list))›*) B (*‹distinct (p₂ # ps)› ‹sorted_snd (p₂ # ps)›*) C (*‹set ((p₂::int × int) # (ps::(int × int) list)) = (PS⇩L::(int × int) set) ∪ (PS⇩R::(int × int) set)›*) D (*‹∀p∈set (p₂ # ps). real_of_int l - Δ < real_of_int (fst p) ∧ real_of_int (fst p) < real_of_int l + Δ›*) E (*‹∀p::int × int∈PS⇩L::(int × int) set. fst p ≤ (l::int)› ‹∀p∈PS⇩R. l ≤ fst p›*) F (*‹sparse Δ PS⇩L› ‹sparse (Δ::real) (PS⇩R::(int × int) set)›*) by blast moreover have "t_find_closest_pair (c₀, c₁) (p₀ # ?ps) = 1 + t_find_closest p₀ (dist c₀ c₁) ?ps + t_find_closest_pair (c₀, c₁) ?ps" using defs (*‹p₁ = find_closest p₀ (dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y))) (p₂ # ps)› ‹PS⇩L = ps⇩L - {p₀}› ‹(PS⇩R::(int × int) set) = (ps⇩R::(int × int) set) - {p₀::int × int}›*) True (*‹dist (case c₀::int × int of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) (case c₁::int × int of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) ≤ dist (case p₀::int × int of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) (case p₁::int × int of (x::int, y::int) ⇒ (real_of_int x, real_of_int y))›*) by (auto 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))›*)) ultimately show "?thesis" (*goal: ‹t_find_closest_pair (c₀, c₁) (p₀ # p₂ # ps) ≤ 9 * length (p₀ # p₂ # ps) + 1›*) using A (*‹t_find_closest p₀ (dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y))) (p₂ # ps) ≤ 8›*) by auto next (*goal: ‹¬ dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y)) ≤ dist (case p₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₁ of (x, y) ⇒ (real_of_int x, real_of_int y)) ⟹ t_find_closest_pair (c₀, c₁) (p₀ # p₂ # ps) ≤ 9 * length (p₀ # p₂ # ps) + 1›*) case False (*‹¬ dist (case c₀::int × int of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) (case c₁::int × int of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) ≤ dist (case p₀::int × int of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) (case p₁::int × int of (x::int, y::int) ⇒ (real_of_int x, real_of_int y))›*) moreover have "0 ≤ dist p₀ p₁" by auto ultimately have "t_find_closest_pair (p₀, p₁) ?ps ≤ 9 * length ?ps + 1" using "3.hyps"(2) (*‹⟦?x = find_closest p₀ (dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y))) (p₂ # ps); ¬ dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y)) ≤ dist (case p₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case ?x of (x, y) ⇒ (real_of_int x, real_of_int y)); distinct (p₂ # ps); sorted_snd (p₂ # ps); ?δ = dist (case p₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case ?x of (x, y) ⇒ (real_of_int x, real_of_int y)); set (p₂ # ps) = ?ps⇩L ∪ ?ps⇩R; ∀p∈set (p₂ # ps). real_of_int l - Δ < real_of_int (fst p) ∧ real_of_int (fst p) < real_of_int l + Δ; ∀p∈?ps⇩L. fst p ≤ l; ∀p∈?ps⇩R. l ≤ fst p; sparse Δ ?ps⇩L; sparse Δ ?ps⇩R; ?δ ≤ Δ⟧ ⟹ t_find_closest_pair (p₀, ?x) (p₂ # ps) ≤ 9 * length (p₂ # ps) + 1›*) "3.prems"(3,10) (*‹(δ::real) = dist (case c₀::int × int of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) (case c₁::int × int of (x::int, y::int) ⇒ (real_of_int x, real_of_int y))› ‹δ ≤ Δ›*) defs(1) (*‹(p₁::int × int) = find_closest (p₀::int × int) (dist (case c₀::int × int of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) (case c₁::int × int of (x::int, y::int) ⇒ (real_of_int x, real_of_int y))) ((p₂::int × int) # (ps::(int × int) list))›*) B (*‹distinct (p₂ # ps)› ‹sorted_snd (p₂ # ps)›*) C (*‹set (p₂ # ps) = PS⇩L ∪ PS⇩R›*) D (*‹∀p::int × int∈set ((p₂::int × int) # (ps::(int × int) list)). real_of_int (l::int) - (Δ::real) < real_of_int (fst p) ∧ real_of_int (fst p) < real_of_int l + Δ›*) E (*‹∀p∈PS⇩L. fst p ≤ l› ‹∀p∈PS⇩R. l ≤ fst p›*) F (*‹sparse Δ PS⇩L› ‹sparse Δ PS⇩R›*) by auto moreover have "t_find_closest_pair (c₀, c₁) (p₀ # ?ps) = 1 + t_find_closest p₀ (dist c₀ c₁) ?ps + t_find_closest_pair (p₀, p₁) ?ps" using defs (*‹p₁ = find_closest p₀ (dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y))) (p₂ # ps)› ‹(PS⇩L::(int × int) set) = (ps⇩L::(int × int) set) - {p₀::int × int}› ‹PS⇩R = ps⇩R - {p₀}›*) False (*‹¬ dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y)) ≤ dist (case p₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₁ of (x, y) ⇒ (real_of_int x, real_of_int y))›*) by (auto 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))›*)) ultimately show "?thesis" (*goal: ‹t_find_closest_pair (c₀, c₁) (p₀ # p₂ # ps) ≤ 9 * length (p₀ # p₂ # ps) + 1›*) using A (*‹t_find_closest p₀ (dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y))) (p₂ # ps) ≤ 8›*) by simp qed qed (auto) (*solves the remaining goals: 1. ‹⋀c₀ c₁ δ ps⇩L ps⇩R. ⟦distinct []; sorted_snd []; δ = dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y)); set [] = ps⇩L ∪ ps⇩R; ∀p∈set []. real_of_int l - Δ < real_of_int (fst p) ∧ real_of_int (fst p) < real_of_int l + Δ; ∀p∈ps⇩L. fst p ≤ l; ∀p∈ps⇩R. l ≤ fst p; sparse Δ ps⇩L; sparse Δ ps⇩R; δ ≤ Δ⟧ ⟹ t_find_closest_pair (c₀, c₁) [] ≤ 9 * length [] + 1› 2. ‹⋀uw_ c₀ c₁ δ ps⇩L ps⇩R. ⟦distinct [uw_]; sorted_snd [uw_]; δ = dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y)); set [uw_] = ps⇩L ∪ ps⇩R; ∀p∈set [uw_]. real_of_int l - Δ < real_of_int (fst p) ∧ real_of_int (fst p) < real_of_int l + Δ; ∀p∈ps⇩L. fst p ≤ l; ∀p∈ps⇩R. l ≤ fst p; sparse Δ ps⇩L; sparse Δ ps⇩R; δ ≤ Δ⟧ ⟹ t_find_closest_pair (c₀, c₁) [uw_] ≤ 9 * length [uw_] + 1›*) fun t_combine :: "(point * point) ⇒ (point * point) ⇒ int ⇒ point list ⇒ nat" where "t_combine (p₀⇩L, p₁⇩L) (p₀⇩R, p₁⇩R) l ps = 1 + ( let (c₀, c₁) = if dist p₀⇩L p₁⇩L < dist p₀⇩R p₁⇩R then (p₀⇩L, p₁⇩L) else (p₀⇩R, p₁⇩R) in let ps' = filter (λp. dist p (l, snd p) < dist c₀ c₁) ps in time (filter_tm (λp. dist p (l, snd p) < dist c₀ c₁) ps) + t_find_closest_pair (c₀, c₁) ps' )" lemma t_combine_eq_time_combine_tm: "t_combine (p₀⇩L, p₁⇩L) (p₀⇩R, p₁⇩R) l ps = time (combine_tm (p₀⇩L, p₁⇩L) (p₀⇩R, p₁⇩R) l ps)" by (auto simp: combine_tm.simps (*‹combine_tm (?p₀⇩L, ?p₁⇩L) (?p₀⇩R, ?p₁⇩R) ?l ?ps =1 (let (c₀, c₁) = if dist (case ?p₀⇩L of (x, y) ⇒ (real_of_int x, real_of_int y)) (case ?p₁⇩L of (x, y) ⇒ (real_of_int x, real_of_int y)) < dist (case ?p₀⇩R of (x, y) ⇒ (real_of_int x, real_of_int y)) (case ?p₁⇩R of (x, y) ⇒ (real_of_int x, real_of_int y)) then (?p₀⇩L, ?p₁⇩L) else (?p₀⇩R, ?p₁⇩R) in filter_tm (λp. dist (case p of (x, y) ⇒ (real_of_int x, real_of_int y)) (case (?l, snd p) of (x, y) ⇒ (real_of_int x, real_of_int y)) < dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y))) ?ps ⤜ find_closest_pair_tm (c₀, c₁))›*) time_simps (*‹time (?tm ⤜ ?f) = time ?tm + time (?f (Time_Monad.val ?tm))› ‹tick ?v = ??.Time_Monad.tm.TM ?v 1›*) t_find_closest_pair_eq_time_find_closest_pair_tm (*‹t_find_closest_pair (?c₀, ?c₁) ?ps = time (find_closest_pair_tm (?c₀, ?c₁) ?ps)›*) filter_eq_val_filter_tm (*‹Time_Monad.val (filter_tm ?P ?xs) = filter ?P ?xs›*)) lemma t_combine_bound: fixes ps :: "point list" assumes "distinct ps" "sorted_snd ps" "set ps = ps⇩L ∪ ps⇩R" assumes "∀p ∈ ps⇩L. fst p ≤ l" "∀p ∈ ps⇩R. l ≤ fst p" assumes "sparse (dist p₀⇩L p₁⇩L) ps⇩L" "sparse (dist p₀⇩R p₁⇩R) ps⇩R" shows "t_combine (p₀⇩L, p₁⇩L) (p₀⇩R, p₁⇩R) l ps ≤ 10 * length ps + 3" proof (-) (*goal: ‹t_combine (p₀⇩L, p₁⇩L) (p₀⇩R, p₁⇩R) l ps ≤ 10 * length ps + 3›*) obtain c₀ and c₁ where c_def: "(c₀, c₁) = (if dist p₀⇩L p₁⇩L < dist p₀⇩R p₁⇩R then (p₀⇩L, p₁⇩L) else (p₀⇩R, p₁⇩R))" (*goal: ‹(⋀c₀ c₁. (c₀, c₁) = (if dist (case p₀⇩L of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₁⇩L of (x, y) ⇒ (real_of_int x, real_of_int y)) < dist (case p₀⇩R of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₁⇩R of (x, y) ⇒ (real_of_int x, real_of_int y)) then (p₀⇩L, p₁⇩L) else (p₀⇩R, p₁⇩R)) ⟹ thesis) ⟹ thesis›*) by metis let ?P = "(λp. dist p (l, snd p) < dist c₀ c₁)" define ps' where ps'_def: "ps' = filter ?P ps" define ps⇩L' where "ps⇩L'_def": "ps⇩L' = { p ∈ ps⇩L. ?P p }" define ps⇩R' where "ps⇩R'_def": "ps⇩R' = { p ∈ ps⇩R. ?P p }" note defs = c_def (*‹(c₀::int × int, c₁::int × int) = (if dist (case p₀⇩L::int × int of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) (case p₁⇩L::int × int of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) < dist (case p₀⇩R::int × int of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) (case p₁⇩R::int × int of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) then (p₀⇩L, p₁⇩L) else (p₀⇩R, p₁⇩R))›*) ps'_def (*‹ps' = filter (λx. dist (case x of (x, y) ⇒ (real_of_int x, real_of_int y)) (case (l, snd (case x of (x, y) ⇒ (real_of_int x, real_of_int y))) of (x, y) ⇒ (real_of_int x, y)) < dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y))) ps›*) "ps⇩L'_def" (*‹(ps⇩L'::(int × int) set) = {p::int × int ∈ ps⇩L::(int × int) set. dist (case case p of (x::int, y::int) ⇒ (real_of_int x, y) of (x::real, y::int) ⇒ (x, real_of_int y)) (case (l::int, snd (case case p of (x::int, y::int) ⇒ (real_of_int x, y) of (x::real, y::int) ⇒ (x, real_of_int y))) of (x::int, y::real) ⇒ (real_of_int x, y)) < dist (case c₀::int × int of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) (case c₁::int × int of (x::int, y::int) ⇒ (real_of_int x, real_of_int y))}›*) "ps⇩R'_def" (*‹ps⇩R' = {p ∈ ps⇩R. dist (case case p of (x, y) ⇒ (real_of_int x, y) of (x, y) ⇒ (x, real_of_int y)) (case (l, snd (case case p of (x, y) ⇒ (real_of_int x, y) of (x, y) ⇒ (x, real_of_int y))) of (x, y) ⇒ (real_of_int x, y)) < dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y))}›*) have "sparse (dist c₀ c₁) ps⇩L" "sparse (dist c₀ c₁) ps⇩R" using assms(6,7) (*‹sparse (dist (case p₀⇩L::int × int of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) (case p₁⇩L::int × int of (x::int, y::int) ⇒ (real_of_int x, real_of_int y))) (ps⇩L::(int × int) set)› ‹sparse (dist (case p₀⇩R of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₁⇩R of (x, y) ⇒ (real_of_int x, real_of_int y))) ps⇩R›*) sparse_mono (*‹⟦sparse ?Δ ?P; ?δ ≤ ?Δ⟧ ⟹ sparse ?δ ?P›*) c_def (*‹(c₀, c₁) = (if dist (case p₀⇩L of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₁⇩L of (x, y) ⇒ (real_of_int x, real_of_int y)) < dist (case p₀⇩R of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₁⇩R of (x, y) ⇒ (real_of_int x, real_of_int y)) then (p₀⇩L, p₁⇩L) else (p₀⇩R, p₁⇩R))›*) apply - (*goals: 1. ‹⟦sparse (dist (case p₀⇩L of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₁⇩L of (x, y) ⇒ (real_of_int x, real_of_int y))) ps⇩L; sparse (dist (case p₀⇩R of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₁⇩R of (x, y) ⇒ (real_of_int x, real_of_int y))) ps⇩R; ⋀Δ P δ. ⟦sparse Δ P; δ ≤ Δ⟧ ⟹ sparse δ P; (c₀, c₁) = (if dist (case p₀⇩L of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₁⇩L of (x, y) ⇒ (real_of_int x, real_of_int y)) < dist (case p₀⇩R of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₁⇩R of (x, y) ⇒ (real_of_int x, real_of_int y)) then (p₀⇩L, p₁⇩L) else (p₀⇩R, p₁⇩R))⟧ ⟹ sparse (dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y))) ps⇩L› 2. ‹⟦sparse (dist (case p₀⇩L of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₁⇩L of (x, y) ⇒ (real_of_int x, real_of_int y))) ps⇩L; sparse (dist (case p₀⇩R of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₁⇩R of (x, y) ⇒ (real_of_int x, real_of_int y))) ps⇩R; ⋀Δ P δ. ⟦sparse Δ P; δ ≤ Δ⟧ ⟹ sparse δ P; (c₀, c₁) = (if dist (case p₀⇩L of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₁⇩L of (x, y) ⇒ (real_of_int x, real_of_int y)) < dist (case p₀⇩R of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₁⇩R of (x, y) ⇒ (real_of_int x, real_of_int y)) then (p₀⇩L, p₁⇩L) else (p₀⇩R, p₁⇩R))⟧ ⟹ sparse (dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y))) ps⇩R› 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*) . hence "sparse (dist c₀ c₁) ps⇩L'" "sparse (dist c₀ c₁) ps⇩R'" using "ps⇩L'_def" (*‹(ps⇩L'::(int × int) set) = {p::int × int ∈ ps⇩L::(int × int) set. dist (case case p of (x::int, y::int) ⇒ (real_of_int x, y) of (x::real, y::int) ⇒ (x, real_of_int y)) (case (l::int, snd (case case p of (x::int, y::int) ⇒ (real_of_int x, y) of (x::real, y::int) ⇒ (x, real_of_int y))) of (x::int, y::real) ⇒ (real_of_int x, y)) < dist (case c₀::int × int of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) (case c₁::int × int of (x::int, y::int) ⇒ (real_of_int x, real_of_int y))}›*) "ps⇩R'_def" (*‹ps⇩R' = {p ∈ ps⇩R. dist (case case p of (x, y) ⇒ (real_of_int x, y) of (x, y) ⇒ (x, real_of_int y)) (case (l, snd (case case p of (x, y) ⇒ (real_of_int x, y) of (x, y) ⇒ (x, real_of_int y))) of (x, y) ⇒ (real_of_int x, y)) < dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y))}›*) sparse_def (*‹sparse ?δ ?ps = (∀p₀∈?ps. ∀p₁∈?ps. p₀ ≠ p₁ ⟶ ?δ ≤ dist (case p₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₁ of (x, y) ⇒ (real_of_int x, real_of_int y)))›*) apply - (*goals: 1. ‹⟦sparse (dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y))) ps⇩L; sparse (dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y))) ps⇩R; ps⇩L' = {p ∈ ps⇩L. dist (case case p of (x, y) ⇒ (real_of_int x, y) of (x, y) ⇒ (x, real_of_int y)) (case (l, snd (case case p of (x, y) ⇒ (real_of_int x, y) of (x, y) ⇒ (x, real_of_int y))) of (x, y) ⇒ (real_of_int x, y)) < dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y))}; ps⇩R' = {p ∈ ps⇩R. dist (case case p of (x, y) ⇒ (real_of_int x, y) of (x, y) ⇒ (x, real_of_int y)) (case (l, snd (case case p of (x, y) ⇒ (real_of_int x, y) of (x, y) ⇒ (x, real_of_int y))) of (x, y) ⇒ (real_of_int x, y)) < dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y))}; ⋀δ ps. sparse δ ps = (∀p₀∈ps. ∀p₁∈ps. p₀ ≠ p₁ ⟶ δ ≤ dist (case p₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₁ of (x, y) ⇒ (real_of_int x, real_of_int y)))⟧ ⟹ sparse (dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y))) ps⇩L'› 2. ‹⟦sparse (dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y))) ps⇩L; sparse (dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y))) ps⇩R; ps⇩L' = {p ∈ ps⇩L. dist (case case p of (x, y) ⇒ (real_of_int x, y) of (x, y) ⇒ (x, real_of_int y)) (case (l, snd (case case p of (x, y) ⇒ (real_of_int x, y) of (x, y) ⇒ (x, real_of_int y))) of (x, y) ⇒ (real_of_int x, y)) < dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y))}; ps⇩R' = {p ∈ ps⇩R. dist (case case p of (x, y) ⇒ (real_of_int x, y) of (x, y) ⇒ (x, real_of_int y)) (case (l, snd (case case p of (x, y) ⇒ (real_of_int x, y) of (x, y) ⇒ (x, real_of_int y))) of (x, y) ⇒ (real_of_int x, y)) < dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y))}; ⋀δ ps. sparse δ ps = (∀p₀∈ps. ∀p₁∈ps. p₀ ≠ p₁ ⟶ δ ≤ dist (case p₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₁ of (x, y) ⇒ (real_of_int x, real_of_int y)))⟧ ⟹ sparse (dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y))) ps⇩R'› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . moreover have "distinct ps'" using ps'_def (*‹ps' = filter (λx. dist (case x of (x, y) ⇒ (real_of_int x, real_of_int y)) (case (l, snd (case x of (x, y) ⇒ (real_of_int x, real_of_int y))) of (x, y) ⇒ (real_of_int x, y)) < dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y))) ps›*) assms(1) (*‹distinct ps›*) by simp moreover have "sorted_snd ps'" using ps'_def (*‹ps' = filter (λx. dist (case x of (x, y) ⇒ (real_of_int x, real_of_int y)) (case (l, snd (case x of (x, y) ⇒ (real_of_int x, real_of_int y))) of (x, y) ⇒ (real_of_int x, y)) < dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y))) ps›*) assms(2) (*‹sorted_snd (ps::(int × int) list)›*) sorted_snd_def (*‹sorted_snd (?ps::(int × int) list) = sorted_wrt (λ(p₀::int × int) p₁::int × int. snd p₀ ≤ snd p₁) ?ps›*) sorted_wrt_filter (*‹sorted_wrt ?f ?xs ⟹ sorted_wrt ?f (filter ?P ?xs)›*) by blast moreover have "0 ≤ dist c₀ c₁" by simp moreover have "set ps' = ps⇩L' ∪ ps⇩R'" using assms(3) (*‹set ps = ps⇩L ∪ ps⇩R›*) defs(2,3,4) (*‹ps' = filter (λx. dist (case x of (x, y) ⇒ (real_of_int x, real_of_int y)) (case (l, snd (case x of (x, y) ⇒ (real_of_int x, real_of_int y))) of (x, y) ⇒ (real_of_int x, y)) < dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y))) ps› ‹ps⇩L' = {p ∈ ps⇩L. dist (case case p of (x, y) ⇒ (real_of_int x, y) of (x, y) ⇒ (x, real_of_int y)) (case (l, snd (case case p of (x, y) ⇒ (real_of_int x, y) of (x, y) ⇒ (x, real_of_int y))) of (x, y) ⇒ (real_of_int x, y)) < dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y))}› ‹(ps⇩R'::(int × int) set) = {p::int × int ∈ ps⇩R::(int × int) set. dist (case case p of (x::int, y::int) ⇒ (real_of_int x, y) of (x::real, y::int) ⇒ (x, real_of_int y)) (case (l::int, snd (case case p of (x::int, y::int) ⇒ (real_of_int x, y) of (x::real, y::int) ⇒ (x, real_of_int y))) of (x::int, y::real) ⇒ (real_of_int x, y)) < dist (case c₀::int × int of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) (case c₁::int × int of (x::int, y::int) ⇒ (real_of_int x, real_of_int y))}›*) filter_Un (*‹set ?xs = ?A ∪ ?B ⟹ set (filter ?P ?xs) = {x ∈ ?A. ?P x} ∪ {x ∈ ?B. ?P x}›*) by auto moreover have "∀p ∈ set ps'. l - dist c₀ c₁ < fst p ∧ fst p < l + dist c₀ c₁" using ps'_def (*‹(ps'::(int × int) list) = filter (λx::int × int. dist (case x of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) (case (l::int, snd (case x of (x::int, y::int) ⇒ (real_of_int x, real_of_int y))) of (x::int, y::real) ⇒ (real_of_int x, y)) < dist (case c₀::int × int of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) (case c₁::int × int of (x::int, y::int) ⇒ (real_of_int x, real_of_int y))) (ps::(int × int) list)›*) dist_transform (*‹(dist (case ?p of (x, y) ⇒ (real_of_int x, real_of_int y)) (case (?l, snd ?p) of (x, y) ⇒ (real_of_int x, real_of_int y)) < ?δ) = (real_of_int ?l - ?δ < real_of_int (fst ?p) ∧ real_of_int (fst ?p) < real_of_int ?l + ?δ)›*) by force moreover have "∀p ∈ ps⇩L'. fst p ≤ l" "∀p ∈ ps⇩R'. l ≤ fst p" using assms(4,5) (*‹∀p∈ps⇩L. fst p ≤ l› ‹∀p∈ps⇩R. l ≤ fst p›*) "ps⇩L'_def" (*‹ps⇩L' = {p ∈ ps⇩L. dist (case case p of (x, y) ⇒ (real_of_int x, y) of (x, y) ⇒ (x, real_of_int y)) (case (l, snd (case case p of (x, y) ⇒ (real_of_int x, y) of (x, y) ⇒ (x, real_of_int y))) of (x, y) ⇒ (real_of_int x, y)) < dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y))}›*) "ps⇩R'_def" (*‹ps⇩R' = {p ∈ ps⇩R. dist (case case p of (x, y) ⇒ (real_of_int x, y) of (x, y) ⇒ (x, real_of_int y)) (case (l, snd (case case p of (x, y) ⇒ (real_of_int x, y) of (x, y) ⇒ (x, real_of_int y))) of (x, y) ⇒ (real_of_int x, y)) < dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y))}›*) apply - (*goals: 1. ‹⟦∀p∈ps⇩L. fst p ≤ l; ∀p∈ps⇩R. l ≤ fst p; ps⇩L' = {p ∈ ps⇩L. dist (case case p of (x, y) ⇒ (real_of_int x, y) of (x, y) ⇒ (x, real_of_int y)) (case (l, snd (case case p of (x, y) ⇒ (real_of_int x, y) of (x, y) ⇒ (x, real_of_int y))) of (x, y) ⇒ (real_of_int x, y)) < dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y))}; ps⇩R' = {p ∈ ps⇩R. dist (case case p of (x, y) ⇒ (real_of_int x, y) of (x, y) ⇒ (x, real_of_int y)) (case (l, snd (case case p of (x, y) ⇒ (real_of_int x, y) of (x, y) ⇒ (x, real_of_int y))) of (x, y) ⇒ (real_of_int x, y)) < dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y))}⟧ ⟹ ∀p∈ps⇩L'. fst p ≤ l› 2. ‹⟦∀p∈ps⇩L. fst p ≤ l; ∀p∈ps⇩R. l ≤ fst p; ps⇩L' = {p ∈ ps⇩L. dist (case case p of (x, y) ⇒ (real_of_int x, y) of (x, y) ⇒ (x, real_of_int y)) (case (l, snd (case case p of (x, y) ⇒ (real_of_int x, y) of (x, y) ⇒ (x, real_of_int y))) of (x, y) ⇒ (real_of_int x, y)) < dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y))}; ps⇩R' = {p ∈ ps⇩R. dist (case case p of (x, y) ⇒ (real_of_int x, y) of (x, y) ⇒ (x, real_of_int y)) (case (l, snd (case case p of (x, y) ⇒ (real_of_int x, y) of (x, y) ⇒ (x, real_of_int y))) of (x, y) ⇒ (real_of_int x, y)) < dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y))}⟧ ⟹ ∀p∈ps⇩R'. l ≤ fst p› discuss goal 1*) apply blast (*discuss goal 2*) apply blast (*proven 2 subgoals*) . ultimately have "t_find_closest_pair (c₀, c₁) ps' ≤ 9 * length ps' + 1" using t_find_closest_pair_bound (*‹⟦distinct ?ps; sorted_snd ?ps; ?δ = dist (case ?c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case ?c₁ of (x, y) ⇒ (real_of_int x, real_of_int y)); set ?ps = ?ps⇩L ∪ ?ps⇩R; ∀p∈set ?ps. real_of_int ?l - ?Δ < real_of_int (fst p) ∧ real_of_int (fst p) < real_of_int ?l + ?Δ; ∀p∈?ps⇩L. fst p ≤ ?l; ∀p∈?ps⇩R. ?l ≤ fst p; sparse ?Δ ?ps⇩L; sparse ?Δ ?ps⇩R; ?δ ≤ ?Δ⟧ ⟹ t_find_closest_pair (?c₀, ?c₁) ?ps ≤ 9 * length ?ps + 1›*) by blast moreover have "length ps' ≤ length ps" using ps'_def (*‹ps' = filter (λx. dist (case x of (x, y) ⇒ (real_of_int x, real_of_int y)) (case (l, snd (case x of (x, y) ⇒ (real_of_int x, real_of_int y))) of (x, y) ⇒ (real_of_int x, y)) < dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y))) ps›*) by simp ultimately have "*": "t_find_closest_pair (c₀, c₁) ps' ≤ 9 * length ps + 1" by simp have "t_combine (p₀⇩L, p₁⇩L) (p₀⇩R, p₁⇩R) l ps = 1 + time (filter_tm ?P ps) + t_find_closest_pair (c₀, c₁) ps'" using defs (*‹(c₀, c₁) = (if dist (case p₀⇩L of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₁⇩L of (x, y) ⇒ (real_of_int x, real_of_int y)) < dist (case p₀⇩R of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₁⇩R of (x, y) ⇒ (real_of_int x, real_of_int y)) then (p₀⇩L, p₁⇩L) else (p₀⇩R, p₁⇩R))› ‹ps' = filter (λx. dist (case x of (x, y) ⇒ (real_of_int x, real_of_int y)) (case (l, snd (case x of (x, y) ⇒ (real_of_int x, real_of_int y))) of (x, y) ⇒ (real_of_int x, y)) < dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y))) ps› ‹ps⇩L' = {p ∈ ps⇩L. dist (case case p of (x, y) ⇒ (real_of_int x, y) of (x, y) ⇒ (x, real_of_int y)) (case (l, snd (case case p of (x, y) ⇒ (real_of_int x, y) of (x, y) ⇒ (x, real_of_int y))) of (x, y) ⇒ (real_of_int x, y)) < dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y))}› ‹ps⇩R' = {p ∈ ps⇩R. dist (case case p of (x, y) ⇒ (real_of_int x, y) of (x, y) ⇒ (x, real_of_int y)) (case (l, snd (case case p of (x, y) ⇒ (real_of_int x, y) of (x, y) ⇒ (x, real_of_int y))) of (x, y) ⇒ (real_of_int x, y)) < dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y))}›*) by (auto 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))›*)) also (*calculation: ‹t_combine (p₀⇩L, p₁⇩L) (p₀⇩R, p₁⇩R) l ps = 1 + time (filter_tm (λx. dist (case x of (x, y) ⇒ (real_of_int x, real_of_int y)) (case (l, snd (case x of (x, y) ⇒ (real_of_int x, real_of_int y))) of (x, y) ⇒ (real_of_int x, y)) < dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y))) ps) + t_find_closest_pair (c₀, c₁) ps'›*) have "... = 2 + length ps + t_find_closest_pair (c₀, c₁) ps'" using time_filter_tm (*‹time (filter_tm ?P ?xs) = length ?xs + 1›*) by auto finally (*calculation: ‹t_combine (p₀⇩L::int × int, p₁⇩L::int × int) (p₀⇩R::int × int, p₁⇩R::int × int) (l::int) (ps::(int × int) list) = (2::nat) + length ps + t_find_closest_pair (c₀::int × int, c₁::int × int) (ps'::(int × int) list)›*) show "?thesis" (*goal: ‹t_combine (p₀⇩L, p₁⇩L) (p₀⇩R, p₁⇩R) l ps ≤ 10 * length ps + 3›*) using "*" (*‹t_find_closest_pair (c₀, c₁) ps' ≤ 9 * length ps + 1›*) by simp qed declare t_combine.simps [simp del] subsubsection "Divide and Conquer Algorithm" lemma time_closest_pair_rec_tm_simps_1: assumes "length xs ≤ 3" shows "time (closest_pair_rec_tm xs) = 1 + time (length_tm xs) + time (mergesort_tm snd xs) + time (closest_pair_bf_tm xs)" using assms (*‹length (xs::(int × int) list) ≤ (3::nat)›*) by (auto simp: time_simps (*‹time (?tm ⤜ ?f) = time ?tm + time (?f (Time_Monad.val ?tm))› ‹tick ?v = ??.Time_Monad.tm.TM ?v 1›*) length_eq_val_length_tm (*‹Time_Monad.val (length_tm ?xs) = length ?xs›*)) lemma time_closest_pair_rec_tm_simps_2: assumes "¬ (length xs ≤ 3)" shows "time (closest_pair_rec_tm xs) = 1 + ( let (xs⇩L, xs⇩R) = val (split_at_tm (length xs div 2) xs) in let (ys⇩L, p⇩L) = val (closest_pair_rec_tm xs⇩L) in let (ys⇩R, p⇩R) = val (closest_pair_rec_tm xs⇩R) in let ys = val (merge_tm (λp. snd p) ys⇩L ys⇩R) in time (length_tm xs) + time (split_at_tm (length xs div 2) xs) + time (closest_pair_rec_tm xs⇩L) + time (closest_pair_rec_tm xs⇩R) + time (merge_tm (λp. snd p) ys⇩L ys⇩R) + t_combine p⇩L p⇩R (fst (hd xs⇩R)) ys )" using assms (*‹¬ length (xs::(int × int) list) ≤ (3::nat)›*) apply (subst closest_pair_rec_tm.simps (*‹closest_pair_rec_tm ?xs =1 length_tm ?xs ⤜ (λn. if n ≤ 3 then mergesort_tm snd ?xs ⤜ (λys. closest_pair_bf_tm ?xs ⤜ (λp. return (ys, p))) else split_at_tm (n div 2) ?xs ⤜ (λ(xs⇩L, xs⇩R). closest_pair_rec_tm xs⇩L ⤜ (λ(ys⇩L, p₀⇩L, p₁⇩L). closest_pair_rec_tm xs⇩R ⤜ (λ(ys⇩R, p₀⇩R, p₁⇩R). merge_tm snd ys⇩L ys⇩R ⤜ (λys. combine_tm (p₀⇩L, p₁⇩L) (p₀⇩R, p₁⇩R) (fst (hd xs⇩R)) ys ⤜ (λ(p₀, p₁). return (ys, p₀, p₁)))))))›*)) (*goal: ‹time (closest_pair_rec_tm xs) = 1 + (let (xs⇩L, xs⇩R) = Time_Monad.val (split_at_tm (length xs div 2) xs); (ys⇩L, p⇩L) = Time_Monad.val (closest_pair_rec_tm xs⇩L); (ys⇩R, p⇩R) = Time_Monad.val (closest_pair_rec_tm xs⇩R); ys = Time_Monad.val (merge_tm snd ys⇩L ys⇩R) in time (length_tm xs) + time (split_at_tm (length xs div 2) xs) + time (closest_pair_rec_tm xs⇩L) + time (closest_pair_rec_tm xs⇩R) + time (merge_tm snd ys⇩L ys⇩R) + t_combine p⇩L p⇩R (fst (hd xs⇩R)) ys)›*) by (auto simp del: closest_pair_rec_tm.simps (*‹closest_pair_rec_tm ?xs =1 length_tm ?xs ⤜ (λn. if n ≤ 3 then mergesort_tm snd ?xs ⤜ (λys. closest_pair_bf_tm ?xs ⤜ (λp. return (ys, p))) else split_at_tm (n div 2) ?xs ⤜ (λ(xs⇩L, xs⇩R). closest_pair_rec_tm xs⇩L ⤜ (λ(ys⇩L, p₀⇩L, p₁⇩L). closest_pair_rec_tm xs⇩R ⤜ (λ(ys⇩R, p₀⇩R, p₁⇩R). merge_tm snd ys⇩L ys⇩R ⤜ (λys. combine_tm (p₀⇩L, p₁⇩L) (p₀⇩R, p₁⇩R) (fst (hd xs⇩R)) ys ⤜ (λ(p₀, p₁). return (ys, p₀, p₁)))))))›*) simp add: time_simps (*‹time (?tm ⤜ ?f) = time ?tm + time (?f (Time_Monad.val ?tm))› ‹tick ?v = ??.Time_Monad.tm.TM ?v 1›*) length_eq_val_length_tm (*‹Time_Monad.val (length_tm ?xs) = length ?xs›*) t_combine_eq_time_combine_tm (*‹t_combine (?p₀⇩L, ?p₁⇩L) (?p₀⇩R, ?p₁⇩R) ?l ?ps = time (combine_tm (?p₀⇩L, ?p₁⇩L) (?p₀⇩R, ?p₁⇩R) ?l ?ps)›*) split: prod.split (*‹?P (case ?prod of (x, xa) ⇒ ?f x xa) = (∀x1 x2. ?prod = (x1, x2) ⟶ ?P (?f x1 x2))›*)) function closest_pair_recurrence :: "nat ⇒ real" where "n ≤ 3 ⟹ closest_pair_recurrence n = 3 + n + mergesort_recurrence n + n * n" | "3 < n ⟹ closest_pair_recurrence n = 7 + 13 * n + closest_pair_recurrence (nat ⌊real n / 2⌋) + closest_pair_recurrence (nat ⌈real n / 2⌉)" by force simp_all termination by akra_bazzi_termination simp_all lemma closest_pair_recurrence_nonneg[simp]: "0 ≤ closest_pair_recurrence n" apply (induction n rule: closest_pair_recurrence.induct (*‹⟦⋀n. n ≤ 3 ⟹ ?P n; ⋀n. ⟦3 < n; ?P (nat ⌊real n / 2⌋); ?P (nat ⌈real n / 2⌉)⟧ ⟹ ?P n⟧ ⟹ ?P ?a0.0›*)) (*goals: 1. ‹⋀n. n ≤ 3 ⟹ 0 ≤ closest_pair_recurrence n› 2. ‹⋀n. ⟦3 < n; 0 ≤ closest_pair_recurrence (nat ⌊real n / 2⌋); 0 ≤ closest_pair_recurrence (nat ⌈real n / 2⌉)⟧ ⟹ 0 ≤ closest_pair_recurrence n› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . lemma time_closest_pair_rec_conv_closest_pair_recurrence: assumes "distinct ps" "sorted_fst ps" shows "time (closest_pair_rec_tm ps) ≤ closest_pair_recurrence (length ps)" using assms (*‹distinct (ps::(int × int) list)› ‹sorted_fst ps›*) proof (induction ps 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 ⟶ distinct ys ⟶ sorted_fst ys ⟶ real (time (closest_pair_rec_tm ys)) ≤ closest_pair_recurrence (length ys); distinct xs; sorted_fst xs⟧ ⟹ real (time (closest_pair_rec_tm xs)) ≤ closest_pair_recurrence (length xs)›*) case (1 ps) (*‹∀ys. length ys < length ps ⟶ distinct ys ⟶ sorted_fst ys ⟶ real (time (closest_pair_rec_tm ys)) ≤ closest_pair_recurrence (length ys)› ‹distinct ps› ‹sorted_fst ps›*) let ?n = "length ps" show "?case" (*goal: ‹real (time (closest_pair_rec_tm (ps::(int × int) list))) ≤ closest_pair_recurrence (length ps)›*) proof (cases "?n ≤ 3") (*goals: 1. ‹length ps ≤ 3 ⟹ real (time (closest_pair_rec_tm ps)) ≤ closest_pair_recurrence (length ps)› 2. ‹¬ length ps ≤ 3 ⟹ real (time (closest_pair_rec_tm ps)) ≤ closest_pair_recurrence (length ps)›*) case True (*‹length ps ≤ 3›*) hence "time (closest_pair_rec_tm ps) = 1 + time (length_tm ps) + time (mergesort_tm snd ps) + time (closest_pair_bf_tm ps)" using time_closest_pair_rec_tm_simps_1 (*‹length (?xs::(int × int) list) ≤ (3::nat) ⟹ time (closest_pair_rec_tm ?xs) = (1::nat) + time (length_tm ?xs) + time (mergesort_tm snd ?xs) + time (closest_pair_bf_tm ?xs)›*) by simp moreover have "closest_pair_recurrence ?n = 3 + ?n + mergesort_recurrence ?n + ?n * ?n" using True (*‹length ps ≤ 3›*) by simp moreover have "time (length_tm ps) ≤ 1 + ?n" "time (mergesort_tm snd ps) ≤ mergesort_recurrence ?n" "time (closest_pair_bf_tm ps) ≤ 1 + ?n * ?n" using time_length_tm[of ps] (*‹time (length_tm ps) = length ps + 1›*) time_mergesort_conv_mergesort_recurrence[of snd ps] (*‹real (time (mergesort_tm snd ps)) ≤ mergesort_recurrence (length ps)›*) time_closest_pair_bf_tm[of ps] (*‹time (closest_pair_bf_tm ps) ≤ length ps * length ps + 1›*) apply - (*goals: 1. ‹⟦time (length_tm (ps::(int × int) list)) = length ps + (1::nat); real (time (mergesort_tm snd ps)) ≤ mergesort_recurrence (length ps); time (closest_pair_bf_tm ps) ≤ length ps * length ps + (1::nat)⟧ ⟹ time (length_tm ps) ≤ (1::nat) + length ps› 2. ‹⟦time (length_tm (ps::(int × int) list)) = length ps + (1::nat); real (time (mergesort_tm snd ps)) ≤ mergesort_recurrence (length ps); time (closest_pair_bf_tm ps) ≤ length ps * length ps + (1::nat)⟧ ⟹ real (time (mergesort_tm snd ps)) ≤ mergesort_recurrence (length ps)› 3. ‹⟦time (length_tm (ps::(int × int) list)) = length ps + (1::nat); real (time (mergesort_tm snd ps)) ≤ mergesort_recurrence (length ps); time (closest_pair_bf_tm ps) ≤ length ps * length ps + (1::nat)⟧ ⟹ time (closest_pair_bf_tm ps) ≤ (1::nat) + length ps * length ps› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*proven 3 subgoals*) . ultimately show "?thesis" (*goal: ‹real (time (closest_pair_rec_tm ps)) ≤ closest_pair_recurrence (length ps)›*) by linarith next (*goal: ‹¬ length ps ≤ 3 ⟹ real (time (closest_pair_rec_tm ps)) ≤ closest_pair_recurrence (length ps)›*) case False (*‹¬ length ps ≤ 3›*) obtain XS⇩L and XS⇩R where XS_def: "(XS⇩L, XS⇩R) = val (split_at_tm (?n div 2) ps)" (*goal: ‹(⋀XS⇩L XS⇩R. (XS⇩L, XS⇩R) = Time_Monad.val (split_at_tm (length ps div 2) ps) ⟹ thesis) ⟹ thesis›*) using prod.collapse (*‹(fst ?prod, snd ?prod) = ?prod›*) by blast obtain YS⇩L and C₀⇩L and C₁⇩L where "CP⇩L_def": "(YS⇩L, C₀⇩L, C₁⇩L) = val (closest_pair_rec_tm XS⇩L)" (*goal: ‹(⋀YS⇩L C₀⇩L C₁⇩L. (YS⇩L, C₀⇩L, C₁⇩L) = Time_Monad.val (closest_pair_rec_tm XS⇩L) ⟹ thesis) ⟹ thesis›*) using prod.collapse (*‹(fst (?prod::?'a × ?'b), snd ?prod) = ?prod›*) by metis obtain YS⇩R and C₀⇩R and C₁⇩R where "CP⇩R_def": "(YS⇩R, C₀⇩R, C₁⇩R) = val (closest_pair_rec_tm XS⇩R)" (*goal: ‹(⋀YS⇩R C₀⇩R C₁⇩R. (YS⇩R, C₀⇩R, C₁⇩R) = Time_Monad.val (closest_pair_rec_tm XS⇩R) ⟹ thesis) ⟹ thesis›*) using prod.collapse (*‹(fst ?prod, snd ?prod) = ?prod›*) by metis define YS where "YS = val (merge_tm (λp. snd p) YS⇩L YS⇩R)" obtain C₀ and C₁ where "C₀₁_def": "(C₀, C₁) = val (combine_tm (C₀⇩L, C₁⇩L) (C₀⇩R, C₁⇩R) (fst (hd XS⇩R)) YS)" (*goal: ‹(⋀(C₀::int × int) C₁::int × int. (C₀, C₁) = Time_Monad.val (combine_tm (C₀⇩L::int × int, C₁⇩L::int × int) (C₀⇩R::int × int, C₁⇩R::int × int) (fst (hd (XS⇩R::(int × int) list))) (YS::(int × int) list)) ⟹ thesis::bool) ⟹ thesis›*) using prod.collapse (*‹(fst ?prod, snd ?prod) = ?prod›*) by metis note defs = XS_def (*‹(XS⇩L, XS⇩R) = Time_Monad.val (split_at_tm (length ps div 2) ps)›*) "CP⇩L_def" (*‹(YS⇩L, C₀⇩L, C₁⇩L) = Time_Monad.val (closest_pair_rec_tm XS⇩L)›*) "CP⇩R_def" (*‹(YS⇩R, C₀⇩R, C₁⇩R) = Time_Monad.val (closest_pair_rec_tm XS⇩R)›*) YS_def (*‹YS = Time_Monad.val (merge_tm snd YS⇩L YS⇩R)›*) "C₀₁_def" (*‹(C₀::int × int, C₁::int × int) = Time_Monad.val (combine_tm (C₀⇩L::int × int, C₁⇩L::int × int) (C₀⇩R::int × int, C₁⇩R::int × int) (fst (hd (XS⇩R::(int × int) list))) (YS::(int × int) list))›*) have XSLR: "XS⇩L = take (?n div 2) ps" "XS⇩R = drop (?n div 2) ps" using defs (*‹(XS⇩L, XS⇩R) = Time_Monad.val (split_at_tm (length ps div 2) ps)› ‹(YS⇩L::(int × int) list, C₀⇩L::int × int, C₁⇩L::int × int) = Time_Monad.val (closest_pair_rec_tm (XS⇩L::(int × int) list))› ‹(YS⇩R, C₀⇩R, C₁⇩R) = Time_Monad.val (closest_pair_rec_tm XS⇩R)› ‹(YS::(int × int) list) = Time_Monad.val (merge_tm snd (YS⇩L::(int × int) list) (YS⇩R::(int × int) list))› ‹(C₀, C₁) = Time_Monad.val (combine_tm (C₀⇩L, C₁⇩L) (C₀⇩R, C₁⇩R) (fst (hd XS⇩R)) YS)›*) apply - (*goals: 1. ‹⟦(XS⇩L, XS⇩R) = Time_Monad.val (split_at_tm (length ps div 2) ps); (YS⇩L, C₀⇩L, C₁⇩L) = Time_Monad.val (closest_pair_rec_tm XS⇩L); (YS⇩R, C₀⇩R, C₁⇩R) = Time_Monad.val (closest_pair_rec_tm XS⇩R); YS = Time_Monad.val (merge_tm snd YS⇩L YS⇩R); (C₀, C₁) = Time_Monad.val (combine_tm (C₀⇩L, C₁⇩L) (C₀⇩R, C₁⇩R) (fst (hd XS⇩R)) YS)⟧ ⟹ XS⇩L = take (length ps div 2) ps› 2. ‹⟦(XS⇩L, XS⇩R) = Time_Monad.val (split_at_tm (length ps div 2) ps); (YS⇩L, C₀⇩L, C₁⇩L) = Time_Monad.val (closest_pair_rec_tm XS⇩L); (YS⇩R, C₀⇩R, C₁⇩R) = Time_Monad.val (closest_pair_rec_tm XS⇩R); YS = Time_Monad.val (merge_tm snd YS⇩L YS⇩R); (C₀, C₁) = Time_Monad.val (combine_tm (C₀⇩L, C₁⇩L) (C₀⇩R, C₁⇩R) (fst (hd XS⇩R)) YS)⟧ ⟹ XS⇩R = drop (length ps div 2) ps› discuss goal 1*) apply ((auto simp: split_at_take_drop_conv (*‹split_at (?n::nat) (?xs::?'a::type list) = (take ?n ?xs, drop ?n ?xs)›*) split_at_eq_val_split_at_tm (*‹Time_Monad.val (split_at_tm (?n::nat) (?xs::?'a::type list)) = split_at ?n ?xs›*))[1]) (*discuss goal 2*) apply ((auto simp: split_at_take_drop_conv (*‹split_at ?n ?xs = (take ?n ?xs, drop ?n ?xs)›*) split_at_eq_val_split_at_tm (*‹Time_Monad.val (split_at_tm ?n ?xs) = split_at ?n ?xs›*))[1]) (*proven 2 subgoals*) . hence "length XS⇩L = ?n div 2" "length XS⇩R = ?n - ?n div 2" apply - (*goals: 1. ‹⟦XS⇩L = take (length ps div 2) ps; XS⇩R = drop (length ps div 2) ps⟧ ⟹ length XS⇩L = length ps div 2› 2. ‹⟦XS⇩L = take (length ps div 2) ps; XS⇩R = drop (length ps div 2) ps⟧ ⟹ length XS⇩R = length ps - length ps div 2› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) . hence "*": "(nat ⌊real ?n / 2⌋) = length XS⇩L" "(nat ⌈real ?n / 2⌉) = length XS⇩R" apply - (*goals: 1. ‹⟦length XS⇩L = length ps div 2; length XS⇩R = length ps - length ps div 2⟧ ⟹ nat ⌊real (length ps) / 2⌋ = length XS⇩L› 2. ‹⟦length XS⇩L = length ps div 2; length XS⇩R = length ps - length ps div 2⟧ ⟹ nat ⌈real (length ps) / 2⌉ = length XS⇩R› discuss goal 1*) apply linarith (*discuss goal 2*) apply linarith (*proven 2 subgoals*) . have "length XS⇩L = length YS⇩L" "length XS⇩R = length YS⇩R" using defs (*‹(XS⇩L, XS⇩R) = Time_Monad.val (split_at_tm (length ps div 2) ps)› ‹(YS⇩L::(int × int) list, C₀⇩L::int × int, C₁⇩L::int × int) = Time_Monad.val (closest_pair_rec_tm (XS⇩L::(int × int) list))› ‹(YS⇩R, C₀⇩R, C₁⇩R) = Time_Monad.val (closest_pair_rec_tm XS⇩R)› ‹YS = Time_Monad.val (merge_tm snd YS⇩L YS⇩R)› ‹(C₀, C₁) = Time_Monad.val (combine_tm (C₀⇩L, C₁⇩L) (C₀⇩R, C₁⇩R) (fst (hd XS⇩R)) YS)›*) closest_pair_rec_set_length_sorted_snd (*‹(?ys::(int × int) list, ?p::(int × int) × int × int) = closest_pair_rec (?xs::(int × int) list) ⟹ set ?ys = set ?xs ∧ length ?ys = length ?xs ∧ sorted_snd ?ys›*) closest_pair_rec_eq_val_closest_pair_rec_tm (*‹Time_Monad.val (closest_pair_rec_tm ?xs) = closest_pair_rec ?xs›*) apply - (*goals: 1. ‹⟦(XS⇩L, XS⇩R) = Time_Monad.val (split_at_tm (length ps div 2) ps); (YS⇩L, C₀⇩L, C₁⇩L) = Time_Monad.val (closest_pair_rec_tm XS⇩L); (YS⇩R, C₀⇩R, C₁⇩R) = Time_Monad.val (closest_pair_rec_tm XS⇩R); YS = Time_Monad.val (merge_tm snd YS⇩L YS⇩R); (C₀, C₁) = Time_Monad.val (combine_tm (C₀⇩L, C₁⇩L) (C₀⇩R, C₁⇩R) (fst (hd XS⇩R)) YS); ⋀ys p xs. (ys, p) = closest_pair_rec xs ⟹ set ys = set xs ∧ length ys = length xs ∧ sorted_snd ys; ⋀xs. Time_Monad.val (closest_pair_rec_tm xs) = closest_pair_rec xs⟧ ⟹ length XS⇩L = length YS⇩L› 2. ‹⟦(XS⇩L, XS⇩R) = Time_Monad.val (split_at_tm (length ps div 2) ps); (YS⇩L, C₀⇩L, C₁⇩L) = Time_Monad.val (closest_pair_rec_tm XS⇩L); (YS⇩R, C₀⇩R, C₁⇩R) = Time_Monad.val (closest_pair_rec_tm XS⇩R); YS = Time_Monad.val (merge_tm snd YS⇩L YS⇩R); (C₀, C₁) = Time_Monad.val (combine_tm (C₀⇩L, C₁⇩L) (C₀⇩R, C₁⇩R) (fst (hd XS⇩R)) YS); ⋀ys p xs. (ys, p) = closest_pair_rec xs ⟹ set ys = set xs ∧ length ys = length xs ∧ sorted_snd ys; ⋀xs. Time_Monad.val (closest_pair_rec_tm xs) = closest_pair_rec xs⟧ ⟹ length XS⇩R = length YS⇩R› discuss goal 1*) apply metis (*discuss goal 2*) apply metis (*proven 2 subgoals*) . hence L: "?n = length YS⇩L + length YS⇩R" using defs (*‹(XS⇩L, XS⇩R) = Time_Monad.val (split_at_tm (length ps div 2) ps)› ‹(YS⇩L, C₀⇩L, C₁⇩L) = Time_Monad.val (closest_pair_rec_tm XS⇩L)› ‹(YS⇩R, C₀⇩R, C₁⇩R) = Time_Monad.val (closest_pair_rec_tm XS⇩R)› ‹YS = Time_Monad.val (merge_tm snd YS⇩L YS⇩R)› ‹(C₀, C₁) = Time_Monad.val (combine_tm (C₀⇩L, C₁⇩L) (C₀⇩R, C₁⇩R) (fst (hd XS⇩R)) YS)›*) XSLR (*‹XS⇩L = take (length ps div 2) ps› ‹XS⇩R = drop (length ps div 2) ps›*) by fastforce have "1 < length XS⇩L" "length XS⇩L < length ps" using False (*‹¬ length ps ≤ 3›*) XSLR (*‹XS⇩L = take (length ps div 2) ps› ‹(XS⇩R::(int × int) list) = drop (length (ps::(int × int) list) div (2::nat)) ps›*) apply - (*goals: 1. ‹⟦¬ length ps ≤ 3; XS⇩L = take (length ps div 2) ps; XS⇩R = drop (length ps div 2) ps⟧ ⟹ 1 < length XS⇩L› 2. ‹⟦¬ length ps ≤ 3; XS⇩L = take (length ps div 2) ps; XS⇩R = drop (length ps div 2) ps⟧ ⟹ length XS⇩L < length ps› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) . moreover have "distinct XS⇩L" "sorted_fst XS⇩L" using XSLR (*‹XS⇩L = take (length ps div 2) ps› ‹XS⇩R = drop (length ps div 2) ps›*) "1.prems"(1,2) (*‹distinct ps› ‹sorted_fst ps›*) sorted_fst_def (*‹sorted_fst (?ps::(int × int) list) = sorted_wrt (λ(p₀::int × int) p₁::int × int. fst p₀ ≤ fst p₁) ?ps›*) sorted_wrt_take (*‹sorted_wrt ?f ?xs ⟹ sorted_wrt ?f (take ?n ?xs)›*) apply - (*goals: 1. ‹⟦XS⇩L = take (length ps div 2) ps; XS⇩R = drop (length ps div 2) ps; distinct ps; sorted_fst ps; ⋀ps. sorted_fst ps = sorted_wrt (λp₀ p₁. fst p₀ ≤ fst p₁) ps; ⋀f xs n. sorted_wrt f xs ⟹ sorted_wrt f (take n xs)⟧ ⟹ distinct XS⇩L› 2. ‹⟦XS⇩L = take (length ps div 2) ps; XS⇩R = drop (length ps div 2) ps; distinct ps; sorted_fst ps; ⋀ps. sorted_fst ps = sorted_wrt (λp₀ p₁. fst p₀ ≤ fst p₁) ps; ⋀f xs n. sorted_wrt f xs ⟹ sorted_wrt f (take n xs)⟧ ⟹ sorted_fst XS⇩L› discuss goal 1*) apply simp (*discuss goal 2*) by simp (*proven 2 subgoals*) ultimately have "time (closest_pair_rec_tm XS⇩L) ≤ closest_pair_recurrence (length XS⇩L)" using "1.IH" (*‹∀ys. length ys < length ps ⟶ distinct ys ⟶ sorted_fst ys ⟶ real (time (closest_pair_rec_tm ys)) ≤ closest_pair_recurrence (length ys)›*) by simp hence IHL: "time (closest_pair_rec_tm XS⇩L) ≤ closest_pair_recurrence (nat ⌊real ?n / 2⌋)" using "*" (*‹nat ⌊real (length ps) / 2⌋ = length XS⇩L› ‹nat ⌈real (length (ps::(int × int) list)) / (2::real)⌉ = length (XS⇩R::(int × int) list)›*) by simp have "1 < length XS⇩R" "length XS⇩R < length ps" using False (*‹¬ length (ps::(int × int) list) ≤ (3::nat)›*) XSLR (*‹XS⇩L = take (length ps div 2) ps› ‹XS⇩R = drop (length ps div 2) ps›*) apply - (*goals: 1. ‹⟦¬ length ps ≤ 3; XS⇩L = take (length ps div 2) ps; XS⇩R = drop (length ps div 2) ps⟧ ⟹ 1 < length XS⇩R› 2. ‹⟦¬ length ps ≤ 3; XS⇩L = take (length ps div 2) ps; XS⇩R = drop (length ps div 2) ps⟧ ⟹ length XS⇩R < length ps› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) . moreover have "distinct XS⇩R" "sorted_fst XS⇩R" using XSLR (*‹XS⇩L = take (length ps div 2) ps› ‹XS⇩R = drop (length ps div 2) ps›*) "1.prems"(1,2) (*‹distinct ps› ‹sorted_fst ps›*) sorted_fst_def (*‹sorted_fst ?ps = sorted_wrt (λp₀ p₁. fst p₀ ≤ fst p₁) ?ps›*) sorted_wrt_drop (*‹sorted_wrt (?f::?'a ⇒ ?'a ⇒ bool) (?xs::?'a list) ⟹ sorted_wrt ?f (drop (?n::nat) ?xs)›*) apply - (*goals: 1. ‹⟦(XS⇩L::(int × int) list) = take (length (ps::(int × int) list) div (2::nat)) ps; (XS⇩R::(int × int) list) = drop (length ps div (2::nat)) ps; distinct ps; sorted_fst ps; ⋀ps::(int × int) list. sorted_fst ps = sorted_wrt (λ(p₀::int × int) p₁::int × int. fst p₀ ≤ fst p₁) ps; ⋀(f::?'a14 ⇒ ?'a14 ⇒ bool) (xs::?'a14 list) n::nat. sorted_wrt f xs ⟹ sorted_wrt f (drop n xs)⟧ ⟹ distinct XS⇩R› 2. ‹⟦(XS⇩L::(int × int) list) = take (length (ps::(int × int) list) div (2::nat)) ps; (XS⇩R::(int × int) list) = drop (length ps div (2::nat)) ps; distinct ps; sorted_fst ps; ⋀ps::(int × int) list. sorted_fst ps = sorted_wrt (λ(p₀::int × int) p₁::int × int. fst p₀ ≤ fst p₁) ps; ⋀(f::?'a6 ⇒ ?'a6 ⇒ bool) (xs::?'a6 list) n::nat. sorted_wrt f xs ⟹ sorted_wrt f (drop n xs)⟧ ⟹ sorted_fst XS⇩R› discuss goal 1*) apply simp (*discuss goal 2*) by simp (*proven 2 subgoals*) ultimately have "time (closest_pair_rec_tm XS⇩R) ≤ closest_pair_recurrence (length XS⇩R)" using "1.IH" (*‹∀ys. length ys < length ps ⟶ distinct ys ⟶ sorted_fst ys ⟶ real (time (closest_pair_rec_tm ys)) ≤ closest_pair_recurrence (length ys)›*) by simp hence IHR: "time (closest_pair_rec_tm XS⇩R) ≤ closest_pair_recurrence (nat ⌈real ?n / 2⌉)" using "*" (*‹nat ⌊real (length ps) / 2⌋ = length XS⇩L› ‹nat ⌈real (length ps) / 2⌉ = length XS⇩R›*) by simp have "(YS, C₀, C₁) = val (closest_pair_rec_tm ps)" using False (*‹¬ length ps ≤ 3›*) closest_pair_rec_simps (*‹⟦?n = length ?xs; ¬ ?n ≤ 3⟧ ⟹ closest_pair_rec ?xs = (let (xs⇩L, xs⇩R) = split_at (?n div 2) ?xs; (ys⇩L, p₀⇩L, p₁⇩L) = closest_pair_rec xs⇩L; (ys⇩R, p₀⇩R, p₁⇩R) = closest_pair_rec xs⇩R; ys = Common.merge snd ys⇩L ys⇩R in (ys, combine (p₀⇩L, p₁⇩L) (p₀⇩R, p₁⇩R) (fst (hd xs⇩R)) ys))›*) defs (*‹(XS⇩L, XS⇩R) = Time_Monad.val (split_at_tm (length ps div 2) ps)› ‹(YS⇩L, C₀⇩L, C₁⇩L) = Time_Monad.val (closest_pair_rec_tm XS⇩L)› ‹(YS⇩R, C₀⇩R, C₁⇩R) = Time_Monad.val (closest_pair_rec_tm XS⇩R)› ‹(YS::(int × int) list) = Time_Monad.val (merge_tm snd (YS⇩L::(int × int) list) (YS⇩R::(int × int) list))› ‹(C₀, C₁) = Time_Monad.val (combine_tm (C₀⇩L, C₁⇩L) (C₀⇩R, C₁⇩R) (fst (hd XS⇩R)) YS)›*) by (auto simp: Let_def (*‹Let (?s::?'a::type) (?f::?'a::type ⇒ ?'b::type) ≡ ?f ?s›*) length_eq_val_length_tm (*‹Time_Monad.val (length_tm (?xs::?'a::type list)) = length ?xs›*) split!: prod.split (*‹(?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))›*)) hence "set ps = set YS" "length ps = length YS" "distinct YS" "sorted_snd YS" using "1.prems" (*‹distinct ps› ‹sorted_fst ps›*) closest_pair_rec_set_length_sorted_snd (*‹(?ys, ?p) = closest_pair_rec ?xs ⟹ set ?ys = set ?xs ∧ length ?ys = length ?xs ∧ sorted_snd ?ys›*) closest_pair_rec_distinct (*‹⟦distinct ?xs; (?ys, ?p) = closest_pair_rec ?xs⟧ ⟹ distinct ?ys›*) closest_pair_rec_eq_val_closest_pair_rec_tm (*‹Time_Monad.val (closest_pair_rec_tm ?xs) = closest_pair_rec ?xs›*) apply - (*goals: 1. ‹⟦(YS, C₀, C₁) = Time_Monad.val (closest_pair_rec_tm ps); distinct ps; sorted_fst ps; ⋀ys p xs. (ys, p) = closest_pair_rec xs ⟹ set ys = set xs ∧ length ys = length xs ∧ sorted_snd ys; ⋀xs ys p. ⟦distinct xs; (ys, p) = closest_pair_rec xs⟧ ⟹ distinct ys; ⋀xs. Time_Monad.val (closest_pair_rec_tm xs) = closest_pair_rec xs⟧ ⟹ set ps = set YS› 2. ‹⟦(YS, C₀, C₁) = Time_Monad.val (closest_pair_rec_tm ps); distinct ps; sorted_fst ps; ⋀ys p xs. (ys, p) = closest_pair_rec xs ⟹ set ys = set xs ∧ length ys = length xs ∧ sorted_snd ys; ⋀xs ys p. ⟦distinct xs; (ys, p) = closest_pair_rec xs⟧ ⟹ distinct ys; ⋀xs. Time_Monad.val (closest_pair_rec_tm xs) = closest_pair_rec xs⟧ ⟹ length ps = length YS› 3. ‹⟦(YS, C₀, C₁) = Time_Monad.val (closest_pair_rec_tm ps); distinct ps; sorted_fst ps; ⋀ys p xs. (ys, p) = closest_pair_rec xs ⟹ set ys = set xs ∧ length ys = length xs ∧ sorted_snd ys; ⋀xs ys p. ⟦distinct xs; (ys, p) = closest_pair_rec xs⟧ ⟹ distinct ys; ⋀xs. Time_Monad.val (closest_pair_rec_tm xs) = closest_pair_rec xs⟧ ⟹ distinct YS› 4. ‹⟦(YS, C₀, C₁) = Time_Monad.val (closest_pair_rec_tm ps); distinct ps; sorted_fst ps; ⋀ys p xs. (ys, p) = closest_pair_rec xs ⟹ set ys = set xs ∧ length ys = length xs ∧ sorted_snd ys; ⋀xs ys p. ⟦distinct xs; (ys, p) = closest_pair_rec xs⟧ ⟹ distinct ys; ⋀xs. Time_Monad.val (closest_pair_rec_tm xs) = closest_pair_rec xs⟧ ⟹ sorted_snd 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]) (*proven 4 subgoals*) . moreover have "∀p ∈ set YS⇩L. fst p ≤ fst (hd XS⇩R)" using False (*‹¬ length ps ≤ 3›*) "1.prems"(2) (*‹sorted_fst ps›*) XSLR (*‹XS⇩L = take (length ps div 2) ps› ‹XS⇩R = drop (length ps div 2) ps›*) ‹length XS⇩L < length ps› (*‹length XS⇩L < length ps›*) ‹length XS⇩L = length ps div 2› (*‹length XS⇩L = length ps div 2›*) "CP⇩L_def" (*‹(YS⇩L, C₀⇩L, C₁⇩L) = Time_Monad.val (closest_pair_rec_tm XS⇩L)›*) sorted_fst_take_less_hd_drop (*‹⟦sorted_fst ?ps; ?n < length ?ps⟧ ⟹ ∀p∈set (take ?n ?ps). fst p ≤ fst (hd (drop ?n ?ps))›*) closest_pair_rec_set_length_sorted_snd (*‹(?ys, ?p) = closest_pair_rec ?xs ⟹ set ?ys = set ?xs ∧ length ?ys = length ?xs ∧ sorted_snd ?ys›*) closest_pair_rec_eq_val_closest_pair_rec_tm (*‹Time_Monad.val (closest_pair_rec_tm ?xs) = closest_pair_rec ?xs›*) by metis moreover have "∀p ∈ set YS⇩R. fst (hd XS⇩R) ≤ fst p" using False (*‹¬ length (ps::(int × int) list) ≤ (3::nat)›*) "1.prems"(2) (*‹sorted_fst (ps::(int × int) list)›*) XSLR (*‹XS⇩L = take (length ps div 2) ps› ‹XS⇩R = drop (length ps div 2) ps›*) "CP⇩R_def" (*‹(YS⇩R, C₀⇩R, C₁⇩R) = Time_Monad.val (closest_pair_rec_tm XS⇩R)›*) sorted_fst_hd_drop_less_drop (*‹sorted_fst ?ps ⟹ ∀p∈set (drop ?n ?ps). fst (hd (drop ?n ?ps)) ≤ fst p›*) closest_pair_rec_set_length_sorted_snd (*‹(?ys, ?p) = closest_pair_rec ?xs ⟹ set ?ys = set ?xs ∧ length ?ys = length ?xs ∧ sorted_snd ?ys›*) closest_pair_rec_eq_val_closest_pair_rec_tm (*‹Time_Monad.val (closest_pair_rec_tm ?xs) = closest_pair_rec ?xs›*) by metis moreover have "set YS = set YS⇩L ∪ set YS⇩R" using set_merge (*‹set (Common.merge ?f ?xs ?ys) = set ?xs ∪ set ?ys›*) defs (*‹(XS⇩L, XS⇩R) = Time_Monad.val (split_at_tm (length ps div 2) ps)› ‹(YS⇩L::(int × int) list, C₀⇩L::int × int, C₁⇩L::int × int) = Time_Monad.val (closest_pair_rec_tm (XS⇩L::(int × int) list))› ‹(YS⇩R, C₀⇩R, C₁⇩R) = Time_Monad.val (closest_pair_rec_tm XS⇩R)› ‹YS = Time_Monad.val (merge_tm snd YS⇩L YS⇩R)› ‹(C₀, C₁) = Time_Monad.val (combine_tm (C₀⇩L, C₁⇩L) (C₀⇩R, C₁⇩R) (fst (hd XS⇩R)) YS)›*) by (metis merge_eq_val_merge_tm (*‹Time_Monad.val (merge_tm ?f ?xs ?ys) = Common.merge ?f ?xs ?ys›*)) moreover have "sparse (dist C₀⇩L C₁⇩L) (set YS⇩L)" using "CP⇩L_def" (*‹(YS⇩L, C₀⇩L, C₁⇩L) = Time_Monad.val (closest_pair_rec_tm XS⇩L)›*) ‹1 < length XS⇩L› (*‹1 < length XS⇩L›*) ‹distinct XS⇩L› (*‹distinct XS⇩L›*) ‹sorted_fst XS⇩L› (*‹sorted_fst XS⇩L›*) closest_pair_rec_dist (*‹⟦1 < length ?xs; sorted_fst ?xs; (?ys, ?c₀, ?c₁) = closest_pair_rec ?xs⟧ ⟹ sparse (dist (case ?c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case ?c₁ of (x, y) ⇒ (real_of_int x, real_of_int y))) (set ?xs)›*) closest_pair_rec_set_length_sorted_snd (*‹(?ys, ?p) = closest_pair_rec ?xs ⟹ set ?ys = set ?xs ∧ length ?ys = length ?xs ∧ sorted_snd ?ys›*) closest_pair_rec_eq_val_closest_pair_rec_tm (*‹Time_Monad.val (closest_pair_rec_tm ?xs) = closest_pair_rec ?xs›*) by auto moreover have "sparse (dist C₀⇩R C₁⇩R) (set YS⇩R)" using "CP⇩R_def" (*‹(YS⇩R, C₀⇩R, C₁⇩R) = Time_Monad.val (closest_pair_rec_tm XS⇩R)›*) ‹1 < length XS⇩R› (*‹(1::nat) < length (XS⇩R::(int × int) list)›*) ‹distinct XS⇩R› (*‹distinct XS⇩R›*) ‹sorted_fst XS⇩R› (*‹sorted_fst XS⇩R›*) closest_pair_rec_dist (*‹⟦1 < length ?xs; sorted_fst ?xs; (?ys, ?c₀, ?c₁) = closest_pair_rec ?xs⟧ ⟹ sparse (dist (case ?c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case ?c₁ of (x, y) ⇒ (real_of_int x, real_of_int y))) (set ?xs)›*) closest_pair_rec_set_length_sorted_snd (*‹(?ys, ?p) = closest_pair_rec ?xs ⟹ set ?ys = set ?xs ∧ length ?ys = length ?xs ∧ sorted_snd ?ys›*) closest_pair_rec_eq_val_closest_pair_rec_tm (*‹Time_Monad.val (closest_pair_rec_tm ?xs) = closest_pair_rec ?xs›*) by auto ultimately have combine_bound: "t_combine (C₀⇩L, C₁⇩L) (C₀⇩R, C₁⇩R) (fst (hd XS⇩R)) YS ≤ 3 + 10 * ?n" using t_combine_bound[of YS "set YS⇩L" "set YS⇩R" "fst (hd XS⇩R)"] (*‹⟦distinct YS; sorted_snd YS; set YS = set YS⇩L ∪ set YS⇩R; ∀p∈set YS⇩L. fst p ≤ fst (hd XS⇩R); ∀p∈set YS⇩R. fst (hd XS⇩R) ≤ fst p; sparse (dist (case ?p₀⇩L of (x, y) ⇒ (real_of_int x, real_of_int y)) (case ?p₁⇩L of (x, y) ⇒ (real_of_int x, real_of_int y))) (set YS⇩L); sparse (dist (case ?p₀⇩R of (x, y) ⇒ (real_of_int x, real_of_int y)) (case ?p₁⇩R of (x, y) ⇒ (real_of_int x, real_of_int y))) (set YS⇩R)⟧ ⟹ t_combine (?p₀⇩L, ?p₁⇩L) (?p₀⇩R, ?p₁⇩R) (fst (hd XS⇩R)) YS ≤ 10 * length YS + 3›*) by (simp add: add.commute (*‹(?a::?'a::ab_semigroup_add) + (?b::?'a::ab_semigroup_add) = ?b + ?a›*)) have "time (closest_pair_rec_tm ps) = 1 + time (length_tm ps) + time (split_at_tm (?n div 2) ps) + time (closest_pair_rec_tm XS⇩L) + time (closest_pair_rec_tm XS⇩R) + time (merge_tm (λp. snd p) YS⇩L YS⇩R) + t_combine (C₀⇩L, C₁⇩L) (C₀⇩R, C₁⇩R) (fst (hd XS⇩R)) YS" using time_closest_pair_rec_tm_simps_2[OF False] (*‹time (closest_pair_rec_tm ps) = 1 + (let (xs⇩L, xs⇩R) = Time_Monad.val (split_at_tm (length ps div 2) ps); (ys⇩L, p⇩L) = Time_Monad.val (closest_pair_rec_tm xs⇩L); (ys⇩R, p⇩R) = Time_Monad.val (closest_pair_rec_tm xs⇩R); ys = Time_Monad.val (merge_tm snd ys⇩L ys⇩R) in time (length_tm ps) + time (split_at_tm (length ps div 2) ps) + time (closest_pair_rec_tm xs⇩L) + time (closest_pair_rec_tm xs⇩R) + time (merge_tm snd ys⇩L ys⇩R) + t_combine p⇩L p⇩R (fst (hd xs⇩R)) ys)›*) defs (*‹(XS⇩L, XS⇩R) = Time_Monad.val (split_at_tm (length ps div 2) ps)› ‹(YS⇩L, C₀⇩L, C₁⇩L) = Time_Monad.val (closest_pair_rec_tm XS⇩L)› ‹(YS⇩R, C₀⇩R, C₁⇩R) = Time_Monad.val (closest_pair_rec_tm XS⇩R)› ‹(YS::(int × int) list) = Time_Monad.val (merge_tm snd (YS⇩L::(int × int) list) (YS⇩R::(int × int) list))› ‹(C₀::int × int, C₁::int × int) = Time_Monad.val (combine_tm (C₀⇩L::int × int, C₁⇩L::int × int) (C₀⇩R::int × int, C₁⇩R::int × int) (fst (hd (XS⇩R::(int × int) list))) (YS::(int × int) list))›*) by (auto simp del: closest_pair_rec_tm.simps (*‹closest_pair_rec_tm (?xs::(int × int) list) =1 length_tm ?xs ⤜ (λn::nat. if n ≤ (3::nat) then mergesort_tm snd ?xs ⤜ (λys::(int × int) list. closest_pair_bf_tm ?xs ⤜ (λp::(int × int) × int × int. return (ys, p))) else split_at_tm (n div (2::nat)) ?xs ⤜ (λ(xs⇩L::(int × int) list, xs⇩R::(int × int) list). closest_pair_rec_tm xs⇩L ⤜ (λ(ys⇩L::(int × int) list, p₀⇩L::int × int, p₁⇩L::int × int). closest_pair_rec_tm xs⇩R ⤜ (λ(ys⇩R::(int × int) list, p₀⇩R::int × int, p₁⇩R::int × int). merge_tm snd ys⇩L ys⇩R ⤜ (λys::(int × int) list. combine_tm (p₀⇩L, p₁⇩L) (p₀⇩R, p₁⇩R) (fst (hd xs⇩R)) ys ⤜ (λ(p₀::int × int, p₁::int × int). return (ys, p₀, p₁)))))))›*) simp add: Let_def (*‹Let (?s::?'a) (?f::?'a ⇒ ?'b) ≡ ?f ?s›*) 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))›*)) also (*calculation: ‹time (closest_pair_rec_tm ps) = 1 + time (length_tm ps) + time (split_at_tm (length ps div 2) ps) + time (closest_pair_rec_tm XS⇩L) + time (closest_pair_rec_tm XS⇩R) + time (merge_tm snd YS⇩L YS⇩R) + t_combine (C₀⇩L, C₁⇩L) (C₀⇩R, C₁⇩R) (fst (hd XS⇩R)) YS›*) have "... ≤ 7 + 13 * ?n + time (closest_pair_rec_tm XS⇩L) + time (closest_pair_rec_tm XS⇩R)" using time_merge_tm[of "(λp. snd p)" YS⇩L YS⇩R] (*‹time (merge_tm snd YS⇩L YS⇩R) ≤ length YS⇩L + length YS⇩R + 1›*) L (*‹length (ps::(int × int) list) = length (YS⇩L::(int × int) list) + length (YS⇩R::(int × int) list)›*) combine_bound (*‹t_combine (C₀⇩L::int × int, C₁⇩L::int × int) (C₀⇩R::int × int, C₁⇩R::int × int) (fst (hd (XS⇩R::(int × int) list))) (YS::(int × int) list) ≤ (3::nat) + (10::nat) * length (ps::(int × int) list)›*) by (simp add: time_length_tm (*‹time (length_tm ?xs) = length ?xs + 1›*) time_split_at_tm (*‹time (split_at_tm ?n ?xs) = min ?n (length ?xs) + 1›*)) also (*calculation: ‹time (closest_pair_rec_tm ps) ≤ 7 + 13 * length ps + time (closest_pair_rec_tm XS⇩L) + time (closest_pair_rec_tm XS⇩R)›*) have "... ≤ 7 + 13 * ?n + closest_pair_recurrence (nat ⌊real ?n / 2⌋) + closest_pair_recurrence (nat ⌈real ?n / 2⌉)" using IHL (*‹real (time (closest_pair_rec_tm XS⇩L)) ≤ closest_pair_recurrence (nat ⌊real (length ps) / 2⌋)›*) IHR (*‹real (time (closest_pair_rec_tm XS⇩R)) ≤ closest_pair_recurrence (nat ⌈real (length ps) / 2⌉)›*) by simp also (*calculation: ‹(⋀x y. x ≤ y ⟹ real x ≤ real y) ⟹ real (time (closest_pair_rec_tm ps)) ≤ real (7 + 13 * length ps) + closest_pair_recurrence (nat ⌊real (length ps) / 2⌋) + closest_pair_recurrence (nat ⌈real (length ps) / 2⌉)›*) have "... = closest_pair_recurrence (length ps)" using False (*‹¬ length ps ≤ 3›*) by simp finally (*calculation: ‹(⋀x y. x ≤ y ⟹ real x ≤ real y) ⟹ real (time (closest_pair_rec_tm ps)) ≤ closest_pair_recurrence (length ps)›*) show "?thesis" (*goal: ‹real (time (closest_pair_rec_tm ps)) ≤ closest_pair_recurrence (length ps)›*) by simp qed qed theorem closest_pair_recurrence: "closest_pair_recurrence ∈ Θ(λn. n * ln n)" apply master_theorem (*goals: 1. ‹⋀x. ⟦0 ≤ x; x < Suc 3⟧ ⟹ 0 ≤ closest_pair_recurrence x› 2. ‹⋀x. Suc 3 ≤ x ⟹ closest_pair_recurrence x = 7 + 13 * real x + (closest_pair_recurrence (nat ⌊real x / 2⌋) + closest_pair_recurrence (nat ⌈real x / 2⌉))› 3. ‹⋀x. Suc 3 ≤ x ⟹ 0 ≤ 7 + 13 * real x› 4. ‹(λn. 7 + 13 * real n) ∈ Θ(real)› 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*) . theorem time_closest_pair_rec_bigo: "(λxs. time (closest_pair_rec_tm xs)) ∈ O[length going_to at_top within { ps. distinct ps ∧ sorted_fst ps }]((λn. n * ln n) o length)" proof (-) (*goal: ‹(λx. real (time (closest_pair_rec_tm x))) ∈ O[length going_to sequentially within {ps. distinct ps ∧ sorted_fst ps}]((λn. real n * ln (real n)) ∘ length)›*) have 0: "⋀ps. ps ∈ { ps. distinct ps ∧ sorted_fst ps } ⟹ time (closest_pair_rec_tm ps) ≤ (closest_pair_recurrence o length) ps" unfolding comp_def (*goal: ‹⋀ps. ps ∈ {ps. distinct ps ∧ sorted_fst ps} ⟹ real (time (closest_pair_rec_tm ps)) ≤ closest_pair_recurrence (length ps)›*) using time_closest_pair_rec_conv_closest_pair_recurrence (*‹⟦distinct ?ps; sorted_fst ?ps⟧ ⟹ real (time (closest_pair_rec_tm ?ps)) ≤ closest_pair_recurrence (length ?ps)›*) by auto show "?thesis" (*goal: ‹(λx. real (time (closest_pair_rec_tm x))) ∈ O[length going_to sequentially within {ps. distinct ps ∧ sorted_fst ps}]((λn. real n * ln (real n)) ∘ length)›*) using bigo_measure_trans[OF 0] (*‹⟦⋀x. x ∈ ?A ⟹ x ∈ {ps. distinct ps ∧ sorted_fst ps}; closest_pair_recurrence ∈ O(?f); ⋀x. x ∈ ?A ⟹ 0 ≤ real (time (closest_pair_rec_tm x))⟧ ⟹ (λx. real (time (closest_pair_rec_tm x))) ∈ O[length going_to sequentially within ?A](?f ∘ length)›*) bigthetaD1[OF closest_pair_recurrence] (*‹closest_pair_recurrence ∈ O(λx::nat. real x * ln (real x))›*) of_nat_0_le_iff (*‹0 ≤ of_nat ?n›*) by blast qed definition closest_pair_time :: "nat ⇒ real" where "closest_pair_time n = 1 + mergesort_recurrence n + closest_pair_recurrence n" lemma time_closest_pair_conv_closest_pair_recurrence: assumes "distinct ps" shows "time (closest_pair_tm ps) ≤ closest_pair_time (length ps)" using assms (*‹distinct ps›*) unfolding closest_pair_time_def (*goal: ‹real (time (closest_pair_tm ps)) ≤ 1 + mergesort_recurrence (length ps) + closest_pair_recurrence (length ps)›*) proof (induction rule: induct_list012 (*‹⟦?P []; ⋀x. ?P [x]; ⋀x y zs. ⟦?P zs; ?P (y # zs)⟧ ⟹ ?P (x # y # zs)⟧ ⟹ ?P ?xs›*)) (*goals: 1. ‹distinct [] ⟹ real (time (closest_pair_tm [])) ≤ 1 + mergesort_recurrence (length []) + closest_pair_recurrence (length [])› 2. ‹⋀x. distinct [x] ⟹ real (time (closest_pair_tm [x])) ≤ 1 + mergesort_recurrence (length [x]) + closest_pair_recurrence (length [x])› 3. ‹⋀x y zs. ⟦distinct zs ⟹ real (time (closest_pair_tm zs)) ≤ 1 + mergesort_recurrence (length zs) + closest_pair_recurrence (length zs); distinct (y # zs) ⟹ real (time (closest_pair_tm (y # zs))) ≤ 1 + mergesort_recurrence (length (y # zs)) + closest_pair_recurrence (length (y # zs)); distinct (x # y # zs)⟧ ⟹ real (time (closest_pair_tm (x # y # zs))) ≤ 1 + mergesort_recurrence (length (x # y # zs)) + closest_pair_recurrence (length (x # y # zs))›*) case (3 x y zs) (*‹distinct zs ⟹ real (time (closest_pair_tm zs)) ≤ 1 + mergesort_recurrence (length zs) + closest_pair_recurrence (length zs)› ‹distinct ((y::int × int) # (zs::(int × int) list)) ⟹ real (time (closest_pair_tm (y # zs))) ≤ (1::real) + mergesort_recurrence (length (y # zs)) + closest_pair_recurrence (length (y # zs))› ‹distinct ((x::int × int) # (y::int × int) # (zs::(int × int) list))›*) let ?ps = "x # y # zs" define xs where "xs = val (mergesort_tm fst ?ps)" have "*": "distinct xs" "sorted_fst xs" "length xs = length ?ps" using xs_def (*‹xs = Time_Monad.val (mergesort_tm fst (x # y # zs))›*) mergesort(4)[OF "3.prems", of fst] (*‹distinct (mergesort fst (x # y # zs))›*) mergesort(1)[of fst ?ps] (*‹sorted_wrt (λx y. fst x ≤ fst y) (mergesort fst (x # y # zs))›*) mergesort(3)[of fst ?ps] (*‹length (mergesort fst ((x::int × int) # (y::int × int) # (zs::(int × int) list))) = length (x # y # zs)›*) sorted_fst_def (*‹sorted_fst ?ps = sorted_wrt (λp₀ p₁. fst p₀ ≤ fst p₁) ?ps›*) mergesort_eq_val_mergesort_tm (*‹Time_Monad.val (mergesort_tm ?f ?xs) = mergesort ?f ?xs›*) by ((metis)+) have "time (closest_pair_tm ?ps) = 1 + time (mergesort_tm fst ?ps) + time (closest_pair_rec_tm xs)" using xs_def (*‹xs = Time_Monad.val (mergesort_tm fst (x # y # zs))›*) by (auto simp del: mergesort_tm.simps (*‹mergesort_tm ?f [] =1 return []› ‹mergesort_tm ?f [?x] =1 return [?x]› ‹mergesort_tm ?f (?v # ?vb # ?vc) =1 length_tm (?v # ?vb # ?vc) ⤜ (λn. split_at_tm (n div 2) (?v # ?vb # ?vc) ⤜ (λ(xs⇩l, xs⇩r). mergesort_tm ?f xs⇩l ⤜ (λl. mergesort_tm ?f xs⇩r ⤜ merge_tm ?f l)))›*) closest_pair_rec_tm.simps (*‹closest_pair_rec_tm ?xs =1 length_tm ?xs ⤜ (λn. if n ≤ 3 then mergesort_tm snd ?xs ⤜ (λys. closest_pair_bf_tm ?xs ⤜ (λp. return (ys, p))) else split_at_tm (n div 2) ?xs ⤜ (λ(xs⇩L, xs⇩R). closest_pair_rec_tm xs⇩L ⤜ (λ(ys⇩L, p₀⇩L, p₁⇩L). closest_pair_rec_tm xs⇩R ⤜ (λ(ys⇩R, p₀⇩R, p₁⇩R). merge_tm snd ys⇩L ys⇩R ⤜ (λys. combine_tm (p₀⇩L, p₁⇩L) (p₀⇩R, p₁⇩R) (fst (hd xs⇩R)) ys ⤜ (λ(p₀, p₁). return (ys, p₀, p₁)))))))›*) simp add: time_simps (*‹time (?tm ⤜ ?f) = time ?tm + time (?f (Time_Monad.val ?tm))› ‹tick ?v = ??.Time_Monad.tm.TM ?v 1›*) split: prod.split (*‹?P (case ?prod of (x, xa) ⇒ ?f x xa) = (∀x1 x2. ?prod = (x1, x2) ⟶ ?P (?f x1 x2))›*)) also (*calculation: ‹time (closest_pair_tm (x # y # zs)) = 1 + time (mergesort_tm fst (x # y # zs)) + time (closest_pair_rec_tm xs)›*) have "... ≤ 1 + mergesort_recurrence (length ?ps) + time (closest_pair_rec_tm xs)" using time_mergesort_conv_mergesort_recurrence[of fst ?ps] (*‹real (time (mergesort_tm fst (x # y # zs))) ≤ mergesort_recurrence (length (x # y # zs))›*) by simp also (*calculation: ‹real (time (closest_pair_tm (x # y # zs))) ≤ 1 + mergesort_recurrence (length (x # y # zs)) + real (time (closest_pair_rec_tm xs))›*) have "... ≤ 1 + mergesort_recurrence (length ?ps) + closest_pair_recurrence (length ?ps)" using time_closest_pair_rec_conv_closest_pair_recurrence[of xs] (*‹⟦distinct xs; sorted_fst xs⟧ ⟹ real (time (closest_pair_rec_tm xs)) ≤ closest_pair_recurrence (length xs)›*) "*" (*‹distinct xs› ‹sorted_fst xs› ‹length xs = length (x # y # zs)›*) by auto finally (*calculation: ‹real (time (closest_pair_tm ((x::int × int) # (y::int × int) # (zs::(int × int) list)))) ≤ (1::real) + mergesort_recurrence (length (x # y # zs)) + closest_pair_recurrence (length (x # y # zs))›*) show "?case" (*goal: ‹real (time (closest_pair_tm (x # y # zs))) ≤ 1 + mergesort_recurrence (length (x # y # zs)) + closest_pair_recurrence (length (x # y # zs))›*) by blast qed (auto simp: time_simps (*‹time (?tm ⤜ ?f) = time ?tm + time (?f (Time_Monad.val ?tm))› ‹tick ?v = ??.Time_Monad.tm.TM ?v 1›*)) (*solves the remaining goals: 1. ‹distinct [] ⟹ real (time (closest_pair_tm [])) ≤ 1 + mergesort_recurrence (length []) + closest_pair_recurrence (length [])› 2. ‹⋀x. distinct [x] ⟹ real (time (closest_pair_tm [x])) ≤ 1 + mergesort_recurrence (length [x]) + closest_pair_recurrence (length [x])›*) corollary closest_pair_time: "closest_pair_time ∈ O(λn. n * ln n)" unfolding closest_pair_time_def (*goal: ‹(λn. 1 + mergesort_recurrence n + closest_pair_recurrence n) ∈ O(λx. real x * ln (real x))›*) using mergesort_recurrence (*‹mergesort_recurrence ∈ Θ(λx. real x * ln (real x))›*) closest_pair_recurrence (*‹closest_pair_recurrence ∈ Θ(λx. real x * ln (real x))›*) sum_in_bigo(1) (*‹⟦(?f::?'a::type ⇒ ?'b::real_normed_field) ∈ O[?F::?'a::type filter](?h::?'a::type ⇒ ?'b::real_normed_field); (?g::?'a::type ⇒ ?'b::real_normed_field) ∈ O[?F](?h)⟧ ⟹ (λx::?'a::type. ?f x + ?g x) ∈ O[?F](?h)›*) const_1_bigo_n_ln_n (*‹(λn. 1) ∈ O(λn. real n * ln (real n))›*) by blast corollary time_closest_pair_bigo: "(λps. time (closest_pair_tm ps)) ∈ O[length going_to at_top within { ps. distinct ps }]((λn. n * ln n) o length)" proof (-) (*goal: ‹(λx. real (time (closest_pair_tm x))) ∈ O[length going_to sequentially within {ps. distinct ps}]((λn. real n * ln (real n)) ∘ length)›*) have 0: "⋀ps. ps ∈ { ps. distinct ps } ⟹ time (closest_pair_tm ps) ≤ (closest_pair_time o length) ps" unfolding comp_def (*goal: ‹⋀ps::(int × int) list. ps ∈ {ps::(int × int) list. distinct ps} ⟹ real (time (closest_pair_tm ps)) ≤ closest_pair_time (length ps)›*) using time_closest_pair_conv_closest_pair_recurrence (*‹distinct ?ps ⟹ real (time (closest_pair_tm ?ps)) ≤ closest_pair_time (length ?ps)›*) by auto show "?thesis" (*goal: ‹(λx. real (time (closest_pair_tm x))) ∈ O[length going_to sequentially within {ps. distinct ps}]((λn. real n * ln (real n)) ∘ length)›*) using bigo_measure_trans[OF 0] (*‹⟦⋀x. x ∈ ?A ⟹ x ∈ {ps. distinct ps}; closest_pair_time ∈ O(?f); ⋀x. x ∈ ?A ⟹ 0 ≤ real (time (closest_pair_tm x))⟧ ⟹ (λx. real (time (closest_pair_tm x))) ∈ O[length going_to sequentially within ?A](?f ∘ length)›*) closest_pair_time (*‹closest_pair_time ∈ O(λx. real x * ln (real x))›*) by fastforce qed subsection "Code Export" subsubsection "Combine Step" fun find_closest_code :: "point ⇒ int ⇒ point list ⇒ (int * point)" where "find_closest_code _ _ [] = undefined" | "find_closest_code p _ [p₀] = (dist_code p p₀, p₀)" | "find_closest_code p δ (p₀ # ps) = ( let δ₀ = dist_code p p₀ in if δ ≤ (snd p₀ - snd p)² then (δ₀, p₀) else let (δ₁, p₁) = find_closest_code p (min δ δ₀) ps in if δ₀ ≤ δ₁ then (δ₀, p₀) else (δ₁, p₁) )" lemma find_closest_code_dist_eq: "0 < length ps ⟹ (δ⇩c, c) = find_closest_code p δ ps ⟹ δ⇩c = dist_code p c" proof (induction p δ ps arbitrary: δ⇩c c rule: find_closest_code.induct) (*goals: 1. ‹⋀uu_ uv_ δ⇩c c. ⟦0 < length []; (δ⇩c, c) = find_closest_code uu_ uv_ []⟧ ⟹ δ⇩c = dist_code uu_ c› 2. ‹⋀p uw_ p₀ δ⇩c c. ⟦0 < length [p₀]; (δ⇩c, c) = find_closest_code p uw_ [p₀]⟧ ⟹ δ⇩c = dist_code p c› 3. ‹⋀p δ p₀ v va δ⇩c c. ⟦⋀x δ⇩c c. ⟦x = dist_code p p₀; ¬ δ ≤ (snd p₀ - snd p)²; 0 < length (v # va); (δ⇩c, c) = find_closest_code p (min δ x) (v # va)⟧ ⟹ δ⇩c = dist_code p c; 0 < length (p₀ # v # va); (δ⇩c, c) = find_closest_code p δ (p₀ # v # va)⟧ ⟹ δ⇩c = dist_code p c›*) case (3 p δ p₀ p₂ ps) (*‹⟦?x = dist_code p p₀; ¬ δ ≤ (snd p₀ - snd p)²; 0 < length (p₂ # ps); (?δ⇩c, ?c) = find_closest_code p (min δ ?x) (p₂ # ps)⟧ ⟹ ?δ⇩c = dist_code p ?c› ‹0 < length (p₀ # p₂ # ps)› ‹(δ⇩c, c) = find_closest_code p δ (p₀ # p₂ # ps)›*) show "?case" (*goal: ‹δ⇩c = dist_code p c›*) proof (cases) (*goals: 1. ‹?P::bool ⟹ (δ⇩c::int) = dist_code (p::int × int) (c::int × int)› 2. ‹¬ (?P::bool) ⟹ (δ⇩c::int) = dist_code (p::int × int) (c::int × int)›*) assume "δ ≤ (snd p₀ - snd p)²" (*‹(δ::int) ≤ (snd (p₀::int × int) - snd (p::int × int))²›*) thus "?thesis" (*goal: ‹δ⇩c = dist_code p c›*) using "3.prems"(2) (*‹(δ⇩c, c) = find_closest_code p δ (p₀ # p₂ # ps)›*) by simp next (*goal: ‹¬ δ ≤ (snd p₀ - snd p)² ⟹ δ⇩c = dist_code p c›*) assume A: "¬ δ ≤ (snd p₀ - snd p)²" (*‹¬ (δ::int) ≤ (snd (p₀::int × int) - snd (p::int × int))²›*) define δ₀ where "δ₀_def": "δ₀ = dist_code p p₀" obtain δ₁ and p₁ where "δ₁_def": "(δ₁, p₁) = find_closest_code p (min δ δ₀) (p₂ # ps)" (*goal: ‹(⋀δ₁ p₁. (δ₁, p₁) = find_closest_code p (min δ δ₀) (p₂ # ps) ⟹ thesis) ⟹ thesis›*) by (metis surj_pair (*‹∃x y. ?p = (x, y)›*)) note defs = "δ₀_def" (*‹(δ₀::int) = dist_code (p::int × int) (p₀::int × int)›*) "δ₁_def" (*‹(δ₁, p₁) = find_closest_code p (min δ δ₀) (p₂ # ps)›*) have "δ₁ = dist_code p p₁" using "3.IH"[of δ₀ δ₁ p₁] (*‹⟦δ₀ = dist_code p p₀; ¬ δ ≤ (snd p₀ - snd p)²; 0 < length (p₂ # ps); (δ₁, p₁) = find_closest_code p (min δ δ₀) (p₂ # ps)⟧ ⟹ δ₁ = dist_code p p₁›*) A (*‹¬ δ ≤ (snd p₀ - snd p)²›*) defs (*‹δ₀ = dist_code p p₀› ‹(δ₁::int, p₁::int × int) = find_closest_code (p::int × int) (min (δ::int) (δ₀::int)) ((p₂::int × int) # (ps::(int × int) list))›*) by simp thus "?thesis" (*goal: ‹δ⇩c = dist_code p c›*) using defs (*‹δ₀ = dist_code p p₀› ‹(δ₁, p₁) = find_closest_code p (min δ δ₀) (p₂ # ps)›*) "3.prems" (*‹0 < length (p₀ # p₂ # ps)› ‹(δ⇩c, c) = find_closest_code p δ (p₀ # p₂ # ps)›*) by (auto simp: Let_def (*‹Let (?s::?'a::type) (?f::?'a::type ⇒ ?'b::type) ≡ ?f ?s›*) 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))›*)) qed qed (simp_all) (*solves the remaining goals: 1. ‹⋀uu_ uv_ δ⇩c c. ⟦0 < length []; (δ⇩c, c) = find_closest_code uu_ uv_ []⟧ ⟹ δ⇩c = dist_code uu_ c› 2. ‹⋀p uw_ p₀ δ⇩c c. ⟦0 < length [p₀]; (δ⇩c, c) = find_closest_code p uw_ [p₀]⟧ ⟹ δ⇩c = dist_code p c›*) declare find_closest.simps [simp add] lemma find_closest_code_eq: assumes "0 < length ps" "δ = dist c₀ c₁" "δ' = dist_code c₀ c₁" "sorted_snd (p # ps)" assumes "c = find_closest p δ ps" "(δ⇩c', c') = find_closest_code p δ' ps" shows "c = c'" using assms (*‹0 < length ps› ‹δ = dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y))› ‹δ' = dist_code c₀ c₁› ‹sorted_snd (p # ps)› ‹(c::int × int) = find_closest (p::int × int) (δ::real) (ps::(int × int) list)› ‹(δ⇩c'::int, c'::int × int) = find_closest_code (p::int × int) (δ'::int) (ps::(int × int) list)›*) proof (induction p δ ps arbitrary: δ' c₀ c₁ c δ⇩c' c' rule: find_closest.induct) (*goals: 1. ‹⋀uu_ uv_ δ' c₀ c₁ c δ⇩c' c'. ⟦0 < length []; uv_ = dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y)); δ' = dist_code c₀ c₁; sorted_snd [uu_]; c = find_closest uu_ uv_ []; (δ⇩c', c') = find_closest_code uu_ δ' []⟧ ⟹ c = c'› 2. ‹⋀uw_ ux_ p δ' c₀ c₁ c δ⇩c' c'. ⟦0 < length [p]; ux_ = dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y)); δ' = dist_code c₀ c₁; sorted_snd [uw_, p]; c = find_closest uw_ ux_ [p]; (δ⇩c', c') = find_closest_code uw_ δ' [p]⟧ ⟹ c = c'› 3. ‹⋀p δ p₀ v va δ' c₀ c₁ c δ⇩c' c'. ⟦⋀δ' c₀ c₁ c δ⇩c' c'. ⟦¬ δ ≤ real_of_int (snd p₀ - snd p); 0 < length (v # va); min δ (dist (case p of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₀ of (x, y) ⇒ (real_of_int x, real_of_int y))) = dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y)); δ' = dist_code c₀ c₁; sorted_snd (p # v # va); c = find_closest p (min δ (dist (case p of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₀ of (x, y) ⇒ (real_of_int x, real_of_int y)))) (v # va); (δ⇩c', c') = find_closest_code p δ' (v # va)⟧ ⟹ c = c'; 0 < length (p₀ # v # va); δ = dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y)); δ' = dist_code c₀ c₁; sorted_snd (p # p₀ # v # va); c = find_closest p δ (p₀ # v # va); (δ⇩c', c') = find_closest_code p δ' (p₀ # v # va)⟧ ⟹ c = c'›*) case (3 p δ p₀ p₂ ps) (*‹⟦¬ δ ≤ real_of_int (snd p₀ - snd p); 0 < length (p₂ # ps); min δ (dist (case p of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₀ of (x, y) ⇒ (real_of_int x, real_of_int y))) = dist (case ?c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case ?c₁ of (x, y) ⇒ (real_of_int x, real_of_int y)); ?δ' = dist_code ?c₀ ?c₁; sorted_snd (p # p₂ # ps); ?c = find_closest p (min δ (dist (case p of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₀ of (x, y) ⇒ (real_of_int x, real_of_int y)))) (p₂ # ps); (?δ⇩c', ?c') = find_closest_code p ?δ' (p₂ # ps)⟧ ⟹ ?c = ?c'› ‹0 < length (p₀ # p₂ # ps)› ‹δ = dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y))› ‹(δ'::int) = dist_code (c₀::int × int) (c₁::int × int)› ‹sorted_snd (p # p₀ # p₂ # ps)› ‹c = find_closest p δ (p₀ # p₂ # ps)› ‹(δ⇩c'::int, c'::int × int) = find_closest_code (p::int × int) (δ'::int) ((p₀::int × int) # (p₂::int × int) # (ps::(int × int) list))›*) define δ₀ and δ₀' where "δ₀_def": "δ₀ = dist p p₀" "δ₀' = dist_code p p₀" obtain p₁ and δ₁' and p₁' where "δ₁_def": "p₁ = find_closest p (min δ δ₀) (p₂ # ps)" "(δ₁', p₁') = find_closest_code p (min δ' δ₀') (p₂ # ps)" (*goal: ‹(⋀p₁ δ₁' p₁'. ⟦p₁ = find_closest p (min δ δ₀) (p₂ # ps); (δ₁', p₁') = find_closest_code p (min δ' δ₀') (p₂ # ps)⟧ ⟹ thesis) ⟹ thesis›*) by (metis surj_pair (*‹∃x y. ?p = (x, y)›*)) note defs = "δ₀_def" (*‹δ₀ = dist (case p of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₀ of (x, y) ⇒ (real_of_int x, real_of_int y))› ‹δ₀' = dist_code p p₀›*) "δ₁_def" (*‹(p₁::int × int) = find_closest (p::int × int) (min (δ::real) (δ₀::real)) ((p₂::int × int) # (ps::(int × int) list))› ‹(δ₁', p₁') = find_closest_code p (min δ' δ₀') (p₂ # ps)›*) show "?case" (*goal: ‹(c::int × int) = (c'::int × int)›*) proof (cases) (*goals: 1. ‹?P ⟹ c = c'› 2. ‹¬ ?P ⟹ c = c'›*) assume "*": "δ ≤ snd p₀ - snd p" (*‹(δ::real) ≤ real_of_int (snd (p₀::int × int) - snd (p::int × int))›*) hence "δ' ≤ (snd p₀ - snd p)²" using "3.prems"(2,3) (*‹δ = dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y))› ‹(δ'::int) = dist_code (c₀::int × int) (c₁::int × int)›*) dist_eq_dist_code_abs_le (*‹(dist (case ?p₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case ?p₁ of (x, y) ⇒ (real_of_int x, real_of_int y)) ≤ ¦real_of_int ?c¦) = (dist_code ?p₀ ?p₁ ≤ ?c²)›*) by fastforce thus "?thesis" (*goal: ‹c = c'›*) using "*" (*‹δ ≤ real_of_int (snd p₀ - snd p)›*) "3.prems"(5,6) (*‹c = find_closest p δ (p₀ # p₂ # ps)› ‹(δ⇩c', c') = find_closest_code p δ' (p₀ # p₂ # ps)›*) by simp next (*goal: ‹¬ δ ≤ real_of_int (snd p₀ - snd p) ⟹ c = c'›*) assume "*": "¬ δ ≤ snd p₀ - snd p" (*‹¬ (δ::real) ≤ real_of_int (snd (p₀::int × int) - snd (p::int × int))›*) moreover have "0 ≤ snd p₀ - snd p" using "3.prems"(4) (*‹sorted_snd (p # p₀ # p₂ # ps)›*) sorted_snd_def (*‹sorted_snd ?ps = sorted_wrt (λp₀ p₁. snd p₀ ≤ snd p₁) ?ps›*) by simp ultimately have A: "¬ δ' ≤ (snd p₀ - snd p)²" using "3.prems"(2,3) (*‹δ = dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y))› ‹δ' = dist_code c₀ c₁›*) dist_eq_dist_code_abs_le[of c₀ c₁ "snd p₀ - snd p"] (*‹(dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y)) ≤ ¦real_of_int (snd p₀ - snd p)¦) = (dist_code c₀ c₁ ≤ (snd p₀ - snd p)²)›*) by simp have "min δ δ₀ = δ ⟷ min δ' δ₀' = δ'" "min δ δ₀ = δ₀ ⟷ min δ' δ₀' = δ₀'" (*goals: 1. ‹(min δ δ₀ = δ) = (min δ' δ₀' = δ')› 2. ‹(min δ δ₀ = δ₀) = (min δ' δ₀' = δ₀')› discuss goal 1*) apply (metis "3.prems" (*‹δ = dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y))› ‹δ' = dist_code c₀ c₁›*) (2,3) defs( (*‹δ₀ = dist (case p of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₀ of (x, y) ⇒ (real_of_int x, real_of_int y))› ‹δ₀' = dist_code p p₀›*) 1,2) dist_eq_dist_code_le (*‹(dist (case ?p₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case ?p₁ of (x, y) ⇒ (real_of_int x, real_of_int y)) ≤ dist (case ?p₂ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case ?p₃ of (x, y) ⇒ (real_of_int x, real_of_int y))) = (dist_code ?p₀ ?p₁ ≤ dist_code ?p₂ ?p₃)›*) min.commute (*‹min ?a ?b = min ?b ?a›*) min_def (*‹min ?a ?b = (if ?a ≤ ?b then ?a else ?b)›*)) (*discuss goal 2*) apply (metis "3.prems" (*‹(δ::real) = dist (case c₀::int × int of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) (case c₁::int × int of (x::int, y::int) ⇒ (real_of_int x, real_of_int y))› ‹(δ'::int) = dist_code (c₀::int × int) (c₁::int × int)›*) (2,3) defs( (*‹(δ₀::real) = dist (case p::int × int of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) (case p₀::int × int of (x::int, y::int) ⇒ (real_of_int x, real_of_int y))› ‹(δ₀'::int) = dist_code (p::int × int) (p₀::int × int)›*) 1,2) dist_eq_dist_code_le (*‹(dist (case ?p₀::int × int of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) (case ?p₁::int × int of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) ≤ dist (case ?p₂::int × int of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) (case ?p₃::int × int of (x::int, y::int) ⇒ (real_of_int x, real_of_int y))) = (dist_code ?p₀ ?p₁ ≤ dist_code ?p₂ ?p₃)›*) min.commute (*‹min (?a::?'a) (?b::?'a) = min ?b ?a›*) min_def (*‹min (?a::?'a) (?b::?'a) = (if ?a ≤ ?b then ?a else ?b)›*)) (*proven 2 subgoals*) . moreover have "sorted_snd (p # p₂ # ps)" using "3.prems"(4) (*‹sorted_snd (p # p₀ # p₂ # ps)›*) sorted_snd_def (*‹sorted_snd ?ps = sorted_wrt (λp₀ p₁. snd p₀ ≤ snd p₁) ?ps›*) by simp ultimately have B: "p₁ = p₁'" using "3.IH"[of c₀ c₁ δ' p₁ δ₁' p₁'] (*‹⟦¬ (δ::real) ≤ real_of_int (snd (p₀::int × int) - snd (p::int × int)); (0::nat) < length ((p₂::int × int) # (ps::(int × int) list)); min δ (dist (case p of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) (case p₀ of (x::int, y::int) ⇒ (real_of_int x, real_of_int y))) = dist (case c₀::int × int of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) (case c₁::int × int of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)); (δ'::int) = dist_code c₀ c₁; sorted_snd (p # p₂ # ps); (p₁::int × int) = find_closest p (min δ (dist (case p of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) (case p₀ of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)))) (p₂ # ps); (δ₁'::int, p₁'::int × int) = find_closest_code p δ' (p₂ # ps)⟧ ⟹ p₁ = p₁'›*) "3.IH"[of p p₀ δ₀' p₁ δ₁' p₁'] (*‹⟦¬ δ ≤ real_of_int (snd p₀ - snd p); 0 < length (p₂ # ps); min δ (dist (case p of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₀ of (x, y) ⇒ (real_of_int x, real_of_int y))) = dist (case p of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₀ of (x, y) ⇒ (real_of_int x, real_of_int y)); δ₀' = dist_code p p₀; sorted_snd (p # p₂ # ps); p₁ = find_closest p (min δ (dist (case p of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₀ of (x, y) ⇒ (real_of_int x, real_of_int y)))) (p₂ # ps); (δ₁', p₁') = find_closest_code p δ₀' (p₂ # ps)⟧ ⟹ p₁ = p₁'›*) "3.prems"(2,3) (*‹δ = dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y))› ‹(δ'::int) = dist_code (c₀::int × int) (c₁::int × int)›*) defs (*‹δ₀ = dist (case p of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₀ of (x, y) ⇒ (real_of_int x, real_of_int y))› ‹δ₀' = dist_code p p₀› ‹p₁ = find_closest p (min δ δ₀) (p₂ # ps)› ‹(δ₁', p₁') = find_closest_code p (min δ' δ₀') (p₂ # ps)›*) "*" (*‹¬ δ ≤ real_of_int (snd p₀ - snd p)›*) by auto have "δ₁' = dist_code p p₁'" using find_closest_code_dist_eq (*‹⟦0 < length ?ps; (?δ⇩c, ?c) = find_closest_code ?p ?δ ?ps⟧ ⟹ ?δ⇩c = dist_code ?p ?c›*) defs (*‹δ₀ = dist (case p of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₀ of (x, y) ⇒ (real_of_int x, real_of_int y))› ‹δ₀' = dist_code p p₀› ‹p₁ = find_closest p (min δ δ₀) (p₂ # ps)› ‹(δ₁', p₁') = find_closest_code p (min δ' δ₀') (p₂ # ps)›*) by blast hence "δ₀ ≤ dist p p₁ ⟷ δ₀' ≤ δ₁'" using defs(1,2) (*‹(δ₀::real) = dist (case p::int × int of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) (case p₀::int × int of (x::int, y::int) ⇒ (real_of_int x, real_of_int y))› ‹δ₀' = dist_code p p₀›*) dist_eq_dist_code_le (*‹(dist (case ?p₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case ?p₁ of (x, y) ⇒ (real_of_int x, real_of_int y)) ≤ dist (case ?p₂ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case ?p₃ of (x, y) ⇒ (real_of_int x, real_of_int y))) = (dist_code ?p₀ ?p₁ ≤ dist_code ?p₂ ?p₃)›*) by (simp add: B (*‹p₁ = p₁'›*)) thus "?thesis" (*goal: ‹c = c'›*) using "3.prems"(5,6) (*‹c = find_closest p δ (p₀ # p₂ # ps)› ‹(δ⇩c'::int, c'::int × int) = find_closest_code (p::int × int) (δ'::int) ((p₀::int × int) # (p₂::int × int) # (ps::(int × int) list))›*) "*" (*‹¬ δ ≤ real_of_int (snd p₀ - snd p)›*) A (*‹¬ δ' ≤ (snd p₀ - snd p)²›*) B (*‹p₁ = p₁'›*) defs (*‹δ₀ = dist (case p of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₀ of (x, y) ⇒ (real_of_int x, real_of_int y))› ‹δ₀' = dist_code p p₀› ‹p₁ = find_closest p (min δ δ₀) (p₂ # ps)› ‹(δ₁', p₁') = find_closest_code p (min δ' δ₀') (p₂ # ps)›*) by (auto simp: 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))›*)) qed qed (auto) (*solves the remaining goals: 1. ‹⋀uu_ uv_ δ' c₀ c₁ c δ⇩c' c'. ⟦0 < length []; uv_ = dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y)); δ' = dist_code c₀ c₁; sorted_snd [uu_]; c = find_closest uu_ uv_ []; (δ⇩c', c') = find_closest_code uu_ δ' []⟧ ⟹ c = c'› 2. ‹⋀uw_ ux_ p δ' c₀ c₁ c δ⇩c' c'. ⟦0 < length [p]; ux_ = dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y)); δ' = dist_code c₀ c₁; sorted_snd [uw_, p]; c = find_closest uw_ ux_ [p]; (δ⇩c', c') = find_closest_code uw_ δ' [p]⟧ ⟹ c = c'›*) fun find_closest_pair_code :: "(int * point * point) ⇒ point list ⇒ (int * point * point)" where "find_closest_pair_code (δ, c₀, c₁) [] = (δ, c₀, c₁)" | "find_closest_pair_code (δ, c₀, c₁) [p] = (δ, c₀, c₁)" | "find_closest_pair_code (δ, c₀, c₁) (p₀ # ps) = ( let (δ', p₁) = find_closest_code p₀ δ ps in if δ ≤ δ' then find_closest_pair_code (δ, c₀, c₁) ps else find_closest_pair_code (δ', p₀, p₁) ps )" lemma find_closest_pair_code_dist_eq: assumes "δ = dist_code c₀ c₁" "(Δ, C₀, C₁) = find_closest_pair_code (δ, c₀, c₁) ps" shows "Δ = dist_code C₀ C₁" using assms (*‹δ = dist_code c₀ c₁› ‹(Δ, C₀, C₁) = find_closest_pair_code (δ, c₀, c₁) ps›*) proof (induction "(δ, c₀, c₁)" ps arbitrary: δ c₀ c₁ Δ C₀ C₁ rule: find_closest_pair_code.induct) (*goals: 1. ‹⋀δ c₀ c₁ Δ C₀ C₁. ⟦δ = dist_code c₀ c₁; (Δ, C₀, C₁) = find_closest_pair_code (δ, c₀, c₁) []⟧ ⟹ Δ = dist_code C₀ C₁› 2. ‹⋀δ c₀ c₁ p Δ C₀ C₁. ⟦δ = dist_code c₀ c₁; (Δ, C₀, C₁) = find_closest_pair_code (δ, c₀, c₁) [p]⟧ ⟹ Δ = dist_code C₀ C₁› 3. ‹⋀δ c₀ c₁ p₀ v va Δ C₀ C₁. ⟦⋀x xa y Δ C₀ C₁. ⟦x = find_closest_code p₀ δ (v # va); (xa, y) = x; δ ≤ xa; δ = dist_code c₀ c₁; (Δ, C₀, C₁) = find_closest_pair_code (δ, c₀, c₁) (v # va)⟧ ⟹ Δ = dist_code C₀ C₁; ⋀x xa y Δ C₀ C₁. ⟦x = find_closest_code p₀ δ (v # va); (xa, y) = x; ¬ δ ≤ xa; xa = dist_code p₀ y; (Δ, C₀, C₁) = find_closest_pair_code (xa, p₀, y) (v # va)⟧ ⟹ Δ = dist_code C₀ C₁; δ = dist_code c₀ c₁; (Δ, C₀, C₁) = find_closest_pair_code (δ, c₀, c₁) (p₀ # v # va)⟧ ⟹ Δ = dist_code C₀ C₁›*) case (3 δ c₀ c₁ p₀ p₂ ps) (*‹⟦?x = find_closest_code p₀ δ (p₂ # ps); (?xa, ?y) = ?x; δ ≤ ?xa; δ = dist_code c₀ c₁; (?Δ, ?C₀, ?C₁) = find_closest_pair_code (δ, c₀, c₁) (p₂ # ps)⟧ ⟹ ?Δ = dist_code ?C₀ ?C₁› ‹⟦?x = find_closest_code p₀ δ (p₂ # ps); (?xa, ?y) = ?x; ¬ δ ≤ ?xa; ?xa = dist_code p₀ ?y; (?Δ, ?C₀, ?C₁) = find_closest_pair_code (?xa, p₀, ?y) (p₂ # ps)⟧ ⟹ ?Δ = dist_code ?C₀ ?C₁› ‹δ = dist_code c₀ c₁› ‹(Δ::int, C₀::int × int, C₁::int × int) = find_closest_pair_code (δ::int, c₀::int × int, c₁::int × int) ((p₀::int × int) # (p₂::int × int) # (ps::(int × int) list))›*) obtain δ' and p₁ where "δ'_def": "(δ', p₁) = find_closest_code p₀ δ (p₂ # ps)" (*goal: ‹(⋀(δ''::int) p₁::int × int. (δ'', p₁) = find_closest_code (p₀::int × int) (δ::int) ((p₂::int × int) # (ps::(int × int) list)) ⟹ thesis::bool) ⟹ thesis›*) by (metis surj_pair (*‹∃x y. ?p = (x, y)›*)) hence A: "δ' = dist_code p₀ p₁" using find_closest_code_dist_eq (*‹⟦0 < length ?ps; (?δ⇩c, ?c) = find_closest_code ?p ?δ ?ps⟧ ⟹ ?δ⇩c = dist_code ?p ?c›*) by blast show "?case" (*goal: ‹Δ = dist_code C₀ C₁›*) proof (cases "δ ≤ δ'") (*goals: 1. ‹(δ::int) ≤ (δ'::int) ⟹ (Δ::int) = dist_code (C₀::int × int) (C₁::int × int)› 2. ‹¬ (δ::int) ≤ (δ'::int) ⟹ (Δ::int) = dist_code (C₀::int × int) (C₁::int × int)›*) case True (*‹δ ≤ δ'›*) obtain Δ' and C₀' and C₁' where "Δ'_def": "(Δ', C₀', C₁') = find_closest_pair_code (δ, c₀, c₁) (p₂ # ps)" (*goal: ‹(⋀Δ' C₀' C₁'. (Δ', C₀', C₁') = find_closest_pair_code (δ, c₀, c₁) (p₂ # ps) ⟹ thesis) ⟹ thesis›*) by (metis prod_cases4 (*‹(⋀(a::?'a) (b::?'b) (c::?'c) d::?'d. (?y::?'a × ?'b × ?'c × ?'d) = (a, b, c, d) ⟹ ?thesis::bool) ⟹ ?thesis›*)) note defs = "δ'_def" (*‹(δ'::int, p₁::int × int) = find_closest_code (p₀::int × int) (δ::int) ((p₂::int × int) # (ps::(int × int) list))›*) "Δ'_def" (*‹(Δ', C₀', C₁') = find_closest_pair_code (δ, c₀, c₁) (p₂ # ps)›*) hence "Δ' = dist_code C₀' C₁'" using "3.hyps"(1)[of "(δ', p₁)" δ' p₁] (*‹⟦(δ', p₁) = find_closest_code p₀ δ (p₂ # ps); (δ', p₁) = (δ', p₁); δ ≤ δ'; δ = dist_code c₀ c₁; (?Δ, ?C₀, ?C₁) = find_closest_pair_code (δ, c₀, c₁) (p₂ # ps)⟧ ⟹ ?Δ = dist_code ?C₀ ?C₁›*) "3.prems"(1) (*‹(δ::int) = dist_code (c₀::int × int) (c₁::int × int)›*) True (*‹δ ≤ δ'›*) "δ'_def" (*‹(δ', p₁) = find_closest_code p₀ δ (p₂ # ps)›*) by blast moreover have "Δ = Δ'" "C₀ = C₀'" "C₁ = C₁'" using defs (*‹(δ'::int, p₁::int × int) = find_closest_code (p₀::int × int) (δ::int) ((p₂::int × int) # (ps::(int × int) list))› ‹(Δ', C₀', C₁') = find_closest_pair_code (δ, c₀, c₁) (p₂ # ps)›*) True (*‹δ ≤ δ'›*) "3.prems"(2) (*‹(Δ, C₀, C₁) = find_closest_pair_code (δ, c₀, c₁) (p₀ # p₂ # ps)›*) apply - (*goals: 1. ‹⟦(δ', p₁) = find_closest_code p₀ δ (p₂ # ps); (Δ', C₀', C₁') = find_closest_pair_code (δ, c₀, c₁) (p₂ # ps); δ ≤ δ'; (Δ, C₀, C₁) = find_closest_pair_code (δ, c₀, c₁) (p₀ # p₂ # ps)⟧ ⟹ Δ = Δ'› 2. ‹⟦(δ', p₁) = find_closest_code p₀ δ (p₂ # ps); (Δ', C₀', C₁') = find_closest_pair_code (δ, c₀, c₁) (p₂ # ps); δ ≤ δ'; (Δ, C₀, C₁) = find_closest_pair_code (δ, c₀, c₁) (p₀ # p₂ # ps)⟧ ⟹ C₀ = C₀'› 3. ‹⟦(δ', p₁) = find_closest_code p₀ δ (p₂ # ps); (Δ', C₀', C₁') = find_closest_pair_code (δ, c₀, c₁) (p₂ # ps); δ ≤ δ'; (Δ, C₀, C₁) = find_closest_pair_code (δ, c₀, c₁) (p₀ # p₂ # ps)⟧ ⟹ C₁ = C₁'› discuss goal 1*) apply ((auto 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]) (*top goal: ‹⟦(δ'::int, p₁::int × int) = find_closest_code (p₀::int × int) (δ::int) ((p₂::int × int) # (ps::(int × int) list)); (Δ'::int, C₀'::int × int, C₁'::int × int) = find_closest_pair_code (δ, c₀::int × int, c₁::int × int) (p₂ # ps); δ ≤ δ'; (Δ::int, C₀::int × int, C₁::int × int) = find_closest_pair_code (δ, c₀, c₁) (p₀ # p₂ # ps)⟧ ⟹ Δ = Δ'› and 2 goals remain*) apply (metis Pair_inject (*‹⟦(?a::?'a, ?b::?'b) = (?a'::?'a, ?b'::?'b); ⟦?a = ?a'; ?b = ?b'⟧ ⟹ ?R::bool⟧ ⟹ ?R›*)) (*discuss goal 2*) apply ((auto 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: ‹⟦(δ', p₁) = find_closest_code p₀ δ (p₂ # ps); (Δ', C₀', C₁') = find_closest_pair_code (δ, c₀, c₁) (p₂ # ps); δ ≤ δ'; (Δ, C₀, C₁) = find_closest_pair_code (δ, c₀, c₁) (p₀ # p₂ # ps)⟧ ⟹ C₀ = C₀'› and 1 goal remains*) apply (metis Pair_inject (*‹⟦(?a, ?b) = (?a', ?b'); ⟦?a = ?a'; ?b = ?b'⟧ ⟹ ?R⟧ ⟹ ?R›*)) (*discuss goal 3*) apply ((auto 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]) (*goal: ‹⟦(δ'::int, p₁::int × int) = find_closest_code (p₀::int × int) (δ::int) ((p₂::int × int) # (ps::(int × int) list)); (Δ'::int, C₀'::int × int, C₁'::int × int) = find_closest_pair_code (δ, c₀::int × int, c₁::int × int) (p₂ # ps); δ ≤ δ'; (Δ::int, C₀::int × int, C₁::int × int) = find_closest_pair_code (δ, c₀, c₁) (p₀ # p₂ # ps)⟧ ⟹ C₁ = C₁'›*) apply (metis Pair_inject (*‹⟦(?a, ?b) = (?a', ?b'); ⟦?a = ?a'; ?b = ?b'⟧ ⟹ ?R⟧ ⟹ ?R›*)) (*proven 3 subgoals*) . ultimately show "?thesis" (*goal: ‹Δ = dist_code C₀ C₁›*) by simp next (*goal: ‹¬ δ ≤ δ' ⟹ Δ = dist_code C₀ C₁›*) case False (*‹¬ (δ::int) ≤ (δ'::int)›*) obtain Δ' and C₀' and C₁' where "Δ'_def": "(Δ', C₀', C₁') = find_closest_pair_code (δ', p₀, p₁) (p₂ # ps)" (*goal: ‹(⋀Δ' C₀' C₁'. (Δ', C₀', C₁') = find_closest_pair_code (δ', p₀, p₁) (p₂ # ps) ⟹ thesis) ⟹ thesis›*) by (metis prod_cases4 (*‹(⋀a b c d. ?y = (a, b, c, d) ⟹ ?thesis) ⟹ ?thesis›*)) note defs = "δ'_def" (*‹(δ'::int, p₁::int × int) = find_closest_code (p₀::int × int) (δ::int) ((p₂::int × int) # (ps::(int × int) list))›*) "Δ'_def" (*‹(Δ', C₀', C₁') = find_closest_pair_code (δ', p₀, p₁) (p₂ # ps)›*) hence "Δ' = dist_code C₀' C₁'" using "3.hyps"(2)[of "(δ', p₁)" δ' p₁] (*‹⟦(δ', p₁) = find_closest_code p₀ δ (p₂ # ps); (δ', p₁) = (δ', p₁); ¬ δ ≤ δ'; δ' = dist_code p₀ p₁; (?Δ, ?C₀, ?C₁) = find_closest_pair_code (δ', p₀, p₁) (p₂ # ps)⟧ ⟹ ?Δ = dist_code ?C₀ ?C₁›*) A (*‹δ' = dist_code p₀ p₁›*) False (*‹¬ δ ≤ δ'›*) "δ'_def" (*‹(δ', p₁) = find_closest_code p₀ δ (p₂ # ps)›*) by blast moreover have "Δ = Δ'" "C₀ = C₀'" "C₁ = C₁'" using defs (*‹(δ', p₁) = find_closest_code p₀ δ (p₂ # ps)› ‹(Δ', C₀', C₁') = find_closest_pair_code (δ', p₀, p₁) (p₂ # ps)›*) False (*‹¬ δ ≤ δ'›*) "3.prems"(2) (*‹(Δ, C₀, C₁) = find_closest_pair_code (δ, c₀, c₁) (p₀ # p₂ # ps)›*) apply - (*goals: 1. ‹⟦(δ'::int, p₁::int × int) = find_closest_code (p₀::int × int) (δ::int) ((p₂::int × int) # (ps::(int × int) list)); (Δ'::int, C₀'::int × int, C₁'::int × int) = find_closest_pair_code (δ', p₀, p₁) (p₂ # ps); ¬ δ ≤ δ'; (Δ::int, C₀::int × int, C₁::int × int) = find_closest_pair_code (δ, c₀::int × int, c₁::int × int) (p₀ # p₂ # ps)⟧ ⟹ Δ = Δ'› 2. ‹⟦(δ'::int, p₁::int × int) = find_closest_code (p₀::int × int) (δ::int) ((p₂::int × int) # (ps::(int × int) list)); (Δ'::int, C₀'::int × int, C₁'::int × int) = find_closest_pair_code (δ', p₀, p₁) (p₂ # ps); ¬ δ ≤ δ'; (Δ::int, C₀::int × int, C₁::int × int) = find_closest_pair_code (δ, c₀::int × int, c₁::int × int) (p₀ # p₂ # ps)⟧ ⟹ C₀ = C₀'› 3. ‹⟦(δ'::int, p₁::int × int) = find_closest_code (p₀::int × int) (δ::int) ((p₂::int × int) # (ps::(int × int) list)); (Δ'::int, C₀'::int × int, C₁'::int × int) = find_closest_pair_code (δ', p₀, p₁) (p₂ # ps); ¬ δ ≤ δ'; (Δ::int, C₀::int × int, C₁::int × int) = find_closest_pair_code (δ, c₀::int × int, c₁::int × int) (p₀ # p₂ # ps)⟧ ⟹ C₁ = C₁'› discuss goal 1*) apply ((auto 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: ‹⟦(δ', p₁) = find_closest_code p₀ δ (p₂ # ps); (Δ', C₀', C₁') = find_closest_pair_code (δ', p₀, p₁) (p₂ # ps); ¬ δ ≤ δ'; (Δ, C₀, C₁) = find_closest_pair_code (δ, c₀, c₁) (p₀ # p₂ # ps)⟧ ⟹ Δ = Δ'› and 2 goals remain*) apply (metis Pair_inject (*‹⟦(?a, ?b) = (?a', ?b'); ⟦?a = ?a'; ?b = ?b'⟧ ⟹ ?R⟧ ⟹ ?R›*)) (*discuss goal 2*) apply ((auto 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: ‹⟦(δ', p₁) = find_closest_code p₀ δ (p₂ # ps); (Δ', C₀', C₁') = find_closest_pair_code (δ', p₀, p₁) (p₂ # ps); ¬ δ ≤ δ'; (Δ, C₀, C₁) = find_closest_pair_code (δ, c₀, c₁) (p₀ # p₂ # ps)⟧ ⟹ C₀ = C₀'› and 1 goal remains*) apply (metis Pair_inject (*‹⟦(?a, ?b) = (?a', ?b'); ⟦?a = ?a'; ?b = ?b'⟧ ⟹ ?R⟧ ⟹ ?R›*)) (*discuss goal 3*) apply ((auto 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]) (*goal: ‹⟦(δ'::int, p₁::int × int) = find_closest_code (p₀::int × int) (δ::int) ((p₂::int × int) # (ps::(int × int) list)); (Δ'::int, C₀'::int × int, C₁'::int × int) = find_closest_pair_code (δ', p₀, p₁) (p₂ # ps); ¬ δ ≤ δ'; (Δ::int, C₀::int × int, C₁::int × int) = find_closest_pair_code (δ, c₀::int × int, c₁::int × int) (p₀ # p₂ # ps)⟧ ⟹ C₁ = C₁'›*) apply (metis Pair_inject (*‹⟦(?a, ?b) = (?a', ?b'); ⟦?a = ?a'; ?b = ?b'⟧ ⟹ ?R⟧ ⟹ ?R›*)) (*proven 3 subgoals*) . ultimately show "?thesis" (*goal: ‹Δ = dist_code C₀ C₁›*) by simp qed qed (auto) (*solves the remaining goals: 1. ‹⋀δ c₀ c₁ Δ C₀ C₁. ⟦δ = dist_code c₀ c₁; (Δ, C₀, C₁) = find_closest_pair_code (δ, c₀, c₁) []⟧ ⟹ Δ = dist_code C₀ C₁› 2. ‹⋀δ c₀ c₁ p Δ C₀ C₁. ⟦δ = dist_code c₀ c₁; (Δ, C₀, C₁) = find_closest_pair_code (δ, c₀, c₁) [p]⟧ ⟹ Δ = dist_code C₀ C₁›*) declare find_closest_pair.simps [simp add] lemma find_closest_pair_code_eq: assumes "δ = dist c₀ c₁" "δ' = dist_code c₀ c₁" "sorted_snd ps" assumes "(C₀, C₁) = find_closest_pair (c₀, c₁) ps" assumes "(Δ', C₀', C₁') = find_closest_pair_code (δ', c₀, c₁) ps" shows "C₀ = C₀' ∧ C₁ = C₁'" using assms (*‹δ = dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y))› ‹δ' = dist_code c₀ c₁› ‹sorted_snd ps› ‹(C₀, C₁) = find_closest_pair (c₀, c₁) ps› ‹(Δ', C₀', C₁') = find_closest_pair_code (δ', c₀, c₁) ps›*) proof (induction "(c₀, c₁)" ps arbitrary: δ δ' c₀ c₁ C₀ C₁ Δ' C₀' C₁' rule: find_closest_pair.induct) (*goals: 1. ‹⋀c₀ c₁ δ δ' C₀ C₁ Δ' C₀' C₁'. ⟦δ = dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y)); δ' = dist_code c₀ c₁; sorted_snd []; (C₀, C₁) = find_closest_pair (c₀, c₁) []; (Δ', C₀', C₁') = find_closest_pair_code (δ', c₀, c₁) []⟧ ⟹ C₀ = C₀' ∧ C₁ = C₁'› 2. ‹⋀c₀ c₁ uu_ δ δ' C₀ C₁ Δ' C₀' C₁'. ⟦δ = dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y)); δ' = dist_code c₀ c₁; sorted_snd [uu_]; (C₀, C₁) = find_closest_pair (c₀, c₁) [uu_]; (Δ', C₀', C₁') = find_closest_pair_code (δ', c₀, c₁) [uu_]⟧ ⟹ C₀ = C₀' ∧ C₁ = C₁'› 3. ‹⋀c₀ c₁ p₀ v va δ δ' C₀ C₁ Δ' C₀' C₁'. ⟦⋀x δ δ' C₀ C₁ Δ' C₀' C₁'. ⟦x = find_closest p₀ (dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y))) (v # va); dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y)) ≤ dist (case p₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case x of (x, y) ⇒ (real_of_int x, real_of_int y)); δ = dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y)); δ' = dist_code c₀ c₁; sorted_snd (v # va); (C₀, C₁) = find_closest_pair (c₀, c₁) (v # va); (Δ', C₀', C₁') = find_closest_pair_code (δ', c₀, c₁) (v # va)⟧ ⟹ C₀ = C₀' ∧ C₁ = C₁'; ⋀x δ δ' C₀ C₁ Δ' C₀' C₁'. ⟦x = find_closest p₀ (dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y))) (v # va); ¬ dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y)) ≤ dist (case p₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case x of (x, y) ⇒ (real_of_int x, real_of_int y)); δ = dist (case p₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case x of (x, y) ⇒ (real_of_int x, real_of_int y)); δ' = dist_code p₀ x; sorted_snd (v # va); (C₀, C₁) = find_closest_pair (p₀, x) (v # va); (Δ', C₀', C₁') = find_closest_pair_code (δ', p₀, x) (v # va)⟧ ⟹ C₀ = C₀' ∧ C₁ = C₁'; δ = dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y)); δ' = dist_code c₀ c₁; sorted_snd (p₀ # v # va); (C₀, C₁) = find_closest_pair (c₀, c₁) (p₀ # v # va); (Δ', C₀', C₁') = find_closest_pair_code (δ', c₀, c₁) (p₀ # v # va)⟧ ⟹ C₀ = C₀' ∧ C₁ = C₁'›*) case (3 c₀ c₁ p₀ p₂ ps) (*‹⟦?x = find_closest p₀ (dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y))) (p₂ # ps); dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y)) ≤ dist (case p₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case ?x of (x, y) ⇒ (real_of_int x, real_of_int y)); ?δ = dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y)); ?δ' = dist_code c₀ c₁; sorted_snd (p₂ # ps); (?C₀, ?C₁) = find_closest_pair (c₀, c₁) (p₂ # ps); (?Δ', ?C₀', ?C₁') = find_closest_pair_code (?δ', c₀, c₁) (p₂ # ps)⟧ ⟹ ?C₀ = ?C₀' ∧ ?C₁ = ?C₁'› ‹⟦?x = find_closest p₀ (dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y))) (p₂ # ps); ¬ dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y)) ≤ dist (case p₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case ?x of (x, y) ⇒ (real_of_int x, real_of_int y)); ?δ = dist (case p₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case ?x of (x, y) ⇒ (real_of_int x, real_of_int y)); ?δ' = dist_code p₀ ?x; sorted_snd (p₂ # ps); (?C₀, ?C₁) = find_closest_pair (p₀, ?x) (p₂ # ps); (?Δ', ?C₀', ?C₁') = find_closest_pair_code (?δ', p₀, ?x) (p₂ # ps)⟧ ⟹ ?C₀ = ?C₀' ∧ ?C₁ = ?C₁'› ‹δ = dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y))› ‹δ' = dist_code c₀ c₁› ‹sorted_snd (p₀ # p₂ # ps)› ‹(C₀, C₁) = find_closest_pair (c₀, c₁) (p₀ # p₂ # ps)› ‹(Δ', C₀', C₁') = find_closest_pair_code (δ', c₀, c₁) (p₀ # p₂ # ps)›*) obtain p₁ and δ⇩p' and p₁' where "δ⇩p_def": "p₁ = find_closest p₀ δ (p₂ # ps)" "(δ⇩p', p₁') = find_closest_code p₀ δ' (p₂ # ps)" (*goal: ‹(⋀p₁ δ⇩p' p₁'. ⟦p₁ = find_closest p₀ δ (p₂ # ps); (δ⇩p', p₁') = find_closest_code p₀ δ' (p₂ # ps)⟧ ⟹ thesis) ⟹ thesis›*) by (metis surj_pair (*‹∃x y. ?p = (x, y)›*)) hence A: "δ⇩p' = dist_code p₀ p₁'" using find_closest_code_dist_eq (*‹⟦0 < length ?ps; (?δ⇩c, ?c) = find_closest_code ?p ?δ ?ps⟧ ⟹ ?δ⇩c = dist_code ?p ?c›*) by blast have B: "p₁ = p₁'" using "3.prems"(1,2,3) (*‹(δ::real) = dist (case c₀::int × int of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) (case c₁::int × int of (x::int, y::int) ⇒ (real_of_int x, real_of_int y))› ‹δ' = dist_code c₀ c₁› ‹sorted_snd (p₀ # p₂ # ps)›*) "δ⇩p_def" (*‹p₁ = find_closest p₀ δ (p₂ # ps)› ‹(δ⇩p', p₁') = find_closest_code p₀ δ' (p₂ # ps)›*) find_closest_code_eq (*‹⟦0 < length ?ps; ?δ = dist (case ?c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case ?c₁ of (x, y) ⇒ (real_of_int x, real_of_int y)); ?δ' = dist_code ?c₀ ?c₁; sorted_snd (?p # ?ps); ?c = find_closest ?p ?δ ?ps; (?δ⇩c', ?c') = find_closest_code ?p ?δ' ?ps⟧ ⟹ ?c = ?c'›*) by blast show "?case" (*goal: ‹C₀ = C₀' ∧ C₁ = C₁'›*) proof (cases "δ ≤ dist p₀ p₁") (*goals: 1. ‹δ ≤ dist (case p₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₁ of (x, y) ⇒ (real_of_int x, real_of_int y)) ⟹ C₀ = C₀' ∧ C₁ = C₁'› 2. ‹¬ δ ≤ dist (case p₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₁ of (x, y) ⇒ (real_of_int x, real_of_int y)) ⟹ C₀ = C₀' ∧ C₁ = C₁'›*) case True (*‹δ ≤ dist (case p₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₁ of (x, y) ⇒ (real_of_int x, real_of_int y))›*) hence C: "δ' ≤ δ⇩p'" by (simp add: "3.prems" (*‹δ = dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y))› ‹δ' = dist_code c₀ c₁›*) (1,2) A (*‹δ⇩p' = dist_code p₀ p₁'›*) B (*‹p₁ = p₁'›*) dist_eq_dist_code_le (*‹(dist (case ?p₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case ?p₁ of (x, y) ⇒ (real_of_int x, real_of_int y)) ≤ dist (case ?p₂ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case ?p₃ of (x, y) ⇒ (real_of_int x, real_of_int y))) = (dist_code ?p₀ ?p₁ ≤ dist_code ?p₂ ?p₃)›*)) obtain C₀⇩i and C₁⇩i and Δ⇩i' and C₀⇩i' and C₁⇩i' where "Δ⇩i_def": "(C₀⇩i, C₁⇩i) = find_closest_pair (c₀, c₁) (p₂ # ps)" "(Δ⇩i', C₀⇩i', C₁⇩i') = find_closest_pair_code (δ', c₀, c₁) (p₂ # ps)" (*goal: ‹(⋀C₀⇩i C₁⇩i Δ⇩i' C₀⇩i' C₁⇩i'. ⟦(C₀⇩i, C₁⇩i) = find_closest_pair (c₀, c₁) (p₂ # ps); (Δ⇩i', C₀⇩i', C₁⇩i') = find_closest_pair_code (δ', c₀, c₁) (p₂ # ps)⟧ ⟹ thesis) ⟹ thesis›*) by (metis prod_cases3 (*‹(⋀a b c. ?y = (a, b, c) ⟹ ?thesis) ⟹ ?thesis›*)) note defs = "δ⇩p_def" (*‹p₁ = find_closest p₀ δ (p₂ # ps)› ‹(δ⇩p', p₁') = find_closest_code p₀ δ' (p₂ # ps)›*) "Δ⇩i_def" (*‹(C₀⇩i, C₁⇩i) = find_closest_pair (c₀, c₁) (p₂ # ps)› ‹(Δ⇩i', C₀⇩i', C₁⇩i') = find_closest_pair_code (δ', c₀, c₁) (p₂ # ps)›*) have "sorted_snd (p₂ # ps)" using "3.prems"(3) (*‹sorted_snd (p₀ # p₂ # ps)›*) sorted_snd_def (*‹sorted_snd ?ps = sorted_wrt (λp₀ p₁. snd p₀ ≤ snd p₁) ?ps›*) by simp hence "C₀⇩i = C₀⇩i' ∧ C₁⇩i = C₁⇩i'" using "3.hyps"(1) (*‹⟦?x = find_closest p₀ (dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y))) (p₂ # ps); dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y)) ≤ dist (case p₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case ?x of (x, y) ⇒ (real_of_int x, real_of_int y)); ?δ = dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y)); ?δ' = dist_code c₀ c₁; sorted_snd (p₂ # ps); (?C₀, ?C₁) = find_closest_pair (c₀, c₁) (p₂ # ps); (?Δ', ?C₀', ?C₁') = find_closest_pair_code (?δ', c₀, c₁) (p₂ # ps)⟧ ⟹ ?C₀ = ?C₀' ∧ ?C₁ = ?C₁'›*) "3.prems"(1,2) (*‹δ = dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y))› ‹δ' = dist_code c₀ c₁›*) True (*‹δ ≤ dist (case p₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₁ of (x, y) ⇒ (real_of_int x, real_of_int y))›*) defs (*‹p₁ = find_closest p₀ δ (p₂ # ps)› ‹(δ⇩p', p₁') = find_closest_code p₀ δ' (p₂ # ps)› ‹(C₀⇩i, C₁⇩i) = find_closest_pair (c₀, c₁) (p₂ # ps)› ‹(Δ⇩i', C₀⇩i', C₁⇩i') = find_closest_pair_code (δ', c₀, c₁) (p₂ # ps)›*) by blast moreover have "C₀ = C₀⇩i" "C₁ = C₁⇩i" using defs(1,3) (*‹p₁ = find_closest p₀ δ (p₂ # ps)› ‹(C₀⇩i, C₁⇩i) = find_closest_pair (c₀, c₁) (p₂ # ps)›*) True (*‹δ ≤ dist (case p₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₁ of (x, y) ⇒ (real_of_int x, real_of_int y))›*) "3.prems"(1,4) (*‹δ = dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y))› ‹(C₀, C₁) = find_closest_pair (c₀, c₁) (p₀ # p₂ # ps)›*) apply - (*goals: 1. ‹⟦(p₁::int × int) = find_closest (p₀::int × int) (δ::real) ((p₂::int × int) # (ps::(int × int) list)); (C₀⇩i::int × int, C₁⇩i::int × int) = find_closest_pair (c₀::int × int, c₁::int × int) (p₂ # ps); δ ≤ dist (case p₀ of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) (case p₁ of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)); δ = dist (case c₀ of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)); (C₀::int × int, C₁::int × int) = find_closest_pair (c₀, c₁) (p₀ # p₂ # ps)⟧ ⟹ C₀ = C₀⇩i› 2. ‹⟦(p₁::int × int) = find_closest (p₀::int × int) (δ::real) ((p₂::int × int) # (ps::(int × int) list)); (C₀⇩i::int × int, C₁⇩i::int × int) = find_closest_pair (c₀::int × int, c₁::int × int) (p₂ # ps); δ ≤ dist (case p₀ of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) (case p₁ of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)); δ = dist (case c₀ of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)); (C₀::int × int, C₁::int × int) = find_closest_pair (c₀, c₁) (p₀ # p₂ # ps)⟧ ⟹ C₁ = C₁⇩i› discuss goal 1*) apply ((auto 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: ‹⟦(p₁::int × int) = find_closest (p₀::int × int) (δ::real) ((p₂::int × int) # (ps::(int × int) list)); (C₀⇩i::int × int, C₁⇩i::int × int) = find_closest_pair (c₀::int × int, c₁::int × int) (p₂ # ps); δ ≤ dist (case p₀ of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) (case p₁ of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)); δ = dist (case c₀ of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)); (C₀::int × int, C₁::int × int) = find_closest_pair (c₀, c₁) (p₀ # p₂ # ps)⟧ ⟹ C₀ = C₀⇩i› and 1 goal remains*) apply (metis Pair_inject (*‹⟦(?a, ?b) = (?a', ?b'); ⟦?a = ?a'; ?b = ?b'⟧ ⟹ ?R⟧ ⟹ ?R›*)) (*discuss goal 2*) apply ((auto 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]) (*goal: ‹⟦(p₁::int × int) = find_closest (p₀::int × int) (δ::real) ((p₂::int × int) # (ps::(int × int) list)); (C₀⇩i::int × int, C₁⇩i::int × int) = find_closest_pair (c₀::int × int, c₁::int × int) (p₂ # ps); δ ≤ dist (case p₀ of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) (case p₁ of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)); δ = dist (case c₀ of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)); (C₀::int × int, C₁::int × int) = find_closest_pair (c₀, c₁) (p₀ # p₂ # ps)⟧ ⟹ C₁ = C₁⇩i›*) apply (metis Pair_inject (*‹⟦(?a, ?b) = (?a', ?b'); ⟦?a = ?a'; ?b = ?b'⟧ ⟹ ?R⟧ ⟹ ?R›*)) (*proven 2 subgoals*) . moreover have "Δ' = Δ⇩i'" "C₀' = C₀⇩i'" "C₁' = C₁⇩i'" using defs(2,4) (*‹(δ⇩p', p₁') = find_closest_code p₀ δ' (p₂ # ps)› ‹(Δ⇩i', C₀⇩i', C₁⇩i') = find_closest_pair_code (δ', c₀, c₁) (p₂ # ps)›*) C (*‹δ' ≤ δ⇩p'›*) "3.prems"(5) (*‹(Δ', C₀', C₁') = find_closest_pair_code (δ', c₀, c₁) (p₀ # p₂ # ps)›*) apply - (*goals: 1. ‹⟦(δ⇩p'::int, p₁'::int × int) = find_closest_code (p₀::int × int) (δ'::int) ((p₂::int × int) # (ps::(int × int) list)); (Δ⇩i'::int, C₀⇩i'::int × int, C₁⇩i'::int × int) = find_closest_pair_code (δ', c₀::int × int, c₁::int × int) (p₂ # ps); δ' ≤ δ⇩p'; (Δ'::int, C₀'::int × int, C₁'::int × int) = find_closest_pair_code (δ', c₀, c₁) (p₀ # p₂ # ps)⟧ ⟹ Δ' = Δ⇩i'› 2. ‹⟦(δ⇩p'::int, p₁'::int × int) = find_closest_code (p₀::int × int) (δ'::int) ((p₂::int × int) # (ps::(int × int) list)); (Δ⇩i'::int, C₀⇩i'::int × int, C₁⇩i'::int × int) = find_closest_pair_code (δ', c₀::int × int, c₁::int × int) (p₂ # ps); δ' ≤ δ⇩p'; (Δ'::int, C₀'::int × int, C₁'::int × int) = find_closest_pair_code (δ', c₀, c₁) (p₀ # p₂ # ps)⟧ ⟹ C₀' = C₀⇩i'› 3. ‹⟦(δ⇩p'::int, p₁'::int × int) = find_closest_code (p₀::int × int) (δ'::int) ((p₂::int × int) # (ps::(int × int) list)); (Δ⇩i'::int, C₀⇩i'::int × int, C₁⇩i'::int × int) = find_closest_pair_code (δ', c₀::int × int, c₁::int × int) (p₂ # ps); δ' ≤ δ⇩p'; (Δ'::int, C₀'::int × int, C₁'::int × int) = find_closest_pair_code (δ', c₀, c₁) (p₀ # p₂ # ps)⟧ ⟹ C₁' = C₁⇩i'› discuss goal 1*) apply ((auto 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: ‹⟦(δ⇩p', p₁') = find_closest_code p₀ δ' (p₂ # ps); (Δ⇩i', C₀⇩i', C₁⇩i') = find_closest_pair_code (δ', c₀, c₁) (p₂ # ps); δ' ≤ δ⇩p'; (Δ', C₀', C₁') = find_closest_pair_code (δ', c₀, c₁) (p₀ # p₂ # ps)⟧ ⟹ Δ' = Δ⇩i'› and 2 goals remain*) apply (metis Pair_inject (*‹⟦(?a, ?b) = (?a', ?b'); ⟦?a = ?a'; ?b = ?b'⟧ ⟹ ?R⟧ ⟹ ?R›*)) (*discuss goal 2*) apply ((auto 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: ‹⟦(δ⇩p', p₁') = find_closest_code p₀ δ' (p₂ # ps); (Δ⇩i', C₀⇩i', C₁⇩i') = find_closest_pair_code (δ', c₀, c₁) (p₂ # ps); δ' ≤ δ⇩p'; (Δ', C₀', C₁') = find_closest_pair_code (δ', c₀, c₁) (p₀ # p₂ # ps)⟧ ⟹ C₀' = C₀⇩i'› and 1 goal remains*) apply (metis Pair_inject (*‹⟦(?a::?'a::type, ?b::?'b::type) = (?a'::?'a::type, ?b'::?'b::type); ⟦?a = ?a'; ?b = ?b'⟧ ⟹ ?R::bool⟧ ⟹ ?R›*)) (*discuss goal 3*) apply ((auto 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]) (*goal: ‹⟦(δ⇩p'::int, p₁'::int × int) = find_closest_code (p₀::int × int) (δ'::int) ((p₂::int × int) # (ps::(int × int) list)); (Δ⇩i'::int, C₀⇩i'::int × int, C₁⇩i'::int × int) = find_closest_pair_code (δ', c₀::int × int, c₁::int × int) (p₂ # ps); δ' ≤ δ⇩p'; (Δ'::int, C₀'::int × int, C₁'::int × int) = find_closest_pair_code (δ', c₀, c₁) (p₀ # p₂ # ps)⟧ ⟹ C₁' = C₁⇩i'›*) apply (metis Pair_inject (*‹⟦(?a, ?b) = (?a', ?b'); ⟦?a = ?a'; ?b = ?b'⟧ ⟹ ?R⟧ ⟹ ?R›*)) (*proven 3 subgoals*) . ultimately show "?thesis" (*goal: ‹C₀ = C₀' ∧ C₁ = C₁'›*) by simp next (*goal: ‹¬ (δ::real) ≤ dist (case p₀::int × int of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) (case p₁::int × int of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) ⟹ (C₀::int × int) = (C₀'::int × int) ∧ (C₁::int × int) = (C₁'::int × int)›*) case False (*‹¬ δ ≤ dist (case p₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₁ of (x, y) ⇒ (real_of_int x, real_of_int y))›*) hence C: "¬ δ' ≤ δ⇩p'" by (simp add: "3.prems" (*‹δ = dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y))› ‹δ' = dist_code c₀ c₁›*) (1,2) A (*‹δ⇩p' = dist_code p₀ p₁'›*) B (*‹p₁ = p₁'›*) dist_eq_dist_code_le (*‹(dist (case ?p₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case ?p₁ of (x, y) ⇒ (real_of_int x, real_of_int y)) ≤ dist (case ?p₂ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case ?p₃ of (x, y) ⇒ (real_of_int x, real_of_int y))) = (dist_code ?p₀ ?p₁ ≤ dist_code ?p₂ ?p₃)›*)) obtain C₀⇩i and C₁⇩i and Δ⇩i' and C₀⇩i' and C₁⇩i' where "Δ⇩i_def": "(C₀⇩i, C₁⇩i) = find_closest_pair (p₀, p₁) (p₂ # ps)" "(Δ⇩i', C₀⇩i', C₁⇩i') = find_closest_pair_code (δ⇩p', p₀, p₁') (p₂ # ps)" (*goal: ‹(⋀(C₀⇩i::int × int) (C₁⇩i::int × int) (Δ⇩i'::int) (C₀⇩i'::int × int) C₁⇩i'::int × int. ⟦(C₀⇩i, C₁⇩i) = find_closest_pair (p₀::int × int, p₁::int × int) ((p₂::int × int) # (ps::(int × int) list)); (Δ⇩i', C₀⇩i', C₁⇩i') = find_closest_pair_code (δ⇩p'::int, p₀, p₁'::int × int) (p₂ # ps)⟧ ⟹ thesis::bool) ⟹ thesis›*) by (metis prod_cases3 (*‹(⋀(a::?'a::type) (b::?'b::type) c::?'c::type. (?y::?'a::type × ?'b::type × ?'c::type) = (a, b, c) ⟹ ?thesis::bool) ⟹ ?thesis›*)) note defs = "δ⇩p_def" (*‹p₁ = find_closest p₀ δ (p₂ # ps)› ‹(δ⇩p', p₁') = find_closest_code p₀ δ' (p₂ # ps)›*) "Δ⇩i_def" (*‹(C₀⇩i, C₁⇩i) = find_closest_pair (p₀, p₁) (p₂ # ps)› ‹(Δ⇩i', C₀⇩i', C₁⇩i') = find_closest_pair_code (δ⇩p', p₀, p₁') (p₂ # ps)›*) have "sorted_snd (p₂ # ps)" using "3.prems"(3) (*‹sorted_snd (p₀ # p₂ # ps)›*) sorted_snd_def (*‹sorted_snd ?ps = sorted_wrt (λp₀ p₁. snd p₀ ≤ snd p₁) ?ps›*) by simp hence "C₀⇩i = C₀⇩i' ∧ C₁⇩i = C₁⇩i'" using "3.prems"(1) (*‹δ = dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y))›*) "3.hyps"(2) (*‹⟦?x = find_closest p₀ (dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y))) (p₂ # ps); ¬ dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y)) ≤ dist (case p₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case ?x of (x, y) ⇒ (real_of_int x, real_of_int y)); ?δ = dist (case p₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case ?x of (x, y) ⇒ (real_of_int x, real_of_int y)); ?δ' = dist_code p₀ ?x; sorted_snd (p₂ # ps); (?C₀, ?C₁) = find_closest_pair (p₀, ?x) (p₂ # ps); (?Δ', ?C₀', ?C₁') = find_closest_pair_code (?δ', p₀, ?x) (p₂ # ps)⟧ ⟹ ?C₀ = ?C₀' ∧ ?C₁ = ?C₁'›*) A (*‹δ⇩p' = dist_code p₀ p₁'›*) B (*‹p₁ = p₁'›*) False (*‹¬ δ ≤ dist (case p₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₁ of (x, y) ⇒ (real_of_int x, real_of_int y))›*) defs (*‹p₁ = find_closest p₀ δ (p₂ # ps)› ‹(δ⇩p', p₁') = find_closest_code p₀ δ' (p₂ # ps)› ‹(C₀⇩i, C₁⇩i) = find_closest_pair (p₀, p₁) (p₂ # ps)› ‹(Δ⇩i', C₀⇩i', C₁⇩i') = find_closest_pair_code (δ⇩p', p₀, p₁') (p₂ # ps)›*) by blast moreover have "C₀ = C₀⇩i" "C₁ = C₁⇩i" using defs(1,3) (*‹p₁ = find_closest p₀ δ (p₂ # ps)› ‹(C₀⇩i, C₁⇩i) = find_closest_pair (p₀, p₁) (p₂ # ps)›*) False (*‹¬ (δ::real) ≤ dist (case p₀::int × int of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) (case p₁::int × int of (x::int, y::int) ⇒ (real_of_int x, real_of_int y))›*) "3.prems"(1,4) (*‹δ = dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y))› ‹(C₀, C₁) = find_closest_pair (c₀, c₁) (p₀ # p₂ # ps)›*) apply - (*goals: 1. ‹⟦p₁ = find_closest p₀ δ (p₂ # ps); (C₀⇩i, C₁⇩i) = find_closest_pair (p₀, p₁) (p₂ # ps); ¬ δ ≤ dist (case p₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₁ of (x, y) ⇒ (real_of_int x, real_of_int y)); δ = dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y)); (C₀, C₁) = find_closest_pair (c₀, c₁) (p₀ # p₂ # ps)⟧ ⟹ C₀ = C₀⇩i› 2. ‹⟦p₁ = find_closest p₀ δ (p₂ # ps); (C₀⇩i, C₁⇩i) = find_closest_pair (p₀, p₁) (p₂ # ps); ¬ δ ≤ dist (case p₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₁ of (x, y) ⇒ (real_of_int x, real_of_int y)); δ = dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y)); (C₀, C₁) = find_closest_pair (c₀, c₁) (p₀ # p₂ # ps)⟧ ⟹ C₁ = C₁⇩i› discuss goal 1*) apply ((auto 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: ‹⟦(p₁::int × int) = find_closest (p₀::int × int) (δ::real) ((p₂::int × int) # (ps::(int × int) list)); (C₀⇩i::int × int, C₁⇩i::int × int) = find_closest_pair (p₀, p₁) (p₂ # ps); ¬ δ ≤ dist (case p₀ of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) (case p₁ of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)); δ = dist (case c₀::int × int of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) (case c₁::int × int of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)); (C₀::int × int, C₁::int × int) = find_closest_pair (c₀, c₁) (p₀ # p₂ # ps)⟧ ⟹ C₀ = C₀⇩i› and 1 goal remains*) apply (metis Pair_inject (*‹⟦(?a, ?b) = (?a', ?b'); ⟦?a = ?a'; ?b = ?b'⟧ ⟹ ?R⟧ ⟹ ?R›*)) (*discuss goal 2*) apply ((auto 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]) (*goal: ‹⟦p₁ = find_closest p₀ δ (p₂ # ps); (C₀⇩i, C₁⇩i) = find_closest_pair (p₀, p₁) (p₂ # ps); ¬ δ ≤ dist (case p₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₁ of (x, y) ⇒ (real_of_int x, real_of_int y)); δ = dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y)); (C₀, C₁) = find_closest_pair (c₀, c₁) (p₀ # p₂ # ps)⟧ ⟹ C₁ = C₁⇩i›*) apply (metis Pair_inject (*‹⟦(?a, ?b) = (?a', ?b'); ⟦?a = ?a'; ?b = ?b'⟧ ⟹ ?R⟧ ⟹ ?R›*)) (*proven 2 subgoals*) . moreover have "Δ' = Δ⇩i'" "C₀' = C₀⇩i'" "C₁' = C₁⇩i'" using defs(2,4) (*‹(δ⇩p', p₁') = find_closest_code p₀ δ' (p₂ # ps)› ‹(Δ⇩i', C₀⇩i', C₁⇩i') = find_closest_pair_code (δ⇩p', p₀, p₁') (p₂ # ps)›*) C (*‹¬ δ' ≤ δ⇩p'›*) "3.prems"(5) (*‹(Δ', C₀', C₁') = find_closest_pair_code (δ', c₀, c₁) (p₀ # p₂ # ps)›*) apply - (*goals: 1. ‹⟦(δ⇩p', p₁') = find_closest_code p₀ δ' (p₂ # ps); (Δ⇩i', C₀⇩i', C₁⇩i') = find_closest_pair_code (δ⇩p', p₀, p₁') (p₂ # ps); ¬ δ' ≤ δ⇩p'; (Δ', C₀', C₁') = find_closest_pair_code (δ', c₀, c₁) (p₀ # p₂ # ps)⟧ ⟹ Δ' = Δ⇩i'› 2. ‹⟦(δ⇩p', p₁') = find_closest_code p₀ δ' (p₂ # ps); (Δ⇩i', C₀⇩i', C₁⇩i') = find_closest_pair_code (δ⇩p', p₀, p₁') (p₂ # ps); ¬ δ' ≤ δ⇩p'; (Δ', C₀', C₁') = find_closest_pair_code (δ', c₀, c₁) (p₀ # p₂ # ps)⟧ ⟹ C₀' = C₀⇩i'› 3. ‹⟦(δ⇩p', p₁') = find_closest_code p₀ δ' (p₂ # ps); (Δ⇩i', C₀⇩i', C₁⇩i') = find_closest_pair_code (δ⇩p', p₀, p₁') (p₂ # ps); ¬ δ' ≤ δ⇩p'; (Δ', C₀', C₁') = find_closest_pair_code (δ', c₀, c₁) (p₀ # p₂ # ps)⟧ ⟹ C₁' = C₁⇩i'› discuss goal 1*) apply ((auto 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: ‹⟦(δ⇩p', p₁') = find_closest_code p₀ δ' (p₂ # ps); (Δ⇩i', C₀⇩i', C₁⇩i') = find_closest_pair_code (δ⇩p', p₀, p₁') (p₂ # ps); ¬ δ' ≤ δ⇩p'; (Δ', C₀', C₁') = find_closest_pair_code (δ', c₀, c₁) (p₀ # p₂ # ps)⟧ ⟹ Δ' = Δ⇩i'› and 2 goals remain*) apply (metis Pair_inject (*‹⟦(?a, ?b) = (?a', ?b'); ⟦?a = ?a'; ?b = ?b'⟧ ⟹ ?R⟧ ⟹ ?R›*)) (*discuss goal 2*) apply ((auto 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: ‹⟦(δ⇩p', p₁') = find_closest_code p₀ δ' (p₂ # ps); (Δ⇩i', C₀⇩i', C₁⇩i') = find_closest_pair_code (δ⇩p', p₀, p₁') (p₂ # ps); ¬ δ' ≤ δ⇩p'; (Δ', C₀', C₁') = find_closest_pair_code (δ', c₀, c₁) (p₀ # p₂ # ps)⟧ ⟹ C₀' = C₀⇩i'› and 1 goal remains*) apply (metis Pair_inject (*‹⟦(?a, ?b) = (?a', ?b'); ⟦?a = ?a'; ?b = ?b'⟧ ⟹ ?R⟧ ⟹ ?R›*)) (*discuss goal 3*) apply ((auto 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]) (*goal: ‹⟦(δ⇩p', p₁') = find_closest_code p₀ δ' (p₂ # ps); (Δ⇩i', C₀⇩i', C₁⇩i') = find_closest_pair_code (δ⇩p', p₀, p₁') (p₂ # ps); ¬ δ' ≤ δ⇩p'; (Δ', C₀', C₁') = find_closest_pair_code (δ', c₀, c₁) (p₀ # p₂ # ps)⟧ ⟹ C₁' = C₁⇩i'›*) apply (metis Pair_inject (*‹⟦(?a::?'a, ?b::?'b) = (?a'::?'a, ?b'::?'b); ⟦?a = ?a'; ?b = ?b'⟧ ⟹ ?R::bool⟧ ⟹ ?R›*)) (*proven 3 subgoals*) . ultimately show "?thesis" (*goal: ‹C₀ = C₀' ∧ C₁ = C₁'›*) by simp qed qed (auto) (*solves the remaining goals: 1. ‹⋀c₀ c₁ δ δ' C₀ C₁ Δ' C₀' C₁'. ⟦δ = dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y)); δ' = dist_code c₀ c₁; sorted_snd []; (C₀, C₁) = find_closest_pair (c₀, c₁) []; (Δ', C₀', C₁') = find_closest_pair_code (δ', c₀, c₁) []⟧ ⟹ C₀ = C₀' ∧ C₁ = C₁'› 2. ‹⋀c₀ c₁ uu_ δ δ' C₀ C₁ Δ' C₀' C₁'. ⟦δ = dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y)); δ' = dist_code c₀ c₁; sorted_snd [uu_]; (C₀, C₁) = find_closest_pair (c₀, c₁) [uu_]; (Δ', C₀', C₁') = find_closest_pair_code (δ', c₀, c₁) [uu_]⟧ ⟹ C₀ = C₀' ∧ C₁ = C₁'›*) fun combine_code :: "(int * point * point) ⇒ (int * point * point) ⇒ int ⇒ point list ⇒ (int * point * point)" where "combine_code (δ⇩L, p₀⇩L, p₁⇩L) (δ⇩R, p₀⇩R, p₁⇩R) l ps = ( let (δ, c₀, c₁) = if δ⇩L < δ⇩R then (δ⇩L, p₀⇩L, p₁⇩L) else (δ⇩R, p₀⇩R, p₁⇩R) in let ps' = filter (λp. (fst p - l)² < δ) ps in find_closest_pair_code (δ, c₀, c₁) ps' )" lemma combine_code_dist_eq: assumes "δ⇩L = dist_code p₀⇩L p₁⇩L" "δ⇩R = dist_code p₀⇩R p₁⇩R" assumes "(δ, c₀, c₁) = combine_code (δ⇩L, p₀⇩L, p₁⇩L) (δ⇩R, p₀⇩R, p₁⇩R) l ps" shows "δ = dist_code c₀ c₁" using assms (*‹δ⇩L = dist_code p₀⇩L p₁⇩L› ‹δ⇩R = dist_code p₀⇩R p₁⇩R› ‹(δ::int, c₀::int × int, c₁::int × int) = combine_code (δ⇩L::int, p₀⇩L::int × int, p₁⇩L::int × int) (δ⇩R::int, p₀⇩R::int × int, p₁⇩R::int × int) (l::int) (ps::(int × int) list)›*) by (auto simp: find_closest_pair_code_dist_eq (*‹⟦?δ = dist_code ?c₀ ?c₁; (?Δ, ?C₀, ?C₁) = find_closest_pair_code (?δ, ?c₀, ?c₁) ?ps⟧ ⟹ ?Δ = dist_code ?C₀ ?C₁›*) 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 combine_code_eq: assumes "δ⇩L' = dist_code p₀⇩L p₁⇩L" "δ⇩R' = dist_code p₀⇩R p₁⇩R" "sorted_snd ps" assumes "(c₀, c₁) = combine (p₀⇩L, p₁⇩L) (p₀⇩R, p₁⇩R) l ps" assumes "(δ', c₀', c₁') = combine_code (δ⇩L', p₀⇩L, p₁⇩L) (δ⇩R', p₀⇩R, p₁⇩R) l ps" shows "c₀ = c₀' ∧ c₁ = c₁'" proof (-) (*goal: ‹(c₀::int × int) = (c₀'::int × int) ∧ (c₁::int × int) = (c₁'::int × int)›*) obtain C₀⇩i and C₁⇩i and Δ⇩i' and C₀⇩i' and C₁⇩i' where "Δ⇩i_def": "(C₀⇩i, C₁⇩i) = (if dist p₀⇩L p₁⇩L < dist p₀⇩R p₁⇩R then (p₀⇩L, p₁⇩L) else (p₀⇩R, p₁⇩R))" "(Δ⇩i', C₀⇩i', C₁⇩i') = (if δ⇩L' < δ⇩R' then (δ⇩L', p₀⇩L, p₁⇩L) else (δ⇩R', p₀⇩R, p₁⇩R))" (*goal: ‹(⋀C₀⇩i C₁⇩i Δ⇩i' C₀⇩i' C₁⇩i'. ⟦(C₀⇩i, C₁⇩i) = (if dist (case p₀⇩L of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₁⇩L of (x, y) ⇒ (real_of_int x, real_of_int y)) < dist (case p₀⇩R of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₁⇩R of (x, y) ⇒ (real_of_int x, real_of_int y)) then (p₀⇩L, p₁⇩L) else (p₀⇩R, p₁⇩R)); (Δ⇩i', C₀⇩i', C₁⇩i') = (if δ⇩L' < δ⇩R' then (δ⇩L', p₀⇩L, p₁⇩L) else (δ⇩R', p₀⇩R, p₁⇩R))⟧ ⟹ thesis) ⟹ thesis›*) by metis define ps' and ps'' where ps'_def: "ps' = filter (λp. dist p (l, snd p) < dist C₀⇩i C₁⇩i) ps" "ps'' = filter (λp. (fst p - l)² < Δ⇩i') ps" obtain C₀ and C₁ and Δ' and C₀' and C₁' where "Δ_def": "(C₀, C₁) = find_closest_pair (C₀⇩i, C₁⇩i) ps'" "(Δ', C₀', C₁') = find_closest_pair_code (Δ⇩i', C₀⇩i', C₁⇩i') ps''" (*goal: ‹(⋀C₀ C₁ Δ' C₀' C₁'. ⟦(C₀, C₁) = find_closest_pair (C₀⇩i, C₁⇩i) ps'; (Δ', C₀', C₁') = find_closest_pair_code (Δ⇩i', C₀⇩i', C₁⇩i') ps''⟧ ⟹ thesis) ⟹ thesis›*) by (metis prod_cases3 (*‹(⋀a b c. ?y = (a, b, c) ⟹ ?thesis) ⟹ ?thesis›*)) note defs = "Δ⇩i_def" (*‹(C₀⇩i::int × int, C₁⇩i::int × int) = (if dist (case p₀⇩L::int × int of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) (case p₁⇩L::int × int of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) < dist (case p₀⇩R::int × int of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) (case p₁⇩R::int × int of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) then (p₀⇩L, p₁⇩L) else (p₀⇩R, p₁⇩R))› ‹(Δ⇩i', C₀⇩i', C₁⇩i') = (if δ⇩L' < δ⇩R' then (δ⇩L', p₀⇩L, p₁⇩L) else (δ⇩R', p₀⇩R, p₁⇩R))›*) ps'_def (*‹ps' = filter (λp. dist (case p of (x, y) ⇒ (real_of_int x, real_of_int y)) (case (l, snd p) of (x, y) ⇒ (real_of_int x, real_of_int y)) < dist (case C₀⇩i of (x, y) ⇒ (real_of_int x, real_of_int y)) (case C₁⇩i of (x, y) ⇒ (real_of_int x, real_of_int y))) ps› ‹ps'' = filter (λp. (fst p - l)² < Δ⇩i') ps›*) "Δ_def" (*‹(C₀::int × int, C₁::int × int) = find_closest_pair (C₀⇩i::int × int, C₁⇩i::int × int) (ps'::(int × int) list)› ‹(Δ', C₀', C₁') = find_closest_pair_code (Δ⇩i', C₀⇩i', C₁⇩i') ps''›*) have "*": "C₀⇩i = C₀⇩i'" "C₁⇩i = C₁⇩i'" "Δ⇩i' = dist_code C₀⇩i' C₁⇩i'" using "Δ⇩i_def" (*‹(C₀⇩i::int × int, C₁⇩i::int × int) = (if dist (case p₀⇩L::int × int of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) (case p₁⇩L::int × int of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) < dist (case p₀⇩R::int × int of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) (case p₁⇩R::int × int of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) then (p₀⇩L, p₁⇩L) else (p₀⇩R, p₁⇩R))› ‹(Δ⇩i', C₀⇩i', C₁⇩i') = (if δ⇩L' < δ⇩R' then (δ⇩L', p₀⇩L, p₁⇩L) else (δ⇩R', p₀⇩R, p₁⇩R))›*) assms(1,2,3,4) (*‹δ⇩L' = dist_code p₀⇩L p₁⇩L› ‹(δ⇩R'::int) = dist_code (p₀⇩R::int × int) (p₁⇩R::int × int)› ‹sorted_snd ps› ‹(c₀, c₁) = combine (p₀⇩L, p₁⇩L) (p₀⇩R, p₁⇩R) l ps›*) dist_eq_dist_code_lt (*‹(dist (case ?p₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case ?p₁ of (x, y) ⇒ (real_of_int x, real_of_int y)) < dist (case ?p₂ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case ?p₃ of (x, y) ⇒ (real_of_int x, real_of_int y))) = (dist_code ?p₀ ?p₁ < dist_code ?p₂ ?p₃)›*) apply - (*goals: 1. ‹⟦(C₀⇩i, C₁⇩i) = (if dist (case p₀⇩L of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₁⇩L of (x, y) ⇒ (real_of_int x, real_of_int y)) < dist (case p₀⇩R of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₁⇩R of (x, y) ⇒ (real_of_int x, real_of_int y)) then (p₀⇩L, p₁⇩L) else (p₀⇩R, p₁⇩R)); (Δ⇩i', C₀⇩i', C₁⇩i') = (if δ⇩L' < δ⇩R' then (δ⇩L', p₀⇩L, p₁⇩L) else (δ⇩R', p₀⇩R, p₁⇩R)); δ⇩L' = dist_code p₀⇩L p₁⇩L; δ⇩R' = dist_code p₀⇩R p₁⇩R; sorted_snd ps; (c₀, c₁) = combine (p₀⇩L, p₁⇩L) (p₀⇩R, p₁⇩R) l ps; ⋀p₀ p₁ p₂ p₃. (dist (case p₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₁ of (x, y) ⇒ (real_of_int x, real_of_int y)) < dist (case p₂ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₃ of (x, y) ⇒ (real_of_int x, real_of_int y))) = (dist_code p₀ p₁ < dist_code p₂ p₃)⟧ ⟹ C₀⇩i = C₀⇩i'› 2. ‹⟦(C₀⇩i, C₁⇩i) = (if dist (case p₀⇩L of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₁⇩L of (x, y) ⇒ (real_of_int x, real_of_int y)) < dist (case p₀⇩R of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₁⇩R of (x, y) ⇒ (real_of_int x, real_of_int y)) then (p₀⇩L, p₁⇩L) else (p₀⇩R, p₁⇩R)); (Δ⇩i', C₀⇩i', C₁⇩i') = (if δ⇩L' < δ⇩R' then (δ⇩L', p₀⇩L, p₁⇩L) else (δ⇩R', p₀⇩R, p₁⇩R)); δ⇩L' = dist_code p₀⇩L p₁⇩L; δ⇩R' = dist_code p₀⇩R p₁⇩R; sorted_snd ps; (c₀, c₁) = combine (p₀⇩L, p₁⇩L) (p₀⇩R, p₁⇩R) l ps; ⋀p₀ p₁ p₂ p₃. (dist (case p₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₁ of (x, y) ⇒ (real_of_int x, real_of_int y)) < dist (case p₂ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₃ of (x, y) ⇒ (real_of_int x, real_of_int y))) = (dist_code p₀ p₁ < dist_code p₂ p₃)⟧ ⟹ C₁⇩i = C₁⇩i'› 3. ‹⟦(C₀⇩i, C₁⇩i) = (if dist (case p₀⇩L of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₁⇩L of (x, y) ⇒ (real_of_int x, real_of_int y)) < dist (case p₀⇩R of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₁⇩R of (x, y) ⇒ (real_of_int x, real_of_int y)) then (p₀⇩L, p₁⇩L) else (p₀⇩R, p₁⇩R)); (Δ⇩i', C₀⇩i', C₁⇩i') = (if δ⇩L' < δ⇩R' then (δ⇩L', p₀⇩L, p₁⇩L) else (δ⇩R', p₀⇩R, p₁⇩R)); δ⇩L' = dist_code p₀⇩L p₁⇩L; δ⇩R' = dist_code p₀⇩R p₁⇩R; sorted_snd ps; (c₀, c₁) = combine (p₀⇩L, p₁⇩L) (p₀⇩R, p₁⇩R) l ps; ⋀p₀ p₁ p₂ p₃. (dist (case p₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₁ of (x, y) ⇒ (real_of_int x, real_of_int y)) < dist (case p₂ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₃ of (x, y) ⇒ (real_of_int x, real_of_int y))) = (dist_code p₀ p₁ < dist_code p₂ p₃)⟧ ⟹ Δ⇩i' = dist_code C₀⇩i' C₁⇩i'› 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]) (*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]) (*proven 3 subgoals*) . hence "⋀p. ¦fst p - l¦ < dist C₀⇩i C₁⇩i ⟷ (fst p - l)² < Δ⇩i'" using dist_eq_dist_code_abs_lt (*‹(¦real_of_int (?c::int)¦ < dist (case ?p₀::int × int of (x::int, y::int) ⇒ (real_of_int x, real_of_int y)) (case ?p₁::int × int of (x::int, y::int) ⇒ (real_of_int x, real_of_int y))) = (?c² < dist_code ?p₀ ?p₁)›*) by (metis (mono_tags) of_int_abs (*‹of_int ¦?x¦ = ¦of_int ?x¦›*)) hence "ps' = ps''" using ps'_def (*‹ps' = filter (λp. dist (case p of (x, y) ⇒ (real_of_int x, real_of_int y)) (case (l, snd p) of (x, y) ⇒ (real_of_int x, real_of_int y)) < dist (case C₀⇩i of (x, y) ⇒ (real_of_int x, real_of_int y)) (case C₁⇩i of (x, y) ⇒ (real_of_int x, real_of_int y))) ps› ‹ps'' = filter (λp. (fst p - l)² < Δ⇩i') ps›*) dist_fst_abs (*‹dist (case ?p of (x, y) ⇒ (real_of_int x, real_of_int y)) (case (?l, snd ?p) of (x, y) ⇒ (real_of_int x, real_of_int y)) = real_of_int ¦fst ?p - ?l¦›*) by auto moreover have "sorted_snd ps'" using assms(3) (*‹sorted_snd ps›*) ps'_def (*‹ps' = filter (λp. dist (case p of (x, y) ⇒ (real_of_int x, real_of_int y)) (case (l, snd p) of (x, y) ⇒ (real_of_int x, real_of_int y)) < dist (case C₀⇩i of (x, y) ⇒ (real_of_int x, real_of_int y)) (case C₁⇩i of (x, y) ⇒ (real_of_int x, real_of_int y))) ps› ‹ps'' = filter (λp. (fst p - l)² < Δ⇩i') ps›*) sorted_snd_def (*‹sorted_snd ?ps = sorted_wrt (λp₀ p₁. snd p₀ ≤ snd p₁) ?ps›*) sorted_wrt_filter (*‹sorted_wrt ?f ?xs ⟹ sorted_wrt ?f (filter ?P ?xs)›*) by blast ultimately have "C₀ = C₀'" "C₁ = C₁'" using "*" (*‹(C₀⇩i::int × int) = (C₀⇩i'::int × int)› ‹C₁⇩i = C₁⇩i'› ‹Δ⇩i' = dist_code C₀⇩i' C₁⇩i'›*) find_closest_pair_code_eq (*‹⟦?δ = dist (case ?c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case ?c₁ of (x, y) ⇒ (real_of_int x, real_of_int y)); ?δ' = dist_code ?c₀ ?c₁; sorted_snd ?ps; (?C₀, ?C₁) = find_closest_pair (?c₀, ?c₁) ?ps; (?Δ', ?C₀', ?C₁') = find_closest_pair_code (?δ', ?c₀, ?c₁) ?ps⟧ ⟹ ?C₀ = ?C₀' ∧ ?C₁ = ?C₁'›*) "Δ_def" (*‹(C₀, C₁) = find_closest_pair (C₀⇩i, C₁⇩i) ps'› ‹(Δ', C₀', C₁') = find_closest_pair_code (Δ⇩i', C₀⇩i', C₁⇩i') ps''›*) apply - (*goals: 1. ‹⟦ps' = ps''; sorted_snd ps'; C₀⇩i = C₀⇩i'; C₁⇩i = C₁⇩i'; Δ⇩i' = dist_code C₀⇩i' C₁⇩i'; ⋀δ c₀ c₁ δ' ps C₀ C₁ Δ' C₀' C₁'. ⟦δ = dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y)); δ' = dist_code c₀ c₁; sorted_snd ps; (C₀, C₁) = find_closest_pair (c₀, c₁) ps; (Δ', C₀', C₁') = find_closest_pair_code (δ', c₀, c₁) ps⟧ ⟹ C₀ = C₀' ∧ C₁ = C₁'; (C₀, C₁) = find_closest_pair (C₀⇩i, C₁⇩i) ps'; (Δ', C₀', C₁') = find_closest_pair_code (Δ⇩i', C₀⇩i', C₁⇩i') ps''⟧ ⟹ C₀ = C₀'› 2. ‹⟦ps' = ps''; sorted_snd ps'; C₀⇩i = C₀⇩i'; C₁⇩i = C₁⇩i'; Δ⇩i' = dist_code C₀⇩i' C₁⇩i'; ⋀δ c₀ c₁ δ' ps C₀ C₁ Δ' C₀' C₁'. ⟦δ = dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y)); δ' = dist_code c₀ c₁; sorted_snd ps; (C₀, C₁) = find_closest_pair (c₀, c₁) ps; (Δ', C₀', C₁') = find_closest_pair_code (δ', c₀, c₁) ps⟧ ⟹ C₀ = C₀' ∧ C₁ = C₁'; (C₀, C₁) = find_closest_pair (C₀⇩i, C₁⇩i) ps'; (Δ', C₀', C₁') = find_closest_pair_code (Δ⇩i', C₀⇩i', C₁⇩i') ps''⟧ ⟹ C₁ = C₁'› discuss goal 1*) apply blast (*discuss goal 2*) apply blast (*proven 2 subgoals*) . moreover have "C₀ = c₀" "C₁ = c₁" using assms(4) (*‹(c₀, c₁) = combine (p₀⇩L, p₁⇩L) (p₀⇩R, p₁⇩R) l ps›*) defs(1,3,5) (*‹(C₀⇩i, C₁⇩i) = (if dist (case p₀⇩L of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₁⇩L of (x, y) ⇒ (real_of_int x, real_of_int y)) < dist (case p₀⇩R of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₁⇩R of (x, y) ⇒ (real_of_int x, real_of_int y)) then (p₀⇩L, p₁⇩L) else (p₀⇩R, p₁⇩R))› ‹ps' = filter (λp. dist (case p of (x, y) ⇒ (real_of_int x, real_of_int y)) (case (l, snd p) of (x, y) ⇒ (real_of_int x, real_of_int y)) < dist (case C₀⇩i of (x, y) ⇒ (real_of_int x, real_of_int y)) (case C₁⇩i of (x, y) ⇒ (real_of_int x, real_of_int y))) ps› ‹(C₀, C₁) = find_closest_pair (C₀⇩i, C₁⇩i) ps'›*) apply - (*goals: 1. ‹⟦(c₀, c₁) = combine (p₀⇩L, p₁⇩L) (p₀⇩R, p₁⇩R) l ps; (C₀⇩i, C₁⇩i) = (if dist (case p₀⇩L of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₁⇩L of (x, y) ⇒ (real_of_int x, real_of_int y)) < dist (case p₀⇩R of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₁⇩R of (x, y) ⇒ (real_of_int x, real_of_int y)) then (p₀⇩L, p₁⇩L) else (p₀⇩R, p₁⇩R)); ps' = filter (λp. dist (case p of (x, y) ⇒ (real_of_int x, real_of_int y)) (case (l, snd p) of (x, y) ⇒ (real_of_int x, real_of_int y)) < dist (case C₀⇩i of (x, y) ⇒ (real_of_int x, real_of_int y)) (case C₁⇩i of (x, y) ⇒ (real_of_int x, real_of_int y))) ps; (C₀, C₁) = find_closest_pair (C₀⇩i, C₁⇩i) ps'⟧ ⟹ C₀ = c₀› 2. ‹⟦(c₀, c₁) = combine (p₀⇩L, p₁⇩L) (p₀⇩R, p₁⇩R) l ps; (C₀⇩i, C₁⇩i) = (if dist (case p₀⇩L of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₁⇩L of (x, y) ⇒ (real_of_int x, real_of_int y)) < dist (case p₀⇩R of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₁⇩R of (x, y) ⇒ (real_of_int x, real_of_int y)) then (p₀⇩L, p₁⇩L) else (p₀⇩R, p₁⇩R)); ps' = filter (λp. dist (case p of (x, y) ⇒ (real_of_int x, real_of_int y)) (case (l, snd p) of (x, y) ⇒ (real_of_int x, real_of_int y)) < dist (case C₀⇩i of (x, y) ⇒ (real_of_int x, real_of_int y)) (case C₁⇩i of (x, y) ⇒ (real_of_int x, real_of_int y))) ps; (C₀, C₁) = find_closest_pair (C₀⇩i, C₁⇩i) ps'⟧ ⟹ C₁ = c₁› discuss goal 1*) apply ((auto simp: combine.simps (*‹combine (?p₀⇩L, ?p₁⇩L) (?p₀⇩R, ?p₁⇩R) ?l ?ps = (let (c₀, c₁) = if dist (case ?p₀⇩L of (x, y) ⇒ (real_of_int x, real_of_int y)) (case ?p₁⇩L of (x, y) ⇒ (real_of_int x, real_of_int y)) < dist (case ?p₀⇩R of (x, y) ⇒ (real_of_int x, real_of_int y)) (case ?p₁⇩R of (x, y) ⇒ (real_of_int x, real_of_int y)) then (?p₀⇩L, ?p₁⇩L) else (?p₀⇩R, ?p₁⇩R) in Let (filter (λp. dist (case p of (x, y) ⇒ (real_of_int x, real_of_int y)) (case (?l, snd p) of (x, y) ⇒ (real_of_int x, real_of_int y)) < dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y))) ?ps) (find_closest_pair (c₀, c₁)))›*) 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: ‹⟦(c₀, c₁) = combine (p₀⇩L, p₁⇩L) (p₀⇩R, p₁⇩R) l ps; (C₀⇩i, C₁⇩i) = (if dist (case p₀⇩L of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₁⇩L of (x, y) ⇒ (real_of_int x, real_of_int y)) < dist (case p₀⇩R of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₁⇩R of (x, y) ⇒ (real_of_int x, real_of_int y)) then (p₀⇩L, p₁⇩L) else (p₀⇩R, p₁⇩R)); ps' = filter (λp. dist (case p of (x, y) ⇒ (real_of_int x, real_of_int y)) (case (l, snd p) of (x, y) ⇒ (real_of_int x, real_of_int y)) < dist (case C₀⇩i of (x, y) ⇒ (real_of_int x, real_of_int y)) (case C₁⇩i of (x, y) ⇒ (real_of_int x, real_of_int y))) ps; (C₀, C₁) = find_closest_pair (C₀⇩i, C₁⇩i) ps'⟧ ⟹ C₀ = c₀› and 1 goal remains*) apply (metis Pair_inject (*‹⟦(?a, ?b) = (?a', ?b'); ⟦?a = ?a'; ?b = ?b'⟧ ⟹ ?R⟧ ⟹ ?R›*)) (*discuss goal 2*) apply ((auto simp: combine.simps (*‹combine (?p₀⇩L, ?p₁⇩L) (?p₀⇩R, ?p₁⇩R) ?l ?ps = (let (c₀, c₁) = if dist (case ?p₀⇩L of (x, y) ⇒ (real_of_int x, real_of_int y)) (case ?p₁⇩L of (x, y) ⇒ (real_of_int x, real_of_int y)) < dist (case ?p₀⇩R of (x, y) ⇒ (real_of_int x, real_of_int y)) (case ?p₁⇩R of (x, y) ⇒ (real_of_int x, real_of_int y)) then (?p₀⇩L, ?p₁⇩L) else (?p₀⇩R, ?p₁⇩R) in Let (filter (λp. dist (case p of (x, y) ⇒ (real_of_int x, real_of_int y)) (case (?l, snd p) of (x, y) ⇒ (real_of_int x, real_of_int y)) < dist (case c₀ of (x, y) ⇒ (real_of_int x, real_of_int y)) (case c₁ of (x, y) ⇒ (real_of_int x, real_of_int y))) ?ps) (find_closest_pair (c₀, c₁)))›*) 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]) (*goal: ‹⟦(c₀, c₁) = combine (p₀⇩L, p₁⇩L) (p₀⇩R, p₁⇩R) l ps; (C₀⇩i, C₁⇩i) = (if dist (case p₀⇩L of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₁⇩L of (x, y) ⇒ (real_of_int x, real_of_int y)) < dist (case p₀⇩R of (x, y) ⇒ (real_of_int x, real_of_int y)) (case p₁⇩R of (x, y) ⇒ (real_of_int x, real_of_int y)) then (p₀⇩L, p₁⇩L) else (p₀⇩R, p₁⇩R)); ps' = filter (λp. dist (case p of (x, y) ⇒ (real_of_int x, real_of_int y)) (case (l, snd p) of (x, y) ⇒ (real_of_int x, real_of_int y)) < dist (case C₀⇩i of (x, y) ⇒ (real_of_int x, real_of_int y)) (case C₁⇩i of (x, y) ⇒ (real_of_int x, real_of_int y))) ps; (C₀, C₁) = find_closest_pair (C₀⇩i, C₁⇩i) ps'⟧ ⟹ C₁ = c₁›*) apply (metis Pair_inject (*‹⟦(?a, ?b) = (?a', ?b'); ⟦?a = ?a'; ?b = ?b'⟧ ⟹ ?R⟧ ⟹ ?R›*)) (*proven 2 subgoals*) . moreover have "C₀' = c₀'" "C₁' = c₁'" using assms(5) (*‹(δ', c₀', c₁') = combine_code (δ⇩L', p₀⇩L, p₁⇩L) (δ⇩R', p₀⇩R, p₁⇩R) l ps›*) defs(2,4,6) (*‹(Δ⇩i', C₀⇩i', C₁⇩i') = (if δ⇩L' < δ⇩R' then (δ⇩L', p₀⇩L, p₁⇩L) else (δ⇩R', p₀⇩R, p₁⇩R))› ‹ps'' = filter (λp. (fst p - l)² < Δ⇩i') ps› ‹(Δ', C₀', C₁') = find_closest_pair_code (Δ⇩i', C₀⇩i', C₁⇩i') ps''›*) apply - (*goals: 1. ‹⟦(δ', c₀', c₁') = combine_code (δ⇩L', p₀⇩L, p₁⇩L) (δ⇩R', p₀⇩R, p₁⇩R) l ps; (Δ⇩i', C₀⇩i', C₁⇩i') = (if δ⇩L' < δ⇩R' then (δ⇩L', p₀⇩L, p₁⇩L) else (δ⇩R', p₀⇩R, p₁⇩R)); ps'' = filter (λp. (fst p - l)² < Δ⇩i') ps; (Δ', C₀', C₁') = find_closest_pair_code (Δ⇩i', C₀⇩i', C₁⇩i') ps''⟧ ⟹ C₀' = c₀'› 2. ‹⟦(δ', c₀', c₁') = combine_code (δ⇩L', p₀⇩L, p₁⇩L) (δ⇩R', p₀⇩R, p₁⇩R) l ps; (Δ⇩i', C₀⇩i', C₁⇩i') = (if δ⇩L' < δ⇩R' then (δ⇩L', p₀⇩L, p₁⇩L) else (δ⇩R', p₀⇩R, p₁⇩R)); ps'' = filter (λp. (fst p - l)² < Δ⇩i') ps; (Δ', C₀', C₁') = find_closest_pair_code (Δ⇩i', C₀⇩i', C₁⇩i') ps''⟧ ⟹ C₁' = c₁'› discuss goal 1*) apply ((auto 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: ‹⟦(δ', c₀', c₁') = combine_code (δ⇩L', p₀⇩L, p₁⇩L) (δ⇩R', p₀⇩R, p₁⇩R) l ps; (Δ⇩i', C₀⇩i', C₁⇩i') = (if δ⇩L' < δ⇩R' then (δ⇩L', p₀⇩L, p₁⇩L) else (δ⇩R', p₀⇩R, p₁⇩R)); ps'' = filter (λp. (fst p - l)² < Δ⇩i') ps; (Δ', C₀', C₁') = find_closest_pair_code (Δ⇩i', C₀⇩i', C₁⇩i') ps''⟧ ⟹ C₀' = c₀'› and 1 goal remains*) apply (metis prod.inject (*‹((?x1.0, ?x2.0) = (?y1.0, ?y2.0)) = (?x1.0 = ?y1.0 ∧ ?x2.0 = ?y2.0)›*)) (*discuss goal 2*) apply ((auto 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]) (*goal: ‹⟦(δ', c₀', c₁') = combine_code (δ⇩L', p₀⇩L, p₁⇩L) (δ⇩R', p₀⇩R, p₁⇩R) l ps; (Δ⇩i', C₀⇩i', C₁⇩i') = (if δ⇩L' < δ⇩R' then (δ⇩L', p₀⇩L, p₁⇩L) else (δ⇩R', p₀⇩R, p₁⇩R)); ps'' = filter (λp. (fst p - l)² < Δ⇩i') ps; (Δ', C₀', C₁') = find_closest_pair_code (Δ⇩i', C₀⇩i', C₁⇩i') ps''⟧ ⟹ C₁' = c₁'›*) apply (metis prod.inject (*‹((?x1.0, ?x2.0) = (?y1.0, ?y2.0)) = (?x1.0 = ?y1.0 ∧ ?x2.0 = ?y2.0)›*)) (*proven 2 subgoals*) . ultimately show "?thesis" (*goal: ‹c₀ = c₀' ∧ c₁ = c₁'›*) by blast qed subsubsection "Divide and Conquer Algorithm" function closest_pair_rec_code :: "point list ⇒ (point list * int * point * point)" where "closest_pair_rec_code xs = ( let n = length xs in if n ≤ 3 then (mergesort snd xs, closest_pair_bf_code xs) else let (xs⇩L, xs⇩R) = split_at (n div 2) xs in let l = fst (hd xs⇩R) in let (ys⇩L, p⇩L) = closest_pair_rec_code xs⇩L in let (ys⇩R, p⇩R) = closest_pair_rec_code xs⇩R in let ys = merge snd ys⇩L ys⇩R in (ys, combine_code p⇩L p⇩R l ys) )" by pat_completeness auto termination closest_pair_rec_code by (relation "Wellfounded.measure (λxs. length xs)") (auto simp: split_at_take_drop_conv Let_def) lemma closest_pair_rec_code_simps: assumes "n = length xs" "¬ (n ≤ 3)" shows "closest_pair_rec_code xs = ( let (xs⇩L, xs⇩R) = split_at (n div 2) xs in let l = fst (hd xs⇩R) in let (ys⇩L, p⇩L) = closest_pair_rec_code xs⇩L in let (ys⇩R, p⇩R) = closest_pair_rec_code xs⇩R in let ys = merge snd ys⇩L ys⇩R in (ys, combine_code p⇩L p⇩R l ys) )" using assms (*‹n = length xs› ‹¬ n ≤ 3›*) by (auto simp: Let_def (*‹Let ?s ?f ≡ ?f ?s›*)) declare combine.simps combine_code.simps closest_pair_rec_code.simps [simp del] lemma closest_pair_rec_code_dist_eq: assumes "1 < length xs" "(ys, δ, c₀, c₁) = closest_pair_rec_code xs" shows "δ = dist_code c₀ c₁" using assms (*‹1 < length xs› ‹(ys, δ, c₀, c₁) = closest_pair_rec_code xs›*) proof (induction xs arbitrary: ys δ c₀ c₁ rule: length_induct) (*goal: ‹⋀xs ys δ c₀ c₁. ⟦∀ys. length ys < length xs ⟶ 1 < length ys ⟶ (∀x xa xb xc. (x, xa, xb, xc) = closest_pair_rec_code ys ⟶ xa = dist_code xb xc); 1 < length xs; (ys, δ, c₀, c₁) = closest_pair_rec_code xs⟧ ⟹ δ = dist_code c₀ c₁›*) case (1 xs) (*‹∀ys::(int × int) list. length ys < length (xs::(int × int) list) ⟶ (1::nat) < length ys ⟶ (∀(x::(int × int) list) (xa::int) (xb::int × int) xc::int × int. (x, xa, xb, xc) = closest_pair_rec_code ys ⟶ xa = dist_code xb xc)› ‹1 < length xs› ‹(ys, δ, c₀, c₁) = closest_pair_rec_code xs›*) let ?n = "length xs" show "?case" (*goal: ‹δ = dist_code c₀ c₁›*) proof (cases "?n ≤ 3") (*goals: 1. ‹length (xs::(int × int) list) ≤ (3::nat) ⟹ (δ::int) = dist_code (c₀::int × int) (c₁::int × int)› 2. ‹¬ length (xs::(int × int) list) ≤ (3::nat) ⟹ (δ::int) = dist_code (c₀::int × int) (c₁::int × int)›*) case True (*‹length xs ≤ 3›*) hence "(δ, c₀, c₁) = closest_pair_bf_code xs" using "1.prems"(2) (*‹(ys, δ, c₀, c₁) = closest_pair_rec_code xs›*) closest_pair_rec_code.simps (*‹closest_pair_rec_code (?xs::(int × int) list) = (let n::nat = length ?xs in if n ≤ (3::nat) then (mergesort snd ?xs, closest_pair_bf_code ?xs) else let (xs⇩L::(int × int) list, xs⇩R::(int × int) list) = split_at (n div (2::nat)) ?xs; l::int = fst (hd xs⇩R); (ys⇩L::(int × int) list, p⇩L::int × (int × int) × int × int) = closest_pair_rec_code xs⇩L; (ys⇩R::(int × int) list, p⇩R::int × (int × int) × int × int) = closest_pair_rec_code xs⇩R; ys::(int × int) list = Common.merge snd ys⇩L ys⇩R in (ys, combine_code p⇩L p⇩R l ys))›*) by simp thus "?thesis" (*goal: ‹δ = dist_code c₀ c₁›*) using "1.prems"(1) (*‹1 < length xs›*) closest_pair_bf_code_dist_eq (*‹⟦1 < length ?ps; (?δ, ?c₀, ?c₁) = closest_pair_bf_code ?ps⟧ ⟹ ?δ = dist_code ?c₀ ?c₁›*) by simp next (*goal: ‹¬ length xs ≤ 3 ⟹ δ = dist_code c₀ c₁›*) case False (*‹¬ length xs ≤ 3›*) obtain XS⇩L and XS⇩R where "XS⇩L⇩R_def": "(XS⇩L, XS⇩R) = split_at (?n div 2) xs" (*goal: ‹(⋀XS⇩L XS⇩R. (XS⇩L, XS⇩R) = split_at (length xs div 2) xs ⟹ thesis) ⟹ thesis›*) using prod.collapse (*‹(fst (?prod::?'a::type × ?'b::type), snd ?prod) = ?prod›*) by blast define L where "L = fst (hd XS⇩R)" obtain YS⇩L and Δ⇩L and C₀⇩L and C₁⇩L where "YSC₀₁⇩L_def": "(YS⇩L, Δ⇩L, C₀⇩L, C₁⇩L) = closest_pair_rec_code XS⇩L" (*goal: ‹(⋀YS⇩L Δ⇩L C₀⇩L C₁⇩L. (YS⇩L, Δ⇩L, C₀⇩L, C₁⇩L) = closest_pair_rec_code XS⇩L ⟹ thesis) ⟹ thesis›*) using prod.collapse (*‹(fst ?prod, snd ?prod) = ?prod›*) by metis obtain YS⇩R and Δ⇩R and C₀⇩R and C₁⇩R where "YSC₀₁⇩R_def": "(YS⇩R, Δ⇩R, C₀⇩R, C₁⇩R) = closest_pair_rec_code XS⇩R" (*goal: ‹(⋀YS⇩R Δ⇩R C₀⇩R C₁⇩R. (YS⇩R, Δ⇩R, C₀⇩R, C₁⇩R) = closest_pair_rec_code XS⇩R ⟹ thesis) ⟹ thesis›*) using prod.collapse (*‹(fst ?prod, snd ?prod) = ?prod›*) by metis define YS where "YS = merge (λp. snd p) YS⇩L YS⇩R" obtain Δ and C₀ and C₁ where "C₀₁_def": "(Δ, C₀, C₁) = combine_code (Δ⇩L, C₀⇩L, C₁⇩L) (Δ⇩R, C₀⇩R, C₁⇩R) L YS" (*goal: ‹(⋀Δ C₀ C₁. (Δ, C₀, C₁) = combine_code (Δ⇩L, C₀⇩L, C₁⇩L) (Δ⇩R, C₀⇩R, C₁⇩R) L YS ⟹ thesis) ⟹ thesis›*) using prod.collapse (*‹(fst ?prod, snd ?prod) = ?prod›*) by metis note defs = "XS⇩L⇩R_def" (*‹(XS⇩L, XS⇩R) = split_at (length xs div 2) xs›*) L_def (*‹L = fst (hd XS⇩R)›*) "YSC₀₁⇩L_def" (*‹(YS⇩L, Δ⇩L, C₀⇩L, C₁⇩L) = closest_pair_rec_code XS⇩L›*) "YSC₀₁⇩R_def" (*‹(YS⇩R, Δ⇩R, C₀⇩R, C₁⇩R) = closest_pair_rec_code XS⇩R›*) YS_def (*‹YS = Common.merge snd YS⇩L YS⇩R›*) "C₀₁_def" (*‹(Δ, C₀, C₁) = combine_code (Δ⇩L, C₀⇩L, C₁⇩L) (Δ⇩R, C₀⇩R, C₁⇩R) L YS›*) have "1 < length XS⇩L" "length XS⇩L < length xs" using False (*‹¬ length xs ≤ 3›*) "1.prems"(1) (*‹(1::nat) < length (xs::(int × int) list)›*) defs (*‹(XS⇩L, XS⇩R) = split_at (length xs div 2) xs› ‹(L::int) = fst (hd (XS⇩R::(int × int) list))› ‹(YS⇩L, Δ⇩L, C₀⇩L, C₁⇩L) = closest_pair_rec_code XS⇩L› ‹(YS⇩R, Δ⇩R, C₀⇩R, C₁⇩R) = closest_pair_rec_code XS⇩R› ‹YS = Common.merge snd YS⇩L YS⇩R› ‹(Δ, C₀, C₁) = combine_code (Δ⇩L, C₀⇩L, C₁⇩L) (Δ⇩R, C₀⇩R, C₁⇩R) L YS›*) apply - (*goals: 1. ‹⟦¬ length xs ≤ 3; 1 < length xs; (XS⇩L, XS⇩R) = split_at (length xs div 2) xs; L = fst (hd XS⇩R); (YS⇩L, Δ⇩L, C₀⇩L, C₁⇩L) = closest_pair_rec_code XS⇩L; (YS⇩R, Δ⇩R, C₀⇩R, C₁⇩R) = closest_pair_rec_code XS⇩R; YS = Common.merge snd YS⇩L YS⇩R; (Δ, C₀, C₁) = combine_code (Δ⇩L, C₀⇩L, C₁⇩L) (Δ⇩R, C₀⇩R, C₁⇩R) L YS⟧ ⟹ 1 < length XS⇩L› 2. ‹⟦¬ length xs ≤ 3; 1 < length xs; (XS⇩L, XS⇩R) = split_at (length xs div 2) xs; L = fst (hd XS⇩R); (YS⇩L, Δ⇩L, C₀⇩L, C₁⇩L) = closest_pair_rec_code XS⇩L; (YS⇩R, Δ⇩R, C₀⇩R, C₁⇩R) = closest_pair_rec_code XS⇩R; YS = Common.merge snd YS⇩L YS⇩R; (Δ, C₀, C₁) = combine_code (Δ⇩L, C₀⇩L, C₁⇩L) (Δ⇩R, C₀⇩R, C₁⇩R) L YS⟧ ⟹ length XS⇩L < length xs› discuss goal 1*) apply ((auto simp: split_at_take_drop_conv (*‹split_at ?n ?xs = (take ?n ?xs, drop ?n ?xs)›*))[1]) (*discuss goal 2*) apply ((auto simp: split_at_take_drop_conv (*‹split_at ?n ?xs = (take ?n ?xs, drop ?n ?xs)›*))[1]) (*proven 2 subgoals*) . hence IHL: "Δ⇩L = dist_code C₀⇩L C₁⇩L" using "1.IH" (*‹∀ys::(int × int) list. length ys < length (xs::(int × int) list) ⟶ (1::nat) < length ys ⟶ (∀(x::(int × int) list) (xa::int) (xb::int × int) xc::int × int. (x, xa, xb, xc) = closest_pair_rec_code ys ⟶ xa = dist_code xb xc)›*) defs (*‹(XS⇩L, XS⇩R) = split_at (length xs div 2) xs› ‹L = fst (hd XS⇩R)› ‹(YS⇩L, Δ⇩L, C₀⇩L, C₁⇩L) = closest_pair_rec_code XS⇩L› ‹(YS⇩R, Δ⇩R, C₀⇩R, C₁⇩R) = closest_pair_rec_code XS⇩R› ‹YS = Common.merge snd YS⇩L YS⇩R› ‹(Δ, C₀, C₁) = combine_code (Δ⇩L, C₀⇩L, C₁⇩L) (Δ⇩R, C₀⇩R, C₁⇩R) L YS›*) by metis have "1 < length XS⇩R" "length XS⇩R < length xs" using False (*‹¬ length xs ≤ 3›*) "1.prems"(1) (*‹(1::nat) < length (xs::(int × int) list)›*) defs (*‹(XS⇩L, XS⇩R) = split_at (length xs div 2) xs› ‹L = fst (hd XS⇩R)› ‹(YS⇩L, Δ⇩L, C₀⇩L, C₁⇩L) = closest_pair_rec_code XS⇩L› ‹(YS⇩R, Δ⇩R, C₀⇩R, C₁⇩R) = closest_pair_rec_code XS⇩R› ‹YS = Common.merge snd YS⇩L YS⇩R› ‹(Δ, C₀, C₁) = combine_code (Δ⇩L, C₀⇩L, C₁⇩L) (Δ⇩R, C₀⇩R, C₁⇩R) L YS›*) apply - (*goals: 1. ‹⟦¬ length xs ≤ 3; 1 < length xs; (XS⇩L, XS⇩R) = split_at (length xs div 2) xs; L = fst (hd XS⇩R); (YS⇩L, Δ⇩L, C₀⇩L, C₁⇩L) = closest_pair_rec_code XS⇩L; (YS⇩R, Δ⇩R, C₀⇩R, C₁⇩R) = closest_pair_rec_code XS⇩R; YS = Common.merge snd YS⇩L YS⇩R; (Δ, C₀, C₁) = combine_code (Δ⇩L, C₀⇩L, C₁⇩L) (Δ⇩R, C₀⇩R, C₁⇩R) L YS⟧ ⟹ 1 < length XS⇩R› 2. ‹⟦¬ length xs ≤ 3; 1 < length xs; (XS⇩L, XS⇩R) = split_at (length xs div 2) xs; L = fst (hd XS⇩R); (YS⇩L, Δ⇩L, C₀⇩L, C₁⇩L) = closest_pair_rec_code XS⇩L; (YS⇩R, Δ⇩R, C₀⇩R, C₁⇩R) = closest_pair_rec_code XS⇩R; YS = Common.merge snd YS⇩L YS⇩R; (Δ, C₀, C₁) = combine_code (Δ⇩L, C₀⇩L, C₁⇩L) (Δ⇩R, C₀⇩R, C₁⇩R) L YS⟧ ⟹ length XS⇩R < length xs› discuss goal 1*) apply ((auto simp: split_at_take_drop_conv (*‹split_at ?n ?xs = (take ?n ?xs, drop ?n ?xs)›*))[1]) (*discuss goal 2*) apply ((auto simp: split_at_take_drop_conv (*‹split_at (?n::nat) (?xs::?'a::type list) = (take ?n ?xs, drop ?n ?xs)›*))[1]) (*proven 2 subgoals*) . hence IHR: "Δ⇩R = dist_code C₀⇩R C₁⇩R" using "1.IH" (*‹∀ys::(int × int) list. length ys < length (xs::(int × int) list) ⟶ (1::nat) < length ys ⟶ (∀(x::(int × int) list) (xa::int) (xb::int × int) xc::int × int. (x, xa, xb, xc) = closest_pair_rec_code ys ⟶ xa = dist_code xb xc)›*) defs (*‹(XS⇩L, XS⇩R) = split_at (length xs div 2) xs› ‹(L::int) = fst (hd (XS⇩R::(int × int) list))› ‹(YS⇩L, Δ⇩L, C₀⇩L, C₁⇩L) = closest_pair_rec_code XS⇩L› ‹(YS⇩R::(int × int) list, Δ⇩R::int, C₀⇩R::int × int, C₁⇩R::int × int) = closest_pair_rec_code (XS⇩R::(int × int) list)› ‹YS = Common.merge snd YS⇩L YS⇩R› ‹(Δ, C₀, C₁) = combine_code (Δ⇩L, C₀⇩L, C₁⇩L) (Δ⇩R, C₀⇩R, C₁⇩R) L YS›*) by metis have "*": "(YS, Δ, C₀, C₁) = closest_pair_rec_code xs" using False (*‹¬ length xs ≤ 3›*) closest_pair_rec_code_simps (*‹⟦?n = length ?xs; ¬ ?n ≤ 3⟧ ⟹ closest_pair_rec_code ?xs = (let (xs⇩L, xs⇩R) = split_at (?n div 2) ?xs; l = fst (hd xs⇩R); (ys⇩L, p⇩L) = closest_pair_rec_code xs⇩L; (ys⇩R, p⇩R) = closest_pair_rec_code xs⇩R; ys = Common.merge snd ys⇩L ys⇩R in (ys, combine_code p⇩L p⇩R l ys))›*) defs (*‹(XS⇩L, XS⇩R) = split_at (length xs div 2) xs› ‹L = fst (hd XS⇩R)› ‹(YS⇩L, Δ⇩L, C₀⇩L, C₁⇩L) = closest_pair_rec_code XS⇩L› ‹(YS⇩R, Δ⇩R, C₀⇩R, C₁⇩R) = closest_pair_rec_code XS⇩R› ‹(YS::(int × int) list) = Common.merge snd (YS⇩L::(int × int) list) (YS⇩R::(int × int) list)› ‹(Δ, C₀, C₁) = combine_code (Δ⇩L, C₀⇩L, C₁⇩L) (Δ⇩R, C₀⇩R, C₁⇩R) L YS›*) by (auto simp: Let_def (*‹Let ?s ?f ≡ ?f ?s›*) split: prod.split (*‹?P (case ?prod of (x, xa) ⇒ ?f x xa) = (∀x1 x2. ?prod = (x1, x2) ⟶ ?P (?f x1 x2))›*)) moreover have "Δ = dist_code C₀ C₁" using combine_code_dist_eq (*‹⟦?δ⇩L = dist_code ?p₀⇩L ?p₁⇩L; ?δ⇩R = dist_code ?p₀⇩R ?p₁⇩R; (?δ, ?c₀, ?c₁) = combine_code (?δ⇩L, ?p₀⇩L, ?p₁⇩L) (?δ⇩R, ?p₀⇩R, ?p₁⇩R) ?l ?ps⟧ ⟹ ?δ = dist_code ?c₀ ?c₁›*) IHL (*‹Δ⇩L = dist_code C₀⇩L C₁⇩L›*) IHR (*‹Δ⇩R = dist_code C₀⇩R C₁⇩R›*) "C₀₁_def" (*‹(Δ, C₀, C₁) = combine_code (Δ⇩L, C₀⇩L, C₁⇩L) (Δ⇩R, C₀⇩R, C₁⇩R) L YS›*) by blast ultimately show "?thesis" (*goal: ‹δ = dist_code c₀ c₁›*) using "1.prems"(2) (*‹(ys, δ, c₀, c₁) = closest_pair_rec_code xs›*) "*" (*‹(YS, Δ, C₀, C₁) = closest_pair_rec_code xs›*) by (metis Pair_inject (*‹⟦(?a, ?b) = (?a', ?b'); ⟦?a = ?a'; ?b = ?b'⟧ ⟹ ?R⟧ ⟹ ?R›*)) qed qed lemma closest_pair_rec_ys_eq: assumes "1 < length xs" assumes "(ys, c₀, c₁) = closest_pair_rec xs" assumes "(ys', δ', c₀', c₁') = closest_pair_rec_code xs" shows "ys = ys'" using assms (*‹(1::nat) < length (xs::(int × int) list)› ‹(ys, c₀, c₁) = closest_pair_rec xs› ‹(ys', δ', c₀', c₁') = closest_pair_rec_code xs›*) proof (induction xs arbitrary: ys c₀ c₁ ys' δ' c₀' c₁' rule: length_induct) (*goal: ‹⋀(xs::(int × int) list) (ys::(int × int) list) (c₀::int × int) (c₁::int × int) (ys'::(int × int) list) (δ'::int) (c₀'::int × int) c₁'::int × int. ⟦∀ys::(int × int) list. length ys < length xs ⟶ (1::nat) < length ys ⟶ (∀(x::(int × int) list) (xa::int × int) xb::int × int. (x, xa, xb) = closest_pair_rec ys ⟶ (∀(xa::(int × int) list) (xb::int) (xc::int × int) xd::int × int. (xa, xb, xc, xd) = closest_pair_rec_code ys ⟶ x = xa)); (1::nat) < length xs; (ys, c₀, c₁) = closest_pair_rec xs; (ys', δ', c₀', c₁') = closest_pair_rec_code xs⟧ ⟹ ys = ys'›*) case (1 xs) (*‹∀ys. length ys < length xs ⟶ 1 < length ys ⟶ (∀x xa xb. (x, xa, xb) = closest_pair_rec ys ⟶ (∀xa xb xc xd. (xa, xb, xc, xd) = closest_pair_rec_code ys ⟶ x = xa))› ‹1 < length xs› ‹(ys, c₀, c₁) = closest_pair_rec xs› ‹(ys', δ', c₀', c₁') = closest_pair_rec_code xs›*) let ?n = "length xs" show "?case" (*goal: ‹ys = ys'›*) proof (cases "?n ≤ 3") (*goals: 1. ‹length xs ≤ 3 ⟹ ys = ys'› 2. ‹¬ length xs ≤ 3 ⟹ ys = ys'›*) case True (*‹length xs ≤ 3›*) hence "ys = mergesort snd xs" using "1.prems"(2) (*‹(ys::(int × int) list, c₀::int × int, c₁::int × int) = closest_pair_rec (xs::(int × int) list)›*) closest_pair_rec.simps (*‹closest_pair_rec ?xs = (let n = length ?xs in if n ≤ 3 then (mergesort snd ?xs, closest_pair_bf ?xs) else let (xs⇩L, xs⇩R) = split_at (n div 2) ?xs; (ys⇩L, p₀⇩L, p₁⇩L) = closest_pair_rec xs⇩L; (ys⇩R, p₀⇩R, p₁⇩R) = closest_pair_rec xs⇩R; ys = Common.merge snd ys⇩L ys⇩R in (ys, combine (p₀⇩L, p₁⇩L) (p₀⇩R, p₁⇩R) (fst (hd xs⇩R)) ys))›*) by simp moreover have "ys' = mergesort snd xs" using "1.prems"(3) (*‹(ys'::(int × int) list, δ'::int, c₀'::int × int, c₁'::int × int) = closest_pair_rec_code (xs::(int × int) list)›*) closest_pair_rec_code.simps (*‹closest_pair_rec_code ?xs = (let n = length ?xs in if n ≤ 3 then (mergesort snd ?xs, closest_pair_bf_code ?xs) else let (xs⇩L, xs⇩R) = split_at (n div 2) ?xs; l = fst (hd xs⇩R); (ys⇩L, p⇩L) = closest_pair_rec_code xs⇩L; (ys⇩R, p⇩R) = closest_pair_rec_code xs⇩R; ys = Common.merge snd ys⇩L ys⇩R in (ys, combine_code p⇩L p⇩R l ys))›*) by (simp add: True (*‹length xs ≤ 3›*)) ultimately show "?thesis" (*goal: ‹ys = ys'›*) using "1.prems"(1) (*‹1 < length xs›*) by simp next (*goal: ‹¬ length xs ≤ 3 ⟹ ys = ys'›*) case False (*‹¬ length xs ≤ 3›*) obtain XS⇩L and XS⇩R where "XS⇩L⇩R_def": "(XS⇩L, XS⇩R) = split_at (?n div 2) xs" (*goal: ‹(⋀XS⇩L XS⇩R. (XS⇩L, XS⇩R) = split_at (length xs div 2) xs ⟹ thesis) ⟹ thesis›*) using prod.collapse (*‹(fst ?prod, snd ?prod) = ?prod›*) by blast define L where "L = fst (hd XS⇩R)" obtain YS⇩L and C₀⇩L and C₁⇩L and YS⇩L' and Δ⇩L' and C₀⇩L' and C₁⇩L' where "YSC₀₁⇩L_def": "(YS⇩L, C₀⇩L, C₁⇩L) = closest_pair_rec XS⇩L" "(YS⇩L', Δ⇩L', C₀⇩L', C₁⇩L') = closest_pair_rec_code XS⇩L" (*goal: ‹(⋀YS⇩L C₀⇩L C₁⇩L YS⇩L' Δ⇩L' C₀⇩L' C₁⇩L'. ⟦(YS⇩L, C₀⇩L, C₁⇩L) = closest_pair_rec XS⇩L; (YS⇩L', Δ⇩L', C₀⇩L', C₁⇩L') = closest_pair_rec_code XS⇩L⟧ ⟹ thesis) ⟹ thesis›*) using prod.collapse (*‹(fst ?prod, snd ?prod) = ?prod›*) by metis obtain YS⇩R and C₀⇩R and C₁⇩R and YS⇩R' and Δ⇩R' and C₀⇩R' and C₁⇩R' where "YSC₀₁⇩R_def": "(YS⇩R, C₀⇩R, C₁⇩R) = closest_pair_rec XS⇩R" "(YS⇩R', Δ⇩R', C₀⇩R', C₁⇩R') = closest_pair_rec_code XS⇩R" (*goal: ‹(⋀YS⇩R C₀⇩R C₁⇩R YS⇩R' Δ⇩R' C₀⇩R' C₁⇩R'. ⟦(YS⇩R, C₀⇩R, C₁⇩R) = closest_pair_rec XS⇩R; (YS⇩R', Δ⇩R', C₀⇩R', C₁⇩R') = closest_pair_rec_code XS⇩R⟧ ⟹ thesis) ⟹ thesis›*) using prod.collapse (*‹(fst ?prod, snd ?prod) = ?prod›*) by metis define YS and YS' where YS_def: "YS = merge (λp. snd p) YS⇩L YS⇩R" "YS' = merge (λp. snd p) YS⇩L' YS⇩R'" obtain C₀ and C₁ and Δ' and C₀' and C₁' where "C₀₁_def": "(C₀, C₁) = combine (C₀⇩L, C₁⇩L) (C₀⇩R, C₁⇩R) L YS" "(Δ', C₀', C₁') = combine_code (Δ⇩L', C₀⇩L', C₁⇩L') (Δ⇩R', C₀⇩R', C₁⇩R') L YS'" (*goal: ‹(⋀C₀ C₁ Δ' C₀' C₁'. ⟦(C₀, C₁) = combine (C₀⇩L, C₁⇩L) (C₀⇩R, C₁⇩R) L YS; (Δ', C₀', C₁') = combine_code (Δ⇩L', C₀⇩L', C₁⇩L') (Δ⇩R', C₀⇩R', C₁⇩R') L YS'⟧ ⟹ thesis) ⟹ thesis›*) using prod.collapse (*‹(fst (?prod::?'a::type × ?'b::type), snd ?prod) = ?prod›*) by metis note defs = "XS⇩L⇩R_def" (*‹(XS⇩L, XS⇩R) = split_at (length xs div 2) xs›*) L_def (*‹L = fst (hd XS⇩R)›*) "YSC₀₁⇩L_def" (*‹(YS⇩L, C₀⇩L, C₁⇩L) = closest_pair_rec XS⇩L› ‹(YS⇩L', Δ⇩L', C₀⇩L', C₁⇩L') = closest_pair_rec_code XS⇩L›*) "YSC₀₁⇩R_def" (*‹(YS⇩R, C₀⇩R, C₁⇩R) = closest_pair_rec XS⇩R› ‹(YS⇩R', Δ⇩R', C₀⇩R', C₁⇩R') = closest_pair_rec_code XS⇩R›*) YS_def (*‹YS = Common.merge snd YS⇩L YS⇩R› ‹YS' = Common.merge snd YS⇩L' YS⇩R'›*) "C₀₁_def" (*‹(C₀, C₁) = combine (C₀⇩L, C₁⇩L) (C₀⇩R, C₁⇩R) L YS› ‹(Δ'::int, C₀'::int × int, C₁'::int × int) = combine_code (Δ⇩L'::int, C₀⇩L'::int × int, C₁⇩L'::int × int) (Δ⇩R'::int, C₀⇩R'::int × int, C₁⇩R'::int × int) (L::int) (YS'::(int × int) list)›*) have "1 < length XS⇩L" "length XS⇩L < length xs" using False (*‹¬ length xs ≤ 3›*) "1.prems"(1) (*‹1 < length xs›*) defs (*‹(XS⇩L::(int × int) list, XS⇩R::(int × int) list) = split_at (length (xs::(int × int) list) div (2::nat)) xs› ‹L = fst (hd XS⇩R)› ‹(YS⇩L::(int × int) list, C₀⇩L::int × int, C₁⇩L::int × int) = closest_pair_rec (XS⇩L::(int × int) list)› ‹(YS⇩L', Δ⇩L', C₀⇩L', C₁⇩L') = closest_pair_rec_code XS⇩L› ‹(YS⇩R, C₀⇩R, C₁⇩R) = closest_pair_rec XS⇩R› ‹(YS⇩R', Δ⇩R', C₀⇩R', C₁⇩R') = closest_pair_rec_code XS⇩R› ‹YS = Common.merge snd YS⇩L YS⇩R› ‹YS' = Common.merge snd YS⇩L' YS⇩R'› ‹(C₀, C₁) = combine (C₀⇩L, C₁⇩L) (C₀⇩R, C₁⇩R) L YS› ‹(Δ', C₀', C₁') = combine_code (Δ⇩L', C₀⇩L', C₁⇩L') (Δ⇩R', C₀⇩R', C₁⇩R') L YS'›*) apply - (*goals: 1. ‹⟦¬ length xs ≤ 3; 1 < length xs; (XS⇩L, XS⇩R) = split_at (length xs div 2) xs; L = fst (hd XS⇩R); (YS⇩L, C₀⇩L, C₁⇩L) = closest_pair_rec XS⇩L; (YS⇩L', Δ⇩L', C₀⇩L', C₁⇩L') = closest_pair_rec_code XS⇩L; (YS⇩R, C₀⇩R, C₁⇩R) = closest_pair_rec XS⇩R; (YS⇩R', Δ⇩R', C₀⇩R', C₁⇩R') = closest_pair_rec_code XS⇩R; YS = Common.merge snd YS⇩L YS⇩R; YS' = Common.merge snd YS⇩L' YS⇩R'; (C₀, C₁) = combine (C₀⇩L, C₁⇩L) (C₀⇩R, C₁⇩R) L YS; (Δ', C₀', C₁') = combine_code (Δ⇩L', C₀⇩L', C₁⇩L') (Δ⇩R', C₀⇩R', C₁⇩R') L YS'⟧ ⟹ 1 < length XS⇩L› 2. ‹⟦¬ length xs ≤ 3; 1 < length xs; (XS⇩L, XS⇩R) = split_at (length xs div 2) xs; L = fst (hd XS⇩R); (YS⇩L, C₀⇩L, C₁⇩L) = closest_pair_rec XS⇩L; (YS⇩L', Δ⇩L', C₀⇩L', C₁⇩L') = closest_pair_rec_code XS⇩L; (YS⇩R, C₀⇩R, C₁⇩R) = closest_pair_rec XS⇩R; (YS⇩R', Δ⇩R', C₀⇩R', C₁⇩R') = closest_pair_rec_code XS⇩R; YS = Common.merge snd YS⇩L YS⇩R; YS' = Common.merge snd YS⇩L' YS⇩R'; (C₀, C₁) = combine (C₀⇩L, C₁⇩L) (C₀⇩R, C₁⇩R) L YS; (Δ', C₀', C₁') = combine_code (Δ⇩L', C₀⇩L', C₁⇩L') (Δ⇩R', C₀⇩R', C₁⇩R') L YS'⟧ ⟹ length XS⇩L < length xs› discuss goal 1*) apply ((auto simp: split_at_take_drop_conv (*‹split_at ?n ?xs = (take ?n ?xs, drop ?n ?xs)›*))[1]) (*discuss goal 2*) apply ((auto simp: split_at_take_drop_conv (*‹split_at (?n::nat) (?xs::?'a list) = (take ?n ?xs, drop ?n ?xs)›*))[1]) (*proven 2 subgoals*) . hence IHL: "YS⇩L = YS⇩L'" using "1.IH" (*‹∀ys. length ys < length xs ⟶ 1 < length ys ⟶ (∀x xa xb. (x, xa, xb) = closest_pair_rec ys ⟶ (∀xa xb xc xd. (xa, xb, xc, xd) = closest_pair_rec_code ys ⟶ x = xa))›*) defs (*‹(XS⇩L, XS⇩R) = split_at (length xs div 2) xs› ‹(L::int) = fst (hd (XS⇩R::(int × int) list))› ‹(YS⇩L, C₀⇩L, C₁⇩L) = closest_pair_rec XS⇩L› ‹(YS⇩L'::(int × int) list, Δ⇩L'::int, C₀⇩L'::int × int, C₁⇩L'::int × int) = closest_pair_rec_code (XS⇩L::(int × int) list)› ‹(YS⇩R, C₀⇩R, C₁⇩R) = closest_pair_rec XS⇩R› ‹(YS⇩R', Δ⇩R', C₀⇩R', C₁⇩R') = closest_pair_rec_code XS⇩R› ‹YS = Common.merge snd YS⇩L YS⇩R› ‹YS' = Common.merge snd YS⇩L' YS⇩R'› ‹(C₀::int × int, C₁::int × int) = combine (C₀⇩L::int × int, C₁⇩L::int × int) (C₀⇩R::int × int, C₁⇩R::int × int) (L::int) (YS::(int × int) list)› ‹(Δ', C₀', C₁') = combine_code (Δ⇩L', C₀⇩L', C₁⇩L') (Δ⇩R', C₀⇩R', C₁⇩R') L YS'›*) by metis have "1 < length XS⇩R" "length XS⇩R < length xs" using False (*‹¬ length xs ≤ 3›*) "1.prems"(1) (*‹(1::nat) < length (xs::(int × int) list)›*) defs (*‹(XS⇩L, XS⇩R) = split_at (length xs div 2) xs› ‹L = fst (hd XS⇩R)› ‹(YS⇩L, C₀⇩L, C₁⇩L) = closest_pair_rec XS⇩L› ‹(YS⇩L', Δ⇩L', C₀⇩L', C₁⇩L') = closest_pair_rec_code XS⇩L› ‹(YS⇩R, C₀⇩R, C₁⇩R) = closest_pair_rec XS⇩R› ‹(YS⇩R'::(int × int) list, Δ⇩R'::int, C₀⇩R'::int × int, C₁⇩R'::int × int) = closest_pair_rec_code (XS⇩R::(int × int) list)› ‹(YS::(int × int) list) = Common.merge snd (YS⇩L::(int × int) list) (YS⇩R::(int × int) list)› ‹YS' = Common.merge snd YS⇩L' YS⇩R'› ‹(C₀, C₁) = combine (C₀⇩L, C₁⇩L) (C₀⇩R, C₁⇩R) L YS› ‹(Δ', C₀', C₁') = combine_code (Δ⇩L', C₀⇩L', C₁⇩L') (Δ⇩R', C₀⇩R', C₁⇩R') L YS'›*) apply - (*goals: 1. ‹⟦¬ length xs ≤ 3; 1 < length xs; (XS⇩L, XS⇩R) = split_at (length xs div 2) xs; L = fst (hd XS⇩R); (YS⇩L, C₀⇩L, C₁⇩L) = closest_pair_rec XS⇩L; (YS⇩L', Δ⇩L', C₀⇩L', C₁⇩L') = closest_pair_rec_code XS⇩L; (YS⇩R, C₀⇩R, C₁⇩R) = closest_pair_rec XS⇩R; (YS⇩R', Δ⇩R', C₀⇩R', C₁⇩R') = closest_pair_rec_code XS⇩R; YS = Common.merge snd YS⇩L YS⇩R; YS' = Common.merge snd YS⇩L' YS⇩R'; (C₀, C₁) = combine (C₀⇩L, C₁⇩L) (C₀⇩R, C₁⇩R) L YS; (Δ', C₀', C₁') = combine_code (Δ⇩L', C₀⇩L', C₁⇩L') (Δ⇩R', C₀⇩R', C₁⇩R') L YS'⟧ ⟹ 1 < length XS⇩R› 2. ‹⟦¬ length xs ≤ 3; 1 < length xs; (XS⇩L, XS⇩R) = split_at (length xs div 2) xs; L = fst (hd XS⇩R); (YS⇩L, C₀⇩L, C₁⇩L) = closest_pair_rec XS⇩L; (YS⇩L', Δ⇩L', C₀⇩L', C₁⇩L') = closest_pair_rec_code XS⇩L; (YS⇩R, C₀⇩R, C₁⇩R) = closest_pair_rec XS⇩R; (YS⇩R', Δ⇩R', C₀⇩R', C₁⇩R') = closest_pair_rec_code XS⇩R; YS = Common.merge snd YS⇩L YS⇩R; YS' = Common.merge snd YS⇩L' YS⇩R'; (C₀, C₁) = combine (C₀⇩L, C₁⇩L) (C₀⇩R, C₁⇩R) L YS; (Δ', C₀', C₁') = combine_code (Δ⇩L', C₀⇩L', C₁⇩L') (Δ⇩R', C₀⇩R', C₁⇩R') L YS'⟧ ⟹ length XS⇩R < length xs› discuss goal 1*) apply ((auto simp: split_at_take_drop_conv (*‹split_at ?n ?xs = (take ?n ?xs, drop ?n ?xs)›*))[1]) (*discuss goal 2*) apply ((auto simp: split_at_take_drop_conv (*‹split_at ?n ?xs = (take ?n ?xs, drop ?n ?xs)›*))[1]) (*proven 2 subgoals*) . hence IHR: "YS⇩R = YS⇩R'" using "1.IH" (*‹∀ys. length ys < length xs ⟶ 1 < length ys ⟶ (∀x xa xb. (x, xa, xb) = closest_pair_rec ys ⟶ (∀xa xb xc xd. (xa, xb, xc, xd) = closest_pair_rec_code ys ⟶ x = xa))›*) defs (*‹(XS⇩L, XS⇩R) = split_at (length xs div 2) xs› ‹L = fst (hd XS⇩R)› ‹(YS⇩L, C₀⇩L, C₁⇩L) = closest_pair_rec XS⇩L› ‹(YS⇩L'::(int × int) list, Δ⇩L'::int, C₀⇩L'::int × int, C₁⇩L'::int × int) = closest_pair_rec_code (XS⇩L::(int × int) list)› ‹(YS⇩R, C₀⇩R, C₁⇩R) = closest_pair_rec XS⇩R› ‹(YS⇩R', Δ⇩R', C₀⇩R', C₁⇩R') = closest_pair_rec_code XS⇩R› ‹YS = Common.merge snd YS⇩L YS⇩R› ‹YS' = Common.merge snd YS⇩L' YS⇩R'› ‹(C₀::int × int, C₁::int × int) = combine (C₀⇩L::int × int, C₁⇩L::int × int) (C₀⇩R::int × int, C₁⇩R::int × int) (L::int) (YS::(int × int) list)› ‹(Δ'::int, C₀'::int × int, C₁'::int × int) = combine_code (Δ⇩L'::int, C₀⇩L'::int × int, C₁⇩L'::int × int) (Δ⇩R'::int, C₀⇩R'::int × int, C₁⇩R'::int × int) (L::int) (YS'::(int × int) list)›*) by metis have "(YS, C₀, C₁) = closest_pair_rec xs" using False (*‹¬ length xs ≤ 3›*) closest_pair_rec_simps (*‹⟦?n = length ?xs; ¬ ?n ≤ 3⟧ ⟹ closest_pair_rec ?xs = (let (xs⇩L, xs⇩R) = split_at (?n div 2) ?xs; (ys⇩L, p₀⇩L, p₁⇩L) = closest_pair_rec xs⇩L; (ys⇩R, p₀⇩R, p₁⇩R) = closest_pair_rec xs⇩R; ys = Common.merge snd ys⇩L ys⇩R in (ys, combine (p₀⇩L, p₁⇩L) (p₀⇩R, p₁⇩R) (fst (hd xs⇩R)) ys))›*) defs(1,2,3,5,7,9) (*‹(XS⇩L, XS⇩R) = split_at (length xs div 2) xs› ‹L = fst (hd XS⇩R)› ‹(YS⇩L, C₀⇩L, C₁⇩L) = closest_pair_rec XS⇩L› ‹(YS⇩R, C₀⇩R, C₁⇩R) = closest_pair_rec XS⇩R› ‹YS = Common.merge snd YS⇩L YS⇩R› ‹(C₀, C₁) = combine (C₀⇩L, C₁⇩L) (C₀⇩R, C₁⇩R) L YS›*) by (auto simp: Let_def (*‹Let ?s ?f ≡ ?f ?s›*) split: prod.split (*‹?P (case ?prod of (x, xa) ⇒ ?f x xa) = (∀x1 x2. ?prod = (x1, x2) ⟶ ?P (?f x1 x2))›*)) moreover have "(YS', Δ', C₀', C₁') = closest_pair_rec_code xs" using False (*‹¬ length xs ≤ 3›*) closest_pair_rec_code_simps (*‹⟦?n = length ?xs; ¬ ?n ≤ 3⟧ ⟹ closest_pair_rec_code ?xs = (let (xs⇩L, xs⇩R) = split_at (?n div 2) ?xs; l = fst (hd xs⇩R); (ys⇩L, p⇩L) = closest_pair_rec_code xs⇩L; (ys⇩R, p⇩R) = closest_pair_rec_code xs⇩R; ys = Common.merge snd ys⇩L ys⇩R in (ys, combine_code p⇩L p⇩R l ys))›*) defs(1,2,4,6,8,10) (*‹(XS⇩L, XS⇩R) = split_at (length xs div 2) xs› ‹L = fst (hd XS⇩R)› ‹(YS⇩L', Δ⇩L', C₀⇩L', C₁⇩L') = closest_pair_rec_code XS⇩L› ‹(YS⇩R'::(int × int) list, Δ⇩R'::int, C₀⇩R'::int × int, C₁⇩R'::int × int) = closest_pair_rec_code (XS⇩R::(int × int) list)› ‹YS' = Common.merge snd YS⇩L' YS⇩R'› ‹(Δ', C₀', C₁') = combine_code (Δ⇩L', C₀⇩L', C₁⇩L') (Δ⇩R', C₀⇩R', C₁⇩R') L YS'›*) by (auto simp: Let_def (*‹Let ?s ?f ≡ ?f ?s›*) split: prod.split (*‹?P (case ?prod of (x, xa) ⇒ ?f x xa) = (∀x1 x2. ?prod = (x1, x2) ⟶ ?P (?f x1 x2))›*)) moreover have "YS = YS'" using IHL (*‹YS⇩L = YS⇩L'›*) IHR (*‹YS⇩R = YS⇩R'›*) YS_def (*‹(YS::(int × int) list) = Common.merge snd (YS⇩L::(int × int) list) (YS⇩R::(int × int) list)› ‹YS' = Common.merge snd YS⇩L' YS⇩R'›*) by simp ultimately show "?thesis" (*goal: ‹(ys::(int × int) list) = (ys'::(int × int) list)›*) by (metis "1.prems" (*‹(ys, c₀, c₁) = closest_pair_rec xs› ‹(ys', δ', c₀', c₁') = closest_pair_rec_code xs›*) (2,3) Pair_inject (*‹⟦(?a, ?b) = (?a', ?b'); ⟦?a = ?a'; ?b = ?b'⟧ ⟹ ?R⟧ ⟹ ?R›*)) qed qed lemma closest_pair_rec_code_eq: assumes "1 < length xs" assumes "(ys, c₀, c₁) = closest_pair_rec xs" assumes "(ys', δ', c₀', c₁') = closest_pair_rec_code xs" shows "c₀ = c₀' ∧ c₁ = c₁'" using assms proof (induction xs arbitrary: ys c₀ c₁ ys' δ' c₀' c₁' rule: length_induct) case (1 xs) let ?n = "length xs" show ?case proof (cases "?n ≤ 3") case True hence "(c₀, c₁) = closest_pair_bf xs" using "1.prems"(2) closest_pair_rec.simps by simp moreover have "(δ', c₀', c₁') = closest_pair_bf_code xs" using "1.prems"(3) closest_pair_rec_code.simps by (simp add: True) ultimately show ?thesis using "1.prems"(1) closest_pair_bf_code_eq by simp next case False obtain XS⇩L XS⇩R where XS⇩L⇩R_def: "(XS⇩L, XS⇩R) = split_at (?n div 2) xs" using prod.collapse by blast define L where "L = fst (hd XS⇩R)" obtain YS⇩L C₀⇩L C₁⇩L YS⇩L' Δ⇩L' C₀⇩L' C₁⇩L' where YSC₀₁⇩L_def: "(YS⇩L, C₀⇩L, C₁⇩L) = closest_pair_rec XS⇩L" "(YS⇩L', Δ⇩L', C₀⇩L', C₁⇩L') = closest_pair_rec_code XS⇩L" using prod.collapse by metis obtain YS⇩R C₀⇩R C₁⇩R YS⇩R' Δ⇩R' C₀⇩R' C₁⇩R' where YSC₀₁⇩R_def: "(YS⇩R, C₀⇩R, C₁⇩R) = closest_pair_rec XS⇩R" "(YS⇩R', Δ⇩R', C₀⇩R', C₁⇩R') = closest_pair_rec_code XS⇩R" using prod.collapse by metis define YS YS' where YS_def: "YS = merge (λp. snd p) YS⇩L YS⇩R" "YS' = merge (λp. snd p) YS⇩L' YS⇩R'" obtain C₀ C₁ Δ' C₀' C₁' where C₀₁_def: "(C₀, C₁) = combine (C₀⇩L, C₁⇩L) (C₀⇩R, C₁⇩R) L YS" "(Δ', C₀', C₁') = combine_code (Δ⇩L', C₀⇩L', C₁⇩L') (Δ⇩R', C₀⇩R', C₁⇩R') L YS'" using prod.collapse by metis note defs = XS⇩L⇩R_def L_def YSC₀₁⇩L_def YSC₀₁⇩R_def YS_def C₀₁_def have "1 < length XS⇩L" "length XS⇩L < length xs" using False "1.prems"(1) defs by (auto simp: split_at_take_drop_conv) hence IHL: "C₀⇩L = C₀⇩L'" "C₁⇩L = C₁⇩L'" using "1.IH" defs by metis+ have "1 < length XS⇩R" "length XS⇩R < length xs" using False "1.prems"(1) defs by (auto simp: split_at_take_drop_conv) hence IHR: "C₀⇩R = C₀⇩R'" "C₁⇩R = C₁⇩R'" using "1.IH" defs by metis+ have "sorted_snd YS⇩L" "sorted_snd YS⇩R" using closest_pair_rec_set_length_sorted_snd YSC₀₁⇩L_def(1) YSC₀₁⇩R_def(1) by blast+ hence "sorted_snd YS" using sorted_merge sorted_snd_def YS_def by blast moreover have "YS = YS'" using defs ‹1 < length XS⇩L› ‹1 < length XS⇩R› closest_pair_rec_ys_eq by blast moreover have "Δ⇩L' = dist_code C₀⇩L' C₁⇩L'" "Δ⇩R' = dist_code C₀⇩R' C₁⇩R'" using defs ‹1 < length XS⇩L› ‹1 < length XS⇩R› closest_pair_rec_code_dist_eq by blast+ ultimately have "C₀ = C₀'" "C₁ = C₁'" using combine_code_eq IHL IHR C₀₁_def by blast+ moreover have "(YS, C₀, C₁) = closest_pair_rec xs" using False closest_pair_rec_simps defs(1,2,3,5,7,9) by (auto simp: Let_def split: prod.split) moreover have "(YS', Δ', C₀', C₁') = closest_pair_rec_code xs" using False closest_pair_rec_code_simps defs(1,2,4,6,8,10) by (auto simp: Let_def split: prod.split) ultimately show ?thesis using "1.prems"(2,3) by (metis Pair_inject) qed qed declare closest_pair.simps [simp add] fun closest_pair_code :: "point list ⇒ (point * point)" where "closest_pair_code [] = undefined" | "closest_pair_code [_] = undefined" | "closest_pair_code ps = (let (_, _, c₀, c₁) = closest_pair_rec_code (mergesort fst ps) in (c₀, c₁))" lemma closest_pair_code_eq: "closest_pair ps = closest_pair_code ps" proof (induction ps rule: induct_list012) case (3 x y zs) obtain ys c₀ c₁ ys' δ' c₀' c₁' where *: "(ys, c₀, c₁) = closest_pair_rec (mergesort fst (x # y # zs))" "(ys', δ', c₀', c₁') = closest_pair_rec_code (mergesort fst (x # y # zs))" by (metis prod_cases3) moreover have "1 < length (mergesort fst (x # y # zs))" using length_mergesort[of fst "x # y # zs"] by simp ultimately have "c₀ = c₀'" "c₁ = c₁'" using closest_pair_rec_code_eq by blast+ thus ?case using * by (auto split: prod.splits) qed auto export_code closest_pair_code in OCaml module_name Verified end
{ "path": "afp-2025-02-12/thys/Closest_Pair_Points/Closest_Pair.thy", "repo": "afp-2025-02-12", "sha": "df4f1e70e8c8e4b03c7479c46382ee42ba9f8fe435236f4d8481444c3cdc6559" }
section ‹Tangent numbers› theory Tangent_Numbers imports "HOL-Computational_Algebra.Computational_Algebra" "Bernoulli.Bernoulli_FPS" "Polynomial_Interpolation.Ring_Hom_Poly" Boustrophedon_Transform_Library Alternating_Permutations begin subsection ‹The higher derivatives of $\tan x$› text ‹ The $n$-th derivatives of $\tan x$ are: ▪ $\tan x ^ 2 + 1$ ▪ $\tan x ^ 3 + \tan x$ ▪ $6 \tan x ^ 4 + 8 \tan x ^ 2 + 2$ ▪ $24 \tan x ^ 5 + 40 \tan x ^ 3 + 16 \tan x$ ▪ \dots No pattern is readily apparent, but it is obvious that for any $n$, the $n$-th derivative of $\tan x$ can be expressed as a polynomial of degree $n+1$ in $\tan x$, i.e.\ it is of the form $P_n(\tan x)$ for some family of polynomials $P_n$. Using the fact that $\tan' x = \tan x ^ 2 + 1$ and the chain rule, one can deduce that $P_{n+1}(X) = (X^2 + 1)P_n'(X)$, and of course $P_0(X) = X$, which gives us a recursive characterisation of $P_n$. › primrec tangent_poly :: "nat ⇒ nat poly" where "tangent_poly 0 = [:0, 1:]" | "tangent_poly (Suc n) = pderiv (tangent_poly n) * [:1,0,1:]" lemma degree_tangent_poly [simp]: "degree (tangent_poly n) = n + 1" apply (induction n) (*goals: 1. ‹degree (tangent_poly 0) = 0 + 1› 2. ‹⋀n. degree (tangent_poly n) = n + 1 ⟹ degree (tangent_poly (Suc n)) = Suc n + 1› discuss goal 1*) apply ((auto simp: degree_mult_eq (*‹⟦(?p::?'a poly) ≠ (0::?'a poly); (?q::?'a poly) ≠ (0::?'a poly)⟧ ⟹ degree (?p * ?q) = degree ?p + degree ?q›*) pderiv_eq_0_iff (*‹(pderiv (?p::?'a poly) = (0::?'a poly)) = (degree ?p = (0::nat))›*) degree_pderiv (*‹degree (pderiv (?p::?'a poly)) = degree ?p - (1::nat)›*) simp del: mult_pCons_right (*‹(?p::?'a poly) * pCons (?a::?'a) (?q::?'a poly) = Polynomial.smult ?a ?p + pCons (0::?'a) (?p * ?q)›*))[1]) (*discuss goal 2*) apply ((auto simp: degree_mult_eq (*‹⟦?p ≠ 0; ?q ≠ 0⟧ ⟹ degree (?p * ?q) = degree ?p + degree ?q›*) pderiv_eq_0_iff (*‹(pderiv ?p = 0) = (degree ?p = 0)›*) degree_pderiv (*‹degree (pderiv ?p) = degree ?p - 1›*) simp del: mult_pCons_right (*‹?p * pCons ?a ?q = Polynomial.smult ?a ?p + pCons 0 (?p * ?q)›*))[1]) (*proven 2 subgoals*) . lemma tangent_poly_altdef [code]: "tangent_poly n = ((λp. pderiv p * [:1,0,1:]) ^^ n) [:0, 1:]" apply (induction n) (*goals: 1. ‹tangent_poly 0 = ((λp. pderiv p * [:1, 0, 1:]) ^^ 0) [:0, 1:]› 2. ‹⋀n. tangent_poly n = ((λp. pderiv p * [:1, 0, 1:]) ^^ n) [:0, 1:] ⟹ tangent_poly (Suc n) = ((λp. pderiv p * [:1, 0, 1:]) ^^ Suc n) [:0, 1:]› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) . lemma fps_tan_higher_deriv': "(fps_deriv ^^ n) (fps_tan (1::'a::field_char_0)) = fps_compose (fps_of_poly (map_poly of_nat (tangent_poly n))) (fps_tan 1)" proof (-) (*goal: ‹(fps_deriv ^^ (n::nat)) (fps_tan (1::'a::field_char_0)) = fps_of_poly (map_poly of_nat (tangent_poly n)) oo fps_tan (1::'a::field_char_0)›*) interpret of_nat_poly_hom: map_poly_comm_semiring_hom of_nat apply standard (*goals: 1. ‹of_nat (0::nat) = (0::'b)› 2. ‹⋀(x::nat) y::nat. of_nat (x + y) = of_nat x + of_nat y› 3. ‹of_nat (1::nat) = (1::'b)› 4. ‹⋀(x::nat) y::nat. of_nat (x * y) = of_nat x * of_nat 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]) (*proven 4 subgoals*) . show "?thesis" (*goal: ‹(fps_deriv ^^ n) (fps_tan 1) = fps_of_poly (map_poly of_nat (tangent_poly n)) oo fps_tan 1›*) apply (induction n) (*goals: 1. ‹(fps_deriv ^^ 0) (fps_tan 1) = fps_of_poly (map_poly of_nat (tangent_poly 0)) oo fps_tan 1› 2. ‹⋀n. (fps_deriv ^^ n) (fps_tan 1) = fps_of_poly (map_poly of_nat (tangent_poly n)) oo fps_tan 1 ⟹ (fps_deriv ^^ Suc n) (fps_tan 1) = fps_of_poly (map_poly of_nat (tangent_poly (Suc n))) oo fps_tan 1› 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 120 facts*) fps_of_poly_pderiv (*‹fps_of_poly (pderiv ?p) = fps_deriv (fps_of_poly ?p)›*) fps_of_poly_add (*‹fps_of_poly (?p + ?q) = fps_of_poly ?p + fps_of_poly ?q›*) fps_of_poly_pCons (*‹fps_of_poly (pCons ?c ?p) = fps_const ?c + fps_of_poly ?p * fps_X›*) fps_compose_add_distrib (*‹?a + ?b oo ?c = (?a oo ?c) + (?b oo ?c)›*) fps_compose_mult_distrib (*‹?c $ 0 = 0 ⟹ ?a * ?b oo ?c = (?a oo ?c) * (?b oo ?c)›*) fps_compose_deriv (*‹?b $ 0 = 0 ⟹ fps_deriv (?a oo ?b) = (fps_deriv ?a oo ?b) * fps_deriv ?b›*) fps_tan_deriv' (*‹fps_deriv (fps_tan 1) = 1 + (fps_tan 1)²›*) power2_eq_square (*‹?a² = ?a * ?a›*) of_nat_poly_pderiv (*‹map_poly of_nat (pderiv ?p) = pderiv (map_poly of_nat ?p)›*)) (*discuss goal 2*) apply (simp add: hom_distribs (*‹of_int ((?x::int) + (?y::int)) = of_int ?x + of_int ?y› ‹of_int (sum (?f::?'c::type ⇒ int) (?X::?'c::type set)) = (∑x::?'c::type∈?X. of_int (?f x))› ‹of_int (∑⇩# (?X::int multiset)) = ∑⇩# (image_mset of_int ?X)› ‹of_int ((?x::int) * (?y::int)) = of_int ?x * of_int ?y› ‹of_int ((?x::int) ^ (?n::nat)) = of_int ?x ^ ?n› ‹of_int (- (?x::int)) = - of_int ?x› ‹of_int ((?x::int) - (?y::int)) = of_int ?x - of_int ?y› ‹of_int (prod (?f::?'c::type ⇒ int) (?X::?'c::type set)) = (∏x::?'c::type∈?X. of_int (?f x))› ‹of_rat ((?x::rat) + (?y::rat)) = of_rat ?x + of_rat ?y› ‹of_rat (sum (?f::?'c::type ⇒ rat) (?X::?'c::type set)) = (∑x::?'c::type∈?X. of_rat (?f x))› ‹of_rat (∑⇩# (?X::rat multiset)) = ∑⇩# (image_mset of_rat ?X)› ‹of_rat ((?x::rat) * (?y::rat)) = of_rat ?x * of_rat ?y› and more 120 facts*) fps_of_poly_pderiv (*‹fps_of_poly (pderiv (?p::?'a::{comm_semiring_1,semiring_no_zero_divisors} poly)) = fps_deriv (fps_of_poly ?p)›*) fps_of_poly_add (*‹fps_of_poly ((?p::?'a::comm_monoid_add poly) + (?q::?'a::comm_monoid_add poly)) = fps_of_poly ?p + fps_of_poly ?q›*) fps_of_poly_pCons (*‹fps_of_poly (pCons (?c::?'a::semiring_1) (?p::?'a::semiring_1 poly)) = fps_const ?c + fps_of_poly ?p * fps_X›*) fps_compose_add_distrib (*‹(?a::?'a::semiring_1 fps) + (?b::?'a::semiring_1 fps) oo (?c::?'a::semiring_1 fps) = (?a oo ?c) + (?b oo ?c)›*) fps_compose_mult_distrib (*‹(?c::?'a::idom fps) $ (0::nat) = (0::?'a::idom) ⟹ (?a::?'a::idom fps) * (?b::?'a::idom fps) oo ?c = (?a oo ?c) * (?b oo ?c)›*) fps_compose_deriv (*‹(?b::?'a::idom fps) $ (0::nat) = (0::?'a::idom) ⟹ fps_deriv ((?a::?'a::idom fps) oo ?b) = (fps_deriv ?a oo ?b) * fps_deriv ?b›*) fps_tan_deriv' (*‹fps_deriv (fps_tan (1::?'a::field_char_0)) = (1::?'a::field_char_0 fps) + (fps_tan (1::?'a::field_char_0))²›*) power2_eq_square (*‹(?a::?'a::monoid_mult)² = ?a * ?a›*) of_nat_poly_pderiv (*‹map_poly of_nat (pderiv (?p::nat poly)) = pderiv (map_poly of_nat ?p)›*)) (*proven 2 subgoals*) . qed theorem fps_tan_higher_deriv: "(fps_deriv ^^ n) (fps_tan 1) = poly (map_poly of_int (tangent_poly n)) (fps_tan (1::'a::field_char_0))" using fps_tan_higher_deriv'[of n] (*‹(fps_deriv ^^ n) (fps_tan 1) = fps_of_poly (map_poly of_nat (tangent_poly n)) oo fps_tan 1›*) apply (subst (asm) fps_compose_of_poly (*‹(?f::?'a fps) $ (0::nat) = (0::?'a) ⟹ fps_of_poly (?p::?'a poly) oo ?f = poly (map_poly fps_const ?p) ?f›*)) (*goals: 1. ‹fps_tan 1 $ 0 = 0› 2. ‹(fps_deriv ^^ n) (fps_tan 1) = poly (map_poly fps_const (map_poly of_nat (tangent_poly n))) (fps_tan 1) ⟹ (fps_deriv ^^ n) (fps_tan 1) = poly (map_poly (λx. of_int (int x)) (tangent_poly n)) (fps_tan 1)› discuss goal 1*) apply (simp add: map_poly_map_poly (*‹?f 0 = 0 ⟹ map_poly ?f (map_poly ?g ?p) = map_poly (?f ∘ ?g) ?p›*) o_def (*‹?f ∘ ?g = (λx. ?f (?g x))›*) fps_of_nat (*‹fps_const (of_nat ?c) = of_nat ?c›*)) (*discuss goal 2*) apply (simp add: map_poly_map_poly (*‹?f 0 = 0 ⟹ map_poly ?f (map_poly ?g ?p) = map_poly (?f ∘ ?g) ?p›*) o_def (*‹?f ∘ ?g = (λx. ?f (?g x))›*) fps_of_nat (*‹fps_const (of_nat ?c) = of_nat ?c›*)) (*proven 2 subgoals*) . text ‹ For easier notation, we give the name ``auxiliary tangent numbers'' to the coefficients of these polynomials and treat them as a number triangle $T_{n,j}$. These will aid us in the computation of the actual tangent numbers later. › definition tangent_number_aux :: "nat ⇒ nat ⇒ nat" where "tangent_number_aux n j = poly.coeff (tangent_poly n) j" text ‹ The coefficients satisfy the following recurrence and boundary conditions: ▪ $T_{0, 1} = 1$ ▪ $T_{0, j} = 0$ if $j\neq 1$ ▪ $T_{n, j} = 0$ if $j > n+1$ or $n+j$ even ▪ $T_{n, n+1} = n!$ ▪ $T_{n+1, j+1} = j T_{n,j} + (j+2) T_{n, j+2}$ › lemma tangent_number_aux_0_left: "tangent_number_aux 0 j = (if j = 1 then 1 else 0)" unfolding tangent_number_aux_def (*goal: ‹poly.coeff (tangent_poly 0) j = (if j = 1 then 1 else 0)›*) by (auto simp: coeff_pCons (*‹poly.coeff (pCons ?x ?xa) = case_nat ?x (poly.coeff ?xa)›*) 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 tangent_number_aux_0_left' [simp]: "j ≠ 1 ⟹ tangent_number_aux 0 j = 0" "tangent_number_aux 0 (Suc 0) = 1" (*goals: 1. ‹(j::nat) ≠ (1::nat) ⟹ tangent_number_aux (0::nat) j = (0::nat)› 2. ‹tangent_number_aux (0::nat) (Suc (0::nat)) = (1::nat)› discuss goal 1*) apply (simp add: tangent_number_aux_0_left (*‹tangent_number_aux 0 ?j = (if ?j = 1 then 1 else 0)›*)) (*discuss goal 2*) apply (simp add: tangent_number_aux_0_left (*‹tangent_number_aux 0 ?j = (if ?j = 1 then 1 else 0)›*)) (*proven 2 subgoals*) . lemma tangent_number_aux_0_right: "tangent_number_aux (Suc n) 0 = poly.coeff (tangent_poly n) 1" unfolding tangent_number_aux_def tangent_poly.simps (*goal: ‹poly.coeff (pderiv (tangent_poly n) * [:1, 0, 1:]) 0 = poly.coeff (tangent_poly n) 1›*) by (auto simp: coeff_pderiv (*‹poly.coeff (pderiv ?p) ?n = of_nat (Suc ?n) * poly.coeff ?p (Suc ?n)›*)) lemma tangent_number_aux_rec: "tangent_number_aux (Suc n) (Suc j) = j * tangent_number_aux n j + (j + 2) * tangent_number_aux n (j + 2)" unfolding tangent_number_aux_def tangent_poly.simps (*goal: ‹poly.coeff (pderiv (tangent_poly n) * [:1, 0, 1:]) (Suc j) = j * poly.coeff (tangent_poly n) j + (j + 2) * poly.coeff (tangent_poly n) (j + 2)›*) by (simp add: coeff_pderiv (*‹poly.coeff (pderiv ?p) ?n = of_nat (Suc ?n) * poly.coeff ?p (Suc ?n)›*) coeff_pCons (*‹poly.coeff (pCons ?x ?xa) = case_nat ?x (poly.coeff ?xa)›*) 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 tangent_number_aux_rec': "n > 0 ⟹ j > 0 ⟹ tangent_number_aux n j = (j-1) * tangent_number_aux (n-1) (j-1) + (j+1) * tangent_number_aux (n-1) (j+1)" using tangent_number_aux_rec[of "n-1" "j-1"] (*‹tangent_number_aux (Suc (n - 1)) (Suc (j - 1)) = (j - 1) * tangent_number_aux (n - 1) (j - 1) + (j - 1 + 2) * tangent_number_aux (n - 1) (j - 1 + 2)›*) by simp lemma tangent_number_aux_odd_eq_0: "even (n + j) ⟹ tangent_number_aux n j = 0" unfolding tangent_number_aux_def (*goal: ‹even (n + j) ⟹ poly.coeff (tangent_poly n) j = 0›*) apply (induction n arbitrary: j) (*goals: 1. ‹⋀j::nat. even ((0::nat) + j) ⟹ poly.coeff (tangent_poly (0::nat)) j = (0::nat)› 2. ‹⋀(n::nat) j::nat. ⟦⋀j::nat. even (n + j) ⟹ poly.coeff (tangent_poly n) j = (0::nat); even (Suc n + j)⟧ ⟹ poly.coeff (tangent_poly (Suc n)) j = (0::nat)› discuss goal 1*) apply ((auto simp: coeff_pCons (*‹poly.coeff (pCons (?x::?'a) (?xa::?'a poly)) = case_nat ?x (poly.coeff ?xa)›*) coeff_pderiv (*‹poly.coeff (pderiv (?p::?'a poly)) (?n::nat) = of_nat (Suc ?n) * poly.coeff ?p (Suc ?n)›*) split: nat.splits (*‹(?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)))› ‹(?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))))›*))[1]) (*discuss goal 2*) apply ((auto simp: coeff_pCons (*‹poly.coeff (pCons ?x ?xa) = case_nat ?x (poly.coeff ?xa)›*) coeff_pderiv (*‹poly.coeff (pderiv ?p) ?n = of_nat (Suc ?n) * poly.coeff ?p (Suc ?n)›*) 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 tangent_number_aux_eq_0 [simp]: "j > n + 1 ⟹ tangent_number_aux n j = 0" unfolding tangent_number_aux_def (*goal: ‹n + 1 < j ⟹ poly.coeff (tangent_poly n) j = 0›*) by (simp add: coeff_eq_0 (*‹degree (?p::?'a poly) < (?n::nat) ⟹ poly.coeff ?p ?n = (0::?'a)›*)) lemma tangent_number_aux_last [simp]: "tangent_number_aux n (Suc n) = fact n" apply (induction n) (*goals: 1. ‹tangent_number_aux (0::nat) (Suc (0::nat)) = fact (0::nat)› 2. ‹⋀n::nat. tangent_number_aux n (Suc n) = fact n ⟹ tangent_number_aux (Suc n) (Suc (Suc n)) = fact (Suc n)› discuss goal 1*) apply ((auto simp: tangent_number_aux_rec (*‹tangent_number_aux (Suc ?n) (Suc ?j) = ?j * tangent_number_aux ?n ?j + (?j + 2) * tangent_number_aux ?n (?j + 2)›*))[1]) (*discuss goal 2*) apply ((auto simp: tangent_number_aux_rec (*‹tangent_number_aux (Suc ?n) (Suc ?j) = ?j * tangent_number_aux ?n ?j + (?j + 2) * tangent_number_aux ?n (?j + 2)›*))[1]) (*proven 2 subgoals*) . lemma tangent_number_aux_last': "Suc m = n ⟹ tangent_number_aux m n = fact m" apply (cases n) (*goals: 1. ‹⟦Suc m = n; n = 0⟧ ⟹ tangent_number_aux m n = fact m› 2. ‹⋀nat. ⟦Suc m = n; n = Suc nat⟧ ⟹ tangent_number_aux m n = fact m› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . lemma tangent_number_aux_1_right [simp]: "tangent_number_aux i (Suc 0) = tangent_number_aux (i + 1) 0" by (simp add: tangent_number_aux_def (*‹tangent_number_aux ?n ?j = poly.coeff (tangent_poly ?n) ?j›*) coeff_pderiv (*‹poly.coeff (pderiv ?p) ?n = of_nat (Suc ?n) * poly.coeff ?p (Suc ?n)›*)) subsection ‹The tangent numbers› text ‹ The actual secant numbers $T_n$ are now defined to be the even-index coefficients of the power series expansion of $\tan x$ (the even-index ones are all $0$).~\oeiscite{A000182} This also turns out to be exactly the same as $T_{n, 0}$. › definition tangent_number :: "nat ⇒ nat" where "tangent_number n = nat (floor (fps_nth (fps_tan 1) (2*n-1) * fact (2*n-1) :: real))" lemma tangent_number_conv_zigzag_number: "n > 0 ⟹ tangent_number n = zigzag_number (2 * n - 1)" unfolding tangent_number_def (*goal: ‹0 < n ⟹ nat ⌊fps_tan 1 $ (2 * n - 1) * fact (2 * n - 1)⌋ = zigzag_number (2 * n - 1)›*) apply (subst zigzag_number_conv_fps_tan [symmetric] (*‹odd ?n ⟹ fps_tan 1 $ ?n * fact ?n = real (zigzag_number ?n)›*)) (*goals: 1. ‹0 < n ⟹ odd (2 * n - 1)› 2. ‹0 < n ⟹ nat ⌊real (zigzag_number (2 * n - 1))⌋ = zigzag_number (2 * n - 1)› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . lemma tangent_number_0 [simp]: "tangent_number 0 = 0" by (simp add: tangent_number_def (*‹tangent_number ?n = nat ⌊fps_tan 1 $ (2 * ?n - 1) * fact (2 * ?n - 1)⌋›*) fps_tan_def (*‹fps_tan ?c = fps_sin ?c / fps_cos ?c›*)) lemma fps_nth_tan_aux: "fps_tan (1::'a::field_char_0) $ (2*n-1) = of_nat (tangent_number_aux (2*n-1) 0) / fact (2*n-1)" proof (cases "n = 0") (*goals: 1. ‹n = 0 ⟹ fps_tan 1 $ (2 * n - 1) = of_nat (tangent_number_aux (2 * n - 1) 0) / fact (2 * n - 1)› 2. ‹n ≠ 0 ⟹ fps_tan 1 $ (2 * n - 1) = of_nat (tangent_number_aux (2 * n - 1) 0) / fact (2 * n - 1)›*) case False (*‹n ≠ 0›*) interpret of_nat_poly_hom: map_poly_comm_semiring_hom of_nat apply standard (*goals: 1. ‹of_nat (0::nat) = (0::'b)› 2. ‹⋀(x::nat) y::nat. of_nat (x + y) = of_nat x + of_nat y› 3. ‹of_nat (1::nat) = (1::'b)› 4. ‹⋀(x::nat) y::nat. of_nat (x * y) = of_nat x * of_nat 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]) (*proven 4 subgoals*) . from False (*‹n ≠ 0›*) have n: "n > 0" by simp have "fps_nth ((fps_deriv ^^ (2 * n - 1)) (fps_tan (1::'a))) 0 = fact (2*n-1) * fps_nth (fps_tan 1) (2*n-1)" by (simp add: fps_0th_higher_deriv (*‹(fps_deriv ^^ ?n) ?f $ 0 = fact ?n * ?f $ ?n›*)) also (*calculation: ‹(fps_deriv ^^ (2 * n - 1)) (fps_tan 1) $ 0 = fact (2 * n - 1) * fps_tan 1 $ (2 * n - 1)›*) have "(fps_deriv ^^ (2*n-1)) (fps_tan (1::'a)) = fps_of_poly (map_poly of_nat (tangent_poly (2*n-1))) oo fps_tan 1" apply (subst fps_tan_higher_deriv' (*‹(fps_deriv ^^ ?n) (fps_tan 1) = fps_of_poly (map_poly of_nat (tangent_poly ?n)) oo fps_tan 1›*)) (*goal: ‹(fps_deriv ^^ ((2::nat) * (n::nat) - (1::nat))) (fps_tan (1::'a)) = fps_of_poly (map_poly of_nat (tangent_poly ((2::nat) * n - (1::nat)))) oo fps_tan (1::'a)›*) by auto also (*calculation: ‹(fps_of_poly (map_poly of_nat (tangent_poly (2 * n - 1))) oo fps_tan 1) $ 0 = fact (2 * n - 1) * fps_tan 1 $ (2 * n - 1)›*) have "fps_nth … 0 = of_nat (tangent_number_aux (2*n-1) 0)" by (simp add: tangent_number_aux_def (*‹tangent_number_aux (?n::nat) (?j::nat) = poly.coeff (tangent_poly ?n) ?j›*)) finally (*calculation: ‹of_nat (tangent_number_aux ((2::nat) * (n::nat) - (1::nat)) (0::nat)) = fact ((2::nat) * n - (1::nat)) * fps_tan (1::'a) $ ((2::nat) * n - (1::nat))›*) show "?thesis" (*goal: ‹fps_tan 1 $ (2 * n - 1) = of_nat (tangent_number_aux (2 * n - 1) 0) / fact (2 * n - 1)›*) by simp qed (auto) (*solved the remaining goal: ‹n = 0 ⟹ fps_tan 1 $ (2 * n - 1) = of_nat (tangent_number_aux (2 * n - 1) 0) / fact (2 * n - 1)›*) lemma fps_nth_tan: "fps_nth (fps_tan (1::'a :: field_char_0)) (2*n - Suc 0) = of_int (tangent_number n) / fact (2*n-1)" using fps_nth_tan_aux[of n, where ?'a = real] (*‹fps_tan 1 $ (2 * n - 1) = real (tangent_number_aux (2 * n - 1) 0) / fact (2 * n - 1)›*) fps_nth_tan_aux[of n, where ?'a = 'a] (*‹fps_tan (1::'a::field_char_0) $ ((2::nat) * (n::nat) - (1::nat)) = of_nat (tangent_number_aux ((2::nat) * n - (1::nat)) (0::nat)) / fact ((2::nat) * n - (1::nat))›*) by (simp add: tangent_number_def (*‹tangent_number (?n::nat) = nat ⌊fps_tan (1::real) $ ((2::nat) * ?n - (1::nat)) * fact ((2::nat) * ?n - (1::nat))⌋›*)) lemma tangent_number_conv_aux [code]: "tangent_number n = tangent_number_aux (2*n - Suc 0) 0" using fps_nth_tan[of n, where ?'a = real] (*‹fps_tan 1 $ (2 * n - Suc 0) = real_of_int (int (tangent_number n)) / fact (2 * n - 1)›*) fps_nth_tan_aux[of n, where ?'a = real] (*‹fps_tan 1 $ (2 * n - 1) = real (tangent_number_aux (2 * n - 1) 0) / fact (2 * n - 1)›*) by simp lemma tangent_number_1 [simp]: "tangent_number (Suc 0) = 1" by (simp add: tangent_number_conv_aux (*‹tangent_number ?n = tangent_number_aux (2 * ?n - Suc 0) 0›*) tangent_number_aux_0_right (*‹tangent_number_aux (Suc ?n) 0 = poly.coeff (tangent_poly ?n) 1›*)) text ‹ The tangent number $T_n$ can be expressed in terms of the Bernoulli number $\mathcal{B}_n$: › theorem tangent_number_conv_bernoulli: "2 * real n * of_int (tangent_number n) = (-1)^(n+1) * (2^(2*n) * (2^(2*n) - 1)) * bernoulli (2*n)" proof (-) (*goal: ‹2 * real n * real_of_int (int (tangent_number n)) = (- 1) ^ (n + 1) * (2 ^ (2 * n) * (2 ^ (2 * n) - 1)) * bernoulli (2 * n)›*) define F where "F = (λc::complex. fps_compose bernoulli_fps (fps_const c * fps_X))" define E where "E = (λc::complex. fps_to_fls (fps_exp c))" have neqI1: "f ≠ g" if "fls_nth f 0 ≠ fls_nth g 0" for f :: "complex fls" and g :: "complex fls" using that (*‹fls_nth f 0 ≠ fls_nth g 0›*) by metis have [simp]: "fls_nth (E c) n = c ^ nat n / (fact (nat n))" if "n ≥ 0" for n and c using that (*‹0 ≤ n›*) by (auto simp: E_def (*‹E = (λc. fps_to_fls (fps_exp c))›*)) have [simp]: "subdegree (1 - fps_exp 1 :: complex fps) = 1" apply (rule subdegreeI (*‹⟦?f $ ?d ≠ 0; ⋀i. i < ?d ⟹ ?f $ i = 0⟧ ⟹ subdegree ?f = ?d›*)) (*goals: 1. ‹(1 - fps_exp 1) $ 1 ≠ 0› 2. ‹⋀i. i < 1 ⟹ (1 - fps_exp 1) $ i = 0› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . have "fps_to_fls (F (2*𝗂) - F (4*𝗂) - fps_const 𝗂 * fps_X) = 2 * fls_const 𝗂 * fls_X / (E (2*𝗂) - 1) - 4 * fls_const 𝗂 * fls_X / (E (4*𝗂) - 1) - fls_const 𝗂 * fls_X" unfolding F_def bernoulli_fps_def E_def (*goal: ‹fps_to_fls ((fps_X / (fps_exp (1::complex) - (1::complex fps)) oo fps_const ((2::complex) * 𝗂) * fps_X) - (fps_X / (fps_exp (1::complex) - (1::complex fps)) oo fps_const ((4::complex) * 𝗂) * fps_X) - fps_const 𝗂 * fps_X) = (2::complex fls) * fls_const 𝗂 * fls_X / (fps_to_fls (fps_exp ((2::complex) * 𝗂)) - (1::complex fls)) - (4::complex fls) * fls_const 𝗂 * fls_X / (fps_to_fls (fps_exp ((4::complex) * 𝗂)) - (1::complex fls)) - fls_const 𝗂 * fls_X›*) apply (simp flip: fls_compose_fps_to_fls (*‹⟦?G ≠ 0; ?G $ 0 = 0⟧ ⟹ fls_compose_fps (fps_to_fls ?F) ?G = fps_to_fls (?F oo ?G)›*)) (*goal: ‹fps_to_fls ((fps_X / (fps_exp 1 - 1) oo fps_const (2 * 𝗂) * fps_X) - (fps_X / (fps_exp 1 - 1) oo fps_const (4 * 𝗂) * fps_X) - fps_const 𝗂 * fps_X) = 2 * fls_const 𝗂 * fls_X / (fps_to_fls (fps_exp (2 * 𝗂)) - 1) - 4 * fls_const 𝗂 * fls_X / (fps_to_fls (fps_exp (4 * 𝗂)) - 1) - fls_const 𝗂 * fls_X›*) by (simp add: fls_compose_fps_divide (*‹⟦?H ≠ 0; ?H $ 0 = 0⟧ ⟹ fls_compose_fps (?F / ?G) ?H = fls_compose_fps ?F ?H / fls_compose_fps ?G ?H›*) fls_times_fps_to_fls (*‹fps_to_fls (?f * ?g) = fps_to_fls ?f * fps_to_fls ?g›*) fls_compose_fps_diff (*‹⟦?H ≠ 0; ?H $ 0 = 0⟧ ⟹ fls_compose_fps (?F - ?G) ?H = fls_compose_fps ?F ?H - fls_compose_fps ?G ?H›*) flip: fls_const_mult_const (*‹fls_const ?x * fls_const ?y = fls_const (?x * ?y)›*) fls_divide_fps_to_fls (*‹subdegree ?g ≤ subdegree ?f ⟹ fps_to_fls ?f / fps_to_fls ?g = fps_to_fls (?f / ?g)›*)) also (*calculation: ‹fps_to_fls (F (2 * 𝗂) - F (4 * 𝗂) - fps_const 𝗂 * fps_X) = 2 * fls_const 𝗂 * fls_X / (E (2 * 𝗂) - 1) - 4 * fls_const 𝗂 * fls_X / (E (4 * 𝗂) - 1) - fls_const 𝗂 * fls_X›*) have "E (4 * 𝗂) = E (2 * 𝗂) ^ 2" by (simp add: fps_exp_power_mult (*‹fps_exp ?c ^ ?n = fps_exp (of_nat ?n * ?c)›*) E_def (*‹E = (λc. fps_to_fls (fps_exp c))›*) flip: fps_to_fls_power (*‹fps_to_fls (?f ^ ?n) = fps_to_fls ?f ^ ?n›*)) also (*calculation: ‹fps_to_fls (F (2 * 𝗂) - F (4 * 𝗂) - fps_const 𝗂 * fps_X) = 2 * fls_const 𝗂 * fls_X / (E (2 * 𝗂) - 1) - 4 * fls_const 𝗂 * fls_X / ((E (2 * 𝗂))² - 1) - fls_const 𝗂 * fls_X›*) have "E (2 * 𝗂) ^ 2 - 1 = (E (2 * 𝗂) - 1) * (E (2 * 𝗂) + 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 15 facts*) power2_eq_square (*‹?a² = ?a * ?a›*)) also (*calculation: ‹fps_to_fls (F (2 * 𝗂) - F (4 * 𝗂) - fps_const 𝗂 * fps_X) = 2 * fls_const 𝗂 * fls_X / (E (2 * 𝗂) - 1) - 4 * fls_const 𝗂 * fls_X / ((E (2 * 𝗂) - 1) * (E (2 * 𝗂) + 1)) - fls_const 𝗂 * fls_X›*) have "2 * fls_const 𝗂 * fls_X / (E (2 * 𝗂) - 1) - 4 * fls_const 𝗂 * fls_X / ((E (2 * 𝗂) - 1) * (E (2 * 𝗂) + 1)) = 2 * fls_const 𝗂 * fls_X * (1 / (E (2 * 𝗂) + 1))" unfolding E_def (*goal: ‹(2::complex fls) * fls_const 𝗂 * fls_X / (fps_to_fls (fps_exp ((2::complex) * 𝗂)) - (1::complex fls)) - (4::complex fls) * fls_const 𝗂 * fls_X / ((fps_to_fls (fps_exp ((2::complex) * 𝗂)) - (1::complex fls)) * (fps_to_fls (fps_exp ((2::complex) * 𝗂)) + (1::complex fls))) = (2::complex fls) * fls_const 𝗂 * fls_X * ((1::complex fls) / (fps_to_fls (fps_exp ((2::complex) * 𝗂)) + (1::complex fls)))›*) 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*)) (*goal: ‹2 * fls_const 𝗂 * fls_X / (fps_to_fls (fps_exp (2 * 𝗂)) - 1) - 4 * fls_const 𝗂 * fls_X / ((fps_to_fls (fps_exp (2 * 𝗂)) - 1) * (fps_to_fls (fps_exp (2 * 𝗂)) + 1)) = 2 * fls_const 𝗂 * fls_X * (1 / (fps_to_fls (fps_exp (2 * 𝗂)) + 1))›*) 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 15 facts*) add_eq_0_iff (*‹(?a + ?b = 0) = (?b = - ?a)›*) fls_times_fps_to_fls (*‹fps_to_fls (?f * ?g) = fps_to_fls ?f * fps_to_fls ?g›*) neqI1 (*‹fls_nth ?f 0 ≠ fls_nth ?g 0 ⟹ ?f ≠ ?g›*)) also (*calculation: ‹fps_to_fls ((F::complex ⇒ complex fps) ((2::complex) * 𝗂) - F ((4::complex) * 𝗂) - fps_const 𝗂 * fps_X) = (2::complex fls) * fls_const 𝗂 * fls_X * ((1::complex fls) / ((E::complex ⇒ complex fls) ((2::complex) * 𝗂) + (1::complex fls))) - fls_const 𝗂 * fls_X›*) have "1 / (E (2 * 𝗂) + 1) = E (-𝗂) / (E (-𝗂) * (E (2 * 𝗂) + 1))" 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*) add_eq_0_iff2 (*‹(?a + ?b = 0) = (?a = - ?b)›*) neqI1 (*‹fls_nth ?f 0 ≠ fls_nth ?g 0 ⟹ ?f ≠ ?g›*)) also (*calculation: ‹fps_to_fls (F (2 * 𝗂) - F (4 * 𝗂) - fps_const 𝗂 * fps_X) = 2 * fls_const 𝗂 * fls_X * (E (- 𝗂) / (E (- 𝗂) * (E (2 * 𝗂) + 1))) - fls_const 𝗂 * fls_X›*) have "E (-𝗂) * (E (2 * 𝗂) + 1) = E 𝗂 + E (-𝗂)" by (simp add: E_def (*‹E = (λc. fps_to_fls (fps_exp c))›*) 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*) flip: fls_times_fps_to_fls (*‹fps_to_fls (?f * ?g) = fps_to_fls ?f * fps_to_fls ?g›*) fps_exp_add_mult (*‹fps_exp (?a + ?b) = fps_exp ?a * fps_exp ?b›*)) also (*calculation: ‹fps_to_fls (F (2 * 𝗂) - F (4 * 𝗂) - fps_const 𝗂 * fps_X) = 2 * fls_const 𝗂 * fls_X * (E (- 𝗂) / (E 𝗂 + E (- 𝗂))) - fls_const 𝗂 * fls_X›*) have "2 * fls_const 𝗂 * fls_X * (E (-𝗂) / (E 𝗂 + E (-𝗂))) - fls_const 𝗂 * fls_X = fls_X * (fls_const (-𝗂) * (1 - 2 * E (-𝗂) / (E 𝗂 + E (-𝗂))))" 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: ‹fps_to_fls (F (2 * 𝗂) - F (4 * 𝗂) - fps_const 𝗂 * fps_X) = fls_X * (fls_const (- 𝗂) * (1 - 2 * E (- 𝗂) / (E 𝗂 + E (- 𝗂))))›*) have "1 - 2 * E (-𝗂) / (E 𝗂 + E (-𝗂)) = (E 𝗂 - E (-𝗂)) / (E 𝗂 + E (-𝗂))" 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*) neqI1 (*‹fls_nth ?f 0 ≠ fls_nth ?g 0 ⟹ ?f ≠ ?g›*)) also (*calculation: ‹fps_to_fls ((F::complex ⇒ complex fps) ((2::complex) * 𝗂) - F ((4::complex) * 𝗂) - fps_const 𝗂 * fps_X) = fls_X * (fls_const (- 𝗂) * (((E::complex ⇒ complex fls) 𝗂 - E (- 𝗂)) / (E 𝗂 + E (- 𝗂))))›*) have "fls_const (-𝗂) * … = (-fls_const 𝗂/2 * (E 𝗂 - E (-𝗂))) / ((E 𝗂 + E (-𝗂)) / 2)" 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*) neqI1 (*‹fls_nth ?f 0 ≠ fls_nth ?g 0 ⟹ ?f ≠ ?g›*)) also (*calculation: ‹fps_to_fls (F (2 * 𝗂) - F (4 * 𝗂) - fps_const 𝗂 * fps_X) = fls_X * (- fls_const 𝗂 / 2 * (E 𝗂 - E (- 𝗂)) / ((E 𝗂 + E (- 𝗂)) / 2))›*) have "-fls_const 𝗂 / 2 * (E 𝗂 - E (-𝗂)) = fps_to_fls (fps_sin 1)" by (simp add: fps_sin_fps_exp_ii (*‹fps_sin ?c = (fps_exp (𝗂 * ?c) - fps_exp (- 𝗂 * ?c)) / fps_const (2 * 𝗂)›*) E_def (*‹E = (λc. fps_to_fls (fps_exp c))›*) fls_times_fps_to_fls (*‹fps_to_fls (?f * ?g) = fps_to_fls ?f * fps_to_fls ?g›*) flip: fls_const_divide_const (*‹fls_const ?x / fls_const ?y = fls_const (?x / ?y)›*)) also (*calculation: ‹fps_to_fls (F (2 * 𝗂) - F (4 * 𝗂) - fps_const 𝗂 * fps_X) = fls_X * (fps_to_fls (fps_sin 1) / ((E 𝗂 + E (- 𝗂)) / 2))›*) have "(E 𝗂 + E (-𝗂)) / 2 = fps_to_fls (fps_cos 1)" by (simp add: fps_cos_fps_exp_ii (*‹fps_cos ?c = (fps_exp (𝗂 * ?c) + fps_exp (- 𝗂 * ?c)) / fps_const 2›*) E_def (*‹E = (λc. fps_to_fls (fps_exp c))›*) fls_times_fps_to_fls (*‹fps_to_fls (?f * ?g) = fps_to_fls ?f * fps_to_fls ?g›*) flip: fls_const_divide_const (*‹fls_const ?x / fls_const ?y = fls_const (?x / ?y)›*)) also (*calculation: ‹fps_to_fls (F (2 * 𝗂) - F (4 * 𝗂) - fps_const 𝗂 * fps_X) = fls_X * (fps_to_fls (fps_sin 1) / fps_to_fls (fps_cos 1))›*) have "fls_X * (fps_to_fls (fps_sin 1) / fps_to_fls (fps_cos 1)) = fps_to_fls (fps_X * fps_tan (1::complex))" by (simp add: fps_tan_def (*‹fps_tan ?c = fps_sin ?c / fps_cos ?c›*) fls_times_fps_to_fls (*‹fps_to_fls (?f * ?g) = fps_to_fls ?f * fps_to_fls ?g›*) flip: fls_divide_fps_to_fls (*‹subdegree ?g ≤ subdegree ?f ⟹ fps_to_fls ?f / fps_to_fls ?g = fps_to_fls (?f / ?g)›*)) finally (*calculation: ‹fps_to_fls (F (2 * 𝗂) - F (4 * 𝗂) - fps_const 𝗂 * fps_X) = fps_to_fls (fps_X * fps_tan 1)›*) have eq: "F (2 * 𝗂) - F (4 * 𝗂) - fps_const 𝗂 * fps_X = fps_X * fps_tan 1" (is "?lhs = ?rhs") by (simp only: fps_to_fls_eq_iff (*‹(fps_to_fls ?f = fps_to_fls ?g) = (?f = ?g)›*)) show "2 * real n * of_int (tangent_number n) = (-1)^(n+1) * (2^(2*n) * (2^(2*n) - 1)) * bernoulli (2*n)" proof (cases "n = 0") (*goals: 1. ‹n = 0 ⟹ 2 * real n * real_of_int (int (tangent_number n)) = (- 1) ^ (n + 1) * (2 ^ (2 * n) * (2 ^ (2 * n) - 1)) * bernoulli (2 * n)› 2. ‹n ≠ 0 ⟹ 2 * real n * real_of_int (int (tangent_number n)) = (- 1) ^ (n + 1) * (2 ^ (2 * n) * (2 ^ (2 * n) - 1)) * bernoulli (2 * n)›*) case False (*‹(n::nat) ≠ (0::nat)›*) hence n: "n > 0" by simp have "fps_nth ?lhs (2*n) = (-1)^n * (2^(2*n) - 4^(2*n)) * of_real (bernoulli (2 * n)) / fact (2*n)" using n (*‹0 < n›*) unfolding F_def fps_nth_compose_linear fps_sub_nth (*goal: ‹(2 * 𝗂) ^ (2 * n) * bernoulli_fps $ (2 * n) - (4 * 𝗂) ^ (2 * n) * bernoulli_fps $ (2 * n) - (fps_const 𝗂 * fps_X) $ (2 * n) = (- 1) ^ n * (2 ^ (2 * n) - 4 ^ (2 * n)) * complex_of_real (bernoulli (2 * n)) / fact (2 * n)›*) 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 15 facts*) diff_divide_distrib (*‹((?a::?'a::division_ring) - (?b::?'a::division_ring)) / (?c::?'a::division_ring) = ?a / ?c - ?b / ?c›*)) also (*calculation: ‹(F (2 * 𝗂) - F (4 * 𝗂) - fps_const 𝗂 * fps_X) $ (2 * n) = (- 1) ^ n * (2 ^ (2 * n) - 4 ^ (2 * n)) * complex_of_real (bernoulli (2 * n)) / fact (2 * n)›*) note ‹?lhs = ?rhs› (*‹F (2 * 𝗂) - F (4 * 𝗂) - fps_const 𝗂 * fps_X = fps_X * fps_tan 1›*) also (*calculation: ‹(fps_X * fps_tan (1::complex)) $ ((2::nat) * (n::nat)) = (- (1::complex)) ^ n * ((2::complex) ^ ((2::nat) * n) - (4::complex) ^ ((2::nat) * n)) * complex_of_real (bernoulli ((2::nat) * n)) / fact ((2::nat) * n)›*) have "fps_nth ?rhs (2*n) = complex_of_int (tangent_number n) / fact (2 * n - 1)" using n (*‹(0::nat) < (n::nat)›*) by (simp add: fps_nth_tan (*‹fps_tan (1::?'a::field_char_0) $ ((2::nat) * (?n::nat) - Suc (0::nat)) = of_int (int (tangent_number ?n)) / fact ((2::nat) * ?n - (1::nat))›*)) finally (*calculation: ‹complex_of_int (int (tangent_number n)) / fact (2 * n - 1) = (- 1) ^ n * (2 ^ (2 * n) - 4 ^ (2 * n)) * complex_of_real (bernoulli (2 * n)) / fact (2 * n)›*) have "complex_of_int (tangent_number n) * (fact (2*n) / fact (2 * n - 1)) = (- 1) ^ n * (2 ^ (2 * n) - 4 ^ (2 * n)) * complex_of_real (bernoulli (2 * 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: ‹complex_of_int (int (tangent_number n)) * (fact (2 * n) / fact (2 * n - 1)) = (- 1) ^ n * (2 ^ (2 * n) - 4 ^ (2 * n)) * complex_of_real (bernoulli (2 * n))›*) have "complex_of_int (tangent_number n) * (fact (2*n) / fact (2 * n - 1)) = of_real (fact (2*n) / fact (2 * n - 1) * of_int (tangent_number n))" 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*)) also (*calculation: ‹complex_of_real (fact (2 * n) / fact (2 * n - 1) * real_of_int (int (tangent_number n))) = (- 1) ^ n * (2 ^ (2 * n) - 4 ^ (2 * n)) * complex_of_real (bernoulli (2 * n))›*) have "fact (2*n) / fact (2 * n - 1) = (2 * of_nat n :: real)" using fact_binomial[of 1 "2 * n", where ?'a = real] (*‹1 ≤ 2 * n ⟹ fact 1 * real (2 * n choose 1) = fact (2 * n) / fact (2 * n - 1)›*) n (*‹0 < n›*) by simp also (*calculation: ‹complex_of_real (2 * real n * real_of_int (int (tangent_number n))) = (- 1) ^ n * (2 ^ (2 * n) - 4 ^ (2 * n)) * complex_of_real (bernoulli (2 * n))›*) have "2 ^ (2 * n) - 4 ^ (2 * n) = -(2 ^ (2 * n) * (2 ^ (2 * n) - 1 :: complex))" 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*) flip: power_mult_distrib (*‹((?a::?'a) * (?b::?'a)) ^ (?n::nat) = ?a ^ ?n * ?b ^ ?n›*)) also (*calculation: ‹complex_of_real (2 * real n * real_of_int (int (tangent_number n))) = (- 1) ^ n * - (2 ^ (2 * n) * (2 ^ (2 * n) - 1)) * complex_of_real (bernoulli (2 * n))›*) have "(- 1) ^ n * - (2 ^ (2 * n) * (2 ^ (2 * n) - 1)) * complex_of_real (bernoulli (2 * n)) = of_real ((-1)^(n+1) * (2^(2*n) * (2^(2*n) - 1)) * bernoulli (2*n))" by simp finally (*calculation: ‹complex_of_real (2 * real n * real_of_int (int (tangent_number n))) = complex_of_real ((- 1) ^ (n + 1) * (2 ^ (2 * n) * (2 ^ (2 * n) - 1)) * bernoulli (2 * n))›*) show "?thesis" (*goal: ‹2 * real n * real_of_int (int (tangent_number n)) = (- 1) ^ (n + 1) * (2 ^ (2 * n) * (2 ^ (2 * n) - 1)) * bernoulli (2 * n)›*) by (simp only: of_real_eq_iff (*‹(of_real ?x = of_real ?y) = (?x = ?y)›*)) qed (auto) (*solved the remaining goal: ‹n = 0 ⟹ 2 * real n * real_of_int (int (tangent_number n)) = (- 1) ^ (n + 1) * (2 ^ (2 * n) * (2 ^ (2 * n) - 1)) * bernoulli (2 * n)›*) qed subsection ‹Efficient functional computation› text ‹ We will now formalise and verify an algorithm to compute the first $n$ tangent numbers relatively efficiently via the auxiliary tangent numbers. The algorithm is a functional variant of the imperative in-place algorithm given by Brent et al.~\<^cite>‹brent›. The functional algorithm could easily be adapted to one that returns a stream of all tangent numbers instead of a list of the first $n$ of them. The algorithm uses $O(n^2)$ additions and multiplications on integers, but since the numbers grow up to $\Theta(n \log n)$ bits, this translates to $O(n^3 \log{1+\varepsilon} n)$ bit operations. Note that Brent et al.\ only define the tangent numbers $T_n$ starting with $n = 1$, whereas we also defined $T_0 = 0$. The algorithm only computes $T_1, \ldots, T_n$. › function pochhammer_row_impl :: "nat ⇒ nat ⇒ nat ⇒ nat list" where "pochhammer_row_impl k n x = (if k ≥ n then [] else x # pochhammer_row_impl (Suc k) n (x * k))" by auto termination by (relation "measure (λ(k,n,_) ⇒ n - k)") auto lemmas [simp del] = pochhammer_row_impl.simps lemma pochhammer_rec'': "k > 0 ⟹ pochhammer n k = n * pochhammer (n+1) (k-1)" apply (cases k) (*goals: 1. ‹⟦0 < k; k = 0⟧ ⟹ pochhammer n k = n * pochhammer (n + 1) (k - 1)› 2. ‹⋀nat. ⟦0 < k; k = Suc nat⟧ ⟹ pochhammer n k = n * pochhammer (n + 1) (k - 1)› discuss goal 1*) apply ((auto simp: pochhammer_rec (*‹pochhammer ?a (Suc ?n) = ?a * pochhammer (?a + 1) ?n›*))[1]) (*discuss goal 2*) apply ((auto simp: pochhammer_rec (*‹pochhammer ?a (Suc ?n) = ?a * pochhammer (?a + 1) ?n›*))[1]) (*proven 2 subgoals*) . lemma pochhammer_row_impl_correct: "pochhammer_row_impl k n x = map (λi. x * pochhammer k i) [0..<n-k]" proof (induction k n x rule: pochhammer_row_impl.induct) case (1 k n x) show ?case proof (cases "k < n") case True have "pochhammer_row_impl k n x = x # map (λi. x * k * pochhammer (Suc k) i) [0..<n - (k + 1)]" using True by (subst pochhammer_row_impl.simps) (simp_all add: "1.IH") also have "map (λi. x * k * pochhammer (Suc k) i) [0..<n - (k + 1)] = map (λi. x * pochhammer k i) (map Suc [0..<n - (k + 1)])" by (simp add: pochhammer_rec) also have "map Suc [0..<n - (k + 1)] = [Suc 0..<n-k]" using True by (simp add: map_Suc_upt Suc_diff_Suc del: upt_Suc) also have "x # map (λi. x * pochhammer k i) [Suc 0..<n-k] = map (λi. x * pochhammer k i) (0 # [Suc 0..<n-k])" by simp also have "0 # [Suc 0..<n-k] = [0..<n-k]" using True by (subst upt_conv_Cons) auto finally show ?thesis . qed (subst pochhammer_row_impl.simps; auto) qed context fixes T :: "nat ⇒ nat ⇒ nat" defines "T ≡ tangent_number_aux" begin primrec tangent_number_impl_aux1 :: "nat ⇒ nat ⇒ nat list ⇒ nat list" where "tangent_number_impl_aux1 j y [] = []" | "tangent_number_impl_aux1 j y (x # xs) = (let x' = j * y + (j+2) * x in x' # tangent_number_impl_aux1 (j+1) x' xs)" lemma length_tangent_number_impl_aux1 [simp]: "length (tangent_number_impl_aux1 j y xs) = length xs" apply (induction xs arbitrary: j y) (*goals: 1. ‹⋀j y. length (tangent_number_impl_aux1 j y []) = length []› 2. ‹⋀a xs j y. (⋀j y. length (tangent_number_impl_aux1 j y xs) = length xs) ⟹ length (tangent_number_impl_aux1 j y (a # xs)) = length (a # xs)› discuss goal 1*) apply (simp add: Let_def (*‹Let (?s::?'a) (?f::?'a ⇒ ?'b) ≡ ?f ?s›*)) (*discuss goal 2*) apply (simp add: Let_def (*‹Let ?s ?f ≡ ?f ?s›*)) (*proven 2 subgoals*) . fun tangent_number_impl_aux2 :: "nat list ⇒ nat list" where "tangent_number_impl_aux2 [] = []" | "tangent_number_impl_aux2 (x # xs) = x # tangent_number_impl_aux2 (tangent_number_impl_aux1 0 x xs)" lemma tangent_number_impl_aux1_nth_eq: assumes "i < length xs" shows "tangent_number_impl_aux1 j y xs ! i = (j+i) * (if i = 0 then y else tangent_number_impl_aux1 j y xs ! (i-1)) + (j+i+2) * xs ! i" using assms (*‹i < length xs›*) proof (induction xs arbitrary: i j y) (*goals: 1. ‹⋀i j y. i < length [] ⟹ tangent_number_impl_aux1 j y [] ! i = (j + i) * (if i = 0 then y else tangent_number_impl_aux1 j y [] ! (i - 1)) + (j + i + 2) * [] ! i› 2. ‹⋀a xs i j y. ⟦⋀i j y. i < length xs ⟹ tangent_number_impl_aux1 j y xs ! i = (j + i) * (if i = 0 then y else tangent_number_impl_aux1 j y xs ! (i - 1)) + (j + i + 2) * xs ! i; i < length (a # xs)⟧ ⟹ tangent_number_impl_aux1 j y (a # xs) ! i = (j + i) * (if i = 0 then y else tangent_number_impl_aux1 j y (a # xs) ! (i - 1)) + (j + i + 2) * (a # xs) ! i›*) case (Cons x xs) (*‹(?i::nat) < length (xs::nat list) ⟹ tangent_number_impl_aux1 (?j::nat) (?y::nat) xs ! ?i = (?j + ?i) * (if ?i = (0::nat) then ?y else tangent_number_impl_aux1 ?j ?y xs ! (?i - (1::nat))) + (?j + ?i + (2::nat)) * xs ! ?i› ‹i < length (x # xs)›*) show "?case" (*goal: ‹tangent_number_impl_aux1 j y (x # xs) ! i = (j + i) * (if i = 0 then y else tangent_number_impl_aux1 j y (x # xs) ! (i - 1)) + (j + i + 2) * (x # xs) ! i›*) proof (cases i) (*goals: 1. ‹(i::nat) = (0::nat) ⟹ tangent_number_impl_aux1 (j::nat) (y::nat) ((x::nat) # (xs::nat list)) ! i = (j + i) * (if i = (0::nat) then y else tangent_number_impl_aux1 j y (x # xs) ! (i - (1::nat))) + (j + i + (2::nat)) * (x # xs) ! i› 2. ‹⋀nat::nat. (i::nat) = Suc nat ⟹ tangent_number_impl_aux1 (j::nat) (y::nat) ((x::nat) # (xs::nat list)) ! i = (j + i) * (if i = (0::nat) then y else tangent_number_impl_aux1 j y (x # xs) ! (i - (1::nat))) + (j + i + (2::nat)) * (x # xs) ! i›*) case 0 (*‹i = 0›*) thus "?thesis" (*goal: ‹tangent_number_impl_aux1 j y (x # xs) ! i = (j + i) * (if i = 0 then y else tangent_number_impl_aux1 j y (x # xs) ! (i - 1)) + (j + i + 2) * (x # xs) ! i›*) by (simp add: Let_def (*‹Let ?s ?f ≡ ?f ?s›*)) next (*goal: ‹⋀nat. i = Suc nat ⟹ tangent_number_impl_aux1 j y (x # xs) ! i = (j + i) * (if i = 0 then y else tangent_number_impl_aux1 j y (x # xs) ! (i - 1)) + (j + i + 2) * (x # xs) ! i›*) case (Suc i') (*‹i = Suc i'›*) define x' where "x' = j * y + (x + (x + j * x))" have "tangent_number_impl_aux1 j y (x # xs) ! i = tangent_number_impl_aux1 (Suc j) x' xs ! i'" by (simp add: x'_def (*‹x' = j * y + (x + (x + j * x))›*) Let_def (*‹Let ?s ?f ≡ ?f ?s›*) Suc (*‹i = Suc i'›*)) also (*calculation: ‹tangent_number_impl_aux1 j y (x # xs) ! i = tangent_number_impl_aux1 (Suc j) x' xs ! i'›*) have "… = (Suc j + i') * (if i' = 0 then x' else tangent_number_impl_aux1 (Suc j) x' xs ! (i'-1)) + (Suc j + i' + 2) * xs ! i'" using Cons.prems (*‹i < length (x # xs)›*) apply (subst Cons.IH (*‹?i < length xs ⟹ tangent_number_impl_aux1 ?j ?y xs ! ?i = (?j + ?i) * (if ?i = 0 then ?y else tangent_number_impl_aux1 ?j ?y xs ! (?i - 1)) + (?j + ?i + 2) * xs ! ?i›*)) (*goals: 1. ‹i < length (x # xs) ⟹ i' < length xs› 2. ‹i < length (x # xs) ⟹ (Suc j + i') * (if i' = 0 then x' else tangent_number_impl_aux1 (Suc j) x' xs ! (i' - 1)) + (Suc j + i' + 2) * xs ! i' = (Suc j + i') * (if i' = 0 then x' else tangent_number_impl_aux1 (Suc j) x' xs ! (i' - 1)) + (Suc j + i' + 2) * xs ! i'› discuss goal 1*) apply ((auto simp: Suc (*‹i = Suc i'›*))[1]) (*discuss goal 2*) apply ((auto simp: Suc (*‹i = Suc i'›*))[1]) (*proven 2 subgoals*) . also (*calculation: ‹tangent_number_impl_aux1 j y (x # xs) ! i = (Suc j + i') * (if i' = 0 then x' else tangent_number_impl_aux1 (Suc j) x' xs ! (i' - 1)) + (Suc j + i' + 2) * xs ! i'›*) have "Suc j + i' = j + i" by (simp add: Suc (*‹i = Suc i'›*)) also (*calculation: ‹tangent_number_impl_aux1 j y (x # xs) ! i = (j + i) * (if i' = 0 then x' else tangent_number_impl_aux1 (Suc j) x' xs ! (i' - 1)) + (j + i + 2) * xs ! i'›*) have "xs ! i' = (x # xs) ! i" by (auto simp: Suc (*‹i = Suc i'›*)) also (*calculation: ‹tangent_number_impl_aux1 j y (x # xs) ! i = (j + i) * (if i' = 0 then x' else tangent_number_impl_aux1 (Suc j) x' xs ! (i' - 1)) + (j + i + 2) * (x # xs) ! i›*) have "(if i' = 0 then x' else tangent_number_impl_aux1 (Suc j) x' xs ! (i'-1)) = (x' # tangent_number_impl_aux1 j y (x # xs)) ! i" by (auto simp: Suc (*‹i = Suc i'›*) x'_def (*‹x' = j * y + (x + (x + j * x))›*) Let_def (*‹Let ?s ?f ≡ ?f ?s›*)) finally (*calculation: ‹tangent_number_impl_aux1 (j::nat) (y::nat) ((x::nat) # (xs::nat list)) ! (i::nat) = (j + i) * ((x'::nat) # tangent_number_impl_aux1 j y (x # xs)) ! i + (j + i + (2::nat)) * (x # xs) ! i›*) show "?thesis" (*goal: ‹tangent_number_impl_aux1 j y (x # xs) ! i = (j + i) * (if i = 0 then y else tangent_number_impl_aux1 j y (x # xs) ! (i - 1)) + (j + i + 2) * (x # xs) ! i›*) by (simp add: Suc (*‹i = Suc i'›*)) qed qed (auto) (*solved the remaining goal: ‹⋀(i::nat) (j::nat) y::nat. i < length [] ⟹ tangent_number_impl_aux1 j y [] ! i = (j + i) * (if i = (0::nat) then y else tangent_number_impl_aux1 j y [] ! (i - (1::nat))) + (j + i + (2::nat)) * [] ! i›*) lemma tangent_number_impl_aux2_correct: assumes "k ≤ n" shows "tangent_number_impl_aux2 (map (λi. T (2 * k + i) (i + 1)) [0..<n-k]) = map tangent_number [Suc k..<Suc n]" using assms (*‹(k::nat) ≤ (n::nat)›*) proof (induction k rule: inc_induct (*‹⟦?i ≤ ?j; ?P ?j; ⋀n. ⟦?i ≤ n; n < ?j; ?P (Suc n)⟧ ⟹ ?P n⟧ ⟹ ?P ?i›*)) (*goals: 1. ‹tangent_number_impl_aux2 (map (λi. T (2 * n + i) (i + 1)) [0..<n - n]) = map tangent_number [Suc n..<Suc n]› 2. ‹⋀na. ⟦k ≤ na; na < n; tangent_number_impl_aux2 (map (λi. T (2 * Suc na + i) (i + 1)) [0..<n - Suc na]) = map tangent_number [Suc (Suc na)..<Suc n]⟧ ⟹ tangent_number_impl_aux2 (map (λi. T (2 * na + i) (i + 1)) [0..<n - na]) = map tangent_number [Suc na..<Suc n]›*) case (step k) (*‹k ≤ k› ‹k < n› ‹tangent_number_impl_aux2 (map (λi. T (2 * Suc k + i) (i + 1)) [0..<n - Suc k]) = map tangent_number [Suc (Suc k)..<Suc n]›*) have "*": "[0..<n-k] = 0 # map Suc [0..<n-Suc k]" apply (subst upt_conv_Cons (*‹?i < ?j ⟹ [?i..<?j] = ?i # [Suc ?i..<?j]›*)) (*goals: 1. ‹0 < n - k› 2. ‹0 # [Suc 0..<n - k] = 0 # map Suc [0..<n - Suc k]› discuss goal 1*) apply ((use step.hyps in ‹auto simp: map_Suc_upt Suc_diff_Suc simp del: upt_Suc›)[1]) (*discuss goal 2*) apply ((use step.hyps in ‹auto simp: map_Suc_upt Suc_diff_Suc simp del: upt_Suc›)[1]) (*proven 2 subgoals*) . define ts where "ts = tangent_number_impl_aux1 0 (T (2*k) 1) (map (λi. T (2*k+i+1) (i+2)) [0..<n-Suc k])" have T_rec: "T (Suc a) (Suc b) = b * T a b + (b + 2) * T a (b + 2)" for a and b unfolding T_def tangent_number_aux_rec (*goal: ‹b * tangent_number_aux a b + (b + 2) * tangent_number_aux a (b + 2) = b * tangent_number_aux a b + (b + 2) * tangent_number_aux a (b + 2)›*) by standard have "tangent_number_impl_aux2 (map (λi. T (2 * k + i) (i + 1)) [0..<n-k]) = T (2 * k) 1 # tangent_number_impl_aux2 ts" unfolding "*" list.map tangent_number_impl_aux2.simps (*goal: ‹(T::nat ⇒ nat ⇒ nat) ((2::nat) * (k::nat) + (0::nat)) ((0::nat) + (1::nat)) # tangent_number_impl_aux2 (tangent_number_impl_aux1 (0::nat) (T ((2::nat) * k + (0::nat)) ((0::nat) + (1::nat))) (map (λi::nat. T ((2::nat) * k + i) (i + (1::nat))) (map Suc [0::nat..<(n::nat) - Suc k]))) = T ((2::nat) * k) (1::nat) # tangent_number_impl_aux2 (ts::nat list)›*) by (simp add: o_def (*‹?f ∘ ?g = (λx. ?f (?g x))›*) ts_def (*‹ts = tangent_number_impl_aux1 0 (T (2 * k) 1) (map (λi. T (2 * k + i + 1) (i + 2)) [0..<n - Suc k])›*) 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*) numeral_3_eq_3 (*‹3 = Suc (Suc (Suc 0))›*)) also (*calculation: ‹tangent_number_impl_aux2 (map (λi. T (2 * k + i) (i + 1)) [0..<n - k]) = T (2 * k) 1 # tangent_number_impl_aux2 ts›*) have "ts = map (λi. T (2 * Suc k + i) (i + 1)) [0..<n - Suc k]" proof (rule nth_equalityI (*‹⟦length ?xs = length ?ys; ⋀i. i < length ?xs ⟹ ?xs ! i = ?ys ! i⟧ ⟹ ?xs = ?ys›*)) (*goals: 1. ‹length ts = length (map (λi. T (2 * Suc k + i) (i + 1)) [0..<n - Suc k])› 2. ‹⋀i. i < length ts ⟹ ts ! i = map (λi. T (2 * Suc k + i) (i + 1)) [0..<n - Suc k] ! i›*) fix i assume "i < length ts" (*‹(i::nat) < length (ts::nat list)›*) hence i: "i < n - Suc k" by (simp add: ts_def (*‹ts = tangent_number_impl_aux1 0 (T (2 * k) 1) (map (λi. T (2 * k + i + 1) (i + 2)) [0..<n - Suc k])›*)) hence "ts ! i = T (2 * Suc k + i) (i + 1)" proof (induction i) (*goals: 1. ‹(0::nat) < (n::nat) - Suc (k::nat) ⟹ (ts::nat list) ! (0::nat) = (T::nat ⇒ nat ⇒ nat) ((2::nat) * Suc k + (0::nat)) ((0::nat) + (1::nat))› 2. ‹⋀i::nat. ⟦i < (n::nat) - Suc (k::nat) ⟹ (ts::nat list) ! i = (T::nat ⇒ nat ⇒ nat) ((2::nat) * Suc k + i) (i + (1::nat)); Suc i < n - Suc k⟧ ⟹ ts ! Suc i = T ((2::nat) * Suc k + Suc i) (Suc i + (1::nat))›*) case 0 (*‹(0::nat) < (n::nat) - Suc (k::nat)›*) thus "?case" (*goal: ‹ts ! 0 = T (2 * Suc k + 0) (0 + 1)›*) unfolding ts_def (*goal: ‹tangent_number_impl_aux1 0 (T (2 * k) 1) (map (λi. T (2 * k + i + 1) (i + 2)) [0..<n - Suc k]) ! 0 = T (2 * Suc k + 0) (0 + 1)›*) apply (subst tangent_number_impl_aux1_nth_eq (*‹?i < length ?xs ⟹ tangent_number_impl_aux1 ?j ?y ?xs ! ?i = (?j + ?i) * (if ?i = 0 then ?y else tangent_number_impl_aux1 ?j ?y ?xs ! (?i - 1)) + (?j + ?i + 2) * ?xs ! ?i›*)) (*goals: 1. ‹0 < n - Suc k ⟹ 0 < length (map (λi. T (2 * k + i + 1) (i + 2)) [0..<n - Suc k])› 2. ‹0 < n - Suc k ⟹ (0 + 0) * (if 0 = 0 then T (2 * k) 1 else tangent_number_impl_aux1 0 (T (2 * k) 1) (map (λi. T (2 * k + i + 1) (i + 2)) [0..<n - Suc k]) ! (0 - 1)) + (0 + 0 + 2) * map (λi. T (2 * k + i + 1) (i + 2)) [0..<n - Suc k] ! 0 = T (2 * Suc k + 0) (0 + 1)› discuss goal 1*) apply ((use T_rec[of "2*k+1" 0] in ‹auto simp: eval_nat_numeral›)[1]) (*discuss goal 2*) apply ((use T_rec[of "2*k+1" 0] in ‹auto simp: eval_nat_numeral›)[1]) (*proven 2 subgoals*) . next (*goal: ‹⋀i. ⟦i < n - Suc k ⟹ ts ! i = T (2 * Suc k + i) (i + 1); Suc i < n - Suc k⟧ ⟹ ts ! Suc i = T (2 * Suc k + Suc i) (Suc i + 1)›*) case (Suc i) (*‹(i::nat) < (n::nat) - Suc (k::nat) ⟹ (ts::nat list) ! i = (T::nat ⇒ nat ⇒ nat) ((2::nat) * Suc k + i) (i + (1::nat))› ‹Suc (i::nat) < (n::nat) - Suc (k::nat)›*) have "ts ! Suc i = Suc i * T (Suc (Suc (2 * k + i))) (Suc i) + (Suc i + 2) * T (Suc (Suc (2 * k + i))) (Suc i + 2)" using Suc (*‹i < n - Suc k ⟹ ts ! i = T (2 * Suc k + i) (i + 1)› ‹Suc i < n - Suc k›*) unfolding ts_def (*goal: ‹tangent_number_impl_aux1 0 (T (2 * k) 1) (map (λi. T (2 * k + i + 1) (i + 2)) [0..<n - Suc k]) ! Suc i = Suc i * T (Suc (Suc (2 * k + i))) (Suc i) + (Suc i + 2) * T (Suc (Suc (2 * k + i))) (Suc i + 2)›*) apply (subst tangent_number_impl_aux1_nth_eq (*‹?i < length ?xs ⟹ tangent_number_impl_aux1 ?j ?y ?xs ! ?i = (?j + ?i) * (if ?i = 0 then ?y else tangent_number_impl_aux1 ?j ?y ?xs ! (?i - 1)) + (?j + ?i + 2) * ?xs ! ?i›*)) (*goals: 1. ‹⟦i < n - Suc k ⟹ tangent_number_impl_aux1 0 (T (2 * k) 1) (map (λi. T (2 * k + i + 1) (i + 2)) [0..<n - Suc k]) ! i = T (2 * Suc k + i) (i + 1); Suc i < n - Suc k⟧ ⟹ Suc i < length (map (λi. T (2 * k + i + 1) (i + 2)) [0..<n - Suc k])› 2. ‹⟦i < n - Suc k ⟹ tangent_number_impl_aux1 0 (T (2 * k) 1) (map (λi. T (2 * k + i + 1) (i + 2)) [0..<n - Suc k]) ! i = T (2 * Suc k + i) (i + 1); Suc i < n - Suc k⟧ ⟹ (0 + Suc i) * (if Suc i = 0 then T (2 * k) 1 else tangent_number_impl_aux1 0 (T (2 * k) 1) (map (λi. T (2 * k + i + 1) (i + 2)) [0..<n - Suc k]) ! (Suc i - 1)) + (0 + Suc i + 2) * map (λi. T (2 * k + i + 1) (i + 2)) [0..<n - Suc k] ! Suc i = Suc i * T (Suc (Suc (2 * k + i))) (Suc i) + (Suc i + 2) * T (Suc (Suc (2 * k + i))) (Suc i + 2)› discuss goal 1*) apply ((auto simp: 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))›*))[1]) (*discuss goal 2*) apply ((auto simp: eval_nat_numeral (*‹Numeral1 = Suc 0› ‹numeral (num.Bit0 ?n) = Suc (numeral (Num.BitM ?n))› ‹numeral (num.Bit1 ?n) = Suc (numeral (num.Bit0 ?n))›*))[1]) (*proven 2 subgoals*) . also (*calculation: ‹ts ! Suc i = Suc i * T (Suc (Suc (2 * k + i))) (Suc i) + (Suc i + 2) * T (Suc (Suc (2 * k + i))) (Suc i + 2)›*) have "… = T (2 * Suc k + Suc i) (Suc i + 1)" using T_rec[of "2 * Suc k + i" "Suc i"] (*‹T (Suc (2 * Suc k + i)) (Suc (Suc i)) = Suc i * T (2 * Suc k + i) (Suc i) + (Suc i + 2) * T (2 * Suc k + i) (Suc i + 2)›*) by simp finally (*calculation: ‹ts ! Suc i = T (2 * Suc k + Suc i) (Suc i + 1)›*) show "?case" (*goal: ‹ts ! Suc i = T (2 * Suc k + Suc i) (Suc i + 1)›*) . qed thus "ts ! i = map (λi. T (2 * Suc k + i) (i + 1)) [0..<n - Suc k] ! i" using i (*‹(i::nat) < (n::nat) - Suc (k::nat)›*) by simp qed (simp_all add: ts_def) (*solved the remaining goal: ‹length ts = length (map (λi. T (2 * Suc k + i) (i + 1)) [0..<n - Suc k])›*) also (*calculation: ‹tangent_number_impl_aux2 (map (λi::nat. (T::nat ⇒ nat ⇒ nat) ((2::nat) * (k::nat) + i) (i + (1::nat))) [0::nat..<(n::nat) - k]) = T ((2::nat) * k) (1::nat) # tangent_number_impl_aux2 (map (λi::nat. T ((2::nat) * Suc k + i) (i + (1::nat))) [0::nat..<n - Suc k])›*) have "tangent_number_impl_aux2 … = map tangent_number [Suc (Suc k)..<Suc n]" by (rule step.IH (*‹tangent_number_impl_aux2 (map (λi::nat. (T::nat ⇒ nat ⇒ nat) ((2::nat) * Suc (k::nat) + i) (i + (1::nat))) [0::nat..<(n::nat) - Suc k]) = map tangent_number [Suc (Suc k)..<Suc n]›*)) also (*calculation: ‹tangent_number_impl_aux2 (map (λi. T (2 * k + i) (i + 1)) [0..<n - k]) = T (2 * k) 1 # map tangent_number [Suc (Suc k)..<Suc n]›*) have "T (2 * k) 1 = tangent_number (Suc k)" by (simp add: tangent_number_conv_aux (*‹tangent_number (?n::nat) = tangent_number_aux ((2::nat) * ?n - Suc (0::nat)) (0::nat)›*) T_def (*‹T::nat ⇒ nat ⇒ nat ≡ tangent_number_aux›*)) also (*calculation: ‹tangent_number_impl_aux2 (map (λi::nat. (T::nat ⇒ nat ⇒ nat) ((2::nat) * (k::nat) + i) (i + (1::nat))) [0::nat..<(n::nat) - k]) = tangent_number (Suc k) # map tangent_number [Suc (Suc k)..<Suc n]›*) have "tangent_number (Suc k) # map tangent_number [Suc (Suc k)..<Suc n] = map tangent_number [Suc k..<Suc n]" using step.hyps (*‹k ≤ k› ‹(k::nat) < (n::nat)›*) apply - (*goal: ‹tangent_number (Suc (k::nat)) # map tangent_number [Suc (Suc k)..<Suc (n::nat)] = map tangent_number [Suc k..<Suc n]›*) apply (subst upt_conv_Cons (*‹?i < ?j ⟹ [?i..<?j] = ?i # [Suc ?i..<?j]›*)) (*goals: 1. ‹⟦k ≤ k; k < n⟧ ⟹ Suc (Suc k) < Suc n› 2. ‹⟦k ≤ k; k < n⟧ ⟹ tangent_number (Suc k) # map tangent_number (Suc (Suc k) # [Suc (Suc (Suc k))..<Suc n]) = map tangent_number [Suc k..<Suc n]› discuss goal 1*) apply ((auto simp del: upt_Suc (*‹[?i..<Suc ?j] = (if ?i ≤ ?j then [?i..<?j] @ [?j] else [])›*))[1]) (*top goal: ‹⟦k ≤ k; k < n⟧ ⟹ Suc (Suc k) < Suc n› and 1 goal remains*) apply ((msorry)[1]) (*discuss goal 2*) apply ((auto simp del: upt_Suc (*‹[?i..<Suc ?j] = (if ?i ≤ ?j then [?i..<?j] @ [?j] else [])›*))[1]) (*goal: ‹⟦k ≤ k; k < n⟧ ⟹ tangent_number (Suc k) # map tangent_number (Suc (Suc k) # [Suc (Suc (Suc k))..<Suc n]) = map tangent_number [Suc k..<Suc n]›*) apply ((msorry)[1]) (*proven 2 subgoals*) . finally (*calculation: ‹tangent_number_impl_aux2 (map (λi. T (2 * k + i) (i + 1)) [0..<n - k]) = map tangent_number [Suc k..<Suc n]›*) show "?case" (*goal: ‹tangent_number_impl_aux2 (map (λi::nat. (T::nat ⇒ nat ⇒ nat) ((2::nat) * (k::nat) + i) (i + (1::nat))) [0::nat..<(n::nat) - k]) = map tangent_number [Suc k..<Suc n]›*) . qed (auto) (*solved the remaining goal: ‹tangent_number_impl_aux2 (map (λi. T (2 * n + i) (i + 1)) [0..<n - n]) = map tangent_number [Suc n..<Suc n]›*) definition tangent_numbers :: "nat ⇒ nat list" where "tangent_numbers n = map tangent_number [1..<Suc n]" lemma tangent_numbers_code [code]: "tangent_numbers n = tangent_number_impl_aux2 (pochhammer_row_impl 1 (Suc n) 1)" proof (-) (*goal: ‹tangent_numbers n = tangent_number_impl_aux2 (pochhammer_row_impl 1 (Suc n) 1)›*) have "pochhammer_row_impl 1 (Suc n) 1 = map (λi. T i (i + 1)) [0..<n]" by (simp add: pochhammer_row_impl_correct (*‹pochhammer_row_impl ?k ?n ?x = map (λi. ?x * pochhammer ?k i) [0..<?n - ?k]›*) pochhammer_fact (*‹fact ?n = pochhammer 1 ?n›*) T_def (*‹T ≡ tangent_number_aux›*)) also (*calculation: ‹pochhammer_row_impl (1::nat) (Suc (n::nat)) (1::nat) = map (λi::nat. (T::nat ⇒ nat ⇒ nat) i (i + (1::nat))) [0::nat..<n]›*) have "tangent_number_impl_aux2 … = map tangent_number [Suc 0..<Suc n]" using tangent_number_impl_aux2_correct[of 0 n] (*‹0 ≤ n ⟹ tangent_number_impl_aux2 (map (λi. T (2 * 0 + i) (i + 1)) [0..<n - 0]) = map tangent_number [Suc 0..<Suc n]›*) by (simp del: upt_Suc (*‹[?i..<Suc ?j] = (if ?i ≤ ?j then [?i..<?j] @ [?j] else [])›*)) finally (*calculation: ‹tangent_number_impl_aux2 (pochhammer_row_impl 1 (Suc n) 1) = map tangent_number [Suc 0..<Suc n]›*) show "?thesis" (*goal: ‹tangent_numbers (n::nat) = tangent_number_impl_aux2 (pochhammer_row_impl (1::nat) (Suc n) (1::nat))›*) by (simp only: tangent_numbers_def (*‹tangent_numbers ?n = map tangent_number [1..<Suc ?n]›*) One_nat_def (*‹1 = Suc 0›*)) qed lemma tangent_number_code [code]: "tangent_number n = (if n = 0 then 0 else last (tangent_numbers n))" by (simp add: tangent_numbers_def (*‹tangent_numbers ?n = map tangent_number [1..<Suc ?n]›*)) end end
{ "path": "afp-2025-02-12/thys/Boustrophedon_Transform/Tangent_Numbers.thy", "repo": "afp-2025-02-12", "sha": "83f8318685d35ffd76a61f5039c45281ca4ff6ab582a0dab2faf6f9e5647f601" }
section ‹Finite State Machines› text ‹This theory defines well-formed finite state machines and introduces various closely related notions, as well as a selection of basic properties and definitions.› theory FSM imports FSM_Impl "HOL-Library.Quotient_Type" "HOL-Library.Product_Lexorder" begin subsection ‹Well-formed Finite State Machines› text ‹A value of type @{text "fsm_impl"} constitutes a well-formed FSM if its contained sets are finite and the initial state and the components of each transition are contained in their respective sets.› abbreviation(input) "well_formed_fsm (M :: ('state, 'input, 'output) fsm_impl) ≡ (initial M ∈ states M ∧ finite (states M) ∧ finite (inputs M) ∧ finite (outputs M) ∧ finite (transitions M) ∧ (∀ t ∈ transitions M . t_source t ∈ states M ∧ t_input t ∈ inputs M ∧ t_target t ∈ states M ∧ t_output t ∈ outputs M)) " typedef ('state, 'input, 'output) fsm = "{ M :: ('state, 'input, 'output) fsm_impl . well_formed_fsm M}" morphisms fsm_impl_of_fsm Abs_fsm proof - obtain q :: 'state where "True" by blast have "well_formed_fsm (FSMI q {q} {} {} {})" by auto then show ?thesis by blast qed setup_lifting type_definition_fsm lift_definition initial :: "('state, 'input, 'output) fsm ⇒ 'state" is FSM_Impl.initial done lift_definition states :: "('state, 'input, 'output) fsm ⇒ 'state set" is FSM_Impl.states done lift_definition inputs :: "('state, 'input, 'output) fsm ⇒ 'input set" is FSM_Impl.inputs done lift_definition outputs :: "('state, 'input, 'output) fsm ⇒ 'output set" is FSM_Impl.outputs done lift_definition transitions :: "('state, 'input, 'output) fsm ⇒ ('state × 'input × 'output × 'state) set" is FSM_Impl.transitions done lift_definition fsm_from_list :: "'a ⇒ ('a,'b,'c) transition list ⇒ ('a, 'b, 'c) fsm" is FSM_Impl.fsm_impl_from_list proof - fix q :: 'a fix ts :: "('a,'b,'c) transition list" show "well_formed_fsm (fsm_impl_from_list q ts)" by (induction ts; auto) qed lemma fsm_initial[intro]: "initial M ∈ states M" apply transfer (*goal: ‹FSM.initial M ∈ FSM.states M›*) by blast lemma fsm_states_finite: "finite (states M)" apply transfer (*goal: ‹finite (FSM.states M)›*) by blast lemma fsm_inputs_finite: "finite (inputs M)" apply transfer (*goal: ‹finite (FSM.inputs M)›*) by blast lemma fsm_outputs_finite: "finite (outputs M)" apply transfer (*goal: ‹finite (FSM.outputs M)›*) by blast lemma fsm_transitions_finite: "finite (transitions M)" apply transfer (*goal: ‹finite (FSM.transitions M)›*) by blast lemma fsm_transition_source[intro]: "⋀ t . t ∈ (transitions M) ⟹ t_source t ∈ states M" apply transfer (*goal: ‹⋀t. t ∈ FSM.transitions M ⟹ t_source t ∈ FSM.states M›*) by blast lemma fsm_transition_target[intro]: "⋀ t . t ∈ (transitions M) ⟹ t_target t ∈ states M" apply transfer (*goal: ‹⋀t. t ∈ FSM.transitions M ⟹ t_target t ∈ FSM.states M›*) by blast lemma fsm_transition_input[intro]: "⋀ t . t ∈ (transitions M) ⟹ t_input t ∈ inputs M" apply transfer (*goal: ‹⋀t::'a::type × 'b::type × 'c::type × 'a::type. t ∈ FSM.transitions (M::('a::type, 'b::type, 'c::type) fsm) ⟹ t_input t ∈ FSM.inputs M›*) by blast lemma fsm_transition_output[intro]: "⋀ t . t ∈ (transitions M) ⟹ t_output t ∈ outputs M" apply transfer (*goal: ‹⋀t. t ∈ FSM.transitions M ⟹ t_output t ∈ FSM.outputs M›*) by blast instantiation fsm :: (type,type,type) equal begin definition equal_fsm :: "('a, 'b, 'c) fsm ⇒ ('a, 'b, 'c) fsm ⇒ bool" where "equal_fsm x y = (initial x = initial y ∧ states x = states y ∧ inputs x = inputs y ∧ outputs x = outputs y ∧ transitions x = transitions y)" instance apply (intro_classes) unfolding equal_fsm_def apply transfer using fsm_impl.expand by auto end subsubsection ‹Example FSMs› definition m_ex_H :: "(integer,integer,integer) fsm" where "m_ex_H = fsm_from_list 1 [ (1,0,0,2), (1,0,1,4), (1,1,1,4), (2,0,0,2), (2,1,1,4), (3,0,1,4), (3,1,0,1), (3,1,1,3), (4,0,0,3), (4,1,0,1)]" definition m_ex_9 :: "(integer,integer,integer) fsm" where "m_ex_9 = fsm_from_list 0 [ (0,0,2,2), (0,0,3,2), (0,1,0,3), (0,1,1,3), (1,0,3,2), (1,1,1,3), (2,0,2,2), (2,1,3,3), (3,0,2,2), (3,1,0,2), (3,1,1,1)]" definition m_ex_DR :: "(integer,integer,integer) fsm" where "m_ex_DR = fsm_from_list 0 [(0,0,0,100), (100,0,0,101), (100,0,1,101), (101,0,0,102), (101,0,1,102), (102,0,0,103), (102,0,1,103), (103,0,0,104), (103,0,1,104), (104,0,0,100), (104,0,1,100), (104,1,0,400), (0,0,2,200), (200,0,2,201), (201,0,2,202), (202,0,2,203), (203,0,2,200), (203,1,0,400), (0,1,0,300), (100,1,0,300), (101,1,0,300), (102,1,0,300), (103,1,0,300), (200,1,0,300), (201,1,0,300), (202,1,0,300), (300,0,0,300), (300,1,0,300), (400,0,0,300), (400,1,0,300)]" subsection ‹Transition Function h and related functions› lift_definition h :: "('state, 'input, 'output) fsm ⇒ ('state × 'input) ⇒ ('output × 'state) set" is FSM_Impl.h . lemma h_simps[simp]: "FSM.h M (q,x) = { (y,q') . (q,x,y,q') ∈ transitions M }" apply transfer (*goal: ‹FSM.h M (q, x) = {(y, q'). (q, x, y, q') ∈ FSM.transitions M}›*) by auto lift_definition h_obs :: "('state, 'input, 'output) fsm ⇒ 'state ⇒ 'input ⇒ 'output ⇒ 'state option" is FSM_Impl.h_obs . lemma h_obs_simps[simp]: "FSM.h_obs M q x y = (let tgts = snd ` Set.filter (λ (y',q') . y' = y) (h M (q,x)) in if card tgts = 1 then Some (the_elem tgts) else None)" apply transfer (*goal: ‹FSM.h_obs M q x y = (let tgts = snd ` Set.filter (λ(y', q'). y' = y) (FSM.h M (q, x)) in if card tgts = 1 then Some (the_elem tgts) else None)›*) by auto fun defined_inputs' :: "(('a ×'b) ⇒ ('c×'a) set) ⇒ 'b set ⇒ 'a ⇒ 'b set" where "defined_inputs' hM iM q = {x ∈ iM . hM (q,x) ≠ {}}" fun defined_inputs :: "('a,'b,'c) fsm ⇒ 'a ⇒ 'b set" where "defined_inputs M q = defined_inputs' (h M) (inputs M) q" lemma defined_inputs_set : "defined_inputs M q = {x ∈ inputs M . h M (q,x) ≠ {} }" by auto fun transitions_from' :: "(('a ×'b) ⇒ ('c×'a) set) ⇒ 'b set ⇒ 'a ⇒ ('a,'b,'c) transition set" where "transitions_from' hM iM q = ⋃(image (λx . image (λ(y,q') . (q,x,y,q')) (hM (q,x))) iM)" fun transitions_from :: "('a,'b,'c) fsm ⇒ 'a ⇒ ('a,'b,'c) transition set" where "transitions_from M q = transitions_from' (h M) (inputs M) q" lemma transitions_from_set : assumes "q ∈ states M" shows "transitions_from M q = {t ∈ transitions M . t_source t = q}" proof (-) (*goal: ‹transitions_from M q = {t ∈ FSM.transitions M. t_source t = q}›*) have "⋀ t . t ∈ transitions_from M q ⟹ t ∈ transitions M ∧ t_source t = q" by auto moreover have "⋀ t . t ∈ transitions M ⟹ t_source t = q ⟹ t ∈ transitions_from M q" proof (-) (*goal: ‹⋀t::'a × 'b × 'c × 'a. ⟦t ∈ FSM.transitions (M::('a, 'b, 'c) fsm); t_source t = (q::'a)⟧ ⟹ t ∈ transitions_from M q›*) fix t assume "t ∈ transitions M" and "t_source t = q" (*‹(t::'a × 'b × 'c × 'a) ∈ FSM.transitions (M::('a, 'b, 'c) fsm)› ‹t_source (t::'a × 'b × 'c × 'a) = (q::'a)›*) then have "(t_output t, t_target t) ∈ h M (q,t_input t)" and "t_input t ∈ inputs M" apply - (*goals: 1. ‹⟦t ∈ FSM.transitions M; t_source t = q⟧ ⟹ (t_output t, t_target t) ∈ FSM.h M (q, t_input t)› 2. ‹⟦t ∈ FSM.transitions M; t_source t = q⟧ ⟹ t_input t ∈ FSM.inputs M› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . then have "t_input t ∈ defined_inputs' (h M) (inputs M) q" unfolding defined_inputs'.simps ‹t_source t = q› (*goal: ‹t_input t ∈ {x ∈ FSM.inputs M. FSM.h M (q, x) ≠ {}}›*) by blast have "(q, t_input t, t_output t, t_target t) ∈ transitions M" using ‹t_source t = q› (*‹t_source t = q›*) ‹t ∈ transitions M› (*‹(t::'a × 'b × 'c × 'a) ∈ FSM.transitions (M::('a, 'b, 'c) fsm)›*) by auto then have "(q, t_input t, t_output t, t_target t) ∈ (λ(y, q'). (q, t_input t, y, q')) ` h M (q, t_input t)" using ‹(t_output t, t_target t) ∈ h M (q,t_input t)› (*‹(t_output (t::'a::type × 'b::type × 'c::type × 'a::type), t_target t) ∈ FSM.h (M::('a::type, 'b::type, 'c::type) fsm) (q::'a::type, t_input t)›*) unfolding h.simps (*goal: ‹(q, t_input t, t_output t, t_target t) ∈ (λ(y, q'). (q, t_input t, y, q')) ` FSM.h M (q, t_input t)›*) by (metis (no_types, lifting) 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)›*) surjective_pairing (*‹?t = (fst ?t, snd ?t)›*)) then have "t ∈ (λ(y, q'). (q, t_input t, y, q')) ` h M (q, t_input t)" using ‹t_source t = q› (*‹t_source t = q›*) by (metis prod.collapse (*‹(fst (?prod::?'a × ?'b), snd ?prod) = ?prod›*)) then show "t ∈ transitions_from M q" unfolding transitions_from.simps transitions_from'.simps (*goal: ‹(t::'a × 'b × 'c × 'a) ∈ (⋃x::'b∈FSM.inputs M. (λ(y::'c, q'::'a). (q::'a, x, y, q')) ` FSM.h (M::('a, 'b, 'c) fsm) (q, x))›*) using ‹t_input t ∈ defined_inputs' (h M) (inputs M) q› (*‹t_input t ∈ defined_inputs' (FSM.h M) (FSM.inputs M) q›*) using ‹t_input t ∈ FSM.inputs M› (*‹t_input (t::'a × 'b × 'c × 'a) ∈ FSM.inputs (M::('a, 'b, 'c) fsm)›*) by blast qed ultimately show "?thesis" (*goal: ‹transitions_from (M::('a, 'b, 'c) fsm) (q::'a) = {t::'a × 'b × 'c × 'a ∈ FSM.transitions M. t_source t = q}›*) by blast qed fun h_from :: "('state, 'input, 'output) fsm ⇒ 'state ⇒ ('input × 'output × 'state) set" where "h_from M q = { (x,y,q') . (q,x,y,q') ∈ transitions M }" lemma h_from[code] : "h_from M q = (let m = set_as_map (transitions M) in (case m q of Some yqs ⇒ yqs | None ⇒ {}))" unfolding set_as_map_def (*goal: ‹h_from M q = (let m = λx. if ∃z. (x, z) ∈ FSM.transitions M then Some {z. (x, z) ∈ FSM.transitions M} else None in case m q of None ⇒ {} | Some yqs ⇒ yqs)›*) by force fun h_out :: "('a,'b,'c) fsm ⇒ ('a × 'b) ⇒ 'c set" where "h_out M (q,x) = {y . ∃ q' . (q,x,y,q') ∈ transitions M}" lemma h_out_code[code]: "h_out M = (λqx . (case (set_as_map (image (λ(q,x,y,q') . ((q,x),y)) (transitions M))) qx of Some yqs ⇒ yqs | None ⇒ {}))" proof (-) (*goal: ‹h_out (M::('a::type, 'b::type, 'c::type) fsm) = (λqx::'a::type × 'b::type. case set_as_map ((λ(q::'a::type, x::'b::type, y::'c::type, q'::'a::type). ((q, x), y)) ` FSM.transitions M) qx of None ⇒ {} | Some (yqs::'c::type set) ⇒ yqs)›*) let ?f = "(λqx . (case (set_as_map (image (λ(q,x,y,q') . ((q,x),y)) (transitions M))) qx of Some yqs ⇒ yqs | None ⇒ {}))" have "⋀ qx . (λqx . (case (set_as_map (image (λ(q,x,y,q') . ((q,x),y)) (transitions M))) qx of Some yqs ⇒ yqs | None ⇒ {})) qx = (λ qx . {z. (qx, z) ∈ (λ(q, x, y, q'). ((q, x), y)) ` (transitions M)}) qx" unfolding set_as_map_def (*goal: ‹⋀qx. (case if ∃z. (qx, z) ∈ (λ(q, x, y, q'). ((q, x), y)) ` FSM.transitions M then Some {z. (qx, z) ∈ (λ(q, x, y, q'). ((q, x), y)) ` FSM.transitions M} else None of None ⇒ {} | Some yqs ⇒ yqs) = {z. (qx, z) ∈ (λ(q, x, y, q'). ((q, x), y)) ` FSM.transitions M}›*) by auto moreover have "⋀ qx . (λ qx . {z. (qx, z) ∈ (λ(q, x, y, q'). ((q, x), y)) ` (transitions M)}) qx = (λ qx . {y | y . ∃ q' . (fst qx, snd qx, y, q') ∈ (transitions M)}) qx" by force ultimately have "?f = (λ qx . {y | y . ∃ q' . (fst qx, snd qx, y, q') ∈ (transitions M)})" by blast then have "?f = (λ (q,x) . {y | y . ∃ q' . (q, x, y, q') ∈ (transitions M)})" by force then show "?thesis" (*goal: ‹h_out M = (λqx. case set_as_map ((λ(q, x, y, q'). ((q, x), y)) ` FSM.transitions M) qx of None ⇒ {} | Some yqs ⇒ yqs)›*) by force qed lemma h_out_alt_def : "h_out M (q,x) = {t_output t | t . t ∈ transitions M ∧ t_source t = q ∧ t_input t = x}" unfolding h_out.simps (*goal: ‹{y. ∃q'. (q, x, y, q') ∈ FSM.transitions M} = {t_output t |t. t ∈ FSM.transitions M ∧ t_source t = q ∧ t_input t = x}›*) by auto subsection ‹Size› instantiation fsm :: (type,type,type) size begin definition size where [simp, code]: "size (m::('a, 'b, 'c) fsm) = card (states m)" instance .. end lemma fsm_size_Suc : "size M > 0" unfolding FSM.size_def (*goal: ‹0 < card (FSM.states M)›*) using fsm_states_finite[of M] (*‹finite (FSM.states M)›*) fsm_initial[of M] (*‹FSM.initial M ∈ FSM.states M›*) using card_gt_0_iff (*‹((0::nat) < card (?A::?'a::type set)) = (?A ≠ {} ∧ finite ?A)›*) by blast subsection ‹Paths› inductive path :: "('state, 'input, 'output) fsm ⇒ 'state ⇒ ('state, 'input, 'output) path ⇒ bool" where nil[intro!] : "q ∈ states M ⟹ path M q []" | cons[intro!] : "t ∈ transitions M ⟹ path M (t_target t) ts ⟹ path M (t_source t) (t#ts)" inductive_cases path_nil_elim[elim!]: "path M q []" inductive_cases path_cons_elim[elim!]: "path M q (t#ts)" fun visited_states :: "'state ⇒ ('state, 'input, 'output) path ⇒ 'state list" where "visited_states q p = (q # map t_target p)" fun target :: "'state ⇒ ('state, 'input, 'output) path ⇒ 'state" where "target q p = last (visited_states q p)" lemma target_nil [simp] : "target q [] = q" by auto lemma target_snoc [simp] : "target q (p@[t]) = t_target t" by auto lemma path_begin_state : assumes "path M q p" shows "q ∈ states M" using assms (*‹path M q p›*) apply ((cases)[1]) (*goals: 1. ‹⟦p = []; q ∈ FSM.states M⟧ ⟹ q ∈ FSM.states M› 2. ‹⋀t ts. ⟦q = t_source t; p = t # ts; t ∈ FSM.transitions M; path M (t_target t) ts⟧ ⟹ q ∈ FSM.states M› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . lemma path_append[intro!] : assumes "path M q p1" and "path M (target q p1) p2" shows "path M q (p1@p2)" using assms (*‹path (M::('a::type, 'b::type, 'c::type) fsm) (q::'a::type) (p1::('a::type × 'b::type × 'c::type × 'a::type) list)› ‹path (M::('a::type, 'b::type, 'c::type) fsm) (target (q::'a::type) (p1::('a::type × 'b::type × 'c::type × 'a::type) list)) (p2::('a::type × 'b::type × 'c::type × 'a::type) list)›*) apply ((induct p1 arbitrary: p2)[1]) (*goals: 1. ‹⋀(q::'a::type) (M::('a::type, 'b::type, 'c::type) fsm) p2::('a::type × 'b::type × 'c::type × 'a::type) list. ⟦q ∈ FSM.states M; path M (target q []) p2⟧ ⟹ path M q ([] @ p2)› 2. ‹⋀(t::'a::type × 'b::type × 'c::type × 'a::type) (M::('a::type, 'b::type, 'c::type) fsm) (ts::('a::type × 'b::type × 'c::type × 'a::type) list) p2::('a::type × 'b::type × 'c::type × 'a::type) list. ⟦t ∈ FSM.transitions M; path M (t_target t) ts; ⋀p2::('a::type × 'b::type × 'c::type × 'a::type) list. path M (target (t_target t) ts) p2 ⟹ path M (t_target t) (ts @ p2); path M (target (t_source t) (t # ts)) p2⟧ ⟹ path M (t_source t) ((t # ts) @ p2)› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . lemma path_target_is_state : assumes "path M q p" shows "target q p ∈ states M" using assms (*‹path (M::('a::type, 'b::type, 'c::type) fsm) (q::'a::type) (p::('a::type × 'b::type × 'c::type × 'a::type) list)›*) apply ((induct p)[1]) (*goals: 1. ‹⋀q M. q ∈ FSM.states M ⟹ target q [] ∈ FSM.states M› 2. ‹⋀t M ts. ⟦t ∈ FSM.transitions M; path M (t_target t) ts; target (t_target t) ts ∈ FSM.states M⟧ ⟹ target (t_source t) (t # ts) ∈ FSM.states M› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . lemma path_suffix : assumes "path M q (p1@p2)" shows "path M (target q p1) p2" using assms (*‹path M q (p1 @ p2)›*) apply ((induction p1 arbitrary: q)[1]) (*goals: 1. ‹⋀q. path M q ([] @ p2) ⟹ path M (target q []) p2› 2. ‹⋀a p1 q. ⟦⋀q. path M q (p1 @ p2) ⟹ path M (target q p1) p2; path M q ((a # p1) @ p2)⟧ ⟹ path M (target q (a # p1)) p2› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . lemma path_prefix : assumes "path M q (p1@p2)" shows "path M q p1" using assms (*‹path M q (p1 @ p2)›*) apply ((induction p1 arbitrary: q)[1]) (*goals: 1. ‹⋀q. path M q ([] @ p2) ⟹ path M q []› 2. ‹⋀a p1 q. ⟦⋀q. path M q (p1 @ p2) ⟹ path M q p1; path M q ((a # p1) @ p2)⟧ ⟹ path M q (a # p1)› discuss goal 1*) apply ((auto)[1]) (*top goal: ‹⋀q. path M q ([] @ p2) ⟹ path M q []› and 1 goal remains*) apply ((metis path_begin_state (*‹path (?M::(?'a, ?'b, ?'c) fsm) (?q::?'a) (?p::(?'a × ?'b × ?'c × ?'a) list) ⟹ ?q ∈ FSM.states ?M›*))[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . lemma path_append_elim[elim!] : assumes "path M q (p1@p2)" obtains "path M q p1" and "path M (target q p1) p2" by (meson assms (*‹path M q (p1 @ p2)›*) path_prefix (*‹path ?M ?q (?p1.0 @ ?p2.0) ⟹ path ?M ?q ?p1.0›*) path_suffix (*‹path ?M ?q (?p1.0 @ ?p2.0) ⟹ path ?M (target ?q ?p1.0) ?p2.0›*)) lemma path_append_target: "target q (p1@p2) = target (target q p1) p2" apply (induction p1) (*goals: 1. ‹target q ([] @ p2) = target (target q []) p2› 2. ‹⋀a p1. target q (p1 @ p2) = target (target q p1) p2 ⟹ target q ((a # p1) @ p2) = target (target q (a # p1)) p2› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) . lemma path_append_target_hd : assumes "length p > 0" shows "target q p = target (t_target (hd p)) (tl p)" using assms (*‹0 < length p›*) apply (induction p) (*goals: 1. ‹0 < length [] ⟹ target q [] = target (t_target (hd [])) (tl [])› 2. ‹⋀a p. ⟦0 < length p ⟹ target q p = target (t_target (hd p)) (tl p); 0 < length (a # p)⟧ ⟹ target q (a # p) = target (t_target (hd (a # p))) (tl (a # p))› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) . lemma path_transitions : assumes "path M q p" shows "set p ⊆ transitions M" using assms (*‹path M q p›*) apply (induct p arbitrary: q) (*goals: 1. ‹⋀q M. q ∈ FSM.states M ⟹ set [] ⊆ FSM.transitions M› 2. ‹⋀t M ts. ⟦t ∈ FSM.transitions M; path M (t_target t) ts; set ts ⊆ FSM.transitions M⟧ ⟹ set (t # ts) ⊆ FSM.transitions M› discuss goal 1*) apply fastforce (*discuss goal 2*) apply fastforce (*proven 2 subgoals*) . lemma path_append_transition[intro!] : assumes "path M q p" and "t ∈ transitions M" and "t_source t = target q p" shows "path M q (p@[t])" by (metis assms( (*‹path M q p›*) 1) assms( (*‹t ∈ FSM.transitions M›*) 2) assms( (*‹t_source t = target q p›*) 3) cons (*‹⟦?t ∈ FSM.transitions ?M; path ?M (t_target ?t) ?ts⟧ ⟹ path ?M (t_source ?t) (?t # ?ts)›*) fsm_transition_target (*‹?t ∈ FSM.transitions ?M ⟹ t_target ?t ∈ FSM.states ?M›*) nil (*‹?q ∈ FSM.states ?M ⟹ path ?M ?q []›*) path_append (*‹⟦path ?M ?q ?p1.0; path ?M (target ?q ?p1.0) ?p2.0⟧ ⟹ path ?M ?q (?p1.0 @ ?p2.0)›*)) lemma path_append_transition_elim[elim!] : assumes "path M q (p@[t])" shows "path M q p" and "t ∈ transitions M" and "t_source t = target q p" using assms (*‹path M q (p @ [t])›*) apply - (*goals: 1. ‹path M q (p @ [t]) ⟹ path M q p› 2. ‹path M q (p @ [t]) ⟹ t ∈ FSM.transitions M› 3. ‹path M q (p @ [t]) ⟹ t_source t = target q p› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*proven 3 subgoals*) . lemma path_prepend_t : "path M q' p ⟹ (q,x,y,q') ∈ transitions M ⟹ path M q ((q,x,y,q')#p)" by (metis (mono_tags, lifting) fst_conv (*‹fst (?x1.0, ?x2.0) = ?x1.0›*) path.intros( (*‹⟦?t ∈ FSM.transitions ?M; path ?M (t_target ?t) ?ts⟧ ⟹ path ?M (t_source ?t) (?t # ?ts)›*) 2) prod.sel( (*‹snd (?x1.0, ?x2.0) = ?x2.0›*) 2)) lemma path_target_append : "target q1 p1 = q2 ⟹ target q2 p2 = q3 ⟹ target q1 (p1@p2) = q3" by auto lemma single_transition_path : "t ∈ transitions M ⟹ path M (t_source t) [t]" by auto lemma path_source_target_index : assumes "Suc i < length p" and "path M q p" shows "t_target (p ! i) = t_source (p ! (Suc i))" using assms (*‹Suc i < length p› ‹path M q p›*) proof (induction p rule: rev_induct (*‹⟦?P []; ⋀x xs. ?P xs ⟹ ?P (xs @ [x])⟧ ⟹ ?P ?xs›*)) (*goals: 1. ‹⟦Suc i < length []; path M q []⟧ ⟹ t_target ([] ! i) = t_source ([] ! Suc i)› 2. ‹⋀x xs. ⟦⟦Suc i < length xs; path M q xs⟧ ⟹ t_target (xs ! i) = t_source (xs ! Suc i); Suc i < length (xs @ [x]); path M q (xs @ [x])⟧ ⟹ t_target ((xs @ [x]) ! i) = t_source ((xs @ [x]) ! Suc i)›*) case Nil (*‹Suc i < length []› ‹path M q []›*) then show "?case" (*goal: ‹t_target ([] ! i) = t_source ([] ! Suc i)›*) by auto next (*goal: ‹⋀(x::'a::type × 'b::type × 'c::type × 'a::type) xs::('a::type × 'b::type × 'c::type × 'a::type) list. ⟦⟦Suc (i::nat) < length xs; path (M::('a::type, 'b::type, 'c::type) fsm) (q::'a::type) xs⟧ ⟹ t_target (xs ! i) = t_source (xs ! Suc i); Suc i < length (xs @ [x]); path M q (xs @ [x])⟧ ⟹ t_target ((xs @ [x]) ! i) = t_source ((xs @ [x]) ! Suc i)›*) case (snoc t ps) (*‹⟦Suc i < length ps; path M q ps⟧ ⟹ t_target (ps ! i) = t_source (ps ! Suc i)› ‹Suc (i::nat) < length ((ps::('a × 'b × 'c × 'a) list) @ [t::'a × 'b × 'c × 'a])› ‹path M q (ps @ [t])›*) then have "path M q ps" and "t_source t = target q ps" and "t ∈ transitions M" apply - (*goals: 1. ‹⟦⟦Suc (i::nat) < length (ps::('a × 'b × 'c × 'a) list); path (M::('a, 'b, 'c) fsm) (q::'a) ps⟧ ⟹ t_target (ps ! i) = t_source (ps ! Suc i); Suc i < length (ps @ [t::'a × 'b × 'c × 'a]); path M q (ps @ [t])⟧ ⟹ path M q ps› 2. ‹⟦⟦Suc (i::nat) < length (ps::('a × 'b × 'c × 'a) list); path (M::('a, 'b, 'c) fsm) (q::'a) ps⟧ ⟹ t_target (ps ! i) = t_source (ps ! Suc i); Suc i < length (ps @ [t::'a × 'b × 'c × 'a]); path M q (ps @ [t])⟧ ⟹ t_source t = target q ps› 3. ‹⟦⟦Suc (i::nat) < length (ps::('a × 'b × 'c × 'a) list); path (M::('a, 'b, 'c) fsm) (q::'a) ps⟧ ⟹ t_target (ps ! i) = t_source (ps ! Suc i); Suc i < length (ps @ [t::'a × 'b × 'c × 'a]); path M q (ps @ [t])⟧ ⟹ t ∈ FSM.transitions M› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*proven 3 subgoals*) . show "?case" (*goal: ‹t_target ((ps @ [t]) ! i) = t_source ((ps @ [t]) ! Suc i)›*) proof (cases "Suc i < length ps") (*goals: 1. ‹Suc (i::nat) < length (ps::('a × 'b × 'c × 'a) list) ⟹ t_target ((ps @ [t::'a × 'b × 'c × 'a]) ! i) = t_source ((ps @ [t]) ! Suc i)› 2. ‹¬ Suc (i::nat) < length (ps::('a × 'b × 'c × 'a) list) ⟹ t_target ((ps @ [t::'a × 'b × 'c × 'a]) ! i) = t_source ((ps @ [t]) ! Suc i)›*) case True (*‹Suc i < length ps›*) then have "t_target (ps ! i) = t_source (ps ! Suc i)" using snoc.IH (*‹⟦Suc (i::nat) < length (ps::('a × 'b × 'c × 'a) list); path (M::('a, 'b, 'c) fsm) (q::'a) ps⟧ ⟹ t_target (ps ! i) = t_source (ps ! Suc i)›*) ‹path M q ps› (*‹path M q ps›*) by auto then show "?thesis" (*goal: ‹t_target (((ps::('a × 'b × 'c × 'a) list) @ [t::'a × 'b × 'c × 'a]) ! (i::nat)) = t_source ((ps @ [t]) ! Suc i)›*) by (simp add: Suc_lessD (*‹Suc ?m < ?n ⟹ ?m < ?n›*) True (*‹Suc i < length ps›*) nth_append (*‹(?xs @ ?ys) ! ?n = (if ?n < length ?xs then ?xs ! ?n else ?ys ! (?n - length ?xs))›*)) next (*goal: ‹¬ Suc i < length ps ⟹ t_target ((ps @ [t]) ! i) = t_source ((ps @ [t]) ! Suc i)›*) case False (*‹¬ Suc (i::nat) < length (ps::('a × 'b × 'c × 'a) list)›*) then have "Suc i = length ps" using snoc.prems(1) (*‹Suc (i::nat) < length ((ps::('a × 'b × 'c × 'a) list) @ [t::'a × 'b × 'c × 'a])›*) by auto then have "(ps @ [t]) ! Suc i = t" by auto show "?thesis" (*goal: ‹t_target ((ps @ [t]) ! i) = t_source ((ps @ [t]) ! Suc i)›*) proof (cases "ps = []") (*goals: 1. ‹ps = [] ⟹ t_target ((ps @ [t]) ! i) = t_source ((ps @ [t]) ! Suc i)› 2. ‹ps ≠ [] ⟹ t_target ((ps @ [t]) ! i) = t_source ((ps @ [t]) ! Suc i)›*) case True (*‹ps = []›*) then show "?thesis" (*goal: ‹t_target ((ps @ [t]) ! i) = t_source ((ps @ [t]) ! Suc i)›*) using ‹Suc i = length ps› (*‹Suc i = length ps›*) by auto next (*goal: ‹(ps::('a::type × 'b::type × 'c::type × 'a::type) list) ≠ [] ⟹ t_target ((ps @ [t::'a::type × 'b::type × 'c::type × 'a::type]) ! (i::nat)) = t_source ((ps @ [t]) ! Suc i)›*) case False (*‹ps ≠ []›*) then have "target q ps = t_target (last ps)" unfolding target.simps visited_states.simps (*goal: ‹last ((q::'a) # map t_target (ps::('a × 'b × 'c × 'a) list)) = t_target (last ps)›*) by (simp add: last_map (*‹?xs ≠ [] ⟹ last (map ?f ?xs) = ?f (last ?xs)›*)) then have "target q ps = t_target (ps ! i)" using ‹Suc i = length ps› (*‹Suc i = length ps›*) by (metis False (*‹(ps::('a × 'b × 'c × 'a) list) ≠ []›*) diff_Suc_1 (*‹Suc (?n::nat) - (1::nat) = ?n›*) last_conv_nth (*‹(?xs::?'a list) ≠ [] ⟹ last ?xs = ?xs ! (length ?xs - (1::nat))›*)) then show "?thesis" (*goal: ‹t_target ((ps @ [t]) ! i) = t_source ((ps @ [t]) ! Suc i)›*) using ‹t_source t = target q ps› (*‹t_source t = target q ps›*) by (metis ‹(ps @ [t]) ! Suc i = t› ‹Suc i = length ps› lessI (*‹?n < Suc ?n›*) nth_append (*‹(?xs @ ?ys) ! ?n = (if ?n < length ?xs then ?xs ! ?n else ?ys ! (?n - length ?xs))›*)) qed qed qed lemma paths_finite : "finite { p . path M q p ∧ length p ≤ k }" proof (-) (*goal: ‹finite {p::('a::type × 'b::type × 'c::type × 'a::type) list. path (M::('a::type, 'b::type, 'c::type) fsm) (q::'a::type) p ∧ length p ≤ (k::nat)}›*) have "{ p . path M q p ∧ length p ≤ k } ⊆ {xs . set xs ⊆ transitions M ∧ length xs ≤ k}" by (metis (no_types, lifting) Collect_mono (*‹(⋀x. ?P x ⟶ ?Q x) ⟹ Collect ?P ⊆ Collect ?Q›*) path_transitions (*‹path ?M ?q ?p ⟹ set ?p ⊆ FSM.transitions ?M›*)) then show "finite { p . path M q p ∧ length p ≤ k }" using finite_lists_length_le[OF fsm_transitions_finite [ of M ], of k] (*‹finite {xs. set xs ⊆ FSM.transitions M ∧ length xs ≤ k}›*) by (metis (mono_tags) finite_subset (*‹⟦?A ⊆ ?B; finite ?B⟧ ⟹ finite ?A›*)) qed lemma visited_states_prefix : assumes "q' ∈ set (visited_states q p)" shows "∃ p1 p2 . p = p1@p2 ∧ target q p1 = q'" using assms (*‹q' ∈ set (visited_states q p)›*) proof (induction p arbitrary: q) (*goals: 1. ‹⋀q. q' ∈ set (visited_states q []) ⟹ ∃p1 p2. [] = p1 @ p2 ∧ target q p1 = q'› 2. ‹⋀a p q. ⟦⋀q. q' ∈ set (visited_states q p) ⟹ ∃p1 p2. p = p1 @ p2 ∧ target q p1 = q'; q' ∈ set (visited_states q (a # p))⟧ ⟹ ∃p1 p2. a # p = p1 @ p2 ∧ target q p1 = q'›*) case Nil (*‹q' ∈ set (visited_states q [])›*) then show "?case" (*goal: ‹∃p1 p2. [] = p1 @ p2 ∧ target q p1 = q'›*) by auto next (*goal: ‹⋀a p q. ⟦⋀q. q' ∈ set (visited_states q p) ⟹ ∃p1 p2. p = p1 @ p2 ∧ target q p1 = q'; q' ∈ set (visited_states q (a # p))⟧ ⟹ ∃p1 p2. a # p = p1 @ p2 ∧ target q p1 = q'›*) case (Cons a p) (*‹q' ∈ set (visited_states ?q p) ⟹ ∃p1 p2. p = p1 @ p2 ∧ target ?q p1 = q'› ‹q' ∈ set (visited_states q (a # p))›*) then show "?case" (*goal: ‹∃p1 p2. a # p = p1 @ p2 ∧ target q p1 = q'›*) proof (cases "q' ∈ set (visited_states (t_target a) p)") (*goals: 1. ‹⟦⋀q. q' ∈ set (visited_states q p) ⟹ ∃p1 p2. p = p1 @ p2 ∧ target q p1 = q'; q' ∈ set (visited_states q (a # p)); q' ∈ set (visited_states (t_target a) p)⟧ ⟹ ∃p1 p2. a # p = p1 @ p2 ∧ target q p1 = q'› 2. ‹⟦⋀q. q' ∈ set (visited_states q p) ⟹ ∃p1 p2. p = p1 @ p2 ∧ target q p1 = q'; q' ∈ set (visited_states q (a # p)); q' ∉ set (visited_states (t_target a) p)⟧ ⟹ ∃p1 p2. a # p = p1 @ p2 ∧ target q p1 = q'›*) case True (*‹(q'::'a) ∈ set (visited_states (t_target (a::'a × 'b × 'c × 'a)) (p::('a × 'b × 'c × 'a) list))›*) then obtain p1 and p2 where "p = p1 @ p2 ∧ target (t_target a) p1 = q'" (*goal: ‹(⋀p1 p2. p = p1 @ p2 ∧ target (t_target a) p1 = q' ⟹ thesis) ⟹ thesis›*) using Cons.IH (*‹q' ∈ set (visited_states ?q p) ⟹ ∃p1 p2. p = p1 @ p2 ∧ target ?q p1 = q'›*) by blast then have "(a#p) = (a#p1)@p2 ∧ target q (a#p1) = q'" by auto then show "?thesis" (*goal: ‹∃p1 p2. a # p = p1 @ p2 ∧ target q p1 = q'›*) by blast next (*goal: ‹⟦⋀q. q' ∈ set (visited_states q p) ⟹ ∃p1 p2. p = p1 @ p2 ∧ target q p1 = q'; q' ∈ set (visited_states q (a # p)); q' ∉ set (visited_states (t_target a) p)⟧ ⟹ ∃p1 p2. a # p = p1 @ p2 ∧ target q p1 = q'›*) case False (*‹q' ∉ set (visited_states (t_target a) p)›*) then have "q' = q" using Cons.prems (*‹q' ∈ set (visited_states q (a # p))›*) by auto then show "?thesis" (*goal: ‹∃p1 p2. a # p = p1 @ p2 ∧ target q p1 = q'›*) by auto qed qed lemma visited_states_are_states : assumes "path M q1 p" shows "set (visited_states q1 p) ⊆ states M" by (metis assms (*‹path M q1 p›*) path_prefix (*‹path ?M ?q (?p1.0 @ ?p2.0) ⟹ path ?M ?q ?p1.0›*) path_target_is_state (*‹path ?M ?q ?p ⟹ target ?q ?p ∈ FSM.states ?M›*) subsetI (*‹(⋀x. x ∈ ?A ⟹ x ∈ ?B) ⟹ ?A ⊆ ?B›*) visited_states_prefix (*‹?q' ∈ set (visited_states ?q ?p) ⟹ ∃p1 p2. ?p = p1 @ p2 ∧ target ?q p1 = ?q'›*)) lemma transition_subset_path : assumes "transitions A ⊆ transitions B" and "path A q p" and "q ∈ states B" shows "path B q p" using assms(2) (*‹path A q p›*) proof (induction p rule: rev_induct (*‹⟦?P []; ⋀x xs. ?P xs ⟹ ?P (xs @ [x])⟧ ⟹ ?P ?xs›*)) (*goals: 1. ‹path (A::('a, 'b, 'c) fsm) (q::'a) [] ⟹ path (B::('a, 'b, 'c) fsm) q []› 2. ‹⋀(x::'a × 'b × 'c × 'a) xs::('a × 'b × 'c × 'a) list. ⟦path (A::('a, 'b, 'c) fsm) (q::'a) xs ⟹ path (B::('a, 'b, 'c) fsm) q xs; path A q (xs @ [x])⟧ ⟹ path B q (xs @ [x])›*) case Nil (*‹path A q []›*) show "?case" (*goal: ‹path B q []›*) using assms(3) (*‹q ∈ FSM.states B›*) by auto next (*goal: ‹⋀x xs. ⟦path A q xs ⟹ path B q xs; path A q (xs @ [x])⟧ ⟹ path B q (xs @ [x])›*) case (snoc t p) (*‹path A q p ⟹ path B q p› ‹path A q (p @ [t])›*) then show "?case" (*goal: ‹path B q (p @ [t])›*) using assms(1) (*‹FSM.transitions A ⊆ FSM.transitions B›*) path_suffix (*‹path ?M ?q (?p1.0 @ ?p2.0) ⟹ path ?M (target ?q ?p1.0) ?p2.0›*) by fastforce qed subsubsection ‹Paths of fixed length› fun paths_of_length' :: "('a,'b,'c) path ⇒ 'a ⇒ (('a ×'b) ⇒ ('c×'a) set) ⇒ 'b set ⇒ nat ⇒ ('a,'b,'c) path set" where "paths_of_length' prev q hM iM 0 = {prev}" | "paths_of_length' prev q hM iM (Suc k) = (let hF = transitions_from' hM iM q in ⋃ (image (λ t . paths_of_length' (prev@[t]) (t_target t) hM iM k) hF))" fun paths_of_length :: "('a,'b,'c) fsm ⇒ 'a ⇒ nat ⇒ ('a,'b,'c) path set" where "paths_of_length M q k = paths_of_length' [] q (h M) (inputs M) k" subsubsection ‹Paths up to fixed length› fun paths_up_to_length' :: "('a,'b,'c) path ⇒ 'a ⇒ (('a ×'b) ⇒ (('c×'a) set)) ⇒ 'b set ⇒ nat ⇒ ('a,'b,'c) path set" where "paths_up_to_length' prev q hM iM 0 = {prev}" | "paths_up_to_length' prev q hM iM (Suc k) = (let hF = transitions_from' hM iM q in insert prev (⋃ (image (λ t . paths_up_to_length' (prev@[t]) (t_target t) hM iM k) hF)))" fun paths_up_to_length :: "('a,'b,'c) fsm ⇒ 'a ⇒ nat ⇒ ('a,'b,'c) path set" where "paths_up_to_length M q k = paths_up_to_length' [] q (h M) (inputs M) k" lemma paths_up_to_length'_set : assumes "q ∈ states M" and "path M q prev" shows "paths_up_to_length' prev (target q prev) (h M) (inputs M) k = {(prev@p) | p . path M (target q prev) p ∧ length p ≤ k}" using assms(2) (*‹path (M::('a, 'b, 'c) fsm) (q::'a) (prev::('a × 'b × 'c × 'a) list)›*) proof (induction k arbitrary: prev) (*goals: 1. ‹⋀prev. path M q prev ⟹ paths_up_to_length' prev (target q prev) (FSM.h M) (FSM.inputs M) 0 = {prev @ p |p. path M (target q prev) p ∧ length p ≤ 0}› 2. ‹⋀k prev. ⟦⋀prev. path M q prev ⟹ paths_up_to_length' prev (target q prev) (FSM.h M) (FSM.inputs M) k = {prev @ p |p. path M (target q prev) p ∧ length p ≤ k}; path M q prev⟧ ⟹ paths_up_to_length' prev (target q prev) (FSM.h M) (FSM.inputs M) (Suc k) = {prev @ p |p. path M (target q prev) p ∧ length p ≤ Suc k}›*) case 0 (*‹path M q prev›*) show "?case" (*goal: ‹paths_up_to_length' prev (target q prev) (FSM.h M) (FSM.inputs M) 0 = {prev @ p |p. path M (target q prev) p ∧ length p ≤ 0}›*) unfolding paths_up_to_length'.simps (*goal: ‹{prev} = {prev @ p |p. path M (target q prev) p ∧ length p ≤ 0}›*) using path_target_is_state[OF "0.prems" ( 1 )] (*‹target q prev ∈ FSM.states M›*) by auto next (*goal: ‹⋀k prev. ⟦⋀prev. path M q prev ⟹ paths_up_to_length' prev (target q prev) (FSM.h M) (FSM.inputs M) k = {prev @ p |p. path M (target q prev) p ∧ length p ≤ k}; path M q prev⟧ ⟹ paths_up_to_length' prev (target q prev) (FSM.h M) (FSM.inputs M) (Suc k) = {prev @ p |p. path M (target q prev) p ∧ length p ≤ Suc k}›*) case (Suc k) (*‹path M q ?prev ⟹ paths_up_to_length' ?prev (target q ?prev) (FSM.h M) (FSM.inputs M) k = {?prev @ p |p. path M (target q ?prev) p ∧ length p ≤ k}› ‹path M q prev›*) have "⋀ p . p ∈ paths_up_to_length' prev (target q prev) (h M) (inputs M) (Suc k) ⟹ p ∈ {(prev@p) | p . path M (target q prev) p ∧ length p ≤ Suc k}" proof (-) (*goal: ‹⋀p. p ∈ paths_up_to_length' prev (target q prev) (FSM.h M) (FSM.inputs M) (Suc k) ⟹ p ∈ {prev @ p |p. path M (target q prev) p ∧ length p ≤ Suc k}›*) fix p assume "p ∈ paths_up_to_length' prev (target q prev) (h M) (inputs M) (Suc k)" (*‹(p::('a × 'b × 'c × 'a) list) ∈ paths_up_to_length' (prev::('a × 'b × 'c × 'a) list) (target (q::'a) prev) (FSM.h (M::('a, 'b, 'c) fsm)) (FSM.inputs M) (Suc (k::nat))›*) then show "p ∈ {(prev@p) | p . path M (target q prev) p ∧ length p ≤ Suc k}" proof (cases "p = prev") (*goals: 1. ‹⟦p ∈ paths_up_to_length' prev (target q prev) (FSM.h M) (FSM.inputs M) (Suc k); p = prev⟧ ⟹ p ∈ {prev @ p |p. path M (target q prev) p ∧ length p ≤ Suc k}› 2. ‹⟦p ∈ paths_up_to_length' prev (target q prev) (FSM.h M) (FSM.inputs M) (Suc k); p ≠ prev⟧ ⟹ p ∈ {prev @ p |p. path M (target q prev) p ∧ length p ≤ Suc k}›*) case True (*‹p = prev›*) show "?thesis" (*goal: ‹p ∈ {prev @ p |p. path M (target q prev) p ∧ length p ≤ Suc k}›*) using path_target_is_state[OF Suc.prems ( 1 )] (*‹target q prev ∈ FSM.states M›*) unfolding True (*goal: ‹prev ∈ {prev @ p |p. path M (target q prev) p ∧ length p ≤ Suc k}›*) by (simp add: nil (*‹?q ∈ FSM.states ?M ⟹ path ?M ?q []›*)) next (*goal: ‹⟦p ∈ paths_up_to_length' prev (target q prev) (FSM.h M) (FSM.inputs M) (Suc k); p ≠ prev⟧ ⟹ p ∈ {prev @ p |p. path M (target q prev) p ∧ length p ≤ Suc k}›*) case False (*‹p ≠ prev›*) then have "p ∈ (⋃ (image (λt. paths_up_to_length' (prev@[t]) (t_target t) (h M) (inputs M) k) (transitions_from' (h M) (inputs M) (target q prev))))" using ‹p ∈ paths_up_to_length' prev (target q prev) (h M) (inputs M) (Suc k)› (*‹p ∈ paths_up_to_length' prev (target q prev) (FSM.h M) (FSM.inputs M) (Suc k)›*) unfolding paths_up_to_length'.simps Let_def (*goal: ‹p ∈ (⋃t∈transitions_from' (FSM.h M) (FSM.inputs M) (target q prev). paths_up_to_length' (prev @ [t]) (t_target t) (FSM.h M) (FSM.inputs M) k)›*) by blast then obtain t where "t ∈ ⋃(image (λx . image (λ(y,q') . ((target q prev),x,y,q')) (h M ((target q prev),x))) (inputs M))" and "p ∈ paths_up_to_length' (prev@[t]) (t_target t) (h M) (inputs M) k" (*goal: ‹(⋀t. ⟦t ∈ (⋃x∈FSM.inputs M. (λ(y, q'). (target q prev, x, y, q')) ` FSM.h M (target q prev, x)); p ∈ paths_up_to_length' (prev @ [t]) (t_target t) (FSM.h M) (FSM.inputs M) k⟧ ⟹ thesis) ⟹ thesis›*) unfolding transitions_from'.simps (*goal: ‹(⋀t. ⟦t ∈ (⋃x∈FSM.inputs M. (λ(y, q'). (target q prev, x, y, q')) ` FSM.h M (target q prev, x)); p ∈ paths_up_to_length' (prev @ [t]) (t_target t) (FSM.h M) (FSM.inputs M) k⟧ ⟹ thesis) ⟹ thesis›*) by blast have "t ∈ transitions M" and "t_source t = (target q prev)" using ‹t ∈ ⋃(image (λx . image (λ(y,q') . ((target q prev),x,y,q')) (h M ((target q prev),x))) (inputs M))› (*‹t ∈ (⋃x∈FSM.inputs M. (λ(y, q'). (target q prev, x, y, q')) ` FSM.h M (target q prev, x))›*) apply - (*goals: 1. ‹(t::'a::type × 'b::type × 'c::type × 'a::type) ∈ (⋃x::'b::type∈FSM.inputs M. (λ(y::'c::type, q'::'a::type). (target (q::'a::type) (prev::('a::type × 'b::type × 'c::type × 'a::type) list), x, y, q')) ` FSM.h (M::('a::type, 'b::type, 'c::type) fsm) (target q prev, x)) ⟹ t ∈ FSM.transitions M› 2. ‹(t::'a::type × 'b::type × 'c::type × 'a::type) ∈ (⋃x::'b::type∈FSM.inputs M. (λ(y::'c::type, q'::'a::type). (target (q::'a::type) (prev::('a::type × 'b::type × 'c::type × 'a::type) list), x, y, q')) ` FSM.h (M::('a::type, 'b::type, 'c::type) fsm) (target q prev, x)) ⟹ t_source t = target q prev› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . then have "path M q (prev@[t])" using Suc.prems(1) (*‹path M q prev›*) using path_append_transition (*‹⟦path (?M::(?'a::type, ?'b::type, ?'c::type) fsm) (?q::?'a::type) (?p::(?'a::type × ?'b::type × ?'c::type × ?'a::type) list); (?t::?'a::type × ?'b::type × ?'c::type × ?'a::type) ∈ FSM.transitions ?M; t_source ?t = target ?q ?p⟧ ⟹ path ?M ?q (?p @ [?t])›*) by simp have "(target q (prev @ [t])) = t_target t" by auto show "?thesis" (*goal: ‹p ∈ {prev @ p |p. path M (target q prev) p ∧ length p ≤ Suc k}›*) using ‹p ∈ paths_up_to_length' (prev@[t]) (t_target t) (h M) (inputs M) k› (*‹p ∈ paths_up_to_length' (prev @ [t]) (t_target t) (FSM.h M) (FSM.inputs M) k›*) using Suc.IH[OF ‹path M q (prev@[t])›] (*‹paths_up_to_length' (prev @ [t]) (target q (prev @ [t])) (FSM.h M) (FSM.inputs M) k = {(prev @ [t]) @ p |p. path M (target q (prev @ [t])) p ∧ length p ≤ k}›*) unfolding ‹(target q (prev @ [t])) = t_target t› (*goal: ‹p ∈ {prev @ p |p. path M (target q prev) p ∧ length p ≤ Suc k}›*) using ‹path M q (prev @ [t])› (*‹path (M::('a::type, 'b::type, 'c::type) fsm) (q::'a::type) ((prev::('a::type × 'b::type × 'c::type × 'a::type) list) @ [t::'a::type × 'b::type × 'c::type × 'a::type])›*) by auto qed qed moreover have "⋀ p . p ∈ {(prev@p) | p . path M (target q prev) p ∧ length p ≤ Suc k} ⟹ p ∈ paths_up_to_length' prev (target q prev) (h M) (inputs M) (Suc k)" proof (-) (*goal: ‹⋀p. p ∈ {prev @ p |p. path M (target q prev) p ∧ length p ≤ Suc k} ⟹ p ∈ paths_up_to_length' prev (target q prev) (FSM.h M) (FSM.inputs M) (Suc k)›*) fix p assume "p ∈ {(prev@p) | p . path M (target q prev) p ∧ length p ≤ Suc k}" (*‹(p::('a × 'b × 'c × 'a) list) ∈ {(prev::('a × 'b × 'c × 'a) list) @ p |p::('a × 'b × 'c × 'a) list. path (M::('a, 'b, 'c) fsm) (target (q::'a) prev) p ∧ length p ≤ Suc (k::nat)}›*) then obtain p' where "p = prev@p'" and "path M (target q prev) p'" and "length p' ≤ Suc k" (*goal: ‹(⋀p'. ⟦p = prev @ p'; path M (target q prev) p'; length p' ≤ Suc k⟧ ⟹ thesis) ⟹ thesis›*) by blast have "prev@p' ∈ paths_up_to_length' prev (target q prev) (h M) (inputs M) (Suc k)" proof (cases p') (*goals: 1. ‹p' = [] ⟹ prev @ p' ∈ paths_up_to_length' prev (target q prev) (FSM.h M) (FSM.inputs M) (Suc k)› 2. ‹⋀a list. p' = a # list ⟹ prev @ p' ∈ paths_up_to_length' prev (target q prev) (FSM.h M) (FSM.inputs M) (Suc k)›*) case Nil (*‹p' = []›*) then show "?thesis" (*goal: ‹(prev::('a × 'b × 'c × 'a) list) @ (p'::('a × 'b × 'c × 'a) list) ∈ paths_up_to_length' prev (target (q::'a) prev) (FSM.h (M::('a, 'b, 'c) fsm)) (FSM.inputs M) (Suc (k::nat))›*) by auto next (*goal: ‹⋀(a::'a::type × 'b::type × 'c::type × 'a::type) list::('a::type × 'b::type × 'c::type × 'a::type) list. (p'::('a::type × 'b::type × 'c::type × 'a::type) list) = a # list ⟹ (prev::('a::type × 'b::type × 'c::type × 'a::type) list) @ p' ∈ paths_up_to_length' prev (target (q::'a::type) prev) (FSM.h (M::('a::type, 'b::type, 'c::type) fsm)) (FSM.inputs M) (Suc (k::nat))›*) case (Cons t p'') (*‹p' = t # p''›*) then have "t ∈ transitions M" and "t_source t = (target q prev)" using ‹path M (target q prev) p'› (*‹path M (target q prev) p'›*) apply - (*goals: 1. ‹⟦p' = t # p''; path M (target q prev) p'⟧ ⟹ t ∈ FSM.transitions M› 2. ‹⟦p' = t # p''; path M (target q prev) p'⟧ ⟹ t_source t = target q prev› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . then have "path M q (prev@[t])" using Suc.prems(1) (*‹path M q prev›*) using path_append_transition (*‹⟦path ?M ?q ?p; ?t ∈ FSM.transitions ?M; t_source ?t = target ?q ?p⟧ ⟹ path ?M ?q (?p @ [?t])›*) by simp have "(target q (prev @ [t])) = t_target t" by auto have "length p'' ≤ k" using ‹length p' ≤ Suc k› (*‹length p' ≤ Suc k›*) Cons (*‹p' = t # p''›*) by auto moreover have "path M (target q (prev@[t])) p''" using ‹path M (target q prev) p'› (*‹path M (target q prev) p'›*) unfolding Cons (*goal: ‹path M (target q (prev @ [t])) p''›*) by auto ultimately have "p ∈ paths_up_to_length' (prev @ [t]) (t_target t) (h M) (FSM.inputs M) k" using Suc.IH[OF ‹path M q (prev@[t])›] (*‹paths_up_to_length' (prev @ [t]) (target q (prev @ [t])) (FSM.h M) (FSM.inputs M) k = {(prev @ [t]) @ p |p. path M (target q (prev @ [t])) p ∧ length p ≤ k}›*) unfolding ‹(target q (prev @ [t])) = t_target t› ‹p = prev@p'› Cons (*goal: ‹prev @ t # p'' ∈ paths_up_to_length' (prev @ [t]) (t_target t) (FSM.h M) (FSM.inputs M) k›*) by simp then have "prev@t#p'' ∈ paths_up_to_length' (prev @ [t]) (t_target t) (h M) (FSM.inputs M) k" unfolding ‹p = prev@p'› Cons (*goal: ‹prev @ t # p'' ∈ paths_up_to_length' (prev @ [t]) (t_target t) (FSM.h M) (FSM.inputs M) k›*) by auto have "t ∈ (λ(y, q'). (t_source t, t_input t, y, q')) ` {(y, q'). (t_source t, t_input t, y, q') ∈ FSM.transitions M}" using ‹t ∈ transitions M› (*‹t ∈ FSM.transitions M›*) by (metis (no_types, lifting) case_prodI (*‹?f ?a ?b ⟹ case (?a, ?b) of (c, d) ⇒ ?f c d›*) mem_Collect_eq (*‹(?a ∈ Collect ?P) = ?P ?a›*) pair_imageI (*‹(?a, ?b) ∈ ?A ⟹ ?f ?a ?b ∈ (λ(a, b). ?f a b) ` ?A›*) surjective_pairing (*‹?t = (fst ?t, snd ?t)›*)) then have "t ∈ transitions_from' (h M) (inputs M) (target q prev)" unfolding transitions_from'.simps (*goal: ‹t ∈ (⋃x∈FSM.inputs M. (λ(y, q'). (target q prev, x, y, q')) ` FSM.h M (target q prev, x))›*) using fsm_transition_input[OF ‹t ∈ transitions M›] (*‹t_input t ∈ FSM.inputs M›*) unfolding ‹t_source t = (target q prev)›[symmetric] h_simps (*goal: ‹t ∈ (⋃x∈FSM.inputs M. (λ(y, q'). (t_source t, x, y, q')) ` {(y, q'). (t_source t, x, y, q') ∈ FSM.transitions M})›*) by blast then show "?thesis" (*goal: ‹prev @ p' ∈ paths_up_to_length' prev (target q prev) (FSM.h M) (FSM.inputs M) (Suc k)›*) using ‹prev @ t # p'' ∈ paths_up_to_length' (prev@[t]) (t_target t) (h M) (FSM.inputs M) k› (*‹prev @ t # p'' ∈ paths_up_to_length' (prev @ [t]) (t_target t) (FSM.h M) (FSM.inputs M) k›*) unfolding ‹p = prev@p'› Cons paths_up_to_length'.simps Let_def (*goal: ‹prev @ t # p'' ∈ insert prev (⋃t∈transitions_from' (FSM.h M) (FSM.inputs M) (target q prev). paths_up_to_length' (prev @ [t]) (t_target t) (FSM.h M) (FSM.inputs M) k)›*) by blast qed then show "p ∈ paths_up_to_length' prev (target q prev) (h M) (inputs M) (Suc k)" unfolding ‹p = prev@p'› (*goal: ‹prev @ p' ∈ paths_up_to_length' prev (target q prev) (FSM.h M) (FSM.inputs M) (Suc k)›*) by assumption qed ultimately show "?case" (*goal: ‹paths_up_to_length' prev (target q prev) (FSM.h M) (FSM.inputs M) (Suc k) = {prev @ p |p. path M (target q prev) p ∧ length p ≤ Suc k}›*) by blast qed lemma paths_up_to_length_set : assumes "q ∈ states M" shows "paths_up_to_length M q k = {p . path M q p ∧ length p ≤ k}" unfolding paths_up_to_length.simps (*goal: ‹paths_up_to_length' [] q (FSM.h M) (FSM.inputs M) k = {p. path M q p ∧ length p ≤ k}›*) using paths_up_to_length'_set[OF assms nil [ OF assms ], of k] (*‹paths_up_to_length' [] (target q []) (FSM.h M) (FSM.inputs M) k = {[] @ p |p. path M (target q []) p ∧ length p ≤ k}›*) by auto subsubsection ‹Calculating Acyclic Paths› fun acyclic_paths_up_to_length' :: "('a,'b,'c) path ⇒ 'a ⇒ ('a ⇒ (('b×'c×'a) set)) ⇒ 'a set ⇒ nat ⇒ ('a,'b,'c) path set" where "acyclic_paths_up_to_length' prev q hF visitedStates 0 = {prev}" | "acyclic_paths_up_to_length' prev q hF visitedStates (Suc k) = (let tF = Set.filter (λ (x,y,q') . q' ∉ visitedStates) (hF q) in (insert prev (⋃ (image (λ (x,y,q') . acyclic_paths_up_to_length' (prev@[(q,x,y,q')]) q' hF (insert q' visitedStates) k) tF))))" fun p_source :: "'a ⇒ ('a,'b,'c) path ⇒ 'a" where "p_source q p = hd (visited_states q p)" lemma acyclic_paths_up_to_length'_prev : "p' ∈ acyclic_paths_up_to_length' (prev@prev') q hF visitedStates k ⟹ ∃ p'' . p' = prev@p''" apply ((induction k arbitrary: p' q visitedStates prev')[1]) (*goals: 1. ‹⋀p' q visitedStates prev'. p' ∈ acyclic_paths_up_to_length' (prev @ prev') q hF visitedStates 0 ⟹ ∃p''. p' = prev @ p''› 2. ‹⋀k p' q visitedStates prev'. ⟦⋀p' q visitedStates prev'. p' ∈ acyclic_paths_up_to_length' (prev @ prev') q hF visitedStates k ⟹ ∃p''. p' = prev @ p''; p' ∈ acyclic_paths_up_to_length' (prev @ prev') q hF visitedStates (Suc k)⟧ ⟹ ∃p''. p' = prev @ p''› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . lemma acyclic_paths_up_to_length'_set : assumes "path M (p_source q prev) prev" and "⋀ q' . hF q' = {(x,y,q'') | x y q'' . (q',x,y,q'') ∈ transitions M}" and "distinct (visited_states (p_source q prev) prev)" and "visitedStates = set (visited_states (p_source q prev) prev)" shows "acyclic_paths_up_to_length' prev (target (p_source q prev) prev) hF visitedStates k = { prev@p | p . path M (p_source q prev) (prev@p) ∧ length p ≤ k ∧ distinct (visited_states (p_source q prev) (prev@p)) }" using assms proof (induction k arbitrary: q hF prev visitedStates) case 0 then show ?case by auto next case (Suc k) let ?tgt = "(target (p_source q prev) prev)" have "⋀ p . (prev@p) ∈ acyclic_paths_up_to_length' prev (target (p_source q prev) prev) hF visitedStates (Suc k) ⟹ path M (p_source q prev) (prev@p) ∧ length p ≤ Suc k ∧ distinct (visited_states (p_source q prev) (prev@p))" proof - fix p assume "(prev@p) ∈ acyclic_paths_up_to_length' prev (target (p_source q prev) prev) hF visitedStates (Suc k)" then consider (a) "(prev@p) = prev" | (b) "(prev@p) ∈ (⋃ (image (λ (x,y,q') . acyclic_paths_up_to_length' (prev@[(?tgt,x,y,q')]) q' hF (insert q' visitedStates) k) (Set.filter (λ (x,y,q') . q' ∉ visitedStates) (hF (target (p_source q prev) prev)))))" by auto then show "path M (p_source q prev) (prev@p) ∧ length p ≤ Suc k ∧ distinct (visited_states (p_source q prev) (prev@p))" proof (cases) case a then show ?thesis using Suc.prems(1,3) by auto next case b then obtain x y q' where *: "(x,y,q') ∈ Set.filter (λ (x,y,q') . q' ∉ visitedStates) (hF ?tgt)" and **:"(prev@p) ∈ acyclic_paths_up_to_length' (prev@[(?tgt,x,y,q')]) q' hF (insert q' visitedStates) k" by auto let ?t = "(?tgt,x,y,q')" from * have "?t ∈ transitions M" and "q' ∉ visitedStates" using Suc.prems(2)[of ?tgt] by simp+ moreover have "t_source ?t = target (p_source q prev) prev" by simp moreover have "p_source (p_source q prev) (prev@[?t]) = p_source q prev" by auto ultimately have p1: "path M (p_source (p_source q prev) (prev@[?t])) (prev@[?t])" using Suc.prems(1) by (simp add: path_append_transition) have "q' ∉ set (visited_states (p_source q prev) prev)" using ‹q' ∉ visitedStates› Suc.prems(4) by auto then have p2: "distinct (visited_states (p_source (p_source q prev) (prev@[?t])) (prev@[?t]))" using Suc.prems(3) by auto have p3: "(insert q' visitedStates) = set (visited_states (p_source (p_source q prev) (prev@[?t])) (prev@[?t]))" using Suc.prems(4) by auto have ***: "(target (p_source (p_source q prev) (prev @ [(target (p_source q prev) prev, x, y, q')])) (prev @ [(target (p_source q prev) prev, x, y, q')])) = q'" by auto show ?thesis using Suc.IH[OF p1 Suc.prems(2) p2 p3] ** unfolding *** unfolding ‹p_source (p_source q prev) (prev@[?t]) = p_source q prev› proof - assume "acyclic_paths_up_to_length' (prev @ [(target (p_source q prev) prev, x, y, q')]) q' hF (insert q' visitedStates) k = {(prev @ [(target (p_source q prev) prev, x, y, q')]) @ p |p. path M (p_source q prev) ((prev @ [(target (p_source q prev) prev, x, y, q')]) @ p) ∧ length p ≤ k ∧ distinct (visited_states (p_source q prev) ((prev @ [(target (p_source q prev) prev, x, y, q')]) @ p))}" then have "∃ps. prev @ p = (prev @ [(target (p_source q prev) prev, x, y, q')]) @ ps ∧ path M (p_source q prev) ((prev @ [(target (p_source q prev) prev, x, y, q')]) @ ps) ∧ length ps ≤ k ∧ distinct (visited_states (p_source q prev) ((prev @ [(target (p_source q prev) prev, x, y, q')]) @ ps))" using ‹prev @ p ∈ acyclic_paths_up_to_length' (prev @ [(target (p_source q prev) prev, x, y, q')]) q' hF (insert q' visitedStates) k› by blast then show ?thesis by (metis (no_types) Suc_le_mono append.assoc append.right_neutral append_Cons length_Cons same_append_eq) qed qed qed moreover have "⋀ p' . p' ∈ acyclic_paths_up_to_length' prev (target (p_source q prev) prev) hF visitedStates (Suc k) ⟹ ∃ p'' . p' = prev@p''" using acyclic_paths_up_to_length'_prev[of _ prev "[]" "target (p_source q prev) prev" hF visitedStates "Suc k"] by force ultimately have fwd: "⋀ p' . p' ∈ acyclic_paths_up_to_length' prev (target (p_source q prev) prev) hF visitedStates (Suc k) ⟹ p' ∈ { prev@p | p . path M (p_source q prev) (prev@p) ∧ length p ≤ Suc k ∧ distinct (visited_states (p_source q prev) (prev@p)) }" by blast have "⋀ p . path M (p_source q prev) (prev@p) ⟹ length p ≤ Suc k ⟹ distinct (visited_states (p_source q prev) (prev@p)) ⟹ (prev@p) ∈ acyclic_paths_up_to_length' prev (target (p_source q prev) prev) hF visitedStates (Suc k)" proof - fix p assume "path M (p_source q prev) (prev@p)" and "length p ≤ Suc k" and "distinct (visited_states (p_source q prev) (prev@p))" show "(prev@p) ∈ acyclic_paths_up_to_length' prev (target (p_source q prev) prev) hF visitedStates (Suc k)" proof (cases p) case Nil then show ?thesis by auto next case (Cons t p') then have "t_source t = target (p_source q (prev)) (prev)" and "t ∈ transitions M" using ‹path M (p_source q prev) (prev@p)› by auto have "path M (p_source q (prev@[t])) ((prev@[t])@p')" and "path M (p_source q (prev@[t])) ((prev@[t]))" using Cons ‹path M (p_source q prev) (prev@p)› by auto have "length p' ≤ k" using Cons ‹length p ≤ Suc k› by auto have "distinct (visited_states (p_source q (prev@[t])) ((prev@[t])@p'))" and "distinct (visited_states (p_source q (prev@[t])) ((prev@[t])))" using Cons ‹distinct (visited_states (p_source q prev) (prev@p))› by auto then have "t_target t ∉ visitedStates" using Suc.prems(4) by auto let ?vN = "insert (t_target t) visitedStates" have "?vN = set (visited_states (p_source q (prev @ [t])) (prev @ [t]))" using Suc.prems(4) by auto have "prev@p = prev@([t]@p')" using Cons by auto have "(prev@[t])@p' ∈ acyclic_paths_up_to_length' (prev @ [t]) (target (p_source q (prev @ [t])) (prev @ [t])) hF (insert (t_target t) visitedStates) k" using Suc.IH[of q "prev@[t]", OF ‹path M (p_source q (prev@[t])) ((prev@[t]))› Suc.prems(2) ‹distinct (visited_states (p_source q (prev@[t])) ((prev@[t])))› ‹?vN = set (visited_states (p_source q (prev @ [t])) (prev @ [t]))› ] using ‹path M (p_source q (prev@[t])) ((prev@[t])@p')› ‹length p' ≤ k› ‹distinct (visited_states (p_source q (prev@[t])) ((prev@[t])@p'))› by force then have "(prev@[t])@p' ∈ acyclic_paths_up_to_length' (prev@[t]) (t_target t) hF ?vN k" by auto moreover have "(t_input t,t_output t, t_target t) ∈ Set.filter (λ (x,y,q') . q' ∉ visitedStates) (hF (t_source t))" using Suc.prems(2)[of "t_source t"] ‹t ∈ transitions M› ‹t_target t ∉ visitedStates› proof - have "∃b c a. snd t = (b, c, a) ∧ (t_source t, b, c, a) ∈ FSM.transitions M" by (metis (no_types) ‹t ∈ FSM.transitions M› prod.collapse) then show ?thesis using ‹hF (t_source t) = {(x, y, q'') |x y q''. (t_source t, x, y, q'') ∈ FSM.transitions M}› ‹t_target t ∉ visitedStates› by fastforce qed ultimately have "∃ (x,y,q') ∈ (Set.filter (λ (x,y,q') . q' ∉ visitedStates) (hF (target (p_source q prev) prev))) . (prev@[t])@p' ∈ (acyclic_paths_up_to_length' (prev@[((target (p_source q prev) prev),x,y,q')]) q' hF (insert q' visitedStates) k)" unfolding ‹t_source t = target (p_source q (prev)) (prev)› by (metis (no_types, lifting) ‹t_source t = target (p_source q prev) prev› case_prodI prod.collapse) then show ?thesis unfolding ‹prev@p = prev@[t]@p'› unfolding acyclic_paths_up_to_length'.simps Let_def by force qed qed then have rev: "⋀ p' . p' ∈ {prev@p | p . path M (p_source q prev) (prev@p) ∧ length p ≤ Suc k ∧ distinct (visited_states (p_source q prev) (prev@p))} ⟹ p' ∈ acyclic_paths_up_to_length' prev (target (p_source q prev) prev) hF visitedStates (Suc k)" by blast show ?case using fwd rev by blast qed fun acyclic_paths_up_to_length :: "('a,'b,'c) fsm ⇒ 'a ⇒ nat ⇒ ('a,'b,'c) path set" where "acyclic_paths_up_to_length M q k = {p. path M q p ∧ length p ≤ k ∧ distinct (visited_states q p)}" lemma acyclic_paths_up_to_length_code[code] : "acyclic_paths_up_to_length M q k = (if q ∈ states M then acyclic_paths_up_to_length' [] q (m2f (set_as_map (transitions M))) {q} k else {})" proof (cases "q ∈ states M") (*goals: 1. ‹q ∈ FSM.states M ⟹ acyclic_paths_up_to_length M q k = (if q ∈ FSM.states M then acyclic_paths_up_to_length' [] q (λx. case set_as_map (FSM.transitions M) x of None ⇒ {} | Some xs ⇒ xs) {q} k else {})› 2. ‹q ∉ FSM.states M ⟹ acyclic_paths_up_to_length M q k = (if q ∈ FSM.states M then acyclic_paths_up_to_length' [] q (λx. case set_as_map (FSM.transitions M) x of None ⇒ {} | Some xs ⇒ xs) {q} k else {})›*) case False (*‹(q::'a::type) ∉ FSM.states (M::('a::type, 'b::type, 'c::type) fsm)›*) then have "acyclic_paths_up_to_length M q k = {}" using path_begin_state (*‹path ?M ?q ?p ⟹ ?q ∈ FSM.states ?M›*) by fastforce then show "?thesis" (*goal: ‹acyclic_paths_up_to_length M q k = (if q ∈ FSM.states M then acyclic_paths_up_to_length' [] q (λx. case set_as_map (FSM.transitions M) x of None ⇒ {} | Some xs ⇒ xs) {q} k else {})›*) using False (*‹q ∉ FSM.states M›*) by auto next (*goal: ‹q ∈ FSM.states M ⟹ acyclic_paths_up_to_length M q k = (if q ∈ FSM.states M then acyclic_paths_up_to_length' [] q (λx. case set_as_map (FSM.transitions M) x of None ⇒ {} | Some xs ⇒ xs) {q} k else {})›*) case True (*‹q ∈ FSM.states M›*) then have "*": "path M (p_source q []) []" by auto have "**": "(⋀q'. (m2f (set_as_map (transitions M))) q' = {(x, y, q'') |x y q''. (q', x, y, q'') ∈ FSM.transitions M})" unfolding set_as_map_def (*goal: ‹⋀q'::'a::type. (case if ∃z::'b::type × 'c::type × 'a::type. (q', z) ∈ FSM.transitions (M::('a::type, 'b::type, 'c::type) fsm) then Some {z::'b::type × 'c::type × 'a::type. (q', z) ∈ FSM.transitions M} else None of None ⇒ {} | Some (xs::('b::type × 'c::type × 'a::type) set) ⇒ xs) = {(x, y, q'') |(x::'b::type) (y::'c::type) q''::'a::type. (q', x, y, q'') ∈ FSM.transitions M}›*) by auto have "***": "distinct (visited_states (p_source q []) [])" by auto have "****": "{q} = set (visited_states (p_source q []) [])" by auto show "?thesis" (*goal: ‹acyclic_paths_up_to_length M q k = (if q ∈ FSM.states M then acyclic_paths_up_to_length' [] q (λx. case set_as_map (FSM.transitions M) x of None ⇒ {} | Some xs ⇒ xs) {q} k else {})›*) using acyclic_paths_up_to_length'_set[OF * ** *** ****, of k] (*‹acyclic_paths_up_to_length' [] (target (p_source q []) []) (λq'. case set_as_map (FSM.transitions M) q' of None ⇒ {} | Some xs ⇒ xs) {q} k = {[] @ p |p. path M (p_source q []) ([] @ p) ∧ length p ≤ k ∧ distinct (visited_states (p_source q []) ([] @ p))}›*) using True (*‹q ∈ FSM.states M›*) by auto qed lemma path_map_target : "target (f4 q) (map (λ t . (f1 (t_source t), f2 (t_input t), f3 (t_output t), f4 (t_target t))) p) = f4 (target q p)" apply ((induction p)[1]) (*goals: 1. ‹target (f4 q) (map (λt. (f1 (t_source t), f2 (t_input t), f3 (t_output t), f4 (t_target t))) []) = f4 (target q [])› 2. ‹⋀a p. target (f4 q) (map (λt. (f1 (t_source t), f2 (t_input t), f3 (t_output t), f4 (t_target t))) p) = f4 (target q p) ⟹ target (f4 q) (map (λt. (f1 (t_source t), f2 (t_input t), f3 (t_output t), f4 (t_target t))) (a # p)) = f4 (target q (a # p))› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . lemma path_length_sum : assumes "path M q p" shows "length p = (∑ q ∈ states M . length (filter (λt. t_target t = q) p))" using assms (*‹path (M::('a, 'b, 'c) fsm) (q::'a) (p::('a × 'b × 'c × 'a) list)›*) proof (induction p rule: rev_induct (*‹⟦?P []; ⋀x xs. ?P xs ⟹ ?P (xs @ [x])⟧ ⟹ ?P ?xs›*)) (*goals: 1. ‹path M q [] ⟹ length [] = (∑q∈FSM.states M. length (filter (λt. t_target t = q) []))› 2. ‹⋀x xs. ⟦path M q xs ⟹ length xs = (∑q∈FSM.states M. length (filter (λt. t_target t = q) xs)); path M q (xs @ [x])⟧ ⟹ length (xs @ [x]) = (∑q∈FSM.states M. length (filter (λt. t_target t = q) (xs @ [x])))›*) case Nil (*‹path M q []›*) then show "?case" (*goal: ‹length [] = (∑q∈FSM.states M. length (filter (λt. t_target t = q) []))›*) by auto next (*goal: ‹⋀x xs. ⟦path M q xs ⟹ length xs = (∑q∈FSM.states M. length (filter (λt. t_target t = q) xs)); path M q (xs @ [x])⟧ ⟹ length (xs @ [x]) = (∑q∈FSM.states M. length (filter (λt. t_target t = q) (xs @ [x])))›*) case (snoc x xs) (*‹path M q xs ⟹ length xs = (∑q∈FSM.states M. length (filter (λt. t_target t = q) xs))› ‹path (M::('a, 'b, 'c) fsm) (q::'a) ((xs::('a × 'b × 'c × 'a) list) @ [x::'a × 'b × 'c × 'a])›*) then have "length xs = (∑q∈states M. length (filter (λt. t_target t = q) xs))" by auto have "*": "t_target x ∈ states M" using ‹path M q (xs @ [x])› (*‹path M q (xs @ [x])›*) by auto then have "**": "length (filter (λt. t_target t = t_target x) (xs @ [x])) = Suc (length (filter (λt. t_target t = t_target x) xs))" by auto have "⋀ q . q ∈ states M ⟹ q ≠ t_target x ⟹ length (filter (λt. t_target t = q) (xs @ [x])) = length (filter (λt. t_target t = q) xs)" by simp then have "***": "(∑q∈states M - {t_target x}. length (filter (λt. t_target t = q) (xs @ [x]))) = (∑q∈states M - {t_target x}. length (filter (λt. t_target t = q) xs))" using fsm_states_finite[of M] (*‹finite (FSM.states (M::('a, 'b, 'c) fsm))›*) by (metis (no_types, lifting) DiffE (*‹⟦?c ∈ ?A - ?B; ⟦?c ∈ ?A; ?c ∉ ?B⟧ ⟹ ?P⟧ ⟹ ?P›*) insertCI (*‹(?a ∉ ?B ⟹ ?a = ?b) ⟹ ?a ∈ insert ?b ?B›*) sum.cong (*‹⟦?A = ?B; ⋀x. x ∈ ?B ⟹ ?g x = ?h x⟧ ⟹ sum ?g ?A = sum ?h ?B›*)) have "(∑q∈states M. length (filter (λt. t_target t = q) (xs @ [x]))) = (∑q∈states M - {t_target x}. length (filter (λt. t_target t = q) (xs @ [x]))) + (length (filter (λt. t_target t = t_target x) (xs @ [x])))" using "*" (*‹t_target (x::'a::type × 'b::type × 'c::type × 'a::type) ∈ FSM.states (M::('a::type, 'b::type, 'c::type) fsm)›*) fsm_states_finite[of M] (*‹finite (FSM.states M)›*) proof (-) (*goal: ‹⟦t_target x ∈ FSM.states M; finite (FSM.states M)⟧ ⟹ (∑q∈FSM.states M. length (filter (λt. t_target t = q) (xs @ [x]))) = (∑q∈FSM.states M - {t_target x}. length (filter (λt. t_target t = q) (xs @ [x]))) + length (filter (λt. t_target t = t_target x) (xs @ [x]))›*) have "(∑a∈insert (t_target x) (states M). length (filter (λp. t_target p = a) (xs @ [x]))) = (∑a∈states M. length (filter (λp. t_target p = a) (xs @ [x])))" by (simp add: ‹t_target x ∈ states M› insert_absorb (*‹?a ∈ ?A ⟹ insert ?a ?A = ?A›*)) then show "?thesis" (*goal: ‹(∑q∈FSM.states M. length (filter (λt. t_target t = q) (xs @ [x]))) = (∑q∈FSM.states M - {t_target x}. length (filter (λt. t_target t = q) (xs @ [x]))) + length (filter (λt. t_target t = t_target x) (xs @ [x]))›*) by (simp add: ‹finite (states M)› sum.insert_remove (*‹finite ?A ⟹ sum ?g (insert ?x ?A) = ?g ?x + sum ?g (?A - {?x})›*)) qed moreover have "(∑q∈states M. length (filter (λt. t_target t = q) xs)) = (∑q∈states M - {t_target x}. length (filter (λt. t_target t = q) xs)) + (length (filter (λt. t_target t = t_target x) xs))" using "*" (*‹t_target (x::'a × 'b × 'c × 'a) ∈ FSM.states (M::('a, 'b, 'c) fsm)›*) fsm_states_finite[of M] (*‹finite (FSM.states M)›*) proof (-) (*goal: ‹⟦t_target x ∈ FSM.states M; finite (FSM.states M)⟧ ⟹ (∑q∈FSM.states M. length (filter (λt. t_target t = q) xs)) = (∑q∈FSM.states M - {t_target x}. length (filter (λt. t_target t = q) xs)) + length (filter (λt. t_target t = t_target x) xs)›*) have "(∑a∈insert (t_target x) (states M). length (filter (λp. t_target p = a) xs)) = (∑a∈states M. length (filter (λp. t_target p = a) xs))" by (simp add: ‹t_target x ∈ states M› insert_absorb (*‹?a ∈ ?A ⟹ insert ?a ?A = ?A›*)) then show "?thesis" (*goal: ‹(∑q∈FSM.states M. length (filter (λt. t_target t = q) xs)) = (∑q∈FSM.states M - {t_target x}. length (filter (λt. t_target t = q) xs)) + length (filter (λt. t_target t = t_target x) xs)›*) by (simp add: ‹finite (states M)› sum.insert_remove (*‹finite ?A ⟹ sum ?g (insert ?x ?A) = ?g ?x + sum ?g (?A - {?x})›*)) qed ultimately have "(∑q∈states M. length (filter (λt. t_target t = q) (xs @ [x]))) = Suc (∑q∈states M. length (filter (λt. t_target t = q) xs))" using "**" (*‹length (filter (λt::'a::type × 'b::type × 'c::type × 'a::type. t_target t = t_target (x::'a::type × 'b::type × 'c::type × 'a::type)) ((xs::('a::type × 'b::type × 'c::type × 'a::type) list) @ [x])) = Suc (length (filter (λt::'a::type × 'b::type × 'c::type × 'a::type. t_target t = t_target x) xs))›*) "***" (*‹(∑q∈FSM.states M - {t_target x}. length (filter (λt. t_target t = q) (xs @ [x]))) = (∑q∈FSM.states M - {t_target x}. length (filter (λt. t_target t = q) xs))›*) by auto then show "?case" (*goal: ‹length (xs @ [x]) = (∑q∈FSM.states M. length (filter (λt. t_target t = q) (xs @ [x])))›*) by (simp add: ‹length xs = (∑q∈states M. length (filter (λt. t_target t = q) xs))›) qed lemma path_loop_cut : assumes "path M q p" and "t_target (p ! i) = t_target (p ! j)" and "i < j" and "j < length p" shows "path M q ((take (Suc i) p) @ (drop (Suc j) p))" and "target q ((take (Suc i) p) @ (drop (Suc j) p)) = target q p" and "length ((take (Suc i) p) @ (drop (Suc j) p)) < length p" and "path M (target q (take (Suc i) p)) (drop (Suc i) (take (Suc j) p))" and "target (target q (take (Suc i) p)) (drop (Suc i) (take (Suc j) p)) = (target q (take (Suc i) p))" proof (-) (*goals: 1. ‹path M q (take (Suc i) p @ drop (Suc j) p)› 2. ‹target q (take (Suc i) p @ drop (Suc j) p) = target q p› 3. ‹length (take (Suc i) p @ drop (Suc j) p) < length p› 4. ‹path M (target q (take (Suc i) p)) (drop (Suc i) (take (Suc j) p))› 5. ‹target (target q (take (Suc i) p)) (drop (Suc i) (take (Suc j) p)) = target q (take (Suc i) p)›*) have "p = (take (Suc j) p) @ (drop (Suc j) p)" by auto also (*calculation: ‹p = take (Suc j) p @ drop (Suc j) p›*) have "… = ((take (Suc i) (take (Suc j) p)) @ (drop (Suc i) (take (Suc j) p))) @ (drop (Suc j) p)" by (metis append_take_drop_id (*‹take ?n ?xs @ drop ?n ?xs = ?xs›*)) also (*calculation: ‹p = (take (Suc i) (take (Suc j) p) @ drop (Suc i) (take (Suc j) p)) @ drop (Suc j) p›*) have "… = ((take (Suc i) p) @ (drop (Suc i) (take (Suc j) p))) @ (drop (Suc j) p)" using ‹i < j› (*‹(i::nat) < (j::nat)›*) by simp finally (*calculation: ‹p = (take (Suc i) p @ drop (Suc i) (take (Suc j) p)) @ drop (Suc j) p›*) have "p = (take (Suc i) p) @ (drop (Suc i) (take (Suc j) p)) @ (drop (Suc j) p)" by simp then have "path M q ((take (Suc i) p) @ (drop (Suc i) (take (Suc j) p)) @ (drop (Suc j) p))" and "path M q (((take (Suc i) p) @ (drop (Suc i) (take (Suc j) p))) @ (drop (Suc j) p))" using ‹path M q p› (*‹path M q p›*) apply - (*goals: 1. ‹⟦p = take (Suc i) p @ drop (Suc i) (take (Suc j) p) @ drop (Suc j) p; path M q p⟧ ⟹ path M q (take (Suc i) p @ drop (Suc i) (take (Suc j) p) @ drop (Suc j) p)› 2. ‹⟦p = take (Suc i) p @ drop (Suc i) (take (Suc j) p) @ drop (Suc j) p; path M q p⟧ ⟹ path M q ((take (Suc i) p @ drop (Suc i) (take (Suc j) p)) @ drop (Suc j) p)› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . have "path M q (take (Suc i) p)" and "path M (target q (take (Suc i) p)) (drop (Suc i) (take (Suc j) p) @ drop (Suc j) p)" using path_append_elim[OF ‹path M q ((take (Suc i) p) @ (drop (Suc i) (take (Suc j) p)) @ (drop (Suc j) p))›] (*‹(⟦path M q (take (Suc i) p); path M (target q (take (Suc i) p)) (drop (Suc i) (take (Suc j) p) @ drop (Suc j) p)⟧ ⟹ ?thesis) ⟹ ?thesis›*) apply - (*goals: 1. ‹(⋀thesis. (⟦path M q (take (Suc i) p); path M (target q (take (Suc i) p)) (drop (Suc i) (take (Suc j) p) @ drop (Suc j) p)⟧ ⟹ thesis) ⟹ thesis) ⟹ path M q (take (Suc i) p)› 2. ‹(⋀thesis. (⟦path M q (take (Suc i) p); path M (target q (take (Suc i) p)) (drop (Suc i) (take (Suc j) p) @ drop (Suc j) p)⟧ ⟹ thesis) ⟹ thesis) ⟹ path M (target q (take (Suc i) p)) (drop (Suc i) (take (Suc j) p) @ drop (Suc j) p)› discuss goal 1*) apply blast (*discuss goal 2*) apply blast (*proven 2 subgoals*) . have "*": "(take (Suc i) p @ drop (Suc i) (take (Suc j) p)) = (take (Suc j) p)" using ‹i < j› (*‹i < j›*) append_take_drop_id (*‹take ?n ?xs @ drop ?n ?xs = ?xs›*) by (metis ‹(take (Suc i) (take (Suc j) p) @ drop (Suc i) (take (Suc j) p)) @ drop (Suc j) p = (take (Suc i) p @ drop (Suc i) (take (Suc j) p)) @ drop (Suc j) p› append_same_eq (*‹(?ys @ ?xs = ?zs @ ?xs) = (?ys = ?zs)›*)) have "path M q (take (Suc j) p)" and "path M (target q (take (Suc j) p)) (drop (Suc j) p)" using path_append_elim[OF ‹path M q (((take (Suc i) p) @ (drop (Suc i) (take (Suc j) p))) @ (drop (Suc j) p))›] (*‹(⟦path M q (take (Suc i) p @ drop (Suc i) (take (Suc j) p)); path M (target q (take (Suc i) p @ drop (Suc i) (take (Suc j) p))) (drop (Suc j) p)⟧ ⟹ ?thesis) ⟹ ?thesis›*) unfolding "*" (*goals: 1. ‹path M q (take (Suc j) p)› 2. ‹path M (target q (take (Suc j) p)) (drop (Suc j) p)›*) apply - (*goals: 1. ‹(⋀thesis. (⟦path M q (take (Suc j) p); path M (target q (take (Suc j) p)) (drop (Suc j) p)⟧ ⟹ thesis) ⟹ thesis) ⟹ path M q (take (Suc j) p)› 2. ‹(⋀thesis. (⟦path M q (take (Suc j) p); path M (target q (take (Suc j) p)) (drop (Suc j) p)⟧ ⟹ thesis) ⟹ thesis) ⟹ path M (target q (take (Suc j) p)) (drop (Suc j) p)› discuss goal 1*) apply blast (*discuss goal 2*) apply blast (*proven 2 subgoals*) . have "**": "(target q (take (Suc j) p)) = (target q (take (Suc i) p))" proof (-) (*goal: ‹target (q::'a::type) (take (Suc (j::nat)) (p::('a::type × 'b::type × 'c::type × 'a::type) list)) = target q (take (Suc (i::nat)) p)›*) have "p ! i = last (take (Suc i) p)" by (metis Suc_lessD (*‹Suc ?m < ?n ⟹ ?m < ?n›*) assms( (*‹i < j›*) 3) assms( (*‹j < length p›*) 4) less_trans_Suc (*‹⟦?i < ?j; ?j < ?k⟧ ⟹ Suc ?i < ?k›*) take_last_index (*‹?i < length ?xs ⟹ last (take (Suc ?i) ?xs) = ?xs ! ?i›*)) moreover have "p ! j = last (take (Suc j) p)" by (simp add: assms( (*‹j < length p›*) 4) take_last_index (*‹?i < length ?xs ⟹ last (take (Suc ?i) ?xs) = ?xs ! ?i›*)) ultimately show "?thesis" (*goal: ‹target (q::'a) (take (Suc (j::nat)) (p::('a × 'b × 'c × 'a) list)) = target q (take (Suc (i::nat)) p)›*) using assms(2) (*‹t_target (p ! i) = t_target (p ! j)›*) unfolding "*" target.simps visited_states.simps (*goal: ‹last (q # map t_target (take (Suc j) p)) = last (q # map t_target (take (Suc i) p))›*) by (simp add: last_map (*‹?xs ≠ [] ⟹ last (map ?f ?xs) = ?f (last ?xs)›*)) qed show "path M q ((take (Suc i) p) @ (drop (Suc j) p))" using ‹path M q (take (Suc i) p)› (*‹path M q (take (Suc i) p)›*) ‹path M (target q (take (Suc j) p)) (drop (Suc j) p)› (*‹path (M::('a::type, 'b::type, 'c::type) fsm) (target (q::'a::type) (take (Suc (j::nat)) (p::('a::type × 'b::type × 'c::type × 'a::type) list))) (drop (Suc j) p)›*) unfolding "**" (*goal: ‹path M q (take (Suc i) p @ drop (Suc j) p)›*) by auto show "target q ((take (Suc i) p) @ (drop (Suc j) p)) = target q p" by (metis "**" (*‹target (q::'a::type) (take (Suc (j::nat)) (p::('a::type × 'b::type × 'c::type × 'a::type) list)) = target q (take (Suc (i::nat)) p)›*) append_take_drop_id (*‹take (?n::nat) (?xs::?'a::type list) @ drop ?n ?xs = ?xs›*) path_append_target (*‹target (?q::?'a::type) ((?p1.0::(?'a::type × ?'b::type × ?'c::type × ?'a::type) list) @ (?p2.0::(?'a::type × ?'b::type × ?'c::type × ?'a::type) list)) = target (target ?q ?p1.0) ?p2.0›*)) show "length ((take (Suc i) p) @ (drop (Suc j) p)) < length p" proof (-) (*goal: ‹length (take (Suc i) p @ drop (Suc j) p) < length p›*) have "***": "length p = length ((take (Suc j) p) @ (drop (Suc j) p))" by auto have "length (take (Suc i) p) < length (take (Suc j) p)" using assms(3,4) (*‹i < j› ‹j < length p›*) by (simp add: min_absorb2 (*‹?y ≤ ?x ⟹ min ?x ?y = ?y›*)) have scheme: "⋀ a b c . length a < length b ⟹ length (a@c) < length (b@c)" by auto show "?thesis" (*goal: ‹length (take (Suc i) p @ drop (Suc j) p) < length p›*) unfolding "***" (*goal: ‹length (take (Suc i) p @ drop (Suc j) p) < length (take (Suc j) p @ drop (Suc j) p)›*) using scheme[OF ‹length (take (Suc i) p) < length (take (Suc j) p)›, of "(drop (Suc j) p)"] (*‹length (take (Suc i) p @ drop (Suc j) p) < length (take (Suc j) p @ drop (Suc j) p)›*) by assumption qed show "path M (target q (take (Suc i) p)) (drop (Suc i) (take (Suc j) p))" using ‹path M (target q (take (Suc i) p)) (drop (Suc i) (take (Suc j) p) @ drop (Suc j) p)› (*‹path M (target q (take (Suc i) p)) (drop (Suc i) (take (Suc j) p) @ drop (Suc j) p)›*) by blast show "target (target q (take (Suc i) p)) (drop (Suc i) (take (Suc j) p)) = (target q (take (Suc i) p))" by (metis "*" (*‹take (Suc i) p @ drop (Suc i) (take (Suc j) p) = take (Suc j) p›*) "**" (*‹target q (take (Suc j) p) = target q (take (Suc i) p)›*) path_append_target (*‹target ?q (?p1.0 @ ?p2.0) = target (target ?q ?p1.0) ?p2.0›*)) qed lemma path_prefix_take : assumes "path M q p" shows "path M q (take i p)" proof (-) (*goal: ‹path M q (take i p)›*) have "p = (take i p)@(drop i p)" by auto then have "path M q ((take i p)@(drop i p))" using assms (*‹path M q p›*) by auto then show "?thesis" (*goal: ‹path M q (take i p)›*) by blast qed subsection ‹Acyclic Paths› lemma cyclic_path_loop : assumes "path M q p" and "¬ distinct (visited_states q p)" shows "∃ p1 p2 p3 . p = p1@p2@p3 ∧ p2 ≠ [] ∧ target q p1 = target q (p1@p2)" using assms (*‹path (M::('a::type, 'b::type, 'c::type) fsm) (q::'a::type) (p::('a::type × 'b::type × 'c::type × 'a::type) list)› ‹¬ distinct (visited_states q p)›*) proof (induction p arbitrary: q) (*goals: 1. ‹⋀q M qa. ⟦q ∈ FSM.states M; ¬ distinct (visited_states qa [])⟧ ⟹ ∃p1 p2 p3. [] = p1 @ p2 @ p3 ∧ p2 ≠ [] ∧ target qa p1 = target qa (p1 @ p2)› 2. ‹⋀t M ts q. ⟦t ∈ FSM.transitions M; path M (t_target t) ts; ⋀q. ¬ distinct (visited_states q ts) ⟹ ∃p1 p2 p3. ts = p1 @ p2 @ p3 ∧ p2 ≠ [] ∧ target q p1 = target q (p1 @ p2); ¬ distinct (visited_states q (t # ts))⟧ ⟹ ∃p1 p2 p3. t # ts = p1 @ p2 @ p3 ∧ p2 ≠ [] ∧ target q p1 = target q (p1 @ p2)›*) case (nil M q) (*‹M ∈ FSM.states qa__› ‹¬ distinct (visited_states q [])›*) then show "?case" (*goal: ‹∃p1 p2 p3. [] = p1 @ p2 @ p3 ∧ p2 ≠ [] ∧ target q p1 = target q (p1 @ p2)›*) by auto next (*goal: ‹⋀t M ts q. ⟦t ∈ FSM.transitions M; path M (t_target t) ts; ⋀q. ¬ distinct (visited_states q ts) ⟹ ∃p1 p2 p3. ts = p1 @ p2 @ p3 ∧ p2 ≠ [] ∧ target q p1 = target q (p1 @ p2); ¬ distinct (visited_states q (t # ts))⟧ ⟹ ∃p1 p2 p3. t # ts = p1 @ p2 @ p3 ∧ p2 ≠ [] ∧ target q p1 = target q (p1 @ p2)›*) case (cons t M ts) (*‹t ∈ FSM.transitions M› ‹path M (t_target t) ts› ‹¬ distinct (visited_states ?q ts) ⟹ ∃p1 p2 p3. ts = p1 @ p2 @ p3 ∧ p2 ≠ [] ∧ target ?q p1 = target ?q (p1 @ p2)› ‹¬ distinct (visited_states q (t # ts))›*) then show "?case" (*goal: ‹∃p1 p2 p3. t # ts = p1 @ p2 @ p3 ∧ p2 ≠ [] ∧ target q p1 = target q (p1 @ p2)›*) proof (cases "distinct (visited_states (t_target t) ts)") (*goals: 1. ‹⟦t ∈ FSM.transitions M; path M (t_target t) ts; ⋀q. ¬ distinct (visited_states q ts) ⟹ ∃p1 p2 p3. ts = p1 @ p2 @ p3 ∧ p2 ≠ [] ∧ target q p1 = target q (p1 @ p2); ¬ distinct (visited_states q (t # ts)); distinct (visited_states (t_target t) ts)⟧ ⟹ ∃p1 p2 p3. t # ts = p1 @ p2 @ p3 ∧ p2 ≠ [] ∧ target q p1 = target q (p1 @ p2)› 2. ‹⟦t ∈ FSM.transitions M; path M (t_target t) ts; ⋀q. ¬ distinct (visited_states q ts) ⟹ ∃p1 p2 p3. ts = p1 @ p2 @ p3 ∧ p2 ≠ [] ∧ target q p1 = target q (p1 @ p2); ¬ distinct (visited_states q (t # ts)); ¬ distinct (visited_states (t_target t) ts)⟧ ⟹ ∃p1 p2 p3. t # ts = p1 @ p2 @ p3 ∧ p2 ≠ [] ∧ target q p1 = target q (p1 @ p2)›*) case True (*‹distinct (visited_states (t_target t) ts)›*) then have "q ∈ set (visited_states (t_target t) ts)" using cons.prems (*‹¬ distinct (visited_states q (t # ts))›*) by simp then obtain p2 and p3 where "ts = p2@p3" and "target (t_target t) p2 = q" (*goal: ‹(⋀p2 p3. ⟦ts = p2 @ p3; target (t_target t) p2 = q⟧ ⟹ thesis) ⟹ thesis›*) using visited_states_prefix[of q "t_target t" ts] (*‹q ∈ set (visited_states (t_target t) ts) ⟹ ∃p1 p2. ts = p1 @ p2 ∧ target (t_target t) p1 = q›*) by blast then have "(t#ts) = []@(t#p2)@p3 ∧ (t#p2) ≠ [] ∧ target q [] = target q ([]@(t#p2))" using cons.hyps (*‹t ∈ FSM.transitions M› ‹path M (t_target t) ts›*) by auto then show "?thesis" (*goal: ‹∃p1 p2 p3. t # ts = p1 @ p2 @ p3 ∧ p2 ≠ [] ∧ target q p1 = target q (p1 @ p2)›*) by blast next (*goal: ‹⟦t ∈ FSM.transitions M; path M (t_target t) ts; ⋀q. ¬ distinct (visited_states q ts) ⟹ ∃p1 p2 p3. ts = p1 @ p2 @ p3 ∧ p2 ≠ [] ∧ target q p1 = target q (p1 @ p2); ¬ distinct (visited_states q (t # ts)); ¬ distinct (visited_states (t_target t) ts)⟧ ⟹ ∃p1 p2 p3. t # ts = p1 @ p2 @ p3 ∧ p2 ≠ [] ∧ target q p1 = target q (p1 @ p2)›*) case False (*‹¬ distinct (visited_states (t_target t) ts)›*) then obtain p1 and p2 and p3 where "ts = p1@p2@p3" and "p2 ≠ []" and "target (t_target t) p1 = target (t_target t) (p1@p2)" (*goal: ‹(⋀p1 p2 p3. ⟦ts = p1 @ p2 @ p3; p2 ≠ []; target (t_target t) p1 = target (t_target t) (p1 @ p2)⟧ ⟹ thesis) ⟹ thesis›*) using cons.IH (*‹¬ distinct (visited_states ?q ts) ⟹ ∃p1 p2 p3. ts = p1 @ p2 @ p3 ∧ p2 ≠ [] ∧ target ?q p1 = target ?q (p1 @ p2)›*) by blast then have "t#ts = (t#p1)@p2@p3 ∧ p2 ≠ [] ∧ target q (t#p1) = target q ((t#p1)@p2)" by simp then show "?thesis" (*goal: ‹∃p1 p2 p3. t # ts = p1 @ p2 @ p3 ∧ p2 ≠ [] ∧ target q p1 = target q (p1 @ p2)›*) by blast qed qed lemma cyclic_path_pumping : assumes "path M (initial M) p" and "¬ distinct (visited_states (initial M) p)" shows "∃ p . path M (initial M) p ∧ length p ≥ n" proof (-) (*goal: ‹∃p. path M (FSM.initial M) p ∧ n ≤ length p›*) from assms (*‹path M (FSM.initial M) p› ‹¬ distinct (visited_states (FSM.initial M) p)›*) obtain p1 and p2 and p3 where "p = p1 @ p2 @ p3" and "p2 ≠ []" and "target (initial M) p1 = target (initial M) (p1 @ p2)" (*goal: ‹(⋀(p1::('a × 'b × 'c × 'a) list) (p2::('a × 'b × 'c × 'a) list) p3::('a × 'b × 'c × 'a) list. ⟦(p::('a × 'b × 'c × 'a) list) = p1 @ p2 @ p3; p2 ≠ []; target (FSM.initial (M::('a, 'b, 'c) fsm)) p1 = target (FSM.initial M) (p1 @ p2)⟧ ⟹ thesis::bool) ⟹ thesis›*) using cyclic_path_loop[of M "initial M" p] (*‹⟦path M (FSM.initial M) p; ¬ distinct (visited_states (FSM.initial M) p)⟧ ⟹ ∃p1 p2 p3. p = p1 @ p2 @ p3 ∧ p2 ≠ [] ∧ target (FSM.initial M) p1 = target (FSM.initial M) (p1 @ p2)›*) by blast then have "path M (target (initial M) p1) p3" using path_suffix[of M "initial M" "p1@p2" p3] (*‹path M (FSM.initial M) ((p1 @ p2) @ p3) ⟹ path M (target (FSM.initial M) (p1 @ p2)) p3›*) ‹path M (initial M) p› (*‹path M (FSM.initial M) p›*) by auto have "path M (initial M) p1" using path_prefix[of M "initial M" p1 "p2@p3"] (*‹path M (FSM.initial M) (p1 @ p2 @ p3) ⟹ path M (FSM.initial M) p1›*) ‹path M (initial M) p› (*‹path M (FSM.initial M) p›*) ‹p = p1 @ p2 @ p3› (*‹(p::('a × 'b × 'c × 'a) list) = (p1::('a × 'b × 'c × 'a) list) @ (p2::('a × 'b × 'c × 'a) list) @ (p3::('a × 'b × 'c × 'a) list)›*) by auto have "path M (initial M) ((p1@p2)@p3)" using ‹path M (initial M) p› (*‹path M (FSM.initial M) p›*) ‹p = p1 @ p2 @ p3› (*‹p = p1 @ p2 @ p3›*) by auto have "path M (target (initial M) p1) p2" using path_suffix[of M "initial M" p1 p2, OF path_prefix [ of M "initial M" "p1@p2" p3 , OF ‹path M (initial M) ((p1@p2)@p3)› ]] (*‹path M (target (FSM.initial M) p1) p2›*) by assumption have "target (target (initial M) p1) p2 = (target (initial M) p1)" using path_append_target (*‹target ?q (?p1.0 @ ?p2.0) = target (target ?q ?p1.0) ?p2.0›*) ‹target (initial M) p1 = target (initial M) (p1 @ p2)› (*‹target (FSM.initial M) p1 = target (FSM.initial M) (p1 @ p2)›*) by auto have "path M (initial M) (p1 @ (concat (replicate n p2)) @ p3)" proof (induction n) (*goals: 1. ‹path M (FSM.initial M) (p1 @ concat (replicate 0 p2) @ p3)› 2. ‹⋀n. path M (FSM.initial M) (p1 @ concat (replicate n p2) @ p3) ⟹ path M (FSM.initial M) (p1 @ concat (replicate (Suc n) p2) @ p3)›*) case 0 (*no hyothesis introduced yet*) then show "?case" (*goal: ‹path M (FSM.initial M) (p1 @ concat (replicate 0 p2) @ p3)›*) using path_append[OF ‹path M (initial M) p1› ‹path M (target (initial M) p1) p3›] (*‹path M (FSM.initial M) (p1 @ p3)›*) by auto next (*goal: ‹⋀n. path M (FSM.initial M) (p1 @ concat (replicate n p2) @ p3) ⟹ path M (FSM.initial M) (p1 @ concat (replicate (Suc n) p2) @ p3)›*) case (Suc n) (*‹path M (FSM.initial M) (p1 @ concat (replicate n p2) @ p3)›*) then show "?case" (*goal: ‹path M (FSM.initial M) (p1 @ concat (replicate (Suc n) p2) @ p3)›*) using ‹path M (target (initial M) p1) p2› (*‹path M (target (FSM.initial M) p1) p2›*) ‹target (target (initial M) p1) p2 = target (initial M) p1› (*‹target (target (FSM.initial M) p1) p2 = target (FSM.initial M) p1›*) by auto qed moreover have "length (p1 @ (concat (replicate n p2)) @ p3) ≥ n" proof (-) (*goal: ‹n ≤ length (p1 @ concat (replicate n p2) @ p3)›*) have "length (concat (replicate n p2)) = n * (length p2)" using concat_replicate_length (*‹length (concat (replicate ?n ?xs)) = ?n * length ?xs›*) by metis moreover have "length p2 > 0" using ‹p2 ≠ []› (*‹p2 ≠ []›*) by auto ultimately have "length (concat (replicate n p2)) ≥ n" by (simp add: Suc_leI (*‹(?m::nat) < (?n::nat) ⟹ Suc ?m ≤ ?n›*)) then show "?thesis" (*goal: ‹n ≤ length (p1 @ concat (replicate n p2) @ p3)›*) by auto qed ultimately show "∃ p . path M (initial M) p ∧ length p ≥ n" by blast qed lemma cyclic_path_shortening : assumes "path M q p" and "¬ distinct (visited_states q p)" shows "∃ p' . path M q p' ∧ target q p' = target q p ∧ length p' < length p" proof (-) (*goal: ‹∃p'. path M q p' ∧ target q p' = target q p ∧ length p' < length p›*) obtain p1 and p2 and p3 where "*": "p = p1@p2@p3 ∧ p2 ≠ [] ∧ target q p1 = target q (p1@p2)" (*goal: ‹(⋀p1 p2 p3. p = p1 @ p2 @ p3 ∧ p2 ≠ [] ∧ target q p1 = target q (p1 @ p2) ⟹ thesis) ⟹ thesis›*) using cyclic_path_loop[OF assms] (*‹∃p1 p2 p3. p = p1 @ p2 @ p3 ∧ p2 ≠ [] ∧ target q p1 = target q (p1 @ p2)›*) by blast then have "path M q (p1@p3)" using assms(1) (*‹path M q p›*) by force moreover have "target q (p1@p3) = target q p" by (metis (full_types) * (*‹p = p1 @ p2 @ p3 ∧ p2 ≠ [] ∧ target q p1 = target q (p1 @ p2)›*) path_append_target (*‹target ?q (?p1.0 @ ?p2.0) = target (target ?q ?p1.0) ?p2.0›*)) moreover have "length (p1@p3) < length p" using "*" (*‹p = p1 @ p2 @ p3 ∧ p2 ≠ [] ∧ target q p1 = target q (p1 @ p2)›*) by auto ultimately show "?thesis" (*goal: ‹∃p'::('a × 'b × 'c × 'a) list. path (M::('a, 'b, 'c) fsm) (q::'a) p' ∧ target q p' = target q (p::('a × 'b × 'c × 'a) list) ∧ length p' < length p›*) by blast qed lemma acyclic_path_from_cyclic_path : assumes "path M q p" and "¬ distinct (visited_states q p)" obtains p' where "path M q p'" and "target q p = target q p'" and "distinct (visited_states q p')" proof (-) (*goal: ‹(⋀p'. ⟦path M q p'; target q p = target q p'; distinct (visited_states q p')⟧ ⟹ thesis) ⟹ thesis›*) let ?paths = "{p' . (path M q p' ∧ target q p' = target q p ∧ length p' ≤ length p)}" let ?minPath = "arg_min length (λ io . io ∈ ?paths)" have "?paths ≠ empty" using assms(1) (*‹path (M::('a::type, 'b::type, 'c::type) fsm) (q::'a::type) (p::('a::type × 'b::type × 'c::type × 'a::type) list)›*) by auto moreover have "finite ?paths" using paths_finite[of M q "length p"] (*‹finite {pa. path M q pa ∧ length pa ≤ length p}›*) by (metis (no_types, lifting) Collect_mono (*‹(⋀x. ?P x ⟶ ?Q x) ⟹ Collect ?P ⊆ Collect ?Q›*) rev_finite_subset (*‹⟦finite ?B; ?A ⊆ ?B⟧ ⟹ finite ?A›*)) ultimately have minPath_def: "?minPath ∈ ?paths ∧ (∀ p' ∈ ?paths . length ?minPath ≤ length p')" by (meson arg_min_nat_lemma (*‹?P ?k ⟹ ?P (arg_min ?m ?P) ∧ (∀y. ?P y ⟶ ?m (arg_min ?m ?P) ≤ ?m y)›*) equals0I (*‹(⋀y. y ∈ ?A ⟹ False) ⟹ ?A = {}›*)) then have "path M q ?minPath" and "target q ?minPath = target q p" apply - (*goals: 1. ‹(ARG_MIN length io. io ∈ {p'. path M q p' ∧ target q p' = target q p ∧ length p' ≤ length p}) ∈ {p'. path M q p' ∧ target q p' = target q p ∧ length p' ≤ length p} ∧ (∀p'∈{p'. path M q p' ∧ target q p' = target q p ∧ length p' ≤ length p}. length (ARG_MIN length io. io ∈ {p'. path M q p' ∧ target q p' = target q p ∧ length p' ≤ length p}) ≤ length p') ⟹ path M q (ARG_MIN length io. io ∈ {p'. path M q p' ∧ target q p' = target q p ∧ length p' ≤ length p})› 2. ‹(ARG_MIN length io. io ∈ {p'. path M q p' ∧ target q p' = target q p ∧ length p' ≤ length p}) ∈ {p'. path M q p' ∧ target q p' = target q p ∧ length p' ≤ length p} ∧ (∀p'∈{p'. path M q p' ∧ target q p' = target q p ∧ length p' ≤ length p}. length (ARG_MIN length io. io ∈ {p'. path M q p' ∧ target q p' = target q p ∧ length p' ≤ length p}) ≤ length p') ⟹ target q (ARG_MIN length io. io ∈ {p'. path M q p' ∧ target q p' = target q p ∧ length p' ≤ length p}) = target q p› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . moreover have "distinct (visited_states q ?minPath)" proof (rule ccontr (*‹(¬ ?P ⟹ False) ⟹ ?P›*)) (*goal: ‹¬ distinct (visited_states q (ARG_MIN length io. io ∈ {p'. path M q p' ∧ target q p' = target q p ∧ length p' ≤ length p})) ⟹ False›*) assume "¬ distinct (visited_states q ?minPath)" (*‹¬ distinct (visited_states (q::'a) (ARG_MIN length io::('a × 'b × 'c × 'a) list. io ∈ {p'::('a × 'b × 'c × 'a) list. path (M::('a, 'b, 'c) fsm) q p' ∧ target q p' = target q (p::('a × 'b × 'c × 'a) list) ∧ length p' ≤ length p}))›*) have "∃ p' . path M q p' ∧ target q p' = target q p ∧ length p' < length ?minPath" using cyclic_path_shortening[OF ‹path M q ?minPath› ‹¬ distinct (visited_states q ?minPath)›] (*‹∃p'. path M q p' ∧ target q p' = target q (ARG_MIN length io. io ∈ {p'. path M q p' ∧ target q p' = target q p ∧ length p' ≤ length p}) ∧ length p' < length (ARG_MIN length io. io ∈ {p'. path M q p' ∧ target q p' = target q p ∧ length p' ≤ length p})›*) minPath_def (*‹(ARG_MIN length io. io ∈ {p'. path M q p' ∧ target q p' = target q p ∧ length p' ≤ length p}) ∈ {p'. path M q p' ∧ target q p' = target q p ∧ length p' ≤ length p} ∧ (∀p'∈{p'. path M q p' ∧ target q p' = target q p ∧ length p' ≤ length p}. length (ARG_MIN length io. io ∈ {p'. path M q p' ∧ target q p' = target q p ∧ length p' ≤ length p}) ≤ length p')›*) ‹target q ?minPath= target q p› (*‹target q (ARG_MIN length io. io ∈ {p'. path M q p' ∧ target q p' = target q p ∧ length p' ≤ length p}) = target q p›*) by auto then show False using minPath_def (*‹(ARG_MIN length io. io ∈ {p'. path M q p' ∧ target q p' = target q p ∧ length p' ≤ length p}) ∈ {p'. path M q p' ∧ target q p' = target q p ∧ length p' ≤ length p} ∧ (∀p'∈{p'. path M q p' ∧ target q p' = target q p ∧ length p' ≤ length p}. length (ARG_MIN length io. io ∈ {p'. path M q p' ∧ target q p' = target q p ∧ length p' ≤ length p}) ≤ length p')›*) using arg_min_nat_le (*‹(?P::?'a ⇒ bool) (?x::?'a) ⟹ (?m::?'a ⇒ nat) (arg_min ?m ?P) ≤ ?m ?x›*) dual_order.strict_trans1 (*‹⟦(?b::?'a::preorder) ≤ (?a::?'a::preorder); (?c::?'a::preorder) < ?b⟧ ⟹ ?c < ?a›*) by auto qed ultimately show "?thesis" (*goal: ‹thesis::bool›*) by (simp add: that (*‹⟦path M q ?p'; target q p = target q ?p'; distinct (visited_states q ?p')⟧ ⟹ thesis›*)) qed lemma acyclic_path_length_limit : assumes "path M q p" and "distinct (visited_states q p)" shows "length p < size M" proof (rule ccontr (*‹(¬ ?P ⟹ False) ⟹ ?P›*)) (*goal: ‹¬ length p < FSM.size M ⟹ False›*) assume "*": "¬ length p < size M" (*‹¬ length (p::('a × 'b × 'c × 'a) list) < FSM.size (M::('a, 'b, 'c) fsm)›*) then have "length p ≥ card (states M)" using size_def (*‹FSM.size ?m = card (FSM.states ?m)›*) by auto then have "length (visited_states q p) > card (states M)" by auto moreover have "set (visited_states q p) ⊆ states M" by (metis assms( (*‹path M q p›*) 1) path_prefix (*‹path ?M ?q (?p1.0 @ ?p2.0) ⟹ path ?M ?q ?p1.0›*) path_target_is_state (*‹path ?M ?q ?p ⟹ target ?q ?p ∈ FSM.states ?M›*) subsetI (*‹(⋀x. x ∈ ?A ⟹ x ∈ ?B) ⟹ ?A ⊆ ?B›*) visited_states_prefix (*‹?q' ∈ set (visited_states ?q ?p) ⟹ ∃p1 p2. ?p = p1 @ p2 ∧ target ?q p1 = ?q'›*)) ultimately have "¬ distinct (visited_states q p)" using distinct_card[OF assms ( 2 )] (*‹card (set (visited_states (q::'a) (p::('a × 'b × 'c × 'a) list))) = length (visited_states q p)›*) using List.finite_set[of "visited_states q p"] (*‹finite (set (visited_states q p))›*) by (metis card_mono (*‹⟦finite ?B; ?A ⊆ ?B⟧ ⟹ card ?A ≤ card ?B›*) fsm_states_finite (*‹finite (FSM.states ?M)›*) leD (*‹?y ≤ ?x ⟹ ¬ ?x < ?y›*)) then show False using assms(2) (*‹distinct (visited_states q p)›*) by blast qed subsection ‹Reachable States› definition reachable :: "('a,'b,'c) fsm ⇒ 'a ⇒ bool" where "reachable M q = (∃ p . path M (initial M) p ∧ target (initial M) p = q)" definition reachable_states :: "('a,'b,'c) fsm ⇒ 'a set" where "reachable_states M = {target (initial M) p | p . path M (initial M) p }" abbreviation "size_r M ≡ card (reachable_states M)" lemma acyclic_paths_set : "acyclic_paths_up_to_length M q (size M - 1) = {p . path M q p ∧ distinct (visited_states q p)}" unfolding acyclic_paths_up_to_length.simps (*goal: ‹{p. path M q p ∧ length p ≤ FSM.size M - 1 ∧ distinct (visited_states q p)} = {p. path M q p ∧ distinct (visited_states q p)}›*) using acyclic_path_length_limit[of M q] (*‹⟦path (M::('a::type, 'b::type, 'c::type) fsm) (q::'a::type) (?p::('a::type × 'b::type × 'c::type × 'a::type) list); distinct (visited_states q ?p)⟧ ⟹ length ?p < FSM.size M›*) by (metis (no_types, lifting) One_nat_def (*‹1 = Suc 0›*) Suc_pred (*‹0 < ?n ⟹ Suc (?n - Suc 0) = ?n›*) cyclic_path_shortening (*‹⟦path ?M ?q ?p; ¬ distinct (visited_states ?q ?p)⟧ ⟹ ∃p'. path ?M ?q p' ∧ target ?q p' = target ?q ?p ∧ length p' < length ?p›*) leD (*‹?y ≤ ?x ⟹ ¬ ?x < ?y›*) list.size( (*‹length [] = 0›*) 3) not_less_eq_eq (*‹(¬ ?m ≤ ?n) = (Suc ?n ≤ ?m)›*) not_less_zero (*‹¬ ?n < 0›*) path.intros( (*‹?q ∈ FSM.states ?M ⟹ path ?M ?q []›*) 1) path_begin_state (*‹path ?M ?q ?p ⟹ ?q ∈ FSM.states ?M›*)) (* inefficient calculation, as a state may be target of a large number of acyclic paths *) lemma reachable_states_code[code] : "reachable_states M = image (target (initial M)) (acyclic_paths_up_to_length M (initial M) (size M - 1))" proof (-) (*goal: ‹reachable_states M = target (FSM.initial M) ` acyclic_paths_up_to_length M (FSM.initial M) (FSM.size M - 1)›*) have "⋀ q' . q' ∈ reachable_states M ⟹ q' ∈ image (target (initial M)) (acyclic_paths_up_to_length M (initial M) (size M - 1))" proof (-) (*goal: ‹⋀q'. q' ∈ reachable_states M ⟹ q' ∈ target (FSM.initial M) ` acyclic_paths_up_to_length M (FSM.initial M) (FSM.size M - 1)›*) fix q' assume "q' ∈ reachable_states M" (*‹(q'::'a) ∈ reachable_states (M::('a, 'b, 'c) fsm)›*) then obtain p where "path M (initial M) p" and "target (initial M) p = q'" (*goal: ‹(⋀p. ⟦path M (FSM.initial M) p; target (FSM.initial M) p = q'⟧ ⟹ thesis) ⟹ thesis›*) unfolding reachable_states_def (*goal: ‹(⋀p. ⟦path M (FSM.initial M) p; target (FSM.initial M) p = q'⟧ ⟹ thesis) ⟹ thesis›*) by blast obtain p' where "path M (initial M) p'" and "target (initial M) p' = q'" and "distinct (visited_states (initial M) p')" (*goal: ‹(⋀p'. ⟦path M (FSM.initial M) p'; target (FSM.initial M) p' = q'; distinct (visited_states (FSM.initial M) p')⟧ ⟹ thesis) ⟹ thesis›*) proof (cases "distinct (visited_states (initial M) p)") (*goals: 1. ‹⟦⋀p'. ⟦path M (FSM.initial M) p'; target (FSM.initial M) p' = q'; distinct (visited_states (FSM.initial M) p')⟧ ⟹ thesis; distinct (visited_states (FSM.initial M) p)⟧ ⟹ thesis› 2. ‹⟦⋀p'. ⟦path M (FSM.initial M) p'; target (FSM.initial M) p' = q'; distinct (visited_states (FSM.initial M) p')⟧ ⟹ thesis; ¬ distinct (visited_states (FSM.initial M) p)⟧ ⟹ thesis›*) case True (*‹distinct (visited_states (FSM.initial M) p)›*) then show "?thesis" (*goal: ‹thesis›*) using ‹path M (initial M) p› (*‹path M (FSM.initial M) p›*) ‹target (initial M) p = q'› (*‹target (FSM.initial (M::('a, 'b, 'c) fsm)) (p::('a × 'b × 'c × 'a) list) = (q'::'a)›*) that (*‹⟦path M (FSM.initial M) ?p'; target (FSM.initial M) ?p' = q'; distinct (visited_states (FSM.initial M) ?p')⟧ ⟹ thesis›*) by auto next (*goal: ‹⟦⋀p'::('a::type × 'b::type × 'c::type × 'a::type) list. ⟦path (M::('a::type, 'b::type, 'c::type) fsm) (FSM.initial M) p'; target (FSM.initial M) p' = (q'::'a::type); distinct (visited_states (FSM.initial M) p')⟧ ⟹ thesis::bool; ¬ distinct (visited_states (FSM.initial M) (p::('a::type × 'b::type × 'c::type × 'a::type) list))⟧ ⟹ thesis›*) case False (*‹¬ distinct (visited_states (FSM.initial M) p)›*) then show "?thesis" (*goal: ‹thesis::bool›*) using acyclic_path_from_cyclic_path[OF ‹path M (initial M) p›] (*‹⟦¬ distinct (visited_states (FSM.initial M) p); ⋀p'. ⟦path M (FSM.initial M) p'; target (FSM.initial M) p = target (FSM.initial M) p'; distinct (visited_states (FSM.initial M) p')⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*) unfolding ‹target (initial M) p = q'› (*goal: ‹thesis›*) using that (*‹⟦path (M::('a, 'b, 'c) fsm) (FSM.initial M) (?p'::('a × 'b × 'c × 'a) list); target (FSM.initial M) ?p' = (q'::'a); distinct (visited_states (FSM.initial M) ?p')⟧ ⟹ thesis::bool›*) by blast qed then show "q' ∈ image (target (initial M)) (acyclic_paths_up_to_length M (initial M) (size M - 1))" unfolding acyclic_paths_set (*goal: ‹q' ∈ target (FSM.initial M) ` {p. path M (FSM.initial M) p ∧ distinct (visited_states (FSM.initial M) p)}›*) by force qed moreover have "⋀ q' . q' ∈ image (target (initial M)) (acyclic_paths_up_to_length M (initial M) (size M - 1)) ⟹ q' ∈ reachable_states M" unfolding reachable_states_def acyclic_paths_set (*goal: ‹⋀q'. q' ∈ target (FSM.initial M) ` {p. path M (FSM.initial M) p ∧ distinct (visited_states (FSM.initial M) p)} ⟹ q' ∈ {target (FSM.initial M) p |p. path M (FSM.initial M) p}›*) by blast ultimately show "?thesis" (*goal: ‹reachable_states M = target (FSM.initial M) ` acyclic_paths_up_to_length M (FSM.initial M) (FSM.size M - 1)›*) by blast qed lemma reachable_states_intro[intro!] : assumes "path M (initial M) p" shows "target (initial M) p ∈ reachable_states M" using assms (*‹path M (FSM.initial M) p›*) unfolding reachable_states_def (*goal: ‹target (FSM.initial (M::('a, 'b, 'c) fsm)) (p::('a × 'b × 'c × 'a) list) ∈ {target (FSM.initial M) p |p::('a × 'b × 'c × 'a) list. path M (FSM.initial M) p}›*) by auto lemma reachable_states_initial : "initial M ∈ reachable_states M" unfolding reachable_states_def (*goal: ‹FSM.initial M ∈ {target (FSM.initial M) p |p. path M (FSM.initial M) p}›*) by auto lemma reachable_states_next : assumes "q ∈ reachable_states M" and "t ∈ transitions M" and "t_source t = q" shows "t_target t ∈ reachable_states M" proof (-) (*goal: ‹t_target t ∈ reachable_states M›*) from ‹q ∈ reachable_states M› (*‹(q::'a) ∈ reachable_states (M::('a, 'b, 'c) fsm)›*) obtain p where "*": "path M (initial M) p" and "**": "target (initial M) p = q" (*goal: ‹(⋀p. ⟦path M (FSM.initial M) p; target (FSM.initial M) p = q⟧ ⟹ thesis) ⟹ thesis›*) unfolding reachable_states_def (*goal: ‹(⋀p. ⟦path M (FSM.initial M) p; target (FSM.initial M) p = q⟧ ⟹ thesis) ⟹ thesis›*) by auto then have "path M (initial M) (p@[t])" using assms(2,3) (*‹t ∈ FSM.transitions M› ‹t_source t = q›*) path_append_transition (*‹⟦path ?M ?q ?p; ?t ∈ FSM.transitions ?M; t_source ?t = target ?q ?p⟧ ⟹ path ?M ?q (?p @ [?t])›*) by metis moreover have "target (initial M) (p@[t]) = t_target t" by auto ultimately show "?thesis" (*goal: ‹t_target t ∈ reachable_states M›*) unfolding reachable_states_def (*goal: ‹t_target t ∈ {target (FSM.initial M) p |p. path M (FSM.initial M) p}›*) by (metis (mono_tags, lifting) mem_Collect_eq (*‹(?a ∈ Collect ?P) = ?P ?a›*)) qed lemma reachable_states_path : assumes "q ∈ reachable_states M" and "path M q p" and "t ∈ set p" shows "t_source t ∈ reachable_states M" using assms (*‹q ∈ reachable_states M› ‹path M q p› ‹t ∈ set p›*) unfolding reachable_states_def (*goal: ‹t_source t ∈ {target (FSM.initial M) p |p. path M (FSM.initial M) p}›*) proof (induction p arbitrary: q) (*goals: 1. ‹⋀q. ⟦q ∈ {target (FSM.initial M) p |p. path M (FSM.initial M) p}; path M q []; t ∈ set []⟧ ⟹ t_source t ∈ {target (FSM.initial M) p |p. path M (FSM.initial M) p}› 2. ‹⋀a p q. ⟦⋀q. ⟦q ∈ {target (FSM.initial M) p |p. path M (FSM.initial M) p}; path M q p; t ∈ set p⟧ ⟹ t_source t ∈ {target (FSM.initial M) p |p. path M (FSM.initial M) p}; q ∈ {target (FSM.initial M) p |p. path M (FSM.initial M) p}; path M q (a # p); t ∈ set (a # p)⟧ ⟹ t_source t ∈ {target (FSM.initial M) p |p. path M (FSM.initial M) p}›*) case Nil (*‹q ∈ {target (FSM.initial M) p |p. path M (FSM.initial M) p}› ‹path (M::('a::type, 'b::type, 'c::type) fsm) (q::'a::type) []› ‹(t::'a × 'b × 'c × 'a) ∈ set []›*) then show "?case" (*goal: ‹t_source t ∈ {target (FSM.initial M) p |p. path M (FSM.initial M) p}›*) by auto next (*goal: ‹⋀a p q. ⟦⋀q. ⟦q ∈ {target (FSM.initial M) p |p. path M (FSM.initial M) p}; path M q p; t ∈ set p⟧ ⟹ t_source t ∈ {target (FSM.initial M) p |p. path M (FSM.initial M) p}; q ∈ {target (FSM.initial M) p |p. path M (FSM.initial M) p}; path M q (a # p); t ∈ set (a # p)⟧ ⟹ t_source t ∈ {target (FSM.initial M) p |p. path M (FSM.initial M) p}›*) case (Cons t' p') (*‹⟦?q ∈ {target (FSM.initial M) p |p. path M (FSM.initial M) p}; path M ?q p'; t ∈ set p'⟧ ⟹ t_source t ∈ {target (FSM.initial M) p |p. path M (FSM.initial M) p}› ‹q ∈ {target (FSM.initial M) p |p. path M (FSM.initial M) p}› ‹path M q (t' # p')› ‹(t::'a × 'b × 'c × 'a) ∈ set ((t'::'a × 'b × 'c × 'a) # (p'::('a × 'b × 'c × 'a) list))›*) then show "?case" (*goal: ‹t_source (t::'a::type × 'b::type × 'c::type × 'a::type) ∈ {target (FSM.initial (M::('a::type, 'b::type, 'c::type) fsm)) p |p::('a::type × 'b::type × 'c::type × 'a::type) list. path M (FSM.initial M) p}›*) proof (cases "t = t'") (*goals: 1. ‹⟦⋀q. ⟦q ∈ {target (FSM.initial M) p |p. path M (FSM.initial M) p}; path M q p'; t ∈ set p'⟧ ⟹ t_source t ∈ {target (FSM.initial M) p |p. path M (FSM.initial M) p}; q ∈ {target (FSM.initial M) p |p. path M (FSM.initial M) p}; path M q (t' # p'); t ∈ set (t' # p'); t = t'⟧ ⟹ t_source t ∈ {target (FSM.initial M) p |p. path M (FSM.initial M) p}› 2. ‹⟦⋀q. ⟦q ∈ {target (FSM.initial M) p |p. path M (FSM.initial M) p}; path M q p'; t ∈ set p'⟧ ⟹ t_source t ∈ {target (FSM.initial M) p |p. path M (FSM.initial M) p}; q ∈ {target (FSM.initial M) p |p. path M (FSM.initial M) p}; path M q (t' # p'); t ∈ set (t' # p'); t ≠ t'⟧ ⟹ t_source t ∈ {target (FSM.initial M) p |p. path M (FSM.initial M) p}›*) case True (*‹t = t'›*) then show "?thesis" (*goal: ‹t_source t ∈ {target (FSM.initial M) p |p. path M (FSM.initial M) p}›*) using Cons.prems(1,2) (*‹(q::'a) ∈ {target (FSM.initial (M::('a, 'b, 'c) fsm)) p |p::('a × 'b × 'c × 'a) list. path M (FSM.initial M) p}› ‹path M q (t' # p')›*) by force next (*goal: ‹⟦⋀q. ⟦q ∈ {target (FSM.initial M) p |p. path M (FSM.initial M) p}; path M q p'; t ∈ set p'⟧ ⟹ t_source t ∈ {target (FSM.initial M) p |p. path M (FSM.initial M) p}; q ∈ {target (FSM.initial M) p |p. path M (FSM.initial M) p}; path M q (t' # p'); t ∈ set (t' # p'); t ≠ t'⟧ ⟹ t_source t ∈ {target (FSM.initial M) p |p. path M (FSM.initial M) p}›*) case False (*‹t ≠ t'›*) then show "?thesis" (*goal: ‹t_source (t::'a::type × 'b::type × 'c::type × 'a::type) ∈ {target (FSM.initial (M::('a::type, 'b::type, 'c::type) fsm)) p |p::('a::type × 'b::type × 'c::type × 'a::type) list. path M (FSM.initial M) p}›*) using Cons (*‹⟦?q ∈ {target (FSM.initial M) p |p. path M (FSM.initial M) p}; path M ?q p'; t ∈ set p'⟧ ⟹ t_source t ∈ {target (FSM.initial M) p |p. path M (FSM.initial M) p}› ‹q ∈ {target (FSM.initial M) p |p. path M (FSM.initial M) p}› ‹path M q (t' # p')› ‹t ∈ set (t' # p')›*) by (metis (mono_tags, lifting) path_cons_elim (*‹⟦path ?M ?q (?t # ?ts); ⟦?q = t_source ?t; ?t ∈ FSM.transitions ?M; path ?M (t_target ?t) ?ts⟧ ⟹ ?P⟧ ⟹ ?P›*) reachable_states_def (*‹reachable_states ?M = {target (FSM.initial ?M) p |p. path ?M (FSM.initial ?M) p}›*) reachable_states_next (*‹⟦?q ∈ reachable_states ?M; ?t ∈ FSM.transitions ?M; t_source ?t = ?q⟧ ⟹ t_target ?t ∈ reachable_states ?M›*) set_ConsD (*‹?y ∈ set (?x # ?xs) ⟹ ?y = ?x ∨ ?y ∈ set ?xs›*)) qed qed lemma reachable_states_initial_or_target : assumes "q ∈ reachable_states M" shows "q = initial M ∨ (∃ t ∈ transitions M . t_source t ∈ reachable_states M ∧ t_target t = q)" proof (-) (*goal: ‹q = FSM.initial M ∨ (∃t∈FSM.transitions M. t_source t ∈ reachable_states M ∧ t_target t = q)›*) obtain p where "path M (initial M) p" and "target (initial M) p = q" (*goal: ‹(⋀p. ⟦path M (FSM.initial M) p; target (FSM.initial M) p = q⟧ ⟹ thesis) ⟹ thesis›*) using assms (*‹(q::'a::type) ∈ reachable_states (M::('a::type, 'b::type, 'c::type) fsm)›*) unfolding reachable_states_def (*goal: ‹(⋀p::('a × 'b × 'c × 'a) list. ⟦path (M::('a, 'b, 'c) fsm) (FSM.initial M) p; target (FSM.initial M) p = (q::'a)⟧ ⟹ thesis::bool) ⟹ thesis›*) by auto show "?thesis" (*goal: ‹(q::'a::type) = FSM.initial (M::('a::type, 'b::type, 'c::type) fsm) ∨ (∃t::'a::type × 'b::type × 'c::type × 'a::type∈FSM.transitions M. t_source t ∈ reachable_states M ∧ t_target t = q)›*) proof (cases p rule: rev_cases (*‹⟦?xs = [] ⟹ ?P; ⋀ys y. ?xs = ys @ [y] ⟹ ?P⟧ ⟹ ?P›*)) (*goals: 1. ‹p = [] ⟹ q = FSM.initial M ∨ (∃t∈FSM.transitions M. t_source t ∈ reachable_states M ∧ t_target t = q)› 2. ‹⋀ys y. p = ys @ [y] ⟹ q = FSM.initial M ∨ (∃t∈FSM.transitions M. t_source t ∈ reachable_states M ∧ t_target t = q)›*) case Nil (*‹(p::('a × 'b × 'c × 'a) list) = []›*) then show "?thesis" (*goal: ‹q = FSM.initial M ∨ (∃t∈FSM.transitions M. t_source t ∈ reachable_states M ∧ t_target t = q)›*) using ‹path M (initial M) p› (*‹path (M::('a, 'b, 'c) fsm) (FSM.initial M) (p::('a × 'b × 'c × 'a) list)›*) ‹target (initial M) p = q› (*‹target (FSM.initial (M::('a::type, 'b::type, 'c::type) fsm)) (p::('a::type × 'b::type × 'c::type × 'a::type) list) = (q::'a::type)›*) by auto next (*goal: ‹⋀(ys::('a × 'b × 'c × 'a) list) y::'a × 'b × 'c × 'a. (p::('a × 'b × 'c × 'a) list) = ys @ [y] ⟹ (q::'a) = FSM.initial (M::('a, 'b, 'c) fsm) ∨ (∃t::'a × 'b × 'c × 'a∈FSM.transitions M. t_source t ∈ reachable_states M ∧ t_target t = q)›*) case (snoc p' t) (*‹p = p' @ [t]›*) have "t ∈ transitions M" using ‹path M (initial M) p› (*‹path M (FSM.initial M) p›*) unfolding snoc (*goal: ‹t ∈ FSM.transitions M›*) by auto moreover have "t_target t = q" using ‹target (initial M) p = q› (*‹target (FSM.initial M) p = q›*) unfolding snoc (*goal: ‹t_target t = q›*) by auto moreover have "t_source t ∈ reachable_states M" using ‹path M (initial M) p› (*‹path M (FSM.initial M) p›*) unfolding snoc (*goal: ‹t_source (t::'a × 'b × 'c × 'a) ∈ reachable_states (M::('a, 'b, 'c) fsm)›*) by (metis append_is_Nil_conv (*‹((?xs::?'a::type list) @ (?ys::?'a::type list) = []) = (?xs = [] ∧ ?ys = [])›*) last_in_set (*‹(?as::?'a::type list) ≠ [] ⟹ last ?as ∈ set ?as›*) last_snoc (*‹last ((?xs::?'a::type list) @ [?x::?'a::type]) = ?x›*) not_Cons_self2 (*‹(?x::?'a::type) # (?xs::?'a::type list) ≠ ?xs›*) reachable_states_initial (*‹FSM.initial (?M::(?'a::type, ?'b::type, ?'c::type) fsm) ∈ reachable_states ?M›*) reachable_states_path (*‹⟦(?q::?'a::type) ∈ reachable_states (?M::(?'a::type, ?'b::type, ?'c::type) fsm); path ?M ?q (?p::(?'a::type × ?'b::type × ?'c::type × ?'a::type) list); (?t::?'a::type × ?'b::type × ?'c::type × ?'a::type) ∈ set ?p⟧ ⟹ t_source ?t ∈ reachable_states ?M›*)) ultimately show "?thesis" (*goal: ‹q = FSM.initial M ∨ (∃t∈FSM.transitions M. t_source t ∈ reachable_states M ∧ t_target t = q)›*) by blast qed qed lemma reachable_state_is_state : "q ∈ reachable_states M ⟹ q ∈ states M" unfolding reachable_states_def (*goal: ‹(q::'a) ∈ {target (FSM.initial (M::('a, 'b, 'c) fsm)) p |p::('a × 'b × 'c × 'a) list. path M (FSM.initial M) p} ⟹ q ∈ FSM.states M›*) using path_target_is_state (*‹path ?M ?q ?p ⟹ target ?q ?p ∈ FSM.states ?M›*) by fastforce lemma reachable_states_finite : "finite (reachable_states M)" using fsm_states_finite[of M] (*‹finite (FSM.states M)›*) reachable_state_is_state[of _ M] (*‹(?q::'a) ∈ reachable_states (M::('a, 'b, 'c) fsm) ⟹ ?q ∈ FSM.states M›*) by (meson finite_subset (*‹⟦?A ⊆ ?B; finite ?B⟧ ⟹ finite ?A›*) subset_eq (*‹(?A ⊆ ?B) = (∀x∈?A. x ∈ ?B)›*)) subsection ‹Language› abbreviation "p_io (p :: ('state,'input,'output) path) ≡ map (λ t . (t_input t, t_output t)) p" fun language_state_for_input :: "('state,'input,'output) fsm ⇒ 'state ⇒ 'input list ⇒ ('input × 'output) list set" where "language_state_for_input M q xs = {p_io p | p . path M q p ∧ map fst (p_io p) = xs}" fun LS⇩i⇩n :: "('state,'input,'output) fsm ⇒ 'state ⇒ 'input list set ⇒ ('input × 'output) list set" where "LS⇩i⇩n M q xss = {p_io p | p . path M q p ∧ map fst (p_io p) ∈ xss}" abbreviation(input) "L⇩i⇩n M ≡ LS⇩i⇩n M (initial M)" lemma language_state_for_input_inputs : assumes "io ∈ language_state_for_input M q xs" shows "map fst io = xs" using assms (*‹(io::('a::type × 'b::type) list) ∈ language_state_for_input (M::('c::type, 'a::type, 'b::type) fsm) (q::'c::type) (xs::'a::type list)›*) by auto lemma language_state_for_inputs_inputs : assumes "io ∈ LS⇩i⇩n M q xss" shows "map fst io ∈ xss" using assms (*‹io ∈ LS⇩i⇩n M q xss›*) by auto fun LS :: "('state,'input,'output) fsm ⇒ 'state ⇒ ('input × 'output) list set" where "LS M q = { p_io p | p . path M q p }" abbreviation "L M ≡ LS M (initial M)" lemma language_state_containment : assumes "path M q p" and "p_io p = io" shows "io ∈ LS M q" using assms (*‹path (M::('a, 'b, 'c) fsm) (q::'a) (p::('a × 'b × 'c × 'a) list)› ‹p_io p = io›*) by auto lemma language_prefix : assumes "io1@io2 ∈ LS M q" shows "io1 ∈ LS M q" proof (-) (*goal: ‹io1 ∈ LS M q›*) obtain p where "path M q p" and "p_io p = io1@io2" (*goal: ‹(⋀p. ⟦path M q p; p_io p = io1 @ io2⟧ ⟹ thesis) ⟹ thesis›*) using assms (*‹io1 @ io2 ∈ LS M q›*) by auto let ?tp = "take (length io1) p" have "path M q ?tp" by (metis (no_types) ‹path M q p› append_take_drop_id (*‹take ?n ?xs @ drop ?n ?xs = ?xs›*) path_prefix (*‹path ?M ?q (?p1.0 @ ?p2.0) ⟹ path ?M ?q ?p1.0›*)) moreover have "p_io ?tp = io1" using ‹p_io p = io1@io2› (*‹p_io p = io1 @ io2›*) by (metis append_eq_conv_conj (*‹((?xs::?'a list) @ (?ys::?'a list) = (?zs::?'a list)) = (?xs = take (length ?xs) ?zs ∧ ?ys = drop (length ?xs) ?zs)›*) take_map (*‹take (?n::nat) (map (?f::?'b ⇒ ?'a) (?xs::?'b list)) = map ?f (take ?n ?xs)›*)) ultimately show "?thesis" (*goal: ‹io1 ∈ LS M q›*) by force qed lemma language_contains_empty_sequence : "[] ∈ L M" by auto lemma language_state_split : assumes "io1 @ io2 ∈ LS M q1" obtains p1 p2 where "path M q1 p1" and "path M (target q1 p1) p2" and "p_io p1 = io1" and "p_io p2 = io2" proof (-) (*goal: ‹(⋀p1 p2. ⟦path M q1 p1; path M (target q1 p1) p2; p_io p1 = io1; p_io p2 = io2⟧ ⟹ thesis) ⟹ thesis›*) obtain p12 where "path M q1 p12" and "p_io p12 = io1 @ io2" (*goal: ‹(⋀p12. ⟦path M q1 p12; p_io p12 = io1 @ io2⟧ ⟹ thesis) ⟹ thesis›*) using assms (*‹io1 @ io2 ∈ LS M q1›*) unfolding LS.simps (*goal: ‹(⋀p12::('c::type × 'a::type × 'b::type × 'c::type) list. ⟦path (M::('c::type, 'a::type, 'b::type) fsm) (q1::'c::type) p12; p_io p12 = (io1::('a::type × 'b::type) list) @ (io2::('a::type × 'b::type) list)⟧ ⟹ thesis::bool) ⟹ thesis›*) by auto let ?p1 = "take (length io1) p12" let ?p2 = "drop (length io1) p12" have "p12 = ?p1 @ ?p2" by auto then have "path M q1 (?p1 @ ?p2)" using ‹path M q1 p12› (*‹path (M::('c, 'a, 'b) fsm) (q1::'c) (p12::('c × 'a × 'b × 'c) list)›*) by auto have "path M q1 ?p1" and "path M (target q1 ?p1) ?p2" using path_append_elim[OF ‹path M q1 (?p1 @ ?p2)›] (*‹(⟦path M q1 (take (length io1) p12); path M (target q1 (take (length io1) p12)) (drop (length io1) p12)⟧ ⟹ ?thesis) ⟹ ?thesis›*) apply - (*goals: 1. ‹(⋀thesis. (⟦path M q1 (take (length io1) p12); path M (target q1 (take (length io1) p12)) (drop (length io1) p12)⟧ ⟹ thesis) ⟹ thesis) ⟹ path M q1 (take (length io1) p12)› 2. ‹(⋀thesis. (⟦path M q1 (take (length io1) p12); path M (target q1 (take (length io1) p12)) (drop (length io1) p12)⟧ ⟹ thesis) ⟹ thesis) ⟹ path M (target q1 (take (length io1) p12)) (drop (length io1) p12)› discuss goal 1*) apply blast (*discuss goal 2*) apply blast (*proven 2 subgoals*) . moreover have "p_io ?p1 = io1" using ‹p12 = ?p1 @ ?p2› (*‹p12 = take (length io1) p12 @ drop (length io1) p12›*) ‹p_io p12 = io1 @ io2› (*‹p_io p12 = io1 @ io2›*) by (metis append_eq_conv_conj (*‹(?xs @ ?ys = ?zs) = (?xs = take (length ?xs) ?zs ∧ ?ys = drop (length ?xs) ?zs)›*) take_map (*‹take ?n (map ?f ?xs) = map ?f (take ?n ?xs)›*)) moreover have "p_io ?p2 = io2" using ‹p12 = ?p1 @ ?p2› (*‹(p12::('c::type × 'a::type × 'b::type × 'c::type) list) = take (length (io1::('a::type × 'b::type) list)) p12 @ drop (length io1) p12›*) ‹p_io p12 = io1 @ io2› (*‹p_io p12 = io1 @ io2›*) by (metis (no_types) ‹p_io p12 = io1 @ io2› append_eq_conv_conj (*‹(?xs @ ?ys = ?zs) = (?xs = take (length ?xs) ?zs ∧ ?ys = drop (length ?xs) ?zs)›*) drop_map (*‹drop ?n (map ?f ?xs) = map ?f (drop ?n ?xs)›*)) ultimately show "?thesis" (*goal: ‹thesis›*) using that (*‹⟦path (M::('c::type, 'a::type, 'b::type) fsm) (q1::'c::type) (?p1.0::('c::type × 'a::type × 'b::type × 'c::type) list); path M (target q1 ?p1.0) (?p2.0::('c::type × 'a::type × 'b::type × 'c::type) list); p_io ?p1.0 = (io1::('a::type × 'b::type) list); p_io ?p2.0 = (io2::('a::type × 'b::type) list)⟧ ⟹ thesis::bool›*) by blast qed lemma language_initial_path_append_transition : assumes "ios @ [io] ∈ L M" obtains p t where "path M (initial M) (p@[t])" and "p_io (p@[t]) = ios @ [io]" proof (-) (*goal: ‹(⋀p t. ⟦path M (FSM.initial M) (p @ [t]); p_io (p @ [t]) = ios @ [io]⟧ ⟹ thesis) ⟹ thesis›*) obtain pt where "path M (initial M) pt" and "p_io pt = ios @ [io]" (*goal: ‹(⋀pt. ⟦path M (FSM.initial M) pt; p_io pt = ios @ [io]⟧ ⟹ thesis) ⟹ thesis›*) using assms (*‹ios @ [io] ∈ L M›*) unfolding LS.simps (*goal: ‹(⋀pt::('c::type × 'a::type × 'b::type × 'c::type) list. ⟦path (M::('c::type, 'a::type, 'b::type) fsm) (FSM.initial M) pt; p_io pt = (ios::('a::type × 'b::type) list) @ [io::'a::type × 'b::type]⟧ ⟹ thesis::bool) ⟹ thesis›*) by auto then have "pt ≠ []" by auto then obtain p and t where "pt = p @ [t]" (*goal: ‹(⋀p t. pt = p @ [t] ⟹ thesis) ⟹ thesis›*) using rev_exhaust (*‹⟦?xs = [] ⟹ ?P; ⋀ys y. ?xs = ys @ [y] ⟹ ?P⟧ ⟹ ?P›*) by blast then have "path M (initial M) (p@[t])" and "p_io (p@[t]) = ios @ [io]" using ‹path M (initial M) pt› (*‹path M (FSM.initial M) pt›*) ‹p_io pt = ios @ [io]› (*‹p_io pt = ios @ [io]›*) apply - (*goals: 1. ‹⟦pt = p @ [t]; path M (FSM.initial M) pt; p_io pt = ios @ [io]⟧ ⟹ path M (FSM.initial M) (p @ [t])› 2. ‹⟦pt = p @ [t]; path M (FSM.initial M) pt; p_io pt = ios @ [io]⟧ ⟹ p_io (p @ [t]) = ios @ [io]› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . then show "?thesis" (*goal: ‹thesis›*) using that (*‹⟦path M (FSM.initial M) (?p @ [?t]); p_io (?p @ [?t]) = ios @ [io]⟧ ⟹ thesis›*) by simp qed lemma language_path_append_transition : assumes "ios @ [io] ∈ LS M q" obtains p t where "path M q (p@[t])" and "p_io (p@[t]) = ios @ [io]" proof (-) (*goal: ‹(⋀(p::('c × 'a × 'b × 'c) list) t::'c × 'a × 'b × 'c. ⟦path (M::('c, 'a, 'b) fsm) (q::'c) (p @ [t]); p_io (p @ [t]) = (ios::('a × 'b) list) @ [io::'a × 'b]⟧ ⟹ thesis::bool) ⟹ thesis›*) obtain pt where "path M q pt" and "p_io pt = ios @ [io]" (*goal: ‹(⋀pt. ⟦path M q pt; p_io pt = ios @ [io]⟧ ⟹ thesis) ⟹ thesis›*) using assms (*‹ios @ [io] ∈ LS M q›*) unfolding LS.simps (*goal: ‹(⋀pt. ⟦path M q pt; p_io pt = ios @ [io]⟧ ⟹ thesis) ⟹ thesis›*) by auto then have "pt ≠ []" by auto then obtain p and t where "pt = p @ [t]" (*goal: ‹(⋀(p::('c × 'a × 'b × 'c) list) t::'c × 'a × 'b × 'c. (pt::('c × 'a × 'b × 'c) list) = p @ [t] ⟹ thesis::bool) ⟹ thesis›*) using rev_exhaust (*‹⟦?xs = [] ⟹ ?P; ⋀ys y. ?xs = ys @ [y] ⟹ ?P⟧ ⟹ ?P›*) by blast then have "path M q (p@[t])" and "p_io (p@[t]) = ios @ [io]" using ‹path M q pt› (*‹path (M::('c::type, 'a::type, 'b::type) fsm) (q::'c::type) (pt::('c::type × 'a::type × 'b::type × 'c::type) list)›*) ‹p_io pt = ios @ [io]› (*‹p_io pt = ios @ [io]›*) apply - (*goals: 1. ‹⟦(pt::('c::type × 'a::type × 'b::type × 'c::type) list) = (p::('c::type × 'a::type × 'b::type × 'c::type) list) @ [t::'c::type × 'a::type × 'b::type × 'c::type]; path (M::('c::type, 'a::type, 'b::type) fsm) (q::'c::type) pt; p_io pt = (ios::('a::type × 'b::type) list) @ [io::'a::type × 'b::type]⟧ ⟹ path M q (p @ [t])› 2. ‹⟦(pt::('c::type × 'a::type × 'b::type × 'c::type) list) = (p::('c::type × 'a::type × 'b::type × 'c::type) list) @ [t::'c::type × 'a::type × 'b::type × 'c::type]; path (M::('c::type, 'a::type, 'b::type) fsm) (q::'c::type) pt; p_io pt = (ios::('a::type × 'b::type) list) @ [io::'a::type × 'b::type]⟧ ⟹ p_io (p @ [t]) = ios @ [io]› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . then show "?thesis" (*goal: ‹thesis::bool›*) using that (*‹⟦path M q (?p @ [?t]); p_io (?p @ [?t]) = ios @ [io]⟧ ⟹ thesis›*) by simp qed lemma language_split : assumes "io1@io2 ∈ L M" obtains p1 p2 where "path M (initial M) (p1@p2)" and "p_io p1 = io1" and "p_io p2 = io2" proof (-) (*goal: ‹(⋀p1 p2. ⟦path M (FSM.initial M) (p1 @ p2); p_io p1 = io1; p_io p2 = io2⟧ ⟹ thesis) ⟹ thesis›*) from assms (*‹io1 @ io2 ∈ L M›*) obtain p where "path M (initial M) p" and "p_io p = io1 @ io2" (*goal: ‹(⋀p. ⟦path M (FSM.initial M) p; p_io p = io1 @ io2⟧ ⟹ thesis) ⟹ thesis›*) by auto let ?p1 = "take (length io1) p" let ?p2 = "drop (length io1) p" have "path M (initial M) (?p1@?p2)" using ‹path M (initial M) p› (*‹path M (FSM.initial M) p›*) by simp moreover have "p_io ?p1 = io1" using ‹p_io p = io1 @ io2› (*‹p_io (p::('c::type × 'a::type × 'b::type × 'c::type) list) = (io1::('a::type × 'b::type) list) @ (io2::('a::type × 'b::type) list)›*) by (metis append_eq_conv_conj (*‹((?xs::?'a list) @ (?ys::?'a list) = (?zs::?'a list)) = (?xs = take (length ?xs) ?zs ∧ ?ys = drop (length ?xs) ?zs)›*) take_map (*‹take (?n::nat) (map (?f::?'b ⇒ ?'a) (?xs::?'b list)) = map ?f (take ?n ?xs)›*)) moreover have "p_io ?p2 = io2" using ‹p_io p = io1 @ io2› (*‹p_io p = io1 @ io2›*) by (metis append_eq_conv_conj (*‹(?xs @ ?ys = ?zs) = (?xs = take (length ?xs) ?zs ∧ ?ys = drop (length ?xs) ?zs)›*) drop_map (*‹drop ?n (map ?f ?xs) = map ?f (drop ?n ?xs)›*)) ultimately show "?thesis" (*goal: ‹thesis›*) using that (*‹⟦path (M::('c::type, 'a::type, 'b::type) fsm) (FSM.initial M) ((?p1.0::('c::type × 'a::type × 'b::type × 'c::type) list) @ (?p2.0::('c::type × 'a::type × 'b::type × 'c::type) list)); p_io ?p1.0 = (io1::('a::type × 'b::type) list); p_io ?p2.0 = (io2::('a::type × 'b::type) list)⟧ ⟹ thesis::bool›*) by blast qed lemma language_io : assumes "io ∈ LS M q" and "(x,y) ∈ set io" shows "x ∈ (inputs M)" and "y ∈ outputs M" proof (-) (*goals: 1. ‹(x::'a::type) ∈ FSM.inputs (M::('c::type, 'a::type, 'b::type) fsm)› 2. ‹(y::'b::type) ∈ FSM.outputs (M::('c::type, 'a::type, 'b::type) fsm)›*) obtain p where "path M q p" and "p_io p = io" (*goal: ‹(⋀p. ⟦path M q p; p_io p = io⟧ ⟹ thesis) ⟹ thesis›*) using ‹io ∈ LS M q› (*‹io ∈ LS M q›*) by auto then obtain t where "t ∈ set p" and "t_input t = x" and "t_output t = y" (*goal: ‹(⋀t. ⟦t ∈ set p; t_input t = x; t_output t = y⟧ ⟹ thesis) ⟹ thesis›*) using ‹(x,y) ∈ set io› (*‹(x, y) ∈ set io›*) by auto have "t ∈ transitions M" using ‹path M q p› (*‹path M q p›*) ‹t ∈ set p› (*‹(t::'c × 'a × 'b × 'c) ∈ set (p::('c × 'a × 'b × 'c) list)›*) apply ((induction p)[1]) (*goals: 1. ‹⋀q M. ⟦q ∈ FSM.states M; t ∈ set []⟧ ⟹ t ∈ FSM.transitions M› 2. ‹⋀ta M ts. ⟦ta ∈ FSM.transitions M; path M (t_target ta) ts; t ∈ set ts ⟹ t ∈ FSM.transitions M; t ∈ set (ta # ts)⟧ ⟹ t ∈ FSM.transitions M› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . show "x ∈ (inputs M)" using ‹t ∈ transitions M› (*‹t ∈ FSM.transitions M›*) ‹t_input t = x› (*‹t_input t = x›*) by auto show "y ∈ outputs M" using ‹t ∈ transitions M› (*‹t ∈ FSM.transitions M›*) ‹t_output t = y› (*‹t_output t = y›*) by auto qed lemma path_io_split : assumes "path M q p" and "p_io p = io1@io2" shows "path M q (take (length io1) p)" and "p_io (take (length io1) p) = io1" and "path M (target q (take (length io1) p)) (drop (length io1) p)" and "p_io (drop (length io1) p) = io2" proof (-) (*goals: 1. ‹path M q (take (length io1) p)› 2. ‹p_io (take (length io1) p) = io1› 3. ‹path M (target q (take (length io1) p)) (drop (length io1) p)› 4. ‹p_io (drop (length io1) p) = io2›*) have "length io1 ≤ length p" using ‹p_io p = io1@io2› (*‹p_io (p::('a × 'b × 'c × 'a) list) = (io1::('b × 'c) list) @ (io2::('b × 'c) list)›*) unfolding length_map[of "(λ t . (t_input t, t_output t))", symmetric] (*goal: ‹length (io1::('b::type × 'c::type) list) ≤ length (p_io (p::('a::type × 'b::type × 'c::type × 'a::type) list))›*) by auto have "p = (take (length io1) p)@(drop (length io1) p)" by simp then have "*": "path M q ((take (length io1) p)@(drop (length io1) p))" using ‹path M q p› (*‹path (M::('a, 'b, 'c) fsm) (q::'a) (p::('a × 'b × 'c × 'a) list)›*) by auto show "path M q (take (length io1) p)" and "path M (target q (take (length io1) p)) (drop (length io1) p)" using path_append_elim[OF *] (*‹(⟦path M q (take (length io1) p); path M (target q (take (length io1) p)) (drop (length io1) p)⟧ ⟹ ?thesis) ⟹ ?thesis›*) apply - (*goals: 1. ‹(⋀thesis. (⟦path M q (take (length io1) p); path M (target q (take (length io1) p)) (drop (length io1) p)⟧ ⟹ thesis) ⟹ thesis) ⟹ path M q (take (length io1) p)› 2. ‹(⋀thesis. (⟦path M q (take (length io1) p); path M (target q (take (length io1) p)) (drop (length io1) p)⟧ ⟹ thesis) ⟹ thesis) ⟹ path M (target q (take (length io1) p)) (drop (length io1) p)› discuss goal 1*) apply blast (*discuss goal 2*) apply blast (*proven 2 subgoals*) . show "p_io (take (length io1) p) = io1" using ‹p = (take (length io1) p)@(drop (length io1) p)› (*‹(p::('a::type × 'b::type × 'c::type × 'a::type) list) = take (length (io1::('b::type × 'c::type) list)) p @ drop (length io1) p›*) ‹p_io p = io1@io2› (*‹p_io p = io1 @ io2›*) by (metis append_eq_conv_conj (*‹((?xs::?'a list) @ (?ys::?'a list) = (?zs::?'a list)) = (?xs = take (length ?xs) ?zs ∧ ?ys = drop (length ?xs) ?zs)›*) take_map (*‹take (?n::nat) (map (?f::?'b ⇒ ?'a) (?xs::?'b list)) = map ?f (take ?n ?xs)›*)) show "p_io (drop (length io1) p) = io2" using ‹p = (take (length io1) p)@(drop (length io1) p)› (*‹(p::('a × 'b × 'c × 'a) list) = take (length (io1::('b × 'c) list)) p @ drop (length io1) p›*) ‹p_io p = io1@io2› (*‹p_io p = io1 @ io2›*) by (metis append_eq_conv_conj (*‹(?xs @ ?ys = ?zs) = (?xs = take (length ?xs) ?zs ∧ ?ys = drop (length ?xs) ?zs)›*) drop_map (*‹drop ?n (map ?f ?xs) = map ?f (drop ?n ?xs)›*)) qed lemma language_intro : assumes "path M q p" shows "p_io p ∈ LS M q" using assms (*‹path M q p›*) unfolding LS.simps (*goal: ‹p_io p ∈ {p_io p |p. path M q p}›*) by auto lemma language_prefix_append : assumes "io1 @ (p_io p) ∈ L M" shows "io1 @ p_io (take i p) ∈ L M" proof (-) (*goal: ‹io1 @ p_io (take i p) ∈ L M›*) fix i have "p_io p = (p_io (take i p)) @ (p_io (drop i p))" by (metis append_take_drop_id (*‹take ?n ?xs @ drop ?n ?xs = ?xs›*) map_append (*‹map ?f (?xs @ ?ys) = map ?f ?xs @ map ?f ?ys›*)) then have "(io1 @ (p_io (take i p))) @ (p_io (drop i p)) ∈ L M" using ‹io1 @ p_io p ∈ L M› (*‹io1 @ p_io p ∈ L M›*) by auto show "io1 @ p_io (take i p) ∈ L M" using language_prefix[OF ‹(io1 @ (p_io (take i p))) @ (p_io (drop i p)) ∈ L M›] (*‹io1 @ p_io (take i p) ∈ L M›*) by assumption qed lemma language_finite: "finite {io . io ∈ L M ∧ length io ≤ k}" proof (-) (*goal: ‹finite {io ∈ L M. length io ≤ k}›*) have "{io . io ∈ L M ∧ length io ≤ k} ⊆ p_io ` {p. path M (FSM.initial M) p ∧ length p ≤ k}" by auto then show "?thesis" (*goal: ‹finite {io ∈ L M. length io ≤ k}›*) using paths_finite[of M "initial M" k] (*‹finite {p. path M (FSM.initial M) p ∧ length p ≤ k}›*) using finite_surj (*‹⟦finite ?A; ?B ⊆ ?f ` ?A⟧ ⟹ finite ?B›*) by auto qed lemma LS_prepend_transition : assumes "t ∈ transitions M" and "io ∈ LS M (t_target t)" shows "(t_input t, t_output t) # io ∈ LS M (t_source t)" proof (-) (*goal: ‹(t_input t, t_output t) # io ∈ LS M (t_source t)›*) obtain p where "path M (t_target t) p" and "p_io p = io" (*goal: ‹(⋀p. ⟦path M (t_target t) p; p_io p = io⟧ ⟹ thesis) ⟹ thesis›*) using assms(2) (*‹io ∈ LS M (t_target t)›*) by auto then have "path M (t_source t) (t#p)" and "p_io (t#p) = (t_input t, t_output t) # io" using assms(1) (*‹t ∈ FSM.transitions M›*) apply - (*goals: 1. ‹⟦path (M::('a, 'b, 'c) fsm) (t_target (t::'a × 'b × 'c × 'a)) (p::('a × 'b × 'c × 'a) list); p_io p = (io::('b × 'c) list); t ∈ FSM.transitions M⟧ ⟹ path M (t_source t) (t # p)› 2. ‹⟦path (M::('a, 'b, 'c) fsm) (t_target (t::'a × 'b × 'c × 'a)) (p::('a × 'b × 'c × 'a) list); p_io p = (io::('b × 'c) list); t ∈ FSM.transitions M⟧ ⟹ p_io (t # p) = (t_input t, t_output t) # io› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . then show "?thesis" (*goal: ‹(t_input t, t_output t) # io ∈ LS M (t_source t)›*) unfolding LS.simps (*goal: ‹(t_input t, t_output t) # io ∈ {p_io p |p. path M (t_source t) p}›*) by (metis (mono_tags, lifting) mem_Collect_eq (*‹(?a ∈ Collect ?P) = ?P ?a›*)) qed lemma language_empty_IO : assumes "inputs M = {} ∨ outputs M = {}" shows "L M = {[]}" proof (-) (*goal: ‹L M = {[]}›*) consider "inputs M = {}" | "outputs M = {}" (*goal: ‹⟦FSM.inputs M = {} ⟹ thesis; FSM.outputs M = {} ⟹ thesis⟧ ⟹ thesis›*) using assms (*‹FSM.inputs M = {} ∨ FSM.outputs M = {}›*) by blast then show "?thesis" (*goal: ‹L M = {[]}›*) proof (cases) (*goals: 1. ‹FSM.inputs M = {} ⟹ L M = {[]}› 2. ‹FSM.outputs M = {} ⟹ L M = {[]}›*) case 1 (*‹FSM.inputs M = {}›*) show "L M = {[]}" using language_io(1)[of _ M "initial M"] (*‹⟦?io ∈ L M; (?x, ?y) ∈ set ?io⟧ ⟹ ?x ∈ FSM.inputs M›*) unfolding "1" (*goal: ‹L M = {[]}›*) by (metis (no_types, opaque_lifting) ex_in_conv (*‹(∃x. x ∈ ?A) = (?A ≠ {})›*) is_singletonI' (*‹⟦?A ≠ {}; ⋀x y. ⟦x ∈ ?A; y ∈ ?A⟧ ⟹ x = y⟧ ⟹ is_singleton ?A›*) is_singleton_the_elem (*‹is_singleton ?A = (?A = {the_elem ?A})›*) language_contains_empty_sequence (*‹[] ∈ L ?M›*) set_empty2 (*‹({} = set ?xs) = (?xs = [])›*) singleton_iff (*‹(?b ∈ {?a}) = (?b = ?a)›*) surj_pair (*‹∃x y. ?p = (x, y)›*)) next (*goal: ‹FSM.outputs M = {} ⟹ L M = {[]}›*) case 2 (*‹FSM.outputs (M::('b, 'a, 'c) fsm) = {}›*) show "L M = {[]}" using language_io(2)[of _ M "initial M"] (*‹⟦?io ∈ L M; (?x, ?y) ∈ set ?io⟧ ⟹ ?y ∈ FSM.outputs M›*) unfolding "2" (*goal: ‹L M = {[]}›*) by (metis (no_types, opaque_lifting) ex_in_conv (*‹(∃x. x ∈ ?A) = (?A ≠ {})›*) is_singletonI' (*‹⟦?A ≠ {}; ⋀x y. ⟦x ∈ ?A; y ∈ ?A⟧ ⟹ x = y⟧ ⟹ is_singleton ?A›*) is_singleton_the_elem (*‹is_singleton ?A = (?A = {the_elem ?A})›*) language_contains_empty_sequence (*‹[] ∈ L ?M›*) set_empty2 (*‹({} = set ?xs) = (?xs = [])›*) singleton_iff (*‹(?b ∈ {?a}) = (?b = ?a)›*) surj_pair (*‹∃x y. ?p = (x, y)›*)) qed qed lemma language_equivalence_from_isomorphism_helper : assumes "bij_betw f (states M1) (states M2)" and "f (initial M1) = initial M2" and "⋀ q x y q' . q ∈ states M1 ⟹ q' ∈ states M1 ⟹ (q,x,y,q') ∈ transitions M1 ⟷ (f q,x,y,f q') ∈ transitions M2" and "q ∈ states M1" shows "LS M1 q ⊆ LS M2 (f q)" proof (standard) (*goal: ‹⋀x. x ∈ LS M1 q ⟹ x ∈ LS M2 (f q)›*) fix io assume "io ∈ LS M1 q" (*‹(io::('c × 'd) list) ∈ LS (M1::('a, 'c, 'd) fsm) (q::'a)›*) then obtain p where "path M1 q p" and "p_io p = io" (*goal: ‹(⋀p. ⟦path M1 q p; p_io p = io⟧ ⟹ thesis) ⟹ thesis›*) by auto let ?f = "λ(q,x,y,q') . (f q,x,y,f q')" let ?p = "map ?f p" have "f q ∈ states M2" using assms(1,4) (*‹bij_betw (f::'a::type ⇒ 'b::type) (FSM.states (M1::('a::type, 'c::type, 'd::type) fsm)) (FSM.states (M2::('b::type, 'c::type, 'd::type) fsm))› ‹q ∈ FSM.states M1›*) using bij_betwE (*‹bij_betw ?f ?A ?B ⟹ ∀a∈?A. ?f a ∈ ?B›*) by auto have "path M2 (f q) ?p" using ‹path M1 q p› (*‹path (M1::('a::type, 'c::type, 'd::type) fsm) (q::'a::type) (p::('a::type × 'c::type × 'd::type × 'a::type) list)›*) proof (induction p rule: rev_induct (*‹⟦?P []; ⋀x xs. ?P xs ⟹ ?P (xs @ [x])⟧ ⟹ ?P ?xs›*)) (*goals: 1. ‹path M1 q [] ⟹ path M2 (f q) (map (λ(q, x, y, q'). (f q, x, y, f q')) [])› 2. ‹⋀x xs. ⟦path M1 q xs ⟹ path M2 (f q) (map (λ(q, x, y, q'). (f q, x, y, f q')) xs); path M1 q (xs @ [x])⟧ ⟹ path M2 (f q) (map (λ(q, x, y, q'). (f q, x, y, f q')) (xs @ [x]))›*) case Nil (*‹path M1 q []›*) show "?case" (*goal: ‹path M2 (f q) (map (λa. case a of (q, x, y, q') ⇒ (f q, x, y, f q')) [])›*) using ‹f q ∈ states M2› (*‹f q ∈ FSM.states M2›*) by auto next (*goal: ‹⋀(x::'a × 'c × 'd × 'a) xs::('a × 'c × 'd × 'a) list. ⟦path (M1::('a, 'c, 'd) fsm) (q::'a) xs ⟹ path (M2::('b, 'c, 'd) fsm) ((f::'a ⇒ 'b) q) (map (λ(q::'a, x::'c, y::'d, q'::'a). (f q, x, y, f q')) xs); path M1 q (xs @ [x])⟧ ⟹ path M2 (f q) (map (λ(q::'a, x::'c, y::'d, q'::'a). (f q, x, y, f q')) (xs @ [x]))›*) case (snoc a p) (*‹path M1 q p ⟹ path M2 (f q) (map (λa. case a of (q, x, y, q') ⇒ (f q, x, y, f q')) p)› ‹path M1 q (p @ [a])›*) then have "path M2 (f q) (map ?f p)" by auto have "target (f q) (map ?f p) = f (target q p)" using ‹f (initial M1) = initial M2› (*‹f (FSM.initial M1) = FSM.initial M2›*) assms(2) (*‹f (FSM.initial M1) = FSM.initial M2›*) apply ((induction p)[1]) (*goals: 1. ‹⟦f (FSM.initial M1) = FSM.initial M2; f (FSM.initial M1) = FSM.initial M2⟧ ⟹ target (f q) (map (λ(q, x, y, q'). (f q, x, y, f q')) []) = f (target q [])› 2. ‹⋀a p. ⟦⟦f (FSM.initial M1) = FSM.initial M2; f (FSM.initial M1) = FSM.initial M2⟧ ⟹ target (f q) (map (λ(q, x, y, q'). (f q, x, y, f q')) p) = f (target q p); f (FSM.initial M1) = FSM.initial M2; f (FSM.initial M1) = FSM.initial M2⟧ ⟹ target (f q) (map (λ(q, x, y, q'). (f q, x, y, f q')) (a # p)) = f (target q (a # p))› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . then have "t_source (?f a) = target (f q) (map ?f p)" by (metis (no_types, lifting) case_prod_beta' (*‹(λ(x, y). ?f x y) = (λx. ?f (fst x) (snd x))›*) fst_conv (*‹fst (?x1.0, ?x2.0) = ?x1.0›*) path_append_transition_elim( (*‹path ?M ?q (?p @ [?t]) ⟹ t_source ?t = target ?q ?p›*) 3) snoc.prems (*‹path M1 q (p @ [a])›*)) have "a ∈ transitions M1" using snoc.prems (*‹path M1 q (p @ [a])›*) by auto then have "?f a ∈ transitions M2" by (metis (mono_tags, lifting) assms( (*‹⟦?q ∈ FSM.states M1; ?q' ∈ FSM.states M1⟧ ⟹ ((?q, ?x, ?y, ?q') ∈ FSM.transitions M1) = ((f ?q, ?x, ?y, f ?q') ∈ FSM.transitions M2)›*) 3) case_prod_beta (*‹(case ?p of (x, xa) ⇒ ?f x xa) = ?f (fst ?p) (snd ?p)›*) fsm_transition_source (*‹?t ∈ FSM.transitions ?M ⟹ t_source ?t ∈ FSM.states ?M›*) fsm_transition_target (*‹?t ∈ FSM.transitions ?M ⟹ t_target ?t ∈ FSM.states ?M›*) surjective_pairing (*‹?t = (fst ?t, snd ?t)›*)) have "map ?f (p@[a]) = (map ?f p)@[?f a]" by auto show "?case" (*goal: ‹path M2 (f q) (map (λa. case a of (q, x, y, q') ⇒ (f q, x, y, f q')) (p @ [a]))›*) unfolding ‹map ?f (p@[a]) = (map ?f p)@[?f a]› (*goal: ‹path (M2::('b, 'c, 'd) fsm) ((f::'a ⇒ 'b) (q::'a)) (map (λ(q::'a, x::'c, y::'d, q'::'a). (f q, x, y, f q')) (p::('a × 'c × 'd × 'a) list) @ [case a::'a × 'c × 'd × 'a of (q::'a, xa::'c, y::'d, q'::'a) ⇒ (f q, xa, y, f q')])›*) using path_append_transition[OF ‹path M2 (f q) (map ?f p)› ‹?f a ∈ transitions M2› ‹t_source (?f a) = target (f q) (map ?f p)›] (*‹path (M2::('b::type, 'c::type, 'd::type) fsm) ((f::'a::type ⇒ 'b::type) (q::'a::type)) (map (λ(q::'a::type, x::'c::type, y::'d::type, q'::'a::type). (f q, x, y, f q')) (p::('a::type × 'c::type × 'd::type × 'a::type) list) @ [case a::'a::type × 'c::type × 'd::type × 'a::type of (q::'a::type, xa::'c::type, y::'d::type, q'::'a::type) ⇒ (f q, xa, y, f q')])›*) by assumption qed moreover have "p_io ?p = io" using ‹p_io p = io› (*‹p_io p = io›*) apply ((induction p)[1]) (*goals: 1. ‹p_io [] = io ⟹ p_io (map (λ(q, x, y, q'). (f q, x, y, f q')) []) = io› 2. ‹⋀a p. ⟦p_io p = io ⟹ p_io (map (λ(q, x, y, q'). (f q, x, y, f q')) p) = io; p_io (a # p) = io⟧ ⟹ p_io (map (λ(q, x, y, q'). (f q, x, y, f q')) (a # p)) = io› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . ultimately show "io ∈ LS M2 (f q)" using language_state_containment (*‹⟦path ?M ?q ?p; p_io ?p = ?io⟧ ⟹ ?io ∈ LS ?M ?q›*) by fastforce qed lemma language_equivalence_from_isomorphism : assumes "bij_betw f (states M1) (states M2)" and "f (initial M1) = initial M2" and "⋀ q x y q' . q ∈ states M1 ⟹ q' ∈ states M1 ⟹ (q,x,y,q') ∈ transitions M1 ⟷ (f q,x,y,f q') ∈ transitions M2" and "q ∈ states M1" shows "LS M1 q = LS M2 (f q)" proof (standard) (*goals: 1. ‹LS M1 q ⊆ LS M2 (f q)› 2. ‹LS M2 (f q) ⊆ LS M1 q›*) show "LS M1 q ⊆ LS M2 (f q)" using language_equivalence_from_isomorphism_helper[OF assms] (*‹⟦⋀q x y q'. ⟦q ∈ FSM.states M1; q' ∈ FSM.states M1⟧ ⟹ q ∈ FSM.states M1; ⋀q x y q'. ⟦q ∈ FSM.states M1; q' ∈ FSM.states M1⟧ ⟹ q' ∈ FSM.states M1⟧ ⟹ LS M1 q ⊆ LS M2 (f q)›*) . have "f q ∈ states M2" using assms(1,4) (*‹bij_betw f (FSM.states M1) (FSM.states M2)› ‹(q::'a::type) ∈ FSM.states (M1::('a::type, 'c::type, 'd::type) fsm)›*) using bij_betwE (*‹bij_betw ?f ?A ?B ⟹ ∀a∈?A. ?f a ∈ ?B›*) by auto have "(inv_into (FSM.states M1) f (f q)) = q" by (meson assms( (*‹bij_betw f (FSM.states M1) (FSM.states M2)›*) 1) assms( (*‹q ∈ FSM.states M1›*) 4) bij_betw_imp_inj_on (*‹bij_betw ?f ?A ?B ⟹ inj_on ?f ?A›*) inv_into_f_f (*‹⟦inj_on ?f ?A; ?x ∈ ?A⟧ ⟹ inv_into ?A ?f (?f ?x) = ?x›*)) have "bij_betw (inv_into (states M1) f) (states M2) (states M1)" using bij_betw_inv_into[OF assms ( 1 )] (*‹bij_betw (inv_into (FSM.states M1) f) (FSM.states M2) (FSM.states M1)›*) . moreover have "(inv_into (states M1) f) (initial M2) = (initial M1)" using assms(1,2) (*‹bij_betw (f::'a::type ⇒ 'b::type) (FSM.states (M1::('a::type, 'c::type, 'd::type) fsm)) (FSM.states (M2::('b::type, 'c::type, 'd::type) fsm))› ‹f (FSM.initial M1) = FSM.initial M2›*) by (metis bij_betw_inv_into_left (*‹⟦bij_betw (?f::?'a ⇒ ?'b) (?A::?'a set) (?A'::?'b set); (?a::?'a) ∈ ?A⟧ ⟹ inv_into ?A ?f (?f ?a) = ?a›*) fsm_initial (*‹FSM.initial (?M::(?'a, ?'b, ?'c) fsm) ∈ FSM.states ?M›*)) moreover have "⋀ q x y q' . q ∈ states M2 ⟹ q' ∈ states M2 ⟹ (q,x,y,q') ∈ transitions M2 ⟷ ((inv_into (states M1) f) q,x,y,(inv_into (states M1) f) q') ∈ transitions M1" proof (standard) (*goals: 1. ‹⋀q x y q'. ⟦q ∈ FSM.states M2; q' ∈ FSM.states M2; (q, x, y, q') ∈ FSM.transitions M2⟧ ⟹ (inv_into (FSM.states M1) f q, x, y, inv_into (FSM.states M1) f q') ∈ FSM.transitions M1› 2. ‹⋀q x y q'. ⟦q ∈ FSM.states M2; q' ∈ FSM.states M2; (inv_into (FSM.states M1) f q, x, y, inv_into (FSM.states M1) f q') ∈ FSM.transitions M1⟧ ⟹ (q, x, y, q') ∈ FSM.transitions M2›*) fix q and x and y and q' assume "q ∈ states M2" and "q' ∈ states M2" (*‹(q::'b) ∈ FSM.states (M2::('b, 'c, 'd) fsm)› ‹(q'::'b) ∈ FSM.states (M2::('b, 'c, 'd) fsm)›*) show "(q,x,y,q') ∈ transitions M2 ⟹ ((inv_into (states M1) f) q,x,y,(inv_into (states M1) f) q') ∈ transitions M1" proof (-) (*goal: ‹(q, x, y, q') ∈ FSM.transitions M2 ⟹ (inv_into (FSM.states M1) f q, x, y, inv_into (FSM.states M1) f q') ∈ FSM.transitions M1›*) assume a1: "(q, x, y, q') ∈ FSM.transitions M2" (*‹(q::'b, x::'c, y::'d, q'::'b) ∈ FSM.transitions (M2::('b, 'c, 'd) fsm)›*) have f2: "∀f B A. ¬ bij_betw f B A ∨ (∀b. (b::'b) ∉ B ∨ (f b::'a) ∈ A)" using bij_betwE (*‹bij_betw ?f ?A ?B ⟹ ∀a∈?A. ?f a ∈ ?B›*) by blast then have f3: "inv_into (states M1) f q ∈ states M1" using ‹q ∈ states M2› (*‹q ∈ FSM.states M2›*) calculation(1) (*‹bij_betw (inv_into (FSM.states (M1::('a, 'c, 'd) fsm)) (f::'a ⇒ 'b)) (FSM.states (M2::('b, 'c, 'd) fsm)) (FSM.states M1)›*) by blast have "inv_into (states M1) f q' ∈ states M1" using f2 (*‹∀f B A. ¬ bij_betw f B A ∨ (∀b. b ∉ B ∨ f b ∈ A)›*) ‹q' ∈ states M2› (*‹q' ∈ FSM.states M2›*) calculation(1) (*‹bij_betw (inv_into (FSM.states M1) f) (FSM.states M2) (FSM.states M1)›*) by blast then show "?thesis" (*goal: ‹(inv_into (FSM.states M1) f q, x, y, inv_into (FSM.states M1) f q') ∈ FSM.transitions M1›*) using f3 (*‹inv_into (FSM.states M1) f q ∈ FSM.states M1›*) a1 (*‹(q, x, y, q') ∈ FSM.transitions M2›*) ‹q ∈ states M2› (*‹q ∈ FSM.states M2›*) ‹q' ∈ states M2› (*‹q' ∈ FSM.states M2›*) assms(1) (*‹bij_betw (f::'a ⇒ 'b) (FSM.states (M1::('a, 'c, 'd) fsm)) (FSM.states (M2::('b, 'c, 'd) fsm))›*) assms(3) (*‹⟦?q ∈ FSM.states M1; ?q' ∈ FSM.states M1⟧ ⟹ ((?q, ?x, ?y, ?q') ∈ FSM.transitions M1) = ((f ?q, ?x, ?y, f ?q') ∈ FSM.transitions M2)›*) bij_betw_inv_into_right (*‹⟦bij_betw (?f::?'a ⇒ ?'b) (?A::?'a set) (?A'::?'b set); (?a'::?'b) ∈ ?A'⟧ ⟹ ?f (inv_into ?A ?f ?a') = ?a'›*) by fastforce qed show "((inv_into (states M1) f) q,x,y,(inv_into (states M1) f) q') ∈ transitions M1 ⟹ (q,x,y,q') ∈ transitions M2" proof (-) (*goal: ‹(inv_into (FSM.states M1) f q, x, y, inv_into (FSM.states M1) f q') ∈ FSM.transitions M1 ⟹ (q, x, y, q') ∈ FSM.transitions M2›*) assume a1: "(inv_into (states M1) f q, x, y, inv_into (states M1) f q') ∈ FSM.transitions M1" (*‹(inv_into (FSM.states (M1::('a, 'c, 'd) fsm)) (f::'a ⇒ 'b) (q::'b), x::'c, y::'d, inv_into (FSM.states M1) f (q'::'b)) ∈ FSM.transitions M1›*) have f2: "∀f B A. ¬ bij_betw f B A ∨ (∀b. (b::'b) ∉ B ∨ (f b::'a) ∈ A)" by (metis (full_types) bij_betwE (*‹bij_betw ?f ?A ?B ⟹ ∀a∈?A. ?f a ∈ ?B›*)) then have f3: "inv_into (states M1) f q' ∈ states M1" using ‹q' ∈ states M2› (*‹q' ∈ FSM.states M2›*) calculation(1) (*‹bij_betw (inv_into (FSM.states M1) f) (FSM.states M2) (FSM.states M1)›*) by blast have "inv_into (states M1) f q ∈ states M1" using f2 (*‹∀f B A. ¬ bij_betw f B A ∨ (∀b. b ∉ B ∨ f b ∈ A)›*) ‹q ∈ states M2› (*‹q ∈ FSM.states M2›*) calculation(1) (*‹bij_betw (inv_into (FSM.states M1) f) (FSM.states M2) (FSM.states M1)›*) by blast then show "?thesis" (*goal: ‹(q::'b, x::'c, y::'d, q'::'b) ∈ FSM.transitions (M2::('b, 'c, 'd) fsm)›*) using f3 (*‹inv_into (FSM.states M1) f q' ∈ FSM.states M1›*) a1 (*‹(inv_into (FSM.states M1) f q, x, y, inv_into (FSM.states M1) f q') ∈ FSM.transitions M1›*) ‹q ∈ states M2› (*‹q ∈ FSM.states M2›*) ‹q' ∈ states M2› (*‹(q'::'b) ∈ FSM.states (M2::('b, 'c, 'd) fsm)›*) assms(1) (*‹bij_betw f (FSM.states M1) (FSM.states M2)›*) assms(3) (*‹⟦?q ∈ FSM.states M1; ?q' ∈ FSM.states M1⟧ ⟹ ((?q, ?x, ?y, ?q') ∈ FSM.transitions M1) = ((f ?q, ?x, ?y, f ?q') ∈ FSM.transitions M2)›*) bij_betw_inv_into_right (*‹⟦bij_betw ?f ?A ?A'; ?a' ∈ ?A'⟧ ⟹ ?f (inv_into ?A ?f ?a') = ?a'›*) by fastforce qed qed ultimately show "LS M2 (f q) ⊆ LS M1 q" using language_equivalence_from_isomorphism_helper[of "(inv_into (states M1) f)" M2 M1, OF _ _ _ ‹f q ∈ states M2›] (*‹⟦bij_betw (inv_into (FSM.states M1) f) (FSM.states M2) (FSM.states M1); inv_into (FSM.states M1) f (FSM.initial M2) = FSM.initial M1; ⋀q x y q'. ⟦q ∈ FSM.states M2; q' ∈ FSM.states M2⟧ ⟹ ((q, x, y, q') ∈ FSM.transitions M2) = ((inv_into (FSM.states M1) f q, x, y, inv_into (FSM.states M1) f q') ∈ FSM.transitions M1)⟧ ⟹ LS M2 (f q) ⊆ LS M1 (inv_into (FSM.states M1) f (f q))›*) unfolding ‹(inv_into (FSM.states M1) f (f q)) = q› (*goal: ‹LS (M2::('b::type, 'c::type, 'd::type) fsm) ((f::'a::type ⇒ 'b::type) (q::'a::type)) ⊆ LS (M1::('a::type, 'c::type, 'd::type) fsm) q›*) by blast qed lemma language_equivalence_from_isomorphism_helper_reachable : assumes "bij_betw f (reachable_states M1) (reachable_states M2)" and "f (initial M1) = initial M2" and "⋀ q x y q' . q ∈ reachable_states M1 ⟹ q' ∈ reachable_states M1 ⟹ (q,x,y,q') ∈ transitions M1 ⟷ (f q,x,y,f q') ∈ transitions M2" shows "L M1 ⊆ L M2" proof (standard) (*goal: ‹⋀x. x ∈ L M1 ⟹ x ∈ L M2›*) fix io assume "io ∈ L M1" (*‹(io::('c × 'd) list) ∈ L (M1::('a, 'c, 'd) fsm)›*) then obtain p where "path M1 (initial M1) p" and "p_io p = io" (*goal: ‹(⋀p. ⟦path M1 (FSM.initial M1) p; p_io p = io⟧ ⟹ thesis) ⟹ thesis›*) by auto let ?f = "λ(q,x,y,q') . (f q,x,y,f q')" let ?p = "map ?f p" have "path M2 (initial M2) ?p" using ‹path M1 (initial M1) p› (*‹path M1 (FSM.initial M1) p›*) proof (induction p rule: rev_induct (*‹⟦?P []; ⋀x xs. ?P xs ⟹ ?P (xs @ [x])⟧ ⟹ ?P ?xs›*)) (*goals: 1. ‹path M1 (FSM.initial M1) [] ⟹ path M2 (FSM.initial M2) (map (λ(q, x, y, q'). (f q, x, y, f q')) [])› 2. ‹⋀x xs. ⟦path M1 (FSM.initial M1) xs ⟹ path M2 (FSM.initial M2) (map (λ(q, x, y, q'). (f q, x, y, f q')) xs); path M1 (FSM.initial M1) (xs @ [x])⟧ ⟹ path M2 (FSM.initial M2) (map (λ(q, x, y, q'). (f q, x, y, f q')) (xs @ [x]))›*) case Nil (*‹path (M1::('a::type, 'c::type, 'd::type) fsm) (FSM.initial M1) []›*) then show "?case" (*goal: ‹path M2 (FSM.initial M2) (map (λa. case a of (q, x, y, q') ⇒ (f q, x, y, f q')) [])›*) by auto next (*goal: ‹⋀x xs. ⟦path M1 (FSM.initial M1) xs ⟹ path M2 (FSM.initial M2) (map (λ(q, x, y, q'). (f q, x, y, f q')) xs); path M1 (FSM.initial M1) (xs @ [x])⟧ ⟹ path M2 (FSM.initial M2) (map (λ(q, x, y, q'). (f q, x, y, f q')) (xs @ [x]))›*) case (snoc a p) (*‹path M1 (FSM.initial M1) p ⟹ path M2 (FSM.initial M2) (map (λa. case a of (q, x, y, q') ⇒ (f q, x, y, f q')) p)› ‹path M1 (FSM.initial M1) (p @ [a])›*) then have "path M2 (initial M2) (map ?f p)" by auto have "target (initial M2) (map ?f p) = f (target (initial M1) p)" using ‹f (initial M1) = initial M2› (*‹(f::'a ⇒ 'b) (FSM.initial (M1::('a, 'c, 'd) fsm)) = FSM.initial (M2::('b, 'c, 'd) fsm)›*) assms(2) (*‹f (FSM.initial M1) = FSM.initial M2›*) apply ((induction p)[1]) (*goals: 1. ‹⟦f (FSM.initial M1) = FSM.initial M2; f (FSM.initial M1) = FSM.initial M2⟧ ⟹ target (FSM.initial M2) (map (λ(q, x, y, q'). (f q, x, y, f q')) []) = f (target (FSM.initial M1) [])› 2. ‹⋀a p. ⟦⟦f (FSM.initial M1) = FSM.initial M2; f (FSM.initial M1) = FSM.initial M2⟧ ⟹ target (FSM.initial M2) (map (λ(q, x, y, q'). (f q, x, y, f q')) p) = f (target (FSM.initial M1) p); f (FSM.initial M1) = FSM.initial M2; f (FSM.initial M1) = FSM.initial M2⟧ ⟹ target (FSM.initial M2) (map (λ(q, x, y, q'). (f q, x, y, f q')) (a # p)) = f (target (FSM.initial M1) (a # p))› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . then have "t_source (?f a) = target (initial M2) (map ?f p)" by (metis (no_types, lifting) case_prod_beta' (*‹(λ(x, y). ?f x y) = (λx. ?f (fst x) (snd x))›*) fst_conv (*‹fst (?x1.0, ?x2.0) = ?x1.0›*) path_append_transition_elim( (*‹path ?M ?q (?p @ [?t]) ⟹ t_source ?t = target ?q ?p›*) 3) snoc.prems (*‹path M1 (FSM.initial M1) (p @ [a])›*)) have "t_source a ∈ reachable_states M1" using ‹path M1 (FSM.initial M1) (p @ [a])› (*‹path M1 (FSM.initial M1) (p @ [a])›*) by (metis path_append_transition_elim( (*‹path ?M ?q (?p @ [?t]) ⟹ t_source ?t = target ?q ?p›*) 3) path_prefix (*‹path ?M ?q (?p1.0 @ ?p2.0) ⟹ path ?M ?q ?p1.0›*) reachable_states_intro (*‹path ?M (FSM.initial ?M) ?p ⟹ target (FSM.initial ?M) ?p ∈ reachable_states ?M›*)) have "t_target a ∈ reachable_states M1" using ‹path M1 (FSM.initial M1) (p @ [a])› (*‹path (M1::('a, 'c, 'd) fsm) (FSM.initial M1) ((p::('a × 'c × 'd × 'a) list) @ [a::'a × 'c × 'd × 'a])›*) by (meson ‹t_source a ∈ reachable_states M1› path_append_transition_elim( (*‹path ?M ?q (?p @ [?t]) ⟹ ?t ∈ FSM.transitions ?M›*) 2) reachable_states_next (*‹⟦?q ∈ reachable_states ?M; ?t ∈ FSM.transitions ?M; t_source ?t = ?q⟧ ⟹ t_target ?t ∈ reachable_states ?M›*)) have "a ∈ transitions M1" using snoc.prems (*‹path M1 (FSM.initial M1) (p @ [a])›*) by auto then have "?f a ∈ transitions M2" using assms(3)[OF ‹t_source a ∈ reachable_states M1› ‹t_target a ∈ reachable_states M1›] (*‹((t_source (a::'a::type × 'c::type × 'd::type × 'a::type), ?x::'c::type, ?y::'d::type, t_target a) ∈ FSM.transitions (M1::('a::type, 'c::type, 'd::type) fsm)) = (((f::'a::type ⇒ 'b::type) (t_source a), ?x, ?y, f (t_target a)) ∈ FSM.transitions (M2::('b::type, 'c::type, 'd::type) fsm))›*) by (metis (mono_tags, lifting) prod.case_eq_if (*‹(case ?prod of (x, xa) ⇒ ?f x xa) = ?f (fst ?prod) (snd ?prod)›*) prod.collapse (*‹(fst ?prod, snd ?prod) = ?prod›*)) have "map ?f (p@[a]) = (map ?f p)@[?f a]" by auto show "?case" (*goal: ‹path M2 (FSM.initial M2) (map (λa. case a of (q, x, y, q') ⇒ (f q, x, y, f q')) (p @ [a]))›*) unfolding ‹map ?f (p@[a]) = (map ?f p)@[?f a]› (*goal: ‹path M2 (FSM.initial M2) (map (λ(q, x, y, q'). (f q, x, y, f q')) p @ [case a of (q, xa, y, q') ⇒ (f q, xa, y, f q')])›*) using path_append_transition[OF ‹path M2 (initial M2) (map ?f p)› ‹?f a ∈ transitions M2› ‹t_source (?f a) = target (initial M2) (map ?f p)›] (*‹path (M2::('b, 'c, 'd) fsm) (FSM.initial M2) (map (λ(q::'a, x::'c, y::'d, q'::'a). ((f::'a ⇒ 'b) q, x, y, f q')) (p::('a × 'c × 'd × 'a) list) @ [case a::'a × 'c × 'd × 'a of (q::'a, xa::'c, y::'d, q'::'a) ⇒ (f q, xa, y, f q')])›*) by assumption qed moreover have "p_io ?p = io" using ‹p_io p = io› (*‹p_io p = io›*) apply ((induction p)[1]) (*goals: 1. ‹p_io [] = io ⟹ p_io (map (λ(q, x, y, q'). (f q, x, y, f q')) []) = io› 2. ‹⋀a p. ⟦p_io p = io ⟹ p_io (map (λ(q, x, y, q'). (f q, x, y, f q')) p) = io; p_io (a # p) = io⟧ ⟹ p_io (map (λ(q, x, y, q'). (f q, x, y, f q')) (a # p)) = io› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . ultimately show "io ∈ L M2" using language_state_containment (*‹⟦path ?M ?q ?p; p_io ?p = ?io⟧ ⟹ ?io ∈ LS ?M ?q›*) by fastforce qed lemma language_equivalence_from_isomorphism_reachable : assumes "bij_betw f (reachable_states M1) (reachable_states M2)" and "f (initial M1) = initial M2" and "⋀ q x y q' . q ∈ reachable_states M1 ⟹ q' ∈ reachable_states M1 ⟹ (q,x,y,q') ∈ transitions M1 ⟷ (f q,x,y,f q') ∈ transitions M2" shows "L M1 = L M2" proof (standard) (*goals: 1. ‹L M1 ⊆ L M2› 2. ‹L M2 ⊆ L M1›*) show "L M1 ⊆ L M2" using language_equivalence_from_isomorphism_helper_reachable[OF assms] (*‹⟦⋀q x y q'. ⟦q ∈ reachable_states M1; q' ∈ reachable_states M1⟧ ⟹ q ∈ reachable_states M1; ⋀q x y q'. ⟦q ∈ reachable_states M1; q' ∈ reachable_states M1⟧ ⟹ q' ∈ reachable_states M1⟧ ⟹ L M1 ⊆ L M2›*) . have "bij_betw (inv_into (reachable_states M1) f) (reachable_states M2) (reachable_states M1)" using bij_betw_inv_into[OF assms ( 1 )] (*‹bij_betw (inv_into (reachable_states M1) f) (reachable_states M2) (reachable_states M1)›*) . moreover have "(inv_into (reachable_states M1) f) (initial M2) = (initial M1)" using assms(1,2) (*‹bij_betw f (reachable_states M1) (reachable_states M2)› ‹f (FSM.initial M1) = FSM.initial M2›*) reachable_states_initial (*‹FSM.initial (?M::(?'a, ?'b, ?'c) fsm) ∈ reachable_states ?M›*) by (metis bij_betw_inv_into_left (*‹⟦bij_betw ?f ?A ?A'; ?a ∈ ?A⟧ ⟹ inv_into ?A ?f (?f ?a) = ?a›*)) moreover have "⋀ q x y q' . q ∈ reachable_states M2 ⟹ q' ∈ reachable_states M2 ⟹ (q,x,y,q') ∈ transitions M2 ⟷ ((inv_into (reachable_states M1) f) q,x,y,(inv_into (reachable_states M1) f) q') ∈ transitions M1" proof (standard) (*goals: 1. ‹⋀(q::'b::type) (x::'c::type) (y::'d::type) q'::'b::type. ⟦q ∈ reachable_states (M2::('b::type, 'c::type, 'd::type) fsm); q' ∈ reachable_states M2; (q, x, y, q') ∈ FSM.transitions M2⟧ ⟹ (inv_into (reachable_states (M1::('a::type, 'c::type, 'd::type) fsm)) (f::'a::type ⇒ 'b::type) q, x, y, inv_into (reachable_states M1) f q') ∈ FSM.transitions M1› 2. ‹⋀(q::'b::type) (x::'c::type) (y::'d::type) q'::'b::type. ⟦q ∈ reachable_states (M2::('b::type, 'c::type, 'd::type) fsm); q' ∈ reachable_states M2; (inv_into (reachable_states (M1::('a::type, 'c::type, 'd::type) fsm)) (f::'a::type ⇒ 'b::type) q, x, y, inv_into (reachable_states M1) f q') ∈ FSM.transitions M1⟧ ⟹ (q, x, y, q') ∈ FSM.transitions M2›*) fix q and x and y and q' assume "q ∈ reachable_states M2" and "q' ∈ reachable_states M2" (*‹(q::'b) ∈ reachable_states (M2::('b, 'c, 'd) fsm)› ‹(q'::'b) ∈ reachable_states (M2::('b, 'c, 'd) fsm)›*) show "(q,x,y,q') ∈ transitions M2 ⟹ ((inv_into (reachable_states M1) f) q,x,y,(inv_into (reachable_states M1) f) q') ∈ transitions M1" proof (-) (*goal: ‹(q, x, y, q') ∈ FSM.transitions M2 ⟹ (inv_into (reachable_states M1) f q, x, y, inv_into (reachable_states M1) f q') ∈ FSM.transitions M1›*) assume a1: "(q, x, y, q') ∈ FSM.transitions M2" (*‹(q::'b, x::'c, y::'d, q'::'b) ∈ FSM.transitions (M2::('b, 'c, 'd) fsm)›*) have f2: "∀f B A. ¬ bij_betw f B A ∨ (∀b. (b::'b) ∉ B ∨ (f b::'a) ∈ A)" using bij_betwE (*‹bij_betw ?f ?A ?B ⟹ ∀a∈?A. ?f a ∈ ?B›*) by blast then have f3: "inv_into (FSM.reachable_states M1) f q ∈ FSM.reachable_states M1" using ‹q ∈ FSM.reachable_states M2› (*‹q ∈ reachable_states M2›*) calculation(1) (*‹bij_betw (inv_into (reachable_states (M1::('a::type, 'c::type, 'd::type) fsm)) (f::'a::type ⇒ 'b::type)) (reachable_states (M2::('b::type, 'c::type, 'd::type) fsm)) (reachable_states M1)›*) by blast have "inv_into (FSM.reachable_states M1) f q' ∈ FSM.reachable_states M1" using f2 (*‹∀(f::'b ⇒ 'a) (B::'b set) A::'a set. ¬ bij_betw f B A ∨ (∀b::'b. b ∉ B ∨ f b ∈ A)›*) ‹q' ∈ FSM.reachable_states M2› (*‹(q'::'b) ∈ reachable_states (M2::('b, 'c, 'd) fsm)›*) calculation(1) (*‹bij_betw (inv_into (reachable_states M1) f) (reachable_states M2) (reachable_states M1)›*) by blast then show "?thesis" (*goal: ‹(inv_into (reachable_states M1) f q, x, y, inv_into (reachable_states M1) f q') ∈ FSM.transitions M1›*) using f3 (*‹inv_into (reachable_states (M1::('a, 'c, 'd) fsm)) (f::'a ⇒ 'b) (q::'b) ∈ reachable_states M1›*) a1 (*‹(q, x, y, q') ∈ FSM.transitions M2›*) ‹q ∈ FSM.reachable_states M2› (*‹q ∈ reachable_states M2›*) ‹q' ∈ FSM.reachable_states M2› (*‹q' ∈ reachable_states M2›*) assms(1) (*‹bij_betw f (reachable_states M1) (reachable_states M2)›*) assms(3) (*‹⟦?q ∈ reachable_states M1; ?q' ∈ reachable_states M1⟧ ⟹ ((?q, ?x, ?y, ?q') ∈ FSM.transitions M1) = ((f ?q, ?x, ?y, f ?q') ∈ FSM.transitions M2)›*) bij_betw_inv_into_right (*‹⟦bij_betw ?f ?A ?A'; ?a' ∈ ?A'⟧ ⟹ ?f (inv_into ?A ?f ?a') = ?a'›*) by fastforce qed show "((inv_into (reachable_states M1) f) q,x,y,(inv_into (reachable_states M1) f) q') ∈ transitions M1 ⟹ (q,x,y,q') ∈ transitions M2" proof (-) (*goal: ‹(inv_into (reachable_states M1) f q, x, y, inv_into (reachable_states M1) f q') ∈ FSM.transitions M1 ⟹ (q, x, y, q') ∈ FSM.transitions M2›*) assume a1: "(inv_into (FSM.reachable_states M1) f q, x, y, inv_into (FSM.reachable_states M1) f q') ∈ FSM.transitions M1" (*‹(inv_into (reachable_states (M1::('a, 'c, 'd) fsm)) (f::'a ⇒ 'b) (q::'b), x::'c, y::'d, inv_into (reachable_states M1) f (q'::'b)) ∈ FSM.transitions M1›*) have f2: "∀f B A. ¬ bij_betw f B A ∨ (∀b. (b::'b) ∉ B ∨ (f b::'a) ∈ A)" by (metis (full_types) bij_betwE (*‹bij_betw ?f ?A ?B ⟹ ∀a∈?A. ?f a ∈ ?B›*)) then have f3: "inv_into (FSM.reachable_states M1) f q' ∈ FSM.reachable_states M1" using ‹q' ∈ FSM.reachable_states M2› (*‹q' ∈ reachable_states M2›*) calculation(1) (*‹bij_betw (inv_into (reachable_states M1) f) (reachable_states M2) (reachable_states M1)›*) by blast have "inv_into (FSM.reachable_states M1) f q ∈ FSM.reachable_states M1" using f2 (*‹∀f B A. ¬ bij_betw f B A ∨ (∀b. b ∉ B ∨ f b ∈ A)›*) ‹q ∈ FSM.reachable_states M2› (*‹q ∈ reachable_states M2›*) calculation(1) (*‹bij_betw (inv_into (reachable_states (M1::('a, 'c, 'd) fsm)) (f::'a ⇒ 'b)) (reachable_states (M2::('b, 'c, 'd) fsm)) (reachable_states M1)›*) by blast then show "?thesis" (*goal: ‹(q, x, y, q') ∈ FSM.transitions M2›*) using f3 (*‹inv_into (reachable_states M1) f q' ∈ reachable_states M1›*) a1 (*‹(inv_into (reachable_states M1) f q, x, y, inv_into (reachable_states M1) f q') ∈ FSM.transitions M1›*) ‹q ∈ FSM.reachable_states M2› (*‹(q::'b::type) ∈ reachable_states (M2::('b::type, 'c::type, 'd::type) fsm)›*) ‹q' ∈ FSM.reachable_states M2› (*‹q' ∈ reachable_states M2›*) assms(1) (*‹bij_betw (f::'a ⇒ 'b) (reachable_states (M1::('a, 'c, 'd) fsm)) (reachable_states (M2::('b, 'c, 'd) fsm))›*) assms(3) (*‹⟦?q ∈ reachable_states M1; ?q' ∈ reachable_states M1⟧ ⟹ ((?q, ?x, ?y, ?q') ∈ FSM.transitions M1) = ((f ?q, ?x, ?y, f ?q') ∈ FSM.transitions M2)›*) bij_betw_inv_into_right (*‹⟦bij_betw ?f ?A ?A'; ?a' ∈ ?A'⟧ ⟹ ?f (inv_into ?A ?f ?a') = ?a'›*) by fastforce qed qed ultimately show "L M2 ⊆ L M1" using language_equivalence_from_isomorphism_helper_reachable[of "(inv_into (reachable_states M1) f)" M2 M1] (*‹⟦bij_betw (inv_into (reachable_states M1) f) (reachable_states M2) (reachable_states M1); inv_into (reachable_states M1) f (FSM.initial M2) = FSM.initial M1; ⋀q x y q'. ⟦q ∈ reachable_states M2; q' ∈ reachable_states M2⟧ ⟹ ((q, x, y, q') ∈ FSM.transitions M2) = ((inv_into (reachable_states M1) f q, x, y, inv_into (reachable_states M1) f q') ∈ FSM.transitions M1)⟧ ⟹ L M2 ⊆ L M1›*) by blast qed lemma language_empty_io : assumes "inputs M = {} ∨ outputs M = {}" shows "L M = {[]}" proof (-) (*goal: ‹L M = {[]}›*) have "transitions M = {}" using assms (*‹FSM.inputs M = {} ∨ FSM.outputs M = {}›*) fsm_transition_input (*‹?t ∈ FSM.transitions ?M ⟹ t_input ?t ∈ FSM.inputs ?M›*) fsm_transition_output (*‹(?t::?'a × ?'b × ?'c × ?'a) ∈ FSM.transitions (?M::(?'a, ?'b, ?'c) fsm) ⟹ t_output ?t ∈ FSM.outputs ?M›*) by auto then have "⋀ p . path M (initial M) p ⟹ p = []" by (metis empty_iff (*‹(?c ∈ {}) = False›*) path.cases (*‹⟦path ?a1.0 ?a2.0 ?a3.0; ⋀q M. ⟦?a1.0 = M; ?a2.0 = q; ?a3.0 = []; q ∈ FSM.states M⟧ ⟹ ?P; ⋀t M ts. ⟦?a1.0 = M; ?a2.0 = t_source t; ?a3.0 = t # ts; t ∈ FSM.transitions M; path M (t_target t) ts⟧ ⟹ ?P⟧ ⟹ ?P›*)) then show "?thesis" (*goal: ‹L (M::('b, 'a, 'c) fsm) = {[]}›*) unfolding LS.simps (*goal: ‹{p_io p |p. path M (FSM.initial M) p} = {[]}›*) by blast qed subsection ‹Basic FSM Properties› subsubsection ‹Completely Specified› fun completely_specified :: "('a,'b,'c) fsm ⇒ bool" where "completely_specified M = (∀ q ∈ states M . ∀ x ∈ inputs M . ∃ t ∈ transitions M . t_source t = q ∧ t_input t = x)" lemma completely_specified_alt_def : "completely_specified M = (∀ q ∈ states M . ∀ x ∈ inputs M . ∃ q' y . (q,x,y,q') ∈ transitions M)" by force lemma completely_specified_alt_def_h : "completely_specified M = (∀ q ∈ states M . ∀ x ∈ inputs M . h M (q,x) ≠ {})" by force fun completely_specified_state :: "('a,'b,'c) fsm ⇒ 'a ⇒ bool" where "completely_specified_state M q = (∀ x ∈ inputs M . ∃ t ∈ transitions M . t_source t = q ∧ t_input t = x)" lemma completely_specified_states : "completely_specified M = (∀ q ∈ states M . completely_specified_state M q)" unfolding completely_specified.simps completely_specified_state.simps (*goal: ‹(∀q::'a∈FSM.states (M::('a, 'b, 'c) fsm). ∀x::'b∈FSM.inputs M. ∃t::'a × 'b × 'c × 'a∈FSM.transitions M. t_source t = q ∧ t_input t = x) = (∀q::'a∈FSM.states M. ∀x::'b∈FSM.inputs M. ∃t::'a × 'b × 'c × 'a∈FSM.transitions M. t_source t = q ∧ t_input t = x)›*) by force lemma completely_specified_state_alt_def_h : "completely_specified_state M q = (∀ x ∈ inputs M . h M (q,x) ≠ {})" by force lemma completely_specified_path_extension : assumes "completely_specified M" and "q ∈ states M" and "path M q p" and "x ∈ (inputs M)" obtains t where "t ∈ transitions M" and "t_input t = x" and "t_source t = target q p" proof (-) (*goal: ‹(⋀t. ⟦t ∈ FSM.transitions M; t_input t = x; t_source t = target q p⟧ ⟹ thesis) ⟹ thesis›*) have "target q p ∈ states M" using path_target_is_state (*‹path (?M::(?'a, ?'b, ?'c) fsm) (?q::?'a) (?p::(?'a × ?'b × ?'c × ?'a) list) ⟹ target ?q ?p ∈ FSM.states ?M›*) ‹path M q p› (*‹path M q p›*) by metis then obtain t where "t ∈ transitions M" and "t_input t = x" and "t_source t = target q p" (*goal: ‹(⋀t. ⟦t ∈ FSM.transitions M; t_input t = x; t_source t = target q p⟧ ⟹ thesis) ⟹ thesis›*) using ‹completely_specified M› (*‹completely_specified M›*) ‹x ∈ (inputs M)› (*‹x ∈ FSM.inputs M›*) unfolding completely_specified.simps (*goal: ‹(⋀t. ⟦t ∈ FSM.transitions M; t_input t = x; t_source t = target q p⟧ ⟹ thesis) ⟹ thesis›*) by blast then show "?thesis" (*goal: ‹thesis›*) using that (*‹⟦?t ∈ FSM.transitions M; t_input ?t = x; t_source ?t = target q p⟧ ⟹ thesis›*) by blast qed lemma completely_specified_language_extension : assumes "completely_specified M" and "q ∈ states M" and "io ∈ LS M q" and "x ∈ (inputs M)" obtains y where "io@[(x,y)] ∈ LS M q" proof (-) (*goal: ‹(⋀y::'c::type. (io::('b::type × 'c::type) list) @ [(x::'b::type, y)] ∈ LS (M::('a::type, 'b::type, 'c::type) fsm) (q::'a::type) ⟹ thesis::bool) ⟹ thesis›*) obtain p where "path M q p" and "p_io p = io" (*goal: ‹(⋀p. ⟦path M q p; p_io p = io⟧ ⟹ thesis) ⟹ thesis›*) using ‹io ∈ LS M q› (*‹io ∈ LS M q›*) by auto moreover obtain t where "t ∈ transitions M" and "t_input t = x" and "t_source t = target q p" (*goal: ‹(⋀t. ⟦t ∈ FSM.transitions M; t_input t = x; t_source t = target q p⟧ ⟹ thesis) ⟹ thesis›*) using completely_specified_path_extension[OF assms ( 1 , 2 ) ‹path M q p› assms ( 4 )] (*‹(⋀t. ⟦t ∈ FSM.transitions M; t_input t = x; t_source t = target q p⟧ ⟹ ?thesis) ⟹ ?thesis›*) by blast ultimately have "path M q (p@[t])" and "p_io (p@[t]) = io@[(x,t_output t)]" apply - (*goals: 1. ‹⟦path M q p; p_io p = io; t ∈ FSM.transitions M; t_input t = x; t_source t = target q p⟧ ⟹ path M q (p @ [t])› 2. ‹⟦path M q p; p_io p = io; t ∈ FSM.transitions M; t_input t = x; t_source t = target q p⟧ ⟹ p_io (p @ [t]) = io @ [(x, t_output t)]› discuss goal 1*) apply (simp add: path_append_transition (*‹⟦path ?M ?q ?p; ?t ∈ FSM.transitions ?M; t_source ?t = target ?q ?p⟧ ⟹ path ?M ?q (?p @ [?t])›*)) (*discuss goal 2*) apply (simp add: path_append_transition (*‹⟦path ?M ?q ?p; ?t ∈ FSM.transitions ?M; t_source ?t = target ?q ?p⟧ ⟹ path ?M ?q (?p @ [?t])›*)) (*proven 2 subgoals*) . then have "io@[(x,t_output t)] ∈ LS M q" using language_state_containment[of M q "p@[t]" "io@[(x,t_output t)]"] (*‹⟦path M q (p @ [t]); p_io (p @ [t]) = io @ [(x, t_output t)]⟧ ⟹ io @ [(x, t_output t)] ∈ LS M q›*) by auto then show "?thesis" (*goal: ‹thesis›*) using that (*‹io @ [(x, ?y)] ∈ LS M q ⟹ thesis›*) by blast qed lemma path_of_length_ex : assumes "completely_specified M" and "q ∈ states M" and "inputs M ≠ {}" shows "∃ p . path M q p ∧ length p = k" using assms(2) (*‹(q::'a) ∈ FSM.states (M::('a, 'b, 'c) fsm)›*) proof (induction k arbitrary: q) (*goals: 1. ‹⋀q. q ∈ FSM.states M ⟹ ∃p. path M q p ∧ length p = 0› 2. ‹⋀k q. ⟦⋀q. q ∈ FSM.states M ⟹ ∃p. path M q p ∧ length p = k; q ∈ FSM.states M⟧ ⟹ ∃p. path M q p ∧ length p = Suc k›*) case 0 (*‹q ∈ FSM.states M›*) then show "?case" (*goal: ‹∃p::('a::type × 'b::type × 'c::type × 'a::type) list. path (M::('a::type, 'b::type, 'c::type) fsm) (q::'a::type) p ∧ length p = (0::nat)›*) by auto next (*goal: ‹⋀k q. ⟦⋀q. q ∈ FSM.states M ⟹ ∃p. path M q p ∧ length p = k; q ∈ FSM.states M⟧ ⟹ ∃p. path M q p ∧ length p = Suc k›*) case (Suc k) (*‹?q ∈ FSM.states M ⟹ ∃p. path M ?q p ∧ length p = k› ‹q ∈ FSM.states M›*) obtain t where "t_source t = q" and "t ∈ transitions M" (*goal: ‹(⋀t. ⟦t_source t = q; t ∈ FSM.transitions M⟧ ⟹ thesis) ⟹ thesis›*) by (meson Suc.prems (*‹q ∈ FSM.states M›*) assms( (*‹completely_specified M›*) 1) assms( (*‹FSM.inputs M ≠ {}›*) 3) completely_specified.simps (*‹completely_specified ?M = (∀q∈FSM.states ?M. ∀x∈FSM.inputs ?M. ∃t∈FSM.transitions ?M. t_source t = q ∧ t_input t = x)›*) equals0I (*‹(⋀y. y ∈ ?A ⟹ False) ⟹ ?A = {}›*)) then have "t_target t ∈ states M" using fsm_transition_target (*‹(?t::?'a × ?'b × ?'c × ?'a) ∈ FSM.transitions (?M::(?'a, ?'b, ?'c) fsm) ⟹ t_target ?t ∈ FSM.states ?M›*) by blast then obtain p where "path M (t_target t) p ∧ length p = k" (*goal: ‹(⋀p. path M (t_target t) p ∧ length p = k ⟹ thesis) ⟹ thesis›*) using Suc.IH (*‹?q ∈ FSM.states M ⟹ ∃p. path M ?q p ∧ length p = k›*) by blast then show "?case" (*goal: ‹∃p. path M q p ∧ length p = Suc k›*) using ‹t_source t = q› (*‹t_source t = q›*) ‹t ∈ transitions M› (*‹t ∈ FSM.transitions M›*) by auto qed subsubsection ‹Deterministic› fun deterministic :: "('a,'b,'c) fsm ⇒ bool" where "deterministic M = (∀ t1 ∈ transitions M . ∀ t2 ∈ transitions M . (t_source t1 = t_source t2 ∧ t_input t1 = t_input t2) ⟶ (t_output t1 = t_output t2 ∧ t_target t1 = t_target t2))" lemma deterministic_alt_def : "deterministic M = (∀ q1 x y' y'' q1' q1'' . (q1,x,y',q1') ∈ transitions M ∧ (q1,x,y'',q1'') ∈ transitions M ⟶ y' = y'' ∧ q1' = q1'')" by auto lemma deterministic_alt_def_h : "deterministic M = (∀ q1 x yq yq' . (yq ∈ h M (q1,x) ∧ yq' ∈ h M (q1,x)) ⟶ yq = yq')" by auto subsubsection ‹Observable› fun observable :: "('a,'b,'c) fsm ⇒ bool" where "observable M = (∀ t1 ∈ transitions M . ∀ t2 ∈ transitions M . (t_source t1 = t_source t2 ∧ t_input t1 = t_input t2 ∧ t_output t1 = t_output t2) ⟶ t_target t1 = t_target t2)" lemma observable_alt_def : "observable M = (∀ q1 x y q1' q1'' . (q1,x,y,q1') ∈ transitions M ∧ (q1,x,y,q1'') ∈ transitions M ⟶ q1' = q1'')" by auto lemma observable_alt_def_h : "observable M = (∀ q1 x yq yq' . (yq ∈ h M (q1,x) ∧ yq' ∈ h M (q1,x)) ⟶ fst yq = fst yq' ⟶ snd yq = snd yq')" by auto lemma language_append_path_ob : assumes "io@[(x,y)] ∈ L M" obtains p t where "path M (initial M) (p@[t])" and "p_io p = io" and "t_input t = x" and "t_output t = y" proof (-) (*goal: ‹(⋀(p::('c × 'a × 'b × 'c) list) t::'c × 'a × 'b × 'c. ⟦path (M::('c, 'a, 'b) fsm) (FSM.initial M) (p @ [t]); p_io p = (io::('a × 'b) list); t_input t = (x::'a); t_output t = (y::'b)⟧ ⟹ thesis::bool) ⟹ thesis›*) obtain p and p2 where "path M (initial M) p" and "path M (target (initial M) p) p2" and "p_io p = io" and "p_io p2 = [(x,y)]" (*goal: ‹(⋀(p::('c × 'a × 'b × 'c) list) p2::('c × 'a × 'b × 'c) list. ⟦path (M::('c, 'a, 'b) fsm) (FSM.initial M) p; path M (target (FSM.initial M) p) p2; p_io p = (io::('a × 'b) list); p_io p2 = [(x::'a, y::'b)]⟧ ⟹ thesis::bool) ⟹ thesis›*) using language_state_split[OF assms] (*‹(⋀p1 p2. ⟦path M (FSM.initial M) p1; path M (target (FSM.initial M) p1) p2; p_io p1 = io; p_io p2 = [(x, y)]⟧ ⟹ ?thesis) ⟹ ?thesis›*) by blast obtain t where "p2 = [t]" and "t_input t = x" and "t_output t = y" (*goal: ‹(⋀t. ⟦p2 = [t]; t_input t = x; t_output t = y⟧ ⟹ thesis) ⟹ thesis›*) using ‹p_io p2 = [(x,y)]› (*‹p_io p2 = [(x, y)]›*) by auto have "path M (initial M) (p@[t])" using ‹path M (initial M) p› (*‹path M (FSM.initial M) p›*) ‹path M (target (initial M) p) p2› (*‹path M (target (FSM.initial M) p) p2›*) unfolding ‹p2 = [t]› (*goal: ‹path M (FSM.initial M) (p @ [t])›*) by auto then show "?thesis" (*goal: ‹thesis›*) using that[OF _ ‹p_io p = io› ‹t_input t = x› ‹t_output t = y›] (*‹path M (FSM.initial M) (p @ [t]) ⟹ thesis›*) by simp qed subsubsection ‹Single Input› (* each state has at most one input, but may have none *) fun single_input :: "('a,'b,'c) fsm ⇒ bool" where "single_input M = (∀ t1 ∈ transitions M . ∀ t2 ∈ transitions M . t_source t1 = t_source t2 ⟶ t_input t1 = t_input t2)" lemma single_input_alt_def : "single_input M = (∀ q1 x x' y y' q1' q1'' . (q1,x,y,q1') ∈ transitions M ∧ (q1,x',y',q1'') ∈ transitions M ⟶ x = x')" by fastforce lemma single_input_alt_def_h : "single_input M = (∀ q x x' . (h M (q,x) ≠ {} ∧ h M (q,x') ≠ {}) ⟶ x = x')" by force subsubsection ‹Output Complete› fun output_complete :: "('a,'b,'c) fsm ⇒ bool" where "output_complete M = (∀ t ∈ transitions M . ∀ y ∈ outputs M . ∃ t' ∈ transitions M . t_source t = t_source t' ∧ t_input t = t_input t' ∧ t_output t' = y)" lemma output_complete_alt_def : "output_complete M = (∀ q x . (∃ y q' . (q,x,y,q') ∈ transitions M) ⟶ (∀ y ∈ (outputs M) . ∃ q' . (q,x,y,q') ∈ transitions M))" by force lemma output_complete_alt_def_h : "output_complete M = (∀ q x . h M (q,x) ≠ {} ⟶ (∀ y ∈ outputs M . ∃ q' . (y,q') ∈ h M (q,x)))" by force subsubsection ‹Acyclic› fun acyclic :: "('a,'b,'c) fsm ⇒ bool" where "acyclic M = (∀ p . path M (initial M) p ⟶ distinct (visited_states (initial M) p))" lemma visited_states_length : "length (visited_states q p) = Suc (length p)" by auto lemma visited_states_take : "(take (Suc n) (visited_states q p)) = (visited_states q (take n p))" proof (induction p 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. ‹take (Suc n) (visited_states q []) = visited_states q (take n [])› 2. ‹⋀x xs. take (Suc n) (visited_states q xs) = visited_states q (take n xs) ⟹ take (Suc n) (visited_states q (xs @ [x])) = visited_states q (take n (xs @ [x]))›*) case Nil (*no hyothesis introduced yet*) then show "?case" (*goal: ‹take (Suc n) (visited_states q []) = visited_states q (take n [])›*) by auto next (*goal: ‹⋀x xs. take (Suc n) (visited_states q xs) = visited_states q (take n xs) ⟹ take (Suc n) (visited_states q (xs @ [x])) = visited_states q (take n (xs @ [x]))›*) case (snoc x xs) (*‹take (Suc (n::nat)) (visited_states (q::'a) (xs::('a × 'b × 'c × 'a) list)) = visited_states q (take n xs)›*) then show "?case" (*goal: ‹take (Suc (n::nat)) (visited_states (q::'a) ((xs::('a × 'b × 'c × 'a) list) @ [x::'a × 'b × 'c × 'a])) = visited_states q (take n (xs @ [x]))›*) apply ((cases "n ≤ length xs")[1]) (*goals: 1. ‹⟦take (Suc (n::nat)) (visited_states (q::'a) (xs::('a × 'b × 'c × 'a) list)) = visited_states q (take n xs); n ≤ length xs⟧ ⟹ take (Suc n) (visited_states q (xs @ [x::'a × 'b × 'c × 'a])) = visited_states q (take n (xs @ [x]))› 2. ‹⟦take (Suc (n::nat)) (visited_states (q::'a) (xs::('a × 'b × 'c × 'a) list)) = visited_states q (take n xs); ¬ n ≤ length xs⟧ ⟹ take (Suc n) (visited_states q (xs @ [x::'a × 'b × 'c × 'a])) = visited_states q (take n (xs @ [x]))› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . qed (* very inefficient calculation *) lemma acyclic_code[code] : "acyclic M = (¬(∃ p ∈ (acyclic_paths_up_to_length M (initial M) (size M - 1)) . ∃ t ∈ transitions M . t_source t = target (initial M) p ∧ t_target t ∈ set (visited_states (initial M) p)))" proof (-) (*goal: ‹FSM.acyclic (M::('a::type, 'b::type, 'c::type) fsm) = (¬ (∃p::('a::type × 'b::type × 'c::type × 'a::type) list∈acyclic_paths_up_to_length M (FSM.initial M) (FSM.size M - (1::nat)). ∃t::'a::type × 'b::type × 'c::type × 'a::type∈FSM.transitions M. t_source t = target (FSM.initial M) p ∧ t_target t ∈ set (visited_states (FSM.initial M) p)))›*) have "(∃ p ∈ (acyclic_paths_up_to_length M (initial M) (size M - 1)) . ∃ t ∈ transitions M . t_source t = target (initial M) p ∧ t_target t ∈ set (visited_states (initial M) p)) ⟹ ¬ FSM.acyclic M" proof (-) (*goal: ‹∃p∈acyclic_paths_up_to_length M (FSM.initial M) (FSM.size M - 1). ∃t∈FSM.transitions M. t_source t = target (FSM.initial M) p ∧ t_target t ∈ set (visited_states (FSM.initial M) p) ⟹ ¬ FSM.acyclic M›*) assume "(∃ p ∈ (acyclic_paths_up_to_length M (initial M) (size M - 1)) . ∃ t ∈ transitions M . t_source t = target (initial M) p ∧ t_target t ∈ set (visited_states (initial M) p))" (*‹∃p::('a × 'b × 'c × 'a) list∈acyclic_paths_up_to_length (M::('a, 'b, 'c) fsm) (FSM.initial M) (FSM.size M - (1::nat)). ∃t::'a × 'b × 'c × 'a∈FSM.transitions M. t_source t = target (FSM.initial M) p ∧ t_target t ∈ set (visited_states (FSM.initial M) p)›*) then obtain p and t where "path M (initial M) p" and "distinct (visited_states (initial M) p)" and "t ∈ transitions M" and "t_source t = target (initial M) p" and "t_target t ∈ set (visited_states (initial M) p)" (*goal: ‹(⋀p t. ⟦path M (FSM.initial M) p; distinct (visited_states (FSM.initial M) p); t ∈ FSM.transitions M; t_source t = target (FSM.initial M) p; t_target t ∈ set (visited_states (FSM.initial M) p)⟧ ⟹ thesis) ⟹ thesis›*) unfolding acyclic_paths_set (*goal: ‹(⋀p t. ⟦path M (FSM.initial M) p; distinct (visited_states (FSM.initial M) p); t ∈ FSM.transitions M; t_source t = target (FSM.initial M) p; t_target t ∈ set (visited_states (FSM.initial M) p)⟧ ⟹ thesis) ⟹ thesis›*) by blast then have "path M (initial M) (p@[t])" by (simp add: path_append_transition (*‹⟦path ?M ?q ?p; ?t ∈ FSM.transitions ?M; t_source ?t = target ?q ?p⟧ ⟹ path ?M ?q (?p @ [?t])›*)) moreover have "¬ (distinct (visited_states (initial M) (p@[t])))" using ‹t_target t ∈ set (visited_states (initial M) p)› (*‹t_target t ∈ set (visited_states (FSM.initial M) p)›*) by auto ultimately show "¬ FSM.acyclic M" by (meson acyclic.elims( (*‹⟦FSM.acyclic ?x; ⋀M. ⟦?x = M; ∀p. path M (FSM.initial M) p ⟶ distinct (visited_states (FSM.initial M) p)⟧ ⟹ ?P⟧ ⟹ ?P›*) 2)) qed moreover have "¬ FSM.acyclic M ⟹ (∃ p ∈ (acyclic_paths_up_to_length M (initial M) (size M - 1)) . ∃ t ∈ transitions M . t_source t = target (initial M) p ∧ t_target t ∈ set (visited_states (initial M) p))" proof (-) (*goal: ‹¬ FSM.acyclic M ⟹ ∃p∈acyclic_paths_up_to_length M (FSM.initial M) (FSM.size M - 1). ∃t∈FSM.transitions M. t_source t = target (FSM.initial M) p ∧ t_target t ∈ set (visited_states (FSM.initial M) p)›*) assume "¬ FSM.acyclic M" (*‹¬ FSM.acyclic (M::('a, 'b, 'c) fsm)›*) then obtain p where "path M (initial M) p" and "¬ distinct (visited_states (initial M) p)" (*goal: ‹(⋀p. ⟦path M (FSM.initial M) p; ¬ distinct (visited_states (FSM.initial M) p)⟧ ⟹ thesis) ⟹ thesis›*) by auto then obtain n where "distinct (take (Suc n) (visited_states (initial M) p))" and "¬ distinct (take (Suc (Suc n)) (visited_states (initial M) p))" (*goal: ‹(⋀n. ⟦distinct (take (Suc n) (visited_states (FSM.initial M) p)); ¬ distinct (take (Suc (Suc n)) (visited_states (FSM.initial M) p))⟧ ⟹ thesis) ⟹ thesis›*) using maximal_distinct_prefix (*‹⟦¬ distinct ?xs; ⋀n. ⟦distinct (take (Suc n) ?xs); ¬ distinct (take (Suc (Suc n)) ?xs)⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*) by blast then have "distinct (visited_states (initial M) (take n p))" and "¬ distinct (visited_states (initial M)(take (Suc n) p))" unfolding visited_states_take (*goals: 1. ‹distinct (visited_states (FSM.initial M) (take n p))› 2. ‹¬ distinct (visited_states (FSM.initial M) (take (Suc n) p))›*) apply - (*goals: 1. ‹⟦distinct (visited_states (FSM.initial (M::('a, 'b, 'c) fsm)) (take (n::nat) (p::('a × 'b × 'c × 'a) list))); ¬ distinct (visited_states (FSM.initial M) (take (Suc n) p))⟧ ⟹ distinct (visited_states (FSM.initial M) (take n p))› 2. ‹⟦distinct (visited_states (FSM.initial (M::('a, 'b, 'c) fsm)) (take (n::nat) (p::('a × 'b × 'c × 'a) list))); ¬ distinct (visited_states (FSM.initial M) (take (Suc n) p))⟧ ⟹ ¬ distinct (visited_states (FSM.initial M) (take (Suc n) p))› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) . then obtain p' and t' where "*": "take n p = p'" and "**": "take (Suc n) p = p' @ [t']" (*goal: ‹(⋀p' t'. ⟦take n p = p'; take (Suc n) p = p' @ [t']⟧ ⟹ thesis) ⟹ thesis›*) by (metis Suc_less_eq (*‹(Suc (?m::nat) < Suc (?n::nat)) = (?m < ?n)›*) ‹¬ distinct (visited_states (FSM.initial M) p)› le_imp_less_Suc (*‹(?m::nat) ≤ (?n::nat) ⟹ ?m < Suc ?n›*) not_less_eq_eq (*‹(¬ (?m::nat) ≤ (?n::nat)) = (Suc ?n ≤ ?m)›*) take_all (*‹length (?xs::?'a::type list) ≤ (?n::nat) ⟹ take ?n ?xs = ?xs›*) take_hd_drop (*‹(?n::nat) < length (?xs::?'a::type list) ⟹ take ?n ?xs @ [hd (drop ?n ?xs)] = take (Suc ?n) ?xs›*)) have "***": "visited_states (FSM.initial M) (p' @ [t']) = (visited_states (FSM.initial M) p')@[t_target t']" by auto have "path M (initial M) p'" using "*" (*‹take n p = p'›*) ‹path M (initial M) p› (*‹path (M::('a::type, 'b::type, 'c::type) fsm) (FSM.initial M) (p::('a::type × 'b::type × 'c::type × 'a::type) list)›*) by (metis append_take_drop_id (*‹take ?n ?xs @ drop ?n ?xs = ?xs›*) path_prefix (*‹path ?M ?q (?p1.0 @ ?p2.0) ⟹ path ?M ?q ?p1.0›*)) then have "p' ∈ (acyclic_paths_up_to_length M (initial M) (size M - 1))" using ‹distinct (visited_states (initial M) (take n p))› (*‹distinct (visited_states (FSM.initial M) (take n p))›*) unfolding "*" acyclic_paths_set (*goal: ‹p' ∈ {p. path M (FSM.initial M) p ∧ distinct (visited_states (FSM.initial M) p)}›*) by blast moreover have "t' ∈ transitions M ∧ t_source t' = target (initial M) p'" using "*" (*‹take n p = p'›*) "**" (*‹take (Suc n) p = p' @ [t']›*) ‹path M (initial M) p› (*‹path M (FSM.initial M) p›*) by (metis append_take_drop_id (*‹take ?n ?xs @ drop ?n ?xs = ?xs›*) path_append_elim (*‹⟦path ?M ?q (?p1.0 @ ?p2.0); ⟦path ?M ?q ?p1.0; path ?M (target ?q ?p1.0) ?p2.0⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*) path_cons_elim (*‹⟦path ?M ?q (?t # ?ts); ⟦?q = t_source ?t; ?t ∈ FSM.transitions ?M; path ?M (t_target ?t) ?ts⟧ ⟹ ?P⟧ ⟹ ?P›*)) moreover have "t_target t' ∈ set (visited_states (initial M) p')" using ‹distinct (visited_states (initial M) (take n p))› (*‹distinct (visited_states (FSM.initial M) (take n p))›*) ‹¬ distinct (visited_states (initial M)(take (Suc n) p))› (*‹¬ distinct (visited_states (FSM.initial M) (take (Suc n) p))›*) unfolding "*" "**" "***" (*goal: ‹t_target t' ∈ set (visited_states (FSM.initial M) p')›*) by auto ultimately show "(∃ p ∈ (acyclic_paths_up_to_length M (initial M) (size M - 1)) . ∃ t ∈ transitions M . t_source t = target (initial M) p ∧ t_target t ∈ set (visited_states (initial M) p))" by blast qed ultimately show "?thesis" (*goal: ‹FSM.acyclic (M::('a, 'b, 'c) fsm) = (¬ (∃p::('a × 'b × 'c × 'a) list∈acyclic_paths_up_to_length M (FSM.initial M) (FSM.size M - (1::nat)). ∃t::'a × 'b × 'c × 'a∈FSM.transitions M. t_source t = target (FSM.initial M) p ∧ t_target t ∈ set (visited_states (FSM.initial M) p)))›*) by blast qed lemma acyclic_alt_def : "acyclic M = finite (L M)" proof (standard) (*goals: 1. ‹FSM.acyclic M ⟹ finite (L M)› 2. ‹finite (L M) ⟹ FSM.acyclic M›*) show "acyclic M ⟹ finite (L M)" proof (-) (*goal: ‹FSM.acyclic M ⟹ finite (L M)›*) assume "acyclic M" (*‹FSM.acyclic (M::('a, 'b, 'c) fsm)›*) then have "{ p . path M (initial M) p} ⊆ (acyclic_paths_up_to_length M (initial M) (size M - 1))" unfolding acyclic_paths_set (*goal: ‹{p. path M (FSM.initial M) p} ⊆ {p. path M (FSM.initial M) p ∧ distinct (visited_states (FSM.initial M) p)}›*) by auto moreover have "finite (acyclic_paths_up_to_length M (initial M) (size M - 1))" unfolding acyclic_paths_up_to_length.simps (*goal: ‹finite {p. path M (FSM.initial M) p ∧ length p ≤ FSM.size M - 1 ∧ distinct (visited_states (FSM.initial M) p)}›*) using paths_finite[of M "initial M" "size M - 1"] (*‹finite {p::('a × 'b × 'c × 'a) list. path (M::('a, 'b, 'c) fsm) (FSM.initial M) p ∧ length p ≤ FSM.size M - (1::nat)}›*) by (metis (mono_tags, lifting) Collect_cong (*‹(⋀x::?'a. (?P::?'a ⇒ bool) x = (?Q::?'a ⇒ bool) x) ⟹ {x::?'a. ?P x} = {x::?'a. ?Q x}›*) ‹FSM.acyclic M› acyclic.elims( (*‹⟦FSM.acyclic (?x::(?'a, ?'b, ?'c) fsm); ⋀M::(?'a, ?'b, ?'c) fsm. ⟦?x = M; ∀p::(?'a × ?'b × ?'c × ?'a) list. path M (FSM.initial M) p ⟶ distinct (visited_states (FSM.initial M) p)⟧ ⟹ ?P::bool⟧ ⟹ ?P›*) 2)) ultimately have "finite { p . path M (initial M) p}" using finite_subset (*‹⟦?A ⊆ ?B; finite ?B⟧ ⟹ finite ?A›*) by blast then show "finite (L M)" unfolding LS.simps (*goal: ‹finite {p_io p |p. path M (FSM.initial M) p}›*) by auto qed show "finite (L M) ⟹ acyclic M" proof (rule ccontr (*‹(¬ ?P ⟹ False) ⟹ ?P›*)) (*goal: ‹⟦finite (L M); ¬ FSM.acyclic M⟧ ⟹ False›*) assume "finite (L M)" (*‹finite (L (M::('a, 'b, 'c) fsm))›*) assume "¬ acyclic M" (*‹¬ FSM.acyclic (M::('a, 'b, 'c) fsm)›*) obtain max_io_len where "∀io ∈ L M . length io < max_io_len" (*goal: ‹(⋀max_io_len. ∀io∈L M. length io < max_io_len ⟹ thesis) ⟹ thesis›*) using finite_maxlen[OF ‹finite (L M)›] (*‹∃n::nat. ∀s::('b × 'c) list∈L (M::('a, 'b, 'c) fsm). length s < n›*) by blast then have "⋀ p . path M (initial M) p ⟹ length p < max_io_len" proof (-) (*goal: ‹⋀p. ⟦path M (FSM.initial M) p; ∀io∈L M. length io < max_io_len⟧ ⟹ length p < max_io_len›*) fix p assume "path M (initial M) p" (*‹path (M::('a, 'b, 'c) fsm) (FSM.initial M) (p::('a × 'b × 'c × 'a) list)›*) show "length p < max_io_len" proof (rule ccontr (*‹(¬ ?P ⟹ False) ⟹ ?P›*)) (*goal: ‹¬ length p < max_io_len ⟹ False›*) assume "¬ length p < max_io_len" (*‹¬ length (p::('a × 'b × 'c × 'a) list) < (max_io_len::nat)›*) then have "¬ length (p_io p) < max_io_len" by auto moreover have "p_io p ∈ L M" unfolding LS.simps (*goal: ‹p_io p ∈ {p_io p |p. path M (FSM.initial M) p}›*) using ‹path M (initial M) p› (*‹path M (FSM.initial M) p›*) by blast ultimately show False using ‹∀io ∈ L M . length io < max_io_len› (*‹∀io∈L M. length io < max_io_len›*) by blast qed qed obtain p where "path M (initial M) p" and "¬ distinct (visited_states (initial M) p)" (*goal: ‹(⋀p. ⟦path M (FSM.initial M) p; ¬ distinct (visited_states (FSM.initial M) p)⟧ ⟹ thesis) ⟹ thesis›*) using ‹¬ acyclic M› (*‹¬ FSM.acyclic M›*) unfolding acyclic.simps (*goal: ‹(⋀p. ⟦path M (FSM.initial M) p; ¬ distinct (visited_states (FSM.initial M) p)⟧ ⟹ thesis) ⟹ thesis›*) by blast then obtain pL where "path M (initial M) pL" and "max_io_len ≤ length pL" (*goal: ‹(⋀pL. ⟦path M (FSM.initial M) pL; max_io_len ≤ length pL⟧ ⟹ thesis) ⟹ thesis›*) using cyclic_path_pumping[of M p max_io_len] (*‹⟦path M (FSM.initial M) p; ¬ distinct (visited_states (FSM.initial M) p)⟧ ⟹ ∃p. path M (FSM.initial M) p ∧ max_io_len ≤ length p›*) by blast then show False using ‹⋀ p . path M (initial M) p ⟹ length p < max_io_len› (*‹path M (FSM.initial M) ?p ⟹ length ?p < max_io_len›*) using not_le (*‹(¬ ?x ≤ ?y) = (?y < ?x)›*) by blast qed qed lemma acyclic_finite_paths_from_reachable_state : assumes "acyclic M" and "path M (initial M) p" and "target (initial M) p = q" shows "finite {p . path M q p}" proof (-) (*goal: ‹finite {p::('a::type × 'b::type × 'c::type × 'a::type) list. path (M::('a::type, 'b::type, 'c::type) fsm) (q::'a::type) p}›*) from assms (*‹FSM.acyclic M› ‹path (M::('a, 'b, 'c) fsm) (FSM.initial M) (p::('a × 'b × 'c × 'a) list)› ‹target (FSM.initial M) p = q›*) have "{ p . path M (initial M) p} ⊆ (acyclic_paths_up_to_length M (initial M) (size M - 1))" unfolding acyclic_paths_set (*goal: ‹{p::('a::type × 'b::type × 'c::type × 'a::type) list. path (M::('a::type, 'b::type, 'c::type) fsm) (FSM.initial M) p} ⊆ {p::('a::type × 'b::type × 'c::type × 'a::type) list. path M (FSM.initial M) p ∧ distinct (visited_states (FSM.initial M) p)}›*) by auto moreover have "finite (acyclic_paths_up_to_length M (initial M) (size M - 1))" unfolding acyclic_paths_up_to_length.simps (*goal: ‹finite {p. path M (FSM.initial M) p ∧ length p ≤ FSM.size M - 1 ∧ distinct (visited_states (FSM.initial M) p)}›*) using paths_finite[of M "initial M" "size M - 1"] (*‹finite {p. path M (FSM.initial M) p ∧ length p ≤ FSM.size M - 1}›*) by (metis (mono_tags, lifting) Collect_cong (*‹(⋀x. ?P x = ?Q x) ⟹ {x. ?P x} = {x. ?Q x}›*) ‹FSM.acyclic M› acyclic.elims( (*‹⟦FSM.acyclic ?x; ⋀M. ⟦?x = M; ∀p. path M (FSM.initial M) p ⟶ distinct (visited_states (FSM.initial M) p)⟧ ⟹ ?P⟧ ⟹ ?P›*) 2)) ultimately have "finite { p . path M (initial M) p}" using finite_subset (*‹⟦?A ⊆ ?B; finite ?B⟧ ⟹ finite ?A›*) by blast show "finite {p . path M q p}" proof (cases "q ∈ states M") (*goals: 1. ‹q ∈ FSM.states M ⟹ finite {p. path M q p}› 2. ‹q ∉ FSM.states M ⟹ finite {p. path M q p}›*) case True (*‹q ∈ FSM.states M›*) have "image (λp' . p@p') {p' . path M q p'} ⊆ {p' . path M (initial M) p'}" proof (standard) (*goal: ‹⋀x. x ∈ (@) p ` {p'. path M q p'} ⟹ x ∈ {p'. path M (FSM.initial M) p'}›*) fix x assume "x ∈ image (λp' . p@p') {p' . path M q p'}" (*‹(x::('a × 'b × 'c × 'a) list) ∈ (@) (p::('a × 'b × 'c × 'a) list) ` {p'::('a × 'b × 'c × 'a) list. path (M::('a, 'b, 'c) fsm) (q::'a) p'}›*) then obtain p' where "x = p@p'" and "p' ∈ {p' . path M q p'}" (*goal: ‹(⋀p'. ⟦x = p @ p'; p' ∈ {p'. path M q p'}⟧ ⟹ thesis) ⟹ thesis›*) by blast then have "path M q p'" by auto then have "path M (initial M) (p@p')" using path_append[OF ‹path M (initial M) p›] (*‹path M (target (FSM.initial M) p) ?p2.0 ⟹ path M (FSM.initial M) (p @ ?p2.0)›*) ‹target (initial M) p = q› (*‹target (FSM.initial M) p = q›*) by auto then show "x ∈ {p' . path M (initial M) p'}" using ‹x = p@p'› (*‹(x::('a::type × 'b::type × 'c::type × 'a::type) list) = (p::('a::type × 'b::type × 'c::type × 'a::type) list) @ (p'::('a::type × 'b::type × 'c::type × 'a::type) list)›*) by blast qed then have "finite (image (λp' . p@p') {p' . path M q p'})" using ‹finite { p . path M (initial M) p}› (*‹finite {p::('a × 'b × 'c × 'a) list. path (M::('a, 'b, 'c) fsm) (FSM.initial M) p}›*) finite_subset (*‹⟦?A ⊆ ?B; finite ?B⟧ ⟹ finite ?A›*) by auto show "?thesis" (*goal: ‹finite {p::('a × 'b × 'c × 'a) list. path (M::('a, 'b, 'c) fsm) (q::'a) p}›*) using finite_imageD[OF ‹finite (image (λp' . p@p') {p' . path M q p'})›] (*‹inj_on ((@) p) {p'. path M q p'} ⟹ finite {p'. path M q p'}›*) by (meson inj_onI (*‹(⋀x y. ⟦x ∈ ?A; y ∈ ?A; ?f x = ?f y⟧ ⟹ x = y) ⟹ inj_on ?f ?A›*) same_append_eq (*‹(?xs @ ?ys = ?xs @ ?zs) = (?ys = ?zs)›*)) next (*goal: ‹q ∉ FSM.states M ⟹ finite {p. path M q p}›*) case False (*‹q ∉ FSM.states M›*) then show "?thesis" (*goal: ‹finite {p. path M q p}›*) by (meson not_finite_existsD (*‹infinite {a. ?P a} ⟹ ∃a. ?P a›*) path_begin_state (*‹path ?M ?q ?p ⟹ ?q ∈ FSM.states ?M›*)) qed qed lemma acyclic_paths_from_reachable_states : assumes "acyclic M" and "path M (initial M) p'" and "target (initial M) p' = q" and "path M q p" shows "distinct (visited_states q p)" proof (-) (*goal: ‹distinct (visited_states q p)›*) have "path M (initial M) (p'@p)" using assms(2,3,4) (*‹path M (FSM.initial M) p'› ‹target (FSM.initial (M::('a, 'b, 'c) fsm)) (p'::('a × 'b × 'c × 'a) list) = (q::'a)› ‹path M q p›*) path_append (*‹⟦path ?M ?q ?p1.0; path ?M (target ?q ?p1.0) ?p2.0⟧ ⟹ path ?M ?q (?p1.0 @ ?p2.0)›*) by metis then have "distinct (visited_states (initial M) (p'@p))" using assms(1) (*‹FSM.acyclic M›*) unfolding acyclic.simps (*goal: ‹distinct (visited_states (FSM.initial M) (p' @ p))›*) by blast then have "distinct (initial M # (map t_target p') @ map t_target p)" by auto moreover have "initial M # (map t_target p') @ map t_target p = (butlast (initial M # map t_target p')) @ ((last (initial M # map t_target p')) # map t_target p)" by auto ultimately have "distinct ((last (initial M # map t_target p')) # map t_target p)" by auto then show "?thesis" (*goal: ‹distinct (visited_states q p)›*) using ‹target (initial M) p' = q› (*‹target (FSM.initial M) p' = q›*) unfolding visited_states.simps target.simps (*goal: ‹distinct (q # map t_target p)›*) by simp qed definition LS_acyclic :: "('a,'b,'c) fsm ⇒ 'a ⇒ ('b × 'c) list set" where "LS_acyclic M q = {p_io p | p . path M q p ∧ distinct (visited_states q p)}" lemma LS_acyclic_code[code] : "LS_acyclic M q = image p_io (acyclic_paths_up_to_length M q (size M - 1))" unfolding acyclic_paths_set LS_acyclic_def (*goal: ‹{p_io p |p::('c::type × 'a::type × 'b::type × 'c::type) list. path (M::('c::type, 'a::type, 'b::type) fsm) (q::'c::type) p ∧ distinct (visited_states q p)} = p_io ` {p::('c::type × 'a::type × 'b::type × 'c::type) list. path M q p ∧ distinct (visited_states q p)}›*) by blast lemma LS_from_LS_acyclic : assumes "acyclic M" shows "L M = LS_acyclic M (initial M)" proof (-) (*goal: ‹L M = LS_acyclic M (FSM.initial M)›*) obtain pps :: "(('b × 'c) list ⇒ bool) ⇒ (('b × 'c) list ⇒ bool) ⇒ ('b × 'c) list" where f1: "∀p pa. (¬ p (pps pa p)) = pa (pps pa p) ∨ Collect p = Collect pa" (*goal: ‹(⋀pps::(('b × 'c) list ⇒ bool) ⇒ (('b × 'c) list ⇒ bool) ⇒ ('b × 'c) list. ∀(p::('b × 'c) list ⇒ bool) pa::('b × 'c) list ⇒ bool. (¬ p (pps pa p)) = pa (pps pa p) ∨ Collect p = Collect pa ⟹ thesis::bool) ⟹ thesis›*) by (metis (no_types) Collect_cong (*‹(⋀x. ?P x = ?Q x) ⟹ {x. ?P x} = {x. ?Q x}›*)) have "∀ps. ¬ path M (FSM.initial M) ps ∨ distinct (visited_states (FSM.initial M) ps)" using acyclic.simps (*‹FSM.acyclic (?M::(?'a, ?'b, ?'c) fsm) = (∀p::(?'a × ?'b × ?'c × ?'a) list. path ?M (FSM.initial ?M) p ⟶ distinct (visited_states (FSM.initial ?M) p))›*) assms (*‹FSM.acyclic (M::('a, 'b, 'c) fsm)›*) by blast then have "(∄ps. pps (λps. ∃psa. ps = p_io psa ∧ path M (FSM.initial M) psa) (λps. ∃psa. ps = p_io psa ∧ path M (FSM.initial M) psa ∧ distinct (visited_states (FSM.initial M) psa)) = p_io ps ∧ path M (FSM.initial M) ps ∧ distinct (visited_states (FSM.initial M) ps)) ≠ (∃ps. pps (λps. ∃psa. ps = p_io psa ∧ path M (FSM.initial M) psa) (λps. ∃psa. ps = p_io psa ∧ path M (FSM.initial M) psa ∧ distinct (visited_states (FSM.initial M) psa)) = p_io ps ∧ path M (FSM.initial M) ps)" by blast then have "{p_io ps |ps. path M (FSM.initial M) ps ∧ distinct (visited_states (FSM.initial M) ps)} = {p_io ps |ps. path M (FSM.initial M) ps}" using f1 (*‹∀p pa. (¬ p (pps pa p)) = pa (pps pa p) ∨ Collect p = Collect pa›*) by (meson ‹∀ps. ¬ path M (FSM.initial M) ps ∨ distinct (visited_states (FSM.initial M) ps)›) then show "?thesis" (*goal: ‹L M = LS_acyclic M (FSM.initial M)›*) by (simp add: LS_acyclic_def (*‹LS_acyclic (?M::(?'a, ?'b, ?'c) fsm) (?q::?'a) = {p_io p |p::(?'a × ?'b × ?'c × ?'a) list. path ?M ?q p ∧ distinct (visited_states ?q p)}›*)) qed lemma cyclic_cycle : assumes "¬ acyclic M" shows "∃ q p . path M q p ∧ p ≠ [] ∧ target q p = q" proof (-) (*goal: ‹∃(q::'a::type) p::('a::type × 'b::type × 'c::type × 'a::type) list. path (M::('a::type, 'b::type, 'c::type) fsm) q p ∧ p ≠ [] ∧ target q p = q›*) from ‹¬ acyclic M› (*‹¬ FSM.acyclic (M::('a, 'b, 'c) fsm)›*) obtain p and t where "path M (initial M) (p@[t])" and "¬distinct (visited_states (initial M) (p@[t]))" (*goal: ‹(⋀p t. ⟦path M (FSM.initial M) (p @ [t]); ¬ distinct (visited_states (FSM.initial M) (p @ [t]))⟧ ⟹ thesis) ⟹ thesis›*) by (metis (no_types, opaque_lifting) Nil_is_append_conv (*‹([] = ?xs @ ?ys) = (?xs = [] ∧ ?ys = [])›*) acyclic.simps (*‹FSM.acyclic ?M = (∀p. path ?M (FSM.initial ?M) p ⟶ distinct (visited_states (FSM.initial ?M) p))›*) append_take_drop_id (*‹take ?n ?xs @ drop ?n ?xs = ?xs›*) maximal_distinct_prefix (*‹⟦¬ distinct ?xs; ⋀n. ⟦distinct (take (Suc n) ?xs); ¬ distinct (take (Suc (Suc n)) ?xs)⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*) rev_exhaust (*‹⟦?xs = [] ⟹ ?P; ⋀ys y. ?xs = ys @ [y] ⟹ ?P⟧ ⟹ ?P›*) visited_states_take (*‹take (Suc ?n) (visited_states ?q ?p) = visited_states ?q (take ?n ?p)›*)) show "?thesis" (*goal: ‹∃q p. path M q p ∧ p ≠ [] ∧ target q p = q›*) proof (cases "initial M ∈ set (map t_target (p@[t]))") (*goals: 1. ‹FSM.initial M ∈ set (map t_target (p @ [t])) ⟹ ∃q p. path M q p ∧ p ≠ [] ∧ target q p = q› 2. ‹FSM.initial M ∉ set (map t_target (p @ [t])) ⟹ ∃q p. path M q p ∧ p ≠ [] ∧ target q p = q›*) case True (*‹FSM.initial M ∈ set (map t_target (p @ [t]))›*) then obtain i where "last (take i (map t_target (p@[t]))) = initial M" and "i ≤ length (map t_target (p@[t]))" and "0 < i" (*goal: ‹(⋀i. ⟦last (take i (map t_target (p @ [t]))) = FSM.initial M; i ≤ length (map t_target (p @ [t])); 0 < i⟧ ⟹ thesis) ⟹ thesis›*) using list_contains_last_take (*‹?x ∈ set ?xs ⟹ ∃i>0. i ≤ length ?xs ∧ last (take i ?xs) = ?x›*) by metis let ?p = "take i (p@[t])" have "path M (initial M) (?p@(drop i (p@[t])))" using ‹path M (initial M) (p@[t])› (*‹path (M::('a::type, 'b::type, 'c::type) fsm) (FSM.initial M) ((p::('a::type × 'b::type × 'c::type × 'a::type) list) @ [t::'a::type × 'b::type × 'c::type × 'a::type])›*) by (metis append_take_drop_id (*‹take (?n::nat) (?xs::?'a list) @ drop ?n ?xs = ?xs›*)) then have "path M (initial M) ?p" by auto moreover have "?p ≠ []" using ‹0 < i› (*‹(0::nat) < (i::nat)›*) by auto moreover have "target (initial M) ?p = initial M" using ‹last (take i (map t_target (p@[t]))) = initial M› (*‹last (take i (map t_target (p @ [t]))) = FSM.initial M›*) unfolding target.simps visited_states.simps (*goal: ‹last (FSM.initial (M::('a, 'b, 'c) fsm) # map t_target (take (i::nat) ((p::('a × 'b × 'c × 'a) list) @ [t::'a × 'b × 'c × 'a]))) = FSM.initial M›*) by (metis (no_types, lifting) calculation( (*‹take i (p @ [t]) ≠ []›*) 2) last_ConsR (*‹?xs ≠ [] ⟹ last (?x # ?xs) = last ?xs›*) list.map_disc_iff (*‹(map ?f ?a = []) = (?a = [])›*) take_map (*‹take ?n (map ?f ?xs) = map ?f (take ?n ?xs)›*)) ultimately show "?thesis" (*goal: ‹∃q p. path M q p ∧ p ≠ [] ∧ target q p = q›*) by blast next (*goal: ‹FSM.initial M ∉ set (map t_target (p @ [t])) ⟹ ∃q p. path M q p ∧ p ≠ [] ∧ target q p = q›*) case False (*‹FSM.initial M ∉ set (map t_target (p @ [t]))›*) then have "¬ distinct (map t_target (p@[t]))" using ‹¬distinct (visited_states (initial M) (p@[t]))› (*‹¬ distinct (visited_states (FSM.initial M) (p @ [t]))›*) unfolding visited_states.simps (*goal: ‹¬ distinct (map t_target (p @ [t]))›*) by auto then obtain i and j where "i < j" and "j < length (map t_target (p@[t]))" and "(map t_target (p@[t])) ! i = (map t_target (p@[t])) ! j" (*goal: ‹(⋀i j. ⟦i < j; j < length (map t_target (p @ [t])); map t_target (p @ [t]) ! i = map t_target (p @ [t]) ! j⟧ ⟹ thesis) ⟹ thesis›*) using non_distinct_repetition_indices (*‹¬ distinct ?xs ⟹ ∃i j. i < j ∧ j < length ?xs ∧ ?xs ! i = ?xs ! j›*) by blast let ?pre_i = "take (Suc i) (p@[t])" let ?p = "take ((Suc j)-(Suc i)) (drop (Suc i) (p@[t]))" let ?post_j = "drop ((Suc j)-(Suc i)) (drop (Suc i) (p@[t]))" have "p@[t] = ?pre_i @ ?p @ ?post_j" using ‹i < j› (*‹i < j›*) ‹j < length (map t_target (p@[t]))› (*‹j < length (map t_target (p @ [t]))›*) by (metis append_take_drop_id (*‹take ?n ?xs @ drop ?n ?xs = ?xs›*)) then have "path M (target (initial M) ?pre_i) ?p" using ‹path M (initial M) (p@[t])› (*‹path M (FSM.initial M) (p @ [t])›*) by (metis path_prefix (*‹path ?M ?q (?p1.0 @ ?p2.0) ⟹ path ?M ?q ?p1.0›*) path_suffix (*‹path ?M ?q (?p1.0 @ ?p2.0) ⟹ path ?M (target ?q ?p1.0) ?p2.0›*)) have "?p ≠ []" using ‹i < j› (*‹i < j›*) ‹j < length (map t_target (p@[t]))› (*‹j < length (map t_target (p @ [t]))›*) by auto have "i < length (map t_target (p@[t]))" using ‹i < j› (*‹i < j›*) ‹j < length (map t_target (p@[t]))› (*‹j < length (map t_target (p @ [t]))›*) by auto have "(target (initial M) ?pre_i) = (map t_target (p@[t])) ! i" unfolding target.simps visited_states.simps (*goal: ‹last (FSM.initial M # map t_target (take (Suc i) (p @ [t]))) = map t_target (p @ [t]) ! i›*) using take_last_index[OF ‹i < length (map t_target (p@[t]))›] (*‹last (take (Suc i) (map t_target (p @ [t]))) = map t_target (p @ [t]) ! i›*) by (metis (no_types, lifting) ‹i < length (map t_target (p @ [t]))› last_ConsR (*‹(?xs::?'a list) ≠ [] ⟹ last ((?x::?'a) # ?xs) = last ?xs›*) snoc_eq_iff_butlast (*‹((?xs::?'a list) @ [?x::?'a] = (?ys::?'a list)) = (?ys ≠ [] ∧ butlast ?ys = ?xs ∧ last ?ys = ?x)›*) take_Suc_conv_app_nth (*‹(?i::nat) < length (?xs::?'a list) ⟹ take (Suc ?i) ?xs = take ?i ?xs @ [?xs ! ?i]›*) take_map (*‹take (?n::nat) (map (?f::?'b ⇒ ?'a) (?xs::?'b list)) = map ?f (take ?n ?xs)›*)) have "?pre_i@?p = take (Suc j) (p@[t])" by (metis (no_types) ‹i < j› add_Suc (*‹Suc ?m + ?n = Suc (?m + ?n)›*) add_diff_cancel_left' (*‹?a + ?b - ?a = ?b›*) less_SucI (*‹?m < ?n ⟹ ?m < Suc ?n›*) less_imp_Suc_add (*‹?m < ?n ⟹ ∃k. ?n = Suc (?m + k)›*) take_add (*‹take (?i + ?j) ?xs = take ?i ?xs @ take ?j (drop ?i ?xs)›*)) moreover have "(target (initial M) (take (Suc j) (p@[t]))) = (map t_target (p@[t])) ! j" unfolding target.simps visited_states.simps (*goal: ‹last (FSM.initial M # map t_target (take (Suc j) (p @ [t]))) = map t_target (p @ [t]) ! j›*) using take_last_index[OF ‹j < length (map t_target (p@[t]))›] (*‹last (take (Suc j) (map t_target (p @ [t]))) = map t_target (p @ [t]) ! j›*) by (metis (no_types, lifting) ‹j < length (map t_target (p @ [t]))› last_ConsR (*‹?xs ≠ [] ⟹ last (?x # ?xs) = last ?xs›*) snoc_eq_iff_butlast (*‹(?xs @ [?x] = ?ys) = (?ys ≠ [] ∧ butlast ?ys = ?xs ∧ last ?ys = ?x)›*) take_Suc_conv_app_nth (*‹?i < length ?xs ⟹ take (Suc ?i) ?xs = take ?i ?xs @ [?xs ! ?i]›*) take_map (*‹take ?n (map ?f ?xs) = map ?f (take ?n ?xs)›*)) ultimately have "(target (initial M) (?pre_i@?p)) = (map t_target (p@[t])) ! j" by auto then have "(target (initial M) (?pre_i@?p)) = (map t_target (p@[t])) ! i" using ‹(map t_target (p@[t])) ! i = (map t_target (p@[t])) ! j› (*‹map t_target (p @ [t]) ! i = map t_target (p @ [t]) ! j›*) by simp moreover have "(target (initial M) (?pre_i@?p)) = (target (target (initial M) ?pre_i) ?p)" unfolding target.simps visited_states.simps last.simps (*goal: ‹(if map t_target (take (Suc i) (p @ [t]) @ take (Suc j - Suc i) (drop (Suc i) (p @ [t]))) = [] then FSM.initial M else last (map t_target (take (Suc i) (p @ [t]) @ take (Suc j - Suc i) (drop (Suc i) (p @ [t]))))) = (if map t_target (take (Suc j - Suc i) (drop (Suc i) (p @ [t]))) = [] then if map t_target (take (Suc i) (p @ [t])) = [] then FSM.initial M else last (map t_target (take (Suc i) (p @ [t]))) else last (map t_target (take (Suc j - Suc i) (drop (Suc i) (p @ [t])))))›*) by auto ultimately have "(target (target (initial M) ?pre_i) ?p) = (map t_target (p@[t])) ! i" by auto then have "(target (target (initial M) ?pre_i) ?p) = (target (initial M) ?pre_i)" using ‹(target (initial M) ?pre_i) = (map t_target (p@[t])) ! i› (*‹target (FSM.initial M) (take (Suc i) (p @ [t])) = map t_target (p @ [t]) ! i›*) by auto show "?thesis" (*goal: ‹∃q p. path M q p ∧ p ≠ [] ∧ target q p = q›*) using ‹path M (target (initial M) ?pre_i) ?p› (*‹path M (target (FSM.initial M) (take (Suc i) (p @ [t]))) (take (Suc j - Suc i) (drop (Suc i) (p @ [t])))›*) ‹?p ≠ []› (*‹take (Suc j - Suc i) (drop (Suc i) (p @ [t])) ≠ []›*) ‹(target (target (initial M) ?pre_i) ?p) = (target (initial M) ?pre_i)› (*‹target (target (FSM.initial (M::('a, 'b, 'c) fsm)) (take (Suc (i::nat)) ((p::('a × 'b × 'c × 'a) list) @ [t::'a × 'b × 'c × 'a]))) (take (Suc (j::nat) - Suc i) (drop (Suc i) (p @ [t]))) = target (FSM.initial M) (take (Suc i) (p @ [t]))›*) by blast qed qed lemma cyclic_cycle_rev : fixes M :: "('a,'b,'c) fsm" assumes "path M (initial M) p'" and "target (initial M) p' = q" and "path M q p" and "p ≠ []" and "target q p = q" shows "¬ acyclic M" using assms (*‹path M (FSM.initial M) p'› ‹target (FSM.initial M) p' = q› ‹path M q p› ‹(p::('a × 'b × 'c × 'a) list) ≠ []› ‹target q p = q›*) unfolding acyclic.simps target.simps visited_states.simps (*goal: ‹¬ (∀p. path M (FSM.initial M) p ⟶ distinct (FSM.initial M # map t_target p))›*) using distinct.simps(2) (*‹distinct (?x # ?xs) = (?x ∉ set ?xs ∧ distinct ?xs)›*) by fastforce lemma acyclic_initial : assumes "acyclic M" shows "¬ (∃ t ∈ transitions M . t_target t = initial M ∧ (∃ p . path M (initial M) p ∧ target (initial M) p = t_source t))" by (metis append_Cons (*‹(?x # ?xs) @ ?ys = ?x # ?xs @ ?ys›*) assms (*‹FSM.acyclic M›*) cyclic_cycle_rev (*‹⟦path ?M (FSM.initial ?M) ?p'; target (FSM.initial ?M) ?p' = ?q; path ?M ?q ?p; ?p ≠ []; target ?q ?p = ?q⟧ ⟹ ¬ FSM.acyclic ?M›*) list.distinct( (*‹[] ≠ ?x21.0 # ?x22.0›*) 1) path.simps (*‹path ?a1.0 ?a2.0 ?a3.0 = ((∃q M. ?a1.0 = M ∧ ?a2.0 = q ∧ ?a3.0 = [] ∧ q ∈ FSM.states M) ∨ (∃t M ts. ?a1.0 = M ∧ ?a2.0 = t_source t ∧ ?a3.0 = t # ts ∧ t ∈ FSM.transitions M ∧ path M (t_target t) ts))›*) path_append (*‹⟦path ?M ?q ?p1.0; path ?M (target ?q ?p1.0) ?p2.0⟧ ⟹ path ?M ?q (?p1.0 @ ?p2.0)›*) path_append_transition_elim( (*‹path ?M ?q (?p @ [?t]) ⟹ t_source ?t = target ?q ?p›*) 3) single_transition_path (*‹?t ∈ FSM.transitions ?M ⟹ path ?M (t_source ?t) [?t]›*)) lemma cyclic_path_shift : assumes "path M q p" and "target q p = q" shows "path M (target q (take i p)) ((drop i p) @ (take i p))" and "target (target q (take i p)) ((drop i p) @ (take i p)) = (target q (take i p))" proof (-) (*goals: 1. ‹path M (target q (take i p)) (drop i p @ take i p)› 2. ‹target (target q (take i p)) (drop i p @ take i p) = target q (take i p)›*) show "path M (target q (take i p)) ((drop i p) @ (take i p))" by (metis append_take_drop_id (*‹take (?n::nat) (?xs::?'a::type list) @ drop ?n ?xs = ?xs›*) assms( (*‹path (M::('a::type, 'b::type, 'c::type) fsm) (q::'a::type) (p::('a::type × 'b::type × 'c::type × 'a::type) list)›*) 1) assms( (*‹target (q::'a::type) (p::('a::type × 'b::type × 'c::type × 'a::type) list) = q›*) 2) path_append (*‹⟦path (?M::(?'a::type, ?'b::type, ?'c::type) fsm) (?q::?'a::type) (?p1.0::(?'a::type × ?'b::type × ?'c::type × ?'a::type) list); path ?M (target ?q ?p1.0) (?p2.0::(?'a::type × ?'b::type × ?'c::type × ?'a::type) list)⟧ ⟹ path ?M ?q (?p1.0 @ ?p2.0)›*) path_append_elim (*‹⟦path (?M::(?'a::type, ?'b::type, ?'c::type) fsm) (?q::?'a::type) ((?p1.0::(?'a::type × ?'b::type × ?'c::type × ?'a::type) list) @ (?p2.0::(?'a::type × ?'b::type × ?'c::type × ?'a::type) list)); ⟦path ?M ?q ?p1.0; path ?M (target ?q ?p1.0) ?p2.0⟧ ⟹ ?thesis::bool⟧ ⟹ ?thesis›*) path_append_target (*‹target (?q::?'a::type) ((?p1.0::(?'a::type × ?'b::type × ?'c::type × ?'a::type) list) @ (?p2.0::(?'a::type × ?'b::type × ?'c::type × ?'a::type) list)) = target (target ?q ?p1.0) ?p2.0›*)) show "target (target q (take i p)) ((drop i p) @ (take i p)) = (target q (take i p))" by (metis append_take_drop_id (*‹take ?n ?xs @ drop ?n ?xs = ?xs›*) assms( (*‹target q p = q›*) 2) path_append_target (*‹target ?q (?p1.0 @ ?p2.0) = target (target ?q ?p1.0) ?p2.0›*)) qed lemma cyclic_path_transition_states_property : assumes "∃ t ∈ set p . P (t_source t)" and "∀ t ∈ set p . P (t_source t) ⟶ P (t_target t)" and "path M q p" and "target q p = q" shows "∀ t ∈ set p . P (t_source t)" and "∀ t ∈ set p . P (t_target t)" proof (-) (*goals: 1. ‹∀t::'a::type × 'b::type × 'c::type × 'a::type∈set (p::('a::type × 'b::type × 'c::type × 'a::type) list). (P::'a::type ⇒ bool) (t_source t)› 2. ‹∀t::'a::type × 'b::type × 'c::type × 'a::type∈set (p::('a::type × 'b::type × 'c::type × 'a::type) list). (P::'a::type ⇒ bool) (t_target t)›*) obtain t0 where "t0 ∈ set p" and "P (t_source t0)" (*goal: ‹(⋀t0. ⟦t0 ∈ set p; P (t_source t0)⟧ ⟹ thesis) ⟹ thesis›*) using assms(1) (*‹∃t∈set p. P (t_source t)›*) by blast then obtain i where "i < length p" and "p ! i = t0" (*goal: ‹(⋀i::nat. ⟦i < length (p::('a × 'b × 'c × 'a) list); p ! i = (t0::'a × 'b × 'c × 'a)⟧ ⟹ thesis::bool) ⟹ thesis›*) by (meson in_set_conv_nth (*‹(?x ∈ set ?xs) = (∃i<length ?xs. ?xs ! i = ?x)›*)) let ?p = "(drop i p @ take i p)" have "path M (target q (take i p)) ?p" using cyclic_path_shift(1)[OF assms ( 3 , 4 ), of i] (*‹path M (target q (take i p)) (drop i p @ take i p)›*) by assumption have "set ?p = set p" proof (-) (*goal: ‹set (drop i p @ take i p) = set p›*) have "set ?p = set (take i p @ drop i p)" using list_set_sym (*‹set (?x @ ?y) = set (?y @ ?x)›*) by metis then show "?thesis" (*goal: ‹set (drop i p @ take i p) = set p›*) by auto qed then have "⋀ t . t ∈ set ?p ⟹ P (t_source t) ⟹ P (t_target t)" using assms(2) (*‹∀t::'a × 'b × 'c × 'a∈set (p::('a × 'b × 'c × 'a) list). (P::'a ⇒ bool) (t_source t) ⟶ P (t_target t)›*) by blast have "⋀ j . j < length ?p ⟹ P (t_source (?p ! j))" proof (-) (*goal: ‹⋀j. j < length (drop i p @ take i p) ⟹ P (t_source ((drop i p @ take i p) ! j))›*) fix j assume "j < length ?p" (*‹(j::nat) < length (drop (i::nat) (p::('a × 'b × 'c × 'a) list) @ take i p)›*) then show "P (t_source (?p ! j))" proof (induction j) (*goals: 1. ‹0 < length (drop i p @ take i p) ⟹ P (t_source ((drop i p @ take i p) ! 0))› 2. ‹⋀j. ⟦j < length (drop i p @ take i p) ⟹ P (t_source ((drop i p @ take i p) ! j)); Suc j < length (drop i p @ take i p)⟧ ⟹ P (t_source ((drop i p @ take i p) ! Suc j))›*) case 0 (*‹0 < length (drop i p @ take i p)›*) then show "?case" (*goal: ‹P (t_source ((drop i p @ take i p) ! 0))›*) using ‹p ! i = t0› (*‹p ! i = t0›*) ‹P (t_source t0)› (*‹P (t_source t0)›*) by (metis ‹i < length p› drop_eq_Nil (*‹(drop (?n::nat) (?xs::?'a list) = []) = (length ?xs ≤ ?n)›*) hd_append2 (*‹(?xs::?'a list) ≠ [] ⟹ hd (?xs @ (?ys::?'a list)) = hd ?xs›*) hd_conv_nth (*‹(?xs::?'a list) ≠ [] ⟹ hd ?xs = ?xs ! (0::nat)›*) hd_drop_conv_nth (*‹(?n::nat) < length (?xs::?'a list) ⟹ hd (drop ?n ?xs) = ?xs ! ?n›*) leD (*‹(?y::?'a) ≤ (?x::?'a) ⟹ ¬ ?x < ?y›*) length_greater_0_conv (*‹((0::nat) < length (?xs::?'a list)) = (?xs ≠ [])›*)) next (*goal: ‹⋀j. ⟦j < length (drop i p @ take i p) ⟹ P (t_source ((drop i p @ take i p) ! j)); Suc j < length (drop i p @ take i p)⟧ ⟹ P (t_source ((drop i p @ take i p) ! Suc j))›*) case (Suc j) (*‹j < length (drop i p @ take i p) ⟹ P (t_source ((drop i p @ take i p) ! j))› ‹Suc (j::nat) < length (drop (i::nat) (p::('a × 'b × 'c × 'a) list) @ take i p)›*) then have "P (t_source (?p ! j))" by auto then have "P (t_target (?p ! j))" using Suc.prems (*‹Suc (j::nat) < length (drop (i::nat) (p::('a::type × 'b::type × 'c::type × 'a::type) list) @ take i p)›*) ‹⋀ t . t ∈ set ?p ⟹ P (t_source t) ⟹ P (t_target t)›[of "?p ! j"] (*‹⟦(drop i p @ take i p) ! j ∈ set (drop i p @ take i p); P (t_source ((drop i p @ take i p) ! j))⟧ ⟹ P (t_target ((drop i p @ take i p) ! j))›*) using Suc_lessD (*‹Suc ?m < ?n ⟹ ?m < ?n›*) nth_mem (*‹(?n::nat) < length (?xs::?'a list) ⟹ ?xs ! ?n ∈ set ?xs›*) by blast moreover have "t_target (?p ! j) = t_source (?p ! (Suc j))" using path_source_target_index[OF Suc.prems ‹path M (target q (take i p)) ?p›] (*‹t_target ((drop i p @ take i p) ! j) = t_source ((drop i p @ take i p) ! Suc j)›*) by assumption ultimately show "?case" (*goal: ‹P (t_source ((drop i p @ take i p) ! Suc j))›*) using ‹⋀ t . t ∈ set ?p ⟹ P (t_source t) ⟹ P (t_target t)›[of "?p ! j"] (*‹⟦(drop i p @ take i p) ! j ∈ set (drop i p @ take i p); P (t_source ((drop i p @ take i p) ! j))⟧ ⟹ P (t_target ((drop i p @ take i p) ! j))›*) by simp qed qed then have "∀ t ∈ set ?p . P (t_source t)" by (metis in_set_conv_nth (*‹(?x ∈ set ?xs) = (∃i<length ?xs. ?xs ! i = ?x)›*)) then show "∀ t ∈ set p . P (t_source t)" using ‹set ?p = set p› (*‹set (drop i p @ take i p) = set p›*) by blast then show "∀ t ∈ set p . P (t_target t)" using assms(2) (*‹∀t∈set p. P (t_source t) ⟶ P (t_target t)›*) by blast qed lemma cycle_incoming_transition_ex : assumes "path M q p" and "p ≠ []" and "target q p = q" and "t ∈ set p" shows "∃ tI ∈ set p . t_target tI = t_source t" proof (-) (*goal: ‹∃tI∈set p. t_target tI = t_source t›*) obtain i where "i < length p" and "p ! i = t" (*goal: ‹(⋀i. ⟦i < length p; p ! i = t⟧ ⟹ thesis) ⟹ thesis›*) using assms(4) (*‹t ∈ set p›*) by (meson in_set_conv_nth (*‹((?x::?'a) ∈ set (?xs::?'a list)) = (∃i<length ?xs. ?xs ! i = ?x)›*)) let ?p = "(drop i p @ take i p)" have "path M (target q (take i p)) ?p" and "target (target q (take i p)) ?p = target q (take i p)" using cyclic_path_shift[OF assms ( 1 , 3 ), of i] (*‹path M (target q (take i p)) (drop i p @ take i p)› ‹target (target (q::'a::type) (take (i::nat) (p::('a::type × 'b::type × 'c::type × 'a::type) list))) (drop i p @ take i p) = target q (take i p)›*) apply - (*goals: 1. ‹⟦path M (target q (take i p)) (drop i p @ take i p); target (target q (take i p)) (drop i p @ take i p) = target q (take i p)⟧ ⟹ path M (target q (take i p)) (drop i p @ take i p)› 2. ‹⟦path M (target q (take i p)) (drop i p @ take i p); target (target q (take i p)) (drop i p @ take i p) = target q (take i p)⟧ ⟹ target (target q (take i p)) (drop i p @ take i p) = target q (take i p)› discuss goal 1*) apply linarith (*discuss goal 2*) apply linarith (*proven 2 subgoals*) . have "p = (take i p @ drop i p)" by auto then have "path M (target q (take i p)) (drop i p)" using path_suffix (*‹path (?M::(?'a, ?'b, ?'c) fsm) (?q::?'a) ((?p1.0::(?'a × ?'b × ?'c × ?'a) list) @ (?p2.0::(?'a × ?'b × ?'c × ?'a) list)) ⟹ path ?M (target ?q ?p1.0) ?p2.0›*) assms(1) (*‹path M q p›*) by metis moreover have "t = hd (drop i p)" using ‹i < length p› (*‹i < length p›*) ‹p ! i = t› (*‹(p::('a × 'b × 'c × 'a) list) ! (i::nat) = (t::'a × 'b × 'c × 'a)›*) by (simp add: hd_drop_conv_nth (*‹(?n::nat) < length (?xs::?'a::type list) ⟹ hd (drop ?n ?xs) = ?xs ! ?n›*)) ultimately have "path M (target q (take i p)) [t]" by (metis ‹i < length p› append_take_drop_id (*‹take (?n::nat) (?xs::?'a list) @ drop ?n ?xs = ?xs›*) assms( (*‹path (M::('a, 'b, 'c) fsm) (q::'a) (p::('a × 'b × 'c × 'a) list)›*) 1) path_append_elim (*‹⟦path (?M::(?'a, ?'b, ?'c) fsm) (?q::?'a) ((?p1.0::(?'a × ?'b × ?'c × ?'a) list) @ (?p2.0::(?'a × ?'b × ?'c × ?'a) list)); ⟦path ?M ?q ?p1.0; path ?M (target ?q ?p1.0) ?p2.0⟧ ⟹ ?thesis::bool⟧ ⟹ ?thesis›*) take_hd_drop (*‹(?n::nat) < length (?xs::?'a list) ⟹ take ?n ?xs @ [hd (drop ?n ?xs)] = take (Suc ?n) ?xs›*)) then have "t_source t = (target q (take i p))" by auto moreover have "t_target (last ?p) = (target q (take i p))" using ‹path M (target q (take i p)) ?p› (*‹path (M::('a::type, 'b::type, 'c::type) fsm) (target (q::'a::type) (take (i::nat) (p::('a::type × 'b::type × 'c::type × 'a::type) list))) (drop i p @ take i p)›*) ‹target (target q (take i p)) ?p = target q (take i p)› (*‹target (target q (take i p)) (drop i p @ take i p) = target q (take i p)›*) assms(2) (*‹p ≠ []›*) unfolding target.simps visited_states.simps last.simps (*goal: ‹t_target (last (drop i p @ take i p)) = (if map t_target (take i p) = [] then q else last (map t_target (take i p)))›*) by (metis (no_types, lifting) ‹p = take i p @ drop i p› append_is_Nil_conv (*‹(?xs @ ?ys = []) = (?xs = [] ∧ ?ys = [])›*) last_map (*‹?xs ≠ [] ⟹ last (map ?f ?xs) = ?f (last ?xs)›*) list.map_disc_iff (*‹(map ?f ?a = []) = (?a = [])›*)) moreover have "set ?p = set p" proof (-) (*goal: ‹set (drop i p @ take i p) = set p›*) have "set ?p = set (take i p @ drop i p)" using list_set_sym (*‹set (?x @ ?y) = set (?y @ ?x)›*) by metis then show "?thesis" (*goal: ‹set (drop i p @ take i p) = set p›*) by auto qed ultimately show "?thesis" (*goal: ‹∃tI∈set p. t_target tI = t_source t›*) by (metis ‹i < length p› append_is_Nil_conv (*‹(?xs @ ?ys = []) = (?xs = [] ∧ ?ys = [])›*) drop_eq_Nil (*‹(drop ?n ?xs = []) = (length ?xs ≤ ?n)›*) last_in_set (*‹?as ≠ [] ⟹ last ?as ∈ set ?as›*) leD (*‹?y ≤ ?x ⟹ ¬ ?x < ?y›*)) qed lemma acyclic_paths_finite : "finite {p . path M q p ∧ distinct (visited_states q p) }" proof (-) (*goal: ‹finite {p. path M q p ∧ distinct (visited_states q p)}›*) have "⋀ p . path M q p ⟹ distinct (visited_states q p) ⟹ distinct p" proof (-) (*goal: ‹⋀p. ⟦path M q p; distinct (visited_states q p)⟧ ⟹ distinct p›*) fix p assume "path M q p" and "distinct (visited_states q p)" (*‹path (M::('a, 'b, 'c) fsm) (q::'a) (p::('a × 'b × 'c × 'a) list)› ‹distinct (visited_states (q::'a) (p::('a × 'b × 'c × 'a) list))›*) then have "distinct (map t_target p)" by auto then show "distinct p" by (simp add: distinct_map (*‹distinct (map ?f ?xs) = (distinct ?xs ∧ inj_on ?f (set ?xs))›*)) qed then show "?thesis" (*goal: ‹finite {p. path M q p ∧ distinct (visited_states q p)}›*) using finite_subset_distinct[OF fsm_transitions_finite, of M] (*‹finite {xs. set xs ⊆ FSM.transitions M ∧ distinct xs}›*) path_transitions[of M q] (*‹path M q ?p ⟹ set ?p ⊆ FSM.transitions M›*) by (metis (no_types, lifting) infinite_super (*‹⟦?S ⊆ ?T; infinite ?S⟧ ⟹ infinite ?T›*) mem_Collect_eq (*‹(?a ∈ Collect ?P) = ?P ?a›*) path_transitions (*‹path ?M ?q ?p ⟹ set ?p ⊆ FSM.transitions ?M›*) subsetI (*‹(⋀x. x ∈ ?A ⟹ x ∈ ?B) ⟹ ?A ⊆ ?B›*)) qed lemma acyclic_no_self_loop : assumes "acyclic M" and "q ∈ reachable_states M" shows "¬ (∃ x y . (q,x,y,q) ∈ transitions M)" proof (standard) (*goal: ‹∃(x::'b) y::'c. (q::'a, x, y, q) ∈ FSM.transitions (M::('a, 'b, 'c) fsm) ⟹ False›*) assume "∃x y. (q, x, y, q) ∈ FSM.transitions M" (*‹∃(x::'b) y::'c. (q::'a, x, y, q) ∈ FSM.transitions (M::('a, 'b, 'c) fsm)›*) then obtain x and y where "(q, x, y, q) ∈ FSM.transitions M" (*goal: ‹(⋀x y. (q, x, y, q) ∈ FSM.transitions M ⟹ thesis) ⟹ thesis›*) by blast moreover obtain p where "path M (initial M) p" and "target (initial M) p = q" (*goal: ‹(⋀p. ⟦path M (FSM.initial M) p; target (FSM.initial M) p = q⟧ ⟹ thesis) ⟹ thesis›*) using assms(2) (*‹q ∈ reachable_states M›*) unfolding reachable_states_def (*goal: ‹(⋀p. ⟦path M (FSM.initial M) p; target (FSM.initial M) p = q⟧ ⟹ thesis) ⟹ thesis›*) by blast ultimately have "path M (initial M) (p@[(q,x,y,q)])" by (simp add: path_append_transition (*‹⟦path ?M ?q ?p; ?t ∈ FSM.transitions ?M; t_source ?t = target ?q ?p⟧ ⟹ path ?M ?q (?p @ [?t])›*)) moreover have "¬ (distinct (visited_states (initial M) (p@[(q,x,y,q)])))" using ‹target (initial M) p = q› (*‹target (FSM.initial M) p = q›*) unfolding visited_states.simps target.simps (*goal: ‹¬ distinct (FSM.initial (M::('a, 'b, 'c) fsm) # map t_target ((p::('a × 'b × 'c × 'a) list) @ [(q::'a, x::'b, y::'c, q)]))›*) apply ((cases p rule: rev_cases (*‹⟦?xs = [] ⟹ ?P; ⋀ys y. ?xs = ys @ [y] ⟹ ?P⟧ ⟹ ?P›*))[1]) (*goals: 1. ‹⟦last (FSM.initial M # map t_target p) = q; p = []⟧ ⟹ ¬ distinct (FSM.initial M # map t_target (p @ [(q, x, y, q)]))› 2. ‹⋀ys ya. ⟦last (FSM.initial M # map t_target p) = q; p = ys @ [ya]⟧ ⟹ ¬ distinct (FSM.initial M # map t_target (p @ [(q, x, y, q)]))› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . ultimately show False using assms(1) (*‹FSM.acyclic M›*) unfolding acyclic.simps (*goal: ‹False›*) by meson qed subsubsection ‹Deadlock States› fun deadlock_state :: "('a,'b,'c) fsm ⇒ 'a ⇒ bool" where "deadlock_state M q = (¬(∃ t ∈ transitions M . t_source t = q))" lemma deadlock_state_alt_def : "deadlock_state M q = (LS M q ⊆ {[]})" proof (standard) (*goals: 1. ‹deadlock_state (M::('a, 'b, 'c) fsm) (q::'a) ⟹ LS M q ⊆ {[]}› 2. ‹LS (M::('a, 'b, 'c) fsm) (q::'a) ⊆ {[]} ⟹ deadlock_state M q›*) show "deadlock_state M q ⟹ LS M q ⊆ {[]}" proof (-) (*goal: ‹deadlock_state M q ⟹ LS M q ⊆ {[]}›*) assume "deadlock_state M q" (*‹deadlock_state (M::('a, 'b, 'c) fsm) (q::'a)›*) moreover have "⋀ p . deadlock_state M q ⟹ path M q p ⟹ p = []" unfolding deadlock_state.simps (*goal: ‹⋀p::('a::type × 'b::type × 'c::type × 'a::type) list. ⟦¬ (∃t::'a::type × 'b::type × 'c::type × 'a::type∈FSM.transitions (M::('a::type, 'b::type, 'c::type) fsm). t_source t = (q::'a::type)); path M q p⟧ ⟹ p = []›*) by (metis path.cases (*‹⟦path ?a1.0 ?a2.0 ?a3.0; ⋀q M. ⟦?a1.0 = M; ?a2.0 = q; ?a3.0 = []; q ∈ FSM.states M⟧ ⟹ ?P; ⋀t M ts. ⟦?a1.0 = M; ?a2.0 = t_source t; ?a3.0 = t # ts; t ∈ FSM.transitions M; path M (t_target t) ts⟧ ⟹ ?P⟧ ⟹ ?P›*)) ultimately show "LS M q ⊆ {[]}" unfolding LS.simps (*goal: ‹{p_io p |p. path M q p} ⊆ {[]}›*) by blast qed show "LS M q ⊆ {[]} ⟹ deadlock_state M q" unfolding LS.simps deadlock_state.simps (*goal: ‹{p_io p |p. path M q p} ⊆ {[]} ⟹ ¬ (∃t∈FSM.transitions M. t_source t = q)›*) using path.cases[of M q] (*‹⟦path M q ?a3.0; ⋀qa Ma. ⟦M = Ma; q = qa; ?a3.0 = []; qa ∈ FSM.states Ma⟧ ⟹ ?P; ⋀t Ma ts. ⟦M = Ma; q = t_source t; ?a3.0 = t # ts; t ∈ FSM.transitions Ma; path Ma (t_target t) ts⟧ ⟹ ?P⟧ ⟹ ?P›*) by blast qed lemma deadlock_state_alt_def_h : "deadlock_state M q = (∀ x ∈ inputs M . h M (q,x) = {})" unfolding deadlock_state.simps h.simps (*goal: ‹(¬ (∃t∈FSM.transitions M. t_source t = q)) = (∀x∈FSM.inputs M. FSM.h M (q, x) = {})›*) using fsm_transition_input (*‹?t ∈ FSM.transitions ?M ⟹ t_input ?t ∈ FSM.inputs ?M›*) by force lemma acyclic_deadlock_reachable : assumes "acyclic M" shows "∃ q ∈ reachable_states M . deadlock_state M q" proof (rule ccontr (*‹(¬ ?P ⟹ False) ⟹ ?P›*)) (*goal: ‹¬ (∃q∈reachable_states M. deadlock_state M q) ⟹ False›*) assume "¬ (∃q∈reachable_states M. deadlock_state M q)" (*‹¬ (∃q::'a∈reachable_states (M::('a, 'b, 'c) fsm). deadlock_state M q)›*) then have "*": "⋀ q . q ∈ reachable_states M ⟹ (∃ t ∈ transitions M . t_source t = q)" unfolding deadlock_state.simps (*goal: ‹⋀q. q ∈ reachable_states M ⟹ ∃t∈FSM.transitions M. t_source t = q›*) by blast let ?p = "arg_max_on length {p. path M (initial M) p}" have "finite {p. path M (initial M) p}" by (metis Collect_cong (*‹(⋀x. ?P x = ?Q x) ⟹ {x. ?P x} = {x. ?Q x}›*) acyclic_finite_paths_from_reachable_state (*‹⟦FSM.acyclic ?M; path ?M (FSM.initial ?M) ?p; target (FSM.initial ?M) ?p = ?q⟧ ⟹ finite {p. path ?M ?q p}›*) assms (*‹FSM.acyclic M›*) eq_Nil_appendI (*‹?xs = ?ys ⟹ ?xs = [] @ ?ys›*) fsm_initial (*‹FSM.initial ?M ∈ FSM.states ?M›*) nil (*‹?q ∈ FSM.states ?M ⟹ path ?M ?q []›*) path_append (*‹⟦path ?M ?q ?p1.0; path ?M (target ?q ?p1.0) ?p2.0⟧ ⟹ path ?M ?q (?p1.0 @ ?p2.0)›*) path_append_elim (*‹⟦path ?M ?q (?p1.0 @ ?p2.0); ⟦path ?M ?q ?p1.0; path ?M (target ?q ?p1.0) ?p2.0⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*)) moreover have "{p. path M (initial M) p} ≠ {}" by auto ultimately obtain p where "path M (initial M) p" and "⋀ p' . path M (initial M) p' ⟹ length p' ≤ length p" (*goal: ‹(⋀p. ⟦path M (FSM.initial M) p; ⋀p'. path M (FSM.initial M) p' ⟹ length p' ≤ length p⟧ ⟹ thesis) ⟹ thesis›*) using max_length_elem (*‹⟦finite ?xs; ?xs ≠ {}⟧ ⟹ ∃x∈?xs. ¬ (∃y∈?xs. length x < length y)›*) by (metis mem_Collect_eq (*‹(?a ∈ Collect ?P) = ?P ?a›*) not_le_imp_less (*‹¬ ?y ≤ ?x ⟹ ?x < ?y›*)) then obtain t where "t ∈ transitions M" and "t_source t = target (initial M) p" (*goal: ‹(⋀t. ⟦t ∈ FSM.transitions M; t_source t = target (FSM.initial M) p⟧ ⟹ thesis) ⟹ thesis›*) using "*"[of "target (initial M) p"] (*‹target (FSM.initial M) p ∈ reachable_states M ⟹ ∃t∈FSM.transitions M. t_source t = target (FSM.initial M) p›*) unfolding reachable_states_def (*goal: ‹(⋀t::'a::type × 'b::type × 'c::type × 'a::type. ⟦t ∈ FSM.transitions (M::('a::type, 'b::type, 'c::type) fsm); t_source t = target (FSM.initial M) (p::('a::type × 'b::type × 'c::type × 'a::type) list)⟧ ⟹ thesis::bool) ⟹ thesis›*) by blast then have "path M (initial M) (p@[t])" using ‹path M (initial M) p› (*‹path M (FSM.initial M) p›*) by (simp add: path_append_transition (*‹⟦path ?M ?q ?p; ?t ∈ FSM.transitions ?M; t_source ?t = target ?q ?p⟧ ⟹ path ?M ?q (?p @ [?t])›*)) then show False using ‹⋀ p' . path M (initial M) p' ⟹ length p' ≤ length p› (*‹path M (FSM.initial M) ?p' ⟹ length ?p' ≤ length p›*) by (metis impossible_Cons (*‹length ?xs ≤ length ?ys ⟹ (?xs = ?x # ?ys) = False›*) length_rotate1 (*‹length (rotate1 ?xs) = length ?xs›*) rotate1.simps( (*‹rotate1 (?x # ?xs) = ?xs @ [?x]›*) 2)) qed lemma deadlock_prefix : assumes "path M q p" and "t ∈ set (butlast p)" shows "¬ (deadlock_state M (t_target t))" using assms (*‹path M q p› ‹t ∈ set (butlast p)›*) proof (induction p rule: rev_induct (*‹⟦?P []; ⋀x xs. ?P xs ⟹ ?P (xs @ [x])⟧ ⟹ ?P ?xs›*)) (*goals: 1. ‹⟦path M q []; t ∈ set (butlast [])⟧ ⟹ ¬ deadlock_state M (t_target t)› 2. ‹⋀x xs. ⟦⟦path M q xs; t ∈ set (butlast xs)⟧ ⟹ ¬ deadlock_state M (t_target t); path M q (xs @ [x]); t ∈ set (butlast (xs @ [x]))⟧ ⟹ ¬ deadlock_state M (t_target t)›*) case Nil (*‹path M q []› ‹t ∈ set (butlast [])›*) then show "?case" (*goal: ‹¬ deadlock_state M (t_target t)›*) by auto next (*goal: ‹⋀x xs. ⟦⟦path M q xs; t ∈ set (butlast xs)⟧ ⟹ ¬ deadlock_state M (t_target t); path M q (xs @ [x]); t ∈ set (butlast (xs @ [x]))⟧ ⟹ ¬ deadlock_state M (t_target t)›*) case (snoc t' p') (*‹⟦path M q p'; t ∈ set (butlast p')⟧ ⟹ ¬ deadlock_state M (t_target t)› ‹path M q (p' @ [t'])› ‹t ∈ set (butlast (p' @ [t']))›*) show "?case" (*goal: ‹¬ deadlock_state M (t_target t)›*) proof (cases "t ∈ set (butlast p')") (*goals: 1. ‹t ∈ set (butlast p') ⟹ ¬ deadlock_state M (t_target t)› 2. ‹t ∉ set (butlast p') ⟹ ¬ deadlock_state M (t_target t)›*) case True (*‹t ∈ set (butlast p')›*) show "?thesis" (*goal: ‹¬ deadlock_state M (t_target t)›*) using snoc.IH[OF _ True] (*‹path M q p' ⟹ ¬ deadlock_state M (t_target t)›*) snoc.prems(1) (*‹path (M::('a, 'b, 'c) fsm) (q::'a) ((p'::('a × 'b × 'c × 'a) list) @ [t'::'a × 'b × 'c × 'a])›*) by blast next (*goal: ‹t ∉ set (butlast p') ⟹ ¬ deadlock_state M (t_target t)›*) case False (*‹t ∉ set (butlast p')›*) then have "p' = (butlast p')@[t]" using snoc.prems(2) (*‹t ∈ set (butlast (p' @ [t']))›*) by (metis append_butlast_last_id (*‹(?xs::?'a::type list) ≠ [] ⟹ butlast ?xs @ [last ?xs] = ?xs›*) append_self_conv2 (*‹((?xs::?'a::type list) @ (?ys::?'a::type list) = ?ys) = (?xs = [])›*) butlast_snoc (*‹butlast ((?xs::?'a::type list) @ [?x::?'a::type]) = ?xs›*) in_set_butlast_appendI (*‹(?x::?'a::type) ∈ set (butlast (?xs::?'a::type list)) ∨ ?x ∈ set (butlast (?ys::?'a::type list)) ⟹ ?x ∈ set (butlast (?xs @ ?ys))›*) list_prefix_elem (*‹⟦(?x::?'a::type) ∈ set ((?xs::?'a::type list) @ (?ys::?'a::type list)); ?x ∉ set ?ys⟧ ⟹ ?x ∈ set ?xs›*) set_ConsD (*‹(?y::?'a::type) ∈ set ((?x::?'a::type) # (?xs::?'a::type list)) ⟹ ?y = ?x ∨ ?y ∈ set ?xs›*)) then have "path M q ((butlast p'@[t])@[t'])" using snoc.prems(1) (*‹path M q (p' @ [t'])›*) by auto have "t' ∈ transitions M" and "t_source t' = target q (butlast p'@[t])" using path_suffix[OF ‹path M q ((butlast p'@[t])@[t'])›] (*‹path M (target q (butlast p' @ [t])) [t']›*) apply - (*goals: 1. ‹path M (target q (butlast p' @ [t])) [t'] ⟹ t' ∈ FSM.transitions M› 2. ‹path M (target q (butlast p' @ [t])) [t'] ⟹ t_source t' = target q (butlast p' @ [t])› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . then have "t' ∈ transitions M ∧ t_source t' = t_target t" unfolding target.simps visited_states.simps (*goal: ‹(t'::'a::type × 'b::type × 'c::type × 'a::type) ∈ FSM.transitions (M::('a::type, 'b::type, 'c::type) fsm) ∧ t_source t' = t_target (t::'a::type × 'b::type × 'c::type × 'a::type)›*) by auto then show "?thesis" (*goal: ‹¬ deadlock_state M (t_target t)›*) unfolding deadlock_state.simps (*goal: ‹¬ ¬ (∃ta∈FSM.transitions M. t_source ta = t_target t)›*) using ‹t' ∈ transitions M› (*‹t' ∈ FSM.transitions M›*) by blast qed qed lemma states_initial_deadlock : assumes "deadlock_state M (initial M)" shows "reachable_states M = {initial M}" proof (-) (*goal: ‹reachable_states M = {FSM.initial M}›*) have "⋀ q . q ∈ reachable_states M ⟹ q = initial M" proof (-) (*goal: ‹⋀q. q ∈ reachable_states M ⟹ q = FSM.initial M›*) fix q assume "q ∈ reachable_states M" (*‹(q::'a) ∈ reachable_states (M::('a, 'b, 'c) fsm)›*) then obtain p where "path M (initial M) p" and "target (initial M) p = q" (*goal: ‹(⋀p. ⟦path M (FSM.initial M) p; target (FSM.initial M) p = q⟧ ⟹ thesis) ⟹ thesis›*) unfolding reachable_states_def (*goal: ‹(⋀p. ⟦path M (FSM.initial M) p; target (FSM.initial M) p = q⟧ ⟹ thesis) ⟹ thesis›*) by auto show "q = initial M" proof (cases p) (*goals: 1. ‹(p::('a::type × 'b::type × 'c::type × 'a::type) list) = [] ⟹ (q::'a::type) = FSM.initial (M::('a::type, 'b::type, 'c::type) fsm)› 2. ‹⋀(a::'a::type × 'b::type × 'c::type × 'a::type) list::('a::type × 'b::type × 'c::type × 'a::type) list. (p::('a::type × 'b::type × 'c::type × 'a::type) list) = a # list ⟹ (q::'a::type) = FSM.initial (M::('a::type, 'b::type, 'c::type) fsm)›*) case Nil (*‹p = []›*) then show "?thesis" (*goal: ‹q = FSM.initial M›*) using ‹target (initial M) p = q› (*‹target (FSM.initial M) p = q›*) by auto next (*goal: ‹⋀(a::'a × 'b × 'c × 'a) list::('a × 'b × 'c × 'a) list. (p::('a × 'b × 'c × 'a) list) = a # list ⟹ (q::'a) = FSM.initial (M::('a, 'b, 'c) fsm)›*) case (Cons t p') (*‹p = t # p'›*) then have False using assms (*‹deadlock_state M (FSM.initial M)›*) ‹path M (initial M) p› (*‹path M (FSM.initial M) p›*) unfolding deadlock_state.simps (*goal: ‹False›*) by auto then show "?thesis" (*goal: ‹q = FSM.initial M›*) by simp qed qed then show "?thesis" (*goal: ‹reachable_states M = {FSM.initial M}›*) using reachable_states_initial[of M] (*‹FSM.initial M ∈ reachable_states M›*) by blast qed subsubsection ‹Other› fun completed_path :: "('a,'b,'c) fsm ⇒ 'a ⇒ ('a,'b,'c) path ⇒ bool" where "completed_path M q p = deadlock_state M (target q p)" fun minimal :: "('a,'b,'c) fsm ⇒ bool" where "minimal M = (∀ q ∈ states M . ∀ q' ∈ states M . q ≠ q' ⟶ LS M q ≠ LS M q')" lemma minimal_alt_def : "minimal M = (∀ q q' . q ∈ states M ⟶ q' ∈ states M ⟶ LS M q = LS M q' ⟶ q = q')" by auto definition retains_outputs_for_states_and_inputs :: "('a,'b,'c) fsm ⇒ ('a,'b,'c) fsm ⇒ bool" where "retains_outputs_for_states_and_inputs M S = (∀ tS ∈ transitions S . ∀ tM ∈ transitions M . (t_source tS = t_source tM ∧ t_input tS = t_input tM) ⟶ tM ∈ transitions S)" subsection ‹IO Targets and Observability› fun paths_for_io' :: "(('a × 'b) ⇒ ('c × 'a) set) ⇒ ('b × 'c) list ⇒ 'a ⇒ ('a,'b,'c) path ⇒ ('a,'b,'c) path set" where "paths_for_io' f [] q prev = {prev}" | "paths_for_io' f ((x,y)#io) q prev = ⋃(image (λyq' . paths_for_io' f io (snd yq') (prev@[(q,x,y,(snd yq'))])) (Set.filter (λyq' . fst yq' = y) (f (q,x))))" lemma paths_for_io'_set : assumes "q ∈ states M" shows "paths_for_io' (h M) io q prev = {prev@p | p . path M q p ∧ p_io p = io}" using assms (*‹(q::'a) ∈ FSM.states (M::('a, 'b, 'c) fsm)›*) proof (induction io arbitrary: q prev) (*goals: 1. ‹⋀q prev. q ∈ FSM.states M ⟹ paths_for_io' (FSM.h M) [] q prev = {prev @ p |p. path M q p ∧ p_io p = []}› 2. ‹⋀a io q prev. ⟦⋀q prev. q ∈ FSM.states M ⟹ paths_for_io' (FSM.h M) io q prev = {prev @ p |p. path M q p ∧ p_io p = io}; q ∈ FSM.states M⟧ ⟹ paths_for_io' (FSM.h M) (a # io) q prev = {prev @ p |p. path M q p ∧ p_io p = a # io}›*) case Nil (*‹q ∈ FSM.states M›*) then show "?case" (*goal: ‹paths_for_io' (FSM.h M) [] q prev = {prev @ p |p. path M q p ∧ p_io p = []}›*) by auto next (*goal: ‹⋀a io q prev. ⟦⋀q prev. q ∈ FSM.states M ⟹ paths_for_io' (FSM.h M) io q prev = {prev @ p |p. path M q p ∧ p_io p = io}; q ∈ FSM.states M⟧ ⟹ paths_for_io' (FSM.h M) (a # io) q prev = {prev @ p |p. path M q p ∧ p_io p = a # io}›*) case (Cons xy io) (*‹?q ∈ FSM.states M ⟹ paths_for_io' (FSM.h M) io ?q ?prev = {?prev @ p |p. path M ?q p ∧ p_io p = io}› ‹q ∈ FSM.states M›*) obtain x and y where "xy = (x,y)" (*goal: ‹(⋀x y. xy = (x, y) ⟹ thesis) ⟹ thesis›*) by (meson surj_pair (*‹∃x y. ?p = (x, y)›*)) let ?UN = "⋃(image (λyq' . paths_for_io' (h M) io (snd yq') (prev@[(q,x,y,(snd yq'))])) (Set.filter (λyq' . fst yq' = y) (h M (q,x))))" have "?UN = {prev@p | p . path M q p ∧ p_io p = (x,y)#io}" proof (standard) (*goals: 1. ‹(⋃yq'∈Set.filter (λyq'. fst yq' = y) (FSM.h M (q, x)). paths_for_io' (FSM.h M) io (snd yq') (prev @ [(q, x, y, snd yq')])) ⊆ {prev @ p |p. path M q p ∧ p_io p = (x, y) # io}› 2. ‹{prev @ p |p. path M q p ∧ p_io p = (x, y) # io} ⊆ (⋃yq'∈Set.filter (λyq'. fst yq' = y) (FSM.h M (q, x)). paths_for_io' (FSM.h M) io (snd yq') (prev @ [(q, x, y, snd yq')]))›*) have "⋀ p . p ∈ ?UN ⟹ p ∈ {prev@p | p . path M q p ∧ p_io p = (x,y)#io}" proof (-) (*goal: ‹⋀p. p ∈ (⋃yq'∈Set.filter (λyq'. fst yq' = y) (FSM.h M (q, x)). paths_for_io' (FSM.h M) io (snd yq') (prev @ [(q, x, y, snd yq')])) ⟹ p ∈ {prev @ p |p. path M q p ∧ p_io p = (x, y) # io}›*) fix p assume "p ∈ ?UN" (*‹(p::('a × 'b × 'c × 'a) list) ∈ (⋃yq'::'c × 'a∈Set.filter (λyq'::'c × 'a. fst yq' = y) (FSM.h M (q, x)). paths_for_io' (FSM.h (M::('a, 'b, 'c) fsm)) (io::('b × 'c) list) (snd yq') ((prev::('a × 'b × 'c × 'a) list) @ [(q::'a, x::'b, y::'c, snd yq')]))›*) then obtain q' where "(y,q') ∈ (Set.filter (λyq' . fst yq' = y) (h M (q,x)))" and "p ∈ paths_for_io' (h M) io q' (prev@[(q,x,y,q')])" (*goal: ‹(⋀q'. ⟦(y, q') ∈ Set.filter (λyq'. fst yq' = y) (FSM.h M (q, x)); p ∈ paths_for_io' (FSM.h M) io q' (prev @ [(q, x, y, q')])⟧ ⟹ thesis) ⟹ thesis›*) by auto from ‹(y,q') ∈ (Set.filter (λyq' . fst yq' = y) (h M (q,x)))› (*‹(y::'c, q'::'a) ∈ Set.filter (λyq'::'c × 'a. fst yq' = y) (FSM.h (M::('a, 'b, 'c) fsm) (q::'a, x::'b))›*) have "q' ∈ states M" and "(q,x,y,q') ∈ transitions M" using fsm_transition_target (*‹?t ∈ FSM.transitions ?M ⟹ t_target ?t ∈ FSM.states ?M›*) unfolding h.simps (*goals: 1. ‹q' ∈ FSM.states M› 2. ‹(q, x, y, q') ∈ FSM.transitions M›*) by auto have "p ∈ {(prev @ [(q, x, y, q')]) @ p |p. path M q' p ∧ p_io p = io}" using ‹p ∈ paths_for_io' (h M) io q' (prev@[(q,x,y,q')])› (*‹p ∈ paths_for_io' (FSM.h M) io q' (prev @ [(q, x, y, q')])›*) unfolding Cons.IH[OF ‹q' ∈ states M›] (*goal: ‹p ∈ {(prev @ [(q, x, y, q')]) @ p |p. path M q' p ∧ p_io p = io}›*) by assumption moreover have "{(prev @ [(q, x, y, q')]) @ p |p. path M q' p ∧ p_io p = io} ⊆ {prev@p | p . path M q p ∧ p_io p = (x,y)#io}" using ‹(q,x,y,q') ∈ transitions M› (*‹(q, x, y, q') ∈ FSM.transitions M›*) using cons (*‹⟦(?t::?'state × ?'input × ?'output × ?'state) ∈ FSM.transitions (?M::(?'state, ?'input, ?'output) fsm); path ?M (t_target ?t) (?ts::(?'state × ?'input × ?'output × ?'state) list)⟧ ⟹ path ?M (t_source ?t) (?t # ?ts)›*) by force ultimately show "p ∈ {prev@p | p . path M q p ∧ p_io p = (x,y)#io}" by blast qed then show "?UN ⊆ {prev@p | p . path M q p ∧ p_io p = (x,y)#io}" by blast have "⋀ p . p ∈ {prev@p | p . path M q p ∧ p_io p = (x,y)#io} ⟹ p ∈ ?UN" proof (-) (*goal: ‹⋀p. p ∈ {prev @ p |p. path M q p ∧ p_io p = (x, y) # io} ⟹ p ∈ (⋃yq'∈Set.filter (λyq'. fst yq' = y) (FSM.h M (q, x)). paths_for_io' (FSM.h M) io (snd yq') (prev @ [(q, x, y, snd yq')]))›*) fix pp assume "pp ∈ {prev@p | p . path M q p ∧ p_io p = (x,y)#io}" (*‹(pp::('a × 'b × 'c × 'a) list) ∈ {(prev::('a × 'b × 'c × 'a) list) @ p |p::('a × 'b × 'c × 'a) list. path (M::('a, 'b, 'c) fsm) (q::'a) p ∧ p_io p = (x::'b, y::'c) # (io::('b × 'c) list)}›*) then obtain p where "pp = prev@p" and "path M q p" and "p_io p = (x,y)#io" (*goal: ‹(⋀p. ⟦pp = prev @ p; path M q p; p_io p = (x, y) # io⟧ ⟹ thesis) ⟹ thesis›*) by fastforce then obtain t and p' where "p = t#p'" and "path M q (t#p')" and "p_io (t#p') = (x,y)#io" and "p_io p' = io" (*goal: ‹(⋀t p'. ⟦p = t # p'; path M q (t # p'); p_io (t # p') = (x, y) # io; p_io p' = io⟧ ⟹ thesis) ⟹ thesis›*) by (metis (no_types, lifting) map_eq_Cons_D (*‹map ?f ?xs = ?y # ?ys ⟹ ∃z zs. ?xs = z # zs ∧ ?f z = ?y ∧ map ?f zs = ?ys›*)) then have "path M (t_target t) p'" and "t_source t = q" and "t_input t = x" and "t_output t = y" and "t_target t ∈ states M" and "t ∈ transitions M" apply - (*goals: 1. ‹⟦(p::('a × 'b × 'c × 'a) list) = (t::'a × 'b × 'c × 'a) # (p'::('a × 'b × 'c × 'a) list); path (M::('a, 'b, 'c) fsm) (q::'a) (t # p'); p_io (t # p') = (x::'b, y::'c) # (io::('b × 'c) list); p_io p' = io⟧ ⟹ path M (t_target t) p'› 2. ‹⟦(p::('a × 'b × 'c × 'a) list) = (t::'a × 'b × 'c × 'a) # (p'::('a × 'b × 'c × 'a) list); path (M::('a, 'b, 'c) fsm) (q::'a) (t # p'); p_io (t # p') = (x::'b, y::'c) # (io::('b × 'c) list); p_io p' = io⟧ ⟹ t_source t = q› 3. ‹⟦(p::('a × 'b × 'c × 'a) list) = (t::'a × 'b × 'c × 'a) # (p'::('a × 'b × 'c × 'a) list); path (M::('a, 'b, 'c) fsm) (q::'a) (t # p'); p_io (t # p') = (x::'b, y::'c) # (io::('b × 'c) list); p_io p' = io⟧ ⟹ t_input t = x› 4. ‹⟦(p::('a × 'b × 'c × 'a) list) = (t::'a × 'b × 'c × 'a) # (p'::('a × 'b × 'c × 'a) list); path (M::('a, 'b, 'c) fsm) (q::'a) (t # p'); p_io (t # p') = (x::'b, y::'c) # (io::('b × 'c) list); p_io p' = io⟧ ⟹ t_output t = y› 5. ‹⟦(p::('a × 'b × 'c × 'a) list) = (t::'a × 'b × 'c × 'a) # (p'::('a × 'b × 'c × 'a) list); path (M::('a, 'b, 'c) fsm) (q::'a) (t # p'); p_io (t # p') = (x::'b, y::'c) # (io::('b × 'c) list); p_io p' = io⟧ ⟹ t_target t ∈ FSM.states M› 6. ‹⟦(p::('a × 'b × 'c × 'a) list) = (t::'a × 'b × 'c × 'a) # (p'::('a × 'b × 'c × 'a) list); path (M::('a, 'b, 'c) fsm) (q::'a) (t # p'); p_io (t # p') = (x::'b, y::'c) # (io::('b × 'c) list); p_io p' = io⟧ ⟹ t ∈ FSM.transitions M› 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 "(y,t_target t) ∈ Set.filter (λyq'. fst yq' = y) (h M (q, x))" using ‹t ∈ transitions M› (*‹t ∈ FSM.transitions M›*) ‹t_output t = y› (*‹t_output t = y›*) ‹t_input t = x› (*‹t_input t = x›*) ‹t_source t = q› (*‹t_source (t::'a::type × 'b::type × 'c::type × 'a::type) = (q::'a::type)›*) unfolding h.simps (*goal: ‹(y, t_target t) ∈ Set.filter (λyq'. fst yq' = y) (FSM.h M (q, x))›*) by auto moreover have "(prev@p) ∈ paths_for_io' (h M) io (snd (y,t_target t)) (prev @ [(q, x, y, snd (y,t_target t))])" using Cons.IH[OF ‹t_target t ∈ states M›, of "prev@[(q, x, y, t_target t)]"] (*‹paths_for_io' (FSM.h M) io (t_target t) (prev @ [(q, x, y, t_target t)]) = {(prev @ [(q, x, y, t_target t)]) @ p |p. path M (t_target t) p ∧ p_io p = io}›*) using ‹p = t # p'› (*‹p = t # p'›*) ‹p_io p' = io› (*‹p_io p' = io›*) ‹path M (t_target t) p'› (*‹path M (t_target t) p'›*) ‹t_input t = x› (*‹t_input (t::'a × 'b × 'c × 'a) = (x::'b)›*) ‹t_output t = y› (*‹t_output t = y›*) ‹t_source t = q› (*‹t_source (t::'a × 'b × 'c × 'a) = (q::'a)›*) by auto ultimately show "pp ∈ ?UN" unfolding ‹pp = prev@p› (*goal: ‹prev @ p ∈ (⋃yq'∈Set.filter (λyq'. fst yq' = y) (FSM.h M (q, x)). paths_for_io' (FSM.h M) io (snd yq') (prev @ [(q, x, y, snd yq')]))›*) by blast qed then show "{prev@p | p . path M q p ∧ p_io p = (x,y)#io} ⊆ ?UN" by (meson subsetI (*‹(⋀x. x ∈ ?A ⟹ x ∈ ?B) ⟹ ?A ⊆ ?B›*)) qed then show "?case" (*goal: ‹paths_for_io' (FSM.h M) (xy # io) q prev = {prev @ p |p. path M q p ∧ p_io p = xy # io}›*) by (simp add: ‹xy = (x, y)›) qed definition paths_for_io :: "('a,'b,'c) fsm ⇒ 'a ⇒ ('b × 'c) list ⇒ ('a,'b,'c) path set" where "paths_for_io M q io = {p . path M q p ∧ p_io p = io}" lemma paths_for_io_set_code[code] : "paths_for_io M q io = (if q ∈ states M then paths_for_io' (h M) io q [] else {})" using paths_for_io'_set[of q M io "[]"] (*‹q ∈ FSM.states M ⟹ paths_for_io' (FSM.h M) io q [] = {[] @ p |p. path M q p ∧ p_io p = io}›*) unfolding paths_for_io_def (*goal: ‹{p::('a × 'b × 'c × 'a) list. path (M::('a, 'b, 'c) fsm) (q::'a) p ∧ p_io p = (io::('b × 'c) list)} = (if q ∈ FSM.states M then paths_for_io' (FSM.h M) io q [] else {})›*) proof (-) (*goal: ‹(q ∈ FSM.states M ⟹ paths_for_io' (FSM.h M) io q [] = {[] @ p |p. path M q p ∧ p_io p = io}) ⟹ {p. path M q p ∧ p_io p = io} = (if q ∈ FSM.states M then paths_for_io' (FSM.h M) io q [] else {})›*) have "{[] @ ps |ps. path M q ps ∧ p_io ps = io} = (if q ∈ FSM.states M then paths_for_io' (h M) io q [] else {}) ⟶ {ps. path M q ps ∧ p_io ps = io} = (if q ∈ FSM.states M then paths_for_io' (h M) io q [] else {})" by auto moreover { assume "{[] @ ps |ps. path M q ps ∧ p_io ps = io} ≠ (if q ∈ FSM.states M then paths_for_io' (h M) io q [] else {})" (*‹{[] @ ps |ps::('a × 'b × 'c × 'a) list. path (M::('a, 'b, 'c) fsm) (q::'a) ps ∧ p_io ps = (io::('b × 'c) list)} ≠ (if q ∈ FSM.states M then paths_for_io' (FSM.h M) io q [] else {})›*) then have "q ∉ FSM.states M" using ‹q ∈ FSM.states M ⟹ paths_for_io' (h M) io q [] = {[] @ p |p. path M q p ∧ p_io p = io}› (*‹(q::'a) ∈ FSM.states (M::('a, 'b, 'c) fsm) ⟹ paths_for_io' (FSM.h M) (io::('b × 'c) list) q [] = {[] @ p |p::('a × 'b × 'c × 'a) list. path M q p ∧ p_io p = io}›*) by force then have "{ps. path M q ps ∧ p_io ps = io} = (if q ∈ FSM.states M then paths_for_io' (h M) io q [] else {})" using path_begin_state (*‹path (?M::(?'a::type, ?'b::type, ?'c::type) fsm) (?q::?'a::type) (?p::(?'a::type × ?'b::type × ?'c::type × ?'a::type) list) ⟹ ?q ∈ FSM.states ?M›*) by force } ultimately show "{ps. path M q ps ∧ p_io ps = io} = (if q ∈ FSM.states M then paths_for_io' (h M) io q [] else {})" by linarith qed fun io_targets :: "('a,'b,'c) fsm ⇒ ('b × 'c) list ⇒ 'a ⇒ 'a set" where "io_targets M io q = {target q p | p . path M q p ∧ p_io p = io}" lemma io_targets_code[code] : "io_targets M io q = image (target q) (paths_for_io M q io)" unfolding io_targets.simps paths_for_io_def (*goal: ‹{target q p |p. path M q p ∧ p_io p = io} = target q ` {p. path M q p ∧ p_io p = io}›*) by blast lemma io_targets_states : "io_targets M io q ⊆ states M" using path_target_is_state (*‹path ?M ?q ?p ⟹ target ?q ?p ∈ FSM.states ?M›*) by fastforce lemma observable_transition_unique : assumes "observable M" and "t ∈ transitions M" shows "∃! t' ∈ transitions M . t_source t' = t_source t ∧ t_input t' = t_input t ∧ t_output t' = t_output t" by (metis assms (*‹observable M› ‹t ∈ FSM.transitions M›*) observable.elims( (*‹⟦observable ?x; ⋀M. ⟦?x = M; ∀t1∈FSM.transitions M. ∀t2∈FSM.transitions M. t_source t1 = t_source t2 ∧ t_input t1 = t_input t2 ∧ t_output t1 = t_output t2 ⟶ t_target t1 = t_target t2⟧ ⟹ ?P⟧ ⟹ ?P›*) 2) prod.expand (*‹fst ?prod = fst ?prod' ∧ snd ?prod = snd ?prod' ⟹ ?prod = ?prod'›*)) lemma observable_path_unique : assumes "observable M" and "path M q p" and "path M q p'" and "p_io p = p_io p'" shows "p = p'" proof (-) (*goal: ‹p = p'›*) have "length p = length p'" using assms(4) (*‹p_io p = p_io p'›*) map_eq_imp_length_eq (*‹map ?f ?xs = map ?g ?ys ⟹ length ?xs = length ?ys›*) by blast then show "?thesis" (*goal: ‹p = p'›*) using ‹p_io p = p_io p'› (*‹p_io p = p_io p'›*) ‹path M q p› (*‹path M q p›*) ‹path M q p'› (*‹path M q p'›*) proof (induction p p' arbitrary: q rule: list_induct2) (*goals: 1. ‹⋀q::'a. ⟦p_io [] = p_io []; path (M::('a, 'b, 'c) fsm) q []; path M q []⟧ ⟹ [] = []› 2. ‹⋀(x::'a × 'b × 'c × 'a) (xs::('a × 'b × 'c × 'a) list) (y::'a × 'b × 'c × 'a) (ys::('a × 'b × 'c × 'a) list) q::'a. ⟦length xs = length ys; ⋀q::'a. ⟦p_io xs = p_io ys; path (M::('a, 'b, 'c) fsm) q xs; path M q ys⟧ ⟹ xs = ys; p_io (x # xs) = p_io (y # ys); path M q (x # xs); path M q (y # ys)⟧ ⟹ x # xs = y # ys›*) case Nil (*‹p_io [] = p_io []› ‹path M q []› ‹path M q []›*) then show "?case" (*goal: ‹[] = []›*) by auto next (*goal: ‹⋀(x::'a × 'b × 'c × 'a) (xs::('a × 'b × 'c × 'a) list) (y::'a × 'b × 'c × 'a) (ys::('a × 'b × 'c × 'a) list) q::'a. ⟦length xs = length ys; ⋀q::'a. ⟦p_io xs = p_io ys; path (M::('a, 'b, 'c) fsm) q xs; path M q ys⟧ ⟹ xs = ys; p_io (x # xs) = p_io (y # ys); path M q (x # xs); path M q (y # ys)⟧ ⟹ x # xs = y # ys›*) case (Cons x xs y ys) (*‹length xs = length ys› ‹⟦p_io xs = p_io ys; path M ?q xs; path M ?q ys⟧ ⟹ xs = ys› ‹p_io (x # xs) = p_io (y # ys)› ‹path M q (x # xs)› ‹path M q (y # ys)›*) then have "*": "x ∈ transitions M ∧ y ∈ transitions M ∧ t_source x = t_source y ∧ t_input x = t_input y ∧ t_output x = t_output y" by auto then have "t_target x = t_target y" using assms(1) (*‹observable M›*) observable.elims(2) (*‹⟦observable ?x; ⋀M. ⟦?x = M; ∀t1∈FSM.transitions M. ∀t2∈FSM.transitions M. t_source t1 = t_source t2 ∧ t_input t1 = t_input t2 ∧ t_output t1 = t_output t2 ⟶ t_target t1 = t_target t2⟧ ⟹ ?P⟧ ⟹ ?P›*) by blast then have "x = y" by (simp add: "*" (*‹(x::'a × 'b × 'c × 'a) ∈ FSM.transitions (M::('a, 'b, 'c) fsm) ∧ (y::'a × 'b × 'c × 'a) ∈ FSM.transitions M ∧ t_source x = t_source y ∧ t_input x = t_input y ∧ t_output x = t_output y›*) prod.expand (*‹fst (?prod::?'a × ?'b) = fst (?prod'::?'a × ?'b) ∧ snd ?prod = snd ?prod' ⟹ ?prod = ?prod'›*)) have "p_io xs = p_io ys" using Cons (*‹length xs = length ys› ‹⟦p_io xs = p_io ys; path M ?q xs; path M ?q ys⟧ ⟹ xs = ys› ‹p_io ((x::'a × 'b × 'c × 'a) # (xs::('a × 'b × 'c × 'a) list)) = p_io ((y::'a × 'b × 'c × 'a) # (ys::('a × 'b × 'c × 'a) list))› ‹path M q (x # xs)› ‹path (M::('a, 'b, 'c) fsm) (q::'a) ((y::'a × 'b × 'c × 'a) # (ys::('a × 'b × 'c × 'a) list))›*) by auto moreover have "path M (t_target x) xs" using Cons (*‹length xs = length ys› ‹⟦p_io xs = p_io ys; path M ?q xs; path M ?q ys⟧ ⟹ xs = ys› ‹p_io ((x::'a × 'b × 'c × 'a) # (xs::('a × 'b × 'c × 'a) list)) = p_io ((y::'a × 'b × 'c × 'a) # (ys::('a × 'b × 'c × 'a) list))› ‹path (M::('a, 'b, 'c) fsm) (q::'a) ((x::'a × 'b × 'c × 'a) # (xs::('a × 'b × 'c × 'a) list))› ‹path M q (y # ys)›*) by auto moreover have "path M (t_target x) ys" using Cons (*‹length xs = length ys› ‹⟦p_io (xs::('a::type × 'b::type × 'c::type × 'a::type) list) = p_io (ys::('a::type × 'b::type × 'c::type × 'a::type) list); path (M::('a::type, 'b::type, 'c::type) fsm) (?q::'a::type) xs; path M ?q ys⟧ ⟹ xs = ys› ‹p_io (x # xs) = p_io (y # ys)› ‹path M q (x # xs)› ‹path M q (y # ys)›*) ‹t_target x = t_target y› (*‹t_target x = t_target y›*) by auto ultimately have "xs = ys" using Cons (*‹length xs = length ys› ‹⟦p_io xs = p_io ys; path M ?q xs; path M ?q ys⟧ ⟹ xs = ys› ‹p_io (x # xs) = p_io (y # ys)› ‹path M q (x # xs)› ‹path (M::('a, 'b, 'c) fsm) (q::'a) ((y::'a × 'b × 'c × 'a) # (ys::('a × 'b × 'c × 'a) list))›*) by auto then show "?case" (*goal: ‹(x::'a::type × 'b::type × 'c::type × 'a::type) # (xs::('a::type × 'b::type × 'c::type × 'a::type) list) = (y::'a::type × 'b::type × 'c::type × 'a::type) # (ys::('a::type × 'b::type × 'c::type × 'a::type) list)›*) using ‹x = y› (*‹x = y›*) by simp qed qed lemma observable_io_targets : assumes "observable M" and "io ∈ LS M q" obtains q' where "io_targets M io q = {q'}" proof (-) (*goal: ‹(⋀q'. io_targets M io q = {q'} ⟹ thesis) ⟹ thesis›*) obtain p where "path M q p" and "p_io p = io" (*goal: ‹(⋀p. ⟦path M q p; p_io p = io⟧ ⟹ thesis) ⟹ thesis›*) using assms(2) (*‹(io::('b::type × 'c::type) list) ∈ LS (M::('a::type, 'b::type, 'c::type) fsm) (q::'a::type)›*) by auto then have "target q p ∈ io_targets M io q" by auto have "∃ q' . io_targets M io q = {q'}" proof (rule ccontr (*‹(¬ ?P ⟹ False) ⟹ ?P›*)) (*goal: ‹∄q'. io_targets M io q = {q'} ⟹ False›*) assume "¬(∃q'. io_targets M io q = {q'})" (*‹∄q'::'a. io_targets (M::('a, 'b, 'c) fsm) (io::('b × 'c) list) (q::'a) = {q'}›*) then have "∃ q' . q' ≠ target q p ∧ q' ∈ io_targets M io q" proof (-) (*goal: ‹∄q'. io_targets M io q = {q'} ⟹ ∃q'. q' ≠ target q p ∧ q' ∈ io_targets M io q›*) have "¬ io_targets M io q ⊆ {target q p}" using ‹¬(∃q'. io_targets M io q = {q'})› (*‹∄q'. io_targets M io q = {q'}›*) ‹target q p ∈ io_targets M io q› (*‹target q p ∈ io_targets M io q›*) by blast then show "?thesis" (*goal: ‹∃q'. q' ≠ target q p ∧ q' ∈ io_targets M io q›*) by blast qed then obtain q' where "q' ≠ target q p" and "q' ∈ io_targets M io q" (*goal: ‹(⋀q'. ⟦q' ≠ target q p; q' ∈ io_targets M io q⟧ ⟹ thesis) ⟹ thesis›*) by blast then obtain p' where "path M q p'" and "target q p' = q'" and "p_io p' = io" (*goal: ‹(⋀p'::('a × 'b × 'c × 'a) list. ⟦path (M::('a, 'b, 'c) fsm) (q::'a) p'; target q p' = (q'::'a); p_io p' = (io::('b × 'c) list)⟧ ⟹ thesis::bool) ⟹ thesis›*) by auto then have "p_io p = p_io p'" using ‹p_io p = io› (*‹p_io p = io›*) by simp then have "p = p'" using observable_path_unique[OF assms ( 1 ) ‹path M q p› ‹path M q p'›] (*‹p_io p = p_io p' ⟹ p = p'›*) by simp then show False using ‹q' ≠ target q p› (*‹(q'::'a::type) ≠ target (q::'a::type) (p::('a::type × 'b::type × 'c::type × 'a::type) list)›*) ‹target q p' = q'› (*‹target (q::'a) (p'::('a × 'b × 'c × 'a) list) = (q'::'a)›*) by auto qed then show "?thesis" (*goal: ‹thesis›*) using that (*‹io_targets M io q = {?q'} ⟹ thesis›*) by blast qed lemma observable_path_io_target : assumes "observable M" and "path M q p" shows "io_targets M (p_io p) q = {target q p}" using observable_io_targets[OF assms ( 1 ) language_state_containment [ OF assms ( 2 ) ], of "p_io p"] (*‹⟦p_io p = p_io p; ⋀q'. io_targets M (p_io p) q = {q'} ⟹ ?thesis⟧ ⟹ ?thesis›*) singletonD[of "target q p"] (*‹target q p ∈ {?a} ⟹ target q p = ?a›*) unfolding io_targets.simps (*goal: ‹{target q pa |pa. path M q pa ∧ p_io pa = p_io p} = {target q p}›*) proof (-) (*goal: ‹⟦⋀thesis. ⟦p_io p = p_io p; ⋀q'. {target q pa |pa. path M q pa ∧ p_io pa = p_io p} = {q'} ⟹ thesis⟧ ⟹ thesis; ⋀a. target q p ∈ {a} ⟹ target q p = a⟧ ⟹ {target q pa |pa. path M q pa ∧ p_io pa = p_io p} = {target q p}›*) assume a1: "⋀a. target q p ∈ {a} ⟹ target q p = a" (*‹target (q::'a) (p::('a × 'b × 'c × 'a) list) ∈ {?a::'a} ⟹ target q p = ?a›*) assume "⋀thesis. ⟦p_io p = p_io p; ⋀q'. {target q pa |pa. path M q pa ∧ p_io pa = p_io p} = {q'} ⟹ thesis⟧ ⟹ thesis" (*‹⟦p_io (p::('a × 'b × 'c × 'a) list) = p_io p; ⋀q'::'a. {target (q::'a) pa |pa::('a × 'b × 'c × 'a) list. path (M::('a, 'b, 'c) fsm) q pa ∧ p_io pa = p_io p} = {q'} ⟹ ?thesis::bool⟧ ⟹ ?thesis›*) then obtain aa :: 'a where "⋀b. {target q ps |ps. path M q ps ∧ p_io ps = p_io p} = {aa} ∨ b" (*goal: ‹(⋀aa. (⋀b. {target q ps |ps. path M q ps ∧ p_io ps = p_io p} = {aa} ∨ b) ⟹ thesis) ⟹ thesis›*) by meson then show "{target q ps |ps. path M q ps ∧ p_io ps = p_io p} = {target q p}" using a1 (*‹target (q::'a::type) (p::('a::type × 'b::type × 'c::type × 'a::type) list) ∈ {?a::'a::type} ⟹ target q p = ?a›*) assms(2) (*‹path M q p›*) by blast qed lemma completely_specified_io_targets : assumes "completely_specified M" shows "∀ q ∈ io_targets M io (initial M) . ∀ x ∈ (inputs M) . ∃ t ∈ transitions M . t_source t = q ∧ t_input t = x" by (meson assms (*‹completely_specified (M::('a::type, 'b::type, 'c::type) fsm)›*) completely_specified.elims( (*‹⟦completely_specified (?x::(?'a::type, ?'b::type, ?'c::type) fsm); ⋀M::(?'a::type, ?'b::type, ?'c::type) fsm. ⟦?x = M; ∀q::?'a::type∈FSM.states M. ∀x::?'b::type∈FSM.inputs M. ∃t::?'a::type × ?'b::type × ?'c::type × ?'a::type∈FSM.transitions M. t_source t = q ∧ t_input t = x⟧ ⟹ ?P::bool⟧ ⟹ ?P›*) 2) io_targets_states (*‹io_targets (?M::(?'a::type, ?'b::type, ?'c::type) fsm) (?io::(?'b::type × ?'c::type) list) (?q::?'a::type) ⊆ FSM.states ?M›*) subsetD (*‹⟦(?A::?'a::type set) ⊆ (?B::?'a::type set); (?c::?'a::type) ∈ ?A⟧ ⟹ ?c ∈ ?B›*)) lemma observable_path_language_step : assumes "observable M" and "path M q p" and "¬ (∃t∈transitions M. t_source t = target q p ∧ t_input t = x ∧ t_output t = y)" shows "(p_io p)@[(x,y)] ∉ LS M q" using assms (*‹observable M› ‹path M q p› ‹¬ (∃t∈FSM.transitions M. t_source t = target q p ∧ t_input t = x ∧ t_output t = y)›*) proof (induction p rule: rev_induct (*‹⟦?P []; ⋀x xs. ?P xs ⟹ ?P (xs @ [x])⟧ ⟹ ?P ?xs›*)) (*goals: 1. ‹⟦observable M; path M q []; ¬ (∃t∈FSM.transitions M. t_source t = target q [] ∧ t_input t = x ∧ t_output t = y)⟧ ⟹ p_io [] @ [(x, y)] ∉ LS M q› 2. ‹⋀xa xs. ⟦⟦observable M; path M q xs; ¬ (∃t∈FSM.transitions M. t_source t = target q xs ∧ t_input t = x ∧ t_output t = y)⟧ ⟹ p_io xs @ [(x, y)] ∉ LS M q; observable M; path M q (xs @ [xa]); ¬ (∃t∈FSM.transitions M. t_source t = target q (xs @ [xa]) ∧ t_input t = x ∧ t_output t = y)⟧ ⟹ p_io (xs @ [xa]) @ [(x, y)] ∉ LS M q›*) case Nil (*‹observable M› ‹path (M::('a, 'b, 'c) fsm) (q::'a) []› ‹¬ (∃t∈FSM.transitions M. t_source t = target q [] ∧ t_input t = x ∧ t_output t = y)›*) show "?case" (*goal: ‹p_io [] @ [(x, y)] ∉ LS M q›*) proof (standard) (*goal: ‹p_io [] @ [(x, y)] ∈ LS M q ⟹ False›*) assume "p_io [] @ [(x, y)] ∈ LS M q" (*‹p_io [] @ [(x::'b, y::'c)] ∈ LS (M::('a, 'b, 'c) fsm) (q::'a)›*) then obtain p' where "path M q p'" and "p_io p' = [(x,y)]" (*goal: ‹(⋀p'::('a × 'b × 'c × 'a) list. ⟦path (M::('a, 'b, 'c) fsm) (q::'a) p'; p_io p' = [(x::'b, y::'c)]⟧ ⟹ thesis::bool) ⟹ thesis›*) unfolding LS.simps (*goal: ‹(⋀p'. ⟦path M q p'; p_io p' = [(x, y)]⟧ ⟹ thesis) ⟹ thesis›*) by force then obtain t where "p' = [t]" (*goal: ‹(⋀t. p' = [t] ⟹ thesis) ⟹ thesis›*) by blast have "t∈transitions M" and "t_source t = target q []" using ‹path M q p'› (*‹path M q p'›*) ‹p' = [t]› (*‹p' = [t]›*) apply - (*goals: 1. ‹⟦path (M::('a, 'b, 'c) fsm) (q::'a) (p'::('a × 'b × 'c × 'a) list); p' = [t::'a × 'b × 'c × 'a]⟧ ⟹ t ∈ FSM.transitions M› 2. ‹⟦path (M::('a, 'b, 'c) fsm) (q::'a) (p'::('a × 'b × 'c × 'a) list); p' = [t::'a × 'b × 'c × 'a]⟧ ⟹ t_source t = target q []› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . moreover have "t_input t = x ∧ t_output t = y" using ‹p_io p' = [(x,y)]› (*‹p_io (p'::('a × 'b × 'c × 'a) list) = [(x::'b, y::'c)]›*) ‹p' = [t]› (*‹p' = [t]›*) by auto ultimately show False using Nil.prems(3) (*‹¬ (∃t∈FSM.transitions M. t_source t = target q [] ∧ t_input t = x ∧ t_output t = y)›*) by blast qed next (*goal: ‹⋀xa xs. ⟦⟦observable M; path M q xs; ¬ (∃t∈FSM.transitions M. t_source t = target q xs ∧ t_input t = x ∧ t_output t = y)⟧ ⟹ p_io xs @ [(x, y)] ∉ LS M q; observable M; path M q (xs @ [xa]); ¬ (∃t∈FSM.transitions M. t_source t = target q (xs @ [xa]) ∧ t_input t = x ∧ t_output t = y)⟧ ⟹ p_io (xs @ [xa]) @ [(x, y)] ∉ LS M q›*) case (snoc t p) (*‹⟦observable M; path M q p; ¬ (∃t∈FSM.transitions M. t_source t = target q p ∧ t_input t = x ∧ t_output t = y)⟧ ⟹ p_io p @ [(x, y)] ∉ LS M q› ‹observable (M::('a, 'b, 'c) fsm)› ‹path M q (p @ [t])› ‹¬ (∃ta∈FSM.transitions M. t_source ta = target q (p @ [t]) ∧ t_input ta = x ∧ t_output ta = y)›*) from ‹path M q (p @ [t])› (*‹path M q (p @ [t])›*) have "path M q p" and "t_source t = target q p" and "t ∈ transitions M" apply - (*goals: 1. ‹path M q (p @ [t]) ⟹ path M q p› 2. ‹path M q (p @ [t]) ⟹ t_source t = target q p› 3. ‹path M q (p @ [t]) ⟹ t ∈ FSM.transitions M› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*proven 3 subgoals*) . show "?case" (*goal: ‹p_io (p @ [t]) @ [(x, y)] ∉ LS M q›*) proof (standard) (*goal: ‹p_io (p @ [t]) @ [(x, y)] ∈ LS M q ⟹ False›*) assume "p_io (p @ [t]) @ [(x, y)] ∈ LS M q" (*‹p_io ((p::('a × 'b × 'c × 'a) list) @ [t::'a × 'b × 'c × 'a]) @ [(x::'b, y::'c)] ∈ LS (M::('a, 'b, 'c) fsm) (q::'a)›*) then obtain p' where "path M q p'" and "p_io p' = p_io (p @ [t]) @ [(x, y)]" (*goal: ‹(⋀p'. ⟦path M q p'; p_io p' = p_io (p @ [t]) @ [(x, y)]⟧ ⟹ thesis) ⟹ thesis›*) by auto then obtain p'' and t' and t'' where "p' = p''@[t']@[t'']" (*goal: ‹(⋀p'' t' t''. p' = p'' @ [t'] @ [t''] ⟹ thesis) ⟹ thesis›*) by (metis (no_types, lifting) append.assoc (*‹((?a::?'a list) @ (?b::?'a list)) @ (?c::?'a list) = ?a @ ?b @ ?c›*) map_butlast (*‹map (?f::?'b ⇒ ?'a) (butlast (?xs::?'b list)) = butlast (map ?f ?xs)›*) map_is_Nil_conv (*‹(map (?f::?'b ⇒ ?'a) (?xs::?'b list) = []) = (?xs = [])›*) snoc_eq_iff_butlast (*‹((?xs::?'a list) @ [?x::?'a] = (?ys::?'a list)) = (?ys ≠ [] ∧ butlast ?ys = ?xs ∧ last ?ys = ?x)›*)) then have "path M q p''" using ‹path M q p'› (*‹path (M::('a, 'b, 'c) fsm) (q::'a) (p'::('a × 'b × 'c × 'a) list)›*) by blast have "p_io p'' = p_io p" using ‹p' = p''@[t']@[t'']› (*‹p' = p'' @ [t'] @ [t'']›*) ‹p_io p' = p_io (p @ [t]) @ [(x, y)]› (*‹p_io p' = p_io (p @ [t]) @ [(x, y)]›*) by auto then have "p'' = p" using observable_path_unique[OF assms ( 1 ) ‹path M q p''› ‹path M q p›] (*‹p_io p'' = p_io p ⟹ p'' = p›*) by blast have "t_source t' = target q p''" and "t' ∈ transitions M" using ‹path M q p'› (*‹path (M::('a::type, 'b::type, 'c::type) fsm) (q::'a::type) (p'::('a::type × 'b::type × 'c::type × 'a::type) list)›*) ‹p' = p''@[t']@[t'']› (*‹p' = p'' @ [t'] @ [t'']›*) apply - (*goals: 1. ‹⟦path M q p'; p' = p'' @ [t'] @ [t'']⟧ ⟹ t_source t' = target q p''› 2. ‹⟦path M q p'; p' = p'' @ [t'] @ [t'']⟧ ⟹ t' ∈ FSM.transitions M› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . then have "t_source t' = t_source t" using ‹p'' = p› (*‹p'' = p›*) ‹t_source t = target q p› (*‹t_source t = target q p›*) by auto moreover have "t_input t' = t_input t ∧ t_output t' = t_output t" using ‹p_io p' = p_io (p @ [t]) @ [(x, y)]› (*‹p_io p' = p_io (p @ [t]) @ [(x, y)]›*) ‹p' = p''@[t']@[t'']› (*‹(p'::('a × 'b × 'c × 'a) list) = (p''::('a × 'b × 'c × 'a) list) @ [t'::'a × 'b × 'c × 'a] @ [t''::'a × 'b × 'c × 'a]›*) ‹p'' = p› (*‹p'' = p›*) by auto ultimately have "t' = t" using ‹t ∈ transitions M› (*‹(t::'a × 'b × 'c × 'a) ∈ FSM.transitions (M::('a, 'b, 'c) fsm)›*) ‹t' ∈ transitions M› (*‹t' ∈ FSM.transitions M›*) assms(1) (*‹observable M›*) unfolding observable.simps (*goal: ‹(t'::'a × 'b × 'c × 'a) = (t::'a × 'b × 'c × 'a)›*) by (meson prod.expand (*‹fst ?prod = fst ?prod' ∧ snd ?prod = snd ?prod' ⟹ ?prod = ?prod'›*)) have "t'' ∈ transitions M" and "t_source t'' = target q (p@[t])" using ‹path M q p'› (*‹path M q p'›*) ‹p' = p''@[t']@[t'']› (*‹p' = p'' @ [t'] @ [t'']›*) ‹p'' = p› (*‹p'' = p›*) ‹t' = t› (*‹t' = t›*) apply - (*goals: 1. ‹⟦path M q p'; p' = p'' @ [t'] @ [t'']; p'' = p; t' = t⟧ ⟹ t'' ∈ FSM.transitions M› 2. ‹⟦path M q p'; p' = p'' @ [t'] @ [t'']; p'' = p; t' = t⟧ ⟹ t_source t'' = target q (p @ [t])› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . moreover have "t_input t'' = x ∧ t_output t'' = y" using ‹p_io p' = p_io (p @ [t]) @ [(x, y)]› (*‹p_io (p'::('a × 'b × 'c × 'a) list) = p_io ((p::('a × 'b × 'c × 'a) list) @ [t::'a × 'b × 'c × 'a]) @ [(x::'b, y::'c)]›*) ‹p' = p''@[t']@[t'']› (*‹p' = p'' @ [t'] @ [t'']›*) by auto ultimately show False using snoc.prems(3) (*‹¬ (∃ta∈FSM.transitions M. t_source ta = target q (p @ [t]) ∧ t_input ta = x ∧ t_output ta = y)›*) by blast qed qed lemma observable_io_targets_language : assumes "io1 @ io2 ∈ LS M q1" and "observable M" and "q2 ∈ io_targets M io1 q1" shows "io2 ∈ LS M q2" proof (-) (*goal: ‹io2 ∈ LS M q2›*) obtain p1 and p2 where "path M q1 p1" and "path M (target q1 p1) p2" and "p_io p1 = io1" and "p_io p2 = io2" (*goal: ‹(⋀p1 p2. ⟦path M q1 p1; path M (target q1 p1) p2; p_io p1 = io1; p_io p2 = io2⟧ ⟹ thesis) ⟹ thesis›*) using language_state_split[OF assms ( 1 )] (*‹(⋀p1 p2. ⟦path M q1 p1; path M (target q1 p1) p2; p_io p1 = io1; p_io p2 = io2⟧ ⟹ ?thesis) ⟹ ?thesis›*) by blast then have "io1 ∈ LS M q1" and "io2 ∈ LS M (target q1 p1)" apply - (*goals: 1. ‹⟦path M q1 p1; path M (target q1 p1) p2; p_io p1 = io1; p_io p2 = io2⟧ ⟹ io1 ∈ LS M q1› 2. ‹⟦path M q1 p1; path M (target q1 p1) p2; p_io p1 = io1; p_io p2 = io2⟧ ⟹ io2 ∈ LS M (target q1 p1)› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . have "target q1 p1 ∈ io_targets M io1 q1" using ‹path M q1 p1› (*‹path M q1 p1›*) ‹p_io p1 = io1› (*‹p_io p1 = io1›*) unfolding io_targets.simps (*goal: ‹target q1 p1 ∈ {target q1 p |p. path M q1 p ∧ p_io p = io1}›*) by blast then have "target q1 p1 = q2" using observable_io_targets[OF assms ( 2 ) ‹io1 ∈ LS M q1›] (*‹(⋀q'. io_targets M io1 q1 = {q'} ⟹ ?thesis) ⟹ ?thesis›*) by (metis assms( (*‹q2 ∈ io_targets M io1 q1›*) 3) singletonD (*‹?b ∈ {?a} ⟹ ?b = ?a›*)) then show "?thesis" (*goal: ‹io2 ∈ LS M q2›*) using ‹io2 ∈ LS M (target q1 p1)› (*‹io2 ∈ LS M (target q1 p1)›*) by auto qed lemma io_targets_language_append : assumes "q1 ∈ io_targets M io1 q" and "io2 ∈ LS M q1" shows "io1@io2 ∈ LS M q" proof (-) (*goal: ‹io1 @ io2 ∈ LS M q›*) obtain p1 where "path M q p1" and "p_io p1 = io1" and "target q p1 = q1" (*goal: ‹(⋀p1. ⟦path M q p1; p_io p1 = io1; target q p1 = q1⟧ ⟹ thesis) ⟹ thesis›*) using assms(1) (*‹q1 ∈ io_targets M io1 q›*) by auto moreover obtain p2 where "path M q1 p2" and "p_io p2 = io2" (*goal: ‹(⋀p2::('a::type × 'b::type × 'c::type × 'a::type) list. ⟦path (M::('a::type, 'b::type, 'c::type) fsm) (q1::'a::type) p2; p_io p2 = (io2::('b::type × 'c::type) list)⟧ ⟹ thesis::bool) ⟹ thesis›*) using assms(2) (*‹io2 ∈ LS M q1›*) by auto ultimately have "path M q (p1@p2)" and "p_io (p1@p2) = io1@io2" apply - (*goals: 1. ‹⟦path M q p1; p_io p1 = io1; target q p1 = q1; path M q1 p2; p_io p2 = io2⟧ ⟹ path M q (p1 @ p2)› 2. ‹⟦path M q p1; p_io p1 = io1; target q p1 = q1; path M q1 p2; p_io p2 = io2⟧ ⟹ p_io (p1 @ p2) = io1 @ io2› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . then show "?thesis" (*goal: ‹io1 @ io2 ∈ LS M q›*) using language_state_containment[of M q "p1@p2" "io1@io2"] (*‹⟦path (M::('a::type, 'b::type, 'c::type) fsm) (q::'a::type) ((p1::('a::type × 'b::type × 'c::type × 'a::type) list) @ (p2::('a::type × 'b::type × 'c::type × 'a::type) list)); p_io (p1 @ p2) = (io1::('b::type × 'c::type) list) @ (io2::('b::type × 'c::type) list)⟧ ⟹ io1 @ io2 ∈ LS M q›*) by simp qed lemma io_targets_next : assumes "t ∈ transitions M" shows "io_targets M io (t_target t) ⊆ io_targets M (p_io [t] @ io) (t_source t)" unfolding io_targets.simps (*goal: ‹{target (t_target t) p |p. path M (t_target t) p ∧ p_io p = io} ⊆ {target (t_source t) p |p. path M (t_source t) p ∧ p_io p = p_io [t] @ io}›*) proof (standard) (*goal: ‹⋀x. x ∈ {target (t_target t) p |p. path M (t_target t) p ∧ p_io p = io} ⟹ x ∈ {target (t_source t) p |p. path M (t_source t) p ∧ p_io p = p_io [t] @ io}›*) fix q assume "q ∈ {target (t_target t) p |p. path M (t_target t) p ∧ p_io p = io}" (*‹(q::'a) ∈ {target (t_target (t::'a × 'b × 'c × 'a)) p |p::('a × 'b × 'c × 'a) list. path (M::('a, 'b, 'c) fsm) (t_target t) p ∧ p_io p = (io::('b × 'c) list)}›*) then obtain p where "path M (t_target t) p ∧ p_io p = io ∧ target (t_target t) p = q" (*goal: ‹(⋀p. path M (t_target t) p ∧ p_io p = io ∧ target (t_target t) p = q ⟹ thesis) ⟹ thesis›*) by auto then have "path M (t_source t) (t#p) ∧ p_io (t#p) = p_io [t] @ io ∧ target (t_source t) (t#p) = q" using FSM.path.cons[OF assms] (*‹path M (t_target t) ?ts ⟹ path M (t_source t) (t # ?ts)›*) by auto then show "q ∈ {target (t_source t) p |p. path M (t_source t) p ∧ p_io p = p_io [t] @ io}" by blast qed lemma observable_io_targets_next : assumes "observable M" and "t ∈ transitions M" shows "io_targets M (p_io [t] @ io) (t_source t) = io_targets M io (t_target t)" proof (standard) (*goals: 1. ‹io_targets M (p_io [t] @ io) (t_source t) ⊆ io_targets M io (t_target t)› 2. ‹io_targets M io (t_target t) ⊆ io_targets M (p_io [t] @ io) (t_source t)›*) show "io_targets M (p_io [t] @ io) (t_source t) ⊆ io_targets M io (t_target t)" proof (standard) (*goal: ‹⋀x. x ∈ io_targets M (p_io [t] @ io) (t_source t) ⟹ x ∈ io_targets M io (t_target t)›*) fix q assume "q ∈ io_targets M (p_io [t] @ io) (t_source t)" (*‹(q::'a) ∈ io_targets (M::('a, 'b, 'c) fsm) (p_io [t::'a × 'b × 'c × 'a] @ (io::('b × 'c) list)) (t_source t)›*) then obtain p where "q = target (t_source t) p" and "path M (t_source t) p" and "p_io p = p_io [t] @ io" (*goal: ‹(⋀p. ⟦q = target (t_source t) p; path M (t_source t) p; p_io p = p_io [t] @ io⟧ ⟹ thesis) ⟹ thesis›*) unfolding io_targets.simps (*goal: ‹(⋀p. ⟦q = target (t_source t) p; path M (t_source t) p; p_io p = p_io [t] @ io⟧ ⟹ thesis) ⟹ thesis›*) by blast then have "q = t_target (last p)" unfolding target.simps visited_states.simps (*goal: ‹(q::'a) = t_target (last (p::('a × 'b × 'c × 'a) list))›*) using last_map (*‹?xs ≠ [] ⟹ last (map ?f ?xs) = ?f (last ?xs)›*) by auto obtain t' and p' where "p = t' # p'" (*goal: ‹(⋀(t'::'a::type × 'b::type × 'c::type × 'a::type) p'::('a::type × 'b::type × 'c::type × 'a::type) list. (p::('a::type × 'b::type × 'c::type × 'a::type) list) = t' # p' ⟹ thesis::bool) ⟹ thesis›*) using ‹p_io p = p_io [t] @ io› (*‹p_io (p::('a::type × 'b::type × 'c::type × 'a::type) list) = p_io [t::'a::type × 'b::type × 'c::type × 'a::type] @ (io::('b::type × 'c::type) list)›*) by auto then have "t' ∈ transitions M" and "t_source t' = t_source t" using ‹path M (t_source t) p› (*‹path M (t_source t) p›*) apply - (*goals: 1. ‹⟦p = t' # p'; path M (t_source t) p⟧ ⟹ t' ∈ FSM.transitions M› 2. ‹⟦p = t' # p'; path M (t_source t) p⟧ ⟹ t_source t' = t_source t› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . moreover have "t_input t' = t_input t" and "t_output t' = t_output t" using ‹p = t' # p'› (*‹(p::('a × 'b × 'c × 'a) list) = (t'::'a × 'b × 'c × 'a) # (p'::('a × 'b × 'c × 'a) list)›*) ‹p_io p = p_io [t] @ io› (*‹p_io p = p_io [t] @ io›*) apply - (*goals: 1. ‹⟦(p::('a::type × 'b::type × 'c::type × 'a::type) list) = (t'::'a::type × 'b::type × 'c::type × 'a::type) # (p'::('a::type × 'b::type × 'c::type × 'a::type) list); p_io p = p_io [t::'a::type × 'b::type × 'c::type × 'a::type] @ (io::('b::type × 'c::type) list)⟧ ⟹ t_input t' = t_input t› 2. ‹⟦(p::('a::type × 'b::type × 'c::type × 'a::type) list) = (t'::'a::type × 'b::type × 'c::type × 'a::type) # (p'::('a::type × 'b::type × 'c::type × 'a::type) list); p_io p = p_io [t::'a::type × 'b::type × 'c::type × 'a::type] @ (io::('b::type × 'c::type) list)⟧ ⟹ t_output t' = t_output t› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . ultimately have "t' = t" using ‹t ∈ transitions M› (*‹(t::'a × 'b × 'c × 'a) ∈ FSM.transitions (M::('a, 'b, 'c) fsm)›*) ‹observable M› (*‹observable M›*) unfolding observable.simps (*goal: ‹(t'::'a × 'b × 'c × 'a) = (t::'a × 'b × 'c × 'a)›*) by (meson prod.expand (*‹fst ?prod = fst ?prod' ∧ snd ?prod = snd ?prod' ⟹ ?prod = ?prod'›*)) then have "path M (t_target t) p'" using ‹path M (t_source t) p› (*‹path (M::('a, 'b, 'c) fsm) (t_source (t::'a × 'b × 'c × 'a)) (p::('a × 'b × 'c × 'a) list)›*) ‹p = t' # p'› (*‹p = t' # p'›*) by auto moreover have "p_io p' = io" using ‹p_io p = p_io [t] @ io› (*‹p_io p = p_io [t] @ io›*) ‹p = t' # p'› (*‹p = t' # p'›*) by auto moreover have "q = target (t_target t) p'" using ‹q = target (t_source t) p› (*‹q = target (t_source t) p›*) ‹p = t' # p'› (*‹p = t' # p'›*) ‹t' = t› (*‹t' = t›*) by auto ultimately show "q ∈ io_targets M io (t_target t)" by auto qed show "io_targets M io (t_target t) ⊆ io_targets M (p_io [t] @ io) (t_source t)" using io_targets_next[OF assms ( 2 )] (*‹io_targets M ?io (t_target t) ⊆ io_targets M (p_io [t] @ ?io) (t_source t)›*) by assumption qed lemma observable_language_target : assumes "observable M" and "q ∈ io_targets M io1 (initial M)" and "t ∈ io_targets T io1 (initial T)" and "L T ⊆ L M" shows "LS T t ⊆ LS M q" proof (standard) (*goal: ‹⋀x::('b × 'c) list. x ∈ LS (T::('d, 'b, 'c) fsm) (t::'d) ⟹ x ∈ LS (M::('a, 'b, 'c) fsm) (q::'a)›*) fix io2 assume "io2 ∈ LS T t" (*‹(io2::('b × 'c) list) ∈ LS (T::('d, 'b, 'c) fsm) (t::'d)›*) then obtain pT2 where "path T t pT2" and "p_io pT2 = io2" (*goal: ‹(⋀pT2::('d × 'b × 'c × 'd) list. ⟦path (T::('d, 'b, 'c) fsm) (t::'d) pT2; p_io pT2 = (io2::('b × 'c) list)⟧ ⟹ thesis::bool) ⟹ thesis›*) by auto obtain pT1 where "path T (initial T) pT1" and "p_io pT1 = io1" and "target (initial T) pT1 = t" (*goal: ‹(⋀pT1. ⟦path T (FSM.initial T) pT1; p_io pT1 = io1; target (FSM.initial T) pT1 = t⟧ ⟹ thesis) ⟹ thesis›*) using ‹t ∈ io_targets T io1 (initial T)› (*‹(t::'d::type) ∈ io_targets (T::('d::type, 'b::type, 'c::type) fsm) (io1::('b::type × 'c::type) list) (FSM.initial T)›*) by auto then have "path T (initial T) (pT1@pT2)" using ‹path T t pT2› (*‹path T t pT2›*) using path_append (*‹⟦path ?M ?q ?p1.0; path ?M (target ?q ?p1.0) ?p2.0⟧ ⟹ path ?M ?q (?p1.0 @ ?p2.0)›*) by metis moreover have "p_io (pT1@pT2) = io1@io2" using ‹p_io pT1 = io1› (*‹p_io pT1 = io1›*) ‹p_io pT2 = io2› (*‹p_io pT2 = io2›*) by auto ultimately have "io1@io2 ∈ L T" using language_state_containment[of T] (*‹⟦path (T::('d, 'b, 'c) fsm) (?q::'d) (?p::('d × 'b × 'c × 'd) list); p_io ?p = (?io::('b × 'c) list)⟧ ⟹ ?io ∈ LS T ?q›*) by auto then have "io1@io2 ∈ L M" using ‹L T ⊆ L M› (*‹L T ⊆ L M›*) by blast then obtain pM where "path M (initial M) pM" and "p_io pM = io1@io2" (*goal: ‹(⋀pM::('a × 'b × 'c × 'a) list. ⟦path (M::('a, 'b, 'c) fsm) (FSM.initial M) pM; p_io pM = (io1::('b × 'c) list) @ (io2::('b × 'c) list)⟧ ⟹ thesis::bool) ⟹ thesis›*) by auto let ?pM1 = "take (length io1) pM" let ?pM2 = "drop (length io1) pM" have "path M (initial M) (?pM1@?pM2)" using ‹path M (initial M) pM› (*‹path M (FSM.initial M) pM›*) by auto then have "path M (initial M) ?pM1" and "path M (target (initial M) ?pM1) ?pM2" apply - (*goals: 1. ‹path M (FSM.initial M) (take (length io1) pM @ drop (length io1) pM) ⟹ path M (FSM.initial M) (take (length io1) pM)› 2. ‹path M (FSM.initial M) (take (length io1) pM @ drop (length io1) pM) ⟹ path M (target (FSM.initial M) (take (length io1) pM)) (drop (length io1) pM)› discuss goal 1*) apply blast (*discuss goal 2*) apply blast (*proven 2 subgoals*) . have "p_io ?pM1 = io1" using ‹p_io pM = io1@io2› (*‹p_io pM = io1 @ io2›*) by (metis append_eq_conv_conj (*‹(?xs @ ?ys = ?zs) = (?xs = take (length ?xs) ?zs ∧ ?ys = drop (length ?xs) ?zs)›*) take_map (*‹take ?n (map ?f ?xs) = map ?f (take ?n ?xs)›*)) have "p_io ?pM2 = io2" using ‹p_io pM = io1@io2› (*‹p_io pM = io1 @ io2›*) by (metis append_eq_conv_conj (*‹(?xs @ ?ys = ?zs) = (?xs = take (length ?xs) ?zs ∧ ?ys = drop (length ?xs) ?zs)›*) drop_map (*‹drop ?n (map ?f ?xs) = map ?f (drop ?n ?xs)›*)) obtain pM1 where "path M (initial M) pM1" and "p_io pM1 = io1" and "target (initial M) pM1 = q" (*goal: ‹(⋀pM1. ⟦path M (FSM.initial M) pM1; p_io pM1 = io1; target (FSM.initial M) pM1 = q⟧ ⟹ thesis) ⟹ thesis›*) using ‹q ∈ io_targets M io1 (initial M)› (*‹q ∈ io_targets M io1 (FSM.initial M)›*) by auto have "pM1 = ?pM1" using observable_path_unique[OF ‹observable M› ‹path M (initial M) pM1› ‹path M (initial M) ?pM1›] (*‹p_io (pM1::('a × 'b × 'c × 'a) list) = p_io (take (length (io1::('b × 'c) list)) (pM::('a × 'b × 'c × 'a) list)) ⟹ pM1 = take (length io1) pM›*) unfolding ‹p_io pM1 = io1› ‹p_io ?pM1 = io1› (*goal: ‹pM1 = take (length io1) pM›*) by simp then have "path M q ?pM2" using ‹path M (target (initial M) ?pM1) ?pM2› (*‹path (M::('a, 'b, 'c) fsm) (target (FSM.initial M) (take (length (io1::('b × 'c) list)) (pM::('a × 'b × 'c × 'a) list))) (drop (length io1) pM)›*) ‹target (initial M) pM1 = q› (*‹target (FSM.initial M) pM1 = q›*) by auto then show "io2 ∈ LS M q" using language_state_containment[OF _ ‹p_io ?pM2 = io2›, of M] (*‹path M ?q (drop (length io1) pM) ⟹ io2 ∈ LS M ?q›*) by auto qed lemma observable_language_target_failure : assumes "observable M" and "q ∈ io_targets M io1 (initial M)" and "t ∈ io_targets T io1 (initial T)" and "¬ LS T t ⊆ LS M q" shows "¬ L T ⊆ L M" using observable_language_target[OF assms ( 1 , 2 , 3 )] (*‹L T ⊆ L M ⟹ LS T t ⊆ LS M q›*) assms(4) (*‹¬ LS (T::('d::type, 'b::type, 'c::type) fsm) (t::'d::type) ⊆ LS (M::('a::type, 'b::type, 'c::type) fsm) (q::'a::type)›*) by blast lemma language_path_append_transition_observable : assumes "(p_io p) @ [(x,y)] ∈ LS M q" and "path M q p" and "observable M" obtains t where "path M q (p@[t])" and "t_input t = x" and "t_output t = y" proof (-) (*goal: ‹(⋀t. ⟦path M q (p @ [t]); t_input t = x; t_output t = y⟧ ⟹ thesis) ⟹ thesis›*) obtain p' and t where "path M q (p'@[t])" and "p_io (p'@[t]) = (p_io p) @ [(x,y)]" (*goal: ‹(⋀p' t. ⟦path M q (p' @ [t]); p_io (p' @ [t]) = p_io p @ [(x, y)]⟧ ⟹ thesis) ⟹ thesis›*) using language_path_append_transition[OF assms ( 1 )] (*‹(⋀(pa::('c::type × 'a::type × 'b::type × 'c::type) list) t::'c::type × 'a::type × 'b::type × 'c::type. ⟦path (M::('c::type, 'a::type, 'b::type) fsm) (q::'c::type) (pa @ [t]); p_io (pa @ [t]) = p_io (p::('c::type × 'a::type × 'b::type × 'c::type) list) @ [(x::'a::type, y::'b::type)]⟧ ⟹ ?thesis::bool) ⟹ ?thesis›*) by blast then have "path M q p'" and "p_io p' = p_io p" and "t_input t = x" and "t_output t = y" apply - (*goals: 1. ‹⟦path M q (p' @ [t]); p_io (p' @ [t]) = p_io p @ [(x, y)]⟧ ⟹ path M q p'› 2. ‹⟦path M q (p' @ [t]); p_io (p' @ [t]) = p_io p @ [(x, y)]⟧ ⟹ p_io p' = p_io p› 3. ‹⟦path M q (p' @ [t]); p_io (p' @ [t]) = p_io p @ [(x, y)]⟧ ⟹ t_input t = x› 4. ‹⟦path M q (p' @ [t]); p_io (p' @ [t]) = p_io p @ [(x, y)]⟧ ⟹ t_output t = 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]) (*proven 4 subgoals*) . have "p' = p" using observable_path_unique[OF assms ( 3 ) ‹path M q p'› ‹path M q p› ‹p_io p' = p_io p›] (*‹p' = p›*) by assumption then have "path M q (p@[t])" using ‹path M q (p'@[t])› (*‹path M q (p' @ [t])›*) by auto then show "?thesis" (*goal: ‹thesis›*) using that (*‹⟦path (M::('c, 'a, 'b) fsm) (q::'c) ((p::('c × 'a × 'b × 'c) list) @ [?t::'c × 'a × 'b × 'c]); t_input ?t = (x::'a); t_output ?t = (y::'b)⟧ ⟹ thesis::bool›*) ‹t_input t = x› (*‹t_input (t::'c × 'a × 'b × 'c) = (x::'a)›*) ‹t_output t = y› (*‹t_output t = y›*) by metis qed lemma language_io_target_append : assumes "q' ∈ io_targets M io1 q" and "io2 ∈ LS M q'" shows "(io1@io2) ∈ LS M q" proof (-) (*goal: ‹io1 @ io2 ∈ LS M q›*) obtain p2 where "path M q' p2" and "p_io p2 = io2" (*goal: ‹(⋀p2. ⟦path M q' p2; p_io p2 = io2⟧ ⟹ thesis) ⟹ thesis›*) using assms(2) (*‹(io2::('b × 'c) list) ∈ LS (M::('a, 'b, 'c) fsm) (q'::'a)›*) by auto moreover obtain p1 where "q' = target q p1" and "path M q p1" and "p_io p1 = io1" (*goal: ‹(⋀p1::('a × 'b × 'c × 'a) list. ⟦(q'::'a) = target (q::'a) p1; path (M::('a, 'b, 'c) fsm) q p1; p_io p1 = (io1::('b × 'c) list)⟧ ⟹ thesis::bool) ⟹ thesis›*) using assms(1) (*‹q' ∈ io_targets M io1 q›*) by auto ultimately show "?thesis" (*goal: ‹io1 @ io2 ∈ LS M q›*) unfolding LS.simps (*goal: ‹io1 @ io2 ∈ {p_io p |p. path M q p}›*) by (metis (mono_tags, lifting) map_append (*‹map ?f (?xs @ ?ys) = map ?f ?xs @ map ?f ?ys›*) mem_Collect_eq (*‹(?a ∈ Collect ?P) = ?P ?a›*) path_append (*‹⟦path ?M ?q ?p1.0; path ?M (target ?q ?p1.0) ?p2.0⟧ ⟹ path ?M ?q (?p1.0 @ ?p2.0)›*)) qed lemma observable_path_suffix : assumes "(p_io p)@io ∈ LS M q" and "path M q p" and "observable M" obtains p' where "path M (target q p) p'" and "p_io p' = io" proof (-) (*goal: ‹(⋀p'. ⟦path M (target q p) p'; p_io p' = io⟧ ⟹ thesis) ⟹ thesis›*) obtain p1 and p2 where "path M q p1" and "path M (target q p1) p2" and "p_io p1 = p_io p" and "p_io p2 = io" (*goal: ‹(⋀p1 p2. ⟦path M q p1; path M (target q p1) p2; p_io p1 = p_io p; p_io p2 = io⟧ ⟹ thesis) ⟹ thesis›*) using language_state_split[OF assms ( 1 )] (*‹(⋀p1 p2. ⟦path M q p1; path M (target q p1) p2; p_io p1 = p_io p; p_io p2 = io⟧ ⟹ ?thesis) ⟹ ?thesis›*) by blast have "p1 = p" using observable_path_unique[OF assms ( 3 , 2 ) ‹path M q p1› ‹p_io p1 = p_io p› [ symmetric ]] (*‹p = p1›*) by simp show "?thesis" (*goal: ‹thesis›*) using that[of p2] (*‹⟦path M (target q p) p2; p_io p2 = io⟧ ⟹ thesis›*) ‹path M (target q p1) p2› (*‹path M (target q p1) p2›*) ‹p_io p2 = io› (*‹p_io p2 = io›*) unfolding ‹p1 = p› (*goal: ‹thesis::bool›*) by blast qed lemma io_targets_finite : "finite (io_targets M io q)" proof (-) (*goal: ‹finite (io_targets M io q)›*) have "(io_targets M io q) ⊆ {target q p | p . path M q p ∧ length p ≤ length io}" unfolding io_targets.simps length_map[of "(λ t . (t_input t, t_output t))", symmetric] (*goal: ‹{target q p |p. path M q p ∧ p_io p = io} ⊆ {target q p |p. path M q p ∧ length (p_io p) ≤ length io}›*) by force moreover have "finite {target q p | p . path M q p ∧ length p ≤ length io}" using paths_finite[of M q "length io"] (*‹finite {p. path M q p ∧ length p ≤ length io}›*) by simp ultimately show "?thesis" (*goal: ‹finite (io_targets M io q)›*) using rev_finite_subset (*‹⟦finite ?B; ?A ⊆ ?B⟧ ⟹ finite ?A›*) by blast qed lemma language_next_transition_ob : assumes "(x,y)#ios ∈ LS M q" obtains t where "t_source t = q" and "t ∈ transitions M" and "t_input t = x" and "t_output t = y" and "ios ∈ LS M (t_target t)" proof (-) (*goal: ‹(⋀t. ⟦t_source t = q; t ∈ FSM.transitions M; t_input t = x; t_output t = y; ios ∈ LS M (t_target t)⟧ ⟹ thesis) ⟹ thesis›*) obtain p where "path M q p" and "p_io p = (x,y)#ios" (*goal: ‹(⋀p. ⟦path M q p; p_io p = (x, y) # ios⟧ ⟹ thesis) ⟹ thesis›*) using assms (*‹(x, y) # ios ∈ LS M q›*) unfolding LS.simps mem_Collect_eq (*goal: ‹(⋀p::('c × 'a × 'b × 'c) list. ⟦path (M::('c, 'a, 'b) fsm) (q::'c) p; p_io p = (x::'a, y::'b) # (ios::('a × 'b) list)⟧ ⟹ thesis::bool) ⟹ thesis›*) by (metis (no_types, lifting)) then obtain t and p' where "p = t#p'" (*goal: ‹(⋀t p'. p = t # p' ⟹ thesis) ⟹ thesis›*) by blast have "t_source t = q" and "t ∈ transitions M" and "path M (t_target t) p'" using ‹path M q p› (*‹path M q p›*) unfolding ‹p = t#p'› (*goals: 1. ‹t_source (t::'c × 'a × 'b × 'c) = (q::'c)› 2. ‹(t::'c × 'a × 'b × 'c) ∈ FSM.transitions (M::('c, 'a, 'b) fsm)› 3. ‹path (M::('c, 'a, 'b) fsm) (t_target (t::'c × 'a × 'b × 'c)) (p'::('c × 'a × 'b × 'c) list)›*) apply - (*goals: 1. ‹path (M::('c::type, 'a::type, 'b::type) fsm) (q::'c::type) ((t::'c::type × 'a::type × 'b::type × 'c::type) # (p'::('c::type × 'a::type × 'b::type × 'c::type) list)) ⟹ t_source t = q› 2. ‹path (M::('c::type, 'a::type, 'b::type) fsm) (q::'c::type) ((t::'c::type × 'a::type × 'b::type × 'c::type) # (p'::('c::type × 'a::type × 'b::type × 'c::type) list)) ⟹ t ∈ FSM.transitions M› 3. ‹path (M::('c::type, 'a::type, 'b::type) fsm) (q::'c::type) ((t::'c::type × 'a::type × 'b::type × 'c::type) # (p'::('c::type × 'a::type × 'b::type × 'c::type) list)) ⟹ path M (t_target t) p'› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*proven 3 subgoals*) . moreover have "t_input t = x" and "t_output t = y" and "p_io p' = ios" using ‹p_io p = (x,y)#ios› (*‹p_io p = (x, y) # ios›*) unfolding ‹p = t#p'› (*goals: 1. ‹t_input t = x› 2. ‹t_output t = y› 3. ‹p_io p' = ios›*) apply - (*goals: 1. ‹p_io (t # p') = (x, y) # ios ⟹ t_input t = x› 2. ‹p_io (t # p') = (x, y) # ios ⟹ t_output t = y› 3. ‹p_io (t # p') = (x, y) # ios ⟹ p_io p' = ios› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*proven 3 subgoals*) . ultimately show "?thesis" (*goal: ‹thesis::bool›*) using that[of t] (*‹⟦t_source t = q; t ∈ FSM.transitions M; t_input t = x; t_output t = y; ios ∈ LS M (t_target t)⟧ ⟹ thesis›*) by auto qed lemma h_observable_card : assumes "observable M" shows "card (snd ` Set.filter (λ (y',q') . y' = y) (h M (q,x))) ≤ 1" and "finite (snd ` Set.filter (λ (y',q') . y' = y) (h M (q,x)))" proof (-) (*goals: 1. ‹card (snd ` Set.filter (λ(y', q'). y' = y) (FSM.h M (q, x))) ≤ 1› 2. ‹finite (snd ` Set.filter (λ(y', q'). y' = y) (FSM.h M (q, x)))›*) have "snd ` Set.filter (λ (y',q') . y' = y) (h M (q,x)) = {q' . (q,x,y,q') ∈ transitions M}" unfolding h.simps (*goal: ‹snd ` Set.filter (λ(y', q'). y' = y) (FSM.h M (q, x)) = {q'. (q, x, y, q') ∈ FSM.transitions M}›*) by force moreover have "{q' . (q,x,y,q') ∈ transitions M} = {} ∨ (∃ q' . {q' . (q,x,y,q') ∈ transitions M} = {q'})" using assms (*‹observable M›*) unfolding observable_alt_def (*goal: ‹{q'::'a. (q::'a, x::'b, y::'c, q') ∈ FSM.transitions (M::('a, 'b, 'c) fsm)} = {} ∨ (∃q'::'a. {q'::'a. (q, x, y, q') ∈ FSM.transitions M} = {q'})›*) by blast ultimately show "card (snd ` Set.filter (λ (y',q') . y' = y) (h M (q,x))) ≤ 1" and "finite (snd ` Set.filter (λ (y',q') . y' = y) (h M (q,x)))" apply - (*goals: 1. ‹⟦snd ` Set.filter (λ(y', q'). y' = y) (FSM.h M (q, x)) = {q'. (q, x, y, q') ∈ FSM.transitions M}; {q'. (q, x, y, q') ∈ FSM.transitions M} = {} ∨ (∃q'. {q'. (q, x, y, q') ∈ FSM.transitions M} = {q'})⟧ ⟹ card (snd ` Set.filter (λ(y', q'). y' = y) (FSM.h M (q, x))) ≤ 1› 2. ‹⟦snd ` Set.filter (λ(y', q'). y' = y) (FSM.h M (q, x)) = {q'. (q, x, y, q') ∈ FSM.transitions M}; {q'. (q, x, y, q') ∈ FSM.transitions M} = {} ∨ (∃q'. {q'. (q, x, y, q') ∈ FSM.transitions M} = {q'})⟧ ⟹ finite (snd ` Set.filter (λ(y', q'). y' = y) (FSM.h M (q, x)))› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . qed lemma h_obs_None : assumes "observable M" shows "(h_obs M q x y = None) = (∄q' . (q,x,y,q') ∈ transitions M)" proof (standard) (*goals: 1. ‹FSM.h_obs M q x y = None ⟹ ∄q'. (q, x, y, q') ∈ FSM.transitions M› 2. ‹∄q'. (q, x, y, q') ∈ FSM.transitions M ⟹ FSM.h_obs M q x y = None›*) show "(h_obs M q x y = None) ⟹ (∄q' . (q,x,y,q') ∈ transitions M)" proof (-) (*goal: ‹FSM.h_obs M q x y = None ⟹ ∄q'. (q, x, y, q') ∈ FSM.transitions M›*) assume "h_obs M q x y = None" (*‹FSM.h_obs (M::('a, 'b, 'c) fsm) (q::'a) (x::'b) (y::'c) = None›*) then have "card (snd ` Set.filter (λ (y',q') . y' = y) (h M (q,x))) ≠ 1" by auto then have "card (snd ` Set.filter (λ (y',q') . y' = y) (h M (q,x))) = 0" using h_observable_card(1)[OF assms, of y q x] (*‹card (snd ` Set.filter (λ(y', q'). y' = y) (FSM.h M (q, x))) ≤ 1›*) by presburger then have "(snd ` Set.filter (λ (y',q') . y' = y) (h M (q,x))) = {}" using h_observable_card(2)[OF assms, of y q x] (*‹finite (snd ` Set.filter (λ(y'::'c, q'::'a). y' = (y::'c)) (FSM.h (M::('a, 'b, 'c) fsm) (q::'a, x::'b)))›*) card_0_eq[of "(snd ` Set.filter (λ(y', q'). y' = y) (h M (q, x)))"] (*‹finite (snd ` Set.filter (λ(y', q'). y' = y) (FSM.h M (q, x))) ⟹ (card (snd ` Set.filter (λ(y', q'). y' = y) (FSM.h M (q, x))) = 0) = (snd ` Set.filter (λ(y', q'). y' = y) (FSM.h M (q, x)) = {})›*) by blast then show "?thesis" (*goal: ‹∄q'. (q, x, y, q') ∈ FSM.transitions M›*) unfolding h.simps (*goal: ‹∄q'. (q, x, y, q') ∈ FSM.transitions M›*) by force qed show "(∄q' . (q,x,y,q') ∈ transitions M) ⟹ (h_obs M q x y = None)" proof (-) (*goal: ‹∄q'::'a. (q::'a, x::'b, y::'c, q') ∈ FSM.transitions (M::('a, 'b, 'c) fsm) ⟹ FSM.h_obs M q x y = None›*) assume "(∄q' . (q,x,y,q') ∈ transitions M)" (*‹∄q'::'a. (q::'a, x::'b, y::'c, q') ∈ FSM.transitions (M::('a, 'b, 'c) fsm)›*) then have "snd ` Set.filter (λ (y',q') . y' = y) (h M (q,x)) = {}" unfolding h.simps (*goal: ‹snd ` Set.filter (λ(y', q'). y' = y) (FSM.h M (q, x)) = {}›*) by force then have "card (snd ` Set.filter (λ (y',q') . y' = y) (h M (q,x))) = 0" by simp then show "?thesis" (*goal: ‹FSM.h_obs M q x y = None›*) unfolding h_obs_simps Let_def ‹snd ` Set.filter (λ (y',q') . y' = y) (h M (q,x)) = {}› (*goal: ‹(if card {} = 1 then Some (the_elem {}) else None) = None›*) by auto qed qed lemma h_obs_Some : assumes "observable M" shows "(h_obs M q x y = Some q') = ({q' . (q,x,y,q') ∈ transitions M} = {q'})" proof (standard) (*goals: 1. ‹FSM.h_obs M q x y = Some q' ⟹ {q'. (q, x, y, q') ∈ FSM.transitions M} = {q'}› 2. ‹{q'. (q, x, y, q') ∈ FSM.transitions M} = {q'} ⟹ FSM.h_obs M q x y = Some q'›*) have "*": "snd ` Set.filter (λ (y',q') . y' = y) (h M (q,x)) = {q' . (q,x,y,q') ∈ transitions M}" unfolding h.simps (*goal: ‹snd ` Set.filter (λ(y', q'). y' = y) (FSM.h M (q, x)) = {q'. (q, x, y, q') ∈ FSM.transitions M}›*) by force show "h_obs M q x y = Some q' ⟹ ({q' . (q,x,y,q') ∈ transitions M} = {q'})" proof (-) (*goal: ‹FSM.h_obs M q x y = Some q' ⟹ {q'. (q, x, y, q') ∈ FSM.transitions M} = {q'}›*) assume "h_obs M q x y = Some q'" (*‹FSM.h_obs (M::('a, 'b, 'c) fsm) (q::'a) (x::'b) (y::'c) = Some (q'::'a)›*) then have "(snd ` Set.filter (λ (y',q') . y' = y) (h M (q,x))) ≠ {}" by force then have "card (snd ` Set.filter (λ (y',q') . y' = y) (h M (q,x))) > 0" unfolding h_simps (*goal: ‹(0::nat) < card (snd ` Set.filter (λ(y'::'c, q'::'a). y' = (y::'c)) {(y::'c, q'::'a). (q::'a, x::'b, y, q') ∈ FSM.transitions (M::('a, 'b, 'c) fsm)})›*) using fsm_transitions_finite[of M] (*‹finite (FSM.transitions M)›*) by (metis assms (*‹observable (M::('a, 'b, 'c) fsm)›*) card_0_eq (*‹finite (?A::?'a set) ⟹ (card ?A = (0::nat)) = (?A = {})›*) h_observable_card( (*‹observable (?M::(?'a, ?'b, ?'c) fsm) ⟹ finite (snd ` Set.filter (λ(y'::?'c, q'::?'a). y' = (?y::?'c)) (FSM.h ?M (?q::?'a, ?x::?'b)))›*) 2) h_simps (*‹FSM.h (?M::(?'b, ?'c, ?'a) fsm) (?q::?'b, ?x::?'c) = {(y::?'a, q'::?'b). (?q, ?x, y, q') ∈ FSM.transitions ?M}›*) neq0_conv (*‹((?n::nat) ≠ (0::nat)) = ((0::nat) < ?n)›*)) moreover have "card (snd ` Set.filter (λ (y',q') . y' = y) (h M (q,x))) ≤ 1" using assms (*‹observable M›*) unfolding observable_alt_def h_simps (*goal: ‹card (snd ` Set.filter (λ(y', q'). y' = y) {(y, q'). (q, x, y, q') ∈ FSM.transitions M}) ≤ 1›*) by (metis assms (*‹observable M›*) h_observable_card( (*‹observable ?M ⟹ card (snd ` Set.filter (λ(y', q'). y' = ?y) (FSM.h ?M (?q, ?x))) ≤ 1›*) 1) h_simps (*‹FSM.h ?M (?q, ?x) = {(y, q'). (?q, ?x, y, q') ∈ FSM.transitions ?M}›*)) ultimately have "card (snd ` Set.filter (λ (y',q') . y' = y) (h M (q,x))) = 1" by auto then have "(snd ` Set.filter (λ (y',q') . y' = y) (h M (q,x))) = {q'}" using ‹h_obs M q x y = Some q'› (*‹FSM.h_obs M q x y = Some q'›*) unfolding h_obs_simps Let_def (*goal: ‹snd ` Set.filter (λ(y', q'). y' = y) (FSM.h M (q, x)) = {q'}›*) by (metis card_1_singletonE (*‹⟦card ?A = 1; ⋀x. ?A = {x} ⟹ ?thesis⟧ ⟹ ?thesis›*) option.inject (*‹(Some ?x2.0 = Some ?y2.0) = (?x2.0 = ?y2.0)›*) the_elem_eq (*‹the_elem {?x} = ?x›*)) then show "?thesis" (*goal: ‹{q'. (q, x, y, q') ∈ FSM.transitions M} = {q'}›*) using "*" (*‹snd ` Set.filter (λ(y', q'). y' = y) (FSM.h M (q, x)) = {q'. (q, x, y, q') ∈ FSM.transitions M}›*) unfolding h.simps (*goal: ‹{q'. (q, x, y, q') ∈ FSM.transitions M} = {q'}›*) by blast qed show "({q' . (q,x,y,q') ∈ transitions M} = {q'}) ⟹ (h_obs M q x y = Some q')" proof (-) (*goal: ‹{q'. (q, x, y, q') ∈ FSM.transitions M} = {q'} ⟹ FSM.h_obs M q x y = Some q'›*) assume "({q' . (q,x,y,q') ∈ transitions M} = {q'})" (*‹{q'::'a. (q::'a, x::'b, y::'c, q') ∈ FSM.transitions (M::('a, 'b, 'c) fsm)} = {q'::'a}›*) then have "snd ` Set.filter (λ (y',q') . y' = y) (h M (q,x)) = {q'}" unfolding h.simps (*goal: ‹snd ` Set.filter (λ(y'::'c, q'::'a). y' = (y::'c)) (FSM.h (M::('a, 'b, 'c) fsm) (q::'a, x::'b)) = {q'::'a}›*) by force then show "?thesis" (*goal: ‹FSM.h_obs M q x y = Some q'›*) unfolding Let_def (*goal: ‹FSM.h_obs M q x y = Some q'›*) by simp qed qed lemma h_obs_state : assumes "h_obs M q x y = Some q'" shows "q' ∈ states M" proof (cases "card (snd ` Set.filter (λ (y',q') . y' = y) (h M (q,x))) = 1") (*goals: 1. ‹card (snd ` Set.filter (λ(y'::'c, q'::'a). y' = (y::'c)) (FSM.h (M::('a, 'b, 'c) fsm) (q::'a, x::'b))) = (1::nat) ⟹ (q'::'a) ∈ FSM.states M› 2. ‹card (snd ` Set.filter (λ(y'::'c, q'::'a). y' = (y::'c)) (FSM.h (M::('a, 'b, 'c) fsm) (q::'a, x::'b))) ≠ (1::nat) ⟹ (q'::'a) ∈ FSM.states M›*) case True (*‹card (snd ` Set.filter (λ(y', q'). y' = y) (FSM.h M (q, x))) = 1›*) then have "(snd ` Set.filter (λ (y',q') . y' = y) (h M (q,x))) = {q'}" using ‹h_obs M q x y = Some q'› (*‹FSM.h_obs M q x y = Some q'›*) unfolding h_obs_simps Let_def (*goal: ‹snd ` Set.filter (λ(y', q'). y' = y) (FSM.h M (q, x)) = {q'}›*) by (metis card_1_singletonE (*‹⟦card (?A::?'a set) = (1::nat); ⋀x::?'a. ?A = {x} ⟹ ?thesis::bool⟧ ⟹ ?thesis›*) option.inject (*‹(Some (?x2.0::?'a) = Some (?y2.0::?'a)) = (?x2.0 = ?y2.0)›*) the_elem_eq (*‹the_elem {?x::?'a} = ?x›*)) then have "(q,x,y,q') ∈ transitions M" unfolding h_simps (*goal: ‹(q, x, y, q') ∈ FSM.transitions M›*) by auto then show "?thesis" (*goal: ‹q' ∈ FSM.states M›*) by (metis fsm_transition_target (*‹?t ∈ FSM.transitions ?M ⟹ t_target ?t ∈ FSM.states ?M›*) snd_conv (*‹snd (?x1.0, ?x2.0) = ?x2.0›*)) next (*goal: ‹card (snd ` Set.filter (λ(y', q'). y' = y) (FSM.h M (q, x))) ≠ 1 ⟹ q' ∈ FSM.states M›*) case False (*‹card (snd ` Set.filter (λ(y', q'). y' = y) (FSM.h M (q, x))) ≠ 1›*) then have "h_obs M q x y = None" using False (*‹card (snd ` Set.filter (λ(y', q'). y' = y) (FSM.h M (q, x))) ≠ 1›*) unfolding h_obs_simps Let_def (*goal: ‹(if card (snd ` Set.filter (λ(y', q'). y' = y) (FSM.h M (q, x))) = 1 then Some (the_elem (snd ` Set.filter (λ(y', q'). y' = y) (FSM.h M (q, x)))) else None) = None›*) by auto then show "?thesis" (*goal: ‹q' ∈ FSM.states M›*) using assms (*‹FSM.h_obs M q x y = Some q'›*) by auto qed fun after :: "('a,'b,'c) fsm ⇒ 'a ⇒ ('b × 'c) list ⇒ 'a" where "after M q [] = q" | "after M q ((x,y)#io) = after M (the (h_obs M q x y)) io" (*abbreviation(input) "after_initial M io ≡ after M (initial M) io" *) abbreviation "after_initial M io ≡ after M (initial M) io" lemma after_path : assumes "observable M" and "path M q p" shows "after M q (p_io p) = target q p" using assms(2) (*‹path (M::('a, 'b, 'c) fsm) (q::'a) (p::('a × 'b × 'c × 'a) list)›*) proof (induction p arbitrary: q rule: list.induct) (*goals: 1. ‹⋀q. path M q [] ⟹ after M q (p_io []) = target q []› 2. ‹⋀x1 x2 q. ⟦⋀q. path M q x2 ⟹ after M q (p_io x2) = target q x2; path M q (x1 # x2)⟧ ⟹ after M q (p_io (x1 # x2)) = target q (x1 # x2)›*) case Nil (*‹path M q []›*) then show "?case" (*goal: ‹after M q (p_io []) = target q []›*) by auto next (*goal: ‹⋀x1 x2 q. ⟦⋀q. path M q x2 ⟹ after M q (p_io x2) = target q x2; path M q (x1 # x2)⟧ ⟹ after M q (p_io (x1 # x2)) = target q (x1 # x2)›*) case (Cons t p) (*‹path (M::('a, 'b, 'c) fsm) (?q::'a) (p::('a × 'b × 'c × 'a) list) ⟹ after M ?q (p_io p) = target ?q p› ‹path M q (t # p)›*) then have "t ∈ transitions M" and "path M (t_target t) p" and "t_source t = q" apply - (*goals: 1. ‹⟦⋀q. path M q p ⟹ after M q (p_io p) = target q p; path M q (t # p)⟧ ⟹ t ∈ FSM.transitions M› 2. ‹⟦⋀q. path M q p ⟹ after M q (p_io p) = target q p; path M q (t # p)⟧ ⟹ path M (t_target t) p› 3. ‹⟦⋀q. path M q p ⟹ after M q (p_io p) = target q p; path M q (t # p)⟧ ⟹ t_source t = q› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*proven 3 subgoals*) . have "⋀ q' . (q, t_input t, t_output t, q') ∈ FSM.transitions M ⟹ q' = t_target t" using observable_transition_unique[OF assms ( 1 ) ‹t ∈ transitions M›] (*‹∃!t'. t' ∈ FSM.transitions M ∧ t_source t' = t_source t ∧ t_input t' = t_input t ∧ t_output t' = t_output t›*) ‹t ∈ transitions M› (*‹t ∈ FSM.transitions M›*) using ‹t_source t = q› (*‹t_source t = q›*) assms(1) (*‹observable M›*) by auto then have "({q'. (q, t_input t, t_output t, q') ∈ FSM.transitions M} = {t_target t})" using ‹t ∈ transitions M› (*‹t ∈ FSM.transitions M›*) ‹t_source t = q› (*‹t_source t = q›*) by auto then have "(h_obs M q (t_input t) (t_output t)) = Some (t_target t)" using h_obs_Some[OF assms ( 1 ), of q "t_input t" "t_output t" "t_target t"] (*‹(FSM.h_obs M q (t_input t) (t_output t) = Some (t_target t)) = ({q'. (q, t_input t, t_output t, q') ∈ FSM.transitions M} = {t_target t})›*) by blast then have "after M q (p_io (t#p)) = after M (t_target t) (p_io p)" by auto moreover have "target (t_target t) p = target q (t#p)" using ‹t_source t = q› (*‹t_source t = q›*) by auto ultimately show "?case" (*goal: ‹after (M::('a::type, 'b::type, 'c::type) fsm) (q::'a::type) (p_io ((t::'a::type × 'b::type × 'c::type × 'a::type) # (p::('a::type × 'b::type × 'c::type × 'a::type) list))) = target q (t # p)›*) using Cons.IH[OF ‹path M (t_target t) p›] (*‹after M (t_target t) (p_io p) = target (t_target t) p›*) by simp qed lemma observable_after_path : assumes "observable M" and "io ∈ LS M q" obtains p where "path M q p" and "p_io p = io" and "target q p = after M q io" using after_path[OF assms ( 1 )] (*‹path M ?q ?p ⟹ after M ?q (p_io ?p) = target ?q ?p›*) using assms(2) (*‹(io::('b × 'c) list) ∈ LS (M::('a, 'b, 'c) fsm) (q::'a)›*) by auto lemma h_obs_from_LS : assumes "observable M" and "[(x,y)] ∈ LS M q" obtains q' where "h_obs M q x y = Some q'" using assms(2) (*‹[(x, y)] ∈ LS M q›*) h_obs_None[OF assms ( 1 ), of q x y] (*‹(FSM.h_obs M q x y = None) = (∄q'. (q, x, y, q') ∈ FSM.transitions M)›*) by force lemma after_h_obs : assumes "observable M" and "h_obs M q x y = Some q'" shows "after M q [(x,y)] = q'" proof (-) (*goal: ‹after (M::('a, 'b, 'c) fsm) (q::'a) [(x::'b, y::'c)] = (q'::'a)›*) have "path M q [(q,x,y,q')]" using assms(2) (*‹FSM.h_obs M q x y = Some q'›*) unfolding h_obs_Some[OF assms ( 1 )] (*goal: ‹path M q [(q, x, y, q')]›*) using single_transition_path (*‹(?t::?'a × ?'b × ?'c × ?'a) ∈ FSM.transitions (?M::(?'a, ?'b, ?'c) fsm) ⟹ path ?M (t_source ?t) [?t]›*) by fastforce then show "?thesis" (*goal: ‹after M q [(x, y)] = q'›*) using assms(2) (*‹FSM.h_obs M q x y = Some q'›*) after_path[OF assms ( 1 ), of q "[(q,x,y,q')]"] (*‹path M q [(q, x, y, q')] ⟹ after M q (p_io [(q, x, y, q')]) = target q [(q, x, y, q')]›*) by auto qed lemma after_h_obs_prepend : assumes "observable M" and "h_obs M q x y = Some q'" and "io ∈ LS M q'" shows "after M q ((x,y)#io) = after M q' io" proof (-) (*goal: ‹after (M::('a, 'b, 'c) fsm) (q::'a) ((x::'b, y::'c) # (io::('b × 'c) list)) = after M (q'::'a) io›*) obtain p where "path M q' p" and "p_io p = io" (*goal: ‹(⋀p. ⟦path M q' p; p_io p = io⟧ ⟹ thesis) ⟹ thesis›*) using assms(3) (*‹io ∈ LS M q'›*) by auto then have "after M q' io = target q' p" using after_path[OF assms ( 1 )] (*‹path M ?q ?p ⟹ after M ?q (p_io ?p) = target ?q ?p›*) by blast have "path M q ((q,x,y,q')#p)" using assms(2) (*‹FSM.h_obs M q x y = Some q'›*) path_prepend_t[OF ‹path M q' p›, of q x y] (*‹(q, x, y, q') ∈ FSM.transitions M ⟹ path M q ((q, x, y, q') # p)›*) unfolding h_obs_Some[OF assms ( 1 )] (*goal: ‹path M q ((q, x, y, q') # p)›*) by auto moreover have "p_io ((q,x,y,q')#p) = (x,y)#io" using ‹p_io p = io› (*‹p_io p = io›*) by auto ultimately have "after M q ((x,y)#io) = target q ((q,x,y,q')#p)" using after_path[OF assms ( 1 ), of q "(q,x,y,q')#p"] (*‹path M q ((q, x, y, q') # p) ⟹ after M q (p_io ((q, x, y, q') # p)) = target q ((q, x, y, q') # p)›*) by simp moreover have "target q ((q,x,y,q')#p) = target q' p" by auto ultimately show "?thesis" (*goal: ‹after M q ((x, y) # io) = after M q' io›*) using ‹after M q' io = target q' p› (*‹after M q' io = target q' p›*) by simp qed lemma after_split : assumes "observable M" and "α@γ ∈ LS M q" shows "after M (after M q α) γ = after M q (α @ γ)" proof (-) (*goal: ‹after M (after M q α) γ = after M q (α @ γ)›*) obtain p1 and p2 where "path M q p1" and "path M (target q p1) p2" and "p_io p1 = α" and "p_io p2 = γ" (*goal: ‹(⋀p1 p2. ⟦path M q p1; path M (target q p1) p2; p_io p1 = α; p_io p2 = γ⟧ ⟹ thesis) ⟹ thesis›*) using language_state_split[OF assms ( 2 )] (*‹(⋀p1 p2. ⟦path M q p1; path M (target q p1) p2; p_io p1 = α; p_io p2 = γ⟧ ⟹ ?thesis) ⟹ ?thesis›*) by blast then have "path M q (p1@p2)" and "p_io (p1@p2) = (α @ γ)" apply - (*goals: 1. ‹⟦path M q p1; path M (target q p1) p2; p_io p1 = α; p_io p2 = γ⟧ ⟹ path M q (p1 @ p2)› 2. ‹⟦path M q p1; path M (target q p1) p2; p_io p1 = α; p_io p2 = γ⟧ ⟹ p_io (p1 @ p2) = α @ γ› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . then have "after M q (α @ γ) = target q (p1@p2)" using assms(1) (*‹observable M›*) by (metis (mono_tags, lifting) after_path (*‹⟦observable ?M; path ?M ?q ?p⟧ ⟹ after ?M ?q (p_io ?p) = target ?q ?p›*)) moreover have "after M q α = target q p1" using ‹path M q p1› (*‹path (M::('a, 'b, 'c) fsm) (q::'a) (p1::('a × 'b × 'c × 'a) list)›*) ‹p_io p1 = α› (*‹p_io (p1::('a × 'b × 'c × 'a) list) = (α::('b × 'c) list)›*) assms(1) (*‹observable (M::('a, 'b, 'c) fsm)›*) by (metis (mono_tags, lifting) after_path (*‹⟦observable ?M; path ?M ?q ?p⟧ ⟹ after ?M ?q (p_io ?p) = target ?q ?p›*)) moreover have "after M (target q p1) γ = target (target q p1) p2" using ‹path M (target q p1) p2› (*‹path M (target q p1) p2›*) ‹p_io p2 = γ› (*‹p_io p2 = γ›*) assms(1) (*‹observable M›*) by (metis (mono_tags, lifting) after_path (*‹⟦observable ?M; path ?M ?q ?p⟧ ⟹ after ?M ?q (p_io ?p) = target ?q ?p›*)) moreover have "target (target q p1) p2 = target q (p1@p2)" by auto ultimately show "?thesis" (*goal: ‹after M (after M q α) γ = after M q (α @ γ)›*) by auto qed lemma after_io_targets : assumes "observable M" and "io ∈ LS M q" shows "after M q io = the_elem (io_targets M io q)" proof (-) (*goal: ‹after M q io = the_elem (io_targets M io q)›*) have "after M q io ∈ io_targets M io q" using after_path[OF assms ( 1 )] (*‹path M ?q ?p ⟹ after M ?q (p_io ?p) = target ?q ?p›*) assms(2) (*‹(io::('b × 'c) list) ∈ LS (M::('a, 'b, 'c) fsm) (q::'a)›*) unfolding io_targets.simps LS.simps (*goal: ‹after M q io ∈ {target q p |p. path M q p ∧ p_io p = io}›*) by blast then show "?thesis" (*goal: ‹after M q io = the_elem (io_targets M io q)›*) using observable_io_targets[OF assms] (*‹(⋀q'. io_targets M io q = {q'} ⟹ ?thesis) ⟹ ?thesis›*) by (metis singletonD (*‹(?b::?'a) ∈ {?a::?'a} ⟹ ?b = ?a›*) the_elem_eq (*‹the_elem {?x::?'a} = ?x›*)) qed lemma after_language_subset : assumes "observable M" and "α@γ ∈ L M" and "β ∈ LS M (after_initial M (α@γ))" shows "γ@β ∈ LS M (after_initial M α)" by (metis after_io_targets (*‹⟦observable ?M; ?io ∈ LS ?M ?q⟧ ⟹ after ?M ?q ?io = the_elem (io_targets ?M ?io ?q)›*) after_split (*‹⟦observable ?M; ?α @ ?γ ∈ LS ?M ?q⟧ ⟹ after ?M (after ?M ?q ?α) ?γ = after ?M ?q (?α @ ?γ)›*) assms( (*‹observable M›*) 1) assms( (*‹α @ γ ∈ L M›*) 2) assms( (*‹β ∈ LS M (after_initial M (α @ γ))›*) 3) language_io_target_append (*‹⟦?q' ∈ io_targets ?M ?io1.0 ?q; ?io2.0 ∈ LS ?M ?q'⟧ ⟹ ?io1.0 @ ?io2.0 ∈ LS ?M ?q›*) language_prefix (*‹?io1.0 @ ?io2.0 ∈ LS ?M ?q ⟹ ?io1.0 ∈ LS ?M ?q›*) observable_io_targets (*‹⟦observable ?M; ?io ∈ LS ?M ?q; ⋀q'. io_targets ?M ?io ?q = {q'} ⟹ ?thesis⟧ ⟹ ?thesis›*) observable_io_targets_language (*‹⟦?io1.0 @ ?io2.0 ∈ LS ?M ?q1.0; observable ?M; ?q2.0 ∈ io_targets ?M ?io1.0 ?q1.0⟧ ⟹ ?io2.0 ∈ LS ?M ?q2.0›*) singletonI (*‹?a ∈ {?a}›*) the_elem_eq (*‹the_elem {?x} = ?x›*)) lemma after_language_append_iff : assumes "observable M" and "α@γ ∈ L M" shows "β ∈ LS M (after_initial M (α@γ)) = (γ@β ∈ LS M (after_initial M α))" by (metis after_io_targets (*‹⟦observable (?M::(?'a::type, ?'b::type, ?'c::type) fsm); (?io::(?'b::type × ?'c::type) list) ∈ LS ?M (?q::?'a::type)⟧ ⟹ after ?M ?q ?io = the_elem (io_targets ?M ?io ?q)›*) after_language_subset (*‹⟦observable (?M::(?'a::type, ?'b::type, ?'c::type) fsm); (?α::(?'b::type × ?'c::type) list) @ (?γ::(?'b::type × ?'c::type) list) ∈ L ?M; (?β::(?'b::type × ?'c::type) list) ∈ LS ?M (after_initial ?M (?α @ ?γ))⟧ ⟹ ?γ @ ?β ∈ LS ?M (after_initial ?M ?α)›*) after_split (*‹⟦observable (?M::(?'a::type, ?'b::type, ?'c::type) fsm); (?α::(?'b::type × ?'c::type) list) @ (?γ::(?'b::type × ?'c::type) list) ∈ LS ?M (?q::?'a::type)⟧ ⟹ after ?M (after ?M ?q ?α) ?γ = after ?M ?q (?α @ ?γ)›*) assms( (*‹observable (M::('a::type, 'b::type, 'c::type) fsm)›*) 1) assms( (*‹(α::('b::type × 'c::type) list) @ (γ::('b::type × 'c::type) list) ∈ L (M::('a::type, 'b::type, 'c::type) fsm)›*) 2) language_prefix (*‹(?io1.0::(?'a::type × ?'b::type) list) @ (?io2.0::(?'a::type × ?'b::type) list) ∈ LS (?M::(?'c::type, ?'a::type, ?'b::type) fsm) (?q::?'c::type) ⟹ ?io1.0 ∈ LS ?M ?q›*) observable_io_targets (*‹⟦observable (?M::(?'a::type, ?'b::type, ?'c::type) fsm); (?io::(?'b::type × ?'c::type) list) ∈ LS ?M (?q::?'a::type); ⋀q'::?'a::type. io_targets ?M ?io ?q = {q'} ⟹ ?thesis::bool⟧ ⟹ ?thesis›*) observable_io_targets_language (*‹⟦(?io1.0::(?'a::type × ?'b::type) list) @ (?io2.0::(?'a::type × ?'b::type) list) ∈ LS (?M::(?'c::type, ?'a::type, ?'b::type) fsm) (?q1.0::?'c::type); observable ?M; (?q2.0::?'c::type) ∈ io_targets ?M ?io1.0 ?q1.0⟧ ⟹ ?io2.0 ∈ LS ?M ?q2.0›*) singletonI (*‹(?a::?'a::type) ∈ {?a}›*) the_elem_eq (*‹the_elem {?x::?'a::type} = ?x›*)) lemma h_obs_language_iff : assumes "observable M" shows "(x,y)#io ∈ LS M q = (∃ q' . h_obs M q x y = Some q' ∧ io ∈ LS M q')" (is "?P1 = ?P2") proof (standard) (*goals: 1. ‹(x, y) # io ∈ LS M q ⟹ ∃q'. FSM.h_obs M q x y = Some q' ∧ io ∈ LS M q'› 2. ‹∃q'. FSM.h_obs M q x y = Some q' ∧ io ∈ LS M q' ⟹ (x, y) # io ∈ LS M q›*) show "?P1 ⟹ ?P2" proof (-) (*goal: ‹(x, y) # io ∈ LS M q ⟹ ∃q'. FSM.h_obs M q x y = Some q' ∧ io ∈ LS M q'›*) assume "?P1" (*‹(x::'b, y::'c) # (io::('b × 'c) list) ∈ LS (M::('a, 'b, 'c) fsm) (q::'a)›*) then obtain t and p where "t ∈ transitions M" and "path M (t_target t) p" and "t_input t = x" and "t_output t = y" and "t_source t = q" and "p_io p = io" (*goal: ‹(⋀t p. ⟦t ∈ FSM.transitions M; path M (t_target t) p; t_input t = x; t_output t = y; t_source t = q; p_io p = io⟧ ⟹ thesis) ⟹ thesis›*) by auto then have "(q,x,y,t_target t) ∈ transitions M" by auto then have "h_obs M q x y = Some (t_target t)" unfolding h_obs_Some[OF assms] (*goal: ‹{q'. (q, x, y, q') ∈ FSM.transitions M} = {t_target t}›*) using assms (*‹observable M›*) by auto moreover have "io ∈ LS M (t_target t)" using ‹path M (t_target t) p› (*‹path M (t_target t) p›*) ‹p_io p = io› (*‹p_io (p::('a × 'b × 'c × 'a) list) = (io::('b × 'c) list)›*) by auto ultimately show "?P2" by blast qed show "?P2 ⟹ ?P1" unfolding h_obs_Some[OF assms] (*goal: ‹∃q'. {q'. (q, x, y, q') ∈ FSM.transitions M} = {q'} ∧ io ∈ LS M q' ⟹ (x, y) # io ∈ LS M q›*) using LS_prepend_transition[where io = io and M = M] (*‹⟦?t ∈ FSM.transitions M; io ∈ LS M (t_target ?t)⟧ ⟹ (t_input ?t, t_output ?t) # io ∈ LS M (t_source ?t)›*) by (metis fst_conv (*‹fst (?x1.0, ?x2.0) = ?x1.0›*) mem_Collect_eq (*‹(?a ∈ Collect ?P) = ?P ?a›*) singletonI (*‹?a ∈ {?a}›*) snd_conv (*‹snd (?x1.0, ?x2.0) = ?x2.0›*)) qed lemma after_language_iff : assumes "observable M" and "α ∈ LS M q" shows "(γ ∈ LS M (after M q α)) = (α@γ ∈ LS M q)" by (metis after_io_targets (*‹⟦observable ?M; ?io ∈ LS ?M ?q⟧ ⟹ after ?M ?q ?io = the_elem (io_targets ?M ?io ?q)›*) assms( (*‹observable M›*) 1) assms( (*‹α ∈ LS M q›*) 2) language_io_target_append (*‹⟦?q' ∈ io_targets ?M ?io1.0 ?q; ?io2.0 ∈ LS ?M ?q'⟧ ⟹ ?io1.0 @ ?io2.0 ∈ LS ?M ?q›*) observable_io_targets (*‹⟦observable ?M; ?io ∈ LS ?M ?q; ⋀q'. io_targets ?M ?io ?q = {q'} ⟹ ?thesis⟧ ⟹ ?thesis›*) observable_io_targets_language (*‹⟦?io1.0 @ ?io2.0 ∈ LS ?M ?q1.0; observable ?M; ?q2.0 ∈ io_targets ?M ?io1.0 ?q1.0⟧ ⟹ ?io2.0 ∈ LS ?M ?q2.0›*) singletonI (*‹?a ∈ {?a}›*) the_elem_eq (*‹the_elem {?x} = ?x›*)) (* TODO: generalise to non-observable FSMs *) lemma language_maximal_contained_prefix_ob : assumes "io ∉ LS M q" and "q ∈ states M" and "observable M" obtains io' x y io'' where "io = io'@[(x,y)]@io''" and "io' ∈ LS M q" and "io'@[(x,y)] ∉ LS M q" proof (-) (*goal: ‹(⋀(io'::('a::type × 'b::type) list) (x::'a::type) (y::'b::type) io''::('a::type × 'b::type) list. ⟦(io::('a::type × 'b::type) list) = io' @ [(x, y)] @ io''; io' ∈ LS (M::('c::type, 'a::type, 'b::type) fsm) (q::'c::type); io' @ [(x, y)] ∉ LS M q⟧ ⟹ thesis::bool) ⟹ thesis›*) have "∃ io' x y io'' . io = io'@[(x,y)]@io'' ∧ io' ∈ LS M q ∧ io'@[(x,y)] ∉ LS M q" using assms(1,2) (*‹io ∉ LS M q› ‹(q::'c) ∈ FSM.states (M::('c, 'a, 'b) fsm)›*) proof (induction io arbitrary: q) (*goals: 1. ‹⋀q::'c. ⟦[] ∉ LS (M::('c, 'a, 'b) fsm) q; q ∈ FSM.states M⟧ ⟹ ∃(io'::('a × 'b) list) (x::'a) (y::'b) io''::('a × 'b) list. [] = io' @ [(x, y)] @ io'' ∧ io' ∈ LS M q ∧ io' @ [(x, y)] ∉ LS M q› 2. ‹⋀(a::'a × 'b) (io::('a × 'b) list) q::'c. ⟦⋀q::'c. ⟦io ∉ LS (M::('c, 'a, 'b) fsm) q; q ∈ FSM.states M⟧ ⟹ ∃(io'::('a × 'b) list) (x::'a) (y::'b) io''::('a × 'b) list. io = io' @ [(x, y)] @ io'' ∧ io' ∈ LS M q ∧ io' @ [(x, y)] ∉ LS M q; a # io ∉ LS M q; q ∈ FSM.states M⟧ ⟹ ∃(io'::('a × 'b) list) (x::'a) (y::'b) io''::('a × 'b) list. a # io = io' @ [(x, y)] @ io'' ∧ io' ∈ LS M q ∧ io' @ [(x, y)] ∉ LS M q›*) case Nil (*‹[] ∉ LS M q› ‹q ∈ FSM.states M›*) then show "?case" (*goal: ‹∃io' x y io''. [] = io' @ [(x, y)] @ io'' ∧ io' ∈ LS M q ∧ io' @ [(x, y)] ∉ LS M q›*) by auto next (*goal: ‹⋀a io q. ⟦⋀q. ⟦io ∉ LS M q; q ∈ FSM.states M⟧ ⟹ ∃io' x y io''. io = io' @ [(x, y)] @ io'' ∧ io' ∈ LS M q ∧ io' @ [(x, y)] ∉ LS M q; a # io ∉ LS M q; q ∈ FSM.states M⟧ ⟹ ∃io' x y io''. a # io = io' @ [(x, y)] @ io'' ∧ io' ∈ LS M q ∧ io' @ [(x, y)] ∉ LS M q›*) case (Cons xy io) (*‹⟦io ∉ LS M ?q; ?q ∈ FSM.states M⟧ ⟹ ∃io' x y io''. io = io' @ [(x, y)] @ io'' ∧ io' ∈ LS M ?q ∧ io' @ [(x, y)] ∉ LS M ?q› ‹(xy::'a::type × 'b::type) # (io::('a::type × 'b::type) list) ∉ LS (M::('c::type, 'a::type, 'b::type) fsm) (q::'c::type)› ‹q ∈ FSM.states M›*) obtain x and y where "xy = (x,y)" (*goal: ‹(⋀x y. xy = (x, y) ⟹ thesis) ⟹ thesis›*) by fastforce show "?case" (*goal: ‹∃io' x y io''. xy # io = io' @ [(x, y)] @ io'' ∧ io' ∈ LS M q ∧ io' @ [(x, y)] ∉ LS M q›*) proof (cases "h_obs M q x y") (*goals: 1. ‹FSM.h_obs M q x y = None ⟹ ∃io' x y io''. xy # io = io' @ [(x, y)] @ io'' ∧ io' ∈ LS M q ∧ io' @ [(x, y)] ∉ LS M q› 2. ‹⋀a. FSM.h_obs M q x y = Some a ⟹ ∃io' x y io''. xy # io = io' @ [(x, y)] @ io'' ∧ io' ∈ LS M q ∧ io' @ [(x, y)] ∉ LS M q›*) case None (*‹FSM.h_obs M q x y = None›*) then have "[]@[(x,y)] ∉ LS M q" unfolding h_obs_None[OF assms ( 3 )] (*goal: ‹[] @ [(x, y)] ∉ LS M q›*) by auto moreover have "[] ∈ LS M q" using Cons.prems (*‹(xy::'a × 'b) # (io::('a × 'b) list) ∉ LS (M::('c, 'a, 'b) fsm) (q::'c)› ‹(q::'c) ∈ FSM.states (M::('c, 'a, 'b) fsm)›*) by auto moreover have "(x,y)#io = []@[(x,y)]@io" using Cons.prems (*‹(xy::'a × 'b) # (io::('a × 'b) list) ∉ LS (M::('c, 'a, 'b) fsm) (q::'c)› ‹q ∈ FSM.states M›*) unfolding ‹xy = (x,y)› (*goal: ‹(x, y) # io = [] @ [(x, y)] @ io›*) by auto ultimately show "?thesis" (*goal: ‹∃io' x y io''. xy # io = io' @ [(x, y)] @ io'' ∧ io' ∈ LS M q ∧ io' @ [(x, y)] ∉ LS M q›*) unfolding ‹xy = (x,y)› (*goal: ‹∃io' xa ya io''. (x, y) # io = io' @ [(xa, ya)] @ io'' ∧ io' ∈ LS M q ∧ io' @ [(xa, ya)] ∉ LS M q›*) by blast next (*goal: ‹⋀a. FSM.h_obs M q x y = Some a ⟹ ∃io' x y io''. xy # io = io' @ [(x, y)] @ io'' ∧ io' ∈ LS M q ∧ io' @ [(x, y)] ∉ LS M q›*) case (Some q') (*‹FSM.h_obs M q x y = Some q'›*) then have "io ∉ LS M q'" using h_obs_language_iff[OF assms ( 3 ), of x y io q] (*‹((x, y) # io ∈ LS M q) = (∃q'. FSM.h_obs M q x y = Some q' ∧ io ∈ LS M q')›*) Cons.prems(1) (*‹xy # io ∉ LS M q›*) unfolding ‹xy = (x,y)› (*goal: ‹io ∉ LS M q'›*) by auto then obtain io' and x' and y' and io'' where "io = io'@[(x',y')]@io''" and "io' ∈ LS M q'" and "io'@[(x',y')] ∉ LS M q'" (*goal: ‹(⋀io' x' y' io''. ⟦io = io' @ [(x', y')] @ io''; io' ∈ LS M q'; io' @ [(x', y')] ∉ LS M q'⟧ ⟹ thesis) ⟹ thesis›*) using Cons.IH[OF _ h_obs_state [ OF Some ]] (*‹io ∉ LS M q' ⟹ ∃io' x y io''. io = io' @ [(x, y)] @ io'' ∧ io' ∈ LS M q' ∧ io' @ [(x, y)] ∉ LS M q'›*) by blast have "xy#io = (xy#io')@[(x',y')]@io''" using ‹io = io'@[(x',y')]@io''› (*‹io = io' @ [(x', y')] @ io''›*) by auto moreover have "(xy#io') ∈ LS M q" using ‹io' ∈ LS M q'› (*‹io' ∈ LS M q'›*) Some (*‹FSM.h_obs M q x y = Some q'›*) unfolding ‹xy = (x,y)› h_obs_language_iff[OF assms ( 3 )] (*goal: ‹∃q'. FSM.h_obs M q x y = Some q' ∧ io' ∈ LS M q'›*) by blast moreover have "(xy#io')@[(x',y')] ∉ LS M q" using ‹io'@[(x',y')] ∉ LS M q'› (*‹io' @ [(x', y')] ∉ LS M q'›*) Some (*‹FSM.h_obs M q x y = Some q'›*) h_obs_language_iff[OF assms ( 3 ), of x y "io'@[(x',y')]" q] (*‹((x, y) # io' @ [(x', y')] ∈ LS M q) = (∃q'. FSM.h_obs M q x y = Some q' ∧ io' @ [(x', y')] ∈ LS M q')›*) unfolding ‹xy = (x,y)› (*goal: ‹((x, y) # io') @ [(x', y')] ∉ LS M q›*) by auto ultimately show "?thesis" (*goal: ‹∃io' x y io''. xy # io = io' @ [(x, y)] @ io'' ∧ io' ∈ LS M q ∧ io' @ [(x, y)] ∉ LS M q›*) by blast qed qed then show "?thesis" (*goal: ‹thesis›*) using that (*‹⟦(io::('a::type × 'b::type) list) = (?io'::('a::type × 'b::type) list) @ [(?x::'a::type, ?y::'b::type)] @ (?io''::('a::type × 'b::type) list); ?io' ∈ LS (M::('c::type, 'a::type, 'b::type) fsm) (q::'c::type); ?io' @ [(?x, ?y)] ∉ LS M q⟧ ⟹ thesis::bool›*) by blast qed lemma after_is_state : assumes "observable M" assumes "io ∈ LS M q" shows "FSM.after M q io ∈ states M" using assms (*‹observable M› ‹io ∈ LS M q›*) by (metis observable_after_path (*‹⟦observable ?M; ?io ∈ LS ?M ?q; ⋀p. ⟦path ?M ?q p; p_io p = ?io; target ?q p = after ?M ?q ?io⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*) path_target_is_state (*‹path ?M ?q ?p ⟹ target ?q ?p ∈ FSM.states ?M›*)) lemma after_reachable_initial : assumes "observable M" and "io ∈ L M" shows "after_initial M io ∈ reachable_states M" proof (-) (*goal: ‹after_initial M io ∈ reachable_states M›*) obtain p where "path M (initial M) p" and "p_io p = io" (*goal: ‹(⋀p. ⟦path M (FSM.initial M) p; p_io p = io⟧ ⟹ thesis) ⟹ thesis›*) using assms(2) (*‹io ∈ L M›*) by auto then have "after_initial M io = target (initial M) p" using after_path[OF assms ( 1 )] (*‹path M ?q ?p ⟹ after M ?q (p_io ?p) = target ?q ?p›*) by blast then show "?thesis" (*goal: ‹after_initial M io ∈ reachable_states M›*) unfolding reachable_states_def (*goal: ‹after_initial (M::('a::type, 'b::type, 'c::type) fsm) (io::('b::type × 'c::type) list) ∈ {target (FSM.initial M) p |p::('a::type × 'b::type × 'c::type × 'a::type) list. path M (FSM.initial M) p}›*) using ‹path M (initial M) p› (*‹path M (FSM.initial M) p›*) by blast qed lemma after_transition : assumes "observable M" and "(q,x,y,q') ∈ transitions M" shows "after M q [(x,y)] = q'" using after_path[OF assms ( 1 ) single_transition_path [ OF assms ( 2 ) ]] (*‹after M (t_source (q, x, y, q')) (p_io [(q, x, y, q')]) = target (t_source (q, x, y, q')) [(q, x, y, q')]›*) by auto lemma after_transition_exhaust : assumes "observable M" and "t ∈ transitions M" shows "t_target t = after M (t_source t) [(t_input t, t_output t)]" using after_transition[OF assms ( 1 )] (*‹(?q, ?x, ?y, ?q') ∈ FSM.transitions M ⟹ after M ?q [(?x, ?y)] = ?q'›*) assms(2) (*‹t ∈ FSM.transitions M›*) by (metis surjective_pairing (*‹?t = (fst ?t, snd ?t)›*)) lemma after_reachable : assumes "observable M" and "io ∈ LS M q" and "q ∈ reachable_states M" shows "after M q io ∈ reachable_states M" proof (-) (*goal: ‹after M q io ∈ reachable_states M›*) obtain p where "path M q p" and "p_io p = io" (*goal: ‹(⋀p. ⟦path M q p; p_io p = io⟧ ⟹ thesis) ⟹ thesis›*) using assms(2) (*‹io ∈ LS M q›*) by auto then have "after M q io = target q p" using after_path[OF assms ( 1 )] (*‹path M ?q ?p ⟹ after M ?q (p_io ?p) = target ?q ?p›*) by force obtain p' where "path M (initial M) p'" and "target (initial M) p' = q" (*goal: ‹(⋀p'::('a × 'b × 'c × 'a) list. ⟦path (M::('a, 'b, 'c) fsm) (FSM.initial M) p'; target (FSM.initial M) p' = (q::'a)⟧ ⟹ thesis::bool) ⟹ thesis›*) using assms(3) (*‹q ∈ reachable_states M›*) unfolding reachable_states_def (*goal: ‹(⋀p'. ⟦path M (FSM.initial M) p'; target (FSM.initial M) p' = q⟧ ⟹ thesis) ⟹ thesis›*) by blast then have "path M (initial M) (p'@p)" using ‹path M q p› (*‹path M q p›*) by auto moreover have "after M q io = target (initial M) (p'@p)" using ‹target (initial M) p' = q› (*‹target (FSM.initial M) p' = q›*) unfolding ‹after M q io = target q p› (*goal: ‹target q p = target (FSM.initial M) (p' @ p)›*) by auto ultimately show "?thesis" (*goal: ‹after M q io ∈ reachable_states M›*) unfolding reachable_states_def (*goal: ‹after M q io ∈ {target (FSM.initial M) p |p. path M (FSM.initial M) p}›*) by blast qed lemma observable_after_language_append : assumes "observable M" and "io1 ∈ LS M q" and "io2 ∈ LS M (after M q io1)" shows "io1@io2 ∈ LS M q" using observable_after_path[OF assms ( 1 , 2 )] (*‹(⋀p. ⟦path M q p; p_io p = io1; target q p = after M q io1⟧ ⟹ ?thesis) ⟹ ?thesis›*) assms(3) (*‹(io2::('b × 'c) list) ∈ LS (M::('a, 'b, 'c) fsm) (after M (q::'a) (io1::('b × 'c) list))›*) proof (-) (*goal: ‹⟦⋀thesis. (⋀p. ⟦path M q p; p_io p = io1; target q p = after M q io1⟧ ⟹ thesis) ⟹ thesis; io2 ∈ LS M (after M q io1)⟧ ⟹ io1 @ io2 ∈ LS M q›*) assume a1: "⋀thesis. (⋀p. ⟦path M q p; p_io p = io1; target q p = after M q io1⟧ ⟹ thesis) ⟹ thesis" (*‹(⋀p::('a × 'b × 'c × 'a) list. ⟦path (M::('a, 'b, 'c) fsm) (q::'a) p; p_io p = (io1::('b × 'c) list); target q p = after M q io1⟧ ⟹ ?thesis::bool) ⟹ ?thesis›*) have "∃ps. io2 = p_io ps ∧ path M (after M q io1) ps" using ‹io2 ∈ LS M (after M q io1)› (*‹io2 ∈ LS M (after M q io1)›*) by auto moreover { assume "(∃ps. io2 = p_io ps ∧ path M (after M q io1) ps) ∧ (∀ps. io1 @ io2 ≠ p_io ps ∨ ¬ path M q ps)" (*‹(∃ps::('a × 'b × 'c × 'a) list. (io2::('b × 'c) list) = p_io ps ∧ path (M::('a, 'b, 'c) fsm) (after M (q::'a) (io1::('b × 'c) list)) ps) ∧ (∀ps::('a × 'b × 'c × 'a) list. io1 @ io2 ≠ p_io ps ∨ ¬ path M q ps)›*) then have "io1 @ io2 ∈ {p_io ps |ps. path M q ps}" using a1 (*‹(⋀p::('a × 'b × 'c × 'a) list. ⟦path (M::('a, 'b, 'c) fsm) (q::'a) p; p_io p = (io1::('b × 'c) list); target q p = after M q io1⟧ ⟹ ?thesis::bool) ⟹ ?thesis›*) by (metis (lifting) map_append (*‹map ?f (?xs @ ?ys) = map ?f ?xs @ map ?f ?ys›*) path_append (*‹⟦path ?M ?q ?p1.0; path ?M (target ?q ?p1.0) ?p2.0⟧ ⟹ path ?M ?q (?p1.0 @ ?p2.0)›*)) } ultimately show "?thesis" (*goal: ‹io1 @ io2 ∈ LS M q›*) by auto qed lemma observable_after_language_none : assumes "observable M" and "io1 ∈ LS M q" and "io2 ∉ LS M (after M q io1)" shows "io1@io2 ∉ LS M q" using after_path[OF assms ( 1 )] (*‹path (M::('a, 'b, 'c) fsm) (?q::'a) (?p::('a × 'b × 'c × 'a) list) ⟹ after M ?q (p_io ?p) = target ?q ?p›*) language_state_split[of io1 io2 M q] (*‹⟦(io1::('b::type × 'c::type) list) @ (io2::('b::type × 'c::type) list) ∈ LS (M::('a::type, 'b::type, 'c::type) fsm) (q::'a::type); ⋀(p1::('a::type × 'b::type × 'c::type × 'a::type) list) p2::('a::type × 'b::type × 'c::type × 'a::type) list. ⟦path M q p1; path M (target q p1) p2; p_io p1 = io1; p_io p2 = io2⟧ ⟹ ?thesis::bool⟧ ⟹ ?thesis›*) by (metis (mono_tags, lifting) assms( (*‹io2 ∉ LS M (after M q io1)›*) 3) language_intro (*‹path ?M ?q ?p ⟹ p_io ?p ∈ LS ?M ?q›*)) lemma observable_after_eq : assumes "observable M" and "after M q io1 = after M q io2" and "io1 ∈ LS M q" and "io2 ∈ LS M q" shows "io1@io ∈ LS M q ⟷ io2@io ∈ LS M q" using observable_after_language_append[OF assms ( 1 , 3 ), of io] (*‹io ∈ LS M (after M q io1) ⟹ io1 @ io ∈ LS M q›*) observable_after_language_append[OF assms ( 1 , 4 ), of io] (*‹io ∈ LS M (after M q io2) ⟹ io2 @ io ∈ LS M q›*) assms(2) (*‹after (M::('a, 'b, 'c) fsm) (q::'a) (io1::('b × 'c) list) = after M q (io2::('b × 'c) list)›*) by (metis assms( (*‹observable M›*) 1) language_prefix (*‹?io1.0 @ ?io2.0 ∈ LS ?M ?q ⟹ ?io1.0 ∈ LS ?M ?q›*) observable_after_language_none (*‹⟦observable ?M; ?io1.0 ∈ LS ?M ?q; ?io2.0 ∉ LS ?M (after ?M ?q ?io1.0)⟧ ⟹ ?io1.0 @ ?io2.0 ∉ LS ?M ?q›*)) lemma observable_after_target : assumes "observable M" and "io @ io' ∈ LS M q" and "path M (FSM.after M q io) p" and "p_io p = io'" shows "target (FSM.after M q io) p = (FSM.after M q (io @ io'))" proof (-) (*goal: ‹target (after M q io) p = after M q (io @ io')›*) obtain p' where "path M q p'" and "p_io p' = io @ io'" (*goal: ‹(⋀p'. ⟦path M q p'; p_io p' = io @ io'⟧ ⟹ thesis) ⟹ thesis›*) using ‹io @ io' ∈ LS M q› (*‹(io::('b × 'c) list) @ (io'::('b × 'c) list) ∈ LS (M::('a, 'b, 'c) fsm) (q::'a)›*) by auto then have "path M q (take (length io) p')" and "p_io (take (length io) p') = io" and "path M (target q (take (length io) p')) (drop (length io) p')" and "p_io (drop (length io) p') = io'" using path_io_split[of M q p' io io'] (*‹⟦path M q p'; p_io p' = io @ io'⟧ ⟹ path M q (take (length io) p')› ‹⟦path M q p'; p_io p' = io @ io'⟧ ⟹ p_io (take (length io) p') = io› ‹⟦path (M::('a::type, 'b::type, 'c::type) fsm) (q::'a::type) (p'::('a::type × 'b::type × 'c::type × 'a::type) list); p_io p' = (io::('b::type × 'c::type) list) @ (io'::('b::type × 'c::type) list)⟧ ⟹ path M (target q (take (length io) p')) (drop (length io) p')› ‹⟦path M q p'; p_io p' = io @ io'⟧ ⟹ p_io (drop (length io) p') = io'›*) apply - (*goals: 1. ‹⟦path M q p'; p_io p' = io @ io'; ⟦path M q p'; p_io p' = io @ io'⟧ ⟹ path M q (take (length io) p'); ⟦path M q p'; p_io p' = io @ io'⟧ ⟹ p_io (take (length io) p') = io; ⟦path M q p'; p_io p' = io @ io'⟧ ⟹ path M (target q (take (length io) p')) (drop (length io) p'); ⟦path M q p'; p_io p' = io @ io'⟧ ⟹ p_io (drop (length io) p') = io'⟧ ⟹ path M q (take (length io) p')› 2. ‹⟦path M q p'; p_io p' = io @ io'; ⟦path M q p'; p_io p' = io @ io'⟧ ⟹ path M q (take (length io) p'); ⟦path M q p'; p_io p' = io @ io'⟧ ⟹ p_io (take (length io) p') = io; ⟦path M q p'; p_io p' = io @ io'⟧ ⟹ path M (target q (take (length io) p')) (drop (length io) p'); ⟦path M q p'; p_io p' = io @ io'⟧ ⟹ p_io (drop (length io) p') = io'⟧ ⟹ p_io (take (length io) p') = io› 3. ‹⟦path M q p'; p_io p' = io @ io'; ⟦path M q p'; p_io p' = io @ io'⟧ ⟹ path M q (take (length io) p'); ⟦path M q p'; p_io p' = io @ io'⟧ ⟹ p_io (take (length io) p') = io; ⟦path M q p'; p_io p' = io @ io'⟧ ⟹ path M (target q (take (length io) p')) (drop (length io) p'); ⟦path M q p'; p_io p' = io @ io'⟧ ⟹ p_io (drop (length io) p') = io'⟧ ⟹ path M (target q (take (length io) p')) (drop (length io) p')› 4. ‹⟦path M q p'; p_io p' = io @ io'; ⟦path M q p'; p_io p' = io @ io'⟧ ⟹ path M q (take (length io) p'); ⟦path M q p'; p_io p' = io @ io'⟧ ⟹ p_io (take (length io) p') = io; ⟦path M q p'; p_io p' = io @ io'⟧ ⟹ path M (target q (take (length io) p')) (drop (length io) p'); ⟦path M q p'; p_io p' = io @ io'⟧ ⟹ p_io (drop (length io) p') = io'⟧ ⟹ p_io (drop (length io) p') = io'› 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 "FSM.after M q io = target q (take (length io) p')" using after_path (*‹⟦observable (?M::(?'a, ?'b, ?'c) fsm); path ?M (?q::?'a) (?p::(?'a × ?'b × ?'c × ?'a) list)⟧ ⟹ after ?M ?q (p_io ?p) = target ?q ?p›*) assms(1) (*‹observable M›*) by fastforce then have "p = (drop (length io) p')" using ‹path M (target q (take (length io) p')) (drop (length io) p')› (*‹path M (target q (take (length io) p')) (drop (length io) p')›*) ‹p_io (drop (length io) p') = io'› (*‹p_io (drop (length io) p') = io'›*) assms(3,4) (*‹path (M::('a, 'b, 'c) fsm) (after M (q::'a) (io::('b × 'c) list)) (p::('a × 'b × 'c × 'a) list)› ‹p_io (p::('a × 'b × 'c × 'a) list) = (io'::('b × 'c) list)›*) observable_path_unique[OF ‹observable M›] (*‹⟦path M ?q ?p; path M ?q ?p'; p_io ?p = p_io ?p'⟧ ⟹ ?p = ?p'›*) by force have "(FSM.after M q (io @ io')) = target q p'" using after_path[OF ‹observable M› ‹path M q p'›] (*‹after M q (p_io p') = target q p'›*) unfolding ‹p_io p' = io @ io'› (*goal: ‹after (M::('a::type, 'b::type, 'c::type) fsm) (q::'a::type) ((io::('b::type × 'c::type) list) @ (io'::('b::type × 'c::type) list)) = target q (p'::('a::type × 'b::type × 'c::type × 'a::type) list)›*) . moreover have "target (FSM.after M q io) p = target q p'" using ‹FSM.after M q io = target q (take (length io) p')› (*‹after M q io = target q (take (length io) p')›*) by (metis ‹p = drop (length io) p'› append_take_drop_id (*‹take ?n ?xs @ drop ?n ?xs = ?xs›*) path_append_target (*‹target ?q (?p1.0 @ ?p2.0) = target (target ?q ?p1.0) ?p2.0›*)) ultimately show "?thesis" (*goal: ‹target (after M q io) p = after M q (io @ io')›*) by simp qed fun is_in_language :: "('a,'b,'c) fsm ⇒ 'a ⇒ ('b ×'c) list ⇒ bool" where "is_in_language M q [] = True" | "is_in_language M q ((x,y)#io) = (case h_obs M q x y of None ⇒ False | Some q' ⇒ is_in_language M q' io)" lemma is_in_language_iff : assumes "observable M" and "q ∈ states M" shows "is_in_language M q io ⟷ io ∈ LS M q" using assms(2) (*‹q ∈ FSM.states M›*) proof (induction io arbitrary: q) (*goals: 1. ‹⋀q. q ∈ FSM.states M ⟹ is_in_language M q [] = ([] ∈ LS M q)› 2. ‹⋀a io q. ⟦⋀q. q ∈ FSM.states M ⟹ is_in_language M q io = (io ∈ LS M q); q ∈ FSM.states M⟧ ⟹ is_in_language M q (a # io) = (a # io ∈ LS M q)›*) case Nil (*‹q ∈ FSM.states M›*) then show "?case" (*goal: ‹is_in_language M q [] = ([] ∈ LS M q)›*) by auto next (*goal: ‹⋀a io q. ⟦⋀q. q ∈ FSM.states M ⟹ is_in_language M q io = (io ∈ LS M q); q ∈ FSM.states M⟧ ⟹ is_in_language M q (a # io) = (a # io ∈ LS M q)›*) case (Cons xy io) (*‹?q ∈ FSM.states M ⟹ is_in_language M ?q io = (io ∈ LS M ?q)› ‹q ∈ FSM.states M›*) obtain x and y where "xy = (x,y)" (*goal: ‹(⋀x y. xy = (x, y) ⟹ thesis) ⟹ thesis›*) using prod.exhaust (*‹(⋀x1 x2. ?y = (x1, x2) ⟹ ?P) ⟹ ?P›*) by metis show "?case" (*goal: ‹is_in_language M q (xy # io) = (xy # io ∈ LS M q)›*) unfolding ‹xy = (x,y)› (*goal: ‹is_in_language M q ((x, y) # io) = ((x, y) # io ∈ LS M q)›*) unfolding h_obs_language_iff[OF assms ( 1 ), of x y io q] (*goal: ‹is_in_language M q ((x, y) # io) = (∃q'. FSM.h_obs M q x y = Some q' ∧ io ∈ LS M q')›*) unfolding is_in_language.simps (*goal: ‹(case FSM.h_obs M q x y of None ⇒ False | Some q' ⇒ is_in_language M q' io) = (∃q'. FSM.h_obs M q x y = Some q' ∧ io ∈ LS M q')›*) apply ((cases "h_obs M q x y")[1]) (*goals: 1. ‹FSM.h_obs M q x y = None ⟹ (case FSM.h_obs M q x y of None ⇒ False | Some q' ⇒ is_in_language M q' io) = (∃q'. FSM.h_obs M q x y = Some q' ∧ io ∈ LS M q')› 2. ‹⋀a. FSM.h_obs M q x y = Some a ⟹ (case FSM.h_obs M q x y of None ⇒ False | Some q' ⇒ is_in_language M q' io) = (∃q'. FSM.h_obs M q x y = Some q' ∧ io ∈ LS M q')› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((metis Cons.IH (*‹?q ∈ FSM.states M ⟹ is_in_language M ?q io = (io ∈ LS M ?q)›*) h_obs_state (*‹FSM.h_obs ?M ?q ?x ?y = Some ?q' ⟹ ?q' ∈ FSM.states ?M›*) option.simps( (*‹(case Some ?x2.0 of None ⇒ ?f1.0 | Some x ⇒ ?f2.0 x) = ?f2.0 ?x2.0›*) 5))[1]) (*proven 2 subgoals*) . qed lemma observable_paths_for_io : assumes "observable M" and "io ∈ LS M q" obtains p where "paths_for_io M q io = {p}" proof (-) (*goal: ‹(⋀p::('a × 'b × 'c × 'a) list. paths_for_io (M::('a, 'b, 'c) fsm) (q::'a) (io::('b × 'c) list) = {p} ⟹ thesis::bool) ⟹ thesis›*) obtain p where "path M q p" and "p_io p = io" (*goal: ‹(⋀p. ⟦path M q p; p_io p = io⟧ ⟹ thesis) ⟹ thesis›*) using assms(2) (*‹io ∈ LS M q›*) by auto then have "p ∈ paths_for_io M q io" unfolding paths_for_io_def (*goal: ‹(p::('a × 'b × 'c × 'a) list) ∈ {p::('a × 'b × 'c × 'a) list. path (M::('a, 'b, 'c) fsm) (q::'a) p ∧ p_io p = (io::('b × 'c) list)}›*) by blast then show "?thesis" (*goal: ‹thesis›*) using that[of p] (*‹paths_for_io M q io = {p} ⟹ thesis›*) using observable_path_unique[OF assms ( 1 ) ‹path M q p›] (*‹⟦path M q ?p'; p_io p = p_io ?p'⟧ ⟹ p = ?p'›*) ‹p_io p = io› (*‹p_io p = io›*) unfolding paths_for_io_def (*goal: ‹thesis›*) by force qed lemma io_targets_language : assumes "q' ∈ io_targets M io q" shows "io ∈ LS M q" using assms (*‹q' ∈ io_targets M io q›*) by auto lemma observable_after_reachable_surj : assumes "observable M" shows "(after_initial M) ` (L M) = reachable_states M" proof (standard) (*goals: 1. ‹after_initial M ` L M ⊆ reachable_states M› 2. ‹reachable_states M ⊆ after_initial M ` L M›*) show "after_initial M ` L M ⊆ reachable_states M" using after_reachable[OF assms _ reachable_states_initial] (*‹?io ∈ L M ⟹ after_initial M ?io ∈ reachable_states M›*) by blast show "reachable_states M ⊆ after_initial M ` L M" unfolding reachable_states_def (*goal: ‹{target (FSM.initial M) p |p. path M (FSM.initial M) p} ⊆ after_initial M ` L M›*) using after_path[OF assms] (*‹path M ?q ?p ⟹ after M ?q (p_io ?p) = target ?q ?p›*) using image_iff (*‹(?z ∈ ?f ` ?A) = (∃x∈?A. ?z = ?f x)›*) by fastforce qed lemma observable_minimal_size_r_language_distinct : assumes "minimal M1" and "minimal M2" and "observable M1" and "observable M2" and "size_r M1 < size_r M2" shows "L M1 ≠ L M2" proof (standard) (*goal: ‹L M1 = L M2 ⟹ False›*) assume "L M1 = L M2" (*‹L (M1::('a, 'b, 'c) fsm) = L (M2::('d, 'b, 'c) fsm)›*) define V where "V = (λ q . SOME io . io ∈ L M1 ∧ after_initial M2 io = q)" have "⋀ q . q ∈ reachable_states M2 ⟹ V q ∈ L M1 ∧ after_initial M2 (V q) = q" proof (-) (*goal: ‹⋀q::'d. q ∈ reachable_states (M2::('d, 'b, 'c) fsm) ⟹ (V::'d ⇒ ('b × 'c) list) q ∈ L (M1::('a, 'b, 'c) fsm) ∧ after_initial M2 (V q) = q›*) fix q assume "q ∈ reachable_states M2" (*‹(q::'d) ∈ reachable_states (M2::('d, 'b, 'c) fsm)›*) then have "∃ io . io ∈ L M1 ∧ after_initial M2 io = q" unfolding ‹L M1 = L M2› (*goal: ‹∃io. io ∈ L M2 ∧ after_initial M2 io = q›*) by (metis assms( (*‹observable M2›*) 4) imageE (*‹⟦?b ∈ ?f ` ?A; ⋀x. ⟦?b = ?f x; x ∈ ?A⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*) observable_after_reachable_surj (*‹observable ?M ⟹ after_initial ?M ` L ?M = reachable_states ?M›*)) then show "V q ∈ L M1 ∧ after_initial M2 (V q) = q" unfolding V_def (*goal: ‹(SOME io. io ∈ L M1 ∧ after_initial M2 io = q) ∈ L M1 ∧ after_initial M2 (SOME io. io ∈ L M1 ∧ after_initial M2 io = q) = q›*) using someI_ex[of "λ io . io ∈ L M1 ∧ after_initial M2 io = q"] (*‹∃x. x ∈ L M1 ∧ after_initial M2 x = q ⟹ (SOME x. x ∈ L M1 ∧ after_initial M2 x = q) ∈ L M1 ∧ after_initial M2 (SOME x. x ∈ L M1 ∧ after_initial M2 x = q) = q›*) by blast qed then have "(after_initial M1) ` V ` reachable_states M2 ⊆ reachable_states M1" by (metis assms( (*‹observable M1›*) 3) image_mono (*‹?A ⊆ ?B ⟹ ?f ` ?A ⊆ ?f ` ?B›*) image_subsetI (*‹(⋀x. x ∈ ?A ⟹ ?f x ∈ ?B) ⟹ ?f ` ?A ⊆ ?B›*) observable_after_reachable_surj (*‹observable ?M ⟹ after_initial ?M ` L ?M = reachable_states ?M›*)) then have "card (after_initial M1 ` V ` reachable_states M2) ≤ size_r M1" using reachable_states_finite[of M1] (*‹finite (reachable_states (M1::('a, 'b, 'c) fsm))›*) by (meson card_mono (*‹⟦finite ?B; ?A ⊆ ?B⟧ ⟹ card ?A ≤ card ?B›*)) have "(after_initial M2) ` V ` reachable_states M2 = reachable_states M2" proof (standard) (*goals: 1. ‹after_initial M2 ` V ` reachable_states M2 ⊆ reachable_states M2› 2. ‹reachable_states M2 ⊆ after_initial M2 ` V ` reachable_states M2›*) show "after_initial M2 ` V ` reachable_states M2 ⊆ reachable_states M2" using ‹⋀ q . q ∈ reachable_states M2 ⟹ V q ∈ L M1 ∧ after_initial M2 (V q) = q› (*‹?q ∈ reachable_states M2 ⟹ V ?q ∈ L M1 ∧ after_initial M2 (V ?q) = ?q›*) by auto show "reachable_states M2 ⊆ after_initial M2 ` V ` reachable_states M2" using ‹⋀ q . q ∈ reachable_states M2 ⟹ V q ∈ L M1 ∧ after_initial M2 (V q) = q› (*‹?q ∈ reachable_states M2 ⟹ V ?q ∈ L M1 ∧ after_initial M2 (V ?q) = ?q›*) observable_after_reachable_surj[OF assms ( 4 )] (*‹after_initial M2 ` L M2 = reachable_states M2›*) unfolding ‹L M1 = L M2› (*goal: ‹reachable_states (M2::('d::type, 'b::type, 'c::type) fsm) ⊆ after_initial M2 ` (V::'d::type ⇒ ('b::type × 'c::type) list) ` reachable_states M2›*) using image_iff (*‹((?z::?'a) ∈ (?f::?'b ⇒ ?'a) ` (?A::?'b set)) = (∃x::?'b∈?A. ?z = ?f x)›*) by fastforce qed then have "card ((after_initial M2) ` V ` reachable_states M2) = size_r M2" by auto have "*": "finite (V ` reachable_states M2)" by (simp add: reachable_states_finite (*‹finite (reachable_states (?M::(?'a, ?'b, ?'c) fsm))›*)) have "**": "card ((after_initial M1) ` V ` reachable_states M2) < card ((after_initial M2) ` V ` reachable_states M2)" using assms(5) (*‹size_r M1 < size_r M2›*) ‹card (after_initial M1 ` V ` reachable_states M2) ≤ size_r M1› (*‹card (after_initial M1 ` V ` reachable_states M2) ≤ size_r M1›*) unfolding ‹card ((after_initial M2) ` V ` reachable_states M2) = size_r M2› (*goal: ‹card (after_initial M1 ` V ` reachable_states M2) < size_r M2›*) by linarith obtain io1 and io2 where "io1 ∈ V ` reachable_states M2" "io2 ∈ V ` reachable_states M2" "after_initial M2 io1 ≠ after_initial M2 io2" "after_initial M1 io1 = after_initial M1 io2" (*goal: ‹(⋀io1 io2. ⟦io1 ∈ V ` reachable_states M2; io2 ∈ V ` reachable_states M2; after_initial M2 io1 ≠ after_initial M2 io2; after_initial M1 io1 = after_initial M1 io2⟧ ⟹ thesis) ⟹ thesis›*) using finite_card_less_witnesses[OF * **] (*‹(⋀a b. ⟦a ∈ V ` reachable_states M2; b ∈ V ` reachable_states M2; after_initial M2 a ≠ after_initial M2 b; after_initial M1 a = after_initial M1 b⟧ ⟹ ?thesis) ⟹ ?thesis›*) by blast then have "io1 ∈ L M1" and "io2 ∈ L M1" and "io1 ∈ L M2" and "io2 ∈ L M2" using ‹⋀ q . q ∈ reachable_states M2 ⟹ V q ∈ L M1 ∧ after_initial M2 (V q) = q› (*‹?q ∈ reachable_states M2 ⟹ V ?q ∈ L M1 ∧ after_initial M2 (V ?q) = ?q›*) unfolding ‹L M1 = L M2› (*goals: 1. ‹io1 ∈ L M2› 2. ‹io2 ∈ L M2› 3. ‹io1 ∈ L M2› 4. ‹io2 ∈ L M2›*) apply - (*goals: 1. ‹⟦io1 ∈ V ` reachable_states M2; io2 ∈ V ` reachable_states M2; after_initial M2 io1 ≠ after_initial M2 io2; after_initial M1 io1 = after_initial M1 io2; ⋀q. q ∈ reachable_states M2 ⟹ V q ∈ L M2 ∧ after_initial M2 (V q) = q⟧ ⟹ io1 ∈ L M2› 2. ‹⟦io1 ∈ V ` reachable_states M2; io2 ∈ V ` reachable_states M2; after_initial M2 io1 ≠ after_initial M2 io2; after_initial M1 io1 = after_initial M1 io2; ⋀q. q ∈ reachable_states M2 ⟹ V q ∈ L M2 ∧ after_initial M2 (V q) = q⟧ ⟹ io2 ∈ L M2› 3. ‹⟦io1 ∈ V ` reachable_states M2; io2 ∈ V ` reachable_states M2; after_initial M2 io1 ≠ after_initial M2 io2; after_initial M1 io1 = after_initial M1 io2; ⋀q. q ∈ reachable_states M2 ⟹ V q ∈ L M2 ∧ after_initial M2 (V q) = q⟧ ⟹ io1 ∈ L M2› 4. ‹⟦io1 ∈ V ` reachable_states M2; io2 ∈ V ` reachable_states M2; after_initial M2 io1 ≠ after_initial M2 io2; after_initial M1 io1 = after_initial M1 io2; ⋀q. q ∈ reachable_states M2 ⟹ V q ∈ L M2 ∧ after_initial M2 (V q) = q⟧ ⟹ io2 ∈ L M2› 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 "after_initial M1 io1 ∈ reachable_states M1" "after_initial M1 io2 ∈ reachable_states M1" "after_initial M2 io1 ∈ reachable_states M2" "after_initial M2 io2 ∈ reachable_states M2" using after_reachable[OF assms ( 3 ) _ reachable_states_initial] (*‹?io ∈ L M1 ⟹ after_initial M1 ?io ∈ reachable_states M1›*) after_reachable[OF assms ( 4 ) _ reachable_states_initial] (*‹?io ∈ L M2 ⟹ after_initial M2 ?io ∈ reachable_states M2›*) apply - (*goals: 1. ‹⟦io1 ∈ L M1; io2 ∈ L M1; io1 ∈ L M2; io2 ∈ L M2; ⋀io. io ∈ L M1 ⟹ after_initial M1 io ∈ reachable_states M1; ⋀io. io ∈ L M2 ⟹ after_initial M2 io ∈ reachable_states M2⟧ ⟹ after_initial M1 io1 ∈ reachable_states M1› 2. ‹⟦io1 ∈ L M1; io2 ∈ L M1; io1 ∈ L M2; io2 ∈ L M2; ⋀io. io ∈ L M1 ⟹ after_initial M1 io ∈ reachable_states M1; ⋀io. io ∈ L M2 ⟹ after_initial M2 io ∈ reachable_states M2⟧ ⟹ after_initial M1 io2 ∈ reachable_states M1› 3. ‹⟦io1 ∈ L M1; io2 ∈ L M1; io1 ∈ L M2; io2 ∈ L M2; ⋀io. io ∈ L M1 ⟹ after_initial M1 io ∈ reachable_states M1; ⋀io. io ∈ L M2 ⟹ after_initial M2 io ∈ reachable_states M2⟧ ⟹ after_initial M2 io1 ∈ reachable_states M2› 4. ‹⟦io1 ∈ L M1; io2 ∈ L M1; io1 ∈ L M2; io2 ∈ L M2; ⋀io. io ∈ L M1 ⟹ after_initial M1 io ∈ reachable_states M1; ⋀io. io ∈ L M2 ⟹ after_initial M2 io ∈ reachable_states M2⟧ ⟹ after_initial M2 io2 ∈ reachable_states M2› discuss goal 1*) apply blast (*discuss goal 2*) apply blast (*discuss goal 3*) apply blast (*discuss goal 4*) apply blast (*proven 4 subgoals*) . obtain io3 where "io3 ∈ LS M2 (after_initial M2 io1) = (io3 ∉ LS M2 (after_initial M2 io2))" (*goal: ‹(⋀io3::('b × 'c) list. (io3 ∈ LS (M2::('d, 'b, 'c) fsm) (after_initial M2 (io1::('b × 'c) list))) = (io3 ∉ LS M2 (after_initial M2 (io2::('b × 'c) list))) ⟹ thesis::bool) ⟹ thesis›*) using reachable_state_is_state[OF ‹after_initial M2 io1 ∈ reachable_states M2›] (*‹after_initial M2 io1 ∈ FSM.states M2›*) reachable_state_is_state[OF ‹after_initial M2 io2 ∈ reachable_states M2›] (*‹after_initial M2 io2 ∈ FSM.states M2›*) ‹after_initial M2 io1 ≠ after_initial M2 io2› (*‹after_initial M2 io1 ≠ after_initial M2 io2›*) assms(2) (*‹minimal M2›*) unfolding minimal.simps (*goal: ‹(⋀io3. (io3 ∈ LS M2 (after_initial M2 io1)) = (io3 ∉ LS M2 (after_initial M2 io2)) ⟹ thesis) ⟹ thesis›*) by blast then have "io1@io3 ∈ L M2 = (io2@io3 ∉ L M2)" using observable_after_language_append[OF assms ( 4 ) ‹io1 ∈ L M2›] (*‹?io2.0 ∈ LS M2 (after_initial M2 io1) ⟹ io1 @ ?io2.0 ∈ L M2›*) observable_after_language_append[OF assms ( 4 ) ‹io2 ∈ L M2›] (*‹?io2.0 ∈ LS M2 (after_initial M2 io2) ⟹ io2 @ ?io2.0 ∈ L M2›*) observable_after_language_none[OF assms ( 4 ) ‹io1 ∈ L M2›] (*‹?io2.0 ∉ LS M2 (after_initial M2 io1) ⟹ io1 @ ?io2.0 ∉ L M2›*) observable_after_language_none[OF assms ( 4 ) ‹io2 ∈ L M2›] (*‹(?io2.0::('b::type × 'c::type) list) ∉ LS (M2::('d::type, 'b::type, 'c::type) fsm) (after_initial M2 (io2::('b::type × 'c::type) list)) ⟹ io2 @ ?io2.0 ∉ L M2›*) by blast moreover have "io1@io3 ∈ L M1 = (io2@io3 ∈ L M1)" by (meson ‹after_initial M1 io1 = after_initial M1 io2› ‹io1 ∈ L M1› ‹io2 ∈ L M1› assms( (*‹observable M1›*) 3) observable_after_eq (*‹⟦observable ?M; after ?M ?q ?io1.0 = after ?M ?q ?io2.0; ?io1.0 ∈ LS ?M ?q; ?io2.0 ∈ LS ?M ?q⟧ ⟹ (?io1.0 @ ?io ∈ LS ?M ?q) = (?io2.0 @ ?io ∈ LS ?M ?q)›*)) ultimately show False using ‹L M1 = L M2› (*‹L M1 = L M2›*) by blast qed (* language equivalent minimal FSMs have the same number of reachable states *) lemma minimal_equivalence_size_r : assumes "minimal M1" and "minimal M2" and "observable M1" and "observable M2" and "L M1 = L M2" shows "size_r M1 = size_r M2" using observable_minimal_size_r_language_distinct[OF assms ( 1 - 4 )] (*‹size_r M1 < size_r M2 ⟹ L M1 ≠ L M2›*) observable_minimal_size_r_language_distinct[OF assms ( 2 , 1 , 4 , 3 )] (*‹size_r M2 < size_r M1 ⟹ L M2 ≠ L M1›*) assms(5) (*‹L M1 = L M2›*) using nat_neq_iff (*‹(?m ≠ ?n) = (?m < ?n ∨ ?n < ?m)›*) by auto subsection ‹Conformity Relations› fun is_io_reduction_state :: "('a,'b,'c) fsm ⇒ 'a ⇒ ('d,'b,'c) fsm ⇒ 'd ⇒ bool" where "is_io_reduction_state A a B b = (LS A a ⊆ LS B b)" abbreviation(input) "is_io_reduction A B ≡ is_io_reduction_state A (initial A) B (initial B)" notation is_io_reduction ("_ ≼ _") fun is_io_reduction_state_on_inputs :: "('a,'b,'c) fsm ⇒ 'a ⇒ 'b list set ⇒ ('d,'b,'c) fsm ⇒ 'd ⇒ bool" where "is_io_reduction_state_on_inputs A a U B b = (LS⇩i⇩n A a U ⊆ LS⇩i⇩n B b U)" abbreviation(input) "is_io_reduction_on_inputs A U B ≡ is_io_reduction_state_on_inputs A (initial A) U B (initial B)" notation is_io_reduction_on_inputs ("_ ≼⟦_⟧ _") subsection ‹A Pass Relation for Reduction and Test Represented as Sets of Input-Output Sequences› definition pass_io_set :: "('a,'b,'c) fsm ⇒ ('b × 'c) list set ⇒ bool" where "pass_io_set M ios = (∀ io x y . io@[(x,y)] ∈ ios ⟶ (∀ y' . io@[(x,y')] ∈ L M ⟶ io@[(x,y')] ∈ ios))" definition pass_io_set_maximal :: "('a,'b,'c) fsm ⇒ ('b × 'c) list set ⇒ bool" where "pass_io_set_maximal M ios = (∀ io x y io' . io@[(x,y)]@io' ∈ ios ⟶ (∀ y' . io@[(x,y')] ∈ L M ⟶ (∃ io''. io@[(x,y')]@io'' ∈ ios)))" lemma pass_io_set_from_pass_io_set_maximal : "pass_io_set_maximal M ios = pass_io_set M {io' . ∃ io io'' . io = io'@io'' ∧ io ∈ ios}" proof (-) (*goal: ‹pass_io_set_maximal M ios = pass_io_set M {io'. ∃io io''. io = io' @ io'' ∧ io ∈ ios}›*) have "⋀ io x y io' . io@[(x,y)]@io' ∈ ios ⟹ io@[(x,y)] ∈ {io' . ∃ io io'' . io = io'@io'' ∧ io ∈ ios}" by auto moreover have "⋀ io x y . io@[(x,y)] ∈ {io' . ∃ io io'' . io = io'@io'' ∧ io ∈ ios} ⟹ ∃ io' . io@[(x,y)]@io' ∈ ios" by auto ultimately show "?thesis" (*goal: ‹pass_io_set_maximal M ios = pass_io_set M {io'. ∃io io''. io = io' @ io'' ∧ io ∈ ios}›*) unfolding pass_io_set_def pass_io_set_maximal_def (*goal: ‹(∀io x y io'. io @ [(x, y)] @ io' ∈ ios ⟶ (∀y'. io @ [(x, y')] ∈ L M ⟶ (∃io''. io @ [(x, y')] @ io'' ∈ ios))) = (∀io x y. io @ [(x, y)] ∈ {io'. ∃io io''. io = io' @ io'' ∧ io ∈ ios} ⟶ (∀y'. io @ [(x, y')] ∈ L M ⟶ io @ [(x, y')] ∈ {io'. ∃io io''. io = io' @ io'' ∧ io ∈ ios}))›*) by meson qed lemma pass_io_set_maximal_from_pass_io_set : assumes "finite ios" and "⋀ io' io'' . io'@io'' ∈ ios ⟹ io' ∈ ios" shows "pass_io_set M ios = pass_io_set_maximal M {io' ∈ ios . ¬ (∃ io'' . io'' ≠ [] ∧ io'@io'' ∈ ios)}" proof (-) (*goal: ‹pass_io_set (M::('c, 'a, 'b) fsm) (ios::('a × 'b) list set) = pass_io_set_maximal M {io'::('a × 'b) list ∈ ios. ∄io''::('a × 'b) list. io'' ≠ [] ∧ io' @ io'' ∈ ios}›*) have "⋀ io x y . io@[(x,y)] ∈ ios ⟹ ∃ io' . io@[(x,y)]@io' ∈ {io'' ∈ ios . ¬ (∃ io''' . io''' ≠ [] ∧ io''@io''' ∈ ios)}" proof (-) (*goal: ‹⋀io x y. io @ [(x, y)] ∈ ios ⟹ ∃io'. io @ [(x, y)] @ io' ∈ {io'' ∈ ios. ∄io'''. io''' ≠ [] ∧ io'' @ io''' ∈ ios}›*) fix io and x and y assume "io@[(x,y)] ∈ ios" (*‹(io::('a × 'b) list) @ [(x::'a, y::'b)] ∈ (ios::('a × 'b) list set)›*) show "∃ io' . io@[(x,y)]@io' ∈ {io'' ∈ ios . ¬ (∃ io''' . io''' ≠ [] ∧ io''@io''' ∈ ios)}" using finite_set_elem_maximal_extension_ex[OF ‹io@[(x,y)] ∈ ios› assms ( 1 )] (*‹∃ys::('a × 'b) list. ((io::('a × 'b) list) @ [(x::'a, y::'b)]) @ ys ∈ (ios::('a × 'b) list set) ∧ (∄zs::('a × 'b) list. zs ≠ [] ∧ (io @ [(x, y)]) @ ys @ zs ∈ ios)›*) by force qed moreover have "⋀ io x y io' . io@[(x,y)]@io' ∈ {io'' ∈ ios . ¬ (∃ io''' . io''' ≠ [] ∧ io''@io''' ∈ ios)} ⟹ io@[(x,y)] ∈ ios" using ‹⋀ io' io'' . io'@io'' ∈ ios ⟹ io' ∈ ios› (*‹?io' @ ?io'' ∈ ios ⟹ ?io' ∈ ios›*) by force ultimately show "?thesis" (*goal: ‹pass_io_set M ios = pass_io_set_maximal M {io' ∈ ios. ∄io''. io'' ≠ [] ∧ io' @ io'' ∈ ios}›*) unfolding pass_io_set_def pass_io_set_maximal_def (*goal: ‹(∀(io::('a × 'b) list) (x::'a) y::'b. io @ [(x, y)] ∈ (ios::('a × 'b) list set) ⟶ (∀y'::'b. io @ [(x, y')] ∈ L (M::('c, 'a, 'b) fsm) ⟶ io @ [(x, y')] ∈ ios)) = (∀(io::('a × 'b) list) (x::'a) (y::'b) io'::('a × 'b) list. io @ [(x, y)] @ io' ∈ {io'::('a × 'b) list ∈ ios. ∄io''::('a × 'b) list. io'' ≠ [] ∧ io' @ io'' ∈ ios} ⟶ (∀y'::'b. io @ [(x, y')] ∈ L M ⟶ (∃io''::('a × 'b) list. io @ [(x, y')] @ io'' ∈ {io'::('a × 'b) list ∈ ios. ∄io''::('a × 'b) list. io'' ≠ [] ∧ io' @ io'' ∈ ios})))›*) by meson qed subsection ‹Relaxation of IO based test suites to sets of input sequences› abbreviation(input) "input_portion xs ≡ map fst xs" lemma equivalence_io_relaxation : assumes "(L M1 = L M2) ⟷ (L M1 ∩ T = L M2 ∩ T)" shows "(L M1 = L M2) ⟷ ({io . io ∈ L M1 ∧ (∃ io' ∈ T . input_portion io = input_portion io')} = {io . io ∈ L M2 ∧ (∃ io' ∈ T . input_portion io = input_portion io')})" proof (standard) (*goals: 1. ‹L M1 = L M2 ⟹ {io ∈ L M1. ∃io'∈T. map fst io = map fst io'} = {io ∈ L M2. ∃io'∈T. map fst io = map fst io'}› 2. ‹{io ∈ L M1. ∃io'∈T. map fst io = map fst io'} = {io ∈ L M2. ∃io'∈T. map fst io = map fst io'} ⟹ L M1 = L M2›*) show "(L M1 = L M2) ⟹ ({io . io ∈ L M1 ∧ (∃ io' ∈ T . input_portion io = input_portion io')} = {io . io ∈ L M2 ∧ (∃ io' ∈ T . input_portion io = input_portion io')})" by blast show "({io . io ∈ L M1 ∧ (∃ io' ∈ T . input_portion io = input_portion io')} = {io . io ∈ L M2 ∧ (∃ io' ∈ T . input_portion io = input_portion io')}) ⟹ L M1 = L M2" proof (-) (*goal: ‹{io::('a × 'b) list ∈ L (M1::('c, 'a, 'b) fsm). ∃io'::('a × 'b) list∈T::('a × 'b) list set. map fst io = map fst io'} = {io::('a × 'b) list ∈ L (M2::('d, 'a, 'b) fsm). ∃io'::('a × 'b) list∈T. map fst io = map fst io'} ⟹ L M1 = L M2›*) have "*": "⋀ M . {io . io ∈ L M ∧ (∃ io' ∈ T . input_portion io = input_portion io')} = L M ∩ {io . ∃ io' ∈ T . input_portion io = input_portion io'}" by blast have "({io . io ∈ L M1 ∧ (∃ io' ∈ T . input_portion io = input_portion io')} = {io . io ∈ L M2 ∧ (∃ io' ∈ T . input_portion io = input_portion io')}) ⟹ (L M1 ∩ T = L M2 ∩ T)" unfolding "*" (*goal: ‹L (M1::('c, 'a, 'b) fsm) ∩ {io::('a × 'b) list. ∃io'::('a × 'b) list∈T::('a × 'b) list set. map fst io = map fst io'} = L (M2::('d, 'a, 'b) fsm) ∩ {io::('a × 'b) list. ∃io'::('a × 'b) list∈T. map fst io = map fst io'} ⟹ L M1 ∩ T = L M2 ∩ T›*) by blast then show "({io . io ∈ L M1 ∧ (∃ io' ∈ T . input_portion io = input_portion io')} = {io . io ∈ L M2 ∧ (∃ io' ∈ T . input_portion io = input_portion io')}) ⟹ L M1 = L M2" using assms (*‹(L M1 = L M2) = (L M1 ∩ T = L M2 ∩ T)›*) by blast qed qed lemma reduction_io_relaxation : assumes "(L M1 ⊆ L M2) ⟷ (L M1 ∩ T ⊆ L M2 ∩ T)" shows "(L M1 ⊆ L M2) ⟷ ({io . io ∈ L M1 ∧ (∃ io' ∈ T . input_portion io = input_portion io')} ⊆ {io . io ∈ L M2 ∧ (∃ io' ∈ T . input_portion io = input_portion io')})" proof (standard) (*goals: 1. ‹L M1 ⊆ L M2 ⟹ {io ∈ L M1. ∃io'∈T. map fst io = map fst io'} ⊆ {io ∈ L M2. ∃io'∈T. map fst io = map fst io'}› 2. ‹{io ∈ L M1. ∃io'∈T. map fst io = map fst io'} ⊆ {io ∈ L M2. ∃io'∈T. map fst io = map fst io'} ⟹ L M1 ⊆ L M2›*) show "(L M1 ⊆ L M2) ⟹ ({io . io ∈ L M1 ∧ (∃ io' ∈ T . input_portion io = input_portion io')} ⊆ {io . io ∈ L M2 ∧ (∃ io' ∈ T . input_portion io = input_portion io')})" by blast show "({io . io ∈ L M1 ∧ (∃ io' ∈ T . input_portion io = input_portion io')} ⊆ {io . io ∈ L M2 ∧ (∃ io' ∈ T . input_portion io = input_portion io')}) ⟹ L M1 ⊆ L M2" proof (-) (*goal: ‹{io ∈ L M1. ∃io'∈T. map fst io = map fst io'} ⊆ {io ∈ L M2. ∃io'∈T. map fst io = map fst io'} ⟹ L M1 ⊆ L M2›*) have "*": "⋀ M . {io . io ∈ L M ∧ (∃ io' ∈ T . input_portion io = input_portion io')} ⊆ L M ∩ {io . ∃ io' ∈ T . input_portion io = input_portion io'}" by blast have "({io . io ∈ L M1 ∧ (∃ io' ∈ T . input_portion io = input_portion io')} ⊆ {io . io ∈ L M2 ∧ (∃ io' ∈ T . input_portion io = input_portion io')}) ⟹ (L M1 ∩ T ⊆ L M2 ∩ T)" unfolding "*" (*goal: ‹{io ∈ L M1. ∃io'∈T. map fst io = map fst io'} ⊆ {io ∈ L M2. ∃io'∈T. map fst io = map fst io'} ⟹ L M1 ∩ T ⊆ L M2 ∩ T›*) by blast then show "({io . io ∈ L M1 ∧ (∃ io' ∈ T . input_portion io = input_portion io')} ⊆ {io . io ∈ L M2 ∧ (∃ io' ∈ T . input_portion io = input_portion io')}) ⟹ L M1 ⊆ L M2" using assms (*‹(L M1 ⊆ L M2) = (L M1 ∩ T ⊆ L M2 ∩ T)›*) by blast qed qed subsection ‹Submachines› fun is_submachine :: "('a,'b,'c) fsm ⇒ ('a,'b,'c) fsm ⇒ bool" where "is_submachine A B = (initial A = initial B ∧ transitions A ⊆ transitions B ∧ inputs A = inputs B ∧ outputs A = outputs B ∧ states A ⊆ states B)" lemma submachine_path_initial : assumes "is_submachine A B" and "path A (initial A) p" shows "path B (initial B) p" using assms (*‹is_submachine A B› ‹path (A::('a, 'b, 'c) fsm) (FSM.initial A) (p::('a × 'b × 'c × 'a) list)›*) proof (induction p rule: rev_induct (*‹⟦?P []; ⋀x xs. ?P xs ⟹ ?P (xs @ [x])⟧ ⟹ ?P ?xs›*)) (*goals: 1. ‹⟦is_submachine A B; path A (FSM.initial A) []⟧ ⟹ path B (FSM.initial B) []› 2. ‹⋀x xs. ⟦⟦is_submachine A B; path A (FSM.initial A) xs⟧ ⟹ path B (FSM.initial B) xs; is_submachine A B; path A (FSM.initial A) (xs @ [x])⟧ ⟹ path B (FSM.initial B) (xs @ [x])›*) case Nil (*‹is_submachine A B› ‹path (A::('a::type, 'b::type, 'c::type) fsm) (FSM.initial A) []›*) then show "?case" (*goal: ‹path B (FSM.initial B) []›*) by auto next (*goal: ‹⋀x xs. ⟦⟦is_submachine A B; path A (FSM.initial A) xs⟧ ⟹ path B (FSM.initial B) xs; is_submachine A B; path A (FSM.initial A) (xs @ [x])⟧ ⟹ path B (FSM.initial B) (xs @ [x])›*) case (snoc a p) (*‹⟦is_submachine A B; path A (FSM.initial A) p⟧ ⟹ path B (FSM.initial B) p› ‹is_submachine A B› ‹path (A::('a, 'b, 'c) fsm) (FSM.initial A) ((p::('a × 'b × 'c × 'a) list) @ [a::'a × 'b × 'c × 'a])›*) then show "?case" (*goal: ‹path B (FSM.initial B) (p @ [a])›*) by fastforce qed lemma submachine_path : assumes "is_submachine A B" and "path A q p" shows "path B q p" by (meson assms( (*‹is_submachine A B›*) 1) assms( (*‹path A q p›*) 2) is_submachine.elims( (*‹⟦is_submachine ?x ?xa; ⋀A B. ⟦?x = A; ?xa = B; FSM.initial A = FSM.initial B ∧ FSM.transitions A ⊆ FSM.transitions B ∧ FSM.inputs A = FSM.inputs B ∧ FSM.outputs A = FSM.outputs B ∧ FSM.states A ⊆ FSM.states B⟧ ⟹ ?P⟧ ⟹ ?P›*) 2) path_begin_state (*‹path ?M ?q ?p ⟹ ?q ∈ FSM.states ?M›*) subsetD (*‹⟦?A ⊆ ?B; ?c ∈ ?A⟧ ⟹ ?c ∈ ?B›*) transition_subset_path (*‹⟦FSM.transitions ?A ⊆ FSM.transitions ?B; path ?A ?q ?p; ?q ∈ FSM.states ?B⟧ ⟹ path ?B ?q ?p›*)) lemma submachine_reduction : assumes "is_submachine A B" shows "is_io_reduction A B" using submachine_path[OF assms] (*‹path (A::('a::type, 'b::type, 'c::type) fsm) (?q::'a::type) (?p::('a::type × 'b::type × 'c::type × 'a::type) list) ⟹ path (B::('a::type, 'b::type, 'c::type) fsm) ?q ?p›*) assms (*‹is_submachine A B›*) by auto lemma complete_submachine_initial : assumes "is_submachine A B" and "completely_specified A" shows "completely_specified_state B (initial B)" using assms(1) (*‹is_submachine (A::('a, 'b, 'c) fsm) (B::('a, 'b, 'c) fsm)›*) assms(2) (*‹completely_specified A›*) fsm_initial (*‹FSM.initial ?M ∈ FSM.states ?M›*) subset_iff (*‹(?A ⊆ ?B) = (∀t. t ∈ ?A ⟶ t ∈ ?B)›*) by fastforce lemma submachine_language : assumes "is_submachine S M" shows "L S ⊆ L M" by (meson assms (*‹is_submachine S M›*) is_io_reduction_state.elims( (*‹⟦is_io_reduction_state ?x ?xa ?xb ?xc; ⋀A a B b. ⟦?x = A; ?xa = a; ?xb = B; ?xc = b; LS A a ⊆ LS B b⟧ ⟹ ?P⟧ ⟹ ?P›*) 2) submachine_reduction (*‹is_submachine ?A ?B ⟹ is_io_reduction_state ?A (FSM.initial ?A) ?B (FSM.initial ?B)›*)) lemma submachine_observable : assumes "is_submachine S M" and "observable M" shows "observable S" using assms (*‹is_submachine (S::('a::type, 'b::type, 'c::type) fsm) (M::('a::type, 'b::type, 'c::type) fsm)› ‹observable (M::('a, 'b, 'c) fsm)›*) unfolding is_submachine.simps observable.simps (*goal: ‹∀t1∈FSM.transitions S. ∀t2∈FSM.transitions S. t_source t1 = t_source t2 ∧ t_input t1 = t_input t2 ∧ t_output t1 = t_output t2 ⟶ t_target t1 = t_target t2›*) by blast lemma submachine_transitive : assumes "is_submachine S M" and "is_submachine S' S" shows "is_submachine S' M" using assms (*‹is_submachine S M› ‹is_submachine S' S›*) unfolding is_submachine.simps (*goal: ‹FSM.initial S' = FSM.initial M ∧ FSM.transitions S' ⊆ FSM.transitions M ∧ FSM.inputs S' = FSM.inputs M ∧ FSM.outputs S' = FSM.outputs M ∧ FSM.states S' ⊆ FSM.states M›*) by force lemma transitions_subset_path : assumes "set p ⊆ transitions M" and "p ≠ []" and "path S q p" shows "path M q p" using assms (*‹set p ⊆ FSM.transitions M› ‹p ≠ []› ‹path S q p›*) apply ((induction p arbitrary: q)[1]) (*goals: 1. ‹⋀q. ⟦set [] ⊆ FSM.transitions M; [] ≠ []; path S q []⟧ ⟹ path M q []› 2. ‹⋀a p q. ⟦⋀q. ⟦set p ⊆ FSM.transitions M; p ≠ []; path S q p⟧ ⟹ path M q p; set (a # p) ⊆ FSM.transitions M; a # p ≠ []; path S q (a # p)⟧ ⟹ path M q (a # p)› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . lemma transition_subset_paths : assumes "transitions S ⊆ transitions M" and "initial S ∈ states M" and "inputs S = inputs M" and "outputs S = outputs M" and "path S (initial S) p" shows "path M (initial S) p" using assms(5) (*‹path S (FSM.initial S) p›*) proof (induction p rule: rev_induct (*‹⟦?P []; ⋀x xs. ?P xs ⟹ ?P (xs @ [x])⟧ ⟹ ?P ?xs›*)) (*goals: 1. ‹path S (FSM.initial S) [] ⟹ path M (FSM.initial S) []› 2. ‹⋀x xs. ⟦path S (FSM.initial S) xs ⟹ path M (FSM.initial S) xs; path S (FSM.initial S) (xs @ [x])⟧ ⟹ path M (FSM.initial S) (xs @ [x])›*) case Nil (*‹path S (FSM.initial S) []›*) then show "?case" (*goal: ‹path M (FSM.initial S) []›*) using assms(2) (*‹FSM.initial S ∈ FSM.states M›*) by auto next (*goal: ‹⋀(x::'a × 'b × 'c × 'a) xs::('a × 'b × 'c × 'a) list. ⟦path (S::('a, 'b, 'c) fsm) (FSM.initial S) xs ⟹ path (M::('a, 'b, 'c) fsm) (FSM.initial S) xs; path S (FSM.initial S) (xs @ [x])⟧ ⟹ path M (FSM.initial S) (xs @ [x])›*) case (snoc t p) (*‹path S (FSM.initial S) p ⟹ path M (FSM.initial S) p› ‹path (S::('a, 'b, 'c) fsm) (FSM.initial S) ((p::('a × 'b × 'c × 'a) list) @ [t::'a × 'b × 'c × 'a])›*) then have "path S (initial S) p" and "t ∈ transitions S" and "t_source t = target (initial S) p" and "path M (initial S) p" apply - (*goals: 1. ‹⟦path (S::('a, 'b, 'c) fsm) (FSM.initial S) (p::('a × 'b × 'c × 'a) list) ⟹ path (M::('a, 'b, 'c) fsm) (FSM.initial S) p; path S (FSM.initial S) (p @ [t::'a × 'b × 'c × 'a])⟧ ⟹ path S (FSM.initial S) p› 2. ‹⟦path (S::('a, 'b, 'c) fsm) (FSM.initial S) (p::('a × 'b × 'c × 'a) list) ⟹ path (M::('a, 'b, 'c) fsm) (FSM.initial S) p; path S (FSM.initial S) (p @ [t::'a × 'b × 'c × 'a])⟧ ⟹ t ∈ FSM.transitions S› 3. ‹⟦path (S::('a, 'b, 'c) fsm) (FSM.initial S) (p::('a × 'b × 'c × 'a) list) ⟹ path (M::('a, 'b, 'c) fsm) (FSM.initial S) p; path S (FSM.initial S) (p @ [t::'a × 'b × 'c × 'a])⟧ ⟹ t_source t = target (FSM.initial S) p› 4. ‹⟦path (S::('a, 'b, 'c) fsm) (FSM.initial S) (p::('a × 'b × 'c × 'a) list) ⟹ path (M::('a, 'b, 'c) fsm) (FSM.initial S) p; path S (FSM.initial S) (p @ [t::'a × 'b × 'c × 'a])⟧ ⟹ path M (FSM.initial S) 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*) . have "t ∈ transitions M" using assms(1) (*‹FSM.transitions S ⊆ FSM.transitions M›*) ‹t ∈ transitions S› (*‹(t::'a::type × 'b::type × 'c::type × 'a::type) ∈ FSM.transitions (S::('a::type, 'b::type, 'c::type) fsm)›*) by auto moreover have "t_source t ∈ states M" using ‹t_source t = target (initial S) p› (*‹t_source (t::'a::type × 'b::type × 'c::type × 'a::type) = target (FSM.initial (S::('a::type, 'b::type, 'c::type) fsm)) (p::('a::type × 'b::type × 'c::type × 'a::type) list)›*) ‹path M (initial S) p› (*‹path M (FSM.initial S) p›*) using path_target_is_state (*‹path ?M ?q ?p ⟹ target ?q ?p ∈ FSM.states ?M›*) by fastforce ultimately have "t ∈ transitions M" using ‹t ∈ transitions S› (*‹t ∈ FSM.transitions S›*) assms(3,4) (*‹FSM.inputs S = FSM.inputs M› ‹FSM.outputs S = FSM.outputs M›*) by auto then show "?case" (*goal: ‹path M (FSM.initial S) (p @ [t])›*) using ‹path M (initial S) p› (*‹path M (FSM.initial S) p›*) using snoc.prems (*‹path (S::('a, 'b, 'c) fsm) (FSM.initial S) ((p::('a × 'b × 'c × 'a) list) @ [t::'a × 'b × 'c × 'a])›*) by auto qed lemma submachine_reachable_subset : assumes "is_submachine A B" shows "reachable_states A ⊆ reachable_states B" using assms (*‹is_submachine A B›*) submachine_path_initial[OF assms] (*‹path A (FSM.initial A) ?p ⟹ path B (FSM.initial B) ?p›*) unfolding is_submachine.simps reachable_states_def (*goal: ‹{target (FSM.initial A) p |p. path A (FSM.initial A) p} ⊆ {target (FSM.initial B) p |p. path B (FSM.initial B) p}›*) by force lemma submachine_simps : assumes "is_submachine A B" shows "initial A = initial B" and "states A ⊆ states B" and "inputs A = inputs B" and "outputs A = outputs B" and "transitions A ⊆ transitions B" using assms (*‹is_submachine A B›*) unfolding is_submachine.simps (*goals: 1. ‹FSM.initial A = FSM.initial B› 2. ‹FSM.states A ⊆ FSM.states B› 3. ‹FSM.inputs A = FSM.inputs B› 4. ‹FSM.outputs A = FSM.outputs B› 5. ‹FSM.transitions A ⊆ FSM.transitions B›*) apply - (*goals: 1. ‹FSM.initial A = FSM.initial B ∧ FSM.transitions A ⊆ FSM.transitions B ∧ FSM.inputs A = FSM.inputs B ∧ FSM.outputs A = FSM.outputs B ∧ FSM.states A ⊆ FSM.states B ⟹ FSM.initial A = FSM.initial B› 2. ‹FSM.initial A = FSM.initial B ∧ FSM.transitions A ⊆ FSM.transitions B ∧ FSM.inputs A = FSM.inputs B ∧ FSM.outputs A = FSM.outputs B ∧ FSM.states A ⊆ FSM.states B ⟹ FSM.states A ⊆ FSM.states B› 3. ‹FSM.initial A = FSM.initial B ∧ FSM.transitions A ⊆ FSM.transitions B ∧ FSM.inputs A = FSM.inputs B ∧ FSM.outputs A = FSM.outputs B ∧ FSM.states A ⊆ FSM.states B ⟹ FSM.inputs A = FSM.inputs B› 4. ‹FSM.initial A = FSM.initial B ∧ FSM.transitions A ⊆ FSM.transitions B ∧ FSM.inputs A = FSM.inputs B ∧ FSM.outputs A = FSM.outputs B ∧ FSM.states A ⊆ FSM.states B ⟹ FSM.outputs A = FSM.outputs B› 5. ‹FSM.initial A = FSM.initial B ∧ FSM.transitions A ⊆ FSM.transitions B ∧ FSM.inputs A = FSM.inputs B ∧ FSM.outputs A = FSM.outputs B ∧ FSM.states A ⊆ FSM.states B ⟹ FSM.transitions A ⊆ FSM.transitions B› 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 (*proven 5 subgoals*) . lemma submachine_deadlock : assumes "is_submachine A B" and "deadlock_state B q" shows "deadlock_state A q" using assms(1) (*‹is_submachine A B›*) assms(2) (*‹deadlock_state B q›*) in_mono (*‹?A ⊆ ?B ⟹ ?x ∈ ?A ⟶ ?x ∈ ?B›*) by auto subsection ‹Changing Initial States› lift_definition from_FSM :: "('a,'b,'c) fsm ⇒ 'a ⇒ ('a,'b,'c) fsm" is FSM_Impl.from_FSMI by simp lemma from_FSM_simps[simp]: assumes "q ∈ states M" shows "initial (from_FSM M q) = q" "inputs (from_FSM M q) = inputs M" "outputs (from_FSM M q) = outputs M" "transitions (from_FSM M q) = transitions M" "states (from_FSM M q) = states M" using assms (*‹q ∈ FSM.states M›*) (*goals: 1. ‹FSM.initial (from_FSM (M::('a::type, 'b::type, 'c::type) fsm) (q::'a::type)) = q› 2. ‹FSM.inputs (from_FSM (M::('a::type, 'b::type, 'c::type) fsm) (q::'a::type)) = FSM.inputs M› 3. ‹FSM.outputs (from_FSM (M::('a::type, 'b::type, 'c::type) fsm) (q::'a::type)) = FSM.outputs M› 4. ‹FSM.transitions (from_FSM (M::('a::type, 'b::type, 'c::type) fsm) (q::'a::type)) = FSM.transitions M› 5. ‹FSM.states (from_FSM (M::('a::type, 'b::type, 'c::type) fsm) (q::'a::type)) = FSM.states M› discuss goal 1*) apply transfer (*top goal: ‹FSM.initial (from_FSM M q) = q› and 4 goals remain*) apply simp (*discuss goal 2*) apply transfer (*top goal: ‹FSM.inputs (from_FSM M q) = FSM.inputs M› and 3 goals remain*) apply simp (*discuss goal 3*) apply transfer (*top goal: ‹FSM.outputs (from_FSM M q) = FSM.outputs M› and 2 goals remain*) apply simp (*discuss goal 4*) apply transfer (*top goal: ‹FSM.transitions (from_FSM M q) = FSM.transitions M› and 1 goal remains*) apply simp (*discuss goal 5*) apply transfer (*goal: ‹FSM.states (from_FSM M q) = FSM.states M›*) apply simp (*proven 5 subgoals*) . lemma from_FSM_path_initial : assumes "q ∈ states M" shows "path M q p = path (from_FSM M q) (initial (from_FSM M q)) p" by (metis assms (*‹q ∈ FSM.states M›*) from_FSM_simps( (*‹?q ∈ FSM.states ?M ⟹ FSM.initial (from_FSM ?M ?q) = ?q›*) 1) from_FSM_simps( (*‹?q ∈ FSM.states ?M ⟹ FSM.transitions (from_FSM ?M ?q) = FSM.transitions ?M›*) 4) from_FSM_simps( (*‹?q ∈ FSM.states ?M ⟹ FSM.states (from_FSM ?M ?q) = FSM.states ?M›*) 5) order_refl (*‹?x ≤ ?x›*) transition_subset_path (*‹⟦FSM.transitions ?A ⊆ FSM.transitions ?B; path ?A ?q ?p; ?q ∈ FSM.states ?B⟧ ⟹ path ?B ?q ?p›*)) lemma from_FSM_path : assumes "q ∈ states M" and "path (from_FSM M q) q' p" shows "path M q' p" using assms(1) (*‹(q::'a) ∈ FSM.states (M::('a, 'b, 'c) fsm)›*) assms(2) (*‹path (from_FSM M q) q' p›*) path_transitions (*‹path (?M::(?'a::type, ?'b::type, ?'c::type) fsm) (?q::?'a::type) (?p::(?'a::type × ?'b::type × ?'c::type × ?'a::type) list) ⟹ set ?p ⊆ FSM.transitions ?M›*) transitions_subset_path (*‹⟦set ?p ⊆ FSM.transitions ?M; ?p ≠ []; path ?S ?q ?p⟧ ⟹ path ?M ?q ?p›*) by fastforce lemma from_FSM_reachable_states : assumes "q ∈ reachable_states M" shows "reachable_states (from_FSM M q) ⊆ reachable_states M" proof (standard) (*goal: ‹⋀x. x ∈ reachable_states (from_FSM M q) ⟹ x ∈ reachable_states M›*) from assms (*‹q ∈ reachable_states M›*) obtain p where "path M (initial M) p" and "target (initial M) p = q" (*goal: ‹(⋀p. ⟦path M (FSM.initial M) p; target (FSM.initial M) p = q⟧ ⟹ thesis) ⟹ thesis›*) unfolding reachable_states_def (*goal: ‹(⋀p. ⟦path M (FSM.initial M) p; target (FSM.initial M) p = q⟧ ⟹ thesis) ⟹ thesis›*) by blast then have "q ∈ states M" by (meson path_target_is_state (*‹path ?M ?q ?p ⟹ target ?q ?p ∈ FSM.states ?M›*)) fix q' assume "q' ∈ reachable_states (from_FSM M q)" (*‹(q'::'a) ∈ reachable_states (from_FSM (M::('a, 'b, 'c) fsm) (q::'a))›*) then obtain p' where "path (from_FSM M q) q p'" and "target q p' = q'" (*goal: ‹(⋀p'. ⟦path (from_FSM M q) q p'; target q p' = q'⟧ ⟹ thesis) ⟹ thesis›*) unfolding reachable_states_def from_FSM_simps[OF ‹q ∈ states M›] (*goal: ‹(⋀p'. ⟦path (from_FSM M q) q p'; target q p' = q'⟧ ⟹ thesis) ⟹ thesis›*) by blast then have "path M (initial M) (p@p')" and "target (initial M) (p@p') = q'" using from_FSM_path[OF ‹q ∈ states M›] (*‹path (from_FSM M q) ?q' ?p ⟹ path M ?q' ?p›*) ‹path M (initial M) p› (*‹path M (FSM.initial M) p›*) using ‹target (FSM.initial M) p = q› (*‹target (FSM.initial M) p = q›*) apply - (*goals: 1. ‹⟦path (from_FSM M q) q p'; target q p' = q'; ⋀q' p. path (from_FSM M q) q' p ⟹ path M q' p; path M (FSM.initial M) p; target (FSM.initial M) p = q⟧ ⟹ path M (FSM.initial M) (p @ p')› 2. ‹⟦path (from_FSM M q) q p'; target q p' = q'; ⋀q' p. path (from_FSM M q) q' p ⟹ path M q' p; path M (FSM.initial M) p; target (FSM.initial M) p = q⟧ ⟹ target (FSM.initial M) (p @ p') = q'› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . then show "q' ∈ reachable_states M" unfolding reachable_states_def (*goal: ‹q' ∈ {target (FSM.initial M) p |p. path M (FSM.initial M) p}›*) by blast qed lemma submachine_from : assumes "is_submachine S M" and "q ∈ states S" shows "is_submachine (from_FSM S q) (from_FSM M q)" proof (-) (*goal: ‹is_submachine (from_FSM S q) (from_FSM M q)›*) have "path S q []" using assms(2) (*‹(q::'a) ∈ FSM.states (S::('a, 'b, 'c) fsm)›*) by blast then have "path M q []" by (meson assms( (*‹is_submachine S M›*) 1) submachine_path (*‹⟦is_submachine ?A ?B; path ?A ?q ?p⟧ ⟹ path ?B ?q ?p›*)) then show "?thesis" (*goal: ‹is_submachine (from_FSM S q) (from_FSM M q)›*) using assms(1) (*‹is_submachine (S::('a::type, 'b::type, 'c::type) fsm) (M::('a::type, 'b::type, 'c::type) fsm)›*) assms(2) (*‹q ∈ FSM.states S›*) by force qed lemma from_FSM_path_rev_initial : assumes "path M q p" shows "path (from_FSM M q) q p" by (metis (no_types) assms (*‹path M q p›*) from_FSM_path_initial (*‹?q ∈ FSM.states ?M ⟹ path ?M ?q ?p = path (from_FSM ?M ?q) (FSM.initial (from_FSM ?M ?q)) ?p›*) from_FSM_simps( (*‹?q ∈ FSM.states ?M ⟹ FSM.initial (from_FSM ?M ?q) = ?q›*) 1) path_begin_state (*‹path ?M ?q ?p ⟹ ?q ∈ FSM.states ?M›*)) lemma from_from[simp] : assumes "q1 ∈ states M" and "q1' ∈ states M" shows "from_FSM (from_FSM M q1) q1' = from_FSM M q1'" (is "?M = ?M'") proof (-) (*goal: ‹from_FSM (from_FSM M q1) q1' = from_FSM M q1'›*) have "*": "q1' ∈ states (from_FSM M q1)" using assms(2) (*‹q1' ∈ FSM.states M›*) unfolding from_FSM_simps(5)[OF assms ( 1 )] (*goal: ‹q1' ∈ FSM.states M›*) by assumption have "initial ?M = initial ?M'" and "states ?M = states ?M'" and "inputs ?M = inputs ?M'" and "outputs ?M = outputs ?M'" and "transitions ?M = transitions ?M'" unfolding from_FSM_simps[OF *] from_FSM_simps[OF assms ( 1 )] from_FSM_simps[OF assms ( 2 )] (*goals: 1. ‹q1' = q1'› 2. ‹FSM.states M = FSM.states M› 3. ‹FSM.inputs M = FSM.inputs M› 4. ‹FSM.outputs M = FSM.outputs M› 5. ‹FSM.transitions M = FSM.transitions M›*) (*goals: 1. ‹q1' = q1'› 2. ‹FSM.states M = FSM.states M› 3. ‹FSM.inputs M = FSM.inputs M› 4. ‹FSM.outputs M = FSM.outputs M› 5. ‹FSM.transitions M = FSM.transitions M› 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*) . then show "?thesis" (*goal: ‹from_FSM (from_FSM (M::('a::type, 'b::type, 'c::type) fsm) (q1::'a::type)) (q1'::'a::type) = from_FSM M q1'›*) apply transfer (*goal: ‹from_FSM (from_FSM M q1) q1' = from_FSM M q1'›*) by force qed lemma from_FSM_completely_specified : assumes "completely_specified M" shows "completely_specified (from_FSM M q)" proof (cases "q ∈ states M") (*goals: 1. ‹q ∈ FSM.states M ⟹ completely_specified (from_FSM M q)› 2. ‹q ∉ FSM.states M ⟹ completely_specified (from_FSM M q)›*) case True (*‹q ∈ FSM.states M›*) then show "?thesis" (*goal: ‹completely_specified (from_FSM M q)›*) using assms (*‹completely_specified M›*) by auto next (*goal: ‹q ∉ FSM.states M ⟹ completely_specified (from_FSM M q)›*) case False (*‹q ∉ FSM.states M›*) then have "from_FSM M q = M" apply transfer (*goal: ‹from_FSM (M::('a, 'b, 'c) fsm) (q::'a) = M›*) by auto then show "?thesis" (*goal: ‹completely_specified (from_FSM M q)›*) using assms (*‹completely_specified M›*) by auto qed lemma from_FSM_single_input : assumes "single_input M" shows "single_input (from_FSM M q)" proof (cases "q ∈ states M") (*goals: 1. ‹(q::'a::type) ∈ FSM.states (M::('a::type, 'b::type, 'c::type) fsm) ⟹ single_input (from_FSM M q)› 2. ‹(q::'a::type) ∉ FSM.states (M::('a::type, 'b::type, 'c::type) fsm) ⟹ single_input (from_FSM M q)›*) case True (*‹q ∈ FSM.states M›*) then show "?thesis" (*goal: ‹single_input (from_FSM M q)›*) using assms (*‹single_input M›*) by (metis from_FSM_simps( (*‹(?q::?'a::type) ∈ FSM.states (?M::(?'a::type, ?'b::type, ?'c::type) fsm) ⟹ FSM.transitions (from_FSM ?M ?q) = FSM.transitions ?M›*) 4) single_input.elims( (*‹⟦single_input (?x::(?'a::type, ?'b::type, ?'c::type) fsm) = (?y::bool); ⋀M::(?'a::type, ?'b::type, ?'c::type) fsm. ⟦?x = M; ?y = (∀t1::?'a::type × ?'b::type × ?'c::type × ?'a::type∈FSM.transitions M. ∀t2::?'a::type × ?'b::type × ?'c::type × ?'a::type∈FSM.transitions M. t_source t1 = t_source t2 ⟶ t_input t1 = t_input t2)⟧ ⟹ ?P::bool⟧ ⟹ ?P›*) 1)) next (*goal: ‹q ∉ FSM.states M ⟹ single_input (from_FSM M q)›*) case False (*‹q ∉ FSM.states M›*) then have "from_FSM M q = M" apply transfer (*goal: ‹from_FSM M q = M›*) by auto then show "?thesis" (*goal: ‹single_input (from_FSM M q)›*) using assms (*‹single_input (M::('a::type, 'b::type, 'c::type) fsm)›*) by presburger qed lemma from_FSM_acyclic : assumes "q ∈ reachable_states M" and "acyclic M" shows "acyclic (from_FSM M q)" using assms(1) (*‹q ∈ reachable_states M›*) acyclic_paths_from_reachable_states[OF assms ( 2 ), of _ q] (*‹⟦path M (FSM.initial M) ?p'; target (FSM.initial M) ?p' = q; path M q ?p⟧ ⟹ distinct (visited_states q ?p)›*) from_FSM_path[of q M q] (*‹⟦(q::'a::type) ∈ FSM.states (M::('a::type, 'b::type, 'c::type) fsm); path (from_FSM M q) q (?p::('a::type × 'b::type × 'c::type × 'a::type) list)⟧ ⟹ path M q ?p›*) path_target_is_state (*‹path ?M ?q ?p ⟹ target ?q ?p ∈ FSM.states ?M›*) reachable_state_is_state[OF assms ( 1 )] (*‹q ∈ FSM.states M›*) from_FSM_simps(1) (*‹(?q::?'a) ∈ FSM.states (?M::(?'a, ?'b, ?'c) fsm) ⟹ FSM.initial (from_FSM ?M ?q) = ?q›*) unfolding acyclic.simps reachable_states_def (*goal: ‹∀p::('a × 'b × 'c × 'a) list. path (from_FSM (M::('a, 'b, 'c) fsm) (q::'a)) (FSM.initial (from_FSM M q)) p ⟶ distinct (visited_states (FSM.initial (from_FSM M q)) p)›*) by force lemma from_FSM_observable : assumes "observable M" shows "observable (from_FSM M q)" proof (cases "q ∈ states M") (*goals: 1. ‹q ∈ FSM.states M ⟹ observable (from_FSM M q)› 2. ‹q ∉ FSM.states M ⟹ observable (from_FSM M q)›*) case True (*‹q ∈ FSM.states M›*) then show "?thesis" (*goal: ‹observable (from_FSM (M::('a, 'b, 'c) fsm) (q::'a))›*) using assms (*‹observable M›*) proof (-) (*goal: ‹⟦(q::'a) ∈ FSM.states (M::('a, 'b, 'c) fsm); observable M⟧ ⟹ observable (from_FSM M q)›*) have f1: "∀f. observable f = (∀a b c aa ab. ((a::'a, b::'b, c::'c, aa) ∉ FSM.transitions f ∨ (a, b, c, ab) ∉ FSM.transitions f) ∨ aa = ab)" by force have "∀a f. a ∉ FSM.states (f::('a, 'b, 'c) fsm) ∨ FSM.transitions (FSM.from_FSM f a) = FSM.transitions f" by (meson from_FSM_simps( (*‹?q ∈ FSM.states ?M ⟹ FSM.transitions (from_FSM ?M ?q) = FSM.transitions ?M›*) 4)) then show "?thesis" (*goal: ‹observable (from_FSM M q)›*) using f1 (*‹∀f. observable f = (∀a b c aa ab. ((a, b, c, aa) ∉ FSM.transitions f ∨ (a, b, c, ab) ∉ FSM.transitions f) ∨ aa = ab)›*) True (*‹q ∈ FSM.states M›*) assms (*‹observable M›*) by presburger qed next (*goal: ‹q ∉ FSM.states M ⟹ observable (from_FSM M q)›*) case False (*‹(q::'a) ∉ FSM.states (M::('a, 'b, 'c) fsm)›*) then have "from_FSM M q = M" apply transfer (*goal: ‹from_FSM (M::('a, 'b, 'c) fsm) (q::'a) = M›*) by auto then show "?thesis" (*goal: ‹observable (from_FSM M q)›*) using assms (*‹observable M›*) by presburger qed lemma observable_language_next : assumes "io#ios ∈ LS M (t_source t)" and "observable M" and "t ∈ transitions M" and "t_input t = fst io" and "t_output t = snd io" shows "ios ∈ L (from_FSM M (t_target t))" proof (-) (*goal: ‹ios ∈ L (from_FSM M (t_target t))›*) obtain p where "path M (t_source t) p" and "p_io p = io#ios" (*goal: ‹(⋀p. ⟦path M (t_source t) p; p_io p = io # ios⟧ ⟹ thesis) ⟹ thesis›*) using assms(1) (*‹io # ios ∈ LS M (t_source t)›*) proof (-) (*goal: ‹⟦⋀p. ⟦path M (t_source t) p; p_io p = io # ios⟧ ⟹ thesis; io # ios ∈ LS M (t_source t)⟧ ⟹ thesis›*) assume a1: "⋀p. ⟦path M (t_source t) p; p_io p = io # ios⟧ ⟹ thesis" (*‹⟦path (M::('c, 'a, 'b) fsm) (t_source (t::'c × 'a × 'b × 'c)) (?p::('c × 'a × 'b × 'c) list); p_io ?p = (io::'a × 'b) # (ios::('a × 'b) list)⟧ ⟹ thesis::bool›*) obtain pps :: "('a × 'b) list ⇒ 'c ⇒ ('c, 'a, 'b) fsm ⇒ ('c × 'a × 'b × 'c) list" where "∀x0 x1 x2. (∃v3. x0 = p_io v3 ∧ path x2 x1 v3) = (x0 = p_io (pps x0 x1 x2) ∧ path x2 x1 (pps x0 x1 x2))" (*goal: ‹(⋀pps. ∀x0 x1 x2. (∃v3. x0 = p_io v3 ∧ path x2 x1 v3) = (x0 = p_io (pps x0 x1 x2) ∧ path x2 x1 (pps x0 x1 x2)) ⟹ thesis) ⟹ thesis›*) by moura then have "∃ps. path M (t_source t) ps ∧ p_io ps = io # ios" using assms(1) (*‹io # ios ∈ LS M (t_source t)›*) by auto then show "?thesis" (*goal: ‹thesis›*) using a1 (*‹⟦path M (t_source t) ?p; p_io ?p = io # ios⟧ ⟹ thesis›*) by meson qed then obtain t' and p' where "p = t' # p'" (*goal: ‹(⋀(t'::'c × 'a × 'b × 'c) p'::('c × 'a × 'b × 'c) list. (p::('c × 'a × 'b × 'c) list) = t' # p' ⟹ thesis::bool) ⟹ thesis›*) by auto then have "t' ∈ transitions M" and "t_source t' = t_source t" and "t_input t' = fst io" and "t_output t' = snd io" using ‹path M (t_source t) p› (*‹path M (t_source t) p›*) ‹p_io p = io#ios› (*‹p_io p = io # ios›*) apply - (*goals: 1. ‹⟦p = t' # p'; path M (t_source t) p; p_io p = io # ios⟧ ⟹ t' ∈ FSM.transitions M› 2. ‹⟦p = t' # p'; path M (t_source t) p; p_io p = io # ios⟧ ⟹ t_source t' = t_source t› 3. ‹⟦p = t' # p'; path M (t_source t) p; p_io p = io # ios⟧ ⟹ t_input t' = fst io› 4. ‹⟦p = t' # p'; path M (t_source t) p; p_io p = io # ios⟧ ⟹ t_output t' = snd io› 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 "t = t'" using assms(2,3,4,5) (*‹observable M› ‹t ∈ FSM.transitions M› ‹t_input (t::'c × 'a × 'b × 'c) = fst (io::'a × 'b)› ‹t_output t = snd io›*) unfolding observable.simps (*goal: ‹t = t'›*) by (metis (no_types, opaque_lifting) prod.expand (*‹fst ?prod = fst ?prod' ∧ snd ?prod = snd ?prod' ⟹ ?prod = ?prod'›*)) then have "path M (t_target t) p'" and "p_io p' = ios" using ‹p = t' # p'› (*‹(p::('c::type × 'a::type × 'b::type × 'c::type) list) = (t'::'c::type × 'a::type × 'b::type × 'c::type) # (p'::('c::type × 'a::type × 'b::type × 'c::type) list)›*) ‹path M (t_source t) p› (*‹path (M::('c, 'a, 'b) fsm) (t_source (t::'c × 'a × 'b × 'c)) (p::('c × 'a × 'b × 'c) list)›*) ‹p_io p = io#ios› (*‹p_io (p::('c::type × 'a::type × 'b::type × 'c::type) list) = (io::'a::type × 'b::type) # (ios::('a::type × 'b::type) list)›*) apply - (*goals: 1. ‹⟦t = t'; p = t' # p'; path M (t_source t) p; p_io p = io # ios⟧ ⟹ path M (t_target t) p'› 2. ‹⟦t = t'; p = t' # p'; path M (t_source t) p; p_io p = io # ios⟧ ⟹ p_io p' = ios› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . then have "path (from_FSM M (t_target t)) (initial (from_FSM M (t_target t))) p'" by (meson assms( (*‹t ∈ FSM.transitions M›*) 3) from_FSM_path_initial (*‹?q ∈ FSM.states ?M ⟹ path ?M ?q ?p = path (from_FSM ?M ?q) (FSM.initial (from_FSM ?M ?q)) ?p›*) fsm_transition_target (*‹?t ∈ FSM.transitions ?M ⟹ t_target ?t ∈ FSM.states ?M›*)) then show "?thesis" (*goal: ‹ios ∈ L (from_FSM M (t_target t))›*) using ‹p_io p' = ios› (*‹p_io p' = ios›*) by auto qed lemma from_FSM_language : assumes "q ∈ states M" shows "L (from_FSM M q) = LS M q" using assms (*‹q ∈ FSM.states M›*) unfolding LS.simps (*goal: ‹{p_io p |p. path (from_FSM M q) (FSM.initial (from_FSM M q)) p} = {p_io p |p. path M q p}›*) by (meson from_FSM_path_initial (*‹?q ∈ FSM.states ?M ⟹ path ?M ?q ?p = path (from_FSM ?M ?q) (FSM.initial (from_FSM ?M ?q)) ?p›*)) lemma observable_transition_target_language_subset : assumes "LS M (t_source t1) ⊆ LS M (t_source t2)" and "t1 ∈ transitions M" and "t2 ∈ transitions M" and "t_input t1 = t_input t2" and "t_output t1 = t_output t2" and "observable M" shows "LS M (t_target t1) ⊆ LS M (t_target t2)" proof (rule ccontr (*‹(¬ ?P ⟹ False) ⟹ ?P›*)) (*goal: ‹¬ LS M (t_target t1) ⊆ LS M (t_target t2) ⟹ False›*) assume "¬ LS M (t_target t1) ⊆ LS M (t_target t2)" (*‹¬ LS (M::('c, 'a, 'b) fsm) (t_target (t1::'c × 'a × 'b × 'c)) ⊆ LS M (t_target (t2::'c × 'a × 'b × 'c))›*) then obtain ioF where "ioF ∈ LS M (t_target t1)" and "ioF ∉ LS M (t_target t2)" (*goal: ‹(⋀ioF. ⟦ioF ∈ LS M (t_target t1); ioF ∉ LS M (t_target t2)⟧ ⟹ thesis) ⟹ thesis›*) by blast then have "(t_input t1, t_output t1)#ioF ∈ LS M (t_source t1)" using LS_prepend_transition (*‹⟦?t ∈ FSM.transitions ?M; ?io ∈ LS ?M (t_target ?t)⟧ ⟹ (t_input ?t, t_output ?t) # ?io ∈ LS ?M (t_source ?t)›*) assms(2) (*‹t1 ∈ FSM.transitions M›*) by blast then have "*": "(t_input t1, t_output t1)#ioF ∈ LS M (t_source t2)" using assms(1) (*‹LS M (t_source t1) ⊆ LS M (t_source t2)›*) by blast have "ioF ∈ LS M (t_target t2)" using observable_language_next[OF * ‹observable M› ‹t2 ∈ transitions M›] (*‹⟦t_input t2 = fst (t_input t1, t_output t1); t_output t2 = snd (t_input t1, t_output t1)⟧ ⟹ ioF ∈ L (from_FSM M (t_target t2))›*) unfolding assms(4,5) fst_conv snd_conv (*goal: ‹ioF ∈ LS M (t_target t2)›*) by (metis assms( (*‹t2 ∈ FSM.transitions M›*) 3) from_FSM_language (*‹?q ∈ FSM.states ?M ⟹ L (from_FSM ?M ?q) = LS ?M ?q›*) fsm_transition_target (*‹?t ∈ FSM.transitions ?M ⟹ t_target ?t ∈ FSM.states ?M›*)) then show False using ‹ioF ∉ LS M (t_target t2)› (*‹ioF ∉ LS M (t_target t2)›*) by blast qed lemma observable_transition_target_language_eq : assumes "LS M (t_source t1) = LS M (t_source t2)" and "t1 ∈ transitions M" and "t2 ∈ transitions M" and "t_input t1 = t_input t2" and "t_output t1 = t_output t2" and "observable M" shows "LS M (t_target t1) = LS M (t_target t2)" using observable_transition_target_language_subset[OF _ assms ( 2 , 3 , 4 , 5 , 6 )] (*‹LS (M::('c, 'a, 'b) fsm) (t_source (t1::'c × 'a × 'b × 'c)) ⊆ LS M (t_source (t2::'c × 'a × 'b × 'c)) ⟹ LS M (t_target t1) ⊆ LS M (t_target t2)›*) observable_transition_target_language_subset[OF _ assms ( 3 , 2 ) assms ( 4 , 5 ) [ symmetric ] assms ( 6 )] (*‹LS M (t_source t2) ⊆ LS M (t_source t1) ⟹ LS M (t_target t2) ⊆ LS M (t_target t1)›*) assms(1) (*‹LS M (t_source t1) = LS M (t_source t2)›*) by blast lemma language_state_prepend_transition : assumes "io ∈ LS (from_FSM A (t_target t)) (initial (from_FSM A (t_target t)))" and "t ∈ transitions A" shows "p_io [t] @ io ∈ LS A (t_source t)" proof (-) (*goal: ‹p_io [t] @ io ∈ LS A (t_source t)›*) obtain p where "path (from_FSM A (t_target t)) (initial (from_FSM A (t_target t))) p" and "p_io p = io" (*goal: ‹(⋀p. ⟦path (from_FSM A (t_target t)) (FSM.initial (from_FSM A (t_target t))) p; p_io p = io⟧ ⟹ thesis) ⟹ thesis›*) using assms(1) (*‹io ∈ L (from_FSM A (t_target t))›*) unfolding LS.simps (*goal: ‹(⋀p. ⟦path (from_FSM A (t_target t)) (FSM.initial (from_FSM A (t_target t))) p; p_io p = io⟧ ⟹ thesis) ⟹ thesis›*) by blast then have "path A (t_target t) p" by (meson assms( (*‹t ∈ FSM.transitions A›*) 2) from_FSM_path_initial (*‹?q ∈ FSM.states ?M ⟹ path ?M ?q ?p = path (from_FSM ?M ?q) (FSM.initial (from_FSM ?M ?q)) ?p›*) fsm_transition_target (*‹?t ∈ FSM.transitions ?M ⟹ t_target ?t ∈ FSM.states ?M›*)) then have "path A (t_source t) (t # p)" using assms(2) (*‹t ∈ FSM.transitions A›*) by auto then show "?thesis" (*goal: ‹p_io [t] @ io ∈ LS A (t_source t)›*) using ‹p_io p = io› (*‹p_io p = io›*) unfolding LS.simps (*goal: ‹p_io [t] @ io ∈ {p_io p |p. path A (t_source t) p}›*) by force qed lemma observable_language_transition_target : assumes "observable M" and "t ∈ transitions M" and "(t_input t, t_output t) # io ∈ LS M (t_source t)" shows "io ∈ LS M (t_target t)" by (metis (no_types) assms( (*‹observable M›*) 1) assms( (*‹t ∈ FSM.transitions M›*) 2) assms( (*‹(t_input t, t_output t) # io ∈ LS M (t_source t)›*) 3) from_FSM_language (*‹?q ∈ FSM.states ?M ⟹ L (from_FSM ?M ?q) = LS ?M ?q›*) fsm_transition_target (*‹?t ∈ FSM.transitions ?M ⟹ t_target ?t ∈ FSM.states ?M›*) fst_conv (*‹fst (?x1.0, ?x2.0) = ?x1.0›*) observable_language_next (*‹⟦?io # ?ios ∈ LS ?M (t_source ?t); observable ?M; ?t ∈ FSM.transitions ?M; t_input ?t = fst ?io; t_output ?t = snd ?io⟧ ⟹ ?ios ∈ L (from_FSM ?M (t_target ?t))›*) snd_conv (*‹snd (?x1.0, ?x2.0) = ?x2.0›*)) lemma LS_single_transition : "[(x,y)] ∈ LS M q ⟷ (∃ t ∈ transitions M . t_source t = q ∧ t_input t = x ∧ t_output t = y)" proof (standard) (*goals: 1. ‹[(x::'a, y::'b)] ∈ LS (M::('c, 'a, 'b) fsm) (q::'c) ⟹ ∃t::'c × 'a × 'b × 'c∈FSM.transitions M. t_source t = q ∧ t_input t = x ∧ t_output t = y› 2. ‹∃t::'c × 'a × 'b × 'c∈FSM.transitions (M::('c, 'a, 'b) fsm). t_source t = (q::'c) ∧ t_input t = (x::'a) ∧ t_output t = (y::'b) ⟹ [(x, y)] ∈ LS M q›*) show "[(x, y)] ∈ LS M q ⟹ ∃t∈FSM.transitions M. t_source t = q ∧ t_input t = x ∧ t_output t = y" by auto show "∃t∈FSM.transitions M. t_source t = q ∧ t_input t = x ∧ t_output t = y ⟹ [(x, y)] ∈ LS M q" by (metis LS_prepend_transition (*‹⟦?t ∈ FSM.transitions ?M; ?io ∈ LS ?M (t_target ?t)⟧ ⟹ (t_input ?t, t_output ?t) # ?io ∈ LS ?M (t_source ?t)›*) from_FSM_language (*‹?q ∈ FSM.states ?M ⟹ L (from_FSM ?M ?q) = LS ?M ?q›*) fsm_transition_target (*‹?t ∈ FSM.transitions ?M ⟹ t_target ?t ∈ FSM.states ?M›*) language_contains_empty_sequence (*‹[] ∈ L ?M›*)) qed lemma h_obs_language_append : assumes "observable M" and "u ∈ L M" and "h_obs M (after_initial M u) x y ≠ None" shows "u@[(x,y)] ∈ L M" using after_language_iff[OF assms ( 1 , 2 ), of "[(x,y)]"] (*‹([(x, y)] ∈ LS M (after_initial M u)) = (u @ [(x, y)] ∈ L M)›*) using h_obs_None[OF assms ( 1 )] (*‹(FSM.h_obs M ?q ?x ?y = None) = (∄q'. (?q, ?x, ?y, q') ∈ FSM.transitions M)›*) assms(3) (*‹FSM.h_obs M (after_initial M u) x y ≠ None›*) unfolding LS_single_transition (*goal: ‹u @ [(x, y)] ∈ L M›*) by (metis old.prod.inject (*‹((?a, ?b) = (?a', ?b')) = (?a = ?a' ∧ ?b = ?b')›*) prod.collapse (*‹(fst ?prod, snd ?prod) = ?prod›*)) lemma h_obs_language_single_transition_iff : assumes "observable M" shows "[(x,y)] ∈ LS M q ⟷ h_obs M q x y ≠ None" using h_obs_None[OF assms ( 1 ), of q x y] (*‹(FSM.h_obs M q x y = None) = (∄q'. (q, x, y, q') ∈ FSM.transitions M)›*) unfolding LS_single_transition (*goal: ‹(∃t∈FSM.transitions M. t_source t = q ∧ t_input t = x ∧ t_output t = y) = (FSM.h_obs M q x y ≠ None)›*) by (metis fst_conv (*‹fst (?x1.0, ?x2.0) = ?x1.0›*) prod.exhaust_sel (*‹(?prod = (fst ?prod, snd ?prod) ⟹ ?P) ⟹ ?P›*) snd_conv (*‹snd (?x1.0, ?x2.0) = ?x2.0›*)) (* TODO: generalise to non-observable FSMs *) lemma minimal_failure_prefix_ob : assumes "observable M" and "observable I" and "qM ∈ states M" and "qI ∈ states I" and "io ∈ LS I qI - LS M qM" obtains io' xy io'' where "io = io'@[xy]@io''" and "io' ∈ LS I qI ∩ LS M qM" and "io'@[xy] ∈ LS I qI - LS M qM" proof (-) (*goal: ‹(⋀io' xy io''. ⟦io = io' @ [xy] @ io''; io' ∈ LS I qI ∩ LS M qM; io' @ [xy] ∈ LS I qI - LS M qM⟧ ⟹ thesis) ⟹ thesis›*) have "∃ io' xy io'' . io = io'@[xy]@io'' ∧ io' ∈ LS I qI ∩ LS M qM ∧ io'@[xy] ∈ LS I qI - LS M qM" using assms(3,4,5) (*‹qM ∈ FSM.states M› ‹qI ∈ FSM.states I› ‹(io::('b × 'c) list) ∈ LS (I::('d, 'b, 'c) fsm) (qI::'d) - LS (M::('a, 'b, 'c) fsm) (qM::'a)›*) proof (induction io arbitrary: qM qI) (*goals: 1. ‹⋀qM qI. ⟦qM ∈ FSM.states M; qI ∈ FSM.states I; [] ∈ LS I qI - LS M qM⟧ ⟹ ∃io' xy io''. [] = io' @ [xy] @ io'' ∧ io' ∈ LS I qI ∩ LS M qM ∧ io' @ [xy] ∈ LS I qI - LS M qM› 2. ‹⋀a io qM qI. ⟦⋀qM qI. ⟦qM ∈ FSM.states M; qI ∈ FSM.states I; io ∈ LS I qI - LS M qM⟧ ⟹ ∃io' xy io''. io = io' @ [xy] @ io'' ∧ io' ∈ LS I qI ∩ LS M qM ∧ io' @ [xy] ∈ LS I qI - LS M qM; qM ∈ FSM.states M; qI ∈ FSM.states I; a # io ∈ LS I qI - LS M qM⟧ ⟹ ∃io' xy io''. a # io = io' @ [xy] @ io'' ∧ io' ∈ LS I qI ∩ LS M qM ∧ io' @ [xy] ∈ LS I qI - LS M qM›*) case Nil (*‹(qM::'a::type) ∈ FSM.states (M::('a::type, 'b::type, 'c::type) fsm)› ‹qI ∈ FSM.states I› ‹[] ∈ LS I qI - LS M qM›*) then show "?case" (*goal: ‹∃(io'::('b × 'c) list) (xy::'b × 'c) io''::('b × 'c) list. [] = io' @ [xy] @ io'' ∧ io' ∈ LS (I::('d, 'b, 'c) fsm) (qI::'d) ∩ LS (M::('a, 'b, 'c) fsm) (qM::'a) ∧ io' @ [xy] ∈ LS I qI - LS M qM›*) by auto next (*goal: ‹⋀a io qM qI. ⟦⋀qM qI. ⟦qM ∈ FSM.states M; qI ∈ FSM.states I; io ∈ LS I qI - LS M qM⟧ ⟹ ∃io' xy io''. io = io' @ [xy] @ io'' ∧ io' ∈ LS I qI ∩ LS M qM ∧ io' @ [xy] ∈ LS I qI - LS M qM; qM ∈ FSM.states M; qI ∈ FSM.states I; a # io ∈ LS I qI - LS M qM⟧ ⟹ ∃io' xy io''. a # io = io' @ [xy] @ io'' ∧ io' ∈ LS I qI ∩ LS M qM ∧ io' @ [xy] ∈ LS I qI - LS M qM›*) case (Cons xy io) (*‹⟦?qM ∈ FSM.states M; ?qI ∈ FSM.states I; io ∈ LS I ?qI - LS M ?qM⟧ ⟹ ∃io' xy io''. io = io' @ [xy] @ io'' ∧ io' ∈ LS I ?qI ∩ LS M ?qM ∧ io' @ [xy] ∈ LS I ?qI - LS M ?qM› ‹(qM::'a::type) ∈ FSM.states (M::('a::type, 'b::type, 'c::type) fsm)› ‹qI ∈ FSM.states I› ‹xy # io ∈ LS I qI - LS M qM›*) show "?case" (*goal: ‹∃(io'::('b × 'c) list) (xya::'b × 'c) io''::('b × 'c) list. (xy::'b × 'c) # (io::('b × 'c) list) = io' @ [xya] @ io'' ∧ io' ∈ LS (I::('d, 'b, 'c) fsm) (qI::'d) ∩ LS (M::('a, 'b, 'c) fsm) (qM::'a) ∧ io' @ [xya] ∈ LS I qI - LS M qM›*) proof (cases "[xy] ∈ LS I qI - LS M qM") (*goals: 1. ‹[xy] ∈ LS I qI - LS M qM ⟹ ∃io' xya io''. xy # io = io' @ [xya] @ io'' ∧ io' ∈ LS I qI ∩ LS M qM ∧ io' @ [xya] ∈ LS I qI - LS M qM› 2. ‹[xy] ∉ LS I qI - LS M qM ⟹ ∃io' xya io''. xy # io = io' @ [xya] @ io'' ∧ io' ∈ LS I qI ∩ LS M qM ∧ io' @ [xya] ∈ LS I qI - LS M qM›*) case True (*‹[xy] ∈ LS I qI - LS M qM›*) have "xy # io = []@[xy]@io" by auto moreover have "[] ∈ LS I qI ∩ LS M qM" using ‹qM ∈ states M› (*‹qM ∈ FSM.states M›*) ‹qI ∈ states I› (*‹qI ∈ FSM.states I›*) by auto moreover have "[]@[xy] ∈ LS I qI - LS M qM" using True (*‹[xy] ∈ LS I qI - LS M qM›*) by auto ultimately show "?thesis" (*goal: ‹∃io' xya io''. xy # io = io' @ [xya] @ io'' ∧ io' ∈ LS I qI ∩ LS M qM ∧ io' @ [xya] ∈ LS I qI - LS M qM›*) by blast next (*goal: ‹[xy] ∉ LS I qI - LS M qM ⟹ ∃io' xya io''. xy # io = io' @ [xya] @ io'' ∧ io' ∈ LS I qI ∩ LS M qM ∧ io' @ [xya] ∈ LS I qI - LS M qM›*) case False (*‹[xy] ∉ LS I qI - LS M qM›*) obtain x and y where "xy = (x,y)" (*goal: ‹(⋀x y. xy = (x, y) ⟹ thesis) ⟹ thesis›*) by (meson surj_pair (*‹∃x y. ?p = (x, y)›*)) have "[(x,y)] ∈ LS M qM" using ‹xy = (x,y)› (*‹xy = (x, y)›*) False (*‹[xy] ∉ LS I qI - LS M qM›*) ‹xy # io ∈ LS I qI - LS M qM› (*‹(xy::'b::type × 'c::type) # (io::('b::type × 'c::type) list) ∈ LS (I::('d::type, 'b::type, 'c::type) fsm) (qI::'d::type) - LS (M::('a::type, 'b::type, 'c::type) fsm) (qM::'a::type)›*) by (metis DiffD1 (*‹?c ∈ ?A - ?B ⟹ ?c ∈ ?A›*) DiffI (*‹⟦?c ∈ ?A; ?c ∉ ?B⟧ ⟹ ?c ∈ ?A - ?B›*) append_Cons (*‹(?x # ?xs) @ ?ys = ?x # ?xs @ ?ys›*) append_Nil (*‹[] @ ?ys = ?ys›*) language_prefix (*‹?io1.0 @ ?io2.0 ∈ LS ?M ?q ⟹ ?io1.0 ∈ LS ?M ?q›*)) then obtain qM' where "(qM,x,y,qM') ∈ transitions M" (*goal: ‹(⋀qM'. (qM, x, y, qM') ∈ FSM.transitions M ⟹ thesis) ⟹ thesis›*) by auto then have "io ∉ LS M qM'" using observable_language_transition_target[OF ‹observable M›] (*‹⟦?t ∈ FSM.transitions M; (t_input ?t, t_output ?t) # ?io ∈ LS M (t_source ?t)⟧ ⟹ ?io ∈ LS M (t_target ?t)›*) ‹xy = (x,y)› (*‹(xy::'b::type × 'c::type) = (x::'b::type, y::'c::type)›*) ‹xy # io ∈ LS I qI - LS M qM› (*‹(xy::'b × 'c) # (io::('b × 'c) list) ∈ LS (I::('d, 'b, 'c) fsm) (qI::'d) - LS (M::('a, 'b, 'c) fsm) (qM::'a)›*) by (metis DiffD2 (*‹⟦?c ∈ ?A - ?B; ?c ∈ ?B⟧ ⟹ ?P›*) LS_prepend_transition (*‹⟦?t ∈ FSM.transitions ?M; ?io ∈ LS ?M (t_target ?t)⟧ ⟹ (t_input ?t, t_output ?t) # ?io ∈ LS ?M (t_source ?t)›*) fst_conv (*‹fst (?x1.0, ?x2.0) = ?x1.0›*) snd_conv (*‹snd (?x1.0, ?x2.0) = ?x2.0›*)) have "[(x,y)] ∈ LS I qI" using ‹xy = (x,y)› (*‹xy = (x, y)›*) ‹xy # io ∈ LS I qI - LS M qM› (*‹(xy::'b × 'c) # (io::('b × 'c) list) ∈ LS (I::('d, 'b, 'c) fsm) (qI::'d) - LS (M::('a, 'b, 'c) fsm) (qM::'a)›*) by (metis DiffD1 (*‹?c ∈ ?A - ?B ⟹ ?c ∈ ?A›*) append_Cons (*‹(?x # ?xs) @ ?ys = ?x # ?xs @ ?ys›*) append_Nil (*‹[] @ ?ys = ?ys›*) language_prefix (*‹?io1.0 @ ?io2.0 ∈ LS ?M ?q ⟹ ?io1.0 ∈ LS ?M ?q›*)) then obtain qI' where "(qI,x,y,qI') ∈ transitions I" (*goal: ‹(⋀qI'::'d. (qI::'d, x::'b, y::'c, qI') ∈ FSM.transitions (I::('d, 'b, 'c) fsm) ⟹ thesis::bool) ⟹ thesis›*) by auto then have "io ∈ LS I qI'" using observable_language_next[of xy io I "(qI,x,y,qI')", OF _ ‹observable I›] (*‹⟦xy # io ∈ LS I (t_source (qI, x, y, qI')); (qI, x, y, qI') ∈ FSM.transitions I; t_input (qI, x, y, qI') = fst xy; t_output (qI, x, y, qI') = snd xy⟧ ⟹ io ∈ L (from_FSM I (t_target (qI, x, y, qI')))›*) ‹xy # io ∈ LS I qI - LS M qM› (*‹xy # io ∈ LS I qI - LS M qM›*) fsm_transition_target[OF ‹(qI,x,y,qI') ∈ transitions I›] (*‹t_target (qI::'d, x::'b, y::'c, qI'::'d) ∈ FSM.states (I::('d, 'b, 'c) fsm)›*) unfolding ‹xy = (x,y)› fst_conv snd_conv (*goal: ‹io ∈ LS I qI'›*) by (metis DiffD1 (*‹?c ∈ ?A - ?B ⟹ ?c ∈ ?A›*) from_FSM_language (*‹?q ∈ FSM.states ?M ⟹ L (from_FSM ?M ?q) = LS ?M ?q›*)) obtain io' and xy' and io'' where "io = io'@[xy']@io''" and "io' ∈ LS I qI' ∩ LS M qM'" and "io'@[xy'] ∈ LS I qI' - LS M qM'" (*goal: ‹(⋀io' xy' io''. ⟦io = io' @ [xy'] @ io''; io' ∈ LS I qI' ∩ LS M qM'; io' @ [xy'] ∈ LS I qI' - LS M qM'⟧ ⟹ thesis) ⟹ thesis›*) using ‹io ∈ LS I qI'› (*‹io ∈ LS I qI'›*) ‹io ∉ LS M qM'› (*‹io ∉ LS M qM'›*) Cons.IH[OF fsm_transition_target [ OF ‹(qM,x,y,qM') ∈ transitions M› ] fsm_transition_target [ OF ‹(qI,x,y,qI') ∈ transitions I› ]] (*‹io ∈ LS I (t_target (qI, x, y, qI')) - LS M (t_target (qM, x, y, qM')) ⟹ ∃io' xy io''. io = io' @ [xy] @ io'' ∧ io' ∈ LS I (t_target (qI, x, y, qI')) ∩ LS M (t_target (qM, x, y, qM')) ∧ io' @ [xy] ∈ LS I (t_target (qI, x, y, qI')) - LS M (t_target (qM, x, y, qM'))›*) unfolding fst_conv snd_conv (*goal: ‹(⋀io' xy' io''. ⟦io = io' @ [xy'] @ io''; io' ∈ LS I qI' ∩ LS M qM'; io' @ [xy'] ∈ LS I qI' - LS M qM'⟧ ⟹ thesis) ⟹ thesis›*) by blast have "xy#io = (xy#io')@[xy']@io''" using ‹io = io'@[xy']@io''› (*‹io = io' @ [xy'] @ io''›*) ‹xy = (x,y)› (*‹xy = (x, y)›*) by auto moreover have "xy#io' ∈ LS I qI ∩ LS M qM" using LS_prepend_transition[OF ‹(qI,x,y,qI') ∈ transitions I›, of io'] (*‹io' ∈ LS I (t_target (qI, x, y, qI')) ⟹ (t_input (qI, x, y, qI'), t_output (qI, x, y, qI')) # io' ∈ LS I (t_source (qI, x, y, qI'))›*) using LS_prepend_transition[OF ‹(qM,x,y,qM') ∈ transitions M›, of io'] (*‹io' ∈ LS M (t_target (qM, x, y, qM')) ⟹ (t_input (qM, x, y, qM'), t_output (qM, x, y, qM')) # io' ∈ LS M (t_source (qM, x, y, qM'))›*) using ‹io' ∈ LS I qI' ∩ LS M qM'› (*‹io' ∈ LS I qI' ∩ LS M qM'›*) unfolding ‹xy = (x,y)› fst_conv snd_conv (*goal: ‹(x, y) # io' ∈ LS I qI ∩ LS M qM›*) by auto moreover have "(xy#io')@[xy'] ∈ LS I qI - LS M qM" using LS_prepend_transition[OF ‹(qI,x,y,qI') ∈ transitions I›, of "io'@[xy']"] (*‹io' @ [xy'] ∈ LS I (t_target (qI, x, y, qI')) ⟹ (t_input (qI, x, y, qI'), t_output (qI, x, y, qI')) # io' @ [xy'] ∈ LS I (t_source (qI, x, y, qI'))›*) using observable_language_transition_target[OF ‹observable M› ‹(qM,x,y,qM') ∈ transitions M›, of "io'@[xy']"] (*‹(t_input (qM, x, y, qM'), t_output (qM, x, y, qM')) # io' @ [xy'] ∈ LS M (t_source (qM, x, y, qM')) ⟹ io' @ [xy'] ∈ LS M (t_target (qM, x, y, qM'))›*) using ‹io'@[xy'] ∈ LS I qI' - LS M qM'› (*‹io' @ [xy'] ∈ LS I qI' - LS M qM'›*) unfolding ‹xy = (x,y)› fst_conv snd_conv (*goal: ‹((x, y) # io') @ [xy'] ∈ LS I qI - LS M qM›*) by fastforce ultimately show "?thesis" (*goal: ‹∃io' xya io''. xy # io = io' @ [xya] @ io'' ∧ io' ∈ LS I qI ∩ LS M qM ∧ io' @ [xya] ∈ LS I qI - LS M qM›*) by blast qed qed then show "?thesis" (*goal: ‹thesis›*) using that (*‹⟦(io::('b::type × 'c::type) list) = (?io'::('b::type × 'c::type) list) @ [?xy::'b::type × 'c::type] @ (?io''::('b::type × 'c::type) list); ?io' ∈ LS (I::('d::type, 'b::type, 'c::type) fsm) (qI::'d::type) ∩ LS (M::('a::type, 'b::type, 'c::type) fsm) (qM::'a::type); ?io' @ [?xy] ∈ LS I qI - LS M qM⟧ ⟹ thesis::bool›*) by blast qed subsection ‹Language and Defined Inputs› lemma defined_inputs_code : "defined_inputs M q = t_input ` Set.filter (λt . t_source t = q) (transitions M)" unfolding defined_inputs_set (*goal: ‹{x ∈ FSM.inputs M. FSM.h M (q, x) ≠ {}} = t_input ` Set.filter (λt. t_source t = q) (FSM.transitions M)›*) by force lemma defined_inputs_alt_def : "defined_inputs M q = {t_input t | t . t ∈ transitions M ∧ t_source t = q}" unfolding defined_inputs_code (*goal: ‹t_input ` Set.filter (λt. t_source t = q) (FSM.transitions M) = {t_input t |t. t ∈ FSM.transitions M ∧ t_source t = q}›*) by force lemma defined_inputs_language_diff : assumes "x ∈ defined_inputs M1 q1" and "x ∉ defined_inputs M2 q2" obtains y where "[(x,y)] ∈ LS M1 q1 - LS M2 q2" using assms (*‹x ∈ defined_inputs M1 q1› ‹x ∉ defined_inputs M2 q2›*) unfolding defined_inputs_alt_def (*goal: ‹(⋀y. [(x, y)] ∈ LS M1 q1 - LS M2 q2 ⟹ thesis) ⟹ thesis›*) proof (-) (*goal: ‹⟦⋀y::'c. [(x::'a, y)] ∈ LS (M1::('b, 'a, 'c) fsm) (q1::'b) - LS (M2::('d, 'a, 'c) fsm) (q2::'d) ⟹ thesis::bool; x ∈ {t_input t |t::'b × 'a × 'c × 'b. t ∈ FSM.transitions M1 ∧ t_source t = q1}; x ∉ {t_input t |t::'d × 'a × 'c × 'd. t ∈ FSM.transitions M2 ∧ t_source t = q2}⟧ ⟹ thesis›*) assume a1: "x ∉ {t_input t |t. t ∈ FSM.transitions M2 ∧ t_source t = q2}" (*‹(x::'a) ∉ {t_input t |t::'d × 'a × 'c × 'd. t ∈ FSM.transitions (M2::('d, 'a, 'c) fsm) ∧ t_source t = (q2::'d)}›*) assume a2: "x ∈ {t_input t |t. t ∈ FSM.transitions M1 ∧ t_source t = q1}" (*‹(x::'a) ∈ {t_input t |t::'b × 'a × 'c × 'b. t ∈ FSM.transitions (M1::('b, 'a, 'c) fsm) ∧ t_source t = (q1::'b)}›*) assume a3: "⋀y. [(x, y)] ∈ LS M1 q1 - LS M2 q2 ⟹ thesis" (*‹[(x::'a, ?y::'c)] ∈ LS (M1::('b, 'a, 'c) fsm) (q1::'b) - LS (M2::('d, 'a, 'c) fsm) (q2::'d) ⟹ thesis::bool›*) have f4: "∄p. x = t_input p ∧ p ∈ FSM.transitions M2 ∧ t_source p = q2" using a1 (*‹x ∉ {t_input t |t. t ∈ FSM.transitions M2 ∧ t_source t = q2}›*) by blast obtain pp :: "'a ⇒ 'b × 'a × 'c × 'b" where "∀a. ((∄p. a = t_input p ∧ p ∈ FSM.transitions M1 ∧ t_source p = q1) ∨ a = t_input (pp a) ∧ pp a ∈ FSM.transitions M1 ∧ t_source (pp a) = q1) ∧ ((∃p. a = t_input p ∧ p ∈ FSM.transitions M1 ∧ t_source p = q1) ∨ (∀p. a ≠ t_input p ∨ p ∉ FSM.transitions M1 ∨ t_source p ≠ q1))" (*goal: ‹(⋀pp. ∀a. ((∄p. a = t_input p ∧ p ∈ FSM.transitions M1 ∧ t_source p = q1) ∨ a = t_input (pp a) ∧ pp a ∈ FSM.transitions M1 ∧ t_source (pp a) = q1) ∧ ((∃p. a = t_input p ∧ p ∈ FSM.transitions M1 ∧ t_source p = q1) ∨ (∀p. a ≠ t_input p ∨ p ∉ FSM.transitions M1 ∨ t_source p ≠ q1)) ⟹ thesis) ⟹ thesis›*) by moura then have "x = t_input (pp x) ∧ pp x ∈ FSM.transitions M1 ∧ t_source (pp x) = q1" using a2 (*‹x ∈ {t_input t |t. t ∈ FSM.transitions M1 ∧ t_source t = q1}›*) by blast then show "?thesis" (*goal: ‹thesis›*) using f4 (*‹∄p. x = t_input p ∧ p ∈ FSM.transitions M2 ∧ t_source p = q2›*) a3 (*‹[(x, ?y)] ∈ LS M1 q1 - LS M2 q2 ⟹ thesis›*) by (metis (no_types) DiffI (*‹⟦(?c::?'a::type) ∈ (?A::?'a::type set); ?c ∉ (?B::?'a::type set)⟧ ⟹ ?c ∈ ?A - ?B›*) LS_single_transition (*‹([(?x::?'a::type, ?y::?'b::type)] ∈ LS (?M::(?'c::type, ?'a::type, ?'b::type) fsm) (?q::?'c::type)) = (∃t::?'c::type × ?'a::type × ?'b::type × ?'c::type∈FSM.transitions ?M. t_source t = ?q ∧ t_input t = ?x ∧ t_output t = ?y)›*)) qed lemma language_path_append : assumes "path M1 q1 p1" and "io ∈ LS M1 (target q1 p1)" shows "(p_io p1 @ io) ∈ LS M1 q1" proof (-) (*goal: ‹p_io p1 @ io ∈ LS M1 q1›*) obtain p2 where "path M1 (target q1 p1) p2" and "p_io p2 = io" (*goal: ‹(⋀p2. ⟦path M1 (target q1 p1) p2; p_io p2 = io⟧ ⟹ thesis) ⟹ thesis›*) using assms(2) (*‹io ∈ LS M1 (target q1 p1)›*) by auto then have "path M1 q1 (p1@p2)" using assms(1) (*‹path M1 q1 p1›*) by auto moreover have "p_io (p1@p2) = (p_io p1 @ io)" using ‹p_io p2 = io› (*‹p_io p2 = io›*) by auto ultimately show "?thesis" (*goal: ‹p_io (p1::('a::type × 'b::type × 'c::type × 'a::type) list) @ (io::('b::type × 'c::type) list) ∈ LS (M1::('a::type, 'b::type, 'c::type) fsm) (q1::'a::type)›*) by (metis (mono_tags, lifting) language_intro (*‹path ?M ?q ?p ⟹ p_io ?p ∈ LS ?M ?q›*)) qed lemma observable_defined_inputs_diff_ob : assumes "observable M1" and "observable M2" and "path M1 q1 p1" and "path M2 q2 p2" and "p_io p1 = p_io p2" and "x ∈ defined_inputs M1 (target q1 p1)" and "x ∉ defined_inputs M2 (target q2 p2)" obtains y where "(p_io p1)@[(x,y)] ∈ LS M1 q1 - LS M2 q2" proof (-) (*goal: ‹(⋀y. p_io p1 @ [(x, y)] ∈ LS M1 q1 - LS M2 q2 ⟹ thesis) ⟹ thesis›*) obtain y where "[(x,y)] ∈ LS M1 (target q1 p1) - LS M2 (target q2 p2)" (*goal: ‹(⋀y. [(x, y)] ∈ LS M1 (target q1 p1) - LS M2 (target q2 p2) ⟹ thesis) ⟹ thesis›*) using defined_inputs_language_diff[OF assms ( 6 , 7 )] (*‹(⋀y. [(x, y)] ∈ LS M1 (target q1 p1) - LS M2 (target q2 p2) ⟹ ?thesis) ⟹ ?thesis›*) by blast then have "(p_io p1)@[(x,y)] ∈ LS M1 q1" using language_path_append[OF assms ( 3 )] (*‹?io ∈ LS M1 (target q1 p1) ⟹ p_io p1 @ ?io ∈ LS M1 q1›*) by blast moreover have "(p_io p1)@[(x,y)] ∉ LS M2 q2" by (metis (mono_tags, lifting) DiffD2 (*‹⟦?c ∈ ?A - ?B; ?c ∈ ?B⟧ ⟹ ?P›*) ‹[(x, y)] ∈ LS M1 (target q1 p1) - LS M2 (target q2 p2)› assms( (*‹observable M2›*) 2) assms( (*‹path M2 q2 p2›*) 4) assms( (*‹p_io p1 = p_io p2›*) 5) language_state_containment (*‹⟦path ?M ?q ?p; p_io ?p = ?io⟧ ⟹ ?io ∈ LS ?M ?q›*) observable_path_suffix (*‹⟦p_io ?p @ ?io ∈ LS ?M ?q; path ?M ?q ?p; observable ?M; ⋀p'. ⟦path ?M (target ?q ?p) p'; p_io p' = ?io⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*)) ultimately show "?thesis" (*goal: ‹thesis›*) using that[of y] (*‹p_io p1 @ [(x, y)] ∈ LS M1 q1 - LS M2 q2 ⟹ thesis›*) by blast qed lemma observable_defined_inputs_diff_language : assumes "observable M1" and "observable M2" and "path M1 q1 p1" and "path M2 q2 p2" and "p_io p1 = p_io p2" and "defined_inputs M1 (target q1 p1) ≠ defined_inputs M2 (target q2 p2)" shows "LS M1 q1 ≠ LS M2 q2" proof (-) (*goal: ‹LS M1 q1 ≠ LS M2 q2›*) obtain x where "(x ∈ defined_inputs M1 (target q1 p1) - defined_inputs M2 (target q2 p2)) ∨ (x ∈ defined_inputs M2 (target q2 p2) - defined_inputs M1 (target q1 p1))" (*goal: ‹(⋀x. x ∈ defined_inputs M1 (target q1 p1) - defined_inputs M2 (target q2 p2) ∨ x ∈ defined_inputs M2 (target q2 p2) - defined_inputs M1 (target q1 p1) ⟹ thesis) ⟹ thesis›*) using assms (*‹observable M1› ‹observable M2› ‹path M1 q1 p1› ‹path M2 q2 p2› ‹p_io (p1::('a::type × 'b::type × 'c::type × 'a::type) list) = p_io (p2::('d::type × 'b::type × 'c::type × 'd::type) list)› ‹defined_inputs (M1::('a::type, 'b::type, 'c::type) fsm) (target (q1::'a::type) (p1::('a::type × 'b::type × 'c::type × 'a::type) list)) ≠ defined_inputs (M2::('d::type, 'b::type, 'c::type) fsm) (target (q2::'d::type) (p2::('d::type × 'b::type × 'c::type × 'd::type) list))›*) by blast then consider "(x ∈ defined_inputs M1 (target q1 p1) - defined_inputs M2 (target q2 p2))" | "(x ∈ defined_inputs M2 (target q2 p2) - defined_inputs M1 (target q1 p1))" (*goal: ‹⟦(x::'b::type) ∈ defined_inputs (M1::('a::type, 'b::type, 'c::type) fsm) (target (q1::'a::type) (p1::('a::type × 'b::type × 'c::type × 'a::type) list)) - defined_inputs (M2::('d::type, 'b::type, 'c::type) fsm) (target (q2::'d::type) (p2::('d::type × 'b::type × 'c::type × 'd::type) list)) ⟹ thesis::bool; x ∈ defined_inputs M2 (target q2 p2) - defined_inputs M1 (target q1 p1) ⟹ thesis⟧ ⟹ thesis›*) by blast then show "?thesis" (*goal: ‹LS M1 q1 ≠ LS M2 q2›*) proof (cases) (*goals: 1. ‹x ∈ defined_inputs M1 (target q1 p1) - defined_inputs M2 (target q2 p2) ⟹ LS M1 q1 ≠ LS M2 q2› 2. ‹x ∈ defined_inputs M2 (target q2 p2) - defined_inputs M1 (target q1 p1) ⟹ LS M1 q1 ≠ LS M2 q2›*) case 1 (*‹x ∈ defined_inputs M1 (target q1 p1) - defined_inputs M2 (target q2 p2)›*) then show "?thesis" (*goal: ‹LS (M1::('a, 'b, 'c) fsm) (q1::'a) ≠ LS (M2::('d, 'b, 'c) fsm) (q2::'d)›*) using observable_defined_inputs_diff_ob[OF assms ( 1 - 5 ), of x] (*‹⟦(x::'b) ∈ defined_inputs (M1::('a, 'b, 'c) fsm) (target (q1::'a) (p1::('a × 'b × 'c × 'a) list)); x ∉ defined_inputs (M2::('d, 'b, 'c) fsm) (target (q2::'d) (p2::('d × 'b × 'c × 'd) list)); ⋀y::'c. p_io p1 @ [(x, y)] ∈ LS M1 q1 - LS M2 q2 ⟹ ?thesis::bool⟧ ⟹ ?thesis›*) by blast next (*goal: ‹x ∈ defined_inputs M2 (target q2 p2) - defined_inputs M1 (target q1 p1) ⟹ LS M1 q1 ≠ LS M2 q2›*) case 2 (*‹(x::'b::type) ∈ defined_inputs (M2::('d::type, 'b::type, 'c::type) fsm) (target (q2::'d::type) (p2::('d::type × 'b::type × 'c::type × 'd::type) list)) - defined_inputs (M1::('a::type, 'b::type, 'c::type) fsm) (target (q1::'a::type) (p1::('a::type × 'b::type × 'c::type × 'a::type) list))›*) then show "?thesis" (*goal: ‹LS M1 q1 ≠ LS M2 q2›*) using observable_defined_inputs_diff_ob[OF assms ( 2 , 1 , 4 , 3 ) assms ( 5 ) [ symmetric ], of x] (*‹⟦x ∈ defined_inputs M2 (target q2 p2); x ∉ defined_inputs M1 (target q1 p1); ⋀y. p_io p2 @ [(x, y)] ∈ LS M2 q2 - LS M1 q1 ⟹ ?thesis⟧ ⟹ ?thesis›*) by blast qed qed fun maximal_prefix_in_language :: "('a,'b,'c) fsm ⇒ 'a ⇒ ('b ×'c) list ⇒ ('b ×'c) list" where "maximal_prefix_in_language M q [] = []" | "maximal_prefix_in_language M q ((x,y)#io) = (case h_obs M q x y of None ⇒ [] | Some q' ⇒ (x,y)#maximal_prefix_in_language M q' io)" lemma maximal_prefix_in_language_properties : assumes "observable M" and "q ∈ states M" shows "maximal_prefix_in_language M q io ∈ LS M q" and "maximal_prefix_in_language M q io ∈ list.set (prefixes io)" proof (-) (*goals: 1. ‹maximal_prefix_in_language M q io ∈ LS M q› 2. ‹maximal_prefix_in_language M q io ∈ set (prefixes io)›*) have "maximal_prefix_in_language M q io ∈ LS M q ∧ maximal_prefix_in_language M q io ∈ list.set (prefixes io)" using assms(2) (*‹(q::'a) ∈ FSM.states (M::('a, 'b, 'c) fsm)›*) proof (induction io arbitrary: q) (*goals: 1. ‹⋀q. q ∈ FSM.states M ⟹ maximal_prefix_in_language M q [] ∈ LS M q ∧ maximal_prefix_in_language M q [] ∈ set (prefixes [])› 2. ‹⋀a io q. ⟦⋀q. q ∈ FSM.states M ⟹ maximal_prefix_in_language M q io ∈ LS M q ∧ maximal_prefix_in_language M q io ∈ set (prefixes io); q ∈ FSM.states M⟧ ⟹ maximal_prefix_in_language M q (a # io) ∈ LS M q ∧ maximal_prefix_in_language M q (a # io) ∈ set (prefixes (a # io))›*) case Nil (*‹q ∈ FSM.states M›*) then show "?case" (*goal: ‹maximal_prefix_in_language M q [] ∈ LS M q ∧ maximal_prefix_in_language M q [] ∈ set (prefixes [])›*) by auto next (*goal: ‹⋀a io q. ⟦⋀q. q ∈ FSM.states M ⟹ maximal_prefix_in_language M q io ∈ LS M q ∧ maximal_prefix_in_language M q io ∈ set (prefixes io); q ∈ FSM.states M⟧ ⟹ maximal_prefix_in_language M q (a # io) ∈ LS M q ∧ maximal_prefix_in_language M q (a # io) ∈ set (prefixes (a # io))›*) case (Cons xy io) (*‹?q ∈ FSM.states M ⟹ maximal_prefix_in_language M ?q io ∈ LS M ?q ∧ maximal_prefix_in_language M ?q io ∈ set (prefixes io)› ‹q ∈ FSM.states M›*) obtain x and y where "xy = (x,y)" (*goal: ‹(⋀x y. xy = (x, y) ⟹ thesis) ⟹ thesis›*) using prod.exhaust (*‹(⋀x1 x2. ?y = (x1, x2) ⟹ ?P) ⟹ ?P›*) by metis show "?case" (*goal: ‹maximal_prefix_in_language (M::('a::type, 'b::type, 'c::type) fsm) (q::'a::type) ((xy::'b::type × 'c::type) # (io::('b::type × 'c::type) list)) ∈ LS M q ∧ maximal_prefix_in_language M q (xy # io) ∈ set (prefixes (xy # io))›*) proof (cases "h_obs M q x y") (*goals: 1. ‹FSM.h_obs (M::('a, 'b, 'c) fsm) (q::'a) (x::'b) (y::'c) = None ⟹ maximal_prefix_in_language M q ((xy::'b × 'c) # (io::('b × 'c) list)) ∈ LS M q ∧ maximal_prefix_in_language M q (xy # io) ∈ set (prefixes (xy # io))› 2. ‹⋀a::'a. FSM.h_obs (M::('a, 'b, 'c) fsm) (q::'a) (x::'b) (y::'c) = Some a ⟹ maximal_prefix_in_language M q ((xy::'b × 'c) # (io::('b × 'c) list)) ∈ LS M q ∧ maximal_prefix_in_language M q (xy # io) ∈ set (prefixes (xy # io))›*) case None (*‹FSM.h_obs (M::('a::type, 'b::type, 'c::type) fsm) (q::'a::type) (x::'b::type) (y::'c::type) = None›*) then have "maximal_prefix_in_language M q (xy#io) = []" unfolding ‹xy = (x,y)› (*goal: ‹maximal_prefix_in_language M q ((x, y) # io) = []›*) by auto then show "?thesis" (*goal: ‹maximal_prefix_in_language M q (xy # io) ∈ LS M q ∧ maximal_prefix_in_language M q (xy # io) ∈ set (prefixes (xy # io))›*) by (metis (mono_tags, lifting) Cons.prems (*‹q ∈ FSM.states M›*) append_self_conv2 (*‹(?xs @ ?ys = ?ys) = (?xs = [])›*) from_FSM_language (*‹?q ∈ FSM.states ?M ⟹ L (from_FSM ?M ?q) = LS ?M ?q›*) language_contains_empty_sequence (*‹[] ∈ L ?M›*) mem_Collect_eq (*‹(?a ∈ Collect ?P) = ?P ?a›*) prefixes_set (*‹set (prefixes ?xs) = {xs'. ∃xs''. xs' @ xs'' = ?xs}›*)) next (*goal: ‹⋀a. FSM.h_obs M q x y = Some a ⟹ maximal_prefix_in_language M q (xy # io) ∈ LS M q ∧ maximal_prefix_in_language M q (xy # io) ∈ set (prefixes (xy # io))›*) case (Some q') (*‹FSM.h_obs M q x y = Some q'›*) then have "*": "maximal_prefix_in_language M q (xy#io) = (x,y)#maximal_prefix_in_language M q' io" unfolding ‹xy = (x,y)› (*goal: ‹maximal_prefix_in_language M q ((x, y) # io) = (x, y) # maximal_prefix_in_language M q' io›*) by auto have "q' ∈ states M" using h_obs_state[OF Some] (*‹(q'::'a::type) ∈ FSM.states (M::('a::type, 'b::type, 'c::type) fsm)›*) by auto then have "maximal_prefix_in_language M q' io ∈ LS M q'" and "maximal_prefix_in_language M q' io ∈ list.set (prefixes io)" using Cons.IH (*‹(?q::'a::type) ∈ FSM.states (M::('a::type, 'b::type, 'c::type) fsm) ⟹ maximal_prefix_in_language M ?q (io::('b::type × 'c::type) list) ∈ LS M ?q ∧ maximal_prefix_in_language M ?q io ∈ set (prefixes io)›*) apply - (*goals: 1. ‹⟦q' ∈ FSM.states M; ⋀q. q ∈ FSM.states M ⟹ maximal_prefix_in_language M q io ∈ LS M q ∧ maximal_prefix_in_language M q io ∈ set (prefixes io)⟧ ⟹ maximal_prefix_in_language M q' io ∈ LS M q'› 2. ‹⟦q' ∈ FSM.states M; ⋀q. q ∈ FSM.states M ⟹ maximal_prefix_in_language M q io ∈ LS M q ∧ maximal_prefix_in_language M q io ∈ set (prefixes io)⟧ ⟹ maximal_prefix_in_language M q' io ∈ set (prefixes io)› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . have "maximal_prefix_in_language M q (xy # io) ∈ LS M q" unfolding "*" (*goal: ‹(x, y) # maximal_prefix_in_language M q' io ∈ LS M q›*) using Some (*‹FSM.h_obs M q x y = Some q'›*) ‹maximal_prefix_in_language M q' io ∈ LS M q'› (*‹maximal_prefix_in_language M q' io ∈ LS M q'›*) by (meson assms( (*‹observable M›*) 1) h_obs_language_iff (*‹observable ?M ⟹ ((?x, ?y) # ?io ∈ LS ?M ?q) = (∃q'. FSM.h_obs ?M ?q ?x ?y = Some q' ∧ ?io ∈ LS ?M q')›*)) moreover have "maximal_prefix_in_language M q (xy # io) ∈ list.set (prefixes (xy # io))" unfolding "*" (*goal: ‹(x, y) # maximal_prefix_in_language M q' io ∈ set (prefixes (xy # io))›*) unfolding ‹xy = (x,y)› (*goal: ‹(x, y) # maximal_prefix_in_language M q' io ∈ set (prefixes ((x, y) # io))›*) using ‹maximal_prefix_in_language M q' io ∈ list.set (prefixes io)› (*‹maximal_prefix_in_language (M::('a, 'b, 'c) fsm) (q'::'a) (io::('b × 'c) list) ∈ set (prefixes io)›*) append_Cons (*‹((?x::?'a::type) # (?xs::?'a::type list)) @ (?ys::?'a::type list) = ?x # ?xs @ ?ys›*) unfolding prefixes_set (*goal: ‹(x, y) # maximal_prefix_in_language M q' io ∈ {xs'. ∃xs''. xs' @ xs'' = (x, y) # io}›*) by auto ultimately show "?thesis" (*goal: ‹maximal_prefix_in_language M q (xy # io) ∈ LS M q ∧ maximal_prefix_in_language M q (xy # io) ∈ set (prefixes (xy # io))›*) by blast qed qed then show "maximal_prefix_in_language M q io ∈ LS M q" and "maximal_prefix_in_language M q io ∈ list.set (prefixes io)" apply - (*goals: 1. ‹maximal_prefix_in_language M q io ∈ LS M q ∧ maximal_prefix_in_language M q io ∈ set (prefixes io) ⟹ maximal_prefix_in_language M q io ∈ LS M q› 2. ‹maximal_prefix_in_language M q io ∈ LS M q ∧ maximal_prefix_in_language M q io ∈ set (prefixes io) ⟹ maximal_prefix_in_language M q io ∈ set (prefixes io)› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . qed subsection ‹Further Reachability Formalisations› (* states that are reachable in at most k transitions *) fun reachable_k :: "('a,'b,'c) fsm ⇒ 'a ⇒ nat ⇒ 'a set" where "reachable_k M q n = {target q p | p . path M q p ∧ length p ≤ n}" lemma reachable_k_0_initial : "reachable_k M (initial M) 0 = {initial M}" by auto lemma reachable_k_states : "reachable_states M = reachable_k M (initial M) ( size M - 1)" proof (-) (*goal: ‹reachable_states M = reachable_k M (FSM.initial M) (FSM.size M - 1)›*) have "⋀q. q ∈ reachable_states M ⟹ q ∈ reachable_k M (initial M) ( size M - 1)" proof (-) (*goal: ‹⋀q::'a. q ∈ reachable_states (M::('a, 'b, 'c) fsm) ⟹ q ∈ reachable_k M (FSM.initial M) (FSM.size M - (1::nat))›*) fix q assume "q ∈ reachable_states M" (*‹(q::'a) ∈ reachable_states (M::('a, 'b, 'c) fsm)›*) then obtain p where "path M (initial M) p" and "target (initial M) p = q" (*goal: ‹(⋀p. ⟦path M (FSM.initial M) p; target (FSM.initial M) p = q⟧ ⟹ thesis) ⟹ thesis›*) unfolding reachable_states_def (*goal: ‹(⋀p. ⟦path M (FSM.initial M) p; target (FSM.initial M) p = q⟧ ⟹ thesis) ⟹ thesis›*) by blast then obtain p' where "path M (initial M) p'" and "target (initial M) p' = target (initial M) p" and "length p' < size M" (*goal: ‹(⋀p'. ⟦path M (FSM.initial M) p'; target (FSM.initial M) p' = target (FSM.initial M) p; length p' < FSM.size M⟧ ⟹ thesis) ⟹ thesis›*) by (metis acyclic_path_from_cyclic_path (*‹⟦path ?M ?q ?p; ¬ distinct (visited_states ?q ?p); ⋀p'. ⟦path ?M ?q p'; target ?q ?p = target ?q p'; distinct (visited_states ?q p')⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*) acyclic_path_length_limit (*‹⟦path ?M ?q ?p; distinct (visited_states ?q ?p)⟧ ⟹ length ?p < FSM.size ?M›*)) then show "q ∈ reachable_k M (initial M) ( size M - 1)" using ‹target (FSM.initial M) p = q› (*‹target (FSM.initial M) p = q›*) less_trans (*‹⟦?x < ?y; ?y < ?z⟧ ⟹ ?x < ?z›*) by auto qed moreover have "⋀x. x ∈ reachable_k M (initial M) ( size M - 1) ⟹ x ∈ reachable_states M" unfolding reachable_states_def reachable_k.simps (*goal: ‹⋀x. x ∈ {target (FSM.initial M) p |p. path M (FSM.initial M) p ∧ length p ≤ FSM.size M - 1} ⟹ x ∈ {target (FSM.initial M) p |p. path M (FSM.initial M) p}›*) by blast ultimately show "?thesis" (*goal: ‹reachable_states M = reachable_k M (FSM.initial M) (FSM.size M - 1)›*) by blast qed subsubsection ‹Induction Schemes› lemma acyclic_induction [consumes 1, case_names reachable_state]: assumes "acyclic M" and "⋀ q . q ∈ reachable_states M ⟹ (⋀ t . t ∈ transitions M ⟹ ((t_source t = q) ⟹ P (t_target t))) ⟹ P q" shows "∀ q ∈ reachable_states M . P q" proof (standard) (*goal: ‹⋀q. q ∈ reachable_states M ⟹ P q›*) fix q assume "q ∈ reachable_states M" (*‹(q::'a) ∈ reachable_states (M::('a, 'b, 'c) fsm)›*) let ?k = "Max (image length {p . path M q p})" have "finite {p . path M q p}" using acyclic_finite_paths_from_reachable_state[OF assms ( 1 )] (*‹⟦path M (FSM.initial M) ?p; target (FSM.initial M) ?p = ?q⟧ ⟹ finite {p. path M ?q p}›*) using ‹q ∈ reachable_states M› (*‹q ∈ reachable_states M›*) unfolding reachable_states_def (*goal: ‹finite {p. path M q p}›*) by force then have k_prop: "(∀ p . path M q p ⟶ length p ≤ ?k)" by auto moreover have "⋀ q k . q ∈ reachable_states M ⟹ (∀ p . path M q p ⟶ length p ≤ k) ⟹ P q" proof (-) (*goal: ‹⋀q k. ⟦q ∈ reachable_states M; ∀p. path M q p ⟶ length p ≤ k⟧ ⟹ P q›*) fix q and k assume "q ∈ reachable_states M" and "(∀ p . path M q p ⟶ length p ≤ k)" (*‹(q::'a) ∈ reachable_states (M::('a, 'b, 'c) fsm)› ‹∀p::('a × 'b × 'c × 'a) list. path (M::('a, 'b, 'c) fsm) (q::'a) p ⟶ length p ≤ (k::nat)›*) then show "P q" proof (induction k arbitrary: q) (*goals: 1. ‹⋀q::'a. ⟦q ∈ reachable_states (M::('a, 'b, 'c) fsm); ∀p::('a × 'b × 'c × 'a) list. path M q p ⟶ length p ≤ (0::nat)⟧ ⟹ (P::'a ⇒ bool) q› 2. ‹⋀(k::nat) q::'a. ⟦⋀q::'a. ⟦q ∈ reachable_states (M::('a, 'b, 'c) fsm); ∀p::('a × 'b × 'c × 'a) list. path M q p ⟶ length p ≤ k⟧ ⟹ (P::'a ⇒ bool) q; q ∈ reachable_states M; ∀p::('a × 'b × 'c × 'a) list. path M q p ⟶ length p ≤ Suc k⟧ ⟹ P q›*) case 0 (*‹(q::'a) ∈ reachable_states (M::('a, 'b, 'c) fsm)› ‹∀p. path M q p ⟶ length p ≤ 0›*) then have "{p . path M q p} = {[]}" using reachable_state_is_state[OF ‹q ∈ reachable_states M›] (*‹q ∈ FSM.states M›*) by blast then have "LS M q ⊆ {[]}" unfolding LS.simps (*goal: ‹{p_io p |p::('a × 'b × 'c × 'a) list. path (M::('a, 'b, 'c) fsm) (q::'a) p} ⊆ {[]}›*) by blast then have "deadlock_state M q" using deadlock_state_alt_def (*‹deadlock_state ?M ?q = (LS ?M ?q ⊆ {[]})›*) by metis then show "?case" (*goal: ‹P q›*) using assms(2)[OF ‹q ∈ reachable_states M›] (*‹(⋀t. ⟦t ∈ FSM.transitions M; t_source t = q⟧ ⟹ P (t_target t)) ⟹ P q›*) unfolding deadlock_state.simps (*goal: ‹P q›*) by blast next (*goal: ‹⋀k q. ⟦⋀q. ⟦q ∈ reachable_states M; ∀p. path M q p ⟶ length p ≤ k⟧ ⟹ P q; q ∈ reachable_states M; ∀p. path M q p ⟶ length p ≤ Suc k⟧ ⟹ P q›*) case (Suc k) (*‹⟦?q ∈ reachable_states M; ∀p. path M ?q p ⟶ length p ≤ k⟧ ⟹ P ?q› ‹q ∈ reachable_states M› ‹∀p. path M q p ⟶ length p ≤ Suc k›*) have "⋀ t . t ∈ transitions M ⟹ (t_source t = q) ⟹ P (t_target t)" proof (-) (*goal: ‹⋀t. ⟦t ∈ FSM.transitions M; t_source t = q⟧ ⟹ P (t_target t)›*) fix t assume "t ∈ transitions M" and "t_source t = q" (*‹(t::'a × 'b × 'c × 'a) ∈ FSM.transitions (M::('a, 'b, 'c) fsm)› ‹t_source (t::'a × 'b × 'c × 'a) = (q::'a)›*) then have "t_target t ∈ reachable_states M" using ‹q ∈ reachable_states M› (*‹q ∈ reachable_states M›*) using reachable_states_next (*‹⟦?q ∈ reachable_states ?M; ?t ∈ FSM.transitions ?M; t_source ?t = ?q⟧ ⟹ t_target ?t ∈ reachable_states ?M›*) by metis moreover have "∀p. path M (t_target t) p ⟶ length p ≤ k" using Suc.prems(2) (*‹∀p. path M q p ⟶ length p ≤ Suc k›*) ‹t ∈ transitions M› (*‹t ∈ FSM.transitions M›*) ‹t_source t = q› (*‹t_source t = q›*) by auto ultimately show "P (t_target t)" using Suc.IH (*‹⟦(?q::'a) ∈ reachable_states (M::('a, 'b, 'c) fsm); ∀p::('a × 'b × 'c × 'a) list. path M ?q p ⟶ length p ≤ (k::nat)⟧ ⟹ (P::'a ⇒ bool) ?q›*) unfolding reachable_states_def (*goal: ‹P (t_target t)›*) by blast qed then show "?case" (*goal: ‹P q›*) using assms(2)[OF Suc.prems ( 1 )] (*‹(⋀t. ⟦t ∈ FSM.transitions M; t_source t = q⟧ ⟹ P (t_target t)) ⟹ P q›*) by blast qed qed ultimately show "P q" using ‹q ∈ reachable_states M› (*‹(q::'a) ∈ reachable_states (M::('a, 'b, 'c) fsm)›*) by blast qed lemma reachable_states_induct [consumes 1, case_names init transition] : assumes "q ∈ reachable_states M" and "P (initial M)" and "⋀ t . t ∈ transitions M ⟹ t_source t ∈ reachable_states M ⟹ P (t_source t) ⟹ P (t_target t)" shows "P q" proof (-) (*goal: ‹P q›*) from assms(1) (*‹q ∈ reachable_states M›*) obtain p where "path M (initial M) p" and "target (initial M) p = q" (*goal: ‹(⋀p. ⟦path M (FSM.initial M) p; target (FSM.initial M) p = q⟧ ⟹ thesis) ⟹ thesis›*) unfolding reachable_states_def (*goal: ‹(⋀p::('a × 'b × 'c × 'a) list. ⟦path (M::('a, 'b, 'c) fsm) (FSM.initial M) p; target (FSM.initial M) p = (q::'a)⟧ ⟹ thesis::bool) ⟹ thesis›*) by auto then show "P q" proof (induction p arbitrary: q rule: rev_induct) (*goals: 1. ‹⋀q. ⟦path M (FSM.initial M) []; target (FSM.initial M) [] = q⟧ ⟹ P q› 2. ‹⋀x xs q. ⟦⋀q. ⟦path M (FSM.initial M) xs; target (FSM.initial M) xs = q⟧ ⟹ P q; path M (FSM.initial M) (xs @ [x]); target (FSM.initial M) (xs @ [x]) = q⟧ ⟹ P q›*) case Nil (*‹path M (FSM.initial M) []› ‹target (FSM.initial M) [] = q›*) then show "?case" (*goal: ‹P q›*) using assms(2) (*‹P (FSM.initial M)›*) by auto next (*goal: ‹⋀x xs q. ⟦⋀q. ⟦path M (FSM.initial M) xs; target (FSM.initial M) xs = q⟧ ⟹ P q; path M (FSM.initial M) (xs @ [x]); target (FSM.initial M) (xs @ [x]) = q⟧ ⟹ P q›*) case (snoc t p) (*‹⟦path M (FSM.initial M) p; target (FSM.initial M) p = ?q⟧ ⟹ P ?q› ‹path M (FSM.initial M) (p @ [t])› ‹target (FSM.initial M) (p @ [t]) = q›*) then have "target (initial M) p = t_source t" by auto then have "P (t_source t)" using snoc.IH (*‹⟦path M (FSM.initial M) p; target (FSM.initial M) p = ?q⟧ ⟹ P ?q›*) snoc.prems (*‹path (M::('a::type, 'b::type, 'c::type) fsm) (FSM.initial M) ((p::('a::type × 'b::type × 'c::type × 'a::type) list) @ [t::'a::type × 'b::type × 'c::type × 'a::type])› ‹target (FSM.initial M) (p @ [t]) = q›*) by auto moreover have "t ∈ transitions M" using snoc.prems (*‹path (M::('a, 'b, 'c) fsm) (FSM.initial M) ((p::('a × 'b × 'c × 'a) list) @ [t::'a × 'b × 'c × 'a])› ‹target (FSM.initial M) (p @ [t]) = q›*) by auto moreover have "t_source t ∈ reachable_states M" by (metis ‹target (FSM.initial M) p = t_source t› path_prefix (*‹path (?M::(?'a, ?'b, ?'c) fsm) (?q::?'a) ((?p1.0::(?'a × ?'b × ?'c × ?'a) list) @ (?p2.0::(?'a × ?'b × ?'c × ?'a) list)) ⟹ path ?M ?q ?p1.0›*) reachable_states_intro (*‹path (?M::(?'a, ?'b, ?'c) fsm) (FSM.initial ?M) (?p::(?'a × ?'b × ?'c × ?'a) list) ⟹ target (FSM.initial ?M) ?p ∈ reachable_states ?M›*) snoc.prems( (*‹path (M::('a, 'b, 'c) fsm) (FSM.initial M) ((p::('a × 'b × 'c × 'a) list) @ [t::'a × 'b × 'c × 'a])›*) 1)) moreover have "t_target t = q" using snoc.prems (*‹path M (FSM.initial M) (p @ [t])› ‹target (FSM.initial M) (p @ [t]) = q›*) by auto ultimately show "?case" (*goal: ‹(P::'a ⇒ bool) (q::'a)›*) using assms(3) (*‹⟦?t ∈ FSM.transitions M; t_source ?t ∈ reachable_states M; P (t_source ?t)⟧ ⟹ P (t_target ?t)›*) by blast qed qed lemma reachable_states_cases [consumes 1, case_names init transition] : assumes "q ∈ reachable_states M" and "P (initial M)" and "⋀ t . t ∈ transitions M ⟹ t_source t ∈ reachable_states M ⟹ P (t_target t)" shows "P q" by (metis assms( (*‹q ∈ reachable_states M›*) 1) assms( (*‹P (FSM.initial M)›*) 2) assms( (*‹⟦?t ∈ FSM.transitions M; t_source ?t ∈ reachable_states M⟧ ⟹ P (t_target ?t)›*) 3) reachable_states_induct (*‹⟦?q ∈ reachable_states ?M; ?P (FSM.initial ?M); ⋀t. ⟦t ∈ FSM.transitions ?M; t_source t ∈ reachable_states ?M; ?P (t_source t)⟧ ⟹ ?P (t_target t)⟧ ⟹ ?P ?q›*)) subsection ‹Further Path Enumeration Algorithms› fun paths_for_input' :: "('a ⇒ ('b × 'c × 'a) set) ⇒ 'b list ⇒ 'a ⇒ ('a,'b,'c) path ⇒ ('a,'b,'c) path set" where "paths_for_input' f [] q prev = {prev}" | "paths_for_input' f (x#xs) q prev = ⋃(image (λ(x',y',q') . paths_for_input' f xs q' (prev@[(q,x,y',q')])) (Set.filter (λ(x',y',q') . x' = x) (f q)))" lemma paths_for_input'_set : assumes "q ∈ states M" shows "paths_for_input' (h_from M) xs q prev = {prev@p | p . path M q p ∧ map fst (p_io p) = xs}" using assms (*‹q ∈ FSM.states M›*) proof (induction xs arbitrary: q prev) (*goals: 1. ‹⋀q prev. q ∈ FSM.states M ⟹ paths_for_input' (h_from M) [] q prev = {prev @ p |p. path M q p ∧ map fst (p_io p) = []}› 2. ‹⋀a xs q prev. ⟦⋀q prev. q ∈ FSM.states M ⟹ paths_for_input' (h_from M) xs q prev = {prev @ p |p. path M q p ∧ map fst (p_io p) = xs}; q ∈ FSM.states M⟧ ⟹ paths_for_input' (h_from M) (a # xs) q prev = {prev @ p |p. path M q p ∧ map fst (p_io p) = a # xs}›*) case Nil (*‹q ∈ FSM.states M›*) then show "?case" (*goal: ‹paths_for_input' (h_from M) [] q prev = {prev @ p |p. path M q p ∧ map fst (p_io p) = []}›*) by auto next (*goal: ‹⋀(a::'b::type) (xs::'b::type list) (q::'a::type) prev::('a::type × 'b::type × 'c::type × 'a::type) list. ⟦⋀(q::'a::type) prev::('a::type × 'b::type × 'c::type × 'a::type) list. q ∈ FSM.states (M::('a::type, 'b::type, 'c::type) fsm) ⟹ paths_for_input' (h_from M) xs q prev = {prev @ p |p::('a::type × 'b::type × 'c::type × 'a::type) list. path M q p ∧ map fst (p_io p) = xs}; q ∈ FSM.states M⟧ ⟹ paths_for_input' (h_from M) (a # xs) q prev = {prev @ p |p::('a::type × 'b::type × 'c::type × 'a::type) list. path M q p ∧ map fst (p_io p) = a # xs}›*) case (Cons x xs) (*‹?q ∈ FSM.states M ⟹ paths_for_input' (h_from M) xs ?q ?prev = {?prev @ p |p. path M ?q p ∧ map fst (p_io p) = xs}› ‹q ∈ FSM.states M›*) let ?UN = "⋃(image (λ(x',y',q') . paths_for_input' (h_from M) xs q' (prev@[(q,x,y',q')])) (Set.filter (λ(x',y',q') . x' = x) (h_from M q)))" have "?UN = {prev@p | p . path M q p ∧ map fst (p_io p) = x#xs}" proof (standard) (*goals: 1. ‹(⋃(x', y', q')∈Set.filter (λ(x', y', q'). x' = x) (h_from M q). paths_for_input' (h_from M) xs q' (prev @ [(q, x, y', q')])) ⊆ {prev @ p |p. path M q p ∧ map fst (p_io p) = x # xs}› 2. ‹{prev @ p |p. path M q p ∧ map fst (p_io p) = x # xs} ⊆ (⋃(x', y', q')∈Set.filter (λ(x', y', q'). x' = x) (h_from M q). paths_for_input' (h_from M) xs q' (prev @ [(q, x, y', q')]))›*) have "⋀ p . p ∈ ?UN ⟹ p ∈ {prev@p | p . path M q p ∧ map fst (p_io p) = x#xs}" proof (-) (*goal: ‹⋀p. p ∈ (⋃(x', y', q')∈Set.filter (λ(x', y', q'). x' = x) (h_from M q). paths_for_input' (h_from M) xs q' (prev @ [(q, x, y', q')])) ⟹ p ∈ {prev @ p |p. path M q p ∧ map fst (p_io p) = x # xs}›*) fix p assume "p ∈ ?UN" (*‹(p::('a × 'b × 'c × 'a) list) ∈ (⋃(x'::'b, y'::'c, q'::'a)∈Set.filter (λ(x'::'b, y'::'c, q'::'a). x' = x) (h_from M q). paths_for_input' (h_from (M::('a, 'b, 'c) fsm)) (xs::'b list) q' ((prev::('a × 'b × 'c × 'a) list) @ [(q::'a, x::'b, y', q')]))›*) then obtain y' and q' where "(x,y',q') ∈ (Set.filter (λ(x',y',q') . x' = x) (h_from M q))" and "p ∈ paths_for_input' (h_from M) xs q' (prev@[(q,x,y',q')])" (*goal: ‹(⋀y' q'. ⟦(x, y', q') ∈ Set.filter (λ(x', y', q'). x' = x) (h_from M q); p ∈ paths_for_input' (h_from M) xs q' (prev @ [(q, x, y', q')])⟧ ⟹ thesis) ⟹ thesis›*) by auto from ‹(x,y',q') ∈ (Set.filter (λ(x',y',q') . x' = x) (h_from M q))› (*‹(x, y', q') ∈ Set.filter (λ(x', y', q'). x' = x) (h_from M q)›*) have "q' ∈ states M" and "(q,x,y',q') ∈ transitions M" using fsm_transition_target (*‹?t ∈ FSM.transitions ?M ⟹ t_target ?t ∈ FSM.states ?M›*) unfolding h.simps (*goals: 1. ‹q' ∈ FSM.states M› 2. ‹(q, x, y', q') ∈ FSM.transitions M›*) by auto have "p ∈ {(prev @ [(q, x, y', q')]) @ p |p. path M q' p ∧ map fst (p_io p) = xs}" using ‹p ∈ paths_for_input' (h_from M) xs q' (prev@[(q,x,y',q')])› (*‹p ∈ paths_for_input' (h_from M) xs q' (prev @ [(q, x, y', q')])›*) unfolding Cons.IH[OF ‹q' ∈ states M›] (*goal: ‹p ∈ {(prev @ [(q, x, y', q')]) @ p |p. path M q' p ∧ map fst (p_io p) = xs}›*) by assumption moreover have "{(prev @ [(q, x, y', q')]) @ p |p. path M q' p ∧ map fst (p_io p) = xs} ⊆ {prev@p | p . path M q p ∧ map fst (p_io p) = x#xs}" using ‹(q,x,y',q') ∈ transitions M› (*‹(q, x, y', q') ∈ FSM.transitions M›*) using cons (*‹⟦(?t::?'state::type × ?'input::type × ?'output::type × ?'state::type) ∈ FSM.transitions (?M::(?'state::type, ?'input::type, ?'output::type) fsm); path ?M (t_target ?t) (?ts::(?'state::type × ?'input::type × ?'output::type × ?'state::type) list)⟧ ⟹ path ?M (t_source ?t) (?t # ?ts)›*) by force ultimately show "p ∈ {prev@p | p . path M q p ∧ map fst (p_io p) = x#xs}" by blast qed then show "?UN ⊆ {prev@p | p . path M q p ∧ map fst (p_io p) = x#xs}" by blast have "⋀ p . p ∈ {prev@p | p . path M q p ∧ map fst (p_io p) = x#xs} ⟹ p ∈ ?UN" proof (-) (*goal: ‹⋀p. p ∈ {prev @ p |p. path M q p ∧ map fst (p_io p) = x # xs} ⟹ p ∈ (⋃(x', y', q')∈Set.filter (λ(x', y', q'). x' = x) (h_from M q). paths_for_input' (h_from M) xs q' (prev @ [(q, x, y', q')]))›*) fix pp assume "pp ∈ {prev@p | p . path M q p ∧ map fst (p_io p) = x#xs}" (*‹(pp::('a × 'b × 'c × 'a) list) ∈ {(prev::('a × 'b × 'c × 'a) list) @ p |p::('a × 'b × 'c × 'a) list. path (M::('a, 'b, 'c) fsm) (q::'a) p ∧ map fst (p_io p) = (x::'b) # (xs::'b list)}›*) then obtain p where "pp = prev@p" and "path M q p" and "map fst (p_io p) = x#xs" (*goal: ‹(⋀p. ⟦pp = prev @ p; path M q p; map fst (p_io p) = x # xs⟧ ⟹ thesis) ⟹ thesis›*) by fastforce then obtain t and p' where "p = t#p'" and "path M q (t#p')" and "map fst (p_io (t#p')) = x#xs" and "map fst (p_io p') = xs" (*goal: ‹(⋀t p'. ⟦p = t # p'; path M q (t # p'); map fst (p_io (t # p')) = x # xs; map fst (p_io p') = xs⟧ ⟹ thesis) ⟹ thesis›*) by (metis (no_types, lifting) map_eq_Cons_D (*‹map ?f ?xs = ?y # ?ys ⟹ ∃z zs. ?xs = z # zs ∧ ?f z = ?y ∧ map ?f zs = ?ys›*)) then have "path M (t_target t) p'" and "t_source t = q" and "t_input t = x" and "t_target t ∈ states M" and "t ∈ transitions M" apply - (*goals: 1. ‹⟦p = t # p'; path M q (t # p'); map fst (p_io (t # p')) = x # xs; map fst (p_io p') = xs⟧ ⟹ path M (t_target t) p'› 2. ‹⟦p = t # p'; path M q (t # p'); map fst (p_io (t # p')) = x # xs; map fst (p_io p') = xs⟧ ⟹ t_source t = q› 3. ‹⟦p = t # p'; path M q (t # p'); map fst (p_io (t # p')) = x # xs; map fst (p_io p') = xs⟧ ⟹ t_input t = x› 4. ‹⟦p = t # p'; path M q (t # p'); map fst (p_io (t # p')) = x # xs; map fst (p_io p') = xs⟧ ⟹ t_target t ∈ FSM.states M› 5. ‹⟦p = t # p'; path M q (t # p'); map fst (p_io (t # p')) = x # xs; map fst (p_io p') = xs⟧ ⟹ t ∈ FSM.transitions M› 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 "(x,t_output t,t_target t) ∈ (Set.filter (λ(x',y',q') . x' = x) (h_from M q))" using ‹t ∈ transitions M› (*‹t ∈ FSM.transitions M›*) ‹t_input t = x› (*‹t_input (t::'a × 'b × 'c × 'a) = (x::'b)›*) ‹t_source t = q› (*‹t_source t = q›*) unfolding h.simps (*goal: ‹(x, t_output t, t_target t) ∈ Set.filter (λ(x', y', q'). x' = x) (h_from M q)›*) by auto moreover have "(prev@p) ∈ paths_for_input' (h_from M) xs (t_target t) (prev@[(q,x,t_output t,t_target t)])" using Cons.IH[OF ‹t_target t ∈ states M›, of "prev@[(q, x, t_output t, t_target t)]"] (*‹paths_for_input' (h_from M) xs (t_target t) (prev @ [(q, x, t_output t, t_target t)]) = {(prev @ [(q, x, t_output t, t_target t)]) @ p |p. path M (t_target t) p ∧ map fst (p_io p) = xs}›*) using ‹⋀thesis. (⋀t p'. ⟦p = t # p'; path M q (t # p'); map fst (p_io (t # p')) = x # xs; map fst (p_io p') = xs⟧ ⟹ thesis) ⟹ thesis› (*‹(⋀t p'. ⟦p = t # p'; path M q (t # p'); map fst (p_io (t # p')) = x # xs; map fst (p_io p') = xs⟧ ⟹ ?thesis) ⟹ ?thesis›*) ‹p = t # p'› (*‹p = t # p'›*) ‹paths_for_input' (h_from M) xs (t_target t) (prev @ [(q, x, t_output t, t_target t)]) = {(prev @ [(q, x, t_output t, t_target t)]) @ p |p. path M (t_target t) p ∧ map fst (p_io p) = xs}› (*‹paths_for_input' (h_from M) xs (t_target t) (prev @ [(q, x, t_output t, t_target t)]) = {(prev @ [(q, x, t_output t, t_target t)]) @ p |p. path M (t_target t) p ∧ map fst (p_io p) = xs}›*) ‹t_input t = x› (*‹t_input t = x›*) ‹t_source t = q› (*‹t_source t = q›*) by fastforce ultimately show "pp ∈ ?UN" unfolding ‹pp = prev@p› (*goal: ‹prev @ p ∈ (⋃(x', y', q')∈Set.filter (λ(x', y', q'). x' = x) (h_from M q). paths_for_input' (h_from M) xs q' (prev @ [(q, x, y', q')]))›*) by blast qed then show "{prev@p | p . path M q p ∧ map fst (p_io p) = x#xs} ⊆ ?UN" by (meson subsetI (*‹(⋀x. x ∈ ?A ⟹ x ∈ ?B) ⟹ ?A ⊆ ?B›*)) qed then show "?case" (*goal: ‹paths_for_input' (h_from M) (x # xs) q prev = {prev @ p |p. path M q p ∧ map fst (p_io p) = x # xs}›*) by (metis paths_for_input'.simps( (*‹paths_for_input' (?f::?'a ⇒ (?'b × ?'c × ?'a) set) ((?x::?'b) # (?xs::?'b list)) (?q::?'a) (?prev::(?'a × ?'b × ?'c × ?'a) list) = (⋃(x'::?'b, y'::?'c, q'::?'a)∈Set.filter (λ(x'::?'b, y'::?'c, q'::?'a). x' = ?x) (?f ?q). paths_for_input' ?f ?xs q' (?prev @ [(?q, ?x, y', q')]))›*) 2)) qed definition paths_for_input :: "('a,'b,'c) fsm ⇒ 'a ⇒ 'b list ⇒ ('a,'b,'c) path set" where "paths_for_input M q xs = {p . path M q p ∧ map fst (p_io p) = xs}" lemma paths_for_input_set_code[code] : "paths_for_input M q xs = (if q ∈ states M then paths_for_input' (h_from M) xs q [] else {})" using paths_for_input'_set[of q M xs "[]"] (*‹q ∈ FSM.states M ⟹ paths_for_input' (h_from M) xs q [] = {[] @ p |p. path M q p ∧ map fst (p_io p) = xs}›*) unfolding paths_for_input_def (*goal: ‹{p::('a::type × 'b::type × 'c::type × 'a::type) list. path (M::('a::type, 'b::type, 'c::type) fsm) (q::'a::type) p ∧ map fst (p_io p) = (xs::'b::type list)} = (if q ∈ FSM.states M then paths_for_input' (h_from M) xs q [] else {})›*) apply ((cases "q ∈ states M")[1]) (*goals: 1. ‹⟦q ∈ FSM.states M ⟹ paths_for_input' (h_from M) xs q [] = {[] @ p |p. path M q p ∧ map fst (p_io p) = xs}; q ∈ FSM.states M⟧ ⟹ {p. path M q p ∧ map fst (p_io p) = xs} = (if q ∈ FSM.states M then paths_for_input' (h_from M) xs q [] else {})› 2. ‹⟦q ∈ FSM.states M ⟹ paths_for_input' (h_from M) xs q [] = {[] @ p |p. path M q p ∧ map fst (p_io p) = xs}; q ∉ FSM.states M⟧ ⟹ {p. path M q p ∧ map fst (p_io p) = xs} = (if q ∈ FSM.states M then paths_for_input' (h_from M) xs q [] else {})› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*goal: ‹⟦q ∈ FSM.states M ⟹ paths_for_input' (h_from M) xs q [] = {[] @ p |p. path M q p ∧ map fst (p_io p) = xs}; q ∉ FSM.states M⟧ ⟹ {p. path M q p ∧ map fst (p_io p) = xs} = (if q ∈ FSM.states M then paths_for_input' (h_from M) xs q [] else {})›*) apply (simp add: path_begin_state (*‹path ?M ?q ?p ⟹ ?q ∈ FSM.states ?M›*)) (*proven 2 subgoals*) . fun paths_up_to_length_or_condition_with_witness' :: "('a ⇒ ('b × 'c × 'a) set) ⇒ (('a,'b,'c) path ⇒ 'd option) ⇒ ('a,'b,'c) path ⇒ nat ⇒ 'a ⇒ (('a,'b,'c) path × 'd) set" where "paths_up_to_length_or_condition_with_witness' f P prev 0 q = (case P prev of Some w ⇒ {(prev,w)} | None ⇒ {})" | "paths_up_to_length_or_condition_with_witness' f P prev (Suc k) q = (case P prev of Some w ⇒ {(prev,w)} | None ⇒ (⋃(image (λ(x,y,q') . paths_up_to_length_or_condition_with_witness' f P (prev@[(q,x,y,q')]) k q') (f q))))" lemma paths_up_to_length_or_condition_with_witness'_set : assumes "q ∈ states M" shows "paths_up_to_length_or_condition_with_witness' (h_from M) P prev k q = {(prev@p,x) | p x . path M q p ∧ length p ≤ k ∧ P (prev@p) = Some x ∧ (∀ p' p'' . (p = p'@p'' ∧ p'' ≠ []) ⟶ P (prev@p') = None)}" using assms (*‹q ∈ FSM.states M›*) proof (induction k arbitrary: q prev) (*goals: 1. ‹⋀q prev. q ∈ FSM.states M ⟹ paths_up_to_length_or_condition_with_witness' (h_from M) P prev 0 q = {(prev @ p, x) |p x. path M q p ∧ length p ≤ 0 ∧ P (prev @ p) = Some x ∧ (∀p' p''. p = p' @ p'' ∧ p'' ≠ [] ⟶ P (prev @ p') = None)}› 2. ‹⋀k q prev. ⟦⋀q prev. q ∈ FSM.states M ⟹ paths_up_to_length_or_condition_with_witness' (h_from M) P prev k q = {(prev @ p, x) |p x. path M q p ∧ length p ≤ k ∧ P (prev @ p) = Some x ∧ (∀p' p''. p = p' @ p'' ∧ p'' ≠ [] ⟶ P (prev @ p') = None)}; q ∈ FSM.states M⟧ ⟹ paths_up_to_length_or_condition_with_witness' (h_from M) P prev (Suc k) q = {(prev @ p, x) |p x. path M q p ∧ length p ≤ Suc k ∧ P (prev @ p) = Some x ∧ (∀p' p''. p = p' @ p'' ∧ p'' ≠ [] ⟶ P (prev @ p') = None)}›*) case 0 (*‹q ∈ FSM.states M›*) then show "?case" (*goal: ‹paths_up_to_length_or_condition_with_witness' (h_from M) P prev 0 q = {(prev @ p, x) |p x. path M q p ∧ length p ≤ 0 ∧ P (prev @ p) = Some x ∧ (∀p' p''. p = p' @ p'' ∧ p'' ≠ [] ⟶ P (prev @ p') = None)}›*) proof (cases "P prev") (*goals: 1. ‹⟦q ∈ FSM.states M; P prev = None⟧ ⟹ paths_up_to_length_or_condition_with_witness' (h_from M) P prev 0 q = {(prev @ p, x) |p x. path M q p ∧ length p ≤ 0 ∧ P (prev @ p) = Some x ∧ (∀p' p''. p = p' @ p'' ∧ p'' ≠ [] ⟶ P (prev @ p') = None)}› 2. ‹⋀a. ⟦q ∈ FSM.states M; P prev = Some a⟧ ⟹ paths_up_to_length_or_condition_with_witness' (h_from M) P prev 0 q = {(prev @ p, x) |p x. path M q p ∧ length p ≤ 0 ∧ P (prev @ p) = Some x ∧ (∀p' p''. p = p' @ p'' ∧ p'' ≠ [] ⟶ P (prev @ p') = None)}›*) case None (*‹(P::('a × 'b × 'c × 'a) list ⇒ 'd option) (prev::('a × 'b × 'c × 'a) list) = None›*) then show "?thesis" (*goal: ‹paths_up_to_length_or_condition_with_witness' (h_from M) P prev 0 q = {(prev @ p, x) |p x. path M q p ∧ length p ≤ 0 ∧ P (prev @ p) = Some x ∧ (∀p' p''. p = p' @ p'' ∧ p'' ≠ [] ⟶ P (prev @ p') = None)}›*) by auto next (*goal: ‹⋀a. ⟦q ∈ FSM.states M; P prev = Some a⟧ ⟹ paths_up_to_length_or_condition_with_witness' (h_from M) P prev 0 q = {(prev @ p, x) |p x. path M q p ∧ length p ≤ 0 ∧ P (prev @ p) = Some x ∧ (∀p' p''. p = p' @ p'' ∧ p'' ≠ [] ⟶ P (prev @ p') = None)}›*) case (Some w) (*‹P prev = Some w›*) then show "?thesis" (*goal: ‹paths_up_to_length_or_condition_with_witness' (h_from M) P prev 0 q = {(prev @ p, x) |p x. path M q p ∧ length p ≤ 0 ∧ P (prev @ p) = Some x ∧ (∀p' p''. p = p' @ p'' ∧ p'' ≠ [] ⟶ P (prev @ p') = None)}›*) by (simp add: "0.prems" (*‹q ∈ FSM.states M›*) nil (*‹?q ∈ FSM.states ?M ⟹ path ?M ?q []›*)) qed next (*goal: ‹⋀k q prev. ⟦⋀q prev. q ∈ FSM.states M ⟹ paths_up_to_length_or_condition_with_witness' (h_from M) P prev k q = {(prev @ p, x) |p x. path M q p ∧ length p ≤ k ∧ P (prev @ p) = Some x ∧ (∀p' p''. p = p' @ p'' ∧ p'' ≠ [] ⟶ P (prev @ p') = None)}; q ∈ FSM.states M⟧ ⟹ paths_up_to_length_or_condition_with_witness' (h_from M) P prev (Suc k) q = {(prev @ p, x) |p x. path M q p ∧ length p ≤ Suc k ∧ P (prev @ p) = Some x ∧ (∀p' p''. p = p' @ p'' ∧ p'' ≠ [] ⟶ P (prev @ p') = None)}›*) case (Suc k) (*‹?q ∈ FSM.states M ⟹ paths_up_to_length_or_condition_with_witness' (h_from M) P ?prev k ?q = {(?prev @ p, x) |p x. path M ?q p ∧ length p ≤ k ∧ P (?prev @ p) = Some x ∧ (∀p' p''. p = p' @ p'' ∧ p'' ≠ [] ⟶ P (?prev @ p') = None)}› ‹q ∈ FSM.states M›*) then show "?case" (*goal: ‹paths_up_to_length_or_condition_with_witness' (h_from M) P prev (Suc k) q = {(prev @ p, x) |p x. path M q p ∧ length p ≤ Suc k ∧ P (prev @ p) = Some x ∧ (∀p' p''. p = p' @ p'' ∧ p'' ≠ [] ⟶ P (prev @ p') = None)}›*) proof (cases "P prev") (*goals: 1. ‹⟦⋀q prev. q ∈ FSM.states M ⟹ paths_up_to_length_or_condition_with_witness' (h_from M) P prev k q = {(prev @ p, x) |p x. path M q p ∧ length p ≤ k ∧ P (prev @ p) = Some x ∧ (∀p' p''. p = p' @ p'' ∧ p'' ≠ [] ⟶ P (prev @ p') = None)}; q ∈ FSM.states M; P prev = None⟧ ⟹ paths_up_to_length_or_condition_with_witness' (h_from M) P prev (Suc k) q = {(prev @ p, x) |p x. path M q p ∧ length p ≤ Suc k ∧ P (prev @ p) = Some x ∧ (∀p' p''. p = p' @ p'' ∧ p'' ≠ [] ⟶ P (prev @ p') = None)}› 2. ‹⋀a. ⟦⋀q prev. q ∈ FSM.states M ⟹ paths_up_to_length_or_condition_with_witness' (h_from M) P prev k q = {(prev @ p, x) |p x. path M q p ∧ length p ≤ k ∧ P (prev @ p) = Some x ∧ (∀p' p''. p = p' @ p'' ∧ p'' ≠ [] ⟶ P (prev @ p') = None)}; q ∈ FSM.states M; P prev = Some a⟧ ⟹ paths_up_to_length_or_condition_with_witness' (h_from M) P prev (Suc k) q = {(prev @ p, x) |p x. path M q p ∧ length p ≤ Suc k ∧ P (prev @ p) = Some x ∧ (∀p' p''. p = p' @ p'' ∧ p'' ≠ [] ⟶ P (prev @ p') = None)}›*) case (Some w) (*‹P prev = Some w›*) then have "(prev,w) ∈ {(prev@p,x) | p x . path M q p ∧ length p ≤ Suc k ∧ P (prev@p) = Some x ∧ (∀ p' p'' . (p = p'@p'' ∧ p'' ≠ []) ⟶ P (prev@p') = None)}" by (simp add: Suc.prems (*‹(q::'a) ∈ FSM.states (M::('a, 'b, 'c) fsm)›*) nil (*‹(?q::?'state) ∈ FSM.states (?M::(?'state, ?'input, ?'output) fsm) ⟹ path ?M ?q []›*)) then have "{(prev@p,x) | p x . path M q p ∧ length p ≤ Suc k ∧ P (prev@p) = Some x ∧ (∀ p' p'' . (p = p'@p'' ∧ p'' ≠ []) ⟶ P (prev@p') = None)} = {(prev,w)}" using Some (*‹P prev = Some w›*) by fastforce then show "?thesis" (*goal: ‹paths_up_to_length_or_condition_with_witness' (h_from M) P prev (Suc k) q = {(prev @ p, x) |p x. path M q p ∧ length p ≤ Suc k ∧ P (prev @ p) = Some x ∧ (∀p' p''. p = p' @ p'' ∧ p'' ≠ [] ⟶ P (prev @ p') = None)}›*) using Some (*‹P prev = Some w›*) by auto next (*goal: ‹⟦⋀q prev. q ∈ FSM.states M ⟹ paths_up_to_length_or_condition_with_witness' (h_from M) P prev k q = {(prev @ p, x) |p x. path M q p ∧ length p ≤ k ∧ P (prev @ p) = Some x ∧ (∀p' p''. p = p' @ p'' ∧ p'' ≠ [] ⟶ P (prev @ p') = None)}; q ∈ FSM.states M; P prev = None⟧ ⟹ paths_up_to_length_or_condition_with_witness' (h_from M) P prev (Suc k) q = {(prev @ p, x) |p x. path M q p ∧ length p ≤ Suc k ∧ P (prev @ p) = Some x ∧ (∀p' p''. p = p' @ p'' ∧ p'' ≠ [] ⟶ P (prev @ p') = None)}›*) case None (*‹(P::('a::type × 'b::type × 'c::type × 'a::type) list ⇒ 'd::type option) (prev::('a::type × 'b::type × 'c::type × 'a::type) list) = None›*) have "(⋃(image (λ(x,y,q') . paths_up_to_length_or_condition_with_witness' (h_from M) P (prev@[(q,x,y,q')]) k q') (h_from M q))) = {(prev@p,x) | p x . path M q p ∧ length p ≤ Suc k ∧ P (prev@p) = Some x ∧ (∀ p' p'' . (p = p'@p'' ∧ p'' ≠ []) ⟶ P (prev@p') = None)}" (is "?UN = ?PX") proof (-) (*goal: ‹(⋃(x, y, q')∈h_from M q. paths_up_to_length_or_condition_with_witness' (h_from M) P (prev @ [(q, x, y, q')]) k q') = {(prev @ p, x) |p x. path M q p ∧ length p ≤ Suc k ∧ P (prev @ p) = Some x ∧ (∀p' p''. p = p' @ p'' ∧ p'' ≠ [] ⟶ P (prev @ p') = None)}›*) have "*": "⋀ pp . pp ∈ ?UN ⟹ pp ∈ ?PX" proof (-) (*goal: ‹⋀pp::('a::type × 'b::type × 'c::type × 'a::type) list × 'd::type. pp ∈ (⋃(x::'b::type, y::'c::type, q'::'a::type)∈h_from M q. paths_up_to_length_or_condition_with_witness' (h_from (M::('a::type, 'b::type, 'c::type) fsm)) (P::('a::type × 'b::type × 'c::type × 'a::type) list ⇒ 'd::type option) ((prev::('a::type × 'b::type × 'c::type × 'a::type) list) @ [(q::'a::type, x, y, q')]) (k::nat) q') ⟹ pp ∈ {(prev @ p, x) |(p::('a::type × 'b::type × 'c::type × 'a::type) list) x::'d::type. path M q p ∧ length p ≤ Suc k ∧ P (prev @ p) = Some x ∧ (∀(p'::('a::type × 'b::type × 'c::type × 'a::type) list) p''::('a::type × 'b::type × 'c::type × 'a::type) list. p = p' @ p'' ∧ p'' ≠ [] ⟶ P (prev @ p') = None)}›*) fix pp assume "pp ∈ ?UN" (*‹(pp::('a × 'b × 'c × 'a) list × 'd) ∈ (⋃(x::'b, y::'c, q'::'a)∈h_from M q. paths_up_to_length_or_condition_with_witness' (h_from (M::('a, 'b, 'c) fsm)) (P::('a × 'b × 'c × 'a) list ⇒ 'd option) ((prev::('a × 'b × 'c × 'a) list) @ [(q::'a, x, y, q')]) (k::nat) q')›*) then obtain x and y and q' where "(x,y,q') ∈ h_from M q" and "pp ∈ paths_up_to_length_or_condition_with_witness' (h_from M) P (prev@[(q,x,y,q')]) k q'" (*goal: ‹(⋀x y q'. ⟦(x, y, q') ∈ h_from M q; pp ∈ paths_up_to_length_or_condition_with_witness' (h_from M) P (prev @ [(q, x, y, q')]) k q'⟧ ⟹ thesis) ⟹ thesis›*) by blast then have "(q,x,y,q') ∈ transitions M" by auto then have "q' ∈ states M" using fsm_transition_target (*‹?t ∈ FSM.transitions ?M ⟹ t_target ?t ∈ FSM.states ?M›*) by auto obtain p and w where "pp = ((prev@[(q,x,y,q')])@p,w)" and "path M q' p" and "length p ≤ k" and "P ((prev @ [(q, x, y, q')]) @ p) = Some w" and "⋀ p' p''. p = p' @ p'' ⟹ p'' ≠ [] ⟹ P ((prev @ [(q, x, y, q')]) @ p') = None" (*goal: ‹(⋀(p::('a × 'b × 'c × 'a) list) w::'d. ⟦(pp::('a × 'b × 'c × 'a) list × 'd) = (((prev::('a × 'b × 'c × 'a) list) @ [(q::'a, x::'b, y::'c, q'::'a)]) @ p, w); path (M::('a, 'b, 'c) fsm) q' p; length p ≤ (k::nat); (P::('a × 'b × 'c × 'a) list ⇒ 'd option) ((prev @ [(q, x, y, q')]) @ p) = Some w; ⋀(p'::('a × 'b × 'c × 'a) list) p''::('a × 'b × 'c × 'a) list. ⟦p = p' @ p''; p'' ≠ []⟧ ⟹ P ((prev @ [(q, x, y, q')]) @ p') = None⟧ ⟹ thesis::bool) ⟹ thesis›*) using ‹pp ∈ paths_up_to_length_or_condition_with_witness' (h_from M) P (prev@[(q,x,y,q')]) k q'› (*‹pp ∈ paths_up_to_length_or_condition_with_witness' (h_from M) P (prev @ [(q, x, y, q')]) k q'›*) unfolding Suc.IH[OF ‹q' ∈ states M›, of "prev@[(q,x,y,q')]"] (*goal: ‹(⋀p w. ⟦pp = ((prev @ [(q, x, y, q')]) @ p, w); path M q' p; length p ≤ k; P ((prev @ [(q, x, y, q')]) @ p) = Some w; ⋀p' p''. ⟦p = p' @ p''; p'' ≠ []⟧ ⟹ P ((prev @ [(q, x, y, q')]) @ p') = None⟧ ⟹ thesis) ⟹ thesis›*) by blast have "path M q ((q,x,y,q')#p)" using ‹path M q' p› (*‹path M q' p›*) ‹(q,x,y,q') ∈ transitions M› (*‹(q, x, y, q') ∈ FSM.transitions M›*) by (simp add: path_prepend_t (*‹⟦path ?M ?q' ?p; (?q, ?x, ?y, ?q') ∈ FSM.transitions ?M⟧ ⟹ path ?M ?q ((?q, ?x, ?y, ?q') # ?p)›*)) moreover have "length ((q,x,y,q')#p) ≤ Suc k" using ‹length p ≤ k› (*‹length (p::('a::type × 'b::type × 'c::type × 'a::type) list) ≤ (k::nat)›*) by auto moreover have "P (prev @ ([(q, x, y, q')] @ p)) = Some w" using ‹P ((prev @ [(q, x, y, q')]) @ p) = Some w› (*‹P ((prev @ [(q, x, y, q')]) @ p) = Some w›*) by auto moreover have "⋀ p' p''. ((q,x,y,q')#p) = p' @ p'' ⟹ p'' ≠ [] ⟹ P (prev @ p') = None" using ‹⋀ p' p''. p = p' @ p'' ⟹ p'' ≠ [] ⟹ P ((prev @ [(q, x, y, q')]) @ p') = None› (*‹⟦p = ?p' @ ?p''; ?p'' ≠ []⟧ ⟹ P ((prev @ [(q, x, y, q')]) @ ?p') = None›*) using None (*‹P prev = None›*) by (metis (no_types, opaque_lifting) append.simps( (*‹[] @ ?ys = ?ys›*) 1) append_Cons (*‹(?x # ?xs) @ ?ys = ?x # ?xs @ ?ys›*) append_Nil2 (*‹?xs @ [] = ?xs›*) append_assoc (*‹(?xs @ ?ys) @ ?zs = ?xs @ ?ys @ ?zs›*) list.inject (*‹(?x21.0 # ?x22.0 = ?y21.0 # ?y22.0) = (?x21.0 = ?y21.0 ∧ ?x22.0 = ?y22.0)›*) neq_Nil_conv (*‹(?xs ≠ []) = (∃y ys. ?xs = y # ys)›*)) ultimately show "pp ∈ ?PX" unfolding ‹pp = ((prev@[(q,x,y,q')])@p,w)› (*goal: ‹((prev @ [(q, x, y, q')]) @ p, w) ∈ {(prev @ p, x) |p x. path M q p ∧ length p ≤ Suc k ∧ P (prev @ p) = Some x ∧ (∀p' p''. p = p' @ p'' ∧ p'' ≠ [] ⟶ P (prev @ p') = None)}›*) by auto qed have "**": "⋀ pp . pp ∈ ?PX ⟹ pp ∈ ?UN" proof (-) (*goal: ‹⋀pp::('a × 'b × 'c × 'a) list × 'd. pp ∈ {((prev::('a × 'b × 'c × 'a) list) @ p, x) |(p::('a × 'b × 'c × 'a) list) x::'d. path (M::('a, 'b, 'c) fsm) (q::'a) p ∧ length p ≤ Suc (k::nat) ∧ (P::('a × 'b × 'c × 'a) list ⇒ 'd option) (prev @ p) = Some x ∧ (∀(p'::('a × 'b × 'c × 'a) list) p''::('a × 'b × 'c × 'a) list. p = p' @ p'' ∧ p'' ≠ [] ⟶ P (prev @ p') = None)} ⟹ pp ∈ (⋃(x::'b, y::'c, q'::'a)∈h_from M q. paths_up_to_length_or_condition_with_witness' (h_from M) P (prev @ [(q, x, y, q')]) k q')›*) fix pp assume "pp ∈ ?PX" (*‹(pp::('a × 'b × 'c × 'a) list × 'd) ∈ {((prev::('a × 'b × 'c × 'a) list) @ p, x) |(p::('a × 'b × 'c × 'a) list) x::'d. path (M::('a, 'b, 'c) fsm) (q::'a) p ∧ length p ≤ Suc (k::nat) ∧ (P::('a × 'b × 'c × 'a) list ⇒ 'd option) (prev @ p) = Some x ∧ (∀(p'::('a × 'b × 'c × 'a) list) p''::('a × 'b × 'c × 'a) list. p = p' @ p'' ∧ p'' ≠ [] ⟶ P (prev @ p') = None)}›*) then obtain p' and w where "pp = (prev @ p', w)" and "path M q p'" and "length p' ≤ Suc k" and "P (prev @ p') = Some w" and "⋀ p' p''. p' = p' @ p'' ⟹ p'' ≠ [] ⟹ P (prev @ p') = None" (*goal: ‹(⋀(p'::('a × 'b × 'c × 'a) list) w::'d. ⟦(pp::('a × 'b × 'c × 'a) list × 'd) = ((prev::('a × 'b × 'c × 'a) list) @ p', w); path (M::('a, 'b, 'c) fsm) (q::'a) p'; length p' ≤ Suc (k::nat); (P::('a × 'b × 'c × 'a) list ⇒ 'd option) (prev @ p') = Some w; ⋀(p'::('a × 'b × 'c × 'a) list) p''::('a × 'b × 'c × 'a) list. ⟦p' = p' @ p''; p'' ≠ []⟧ ⟹ P (prev @ p') = None⟧ ⟹ thesis::bool) ⟹ thesis›*) by blast moreover obtain t and p where "p' = t#p" (*goal: ‹(⋀t p. p' = t # p ⟹ thesis) ⟹ thesis›*) using ‹P (prev @ p') = Some w› (*‹(P::('a × 'b × 'c × 'a) list ⇒ 'd option) ((prev::('a × 'b × 'c × 'a) list) @ (p'::('a × 'b × 'c × 'a) list)) = Some (w::'d)›*) using None (*‹P prev = None›*) by (metis append_Nil2 (*‹?xs @ [] = ?xs›*) list.exhaust (*‹⟦?y = [] ⟹ ?P; ⋀x21 x22. ?y = x21 # x22 ⟹ ?P⟧ ⟹ ?P›*) option.distinct( (*‹None ≠ Some ?x2.0›*) 1)) have "pp = ((prev @ [t])@p, w)" using ‹pp = (prev @ p', w)› (*‹pp = (prev @ p', w)›*) unfolding ‹p' = t#p› (*goal: ‹pp = ((prev @ [t]) @ p, w)›*) by auto have "path M q (t#p)" using ‹path M q p'› (*‹path M q p'›*) unfolding ‹p' = t#p› (*goal: ‹path (M::('a, 'b, 'c) fsm) (q::'a) ((t::'a × 'b × 'c × 'a) # (p::('a × 'b × 'c × 'a) list))›*) by auto have p2: "length (t#p) ≤ Suc k" using ‹length p' ≤ Suc k› (*‹length p' ≤ Suc k›*) unfolding ‹p' = t#p› (*goal: ‹length (t # p) ≤ Suc k›*) by auto have p3: "P ((prev @ [t])@p) = Some w" using ‹P (prev @ p') = Some w› (*‹P (prev @ p') = Some w›*) unfolding ‹p' = t#p› (*goal: ‹(P::('a::type × 'b::type × 'c::type × 'a::type) list ⇒ 'd::type option) (((prev::('a::type × 'b::type × 'c::type × 'a::type) list) @ [t::'a::type × 'b::type × 'c::type × 'a::type]) @ (p::('a::type × 'b::type × 'c::type × 'a::type) list)) = Some (w::'d::type)›*) by auto have p4: "⋀ p' p''. p = p' @ p'' ⟹ p'' ≠ [] ⟹ P ((prev@[t]) @ p') = None" using ‹⋀ p' p''. p' = p' @ p'' ⟹ p'' ≠ [] ⟹ P (prev @ p') = None› (*‹⟦(?p'::('a × 'b × 'c × 'a) list) = ?p' @ (?p''::('a × 'b × 'c × 'a) list); ?p'' ≠ []⟧ ⟹ (P::('a × 'b × 'c × 'a) list ⇒ 'd option) ((prev::('a × 'b × 'c × 'a) list) @ ?p') = None›*) ‹pp ∈ ?PX› (*‹pp ∈ {(prev @ p, x) |p x. path M q p ∧ length p ≤ Suc k ∧ P (prev @ p) = Some x ∧ (∀p' p''. p = p' @ p'' ∧ p'' ≠ [] ⟶ P (prev @ p') = None)}›*) unfolding ‹pp = ((prev @ [t]) @ p, w)› ‹p' = t#p› (*goal: ‹⋀p' p''. ⟦p = p' @ p''; p'' ≠ []⟧ ⟹ P ((prev @ [t]) @ p') = None›*) by auto have "t ∈ transitions M" and p1: "path M (t_target t) p" and "t_source t = q" using ‹path M q (t#p)› (*‹path M q (t # p)›*) apply - (*goals: 1. ‹path M q (t # p) ⟹ t ∈ FSM.transitions M› 2. ‹path M q (t # p) ⟹ path M (t_target t) p› 3. ‹path M q (t # p) ⟹ t_source t = q› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*proven 3 subgoals*) . then have "t_target t ∈ states M" and "(t_input t, t_output t, t_target t) ∈ h_from M q" and "t_source t = q" using fsm_transition_target (*‹(?t::?'a × ?'b × ?'c × ?'a) ∈ FSM.transitions (?M::(?'a, ?'b, ?'c) fsm) ⟹ t_target ?t ∈ FSM.states ?M›*) apply - (*goals: 1. ‹⟦t ∈ FSM.transitions M; path M (t_target t) p; t_source t = q; ⋀t M. t ∈ FSM.transitions M ⟹ t_target t ∈ FSM.states M⟧ ⟹ t_target t ∈ FSM.states M› 2. ‹⟦t ∈ FSM.transitions M; path M (t_target t) p; t_source t = q; ⋀t M. t ∈ FSM.transitions M ⟹ t_target t ∈ FSM.states M⟧ ⟹ (t_input t, t_output t, t_target t) ∈ h_from M q› 3. ‹⟦t ∈ FSM.transitions M; path M (t_target t) p; t_source t = q; ⋀t M. t ∈ FSM.transitions M ⟹ t_target t ∈ FSM.states M⟧ ⟹ t_source t = q› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*proven 3 subgoals*) . then have "t = (q,t_input t, t_output t, t_target t)" by auto have "((prev @ [t])@p, w) ∈ paths_up_to_length_or_condition_with_witness' (h_from M) P (prev@[t]) k (t_target t)" unfolding Suc.IH[OF ‹t_target t ∈ states M›, of "prev@[t]"] (*goal: ‹((prev @ [t]) @ p, w) ∈ {((prev @ [t]) @ p, x) |p x. path M (t_target t) p ∧ length p ≤ k ∧ P ((prev @ [t]) @ p) = Some x ∧ (∀p' p''. p = p' @ p'' ∧ p'' ≠ [] ⟶ P ((prev @ [t]) @ p') = None)}›*) using p1 (*‹path (M::('a, 'b, 'c) fsm) (t_target (t::'a × 'b × 'c × 'a)) (p::('a × 'b × 'c × 'a) list)›*) p2 (*‹length (t # p) ≤ Suc k›*) p3 (*‹P ((prev @ [t]) @ p) = Some w›*) p4 (*‹⟦p = ?p' @ ?p''; ?p'' ≠ []⟧ ⟹ P ((prev @ [t]) @ ?p') = None›*) by auto then show "pp ∈ ?UN" unfolding ‹pp = ((prev @ [t])@p, w)› (*goal: ‹((prev @ [t]) @ p, w) ∈ (⋃(x, y, q')∈h_from M q. paths_up_to_length_or_condition_with_witness' (h_from M) P (prev @ [(q, x, y, q')]) k q')›*) proof (-) (*goal: ‹((prev @ [t]) @ p, w) ∈ paths_up_to_length_or_condition_with_witness' (h_from M) P (prev @ [t]) k (t_target t) ⟹ ((prev @ [t]) @ p, w) ∈ (⋃(x, y, q')∈h_from M q. paths_up_to_length_or_condition_with_witness' (h_from M) P (prev @ [(q, x, y, q')]) k q')›*) have "paths_up_to_length_or_condition_with_witness' (h_from M) P (prev @ [t]) k (t_target t) = paths_up_to_length_or_condition_with_witness' (h_from M) P (prev @ [(q, t_input t, t_output t, t_target t)]) k (t_target t)" using ‹t = (q, t_input t, t_output t, t_target t)› (*‹t = (q, t_input t, t_output t, t_target t)›*) by presburger then show "((prev @ [t]) @ p, w) ∈ (⋃(b, c, a)∈h_from M q. paths_up_to_length_or_condition_with_witness' (h_from M) P (prev @ [(q, b, c, a)]) k a)" using ‹((prev @ [t]) @ p, w) ∈ paths_up_to_length_or_condition_with_witness' (h_from M) P (prev @ [t]) k (t_target t)› (*‹((prev @ [t]) @ p, w) ∈ paths_up_to_length_or_condition_with_witness' (h_from M) P (prev @ [t]) k (t_target t)›*) ‹(t_input t, t_output t, t_target t) ∈ h_from M q› (*‹(t_input t, t_output t, t_target t) ∈ h_from M q›*) by blast qed qed show "?thesis" (*goal: ‹(⋃(x, y, q')∈h_from M q. paths_up_to_length_or_condition_with_witness' (h_from M) P (prev @ [(q, x, y, q')]) k q') = {(prev @ p, x) |p x. path M q p ∧ length p ≤ Suc k ∧ P (prev @ p) = Some x ∧ (∀p' p''. p = p' @ p'' ∧ p'' ≠ [] ⟶ P (prev @ p') = None)}›*) using subsetI[of ?UN ?PX, OF *] (*‹(⋀x::('a::type × 'b::type × 'c::type × 'a::type) list × 'd::type. x ∈ (⋃(x::'b::type, y::'c::type, q'::'a::type)∈h_from M q. paths_up_to_length_or_condition_with_witness' (h_from (M::('a::type, 'b::type, 'c::type) fsm)) (P::('a::type × 'b::type × 'c::type × 'a::type) list ⇒ 'd::type option) ((prev::('a::type × 'b::type × 'c::type × 'a::type) list) @ [(q::'a::type, x, y, q')]) (k::nat) q') ⟹ x ∈ (⋃(x::'b::type, y::'c::type, q'::'a::type)∈h_from M q. paths_up_to_length_or_condition_with_witness' (h_from M) P (prev @ [(q, x, y, q')]) k q')) ⟹ (⋃(x::'b::type, y::'c::type, q'::'a::type)∈h_from M q. paths_up_to_length_or_condition_with_witness' (h_from M) P (prev @ [(q, x, y, q')]) k q') ⊆ {(prev @ p, x) |(p::('a::type × 'b::type × 'c::type × 'a::type) list) x::'d::type. path M q p ∧ length p ≤ Suc k ∧ P (prev @ p) = Some x ∧ (∀(p'::('a::type × 'b::type × 'c::type × 'a::type) list) p''::('a::type × 'b::type × 'c::type × 'a::type) list. p = p' @ p'' ∧ p'' ≠ [] ⟶ P (prev @ p') = None)}›*) subsetI[of ?PX ?UN, OF **] (*‹(⋀x. x ∈ {(prev @ p, x) |p x. path M q p ∧ length p ≤ Suc k ∧ P (prev @ p) = Some x ∧ (∀p' p''. p = p' @ p'' ∧ p'' ≠ [] ⟶ P (prev @ p') = None)} ⟹ x ∈ {(prev @ p, x) |p x. path M q p ∧ length p ≤ Suc k ∧ P (prev @ p) = Some x ∧ (∀p' p''. p = p' @ p'' ∧ p'' ≠ [] ⟶ P (prev @ p') = None)}) ⟹ {(prev @ p, x) |p x. path M q p ∧ length p ≤ Suc k ∧ P (prev @ p) = Some x ∧ (∀p' p''. p = p' @ p'' ∧ p'' ≠ [] ⟶ P (prev @ p') = None)} ⊆ (⋃(x, y, q')∈h_from M q. paths_up_to_length_or_condition_with_witness' (h_from M) P (prev @ [(q, x, y, q')]) k q')›*) subset_antisym (*‹⟦?A ⊆ ?B; ?B ⊆ ?A⟧ ⟹ ?A = ?B›*) by blast qed then show "?thesis" (*goal: ‹paths_up_to_length_or_condition_with_witness' (h_from M) P prev (Suc k) q = {(prev @ p, x) |p x. path M q p ∧ length p ≤ Suc k ∧ P (prev @ p) = Some x ∧ (∀p' p''. p = p' @ p'' ∧ p'' ≠ [] ⟶ P (prev @ p') = None)}›*) using None (*‹P prev = None›*) unfolding paths_up_to_length_or_condition_with_witness'.simps (*goal: ‹(case P prev of None ⇒ ⋃(x, y, q')∈h_from M q. paths_up_to_length_or_condition_with_witness' (h_from M) P (prev @ [(q, x, y, q')]) k q' | Some w ⇒ {(prev, w)}) = {(prev @ p, x) |p x. path M q p ∧ length p ≤ Suc k ∧ P (prev @ p) = Some x ∧ (∀p' p''. p = p' @ p'' ∧ p'' ≠ [] ⟶ P (prev @ p') = None)}›*) by simp qed qed definition paths_up_to_length_or_condition_with_witness :: "('a,'b,'c) fsm ⇒ (('a,'b,'c) path ⇒ 'd option) ⇒ nat ⇒ 'a ⇒ (('a,'b,'c) path × 'd) set" where "paths_up_to_length_or_condition_with_witness M P k q = {(p,x) | p x . path M q p ∧ length p ≤ k ∧ P p = Some x ∧ (∀ p' p'' . (p = p'@p'' ∧ p'' ≠ []) ⟶ P p' = None)}" lemma paths_up_to_length_or_condition_with_witness_code[code] : "paths_up_to_length_or_condition_with_witness M P k q = (if q ∈ states M then paths_up_to_length_or_condition_with_witness' (h_from M) P [] k q else {})" proof (cases "q ∈ states M") (*goals: 1. ‹q ∈ FSM.states M ⟹ paths_up_to_length_or_condition_with_witness M P k q = (if q ∈ FSM.states M then paths_up_to_length_or_condition_with_witness' (h_from M) P [] k q else {})› 2. ‹q ∉ FSM.states M ⟹ paths_up_to_length_or_condition_with_witness M P k q = (if q ∈ FSM.states M then paths_up_to_length_or_condition_with_witness' (h_from M) P [] k q else {})›*) case True (*‹q ∈ FSM.states M›*) then show "?thesis" (*goal: ‹paths_up_to_length_or_condition_with_witness M P k q = (if q ∈ FSM.states M then paths_up_to_length_or_condition_with_witness' (h_from M) P [] k q else {})›*) unfolding paths_up_to_length_or_condition_with_witness_def paths_up_to_length_or_condition_with_witness'_set[OF True] (*goal: ‹{(p, x) |p x. path M q p ∧ length p ≤ k ∧ P p = Some x ∧ (∀p' p''. p = p' @ p'' ∧ p'' ≠ [] ⟶ P p' = None)} = (if q ∈ FSM.states M then {([] @ p, x) |p x. path M q p ∧ length p ≤ k ∧ P ([] @ p) = Some x ∧ (∀p' p''. p = p' @ p'' ∧ p'' ≠ [] ⟶ P ([] @ p') = None)} else {})›*) by auto next (*goal: ‹q ∉ FSM.states M ⟹ paths_up_to_length_or_condition_with_witness M P k q = (if q ∈ FSM.states M then paths_up_to_length_or_condition_with_witness' (h_from M) P [] k q else {})›*) case False (*‹q ∉ FSM.states M›*) then show "?thesis" (*goal: ‹paths_up_to_length_or_condition_with_witness M P k q = (if q ∈ FSM.states M then paths_up_to_length_or_condition_with_witness' (h_from M) P [] k q else {})›*) unfolding paths_up_to_length_or_condition_with_witness_def (*goal: ‹{(p, x) |p x. path M q p ∧ length p ≤ k ∧ P p = Some x ∧ (∀p' p''. p = p' @ p'' ∧ p'' ≠ [] ⟶ P p' = None)} = (if q ∈ FSM.states M then paths_up_to_length_or_condition_with_witness' (h_from M) P [] k q else {})›*) using path_begin_state (*‹path (?M::(?'a, ?'b, ?'c) fsm) (?q::?'a) (?p::(?'a × ?'b × ?'c × ?'a) list) ⟹ ?q ∈ FSM.states ?M›*) by fastforce qed lemma paths_up_to_length_or_condition_with_witness_finite : "finite (paths_up_to_length_or_condition_with_witness M P k q)" proof (-) (*goal: ‹finite (paths_up_to_length_or_condition_with_witness M P k q)›*) have "paths_up_to_length_or_condition_with_witness M P k q ⊆ {(p, the (P p)) | p . path M q p ∧ length p ≤ k}" unfolding paths_up_to_length_or_condition_with_witness_def (*goal: ‹{(p, x) |p x. path M q p ∧ length p ≤ k ∧ P p = Some x ∧ (∀p' p''. p = p' @ p'' ∧ p'' ≠ [] ⟶ P p' = None)} ⊆ {(p, the (P p)) |p. path M q p ∧ length p ≤ k}›*) by auto moreover have "finite {(p, the (P p)) | p . path M q p ∧ length p ≤ k}" using paths_finite[of M q k] (*‹finite {p::('a × 'b × 'c × 'a) list. path (M::('a, 'b, 'c) fsm) (q::'a) p ∧ length p ≤ (k::nat)}›*) by simp ultimately show "?thesis" (*goal: ‹finite (paths_up_to_length_or_condition_with_witness M P k q)›*) using rev_finite_subset (*‹⟦finite ?B; ?A ⊆ ?B⟧ ⟹ finite ?A›*) by auto qed subsection ‹More Acyclicity Properties› lemma maximal_path_target_deadlock : assumes "path M (initial M) p" and "¬(∃ p' . path M (initial M) p' ∧ is_prefix p p' ∧ p ≠ p')" shows "deadlock_state M (target (initial M) p)" proof (-) (*goal: ‹deadlock_state M (target (FSM.initial M) p)›*) have "¬(∃ t ∈ transitions M . t_source t = target (initial M) p)" using assms(2) (*‹∄p'. path M (FSM.initial M) p' ∧ is_prefix p p' ∧ p ≠ p'›*) unfolding is_prefix_prefix (*goal: ‹¬ (∃t∈FSM.transitions M. t_source t = target (FSM.initial M) p)›*) by (metis append_Nil2 (*‹?xs @ [] = ?xs›*) assms( (*‹path M (FSM.initial M) p›*) 1) not_Cons_self2 (*‹?x # ?xs ≠ ?xs›*) path_append_transition (*‹⟦path ?M ?q ?p; ?t ∈ FSM.transitions ?M; t_source ?t = target ?q ?p⟧ ⟹ path ?M ?q (?p @ [?t])›*) same_append_eq (*‹(?xs @ ?ys = ?xs @ ?zs) = (?ys = ?zs)›*)) then show "?thesis" (*goal: ‹deadlock_state M (target (FSM.initial M) p)›*) by auto qed lemma path_to_deadlock_is_maximal : assumes "path M (initial M) p" and "deadlock_state M (target (initial M) p)" shows "¬(∃ p' . path M (initial M) p' ∧ is_prefix p p' ∧ p ≠ p')" proof (standard) (*goal: ‹∃p'::('a × 'b × 'c × 'a) list. path (M::('a, 'b, 'c) fsm) (FSM.initial M) p' ∧ is_prefix (p::('a × 'b × 'c × 'a) list) p' ∧ p ≠ p' ⟹ False›*) assume "∃p'. path M (initial M) p' ∧ is_prefix p p' ∧ p ≠ p'" (*‹∃p'::('a × 'b × 'c × 'a) list. path (M::('a, 'b, 'c) fsm) (FSM.initial M) p' ∧ is_prefix (p::('a × 'b × 'c × 'a) list) p' ∧ p ≠ p'›*) then obtain p' where "path M (initial M) p'" and "is_prefix p p'" and "p ≠ p'" (*goal: ‹(⋀p'. ⟦path M (FSM.initial M) p'; is_prefix p p'; p ≠ p'⟧ ⟹ thesis) ⟹ thesis›*) by blast then have "length p' > length p" unfolding is_prefix_prefix (*goal: ‹length p < length p'›*) by auto then obtain t and p2 where "p' = p @ [t] @ p2" (*goal: ‹(⋀t p2. p' = p @ [t] @ p2 ⟹ thesis) ⟹ thesis›*) using ‹is_prefix p p'› (*‹is_prefix (p::('a × 'b × 'c × 'a) list) (p'::('a × 'b × 'c × 'a) list)›*) unfolding is_prefix_prefix (*goal: ‹(⋀t p2. p' = p @ [t] @ p2 ⟹ thesis) ⟹ thesis›*) by (metis ‹p ≠ p'› append.left_neutral (*‹[] @ ?a = ?a›*) append_Cons (*‹(?x # ?xs) @ ?ys = ?x # ?xs @ ?ys›*) append_Nil2 (*‹?xs @ [] = ?xs›*) non_sym_dist_pairs'.cases (*‹⟦?x = [] ⟹ ?P; ⋀x xs. ?x = x # xs ⟹ ?P⟧ ⟹ ?P›*)) then have "path M (initial M) (p@[t])" using ‹path M (initial M) p'› (*‹path M (FSM.initial M) p'›*) by auto then have "t ∈ transitions M" and "t_source t = target (initial M) p" apply - (*goals: 1. ‹path M (FSM.initial M) (p @ [t]) ⟹ t ∈ FSM.transitions M› 2. ‹path M (FSM.initial M) (p @ [t]) ⟹ t_source t = target (FSM.initial M) p› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . then show False using ‹deadlock_state M (target (initial M) p)› (*‹deadlock_state M (target (FSM.initial M) p)›*) unfolding deadlock_state.simps (*goal: ‹False›*) by blast qed definition maximal_acyclic_paths :: "('a,'b,'c) fsm ⇒ ('a,'b,'c) path set" where "maximal_acyclic_paths M = {p . path M (initial M) p ∧ distinct (visited_states (initial M) p) ∧ ¬(∃ p' . p' ≠ [] ∧ path M (initial M) (p@p') ∧ distinct (visited_states (initial M) (p@p')))}" (* very inefficient construction *) lemma maximal_acyclic_paths_code[code] : "maximal_acyclic_paths M = (let ps = acyclic_paths_up_to_length M (initial M) (size M - 1) in Set.filter (λp . ¬ (∃ p' ∈ ps . p' ≠ p ∧ is_prefix p p')) ps)" proof (-) (*goal: ‹maximal_acyclic_paths M = (let ps = acyclic_paths_up_to_length M (FSM.initial M) (FSM.size M - 1) in Set.filter (λp. ¬ (∃p'∈ps. p' ≠ p ∧ is_prefix p p')) ps)›*) have scheme1: "⋀ P p . (∃ p' . p' ≠ [] ∧ P (p@p')) = (∃ p' ∈ {p . P p} . p' ≠ p ∧ is_prefix p p')" unfolding is_prefix_prefix (*goal: ‹⋀P p. (∃p'. p' ≠ [] ∧ P (p @ p')) = (∃p'∈{p. P p}. p' ≠ p ∧ (∃xs'. p' = p @ xs'))›*) by blast have scheme2: "⋀ p . (path M (FSM.initial M) p ∧ length p ≤ FSM.size M - 1 ∧ distinct (visited_states (FSM.initial M) p)) = (path M (FSM.initial M) p ∧ distinct (visited_states (FSM.initial M) p))" using acyclic_path_length_limit (*‹⟦path ?M ?q ?p; distinct (visited_states ?q ?p)⟧ ⟹ length ?p < FSM.size ?M›*) by fastforce show "?thesis" (*goal: ‹maximal_acyclic_paths M = (let ps = acyclic_paths_up_to_length M (FSM.initial M) (FSM.size M - 1) in Set.filter (λp. ¬ (∃p'∈ps. p' ≠ p ∧ is_prefix p p')) ps)›*) unfolding maximal_acyclic_paths_def acyclic_paths_up_to_length.simps Let_def (*goal: ‹{p. path M (FSM.initial M) p ∧ distinct (visited_states (FSM.initial M) p) ∧ (∄p'. p' ≠ [] ∧ path M (FSM.initial M) (p @ p') ∧ distinct (visited_states (FSM.initial M) (p @ p')))} = Set.filter (λp. ¬ (∃p'∈{p. path M (FSM.initial M) p ∧ length p ≤ FSM.size M - 1 ∧ distinct (visited_states (FSM.initial M) p)}. p' ≠ p ∧ is_prefix p p')) {p. path M (FSM.initial M) p ∧ length p ≤ FSM.size M - 1 ∧ distinct (visited_states (FSM.initial M) p)}›*) unfolding scheme1[of "λp . path M (initial M) p ∧ distinct (visited_states (initial M) p)"] (*goal: ‹{p. path M (FSM.initial M) p ∧ distinct (visited_states (FSM.initial M) p) ∧ ¬ (∃p'∈{p. path M (FSM.initial M) p ∧ distinct (visited_states (FSM.initial M) p)}. p' ≠ p ∧ is_prefix p p')} = Set.filter (λp. ¬ (∃p'∈{p. path M (FSM.initial M) p ∧ length p ≤ FSM.size M - 1 ∧ distinct (visited_states (FSM.initial M) p)}. p' ≠ p ∧ is_prefix p p')) {p. path M (FSM.initial M) p ∧ length p ≤ FSM.size M - 1 ∧ distinct (visited_states (FSM.initial M) p)}›*) unfolding scheme2 (*goal: ‹{p. path M (FSM.initial M) p ∧ distinct (visited_states (FSM.initial M) p) ∧ ¬ (∃p'∈{p. path M (FSM.initial M) p ∧ distinct (visited_states (FSM.initial M) p)}. p' ≠ p ∧ is_prefix p p')} = Set.filter (λp. ¬ (∃p'∈{p. path M (FSM.initial M) p ∧ distinct (visited_states (FSM.initial M) p)}. p' ≠ p ∧ is_prefix p p')) {p. path M (FSM.initial M) p ∧ distinct (visited_states (FSM.initial M) p)}›*) by fastforce qed lemma maximal_acyclic_path_deadlock : assumes "acyclic M" and "path M (initial M) p" shows "¬(∃ p' . p' ≠ [] ∧ path M (initial M) (p@p') ∧ distinct (visited_states (initial M) (p@p'))) = deadlock_state M (target (initial M) p)" proof (-) (*goal: ‹(∃p'. p' ≠ [] ∧ path M (FSM.initial M) (p @ p') ∧ distinct (visited_states (FSM.initial M) (p @ p'))) ≠ deadlock_state M (target (FSM.initial M) p)›*) have "deadlock_state M (target (initial M) p) ⟹ ¬(∃ p' . p' ≠ [] ∧ path M (initial M) (p@p') ∧ distinct (visited_states (initial M) (p@p')))" unfolding deadlock_state.simps (*goal: ‹¬ (∃t∈FSM.transitions M. t_source t = target (FSM.initial M) p) ⟹ ∄p'. p' ≠ [] ∧ path M (FSM.initial M) (p @ p') ∧ distinct (visited_states (FSM.initial M) (p @ p'))›*) using assms(2) (*‹path M (FSM.initial M) p›*) by (metis path.cases (*‹⟦path ?a1.0 ?a2.0 ?a3.0; ⋀q M. ⟦?a1.0 = M; ?a2.0 = q; ?a3.0 = []; q ∈ FSM.states M⟧ ⟹ ?P; ⋀t M ts. ⟦?a1.0 = M; ?a2.0 = t_source t; ?a3.0 = t # ts; t ∈ FSM.transitions M; path M (t_target t) ts⟧ ⟹ ?P⟧ ⟹ ?P›*) path_suffix (*‹path ?M ?q (?p1.0 @ ?p2.0) ⟹ path ?M (target ?q ?p1.0) ?p2.0›*)) then show "?thesis" (*goal: ‹(∃p'. p' ≠ [] ∧ path M (FSM.initial M) (p @ p') ∧ distinct (visited_states (FSM.initial M) (p @ p'))) ≠ deadlock_state M (target (FSM.initial M) p)›*) by (metis acyclic.elims( (*‹⟦FSM.acyclic ?x; ⋀M. ⟦?x = M; ∀p. path M (FSM.initial M) p ⟶ distinct (visited_states (FSM.initial M) p)⟧ ⟹ ?P⟧ ⟹ ?P›*) 2) assms( (*‹FSM.acyclic M›*) 1) assms( (*‹path M (FSM.initial M) p›*) 2) is_prefix_prefix (*‹is_prefix ?xs ?ys = (∃xs'. ?ys = ?xs @ xs')›*) maximal_path_target_deadlock (*‹⟦path ?M (FSM.initial ?M) ?p; ∄p'. path ?M (FSM.initial ?M) p' ∧ is_prefix ?p p' ∧ ?p ≠ p'⟧ ⟹ deadlock_state ?M (target (FSM.initial ?M) ?p)›*) self_append_conv (*‹(?y = ?y @ ?ys) = (?ys = [])›*)) qed lemma maximal_acyclic_paths_deadlock_targets : assumes "acyclic M" shows "maximal_acyclic_paths M = { p . path M (initial M) p ∧ deadlock_state M (target (initial M) p)}" using maximal_acyclic_path_deadlock[OF assms] (*‹path M (FSM.initial M) ?p ⟹ (∃p'. p' ≠ [] ∧ path M (FSM.initial M) (?p @ p') ∧ distinct (visited_states (FSM.initial M) (?p @ p'))) ≠ deadlock_state M (target (FSM.initial M) ?p)›*) unfolding maximal_acyclic_paths_def (*goal: ‹{p. path M (FSM.initial M) p ∧ distinct (visited_states (FSM.initial M) p) ∧ (∄p'. p' ≠ [] ∧ path M (FSM.initial M) (p @ p') ∧ distinct (visited_states (FSM.initial M) (p @ p')))} = {p. path M (FSM.initial M) p ∧ deadlock_state M (target (FSM.initial M) p)}›*) by (metis (no_types, lifting) acyclic.elims( (*‹⟦FSM.acyclic ?x; ⋀M. ⟦?x = M; ∀p. path M (FSM.initial M) p ⟶ distinct (visited_states (FSM.initial M) p)⟧ ⟹ ?P⟧ ⟹ ?P›*) 2) assms (*‹FSM.acyclic M›*)) lemma cycle_from_cyclic_path : assumes "path M q p" and "¬ distinct (visited_states q p)" obtains i j where "take j (drop i p) ≠ []" "target (target q (take i p)) (take j (drop i p)) = (target q (take i p))" "path M (target q (take i p)) (take j (drop i p))" proof (-) (*goal: ‹(⋀j i. ⟦take j (drop i p) ≠ []; target (target q (take i p)) (take j (drop i p)) = target q (take i p); path M (target q (take i p)) (take j (drop i p))⟧ ⟹ thesis) ⟹ thesis›*) obtain i and j where "i < j" and "j < length (visited_states q p)" and "(visited_states q p) ! i = (visited_states q p) ! j" (*goal: ‹(⋀i j. ⟦i < j; j < length (visited_states q p); visited_states q p ! i = visited_states q p ! j⟧ ⟹ thesis) ⟹ thesis›*) using assms(2) (*‹¬ distinct (visited_states q p)›*) non_distinct_repetition_indices (*‹¬ distinct ?xs ⟹ ∃i j. i < j ∧ j < length ?xs ∧ ?xs ! i = ?xs ! j›*) by blast have "(target q (take i p)) = (visited_states q p) ! i" using ‹i < j› (*‹(i::nat) < (j::nat)›*) ‹j < length (visited_states q p)› (*‹j < length (visited_states q p)›*) by (metis less_trans (*‹⟦?x < ?y; ?y < ?z⟧ ⟹ ?x < ?z›*) take_last_index (*‹?i < length ?xs ⟹ last (take (Suc ?i) ?xs) = ?xs ! ?i›*) target.simps (*‹target ?q ?p = last (visited_states ?q ?p)›*) visited_states_take (*‹take (Suc ?n) (visited_states ?q ?p) = visited_states ?q (take ?n ?p)›*)) then have "(target q (take i p)) = (visited_states q p) ! j" using ‹(visited_states q p) ! i = (visited_states q p) ! j› (*‹visited_states q p ! i = visited_states q p ! j›*) by auto have p1: "take (j-i) (drop i p) ≠ []" using ‹i < j› (*‹i < j›*) ‹j < length (visited_states q p)› (*‹j < length (visited_states q p)›*) by auto have "target (target q (take i p)) (take (j-i) (drop i p)) = (target q (take j p))" using ‹i < j› (*‹i < j›*) by (metis add_diff_inverse_nat (*‹¬ (?m::nat) < (?n::nat) ⟹ ?n + (?m - ?n) = ?m›*) less_asym' (*‹⟦(?a::?'a) < (?b::?'a); ?b < ?a⟧ ⟹ ?P::bool›*) path_append_target (*‹target (?q::?'a) ((?p1.0::(?'a × ?'b × ?'c × ?'a) list) @ (?p2.0::(?'a × ?'b × ?'c × ?'a) list)) = target (target ?q ?p1.0) ?p2.0›*) take_add (*‹take ((?i::nat) + (?j::nat)) (?xs::?'a list) = take ?i ?xs @ take ?j (drop ?i ?xs)›*)) then have p2: "target (target q (take i p)) (take (j-i) (drop i p)) = (target q (take i p))" using ‹(target q (take i p)) = (visited_states q p) ! i› (*‹target (q::'a::type) (take (i::nat) (p::('a::type × 'b::type × 'c::type × 'a::type) list)) = visited_states q p ! i›*) using ‹(target q (take i p)) = (visited_states q p) ! j› (*‹target (q::'a::type) (take (i::nat) (p::('a::type × 'b::type × 'c::type × 'a::type) list)) = visited_states q p ! (j::nat)›*) by (metis ‹j < length (visited_states q p)› take_last_index (*‹?i < length ?xs ⟹ last (take (Suc ?i) ?xs) = ?xs ! ?i›*) target.simps (*‹target ?q ?p = last (visited_states ?q ?p)›*) visited_states_take (*‹take (Suc ?n) (visited_states ?q ?p) = visited_states ?q (take ?n ?p)›*)) have p3: "path M (target q (take i p)) (take (j-i) (drop i p))" by (metis append_take_drop_id (*‹take (?n::nat) (?xs::?'a::type list) @ drop ?n ?xs = ?xs›*) assms( (*‹path (M::('a::type, 'b::type, 'c::type) fsm) (q::'a::type) (p::('a::type × 'b::type × 'c::type × 'a::type) list)›*) 1) path_append_elim (*‹⟦path (?M::(?'a::type, ?'b::type, ?'c::type) fsm) (?q::?'a::type) ((?p1.0::(?'a::type × ?'b::type × ?'c::type × ?'a::type) list) @ (?p2.0::(?'a::type × ?'b::type × ?'c::type × ?'a::type) list)); ⟦path ?M ?q ?p1.0; path ?M (target ?q ?p1.0) ?p2.0⟧ ⟹ ?thesis::bool⟧ ⟹ ?thesis›*)) show "?thesis" (*goal: ‹thesis›*) using p1 (*‹take ((j::nat) - (i::nat)) (drop i (p::('a::type × 'b::type × 'c::type × 'a::type) list)) ≠ []›*) p2 (*‹target (target (q::'a) (take (i::nat) (p::('a × 'b × 'c × 'a) list))) (take ((j::nat) - i) (drop i p)) = target q (take i p)›*) p3 (*‹path (M::('a::type, 'b::type, 'c::type) fsm) (target (q::'a::type) (take (i::nat) (p::('a::type × 'b::type × 'c::type × 'a::type) list))) (take ((j::nat) - i) (drop i p))›*) that (*‹⟦take ?j (drop ?i p) ≠ []; target (target q (take ?i p)) (take ?j (drop ?i p)) = target q (take ?i p); path M (target q (take ?i p)) (take ?j (drop ?i p))⟧ ⟹ thesis›*) by blast qed lemma acyclic_single_deadlock_reachable : assumes "acyclic M" and "⋀ q' . q' ∈ reachable_states M ⟹ q' = qd ∨ ¬ deadlock_state M q'" shows "qd ∈ reachable_states M" using acyclic_deadlock_reachable[OF assms ( 1 )] (*‹∃q::'a∈reachable_states (M::('a, 'b, 'c) fsm). deadlock_state M q›*) using assms(2) (*‹?q' ∈ reachable_states M ⟹ ?q' = qd ∨ ¬ deadlock_state M ?q'›*) by auto lemma acyclic_paths_to_single_deadlock : assumes "acyclic M" and "⋀ q' . q' ∈ reachable_states M ⟹ q' = qd ∨ ¬ deadlock_state M q'" and "q ∈ reachable_states M" obtains p where "path M q p" and "target q p = qd" proof (-) (*goal: ‹(⋀p. ⟦path M q p; target q p = qd⟧ ⟹ thesis) ⟹ thesis›*) have "q ∈ states M" using assms(3) (*‹(q::'a) ∈ reachable_states (M::('a, 'b, 'c) fsm)›*) reachable_state_is_state (*‹?q ∈ reachable_states ?M ⟹ ?q ∈ FSM.states ?M›*) by metis have "acyclic (from_FSM M q)" using from_FSM_acyclic[OF assms ( 3 , 1 )] (*‹FSM.acyclic (from_FSM M q)›*) by assumption have "*": "(⋀q'. q' ∈ reachable_states (FSM.from_FSM M q) ⟹ q' = qd ∨ ¬ deadlock_state (FSM.from_FSM M q) q')" using assms(2) (*‹?q' ∈ reachable_states M ⟹ ?q' = qd ∨ ¬ deadlock_state M ?q'›*) from_FSM_reachable_states[OF assms ( 3 )] (*‹reachable_states (from_FSM M q) ⊆ reachable_states M›*) unfolding deadlock_state.simps from_FSM_simps[OF ‹q ∈ states M›] (*goal: ‹⋀q'. q' ∈ reachable_states (from_FSM M q) ⟹ q' = qd ∨ ¬ ¬ (∃t∈FSM.transitions M. t_source t = q')›*) by blast obtain p where "path (from_FSM M q) q p" and "target q p = qd" (*goal: ‹(⋀p::('a × 'b × 'c × 'a) list. ⟦path (from_FSM (M::('a, 'b, 'c) fsm) (q::'a)) q p; target q p = (qd::'a)⟧ ⟹ thesis::bool) ⟹ thesis›*) using acyclic_single_deadlock_reachable[OF ‹acyclic (from_FSM M q)› *] (*‹(⋀q'. q' ∈ reachable_states (from_FSM M q) ⟹ q' ∈ reachable_states (from_FSM M q)) ⟹ qd ∈ reachable_states (from_FSM M q)›*) unfolding reachable_states_def from_FSM_simps[OF ‹q ∈ states M›] (*goal: ‹(⋀p. ⟦path (from_FSM M q) q p; target q p = qd⟧ ⟹ thesis) ⟹ thesis›*) by blast then show "?thesis" (*goal: ‹thesis›*) using that (*‹⟦path M q ?p; target q ?p = qd⟧ ⟹ thesis›*) by (metis ‹q ∈ FSM.states M› from_FSM_path (*‹⟦?q ∈ FSM.states ?M; path (from_FSM ?M ?q) ?q' ?p⟧ ⟹ path ?M ?q' ?p›*)) qed subsection ‹Elements as Lists› fun states_as_list :: "('a :: linorder, 'b, 'c) fsm ⇒ 'a list" where "states_as_list M = sorted_list_of_set (states M)" lemma states_as_list_distinct : "distinct (states_as_list M)" by auto lemma states_as_list_set : "set (states_as_list M) = states M" by (simp add: fsm_states_finite (*‹finite (FSM.states ?M)›*)) fun reachable_states_as_list :: "('a :: linorder, 'b, 'c) fsm ⇒ 'a list" where "reachable_states_as_list M = sorted_list_of_set (reachable_states M)" lemma reachable_states_as_list_distinct : "distinct (reachable_states_as_list M)" by auto lemma reachable_states_as_list_set : "set (reachable_states_as_list M) = reachable_states M" by (metis fsm_states_finite (*‹finite (FSM.states ?M)›*) infinite_super (*‹⟦?S ⊆ ?T; infinite ?S⟧ ⟹ infinite ?T›*) reachable_state_is_state (*‹?q ∈ reachable_states ?M ⟹ ?q ∈ FSM.states ?M›*) reachable_states_as_list.simps (*‹reachable_states_as_list ?M = sorted_list_of_set (reachable_states ?M)›*) set_sorted_list_of_set (*‹finite ?A ⟹ set (sorted_list_of_set ?A) = ?A›*) subsetI (*‹(⋀x. x ∈ ?A ⟹ x ∈ ?B) ⟹ ?A ⊆ ?B›*)) fun inputs_as_list :: "('a, 'b :: linorder, 'c) fsm ⇒ 'b list" where "inputs_as_list M = sorted_list_of_set (inputs M)" lemma inputs_as_list_set : "set (inputs_as_list M) = inputs M" by (simp add: fsm_inputs_finite (*‹finite (FSM.inputs ?M)›*)) lemma inputs_as_list_distinct : "distinct (inputs_as_list M)" by auto fun transitions_as_list :: "('a :: linorder,'b :: linorder,'c :: linorder) fsm ⇒ ('a,'b,'c) transition list" where "transitions_as_list M = sorted_list_of_set (transitions M)" lemma transitions_as_list_set : "set (transitions_as_list M) = transitions M" by (simp add: fsm_transitions_finite (*‹finite (FSM.transitions ?M)›*)) fun outputs_as_list :: "('a,'b,'c :: linorder) fsm ⇒ 'c list" where "outputs_as_list M = sorted_list_of_set (outputs M)" lemma outputs_as_list_set : "set (outputs_as_list M) = outputs M" by (simp add: fsm_outputs_finite (*‹finite (FSM.outputs (?M::(?'b, ?'c, ?'a) fsm))›*)) fun ftransitions :: "('a :: linorder,'b :: linorder,'c :: linorder) fsm ⇒ ('a,'b,'c) transition fset" where "ftransitions M = fset_of_list (transitions_as_list M)" fun fstates :: "('a :: linorder,'b,'c) fsm ⇒ 'a fset" where "fstates M = fset_of_list (states_as_list M)" fun finputs :: "('a,'b :: linorder,'c) fsm ⇒ 'b fset" where "finputs M = fset_of_list (inputs_as_list M)" fun foutputs :: "('a,'b,'c :: linorder) fsm ⇒ 'c fset" where "foutputs M = fset_of_list (outputs_as_list M)" lemma fstates_set : "fset (fstates M) = states M" using fsm_states_finite[of M] (*‹finite (FSM.states M)›*) by (simp add: fset_of_list.rep_eq (*‹fset (fset_of_list ?x) = set ?x›*)) lemma finputs_set : "fset (finputs M) = inputs M" using fsm_inputs_finite[of M] (*‹finite (FSM.inputs M)›*) by (simp add: fset_of_list.rep_eq (*‹fset (fset_of_list ?x) = set ?x›*)) lemma foutputs_set : "fset (foutputs M) = outputs M" using fsm_outputs_finite[of M] (*‹finite (FSM.outputs M)›*) by (simp add: fset_of_list.rep_eq (*‹fset (fset_of_list ?x) = set ?x›*)) lemma ftransitions_set: "fset (ftransitions M) = transitions M" by (metis (no_types) fset_of_list.rep_eq (*‹fset (fset_of_list (?x::?'a list)) = set ?x›*) ftransitions.simps (*‹ftransitions (?M::(?'a, ?'b, ?'c) fsm) = fset_of_list (transitions_as_list ?M)›*) transitions_as_list_set (*‹set (transitions_as_list (?M::(?'a, ?'b, ?'c) fsm)) = FSM.transitions ?M›*)) lemma ftransitions_source: "q |∈| (t_source |`| ftransitions M) ⟹ q ∈ states M" using ftransitions_set[of M] (*‹fset (ftransitions M) = FSM.transitions M›*) fsm_transition_source[of _ M] (*‹(?t::'a::linorder × 'b::linorder × 'c::linorder × 'a::linorder) ∈ FSM.transitions (M::('a::linorder, 'b::linorder, 'c::linorder) fsm) ⟹ t_source ?t ∈ FSM.states M›*) by (metis (no_types, opaque_lifting) fimageE (*‹⟦?b |∈| ?f |`| ?A; ⋀x. ⟦?b = ?f x; x |∈| ?A⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*)) lemma ftransitions_target: "q |∈| (t_target |`| ftransitions M) ⟹ q ∈ states M" using ftransitions_set[of M] (*‹fset (ftransitions (M::('a::linorder, 'b::linorder, 'c::linorder) fsm)) = FSM.transitions M›*) fsm_transition_target[of _ M] (*‹(?t::'a::linorder × 'b::linorder × 'c::linorder × 'a::linorder) ∈ FSM.transitions (M::('a::linorder, 'b::linorder, 'c::linorder) fsm) ⟹ t_target ?t ∈ FSM.states M›*) by (metis (no_types, lifting) fimageE (*‹⟦?b |∈| ?f |`| ?A; ⋀x. ⟦?b = ?f x; x |∈| ?A⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*)) subsection ‹Responses to Input Sequences› fun language_for_input :: "('a::linorder,'b::linorder,'c::linorder) fsm ⇒ 'a ⇒ 'b list ⇒ ('b×'c) list list" where "language_for_input M q [] = [[]]" | "language_for_input M q (x#xs) = (let outs = outputs_as_list M in concat (map (λy . case h_obs M q x y of None ⇒ [] | Some q' ⇒ map ((#) (x,y)) (language_for_input M q' xs)) outs))" lemma language_for_input_set : assumes "observable M" and "q ∈ states M" shows "list.set (language_for_input M q xs) = {io . io ∈ LS M q ∧ map fst io = xs}" using assms(2) (*‹q ∈ FSM.states M›*) proof (induction xs arbitrary: q) (*goals: 1. ‹⋀q::'a. q ∈ FSM.states (M::('a, 'b, 'c) fsm) ⟹ set (language_for_input M q []) = {io::('b × 'c) list ∈ LS M q. map fst io = []}› 2. ‹⋀(a::'b) (xs::'b list) q::'a. ⟦⋀q::'a. q ∈ FSM.states (M::('a, 'b, 'c) fsm) ⟹ set (language_for_input M q xs) = {io::('b × 'c) list ∈ LS M q. map fst io = xs}; q ∈ FSM.states M⟧ ⟹ set (language_for_input M q (a # xs)) = {io::('b × 'c) list ∈ LS M q. map fst io = a # xs}›*) case Nil (*‹q ∈ FSM.states M›*) then show "?case" (*goal: ‹set (language_for_input M q []) = {io ∈ LS M q. map fst io = []}›*) by auto next (*goal: ‹⋀a xs q. ⟦⋀q. q ∈ FSM.states M ⟹ set (language_for_input M q xs) = {io ∈ LS M q. map fst io = xs}; q ∈ FSM.states M⟧ ⟹ set (language_for_input M q (a # xs)) = {io ∈ LS M q. map fst io = a # xs}›*) case (Cons x xs) (*‹?q ∈ FSM.states M ⟹ set (language_for_input M ?q xs) = {io ∈ LS M ?q. map fst io = xs}› ‹(q::'a) ∈ FSM.states (M::('a, 'b, 'c) fsm)›*) have "list.set (language_for_input M q (x#xs)) ⊆ {io . io ∈ LS M q ∧ map fst io = (x#xs)}" proof (standard) (*goal: ‹⋀xa. xa ∈ set (language_for_input M q (x # xs)) ⟹ xa ∈ {io ∈ LS M q. map fst io = x # xs}›*) fix io assume "io ∈ list.set (language_for_input M q (x#xs))" (*‹(io::('b × 'c) list) ∈ set (language_for_input (M::('a, 'b, 'c) fsm) (q::'a) ((x::'b) # (xs::'b list)))›*) then obtain y where "y ∈ outputs M" and "io ∈ list.set (case h_obs M q x y of None ⇒ [] | Some q' ⇒ map ((#) (x,y)) (language_for_input M q' xs))" (*goal: ‹(⋀y. ⟦y ∈ FSM.outputs M; io ∈ set (case FSM.h_obs M q x y of None ⇒ [] | Some q' ⇒ map ((#) (x, y)) (language_for_input M q' xs))⟧ ⟹ thesis) ⟹ thesis›*) unfolding outputs_as_list_set[symmetric] (*goal: ‹(⋀y. ⟦y ∈ set (outputs_as_list M); io ∈ set (case FSM.h_obs M q x y of None ⇒ [] | Some q' ⇒ map ((#) (x, y)) (language_for_input M q' xs))⟧ ⟹ thesis) ⟹ thesis›*) by auto then obtain q' where "h_obs M q x y = Some q'" and "io ∈ list.set (map ((#) (x,y)) (language_for_input M q' xs))" (*goal: ‹(⋀q'. ⟦FSM.h_obs M q x y = Some q'; io ∈ set (map ((#) (x, y)) (language_for_input M q' xs))⟧ ⟹ thesis) ⟹ thesis›*) apply ((cases "h_obs M q x y")[1]) (*goals: 1. ‹⟦⋀q'. ⟦FSM.h_obs M q x y = Some q'; io ∈ set (map ((#) (x, y)) (language_for_input M q' xs))⟧ ⟹ thesis; y ∈ FSM.outputs M; io ∈ set (case FSM.h_obs M q x y of None ⇒ [] | Some q' ⇒ map ((#) (x, y)) (language_for_input M q' xs)); FSM.h_obs M q x y = None⟧ ⟹ thesis› 2. ‹⋀a. ⟦⋀q'. ⟦FSM.h_obs M q x y = Some q'; io ∈ set (map ((#) (x, y)) (language_for_input M q' xs))⟧ ⟹ thesis; y ∈ FSM.outputs M; io ∈ set (case FSM.h_obs M q x y of None ⇒ [] | Some q' ⇒ map ((#) (x, y)) (language_for_input M q' xs)); FSM.h_obs M q x y = Some a⟧ ⟹ thesis› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . then obtain io' where "io = (x,y)#io'" and "io' ∈ list.set (language_for_input M q' xs)" (*goal: ‹(⋀io'. ⟦io = (x, y) # io'; io' ∈ set (language_for_input M q' xs)⟧ ⟹ thesis) ⟹ thesis›*) by auto then have "io' ∈ LS M q'" and "map fst io' = xs" using Cons.IH[OF h_obs_state [ OF ‹h_obs M q x y = Some q'› ]] (*‹set (language_for_input M q' xs) = {io ∈ LS M q'. map fst io = xs}›*) apply - (*goals: 1. ‹⟦io = (x, y) # io'; io' ∈ set (language_for_input M q' xs); set (language_for_input M q' xs) = {io ∈ LS M q'. map fst io = xs}⟧ ⟹ io' ∈ LS M q'› 2. ‹⟦io = (x, y) # io'; io' ∈ set (language_for_input M q' xs); set (language_for_input M q' xs) = {io ∈ LS M q'. map fst io = xs}⟧ ⟹ map fst io' = xs› discuss goal 1*) apply blast (*discuss goal 2*) apply blast (*proven 2 subgoals*) . then have "(x,y)#io' ∈ LS M q" using ‹h_obs M q x y = Some q'› (*‹FSM.h_obs (M::('a, 'b, 'c) fsm) (q::'a) (x::'b) (y::'c) = Some (q'::'a)›*) unfolding h_obs_language_iff[OF assms ( 1 ), of x y io' q] (*goal: ‹∃q'::'a::linorder. FSM.h_obs (M::('a::linorder, 'b::linorder, 'c::linorder) fsm) (q::'a::linorder) (x::'b::linorder) (y::'c::linorder) = Some q' ∧ (io'::('b::linorder × 'c::linorder) list) ∈ LS M q'›*) by blast then show "io ∈ {io . io ∈ LS M q ∧ map fst io = (x#xs)}" unfolding ‹io = (x,y)#io'› (*goal: ‹(x, y) # io' ∈ {io ∈ LS M q. map fst io = x # xs}›*) using ‹map fst io' = xs› (*‹map fst io' = xs›*) by auto qed moreover have "{io . io ∈ LS M q ∧ map fst io = (x#xs)} ⊆ list.set (language_for_input M q (x#xs))" proof (standard) (*goal: ‹⋀xa. xa ∈ {io ∈ LS M q. map fst io = x # xs} ⟹ xa ∈ set (language_for_input M q (x # xs))›*) have scheme: "⋀ x y f xs . y ∈ list.set (f x) ⟹ x ∈ list.set xs ⟹ y ∈ list.set (concat (map f xs))" by auto fix io assume "io ∈ {io . io ∈ LS M q ∧ map fst io = (x#xs)}" (*‹(io::('b × 'c) list) ∈ {io::('b × 'c) list ∈ LS (M::('a, 'b, 'c) fsm) (q::'a). map fst io = (x::'b) # (xs::'b list)}›*) then have "io ∈ LS M q" and "map fst io = (x#xs)" apply - (*goals: 1. ‹io ∈ {io ∈ LS M q. map fst io = x # xs} ⟹ io ∈ LS M q› 2. ‹io ∈ {io ∈ LS M q. map fst io = x # xs} ⟹ map fst io = x # xs› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . then obtain y and io' where "io = (x,y)#io'" (*goal: ‹(⋀y io'. io = (x, y) # io' ⟹ thesis) ⟹ thesis›*) by fastforce then have "(x,y)#io' ∈ LS M q" using ‹io ∈ LS M q› (*‹io ∈ LS M q›*) by auto then obtain q' where "h_obs M q x y = Some q'" and "io' ∈ LS M q'" (*goal: ‹(⋀q'::'a::linorder. ⟦FSM.h_obs (M::('a::linorder, 'b::linorder, 'c::linorder) fsm) (q::'a::linorder) (x::'b::linorder) (y::'c::linorder) = Some q'; (io'::('b::linorder × 'c::linorder) list) ∈ LS M q'⟧ ⟹ thesis::bool) ⟹ thesis›*) unfolding h_obs_language_iff[OF assms ( 1 ), of x y io' q] (*goal: ‹(⋀q'. ⟦FSM.h_obs M q x y = Some q'; io' ∈ LS M q'⟧ ⟹ thesis) ⟹ thesis›*) by blast moreover have "io' ∈ list.set (language_for_input M q' xs)" using Cons.IH[OF h_obs_state [ OF ‹h_obs M q x y = Some q'› ]] (*‹set (language_for_input M q' xs) = {io ∈ LS M q'. map fst io = xs}›*) ‹io' ∈ LS M q'› (*‹io' ∈ LS M q'›*) ‹map fst io = (x#xs)› (*‹map fst io = x # xs›*) unfolding ‹io = (x,y)#io'› (*goal: ‹io' ∈ set (language_for_input M q' xs)›*) by auto ultimately have "io ∈ list.set ((λ y .(case h_obs M q x y of None ⇒ [] | Some q' ⇒ map ((#) (x,y)) (language_for_input M q' xs))) y)" unfolding ‹io = (x,y)#io'› (*goal: ‹(x, y) # io' ∈ set (case FSM.h_obs M q x y of None ⇒ [] | Some q' ⇒ map ((#) (x, y)) (language_for_input M q' xs))›*) by force moreover have "y ∈ list.set (outputs_as_list M)" unfolding outputs_as_list_set (*goal: ‹y ∈ FSM.outputs M›*) using language_io(2)[OF ‹(x,y)#io' ∈ LS M q›] (*‹(?x, ?y) ∈ set ((x, y) # io') ⟹ ?y ∈ FSM.outputs M›*) by auto ultimately show "io ∈ list.set (language_for_input M q (x#xs))" unfolding language_for_input.simps Let_def (*goal: ‹io ∈ set (concat (map (λy. case FSM.h_obs M q x y of None ⇒ [] | Some q' ⇒ map ((#) (x, y)) (language_for_input M q' xs)) (outputs_as_list M)))›*) using scheme[of io "(λ y .(case h_obs M q x y of None ⇒ [] | Some q' ⇒ map ((#) (x,y)) (language_for_input M q' xs)))" y] (*‹⟦io ∈ set (case FSM.h_obs M q x y of None ⇒ [] | Some q' ⇒ map ((#) (x, y)) (language_for_input M q' xs)); y ∈ set ?xs⟧ ⟹ io ∈ set (concat (map (λy. case FSM.h_obs M q x y of None ⇒ [] | Some q' ⇒ map ((#) (x, y)) (language_for_input M q' xs)) ?xs))›*) by blast qed ultimately show "?case" (*goal: ‹set (language_for_input M q (x # xs)) = {io ∈ LS M q. map fst io = x # xs}›*) by blast qed subsection ‹Filtering Transitions› lift_definition filter_transitions :: "('a,'b,'c) fsm ⇒ (('a,'b,'c) transition ⇒ bool) ⇒ ('a,'b,'c) fsm" is FSM_Impl.filter_transitions proof - fix M :: "('a,'b,'c) fsm_impl" fix P :: "('a,'b,'c) transition ⇒ bool" assume "well_formed_fsm M" then show "well_formed_fsm (FSM_Impl.filter_transitions M P)" unfolding FSM_Impl.filter_transitions.simps by force qed lemma filter_transitions_simps[simp] : "initial (filter_transitions M P) = initial M" "states (filter_transitions M P) = states M" "inputs (filter_transitions M P) = inputs M" "outputs (filter_transitions M P) = outputs M" "transitions (filter_transitions M P) = {t ∈ transitions M . P t}" (*goals: 1. ‹FSM.initial (FSM.filter_transitions M P) = FSM.initial M› 2. ‹FSM.states (FSM.filter_transitions M P) = FSM.states M› 3. ‹FSM.inputs (FSM.filter_transitions M P) = FSM.inputs M› 4. ‹FSM.outputs (FSM.filter_transitions M P) = FSM.outputs M› 5. ‹FSM.transitions (FSM.filter_transitions M P) = {t ∈ FSM.transitions M. P t}› discuss goal 1*) apply ((transfer)[1]) (*top goal: ‹FSM.initial (FSM.filter_transitions M P) = FSM.initial M› and 4 goals remain*) apply ((auto)[1]) (*discuss goal 2*) apply ((transfer)[1]) (*top goal: ‹FSM.states (FSM.filter_transitions (M::('a::type, 'b::type, 'c::type) fsm) (P::'a::type × 'b::type × 'c::type × 'a::type ⇒ bool)) = FSM.states M› and 3 goals remain*) apply ((auto)[1]) (*discuss goal 3*) apply ((transfer)[1]) (*top goal: ‹FSM.inputs (FSM.filter_transitions M P) = FSM.inputs M› and 2 goals remain*) apply ((auto)[1]) (*discuss goal 4*) apply ((transfer)[1]) (*top goal: ‹FSM.outputs (FSM.filter_transitions M P) = FSM.outputs M› and 1 goal remains*) apply ((auto)[1]) (*discuss goal 5*) apply ((transfer)[1]) (*goal: ‹FSM.transitions (FSM.filter_transitions M P) = {t ∈ FSM.transitions M. P t}›*) apply ((auto)[1]) (*proven 5 subgoals*) . lemma filter_transitions_submachine : "is_submachine (filter_transitions M P) M" unfolding filter_transitions_simps (*goal: ‹is_submachine (FSM.filter_transitions M P) M›*) by fastforce lemma filter_transitions_path : assumes "path (filter_transitions M P) q p" shows "path M q p" using path_begin_state[OF assms] (*‹(q::'a) ∈ FSM.states (FSM.filter_transitions (M::('a, 'b, 'c) fsm) (P::'a × 'b × 'c × 'a ⇒ bool))›*) transition_subset_path[of "filter_transitions M P" M, OF _ assms] (*‹⟦FSM.transitions (FSM.filter_transitions (M::('a, 'b, 'c) fsm) (P::'a × 'b × 'c × 'a ⇒ bool)) ⊆ FSM.transitions M; (q::'a) ∈ FSM.states M⟧ ⟹ path M q (p::('a × 'b × 'c × 'a) list)›*) unfolding filter_transitions_simps (*goal: ‹path M q p›*) by blast lemma filter_transitions_reachable_states : assumes "q ∈ reachable_states (filter_transitions M P)" shows "q ∈ reachable_states M" using assms (*‹q ∈ reachable_states (FSM.filter_transitions M P)›*) unfolding reachable_states_def filter_transitions_simps (*goal: ‹(q::'a) ∈ {target (FSM.initial (M::('a, 'b, 'c) fsm)) p |p::('a × 'b × 'c × 'a) list. path M (FSM.initial M) p}›*) using filter_transitions_path[of M P "initial M"] (*‹path (FSM.filter_transitions M P) (FSM.initial M) ?p ⟹ path M (FSM.initial M) ?p›*) by blast subsection ‹Filtering States› lift_definition filter_states :: "('a,'b,'c) fsm ⇒ ('a ⇒ bool) ⇒ ('a,'b,'c) fsm" is FSM_Impl.filter_states proof - fix M :: "('a,'b,'c) fsm_impl" fix P :: "'a ⇒ bool" assume *: "well_formed_fsm M" then show "well_formed_fsm (FSM_Impl.filter_states M P)" by (cases "P (FSM_Impl.initial M)"; auto) qed lemma filter_states_simps[simp] : assumes "P (initial M)" shows "initial (filter_states M P) = initial M" "states (filter_states M P) = Set.filter P (states M)" "inputs (filter_states M P) = inputs M" "outputs (filter_states M P) = outputs M" "transitions (filter_states M P) = {t ∈ transitions M . P (t_source t) ∧ P (t_target t)}" using assms (*‹P (FSM.initial M)›*) apply - (*goals: 1. ‹(P::'a ⇒ bool) (FSM.initial (M::('a, 'b, 'c) fsm)) ⟹ FSM.initial (FSM.filter_states M P) = FSM.initial M› 2. ‹(P::'a ⇒ bool) (FSM.initial (M::('a, 'b, 'c) fsm)) ⟹ FSM.states (FSM.filter_states M P) = Set.filter P (FSM.states M)› 3. ‹(P::'a ⇒ bool) (FSM.initial (M::('a, 'b, 'c) fsm)) ⟹ FSM.inputs (FSM.filter_states M P) = FSM.inputs M› 4. ‹(P::'a ⇒ bool) (FSM.initial (M::('a, 'b, 'c) fsm)) ⟹ FSM.outputs (FSM.filter_states M P) = FSM.outputs M› 5. ‹(P::'a ⇒ bool) (FSM.initial (M::('a, 'b, 'c) fsm)) ⟹ FSM.transitions (FSM.filter_states M P) = {t::'a × 'b × 'c × 'a ∈ FSM.transitions M. P (t_source t) ∧ P (t_target t)}› discuss goal 1*) apply ((transfer)[1]) (*top goal: ‹P (FSM.initial M) ⟹ FSM.initial (FSM.filter_states M P) = FSM.initial M› and 4 goals remain*) apply ((auto)[1]) (*discuss goal 2*) apply ((transfer)[1]) (*top goal: ‹P (FSM.initial M) ⟹ FSM.states (FSM.filter_states M P) = Set.filter P (FSM.states M)› and 3 goals remain*) apply ((auto)[1]) (*discuss goal 3*) apply ((transfer)[1]) (*top goal: ‹(P::'a ⇒ bool) (FSM.initial (M::('a, 'b, 'c) fsm)) ⟹ FSM.inputs (FSM.filter_states M P) = FSM.inputs M› and 2 goals remain*) apply ((auto)[1]) (*discuss goal 4*) apply ((transfer)[1]) (*top goal: ‹P (FSM.initial M) ⟹ FSM.outputs (FSM.filter_states M P) = FSM.outputs M› and 1 goal remains*) apply ((auto)[1]) (*discuss goal 5*) apply ((transfer)[1]) (*goal: ‹P (FSM.initial M) ⟹ FSM.transitions (FSM.filter_states M P) = {t ∈ FSM.transitions M. P (t_source t) ∧ P (t_target t)}›*) apply ((auto)[1]) (*proven 5 subgoals*) . lemma filter_states_submachine : assumes "P (initial M)" shows "is_submachine (filter_states M P) M" using filter_states_simps[of P M, OF assms] (*‹FSM.initial (FSM.filter_states M P) = FSM.initial M› ‹FSM.states (FSM.filter_states M P) = Set.filter P (FSM.states M)› ‹FSM.inputs (FSM.filter_states (M::('a::type, 'b::type, 'c::type) fsm) (P::'a::type ⇒ bool)) = FSM.inputs M› ‹FSM.outputs (FSM.filter_states M P) = FSM.outputs M› ‹FSM.transitions (FSM.filter_states M P) = {t ∈ FSM.transitions M. P (t_source t) ∧ P (t_target t)}›*) by fastforce fun restrict_to_reachable_states :: "('a,'b,'c) fsm ⇒ ('a,'b,'c) fsm" where "restrict_to_reachable_states M = filter_states M (λ q . q ∈ reachable_states M)" lemma restrict_to_reachable_states_simps[simp] : shows "initial (restrict_to_reachable_states M) = initial M" "states (restrict_to_reachable_states M) = reachable_states M" "inputs (restrict_to_reachable_states M) = inputs M" "outputs (restrict_to_reachable_states M) = outputs M" "transitions (restrict_to_reachable_states M) = {t ∈ transitions M . (t_source t) ∈ reachable_states M}" proof (-) (*goals: 1. ‹FSM.initial (restrict_to_reachable_states M) = FSM.initial M› 2. ‹FSM.states (restrict_to_reachable_states M) = reachable_states M› 3. ‹FSM.inputs (restrict_to_reachable_states M) = FSM.inputs M› 4. ‹FSM.outputs (restrict_to_reachable_states M) = FSM.outputs M› 5. ‹FSM.transitions (restrict_to_reachable_states M) = {t ∈ FSM.transitions M. t_source t ∈ reachable_states M}›*) show "initial (restrict_to_reachable_states M) = initial M" "states (restrict_to_reachable_states M) = reachable_states M" "inputs (restrict_to_reachable_states M) = inputs M" "outputs (restrict_to_reachable_states M) = outputs M" using filter_states_simps[of "(λ q . q ∈ reachable_states M)", OF reachable_states_initial] (*‹FSM.initial (FSM.filter_states M (λq. q ∈ reachable_states M)) = FSM.initial M› ‹FSM.states (FSM.filter_states (M::('a, 'b, 'c) fsm) (λq::'a. q ∈ reachable_states M)) = Set.filter (λq::'a. q ∈ reachable_states M) (FSM.states M)› ‹FSM.inputs (FSM.filter_states M (λq. q ∈ reachable_states M)) = FSM.inputs M› ‹FSM.outputs (FSM.filter_states M (λq. q ∈ reachable_states M)) = FSM.outputs M› ‹FSM.transitions (FSM.filter_states M (λq. q ∈ reachable_states M)) = {t ∈ FSM.transitions M. t_source t ∈ reachable_states M ∧ t_target t ∈ reachable_states M}›*) using reachable_state_is_state[of _ M] (*‹?q ∈ reachable_states M ⟹ ?q ∈ FSM.states M›*) apply - (*goals: 1. ‹⟦FSM.initial (FSM.filter_states M (λq. q ∈ reachable_states M)) = FSM.initial M; FSM.states (FSM.filter_states M (λq. q ∈ reachable_states M)) = Set.filter (λq. q ∈ reachable_states M) (FSM.states M); FSM.inputs (FSM.filter_states M (λq. q ∈ reachable_states M)) = FSM.inputs M; FSM.outputs (FSM.filter_states M (λq. q ∈ reachable_states M)) = FSM.outputs M; FSM.transitions (FSM.filter_states M (λq. q ∈ reachable_states M)) = {t ∈ FSM.transitions M. t_source t ∈ reachable_states M ∧ t_target t ∈ reachable_states M}; ⋀q. q ∈ reachable_states M ⟹ q ∈ FSM.states M⟧ ⟹ FSM.initial (restrict_to_reachable_states M) = FSM.initial M› 2. ‹⟦FSM.initial (FSM.filter_states M (λq. q ∈ reachable_states M)) = FSM.initial M; FSM.states (FSM.filter_states M (λq. q ∈ reachable_states M)) = Set.filter (λq. q ∈ reachable_states M) (FSM.states M); FSM.inputs (FSM.filter_states M (λq. q ∈ reachable_states M)) = FSM.inputs M; FSM.outputs (FSM.filter_states M (λq. q ∈ reachable_states M)) = FSM.outputs M; FSM.transitions (FSM.filter_states M (λq. q ∈ reachable_states M)) = {t ∈ FSM.transitions M. t_source t ∈ reachable_states M ∧ t_target t ∈ reachable_states M}; ⋀q. q ∈ reachable_states M ⟹ q ∈ FSM.states M⟧ ⟹ FSM.states (restrict_to_reachable_states M) = reachable_states M› 3. ‹⟦FSM.initial (FSM.filter_states M (λq. q ∈ reachable_states M)) = FSM.initial M; FSM.states (FSM.filter_states M (λq. q ∈ reachable_states M)) = Set.filter (λq. q ∈ reachable_states M) (FSM.states M); FSM.inputs (FSM.filter_states M (λq. q ∈ reachable_states M)) = FSM.inputs M; FSM.outputs (FSM.filter_states M (λq. q ∈ reachable_states M)) = FSM.outputs M; FSM.transitions (FSM.filter_states M (λq. q ∈ reachable_states M)) = {t ∈ FSM.transitions M. t_source t ∈ reachable_states M ∧ t_target t ∈ reachable_states M}; ⋀q. q ∈ reachable_states M ⟹ q ∈ FSM.states M⟧ ⟹ FSM.inputs (restrict_to_reachable_states M) = FSM.inputs M› 4. ‹⟦FSM.initial (FSM.filter_states M (λq. q ∈ reachable_states M)) = FSM.initial M; FSM.states (FSM.filter_states M (λq. q ∈ reachable_states M)) = Set.filter (λq. q ∈ reachable_states M) (FSM.states M); FSM.inputs (FSM.filter_states M (λq. q ∈ reachable_states M)) = FSM.inputs M; FSM.outputs (FSM.filter_states M (λq. q ∈ reachable_states M)) = FSM.outputs M; FSM.transitions (FSM.filter_states M (λq. q ∈ reachable_states M)) = {t ∈ FSM.transitions M. t_source t ∈ reachable_states M ∧ t_target t ∈ reachable_states M}; ⋀q. q ∈ reachable_states M ⟹ q ∈ FSM.states M⟧ ⟹ FSM.outputs (restrict_to_reachable_states M) = FSM.outputs M› 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*) . have "transitions (restrict_to_reachable_states M) = {t ∈ transitions M. (t_source t) ∈ reachable_states M ∧ (t_target t) ∈ reachable_states M}" using filter_states_simps[of "(λ q . q ∈ reachable_states M)", OF reachable_states_initial] (*‹FSM.initial (FSM.filter_states M (λq. q ∈ reachable_states M)) = FSM.initial M› ‹FSM.states (FSM.filter_states M (λq. q ∈ reachable_states M)) = Set.filter (λq. q ∈ reachable_states M) (FSM.states M)› ‹FSM.inputs (FSM.filter_states (M::('a, 'b, 'c) fsm) (λq::'a. q ∈ reachable_states M)) = FSM.inputs M› ‹FSM.outputs (FSM.filter_states M (λq. q ∈ reachable_states M)) = FSM.outputs M› ‹FSM.transitions (FSM.filter_states (M::('a, 'b, 'c) fsm) (λq::'a. q ∈ reachable_states M)) = {t::'a × 'b × 'c × 'a ∈ FSM.transitions M. t_source t ∈ reachable_states M ∧ t_target t ∈ reachable_states M}›*) by auto then show "transitions (restrict_to_reachable_states M) = {t ∈ transitions M . (t_source t) ∈ reachable_states M}" using reachable_states_next[of _ M] (*‹⟦?q ∈ reachable_states M; ?t ∈ FSM.transitions M; t_source ?t = ?q⟧ ⟹ t_target ?t ∈ reachable_states M›*) by auto qed lemma restrict_to_reachable_states_path : assumes "q ∈ reachable_states M" shows "path M q p = path (restrict_to_reachable_states M) q p" proof (standard) (*goals: 1. ‹path M q p ⟹ path (restrict_to_reachable_states M) q p› 2. ‹path (restrict_to_reachable_states M) q p ⟹ path M q p›*) show "path M q p ⟹ path (restrict_to_reachable_states M) q p" proof (-) (*goal: ‹path (M::('a::type, 'b::type, 'c::type) fsm) (q::'a::type) (p::('a::type × 'b::type × 'c::type × 'a::type) list) ⟹ path (restrict_to_reachable_states M) q p›*) assume "path M q p" (*‹path (M::('a, 'b, 'c) fsm) (q::'a) (p::('a × 'b × 'c × 'a) list)›*) then show "path (restrict_to_reachable_states M) q p" using assms (*‹q ∈ reachable_states M›*) proof (induction p arbitrary: q rule: list.induct) (*goals: 1. ‹⋀q. ⟦path M q []; q ∈ reachable_states M⟧ ⟹ path (restrict_to_reachable_states M) q []› 2. ‹⋀x1 x2 q. ⟦⋀q. ⟦path M q x2; q ∈ reachable_states M⟧ ⟹ path (restrict_to_reachable_states M) q x2; path M q (x1 # x2); q ∈ reachable_states M⟧ ⟹ path (restrict_to_reachable_states M) q (x1 # x2)›*) case Nil (*‹path M q []› ‹q ∈ reachable_states M›*) then show "?case" (*goal: ‹path (restrict_to_reachable_states M) q []›*) using restrict_to_reachable_states_simps(2) (*‹FSM.states (restrict_to_reachable_states (?M::(?'a, ?'b, ?'c) fsm)) = reachable_states ?M›*) by fastforce next (*goal: ‹⋀x1 x2 q. ⟦⋀q. ⟦path M q x2; q ∈ reachable_states M⟧ ⟹ path (restrict_to_reachable_states M) q x2; path M q (x1 # x2); q ∈ reachable_states M⟧ ⟹ path (restrict_to_reachable_states M) q (x1 # x2)›*) case (Cons t' p') (*‹⟦path M ?q p'; ?q ∈ reachable_states M⟧ ⟹ path (restrict_to_reachable_states M) ?q p'› ‹path M q (t' # p')› ‹(q::'a) ∈ reachable_states (M::('a, 'b, 'c) fsm)›*) then have "path M (t_target t') p'" by auto moreover have "t_target t' ∈ reachable_states M" using Cons.prems (*‹path M q (t' # p')› ‹q ∈ reachable_states M›*) by (metis path_cons_elim (*‹⟦path (?M::(?'a::type, ?'b::type, ?'c::type) fsm) (?q::?'a::type) ((?t::?'a::type × ?'b::type × ?'c::type × ?'a::type) # (?ts::(?'a::type × ?'b::type × ?'c::type × ?'a::type) list)); ⟦?q = t_source ?t; ?t ∈ FSM.transitions ?M; path ?M (t_target ?t) ?ts⟧ ⟹ ?P::bool⟧ ⟹ ?P›*) reachable_states_next (*‹⟦(?q::?'a::type) ∈ reachable_states (?M::(?'a::type, ?'b::type, ?'c::type) fsm); (?t::?'a::type × ?'b::type × ?'c::type × ?'a::type) ∈ FSM.transitions ?M; t_source ?t = ?q⟧ ⟹ t_target ?t ∈ reachable_states ?M›*)) ultimately show "?case" (*goal: ‹path (restrict_to_reachable_states M) q (t' # p')›*) using Cons.IH (*‹⟦path M ?q p'; ?q ∈ reachable_states M⟧ ⟹ path (restrict_to_reachable_states M) ?q p'›*) by (metis (no_types, lifting) Cons.prems( (*‹path M q (t' # p')›*) 1) Cons.prems( (*‹q ∈ reachable_states M›*) 2) mem_Collect_eq (*‹(?a ∈ Collect ?P) = ?P ?a›*) path.simps (*‹path ?a1.0 ?a2.0 ?a3.0 = ((∃q M. ?a1.0 = M ∧ ?a2.0 = q ∧ ?a3.0 = [] ∧ q ∈ FSM.states M) ∨ (∃t M ts. ?a1.0 = M ∧ ?a2.0 = t_source t ∧ ?a3.0 = t # ts ∧ t ∈ FSM.transitions M ∧ path M (t_target t) ts))›*) path_cons_elim (*‹⟦path ?M ?q (?t # ?ts); ⟦?q = t_source ?t; ?t ∈ FSM.transitions ?M; path ?M (t_target ?t) ?ts⟧ ⟹ ?P⟧ ⟹ ?P›*) restrict_to_reachable_states_simps( (*‹FSM.transitions (restrict_to_reachable_states ?M) = {t ∈ FSM.transitions ?M. t_source t ∈ reachable_states ?M}›*) 5)) qed qed show "path (restrict_to_reachable_states M) q p ⟹ path M q p" by (metis (no_types, lifting) assms (*‹(q::'a::type) ∈ reachable_states (M::('a::type, 'b::type, 'c::type) fsm)›*) mem_Collect_eq (*‹((?a::?'a::type) ∈ Collect (?P::?'a::type ⇒ bool)) = ?P ?a›*) reachable_state_is_state (*‹(?q::?'a::type) ∈ reachable_states (?M::(?'a::type, ?'b::type, ?'c::type) fsm) ⟹ ?q ∈ FSM.states ?M›*) restrict_to_reachable_states_simps( (*‹FSM.transitions (restrict_to_reachable_states (?M::(?'a::type, ?'b::type, ?'c::type) fsm)) = {t::?'a::type × ?'b::type × ?'c::type × ?'a::type ∈ FSM.transitions ?M. t_source t ∈ reachable_states ?M}›*) 5) subsetI (*‹(⋀x::?'a::type. x ∈ (?A::?'a::type set) ⟹ x ∈ (?B::?'a::type set)) ⟹ ?A ⊆ ?B›*) transition_subset_path (*‹⟦FSM.transitions (?A::(?'a::type, ?'b::type, ?'c::type) fsm) ⊆ FSM.transitions (?B::(?'a::type, ?'b::type, ?'c::type) fsm); path ?A (?q::?'a::type) (?p::(?'a::type × ?'b::type × ?'c::type × ?'a::type) list); ?q ∈ FSM.states ?B⟧ ⟹ path ?B ?q ?p›*)) qed lemma restrict_to_reachable_states_language : "L (restrict_to_reachable_states M) = L M" unfolding LS.simps (*goal: ‹{p_io p |p. path (restrict_to_reachable_states M) (FSM.initial (restrict_to_reachable_states M)) p} = {p_io p |p. path M (FSM.initial M) p}›*) unfolding restrict_to_reachable_states_simps (*goal: ‹{p_io p |p. path (restrict_to_reachable_states M) (FSM.initial M) p} = {p_io p |p. path M (FSM.initial M) p}›*) unfolding restrict_to_reachable_states_path[OF reachable_states_initial, of M] (*goal: ‹{p_io p |p. path (restrict_to_reachable_states M) (FSM.initial M) p} = {p_io p |p. path (restrict_to_reachable_states M) (FSM.initial M) p}›*) by blast lemma restrict_to_reachable_states_observable : assumes "observable M" shows "observable (restrict_to_reachable_states M)" using assms (*‹observable M›*) unfolding observable.simps (*goal: ‹∀t1∈FSM.transitions (restrict_to_reachable_states M). ∀t2∈FSM.transitions (restrict_to_reachable_states M). t_source t1 = t_source t2 ∧ t_input t1 = t_input t2 ∧ t_output t1 = t_output t2 ⟶ t_target t1 = t_target t2›*) unfolding restrict_to_reachable_states_simps (*goal: ‹∀t1∈{t ∈ FSM.transitions M. t_source t ∈ reachable_states M}. ∀t2∈{t ∈ FSM.transitions M. t_source t ∈ reachable_states M}. t_source t1 = t_source t2 ∧ t_input t1 = t_input t2 ∧ t_output t1 = t_output t2 ⟶ t_target t1 = t_target t2›*) by blast lemma restrict_to_reachable_states_minimal : assumes "minimal M" shows "minimal (restrict_to_reachable_states M)" proof (-) (*goal: ‹minimal (restrict_to_reachable_states M)›*) have "⋀ q1 q2 . q1 ∈ reachable_states M ⟹ q2 ∈ reachable_states M ⟹ q1 ≠ q2 ⟹ LS (restrict_to_reachable_states M) q1 ≠ LS (restrict_to_reachable_states M) q2" proof (-) (*goal: ‹⋀(q1::'a) q2::'a. ⟦q1 ∈ reachable_states (M::('a, 'b, 'c) fsm); q2 ∈ reachable_states M; q1 ≠ q2⟧ ⟹ LS (restrict_to_reachable_states M) q1 ≠ LS (restrict_to_reachable_states M) q2›*) fix q1 and q2 assume "q1 ∈ reachable_states M" and "q2 ∈ reachable_states M" and "q1 ≠ q2" (*‹(q1::'a) ∈ reachable_states (M::('a, 'b, 'c) fsm)› ‹(q2::'a) ∈ reachable_states (M::('a, 'b, 'c) fsm)› ‹(q1::'a) ≠ (q2::'a)›*) then have "q1 ∈ states M" and "q2 ∈ states M" apply - (*goals: 1. ‹⟦q1 ∈ reachable_states M; q2 ∈ reachable_states M; q1 ≠ q2⟧ ⟹ q1 ∈ FSM.states M› 2. ‹⟦q1 ∈ reachable_states M; q2 ∈ reachable_states M; q1 ≠ q2⟧ ⟹ q2 ∈ FSM.states M› discuss goal 1*) apply (simp add: reachable_state_is_state (*‹?q ∈ reachable_states ?M ⟹ ?q ∈ FSM.states ?M›*)) (*discuss goal 2*) apply (simp add: reachable_state_is_state (*‹?q ∈ reachable_states ?M ⟹ ?q ∈ FSM.states ?M›*)) (*proven 2 subgoals*) . then have "LS M q1 ≠ LS M q2" using ‹q1 ≠ q2› (*‹q1 ≠ q2›*) assms (*‹minimal M›*) by auto then show "LS (restrict_to_reachable_states M) q1 ≠ LS (restrict_to_reachable_states M) q2" unfolding LS.simps (*goal: ‹{p_io p |p. path (restrict_to_reachable_states M) q1 p} ≠ {p_io p |p. path (restrict_to_reachable_states M) q2 p}›*) unfolding restrict_to_reachable_states_path[OF ‹q1 ∈ reachable_states M›] (*goal: ‹{p_io p |p. path (restrict_to_reachable_states M) q1 p} ≠ {p_io p |p. path (restrict_to_reachable_states M) q2 p}›*) unfolding restrict_to_reachable_states_path[OF ‹q2 ∈ reachable_states M›] (*goal: ‹{p_io p |p. path (restrict_to_reachable_states M) q1 p} ≠ {p_io p |p. path (restrict_to_reachable_states M) q2 p}›*) . qed then show "?thesis" (*goal: ‹minimal (restrict_to_reachable_states M)›*) unfolding minimal.simps restrict_to_reachable_states_simps (*goal: ‹∀q∈reachable_states M. ∀q'∈reachable_states M. q ≠ q' ⟶ LS (restrict_to_reachable_states M) q ≠ LS (restrict_to_reachable_states M) q'›*) by blast qed lemma restrict_to_reachable_states_reachable_states : "reachable_states (restrict_to_reachable_states M) = states (restrict_to_reachable_states M)" proof (standard) (*goals: 1. ‹reachable_states (restrict_to_reachable_states M) ⊆ FSM.states (restrict_to_reachable_states M)› 2. ‹FSM.states (restrict_to_reachable_states M) ⊆ reachable_states (restrict_to_reachable_states M)›*) show "reachable_states (restrict_to_reachable_states M) ⊆ states (restrict_to_reachable_states M)" by (simp add: reachable_state_is_state (*‹(?q::?'a) ∈ reachable_states (?M::(?'a, ?'b, ?'c) fsm) ⟹ ?q ∈ FSM.states ?M›*) subsetI (*‹(⋀x::?'a. x ∈ (?A::?'a set) ⟹ x ∈ (?B::?'a set)) ⟹ ?A ⊆ ?B›*)) show "states (restrict_to_reachable_states M) ⊆ reachable_states (restrict_to_reachable_states M)" proof (standard) (*goal: ‹⋀x::'a::type. x ∈ FSM.states (restrict_to_reachable_states (M::('a::type, 'b::type, 'c::type) fsm)) ⟹ x ∈ reachable_states (restrict_to_reachable_states M)›*) fix q assume "q ∈ states (restrict_to_reachable_states M)" (*‹(q::'a) ∈ FSM.states (restrict_to_reachable_states (M::('a, 'b, 'c) fsm))›*) then have "q ∈ reachable_states M" unfolding restrict_to_reachable_states_simps (*goal: ‹q ∈ reachable_states M›*) . then show "q ∈ reachable_states (restrict_to_reachable_states M)" unfolding reachable_states_def (*goal: ‹q ∈ {target (FSM.initial (restrict_to_reachable_states M)) p |p. path (restrict_to_reachable_states M) (FSM.initial (restrict_to_reachable_states M)) p}›*) unfolding restrict_to_reachable_states_simps (*goal: ‹(q::'a::type) ∈ {target (FSM.initial (M::('a::type, 'b::type, 'c::type) fsm)) p |p::('a::type × 'b::type × 'c::type × 'a::type) list. path (restrict_to_reachable_states M) (FSM.initial M) p}›*) unfolding restrict_to_reachable_states_path[OF reachable_states_initial, symmetric] (*goal: ‹q ∈ {target (FSM.initial M) p |p. path M (FSM.initial M) p}›*) . qed qed subsection ‹Adding Transitions› lift_definition create_unconnected_fsm :: "'a ⇒ 'a set ⇒ 'b set ⇒ 'c set ⇒ ('a,'b,'c) fsm" is FSM_Impl.create_unconnected_FSMI by (transfer; simp) lemma create_unconnected_fsm_simps : assumes "finite ns" and "finite ins" and "finite outs" and "q ∈ ns" shows "initial (create_unconnected_fsm q ns ins outs) = q" "states (create_unconnected_fsm q ns ins outs) = ns" "inputs (create_unconnected_fsm q ns ins outs) = ins" "outputs (create_unconnected_fsm q ns ins outs) = outs" "transitions (create_unconnected_fsm q ns ins outs) = {}" using assms (*‹finite (ns::'a::type set)› ‹finite (ins::'b set)› ‹finite (outs::'c::type set)› ‹(q::'a::type) ∈ (ns::'a::type set)›*) apply - (*goals: 1. ‹⟦finite (ns::'a set); finite (ins::'b set); finite (outs::'c set); (q::'a) ∈ ns⟧ ⟹ FSM.initial (create_unconnected_fsm q ns ins outs) = q› 2. ‹⟦finite (ns::'a set); finite (ins::'b set); finite (outs::'c set); (q::'a) ∈ ns⟧ ⟹ FSM.states (create_unconnected_fsm q ns ins outs) = ns› 3. ‹⟦finite (ns::'a set); finite (ins::'b set); finite (outs::'c set); (q::'a) ∈ ns⟧ ⟹ FSM.inputs (create_unconnected_fsm q ns ins outs) = ins› 4. ‹⟦finite (ns::'a set); finite (ins::'b set); finite (outs::'c set); (q::'a) ∈ ns⟧ ⟹ FSM.outputs (create_unconnected_fsm q ns ins outs) = outs› 5. ‹⟦finite (ns::'a set); finite (ins::'b set); finite (outs::'c set); (q::'a) ∈ ns⟧ ⟹ FSM.transitions (create_unconnected_fsm q ns ins outs) = {}› discuss goal 1*) apply ((transfer)[1]) (*top goal: ‹⟦finite ns; finite ins; finite outs; q ∈ ns⟧ ⟹ FSM.initial (create_unconnected_fsm q ns ins outs) = q› and 4 goals remain*) apply ((auto)[1]) (*discuss goal 2*) apply ((transfer)[1]) (*top goal: ‹⟦finite ns; finite ins; finite outs; q ∈ ns⟧ ⟹ FSM.states (create_unconnected_fsm q ns ins outs) = ns› and 3 goals remain*) apply ((auto)[1]) (*discuss goal 3*) apply ((transfer)[1]) (*top goal: ‹⟦finite ns; finite ins; finite outs; q ∈ ns⟧ ⟹ FSM.inputs (create_unconnected_fsm q ns ins outs) = ins› and 2 goals remain*) apply ((auto)[1]) (*discuss goal 4*) apply ((transfer)[1]) (*top goal: ‹⟦finite (ns::'a set); finite (ins::'b set); finite (outs::'c set); (q::'a) ∈ ns⟧ ⟹ FSM.outputs (create_unconnected_fsm q ns ins outs) = outs› and 1 goal remains*) apply ((auto)[1]) (*discuss goal 5*) apply ((transfer)[1]) (*goal: ‹⟦finite ns; finite ins; finite outs; q ∈ ns⟧ ⟹ FSM.transitions (create_unconnected_fsm q ns ins outs) = {}›*) apply ((auto)[1]) (*proven 5 subgoals*) . lift_definition create_unconnected_fsm_from_lists :: "'a ⇒ 'a list ⇒ 'b list ⇒ 'c list ⇒ ('a,'b,'c) fsm" is FSM_Impl.create_unconnected_fsm_from_lists by (transfer; simp) lemma create_unconnected_fsm_from_lists_simps : assumes "q ∈ set ns" shows "initial (create_unconnected_fsm_from_lists q ns ins outs) = q" "states (create_unconnected_fsm_from_lists q ns ins outs) = set ns" "inputs (create_unconnected_fsm_from_lists q ns ins outs) = set ins" "outputs (create_unconnected_fsm_from_lists q ns ins outs) = set outs" "transitions (create_unconnected_fsm_from_lists q ns ins outs) = {}" using assms (*‹q ∈ set ns›*) apply - (*goals: 1. ‹q ∈ set ns ⟹ FSM.initial (FSM.create_unconnected_fsm_from_lists q ns ins outs) = q› 2. ‹q ∈ set ns ⟹ FSM.states (FSM.create_unconnected_fsm_from_lists q ns ins outs) = set ns› 3. ‹q ∈ set ns ⟹ FSM.inputs (FSM.create_unconnected_fsm_from_lists q ns ins outs) = set ins› 4. ‹q ∈ set ns ⟹ FSM.outputs (FSM.create_unconnected_fsm_from_lists q ns ins outs) = set outs› 5. ‹q ∈ set ns ⟹ FSM.transitions (FSM.create_unconnected_fsm_from_lists q ns ins outs) = {}› discuss goal 1*) apply ((transfer)[1]) (*top goal: ‹q ∈ set ns ⟹ FSM.initial (FSM.create_unconnected_fsm_from_lists q ns ins outs) = q› and 4 goals remain*) apply ((auto)[1]) (*discuss goal 2*) apply ((transfer)[1]) (*top goal: ‹q ∈ set ns ⟹ FSM.states (FSM.create_unconnected_fsm_from_lists q ns ins outs) = set ns› and 3 goals remain*) apply ((auto)[1]) (*discuss goal 3*) apply ((transfer)[1]) (*top goal: ‹q ∈ set ns ⟹ FSM.inputs (FSM.create_unconnected_fsm_from_lists q ns ins outs) = set ins› and 2 goals remain*) apply ((auto)[1]) (*discuss goal 4*) apply ((transfer)[1]) (*top goal: ‹q ∈ set ns ⟹ FSM.outputs (FSM.create_unconnected_fsm_from_lists q ns ins outs) = set outs› and 1 goal remains*) apply ((auto)[1]) (*discuss goal 5*) apply ((transfer)[1]) (*goal: ‹q ∈ set ns ⟹ FSM.transitions (FSM.create_unconnected_fsm_from_lists q ns ins outs) = {}›*) apply ((auto)[1]) (*proven 5 subgoals*) . lift_definition create_unconnected_fsm_from_fsets :: "'a ⇒ 'a fset ⇒ 'b fset ⇒ 'c fset ⇒ ('a,'b,'c) fsm" is FSM_Impl.create_unconnected_fsm_from_fsets by (transfer; simp) lemma create_unconnected_fsm_from_fsets_simps : assumes "q |∈| ns" shows "initial (create_unconnected_fsm_from_fsets q ns ins outs) = q" "states (create_unconnected_fsm_from_fsets q ns ins outs) = fset ns" "inputs (create_unconnected_fsm_from_fsets q ns ins outs) = fset ins" "outputs (create_unconnected_fsm_from_fsets q ns ins outs) = fset outs" "transitions (create_unconnected_fsm_from_fsets q ns ins outs) = {}" using assms (*‹q |∈| ns›*) apply - (*goals: 1. ‹q |∈| ns ⟹ FSM.initial (FSM.create_unconnected_fsm_from_fsets q ns ins outs) = q› 2. ‹q |∈| ns ⟹ FSM.states (FSM.create_unconnected_fsm_from_fsets q ns ins outs) = fset ns› 3. ‹q |∈| ns ⟹ FSM.inputs (FSM.create_unconnected_fsm_from_fsets q ns ins outs) = fset ins› 4. ‹q |∈| ns ⟹ FSM.outputs (FSM.create_unconnected_fsm_from_fsets q ns ins outs) = fset outs› 5. ‹q |∈| ns ⟹ FSM.transitions (FSM.create_unconnected_fsm_from_fsets q ns ins outs) = {}› discuss goal 1*) apply ((transfer)[1]) (*top goal: ‹q |∈| ns ⟹ FSM.initial (FSM.create_unconnected_fsm_from_fsets q ns ins outs) = q› and 4 goals remain*) apply ((auto)[1]) (*discuss goal 2*) apply ((transfer)[1]) (*top goal: ‹(q::'a) |∈| (ns::'a fset) ⟹ FSM.states (FSM.create_unconnected_fsm_from_fsets q ns (ins::'b fset) (outs::'c fset)) = fset ns› and 3 goals remain*) apply ((auto)[1]) (*discuss goal 3*) apply ((transfer)[1]) (*top goal: ‹(q::'a) |∈| (ns::'a fset) ⟹ FSM.inputs (FSM.create_unconnected_fsm_from_fsets q ns (ins::'b fset) (outs::'c fset)) = fset ins› and 2 goals remain*) apply ((auto)[1]) (*discuss goal 4*) apply ((transfer)[1]) (*top goal: ‹q |∈| ns ⟹ FSM.outputs (FSM.create_unconnected_fsm_from_fsets q ns ins outs) = fset outs› and 1 goal remains*) apply ((auto)[1]) (*discuss goal 5*) apply ((transfer)[1]) (*goal: ‹q |∈| ns ⟹ FSM.transitions (FSM.create_unconnected_fsm_from_fsets q ns ins outs) = {}›*) apply ((auto)[1]) (*proven 5 subgoals*) . lift_definition add_transitions :: "('a,'b,'c) fsm ⇒ ('a,'b,'c) transition set ⇒ ('a,'b,'c) fsm" is FSM_Impl.add_transitions proof - fix M :: "('a,'b,'c) fsm_impl" fix ts :: "('a,'b,'c) transition set" assume *: "well_formed_fsm M" then show "well_formed_fsm (FSM_Impl.add_transitions M ts)" proof (cases "∀ t ∈ ts . t_source t ∈ FSM_Impl.states M ∧ t_input t ∈ FSM_Impl.inputs M ∧ t_output t ∈ FSM_Impl.outputs M ∧ t_target t ∈ FSM_Impl.states M") case True then have "ts ⊆ FSM_Impl.states M × FSM_Impl.inputs M × FSM_Impl.outputs M × FSM_Impl.states M" by fastforce moreover have "finite (FSM_Impl.states M × FSM_Impl.inputs M × FSM_Impl.outputs M × FSM_Impl.states M)" using * by blast ultimately have "finite ts" using rev_finite_subset by auto then show ?thesis using * by auto next case False then show ?thesis using * by auto qed qed lemma add_transitions_simps : assumes "⋀ t . t ∈ ts ⟹ t_source t ∈ states M ∧ t_input t ∈ inputs M ∧ t_output t ∈ outputs M ∧ t_target t ∈ states M" shows "initial (add_transitions M ts) = initial M" "states (add_transitions M ts) = states M" "inputs (add_transitions M ts) = inputs M" "outputs (add_transitions M ts) = outputs M" "transitions (add_transitions M ts) = transitions M ∪ ts" using assms (*‹?t ∈ ts ⟹ t_source ?t ∈ FSM.states M ∧ t_input ?t ∈ FSM.inputs M ∧ t_output ?t ∈ FSM.outputs M ∧ t_target ?t ∈ FSM.states M›*) apply - (*goals: 1. ‹(⋀t. t ∈ ts ⟹ t_source t ∈ FSM.states M ∧ t_input t ∈ FSM.inputs M ∧ t_output t ∈ FSM.outputs M ∧ t_target t ∈ FSM.states M) ⟹ FSM.initial (FSM.add_transitions M ts) = FSM.initial M› 2. ‹(⋀t. t ∈ ts ⟹ t_source t ∈ FSM.states M ∧ t_input t ∈ FSM.inputs M ∧ t_output t ∈ FSM.outputs M ∧ t_target t ∈ FSM.states M) ⟹ FSM.states (FSM.add_transitions M ts) = FSM.states M› 3. ‹(⋀t. t ∈ ts ⟹ t_source t ∈ FSM.states M ∧ t_input t ∈ FSM.inputs M ∧ t_output t ∈ FSM.outputs M ∧ t_target t ∈ FSM.states M) ⟹ FSM.inputs (FSM.add_transitions M ts) = FSM.inputs M› 4. ‹(⋀t. t ∈ ts ⟹ t_source t ∈ FSM.states M ∧ t_input t ∈ FSM.inputs M ∧ t_output t ∈ FSM.outputs M ∧ t_target t ∈ FSM.states M) ⟹ FSM.outputs (FSM.add_transitions M ts) = FSM.outputs M› 5. ‹(⋀t. t ∈ ts ⟹ t_source t ∈ FSM.states M ∧ t_input t ∈ FSM.inputs M ∧ t_output t ∈ FSM.outputs M ∧ t_target t ∈ FSM.states M) ⟹ FSM.transitions (FSM.add_transitions M ts) = FSM.transitions M ∪ ts› discuss goal 1*) apply ((transfer)[1]) (*top goal: ‹(⋀t::'a × 'b × 'c × 'a. t ∈ (ts::('a × 'b × 'c × 'a) set) ⟹ t_source t ∈ FSM.states (M::('a, 'b, 'c) fsm) ∧ t_input t ∈ FSM.inputs M ∧ t_output t ∈ FSM.outputs M ∧ t_target t ∈ FSM.states M) ⟹ FSM.initial (FSM.add_transitions M ts) = FSM.initial M› and 4 goals remain*) apply ((auto)[1]) (*discuss goal 2*) apply ((transfer)[1]) (*top goal: ‹(⋀t. t ∈ ts ⟹ t_source t ∈ FSM.states M ∧ t_input t ∈ FSM.inputs M ∧ t_output t ∈ FSM.outputs M ∧ t_target t ∈ FSM.states M) ⟹ FSM.states (FSM.add_transitions M ts) = FSM.states M› and 3 goals remain*) apply ((auto)[1]) (*discuss goal 3*) apply ((transfer)[1]) (*top goal: ‹(⋀t. t ∈ ts ⟹ t_source t ∈ FSM.states M ∧ t_input t ∈ FSM.inputs M ∧ t_output t ∈ FSM.outputs M ∧ t_target t ∈ FSM.states M) ⟹ FSM.inputs (FSM.add_transitions M ts) = FSM.inputs M› and 2 goals remain*) apply ((auto)[1]) (*discuss goal 4*) apply ((transfer)[1]) (*top goal: ‹(⋀t::'a × 'b × 'c × 'a. t ∈ (ts::('a × 'b × 'c × 'a) set) ⟹ t_source t ∈ FSM.states (M::('a, 'b, 'c) fsm) ∧ t_input t ∈ FSM.inputs M ∧ t_output t ∈ FSM.outputs M ∧ t_target t ∈ FSM.states M) ⟹ FSM.outputs (FSM.add_transitions M ts) = FSM.outputs M› and 1 goal remains*) apply ((auto)[1]) (*discuss goal 5*) apply ((transfer)[1]) (*goal: ‹(⋀t. t ∈ ts ⟹ t_source t ∈ FSM.states M ∧ t_input t ∈ FSM.inputs M ∧ t_output t ∈ FSM.outputs M ∧ t_target t ∈ FSM.states M) ⟹ FSM.transitions (FSM.add_transitions M ts) = FSM.transitions M ∪ ts›*) apply ((auto)[1]) (*proven 5 subgoals*) . lift_definition create_fsm_from_sets :: "'a ⇒ 'a set ⇒ 'b set ⇒ 'c set ⇒ ('a,'b,'c) transition set ⇒ ('a,'b,'c) fsm" is FSM_Impl.create_fsm_from_sets proof - fix q :: 'a fix qs :: "'a set" fix ins :: "'b set" fix outs :: "'c set" fix ts :: "('a,'b,'c) transition set" show "well_formed_fsm (FSM_Impl.create_fsm_from_sets q qs ins outs ts)" proof (cases "q ∈ qs ∧ finite qs ∧ finite ins ∧ finite outs") case True let ?M = "(FSMI q qs ins outs {})" show ?thesis proof (cases "∀ t ∈ ts . t_source t ∈ FSM_Impl.states ?M ∧ t_input t ∈ FSM_Impl.inputs ?M ∧ t_output t ∈ FSM_Impl.outputs ?M ∧ t_target t ∈ FSM_Impl.states ?M") case True then have "ts ⊆ FSM_Impl.states ?M × FSM_Impl.inputs ?M × FSM_Impl.outputs ?M × FSM_Impl.states ?M" by fastforce moreover have "finite (FSM_Impl.states ?M × FSM_Impl.inputs ?M × FSM_Impl.outputs ?M × FSM_Impl.states ?M)" using ‹q ∈ qs ∧ finite qs ∧ finite ins ∧ finite outs› by force ultimately have "finite ts" using rev_finite_subset by auto then show ?thesis by auto next case False then show ?thesis by auto qed next case False then show ?thesis by auto qed qed lemma create_fsm_from_sets_simps : assumes "q ∈ qs" and "finite qs" and "finite ins" and "finite outs" assumes "⋀ t . t ∈ ts ⟹ t_source t ∈ qs ∧ t_input t ∈ ins ∧ t_output t ∈ outs ∧ t_target t ∈ qs" shows "initial (create_fsm_from_sets q qs ins outs ts) = q" "states (create_fsm_from_sets q qs ins outs ts) = qs" "inputs (create_fsm_from_sets q qs ins outs ts) = ins" "outputs (create_fsm_from_sets q qs ins outs ts) = outs" "transitions (create_fsm_from_sets q qs ins outs ts) = ts" using assms (*‹q ∈ qs› ‹finite qs› ‹finite ins› ‹finite outs› ‹?t ∈ ts ⟹ t_source ?t ∈ qs ∧ t_input ?t ∈ ins ∧ t_output ?t ∈ outs ∧ t_target ?t ∈ qs›*) apply - (*goals: 1. ‹⟦q ∈ qs; finite qs; finite ins; finite outs; ⋀t. t ∈ ts ⟹ t_source t ∈ qs ∧ t_input t ∈ ins ∧ t_output t ∈ outs ∧ t_target t ∈ qs⟧ ⟹ FSM.initial (FSM.create_fsm_from_sets q qs ins outs ts) = q› 2. ‹⟦q ∈ qs; finite qs; finite ins; finite outs; ⋀t. t ∈ ts ⟹ t_source t ∈ qs ∧ t_input t ∈ ins ∧ t_output t ∈ outs ∧ t_target t ∈ qs⟧ ⟹ FSM.states (FSM.create_fsm_from_sets q qs ins outs ts) = qs› 3. ‹⟦q ∈ qs; finite qs; finite ins; finite outs; ⋀t. t ∈ ts ⟹ t_source t ∈ qs ∧ t_input t ∈ ins ∧ t_output t ∈ outs ∧ t_target t ∈ qs⟧ ⟹ FSM.inputs (FSM.create_fsm_from_sets q qs ins outs ts) = ins› 4. ‹⟦q ∈ qs; finite qs; finite ins; finite outs; ⋀t. t ∈ ts ⟹ t_source t ∈ qs ∧ t_input t ∈ ins ∧ t_output t ∈ outs ∧ t_target t ∈ qs⟧ ⟹ FSM.outputs (FSM.create_fsm_from_sets q qs ins outs ts) = outs› 5. ‹⟦q ∈ qs; finite qs; finite ins; finite outs; ⋀t. t ∈ ts ⟹ t_source t ∈ qs ∧ t_input t ∈ ins ∧ t_output t ∈ outs ∧ t_target t ∈ qs⟧ ⟹ FSM.transitions (FSM.create_fsm_from_sets q qs ins outs ts) = ts› discuss goal 1*) apply ((transfer)[1]) (*top goal: ‹⟦q ∈ qs; finite qs; finite ins; finite outs; ⋀t. t ∈ ts ⟹ t_source t ∈ qs ∧ t_input t ∈ ins ∧ t_output t ∈ outs ∧ t_target t ∈ qs⟧ ⟹ FSM.initial (FSM.create_fsm_from_sets q qs ins outs ts) = q› and 4 goals remain*) apply ((auto)[1]) (*discuss goal 2*) apply ((transfer)[1]) (*top goal: ‹⟦q ∈ qs; finite qs; finite ins; finite outs; ⋀t. t ∈ ts ⟹ t_source t ∈ qs ∧ t_input t ∈ ins ∧ t_output t ∈ outs ∧ t_target t ∈ qs⟧ ⟹ FSM.states (FSM.create_fsm_from_sets q qs ins outs ts) = qs› and 3 goals remain*) apply ((auto)[1]) (*discuss goal 3*) apply ((transfer)[1]) (*top goal: ‹⟦q ∈ qs; finite qs; finite ins; finite outs; ⋀t. t ∈ ts ⟹ t_source t ∈ qs ∧ t_input t ∈ ins ∧ t_output t ∈ outs ∧ t_target t ∈ qs⟧ ⟹ FSM.inputs (FSM.create_fsm_from_sets q qs ins outs ts) = ins› and 2 goals remain*) apply ((auto)[1]) (*discuss goal 4*) apply ((transfer)[1]) (*top goal: ‹⟦q ∈ qs; finite qs; finite ins; finite outs; ⋀t. t ∈ ts ⟹ t_source t ∈ qs ∧ t_input t ∈ ins ∧ t_output t ∈ outs ∧ t_target t ∈ qs⟧ ⟹ FSM.outputs (FSM.create_fsm_from_sets q qs ins outs ts) = outs› and 1 goal remains*) apply ((auto)[1]) (*discuss goal 5*) apply ((transfer)[1]) (*goal: ‹⟦(q::'a) ∈ (qs::'a set); finite qs; finite (ins::'b set); finite (outs::'c set); ⋀t::'a × 'b × 'c × 'a. t ∈ (ts::('a × 'b × 'c × 'a) set) ⟹ t_source t ∈ qs ∧ t_input t ∈ ins ∧ t_output t ∈ outs ∧ t_target t ∈ qs⟧ ⟹ FSM.transitions (FSM.create_fsm_from_sets q qs ins outs ts) = ts›*) apply ((auto)[1]) (*proven 5 subgoals*) . lemma create_fsm_from_self : "m = create_fsm_from_sets (initial m) (states m) (inputs m) (outputs m) (transitions m)" proof (-) (*goal: ‹m = FSM.create_fsm_from_sets (FSM.initial m) (FSM.states m) (FSM.inputs m) (FSM.outputs m) (FSM.transitions m)›*) have "*": "⋀ t . t ∈ transitions m ⟹ t_source t ∈ states m ∧ t_input t ∈ inputs m ∧ t_output t ∈ outputs m ∧ t_target t ∈ states m" by auto show "?thesis" (*goal: ‹m = FSM.create_fsm_from_sets (FSM.initial m) (FSM.states m) (FSM.inputs m) (FSM.outputs m) (FSM.transitions m)›*) using create_fsm_from_sets_simps[OF fsm_initial fsm_states_finite fsm_inputs_finite fsm_outputs_finite *, of "transitions m"] (*‹(⋀t. t ∈ FSM.transitions m ⟹ t ∈ FSM.transitions m) ⟹ FSM.initial (FSM.create_fsm_from_sets (FSM.initial m) (FSM.states m) (FSM.inputs m) (FSM.outputs m) (FSM.transitions m)) = FSM.initial m› ‹(⋀t. t ∈ FSM.transitions m ⟹ t ∈ FSM.transitions m) ⟹ FSM.states (FSM.create_fsm_from_sets (FSM.initial m) (FSM.states m) (FSM.inputs m) (FSM.outputs m) (FSM.transitions m)) = FSM.states m› ‹(⋀t. t ∈ FSM.transitions m ⟹ t ∈ FSM.transitions m) ⟹ FSM.inputs (FSM.create_fsm_from_sets (FSM.initial m) (FSM.states m) (FSM.inputs m) (FSM.outputs m) (FSM.transitions m)) = FSM.inputs m› ‹(⋀t::'a × 'b × 'c × 'a. t ∈ FSM.transitions (m::('a, 'b, 'c) fsm) ⟹ t ∈ FSM.transitions m) ⟹ FSM.outputs (FSM.create_fsm_from_sets (FSM.initial m) (FSM.states m) (FSM.inputs m) (FSM.outputs m) (FSM.transitions m)) = FSM.outputs m› ‹(⋀t. t ∈ FSM.transitions m ⟹ t ∈ FSM.transitions m) ⟹ FSM.transitions (FSM.create_fsm_from_sets (FSM.initial m) (FSM.states m) (FSM.inputs m) (FSM.outputs m) (FSM.transitions m)) = FSM.transitions m›*) apply transfer (*goal: ‹m = FSM.create_fsm_from_sets (FSM.initial m) (FSM.states m) (FSM.inputs m) (FSM.outputs m) (FSM.transitions m)›*) by force qed lemma create_fsm_from_sets_surj : assumes "finite (UNIV :: 'a set)" and "finite (UNIV :: 'b set)" and "finite (UNIV :: 'c set)" shows "surj (λ(q::'a,Q,X::'b set,Y::'c set,T) . create_fsm_from_sets q Q X Y T)" proof (standard) (*goals: 1. ‹range (λ(q, Q, X, Y, T). FSM.create_fsm_from_sets q Q X Y T) ⊆ UNIV› 2. ‹UNIV ⊆ range (λ(q, Q, X, Y, T). FSM.create_fsm_from_sets q Q X Y T)›*) show "range (λ(q::'a,Q,X::'b set,Y::'c set,T) . create_fsm_from_sets q Q X Y T) ⊆ UNIV" by simp show "UNIV ⊆ range (λ(q::'a,Q,X::'b set,Y::'c set,T) . create_fsm_from_sets q Q X Y T)" proof (standard) (*goal: ‹⋀x. x ∈ UNIV ⟹ x ∈ range (λ(q, Q, X, Y, T). FSM.create_fsm_from_sets q Q X Y T)›*) fix m assume "m ∈ (UNIV :: ('a,'b,'c) fsm set)" (*‹(m::('a, 'b, 'c) fsm) ∈ UNIV›*) then have "m = create_fsm_from_sets (initial m) (states m) (inputs m) (outputs m) (transitions m)" using create_fsm_from_self (*‹?m = FSM.create_fsm_from_sets (FSM.initial ?m) (FSM.states ?m) (FSM.inputs ?m) (FSM.outputs ?m) (FSM.transitions ?m)›*) by blast then have "m = (λ(q::'a,Q,X::'b set,Y::'c set,T) . create_fsm_from_sets q Q X Y T) (initial m,states m,inputs m,outputs m,transitions m)" by auto then show "m ∈ range (λ(q::'a,Q,X::'b set,Y::'c set,T) . create_fsm_from_sets q Q X Y T)" by blast qed qed subsection ‹Distinguishability› definition distinguishes :: "('a,'b,'c) fsm ⇒ 'a ⇒ 'a ⇒ ('b ×'c) list ⇒ bool" where "distinguishes M q1 q2 io = (io ∈ LS M q1 ∪ LS M q2 ∧ io ∉ LS M q1 ∩ LS M q2)" definition minimally_distinguishes :: "('a,'b,'c) fsm ⇒ 'a ⇒ 'a ⇒ ('b ×'c) list ⇒ bool" where "minimally_distinguishes M q1 q2 io = (distinguishes M q1 q2 io ∧ (∀ io' . distinguishes M q1 q2 io' ⟶ length io ≤ length io'))" lemma minimally_distinguishes_ex : assumes "q1 ∈ states M" and "q2 ∈ states M" and "LS M q1 ≠ LS M q2" obtains v where "minimally_distinguishes M q1 q2 v" proof (-) (*goal: ‹(⋀v. minimally_distinguishes M q1 q2 v ⟹ thesis) ⟹ thesis›*) let ?vs = "{v . distinguishes M q1 q2 v}" define vMin where vMin: "vMin = arg_min length (λv . v ∈ ?vs)" obtain v' where "distinguishes M q1 q2 v'" (*goal: ‹(⋀v'::('b × 'c) list. distinguishes (M::('a, 'b, 'c) fsm) (q1::'a) (q2::'a) v' ⟹ thesis::bool) ⟹ thesis›*) using assms (*‹q1 ∈ FSM.states M› ‹q2 ∈ FSM.states M› ‹LS M q1 ≠ LS M q2›*) unfolding distinguishes_def (*goal: ‹(⋀v'. v' ∈ LS M q1 ∪ LS M q2 ∧ v' ∉ LS M q1 ∩ LS M q2 ⟹ thesis) ⟹ thesis›*) by blast then have "vMin ∈ ?vs ∧ (∀ v'' . distinguishes M q1 q2 v'' ⟶ length vMin ≤ length v'')" unfolding vMin (*goal: ‹(ARG_MIN length v. v ∈ Collect (distinguishes M q1 q2)) ∈ {v. distinguishes M q1 q2 v} ∧ (∀v''. distinguishes M q1 q2 v'' ⟶ length (ARG_MIN length v. v ∈ Collect (distinguishes M q1 q2)) ≤ length v'')›*) using arg_min_nat_lemma[of "λv . distinguishes M q1 q2 v" v' length] (*‹distinguishes M q1 q2 v' ⟹ distinguishes M q1 q2 (arg_min length (distinguishes M q1 q2)) ∧ (∀y. distinguishes M q1 q2 y ⟶ length (arg_min length (distinguishes M q1 q2)) ≤ length y)›*) by simp then show "?thesis" (*goal: ‹thesis›*) using that[of vMin] (*‹minimally_distinguishes M q1 q2 vMin ⟹ thesis›*) unfolding minimally_distinguishes_def (*goal: ‹thesis›*) by blast qed lemma distinguish_prepend : assumes "observable M" and "distinguishes M (FSM.after M q1 io) (FSM.after M q2 io) w" and "q1 ∈ states M" and "q2 ∈ states M" and "io ∈ LS M q1" and "io ∈ LS M q2" shows "distinguishes M q1 q2 (io@w)" proof (-) (*goal: ‹distinguishes M q1 q2 (io @ w)›*) have "(io@w ∈ LS M q1) = (w ∈ LS M (after M q1 io))" using assms(1,3,5) (*‹observable M› ‹q1 ∈ FSM.states M› ‹io ∈ LS M q1›*) by (metis after_language_iff (*‹⟦observable ?M; ?α ∈ LS ?M ?q⟧ ⟹ (?γ ∈ LS ?M (after ?M ?q ?α)) = (?α @ ?γ ∈ LS ?M ?q)›*)) moreover have "(io@w ∈ LS M q2) = (w ∈ LS M (after M q2 io))" using assms(1,4,6) (*‹observable (M::('a, 'b, 'c) fsm)› ‹q2 ∈ FSM.states M› ‹io ∈ LS M q2›*) by (metis after_language_iff (*‹⟦observable ?M; ?α ∈ LS ?M ?q⟧ ⟹ (?γ ∈ LS ?M (after ?M ?q ?α)) = (?α @ ?γ ∈ LS ?M ?q)›*)) ultimately show "?thesis" (*goal: ‹distinguishes M q1 q2 (io @ w)›*) using assms(2) (*‹distinguishes M (after M q1 io) (after M q2 io) w›*) unfolding distinguishes_def (*goal: ‹io @ w ∈ LS M q1 ∪ LS M q2 ∧ io @ w ∉ LS M q1 ∩ LS M q2›*) by blast qed lemma distinguish_prepend_initial : assumes "observable M" and "distinguishes M (after_initial M (io1@io)) (after_initial M (io2@io)) w" and "io1@io ∈ L M" and "io2@io ∈ L M" shows "distinguishes M (after_initial M io1) (after_initial M io2) (io@w)" proof (-) (*goal: ‹distinguishes (M::('a, 'b, 'c) fsm) (after_initial M (io1::('b × 'c) list)) (after_initial M (io2::('b × 'c) list)) ((io::('b × 'c) list) @ (w::('b × 'c) list))›*) have f1: "∀ps psa f a. (ps::('b × 'c) list) @ psa ∉ LS f (a::'a) ∨ ps ∈ LS f a" by (meson language_prefix (*‹?io1.0 @ ?io2.0 ∈ LS ?M ?q ⟹ ?io1.0 ∈ LS ?M ?q›*)) then have f2: "io1 ∈ L M" by (meson assms( (*‹io1 @ io ∈ L M›*) 3)) have f3: "io2 ∈ L M" using f1 (*‹∀ps psa f a. ps @ psa ∉ LS f a ∨ ps ∈ LS f a›*) by (metis assms( (*‹io2 @ io ∈ L M›*) 4)) have "io1 ∈ L M" using f1 (*‹∀ps psa f a. ps @ psa ∉ LS f a ∨ ps ∈ LS f a›*) by (metis assms( (*‹io1 @ io ∈ L M›*) 3)) then show "?thesis" (*goal: ‹distinguishes M (after_initial M io1) (after_initial M io2) (io @ w)›*) by (metis after_is_state (*‹⟦observable (?M::(?'a::type, ?'b::type, ?'c::type) fsm); (?io::(?'b::type × ?'c::type) list) ∈ LS ?M (?q::?'a::type)⟧ ⟹ after ?M ?q ?io ∈ FSM.states ?M›*) after_language_iff (*‹⟦observable (?M::(?'a::type, ?'b::type, ?'c::type) fsm); (?α::(?'b::type × ?'c::type) list) ∈ LS ?M (?q::?'a::type)⟧ ⟹ ((?γ::(?'b::type × ?'c::type) list) ∈ LS ?M (after ?M ?q ?α)) = (?α @ ?γ ∈ LS ?M ?q)›*) after_split (*‹⟦observable (?M::(?'a::type, ?'b::type, ?'c::type) fsm); (?α::(?'b::type × ?'c::type) list) @ (?γ::(?'b::type × ?'c::type) list) ∈ LS ?M (?q::?'a::type)⟧ ⟹ after ?M (after ?M ?q ?α) ?γ = after ?M ?q (?α @ ?γ)›*) assms( (*‹observable (M::('a::type, 'b::type, 'c::type) fsm)›*) 1) assms( (*‹distinguishes (M::('a::type, 'b::type, 'c::type) fsm) (after_initial M ((io1::('b::type × 'c::type) list) @ (io::('b::type × 'c::type) list))) (after_initial M ((io2::('b::type × 'c::type) list) @ io)) (w::('b::type × 'c::type) list)›*) 2) assms( (*‹(io1::('b::type × 'c::type) list) @ (io::('b::type × 'c::type) list) ∈ L (M::('a::type, 'b::type, 'c::type) fsm)›*) 3) assms( (*‹(io2::('b::type × 'c::type) list) @ (io::('b::type × 'c::type) list) ∈ L (M::('a::type, 'b::type, 'c::type) fsm)›*) 4) distinguish_prepend (*‹⟦observable (?M::(?'a::type, ?'b::type, ?'c::type) fsm); distinguishes ?M (after ?M (?q1.0::?'a::type) (?io::(?'b::type × ?'c::type) list)) (after ?M (?q2.0::?'a::type) ?io) (?w::(?'b::type × ?'c::type) list); ?q1.0 ∈ FSM.states ?M; ?q2.0 ∈ FSM.states ?M; ?io ∈ LS ?M ?q1.0; ?io ∈ LS ?M ?q2.0⟧ ⟹ distinguishes ?M ?q1.0 ?q2.0 (?io @ ?w)›*) f3 (*‹(io2::('b::type × 'c::type) list) ∈ L (M::('a::type, 'b::type, 'c::type) fsm)›*)) qed lemma minimally_distinguishes_no_prefix : assumes "observable M" and "u@w ∈ L M" and "v@w ∈ L M" and "minimally_distinguishes M (after_initial M u) (after_initial M v) (w@w'@w'')" and "w' ≠ []" shows "¬distinguishes M (after_initial M (u@w)) (after_initial M (v@w)) w''" proof (standard) (*goal: ‹distinguishes M (after_initial M (u @ w)) (after_initial M (v @ w)) w'' ⟹ False›*) assume "distinguishes M (after_initial M (u @ w)) (after_initial M (v @ w)) w''" (*‹distinguishes (M::('a, 'b, 'c) fsm) (after_initial M ((u::('b × 'c) list) @ (w::('b × 'c) list))) (after_initial M ((v::('b × 'c) list) @ w)) (w''::('b × 'c) list)›*) then have "distinguishes M (after_initial M u) (after_initial M v) (w@w'')" using assms(1-3) (*‹observable (M::('a::type, 'b::type, 'c::type) fsm)› ‹u @ w ∈ L M› ‹v @ w ∈ L M›*) distinguish_prepend_initial (*‹⟦observable ?M; distinguishes ?M (after_initial ?M (?io1.0 @ ?io)) (after_initial ?M (?io2.0 @ ?io)) ?w; ?io1.0 @ ?io ∈ L ?M; ?io2.0 @ ?io ∈ L ?M⟧ ⟹ distinguishes ?M (after_initial ?M ?io1.0) (after_initial ?M ?io2.0) (?io @ ?w)›*) by blast moreover have "length (w@w'') < length (w@w'@w'')" using assms(5) (*‹(w'::('b::type × 'c::type) list) ≠ []›*) by auto ultimately show False using assms(4) (*‹minimally_distinguishes M (after_initial M u) (after_initial M v) (w @ w' @ w'')›*) unfolding minimally_distinguishes_def (*goal: ‹False›*) using leD (*‹(?y::?'a) ≤ (?x::?'a) ⟹ ¬ ?x < ?y›*) by blast qed lemma minimally_distinguishes_after_append : assumes "observable M" and "minimal M" and "q1 ∈ states M" and "q2 ∈ states M" and "minimally_distinguishes M q1 q2 (w@w')" and "w' ≠ []" shows "minimally_distinguishes M (after M q1 w) (after M q2 w) w'" proof (-) (*goal: ‹minimally_distinguishes M (after M q1 w) (after M q2 w) w'›*) have "¬ distinguishes M q1 q2 w" using assms(5,6) (*‹minimally_distinguishes M q1 q2 (w @ w')› ‹w' ≠ []›*) by (metis add.right_neutral (*‹?a + 0 = ?a›*) add_le_cancel_left (*‹(?c + ?a ≤ ?c + ?b) = (?a ≤ ?b)›*) length_append (*‹length (?xs @ ?ys) = length ?xs + length ?ys›*) length_greater_0_conv (*‹(0 < length ?xs) = (?xs ≠ [])›*) linorder_not_le (*‹(¬ ?x ≤ ?y) = (?y < ?x)›*) minimally_distinguishes_def (*‹minimally_distinguishes ?M ?q1.0 ?q2.0 ?io = (distinguishes ?M ?q1.0 ?q2.0 ?io ∧ (∀io'. distinguishes ?M ?q1.0 ?q2.0 io' ⟶ length ?io ≤ length io'))›*)) then have "w ∈ LS M q1 = (w ∈ LS M q2)" unfolding distinguishes_def (*goal: ‹(w ∈ LS M q1) = (w ∈ LS M q2)›*) by blast moreover have "(w@w') ∈ LS M q1 ∪ LS M q2" using assms(5) (*‹minimally_distinguishes M q1 q2 (w @ w')›*) unfolding minimally_distinguishes_def distinguishes_def (*goal: ‹w @ w' ∈ LS M q1 ∪ LS M q2›*) by blast ultimately have "w ∈ LS M q1" and "w ∈ LS M q2" apply - (*goals: 1. ‹⟦(w ∈ LS M q1) = (w ∈ LS M q2); w @ w' ∈ LS M q1 ∪ LS M q2⟧ ⟹ w ∈ LS M q1› 2. ‹⟦(w ∈ LS M q1) = (w ∈ LS M q2); w @ w' ∈ LS M q1 ∪ LS M q2⟧ ⟹ w ∈ LS M q2› discuss goal 1*) apply (meson Un_iff (*‹(?c ∈ ?A ∪ ?B) = (?c ∈ ?A ∨ ?c ∈ ?B)›*) language_prefix (*‹?io1.0 @ ?io2.0 ∈ LS ?M ?q ⟹ ?io1.0 ∈ LS ?M ?q›*)) (*discuss goal 2*) apply (meson Un_iff (*‹(?c ∈ ?A ∪ ?B) = (?c ∈ ?A ∨ ?c ∈ ?B)›*) language_prefix (*‹?io1.0 @ ?io2.0 ∈ LS ?M ?q ⟹ ?io1.0 ∈ LS ?M ?q›*)) (*proven 2 subgoals*) . have "(w@w') ∈ LS M q1 = (w' ∈ LS M (after M q1 w))" by (meson ‹w ∈ LS M q1› after_language_iff (*‹⟦observable ?M; ?α ∈ LS ?M ?q⟧ ⟹ (?γ ∈ LS ?M (after ?M ?q ?α)) = (?α @ ?γ ∈ LS ?M ?q)›*) assms( (*‹observable M›*) 1)) moreover have "(w@w') ∈ LS M q2 = (w' ∈ LS M (after M q2 w))" by (meson ‹w ∈ LS M q2› after_language_iff (*‹⟦observable ?M; ?α ∈ LS ?M ?q⟧ ⟹ (?γ ∈ LS ?M (after ?M ?q ?α)) = (?α @ ?γ ∈ LS ?M ?q)›*) assms( (*‹observable M›*) 1)) ultimately have "distinguishes M (after M q1 w) (after M q2 w) w'" using assms(5) (*‹minimally_distinguishes M q1 q2 (w @ w')›*) unfolding minimally_distinguishes_def distinguishes_def (*goal: ‹w' ∈ LS M (after M q1 w) ∪ LS M (after M q2 w) ∧ w' ∉ LS M (after M q1 w) ∩ LS M (after M q2 w)›*) by blast moreover have "⋀ w'' . distinguishes M (after M q1 w) (after M q2 w) w'' ⟹ length w' ≤ length w''" proof (-) (*goal: ‹⋀w''. distinguishes M (after M q1 w) (after M q2 w) w'' ⟹ length w' ≤ length w''›*) fix w'' assume "distinguishes M (after M q1 w) (after M q2 w) w''" (*‹distinguishes (M::('a, 'b, 'c) fsm) (after M (q1::'a) (w::('b × 'c) list)) (after M (q2::'a) w) (w''::('b × 'c) list)›*) then have "distinguishes M q1 q2 (w@w'')" by (metis ‹w ∈ LS M q1› ‹w ∈ LS M q2› assms( (*‹observable M›*) 1) assms( (*‹q1 ∈ FSM.states M›*) 3) assms( (*‹q2 ∈ FSM.states M›*) 4) distinguish_prepend (*‹⟦observable ?M; distinguishes ?M (after ?M ?q1.0 ?io) (after ?M ?q2.0 ?io) ?w; ?q1.0 ∈ FSM.states ?M; ?q2.0 ∈ FSM.states ?M; ?io ∈ LS ?M ?q1.0; ?io ∈ LS ?M ?q2.0⟧ ⟹ distinguishes ?M ?q1.0 ?q2.0 (?io @ ?w)›*)) then have "length (w@w') ≤ length (w@w'')" using assms(5) (*‹minimally_distinguishes M q1 q2 (w @ w')›*) unfolding minimally_distinguishes_def distinguishes_def (*goal: ‹length (w @ w') ≤ length (w @ w'')›*) by blast then show "length w' ≤ length w''" by auto qed ultimately show "?thesis" (*goal: ‹minimally_distinguishes (M::('a, 'b, 'c) fsm) (after M (q1::'a) (w::('b × 'c) list)) (after M (q2::'a) w) (w'::('b × 'c) list)›*) unfolding minimally_distinguishes_def distinguishes_def (*goal: ‹((w'::('b × 'c) list) ∈ LS (M::('a, 'b, 'c) fsm) (after M (q1::'a) (w::('b × 'c) list)) ∪ LS M (after M (q2::'a) w) ∧ w' ∉ LS M (after M q1 w) ∩ LS M (after M q2 w)) ∧ (∀io'::('b × 'c) list. io' ∈ LS M (after M q1 w) ∪ LS M (after M q2 w) ∧ io' ∉ LS M (after M q1 w) ∩ LS M (after M q2 w) ⟶ length w' ≤ length io')›*) by blast qed lemma minimally_distinguishes_after_append_initial : assumes "observable M" and "minimal M" and "u ∈ L M" and "v ∈ L M" and "minimally_distinguishes M (after_initial M u) (after_initial M v) (w@w')" and "w' ≠ []" shows "minimally_distinguishes M (after_initial M (u@w)) (after_initial M (v@w)) w'" proof (-) (*goal: ‹minimally_distinguishes M (after_initial M (u @ w)) (after_initial M (v @ w)) w'›*) have "¬ distinguishes M (after_initial M u) (after_initial M v) w" using assms(5,6) (*‹minimally_distinguishes M (after_initial M u) (after_initial M v) (w @ w')› ‹w' ≠ []›*) by (metis add.right_neutral (*‹?a + 0 = ?a›*) add_le_cancel_left (*‹(?c + ?a ≤ ?c + ?b) = (?a ≤ ?b)›*) length_append (*‹length (?xs @ ?ys) = length ?xs + length ?ys›*) length_greater_0_conv (*‹(0 < length ?xs) = (?xs ≠ [])›*) linorder_not_le (*‹(¬ ?x ≤ ?y) = (?y < ?x)›*) minimally_distinguishes_def (*‹minimally_distinguishes ?M ?q1.0 ?q2.0 ?io = (distinguishes ?M ?q1.0 ?q2.0 ?io ∧ (∀io'. distinguishes ?M ?q1.0 ?q2.0 io' ⟶ length ?io ≤ length io'))›*)) then have "w ∈ LS M (after_initial M u) = (w ∈ LS M (after_initial M v))" unfolding distinguishes_def (*goal: ‹((w::('b::type × 'c::type) list) ∈ LS (M::('a::type, 'b::type, 'c::type) fsm) (after_initial M (u::('b::type × 'c::type) list))) = (w ∈ LS M (after_initial M (v::('b::type × 'c::type) list)))›*) by blast moreover have "(w@w') ∈ LS M (after_initial M u) ∪ LS M (after_initial M v)" using assms(5) (*‹minimally_distinguishes M (after_initial M u) (after_initial M v) (w @ w')›*) unfolding minimally_distinguishes_def distinguishes_def (*goal: ‹w @ w' ∈ LS M (after_initial M u) ∪ LS M (after_initial M v)›*) by blast ultimately have "w ∈ LS M (after_initial M u)" and "w ∈ LS M (after_initial M v)" apply - (*goals: 1. ‹⟦(w ∈ LS M (after_initial M u)) = (w ∈ LS M (after_initial M v)); w @ w' ∈ LS M (after_initial M u) ∪ LS M (after_initial M v)⟧ ⟹ w ∈ LS M (after_initial M u)› 2. ‹⟦(w ∈ LS M (after_initial M u)) = (w ∈ LS M (after_initial M v)); w @ w' ∈ LS M (after_initial M u) ∪ LS M (after_initial M v)⟧ ⟹ w ∈ LS M (after_initial M v)› discuss goal 1*) apply (meson Un_iff (*‹(?c ∈ ?A ∪ ?B) = (?c ∈ ?A ∨ ?c ∈ ?B)›*) language_prefix (*‹?io1.0 @ ?io2.0 ∈ LS ?M ?q ⟹ ?io1.0 ∈ LS ?M ?q›*)) (*discuss goal 2*) apply (meson Un_iff (*‹((?c::?'a) ∈ (?A::?'a set) ∪ (?B::?'a set)) = (?c ∈ ?A ∨ ?c ∈ ?B)›*) language_prefix (*‹(?io1.0::(?'a × ?'b) list) @ (?io2.0::(?'a × ?'b) list) ∈ LS (?M::(?'c, ?'a, ?'b) fsm) (?q::?'c) ⟹ ?io1.0 ∈ LS ?M ?q›*)) (*proven 2 subgoals*) . have "(w@w') ∈ LS M (after_initial M u) = (w' ∈ LS M (after_initial M (u@w)))" by (meson ‹w ∈ LS M (after_initial M u)› after_language_append_iff (*‹⟦observable ?M; ?α @ ?γ ∈ L ?M⟧ ⟹ (?β ∈ LS ?M (after_initial ?M (?α @ ?γ))) = (?γ @ ?β ∈ LS ?M (after_initial ?M ?α))›*) after_language_iff (*‹⟦observable ?M; ?α ∈ LS ?M ?q⟧ ⟹ (?γ ∈ LS ?M (after ?M ?q ?α)) = (?α @ ?γ ∈ LS ?M ?q)›*) assms( (*‹observable M›*) 1) assms( (*‹u ∈ L M›*) 3)) moreover have "(w@w') ∈ LS M (after_initial M v) = (w' ∈ LS M (after_initial M (v@w)))" by (meson ‹w ∈ LS M (after_initial M v)› after_language_append_iff (*‹⟦observable ?M; ?α @ ?γ ∈ L ?M⟧ ⟹ (?β ∈ LS ?M (after_initial ?M (?α @ ?γ))) = (?γ @ ?β ∈ LS ?M (after_initial ?M ?α))›*) after_language_iff (*‹⟦observable ?M; ?α ∈ LS ?M ?q⟧ ⟹ (?γ ∈ LS ?M (after ?M ?q ?α)) = (?α @ ?γ ∈ LS ?M ?q)›*) assms( (*‹observable M›*) 1) assms( (*‹v ∈ L M›*) 4)) ultimately have "distinguishes M (after_initial M (u@w)) (after_initial M (v@w)) w'" using assms(5) (*‹minimally_distinguishes M (after_initial M u) (after_initial M v) (w @ w')›*) unfolding minimally_distinguishes_def distinguishes_def (*goal: ‹w' ∈ LS M (after_initial M (u @ w)) ∪ LS M (after_initial M (v @ w)) ∧ w' ∉ LS M (after_initial M (u @ w)) ∩ LS M (after_initial M (v @ w))›*) by blast moreover have "⋀ w'' . distinguishes M (after_initial M (u@w)) (after_initial M (v@w)) w'' ⟹ length w' ≤ length w''" proof (-) (*goal: ‹⋀w''. distinguishes M (after_initial M (u @ w)) (after_initial M (v @ w)) w'' ⟹ length w' ≤ length w''›*) fix w'' assume "distinguishes M (after_initial M (u@w)) (after_initial M (v@w)) w''" (*‹distinguishes (M::('a, 'b, 'c) fsm) (after_initial M ((u::('b × 'c) list) @ (w::('b × 'c) list))) (after_initial M ((v::('b × 'c) list) @ w)) (w''::('b × 'c) list)›*) then have "distinguishes M (after_initial M u) (after_initial M v) (w@w'')" by (meson ‹w ∈ LS M (after_initial M u)› ‹w ∈ LS M (after_initial M v)› after_language_iff (*‹⟦observable (?M::(?'a, ?'b, ?'c) fsm); (?α::(?'b × ?'c) list) ∈ LS ?M (?q::?'a)⟧ ⟹ ((?γ::(?'b × ?'c) list) ∈ LS ?M (after ?M ?q ?α)) = (?α @ ?γ ∈ LS ?M ?q)›*) assms( (*‹observable (M::('a, 'b, 'c) fsm)›*) 1) assms( (*‹(u::('b × 'c) list) ∈ L (M::('a, 'b, 'c) fsm)›*) 3) assms( (*‹(v::('b × 'c) list) ∈ L (M::('a, 'b, 'c) fsm)›*) 4) distinguish_prepend_initial (*‹⟦observable (?M::(?'a, ?'b, ?'c) fsm); distinguishes ?M (after_initial ?M ((?io1.0::(?'b × ?'c) list) @ (?io::(?'b × ?'c) list))) (after_initial ?M ((?io2.0::(?'b × ?'c) list) @ ?io)) (?w::(?'b × ?'c) list); ?io1.0 @ ?io ∈ L ?M; ?io2.0 @ ?io ∈ L ?M⟧ ⟹ distinguishes ?M (after_initial ?M ?io1.0) (after_initial ?M ?io2.0) (?io @ ?w)›*)) then have "length (w@w') ≤ length (w@w'')" using assms(5) (*‹minimally_distinguishes M (after_initial M u) (after_initial M v) (w @ w')›*) unfolding minimally_distinguishes_def distinguishes_def (*goal: ‹length (w @ w') ≤ length (w @ w'')›*) by blast then show "length w' ≤ length w''" by auto qed ultimately show "?thesis" (*goal: ‹minimally_distinguishes M (after_initial M (u @ w)) (after_initial M (v @ w)) w'›*) unfolding minimally_distinguishes_def distinguishes_def (*goal: ‹((w'::('b × 'c) list) ∈ LS (M::('a, 'b, 'c) fsm) (after_initial M ((u::('b × 'c) list) @ (w::('b × 'c) list))) ∪ LS M (after_initial M ((v::('b × 'c) list) @ w)) ∧ w' ∉ LS M (after_initial M (u @ w)) ∩ LS M (after_initial M (v @ w))) ∧ (∀io'::('b × 'c) list. io' ∈ LS M (after_initial M (u @ w)) ∪ LS M (after_initial M (v @ w)) ∧ io' ∉ LS M (after_initial M (u @ w)) ∩ LS M (after_initial M (v @ w)) ⟶ length w' ≤ length io')›*) by blast qed lemma minimally_distinguishes_proper_prefixes_card : assumes "observable M" and "minimal M" and "q1 ∈ states M" and "q2 ∈ states M" and "minimally_distinguishes M q1 q2 w" and "S ⊆ states M" shows "card {w' . w' ∈ set (prefixes w) ∧ w' ≠ w ∧ after M q1 w' ∈ S ∧ after M q2 w' ∈ S} ≤ card S - 1" (is "?P S") proof (-) (*goal: ‹card {w' ∈ set (prefixes w). w' ≠ w ∧ after M q1 w' ∈ S ∧ after M q2 w' ∈ S} ≤ card S - 1›*) define k where "k = card S" then show "?thesis" (*goal: ‹card {w' ∈ set (prefixes w). w' ≠ w ∧ after M q1 w' ∈ S ∧ after M q2 w' ∈ S} ≤ card S - 1›*) using assms(6) (*‹(S::'a set) ⊆ FSM.states (M::('a, 'b, 'c) fsm)›*) proof (induction k arbitrary: S rule: less_induct) (*goal: ‹⋀x S. ⟦⋀y S. ⟦y < x; y = card S; S ⊆ FSM.states M⟧ ⟹ card {w' ∈ set (prefixes w). w' ≠ w ∧ after M q1 w' ∈ S ∧ after M q2 w' ∈ S} ≤ card S - 1; x = card S; S ⊆ FSM.states M⟧ ⟹ card {w' ∈ set (prefixes w). w' ≠ w ∧ after M q1 w' ∈ S ∧ after M q2 w' ∈ S} ≤ card S - 1›*) case (less k) (*‹⟦?y < k; ?y = card ?S; ?S ⊆ FSM.states M⟧ ⟹ card {w' ∈ set (prefixes w). w' ≠ w ∧ after M q1 w' ∈ ?S ∧ after M q2 w' ∈ ?S} ≤ card ?S - 1› ‹(k::nat) = card (S::'a set)› ‹S ⊆ FSM.states M›*) then have "finite S" by (metis fsm_states_finite (*‹finite (FSM.states (?M::(?'a, ?'b, ?'c) fsm))›*) rev_finite_subset (*‹⟦finite (?B::?'a set); (?A::?'a set) ⊆ ?B⟧ ⟹ finite ?A›*)) show "?case" (*goal: ‹card {w' ∈ set (prefixes w). w' ≠ w ∧ after M q1 w' ∈ S ∧ after M q2 w' ∈ S} ≤ card S - 1›*) proof (cases k) (*goals: 1. ‹k = 0 ⟹ card {w' ∈ set (prefixes w). w' ≠ w ∧ after M q1 w' ∈ S ∧ after M q2 w' ∈ S} ≤ card S - 1› 2. ‹⋀nat. k = Suc nat ⟹ card {w' ∈ set (prefixes w). w' ≠ w ∧ after M q1 w' ∈ S ∧ after M q2 w' ∈ S} ≤ card S - 1›*) case 0 (*‹k = 0›*) then have "S = {}" using less.prems (*‹k = card S› ‹S ⊆ FSM.states M›*) ‹finite S› (*‹finite S›*) by auto then show "?thesis" (*goal: ‹card {w' ∈ set (prefixes w). w' ≠ w ∧ after M q1 w' ∈ S ∧ after M q2 w' ∈ S} ≤ card S - 1›*) by fastforce next (*goal: ‹⋀nat. k = Suc nat ⟹ card {w' ∈ set (prefixes w). w' ≠ w ∧ after M q1 w' ∈ S ∧ after M q2 w' ∈ S} ≤ card S - 1›*) case (Suc k') (*‹k = Suc k'›*) show "?thesis" (*goal: ‹card {w'::('b::type × 'c::type) list ∈ set (prefixes (w::('b::type × 'c::type) list)). w' ≠ w ∧ after (M::('a::type, 'b::type, 'c::type) fsm) (q1::'a::type) w' ∈ (S::'a::type set) ∧ after M (q2::'a::type) w' ∈ S} ≤ card S - (1::nat)›*) proof (cases "{w' . w' ∈ set (prefixes w) ∧ w' ≠ w ∧ after M q1 w' ∈ S ∧ after M q2 w' ∈ S} = {}") (*goals: 1. ‹{w' ∈ set (prefixes w). w' ≠ w ∧ after M q1 w' ∈ S ∧ after M q2 w' ∈ S} = {} ⟹ card {w' ∈ set (prefixes w). w' ≠ w ∧ after M q1 w' ∈ S ∧ after M q2 w' ∈ S} ≤ card S - 1› 2. ‹{w' ∈ set (prefixes w). w' ≠ w ∧ after M q1 w' ∈ S ∧ after M q2 w' ∈ S} ≠ {} ⟹ card {w' ∈ set (prefixes w). w' ≠ w ∧ after M q1 w' ∈ S ∧ after M q2 w' ∈ S} ≤ card S - 1›*) case True (*‹{w' ∈ set (prefixes w). w' ≠ w ∧ after M q1 w' ∈ S ∧ after M q2 w' ∈ S} = {}›*) then show "?thesis" (*goal: ‹card {w'::('b::type × 'c::type) list ∈ set (prefixes (w::('b::type × 'c::type) list)). w' ≠ w ∧ after (M::('a::type, 'b::type, 'c::type) fsm) (q1::'a::type) w' ∈ (S::'a::type set) ∧ after M (q2::'a::type) w' ∈ S} ≤ card S - (1::nat)›*) by (metis bot.extremum (*‹bot ≤ ?a›*) dual_order.eq_iff (*‹(?a = ?b) = (?b ≤ ?a ∧ ?a ≤ ?b)›*) obtain_subset_with_card_n (*‹⟦?n ≤ card ?S; ⋀T. ⟦T ⊆ ?S; card T = ?n; finite T⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*)) next (*goal: ‹{w' ∈ set (prefixes w). w' ≠ w ∧ after M q1 w' ∈ S ∧ after M q2 w' ∈ S} ≠ {} ⟹ card {w' ∈ set (prefixes w). w' ≠ w ∧ after M q1 w' ∈ S ∧ after M q2 w' ∈ S} ≤ card S - 1›*) case False (*‹{w'::('b × 'c) list ∈ set (prefixes (w::('b × 'c) list)). w' ≠ w ∧ after (M::('a, 'b, 'c) fsm) (q1::'a) w' ∈ (S::'a set) ∧ after M (q2::'a) w' ∈ S} ≠ {}›*) define wk where wk: "wk = arg_max length (λwk . wk ∈ {w' . w' ∈ set (prefixes w) ∧ w' ≠ w ∧ after M q1 w' ∈ S ∧ after M q2 w' ∈ S})" obtain wk' where "*": "wk' ∈ {w' . w' ∈ set (prefixes w) ∧ w' ≠ w ∧ after M q1 w' ∈ S ∧ after M q2 w' ∈ S}" (*goal: ‹(⋀wk'. wk' ∈ {w' ∈ set (prefixes w). w' ≠ w ∧ after M q1 w' ∈ S ∧ after M q2 w' ∈ S} ⟹ thesis) ⟹ thesis›*) using False (*‹{w' ∈ set (prefixes w). w' ≠ w ∧ after M q1 w' ∈ S ∧ after M q2 w' ∈ S} ≠ {}›*) by blast have "finite {w' . w' ∈ set (prefixes w) ∧ w' ≠ w ∧ after M q1 w' ∈ S ∧ after M q2 w' ∈ S}" by (metis (no_types) Collect_mem_eq (*‹{x. x ∈ ?A} = ?A›*) List.finite_set (*‹finite (set ?xs)›*) finite_Collect_conjI (*‹finite {x. ?P x} ∨ finite {x. ?Q x} ⟹ finite {x. ?P x ∧ ?Q x}›*)) then have "wk ∈ {w' . w' ∈ set (prefixes w) ∧ w' ≠ w ∧ after M q1 w' ∈ S ∧ after M q2 w' ∈ S}" and "⋀ wk' . wk' ∈ {w' . w' ∈ set (prefixes w) ∧ w' ≠ w ∧ after M q1 w' ∈ S ∧ after M q2 w' ∈ S} ⟹ length wk' ≤ length wk" using False (*‹{w' ∈ set (prefixes w). w' ≠ w ∧ after M q1 w' ∈ S ∧ after M q2 w' ∈ S} ≠ {}›*) unfolding wk (*goals: 1. ‹(ARG_MAX length wk. wk ∈ {w' ∈ set (prefixes w). w' ≠ w ∧ after M q1 w' ∈ S ∧ after M q2 w' ∈ S}) ∈ {w' ∈ set (prefixes w). w' ≠ w ∧ after M q1 w' ∈ S ∧ after M q2 w' ∈ S}› 2. ‹⋀wk'. wk' ∈ {w' ∈ set (prefixes w). w' ≠ w ∧ after M q1 w' ∈ S ∧ after M q2 w' ∈ S} ⟹ length wk' ≤ length (ARG_MAX length wk. wk ∈ {w' ∈ set (prefixes w). w' ≠ w ∧ after M q1 w' ∈ S ∧ after M q2 w' ∈ S})›*) using arg_max_nat_lemma[of "(λwk . wk ∈ {w' . w' ∈ set (prefixes w) ∧ w' ≠ w ∧ after M q1 w' ∈ S ∧ after M q2 w' ∈ S})", OF *] (*‹∀y. y ∈ {w' ∈ set (prefixes w). w' ≠ w ∧ after M q1 w' ∈ S ∧ after M q2 w' ∈ S} ⟶ ?f y < ?b ⟹ (ARG_MAX ?f wk. wk ∈ {w' ∈ set (prefixes w). w' ≠ w ∧ after M q1 w' ∈ S ∧ after M q2 w' ∈ S}) ∈ {w' ∈ set (prefixes w). w' ≠ w ∧ after M q1 w' ∈ S ∧ after M q2 w' ∈ S} ∧ (∀y. y ∈ {w' ∈ set (prefixes w). w' ≠ w ∧ after M q1 w' ∈ S ∧ after M q2 w' ∈ S} ⟶ ?f y ≤ ?f (ARG_MAX ?f wk. wk ∈ {w' ∈ set (prefixes w). w' ≠ w ∧ after M q1 w' ∈ S ∧ after M q2 w' ∈ S}))›*) apply - (*goals: 1. ‹⟦finite {w' ∈ set (prefixes w). w' ≠ w ∧ after M q1 w' ∈ S ∧ after M q2 w' ∈ S}; {w' ∈ set (prefixes w). w' ≠ w ∧ after M q1 w' ∈ S ∧ after M q2 w' ∈ S} ≠ {}; ⋀f b. ∀y. y ∈ {w' ∈ set (prefixes w). w' ≠ w ∧ after M q1 w' ∈ S ∧ after M q2 w' ∈ S} ⟶ f y < b ⟹ (ARG_MAX f wk. wk ∈ {w' ∈ set (prefixes w). w' ≠ w ∧ after M q1 w' ∈ S ∧ after M q2 w' ∈ S}) ∈ {w' ∈ set (prefixes w). w' ≠ w ∧ after M q1 w' ∈ S ∧ after M q2 w' ∈ S} ∧ (∀y. y ∈ {w' ∈ set (prefixes w). w' ≠ w ∧ after M q1 w' ∈ S ∧ after M q2 w' ∈ S} ⟶ f y ≤ f (ARG_MAX f wk. wk ∈ {w' ∈ set (prefixes w). w' ≠ w ∧ after M q1 w' ∈ S ∧ after M q2 w' ∈ S}))⟧ ⟹ (ARG_MAX length wk. wk ∈ {w' ∈ set (prefixes w). w' ≠ w ∧ after M q1 w' ∈ S ∧ after M q2 w' ∈ S}) ∈ {w' ∈ set (prefixes w). w' ≠ w ∧ after M q1 w' ∈ S ∧ after M q2 w' ∈ S}› 2. ‹⋀wk'. ⟦wk' ∈ {w' ∈ set (prefixes w). w' ≠ w ∧ after M q1 w' ∈ S ∧ after M q2 w' ∈ S}; finite {w' ∈ set (prefixes w). w' ≠ w ∧ after M q1 w' ∈ S ∧ after M q2 w' ∈ S}; {w' ∈ set (prefixes w). w' ≠ w ∧ after M q1 w' ∈ S ∧ after M q2 w' ∈ S} ≠ {}; ⋀f b. ∀y. y ∈ {w' ∈ set (prefixes w). w' ≠ w ∧ after M q1 w' ∈ S ∧ after M q2 w' ∈ S} ⟶ f y < b ⟹ (ARG_MAX f wk. wk ∈ {w' ∈ set (prefixes w). w' ≠ w ∧ after M q1 w' ∈ S ∧ after M q2 w' ∈ S}) ∈ {w' ∈ set (prefixes w). w' ≠ w ∧ after M q1 w' ∈ S ∧ after M q2 w' ∈ S} ∧ (∀y. y ∈ {w' ∈ set (prefixes w). w' ≠ w ∧ after M q1 w' ∈ S ∧ after M q2 w' ∈ S} ⟶ f y ≤ f (ARG_MAX f wk. wk ∈ {w' ∈ set (prefixes w). w' ≠ w ∧ after M q1 w' ∈ S ∧ after M q2 w' ∈ S}))⟧ ⟹ length wk' ≤ length (ARG_MAX length wk. wk ∈ {w' ∈ set (prefixes w). w' ≠ w ∧ after M q1 w' ∈ S ∧ after M q2 w' ∈ S})› discuss goal 1*) apply (meson finite_maxlen (*‹finite (?M::?'a list set) ⟹ ∃n::nat. ∀s::?'a list∈?M. length s < n›*)) (*discuss goal 2*) apply (meson finite_maxlen (*‹finite ?M ⟹ ∃n. ∀s∈?M. length s < n›*)) (*proven 2 subgoals*) . then have "wk ∈ set (prefixes w)" and "wk ≠ w" and "after M q1 wk ∈ S" and "after M q2 wk ∈ S" apply - (*goals: 1. ‹⟦wk ∈ {w' ∈ set (prefixes w). w' ≠ w ∧ after M q1 w' ∈ S ∧ after M q2 w' ∈ S}; ⋀wk'. wk' ∈ {w' ∈ set (prefixes w). w' ≠ w ∧ after M q1 w' ∈ S ∧ after M q2 w' ∈ S} ⟹ length wk' ≤ length wk⟧ ⟹ wk ∈ set (prefixes w)› 2. ‹⟦wk ∈ {w' ∈ set (prefixes w). w' ≠ w ∧ after M q1 w' ∈ S ∧ after M q2 w' ∈ S}; ⋀wk'. wk' ∈ {w' ∈ set (prefixes w). w' ≠ w ∧ after M q1 w' ∈ S ∧ after M q2 w' ∈ S} ⟹ length wk' ≤ length wk⟧ ⟹ wk ≠ w› 3. ‹⟦wk ∈ {w' ∈ set (prefixes w). w' ≠ w ∧ after M q1 w' ∈ S ∧ after M q2 w' ∈ S}; ⋀wk'. wk' ∈ {w' ∈ set (prefixes w). w' ≠ w ∧ after M q1 w' ∈ S ∧ after M q2 w' ∈ S} ⟹ length wk' ≤ length wk⟧ ⟹ after M q1 wk ∈ S› 4. ‹⟦wk ∈ {w' ∈ set (prefixes w). w' ≠ w ∧ after M q1 w' ∈ S ∧ after M q2 w' ∈ S}; ⋀wk'. wk' ∈ {w' ∈ set (prefixes w). w' ≠ w ∧ after M q1 w' ∈ S ∧ after M q2 w' ∈ S} ⟹ length wk' ≤ length wk⟧ ⟹ after M q2 wk ∈ S› discuss goal 1*) apply blast (*discuss goal 2*) apply blast (*discuss goal 3*) apply blast (*discuss goal 4*) apply blast (*proven 4 subgoals*) . obtain wk_suffix where "w = wk@wk_suffix" and "wk_suffix ≠ []" (*goal: ‹(⋀wk_suffix::('b × 'c) list. ⟦(w::('b × 'c) list) = (wk::('b × 'c) list) @ wk_suffix; wk_suffix ≠ []⟧ ⟹ thesis::bool) ⟹ thesis›*) using ‹wk ∈ set (prefixes w)› (*‹wk ∈ set (prefixes w)›*) using prefixes_set_ob (*‹⟦?xs ∈ set (prefixes ?xss); ⋀xs'. ?xss = ?xs @ xs' ⟹ ?thesis⟧ ⟹ ?thesis›*) ‹wk ≠ w› (*‹wk ≠ w›*) by blast have "distinguishes M (after M q1 []) (after M q2 []) w" using ‹minimally_distinguishes M q1 q2 w› (*‹minimally_distinguishes M q1 q2 w›*) by (metis after.simps( (*‹after ?M ?q [] = ?q›*) 1) minimally_distinguishes_def (*‹minimally_distinguishes ?M ?q1.0 ?q2.0 ?io = (distinguishes ?M ?q1.0 ?q2.0 ?io ∧ (∀io'. distinguishes ?M ?q1.0 ?q2.0 io' ⟶ length ?io ≤ length io'))›*)) have "minimally_distinguishes M (after M q1 wk) (after M q2 wk) wk_suffix" using ‹minimally_distinguishes M q1 q2 w› (*‹minimally_distinguishes M q1 q2 w›*) ‹wk_suffix ≠ []› (*‹(wk_suffix::('b × 'c) list) ≠ []›*) unfolding ‹w = wk@wk_suffix› (*goal: ‹minimally_distinguishes M (after M q1 wk) (after M q2 wk) wk_suffix›*) using minimally_distinguishes_after_append[OF assms ( 1 , 2 , 3 , 4 ), of wk wk_suffix] (*‹⟦minimally_distinguishes M q1 q2 (wk @ wk_suffix); wk_suffix ≠ []⟧ ⟹ minimally_distinguishes M (after M q1 wk) (after M q2 wk) wk_suffix›*) by blast then have "distinguishes M (after M q1 wk) (after M q2 wk) wk_suffix" unfolding minimally_distinguishes_def (*goal: ‹distinguishes M (after M q1 wk) (after M q2 wk) wk_suffix›*) by auto then have "wk_suffix ∈ LS M (after M q1 wk) = (wk_suffix ∉ LS M (after M q2 wk))" unfolding distinguishes_def (*goal: ‹(wk_suffix ∈ LS M (after M q1 wk)) = (wk_suffix ∉ LS M (after M q2 wk))›*) by blast define S1 where S1: "S1 = Set.filter (λq . wk_suffix ∈ LS M q) S" define S2 where S2: "S2 = Set.filter (λq . wk_suffix ∉ LS M q) S" have "S = S1 ∪ S2" unfolding S1 S2 (*goal: ‹(S::'a::type set) = Set.filter (λq::'a::type. (wk_suffix::('b::type × 'c::type) list) ∈ LS (M::('a::type, 'b::type, 'c::type) fsm) q) S ∪ Set.filter (λq::'a::type. wk_suffix ∉ LS M q) S›*) by auto moreover have "S1 ∩ S2 = {}" unfolding S1 S2 (*goal: ‹Set.filter (λq. wk_suffix ∈ LS M q) S ∩ Set.filter (λq. wk_suffix ∉ LS M q) S = {}›*) by auto ultimately have "card S = card S1 + card S2" using ‹finite S› (*‹finite S›*) card_Un_disjoint (*‹⟦finite ?A; finite ?B; ?A ∩ ?B = {}⟧ ⟹ card (?A ∪ ?B) = card ?A + card ?B›*) by blast have "S1 ⊆ states M" and "S2 ⊆ states M" using ‹S = S1 ∪ S2› (*‹S = S1 ∪ S2›*) less.prems(2) (*‹S ⊆ FSM.states M›*) apply - (*goals: 1. ‹⟦S = S1 ∪ S2; S ⊆ FSM.states M⟧ ⟹ S1 ⊆ FSM.states M› 2. ‹⟦S = S1 ∪ S2; S ⊆ FSM.states M⟧ ⟹ S2 ⊆ FSM.states M› discuss goal 1*) apply blast (*discuss goal 2*) apply blast (*proven 2 subgoals*) . have "S1 ≠ {}" and "S2 ≠ {}" using ‹wk_suffix ∈ LS M (after M q1 wk) = (wk_suffix ∉ LS M (after M q2 wk))› (*‹((wk_suffix::('b::type × 'c::type) list) ∈ LS (M::('a::type, 'b::type, 'c::type) fsm) (after M (q1::'a::type) (wk::('b::type × 'c::type) list))) = (wk_suffix ∉ LS M (after M (q2::'a::type) wk))›*) ‹after M q1 wk ∈ S› (*‹after M q1 wk ∈ S›*) ‹after M q2 wk ∈ S› (*‹after M q2 wk ∈ S›*) unfolding S1 S2 (*goals: 1. ‹Set.filter (λq. wk_suffix ∈ LS M q) S ≠ {}› 2. ‹Set.filter (λq. wk_suffix ∉ LS M q) S ≠ {}›*) apply - (*goals: 1. ‹⟦(wk_suffix ∈ LS M (after M q1 wk)) = (wk_suffix ∉ LS M (after M q2 wk)); after M q1 wk ∈ S; after M q2 wk ∈ S⟧ ⟹ Set.filter (λq. wk_suffix ∈ LS M q) S ≠ {}› 2. ‹⟦(wk_suffix ∈ LS M (after M q1 wk)) = (wk_suffix ∉ LS M (after M q2 wk)); after M q1 wk ∈ S; after M q2 wk ∈ S⟧ ⟹ Set.filter (λq. wk_suffix ∉ LS M q) S ≠ {}› discuss goal 1*) apply (metis empty_iff (*‹(?c ∈ {}) = False›*) member_filter (*‹(?x ∈ Set.filter ?P ?A) = (?x ∈ ?A ∧ ?P ?x)›*)) (*discuss goal 2*) apply (metis empty_iff (*‹(?c ∈ {}) = False›*) member_filter (*‹(?x ∈ Set.filter ?P ?A) = (?x ∈ ?A ∧ ?P ?x)›*)) (*proven 2 subgoals*) . then have "card S1 > 0" and "card S2 > 0" using ‹S = S1 ∪ S2› (*‹(S::'a::type set) = (S1::'a::type set) ∪ (S2::'a::type set)›*) ‹finite S› (*‹finite S›*) apply - (*goals: 1. ‹⟦S1 ≠ {}; S2 ≠ {}; S = S1 ∪ S2; finite S⟧ ⟹ 0 < card S1› 2. ‹⟦S1 ≠ {}; S2 ≠ {}; S = S1 ∪ S2; finite S⟧ ⟹ 0 < card S2› discuss goal 1*) apply (meson card_0_eq (*‹finite ?A ⟹ (card ?A = 0) = (?A = {})›*) finite_Un (*‹finite (?F ∪ ?G) = (finite ?F ∧ finite ?G)›*) neq0_conv (*‹(?n ≠ 0) = (0 < ?n)›*)) (*discuss goal 2*) apply (meson card_0_eq (*‹finite ?A ⟹ (card ?A = 0) = (?A = {})›*) finite_Un (*‹finite (?F ∪ ?G) = (finite ?F ∧ finite ?G)›*) neq0_conv (*‹(?n ≠ 0) = (0 < ?n)›*)) (*proven 2 subgoals*) . then have "card S1 < k" and "card S2 < k" using ‹card S = card S1 + card S2› (*‹card S = card S1 + card S2›*) unfolding less.prems (*goals: 1. ‹card S1 < card S› 2. ‹card S2 < card S›*) apply - (*goals: 1. ‹⟦0 < card S1; 0 < card S2; card S = card S1 + card S2⟧ ⟹ card S1 < card S› 2. ‹⟦0 < card S1; 0 < card S2; card S = card S1 + card S2⟧ ⟹ card S2 < card S› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . define W where W: "W = (λ S1 S2 . {w' . w' ∈ set (prefixes w) ∧ w' ≠ w ∧ after M q1 w' ∈ S1 ∧ after M q2 w' ∈ S2})" then have "⋀ S' S'' . W S' S'' ⊆ set (prefixes w)" by auto then have W_finite: "⋀ S' S'' . finite (W S' S'')" using List.finite_set[of "prefixes w"] (*‹finite (set (prefixes w))›*) by (meson finite_subset (*‹⟦?A ⊆ ?B; finite ?B⟧ ⟹ finite ?A›*)) have "⋀ w' . w' ∈ W S S ⟹ w' ≠ wk ⟹ after M q1 w' ∈ S1 = (after M q2 w' ∈ S1)" proof (-) (*goal: ‹⋀w'::('b × 'c) list. ⟦w' ∈ (W::'a set ⇒ 'a set ⇒ ('b × 'c) list set) (S::'a set) S; w' ≠ (wk::('b × 'c) list)⟧ ⟹ (after (M::('a, 'b, 'c) fsm) (q1::'a) w' ∈ (S1::'a set)) = (after M (q2::'a) w' ∈ S1)›*) fix w' assume "*": "w' ∈ W S S" and "w' ≠ wk" (*‹(w'::('b × 'c) list) ∈ (W::'a set ⇒ 'a set ⇒ ('b × 'c) list set) (S::'a set) S› ‹(w'::('b × 'c) list) ≠ (wk::('b × 'c) list)›*) then have "w' ∈ set (prefixes w)" and "w' ≠ w" and "after M q1 w' ∈ S" and "after M q2 w' ∈ S" unfolding W (*goals: 1. ‹w' ∈ set (prefixes w)› 2. ‹w' ≠ w› 3. ‹after M q1 w' ∈ S› 4. ‹after M q2 w' ∈ S›*) apply - (*goals: 1. ‹⟦w' ∈ {w' ∈ set (prefixes w). w' ≠ w ∧ after M q1 w' ∈ S ∧ after M q2 w' ∈ S}; w' ≠ wk⟧ ⟹ w' ∈ set (prefixes w)› 2. ‹⟦w' ∈ {w' ∈ set (prefixes w). w' ≠ w ∧ after M q1 w' ∈ S ∧ after M q2 w' ∈ S}; w' ≠ wk⟧ ⟹ w' ≠ w› 3. ‹⟦w' ∈ {w' ∈ set (prefixes w). w' ≠ w ∧ after M q1 w' ∈ S ∧ after M q2 w' ∈ S}; w' ≠ wk⟧ ⟹ after M q1 w' ∈ S› 4. ‹⟦w' ∈ {w' ∈ set (prefixes w). w' ≠ w ∧ after M q1 w' ∈ S ∧ after M q2 w' ∈ S}; w' ≠ wk⟧ ⟹ after M q2 w' ∈ S› discuss goal 1*) apply blast (*discuss goal 2*) apply blast (*discuss goal 3*) apply blast (*discuss goal 4*) apply blast (*proven 4 subgoals*) . then have "w' ∈ LS M q1" by (metis IntE (*‹⟦?c ∈ ?A ∩ ?B; ⟦?c ∈ ?A; ?c ∈ ?B⟧ ⟹ ?P⟧ ⟹ ?P›*) UnCI (*‹(?c ∉ ?B ⟹ ?c ∈ ?A) ⟹ ?c ∈ ?A ∪ ?B›*) UnE (*‹⟦?c ∈ ?A ∪ ?B; ?c ∈ ?A ⟹ ?P; ?c ∈ ?B ⟹ ?P⟧ ⟹ ?P›*) append_self_conv (*‹(?xs @ ?ys = ?xs) = (?ys = [])›*) assms( (*‹minimally_distinguishes M q1 q2 w›*) 5) distinguishes_def (*‹distinguishes ?M ?q1.0 ?q2.0 ?io = (?io ∈ LS ?M ?q1.0 ∪ LS ?M ?q2.0 ∧ ?io ∉ LS ?M ?q1.0 ∩ LS ?M ?q2.0)›*) language_prefix (*‹?io1.0 @ ?io2.0 ∈ LS ?M ?q ⟹ ?io1.0 ∈ LS ?M ?q›*) leD (*‹?y ≤ ?x ⟹ ¬ ?x < ?y›*) length_append (*‹length (?xs @ ?ys) = length ?xs + length ?ys›*) length_greater_0_conv (*‹(0 < length ?xs) = (?xs ≠ [])›*) less_add_same_cancel1 (*‹(?a < ?a + ?b) = (0 < ?b)›*) minimally_distinguishes_def (*‹minimally_distinguishes ?M ?q1.0 ?q2.0 ?io = (distinguishes ?M ?q1.0 ?q2.0 ?io ∧ (∀io'. distinguishes ?M ?q1.0 ?q2.0 io' ⟶ length ?io ≤ length io'))›*) prefixes_set_ob (*‹⟦?xs ∈ set (prefixes ?xss); ⋀xs'. ?xss = ?xs @ xs' ⟹ ?thesis⟧ ⟹ ?thesis›*)) have "w' ∈ LS M q2" by (metis IntE (*‹⟦?c ∈ ?A ∩ ?B; ⟦?c ∈ ?A; ?c ∈ ?B⟧ ⟹ ?P⟧ ⟹ ?P›*) UnCI (*‹(?c ∉ ?B ⟹ ?c ∈ ?A) ⟹ ?c ∈ ?A ∪ ?B›*) ‹w' ∈ LS M q1› ‹w' ∈ set (prefixes w)› ‹w' ≠ w› append_Nil2 (*‹?xs @ [] = ?xs›*) assms( (*‹minimally_distinguishes M q1 q2 w›*) 5) distinguishes_def (*‹distinguishes ?M ?q1.0 ?q2.0 ?io = (?io ∈ LS ?M ?q1.0 ∪ LS ?M ?q2.0 ∧ ?io ∉ LS ?M ?q1.0 ∩ LS ?M ?q2.0)›*) leD (*‹?y ≤ ?x ⟹ ¬ ?x < ?y›*) length_append (*‹length (?xs @ ?ys) = length ?xs + length ?ys›*) length_greater_0_conv (*‹(0 < length ?xs) = (?xs ≠ [])›*) less_add_same_cancel1 (*‹(?a < ?a + ?b) = (0 < ?b)›*) minimally_distinguishes_def (*‹minimally_distinguishes ?M ?q1.0 ?q2.0 ?io = (distinguishes ?M ?q1.0 ?q2.0 ?io ∧ (∀io'. distinguishes ?M ?q1.0 ?q2.0 io' ⟶ length ?io ≤ length io'))›*) prefixes_set_ob (*‹⟦?xs ∈ set (prefixes ?xss); ⋀xs'. ?xss = ?xs @ xs' ⟹ ?thesis⟧ ⟹ ?thesis›*)) have "length w' < length wk" using ‹w' ≠ wk› (*‹w' ≠ wk›*) "*" (*‹w' ∈ W S S›*) ‹⋀ wk' . wk' ∈ {w' . w' ∈ set (prefixes w) ∧ w' ≠ w ∧ after M q1 w' ∈ S ∧ after M q2 w' ∈ S} ⟹ length wk' ≤ length wk› (*‹(?wk'::('b × 'c) list) ∈ {w'::('b × 'c) list ∈ set (prefixes (w::('b × 'c) list)). w' ≠ w ∧ after (M::('a, 'b, 'c) fsm) (q1::'a) w' ∈ (S::'a set) ∧ after M (q2::'a) w' ∈ S} ⟹ length ?wk' ≤ length (wk::('b × 'c) list)›*) unfolding W (*goal: ‹length w' < length wk›*) by (metis (no_types, lifting) ‹w = wk @ wk_suffix› ‹w' ∈ set (prefixes w)› append_eq_append_conv (*‹length ?xs = length ?ys ∨ length ?us = length ?vs ⟹ (?xs @ ?us = ?ys @ ?vs) = (?xs = ?ys ∧ ?us = ?vs)›*) le_neq_implies_less (*‹⟦?m ≤ ?n; ?m ≠ ?n⟧ ⟹ ?m < ?n›*) prefixes_set_ob (*‹⟦?xs ∈ set (prefixes ?xss); ⋀xs'. ?xss = ?xs @ xs' ⟹ ?thesis⟧ ⟹ ?thesis›*)) show "after M q1 w' ∈ S1 = (after M q2 w' ∈ S1)" proof (rule ccontr (*‹(¬ ?P ⟹ False) ⟹ ?P›*)) (*goal: ‹(after M q1 w' ∈ S1) ≠ (after M q2 w' ∈ S1) ⟹ False›*) assume "(after M q1 w' ∈ S1) ≠ (after M q2 w' ∈ S1)" (*‹(after (M::('a, 'b, 'c) fsm) (q1::'a) (w'::('b × 'c) list) ∈ (S1::'a set)) ≠ (after M (q2::'a) w' ∈ S1)›*) then have "(after M q1 w' ∈ S1 ∧ (after M q2 w' ∈ S2)) ∨ (after M q1 w' ∈ S2 ∧ (after M q2 w' ∈ S1))" using ‹after M q1 w' ∈ S› (*‹after M q1 w' ∈ S›*) ‹after M q2 w' ∈ S› (*‹after M q2 w' ∈ S›*) unfolding ‹S = S1 ∪ S2› (*goal: ‹after (M::('a, 'b, 'c) fsm) (q1::'a) (w'::('b × 'c) list) ∈ (S1::'a set) ∧ after M (q2::'a) w' ∈ (S2::'a set) ∨ after M q1 w' ∈ S2 ∧ after M q2 w' ∈ S1›*) by blast then have "wk_suffix ∈ LS M (after M q1 w') = (wk_suffix ∉ LS M (after M q2 w'))" unfolding S1 S2 (*goal: ‹(wk_suffix ∈ LS M (after M q1 w')) = (wk_suffix ∉ LS M (after M q2 w'))›*) by (metis member_filter (*‹((?x::?'a::type) ∈ Set.filter (?P::?'a::type ⇒ bool) (?A::?'a::type set)) = (?x ∈ ?A ∧ ?P ?x)›*)) then have "distinguishes M (after M q1 w') (after M q2 w') wk_suffix" unfolding distinguishes_def (*goal: ‹wk_suffix ∈ LS M (after M q1 w') ∪ LS M (after M q2 w') ∧ wk_suffix ∉ LS M (after M q1 w') ∩ LS M (after M q2 w')›*) by blast then have "distinguishes M q1 q2 (w'@wk_suffix)" using distinguish_prepend[OF assms ( 1 ) _ ‹q1 ∈ states M› ‹q2 ∈ states M› ‹w' ∈ LS M q1› ‹w' ∈ LS M q2›] (*‹distinguishes M (after M q1 w') (after M q2 w') ?w ⟹ distinguishes M q1 q2 (w' @ ?w)›*) by blast moreover have "length (w'@wk_suffix) < length (wk@wk_suffix)" using ‹length w' < length wk› (*‹length w' < length wk›*) by auto ultimately show False using ‹minimally_distinguishes M q1 q2 w› (*‹minimally_distinguishes (M::('a, 'b, 'c) fsm) (q1::'a) (q2::'a) (w::('b × 'c) list)›*) unfolding ‹w = wk@wk_suffix› minimally_distinguishes_def (*goal: ‹False›*) by auto qed qed have "⋀ x . x ∈ W S1 S2 ∪ W S2 S1 ⟹ x = wk" proof (-) (*goal: ‹⋀x. x ∈ W S1 S2 ∪ W S2 S1 ⟹ x = wk›*) fix x assume "x ∈ W S1 S2 ∪ W S2 S1" (*‹(x::('b × 'c) list) ∈ (W::'a set ⇒ 'a set ⇒ ('b × 'c) list set) (S1::'a set) (S2::'a set) ∪ W S2 S1›*) then have "x ∈ W S S" unfolding W ‹S = S1 ∪ S2› (*goal: ‹(x::('b::type × 'c::type) list) ∈ {w'::('b::type × 'c::type) list ∈ set (prefixes (w::('b::type × 'c::type) list)). w' ≠ w ∧ after (M::('a::type, 'b::type, 'c::type) fsm) (q1::'a::type) w' ∈ (S1::'a::type set) ∪ (S2::'a::type set) ∧ after M (q2::'a::type) w' ∈ S1 ∪ S2}›*) by blast show "x = wk" using ‹x ∈ W S1 S2 ∪ W S2 S1› (*‹x ∈ W S1 S2 ∪ W S2 S1›*) using ‹⋀ w' . w' ∈ W S S ⟹ w' ≠ wk ⟹ after M q1 w' ∈ S1 = (after M q2 w' ∈ S1)›[OF ‹x ∈ W S S›] (*‹x ≠ wk ⟹ (after M q1 x ∈ S1) = (after M q2 x ∈ S1)›*) unfolding W (*goal: ‹x = wk›*) using ‹S1 ∩ S2 = {}› (*‹S1 ∩ S2 = {}›*) by blast qed moreover have "wk ∈ W S1 S2 ∪ W S2 S1" unfolding W (*goal: ‹wk ∈ {w' ∈ set (prefixes w). w' ≠ w ∧ after M q1 w' ∈ S1 ∧ after M q2 w' ∈ S2} ∪ {w' ∈ set (prefixes w). w' ≠ w ∧ after M q1 w' ∈ S2 ∧ after M q2 w' ∈ S1}›*) using ‹wk ∈ {w' . w' ∈ set (prefixes w) ∧ w' ≠ w ∧ after M q1 w' ∈ S ∧ after M q2 w' ∈ S}› (*‹(wk::('b × 'c) list) ∈ {w'::('b × 'c) list ∈ set (prefixes (w::('b × 'c) list)). w' ≠ w ∧ after (M::('a, 'b, 'c) fsm) (q1::'a) w' ∈ (S::'a set) ∧ after M (q2::'a) w' ∈ S}›*) ‹wk_suffix ∈ LS M (after M q1 wk) = (wk_suffix ∉ LS M (after M q2 wk))› (*‹(wk_suffix ∈ LS M (after M q1 wk)) = (wk_suffix ∉ LS M (after M q2 wk))›*) by (metis (no_types, lifting) S1 (*‹S1 = Set.filter (λq. wk_suffix ∈ LS M q) S›*) Un_iff (*‹(?c ∈ ?A ∪ ?B) = (?c ∈ ?A ∨ ?c ∈ ?B)›*) ‹S = S1 ∪ S2› mem_Collect_eq (*‹(?a ∈ Collect ?P) = ?P ?a›*) member_filter (*‹(?x ∈ Set.filter ?P ?A) = (?x ∈ ?A ∧ ?P ?x)›*)) ultimately have "W S1 S2 ∪ W S2 S1 = {wk}" by blast have "W S S = (W S1 S1 ∪ W S2 S2 ∪ (W S1 S2 ∪ W S2 S1))" unfolding W ‹S = S1 ∪ S2› (*goal: ‹{w'::('b::type × 'c::type) list ∈ set (prefixes (w::('b::type × 'c::type) list)). w' ≠ w ∧ after (M::('a::type, 'b::type, 'c::type) fsm) (q1::'a::type) w' ∈ (S1::'a::type set) ∪ (S2::'a::type set) ∧ after M (q2::'a::type) w' ∈ S1 ∪ S2} = {w'::('b::type × 'c::type) list ∈ set (prefixes w). w' ≠ w ∧ after M q1 w' ∈ S1 ∧ after M q2 w' ∈ S1} ∪ {w'::('b::type × 'c::type) list ∈ set (prefixes w). w' ≠ w ∧ after M q1 w' ∈ S2 ∧ after M q2 w' ∈ S2} ∪ ({w'::('b::type × 'c::type) list ∈ set (prefixes w). w' ≠ w ∧ after M q1 w' ∈ S1 ∧ after M q2 w' ∈ S2} ∪ {w'::('b::type × 'c::type) list ∈ set (prefixes w). w' ≠ w ∧ after M q1 w' ∈ S2 ∧ after M q2 w' ∈ S1})›*) by blast moreover have "W S1 S1 ∩ W S2 S2 = {}" using ‹S1 ∩ S2 = {}› (*‹S1 ∩ S2 = {}›*) unfolding W (*goal: ‹{w' ∈ set (prefixes w). w' ≠ w ∧ after M q1 w' ∈ S1 ∧ after M q2 w' ∈ S1} ∩ {w' ∈ set (prefixes w). w' ≠ w ∧ after M q1 w' ∈ S2 ∧ after M q2 w' ∈ S2} = {}›*) by blast moreover have "W S1 S1 ∩ (W S1 S2 ∪ W S2 S1) = {}" unfolding W (*goal: ‹{w' ∈ set (prefixes w). w' ≠ w ∧ after M q1 w' ∈ S1 ∧ after M q2 w' ∈ S1} ∩ ({w' ∈ set (prefixes w). w' ≠ w ∧ after M q1 w' ∈ S1 ∧ after M q2 w' ∈ S2} ∪ {w' ∈ set (prefixes w). w' ≠ w ∧ after M q1 w' ∈ S2 ∧ after M q2 w' ∈ S1}) = {}›*) using ‹S1 ∩ S2 = {}› (*‹S1 ∩ S2 = {}›*) by blast moreover have "W S2 S2 ∩ (W S1 S2 ∪ W S2 S1) = {}" unfolding W (*goal: ‹{w' ∈ set (prefixes w). w' ≠ w ∧ after M q1 w' ∈ S2 ∧ after M q2 w' ∈ S2} ∩ ({w' ∈ set (prefixes w). w' ≠ w ∧ after M q1 w' ∈ S1 ∧ after M q2 w' ∈ S2} ∪ {w' ∈ set (prefixes w). w' ≠ w ∧ after M q1 w' ∈ S2 ∧ after M q2 w' ∈ S1}) = {}›*) using ‹S1 ∩ S2 = {}› (*‹S1 ∩ S2 = {}›*) by blast moreover have "finite (W S1 S1)" and "finite (W S2 S2)" and "finite {wk}" using W_finite (*‹finite ((W::'a set ⇒ 'a set ⇒ ('b × 'c) list set) (?S'::'a set) (?S''::'a set))›*) apply - (*goals: 1. ‹(⋀S' S''. finite (W S' S'')) ⟹ finite (W S1 S1)› 2. ‹(⋀S' S''. finite (W S' S'')) ⟹ finite (W S2 S2)› 3. ‹(⋀S' S''. finite (W S' S'')) ⟹ finite {wk}› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*proven 3 subgoals*) . ultimately have "card (W S S) = card (W S1 S1) + card (W S2 S2) + 1" unfolding ‹W S1 S2 ∪ W S2 S1 = {wk}› (*goal: ‹card (W S S) = card (W S1 S1) + card (W S2 S2) + 1›*) by (metis card_Un_disjoint (*‹⟦finite (?A::?'a set); finite (?B::?'a set); ?A ∩ ?B = {}⟧ ⟹ card (?A ∪ ?B) = card ?A + card ?B›*) finite_UnI (*‹⟦finite (?F::?'a set); finite (?G::?'a set)⟧ ⟹ finite (?F ∪ ?G)›*) inf_sup_distrib2 (*‹inf (sup (?y::?'a) (?z::?'a)) (?x::?'a) = sup (inf ?y ?x) (inf ?z ?x)›*) is_singletonI (*‹is_singleton {?x::?'a}›*) is_singleton_altdef (*‹is_singleton (?A::?'a set) = (card ?A = (1::nat))›*) sup_idem (*‹sup (?x::?'a) ?x = ?x›*)) moreover have "card (W S1 S1) ≤ card S1 - 1" using less.IH[OF ‹card S1 < k› _ ‹S1 ⊆ states M›] (*‹card (S1::'a set) = card S1 ⟹ card {w'::('b × 'c) list ∈ set (prefixes (w::('b × 'c) list)). w' ≠ w ∧ after (M::('a, 'b, 'c) fsm) (q1::'a) w' ∈ S1 ∧ after M (q2::'a) w' ∈ S1} ≤ card S1 - (1::nat)›*) unfolding W (*goal: ‹card {w' ∈ set (prefixes w). w' ≠ w ∧ after M q1 w' ∈ S1 ∧ after M q2 w' ∈ S1} ≤ card S1 - 1›*) by blast moreover have "card (W S2 S2) ≤ card S2 - 1" using less.IH[OF ‹card S2 < k› _ ‹S2 ⊆ states M›] (*‹card S2 = card S2 ⟹ card {w' ∈ set (prefixes w). w' ≠ w ∧ after M q1 w' ∈ S2 ∧ after M q2 w' ∈ S2} ≤ card S2 - 1›*) unfolding W (*goal: ‹card {w' ∈ set (prefixes w). w' ≠ w ∧ after M q1 w' ∈ S2 ∧ after M q2 w' ∈ S2} ≤ card S2 - 1›*) by blast ultimately have "card (W S S) ≤ card S - 1" using ‹card S = card S1 + card S2› (*‹card S = card S1 + card S2›*) using ‹card S1 < k› (*‹card S1 < k›*) ‹card S2 < k› (*‹card S2 < k›*) less.prems(1) (*‹k = card S›*) by linarith then show "?thesis" (*goal: ‹card {w' ∈ set (prefixes w). w' ≠ w ∧ after M q1 w' ∈ S ∧ after M q2 w' ∈ S} ≤ card S - 1›*) unfolding W (*goal: ‹card {w' ∈ set (prefixes w). w' ≠ w ∧ after M q1 w' ∈ S ∧ after M q2 w' ∈ S} ≤ card S - 1›*) . qed qed qed qed lemma minimally_distinguishes_proper_prefix_in_language : assumes "minimally_distinguishes M q1 q2 io" and "io' ∈ set (prefixes io)" and "io' ≠ io" shows "io' ∈ LS M q1 ∩ LS M q2" proof (-) (*goal: ‹io' ∈ LS M q1 ∩ LS M q2›*) have "io ∈ LS M q1 ∨ io ∈ LS M q2" using assms(1) (*‹minimally_distinguishes M q1 q2 io›*) unfolding minimally_distinguishes_def distinguishes_def (*goal: ‹io ∈ LS M q1 ∨ io ∈ LS M q2›*) by blast then have "io' ∈ LS M q1 ∨ io' ∈ LS M q2" by (metis assms( (*‹(io'::('b × 'c) list) ∈ set (prefixes (io::('b × 'c) list))›*) 2) prefixes_set_ob (*‹⟦(?xs::?'a list) ∈ set (prefixes (?xss::?'a list)); ⋀xs'::?'a list. ?xss = ?xs @ xs' ⟹ ?thesis::bool⟧ ⟹ ?thesis›*) language_prefix (*‹(?io1.0::(?'a × ?'b) list) @ (?io2.0::(?'a × ?'b) list) ∈ LS (?M::(?'c, ?'a, ?'b) fsm) (?q::?'c) ⟹ ?io1.0 ∈ LS ?M ?q›*)) have "length io' < length io" using assms(2,3) (*‹(io'::('b × 'c) list) ∈ set (prefixes (io::('b × 'c) list))› ‹io' ≠ io›*) unfolding prefixes_set (*goal: ‹length io' < length io›*) by auto then have "io' ∈ LS M q1 ⟷ io' ∈ LS M q2" using assms(1) (*‹minimally_distinguishes M q1 q2 io›*) unfolding minimally_distinguishes_def distinguishes_def (*goal: ‹(io' ∈ LS M q1) = (io' ∈ LS M q2)›*) by (metis Int_iff (*‹(?c ∈ ?A ∩ ?B) = (?c ∈ ?A ∧ ?c ∈ ?B)›*) Un_Int_eq( (*‹(?S ∪ ?T) ∩ ?S = ?S›*) 1) Un_Int_eq( (*‹(?S ∪ ?T) ∩ ?T = ?T›*) 2) leD (*‹?y ≤ ?x ⟹ ¬ ?x < ?y›*)) then show "?thesis" (*goal: ‹io' ∈ LS M q1 ∩ LS M q2›*) using ‹io' ∈ LS M q1 ∨ io' ∈ LS M q2› (*‹(io'::('b × 'c) list) ∈ LS (M::('a, 'b, 'c) fsm) (q1::'a) ∨ io' ∈ LS M (q2::'a)›*) by blast qed lemma distinguishes_not_Nil: assumes "distinguishes M q1 q2 io" and "q1 ∈ states M" and "q2 ∈ states M" shows "io ≠ []" using assms (*‹distinguishes M q1 q2 io› ‹q1 ∈ FSM.states M› ‹q2 ∈ FSM.states M›*) unfolding distinguishes_def (*goal: ‹io ≠ []›*) by auto fun does_distinguish :: "('a,'b,'c) fsm ⇒ 'a ⇒ 'a ⇒ ('b × 'c) list ⇒ bool" where "does_distinguish M q1 q2 io = (is_in_language M q1 io ≠ is_in_language M q2 io)" lemma does_distinguish_correctness : assumes "observable M" and "q1 ∈ states M" and "q2 ∈ states M" shows "does_distinguish M q1 q2 io = distinguishes M q1 q2 io" unfolding does_distinguish.simps is_in_language_iff[OF assms ( 1 , 2 )] is_in_language_iff[OF assms ( 1 , 3 )] distinguishes_def (*goal: ‹((io ∈ LS M q1) ≠ (io ∈ LS M q2)) = (io ∈ LS M q1 ∪ LS M q2 ∧ io ∉ LS M q1 ∩ LS M q2)›*) by blast lemma h_obs_distinguishes : assumes "observable M" and "h_obs M q1 x y = Some q1'" and "h_obs M q2 x y = None" shows "distinguishes M q1 q2 [(x,y)]" using assms(2,3) (*‹FSM.h_obs M q1 x y = Some q1'› ‹FSM.h_obs M q2 x y = None›*) LS_single_transition[of x y M] (*‹([(x, y)] ∈ LS M ?q) = (∃t∈FSM.transitions M. t_source t = ?q ∧ t_input t = x ∧ t_output t = y)›*) unfolding distinguishes_def h_obs_Some[OF assms ( 1 )] h_obs_None[OF assms ( 1 )] (*goal: ‹[(x, y)] ∈ LS M q1 ∪ LS M q2 ∧ [(x, y)] ∉ LS M q1 ∩ LS M q2›*) by (metis Int_iff (*‹(?c ∈ ?A ∩ ?B) = (?c ∈ ?A ∧ ?c ∈ ?B)›*) UnI1 (*‹?c ∈ ?A ⟹ ?c ∈ ?A ∪ ?B›*) ‹⋀y x q. (h_obs M q x y = None) = (∄q'. (q, x, y, q') ∈ FSM.transitions M)› assms( (*‹observable M›*) 1) assms( (*‹FSM.h_obs M q1 x y = Some q1'›*) 2) fst_conv (*‹fst (?x1.0, ?x2.0) = ?x1.0›*) h_obs_language_iff (*‹observable ?M ⟹ ((?x, ?y) # ?io ∈ LS ?M ?q) = (∃q'. FSM.h_obs ?M ?q ?x ?y = Some q' ∧ ?io ∈ LS ?M q')›*) option.distinct( (*‹None ≠ Some ?x2.0›*) 1) snd_conv (*‹snd (?x1.0, ?x2.0) = ?x2.0›*)) lemma distinguishes_sym : assumes "distinguishes M q1 q2 io" shows "distinguishes M q2 q1 io" using assms (*‹distinguishes M q1 q2 io›*) unfolding distinguishes_def (*goal: ‹io ∈ LS M q2 ∪ LS M q1 ∧ io ∉ LS M q2 ∩ LS M q1›*) by blast lemma distinguishes_after_prepend : assumes "observable M" and "h_obs M q1 x y ≠ None" and "h_obs M q2 x y ≠ None" and "distinguishes M (FSM.after M q1 [(x,y)]) (FSM.after M q2 [(x,y)]) γ" shows "distinguishes M q1 q2 ((x,y)#γ)" proof (-) (*goal: ‹distinguishes (M::('a, 'b, 'c) fsm) (q1::'a) (q2::'a) ((x::'b, y::'c) # (γ::('b × 'c) list))›*) have "[(x,y)] ∈ LS M q1" using assms(2) (*‹FSM.h_obs M q1 x y ≠ None›*) h_obs_language_single_transition_iff[OF assms ( 1 )] (*‹([(?x, ?y)] ∈ LS M ?q) = (FSM.h_obs M ?q ?x ?y ≠ None)›*) by auto have "[(x,y)] ∈ LS M q2" using assms(3) (*‹FSM.h_obs (M::('a::type, 'b::type, 'c::type) fsm) (q2::'a::type) (x::'b::type) (y::'c::type) ≠ None›*) h_obs_language_single_transition_iff[OF assms ( 1 )] (*‹([(?x, ?y)] ∈ LS M ?q) = (FSM.h_obs M ?q ?x ?y ≠ None)›*) by auto show "?thesis" (*goal: ‹distinguishes (M::('a, 'b, 'c) fsm) (q1::'a) (q2::'a) ((x::'b, y::'c) # (γ::('b × 'c) list))›*) using after_language_iff[OF assms ( 1 ) ‹[(x,y)] ∈ LS M q1›, of γ] (*‹(γ ∈ LS M (after M q1 [(x, y)])) = ([(x, y)] @ γ ∈ LS M q1)›*) using after_language_iff[OF assms ( 1 ) ‹[(x,y)] ∈ LS M q2›, of γ] (*‹(γ ∈ LS M (after M q2 [(x, y)])) = ([(x, y)] @ γ ∈ LS M q2)›*) using assms(4) (*‹distinguishes M (after M q1 [(x, y)]) (after M q2 [(x, y)]) γ›*) unfolding distinguishes_def (*goal: ‹(x, y) # γ ∈ LS M q1 ∪ LS M q2 ∧ (x, y) # γ ∉ LS M q1 ∩ LS M q2›*) by simp qed lemma distinguishes_after_initial_prepend : assumes "observable M" and "io1 ∈ L M" and "io2 ∈ L M" and "h_obs M (after_initial M io1) x y ≠ None" and "h_obs M (after_initial M io2) x y ≠ None" and "distinguishes M (after_initial M (io1@[(x,y)])) (after_initial M (io2@[(x,y)])) γ" shows "distinguishes M (after_initial M io1) (after_initial M io2) ((x,y)#γ)" by (metis after_split (*‹⟦observable ?M; ?α @ ?γ ∈ LS ?M ?q⟧ ⟹ after ?M (after ?M ?q ?α) ?γ = after ?M ?q (?α @ ?γ)›*) assms( (*‹observable M›*) 1) assms( (*‹io1 ∈ L M›*) 2) assms( (*‹io2 ∈ L M›*) 3) assms( (*‹FSM.h_obs M (after_initial M io1) x y ≠ None›*) 4) assms( (*‹FSM.h_obs M (after_initial M io2) x y ≠ None›*) 5) assms( (*‹distinguishes M (after_initial M (io1 @ [(x, y)])) (after_initial M (io2 @ [(x, y)])) γ›*) 6) distinguishes_after_prepend (*‹⟦observable ?M; FSM.h_obs ?M ?q1.0 ?x ?y ≠ None; FSM.h_obs ?M ?q2.0 ?x ?y ≠ None; distinguishes ?M (after ?M ?q1.0 [(?x, ?y)]) (after ?M ?q2.0 [(?x, ?y)]) ?γ⟧ ⟹ distinguishes ?M ?q1.0 ?q2.0 ((?x, ?y) # ?γ)›*) h_obs_language_append (*‹⟦observable ?M; ?u ∈ L ?M; FSM.h_obs ?M (after_initial ?M ?u) ?x ?y ≠ None⟧ ⟹ ?u @ [(?x, ?y)] ∈ L ?M›*)) subsection ‹Extending FSMs by single elements› lemma fsm_from_list_simps[simp] : "initial (fsm_from_list q ts) = (case ts of [] ⇒ q | (t#ts) ⇒ t_source t)" "states (fsm_from_list q ts) = (case ts of [] ⇒ {q} | (t#ts') ⇒ ((image t_source (set ts)) ∪ (image t_target (set ts))))" "inputs (fsm_from_list q ts) = image t_input (set ts)" "outputs (fsm_from_list q ts) = image t_output (set ts)" "transitions (fsm_from_list q ts) = set ts" (*goals: 1. ‹FSM.initial (fsm_from_list (q::'a::type) (ts::('a::type × 'b::type × 'c::type × 'a::type) list)) = (case ts of [] ⇒ q | (t::'a::type × 'b::type × 'c::type × 'a::type) # (ts::('a::type × 'b::type × 'c::type × 'a::type) list) ⇒ t_source t)› 2. ‹FSM.states (fsm_from_list (q::'a::type) (ts::('a::type × 'b::type × 'c::type × 'a::type) list)) = (case ts of [] ⇒ {q} | (t::'a::type × 'b::type × 'c::type × 'a::type) # (ts'::('a::type × 'b::type × 'c::type × 'a::type) list) ⇒ t_source ` set ts ∪ t_target ` set ts)› 3. ‹FSM.inputs (fsm_from_list (q::'a::type) (ts::('a::type × 'b::type × 'c::type × 'a::type) list)) = t_input ` set ts› 4. ‹FSM.outputs (fsm_from_list (q::'a::type) (ts::('a::type × 'b::type × 'c::type × 'a::type) list)) = t_output ` set ts› 5. ‹FSM.transitions (fsm_from_list (q::'a::type) (ts::('a::type × 'b::type × 'c::type × 'a::type) list)) = set ts› discuss goal 1*) apply (cases ts) (*goals: 1. ‹ts = [] ⟹ FSM.initial (fsm_from_list q ts) = (case ts of [] ⇒ q | t # ts ⇒ t_source t)› 2. ‹⋀a list. ts = a # list ⟹ FSM.initial (fsm_from_list q ts) = (case ts of [] ⇒ q | t # ts ⇒ t_source t)› discuss goal 1*) apply transfer (*top goal: ‹ts = [] ⟹ FSM.initial (fsm_from_list q ts) = (case ts of [] ⇒ q | t # ts ⇒ t_source t)› and 5 goals remain*) apply simp (*discuss goal 2*) apply transfer (*top goal: ‹⋀a list. ts = a # list ⟹ FSM.initial (fsm_from_list q ts) = (case ts of [] ⇒ q | t # ts ⇒ t_source t)› and 4 goals remain*) apply simp (*proven 2 subgoals*) (*discuss goal 2*) apply (cases ts) (*goals: 1. ‹(ts::('a × 'b × 'c × 'a) list) = [] ⟹ FSM.states (fsm_from_list (q::'a) ts) = (case ts of [] ⇒ {q} | (t::'a × 'b × 'c × 'a) # (ts'::('a × 'b × 'c × 'a) list) ⇒ t_source ` set ts ∪ t_target ` set ts)› 2. ‹⋀(a::'a × 'b × 'c × 'a) list::('a × 'b × 'c × 'a) list. (ts::('a × 'b × 'c × 'a) list) = a # list ⟹ FSM.states (fsm_from_list (q::'a) ts) = (case ts of [] ⇒ {q} | (t::'a × 'b × 'c × 'a) # (ts'::('a × 'b × 'c × 'a) list) ⇒ t_source ` set ts ∪ t_target ` set ts)› discuss goal 1*) apply transfer (*top goal: ‹ts = [] ⟹ FSM.states (fsm_from_list q ts) = (case ts of [] ⇒ {q} | t # ts' ⇒ t_source ` set ts ∪ t_target ` set ts)› and 4 goals remain*) apply simp (*discuss goal 2*) apply transfer (*top goal: ‹⋀a list. ts = a # list ⟹ FSM.states (fsm_from_list q ts) = (case ts of [] ⇒ {q} | t # ts' ⇒ t_source ` set ts ∪ t_target ` set ts)› and 3 goals remain*) apply simp (*proven 2 subgoals*) (*discuss goal 3*) apply (cases ts) (*goals: 1. ‹ts = [] ⟹ FSM.inputs (fsm_from_list q ts) = t_input ` set ts› 2. ‹⋀a list. ts = a # list ⟹ FSM.inputs (fsm_from_list q ts) = t_input ` set ts› discuss goal 1*) apply transfer (*top goal: ‹(ts::('a × 'b × 'c × 'a) list) = [] ⟹ FSM.inputs (fsm_from_list (q::'a) ts) = t_input ` set ts› and 3 goals remain*) apply simp (*discuss goal 2*) apply transfer (*top goal: ‹⋀a list. ts = a # list ⟹ FSM.inputs (fsm_from_list q ts) = t_input ` set ts› and 2 goals remain*) apply simp (*proven 2 subgoals*) (*discuss goal 4*) apply (cases ts) (*goals: 1. ‹ts = [] ⟹ FSM.outputs (fsm_from_list q ts) = t_output ` set ts› 2. ‹⋀a list. ts = a # list ⟹ FSM.outputs (fsm_from_list q ts) = t_output ` set ts› discuss goal 1*) apply transfer (*top goal: ‹ts = [] ⟹ FSM.outputs (fsm_from_list q ts) = t_output ` set ts› and 2 goals remain*) apply simp (*discuss goal 2*) apply transfer (*top goal: ‹⋀a list. ts = a # list ⟹ FSM.outputs (fsm_from_list q ts) = t_output ` set ts› and 1 goal remains*) apply simp (*proven 2 subgoals*) (*discuss goal 5*) apply (cases ts) (*goals: 1. ‹ts = [] ⟹ FSM.transitions (fsm_from_list q ts) = set ts› 2. ‹⋀a list. ts = a # list ⟹ FSM.transitions (fsm_from_list q ts) = set ts› discuss goal 1*) apply transfer (*top goal: ‹ts = [] ⟹ FSM.transitions (fsm_from_list q ts) = set ts› and 1 goal remains*) apply simp (*discuss goal 2*) apply transfer (*goal: ‹⋀a list. ts = a # list ⟹ FSM.transitions (fsm_from_list q ts) = set ts›*) apply simp (*proven 2 subgoals*) (*proven 5 subgoals*) . lift_definition add_transition :: "('a,'b,'c) fsm ⇒ ('a,'b,'c) transition ⇒ ('a,'b,'c) fsm" is FSM_Impl.add_transition by simp lemma add_transition_simps[simp]: assumes "t_source t ∈ states M" and "t_input t ∈ inputs M" and "t_output t ∈ outputs M" and "t_target t ∈ states M" shows "initial (add_transition M t) = initial M" "inputs (add_transition M t) = inputs M" "outputs (add_transition M t) = outputs M" "transitions (add_transition M t) = insert t (transitions M)" "states (add_transition M t) = states M" using assms (*‹t_source (t::'a × 'b × 'c × 'a) ∈ FSM.states (M::('a, 'b, 'c) fsm)› ‹t_input (t::'a::type × 'b::type × 'c::type × 'a::type) ∈ FSM.inputs (M::('a::type, 'b::type, 'c::type) fsm)› ‹t_output t ∈ FSM.outputs M› ‹t_target t ∈ FSM.states M›*) apply - (*goals: 1. ‹⟦t_source (t::'a × 'b × 'c × 'a) ∈ FSM.states (M::('a, 'b, 'c) fsm); t_input t ∈ FSM.inputs M; t_output t ∈ FSM.outputs M; t_target t ∈ FSM.states M⟧ ⟹ FSM.initial (FSM.add_transition M t) = FSM.initial M› 2. ‹⟦t_source (t::'a × 'b × 'c × 'a) ∈ FSM.states (M::('a, 'b, 'c) fsm); t_input t ∈ FSM.inputs M; t_output t ∈ FSM.outputs M; t_target t ∈ FSM.states M⟧ ⟹ FSM.inputs (FSM.add_transition M t) = FSM.inputs M› 3. ‹⟦t_source (t::'a × 'b × 'c × 'a) ∈ FSM.states (M::('a, 'b, 'c) fsm); t_input t ∈ FSM.inputs M; t_output t ∈ FSM.outputs M; t_target t ∈ FSM.states M⟧ ⟹ FSM.outputs (FSM.add_transition M t) = FSM.outputs M› 4. ‹⟦t_source (t::'a × 'b × 'c × 'a) ∈ FSM.states (M::('a, 'b, 'c) fsm); t_input t ∈ FSM.inputs M; t_output t ∈ FSM.outputs M; t_target t ∈ FSM.states M⟧ ⟹ FSM.transitions (FSM.add_transition M t) = insert t (FSM.transitions M)› 5. ‹⟦t_source (t::'a × 'b × 'c × 'a) ∈ FSM.states (M::('a, 'b, 'c) fsm); t_input t ∈ FSM.inputs M; t_output t ∈ FSM.outputs M; t_target t ∈ FSM.states M⟧ ⟹ FSM.states (FSM.add_transition M t) = FSM.states M› discuss goal 1*) apply transfer (*top goal: ‹⟦t_source t ∈ FSM.states M; t_input t ∈ FSM.inputs M; t_output t ∈ FSM.outputs M; t_target t ∈ FSM.states M⟧ ⟹ FSM.initial (FSM.add_transition M t) = FSM.initial M› and 4 goals remain*) apply simp (*discuss goal 2*) apply transfer (*top goal: ‹⟦t_source t ∈ FSM.states M; t_input t ∈ FSM.inputs M; t_output t ∈ FSM.outputs M; t_target t ∈ FSM.states M⟧ ⟹ FSM.inputs (FSM.add_transition M t) = FSM.inputs M› and 3 goals remain*) apply simp (*discuss goal 3*) apply transfer (*top goal: ‹⟦t_source t ∈ FSM.states M; t_input t ∈ FSM.inputs M; t_output t ∈ FSM.outputs M; t_target t ∈ FSM.states M⟧ ⟹ FSM.outputs (FSM.add_transition M t) = FSM.outputs M› and 2 goals remain*) apply simp (*discuss goal 4*) apply transfer (*top goal: ‹⟦t_source t ∈ FSM.states M; t_input t ∈ FSM.inputs M; t_output t ∈ FSM.outputs M; t_target t ∈ FSM.states M⟧ ⟹ FSM.transitions (FSM.add_transition M t) = insert t (FSM.transitions M)› and 1 goal remains*) apply simp (*discuss goal 5*) apply transfer (*goal: ‹⟦t_source t ∈ FSM.states M; t_input t ∈ FSM.inputs M; t_output t ∈ FSM.outputs M; t_target t ∈ FSM.states M⟧ ⟹ FSM.states (FSM.add_transition M t) = FSM.states M›*) apply simp (*proven 5 subgoals*) . lift_definition add_state :: "('a,'b,'c) fsm ⇒ 'a ⇒ ('a,'b,'c) fsm" is FSM_Impl.add_state by simp lemma add_state_simps[simp]: "initial (add_state M q) = initial M" "inputs (add_state M q) = inputs M" "outputs (add_state M q) = outputs M" "transitions (add_state M q) = transitions M" "states (add_state M q) = insert q (states M)" (*goals: 1. ‹FSM.initial (FSM.add_state M q) = FSM.initial M› 2. ‹FSM.inputs (FSM.add_state M q) = FSM.inputs M› 3. ‹FSM.outputs (FSM.add_state M q) = FSM.outputs M› 4. ‹FSM.transitions (FSM.add_state M q) = FSM.transitions M› 5. ‹FSM.states (FSM.add_state M q) = insert q (FSM.states M)› discuss goal 1*) apply transfer (*top goal: ‹FSM.initial (FSM.add_state (M::('a::type, 'b::type, 'c::type) fsm) (q::'a::type)) = FSM.initial M› and 4 goals remain*) apply simp (*discuss goal 2*) apply transfer (*top goal: ‹FSM.inputs (FSM.add_state M q) = FSM.inputs M› and 3 goals remain*) apply simp (*discuss goal 3*) apply transfer (*top goal: ‹FSM.outputs (FSM.add_state (M::('a, 'b, 'c) fsm) (q::'a)) = FSM.outputs M› and 2 goals remain*) apply simp (*discuss goal 4*) apply transfer (*top goal: ‹FSM.transitions (FSM.add_state M q) = FSM.transitions M› and 1 goal remains*) apply simp (*discuss goal 5*) apply transfer (*goal: ‹FSM.states (FSM.add_state M q) = insert q (FSM.states M)›*) apply simp (*proven 5 subgoals*) . lift_definition add_input :: "('a,'b,'c) fsm ⇒ 'b ⇒ ('a,'b,'c) fsm" is FSM_Impl.add_input by simp lemma add_input_simps[simp]: "initial (add_input M x) = initial M" "inputs (add_input M x) = insert x (inputs M)" "outputs (add_input M x) = outputs M" "transitions (add_input M x) = transitions M" "states (add_input M x) = states M" (*goals: 1. ‹FSM.initial (FSM.add_input M x) = FSM.initial M› 2. ‹FSM.inputs (FSM.add_input M x) = insert x (FSM.inputs M)› 3. ‹FSM.outputs (FSM.add_input M x) = FSM.outputs M› 4. ‹FSM.transitions (FSM.add_input M x) = FSM.transitions M› 5. ‹FSM.states (FSM.add_input M x) = FSM.states M› discuss goal 1*) apply transfer (*top goal: ‹FSM.initial (FSM.add_input M x) = FSM.initial M› and 4 goals remain*) apply simp (*discuss goal 2*) apply transfer (*top goal: ‹FSM.inputs (FSM.add_input (M::('a::type, 'b::type, 'c::type) fsm) (x::'b::type)) = insert x (FSM.inputs M)› and 3 goals remain*) apply simp (*discuss goal 3*) apply transfer (*top goal: ‹FSM.outputs (FSM.add_input M x) = FSM.outputs M› and 2 goals remain*) apply simp (*discuss goal 4*) apply transfer (*top goal: ‹FSM.transitions (FSM.add_input M x) = FSM.transitions M› and 1 goal remains*) apply simp (*discuss goal 5*) apply transfer (*goal: ‹FSM.states (FSM.add_input M x) = FSM.states M›*) apply simp (*proven 5 subgoals*) . lift_definition add_output :: "('a,'b,'c) fsm ⇒ 'c ⇒ ('a,'b,'c) fsm" is FSM_Impl.add_output by simp lemma add_output_simps[simp]: "initial (add_output M y) = initial M" "inputs (add_output M y) = inputs M" "outputs (add_output M y) = insert y (outputs M)" "transitions (add_output M y) = transitions M" "states (add_output M y) = states M" (*goals: 1. ‹FSM.initial (FSM.add_output M y) = FSM.initial M› 2. ‹FSM.inputs (FSM.add_output M y) = FSM.inputs M› 3. ‹FSM.outputs (FSM.add_output M y) = insert y (FSM.outputs M)› 4. ‹FSM.transitions (FSM.add_output M y) = FSM.transitions M› 5. ‹FSM.states (FSM.add_output M y) = FSM.states M› discuss goal 1*) apply transfer (*top goal: ‹FSM.initial (FSM.add_output M y) = FSM.initial M› and 4 goals remain*) apply simp (*discuss goal 2*) apply transfer (*top goal: ‹FSM.inputs (FSM.add_output M y) = FSM.inputs M› and 3 goals remain*) apply simp (*discuss goal 3*) apply transfer (*top goal: ‹FSM.outputs (FSM.add_output M y) = insert y (FSM.outputs M)› and 2 goals remain*) apply simp (*discuss goal 4*) apply transfer (*top goal: ‹FSM.transitions (FSM.add_output M y) = FSM.transitions M› and 1 goal remains*) apply simp (*discuss goal 5*) apply transfer (*goal: ‹FSM.states (FSM.add_output (M::('a::type, 'b::type, 'c::type) fsm) (y::'c::type)) = FSM.states M›*) apply simp (*proven 5 subgoals*) . lift_definition add_transition_with_components :: "('a,'b,'c) fsm ⇒ ('a,'b,'c) transition ⇒ ('a,'b,'c) fsm" is FSM_Impl.add_transition_with_components by simp lemma add_transition_with_components_simps[simp]: "initial (add_transition_with_components M t) = initial M" "inputs (add_transition_with_components M t) = insert (t_input t) (inputs M)" "outputs (add_transition_with_components M t) = insert (t_output t) (outputs M)" "transitions (add_transition_with_components M t) = insert t (transitions M)" "states (add_transition_with_components M t) = insert (t_target t) (insert (t_source t) (states M))" (*goals: 1. ‹FSM.initial (FSM.add_transition_with_components M t) = FSM.initial M› 2. ‹FSM.inputs (FSM.add_transition_with_components M t) = insert (t_input t) (FSM.inputs M)› 3. ‹FSM.outputs (FSM.add_transition_with_components M t) = insert (t_output t) (FSM.outputs M)› 4. ‹FSM.transitions (FSM.add_transition_with_components M t) = insert t (FSM.transitions M)› 5. ‹FSM.states (FSM.add_transition_with_components M t) = insert (t_target t) (insert (t_source t) (FSM.states M))› discuss goal 1*) apply transfer (*top goal: ‹FSM.initial (FSM.add_transition_with_components M t) = FSM.initial M› and 4 goals remain*) apply simp (*discuss goal 2*) apply transfer (*top goal: ‹FSM.inputs (FSM.add_transition_with_components M t) = insert (t_input t) (FSM.inputs M)› and 3 goals remain*) apply simp (*discuss goal 3*) apply transfer (*top goal: ‹FSM.outputs (FSM.add_transition_with_components M t) = insert (t_output t) (FSM.outputs M)› and 2 goals remain*) apply simp (*discuss goal 4*) apply transfer (*top goal: ‹FSM.transitions (FSM.add_transition_with_components M t) = insert t (FSM.transitions M)› and 1 goal remains*) apply simp (*discuss goal 5*) apply transfer (*goal: ‹FSM.states (FSM.add_transition_with_components M t) = insert (t_target t) (insert (t_source t) (FSM.states M))›*) apply simp (*proven 5 subgoals*) . subsection ‹Renaming Elements› lift_definition rename_states :: "('a,'b,'c) fsm ⇒ ('a ⇒ 'd) ⇒ ('d,'b,'c) fsm" is FSM_Impl.rename_states by simp lemma rename_states_simps[simp]: "initial (rename_states M f) = f (initial M)" "states (rename_states M f) = f ` (states M)" "inputs (rename_states M f) = inputs M" "outputs (rename_states M f) = outputs M" "transitions (rename_states M f) = (λt . (f (t_source t), t_input t, t_output t, f (t_target t))) ` transitions M" (*goals: 1. ‹FSM.initial (FSM.rename_states M f) = f (FSM.initial M)› 2. ‹FSM.states (FSM.rename_states M f) = f ` FSM.states M› 3. ‹FSM.inputs (FSM.rename_states M f) = FSM.inputs M› 4. ‹FSM.outputs (FSM.rename_states M f) = FSM.outputs M› 5. ‹FSM.transitions (FSM.rename_states M f) = (λt. (f (t_source t), t_input t, t_output t, f (t_target t))) ` FSM.transitions M› discuss goal 1*) apply transfer (*top goal: ‹FSM.initial (FSM.rename_states M f) = f (FSM.initial M)› and 4 goals remain*) apply simp (*discuss goal 2*) apply transfer (*top goal: ‹FSM.states (FSM.rename_states M f) = f ` FSM.states M› and 3 goals remain*) apply simp (*discuss goal 3*) apply transfer (*top goal: ‹FSM.inputs (FSM.rename_states M f) = FSM.inputs M› and 2 goals remain*) apply simp (*discuss goal 4*) apply transfer (*top goal: ‹FSM.outputs (FSM.rename_states M f) = FSM.outputs M› and 1 goal remains*) apply simp (*discuss goal 5*) apply transfer (*goal: ‹FSM.transitions (FSM.rename_states M f) = (λt. (f (t_source t), t_input t, t_output t, f (t_target t))) ` FSM.transitions M›*) apply simp (*proven 5 subgoals*) . lemma rename_states_isomorphism_language_state : assumes "bij_betw f (states M) (f ` states M)" and "q ∈ states M" shows "LS (rename_states M f) (f q) = LS M q" proof (-) (*goal: ‹LS (FSM.rename_states M f) (f q) = LS M q›*) have "*": "bij_betw f (FSM.states M) (FSM.states (FSM.rename_states M f))" using assms (*‹bij_betw f (FSM.states M) (f ` FSM.states M)› ‹q ∈ FSM.states M›*) rename_states_simps (*‹FSM.initial (FSM.rename_states ?M ?f) = ?f (FSM.initial ?M)› ‹FSM.states (FSM.rename_states (?M::(?'d::type, ?'b::type, ?'c::type) fsm) (?f::?'d::type ⇒ ?'a::type)) = ?f ` FSM.states ?M› ‹FSM.inputs (FSM.rename_states ?M ?f) = FSM.inputs ?M› ‹FSM.outputs (FSM.rename_states ?M ?f) = FSM.outputs ?M› ‹FSM.transitions (FSM.rename_states ?M ?f) = (λt. (?f (t_source t), t_input t, t_output t, ?f (t_target t))) ` FSM.transitions ?M›*) by auto have "**": "f (initial M) = initial (rename_states M f)" using rename_states_simps (*‹FSM.initial (FSM.rename_states ?M ?f) = ?f (FSM.initial ?M)› ‹FSM.states (FSM.rename_states ?M ?f) = ?f ` FSM.states ?M› ‹FSM.inputs (FSM.rename_states ?M ?f) = FSM.inputs ?M› ‹FSM.outputs (FSM.rename_states ?M ?f) = FSM.outputs ?M› ‹FSM.transitions (FSM.rename_states (?M::(?'d::type, ?'b::type, ?'c::type) fsm) (?f::?'d::type ⇒ ?'a::type)) = (λt::?'d::type × ?'b::type × ?'c::type × ?'d::type. (?f (t_source t), t_input t, t_output t, ?f (t_target t))) ` FSM.transitions ?M›*) by auto have "***": "(⋀q x y q'. q ∈ states M ⟹ q' ∈ states M ⟹ ((q, x, y, q') ∈ transitions M) = ((f q, x, y, f q') ∈ transitions (rename_states M f)))" proof (standard) (*goals: 1. ‹⋀q x y q'. ⟦q ∈ FSM.states M; q' ∈ FSM.states M; (q, x, y, q') ∈ FSM.transitions M⟧ ⟹ (f q, x, y, f q') ∈ FSM.transitions (FSM.rename_states M f)› 2. ‹⋀q x y q'. ⟦q ∈ FSM.states M; q' ∈ FSM.states M; (f q, x, y, f q') ∈ FSM.transitions (FSM.rename_states M f)⟧ ⟹ (q, x, y, q') ∈ FSM.transitions M›*) fix q and x and y and q' assume "q ∈ states M" and "q' ∈ states M" (*‹(q::'a) ∈ FSM.states (M::('a, 'c, 'd) fsm)› ‹(q'::'a) ∈ FSM.states (M::('a, 'c, 'd) fsm)›*) show "(q, x, y, q') ∈ transitions M ⟹ (f q, x, y, f q') ∈ transitions (rename_states M f)" unfolding assms rename_states_simps (*goal: ‹(q, x, y, q') ∈ FSM.transitions M ⟹ (f q, x, y, f q') ∈ (λt. (f (t_source t), t_input t, t_output t, f (t_target t))) ` FSM.transitions M›*) by force show "(f q, x, y, f q') ∈ transitions (rename_states M f) ⟹ (q, x, y, q') ∈ transitions M" proof (-) (*goal: ‹(f q, x, y, f q') ∈ FSM.transitions (FSM.rename_states M f) ⟹ (q, x, y, q') ∈ FSM.transitions M›*) assume "(f q, x, y, f q') ∈ transitions (rename_states M f)" (*‹((f::'a ⇒ 'b) (q::'a), x::'c, y::'d, f (q'::'a)) ∈ FSM.transitions (FSM.rename_states (M::('a, 'c, 'd) fsm) f)›*) then obtain t where "(f q, x, y, f q') = (f (t_source t), t_input t, t_output t, f (t_target t))" and "t ∈ transitions M" (*goal: ‹(⋀t. ⟦(f q, x, y, f q') = (f (t_source t), t_input t, t_output t, f (t_target t)); t ∈ FSM.transitions M⟧ ⟹ thesis) ⟹ thesis›*) unfolding assms rename_states_simps (*goal: ‹(⋀t. ⟦(f q, x, y, f q') = (f (t_source t), t_input t, t_output t, f (t_target t)); t ∈ FSM.transitions M⟧ ⟹ thesis) ⟹ thesis›*) by blast then have "t_source t ∈ states M" and "t_target t ∈ states M" and "f (t_source t) = f q" and "f (t_target t) = f q'" and "t_input t = x" and "t_output t = y" apply - (*goals: 1. ‹⟦(f q, x, y, f q') = (f (t_source t), t_input t, t_output t, f (t_target t)); t ∈ FSM.transitions M⟧ ⟹ t_source t ∈ FSM.states M› 2. ‹⟦(f q, x, y, f q') = (f (t_source t), t_input t, t_output t, f (t_target t)); t ∈ FSM.transitions M⟧ ⟹ t_target t ∈ FSM.states M› 3. ‹⟦(f q, x, y, f q') = (f (t_source t), t_input t, t_output t, f (t_target t)); t ∈ FSM.transitions M⟧ ⟹ f (t_source t) = f q› 4. ‹⟦(f q, x, y, f q') = (f (t_source t), t_input t, t_output t, f (t_target t)); t ∈ FSM.transitions M⟧ ⟹ f (t_target t) = f q'› 5. ‹⟦(f q, x, y, f q') = (f (t_source t), t_input t, t_output t, f (t_target t)); t ∈ FSM.transitions M⟧ ⟹ t_input t = x› 6. ‹⟦(f q, x, y, f q') = (f (t_source t), t_input t, t_output t, f (t_target t)); t ∈ FSM.transitions M⟧ ⟹ t_output t = 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*) . have "f q ∈ states (rename_states M f)" and "f q' ∈ states (rename_states M f)" using ‹(f q, x, y, f q') ∈ transitions (rename_states M f)› (*‹(f q, x, y, f q') ∈ FSM.transitions (FSM.rename_states M f)›*) apply - (*goals: 1. ‹((f::'a::type ⇒ 'b::type) (q::'a::type), x::'c::type, y::'d::type, f (q'::'a::type)) ∈ FSM.transitions (FSM.rename_states (M::('a::type, 'c::type, 'd::type) fsm) f) ⟹ f q ∈ FSM.states (FSM.rename_states M f)› 2. ‹((f::'a::type ⇒ 'b::type) (q::'a::type), x::'c::type, y::'d::type, f (q'::'a::type)) ∈ FSM.transitions (FSM.rename_states (M::('a::type, 'c::type, 'd::type) fsm) f) ⟹ f q' ∈ FSM.states (FSM.rename_states M f)› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . have "t_source t = q" using ‹f (t_source t) = f q› (*‹f (t_source t) = f q›*) ‹q ∈ states M› (*‹q ∈ FSM.states M›*) ‹t_source t ∈ states M› (*‹t_source (t::'a × 'c × 'd × 'a) ∈ FSM.states (M::('a, 'c, 'd) fsm)›*) using assms (*‹bij_betw f (FSM.states M) (f ` FSM.states M)› ‹q ∈ FSM.states M›*) unfolding bij_betw_def inj_on_def (*goal: ‹t_source t = q›*) by blast moreover have "t_target t = q'" using ‹f (t_target t) = f q'› (*‹f (t_target t) = f q'›*) ‹q' ∈ states M› (*‹q' ∈ FSM.states M›*) ‹t_target t ∈ states M› (*‹t_target t ∈ FSM.states M›*) using assms (*‹bij_betw f (FSM.states M) (f ` FSM.states M)› ‹q ∈ FSM.states M›*) unfolding bij_betw_def inj_on_def (*goal: ‹t_target t = q'›*) by blast ultimately show "(q, x, y, q') ∈ transitions M" using ‹t_input t = x› (*‹t_input (t::'a::type × 'c::type × 'd::type × 'a::type) = (x::'c::type)›*) ‹t_output t = y› (*‹t_output (t::'a × 'c × 'd × 'a) = (y::'d)›*) ‹t ∈ transitions M› (*‹t ∈ FSM.transitions M›*) by auto qed qed show "?thesis" (*goal: ‹LS (FSM.rename_states M f) (f q) = LS M q›*) using language_equivalence_from_isomorphism[OF * ** *** assms ( 2 )] (*‹⟦⋀q x y q'. ⟦q ∈ FSM.states M; q' ∈ FSM.states M⟧ ⟹ q ∈ FSM.states M; ⋀q x y q'. ⟦q ∈ FSM.states M; q' ∈ FSM.states M⟧ ⟹ q' ∈ FSM.states M⟧ ⟹ LS M q = LS (FSM.rename_states M f) (f q)›*) by blast qed lemma rename_states_isomorphism_language : assumes "bij_betw f (states M) (f ` states M)" shows "L (rename_states M f) = L M" using rename_states_isomorphism_language_state[OF assms fsm_initial] (*‹LS (FSM.rename_states M f) (f (FSM.initial M)) = L M›*) unfolding rename_states_simps (*goal: ‹LS (FSM.rename_states M f) (f (FSM.initial M)) = L M›*) . lemma rename_states_observable : assumes "bij_betw f (states M) (f ` states M)" and "observable M" shows "observable (rename_states M f)" proof (-) (*goal: ‹observable (FSM.rename_states M f)›*) have "⋀ q1 x y q1' q1'' . (q1,x,y,q1') ∈ transitions (rename_states M f) ⟹ (q1,x,y,q1'') ∈ transitions (rename_states M f) ⟹ q1' = q1''" proof (-) (*goal: ‹⋀q1 x y q1' q1''. ⟦(q1, x, y, q1') ∈ FSM.transitions (FSM.rename_states M f); (q1, x, y, q1'') ∈ FSM.transitions (FSM.rename_states M f)⟧ ⟹ q1' = q1''›*) fix q1 and x and y and q1' and q1'' assume "(q1,x,y,q1') ∈ transitions (rename_states M f)" and "(q1,x,y,q1'') ∈ transitions (rename_states M f)" (*‹(q1::'b, x::'c, y::'d, q1'::'b) ∈ FSM.transitions (FSM.rename_states (M::('a, 'c, 'd) fsm) (f::'a ⇒ 'b))› ‹(q1::'b, x::'c, y::'d, q1''::'b) ∈ FSM.transitions (FSM.rename_states (M::('a, 'c, 'd) fsm) (f::'a ⇒ 'b))›*) then obtain t' and t'' where "t' ∈ transitions M" and "t'' ∈ transitions M" and "(f (t_source t'), t_input t', t_output t', f (t_target t')) = (q1,x,y,q1')" and "(f (t_source t''), t_input t'', t_output t'', f (t_target t'')) = (q1,x,y,q1'')" (*goal: ‹(⋀t' t''. ⟦t' ∈ FSM.transitions M; t'' ∈ FSM.transitions M; (f (t_source t'), t_input t', t_output t', f (t_target t')) = (q1, x, y, q1'); (f (t_source t''), t_input t'', t_output t'', f (t_target t'')) = (q1, x, y, q1'')⟧ ⟹ thesis) ⟹ thesis›*) unfolding rename_states_simps (*goal: ‹(⋀t' t''. ⟦t' ∈ FSM.transitions M; t'' ∈ FSM.transitions M; (f (t_source t'), t_input t', t_output t', f (t_target t')) = (q1, x, y, q1'); (f (t_source t''), t_input t'', t_output t'', f (t_target t'')) = (q1, x, y, q1'')⟧ ⟹ thesis) ⟹ thesis›*) by force then have "f (t_source t') = f (t_source t'')" by auto moreover have "t_source t' ∈ states M" and "t_source t'' ∈ states M" using ‹t' ∈ transitions M› (*‹t' ∈ FSM.transitions M›*) ‹t'' ∈ transitions M› (*‹t'' ∈ FSM.transitions M›*) apply - (*goals: 1. ‹⟦t' ∈ FSM.transitions M; t'' ∈ FSM.transitions M⟧ ⟹ t_source t' ∈ FSM.states M› 2. ‹⟦t' ∈ FSM.transitions M; t'' ∈ FSM.transitions M⟧ ⟹ t_source t'' ∈ FSM.states M› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . ultimately have "t_source t' = t_source t''" using assms(1) (*‹bij_betw f (FSM.states M) (f ` FSM.states M)›*) unfolding bij_betw_def inj_on_def (*goal: ‹t_source t' = t_source t''›*) by blast then have "t_target t' = t_target t''" using assms(2) (*‹observable M›*) unfolding observable.simps (*goal: ‹t_target t' = t_target t''›*) by (metis Pair_inject (*‹⟦(?a, ?b) = (?a', ?b'); ⟦?a = ?a'; ?b = ?b'⟧ ⟹ ?R⟧ ⟹ ?R›*) ‹(f (t_source t''), t_input t'', t_output t'', f (t_target t'')) = (q1, x, y, q1'')› ‹(f (t_source t'), t_input t', t_output t', f (t_target t')) = (q1, x, y, q1')› ‹t' ∈ FSM.transitions M› ‹t'' ∈ FSM.transitions M›) then show "q1' = q1''" using ‹(f (t_source t''), t_input t'', t_output t'', f (t_target t'')) = (q1, x, y, q1'')› (*‹((f::'a ⇒ 'b) (t_source (t''::'a × 'c × 'd × 'a)), t_input t'', t_output t'', f (t_target t'')) = (q1::'b, x::'c, y::'d, q1''::'b)›*) ‹(f (t_source t'), t_input t', t_output t', f (t_target t')) = (q1, x, y, q1')› (*‹(f (t_source t'), t_input t', t_output t', f (t_target t')) = (q1, x, y, q1')›*) by auto qed then show "?thesis" (*goal: ‹observable (FSM.rename_states M f)›*) unfolding observable_alt_def (*goal: ‹∀q1 x y q1' q1''. (q1, x, y, q1') ∈ FSM.transitions (FSM.rename_states M f) ∧ (q1, x, y, q1'') ∈ FSM.transitions (FSM.rename_states M f) ⟶ q1' = q1''›*) by blast qed lemma rename_states_minimal : assumes "bij_betw f (states M) (f ` states M)" and "minimal M" shows "minimal (rename_states M f)" proof (-) (*goal: ‹minimal (FSM.rename_states M f)›*) have "⋀ q q' . q ∈ f ` FSM.states M ⟹ q' ∈ f ` FSM.states M ⟹ q ≠ q' ⟹ LS (rename_states M f) q ≠ LS (rename_states M f) q'" proof (-) (*goal: ‹⋀(q::'b::type) q'::'b::type. ⟦q ∈ (f::'a::type ⇒ 'b::type) ` FSM.states (M::('a::type, 'c::type, 'd::type) fsm); q' ∈ f ` FSM.states M; q ≠ q'⟧ ⟹ LS (FSM.rename_states M f) q ≠ LS (FSM.rename_states M f) q'›*) fix q and q' assume "q ∈ f ` FSM.states M" and "q' ∈ f ` FSM.states M" and "q ≠ q'" (*‹(q::'b) ∈ (f::'a ⇒ 'b) ` FSM.states (M::('a, 'c, 'd) fsm)› ‹(q'::'b) ∈ (f::'a ⇒ 'b) ` FSM.states (M::('a, 'c, 'd) fsm)› ‹(q::'b) ≠ (q'::'b)›*) then obtain fq and fq' where "fq ∈ states M" and "fq' ∈ states M" and "q = f fq" and "q' = f fq'" (*goal: ‹(⋀fq fq'. ⟦fq ∈ FSM.states M; fq' ∈ FSM.states M; q = f fq; q' = f fq'⟧ ⟹ thesis) ⟹ thesis›*) by auto then have "fq ≠ fq'" using ‹q ≠ q'› (*‹(q::'b) ≠ (q'::'b)›*) by auto then have "LS M fq ≠ LS M fq'" by (meson ‹fq ∈ FSM.states M› ‹fq' ∈ FSM.states M› assms( (*‹minimal (M::('a::type, 'c::type, 'd::type) fsm)›*) 2) minimal.elims( (*‹⟦minimal (?x::(?'a::type, ?'b::type, ?'c::type) fsm); ⋀M::(?'a::type, ?'b::type, ?'c::type) fsm. ⟦?x = M; ∀q::?'a::type∈FSM.states M. ∀q'::?'a::type∈FSM.states M. q ≠ q' ⟶ LS M q ≠ LS M q'⟧ ⟹ ?P::bool⟧ ⟹ ?P›*) 2)) then show "LS (rename_states M f) q ≠ LS (rename_states M f) q'" using rename_states_isomorphism_language_state[OF assms ( 1 )] (*‹?q ∈ FSM.states M ⟹ LS (FSM.rename_states M f) (f ?q) = LS M ?q›*) by (simp add: ‹fq ∈ FSM.states M› ‹fq' ∈ FSM.states M› ‹q = f fq› ‹q' = f fq'›) qed then show "?thesis" (*goal: ‹minimal (FSM.rename_states (M::('a::type, 'c::type, 'd::type) fsm) (f::'a::type ⇒ 'b::type))›*) by auto qed fun index_states :: "('a::linorder,'b,'c) fsm ⇒ (nat,'b,'c) fsm" where "index_states M = rename_states M (assign_indices (states M))" lemma assign_indices_bij_betw: "bij_betw (assign_indices (FSM.states M)) (FSM.states M) (assign_indices (FSM.states M) ` FSM.states M)" using assign_indices_bij[OF fsm_states_finite [ of M ]] (*‹bij_betw (assign_indices (FSM.states M)) (FSM.states M) {..<card (FSM.states M)}›*) by (simp add: bij_betw_def (*‹bij_betw ?f ?A ?B = (inj_on ?f ?A ∧ ?f ` ?A = ?B)›*)) lemma index_states_language : "L (index_states M) = L M" using rename_states_isomorphism_language[of "assign_indices (states M)" M, OF assign_indices_bij_betw] (*‹L (FSM.rename_states M (assign_indices (FSM.states M))) = L M›*) by auto lemma index_states_observable : assumes "observable M" shows "observable (index_states M)" using rename_states_observable[of "assign_indices (states M)", OF assign_indices_bij_betw assms] (*‹observable (FSM.rename_states (M::('a, 'b, 'c) fsm) (assign_indices (FSM.states M)))›*) unfolding index_states.simps (*goal: ‹observable (FSM.rename_states M (assign_indices (FSM.states M)))›*) . lemma index_states_minimal : assumes "minimal M" shows "minimal (index_states M)" using rename_states_minimal[of "assign_indices (states M)", OF assign_indices_bij_betw assms] (*‹minimal (FSM.rename_states M (assign_indices (FSM.states M)))›*) unfolding index_states.simps (*goal: ‹minimal (FSM.rename_states (M::('a::linorder, 'b::type, 'c::type) fsm) (assign_indices (FSM.states M)))›*) . fun index_states_integer :: "('a::linorder,'b,'c) fsm ⇒ (integer,'b,'c) fsm" where "index_states_integer M = rename_states M (integer_of_nat ∘ assign_indices (states M))" lemma assign_indices_integer_bij_betw: "bij_betw (integer_of_nat ∘ assign_indices (states M)) (FSM.states M) ((integer_of_nat ∘ assign_indices (states M)) ` FSM.states M)" proof (-) (*goal: ‹bij_betw (integer_of_nat ∘ assign_indices (FSM.states M)) (FSM.states M) ((integer_of_nat ∘ assign_indices (FSM.states M)) ` FSM.states M)›*) have "*": "inj_on (assign_indices (FSM.states M)) (FSM.states M)" using assign_indices_bij[OF fsm_states_finite [ of M ]] (*‹bij_betw (assign_indices (FSM.states M)) (FSM.states M) {..<card (FSM.states M)}›*) unfolding bij_betw_def (*goal: ‹inj_on (assign_indices (FSM.states M)) (FSM.states M)›*) by auto then have "inj_on (integer_of_nat ∘ assign_indices (states M)) (FSM.states M)" unfolding inj_on_def (*goal: ‹∀x::'a∈FSM.states (M::('a, 'b, 'c) fsm). ∀y::'a∈FSM.states M. (integer_of_nat ∘ assign_indices (FSM.states M)) x = (integer_of_nat ∘ assign_indices (FSM.states M)) y ⟶ x = y›*) by (metis comp_apply (*‹(?f ∘ ?g) ?x = ?f (?g ?x)›*) nat_of_integer_integer_of_nat (*‹nat_of_integer (integer_of_nat ?n) = ?n›*)) then show "?thesis" (*goal: ‹bij_betw (integer_of_nat ∘ assign_indices (FSM.states M)) (FSM.states M) ((integer_of_nat ∘ assign_indices (FSM.states M)) ` FSM.states M)›*) unfolding bij_betw_def (*goal: ‹inj_on (integer_of_nat ∘ assign_indices (FSM.states (M::('a::linorder, 'b::type, 'c::type) fsm))) (FSM.states M) ∧ (integer_of_nat ∘ assign_indices (FSM.states M)) ` FSM.states M = (integer_of_nat ∘ assign_indices (FSM.states M)) ` FSM.states M›*) by auto qed lemma index_states_integer_language : "L (index_states_integer M) = L M" using rename_states_isomorphism_language[of "integer_of_nat ∘ assign_indices (states M)" M, OF assign_indices_integer_bij_betw] (*‹L (FSM.rename_states M (integer_of_nat ∘ assign_indices (FSM.states M))) = L M›*) by auto lemma index_states_integer_observable : assumes "observable M" shows "observable (index_states_integer M)" using rename_states_observable[of "integer_of_nat ∘ assign_indices (states M)" M, OF assign_indices_integer_bij_betw assms] (*‹observable (FSM.rename_states M (integer_of_nat ∘ assign_indices (FSM.states M)))›*) unfolding index_states_integer.simps (*goal: ‹observable (FSM.rename_states M (integer_of_nat ∘ assign_indices (FSM.states M)))›*) . lemma index_states_integer_minimal : assumes "minimal M" shows "minimal (index_states_integer M)" using rename_states_minimal[of "integer_of_nat ∘ assign_indices (states M)" M, OF assign_indices_integer_bij_betw assms] (*‹minimal (FSM.rename_states M (integer_of_nat ∘ assign_indices (FSM.states M)))›*) unfolding index_states_integer.simps (*goal: ‹minimal (FSM.rename_states M (integer_of_nat ∘ assign_indices (FSM.states M)))›*) . subsection ‹Canonical Separators› lift_definition canonical_separator' :: "('a,'b,'c) fsm ⇒ (('a × 'a),'b,'c) fsm ⇒ 'a ⇒ 'a ⇒ (('a × 'a) + 'a,'b,'c) fsm" is FSM_Impl.canonical_separator' proof - fix A :: "('a,'b,'c) fsm_impl" fix B :: "('a × 'a,'b,'c) fsm_impl" fix q1 :: 'a fix q2 :: 'a assume "well_formed_fsm A" and "well_formed_fsm B" then have p1a: "fsm_impl.initial A ∈ fsm_impl.states A" and p2a: "finite (fsm_impl.states A)" and p3a: "finite (fsm_impl.inputs A)" and p4a: "finite (fsm_impl.outputs A)" and p5a: "finite (fsm_impl.transitions A)" and p6a: "(∀t∈fsm_impl.transitions A. t_source t ∈ fsm_impl.states A ∧ t_input t ∈ fsm_impl.inputs A ∧ t_target t ∈ fsm_impl.states A ∧ t_output t ∈ fsm_impl.outputs A)" and p1b: "fsm_impl.initial B ∈ fsm_impl.states B" and p2b: "finite (fsm_impl.states B)" and p3b: "finite (fsm_impl.inputs B)" and p4b: "finite (fsm_impl.outputs B)" and p5b: "finite (fsm_impl.transitions B)" and p6b: "(∀t∈fsm_impl.transitions B. t_source t ∈ fsm_impl.states B ∧ t_input t ∈ fsm_impl.inputs B ∧ t_target t ∈ fsm_impl.states B ∧ t_output t ∈ fsm_impl.outputs B)" by simp+ let ?P = "FSM_Impl.canonical_separator' A B q1 q2" show "well_formed_fsm ?P" proof (cases "fsm_impl.initial B = (q1,q2)") case False then show ?thesis by auto next case True let ?f = "(λqx . (case (set_as_map (image (λ(q,x,y,q') . ((q,x),y)) (fsm_impl.transitions A))) qx of Some yqs ⇒ yqs | None ⇒ {}))" have "⋀ qx . (λqx . (case (set_as_map (image (λ(q,x,y,q') . ((q,x),y)) (fsm_impl.transitions A))) qx of Some yqs ⇒ yqs | None ⇒ {})) qx = (λ qx . {z. (qx, z) ∈ (λ(q, x, y, q'). ((q, x), y)) ` fsm_impl.transitions A}) qx" proof - fix qx show "⋀ qx . (λqx . (case (set_as_map (image (λ(q,x,y,q') . ((q,x),y)) (fsm_impl.transitions A))) qx of Some yqs ⇒ yqs | None ⇒ {})) qx = (λ qx . {z. (qx, z) ∈ (λ(q, x, y, q'). ((q, x), y)) ` fsm_impl.transitions A}) qx" unfolding set_as_map_def by (cases "∃z. (qx, z) ∈ (λ(q, x, y, q'). ((q, x), y)) ` fsm_impl.transitions A"; auto) qed moreover have "⋀ qx . (λ qx . {z. (qx, z) ∈ (λ(q, x, y, q'). ((q, x), y)) ` fsm_impl.transitions A}) qx = (λ qx . {y | y . ∃ q' . (fst qx, snd qx, y, q') ∈ fsm_impl.transitions A}) qx" proof - fix qx show "(λ qx . {z. (qx, z) ∈ (λ(q, x, y, q'). ((q, x), y)) ` fsm_impl.transitions A}) qx = (λ qx . {y | y . ∃ q' . (fst qx, snd qx, y, q') ∈ fsm_impl.transitions A}) qx" by force qed ultimately have *:" ?f = (λ qx . {y | y . ∃ q' . (fst qx, snd qx, y, q') ∈ fsm_impl.transitions A})" by blast let ?shifted_transitions' = "shifted_transitions (fsm_impl.transitions B)" let ?distinguishing_transitions_lr = "distinguishing_transitions ?f q1 q2 (fsm_impl.states B) (fsm_impl.inputs B)" let ?ts = "?shifted_transitions' ∪ ?distinguishing_transitions_lr" have "FSM_Impl.states ?P = (image Inl (FSM_Impl.states B)) ∪ {Inr q1, Inr q2}" and "FSM_Impl.transitions ?P = ?ts" unfolding FSM_Impl.canonical_separator'.simps Let_def True by simp+ have p2: "finite (fsm_impl.states ?P)" unfolding ‹FSM_Impl.states ?P = (image Inl (FSM_Impl.states B)) ∪ {Inr q1, Inr q2}› using p2b by blast have "fsm_impl.initial ?P = Inl (q1,q2)" by auto then have p1: "fsm_impl.initial ?P ∈ fsm_impl.states ?P" using p1a p1b unfolding canonical_separator'.simps True by auto have p3: "finite (fsm_impl.inputs ?P)" using p3a p3b by auto have p4: "finite (fsm_impl.outputs ?P)" using p4a p4b by auto have "finite (fsm_impl.states B × fsm_impl.inputs B)" using p2b p3b by blast moreover have **: "⋀ x q1 . finite ({y |y. ∃q'. (fst (q1, x), snd (q1, x), y, q') ∈ fsm_impl.transitions A})" proof - fix x q1 have "{y |y. ∃q'. (fst (q1, x), snd (q1, x), y, q') ∈ fsm_impl.transitions A} = {t_output t | t . t ∈ fsm_impl.transitions A ∧ t_source t = q1 ∧ t_input t = x}" by auto then have "{y |y. ∃q'. (fst (q1, x), snd (q1, x), y, q') ∈ fsm_impl.transitions A} ⊆ image t_output (fsm_impl.transitions A)" unfolding fst_conv snd_conv by blast moreover have "finite (image t_output (fsm_impl.transitions A))" using p5a by auto ultimately show "finite ({y |y. ∃q'. (fst (q1, x), snd (q1, x), y, q') ∈ fsm_impl.transitions A})" by (simp add: finite_subset) qed ultimately have "finite ?distinguishing_transitions_lr" unfolding * distinguishing_transitions_def by force moreover have "finite ?shifted_transitions'" unfolding shifted_transitions_def using p5b by auto ultimately have "finite ?ts" by blast then have p5: "finite (fsm_impl.transitions ?P)" by simp have "fsm_impl.inputs ?P = fsm_impl.inputs A ∪ fsm_impl.inputs B" using True by auto have "fsm_impl.outputs ?P = fsm_impl.outputs A ∪ fsm_impl.outputs B" using True by auto have "⋀ t . t ∈ ?shifted_transitions' ⟹ t_source t ∈ fsm_impl.states ?P ∧ t_target t ∈ fsm_impl.states ?P" unfolding ‹FSM_Impl.states ?P = (image Inl (FSM_Impl.states B)) ∪ {Inr q1, Inr q2}› shifted_transitions_def using p6b by force moreover have "⋀ t . t ∈ ?distinguishing_transitions_lr ⟹ t_source t ∈ fsm_impl.states ?P ∧ t_target t ∈ fsm_impl.states ?P" unfolding ‹FSM_Impl.states ?P = (image Inl (FSM_Impl.states B)) ∪ {Inr q1, Inr q2}› distinguishing_transitions_def * by force ultimately have "⋀ t . t ∈ ?ts ⟹ t_source t ∈ fsm_impl.states ?P ∧ t_target t ∈ fsm_impl.states ?P" by blast moreover have "⋀ t . t ∈ ?shifted_transitions' ⟹ t_input t ∈ fsm_impl.inputs ?P ∧ t_output t ∈ fsm_impl.outputs ?P" proof - have "⋀ t . t ∈ ?shifted_transitions' ⟹ t_input t ∈ fsm_impl.inputs B ∧ t_output t ∈ fsm_impl.outputs B" unfolding shifted_transitions_def using p6b by auto then show "⋀ t . t ∈ ?shifted_transitions' ⟹ t_input t ∈ fsm_impl.inputs ?P ∧ t_output t ∈ fsm_impl.outputs ?P" unfolding ‹fsm_impl.inputs ?P = fsm_impl.inputs A ∪ fsm_impl.inputs B› ‹fsm_impl.outputs ?P = fsm_impl.outputs A ∪ fsm_impl.outputs B› by blast qed moreover have "⋀ t . t ∈ ?distinguishing_transitions_lr ⟹ t_input t ∈ fsm_impl.inputs ?P ∧ t_output t ∈ fsm_impl.outputs ?P" unfolding * distinguishing_transitions_def using p6a p6b True by auto ultimately have p6: "(∀t∈fsm_impl.transitions ?P. t_source t ∈ fsm_impl.states ?P ∧ t_input t ∈ fsm_impl.inputs ?P ∧ t_target t ∈ fsm_impl.states ?P ∧ t_output t ∈ fsm_impl.outputs ?P)" unfolding ‹FSM_Impl.transitions ?P = ?ts› by blast show "well_formed_fsm ?P" using p1 p2 p3 p4 p5 p6 by linarith qed qed lemma canonical_separator'_simps : assumes "initial P = (q1,q2)" shows "initial (canonical_separator' M P q1 q2) = Inl (q1,q2)" "states (canonical_separator' M P q1 q2) = (image Inl (states P)) ∪ {Inr q1, Inr q2}" "inputs (canonical_separator' M P q1 q2) = inputs M ∪ inputs P" "outputs (canonical_separator' M P q1 q2) = outputs M ∪ outputs P" "transitions (canonical_separator' M P q1 q2) = shifted_transitions (transitions P) ∪ distinguishing_transitions (h_out M) q1 q2 (states P) (inputs P)" using assms (*‹FSM.initial P = (q1, q2)›*) unfolding h_out_code (*goals: 1. ‹FSM.initial (FSM.canonical_separator' M P q1 q2) = Inl (q1, q2)› 2. ‹FSM.states (FSM.canonical_separator' M P q1 q2) = Inl ` FSM.states P ∪ {Inr q1, Inr q2}› 3. ‹FSM.inputs (FSM.canonical_separator' M P q1 q2) = FSM.inputs M ∪ FSM.inputs P› 4. ‹FSM.outputs (FSM.canonical_separator' M P q1 q2) = FSM.outputs M ∪ FSM.outputs P› 5. ‹FSM.transitions (FSM.canonical_separator' M P q1 q2) = shifted_transitions (FSM.transitions P) ∪ distinguishing_transitions (λqx. case set_as_map ((λ(q, x, y, q'). ((q, x), y)) ` FSM.transitions M) qx of None ⇒ {} | Some yqs ⇒ yqs) q1 q2 (FSM.states P) (FSM.inputs P)›*) apply - (*goals: 1. ‹FSM.initial P = (q1, q2) ⟹ FSM.initial (FSM.canonical_separator' M P q1 q2) = Inl (q1, q2)› 2. ‹FSM.initial P = (q1, q2) ⟹ FSM.states (FSM.canonical_separator' M P q1 q2) = Inl ` FSM.states P ∪ {Inr q1, Inr q2}› 3. ‹FSM.initial P = (q1, q2) ⟹ FSM.inputs (FSM.canonical_separator' M P q1 q2) = FSM.inputs M ∪ FSM.inputs P› 4. ‹FSM.initial P = (q1, q2) ⟹ FSM.outputs (FSM.canonical_separator' M P q1 q2) = FSM.outputs M ∪ FSM.outputs P› 5. ‹FSM.initial P = (q1, q2) ⟹ FSM.transitions (FSM.canonical_separator' M P q1 q2) = shifted_transitions (FSM.transitions P) ∪ distinguishing_transitions (λqx. case set_as_map ((λ(q, x, y, q'). ((q, x), y)) ` FSM.transitions M) qx of None ⇒ {} | Some yqs ⇒ yqs) q1 q2 (FSM.states P) (FSM.inputs P)› discuss goal 1*) apply ((transfer)[1]) (*top goal: ‹FSM.initial P = (q1, q2) ⟹ FSM.initial (FSM.canonical_separator' M P q1 q2) = Inl (q1, q2)› and 4 goals remain*) apply ((auto)[1]) (*discuss goal 2*) apply ((transfer)[1]) (*top goal: ‹FSM.initial P = (q1, q2) ⟹ FSM.states (FSM.canonical_separator' M P q1 q2) = Inl ` FSM.states P ∪ {Inr q1, Inr q2}› and 3 goals remain*) apply ((auto)[1]) (*discuss goal 3*) apply ((transfer)[1]) (*top goal: ‹FSM.initial P = (q1, q2) ⟹ FSM.inputs (FSM.canonical_separator' M P q1 q2) = FSM.inputs M ∪ FSM.inputs P› and 2 goals remain*) apply ((auto)[1]) (*discuss goal 4*) apply ((transfer)[1]) (*top goal: ‹FSM.initial P = (q1, q2) ⟹ FSM.outputs (FSM.canonical_separator' M P q1 q2) = FSM.outputs M ∪ FSM.outputs P› and 1 goal remains*) apply ((auto)[1]) (*discuss goal 5*) apply ((transfer)[1]) (*goal: ‹FSM.initial P = (q1, q2) ⟹ FSM.transitions (FSM.canonical_separator' M P q1 q2) = shifted_transitions (FSM.transitions P) ∪ distinguishing_transitions (λqx. case set_as_map ((λ(q, x, y, q'). ((q, x), y)) ` FSM.transitions M) qx of None ⇒ {} | Some yqs ⇒ yqs) q1 q2 (FSM.states P) (FSM.inputs P)›*) apply ((auto)[1]) (*proven 5 subgoals*) . lemma canonical_separator'_simps_without_assm : "initial (canonical_separator' M P q1 q2) = Inl (q1,q2)" "states (canonical_separator' M P q1 q2) = (if initial P = (q1,q2) then (image Inl (states P)) ∪ {Inr q1, Inr q2} else {Inl (q1,q2)})" "inputs (canonical_separator' M P q1 q2) = (if initial P = (q1,q2) then inputs M ∪ inputs P else {})" "outputs (canonical_separator' M P q1 q2) = (if initial P = (q1,q2) then outputs M ∪ outputs P else {})" "transitions (canonical_separator' M P q1 q2) = (if initial P = (q1,q2) then shifted_transitions (transitions P) ∪ distinguishing_transitions (h_out M) q1 q2 (states P) (inputs P) else {})" unfolding h_out_code (*goals: 1. ‹FSM.initial (FSM.canonical_separator' (M::('a, 'b, 'c) fsm) (P::('a × 'a, 'b, 'c) fsm) (q1::'a) (q2::'a)) = Inl (q1, q2)› 2. ‹FSM.states (FSM.canonical_separator' (M::('a, 'b, 'c) fsm) (P::('a × 'a, 'b, 'c) fsm) (q1::'a) (q2::'a)) = (if FSM.initial P = (q1, q2) then Inl ` FSM.states P ∪ {Inr q1, Inr q2} else {Inl (q1, q2)})› 3. ‹FSM.inputs (FSM.canonical_separator' (M::('a, 'b, 'c) fsm) (P::('a × 'a, 'b, 'c) fsm) (q1::'a) (q2::'a)) = (if FSM.initial P = (q1, q2) then FSM.inputs M ∪ FSM.inputs P else {})› 4. ‹FSM.outputs (FSM.canonical_separator' (M::('a, 'b, 'c) fsm) (P::('a × 'a, 'b, 'c) fsm) (q1::'a) (q2::'a)) = (if FSM.initial P = (q1, q2) then FSM.outputs M ∪ FSM.outputs P else {})› 5. ‹FSM.transitions (FSM.canonical_separator' (M::('a, 'b, 'c) fsm) (P::('a × 'a, 'b, 'c) fsm) (q1::'a) (q2::'a)) = (if FSM.initial P = (q1, q2) then shifted_transitions (FSM.transitions P) ∪ distinguishing_transitions (λqx::'a × 'b. case set_as_map ((λ(q::'a, x::'b, y::'c, q'::'a). ((q, x), y)) ` FSM.transitions M) qx of None ⇒ {} | Some (yqs::'c set) ⇒ yqs) q1 q2 (FSM.states P) (FSM.inputs P) else {})›*) (*goals: 1. ‹FSM.initial (FSM.canonical_separator' M P q1 q2) = Inl (q1, q2)› 2. ‹FSM.states (FSM.canonical_separator' M P q1 q2) = (if FSM.initial P = (q1, q2) then Inl ` FSM.states P ∪ {Inr q1, Inr q2} else {Inl (q1, q2)})› 3. ‹FSM.inputs (FSM.canonical_separator' M P q1 q2) = (if FSM.initial P = (q1, q2) then FSM.inputs M ∪ FSM.inputs P else {})› 4. ‹FSM.outputs (FSM.canonical_separator' M P q1 q2) = (if FSM.initial P = (q1, q2) then FSM.outputs M ∪ FSM.outputs P else {})› 5. ‹FSM.transitions (FSM.canonical_separator' M P q1 q2) = (if FSM.initial P = (q1, q2) then shifted_transitions (FSM.transitions P) ∪ distinguishing_transitions (λqx. case set_as_map ((λ(q, x, y, q'). ((q, x), y)) ` FSM.transitions M) qx of None ⇒ {} | Some yqs ⇒ yqs) q1 q2 (FSM.states P) (FSM.inputs P) else {})› discuss goal 1*) apply transfer (*top goal: ‹FSM.initial (FSM.canonical_separator' M P q1 q2) = Inl (q1, q2)› and 4 goals remain*) apply (simp add: Let_def (*‹Let ?s ?f ≡ ?f ?s›*)) (*discuss goal 2*) apply transfer (*top goal: ‹FSM.states (FSM.canonical_separator' M P q1 q2) = (if FSM.initial P = (q1, q2) then Inl ` FSM.states P ∪ {Inr q1, Inr q2} else {Inl (q1, q2)})› and 3 goals remain*) apply (simp add: Let_def (*‹Let ?s ?f ≡ ?f ?s›*)) (*discuss goal 3*) apply transfer (*top goal: ‹FSM.inputs (FSM.canonical_separator' M P q1 q2) = (if FSM.initial P = (q1, q2) then FSM.inputs M ∪ FSM.inputs P else {})› and 2 goals remain*) apply (simp add: Let_def (*‹Let ?s ?f ≡ ?f ?s›*)) (*discuss goal 4*) apply transfer (*top goal: ‹FSM.outputs (FSM.canonical_separator' (M::('a::type, 'b::type, 'c::type) fsm) (P::('a::type × 'a::type, 'b::type, 'c::type) fsm) (q1::'a::type) (q2::'a::type)) = (if FSM.initial P = (q1, q2) then FSM.outputs M ∪ FSM.outputs P else {})› and 1 goal remains*) apply (simp add: Let_def (*‹Let ?s ?f ≡ ?f ?s›*)) (*discuss goal 5*) apply transfer (*goal: ‹FSM.transitions (FSM.canonical_separator' M P q1 q2) = (if FSM.initial P = (q1, q2) then shifted_transitions (FSM.transitions P) ∪ distinguishing_transitions (λqx. case set_as_map ((λ(q, x, y, q'). ((q, x), y)) ` FSM.transitions M) qx of None ⇒ {} | Some yqs ⇒ yqs) q1 q2 (FSM.states P) (FSM.inputs P) else {})›*) apply (simp add: Let_def (*‹Let ?s ?f ≡ ?f ?s›*)) (*proven 5 subgoals*) . end
{ "path": "afp-2025-02-12/thys/FSM_Tests/FSM.thy", "repo": "afp-2025-02-12", "sha": "1f5167daef313fed6c49195d96db1738a47796498c0ffc5bbeab285dbf252cea" }
(* Author: Bernhard Stöckl *) theory Graph_Additions imports Complex_Main "Graph_Theory.Graph_Theory" "Shortest_Path_Tree" begin lemma two_elems_card_ge_2: "finite xs ⟹ x ∈ xs ∧ y ∈ xs ∧ x≠y ⟹ Finite_Set.card xs ≥ 2" using card_gt_0_iff (*‹(0 < card ?A) = (?A ≠ {} ∧ finite ?A)›*) mk_disjoint_insert (*‹?a ∈ ?A ⟹ ∃B. ?A = insert ?a B ∧ ?a ∉ B›*) not_less_eq_eq (*‹(¬ ?m ≤ ?n) = (Suc ?n ≤ ?m)›*) by fastforce section ‹Graph Extensions› context wf_digraph begin lemma awalk_dom_if_uneq: "⟦u≠v; awalk u p v⟧ ⟹ ∃x. x →⇘G⇙ v" using reachable_awalk[of u v] (*‹(u →⇧* v) = (∃p. awalk u p v)›*) awalk_ends[of u p v] (*‹⟦awalk u p v; awalk ?u' p ?v'⟧ ⟹ p ≠ [] ∧ u = ?u' ∧ v = ?v' ∨ p = [] ∧ u = v ∧ ?u' = ?v'›*) converse_reachable_induct (*‹⟦?u →⇧* ?v; ?v ∈ verts G ⟹ ?P ?v; ⋀x y. ⟦x → y; y →⇧* ?v; ?P y⟧ ⟹ ?P x⟧ ⟹ ?P ?u›*) by blast lemma awalk_verts_dom_if_uneq: "⟦u≠v; awalk u p v⟧ ⟹ ∃x. x →⇘G⇙ v ∧ x ∈ set (awalk_verts u p)" proof (induction p arbitrary: u) (*goals: 1. ‹⋀u. ⟦u ≠ v; awalk u [] v⟧ ⟹ ∃x. x → v ∧ x ∈ set (awalk_verts u [])› 2. ‹⋀a p u. ⟦⋀u. ⟦u ≠ v; awalk u p v⟧ ⟹ ∃x. x → v ∧ x ∈ set (awalk_verts u p); u ≠ v; awalk u (a # p) v⟧ ⟹ ∃x. x → v ∧ x ∈ set (awalk_verts u (a # p))›*) case Nil (*‹(u::'a) ≠ (v::'a)› ‹awalk u [] v›*) then show "?case" (*goal: ‹∃x. x → v ∧ x ∈ set (awalk_verts u [])›*) using awalk_def (*‹awalk ?u ?p ?v ≡ ?u ∈ verts G ∧ set ?p ⊆ arcs G ∧ cas ?u ?p ?v›*) by simp next (*goal: ‹⋀(a::'b) (p::'b list) u::'a. ⟦⋀u::'a. ⟦u ≠ (v::'a); awalk u p v⟧ ⟹ ∃x::'a. x → v ∧ x ∈ set (awalk_verts u p); u ≠ v; awalk u (a # p) v⟧ ⟹ ∃x::'a. x → v ∧ x ∈ set (awalk_verts u (a # p))›*) case (Cons p ps) (*‹⟦?u2 ≠ v; awalk ?u2 ps v⟧ ⟹ ∃x. x → v ∧ x ∈ set (awalk_verts ?u2 ps)› ‹u ≠ v› ‹awalk (u::'a) ((p::'b) # (ps::'b list)) (v::'a)›*) then show "?case" (*goal: ‹∃x::'a. x → (v::'a) ∧ x ∈ set (awalk_verts (u::'a) ((p::'b) # (ps::'b list)))›*) using awalk_Cons_iff[of u p ps v] (*‹awalk (u::'a::type) ((p::'b::type) # (ps::'b::type list)) (v::'a::type) = (p ∈ arcs G ∧ u = tail G p ∧ awalk (head G p) ps v)›*) awalk_verts.simps(2)[of u p ps] (*‹awalk_verts u (p # ps) = tail G p # awalk_verts (head G p) ps›*) awalk_verts_non_Nil (*‹awalk_verts ?u ?p ≠ []›*) by (metis in_arcs_imp_in_arcs_ends (*‹?e ∈ arcs G ⟹ tail G ?e → head G ?e›*) list.sel( (*‹hd (?x21.0 # ?x22.0) = ?x21.0›*) 1) list.set_intros( (*‹?y ∈ set ?x22.0 ⟹ ?y ∈ set (?x21.0 # ?x22.0)›*) 2) list.set_sel( (*‹?a ≠ [] ⟹ hd ?a ∈ set ?a›*) 1)) qed lemma awalk_verts_append_distinct: "⟦∃v. awalk r (p1@p2) v; distinct (awalk_verts r (p1@p2))⟧ ⟹ distinct (awalk_verts r p1)" using awalk_verts_append (*‹awalk ?u (?p @ ?q) ?v ⟹ awalk_verts ?u (?p @ ?q) = awalk_verts ?u ?p @ tl (awalk_verts (awlast ?u ?p) ?q)›*) by auto lemma not_distinct_if_head_eq_tail: assumes "tail G p = u" and "head G e = u" and "awalk r (ps@[p]@e#p2) v" shows "¬(distinct (awalk_verts r (ps@[p]@e#p2)))" using assms (*‹tail G p = u› ‹head G e = u› ‹awalk (r::'a) ((ps::'b list) @ [p::'b] @ (e::'b) # (p2::'b list)) (v::'a)›*) proof (induction ps arbitrary: r) (*goals: 1. ‹⋀r. ⟦tail G p = u; head G e = u; awalk r ([] @ [p] @ e # p2) v⟧ ⟹ ¬ distinct (awalk_verts r ([] @ [p] @ e # p2))› 2. ‹⋀a ps r. ⟦⋀r. ⟦tail G p = u; head G e = u; awalk r (ps @ [p] @ e # p2) v⟧ ⟹ ¬ distinct (awalk_verts r (ps @ [p] @ e # p2)); tail G p = u; head G e = u; awalk r ((a # ps) @ [p] @ e # p2) v⟧ ⟹ ¬ distinct (awalk_verts r ((a # ps) @ [p] @ e # p2))›*) case Nil (*‹tail G p = u› ‹head G e = u› ‹awalk r ([] @ [p] @ e # p2) v›*) then have "u ∈ set (awalk_verts (head G p) (e#p2))" by (metis append.left_neutral (*‹[] @ (?a::?'a list) = ?a›*) append_Cons (*‹((?x::?'a) # (?xs::?'a list)) @ (?ys::?'a list) = ?x # ?xs @ ?ys›*) awalk_Cons_iff (*‹awalk (?u::'a) ((?e::'b) # (?es::'b list)) (?w::'a) = (?e ∈ arcs G ∧ ?u = tail G ?e ∧ awalk (head G ?e) ?es ?w)›*) awalk_verts_arc2 (*‹⟦awalk (?u::'a) (?p::'b list) (?v::'a); (?e::'b) ∈ set ?p⟧ ⟹ head G ?e ∈ set (awalk_verts ?u ?p)›*) list.set_intros( (*‹(?x21.0::?'a) ∈ set (?x21.0 # (?x22.0::?'a list))›*) 1)) then show "?case" (*goal: ‹¬ distinct (awalk_verts r ([] @ [p] @ e # p2))›*) by (simp add: Nil( (*‹tail G p = u›*) 1)) next (*goal: ‹⋀(a::'b) (ps::'b list) r::'a. ⟦⋀r::'a. ⟦tail G (p::'b) = (u::'a); head G (e::'b) = u; awalk r (ps @ [p] @ e # (p2::'b list)) (v::'a)⟧ ⟹ ¬ distinct (awalk_verts r (ps @ [p] @ e # p2)); tail G p = u; head G e = u; awalk r ((a # ps) @ [p] @ e # p2) v⟧ ⟹ ¬ distinct (awalk_verts r ((a # ps) @ [p] @ e # p2))›*) case (Cons p ps) (*‹⟦tail G (p::'b) = (u::'a); head G (e::'b) = u; awalk (?r2::'a) ((ps::'b list) @ [p] @ e # (p2::'b list)) (v::'a)⟧ ⟹ ¬ distinct (awalk_verts ?r2 (ps @ [p] @ e # p2))› ‹tail G p = u› ‹head G e = u› ‹awalk (r::'a) (((p::'b) # (ps::'b list)) @ [p::'b] @ (e::'b) # (p2::'b list)) (v::'a)›*) then show "?case" (*goal: ‹¬ distinct (awalk_verts r ((p # ps) @ [p] @ e # p2))›*) using awalk_Cons_iff (*‹awalk (?u::'a::type) ((?e::'b::type) # (?es::'b::type list)) (?w::'a::type) = (?e ∈ arcs G ∧ ?u = tail G ?e ∧ awalk (head G ?e) ?es ?w)›*) by auto qed lemma awalk_verts_subset_if_p_sub: "⟦awalk u p1 v; awalk u p2 v; set p1 ⊆ set p2⟧ ⟹ set (awalk_verts u p1) ⊆ set (awalk_verts u p2)" using awalk_verts_conv (*‹awalk_verts ?u ?p = (if ?p = [] then [?u] else map (tail G) ?p @ [head G (last ?p)])›*) by fastforce lemma awalk_to_apath_verts_subset: "awalk u p v ⟹ set (awalk_verts u (awalk_to_apath p)) ⊆ set (awalk_verts u p)" using awalk_verts_subset_if_p_sub (*‹⟦awalk (?u::'a::type) (?p1.0::'b::type list) (?v::'a::type); awalk ?u (?p2.0::'b::type list) ?v; set ?p1.0 ⊆ set ?p2.0⟧ ⟹ set (awalk_verts ?u ?p1.0) ⊆ set (awalk_verts ?u ?p2.0)›*) awalk_to_apath_subset (*‹awalk (?u::'a) (?p::'b list) (?v::'a) ⟹ set (awalk_to_apath ?p) ⊆ set ?p›*) apath_awalk_to_apath (*‹awalk ?u ?p ?v ⟹ apath ?u (awalk_to_apath ?p) ?v›*) awalkI_apath (*‹apath ?u ?p ?v ⟹ awalk ?u ?p ?v›*) by blast lemma unique_apath_verts_in_awalk: "⟦x ∈ set (awalk_verts u p1); apath u p1 v; awalk u p2 v; ∃!p. apath u p v⟧ ⟹ x ∈ set (awalk_verts u p2)" using apath_awalk_to_apath (*‹awalk ?u ?p ?v ⟹ apath ?u (awalk_to_apath ?p) ?v›*) awalk_to_apath_verts_subset (*‹awalk ?u ?p ?v ⟹ set (awalk_verts ?u (awalk_to_apath ?p)) ⊆ set (awalk_verts ?u ?p)›*) by blast lemma unique_apath_verts_sub_awalk: "⟦apath u p v; awalk u q v; ∃!p. apath u p v⟧ ⟹ set (awalk_verts u p) ⊆ set (awalk_verts u q)" using unique_apath_verts_in_awalk (*‹⟦?x ∈ set (awalk_verts ?u ?p1.0); apath ?u ?p1.0 ?v; awalk ?u ?p2.0 ?v; ∃!p. apath ?u p ?v⟧ ⟹ ?x ∈ set (awalk_verts ?u ?p2.0)›*) by blast lemma awalk_verts_append3: "⟦awalk u (p@e#q) r; awalk v q r⟧ ⟹ awalk_verts u (p@e#q) = awalk_verts u p @ awalk_verts v q" using awalk_verts_conv (*‹awalk_verts ?u ?p = (if ?p = [] then [?u] else map (tail G) ?p @ [head G (last ?p)])›*) by fastforce lemma verts_reachable_connected: "verts G ≠ {} ⟹ (∀x∈verts G. ∀y∈verts G. x →⇧* y) ⟹ connected G" by (simp add: connected_def (*‹Digraph_Component.connected ?G ≡ strongly_connected (with_proj (mk_symmetric ?G))›*) strongly_connected_def (*‹strongly_connected ?G ≡ verts ?G ≠ {} ∧ (∀u∈verts ?G. ∀v∈verts ?G. u →⇧*⇘?G⇙ v)›*) reachable_mk_symmetricI (*‹?u →⇧* ?v ⟹ ?u →⇧*⇘with_proj (mk_symmetric G)⇙ ?v›*)) lemma out_degree_0_no_arcs: assumes "out_degree G v = 0" and "finite (arcs G)" shows "∀y. (v,y) ∉ arcs_ends G" proof (rule ccontr (*‹(¬ (?P::bool) ⟹ False) ⟹ ?P›*)) (*goal: ‹¬ (∀y. (v, y) ∉ arcs_ends G) ⟹ False›*) assume "¬(∀y. (v,y) ∉ arcs_ends G)" (*‹¬ (∀y::'a. (v::'a, y) ∉ arcs_ends G)›*) then obtain y where y_def: "(v,y) ∈ arcs_ends G" (*goal: ‹(⋀y. v → y ⟹ thesis) ⟹ thesis›*) by blast then obtain a where a_def: "a ∈ arcs G ∧ tail G a = v ∧ head G a = y" (*goal: ‹(⋀a::'b. a ∈ arcs G ∧ tail G a = (v::'a) ∧ head G a = (y::'a) ⟹ thesis::bool) ⟹ thesis›*) by auto then have "a ∈ {e ∈ arcs G. tail G e = v}" by simp then have "Finite_Set.card {e ∈ arcs G. tail G e = v} > 0" using assms(2) (*‹finite (arcs G)›*) card_gt_0_iff (*‹(0 < card ?A) = (?A ≠ {} ∧ finite ?A)›*) by force then show False using assms(1) (*‹out_degree G v = 0›*) by (metis less_nat_zero_code (*‹(?n < 0) = False›*) out_arcs_def (*‹out_arcs ?G ?v ≡ {e ∈ arcs ?G. tail ?G e = ?v}›*) out_degree_def (*‹out_degree ?G ?v ≡ card (out_arcs ?G ?v)›*)) qed lemma out_degree_0_only_self: "finite (arcs G) ⟹ out_degree G v = 0 ⟹ v →⇧* x ⟹ x = v" using converse_reachable_cases (*‹⟦?u →⇧* ?v; ⟦?u = ?v; ?u ∈ verts G⟧ ⟹ ?thesis; ⋀w. ⟦?u → w; w →⇧* ?v⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*) out_degree_0_no_arcs (*‹⟦out_degree G ?v = 0; finite (arcs G)⟧ ⟹ ∀y. (?v, y) ∉ arcs_ends G›*) by force lemma not_elem_no_out_arcs: "v ∉ verts G ⟹ out_arcs G v = {}" by auto lemma not_elem_no_in_arcs: "v ∉ verts G ⟹ in_arcs G v = {}" by auto lemma not_elem_out_0: "v ∉ verts G ⟹ out_degree G v = 0" unfolding out_degree_def (*goal: ‹v ∉ verts G ⟹ card (out_arcs G v) = 0›*) using not_elem_no_out_arcs (*‹(?v::'a) ∉ verts G ⟹ out_arcs G ?v = {}›*) by simp lemma not_elem_in_0: "v ∉ verts G ⟹ in_degree G v = 0" unfolding in_degree_def (*goal: ‹v ∉ verts G ⟹ card (in_arcs G v) = 0›*) using not_elem_no_in_arcs (*‹?v ∉ verts G ⟹ in_arcs G ?v = {}›*) by simp lemma new_vert_only_no_arcs: assumes "G = ⦇verts = V ∪ {v}, arcs = A, tail = t, head = h⦈" and "G' = ⦇verts = V, arcs = A, tail = t, head = h⦈" and "wf_digraph G'" and "v ∉ V" and "finite (arcs G)" shows "∀u. (v,u) ∉ arcs_ends G" proof (-) (*goal: ‹∀u. (v, u) ∉ arcs_ends G›*) have "out_degree G' v = 0" using assms(2-4) (*‹G' = ⦇verts = V, arcs = A, tail = t, head = h⦈› ‹wf_digraph G'› ‹v ∉ V›*) wf_digraph.not_elem_out_0 (*‹⟦wf_digraph ?G; ?v ∉ verts ?G⟧ ⟹ out_degree ?G ?v = 0›*) by fastforce then have "out_degree G v = 0" unfolding out_degree_def out_arcs_def (*goal: ‹card {e ∈ arcs G. tail G e = v} = 0›*) using assms(1,2) (*‹G = ⦇verts = V ∪ {v}, arcs = A, tail = t, head = h⦈› ‹G' = ⦇verts = V, arcs = A, tail = t, head = h⦈›*) by simp then show "?thesis" (*goal: ‹∀u. (v, u) ∉ arcs_ends G›*) using assms(5) (*‹finite (arcs G)›*) out_degree_0_no_arcs (*‹⟦out_degree G ?v = 0; finite (arcs G)⟧ ⟹ ∀y. (?v, y) ∉ arcs_ends G›*) by blast qed lemma new_leaf_out_sets_eq: assumes "G = ⦇verts = V ∪ {v}, arcs = A ∪ {a}, tail = t(a := u), head = h(a := v)⦈" and "G' = ⦇verts = V, arcs = A, tail = t, head = h⦈" and "u ∈ V" and "v ∉ V" and "a ∉ A" shows "{e ∈ arcs G. tail G e = v} = {e ∈ arcs G'. tail G' e = v}" using assms (*‹G = ⦇verts = V ∪ {v}, arcs = A ∪ {a}, tail = t(a := u), head = h(a := v)⦈› ‹G' = ⦇verts = V, arcs = A, tail = t, head = h⦈› ‹u ∈ V› ‹(v::'a) ∉ (V::'a set)› ‹a ∉ A›*) by auto lemma new_leaf_out_0: assumes "G = ⦇verts = V ∪ {v}, arcs = A ∪ {a}, tail = t(a := u), head = h(a := v)⦈" and "G' = ⦇verts = V, arcs = A, tail = t, head = h⦈" and "wf_digraph G'" and "u ∈ V" and "v ∉ V" and "a ∉ A" shows "out_degree G v = 0" proof (-) (*goal: ‹out_degree G v = 0›*) have "tail G a = u" using assms(1) (*‹G = ⦇verts = V ∪ {v}, arcs = A ∪ {a}, tail = t(a := u), head = h(a := v)⦈›*) by simp then have 0: "{e ∈ arcs G. tail G e = v} = {e ∈ arcs G'. tail G' e = v}" using new_leaf_out_sets_eq (*‹⟦G = ⦇verts = ?V ∪ {?v}, arcs = ?A ∪ {?a}, tail = ?t(?a := ?u), head = ?h(?a := ?v)⦈; ?G' = ⦇verts = ?V, arcs = ?A, tail = ?t, head = ?h⦈; ?u ∈ ?V; ?v ∉ ?V; ?a ∉ ?A⟧ ⟹ {e ∈ arcs G. tail G e = ?v} = {e ∈ arcs ?G'. tail ?G' e = ?v}›*) assms(1,2,4-6) (*‹G = ⦇verts = V ∪ {v}, arcs = A ∪ {a}, tail = t(a := u), head = h(a := v)⦈› ‹G' = ⦇verts = V, arcs = A, tail = t, head = h⦈› ‹u ∈ V› ‹(v::'a::type) ∉ (V::'a::type set)› ‹a ∉ A›*) by blast have "out_degree G' v = 0" using assms(2,3,5) (*‹G' = ⦇verts = V, arcs = A, tail = t, head = h⦈› ‹wf_digraph (G'::('a, 'b) pre_digraph)› ‹v ∉ V›*) wf_digraph.not_elem_out_0 (*‹⟦wf_digraph ?G; ?v ∉ verts ?G⟧ ⟹ out_degree ?G ?v = 0›*) by fastforce then show "?thesis" (*goal: ‹out_degree G v = 0›*) unfolding out_degree_def out_arcs_def (*goal: ‹card {e ∈ arcs G. tail G e = v} = 0›*) using "0" (*‹{e ∈ arcs G. tail G e = v} = {e ∈ arcs G'. tail G' e = v}›*) by simp qed lemma new_leaf_no_arcs: assumes "G = ⦇verts = V ∪ {v}, arcs = A ∪ {a}, tail = t(a := u), head = h(a := v)⦈" and "G' = ⦇verts = V, arcs = A, tail = t, head = h⦈" and "wf_digraph G'" and "u ∈ V" and "v ∉ V" and "a ∉ A" and "finite (arcs G)" shows "∀u. (v,u) ∉ arcs_ends G" using new_leaf_out_0 (*‹⟦G = ⦇verts = ?V ∪ {?v}, arcs = ?A ∪ {?a}, tail = ?t(?a := ?u), head = ?h(?a := ?v)⦈; ?G' = ⦇verts = ?V, arcs = ?A, tail = ?t, head = ?h⦈; wf_digraph ?G'; ?u ∈ ?V; ?v ∉ ?V; ?a ∉ ?A⟧ ⟹ out_degree G ?v = 0›*) assms (*‹G = ⦇verts = V ∪ {v}, arcs = A ∪ {a}, tail = t(a := u), head = h(a := v)⦈› ‹G' = ⦇verts = V, arcs = A, tail = t, head = h⦈› ‹wf_digraph (G'::('a, 'b) pre_digraph)› ‹u ∈ V› ‹v ∉ V› ‹a ∉ A› ‹finite (arcs G)›*) out_degree_0_no_arcs (*‹⟦out_degree G ?v = 0; finite (arcs G)⟧ ⟹ ∀y. (?v, y) ∉ arcs_ends G›*) by presburger lemma tail_and_head_eq_impl_cas: assumes "cas x p y" and "∀x ∈ set p. tail G x = tail G' x" and "∀x ∈ set p. head G x = head G' x" shows "pre_digraph.cas G' x p y" using assms (*‹cas x p y› ‹∀x::'b∈set (p::'b list). tail G x = tail (G'::('a, 'b) pre_digraph) x› ‹∀x∈set p. head G x = head G' x›*) proof (induction p arbitrary: x y) (*goals: 1. ‹⋀x y. ⟦cas x [] y; ∀x∈set []. tail G x = tail G' x; ∀x∈set []. head G x = head G' x⟧ ⟹ pre_digraph.cas G' x [] y› 2. ‹⋀a p x y. ⟦⋀x y. ⟦cas x p y; ∀x∈set p. tail G x = tail G' x; ∀x∈set p. head G x = head G' x⟧ ⟹ pre_digraph.cas G' x p y; cas x (a # p) y; ∀x∈set (a # p). tail G x = tail G' x; ∀x∈set (a # p). head G x = head G' x⟧ ⟹ pre_digraph.cas G' x (a # p) y›*) case Nil (*‹cas x [] y› ‹∀x∈set []. tail G x = tail G' x› ‹∀x∈set []. head G x = head G' x›*) show "?case" (*goal: ‹pre_digraph.cas G' x [] y›*) using pre_digraph.cas.simps(1) (*‹pre_digraph.cas ?G ?u [] ?v = (?u = ?v)›*) Nil(1) (*‹cas x [] y›*) by fastforce next (*goal: ‹⋀a p x y. ⟦⋀x y. ⟦cas x p y; ∀x∈set p. tail G x = tail G' x; ∀x∈set p. head G x = head G' x⟧ ⟹ pre_digraph.cas G' x p y; cas x (a # p) y; ∀x∈set (a # p). tail G x = tail G' x; ∀x∈set (a # p). head G x = head G' x⟧ ⟹ pre_digraph.cas G' x (a # p) y›*) case (Cons p ps) (*‹⟦cas (?x2::'a) (ps::'b list) (?y2::'a); ∀x::'b∈set ps. tail G x = tail (G'::('a, 'b) pre_digraph) x; ∀x::'b∈set ps. head G x = head G' x⟧ ⟹ pre_digraph.cas G' ?x2 ps ?y2› ‹cas x (p # ps) y› ‹∀x::'b::type∈set ((p::'b::type) # (ps::'b::type list)). tail G x = tail (G'::('a, 'b) pre_digraph) x› ‹∀x∈set (p # ps). head G x = head G' x›*) have 0: "tail G' p = x" using Cons.prems(1,2) (*‹cas (x::'a::type) ((p::'b::type) # (ps::'b::type list)) (y::'a::type)› ‹∀x∈set (p # ps). tail G x = tail G' x›*) by simp have "cas (head G p) ps y" using Cons.prems(1) (*‹cas x (p # ps) y›*) by simp then have "pre_digraph.cas G' (head G' p) ps y" using Cons.IH (*‹⟦cas ?x2 ps ?y2; ∀x∈set ps. tail G x = tail G' x; ∀x∈set ps. head G x = head G' x⟧ ⟹ pre_digraph.cas G' ?x2 ps ?y2›*) Cons.prems(2,3) (*‹∀x∈set (p # ps). tail G x = tail G' x› ‹∀x∈set (p # ps). head G x = head G' x›*) by simp then show "?case" (*goal: ‹pre_digraph.cas G' x (p # ps) y›*) using "0" (*‹tail G' p = x›*) by (simp add: pre_digraph.cas.simps( (*‹pre_digraph.cas ?G ?u (?e # ?es) ?v = (tail ?G ?e = ?u ∧ pre_digraph.cas ?G (head ?G ?e) ?es ?v)›*) 2)) qed lemma new_leaf_same_reachables_orig: assumes "x →⇧*⇘G⇙ y" and "G = ⦇verts = V ∪ {v}, arcs = A ∪ {a}, tail = t(a := u), head = h(a := v)⦈" and "G' = ⦇verts = V, arcs = A, tail = t, head = h⦈" and "wf_digraph G'" and "x ∈ V" and "u ∈ V" and "v ∉ V" and "y ≠ v" and "a ∉ A" and "finite (arcs G)" shows "x →⇧*⇘G'⇙ y" proof (-) (*goal: ‹(x::'a::type) →⇧*⇘G'::('a, 'b) pre_digraph⇙ (y::'a::type)›*) obtain p where p_def: "awalk x p y" (*goal: ‹(⋀p. awalk x p y ⟹ thesis) ⟹ thesis›*) using reachable_awalk (*‹(?u →⇧* ?v) = (∃p. awalk ?u p ?v)›*) assms(1) (*‹(x::'a::type) →⇧* (y::'a::type)›*) by auto then have 0: "set p ⊆ arcs G" by blast have v_0: "out_degree G v = 0" using new_leaf_out_0 (*‹⟦G = ⦇verts = ?V ∪ {?v}, arcs = ?A ∪ {?a}, tail = ?t(?a := ?u), head = ?h(?a := ?v)⦈; ?G' = ⦇verts = ?V, arcs = ?A, tail = ?t, head = ?h⦈; wf_digraph ?G'; ?u ∈ ?V; ?v ∉ ?V; ?a ∉ ?A⟧ ⟹ out_degree G ?v = 0›*) assms (*‹x →⇧* y› ‹G = ⦇verts = V ∪ {v}, arcs = A ∪ {a}, tail = t(a := u), head = h(a := v)⦈› ‹G' = ⦇verts = V, arcs = A, tail = t, head = h⦈› ‹wf_digraph G'› ‹x ∈ V› ‹u ∈ V› ‹v ∉ V› ‹y ≠ v› ‹a ∉ A› ‹finite (arcs G)›*) by presburger have a_notin_p: "a ∉ set p" proof (standard) (*goal: ‹a ∈ set p ⟹ False›*) assume asm: "a ∈ set p" (*‹(a::'b) ∈ set (p::'b list)›*) have "head G a = v" using assms(2) (*‹G = ⦇verts = V ∪ {v}, arcs = A ∪ {a}, tail = t(a := u), head = h(a := v)⦈›*) by simp then have "∃p' p''. p'@p''=p ∧ awalk x p' v" using asm (*‹(a::'b) ∈ set (p::'b list)›*) awalk_decomp (*‹⟦awalk ?u ?p ?v; ?w ∈ set (awalk_verts ?u ?p)⟧ ⟹ ∃q r. ?p = q @ r ∧ awalk ?u q ?w ∧ awalk ?w r ?v›*) awalk_verts_arc2 (*‹⟦awalk (?u::'a) (?p::'b list) (?v::'a); (?e::'b) ∈ set ?p⟧ ⟹ head G ?e ∈ set (awalk_verts ?u ?p)›*) p_def (*‹awalk x p y›*) by metis then obtain p' and p'' where p'_def: "p'@p''=p ∧ awalk x p' v" (*goal: ‹(⋀p' p''. p' @ p'' = p ∧ awalk x p' v ⟹ thesis) ⟹ thesis›*) by blast then have "awalk v p'' y" using p_def (*‹awalk x p y›*) by auto then have "v →⇧* y" using reachable_awalk (*‹(?u →⇧* ?v) = (∃p. awalk ?u p ?v)›*) by auto then have "v = y" using out_degree_0_only_self (*‹⟦finite (arcs G); out_degree G ?v = 0; ?v →⇧* ?x⟧ ⟹ ?x = ?v›*) assms(10) (*‹finite (arcs G)›*) v_0 (*‹out_degree G (v::'a::type) = (0::nat)›*) by blast then show False using assms(8) (*‹y ≠ v›*) by simp qed then have 1: "set p ⊆ arcs G'" using assms(2,3) (*‹G = ⦇verts = V ∪ {v}, arcs = A ∪ {a}, tail = t(a := u), head = h(a := v)⦈› ‹G' = ⦇verts = V, arcs = A, tail = t, head = h⦈›*) "0" (*‹set (p::'b list) ⊆ arcs G›*) by auto have "∀x ∈ set p. tail G x = tail G' x" using assms(2,3) (*‹G = ⦇verts = V ∪ {v}, arcs = A ∪ {a}, tail = t(a := u), head = h(a := v)⦈› ‹G' = ⦇verts = V, arcs = A, tail = t, head = h⦈›*) a_notin_p (*‹a ∉ set p›*) by simp moreover have "∀x ∈ set p. head G x = head G' x" using assms(2,3) (*‹G = ⦇verts = V ∪ {v}, arcs = A ∪ {a}, tail = t(a := u), head = h(a := v)⦈› ‹G' = ⦇verts = V, arcs = A, tail = t, head = h⦈›*) a_notin_p (*‹a ∉ set p›*) by simp ultimately have "pre_digraph.cas G' x p y" using tail_and_head_eq_impl_cas (*‹⟦cas (?x::'a::type) (?p::'b::type list) (?y::'a::type); ∀x::'b::type∈set ?p. tail G x = tail (?G'::('a, 'b) pre_digraph) x; ∀x::'b::type∈set ?p. head G x = head ?G' x⟧ ⟹ pre_digraph.cas ?G' ?x ?p ?y›*) p_def (*‹awalk (x::'a) (p::'b list) (y::'a)›*) by blast then have "pre_digraph.awalk G' x p y" unfolding pre_digraph.awalk_def (*goal: ‹x ∈ verts G' ∧ set p ⊆ arcs G' ∧ pre_digraph.cas G' x p y›*) using assms(3,5) (*‹G' = ⦇verts = V, arcs = A, tail = t, head = h⦈› ‹(x::'a) ∈ (V::'a set)›*) "1" (*‹set p ⊆ arcs G'›*) by simp then show "?thesis" (*goal: ‹(x::'a) →⇧*⇘G'::('a, 'b) pre_digraph⇙ (y::'a)›*) using assms(4) (*‹wf_digraph G'›*) wf_digraph.reachable_awalkI (*‹⟦wf_digraph ?G; pre_digraph.awalk ?G ?u ?p ?v⟧ ⟹ ?u →⇧*⇘?G⇙ ?v›*) by fast qed lemma new_leaf_same_reachables_new: assumes "x →⇧*⇘G'⇙ y" and "G = ⦇verts = V ∪ {v}, arcs = A ∪ {a}, tail = t(a := u), head = h(a := v)⦈" and "G' = ⦇verts = V, arcs = A, tail = t, head = h⦈" and "wf_digraph G'" and "x ∈ V" and "u ∈ V" and "v ∉ V" and "y ≠ v" and "a ∉ A" shows "x →⇧*⇘G⇙ y" proof (-) (*goal: ‹x →⇧* y›*) obtain p where p_def: "pre_digraph.awalk G' x p y" (*goal: ‹(⋀p. pre_digraph.awalk G' x p y ⟹ thesis) ⟹ thesis›*) using wf_digraph.reachable_awalk (*‹wf_digraph ?G ⟹ (?u →⇧*⇘?G⇙ ?v) = (∃p. pre_digraph.awalk ?G ?u p ?v)›*) assms(1,4) (*‹x →⇧*⇘G'⇙ y› ‹wf_digraph G'›*) by fast then have 0: "set p ⊆ arcs G'" by (meson 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 a_notin_p: "a ∉ set p" using assms(3,9) (*‹G' = ⦇verts = V, arcs = A, tail = t, head = h⦈› ‹a ∉ A›*) by auto have 1: "set p ⊆ arcs G" using assms(2,3) (*‹G = ⦇verts = (V::'a set) ∪ {v::'a}, arcs = (A::'b set) ∪ {a::'b}, tail = (t::'b ⇒ 'a)(a := u::'a), head = (h::'b ⇒ 'a)(a := v)⦈› ‹(G'::('a, 'b) pre_digraph) = ⦇verts = V::'a set, arcs = A::'b set, tail = t::'b ⇒ 'a, head = h::'b ⇒ 'a⦈›*) "0" (*‹set (p::'b list) ⊆ arcs (G'::('a, 'b) pre_digraph)›*) by auto have "∀x ∈ set p. tail G x = tail G' x" using assms(2,3) (*‹G = ⦇verts = V ∪ {v}, arcs = A ∪ {a}, tail = t(a := u), head = h(a := v)⦈› ‹G' = ⦇verts = V, arcs = A, tail = t, head = h⦈›*) a_notin_p (*‹a ∉ set p›*) by simp moreover have "∀x ∈ set p. head G x = head G' x" using assms(2,3) (*‹G = ⦇verts = V ∪ {v}, arcs = A ∪ {a}, tail = t(a := u), head = h(a := v)⦈› ‹G' = ⦇verts = V, arcs = A, tail = t, head = h⦈›*) a_notin_p (*‹a ∉ set p›*) by simp moreover have "pre_digraph.cas G' x p y" using p_def (*‹pre_digraph.awalk G' x p y›*) 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›*) by fast ultimately have "cas x p y" using assms(4) (*‹wf_digraph G'›*) wf_digraph.tail_and_head_eq_impl_cas (*‹⟦wf_digraph ?G; pre_digraph.cas ?G ?x ?p ?y; ∀x∈set ?p. tail ?G x = tail ?G' x; ∀x∈set ?p. head ?G x = head ?G' x⟧ ⟹ pre_digraph.cas ?G' ?x ?p ?y›*) by fastforce then have "awalk x p y" unfolding awalk_def (*goal: ‹(x::'a) ∈ verts G ∧ set (p::'b list) ⊆ arcs G ∧ cas x p (y::'a)›*) using assms(2,5) (*‹G = ⦇verts = (V::'a set) ∪ {v::'a}, arcs = (A::'b set) ∪ {a::'b}, tail = (t::'b ⇒ 'a)(a := u::'a), head = (h::'b ⇒ 'a)(a := v)⦈› ‹(x::'a) ∈ (V::'a set)›*) "1" (*‹set p ⊆ arcs G›*) by simp then show "?thesis" (*goal: ‹x →⇧* y›*) using reachable_awalkI (*‹awalk ?u ?p ?v ⟹ ?u →⇧* ?v›*) by simp qed lemma new_leaf_reach_impl_parent: assumes "y →⇧* v" and "G = ⦇verts = V ∪ {v}, arcs = A ∪ {a}, tail = t(a := u), head = h(a := v)⦈" and "G' = ⦇verts = V, arcs = A, tail = t, head = h⦈" and "wf_digraph G'" and "y ∈ V" and "v ∉ V" shows "y →⇧* u" proof (-) (*goal: ‹y →⇧* u›*) have "∀a ∈ A. h a ≠ v" using assms(3,4,6) (*‹G' = ⦇verts = V, arcs = A, tail = t, head = h⦈› ‹wf_digraph G'› ‹v ∉ V›*) wf_digraph.head_in_verts (*‹⟦wf_digraph ?G; ?e ∈ arcs ?G⟧ ⟹ head ?G ?e ∈ verts ?G›*) by (metis pre_digraph.select_convs( (*‹verts ⦇verts = ?verts, arcs = ?arcs, tail = ?tail, head = ?head, … = ?more⦈ = ?verts› ‹arcs ⦇verts = ?verts, arcs = ?arcs, tail = ?tail, head = ?head, … = ?more⦈ = ?arcs› ‹head ⦇verts = ?verts, arcs = ?arcs, tail = ?tail, head = ?head, … = ?more⦈ = ?head›*) 1,2,4)) then have 0: "∀x. (x,v) ∈ arcs_ends G ⟶ x = u" using assms(2) (*‹G = ⦇verts = V ∪ {v}, arcs = A ∪ {a}, tail = t(a := u), head = h(a := v)⦈›*) by fastforce have "v ≠ y" using assms(5,6) (*‹y ∈ V› ‹v ∉ V›*) by blast then have "y →⁺ v" using assms(1) (*‹y →⇧* v›*) by blast then have "∃x. y →⇧*x ∧ x →⇘G⇙ v" by (meson reachable1_in_verts( (*‹?u →⁺ ?v ⟹ ?u ∈ verts G›*) 1) reachable_conv' (*‹?u ∈ verts G ⟹ (?u →⇧* ?v) = ((?u, ?v) ∈ (arcs_ends G)⇧*) › * ) tranclD2 (*‹(?x, ?y) ∈ ?R⁺ ⟹ ∃z. (?x, z) ∈ ?R⇧* ∧ (z, ?y) ∈ ?R›*)) then obtain x where "y →⇧* x ∧ x →⇘G⇙ v" (*goal: ‹(⋀x. y →⇧* x ∧ x → v ⟹ thesis) ⟹ thesis›*) by blast then show "?thesis" (*goal: ‹y →⇧* u›*) using "0" (*‹∀x. x → v ⟶ x = u›*) by blast qed end context graph begin abbreviation min_degree :: "'a set ⇒ 'a ⇒ bool" where "min_degree xs x ≡ x∈xs ∧ (∀y∈xs. out_degree G x ≤ out_degree G y)" lemma graph_del_vert_sym: "sym (arcs_ends (del_vert x))" by (smt (z3) wf_digraph_del_vert (*‹wf_digraph (del_vert ?u)›*) mem_Collect_eq (*‹(?a ∈ Collect ?P) = ?P ?a›*) reachableE (*‹⟦?u →⇘?G⇙ ?v; ⋀e. ⟦e ∈ arcs ?G; tail ?G e = ?u; head ?G e = ?v⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*) sym_digraph_axioms_def (*‹sym_digraph_axioms ?G ≡ symmetric ?G›*) arcs_del_vert (*‹arcs (del_vert ?u) = {a ∈ arcs G. tail G a ≠ ?u ∧ head G a ≠ ?u}›*) symmetric_conv (*‹symmetric ?G = (∀e1∈arcs ?G. ∃e2∈arcs ?G. tail ?G e1 = head ?G e2 ∧ head ?G e1 = tail ?G e2)›*) symI (*‹(⋀x y. (x, y) ∈ ?r ⟹ (y, x) ∈ ?r) ⟹ sym ?r›*) wf_digraph.in_arcs_imp_in_arcs_ends (*‹⟦wf_digraph ?G; ?e ∈ arcs ?G⟧ ⟹ tail ?G ?e →⇘?G⇙ head ?G ?e›*) head_del_vert (*‹head (del_vert ?u) = head G›*) sym_arcs (*‹symmetric G›*) tail_del_vert (*‹tail (del_vert ?u) = tail G›*)) lemma graph_del_vert: "graph (del_vert x)" apply standard (*goals: 1. ‹⋀e. e ∈ arcs (del_vert x) ⟹ tail (del_vert x) e ∈ verts (del_vert x)› 2. ‹⋀e. e ∈ arcs (del_vert x) ⟹ head (del_vert x) e ∈ verts (del_vert x)› 3. ‹finite (verts (del_vert x))› 4. ‹finite (arcs (del_vert x))› 5. ‹⋀e. e ∈ arcs (del_vert x) ⟹ tail (del_vert x) e ≠ head (del_vert x) e› 6. ‹⋀e1 e2. ⟦e1 ∈ arcs (del_vert x); e2 ∈ arcs (del_vert x); arc_to_ends (del_vert x) e1 = arc_to_ends (del_vert x) e2⟧ ⟹ e1 = e2› 7. ‹symmetric (del_vert x)› discuss goal 1*) apply ((auto simp: arcs_del_vert2 (*‹arcs (del_vert ?v) = arcs G - in_arcs G ?v - out_arcs G ?v›*) tail_del_vert (*‹tail (del_vert ?u) = tail G›*) head_del_vert (*‹head (del_vert ?u) = head G›*) verts_del_vert (*‹verts (del_vert ?u) = verts G - {?u}›*) no_loops (*‹?e ∈ arcs G ⟹ tail G ?e ≠ head G ?e›*) ends_del_vert (*‹arc_to_ends (del_vert ?u) = arc_to_ends G›*) no_multi_arcs (*‹⟦?e1.0 ∈ arcs G; ?e2.0 ∈ arcs G; arc_to_ends G ?e1.0 = arc_to_ends G ?e2.0⟧ ⟹ ?e1.0 = ?e2.0›*) symmetric_def (*‹symmetric ?G ≡ sym (arcs_ends ?G)›*) graph_del_vert_sym (*‹sym (arcs_ends (del_vert ?x))›*))[1]) (*discuss goal 2*) apply ((auto simp: arcs_del_vert2 (*‹arcs (del_vert (?v::'a)) = arcs G - in_arcs G ?v - out_arcs G ?v›*) tail_del_vert (*‹tail (del_vert (?u::'a)) = tail G›*) head_del_vert (*‹head (del_vert (?u::'a)) = head G›*) verts_del_vert (*‹verts (del_vert (?u::'a)) = verts G - {?u}›*) no_loops (*‹(?e::'b) ∈ arcs G ⟹ tail G ?e ≠ head G ?e›*) ends_del_vert (*‹arc_to_ends (del_vert (?u::'a)) = arc_to_ends G›*) no_multi_arcs (*‹⟦(?e1.0::'b) ∈ arcs G; (?e2.0::'b) ∈ arcs G; arc_to_ends G ?e1.0 = arc_to_ends G ?e2.0⟧ ⟹ ?e1.0 = ?e2.0›*) symmetric_def (*‹symmetric (?G::(?'a, ?'b) pre_digraph) ≡ sym (arcs_ends ?G)›*) graph_del_vert_sym (*‹sym (arcs_ends (del_vert (?x::'a)))›*))[1]) (*discuss goal 3*) apply ((auto simp: arcs_del_vert2 (*‹arcs (del_vert (?v::'a::type)) = arcs G - in_arcs G ?v - out_arcs G ?v›*) tail_del_vert (*‹tail (del_vert (?u::'a::type)) = tail G›*) head_del_vert (*‹head (del_vert (?u::'a::type)) = head G›*) verts_del_vert (*‹verts (del_vert (?u::'a::type)) = verts G - {?u}›*) no_loops (*‹(?e::'b::type) ∈ arcs G ⟹ tail G ?e ≠ head G ?e›*) ends_del_vert (*‹arc_to_ends (del_vert (?u::'a::type)) = arc_to_ends G›*) no_multi_arcs (*‹⟦(?e1.0::'b::type) ∈ arcs G; (?e2.0::'b::type) ∈ arcs G; arc_to_ends G ?e1.0 = arc_to_ends G ?e2.0⟧ ⟹ ?e1.0 = ?e2.0›*) symmetric_def (*‹symmetric (?G::(?'a, ?'b) pre_digraph) ≡ sym (arcs_ends ?G)›*) graph_del_vert_sym (*‹sym (arcs_ends (del_vert (?x::'a::type)))›*))[1]) (*discuss goal 4*) apply ((auto simp: arcs_del_vert2 (*‹arcs (del_vert ?v) = arcs G - in_arcs G ?v - out_arcs G ?v›*) tail_del_vert (*‹tail (del_vert ?u) = tail G›*) head_del_vert (*‹head (del_vert ?u) = head G›*) verts_del_vert (*‹verts (del_vert ?u) = verts G - {?u}›*) no_loops (*‹?e ∈ arcs G ⟹ tail G ?e ≠ head G ?e›*) ends_del_vert (*‹arc_to_ends (del_vert ?u) = arc_to_ends G›*) no_multi_arcs (*‹⟦?e1.0 ∈ arcs G; ?e2.0 ∈ arcs G; arc_to_ends G ?e1.0 = arc_to_ends G ?e2.0⟧ ⟹ ?e1.0 = ?e2.0›*) symmetric_def (*‹symmetric ?G ≡ sym (arcs_ends ?G)›*) graph_del_vert_sym (*‹sym (arcs_ends (del_vert ?x))›*))[1]) (*discuss goal 5*) apply ((auto simp: arcs_del_vert2 (*‹arcs (del_vert ?v) = arcs G - in_arcs G ?v - out_arcs G ?v›*) tail_del_vert (*‹tail (del_vert ?u) = tail G›*) head_del_vert (*‹head (del_vert ?u) = head G›*) verts_del_vert (*‹verts (del_vert ?u) = verts G - {?u}›*) no_loops (*‹?e ∈ arcs G ⟹ tail G ?e ≠ head G ?e›*) ends_del_vert (*‹arc_to_ends (del_vert ?u) = arc_to_ends G›*) no_multi_arcs (*‹⟦?e1.0 ∈ arcs G; ?e2.0 ∈ arcs G; arc_to_ends G ?e1.0 = arc_to_ends G ?e2.0⟧ ⟹ ?e1.0 = ?e2.0›*) symmetric_def (*‹symmetric ?G ≡ sym (arcs_ends ?G)›*) graph_del_vert_sym (*‹sym (arcs_ends (del_vert ?x))›*))[1]) (*discuss goal 6*) apply ((auto simp: arcs_del_vert2 (*‹arcs (del_vert ?v) = arcs G - in_arcs G ?v - out_arcs G ?v›*) tail_del_vert (*‹tail (del_vert ?u) = tail G›*) head_del_vert (*‹head (del_vert ?u) = head G›*) verts_del_vert (*‹verts (del_vert ?u) = verts G - {?u}›*) no_loops (*‹?e ∈ arcs G ⟹ tail G ?e ≠ head G ?e›*) ends_del_vert (*‹arc_to_ends (del_vert ?u) = arc_to_ends G›*) no_multi_arcs (*‹⟦?e1.0 ∈ arcs G; ?e2.0 ∈ arcs G; arc_to_ends G ?e1.0 = arc_to_ends G ?e2.0⟧ ⟹ ?e1.0 = ?e2.0›*) symmetric_def (*‹symmetric ?G ≡ sym (arcs_ends ?G)›*) graph_del_vert_sym (*‹sym (arcs_ends (del_vert ?x))›*))[1]) (*discuss goal 7*) apply ((auto simp: arcs_del_vert2 (*‹arcs (del_vert ?v) = arcs G - in_arcs G ?v - out_arcs G ?v›*) tail_del_vert (*‹tail (del_vert ?u) = tail G›*) head_del_vert (*‹head (del_vert ?u) = head G›*) verts_del_vert (*‹verts (del_vert ?u) = verts G - {?u}›*) no_loops (*‹?e ∈ arcs G ⟹ tail G ?e ≠ head G ?e›*) ends_del_vert (*‹arc_to_ends (del_vert ?u) = arc_to_ends G›*) no_multi_arcs (*‹⟦?e1.0 ∈ arcs G; ?e2.0 ∈ arcs G; arc_to_ends G ?e1.0 = arc_to_ends G ?e2.0⟧ ⟹ ?e1.0 = ?e2.0›*) symmetric_def (*‹symmetric ?G ≡ sym (arcs_ends ?G)›*) graph_del_vert_sym (*‹sym (arcs_ends (del_vert ?x))›*))[1]) (*proven 7 subgoals*) . lemma connected_iff_reachable: "connected G ⟷ ((∀x∈verts G. ∀y∈verts G. x →⇧* y) ∧ verts G ≠ {})" using symmetric_connected_imp_strongly_connected (*‹⟦symmetric G; Digraph_Component.connected G⟧ ⟹ strongly_connected G›*) strongly_connected_def (*‹strongly_connected ?G ≡ verts ?G ≠ {} ∧ (∀u∈verts ?G. ∀v∈verts ?G. u →⇧*⇘?G⇙ v)›*) verts_reachable_connected (*‹⟦verts G ≠ {}; ∀x∈verts G. ∀y∈verts G. x →⇧* y⟧ ⟹ Digraph_Component.connected G›*) by blast end context nomulti_digraph begin lemma no_multi_alt: "⟦e1 ∈ arcs G; e2 ∈ arcs G; e1 ≠ e2⟧ ⟹ head G e1 ≠ head G e2 ∨ tail G e1 ≠ tail G e2" using no_multi_arcs (*‹⟦?e1.0 ∈ arcs G; ?e2.0 ∈ arcs G; arc_to_ends G ?e1.0 = arc_to_ends G ?e2.0⟧ ⟹ ?e1.0 = ?e2.0›*) by (auto simp: arc_to_ends_def (*‹arc_to_ends ?G ?e ≡ (tail ?G ?e, head ?G ?e)›*)) end subsection ‹Vertices with Multiple Outgoing Arcs› context wf_digraph begin definition branching_points :: "'a set" where "branching_points = {x. ∃y∈arcs G. ∃z∈arcs G. y≠z ∧ tail G y = x ∧ tail G z = x}" definition is_chain :: "bool" where "is_chain = (branching_points = {})" definition last_branching_points :: "'a set" where "last_branching_points = {x. (x∈branching_points ∧ ¬(∃y ∈ branching_points. y≠x ∧ x →⇧* y))}" lemma branch_in_verts: "x ∈ branching_points ⟹ x ∈ verts G" unfolding branching_points_def (*goal: ‹x ∈ {x. ∃y∈arcs G. ∃z∈arcs G. y ≠ z ∧ tail G y = x ∧ tail G z = x} ⟹ x ∈ verts G›*) by auto lemma last_branch_is_branch: "(y∈last_branching_points ⟹ y∈branching_points)" unfolding last_branching_points_def (*goal: ‹y ∈ {x ∈ branching_points. ¬ (∃y∈branching_points. y ≠ x ∧ x →⇧* y)} ⟹ y ∈ branching_points›*) by blast lemma last_branch_alt: "x ∈ last_branching_points ⟹ (∀z. x →⇧* z ∧ z≠x ⟶ z ∉ branching_points)" unfolding last_branching_points_def (*goal: ‹(x::'a) ∈ {x::'a ∈ branching_points. ¬ (∃y::'a∈branching_points. y ≠ x ∧ x →⇧* y)} ⟹ ∀z::'a. x →⇧* z ∧ z ≠ x ⟶ z ∉ branching_points›*) by blast lemma braching_points_alt: assumes "finite (arcs G)" shows "x ∈ branching_points ⟷ out_degree G x ≥ 2" (is "?P ⟷ ?Q") proof (standard) (*goals: 1. ‹x ∈ branching_points ⟹ 2 ≤ out_degree G x› 2. ‹2 ≤ out_degree G x ⟹ x ∈ branching_points›*) assume "?P" (*‹(x::'a) ∈ branching_points›*) then obtain a1 and a2 where "a1∈arcs G ∧ a2∈arcs G ∧ a1≠a2 ∧ tail G a1 = x ∧ tail G a2 = x" (*goal: ‹(⋀a1 a2. a1 ∈ arcs G ∧ a2 ∈ arcs G ∧ a1 ≠ a2 ∧ tail G a1 = x ∧ tail G a2 = x ⟹ thesis) ⟹ thesis›*) using branching_points_def (*‹branching_points = {x. ∃y∈arcs G. ∃z∈arcs G. y ≠ z ∧ tail G y = x ∧ tail G z = x}›*) by auto then have 0: "a1 ∈ out_arcs G x ∧ a2 ∈ out_arcs G x ∧ a1≠a2" by simp have "finite (out_arcs G x)" by (simp add: assms (*‹finite (arcs G)›*) out_arcs_def (*‹out_arcs ?G ?v ≡ {e ∈ arcs ?G. tail ?G e = ?v}›*)) then show "?Q" unfolding out_degree_def (*goal: ‹2 ≤ card (out_arcs G x)›*) using "0" (*‹a1 ∈ out_arcs G x ∧ a2 ∈ out_arcs G x ∧ a1 ≠ a2›*) two_elems_card_ge_2 (*‹⟦finite ?xs; ?x ∈ ?xs ∧ ?y ∈ ?xs ∧ ?x ≠ ?y⟧ ⟹ 2 ≤ card ?xs›*) by fast next (*goal: ‹2 ≤ out_degree G x ⟹ x ∈ branching_points›*) assume 0: "?Q" (*‹(2::nat) ≤ out_degree G (x::'a)›*) have "finite (out_arcs G x)" by (simp add: assms (*‹finite (arcs G)›*) out_arcs_def (*‹out_arcs ?G ?v ≡ {e ∈ arcs ?G. tail ?G e = ?v}›*)) then have "∃a1 a2. a1 ∈ (out_arcs G x) ∧ a2 ∈ (out_arcs G x) ∧ a1≠a2" using "0" (*‹2 ≤ out_degree G x›*) out_degree_def (*‹out_degree ?G ?v ≡ card (out_arcs ?G ?v)›*) by (metis Suc_n_not_le_n (*‹¬ Suc ?n ≤ ?n›*) card_le_Suc0_iff_eq (*‹finite ?A ⟹ (card ?A ≤ Suc 0) = (∀a1∈?A. ∀a2∈?A. a1 = a2)›*) le_trans (*‹⟦?i ≤ ?j; ?j ≤ ?k⟧ ⟹ ?i ≤ ?k›*) numeral_2_eq_2 (*‹2 = Suc (Suc 0)›*)) then show "?P" unfolding branching_points_def (*goal: ‹x ∈ {x. ∃y∈arcs G. ∃z∈arcs G. y ≠ z ∧ tail G y = x ∧ tail G z = x}›*) by auto qed lemma branch_in_supergraph: assumes "subgraph C G" and "x ∈ wf_digraph.branching_points C" shows "x ∈ branching_points" proof (-) (*goal: ‹x ∈ branching_points›*) have 0: "wf_digraph C" using assms(1) (*‹Shortest_Path_Tree.subgraph C G›*) Digraph_Component.subgraph_def (*‹Digraph_Component.subgraph ?H ?G ≡ verts ?H ⊆ verts ?G ∧ arcs ?H ⊆ arcs ?G ∧ wf_digraph ?G ∧ wf_digraph ?H ∧ compatible ?G ?H›*) subgraph.sub_G (*‹Shortest_Path_Tree.subgraph ?T ?G ⟹ Digraph_Component.subgraph ?T ?G›*) by auto have 1: "wf_digraph G" using assms(1) (*‹Shortest_Path_Tree.subgraph C G›*) subgraph.sub_G (*‹Shortest_Path_Tree.subgraph ?T ?G ⟹ Digraph_Component.subgraph ?T ?G›*) by auto obtain y and z where arcs_C: "y∈arcs C ∧ z∈arcs C ∧ y≠z ∧ tail C y = x ∧ tail C z = x" (*goal: ‹(⋀y z. y ∈ arcs C ∧ z ∈ arcs C ∧ y ≠ z ∧ tail C y = x ∧ tail C z = x ⟹ thesis) ⟹ thesis›*) using assms(2) (*‹x ∈ wf_digraph.branching_points C›*) wf_digraph.branching_points_def (*‹wf_digraph ?G ⟹ wf_digraph.branching_points ?G = {x. ∃y∈arcs ?G. ∃z∈arcs ?G. y ≠ z ∧ tail ?G y = x ∧ tail ?G z = x}›*) "0" (*‹wf_digraph C›*) by blast then have "y∈arcs G ∧ z∈arcs G ∧ y≠z ∧ tail C y = x ∧ tail C z = x" using assms(1) (*‹Shortest_Path_Tree.subgraph C G›*) subgraph.sub_G (*‹Shortest_Path_Tree.subgraph (?T::(?'a, ?'b) pre_digraph) (?G::(?'a, ?'b) pre_digraph) ⟹ Digraph_Component.subgraph ?T ?G›*) by blast then have "y∈arcs G ∧ z∈arcs G ∧ y≠z ∧ tail G y = x ∧ tail G z = x" using assms(1) (*‹Shortest_Path_Tree.subgraph (C::('a, 'b) pre_digraph) G›*) subgraph.sub_G (*‹Shortest_Path_Tree.subgraph ?T ?G ⟹ Digraph_Component.subgraph ?T ?G›*) compatible_def (*‹compatible ?G ?H ≡ tail ?G = tail ?H ∧ head ?G = head ?H›*) by force then show "?thesis" (*goal: ‹x ∈ branching_points›*) using branching_points_def (*‹branching_points = {x. ∃y∈arcs G. ∃z∈arcs G. y ≠ z ∧ tail G y = x ∧ tail G z = x}›*) assms(1) (*‹Shortest_Path_Tree.subgraph (C::('a, 'b) pre_digraph) G›*) subgraph.sub_G (*‹Shortest_Path_Tree.subgraph ?T ?G ⟹ Digraph_Component.subgraph ?T ?G›*) by blast qed lemma subgraph_no_branch_chain: assumes "subgraph C G" and "verts C ⊆ verts G - {x. ∃y∈branching_points. x →⇧*⇘G⇙ y}" shows "wf_digraph.is_chain C" proof (rule ccontr (*‹(¬ ?P ⟹ False) ⟹ ?P›*)) (*goal: ‹¬ wf_digraph.is_chain C ⟹ False›*) assume asm: "¬wf_digraph.is_chain C" (*‹¬ wf_digraph.is_chain (C::('a, 'b) pre_digraph)›*) let ?rem = "{x. ∃y∈branching_points. x →⇧*⇘G⇙ y}" have "wf_digraph C" using assms(1) (*‹Shortest_Path_Tree.subgraph C G›*) Digraph_Component.subgraph_def (*‹Digraph_Component.subgraph (?H::(?'a, ?'b) pre_digraph) (?G::(?'a, ?'b) pre_digraph) ≡ verts ?H ⊆ verts ?G ∧ arcs ?H ⊆ arcs ?G ∧ wf_digraph ?G ∧ wf_digraph ?H ∧ compatible ?G ?H›*) subgraph.sub_G (*‹Shortest_Path_Tree.subgraph ?T ?G ⟹ Digraph_Component.subgraph ?T ?G›*) by auto then obtain x where x_def[simp]: "x ∈ wf_digraph.branching_points C" (*goal: ‹(⋀x. x ∈ wf_digraph.branching_points C ⟹ thesis) ⟹ thesis›*) using wf_digraph.is_chain_def (*‹wf_digraph ?G ⟹ wf_digraph.is_chain ?G = (wf_digraph.branching_points ?G = {})›*) asm (*‹¬ wf_digraph.is_chain (C::('a, 'b) pre_digraph)›*) by blast then have "x ∈ branching_points" using assms(1) (*‹Shortest_Path_Tree.subgraph C G›*) branch_in_supergraph (*‹⟦Shortest_Path_Tree.subgraph ?C G; ?x ∈ wf_digraph.branching_points ?C⟧ ⟹ ?x ∈ branching_points›*) by simp moreover from this (*‹x ∈ branching_points›*) have "x ∈ verts G" using branch_in_verts (*‹?x ∈ branching_points ⟹ ?x ∈ verts G›*) by simp moreover from this (*‹(x::'a::type) ∈ verts G›*) have "x →⇧*⇘G⇙ x" by simp ultimately have "x ∈ ?rem" by blast then show False using assms(2) (*‹verts C ⊆ verts G - {x. ∃y∈branching_points. x →⇧* y}›*) ‹wf_digraph C› (*‹wf_digraph C›*) subsetD (*‹⟦(?A::?'a::type set) ⊆ (?B::?'a::type set); (?c::?'a::type) ∈ ?A⟧ ⟹ ?c ∈ ?B›*) wf_digraph.branch_in_verts (*‹⟦wf_digraph ?G; ?x ∈ wf_digraph.branching_points ?G⟧ ⟹ ?x ∈ verts ?G›*) by fastforce qed lemma branch_if_leaf_added: assumes "x∈wf_digraph.branching_points G'" and "G = ⦇verts = V ∪ {v}, arcs = A ∪ {a}, tail = t(a := u), head = h(a := v)⦈" and "G' = ⦇verts = V, arcs = A, tail = t, head = h⦈" and "wf_digraph G'" and "a ∉ A" shows "x ∈ branching_points" proof (-) (*goal: ‹x ∈ branching_points›*) obtain a1 and a2 where a12: "a1∈arcs G' ∧ a2∈arcs G' ∧ a1≠a2 ∧ tail G' a1 = x ∧ tail G' a2 = x" (*goal: ‹(⋀a1 a2. a1 ∈ arcs G' ∧ a2 ∈ arcs G' ∧ a1 ≠ a2 ∧ tail G' a1 = x ∧ tail G' a2 = x ⟹ thesis) ⟹ thesis›*) using wf_digraph.branching_points_def (*‹wf_digraph ?G ⟹ wf_digraph.branching_points ?G = {x. ∃y∈arcs ?G. ∃z∈arcs ?G. y ≠ z ∧ tail ?G y = x ∧ tail ?G z = x}›*) assms(1,4) (*‹(x::'a::type) ∈ wf_digraph.branching_points (G'::('a, 'b) pre_digraph)› ‹wf_digraph G'›*) by blast then have "a1 ≠ a ∧ a2 ≠ a" using assms(3,5) (*‹G' = ⦇verts = V, arcs = A, tail = t, head = h⦈› ‹a ∉ A›*) by auto then have 0: "tail G a1 = tail G' a1 ∧ tail G a2 = tail G' a2" using assms(2,3) (*‹G = ⦇verts = V ∪ {v}, arcs = A ∪ {a}, tail = t(a := u), head = h(a := v)⦈› ‹G' = ⦇verts = V, arcs = A, tail = t, head = h⦈›*) by simp have "a1∈arcs G ∧ a2∈arcs G ∧ a1≠a2 ∧ a1≠a2 ∧ tail G' a1 = x ∧ tail G' a2 = x" using assms(2,3) (*‹G = ⦇verts = (V::'a::type set) ∪ {v::'a::type}, arcs = (A::'b::type set) ∪ {a::'b::type}, tail = (t::'b::type ⇒ 'a::type)(a := u::'a::type), head = (h::'b::type ⇒ 'a::type)(a := v)⦈› ‹G' = ⦇verts = V, arcs = A, tail = t, head = h⦈›*) a12 (*‹a1 ∈ arcs G' ∧ a2 ∈ arcs G' ∧ a1 ≠ a2 ∧ tail G' a1 = x ∧ tail G' a2 = x›*) by simp then have "a1∈arcs G ∧ a2∈arcs G ∧ a1≠a2 ∧ tail G a1 = x ∧ tail G a2 = x" using "0" (*‹tail G a1 = tail G' a1 ∧ tail G a2 = tail G' a2›*) by simp then show "?thesis" (*goal: ‹x ∈ branching_points›*) unfolding branching_points_def (*goal: ‹x ∈ {x. ∃y∈arcs G. ∃z∈arcs G. y ≠ z ∧ tail G y = x ∧ tail G z = x}›*) by blast qed lemma new_leaf_no_branch: assumes "G = ⦇verts = V ∪ {v}, arcs = A ∪ {a}, tail = t(a := u), head = h(a := v)⦈" and "G' = ⦇verts = V, arcs = A, tail = t, head = h⦈" and "wf_digraph G'" and "u ∈ V" and "v ∉ V" and "a ∉ A" shows "v ∉ branching_points" proof (-) (*goal: ‹v ∉ branching_points›*) have "v ≠ u" using assms(4,5) (*‹(u::'a) ∈ (V::'a set)› ‹v ∉ V›*) by fast have "∀a∈arcs G'. tail G' a ≠ v" using assms(2,3,5) (*‹G' = ⦇verts = V, arcs = A, tail = t, head = h⦈› ‹wf_digraph (G'::('a, 'b) pre_digraph)› ‹v ∉ V›*) pre_digraph.select_convs(1) (*‹verts ⦇verts = ?verts::?'a set, arcs = ?arcs::?'b set, tail = ?tail::?'b ⇒ ?'a, head = ?head::?'b ⇒ ?'a, … = ?more::?'z⦈ = ?verts›*) wf_digraph_def (*‹wf_digraph ?G ≡ (∀e. e ∈ arcs ?G ⟶ tail ?G e ∈ verts ?G) ∧ (∀e. e ∈ arcs ?G ⟶ head ?G e ∈ verts ?G)›*) by fast moreover have "∀x ∈ arcs G'. tail G x = tail G' x" using assms(1,2,6) (*‹G = ⦇verts = (V::'a set) ∪ {v::'a}, arcs = (A::'b set) ∪ {a::'b}, tail = (t::'b ⇒ 'a)(a := u::'a), head = (h::'b ⇒ 'a)(a := v)⦈› ‹G' = ⦇verts = V, arcs = A, tail = t, head = h⦈› ‹a ∉ A›*) by simp ultimately have "∀a∈arcs G'. tail G a ≠ v" by simp then have "∀a∈arcs G. tail G a ≠ v" using assms(1,2,6) (*‹G = ⦇verts = V ∪ {v}, arcs = A ∪ {a}, tail = t(a := u), head = h(a := v)⦈› ‹(G'::('a, 'b) pre_digraph) = ⦇verts = V::'a::type set, arcs = A::'b::type set, tail = t::'b::type ⇒ 'a::type, head = h::'b::type ⇒ 'a::type⦈› ‹(a::'b) ∉ (A::'b set)›*) Un_iff (*‹(?c ∈ ?A ∪ ?B) = (?c ∈ ?A ∨ ?c ∈ ?B)›*) pre_digraph.select_convs(2) (*‹arcs ⦇verts = ?verts, arcs = ?arcs, tail = ?tail, head = ?head, … = ?more⦈ = ?arcs›*) singletonD (*‹?b ∈ {?a} ⟹ ?b = ?a›*) ‹v ≠ u› (*‹v ≠ u›*) by simp then show "?thesis" (*goal: ‹v ∉ branching_points›*) unfolding branching_points_def (*goal: ‹(v::'a) ∉ {x::'a. ∃y::'b∈arcs G. ∃z::'b∈arcs G. y ≠ z ∧ tail G y = x ∧ tail G z = x}›*) by blast qed lemma new_leaf_not_reach_last_branch: assumes "y∈wf_digraph.last_branching_points G'" and "¬ y →⇧* u" and "G = ⦇verts = V ∪ {v}, arcs = A ∪ {a}, tail = t(a := u), head = h(a := v)⦈" and "G' = ⦇verts = V, arcs = A, tail = t, head = h⦈" and "wf_digraph G'" and "y ∈ V" and "u ∈ V" and "v ∉ V" and "a ∉ A" and "finite (arcs G)" shows "¬(∃z ∈ branching_points. z≠y ∧ y →⇧* z)" proof (standard) (*goal: ‹∃z∈branching_points. z ≠ y ∧ y →⇧* z ⟹ False›*) assume "∃z ∈ branching_points. z≠y ∧ y →⇧* z" (*‹∃z::'a∈branching_points. z ≠ (y::'a) ∧ y →⇧* z›*) then obtain z where z_def: "z ∈ branching_points ∧ z≠y ∧ y →⇧* z" (*goal: ‹(⋀z. z ∈ branching_points ∧ z ≠ y ∧ y →⇧* z ⟹ thesis) ⟹ thesis›*) by blast then have "z ≠ u" using assms(2) (*‹¬ y →⇧* u›*) by blast then obtain a1 and a2 where a12: "a1∈arcs G ∧ a2∈arcs G ∧ a1≠a2 ∧ tail G a1 = z ∧ tail G a2 = z" (*goal: ‹(⋀(a1::'b) a2::'b. a1 ∈ arcs G ∧ a2 ∈ arcs G ∧ a1 ≠ a2 ∧ tail G a1 = (z::'a) ∧ tail G a2 = z ⟹ thesis::bool) ⟹ thesis›*) using branching_points_def (*‹branching_points = {x. ∃y∈arcs G. ∃z∈arcs G. y ≠ z ∧ tail G y = x ∧ tail G z = x}›*) z_def (*‹z ∈ branching_points ∧ z ≠ y ∧ y →⇧* z›*) by blast then have 0: "a1 ≠ a ∧ a2 ≠ a" using assms(3) (*‹G = ⦇verts = (V::'a set) ∪ {v::'a}, arcs = (A::'b set) ∪ {a::'b}, tail = (t::'b ⇒ 'a)(a := u::'a), head = (h::'b ⇒ 'a)(a := v)⦈›*) ‹z≠u› (*‹z ≠ u›*) by fastforce then have 1: "tail G a1 = tail G' a1 ∧ tail G a2 = tail G' a2" using assms(3,4) (*‹G = ⦇verts = V ∪ {v}, arcs = A ∪ {a}, tail = t(a := u), head = h(a := v)⦈› ‹G' = ⦇verts = V, arcs = A, tail = t, head = h⦈›*) by simp have "a1∈arcs G' ∧ a2∈arcs G' ∧ a1≠a2 ∧ tail G a1 = z ∧ tail G a2 = z" using assms(3,4) (*‹G = ⦇verts = V ∪ {v}, arcs = A ∪ {a}, tail = t(a := u), head = h(a := v)⦈› ‹G' = ⦇verts = V, arcs = A, tail = t, head = h⦈›*) a12 (*‹a1 ∈ arcs G ∧ a2 ∈ arcs G ∧ a1 ≠ a2 ∧ tail G a1 = z ∧ tail G a2 = z›*) "0" (*‹a1 ≠ a ∧ a2 ≠ a›*) by simp then have "a1∈arcs G' ∧ a2∈arcs G' ∧ a1≠a2 ∧ tail G' a1 = z ∧ tail G' a2 = z" using "1" (*‹tail G (a1::'b) = tail (G'::('a, 'b) pre_digraph) a1 ∧ tail G (a2::'b) = tail G' a2›*) by simp then have 2: "z ∈ wf_digraph.branching_points G'" using wf_digraph.branching_points_def (*‹wf_digraph ?G ⟹ wf_digraph.branching_points ?G = {x. ∃y∈arcs ?G. ∃z∈arcs ?G. y ≠ z ∧ tail ?G y = x ∧ tail ?G z = x}›*) assms(5) (*‹wf_digraph G'›*) by auto have "z ≠ v" using assms(2,3,4,5,6,8) (*‹¬ y →⇧* u› ‹G = ⦇verts = (V::'a set) ∪ {v::'a}, arcs = (A::'b set) ∪ {a::'b}, tail = (t::'b ⇒ 'a)(a := u::'a), head = (h::'b ⇒ 'a)(a := v)⦈› ‹G' = ⦇verts = V, arcs = A, tail = t, head = h⦈› ‹wf_digraph G'› ‹y ∈ V› ‹v ∉ V›*) z_def (*‹z ∈ branching_points ∧ z ≠ y ∧ y →⇧* z›*) new_leaf_reach_impl_parent (*‹⟦(?y::'a) →⇧* (?v::'a); G = ⦇verts = (?V::'a set) ∪ {?v}, arcs = (?A::'b set) ∪ {?a::'b}, tail = (?t::'b ⇒ 'a)(?a := ?u::'a), head = (?h::'b ⇒ 'a)(?a := ?v)⦈; (?G'::('a, 'b) pre_digraph) = ⦇verts = ?V, arcs = ?A, tail = ?t, head = ?h⦈; wf_digraph ?G'; ?y ∈ ?V; ?v ∉ ?V⟧ ⟹ ?y →⇧* ?u›*) by blast then have "y →⇧*⇘G'⇙ z" using new_leaf_same_reachables_orig (*‹⟦?x →⇧* ?y; G = ⦇verts = ?V ∪ {?v}, arcs = ?A ∪ {?a}, tail = ?t(?a := ?u), head = ?h(?a := ?v)⦈; ?G' = ⦇verts = ?V, arcs = ?A, tail = ?t, head = ?h⦈; wf_digraph ?G'; ?x ∈ ?V; ?u ∈ ?V; ?v ∉ ?V; ?y ≠ ?v; ?a ∉ ?A; finite (arcs G)⟧ ⟹ ?x →⇧*⇘?G'⇙ ?y›*) z_def (*‹z ∈ branching_points ∧ z ≠ y ∧ y →⇧* z›*) assms (*‹y ∈ wf_digraph.last_branching_points G'› ‹¬ y →⇧* u› ‹G = ⦇verts = V ∪ {v}, arcs = A ∪ {a}, tail = t(a := u), head = h(a := v)⦈› ‹(G'::('a, 'b) pre_digraph) = ⦇verts = V::'a set, arcs = A::'b set, tail = t::'b ⇒ 'a, head = h::'b ⇒ 'a⦈› ‹wf_digraph G'› ‹(y::'a) ∈ (V::'a set)› ‹u ∈ V› ‹v ∉ V› ‹a ∉ A› ‹finite (arcs G)›*) by blast then have "∃z∈wf_digraph.branching_points G'. z≠y ∧ y →⇧*⇘G'⇙ z" using "2" (*‹z ∈ wf_digraph.branching_points G'›*) z_def (*‹(z::'a) ∈ branching_points ∧ z ≠ (y::'a) ∧ y →⇧* z›*) by blast then have "y ∉ wf_digraph.last_branching_points G'" using wf_digraph.last_branching_points_def (*‹wf_digraph (?G::(?'a, ?'b) pre_digraph) ⟹ wf_digraph.last_branching_points ?G = {x::?'a::type ∈ wf_digraph.branching_points ?G. ¬ (∃y::?'a::type∈wf_digraph.branching_points ?G. y ≠ x ∧ x →⇧*⇘?G⇙ y)}›*) assms(5) (*‹wf_digraph G'›*) by blast then show False using assms(1) (*‹y ∈ wf_digraph.last_branching_points G'›*) by simp qed lemma new_leaf_parent_nbranch_in_orig: assumes "y∈branching_points" and "y ≠ u" and "G = ⦇verts = V ∪ {v}, arcs = A ∪ {a}, tail = t(a := u), head = h(a := v)⦈" and "G' = ⦇verts = V, arcs = A, tail = t, head = h⦈" and "wf_digraph G'" shows "y∈wf_digraph.branching_points G'" proof (-) (*goal: ‹y ∈ wf_digraph.branching_points G'›*) obtain a1 and a2 where a12: "a1∈arcs G ∧ a2∈arcs G ∧ a1≠a2 ∧ tail G a1 = y ∧ tail G a2 = y" (*goal: ‹(⋀a1 a2. a1 ∈ arcs G ∧ a2 ∈ arcs G ∧ a1 ≠ a2 ∧ tail G a1 = y ∧ tail G a2 = y ⟹ thesis) ⟹ thesis›*) using branching_points_def (*‹branching_points = {x. ∃y∈arcs G. ∃z∈arcs G. y ≠ z ∧ tail G y = x ∧ tail G z = x}›*) assms(1) (*‹(y::'a) ∈ branching_points›*) by blast then have 0: "a1 ≠ a ∧ a2 ≠ a" using assms(2,3) (*‹y ≠ u› ‹G = ⦇verts = V ∪ {v}, arcs = A ∪ {a}, tail = t(a := u), head = h(a := v)⦈›*) by fastforce then have 1: "tail G a1 = tail G' a1 ∧ tail G a2 = tail G' a2" using assms(3,4) (*‹G = ⦇verts = V ∪ {v}, arcs = A ∪ {a}, tail = t(a := u), head = h(a := v)⦈› ‹G' = ⦇verts = V, arcs = A, tail = t, head = h⦈›*) by simp have "a1∈arcs G' ∧ a2∈arcs G' ∧ a1≠a2 ∧ tail G a1 = y ∧ tail G a2 = y" using assms(3,4) (*‹G = ⦇verts = (V::'a::type set) ∪ {v::'a::type}, arcs = (A::'b::type set) ∪ {a::'b::type}, tail = (t::'b::type ⇒ 'a::type)(a := u::'a::type), head = (h::'b::type ⇒ 'a::type)(a := v)⦈› ‹(G'::('a, 'b) pre_digraph) = ⦇verts = V::'a set, arcs = A::'b set, tail = t::'b ⇒ 'a, head = h::'b ⇒ 'a⦈›*) a12 (*‹a1 ∈ arcs G ∧ a2 ∈ arcs G ∧ a1 ≠ a2 ∧ tail G a1 = y ∧ tail G a2 = y›*) "0" (*‹a1 ≠ a ∧ a2 ≠ a›*) by auto then have "a1∈arcs G' ∧ a2∈arcs G' ∧ a1≠a2 ∧ tail G' a1 = y ∧ tail G' a2 = y" using "1" (*‹tail G a1 = tail G' a1 ∧ tail G a2 = tail G' a2›*) by simp then show "?thesis" (*goal: ‹(y::'a) ∈ wf_digraph.branching_points (G'::('a, 'b) pre_digraph)›*) using assms(5) (*‹wf_digraph (G'::('a, 'b) pre_digraph)›*) wf_digraph.branching_points_def (*‹wf_digraph ?G ⟹ wf_digraph.branching_points ?G = {x. ∃y∈arcs ?G. ∃z∈arcs ?G. y ≠ z ∧ tail ?G y = x ∧ tail ?G z = x}›*) by auto qed lemma new_leaf_last_branch_exists_preserv: assumes "y∈wf_digraph.last_branching_points G'" and "x →⇧* y" and "G = ⦇verts = V ∪ {v}, arcs = A ∪ {a}, tail = t(a := u), head = h(a := v)⦈" and "G' = ⦇verts = V, arcs = A, tail = t, head = h⦈" and "wf_digraph G'" and "y ∈ V" and "u ∈ V" and "v ∉ V" and "a ∉ A" and "finite (arcs G)" and "∀x. y →⁺ x ⟶ y≠x" obtains y' where "y'∈last_branching_points ∧ x →⇧* y'" proof (cases "y →⇧* u") (*goals: 1. ‹⟦⋀y'::'a::type. y' ∈ last_branching_points ∧ (x::'a::type) →⇧* y' ⟹ thesis::bool; (y::'a::type) →⇧* (u::'a::type)⟧ ⟹ thesis› 2. ‹⟦⋀y'::'a::type. y' ∈ last_branching_points ∧ (x::'a::type) →⇧* y' ⟹ thesis::bool; ¬ (y::'a::type) →⇧* (u::'a::type)⟧ ⟹ thesis›*) case True (*‹y →⇧* u›*) have "y ∈ wf_digraph.branching_points G'" using assms(1,5) (*‹y ∈ wf_digraph.last_branching_points G'› ‹wf_digraph G'›*) wf_digraph.last_branch_is_branch (*‹⟦wf_digraph ?G; ?y ∈ wf_digraph.last_branching_points ?G⟧ ⟹ ?y ∈ wf_digraph.branching_points ?G›*) by fast then have y_branch: "y ∈ branching_points" using branch_if_leaf_added (*‹⟦?x ∈ wf_digraph.branching_points ?G'; G = ⦇verts = ?V ∪ {?v}, arcs = ?A ∪ {?a}, tail = ?t(?a := ?u), head = ?h(?a := ?v)⦈; ?G' = ⦇verts = ?V, arcs = ?A, tail = ?t, head = ?h⦈; wf_digraph ?G'; ?a ∉ ?A⟧ ⟹ ?x ∈ branching_points›*) assms(3-5,9) (*‹G = ⦇verts = (V::'a::type set) ∪ {v::'a::type}, arcs = (A::'b::type set) ∪ {a::'b::type}, tail = (t::'b::type ⇒ 'a::type)(a := u::'a::type), head = (h::'b::type ⇒ 'a::type)(a := v)⦈› ‹G' = ⦇verts = V, arcs = A, tail = t, head = h⦈› ‹wf_digraph G'› ‹a ∉ A›*) by blast have v_nbranch: "v ∉ branching_points" using new_leaf_no_branch (*‹⟦G = ⦇verts = ?V ∪ {?v}, arcs = ?A ∪ {?a}, tail = ?t(?a := ?u), head = ?h(?a := ?v)⦈; ?G' = ⦇verts = ?V, arcs = ?A, tail = ?t, head = ?h⦈; wf_digraph ?G'; ?u ∈ ?V; ?v ∉ ?V; ?a ∉ ?A⟧ ⟹ ?v ∉ branching_points›*) assms(3-5,7-9) (*‹G = ⦇verts = V ∪ {v}, arcs = A ∪ {a}, tail = t(a := u), head = h(a := v)⦈› ‹G' = ⦇verts = V, arcs = A, tail = t, head = h⦈› ‹wf_digraph G'› ‹u ∈ V› ‹v ∉ V› ‹a ∉ A›*) by blast then show "?thesis" (*goal: ‹thesis›*) proof (cases "u ∈ branching_points") (*goals: 1. ‹⟦(v::'a::type) ∉ branching_points; (u::'a::type) ∈ branching_points⟧ ⟹ thesis::bool› 2. ‹⟦(v::'a::type) ∉ branching_points; (u::'a::type) ∉ branching_points⟧ ⟹ thesis::bool›*) case True (*‹u ∈ branching_points›*) have "¬(∃z ∈ branching_points. z≠u ∧ u →⇧* z)" proof (standard) (*goal: ‹∃z∈branching_points. z ≠ u ∧ u →⇧* z ⟹ False›*) assume "∃z ∈ branching_points. z≠u ∧ u →⇧* z" (*‹∃z::'a∈branching_points. z ≠ (u::'a) ∧ u →⇧* z›*) then obtain z where z_def: "z ∈ branching_points ∧ z≠u ∧ u →⇧* z" (*goal: ‹(⋀z::'a::type. z ∈ branching_points ∧ z ≠ (u::'a::type) ∧ u →⇧* z ⟹ thesis::bool) ⟹ thesis›*) by blast then have "z ≠ v" using v_nbranch (*‹v ∉ branching_points›*) by blast then have "u →⇧*⇘G'⇙ z" using new_leaf_same_reachables_orig (*‹⟦?x →⇧* ?y; G = ⦇verts = ?V ∪ {?v}, arcs = ?A ∪ {?a}, tail = ?t(?a := ?u), head = ?h(?a := ?v)⦈; ?G' = ⦇verts = ?V, arcs = ?A, tail = ?t, head = ?h⦈; wf_digraph ?G'; ?x ∈ ?V; ?u ∈ ?V; ?v ∉ ?V; ?y ≠ ?v; ?a ∉ ?A; finite (arcs G)⟧ ⟹ ?x →⇧*⇘?G'⇙ ?y›*) assms(3-5,7-10) (*‹G = ⦇verts = V ∪ {v}, arcs = A ∪ {a}, tail = t(a := u), head = h(a := v)⦈› ‹G' = ⦇verts = V, arcs = A, tail = t, head = h⦈› ‹wf_digraph G'› ‹u ∈ V› ‹v ∉ V› ‹(a::'b) ∉ (A::'b set)› ‹finite (arcs G)›*) z_def (*‹(z::'a::type) ∈ branching_points ∧ z ≠ (u::'a::type) ∧ u →⇧* z›*) by blast moreover have "y →⇧*⇘G'⇙ u" using new_leaf_same_reachables_orig (*‹⟦?x →⇧* ?y; G = ⦇verts = ?V ∪ {?v}, arcs = ?A ∪ {?a}, tail = ?t(?a := ?u), head = ?h(?a := ?v)⦈; ?G' = ⦇verts = ?V, arcs = ?A, tail = ?t, head = ?h⦈; wf_digraph ?G'; ?x ∈ ?V; ?u ∈ ?V; ?v ∉ ?V; ?y ≠ ?v; ?a ∉ ?A; finite (arcs G)⟧ ⟹ ?x →⇧*⇘?G'⇙ ?y›*) ‹y →⇧* u› (*‹y →⇧* u›*) assms(3-10) (*‹G = ⦇verts = (V::'a::type set) ∪ {v::'a::type}, arcs = (A::'b::type set) ∪ {a::'b::type}, tail = (t::'b::type ⇒ 'a::type)(a := u::'a::type), head = (h::'b::type ⇒ 'a::type)(a := v)⦈› ‹G' = ⦇verts = V, arcs = A, tail = t, head = h⦈› ‹wf_digraph (G'::('a, 'b) pre_digraph)› ‹y ∈ V› ‹u ∈ V› ‹v ∉ V› ‹a ∉ A› ‹finite (arcs G)›*) by blast ultimately have 0: "y →⇧*⇘G'⇙ z" using assms(5) (*‹wf_digraph G'›*) wf_digraph.reachable_trans (*‹⟦wf_digraph (?G::(?'a, ?'b) pre_digraph); (?u::?'a) →⇧*⇘?G⇙ (?v::?'a); ?v →⇧*⇘?G⇙ (?w::?'a)⟧ ⟹ ?u →⇧*⇘?G⇙ ?w›*) by fast have "y →⁺ z" using ‹y →⇧* u› (*‹y →⇧* u›*) z_def (*‹z ∈ branching_points ∧ z ≠ u ∧ u →⇧* z›*) reachable_reachable1_trans (*‹⟦?u →⇧* ?v; ?v →⁺ ?w⟧ ⟹ ?u →⁺ ?w›*) reachable_neq_reachable1 (*‹⟦?v →⇧* ?w; ?v ≠ ?w⟧ ⟹ ?v →⁺ ?w›*) by blast then have "y ≠ z" using assms(11) (*‹∀x. y →⁺ x ⟶ y ≠ x›*) by simp have "z ∈ wf_digraph.branching_points G'" using z_def (*‹z ∈ branching_points ∧ z ≠ u ∧ u →⇧* z›*) new_leaf_parent_nbranch_in_orig (*‹⟦?y ∈ branching_points; ?y ≠ ?u; G = ⦇verts = ?V ∪ {?v}, arcs = ?A ∪ {?a}, tail = ?t(?a := ?u), head = ?h(?a := ?v)⦈; ?G' = ⦇verts = ?V, arcs = ?A, tail = ?t, head = ?h⦈; wf_digraph ?G'⟧ ⟹ ?y ∈ wf_digraph.branching_points ?G'›*) assms(3-5) (*‹G = ⦇verts = V ∪ {v}, arcs = A ∪ {a}, tail = t(a := u), head = h(a := v)⦈› ‹G' = ⦇verts = V, arcs = A, tail = t, head = h⦈› ‹wf_digraph G'›*) by blast then have "y ∉ wf_digraph.last_branching_points G'" using "0" (*‹y →⇧*⇘G'⇙ z›*) assms(5) (*‹wf_digraph (G'::('a, 'b) pre_digraph)›*) wf_digraph.last_branch_alt (*‹⟦wf_digraph ?G; ?x ∈ wf_digraph.last_branching_points ?G⟧ ⟹ ∀z. ?x →⇧*⇘?G⇙ z ∧ z ≠ ?x ⟶ z ∉ wf_digraph.branching_points ?G›*) ‹y ≠ z› (*‹y ≠ z›*) by fast then show False using assms(1) (*‹y ∈ wf_digraph.last_branching_points G'›*) by simp qed then have "u ∈ last_branching_points" unfolding last_branching_points_def (*goal: ‹u ∈ {x ∈ branching_points. ¬ (∃y∈branching_points. y ≠ x ∧ x →⇧* y)}›*) using True (*‹(u::'a) ∈ branching_points›*) by blast then show "?thesis" (*goal: ‹thesis›*) using assms(2) (*‹x →⇧* y›*) ‹y →⇧* u› (*‹y →⇧* u›*) reachable_trans (*‹⟦?u →⇧* ?v; ?v →⇧* ?w⟧ ⟹ ?u →⇧* ?w›*) that (*‹?y'2 ∈ last_branching_points ∧ x →⇧* ?y'2 ⟹ thesis›*) by blast next (*goal: ‹⟦v ∉ branching_points; u ∉ branching_points⟧ ⟹ thesis›*) case False (*‹u ∉ branching_points›*) have "¬(∃z ∈ branching_points. z≠y ∧ y →⇧* z)" proof (standard) (*goal: ‹∃z::'a∈branching_points. z ≠ (y::'a) ∧ y →⇧* z ⟹ False›*) assume "∃z ∈ branching_points. z≠y ∧ y →⇧* z" (*‹∃z::'a∈branching_points. z ≠ (y::'a) ∧ y →⇧* z›*) then obtain z where z_def: "z ∈ branching_points ∧ z≠y ∧ y →⇧* z" (*goal: ‹(⋀z. z ∈ branching_points ∧ z ≠ y ∧ y →⇧* z ⟹ thesis) ⟹ thesis›*) by blast then have "z ≠ v" using v_nbranch (*‹v ∉ branching_points›*) by blast then have 0: "y →⇧*⇘G'⇙ z" using new_leaf_same_reachables_orig (*‹⟦?x →⇧* ?y; G = ⦇verts = ?V ∪ {?v}, arcs = ?A ∪ {?a}, tail = ?t(?a := ?u), head = ?h(?a := ?v)⦈; ?G' = ⦇verts = ?V, arcs = ?A, tail = ?t, head = ?h⦈; wf_digraph ?G'; ?x ∈ ?V; ?u ∈ ?V; ?v ∉ ?V; ?y ≠ ?v; ?a ∉ ?A; finite (arcs G)⟧ ⟹ ?x →⇧*⇘?G'⇙ ?y›*) assms(3-10) (*‹G = ⦇verts = (V::'a set) ∪ {v::'a}, arcs = (A::'b set) ∪ {a::'b}, tail = (t::'b ⇒ 'a)(a := u::'a), head = (h::'b ⇒ 'a)(a := v)⦈› ‹G' = ⦇verts = V, arcs = A, tail = t, head = h⦈› ‹wf_digraph G'› ‹y ∈ V› ‹u ∈ V› ‹v ∉ V› ‹(a::'b) ∉ (A::'b set)› ‹finite (arcs G)›*) z_def (*‹z ∈ branching_points ∧ z ≠ y ∧ y →⇧* z›*) by blast have "z ≠ u" using False (*‹u ∉ branching_points›*) z_def (*‹z ∈ branching_points ∧ z ≠ y ∧ y →⇧* z›*) by blast then have "z ∈ wf_digraph.branching_points G'" using z_def (*‹z ∈ branching_points ∧ z ≠ y ∧ y →⇧* z›*) new_leaf_parent_nbranch_in_orig (*‹⟦?y ∈ branching_points; ?y ≠ ?u; G = ⦇verts = ?V ∪ {?v}, arcs = ?A ∪ {?a}, tail = ?t(?a := ?u), head = ?h(?a := ?v)⦈; ?G' = ⦇verts = ?V, arcs = ?A, tail = ?t, head = ?h⦈; wf_digraph ?G'⟧ ⟹ ?y ∈ wf_digraph.branching_points ?G'›*) assms(3-5) (*‹G = ⦇verts = V ∪ {v}, arcs = A ∪ {a}, tail = t(a := u), head = h(a := v)⦈› ‹G' = ⦇verts = V, arcs = A, tail = t, head = h⦈› ‹wf_digraph G'›*) by blast then have "y ∉ wf_digraph.last_branching_points G'" using "0" (*‹y →⇧*⇘G'⇙ z›*) z_def (*‹z ∈ branching_points ∧ z ≠ y ∧ y →⇧* z›*) assms(5) (*‹wf_digraph G'›*) wf_digraph.last_branch_alt (*‹⟦wf_digraph (?G::(?'a, ?'b) pre_digraph); (?x::?'a::type) ∈ wf_digraph.last_branching_points ?G⟧ ⟹ ∀z::?'a::type. ?x →⇧*⇘?G⇙ z ∧ z ≠ ?x ⟶ z ∉ wf_digraph.branching_points ?G›*) by fast then show False using assms(1) (*‹y ∈ wf_digraph.last_branching_points G'›*) by simp qed then have "y ∈ last_branching_points" using last_branching_points_def (*‹last_branching_points = {x ∈ branching_points. ¬ (∃y∈branching_points. y ≠ x ∧ x →⇧* y)}›*) y_branch (*‹y ∈ branching_points›*) by simp then show "?thesis" (*goal: ‹thesis›*) using assms(2) (*‹x →⇧* y›*) that (*‹?y'2 ∈ last_branching_points ∧ x →⇧* ?y'2 ⟹ thesis›*) by blast qed next (*goal: ‹⟦⋀y'. y' ∈ last_branching_points ∧ x →⇧* y' ⟹ thesis; ¬ y →⇧* u⟧ ⟹ thesis›*) case False (*‹¬ y →⇧* u›*) have "y ∈ wf_digraph.branching_points G'" using assms(1,5) (*‹y ∈ wf_digraph.last_branching_points G'› ‹wf_digraph G'›*) wf_digraph.last_branch_is_branch (*‹⟦wf_digraph (?G::(?'a, ?'b) pre_digraph); (?y::?'a::type) ∈ wf_digraph.last_branching_points ?G⟧ ⟹ ?y ∈ wf_digraph.branching_points ?G›*) by fast then have "y ∈ branching_points" using branch_if_leaf_added (*‹⟦(?x::'a) ∈ wf_digraph.branching_points (?G'::('a, 'b) pre_digraph); G = ⦇verts = (?V::'a set) ∪ {?v::'a}, arcs = (?A::'b set) ∪ {?a::'b}, tail = (?t::'b ⇒ 'a)(?a := ?u::'a), head = (?h::'b ⇒ 'a)(?a := ?v)⦈; ?G' = ⦇verts = ?V, arcs = ?A, tail = ?t, head = ?h⦈; wf_digraph ?G'; ?a ∉ ?A⟧ ⟹ ?x ∈ branching_points›*) assms(3-5,9) (*‹G = ⦇verts = V ∪ {v}, arcs = A ∪ {a}, tail = t(a := u), head = h(a := v)⦈› ‹G' = ⦇verts = V, arcs = A, tail = t, head = h⦈› ‹wf_digraph G'› ‹a ∉ A›*) by blast moreover have "¬(∃z ∈ branching_points. z≠y ∧ y →⇧* z)" using new_leaf_not_reach_last_branch (*‹⟦(?y::'a) ∈ wf_digraph.last_branching_points (?G'::('a, 'b) pre_digraph); ¬ ?y →⇧* (?u::'a); G = ⦇verts = (?V::'a set) ∪ {?v::'a}, arcs = (?A::'b set) ∪ {?a::'b}, tail = (?t::'b ⇒ 'a)(?a := ?u), head = (?h::'b ⇒ 'a)(?a := ?v)⦈; ?G' = ⦇verts = ?V, arcs = ?A, tail = ?t, head = ?h⦈; wf_digraph ?G'; ?y ∈ ?V; ?u ∈ ?V; ?v ∉ ?V; ?a ∉ ?A; finite (arcs G)⟧ ⟹ ¬ (∃z::'a∈branching_points. z ≠ ?y ∧ ?y →⇧* z)›*) assms(1,3-10) (*‹(y::'a) ∈ wf_digraph.last_branching_points (G'::('a, 'b) pre_digraph)› ‹G = ⦇verts = (V::'a set) ∪ {v::'a}, arcs = (A::'b set) ∪ {a::'b}, tail = (t::'b ⇒ 'a)(a := u::'a), head = (h::'b ⇒ 'a)(a := v)⦈› ‹G' = ⦇verts = V, arcs = A, tail = t, head = h⦈› ‹wf_digraph G'› ‹y ∈ V› ‹u ∈ V› ‹v ∉ V› ‹a ∉ A› ‹finite (arcs G)›*) False (*‹¬ (y::'a) →⇧* (u::'a)›*) by blast ultimately have "y ∈ last_branching_points" unfolding last_branching_points_def (*goal: ‹y ∈ {x ∈ branching_points. ¬ (∃y∈branching_points. y ≠ x ∧ x →⇧* y)}›*) by blast then show "?thesis" (*goal: ‹thesis›*) using assms(2) (*‹x →⇧* y›*) that (*‹?y'2 ∈ last_branching_points ∧ x →⇧* ?y'2 ⟹ thesis›*) by blast qed end subsection ‹Vertices with Multiple Incoming Arcs› context wf_digraph begin definition merging_points :: "'a set" where "merging_points = {x. ∃y∈arcs G. ∃z∈arcs G. y≠z ∧ head G y = x ∧ head G z = x}" definition is_chain' :: "bool" where "is_chain' = (merging_points = {})" definition last_merging_points :: "'a set" where "last_merging_points = {x. (x∈merging_points ∧ ¬(∃y ∈ merging_points. y≠x ∧ x →⇧* y))}" lemma merge_in_verts: "x ∈ merging_points ⟹ x ∈ verts G" unfolding merging_points_def (*goal: ‹x ∈ {x. ∃y∈arcs G. ∃z∈arcs G. y ≠ z ∧ head G y = x ∧ head G z = x} ⟹ x ∈ verts G›*) by auto lemma last_merge_is_merge: "(y∈last_merging_points ⟹ y∈merging_points)" unfolding last_merging_points_def (*goal: ‹(y::'a) ∈ {x::'a ∈ merging_points. ¬ (∃y::'a∈merging_points. y ≠ x ∧ x →⇧* y)} ⟹ y ∈ merging_points›*) by blast lemma last_merge_alt: "x ∈ last_merging_points ⟹ (∀z. x →⇧* z ∧ z≠x ⟶ z ∉ merging_points)" unfolding last_merging_points_def (*goal: ‹x ∈ {x ∈ merging_points. ¬ (∃y∈merging_points. y ≠ x ∧ x →⇧* y)} ⟹ ∀z. x →⇧* z ∧ z ≠ x ⟶ z ∉ merging_points›*) using reachable_in_verts(2) (*‹?u →⇧* ?v ⟹ ?v ∈ verts G›*) by blast lemma merge_in_supergraph: assumes "subgraph C G" and "x ∈ wf_digraph.merging_points C" shows "x ∈ merging_points" proof (-) (*goal: ‹x ∈ merging_points›*) have 0: "wf_digraph C" using assms(1) (*‹Shortest_Path_Tree.subgraph C G›*) Digraph_Component.subgraph_def (*‹Digraph_Component.subgraph ?H ?G ≡ verts ?H ⊆ verts ?G ∧ arcs ?H ⊆ arcs ?G ∧ wf_digraph ?G ∧ wf_digraph ?H ∧ compatible ?G ?H›*) subgraph.sub_G (*‹Shortest_Path_Tree.subgraph (?T::(?'a, ?'b) pre_digraph) (?G::(?'a, ?'b) pre_digraph) ⟹ Digraph_Component.subgraph ?T ?G›*) by auto have 1: "wf_digraph G" using assms(1) (*‹Shortest_Path_Tree.subgraph C G›*) subgraph.sub_G (*‹Shortest_Path_Tree.subgraph (?T::(?'a, ?'b) pre_digraph) (?G::(?'a, ?'b) pre_digraph) ⟹ Digraph_Component.subgraph ?T ?G›*) by auto obtain y and z where arcs_C: "y∈arcs C ∧ z∈arcs C ∧ y≠z ∧ head C y = x ∧ head C z = x" (*goal: ‹(⋀(y::'b) z::'b. y ∈ arcs (C::('a, 'b) pre_digraph) ∧ z ∈ arcs C ∧ y ≠ z ∧ head C y = (x::'a) ∧ head C z = x ⟹ thesis::bool) ⟹ thesis›*) using assms(2) (*‹x ∈ wf_digraph.merging_points C›*) wf_digraph.merging_points_def (*‹wf_digraph ?G ⟹ wf_digraph.merging_points ?G = {x. ∃y∈arcs ?G. ∃z∈arcs ?G. y ≠ z ∧ head ?G y = x ∧ head ?G z = x}›*) "0" (*‹wf_digraph C›*) by blast then have "y∈arcs G ∧ z∈arcs G ∧ y≠z ∧ head C y = x ∧ head C z = x" using assms(1) (*‹Shortest_Path_Tree.subgraph C G›*) subgraph.sub_G (*‹Shortest_Path_Tree.subgraph ?T ?G ⟹ Digraph_Component.subgraph ?T ?G›*) by blast then have "y∈arcs G ∧ z∈arcs G ∧ y≠z ∧ head G y = x ∧ head G z = x" using assms(1) (*‹Shortest_Path_Tree.subgraph (C::('a, 'b) pre_digraph) G›*) subgraph.sub_G (*‹Shortest_Path_Tree.subgraph ?T ?G ⟹ Digraph_Component.subgraph ?T ?G›*) compatible_def (*‹compatible ?G ?H ≡ tail ?G = tail ?H ∧ head ?G = head ?H›*) by force then show "?thesis" (*goal: ‹x ∈ merging_points›*) using merging_points_def (*‹merging_points = {x. ∃y∈arcs G. ∃z∈arcs G. y ≠ z ∧ head G y = x ∧ head G z = x}›*) assms(1) (*‹Shortest_Path_Tree.subgraph C G›*) subgraph.sub_G (*‹Shortest_Path_Tree.subgraph ?T ?G ⟹ Digraph_Component.subgraph ?T ?G›*) by blast qed lemma subgraph_no_merge_chain: assumes "subgraph C G" and "verts C ⊆ verts G - {x. ∃y∈merging_points. x →⇧*⇘G⇙ y}" shows "wf_digraph.is_chain' C" proof (rule ccontr (*‹(¬ ?P ⟹ False) ⟹ ?P›*)) (*goal: ‹¬ wf_digraph.is_chain' (C::('a, 'b) pre_digraph) ⟹ False›*) assume asm: "¬wf_digraph.is_chain' C" (*‹¬ wf_digraph.is_chain' (C::('a, 'b) pre_digraph)›*) let ?rem = "{x. ∃y∈merging_points. x →⇧*⇘G⇙ y}" have "wf_digraph C" using assms(1) (*‹Shortest_Path_Tree.subgraph (C::('a, 'b) pre_digraph) G›*) Digraph_Component.subgraph_def (*‹Digraph_Component.subgraph ?H ?G ≡ verts ?H ⊆ verts ?G ∧ arcs ?H ⊆ arcs ?G ∧ wf_digraph ?G ∧ wf_digraph ?H ∧ compatible ?G ?H›*) subgraph.sub_G (*‹Shortest_Path_Tree.subgraph ?T ?G ⟹ Digraph_Component.subgraph ?T ?G›*) by auto then obtain x where x_def[simp]: "x ∈ wf_digraph.merging_points C" (*goal: ‹(⋀x. x ∈ wf_digraph.merging_points C ⟹ thesis) ⟹ thesis›*) using wf_digraph.is_chain'_def (*‹wf_digraph ?G ⟹ wf_digraph.is_chain' ?G = (wf_digraph.merging_points ?G = {})›*) asm (*‹¬ wf_digraph.is_chain' (C::('a, 'b) pre_digraph)›*) by blast then have "x ∈ merging_points" using assms(1) (*‹Shortest_Path_Tree.subgraph C G›*) merge_in_supergraph (*‹⟦Shortest_Path_Tree.subgraph ?C G; ?x ∈ wf_digraph.merging_points ?C⟧ ⟹ ?x ∈ merging_points›*) by simp moreover from this (*‹x ∈ merging_points›*) have "x ∈ verts G" using merge_in_verts (*‹?x ∈ merging_points ⟹ ?x ∈ verts G›*) by simp moreover from this (*‹x ∈ verts G›*) have "x →⇧*⇘G⇙ x" by simp ultimately have "x ∈ ?rem" by blast then show False using assms(2) (*‹verts C ⊆ verts G - {x. ∃y∈merging_points. x →⇧* y}›*) ‹wf_digraph C› (*‹wf_digraph C›*) subsetD (*‹⟦?A ⊆ ?B; ?c ∈ ?A⟧ ⟹ ?c ∈ ?B›*) wf_digraph.merge_in_verts (*‹⟦wf_digraph ?G; ?x ∈ wf_digraph.merging_points ?G⟧ ⟹ ?x ∈ verts ?G›*) by fastforce qed end end
{ "path": "afp-2025-02-12/thys/Query_Optimization/Graph_Additions.thy", "repo": "afp-2025-02-12", "sha": "e873af5b9dd5db8f7bc700044a976fbf7fb172216f209ffd782dcabdf771fe37" }
(* File: KD_Tree.thy Author: Martin Rau, TU München *) section "Definition of the ‹k›-d Tree" theory KD_Tree imports Complex_Main "HOL-Analysis.Finite_Cartesian_Product" "HOL-Analysis.Topology_Euclidean_Space" begin text ‹ A ‹k›-d tree is a space-partitioning data structure for organizing points in a ‹k›-dimensional space. In principle the ‹k›-d tree is a binary tree. The leafs hold the ‹k›-dimensional points and the nodes contain left and right subtrees as well as a discriminator ‹v› at a particular axis ‹k›. Every node divides the space into two parts by splitting along a hyperplane. Consider a node ‹n› with associated discriminator ‹v› at axis ‹k›. All points in the left subtree must have a value at axis ‹k› that is less than or equal to ‹v› and all points in the right subtree must have a value at axis ‹k› that is greater than ‹v›. Deviations from the papers: The chosen tree representation is taken from \<^cite>‹"DBLP:journals/toms/FriedmanBF77"› with one minor adjustment. Originally the leafs hold buckets of points of size ‹b›. This representation fixes the bucket size to ‹b = 1›, a single point per Leaf. This is only a minor adjustment since the paper proves that ‹b = 1› is the optimal bucket size for minimizing the running time of the nearest neighbor algorithm \<^cite>‹"DBLP:journals/toms/FriedmanBF77"›, only simplifies building the optimized ‹k›-d trees \<^cite>‹"DBLP:journals/toms/FriedmanBF77"› and has little influence on the search algorithm \<^cite>‹"DBLP:journals/cacm/Bentley75"›. › type_synonym 'k point = "(real, 'k) vec" lemma dist_point_def: fixes p₀ :: "('k::finite) point" shows "dist p₀ p₁ = sqrt (∑k ∈ UNIV. (p₀$k - p₁$k)²)" unfolding dist_vec_def L2_set_def dist_real_def (*goal: ‹sqrt (∑i∈UNIV. ¦p₀ $ i - p₁ $ i¦²) = sqrt (∑k∈UNIV. (p₀ $ k - p₁ $ k)²)›*) by simp datatype 'k kdt = Leaf "'k point" | Node 'k real "'k kdt" "'k kdt" subsection ‹Definition of the ‹k›-d Tree Invariant and Related Functions› fun set_kdt :: "'k kdt ⇒ ('k point) set" where "set_kdt (Leaf p) = { p }" | "set_kdt (Node _ _ l r) = set_kdt l ∪ set_kdt r" definition spread :: "('k::finite) ⇒ 'k point set ⇒ real" where "spread k P = (if P = {} then 0 else let V = (λp. p$k) ` P in Max V - Min V)" definition widest_spread_axis :: "('k::finite) ⇒ 'k set ⇒ 'k point set ⇒ bool" where "widest_spread_axis k K ps ⟷ (∀k' ∈ K. spread k' ps ≤ spread k ps)" fun invar :: "('k::finite) kdt ⇒ bool" where "invar (Leaf p) ⟷ True" | "invar (Node k v l r) ⟷ (∀p ∈ set_kdt l. p$k ≤ v) ∧ (∀p ∈ set_kdt r. v < p$k) ∧ widest_spread_axis k UNIV (set_kdt l ∪ set_kdt r) ∧ invar l ∧ invar r" fun size_kdt :: "'k kdt ⇒ nat" where "size_kdt (Leaf _) = 1" | "size_kdt (Node _ _ l r) = size_kdt l + size_kdt r" fun height :: "'k kdt ⇒ nat" where "height (Leaf _) = 0" | "height (Node _ _ l r) = max (height l) (height r) + 1" fun min_height :: "'k kdt ⇒ nat" where "min_height (Leaf _) = 0" | "min_height (Node _ _ l r) = min (min_height l) (min_height r) + 1" definition balanced :: "'k kdt ⇒ bool" where "balanced kdt ⟷ height kdt - min_height kdt ≤ 1" fun complete :: "'k kdt ⇒ bool" where "complete (Leaf _) = True" | "complete (Node _ _ l r) ⟷ complete l ∧ complete r ∧ height l = height r" lemma invar_l: "invar (Node k v l r) ⟹ invar l" sorry lemma invar_r: "invar (Node k v l r) ⟹ invar r" by simp lemma invar_l_le_k: "invar (Node k v l r) ⟹ ∀p ∈ set_kdt l. p$k ≤ v" by simp lemma invar_r_ge_k: "invar (Node k v l r) ⟹ ∀p ∈ set_kdt r. v < p$k" by simp lemma invar_set: "set_kdt (Node k v l r) = set_kdt l ∪ set_kdt r" by simp subsection ‹Lemmas adapted from ‹HOL-Library.Tree› to ‹k›-d Tree› lemma size_ge0[simp]: "0 < size_kdt kdt" apply (induction kdt) (*goals: 1. ‹⋀x. 0 < KD_Tree.size_kdt (Leaf x)› 2. ‹⋀x1a x2 kdt1 kdt2. ⟦0 < KD_Tree.size_kdt kdt1; 0 < KD_Tree.size_kdt kdt2⟧ ⟹ 0 < KD_Tree.size_kdt (Node x1a x2 kdt1 kdt2)› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . lemma eq_size_1[simp]: "size_kdt kdt = 1 ⟷ (∃p. kdt = Leaf p)" apply (induction kdt) (*goal: ‹(KD_Tree.size_kdt kdt = 1) = (∃p. kdt = Leaf p)›*) apply auto (*top goal: ‹⋀x::(real, 'a) vec. (KD_Tree.size_kdt (Leaf x) = (1::nat)) = (∃p::(real, 'a) vec. Leaf x = Leaf p)› and 1 goal remains*) using size_ge0 (*‹0 < KD_Tree.size_kdt ?kdt›*) nat_less_le (*‹(?m < ?n) = (?m ≤ ?n ∧ ?m ≠ ?n)›*) apply - (*goals: 1. ‹⋀kdt2. ⟦KD_Tree.size_kdt kdt2 = 0; ∀p. kdt2 ≠ Leaf p; ⋀kdt. 0 < KD_Tree.size_kdt kdt; ⋀m n. (m < n) = (m ≤ n ∧ m ≠ n)⟧ ⟹ False› 2. ‹⋀kdt1. ⟦KD_Tree.size_kdt kdt1 = 0; ∀p. kdt1 ≠ Leaf p; ⋀kdt. 0 < KD_Tree.size_kdt kdt; ⋀m n. (m < n) = (m ≤ n ∧ m ≠ n)⟧ ⟹ False› discuss goal 1*) apply blast (*discuss goal 2*) apply blast (*proven 2 subgoals*) . lemma eq_1_size[simp]: "1 = size_kdt kdt ⟷ (∃p. kdt = Leaf p)" using eq_size_1 (*‹(KD_Tree.size_kdt ?kdt = 1) = (∃p. ?kdt = Leaf p)›*) by metis lemma neq_Leaf_iff: "(∄p. kdt = Leaf p) = (∃k v l r. kdt = Node k v l r)" apply (cases kdt) (*goals: 1. ‹⋀x1. kdt = Leaf x1 ⟹ (∄p. kdt = Leaf p) = (∃k v l r. kdt = Node k v l r)› 2. ‹⋀x21 x22 x23 x24. kdt = Node x21 x22 x23 x24 ⟹ (∄p. kdt = Leaf p) = (∃k v l r. kdt = Node k v l r)› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . lemma eq_height_0[simp]: "height kdt = 0 ⟷ (∃p. kdt = Leaf p)" apply (cases kdt) (*goals: 1. ‹⋀x1. kdt = Leaf x1 ⟹ (height kdt = 0) = (∃p. kdt = Leaf p)› 2. ‹⋀x21 x22 x23 x24. kdt = Node x21 x22 x23 x24 ⟹ (height kdt = 0) = (∃p. kdt = Leaf p)› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . lemma eq_0_height[simp]: "0 = height kdt ⟷ (∃p. kdt = Leaf p)" apply (cases kdt) (*goals: 1. ‹⋀x1. kdt = Leaf x1 ⟹ (0 = height kdt) = (∃p. kdt = Leaf p)› 2. ‹⋀x21 x22 x23 x24. kdt = Node x21 x22 x23 x24 ⟹ (0 = height kdt) = (∃p. kdt = Leaf p)› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . lemma eq_min_height_0[simp]: "min_height kdt = 0 ⟷ (∃p. kdt = Leaf p)" apply (cases kdt) (*goals: 1. ‹⋀x1. kdt = Leaf x1 ⟹ (min_height kdt = 0) = (∃p. kdt = Leaf p)› 2. ‹⋀x21 x22 x23 x24. kdt = Node x21 x22 x23 x24 ⟹ (min_height kdt = 0) = (∃p. kdt = Leaf p)› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . lemma eq_0_min_height[simp]: "0 = min_height kdt ⟷ (∃p. kdt = Leaf p)" apply (cases kdt) (*goals: 1. ‹⋀x1. kdt = Leaf x1 ⟹ (0 = min_height kdt) = (∃p. kdt = Leaf p)› 2. ‹⋀x21 x22 x23 x24. kdt = Node x21 x22 x23 x24 ⟹ (0 = min_height kdt) = (∃p. kdt = Leaf p)› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . lemma size_height: "size_kdt kdt ≤ 2 ^ height kdt" proof (induction kdt) (*goals: 1. ‹⋀x. KD_Tree.size_kdt (Leaf x) ≤ 2 ^ height (Leaf x)› 2. ‹⋀x1a x2 kdt1 kdt2. ⟦KD_Tree.size_kdt kdt1 ≤ 2 ^ height kdt1; KD_Tree.size_kdt kdt2 ≤ 2 ^ height kdt2⟧ ⟹ KD_Tree.size_kdt (Node x1a x2 kdt1 kdt2) ≤ 2 ^ height (Node x1a x2 kdt1 kdt2)›*) case (Node k v l r) (*‹KD_Tree.size_kdt l ≤ 2 ^ height l› ‹KD_Tree.size_kdt r ≤ 2 ^ height r›*) show "?case" (*goal: ‹KD_Tree.size_kdt (Node k v l r) ≤ 2 ^ height (Node k v l r)›*) proof (cases "height l ≤ height r") (*goals: 1. ‹height l ≤ height r ⟹ KD_Tree.size_kdt (Node k v l r) ≤ 2 ^ height (Node k v l r)› 2. ‹¬ height l ≤ height r ⟹ KD_Tree.size_kdt (Node k v l r) ≤ 2 ^ height (Node k v l r)›*) case True (*‹height l ≤ height r›*) have "size_kdt (Node k v l r) = size_kdt l + size_kdt r" by simp also (*calculation: ‹KD_Tree.size_kdt (Node k v l r) = KD_Tree.size_kdt l + KD_Tree.size_kdt r›*) have "… ≤ 2 ^ height l + 2 ^ height r" using Node.IH (*‹KD_Tree.size_kdt (l::'a kdt) ≤ (2::nat) ^ height l› ‹KD_Tree.size_kdt r ≤ 2 ^ height r›*) by arith also (*calculation: ‹KD_Tree.size_kdt (Node k v l r) ≤ 2 ^ height l + 2 ^ height r›*) have "… ≤ 2 ^ height r + 2 ^ height r" using True (*‹height l ≤ height r›*) by simp also (*calculation: ‹KD_Tree.size_kdt (Node k v l r) ≤ 2 ^ height r + 2 ^ height r›*) have "… = 2 ^ height (Node k v l r)" using True (*‹height l ≤ height r›*) by (auto simp: max_def (*‹max ?a ?b = (if ?a ≤ ?b then ?b else ?a)›*) mult_2 (*‹2 * ?z = ?z + ?z›*)) finally (*calculation: ‹KD_Tree.size_kdt (Node k v l r) ≤ 2 ^ height (Node k v l r)›*) show "?thesis" (*goal: ‹KD_Tree.size_kdt (Node k v l r) ≤ 2 ^ height (Node k v l r)›*) . next (*goal: ‹¬ height l ≤ height r ⟹ KD_Tree.size_kdt (Node k v l r) ≤ 2 ^ height (Node k v l r)›*) case False (*‹¬ height l ≤ height r›*) have "size_kdt (Node k v l r) = size_kdt l + size_kdt r" by simp also (*calculation: ‹KD_Tree.size_kdt (Node k v l r) = KD_Tree.size_kdt l + KD_Tree.size_kdt r›*) have "… ≤ 2 ^ height l + 2 ^ height r" using Node.IH (*‹KD_Tree.size_kdt l ≤ 2 ^ height l› ‹KD_Tree.size_kdt r ≤ 2 ^ height r›*) by arith also (*calculation: ‹KD_Tree.size_kdt (Node (k::'a::type) (v::real) (l::'a::type kdt) (r::'a::type kdt)) ≤ (2::nat) ^ height l + (2::nat) ^ height r›*) have "… ≤ 2 ^ height l + 2 ^ height l" using False (*‹¬ height l ≤ height r›*) by simp finally (*calculation: ‹KD_Tree.size_kdt (Node k v l r) ≤ 2 ^ height l + 2 ^ height l›*) show "?thesis" (*goal: ‹KD_Tree.size_kdt (Node k v l r) ≤ 2 ^ height (Node k v l r)›*) using False (*‹¬ height l ≤ height r›*) by (auto simp: max_def (*‹max ?a ?b = (if ?a ≤ ?b then ?b else ?a)›*) mult_2 (*‹2 * ?z = ?z + ?z›*)) qed qed (simp) (*solved the remaining goal: ‹⋀x. KD_Tree.size_kdt (Leaf x) ≤ 2 ^ height (Leaf x)›*) lemma min_height_le_height: "min_height kdt ≤ height kdt" apply (induction kdt) (*goals: 1. ‹⋀x. min_height (Leaf x) ≤ height (Leaf x)› 2. ‹⋀x1a x2 kdt1 kdt2. ⟦min_height kdt1 ≤ height kdt1; min_height kdt2 ≤ height kdt2⟧ ⟹ min_height (Node x1a x2 kdt1 kdt2) ≤ height (Node x1a x2 kdt1 kdt2)› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . lemma min_height_size: "2 ^ min_height kdt ≤ size_kdt kdt" proof (induction kdt) (*goals: 1. ‹⋀x. 2 ^ min_height (Leaf x) ≤ KD_Tree.size_kdt (Leaf x)› 2. ‹⋀x1a x2 kdt1 kdt2. ⟦2 ^ min_height kdt1 ≤ KD_Tree.size_kdt kdt1; 2 ^ min_height kdt2 ≤ KD_Tree.size_kdt kdt2⟧ ⟹ 2 ^ min_height (Node x1a x2 kdt1 kdt2) ≤ KD_Tree.size_kdt (Node x1a x2 kdt1 kdt2)›*) case (Node k v l r) (*‹2 ^ min_height l ≤ KD_Tree.size_kdt l› ‹2 ^ min_height r ≤ KD_Tree.size_kdt r›*) have "(2::nat) ^ min_height (Node k v l r) ≤ 2 ^ min_height l + 2 ^ min_height r" by (simp add: min_def (*‹min (?a::?'a::ord) (?b::?'a::ord) = (if ?a ≤ ?b then ?a else ?b)›*)) also (*calculation: ‹2 ^ min_height (Node k v l r) ≤ 2 ^ min_height l + 2 ^ min_height r›*) have "… ≤ size_kdt (Node k v l r)" using Node.IH (*‹2 ^ min_height l ≤ KD_Tree.size_kdt l› ‹2 ^ min_height r ≤ KD_Tree.size_kdt r›*) by simp finally (*calculation: ‹2 ^ min_height (Node k v l r) ≤ KD_Tree.size_kdt (Node k v l r)›*) show "?case" (*goal: ‹(2::nat) ^ min_height (Node (k::'a) (v::real) (l::'a kdt) (r::'a kdt)) ≤ KD_Tree.size_kdt (Node k v l r)›*) . qed (simp) (*solved the remaining goal: ‹⋀x. 2 ^ min_height (Leaf x) ≤ KD_Tree.size_kdt (Leaf x)›*) lemma complete_iff_height: "complete kdt ⟷ (min_height kdt = height kdt)" apply (induction kdt) (*goals: 1. ‹⋀x. KD_Tree.complete (Leaf x) = (min_height (Leaf x) = height (Leaf x))› 2. ‹⋀x1a x2 kdt1 kdt2. ⟦KD_Tree.complete kdt1 = (min_height kdt1 = height kdt1); KD_Tree.complete kdt2 = (min_height kdt2 = height kdt2)⟧ ⟹ KD_Tree.complete (Node x1a x2 kdt1 kdt2) = (min_height (Node x1a x2 kdt1 kdt2) = height (Node x1a x2 kdt1 kdt2))› discuss goal 1*) apply simp (*discuss goal 2*) apply (simp add: 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)›*)) (*goal: ‹⋀x1a x2 kdt1 kdt2. ⟦KD_Tree.complete kdt1 = (min_height kdt1 = height kdt1); KD_Tree.complete kdt2 = (min_height kdt2 = height kdt2)⟧ ⟹ KD_Tree.complete (Node x1a x2 kdt1 kdt2) = (min_height (Node x1a x2 kdt1 kdt2) = height (Node x1a x2 kdt1 kdt2))›*) apply (metis le_antisym (*‹⟦(?m::nat) ≤ (?n::nat); ?n ≤ ?m⟧ ⟹ ?m = ?n›*) le_trans (*‹⟦(?i::nat) ≤ (?j::nat); ?j ≤ (?k::nat)⟧ ⟹ ?i ≤ ?k›*) min_height_le_height (*‹min_height (?kdt::?'a kdt) ≤ height ?kdt›*)) (*proven 2 subgoals*) . lemma size_if_complete: "complete kdt ⟹ size_kdt kdt = 2 ^ height kdt" apply (induction kdt) (*goals: 1. ‹⋀x. KD_Tree.complete (Leaf x) ⟹ KD_Tree.size_kdt (Leaf x) = 2 ^ height (Leaf x)› 2. ‹⋀x1a x2 kdt1 kdt2. ⟦KD_Tree.complete kdt1 ⟹ KD_Tree.size_kdt kdt1 = 2 ^ height kdt1; KD_Tree.complete kdt2 ⟹ KD_Tree.size_kdt kdt2 = 2 ^ height kdt2; KD_Tree.complete (Node x1a x2 kdt1 kdt2)⟧ ⟹ KD_Tree.size_kdt (Node x1a x2 kdt1 kdt2) = 2 ^ height (Node x1a x2 kdt1 kdt2)› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . lemma complete_if_size_height: "size_kdt kdt = 2 ^ height kdt ⟹ complete kdt" proof (induction "height kdt" arbitrary: kdt) (*goals: 1. ‹⋀kdt. ⟦0 = height kdt; KD_Tree.size_kdt kdt = 2 ^ height kdt⟧ ⟹ KD_Tree.complete kdt› 2. ‹⋀x kdt. ⟦⋀kdt. ⟦x = height kdt; KD_Tree.size_kdt kdt = 2 ^ height kdt⟧ ⟹ KD_Tree.complete kdt; Suc x = height kdt; KD_Tree.size_kdt kdt = 2 ^ height kdt⟧ ⟹ KD_Tree.complete kdt›*) case 0 (*‹(0::nat) = height (kdt::'a::type kdt)› ‹KD_Tree.size_kdt kdt = 2 ^ height kdt›*) thus "?case" (*goal: ‹KD_Tree.complete kdt›*) by auto next (*goal: ‹⋀x kdt. ⟦⋀kdt. ⟦x = height kdt; KD_Tree.size_kdt kdt = 2 ^ height kdt⟧ ⟹ KD_Tree.complete kdt; Suc x = height kdt; KD_Tree.size_kdt kdt = 2 ^ height kdt⟧ ⟹ KD_Tree.complete kdt›*) case (Suc h) (*‹⟦(h::nat) = height (?kdt::'a::type kdt); KD_Tree.size_kdt ?kdt = (2::nat) ^ height ?kdt⟧ ⟹ KD_Tree.complete ?kdt› ‹Suc h = height kdt› ‹KD_Tree.size_kdt kdt = 2 ^ height kdt›*) hence "∄p. kdt = Leaf p" by auto then obtain k and v and l and r where [simp]: "kdt = Node k v l r" (*goal: ‹(⋀k v l r. kdt = Node k v l r ⟹ thesis) ⟹ thesis›*) using neq_Leaf_iff (*‹(∄p::(real, ?'a) vec. (?kdt::?'a kdt) = Leaf p) = (∃(k::?'a) (v::real) (l::?'a kdt) r::?'a kdt. ?kdt = Node k v l r)›*) by metis have 1: "height l ≤ h" and 2: "height r ≤ h" using Suc(2) (*‹Suc (h::nat) = height (kdt::'a kdt)›*) apply - (*goals: 1. ‹Suc h = height kdt ⟹ height l ≤ h› 2. ‹Suc h = height kdt ⟹ height r ≤ h› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . have 3: "¬ height l < h" proof (standard) (*goal: ‹height l < h ⟹ False›*) assume 0: "height l < h" (*‹height (l::'a kdt) < (h::nat)›*) have "size_kdt kdt = size_kdt l + size_kdt r" by simp also (*calculation: ‹KD_Tree.size_kdt kdt = KD_Tree.size_kdt l + KD_Tree.size_kdt r›*) have "… ≤ 2 ^ height l + 2 ^ height r" using size_height[of l] (*‹KD_Tree.size_kdt l ≤ 2 ^ height l›*) size_height[of r] (*‹KD_Tree.size_kdt r ≤ 2 ^ height r›*) by arith also (*calculation: ‹KD_Tree.size_kdt kdt ≤ 2 ^ height l + 2 ^ height r›*) have " … < 2 ^ h + 2 ^ height r" using "0" (*‹height l < h›*) by simp also (*calculation: ‹KD_Tree.size_kdt (kdt::'a::type kdt) < (2::nat) ^ (h::nat) + (2::nat) ^ height (r::'a::type kdt)›*) have " … ≤ 2 ^ h + 2 ^ h" using "2" (*‹height r ≤ h›*) by simp also (*calculation: ‹KD_Tree.size_kdt kdt < 2 ^ h + 2 ^ h›*) have "… = 2 ^ (Suc h)" by simp also (*calculation: ‹KD_Tree.size_kdt kdt < 2 ^ Suc h›*) have "… = size_kdt kdt" using Suc(2,3) (*‹Suc h = height kdt› ‹KD_Tree.size_kdt (kdt::'a kdt) = (2::nat) ^ height kdt›*) by simp finally (*calculation: ‹KD_Tree.size_kdt kdt < KD_Tree.size_kdt kdt›*) have "size_kdt kdt < size_kdt kdt" . thus False by simp qed have 4: "¬ height r < h" proof (standard) (*goal: ‹height (r::'a::type kdt) < (h::nat) ⟹ False›*) assume 0: "height r < h" (*‹height (r::'a kdt) < (h::nat)›*) have "size_kdt kdt = size_kdt l + size_kdt r" by simp also (*calculation: ‹KD_Tree.size_kdt kdt = KD_Tree.size_kdt l + KD_Tree.size_kdt r›*) have "… ≤ 2 ^ height l + 2 ^ height r" using size_height[of l] (*‹KD_Tree.size_kdt l ≤ 2 ^ height l›*) size_height[of r] (*‹KD_Tree.size_kdt r ≤ 2 ^ height r›*) by arith also (*calculation: ‹KD_Tree.size_kdt kdt ≤ 2 ^ height l + 2 ^ height r›*) have " … < 2 ^ height l + 2 ^ h" using "0" (*‹height r < h›*) by simp also (*calculation: ‹KD_Tree.size_kdt kdt < 2 ^ height l + 2 ^ h›*) have " … ≤ 2 ^ h + 2 ^ h" using "1" (*‹height l ≤ h›*) by simp also (*calculation: ‹KD_Tree.size_kdt (kdt::'a kdt) < (2::nat) ^ (h::nat) + (2::nat) ^ h›*) have "… = 2 ^ (Suc h)" by simp also (*calculation: ‹KD_Tree.size_kdt (kdt::'a kdt) < (2::nat) ^ Suc (h::nat)›*) have "… = size_kdt kdt" using Suc(2,3) (*‹Suc (h::nat) = height (kdt::'a kdt)› ‹KD_Tree.size_kdt kdt = 2 ^ height kdt›*) by simp finally (*calculation: ‹KD_Tree.size_kdt kdt < KD_Tree.size_kdt kdt›*) have "size_kdt kdt < size_kdt kdt" . thus False by simp qed from "1" (*‹height l ≤ h›*) "2" (*‹height r ≤ h›*) "3" (*‹¬ height l < h›*) "4" (*‹¬ height r < h›*) have "*": "height l = h" "height r = h" apply - (*goals: 1. ‹⟦height (l::'a kdt) ≤ (h::nat); height (r::'a kdt) ≤ h; ¬ height l < h; ¬ height r < h⟧ ⟹ height l = h› 2. ‹⟦height (l::'a kdt) ≤ (h::nat); height (r::'a kdt) ≤ h; ¬ height l < h; ¬ height r < h⟧ ⟹ height r = h› discuss goal 1*) apply linarith (*discuss goal 2*) apply linarith (*proven 2 subgoals*) . hence "size_kdt l = 2 ^ height l" "size_kdt r = 2 ^ height r" using Suc(3) (*‹KD_Tree.size_kdt kdt = 2 ^ height kdt›*) size_height[of l] (*‹KD_Tree.size_kdt l ≤ 2 ^ height l›*) size_height[of r] (*‹KD_Tree.size_kdt r ≤ 2 ^ height r›*) apply - (*goals: 1. ‹⟦height l = h; height r = h; KD_Tree.size_kdt kdt = 2 ^ height kdt; KD_Tree.size_kdt l ≤ 2 ^ height l; KD_Tree.size_kdt r ≤ 2 ^ height r⟧ ⟹ KD_Tree.size_kdt l = 2 ^ height l› 2. ‹⟦height l = h; height r = h; KD_Tree.size_kdt kdt = 2 ^ height kdt; KD_Tree.size_kdt l ≤ 2 ^ height l; KD_Tree.size_kdt r ≤ 2 ^ height r⟧ ⟹ KD_Tree.size_kdt r = 2 ^ height r› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . with "*" (*‹height l = h› ‹height r = h›*) Suc(1) (*‹⟦(h::nat) = height (?kdt::'a kdt); KD_Tree.size_kdt ?kdt = (2::nat) ^ height ?kdt⟧ ⟹ KD_Tree.complete ?kdt›*) show "?case" (*goal: ‹KD_Tree.complete kdt›*) by simp qed lemma complete_if_size_min_height: "size_kdt kdt = 2 ^ min_height kdt ⟹ complete kdt" proof (induct "min_height kdt" arbitrary: kdt) case 0 thus ?case by auto next case (Suc h) hence "∄p. kdt = Leaf p" by auto then obtain k v l r where [simp]: "kdt = Node k v l r" using neq_Leaf_iff by metis have 1: "h ≤ min_height l" and 2: "h ≤ min_height r" using Suc(2) by (auto) have 3: "¬ h < min_height l" proof assume 0: "h < min_height l" have "size_kdt kdt = size_kdt l + size_kdt r" by simp also note min_height_size[of l] also(xtrans) note min_height_size[of r] also(xtrans) have "(2::nat) ^ min_height l > 2 ^ h" using 0 by (simp add: diff_less_mono) also(xtrans) have "(2::nat) ^ min_height r ≥ 2 ^ h" using 2 by simp also(xtrans) have "(2::nat) ^ h + 2 ^ h = 2 ^ (Suc h)" by (simp) also have "… = size_kdt kdt" using Suc(2,3) by simp finally show False by (simp add: diff_le_mono) qed have 4: "¬ h < min_height r" proof assume 0: "h < min_height r" have "size_kdt kdt = size_kdt l + size_kdt r" by simp also note min_height_size[of l] also(xtrans) note min_height_size[of r] also(xtrans) have "(2::nat) ^ min_height r > 2 ^ h" using 0 by (simp add: diff_less_mono) also(xtrans) have "(2::nat) ^ min_height l ≥ 2 ^ h" using 1 by simp also(xtrans) have "(2::nat) ^ h + 2 ^ h = 2 ^ (Suc h)" by (simp) also have "… = size_kdt kdt" using Suc(2,3) by simp finally show False by (simp add: diff_le_mono) qed from 1 2 3 4 have *: "min_height l = h" "min_height r = h" by linarith+ hence "size_kdt l = 2 ^ min_height l" "size_kdt r = 2 ^ min_height r" using Suc(3) min_height_size[of l] min_height_size[of r] by (auto) with * Suc(1) show ?case by (simp add: complete_iff_height) qed lemma complete_iff_size: "complete kdt ⟷ size_kdt kdt = 2 ^ height kdt" using complete_if_size_height (*‹KD_Tree.size_kdt ?kdt = 2 ^ height ?kdt ⟹ KD_Tree.complete ?kdt›*) size_if_complete (*‹KD_Tree.complete ?kdt ⟹ KD_Tree.size_kdt ?kdt = 2 ^ height ?kdt›*) by blast lemma size_height_if_incomplete: "¬ complete kdt ⟹ size_kdt kdt < 2 ^ height kdt" by (meson antisym_conv (*‹?y ≤ ?x ⟹ (?x ≤ ?y) = (?x = ?y)›*) complete_iff_size (*‹KD_Tree.complete ?kdt = (KD_Tree.size_kdt ?kdt = 2 ^ height ?kdt)›*) not_le (*‹(¬ ?x ≤ ?y) = (?y < ?x)›*) size_height (*‹KD_Tree.size_kdt ?kdt ≤ 2 ^ height ?kdt›*)) lemma min_height_size_if_incomplete: "¬ complete kdt ⟹ 2 ^ min_height kdt < size_kdt kdt" by (metis complete_if_size_min_height (*‹KD_Tree.size_kdt ?kdt = 2 ^ min_height ?kdt ⟹ KD_Tree.complete ?kdt›*) le_less (*‹(?x ≤ ?y) = (?x < ?y ∨ ?x = ?y)›*) min_height_size (*‹2 ^ min_height ?kdt ≤ KD_Tree.size_kdt ?kdt›*)) lemma balanced_subtreeL: "balanced (Node k v l r) ⟹ balanced l" by (simp add: balanced_def (*‹balanced ?kdt = (height ?kdt - min_height ?kdt ≤ 1)›*)) lemma balanced_subtreeR: "balanced (Node k v l r) ⟹ balanced r" by (simp add: balanced_def (*‹balanced ?kdt = (height ?kdt - min_height ?kdt ≤ 1)›*)) lemma balanced_optimal: assumes "balanced kdt" "size_kdt kdt ≤ size_kdt kdt'" shows "height kdt ≤ height kdt'" proof (cases "complete kdt") (*goals: 1. ‹KD_Tree.complete (kdt::'a kdt) ⟹ height kdt ≤ height (kdt'::'b kdt)› 2. ‹¬ KD_Tree.complete (kdt::'a kdt) ⟹ height kdt ≤ height (kdt'::'b kdt)›*) case True (*‹KD_Tree.complete kdt›*) have "(2::nat) ^ height kdt ≤ 2 ^ height kdt'" proof (-) (*goal: ‹(2::nat) ^ height (kdt::'a kdt) ≤ (2::nat) ^ height (kdt'::'b kdt)›*) have "2 ^ height kdt = size_kdt kdt" using True (*‹KD_Tree.complete kdt›*) by (simp add: complete_iff_height (*‹KD_Tree.complete (?kdt::?'a::type kdt) = (min_height ?kdt = height ?kdt)›*) size_if_complete (*‹KD_Tree.complete (?kdt::?'a::type kdt) ⟹ KD_Tree.size_kdt ?kdt = (2::nat) ^ height ?kdt›*)) also (*calculation: ‹(2::nat) ^ height (kdt::'a::type kdt) = KD_Tree.size_kdt kdt›*) have "… ≤ size_kdt kdt'" using assms(2) (*‹KD_Tree.size_kdt kdt ≤ KD_Tree.size_kdt kdt'›*) by simp also (*calculation: ‹2 ^ height kdt ≤ KD_Tree.size_kdt kdt'›*) have "… ≤ 2 ^ height kdt'" by (rule size_height (*‹KD_Tree.size_kdt (?kdt::?'a kdt) ≤ (2::nat) ^ height ?kdt›*)) finally (*calculation: ‹2 ^ height kdt ≤ 2 ^ height kdt'›*) show "?thesis" (*goal: ‹2 ^ height kdt ≤ 2 ^ height kdt'›*) . qed thus "?thesis" (*goal: ‹height kdt ≤ height kdt'›*) by simp next (*goal: ‹¬ KD_Tree.complete kdt ⟹ height kdt ≤ height kdt'›*) case False (*‹¬ KD_Tree.complete kdt›*) have "(2::nat) ^ min_height kdt < 2 ^ height kdt'" proof (-) (*goal: ‹2 ^ min_height kdt < 2 ^ height kdt'›*) have "(2::nat) ^ min_height kdt < size_kdt kdt" by (rule min_height_size_if_incomplete[OF False] (*‹2 ^ min_height kdt < KD_Tree.size_kdt kdt›*)) also (*calculation: ‹2 ^ min_height kdt < KD_Tree.size_kdt kdt›*) have "… ≤ size_kdt kdt'" using assms(2) (*‹KD_Tree.size_kdt kdt ≤ KD_Tree.size_kdt kdt'›*) by simp also (*calculation: ‹2 ^ min_height kdt < KD_Tree.size_kdt kdt'›*) have "… ≤ 2 ^ height kdt'" by (rule size_height (*‹KD_Tree.size_kdt ?kdt ≤ 2 ^ height ?kdt›*)) finally (*calculation: ‹2 ^ min_height kdt < 2 ^ height kdt'›*) have "(2::nat) ^ min_height kdt < (2::nat) ^ height kdt'" . thus "?thesis" (*goal: ‹2 ^ min_height kdt < 2 ^ height kdt'›*) . qed hence "*": "min_height kdt < height kdt'" by simp have "min_height kdt + 1 = height kdt" using min_height_le_height[of kdt] (*‹min_height kdt ≤ height kdt›*) assms(1) (*‹balanced kdt›*) False (*‹¬ KD_Tree.complete kdt›*) by (simp add: complete_iff_height (*‹KD_Tree.complete ?kdt = (min_height ?kdt = height ?kdt)›*) balanced_def (*‹balanced ?kdt = (height ?kdt - min_height ?kdt ≤ 1)›*)) with "*" (*‹min_height kdt < height kdt'›*) show "?thesis" (*goal: ‹height kdt ≤ height kdt'›*) by arith qed subsection ‹Lemmas adapted from ‹HOL-Library.Tree_Real› to ‹k›-d Tree› lemma size_height_log: "log 2 (size_kdt kdt) ≤ height kdt" by (simp add: log2_of_power_le (*‹⟦(?m::nat) ≤ (2::nat) ^ (?n::nat); (0::nat) < ?m⟧ ⟹ log (2::real) (real ?m) ≤ real ?n›*) size_height (*‹KD_Tree.size_kdt (?kdt::?'a::type kdt) ≤ (2::nat) ^ height ?kdt›*)) lemma min_height_size_log: "min_height kdt ≤ log 2 (size_kdt kdt)" by (simp add: le_log2_of_power (*‹2 ^ ?n ≤ ?m ⟹ real ?n ≤ log 2 (real ?m)›*) min_height_size (*‹2 ^ min_height ?kdt ≤ KD_Tree.size_kdt ?kdt›*)) lemma size_log_if_complete: "complete kdt ⟹ height kdt = log 2 (size_kdt kdt)" using complete_iff_size (*‹KD_Tree.complete ?kdt = (KD_Tree.size_kdt ?kdt = 2 ^ height ?kdt)›*) log2_of_power_eq (*‹?m = 2 ^ ?n ⟹ real ?n = log 2 (real ?m)›*) by blast lemma min_height_size_log_if_incomplete: "¬ complete kdt ⟹ min_height kdt < log 2 (size_kdt kdt)" by (simp add: less_log2_of_power (*‹2 ^ ?n < ?m ⟹ real ?n < log 2 (real ?m)›*) min_height_size_if_incomplete (*‹¬ KD_Tree.complete ?kdt ⟹ 2 ^ min_height ?kdt < KD_Tree.size_kdt ?kdt›*)) lemma min_height_balanced: assumes "balanced kdt" shows "min_height kdt = nat(floor(log 2 (size_kdt kdt)))" proof (cases) (*goals: 1. ‹?P ⟹ min_height kdt = nat ⌊log 2 (real (KD_Tree.size_kdt kdt))⌋› 2. ‹¬ ?P ⟹ min_height kdt = nat ⌊log 2 (real (KD_Tree.size_kdt kdt))⌋›*) assume "*": "complete kdt" (*‹KD_Tree.complete (kdt::'a kdt)›*) hence "size_kdt kdt = 2 ^ min_height kdt" by (simp add: complete_iff_height (*‹KD_Tree.complete ?kdt = (min_height ?kdt = height ?kdt)›*) size_if_complete (*‹KD_Tree.complete ?kdt ⟹ KD_Tree.size_kdt ?kdt = 2 ^ height ?kdt›*)) from log2_of_power_eq[OF this] (*‹real (min_height kdt) = log 2 (real (KD_Tree.size_kdt kdt))›*) show "?thesis" (*goal: ‹min_height kdt = nat ⌊log 2 (real (KD_Tree.size_kdt kdt))⌋›*) by linarith next (*goal: ‹¬ KD_Tree.complete kdt ⟹ min_height kdt = nat ⌊log 2 (real (KD_Tree.size_kdt kdt))⌋›*) assume "*": "¬ complete kdt" (*‹¬ KD_Tree.complete (kdt::'a kdt)›*) hence "height kdt = min_height kdt + 1" using assms (*‹balanced kdt›*) min_height_le_height[of kdt] (*‹min_height kdt ≤ height kdt›*) by (auto simp add: balanced_def (*‹balanced ?kdt = (height ?kdt - min_height ?kdt ≤ 1)›*) complete_iff_height (*‹KD_Tree.complete ?kdt = (min_height ?kdt = height ?kdt)›*)) hence "size_kdt kdt < 2 ^ (min_height kdt + 1)" by (metis * (*‹¬ KD_Tree.complete kdt›*) size_height_if_incomplete (*‹¬ KD_Tree.complete ?kdt ⟹ KD_Tree.size_kdt ?kdt < 2 ^ height ?kdt›*)) hence "log 2 (size_kdt kdt) < min_height kdt + 1" using log2_of_power_less (*‹⟦?m < 2 ^ ?n; 0 < ?m⟧ ⟹ log 2 (real ?m) < real ?n›*) size_ge0 (*‹0 < KD_Tree.size_kdt ?kdt›*) by blast thus "?thesis" (*goal: ‹min_height (kdt::'a kdt) = nat ⌊log (2::real) (real (KD_Tree.size_kdt kdt))⌋›*) using min_height_size_log[of kdt] (*‹real (min_height kdt) ≤ log 2 (real (KD_Tree.size_kdt kdt))›*) by linarith qed lemma height_balanced: assumes "balanced kdt" shows "height kdt = nat(ceiling(log 2 (size_kdt kdt)))" proof (cases) (*goals: 1. ‹?P::bool ⟹ height (kdt::'a::type kdt) = nat ⌈log (2::real) (real (KD_Tree.size_kdt kdt))⌉› 2. ‹¬ (?P::bool) ⟹ height (kdt::'a::type kdt) = nat ⌈log (2::real) (real (KD_Tree.size_kdt kdt))⌉›*) assume "*": "complete kdt" (*‹KD_Tree.complete (kdt::'a kdt)›*) hence "size_kdt kdt = 2 ^ height kdt" by (simp add: size_if_complete (*‹KD_Tree.complete ?kdt ⟹ KD_Tree.size_kdt ?kdt = 2 ^ height ?kdt›*)) from log2_of_power_eq[OF this] (*‹real (height kdt) = log 2 (real (KD_Tree.size_kdt kdt))›*) show "?thesis" (*goal: ‹height kdt = nat ⌈log 2 (real (KD_Tree.size_kdt kdt))⌉›*) by linarith next (*goal: ‹¬ KD_Tree.complete kdt ⟹ height kdt = nat ⌈log 2 (real (KD_Tree.size_kdt kdt))⌉›*) assume "*": "¬ complete kdt" (*‹¬ KD_Tree.complete (kdt::'a kdt)›*) hence "**": "height kdt = min_height kdt + 1" using assms (*‹balanced kdt›*) min_height_le_height[of kdt] (*‹min_height (kdt::'a kdt) ≤ height kdt›*) by (auto simp add: balanced_def (*‹balanced ?kdt = (height ?kdt - min_height ?kdt ≤ 1)›*) complete_iff_height (*‹KD_Tree.complete ?kdt = (min_height ?kdt = height ?kdt)›*)) hence "size_kdt kdt ≤ 2 ^ (min_height kdt + 1)" by (metis size_height (*‹KD_Tree.size_kdt ?kdt ≤ 2 ^ height ?kdt›*)) from log2_of_power_le[OF this size_ge0] (*‹log 2 (real (KD_Tree.size_kdt kdt)) ≤ real (min_height kdt + 1)›*) min_height_size_log_if_incomplete[OF *] (*‹real (min_height kdt) < log 2 (real (KD_Tree.size_kdt kdt))›*) "**" (*‹height kdt = min_height kdt + 1›*) show "?thesis" (*goal: ‹height kdt = nat ⌈log 2 (real (KD_Tree.size_kdt kdt))⌉›*) by linarith qed lemma balanced_Node_if_wbal1: assumes "balanced l" "balanced r" "size_kdt l = size_kdt r + 1" shows "balanced (Node k v l r)" proof (-) (*goal: ‹balanced (Node k v l r)›*) from assms(3) (*‹KD_Tree.size_kdt l = KD_Tree.size_kdt r + 1›*) have [simp]: "size_kdt l = size_kdt r + 1" by simp have "nat ⌈log 2 (1 + size_kdt r)⌉ ≥ nat ⌈log 2 (size_kdt r)⌉" apply (rule nat_mono[OF ceiling_mono] (*‹?y1 ≤ ?x1 ⟹ nat ⌈?y1⌉ ≤ nat ⌈?x1⌉›*)) (*goal: ‹nat ⌈log 2 (real (KD_Tree.size_kdt r))⌉ ≤ nat ⌈log 2 (real (1 + KD_Tree.size_kdt r))⌉›*) by simp hence 1: "height(Node k v l r) = nat ⌈log 2 (1 + size_kdt r)⌉ + 1" using height_balanced[OF assms ( 1 )] (*‹height l = nat ⌈log 2 (real (KD_Tree.size_kdt l))⌉›*) height_balanced[OF assms ( 2 )] (*‹height r = nat ⌈log 2 (real (KD_Tree.size_kdt r))⌉›*) by (simp del: nat_ceiling_le_eq (*‹(nat ⌈?x⌉ ≤ ?a) = (?x ≤ real ?a)›*) add: max_def (*‹max ?a ?b = (if ?a ≤ ?b then ?b else ?a)›*)) have "nat ⌊log 2 (1 + size_kdt r)⌋ ≥ nat ⌊log 2 (size_kdt r)⌋" apply (rule nat_mono[OF floor_mono] (*‹?x1 ≤ ?y1 ⟹ nat ⌊?x1⌋ ≤ nat ⌊?y1⌋›*)) (*goal: ‹nat ⌊log 2 (real (KD_Tree.size_kdt r))⌋ ≤ nat ⌊log 2 (real (1 + KD_Tree.size_kdt r))⌋›*) by simp hence 2: "min_height(Node k v l r) = nat ⌊log 2 (size_kdt r)⌋ + 1" using min_height_balanced[OF assms ( 1 )] (*‹min_height l = nat ⌊log 2 (real (KD_Tree.size_kdt l))⌋›*) min_height_balanced[OF assms ( 2 )] (*‹min_height (r::'a kdt) = nat ⌊log (2::real) (real (KD_Tree.size_kdt r))⌋›*) by simp have "size_kdt r ≥ 1" by (simp add: Suc_leI (*‹?m < ?n ⟹ Suc ?m ≤ ?n›*)) then obtain i where i: "2 ^ i ≤ size_kdt r" "size_kdt r < 2 ^ (i + 1)" (*goal: ‹(⋀i. ⟦2 ^ i ≤ KD_Tree.size_kdt r; KD_Tree.size_kdt r < 2 ^ (i + 1)⟧ ⟹ thesis) ⟹ thesis›*) using ex_power_ivl1[of 2 "size_kdt r"] (*‹⟦(2::nat) ≤ (2::nat); (1::nat) ≤ KD_Tree.size_kdt (r::'a kdt)⟧ ⟹ ∃n::nat. (2::nat) ^ n ≤ KD_Tree.size_kdt r ∧ KD_Tree.size_kdt r < (2::nat) ^ (n + (1::nat))›*) by auto hence i1: "2 ^ i < size_kdt r + 1" "size_kdt r + 1 ≤ 2 ^ (i + 1)" apply - (*goals: 1. ‹⟦2 ^ i ≤ KD_Tree.size_kdt r; KD_Tree.size_kdt r < 2 ^ (i + 1)⟧ ⟹ 2 ^ i < KD_Tree.size_kdt r + 1› 2. ‹⟦2 ^ i ≤ KD_Tree.size_kdt r; KD_Tree.size_kdt r < 2 ^ (i + 1)⟧ ⟹ KD_Tree.size_kdt r + 1 ≤ 2 ^ (i + 1)› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . from "1" (*‹height (Node k v l r) = nat ⌈log 2 (real (1 + KD_Tree.size_kdt r))⌉ + 1›*) "2" (*‹min_height (Node k v l r) = nat ⌊log 2 (real (KD_Tree.size_kdt r))⌋ + 1›*) floor_log_nat_eq_if[OF i] (*‹2 ≤ 2 ⟹ ⌊log (real 2) (real (KD_Tree.size_kdt r))⌋ = int i›*) ceiling_log_nat_eq_if[OF i1] (*‹(2::nat) ≤ (2::nat) ⟹ ⌈log (real (2::nat)) (real (KD_Tree.size_kdt (r::'a::type kdt) + (1::nat)))⌉ = int (i::nat) + (1::int)›*) show "?thesis" (*goal: ‹balanced (Node k v l r)›*) by (simp add:balanced_def (*‹balanced ?kdt = (height ?kdt - min_height ?kdt ≤ 1)›*)) qed lemma balanced_sym: "balanced (Node k v l r) ⟹ balanced (Node k' v' r l)" by (auto simp: balanced_def (*‹balanced ?kdt = (height ?kdt - min_height ?kdt ≤ 1)›*)) lemma balanced_Node_if_wbal2: assumes "balanced l" "balanced r" "abs(int(size_kdt l) - int(size_kdt r)) ≤ 1" shows "balanced (Node k v l r)" proof (-) (*goal: ‹balanced (Node k v l r)›*) have "size_kdt l = size_kdt r ∨ (size_kdt l = size_kdt r + 1 ∨ size_kdt r = size_kdt l + 1)" (is "?A ∨ ?B") using assms(3) (*‹¦int (KD_Tree.size_kdt l) - int (KD_Tree.size_kdt r)¦ ≤ 1›*) by linarith thus "?thesis" (*goal: ‹balanced (Node k v l r)›*) proof (standard) (*goals: 1. ‹KD_Tree.size_kdt (l::'a::type kdt) = KD_Tree.size_kdt (r::'a::type kdt) ⟹ balanced (Node (k::'a::type) (v::real) l r)› 2. ‹KD_Tree.size_kdt (l::'a::type kdt) = KD_Tree.size_kdt (r::'a::type kdt) + (1::nat) ∨ KD_Tree.size_kdt r = KD_Tree.size_kdt l + (1::nat) ⟹ balanced (Node (k::'a::type) (v::real) l r)›*) assume "?A" (*‹KD_Tree.size_kdt (l::'a kdt) = KD_Tree.size_kdt (r::'a kdt)›*) thus "?thesis" (*goal: ‹balanced (Node k v l r)›*) using assms(1,2) (*‹balanced l› ‹balanced r›*) apply (simp add: balanced_def (*‹balanced ?kdt = (height ?kdt - min_height ?kdt ≤ 1)›*) min_def (*‹min ?a ?b = (if ?a ≤ ?b then ?a else ?b)›*) max_def (*‹max ?a ?b = (if ?a ≤ ?b then ?b else ?a)›*)) (*goal: ‹balanced (Node k v l r)›*) by (metis assms( (*‹balanced l› ‹balanced r›*) 1,2) balanced_optimal (*‹⟦balanced ?kdt; KD_Tree.size_kdt ?kdt ≤ KD_Tree.size_kdt ?kdt'⟧ ⟹ height ?kdt ≤ height ?kdt'›*) le_antisym (*‹⟦?m ≤ ?n; ?n ≤ ?m⟧ ⟹ ?m = ?n›*) le_less (*‹(?x ≤ ?y) = (?x < ?y ∨ ?x = ?y)›*)) next (*goal: ‹KD_Tree.size_kdt l = KD_Tree.size_kdt r + 1 ∨ KD_Tree.size_kdt r = KD_Tree.size_kdt l + 1 ⟹ balanced (Node k v l r)›*) assume "?B" (*‹KD_Tree.size_kdt (l::'a kdt) = KD_Tree.size_kdt (r::'a kdt) + (1::nat) ∨ KD_Tree.size_kdt r = KD_Tree.size_kdt l + (1::nat)›*) thus "?thesis" (*goal: ‹balanced (Node k v l r)›*) by (meson assms( (*‹balanced l› ‹balanced r›*) 1,2) balanced_sym (*‹balanced (Node ?k ?v ?l ?r) ⟹ balanced (Node ?k' ?v' ?r ?l)›*) balanced_Node_if_wbal1 (*‹⟦balanced ?l; balanced ?r; KD_Tree.size_kdt ?l = KD_Tree.size_kdt ?r + 1⟧ ⟹ balanced (Node ?k ?v ?l ?r)›*)) qed qed end
{ "path": "afp-2025-02-12/thys/KD_Tree/KD_Tree.thy", "repo": "afp-2025-02-12", "sha": "51ebf26b2462b9dfcfac404b1477d1051e16c41c88e74120442d5857325d6369" }
section‹Separative notions and proper extensions› theory Proper_Extension imports Names begin text‹The key ingredient to obtain a proper extension is to have a ∗‹separative preorder›:› locale separative_notion = forcing_notion + assumes separative: "p∈P ⟹ ∃q∈P. ∃r∈P. q ≼ p ∧ r ≼ p ∧ q ⊥ r" begin text‹For separative preorders, the complement of every filter is dense. Hence an $M$-generic filter can't belong to the ground model.› lemma filter_complement_dense: assumes "filter(G)" shows "dense(P - G)" proof (standard) (*goal: ‹⋀p. p ∈ P ⟹ ∃d∈P - G. d ≼ p›*) fix p assume "p∈P" (*‹(p::i) ∈ (P::i)›*) show "∃d∈P - G. d ≼ p" proof (cases "p∈G") (*goals: 1. ‹(p::i) ∈ (G::i) ⟹ ∃d::i∈(P::i) - G. d ≼ p› 2. ‹(p::i) ∉ (G::i) ⟹ ∃d::i∈(P::i) - G. d ≼ p›*) case True (*‹p ∈ G›*) note ‹p∈P› (*‹(p::i) ∈ (P::i)›*) assms (*‹local.filter(G)›*) moreover obtain q and r where "q ≼ p" "r ≼ p" "q ⊥ r" "q∈P" "r∈P" (*goal: ‹(⋀q r. ⟦q ≼ p; r ≼ p; q ⊥ r; q ∈ P; r ∈ P⟧ ⟹ thesis) ⟹ thesis›*) using separative[OF ‹p∈P›] (*‹∃q∈P. ∃r∈P. q ≼ p ∧ r ≼ p ∧ q ⊥ r›*) by force with ‹filter(G)› (*‹local.filter(G)›*) obtain s where "s ≼ p" "s ∉ G" "s ∈ P" (*goal: ‹(⋀s. ⟦s ≼ p; s ∉ G; s ∈ P⟧ ⟹ thesis) ⟹ thesis›*) using filter_imp_compat[of G q r] (*‹⟦local.filter(G); q ∈ G; r ∈ G⟧ ⟹ compat(q, r)›*) by auto then show "?thesis" (*goal: ‹∃d∈P - G. d ≼ p›*) by blast next (*goal: ‹p ∉ G ⟹ ∃d∈P - G. d ≼ p›*) case False (*‹p ∉ G›*) with ‹p∈P› (*‹p ∈ P›*) show "?thesis" (*goal: ‹∃d::i∈(P::i) - (G::i). d ≼ (p::i)›*) using leq_reflI (*‹?p ∈ P ⟹ ?p ≼ ?p›*) unfolding Diff_def (*goal: ‹∃d∈{x ∈ P . x ∉ G}. d ≼ p›*) by auto qed qed end (* separative_notion *) locale ctm_separative = forcing_data + separative_notion begin lemma generic_not_in_M: assumes "M_generic(G)" shows "G ∉ M" proof (standard) (*goal: ‹G ∈ M ⟹ False›*) assume "G∈M" (*‹(G::i) ∈ (M::i)›*) then have "P - G ∈ M" using P_in_M (*‹(P::i) ∈ (M::i)›*) Diff_closed (*‹⟦(##(M::i))(?A::i); (##M)(?B::i)⟧ ⟹ (##M)(?A - ?B)›*) by simp moreover have "¬(∃q∈G. q ∈ P - G)" "(P - G) ⊆ P" unfolding Diff_def (*goals: 1. ‹¬ (∃q∈G. q ∈ {x ∈ P . x ∉ G})› 2. ‹{x ∈ P . x ∉ G} ⊆ P›*) (*goals: 1. ‹¬ (∃q∈G. q ∈ {x ∈ P . x ∉ G})› 2. ‹{x ∈ P . x ∉ G} ⊆ P› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . moreover note assms (*‹M_generic(G)›*) ultimately show False using filter_complement_dense[of G] (*‹local.filter(G) ⟹ dense(P - G)›*) M_generic_denseD[of G "P-G"] (*‹⟦M_generic(G); dense(P - G); P - G ⊆ P; P - G ∈ M⟧ ⟹ ∃q∈G. q ∈ P - G›*) M_generic_def (*‹M_generic(?G) ≡ local.filter(?G) ∧ (∀D∈M. D ⊆ P ∧ dense(D) ⟶ D ∩ ?G ≠ 0)›*) by simp qed theorem proper_extension: assumes "M_generic(G)" shows "M ≠ M[G]" using assms (*‹M_generic(G::i)›*) G_in_Gen_Ext[of G] (*‹⟦G ⊆ P; one ∈ G⟧ ⟹ G ∈ M[G]›*) one_in_G[of G] (*‹M_generic(G) ⟹ one ∈ G›*) generic_not_in_M (*‹M_generic(?G) ⟹ ?G ∉ M›*) by force end (* ctm_separative *) end
{ "path": "afp-2025-02-12/thys/Forcing/Proper_Extension.thy", "repo": "afp-2025-02-12", "sha": "9c24bd61a89950dfcc445ebd248338596532b5949212d23fb698fbfaf5437fbd" }
(* Author: Tobias Nipkow *) section ‹Multiset of Elements of Binary Tree› theory Tree_Multiset imports Multiset Tree begin text ‹ Kept separate from theory \<^theory>‹HOL-Library.Tree› to avoid importing all of theory \<^theory>‹HOL-Library.Multiset› into \<^theory>‹HOL-Library.Tree›. Should be merged if \<^theory>‹HOL-Library.Multiset› ever becomes part of \<^theory>‹Main›. › fun mset_tree :: "'a tree ⇒ 'a multiset" where "mset_tree Leaf = {#}" | "mset_tree (Node l a r) = {#a#} + mset_tree l + mset_tree r" fun subtrees_mset :: "'a tree ⇒ 'a tree multiset" where "subtrees_mset Leaf = {#Leaf#}" | "subtrees_mset (Node l x r) = add_mset (Node l x r) (subtrees_mset l + subtrees_mset r)" lemma mset_tree_empty_iff[simp]: "mset_tree t = {#} ⟷ t = Leaf" apply (cases t) (*goals: 1. ‹t = ⟨⟩ ⟹ (mset_tree t = {#}) = (t = ⟨⟩)› 2. ‹⋀x21 x22 x23. t = ⟨x21, x22, x23⟩ ⟹ (mset_tree t = {#}) = (t = ⟨⟩)› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . lemma set_mset_tree[simp]: "set_mset (mset_tree t) = set_tree t" apply (induction t) (*goals: 1. ‹set_mset (mset_tree ⟨⟩) = set_tree ⟨⟩› 2. ‹⋀t1 x2 t2. ⟦set_mset (mset_tree t1) = set_tree t1; set_mset (mset_tree t2) = set_tree t2⟧ ⟹ set_mset (mset_tree ⟨t1, x2, t2⟩) = set_tree ⟨t1, x2, t2⟩› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . lemma size_mset_tree[simp]: "size(mset_tree t) = size t" apply (induction t) (*goals: 1. ‹size (mset_tree ⟨⟩) = size ⟨⟩› 2. ‹⋀t1 x2 t2. ⟦size (mset_tree t1) = size t1; size (mset_tree t2) = size t2⟧ ⟹ size (mset_tree ⟨t1, x2, t2⟩) = size ⟨t1, x2, t2⟩› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . lemma mset_map_tree: "mset_tree (map_tree f t) = image_mset f (mset_tree t)" apply (induction t) (*goals: 1. ‹mset_tree (map_tree f ⟨⟩) = image_mset f (mset_tree ⟨⟩)› 2. ‹⋀t1 x2 t2. ⟦mset_tree (map_tree f t1) = image_mset f (mset_tree t1); mset_tree (map_tree f t2) = image_mset f (mset_tree t2)⟧ ⟹ mset_tree (map_tree f ⟨t1, x2, t2⟩) = image_mset f (mset_tree ⟨t1, x2, t2⟩)› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . lemma mset_iff_set_tree: "x ∈# mset_tree t ⟷ x ∈ set_tree t" apply (induction t arbitrary: x) (*goals: 1. ‹⋀x. (x ∈# mset_tree ⟨⟩) = (x ∈ set_tree ⟨⟩)› 2. ‹⋀t1 x2 t2 x. ⟦⋀x. (x ∈# mset_tree t1) = (x ∈ set_tree t1); ⋀x. (x ∈# mset_tree t2) = (x ∈ set_tree t2)⟧ ⟹ (x ∈# mset_tree ⟨t1, x2, t2⟩) = (x ∈ set_tree ⟨t1, x2, t2⟩)› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . lemma mset_preorder[simp]: "mset (preorder t) = mset_tree t" apply (induction t) (*goals: 1. ‹mset (preorder ⟨⟩) = mset_tree ⟨⟩› 2. ‹⋀t1 x2 t2. ⟦mset (preorder t1) = mset_tree t1; mset (preorder t2) = mset_tree t2⟧ ⟹ mset (preorder ⟨t1, x2, t2⟩) = mset_tree ⟨t1, x2, t2⟩› 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 36 facts*))[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 36 facts*))[1]) (*proven 2 subgoals*) . lemma mset_inorder[simp]: "mset (inorder t) = mset_tree t" apply (induction t) (*goals: 1. ‹mset (inorder ⟨⟩) = mset_tree ⟨⟩› 2. ‹⋀t1 x2 t2. ⟦mset (inorder t1) = mset_tree t1; mset (inorder t2) = mset_tree t2⟧ ⟹ mset (inorder ⟨t1, x2, t2⟩) = mset_tree ⟨t1, x2, t2⟩› 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 36 facts*))[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 36 facts*))[1]) (*proven 2 subgoals*) . lemma map_mirror: "mset_tree (mirror t) = mset_tree t" apply (induction t) (*goals: 1. ‹mset_tree (mirror ⟨⟩) = mset_tree ⟨⟩› 2. ‹⋀t1 x2 t2. ⟦mset_tree (mirror t1) = mset_tree t1; mset_tree (mirror t2) = mset_tree t2⟧ ⟹ mset_tree (mirror ⟨t1, x2, t2⟩) = mset_tree ⟨t1, x2, t2⟩› discuss goal 1*) apply (simp add: 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*)) (*discuss goal 2*) apply (simp add: 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*)) (*proven 2 subgoals*) . lemma in_subtrees_mset_iff[simp]: "s ∈# subtrees_mset t ⟷ s ∈ subtrees t" apply (induction t) (*goals: 1. ‹(s ∈# subtrees_mset ⟨⟩) = (s ∈ subtrees ⟨⟩)› 2. ‹⋀t1 x2 t2. ⟦(s ∈# subtrees_mset t1) = (s ∈ subtrees t1); (s ∈# subtrees_mset t2) = (s ∈ subtrees t2)⟧ ⟹ (s ∈# subtrees_mset ⟨t1, x2, t2⟩) = (s ∈ subtrees ⟨t1, x2, t2⟩)› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . end
{ "path": "Isabelle2024/src/HOL/Library/Tree_Multiset.thy", "repo": "Isabelle2024", "sha": "2e87f581435b2eb6eaf138189aec3073e81dd1d483f340cc7dccd5505dd4538e" }
(* Title: HOL/Algebra/Ideal.thy Author: Stephan Hohe, TU Muenchen *) theory Ideal imports Ring AbelCoset begin section ‹Ideals› subsection ‹Definitions› subsubsection ‹General definition› locale ideal = additive_subgroup I R + ring R for I and R (structure) + assumes I_l_closed: "⟦a ∈ I; x ∈ carrier R⟧ ⟹ x ⊗ a ∈ I" and I_r_closed: "⟦a ∈ I; x ∈ carrier R⟧ ⟹ a ⊗ x ∈ I" sublocale ideal ⊆ abelian_subgroup I R proof (intro abelian_subgroupI3 (*‹⟦additive_subgroup ?H ?G; abelian_group ?G⟧ ⟹ abelian_subgroup ?H ?G›*) abelian_group.intro (*‹⟦abelian_monoid ?G; abelian_group_axioms ?G⟧ ⟹ abelian_group ?G›*)) (*goals: 1. ‹additive_subgroup (I::'a set) R› 2. ‹abelian_monoid R› 3. ‹abelian_group_axioms R›*) show "additive_subgroup I R" by (simp add: is_additive_subgroup (*‹additive_subgroup I R›*)) show "abelian_monoid R" by (simp add: abelian_monoid_axioms (*‹abelian_monoid R›*)) show "abelian_group_axioms R" using abelian_group_def (*‹abelian_group ?G ≡ abelian_monoid ?G ∧ abelian_group_axioms ?G›*) is_abelian_group (*‹abelian_group R›*) by blast qed lemma (in ideal) is_ideal: "ideal I R" by (rule ideal_axioms (*‹ideal I R›*)) lemma idealI: fixes R (structure) assumes "ring R" assumes a_subgroup: "subgroup I (add_monoid R)" and I_l_closed: "⋀a x. ⟦a ∈ I; x ∈ carrier R⟧ ⟹ x ⊗ a ∈ I" and I_r_closed: "⋀a x. ⟦a ∈ I; x ∈ carrier R⟧ ⟹ a ⊗ x ∈ I" shows "ideal I R" proof (-) (*goal: ‹ideal I R›*) interpret ring R by fact show "?thesis" (*goal: ‹ideal I R›*) by (auto simp: ideal.intro (*‹⟦additive_subgroup ?I ?R; ring ?R; ideal_axioms ?I ?R⟧ ⟹ ideal ?I ?R›*) ideal_axioms.intro (*‹⟦⋀a x. ⟦a ∈ ?I; x ∈ carrier ?R⟧ ⟹ x ⊗⇘?R⇙ a ∈ ?I; ⋀a x. ⟦a ∈ ?I; x ∈ carrier ?R⟧ ⟹ a ⊗⇘?R⇙ x ∈ ?I⟧ ⟹ ideal_axioms ?I ?R›*) additive_subgroupI (*‹subgroup ?H (add_monoid ?G) ⟹ additive_subgroup ?H ?G›*) a_subgroup (*‹subgroup I (add_monoid R)›*) ring_axioms (*‹ring R›*) I_l_closed (*‹⟦?a ∈ I; ?x ∈ carrier R⟧ ⟹ ?x ⊗ ?a ∈ I›*) I_r_closed (*‹⟦?a ∈ I; ?x ∈ carrier R⟧ ⟹ ?a ⊗ ?x ∈ I›*)) qed subsubsection (in ring) ‹Ideals Generated by a Subset of \<^term>‹carrier R›› definition genideal :: "_ ⇒ 'a set ⇒ 'a set" ("Idlı _" [80] 79) where "genideal R S = ⋂{I. ideal I R ∧ S ⊆ I}" subsubsection ‹Principal Ideals› locale principalideal = ideal + assumes generate: "∃i ∈ carrier R. I = Idl {i}" lemma (in principalideal) is_principalideal: "principalideal I R" by (rule principalideal_axioms (*‹principalideal I R›*)) lemma principalidealI: fixes R (structure) assumes "ideal I R" and generate: "∃i ∈ carrier R. I = Idl {i}" shows "principalideal I R" proof (-) (*goal: ‹principalideal I R›*) interpret ideal I R by fact show "?thesis" (*goal: ‹principalideal I R›*) apply (intro principalideal.intro (*‹⟦ideal ?I ?R; principalideal_axioms ?I ?R⟧ ⟹ principalideal ?I ?R›*) principalideal_axioms.intro (*‹∃i∈carrier ?R. ?I = Idl⇘?R⇙ {i} ⟹ principalideal_axioms ?I ?R›*)) (*goals: 1. ‹ideal I R› 2. ‹∃i∈carrier R. I = Idl {i}› discuss goal 1*) apply (rule is_ideal (*‹ideal I R›*)) (*discuss goal 2*) apply (rule generate (*‹∃i∈carrier R. I = Idl {i}›*)) (*proven 2 subgoals*) . qed (* NEW ====== *) lemma (in ideal) rcos_const_imp_mem: assumes "i ∈ carrier R" and "I +> i = I" shows "i ∈ I" using additive_subgroup.zero_closed[OF ideal.axioms ( 1 ) [ OF ideal_axioms ]] (*‹𝟬 ∈ (I::'a::type set)›*) assms (*‹(i::'a) ∈ carrier R› ‹I +> i = I›*) by (force simp add: a_r_coset_def' (*‹?H +>⇘?G⇙ ?a ≡ ⋃h∈?H. {h ⊕⇘?G⇙ ?a}›*)) (* ========== *) (* NEW ====== *) lemma (in ring) a_rcos_zero: assumes "ideal I R" "i ∈ I" shows "I +> i = I" using abelian_subgroupI3[OF ideal.axioms ( 1 ) is_abelian_group] (*‹ideal ?H R ⟹ abelian_subgroup ?H R›*) by (simp add: abelian_subgroup.a_rcos_const (*‹⟦abelian_subgroup ?H ?G; ?h ∈ ?H⟧ ⟹ ?H +>⇘?G⇙ ?h = ?H›*) assms (*‹ideal I R› ‹i ∈ I›*)) (* ========== *) (* NEW ====== *) lemma (in ring) ideal_is_normal: assumes "ideal I R" shows "I ⊲ (add_monoid R)" using abelian_subgroup.a_normal[OF abelian_subgroupI3 [ OF ideal.axioms ( 1 ) ]] (*‹⟦ideal (?H::?'a set) (?G::(?'a, ?'b) ring_scheme); abelian_group ?G⟧ ⟹ ?H ⊲ add_monoid ?G›*) abelian_group_axioms (*‹abelian_group R›*) assms (*‹ideal I R›*) by auto (* ========== *) (* NEW ====== *) lemma (in ideal) a_rcos_sum: assumes "a ∈ carrier R" and "b ∈ carrier R" shows "(I +> a) <+> (I +> b) = I +> (a ⊕ b)" using normal.rcos_sum[OF ideal_is_normal [ OF ideal_axioms ]] (*‹⟦(?x::'a) ∈ carrier (add_monoid R); (?y::'a) ∈ carrier (add_monoid R)⟧ ⟹ (I::'a set) #>⇘add_monoid R⇙ ?x <#>⇘add_monoid R⇙ (I #>⇘add_monoid R⇙ ?y) = I #>⇘add_monoid R⇙ ?x ⊗⇘add_monoid R⇙ ?y›*) assms (*‹a ∈ carrier R› ‹b ∈ carrier R›*) unfolding set_add_def a_r_coset_def (*goal: ‹(I::'a::type set) #>⇘add_monoid R⇙ (a::'a::type) <#>⇘add_monoid R⇙ (I #>⇘add_monoid R⇙ (b::'a::type)) = I #>⇘add_monoid R⇙ a ⊕ b›*) by simp (* ========== *) (* NEW ====== *) lemma (in ring) set_add_comm: assumes "I ⊆ carrier R" "J ⊆ carrier R" shows "I <+> J = J <+> I" proof (-) (*goal: ‹I <+> J = J <+> I›*) { fix I and J assume "I ⊆ carrier R" "J ⊆ carrier R" (*‹(I::'a set) ⊆ carrier R› ‹(J::'a set) ⊆ carrier R›*) hence "I <+> J ⊆ J <+> I" using a_comm (*‹⟦?x ∈ carrier R; ?y ∈ carrier R⟧ ⟹ ?x ⊕ ?y = ?y ⊕ ?x›*) unfolding set_add_def' (*goal: ‹(⋃h∈I. ⋃k∈J. {h ⊕ k}) ⊆ (⋃h∈J. ⋃k∈I. {h ⊕ k})›*) apply auto (*goal: ‹(⋃h∈I. ⋃k∈J. {h ⊕ k}) ⊆ (⋃h∈J. ⋃k∈I. {h ⊕ k})›*) by blast } thus "?thesis" (*goal: ‹I <+> J = J <+> I›*) using assms (*‹(I::'a set) ⊆ carrier R› ‹J ⊆ carrier R›*) by auto qed (* ========== *) subsubsection ‹Maximal Ideals› locale maximalideal = ideal + assumes I_notcarr: "carrier R ≠ I" and I_maximal: "⟦ideal J R; I ⊆ J; J ⊆ carrier R⟧ ⟹ (J = I) ∨ (J = carrier R)" lemma (in maximalideal) is_maximalideal: "maximalideal I R" by (rule maximalideal_axioms (*‹maximalideal I R›*)) lemma maximalidealI: fixes R assumes "ideal I R" and I_notcarr: "carrier R ≠ I" and I_maximal: "⋀J. ⟦ideal J R; I ⊆ J; J ⊆ carrier R⟧ ⟹ (J = I) ∨ (J = carrier R)" shows "maximalideal I R" proof (-) (*goal: ‹maximalideal (I::'a::type set) (R::('a, 'b) ring_scheme)›*) interpret ideal I R by fact show "?thesis" (*goal: ‹maximalideal I R›*) apply (intro maximalideal.intro (*‹⟦ideal ?I ?R; maximalideal_axioms ?I ?R⟧ ⟹ maximalideal ?I ?R›*) maximalideal_axioms.intro (*‹⟦carrier ?R ≠ ?I; ⋀J. ⟦ideal J ?R; ?I ⊆ J; J ⊆ carrier ?R⟧ ⟹ J = ?I ∨ J = carrier ?R⟧ ⟹ maximalideal_axioms ?I ?R›*)) (*goals: 1. ‹ideal I R› 2. ‹carrier R ≠ I› 3. ‹⋀J. ⟦ideal J R; I ⊆ J; J ⊆ carrier R⟧ ⟹ J = I ∨ J = carrier R› discuss goal 1*) apply (rule is_ideal (*‹ideal (I::'a set) (R::('a, 'b) ring_scheme)›*)) (*discuss goal 2*) apply (rule I_notcarr (*‹carrier R ≠ I›*)) (*discuss goal 3*) apply (rule I_maximal (*‹⟦ideal (?J::'a::type set) (R::('a, 'b) ring_scheme); (I::'a::type set) ⊆ ?J; ?J ⊆ carrier R⟧ ⟹ ?J = I ∨ ?J = carrier R›*)) (*goals: 1. ‹⋀J. ⟦ideal J R; I ⊆ J; J ⊆ carrier R⟧ ⟹ ideal J R› 2. ‹⋀J. ⟦ideal J R; I ⊆ J; J ⊆ carrier R⟧ ⟹ I ⊆ J› 3. ‹⋀J. ⟦ideal J R; I ⊆ J; J ⊆ carrier R⟧ ⟹ J ⊆ carrier R› discuss goal 1*) apply ((assumption)[1]) (*discuss goal 2*) apply ((assumption)[1]) (*discuss goal 3*) . (*proven 3 subgoals*) (*proven 3 subgoals*) qed subsubsection ‹Prime Ideals› locale primeideal = ideal + cring + assumes I_notcarr: "carrier R ≠ I" and I_prime: "⟦a ∈ carrier R; b ∈ carrier R; a ⊗ b ∈ I⟧ ⟹ a ∈ I ∨ b ∈ I" lemma (in primeideal) primeideal: "primeideal I R" by (rule primeideal_axioms (*‹primeideal I R›*)) lemma primeidealI: fixes R (structure) assumes "ideal I R" and "cring R" and I_notcarr: "carrier R ≠ I" and I_prime: "⋀a b. ⟦a ∈ carrier R; b ∈ carrier R; a ⊗ b ∈ I⟧ ⟹ a ∈ I ∨ b ∈ I" shows "primeideal I R" proof (-) (*goal: ‹primeideal I R›*) interpret ideal I R by fact interpret cring R by fact show "?thesis" (*goal: ‹primeideal I R›*) apply (intro primeideal.intro (*‹⟦ideal (?I::?'a set) (?R::(?'a, ?'b) ring_scheme); cring ?R; primeideal_axioms ?I ?R⟧ ⟹ primeideal ?I ?R›*) primeideal_axioms.intro (*‹⟦carrier (?R::(?'a, ?'b) ring_scheme) ≠ (?I::?'a set); ⋀(a::?'a) b::?'a. ⟦a ∈ carrier ?R; b ∈ carrier ?R; a ⊗⇘?R⇙ b ∈ ?I⟧ ⟹ a ∈ ?I ∨ b ∈ ?I⟧ ⟹ primeideal_axioms ?I ?R›*)) (*goals: 1. ‹ideal I R› 2. ‹cring R› 3. ‹carrier R ≠ I› 4. ‹⋀a b. ⟦a ∈ carrier R; b ∈ carrier R; a ⊗ b ∈ I⟧ ⟹ a ∈ I ∨ b ∈ I› discuss goal 1*) apply (rule is_ideal (*‹ideal I R›*)) (*discuss goal 2*) apply (rule is_cring (*‹cring R›*)) (*discuss goal 3*) apply (rule I_notcarr (*‹carrier R ≠ I›*)) (*discuss goal 4*) apply (rule I_prime (*‹⟦?a ∈ carrier R; ?b ∈ carrier R; ?a ⊗ ?b ∈ I⟧ ⟹ ?a ∈ I ∨ ?b ∈ I›*)) (*goals: 1. ‹⋀a b. ⟦a ∈ carrier R; b ∈ carrier R; a ⊗ b ∈ I⟧ ⟹ a ∈ carrier R› 2. ‹⋀a b. ⟦a ∈ carrier R; b ∈ carrier R; a ⊗ b ∈ I⟧ ⟹ b ∈ carrier R› 3. ‹⋀a b. ⟦a ∈ carrier R; b ∈ carrier R; a ⊗ b ∈ I⟧ ⟹ a ⊗ b ∈ I› discuss goal 1*) apply ((assumption)[1]) (*discuss goal 2*) apply ((assumption)[1]) (*discuss goal 3*) . (*proven 3 subgoals*) (*proven 4 subgoals*) qed lemma primeidealI2: fixes R (structure) assumes "additive_subgroup I R" and "cring R" and I_l_closed: "⋀a x. ⟦a ∈ I; x ∈ carrier R⟧ ⟹ x ⊗ a ∈ I" and I_r_closed: "⋀a x. ⟦a ∈ I; x ∈ carrier R⟧ ⟹ a ⊗ x ∈ I" and I_notcarr: "carrier R ≠ I" and I_prime: "⋀a b. ⟦a ∈ carrier R; b ∈ carrier R; a ⊗ b ∈ I⟧ ⟹ a ∈ I ∨ b ∈ I" shows "primeideal I R" proof (-) (*goal: ‹primeideal I R›*) interpret additive_subgroup I R by fact interpret cring R by fact show "?thesis" (*goal: ‹primeideal I R›*) apply intro_locales (*goals: 1. ‹ideal_axioms (I::'a set) R› 2. ‹primeideal_axioms (I::'a set) R› discuss goal 1*) apply (intro ideal_axioms.intro (*‹⟦⋀a x. ⟦a ∈ ?I; x ∈ carrier ?R⟧ ⟹ x ⊗⇘?R⇙ a ∈ ?I; ⋀a x. ⟦a ∈ ?I; x ∈ carrier ?R⟧ ⟹ a ⊗⇘?R⇙ x ∈ ?I⟧ ⟹ ideal_axioms ?I ?R›*)) (*goals: 1. ‹⋀a x. ⟦a ∈ I; x ∈ carrier R⟧ ⟹ x ⊗ a ∈ I› 2. ‹⋀a x. ⟦a ∈ I; x ∈ carrier R⟧ ⟹ a ⊗ x ∈ I› discuss goal 1*) apply (erule (1) I_l_closed (*‹⟦?a ∈ I; ?x ∈ carrier R⟧ ⟹ ?x ⊗ ?a ∈ I›*)) (*discuss goal 2*) apply (erule (1) I_r_closed (*‹⟦(?a::'a) ∈ (I::'a set); (?x::'a) ∈ carrier R⟧ ⟹ ?a ⊗ ?x ∈ I›*)) (*proven 2 subgoals*) (*discuss goal 2*) apply (simp add: I_notcarr (*‹carrier R ≠ I›*) I_prime (*‹⟦?a ∈ carrier R; ?b ∈ carrier R; ?a ⊗ ?b ∈ I⟧ ⟹ ?a ∈ I ∨ ?b ∈ I›*) primeideal_axioms.intro (*‹⟦carrier ?R ≠ ?I; ⋀a b. ⟦a ∈ carrier ?R; b ∈ carrier ?R; a ⊗⇘?R⇙ b ∈ ?I⟧ ⟹ a ∈ ?I ∨ b ∈ ?I⟧ ⟹ primeideal_axioms ?I ?R›*)) (*proven 2 subgoals*) . qed subsection ‹Special Ideals› lemma (in ring) zeroideal: "ideal {𝟬} R" apply (intro idealI (*‹⟦ring ?R; subgroup ?I (add_monoid ?R); ⋀a x. ⟦a ∈ ?I; x ∈ carrier ?R⟧ ⟹ x ⊗⇘?R⇙ a ∈ ?I; ⋀a x. ⟦a ∈ ?I; x ∈ carrier ?R⟧ ⟹ a ⊗⇘?R⇙ x ∈ ?I⟧ ⟹ ideal ?I ?R›*) subgroup.intro (*‹⟦?H ⊆ carrier ?G; ⋀x y. ⟦x ∈ ?H; y ∈ ?H⟧ ⟹ x ⊗⇘?G⇙ y ∈ ?H; 𝟭⇘?G⇙ ∈ ?H; ⋀x. x ∈ ?H ⟹ inv⇘?G⇙ x ∈ ?H⟧ ⟹ subgroup ?H ?G›*)) (*goals: 1. ‹ring R› 2. ‹{𝟬} ⊆ carrier (add_monoid R)› 3. ‹⋀x y. ⟦x ∈ {𝟬}; y ∈ {𝟬}⟧ ⟹ x ⊗⇘add_monoid R⇙ y ∈ {𝟬}› 4. ‹𝟭⇘add_monoid R⇙ ∈ {𝟬}› 5. ‹⋀x. x ∈ {𝟬} ⟹ inv⇘add_monoid R⇙ x ∈ {𝟬}› 6. ‹⋀a x. ⟦a ∈ {𝟬}; x ∈ carrier R⟧ ⟹ x ⊗ a ∈ {𝟬}› 7. ‹⋀a x. ⟦a ∈ {𝟬}; x ∈ carrier R⟧ ⟹ a ⊗ x ∈ {𝟬}› discuss goal 1*) apply (simp add: ring_axioms (*‹ring R›*)) (*discuss goal 2*) apply (simp add: ring_axioms (*‹ring R›*)) (*discuss goal 3*) apply (simp add: ring_axioms (*‹ring R›*)) (*discuss goal 4*) apply (simp add: ring_axioms (*‹ring R›*)) (*discuss goal 5*) apply (simp add: ring_axioms (*‹ring R›*)) (*discuss goal 6*) apply (simp add: ring_axioms (*‹ring R›*)) (*discuss goal 7*) apply (simp add: ring_axioms (*‹ring R›*)) (*proven 7 subgoals*) . lemma (in ring) oneideal: "ideal (carrier R) R" apply (rule idealI (*‹⟦ring ?R; subgroup ?I (add_monoid ?R); ⋀a x. ⟦a ∈ ?I; x ∈ carrier ?R⟧ ⟹ x ⊗⇘?R⇙ a ∈ ?I; ⋀a x. ⟦a ∈ ?I; x ∈ carrier ?R⟧ ⟹ a ⊗⇘?R⇙ x ∈ ?I⟧ ⟹ ideal ?I ?R›*)) (*goals: 1. ‹ring R› 2. ‹subgroup (carrier R) (add_monoid R)› 3. ‹⋀a x. ⟦a ∈ carrier R; x ∈ carrier R⟧ ⟹ x ⊗ a ∈ carrier R› 4. ‹⋀a x. ⟦a ∈ carrier R; x ∈ carrier R⟧ ⟹ a ⊗ x ∈ carrier R› discuss goal 1*) apply ((auto intro: ring_axioms (*‹ring R›*) add.subgroupI (*‹⟦?H ⊆ carrier R; ?H ≠ {}; ⋀a. a ∈ ?H ⟹ ⊖ a ∈ ?H; ⋀a b. ⟦a ∈ ?H; b ∈ ?H⟧ ⟹ a ⊕ b ∈ ?H⟧ ⟹ subgroup ?H (add_monoid R)›*))[1]) (*discuss goal 2*) apply ((auto intro: ring_axioms (*‹ring R›*) add.subgroupI (*‹⟦?H ⊆ carrier R; ?H ≠ {}; ⋀a. a ∈ ?H ⟹ ⊖ a ∈ ?H; ⋀a b. ⟦a ∈ ?H; b ∈ ?H⟧ ⟹ a ⊕ b ∈ ?H⟧ ⟹ subgroup ?H (add_monoid R)›*))[1]) (*discuss goal 3*) apply ((auto intro: ring_axioms (*‹ring R›*) add.subgroupI (*‹⟦?H ⊆ carrier R; ?H ≠ {}; ⋀a. a ∈ ?H ⟹ ⊖ a ∈ ?H; ⋀a b. ⟦a ∈ ?H; b ∈ ?H⟧ ⟹ a ⊕ b ∈ ?H⟧ ⟹ subgroup ?H (add_monoid R)›*))[1]) (*discuss goal 4*) apply ((auto intro: ring_axioms (*‹ring R›*) add.subgroupI (*‹⟦?H ⊆ carrier R; ?H ≠ {}; ⋀a. a ∈ ?H ⟹ ⊖ a ∈ ?H; ⋀a b. ⟦a ∈ ?H; b ∈ ?H⟧ ⟹ a ⊕ b ∈ ?H⟧ ⟹ subgroup ?H (add_monoid R)›*))[1]) (*proven 4 subgoals*) . lemma (in "domain") zeroprimeideal: "primeideal {𝟬} R" proof (-) (*goal: ‹primeideal {𝟬} R›*) have "carrier R ≠ {𝟬}" by (simp add: carrier_one_not_zero (*‹(carrier R ≠ {𝟬}) = (𝟭 ≠ 𝟬)›*)) then show "?thesis" (*goal: ‹primeideal {𝟬} R›*) by (metis (no_types, lifting) domain_axioms (*‹domain R›*) domain_def (*‹domain (?R::(?'a, ?'b) ring_scheme) ≡ cring ?R ∧ domain_axioms ?R›*) integral (*‹⟦(?a::'a) ⊗ (?b::'a) = 𝟬; ?a ∈ carrier R; ?b ∈ carrier R⟧ ⟹ ?a = 𝟬 ∨ ?b = 𝟬›*) primeidealI (*‹⟦ideal (?I::?'a set) (?R::(?'a, ?'b) ring_scheme); cring ?R; carrier ?R ≠ ?I; ⋀(a::?'a) b::?'a. ⟦a ∈ carrier ?R; b ∈ carrier ?R; a ⊗⇘?R⇙ b ∈ ?I⟧ ⟹ a ∈ ?I ∨ b ∈ ?I⟧ ⟹ primeideal ?I ?R›*) singleton_iff (*‹((?b::?'a) ∈ {?a::?'a}) = (?b = ?a)›*) zeroideal (*‹ideal {𝟬} R›*)) qed subsection ‹General Ideal Properties› lemma (in ideal) one_imp_carrier: assumes I_one_closed: "𝟭 ∈ I" shows "I = carrier R" proof (standard) (*goals: 1. ‹I ⊆ carrier R› 2. ‹carrier R ⊆ I›*) show "carrier R ⊆ I" using I_r_closed (*‹⟦(?a::'a::type) ∈ (I::'a::type set); (?x::'a::type) ∈ carrier R⟧ ⟹ ?a ⊗ ?x ∈ I›*) assms (*‹𝟭 ∈ I›*) by fastforce show "I ⊆ carrier R" by (rule a_subset (*‹I ⊆ carrier R›*)) qed lemma (in ideal) Icarr: assumes iI: "i ∈ I" shows "i ∈ carrier R" using iI (*‹i ∈ I›*) by (rule a_Hcarr (*‹?h ∈ I ⟹ ?h ∈ carrier R›*)) lemma (in ring) quotient_eq_iff_same_a_r_cos: assumes "ideal I R" and "a ∈ carrier R" and "b ∈ carrier R" shows "a ⊖ b ∈ I ⟷ I +> a = I +> b" proof (standard) (*goals: 1. ‹(a::'a::type) ⊖ (b::'a::type) ∈ (I::'a::type set) ⟹ I +> a = I +> b› 2. ‹(I::'a::type set) +> (a::'a::type) = I +> (b::'a::type) ⟹ a ⊖ b ∈ I›*) assume "I +> a = I +> b" (*‹(I::'a set) +> (a::'a) = I +> (b::'a)›*) then obtain i where "i ∈ I" and "𝟬 ⊕ a = i ⊕ b" (*goal: ‹(⋀i. ⟦i ∈ I; 𝟬 ⊕ a = i ⊕ b⟧ ⟹ thesis) ⟹ thesis›*) using additive_subgroup.zero_closed[OF ideal.axioms ( 1 ) [ OF assms ( 1 ) ]] (*‹𝟬 ∈ I›*) assms(2) (*‹(a::'a) ∈ carrier R›*) unfolding a_r_coset_def' (*goal: ‹(⋀i. ⟦i ∈ I; 𝟬 ⊕ a = i ⊕ b⟧ ⟹ thesis) ⟹ thesis›*) by blast hence "a ⊖ b = i" using assms(2-3) (*‹a ∈ carrier R› ‹(b::'a) ∈ carrier R›*) by (metis a_minus_def (*‹?x ⊖⇘?R⇙ ?y = ?x ⊕⇘?R⇙ ⊖⇘?R⇙ ?y›*) add.inv_solve_right (*‹⟦?a ∈ carrier R; ?b ∈ carrier R; ?c ∈ carrier R⟧ ⟹ (?a = ?b ⊕ ⊖ ?c) = (?b = ?a ⊕ ?c)›*) assms( (*‹ideal I R›*) 1) ideal.Icarr (*‹⟦ideal ?I ?R; ?i ∈ ?I⟧ ⟹ ?i ∈ carrier ?R›*) l_zero (*‹?x ∈ carrier R ⟹ 𝟬 ⊕ ?x = ?x›*)) with ‹i ∈ I› (*‹i ∈ I›*) show "a ⊖ b ∈ I" by simp next (*goal: ‹a ⊖ b ∈ I ⟹ I +> a = I +> b›*) assume "a ⊖ b ∈ I" (*‹(a::'a) ⊖ (b::'a) ∈ (I::'a set)›*) then obtain i where "i ∈ I" and "a = i ⊕ b" (*goal: ‹(⋀i. ⟦i ∈ I; a = i ⊕ b⟧ ⟹ thesis) ⟹ thesis›*) using ideal.Icarr[OF assms ( 1 )] (*‹?i ∈ I ⟹ ?i ∈ carrier R›*) assms(2-3) (*‹a ∈ carrier R› ‹b ∈ carrier R›*) by (metis a_minus_def (*‹?x ⊖⇘?R⇙ ?y = ?x ⊕⇘?R⇙ ⊖⇘?R⇙ ?y›*) add.inv_solve_right (*‹⟦?a ∈ carrier R; ?b ∈ carrier R; ?c ∈ carrier R⟧ ⟹ (?a = ?b ⊕ ⊖ ?c) = (?b = ?a ⊕ ?c)›*)) hence "I +> a = (I +> i) +> b" using ideal.Icarr[OF assms ( 1 )] (*‹?i ∈ I ⟹ ?i ∈ carrier R›*) assms(3) (*‹b ∈ carrier R›*) by (simp add: a_coset_add_assoc (*‹⟦?M ⊆ carrier R; ?g ∈ carrier R; ?h ∈ carrier R⟧ ⟹ ?M +> ?g +> ?h = ?M +> ?g ⊕ ?h›*) subsetI (*‹(⋀x. x ∈ ?A ⟹ x ∈ ?B) ⟹ ?A ⊆ ?B›*)) with ‹i ∈ I› (*‹i ∈ I›*) show "I +> a = I +> b" using a_rcos_zero[OF assms ( 1 )] (*‹?i ∈ I ⟹ I +> ?i = I›*) by simp qed subsection ‹Intersection of Ideals› paragraph ‹Intersection of two ideals› text ‹The intersection of any two ideals is again an ideal in \<^term>‹R›› lemma (in ring) i_intersect: assumes "ideal I R" assumes "ideal J R" shows "ideal (I ∩ J) R" proof (-) (*goal: ‹ideal (I ∩ J) R›*) interpret ideal I R by fact interpret ideal J R by fact have IJ: "I ∩ J ⊆ carrier R" by (force simp: a_subset (*‹J ⊆ carrier R›*)) show "?thesis" (*goal: ‹ideal (I ∩ J) R›*) apply (intro idealI (*‹⟦ring (?R::(?'a, ?'b) ring_scheme); subgroup (?I::?'a set) (add_monoid ?R); ⋀(a::?'a) x::?'a. ⟦a ∈ ?I; x ∈ carrier ?R⟧ ⟹ x ⊗⇘?R⇙ a ∈ ?I; ⋀(a::?'a) x::?'a. ⟦a ∈ ?I; x ∈ carrier ?R⟧ ⟹ a ⊗⇘?R⇙ x ∈ ?I⟧ ⟹ ideal ?I ?R›*) subgroup.intro (*‹⟦(?H::?'a set) ⊆ carrier (?G::(?'a, ?'b) monoid_scheme); ⋀(x::?'a) y::?'a. ⟦x ∈ ?H; y ∈ ?H⟧ ⟹ x ⊗⇘?G⇙ y ∈ ?H; 𝟭⇘?G⇙ ∈ ?H; ⋀x::?'a. x ∈ ?H ⟹ inv⇘?G⇙ x ∈ ?H⟧ ⟹ subgroup ?H ?G›*)) (*goals: 1. ‹ring R› 2. ‹I ∩ J ⊆ carrier (add_monoid R)› 3. ‹⋀x y. ⟦x ∈ I ∩ J; y ∈ I ∩ J⟧ ⟹ x ⊗⇘add_monoid R⇙ y ∈ I ∩ J› 4. ‹𝟭⇘add_monoid R⇙ ∈ I ∩ J› 5. ‹⋀x. x ∈ I ∩ J ⟹ inv⇘add_monoid R⇙ x ∈ I ∩ J› 6. ‹⋀a x. ⟦a ∈ I ∩ J; x ∈ carrier R⟧ ⟹ x ⊗ a ∈ I ∩ J› 7. ‹⋀a x. ⟦a ∈ I ∩ J; x ∈ carrier R⟧ ⟹ a ⊗ x ∈ I ∩ J› discuss goal 1*) apply (simp add: IJ (*‹I ∩ J ⊆ carrier R›*) ring_axioms (*‹ring R›*) I_l_closed (*‹⟦?a ∈ J; ?x ∈ carrier R⟧ ⟹ ?x ⊗ ?a ∈ J›*) assms (*‹ideal I R› ‹ideal J R›*) ideal.I_l_closed (*‹⟦ideal ?I ?R; ?a ∈ ?I; ?x ∈ carrier ?R⟧ ⟹ ?x ⊗⇘?R⇙ ?a ∈ ?I›*) ideal.I_r_closed (*‹⟦ideal ?I ?R; ?a ∈ ?I; ?x ∈ carrier ?R⟧ ⟹ ?a ⊗⇘?R⇙ ?x ∈ ?I›*) flip: a_inv_def (*‹a_inv ?R = m_inv (add_monoid ?R)›*)) (*discuss goal 2*) apply (simp add: IJ (*‹I ∩ J ⊆ carrier R›*) ring_axioms (*‹ring R›*) I_l_closed (*‹⟦?a ∈ J; ?x ∈ carrier R⟧ ⟹ ?x ⊗ ?a ∈ J›*) assms (*‹ideal I R› ‹ideal J R›*) ideal.I_l_closed (*‹⟦ideal ?I ?R; ?a ∈ ?I; ?x ∈ carrier ?R⟧ ⟹ ?x ⊗⇘?R⇙ ?a ∈ ?I›*) ideal.I_r_closed (*‹⟦ideal ?I ?R; ?a ∈ ?I; ?x ∈ carrier ?R⟧ ⟹ ?a ⊗⇘?R⇙ ?x ∈ ?I›*) flip: a_inv_def (*‹a_inv ?R = m_inv (add_monoid ?R)›*)) (*discuss goal 3*) apply (simp add: IJ (*‹I ∩ J ⊆ carrier R›*) ring_axioms (*‹ring R›*) I_l_closed (*‹⟦?a ∈ J; ?x ∈ carrier R⟧ ⟹ ?x ⊗ ?a ∈ J›*) assms (*‹ideal I R› ‹ideal J R›*) ideal.I_l_closed (*‹⟦ideal ?I ?R; ?a ∈ ?I; ?x ∈ carrier ?R⟧ ⟹ ?x ⊗⇘?R⇙ ?a ∈ ?I›*) ideal.I_r_closed (*‹⟦ideal ?I ?R; ?a ∈ ?I; ?x ∈ carrier ?R⟧ ⟹ ?a ⊗⇘?R⇙ ?x ∈ ?I›*) flip: a_inv_def (*‹a_inv ?R = m_inv (add_monoid ?R)›*)) (*discuss goal 4*) apply (simp add: IJ (*‹I ∩ J ⊆ carrier R›*) ring_axioms (*‹ring R›*) I_l_closed (*‹⟦?a ∈ J; ?x ∈ carrier R⟧ ⟹ ?x ⊗ ?a ∈ J›*) assms (*‹ideal I R› ‹ideal J R›*) ideal.I_l_closed (*‹⟦ideal ?I ?R; ?a ∈ ?I; ?x ∈ carrier ?R⟧ ⟹ ?x ⊗⇘?R⇙ ?a ∈ ?I›*) ideal.I_r_closed (*‹⟦ideal ?I ?R; ?a ∈ ?I; ?x ∈ carrier ?R⟧ ⟹ ?a ⊗⇘?R⇙ ?x ∈ ?I›*) flip: a_inv_def (*‹a_inv ?R = m_inv (add_monoid ?R)›*)) (*discuss goal 5*) apply (simp add: IJ (*‹I ∩ J ⊆ carrier R›*) ring_axioms (*‹ring R›*) I_l_closed (*‹⟦?a ∈ J; ?x ∈ carrier R⟧ ⟹ ?x ⊗ ?a ∈ J›*) assms (*‹ideal I R› ‹ideal J R›*) ideal.I_l_closed (*‹⟦ideal ?I ?R; ?a ∈ ?I; ?x ∈ carrier ?R⟧ ⟹ ?x ⊗⇘?R⇙ ?a ∈ ?I›*) ideal.I_r_closed (*‹⟦ideal ?I ?R; ?a ∈ ?I; ?x ∈ carrier ?R⟧ ⟹ ?a ⊗⇘?R⇙ ?x ∈ ?I›*) flip: a_inv_def (*‹a_inv ?R = m_inv (add_monoid ?R)›*)) (*discuss goal 6*) apply (simp add: IJ (*‹I ∩ J ⊆ carrier R›*) ring_axioms (*‹ring R›*) I_l_closed (*‹⟦?a ∈ J; ?x ∈ carrier R⟧ ⟹ ?x ⊗ ?a ∈ J›*) assms (*‹ideal I R› ‹ideal J R›*) ideal.I_l_closed (*‹⟦ideal ?I ?R; ?a ∈ ?I; ?x ∈ carrier ?R⟧ ⟹ ?x ⊗⇘?R⇙ ?a ∈ ?I›*) ideal.I_r_closed (*‹⟦ideal ?I ?R; ?a ∈ ?I; ?x ∈ carrier ?R⟧ ⟹ ?a ⊗⇘?R⇙ ?x ∈ ?I›*) flip: a_inv_def (*‹a_inv ?R = m_inv (add_monoid ?R)›*)) (*discuss goal 7*) apply (simp add: IJ (*‹(I::'a::type set) ∩ (J::'a::type set) ⊆ carrier R›*) ring_axioms (*‹ring R›*) I_l_closed (*‹⟦(?a::'a::type) ∈ (J::'a::type set); (?x::'a::type) ∈ carrier R⟧ ⟹ ?x ⊗ ?a ∈ J›*) assms (*‹ideal (I::'a::type set) R› ‹ideal (J::'a::type set) R›*) ideal.I_l_closed (*‹⟦ideal (?I::?'a::type set) (?R::(?'a, ?'b) ring_scheme); (?a::?'a::type) ∈ ?I; (?x::?'a::type) ∈ carrier ?R⟧ ⟹ ?x ⊗⇘?R⇙ ?a ∈ ?I›*) ideal.I_r_closed (*‹⟦ideal (?I::?'a::type set) (?R::(?'a, ?'b) ring_scheme); (?a::?'a::type) ∈ ?I; (?x::?'a::type) ∈ carrier ?R⟧ ⟹ ?a ⊗⇘?R⇙ ?x ∈ ?I›*) flip: a_inv_def (*‹a_inv (?R::(?'a, ?'m) ring_scheme) = m_inv (add_monoid ?R)›*)) (*proven 7 subgoals*) . qed text ‹The intersection of any Number of Ideals is again an Ideal in \<^term>‹R›› lemma (in ring) i_Intersect: assumes Sideals: "⋀I. I ∈ S ⟹ ideal I R" and notempty: "S ≠ {}" shows "ideal (⋂S) R" proof (-) (*goal: ‹ideal (⋂ S) R›*) { fix x and y and J assume "∀I∈S. x ∈ I" "∀I∈S. y ∈ I" and JS: "J ∈ S" (*‹∀I::'a set∈S::'a set set. (x::'a) ∈ I› ‹∀I::'a set∈S::'a set set. (y::'a) ∈ I› ‹(J::'a set) ∈ (S::'a set set)›*) interpret ideal J R by (rule Sideals[OF JS] (*‹ideal J R›*)) have "x ⊕ y ∈ J" by (simp add: JS (*‹J ∈ S›*) ‹∀I∈S. x ∈ I› ‹∀I∈S. y ∈ I›) } moreover have "𝟬 ∈ J" if "J ∈ S" for J by (simp add: that (*‹J ∈ S›*) Sideals (*‹?I ∈ S ⟹ ideal ?I R›*) additive_subgroup.zero_closed (*‹additive_subgroup ?H ?G ⟹ 𝟬⇘?G⇙ ∈ ?H›*) ideal.axioms( (*‹ideal ?I ?R ⟹ additive_subgroup ?I ?R›*) 1)) moreover { fix x and J assume "∀I∈S. x ∈ I" and JS: "J ∈ S" (*‹∀I::'a set∈S::'a set set. (x::'a) ∈ I› ‹(J::'a set) ∈ (S::'a set set)›*) interpret ideal J R by (rule Sideals[OF JS] (*‹ideal J R›*)) have "⊖ x ∈ J" by (simp add: JS (*‹J ∈ S›*) ‹∀I∈S. x ∈ I›) } moreover { fix x and y and J assume "∀I∈S. x ∈ I" and ycarr: "y ∈ carrier R" and JS: "J ∈ S" (*‹∀I::'a set∈S::'a set set. (x::'a) ∈ I› ‹(y::'a) ∈ carrier R› ‹(J::'a set) ∈ (S::'a set set)›*) interpret ideal J R by (rule Sideals[OF JS] (*‹ideal J R›*)) have "y ⊗ x ∈ J" "x ⊗ y ∈ J" using I_l_closed (*‹⟦?a ∈ J; ?x ∈ carrier R⟧ ⟹ ?x ⊗ ?a ∈ J›*) I_r_closed (*‹⟦?a ∈ J; ?x ∈ carrier R⟧ ⟹ ?a ⊗ ?x ∈ J›*) JS (*‹J ∈ S›*) ‹∀I∈S. x ∈ I› (*‹∀I::'a set∈S::'a set set. (x::'a) ∈ I›*) ycarr (*‹y ∈ carrier R›*) apply - (*goals: 1. ‹⟦⋀a x. ⟦a ∈ J; x ∈ carrier R⟧ ⟹ x ⊗ a ∈ J; ⋀a x. ⟦a ∈ J; x ∈ carrier R⟧ ⟹ a ⊗ x ∈ J; J ∈ S; ∀I∈S. x ∈ I; y ∈ carrier R⟧ ⟹ y ⊗ x ∈ J› 2. ‹⟦⋀a x. ⟦a ∈ J; x ∈ carrier R⟧ ⟹ x ⊗ a ∈ J; ⋀a x. ⟦a ∈ J; x ∈ carrier R⟧ ⟹ a ⊗ x ∈ J; J ∈ S; ∀I∈S. x ∈ I; y ∈ carrier R⟧ ⟹ x ⊗ y ∈ J› discuss goal 1*) apply blast (*discuss goal 2*) apply blast (*proven 2 subgoals*) . } moreover { fix x assume "∀I∈S. x ∈ I" (*‹∀I::'a set∈S::'a set set. (x::'a) ∈ I›*) obtain I0 where I0S: "I0 ∈ S" (*goal: ‹(⋀I0. I0 ∈ S ⟹ thesis) ⟹ thesis›*) using notempty (*‹S ≠ {}›*) by blast interpret ideal I0 R by (rule Sideals[OF I0S] (*‹ideal I0 R›*)) have "x ∈ I0" by (simp add: I0S (*‹I0 ∈ S›*) ‹∀I∈S. x ∈ I›) with a_subset (*‹(I0::'a set) ⊆ carrier R›*) have "x ∈ carrier R" by fast } ultimately show "?thesis" (*goal: ‹ideal (⋂ (S::'a set set)) R›*) apply unfold_locales (*goals: 1. ‹⟦⋀x y J. ⟦∀I∈S. x ∈ I; ∀I∈S. y ∈ I; J ∈ S⟧ ⟹ x ⊕ y ∈ J; ⋀J. J ∈ S ⟹ 𝟬 ∈ J; ⋀x J. ⟦∀I∈S. x ∈ I; J ∈ S⟧ ⟹ ⊖ x ∈ J; ⋀x y J. ⟦∀I∈S. x ∈ I; y ∈ carrier R; J ∈ S⟧ ⟹ y ⊗ x ∈ J; ⋀x y J. ⟦∀I∈S. x ∈ I; y ∈ carrier R; J ∈ S⟧ ⟹ x ⊗ y ∈ J; ⋀x. ∀I∈S. x ∈ I ⟹ x ∈ carrier R⟧ ⟹ ⋂ S ⊆ carrier (add_monoid R)› 2. ‹⋀x y. ⟦⋀x y J. ⟦∀I∈S. x ∈ I; ∀I∈S. y ∈ I; J ∈ S⟧ ⟹ x ⊕ y ∈ J; ⋀J. J ∈ S ⟹ 𝟬 ∈ J; ⋀x J. ⟦∀I∈S. x ∈ I; J ∈ S⟧ ⟹ ⊖ x ∈ J; ⋀x y J. ⟦∀I∈S. x ∈ I; y ∈ carrier R; J ∈ S⟧ ⟹ y ⊗ x ∈ J; ⋀x y J. ⟦∀I∈S. x ∈ I; y ∈ carrier R; J ∈ S⟧ ⟹ x ⊗ y ∈ J; ⋀x. ∀I∈S. x ∈ I ⟹ x ∈ carrier R; x ∈ ⋂ S; y ∈ ⋂ S⟧ ⟹ x ⊗⇘add_monoid R⇙ y ∈ ⋂ S› 3. ‹⟦⋀x y J. ⟦∀I∈S. x ∈ I; ∀I∈S. y ∈ I; J ∈ S⟧ ⟹ x ⊕ y ∈ J; ⋀J. J ∈ S ⟹ 𝟬 ∈ J; ⋀x J. ⟦∀I∈S. x ∈ I; J ∈ S⟧ ⟹ ⊖ x ∈ J; ⋀x y J. ⟦∀I∈S. x ∈ I; y ∈ carrier R; J ∈ S⟧ ⟹ y ⊗ x ∈ J; ⋀x y J. ⟦∀I∈S. x ∈ I; y ∈ carrier R; J ∈ S⟧ ⟹ x ⊗ y ∈ J; ⋀x. ∀I∈S. x ∈ I ⟹ x ∈ carrier R⟧ ⟹ 𝟭⇘add_monoid R⇙ ∈ ⋂ S› 4. ‹⋀x. ⟦⋀x y J. ⟦∀I∈S. x ∈ I; ∀I∈S. y ∈ I; J ∈ S⟧ ⟹ x ⊕ y ∈ J; ⋀J. J ∈ S ⟹ 𝟬 ∈ J; ⋀x J. ⟦∀I∈S. x ∈ I; J ∈ S⟧ ⟹ ⊖ x ∈ J; ⋀x y J. ⟦∀I∈S. x ∈ I; y ∈ carrier R; J ∈ S⟧ ⟹ y ⊗ x ∈ J; ⋀x y J. ⟦∀I∈S. x ∈ I; y ∈ carrier R; J ∈ S⟧ ⟹ x ⊗ y ∈ J; ⋀x. ∀I∈S. x ∈ I ⟹ x ∈ carrier R; x ∈ ⋂ S⟧ ⟹ inv⇘add_monoid R⇙ x ∈ ⋂ S› 5. ‹⋀a x. ⟦⋀x y J. ⟦∀I∈S. x ∈ I; ∀I∈S. y ∈ I; J ∈ S⟧ ⟹ x ⊕ y ∈ J; ⋀J. J ∈ S ⟹ 𝟬 ∈ J; ⋀x J. ⟦∀I∈S. x ∈ I; J ∈ S⟧ ⟹ ⊖ x ∈ J; ⋀x y J. ⟦∀I∈S. x ∈ I; y ∈ carrier R; J ∈ S⟧ ⟹ y ⊗ x ∈ J; ⋀x y J. ⟦∀I∈S. x ∈ I; y ∈ carrier R; J ∈ S⟧ ⟹ x ⊗ y ∈ J; ⋀x. ∀I∈S. x ∈ I ⟹ x ∈ carrier R; a ∈ ⋂ S; x ∈ carrier R⟧ ⟹ x ⊗ a ∈ ⋂ S› 6. ‹⋀a x. ⟦⋀x y J. ⟦∀I∈S. x ∈ I; ∀I∈S. y ∈ I; J ∈ S⟧ ⟹ x ⊕ y ∈ J; ⋀J. J ∈ S ⟹ 𝟬 ∈ J; ⋀x J. ⟦∀I∈S. x ∈ I; J ∈ S⟧ ⟹ ⊖ x ∈ J; ⋀x y J. ⟦∀I∈S. x ∈ I; y ∈ carrier R; J ∈ S⟧ ⟹ y ⊗ x ∈ J; ⋀x y J. ⟦∀I∈S. x ∈ I; y ∈ carrier R; J ∈ S⟧ ⟹ x ⊗ y ∈ J; ⋀x. ∀I∈S. x ∈ I ⟹ x ∈ carrier R; a ∈ ⋂ S; x ∈ carrier R⟧ ⟹ a ⊗ x ∈ ⋂ S› discuss goal 1*) apply ((auto simp: Inter_eq (*‹⋂ (?A::?'a::type set set) = {x::?'a::type. ∀B::?'a::type set∈?A. x ∈ B}›*) simp flip: a_inv_def (*‹a_inv (?R::(?'a, ?'m) ring_scheme) = m_inv (add_monoid ?R)›*))[1]) (*discuss goal 2*) apply ((auto simp: Inter_eq (*‹⋂ ?A = {x. ∀B∈?A. x ∈ B}›*) simp flip: a_inv_def (*‹a_inv ?R = m_inv (add_monoid ?R)›*))[1]) (*discuss goal 3*) apply ((auto simp: Inter_eq (*‹⋂ ?A = {x. ∀B∈?A. x ∈ B}›*) simp flip: a_inv_def (*‹a_inv ?R = m_inv (add_monoid ?R)›*))[1]) (*discuss goal 4*) apply ((auto simp: Inter_eq (*‹⋂ ?A = {x. ∀B∈?A. x ∈ B}›*) simp flip: a_inv_def (*‹a_inv ?R = m_inv (add_monoid ?R)›*))[1]) (*discuss goal 5*) apply ((auto simp: Inter_eq (*‹⋂ ?A = {x. ∀B∈?A. x ∈ B}›*) simp flip: a_inv_def (*‹a_inv ?R = m_inv (add_monoid ?R)›*))[1]) (*discuss goal 6*) apply ((auto simp: Inter_eq (*‹⋂ ?A = {x. ∀B∈?A. x ∈ B}›*) simp flip: a_inv_def (*‹a_inv ?R = m_inv (add_monoid ?R)›*))[1]) (*proven 6 subgoals*) . qed subsection ‹Addition of Ideals› lemma (in ring) add_ideals: assumes idealI: "ideal I R" and idealJ: "ideal J R" shows "ideal (I <+> J) R" proof (rule ideal.intro (*‹⟦additive_subgroup ?I ?R; ring ?R; ideal_axioms ?I ?R⟧ ⟹ ideal ?I ?R›*)) (*goals: 1. ‹additive_subgroup (I <+> J) R› 2. ‹ring R› 3. ‹ideal_axioms (I <+> J) R›*) show "additive_subgroup (I <+> J) R" by (intro ideal.axioms[OF idealI] (*‹additive_subgroup (I::'a::type set) R› ‹ring R› ‹ideal_axioms (I::'a::type set) R›*) ideal.axioms[OF idealJ] (*‹additive_subgroup (J::'a::type set) R› ‹ring R› ‹ideal_axioms (J::'a::type set) R›*) add_additive_subgroups (*‹⟦additive_subgroup (?H::'a::type set) R; additive_subgroup (?K::'a::type set) R⟧ ⟹ additive_subgroup (?H <+> ?K) R›*)) show "ring R" by (rule ring_axioms (*‹ring R›*)) show "ideal_axioms (I <+> J) R" proof (-) (*goal: ‹ideal_axioms (I <+> J) R›*) { fix x and i and j assume xcarr: "x ∈ carrier R" and iI: "i ∈ I" and jJ: "j ∈ J" (*‹(x::'a) ∈ carrier R› ‹(i::'a) ∈ (I::'a set)› ‹(j::'a) ∈ (J::'a set)›*) from xcarr (*‹(x::'a) ∈ carrier R›*) ideal.Icarr[OF idealI iI] (*‹i ∈ carrier R›*) ideal.Icarr[OF idealJ jJ] (*‹j ∈ carrier R›*) have "∃h∈I. ∃k∈J. (i ⊕ j) ⊗ x = h ⊕ k" by (meson iI (*‹i ∈ I›*) ideal.I_r_closed (*‹⟦ideal ?I ?R; ?a ∈ ?I; ?x ∈ carrier ?R⟧ ⟹ ?a ⊗⇘?R⇙ ?x ∈ ?I›*) idealJ (*‹ideal J R›*) jJ (*‹j ∈ J›*) l_distr (*‹⟦?x ∈ carrier R; ?y ∈ carrier R; ?z ∈ carrier R⟧ ⟹ (?x ⊕ ?y) ⊗ ?z = ?x ⊗ ?z ⊕ ?y ⊗ ?z›*) local.idealI (*‹ideal I R›*)) } moreover { fix x and i and j assume xcarr: "x ∈ carrier R" and iI: "i ∈ I" and jJ: "j ∈ J" (*‹(x::'a) ∈ carrier R› ‹(i::'a) ∈ (I::'a set)› ‹(j::'a) ∈ (J::'a set)›*) from xcarr (*‹(x::'a::type) ∈ carrier R›*) ideal.Icarr[OF idealI iI] (*‹i ∈ carrier R›*) ideal.Icarr[OF idealJ jJ] (*‹j ∈ carrier R›*) have "∃h∈I. ∃k∈J. x ⊗ (i ⊕ j) = h ⊕ k" by (meson iI (*‹i ∈ I›*) ideal.I_l_closed (*‹⟦ideal ?I ?R; ?a ∈ ?I; ?x ∈ carrier ?R⟧ ⟹ ?x ⊗⇘?R⇙ ?a ∈ ?I›*) idealJ (*‹ideal J R›*) jJ (*‹j ∈ J›*) local.idealI (*‹ideal I R›*) r_distr (*‹⟦?x ∈ carrier R; ?y ∈ carrier R; ?z ∈ carrier R⟧ ⟹ ?z ⊗ (?x ⊕ ?y) = ?z ⊗ ?x ⊕ ?z ⊗ ?y›*)) } ultimately show "ideal_axioms (I <+> J) R" apply (intro ideal_axioms.intro (*‹⟦⋀a x. ⟦a ∈ ?I; x ∈ carrier ?R⟧ ⟹ x ⊗⇘?R⇙ a ∈ ?I; ⋀a x. ⟦a ∈ ?I; x ∈ carrier ?R⟧ ⟹ a ⊗⇘?R⇙ x ∈ ?I⟧ ⟹ ideal_axioms ?I ?R›*)) (*goals: 1. ‹⋀a x. ⟦⋀x i j. ⟦x ∈ carrier R; i ∈ I; j ∈ J⟧ ⟹ ∃h∈I. ∃k∈J. (i ⊕ j) ⊗ x = h ⊕ k; ⋀x i j. ⟦x ∈ carrier R; i ∈ I; j ∈ J⟧ ⟹ ∃h∈I. ∃k∈J. x ⊗ (i ⊕ j) = h ⊕ k; a ∈ I <+> J; x ∈ carrier R⟧ ⟹ x ⊗ a ∈ I <+> J› 2. ‹⋀a x. ⟦⋀x i j. ⟦x ∈ carrier R; i ∈ I; j ∈ J⟧ ⟹ ∃h∈I. ∃k∈J. (i ⊕ j) ⊗ x = h ⊕ k; ⋀x i j. ⟦x ∈ carrier R; i ∈ I; j ∈ J⟧ ⟹ ∃h∈I. ∃k∈J. x ⊗ (i ⊕ j) = h ⊕ k; a ∈ I <+> J; x ∈ carrier R⟧ ⟹ a ⊗ x ∈ I <+> J› discuss goal 1*) apply ((auto simp: set_add_defs (*‹(<+>⇘?G⇙) = (<#>⇘add_monoid ?G⇙)› ‹?H <#>⇘?G⇙ ?K = (⋃h∈?H. ⋃k∈?K. {h ⊗⇘?G⇙ k})›*))[1]) (*discuss goal 2*) apply ((auto simp: set_add_defs (*‹(<+>⇘?G⇙) = (<#>⇘add_monoid ?G⇙)› ‹?H <#>⇘?G⇙ ?K = (⋃h∈?H. ⋃k∈?K. {h ⊗⇘?G⇙ k})›*))[1]) (*proven 2 subgoals*) . qed qed subsection (in ring) ‹Ideals generated by a subset of \<^term>‹carrier R›› text ‹\<^term>‹genideal› generates an ideal› lemma (in ring) genideal_ideal: assumes Scarr: "S ⊆ carrier R" shows "ideal (Idl S) R" unfolding genideal_def (*goal: ‹ideal (⋂ {I. ideal I R ∧ S ⊆ I}) R›*) proof (rule i_Intersect (*‹⟦⋀I::'a set. I ∈ (?S::'a set set) ⟹ ideal I R; ?S ≠ {}⟧ ⟹ ideal (⋂ ?S) R›*), fast, simp) (*goal: ‹∃x. ideal x R ∧ S ⊆ x›*) from oneideal (*‹ideal (carrier R) R›*) Scarr (*‹S ⊆ carrier R›*) show "∃I. ideal I R ∧ S ≤ I" by fast qed lemma (in ring) genideal_self: assumes "S ⊆ carrier R" shows "S ⊆ Idl S" unfolding genideal_def (*goal: ‹S ⊆ ⋂ {I. ideal I R ∧ S ⊆ I}›*) by fast lemma (in ring) genideal_self': assumes carr: "i ∈ carrier R" shows "i ∈ Idl {i}" by (simp add: genideal_def (*‹Idl⇘?R⇙ ?S = ⋂ {I. ideal I ?R ∧ ?S ⊆ I}›*)) text ‹\<^term>‹genideal› generates the minimal ideal› lemma (in ring) genideal_minimal: assumes "ideal I R" "S ⊆ I" shows "Idl S ⊆ I" unfolding genideal_def (*goal: ‹⋂ {I. ideal I R ∧ S ⊆ I} ⊆ I›*) apply rule (*goal: ‹⋂ {I. ideal I R ∧ S ⊆ I} ⊆ I›*) apply (elim InterD (*‹⟦?A ∈ ⋂ ?C; ?X ∈ ?C⟧ ⟹ ?A ∈ ?X›*)) (*goal: ‹⋀x. x ∈ ⋂ {I. ideal I R ∧ S ⊆ I} ⟹ x ∈ I›*) by (simp add: assms (*‹ideal (I::'a set) R› ‹(S::'a set) ⊆ (I::'a set)›*)) text ‹Generated ideals and subsets› lemma (in ring) Idl_subset_ideal: assumes Iideal: "ideal I R" and Hcarr: "H ⊆ carrier R" shows "(Idl H ⊆ I) = (H ⊆ I)" proof (standard) (*goals: 1. ‹Idl H ⊆ I ⟹ H ⊆ I› 2. ‹H ⊆ I ⟹ Idl H ⊆ I›*) assume a: "Idl H ⊆ I" (*‹Idl (H::'a set) ⊆ (I::'a set)›*) from Hcarr (*‹H ⊆ carrier R›*) have "H ⊆ Idl H" by (rule genideal_self (*‹?S ⊆ carrier R ⟹ ?S ⊆ Idl ?S›*)) with a (*‹Idl H ⊆ I›*) show "H ⊆ I" by simp next (*goal: ‹H ⊆ I ⟹ Idl H ⊆ I›*) fix x assume "H ⊆ I" (*‹(H::'a set) ⊆ (I::'a set)›*) with Iideal (*‹ideal I R›*) have "I ∈ {I. ideal I R ∧ H ⊆ I}" by fast then show "Idl H ⊆ I" unfolding genideal_def (*goal: ‹⋂ {I. ideal I R ∧ H ⊆ I} ⊆ I›*) by fast qed lemma (in ring) subset_Idl_subset: assumes Icarr: "I ⊆ carrier R" and HI: "H ⊆ I" shows "Idl H ⊆ Idl I" proof (-) (*goal: ‹Idl H ⊆ Idl I›*) from Icarr (*‹(I::'a::type set) ⊆ carrier R›*) have Iideal: "ideal (Idl I) R" by (rule genideal_ideal (*‹?S ⊆ carrier R ⟹ ideal (Idl ?S) R›*)) from HI (*‹H ⊆ I›*) Icarr (*‹I ⊆ carrier R›*) have "H ⊆ carrier R" by fast with Iideal (*‹ideal (Idl I) R›*) have "(H ⊆ Idl I) = (Idl H ⊆ Idl I)" by (rule Idl_subset_ideal[symmetric] (*‹⟦ideal ?I R; ?H ⊆ carrier R⟧ ⟹ (?H ⊆ ?I) = (Idl ?H ⊆ ?I)›*)) then show "Idl H ⊆ Idl I" by (meson HI (*‹(H::'a set) ⊆ (I::'a set)›*) Icarr (*‹(I::'a set) ⊆ carrier R›*) genideal_self (*‹(?S::'a set) ⊆ carrier R ⟹ ?S ⊆ Idl ?S›*) order_trans (*‹⟦(?x::?'a) ≤ (?y::?'a); ?y ≤ (?z::?'a)⟧ ⟹ ?x ≤ ?z›*)) qed lemma (in ring) Idl_subset_ideal': assumes acarr: "a ∈ carrier R" and bcarr: "b ∈ carrier R" shows "Idl {a} ⊆ Idl {b} ⟷ a ∈ Idl {b}" proof (-) (*goal: ‹(Idl {a} ⊆ Idl {b}) = (a ∈ Idl {b})›*) have "Idl {a} ⊆ Idl {b} ⟷ {a} ⊆ Idl {b}" by (simp add: Idl_subset_ideal (*‹⟦ideal ?I R; ?H ⊆ carrier R⟧ ⟹ (Idl ?H ⊆ ?I) = (?H ⊆ ?I)›*) acarr (*‹a ∈ carrier R›*) bcarr (*‹b ∈ carrier R›*) genideal_ideal (*‹?S ⊆ carrier R ⟹ ideal (Idl ?S) R›*)) also (*calculation: ‹(Idl {a} ⊆ Idl {b}) = ({a} ⊆ Idl {b})›*) have "… ⟷ a ∈ Idl {b}" by blast finally (*calculation: ‹(Idl {a} ⊆ Idl {b}) = (a ∈ Idl {b})›*) show "?thesis" (*goal: ‹(Idl {a} ⊆ Idl {b}) = (a ∈ Idl {b})›*) . qed lemma (in ring) genideal_zero: "Idl {𝟬} = {𝟬}" proof (standard) (*goals: 1. ‹Idl {𝟬} ⊆ {𝟬}› 2. ‹{𝟬} ⊆ Idl {𝟬}›*) show "Idl {𝟬} ⊆ {𝟬}" by (simp add: genideal_minimal (*‹⟦ideal ?I R; ?S ⊆ ?I⟧ ⟹ Idl ?S ⊆ ?I›*) zeroideal (*‹ideal {𝟬} R›*)) show "{𝟬} ⊆ Idl {𝟬}" by (simp add: genideal_self' (*‹?i ∈ carrier R ⟹ ?i ∈ Idl {?i}›*)) qed lemma (in ring) genideal_one: "Idl {𝟭} = carrier R" proof (-) (*goal: ‹Idl {𝟭} = carrier R›*) interpret ideal "Idl {𝟭}" R apply (rule genideal_ideal (*‹?S ⊆ carrier R ⟹ ideal (Idl ?S) R›*)) (*goal: ‹ideal (Idl {𝟭}) R›*) by fast show "Idl {𝟭} = carrier R" using genideal_self' (*‹?i ∈ carrier R ⟹ ?i ∈ Idl {?i}›*) one_imp_carrier (*‹𝟭 ∈ Idl {𝟭} ⟹ Idl {𝟭} = carrier R›*) by blast qed text ‹Generation of Principal Ideals in Commutative Rings› definition cgenideal :: "_ ⇒ 'a ⇒ 'a set" ("PIdlı _" [80] 79) where "cgenideal R a = {x ⊗⇘R⇙ a | x. x ∈ carrier R}" text ‹genhideal (?) really generates an ideal› lemma (in cring) cgenideal_ideal: assumes acarr: "a ∈ carrier R" shows "ideal (PIdl a) R" unfolding cgenideal_def (*goal: ‹ideal {x ⊗ (a::'a::type) |x::'a::type. x ∈ carrier R} R›*) proof (intro subgroup.intro (*‹⟦?H ⊆ carrier ?G; ⋀x y. ⟦x ∈ ?H; y ∈ ?H⟧ ⟹ x ⊗⇘?G⇙ y ∈ ?H; 𝟭⇘?G⇙ ∈ ?H; ⋀x. x ∈ ?H ⟹ inv⇘?G⇙ x ∈ ?H⟧ ⟹ subgroup ?H ?G›*) idealI[OF ring_axioms] (*‹⟦subgroup ?I (add_monoid R); ⋀a x. ⟦a ∈ ?I; x ∈ carrier R⟧ ⟹ x ⊗ a ∈ ?I; ⋀a x. ⟦a ∈ ?I; x ∈ carrier R⟧ ⟹ a ⊗ x ∈ ?I⟧ ⟹ ideal ?I R›*), simp_all) (*goals: 1. ‹{x ⊗ a |x. x ∈ carrier R} ⊆ carrier R› 2. ‹⋀x y. ⟦∃xa. x = xa ⊗ a ∧ xa ∈ carrier R; ∃x. y = x ⊗ a ∧ x ∈ carrier R⟧ ⟹ ∃xa. x ⊕ y = xa ⊗ a ∧ xa ∈ carrier R› 3. ‹∃x. 𝟬 = x ⊗ a ∧ x ∈ carrier R› 4. ‹⋀x. ∃xa. x = xa ⊗ a ∧ xa ∈ carrier R ⟹ ∃xa. inv⇘add_monoid R⇙ x = xa ⊗ a ∧ xa ∈ carrier R› 5. ‹⋀aa x. ⟦∃x. aa = x ⊗ a ∧ x ∈ carrier R; x ∈ carrier R⟧ ⟹ ∃xa. x ⊗ aa = xa ⊗ a ∧ xa ∈ carrier R› 6. ‹⋀aa x. ⟦∃x. aa = x ⊗ a ∧ x ∈ carrier R; x ∈ carrier R⟧ ⟹ ∃xa. aa ⊗ x = xa ⊗ a ∧ xa ∈ carrier R›*) show "{x ⊗ a |x. x ∈ carrier R} ⊆ carrier R" by (blast intro: acarr (*‹a ∈ carrier R›*)) show "⋀x y. ⟦∃u. x = u ⊗ a ∧ u ∈ carrier R; ∃x. y = x ⊗ a ∧ x ∈ carrier R⟧ ⟹ ∃v. x ⊕ y = v ⊗ a ∧ v ∈ carrier R" by (metis assms (*‹a ∈ carrier R›*) cring.cring_simprules( (*‹⟦cring ?R; ?x ∈ carrier ?R; ?y ∈ carrier ?R⟧ ⟹ ?x ⊕⇘?R⇙ ?y ∈ carrier ?R›*) 1) is_cring (*‹cring R›*) l_distr (*‹⟦?x ∈ carrier R; ?y ∈ carrier R; ?z ∈ carrier R⟧ ⟹ (?x ⊕ ?y) ⊗ ?z = ?x ⊗ ?z ⊕ ?y ⊗ ?z›*)) show "∃x. 𝟬 = x ⊗ a ∧ x ∈ carrier R" by (metis assms (*‹a ∈ carrier R›*) l_null (*‹?x ∈ carrier R ⟹ 𝟬 ⊗ ?x = 𝟬›*) zero_closed (*‹𝟬 ∈ carrier R›*)) show "⋀x. ∃u. x = u ⊗ a ∧ u ∈ carrier R ⟹ ∃v. inv⇘add_monoid R⇙ x = v ⊗ a ∧ v ∈ carrier R" by (metis a_inv_def (*‹a_inv (?R::(?'a, ?'m) ring_scheme) = m_inv (add_monoid ?R)›*) add.inv_closed (*‹(?x::'a::type) ∈ carrier R ⟹ ⊖ ?x ∈ carrier R›*) assms (*‹(a::'a::type) ∈ carrier R›*) l_minus (*‹⟦(?x::'a::type) ∈ carrier R; (?y::'a::type) ∈ carrier R⟧ ⟹ ⊖ ?x ⊗ ?y = ⊖ (?x ⊗ ?y)›*)) show "⋀b x. ⟦∃x. b = x ⊗ a ∧ x ∈ carrier R; x ∈ carrier R⟧ ⟹ ∃z. x ⊗ b = z ⊗ a ∧ z ∈ carrier R" by (metis assms (*‹a ∈ carrier R›*) m_assoc (*‹⟦?x ∈ carrier R; ?y ∈ carrier R; ?z ∈ carrier R⟧ ⟹ ?x ⊗ ?y ⊗ ?z = ?x ⊗ (?y ⊗ ?z)›*) m_closed (*‹⟦?x ∈ carrier R; ?y ∈ carrier R⟧ ⟹ ?x ⊗ ?y ∈ carrier R›*)) show "⋀b x. ⟦∃x. b = x ⊗ a ∧ x ∈ carrier R; x ∈ carrier R⟧ ⟹ ∃z. b ⊗ x = z ⊗ a ∧ z ∈ carrier R" by (metis assms (*‹a ∈ carrier R›*) m_assoc (*‹⟦?x ∈ carrier R; ?y ∈ carrier R; ?z ∈ carrier R⟧ ⟹ ?x ⊗ ?y ⊗ ?z = ?x ⊗ (?y ⊗ ?z)›*) m_comm (*‹⟦?x ∈ carrier R; ?y ∈ carrier R⟧ ⟹ ?x ⊗ ?y = ?y ⊗ ?x›*) m_closed (*‹⟦?x ∈ carrier R; ?y ∈ carrier R⟧ ⟹ ?x ⊗ ?y ∈ carrier R›*)) qed lemma (in ring) cgenideal_self: assumes icarr: "i ∈ carrier R" shows "i ∈ PIdl i" unfolding cgenideal_def (*goal: ‹(i::'a) ∈ {x ⊗ i |x::'a. x ∈ carrier R}›*) proof (simp) (*goal: ‹∃x. i = x ⊗ i ∧ x ∈ carrier R›*) from icarr (*‹i ∈ carrier R›*) have "i = 𝟭 ⊗ i" by simp with icarr (*‹i ∈ carrier R›*) show "∃x. i = x ⊗ i ∧ x ∈ carrier R" by fast qed text ‹\<^const>‹cgenideal› is minimal› lemma (in ring) cgenideal_minimal: assumes "ideal J R" assumes aJ: "a ∈ J" shows "PIdl a ⊆ J" proof (-) (*goal: ‹PIdl (a::'a) ⊆ (J::'a set)›*) interpret ideal J R by fact show "?thesis" (*goal: ‹PIdl a ⊆ J›*) unfolding cgenideal_def (*goal: ‹{x ⊗ a |x. x ∈ carrier R} ⊆ J›*) using I_l_closed (*‹⟦?a ∈ J; ?x ∈ carrier R⟧ ⟹ ?x ⊗ ?a ∈ J›*) aJ (*‹a ∈ J›*) by blast qed lemma (in cring) cgenideal_eq_genideal: assumes icarr: "i ∈ carrier R" shows "PIdl i = Idl {i}" proof (standard) (*goals: 1. ‹PIdl (i::'a) ⊆ Idl {i}› 2. ‹Idl {i::'a} ⊆ PIdl i›*) show "PIdl i ⊆ Idl {i}" by (simp add: cgenideal_minimal (*‹⟦ideal ?J R; ?a ∈ ?J⟧ ⟹ PIdl ?a ⊆ ?J›*) genideal_ideal (*‹?S ⊆ carrier R ⟹ ideal (Idl ?S) R›*) genideal_self' (*‹?i ∈ carrier R ⟹ ?i ∈ Idl {?i}›*) icarr (*‹i ∈ carrier R›*)) show "Idl {i} ⊆ PIdl i" by (simp add: cgenideal_ideal (*‹?a ∈ carrier R ⟹ ideal (PIdl ?a) R›*) cgenideal_self (*‹?i ∈ carrier R ⟹ ?i ∈ PIdl ?i›*) genideal_minimal (*‹⟦ideal ?I R; ?S ⊆ ?I⟧ ⟹ Idl ?S ⊆ ?I›*) icarr (*‹i ∈ carrier R›*)) qed lemma (in cring) cgenideal_eq_rcos: "PIdl i = carrier R #> i" unfolding cgenideal_def r_coset_def (*goal: ‹{x ⊗ i |x. x ∈ carrier R} = (⋃h∈carrier R. {h ⊗ i})›*) by fast lemma (in cring) cgenideal_is_principalideal: assumes "i ∈ carrier R" shows "principalideal (PIdl i) R" proof (-) (*goal: ‹principalideal (PIdl i) R›*) have "∃i'∈carrier R. PIdl i = Idl {i'}" using cgenideal_eq_genideal (*‹?i ∈ carrier R ⟹ PIdl ?i = Idl {?i}›*) assms (*‹i ∈ carrier R›*) by auto then show "?thesis" (*goal: ‹principalideal (PIdl i) R›*) by (simp add: cgenideal_ideal (*‹(?a::'a) ∈ carrier R ⟹ ideal (PIdl ?a) R›*) assms (*‹(i::'a) ∈ carrier R›*) principalidealI (*‹⟦ideal (?I::?'a set) (?R::(?'a, ?'b) ring_scheme); ∃i::?'a∈carrier ?R. ?I = Idl⇘?R⇙ {i}⟧ ⟹ principalideal ?I ?R›*)) qed subsection ‹Union of Ideals› lemma (in ring) union_genideal: assumes idealI: "ideal I R" and idealJ: "ideal J R" shows "Idl (I ∪ J) = I <+> J" proof (standard) (*goals: 1. ‹Idl (I ∪ J) ⊆ I <+> J› 2. ‹I <+> J ⊆ Idl (I ∪ J)›*) show "Idl (I ∪ J) ⊆ I <+> J" proof (rule ring.genideal_minimal [OF ring_axioms] (*‹⟦ideal ?I R; ?S ⊆ ?I⟧ ⟹ Idl ?S ⊆ ?I›*)) (*goals: 1. ‹ideal (I <+> J) R› 2. ‹I ∪ J ⊆ I <+> J›*) show "ideal (I <+> J) R" by (rule add_ideals[OF idealI idealJ] (*‹ideal ((I::'a set) <+> (J::'a set)) R›*)) have "⋀x. x ∈ I ⟹ ∃xa∈I. ∃xb∈J. x = xa ⊕ xb" by (metis additive_subgroup.zero_closed (*‹additive_subgroup ?H ?G ⟹ 𝟬⇘?G⇙ ∈ ?H›*) ideal.Icarr (*‹⟦ideal ?I ?R; ?i ∈ ?I⟧ ⟹ ?i ∈ carrier ?R›*) idealJ (*‹ideal J R›*) ideal_def (*‹ideal ?I ?R ≡ additive_subgroup ?I ?R ∧ ring ?R ∧ ideal_axioms ?I ?R›*) local.idealI (*‹ideal I R›*) r_zero (*‹?x ∈ carrier R ⟹ ?x ⊕ 𝟬 = ?x›*)) moreover have "⋀x. x ∈ J ⟹ ∃xa∈I. ∃xb∈J. x = xa ⊕ xb" by (metis additive_subgroup.zero_closed (*‹additive_subgroup ?H ?G ⟹ 𝟬⇘?G⇙ ∈ ?H›*) ideal.Icarr (*‹⟦ideal ?I ?R; ?i ∈ ?I⟧ ⟹ ?i ∈ carrier ?R›*) idealJ (*‹ideal J R›*) ideal_def (*‹ideal ?I ?R ≡ additive_subgroup ?I ?R ∧ ring ?R ∧ ideal_axioms ?I ?R›*) l_zero (*‹?x ∈ carrier R ⟹ 𝟬 ⊕ ?x = ?x›*) local.idealI (*‹ideal I R›*)) ultimately show "I ∪ J ⊆ I <+> J" by (auto simp: set_add_defs (*‹(<+>⇘?G⇙) = (<#>⇘add_monoid ?G⇙)› ‹?H <#>⇘?G⇙ ?K = (⋃h∈?H. ⋃k∈?K. {h ⊗⇘?G⇙ k})›*)) qed next (*goal: ‹I <+> J ⊆ Idl (I ∪ J)›*) show "I <+> J ⊆ Idl (I ∪ J)" by (auto simp: set_add_defs (*‹(<+>⇘?G::(?'a, ?'b) ring_scheme⇙) = (<#>⇘add_monoid ?G⇙)› ‹(?H::?'a set) <#>⇘?G::(?'a, ?'b) monoid_scheme⇙ (?K::?'a set) = (⋃h::?'a∈?H. ⋃k::?'a∈?K. {h ⊗⇘?G⇙ k})›*) genideal_def (*‹Idl⇘?R::(?'a, ?'b) ring_scheme⇙ (?S::?'a set) = ⋂ {I::?'a set. ideal I ?R ∧ ?S ⊆ I}›*) additive_subgroup.a_closed (*‹⟦additive_subgroup (?H::?'a set) (?G::(?'a, ?'b) ring_scheme); (?x::?'a) ∈ ?H; (?y::?'a) ∈ ?H⟧ ⟹ ?x ⊕⇘?G⇙ ?y ∈ ?H›*) ideal_def (*‹ideal (?I::?'a set) (?R::(?'a, ?'b) ring_scheme) ≡ additive_subgroup ?I ?R ∧ ring ?R ∧ ideal_axioms ?I ?R›*) subsetD (*‹⟦(?A::?'a set) ⊆ (?B::?'a set); (?c::?'a) ∈ ?A⟧ ⟹ ?c ∈ ?B›*)) qed subsection ‹Properties of Principal Ideals› text ‹The zero ideal is a principal ideal› corollary (in ring) zeropideal: "principalideal {𝟬} R" using genideal_zero (*‹Idl {𝟬} = {𝟬}›*) principalidealI (*‹⟦ideal ?I ?R; ∃i∈carrier ?R. ?I = Idl⇘?R⇙ {i}⟧ ⟹ principalideal ?I ?R›*) zeroideal (*‹ideal {𝟬} R›*) by blast text ‹The unit ideal is a principal ideal› corollary (in ring) onepideal: "principalideal (carrier R) R" using genideal_one (*‹Idl {𝟭} = carrier R›*) oneideal (*‹ideal (carrier R) R›*) principalidealI (*‹⟦ideal ?I ?R; ∃i∈carrier ?R. ?I = Idl⇘?R⇙ {i}⟧ ⟹ principalideal ?I ?R›*) by blast text ‹Every principal ideal is a right coset of the carrier› lemma (in principalideal) rcos_generate: assumes "cring R" shows "∃x∈I. I = carrier R #> x" proof (-) (*goal: ‹∃x∈I. I = carrier R #> x›*) interpret cring R by fact from generate (*‹∃i∈carrier R. I = Idl {i}›*) obtain i where icarr: "i ∈ carrier R" and I1: "I = Idl {i}" (*goal: ‹(⋀i. ⟦i ∈ carrier R; I = Idl {i}⟧ ⟹ thesis) ⟹ thesis›*) by fast then have "I = PIdl i" by (simp add: cgenideal_eq_genideal (*‹?i ∈ carrier R ⟹ PIdl ?i = Idl {?i}›*)) moreover have "i ∈ I" by (simp add: I1 (*‹I = Idl {i}›*) genideal_self' (*‹?i ∈ carrier R ⟹ ?i ∈ Idl {?i}›*) icarr (*‹i ∈ carrier R›*)) moreover have "PIdl i = carrier R #> i" unfolding cgenideal_def r_coset_def (*goal: ‹{x ⊗ i |x. x ∈ carrier R} = (⋃h∈carrier R. {h ⊗ i})›*) by fast ultimately show "∃x∈I. I = carrier R #> x" by fast qed text ‹This next lemma would be trivial if placed in a theory that imports QuotRing, but it makes more sense to have it here (easier to find and coherent with the previous developments).› lemma (in cring) cgenideal_prod: ✐‹contributor ‹Paulo Emílio de Vilhena›› assumes "a ∈ carrier R" "b ∈ carrier R" shows "(PIdl a) <#> (PIdl b) = PIdl (a ⊗ b)" proof (-) (*goal: ‹PIdl a <#> PIdl b = PIdl (a ⊗ b)›*) have "(carrier R #> a) <#> (carrier R #> b) = carrier R #> (a ⊗ b)" proof (standard) (*goals: 1. ‹carrier R #> a <#> (carrier R #> b) ⊆ carrier R #> a ⊗ b› 2. ‹carrier R #> a ⊗ b ⊆ carrier R #> a <#> (carrier R #> b)›*) show "(carrier R #> a) <#> (carrier R #> b) ⊆ carrier R #> a ⊗ b" proof (standard) (*goal: ‹⋀x. x ∈ carrier R #> a <#> (carrier R #> b) ⟹ x ∈ carrier R #> a ⊗ b›*) fix x assume "x ∈ (carrier R #> a) <#> (carrier R #> b)" (*‹(x::'a) ∈ carrier R #> (a::'a) <#> (carrier R #> (b::'a))›*) then obtain r1 and r2 where r1: "r1 ∈ carrier R" and r2: "r2 ∈ carrier R" and "x = (r1 ⊗ a) ⊗ (r2 ⊗ b)" (*goal: ‹(⋀r1 r2. ⟦r1 ∈ carrier R; r2 ∈ carrier R; x = r1 ⊗ a ⊗ (r2 ⊗ b)⟧ ⟹ thesis) ⟹ thesis›*) unfolding set_mult_def r_coset_def (*goal: ‹(⋀r1 r2. ⟦r1 ∈ carrier R; r2 ∈ carrier R; x = r1 ⊗ a ⊗ (r2 ⊗ b)⟧ ⟹ thesis) ⟹ thesis›*) by blast hence "x = (r1 ⊗ r2) ⊗ (a ⊗ b)" by (simp add: assms (*‹a ∈ carrier R› ‹b ∈ carrier R›*) local.ring_axioms (*‹ring R›*) m_lcomm (*‹⟦?x ∈ carrier R; ?y ∈ carrier R; ?z ∈ carrier R⟧ ⟹ ?x ⊗ (?y ⊗ ?z) = ?y ⊗ (?x ⊗ ?z)›*) ring.ring_simprules( (*‹⟦ring ?R; ?x ∈ carrier ?R; ?y ∈ carrier ?R; ?z ∈ carrier ?R⟧ ⟹ ?x ⊗⇘?R⇙ ?y ⊗⇘?R⇙ ?z = ?x ⊗⇘?R⇙ (?y ⊗⇘?R⇙ ?z)›*) 11)) thus "x ∈ carrier R #> a ⊗ b" unfolding r_coset_def (*goal: ‹x ∈ (⋃h∈carrier R. {h ⊗ (a ⊗ b)})›*) using r1 (*‹r1 ∈ carrier R›*) r2 (*‹(r2::'a) ∈ carrier R›*) assms (*‹a ∈ carrier R› ‹b ∈ carrier R›*) by blast qed next (*goal: ‹carrier R #> (a::'a) ⊗ (b::'a) ⊆ carrier R #> a <#> (carrier R #> b)›*) show "carrier R #> a ⊗ b ⊆ (carrier R #> a) <#> (carrier R #> b)" proof (standard) (*goal: ‹⋀x. x ∈ carrier R #> a ⊗ b ⟹ x ∈ carrier R #> a <#> (carrier R #> b)›*) fix x assume "x ∈ carrier R #> a ⊗ b" (*‹(x::'a) ∈ carrier R #> (a::'a) ⊗ (b::'a)›*) then obtain r where r: "r ∈ carrier R" "x = r ⊗ (a ⊗ b)" (*goal: ‹(⋀r. ⟦r ∈ carrier R; x = r ⊗ (a ⊗ b)⟧ ⟹ thesis) ⟹ thesis›*) unfolding r_coset_def (*goal: ‹(⋀r. ⟦r ∈ carrier R; x = r ⊗ (a ⊗ b)⟧ ⟹ thesis) ⟹ thesis›*) by blast hence "x = (r ⊗ a) ⊗ (𝟭 ⊗ b)" using assms (*‹a ∈ carrier R› ‹b ∈ carrier R›*) by (simp add: m_assoc (*‹⟦?x ∈ carrier R; ?y ∈ carrier R; ?z ∈ carrier R⟧ ⟹ ?x ⊗ ?y ⊗ ?z = ?x ⊗ (?y ⊗ ?z)›*)) thus "x ∈ (carrier R #> a) <#> (carrier R #> b)" unfolding set_mult_def r_coset_def (*goal: ‹x ∈ (⋃h∈⋃h∈carrier R. {h ⊗ a}. ⋃k∈⋃h∈carrier R. {h ⊗ b}. {h ⊗ k})›*) using assms (*‹a ∈ carrier R› ‹b ∈ carrier R›*) r (*‹r ∈ carrier R› ‹x = r ⊗ (a ⊗ b)›*) by blast qed qed thus "?thesis" (*goal: ‹PIdl a <#> PIdl b = PIdl (a ⊗ b)›*) using cgenideal_eq_rcos[of a] (*‹PIdl a = carrier R #> a›*) cgenideal_eq_rcos[of b] (*‹PIdl b = carrier R #> b›*) cgenideal_eq_rcos[of "a ⊗ b"] (*‹PIdl (a ⊗ b) = carrier R #> a ⊗ b›*) by simp qed subsection ‹Prime Ideals› lemma (in ideal) primeidealCD: assumes "cring R" assumes notprime: "¬ primeideal I R" shows "carrier R = I ∨ (∃a b. a ∈ carrier R ∧ b ∈ carrier R ∧ a ⊗ b ∈ I ∧ a ∉ I ∧ b ∉ I)" apply (rule ccontr (*‹(¬ ?P ⟹ False) ⟹ ?P›*)) (*goal: ‹carrier R = I ∨ (∃a b. a ∈ carrier R ∧ b ∈ carrier R ∧ a ⊗ b ∈ I ∧ a ∉ I ∧ b ∉ I)›*) proof (clarsimp) (*goal: ‹⟦carrier R ≠ I; ∀a. a ∈ carrier R ⟶ (∀b. a ⊗ b ∈ I ⟶ b ∈ carrier R ⟶ a ∈ I ∨ b ∈ I)⟧ ⟹ False›*) interpret cring R by fact assume InR: "carrier R ≠ I" and "∀a. a ∈ carrier R ⟶ (∀b. a ⊗ b ∈ I ⟶ b ∈ carrier R ⟶ a ∈ I ∨ b ∈ I)" (*‹carrier R ≠ (I::'a set)› ‹∀a::'a. a ∈ carrier R ⟶ (∀b::'a. a ⊗ b ∈ (I::'a set) ⟶ b ∈ carrier R ⟶ a ∈ I ∨ b ∈ I)›*) then have I_prime: "⋀ a b. ⟦a ∈ carrier R; b ∈ carrier R; a ⊗ b ∈ I⟧ ⟹ a ∈ I ∨ b ∈ I" by simp have "primeideal I R" by (simp add: I_prime (*‹⟦?a ∈ carrier R; ?b ∈ carrier R; ?a ⊗ ?b ∈ I⟧ ⟹ ?a ∈ I ∨ ?b ∈ I›*) InR (*‹carrier R ≠ I›*) is_cring (*‹cring R›*) is_ideal (*‹ideal I R›*) 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›*)) with notprime (*‹¬ primeideal I R›*) show False by simp qed lemma (in ideal) primeidealCE: assumes "cring R" assumes notprime: "¬ primeideal I R" obtains "carrier R = I" | "∃a b. a ∈ carrier R ∧ b ∈ carrier R ∧ a ⊗ b ∈ I ∧ a ∉ I ∧ b ∉ I" proof (-) (*goal: ‹⟦carrier R = I ⟹ thesis; ∃a b. a ∈ carrier R ∧ b ∈ carrier R ∧ a ⊗ b ∈ I ∧ a ∉ I ∧ b ∉ I ⟹ thesis⟧ ⟹ thesis›*) interpret R: cring R by fact assume "carrier R = I ==> thesis" and "∃a b. a ∈ carrier R ∧ b ∈ carrier R ∧ a ⊗ b ∈ I ∧ a ∉ I ∧ b ∉ I ⟹ thesis" (*‹carrier R = (I::'a set) ⟹ thesis::bool› ‹∃(a::'a) b::'a. a ∈ carrier R ∧ b ∈ carrier R ∧ a ⊗ b ∈ (I::'a set) ∧ a ∉ I ∧ b ∉ I ⟹ thesis::bool›*) then show thesis using primeidealCD[OF R.is_cring notprime] (*‹carrier R = (I::'a::type set) ∨ (∃(a::'a::type) b::'a::type. a ∈ carrier R ∧ b ∈ carrier R ∧ a ⊗ b ∈ I ∧ a ∉ I ∧ b ∉ I)›*) by blast qed text ‹If ‹{𝟬}› is a prime ideal of a commutative ring, the ring is a domain› lemma (in cring) zeroprimeideal_domainI: assumes pi: "primeideal {𝟬} R" shows "domain R" proof (intro domain.intro (*‹⟦cring ?R; domain_axioms ?R⟧ ⟹ domain ?R›*) is_cring (*‹cring R›*) domain_axioms.intro (*‹⟦𝟭⇘?R⇙ ≠ 𝟬⇘?R⇙; ⋀a b. ⟦a ⊗⇘?R⇙ b = 𝟬⇘?R⇙; a ∈ carrier ?R; b ∈ carrier ?R⟧ ⟹ a = 𝟬⇘?R⇙ ∨ b = 𝟬⇘?R⇙⟧ ⟹ domain_axioms ?R›*)) (*goals: 1. ‹𝟭 ≠ 𝟬› 2. ‹⋀a b. ⟦a ⊗ b = 𝟬; a ∈ carrier R; b ∈ carrier R⟧ ⟹ a = 𝟬 ∨ b = 𝟬›*) show "𝟭 ≠ 𝟬" using genideal_one (*‹Idl {𝟭} = carrier R›*) genideal_zero (*‹Idl {𝟬} = {𝟬}›*) pi (*‹primeideal {𝟬} R›*) primeideal.I_notcarr (*‹primeideal ?I ?R ⟹ carrier ?R ≠ ?I›*) by force show "a = 𝟬 ∨ b = 𝟬" if ab: "a ⊗ b = 𝟬" and carr: "a ∈ carrier R" "b ∈ carrier R" for a and b proof (-) (*goal: ‹a = 𝟬 ∨ b = 𝟬›*) interpret primeideal "{𝟬}" R by (rule pi (*‹primeideal {𝟬} R›*)) show "a = 𝟬 ∨ b = 𝟬" using I_prime (*‹⟦?a ∈ carrier R; ?b ∈ carrier R; ?a ⊗ ?b ∈ {𝟬}⟧ ⟹ ?a ∈ {𝟬} ∨ ?b ∈ {𝟬}›*) ab (*‹a ⊗ b = 𝟬›*) carr (*‹a ∈ carrier R› ‹b ∈ carrier R›*) by blast qed qed corollary (in cring) domain_eq_zeroprimeideal: "domain R = primeideal {𝟬} R" using domain.zeroprimeideal (*‹domain ?R ⟹ primeideal {𝟬⇘?R⇙} ?R›*) zeroprimeideal_domainI (*‹primeideal {𝟬} R ⟹ domain R›*) by blast subsection ‹Maximal Ideals› lemma (in ideal) helper_I_closed: assumes carr: "a ∈ carrier R" "x ∈ carrier R" "y ∈ carrier R" and axI: "a ⊗ x ∈ I" shows "a ⊗ (x ⊗ y) ∈ I" proof (-) (*goal: ‹a ⊗ (x ⊗ y) ∈ I›*) from axI (*‹a ⊗ x ∈ I›*) carr (*‹(a::'a) ∈ carrier R› ‹x ∈ carrier R› ‹y ∈ carrier R›*) have "(a ⊗ x) ⊗ y ∈ I" by (simp add: I_r_closed (*‹⟦?a ∈ I; ?x ∈ carrier R⟧ ⟹ ?a ⊗ ?x ∈ I›*)) also (*calculation: ‹a ⊗ x ⊗ y ∈ I›*) from carr (*‹a ∈ carrier R› ‹x ∈ carrier R› ‹y ∈ carrier R›*) have "(a ⊗ x) ⊗ y = a ⊗ (x ⊗ y)" by (simp add: m_assoc (*‹⟦?x ∈ carrier R; ?y ∈ carrier R; ?z ∈ carrier R⟧ ⟹ ?x ⊗ ?y ⊗ ?z = ?x ⊗ (?y ⊗ ?z)›*)) finally (*calculation: ‹a ⊗ (x ⊗ y) ∈ I›*) show "a ⊗ (x ⊗ y) ∈ I" . qed lemma (in ideal) helper_max_prime: assumes "cring R" assumes acarr: "a ∈ carrier R" shows "ideal {x∈carrier R. a ⊗ x ∈ I} R" proof (-) (*goal: ‹ideal {x ∈ carrier R. a ⊗ x ∈ I} R›*) interpret cring R by fact show "?thesis" (*goal: ‹ideal {x ∈ carrier R. a ⊗ x ∈ I} R›*) proof (rule idealI (*‹⟦ring ?R; subgroup ?I (add_monoid ?R); ⋀a x. ⟦a ∈ ?I; x ∈ carrier ?R⟧ ⟹ x ⊗⇘?R⇙ a ∈ ?I; ⋀a x. ⟦a ∈ ?I; x ∈ carrier ?R⟧ ⟹ a ⊗⇘?R⇙ x ∈ ?I⟧ ⟹ ideal ?I ?R›*), simp_all) (*goals: 1. ‹ring R› 2. ‹subgroup {x::'a ∈ carrier R. (a::'a) ⊗ x ∈ (I::'a set)} (add_monoid R)› 3. ‹⋀(aa::'a) x::'a. ⟦aa ∈ carrier R ∧ (a::'a) ⊗ aa ∈ (I::'a set); x ∈ carrier R⟧ ⟹ a ⊗ (x ⊗ aa) ∈ I› 4. ‹⋀(aa::'a) x::'a. ⟦aa ∈ carrier R ∧ (a::'a) ⊗ aa ∈ (I::'a set); x ∈ carrier R⟧ ⟹ a ⊗ (aa ⊗ x) ∈ I›*) show "ring R" by (simp add: local.ring_axioms (*‹ring R›*)) show "subgroup {x ∈ carrier R. a ⊗ x ∈ I} (add_monoid R)" apply (rule subgroup.intro (*‹⟦?H ⊆ carrier ?G; ⋀x y. ⟦x ∈ ?H; y ∈ ?H⟧ ⟹ x ⊗⇘?G⇙ y ∈ ?H; 𝟭⇘?G⇙ ∈ ?H; ⋀x. x ∈ ?H ⟹ inv⇘?G⇙ x ∈ ?H⟧ ⟹ subgroup ?H ?G›*)) (*goals: 1. ‹{x ∈ carrier R. a ⊗ x ∈ I} ⊆ carrier (add_monoid R)› 2. ‹⋀x y. ⟦x ∈ {x ∈ carrier R. a ⊗ x ∈ I}; y ∈ {x ∈ carrier R. a ⊗ x ∈ I}⟧ ⟹ x ⊗⇘add_monoid R⇙ y ∈ {x ∈ carrier R. a ⊗ x ∈ I}› 3. ‹𝟭⇘add_monoid R⇙ ∈ {x ∈ carrier R. a ⊗ x ∈ I}› 4. ‹⋀x. x ∈ {x ∈ carrier R. a ⊗ x ∈ I} ⟹ inv⇘add_monoid R⇙ x ∈ {x ∈ carrier R. a ⊗ x ∈ I}› discuss goal 1*) apply ((auto simp: r_distr (*‹⟦?x ∈ carrier R; ?y ∈ carrier R; ?z ∈ carrier R⟧ ⟹ ?z ⊗ (?x ⊕ ?y) = ?z ⊗ ?x ⊕ ?z ⊗ ?y›*) acarr (*‹a ∈ carrier R›*) r_minus (*‹⟦?x ∈ carrier R; ?y ∈ carrier R⟧ ⟹ ?x ⊗ ⊖ ?y = ⊖ (?x ⊗ ?y)›*) simp flip: a_inv_def (*‹a_inv ?R = m_inv (add_monoid ?R)›*))[1]) (*discuss goal 2*) apply ((auto simp: r_distr (*‹⟦(?x::'a::type) ∈ carrier R; (?y::'a::type) ∈ carrier R; (?z::'a::type) ∈ carrier R⟧ ⟹ ?z ⊗ (?x ⊕ ?y) = ?z ⊗ ?x ⊕ ?z ⊗ ?y›*) acarr (*‹(a::'a::type) ∈ carrier R›*) r_minus (*‹⟦(?x::'a::type) ∈ carrier R; (?y::'a::type) ∈ carrier R⟧ ⟹ ?x ⊗ ⊖ ?y = ⊖ (?x ⊗ ?y)›*) simp flip: a_inv_def (*‹a_inv (?R::(?'a, ?'m) ring_scheme) = m_inv (add_monoid ?R)›*))[1]) (*discuss goal 3*) apply ((auto simp: r_distr (*‹⟦?x ∈ carrier R; ?y ∈ carrier R; ?z ∈ carrier R⟧ ⟹ ?z ⊗ (?x ⊕ ?y) = ?z ⊗ ?x ⊕ ?z ⊗ ?y›*) acarr (*‹a ∈ carrier R›*) r_minus (*‹⟦?x ∈ carrier R; ?y ∈ carrier R⟧ ⟹ ?x ⊗ ⊖ ?y = ⊖ (?x ⊗ ?y)›*) simp flip: a_inv_def (*‹a_inv ?R = m_inv (add_monoid ?R)›*))[1]) (*discuss goal 4*) apply ((auto simp: r_distr (*‹⟦?x ∈ carrier R; ?y ∈ carrier R; ?z ∈ carrier R⟧ ⟹ ?z ⊗ (?x ⊕ ?y) = ?z ⊗ ?x ⊕ ?z ⊗ ?y›*) acarr (*‹a ∈ carrier R›*) r_minus (*‹⟦?x ∈ carrier R; ?y ∈ carrier R⟧ ⟹ ?x ⊗ ⊖ ?y = ⊖ (?x ⊗ ?y)›*) simp flip: a_inv_def (*‹a_inv ?R = m_inv (add_monoid ?R)›*))[1]) (*proven 4 subgoals*) . show "⋀b x. ⟦b ∈ carrier R ∧ a ⊗ b ∈ I; x ∈ carrier R⟧ ⟹ a ⊗ (x ⊗ b) ∈ I" using acarr (*‹a ∈ carrier R›*) helper_I_closed (*‹⟦(?a::'a) ∈ carrier R; (?x::'a) ∈ carrier R; (?y::'a) ∈ carrier R; ?a ⊗ ?x ∈ (I::'a set)⟧ ⟹ ?a ⊗ (?x ⊗ ?y) ∈ I›*) m_comm (*‹⟦?x ∈ carrier R; ?y ∈ carrier R⟧ ⟹ ?x ⊗ ?y = ?y ⊗ ?x›*) by auto show "⋀b x. ⟦b ∈ carrier R ∧ a ⊗ b ∈ I; x ∈ carrier R⟧ ⟹ a ⊗ (b ⊗ x) ∈ I" by (simp add: acarr (*‹(a::'a::type) ∈ carrier R›*) helper_I_closed (*‹⟦(?a::'a::type) ∈ carrier R; (?x::'a::type) ∈ carrier R; (?y::'a::type) ∈ carrier R; ?a ⊗ ?x ∈ (I::'a::type set)⟧ ⟹ ?a ⊗ (?x ⊗ ?y) ∈ I›*)) qed qed text ‹In a cring every maximal ideal is prime› lemma (in cring) maximalideal_prime: assumes "maximalideal I R" shows "primeideal I R" proof (-) (*goal: ‹primeideal I R›*) interpret maximalideal I R by fact show "?thesis" (*goal: ‹primeideal I R›*) proof (rule ccontr (*‹(¬ ?P ⟹ False) ⟹ ?P›*)) (*goal: ‹¬ primeideal I R ⟹ False›*) assume neg: "¬ primeideal I R" (*‹¬ primeideal (I::'a set) R›*) then obtain a and b where acarr: "a ∈ carrier R" and bcarr: "b ∈ carrier R" and abI: "a ⊗ b ∈ I" and anI: "a ∉ I" and bnI: "b ∉ I" (*goal: ‹(⋀(a::'a) b::'a. ⟦a ∈ carrier R; b ∈ carrier R; a ⊗ b ∈ (I::'a set); a ∉ I; b ∉ I⟧ ⟹ thesis::bool) ⟹ thesis›*) using primeidealCE[OF is_cring] (*‹⟦¬ primeideal I R; carrier R = I ⟹ ?thesis; ∃a b. a ∈ carrier R ∧ b ∈ carrier R ∧ a ⊗ b ∈ I ∧ a ∉ I ∧ b ∉ I ⟹ ?thesis⟧ ⟹ ?thesis›*) by (metis I_notcarr (*‹carrier R ≠ I›*)) define J where "J = {x∈carrier R. a ⊗ x ∈ I}" from is_cring (*‹cring R›*) acarr (*‹a ∈ carrier R›*) have idealJ: "ideal J R" unfolding J_def (*goal: ‹ideal {x ∈ carrier R. a ⊗ x ∈ I} R›*) by (rule helper_max_prime (*‹⟦cring R; ?a ∈ carrier R⟧ ⟹ ideal {x ∈ carrier R. ?a ⊗ x ∈ I} R›*)) have IsubJ: "I ⊆ J" using I_l_closed (*‹⟦?a ∈ I; ?x ∈ carrier R⟧ ⟹ ?x ⊗ ?a ∈ I›*) J_def (*‹J = {x ∈ carrier R. a ⊗ x ∈ I}›*) a_Hcarr (*‹?h ∈ I ⟹ ?h ∈ carrier R›*) acarr (*‹(a::'a) ∈ carrier R›*) by blast from abI (*‹a ⊗ b ∈ I›*) acarr (*‹a ∈ carrier R›*) bcarr (*‹b ∈ carrier R›*) have "b ∈ J" unfolding J_def (*goal: ‹b ∈ {x ∈ carrier R. a ⊗ x ∈ I}›*) by fast with bnI (*‹b ∉ I›*) have JnI: "J ≠ I" by fast have "𝟭 ∉ J" unfolding J_def (*goal: ‹𝟭 ∉ {x::'a ∈ carrier R. (a::'a) ⊗ x ∈ (I::'a set)}›*) by (simp add: acarr (*‹(a::'a) ∈ carrier R›*) anI (*‹(a::'a) ∉ (I::'a set)›*)) then have Jncarr: "J ≠ carrier R" by fast interpret ideal J R by (rule idealJ (*‹ideal J R›*)) have "J = I ∨ J = carrier R" by (simp add: I_maximal (*‹⟦ideal ?J R; I ⊆ ?J; ?J ⊆ carrier R⟧ ⟹ ?J = I ∨ ?J = carrier R›*) IsubJ (*‹I ⊆ J›*) a_subset (*‹J ⊆ carrier R›*) is_ideal (*‹ideal J R›*)) with JnI (*‹(J::'a set) ≠ (I::'a set)›*) Jncarr (*‹J ≠ carrier R›*) show False by simp qed qed subsection ‹Derived Theorems› text ‹A non-zero cring that has only the two trivial ideals is a field› lemma (in cring) trivialideals_fieldI: assumes carrnzero: "carrier R ≠ {𝟬}" and haveideals: "{I. ideal I R} = {{𝟬}, carrier R}" shows "field R" proof (intro cring_fieldI (*‹Units R = carrier R - {𝟬} ⟹ field R›*) equalityI (*‹⟦?A ⊆ ?B; ?B ⊆ ?A⟧ ⟹ ?A = ?B›*)) (*goals: 1. ‹Units R ⊆ carrier R - {𝟬}› 2. ‹carrier R - {𝟬} ⊆ Units R›*) show "Units R ⊆ carrier R - {𝟬}" by (metis Diff_empty (*‹?A - {} = ?A›*) Units_closed (*‹?x ∈ Units R ⟹ ?x ∈ carrier R›*) Units_r_inv_ex (*‹?x ∈ Units R ⟹ ∃y∈carrier R. ?x ⊗ y = 𝟭›*) carrnzero (*‹carrier R ≠ {𝟬}›*) l_null (*‹?x ∈ carrier R ⟹ 𝟬 ⊗ ?x = 𝟬›*) one_zeroD (*‹𝟭 = 𝟬 ⟹ carrier R = {𝟬}›*) subsetI (*‹(⋀x. x ∈ ?A ⟹ x ∈ ?B) ⟹ ?A ⊆ ?B›*) subset_Diff_insert (*‹(?A ⊆ ?B - insert ?x ?C) = (?A ⊆ ?B - ?C ∧ ?x ∉ ?A)›*)) show "carrier R - {𝟬} ⊆ Units R" proof (standard) (*goal: ‹⋀x. x ∈ carrier R - {𝟬} ⟹ x ∈ Units R›*) fix x assume xcarr': "x ∈ carrier R - {𝟬}" (*‹(x::'a) ∈ carrier R - {𝟬}›*) then have xcarr: "x ∈ carrier R" and xnZ: "x ≠ 𝟬" apply - (*goals: 1. ‹x ∈ carrier R - {𝟬} ⟹ x ∈ carrier R› 2. ‹x ∈ carrier R - {𝟬} ⟹ x ≠ 𝟬› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . from xcarr (*‹x ∈ carrier R›*) have xIdl: "ideal (PIdl x) R" apply (intro cgenideal_ideal (*‹?a ∈ carrier R ⟹ ideal (PIdl ?a) R›*)) (*goal: ‹ideal (PIdl x) R›*) by fast have "PIdl x ≠ {𝟬}" using xcarr (*‹x ∈ carrier R›*) xnZ (*‹x ≠ 𝟬›*) cgenideal_self (*‹?i ∈ carrier R ⟹ ?i ∈ PIdl ?i›*) by blast with haveideals (*‹{I. ideal I R} = {{𝟬}, carrier R}›*) have "PIdl x = carrier R" by (blast intro!: xIdl (*‹ideal (PIdl x) R›*)) then have "𝟭 ∈ PIdl x" by simp then have "∃y. 𝟭 = y ⊗ x ∧ y ∈ carrier R" unfolding cgenideal_def (*goal: ‹∃y. 𝟭 = y ⊗ x ∧ y ∈ carrier R›*) by blast then obtain y where ycarr: " y ∈ carrier R" and ylinv: "𝟭 = y ⊗ x" (*goal: ‹(⋀y. ⟦y ∈ carrier R; 𝟭 = y ⊗ x⟧ ⟹ thesis) ⟹ thesis›*) by fast have "∃y ∈ carrier R. y ⊗ x = 𝟭 ∧ x ⊗ y = 𝟭" using m_comm (*‹⟦?x ∈ carrier R; ?y ∈ carrier R⟧ ⟹ ?x ⊗ ?y = ?y ⊗ ?x›*) xcarr (*‹x ∈ carrier R›*) ycarr (*‹y ∈ carrier R›*) ylinv (*‹𝟭 = (y::'a) ⊗ (x::'a)›*) by auto with xcarr (*‹(x::'a) ∈ carrier R›*) show "x ∈ Units R" unfolding Units_def (*goal: ‹x ∈ {y ∈ carrier R. ∃x∈carrier R. x ⊗ y = 𝟭 ∧ y ⊗ x = 𝟭}›*) by fast qed qed lemma (in field) all_ideals: "{I. ideal I R} = {{𝟬}, carrier R}" proof (intro equalityI (*‹⟦?A ⊆ ?B; ?B ⊆ ?A⟧ ⟹ ?A = ?B›*) subsetI (*‹(⋀x. x ∈ ?A ⟹ x ∈ ?B) ⟹ ?A ⊆ ?B›*)) (*goals: 1. ‹⋀x. x ∈ {I. ideal I R} ⟹ x ∈ {{𝟬}, carrier R}› 2. ‹⋀x. x ∈ {{𝟬}, carrier R} ⟹ x ∈ {I. ideal I R}›*) fix I assume a: "I ∈ {I. ideal I R}" (*‹(I::'a set) ∈ {I::'a set. ideal I R}›*) then interpret ideal I R by simp show "I ∈ {{𝟬}, carrier R}" proof (cases "∃a. a ∈ I - {𝟬}") (*goals: 1. ‹∃a. a ∈ I - {𝟬} ⟹ I ∈ {{𝟬}, carrier R}› 2. ‹∄a. a ∈ I - {𝟬} ⟹ I ∈ {{𝟬}, carrier R}›*) case True (*‹∃a. a ∈ I - {𝟬}›*) then obtain a where aI: "a ∈ I" and anZ: "a ≠ 𝟬" (*goal: ‹(⋀a. ⟦a ∈ I; a ≠ 𝟬⟧ ⟹ thesis) ⟹ thesis›*) by fast have aUnit: "a ∈ Units R" by (simp add: aI (*‹a ∈ I›*) anZ (*‹a ≠ 𝟬›*) field_Units (*‹Units R = carrier R - {𝟬}›*)) then have a: "a ⊗ inv a = 𝟭" by (rule Units_r_inv (*‹?x ∈ Units R ⟹ ?x ⊗ inv ?x = 𝟭›*)) from aI (*‹a ∈ I›*) aUnit (*‹a ∈ Units R›*) have "a ⊗ inv a ∈ I" by (simp add: I_r_closed (*‹⟦?a ∈ I; ?x ∈ carrier R⟧ ⟹ ?a ⊗ ?x ∈ I›*) del: Units_r_inv (*‹?x ∈ Units R ⟹ ?x ⊗ inv ?x = 𝟭›*)) then have oneI: "𝟭 ∈ I" by (simp add: a[symmetric] (*‹𝟭 = a ⊗ inv a›*)) have "carrier R ⊆ I" using oneI (*‹𝟭 ∈ I›*) one_imp_carrier (*‹𝟭 ∈ I ⟹ I = carrier R›*) by auto with a_subset (*‹I ⊆ carrier R›*) have "I = carrier R" by fast then show "I ∈ {{𝟬}, carrier R}" by fast next (*goal: ‹∄a::'a::type. a ∈ (I::'a::type set) - {𝟬} ⟹ I ∈ {{𝟬}, carrier R}›*) case False (*‹∄a. a ∈ I - {𝟬}›*) then have IZ: "⋀a. a ∈ I ⟹ a = 𝟬" by simp have a: "I ⊆ {𝟬}" using False (*‹∄a. a ∈ I - {𝟬}›*) by auto have "𝟬 ∈ I" by simp with a (*‹I ⊆ {𝟬}›*) have "I = {𝟬}" by fast then show "I ∈ {{𝟬}, carrier R}" by fast qed qed (auto simp: zeroideal (*‹ideal {𝟬} R›*) oneideal (*‹ideal (carrier R) R›*)) (*solved the remaining goal: ‹⋀x. x ∈ {{𝟬}, carrier R} ⟹ x ∈ {I. ideal I R}›*)<close> lemma (in cring) trivialideals_eq_field: assumes carrnzero: "carrier R ≠ {𝟬}" shows "({I. ideal I R} = {{𝟬}, carrier R}) = field R" by (fast intro!: trivialideals_fieldI[OF carrnzero] (*‹{I::'a set. ideal I R} = {{𝟬}, carrier R} ⟹ field R›*) field.all_ideals (*‹field (?R::(?'a, ?'b) ring_scheme) ⟹ {I::?'a set. ideal I ?R} = {{𝟬⇘?R⇙}, carrier ?R}›*)) text ‹Like zeroprimeideal for domains› lemma (in field) zeromaximalideal: "maximalideal {𝟬} R" proof (intro maximalidealI (*‹⟦ideal ?I ?R; carrier ?R ≠ ?I; ⋀J. ⟦ideal J ?R; ?I ⊆ J; J ⊆ carrier ?R⟧ ⟹ J = ?I ∨ J = carrier ?R⟧ ⟹ maximalideal ?I ?R›*) zeroideal (*‹ideal {𝟬} R›*)) (*goals: 1. ‹carrier R ≠ {𝟬}› 2. ‹⋀J::'a::type set. ⟦ideal J R; {𝟬} ⊆ J; J ⊆ carrier R⟧ ⟹ J = {𝟬} ∨ J = carrier R›*) from one_not_zero (*‹𝟭 ≠ 𝟬›*) have "𝟭 ∉ {𝟬}" by simp with one_closed (*‹𝟭 ∈ carrier R›*) show "carrier R ≠ {𝟬}" by fast next (*goal: ‹⋀J. ⟦ideal J R; {𝟬} ⊆ J; J ⊆ carrier R⟧ ⟹ J = {𝟬} ∨ J = carrier R›*) fix J assume Jideal: "ideal J R" (*‹ideal (J::'a set) R›*) then have "J ∈ {I. ideal I R}" by fast with all_ideals (*‹{I::'a set. ideal I R} = {{𝟬}, carrier R}›*) show "J = {𝟬} ∨ J = carrier R" by simp qed lemma (in cring) zeromaximalideal_fieldI: assumes zeromax: "maximalideal {𝟬} R" shows "field R" proof (intro trivialideals_fieldI (*‹⟦carrier R ≠ {𝟬}; {I. ideal I R} = {{𝟬}, carrier R}⟧ ⟹ field R›*) maximalideal.I_notcarr[OF zeromax] (*‹carrier R ≠ {𝟬}›*)) (*goal: ‹{I. ideal I R} = {{𝟬}, carrier R}›*) have "J = carrier R" if Jn0: "J ≠ {𝟬}" and idealJ: "ideal J R" for J proof (-) (*goal: ‹J = carrier R›*) interpret ideal J R by (rule idealJ (*‹ideal (J::'a::type set) R›*)) have "{𝟬} ⊆ J" by force from zeromax (*‹maximalideal {𝟬} R›*) idealJ (*‹ideal J R›*) this (*‹{𝟬} ⊆ (J::'a set)›*) a_subset (*‹J ⊆ carrier R›*) have "J = {𝟬} ∨ J = carrier R" by (rule maximalideal.I_maximal (*‹⟦maximalideal ?I ?R; ideal ?J ?R; ?I ⊆ ?J; ?J ⊆ carrier ?R⟧ ⟹ ?J = ?I ∨ ?J = carrier ?R›*)) with Jn0 (*‹J ≠ {𝟬}›*) show "J = carrier R" by simp qed then show "{I. ideal I R} = {{𝟬}, carrier R}" by (auto simp: zeroideal (*‹ideal {𝟬} R›*) oneideal (*‹ideal (carrier R) R›*)) qed lemma (in cring) zeromaximalideal_eq_field: "maximalideal {𝟬} R = field R" using field.zeromaximalideal (*‹field ?R ⟹ maximalideal {𝟬⇘?R⇙} ?R›*) zeromaximalideal_fieldI (*‹maximalideal {𝟬} R ⟹ field R›*) by blast end
{ "path": "Isabelle2024/src/HOL/Algebra/Ideal.thy", "repo": "Isabelle2024", "sha": "f7d3438c33b7f912c06a9f6f883b85c892c6a328fc29bba434e020622ad00c2f" }
(* Title: JinjaDCI/BV/TF_JVM.thy Author: Tobias Nipkow, Gerwin Klein, Susannah Mansky Copyright 2000 TUM, 2019-20 UIUC Based on the Jinja theory BV/TF_JVM.thy by Tobias Nipkow and Gerwin Klein *) section ‹ The Typing Framework for the JVM \label{sec:JVM} › theory TF_JVM imports Jinja.Typing_Framework_err EffectMono BVSpec begin definition exec :: "jvm_prog ⇒ nat ⇒ ty ⇒ ex_table ⇒ instr list ⇒ ty⇩i' err step_type" where "exec G maxs rT et bs ≡ err_step (size bs) (λpc. app (bs!pc) G maxs rT pc (size bs) et) (λpc. eff (bs!pc) G pc et)" locale JVM_sl = fixes P :: jvm_prog and mxs and mxl₀ and n fixes b and Ts :: "ty list" and "is" and xt and T⇩r fixes mxl and A and r and f and app and eff and step defines [simp]: "mxl ≡ (case b of Static ⇒ 0 | NonStatic ⇒ 1)+size Ts+mxl₀" defines [simp]: "A ≡ states P mxs mxl" defines [simp]: "r ≡ JVM_SemiType.le P mxs mxl" defines [simp]: "f ≡ JVM_SemiType.sup P mxs mxl" defines [simp]: "app ≡ λpc. Effect.app (is!pc) P mxs T⇩r pc (size is) xt" defines [simp]: "eff ≡ λpc. Effect.eff (is!pc) P pc xt" defines [simp]: "step ≡ err_step (size is) app eff" defines [simp]: "n ≡ size is" assumes staticb: "b = Static ∨ b = NonStatic" locale start_context = JVM_sl + fixes p and C assumes wf: "wf_prog p P" assumes C: "is_class P C" assumes Ts: "set Ts ⊆ types P" fixes first :: ty⇩i' and start defines [simp]: "first ≡ Some ([],(case b of Static ⇒ [] | NonStatic ⇒ [OK (Class C)]) @ map OK Ts @ replicate mxl₀ Err)" defines [simp]: "start ≡ (OK first) # replicate (size is - 1) (OK None)" thm start_context.intro lemma start_context_intro_auxi: fixes P b Ts p C assumes "b = Static ∨ b = NonStatic " and "wf_prog p P" and "is_class P C" and "set Ts ⊆ types P" shows " start_context P b Ts p C" using start_context.intro[OF JVM_sl.intro] (*‹⟦?b = Static ∨ ?b = NonStatic; start_context_axioms ?P ?Ts ?p ?C⟧ ⟹ start_context ?P ?b ?Ts ?p ?C›*) start_context_axioms_def (*‹start_context_axioms ?P ?Ts ?p ?C ≡ wf_prog ?p ?P ∧ is_class ?P ?C ∧ set ?Ts ⊆ types ?P›*) assms (*‹b = Static ∨ b = NonStatic› ‹wf_prog p P› ‹is_class (P::jvm_prog) (C::char list)› ‹set (Ts::ty list) ⊆ types (P::jvm_prog)›*) by auto subsection ‹ Connecting JVM and Framework › lemma (in start_context) semi: "semilat (A, r, f)" apply (insert semilat_JVM[OF wf] (*‹semilat (JVM_SemiType.sl P ?mxs ?mxl)›*)) (*goal: ‹semilat (A, r, f)›*) apply (unfold A_def (*‹A ≡ states P mxs mxl›*) r_def (*‹r ≡ JVM_SemiType.le P mxs mxl›*) f_def (*‹f ≡ JVM_SemiType.sup P mxs mxl›*) JVM_SemiType.le_def (*‹JVM_SemiType.le ?P ?mxs ?mxl ≡ fst (snd (JVM_SemiType.sl ?P ?mxs ?mxl))›*) JVM_SemiType.sup_def (*‹JVM_SemiType.sup ?P ?mxs ?mxl ≡ snd (snd (JVM_SemiType.sl ?P ?mxs ?mxl))›*) states_def (*‹states ?P ?mxs ?mxl ≡ fst (JVM_SemiType.sl ?P ?mxs ?mxl)›*)) (*goal: ‹(⋀mxs mxl. semilat (JVM_SemiType.sl P mxs mxl)) ⟹ semilat (A, r, f)›*) by auto lemma (in JVM_sl) step_def_exec: "step ≡ exec P mxs T⇩r xt is" by (simp add: exec_def (*‹exec ?G ?maxs ?rT ?et ?bs ≡ err_step (length ?bs) (λpc. app (?bs ! pc) ?G ?maxs ?rT pc (length ?bs) ?et) (λpc. eff (?bs ! pc) ?G pc ?et)›*)) lemma special_ex_swap_lemma [iff]: "(? X. (? n. X = A n & P n) & Q X) = (? n. Q(A n) & P n)" by blast lemma ex_in_list [iff]: "(∃n. ST ∈ nlists n A ∧ n ≤ mxs) = (set ST ⊆ A ∧ size ST ≤ mxs)" apply (unfold nlists_def (*‹nlists ?n ?A = {xs. length xs = ?n ∧ set xs ⊆ ?A}›*)) (*goal: ‹(∃n. ST ∈ nlists n A ∧ n ≤ mxs) = (set ST ⊆ A ∧ length ST ≤ mxs)›*) by auto lemma singleton_nlists: "(∃n. [Class C] ∈ nlists n (types P) ∧ n ≤ mxs) = (is_class P C ∧ 0 < mxs)" by auto lemma set_drop_subset: "set xs ⊆ A ⟹ set (drop n xs) ⊆ A" by (auto dest: in_set_dropD (*‹?x ∈ set (drop ?n ?xs) ⟹ ?x ∈ set ?xs›*)) lemma Suc_minus_minus_le: "n < mxs ⟹ Suc (n - (n - b)) ≤ mxs" by arith lemma in_nlistsE: "⟦ xs ∈ nlists n A; ⟦size xs = n; set xs ⊆ A⟧ ⟹ P ⟧ ⟹ P" apply (unfold nlists_def (*‹nlists ?n ?A = {xs. length xs = ?n ∧ set xs ⊆ ?A}›*)) (*goal: ‹⟦xs ∈ nlists n A; ⟦length xs = n; set xs ⊆ A⟧ ⟹ P⟧ ⟹ P›*) by blast declare is_relevant_entry_def [simp] declare set_drop_subset [simp] theorem (in start_context) exec_pres_type: "pres_type step (size is) A" (*<*) proof (-) (*goal: ‹pres_type step (length is) A›*) let ?n = "size is" and ?app = app and ?step = eff let ?mxl = "(case b of Static ⇒ 0 | NonStatic ⇒ 1) + length Ts + mxl₀" let ?A = "opt((Union {nlists n (types P) |n. n <= mxs}) × nlists ?mxl (err(types P)))" have "pres_type (err_step ?n ?app ?step) ?n (err ?A)" proof (rule pres_type_lift (*‹∀s∈?A. ∀p<?n. ?app p s ⟶ (∀(q, s')∈set (?step p s). s' ∈ ?A) ⟹ pres_type (err_step ?n ?app ?step) ?n (err ?A)›*)) (*goal: ‹∀s∈opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists ((case b of Static ⇒ 0 | NonStatic ⇒ 1) + length Ts + mxl₀) (err (types P))). ∀p<length is. app p s ⟶ (∀(q, s')∈set (eff p s). s' ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists ((case b of Static ⇒ 0 | NonStatic ⇒ 1) + length Ts + mxl₀) (err (types P))))›*) have "⋀s pc pc' s'. s∈?A ⟹ pc < ?n ⟹ ?app pc s ⟹ (pc', s')∈set (?step pc s) ⟹ s' ∈ ?A" proof (-) (*goal: ‹⋀s pc pc' s'. ⟦s ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists ((case b of Static ⇒ 0 | NonStatic ⇒ 1) + length Ts + mxl₀) (err (types P))); pc < length is; app pc s; (pc', s') ∈ set (eff pc s)⟧ ⟹ s' ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists ((case b of Static ⇒ 0 | NonStatic ⇒ 1) + length Ts + mxl₀) (err (types P)))›*) fix s and pc and pc' and s' assume asms: "s∈?A" "pc < ?n" "?app pc s" "(pc', s')∈set (?step pc s)" (*‹(s::(ty list × ty err list) option) ∈ opt (⋃ {nlists n (types (P::jvm_prog)) |n::nat. n ≤ (mxs::nat)} × nlists ((case b::staticb of Static ⇒ 0::nat | NonStatic ⇒ 1::nat) + length (Ts::ty list) + (mxl₀::nat)) (err (types P)))› ‹(pc::nat) < length (is::bytecode)› ‹(app::nat ⇒ (ty list × ty err list) option ⇒ bool) (pc::nat) (s::(ty list × ty err list) option)› ‹(pc'::nat, s'::(ty list × ty err list) option) ∈ set ((eff::nat ⇒ (ty list × ty err list) option ⇒ (nat × (ty list × ty err list) option) list) (pc::nat) (s::(ty list × ty err list) option))›*) show "s' ∈ ?A" proof (cases s) (*goals: 1. ‹s = None ⟹ s' ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists ((case b of Static ⇒ 0 | NonStatic ⇒ 1) + length Ts + mxl₀) (err (types P)))› 2. ‹⋀a. s = ⌊a⌋ ⟹ s' ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists ((case b of Static ⇒ 0 | NonStatic ⇒ 1) + length Ts + mxl₀) (err (types P)))›*) case None (*‹s = None›*) then show "?thesis" (*goal: ‹(s'::(ty list × ty err list) option) ∈ opt (⋃ {nlists n (types (P::jvm_prog)) |n::nat. n ≤ (mxs::nat)} × nlists ((case b::staticb of Static ⇒ 0::nat | NonStatic ⇒ 1::nat) + length (Ts::ty list) + (mxl₀::nat)) (err (types P)))›*) using asms (*‹(s::(ty list × ty err list) option) ∈ opt (⋃ {nlists n (types (P::jvm_prog)) |n::nat. n ≤ (mxs::nat)} × nlists ((case b::staticb of Static ⇒ 0::nat | NonStatic ⇒ 1::nat) + length (Ts::ty list) + (mxl₀::nat)) (err (types P)))› ‹pc < length is› ‹app pc s› ‹(pc'::nat, s'::(ty list × ty err list) option) ∈ set ((eff::nat ⇒ (ty list × ty err list) option ⇒ (nat × (ty list × ty err list) option) list) (pc::nat) (s::(ty list × ty err list) option))›*) by (fastforce dest: effNone (*‹(?pc', ?s') ∈ set (eff ?i ?P ?pc ?et None) ⟹ ?s' = None›*)) next (*goal: ‹⋀a::ty list × ty err list. (s::(ty list × ty err list) option) = ⌊a⌋ ⟹ (s'::(ty list × ty err list) option) ∈ opt (⋃ {nlists n (types (P::jvm_prog)) |n::nat. n ≤ (mxs::nat)} × nlists ((case b::staticb of Static ⇒ 0::nat | NonStatic ⇒ 1::nat) + length (Ts::ty list) + (mxl₀::nat)) (err (types P)))›*) case (Some ab) (*‹s = ⌊ab⌋›*) then show "?thesis" (*goal: ‹s' ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists ((case b of Static ⇒ 0 | NonStatic ⇒ 1) + length Ts + mxl₀) (err (types P)))›*) using asms (*‹s ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists ((case b of Static ⇒ 0 | NonStatic ⇒ 1) + length Ts + mxl₀) (err (types P)))› ‹pc < length is› ‹app pc s› ‹(pc', s') ∈ set (eff pc s)›*) proof (cases "is!pc") (*goals: 1. ‹⋀x1::nat. ⟦(s::(ty list × ty err list) option) = ⌊ab::ty list × ty err list⌋; s ∈ opt (⋃ {nlists n (types (P::jvm_prog)) |n::nat. n ≤ (mxs::nat)} × nlists ((case b::staticb of Static ⇒ 0::nat | NonStatic ⇒ 1::nat) + length (Ts::ty list) + (mxl₀::nat)) (err (types P))); (pc::nat) < length (is::bytecode); (app::nat ⇒ (ty list × ty err list) option ⇒ bool) pc s; (pc'::nat, s'::(ty list × ty err list) option) ∈ set ((eff::nat ⇒ (ty list × ty err list) option ⇒ (nat × (ty list × ty err list) option) list) pc s); is ! pc = Load x1⟧ ⟹ s' ∈ opt (⋃ {nlists n (types P) |n::nat. n ≤ mxs} × nlists ((case b of Static ⇒ 0::nat | NonStatic ⇒ 1::nat) + length Ts + mxl₀) (err (types P)))› 2. ‹⋀x2::nat. ⟦(s::(ty list × ty err list) option) = ⌊ab::ty list × ty err list⌋; s ∈ opt (⋃ {nlists n (types (P::jvm_prog)) |n::nat. n ≤ (mxs::nat)} × nlists ((case b::staticb of Static ⇒ 0::nat | NonStatic ⇒ 1::nat) + length (Ts::ty list) + (mxl₀::nat)) (err (types P))); (pc::nat) < length (is::bytecode); (app::nat ⇒ (ty list × ty err list) option ⇒ bool) pc s; (pc'::nat, s'::(ty list × ty err list) option) ∈ set ((eff::nat ⇒ (ty list × ty err list) option ⇒ (nat × (ty list × ty err list) option) list) pc s); is ! pc = Store x2⟧ ⟹ s' ∈ opt (⋃ {nlists n (types P) |n::nat. n ≤ mxs} × nlists ((case b of Static ⇒ 0::nat | NonStatic ⇒ 1::nat) + length Ts + mxl₀) (err (types P)))› 3. ‹⋀x3::val. ⟦(s::(ty list × ty err list) option) = ⌊ab::ty list × ty err list⌋; s ∈ opt (⋃ {nlists n (types (P::jvm_prog)) |n::nat. n ≤ (mxs::nat)} × nlists ((case b::staticb of Static ⇒ 0::nat | NonStatic ⇒ 1::nat) + length (Ts::ty list) + (mxl₀::nat)) (err (types P))); (pc::nat) < length (is::bytecode); (app::nat ⇒ (ty list × ty err list) option ⇒ bool) pc s; (pc'::nat, s'::(ty list × ty err list) option) ∈ set ((eff::nat ⇒ (ty list × ty err list) option ⇒ (nat × (ty list × ty err list) option) list) pc s); is ! pc = Push x3⟧ ⟹ s' ∈ opt (⋃ {nlists n (types P) |n::nat. n ≤ mxs} × nlists ((case b of Static ⇒ 0::nat | NonStatic ⇒ 1::nat) + length Ts + mxl₀) (err (types P)))› 4. ‹⋀x4::char list. ⟦(s::(ty list × ty err list) option) = ⌊ab::ty list × ty err list⌋; s ∈ opt (⋃ {nlists n (types (P::jvm_prog)) |n::nat. n ≤ (mxs::nat)} × nlists ((case b::staticb of Static ⇒ 0::nat | NonStatic ⇒ 1::nat) + length (Ts::ty list) + (mxl₀::nat)) (err (types P))); (pc::nat) < length (is::bytecode); (app::nat ⇒ (ty list × ty err list) option ⇒ bool) pc s; (pc'::nat, s'::(ty list × ty err list) option) ∈ set ((eff::nat ⇒ (ty list × ty err list) option ⇒ (nat × (ty list × ty err list) option) list) pc s); is ! pc = New x4⟧ ⟹ s' ∈ opt (⋃ {nlists n (types P) |n::nat. n ≤ mxs} × nlists ((case b of Static ⇒ 0::nat | NonStatic ⇒ 1::nat) + length Ts + mxl₀) (err (types P)))› 5. ‹⋀(x51::char list) x52::char list. ⟦(s::(ty list × ty err list) option) = ⌊ab::ty list × ty err list⌋; s ∈ opt (⋃ {nlists n (types (P::jvm_prog)) |n::nat. n ≤ (mxs::nat)} × nlists ((case b::staticb of Static ⇒ 0::nat | NonStatic ⇒ 1::nat) + length (Ts::ty list) + (mxl₀::nat)) (err (types P))); (pc::nat) < length (is::bytecode); (app::nat ⇒ (ty list × ty err list) option ⇒ bool) pc s; (pc'::nat, s'::(ty list × ty err list) option) ∈ set ((eff::nat ⇒ (ty list × ty err list) option ⇒ (nat × (ty list × ty err list) option) list) pc s); is ! pc = Getfield x51 x52⟧ ⟹ s' ∈ opt (⋃ {nlists n (types P) |n::nat. n ≤ mxs} × nlists ((case b of Static ⇒ 0::nat | NonStatic ⇒ 1::nat) + length Ts + mxl₀) (err (types P)))› 6. ‹⋀(x61::char list) (x62::char list) x63::char list. ⟦(s::(ty list × ty err list) option) = ⌊ab::ty list × ty err list⌋; s ∈ opt (⋃ {nlists n (types (P::jvm_prog)) |n::nat. n ≤ (mxs::nat)} × nlists ((case b::staticb of Static ⇒ 0::nat | NonStatic ⇒ 1::nat) + length (Ts::ty list) + (mxl₀::nat)) (err (types P))); (pc::nat) < length (is::bytecode); (app::nat ⇒ (ty list × ty err list) option ⇒ bool) pc s; (pc'::nat, s'::(ty list × ty err list) option) ∈ set ((eff::nat ⇒ (ty list × ty err list) option ⇒ (nat × (ty list × ty err list) option) list) pc s); is ! pc = Getstatic x61 x62 x63⟧ ⟹ s' ∈ opt (⋃ {nlists n (types P) |n::nat. n ≤ mxs} × nlists ((case b of Static ⇒ 0::nat | NonStatic ⇒ 1::nat) + length Ts + mxl₀) (err (types P)))› 7. ‹⋀(x71::char list) x72::char list. ⟦(s::(ty list × ty err list) option) = ⌊ab::ty list × ty err list⌋; s ∈ opt (⋃ {nlists n (types (P::jvm_prog)) |n::nat. n ≤ (mxs::nat)} × nlists ((case b::staticb of Static ⇒ 0::nat | NonStatic ⇒ 1::nat) + length (Ts::ty list) + (mxl₀::nat)) (err (types P))); (pc::nat) < length (is::bytecode); (app::nat ⇒ (ty list × ty err list) option ⇒ bool) pc s; (pc'::nat, s'::(ty list × ty err list) option) ∈ set ((eff::nat ⇒ (ty list × ty err list) option ⇒ (nat × (ty list × ty err list) option) list) pc s); is ! pc = Putfield x71 x72⟧ ⟹ s' ∈ opt (⋃ {nlists n (types P) |n::nat. n ≤ mxs} × nlists ((case b of Static ⇒ 0::nat | NonStatic ⇒ 1::nat) + length Ts + mxl₀) (err (types P)))› 8. ‹⋀(x81::char list) (x82::char list) x83::char list. ⟦(s::(ty list × ty err list) option) = ⌊ab::ty list × ty err list⌋; s ∈ opt (⋃ {nlists n (types (P::jvm_prog)) |n::nat. n ≤ (mxs::nat)} × nlists ((case b::staticb of Static ⇒ 0::nat | NonStatic ⇒ 1::nat) + length (Ts::ty list) + (mxl₀::nat)) (err (types P))); (pc::nat) < length (is::bytecode); (app::nat ⇒ (ty list × ty err list) option ⇒ bool) pc s; (pc'::nat, s'::(ty list × ty err list) option) ∈ set ((eff::nat ⇒ (ty list × ty err list) option ⇒ (nat × (ty list × ty err list) option) list) pc s); is ! pc = Putstatic x81 x82 x83⟧ ⟹ s' ∈ opt (⋃ {nlists n (types P) |n::nat. n ≤ mxs} × nlists ((case b of Static ⇒ 0::nat | NonStatic ⇒ 1::nat) + length Ts + mxl₀) (err (types P)))› 9. ‹⋀x9::char list. ⟦(s::(ty list × ty err list) option) = ⌊ab::ty list × ty err list⌋; s ∈ opt (⋃ {nlists n (types (P::jvm_prog)) |n::nat. n ≤ (mxs::nat)} × nlists ((case b::staticb of Static ⇒ 0::nat | NonStatic ⇒ 1::nat) + length (Ts::ty list) + (mxl₀::nat)) (err (types P))); (pc::nat) < length (is::bytecode); (app::nat ⇒ (ty list × ty err list) option ⇒ bool) pc s; (pc'::nat, s'::(ty list × ty err list) option) ∈ set ((eff::nat ⇒ (ty list × ty err list) option ⇒ (nat × (ty list × ty err list) option) list) pc s); is ! pc = Checkcast x9⟧ ⟹ s' ∈ opt (⋃ {nlists n (types P) |n::nat. n ≤ mxs} × nlists ((case b of Static ⇒ 0::nat | NonStatic ⇒ 1::nat) + length Ts + mxl₀) (err (types P)))› 10. ‹⋀(x101::char list) x102::nat. ⟦(s::(ty list × ty err list) option) = ⌊ab::ty list × ty err list⌋; s ∈ opt (⋃ {nlists n (types (P::jvm_prog)) |n::nat. n ≤ (mxs::nat)} × nlists ((case b::staticb of Static ⇒ 0::nat | NonStatic ⇒ 1::nat) + length (Ts::ty list) + (mxl₀::nat)) (err (types P))); (pc::nat) < length (is::bytecode); (app::nat ⇒ (ty list × ty err list) option ⇒ bool) pc s; (pc'::nat, s'::(ty list × ty err list) option) ∈ set ((eff::nat ⇒ (ty list × ty err list) option ⇒ (nat × (ty list × ty err list) option) list) pc s); is ! pc = Invoke x101 x102⟧ ⟹ s' ∈ opt (⋃ {nlists n (types P) |n::nat. n ≤ mxs} × nlists ((case b of Static ⇒ 0::nat | NonStatic ⇒ 1::nat) + length Ts + mxl₀) (err (types P)))› 11. ‹⋀(x111::char list) (x112::char list) x113::nat. ⟦(s::(ty list × ty err list) option) = ⌊ab::ty list × ty err list⌋; s ∈ opt (⋃ {nlists n (types (P::jvm_prog)) |n::nat. n ≤ (mxs::nat)} × nlists ((case b::staticb of Static ⇒ 0::nat | NonStatic ⇒ 1::nat) + length (Ts::ty list) + (mxl₀::nat)) (err (types P))); (pc::nat) < length (is::bytecode); (app::nat ⇒ (ty list × ty err list) option ⇒ bool) pc s; (pc'::nat, s'::(ty list × ty err list) option) ∈ set ((eff::nat ⇒ (ty list × ty err list) option ⇒ (nat × (ty list × ty err list) option) list) pc s); is ! pc = Invokestatic x111 x112 x113⟧ ⟹ s' ∈ opt (⋃ {nlists n (types P) |n::nat. n ≤ mxs} × nlists ((case b of Static ⇒ 0::nat | NonStatic ⇒ 1::nat) + length Ts + mxl₀) (err (types P)))› 12. ‹⟦(s::(ty list × ty err list) option) = ⌊ab::ty list × ty err list⌋; s ∈ opt (⋃ {nlists n (types (P::jvm_prog)) |n::nat. n ≤ (mxs::nat)} × nlists ((case b::staticb of Static ⇒ 0::nat | NonStatic ⇒ 1::nat) + length (Ts::ty list) + (mxl₀::nat)) (err (types P))); (pc::nat) < length (is::bytecode); (app::nat ⇒ (ty list × ty err list) option ⇒ bool) pc s; (pc'::nat, s'::(ty list × ty err list) option) ∈ set ((eff::nat ⇒ (ty list × ty err list) option ⇒ (nat × (ty list × ty err list) option) list) pc s); is ! pc = Return⟧ ⟹ s' ∈ opt (⋃ {nlists n (types P) |n::nat. n ≤ mxs} × nlists ((case b of Static ⇒ 0::nat | NonStatic ⇒ 1::nat) + length Ts + mxl₀) (err (types P)))› 13. ‹⟦(s::(ty list × ty err list) option) = ⌊ab::ty list × ty err list⌋; s ∈ opt (⋃ {nlists n (types (P::jvm_prog)) |n::nat. n ≤ (mxs::nat)} × nlists ((case b::staticb of Static ⇒ 0::nat | NonStatic ⇒ 1::nat) + length (Ts::ty list) + (mxl₀::nat)) (err (types P))); (pc::nat) < length (is::bytecode); (app::nat ⇒ (ty list × ty err list) option ⇒ bool) pc s; (pc'::nat, s'::(ty list × ty err list) option) ∈ set ((eff::nat ⇒ (ty list × ty err list) option ⇒ (nat × (ty list × ty err list) option) list) pc s); is ! pc = Pop⟧ ⟹ s' ∈ opt (⋃ {nlists n (types P) |n::nat. n ≤ mxs} × nlists ((case b of Static ⇒ 0::nat | NonStatic ⇒ 1::nat) + length Ts + mxl₀) (err (types P)))› 14. ‹⟦(s::(ty list × ty err list) option) = ⌊ab::ty list × ty err list⌋; s ∈ opt (⋃ {nlists n (types (P::jvm_prog)) |n::nat. n ≤ (mxs::nat)} × nlists ((case b::staticb of Static ⇒ 0::nat | NonStatic ⇒ 1::nat) + length (Ts::ty list) + (mxl₀::nat)) (err (types P))); (pc::nat) < length (is::bytecode); (app::nat ⇒ (ty list × ty err list) option ⇒ bool) pc s; (pc'::nat, s'::(ty list × ty err list) option) ∈ set ((eff::nat ⇒ (ty list × ty err list) option ⇒ (nat × (ty list × ty err list) option) list) pc s); is ! pc = IAdd⟧ ⟹ s' ∈ opt (⋃ {nlists n (types P) |n::nat. n ≤ mxs} × nlists ((case b of Static ⇒ 0::nat | NonStatic ⇒ 1::nat) + length Ts + mxl₀) (err (types P)))› 15. ‹⋀x15::int. ⟦(s::(ty list × ty err list) option) = ⌊ab::ty list × ty err list⌋; s ∈ opt (⋃ {nlists n (types (P::jvm_prog)) |n::nat. n ≤ (mxs::nat)} × nlists ((case b::staticb of Static ⇒ 0::nat | NonStatic ⇒ 1::nat) + length (Ts::ty list) + (mxl₀::nat)) (err (types P))); (pc::nat) < length (is::bytecode); (app::nat ⇒ (ty list × ty err list) option ⇒ bool) pc s; (pc'::nat, s'::(ty list × ty err list) option) ∈ set ((eff::nat ⇒ (ty list × ty err list) option ⇒ (nat × (ty list × ty err list) option) list) pc s); is ! pc = Goto x15⟧ ⟹ s' ∈ opt (⋃ {nlists n (types P) |n::nat. n ≤ mxs} × nlists ((case b of Static ⇒ 0::nat | NonStatic ⇒ 1::nat) + length Ts + mxl₀) (err (types P)))› 16. ‹⟦(s::(ty list × ty err list) option) = ⌊ab::ty list × ty err list⌋; s ∈ opt (⋃ {nlists n (types (P::jvm_prog)) |n::nat. n ≤ (mxs::nat)} × nlists ((case b::staticb of Static ⇒ 0::nat | NonStatic ⇒ 1::nat) + length (Ts::ty list) + (mxl₀::nat)) (err (types P))); (pc::nat) < length (is::bytecode); (app::nat ⇒ (ty list × ty err list) option ⇒ bool) pc s; (pc'::nat, s'::(ty list × ty err list) option) ∈ set ((eff::nat ⇒ (ty list × ty err list) option ⇒ (nat × (ty list × ty err list) option) list) pc s); is ! pc = CmpEq⟧ ⟹ s' ∈ opt (⋃ {nlists n (types P) |n::nat. n ≤ mxs} × nlists ((case b of Static ⇒ 0::nat | NonStatic ⇒ 1::nat) + length Ts + mxl₀) (err (types P)))› 17. ‹⋀x17::int. ⟦(s::(ty list × ty err list) option) = ⌊ab::ty list × ty err list⌋; s ∈ opt (⋃ {nlists n (types (P::jvm_prog)) |n::nat. n ≤ (mxs::nat)} × nlists ((case b::staticb of Static ⇒ 0::nat | NonStatic ⇒ 1::nat) + length (Ts::ty list) + (mxl₀::nat)) (err (types P))); (pc::nat) < length (is::bytecode); (app::nat ⇒ (ty list × ty err list) option ⇒ bool) pc s; (pc'::nat, s'::(ty list × ty err list) option) ∈ set ((eff::nat ⇒ (ty list × ty err list) option ⇒ (nat × (ty list × ty err list) option) list) pc s); is ! pc = IfFalse x17⟧ ⟹ s' ∈ opt (⋃ {nlists n (types P) |n::nat. n ≤ mxs} × nlists ((case b of Static ⇒ 0::nat | NonStatic ⇒ 1::nat) + length Ts + mxl₀) (err (types P)))› 18. ‹⟦(s::(ty list × ty err list) option) = ⌊ab::ty list × ty err list⌋; s ∈ opt (⋃ {nlists n (types (P::jvm_prog)) |n::nat. n ≤ (mxs::nat)} × nlists ((case b::staticb of Static ⇒ 0::nat | NonStatic ⇒ 1::nat) + length (Ts::ty list) + (mxl₀::nat)) (err (types P))); (pc::nat) < length (is::bytecode); (app::nat ⇒ (ty list × ty err list) option ⇒ bool) pc s; (pc'::nat, s'::(ty list × ty err list) option) ∈ set ((eff::nat ⇒ (ty list × ty err list) option ⇒ (nat × (ty list × ty err list) option) list) pc s); is ! pc = Throw⟧ ⟹ s' ∈ opt (⋃ {nlists n (types P) |n::nat. n ≤ mxs} × nlists ((case b of Static ⇒ 0::nat | NonStatic ⇒ 1::nat) + length Ts + mxl₀) (err (types P)))›*) case Load (*‹is ! pc = Load x1_›*) then show "?thesis" (*goal: ‹s' ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists ((case b of Static ⇒ 0 | NonStatic ⇒ 1) + length Ts + mxl₀) (err (types P)))›*) using asms (*‹s ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists ((case b of Static ⇒ 0 | NonStatic ⇒ 1) + length Ts + mxl₀) (err (types P)))› ‹pc < length is› ‹app pc s› ‹(pc', s') ∈ set (eff pc s)›*) by (fastforce simp: Effect.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)›*) Effect.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)›*) dest: nlistsE_nth_in (*‹⟦?xs ∈ nlists ?n ?A; ?i < ?n⟧ ⟹ ?xs ! ?i ∈ ?A›*)) next (*goals: 1. ‹⋀x2::nat. ⟦(s::(ty list × ty err list) option) = ⌊ab::ty list × ty err list⌋; s ∈ opt (⋃ {nlists n (types (P::jvm_prog)) |n::nat. n ≤ (mxs::nat)} × nlists ((case b::staticb of Static ⇒ 0::nat | NonStatic ⇒ 1::nat) + length (Ts::ty list) + (mxl₀::nat)) (err (types P))); (pc::nat) < length (is::bytecode); (app::nat ⇒ (ty list × ty err list) option ⇒ bool) pc s; (pc'::nat, s'::(ty list × ty err list) option) ∈ set ((eff::nat ⇒ (ty list × ty err list) option ⇒ (nat × (ty list × ty err list) option) list) pc s); is ! pc = Store x2⟧ ⟹ s' ∈ opt (⋃ {nlists n (types P) |n::nat. n ≤ mxs} × nlists ((case b of Static ⇒ 0::nat | NonStatic ⇒ 1::nat) + length Ts + mxl₀) (err (types P)))› 2. ‹⋀x3::val. ⟦(s::(ty list × ty err list) option) = ⌊ab::ty list × ty err list⌋; s ∈ opt (⋃ {nlists n (types (P::jvm_prog)) |n::nat. n ≤ (mxs::nat)} × nlists ((case b::staticb of Static ⇒ 0::nat | NonStatic ⇒ 1::nat) + length (Ts::ty list) + (mxl₀::nat)) (err (types P))); (pc::nat) < length (is::bytecode); (app::nat ⇒ (ty list × ty err list) option ⇒ bool) pc s; (pc'::nat, s'::(ty list × ty err list) option) ∈ set ((eff::nat ⇒ (ty list × ty err list) option ⇒ (nat × (ty list × ty err list) option) list) pc s); is ! pc = Push x3⟧ ⟹ s' ∈ opt (⋃ {nlists n (types P) |n::nat. n ≤ mxs} × nlists ((case b of Static ⇒ 0::nat | NonStatic ⇒ 1::nat) + length Ts + mxl₀) (err (types P)))› 3. ‹⋀x4::char list. ⟦(s::(ty list × ty err list) option) = ⌊ab::ty list × ty err list⌋; s ∈ opt (⋃ {nlists n (types (P::jvm_prog)) |n::nat. n ≤ (mxs::nat)} × nlists ((case b::staticb of Static ⇒ 0::nat | NonStatic ⇒ 1::nat) + length (Ts::ty list) + (mxl₀::nat)) (err (types P))); (pc::nat) < length (is::bytecode); (app::nat ⇒ (ty list × ty err list) option ⇒ bool) pc s; (pc'::nat, s'::(ty list × ty err list) option) ∈ set ((eff::nat ⇒ (ty list × ty err list) option ⇒ (nat × (ty list × ty err list) option) list) pc s); is ! pc = New x4⟧ ⟹ s' ∈ opt (⋃ {nlists n (types P) |n::nat. n ≤ mxs} × nlists ((case b of Static ⇒ 0::nat | NonStatic ⇒ 1::nat) + length Ts + mxl₀) (err (types P)))› 4. ‹⋀(x51::char list) x52::char list. ⟦(s::(ty list × ty err list) option) = ⌊ab::ty list × ty err list⌋; s ∈ opt (⋃ {nlists n (types (P::jvm_prog)) |n::nat. n ≤ (mxs::nat)} × nlists ((case b::staticb of Static ⇒ 0::nat | NonStatic ⇒ 1::nat) + length (Ts::ty list) + (mxl₀::nat)) (err (types P))); (pc::nat) < length (is::bytecode); (app::nat ⇒ (ty list × ty err list) option ⇒ bool) pc s; (pc'::nat, s'::(ty list × ty err list) option) ∈ set ((eff::nat ⇒ (ty list × ty err list) option ⇒ (nat × (ty list × ty err list) option) list) pc s); is ! pc = Getfield x51 x52⟧ ⟹ s' ∈ opt (⋃ {nlists n (types P) |n::nat. n ≤ mxs} × nlists ((case b of Static ⇒ 0::nat | NonStatic ⇒ 1::nat) + length Ts + mxl₀) (err (types P)))› 5. ‹⋀(x61::char list) (x62::char list) x63::char list. ⟦(s::(ty list × ty err list) option) = ⌊ab::ty list × ty err list⌋; s ∈ opt (⋃ {nlists n (types (P::jvm_prog)) |n::nat. n ≤ (mxs::nat)} × nlists ((case b::staticb of Static ⇒ 0::nat | NonStatic ⇒ 1::nat) + length (Ts::ty list) + (mxl₀::nat)) (err (types P))); (pc::nat) < length (is::bytecode); (app::nat ⇒ (ty list × ty err list) option ⇒ bool) pc s; (pc'::nat, s'::(ty list × ty err list) option) ∈ set ((eff::nat ⇒ (ty list × ty err list) option ⇒ (nat × (ty list × ty err list) option) list) pc s); is ! pc = Getstatic x61 x62 x63⟧ ⟹ s' ∈ opt (⋃ {nlists n (types P) |n::nat. n ≤ mxs} × nlists ((case b of Static ⇒ 0::nat | NonStatic ⇒ 1::nat) + length Ts + mxl₀) (err (types P)))› 6. ‹⋀(x71::char list) x72::char list. ⟦(s::(ty list × ty err list) option) = ⌊ab::ty list × ty err list⌋; s ∈ opt (⋃ {nlists n (types (P::jvm_prog)) |n::nat. n ≤ (mxs::nat)} × nlists ((case b::staticb of Static ⇒ 0::nat | NonStatic ⇒ 1::nat) + length (Ts::ty list) + (mxl₀::nat)) (err (types P))); (pc::nat) < length (is::bytecode); (app::nat ⇒ (ty list × ty err list) option ⇒ bool) pc s; (pc'::nat, s'::(ty list × ty err list) option) ∈ set ((eff::nat ⇒ (ty list × ty err list) option ⇒ (nat × (ty list × ty err list) option) list) pc s); is ! pc = Putfield x71 x72⟧ ⟹ s' ∈ opt (⋃ {nlists n (types P) |n::nat. n ≤ mxs} × nlists ((case b of Static ⇒ 0::nat | NonStatic ⇒ 1::nat) + length Ts + mxl₀) (err (types P)))› 7. ‹⋀(x81::char list) (x82::char list) x83::char list. ⟦(s::(ty list × ty err list) option) = ⌊ab::ty list × ty err list⌋; s ∈ opt (⋃ {nlists n (types (P::jvm_prog)) |n::nat. n ≤ (mxs::nat)} × nlists ((case b::staticb of Static ⇒ 0::nat | NonStatic ⇒ 1::nat) + length (Ts::ty list) + (mxl₀::nat)) (err (types P))); (pc::nat) < length (is::bytecode); (app::nat ⇒ (ty list × ty err list) option ⇒ bool) pc s; (pc'::nat, s'::(ty list × ty err list) option) ∈ set ((eff::nat ⇒ (ty list × ty err list) option ⇒ (nat × (ty list × ty err list) option) list) pc s); is ! pc = Putstatic x81 x82 x83⟧ ⟹ s' ∈ opt (⋃ {nlists n (types P) |n::nat. n ≤ mxs} × nlists ((case b of Static ⇒ 0::nat | NonStatic ⇒ 1::nat) + length Ts + mxl₀) (err (types P)))› 8. ‹⋀x9::char list. ⟦(s::(ty list × ty err list) option) = ⌊ab::ty list × ty err list⌋; s ∈ opt (⋃ {nlists n (types (P::jvm_prog)) |n::nat. n ≤ (mxs::nat)} × nlists ((case b::staticb of Static ⇒ 0::nat | NonStatic ⇒ 1::nat) + length (Ts::ty list) + (mxl₀::nat)) (err (types P))); (pc::nat) < length (is::bytecode); (app::nat ⇒ (ty list × ty err list) option ⇒ bool) pc s; (pc'::nat, s'::(ty list × ty err list) option) ∈ set ((eff::nat ⇒ (ty list × ty err list) option ⇒ (nat × (ty list × ty err list) option) list) pc s); is ! pc = Checkcast x9⟧ ⟹ s' ∈ opt (⋃ {nlists n (types P) |n::nat. n ≤ mxs} × nlists ((case b of Static ⇒ 0::nat | NonStatic ⇒ 1::nat) + length Ts + mxl₀) (err (types P)))› 9. ‹⋀(x101::char list) x102::nat. ⟦(s::(ty list × ty err list) option) = ⌊ab::ty list × ty err list⌋; s ∈ opt (⋃ {nlists n (types (P::jvm_prog)) |n::nat. n ≤ (mxs::nat)} × nlists ((case b::staticb of Static ⇒ 0::nat | NonStatic ⇒ 1::nat) + length (Ts::ty list) + (mxl₀::nat)) (err (types P))); (pc::nat) < length (is::bytecode); (app::nat ⇒ (ty list × ty err list) option ⇒ bool) pc s; (pc'::nat, s'::(ty list × ty err list) option) ∈ set ((eff::nat ⇒ (ty list × ty err list) option ⇒ (nat × (ty list × ty err list) option) list) pc s); is ! pc = Invoke x101 x102⟧ ⟹ s' ∈ opt (⋃ {nlists n (types P) |n::nat. n ≤ mxs} × nlists ((case b of Static ⇒ 0::nat | NonStatic ⇒ 1::nat) + length Ts + mxl₀) (err (types P)))› 10. ‹⋀(x111::char list) (x112::char list) x113::nat. ⟦(s::(ty list × ty err list) option) = ⌊ab::ty list × ty err list⌋; s ∈ opt (⋃ {nlists n (types (P::jvm_prog)) |n::nat. n ≤ (mxs::nat)} × nlists ((case b::staticb of Static ⇒ 0::nat | NonStatic ⇒ 1::nat) + length (Ts::ty list) + (mxl₀::nat)) (err (types P))); (pc::nat) < length (is::bytecode); (app::nat ⇒ (ty list × ty err list) option ⇒ bool) pc s; (pc'::nat, s'::(ty list × ty err list) option) ∈ set ((eff::nat ⇒ (ty list × ty err list) option ⇒ (nat × (ty list × ty err list) option) list) pc s); is ! pc = Invokestatic x111 x112 x113⟧ ⟹ s' ∈ opt (⋃ {nlists n (types P) |n::nat. n ≤ mxs} × nlists ((case b of Static ⇒ 0::nat | NonStatic ⇒ 1::nat) + length Ts + mxl₀) (err (types P)))› 11. ‹⟦(s::(ty list × ty err list) option) = ⌊ab::ty list × ty err list⌋; s ∈ opt (⋃ {nlists n (types (P::jvm_prog)) |n::nat. n ≤ (mxs::nat)} × nlists ((case b::staticb of Static ⇒ 0::nat | NonStatic ⇒ 1::nat) + length (Ts::ty list) + (mxl₀::nat)) (err (types P))); (pc::nat) < length (is::bytecode); (app::nat ⇒ (ty list × ty err list) option ⇒ bool) pc s; (pc'::nat, s'::(ty list × ty err list) option) ∈ set ((eff::nat ⇒ (ty list × ty err list) option ⇒ (nat × (ty list × ty err list) option) list) pc s); is ! pc = Return⟧ ⟹ s' ∈ opt (⋃ {nlists n (types P) |n::nat. n ≤ mxs} × nlists ((case b of Static ⇒ 0::nat | NonStatic ⇒ 1::nat) + length Ts + mxl₀) (err (types P)))› 12. ‹⟦(s::(ty list × ty err list) option) = ⌊ab::ty list × ty err list⌋; s ∈ opt (⋃ {nlists n (types (P::jvm_prog)) |n::nat. n ≤ (mxs::nat)} × nlists ((case b::staticb of Static ⇒ 0::nat | NonStatic ⇒ 1::nat) + length (Ts::ty list) + (mxl₀::nat)) (err (types P))); (pc::nat) < length (is::bytecode); (app::nat ⇒ (ty list × ty err list) option ⇒ bool) pc s; (pc'::nat, s'::(ty list × ty err list) option) ∈ set ((eff::nat ⇒ (ty list × ty err list) option ⇒ (nat × (ty list × ty err list) option) list) pc s); is ! pc = Pop⟧ ⟹ s' ∈ opt (⋃ {nlists n (types P) |n::nat. n ≤ mxs} × nlists ((case b of Static ⇒ 0::nat | NonStatic ⇒ 1::nat) + length Ts + mxl₀) (err (types P)))› 13. ‹⟦(s::(ty list × ty err list) option) = ⌊ab::ty list × ty err list⌋; s ∈ opt (⋃ {nlists n (types (P::jvm_prog)) |n::nat. n ≤ (mxs::nat)} × nlists ((case b::staticb of Static ⇒ 0::nat | NonStatic ⇒ 1::nat) + length (Ts::ty list) + (mxl₀::nat)) (err (types P))); (pc::nat) < length (is::bytecode); (app::nat ⇒ (ty list × ty err list) option ⇒ bool) pc s; (pc'::nat, s'::(ty list × ty err list) option) ∈ set ((eff::nat ⇒ (ty list × ty err list) option ⇒ (nat × (ty list × ty err list) option) list) pc s); is ! pc = IAdd⟧ ⟹ s' ∈ opt (⋃ {nlists n (types P) |n::nat. n ≤ mxs} × nlists ((case b of Static ⇒ 0::nat | NonStatic ⇒ 1::nat) + length Ts + mxl₀) (err (types P)))› 14. ‹⋀x15::int. ⟦(s::(ty list × ty err list) option) = ⌊ab::ty list × ty err list⌋; s ∈ opt (⋃ {nlists n (types (P::jvm_prog)) |n::nat. n ≤ (mxs::nat)} × nlists ((case b::staticb of Static ⇒ 0::nat | NonStatic ⇒ 1::nat) + length (Ts::ty list) + (mxl₀::nat)) (err (types P))); (pc::nat) < length (is::bytecode); (app::nat ⇒ (ty list × ty err list) option ⇒ bool) pc s; (pc'::nat, s'::(ty list × ty err list) option) ∈ set ((eff::nat ⇒ (ty list × ty err list) option ⇒ (nat × (ty list × ty err list) option) list) pc s); is ! pc = Goto x15⟧ ⟹ s' ∈ opt (⋃ {nlists n (types P) |n::nat. n ≤ mxs} × nlists ((case b of Static ⇒ 0::nat | NonStatic ⇒ 1::nat) + length Ts + mxl₀) (err (types P)))› 15. ‹⟦(s::(ty list × ty err list) option) = ⌊ab::ty list × ty err list⌋; s ∈ opt (⋃ {nlists n (types (P::jvm_prog)) |n::nat. n ≤ (mxs::nat)} × nlists ((case b::staticb of Static ⇒ 0::nat | NonStatic ⇒ 1::nat) + length (Ts::ty list) + (mxl₀::nat)) (err (types P))); (pc::nat) < length (is::bytecode); (app::nat ⇒ (ty list × ty err list) option ⇒ bool) pc s; (pc'::nat, s'::(ty list × ty err list) option) ∈ set ((eff::nat ⇒ (ty list × ty err list) option ⇒ (nat × (ty list × ty err list) option) list) pc s); is ! pc = CmpEq⟧ ⟹ s' ∈ opt (⋃ {nlists n (types P) |n::nat. n ≤ mxs} × nlists ((case b of Static ⇒ 0::nat | NonStatic ⇒ 1::nat) + length Ts + mxl₀) (err (types P)))› 16. ‹⋀x17::int. ⟦(s::(ty list × ty err list) option) = ⌊ab::ty list × ty err list⌋; s ∈ opt (⋃ {nlists n (types (P::jvm_prog)) |n::nat. n ≤ (mxs::nat)} × nlists ((case b::staticb of Static ⇒ 0::nat | NonStatic ⇒ 1::nat) + length (Ts::ty list) + (mxl₀::nat)) (err (types P))); (pc::nat) < length (is::bytecode); (app::nat ⇒ (ty list × ty err list) option ⇒ bool) pc s; (pc'::nat, s'::(ty list × ty err list) option) ∈ set ((eff::nat ⇒ (ty list × ty err list) option ⇒ (nat × (ty list × ty err list) option) list) pc s); is ! pc = IfFalse x17⟧ ⟹ s' ∈ opt (⋃ {nlists n (types P) |n::nat. n ≤ mxs} × nlists ((case b of Static ⇒ 0::nat | NonStatic ⇒ 1::nat) + length Ts + mxl₀) (err (types P)))› 17. ‹⟦(s::(ty list × ty err list) option) = ⌊ab::ty list × ty err list⌋; s ∈ opt (⋃ {nlists n (types (P::jvm_prog)) |n::nat. n ≤ (mxs::nat)} × nlists ((case b::staticb of Static ⇒ 0::nat | NonStatic ⇒ 1::nat) + length (Ts::ty list) + (mxl₀::nat)) (err (types P))); (pc::nat) < length (is::bytecode); (app::nat ⇒ (ty list × ty err list) option ⇒ bool) pc s; (pc'::nat, s'::(ty list × ty err list) option) ∈ set ((eff::nat ⇒ (ty list × ty err list) option ⇒ (nat × (ty list × ty err list) option) list) pc s); is ! pc = Throw⟧ ⟹ s' ∈ opt (⋃ {nlists n (types P) |n::nat. n ≤ mxs} × nlists ((case b of Static ⇒ 0::nat | NonStatic ⇒ 1::nat) + length Ts + mxl₀) (err (types P)))›*) case Push (*‹(is::bytecode) ! (pc::nat) = Push (x3_::val)›*) then show "?thesis" (*goal: ‹s' ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists ((case b of Static ⇒ 0 | NonStatic ⇒ 1) + length Ts + mxl₀) (err (types P)))›*) using asms (*‹(s::(ty list × ty err list) option) ∈ opt (⋃ {nlists n (types (P::jvm_prog)) |n::nat. n ≤ (mxs::nat)} × nlists ((case b::staticb of Static ⇒ 0::nat | NonStatic ⇒ 1::nat) + length (Ts::ty list) + (mxl₀::nat)) (err (types P)))› ‹pc < length is› ‹app pc s› ‹(pc', s') ∈ set (eff pc s)›*) Some (*‹s = ⌊ab⌋›*) by (fastforce simp: Effect.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)›*) Effect.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)›*) typeof_lit_is_type (*‹typeof⇘λx. None⇙ ?v = ⌊?T⌋ ⟹ is_type ?P ?T›*)) next (*goals: 1. ‹⋀x2. ⟦s = ⌊ab⌋; s ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists ((case b of Static ⇒ 0 | NonStatic ⇒ 1) + length Ts + mxl₀) (err (types P))); pc < length is; app pc s; (pc', s') ∈ set (eff pc s); is ! pc = Store x2⟧ ⟹ s' ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists ((case b of Static ⇒ 0 | NonStatic ⇒ 1) + length Ts + mxl₀) (err (types P)))› 2. ‹⋀x4. ⟦s = ⌊ab⌋; s ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists ((case b of Static ⇒ 0 | NonStatic ⇒ 1) + length Ts + mxl₀) (err (types P))); pc < length is; app pc s; (pc', s') ∈ set (eff pc s); is ! pc = New x4⟧ ⟹ s' ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists ((case b of Static ⇒ 0 | NonStatic ⇒ 1) + length Ts + mxl₀) (err (types P)))› 3. ‹⋀x51 x52. ⟦s = ⌊ab⌋; s ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists ((case b of Static ⇒ 0 | NonStatic ⇒ 1) + length Ts + mxl₀) (err (types P))); pc < length is; app pc s; (pc', s') ∈ set (eff pc s); is ! pc = Getfield x51 x52⟧ ⟹ s' ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists ((case b of Static ⇒ 0 | NonStatic ⇒ 1) + length Ts + mxl₀) (err (types P)))› 4. ‹⋀x61 x62 x63. ⟦s = ⌊ab⌋; s ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists ((case b of Static ⇒ 0 | NonStatic ⇒ 1) + length Ts + mxl₀) (err (types P))); pc < length is; app pc s; (pc', s') ∈ set (eff pc s); is ! pc = Getstatic x61 x62 x63⟧ ⟹ s' ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists ((case b of Static ⇒ 0 | NonStatic ⇒ 1) + length Ts + mxl₀) (err (types P)))› 5. ‹⋀x71 x72. ⟦s = ⌊ab⌋; s ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists ((case b of Static ⇒ 0 | NonStatic ⇒ 1) + length Ts + mxl₀) (err (types P))); pc < length is; app pc s; (pc', s') ∈ set (eff pc s); is ! pc = Putfield x71 x72⟧ ⟹ s' ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists ((case b of Static ⇒ 0 | NonStatic ⇒ 1) + length Ts + mxl₀) (err (types P)))› 6. ‹⋀x81 x82 x83. ⟦s = ⌊ab⌋; s ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists ((case b of Static ⇒ 0 | NonStatic ⇒ 1) + length Ts + mxl₀) (err (types P))); pc < length is; app pc s; (pc', s') ∈ set (eff pc s); is ! pc = Putstatic x81 x82 x83⟧ ⟹ s' ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists ((case b of Static ⇒ 0 | NonStatic ⇒ 1) + length Ts + mxl₀) (err (types P)))› 7. ‹⋀x9. ⟦s = ⌊ab⌋; s ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists ((case b of Static ⇒ 0 | NonStatic ⇒ 1) + length Ts + mxl₀) (err (types P))); pc < length is; app pc s; (pc', s') ∈ set (eff pc s); is ! pc = Checkcast x9⟧ ⟹ s' ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists ((case b of Static ⇒ 0 | NonStatic ⇒ 1) + length Ts + mxl₀) (err (types P)))› 8. ‹⋀x101 x102. ⟦s = ⌊ab⌋; s ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists ((case b of Static ⇒ 0 | NonStatic ⇒ 1) + length Ts + mxl₀) (err (types P))); pc < length is; app pc s; (pc', s') ∈ set (eff pc s); is ! pc = Invoke x101 x102⟧ ⟹ s' ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists ((case b of Static ⇒ 0 | NonStatic ⇒ 1) + length Ts + mxl₀) (err (types P)))› 9. ‹⋀x111 x112 x113. ⟦s = ⌊ab⌋; s ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists ((case b of Static ⇒ 0 | NonStatic ⇒ 1) + length Ts + mxl₀) (err (types P))); pc < length is; app pc s; (pc', s') ∈ set (eff pc s); is ! pc = Invokestatic x111 x112 x113⟧ ⟹ s' ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists ((case b of Static ⇒ 0 | NonStatic ⇒ 1) + length Ts + mxl₀) (err (types P)))› 10. ‹⟦s = ⌊ab⌋; s ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists ((case b of Static ⇒ 0 | NonStatic ⇒ 1) + length Ts + mxl₀) (err (types P))); pc < length is; app pc s; (pc', s') ∈ set (eff pc s); is ! pc = Return⟧ ⟹ s' ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists ((case b of Static ⇒ 0 | NonStatic ⇒ 1) + length Ts + mxl₀) (err (types P)))› 11. ‹⟦s = ⌊ab⌋; s ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists ((case b of Static ⇒ 0 | NonStatic ⇒ 1) + length Ts + mxl₀) (err (types P))); pc < length is; app pc s; (pc', s') ∈ set (eff pc s); is ! pc = Pop⟧ ⟹ s' ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists ((case b of Static ⇒ 0 | NonStatic ⇒ 1) + length Ts + mxl₀) (err (types P)))› 12. ‹⟦s = ⌊ab⌋; s ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists ((case b of Static ⇒ 0 | NonStatic ⇒ 1) + length Ts + mxl₀) (err (types P))); pc < length is; app pc s; (pc', s') ∈ set (eff pc s); is ! pc = IAdd⟧ ⟹ s' ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists ((case b of Static ⇒ 0 | NonStatic ⇒ 1) + length Ts + mxl₀) (err (types P)))› 13. ‹⋀x15. ⟦s = ⌊ab⌋; s ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists ((case b of Static ⇒ 0 | NonStatic ⇒ 1) + length Ts + mxl₀) (err (types P))); pc < length is; app pc s; (pc', s') ∈ set (eff pc s); is ! pc = Goto x15⟧ ⟹ s' ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists ((case b of Static ⇒ 0 | NonStatic ⇒ 1) + length Ts + mxl₀) (err (types P)))› 14. ‹⟦s = ⌊ab⌋; s ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists ((case b of Static ⇒ 0 | NonStatic ⇒ 1) + length Ts + mxl₀) (err (types P))); pc < length is; app pc s; (pc', s') ∈ set (eff pc s); is ! pc = CmpEq⟧ ⟹ s' ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists ((case b of Static ⇒ 0 | NonStatic ⇒ 1) + length Ts + mxl₀) (err (types P)))› 15. ‹⋀x17. ⟦s = ⌊ab⌋; s ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists ((case b of Static ⇒ 0 | NonStatic ⇒ 1) + length Ts + mxl₀) (err (types P))); pc < length is; app pc s; (pc', s') ∈ set (eff pc s); is ! pc = IfFalse x17⟧ ⟹ s' ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists ((case b of Static ⇒ 0 | NonStatic ⇒ 1) + length Ts + mxl₀) (err (types P)))› 16. ‹⟦s = ⌊ab⌋; s ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists ((case b of Static ⇒ 0 | NonStatic ⇒ 1) + length Ts + mxl₀) (err (types P))); pc < length is; app pc s; (pc', s') ∈ set (eff pc s); is ! pc = Throw⟧ ⟹ s' ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists ((case b of Static ⇒ 0 | NonStatic ⇒ 1) + length Ts + mxl₀) (err (types P)))›*) case Getfield (*‹is ! pc = Getfield x51_ x52_›*) then show "?thesis" (*goal: ‹s' ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists ((case b of Static ⇒ 0 | NonStatic ⇒ 1) + length Ts + mxl₀) (err (types P)))›*) using asms (*‹s ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists ((case b of Static ⇒ 0 | NonStatic ⇒ 1) + length Ts + mxl₀) (err (types P)))› ‹pc < length is› ‹(app::nat ⇒ (ty list × ty err list) option ⇒ bool) (pc::nat) (s::(ty list × ty err list) option)› ‹(pc', s') ∈ set (eff pc s)›*) wf (*‹wf_prog p P›*) by (fastforce simp: Effect.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))›*) 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)›*) 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)›*) 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))›*) 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)›*) dest: sees_field_is_type (*‹⟦(?P::?'a prog) ⊢ (?C::char list) sees (?F::char list),(?b::staticb):(?T::ty) in (?D::char list); wf_prog (?wf_md::?'a prog ⇒ char list ⇒ ?'a mdecl ⇒ bool) ?P⟧ ⟹ is_type ?P ?T›*)) next (*goals: 1. ‹⋀x2. ⟦s = ⌊ab⌋; s ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists ((case b of Static ⇒ 0 | NonStatic ⇒ 1) + length Ts + mxl₀) (err (types P))); pc < length is; app pc s; (pc', s') ∈ set (eff pc s); is ! pc = Store x2⟧ ⟹ s' ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists ((case b of Static ⇒ 0 | NonStatic ⇒ 1) + length Ts + mxl₀) (err (types P)))› 2. ‹⋀x4. ⟦s = ⌊ab⌋; s ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists ((case b of Static ⇒ 0 | NonStatic ⇒ 1) + length Ts + mxl₀) (err (types P))); pc < length is; app pc s; (pc', s') ∈ set (eff pc s); is ! pc = New x4⟧ ⟹ s' ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists ((case b of Static ⇒ 0 | NonStatic ⇒ 1) + length Ts + mxl₀) (err (types P)))› 3. ‹⋀x61 x62 x63. ⟦s = ⌊ab⌋; s ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists ((case b of Static ⇒ 0 | NonStatic ⇒ 1) + length Ts + mxl₀) (err (types P))); pc < length is; app pc s; (pc', s') ∈ set (eff pc s); is ! pc = Getstatic x61 x62 x63⟧ ⟹ s' ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists ((case b of Static ⇒ 0 | NonStatic ⇒ 1) + length Ts + mxl₀) (err (types P)))› 4. ‹⋀x71 x72. ⟦s = ⌊ab⌋; s ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists ((case b of Static ⇒ 0 | NonStatic ⇒ 1) + length Ts + mxl₀) (err (types P))); pc < length is; app pc s; (pc', s') ∈ set (eff pc s); is ! pc = Putfield x71 x72⟧ ⟹ s' ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists ((case b of Static ⇒ 0 | NonStatic ⇒ 1) + length Ts + mxl₀) (err (types P)))› 5. ‹⋀x81 x82 x83. ⟦s = ⌊ab⌋; s ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists ((case b of Static ⇒ 0 | NonStatic ⇒ 1) + length Ts + mxl₀) (err (types P))); pc < length is; app pc s; (pc', s') ∈ set (eff pc s); is ! pc = Putstatic x81 x82 x83⟧ ⟹ s' ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists ((case b of Static ⇒ 0 | NonStatic ⇒ 1) + length Ts + mxl₀) (err (types P)))› 6. ‹⋀x9. ⟦s = ⌊ab⌋; s ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists ((case b of Static ⇒ 0 | NonStatic ⇒ 1) + length Ts + mxl₀) (err (types P))); pc < length is; app pc s; (pc', s') ∈ set (eff pc s); is ! pc = Checkcast x9⟧ ⟹ s' ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists ((case b of Static ⇒ 0 | NonStatic ⇒ 1) + length Ts + mxl₀) (err (types P)))› 7. ‹⋀x101 x102. ⟦s = ⌊ab⌋; s ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists ((case b of Static ⇒ 0 | NonStatic ⇒ 1) + length Ts + mxl₀) (err (types P))); pc < length is; app pc s; (pc', s') ∈ set (eff pc s); is ! pc = Invoke x101 x102⟧ ⟹ s' ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists ((case b of Static ⇒ 0 | NonStatic ⇒ 1) + length Ts + mxl₀) (err (types P)))› 8. ‹⋀x111 x112 x113. ⟦s = ⌊ab⌋; s ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists ((case b of Static ⇒ 0 | NonStatic ⇒ 1) + length Ts + mxl₀) (err (types P))); pc < length is; app pc s; (pc', s') ∈ set (eff pc s); is ! pc = Invokestatic x111 x112 x113⟧ ⟹ s' ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists ((case b of Static ⇒ 0 | NonStatic ⇒ 1) + length Ts + mxl₀) (err (types P)))› 9. ‹⟦s = ⌊ab⌋; s ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists ((case b of Static ⇒ 0 | NonStatic ⇒ 1) + length Ts + mxl₀) (err (types P))); pc < length is; app pc s; (pc', s') ∈ set (eff pc s); is ! pc = Return⟧ ⟹ s' ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists ((case b of Static ⇒ 0 | NonStatic ⇒ 1) + length Ts + mxl₀) (err (types P)))› 10. ‹⟦s = ⌊ab⌋; s ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists ((case b of Static ⇒ 0 | NonStatic ⇒ 1) + length Ts + mxl₀) (err (types P))); pc < length is; app pc s; (pc', s') ∈ set (eff pc s); is ! pc = Pop⟧ ⟹ s' ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists ((case b of Static ⇒ 0 | NonStatic ⇒ 1) + length Ts + mxl₀) (err (types P)))› 11. ‹⟦s = ⌊ab⌋; s ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists ((case b of Static ⇒ 0 | NonStatic ⇒ 1) + length Ts + mxl₀) (err (types P))); pc < length is; app pc s; (pc', s') ∈ set (eff pc s); is ! pc = IAdd⟧ ⟹ s' ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists ((case b of Static ⇒ 0 | NonStatic ⇒ 1) + length Ts + mxl₀) (err (types P)))› 12. ‹⋀x15. ⟦s = ⌊ab⌋; s ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists ((case b of Static ⇒ 0 | NonStatic ⇒ 1) + length Ts + mxl₀) (err (types P))); pc < length is; app pc s; (pc', s') ∈ set (eff pc s); is ! pc = Goto x15⟧ ⟹ s' ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists ((case b of Static ⇒ 0 | NonStatic ⇒ 1) + length Ts + mxl₀) (err (types P)))› 13. ‹⟦s = ⌊ab⌋; s ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists ((case b of Static ⇒ 0 | NonStatic ⇒ 1) + length Ts + mxl₀) (err (types P))); pc < length is; app pc s; (pc', s') ∈ set (eff pc s); is ! pc = CmpEq⟧ ⟹ s' ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists ((case b of Static ⇒ 0 | NonStatic ⇒ 1) + length Ts + mxl₀) (err (types P)))› 14. ‹⋀x17. ⟦s = ⌊ab⌋; s ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists ((case b of Static ⇒ 0 | NonStatic ⇒ 1) + length Ts + mxl₀) (err (types P))); pc < length is; app pc s; (pc', s') ∈ set (eff pc s); is ! pc = IfFalse x17⟧ ⟹ s' ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists ((case b of Static ⇒ 0 | NonStatic ⇒ 1) + length Ts + mxl₀) (err (types P)))› 15. ‹⟦s = ⌊ab⌋; s ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists ((case b of Static ⇒ 0 | NonStatic ⇒ 1) + length Ts + mxl₀) (err (types P))); pc < length is; app pc s; (pc', s') ∈ set (eff pc s); is ! pc = Throw⟧ ⟹ s' ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists ((case b of Static ⇒ 0 | NonStatic ⇒ 1) + length Ts + mxl₀) (err (types P)))›*) case Getstatic (*‹is ! pc = Getstatic x61_ x62_ x63_›*) then show "?thesis" (*goal: ‹s' ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists ((case b of Static ⇒ 0 | NonStatic ⇒ 1) + length Ts + mxl₀) (err (types P)))›*) using asms (*‹(s::(ty list × ty err list) option) ∈ opt (⋃ {nlists n (types (P::jvm_prog)) |n::nat. n ≤ (mxs::nat)} × nlists ((case b::staticb of Static ⇒ 0::nat | NonStatic ⇒ 1::nat) + length (Ts::ty list) + (mxl₀::nat)) (err (types P)))› ‹pc < length is› ‹app pc s› ‹(pc', s') ∈ set (eff pc s)›*) wf (*‹wf_prog p P›*) by (fastforce simp: Effect.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))›*) 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)›*) 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)›*) 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))›*) 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)›*) dest: sees_field_is_type (*‹⟦(?P::?'a prog) ⊢ (?C::char list) sees (?F::char list),(?b::staticb):(?T::ty) in (?D::char list); wf_prog (?wf_md::?'a prog ⇒ char list ⇒ ?'a mdecl ⇒ bool) ?P⟧ ⟹ is_type ?P ?T›*)) next (*goals: 1. ‹⋀x2. ⟦s = ⌊ab⌋; s ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists ((case b of Static ⇒ 0 | NonStatic ⇒ 1) + length Ts + mxl₀) (err (types P))); pc < length is; app pc s; (pc', s') ∈ set (eff pc s); is ! pc = Store x2⟧ ⟹ s' ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists ((case b of Static ⇒ 0 | NonStatic ⇒ 1) + length Ts + mxl₀) (err (types P)))› 2. ‹⋀x4. ⟦s = ⌊ab⌋; s ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists ((case b of Static ⇒ 0 | NonStatic ⇒ 1) + length Ts + mxl₀) (err (types P))); pc < length is; app pc s; (pc', s') ∈ set (eff pc s); is ! pc = New x4⟧ ⟹ s' ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists ((case b of Static ⇒ 0 | NonStatic ⇒ 1) + length Ts + mxl₀) (err (types P)))› 3. ‹⋀x71 x72. ⟦s = ⌊ab⌋; s ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists ((case b of Static ⇒ 0 | NonStatic ⇒ 1) + length Ts + mxl₀) (err (types P))); pc < length is; app pc s; (pc', s') ∈ set (eff pc s); is ! pc = Putfield x71 x72⟧ ⟹ s' ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists ((case b of Static ⇒ 0 | NonStatic ⇒ 1) + length Ts + mxl₀) (err (types P)))› 4. ‹⋀x81 x82 x83. ⟦s = ⌊ab⌋; s ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists ((case b of Static ⇒ 0 | NonStatic ⇒ 1) + length Ts + mxl₀) (err (types P))); pc < length is; app pc s; (pc', s') ∈ set (eff pc s); is ! pc = Putstatic x81 x82 x83⟧ ⟹ s' ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists ((case b of Static ⇒ 0 | NonStatic ⇒ 1) + length Ts + mxl₀) (err (types P)))› 5. ‹⋀x9. ⟦s = ⌊ab⌋; s ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists ((case b of Static ⇒ 0 | NonStatic ⇒ 1) + length Ts + mxl₀) (err (types P))); pc < length is; app pc s; (pc', s') ∈ set (eff pc s); is ! pc = Checkcast x9⟧ ⟹ s' ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists ((case b of Static ⇒ 0 | NonStatic ⇒ 1) + length Ts + mxl₀) (err (types P)))› 6. ‹⋀x101 x102. ⟦s = ⌊ab⌋; s ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists ((case b of Static ⇒ 0 | NonStatic ⇒ 1) + length Ts + mxl₀) (err (types P))); pc < length is; app pc s; (pc', s') ∈ set (eff pc s); is ! pc = Invoke x101 x102⟧ ⟹ s' ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists ((case b of Static ⇒ 0 | NonStatic ⇒ 1) + length Ts + mxl₀) (err (types P)))› 7. ‹⋀x111 x112 x113. ⟦s = ⌊ab⌋; s ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists ((case b of Static ⇒ 0 | NonStatic ⇒ 1) + length Ts + mxl₀) (err (types P))); pc < length is; app pc s; (pc', s') ∈ set (eff pc s); is ! pc = Invokestatic x111 x112 x113⟧ ⟹ s' ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists ((case b of Static ⇒ 0 | NonStatic ⇒ 1) + length Ts + mxl₀) (err (types P)))› 8. ‹⟦s = ⌊ab⌋; s ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists ((case b of Static ⇒ 0 | NonStatic ⇒ 1) + length Ts + mxl₀) (err (types P))); pc < length is; app pc s; (pc', s') ∈ set (eff pc s); is ! pc = Return⟧ ⟹ s' ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists ((case b of Static ⇒ 0 | NonStatic ⇒ 1) + length Ts + mxl₀) (err (types P)))› 9. ‹⟦s = ⌊ab⌋; s ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists ((case b of Static ⇒ 0 | NonStatic ⇒ 1) + length Ts + mxl₀) (err (types P))); pc < length is; app pc s; (pc', s') ∈ set (eff pc s); is ! pc = Pop⟧ ⟹ s' ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists ((case b of Static ⇒ 0 | NonStatic ⇒ 1) + length Ts + mxl₀) (err (types P)))› 10. ‹⟦s = ⌊ab⌋; s ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists ((case b of Static ⇒ 0 | NonStatic ⇒ 1) + length Ts + mxl₀) (err (types P))); pc < length is; app pc s; (pc', s') ∈ set (eff pc s); is ! pc = IAdd⟧ ⟹ s' ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists ((case b of Static ⇒ 0 | NonStatic ⇒ 1) + length Ts + mxl₀) (err (types P)))› 11. ‹⋀x15. ⟦s = ⌊ab⌋; s ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists ((case b of Static ⇒ 0 | NonStatic ⇒ 1) + length Ts + mxl₀) (err (types P))); pc < length is; app pc s; (pc', s') ∈ set (eff pc s); is ! pc = Goto x15⟧ ⟹ s' ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists ((case b of Static ⇒ 0 | NonStatic ⇒ 1) + length Ts + mxl₀) (err (types P)))› 12. ‹⟦s = ⌊ab⌋; s ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists ((case b of Static ⇒ 0 | NonStatic ⇒ 1) + length Ts + mxl₀) (err (types P))); pc < length is; app pc s; (pc', s') ∈ set (eff pc s); is ! pc = CmpEq⟧ ⟹ s' ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists ((case b of Static ⇒ 0 | NonStatic ⇒ 1) + length Ts + mxl₀) (err (types P)))› 13. ‹⋀x17. ⟦s = ⌊ab⌋; s ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists ((case b of Static ⇒ 0 | NonStatic ⇒ 1) + length Ts + mxl₀) (err (types P))); pc < length is; app pc s; (pc', s') ∈ set (eff pc s); is ! pc = IfFalse x17⟧ ⟹ s' ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists ((case b of Static ⇒ 0 | NonStatic ⇒ 1) + length Ts + mxl₀) (err (types P)))› 14. ‹⟦s = ⌊ab⌋; s ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists ((case b of Static ⇒ 0 | NonStatic ⇒ 1) + length Ts + mxl₀) (err (types P))); pc < length is; app pc s; (pc', s') ∈ set (eff pc s); is ! pc = Throw⟧ ⟹ s' ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists ((case b of Static ⇒ 0 | NonStatic ⇒ 1) + length Ts + mxl₀) (err (types P)))›*) case (Invoke M n) (*‹is ! pc = Invoke M n›*) obtain a and b where [simp]: "s = ⌊(a,b)⌋" (*goal: ‹(⋀a b. s = ⌊(a, b)⌋ ⟹ thesis) ⟹ thesis›*) using Some (*‹s = ⌊ab⌋›*) asms(1) (*‹(s::(ty list × ty err list) option) ∈ opt (⋃ {nlists n (types (P::jvm_prog)) |n::nat. n ≤ (mxs::nat)} × nlists ((case b::staticb of Static ⇒ 0::nat | NonStatic ⇒ 1::nat) + length (Ts::ty list) + (mxl₀::nat)) (err (types P)))›*) by blast show "?thesis" (*goal: ‹(s'::(ty list × ty err list) option) ∈ opt (⋃ {nlists n (types (P::jvm_prog)) |n::nat. n ≤ (mxs::nat)} × nlists ((case b::staticb of Static ⇒ 0::nat | NonStatic ⇒ 1::nat) + length (Ts::ty list) + (mxl₀::nat)) (err (types P)))›*) proof (cases "a!n = NT") (*goals: 1. ‹a ! n = NT ⟹ s' ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists ((case b of Static ⇒ 0 | NonStatic ⇒ 1) + length Ts + mxl₀) (err (types P)))› 2. ‹a ! n ≠ NT ⟹ s' ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists ((case b of Static ⇒ 0 | NonStatic ⇒ 1) + length Ts + mxl₀) (err (types P)))›*) case True (*‹(a::ty list) ! (n::nat) = NT›*) then show "?thesis" (*goal: ‹s' ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists ((case b of Static ⇒ 0 | NonStatic ⇒ 1) + length Ts + mxl₀) (err (types P)))›*) using Invoke (*‹is ! pc = Invoke M n›*) asms (*‹s ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists ((case b of Static ⇒ 0 | NonStatic ⇒ 1) + length Ts + mxl₀) (err (types P)))› ‹(pc::nat) < length (is::bytecode)› ‹app pc s› ‹(pc', s') ∈ set (eff pc s)›*) wf (*‹wf_prog p P›*) by (fastforce simp: Effect.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)›*) Effect.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)›*)) next (*goal: ‹a ! n ≠ NT ⟹ s' ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists ((case b of Static ⇒ 0 | NonStatic ⇒ 1) + length Ts + mxl₀) (err (types P)))›*) case False (*‹a ! n ≠ NT›*) have "(pc', s') ∈ set (norm_eff (Invoke M n) P pc (a, b)) ∨ (pc', s') ∈ set (xcpt_eff (Invoke M n) P pc (a, b) xt)" using Invoke (*‹is ! pc = Invoke M n›*) asms(4) (*‹(pc', s') ∈ set (eff pc s)›*) 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)›*)) then show "?thesis" (*goal: ‹s' ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists ((case b of Static ⇒ 0 | NonStatic ⇒ 1) + length Ts + mxl₀) (err (types P)))›*) proof (rule disjE (*‹⟦?P ∨ ?Q; ?P ⟹ ?R; ?Q ⟹ ?R⟧ ⟹ ?R›*)) (*goals: 1. ‹(pc', s') ∈ set (norm_eff (Invoke M n) P pc (a, b)) ⟹ s' ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists ((case b of Static ⇒ 0 | NonStatic ⇒ 1) + length Ts + mxl₀) (err (types P)))› 2. ‹(pc', s') ∈ set (xcpt_eff (Invoke M n) P pc (a, b) xt) ⟹ s' ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists ((case b of Static ⇒ 0 | NonStatic ⇒ 1) + length Ts + mxl₀) (err (types P)))›*) assume "(pc', s') ∈ set (xcpt_eff (Invoke M n) P pc (a, b) xt)" (*‹(pc'::nat, s'::(ty list × ty err list) option) ∈ set (xcpt_eff (Invoke (M::char list) (n::nat)) (P::jvm_prog) (pc::nat) (a::ty list, b::ty err list) (xt::ex_table))›*) then show "?thesis" (*goal: ‹s' ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists ((case b of Static ⇒ 0 | NonStatic ⇒ 1) + length Ts + mxl₀) (err (types P)))›*) using Invoke (*‹is ! pc = Invoke M n›*) asms(1-3) (*‹s ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists ((case b of Static ⇒ 0 | NonStatic ⇒ 1) + length Ts + mxl₀) (err (types P)))› ‹pc < length is› ‹app pc s›*) by (fastforce simp: Effect.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)›*) 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))›*)) next (*goal: ‹(pc', s') ∈ set (norm_eff (Invoke M n) P pc (a, b)) ⟹ s' ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists ((case b of Static ⇒ 0 | NonStatic ⇒ 1) + length Ts + mxl₀) (err (types P)))›*) assume norm: "(pc', s') ∈ set (norm_eff (Invoke M n) P pc (a, b))" (*‹(pc'::nat, s'::(ty list × ty err list) option) ∈ set (norm_eff (Invoke (M::char list) (n::nat)) (P::jvm_prog) (pc::nat) (a::ty list, b::ty err list))›*) also (*calculation: ‹(pc', s') ∈ set (norm_eff (Invoke M n) P pc (a, b))›*) have "Suc (length a - Suc n) ≤ mxs" using Invoke (*‹is ! pc = Invoke M n›*) asms(1,3) (*‹s ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists ((case b of Static ⇒ 0 | NonStatic ⇒ 1) + length Ts + mxl₀) (err (types P)))› ‹app pc s›*) apply (simp add: Effect.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)›*)) (*goal: ‹Suc (length (a::ty list) - Suc (n::nat)) ≤ (mxs::nat)›*) by arith ultimately show "?thesis" (*goal: ‹(s'::(ty list × ty err list) option) ∈ opt (⋃ {nlists n (types (P::jvm_prog)) |n::nat. n ≤ (mxs::nat)} × nlists ((case b::staticb of Static ⇒ 0::nat | NonStatic ⇒ 1::nat) + length (Ts::ty list) + (mxl₀::nat)) (err (types P)))›*) using False (*‹a ! n ≠ NT›*) Invoke (*‹is ! pc = Invoke M n›*) asms(1-3) (*‹(s::(ty list × ty err list) option) ∈ opt (⋃ {nlists n (types (P::jvm_prog)) |n::nat. n ≤ (mxs::nat)} × nlists ((case b::staticb of Static ⇒ 0::nat | NonStatic ⇒ 1::nat) + length (Ts::ty list) + (mxl₀::nat)) (err (types P)))› ‹pc < length is› ‹app pc s›*) wf (*‹wf_prog p P›*) by (auto simp: Effect.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)›*) norm_eff_def (*‹norm_eff ?i ?P ?pc ?τ = map (λpc'. (pc', ⌊eff⇩i (?i, ?P, ?τ)⌋)) (succs ?i ?τ ?pc)›*) 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)›*) dest!: sees_wf_mdecl (*‹⟦wf_prog ?wf_md ?P; ?P ⊢ ?C sees ?M, ?b : ?Ts→?T = ?m in ?D⟧ ⟹ wf_mdecl ?wf_md ?P ?D (?M, ?b, ?Ts, ?T, ?m)›*)) qed qed next (*goals: 1. ‹⋀x2. ⟦s = ⌊ab⌋; s ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists ((case b of Static ⇒ 0 | NonStatic ⇒ 1) + length Ts + mxl₀) (err (types P))); pc < length is; app pc s; (pc', s') ∈ set (eff pc s); is ! pc = Store x2⟧ ⟹ s' ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists ((case b of Static ⇒ 0 | NonStatic ⇒ 1) + length Ts + mxl₀) (err (types P)))› 2. ‹⋀x4. ⟦s = ⌊ab⌋; s ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists ((case b of Static ⇒ 0 | NonStatic ⇒ 1) + length Ts + mxl₀) (err (types P))); pc < length is; app pc s; (pc', s') ∈ set (eff pc s); is ! pc = New x4⟧ ⟹ s' ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists ((case b of Static ⇒ 0 | NonStatic ⇒ 1) + length Ts + mxl₀) (err (types P)))› 3. ‹⋀x71 x72. ⟦s = ⌊ab⌋; s ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists ((case b of Static ⇒ 0 | NonStatic ⇒ 1) + length Ts + mxl₀) (err (types P))); pc < length is; app pc s; (pc', s') ∈ set (eff pc s); is ! pc = Putfield x71 x72⟧ ⟹ s' ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists ((case b of Static ⇒ 0 | NonStatic ⇒ 1) + length Ts + mxl₀) (err (types P)))› 4. ‹⋀x81 x82 x83. ⟦s = ⌊ab⌋; s ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists ((case b of Static ⇒ 0 | NonStatic ⇒ 1) + length Ts + mxl₀) (err (types P))); pc < length is; app pc s; (pc', s') ∈ set (eff pc s); is ! pc = Putstatic x81 x82 x83⟧ ⟹ s' ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists ((case b of Static ⇒ 0 | NonStatic ⇒ 1) + length Ts + mxl₀) (err (types P)))› 5. ‹⋀x9. ⟦s = ⌊ab⌋; s ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists ((case b of Static ⇒ 0 | NonStatic ⇒ 1) + length Ts + mxl₀) (err (types P))); pc < length is; app pc s; (pc', s') ∈ set (eff pc s); is ! pc = Checkcast x9⟧ ⟹ s' ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists ((case b of Static ⇒ 0 | NonStatic ⇒ 1) + length Ts + mxl₀) (err (types P)))› 6. ‹⋀x111 x112 x113. ⟦s = ⌊ab⌋; s ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists ((case b of Static ⇒ 0 | NonStatic ⇒ 1) + length Ts + mxl₀) (err (types P))); pc < length is; app pc s; (pc', s') ∈ set (eff pc s); is ! pc = Invokestatic x111 x112 x113⟧ ⟹ s' ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists ((case b of Static ⇒ 0 | NonStatic ⇒ 1) + length Ts + mxl₀) (err (types P)))› 7. ‹⟦s = ⌊ab⌋; s ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists ((case b of Static ⇒ 0 | NonStatic ⇒ 1) + length Ts + mxl₀) (err (types P))); pc < length is; app pc s; (pc', s') ∈ set (eff pc s); is ! pc = Return⟧ ⟹ s' ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists ((case b of Static ⇒ 0 | NonStatic ⇒ 1) + length Ts + mxl₀) (err (types P)))› 8. ‹⟦s = ⌊ab⌋; s ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists ((case b of Static ⇒ 0 | NonStatic ⇒ 1) + length Ts + mxl₀) (err (types P))); pc < length is; app pc s; (pc', s') ∈ set (eff pc s); is ! pc = Pop⟧ ⟹ s' ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists ((case b of Static ⇒ 0 | NonStatic ⇒ 1) + length Ts + mxl₀) (err (types P)))› 9. ‹⟦s = ⌊ab⌋; s ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists ((case b of Static ⇒ 0 | NonStatic ⇒ 1) + length Ts + mxl₀) (err (types P))); pc < length is; app pc s; (pc', s') ∈ set (eff pc s); is ! pc = IAdd⟧ ⟹ s' ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists ((case b of Static ⇒ 0 | NonStatic ⇒ 1) + length Ts + mxl₀) (err (types P)))› 10. ‹⋀x15. ⟦s = ⌊ab⌋; s ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists ((case b of Static ⇒ 0 | NonStatic ⇒ 1) + length Ts + mxl₀) (err (types P))); pc < length is; app pc s; (pc', s') ∈ set (eff pc s); is ! pc = Goto x15⟧ ⟹ s' ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists ((case b of Static ⇒ 0 | NonStatic ⇒ 1) + length Ts + mxl₀) (err (types P)))› 11. ‹⟦s = ⌊ab⌋; s ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists ((case b of Static ⇒ 0 | NonStatic ⇒ 1) + length Ts + mxl₀) (err (types P))); pc < length is; app pc s; (pc', s') ∈ set (eff pc s); is ! pc = CmpEq⟧ ⟹ s' ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists ((case b of Static ⇒ 0 | NonStatic ⇒ 1) + length Ts + mxl₀) (err (types P)))› 12. ‹⋀x17. ⟦s = ⌊ab⌋; s ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists ((case b of Static ⇒ 0 | NonStatic ⇒ 1) + length Ts + mxl₀) (err (types P))); pc < length is; app pc s; (pc', s') ∈ set (eff pc s); is ! pc = IfFalse x17⟧ ⟹ s' ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists ((case b of Static ⇒ 0 | NonStatic ⇒ 1) + length Ts + mxl₀) (err (types P)))› 13. ‹⟦s = ⌊ab⌋; s ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists ((case b of Static ⇒ 0 | NonStatic ⇒ 1) + length Ts + mxl₀) (err (types P))); pc < length is; app pc s; (pc', s') ∈ set (eff pc s); is ! pc = Throw⟧ ⟹ s' ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists ((case b of Static ⇒ 0 | NonStatic ⇒ 1) + length Ts + mxl₀) (err (types P)))›*) case (Invokestatic C M n) (*‹(is::bytecode) ! (pc::nat) = Invokestatic (C::char list) (M::char list) (n::nat)›*) obtain a and b where [simp]: "s = ⌊(a,b)⌋" (*goal: ‹(⋀a b. s = ⌊(a, b)⌋ ⟹ thesis) ⟹ thesis›*) using Some (*‹(s::(ty list × ty err list) option) = ⌊ab::ty list × ty err list⌋›*) asms(1) (*‹s ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists ((case b of Static ⇒ 0 | NonStatic ⇒ 1) + length Ts + mxl₀) (err (types P)))›*) by blast have "(pc', s') ∈ set (norm_eff (Invokestatic C M n) P pc (a, b)) ∨ (pc', s') ∈ set (xcpt_eff (Invokestatic C M n) P pc (a, b) xt)" using Invokestatic (*‹(is::bytecode) ! (pc::nat) = Invokestatic (C::char list) (M::char list) (n::nat)›*) asms(4) (*‹(pc', s') ∈ set (eff pc s)›*) by (simp add: Effect.eff_def (*‹eff ?i ?P ?pc ?et ?t = (case ?t of None ⇒ [] | ⌊τ⌋ ⇒ norm_eff ?i ?P ?pc τ @ xcpt_eff ?i ?P ?pc τ ?et)›*)) then show "?thesis" (*goal: ‹s' ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists ((case b of Static ⇒ 0 | NonStatic ⇒ 1) + length Ts + mxl₀) (err (types P)))›*) proof (rule disjE (*‹⟦?P ∨ ?Q; ?P ⟹ ?R; ?Q ⟹ ?R⟧ ⟹ ?R›*)) (*goals: 1. ‹(pc', s') ∈ set (norm_eff (Invokestatic C M n) P pc (a, b)) ⟹ s' ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists ((case b of Static ⇒ 0 | NonStatic ⇒ 1) + length Ts + mxl₀) (err (types P)))› 2. ‹(pc', s') ∈ set (xcpt_eff (Invokestatic C M n) P pc (a, b) xt) ⟹ s' ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists ((case b of Static ⇒ 0 | NonStatic ⇒ 1) + length Ts + mxl₀) (err (types P)))›*) assume "(pc', s') ∈ set (xcpt_eff (Invokestatic C M n) P pc (a, b) xt)" (*‹(pc'::nat, s'::(ty list × ty err list) option) ∈ set (xcpt_eff (Invokestatic (C::char list) (M::char list) (n::nat)) (P::jvm_prog) (pc::nat) (a::ty list, b::ty err list) (xt::ex_table))›*) then show "?thesis" (*goal: ‹s' ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists ((case b of Static ⇒ 0 | NonStatic ⇒ 1) + length Ts + mxl₀) (err (types P)))›*) using Invokestatic (*‹(is::bytecode) ! (pc::nat) = Invokestatic (C::char list) (M::char list) (n::nat)›*) asms(1-3) (*‹s ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists ((case b of Static ⇒ 0 | NonStatic ⇒ 1) + length Ts + mxl₀) (err (types P)))› ‹(pc::nat) < length (is::bytecode)› ‹app pc s›*) by (fastforce simp: Effect.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)›*) 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))›*)) next (*goal: ‹(pc', s') ∈ set (norm_eff (Invokestatic C M n) P pc (a, b)) ⟹ s' ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists ((case b of Static ⇒ 0 | NonStatic ⇒ 1) + length Ts + mxl₀) (err (types P)))›*) assume norm: "(pc', s') ∈ set (norm_eff (Invokestatic C M n) P pc (a, b))" (*‹(pc'::nat, s'::(ty list × ty err list) option) ∈ set (norm_eff (Invokestatic (C::char list) (M::char list) (n::nat)) (P::jvm_prog) (pc::nat) (a::ty list, b::ty err list))›*) also (*calculation: ‹(pc', s') ∈ set (norm_eff (Invokestatic C M n) P pc (a, b))›*) have "Suc (length a - Suc n) ≤ mxs" using Invokestatic (*‹is ! pc = Invokestatic C M n›*) asms(1,3) (*‹(s::(ty list × ty err list) option) ∈ opt (⋃ {nlists n (types (P::jvm_prog)) |n::nat. n ≤ (mxs::nat)} × nlists ((case b::staticb of Static ⇒ 0::nat | NonStatic ⇒ 1::nat) + length (Ts::ty list) + (mxl₀::nat)) (err (types P)))› ‹app pc s›*) apply (simp add: Effect.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))›*) xcpt_app_def (*‹xcpt_app (?i::instr) (?P::?'m::type 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)›*)) (*goal: ‹Suc (length (a::ty list) - Suc (n::nat)) ≤ (mxs::nat)›*) by arith ultimately show "?thesis" (*goal: ‹s' ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists ((case b of Static ⇒ 0 | NonStatic ⇒ 1) + length Ts + mxl₀) (err (types P)))›*) using Invokestatic (*‹is ! pc = Invokestatic C M n›*) asms(1-3) (*‹s ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists ((case b of Static ⇒ 0 | NonStatic ⇒ 1) + length Ts + mxl₀) (err (types P)))› ‹pc < length is› ‹(app::nat ⇒ (ty list × ty err list) option ⇒ bool) (pc::nat) (s::(ty list × ty err list) option)›*) wf (*‹wf_prog (p::jvm_prog ⇒ char list ⇒ jvm_method mdecl ⇒ bool) (P::jvm_prog)›*) by (auto simp: Effect.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)›*) norm_eff_def (*‹norm_eff ?i ?P ?pc ?τ = map (λpc'. (pc', ⌊eff⇩i (?i, ?P, ?τ)⌋)) (succs ?i ?τ ?pc)›*) 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)›*) dest!: sees_wf_mdecl (*‹⟦wf_prog ?wf_md ?P; ?P ⊢ ?C sees ?M, ?b : ?Ts→?T = ?m in ?D⟧ ⟹ wf_mdecl ?wf_md ?P ?D (?M, ?b, ?Ts, ?T, ?m)›*)) qed qed ((fastforce simp: Effect.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)›*) Effect.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)›*))+) (*solves the remaining goals: 1. ‹⋀x2::nat. ⟦(s::(ty list × ty err list) option) = ⌊ab::ty list × ty err list⌋; s ∈ opt (⋃ {nlists n (types (P::jvm_prog)) |n::nat. n ≤ (mxs::nat)} × nlists ((case b::staticb of Static ⇒ 0::nat | NonStatic ⇒ 1::nat) + length (Ts::ty list) + (mxl₀::nat)) (err (types P))); (pc::nat) < length (is::bytecode); (app::nat ⇒ (ty list × ty err list) option ⇒ bool) pc s; (pc'::nat, s'::(ty list × ty err list) option) ∈ set ((eff::nat ⇒ (ty list × ty err list) option ⇒ (nat × (ty list × ty err list) option) list) pc s); is ! pc = Store x2⟧ ⟹ s' ∈ opt (⋃ {nlists n (types P) |n::nat. n ≤ mxs} × nlists ((case b of Static ⇒ 0::nat | NonStatic ⇒ 1::nat) + length Ts + mxl₀) (err (types P)))› 2. ‹⋀x4::char list. ⟦(s::(ty list × ty err list) option) = ⌊ab::ty list × ty err list⌋; s ∈ opt (⋃ {nlists n (types (P::jvm_prog)) |n::nat. n ≤ (mxs::nat)} × nlists ((case b::staticb of Static ⇒ 0::nat | NonStatic ⇒ 1::nat) + length (Ts::ty list) + (mxl₀::nat)) (err (types P))); (pc::nat) < length (is::bytecode); (app::nat ⇒ (ty list × ty err list) option ⇒ bool) pc s; (pc'::nat, s'::(ty list × ty err list) option) ∈ set ((eff::nat ⇒ (ty list × ty err list) option ⇒ (nat × (ty list × ty err list) option) list) pc s); is ! pc = New x4⟧ ⟹ s' ∈ opt (⋃ {nlists n (types P) |n::nat. n ≤ mxs} × nlists ((case b of Static ⇒ 0::nat | NonStatic ⇒ 1::nat) + length Ts + mxl₀) (err (types P)))› 3. ‹⋀(x71::char list) x72::char list. ⟦(s::(ty list × ty err list) option) = ⌊ab::ty list × ty err list⌋; s ∈ opt (⋃ {nlists n (types (P::jvm_prog)) |n::nat. n ≤ (mxs::nat)} × nlists ((case b::staticb of Static ⇒ 0::nat | NonStatic ⇒ 1::nat) + length (Ts::ty list) + (mxl₀::nat)) (err (types P))); (pc::nat) < length (is::bytecode); (app::nat ⇒ (ty list × ty err list) option ⇒ bool) pc s; (pc'::nat, s'::(ty list × ty err list) option) ∈ set ((eff::nat ⇒ (ty list × ty err list) option ⇒ (nat × (ty list × ty err list) option) list) pc s); is ! pc = Putfield x71 x72⟧ ⟹ s' ∈ opt (⋃ {nlists n (types P) |n::nat. n ≤ mxs} × nlists ((case b of Static ⇒ 0::nat | NonStatic ⇒ 1::nat) + length Ts + mxl₀) (err (types P)))› 4. ‹⋀(x81::char list) (x82::char list) x83::char list. ⟦(s::(ty list × ty err list) option) = ⌊ab::ty list × ty err list⌋; s ∈ opt (⋃ {nlists n (types (P::jvm_prog)) |n::nat. n ≤ (mxs::nat)} × nlists ((case b::staticb of Static ⇒ 0::nat | NonStatic ⇒ 1::nat) + length (Ts::ty list) + (mxl₀::nat)) (err (types P))); (pc::nat) < length (is::bytecode); (app::nat ⇒ (ty list × ty err list) option ⇒ bool) pc s; (pc'::nat, s'::(ty list × ty err list) option) ∈ set ((eff::nat ⇒ (ty list × ty err list) option ⇒ (nat × (ty list × ty err list) option) list) pc s); is ! pc = Putstatic x81 x82 x83⟧ ⟹ s' ∈ opt (⋃ {nlists n (types P) |n::nat. n ≤ mxs} × nlists ((case b of Static ⇒ 0::nat | NonStatic ⇒ 1::nat) + length Ts + mxl₀) (err (types P)))› 5. ‹⋀x9::char list. ⟦(s::(ty list × ty err list) option) = ⌊ab::ty list × ty err list⌋; s ∈ opt (⋃ {nlists n (types (P::jvm_prog)) |n::nat. n ≤ (mxs::nat)} × nlists ((case b::staticb of Static ⇒ 0::nat | NonStatic ⇒ 1::nat) + length (Ts::ty list) + (mxl₀::nat)) (err (types P))); (pc::nat) < length (is::bytecode); (app::nat ⇒ (ty list × ty err list) option ⇒ bool) pc s; (pc'::nat, s'::(ty list × ty err list) option) ∈ set ((eff::nat ⇒ (ty list × ty err list) option ⇒ (nat × (ty list × ty err list) option) list) pc s); is ! pc = Checkcast x9⟧ ⟹ s' ∈ opt (⋃ {nlists n (types P) |n::nat. n ≤ mxs} × nlists ((case b of Static ⇒ 0::nat | NonStatic ⇒ 1::nat) + length Ts + mxl₀) (err (types P)))› 6. ‹⟦(s::(ty list × ty err list) option) = ⌊ab::ty list × ty err list⌋; s ∈ opt (⋃ {nlists n (types (P::jvm_prog)) |n::nat. n ≤ (mxs::nat)} × nlists ((case b::staticb of Static ⇒ 0::nat | NonStatic ⇒ 1::nat) + length (Ts::ty list) + (mxl₀::nat)) (err (types P))); (pc::nat) < length (is::bytecode); (app::nat ⇒ (ty list × ty err list) option ⇒ bool) pc s; (pc'::nat, s'::(ty list × ty err list) option) ∈ set ((eff::nat ⇒ (ty list × ty err list) option ⇒ (nat × (ty list × ty err list) option) list) pc s); is ! pc = Return⟧ ⟹ s' ∈ opt (⋃ {nlists n (types P) |n::nat. n ≤ mxs} × nlists ((case b of Static ⇒ 0::nat | NonStatic ⇒ 1::nat) + length Ts + mxl₀) (err (types P)))› 7. ‹⟦(s::(ty list × ty err list) option) = ⌊ab::ty list × ty err list⌋; s ∈ opt (⋃ {nlists n (types (P::jvm_prog)) |n::nat. n ≤ (mxs::nat)} × nlists ((case b::staticb of Static ⇒ 0::nat | NonStatic ⇒ 1::nat) + length (Ts::ty list) + (mxl₀::nat)) (err (types P))); (pc::nat) < length (is::bytecode); (app::nat ⇒ (ty list × ty err list) option ⇒ bool) pc s; (pc'::nat, s'::(ty list × ty err list) option) ∈ set ((eff::nat ⇒ (ty list × ty err list) option ⇒ (nat × (ty list × ty err list) option) list) pc s); is ! pc = Pop⟧ ⟹ s' ∈ opt (⋃ {nlists n (types P) |n::nat. n ≤ mxs} × nlists ((case b of Static ⇒ 0::nat | NonStatic ⇒ 1::nat) + length Ts + mxl₀) (err (types P)))› 8. ‹⟦(s::(ty list × ty err list) option) = ⌊ab::ty list × ty err list⌋; s ∈ opt (⋃ {nlists n (types (P::jvm_prog)) |n::nat. n ≤ (mxs::nat)} × nlists ((case b::staticb of Static ⇒ 0::nat | NonStatic ⇒ 1::nat) + length (Ts::ty list) + (mxl₀::nat)) (err (types P))); (pc::nat) < length (is::bytecode); (app::nat ⇒ (ty list × ty err list) option ⇒ bool) pc s; (pc'::nat, s'::(ty list × ty err list) option) ∈ set ((eff::nat ⇒ (ty list × ty err list) option ⇒ (nat × (ty list × ty err list) option) list) pc s); is ! pc = IAdd⟧ ⟹ s' ∈ opt (⋃ {nlists n (types P) |n::nat. n ≤ mxs} × nlists ((case b of Static ⇒ 0::nat | NonStatic ⇒ 1::nat) + length Ts + mxl₀) (err (types P)))› 9. ‹⋀x15::int. ⟦(s::(ty list × ty err list) option) = ⌊ab::ty list × ty err list⌋; s ∈ opt (⋃ {nlists n (types (P::jvm_prog)) |n::nat. n ≤ (mxs::nat)} × nlists ((case b::staticb of Static ⇒ 0::nat | NonStatic ⇒ 1::nat) + length (Ts::ty list) + (mxl₀::nat)) (err (types P))); (pc::nat) < length (is::bytecode); (app::nat ⇒ (ty list × ty err list) option ⇒ bool) pc s; (pc'::nat, s'::(ty list × ty err list) option) ∈ set ((eff::nat ⇒ (ty list × ty err list) option ⇒ (nat × (ty list × ty err list) option) list) pc s); is ! pc = Goto x15⟧ ⟹ s' ∈ opt (⋃ {nlists n (types P) |n::nat. n ≤ mxs} × nlists ((case b of Static ⇒ 0::nat | NonStatic ⇒ 1::nat) + length Ts + mxl₀) (err (types P)))› 10. ‹⟦(s::(ty list × ty err list) option) = ⌊ab::ty list × ty err list⌋; s ∈ opt (⋃ {nlists n (types (P::jvm_prog)) |n::nat. n ≤ (mxs::nat)} × nlists ((case b::staticb of Static ⇒ 0::nat | NonStatic ⇒ 1::nat) + length (Ts::ty list) + (mxl₀::nat)) (err (types P))); (pc::nat) < length (is::bytecode); (app::nat ⇒ (ty list × ty err list) option ⇒ bool) pc s; (pc'::nat, s'::(ty list × ty err list) option) ∈ set ((eff::nat ⇒ (ty list × ty err list) option ⇒ (nat × (ty list × ty err list) option) list) pc s); is ! pc = CmpEq⟧ ⟹ s' ∈ opt (⋃ {nlists n (types P) |n::nat. n ≤ mxs} × nlists ((case b of Static ⇒ 0::nat | NonStatic ⇒ 1::nat) + length Ts + mxl₀) (err (types P)))› 11. ‹⋀x17::int. ⟦(s::(ty list × ty err list) option) = ⌊ab::ty list × ty err list⌋; s ∈ opt (⋃ {nlists n (types (P::jvm_prog)) |n::nat. n ≤ (mxs::nat)} × nlists ((case b::staticb of Static ⇒ 0::nat | NonStatic ⇒ 1::nat) + length (Ts::ty list) + (mxl₀::nat)) (err (types P))); (pc::nat) < length (is::bytecode); (app::nat ⇒ (ty list × ty err list) option ⇒ bool) pc s; (pc'::nat, s'::(ty list × ty err list) option) ∈ set ((eff::nat ⇒ (ty list × ty err list) option ⇒ (nat × (ty list × ty err list) option) list) pc s); is ! pc = IfFalse x17⟧ ⟹ s' ∈ opt (⋃ {nlists n (types P) |n::nat. n ≤ mxs} × nlists ((case b of Static ⇒ 0::nat | NonStatic ⇒ 1::nat) + length Ts + mxl₀) (err (types P)))› 12. ‹⟦(s::(ty list × ty err list) option) = ⌊ab::ty list × ty err list⌋; s ∈ opt (⋃ {nlists n (types (P::jvm_prog)) |n::nat. n ≤ (mxs::nat)} × nlists ((case b::staticb of Static ⇒ 0::nat | NonStatic ⇒ 1::nat) + length (Ts::ty list) + (mxl₀::nat)) (err (types P))); (pc::nat) < length (is::bytecode); (app::nat ⇒ (ty list × ty err list) option ⇒ bool) pc s; (pc'::nat, s'::(ty list × ty err list) option) ∈ set ((eff::nat ⇒ (ty list × ty err list) option ⇒ (nat × (ty list × ty err list) option) list) pc s); is ! pc = Throw⟧ ⟹ s' ∈ opt (⋃ {nlists n (types P) |n::nat. n ≤ mxs} × nlists ((case b of Static ⇒ 0::nat | NonStatic ⇒ 1::nat) + length Ts + mxl₀) (err (types P)))›*) qed qed then show "∀s∈?A. ∀p. p < ?n ⟶ ?app p s ⟶ (∀(q, s')∈set (?step p s). s' ∈ ?A)" by clarsimp qed then show "?thesis" (*goal: ‹pres_type step (length is) A›*) by (simp add: JVM_states_unfold (*‹states ?P ?mxs ?mxl ≡ err (opt (⋃ {nlists n (types ?P) |n. n ≤ ?mxs} × nlists ?mxl (err (types ?P))))›*)) qed (*>*) declare is_relevant_entry_def [simp del] declare set_drop_subset [simp del] lemma lesubstep_type_simple: "xs [⊑⇘Product.le (=) r⇙] ys ⟹ set xs {⊑⇘r⇙} set ys" (*<*) proof (-) (*goal: ‹xs [⊑⇘Product.le (=) r⇙] ys ⟹ set xs {⊑⇘r⇙} set ys›*) assume assm: "xs [⊑⇘Product.le (=) r⇙] ys" (*‹(xs::(nat × 'a) list) [⊑⇘Product.le (=) (r::'a ⇒ 'a ⇒ bool)⇙] (ys::(nat × 'a) list)›*) have "⋀a b i y. (a, b) = xs ! i ⟹ i < length xs ⟹ ∃τ'. (∃i. (a, τ') = ys ! i ∧ i < length xs) ∧ b ⊑⇘r⇙ τ'" proof (-) (*goal: ‹⋀a b i y. ⟦(a, b) = xs ! i; i < length xs⟧ ⟹ ∃τ'. (∃i. (a, τ') = ys ! i ∧ i < length xs) ∧ b ⊑⇘r⇙ τ'›*) fix a and b and i assume ith: "(a, b) = xs ! i" and len: "i < length xs" (*‹(a::nat, b::'a) = (xs::(nat × 'a) list) ! (i::nat)› ‹(i::nat) < length (xs::(nat × 'a) list)›*) obtain τ where "ys ! i = (a, τ) ∧ r b τ" (*goal: ‹(⋀τ. ys ! i = (a, τ) ∧ r b τ ⟹ thesis) ⟹ thesis›*) using le_listD[OF assm len] (*‹xs ! i <=((=),r) ys ! i›*) ith (*‹(a, b) = xs ! i›*) by (clarsimp simp: lesub_def (*‹(?x ⊑⇘?r⇙ ?y) = ?r ?x ?y›*) Product.le_def (*‹Product.le ?r⇩A ?r⇩B = (λ(a₁, b₁) (a₂, b₂). a₁ ⊑⇘?r⇩A⇙ a₂ ∧ b₁ ⊑⇘?r⇩B⇙ b₂)›*)) then have "(a, τ) = ys ! i ∧ b ⊑⇘r⇙ τ" by (clarsimp simp: lesub_def (*‹(?x ⊑⇘?r⇙ ?y) = ?r ?x ?y›*)) with len (*‹i < length xs›*) show "∃τ'. (∃i. (a, τ') = ys ! i ∧ i < length xs) ∧ b ⊑⇘r⇙ τ'" by fastforce qed then show "set xs {⊑⇘r⇙} set ys" using assm (*‹xs [⊑⇘Product.le (=) r⇙] ys›*) by (clarsimp simp: lesubstep_type_def (*‹(?A::(nat × ?'s::type) set) {⊑⇘?r::?'s::type ⇒ ?'s::type ⇒ bool⇙} (?B::(nat × ?'s::type) set) ≡ ∀(p::nat, τ::?'s::type)∈?A. ∃τ'::?'s::type. (p, τ') ∈ ?B ∧ τ ⊑⇘?r⇙ τ'›*) set_conv_nth (*‹set (?xs::?'a::type list) = {?xs ! i |i::nat. i < length ?xs}›*)) qed (*>*) declare is_relevant_entry_def [simp del] lemma conjI2: "⟦ A; A ⟹ B ⟧ ⟹ A ∧ B" by blast lemma (in JVM_sl) eff_mono: assumes wf: "wf_prog p P" and "pc < length is" and lesub: "s ⊑⇘sup_state_opt P⇙ t" and app: "app pc t" shows "set (eff pc s) {⊑⇘sup_state_opt P⇙} set (eff pc t)" (*<*) proof (cases t) (*goals: 1. ‹t = None ⟹ set (eff pc s) {⊑⇘sup_state_opt P⇙} set (eff pc t)› 2. ‹⋀a. t = ⌊a⌋ ⟹ set (eff pc s) {⊑⇘sup_state_opt P⇙} set (eff pc t)›*) case None (*‹(t::(ty list × ty err list) option) = None›*) then show "?thesis" (*goal: ‹set (eff pc s) {⊑⇘sup_state_opt P⇙} set (eff pc t)›*) using lesub (*‹s ⊑⇘sup_state_opt P⇙ t›*) by (simp add: Effect.eff_def (*‹eff ?i ?P ?pc ?et ?t = (case ?t of None ⇒ [] | ⌊τ⌋ ⇒ norm_eff ?i ?P ?pc τ @ xcpt_eff ?i ?P ?pc τ ?et)›*) lesub_def (*‹(?x ⊑⇘?r⇙ ?y) = ?r ?x ?y›*)) next (*goal: ‹⋀a. t = ⌊a⌋ ⟹ set (eff pc s) {⊑⇘sup_state_opt P⇙} set (eff pc t)›*) case tSome: (Some a) (*‹(t::(ty list × ty err list) option) = ⌊a::ty list × ty err list⌋›*) show "?thesis" (*goal: ‹set (eff pc s) {⊑⇘sup_state_opt P⇙} set (eff pc t)›*) proof (cases s) (*goals: 1. ‹s = None ⟹ set (eff pc s) {⊑⇘sup_state_opt P⇙} set (eff pc t)› 2. ‹⋀a. s = ⌊a⌋ ⟹ set (eff pc s) {⊑⇘sup_state_opt P⇙} set (eff pc t)›*) case None (*‹s = None›*) then show "?thesis" (*goal: ‹set (eff pc s) {⊑⇘sup_state_opt P⇙} set (eff pc t)›*) using lesub (*‹s ⊑⇘sup_state_opt P⇙ t›*) by (simp add: Effect.eff_def (*‹eff ?i ?P ?pc ?et ?t = (case ?t of None ⇒ [] | ⌊τ⌋ ⇒ norm_eff ?i ?P ?pc τ @ xcpt_eff ?i ?P ?pc τ ?et)›*) lesub_def (*‹(?x ⊑⇘?r⇙ ?y) = ?r ?x ?y›*)) next (*goal: ‹⋀a. s = ⌊a⌋ ⟹ set (eff pc s) {⊑⇘sup_state_opt P⇙} set (eff pc t)›*) case (Some b) (*‹s = ⌊b⌋›*) let ?norm = "λx. norm_eff (is ! pc) P pc x" let ?xcpt = "λx. xcpt_eff (is ! pc) P pc x xt" let ?r = "Product.le (=) (sup_state_opt P)" let ?τ' = "⌊eff⇩i (is ! pc, P, a)⌋" { fix x assume xb: "x ∈ set (succs (is ! pc) b pc)" (*‹(x::nat) ∈ set (succs ((is::bytecode) ! (pc::nat)) (b::ty list × ty err list) pc)›*) then have appi: "app⇩i (is ! pc, P, pc, mxs, T⇩r, a)" and bia: "P ⊢ b ≤⇩i a" and appa: "app pc ⌊a⌋" using lesub (*‹(s::(ty list × ty err list) option) ⊑⇘sup_state_opt (P::jvm_prog)⇙ (t::(ty list × ty err list) option)›*) app (*‹app pc t›*) tSome (*‹t = ⌊a⌋›*) Some (*‹(s::(ty list × ty err list) option) = ⌊b::ty list × ty err list⌋›*) apply - (*goals: 1. ‹⟦(x::nat) ∈ set (succs ((is::bytecode) ! (pc::nat)) (b::ty list × ty err list) pc); (s::(ty list × ty err list) option) ⊑⇘sup_state_opt (P::jvm_prog)⇙ (t::(ty list × ty err list) option); (app::nat ⇒ (ty list × ty err list) option ⇒ bool) pc t; t = ⌊a::ty list × ty err list⌋; s = ⌊b⌋⟧ ⟹ app⇩i (is ! pc, P, pc, mxs::nat, T⇩r::ty, a)› 2. ‹⟦(x::nat) ∈ set (succs ((is::bytecode) ! (pc::nat)) (b::ty list × ty err list) pc); (s::(ty list × ty err list) option) ⊑⇘sup_state_opt (P::jvm_prog)⇙ (t::(ty list × ty err list) option); (app::nat ⇒ (ty list × ty err list) option ⇒ bool) pc t; t = ⌊a::ty list × ty err list⌋; s = ⌊b⌋⟧ ⟹ P ⊢ b ≤⇩i a› 3. ‹⟦(x::nat) ∈ set (succs ((is::bytecode) ! (pc::nat)) (b::ty list × ty err list) pc); (s::(ty list × ty err list) option) ⊑⇘sup_state_opt (P::jvm_prog)⇙ (t::(ty list × ty err list) option); (app::nat ⇒ (ty list × ty err list) option ⇒ bool) pc t; t = ⌊a::ty list × ty err list⌋; s = ⌊b⌋⟧ ⟹ app pc ⌊a⌋› discuss goal 1*) apply ((auto simp add: lesub_def (*‹((?x::?'a) ⊑⇘?r::?'a ⇒ ?'a ⇒ bool⇙ (?y::?'a)) = ?r ?x ?y›*) Effect.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 2*) apply ((auto simp add: lesub_def (*‹(?x ⊑⇘?r⇙ ?y) = ?r ?x ?y›*) Effect.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 add: lesub_def (*‹((?x::?'a) ⊑⇘?r::?'a ⇒ ?'a ⇒ bool⇙ (?y::?'a)) = ?r ?x ?y›*) Effect.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]) (*proven 3 subgoals*) . have xa: "x ∈ set (succs (is ! pc) a pc)" using xb (*‹x ∈ set (succs (is ! pc) b pc)›*) succs_mono[OF wf appi bia] (*‹set (succs (is ! pc) b ?pc) ⊆ set (succs (is ! pc) a ?pc)›*) by auto then have "(x, ?τ') ∈ (λpc'. (pc', ?τ')) ` set (succs (is ! pc) a pc)" by (rule imageI (*‹?x ∈ ?A ⟹ ?f ?x ∈ ?f ` ?A›*)) moreover have "P ⊢ ⌊eff⇩i (is ! pc, P, b)⌋ ≤' ?τ'" using xb (*‹x ∈ set (succs (is ! pc) b pc)›*) xa (*‹x ∈ set (succs (is ! pc) a pc)›*) "eff⇩i_mono"[OF wf bia] (*‹⟦app ?i P ?m ?rT ?pc ?mpc ?xt ⌊a⌋; succs ?i b ?pc ≠ []; succs ?i a ?pc ≠ []⟧ ⟹ P ⊢ eff⇩i (?i, P, b) ≤⇩i eff⇩i (?i, P, a)›*) appa (*‹app pc ⌊a⌋›*) by fastforce ultimately have "∃τ'. (x, τ') ∈ (λpc'. (pc', ⌊eff⇩i (is ! pc, P, a)⌋)) ` set (succs (is ! pc) a pc) ∧ P ⊢ ⌊eff⇩i (is ! pc, P, b)⌋ ≤' τ'" by blast } then have norm: "set (?norm b) {⊑⇘sup_state_opt P⇙} set (?norm a)" using tSome (*‹t = ⌊a⌋›*) Some (*‹s = ⌊b⌋›*) by (clarsimp simp: norm_eff_def (*‹norm_eff ?i ?P ?pc ?τ = map (λpc'. (pc', ⌊eff⇩i (?i, ?P, ?τ)⌋)) (succs ?i ?τ ?pc)›*) lesubstep_type_def (*‹?A {⊑⇘?r⇙} ?B ≡ ∀(p, τ)∈?A. ∃τ'. (p, τ') ∈ ?B ∧ τ ⊑⇘?r⇙ τ'›*) lesub_def (*‹(?x ⊑⇘?r⇙ ?y) = ?r ?x ?y›*)) obtain a1 and b1 and a2 and b2 where a: "a = (a1, b1)" and b: "b = (a2, b2)" (*goal: ‹(⋀a1 b1 a2 b2. ⟦a = (a1, b1); b = (a2, b2)⟧ ⟹ thesis) ⟹ thesis›*) using tSome (*‹t = ⌊a⌋›*) Some (*‹s = ⌊b⌋›*) by fastforce then have a12: "size a2 = size a1" using lesub (*‹(s::(ty list × ty err list) option) ⊑⇘sup_state_opt (P::jvm_prog)⇙ (t::(ty list × ty err list) option)›*) tSome (*‹t = ⌊a⌋›*) Some (*‹s = ⌊b⌋›*) by (clarsimp simp: lesub_def (*‹(?x ⊑⇘?r⇙ ?y) = ?r ?x ?y›*) list_all2_lengthD (*‹list_all2 ?P ?xs ?ys ⟹ length ?xs = length ?ys›*)) have "length (?xcpt b) = length (?xcpt a)" 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))›*) split_beta (*‹(case ?prod of (x, xa) ⇒ ?f x xa) = ?f (fst ?prod) (snd ?prod)›*)) moreover have "⋀n. n < length (?xcpt b) ⟹ (?xcpt b) ! n ⊑⇘?r⇙ (?xcpt a) ! n" using lesub (*‹s ⊑⇘sup_state_opt P⇙ t›*) tSome (*‹t = ⌊a⌋›*) Some (*‹s = ⌊b⌋›*) a (*‹(a::ty list × ty err list) = (a1::ty list, b1::ty err list)›*) b (*‹b = (a2, b2)›*) a12 (*‹length a2 = length a1›*) 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))›*) split_beta (*‹(case ?prod of (x, xa) ⇒ ?f x xa) = ?f (fst ?prod) (snd ?prod)›*) fun_of_def (*‹fun_of ?S ≡ λx y. (x, y) ∈ ?S›*)) (*goal: ‹⋀n. n < length (xcpt_eff (is ! pc) P pc b xt) ⟹ xcpt_eff (is ! pc) P pc b xt ! n <=((=),sup_state_opt P) xcpt_eff (is ! pc) P pc a xt ! n›*) by (simp add: lesub_def (*‹(?x ⊑⇘?r⇙ ?y) = ?r ?x ?y›*)) ultimately have "?xcpt b [⊑⇘?r⇙] ?xcpt a" by (rule le_listI (*‹⟦length ?a = length ?b; ⋀n. n < length ?a ⟹ ?a ! n ⊑⇘?r⇙ ?b ! n⟧ ⟹ ?a [⊑⇘?r⇙] ?b›*)) then have "set (?xcpt b) {⊑⇘sup_state_opt P⇙} set (?xcpt a)" by (rule lesubstep_type_simple (*‹?xs [⊑⇘Product.le (=) ?r⇙] ?ys ⟹ set ?xs {⊑⇘?r⇙} set ?ys›*)) moreover note norm (*‹set (norm_eff (is ! pc) P pc b) {⊑⇘sup_state_opt P⇙} set (norm_eff (is ! pc) P pc a)›*) ultimately have "set (?norm b) ∪ set (?xcpt b) {⊑⇘sup_state_opt P⇙} set (?norm a) ∪ set (?xcpt a)" apply (intro lesubstep_union (*‹⟦?A₁ {⊑⇘?r⇙} ?B₁; ?A₂ {⊑⇘?r⇙} ?B₂⟧ ⟹ ?A₁ ∪ ?A₂ {⊑⇘?r⇙} ?B₁ ∪ ?B₂›*)) (*goals: 1. ‹⟦set (xcpt_eff (is ! pc) P pc b xt) {⊑⇘sup_state_opt P⇙} set (xcpt_eff (is ! pc) P pc a xt); set (norm_eff (is ! pc) P pc b) {⊑⇘sup_state_opt P⇙} set (norm_eff (is ! pc) P pc a)⟧ ⟹ set (norm_eff (is ! pc) P pc b) {⊑⇘sup_state_opt P⇙} set (norm_eff (is ! pc) P pc a)› 2. ‹⟦set (xcpt_eff (is ! pc) P pc b xt) {⊑⇘sup_state_opt P⇙} set (xcpt_eff (is ! pc) P pc a xt); set (norm_eff (is ! pc) P pc b) {⊑⇘sup_state_opt P⇙} set (norm_eff (is ! pc) P pc a)⟧ ⟹ set (xcpt_eff (is ! pc) P pc b xt) {⊑⇘sup_state_opt P⇙} set (xcpt_eff (is ! pc) P pc a xt)› discuss goal 1*) apply ((assumption)[1]) (*discuss goal 2*) . (*proven 2 subgoals*) then show "?thesis" (*goal: ‹set (eff pc s) {⊑⇘sup_state_opt P⇙} set (eff pc t)›*) using tSome (*‹t = ⌊a⌋›*) Some (*‹(s::(ty list × ty err list) option) = ⌊b::ty list × ty err list⌋›*) by (simp add: Effect.eff_def (*‹eff ?i ?P ?pc ?et ?t = (case ?t of None ⇒ [] | ⌊τ⌋ ⇒ norm_eff ?i ?P ?pc τ @ xcpt_eff ?i ?P ?pc τ ?et)›*)) qed qed (*>*) lemma (in JVM_sl) bounded_step: "bounded step (size is)" (*<*) by (auto simp: bounded_def (*‹bounded (?step::nat ⇒ ?'s ⇒ (nat × ?'s) list) (?n::nat) = (∀p<?n. ∀τ::?'s. ∀(q::nat, τ'::?'s)∈set (?step p τ). q < ?n)›*) err_step_def (*‹err_step (?n::nat) (?app::nat ⇒ ?'s ⇒ bool) (?step::nat ⇒ ?'s ⇒ (nat × ?'s) list) (?p::nat) (?t::?'s err) = (case ?t of Err ⇒ error ?n | OK (τ::?'s) ⇒ if ?app ?p τ then map_snd OK (?step ?p τ) else error ?n)›*) Effect.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))›*) 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)›*) error_def (*‹error (?n::nat) = map (λx::nat. (x, Err)) [0::nat..<?n]›*) map_snd_def (*‹map_snd (?f::?'b ⇒ ?'c) = map (λ(x::?'a, y::?'b). (x, ?f y))›*) split: err.splits (*‹(?P::?'b ⇒ bool) (case ?err::?'a err of Err ⇒ ?f1.0::?'b | OK (x::?'a) ⇒ (?f2.0::?'a ⇒ ?'b) x) = ((?err = Err ⟶ ?P ?f1.0) ∧ (∀x2::?'a. ?err = OK x2 ⟶ ?P (?f2.0 x2)))› ‹(?P::?'b ⇒ bool) (case ?err::?'a err of Err ⇒ ?f1.0::?'b | OK (x::?'a) ⇒ (?f2.0::?'a ⇒ ?'b) x) = (¬ (?err = Err ∧ ¬ ?P ?f1.0 ∨ (∃x2::?'a. ?err = OK x2 ∧ ¬ ?P (?f2.0 x2))))›*) option.splits (*‹(?P::?'b ⇒ bool) (case ?option::?'a option of None ⇒ ?f1.0::?'b | ⌊x::?'a⌋ ⇒ (?f2.0::?'a ⇒ ?'b) x) = ((?option = None ⟶ ?P ?f1.0) ∧ (∀x2::?'a. ?option = ⌊x2⌋ ⟶ ?P (?f2.0 x2)))› ‹(?P::?'b ⇒ bool) (case ?option::?'a option of None ⇒ ?f1.0::?'b | ⌊x::?'a⌋ ⇒ (?f2.0::?'a ⇒ ?'b) x) = (¬ (?option = None ∧ ¬ ?P ?f1.0 ∨ (∃x2::?'a. ?option = ⌊x2⌋ ∧ ¬ ?P (?f2.0 x2))))›*)) (*>*) theorem (in JVM_sl) step_mono: "wf_prog wf_mb P ⟹ mono r step (size is) A" (*<*) apply (simp add: JVM_le_Err_conv (*‹JVM_SemiType.le ?P ?m ?n = Err.le (sup_state_opt ?P)›*)) (*goal: ‹wf_prog wf_mb P ⟹ SemilatAlg.mono r step (length is) A›*) apply (insert bounded_step (*‹bounded step (length is)›*)) (*goal: ‹wf_prog wf_mb P ⟹ SemilatAlg.mono (Err.le (sup_state_opt P)) (err_step (length is) (λpc. app (is ! pc) P mxs T⇩r pc (length is) xt) (λpc. eff (is ! pc) P pc xt)) (length is) (states P mxs ((case b of Static ⇒ 0 | NonStatic ⇒ 1) + length Ts + mxl₀))›*) apply (unfold JVM_states_unfold (*‹states ?P ?mxs ?mxl ≡ err (opt (⋃ {nlists n (types ?P) |n. n ≤ ?mxs} × nlists ?mxl (err (types ?P))))›*)) (*goal: ‹⟦wf_prog wf_mb P; bounded step (length is)⟧ ⟹ SemilatAlg.mono (Err.le (sup_state_opt P)) (err_step (length is) (λpc. app (is ! pc) P mxs T⇩r pc (length is) xt) (λpc. eff (is ! pc) P pc xt)) (length is) (states P mxs ((case b of Static ⇒ 0 | NonStatic ⇒ 1) + length Ts + mxl₀))›*) apply (rule mono_lift (*‹⟦order ?r ?A; app_mono ?r ?app ?n ?A; bounded (err_step ?n ?app ?step) ?n; ∀s p t. s ∈ ?A ∧ p < ?n ∧ s ⊑⇘?r⇙ t ⟶ ?app p t ⟶ set (?step p s) {⊑⇘?r⇙} set (?step p t)⟧ ⟹ SemilatAlg.mono (Err.le ?r) (err_step ?n ?app ?step) ?n (err ?A)›*)) (*goals: 1. ‹⟦wf_prog wf_mb P; bounded step (length is)⟧ ⟹ order (sup_state_opt P) (opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists ((case b of Static ⇒ 0 | NonStatic ⇒ 1) + length Ts + mxl₀) (err (types P))))› 2. ‹⟦wf_prog wf_mb P; bounded step (length is)⟧ ⟹ app_mono (sup_state_opt P) (λpc. app (is ! pc) P mxs T⇩r pc (length is) xt) (length is) (opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists ((case b of Static ⇒ 0 | NonStatic ⇒ 1) + length Ts + mxl₀) (err (types P))))› 3. ‹⟦wf_prog wf_mb P; bounded step (length is)⟧ ⟹ bounded (err_step (length is) (λpc. app (is ! pc) P mxs T⇩r pc (length is) xt) (λpc. eff (is ! pc) P pc xt)) (length is)› 4. ‹⟦wf_prog wf_mb P; bounded step (length is)⟧ ⟹ ∀s p t. s ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists ((case b of Static ⇒ 0 | NonStatic ⇒ 1) + length Ts + mxl₀) (err (types P))) ∧ p < length is ∧ s ⊑⇘sup_state_opt P⇙ t ⟶ app (is ! p) P mxs T⇩r p (length is) xt t ⟶ set (eff (is ! p) P p xt s) {⊑⇘sup_state_opt P⇙} set (eff (is ! p) P p xt t)› discuss goal 1*) apply (subgoal_tac "b = Static ∨ b = NonStatic") (*goals: 1. ‹⟦wf_prog wf_mb P; bounded step (length is); b = Static ∨ b = NonStatic⟧ ⟹ order (sup_state_opt P) (opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists ((case b of Static ⇒ 0 | NonStatic ⇒ 1) + length Ts + mxl₀) (err (types P))))› 2. ‹⟦wf_prog wf_mb P; bounded step (length is)⟧ ⟹ b = Static ∨ b = NonStatic› discuss goal 1*) apply (fastforce 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))›*)) (*discuss goal 2*) apply (simp only:staticb (*‹b = Static ∨ b = NonStatic›*)) (*proven 2 subgoals*) (*discuss goal 2*) apply ((unfold app_mono_def (*‹app_mono ?r ?app ?n ?A = (∀s p t. s ∈ ?A ∧ p < ?n ∧ s ⊑⇘?r⇙ t ⟶ ?app p t ⟶ ?app p s)›*) lesub_def (*‹(?x ⊑⇘?r⇙ ?y) = ?r ?x ?y›*))[1]) (*top goal: ‹⟦wf_prog (wf_mb::jvm_prog ⇒ char list ⇒ jvm_method mdecl ⇒ bool) (P::jvm_prog); bounded (step::nat ⇒ (ty list × ty err list) option err ⇒ (nat × (ty list × ty err list) option err) list) (length (is::bytecode))⟧ ⟹ app_mono (sup_state_opt P) (λpc::nat. app (is ! pc) P (mxs::nat) (T⇩r::ty) pc (length is) (xt::ex_table)) (length is) (opt (⋃ {nlists n (types P) |n::nat. n ≤ mxs} × nlists ((case b::staticb of Static ⇒ 0::nat | NonStatic ⇒ 1::nat) + length (Ts::ty list) + (mxl₀::nat)) (err (types P))))› and 2 goals remain*) apply clarsimp (*top goal: ‹⟦wf_prog wf_mb P; bounded step (length is)⟧ ⟹ ∀s p t. s ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists ((case b of Static ⇒ 0 | NonStatic ⇒ 1) + length Ts + mxl₀) (err (types P))) ∧ p < length is ∧ P ⊢ s ≤' t ⟶ app (is ! p) P mxs T⇩r p (length is) xt t ⟶ app (is ! p) P mxs T⇩r p (length is) xt s› and 2 goals remain*) apply (erule (2) app_mono (*‹⟦wf_prog ?p ?P; ?P ⊢ ?τ ≤' ?τ'; app ?i ?P ?m ?rT ?pc ?mpc ?xt ?τ'⟧ ⟹ app ?i ?P ?m ?rT ?pc ?mpc ?xt ?τ›*)) (*discuss goal 3*) apply simp (*discuss goal 4*) apply ((unfold app_mono_def (*‹app_mono ?r ?app ?n ?A = (∀s p t. s ∈ ?A ∧ p < ?n ∧ s ⊑⇘?r⇙ t ⟶ ?app p t ⟶ ?app p s)›*) lesub_def (*‹(?x ⊑⇘?r⇙ ?y) = ?r ?x ?y›*))[1]) (*goal: ‹⟦wf_prog wf_mb P; bounded step (length is)⟧ ⟹ ∀s p t. s ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists ((case b of Static ⇒ 0 | NonStatic ⇒ 1) + length Ts + mxl₀) (err (types P))) ∧ p < length is ∧ s ⊑⇘sup_state_opt P⇙ t ⟶ app (is ! p) P mxs T⇩r p (length is) xt t ⟶ set (eff (is ! p) P p xt s) {⊑⇘sup_state_opt P⇙} set (eff (is ! p) P p xt t)›*) apply clarify (*goal: ‹⟦wf_prog wf_mb P; bounded step (length is)⟧ ⟹ ∀s p t. s ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists ((case b of Static ⇒ 0 | NonStatic ⇒ 1) + length Ts + mxl₀) (err (types P))) ∧ p < length is ∧ P ⊢ s ≤' t ⟶ app (is ! p) P mxs T⇩r p (length is) xt t ⟶ set (eff (is ! p) P p xt s) {⊑⇘sup_state_opt P⇙} set (eff (is ! p) P p xt t)›*) apply (drule eff_mono (*‹⟦wf_prog ?p P; ?pc < length is; ?s ⊑⇘sup_state_opt P⇙ ?t; app ?pc ?t⟧ ⟹ set (eff ?pc ?s) {⊑⇘sup_state_opt P⇙} set (eff ?pc ?t)›*)) (*goals: 1. ‹⋀s p t. ⟦bounded step (length is); s ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists ((case b of Static ⇒ 0 | NonStatic ⇒ 1) + length Ts + mxl₀) (err (types P))); p < length is; P ⊢ s ≤' t; app (is ! p) P mxs T⇩r p (length is) xt t⟧ ⟹ ?pc37 s p t < length is› 2. ‹⋀s p t. ⟦bounded step (length is); s ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists ((case b of Static ⇒ 0 | NonStatic ⇒ 1) + length Ts + mxl₀) (err (types P))); p < length is; P ⊢ s ≤' t; app (is ! p) P mxs T⇩r p (length is) xt t⟧ ⟹ ?s37 s p t ⊑⇘sup_state_opt P⇙ ?t37 s p t› 3. ‹⋀s p t. ⟦bounded step (length is); s ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists ((case b of Static ⇒ 0 | NonStatic ⇒ 1) + length Ts + mxl₀) (err (types P))); p < length is; P ⊢ s ≤' t; app (is ! p) P mxs T⇩r p (length is) xt t⟧ ⟹ app (?pc37 s p t) (?t37 s p t)› 4. ‹⋀s p t. ⟦bounded step (length is); s ∈ opt (⋃ {nlists n (types P) |n. n ≤ mxs} × nlists ((case b of Static ⇒ 0 | NonStatic ⇒ 1) + length Ts + mxl₀) (err (types P))); p < length is; P ⊢ s ≤' t; app (is ! p) P mxs T⇩r p (length is) xt t; set (eff (?pc37 s p t) (?s37 s p t)) {⊑⇘sup_state_opt P⇙} set (eff (?pc37 s p t) (?t37 s p t))⟧ ⟹ set (eff (is ! p) P p xt s) {⊑⇘sup_state_opt P⇙} set (eff (is ! p) P p xt t)› discuss goal 1*) apply ((auto simp add: lesub_def (*‹((?x::?'a::type) ⊑⇘?r::?'a::type ⇒ ?'a::type ⇒ bool⇙ (?y::?'a::type)) = ?r ?x ?y›*))[1]) (*discuss goal 2*) apply ((auto simp add: lesub_def (*‹(?x ⊑⇘?r⇙ ?y) = ?r ?x ?y›*))[1]) (*discuss goal 3*) apply ((auto simp add: lesub_def (*‹(?x ⊑⇘?r⇙ ?y) = ?r ?x ?y›*))[1]) (*discuss goal 4*) apply ((auto simp add: lesub_def (*‹(?x ⊑⇘?r⇙ ?y) = ?r ?x ?y›*))[1]) (*proven 4 subgoals*) (*proven 4 subgoals*) . (* proof - assume wf: "wf_prog wf_mb P" let ?r = "sup_state_opt P" and ?n = "length is" and ?app = app and ?step = eff let ?A = "opt (⋃ {list n (types P) |n. n ≤ mxs} × list ((case b of Static ⇒ 0 | NonStatic ⇒ 1) + length Ts + mxl₀) (err (types P)))" have "order ?r ?A" using wf by simp moreover have "app_mono ?r ?app ?n ?A" using app_mono[OF wf] by (clarsimp simp: app_mono_def lesub_def) moreover have "bounded (err_step ?n ?app ?step) ?n" using bounded_step by simp moreover have "∀s p t. s ∈ ?A ∧ p < ?n ∧ s ⊑⇘?r⇙ t ⟶ ?app p t ⟶ set (?step p s) {⊑⇘?r⇙} set (?step p t)" using eff_mono[OF wf] by simp ultimately have "mono (Err.le ?r) (err_step ?n ?app ?step) ?n (err ?A)" by(rule mono_lift) then show "mono r step (size is) A" using bounded_step by (simp add: JVM_le_Err_conv JVM_states_unfold) qed *) (*>*) lemma (in start_context) first_in_A [iff]: "OK first ∈ A" using Ts (*‹set (Ts::ty list) ⊆ types (P::jvm_prog)›*) C (*‹is_class P C›*) apply (cases b) (*goals: 1. ‹⟦set (Ts::ty list) ⊆ types (P::jvm_prog); is_class P (C::char list); (b::staticb) = Static⟧ ⟹ OK (first::(ty list × ty err list) option) ∈ (A::(ty list × ty err list) option err set)› 2. ‹⟦set (Ts::ty list) ⊆ types (P::jvm_prog); is_class P (C::char list); (b::staticb) = NonStatic⟧ ⟹ OK (first::(ty list × ty err list) option) ∈ (A::(ty list × ty err list) option err set)› discuss goal 1*) apply (force intro!: nlists_appendI (*‹⟦(?a::?'a list) ∈ nlists (?n::nat) (?A::?'a set); (?b::?'a list) ∈ nlists (?m::nat) ?A⟧ ⟹ ?a @ ?b ∈ nlists (?n + ?m) ?A›*) 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))))›*)) (*discuss goal 2*) apply (force intro!: nlists_appendI (*‹⟦?a ∈ nlists ?n ?A; ?b ∈ nlists ?m ?A⟧ ⟹ ?a @ ?b ∈ nlists (?n + ?m) ?A›*) simp add: JVM_states_unfold (*‹states ?P ?mxs ?mxl ≡ err (opt (⋃ {nlists n (types ?P) |n. n ≤ ?mxs} × nlists ?mxl (err (types ?P))))›*)) (*proven 2 subgoals*) . lemma (in JVM_sl) wt_method_def2: "wt_method P C' b Ts T⇩r mxs mxl₀ is xt τs = (is ≠ [] ∧ (b = Static ∨ b = NonStatic) ∧ size τs = size is ∧ OK ` set τs ⊆ states P mxs mxl ∧ wt_start P C' b Ts mxl₀ τs ∧ wt_app_eff (sup_state_opt P) app eff τs)" (*<*)using staticb (*‹b = Static ∨ b = NonStatic›*) apply (unfold wt_method_def (*‹wt_method (?P::?'m::type prog) (?C::char list) (?b::staticb) (?Ts::ty list) (?T⇩r::ty) (?mxs::nat) (?mxl₀::nat) (?is::bytecode) (?xt::ex_table) (?τs::(ty list × ty err list) option list) ≡ (?b = Static ∨ ?b = NonStatic) ∧ (0::nat) < length ?is ∧ length ?τs = length ?is ∧ check_types ?P ?mxs ((case ?b of Static ⇒ 0::nat | NonStatic ⇒ 1::nat) + 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)›*) wt_app_eff_def (*‹wt_app_eff (?r::?'s::type ⇒ ?'s::type ⇒ bool) (?app::nat ⇒ ?'s::type ⇒ bool) (?step::nat ⇒ ?'s::type ⇒ (nat × ?'s::type) list) (?τs::?'s::type list) = (∀p<length ?τs. ?app p (?τs ! p) ∧ (∀(q::nat, τ::?'s::type)∈set (?step p (?τs ! p)). τ ⊑⇘?r⇙ ?τs ! q))›*) 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')›*) lesub_def (*‹((?x::?'a::type) ⊑⇘?r::?'a::type ⇒ ?'a::type ⇒ bool⇙ (?y::?'a::type)) = ?r ?x ?y›*) check_types_def (*‹check_types (?P::?'m::type prog) (?mxs::nat) (?mxl::nat) (?τs::(ty list × ty err list) option err list) ≡ set ?τs ⊆ states ?P ?mxs ?mxl›*)) (*goal: ‹wt_method P C' b Ts T⇩r mxs mxl₀ is xt τs = (is ≠ [] ∧ (b = Static ∨ b = NonStatic) ∧ length τs = length is ∧ OK ` set τs ⊆ states P mxs mxl ∧ wt_start P C' b Ts mxl₀ τs ∧ wt_app_eff (sup_state_opt P) app eff τs)›*) by auto (*>*) end
{ "path": "afp-2025-02-12/thys/JinjaDCI/BV/TF_JVM.thy", "repo": "afp-2025-02-12", "sha": "1ddbc55a290096b1f3cf72a445a1ca4758d8fa003eae8bc1504219896b156e5d" }
✐‹creator "Kevin Kappelmann"› subsubsection ‹Connected› theory Binary_Relations_Connected imports Binary_Relation_Functions begin consts connected_on :: "'a ⇒ 'b ⇒ bool" overloading connected_on_pred ≡ "connected_on :: ('a ⇒ bool) ⇒ ('a ⇒ 'a ⇒ bool) ⇒ bool" begin definition "connected_on_pred P R ≡ ∀x y : P. x ≠ y ⟶ R x y ∨ R y x" end lemma connected_onI [intro]: assumes "⋀x y. P x ⟹ P y ⟹ x ≠ y ⟹ R x y ∨ R y x" shows "connected_on P R" using assms (*‹⟦P ?x; P ?y; ?x ≠ ?y⟧ ⟹ R ?x ?y ∨ R ?y ?x›*) unfolding connected_on_pred_def (*goal: ‹∀x : P. ∀y : P. x ≠ y ⟶ R x y ∨ R y x›*) by blast lemma connected_onE [elim]: assumes "connected_on P R" and "P x" "P y" obtains "x = y" | "R x y" | "R y x" using assms (*‹connected_on P R› ‹(P::'a ⇒ bool) (x::'a)› ‹P y›*) unfolding connected_on_pred_def (*goal: ‹⟦x = y ⟹ thesis; R x y ⟹ thesis; R y x ⟹ thesis⟧ ⟹ thesis›*) by auto lemma connected_on_rel_inv_iff_connected_on [iff]: "connected_on (P :: 'a ⇒ bool) (R :: 'a ⇒ 'a ⇒ bool)¯ ⟷ connected_on P R" by blast consts connected :: "'a ⇒ bool" overloading connected ≡ "connected :: ('a ⇒ 'a ⇒ bool) ⇒ bool" begin definition "connected :: ('a ⇒ 'a ⇒ bool) ⇒ bool ≡ connected_on (⊤ :: 'a ⇒ bool)" end lemma connected_eq_connected_on: "(connected :: ('a ⇒ 'a ⇒ bool) ⇒ _) = connected_on (⊤ :: 'a ⇒ bool)" unfolding connected_def (*goal: ‹connected_on ⊤ = connected_on ⊤›*) by standard lemma connected_eq_connected_on_uhint [uhint]: "P ≡ (⊤ :: 'a ⇒ bool) ⟹ (connected :: ('a ⇒ 'a ⇒ bool) ⇒ _) ≡ connected_on P" by (simp add: connected_eq_connected_on (*‹connected = connected_on ⊤›*)) lemma connectedI [intro]: assumes "⋀x y. x ≠ y ⟹ R x y ∨ R y x" shows "connected R" using assms (*‹?x ≠ ?y ⟹ R ?x ?y ∨ R ?y ?x›*) by (urule connected_onI) lemma connectedE [elim]: assumes "connected R" and "x ≠ y" obtains "R x y" | "R y x" using assms (*‹connected R› ‹x ≠ y›*) apply (urule (e) connected_onE where chained = insert) (*goals: 1. ‹⟦(R::'a::type ⇒ 'a::type ⇒ bool) (x::'a::type) (y::'a::type) ⟹ thesis::bool; R y x ⟹ thesis; x ≠ y⟧ ⟹ ⊤ (?x8::'a::type)› 2. ‹⟦(R::'a::type ⇒ 'a::type ⇒ bool) (x::'a::type) (y::'a::type) ⟹ thesis::bool; R y x ⟹ thesis; x ≠ y⟧ ⟹ ⊤ (?y8::'a::type)› 3. ‹⟦(R::'a::type ⇒ 'a::type ⇒ bool) (x::'a::type) (y::'a::type) ⟹ thesis::bool; R y x ⟹ thesis; x ≠ y; (?x8::'a::type) = (?y8::'a::type)⟧ ⟹ thesis› 4. ‹⟦(R::'a::type ⇒ 'a::type ⇒ bool) (x::'a::type) (y::'a::type) ⟹ thesis::bool; R y x ⟹ thesis; x ≠ y; R (?x8::'a::type) (?y8::'a::type)⟧ ⟹ thesis› 5. ‹⟦(R::'a::type ⇒ 'a::type ⇒ bool) (x::'a::type) (y::'a::type) ⟹ thesis::bool; R y x ⟹ thesis; x ≠ y; R (?y8::'a::type) (?x8::'a::type)⟧ ⟹ thesis› 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 connected_on_if_connected: fixes P :: "'a ⇒ bool" and R :: "'a ⇒ 'a ⇒ bool" assumes "connected R" shows "connected_on P R" using assms (*‹connected R›*) apply (intro connected_onI (*‹(⋀x y. ⟦?P x; ?P y; x ≠ y⟧ ⟹ ?R x y ∨ ?R y x) ⟹ connected_on ?P ?R›*)) (*goal: ‹connected_on P R›*) by blast end
{ "path": "afp-2025-02-12/thys/Transport/HOL_Basics/Binary_Relations/Properties/Binary_Relations_Connected.thy", "repo": "afp-2025-02-12", "sha": "1940c66c0f56624dcfb97b934c6404b0d87b6dd3b9c33cd66bf538e819842637" }
(* Title: ListSlice.thy Date: Oct 2006 Author: David Trachtenherz *) section ‹Additional definitions and results for lists› theory ListSlice imports "List-Infinite.ListInf" begin subsection ‹Slicing lists into lists of lists› definition ilist_slice :: "'a ilist ⇒ nat ⇒ 'a list ilist" where "ilist_slice f k ≡ λx. map f [x * k..<Suc x * k]" primrec list_slice_aux :: "'a list ⇒ nat ⇒ nat ⇒ 'a list list" where "list_slice_aux xs k 0 = []" | "list_slice_aux xs k (Suc n) = take k xs # list_slice_aux (xs ↑ k) k n" definition list_slice :: "'a list ⇒ nat ⇒ 'a list list" where "list_slice xs k ≡ list_slice_aux xs k (length xs div k)" definition list_slice2 :: "'a list ⇒ nat ⇒ 'a list list" where "list_slice2 xs k ≡ list_slice xs k @ (if length xs mod k = 0 then [] else [xs ↑ (length xs div k * k)])" text ‹ No function ‹list_unslice› for finite lists is needed because the corresponding functionality is already provided by ‹concat›. Therefore, only a ‹ilist_unslice› function for infinite lists is defined.› definition ilist_unslice :: "'a list ilist ⇒ 'a ilist" where "ilist_unslice f ≡ λn. f (n div length (f 0)) ! (n mod length (f 0))" lemma list_slice_aux_length: "⋀xs. length (list_slice_aux xs k n) = n" apply (induct n) (*goals: 1. ‹⋀xs. length (list_slice_aux xs k 0) = 0› 2. ‹⋀n xs. (⋀xs. length (list_slice_aux xs k n) = n) ⟹ length (list_slice_aux xs k (Suc n)) = Suc n› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) . lemma list_slice_aux_nth: " ⋀m xs. m < n ⟹ (list_slice_aux xs k n) ! m = (xs ↑ (m * k) ↓ k)" apply (induct n) (*goals: 1. ‹⋀m xs. m < 0 ⟹ list_slice_aux xs k 0 ! m = xs ↑ (m * k) ↓ k› 2. ‹⋀n m xs. ⟦⋀m xs. m < n ⟹ list_slice_aux xs k n ! m = xs ↑ (m * k) ↓ k; m < Suc n⟧ ⟹ list_slice_aux xs k (Suc n) ! m = xs ↑ (m * k) ↓ k› discuss goal 1*) apply simp (*discuss goal 2*) apply (simp add: nth_Cons' (*‹(?x # ?xs) ! ?n = (if ?n = 0 then ?x else ?xs ! (?n - 1))›*) diff_mult_distrib (*‹(?m - ?n) * ?k = ?m * ?k - ?n * ?k›*)) (*proven 2 subgoals*) . lemma list_slice_length: "length (list_slice xs k) = length xs div k" by (simp add: list_slice_def (*‹list_slice ?xs ?k ≡ list_slice_aux ?xs ?k (length ?xs div ?k)›*) list_slice_aux_length (*‹length (list_slice_aux ?xs ?k ?n) = ?n›*)) lemma list_slice_0: "list_slice xs 0 = []" by (simp add: list_slice_def (*‹list_slice ?xs ?k ≡ list_slice_aux ?xs ?k (length ?xs div ?k)›*)) lemma list_slice_1: "list_slice xs (Suc 0) = map (λx. [x]) xs" by (fastforce simp: list_eq_iff (*‹(?xs = ?ys) = (length ?xs = length ?ys ∧ (∀i<length ?xs. ?xs ! i = ?ys ! i))›*) list_slice_def (*‹list_slice ?xs ?k ≡ list_slice_aux ?xs ?k (length ?xs div ?k)›*) list_slice_aux_nth (*‹?m < ?n ⟹ list_slice_aux ?xs ?k ?n ! ?m = ?xs ↑ (?m * ?k) ↓ ?k›*) list_slice_aux_length (*‹length (list_slice_aux ?xs ?k ?n) = ?n›*)) lemma list_slice_less: "length xs < k ⟹ list_slice xs k = []" by (simp add: list_slice_def (*‹list_slice ?xs ?k ≡ list_slice_aux ?xs ?k (length ?xs div ?k)›*)) lemma list_slice_Nil: "list_slice [] k = []" by (simp add: list_slice_def (*‹list_slice ?xs ?k ≡ list_slice_aux ?xs ?k (length ?xs div ?k)›*)) lemma list_slice_nth: " m < length xs div k ⟹ list_slice xs k ! m = xs ↑ (m * k) ↓ k" by (simp add: list_slice_def (*‹list_slice ?xs ?k ≡ list_slice_aux ?xs ?k (length ?xs div ?k)›*) list_slice_aux_nth (*‹?m < ?n ⟹ list_slice_aux ?xs ?k ?n ! ?m = ?xs ↑ (?m * ?k) ↓ ?k›*)) lemma list_slice_nth_length: " m < length xs div k ⟹ length ((list_slice xs k) ! m) = k" apply (case_tac "length xs < k") (*goal: ‹(m::nat) < length (xs::'a list) div (k::nat) ⟹ length (list_slice xs k ! m) = k›*) apply simp (*top goal: ‹⟦m < length xs div k; length xs < k⟧ ⟹ length (list_slice xs k ! m) = k› and 1 goal remains*) apply (simp add: list_slice_nth (*‹?m < length ?xs div ?k ⟹ list_slice ?xs ?k ! ?m = ?xs ↑ (?m * ?k) ↓ ?k›*)) (*goal: ‹⟦m < length xs div k; ¬ length xs < k⟧ ⟹ length (list_slice xs k ! m) = k›*) thm less_div_imp_mult_add_divisor_le apply (drule less_div_imp_mult_add_divisor_le (*‹(?x::nat) < (?n::nat) div (?m::nat) ⟹ ?x * ?m + ?m ≤ ?n›*)) (*goal: ‹⟦m < length xs div k; ¬ length xs < k⟧ ⟹ min (length xs - m * k) k = k›*) by simp lemma list_slice_nth_eq_sublist_list: " m < length xs div k ⟹ list_slice xs k ! m = sublist_list xs [m * k..<m * k + k]" apply (simp add: list_slice_nth (*‹?m < length ?xs div ?k ⟹ list_slice ?xs ?k ! ?m = ?xs ↑ (?m * ?k) ↓ ?k›*)) (*goal: ‹m < length xs div k ⟹ list_slice xs k ! m = sublist_list xs [m * k..<m * k + k]›*) apply (rule take_drop_eq_sublist_list (*‹?m + ?n ≤ length ?xs ⟹ ?xs ↑ ?m ↓ ?n = sublist_list ?xs [?m..<?m + ?n]›*)) (*goal: ‹m < length xs div k ⟹ xs ↑ (m * k) ↓ k = sublist_list xs [m * k..<m * k + k]›*) apply (rule less_div_imp_mult_add_divisor_le (*‹?x < ?n div ?m ⟹ ?x * ?m + ?m ≤ ?n›*)) (*goal: ‹m < length xs div k ⟹ m * k + k ≤ length xs›*) by assumption lemma list_slice_nth_nth: " ⟦ m < length xs div k; n < k ⟧ ⟹ (list_slice xs k) ! m ! n = xs ! (m * k + n)" apply (frule list_slice_nth_length[of m xs k] (*‹m < length xs div k ⟹ length (list_slice xs k ! m) = k›*)) (*goal: ‹⟦m < length xs div k; n < k⟧ ⟹ list_slice xs k ! m ! n = xs ! (m * k + n)›*) by (simp add: list_slice_nth (*‹?m < length ?xs div ?k ⟹ list_slice ?xs ?k ! ?m = ?xs ↑ (?m * ?k) ↓ ?k›*)) lemma list_slice_nth_nth_rev: " n < length xs div k * k ⟹ (list_slice xs k) ! (n div k) ! (n mod k) = xs ! n" apply (case_tac "k = 0") (*goals: 1. ‹⟦n < length xs div k * k; k = 0⟧ ⟹ list_slice xs k ! (n div k) ! (n mod k) = xs ! n› 2. ‹⟦n < length xs div k * k; k ≠ 0⟧ ⟹ list_slice xs k ! (n div k) ! (n mod k) = xs ! n› discuss goal 1*) apply simp (*discuss goal 2*) apply (simp add: list_slice_nth_nth (*‹⟦?m < length ?xs div ?k; ?n < ?k⟧ ⟹ list_slice ?xs ?k ! ?m ! ?n = ?xs ! (?m * ?k + ?n)›*) div_less_conv (*‹0 < ?m ⟹ (?n div ?m < ?k) = (?n < ?k * ?m)›*)) (*proven 2 subgoals*) . lemma list_slice_eq_list_slice_take: " list_slice (xs ↓ (length xs div k * k)) k = list_slice xs k" apply (case_tac "k = 0") (*goals: 1. ‹(k::nat) = (0::nat) ⟹ list_slice ((xs::'a list) ↓ (length xs div k * k)) k = list_slice xs k› 2. ‹(k::nat) ≠ (0::nat) ⟹ list_slice ((xs::'a list) ↓ (length xs div k * k)) k = list_slice xs k› discuss goal 1*) apply (simp add: list_slice_0 (*‹list_slice ?xs 0 = []›*)) (*discuss goal 2*) apply (simp add: list_eq_iff (*‹(?xs = ?ys) = (length ?xs = length ?ys ∧ (∀i<length ?xs. ?xs ! i = ?ys ! i))›*) list_slice_length (*‹length (list_slice ?xs ?k) = length ?xs div ?k›*)) (*goal: ‹k ≠ 0 ⟹ list_slice (xs ↓ (length xs div k * k)) k = list_slice xs k›*) apply (simp add: div_mult_le (*‹?n div ?m * ?m ≤ ?n›*) min_eqR (*‹?b ≤ ?a ⟹ min ?a ?b = ?b›*) list_slice_nth (*‹?m < length ?xs div ?k ⟹ list_slice ?xs ?k ! ?m = ?xs ↑ (?m * ?k) ↓ ?k›*)) (*goal: ‹(0::nat) < (k::nat) ⟹ ∀i<length (xs::'a list) div k. length (list_slice (xs ↓ (length xs div k * k)) k ! i) = length (list_slice xs k ! i) ∧ (∀ia<length (list_slice (xs ↓ (length xs div k * k)) k ! i). list_slice (xs ↓ (length xs div k * k)) k ! i ! ia = list_slice xs k ! i ! ia)›*) apply clarify (*goal: ‹0 < k ⟹ ∀i<length xs div k. min (length xs div k * k - i * k) k = min (length xs - i * k) k ∧ (∀ia. ia < length xs div k * k - i * k ∧ ia < k ⟶ xs ↓ (length xs div k * k) ! (i * k + ia) = xs ↑ (i * k) ! ia)›*) apply (rename_tac i) (*goal: ‹⋀i::nat. ⟦(0::nat) < (k::nat); i < length (xs::'a::type list) div k⟧ ⟹ min (length xs div k * k - i * k) k = min (length xs - i * k) k ∧ (∀ia::nat. ia < length xs div k * k - i * k ∧ ia < k ⟶ xs ↓ (length xs div k * k) ! (i * k + ia) = xs ↑ (i * k) ! ia)›*) apply (subgoal_tac "k ≤ length xs div k * k - i * k") (*goals: 1. ‹⋀i. ⟦0 < k; i < length xs div k; k ≤ length xs div k * k - i * k⟧ ⟹ min (length xs div k * k - i * k) k = min (length xs - i * k) k ∧ (∀ia. ia < length xs div k * k - i * k ∧ ia < k ⟶ xs ↓ (length xs div k * k) ! (i * k + ia) = xs ↑ (i * k) ! ia)› 2. ‹⋀i. ⟦0 < k; i < length xs div k⟧ ⟹ k ≤ length xs div k * k - i * k› discuss goal 1*) apply (subgoal_tac "length xs div k * k - i * k ≤ length xs - i * k") (*goals: 1. ‹⋀i. ⟦0 < k; i < length xs div k; k ≤ length xs div k * k - i * k; length xs div k * k - i * k ≤ length xs - i * k⟧ ⟹ min (length xs div k * k - i * k) k = min (length xs - i * k) k ∧ (∀ia. ia < length xs div k * k - i * k ∧ ia < k ⟶ xs ↓ (length xs div k * k) ! (i * k + ia) = xs ↑ (i * k) ! ia)› 2. ‹⋀i. ⟦0 < k; i < length xs div k; k ≤ length xs div k * k - i * k⟧ ⟹ length xs div k * k - i * k ≤ length xs - i * k› discuss goal 1*) apply (simp add: min_eqR (*‹?b ≤ ?a ⟹ min ?a ?b = ?b›*)) (*top goal: ‹⋀i::nat. ⟦(0::nat) < (k::nat); i < length (xs::'a list) div k; k ≤ length xs div k * k - i * k; length xs div k * k - i * k ≤ length xs - i * k⟧ ⟹ min (length xs div k * k - i * k) k = min (length xs - i * k) k ∧ (∀ia::nat. ia < length xs div k * k - i * k ∧ ia < k ⟶ xs ↓ (length xs div k * k) ! (i * k + ia) = xs ↑ (i * k) ! ia)› and 2 goals remain*) apply (simp add: less_diff_conv (*‹((?i::nat) < (?j::nat) - (?k::nat)) = (?i + ?k < ?j)›*)) (*discuss goal 2*) apply (simp add: div_mult_cancel (*‹(?a::?'a::semiring_modulo) div (?b::?'a::semiring_modulo) * ?b = ?a - ?a mod ?b›*)) (*proven 2 subgoals*) (*discuss goal 2*) apply (drule_tac m=i in Suc_leI (*‹?m < ?n ⟹ Suc ?m ≤ ?n›*)) (*goal: ‹⋀i. ⟦0 < k; i < length xs div k⟧ ⟹ k ≤ length xs div k * k - i * k›*) apply (drule mult_le_mono1[of _ _ k] (*‹(?i::nat) ≤ (?j::nat) ⟹ ?i * (k::nat) ≤ ?j * k›*)) (*goal: ‹⋀i::nat. ⟦(0::nat) < (k::nat); Suc i ≤ length (xs::'a::type list) div k⟧ ⟹ k ≤ length xs div k * k - i * k›*) apply simp (*proven 2 subgoals*) (*proven 2 subgoals*) . lemma list_slice_append_mult: " ⋀xs. length xs = m * k ⟹ list_slice (xs @ ys) k = list_slice xs k @ list_slice ys k" apply (case_tac "k = 0") (*goals: 1. ‹⋀xs. ⟦length xs = m * k; k = 0⟧ ⟹ list_slice (xs @ ys) k = list_slice xs k @ list_slice ys k› 2. ‹⋀xs. ⟦length xs = m * k; k ≠ 0⟧ ⟹ list_slice (xs @ ys) k = list_slice xs k @ list_slice ys k› discuss goal 1*) apply (simp add: list_slice_0 (*‹list_slice ?xs 0 = []›*)) (*discuss goal 2*) apply (induct m) (*goals: 1. ‹⋀xs. ⟦length xs = 0 * k; k ≠ 0⟧ ⟹ list_slice (xs @ ys) k = list_slice xs k @ list_slice ys k› 2. ‹⋀m xs. ⟦⋀xs. ⟦length xs = m * k; k ≠ 0⟧ ⟹ list_slice (xs @ ys) k = list_slice xs k @ list_slice ys k; length xs = Suc m * k; k ≠ 0⟧ ⟹ list_slice (xs @ ys) k = list_slice xs k @ list_slice ys k› discuss goal 1*) apply (simp add: list_slice_Nil (*‹list_slice [] ?k = []›*)) (*discuss goal 2*) apply (simp add: list_slice_def (*‹list_slice ?xs ?k ≡ list_slice_aux ?xs ?k (length ?xs div ?k)›*)) (*goal: ‹⋀(m::nat) xs::'a list. ⟦⋀xs::'a list. ⟦length xs = m * (k::nat); k ≠ (0::nat)⟧ ⟹ list_slice (xs @ (ys::'a list)) k = list_slice xs k @ list_slice ys k; length xs = Suc m * k; k ≠ (0::nat)⟧ ⟹ list_slice (xs @ ys) k = list_slice xs k @ list_slice ys k›*) apply (simp add: list_slice_def (*‹list_slice ?xs ?k ≡ list_slice_aux ?xs ?k (length ?xs div ?k)›*) add.commute[of _ "length ys"] (*‹?a + length ys = length ys + ?a›*) add.assoc[symmetric] (*‹?a + (?b + ?c) = ?a + ?b + ?c›*)) (*proven 2 subgoals*) (*proven 2 subgoals*) . lemma list_slice_append_mod: " length xs mod k = 0 ⟹ list_slice (xs @ ys) k = list_slice xs k @ list_slice ys k" by (auto intro: list_slice_append_mult (*‹length ?xs = ?m * ?k ⟹ list_slice (?xs @ ?ys) ?k = list_slice ?xs ?k @ list_slice ?ys ?k›*) elim!: dvdE (*‹⟦?b dvd ?a; ⋀k. ?a = ?b * k ⟹ ?P⟧ ⟹ ?P›*)) lemma list_slice_div_eq_1[rule_format]: " length xs div k = Suc 0 ⟹ list_slice xs k = [take k xs]" by (simp add: list_slice_def (*‹list_slice ?xs ?k ≡ list_slice_aux ?xs ?k (length ?xs div ?k)›*)) lemma list_slice_div_eq_Suc[rule_format]: " length xs div k = Suc n ⟹ list_slice xs k = list_slice (xs ↓ (n * k)) k @ [xs ↑ (n * k) ↓ k]" apply (case_tac "k = 0") (*goals: 1. ‹⟦length xs div k = Suc n; k = 0⟧ ⟹ list_slice xs k = list_slice (xs ↓ (n * k)) k @ [xs ↑ (n * k) ↓ k]› 2. ‹⟦length xs div k = Suc n; k ≠ 0⟧ ⟹ list_slice xs k = list_slice (xs ↓ (n * k)) k @ [xs ↑ (n * k) ↓ k]› discuss goal 1*) apply simp (*discuss goal 2*) apply (subgoal_tac "n * k < length xs") (*goals: 1. ‹⟦length xs div k = Suc n; k ≠ 0; n * k < length xs⟧ ⟹ list_slice xs k = list_slice (xs ↓ (n * k)) k @ [xs ↑ (n * k) ↓ k]› 2. ‹⟦length xs div k = Suc n; k ≠ 0⟧ ⟹ n * k < length xs› discuss goal 1*) apply (insert list_slice_append_mult[of "take (n * k) xs" n k "drop (n * k) xs"] (*‹length (xs ↓ (n * k)) = n * k ⟹ list_slice (xs ↓ (n * k) @ xs ↑ (n * k)) k = list_slice (xs ↓ (n * k)) k @ list_slice (xs ↑ (n * k)) k›*)) (*top goal: ‹⟦length (xs::'a list) div (k::nat) = Suc (n::nat); k ≠ (0::nat); n * k < length xs⟧ ⟹ list_slice xs k = list_slice (xs ↓ (n * k)) k @ [xs ↑ (n * k) ↓ k]› and 1 goal remains*) apply (simp add: min_eqR (*‹?b ≤ ?a ⟹ min ?a ?b = ?b›*)) (*top goal: ‹⟦length xs div k = Suc n; k ≠ 0; n * k < length xs; length (xs ↓ (n * k)) = n * k ⟹ list_slice (xs ↓ (n * k) @ xs ↑ (n * k)) k = list_slice (xs ↓ (n * k)) k @ list_slice (xs ↑ (n * k)) k⟧ ⟹ list_slice xs k = list_slice (xs ↓ (n * k)) k @ [xs ↑ (n * k) ↓ k]› and 1 goal remains*) apply (rule list_slice_div_eq_1 (*‹length (?xs::?'a::type list) div (?k::nat) = Suc (0::nat) ⟹ list_slice ?xs ?k = [?xs ↓ ?k]›*)) (*top goal: ‹⟦length (xs::'a list) div (k::nat) = Suc (n::nat); (0::nat) < k; n * k < length xs; list_slice xs k = list_slice (xs ↓ (n * k)) k @ list_slice (xs ↑ (n * k)) k⟧ ⟹ list_slice (xs ↑ (n * k)) k = [xs ↑ (n * k) ↓ k]› and 1 goal remains*) apply (simp add: div_diff_mult_self1 (*‹(?n - ?k * ?m) div ?m = ?n div ?m - ?k›*)) (*discuss goal 2*) apply (case_tac "length xs = 0") (*goals: 1. ‹⟦length xs div k = Suc n; k ≠ 0; length (xs ↓ (n * k)) = n * k ⟹ list_slice (xs ↓ (n * k) @ xs ↑ (n * k)) k = list_slice (xs ↓ (n * k)) k @ list_slice (xs ↑ (n * k)) k; length xs = 0⟧ ⟹ n * k < length xs› 2. ‹⟦length xs div k = Suc n; k ≠ 0; length (xs ↓ (n * k)) = n * k ⟹ list_slice (xs ↓ (n * k) @ xs ↑ (n * k)) k = list_slice (xs ↓ (n * k)) k @ list_slice (xs ↑ (n * k)) k; length xs ≠ 0⟧ ⟹ n * k < length xs› discuss goal 1*) apply simp (*discuss goal 2*) apply (drule_tac arg_cong[where f="λx. x - Suc 0"] (*‹?x = ?y ⟹ ?x - Suc 0 = ?y - Suc 0›*)) (*goal: ‹⟦length xs div k = Suc n; k ≠ 0; length (xs ↓ (n * k)) = n * k ⟹ list_slice (xs ↓ (n * k) @ xs ↑ (n * k)) k = list_slice (xs ↓ (n * k)) k @ list_slice (xs ↑ (n * k)) k; length xs ≠ 0⟧ ⟹ n * k < length xs›*) apply (drule sym (*‹(?s::?'a) = (?t::?'a) ⟹ ?t = ?s›*)) (*goal: ‹⟦(k::nat) ≠ (0::nat); length ((xs::'a list) ↓ ((n::nat) * k)) = n * k ⟹ list_slice (xs ↓ (n * k) @ xs ↑ (n * k)) k = list_slice (xs ↓ (n * k)) k @ list_slice (xs ↑ (n * k)) k; length xs ≠ (0::nat); length xs div k - Suc (0::nat) = Suc n - Suc (0::nat)⟧ ⟹ n * k < length xs›*) apply (simp add: diff_mult_distrib (*‹(?m - ?n) * ?k = ?m * ?k - ?n * ?k›*) div_mult_cancel (*‹?a div ?b * ?b = ?a - ?a mod ?b›*)) (*proven 2 subgoals*) (*proven 2 subgoals*) (*proven 2 subgoals*) . lemma list_slice2_mod_0: " length xs mod k = 0 ⟹ list_slice2 xs k = list_slice xs k" by (simp add: list_slice2_def (*‹list_slice2 ?xs ?k ≡ list_slice ?xs ?k @ (if length ?xs mod ?k = 0 then [] else [?xs ↑ (length ?xs div ?k * ?k)])›*)) lemma list_slice2_mod_gr0: " 0 < length xs mod k ⟹ list_slice2 xs k = list_slice xs k @ [xs ↑ (length xs div k * k)]" by (simp add: list_slice2_def (*‹list_slice2 ?xs ?k ≡ list_slice ?xs ?k @ (if length ?xs mod ?k = 0 then [] else [?xs ↑ (length ?xs div ?k * ?k)])›*)) lemma list_slice2_length: " length (list_slice2 xs k) = ( if length xs mod k = 0 then length xs div k else Suc (length xs div k))" by (simp add: list_slice2_def (*‹list_slice2 ?xs ?k ≡ list_slice ?xs ?k @ (if length ?xs mod ?k = 0 then [] else [?xs ↑ (length ?xs div ?k * ?k)])›*) list_slice_length (*‹length (list_slice ?xs ?k) = length ?xs div ?k›*)) lemma list_slice2_0: " list_slice2 xs 0 = (if (length xs = 0) then [] else [xs])" by (simp add: list_slice2_def (*‹list_slice2 ?xs ?k ≡ list_slice ?xs ?k @ (if length ?xs mod ?k = 0 then [] else [?xs ↑ (length ?xs div ?k * ?k)])›*) list_slice_0 (*‹list_slice ?xs 0 = []›*)) lemma list_slice2_1: "list_slice2 xs (Suc 0) = map (λx. [x]) xs" by (simp add: list_slice2_def (*‹list_slice2 ?xs ?k ≡ list_slice ?xs ?k @ (if length ?xs mod ?k = 0 then [] else [?xs ↑ (length ?xs div ?k * ?k)])›*) list_slice_1 (*‹list_slice ?xs (Suc 0) = map (λx. [x]) ?xs›*)) lemma list_slice2_le: " length xs ≤ k ⟹ list_slice2 xs k = (if length xs = 0 then [] else [xs])" apply (case_tac "k = 0") (*goals: 1. ‹⟦length (xs::'a list) ≤ (k::nat); k = (0::nat)⟧ ⟹ list_slice2 xs k = (if length xs = (0::nat) then [] else [xs])› 2. ‹⟦length (xs::'a list) ≤ (k::nat); k ≠ (0::nat)⟧ ⟹ list_slice2 xs k = (if length xs = (0::nat) then [] else [xs])› discuss goal 1*) apply (simp add: list_slice2_0 (*‹list_slice2 (?xs::?'a list) (0::nat) = (if length ?xs = (0::nat) then [] else [?xs])›*)) (*discuss goal 2*) apply (drule order_le_less[THEN iffD1] (*‹?x1 ≤ ?y1 ⟹ ?x1 < ?y1 ∨ ?x1 = ?y1›*)) (*goal: ‹⟦length xs ≤ k; k ≠ 0⟧ ⟹ list_slice2 xs k = (if length xs = 0 then [] else [xs])›*) apply (erule disjE (*‹⟦?P ∨ ?Q; ?P ⟹ ?R; ?Q ⟹ ?R⟧ ⟹ ?R›*)) (*goals: 1. ‹⟦k ≠ 0; length xs < k⟧ ⟹ list_slice2 xs k = (if length xs = 0 then [] else [xs])› 2. ‹⟦k ≠ 0; length xs = k⟧ ⟹ list_slice2 xs k = (if length xs = 0 then [] else [xs])› discuss goal 1*) apply (simp add: list_slice2_def (*‹list_slice2 ?xs ?k ≡ list_slice ?xs ?k @ (if length ?xs mod ?k = 0 then [] else [?xs ↑ (length ?xs div ?k * ?k)])›*) list_slice_def (*‹list_slice ?xs ?k ≡ list_slice_aux ?xs ?k (length ?xs div ?k)›*)) (*discuss goal 2*) apply (simp add: list_slice2_def (*‹list_slice2 ?xs ?k ≡ list_slice ?xs ?k @ (if length ?xs mod ?k = 0 then [] else [?xs ↑ (length ?xs div ?k * ?k)])›*) list_slice_div_eq_1 (*‹length ?xs div ?k = Suc 0 ⟹ list_slice ?xs ?k = [?xs ↓ ?k]›*)) (*proven 2 subgoals*) (*proven 2 subgoals*) . lemma list_slice2_Nil: "list_slice2 [] k = []" by (simp add: list_slice2_def (*‹list_slice2 ?xs ?k ≡ list_slice ?xs ?k @ (if length ?xs mod ?k = 0 then [] else [?xs ↑ (length ?xs div ?k * ?k)])›*) list_slice_Nil (*‹list_slice [] ?k = []›*)) lemma list_slice2_list_slice_nth: " m < length xs div k ⟹ list_slice2 xs k ! m = list_slice xs k ! m" sorry lemma list_slice2_last: " ⟦ length xs mod k > 0; m = length xs div k ⟧ ⟹ list_slice2 xs k ! m = xs ↑ (length xs div k * k)" by (simp add: list_slice2_def (*‹list_slice2 ?xs ?k ≡ list_slice ?xs ?k @ (if length ?xs mod ?k = 0 then [] else [?xs ↑ (length ?xs div ?k * ?k)])›*) nth_append (*‹(?xs @ ?ys) ! ?n = (if ?n < length ?xs then ?xs ! ?n else ?ys ! (?n - length ?xs))›*) list_slice_length (*‹length (list_slice ?xs ?k) = length ?xs div ?k›*)) lemma list_slice2_nth: " ⟦ m < length xs div k ⟧ ⟹ list_slice2 xs k ! m = xs ↑ (m * k) ↓ k" by (simp add: list_slice2_def (*‹list_slice2 ?xs ?k ≡ list_slice ?xs ?k @ (if length ?xs mod ?k = 0 then [] else [?xs ↑ (length ?xs div ?k * ?k)])›*) list_slice_length (*‹length (list_slice ?xs ?k) = length ?xs div ?k›*) nth_append (*‹(?xs @ ?ys) ! ?n = (if ?n < length ?xs then ?xs ! ?n else ?ys ! (?n - length ?xs))›*) list_slice_nth (*‹?m < length ?xs div ?k ⟹ list_slice ?xs ?k ! ?m = ?xs ↑ (?m * ?k) ↓ ?k›*)) lemma list_slice2_nth_length_eq1: " m < length xs div k ⟹ length (list_slice2 xs k ! m) = k" by (simp add: list_slice2_def (*‹list_slice2 ?xs ?k ≡ list_slice ?xs ?k @ (if length ?xs mod ?k = 0 then [] else [?xs ↑ (length ?xs div ?k * ?k)])›*) nth_append (*‹(?xs @ ?ys) ! ?n = (if ?n < length ?xs then ?xs ! ?n else ?ys ! (?n - length ?xs))›*) list_slice_length (*‹length (list_slice ?xs ?k) = length ?xs div ?k›*) list_slice_nth_length (*‹?m < length ?xs div ?k ⟹ length (list_slice ?xs ?k ! ?m) = ?k›*)) lemma list_slice2_nth_length_eq2: " ⟦ length xs mod k > 0; m = length xs div k ⟧ ⟹ length (list_slice2 xs k ! m) = length xs mod k" by (simp add: list_slice2_def (*‹list_slice2 ?xs ?k ≡ list_slice ?xs ?k @ (if length ?xs mod ?k = 0 then [] else [?xs ↑ (length ?xs div ?k * ?k)])›*) list_slice_length (*‹length (list_slice ?xs ?k) = length ?xs div ?k›*) nth_append (*‹(?xs @ ?ys) ! ?n = (if ?n < length ?xs then ?xs ! ?n else ?ys ! (?n - length ?xs))›*) minus_div_mult_eq_mod [symmetric] (*‹?a mod ?b = ?a - ?a div ?b * ?b›*)) lemma list_slice2_nth_nth_eq1: " ⟦ m < length xs div k; n < k ⟧ ⟹ (list_slice2 xs k) ! m ! n = xs ! (m * k + n)" by (simp add: list_slice2_list_slice_nth (*‹?m < length ?xs div ?k ⟹ list_slice2 ?xs ?k ! ?m = list_slice ?xs ?k ! ?m›*) list_slice_nth_nth (*‹⟦?m < length ?xs div ?k; ?n < ?k⟧ ⟹ list_slice ?xs ?k ! ?m ! ?n = ?xs ! (?m * ?k + ?n)›*)) lemma list_slice2_nth_nth_eq2: " ⟦ m = length xs div k; n < length xs mod k ⟧ ⟹ (list_slice2 xs k) ! m ! n = xs ! (m * k + n)" by (simp add: mult.commute[of _ k] (*‹?a * k = k * ?a›*) minus_mod_eq_mult_div [symmetric] (*‹?b * (?a div ?b) = ?a - ?a mod ?b›*) list_slice2_last (*‹⟦0 < length ?xs mod ?k; ?m = length ?xs div ?k⟧ ⟹ list_slice2 ?xs ?k ! ?m = ?xs ↑ (length ?xs div ?k * ?k)›*)) lemma list_slice2_nth_nth_rev: " n < length xs ⟹ (list_slice2 xs k) ! (n div k) ! (n mod k) = xs ! n" apply (case_tac "k = 0") (*goals: 1. ‹⟦(n::nat) < length (xs::'a list); (k::nat) = (0::nat)⟧ ⟹ list_slice2 xs k ! (n div k) ! (n mod k) = xs ! n› 2. ‹⟦(n::nat) < length (xs::'a list); (k::nat) ≠ (0::nat)⟧ ⟹ list_slice2 xs k ! (n div k) ! (n mod k) = xs ! n› discuss goal 1*) apply (clarsimp simp: list_slice2_0 (*‹list_slice2 ?xs 0 = (if length ?xs = 0 then [] else [?xs])›*)) (*discuss goal 2*) apply (case_tac "n div k < length xs div k") (*goals: 1. ‹⟦n < length xs; k ≠ 0; n div k < length xs div k⟧ ⟹ list_slice2 xs k ! (n div k) ! (n mod k) = xs ! n› 2. ‹⟦n < length xs; k ≠ 0; ¬ n div k < length xs div k⟧ ⟹ list_slice2 xs k ! (n div k) ! (n mod k) = xs ! n› discuss goal 1*) apply (simp add: list_slice2_nth_nth_eq1 (*‹⟦(?m::nat) < length (?xs::?'a list) div (?k::nat); (?n::nat) < ?k⟧ ⟹ list_slice2 ?xs ?k ! ?m ! ?n = ?xs ! (?m * ?k + ?n)›*)) (*discuss goal 2*) apply (frule div_le_mono[OF less_imp_le, of _ _ k] (*‹?m < ?n ⟹ ?m div k ≤ ?n div k›*)) (*goal: ‹⟦n < length xs; k ≠ 0; ¬ n div k < length xs div k⟧ ⟹ list_slice2 xs k ! (n div k) ! (n mod k) = xs ! n›*) apply simp (*goal: ‹⟦n < length xs; k ≠ 0; ¬ n div k < length xs div k; n div k ≤ length xs div k⟧ ⟹ list_slice2 xs k ! (n div k) ! (n mod k) = xs ! n›*) apply (drule sym (*‹?s = ?t ⟹ ?t = ?s›*)) (*goal: ‹⟦n < length xs; 0 < k; n div k = length xs div k⟧ ⟹ list_slice2 xs k ! (length xs div k) ! (n mod k) = xs ! n›*) apply (subgoal_tac "n mod k < length xs mod k") (*goals: 1. ‹⟦n < length xs; 0 < k; length xs div k = n div k; n mod k < length xs mod k⟧ ⟹ list_slice2 xs k ! (length xs div k) ! (n mod k) = xs ! n› 2. ‹⟦n < length xs; 0 < k; length xs div k = n div k⟧ ⟹ n mod k < length xs mod k› discuss goal 1*) apply simp (*top goal: ‹⟦n < length xs; 0 < k; length xs div k = n div k; n mod k < length xs mod k⟧ ⟹ list_slice2 xs k ! (length xs div k) ! (n mod k) = xs ! n› and 1 goal remains*) apply (simp add: list_slice2_nth_nth_eq2 (*‹⟦?m = length ?xs div ?k; ?n < length ?xs mod ?k⟧ ⟹ list_slice2 ?xs ?k ! ?m ! ?n = ?xs ! (?m * ?k + ?n)›*)) (*discuss goal 2*) apply (rule ccontr (*‹(¬ ?P ⟹ False) ⟹ ?P›*)) (*goal: ‹⟦n < length xs; 0 < k; length xs div k = n div k⟧ ⟹ n mod k < length xs mod k›*) apply (simp add: linorder_not_less (*‹(¬ (?x::?'a::linorder) < (?y::?'a::linorder)) = (?y ≤ ?x)›*)) (*goal: ‹⟦(n::nat) < length (xs::'a list); (0::nat) < (k::nat); length xs div k = n div k; ¬ n mod k < length xs mod k⟧ ⟹ False›*) apply (drule less_mod_ge_imp_div_less[of n "length xs" k] (*‹⟦(n::nat) < length (xs::'a::type list); length xs mod (k::nat) ≤ n mod k⟧ ⟹ n div k < length xs div k›*)) (*goals: 1. ‹⟦0 < k; length xs div k = n div k; length xs mod k ≤ n mod k⟧ ⟹ length xs mod k ≤ n mod k› 2. ‹⟦0 < k; length xs div k = n div k; length xs mod k ≤ n mod k; n div k < length xs div k⟧ ⟹ False› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) (*proven 2 subgoals*) (*proven 2 subgoals*) (*proven 2 subgoals*) . lemma list_slice2_append_mult: " length xs = m * k ⟹ list_slice2 (xs @ ys) k = list_slice2 xs k @ list_slice2 ys k" apply (case_tac "k = 0") (*goals: 1. ‹⟦length xs = m * k; k = 0⟧ ⟹ list_slice2 (xs @ ys) k = list_slice2 xs k @ list_slice2 ys k› 2. ‹⟦length xs = m * k; k ≠ 0⟧ ⟹ list_slice2 (xs @ ys) k = list_slice2 xs k @ list_slice2 ys k› discuss goal 1*) apply (simp add: list_slice2_0 (*‹list_slice2 ?xs 0 = (if length ?xs = 0 then [] else [?xs])›*)) (*discuss goal 2*) apply (clarsimp simp: list_slice2_def (*‹list_slice2 ?xs ?k ≡ list_slice ?xs ?k @ (if length ?xs mod ?k = 0 then [] else [?xs ↑ (length ?xs div ?k * ?k)])›*) list_slice_append_mult (*‹length ?xs = ?m * ?k ⟹ list_slice (?xs @ ?ys) ?k = list_slice ?xs ?k @ list_slice ?ys ?k›*)) (*goal: ‹⟦length xs = m * k; k ≠ 0⟧ ⟹ list_slice2 (xs @ ys) k = list_slice2 xs k @ list_slice2 ys k›*) apply (simp add: add.commute[of "m * k"] (*‹m * k + ?b = ?b + m * k›*) add_mult_distrib (*‹(?m + ?n) * ?k = ?m * ?k + ?n * ?k›*)) (*proven 2 subgoals*) . lemma list_slice2_append_mod: " length xs mod k = 0 ⟹ list_slice2 (xs @ ys) k = list_slice2 xs k @ list_slice2 ys k" by (auto intro: list_slice2_append_mult (*‹length (?xs::?'a list) = (?m::nat) * (?k::nat) ⟹ list_slice2 (?xs @ (?ys::?'a list)) ?k = list_slice2 ?xs ?k @ list_slice2 ?ys ?k›*) elim!: dvdE (*‹⟦(?b::?'a) dvd (?a::?'a); ⋀k::?'a. ?a = ?b * k ⟹ ?P::bool⟧ ⟹ ?P›*)) lemma ilist_slice_nth: " (ilist_slice f k) m = map f [m * k..<Suc m * k]" by (simp add: ilist_slice_def (*‹ilist_slice ?f ?k ≡ λx. map ?f [x * ?k..<Suc x * ?k]›*)) lemma ilist_slice_nth_length: "length ((ilist_slice f k) m) = k" by (simp add: ilist_slice_def (*‹ilist_slice ?f ?k ≡ λx. map ?f [x * ?k..<Suc x * ?k]›*)) lemma ilist_slice_nth_nth: " n < k ⟹ (ilist_slice f k) m ! n = f (m * k + n)" by (simp add: ilist_slice_def (*‹ilist_slice ?f ?k ≡ λx. map ?f [x * ?k..<Suc x * ?k]›*)) lemma ilist_slice_nth_nth_rev: " 0 < k ⟹ (ilist_slice f k) (n div k) ! (n mod k) = f n" by (simp add: ilist_slice_nth_nth (*‹?n < ?k ⟹ ilist_slice ?f ?k ?m ! ?n = ?f (?m * ?k + ?n)›*)) lemma list_slice_concat: " concat (list_slice xs k) = xs ↓ (length xs div k * k)" (is "?P xs k") apply (case_tac "k = 0") (*goals: 1. ‹k = 0 ⟹ concat (list_slice xs k) = xs ↓ (length xs div k * k)› 2. ‹k ≠ 0 ⟹ concat (list_slice xs k) = xs ↓ (length xs div k * k)› discuss goal 1*) apply (simp add: list_slice_0 (*‹list_slice ?xs 0 = []›*)) (*discuss goal 2*) apply simp (*goal: ‹(k::nat) ≠ (0::nat) ⟹ concat (list_slice (xs::'a list) k) = xs ↓ (length xs div k * k)›*) apply (subgoal_tac "⋀m. ∀xs. length xs div k = m ⟶ ?P xs k") (*goals: 1. ‹⟦(0::nat) < (k::nat); ⋀m::nat. ∀xs::'a list. length xs div k = m ⟶ concat (list_slice xs k) = xs ↓ (length xs div k * k)⟧ ⟹ concat (list_slice (xs::'a list) k) = xs ↓ (length xs div k * k)› 2. ‹⋀m::nat. (0::nat) < (k::nat) ⟹ ∀xs::'a list. length xs div k = m ⟶ concat (list_slice xs k) = xs ↓ (length xs div k * k)› discuss goal 1*) apply simp (*discuss goal 2*) apply (induct_tac m) (*goals: 1. ‹⋀m. 0 < k ⟹ ∀xs. length xs div k = 0 ⟶ concat (list_slice xs k) = xs ↓ (length xs div k * k)› 2. ‹⋀m n. ⟦0 < k; ∀xs. length xs div k = n ⟶ concat (list_slice xs k) = xs ↓ (length xs div k * k)⟧ ⟹ ∀xs. length xs div k = Suc n ⟶ concat (list_slice xs k) = xs ↓ (length xs div k * k)› discuss goal 1*) apply (intro allI (*‹(⋀x. ?P x) ⟹ ∀x. ?P x›*) impI (*‹(?P ⟹ ?Q) ⟹ ?P ⟶ ?Q›*)) (*top goal: ‹⋀m. 0 < k ⟹ ∀xs. length xs div k = 0 ⟶ concat (list_slice xs k) = xs ↓ (length xs div k * k)› and 1 goal remains*) apply (simp add: in_set_conv_nth (*‹(?x ∈ set ?xs) = (∃i<length ?xs. ?xs ! i = ?x)›*) div_eq_0_conv' (*‹0 < ?m ⟹ (?n div ?m = 0) = (?n < ?m)›*) list_slice_less (*‹length ?xs < ?k ⟹ list_slice ?xs ?k = []›*)) (*discuss goal 2*) apply clarify (*goal: ‹⋀m n. ⟦0 < k; ∀xs. length xs div k = n ⟶ concat (list_slice xs k) = xs ↓ (length xs div k * k)⟧ ⟹ ∀xs. length xs div k = Suc n ⟶ concat (list_slice xs k) = xs ↓ (length xs div k * k)›*) apply (simp add: add.commute[of k] (*‹k + ?b = ?b + k›*)) (*goal: ‹⋀m n xs. ⟦0 < k; ∀xs. length xs div k = n ⟶ concat (list_slice xs k) = xs ↓ (length xs div k * k); length xs div k = Suc n⟧ ⟹ concat (list_slice xs k) = xs ↓ (length xs div k * k)›*) apply (subgoal_tac "n * k + k ≤ length xs") (*goals: 1. ‹⋀n xs. ⟦0 < k; ∀xs. length xs div k = n ⟶ concat (list_slice xs k) = xs ↓ (n * k); length xs div k = Suc n; n * k + k ≤ length xs⟧ ⟹ concat (list_slice xs k) = xs ↓ (n * k + k)› 2. ‹⋀n xs. ⟦0 < k; ∀xs. length xs div k = n ⟶ concat (list_slice xs k) = xs ↓ (n * k); length xs div k = Suc n⟧ ⟹ n * k + k ≤ length xs› discuss goal 1*) apply (simp add: list_slice_div_eq_Suc (*‹length ?xs div ?k = Suc ?n ⟹ list_slice ?xs ?k = list_slice (?xs ↓ (?n * ?k)) ?k @ [?xs ↑ (?n * ?k) ↓ ?k]›*)) (*top goal: ‹⋀n xs. ⟦0 < k; ∀xs. length xs div k = n ⟶ concat (list_slice xs k) = xs ↓ (n * k); length xs div k = Suc n; n * k + k ≤ length xs⟧ ⟹ concat (list_slice xs k) = xs ↓ (n * k + k)› and 1 goal remains*) apply (drule_tac x="xs ↓ (n * k)" in spec (*‹∀x. ?P x ⟹ ?P ?x›*)) (*top goal: ‹⋀n xs. ⟦0 < k; ∀xs. length xs div k = n ⟶ concat (list_slice xs k) = xs ↓ (n * k); length xs div k = Suc n; n * k + k ≤ length xs⟧ ⟹ xs ↓ (n * k) @ xs ↑ (n * k) ↓ k = xs ↓ (n * k + k)› and 1 goal remains*) apply (simp add: min_eqR (*‹?b ≤ ?a ⟹ min ?a ?b = ?b›*)) (*top goal: ‹⋀(n::nat) xs::'a::type list. ⟦(0::nat) < (k::nat); length xs div k = Suc n; n * k + k ≤ length xs; length (xs ↓ (n * k)) div k = n ⟶ concat (list_slice (xs ↓ (n * k)) k) = xs ↓ (n * k) ↓ (n * k)⟧ ⟹ xs ↓ (n * k) @ xs ↑ (n * k) ↓ k = xs ↓ (n * k + k)› and 1 goal remains*) apply (simp add: take_add (*‹?xs ↓ (?i + ?j) = ?xs ↓ ?i @ ?xs ↑ ?i ↓ ?j›*)) (*discuss goal 2*) apply (simp add: le_less_div_conv[symmetric] (*‹0 < ?m ⟹ (?n div ?m = ?k) = (?k * ?m ≤ ?n ∧ ?n < Suc ?k * ?m)›*)) (*proven 2 subgoals*) (*proven 2 subgoals*) (*proven 2 subgoals*) (*proven 2 subgoals*) . lemma list_slice_unslice_mult: " length xs = m * k ⟹ concat (list_slice xs k) = xs" apply (case_tac "k = 0") (*goals: 1. ‹⟦length (xs::'a list) = (m::nat) * (k::nat); k = (0::nat)⟧ ⟹ concat (list_slice xs k) = xs› 2. ‹⟦length (xs::'a list) = (m::nat) * (k::nat); k ≠ (0::nat)⟧ ⟹ concat (list_slice xs k) = xs› discuss goal 1*) apply (simp add: list_slice_Nil (*‹list_slice [] ?k = []›*)) (*discuss goal 2*) apply (simp add: list_slice_concat (*‹concat (list_slice ?xs ?k) = ?xs ↓ (length ?xs div ?k * ?k)›*)) (*proven 2 subgoals*) . lemma ilist_slice_unslice: "0 < k ⟹ ilist_unslice (ilist_slice f k) = f" by (simp add: ilist_unslice_def (*‹ilist_unslice (?f::nat ⇒ ?'a::type list) ≡ λn::nat. ?f (n div length (?f (0::nat))) ! (n mod length (?f (0::nat)))›*) ilist_slice_nth_length (*‹length (ilist_slice (?f::nat ⇒ ?'a::type) (?k::nat) (?m::nat)) = ?k›*) ilist_slice_nth_nth (*‹(?n::nat) < (?k::nat) ⟹ ilist_slice (?f::nat ⇒ ?'a::type) ?k (?m::nat) ! ?n = ?f (?m * ?k + ?n)›*)) lemma i_take_ilist_slice_eq_list_slice: " 0 < k ⟹ ilist_slice f k ⇓ n = list_slice (f ⇓ (n * k)) k" apply (simp add: list_eq_iff (*‹(?xs = ?ys) = (length ?xs = length ?ys ∧ (∀i<length ?xs. ?xs ! i = ?ys ! i))›*) list_slice_length (*‹length (list_slice ?xs ?k) = length ?xs div ?k›*) ilist_slice_nth (*‹ilist_slice ?f ?k ?m = map ?f [?m * ?k..<Suc ?m * ?k]›*) list_slice_nth (*‹?m < length ?xs div ?k ⟹ list_slice ?xs ?k ! ?m = ?xs ↑ (?m * ?k) ↓ ?k›*)) (*goal: ‹0 < k ⟹ ilist_slice f k ⇓ n = list_slice (f ⇓ (n * k)) k›*) apply clarify (*goal: ‹0 < k ⟹ ∀i<n. k = min (n * k - i * k) k ∧ (∀ia<k. f (i * k + ia) = f ⇓ (n * k) ! (i * k + ia))›*) apply (rename_tac i) (*goal: ‹⋀i. ⟦0 < k; i < n⟧ ⟹ k = min (n * k - i * k) k ∧ (∀ia<k. f (i * k + ia) = f ⇓ (n * k) ! (i * k + ia))›*) apply (subgoal_tac "k ≤ n * k - i * k") (*goals: 1. ‹⋀i. ⟦0 < k; i < n; k ≤ n * k - i * k⟧ ⟹ k = min (n * k - i * k) k ∧ (∀ia<k. f (i * k + ia) = f ⇓ (n * k) ! (i * k + ia))› 2. ‹⋀i. ⟦0 < k; i < n⟧ ⟹ k ≤ n * k - i * k› discuss goal 1*) apply simp (*discuss goal 2*) apply (drule_tac m=i in Suc_leI (*‹?m < ?n ⟹ Suc ?m ≤ ?n›*)) (*goal: ‹⋀i. ⟦0 < k; i < n⟧ ⟹ k ≤ n * k - i * k›*) apply (drule mult_le_mono1[of _ _ k] (*‹?i ≤ ?j ⟹ ?i * k ≤ ?j * k›*)) (*goal: ‹⋀i. ⟦0 < k; Suc i ≤ n⟧ ⟹ k ≤ n * k - i * k›*) apply simp (*proven 2 subgoals*) . lemma list_slice_i_take_eq_i_take_ilist_slice: " list_slice (f ⇓ n) k = ilist_slice f k ⇓ (n div k)" apply (case_tac "k = 0") (*goals: 1. ‹k = 0 ⟹ list_slice (f ⇓ n) k = ilist_slice f k ⇓ (n div k)› 2. ‹k ≠ 0 ⟹ list_slice (f ⇓ n) k = ilist_slice f k ⇓ (n div k)› discuss goal 1*) apply (simp add: list_slice_0 (*‹list_slice ?xs 0 = []›*)) (*discuss goal 2*) apply (simp add: i_take_ilist_slice_eq_list_slice (*‹0 < ?k ⟹ ilist_slice ?f ?k ⇓ ?n = list_slice (?f ⇓ (?n * ?k)) ?k›*)) (*goal: ‹k ≠ 0 ⟹ list_slice (f ⇓ n) k = ilist_slice f k ⇓ (n div k)›*) apply (subst list_slice_eq_list_slice_take[of "f ⇓ n", symmetric] (*‹list_slice (f ⇓ n) ?k = list_slice (f ⇓ n ↓ (length (f ⇓ n) div ?k * ?k)) ?k›*)) (*goal: ‹0 < k ⟹ list_slice (f ⇓ n) k = list_slice (f ⇓ (n div k * k)) k›*) apply (simp add: div_mult_le (*‹?n div ?m * ?m ≤ ?n›*) min_eqR (*‹?b ≤ ?a ⟹ min ?a ?b = ?b›*)) (*proven 2 subgoals*) . lemma ilist_slice_i_append_mod: " length xs mod k = 0 ⟹ ilist_slice (xs ⌢ f) k = list_slice xs k ⌢ ilist_slice f k" apply (simp add: ilist_eq_iff (*‹(?f = ?g) = (∀x. ?f x = ?g x)›*) ilist_slice_nth (*‹ilist_slice ?f ?k ?m = map ?f [?m * ?k..<Suc ?m * ?k]›*) i_append_nth (*‹(?xs ⌢ ?f) ?n = (if ?n < length ?xs then ?xs ! ?n else ?f (?n - length ?xs))›*) list_slice_length (*‹length (list_slice ?xs ?k) = length ?xs div ?k›*)) (*goal: ‹length (xs::'a list) mod (k::nat) = (0::nat) ⟹ ilist_slice (xs ⌢ (f::nat ⇒ 'a)) k = list_slice xs k ⌢ ilist_slice f k›*) apply (clarsimp simp: mult.commute[of k] (*‹(k::nat) * (?b::nat) = ?b * k›*) elim!: dvdE (*‹⟦(?b::?'a::dvd) dvd (?a::?'a::dvd); ⋀k::?'a::dvd. ?a = ?b * k ⟹ ?P::bool⟧ ⟹ ?P›*)) (*goal: ‹length xs mod k = 0 ⟹ ∀x. (x < length xs div k ⟶ map (xs ⌢ f) [x * k..<k + x * k] = list_slice xs k ! x) ∧ (¬ x < length xs div k ⟶ map (xs ⌢ f) [x * k..<k + x * k] = map f [(x - length xs div k) * k..<k + (x - length xs div k) * k])›*) apply (rename_tac n i) (*goal: ‹⋀(ka::nat) x::nat. ⟦length (xs::'a list) = ka * (k::nat); (0::nat) < k⟧ ⟹ (x < ka ⟶ map (xs ⌢ (f::nat ⇒ 'a)) [x * k..<k + x * k] = list_slice xs k ! x) ∧ (¬ x < ka ⟶ map (xs ⌢ f) [x * k..<k + x * k] = map f [(x - ka) * k..<k + (x - ka) * k])›*) apply (intro conjI (*‹⟦?P; ?Q⟧ ⟹ ?P ∧ ?Q›*) impI (*‹(?P ⟹ ?Q) ⟹ ?P ⟶ ?Q›*)) (*goals: 1. ‹⋀n i. ⟦length xs = n * k; 0 < k; i < n⟧ ⟹ map (xs ⌢ f) [i * k..<k + i * k] = list_slice xs k ! i› 2. ‹⋀n i. ⟦length xs = n * k; 0 < k; ¬ i < n⟧ ⟹ map (xs ⌢ f) [i * k..<k + i * k] = map f [(i - n) * k..<k + (i - n) * k]› discuss goal 1*) apply (simp add: list_slice_nth (*‹?m < length ?xs div ?k ⟹ list_slice ?xs ?k ! ?m = ?xs ↑ (?m * ?k) ↓ ?k›*)) (*top goal: ‹⋀n i. ⟦length xs = n * k; 0 < k; i < n⟧ ⟹ map (xs ⌢ f) [i * k..<k + i * k] = list_slice xs k ! i› and 1 goal remains*) apply (subgoal_tac "k ≤ n * k - i * k") (*goals: 1. ‹⋀n i. ⟦length xs = n * k; 0 < k; i < n; k ≤ n * k - i * k⟧ ⟹ map (xs ⌢ f) [i * k..<k + i * k] = xs ↑ (i * k) ↓ k› 2. ‹⋀n i. ⟦length xs = n * k; 0 < k; i < n⟧ ⟹ k ≤ n * k - i * k› discuss goal 1*) apply (fastforce simp: list_eq_iff (*‹(?xs = ?ys) = (length ?xs = length ?ys ∧ (∀i<length ?xs. ?xs ! i = ?ys ! i))›*) i_append_nth (*‹(?xs ⌢ ?f) ?n = (if ?n < length ?xs then ?xs ! ?n else ?f (?n - length ?xs))›*) min_eqR (*‹?b ≤ ?a ⟹ min ?a ?b = ?b›*)) (*discuss goal 2*) apply (drule_tac m=i in Suc_leI (*‹?m < ?n ⟹ Suc ?m ≤ ?n›*)) (*top goal: ‹⋀n i. ⟦length xs = n * k; 0 < k; i < n⟧ ⟹ k ≤ n * k - i * k› and 1 goal remains*) apply (drule mult_le_mono1[of _ _ k] (*‹?i ≤ ?j ⟹ ?i * k ≤ ?j * k›*)) (*top goal: ‹⋀n i. ⟦length xs = n * k; 0 < k; Suc i ≤ n⟧ ⟹ k ≤ n * k - i * k› and 1 goal remains*) apply simp (*proven 2 subgoals*) (*discuss goal 2*) apply (simp add: ilist_eq_iff (*‹(?f = ?g) = (∀x. ?f x = ?g x)›*) list_eq_iff (*‹(?xs = ?ys) = (length ?xs = length ?ys ∧ (∀i<length ?xs. ?xs ! i = ?ys ! i))›*) i_append_nth (*‹(?xs ⌢ ?f) ?n = (if ?n < length ?xs then ?xs ! ?n else ?f (?n - length ?xs))›*) linorder_not_less (*‹(¬ ?x < ?y) = (?y ≤ ?x)›*)) (*goal: ‹⋀n i. ⟦length xs = n * k; 0 < k; ¬ i < n⟧ ⟹ map (xs ⌢ f) [i * k..<k + i * k] = map f [(i - n) * k..<k + (i - n) * k]›*) apply clarify (*goal: ‹⋀n i. ⟦length xs = n * k; 0 < k; n ≤ i⟧ ⟹ ∀ia. (i * k + ia < n * k ⟶ ia < k ⟶ xs ! (i * k + ia) = f ((i - n) * k + ia)) ∧ (n * k ≤ i * k + ia ⟶ ia < k ⟶ f (i * k + ia - n * k) = f ((i - n) * k + ia))›*) apply (rename_tac j) (*goal: ‹⋀n i ia. ⟦length xs = n * k; 0 < k; n ≤ i⟧ ⟹ (i * k + ia < n * k ⟶ ia < k ⟶ xs ! (i * k + ia) = f ((i - n) * k + ia)) ∧ (n * k ≤ i * k + ia ⟶ ia < k ⟶ f (i * k + ia - n * k) = f ((i - n) * k + ia))›*) apply (subgoal_tac "n * k ≤ i * k + j") (*goals: 1. ‹⋀(n::nat) (i::nat) j::nat. ⟦length (xs::'a list) = n * (k::nat); (0::nat) < k; n ≤ i; n * k ≤ i * k + j⟧ ⟹ (i * k + j < n * k ⟶ j < k ⟶ xs ! (i * k + j) = (f::nat ⇒ 'a) ((i - n) * k + j)) ∧ (n * k ≤ i * k + j ⟶ j < k ⟶ f (i * k + j - n * k) = f ((i - n) * k + j))› 2. ‹⋀(n::nat) (i::nat) j::nat. ⟦length (xs::'a list) = n * (k::nat); (0::nat) < k; n ≤ i⟧ ⟹ n * k ≤ i * k + j› discuss goal 1*) apply (simp add: diff_mult_distrib (*‹(?m - ?n) * ?k = ?m * ?k - ?n * ?k›*)) (*discuss goal 2*) apply (simp add: trans_le_add1 (*‹?i ≤ ?j ⟹ ?i ≤ ?j + ?m›*)) (*proven 2 subgoals*) (*proven 2 subgoals*) . corollary ilist_slice_append_mult: " length xs = m * k ⟹ ilist_slice (xs ⌢ f) k = list_slice xs k ⌢ ilist_slice f k" by (simp add: ilist_slice_i_append_mod (*‹length ?xs mod ?k = 0 ⟹ ilist_slice (?xs ⌢ ?f) ?k = list_slice ?xs ?k ⌢ ilist_slice ?f ?k›*)) end
{ "path": "afp-2025-02-12/thys/AutoFocus-Stream/ListSlice.thy", "repo": "afp-2025-02-12", "sha": "27bb1632d3c02c6f3d0ec7431cedcebdcb8c1a1c0ff9aef5d5f9144e2bc467f7" }
section ‹Framework Graph Lifting for Noninterference› theory LiftingInter imports NonInterferenceInter begin text ‹In this section, we show how a valid CFG from the slicing framework in \<^cite>‹"Wasserrab:08"› can be lifted to fulfil all properties of the ‹NonInterferenceIntraGraph› locale. Basically, we redefine the hitherto existing ‹Entry› and ‹Exit› nodes as new ‹High› and ‹Low› nodes, and introduce two new nodes ‹NewEntry› and ‹NewExit›. Then, we have to lift all functions to operate on this new graph.› subsection ‹Liftings› subsubsection ‹The datatypes› datatype 'node LDCFG_node = Node 'node | NewEntry | NewExit type_synonym ('edge,'node,'var,'val,'ret,'pname) LDCFG_edge = "'node LDCFG_node × (('var,'val,'ret,'pname) edge_kind) × 'node LDCFG_node" subsubsection ‹Lifting basic definitions using @{typ 'edge} and @{typ 'node}› inductive lift_valid_edge :: "('edge ⇒ bool) ⇒ ('edge ⇒ 'node) ⇒ ('edge ⇒ 'node) ⇒ ('edge ⇒ ('var,'val,'ret,'pname) edge_kind) ⇒ 'node ⇒ 'node ⇒ ('edge,'node,'var,'val,'ret,'pname) LDCFG_edge ⇒ bool" for valid_edge::"'edge ⇒ bool" and src::"'edge ⇒ 'node" and trg::"'edge ⇒ 'node" and knd::"'edge ⇒ ('var,'val,'ret,'pname) edge_kind" and E::'node and X::'node where lve_edge: "⟦valid_edge a; src a ≠ E ∨ trg a ≠ X; e = (Node (src a),knd a,Node (trg a))⟧ ⟹ lift_valid_edge valid_edge src trg knd E X e" | lve_Entry_edge: "e = (NewEntry,(λs. True)⇩√,Node E) ⟹ lift_valid_edge valid_edge src trg knd E X e" | lve_Exit_edge: "e = (Node X,(λs. True)⇩√,NewExit) ⟹ lift_valid_edge valid_edge src trg knd E X e" | lve_Entry_Exit_edge: "e = (NewEntry,(λs. False)⇩√,NewExit) ⟹ lift_valid_edge valid_edge src trg knd E X e" lemma [simp]:"¬ lift_valid_edge valid_edge src trg knd E X (Node E,et,Node X)" by (auto elim:lift_valid_edge.cases (*‹⟦lift_valid_edge ?valid_edge ?src ?trg ?knd ?E ?X ?a; ⋀a e. ⟦?a = e; ?valid_edge a; ?src a ≠ ?E ∨ ?trg a ≠ ?X; e = (Node (?src a), ?knd a, Node (?trg a))⟧ ⟹ ?P; ⋀e. ⟦?a = e; e = (NewEntry, (λs. True)⇩√, Node ?E)⟧ ⟹ ?P; ⋀e. ⟦?a = e; e = (Node ?X, (λs. True)⇩√, NewExit)⟧ ⟹ ?P; ⋀e. ⟦?a = e; e = (NewEntry, (λs. False)⇩√, NewExit)⟧ ⟹ ?P⟧ ⟹ ?P›*)) fun lift_get_proc :: "('node ⇒ 'pname) ⇒ 'pname ⇒ 'node LDCFG_node ⇒ 'pname" where "lift_get_proc get_proc Main (Node n) = get_proc n" | "lift_get_proc get_proc Main NewEntry = Main" | "lift_get_proc get_proc Main NewExit = Main" inductive_set lift_get_return_edges :: "('edge ⇒ 'edge set) ⇒ ('edge ⇒ bool) ⇒ ('edge ⇒ 'node) ⇒ ('edge ⇒ 'node) ⇒ ('edge ⇒ ('var,'val,'ret,'pname) edge_kind) ⇒ ('edge,'node,'var,'val,'ret,'pname) LDCFG_edge ⇒ ('edge,'node,'var,'val,'ret,'pname) LDCFG_edge set" for get_return_edges :: "'edge ⇒ 'edge set" and valid_edge :: "'edge ⇒ bool" and src::"'edge ⇒ 'node" and trg::"'edge ⇒ 'node" and knd::"'edge ⇒ ('var,'val,'ret,'pname) edge_kind" and e::"('edge,'node,'var,'val,'ret,'pname) LDCFG_edge" where lift_get_return_edgesI: "⟦e = (Node (src a),knd a,Node (trg a)); valid_edge a; a' ∈ get_return_edges a; e' = (Node (src a'),knd a',Node (trg a'))⟧ ⟹ e' ∈ lift_get_return_edges get_return_edges valid_edge src trg knd e" subsubsection ‹Lifting the Def and Use sets› inductive_set lift_Def_set :: "('node ⇒ 'var set) ⇒ 'node ⇒ 'node ⇒ 'var set ⇒ 'var set ⇒ ('node LDCFG_node × 'var) set" for Def::"('node ⇒ 'var set)" and E::'node and X::'node and H::"'var set" and L::"'var set" where lift_Def_node: "V ∈ Def n ⟹ (Node n,V) ∈ lift_Def_set Def E X H L" | lift_Def_High: "V ∈ H ⟹ (Node E,V) ∈ lift_Def_set Def E X H L" abbreviation lift_Def :: "('node ⇒ 'var set) ⇒ 'node ⇒ 'node ⇒ 'var set ⇒ 'var set ⇒ 'node LDCFG_node ⇒ 'var set" where "lift_Def Def E X H L n ≡ {V. (n,V) ∈ lift_Def_set Def E X H L}" inductive_set lift_Use_set :: "('node ⇒ 'var set) ⇒ 'node ⇒ 'node ⇒ 'var set ⇒ 'var set ⇒ ('node LDCFG_node × 'var) set" for Use::"'node ⇒ 'var set" and E::'node and X::'node and H::"'var set" and L::"'var set" where lift_Use_node: "V ∈ Use n ⟹ (Node n,V) ∈ lift_Use_set Use E X H L" | lift_Use_High: "V ∈ H ⟹ (Node E,V) ∈ lift_Use_set Use E X H L" | lift_Use_Low: "V ∈ L ⟹ (Node X,V) ∈ lift_Use_set Use E X H L" abbreviation lift_Use :: "('node ⇒ 'var set) ⇒ 'node ⇒ 'node ⇒ 'var set ⇒ 'var set ⇒ 'node LDCFG_node ⇒ 'var set" where "lift_Use Use E X H L n ≡ {V. (n,V) ∈ lift_Use_set Use E X H L}" fun lift_ParamUses :: "('node ⇒ 'var set list) ⇒ 'node LDCFG_node ⇒ 'var set list" where "lift_ParamUses ParamUses (Node n) = ParamUses n" | "lift_ParamUses ParamUses NewEntry = []" | "lift_ParamUses ParamUses NewExit = []" fun lift_ParamDefs :: "('node ⇒ 'var list) ⇒ 'node LDCFG_node ⇒ 'var list" where "lift_ParamDefs ParamDefs (Node n) = ParamDefs n" | "lift_ParamDefs ParamDefs NewEntry = []" | "lift_ParamDefs ParamDefs NewExit = []" subsection ‹The lifting lemmas› subsubsection ‹Lifting the CFG locales› abbreviation src :: "('edge,'node,'var,'val,'ret,'pname) LDCFG_edge ⇒ 'node LDCFG_node" where "src a ≡ fst a" abbreviation trg :: "('edge,'node,'var,'val,'ret,'pname) LDCFG_edge ⇒ 'node LDCFG_node" where "trg a ≡ snd(snd a)" abbreviation knd :: "('edge,'node,'var,'val,'ret,'pname) LDCFG_edge ⇒ ('var,'val,'ret,'pname) edge_kind" where "knd a ≡ fst(snd a)" lemma lift_CFG: assumes wf:"CFGExit_wf sourcenode targetnode kind valid_edge Entry get_proc get_return_edges procs Main Exit Def Use ParamDefs ParamUses" and pd:"Postdomination sourcenode targetnode kind valid_edge Entry get_proc get_return_edges procs Main Exit" shows "CFG src trg knd (lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit) NewEntry (lift_get_proc get_proc Main) (lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind) procs Main" proof (-) (*goal: ‹CFG src trg knd (lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit) NewEntry (lift_get_proc get_proc Main) (lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind) procs Main›*) interpret CFGExit_wf sourcenode targetnode kind valid_edge Entry get_proc get_return_edges procs Main Exit Def Use ParamDefs ParamUses by (rule wf (*‹CFGExit_wf sourcenode targetnode kind valid_edge Entry get_proc get_return_edges procs Main Exit Def Use ParamDefs ParamUses›*)) interpret Postdomination sourcenode targetnode kind valid_edge Entry get_proc get_return_edges procs Main Exit by (rule pd (*‹Postdomination (sourcenode::'a ⇒ 'b) (targetnode::'a ⇒ 'b) (kind::'a ⇒ ('c, 'd, 'e, 'f) edge_kind) (valid_edge::'a ⇒ bool) (Entry::'b) (get_proc::'b ⇒ 'f) (get_return_edges::'a ⇒ 'a set) (procs::('f × 'c list × 'c list) list) (Main::'f) (Exit::'b)›*)) show "?thesis" (*goal: ‹CFG src trg knd (lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit) NewEntry (lift_get_proc get_proc Main) (lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind) procs Main›*) proof (standard) (*goals: 1. ‹⋀a. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; trg a = NewEntry⟧ ⟹ False› 2. ‹lift_get_proc get_proc Main NewEntry = Main› 3. ‹⋀a Q r p fs. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q:r↪⇘p⇙fs; src a = NewEntry⟧ ⟹ False› 4. ‹⋀a a'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a'; src a = src a'; trg a = trg a'⟧ ⟹ a = a'› 5. ‹⋀a Q r f. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q:r↪⇘Main⇙f⟧ ⟹ False› 6. ‹⋀a Q' f'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q'↩⇘Main⇙f'⟧ ⟹ False› 7. ‹⋀a Q r p fs. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q:r↪⇘p⇙fs⟧ ⟹ ∃ins outs. (p, ins, outs) ∈ set procs› 8. ‹⋀a. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; intra_kind (knd a)⟧ ⟹ lift_get_proc get_proc Main (src a) = lift_get_proc get_proc Main (trg a)› 9. ‹⋀a Q r p fs. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q:r↪⇘p⇙fs⟧ ⟹ lift_get_proc get_proc Main (trg a) = p› 10. ‹⋀a Q' p f'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q'↩⇘p⇙f'⟧ ⟹ lift_get_proc get_proc Main (src a) = p› 11. ‹⋀a Q r p fs. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q:r↪⇘p⇙fs⟧ ⟹ ∀a'. lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a' ∧ trg a' = trg a ⟶ (∃Qx rx fsx. knd a' = Qx:rx↪⇘p⇙fsx)› 12. ‹⋀a Q' p f'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q'↩⇘p⇙f'⟧ ⟹ ∀a'. lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a' ∧ src a' = src a ⟶ (∃Qx fx. knd a' = Qx↩⇘p⇙fx)› 13. ‹⋀a Q r p fs. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q:r↪⇘p⇙fs⟧ ⟹ lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind a ≠ {}› 14. ‹⋀a a'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; a' ∈ lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind a⟧ ⟹ lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a'› 15. ‹⋀a a'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; a' ∈ lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind a⟧ ⟹ ∃Q r p fs. knd a = Q:r↪⇘p⇙fs› 16. ‹⋀a Q r p fs a'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q:r↪⇘p⇙fs; a' ∈ lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind a⟧ ⟹ ∃Q' f'. knd a' = Q'↩⇘p⇙f'› 17. ‹⋀a Q' p f'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q'↩⇘p⇙f'⟧ ⟹ ∃!a'. lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a' ∧ (∃Q r fs. knd a' = Q:r↪⇘p⇙fs) ∧ a ∈ lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind a'› 18. ‹⋀a a'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; a' ∈ lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind a⟧ ⟹ ∃a''. lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a'' ∧ src a'' = trg a ∧ trg a'' = src a' ∧ knd a'' = (λcf. False)⇩√› 19. ‹⋀a a'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; a' ∈ lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind a⟧ ⟹ ∃a''. lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a'' ∧ src a'' = src a ∧ trg a'' = trg a' ∧ knd a'' = (λcf. False)⇩√› 20. ‹⋀a Q r p fs. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q:r↪⇘p⇙fs⟧ ⟹ ∃!a'. lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a' ∧ src a' = src a ∧ intra_kind (knd a')› 21. ‹⋀a Q' p f'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q'↩⇘p⇙f'⟧ ⟹ ∃!a'. lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a' ∧ trg a' = trg a ∧ intra_kind (knd a')› 22. ‹⋀a a' Q₁ r₁ p fs₁ Q₂ r₂ fs₂. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a'; knd a = Q₁:r₁↪⇘p⇙fs₁; knd a' = Q₂:r₂↪⇘p⇙fs₂⟧ ⟹ trg a = trg a'› 23. ‹distinct_fst procs› 24. ‹⋀p ins outs. (p, ins, outs) ∈ set procs ⟹ distinct ins› 25. ‹⋀p ins outs. (p, ins, outs) ∈ set procs ⟹ distinct outs›*) fix a assume "lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a" and "trg a = NewEntry" (*‹lift_valid_edge (valid_edge::'a ⇒ bool) (sourcenode::'a ⇒ 'b) (targetnode::'a ⇒ 'b) (kind::'a ⇒ ('c, 'd, 'e, 'f) edge_kind) (Entry::'b) (Exit::'b) (a::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node)› ‹trg (a::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node) = NewEntry›*) thus False by (fastforce elim:lift_valid_edge.cases (*‹⟦lift_valid_edge ?valid_edge ?src ?trg ?knd ?E ?X ?a; ⋀a e. ⟦?a = e; ?valid_edge a; ?src a ≠ ?E ∨ ?trg a ≠ ?X; e = (Node (?src a), ?knd a, Node (?trg a))⟧ ⟹ ?P; ⋀e. ⟦?a = e; e = (NewEntry, (λs. True)⇩√, Node ?E)⟧ ⟹ ?P; ⋀e. ⟦?a = e; e = (Node ?X, (λs. True)⇩√, NewExit)⟧ ⟹ ?P; ⋀e. ⟦?a = e; e = (NewEntry, (λs. False)⇩√, NewExit)⟧ ⟹ ?P⟧ ⟹ ?P›*)) next (*goals: 1. ‹lift_get_proc get_proc Main NewEntry = Main› 2. ‹⋀a Q r p fs. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q:r↪⇘p⇙fs; src a = NewEntry⟧ ⟹ False› 3. ‹⋀a a'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a'; src a = src a'; trg a = trg a'⟧ ⟹ a = a'› 4. ‹⋀a Q r f. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q:r↪⇘Main⇙f⟧ ⟹ False› 5. ‹⋀a Q' f'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q'↩⇘Main⇙f'⟧ ⟹ False› 6. ‹⋀a Q r p fs. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q:r↪⇘p⇙fs⟧ ⟹ ∃ins outs. (p, ins, outs) ∈ set procs› 7. ‹⋀a. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; intra_kind (knd a)⟧ ⟹ lift_get_proc get_proc Main (src a) = lift_get_proc get_proc Main (trg a)› 8. ‹⋀a Q r p fs. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q:r↪⇘p⇙fs⟧ ⟹ lift_get_proc get_proc Main (trg a) = p› 9. ‹⋀a Q' p f'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q'↩⇘p⇙f'⟧ ⟹ lift_get_proc get_proc Main (src a) = p› 10. ‹⋀a Q r p fs. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q:r↪⇘p⇙fs⟧ ⟹ ∀a'. lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a' ∧ trg a' = trg a ⟶ (∃Qx rx fsx. knd a' = Qx:rx↪⇘p⇙fsx)› 11. ‹⋀a Q' p f'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q'↩⇘p⇙f'⟧ ⟹ ∀a'. lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a' ∧ src a' = src a ⟶ (∃Qx fx. knd a' = Qx↩⇘p⇙fx)› 12. ‹⋀a Q r p fs. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q:r↪⇘p⇙fs⟧ ⟹ lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind a ≠ {}› 13. ‹⋀a a'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; a' ∈ lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind a⟧ ⟹ lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a'› 14. ‹⋀a a'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; a' ∈ lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind a⟧ ⟹ ∃Q r p fs. knd a = Q:r↪⇘p⇙fs› 15. ‹⋀a Q r p fs a'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q:r↪⇘p⇙fs; a' ∈ lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind a⟧ ⟹ ∃Q' f'. knd a' = Q'↩⇘p⇙f'› 16. ‹⋀a Q' p f'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q'↩⇘p⇙f'⟧ ⟹ ∃!a'. lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a' ∧ (∃Q r fs. knd a' = Q:r↪⇘p⇙fs) ∧ a ∈ lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind a'› 17. ‹⋀a a'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; a' ∈ lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind a⟧ ⟹ ∃a''. lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a'' ∧ src a'' = trg a ∧ trg a'' = src a' ∧ knd a'' = (λcf. False)⇩√› 18. ‹⋀a a'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; a' ∈ lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind a⟧ ⟹ ∃a''. lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a'' ∧ src a'' = src a ∧ trg a'' = trg a' ∧ knd a'' = (λcf. False)⇩√› 19. ‹⋀a Q r p fs. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q:r↪⇘p⇙fs⟧ ⟹ ∃!a'. lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a' ∧ src a' = src a ∧ intra_kind (knd a')› 20. ‹⋀a Q' p f'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q'↩⇘p⇙f'⟧ ⟹ ∃!a'. lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a' ∧ trg a' = trg a ∧ intra_kind (knd a')› 21. ‹⋀a a' Q₁ r₁ p fs₁ Q₂ r₂ fs₂. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a'; knd a = Q₁:r₁↪⇘p⇙fs₁; knd a' = Q₂:r₂↪⇘p⇙fs₂⟧ ⟹ trg a = trg a'› 22. ‹distinct_fst procs› 23. ‹⋀p ins outs. (p, ins, outs) ∈ set procs ⟹ distinct ins› 24. ‹⋀p ins outs. (p, ins, outs) ∈ set procs ⟹ distinct outs›*) show "lift_get_proc get_proc Main NewEntry = Main" by simp next (*goals: 1. ‹⋀a Q r p fs. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q:r↪⇘p⇙fs; src a = NewEntry⟧ ⟹ False› 2. ‹⋀a a'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a'; src a = src a'; trg a = trg a'⟧ ⟹ a = a'› 3. ‹⋀a Q r f. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q:r↪⇘Main⇙f⟧ ⟹ False› 4. ‹⋀a Q' f'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q'↩⇘Main⇙f'⟧ ⟹ False› 5. ‹⋀a Q r p fs. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q:r↪⇘p⇙fs⟧ ⟹ ∃ins outs. (p, ins, outs) ∈ set procs› 6. ‹⋀a. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; intra_kind (knd a)⟧ ⟹ lift_get_proc get_proc Main (src a) = lift_get_proc get_proc Main (trg a)› 7. ‹⋀a Q r p fs. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q:r↪⇘p⇙fs⟧ ⟹ lift_get_proc get_proc Main (trg a) = p› 8. ‹⋀a Q' p f'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q'↩⇘p⇙f'⟧ ⟹ lift_get_proc get_proc Main (src a) = p› 9. ‹⋀a Q r p fs. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q:r↪⇘p⇙fs⟧ ⟹ ∀a'. lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a' ∧ trg a' = trg a ⟶ (∃Qx rx fsx. knd a' = Qx:rx↪⇘p⇙fsx)› 10. ‹⋀a Q' p f'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q'↩⇘p⇙f'⟧ ⟹ ∀a'. lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a' ∧ src a' = src a ⟶ (∃Qx fx. knd a' = Qx↩⇘p⇙fx)› 11. ‹⋀a Q r p fs. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q:r↪⇘p⇙fs⟧ ⟹ lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind a ≠ {}› 12. ‹⋀a a'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; a' ∈ lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind a⟧ ⟹ lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a'› 13. ‹⋀a a'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; a' ∈ lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind a⟧ ⟹ ∃Q r p fs. knd a = Q:r↪⇘p⇙fs› 14. ‹⋀a Q r p fs a'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q:r↪⇘p⇙fs; a' ∈ lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind a⟧ ⟹ ∃Q' f'. knd a' = Q'↩⇘p⇙f'› 15. ‹⋀a Q' p f'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q'↩⇘p⇙f'⟧ ⟹ ∃!a'. lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a' ∧ (∃Q r fs. knd a' = Q:r↪⇘p⇙fs) ∧ a ∈ lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind a'› 16. ‹⋀a a'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; a' ∈ lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind a⟧ ⟹ ∃a''. lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a'' ∧ src a'' = trg a ∧ trg a'' = src a' ∧ knd a'' = (λcf. False)⇩√› 17. ‹⋀a a'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; a' ∈ lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind a⟧ ⟹ ∃a''. lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a'' ∧ src a'' = src a ∧ trg a'' = trg a' ∧ knd a'' = (λcf. False)⇩√› 18. ‹⋀a Q r p fs. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q:r↪⇘p⇙fs⟧ ⟹ ∃!a'. lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a' ∧ src a' = src a ∧ intra_kind (knd a')› 19. ‹⋀a Q' p f'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q'↩⇘p⇙f'⟧ ⟹ ∃!a'. lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a' ∧ trg a' = trg a ∧ intra_kind (knd a')› 20. ‹⋀a a' Q₁ r₁ p fs₁ Q₂ r₂ fs₂. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a'; knd a = Q₁:r₁↪⇘p⇙fs₁; knd a' = Q₂:r₂↪⇘p⇙fs₂⟧ ⟹ trg a = trg a'› 21. ‹distinct_fst procs› 22. ‹⋀p ins outs. (p, ins, outs) ∈ set procs ⟹ distinct ins› 23. ‹⋀p ins outs. (p, ins, outs) ∈ set procs ⟹ distinct outs›*) fix a and Q and r and p and fs assume "lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a" and "knd a = Q:r↪⇘p⇙fs" and "src a = NewEntry" (*‹lift_valid_edge (valid_edge::'a ⇒ bool) (sourcenode::'a ⇒ 'b) (targetnode::'a ⇒ 'b) (kind::'a ⇒ ('c, 'd, 'e, 'f) edge_kind) (Entry::'b) (Exit::'b) (a::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node)› ‹knd (a::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node) = Q::('c ⇒ 'd option) × 'e ⇒ bool:r::'e↪⇘p::'f⇙fs::(('c ⇒ 'd option) ⇒ 'd option) list› ‹src (a::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node) = NewEntry›*) thus False by (fastforce elim:lift_valid_edge.cases (*‹⟦lift_valid_edge ?valid_edge ?src ?trg ?knd ?E ?X ?a; ⋀a e. ⟦?a = e; ?valid_edge a; ?src a ≠ ?E ∨ ?trg a ≠ ?X; e = (Node (?src a), ?knd a, Node (?trg a))⟧ ⟹ ?P; ⋀e. ⟦?a = e; e = (NewEntry, (λs. True)⇩√, Node ?E)⟧ ⟹ ?P; ⋀e. ⟦?a = e; e = (Node ?X, (λs. True)⇩√, NewExit)⟧ ⟹ ?P; ⋀e. ⟦?a = e; e = (NewEntry, (λs. False)⇩√, NewExit)⟧ ⟹ ?P⟧ ⟹ ?P›*)) next (*goals: 1. ‹⋀a a'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a'; src a = src a'; trg a = trg a'⟧ ⟹ a = a'› 2. ‹⋀a Q r f. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q:r↪⇘Main⇙f⟧ ⟹ False› 3. ‹⋀a Q' f'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q'↩⇘Main⇙f'⟧ ⟹ False› 4. ‹⋀a Q r p fs. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q:r↪⇘p⇙fs⟧ ⟹ ∃ins outs. (p, ins, outs) ∈ set procs› 5. ‹⋀a. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; intra_kind (knd a)⟧ ⟹ lift_get_proc get_proc Main (src a) = lift_get_proc get_proc Main (trg a)› 6. ‹⋀a Q r p fs. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q:r↪⇘p⇙fs⟧ ⟹ lift_get_proc get_proc Main (trg a) = p› 7. ‹⋀a Q' p f'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q'↩⇘p⇙f'⟧ ⟹ lift_get_proc get_proc Main (src a) = p› 8. ‹⋀a Q r p fs. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q:r↪⇘p⇙fs⟧ ⟹ ∀a'. lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a' ∧ trg a' = trg a ⟶ (∃Qx rx fsx. knd a' = Qx:rx↪⇘p⇙fsx)› 9. ‹⋀a Q' p f'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q'↩⇘p⇙f'⟧ ⟹ ∀a'. lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a' ∧ src a' = src a ⟶ (∃Qx fx. knd a' = Qx↩⇘p⇙fx)› 10. ‹⋀a Q r p fs. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q:r↪⇘p⇙fs⟧ ⟹ lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind a ≠ {}› 11. ‹⋀a a'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; a' ∈ lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind a⟧ ⟹ lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a'› 12. ‹⋀a a'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; a' ∈ lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind a⟧ ⟹ ∃Q r p fs. knd a = Q:r↪⇘p⇙fs› 13. ‹⋀a Q r p fs a'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q:r↪⇘p⇙fs; a' ∈ lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind a⟧ ⟹ ∃Q' f'. knd a' = Q'↩⇘p⇙f'› 14. ‹⋀a Q' p f'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q'↩⇘p⇙f'⟧ ⟹ ∃!a'. lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a' ∧ (∃Q r fs. knd a' = Q:r↪⇘p⇙fs) ∧ a ∈ lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind a'› 15. ‹⋀a a'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; a' ∈ lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind a⟧ ⟹ ∃a''. lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a'' ∧ src a'' = trg a ∧ trg a'' = src a' ∧ knd a'' = (λcf. False)⇩√› 16. ‹⋀a a'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; a' ∈ lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind a⟧ ⟹ ∃a''. lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a'' ∧ src a'' = src a ∧ trg a'' = trg a' ∧ knd a'' = (λcf. False)⇩√› 17. ‹⋀a Q r p fs. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q:r↪⇘p⇙fs⟧ ⟹ ∃!a'. lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a' ∧ src a' = src a ∧ intra_kind (knd a')› 18. ‹⋀a Q' p f'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q'↩⇘p⇙f'⟧ ⟹ ∃!a'. lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a' ∧ trg a' = trg a ∧ intra_kind (knd a')› 19. ‹⋀a a' Q₁ r₁ p fs₁ Q₂ r₂ fs₂. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a'; knd a = Q₁:r₁↪⇘p⇙fs₁; knd a' = Q₂:r₂↪⇘p⇙fs₂⟧ ⟹ trg a = trg a'› 20. ‹distinct_fst procs› 21. ‹⋀p ins outs. (p, ins, outs) ∈ set procs ⟹ distinct ins› 22. ‹⋀p ins outs. (p, ins, outs) ∈ set procs ⟹ distinct outs›*) fix a and a' assume "lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a" and "lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a'" and "src a = src a'" and "trg a = trg a'" (*‹lift_valid_edge (valid_edge::'a ⇒ bool) (sourcenode::'a ⇒ 'b) (targetnode::'a ⇒ 'b) (kind::'a ⇒ ('c, 'd, 'e, 'f) edge_kind) (Entry::'b) (Exit::'b) (a::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node)› ‹lift_valid_edge (valid_edge::'a ⇒ bool) (sourcenode::'a ⇒ 'b) (targetnode::'a ⇒ 'b) (kind::'a ⇒ ('c, 'd, 'e, 'f) edge_kind) (Entry::'b) (Exit::'b) (a'::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node)› ‹src (a::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node) = src (a'::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node)› ‹trg (a::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node) = trg (a'::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node)›*) thus "a = a'" proof (induct rule:lift_valid_edge.induct (*‹⟦lift_valid_edge ?valid_edge ?src ?trg ?knd ?E ?X ?x; ⋀a e. ⟦?valid_edge a; ?src a ≠ ?E ∨ ?trg a ≠ ?X; e = (Node (?src a), ?knd a, Node (?trg a))⟧ ⟹ ?P e; ⋀e. e = (NewEntry, (λs. True)⇩√, Node ?E) ⟹ ?P e; ⋀e. e = (Node ?X, (λs. True)⇩√, NewExit) ⟹ ?P e; ⋀e. e = (NewEntry, (λs. False)⇩√, NewExit) ⟹ ?P e⟧ ⟹ ?P ?x›*)) (*goals: 1. ‹⋀a e. ⟦valid_edge a; sourcenode a ≠ Entry ∨ targetnode a ≠ Exit; e = (Node (sourcenode a), kind a, Node (targetnode a)); lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a'; src e = src a'; trg e = trg a'⟧ ⟹ e = a'› 2. ‹⋀e. ⟦e = (NewEntry, (λs. True)⇩√, Node Entry); lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a'; src e = src a'; trg e = trg a'⟧ ⟹ e = a'› 3. ‹⋀e. ⟦e = (Node Exit, (λs. True)⇩√, NewExit); lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a'; src e = src a'; trg e = trg a'⟧ ⟹ e = a'› 4. ‹⋀e. ⟦e = (NewEntry, (λs. False)⇩√, NewExit); lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a'; src e = src a'; trg e = trg a'⟧ ⟹ e = a'›*) case lve_edge (*‹(valid_edge::'a::type ⇒ bool) (a_::'a::type)› ‹(sourcenode::'a ⇒ 'b) (a_::'a) ≠ (Entry::'b) ∨ (targetnode::'a ⇒ 'b) a_ ≠ (Exit::'b)› ‹e_ = (Node (sourcenode a_), kind a_, Node (targetnode a_))› ‹lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a'› ‹src e_ = src a'› ‹trg e_ = trg a'›*) thus "?case" (*goal: ‹e_ = a'›*) apply - (*goal: ‹(e_::'b::type LDCFG_node × ('c::type, 'd::type, 'e::type, 'f::type) edge_kind × 'b::type LDCFG_node) = (a'::'b::type LDCFG_node × ('c::type, 'd::type, 'e::type, 'f::type) edge_kind × 'b::type LDCFG_node)›*) apply (erule lift_valid_edge.cases (*‹⟦lift_valid_edge ?valid_edge ?src ?trg ?knd ?E ?X ?a; ⋀a e. ⟦?a = e; ?valid_edge a; ?src a ≠ ?E ∨ ?trg a ≠ ?X; e = (Node (?src a), ?knd a, Node (?trg a))⟧ ⟹ ?P; ⋀e. ⟦?a = e; e = (NewEntry, (λs. True)⇩√, Node ?E)⟧ ⟹ ?P; ⋀e. ⟦?a = e; e = (Node ?X, (λs. True)⇩√, NewExit)⟧ ⟹ ?P; ⋀e. ⟦?a = e; e = (NewEntry, (λs. False)⇩√, NewExit)⟧ ⟹ ?P⟧ ⟹ ?P›*)) (*goals: 1. ‹⋀a ea. ⟦valid_edge a_; sourcenode a_ ≠ Entry ∨ targetnode a_ ≠ Exit; e_ = (Node (sourcenode a_), kind a_, Node (targetnode a_)); src e_ = src a'; trg e_ = trg a'; a' = ea; valid_edge a; sourcenode a ≠ Entry ∨ targetnode a ≠ Exit; ea = (Node (sourcenode a), kind a, Node (targetnode a))⟧ ⟹ e_ = a'› 2. ‹⋀ea. ⟦valid_edge a_; sourcenode a_ ≠ Entry ∨ targetnode a_ ≠ Exit; e_ = (Node (sourcenode a_), kind a_, Node (targetnode a_)); src e_ = src a'; trg e_ = trg a'; a' = ea; ea = (NewEntry, (λs. True)⇩√, Node Entry)⟧ ⟹ e_ = a'› 3. ‹⋀ea. ⟦valid_edge a_; sourcenode a_ ≠ Entry ∨ targetnode a_ ≠ Exit; e_ = (Node (sourcenode a_), kind a_, Node (targetnode a_)); src e_ = src a'; trg e_ = trg a'; a' = ea; ea = (Node Exit, (λs. True)⇩√, NewExit)⟧ ⟹ e_ = a'› 4. ‹⋀ea. ⟦valid_edge a_; sourcenode a_ ≠ Entry ∨ targetnode a_ ≠ Exit; e_ = (Node (sourcenode a_), kind a_, Node (targetnode a_)); src e_ = src a'; trg e_ = trg a'; a' = ea; ea = (NewEntry, (λs. False)⇩√, NewExit)⟧ ⟹ e_ = a'› discuss goal 1*) apply ((auto dest:edge_det (*‹⟦valid_edge ?a; valid_edge ?a'; sourcenode ?a = sourcenode ?a'; targetnode ?a = targetnode ?a'⟧ ⟹ ?a = ?a'›*))[1]) (*discuss goal 2*) apply ((auto dest:edge_det (*‹⟦(valid_edge::'a ⇒ bool) (?a::'a); valid_edge (?a'::'a); (sourcenode::'a ⇒ 'b) ?a = sourcenode ?a'; (targetnode::'a ⇒ 'b) ?a = targetnode ?a'⟧ ⟹ ?a = ?a'›*))[1]) (*discuss goal 3*) apply ((auto dest:edge_det (*‹⟦(valid_edge::'a ⇒ bool) (?a::'a); valid_edge (?a'::'a); (sourcenode::'a ⇒ 'b) ?a = sourcenode ?a'; (targetnode::'a ⇒ 'b) ?a = targetnode ?a'⟧ ⟹ ?a = ?a'›*))[1]) (*discuss goal 4*) apply ((auto dest:edge_det (*‹⟦valid_edge ?a; valid_edge ?a'; sourcenode ?a = sourcenode ?a'; targetnode ?a = targetnode ?a'⟧ ⟹ ?a = ?a'›*))[1]) (*proven 4 subgoals*) . qed (auto elim:lift_valid_edge.cases (*‹⟦lift_valid_edge ?valid_edge ?src ?trg ?knd ?E ?X ?a; ⋀a e. ⟦?a = e; ?valid_edge a; ?src a ≠ ?E ∨ ?trg a ≠ ?X; e = (Node (?src a), ?knd a, Node (?trg a))⟧ ⟹ ?P; ⋀e. ⟦?a = e; e = (NewEntry, (λs. True)⇩√, Node ?E)⟧ ⟹ ?P; ⋀e. ⟦?a = e; e = (Node ?X, (λs. True)⇩√, NewExit)⟧ ⟹ ?P; ⋀e. ⟦?a = e; e = (NewEntry, (λs. False)⇩√, NewExit)⟧ ⟹ ?P⟧ ⟹ ?P›*)) (*solves the remaining goals: 1. ‹⋀e. ⟦e = (NewEntry, (λs. True)⇩√, Node Entry); lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a'; src e = src a'; trg e = trg a'⟧ ⟹ e = a'› 2. ‹⋀e. ⟦e = (Node Exit, (λs. True)⇩√, NewExit); lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a'; src e = src a'; trg e = trg a'⟧ ⟹ e = a'› 3. ‹⋀e. ⟦e = (NewEntry, (λs. False)⇩√, NewExit); lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a'; src e = src a'; trg e = trg a'⟧ ⟹ e = a'›*) next (*goals: 1. ‹⋀a Q r f. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q:r↪⇘Main⇙f⟧ ⟹ False› 2. ‹⋀a Q' f'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q'↩⇘Main⇙f'⟧ ⟹ False› 3. ‹⋀a Q r p fs. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q:r↪⇘p⇙fs⟧ ⟹ ∃ins outs. (p, ins, outs) ∈ set procs› 4. ‹⋀a. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; intra_kind (knd a)⟧ ⟹ lift_get_proc get_proc Main (src a) = lift_get_proc get_proc Main (trg a)› 5. ‹⋀a Q r p fs. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q:r↪⇘p⇙fs⟧ ⟹ lift_get_proc get_proc Main (trg a) = p› 6. ‹⋀a Q' p f'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q'↩⇘p⇙f'⟧ ⟹ lift_get_proc get_proc Main (src a) = p› 7. ‹⋀a Q r p fs. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q:r↪⇘p⇙fs⟧ ⟹ ∀a'. lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a' ∧ trg a' = trg a ⟶ (∃Qx rx fsx. knd a' = Qx:rx↪⇘p⇙fsx)› 8. ‹⋀a Q' p f'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q'↩⇘p⇙f'⟧ ⟹ ∀a'. lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a' ∧ src a' = src a ⟶ (∃Qx fx. knd a' = Qx↩⇘p⇙fx)› 9. ‹⋀a Q r p fs. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q:r↪⇘p⇙fs⟧ ⟹ lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind a ≠ {}› 10. ‹⋀a a'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; a' ∈ lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind a⟧ ⟹ lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a'› 11. ‹⋀a a'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; a' ∈ lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind a⟧ ⟹ ∃Q r p fs. knd a = Q:r↪⇘p⇙fs› 12. ‹⋀a Q r p fs a'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q:r↪⇘p⇙fs; a' ∈ lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind a⟧ ⟹ ∃Q' f'. knd a' = Q'↩⇘p⇙f'› 13. ‹⋀a Q' p f'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q'↩⇘p⇙f'⟧ ⟹ ∃!a'. lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a' ∧ (∃Q r fs. knd a' = Q:r↪⇘p⇙fs) ∧ a ∈ lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind a'› 14. ‹⋀a a'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; a' ∈ lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind a⟧ ⟹ ∃a''. lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a'' ∧ src a'' = trg a ∧ trg a'' = src a' ∧ knd a'' = (λcf. False)⇩√› 15. ‹⋀a a'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; a' ∈ lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind a⟧ ⟹ ∃a''. lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a'' ∧ src a'' = src a ∧ trg a'' = trg a' ∧ knd a'' = (λcf. False)⇩√› 16. ‹⋀a Q r p fs. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q:r↪⇘p⇙fs⟧ ⟹ ∃!a'. lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a' ∧ src a' = src a ∧ intra_kind (knd a')› 17. ‹⋀a Q' p f'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q'↩⇘p⇙f'⟧ ⟹ ∃!a'. lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a' ∧ trg a' = trg a ∧ intra_kind (knd a')› 18. ‹⋀a a' Q₁ r₁ p fs₁ Q₂ r₂ fs₂. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a'; knd a = Q₁:r₁↪⇘p⇙fs₁; knd a' = Q₂:r₂↪⇘p⇙fs₂⟧ ⟹ trg a = trg a'› 19. ‹distinct_fst procs› 20. ‹⋀p ins outs. (p, ins, outs) ∈ set procs ⟹ distinct ins› 21. ‹⋀p ins outs. (p, ins, outs) ∈ set procs ⟹ distinct outs›*) fix a and Q and r and f assume "lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a" and "knd a = Q:r↪⇘Main⇙f" (*‹lift_valid_edge (valid_edge::'a ⇒ bool) (sourcenode::'a ⇒ 'b) (targetnode::'a ⇒ 'b) (kind::'a ⇒ ('c, 'd, 'e, 'f) edge_kind) (Entry::'b) (Exit::'b) (a::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node)› ‹knd (a::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node) = Q::('c ⇒ 'd option) × 'e ⇒ bool:r::'e↪⇘Main::'f⇙f::(('c ⇒ 'd option) ⇒ 'd option) list›*) thus False by (fastforce elim:lift_valid_edge.cases (*‹⟦lift_valid_edge ?valid_edge ?src ?trg ?knd ?E ?X ?a; ⋀a e. ⟦?a = e; ?valid_edge a; ?src a ≠ ?E ∨ ?trg a ≠ ?X; e = (Node (?src a), ?knd a, Node (?trg a))⟧ ⟹ ?P; ⋀e. ⟦?a = e; e = (NewEntry, (λs. True)⇩√, Node ?E)⟧ ⟹ ?P; ⋀e. ⟦?a = e; e = (Node ?X, (λs. True)⇩√, NewExit)⟧ ⟹ ?P; ⋀e. ⟦?a = e; e = (NewEntry, (λs. False)⇩√, NewExit)⟧ ⟹ ?P⟧ ⟹ ?P›*) dest:Main_no_call_target (*‹⟦valid_edge ?a; kind ?a = ?Q:?r↪⇘Main⇙?f⟧ ⟹ False›*)) next (*goals: 1. ‹⋀a Q' f'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q'↩⇘Main⇙f'⟧ ⟹ False› 2. ‹⋀a Q r p fs. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q:r↪⇘p⇙fs⟧ ⟹ ∃ins outs. (p, ins, outs) ∈ set procs› 3. ‹⋀a. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; intra_kind (knd a)⟧ ⟹ lift_get_proc get_proc Main (src a) = lift_get_proc get_proc Main (trg a)› 4. ‹⋀a Q r p fs. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q:r↪⇘p⇙fs⟧ ⟹ lift_get_proc get_proc Main (trg a) = p› 5. ‹⋀a Q' p f'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q'↩⇘p⇙f'⟧ ⟹ lift_get_proc get_proc Main (src a) = p› 6. ‹⋀a Q r p fs. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q:r↪⇘p⇙fs⟧ ⟹ ∀a'. lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a' ∧ trg a' = trg a ⟶ (∃Qx rx fsx. knd a' = Qx:rx↪⇘p⇙fsx)› 7. ‹⋀a Q' p f'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q'↩⇘p⇙f'⟧ ⟹ ∀a'. lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a' ∧ src a' = src a ⟶ (∃Qx fx. knd a' = Qx↩⇘p⇙fx)› 8. ‹⋀a Q r p fs. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q:r↪⇘p⇙fs⟧ ⟹ lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind a ≠ {}› 9. ‹⋀a a'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; a' ∈ lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind a⟧ ⟹ lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a'› 10. ‹⋀a a'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; a' ∈ lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind a⟧ ⟹ ∃Q r p fs. knd a = Q:r↪⇘p⇙fs› 11. ‹⋀a Q r p fs a'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q:r↪⇘p⇙fs; a' ∈ lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind a⟧ ⟹ ∃Q' f'. knd a' = Q'↩⇘p⇙f'› 12. ‹⋀a Q' p f'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q'↩⇘p⇙f'⟧ ⟹ ∃!a'. lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a' ∧ (∃Q r fs. knd a' = Q:r↪⇘p⇙fs) ∧ a ∈ lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind a'› 13. ‹⋀a a'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; a' ∈ lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind a⟧ ⟹ ∃a''. lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a'' ∧ src a'' = trg a ∧ trg a'' = src a' ∧ knd a'' = (λcf. False)⇩√› 14. ‹⋀a a'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; a' ∈ lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind a⟧ ⟹ ∃a''. lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a'' ∧ src a'' = src a ∧ trg a'' = trg a' ∧ knd a'' = (λcf. False)⇩√› 15. ‹⋀a Q r p fs. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q:r↪⇘p⇙fs⟧ ⟹ ∃!a'. lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a' ∧ src a' = src a ∧ intra_kind (knd a')› 16. ‹⋀a Q' p f'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q'↩⇘p⇙f'⟧ ⟹ ∃!a'. lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a' ∧ trg a' = trg a ∧ intra_kind (knd a')› 17. ‹⋀a a' Q₁ r₁ p fs₁ Q₂ r₂ fs₂. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a'; knd a = Q₁:r₁↪⇘p⇙fs₁; knd a' = Q₂:r₂↪⇘p⇙fs₂⟧ ⟹ trg a = trg a'› 18. ‹distinct_fst procs› 19. ‹⋀p ins outs. (p, ins, outs) ∈ set procs ⟹ distinct ins› 20. ‹⋀p ins outs. (p, ins, outs) ∈ set procs ⟹ distinct outs›*) fix a and Q' and f' assume "lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a" and "knd a = Q'↩⇘Main⇙f'" (*‹lift_valid_edge (valid_edge::'a ⇒ bool) (sourcenode::'a ⇒ 'b) (targetnode::'a ⇒ 'b) (kind::'a ⇒ ('c, 'd, 'e, 'f) edge_kind) (Entry::'b) (Exit::'b) (a::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node)› ‹knd (a::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node) = Q'::('c ⇒ 'd option) × 'e ⇒ bool↩⇘Main::'f⇙f'::('c ⇒ 'd option) ⇒ ('c ⇒ 'd option) ⇒ 'c ⇒ 'd option›*) thus False by (fastforce elim:lift_valid_edge.cases (*‹⟦lift_valid_edge (?valid_edge::?'edge::type ⇒ bool) (?src::?'edge::type ⇒ ?'node::type) (?trg::?'edge::type ⇒ ?'node::type) (?knd::?'edge::type ⇒ (?'var::type, ?'val::type, ?'ret::type, ?'pname::type) edge_kind) (?E::?'node::type) (?X::?'node::type) (?a::?'node::type LDCFG_node × (?'var::type, ?'val::type, ?'ret::type, ?'pname::type) edge_kind × ?'node::type LDCFG_node); ⋀(a::?'edge::type) e::?'node::type LDCFG_node × (?'var::type, ?'val::type, ?'ret::type, ?'pname::type) edge_kind × ?'node::type LDCFG_node. ⟦?a = e; ?valid_edge a; ?src a ≠ ?E ∨ ?trg a ≠ ?X; e = (Node (?src a), ?knd a, Node (?trg a))⟧ ⟹ ?P::bool; ⋀e::?'node::type LDCFG_node × (?'var::type, ?'val::type, ?'ret::type, ?'pname::type) edge_kind × ?'node::type LDCFG_node. ⟦?a = e; e = (NewEntry, (λs::?'var::type ⇒ ?'val::type option. True)⇩√, Node ?E)⟧ ⟹ ?P; ⋀e::?'node::type LDCFG_node × (?'var::type, ?'val::type, ?'ret::type, ?'pname::type) edge_kind × ?'node::type LDCFG_node. ⟦?a = e; e = (Node ?X, (λs::?'var::type ⇒ ?'val::type option. True)⇩√, NewExit)⟧ ⟹ ?P; ⋀e::?'node::type LDCFG_node × (?'var::type, ?'val::type, ?'ret::type, ?'pname::type) edge_kind × ?'node::type LDCFG_node. ⟦?a = e; e = (NewEntry, (λs::?'var::type ⇒ ?'val::type option. False)⇩√, NewExit)⟧ ⟹ ?P⟧ ⟹ ?P›*) dest:Main_no_return_source (*‹⟦(valid_edge::'a::type ⇒ bool) (?a::'a::type); (kind::'a::type ⇒ ('c::type, 'd::type, 'e::type, 'f::type) edge_kind) ?a = ?Q'::('c::type ⇒ 'd::type option) × 'e::type ⇒ bool↩⇘Main::'f::type⇙?f'::('c::type ⇒ 'd::type option) ⇒ ('c::type ⇒ 'd::type option) ⇒ 'c::type ⇒ 'd::type option⟧ ⟹ False›*)) next (*goals: 1. ‹⋀a Q r p fs. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q:r↪⇘p⇙fs⟧ ⟹ ∃ins outs. (p, ins, outs) ∈ set procs› 2. ‹⋀a. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; intra_kind (knd a)⟧ ⟹ lift_get_proc get_proc Main (src a) = lift_get_proc get_proc Main (trg a)› 3. ‹⋀a Q r p fs. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q:r↪⇘p⇙fs⟧ ⟹ lift_get_proc get_proc Main (trg a) = p› 4. ‹⋀a Q' p f'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q'↩⇘p⇙f'⟧ ⟹ lift_get_proc get_proc Main (src a) = p› 5. ‹⋀a Q r p fs. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q:r↪⇘p⇙fs⟧ ⟹ ∀a'. lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a' ∧ trg a' = trg a ⟶ (∃Qx rx fsx. knd a' = Qx:rx↪⇘p⇙fsx)› 6. ‹⋀a Q' p f'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q'↩⇘p⇙f'⟧ ⟹ ∀a'. lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a' ∧ src a' = src a ⟶ (∃Qx fx. knd a' = Qx↩⇘p⇙fx)› 7. ‹⋀a Q r p fs. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q:r↪⇘p⇙fs⟧ ⟹ lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind a ≠ {}› 8. ‹⋀a a'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; a' ∈ lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind a⟧ ⟹ lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a'› 9. ‹⋀a a'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; a' ∈ lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind a⟧ ⟹ ∃Q r p fs. knd a = Q:r↪⇘p⇙fs› 10. ‹⋀a Q r p fs a'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q:r↪⇘p⇙fs; a' ∈ lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind a⟧ ⟹ ∃Q' f'. knd a' = Q'↩⇘p⇙f'› 11. ‹⋀a Q' p f'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q'↩⇘p⇙f'⟧ ⟹ ∃!a'. lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a' ∧ (∃Q r fs. knd a' = Q:r↪⇘p⇙fs) ∧ a ∈ lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind a'› 12. ‹⋀a a'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; a' ∈ lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind a⟧ ⟹ ∃a''. lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a'' ∧ src a'' = trg a ∧ trg a'' = src a' ∧ knd a'' = (λcf. False)⇩√› 13. ‹⋀a a'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; a' ∈ lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind a⟧ ⟹ ∃a''. lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a'' ∧ src a'' = src a ∧ trg a'' = trg a' ∧ knd a'' = (λcf. False)⇩√› 14. ‹⋀a Q r p fs. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q:r↪⇘p⇙fs⟧ ⟹ ∃!a'. lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a' ∧ src a' = src a ∧ intra_kind (knd a')› 15. ‹⋀a Q' p f'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q'↩⇘p⇙f'⟧ ⟹ ∃!a'. lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a' ∧ trg a' = trg a ∧ intra_kind (knd a')› 16. ‹⋀a a' Q₁ r₁ p fs₁ Q₂ r₂ fs₂. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a'; knd a = Q₁:r₁↪⇘p⇙fs₁; knd a' = Q₂:r₂↪⇘p⇙fs₂⟧ ⟹ trg a = trg a'› 17. ‹distinct_fst procs› 18. ‹⋀p ins outs. (p, ins, outs) ∈ set procs ⟹ distinct ins› 19. ‹⋀p ins outs. (p, ins, outs) ∈ set procs ⟹ distinct outs›*) fix a and Q and r and p and fs assume "lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a" and "knd a = Q:r↪⇘p⇙fs" (*‹lift_valid_edge (valid_edge::'a ⇒ bool) (sourcenode::'a ⇒ 'b) (targetnode::'a ⇒ 'b) (kind::'a ⇒ ('c, 'd, 'e, 'f) edge_kind) (Entry::'b) (Exit::'b) (a::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node)› ‹knd (a::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node) = Q::('c ⇒ 'd option) × 'e ⇒ bool:r::'e↪⇘p::'f⇙fs::(('c ⇒ 'd option) ⇒ 'd option) list›*) thus "∃ins outs. (p, ins, outs) ∈ set procs" by (fastforce elim:lift_valid_edge.cases (*‹⟦lift_valid_edge (?valid_edge::?'edge ⇒ bool) (?src::?'edge ⇒ ?'node) (?trg::?'edge ⇒ ?'node) (?knd::?'edge ⇒ (?'var, ?'val, ?'ret, ?'pname) edge_kind) (?E::?'node) (?X::?'node) (?a::?'node LDCFG_node × (?'var, ?'val, ?'ret, ?'pname) edge_kind × ?'node LDCFG_node); ⋀(a::?'edge) e::?'node LDCFG_node × (?'var, ?'val, ?'ret, ?'pname) edge_kind × ?'node LDCFG_node. ⟦?a = e; ?valid_edge a; ?src a ≠ ?E ∨ ?trg a ≠ ?X; e = (Node (?src a), ?knd a, Node (?trg a))⟧ ⟹ ?P::bool; ⋀e::?'node LDCFG_node × (?'var, ?'val, ?'ret, ?'pname) edge_kind × ?'node LDCFG_node. ⟦?a = e; e = (NewEntry, (λs::?'var ⇒ ?'val option. True)⇩√, Node ?E)⟧ ⟹ ?P; ⋀e::?'node LDCFG_node × (?'var, ?'val, ?'ret, ?'pname) edge_kind × ?'node LDCFG_node. ⟦?a = e; e = (Node ?X, (λs::?'var ⇒ ?'val option. True)⇩√, NewExit)⟧ ⟹ ?P; ⋀e::?'node LDCFG_node × (?'var, ?'val, ?'ret, ?'pname) edge_kind × ?'node LDCFG_node. ⟦?a = e; e = (NewEntry, (λs::?'var ⇒ ?'val option. False)⇩√, NewExit)⟧ ⟹ ?P⟧ ⟹ ?P›*) intro:callee_in_procs (*‹⟦(valid_edge::'a ⇒ bool) (?a::'a); (kind::'a ⇒ ('c, 'd, 'e, 'f) edge_kind) ?a = ?Q::('c ⇒ 'd option) × 'e ⇒ bool:?r::'e↪⇘?p::'f⇙?fs::(('c ⇒ 'd option) ⇒ 'd option) list⟧ ⟹ ∃(ins::'c list) outs::'c list. (?p, ins, outs) ∈ set (procs::('f × 'c list × 'c list) list)›*)) next (*goals: 1. ‹⋀a. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; intra_kind (knd a)⟧ ⟹ lift_get_proc get_proc Main (src a) = lift_get_proc get_proc Main (trg a)› 2. ‹⋀a Q r p fs. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q:r↪⇘p⇙fs⟧ ⟹ lift_get_proc get_proc Main (trg a) = p› 3. ‹⋀a Q' p f'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q'↩⇘p⇙f'⟧ ⟹ lift_get_proc get_proc Main (src a) = p› 4. ‹⋀a Q r p fs. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q:r↪⇘p⇙fs⟧ ⟹ ∀a'. lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a' ∧ trg a' = trg a ⟶ (∃Qx rx fsx. knd a' = Qx:rx↪⇘p⇙fsx)› 5. ‹⋀a Q' p f'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q'↩⇘p⇙f'⟧ ⟹ ∀a'. lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a' ∧ src a' = src a ⟶ (∃Qx fx. knd a' = Qx↩⇘p⇙fx)› 6. ‹⋀a Q r p fs. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q:r↪⇘p⇙fs⟧ ⟹ lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind a ≠ {}› 7. ‹⋀a a'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; a' ∈ lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind a⟧ ⟹ lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a'› 8. ‹⋀a a'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; a' ∈ lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind a⟧ ⟹ ∃Q r p fs. knd a = Q:r↪⇘p⇙fs› 9. ‹⋀a Q r p fs a'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q:r↪⇘p⇙fs; a' ∈ lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind a⟧ ⟹ ∃Q' f'. knd a' = Q'↩⇘p⇙f'› 10. ‹⋀a Q' p f'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q'↩⇘p⇙f'⟧ ⟹ ∃!a'. lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a' ∧ (∃Q r fs. knd a' = Q:r↪⇘p⇙fs) ∧ a ∈ lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind a'› 11. ‹⋀a a'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; a' ∈ lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind a⟧ ⟹ ∃a''. lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a'' ∧ src a'' = trg a ∧ trg a'' = src a' ∧ knd a'' = (λcf. False)⇩√› 12. ‹⋀a a'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; a' ∈ lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind a⟧ ⟹ ∃a''. lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a'' ∧ src a'' = src a ∧ trg a'' = trg a' ∧ knd a'' = (λcf. False)⇩√› 13. ‹⋀a Q r p fs. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q:r↪⇘p⇙fs⟧ ⟹ ∃!a'. lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a' ∧ src a' = src a ∧ intra_kind (knd a')› 14. ‹⋀a Q' p f'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q'↩⇘p⇙f'⟧ ⟹ ∃!a'. lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a' ∧ trg a' = trg a ∧ intra_kind (knd a')› 15. ‹⋀a a' Q₁ r₁ p fs₁ Q₂ r₂ fs₂. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a'; knd a = Q₁:r₁↪⇘p⇙fs₁; knd a' = Q₂:r₂↪⇘p⇙fs₂⟧ ⟹ trg a = trg a'› 16. ‹distinct_fst procs› 17. ‹⋀p ins outs. (p, ins, outs) ∈ set procs ⟹ distinct ins› 18. ‹⋀p ins outs. (p, ins, outs) ∈ set procs ⟹ distinct outs›*) fix a assume "lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a" and "intra_kind (knd a)" (*‹lift_valid_edge (valid_edge::'a ⇒ bool) (sourcenode::'a ⇒ 'b) (targetnode::'a ⇒ 'b) (kind::'a ⇒ ('c, 'd, 'e, 'f) edge_kind) (Entry::'b) (Exit::'b) (a::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node)› ‹intra_kind (knd (a::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node))›*) thus "lift_get_proc get_proc Main (src a) = lift_get_proc get_proc Main (trg a)" by (fastforce elim:lift_valid_edge.cases (*‹⟦lift_valid_edge ?valid_edge ?src ?trg ?knd ?E ?X ?a; ⋀a e. ⟦?a = e; ?valid_edge a; ?src a ≠ ?E ∨ ?trg a ≠ ?X; e = (Node (?src a), ?knd a, Node (?trg a))⟧ ⟹ ?P; ⋀e. ⟦?a = e; e = (NewEntry, (λs. True)⇩√, Node ?E)⟧ ⟹ ?P; ⋀e. ⟦?a = e; e = (Node ?X, (λs. True)⇩√, NewExit)⟧ ⟹ ?P; ⋀e. ⟦?a = e; e = (NewEntry, (λs. False)⇩√, NewExit)⟧ ⟹ ?P⟧ ⟹ ?P›*) intro:get_proc_intra (*‹⟦valid_edge ?a; intra_kind (kind ?a)⟧ ⟹ get_proc (sourcenode ?a) = get_proc (targetnode ?a)›*) simp:get_proc_Entry (*‹get_proc Entry = Main›*) get_proc_Exit (*‹get_proc Exit = Main›*)) next (*goals: 1. ‹⋀a Q r p fs. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q:r↪⇘p⇙fs⟧ ⟹ lift_get_proc get_proc Main (trg a) = p› 2. ‹⋀a Q' p f'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q'↩⇘p⇙f'⟧ ⟹ lift_get_proc get_proc Main (src a) = p› 3. ‹⋀a Q r p fs. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q:r↪⇘p⇙fs⟧ ⟹ ∀a'. lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a' ∧ trg a' = trg a ⟶ (∃Qx rx fsx. knd a' = Qx:rx↪⇘p⇙fsx)› 4. ‹⋀a Q' p f'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q'↩⇘p⇙f'⟧ ⟹ ∀a'. lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a' ∧ src a' = src a ⟶ (∃Qx fx. knd a' = Qx↩⇘p⇙fx)› 5. ‹⋀a Q r p fs. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q:r↪⇘p⇙fs⟧ ⟹ lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind a ≠ {}› 6. ‹⋀a a'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; a' ∈ lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind a⟧ ⟹ lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a'› 7. ‹⋀a a'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; a' ∈ lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind a⟧ ⟹ ∃Q r p fs. knd a = Q:r↪⇘p⇙fs› 8. ‹⋀a Q r p fs a'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q:r↪⇘p⇙fs; a' ∈ lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind a⟧ ⟹ ∃Q' f'. knd a' = Q'↩⇘p⇙f'› 9. ‹⋀a Q' p f'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q'↩⇘p⇙f'⟧ ⟹ ∃!a'. lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a' ∧ (∃Q r fs. knd a' = Q:r↪⇘p⇙fs) ∧ a ∈ lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind a'› 10. ‹⋀a a'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; a' ∈ lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind a⟧ ⟹ ∃a''. lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a'' ∧ src a'' = trg a ∧ trg a'' = src a' ∧ knd a'' = (λcf. False)⇩√› 11. ‹⋀a a'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; a' ∈ lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind a⟧ ⟹ ∃a''. lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a'' ∧ src a'' = src a ∧ trg a'' = trg a' ∧ knd a'' = (λcf. False)⇩√› 12. ‹⋀a Q r p fs. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q:r↪⇘p⇙fs⟧ ⟹ ∃!a'. lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a' ∧ src a' = src a ∧ intra_kind (knd a')› 13. ‹⋀a Q' p f'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q'↩⇘p⇙f'⟧ ⟹ ∃!a'. lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a' ∧ trg a' = trg a ∧ intra_kind (knd a')› 14. ‹⋀a a' Q₁ r₁ p fs₁ Q₂ r₂ fs₂. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a'; knd a = Q₁:r₁↪⇘p⇙fs₁; knd a' = Q₂:r₂↪⇘p⇙fs₂⟧ ⟹ trg a = trg a'› 15. ‹distinct_fst procs› 16. ‹⋀p ins outs. (p, ins, outs) ∈ set procs ⟹ distinct ins› 17. ‹⋀p ins outs. (p, ins, outs) ∈ set procs ⟹ distinct outs›*) fix a and Q and r and p and fs assume "lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a" and "knd a = Q:r↪⇘p⇙fs" (*‹lift_valid_edge (valid_edge::'a ⇒ bool) (sourcenode::'a ⇒ 'b) (targetnode::'a ⇒ 'b) (kind::'a ⇒ ('c, 'd, 'e, 'f) edge_kind) (Entry::'b) (Exit::'b) (a::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node)› ‹knd (a::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node) = Q::('c ⇒ 'd option) × 'e ⇒ bool:r::'e↪⇘p::'f⇙fs::(('c ⇒ 'd option) ⇒ 'd option) list›*) thus "lift_get_proc get_proc Main (trg a) = p" by (fastforce elim:lift_valid_edge.cases (*‹⟦lift_valid_edge ?valid_edge ?src ?trg ?knd ?E ?X ?a; ⋀a e. ⟦?a = e; ?valid_edge a; ?src a ≠ ?E ∨ ?trg a ≠ ?X; e = (Node (?src a), ?knd a, Node (?trg a))⟧ ⟹ ?P; ⋀e. ⟦?a = e; e = (NewEntry, (λs. True)⇩√, Node ?E)⟧ ⟹ ?P; ⋀e. ⟦?a = e; e = (Node ?X, (λs. True)⇩√, NewExit)⟧ ⟹ ?P; ⋀e. ⟦?a = e; e = (NewEntry, (λs. False)⇩√, NewExit)⟧ ⟹ ?P⟧ ⟹ ?P›*) intro:get_proc_call (*‹⟦valid_edge ?a; kind ?a = ?Q:?r↪⇘?p⇙?fs⟧ ⟹ get_proc (targetnode ?a) = ?p›*)) next (*goals: 1. ‹⋀a Q' p f'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q'↩⇘p⇙f'⟧ ⟹ lift_get_proc get_proc Main (src a) = p› 2. ‹⋀a Q r p fs. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q:r↪⇘p⇙fs⟧ ⟹ ∀a'. lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a' ∧ trg a' = trg a ⟶ (∃Qx rx fsx. knd a' = Qx:rx↪⇘p⇙fsx)› 3. ‹⋀a Q' p f'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q'↩⇘p⇙f'⟧ ⟹ ∀a'. lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a' ∧ src a' = src a ⟶ (∃Qx fx. knd a' = Qx↩⇘p⇙fx)› 4. ‹⋀a Q r p fs. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q:r↪⇘p⇙fs⟧ ⟹ lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind a ≠ {}› 5. ‹⋀a a'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; a' ∈ lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind a⟧ ⟹ lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a'› 6. ‹⋀a a'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; a' ∈ lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind a⟧ ⟹ ∃Q r p fs. knd a = Q:r↪⇘p⇙fs› 7. ‹⋀a Q r p fs a'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q:r↪⇘p⇙fs; a' ∈ lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind a⟧ ⟹ ∃Q' f'. knd a' = Q'↩⇘p⇙f'› 8. ‹⋀a Q' p f'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q'↩⇘p⇙f'⟧ ⟹ ∃!a'. lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a' ∧ (∃Q r fs. knd a' = Q:r↪⇘p⇙fs) ∧ a ∈ lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind a'› 9. ‹⋀a a'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; a' ∈ lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind a⟧ ⟹ ∃a''. lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a'' ∧ src a'' = trg a ∧ trg a'' = src a' ∧ knd a'' = (λcf. False)⇩√› 10. ‹⋀a a'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; a' ∈ lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind a⟧ ⟹ ∃a''. lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a'' ∧ src a'' = src a ∧ trg a'' = trg a' ∧ knd a'' = (λcf. False)⇩√› 11. ‹⋀a Q r p fs. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q:r↪⇘p⇙fs⟧ ⟹ ∃!a'. lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a' ∧ src a' = src a ∧ intra_kind (knd a')› 12. ‹⋀a Q' p f'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q'↩⇘p⇙f'⟧ ⟹ ∃!a'. lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a' ∧ trg a' = trg a ∧ intra_kind (knd a')› 13. ‹⋀a a' Q₁ r₁ p fs₁ Q₂ r₂ fs₂. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a'; knd a = Q₁:r₁↪⇘p⇙fs₁; knd a' = Q₂:r₂↪⇘p⇙fs₂⟧ ⟹ trg a = trg a'› 14. ‹distinct_fst procs› 15. ‹⋀p ins outs. (p, ins, outs) ∈ set procs ⟹ distinct ins› 16. ‹⋀p ins outs. (p, ins, outs) ∈ set procs ⟹ distinct outs›*) fix a and Q' and p and f' assume "lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a" and "knd a = Q'↩⇘p⇙f'" (*‹lift_valid_edge (valid_edge::'a ⇒ bool) (sourcenode::'a ⇒ 'b) (targetnode::'a ⇒ 'b) (kind::'a ⇒ ('c, 'd, 'e, 'f) edge_kind) (Entry::'b) (Exit::'b) (a::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node)› ‹knd (a::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node) = Q'::('c ⇒ 'd option) × 'e ⇒ bool↩⇘p::'f⇙f'::('c ⇒ 'd option) ⇒ ('c ⇒ 'd option) ⇒ 'c ⇒ 'd option›*) thus "lift_get_proc get_proc Main (src a) = p" by (fastforce elim:lift_valid_edge.cases (*‹⟦lift_valid_edge ?valid_edge ?src ?trg ?knd ?E ?X ?a; ⋀a e. ⟦?a = e; ?valid_edge a; ?src a ≠ ?E ∨ ?trg a ≠ ?X; e = (Node (?src a), ?knd a, Node (?trg a))⟧ ⟹ ?P; ⋀e. ⟦?a = e; e = (NewEntry, (λs. True)⇩√, Node ?E)⟧ ⟹ ?P; ⋀e. ⟦?a = e; e = (Node ?X, (λs. True)⇩√, NewExit)⟧ ⟹ ?P; ⋀e. ⟦?a = e; e = (NewEntry, (λs. False)⇩√, NewExit)⟧ ⟹ ?P⟧ ⟹ ?P›*) intro:get_proc_return (*‹⟦valid_edge ?a; kind ?a = ?Q'↩⇘?p⇙?f'⟧ ⟹ get_proc (sourcenode ?a) = ?p›*)) next (*goals: 1. ‹⋀a Q r p fs. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q:r↪⇘p⇙fs⟧ ⟹ ∀a'. lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a' ∧ trg a' = trg a ⟶ (∃Qx rx fsx. knd a' = Qx:rx↪⇘p⇙fsx)› 2. ‹⋀a Q' p f'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q'↩⇘p⇙f'⟧ ⟹ ∀a'. lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a' ∧ src a' = src a ⟶ (∃Qx fx. knd a' = Qx↩⇘p⇙fx)› 3. ‹⋀a Q r p fs. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q:r↪⇘p⇙fs⟧ ⟹ lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind a ≠ {}› 4. ‹⋀a a'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; a' ∈ lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind a⟧ ⟹ lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a'› 5. ‹⋀a a'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; a' ∈ lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind a⟧ ⟹ ∃Q r p fs. knd a = Q:r↪⇘p⇙fs› 6. ‹⋀a Q r p fs a'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q:r↪⇘p⇙fs; a' ∈ lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind a⟧ ⟹ ∃Q' f'. knd a' = Q'↩⇘p⇙f'› 7. ‹⋀a Q' p f'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q'↩⇘p⇙f'⟧ ⟹ ∃!a'. lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a' ∧ (∃Q r fs. knd a' = Q:r↪⇘p⇙fs) ∧ a ∈ lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind a'› 8. ‹⋀a a'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; a' ∈ lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind a⟧ ⟹ ∃a''. lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a'' ∧ src a'' = trg a ∧ trg a'' = src a' ∧ knd a'' = (λcf. False)⇩√› 9. ‹⋀a a'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; a' ∈ lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind a⟧ ⟹ ∃a''. lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a'' ∧ src a'' = src a ∧ trg a'' = trg a' ∧ knd a'' = (λcf. False)⇩√› 10. ‹⋀a Q r p fs. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q:r↪⇘p⇙fs⟧ ⟹ ∃!a'. lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a' ∧ src a' = src a ∧ intra_kind (knd a')› 11. ‹⋀a Q' p f'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q'↩⇘p⇙f'⟧ ⟹ ∃!a'. lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a' ∧ trg a' = trg a ∧ intra_kind (knd a')› 12. ‹⋀a a' Q₁ r₁ p fs₁ Q₂ r₂ fs₂. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a'; knd a = Q₁:r₁↪⇘p⇙fs₁; knd a' = Q₂:r₂↪⇘p⇙fs₂⟧ ⟹ trg a = trg a'› 13. ‹distinct_fst procs› 14. ‹⋀p ins outs. (p, ins, outs) ∈ set procs ⟹ distinct ins› 15. ‹⋀p ins outs. (p, ins, outs) ∈ set procs ⟹ distinct outs›*) fix a and Q and r and p and fs assume "lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a" and "knd a = Q:r↪⇘p⇙fs" (*‹lift_valid_edge (valid_edge::'a ⇒ bool) (sourcenode::'a ⇒ 'b) (targetnode::'a ⇒ 'b) (kind::'a ⇒ ('c, 'd, 'e, 'f) edge_kind) (Entry::'b) (Exit::'b) (a::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node)› ‹knd (a::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node) = Q::('c ⇒ 'd option) × 'e ⇒ bool:r::'e↪⇘p::'f⇙fs::(('c ⇒ 'd option) ⇒ 'd option) list›*) then obtain ax where "valid_edge ax" and "kind ax = Q:r↪⇘p⇙fs" and "sourcenode ax ≠ Entry ∨ targetnode ax ≠ Exit" and "src a = Node (sourcenode ax)" and "trg a = Node (targetnode ax)" (*goal: ‹(⋀ax. ⟦valid_edge ax; kind ax = Q:r↪⇘p⇙fs; sourcenode ax ≠ Entry ∨ targetnode ax ≠ Exit; src a = Node (sourcenode ax); trg a = Node (targetnode ax)⟧ ⟹ thesis) ⟹ thesis›*) by (fastforce elim:lift_valid_edge.cases (*‹⟦lift_valid_edge (?valid_edge::?'edge::type ⇒ bool) (?src::?'edge::type ⇒ ?'node::type) (?trg::?'edge::type ⇒ ?'node::type) (?knd::?'edge::type ⇒ (?'var::type, ?'val::type, ?'ret::type, ?'pname::type) edge_kind) (?E::?'node::type) (?X::?'node::type) (?a::?'node::type LDCFG_node × (?'var::type, ?'val::type, ?'ret::type, ?'pname::type) edge_kind × ?'node::type LDCFG_node); ⋀(a::?'edge::type) e::?'node::type LDCFG_node × (?'var::type, ?'val::type, ?'ret::type, ?'pname::type) edge_kind × ?'node::type LDCFG_node. ⟦?a = e; ?valid_edge a; ?src a ≠ ?E ∨ ?trg a ≠ ?X; e = (Node (?src a), ?knd a, Node (?trg a))⟧ ⟹ ?P::bool; ⋀e::?'node::type LDCFG_node × (?'var::type, ?'val::type, ?'ret::type, ?'pname::type) edge_kind × ?'node::type LDCFG_node. ⟦?a = e; e = (NewEntry, (λs::?'var::type ⇒ ?'val::type option. True)⇩√, Node ?E)⟧ ⟹ ?P; ⋀e::?'node::type LDCFG_node × (?'var::type, ?'val::type, ?'ret::type, ?'pname::type) edge_kind × ?'node::type LDCFG_node. ⟦?a = e; e = (Node ?X, (λs::?'var::type ⇒ ?'val::type option. True)⇩√, NewExit)⟧ ⟹ ?P; ⋀e::?'node::type LDCFG_node × (?'var::type, ?'val::type, ?'ret::type, ?'pname::type) edge_kind × ?'node::type LDCFG_node. ⟦?a = e; e = (NewEntry, (λs::?'var::type ⇒ ?'val::type option. False)⇩√, NewExit)⟧ ⟹ ?P⟧ ⟹ ?P›*)) from ‹valid_edge ax› (*‹(valid_edge::'a ⇒ bool) (ax::'a)›*) ‹kind ax = Q:r↪⇘p⇙fs› (*‹kind ax = Q:r↪⇘p⇙fs›*) have all: "∀a'. valid_edge a' ∧ targetnode a' = targetnode ax ⟶ (∃Qx rx fsx. kind a' = Qx:rx↪⇘p⇙fsx)" by (auto dest:call_edges_only (*‹⟦valid_edge ?a; kind ?a = ?Q:?r↪⇘?p⇙?fs⟧ ⟹ ∀a'. valid_edge a' ∧ targetnode a' = targetnode ?a ⟶ (∃Qx rx fsx. kind a' = Qx:rx↪⇘?p⇙fsx)›*)) { fix a' assume "lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a'" and "trg a' = trg a" (*‹lift_valid_edge (valid_edge::'a ⇒ bool) (sourcenode::'a ⇒ 'b) (targetnode::'a ⇒ 'b) (kind::'a ⇒ ('c, 'd, 'e, 'f) edge_kind) (Entry::'b) (Exit::'b) (a'::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node)› ‹trg (a'::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node) = trg (a::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node)›*) hence "∃Qx rx fsx. knd a' = Qx:rx↪⇘p⇙fsx" proof (induct rule:lift_valid_edge.induct (*‹⟦lift_valid_edge ?valid_edge ?src ?trg ?knd ?E ?X ?x; ⋀a e. ⟦?valid_edge a; ?src a ≠ ?E ∨ ?trg a ≠ ?X; e = (Node (?src a), ?knd a, Node (?trg a))⟧ ⟹ ?P e; ⋀e. e = (NewEntry, (λs. True)⇩√, Node ?E) ⟹ ?P e; ⋀e. e = (Node ?X, (λs. True)⇩√, NewExit) ⟹ ?P e; ⋀e. e = (NewEntry, (λs. False)⇩√, NewExit) ⟹ ?P e⟧ ⟹ ?P ?x›*)) (*goals: 1. ‹⋀(aa::'a) e::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node. ⟦(valid_edge::'a ⇒ bool) aa; (sourcenode::'a ⇒ 'b) aa ≠ (Entry::'b) ∨ (targetnode::'a ⇒ 'b) aa ≠ (Exit::'b); e = (Node (sourcenode aa), (kind::'a ⇒ ('c, 'd, 'e, 'f) edge_kind) aa, Node (targetnode aa)); trg e = trg (a::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node)⟧ ⟹ ∃(Qx::('c ⇒ 'd option) × 'e ⇒ bool) (rx::'e) fsx::(('c ⇒ 'd option) ⇒ 'd option) list. knd e = Qx:rx↪⇘p::'f⇙fsx› 2. ‹⋀e::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node. ⟦e = (NewEntry, (λs::'c ⇒ 'd option. True)⇩√, Node (Entry::'b)); trg e = trg (a::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node)⟧ ⟹ ∃(Qx::('c ⇒ 'd option) × 'e ⇒ bool) (rx::'e) fsx::(('c ⇒ 'd option) ⇒ 'd option) list. knd e = Qx:rx↪⇘p::'f⇙fsx› 3. ‹⋀e::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node. ⟦e = (Node (Exit::'b), (λs::'c ⇒ 'd option. True)⇩√, NewExit); trg e = trg (a::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node)⟧ ⟹ ∃(Qx::('c ⇒ 'd option) × 'e ⇒ bool) (rx::'e) fsx::(('c ⇒ 'd option) ⇒ 'd option) list. knd e = Qx:rx↪⇘p::'f⇙fsx› 4. ‹⋀e::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node. ⟦e = (NewEntry, (λs::'c ⇒ 'd option. False)⇩√, NewExit); trg e = trg (a::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node)⟧ ⟹ ∃(Qx::('c ⇒ 'd option) × 'e ⇒ bool) (rx::'e) fsx::(('c ⇒ 'd option) ⇒ 'd option) list. knd e = Qx:rx↪⇘p::'f⇙fsx›*) case (lve_edge ax' e) (*‹valid_edge ax'› ‹(sourcenode::'a ⇒ 'b) (ax'::'a) ≠ (Entry::'b) ∨ (targetnode::'a ⇒ 'b) ax' ≠ (Exit::'b)› ‹(e::'b::type LDCFG_node × ('c::type, 'd::type, 'e::type, 'f::type) edge_kind × 'b::type LDCFG_node) = (Node ((sourcenode::'a::type ⇒ 'b::type) (ax'::'a::type)), (kind::'a::type ⇒ ('c::type, 'd::type, 'e::type, 'f::type) edge_kind) ax', Node ((targetnode::'a::type ⇒ 'b::type) ax'))› ‹trg e = trg a›*) note [simp] = ‹e = (Node (sourcenode ax'), kind ax', Node (targetnode ax'))› (*‹e = (Node (sourcenode ax'), kind ax', Node (targetnode ax'))›*) from ‹trg e = trg a› (*‹trg e = trg a›*) ‹trg a = Node (targetnode ax)› (*‹trg a = Node (targetnode ax)›*) have "targetnode ax' = targetnode ax" by simp with ‹valid_edge ax'› (*‹(valid_edge::'a ⇒ bool) (ax'::'a)›*) all (*‹∀a'::'a. (valid_edge::'a ⇒ bool) a' ∧ (targetnode::'a ⇒ 'b) a' = targetnode (ax::'a) ⟶ (∃(Qx::('c ⇒ 'd option) × 'e ⇒ bool) (rx::'e) fsx::(('c ⇒ 'd option) ⇒ 'd option) list. (kind::'a ⇒ ('c, 'd, 'e, 'f) edge_kind) a' = Qx:rx↪⇘p::'f⇙fsx)›*) have "∃Qx rx fsx. kind ax' = Qx:rx↪⇘p⇙fsx" by blast thus "?case" (*goal: ‹∃Qx rx fsx. knd e = Qx:rx↪⇘p⇙fsx›*) by simp next (*goals: 1. ‹⋀e. ⟦e = (NewEntry, (λs. True)⇩√, Node Entry); trg e = trg a⟧ ⟹ ∃Qx rx fsx. knd e = Qx:rx↪⇘p⇙fsx› 2. ‹⋀e. ⟦e = (Node Exit, (λs. True)⇩√, NewExit); trg e = trg a⟧ ⟹ ∃Qx rx fsx. knd e = Qx:rx↪⇘p⇙fsx› 3. ‹⋀e. ⟦e = (NewEntry, (λs. False)⇩√, NewExit); trg e = trg a⟧ ⟹ ∃Qx rx fsx. knd e = Qx:rx↪⇘p⇙fsx›*) case (lve_Entry_edge e) (*‹e = (NewEntry, (λs. True)⇩√, Node Entry)› ‹trg (e::'b::type LDCFG_node × ('c::type, 'd::type, 'e::type, 'f::type) edge_kind × 'b::type LDCFG_node) = trg (a::'b::type LDCFG_node × ('c::type, 'd::type, 'e::type, 'f::type) edge_kind × 'b::type LDCFG_node)›*) from ‹e = (NewEntry, (λs. True)⇩√, Node Entry)› (*‹e = (NewEntry, (λs. True)⇩√, Node Entry)›*) ‹trg e = trg a› (*‹trg e = trg a›*) ‹trg a = Node (targetnode ax)› (*‹trg a = Node (targetnode ax)›*) have "targetnode ax = Entry" by simp with ‹valid_edge ax› (*‹(valid_edge::'a ⇒ bool) (ax::'a)›*) have False by (rule Entry_target (*‹⟦valid_edge ?a; targetnode ?a = Entry⟧ ⟹ False›*)) thus "?case" (*goal: ‹∃Qx rx fsx. knd e = Qx:rx↪⇘p⇙fsx›*) by simp next (*goals: 1. ‹⋀e. ⟦e = (Node Exit, (λs. True)⇩√, NewExit); trg e = trg a⟧ ⟹ ∃Qx rx fsx. knd e = Qx:rx↪⇘p⇙fsx› 2. ‹⋀e. ⟦e = (NewEntry, (λs. False)⇩√, NewExit); trg e = trg a⟧ ⟹ ∃Qx rx fsx. knd e = Qx:rx↪⇘p⇙fsx›*) case (lve_Exit_edge e) (*‹e = (Node Exit, (λs. True)⇩√, NewExit)› ‹trg e = trg a›*) from ‹e = (Node Exit, (λs. True)⇩√, NewExit)› (*‹e = (Node Exit, (λs. True)⇩√, NewExit)›*) ‹trg e = trg a› (*‹trg e = trg a›*) ‹trg a = Node (targetnode ax)› (*‹trg (a::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node) = Node ((targetnode::'a ⇒ 'b) (ax::'a))›*) have False by simp thus "?case" (*goal: ‹∃(Qx::('c::type ⇒ 'd::type option) × 'e::type ⇒ bool) (rx::'e::type) fsx::(('c::type ⇒ 'd::type option) ⇒ 'd::type option) list. knd (e::'b::type LDCFG_node × ('c::type, 'd::type, 'e::type, 'f::type) edge_kind × 'b::type LDCFG_node) = Qx:rx↪⇘p::'f::type⇙fsx›*) by simp next (*goal: ‹⋀e. ⟦e = (NewEntry, (λs. False)⇩√, NewExit); trg e = trg a⟧ ⟹ ∃Qx rx fsx. knd e = Qx:rx↪⇘p⇙fsx›*) case (lve_Entry_Exit_edge e) (*‹e = (NewEntry, (λs. False)⇩√, NewExit)› ‹trg e = trg a›*) from ‹e = (NewEntry,(λs. False)⇩√,NewExit)› (*‹e = (NewEntry, (λs. False)⇩√, NewExit)›*) ‹trg e = trg a› (*‹trg (e::'b::type LDCFG_node × ('c::type, 'd::type, 'e::type, 'f::type) edge_kind × 'b::type LDCFG_node) = trg (a::'b::type LDCFG_node × ('c::type, 'd::type, 'e::type, 'f::type) edge_kind × 'b::type LDCFG_node)›*) ‹trg a = Node (targetnode ax)› (*‹trg (a::'b::type LDCFG_node × ('c::type, 'd::type, 'e::type, 'f::type) edge_kind × 'b::type LDCFG_node) = Node ((targetnode::'a::type ⇒ 'b::type) (ax::'a::type))›*) have False by simp thus "?case" (*goal: ‹∃Qx rx fsx. knd e = Qx:rx↪⇘p⇙fsx›*) by simp qed } thus "∀a'. lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a' ∧ trg a' = trg a ⟶ (∃Qx rx fsx. knd a' = Qx:rx↪⇘p⇙fsx)" by simp next (*goals: 1. ‹⋀a Q' p f'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q'↩⇘p⇙f'⟧ ⟹ ∀a'. lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a' ∧ src a' = src a ⟶ (∃Qx fx. knd a' = Qx↩⇘p⇙fx)› 2. ‹⋀a Q r p fs. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q:r↪⇘p⇙fs⟧ ⟹ lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind a ≠ {}› 3. ‹⋀a a'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; a' ∈ lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind a⟧ ⟹ lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a'› 4. ‹⋀a a'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; a' ∈ lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind a⟧ ⟹ ∃Q r p fs. knd a = Q:r↪⇘p⇙fs› 5. ‹⋀a Q r p fs a'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q:r↪⇘p⇙fs; a' ∈ lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind a⟧ ⟹ ∃Q' f'. knd a' = Q'↩⇘p⇙f'› 6. ‹⋀a Q' p f'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q'↩⇘p⇙f'⟧ ⟹ ∃!a'. lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a' ∧ (∃Q r fs. knd a' = Q:r↪⇘p⇙fs) ∧ a ∈ lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind a'› 7. ‹⋀a a'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; a' ∈ lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind a⟧ ⟹ ∃a''. lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a'' ∧ src a'' = trg a ∧ trg a'' = src a' ∧ knd a'' = (λcf. False)⇩√› 8. ‹⋀a a'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; a' ∈ lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind a⟧ ⟹ ∃a''. lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a'' ∧ src a'' = src a ∧ trg a'' = trg a' ∧ knd a'' = (λcf. False)⇩√› 9. ‹⋀a Q r p fs. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q:r↪⇘p⇙fs⟧ ⟹ ∃!a'. lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a' ∧ src a' = src a ∧ intra_kind (knd a')› 10. ‹⋀a Q' p f'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q'↩⇘p⇙f'⟧ ⟹ ∃!a'. lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a' ∧ trg a' = trg a ∧ intra_kind (knd a')› 11. ‹⋀a a' Q₁ r₁ p fs₁ Q₂ r₂ fs₂. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a'; knd a = Q₁:r₁↪⇘p⇙fs₁; knd a' = Q₂:r₂↪⇘p⇙fs₂⟧ ⟹ trg a = trg a'› 12. ‹distinct_fst procs› 13. ‹⋀p ins outs. (p, ins, outs) ∈ set procs ⟹ distinct ins› 14. ‹⋀p ins outs. (p, ins, outs) ∈ set procs ⟹ distinct outs›*) fix a and Q' and p and f' assume "lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a" and "knd a = Q'↩⇘p⇙f'" (*‹lift_valid_edge (valid_edge::'a ⇒ bool) (sourcenode::'a ⇒ 'b) (targetnode::'a ⇒ 'b) (kind::'a ⇒ ('c, 'd, 'e, 'f) edge_kind) (Entry::'b) (Exit::'b) (a::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node)› ‹knd (a::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node) = Q'::('c ⇒ 'd option) × 'e ⇒ bool↩⇘p::'f⇙f'::('c ⇒ 'd option) ⇒ ('c ⇒ 'd option) ⇒ 'c ⇒ 'd option›*) then obtain ax where "valid_edge ax" and "kind ax = Q'↩⇘p⇙f'" and "sourcenode ax ≠ Entry ∨ targetnode ax ≠ Exit" and "src a = Node (sourcenode ax)" and "trg a = Node (targetnode ax)" (*goal: ‹(⋀ax. ⟦valid_edge ax; kind ax = Q'↩⇘p⇙f'; sourcenode ax ≠ Entry ∨ targetnode ax ≠ Exit; src a = Node (sourcenode ax); trg a = Node (targetnode ax)⟧ ⟹ thesis) ⟹ thesis›*) by (fastforce elim:lift_valid_edge.cases (*‹⟦lift_valid_edge ?valid_edge ?src ?trg ?knd ?E ?X ?a; ⋀a e. ⟦?a = e; ?valid_edge a; ?src a ≠ ?E ∨ ?trg a ≠ ?X; e = (Node (?src a), ?knd a, Node (?trg a))⟧ ⟹ ?P; ⋀e. ⟦?a = e; e = (NewEntry, (λs. True)⇩√, Node ?E)⟧ ⟹ ?P; ⋀e. ⟦?a = e; e = (Node ?X, (λs. True)⇩√, NewExit)⟧ ⟹ ?P; ⋀e. ⟦?a = e; e = (NewEntry, (λs. False)⇩√, NewExit)⟧ ⟹ ?P⟧ ⟹ ?P›*)) from ‹valid_edge ax› (*‹valid_edge ax›*) ‹kind ax = Q'↩⇘p⇙f'› (*‹(kind::'a::type ⇒ ('c::type, 'd::type, 'e::type, 'f::type) edge_kind) (ax::'a::type) = Q'::('c::type ⇒ 'd::type option) × 'e::type ⇒ bool↩⇘p::'f::type⇙f'::('c::type ⇒ 'd::type option) ⇒ ('c::type ⇒ 'd::type option) ⇒ 'c::type ⇒ 'd::type option›*) have all: "∀a'. valid_edge a' ∧ sourcenode a' = sourcenode ax ⟶ (∃Qx fx. kind a' = Qx↩⇘p⇙fx)" by (auto dest:return_edges_only (*‹⟦valid_edge ?a; kind ?a = ?Q'↩⇘?p⇙?f'⟧ ⟹ ∀a'. valid_edge a' ∧ sourcenode a' = sourcenode ?a ⟶ (∃Qx fx. kind a' = Qx↩⇘?p⇙fx)›*)) { fix a' assume "lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a'" and "src a' = src a" (*‹lift_valid_edge (valid_edge::'a ⇒ bool) (sourcenode::'a ⇒ 'b) (targetnode::'a ⇒ 'b) (kind::'a ⇒ ('c, 'd, 'e, 'f) edge_kind) (Entry::'b) (Exit::'b) (a'::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node)› ‹src (a'::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node) = src (a::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node)›*) hence "∃Qx fx. knd a' = Qx↩⇘p⇙fx" proof (induct rule:lift_valid_edge.induct (*‹⟦lift_valid_edge ?valid_edge ?src ?trg ?knd ?E ?X ?x; ⋀a e. ⟦?valid_edge a; ?src a ≠ ?E ∨ ?trg a ≠ ?X; e = (Node (?src a), ?knd a, Node (?trg a))⟧ ⟹ ?P e; ⋀e. e = (NewEntry, (λs. True)⇩√, Node ?E) ⟹ ?P e; ⋀e. e = (Node ?X, (λs. True)⇩√, NewExit) ⟹ ?P e; ⋀e. e = (NewEntry, (λs. False)⇩√, NewExit) ⟹ ?P e⟧ ⟹ ?P ?x›*)) (*goals: 1. ‹⋀aa e. ⟦valid_edge aa; sourcenode aa ≠ Entry ∨ targetnode aa ≠ Exit; e = (Node (sourcenode aa), kind aa, Node (targetnode aa)); src e = src a⟧ ⟹ ∃Qx fx. knd e = Qx↩⇘p⇙fx› 2. ‹⋀e. ⟦e = (NewEntry, (λs. True)⇩√, Node Entry); src e = src a⟧ ⟹ ∃Qx fx. knd e = Qx↩⇘p⇙fx› 3. ‹⋀e. ⟦e = (Node Exit, (λs. True)⇩√, NewExit); src e = src a⟧ ⟹ ∃Qx fx. knd e = Qx↩⇘p⇙fx› 4. ‹⋀e. ⟦e = (NewEntry, (λs. False)⇩√, NewExit); src e = src a⟧ ⟹ ∃Qx fx. knd e = Qx↩⇘p⇙fx›*) case (lve_edge ax' e) (*‹valid_edge ax'› ‹(sourcenode::'a::type ⇒ 'b::type) (ax'::'a::type) ≠ (Entry::'b::type) ∨ (targetnode::'a::type ⇒ 'b::type) ax' ≠ (Exit::'b::type)› ‹e = (Node (sourcenode ax'), kind ax', Node (targetnode ax'))› ‹src e = src a›*) note [simp] = ‹e = (Node (sourcenode ax'), kind ax', Node (targetnode ax'))› (*‹e = (Node (sourcenode ax'), kind ax', Node (targetnode ax'))›*) from ‹src e = src a› (*‹src e = src a›*) ‹src a = Node (sourcenode ax)› (*‹src a = Node (sourcenode ax)›*) have "sourcenode ax' = sourcenode ax" by simp with ‹valid_edge ax'› (*‹valid_edge ax'›*) all (*‹∀a'. valid_edge a' ∧ sourcenode a' = sourcenode ax ⟶ (∃Qx fx. kind a' = Qx↩⇘p⇙fx)›*) have "∃Qx fx. kind ax' = Qx↩⇘p⇙fx" by blast thus "?case" (*goal: ‹∃Qx fx. knd e = Qx↩⇘p⇙fx›*) by simp next (*goals: 1. ‹⋀e. ⟦e = (NewEntry, (λs. True)⇩√, Node Entry); src e = src a⟧ ⟹ ∃Qx fx. knd e = Qx↩⇘p⇙fx› 2. ‹⋀e. ⟦e = (Node Exit, (λs. True)⇩√, NewExit); src e = src a⟧ ⟹ ∃Qx fx. knd e = Qx↩⇘p⇙fx› 3. ‹⋀e. ⟦e = (NewEntry, (λs. False)⇩√, NewExit); src e = src a⟧ ⟹ ∃Qx fx. knd e = Qx↩⇘p⇙fx›*) case (lve_Entry_edge e) (*‹(e::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node) = (NewEntry, (λs::'c ⇒ 'd option. True)⇩√, Node (Entry::'b))› ‹src e = src a›*) from ‹e = (NewEntry, (λs. True)⇩√, Node Entry)› (*‹e = (NewEntry, (λs. True)⇩√, Node Entry)›*) ‹src e = src a› (*‹src e = src a›*) ‹src a = Node (sourcenode ax)› (*‹src a = Node (sourcenode ax)›*) have False by simp thus "?case" (*goal: ‹∃Qx fx. knd e = Qx↩⇘p⇙fx›*) by simp next (*goals: 1. ‹⋀e. ⟦e = (Node Exit, (λs. True)⇩√, NewExit); src e = src a⟧ ⟹ ∃Qx fx. knd e = Qx↩⇘p⇙fx› 2. ‹⋀e. ⟦e = (NewEntry, (λs. False)⇩√, NewExit); src e = src a⟧ ⟹ ∃Qx fx. knd e = Qx↩⇘p⇙fx›*) case (lve_Exit_edge e) (*‹e = (Node Exit, (λs. True)⇩√, NewExit)› ‹src e = src a›*) from ‹e = (Node Exit, (λs. True)⇩√, NewExit)› (*‹e = (Node Exit, (λs. True)⇩√, NewExit)›*) ‹src e = src a› (*‹src (e::'b::type LDCFG_node × ('c::type, 'd::type, 'e::type, 'f::type) edge_kind × 'b::type LDCFG_node) = src (a::'b::type LDCFG_node × ('c::type, 'd::type, 'e::type, 'f::type) edge_kind × 'b::type LDCFG_node)›*) ‹src a = Node (sourcenode ax)› (*‹src a = Node (sourcenode ax)›*) have "sourcenode ax = Exit" by simp with ‹valid_edge ax› (*‹valid_edge ax›*) have False by (rule Exit_source (*‹⟦valid_edge ?a; sourcenode ?a = Exit⟧ ⟹ False›*)) thus "?case" (*goal: ‹∃Qx fx. knd e = Qx↩⇘p⇙fx›*) by simp next (*goal: ‹⋀e. ⟦e = (NewEntry, (λs. False)⇩√, NewExit); src e = src a⟧ ⟹ ∃Qx fx. knd e = Qx↩⇘p⇙fx›*) case (lve_Entry_Exit_edge e) (*‹e = (NewEntry, (λs. False)⇩√, NewExit)› ‹src e = src a›*) from ‹e = (NewEntry,(λs. False)⇩√,NewExit)› (*‹e = (NewEntry, (λs. False)⇩√, NewExit)›*) ‹src e = src a› (*‹src e = src a›*) ‹src a = Node (sourcenode ax)› (*‹src a = Node (sourcenode ax)›*) have False by simp thus "?case" (*goal: ‹∃Qx fx. knd e = Qx↩⇘p⇙fx›*) by simp qed } thus "∀a'. lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a' ∧ src a' = src a ⟶ (∃Qx fx. knd a' = Qx↩⇘p⇙fx)" by simp next (*goals: 1. ‹⋀a Q r p fs. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q:r↪⇘p⇙fs⟧ ⟹ lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind a ≠ {}› 2. ‹⋀a a'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; a' ∈ lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind a⟧ ⟹ lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a'› 3. ‹⋀a a'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; a' ∈ lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind a⟧ ⟹ ∃Q r p fs. knd a = Q:r↪⇘p⇙fs› 4. ‹⋀a Q r p fs a'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q:r↪⇘p⇙fs; a' ∈ lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind a⟧ ⟹ ∃Q' f'. knd a' = Q'↩⇘p⇙f'› 5. ‹⋀a Q' p f'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q'↩⇘p⇙f'⟧ ⟹ ∃!a'. lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a' ∧ (∃Q r fs. knd a' = Q:r↪⇘p⇙fs) ∧ a ∈ lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind a'› 6. ‹⋀a a'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; a' ∈ lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind a⟧ ⟹ ∃a''. lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a'' ∧ src a'' = trg a ∧ trg a'' = src a' ∧ knd a'' = (λcf. False)⇩√› 7. ‹⋀a a'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; a' ∈ lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind a⟧ ⟹ ∃a''. lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a'' ∧ src a'' = src a ∧ trg a'' = trg a' ∧ knd a'' = (λcf. False)⇩√› 8. ‹⋀a Q r p fs. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q:r↪⇘p⇙fs⟧ ⟹ ∃!a'. lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a' ∧ src a' = src a ∧ intra_kind (knd a')› 9. ‹⋀a Q' p f'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q'↩⇘p⇙f'⟧ ⟹ ∃!a'. lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a' ∧ trg a' = trg a ∧ intra_kind (knd a')› 10. ‹⋀a a' Q₁ r₁ p fs₁ Q₂ r₂ fs₂. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a'; knd a = Q₁:r₁↪⇘p⇙fs₁; knd a' = Q₂:r₂↪⇘p⇙fs₂⟧ ⟹ trg a = trg a'› 11. ‹distinct_fst procs› 12. ‹⋀p ins outs. (p, ins, outs) ∈ set procs ⟹ distinct ins› 13. ‹⋀p ins outs. (p, ins, outs) ∈ set procs ⟹ distinct outs›*) fix a and Q and r and p and fs assume "lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a" and "knd a = Q:r↪⇘p⇙fs" (*‹lift_valid_edge (valid_edge::'a ⇒ bool) (sourcenode::'a ⇒ 'b) (targetnode::'a ⇒ 'b) (kind::'a ⇒ ('c, 'd, 'e, 'f) edge_kind) (Entry::'b) (Exit::'b) (a::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node)› ‹knd (a::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node) = Q::('c ⇒ 'd option) × 'e ⇒ bool:r::'e↪⇘p::'f⇙fs::(('c ⇒ 'd option) ⇒ 'd option) list›*) thus "lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind a ≠ {}" proof (induct rule:lift_valid_edge.induct (*‹⟦lift_valid_edge ?valid_edge ?src ?trg ?knd ?E ?X ?x; ⋀a e. ⟦?valid_edge a; ?src a ≠ ?E ∨ ?trg a ≠ ?X; e = (Node (?src a), ?knd a, Node (?trg a))⟧ ⟹ ?P e; ⋀e. e = (NewEntry, (λs. True)⇩√, Node ?E) ⟹ ?P e; ⋀e. e = (Node ?X, (λs. True)⇩√, NewExit) ⟹ ?P e; ⋀e. e = (NewEntry, (λs. False)⇩√, NewExit) ⟹ ?P e⟧ ⟹ ?P ?x›*)) (*goals: 1. ‹⋀a e. ⟦valid_edge a; sourcenode a ≠ Entry ∨ targetnode a ≠ Exit; e = (Node (sourcenode a), kind a, Node (targetnode a)); knd e = Q:r↪⇘p⇙fs⟧ ⟹ lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind e ≠ {}› 2. ‹⋀e. ⟦e = (NewEntry, (λs. True)⇩√, Node Entry); knd e = Q:r↪⇘p⇙fs⟧ ⟹ lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind e ≠ {}› 3. ‹⋀e. ⟦e = (Node Exit, (λs. True)⇩√, NewExit); knd e = Q:r↪⇘p⇙fs⟧ ⟹ lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind e ≠ {}› 4. ‹⋀e. ⟦e = (NewEntry, (λs. False)⇩√, NewExit); knd e = Q:r↪⇘p⇙fs⟧ ⟹ lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind e ≠ {}›*) case (lve_edge ax e) (*‹valid_edge ax› ‹sourcenode ax ≠ Entry ∨ targetnode ax ≠ Exit› ‹e = (Node (sourcenode ax), kind ax, Node (targetnode ax))› ‹knd e = Q:r↪⇘p⇙fs›*) from ‹e = (Node (sourcenode ax), kind ax, Node (targetnode ax))› (*‹e = (Node (sourcenode ax), kind ax, Node (targetnode ax))›*) ‹knd e = Q:r↪⇘p⇙fs› (*‹knd e = Q:r↪⇘p⇙fs›*) have "kind ax = Q:r↪⇘p⇙fs" by simp with ‹valid_edge ax› (*‹(valid_edge::'a::type ⇒ bool) (ax::'a::type)›*) have "get_return_edges ax ≠ {}" by (rule get_return_edge_call (*‹⟦valid_edge ?a; kind ?a = ?Q:?r↪⇘?p⇙?fs⟧ ⟹ get_return_edges ?a ≠ {}›*)) then obtain ax' where "ax' ∈ get_return_edges ax" (*goal: ‹(⋀ax'. ax' ∈ get_return_edges ax ⟹ thesis) ⟹ thesis›*) by blast with ‹e = (Node (sourcenode ax), kind ax, Node (targetnode ax))› (*‹e = (Node (sourcenode ax), kind ax, Node (targetnode ax))›*) ‹valid_edge ax› (*‹(valid_edge::'a::type ⇒ bool) (ax::'a::type)›*) have "(Node (sourcenode ax'),kind ax',Node (targetnode ax')) ∈ lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind e" by (fastforce intro:lift_get_return_edgesI (*‹⟦?e = (Node (?src ?a), ?knd ?a, Node (?trg ?a)); ?valid_edge ?a; ?a' ∈ ?get_return_edges ?a; ?e' = (Node (?src ?a'), ?knd ?a', Node (?trg ?a'))⟧ ⟹ ?e' ∈ lift_get_return_edges ?get_return_edges ?valid_edge ?src ?trg ?knd ?e›*)) thus "?case" (*goal: ‹lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind e ≠ {}›*) by fastforce qed (simp_all) (*solves the remaining goals: 1. ‹⋀e. ⟦e = (NewEntry, (λs. True)⇩√, Node Entry); knd e = Q:r↪⇘p⇙fs⟧ ⟹ lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind e ≠ {}› 2. ‹⋀e. ⟦e = (Node Exit, (λs. True)⇩√, NewExit); knd e = Q:r↪⇘p⇙fs⟧ ⟹ lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind e ≠ {}› 3. ‹⋀e. ⟦e = (NewEntry, (λs. False)⇩√, NewExit); knd e = Q:r↪⇘p⇙fs⟧ ⟹ lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind e ≠ {}›*) next (*goals: 1. ‹⋀a a'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; a' ∈ lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind a⟧ ⟹ lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a'› 2. ‹⋀a a'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; a' ∈ lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind a⟧ ⟹ ∃Q r p fs. knd a = Q:r↪⇘p⇙fs› 3. ‹⋀a Q r p fs a'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q:r↪⇘p⇙fs; a' ∈ lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind a⟧ ⟹ ∃Q' f'. knd a' = Q'↩⇘p⇙f'› 4. ‹⋀a Q' p f'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q'↩⇘p⇙f'⟧ ⟹ ∃!a'. lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a' ∧ (∃Q r fs. knd a' = Q:r↪⇘p⇙fs) ∧ a ∈ lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind a'› 5. ‹⋀a a'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; a' ∈ lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind a⟧ ⟹ ∃a''. lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a'' ∧ src a'' = trg a ∧ trg a'' = src a' ∧ knd a'' = (λcf. False)⇩√› 6. ‹⋀a a'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; a' ∈ lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind a⟧ ⟹ ∃a''. lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a'' ∧ src a'' = src a ∧ trg a'' = trg a' ∧ knd a'' = (λcf. False)⇩√› 7. ‹⋀a Q r p fs. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q:r↪⇘p⇙fs⟧ ⟹ ∃!a'. lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a' ∧ src a' = src a ∧ intra_kind (knd a')› 8. ‹⋀a Q' p f'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q'↩⇘p⇙f'⟧ ⟹ ∃!a'. lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a' ∧ trg a' = trg a ∧ intra_kind (knd a')› 9. ‹⋀a a' Q₁ r₁ p fs₁ Q₂ r₂ fs₂. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a'; knd a = Q₁:r₁↪⇘p⇙fs₁; knd a' = Q₂:r₂↪⇘p⇙fs₂⟧ ⟹ trg a = trg a'› 10. ‹distinct_fst procs› 11. ‹⋀p ins outs. (p, ins, outs) ∈ set procs ⟹ distinct ins› 12. ‹⋀p ins outs. (p, ins, outs) ∈ set procs ⟹ distinct outs›*) fix a and a' assume "a' ∈ lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind a" and "lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a" (*‹(a'::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node) ∈ lift_get_return_edges (get_return_edges::'a ⇒ 'a set) (valid_edge::'a ⇒ bool) (sourcenode::'a ⇒ 'b) (targetnode::'a ⇒ 'b) (kind::'a ⇒ ('c, 'd, 'e, 'f) edge_kind) (a::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node)› ‹lift_valid_edge (valid_edge::'a ⇒ bool) (sourcenode::'a ⇒ 'b) (targetnode::'a ⇒ 'b) (kind::'a ⇒ ('c, 'd, 'e, 'f) edge_kind) (Entry::'b) (Exit::'b) (a::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node)›*) thus "lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a'" proof (induct rule:lift_get_return_edges.induct (*‹⟦(?x::?'node LDCFG_node × (?'var, ?'val, ?'ret, ?'pname) edge_kind × ?'node LDCFG_node) ∈ lift_get_return_edges (?get_return_edges::?'edge ⇒ ?'edge set) (?valid_edge::?'edge ⇒ bool) (?src::?'edge ⇒ ?'node) (?trg::?'edge ⇒ ?'node) (?knd::?'edge ⇒ (?'var, ?'val, ?'ret, ?'pname) edge_kind) (?e::?'node LDCFG_node × (?'var, ?'val, ?'ret, ?'pname) edge_kind × ?'node LDCFG_node); ⋀(a::?'edge) (a'::?'edge) e'::?'node LDCFG_node × (?'var, ?'val, ?'ret, ?'pname) edge_kind × ?'node LDCFG_node. ⟦?e = (Node (?src a), ?knd a, Node (?trg a)); ?valid_edge a; a' ∈ ?get_return_edges a; e' = (Node (?src a'), ?knd a', Node (?trg a'))⟧ ⟹ (?P::?'node LDCFG_node × (?'var, ?'val, ?'ret, ?'pname) edge_kind × ?'node LDCFG_node ⇒ bool) e'⟧ ⟹ ?P ?x›*)) (*goal: ‹⋀aa a' e'. ⟦a = (Node (sourcenode aa), kind aa, Node (targetnode aa)); valid_edge aa; a' ∈ get_return_edges aa; e' = (Node (sourcenode a'), kind a', Node (targetnode a')); lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a⟧ ⟹ lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit e'›*) case (lift_get_return_edgesI ax a' e') (*‹a = (Node (sourcenode ax), kind ax, Node (targetnode ax))› ‹valid_edge ax› ‹a' ∈ get_return_edges ax› ‹(e'::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node) = (Node ((sourcenode::'a ⇒ 'b) (a'::'a)), (kind::'a ⇒ ('c, 'd, 'e, 'f) edge_kind) a', Node ((targetnode::'a ⇒ 'b) a'))› ‹lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a›*) from ‹valid_edge ax› (*‹valid_edge ax›*) ‹a' ∈ get_return_edges ax› (*‹a' ∈ get_return_edges ax›*) have "valid_edge a'" by (rule get_return_edges_valid (*‹⟦(valid_edge::'a::type ⇒ bool) (?a::'a::type); (?a'::'a::type) ∈ (get_return_edges::'a::type ⇒ 'a::type set) ?a⟧ ⟹ valid_edge ?a'›*)) from ‹valid_edge ax› (*‹valid_edge ax›*) ‹a' ∈ get_return_edges ax› (*‹(a'::'a) ∈ (get_return_edges::'a ⇒ 'a set) (ax::'a)›*) obtain Q and r and p and fs where "kind ax = Q:r↪⇘p⇙fs" (*goal: ‹(⋀Q r p fs. kind ax = Q:r↪⇘p⇙fs ⟹ thesis) ⟹ thesis›*) by (fastforce dest!:only_call_get_return_edges (*‹⟦valid_edge ?a; ?a' ∈ get_return_edges ?a⟧ ⟹ ∃Q r p fs. kind ?a = Q:r↪⇘p⇙fs›*)) with ‹valid_edge ax› (*‹valid_edge ax›*) ‹a' ∈ get_return_edges ax› (*‹a' ∈ get_return_edges ax›*) obtain Q' and f' where "kind a' = Q'↩⇘p⇙f'" (*goal: ‹(⋀Q' f'. kind a' = Q'↩⇘p⇙f' ⟹ thesis) ⟹ thesis›*) by (fastforce dest!:call_return_edges (*‹⟦valid_edge ?a; kind ?a = ?Q:?r↪⇘?p⇙?fs; ?a' ∈ get_return_edges ?a⟧ ⟹ ∃Q' f'. kind ?a' = Q'↩⇘?p⇙f'›*)) from ‹valid_edge a'› (*‹valid_edge a'›*) ‹kind a' = Q'↩⇘p⇙f'› (*‹kind a' = Q'↩⇘p⇙f'›*) have "get_proc(sourcenode a') = p" by (rule get_proc_return (*‹⟦valid_edge ?a; kind ?a = ?Q'↩⇘?p⇙?f'⟧ ⟹ get_proc (sourcenode ?a) = ?p›*)) have "sourcenode a' ≠ Entry" proof (standard) (*goal: ‹sourcenode a' = Entry ⟹ False›*) assume "sourcenode a' = Entry" (*‹(sourcenode::'a ⇒ 'b) (a'::'a) = (Entry::'b)›*) with get_proc_Entry (*‹get_proc Entry = Main›*) ‹get_proc(sourcenode a') = p› (*‹(get_proc::'b::type ⇒ 'f::type) ((sourcenode::'a::type ⇒ 'b::type) (a'::'a::type)) = (p::'f::type)›*) have "p = Main" by simp with ‹kind a' = Q'↩⇘p⇙f'› (*‹kind a' = Q'↩⇘p⇙f'›*) have "kind a' = Q'↩⇘Main⇙f'" by simp with ‹valid_edge a'› (*‹valid_edge a'›*) show False by (rule Main_no_return_source (*‹⟦valid_edge ?a; kind ?a = ?Q'↩⇘Main⇙?f'⟧ ⟹ False›*)) qed with ‹e' = (Node (sourcenode a'), kind a', Node (targetnode a'))› (*‹(e'::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node) = (Node ((sourcenode::'a ⇒ 'b) (a'::'a)), (kind::'a ⇒ ('c, 'd, 'e, 'f) edge_kind) a', Node ((targetnode::'a ⇒ 'b) a'))›*) ‹valid_edge a'› (*‹valid_edge a'›*) show "?case" (*goal: ‹lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit e'›*) by (fastforce intro:lve_edge (*‹⟦?valid_edge ?a; ?src ?a ≠ ?E ∨ ?trg ?a ≠ ?X; ?e = (Node (?src ?a), ?knd ?a, Node (?trg ?a))⟧ ⟹ lift_valid_edge ?valid_edge ?src ?trg ?knd ?E ?X ?e›*)) qed next (*goals: 1. ‹⋀a a'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; a' ∈ lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind a⟧ ⟹ ∃Q r p fs. knd a = Q:r↪⇘p⇙fs› 2. ‹⋀a Q r p fs a'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q:r↪⇘p⇙fs; a' ∈ lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind a⟧ ⟹ ∃Q' f'. knd a' = Q'↩⇘p⇙f'› 3. ‹⋀a Q' p f'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q'↩⇘p⇙f'⟧ ⟹ ∃!a'. lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a' ∧ (∃Q r fs. knd a' = Q:r↪⇘p⇙fs) ∧ a ∈ lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind a'› 4. ‹⋀a a'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; a' ∈ lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind a⟧ ⟹ ∃a''. lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a'' ∧ src a'' = trg a ∧ trg a'' = src a' ∧ knd a'' = (λcf. False)⇩√› 5. ‹⋀a a'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; a' ∈ lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind a⟧ ⟹ ∃a''. lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a'' ∧ src a'' = src a ∧ trg a'' = trg a' ∧ knd a'' = (λcf. False)⇩√› 6. ‹⋀a Q r p fs. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q:r↪⇘p⇙fs⟧ ⟹ ∃!a'. lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a' ∧ src a' = src a ∧ intra_kind (knd a')› 7. ‹⋀a Q' p f'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q'↩⇘p⇙f'⟧ ⟹ ∃!a'. lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a' ∧ trg a' = trg a ∧ intra_kind (knd a')› 8. ‹⋀a a' Q₁ r₁ p fs₁ Q₂ r₂ fs₂. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a'; knd a = Q₁:r₁↪⇘p⇙fs₁; knd a' = Q₂:r₂↪⇘p⇙fs₂⟧ ⟹ trg a = trg a'› 9. ‹distinct_fst procs› 10. ‹⋀p ins outs. (p, ins, outs) ∈ set procs ⟹ distinct ins› 11. ‹⋀p ins outs. (p, ins, outs) ∈ set procs ⟹ distinct outs›*) fix a and a' assume "a' ∈ lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind a" and "lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a" (*‹(a'::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node) ∈ lift_get_return_edges (get_return_edges::'a ⇒ 'a set) (valid_edge::'a ⇒ bool) (sourcenode::'a ⇒ 'b) (targetnode::'a ⇒ 'b) (kind::'a ⇒ ('c, 'd, 'e, 'f) edge_kind) (a::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node)› ‹lift_valid_edge (valid_edge::'a ⇒ bool) (sourcenode::'a ⇒ 'b) (targetnode::'a ⇒ 'b) (kind::'a ⇒ ('c, 'd, 'e, 'f) edge_kind) (Entry::'b) (Exit::'b) (a::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node)›*) thus "∃Q r p fs. knd a = Q:r↪⇘p⇙fs" proof (induct rule:lift_get_return_edges.induct (*‹⟦?x ∈ lift_get_return_edges ?get_return_edges ?valid_edge ?src ?trg ?knd ?e; ⋀a a' e'. ⟦?e = (Node (?src a), ?knd a, Node (?trg a)); ?valid_edge a; a' ∈ ?get_return_edges a; e' = (Node (?src a'), ?knd a', Node (?trg a'))⟧ ⟹ ?P e'⟧ ⟹ ?P ?x›*)) (*goal: ‹⋀aa a' e'. ⟦a = (Node (sourcenode aa), kind aa, Node (targetnode aa)); valid_edge aa; a' ∈ get_return_edges aa; e' = (Node (sourcenode a'), kind a', Node (targetnode a')); lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a⟧ ⟹ ∃Q r p fs. knd a = Q:r↪⇘p⇙fs›*) case (lift_get_return_edgesI ax a' e') (*‹(a::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node) = (Node ((sourcenode::'a ⇒ 'b) (ax::'a)), (kind::'a ⇒ ('c, 'd, 'e, 'f) edge_kind) ax, Node ((targetnode::'a ⇒ 'b) ax))› ‹(valid_edge::'a::type ⇒ bool) (ax::'a::type)› ‹(a'::'a) ∈ (get_return_edges::'a ⇒ 'a set) (ax::'a)› ‹e' = (Node (sourcenode a'), kind a', Node (targetnode a'))› ‹lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a›*) from ‹valid_edge ax› (*‹valid_edge ax›*) ‹a' ∈ get_return_edges ax› (*‹a' ∈ get_return_edges ax›*) have "∃Q r p fs. kind ax = Q:r↪⇘p⇙fs" by (rule only_call_get_return_edges (*‹⟦valid_edge ?a; ?a' ∈ get_return_edges ?a⟧ ⟹ ∃Q r p fs. kind ?a = Q:r↪⇘p⇙fs›*)) with ‹a = (Node (sourcenode ax), kind ax, Node (targetnode ax))› (*‹a = (Node (sourcenode ax), kind ax, Node (targetnode ax))›*) show "?case" (*goal: ‹∃Q r p fs. knd a = Q:r↪⇘p⇙fs›*) by simp qed next (*goals: 1. ‹⋀a Q r p fs a'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q:r↪⇘p⇙fs; a' ∈ lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind a⟧ ⟹ ∃Q' f'. knd a' = Q'↩⇘p⇙f'› 2. ‹⋀a Q' p f'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q'↩⇘p⇙f'⟧ ⟹ ∃!a'. lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a' ∧ (∃Q r fs. knd a' = Q:r↪⇘p⇙fs) ∧ a ∈ lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind a'› 3. ‹⋀a a'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; a' ∈ lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind a⟧ ⟹ ∃a''. lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a'' ∧ src a'' = trg a ∧ trg a'' = src a' ∧ knd a'' = (λcf. False)⇩√› 4. ‹⋀a a'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; a' ∈ lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind a⟧ ⟹ ∃a''. lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a'' ∧ src a'' = src a ∧ trg a'' = trg a' ∧ knd a'' = (λcf. False)⇩√› 5. ‹⋀a Q r p fs. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q:r↪⇘p⇙fs⟧ ⟹ ∃!a'. lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a' ∧ src a' = src a ∧ intra_kind (knd a')› 6. ‹⋀a Q' p f'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q'↩⇘p⇙f'⟧ ⟹ ∃!a'. lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a' ∧ trg a' = trg a ∧ intra_kind (knd a')› 7. ‹⋀a a' Q₁ r₁ p fs₁ Q₂ r₂ fs₂. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a'; knd a = Q₁:r₁↪⇘p⇙fs₁; knd a' = Q₂:r₂↪⇘p⇙fs₂⟧ ⟹ trg a = trg a'› 8. ‹distinct_fst procs› 9. ‹⋀p ins outs. (p, ins, outs) ∈ set procs ⟹ distinct ins› 10. ‹⋀p ins outs. (p, ins, outs) ∈ set procs ⟹ distinct outs›*) fix a and Q and r and p and fs and a' assume "a' ∈ lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind a" and "knd a = Q:r↪⇘p⇙fs" and "lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a" (*‹(a'::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node) ∈ lift_get_return_edges (get_return_edges::'a ⇒ 'a set) (valid_edge::'a ⇒ bool) (sourcenode::'a ⇒ 'b) (targetnode::'a ⇒ 'b) (kind::'a ⇒ ('c, 'd, 'e, 'f) edge_kind) (a::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node)› ‹knd (a::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node) = Q::('c ⇒ 'd option) × 'e ⇒ bool:r::'e↪⇘p::'f⇙fs::(('c ⇒ 'd option) ⇒ 'd option) list› ‹lift_valid_edge (valid_edge::'a ⇒ bool) (sourcenode::'a ⇒ 'b) (targetnode::'a ⇒ 'b) (kind::'a ⇒ ('c, 'd, 'e, 'f) edge_kind) (Entry::'b) (Exit::'b) (a::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node)›*) thus "∃Q' f'. knd a' = Q'↩⇘p⇙f'" proof (induct rule:lift_get_return_edges.induct (*‹⟦(?x::?'node LDCFG_node × (?'var, ?'val, ?'ret, ?'pname) edge_kind × ?'node LDCFG_node) ∈ lift_get_return_edges (?get_return_edges::?'edge ⇒ ?'edge set) (?valid_edge::?'edge ⇒ bool) (?src::?'edge ⇒ ?'node) (?trg::?'edge ⇒ ?'node) (?knd::?'edge ⇒ (?'var, ?'val, ?'ret, ?'pname) edge_kind) (?e::?'node LDCFG_node × (?'var, ?'val, ?'ret, ?'pname) edge_kind × ?'node LDCFG_node); ⋀(a::?'edge) (a'::?'edge) e'::?'node LDCFG_node × (?'var, ?'val, ?'ret, ?'pname) edge_kind × ?'node LDCFG_node. ⟦?e = (Node (?src a), ?knd a, Node (?trg a)); ?valid_edge a; a' ∈ ?get_return_edges a; e' = (Node (?src a'), ?knd a', Node (?trg a'))⟧ ⟹ (?P::?'node LDCFG_node × (?'var, ?'val, ?'ret, ?'pname) edge_kind × ?'node LDCFG_node ⇒ bool) e'⟧ ⟹ ?P ?x›*)) (*goal: ‹⋀aa a' e'. ⟦a = (Node (sourcenode aa), kind aa, Node (targetnode aa)); valid_edge aa; a' ∈ get_return_edges aa; e' = (Node (sourcenode a'), kind a', Node (targetnode a')); knd a = Q:r↪⇘p⇙fs; lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a⟧ ⟹ ∃Q' f'. knd e' = Q'↩⇘p⇙f'›*) case (lift_get_return_edgesI ax a' e') (*‹a = (Node (sourcenode ax), kind ax, Node (targetnode ax))› ‹valid_edge ax› ‹a' ∈ get_return_edges ax› ‹e' = (Node (sourcenode a'), kind a', Node (targetnode a'))› ‹knd a = Q:r↪⇘p⇙fs› ‹lift_valid_edge (valid_edge::'a::type ⇒ bool) (sourcenode::'a::type ⇒ 'b::type) (targetnode::'a::type ⇒ 'b::type) (kind::'a::type ⇒ ('c::type, 'd::type, 'e::type, 'f::type) edge_kind) (Entry::'b::type) (Exit::'b::type) (a::'b::type LDCFG_node × ('c::type, 'd::type, 'e::type, 'f::type) edge_kind × 'b::type LDCFG_node)›*) from ‹a = (Node (sourcenode ax), kind ax, Node (targetnode ax))› (*‹a = (Node (sourcenode ax), kind ax, Node (targetnode ax))›*) ‹knd a = Q:r↪⇘p⇙fs› (*‹knd a = Q:r↪⇘p⇙fs›*) have "kind ax = Q:r↪⇘p⇙fs" by simp with ‹valid_edge ax› (*‹(valid_edge::'a ⇒ bool) (ax::'a)›*) ‹a' ∈ get_return_edges ax› (*‹a' ∈ get_return_edges ax›*) have "∃Q' f'. kind a' = Q'↩⇘p⇙f'" apply - (*goal: ‹∃Q' f'. kind a' = Q'↩⇘p⇙f'›*) apply (rule call_return_edges (*‹⟦valid_edge ?a; kind ?a = ?Q:?r↪⇘?p⇙?fs; ?a' ∈ get_return_edges ?a⟧ ⟹ ∃Q' f'. kind ?a' = Q'↩⇘?p⇙f'›*)) (*goals: 1. ‹⟦valid_edge ax; a' ∈ get_return_edges ax; kind ax = Q:r↪⇘p⇙fs⟧ ⟹ valid_edge ?a3› 2. ‹⟦valid_edge ax; a' ∈ get_return_edges ax; kind ax = Q:r↪⇘p⇙fs⟧ ⟹ kind ?a3 = ?Q3:?r3↪⇘p⇙?fs3› 3. ‹⟦valid_edge ax; a' ∈ get_return_edges ax; kind ax = Q:r↪⇘p⇙fs⟧ ⟹ a' ∈ get_return_edges ?a3› discuss goal 1*) apply ((assumption)[1]) (*discuss goal 2*) apply ((assumption)[1]) (*discuss goal 3*) . (*proven 3 subgoals*) with ‹e' = (Node (sourcenode a'), kind a', Node (targetnode a'))› (*‹(e'::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node) = (Node ((sourcenode::'a ⇒ 'b) (a'::'a)), (kind::'a ⇒ ('c, 'd, 'e, 'f) edge_kind) a', Node ((targetnode::'a ⇒ 'b) a'))›*) show "?case" (*goal: ‹∃Q' f'. knd e' = Q'↩⇘p⇙f'›*) by simp qed next (*goals: 1. ‹⋀(a::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node) (Q'::('c ⇒ 'd option) × 'e ⇒ bool) (p::'f) f'::('c ⇒ 'd option) ⇒ ('c ⇒ 'd option) ⇒ 'c ⇒ 'd option. ⟦lift_valid_edge (valid_edge::'a ⇒ bool) (sourcenode::'a ⇒ 'b) (targetnode::'a ⇒ 'b) (kind::'a ⇒ ('c, 'd, 'e, 'f) edge_kind) (Entry::'b) (Exit::'b) a; knd a = Q'↩⇘p⇙f'⟧ ⟹ ∃!a'::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node. lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a' ∧ (∃(Q::('c ⇒ 'd option) × 'e ⇒ bool) (r::'e) fs::(('c ⇒ 'd option) ⇒ 'd option) list. knd a' = Q:r↪⇘p⇙fs) ∧ a ∈ lift_get_return_edges (get_return_edges::'a ⇒ 'a set) valid_edge sourcenode targetnode kind a'› 2. ‹⋀(a::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node) a'::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node. ⟦lift_valid_edge (valid_edge::'a ⇒ bool) (sourcenode::'a ⇒ 'b) (targetnode::'a ⇒ 'b) (kind::'a ⇒ ('c, 'd, 'e, 'f) edge_kind) (Entry::'b) (Exit::'b) a; a' ∈ lift_get_return_edges (get_return_edges::'a ⇒ 'a set) valid_edge sourcenode targetnode kind a⟧ ⟹ ∃a''::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node. lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a'' ∧ src a'' = trg a ∧ trg a'' = src a' ∧ knd a'' = (λcf::'c ⇒ 'd option. False)⇩√› 3. ‹⋀(a::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node) a'::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node. ⟦lift_valid_edge (valid_edge::'a ⇒ bool) (sourcenode::'a ⇒ 'b) (targetnode::'a ⇒ 'b) (kind::'a ⇒ ('c, 'd, 'e, 'f) edge_kind) (Entry::'b) (Exit::'b) a; a' ∈ lift_get_return_edges (get_return_edges::'a ⇒ 'a set) valid_edge sourcenode targetnode kind a⟧ ⟹ ∃a''::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node. lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a'' ∧ src a'' = src a ∧ trg a'' = trg a' ∧ knd a'' = (λcf::'c ⇒ 'd option. False)⇩√› 4. ‹⋀(a::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node) (Q::('c ⇒ 'd option) × 'e ⇒ bool) (r::'e) (p::'f) fs::(('c ⇒ 'd option) ⇒ 'd option) list. ⟦lift_valid_edge (valid_edge::'a ⇒ bool) (sourcenode::'a ⇒ 'b) (targetnode::'a ⇒ 'b) (kind::'a ⇒ ('c, 'd, 'e, 'f) edge_kind) (Entry::'b) (Exit::'b) a; knd a = Q:r↪⇘p⇙fs⟧ ⟹ ∃!a'::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node. lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a' ∧ src a' = src a ∧ intra_kind (knd a')› 5. ‹⋀(a::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node) (Q'::('c ⇒ 'd option) × 'e ⇒ bool) (p::'f) f'::('c ⇒ 'd option) ⇒ ('c ⇒ 'd option) ⇒ 'c ⇒ 'd option. ⟦lift_valid_edge (valid_edge::'a ⇒ bool) (sourcenode::'a ⇒ 'b) (targetnode::'a ⇒ 'b) (kind::'a ⇒ ('c, 'd, 'e, 'f) edge_kind) (Entry::'b) (Exit::'b) a; knd a = Q'↩⇘p⇙f'⟧ ⟹ ∃!a'::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node. lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a' ∧ trg a' = trg a ∧ intra_kind (knd a')› 6. ‹⋀(a::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node) (a'::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node) (Q₁::('c ⇒ 'd option) × 'e ⇒ bool) (r₁::'e) (p::'f) (fs₁::(('c ⇒ 'd option) ⇒ 'd option) list) (Q₂::('c ⇒ 'd option) × 'e ⇒ bool) (r₂::'e) fs₂::(('c ⇒ 'd option) ⇒ 'd option) list. ⟦lift_valid_edge (valid_edge::'a ⇒ bool) (sourcenode::'a ⇒ 'b) (targetnode::'a ⇒ 'b) (kind::'a ⇒ ('c, 'd, 'e, 'f) edge_kind) (Entry::'b) (Exit::'b) a; lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a'; knd a = Q₁:r₁↪⇘p⇙fs₁; knd a' = Q₂:r₂↪⇘p⇙fs₂⟧ ⟹ trg a = trg a'› 7. ‹distinct_fst (procs::('f × 'c list × 'c list) list)› 8. ‹⋀(p::'f) (ins::'c list) outs::'c list. (p, ins, outs) ∈ set (procs::('f × 'c list × 'c list) list) ⟹ distinct ins› 9. ‹⋀(p::'f) (ins::'c list) outs::'c list. (p, ins, outs) ∈ set (procs::('f × 'c list × 'c list) list) ⟹ distinct outs›*) fix a and Q' and p and f' assume "lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a" and "knd a = Q'↩⇘p⇙f'" (*‹lift_valid_edge (valid_edge::'a ⇒ bool) (sourcenode::'a ⇒ 'b) (targetnode::'a ⇒ 'b) (kind::'a ⇒ ('c, 'd, 'e, 'f) edge_kind) (Entry::'b) (Exit::'b) (a::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node)› ‹knd (a::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node) = Q'::('c ⇒ 'd option) × 'e ⇒ bool↩⇘p::'f⇙f'::('c ⇒ 'd option) ⇒ ('c ⇒ 'd option) ⇒ 'c ⇒ 'd option›*) thus "∃!a'. lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a' ∧ (∃Q r fs. knd a' = Q:r↪⇘p⇙fs) ∧ a ∈ lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind a'" proof (induct rule:lift_valid_edge.induct (*‹⟦lift_valid_edge ?valid_edge ?src ?trg ?knd ?E ?X ?x; ⋀a e. ⟦?valid_edge a; ?src a ≠ ?E ∨ ?trg a ≠ ?X; e = (Node (?src a), ?knd a, Node (?trg a))⟧ ⟹ ?P e; ⋀e. e = (NewEntry, (λs. True)⇩√, Node ?E) ⟹ ?P e; ⋀e. e = (Node ?X, (λs. True)⇩√, NewExit) ⟹ ?P e; ⋀e. e = (NewEntry, (λs. False)⇩√, NewExit) ⟹ ?P e⟧ ⟹ ?P ?x›*)) (*goals: 1. ‹⋀(a::'a) e::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node. ⟦(valid_edge::'a ⇒ bool) a; (sourcenode::'a ⇒ 'b) a ≠ (Entry::'b) ∨ (targetnode::'a ⇒ 'b) a ≠ (Exit::'b); e = (Node (sourcenode a), (kind::'a ⇒ ('c, 'd, 'e, 'f) edge_kind) a, Node (targetnode a)); knd e = Q'::('c ⇒ 'd option) × 'e ⇒ bool↩⇘p::'f⇙f'::('c ⇒ 'd option) ⇒ ('c ⇒ 'd option) ⇒ 'c ⇒ 'd option⟧ ⟹ ∃!a'::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node. lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a' ∧ (∃(Q::('c ⇒ 'd option) × 'e ⇒ bool) (r::'e) fs::(('c ⇒ 'd option) ⇒ 'd option) list. knd a' = Q:r↪⇘p⇙fs) ∧ e ∈ lift_get_return_edges (get_return_edges::'a ⇒ 'a set) valid_edge sourcenode targetnode kind a'› 2. ‹⋀e::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node. ⟦e = (NewEntry, (λs::'c ⇒ 'd option. True)⇩√, Node (Entry::'b)); knd e = Q'::('c ⇒ 'd option) × 'e ⇒ bool↩⇘p::'f⇙f'::('c ⇒ 'd option) ⇒ ('c ⇒ 'd option) ⇒ 'c ⇒ 'd option⟧ ⟹ ∃!a'::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node. lift_valid_edge (valid_edge::'a ⇒ bool) (sourcenode::'a ⇒ 'b) (targetnode::'a ⇒ 'b) (kind::'a ⇒ ('c, 'd, 'e, 'f) edge_kind) Entry (Exit::'b) a' ∧ (∃(Q::('c ⇒ 'd option) × 'e ⇒ bool) (r::'e) fs::(('c ⇒ 'd option) ⇒ 'd option) list. knd a' = Q:r↪⇘p⇙fs) ∧ e ∈ lift_get_return_edges (get_return_edges::'a ⇒ 'a set) valid_edge sourcenode targetnode kind a'› 3. ‹⋀e::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node. ⟦e = (Node (Exit::'b), (λs::'c ⇒ 'd option. True)⇩√, NewExit); knd e = Q'::('c ⇒ 'd option) × 'e ⇒ bool↩⇘p::'f⇙f'::('c ⇒ 'd option) ⇒ ('c ⇒ 'd option) ⇒ 'c ⇒ 'd option⟧ ⟹ ∃!a'::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node. lift_valid_edge (valid_edge::'a ⇒ bool) (sourcenode::'a ⇒ 'b) (targetnode::'a ⇒ 'b) (kind::'a ⇒ ('c, 'd, 'e, 'f) edge_kind) (Entry::'b) Exit a' ∧ (∃(Q::('c ⇒ 'd option) × 'e ⇒ bool) (r::'e) fs::(('c ⇒ 'd option) ⇒ 'd option) list. knd a' = Q:r↪⇘p⇙fs) ∧ e ∈ lift_get_return_edges (get_return_edges::'a ⇒ 'a set) valid_edge sourcenode targetnode kind a'› 4. ‹⋀e::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node. ⟦e = (NewEntry, (λs::'c ⇒ 'd option. False)⇩√, NewExit); knd e = Q'::('c ⇒ 'd option) × 'e ⇒ bool↩⇘p::'f⇙f'::('c ⇒ 'd option) ⇒ ('c ⇒ 'd option) ⇒ 'c ⇒ 'd option⟧ ⟹ ∃!a'::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node. lift_valid_edge (valid_edge::'a ⇒ bool) (sourcenode::'a ⇒ 'b) (targetnode::'a ⇒ 'b) (kind::'a ⇒ ('c, 'd, 'e, 'f) edge_kind) (Entry::'b) (Exit::'b) a' ∧ (∃(Q::('c ⇒ 'd option) × 'e ⇒ bool) (r::'e) fs::(('c ⇒ 'd option) ⇒ 'd option) list. knd a' = Q:r↪⇘p⇙fs) ∧ e ∈ lift_get_return_edges (get_return_edges::'a ⇒ 'a set) valid_edge sourcenode targetnode kind a'›*) case (lve_edge a e) (*‹valid_edge a› ‹sourcenode a ≠ Entry ∨ targetnode a ≠ Exit› ‹e = (Node (sourcenode a), kind a, Node (targetnode a))› ‹knd e = Q'↩⇘p⇙f'›*) from ‹e = (Node (sourcenode a), kind a, Node (targetnode a))› (*‹e = (Node (sourcenode a), kind a, Node (targetnode a))›*) ‹knd e = Q'↩⇘p⇙f'› (*‹knd e = Q'↩⇘p⇙f'›*) have "kind a = Q'↩⇘p⇙f'" by simp with ‹valid_edge a› (*‹(valid_edge::'a::type ⇒ bool) (a::'a::type)›*) have "∃!a'. valid_edge a' ∧ (∃Q r fs. kind a' = Q:r↪⇘p⇙fs) ∧ a ∈ get_return_edges a'" by (rule return_needs_call (*‹⟦valid_edge ?a; kind ?a = ?Q'↩⇘?p⇙?f'⟧ ⟹ ∃!a'. valid_edge a' ∧ (∃Q r fs. kind a' = Q:r↪⇘?p⇙fs) ∧ ?a ∈ get_return_edges a'›*)) then obtain a' and Q and r and fs where "valid_edge a'" and "kind a' = Q:r↪⇘p⇙fs" and "a ∈ get_return_edges a'" and imp: "∀x. valid_edge x ∧ (∃Q r fs. kind x = Q:r↪⇘p⇙fs) ∧ a ∈ get_return_edges x ⟶ x = a'" (*goal: ‹(⋀a' Q r fs. ⟦valid_edge a'; kind a' = Q:r↪⇘p⇙fs; a ∈ get_return_edges a'; ∀x. valid_edge x ∧ (∃Q r fs. kind x = Q:r↪⇘p⇙fs) ∧ a ∈ get_return_edges x ⟶ x = a'⟧ ⟹ thesis) ⟹ thesis›*) by (fastforce elim:ex1E (*‹⟦∃!x. ?P x; ⋀x. ⟦?P x; ∀y. ?P y ⟶ y = x⟧ ⟹ ?R⟧ ⟹ ?R›*)) let ?e' = "(Node (sourcenode a'),kind a',Node (targetnode a'))" have "sourcenode a' ≠ Entry" proof (standard) (*goal: ‹sourcenode a' = Entry ⟹ False›*) assume "sourcenode a' = Entry" (*‹(sourcenode::'a ⇒ 'b) (a'::'a) = (Entry::'b)›*) with ‹valid_edge a'› (*‹valid_edge a'›*) ‹kind a' = Q:r↪⇘p⇙fs› (*‹kind a' = Q:r↪⇘p⇙fs›*) show False by (rule Entry_no_call_source (*‹⟦(valid_edge::'a ⇒ bool) (?a::'a); (kind::'a ⇒ ('c, 'd, 'e, 'f) edge_kind) ?a = ?Q::('c ⇒ 'd option) × 'e ⇒ bool:?r::'e↪⇘?p::'f⇙?fs::(('c ⇒ 'd option) ⇒ 'd option) list; (sourcenode::'a ⇒ 'b) ?a = (Entry::'b)⟧ ⟹ False›*)) qed with ‹valid_edge a'› (*‹valid_edge a'›*) have "lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit ?e'" by (fastforce intro:lift_valid_edge.lve_edge (*‹⟦?valid_edge ?a; ?src ?a ≠ ?E ∨ ?trg ?a ≠ ?X; ?e = (Node (?src ?a), ?knd ?a, Node (?trg ?a))⟧ ⟹ lift_valid_edge ?valid_edge ?src ?trg ?knd ?E ?X ?e›*)) moreover from ‹kind a' = Q:r↪⇘p⇙fs› (*‹kind a' = Q:r↪⇘p⇙fs›*) have "knd ?e' = Q:r↪⇘p⇙fs" by simp moreover from ‹e = (Node (sourcenode a), kind a, Node (targetnode a))› (*‹e = (Node (sourcenode a), kind a, Node (targetnode a))›*) ‹valid_edge a'› (*‹valid_edge a'›*) ‹a ∈ get_return_edges a'› (*‹a ∈ get_return_edges a'›*) have "e ∈ lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind ?e'" by (fastforce intro:lift_get_return_edgesI (*‹⟦?e = (Node (?src ?a), ?knd ?a, Node (?trg ?a)); ?valid_edge ?a; ?a' ∈ ?get_return_edges ?a; ?e' = (Node (?src ?a'), ?knd ?a', Node (?trg ?a'))⟧ ⟹ ?e' ∈ lift_get_return_edges ?get_return_edges ?valid_edge ?src ?trg ?knd ?e›*)) moreover { fix x assume "lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit x" and "∃Q r fs. knd x = Q:r↪⇘p⇙fs" and "e ∈ lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind x" (*‹lift_valid_edge (valid_edge::'a ⇒ bool) (sourcenode::'a ⇒ 'b) (targetnode::'a ⇒ 'b) (kind::'a ⇒ ('c, 'd, 'e, 'f) edge_kind) (Entry::'b) (Exit::'b) (x::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node)› ‹∃(Q::('c ⇒ 'd option) × 'e ⇒ bool) (r::'e) fs::(('c ⇒ 'd option) ⇒ 'd option) list. knd (x::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node) = Q:r↪⇘p::'f⇙fs› ‹(e::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node) ∈ lift_get_return_edges (get_return_edges::'a ⇒ 'a set) (valid_edge::'a ⇒ bool) (sourcenode::'a ⇒ 'b) (targetnode::'a ⇒ 'b) (kind::'a ⇒ ('c, 'd, 'e, 'f) edge_kind) (x::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node)›*) from ‹lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit x› (*‹lift_valid_edge (valid_edge::'a ⇒ bool) (sourcenode::'a ⇒ 'b) (targetnode::'a ⇒ 'b) (kind::'a ⇒ ('c, 'd, 'e, 'f) edge_kind) (Entry::'b) (Exit::'b) (x::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node)›*) ‹∃Q r fs. knd x = Q:r↪⇘p⇙fs› (*‹∃Q r fs. knd x = Q:r↪⇘p⇙fs›*) obtain y where "valid_edge y" and "x = (Node (sourcenode y), kind y, Node (targetnode y))" (*goal: ‹(⋀y. ⟦valid_edge y; x = (Node (sourcenode y), kind y, Node (targetnode y))⟧ ⟹ thesis) ⟹ thesis›*) by (fastforce elim:lift_valid_edge.cases (*‹⟦lift_valid_edge ?valid_edge ?src ?trg ?knd ?E ?X ?a; ⋀a e. ⟦?a = e; ?valid_edge a; ?src a ≠ ?E ∨ ?trg a ≠ ?X; e = (Node (?src a), ?knd a, Node (?trg a))⟧ ⟹ ?P; ⋀e. ⟦?a = e; e = (NewEntry, (λs. True)⇩√, Node ?E)⟧ ⟹ ?P; ⋀e. ⟦?a = e; e = (Node ?X, (λs. True)⇩√, NewExit)⟧ ⟹ ?P; ⋀e. ⟦?a = e; e = (NewEntry, (λs. False)⇩√, NewExit)⟧ ⟹ ?P⟧ ⟹ ?P›*)) with ‹e ∈ lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind x› (*‹e ∈ lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind x›*) ‹valid_edge a› (*‹valid_edge a›*) ‹e = (Node (sourcenode a), kind a, Node (targetnode a))› (*‹e = (Node (sourcenode a), kind a, Node (targetnode a))›*) have "x = ?e'" proof (induct rule:lift_get_return_edges.induct (*‹⟦?x ∈ lift_get_return_edges ?get_return_edges ?valid_edge ?src ?trg ?knd ?e; ⋀a a' e'. ⟦?e = (Node (?src a), ?knd a, Node (?trg a)); ?valid_edge a; a' ∈ ?get_return_edges a; e' = (Node (?src a'), ?knd a', Node (?trg a'))⟧ ⟹ ?P e'⟧ ⟹ ?P ?x›*)) (*goal: ‹⋀(a::'a) (a'a::'a) e'::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node. ⟦(x::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node) = (Node ((sourcenode::'a ⇒ 'b) a), (kind::'a ⇒ ('c, 'd, 'e, 'f) edge_kind) a, Node ((targetnode::'a ⇒ 'b) a)); (valid_edge::'a ⇒ bool) a; a'a ∈ (get_return_edges::'a ⇒ 'a set) a; e' = (Node (sourcenode a'a), kind a'a, Node (targetnode a'a)); valid_edge (a::'a); e' = (Node (sourcenode a), kind a, Node (targetnode a)); valid_edge (y::'a); x = (Node (sourcenode y), kind y, Node (targetnode y))⟧ ⟹ x = (Node (sourcenode (a'::'a)), kind a', Node (targetnode a'))›*) case (lift_get_return_edgesI ax ax' e) (*‹x = (Node (sourcenode ax), kind ax, Node (targetnode ax))› ‹valid_edge ax› ‹ax' ∈ get_return_edges ax› ‹e = (Node (sourcenode ax'), kind ax', Node (targetnode ax'))› ‹valid_edge a› ‹e = (Node (sourcenode a), kind a, Node (targetnode a))› ‹valid_edge y› ‹(x::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node) = (Node ((sourcenode::'a ⇒ 'b) (y::'a)), (kind::'a ⇒ ('c, 'd, 'e, 'f) edge_kind) y, Node ((targetnode::'a ⇒ 'b) y))›*) from ‹valid_edge ax› (*‹(valid_edge::'a ⇒ bool) (ax::'a)›*) ‹ax' ∈ get_return_edges ax› (*‹(ax'::'a::type) ∈ (get_return_edges::'a::type ⇒ 'a::type set) (ax::'a::type)›*) have "valid_edge ax'" by (rule get_return_edges_valid (*‹⟦valid_edge ?a; ?a' ∈ get_return_edges ?a⟧ ⟹ valid_edge ?a'›*)) from ‹e = (Node (sourcenode ax'), kind ax', Node (targetnode ax'))› (*‹e = (Node (sourcenode ax'), kind ax', Node (targetnode ax'))›*) ‹e = (Node (sourcenode a), kind a, Node (targetnode a))› (*‹e = (Node (sourcenode a), kind a, Node (targetnode a))›*) have "sourcenode a = sourcenode ax'" and "targetnode a = targetnode ax'" apply - (*goals: 1. ‹⟦e = (Node (sourcenode ax'), kind ax', Node (targetnode ax')); e = (Node (sourcenode a), kind a, Node (targetnode a))⟧ ⟹ sourcenode a = sourcenode ax'› 2. ‹⟦e = (Node (sourcenode ax'), kind ax', Node (targetnode ax')); e = (Node (sourcenode a), kind a, Node (targetnode a))⟧ ⟹ targetnode a = targetnode ax'› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) . with ‹valid_edge a› (*‹valid_edge a›*) ‹valid_edge ax'› (*‹valid_edge ax'›*) have [simp]: "a = ax'" by (rule edge_det (*‹⟦valid_edge ?a; valid_edge ?a'; sourcenode ?a = sourcenode ?a'; targetnode ?a = targetnode ?a'⟧ ⟹ ?a = ?a'›*)) from ‹x = (Node (sourcenode ax), kind ax, Node (targetnode ax))› (*‹(x::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node) = (Node ((sourcenode::'a ⇒ 'b) (ax::'a)), (kind::'a ⇒ ('c, 'd, 'e, 'f) edge_kind) ax, Node ((targetnode::'a ⇒ 'b) ax))›*) ‹∃Q r fs. knd x = Q:r↪⇘p⇙fs› (*‹∃Q r fs. knd x = Q:r↪⇘p⇙fs›*) have "∃Q r fs. kind ax = Q:r↪⇘p⇙fs" by simp with ‹valid_edge ax› (*‹valid_edge ax›*) ‹ax' ∈ get_return_edges ax› (*‹(ax'::'a) ∈ (get_return_edges::'a ⇒ 'a set) (ax::'a)›*) imp (*‹∀x::'a::type. (valid_edge::'a::type ⇒ bool) x ∧ (∃(Q::('c::type ⇒ 'd::type option) × 'e::type ⇒ bool) (r::'e::type) fs::(('c::type ⇒ 'd::type option) ⇒ 'd::type option) list. (kind::'a::type ⇒ ('c::type, 'd::type, 'e::type, 'f::type) edge_kind) x = Q:r↪⇘p::'f::type⇙fs) ∧ (a::'a::type) ∈ (get_return_edges::'a::type ⇒ 'a::type set) x ⟶ x = (a'::'a::type)›*) have "ax = a'" by fastforce with ‹x = (Node (sourcenode ax), kind ax, Node (targetnode ax))› (*‹x = (Node (sourcenode ax), kind ax, Node (targetnode ax))›*) show "?thesis" (*goal: ‹(x::'b::type LDCFG_node × ('c::type, 'd::type, 'e::type, 'f::type) edge_kind × 'b::type LDCFG_node) = (Node ((sourcenode::'a::type ⇒ 'b::type) (a'::'a::type)), (kind::'a::type ⇒ ('c::type, 'd::type, 'e::type, 'f::type) edge_kind) a', Node ((targetnode::'a::type ⇒ 'b::type) a'))›*) by simp qed } ultimately show "?case" (*goal: ‹∃!a'. lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a' ∧ (∃Q r fs. knd a' = Q:r↪⇘p⇙fs) ∧ e ∈ lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind a'›*) by (blast intro:ex1I (*‹⟦?P ?a; ⋀x. ?P x ⟹ x = ?a⟧ ⟹ ∃!x. ?P x›*)) qed (simp_all) (*solves the remaining goals: 1. ‹⋀e. ⟦e = (NewEntry, (λs. True)⇩√, Node Entry); knd e = Q'↩⇘p⇙f'⟧ ⟹ ∃!a'. lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a' ∧ (∃Q r fs. knd a' = Q:r↪⇘p⇙fs) ∧ e ∈ lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind a'› 2. ‹⋀e. ⟦e = (Node Exit, (λs. True)⇩√, NewExit); knd e = Q'↩⇘p⇙f'⟧ ⟹ ∃!a'. lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a' ∧ (∃Q r fs. knd a' = Q:r↪⇘p⇙fs) ∧ e ∈ lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind a'› 3. ‹⋀e. ⟦e = (NewEntry, (λs. False)⇩√, NewExit); knd e = Q'↩⇘p⇙f'⟧ ⟹ ∃!a'. lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a' ∧ (∃Q r fs. knd a' = Q:r↪⇘p⇙fs) ∧ e ∈ lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind a'›*) next (*goals: 1. ‹⋀a a'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; a' ∈ lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind a⟧ ⟹ ∃a''. lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a'' ∧ src a'' = trg a ∧ trg a'' = src a' ∧ knd a'' = (λcf. False)⇩√› 2. ‹⋀a a'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; a' ∈ lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind a⟧ ⟹ ∃a''. lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a'' ∧ src a'' = src a ∧ trg a'' = trg a' ∧ knd a'' = (λcf. False)⇩√› 3. ‹⋀a Q r p fs. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q:r↪⇘p⇙fs⟧ ⟹ ∃!a'. lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a' ∧ src a' = src a ∧ intra_kind (knd a')› 4. ‹⋀a Q' p f'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q'↩⇘p⇙f'⟧ ⟹ ∃!a'. lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a' ∧ trg a' = trg a ∧ intra_kind (knd a')› 5. ‹⋀a a' Q₁ r₁ p fs₁ Q₂ r₂ fs₂. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a'; knd a = Q₁:r₁↪⇘p⇙fs₁; knd a' = Q₂:r₂↪⇘p⇙fs₂⟧ ⟹ trg a = trg a'› 6. ‹distinct_fst procs› 7. ‹⋀p ins outs. (p, ins, outs) ∈ set procs ⟹ distinct ins› 8. ‹⋀p ins outs. (p, ins, outs) ∈ set procs ⟹ distinct outs›*) fix a and a' assume "a' ∈ lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind a" and "lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a" (*‹(a'::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node) ∈ lift_get_return_edges (get_return_edges::'a ⇒ 'a set) (valid_edge::'a ⇒ bool) (sourcenode::'a ⇒ 'b) (targetnode::'a ⇒ 'b) (kind::'a ⇒ ('c, 'd, 'e, 'f) edge_kind) (a::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node)› ‹lift_valid_edge (valid_edge::'a ⇒ bool) (sourcenode::'a ⇒ 'b) (targetnode::'a ⇒ 'b) (kind::'a ⇒ ('c, 'd, 'e, 'f) edge_kind) (Entry::'b) (Exit::'b) (a::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node)›*) thus "∃a''. lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a'' ∧ src a'' = trg a ∧ trg a'' = src a' ∧ knd a'' = (λcf. False)⇩√" proof (induct rule:lift_get_return_edges.induct (*‹⟦(?x::?'node LDCFG_node × (?'var, ?'val, ?'ret, ?'pname) edge_kind × ?'node LDCFG_node) ∈ lift_get_return_edges (?get_return_edges::?'edge ⇒ ?'edge set) (?valid_edge::?'edge ⇒ bool) (?src::?'edge ⇒ ?'node) (?trg::?'edge ⇒ ?'node) (?knd::?'edge ⇒ (?'var, ?'val, ?'ret, ?'pname) edge_kind) (?e::?'node LDCFG_node × (?'var, ?'val, ?'ret, ?'pname) edge_kind × ?'node LDCFG_node); ⋀(a::?'edge) (a'::?'edge) e'::?'node LDCFG_node × (?'var, ?'val, ?'ret, ?'pname) edge_kind × ?'node LDCFG_node. ⟦?e = (Node (?src a), ?knd a, Node (?trg a)); ?valid_edge a; a' ∈ ?get_return_edges a; e' = (Node (?src a'), ?knd a', Node (?trg a'))⟧ ⟹ (?P::?'node LDCFG_node × (?'var, ?'val, ?'ret, ?'pname) edge_kind × ?'node LDCFG_node ⇒ bool) e'⟧ ⟹ ?P ?x›*)) (*goal: ‹⋀aa a' e'. ⟦a = (Node (sourcenode aa), kind aa, Node (targetnode aa)); valid_edge aa; a' ∈ get_return_edges aa; e' = (Node (sourcenode a'), kind a', Node (targetnode a')); lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a⟧ ⟹ ∃a''. lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a'' ∧ src a'' = trg a ∧ trg a'' = src e' ∧ knd a'' = (λcf. False)⇩√›*) case (lift_get_return_edgesI ax a' e') (*‹a = (Node (sourcenode ax), kind ax, Node (targetnode ax))› ‹valid_edge ax› ‹a' ∈ get_return_edges ax› ‹e' = (Node (sourcenode a'), kind a', Node (targetnode a'))› ‹lift_valid_edge (valid_edge::'a ⇒ bool) (sourcenode::'a ⇒ 'b) (targetnode::'a ⇒ 'b) (kind::'a ⇒ ('c, 'd, 'e, 'f) edge_kind) (Entry::'b) (Exit::'b) (a::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node)›*) from ‹valid_edge ax› (*‹valid_edge ax›*) ‹a' ∈ get_return_edges ax› (*‹(a'::'a) ∈ (get_return_edges::'a ⇒ 'a set) (ax::'a)›*) obtain ax' where "valid_edge ax'" and "sourcenode ax' = targetnode ax" and "targetnode ax' = sourcenode a'" and "kind ax' = (λcf. False)⇩√" (*goal: ‹(⋀ax'. ⟦valid_edge ax'; sourcenode ax' = targetnode ax; targetnode ax' = sourcenode a'; kind ax' = (λcf. False)⇩√⟧ ⟹ thesis) ⟹ thesis›*) by (fastforce dest:intra_proc_additional_edge (*‹⟦valid_edge ?a; ?a' ∈ get_return_edges ?a⟧ ⟹ ∃a''. valid_edge a'' ∧ sourcenode a'' = targetnode ?a ∧ targetnode a'' = sourcenode ?a' ∧ kind a'' = (λcf. False)⇩√›*)) let ?ex = "(Node (sourcenode ax'), kind ax', Node (targetnode ax'))" have "targetnode ax ≠ Entry" proof (standard) (*goal: ‹targetnode ax = Entry ⟹ False›*) assume "targetnode ax = Entry" (*‹(targetnode::'a ⇒ 'b) (ax::'a) = (Entry::'b)›*) with ‹valid_edge ax› (*‹valid_edge ax›*) show False by (rule Entry_target (*‹⟦valid_edge ?a; targetnode ?a = Entry⟧ ⟹ False›*)) qed with ‹sourcenode ax' = targetnode ax› (*‹(sourcenode::'a ⇒ 'b) (ax'::'a) = (targetnode::'a ⇒ 'b) (ax::'a)›*) have "sourcenode ax' ≠ Entry" by simp with ‹valid_edge ax'› (*‹valid_edge ax'›*) have "lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit ?ex" by (fastforce intro:lve_edge (*‹⟦?valid_edge ?a; ?src ?a ≠ ?E ∨ ?trg ?a ≠ ?X; ?e = (Node (?src ?a), ?knd ?a, Node (?trg ?a))⟧ ⟹ lift_valid_edge ?valid_edge ?src ?trg ?knd ?E ?X ?e›*)) with ‹e' = (Node (sourcenode a'), kind a', Node (targetnode a'))› (*‹e' = (Node (sourcenode a'), kind a', Node (targetnode a'))›*) ‹a = (Node (sourcenode ax), kind ax, Node (targetnode ax))› (*‹a = (Node (sourcenode ax), kind ax, Node (targetnode ax))›*) ‹e' = (Node (sourcenode a'), kind a', Node (targetnode a'))› (*‹e' = (Node (sourcenode a'), kind a', Node (targetnode a'))›*) ‹sourcenode ax' = targetnode ax› (*‹sourcenode ax' = targetnode ax›*) ‹targetnode ax' = sourcenode a'› (*‹targetnode ax' = sourcenode a'›*) ‹kind ax' = (λcf. False)⇩√› (*‹kind ax' = (λcf. False)⇩√›*) show "?case" (*goal: ‹∃a''. lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a'' ∧ src a'' = trg a ∧ trg a'' = src e' ∧ knd a'' = (λcf. False)⇩√›*) by simp qed next (*goals: 1. ‹⋀(a::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node) a'::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node. ⟦lift_valid_edge (valid_edge::'a ⇒ bool) (sourcenode::'a ⇒ 'b) (targetnode::'a ⇒ 'b) (kind::'a ⇒ ('c, 'd, 'e, 'f) edge_kind) (Entry::'b) (Exit::'b) a; a' ∈ lift_get_return_edges (get_return_edges::'a ⇒ 'a set) valid_edge sourcenode targetnode kind a⟧ ⟹ ∃a''::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node. lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a'' ∧ src a'' = src a ∧ trg a'' = trg a' ∧ knd a'' = (λcf::'c ⇒ 'd option. False)⇩√› 2. ‹⋀(a::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node) (Q::('c ⇒ 'd option) × 'e ⇒ bool) (r::'e) (p::'f) fs::(('c ⇒ 'd option) ⇒ 'd option) list. ⟦lift_valid_edge (valid_edge::'a ⇒ bool) (sourcenode::'a ⇒ 'b) (targetnode::'a ⇒ 'b) (kind::'a ⇒ ('c, 'd, 'e, 'f) edge_kind) (Entry::'b) (Exit::'b) a; knd a = Q:r↪⇘p⇙fs⟧ ⟹ ∃!a'::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node. lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a' ∧ src a' = src a ∧ intra_kind (knd a')› 3. ‹⋀(a::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node) (Q'::('c ⇒ 'd option) × 'e ⇒ bool) (p::'f) f'::('c ⇒ 'd option) ⇒ ('c ⇒ 'd option) ⇒ 'c ⇒ 'd option. ⟦lift_valid_edge (valid_edge::'a ⇒ bool) (sourcenode::'a ⇒ 'b) (targetnode::'a ⇒ 'b) (kind::'a ⇒ ('c, 'd, 'e, 'f) edge_kind) (Entry::'b) (Exit::'b) a; knd a = Q'↩⇘p⇙f'⟧ ⟹ ∃!a'::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node. lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a' ∧ trg a' = trg a ∧ intra_kind (knd a')› 4. ‹⋀(a::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node) (a'::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node) (Q₁::('c ⇒ 'd option) × 'e ⇒ bool) (r₁::'e) (p::'f) (fs₁::(('c ⇒ 'd option) ⇒ 'd option) list) (Q₂::('c ⇒ 'd option) × 'e ⇒ bool) (r₂::'e) fs₂::(('c ⇒ 'd option) ⇒ 'd option) list. ⟦lift_valid_edge (valid_edge::'a ⇒ bool) (sourcenode::'a ⇒ 'b) (targetnode::'a ⇒ 'b) (kind::'a ⇒ ('c, 'd, 'e, 'f) edge_kind) (Entry::'b) (Exit::'b) a; lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a'; knd a = Q₁:r₁↪⇘p⇙fs₁; knd a' = Q₂:r₂↪⇘p⇙fs₂⟧ ⟹ trg a = trg a'› 5. ‹distinct_fst (procs::('f × 'c list × 'c list) list)› 6. ‹⋀(p::'f) (ins::'c list) outs::'c list. (p, ins, outs) ∈ set (procs::('f × 'c list × 'c list) list) ⟹ distinct ins› 7. ‹⋀(p::'f) (ins::'c list) outs::'c list. (p, ins, outs) ∈ set (procs::('f × 'c list × 'c list) list) ⟹ distinct outs›*) fix a and a' assume "a' ∈ lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind a" and "lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a" (*‹(a'::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node) ∈ lift_get_return_edges (get_return_edges::'a ⇒ 'a set) (valid_edge::'a ⇒ bool) (sourcenode::'a ⇒ 'b) (targetnode::'a ⇒ 'b) (kind::'a ⇒ ('c, 'd, 'e, 'f) edge_kind) (a::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node)› ‹lift_valid_edge (valid_edge::'a ⇒ bool) (sourcenode::'a ⇒ 'b) (targetnode::'a ⇒ 'b) (kind::'a ⇒ ('c, 'd, 'e, 'f) edge_kind) (Entry::'b) (Exit::'b) (a::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node)›*) thus "∃a''. lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a'' ∧ src a'' = src a ∧ trg a'' = trg a' ∧ knd a'' = (λcf. False)⇩√" proof (induct rule:lift_get_return_edges.induct (*‹⟦?x ∈ lift_get_return_edges ?get_return_edges ?valid_edge ?src ?trg ?knd ?e; ⋀a a' e'. ⟦?e = (Node (?src a), ?knd a, Node (?trg a)); ?valid_edge a; a' ∈ ?get_return_edges a; e' = (Node (?src a'), ?knd a', Node (?trg a'))⟧ ⟹ ?P e'⟧ ⟹ ?P ?x›*)) (*goal: ‹⋀aa a' e'. ⟦a = (Node (sourcenode aa), kind aa, Node (targetnode aa)); valid_edge aa; a' ∈ get_return_edges aa; e' = (Node (sourcenode a'), kind a', Node (targetnode a')); lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a⟧ ⟹ ∃a''. lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a'' ∧ src a'' = src a ∧ trg a'' = trg e' ∧ knd a'' = (λcf. False)⇩√›*) case (lift_get_return_edgesI ax a' e') (*‹(a::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node) = (Node ((sourcenode::'a ⇒ 'b) (ax::'a)), (kind::'a ⇒ ('c, 'd, 'e, 'f) edge_kind) ax, Node ((targetnode::'a ⇒ 'b) ax))› ‹(valid_edge::'a::type ⇒ bool) (ax::'a::type)› ‹(a'::'a) ∈ (get_return_edges::'a ⇒ 'a set) (ax::'a)› ‹e' = (Node (sourcenode a'), kind a', Node (targetnode a'))› ‹lift_valid_edge (valid_edge::'a ⇒ bool) (sourcenode::'a ⇒ 'b) (targetnode::'a ⇒ 'b) (kind::'a ⇒ ('c, 'd, 'e, 'f) edge_kind) (Entry::'b) (Exit::'b) (a::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node)›*) from ‹valid_edge ax› (*‹valid_edge ax›*) ‹a' ∈ get_return_edges ax› (*‹a' ∈ get_return_edges ax›*) obtain ax' where "valid_edge ax'" and "sourcenode ax' = sourcenode ax" and "targetnode ax' = targetnode a'" and "kind ax' = (λcf. False)⇩√" (*goal: ‹(⋀ax'::'a. ⟦(valid_edge::'a ⇒ bool) ax'; (sourcenode::'a ⇒ 'b) ax' = sourcenode (ax::'a); (targetnode::'a ⇒ 'b) ax' = targetnode (a'::'a); (kind::'a ⇒ ('c, 'd, 'e, 'f) edge_kind) ax' = (λcf::'c ⇒ 'd option. False)⇩√⟧ ⟹ thesis::bool) ⟹ thesis›*) by (fastforce dest:call_return_node_edge (*‹⟦valid_edge ?a; ?a' ∈ get_return_edges ?a⟧ ⟹ ∃a''. valid_edge a'' ∧ sourcenode a'' = sourcenode ?a ∧ targetnode a'' = targetnode ?a' ∧ kind a'' = (λcf. False)⇩√›*)) let ?ex = "(Node (sourcenode ax'), kind ax', Node (targetnode ax'))" from ‹valid_edge ax› (*‹valid_edge ax›*) ‹a' ∈ get_return_edges ax› (*‹(a'::'a) ∈ (get_return_edges::'a ⇒ 'a set) (ax::'a)›*) obtain Q and r and p and fs where "kind ax = Q:r↪⇘p⇙fs" (*goal: ‹(⋀Q r p fs. kind ax = Q:r↪⇘p⇙fs ⟹ thesis) ⟹ thesis›*) by (fastforce dest!:only_call_get_return_edges (*‹⟦valid_edge ?a; ?a' ∈ get_return_edges ?a⟧ ⟹ ∃Q r p fs. kind ?a = Q:r↪⇘p⇙fs›*)) have "sourcenode ax ≠ Entry" proof (standard) (*goal: ‹sourcenode ax = Entry ⟹ False›*) assume "sourcenode ax = Entry" (*‹(sourcenode::'a ⇒ 'b) (ax::'a) = (Entry::'b)›*) with ‹valid_edge ax› (*‹valid_edge ax›*) ‹kind ax = Q:r↪⇘p⇙fs› (*‹kind ax = Q:r↪⇘p⇙fs›*) show False by (rule Entry_no_call_source (*‹⟦valid_edge ?a; kind ?a = ?Q:?r↪⇘?p⇙?fs; sourcenode ?a = Entry⟧ ⟹ False›*)) qed with ‹sourcenode ax' = sourcenode ax› (*‹sourcenode ax' = sourcenode ax›*) have "sourcenode ax' ≠ Entry" by simp with ‹valid_edge ax'› (*‹(valid_edge::'a ⇒ bool) (ax'::'a)›*) have "lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit ?ex" by (fastforce intro:lve_edge (*‹⟦?valid_edge ?a; ?src ?a ≠ ?E ∨ ?trg ?a ≠ ?X; ?e = (Node (?src ?a), ?knd ?a, Node (?trg ?a))⟧ ⟹ lift_valid_edge ?valid_edge ?src ?trg ?knd ?E ?X ?e›*)) with ‹e' = (Node (sourcenode a'), kind a', Node (targetnode a'))› (*‹(e'::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node) = (Node ((sourcenode::'a ⇒ 'b) (a'::'a)), (kind::'a ⇒ ('c, 'd, 'e, 'f) edge_kind) a', Node ((targetnode::'a ⇒ 'b) a'))›*) ‹a = (Node (sourcenode ax), kind ax, Node (targetnode ax))› (*‹a = (Node (sourcenode ax), kind ax, Node (targetnode ax))›*) ‹e' = (Node (sourcenode a'), kind a', Node (targetnode a'))› (*‹e' = (Node (sourcenode a'), kind a', Node (targetnode a'))›*) ‹sourcenode ax' = sourcenode ax› (*‹(sourcenode::'a ⇒ 'b) (ax'::'a) = sourcenode (ax::'a)›*) ‹targetnode ax' = targetnode a'› (*‹(targetnode::'a ⇒ 'b) (ax'::'a) = targetnode (a'::'a)›*) ‹kind ax' = (λcf. False)⇩√› (*‹kind ax' = (λcf. False)⇩√›*) show "?case" (*goal: ‹∃a''. lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a'' ∧ src a'' = src a ∧ trg a'' = trg e' ∧ knd a'' = (λcf. False)⇩√›*) by simp qed next (*goals: 1. ‹⋀a Q r p fs. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q:r↪⇘p⇙fs⟧ ⟹ ∃!a'. lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a' ∧ src a' = src a ∧ intra_kind (knd a')› 2. ‹⋀a Q' p f'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q'↩⇘p⇙f'⟧ ⟹ ∃!a'. lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a' ∧ trg a' = trg a ∧ intra_kind (knd a')› 3. ‹⋀a a' Q₁ r₁ p fs₁ Q₂ r₂ fs₂. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a'; knd a = Q₁:r₁↪⇘p⇙fs₁; knd a' = Q₂:r₂↪⇘p⇙fs₂⟧ ⟹ trg a = trg a'› 4. ‹distinct_fst procs› 5. ‹⋀p ins outs. (p, ins, outs) ∈ set procs ⟹ distinct ins› 6. ‹⋀p ins outs. (p, ins, outs) ∈ set procs ⟹ distinct outs›*) fix a and Q and r and p and fs assume "lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a" and "knd a = Q:r↪⇘p⇙fs" (*‹lift_valid_edge (valid_edge::'a ⇒ bool) (sourcenode::'a ⇒ 'b) (targetnode::'a ⇒ 'b) (kind::'a ⇒ ('c, 'd, 'e, 'f) edge_kind) (Entry::'b) (Exit::'b) (a::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node)› ‹knd (a::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node) = Q::('c ⇒ 'd option) × 'e ⇒ bool:r::'e↪⇘p::'f⇙fs::(('c ⇒ 'd option) ⇒ 'd option) list›*) thus "∃!a'. lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a' ∧ src a' = src a ∧ intra_kind (knd a')" proof (induct rule:lift_valid_edge.induct (*‹⟦lift_valid_edge ?valid_edge ?src ?trg ?knd ?E ?X ?x; ⋀a e. ⟦?valid_edge a; ?src a ≠ ?E ∨ ?trg a ≠ ?X; e = (Node (?src a), ?knd a, Node (?trg a))⟧ ⟹ ?P e; ⋀e. e = (NewEntry, (λs. True)⇩√, Node ?E) ⟹ ?P e; ⋀e. e = (Node ?X, (λs. True)⇩√, NewExit) ⟹ ?P e; ⋀e. e = (NewEntry, (λs. False)⇩√, NewExit) ⟹ ?P e⟧ ⟹ ?P ?x›*)) (*goals: 1. ‹⋀a e. ⟦valid_edge a; sourcenode a ≠ Entry ∨ targetnode a ≠ Exit; e = (Node (sourcenode a), kind a, Node (targetnode a)); knd e = Q:r↪⇘p⇙fs⟧ ⟹ ∃!a'. lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a' ∧ src a' = src e ∧ intra_kind (knd a')› 2. ‹⋀e. ⟦e = (NewEntry, (λs. True)⇩√, Node Entry); knd e = Q:r↪⇘p⇙fs⟧ ⟹ ∃!a'. lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a' ∧ src a' = src e ∧ intra_kind (knd a')› 3. ‹⋀e. ⟦e = (Node Exit, (λs. True)⇩√, NewExit); knd e = Q:r↪⇘p⇙fs⟧ ⟹ ∃!a'. lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a' ∧ src a' = src e ∧ intra_kind (knd a')› 4. ‹⋀e. ⟦e = (NewEntry, (λs. False)⇩√, NewExit); knd e = Q:r↪⇘p⇙fs⟧ ⟹ ∃!a'. lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a' ∧ src a' = src e ∧ intra_kind (knd a')›*) case (lve_edge a e) (*‹valid_edge a› ‹sourcenode a ≠ Entry ∨ targetnode a ≠ Exit› ‹(e::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node) = (Node ((sourcenode::'a ⇒ 'b) (a::'a)), (kind::'a ⇒ ('c, 'd, 'e, 'f) edge_kind) a, Node ((targetnode::'a ⇒ 'b) a))› ‹knd e = Q:r↪⇘p⇙fs›*) from ‹e = (Node (sourcenode a), kind a, Node (targetnode a))› (*‹e = (Node (sourcenode a), kind a, Node (targetnode a))›*) ‹knd e = Q:r↪⇘p⇙fs› (*‹knd e = Q:r↪⇘p⇙fs›*) have "kind a = Q:r↪⇘p⇙fs" by simp with ‹valid_edge a› (*‹valid_edge a›*) have "∃!a'. valid_edge a' ∧ sourcenode a' = sourcenode a ∧ intra_kind(kind a')" by (rule call_only_one_intra_edge (*‹⟦(valid_edge::'a ⇒ bool) (?a::'a); (kind::'a ⇒ ('c, 'd, 'e, 'f) edge_kind) ?a = ?Q::('c ⇒ 'd option) × 'e ⇒ bool:?r::'e↪⇘?p::'f⇙?fs::(('c ⇒ 'd option) ⇒ 'd option) list⟧ ⟹ ∃!a'::'a. valid_edge a' ∧ (sourcenode::'a ⇒ 'b) a' = sourcenode ?a ∧ intra_kind (kind a')›*)) then obtain a' where "valid_edge a'" and "sourcenode a' = sourcenode a" and "intra_kind(kind a')" and imp: "∀x. valid_edge x ∧ sourcenode x = sourcenode a ∧ intra_kind(kind x) ⟶ x = a'" (*goal: ‹(⋀a'::'a. ⟦(valid_edge::'a ⇒ bool) a'; (sourcenode::'a ⇒ 'b) a' = sourcenode (a::'a); intra_kind ((kind::'a ⇒ ('c, 'd, 'e, 'f) edge_kind) a'); ∀x::'a. valid_edge x ∧ sourcenode x = sourcenode a ∧ intra_kind (kind x) ⟶ x = a'⟧ ⟹ thesis::bool) ⟹ thesis›*) by (fastforce elim:ex1E (*‹⟦∃!x. ?P x; ⋀x. ⟦?P x; ∀y. ?P y ⟶ y = x⟧ ⟹ ?R⟧ ⟹ ?R›*)) let ?e' = "(Node (sourcenode a'), kind a', Node (targetnode a'))" have "sourcenode a ≠ Entry" proof (standard) (*goal: ‹(sourcenode::'a::type ⇒ 'b::type) (a::'a::type) = (Entry::'b::type) ⟹ False›*) assume "sourcenode a = Entry" (*‹(sourcenode::'a ⇒ 'b) (a::'a) = (Entry::'b)›*) with ‹valid_edge a› (*‹(valid_edge::'a ⇒ bool) (a::'a)›*) ‹kind a = Q:r↪⇘p⇙fs› (*‹kind a = Q:r↪⇘p⇙fs›*) show False by (rule Entry_no_call_source (*‹⟦valid_edge ?a; kind ?a = ?Q:?r↪⇘?p⇙?fs; sourcenode ?a = Entry⟧ ⟹ False›*)) qed with ‹sourcenode a' = sourcenode a› (*‹sourcenode a' = sourcenode a›*) have "sourcenode a' ≠ Entry" by simp with ‹valid_edge a'› (*‹valid_edge a'›*) have "lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit ?e'" by (fastforce intro:lift_valid_edge.lve_edge (*‹⟦?valid_edge ?a; ?src ?a ≠ ?E ∨ ?trg ?a ≠ ?X; ?e = (Node (?src ?a), ?knd ?a, Node (?trg ?a))⟧ ⟹ lift_valid_edge ?valid_edge ?src ?trg ?knd ?E ?X ?e›*)) moreover from ‹e = (Node (sourcenode a), kind a, Node (targetnode a))› (*‹e = (Node (sourcenode a), kind a, Node (targetnode a))›*) ‹sourcenode a' = sourcenode a› (*‹sourcenode a' = sourcenode a›*) have "src ?e' = src e" by simp moreover from ‹intra_kind(kind a')› (*‹intra_kind (kind a')›*) have "intra_kind (knd ?e')" by simp moreover { fix x assume "lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit x" and "src x = src e" and "intra_kind (knd x)" (*‹lift_valid_edge (valid_edge::'a ⇒ bool) (sourcenode::'a ⇒ 'b) (targetnode::'a ⇒ 'b) (kind::'a ⇒ ('c, 'd, 'e, 'f) edge_kind) (Entry::'b) (Exit::'b) (x::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node)› ‹src (x::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node) = src (e::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node)› ‹intra_kind (knd (x::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node))›*) from ‹lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit x› (*‹lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit x›*) have "x = ?e'" proof (induct rule:lift_valid_edge.cases (*‹⟦lift_valid_edge ?valid_edge ?src ?trg ?knd ?E ?X ?a; ⋀a e. ⟦?a = e; ?valid_edge a; ?src a ≠ ?E ∨ ?trg a ≠ ?X; e = (Node (?src a), ?knd a, Node (?trg a))⟧ ⟹ ?P; ⋀e. ⟦?a = e; e = (NewEntry, (λs. True)⇩√, Node ?E)⟧ ⟹ ?P; ⋀e. ⟦?a = e; e = (Node ?X, (λs. True)⇩√, NewExit)⟧ ⟹ ?P; ⋀e. ⟦?a = e; e = (NewEntry, (λs. False)⇩√, NewExit)⟧ ⟹ ?P⟧ ⟹ ?P›*)) (*goals: 1. ‹⋀(a::'a::type) e::'b::type LDCFG_node × ('c::type, 'd::type, 'e::type, 'f::type) edge_kind × 'b::type LDCFG_node. ⟦(x::'b::type LDCFG_node × ('c::type, 'd::type, 'e::type, 'f::type) edge_kind × 'b::type LDCFG_node) = e; (valid_edge::'a::type ⇒ bool) a; (sourcenode::'a::type ⇒ 'b::type) a ≠ (Entry::'b::type) ∨ (targetnode::'a::type ⇒ 'b::type) a ≠ (Exit::'b::type); e = (Node (sourcenode a), (kind::'a::type ⇒ ('c::type, 'd::type, 'e::type, 'f::type) edge_kind) a, Node (targetnode a))⟧ ⟹ x = (Node (sourcenode (a'::'a::type)), kind a', Node (targetnode a'))› 2. ‹⋀e::'b::type LDCFG_node × ('c::type, 'd::type, 'e::type, 'f::type) edge_kind × 'b::type LDCFG_node. ⟦(x::'b::type LDCFG_node × ('c::type, 'd::type, 'e::type, 'f::type) edge_kind × 'b::type LDCFG_node) = e; e = (NewEntry, (λs::'c::type ⇒ 'd::type option. True)⇩√, Node (Entry::'b::type))⟧ ⟹ x = (Node ((sourcenode::'a::type ⇒ 'b::type) (a'::'a::type)), (kind::'a::type ⇒ ('c::type, 'd::type, 'e::type, 'f::type) edge_kind) a', Node ((targetnode::'a::type ⇒ 'b::type) a'))› 3. ‹⋀e::'b::type LDCFG_node × ('c::type, 'd::type, 'e::type, 'f::type) edge_kind × 'b::type LDCFG_node. ⟦(x::'b::type LDCFG_node × ('c::type, 'd::type, 'e::type, 'f::type) edge_kind × 'b::type LDCFG_node) = e; e = (Node (Exit::'b::type), (λs::'c::type ⇒ 'd::type option. True)⇩√, NewExit)⟧ ⟹ x = (Node ((sourcenode::'a::type ⇒ 'b::type) (a'::'a::type)), (kind::'a::type ⇒ ('c::type, 'd::type, 'e::type, 'f::type) edge_kind) a', Node ((targetnode::'a::type ⇒ 'b::type) a'))› 4. ‹⋀e::'b::type LDCFG_node × ('c::type, 'd::type, 'e::type, 'f::type) edge_kind × 'b::type LDCFG_node. ⟦(x::'b::type LDCFG_node × ('c::type, 'd::type, 'e::type, 'f::type) edge_kind × 'b::type LDCFG_node) = e; e = (NewEntry, (λs::'c::type ⇒ 'd::type option. False)⇩√, NewExit)⟧ ⟹ x = (Node ((sourcenode::'a::type ⇒ 'b::type) (a'::'a::type)), (kind::'a::type ⇒ ('c::type, 'd::type, 'e::type, 'f::type) edge_kind) a', Node ((targetnode::'a::type ⇒ 'b::type) a'))›*) case (lve_edge ax ex) (*‹x = ex› ‹valid_edge ax› ‹sourcenode ax ≠ Entry ∨ targetnode ax ≠ Exit› ‹ex = (Node (sourcenode ax), kind ax, Node (targetnode ax))›*) from ‹intra_kind (knd x)› (*‹intra_kind (knd x)›*) ‹x = ex› (*‹x = ex›*) ‹src x = src e› (*‹src x = src e›*) ‹ex = (Node (sourcenode ax), kind ax, Node (targetnode ax))› (*‹(ex::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node) = (Node ((sourcenode::'a ⇒ 'b) (ax::'a)), (kind::'a ⇒ ('c, 'd, 'e, 'f) edge_kind) ax, Node ((targetnode::'a ⇒ 'b) ax))›*) ‹e = (Node (sourcenode a), kind a, Node (targetnode a))› (*‹e = (Node (sourcenode a), kind a, Node (targetnode a))›*) have "intra_kind (kind ax)" and "sourcenode ax = sourcenode a" apply - (*goals: 1. ‹⟦intra_kind (knd x); x = ex; src x = src e; ex = (Node (sourcenode ax), kind ax, Node (targetnode ax)); e = (Node (sourcenode a), kind a, Node (targetnode a))⟧ ⟹ intra_kind (kind ax)› 2. ‹⟦intra_kind (knd x); x = ex; src x = src e; ex = (Node (sourcenode ax), kind ax, Node (targetnode ax)); e = (Node (sourcenode a), kind a, Node (targetnode a))⟧ ⟹ sourcenode ax = sourcenode a› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) . with ‹valid_edge ax› (*‹valid_edge ax›*) imp (*‹∀x. valid_edge x ∧ sourcenode x = sourcenode a ∧ intra_kind (kind x) ⟶ x = a'›*) have "ax = a'" by fastforce with ‹x = ex› (*‹(x::'b::type LDCFG_node × ('c::type, 'd::type, 'e::type, 'f::type) edge_kind × 'b::type LDCFG_node) = (ex::'b::type LDCFG_node × ('c::type, 'd::type, 'e::type, 'f::type) edge_kind × 'b::type LDCFG_node)›*) ‹ex = (Node (sourcenode ax), kind ax, Node (targetnode ax))› (*‹ex = (Node (sourcenode ax), kind ax, Node (targetnode ax))›*) show "?case" (*goal: ‹x = (Node (sourcenode a'), kind a', Node (targetnode a'))›*) by simp next (*goals: 1. ‹⋀e. ⟦x = e; e = (NewEntry, (λs. True)⇩√, Node Entry)⟧ ⟹ x = (Node (sourcenode a'), kind a', Node (targetnode a'))› 2. ‹⋀e. ⟦x = e; e = (Node Exit, (λs. True)⇩√, NewExit)⟧ ⟹ x = (Node (sourcenode a'), kind a', Node (targetnode a'))› 3. ‹⋀e. ⟦x = e; e = (NewEntry, (λs. False)⇩√, NewExit)⟧ ⟹ x = (Node (sourcenode a'), kind a', Node (targetnode a'))›*) case (lve_Entry_edge ex) (*‹x = ex› ‹(ex::'b::type LDCFG_node × ('c::type, 'd::type, 'e::type, 'f::type) edge_kind × 'b::type LDCFG_node) = (NewEntry, (λs::'c::type ⇒ 'd::type option. True)⇩√, Node (Entry::'b::type))›*) with ‹src x = src e› (*‹src x = src e›*) ‹e = (Node (sourcenode a), kind a, Node (targetnode a))› (*‹e = (Node (sourcenode a), kind a, Node (targetnode a))›*) have False by simp thus "?case" (*goal: ‹x = (Node (sourcenode a'), kind a', Node (targetnode a'))›*) by simp next (*goals: 1. ‹⋀e. ⟦x = e; e = (Node Exit, (λs. True)⇩√, NewExit)⟧ ⟹ x = (Node (sourcenode a'), kind a', Node (targetnode a'))› 2. ‹⋀e. ⟦x = e; e = (NewEntry, (λs. False)⇩√, NewExit)⟧ ⟹ x = (Node (sourcenode a'), kind a', Node (targetnode a'))›*) case (lve_Exit_edge ex) (*‹x = ex› ‹ex = (Node Exit, (λs. True)⇩√, NewExit)›*) with ‹src x = src e› (*‹src x = src e›*) ‹e = (Node (sourcenode a), kind a, Node (targetnode a))› (*‹e = (Node (sourcenode a), kind a, Node (targetnode a))›*) have "sourcenode a = Exit" by simp with ‹valid_edge a› (*‹valid_edge a›*) have False by (rule Exit_source (*‹⟦valid_edge ?a; sourcenode ?a = Exit⟧ ⟹ False›*)) thus "?case" (*goal: ‹x = (Node (sourcenode a'), kind a', Node (targetnode a'))›*) by simp next (*goal: ‹⋀e. ⟦x = e; e = (NewEntry, (λs. False)⇩√, NewExit)⟧ ⟹ x = (Node (sourcenode a'), kind a', Node (targetnode a'))›*) case (lve_Entry_Exit_edge ex) (*‹x = ex› ‹ex = (NewEntry, (λs. False)⇩√, NewExit)›*) with ‹src x = src e› (*‹src (x::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node) = src (e::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node)›*) ‹e = (Node (sourcenode a), kind a, Node (targetnode a))› (*‹(e::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node) = (Node ((sourcenode::'a ⇒ 'b) (a::'a)), (kind::'a ⇒ ('c, 'd, 'e, 'f) edge_kind) a, Node ((targetnode::'a ⇒ 'b) a))›*) have False by simp thus "?case" (*goal: ‹x = (Node (sourcenode a'), kind a', Node (targetnode a'))›*) by simp qed } ultimately show "?case" (*goal: ‹∃!a'. lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a' ∧ src a' = src e ∧ intra_kind (knd a')›*) by (blast intro:ex1I (*‹⟦?P ?a; ⋀x. ?P x ⟹ x = ?a⟧ ⟹ ∃!x. ?P x›*)) qed (simp_all) (*solves the remaining goals: 1. ‹⋀e. ⟦e = (NewEntry, (λs. True)⇩√, Node Entry); knd e = Q:r↪⇘p⇙fs⟧ ⟹ ∃!a'. lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a' ∧ src a' = src e ∧ intra_kind (knd a')› 2. ‹⋀e. ⟦e = (Node Exit, (λs. True)⇩√, NewExit); knd e = Q:r↪⇘p⇙fs⟧ ⟹ ∃!a'. lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a' ∧ src a' = src e ∧ intra_kind (knd a')› 3. ‹⋀e. ⟦e = (NewEntry, (λs. False)⇩√, NewExit); knd e = Q:r↪⇘p⇙fs⟧ ⟹ ∃!a'. lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a' ∧ src a' = src e ∧ intra_kind (knd a')›*) next (*goals: 1. ‹⋀(a::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node) (Q'::('c ⇒ 'd option) × 'e ⇒ bool) (p::'f) f'::('c ⇒ 'd option) ⇒ ('c ⇒ 'd option) ⇒ 'c ⇒ 'd option. ⟦lift_valid_edge (valid_edge::'a ⇒ bool) (sourcenode::'a ⇒ 'b) (targetnode::'a ⇒ 'b) (kind::'a ⇒ ('c, 'd, 'e, 'f) edge_kind) (Entry::'b) (Exit::'b) a; knd a = Q'↩⇘p⇙f'⟧ ⟹ ∃!a'::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node. lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a' ∧ trg a' = trg a ∧ intra_kind (knd a')› 2. ‹⋀(a::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node) (a'::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node) (Q₁::('c ⇒ 'd option) × 'e ⇒ bool) (r₁::'e) (p::'f) (fs₁::(('c ⇒ 'd option) ⇒ 'd option) list) (Q₂::('c ⇒ 'd option) × 'e ⇒ bool) (r₂::'e) fs₂::(('c ⇒ 'd option) ⇒ 'd option) list. ⟦lift_valid_edge (valid_edge::'a ⇒ bool) (sourcenode::'a ⇒ 'b) (targetnode::'a ⇒ 'b) (kind::'a ⇒ ('c, 'd, 'e, 'f) edge_kind) (Entry::'b) (Exit::'b) a; lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a'; knd a = Q₁:r₁↪⇘p⇙fs₁; knd a' = Q₂:r₂↪⇘p⇙fs₂⟧ ⟹ trg a = trg a'› 3. ‹distinct_fst (procs::('f × 'c list × 'c list) list)› 4. ‹⋀(p::'f) (ins::'c list) outs::'c list. (p, ins, outs) ∈ set (procs::('f × 'c list × 'c list) list) ⟹ distinct ins› 5. ‹⋀(p::'f) (ins::'c list) outs::'c list. (p, ins, outs) ∈ set (procs::('f × 'c list × 'c list) list) ⟹ distinct outs›*) fix a and Q' and p and f' assume "lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a" and "knd a = Q'↩⇘p⇙f'" (*‹lift_valid_edge (valid_edge::'a ⇒ bool) (sourcenode::'a ⇒ 'b) (targetnode::'a ⇒ 'b) (kind::'a ⇒ ('c, 'd, 'e, 'f) edge_kind) (Entry::'b) (Exit::'b) (a::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node)› ‹knd (a::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node) = Q'::('c ⇒ 'd option) × 'e ⇒ bool↩⇘p::'f⇙f'::('c ⇒ 'd option) ⇒ ('c ⇒ 'd option) ⇒ 'c ⇒ 'd option›*) thus "∃!a'. lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a' ∧ trg a' = trg a ∧ intra_kind (knd a')" proof (induct rule:lift_valid_edge.induct (*‹⟦lift_valid_edge ?valid_edge ?src ?trg ?knd ?E ?X ?x; ⋀a e. ⟦?valid_edge a; ?src a ≠ ?E ∨ ?trg a ≠ ?X; e = (Node (?src a), ?knd a, Node (?trg a))⟧ ⟹ ?P e; ⋀e. e = (NewEntry, (λs. True)⇩√, Node ?E) ⟹ ?P e; ⋀e. e = (Node ?X, (λs. True)⇩√, NewExit) ⟹ ?P e; ⋀e. e = (NewEntry, (λs. False)⇩√, NewExit) ⟹ ?P e⟧ ⟹ ?P ?x›*)) (*goals: 1. ‹⋀a e. ⟦valid_edge a; sourcenode a ≠ Entry ∨ targetnode a ≠ Exit; e = (Node (sourcenode a), kind a, Node (targetnode a)); knd e = Q'↩⇘p⇙f'⟧ ⟹ ∃!a'. lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a' ∧ trg a' = trg e ∧ intra_kind (knd a')› 2. ‹⋀e. ⟦e = (NewEntry, (λs. True)⇩√, Node Entry); knd e = Q'↩⇘p⇙f'⟧ ⟹ ∃!a'. lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a' ∧ trg a' = trg e ∧ intra_kind (knd a')› 3. ‹⋀e. ⟦e = (Node Exit, (λs. True)⇩√, NewExit); knd e = Q'↩⇘p⇙f'⟧ ⟹ ∃!a'. lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a' ∧ trg a' = trg e ∧ intra_kind (knd a')› 4. ‹⋀e. ⟦e = (NewEntry, (λs. False)⇩√, NewExit); knd e = Q'↩⇘p⇙f'⟧ ⟹ ∃!a'. lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a' ∧ trg a' = trg e ∧ intra_kind (knd a')›*) case (lve_edge a e) (*‹valid_edge a› ‹(sourcenode::'a ⇒ 'b) (a::'a) ≠ (Entry::'b) ∨ (targetnode::'a ⇒ 'b) a ≠ (Exit::'b)› ‹(e::'b::type LDCFG_node × ('c::type, 'd::type, 'e::type, 'f::type) edge_kind × 'b::type LDCFG_node) = (Node ((sourcenode::'a::type ⇒ 'b::type) (a::'a::type)), (kind::'a::type ⇒ ('c::type, 'd::type, 'e::type, 'f::type) edge_kind) a, Node ((targetnode::'a::type ⇒ 'b::type) a))› ‹knd e = Q'↩⇘p⇙f'›*) from ‹e = (Node (sourcenode a), kind a, Node (targetnode a))› (*‹e = (Node (sourcenode a), kind a, Node (targetnode a))›*) ‹knd e = Q'↩⇘p⇙f'› (*‹knd e = Q'↩⇘p⇙f'›*) have "kind a = Q'↩⇘p⇙f'" by simp with ‹valid_edge a› (*‹valid_edge a›*) have "∃!a'. valid_edge a' ∧ targetnode a' = targetnode a ∧ intra_kind(kind a')" by (rule return_only_one_intra_edge (*‹⟦valid_edge ?a; kind ?a = ?Q'↩⇘?p⇙?f'⟧ ⟹ ∃!a'. valid_edge a' ∧ targetnode a' = targetnode ?a ∧ intra_kind (kind a')›*)) then obtain a' where "valid_edge a'" and "targetnode a' = targetnode a" and "intra_kind(kind a')" and imp: "∀x. valid_edge x ∧ targetnode x = targetnode a ∧ intra_kind(kind x) ⟶ x = a'" (*goal: ‹(⋀a'::'a::type. ⟦(valid_edge::'a::type ⇒ bool) a'; (targetnode::'a::type ⇒ 'b::type) a' = targetnode (a::'a::type); intra_kind ((kind::'a::type ⇒ ('c::type, 'd::type, 'e::type, 'f::type) edge_kind) a'); ∀x::'a::type. valid_edge x ∧ targetnode x = targetnode a ∧ intra_kind (kind x) ⟶ x = a'⟧ ⟹ thesis::bool) ⟹ thesis›*) by (fastforce elim:ex1E (*‹⟦∃!x. ?P x; ⋀x. ⟦?P x; ∀y. ?P y ⟶ y = x⟧ ⟹ ?R⟧ ⟹ ?R›*)) let ?e' = "(Node (sourcenode a'), kind a', Node (targetnode a'))" have "targetnode a ≠ Exit" proof (standard) (*goal: ‹targetnode a = Exit ⟹ False›*) assume "targetnode a = Exit" (*‹(targetnode::'a ⇒ 'b) (a::'a) = (Exit::'b)›*) with ‹valid_edge a› (*‹valid_edge a›*) ‹kind a = Q'↩⇘p⇙f'› (*‹kind a = Q'↩⇘p⇙f'›*) show False by (rule Exit_no_return_target (*‹⟦valid_edge ?a; kind ?a = ?Q↩⇘?p⇙?f; targetnode ?a = Exit⟧ ⟹ False›*)) qed with ‹targetnode a' = targetnode a› (*‹targetnode a' = targetnode a›*) have "targetnode a' ≠ Exit" by simp with ‹valid_edge a'› (*‹valid_edge a'›*) have "lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit ?e'" by (fastforce intro:lift_valid_edge.lve_edge (*‹⟦?valid_edge ?a; ?src ?a ≠ ?E ∨ ?trg ?a ≠ ?X; ?e = (Node (?src ?a), ?knd ?a, Node (?trg ?a))⟧ ⟹ lift_valid_edge ?valid_edge ?src ?trg ?knd ?E ?X ?e›*)) moreover from ‹e = (Node (sourcenode a), kind a, Node (targetnode a))› (*‹e = (Node (sourcenode a), kind a, Node (targetnode a))›*) ‹targetnode a' = targetnode a› (*‹targetnode a' = targetnode a›*) have "trg ?e' = trg e" by simp moreover from ‹intra_kind(kind a')› (*‹intra_kind (kind a')›*) have "intra_kind (knd ?e')" by simp moreover { fix x assume "lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit x" and "trg x = trg e" and "intra_kind (knd x)" (*‹lift_valid_edge (valid_edge::'a ⇒ bool) (sourcenode::'a ⇒ 'b) (targetnode::'a ⇒ 'b) (kind::'a ⇒ ('c, 'd, 'e, 'f) edge_kind) (Entry::'b) (Exit::'b) (x::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node)› ‹trg (x::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node) = trg (e::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node)› ‹intra_kind (knd (x::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node))›*) from ‹lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit x› (*‹lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit x›*) have "x = ?e'" proof (induct rule:lift_valid_edge.cases (*‹⟦lift_valid_edge ?valid_edge ?src ?trg ?knd ?E ?X ?a; ⋀a e. ⟦?a = e; ?valid_edge a; ?src a ≠ ?E ∨ ?trg a ≠ ?X; e = (Node (?src a), ?knd a, Node (?trg a))⟧ ⟹ ?P; ⋀e. ⟦?a = e; e = (NewEntry, (λs. True)⇩√, Node ?E)⟧ ⟹ ?P; ⋀e. ⟦?a = e; e = (Node ?X, (λs. True)⇩√, NewExit)⟧ ⟹ ?P; ⋀e. ⟦?a = e; e = (NewEntry, (λs. False)⇩√, NewExit)⟧ ⟹ ?P⟧ ⟹ ?P›*)) (*goals: 1. ‹⋀a e. ⟦x = e; valid_edge a; sourcenode a ≠ Entry ∨ targetnode a ≠ Exit; e = (Node (sourcenode a), kind a, Node (targetnode a))⟧ ⟹ x = (Node (sourcenode a'), kind a', Node (targetnode a'))› 2. ‹⋀e. ⟦x = e; e = (NewEntry, (λs. True)⇩√, Node Entry)⟧ ⟹ x = (Node (sourcenode a'), kind a', Node (targetnode a'))› 3. ‹⋀e. ⟦x = e; e = (Node Exit, (λs. True)⇩√, NewExit)⟧ ⟹ x = (Node (sourcenode a'), kind a', Node (targetnode a'))› 4. ‹⋀e. ⟦x = e; e = (NewEntry, (λs. False)⇩√, NewExit)⟧ ⟹ x = (Node (sourcenode a'), kind a', Node (targetnode a'))›*) case (lve_edge ax ex) (*‹(x::'b::type LDCFG_node × ('c::type, 'd::type, 'e::type, 'f::type) edge_kind × 'b::type LDCFG_node) = (ex::'b::type LDCFG_node × ('c::type, 'd::type, 'e::type, 'f::type) edge_kind × 'b::type LDCFG_node)› ‹valid_edge ax› ‹sourcenode ax ≠ Entry ∨ targetnode ax ≠ Exit› ‹ex = (Node (sourcenode ax), kind ax, Node (targetnode ax))›*) from ‹intra_kind (knd x)› (*‹intra_kind (knd x)›*) ‹x = ex› (*‹x = ex›*) ‹trg x = trg e› (*‹trg x = trg e›*) ‹ex = (Node (sourcenode ax), kind ax, Node (targetnode ax))› (*‹ex = (Node (sourcenode ax), kind ax, Node (targetnode ax))›*) ‹e = (Node (sourcenode a), kind a, Node (targetnode a))› (*‹e = (Node (sourcenode a), kind a, Node (targetnode a))›*) have "intra_kind (kind ax)" and "targetnode ax = targetnode a" apply - (*goals: 1. ‹⟦intra_kind (knd x); x = ex; trg x = trg e; ex = (Node (sourcenode ax), kind ax, Node (targetnode ax)); e = (Node (sourcenode a), kind a, Node (targetnode a))⟧ ⟹ intra_kind (kind ax)› 2. ‹⟦intra_kind (knd x); x = ex; trg x = trg e; ex = (Node (sourcenode ax), kind ax, Node (targetnode ax)); e = (Node (sourcenode a), kind a, Node (targetnode a))⟧ ⟹ targetnode ax = targetnode a› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) . with ‹valid_edge ax› (*‹(valid_edge::'a::type ⇒ bool) (ax::'a::type)›*) imp (*‹∀x. valid_edge x ∧ targetnode x = targetnode a ∧ intra_kind (kind x) ⟶ x = a'›*) have "ax = a'" by fastforce with ‹x = ex› (*‹x = ex›*) ‹ex = (Node (sourcenode ax), kind ax, Node (targetnode ax))› (*‹ex = (Node (sourcenode ax), kind ax, Node (targetnode ax))›*) show "?case" (*goal: ‹x = (Node (sourcenode a'), kind a', Node (targetnode a'))›*) by simp next (*goals: 1. ‹⋀e. ⟦x = e; e = (NewEntry, (λs. True)⇩√, Node Entry)⟧ ⟹ x = (Node (sourcenode a'), kind a', Node (targetnode a'))› 2. ‹⋀e. ⟦x = e; e = (Node Exit, (λs. True)⇩√, NewExit)⟧ ⟹ x = (Node (sourcenode a'), kind a', Node (targetnode a'))› 3. ‹⋀e. ⟦x = e; e = (NewEntry, (λs. False)⇩√, NewExit)⟧ ⟹ x = (Node (sourcenode a'), kind a', Node (targetnode a'))›*) case (lve_Entry_edge ex) (*‹x = ex› ‹ex = (NewEntry, (λs. True)⇩√, Node Entry)›*) with ‹trg x = trg e› (*‹trg x = trg e›*) ‹e = (Node (sourcenode a), kind a, Node (targetnode a))› (*‹e = (Node (sourcenode a), kind a, Node (targetnode a))›*) have "targetnode a = Entry" by simp with ‹valid_edge a› (*‹valid_edge a›*) have False by (rule Entry_target (*‹⟦valid_edge ?a; targetnode ?a = Entry⟧ ⟹ False›*)) thus "?case" (*goal: ‹x = (Node (sourcenode a'), kind a', Node (targetnode a'))›*) by simp next (*goals: 1. ‹⋀e::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node. ⟦(x::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node) = e; e = (Node (Exit::'b), (λs::'c ⇒ 'd option. True)⇩√, NewExit)⟧ ⟹ x = (Node ((sourcenode::'a ⇒ 'b) (a'::'a)), (kind::'a ⇒ ('c, 'd, 'e, 'f) edge_kind) a', Node ((targetnode::'a ⇒ 'b) a'))› 2. ‹⋀e::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node. ⟦(x::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node) = e; e = (NewEntry, (λs::'c ⇒ 'd option. False)⇩√, NewExit)⟧ ⟹ x = (Node ((sourcenode::'a ⇒ 'b) (a'::'a)), (kind::'a ⇒ ('c, 'd, 'e, 'f) edge_kind) a', Node ((targetnode::'a ⇒ 'b) a'))›*) case (lve_Exit_edge ex) (*‹x = ex› ‹ex = (Node Exit, (λs. True)⇩√, NewExit)›*) with ‹trg x = trg e› (*‹trg x = trg e›*) ‹e = (Node (sourcenode a), kind a, Node (targetnode a))› (*‹(e::'b::type LDCFG_node × ('c::type, 'd::type, 'e::type, 'f::type) edge_kind × 'b::type LDCFG_node) = (Node ((sourcenode::'a::type ⇒ 'b::type) (a::'a::type)), (kind::'a::type ⇒ ('c::type, 'd::type, 'e::type, 'f::type) edge_kind) a, Node ((targetnode::'a::type ⇒ 'b::type) a))›*) have False by simp thus "?case" (*goal: ‹x = (Node (sourcenode a'), kind a', Node (targetnode a'))›*) by simp next (*goal: ‹⋀e. ⟦x = e; e = (NewEntry, (λs. False)⇩√, NewExit)⟧ ⟹ x = (Node (sourcenode a'), kind a', Node (targetnode a'))›*) case (lve_Entry_Exit_edge ex) (*‹x = ex› ‹ex = (NewEntry, (λs. False)⇩√, NewExit)›*) with ‹trg x = trg e› (*‹trg x = trg e›*) ‹e = (Node (sourcenode a), kind a, Node (targetnode a))› (*‹e = (Node (sourcenode a), kind a, Node (targetnode a))›*) have False by simp thus "?case" (*goal: ‹x = (Node (sourcenode a'), kind a', Node (targetnode a'))›*) by simp qed } ultimately show "?case" (*goal: ‹∃!a'. lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a' ∧ trg a' = trg e ∧ intra_kind (knd a')›*) by (blast intro:ex1I (*‹⟦?P ?a; ⋀x. ?P x ⟹ x = ?a⟧ ⟹ ∃!x. ?P x›*)) qed (simp_all) (*solves the remaining goals: 1. ‹⋀e::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node. ⟦e = (NewEntry, (λs::'c ⇒ 'd option. True)⇩√, Node (Entry::'b)); knd e = Q'::('c ⇒ 'd option) × 'e ⇒ bool↩⇘p::'f⇙f'::('c ⇒ 'd option) ⇒ ('c ⇒ 'd option) ⇒ 'c ⇒ 'd option⟧ ⟹ ∃!a'::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node. lift_valid_edge (valid_edge::'a ⇒ bool) (sourcenode::'a ⇒ 'b) (targetnode::'a ⇒ 'b) (kind::'a ⇒ ('c, 'd, 'e, 'f) edge_kind) Entry (Exit::'b) a' ∧ trg a' = trg e ∧ intra_kind (knd a')› 2. ‹⋀e::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node. ⟦e = (Node (Exit::'b), (λs::'c ⇒ 'd option. True)⇩√, NewExit); knd e = Q'::('c ⇒ 'd option) × 'e ⇒ bool↩⇘p::'f⇙f'::('c ⇒ 'd option) ⇒ ('c ⇒ 'd option) ⇒ 'c ⇒ 'd option⟧ ⟹ ∃!a'::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node. lift_valid_edge (valid_edge::'a ⇒ bool) (sourcenode::'a ⇒ 'b) (targetnode::'a ⇒ 'b) (kind::'a ⇒ ('c, 'd, 'e, 'f) edge_kind) (Entry::'b) Exit a' ∧ trg a' = trg e ∧ intra_kind (knd a')› 3. ‹⋀e::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node. ⟦e = (NewEntry, (λs::'c ⇒ 'd option. False)⇩√, NewExit); knd e = Q'::('c ⇒ 'd option) × 'e ⇒ bool↩⇘p::'f⇙f'::('c ⇒ 'd option) ⇒ ('c ⇒ 'd option) ⇒ 'c ⇒ 'd option⟧ ⟹ ∃!a'::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node. lift_valid_edge (valid_edge::'a ⇒ bool) (sourcenode::'a ⇒ 'b) (targetnode::'a ⇒ 'b) (kind::'a ⇒ ('c, 'd, 'e, 'f) edge_kind) (Entry::'b) (Exit::'b) a' ∧ trg a' = trg e ∧ intra_kind (knd a')›*) next (*goals: 1. ‹⋀a a' Q₁ r₁ p fs₁ Q₂ r₂ fs₂. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a'; knd a = Q₁:r₁↪⇘p⇙fs₁; knd a' = Q₂:r₂↪⇘p⇙fs₂⟧ ⟹ trg a = trg a'› 2. ‹distinct_fst procs› 3. ‹⋀p ins outs. (p, ins, outs) ∈ set procs ⟹ distinct ins› 4. ‹⋀p ins outs. (p, ins, outs) ∈ set procs ⟹ distinct outs›*) fix a and a' and Q₁ and r₁ and p and fs₁ and Q₂ and r₂ and fs₂ assume "lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a" and "lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a'" and "knd a = Q₁:r₁↪⇘p⇙fs₁" and "knd a' = Q₂:r₂↪⇘p⇙fs₂" (*‹lift_valid_edge (valid_edge::'a ⇒ bool) (sourcenode::'a ⇒ 'b) (targetnode::'a ⇒ 'b) (kind::'a ⇒ ('c, 'd, 'e, 'f) edge_kind) (Entry::'b) (Exit::'b) (a::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node)› ‹lift_valid_edge (valid_edge::'a ⇒ bool) (sourcenode::'a ⇒ 'b) (targetnode::'a ⇒ 'b) (kind::'a ⇒ ('c, 'd, 'e, 'f) edge_kind) (Entry::'b) (Exit::'b) (a'::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node)› ‹knd (a::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node) = Q₁::('c ⇒ 'd option) × 'e ⇒ bool:r₁::'e↪⇘p::'f⇙fs₁::(('c ⇒ 'd option) ⇒ 'd option) list› ‹knd (a'::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node) = Q₂::('c ⇒ 'd option) × 'e ⇒ bool:r₂::'e↪⇘p::'f⇙fs₂::(('c ⇒ 'd option) ⇒ 'd option) list›*) then obtain x and x' where "valid_edge x" and a: "a = (Node (sourcenode x),kind x,Node (targetnode x))" and "valid_edge x'" and a': "a' = (Node (sourcenode x'),kind x',Node (targetnode x'))" (*goal: ‹(⋀(x::'a) x'::'a. ⟦(valid_edge::'a ⇒ bool) x; (a::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node) = (Node ((sourcenode::'a ⇒ 'b) x), (kind::'a ⇒ ('c, 'd, 'e, 'f) edge_kind) x, Node ((targetnode::'a ⇒ 'b) x)); valid_edge x'; (a'::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node) = (Node (sourcenode x'), kind x', Node (targetnode x'))⟧ ⟹ thesis::bool) ⟹ thesis›*) by (auto elim!:lift_valid_edge.cases (*‹⟦lift_valid_edge ?valid_edge ?src ?trg ?knd ?E ?X ?a; ⋀a e. ⟦?a = e; ?valid_edge a; ?src a ≠ ?E ∨ ?trg a ≠ ?X; e = (Node (?src a), ?knd a, Node (?trg a))⟧ ⟹ ?P; ⋀e. ⟦?a = e; e = (NewEntry, (λs. True)⇩√, Node ?E)⟧ ⟹ ?P; ⋀e. ⟦?a = e; e = (Node ?X, (λs. True)⇩√, NewExit)⟧ ⟹ ?P; ⋀e. ⟦?a = e; e = (NewEntry, (λs. False)⇩√, NewExit)⟧ ⟹ ?P⟧ ⟹ ?P›*)) with ‹knd a = Q₁:r₁↪⇘p⇙fs₁› (*‹knd a = Q₁:r₁↪⇘p⇙fs₁›*) ‹knd a' = Q₂:r₂↪⇘p⇙fs₂› (*‹knd (a'::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node) = Q₂::('c ⇒ 'd option) × 'e ⇒ bool:r₂::'e↪⇘p::'f⇙fs₂::(('c ⇒ 'd option) ⇒ 'd option) list›*) have "kind x = Q₁:r₁↪⇘p⇙fs₁" and "kind x' = Q₂:r₂↪⇘p⇙fs₂" apply - (*goals: 1. ‹⟦knd a = Q₁:r₁↪⇘p⇙fs₁; knd a' = Q₂:r₂↪⇘p⇙fs₂; valid_edge x; a = (Node (sourcenode x), kind x, Node (targetnode x)); valid_edge x'; a' = (Node (sourcenode x'), kind x', Node (targetnode x'))⟧ ⟹ kind x = Q₁:r₁↪⇘p⇙fs₁› 2. ‹⟦knd a = Q₁:r₁↪⇘p⇙fs₁; knd a' = Q₂:r₂↪⇘p⇙fs₂; valid_edge x; a = (Node (sourcenode x), kind x, Node (targetnode x)); valid_edge x'; a' = (Node (sourcenode x'), kind x', Node (targetnode x'))⟧ ⟹ kind x' = Q₂:r₂↪⇘p⇙fs₂› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) . with ‹valid_edge x› (*‹valid_edge x›*) ‹valid_edge x'› (*‹valid_edge x'›*) have "targetnode x = targetnode x'" by (rule same_proc_call_unique_target (*‹⟦valid_edge ?a; valid_edge ?a'; kind ?a = ?Q₁:?r₁↪⇘?p⇙?fs₁; kind ?a' = ?Q₂:?r₂↪⇘?p⇙?fs₂⟧ ⟹ targetnode ?a = targetnode ?a'›*)) with a (*‹a = (Node (sourcenode x), kind x, Node (targetnode x))›*) a' (*‹a' = (Node (sourcenode x'), kind x', Node (targetnode x'))›*) show "trg a = trg a'" by simp next (*goals: 1. ‹distinct_fst (procs::('f × 'c list × 'c list) list)› 2. ‹⋀(p::'f) (ins::'c list) outs::'c list. (p, ins, outs) ∈ set (procs::('f × 'c list × 'c list) list) ⟹ distinct ins› 3. ‹⋀(p::'f) (ins::'c list) outs::'c list. (p, ins, outs) ∈ set (procs::('f × 'c list × 'c list) list) ⟹ distinct outs›*) from unique_callers (*‹distinct_fst procs›*) show "distinct_fst procs" . next (*goals: 1. ‹⋀p ins outs. (p, ins, outs) ∈ set procs ⟹ distinct ins› 2. ‹⋀p ins outs. (p, ins, outs) ∈ set procs ⟹ distinct outs›*) fix p and ins and outs assume "(p, ins, outs) ∈ set procs" (*‹(p::'f, ins::'c list, outs::'c list) ∈ set (procs::('f × 'c list × 'c list) list)›*) from distinct_formal_ins[OF this] (*‹distinct ins›*) show "distinct ins" . next (*goal: ‹⋀p ins outs. (p, ins, outs) ∈ set procs ⟹ distinct outs›*) fix p and ins and outs assume "(p, ins, outs) ∈ set procs" (*‹(p::'f, ins::'c list, outs::'c list) ∈ set (procs::('f × 'c list × 'c list) list)›*) from distinct_formal_outs[OF this] (*‹distinct outs›*) show "distinct outs" . qed qed lemma lift_CFG_wf: assumes wf:"CFGExit_wf sourcenode targetnode kind valid_edge Entry get_proc get_return_edges procs Main Exit Def Use ParamDefs ParamUses" and pd:"Postdomination sourcenode targetnode kind valid_edge Entry get_proc get_return_edges procs Main Exit" shows "CFG_wf src trg knd (lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit) NewEntry (lift_get_proc get_proc Main) (lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind) procs Main (lift_Def Def Entry Exit H L) (lift_Use Use Entry Exit H L) (lift_ParamDefs ParamDefs) (lift_ParamUses ParamUses)" proof (-) (*goal: ‹CFG_wf src trg knd (lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit) NewEntry (lift_get_proc get_proc Main) (lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind) procs Main (lift_Def Def Entry Exit H L) (lift_Use Use Entry Exit H L) (lift_ParamDefs ParamDefs) (lift_ParamUses ParamUses)›*) interpret CFGExit_wf sourcenode targetnode kind valid_edge Entry get_proc get_return_edges procs Main Exit Def Use ParamDefs ParamUses by (rule wf (*‹CFGExit_wf sourcenode targetnode kind valid_edge Entry get_proc get_return_edges procs Main Exit Def Use ParamDefs ParamUses›*)) interpret Postdomination sourcenode targetnode kind valid_edge Entry get_proc get_return_edges procs Main Exit by (rule pd (*‹Postdomination sourcenode targetnode kind valid_edge Entry get_proc get_return_edges procs Main Exit›*)) interpret CFG: CFG src trg knd "lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit" NewEntry "lift_get_proc get_proc Main" "lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind" procs Main by (fastforce intro:lift_CFG (*‹⟦CFGExit_wf ?sourcenode ?targetnode ?kind ?valid_edge ?Entry ?get_proc ?get_return_edges ?procs ?Main ?Exit ?Def ?Use ?ParamDefs ?ParamUses; Postdomination ?sourcenode ?targetnode ?kind ?valid_edge ?Entry ?get_proc ?get_return_edges ?procs ?Main ?Exit⟧ ⟹ CFG src trg knd (lift_valid_edge ?valid_edge ?sourcenode ?targetnode ?kind ?Entry ?Exit) NewEntry (lift_get_proc ?get_proc ?Main) (lift_get_return_edges ?get_return_edges ?valid_edge ?sourcenode ?targetnode ?kind) ?procs ?Main›*) wf (*‹CFGExit_wf sourcenode targetnode kind valid_edge Entry get_proc get_return_edges procs Main Exit Def Use ParamDefs ParamUses›*) pd (*‹Postdomination sourcenode targetnode kind valid_edge Entry get_proc get_return_edges procs Main Exit›*)) show "?thesis" (*goal: ‹CFG_wf src trg knd (lift_valid_edge (valid_edge::'a ⇒ bool) (sourcenode::'a ⇒ 'b) (targetnode::'a ⇒ 'b) (kind::'a ⇒ ('c, 'd, 'e, 'f) edge_kind) (Entry::'b) (Exit::'b)) NewEntry (lift_get_proc (get_proc::'b ⇒ 'f) (Main::'f)) (lift_get_return_edges (get_return_edges::'a ⇒ 'a set) valid_edge sourcenode targetnode kind) (procs::('f × 'c list × 'c list) list) Main (lift_Def (Def::'b ⇒ 'c set) Entry Exit (H::'c set) (L::'c set)) (lift_Use (Use::'b ⇒ 'c set) Entry Exit H L) (lift_ParamDefs (ParamDefs::'b ⇒ 'c list)) (lift_ParamUses (ParamUses::'b ⇒ 'c set list))›*) proof (standard) (*goals: 1. ‹lift_Def (Def::'b ⇒ 'c set) (Entry::'b) (Exit::'b) (H::'c set) (L::'c set) NewEntry = {} ∧ lift_Use (Use::'b ⇒ 'c set) Entry Exit H L NewEntry = {}› 2. ‹⋀(a::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node) (Q::('c ⇒ 'd option) × 'e ⇒ bool) (r::'e) (p::'f) (fs::(('c ⇒ 'd option) ⇒ 'd option) list) (ins::'c list) outs::'c list. ⟦lift_valid_edge (valid_edge::'a ⇒ bool) (sourcenode::'a ⇒ 'b) (targetnode::'a ⇒ 'b) (kind::'a ⇒ ('c, 'd, 'e, 'f) edge_kind) (Entry::'b) (Exit::'b) a; knd a = Q:r↪⇘p⇙fs; (p, ins, outs) ∈ set (procs::('f × 'c list × 'c list) list)⟧ ⟹ length (lift_ParamUses (ParamUses::'b ⇒ 'c set list) (src a)) = length ins› 3. ‹⋀a::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node. lift_valid_edge (valid_edge::'a ⇒ bool) (sourcenode::'a ⇒ 'b) (targetnode::'a ⇒ 'b) (kind::'a ⇒ ('c, 'd, 'e, 'f) edge_kind) (Entry::'b) (Exit::'b) a ⟹ distinct (lift_ParamDefs (ParamDefs::'b ⇒ 'c list) (trg a))› 4. ‹⋀(a::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node) (Q'::('c ⇒ 'd option) × 'e ⇒ bool) (p::'f) (f'::('c ⇒ 'd option) ⇒ ('c ⇒ 'd option) ⇒ 'c ⇒ 'd option) (ins::'c list) outs::'c list. ⟦lift_valid_edge (valid_edge::'a ⇒ bool) (sourcenode::'a ⇒ 'b) (targetnode::'a ⇒ 'b) (kind::'a ⇒ ('c, 'd, 'e, 'f) edge_kind) (Entry::'b) (Exit::'b) a; knd a = Q'↩⇘p⇙f'; (p, ins, outs) ∈ set (procs::('f × 'c list × 'c list) list)⟧ ⟹ length (lift_ParamDefs (ParamDefs::'b ⇒ 'c list) (trg a)) = length outs› 5. ‹⋀(n::'b LDCFG_node) V::'c. ⟦local.CFG.valid_node n; V ∈ set (lift_ParamDefs (ParamDefs::'b ⇒ 'c list) n)⟧ ⟹ V ∈ lift_Def (Def::'b ⇒ 'c set) (Entry::'b) (Exit::'b) (H::'c set) (L::'c set) n› 6. ‹⋀(a::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node) (Q::('c ⇒ 'd option) × 'e ⇒ bool) (r::'e) (p::'f) (fs::(('c ⇒ 'd option) ⇒ 'd option) list) (ins::'c list) (outs::'c list) V::'c. ⟦lift_valid_edge (valid_edge::'a ⇒ bool) (sourcenode::'a ⇒ 'b) (targetnode::'a ⇒ 'b) (kind::'a ⇒ ('c, 'd, 'e, 'f) edge_kind) (Entry::'b) (Exit::'b) a; knd a = Q:r↪⇘p⇙fs; (p, ins, outs) ∈ set (procs::('f × 'c list × 'c list) list); V ∈ set ins⟧ ⟹ V ∈ lift_Def (Def::'b ⇒ 'c set) Entry Exit (H::'c set) (L::'c set) (trg a)› 7. ‹⋀(a::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node) (Q::('c ⇒ 'd option) × 'e ⇒ bool) (r::'e) (p::'f) fs::(('c ⇒ 'd option) ⇒ 'd option) list. ⟦lift_valid_edge (valid_edge::'a ⇒ bool) (sourcenode::'a ⇒ 'b) (targetnode::'a ⇒ 'b) (kind::'a ⇒ ('c, 'd, 'e, 'f) edge_kind) (Entry::'b) (Exit::'b) a; knd a = Q:r↪⇘p⇙fs⟧ ⟹ lift_Def (Def::'b ⇒ 'c set) Entry Exit (H::'c set) (L::'c set) (src a) = {}› 8. ‹⋀(n::'b LDCFG_node) V::'c. ⟦local.CFG.valid_node n; V ∈ ⋃ (set (lift_ParamUses (ParamUses::'b ⇒ 'c set list) n))⟧ ⟹ V ∈ lift_Use (Use::'b ⇒ 'c set) (Entry::'b) (Exit::'b) (H::'c set) (L::'c set) n› 9. ‹⋀(a::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node) (Q::('c ⇒ 'd option) × 'e ⇒ bool) (p::'f) (f::('c ⇒ 'd option) ⇒ ('c ⇒ 'd option) ⇒ 'c ⇒ 'd option) (ins::'c list) (outs::'c list) V::'c. ⟦lift_valid_edge (valid_edge::'a ⇒ bool) (sourcenode::'a ⇒ 'b) (targetnode::'a ⇒ 'b) (kind::'a ⇒ ('c, 'd, 'e, 'f) edge_kind) (Entry::'b) (Exit::'b) a; knd a = Q↩⇘p⇙f; (p, ins, outs) ∈ set (procs::('f × 'c list × 'c list) list); V ∈ set outs⟧ ⟹ V ∈ lift_Use (Use::'b ⇒ 'c set) Entry Exit (H::'c set) (L::'c set) (src a)› 10. ‹⋀(a::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node) (V::'c) s::(('c ⇒ 'd option) × 'e) list. ⟦lift_valid_edge (valid_edge::'a ⇒ bool) (sourcenode::'a ⇒ 'b) (targetnode::'a ⇒ 'b) (kind::'a ⇒ ('c, 'd, 'e, 'f) edge_kind) (Entry::'b) (Exit::'b) a; V ∉ lift_Def (Def::'b ⇒ 'c set) Entry Exit (H::'c set) (L::'c set) (src a); intra_kind (knd a); local.CFG.pred (knd a) s⟧ ⟹ local.CFG.state_val (local.CFG.transfer (knd a) s) V = local.CFG.state_val s V› 11. ‹⋀(a::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node) (s::(('c ⇒ 'd option) × 'e) list) s'::(('c ⇒ 'd option) × 'e) list. ⟦lift_valid_edge (valid_edge::'a ⇒ bool) (sourcenode::'a ⇒ 'b) (targetnode::'a ⇒ 'b) (kind::'a ⇒ ('c, 'd, 'e, 'f) edge_kind) (Entry::'b) (Exit::'b) a; ∀V::'c∈lift_Use (Use::'b ⇒ 'c set) Entry Exit (H::'c set) (L::'c set) (src a). local.CFG.state_val s V = local.CFG.state_val s' V; intra_kind (knd a); local.CFG.pred (knd a) s; local.CFG.pred (knd a) s'⟧ ⟹ ∀V::'c∈lift_Def (Def::'b ⇒ 'c set) Entry Exit H L (src a). local.CFG.state_val (local.CFG.transfer (knd a) s) V = local.CFG.state_val (local.CFG.transfer (knd a) s') V› 12. ‹⋀(a::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node) (s::(('c ⇒ 'd option) × 'e) list) s'::(('c ⇒ 'd option) × 'e) list. ⟦lift_valid_edge (valid_edge::'a ⇒ bool) (sourcenode::'a ⇒ 'b) (targetnode::'a ⇒ 'b) (kind::'a ⇒ ('c, 'd, 'e, 'f) edge_kind) (Entry::'b) (Exit::'b) a; local.CFG.pred (knd a) s; snd (hd s) = snd (hd s'); ∀V::'c∈lift_Use (Use::'b ⇒ 'c set) Entry Exit (H::'c set) (L::'c set) (src a). local.CFG.state_val s V = local.CFG.state_val s' V; length s = length s'⟧ ⟹ local.CFG.pred (knd a) s'› 13. ‹⋀(a::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node) (Q::('c ⇒ 'd option) × 'e ⇒ bool) (r::'e) (p::'f) (fs::(('c ⇒ 'd option) ⇒ 'd option) list) (ins::'c list) outs::'c list. ⟦lift_valid_edge (valid_edge::'a ⇒ bool) (sourcenode::'a ⇒ 'b) (targetnode::'a ⇒ 'b) (kind::'a ⇒ ('c, 'd, 'e, 'f) edge_kind) (Entry::'b) (Exit::'b) a; knd a = Q:r↪⇘p⇙fs; (p, ins, outs) ∈ set (procs::('f × 'c list × 'c list) list)⟧ ⟹ length fs = length ins› 14. ‹⋀(a::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node) (Q::('c ⇒ 'd option) × 'e ⇒ bool) (r::'e) (p::'f) (fs::(('c ⇒ 'd option) ⇒ 'd option) list) (a'::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node) (Q'::('c ⇒ 'd option) × 'e ⇒ bool) (r'::'e) (p'::'f) (fs'::(('c ⇒ 'd option) ⇒ 'd option) list) s::(('c ⇒ 'd option) × 'e) list. ⟦lift_valid_edge (valid_edge::'a ⇒ bool) (sourcenode::'a ⇒ 'b) (targetnode::'a ⇒ 'b) (kind::'a ⇒ ('c, 'd, 'e, 'f) edge_kind) (Entry::'b) (Exit::'b) a; knd a = Q:r↪⇘p⇙fs; lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a'; knd a' = Q':r'↪⇘p'⇙fs'; src a = src a'; local.CFG.pred (knd a) s; local.CFG.pred (knd a') s⟧ ⟹ a = a'› 15. ‹⋀(a::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node) (Q::('c ⇒ 'd option) × 'e ⇒ bool) (r::'e) (p::'f) (fs::(('c ⇒ 'd option) ⇒ 'd option) list) (i::nat) (ins::'c list) (outs::'c list) (s::(('c ⇒ 'd option) × 'e) list) s'::(('c ⇒ 'd option) × 'e) list. ⟦lift_valid_edge (valid_edge::'a ⇒ bool) (sourcenode::'a ⇒ 'b) (targetnode::'a ⇒ 'b) (kind::'a ⇒ ('c, 'd, 'e, 'f) edge_kind) (Entry::'b) (Exit::'b) a; knd a = Q:r↪⇘p⇙fs; i < length ins; (p, ins, outs) ∈ set (procs::('f × 'c list × 'c list) list); local.CFG.pred (knd a) s; local.CFG.pred (knd a) s'; ∀V::'c∈lift_ParamUses (ParamUses::'b ⇒ 'c set list) (src a) ! i. local.CFG.state_val s V = local.CFG.state_val s' V⟧ ⟹ local.CFG.params fs (local.CFG.state_val s) ! i = local.CFG.params fs (local.CFG.state_val s') ! i› 16. ‹⋀(a::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node) (Q'::('c ⇒ 'd option) × 'e ⇒ bool) (p::'f) (f'::('c ⇒ 'd option) ⇒ ('c ⇒ 'd option) ⇒ 'c ⇒ 'd option) (ins::'c list) (outs::'c list) (vmap::'c ⇒ 'd option) vmap'::'c ⇒ 'd option. ⟦lift_valid_edge (valid_edge::'a ⇒ bool) (sourcenode::'a ⇒ 'b) (targetnode::'a ⇒ 'b) (kind::'a ⇒ ('c, 'd, 'e, 'f) edge_kind) (Entry::'b) (Exit::'b) a; knd a = Q'↩⇘p⇙f'; (p, ins, outs) ∈ set (procs::('f × 'c list × 'c list) list)⟧ ⟹ f' vmap vmap' = vmap'(lift_ParamDefs (ParamDefs::'b ⇒ 'c list) (trg a) [:=] map vmap outs)› 17. ‹⋀(a::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node) a'::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node. ⟦lift_valid_edge (valid_edge::'a ⇒ bool) (sourcenode::'a ⇒ 'b) (targetnode::'a ⇒ 'b) (kind::'a ⇒ ('c, 'd, 'e, 'f) edge_kind) (Entry::'b) (Exit::'b) a; lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a'; src a = src a'; trg a ≠ trg a'; intra_kind (knd a); intra_kind (knd a')⟧ ⟹ ∃(Q::('c ⇒ 'd option) ⇒ bool) Q'::('c ⇒ 'd option) ⇒ bool. knd a = (Q)⇩√ ∧ knd a' = (Q')⇩√ ∧ (∀s::'c ⇒ 'd option. (Q s ⟶ ¬ Q' s) ∧ (Q' s ⟶ ¬ Q s))›*) show "lift_Def Def Entry Exit H L NewEntry = {} ∧ lift_Use Use Entry Exit H L NewEntry = {}" by (fastforce elim:lift_Use_set.cases (*‹⟦(?a1.0, ?a2.0) ∈ lift_Use_set ?Use ?E ?X ?H ?L; ⋀V n. ⟦?a1.0 = Node n; ?a2.0 = V; V ∈ ?Use n⟧ ⟹ ?P; ⋀V. ⟦?a1.0 = Node ?E; ?a2.0 = V; V ∈ ?H⟧ ⟹ ?P; ⋀V. ⟦?a1.0 = Node ?X; ?a2.0 = V; V ∈ ?L⟧ ⟹ ?P⟧ ⟹ ?P›*) lift_Def_set.cases (*‹⟦(?a1.0, ?a2.0) ∈ lift_Def_set ?Def ?E ?X ?H ?L; ⋀V n. ⟦?a1.0 = Node n; ?a2.0 = V; V ∈ ?Def n⟧ ⟹ ?P; ⋀V. ⟦?a1.0 = Node ?E; ?a2.0 = V; V ∈ ?H⟧ ⟹ ?P⟧ ⟹ ?P›*)) next (*goals: 1. ‹⋀(a::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node) (Q::('c ⇒ 'd option) × 'e ⇒ bool) (r::'e) (p::'f) (fs::(('c ⇒ 'd option) ⇒ 'd option) list) (ins::'c list) outs::'c list. ⟦lift_valid_edge (valid_edge::'a ⇒ bool) (sourcenode::'a ⇒ 'b) (targetnode::'a ⇒ 'b) (kind::'a ⇒ ('c, 'd, 'e, 'f) edge_kind) (Entry::'b) (Exit::'b) a; knd a = Q:r↪⇘p⇙fs; (p, ins, outs) ∈ set (procs::('f × 'c list × 'c list) list)⟧ ⟹ length (lift_ParamUses (ParamUses::'b ⇒ 'c set list) (src a)) = length ins› 2. ‹⋀a::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node. lift_valid_edge (valid_edge::'a ⇒ bool) (sourcenode::'a ⇒ 'b) (targetnode::'a ⇒ 'b) (kind::'a ⇒ ('c, 'd, 'e, 'f) edge_kind) (Entry::'b) (Exit::'b) a ⟹ distinct (lift_ParamDefs (ParamDefs::'b ⇒ 'c list) (trg a))› 3. ‹⋀(a::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node) (Q'::('c ⇒ 'd option) × 'e ⇒ bool) (p::'f) (f'::('c ⇒ 'd option) ⇒ ('c ⇒ 'd option) ⇒ 'c ⇒ 'd option) (ins::'c list) outs::'c list. ⟦lift_valid_edge (valid_edge::'a ⇒ bool) (sourcenode::'a ⇒ 'b) (targetnode::'a ⇒ 'b) (kind::'a ⇒ ('c, 'd, 'e, 'f) edge_kind) (Entry::'b) (Exit::'b) a; knd a = Q'↩⇘p⇙f'; (p, ins, outs) ∈ set (procs::('f × 'c list × 'c list) list)⟧ ⟹ length (lift_ParamDefs (ParamDefs::'b ⇒ 'c list) (trg a)) = length outs› 4. ‹⋀(n::'b LDCFG_node) V::'c. ⟦local.CFG.valid_node n; V ∈ set (lift_ParamDefs (ParamDefs::'b ⇒ 'c list) n)⟧ ⟹ V ∈ lift_Def (Def::'b ⇒ 'c set) (Entry::'b) (Exit::'b) (H::'c set) (L::'c set) n› 5. ‹⋀(a::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node) (Q::('c ⇒ 'd option) × 'e ⇒ bool) (r::'e) (p::'f) (fs::(('c ⇒ 'd option) ⇒ 'd option) list) (ins::'c list) (outs::'c list) V::'c. ⟦lift_valid_edge (valid_edge::'a ⇒ bool) (sourcenode::'a ⇒ 'b) (targetnode::'a ⇒ 'b) (kind::'a ⇒ ('c, 'd, 'e, 'f) edge_kind) (Entry::'b) (Exit::'b) a; knd a = Q:r↪⇘p⇙fs; (p, ins, outs) ∈ set (procs::('f × 'c list × 'c list) list); V ∈ set ins⟧ ⟹ V ∈ lift_Def (Def::'b ⇒ 'c set) Entry Exit (H::'c set) (L::'c set) (trg a)› 6. ‹⋀(a::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node) (Q::('c ⇒ 'd option) × 'e ⇒ bool) (r::'e) (p::'f) fs::(('c ⇒ 'd option) ⇒ 'd option) list. ⟦lift_valid_edge (valid_edge::'a ⇒ bool) (sourcenode::'a ⇒ 'b) (targetnode::'a ⇒ 'b) (kind::'a ⇒ ('c, 'd, 'e, 'f) edge_kind) (Entry::'b) (Exit::'b) a; knd a = Q:r↪⇘p⇙fs⟧ ⟹ lift_Def (Def::'b ⇒ 'c set) Entry Exit (H::'c set) (L::'c set) (src a) = {}› 7. ‹⋀(n::'b LDCFG_node) V::'c. ⟦local.CFG.valid_node n; V ∈ ⋃ (set (lift_ParamUses (ParamUses::'b ⇒ 'c set list) n))⟧ ⟹ V ∈ lift_Use (Use::'b ⇒ 'c set) (Entry::'b) (Exit::'b) (H::'c set) (L::'c set) n› 8. ‹⋀(a::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node) (Q::('c ⇒ 'd option) × 'e ⇒ bool) (p::'f) (f::('c ⇒ 'd option) ⇒ ('c ⇒ 'd option) ⇒ 'c ⇒ 'd option) (ins::'c list) (outs::'c list) V::'c. ⟦lift_valid_edge (valid_edge::'a ⇒ bool) (sourcenode::'a ⇒ 'b) (targetnode::'a ⇒ 'b) (kind::'a ⇒ ('c, 'd, 'e, 'f) edge_kind) (Entry::'b) (Exit::'b) a; knd a = Q↩⇘p⇙f; (p, ins, outs) ∈ set (procs::('f × 'c list × 'c list) list); V ∈ set outs⟧ ⟹ V ∈ lift_Use (Use::'b ⇒ 'c set) Entry Exit (H::'c set) (L::'c set) (src a)› 9. ‹⋀(a::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node) (V::'c) s::(('c ⇒ 'd option) × 'e) list. ⟦lift_valid_edge (valid_edge::'a ⇒ bool) (sourcenode::'a ⇒ 'b) (targetnode::'a ⇒ 'b) (kind::'a ⇒ ('c, 'd, 'e, 'f) edge_kind) (Entry::'b) (Exit::'b) a; V ∉ lift_Def (Def::'b ⇒ 'c set) Entry Exit (H::'c set) (L::'c set) (src a); intra_kind (knd a); local.CFG.pred (knd a) s⟧ ⟹ local.CFG.state_val (local.CFG.transfer (knd a) s) V = local.CFG.state_val s V› 10. ‹⋀(a::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node) (s::(('c ⇒ 'd option) × 'e) list) s'::(('c ⇒ 'd option) × 'e) list. ⟦lift_valid_edge (valid_edge::'a ⇒ bool) (sourcenode::'a ⇒ 'b) (targetnode::'a ⇒ 'b) (kind::'a ⇒ ('c, 'd, 'e, 'f) edge_kind) (Entry::'b) (Exit::'b) a; ∀V::'c∈lift_Use (Use::'b ⇒ 'c set) Entry Exit (H::'c set) (L::'c set) (src a). local.CFG.state_val s V = local.CFG.state_val s' V; intra_kind (knd a); local.CFG.pred (knd a) s; local.CFG.pred (knd a) s'⟧ ⟹ ∀V::'c∈lift_Def (Def::'b ⇒ 'c set) Entry Exit H L (src a). local.CFG.state_val (local.CFG.transfer (knd a) s) V = local.CFG.state_val (local.CFG.transfer (knd a) s') V› 11. ‹⋀(a::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node) (s::(('c ⇒ 'd option) × 'e) list) s'::(('c ⇒ 'd option) × 'e) list. ⟦lift_valid_edge (valid_edge::'a ⇒ bool) (sourcenode::'a ⇒ 'b) (targetnode::'a ⇒ 'b) (kind::'a ⇒ ('c, 'd, 'e, 'f) edge_kind) (Entry::'b) (Exit::'b) a; local.CFG.pred (knd a) s; snd (hd s) = snd (hd s'); ∀V::'c∈lift_Use (Use::'b ⇒ 'c set) Entry Exit (H::'c set) (L::'c set) (src a). local.CFG.state_val s V = local.CFG.state_val s' V; length s = length s'⟧ ⟹ local.CFG.pred (knd a) s'› 12. ‹⋀(a::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node) (Q::('c ⇒ 'd option) × 'e ⇒ bool) (r::'e) (p::'f) (fs::(('c ⇒ 'd option) ⇒ 'd option) list) (ins::'c list) outs::'c list. ⟦lift_valid_edge (valid_edge::'a ⇒ bool) (sourcenode::'a ⇒ 'b) (targetnode::'a ⇒ 'b) (kind::'a ⇒ ('c, 'd, 'e, 'f) edge_kind) (Entry::'b) (Exit::'b) a; knd a = Q:r↪⇘p⇙fs; (p, ins, outs) ∈ set (procs::('f × 'c list × 'c list) list)⟧ ⟹ length fs = length ins› 13. ‹⋀(a::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node) (Q::('c ⇒ 'd option) × 'e ⇒ bool) (r::'e) (p::'f) (fs::(('c ⇒ 'd option) ⇒ 'd option) list) (a'::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node) (Q'::('c ⇒ 'd option) × 'e ⇒ bool) (r'::'e) (p'::'f) (fs'::(('c ⇒ 'd option) ⇒ 'd option) list) s::(('c ⇒ 'd option) × 'e) list. ⟦lift_valid_edge (valid_edge::'a ⇒ bool) (sourcenode::'a ⇒ 'b) (targetnode::'a ⇒ 'b) (kind::'a ⇒ ('c, 'd, 'e, 'f) edge_kind) (Entry::'b) (Exit::'b) a; knd a = Q:r↪⇘p⇙fs; lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a'; knd a' = Q':r'↪⇘p'⇙fs'; src a = src a'; local.CFG.pred (knd a) s; local.CFG.pred (knd a') s⟧ ⟹ a = a'› 14. ‹⋀(a::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node) (Q::('c ⇒ 'd option) × 'e ⇒ bool) (r::'e) (p::'f) (fs::(('c ⇒ 'd option) ⇒ 'd option) list) (i::nat) (ins::'c list) (outs::'c list) (s::(('c ⇒ 'd option) × 'e) list) s'::(('c ⇒ 'd option) × 'e) list. ⟦lift_valid_edge (valid_edge::'a ⇒ bool) (sourcenode::'a ⇒ 'b) (targetnode::'a ⇒ 'b) (kind::'a ⇒ ('c, 'd, 'e, 'f) edge_kind) (Entry::'b) (Exit::'b) a; knd a = Q:r↪⇘p⇙fs; i < length ins; (p, ins, outs) ∈ set (procs::('f × 'c list × 'c list) list); local.CFG.pred (knd a) s; local.CFG.pred (knd a) s'; ∀V::'c∈lift_ParamUses (ParamUses::'b ⇒ 'c set list) (src a) ! i. local.CFG.state_val s V = local.CFG.state_val s' V⟧ ⟹ local.CFG.params fs (local.CFG.state_val s) ! i = local.CFG.params fs (local.CFG.state_val s') ! i› 15. ‹⋀(a::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node) (Q'::('c ⇒ 'd option) × 'e ⇒ bool) (p::'f) (f'::('c ⇒ 'd option) ⇒ ('c ⇒ 'd option) ⇒ 'c ⇒ 'd option) (ins::'c list) (outs::'c list) (vmap::'c ⇒ 'd option) vmap'::'c ⇒ 'd option. ⟦lift_valid_edge (valid_edge::'a ⇒ bool) (sourcenode::'a ⇒ 'b) (targetnode::'a ⇒ 'b) (kind::'a ⇒ ('c, 'd, 'e, 'f) edge_kind) (Entry::'b) (Exit::'b) a; knd a = Q'↩⇘p⇙f'; (p, ins, outs) ∈ set (procs::('f × 'c list × 'c list) list)⟧ ⟹ f' vmap vmap' = vmap'(lift_ParamDefs (ParamDefs::'b ⇒ 'c list) (trg a) [:=] map vmap outs)› 16. ‹⋀(a::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node) a'::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node. ⟦lift_valid_edge (valid_edge::'a ⇒ bool) (sourcenode::'a ⇒ 'b) (targetnode::'a ⇒ 'b) (kind::'a ⇒ ('c, 'd, 'e, 'f) edge_kind) (Entry::'b) (Exit::'b) a; lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a'; src a = src a'; trg a ≠ trg a'; intra_kind (knd a); intra_kind (knd a')⟧ ⟹ ∃(Q::('c ⇒ 'd option) ⇒ bool) Q'::('c ⇒ 'd option) ⇒ bool. knd a = (Q)⇩√ ∧ knd a' = (Q')⇩√ ∧ (∀s::'c ⇒ 'd option. (Q s ⟶ ¬ Q' s) ∧ (Q' s ⟶ ¬ Q s))›*) fix a and Q and r and p and fs and ins and outs assume "lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a" and "knd a = Q:r↪⇘p⇙fs" and "(p, ins, outs) ∈ set procs" (*‹lift_valid_edge (valid_edge::'a ⇒ bool) (sourcenode::'a ⇒ 'b) (targetnode::'a ⇒ 'b) (kind::'a ⇒ ('c, 'd, 'e, 'f) edge_kind) (Entry::'b) (Exit::'b) (a::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node)› ‹knd (a::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node) = Q::('c ⇒ 'd option) × 'e ⇒ bool:r::'e↪⇘p::'f⇙fs::(('c ⇒ 'd option) ⇒ 'd option) list› ‹(p::'f, ins::'c list, outs::'c list) ∈ set (procs::('f × 'c list × 'c list) list)›*) thus "length (lift_ParamUses ParamUses (src a)) = length ins" proof (induct rule:lift_valid_edge.induct (*‹⟦lift_valid_edge (?valid_edge::?'edge ⇒ bool) (?src::?'edge ⇒ ?'node) (?trg::?'edge ⇒ ?'node) (?knd::?'edge ⇒ (?'var, ?'val, ?'ret, ?'pname) edge_kind) (?E::?'node) (?X::?'node) (?x::?'node LDCFG_node × (?'var, ?'val, ?'ret, ?'pname) edge_kind × ?'node LDCFG_node); ⋀(a::?'edge) e::?'node LDCFG_node × (?'var, ?'val, ?'ret, ?'pname) edge_kind × ?'node LDCFG_node. ⟦?valid_edge a; ?src a ≠ ?E ∨ ?trg a ≠ ?X; e = (Node (?src a), ?knd a, Node (?trg a))⟧ ⟹ (?P::?'node LDCFG_node × (?'var, ?'val, ?'ret, ?'pname) edge_kind × ?'node LDCFG_node ⇒ bool) e; ⋀e::?'node LDCFG_node × (?'var, ?'val, ?'ret, ?'pname) edge_kind × ?'node LDCFG_node. e = (NewEntry, (λs::?'var ⇒ ?'val option. True)⇩√, Node ?E) ⟹ ?P e; ⋀e::?'node LDCFG_node × (?'var, ?'val, ?'ret, ?'pname) edge_kind × ?'node LDCFG_node. e = (Node ?X, (λs::?'var ⇒ ?'val option. True)⇩√, NewExit) ⟹ ?P e; ⋀e::?'node LDCFG_node × (?'var, ?'val, ?'ret, ?'pname) edge_kind × ?'node LDCFG_node. e = (NewEntry, (λs::?'var ⇒ ?'val option. False)⇩√, NewExit) ⟹ ?P e⟧ ⟹ ?P ?x›*)) (*goals: 1. ‹⋀a e. ⟦valid_edge a; sourcenode a ≠ Entry ∨ targetnode a ≠ Exit; e = (Node (sourcenode a), kind a, Node (targetnode a)); knd e = Q:r↪⇘p⇙fs; (p, ins, outs) ∈ set procs⟧ ⟹ length (lift_ParamUses ParamUses (src e)) = length ins› 2. ‹⋀e. ⟦e = (NewEntry, (λs. True)⇩√, Node Entry); knd e = Q:r↪⇘p⇙fs; (p, ins, outs) ∈ set procs⟧ ⟹ length (lift_ParamUses ParamUses (src e)) = length ins› 3. ‹⋀e. ⟦e = (Node Exit, (λs. True)⇩√, NewExit); knd e = Q:r↪⇘p⇙fs; (p, ins, outs) ∈ set procs⟧ ⟹ length (lift_ParamUses ParamUses (src e)) = length ins› 4. ‹⋀e. ⟦e = (NewEntry, (λs. False)⇩√, NewExit); knd e = Q:r↪⇘p⇙fs; (p, ins, outs) ∈ set procs⟧ ⟹ length (lift_ParamUses ParamUses (src e)) = length ins›*) case (lve_edge a e) (*‹valid_edge a› ‹sourcenode a ≠ Entry ∨ targetnode a ≠ Exit› ‹e = (Node (sourcenode a), kind a, Node (targetnode a))› ‹knd (e::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node) = Q::('c ⇒ 'd option) × 'e ⇒ bool:r::'e↪⇘p::'f⇙fs::(('c ⇒ 'd option) ⇒ 'd option) list› ‹(p::'f, ins::'c list, outs::'c list) ∈ set (procs::('f × 'c list × 'c list) list)›*) from ‹e = (Node (sourcenode a), kind a, Node (targetnode a))› (*‹(e::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node) = (Node ((sourcenode::'a ⇒ 'b) (a::'a)), (kind::'a ⇒ ('c, 'd, 'e, 'f) edge_kind) a, Node ((targetnode::'a ⇒ 'b) a))›*) ‹knd e = Q:r↪⇘p⇙fs› (*‹knd e = Q:r↪⇘p⇙fs›*) have "kind a = Q:r↪⇘p⇙fs" and "src e = Node (sourcenode a)" apply - (*goals: 1. ‹⟦e = (Node (sourcenode a), kind a, Node (targetnode a)); knd e = Q:r↪⇘p⇙fs⟧ ⟹ kind a = Q:r↪⇘p⇙fs› 2. ‹⟦e = (Node (sourcenode a), kind a, Node (targetnode a)); knd e = Q:r↪⇘p⇙fs⟧ ⟹ src e = Node (sourcenode a)› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) . with ‹valid_edge a› (*‹valid_edge a›*) ‹(p,ins,outs) ∈ set procs› (*‹(p, ins, outs) ∈ set procs›*) have "length(ParamUses (sourcenode a)) = length ins" apply - (*goal: ‹length (ParamUses (sourcenode a)) = length ins›*) apply (rule ParamUses_call_source_length (*‹⟦(valid_edge::'a ⇒ bool) (?a::'a); (kind::'a ⇒ ('c, 'd, 'e, 'f) edge_kind) ?a = ?Q::('c ⇒ 'd option) × 'e ⇒ bool:?r::'e↪⇘?p::'f⇙?fs::(('c ⇒ 'd option) ⇒ 'd option) list; (?p, ?ins::'c list, ?outs::'c list) ∈ set (procs::('f × 'c list × 'c list) list)⟧ ⟹ length ((ParamUses::'b ⇒ 'c set list) ((sourcenode::'a ⇒ 'b) ?a)) = length ?ins›*)) (*goals: 1. ‹⟦valid_edge a; (p, ins, outs) ∈ set procs; kind a = Q:r↪⇘p⇙fs; src e = Node (sourcenode a)⟧ ⟹ valid_edge a› 2. ‹⟦valid_edge a; (p, ins, outs) ∈ set procs; kind a = Q:r↪⇘p⇙fs; src e = Node (sourcenode a)⟧ ⟹ kind a = ?Q4:?r4↪⇘?p4⇙?fs4› 3. ‹⟦valid_edge a; (p, ins, outs) ∈ set procs; kind a = Q:r↪⇘p⇙fs; src e = Node (sourcenode a)⟧ ⟹ (?p4, ins, ?outs4) ∈ set procs› discuss goal 1*) apply ((assumption)[1]) (*discuss goal 2*) apply ((assumption)[1]) (*discuss goal 3*) . (*proven 3 subgoals*) with ‹src e = Node (sourcenode a)› (*‹src (e::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node) = Node ((sourcenode::'a ⇒ 'b) (a::'a))›*) show "?case" (*goal: ‹length (lift_ParamUses ParamUses (src e)) = length ins›*) by simp qed (simp_all) (*solves the remaining goals: 1. ‹⋀e. ⟦e = (NewEntry, (λs. True)⇩√, Node Entry); knd e = Q:r↪⇘p⇙fs; (p, ins, outs) ∈ set procs⟧ ⟹ length (lift_ParamUses ParamUses (src e)) = length ins› 2. ‹⋀e. ⟦e = (Node Exit, (λs. True)⇩√, NewExit); knd e = Q:r↪⇘p⇙fs; (p, ins, outs) ∈ set procs⟧ ⟹ length (lift_ParamUses ParamUses (src e)) = length ins› 3. ‹⋀e. ⟦e = (NewEntry, (λs. False)⇩√, NewExit); knd e = Q:r↪⇘p⇙fs; (p, ins, outs) ∈ set procs⟧ ⟹ length (lift_ParamUses ParamUses (src e)) = length ins›*) next (*goals: 1. ‹⋀a. lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a ⟹ distinct (lift_ParamDefs ParamDefs (trg a))› 2. ‹⋀a Q' p f' ins outs. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q'↩⇘p⇙f'; (p, ins, outs) ∈ set procs⟧ ⟹ length (lift_ParamDefs ParamDefs (trg a)) = length outs› 3. ‹⋀n V. ⟦local.CFG.valid_node n; V ∈ set (lift_ParamDefs ParamDefs n)⟧ ⟹ V ∈ lift_Def Def Entry Exit H L n› 4. ‹⋀a Q r p fs ins outs V. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q:r↪⇘p⇙fs; (p, ins, outs) ∈ set procs; V ∈ set ins⟧ ⟹ V ∈ lift_Def Def Entry Exit H L (trg a)› 5. ‹⋀a Q r p fs. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q:r↪⇘p⇙fs⟧ ⟹ lift_Def Def Entry Exit H L (src a) = {}› 6. ‹⋀n V. ⟦local.CFG.valid_node n; V ∈ ⋃ (set (lift_ParamUses ParamUses n))⟧ ⟹ V ∈ lift_Use Use Entry Exit H L n› 7. ‹⋀a Q p f ins outs V. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q↩⇘p⇙f; (p, ins, outs) ∈ set procs; V ∈ set outs⟧ ⟹ V ∈ lift_Use Use Entry Exit H L (src a)› 8. ‹⋀a V s. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; V ∉ lift_Def Def Entry Exit H L (src a); intra_kind (knd a); local.CFG.pred (knd a) s⟧ ⟹ local.CFG.state_val (local.CFG.transfer (knd a) s) V = local.CFG.state_val s V› 9. ‹⋀a s s'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; ∀V∈lift_Use Use Entry Exit H L (src a). local.CFG.state_val s V = local.CFG.state_val s' V; intra_kind (knd a); local.CFG.pred (knd a) s; local.CFG.pred (knd a) s'⟧ ⟹ ∀V∈lift_Def Def Entry Exit H L (src a). local.CFG.state_val (local.CFG.transfer (knd a) s) V = local.CFG.state_val (local.CFG.transfer (knd a) s') V› 10. ‹⋀a s s'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; local.CFG.pred (knd a) s; snd (hd s) = snd (hd s'); ∀V∈lift_Use Use Entry Exit H L (src a). local.CFG.state_val s V = local.CFG.state_val s' V; length s = length s'⟧ ⟹ local.CFG.pred (knd a) s'› 11. ‹⋀a Q r p fs ins outs. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q:r↪⇘p⇙fs; (p, ins, outs) ∈ set procs⟧ ⟹ length fs = length ins› 12. ‹⋀a Q r p fs a' Q' r' p' fs' s. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q:r↪⇘p⇙fs; lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a'; knd a' = Q':r'↪⇘p'⇙fs'; src a = src a'; local.CFG.pred (knd a) s; local.CFG.pred (knd a') s⟧ ⟹ a = a'› 13. ‹⋀a Q r p fs i ins outs s s'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q:r↪⇘p⇙fs; i < length ins; (p, ins, outs) ∈ set procs; local.CFG.pred (knd a) s; local.CFG.pred (knd a) s'; ∀V∈lift_ParamUses ParamUses (src a) ! i. local.CFG.state_val s V = local.CFG.state_val s' V⟧ ⟹ local.CFG.params fs (local.CFG.state_val s) ! i = local.CFG.params fs (local.CFG.state_val s') ! i› 14. ‹⋀a Q' p f' ins outs vmap vmap'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q'↩⇘p⇙f'; (p, ins, outs) ∈ set procs⟧ ⟹ f' vmap vmap' = vmap'(lift_ParamDefs ParamDefs (trg a) [:=] map vmap outs)› 15. ‹⋀a a'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a'; src a = src a'; trg a ≠ trg a'; intra_kind (knd a); intra_kind (knd a')⟧ ⟹ ∃Q Q'. knd a = (Q)⇩√ ∧ knd a' = (Q')⇩√ ∧ (∀s. (Q s ⟶ ¬ Q' s) ∧ (Q' s ⟶ ¬ Q s))›*) fix a assume "lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a" (*‹lift_valid_edge (valid_edge::'a ⇒ bool) (sourcenode::'a ⇒ 'b) (targetnode::'a ⇒ 'b) (kind::'a ⇒ ('c, 'd, 'e, 'f) edge_kind) (Entry::'b) (Exit::'b) (a::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node)›*) thus "distinct (lift_ParamDefs ParamDefs (trg a))" proof (induct rule:lift_valid_edge.induct (*‹⟦lift_valid_edge ?valid_edge ?src ?trg ?knd ?E ?X ?x; ⋀a e. ⟦?valid_edge a; ?src a ≠ ?E ∨ ?trg a ≠ ?X; e = (Node (?src a), ?knd a, Node (?trg a))⟧ ⟹ ?P e; ⋀e. e = (NewEntry, (λs. True)⇩√, Node ?E) ⟹ ?P e; ⋀e. e = (Node ?X, (λs. True)⇩√, NewExit) ⟹ ?P e; ⋀e. e = (NewEntry, (λs. False)⇩√, NewExit) ⟹ ?P e⟧ ⟹ ?P ?x›*)) (*goals: 1. ‹⋀a e. ⟦valid_edge a; sourcenode a ≠ Entry ∨ targetnode a ≠ Exit; e = (Node (sourcenode a), kind a, Node (targetnode a))⟧ ⟹ distinct (lift_ParamDefs ParamDefs (trg e))› 2. ‹⋀e. e = (NewEntry, (λs. True)⇩√, Node Entry) ⟹ distinct (lift_ParamDefs ParamDefs (trg e))› 3. ‹⋀e. e = (Node Exit, (λs. True)⇩√, NewExit) ⟹ distinct (lift_ParamDefs ParamDefs (trg e))› 4. ‹⋀e. e = (NewEntry, (λs. False)⇩√, NewExit) ⟹ distinct (lift_ParamDefs ParamDefs (trg e))›*) case (lve_edge a e) (*‹valid_edge a› ‹sourcenode a ≠ Entry ∨ targetnode a ≠ Exit› ‹e = (Node (sourcenode a), kind a, Node (targetnode a))›*) from ‹valid_edge a› (*‹valid_edge a›*) have "distinct (ParamDefs (targetnode a))" by (rule distinct_ParamDefs (*‹valid_edge ?a ⟹ distinct (ParamDefs (targetnode ?a))›*)) with ‹e = (Node (sourcenode a), kind a, Node (targetnode a))› (*‹e = (Node (sourcenode a), kind a, Node (targetnode a))›*) show "?case" (*goal: ‹distinct (lift_ParamDefs (ParamDefs::'b ⇒ 'c list) (trg (e::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node)))›*) by simp next (*goals: 1. ‹⋀e. e = (NewEntry, (λs. True)⇩√, Node Entry) ⟹ distinct (lift_ParamDefs ParamDefs (trg e))› 2. ‹⋀e. e = (Node Exit, (λs. True)⇩√, NewExit) ⟹ distinct (lift_ParamDefs ParamDefs (trg e))› 3. ‹⋀e. e = (NewEntry, (λs. False)⇩√, NewExit) ⟹ distinct (lift_ParamDefs ParamDefs (trg e))›*) case (lve_Entry_edge e) (*‹e = (NewEntry, (λs. True)⇩√, Node Entry)›*) have "ParamDefs Entry = []" proof (rule ccontr (*‹(¬ ?P ⟹ False) ⟹ ?P›*)) (*goal: ‹(ParamDefs::'b ⇒ 'c list) (Entry::'b) ≠ [] ⟹ False›*) assume "ParamDefs Entry ≠ []" (*‹(ParamDefs::'b ⇒ 'c list) (Entry::'b) ≠ []›*) then obtain V and Vs where "ParamDefs Entry = V#Vs" (*goal: ‹(⋀V Vs. ParamDefs Entry = V # Vs ⟹ thesis) ⟹ thesis›*) apply (cases "ParamDefs Entry") (*goals: 1. ‹⟦⋀V Vs. ParamDefs Entry = V # Vs ⟹ thesis; ParamDefs Entry ≠ []; ParamDefs Entry = []⟧ ⟹ thesis› 2. ‹⋀a list. ⟦⋀V Vs. ParamDefs Entry = V # Vs ⟹ thesis; ParamDefs Entry ≠ []; ParamDefs Entry = a # list⟧ ⟹ thesis› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . hence "V ∈ set (ParamDefs Entry)" by fastforce hence "V ∈ Def Entry" by (fastforce intro:ParamDefs_in_Def (*‹⟦valid_node (?n::'b::type); (?V::'c::type) ∈ set ((ParamDefs::'b::type ⇒ 'c::type list) ?n)⟧ ⟹ ?V ∈ (Def::'b::type ⇒ 'c::type set) ?n›*)) with Entry_empty (*‹Def Entry = {} ∧ Use Entry = {}›*) show False by simp qed with ‹e = (NewEntry, (λs. True)⇩√, Node Entry)› (*‹e = (NewEntry, (λs. True)⇩√, Node Entry)›*) show "?case" (*goal: ‹distinct (lift_ParamDefs (ParamDefs::'b ⇒ 'c list) (trg (e::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node)))›*) by simp qed (simp_all) (*solves the remaining goals: 1. ‹⋀e. e = (Node Exit, (λs. True)⇩√, NewExit) ⟹ distinct (lift_ParamDefs ParamDefs (trg e))› 2. ‹⋀e. e = (NewEntry, (λs. False)⇩√, NewExit) ⟹ distinct (lift_ParamDefs ParamDefs (trg e))›*) next (*goals: 1. ‹⋀a Q' p f' ins outs. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q'↩⇘p⇙f'; (p, ins, outs) ∈ set procs⟧ ⟹ length (lift_ParamDefs ParamDefs (trg a)) = length outs› 2. ‹⋀n V. ⟦local.CFG.valid_node n; V ∈ set (lift_ParamDefs ParamDefs n)⟧ ⟹ V ∈ lift_Def Def Entry Exit H L n› 3. ‹⋀a Q r p fs ins outs V. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q:r↪⇘p⇙fs; (p, ins, outs) ∈ set procs; V ∈ set ins⟧ ⟹ V ∈ lift_Def Def Entry Exit H L (trg a)› 4. ‹⋀a Q r p fs. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q:r↪⇘p⇙fs⟧ ⟹ lift_Def Def Entry Exit H L (src a) = {}› 5. ‹⋀n V. ⟦local.CFG.valid_node n; V ∈ ⋃ (set (lift_ParamUses ParamUses n))⟧ ⟹ V ∈ lift_Use Use Entry Exit H L n› 6. ‹⋀a Q p f ins outs V. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q↩⇘p⇙f; (p, ins, outs) ∈ set procs; V ∈ set outs⟧ ⟹ V ∈ lift_Use Use Entry Exit H L (src a)› 7. ‹⋀a V s. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; V ∉ lift_Def Def Entry Exit H L (src a); intra_kind (knd a); local.CFG.pred (knd a) s⟧ ⟹ local.CFG.state_val (local.CFG.transfer (knd a) s) V = local.CFG.state_val s V› 8. ‹⋀a s s'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; ∀V∈lift_Use Use Entry Exit H L (src a). local.CFG.state_val s V = local.CFG.state_val s' V; intra_kind (knd a); local.CFG.pred (knd a) s; local.CFG.pred (knd a) s'⟧ ⟹ ∀V∈lift_Def Def Entry Exit H L (src a). local.CFG.state_val (local.CFG.transfer (knd a) s) V = local.CFG.state_val (local.CFG.transfer (knd a) s') V› 9. ‹⋀a s s'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; local.CFG.pred (knd a) s; snd (hd s) = snd (hd s'); ∀V∈lift_Use Use Entry Exit H L (src a). local.CFG.state_val s V = local.CFG.state_val s' V; length s = length s'⟧ ⟹ local.CFG.pred (knd a) s'› 10. ‹⋀a Q r p fs ins outs. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q:r↪⇘p⇙fs; (p, ins, outs) ∈ set procs⟧ ⟹ length fs = length ins› 11. ‹⋀a Q r p fs a' Q' r' p' fs' s. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q:r↪⇘p⇙fs; lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a'; knd a' = Q':r'↪⇘p'⇙fs'; src a = src a'; local.CFG.pred (knd a) s; local.CFG.pred (knd a') s⟧ ⟹ a = a'› 12. ‹⋀a Q r p fs i ins outs s s'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q:r↪⇘p⇙fs; i < length ins; (p, ins, outs) ∈ set procs; local.CFG.pred (knd a) s; local.CFG.pred (knd a) s'; ∀V∈lift_ParamUses ParamUses (src a) ! i. local.CFG.state_val s V = local.CFG.state_val s' V⟧ ⟹ local.CFG.params fs (local.CFG.state_val s) ! i = local.CFG.params fs (local.CFG.state_val s') ! i› 13. ‹⋀a Q' p f' ins outs vmap vmap'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q'↩⇘p⇙f'; (p, ins, outs) ∈ set procs⟧ ⟹ f' vmap vmap' = vmap'(lift_ParamDefs ParamDefs (trg a) [:=] map vmap outs)› 14. ‹⋀a a'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a'; src a = src a'; trg a ≠ trg a'; intra_kind (knd a); intra_kind (knd a')⟧ ⟹ ∃Q Q'. knd a = (Q)⇩√ ∧ knd a' = (Q')⇩√ ∧ (∀s. (Q s ⟶ ¬ Q' s) ∧ (Q' s ⟶ ¬ Q s))›*) fix a and Q' and p and f' and ins and outs assume "lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a" and "knd a = Q'↩⇘p⇙f'" and "(p, ins, outs) ∈ set procs" (*‹lift_valid_edge (valid_edge::'a ⇒ bool) (sourcenode::'a ⇒ 'b) (targetnode::'a ⇒ 'b) (kind::'a ⇒ ('c, 'd, 'e, 'f) edge_kind) (Entry::'b) (Exit::'b) (a::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node)› ‹knd (a::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node) = Q'::('c ⇒ 'd option) × 'e ⇒ bool↩⇘p::'f⇙f'::('c ⇒ 'd option) ⇒ ('c ⇒ 'd option) ⇒ 'c ⇒ 'd option› ‹(p::'f, ins::'c list, outs::'c list) ∈ set (procs::('f × 'c list × 'c list) list)›*) thus "length (lift_ParamDefs ParamDefs (trg a)) = length outs" proof (induct rule:lift_valid_edge.induct (*‹⟦lift_valid_edge ?valid_edge ?src ?trg ?knd ?E ?X ?x; ⋀a e. ⟦?valid_edge a; ?src a ≠ ?E ∨ ?trg a ≠ ?X; e = (Node (?src a), ?knd a, Node (?trg a))⟧ ⟹ ?P e; ⋀e. e = (NewEntry, (λs. True)⇩√, Node ?E) ⟹ ?P e; ⋀e. e = (Node ?X, (λs. True)⇩√, NewExit) ⟹ ?P e; ⋀e. e = (NewEntry, (λs. False)⇩√, NewExit) ⟹ ?P e⟧ ⟹ ?P ?x›*)) (*goals: 1. ‹⋀a e. ⟦valid_edge a; sourcenode a ≠ Entry ∨ targetnode a ≠ Exit; e = (Node (sourcenode a), kind a, Node (targetnode a)); knd e = Q'↩⇘p⇙f'; (p, ins, outs) ∈ set procs⟧ ⟹ length (lift_ParamDefs ParamDefs (trg e)) = length outs› 2. ‹⋀e. ⟦e = (NewEntry, (λs. True)⇩√, Node Entry); knd e = Q'↩⇘p⇙f'; (p, ins, outs) ∈ set procs⟧ ⟹ length (lift_ParamDefs ParamDefs (trg e)) = length outs› 3. ‹⋀e. ⟦e = (Node Exit, (λs. True)⇩√, NewExit); knd e = Q'↩⇘p⇙f'; (p, ins, outs) ∈ set procs⟧ ⟹ length (lift_ParamDefs ParamDefs (trg e)) = length outs› 4. ‹⋀e. ⟦e = (NewEntry, (λs. False)⇩√, NewExit); knd e = Q'↩⇘p⇙f'; (p, ins, outs) ∈ set procs⟧ ⟹ length (lift_ParamDefs ParamDefs (trg e)) = length outs›*) case (lve_edge a e) (*‹valid_edge a› ‹sourcenode a ≠ Entry ∨ targetnode a ≠ Exit› ‹e = (Node (sourcenode a), kind a, Node (targetnode a))› ‹knd (e::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node) = Q'::('c ⇒ 'd option) × 'e ⇒ bool↩⇘p::'f⇙f'::('c ⇒ 'd option) ⇒ ('c ⇒ 'd option) ⇒ 'c ⇒ 'd option› ‹(p, ins, outs) ∈ set procs›*) from ‹e = (Node (sourcenode a), kind a, Node (targetnode a))› (*‹e = (Node (sourcenode a), kind a, Node (targetnode a))›*) ‹knd e = Q'↩⇘p⇙f'› (*‹knd e = Q'↩⇘p⇙f'›*) have "kind a = Q'↩⇘p⇙f'" and "trg e = Node (targetnode a)" apply - (*goals: 1. ‹⟦(e::'b::type LDCFG_node × ('c::type, 'd::type, 'e::type, 'f::type) edge_kind × 'b::type LDCFG_node) = (Node ((sourcenode::'a::type ⇒ 'b::type) (a::'a::type)), (kind::'a::type ⇒ ('c::type, 'd::type, 'e::type, 'f::type) edge_kind) a, Node ((targetnode::'a::type ⇒ 'b::type) a)); knd e = Q'::('c::type ⇒ 'd::type option) × 'e::type ⇒ bool↩⇘p::'f::type⇙f'::('c::type ⇒ 'd::type option) ⇒ ('c::type ⇒ 'd::type option) ⇒ 'c::type ⇒ 'd::type option⟧ ⟹ kind a = Q'↩⇘p⇙f'› 2. ‹⟦(e::'b::type LDCFG_node × ('c::type, 'd::type, 'e::type, 'f::type) edge_kind × 'b::type LDCFG_node) = (Node ((sourcenode::'a::type ⇒ 'b::type) (a::'a::type)), (kind::'a::type ⇒ ('c::type, 'd::type, 'e::type, 'f::type) edge_kind) a, Node ((targetnode::'a::type ⇒ 'b::type) a)); knd e = Q'::('c::type ⇒ 'd::type option) × 'e::type ⇒ bool↩⇘p::'f::type⇙f'::('c::type ⇒ 'd::type option) ⇒ ('c::type ⇒ 'd::type option) ⇒ 'c::type ⇒ 'd::type option⟧ ⟹ trg e = Node (targetnode a)› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) . with ‹valid_edge a› (*‹valid_edge a›*) ‹(p,ins,outs) ∈ set procs› (*‹(p, ins, outs) ∈ set procs›*) have "length(ParamDefs (targetnode a)) = length outs" apply - (*goal: ‹length (ParamDefs (targetnode a)) = length outs›*) apply (rule ParamDefs_return_target_length (*‹⟦valid_edge ?a; kind ?a = ?Q'↩⇘?p⇙?f'; (?p, ?ins, ?outs) ∈ set procs⟧ ⟹ length (ParamDefs (targetnode ?a)) = length ?outs›*)) (*goals: 1. ‹⟦valid_edge a; (p, ins, outs) ∈ set procs; kind a = Q'↩⇘p⇙f'; trg e = Node (targetnode a)⟧ ⟹ valid_edge a› 2. ‹⟦valid_edge a; (p, ins, outs) ∈ set procs; kind a = Q'↩⇘p⇙f'; trg e = Node (targetnode a)⟧ ⟹ kind a = ?Q'4↩⇘?p4⇙?f'4› 3. ‹⟦valid_edge a; (p, ins, outs) ∈ set procs; kind a = Q'↩⇘p⇙f'; trg e = Node (targetnode a)⟧ ⟹ (?p4, ?ins4, outs) ∈ set procs› discuss goal 1*) apply ((assumption)[1]) (*discuss goal 2*) apply ((assumption)[1]) (*discuss goal 3*) . (*proven 3 subgoals*) with ‹trg e = Node (targetnode a)› (*‹trg e = Node (targetnode a)›*) show "?case" (*goal: ‹length (lift_ParamDefs ParamDefs (trg e)) = length outs›*) by simp qed (simp_all) (*solves the remaining goals: 1. ‹⋀e::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node. ⟦e = (NewEntry, (λs::'c ⇒ 'd option. True)⇩√, Node (Entry::'b)); knd e = Q'::('c ⇒ 'd option) × 'e ⇒ bool↩⇘p::'f⇙f'::('c ⇒ 'd option) ⇒ ('c ⇒ 'd option) ⇒ 'c ⇒ 'd option; (p, ins::'c list, outs::'c list) ∈ set (procs::('f × 'c list × 'c list) list)⟧ ⟹ length (lift_ParamDefs (ParamDefs::'b ⇒ 'c list) (trg e)) = length outs› 2. ‹⋀e::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node. ⟦e = (Node (Exit::'b), (λs::'c ⇒ 'd option. True)⇩√, NewExit); knd e = Q'::('c ⇒ 'd option) × 'e ⇒ bool↩⇘p::'f⇙f'::('c ⇒ 'd option) ⇒ ('c ⇒ 'd option) ⇒ 'c ⇒ 'd option; (p, ins::'c list, outs::'c list) ∈ set (procs::('f × 'c list × 'c list) list)⟧ ⟹ length (lift_ParamDefs (ParamDefs::'b ⇒ 'c list) (trg e)) = length outs› 3. ‹⋀e::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node. ⟦e = (NewEntry, (λs::'c ⇒ 'd option. False)⇩√, NewExit); knd e = Q'::('c ⇒ 'd option) × 'e ⇒ bool↩⇘p::'f⇙f'::('c ⇒ 'd option) ⇒ ('c ⇒ 'd option) ⇒ 'c ⇒ 'd option; (p, ins::'c list, outs::'c list) ∈ set (procs::('f × 'c list × 'c list) list)⟧ ⟹ length (lift_ParamDefs (ParamDefs::'b ⇒ 'c list) (trg e)) = length outs›*) next (*goals: 1. ‹⋀n V. ⟦local.CFG.valid_node n; V ∈ set (lift_ParamDefs ParamDefs n)⟧ ⟹ V ∈ lift_Def Def Entry Exit H L n› 2. ‹⋀a Q r p fs ins outs V. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q:r↪⇘p⇙fs; (p, ins, outs) ∈ set procs; V ∈ set ins⟧ ⟹ V ∈ lift_Def Def Entry Exit H L (trg a)› 3. ‹⋀a Q r p fs. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q:r↪⇘p⇙fs⟧ ⟹ lift_Def Def Entry Exit H L (src a) = {}› 4. ‹⋀n V. ⟦local.CFG.valid_node n; V ∈ ⋃ (set (lift_ParamUses ParamUses n))⟧ ⟹ V ∈ lift_Use Use Entry Exit H L n› 5. ‹⋀a Q p f ins outs V. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q↩⇘p⇙f; (p, ins, outs) ∈ set procs; V ∈ set outs⟧ ⟹ V ∈ lift_Use Use Entry Exit H L (src a)› 6. ‹⋀a V s. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; V ∉ lift_Def Def Entry Exit H L (src a); intra_kind (knd a); local.CFG.pred (knd a) s⟧ ⟹ local.CFG.state_val (local.CFG.transfer (knd a) s) V = local.CFG.state_val s V› 7. ‹⋀a s s'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; ∀V∈lift_Use Use Entry Exit H L (src a). local.CFG.state_val s V = local.CFG.state_val s' V; intra_kind (knd a); local.CFG.pred (knd a) s; local.CFG.pred (knd a) s'⟧ ⟹ ∀V∈lift_Def Def Entry Exit H L (src a). local.CFG.state_val (local.CFG.transfer (knd a) s) V = local.CFG.state_val (local.CFG.transfer (knd a) s') V› 8. ‹⋀a s s'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; local.CFG.pred (knd a) s; snd (hd s) = snd (hd s'); ∀V∈lift_Use Use Entry Exit H L (src a). local.CFG.state_val s V = local.CFG.state_val s' V; length s = length s'⟧ ⟹ local.CFG.pred (knd a) s'› 9. ‹⋀a Q r p fs ins outs. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q:r↪⇘p⇙fs; (p, ins, outs) ∈ set procs⟧ ⟹ length fs = length ins› 10. ‹⋀a Q r p fs a' Q' r' p' fs' s. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q:r↪⇘p⇙fs; lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a'; knd a' = Q':r'↪⇘p'⇙fs'; src a = src a'; local.CFG.pred (knd a) s; local.CFG.pred (knd a') s⟧ ⟹ a = a'› 11. ‹⋀a Q r p fs i ins outs s s'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q:r↪⇘p⇙fs; i < length ins; (p, ins, outs) ∈ set procs; local.CFG.pred (knd a) s; local.CFG.pred (knd a) s'; ∀V∈lift_ParamUses ParamUses (src a) ! i. local.CFG.state_val s V = local.CFG.state_val s' V⟧ ⟹ local.CFG.params fs (local.CFG.state_val s) ! i = local.CFG.params fs (local.CFG.state_val s') ! i› 12. ‹⋀a Q' p f' ins outs vmap vmap'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q'↩⇘p⇙f'; (p, ins, outs) ∈ set procs⟧ ⟹ f' vmap vmap' = vmap'(lift_ParamDefs ParamDefs (trg a) [:=] map vmap outs)› 13. ‹⋀a a'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a'; src a = src a'; trg a ≠ trg a'; intra_kind (knd a); intra_kind (knd a')⟧ ⟹ ∃Q Q'. knd a = (Q)⇩√ ∧ knd a' = (Q')⇩√ ∧ (∀s. (Q s ⟶ ¬ Q' s) ∧ (Q' s ⟶ ¬ Q s))›*) fix n and V assume "CFG.CFG.valid_node src trg (lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit) n" and "V ∈ set (lift_ParamDefs ParamDefs n)" (*‹local.CFG.valid_node (n::'b LDCFG_node)› ‹(V::'c) ∈ set (lift_ParamDefs (ParamDefs::'b ⇒ 'c list) (n::'b LDCFG_node))›*) hence "((n = NewEntry) ∨ n = NewExit) ∨ (∃m. n = Node m ∧ valid_node m)" by (auto elim:lift_valid_edge.cases (*‹⟦lift_valid_edge (?valid_edge::?'edge ⇒ bool) (?src::?'edge ⇒ ?'node) (?trg::?'edge ⇒ ?'node) (?knd::?'edge ⇒ (?'var, ?'val, ?'ret, ?'pname) edge_kind) (?E::?'node) (?X::?'node) (?a::?'node LDCFG_node × (?'var, ?'val, ?'ret, ?'pname) edge_kind × ?'node LDCFG_node); ⋀(a::?'edge) e::?'node LDCFG_node × (?'var, ?'val, ?'ret, ?'pname) edge_kind × ?'node LDCFG_node. ⟦?a = e; ?valid_edge a; ?src a ≠ ?E ∨ ?trg a ≠ ?X; e = (Node (?src a), ?knd a, Node (?trg a))⟧ ⟹ ?P::bool; ⋀e::?'node LDCFG_node × (?'var, ?'val, ?'ret, ?'pname) edge_kind × ?'node LDCFG_node. ⟦?a = e; e = (NewEntry, (λs::?'var ⇒ ?'val option. True)⇩√, Node ?E)⟧ ⟹ ?P; ⋀e::?'node LDCFG_node × (?'var, ?'val, ?'ret, ?'pname) edge_kind × ?'node LDCFG_node. ⟦?a = e; e = (Node ?X, (λs::?'var ⇒ ?'val option. True)⇩√, NewExit)⟧ ⟹ ?P; ⋀e::?'node LDCFG_node × (?'var, ?'val, ?'ret, ?'pname) edge_kind × ?'node LDCFG_node. ⟦?a = e; e = (NewEntry, (λs::?'var ⇒ ?'val option. False)⇩√, NewExit)⟧ ⟹ ?P⟧ ⟹ ?P›*) simp:CFG.valid_node_def (*‹local.CFG.valid_node (?n::'b LDCFG_node) ≡ ∃a::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node. lift_valid_edge (valid_edge::'a ⇒ bool) (sourcenode::'a ⇒ 'b) (targetnode::'a ⇒ 'b) (kind::'a ⇒ ('c, 'd, 'e, 'f) edge_kind) (Entry::'b) (Exit::'b) a ∧ (?n = src a ∨ ?n = trg a)›*)) thus "V ∈ lift_Def Def Entry Exit H L n" apply - (*goal: ‹V ∈ lift_Def Def Entry Exit H L n›*) proof ((erule disjE (*‹⟦?P ∨ ?Q; ?P ⟹ ?R; ?Q ⟹ ?R⟧ ⟹ ?R›*))+) (*goals: 1. ‹n = NewEntry ⟹ V ∈ lift_Def Def Entry Exit H L n› 2. ‹n = NewExit ⟹ V ∈ lift_Def Def Entry Exit H L n› 3. ‹∃m. n = Node m ∧ valid_node m ⟹ V ∈ lift_Def Def Entry Exit H L n›*) assume "n = NewEntry" (*‹(n::'b LDCFG_node) = NewEntry›*) with ‹V ∈ set (lift_ParamDefs ParamDefs n)› (*‹V ∈ set (lift_ParamDefs ParamDefs n)›*) show "?thesis" (*goal: ‹V ∈ lift_Def Def Entry Exit H L n›*) by simp next (*goals: 1. ‹(n::'b LDCFG_node) = NewExit ⟹ (V::'c) ∈ lift_Def (Def::'b ⇒ 'c set) (Entry::'b) (Exit::'b) (H::'c set) (L::'c set) n› 2. ‹∃m::'b. (n::'b LDCFG_node) = Node m ∧ valid_node m ⟹ (V::'c) ∈ lift_Def (Def::'b ⇒ 'c set) (Entry::'b) (Exit::'b) (H::'c set) (L::'c set) n›*) assume "n = NewExit" (*‹(n::'b LDCFG_node) = NewExit›*) with ‹V ∈ set (lift_ParamDefs ParamDefs n)› (*‹(V::'c) ∈ set (lift_ParamDefs (ParamDefs::'b ⇒ 'c list) (n::'b LDCFG_node))›*) show "?thesis" (*goal: ‹(V::'c) ∈ lift_Def (Def::'b ⇒ 'c set) (Entry::'b) (Exit::'b) (H::'c set) (L::'c set) (n::'b LDCFG_node)›*) by simp next (*goal: ‹∃m. n = Node m ∧ valid_node m ⟹ V ∈ lift_Def Def Entry Exit H L n›*) assume "∃m. n = Node m ∧ valid_node m" (*‹∃m::'b. (n::'b LDCFG_node) = Node m ∧ valid_node m›*) then obtain m where "n = Node m" and "valid_node m" (*goal: ‹(⋀m. ⟦n = Node m; valid_node m⟧ ⟹ thesis) ⟹ thesis›*) by blast from ‹n = Node m› (*‹n = Node m›*) ‹V ∈ set (lift_ParamDefs ParamDefs n)› (*‹V ∈ set (lift_ParamDefs ParamDefs n)›*) have "V ∈ set (ParamDefs m)" by simp with ‹valid_node m› (*‹valid_node (m::'b)›*) have "V ∈ Def m" by (rule ParamDefs_in_Def (*‹⟦valid_node ?n; ?V ∈ set (ParamDefs ?n)⟧ ⟹ ?V ∈ Def ?n›*)) with ‹n = Node m› (*‹n = Node m›*) show "?thesis" (*goal: ‹V ∈ lift_Def Def Entry Exit H L n›*) by (fastforce intro:lift_Def_node (*‹?V ∈ ?Def ?n ⟹ (Node ?n, ?V) ∈ lift_Def_set ?Def ?E ?X ?H ?L›*)) qed next (*goals: 1. ‹⋀(a::'b::type LDCFG_node × ('c::type, 'd::type, 'e::type, 'f::type) edge_kind × 'b::type LDCFG_node) (Q::('c::type ⇒ 'd::type option) × 'e::type ⇒ bool) (r::'e::type) (p::'f::type) (fs::(('c::type ⇒ 'd::type option) ⇒ 'd::type option) list) (ins::'c::type list) (outs::'c::type list) V::'c::type. ⟦lift_valid_edge (valid_edge::'a::type ⇒ bool) (sourcenode::'a::type ⇒ 'b::type) (targetnode::'a::type ⇒ 'b::type) (kind::'a::type ⇒ ('c::type, 'd::type, 'e::type, 'f::type) edge_kind) (Entry::'b::type) (Exit::'b::type) a; knd a = Q:r↪⇘p⇙fs; (p, ins, outs) ∈ set (procs::('f::type × 'c::type list × 'c::type list) list); V ∈ set ins⟧ ⟹ V ∈ lift_Def (Def::'b::type ⇒ 'c::type set) Entry Exit (H::'c::type set) (L::'c::type set) (trg a)› 2. ‹⋀(a::'b::type LDCFG_node × ('c::type, 'd::type, 'e::type, 'f::type) edge_kind × 'b::type LDCFG_node) (Q::('c::type ⇒ 'd::type option) × 'e::type ⇒ bool) (r::'e::type) (p::'f::type) fs::(('c::type ⇒ 'd::type option) ⇒ 'd::type option) list. ⟦lift_valid_edge (valid_edge::'a::type ⇒ bool) (sourcenode::'a::type ⇒ 'b::type) (targetnode::'a::type ⇒ 'b::type) (kind::'a::type ⇒ ('c::type, 'd::type, 'e::type, 'f::type) edge_kind) (Entry::'b::type) (Exit::'b::type) a; knd a = Q:r↪⇘p⇙fs⟧ ⟹ lift_Def (Def::'b::type ⇒ 'c::type set) Entry Exit (H::'c::type set) (L::'c::type set) (src a) = {}› 3. ‹⋀(n::'b::type LDCFG_node) V::'c::type. ⟦local.CFG.valid_node n; V ∈ ⋃ (set (lift_ParamUses (ParamUses::'b::type ⇒ 'c::type set list) n))⟧ ⟹ V ∈ lift_Use (Use::'b::type ⇒ 'c::type set) (Entry::'b::type) (Exit::'b::type) (H::'c::type set) (L::'c::type set) n› 4. ‹⋀(a::'b::type LDCFG_node × ('c::type, 'd::type, 'e::type, 'f::type) edge_kind × 'b::type LDCFG_node) (Q::('c::type ⇒ 'd::type option) × 'e::type ⇒ bool) (p::'f::type) (f::('c::type ⇒ 'd::type option) ⇒ ('c::type ⇒ 'd::type option) ⇒ 'c::type ⇒ 'd::type option) (ins::'c::type list) (outs::'c::type list) V::'c::type. ⟦lift_valid_edge (valid_edge::'a::type ⇒ bool) (sourcenode::'a::type ⇒ 'b::type) (targetnode::'a::type ⇒ 'b::type) (kind::'a::type ⇒ ('c::type, 'd::type, 'e::type, 'f::type) edge_kind) (Entry::'b::type) (Exit::'b::type) a; knd a = Q↩⇘p⇙f; (p, ins, outs) ∈ set (procs::('f::type × 'c::type list × 'c::type list) list); V ∈ set outs⟧ ⟹ V ∈ lift_Use (Use::'b::type ⇒ 'c::type set) Entry Exit (H::'c::type set) (L::'c::type set) (src a)› 5. ‹⋀(a::'b::type LDCFG_node × ('c::type, 'd::type, 'e::type, 'f::type) edge_kind × 'b::type LDCFG_node) (V::'c::type) s::(('c::type ⇒ 'd::type option) × 'e::type) list. ⟦lift_valid_edge (valid_edge::'a::type ⇒ bool) (sourcenode::'a::type ⇒ 'b::type) (targetnode::'a::type ⇒ 'b::type) (kind::'a::type ⇒ ('c::type, 'd::type, 'e::type, 'f::type) edge_kind) (Entry::'b::type) (Exit::'b::type) a; V ∉ lift_Def (Def::'b::type ⇒ 'c::type set) Entry Exit (H::'c::type set) (L::'c::type set) (src a); intra_kind (knd a); local.CFG.pred (knd a) s⟧ ⟹ local.CFG.state_val (local.CFG.transfer (knd a) s) V = local.CFG.state_val s V› 6. ‹⋀(a::'b::type LDCFG_node × ('c::type, 'd::type, 'e::type, 'f::type) edge_kind × 'b::type LDCFG_node) (s::(('c::type ⇒ 'd::type option) × 'e::type) list) s'::(('c::type ⇒ 'd::type option) × 'e::type) list. ⟦lift_valid_edge (valid_edge::'a::type ⇒ bool) (sourcenode::'a::type ⇒ 'b::type) (targetnode::'a::type ⇒ 'b::type) (kind::'a::type ⇒ ('c::type, 'd::type, 'e::type, 'f::type) edge_kind) (Entry::'b::type) (Exit::'b::type) a; ∀V::'c::type∈lift_Use (Use::'b::type ⇒ 'c::type set) Entry Exit (H::'c::type set) (L::'c::type set) (src a). local.CFG.state_val s V = local.CFG.state_val s' V; intra_kind (knd a); local.CFG.pred (knd a) s; local.CFG.pred (knd a) s'⟧ ⟹ ∀V::'c::type∈lift_Def (Def::'b::type ⇒ 'c::type set) Entry Exit H L (src a). local.CFG.state_val (local.CFG.transfer (knd a) s) V = local.CFG.state_val (local.CFG.transfer (knd a) s') V› 7. ‹⋀(a::'b::type LDCFG_node × ('c::type, 'd::type, 'e::type, 'f::type) edge_kind × 'b::type LDCFG_node) (s::(('c::type ⇒ 'd::type option) × 'e::type) list) s'::(('c::type ⇒ 'd::type option) × 'e::type) list. ⟦lift_valid_edge (valid_edge::'a::type ⇒ bool) (sourcenode::'a::type ⇒ 'b::type) (targetnode::'a::type ⇒ 'b::type) (kind::'a::type ⇒ ('c::type, 'd::type, 'e::type, 'f::type) edge_kind) (Entry::'b::type) (Exit::'b::type) a; local.CFG.pred (knd a) s; snd (hd s) = snd (hd s'); ∀V::'c::type∈lift_Use (Use::'b::type ⇒ 'c::type set) Entry Exit (H::'c::type set) (L::'c::type set) (src a). local.CFG.state_val s V = local.CFG.state_val s' V; length s = length s'⟧ ⟹ local.CFG.pred (knd a) s'› 8. ‹⋀(a::'b::type LDCFG_node × ('c::type, 'd::type, 'e::type, 'f::type) edge_kind × 'b::type LDCFG_node) (Q::('c::type ⇒ 'd::type option) × 'e::type ⇒ bool) (r::'e::type) (p::'f::type) (fs::(('c::type ⇒ 'd::type option) ⇒ 'd::type option) list) (ins::'c::type list) outs::'c::type list. ⟦lift_valid_edge (valid_edge::'a::type ⇒ bool) (sourcenode::'a::type ⇒ 'b::type) (targetnode::'a::type ⇒ 'b::type) (kind::'a::type ⇒ ('c::type, 'd::type, 'e::type, 'f::type) edge_kind) (Entry::'b::type) (Exit::'b::type) a; knd a = Q:r↪⇘p⇙fs; (p, ins, outs) ∈ set (procs::('f::type × 'c::type list × 'c::type list) list)⟧ ⟹ length fs = length ins› 9. ‹⋀(a::'b::type LDCFG_node × ('c::type, 'd::type, 'e::type, 'f::type) edge_kind × 'b::type LDCFG_node) (Q::('c::type ⇒ 'd::type option) × 'e::type ⇒ bool) (r::'e::type) (p::'f::type) (fs::(('c::type ⇒ 'd::type option) ⇒ 'd::type option) list) (a'::'b::type LDCFG_node × ('c::type, 'd::type, 'e::type, 'f::type) edge_kind × 'b::type LDCFG_node) (Q'::('c::type ⇒ 'd::type option) × 'e::type ⇒ bool) (r'::'e::type) (p'::'f::type) (fs'::(('c::type ⇒ 'd::type option) ⇒ 'd::type option) list) s::(('c::type ⇒ 'd::type option) × 'e::type) list. ⟦lift_valid_edge (valid_edge::'a::type ⇒ bool) (sourcenode::'a::type ⇒ 'b::type) (targetnode::'a::type ⇒ 'b::type) (kind::'a::type ⇒ ('c::type, 'd::type, 'e::type, 'f::type) edge_kind) (Entry::'b::type) (Exit::'b::type) a; knd a = Q:r↪⇘p⇙fs; lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a'; knd a' = Q':r'↪⇘p'⇙fs'; src a = src a'; local.CFG.pred (knd a) s; local.CFG.pred (knd a') s⟧ ⟹ a = a'› 10. ‹⋀(a::'b::type LDCFG_node × ('c::type, 'd::type, 'e::type, 'f::type) edge_kind × 'b::type LDCFG_node) (Q::('c::type ⇒ 'd::type option) × 'e::type ⇒ bool) (r::'e::type) (p::'f::type) (fs::(('c::type ⇒ 'd::type option) ⇒ 'd::type option) list) (i::nat) (ins::'c::type list) (outs::'c::type list) (s::(('c::type ⇒ 'd::type option) × 'e::type) list) s'::(('c::type ⇒ 'd::type option) × 'e::type) list. ⟦lift_valid_edge (valid_edge::'a::type ⇒ bool) (sourcenode::'a::type ⇒ 'b::type) (targetnode::'a::type ⇒ 'b::type) (kind::'a::type ⇒ ('c::type, 'd::type, 'e::type, 'f::type) edge_kind) (Entry::'b::type) (Exit::'b::type) a; knd a = Q:r↪⇘p⇙fs; i < length ins; (p, ins, outs) ∈ set (procs::('f::type × 'c::type list × 'c::type list) list); local.CFG.pred (knd a) s; local.CFG.pred (knd a) s'; ∀V::'c::type∈lift_ParamUses (ParamUses::'b::type ⇒ 'c::type set list) (src a) ! i. local.CFG.state_val s V = local.CFG.state_val s' V⟧ ⟹ local.CFG.params fs (local.CFG.state_val s) ! i = local.CFG.params fs (local.CFG.state_val s') ! i› 11. ‹⋀(a::'b::type LDCFG_node × ('c::type, 'd::type, 'e::type, 'f::type) edge_kind × 'b::type LDCFG_node) (Q'::('c::type ⇒ 'd::type option) × 'e::type ⇒ bool) (p::'f::type) (f'::('c::type ⇒ 'd::type option) ⇒ ('c::type ⇒ 'd::type option) ⇒ 'c::type ⇒ 'd::type option) (ins::'c::type list) (outs::'c::type list) (vmap::'c::type ⇒ 'd::type option) vmap'::'c::type ⇒ 'd::type option. ⟦lift_valid_edge (valid_edge::'a::type ⇒ bool) (sourcenode::'a::type ⇒ 'b::type) (targetnode::'a::type ⇒ 'b::type) (kind::'a::type ⇒ ('c::type, 'd::type, 'e::type, 'f::type) edge_kind) (Entry::'b::type) (Exit::'b::type) a; knd a = Q'↩⇘p⇙f'; (p, ins, outs) ∈ set (procs::('f::type × 'c::type list × 'c::type list) list)⟧ ⟹ f' vmap vmap' = vmap'(lift_ParamDefs (ParamDefs::'b::type ⇒ 'c::type list) (trg a) [:=] map vmap outs)› 12. ‹⋀(a::'b::type LDCFG_node × ('c::type, 'd::type, 'e::type, 'f::type) edge_kind × 'b::type LDCFG_node) a'::'b::type LDCFG_node × ('c::type, 'd::type, 'e::type, 'f::type) edge_kind × 'b::type LDCFG_node. ⟦lift_valid_edge (valid_edge::'a::type ⇒ bool) (sourcenode::'a::type ⇒ 'b::type) (targetnode::'a::type ⇒ 'b::type) (kind::'a::type ⇒ ('c::type, 'd::type, 'e::type, 'f::type) edge_kind) (Entry::'b::type) (Exit::'b::type) a; lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a'; src a = src a'; trg a ≠ trg a'; intra_kind (knd a); intra_kind (knd a')⟧ ⟹ ∃(Q::('c::type ⇒ 'd::type option) ⇒ bool) Q'::('c::type ⇒ 'd::type option) ⇒ bool. knd a = (Q)⇩√ ∧ knd a' = (Q')⇩√ ∧ (∀s::'c::type ⇒ 'd::type option. (Q s ⟶ ¬ Q' s) ∧ (Q' s ⟶ ¬ Q s))›*) fix a and Q and r and p and fs and ins and outs and V assume "lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a" and "knd a = Q:r↪⇘p⇙fs" and "(p, ins, outs) ∈ set procs" and "V ∈ set ins" (*‹lift_valid_edge (valid_edge::'a ⇒ bool) (sourcenode::'a ⇒ 'b) (targetnode::'a ⇒ 'b) (kind::'a ⇒ ('c, 'd, 'e, 'f) edge_kind) (Entry::'b) (Exit::'b) (a::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node)› ‹knd (a::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node) = Q::('c ⇒ 'd option) × 'e ⇒ bool:r::'e↪⇘p::'f⇙fs::(('c ⇒ 'd option) ⇒ 'd option) list› ‹(p::'f, ins::'c list, outs::'c list) ∈ set (procs::('f × 'c list × 'c list) list)› ‹(V::'c) ∈ set (ins::'c list)›*) thus "V ∈ lift_Def Def Entry Exit H L (trg a)" proof (induct rule:lift_valid_edge.induct (*‹⟦lift_valid_edge ?valid_edge ?src ?trg ?knd ?E ?X ?x; ⋀a e. ⟦?valid_edge a; ?src a ≠ ?E ∨ ?trg a ≠ ?X; e = (Node (?src a), ?knd a, Node (?trg a))⟧ ⟹ ?P e; ⋀e. e = (NewEntry, (λs. True)⇩√, Node ?E) ⟹ ?P e; ⋀e. e = (Node ?X, (λs. True)⇩√, NewExit) ⟹ ?P e; ⋀e. e = (NewEntry, (λs. False)⇩√, NewExit) ⟹ ?P e⟧ ⟹ ?P ?x›*)) (*goals: 1. ‹⋀a e. ⟦valid_edge a; sourcenode a ≠ Entry ∨ targetnode a ≠ Exit; e = (Node (sourcenode a), kind a, Node (targetnode a)); knd e = Q:r↪⇘p⇙fs; (p, ins, outs) ∈ set procs; V ∈ set ins⟧ ⟹ V ∈ lift_Def Def Entry Exit H L (trg e)› 2. ‹⋀e. ⟦e = (NewEntry, (λs. True)⇩√, Node Entry); knd e = Q:r↪⇘p⇙fs; (p, ins, outs) ∈ set procs; V ∈ set ins⟧ ⟹ V ∈ lift_Def Def Entry Exit H L (trg e)› 3. ‹⋀e. ⟦e = (Node Exit, (λs. True)⇩√, NewExit); knd e = Q:r↪⇘p⇙fs; (p, ins, outs) ∈ set procs; V ∈ set ins⟧ ⟹ V ∈ lift_Def Def Entry Exit H L (trg e)› 4. ‹⋀e. ⟦e = (NewEntry, (λs. False)⇩√, NewExit); knd e = Q:r↪⇘p⇙fs; (p, ins, outs) ∈ set procs; V ∈ set ins⟧ ⟹ V ∈ lift_Def Def Entry Exit H L (trg e)›*) case (lve_edge a e) (*‹valid_edge a› ‹(sourcenode::'a ⇒ 'b) (a::'a) ≠ (Entry::'b) ∨ (targetnode::'a ⇒ 'b) a ≠ (Exit::'b)› ‹e = (Node (sourcenode a), kind a, Node (targetnode a))› ‹knd e = Q:r↪⇘p⇙fs› ‹(p, ins, outs) ∈ set procs› ‹(V::'c) ∈ set (ins::'c list)›*) from ‹e = (Node (sourcenode a), kind a, Node (targetnode a))› (*‹e = (Node (sourcenode a), kind a, Node (targetnode a))›*) ‹knd e = Q:r↪⇘p⇙fs› (*‹knd e = Q:r↪⇘p⇙fs›*) have "kind a = Q:r↪⇘p⇙fs" by simp from ‹valid_edge a› (*‹valid_edge a›*) ‹kind a = Q:r↪⇘p⇙fs› (*‹kind a = Q:r↪⇘p⇙fs›*) ‹(p, ins, outs) ∈ set procs› (*‹(p, ins, outs) ∈ set procs›*) ‹V ∈ set ins› (*‹(V::'c::type) ∈ set (ins::'c::type list)›*) have "V ∈ Def (targetnode a)" by (rule ins_in_Def (*‹⟦valid_edge ?a; kind ?a = ?Q:?r↪⇘?p⇙?fs; (?p, ?ins, ?outs) ∈ set procs; ?V ∈ set ?ins⟧ ⟹ ?V ∈ Def (targetnode ?a)›*)) from ‹e = (Node (sourcenode a), kind a, Node (targetnode a))› (*‹e = (Node (sourcenode a), kind a, Node (targetnode a))›*) have "trg e = Node (targetnode a)" by simp with ‹V ∈ Def (targetnode a)› (*‹(V::'c) ∈ (Def::'b ⇒ 'c set) ((targetnode::'a ⇒ 'b) (a::'a))›*) show "?case" (*goal: ‹V ∈ lift_Def Def Entry Exit H L (trg e)›*) by (fastforce intro:lift_Def_node (*‹?V ∈ ?Def ?n ⟹ (Node ?n, ?V) ∈ lift_Def_set ?Def ?E ?X ?H ?L›*)) qed (simp_all) (*solves the remaining goals: 1. ‹⋀e. ⟦e = (NewEntry, (λs. True)⇩√, Node Entry); knd e = Q:r↪⇘p⇙fs; (p, ins, outs) ∈ set procs; V ∈ set ins⟧ ⟹ V ∈ lift_Def Def Entry Exit H L (trg e)› 2. ‹⋀e. ⟦e = (Node Exit, (λs. True)⇩√, NewExit); knd e = Q:r↪⇘p⇙fs; (p, ins, outs) ∈ set procs; V ∈ set ins⟧ ⟹ V ∈ lift_Def Def Entry Exit H L (trg e)› 3. ‹⋀e. ⟦e = (NewEntry, (λs. False)⇩√, NewExit); knd e = Q:r↪⇘p⇙fs; (p, ins, outs) ∈ set procs; V ∈ set ins⟧ ⟹ V ∈ lift_Def Def Entry Exit H L (trg e)›*) next (*goals: 1. ‹⋀a Q r p fs. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q:r↪⇘p⇙fs⟧ ⟹ lift_Def Def Entry Exit H L (src a) = {}› 2. ‹⋀n V. ⟦local.CFG.valid_node n; V ∈ ⋃ (set (lift_ParamUses ParamUses n))⟧ ⟹ V ∈ lift_Use Use Entry Exit H L n› 3. ‹⋀a Q p f ins outs V. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q↩⇘p⇙f; (p, ins, outs) ∈ set procs; V ∈ set outs⟧ ⟹ V ∈ lift_Use Use Entry Exit H L (src a)› 4. ‹⋀a V s. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; V ∉ lift_Def Def Entry Exit H L (src a); intra_kind (knd a); local.CFG.pred (knd a) s⟧ ⟹ local.CFG.state_val (local.CFG.transfer (knd a) s) V = local.CFG.state_val s V› 5. ‹⋀a s s'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; ∀V∈lift_Use Use Entry Exit H L (src a). local.CFG.state_val s V = local.CFG.state_val s' V; intra_kind (knd a); local.CFG.pred (knd a) s; local.CFG.pred (knd a) s'⟧ ⟹ ∀V∈lift_Def Def Entry Exit H L (src a). local.CFG.state_val (local.CFG.transfer (knd a) s) V = local.CFG.state_val (local.CFG.transfer (knd a) s') V› 6. ‹⋀a s s'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; local.CFG.pred (knd a) s; snd (hd s) = snd (hd s'); ∀V∈lift_Use Use Entry Exit H L (src a). local.CFG.state_val s V = local.CFG.state_val s' V; length s = length s'⟧ ⟹ local.CFG.pred (knd a) s'› 7. ‹⋀a Q r p fs ins outs. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q:r↪⇘p⇙fs; (p, ins, outs) ∈ set procs⟧ ⟹ length fs = length ins› 8. ‹⋀a Q r p fs a' Q' r' p' fs' s. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q:r↪⇘p⇙fs; lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a'; knd a' = Q':r'↪⇘p'⇙fs'; src a = src a'; local.CFG.pred (knd a) s; local.CFG.pred (knd a') s⟧ ⟹ a = a'› 9. ‹⋀a Q r p fs i ins outs s s'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q:r↪⇘p⇙fs; i < length ins; (p, ins, outs) ∈ set procs; local.CFG.pred (knd a) s; local.CFG.pred (knd a) s'; ∀V∈lift_ParamUses ParamUses (src a) ! i. local.CFG.state_val s V = local.CFG.state_val s' V⟧ ⟹ local.CFG.params fs (local.CFG.state_val s) ! i = local.CFG.params fs (local.CFG.state_val s') ! i› 10. ‹⋀a Q' p f' ins outs vmap vmap'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q'↩⇘p⇙f'; (p, ins, outs) ∈ set procs⟧ ⟹ f' vmap vmap' = vmap'(lift_ParamDefs ParamDefs (trg a) [:=] map vmap outs)› 11. ‹⋀a a'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a'; src a = src a'; trg a ≠ trg a'; intra_kind (knd a); intra_kind (knd a')⟧ ⟹ ∃Q Q'. knd a = (Q)⇩√ ∧ knd a' = (Q')⇩√ ∧ (∀s. (Q s ⟶ ¬ Q' s) ∧ (Q' s ⟶ ¬ Q s))›*) fix a and Q and r and p and fs assume "lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a" and "knd a = Q:r↪⇘p⇙fs" (*‹lift_valid_edge (valid_edge::'a ⇒ bool) (sourcenode::'a ⇒ 'b) (targetnode::'a ⇒ 'b) (kind::'a ⇒ ('c, 'd, 'e, 'f) edge_kind) (Entry::'b) (Exit::'b) (a::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node)› ‹knd (a::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node) = Q::('c ⇒ 'd option) × 'e ⇒ bool:r::'e↪⇘p::'f⇙fs::(('c ⇒ 'd option) ⇒ 'd option) list›*) thus "lift_Def Def Entry Exit H L (src a) = {}" proof (induct rule:lift_valid_edge.induct (*‹⟦lift_valid_edge ?valid_edge ?src ?trg ?knd ?E ?X ?x; ⋀a e. ⟦?valid_edge a; ?src a ≠ ?E ∨ ?trg a ≠ ?X; e = (Node (?src a), ?knd a, Node (?trg a))⟧ ⟹ ?P e; ⋀e. e = (NewEntry, (λs. True)⇩√, Node ?E) ⟹ ?P e; ⋀e. e = (Node ?X, (λs. True)⇩√, NewExit) ⟹ ?P e; ⋀e. e = (NewEntry, (λs. False)⇩√, NewExit) ⟹ ?P e⟧ ⟹ ?P ?x›*)) (*goals: 1. ‹⋀a e. ⟦valid_edge a; sourcenode a ≠ Entry ∨ targetnode a ≠ Exit; e = (Node (sourcenode a), kind a, Node (targetnode a)); knd e = Q:r↪⇘p⇙fs⟧ ⟹ lift_Def Def Entry Exit H L (src e) = {}› 2. ‹⋀e. ⟦e = (NewEntry, (λs. True)⇩√, Node Entry); knd e = Q:r↪⇘p⇙fs⟧ ⟹ lift_Def Def Entry Exit H L (src e) = {}› 3. ‹⋀e. ⟦e = (Node Exit, (λs. True)⇩√, NewExit); knd e = Q:r↪⇘p⇙fs⟧ ⟹ lift_Def Def Entry Exit H L (src e) = {}› 4. ‹⋀e. ⟦e = (NewEntry, (λs. False)⇩√, NewExit); knd e = Q:r↪⇘p⇙fs⟧ ⟹ lift_Def Def Entry Exit H L (src e) = {}›*) case (lve_edge a e) (*‹valid_edge a› ‹(sourcenode::'a::type ⇒ 'b::type) (a::'a::type) ≠ (Entry::'b::type) ∨ (targetnode::'a::type ⇒ 'b::type) a ≠ (Exit::'b::type)› ‹e = (Node (sourcenode a), kind a, Node (targetnode a))› ‹knd e = Q:r↪⇘p⇙fs›*) show "?case" (*goal: ‹lift_Def Def Entry Exit H L (src e) = {}›*) proof (rule ccontr (*‹(¬ ?P ⟹ False) ⟹ ?P›*)) (*goal: ‹lift_Def Def Entry Exit H L (src e) ≠ {} ⟹ False›*) assume "lift_Def Def Entry Exit H L (src e) ≠ {}" (*‹lift_Def (Def::'b ⇒ 'c set) (Entry::'b) (Exit::'b) (H::'c set) (L::'c set) (src (e::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node)) ≠ {}›*) then obtain x where "x ∈ lift_Def Def Entry Exit H L (src e)" (*goal: ‹(⋀x::'c. x ∈ lift_Def (Def::'b ⇒ 'c set) (Entry::'b) (Exit::'b) (H::'c set) (L::'c set) (src (e::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node)) ⟹ thesis::bool) ⟹ thesis›*) by blast from ‹e = (Node (sourcenode a), kind a, Node (targetnode a))› (*‹e = (Node (sourcenode a), kind a, Node (targetnode a))›*) ‹knd e = Q:r↪⇘p⇙fs› (*‹knd e = Q:r↪⇘p⇙fs›*) have "kind a = Q:r↪⇘p⇙fs" by simp with ‹valid_edge a› (*‹valid_edge a›*) have "Def (sourcenode a) = {}" by (rule call_source_Def_empty (*‹⟦valid_edge ?a; kind ?a = ?Q:?r↪⇘?p⇙?fs⟧ ⟹ Def (sourcenode ?a) = {}›*)) have "sourcenode a ≠ Entry" proof (standard) (*goal: ‹sourcenode a = Entry ⟹ False›*) assume "sourcenode a = Entry" (*‹(sourcenode::'a ⇒ 'b) (a::'a) = (Entry::'b)›*) with ‹valid_edge a› (*‹(valid_edge::'a ⇒ bool) (a::'a)›*) ‹kind a = Q:r↪⇘p⇙fs› (*‹kind a = Q:r↪⇘p⇙fs›*) show False by (rule Entry_no_call_source (*‹⟦valid_edge ?a; kind ?a = ?Q:?r↪⇘?p⇙?fs; sourcenode ?a = Entry⟧ ⟹ False›*)) qed from ‹e = (Node (sourcenode a), kind a, Node (targetnode a))› (*‹(e::'b::type LDCFG_node × ('c::type, 'd::type, 'e::type, 'f::type) edge_kind × 'b::type LDCFG_node) = (Node ((sourcenode::'a::type ⇒ 'b::type) (a::'a::type)), (kind::'a::type ⇒ ('c::type, 'd::type, 'e::type, 'f::type) edge_kind) a, Node ((targetnode::'a::type ⇒ 'b::type) a))›*) have "src e = Node (sourcenode a)" by simp with ‹Def (sourcenode a) = {}› (*‹(Def::'b ⇒ 'c set) ((sourcenode::'a ⇒ 'b) (a::'a)) = {}›*) ‹x ∈ lift_Def Def Entry Exit H L (src e)› (*‹x ∈ lift_Def Def Entry Exit H L (src e)›*) ‹sourcenode a ≠ Entry› (*‹sourcenode a ≠ Entry›*) show False by (fastforce elim:lift_Def_set.cases (*‹⟦(?a1.0, ?a2.0) ∈ lift_Def_set ?Def ?E ?X ?H ?L; ⋀V n. ⟦?a1.0 = Node n; ?a2.0 = V; V ∈ ?Def n⟧ ⟹ ?P; ⋀V. ⟦?a1.0 = Node ?E; ?a2.0 = V; V ∈ ?H⟧ ⟹ ?P⟧ ⟹ ?P›*)) qed qed (simp_all) (*solves the remaining goals: 1. ‹⋀e::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node. ⟦e = (NewEntry, (λs::'c ⇒ 'd option. True)⇩√, Node (Entry::'b)); knd e = Q::('c ⇒ 'd option) × 'e ⇒ bool:r::'e↪⇘p::'f⇙fs::(('c ⇒ 'd option) ⇒ 'd option) list⟧ ⟹ lift_Def (Def::'b ⇒ 'c set) Entry (Exit::'b) (H::'c set) (L::'c set) (src e) = {}› 2. ‹⋀e::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node. ⟦e = (Node (Exit::'b), (λs::'c ⇒ 'd option. True)⇩√, NewExit); knd e = Q::('c ⇒ 'd option) × 'e ⇒ bool:r::'e↪⇘p::'f⇙fs::(('c ⇒ 'd option) ⇒ 'd option) list⟧ ⟹ lift_Def (Def::'b ⇒ 'c set) (Entry::'b) Exit (H::'c set) (L::'c set) (src e) = {}› 3. ‹⋀e::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node. ⟦e = (NewEntry, (λs::'c ⇒ 'd option. False)⇩√, NewExit); knd e = Q::('c ⇒ 'd option) × 'e ⇒ bool:r::'e↪⇘p::'f⇙fs::(('c ⇒ 'd option) ⇒ 'd option) list⟧ ⟹ lift_Def (Def::'b ⇒ 'c set) (Entry::'b) (Exit::'b) (H::'c set) (L::'c set) (src e) = {}›*) next (*goals: 1. ‹⋀n V. ⟦local.CFG.valid_node n; V ∈ ⋃ (set (lift_ParamUses ParamUses n))⟧ ⟹ V ∈ lift_Use Use Entry Exit H L n› 2. ‹⋀a Q p f ins outs V. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q↩⇘p⇙f; (p, ins, outs) ∈ set procs; V ∈ set outs⟧ ⟹ V ∈ lift_Use Use Entry Exit H L (src a)› 3. ‹⋀a V s. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; V ∉ lift_Def Def Entry Exit H L (src a); intra_kind (knd a); local.CFG.pred (knd a) s⟧ ⟹ local.CFG.state_val (local.CFG.transfer (knd a) s) V = local.CFG.state_val s V› 4. ‹⋀a s s'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; ∀V∈lift_Use Use Entry Exit H L (src a). local.CFG.state_val s V = local.CFG.state_val s' V; intra_kind (knd a); local.CFG.pred (knd a) s; local.CFG.pred (knd a) s'⟧ ⟹ ∀V∈lift_Def Def Entry Exit H L (src a). local.CFG.state_val (local.CFG.transfer (knd a) s) V = local.CFG.state_val (local.CFG.transfer (knd a) s') V› 5. ‹⋀a s s'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; local.CFG.pred (knd a) s; snd (hd s) = snd (hd s'); ∀V∈lift_Use Use Entry Exit H L (src a). local.CFG.state_val s V = local.CFG.state_val s' V; length s = length s'⟧ ⟹ local.CFG.pred (knd a) s'› 6. ‹⋀a Q r p fs ins outs. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q:r↪⇘p⇙fs; (p, ins, outs) ∈ set procs⟧ ⟹ length fs = length ins› 7. ‹⋀a Q r p fs a' Q' r' p' fs' s. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q:r↪⇘p⇙fs; lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a'; knd a' = Q':r'↪⇘p'⇙fs'; src a = src a'; local.CFG.pred (knd a) s; local.CFG.pred (knd a') s⟧ ⟹ a = a'› 8. ‹⋀a Q r p fs i ins outs s s'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q:r↪⇘p⇙fs; i < length ins; (p, ins, outs) ∈ set procs; local.CFG.pred (knd a) s; local.CFG.pred (knd a) s'; ∀V∈lift_ParamUses ParamUses (src a) ! i. local.CFG.state_val s V = local.CFG.state_val s' V⟧ ⟹ local.CFG.params fs (local.CFG.state_val s) ! i = local.CFG.params fs (local.CFG.state_val s') ! i› 9. ‹⋀a Q' p f' ins outs vmap vmap'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q'↩⇘p⇙f'; (p, ins, outs) ∈ set procs⟧ ⟹ f' vmap vmap' = vmap'(lift_ParamDefs ParamDefs (trg a) [:=] map vmap outs)› 10. ‹⋀a a'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a'; src a = src a'; trg a ≠ trg a'; intra_kind (knd a); intra_kind (knd a')⟧ ⟹ ∃Q Q'. knd a = (Q)⇩√ ∧ knd a' = (Q')⇩√ ∧ (∀s. (Q s ⟶ ¬ Q' s) ∧ (Q' s ⟶ ¬ Q s))›*) fix n and V assume "CFG.CFG.valid_node src trg (lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit) n" and "V ∈ ⋃(set (lift_ParamUses ParamUses n))" (*‹local.CFG.valid_node (n::'b LDCFG_node)› ‹(V::'c) ∈ ⋃ (set (lift_ParamUses (ParamUses::'b ⇒ 'c set list) (n::'b LDCFG_node)))›*) hence "((n = NewEntry) ∨ n = NewExit) ∨ (∃m. n = Node m ∧ valid_node m)" by (auto elim:lift_valid_edge.cases (*‹⟦lift_valid_edge (?valid_edge::?'edge ⇒ bool) (?src::?'edge ⇒ ?'node) (?trg::?'edge ⇒ ?'node) (?knd::?'edge ⇒ (?'var, ?'val, ?'ret, ?'pname) edge_kind) (?E::?'node) (?X::?'node) (?a::?'node LDCFG_node × (?'var, ?'val, ?'ret, ?'pname) edge_kind × ?'node LDCFG_node); ⋀(a::?'edge) e::?'node LDCFG_node × (?'var, ?'val, ?'ret, ?'pname) edge_kind × ?'node LDCFG_node. ⟦?a = e; ?valid_edge a; ?src a ≠ ?E ∨ ?trg a ≠ ?X; e = (Node (?src a), ?knd a, Node (?trg a))⟧ ⟹ ?P::bool; ⋀e::?'node LDCFG_node × (?'var, ?'val, ?'ret, ?'pname) edge_kind × ?'node LDCFG_node. ⟦?a = e; e = (NewEntry, (λs::?'var ⇒ ?'val option. True)⇩√, Node ?E)⟧ ⟹ ?P; ⋀e::?'node LDCFG_node × (?'var, ?'val, ?'ret, ?'pname) edge_kind × ?'node LDCFG_node. ⟦?a = e; e = (Node ?X, (λs::?'var ⇒ ?'val option. True)⇩√, NewExit)⟧ ⟹ ?P; ⋀e::?'node LDCFG_node × (?'var, ?'val, ?'ret, ?'pname) edge_kind × ?'node LDCFG_node. ⟦?a = e; e = (NewEntry, (λs::?'var ⇒ ?'val option. False)⇩√, NewExit)⟧ ⟹ ?P⟧ ⟹ ?P›*) simp:CFG.valid_node_def (*‹local.CFG.valid_node (?n::'b LDCFG_node) ≡ ∃a::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node. lift_valid_edge (valid_edge::'a ⇒ bool) (sourcenode::'a ⇒ 'b) (targetnode::'a ⇒ 'b) (kind::'a ⇒ ('c, 'd, 'e, 'f) edge_kind) (Entry::'b) (Exit::'b) a ∧ (?n = src a ∨ ?n = trg a)›*)) thus "V ∈ lift_Use Use Entry Exit H L n" apply - (*goal: ‹V ∈ lift_Use Use Entry Exit H L n›*) proof ((erule disjE (*‹⟦(?P::bool) ∨ (?Q::bool); ?P ⟹ ?R::bool; ?Q ⟹ ?R⟧ ⟹ ?R›*))+) (*goals: 1. ‹n = NewEntry ⟹ V ∈ lift_Use Use Entry Exit H L n› 2. ‹n = NewExit ⟹ V ∈ lift_Use Use Entry Exit H L n› 3. ‹∃m. n = Node m ∧ valid_node m ⟹ V ∈ lift_Use Use Entry Exit H L n›*) assume "n = NewEntry" (*‹(n::'b LDCFG_node) = NewEntry›*) with ‹V ∈ ⋃(set (lift_ParamUses ParamUses n))› (*‹V ∈ ⋃ (set (lift_ParamUses ParamUses n))›*) show "?thesis" (*goal: ‹V ∈ lift_Use Use Entry Exit H L n›*) by simp next (*goals: 1. ‹n = NewExit ⟹ V ∈ lift_Use Use Entry Exit H L n› 2. ‹∃m. n = Node m ∧ valid_node m ⟹ V ∈ lift_Use Use Entry Exit H L n›*) assume "n = NewExit" (*‹(n::'b LDCFG_node) = NewExit›*) with ‹V ∈ ⋃(set (lift_ParamUses ParamUses n))› (*‹V ∈ ⋃ (set (lift_ParamUses ParamUses n))›*) show "?thesis" (*goal: ‹V ∈ lift_Use Use Entry Exit H L n›*) by simp next (*goal: ‹∃m. n = Node m ∧ valid_node m ⟹ V ∈ lift_Use Use Entry Exit H L n›*) assume "∃m. n = Node m ∧ valid_node m" (*‹∃m::'b. (n::'b LDCFG_node) = Node m ∧ valid_node m›*) then obtain m where "n = Node m" and "valid_node m" (*goal: ‹(⋀m. ⟦n = Node m; valid_node m⟧ ⟹ thesis) ⟹ thesis›*) by blast from ‹V ∈ ⋃(set (lift_ParamUses ParamUses n))› (*‹V ∈ ⋃ (set (lift_ParamUses ParamUses n))›*) ‹n = Node m› (*‹n = Node m›*) have "V ∈ ⋃(set (ParamUses m))" by simp with ‹valid_node m› (*‹valid_node (m::'b::type)›*) have "V ∈ Use m" by (rule ParamUses_in_Use (*‹⟦valid_node (?n::'b); (?V::'c) ∈ ⋃ (set ((ParamUses::'b ⇒ 'c set list) ?n))⟧ ⟹ ?V ∈ (Use::'b ⇒ 'c set) ?n›*)) with ‹n = Node m› (*‹(n::'b LDCFG_node) = Node (m::'b)›*) show "?thesis" (*goal: ‹V ∈ lift_Use Use Entry Exit H L n›*) by (fastforce intro:lift_Use_node (*‹?V ∈ ?Use ?n ⟹ (Node ?n, ?V) ∈ lift_Use_set ?Use ?E ?X ?H ?L›*)) qed next (*goals: 1. ‹⋀a Q p f ins outs V. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q↩⇘p⇙f; (p, ins, outs) ∈ set procs; V ∈ set outs⟧ ⟹ V ∈ lift_Use Use Entry Exit H L (src a)› 2. ‹⋀a V s. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; V ∉ lift_Def Def Entry Exit H L (src a); intra_kind (knd a); local.CFG.pred (knd a) s⟧ ⟹ local.CFG.state_val (local.CFG.transfer (knd a) s) V = local.CFG.state_val s V› 3. ‹⋀a s s'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; ∀V∈lift_Use Use Entry Exit H L (src a). local.CFG.state_val s V = local.CFG.state_val s' V; intra_kind (knd a); local.CFG.pred (knd a) s; local.CFG.pred (knd a) s'⟧ ⟹ ∀V∈lift_Def Def Entry Exit H L (src a). local.CFG.state_val (local.CFG.transfer (knd a) s) V = local.CFG.state_val (local.CFG.transfer (knd a) s') V› 4. ‹⋀a s s'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; local.CFG.pred (knd a) s; snd (hd s) = snd (hd s'); ∀V∈lift_Use Use Entry Exit H L (src a). local.CFG.state_val s V = local.CFG.state_val s' V; length s = length s'⟧ ⟹ local.CFG.pred (knd a) s'› 5. ‹⋀a Q r p fs ins outs. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q:r↪⇘p⇙fs; (p, ins, outs) ∈ set procs⟧ ⟹ length fs = length ins› 6. ‹⋀a Q r p fs a' Q' r' p' fs' s. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q:r↪⇘p⇙fs; lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a'; knd a' = Q':r'↪⇘p'⇙fs'; src a = src a'; local.CFG.pred (knd a) s; local.CFG.pred (knd a') s⟧ ⟹ a = a'› 7. ‹⋀a Q r p fs i ins outs s s'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q:r↪⇘p⇙fs; i < length ins; (p, ins, outs) ∈ set procs; local.CFG.pred (knd a) s; local.CFG.pred (knd a) s'; ∀V∈lift_ParamUses ParamUses (src a) ! i. local.CFG.state_val s V = local.CFG.state_val s' V⟧ ⟹ local.CFG.params fs (local.CFG.state_val s) ! i = local.CFG.params fs (local.CFG.state_val s') ! i› 8. ‹⋀a Q' p f' ins outs vmap vmap'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q'↩⇘p⇙f'; (p, ins, outs) ∈ set procs⟧ ⟹ f' vmap vmap' = vmap'(lift_ParamDefs ParamDefs (trg a) [:=] map vmap outs)› 9. ‹⋀a a'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a'; src a = src a'; trg a ≠ trg a'; intra_kind (knd a); intra_kind (knd a')⟧ ⟹ ∃Q Q'. knd a = (Q)⇩√ ∧ knd a' = (Q')⇩√ ∧ (∀s. (Q s ⟶ ¬ Q' s) ∧ (Q' s ⟶ ¬ Q s))›*) fix a and Q and p and f and ins and outs and V assume "lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a" and "knd a = Q↩⇘p⇙f" and "(p, ins, outs) ∈ set procs" and "V ∈ set outs" (*‹lift_valid_edge (valid_edge::'a ⇒ bool) (sourcenode::'a ⇒ 'b) (targetnode::'a ⇒ 'b) (kind::'a ⇒ ('c, 'd, 'e, 'f) edge_kind) (Entry::'b) (Exit::'b) (a::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node)› ‹knd (a::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node) = Q::('c ⇒ 'd option) × 'e ⇒ bool↩⇘p::'f⇙f::('c ⇒ 'd option) ⇒ ('c ⇒ 'd option) ⇒ 'c ⇒ 'd option› ‹(p::'f, ins::'c list, outs::'c list) ∈ set (procs::('f × 'c list × 'c list) list)› ‹(V::'c) ∈ set (outs::'c list)›*) thus "V ∈ lift_Use Use Entry Exit H L (src a)" proof (induct rule:lift_valid_edge.induct (*‹⟦lift_valid_edge ?valid_edge ?src ?trg ?knd ?E ?X ?x; ⋀a e. ⟦?valid_edge a; ?src a ≠ ?E ∨ ?trg a ≠ ?X; e = (Node (?src a), ?knd a, Node (?trg a))⟧ ⟹ ?P e; ⋀e. e = (NewEntry, (λs. True)⇩√, Node ?E) ⟹ ?P e; ⋀e. e = (Node ?X, (λs. True)⇩√, NewExit) ⟹ ?P e; ⋀e. e = (NewEntry, (λs. False)⇩√, NewExit) ⟹ ?P e⟧ ⟹ ?P ?x›*)) (*goals: 1. ‹⋀a e. ⟦valid_edge a; sourcenode a ≠ Entry ∨ targetnode a ≠ Exit; e = (Node (sourcenode a), kind a, Node (targetnode a)); knd e = Q↩⇘p⇙f; (p, ins, outs) ∈ set procs; V ∈ set outs⟧ ⟹ V ∈ lift_Use Use Entry Exit H L (src e)› 2. ‹⋀e. ⟦e = (NewEntry, (λs. True)⇩√, Node Entry); knd e = Q↩⇘p⇙f; (p, ins, outs) ∈ set procs; V ∈ set outs⟧ ⟹ V ∈ lift_Use Use Entry Exit H L (src e)› 3. ‹⋀e. ⟦e = (Node Exit, (λs. True)⇩√, NewExit); knd e = Q↩⇘p⇙f; (p, ins, outs) ∈ set procs; V ∈ set outs⟧ ⟹ V ∈ lift_Use Use Entry Exit H L (src e)› 4. ‹⋀e. ⟦e = (NewEntry, (λs. False)⇩√, NewExit); knd e = Q↩⇘p⇙f; (p, ins, outs) ∈ set procs; V ∈ set outs⟧ ⟹ V ∈ lift_Use Use Entry Exit H L (src e)›*) case (lve_edge a e) (*‹valid_edge a› ‹sourcenode a ≠ Entry ∨ targetnode a ≠ Exit› ‹e = (Node (sourcenode a), kind a, Node (targetnode a))› ‹knd e = Q↩⇘p⇙f› ‹(p, ins, outs) ∈ set procs› ‹(V::'c) ∈ set (outs::'c list)›*) from ‹e = (Node (sourcenode a), kind a, Node (targetnode a))› (*‹e = (Node (sourcenode a), kind a, Node (targetnode a))›*) ‹knd e = Q↩⇘p⇙f› (*‹knd e = Q↩⇘p⇙f›*) have "kind a = Q↩⇘p⇙f" by simp from ‹valid_edge a› (*‹(valid_edge::'a ⇒ bool) (a::'a)›*) ‹kind a = Q↩⇘p⇙f› (*‹(kind::'a::type ⇒ ('c::type, 'd::type, 'e::type, 'f::type) edge_kind) (a::'a::type) = Q::('c::type ⇒ 'd::type option) × 'e::type ⇒ bool↩⇘p::'f::type⇙f::('c::type ⇒ 'd::type option) ⇒ ('c::type ⇒ 'd::type option) ⇒ 'c::type ⇒ 'd::type option›*) ‹(p, ins, outs) ∈ set procs› (*‹(p, ins, outs) ∈ set procs›*) ‹V ∈ set outs› (*‹V ∈ set outs›*) have "V ∈ Use (sourcenode a)" by (rule outs_in_Use (*‹⟦valid_edge ?a; kind ?a = ?Q↩⇘?p⇙?f; (?p, ?ins, ?outs) ∈ set procs; ?V ∈ set ?outs⟧ ⟹ ?V ∈ Use (sourcenode ?a)›*)) from ‹e = (Node (sourcenode a), kind a, Node (targetnode a))› (*‹e = (Node (sourcenode a), kind a, Node (targetnode a))›*) have "src e = Node (sourcenode a)" by simp with ‹V ∈ Use (sourcenode a)› (*‹V ∈ Use (sourcenode a)›*) show "?case" (*goal: ‹V ∈ lift_Use Use Entry Exit H L (src e)›*) by (fastforce intro:lift_Use_node (*‹(?V::?'var) ∈ (?Use::?'node ⇒ ?'var set) (?n::?'node) ⟹ (Node ?n, ?V) ∈ lift_Use_set ?Use (?E::?'node) (?X::?'node) (?H::?'var set) (?L::?'var set)›*)) qed (simp_all) (*solves the remaining goals: 1. ‹⋀e. ⟦e = (NewEntry, (λs. True)⇩√, Node Entry); knd e = Q↩⇘p⇙f; (p, ins, outs) ∈ set procs; V ∈ set outs⟧ ⟹ V ∈ lift_Use Use Entry Exit H L (src e)› 2. ‹⋀e. ⟦e = (Node Exit, (λs. True)⇩√, NewExit); knd e = Q↩⇘p⇙f; (p, ins, outs) ∈ set procs; V ∈ set outs⟧ ⟹ V ∈ lift_Use Use Entry Exit H L (src e)› 3. ‹⋀e. ⟦e = (NewEntry, (λs. False)⇩√, NewExit); knd e = Q↩⇘p⇙f; (p, ins, outs) ∈ set procs; V ∈ set outs⟧ ⟹ V ∈ lift_Use Use Entry Exit H L (src e)›*) next (*goals: 1. ‹⋀a V s. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; V ∉ lift_Def Def Entry Exit H L (src a); intra_kind (knd a); local.CFG.pred (knd a) s⟧ ⟹ local.CFG.state_val (local.CFG.transfer (knd a) s) V = local.CFG.state_val s V› 2. ‹⋀a s s'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; ∀V∈lift_Use Use Entry Exit H L (src a). local.CFG.state_val s V = local.CFG.state_val s' V; intra_kind (knd a); local.CFG.pred (knd a) s; local.CFG.pred (knd a) s'⟧ ⟹ ∀V∈lift_Def Def Entry Exit H L (src a). local.CFG.state_val (local.CFG.transfer (knd a) s) V = local.CFG.state_val (local.CFG.transfer (knd a) s') V› 3. ‹⋀a s s'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; local.CFG.pred (knd a) s; snd (hd s) = snd (hd s'); ∀V∈lift_Use Use Entry Exit H L (src a). local.CFG.state_val s V = local.CFG.state_val s' V; length s = length s'⟧ ⟹ local.CFG.pred (knd a) s'› 4. ‹⋀a Q r p fs ins outs. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q:r↪⇘p⇙fs; (p, ins, outs) ∈ set procs⟧ ⟹ length fs = length ins› 5. ‹⋀a Q r p fs a' Q' r' p' fs' s. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q:r↪⇘p⇙fs; lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a'; knd a' = Q':r'↪⇘p'⇙fs'; src a = src a'; local.CFG.pred (knd a) s; local.CFG.pred (knd a') s⟧ ⟹ a = a'› 6. ‹⋀a Q r p fs i ins outs s s'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q:r↪⇘p⇙fs; i < length ins; (p, ins, outs) ∈ set procs; local.CFG.pred (knd a) s; local.CFG.pred (knd a) s'; ∀V∈lift_ParamUses ParamUses (src a) ! i. local.CFG.state_val s V = local.CFG.state_val s' V⟧ ⟹ local.CFG.params fs (local.CFG.state_val s) ! i = local.CFG.params fs (local.CFG.state_val s') ! i› 7. ‹⋀a Q' p f' ins outs vmap vmap'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q'↩⇘p⇙f'; (p, ins, outs) ∈ set procs⟧ ⟹ f' vmap vmap' = vmap'(lift_ParamDefs ParamDefs (trg a) [:=] map vmap outs)› 8. ‹⋀a a'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a'; src a = src a'; trg a ≠ trg a'; intra_kind (knd a); intra_kind (knd a')⟧ ⟹ ∃Q Q'. knd a = (Q)⇩√ ∧ knd a' = (Q')⇩√ ∧ (∀s. (Q s ⟶ ¬ Q' s) ∧ (Q' s ⟶ ¬ Q s))›*) fix a and V and s assume "lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a" and "V ∉ lift_Def Def Entry Exit H L (src a)" and "intra_kind (knd a)" and "pred (knd a) s" (*‹lift_valid_edge (valid_edge::'a ⇒ bool) (sourcenode::'a ⇒ 'b) (targetnode::'a ⇒ 'b) (kind::'a ⇒ ('c, 'd, 'e, 'f) edge_kind) (Entry::'b) (Exit::'b) (a::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node)› ‹(V::'c) ∉ lift_Def (Def::'b ⇒ 'c set) (Entry::'b) (Exit::'b) (H::'c set) (L::'c set) (src (a::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node))› ‹intra_kind (knd (a::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node))› ‹local.CFG.pred (knd (a::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node)) (s::(('c ⇒ 'd option) × 'e) list)›*) thus "state_val (transfer (knd a) s) V = state_val s V" proof (induct rule:lift_valid_edge.induct (*‹⟦lift_valid_edge ?valid_edge ?src ?trg ?knd ?E ?X ?x; ⋀a e. ⟦?valid_edge a; ?src a ≠ ?E ∨ ?trg a ≠ ?X; e = (Node (?src a), ?knd a, Node (?trg a))⟧ ⟹ ?P e; ⋀e. e = (NewEntry, (λs. True)⇩√, Node ?E) ⟹ ?P e; ⋀e. e = (Node ?X, (λs. True)⇩√, NewExit) ⟹ ?P e; ⋀e. e = (NewEntry, (λs. False)⇩√, NewExit) ⟹ ?P e⟧ ⟹ ?P ?x›*)) (*goals: 1. ‹⋀(a::'a) e::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node. ⟦(valid_edge::'a ⇒ bool) a; (sourcenode::'a ⇒ 'b) a ≠ (Entry::'b) ∨ (targetnode::'a ⇒ 'b) a ≠ (Exit::'b); e = (Node (sourcenode a), (kind::'a ⇒ ('c, 'd, 'e, 'f) edge_kind) a, Node (targetnode a)); (V::'c) ∉ lift_Def (Def::'b ⇒ 'c set) Entry Exit (H::'c set) (L::'c set) (src e); intra_kind (knd e); local.CFG.pred (knd e) (s::(('c ⇒ 'd option) × 'e) list)⟧ ⟹ local.CFG.state_val (local.CFG.transfer (knd e) s) V = local.CFG.state_val s V› 2. ‹⋀e::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node. ⟦e = (NewEntry, (λs::'c ⇒ 'd option. True)⇩√, Node (Entry::'b)); (V::'c) ∉ lift_Def (Def::'b ⇒ 'c set) Entry (Exit::'b) (H::'c set) (L::'c set) (src e); intra_kind (knd e); local.CFG.pred (knd e) (s::(('c ⇒ 'd option) × 'e) list)⟧ ⟹ local.CFG.state_val (local.CFG.transfer (knd e) s) V = local.CFG.state_val s V› 3. ‹⋀e::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node. ⟦e = (Node (Exit::'b), (λs::'c ⇒ 'd option. True)⇩√, NewExit); (V::'c) ∉ lift_Def (Def::'b ⇒ 'c set) (Entry::'b) Exit (H::'c set) (L::'c set) (src e); intra_kind (knd e); local.CFG.pred (knd e) (s::(('c ⇒ 'd option) × 'e) list)⟧ ⟹ local.CFG.state_val (local.CFG.transfer (knd e) s) V = local.CFG.state_val s V› 4. ‹⋀e::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node. ⟦e = (NewEntry, (λs::'c ⇒ 'd option. False)⇩√, NewExit); (V::'c) ∉ lift_Def (Def::'b ⇒ 'c set) (Entry::'b) (Exit::'b) (H::'c set) (L::'c set) (src e); intra_kind (knd e); local.CFG.pred (knd e) (s::(('c ⇒ 'd option) × 'e) list)⟧ ⟹ local.CFG.state_val (local.CFG.transfer (knd e) s) V = local.CFG.state_val s V›*) case (lve_edge a e) (*‹valid_edge a› ‹sourcenode a ≠ Entry ∨ targetnode a ≠ Exit› ‹(e::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node) = (Node ((sourcenode::'a ⇒ 'b) (a::'a)), (kind::'a ⇒ ('c, 'd, 'e, 'f) edge_kind) a, Node ((targetnode::'a ⇒ 'b) a))› ‹V ∉ lift_Def Def Entry Exit H L (src e)› ‹intra_kind (knd e)› ‹local.CFG.pred (knd e) s›*) from ‹e = (Node (sourcenode a), kind a, Node (targetnode a))› (*‹e = (Node (sourcenode a), kind a, Node (targetnode a))›*) ‹intra_kind (knd e)› (*‹intra_kind (knd e)›*) ‹pred (knd e) s› (*‹local.CFG.pred (knd e) s›*) have "intra_kind (kind a)" and "pred (kind a) s" and "knd e = kind a" and "src e = Node (sourcenode a)" apply - (*goals: 1. ‹⟦e = (Node (sourcenode a), kind a, Node (targetnode a)); intra_kind (knd e); local.CFG.pred (knd e) s⟧ ⟹ intra_kind (kind a)› 2. ‹⟦e = (Node (sourcenode a), kind a, Node (targetnode a)); intra_kind (knd e); local.CFG.pred (knd e) s⟧ ⟹ local.CFG.pred (kind a) s› 3. ‹⟦e = (Node (sourcenode a), kind a, Node (targetnode a)); intra_kind (knd e); local.CFG.pred (knd e) s⟧ ⟹ knd e = kind a› 4. ‹⟦e = (Node (sourcenode a), kind a, Node (targetnode a)); intra_kind (knd e); local.CFG.pred (knd e) s⟧ ⟹ src e = Node (sourcenode a)› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*discuss goal 3*) apply simp (*discuss goal 4*) apply simp (*proven 4 subgoals*) . from ‹V ∉ lift_Def Def Entry Exit H L (src e)› (*‹V ∉ lift_Def Def Entry Exit H L (src e)›*) ‹src e = Node (sourcenode a)› (*‹src e = Node (sourcenode a)›*) have "V ∉ Def (sourcenode a)" by (auto dest: lift_Def_node (*‹?V ∈ ?Def ?n ⟹ (Node ?n, ?V) ∈ lift_Def_set ?Def ?E ?X ?H ?L›*)) from ‹valid_edge a› (*‹valid_edge a›*) ‹V ∉ Def (sourcenode a)› (*‹V ∉ Def (sourcenode a)›*) ‹intra_kind (kind a)› (*‹intra_kind (kind a)›*) ‹pred (kind a) s› (*‹local.CFG.pred (kind a) s›*) have "state_val (transfer (kind a) s) V = state_val s V" by (rule CFG_intra_edge_no_Def_equal (*‹⟦valid_edge ?a; ?V ∉ Def (sourcenode ?a); intra_kind (kind ?a); local.CFG.pred (kind ?a) ?s⟧ ⟹ local.CFG.state_val (local.CFG.transfer (kind ?a) ?s) ?V = local.CFG.state_val ?s ?V›*)) with ‹knd e = kind a› (*‹knd e = kind a›*) show "?case" (*goal: ‹local.CFG.state_val (local.CFG.transfer (knd e) s) V = local.CFG.state_val s V›*) by simp next (*goals: 1. ‹⋀e. ⟦e = (NewEntry, (λs. True)⇩√, Node Entry); V ∉ lift_Def Def Entry Exit H L (src e); intra_kind (knd e); local.CFG.pred (knd e) s⟧ ⟹ local.CFG.state_val (local.CFG.transfer (knd e) s) V = local.CFG.state_val s V› 2. ‹⋀e. ⟦e = (Node Exit, (λs. True)⇩√, NewExit); V ∉ lift_Def Def Entry Exit H L (src e); intra_kind (knd e); local.CFG.pred (knd e) s⟧ ⟹ local.CFG.state_val (local.CFG.transfer (knd e) s) V = local.CFG.state_val s V› 3. ‹⋀e. ⟦e = (NewEntry, (λs. False)⇩√, NewExit); V ∉ lift_Def Def Entry Exit H L (src e); intra_kind (knd e); local.CFG.pred (knd e) s⟧ ⟹ local.CFG.state_val (local.CFG.transfer (knd e) s) V = local.CFG.state_val s V›*) case (lve_Entry_edge e) (*‹e = (NewEntry, (λs. True)⇩√, Node Entry)› ‹V ∉ lift_Def Def Entry Exit H L (src e)› ‹intra_kind (knd (e::'b::type LDCFG_node × ('c::type, 'd::type, 'e::type, 'f::type) edge_kind × 'b::type LDCFG_node))› ‹local.CFG.pred (knd e) s›*) from ‹e = (NewEntry, (λs. True)⇩√, Node Entry)› (*‹e = (NewEntry, (λs. True)⇩√, Node Entry)›*) ‹pred (knd e) s› (*‹local.CFG.pred (knd e) s›*) show "?case" (*goal: ‹local.CFG.state_val (local.CFG.transfer (knd e) s) V = local.CFG.state_val s V›*) apply (cases s) (*goals: 1. ‹⟦e = (NewEntry, (λs. True)⇩√, Node Entry); local.CFG.pred (knd e) s; s = []⟧ ⟹ local.CFG.state_val (local.CFG.transfer (knd e) s) V = local.CFG.state_val s V› 2. ‹⋀a list. ⟦e = (NewEntry, (λs. True)⇩√, Node Entry); local.CFG.pred (knd e) s; s = a # list⟧ ⟹ local.CFG.state_val (local.CFG.transfer (knd e) s) V = local.CFG.state_val s V› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . next (*goals: 1. ‹⋀e::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node. ⟦e = (Node (Exit::'b), (λs::'c ⇒ 'd option. True)⇩√, NewExit); (V::'c) ∉ lift_Def (Def::'b ⇒ 'c set) (Entry::'b) Exit (H::'c set) (L::'c set) (src e); intra_kind (knd e); local.CFG.pred (knd e) (s::(('c ⇒ 'd option) × 'e) list)⟧ ⟹ local.CFG.state_val (local.CFG.transfer (knd e) s) V = local.CFG.state_val s V› 2. ‹⋀e::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node. ⟦e = (NewEntry, (λs::'c ⇒ 'd option. False)⇩√, NewExit); (V::'c) ∉ lift_Def (Def::'b ⇒ 'c set) (Entry::'b) (Exit::'b) (H::'c set) (L::'c set) (src e); intra_kind (knd e); local.CFG.pred (knd e) (s::(('c ⇒ 'd option) × 'e) list)⟧ ⟹ local.CFG.state_val (local.CFG.transfer (knd e) s) V = local.CFG.state_val s V›*) case (lve_Exit_edge e) (*‹e = (Node Exit, (λs. True)⇩√, NewExit)› ‹V ∉ lift_Def Def Entry Exit H L (src e)› ‹intra_kind (knd e)› ‹local.CFG.pred (knd e) s›*) from ‹e = (Node Exit, (λs. True)⇩√, NewExit)› (*‹(e::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node) = (Node (Exit::'b), (λs::'c ⇒ 'd option. True)⇩√, NewExit)›*) ‹pred (knd e) s› (*‹local.CFG.pred (knd e) s›*) show "?case" (*goal: ‹local.CFG.state_val (local.CFG.transfer (knd e) s) V = local.CFG.state_val s V›*) apply (cases s) (*goals: 1. ‹⟦e = (Node Exit, (λs. True)⇩√, NewExit); local.CFG.pred (knd e) s; s = []⟧ ⟹ local.CFG.state_val (local.CFG.transfer (knd e) s) V = local.CFG.state_val s V› 2. ‹⋀a list. ⟦e = (Node Exit, (λs. True)⇩√, NewExit); local.CFG.pred (knd e) s; s = a # list⟧ ⟹ local.CFG.state_val (local.CFG.transfer (knd e) s) V = local.CFG.state_val s V› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . next (*goal: ‹⋀e. ⟦e = (NewEntry, (λs. False)⇩√, NewExit); V ∉ lift_Def Def Entry Exit H L (src e); intra_kind (knd e); local.CFG.pred (knd e) s⟧ ⟹ local.CFG.state_val (local.CFG.transfer (knd e) s) V = local.CFG.state_val s V›*) case (lve_Entry_Exit_edge e) (*‹(e::'b::type LDCFG_node × ('c::type, 'd::type, 'e::type, 'f::type) edge_kind × 'b::type LDCFG_node) = (NewEntry, (λs::'c::type ⇒ 'd::type option. False)⇩√, NewExit)› ‹(V::'c) ∉ lift_Def (Def::'b ⇒ 'c set) (Entry::'b) (Exit::'b) (H::'c set) (L::'c set) (src (e::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node))› ‹intra_kind (knd (e::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node))› ‹local.CFG.pred (knd e) s›*) from ‹e = (NewEntry, (λs. False)⇩√, NewExit)› (*‹e = (NewEntry, (λs. False)⇩√, NewExit)›*) ‹pred (knd e) s› (*‹local.CFG.pred (knd e) s›*) have False apply (cases s) (*goals: 1. ‹⟦(e::'b::type LDCFG_node × ('c::type, 'd::type, 'e::type, 'f::type) edge_kind × 'b::type LDCFG_node) = (NewEntry, (λs::'c::type ⇒ 'd::type option. False)⇩√, NewExit); local.CFG.pred (knd e) (s::(('c::type ⇒ 'd::type option) × 'e::type) list); s = []⟧ ⟹ False› 2. ‹⋀(a::('c::type ⇒ 'd::type option) × 'e::type) list::(('c::type ⇒ 'd::type option) × 'e::type) list. ⟦(e::'b::type LDCFG_node × ('c::type, 'd::type, 'e::type, 'f::type) edge_kind × 'b::type LDCFG_node) = (NewEntry, (λs::'c::type ⇒ 'd::type option. False)⇩√, NewExit); local.CFG.pred (knd e) (s::(('c::type ⇒ 'd::type option) × 'e::type) list); s = a # list⟧ ⟹ False› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . thus "?case" (*goal: ‹local.CFG.state_val (local.CFG.transfer (knd e) s) V = local.CFG.state_val s V›*) by simp qed next (*goals: 1. ‹⋀a s s'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; ∀V∈lift_Use Use Entry Exit H L (src a). local.CFG.state_val s V = local.CFG.state_val s' V; intra_kind (knd a); local.CFG.pred (knd a) s; local.CFG.pred (knd a) s'⟧ ⟹ ∀V∈lift_Def Def Entry Exit H L (src a). local.CFG.state_val (local.CFG.transfer (knd a) s) V = local.CFG.state_val (local.CFG.transfer (knd a) s') V› 2. ‹⋀a s s'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; local.CFG.pred (knd a) s; snd (hd s) = snd (hd s'); ∀V∈lift_Use Use Entry Exit H L (src a). local.CFG.state_val s V = local.CFG.state_val s' V; length s = length s'⟧ ⟹ local.CFG.pred (knd a) s'› 3. ‹⋀a Q r p fs ins outs. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q:r↪⇘p⇙fs; (p, ins, outs) ∈ set procs⟧ ⟹ length fs = length ins› 4. ‹⋀a Q r p fs a' Q' r' p' fs' s. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q:r↪⇘p⇙fs; lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a'; knd a' = Q':r'↪⇘p'⇙fs'; src a = src a'; local.CFG.pred (knd a) s; local.CFG.pred (knd a') s⟧ ⟹ a = a'› 5. ‹⋀a Q r p fs i ins outs s s'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q:r↪⇘p⇙fs; i < length ins; (p, ins, outs) ∈ set procs; local.CFG.pred (knd a) s; local.CFG.pred (knd a) s'; ∀V∈lift_ParamUses ParamUses (src a) ! i. local.CFG.state_val s V = local.CFG.state_val s' V⟧ ⟹ local.CFG.params fs (local.CFG.state_val s) ! i = local.CFG.params fs (local.CFG.state_val s') ! i› 6. ‹⋀a Q' p f' ins outs vmap vmap'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q'↩⇘p⇙f'; (p, ins, outs) ∈ set procs⟧ ⟹ f' vmap vmap' = vmap'(lift_ParamDefs ParamDefs (trg a) [:=] map vmap outs)› 7. ‹⋀a a'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a'; src a = src a'; trg a ≠ trg a'; intra_kind (knd a); intra_kind (knd a')⟧ ⟹ ∃Q Q'. knd a = (Q)⇩√ ∧ knd a' = (Q')⇩√ ∧ (∀s. (Q s ⟶ ¬ Q' s) ∧ (Q' s ⟶ ¬ Q s))›*) fix a and s and s' assume assms: "lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a" "∀V∈lift_Use Use Entry Exit H L (src a). state_val s V = state_val s' V" "intra_kind (knd a)" "pred (knd a) s" "pred (knd a) s'" (*‹lift_valid_edge (valid_edge::'a ⇒ bool) (sourcenode::'a ⇒ 'b) (targetnode::'a ⇒ 'b) (kind::'a ⇒ ('c, 'd, 'e, 'f) edge_kind) (Entry::'b) (Exit::'b) (a::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node)› ‹∀V::'c∈lift_Use (Use::'b ⇒ 'c set) (Entry::'b) (Exit::'b) (H::'c set) (L::'c set) (src (a::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node)). local.CFG.state_val (s::(('c ⇒ 'd option) × 'e) list) V = local.CFG.state_val (s'::(('c ⇒ 'd option) × 'e) list) V› ‹intra_kind (knd (a::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node))› ‹local.CFG.pred (knd (a::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node)) (s::(('c ⇒ 'd option) × 'e) list)› ‹local.CFG.pred (knd (a::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node)) (s'::(('c ⇒ 'd option) × 'e) list)›*) show "∀V∈lift_Def Def Entry Exit H L (src a). state_val (transfer (knd a) s) V = state_val (transfer (knd a) s') V" proof (standard) (*goal: ‹⋀V::'c. V ∈ lift_Def (Def::'b ⇒ 'c set) (Entry::'b) (Exit::'b) (H::'c set) (L::'c set) (src (a::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node)) ⟹ local.CFG.state_val (local.CFG.transfer (knd a) (s::(('c ⇒ 'd option) × 'e) list)) V = local.CFG.state_val (local.CFG.transfer (knd a) (s'::(('c ⇒ 'd option) × 'e) list)) V›*) fix V assume "V ∈ lift_Def Def Entry Exit H L (src a)" (*‹(V::'c) ∈ lift_Def (Def::'b ⇒ 'c set) (Entry::'b) (Exit::'b) (H::'c set) (L::'c set) (src (a::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node))›*) with assms (*‹lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a› ‹∀V∈lift_Use Use Entry Exit H L (src a). local.CFG.state_val s V = local.CFG.state_val s' V› ‹intra_kind (knd a)› ‹local.CFG.pred (knd a) s› ‹local.CFG.pred (knd a) s'›*) show "state_val (transfer (knd a) s) V = state_val (transfer (knd a) s') V" proof (induct rule:lift_valid_edge.induct (*‹⟦lift_valid_edge (?valid_edge::?'edge ⇒ bool) (?src::?'edge ⇒ ?'node) (?trg::?'edge ⇒ ?'node) (?knd::?'edge ⇒ (?'var, ?'val, ?'ret, ?'pname) edge_kind) (?E::?'node) (?X::?'node) (?x::?'node LDCFG_node × (?'var, ?'val, ?'ret, ?'pname) edge_kind × ?'node LDCFG_node); ⋀(a::?'edge) e::?'node LDCFG_node × (?'var, ?'val, ?'ret, ?'pname) edge_kind × ?'node LDCFG_node. ⟦?valid_edge a; ?src a ≠ ?E ∨ ?trg a ≠ ?X; e = (Node (?src a), ?knd a, Node (?trg a))⟧ ⟹ (?P::?'node LDCFG_node × (?'var, ?'val, ?'ret, ?'pname) edge_kind × ?'node LDCFG_node ⇒ bool) e; ⋀e::?'node LDCFG_node × (?'var, ?'val, ?'ret, ?'pname) edge_kind × ?'node LDCFG_node. e = (NewEntry, (λs::?'var ⇒ ?'val option. True)⇩√, Node ?E) ⟹ ?P e; ⋀e::?'node LDCFG_node × (?'var, ?'val, ?'ret, ?'pname) edge_kind × ?'node LDCFG_node. e = (Node ?X, (λs::?'var ⇒ ?'val option. True)⇩√, NewExit) ⟹ ?P e; ⋀e::?'node LDCFG_node × (?'var, ?'val, ?'ret, ?'pname) edge_kind × ?'node LDCFG_node. e = (NewEntry, (λs::?'var ⇒ ?'val option. False)⇩√, NewExit) ⟹ ?P e⟧ ⟹ ?P ?x›*)) (*goals: 1. ‹⋀a e. ⟦valid_edge a; sourcenode a ≠ Entry ∨ targetnode a ≠ Exit; e = (Node (sourcenode a), kind a, Node (targetnode a)); ∀V∈lift_Use Use Entry Exit H L (src e). local.CFG.state_val s V = local.CFG.state_val s' V; intra_kind (knd e); local.CFG.pred (knd e) s; local.CFG.pred (knd e) s'; V ∈ lift_Def Def Entry Exit H L (src e)⟧ ⟹ local.CFG.state_val (local.CFG.transfer (knd e) s) V = local.CFG.state_val (local.CFG.transfer (knd e) s') V› 2. ‹⋀e. ⟦e = (NewEntry, (λs. True)⇩√, Node Entry); ∀V∈lift_Use Use Entry Exit H L (src e). local.CFG.state_val s V = local.CFG.state_val s' V; intra_kind (knd e); local.CFG.pred (knd e) s; local.CFG.pred (knd e) s'; V ∈ lift_Def Def Entry Exit H L (src e)⟧ ⟹ local.CFG.state_val (local.CFG.transfer (knd e) s) V = local.CFG.state_val (local.CFG.transfer (knd e) s') V› 3. ‹⋀e. ⟦e = (Node Exit, (λs. True)⇩√, NewExit); ∀V∈lift_Use Use Entry Exit H L (src e). local.CFG.state_val s V = local.CFG.state_val s' V; intra_kind (knd e); local.CFG.pred (knd e) s; local.CFG.pred (knd e) s'; V ∈ lift_Def Def Entry Exit H L (src e)⟧ ⟹ local.CFG.state_val (local.CFG.transfer (knd e) s) V = local.CFG.state_val (local.CFG.transfer (knd e) s') V› 4. ‹⋀e. ⟦e = (NewEntry, (λs. False)⇩√, NewExit); ∀V∈lift_Use Use Entry Exit H L (src e). local.CFG.state_val s V = local.CFG.state_val s' V; intra_kind (knd e); local.CFG.pred (knd e) s; local.CFG.pred (knd e) s'; V ∈ lift_Def Def Entry Exit H L (src e)⟧ ⟹ local.CFG.state_val (local.CFG.transfer (knd e) s) V = local.CFG.state_val (local.CFG.transfer (knd e) s') V›*) case (lve_edge a e) (*‹valid_edge a› ‹sourcenode a ≠ Entry ∨ targetnode a ≠ Exit› ‹e = (Node (sourcenode a), kind a, Node (targetnode a))› ‹∀V::'c∈lift_Use (Use::'b ⇒ 'c set) (Entry::'b) (Exit::'b) (H::'c set) (L::'c set) (src (e::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node)). local.CFG.state_val (s::(('c ⇒ 'd option) × 'e) list) V = local.CFG.state_val (s'::(('c ⇒ 'd option) × 'e) list) V› ‹intra_kind (knd e)› ‹local.CFG.pred (knd (e::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node)) (s::(('c ⇒ 'd option) × 'e) list)› ‹local.CFG.pred (knd e) s'› ‹V ∈ lift_Def Def Entry Exit H L (src e)›*) from ‹e = (Node (sourcenode a), kind a, Node (targetnode a))› (*‹e = (Node (sourcenode a), kind a, Node (targetnode a))›*) ‹intra_kind (knd e)› (*‹intra_kind (knd e)›*) have "intra_kind (kind a)" by simp show "?case" (*goal: ‹local.CFG.state_val (local.CFG.transfer (knd e) s) V = local.CFG.state_val (local.CFG.transfer (knd e) s') V›*) proof (cases "Node (sourcenode a) = Node Entry") (*goals: 1. ‹Node (sourcenode a) = Node Entry ⟹ local.CFG.state_val (local.CFG.transfer (knd e) s) V = local.CFG.state_val (local.CFG.transfer (knd e) s') V› 2. ‹Node (sourcenode a) ≠ Node Entry ⟹ local.CFG.state_val (local.CFG.transfer (knd e) s) V = local.CFG.state_val (local.CFG.transfer (knd e) s') V›*) case True (*‹Node (sourcenode a) = Node Entry›*) hence "sourcenode a = Entry" by simp from Entry_Exit_edge (*‹∃a::'a. (valid_edge::'a ⇒ bool) a ∧ (sourcenode::'a ⇒ 'b) a = (Entry::'b) ∧ (targetnode::'a ⇒ 'b) a = (Exit::'b) ∧ (kind::'a ⇒ ('c, 'd, 'e, 'f) edge_kind) a = (λs::'c ⇒ 'd option. False)⇩√›*) obtain a' where "valid_edge a'" and "sourcenode a' = Entry" and "targetnode a' = Exit" and "kind a' = (λs. False)⇩√" (*goal: ‹(⋀a'. ⟦valid_edge a'; sourcenode a' = Entry; targetnode a' = Exit; kind a' = (λs. False)⇩√⟧ ⟹ thesis) ⟹ thesis›*) by blast have "∃Q. kind a = (Q)⇩√" proof (cases "targetnode a = Exit") (*goals: 1. ‹targetnode a = Exit ⟹ ∃Q. kind a = (Q)⇩√› 2. ‹targetnode a ≠ Exit ⟹ ∃Q. kind a = (Q)⇩√›*) case True (*‹targetnode a = Exit›*) with ‹valid_edge a› (*‹(valid_edge::'a::type ⇒ bool) (a::'a::type)›*) ‹valid_edge a'› (*‹valid_edge a'›*) ‹sourcenode a = Entry› (*‹(sourcenode::'a ⇒ 'b) (a::'a) = (Entry::'b)›*) ‹sourcenode a' = Entry› (*‹sourcenode a' = Entry›*) ‹targetnode a' = Exit› (*‹targetnode a' = Exit›*) have "a = a'" by (fastforce dest:edge_det (*‹⟦valid_edge ?a; valid_edge ?a'; sourcenode ?a = sourcenode ?a'; targetnode ?a = targetnode ?a'⟧ ⟹ ?a = ?a'›*)) with ‹kind a' = (λs. False)⇩√› (*‹kind a' = (λs. False)⇩√›*) show "?thesis" (*goal: ‹∃Q::('c ⇒ 'd option) ⇒ bool. (kind::'a ⇒ ('c, 'd, 'e, 'f) edge_kind) (a::'a) = (Q)⇩√›*) by simp next (*goal: ‹targetnode a ≠ Exit ⟹ ∃Q. kind a = (Q)⇩√›*) case False (*‹targetnode a ≠ Exit›*) with ‹valid_edge a› (*‹valid_edge a›*) ‹valid_edge a'› (*‹valid_edge a'›*) ‹sourcenode a = Entry› (*‹(sourcenode::'a ⇒ 'b) (a::'a) = (Entry::'b)›*) ‹sourcenode a' = Entry› (*‹sourcenode a' = Entry›*) ‹targetnode a' = Exit› (*‹targetnode a' = Exit›*) ‹intra_kind (kind a)› (*‹intra_kind (kind a)›*) ‹kind a' = (λs. False)⇩√› (*‹(kind::'a ⇒ ('c, 'd, 'e, 'f) edge_kind) (a'::'a) = (λs::'c ⇒ 'd option. False)⇩√›*) show "?thesis" (*goal: ‹∃Q::('c ⇒ 'd option) ⇒ bool. (kind::'a ⇒ ('c, 'd, 'e, 'f) edge_kind) (a::'a) = (Q)⇩√›*) by (auto dest:deterministic (*‹⟦valid_edge ?a; valid_edge ?a'; sourcenode ?a = sourcenode ?a'; targetnode ?a ≠ targetnode ?a'; intra_kind (kind ?a); intra_kind (kind ?a')⟧ ⟹ ∃Q Q'. kind ?a = (Q)⇩√ ∧ kind ?a' = (Q')⇩√ ∧ (∀s. (Q s ⟶ ¬ Q' s) ∧ (Q' s ⟶ ¬ Q s))›*) simp:intra_kind_def (*‹intra_kind ?et ≡ (∃f. ?et = ⇑f) ∨ (∃Q. ?et = (Q)⇩√)›*)) qed from True (*‹Node (sourcenode a) = Node Entry›*) ‹V ∈ lift_Def Def Entry Exit H L (src e)› (*‹V ∈ lift_Def Def Entry Exit H L (src e)›*) Entry_empty (*‹Def Entry = {} ∧ Use Entry = {}›*) ‹e = (Node (sourcenode a), kind a, Node (targetnode a))› (*‹e = (Node (sourcenode a), kind a, Node (targetnode a))›*) have "V ∈ H" by (fastforce elim:lift_Def_set.cases (*‹⟦(?a1.0, ?a2.0) ∈ lift_Def_set ?Def ?E ?X ?H ?L; ⋀V n. ⟦?a1.0 = Node n; ?a2.0 = V; V ∈ ?Def n⟧ ⟹ ?P; ⋀V. ⟦?a1.0 = Node ?E; ?a2.0 = V; V ∈ ?H⟧ ⟹ ?P⟧ ⟹ ?P›*)) from True (*‹Node (sourcenode a) = Node Entry›*) ‹e = (Node (sourcenode a), kind a, Node (targetnode a))› (*‹e = (Node (sourcenode a), kind a, Node (targetnode a))›*) ‹sourcenode a ≠ Entry ∨ targetnode a ≠ Exit› (*‹sourcenode a ≠ Entry ∨ targetnode a ≠ Exit›*) have "∀V∈H. V ∈ lift_Use Use Entry Exit H L (src e)" by (fastforce intro:lift_Use_High (*‹(?V::?'var) ∈ (?H::?'var set) ⟹ (Node (?E::?'node), ?V) ∈ lift_Use_set (?Use::?'node ⇒ ?'var set) ?E (?X::?'node) ?H (?L::?'var set)›*)) with ‹∀V∈lift_Use Use Entry Exit H L (src e). state_val s V = state_val s' V› (*‹∀V∈lift_Use Use Entry Exit H L (src e). local.CFG.state_val s V = local.CFG.state_val s' V›*) ‹V ∈ H› (*‹V ∈ H›*) have "state_val s V = state_val s' V" by simp with ‹e = (Node (sourcenode a), kind a, Node (targetnode a))› (*‹e = (Node (sourcenode a), kind a, Node (targetnode a))›*) ‹∃Q. kind a = (Q)⇩√› (*‹∃Q. kind a = (Q)⇩√›*) ‹pred (knd e) s› (*‹local.CFG.pred (knd e) s›*) ‹pred (knd e) s'› (*‹local.CFG.pred (knd e) s'›*) show "?thesis" (*goal: ‹local.CFG.state_val (local.CFG.transfer (knd e) s) V = local.CFG.state_val (local.CFG.transfer (knd e) s') V›*) apply (cases s) (*goals: 1. ‹⟦e = (Node (sourcenode a), kind a, Node (targetnode a)); ∃Q. kind a = (Q)⇩√; local.CFG.pred (knd e) s; local.CFG.pred (knd e) s'; local.CFG.state_val s V = local.CFG.state_val s' V; s = []⟧ ⟹ local.CFG.state_val (local.CFG.transfer (knd e) s) V = local.CFG.state_val (local.CFG.transfer (knd e) s') V› 2. ‹⋀a list. ⟦e = (Node (sourcenode a), kind a, Node (targetnode a)); ∃Q. kind a = (Q)⇩√; local.CFG.pred (knd e) s; local.CFG.pred (knd e) s'; local.CFG.state_val s V = local.CFG.state_val s' V; s = a # list⟧ ⟹ local.CFG.state_val (local.CFG.transfer (knd e) s) V = local.CFG.state_val (local.CFG.transfer (knd e) s') V› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*goal: ‹⋀a list. ⟦e = (Node (sourcenode a), kind a, Node (targetnode a)); ∃Q. kind a = (Q)⇩√; local.CFG.pred (knd e) s; local.CFG.pred (knd e) s'; local.CFG.state_val s V = local.CFG.state_val s' V; s = a # list⟧ ⟹ local.CFG.state_val (local.CFG.transfer (knd e) s) V = local.CFG.state_val (local.CFG.transfer (knd e) s') V›*) apply (cases s') (*goals: 1. ‹⋀a b list Q. ⟦e = (Node (sourcenode a), (Q)⇩√, Node (targetnode a)); Q a; local.CFG.pred (Q)⇩√ s'; a V = local.CFG.state_val s' V; s = (a, b) # list; kind a = (Q)⇩√; s' = []⟧ ⟹ local.CFG.state_val s' V = local.CFG.state_val (local.CFG.transfer (Q)⇩√ s') V› 2. ‹⋀a b list Q aaa lista. ⟦e = (Node (sourcenode a), (Q)⇩√, Node (targetnode a)); Q a; local.CFG.pred (Q)⇩√ s'; a V = local.CFG.state_val s' V; s = (a, b) # list; kind a = (Q)⇩√; s' = aaa # lista⟧ ⟹ local.CFG.state_val s' V = local.CFG.state_val (local.CFG.transfer (Q)⇩√ s') V› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) (*proven 2 subgoals*) . next (*goal: ‹Node (sourcenode a) ≠ Node Entry ⟹ local.CFG.state_val (local.CFG.transfer (knd e) s) V = local.CFG.state_val (local.CFG.transfer (knd e) s') V›*) case False (*‹Node ((sourcenode::'a::type ⇒ 'b::type) (a::'a::type)) ≠ Node (Entry::'b::type)›*) { fix V' assume "V' ∈ Use (sourcenode a)" (*‹(V'::'c) ∈ (Use::'b ⇒ 'c set) ((sourcenode::'a ⇒ 'b) (a::'a))›*) with ‹e = (Node (sourcenode a), kind a, Node (targetnode a))› (*‹e = (Node (sourcenode a), kind a, Node (targetnode a))›*) have "V' ∈ lift_Use Use Entry Exit H L (src e)" by (fastforce intro:lift_Use_node (*‹?V ∈ ?Use ?n ⟹ (Node ?n, ?V) ∈ lift_Use_set ?Use ?E ?X ?H ?L›*)) } with ‹∀V∈lift_Use Use Entry Exit H L (src e). state_val s V = state_val s' V› (*‹∀V∈lift_Use Use Entry Exit H L (src e). local.CFG.state_val s V = local.CFG.state_val s' V›*) have "∀V∈Use (sourcenode a). state_val s V = state_val s' V" by fastforce from ‹valid_edge a› (*‹valid_edge a›*) this (*‹∀V∈Use (sourcenode a). local.CFG.state_val s V = local.CFG.state_val s' V›*) ‹pred (knd e) s› (*‹local.CFG.pred (knd e) s›*) ‹pred (knd e) s'› (*‹local.CFG.pred (knd e) s'›*) ‹e = (Node (sourcenode a), kind a, Node (targetnode a))› (*‹e = (Node (sourcenode a), kind a, Node (targetnode a))›*) ‹intra_kind (knd e)› (*‹intra_kind (knd (e::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node))›*) have "∀V ∈ Def (sourcenode a). state_val (transfer (kind a) s) V = state_val (transfer (kind a) s') V" apply - (*goal: ‹∀V∈Def (sourcenode a). local.CFG.state_val (local.CFG.transfer (kind a) s) V = local.CFG.state_val (local.CFG.transfer (kind a) s') V›*) apply (erule CFG_intra_edge_transfer_uses_only_Use (*‹⟦valid_edge ?a; ∀V∈Use (sourcenode ?a). local.CFG.state_val ?s V = local.CFG.state_val ?s' V; intra_kind (kind ?a); local.CFG.pred (kind ?a) ?s; local.CFG.pred (kind ?a) ?s'⟧ ⟹ ∀V∈Def (sourcenode ?a). local.CFG.state_val (local.CFG.transfer (kind ?a) ?s) V = local.CFG.state_val (local.CFG.transfer (kind ?a) ?s') V›*)) (*goals: 1. ‹⟦∀V∈Use (sourcenode a). local.CFG.state_val s V = local.CFG.state_val s' V; local.CFG.pred (knd e) s; local.CFG.pred (knd e) s'; e = (Node (sourcenode a), kind a, Node (targetnode a)); intra_kind (knd e)⟧ ⟹ ∀V∈Use (sourcenode a). local.CFG.state_val s V = local.CFG.state_val s' V› 2. ‹⟦∀V∈Use (sourcenode a). local.CFG.state_val s V = local.CFG.state_val s' V; local.CFG.pred (knd e) s; local.CFG.pred (knd e) s'; e = (Node (sourcenode a), kind a, Node (targetnode a)); intra_kind (knd e)⟧ ⟹ intra_kind (kind a)› 3. ‹⟦∀V∈Use (sourcenode a). local.CFG.state_val s V = local.CFG.state_val s' V; local.CFG.pred (knd e) s; local.CFG.pred (knd e) s'; e = (Node (sourcenode a), kind a, Node (targetnode a)); intra_kind (knd e)⟧ ⟹ local.CFG.pred (kind a) s› 4. ‹⟦∀V∈Use (sourcenode a). local.CFG.state_val s V = local.CFG.state_val s' V; local.CFG.pred (knd e) s; local.CFG.pred (knd e) s'; e = (Node (sourcenode a), kind a, Node (targetnode a)); intra_kind (knd e)⟧ ⟹ local.CFG.pred (kind a) 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*) . from ‹V ∈ lift_Def Def Entry Exit H L (src e)› (*‹V ∈ lift_Def Def Entry Exit H L (src e)›*) False (*‹Node (sourcenode a) ≠ Node Entry›*) ‹e = (Node (sourcenode a), kind a, Node (targetnode a))› (*‹(e::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node) = (Node ((sourcenode::'a ⇒ 'b) (a::'a)), (kind::'a ⇒ ('c, 'd, 'e, 'f) edge_kind) a, Node ((targetnode::'a ⇒ 'b) a))›*) have "V ∈ Def (sourcenode a)" by (fastforce elim:lift_Def_set.cases (*‹⟦(?a1.0, ?a2.0) ∈ lift_Def_set ?Def ?E ?X ?H ?L; ⋀V n. ⟦?a1.0 = Node n; ?a2.0 = V; V ∈ ?Def n⟧ ⟹ ?P; ⋀V. ⟦?a1.0 = Node ?E; ?a2.0 = V; V ∈ ?H⟧ ⟹ ?P⟧ ⟹ ?P›*)) with ‹∀V ∈ Def (sourcenode a). state_val (transfer (kind a) s) V = state_val (transfer (kind a) s') V› (*‹∀V∈Def (sourcenode a). local.CFG.state_val (local.CFG.transfer (kind a) s) V = local.CFG.state_val (local.CFG.transfer (kind a) s') V›*) ‹e = (Node (sourcenode a), kind a, Node (targetnode a))› (*‹e = (Node (sourcenode a), kind a, Node (targetnode a))›*) show "?thesis" (*goal: ‹local.CFG.state_val (local.CFG.transfer (knd e) s) V = local.CFG.state_val (local.CFG.transfer (knd e) s') V›*) by simp qed next (*goals: 1. ‹⋀e. ⟦e = (NewEntry, (λs. True)⇩√, Node Entry); ∀V∈lift_Use Use Entry Exit H L (src e). local.CFG.state_val s V = local.CFG.state_val s' V; intra_kind (knd e); local.CFG.pred (knd e) s; local.CFG.pred (knd e) s'; V ∈ lift_Def Def Entry Exit H L (src e)⟧ ⟹ local.CFG.state_val (local.CFG.transfer (knd e) s) V = local.CFG.state_val (local.CFG.transfer (knd e) s') V› 2. ‹⋀e. ⟦e = (Node Exit, (λs. True)⇩√, NewExit); ∀V∈lift_Use Use Entry Exit H L (src e). local.CFG.state_val s V = local.CFG.state_val s' V; intra_kind (knd e); local.CFG.pred (knd e) s; local.CFG.pred (knd e) s'; V ∈ lift_Def Def Entry Exit H L (src e)⟧ ⟹ local.CFG.state_val (local.CFG.transfer (knd e) s) V = local.CFG.state_val (local.CFG.transfer (knd e) s') V› 3. ‹⋀e. ⟦e = (NewEntry, (λs. False)⇩√, NewExit); ∀V∈lift_Use Use Entry Exit H L (src e). local.CFG.state_val s V = local.CFG.state_val s' V; intra_kind (knd e); local.CFG.pred (knd e) s; local.CFG.pred (knd e) s'; V ∈ lift_Def Def Entry Exit H L (src e)⟧ ⟹ local.CFG.state_val (local.CFG.transfer (knd e) s) V = local.CFG.state_val (local.CFG.transfer (knd e) s') V›*) case (lve_Entry_edge e) (*‹(e::'b::type LDCFG_node × ('c::type, 'd::type, 'e::type, 'f::type) edge_kind × 'b::type LDCFG_node) = (NewEntry, (λs::'c::type ⇒ 'd::type option. True)⇩√, Node (Entry::'b::type))› ‹∀V∈lift_Use Use Entry Exit H L (src e). local.CFG.state_val s V = local.CFG.state_val s' V› ‹intra_kind (knd e)› ‹local.CFG.pred (knd e) s› ‹local.CFG.pred (knd e) s'› ‹V ∈ lift_Def Def Entry Exit H L (src e)›*) from ‹V ∈ lift_Def Def Entry Exit H L (src e)› (*‹V ∈ lift_Def Def Entry Exit H L (src e)›*) ‹e = (NewEntry, (λs. True)⇩√, Node Entry)› (*‹e = (NewEntry, (λs. True)⇩√, Node Entry)›*) have False by (fastforce elim:lift_Def_set.cases (*‹⟦(?a1.0, ?a2.0) ∈ lift_Def_set ?Def ?E ?X ?H ?L; ⋀V n. ⟦?a1.0 = Node n; ?a2.0 = V; V ∈ ?Def n⟧ ⟹ ?P; ⋀V. ⟦?a1.0 = Node ?E; ?a2.0 = V; V ∈ ?H⟧ ⟹ ?P⟧ ⟹ ?P›*)) thus "?case" (*goal: ‹local.CFG.state_val (local.CFG.transfer (knd e) s) V = local.CFG.state_val (local.CFG.transfer (knd e) s') V›*) by simp next (*goals: 1. ‹⋀e::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node. ⟦e = (Node (Exit::'b), (λs::'c ⇒ 'd option. True)⇩√, NewExit); ∀V::'c∈lift_Use (Use::'b ⇒ 'c set) (Entry::'b) Exit (H::'c set) (L::'c set) (src e). local.CFG.state_val (s::(('c ⇒ 'd option) × 'e) list) V = local.CFG.state_val (s'::(('c ⇒ 'd option) × 'e) list) V; intra_kind (knd e); local.CFG.pred (knd e) s; local.CFG.pred (knd e) s'; (V::'c) ∈ lift_Def (Def::'b ⇒ 'c set) Entry Exit H L (src e)⟧ ⟹ local.CFG.state_val (local.CFG.transfer (knd e) s) V = local.CFG.state_val (local.CFG.transfer (knd e) s') V› 2. ‹⋀e::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node. ⟦e = (NewEntry, (λs::'c ⇒ 'd option. False)⇩√, NewExit); ∀V::'c∈lift_Use (Use::'b ⇒ 'c set) (Entry::'b) (Exit::'b) (H::'c set) (L::'c set) (src e). local.CFG.state_val (s::(('c ⇒ 'd option) × 'e) list) V = local.CFG.state_val (s'::(('c ⇒ 'd option) × 'e) list) V; intra_kind (knd e); local.CFG.pred (knd e) s; local.CFG.pred (knd e) s'; (V::'c) ∈ lift_Def (Def::'b ⇒ 'c set) Entry Exit H L (src e)⟧ ⟹ local.CFG.state_val (local.CFG.transfer (knd e) s) V = local.CFG.state_val (local.CFG.transfer (knd e) s') V›*) case (lve_Exit_edge e) (*‹e = (Node Exit, (λs. True)⇩√, NewExit)› ‹∀V::'c::type∈lift_Use (Use::'b::type ⇒ 'c::type set) (Entry::'b::type) (Exit::'b::type) (H::'c::type set) (L::'c::type set) (src (e::'b::type LDCFG_node × ('c::type, 'd::type, 'e::type, 'f::type) edge_kind × 'b::type LDCFG_node)). local.CFG.state_val (s::(('c::type ⇒ 'd::type option) × 'e::type) list) V = local.CFG.state_val (s'::(('c::type ⇒ 'd::type option) × 'e::type) list) V› ‹intra_kind (knd (e::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node))› ‹local.CFG.pred (knd e) s› ‹local.CFG.pred (knd e) s'› ‹V ∈ lift_Def Def Entry Exit H L (src e)›*) from ‹V ∈ lift_Def Def Entry Exit H L (src e)› (*‹V ∈ lift_Def Def Entry Exit H L (src e)›*) ‹e = (Node Exit, (λs. True)⇩√, NewExit)› (*‹e = (Node Exit, (λs. True)⇩√, NewExit)›*) have False by (fastforce elim:lift_Def_set.cases (*‹⟦(?a1.0, ?a2.0) ∈ lift_Def_set ?Def ?E ?X ?H ?L; ⋀V n. ⟦?a1.0 = Node n; ?a2.0 = V; V ∈ ?Def n⟧ ⟹ ?P; ⋀V. ⟦?a1.0 = Node ?E; ?a2.0 = V; V ∈ ?H⟧ ⟹ ?P⟧ ⟹ ?P›*) intro!:Entry_noteq_Exit (*‹Entry = Exit ⟹ False›*) simp:Exit_empty (*‹Def Exit = {} ∧ Use Exit = {}›*)) thus "?case" (*goal: ‹local.CFG.state_val (local.CFG.transfer (knd e) s) V = local.CFG.state_val (local.CFG.transfer (knd e) s') V›*) by simp next (*goal: ‹⋀e. ⟦e = (NewEntry, (λs. False)⇩√, NewExit); ∀V∈lift_Use Use Entry Exit H L (src e). local.CFG.state_val s V = local.CFG.state_val s' V; intra_kind (knd e); local.CFG.pred (knd e) s; local.CFG.pred (knd e) s'; V ∈ lift_Def Def Entry Exit H L (src e)⟧ ⟹ local.CFG.state_val (local.CFG.transfer (knd e) s) V = local.CFG.state_val (local.CFG.transfer (knd e) s') V›*) case (lve_Entry_Exit_edge e) (*‹e = (NewEntry, (λs. False)⇩√, NewExit)› ‹∀V∈lift_Use Use Entry Exit H L (src e). local.CFG.state_val s V = local.CFG.state_val s' V› ‹intra_kind (knd e)› ‹local.CFG.pred (knd e) s› ‹local.CFG.pred (knd e) s'› ‹(V::'c::type) ∈ lift_Def (Def::'b::type ⇒ 'c::type set) (Entry::'b::type) (Exit::'b::type) (H::'c::type set) (L::'c::type set) (src (e::'b::type LDCFG_node × ('c::type, 'd::type, 'e::type, 'f::type) edge_kind × 'b::type LDCFG_node))›*) thus "?case" (*goal: ‹local.CFG.state_val (local.CFG.transfer (knd e) s) V = local.CFG.state_val (local.CFG.transfer (knd e) s') V›*) apply (cases s) (*goals: 1. ‹⟦e = (NewEntry, (λs. False)⇩√, NewExit); ∀V∈lift_Use Use Entry Exit H L (src e). local.CFG.state_val s V = local.CFG.state_val s' V; intra_kind (knd e); local.CFG.pred (knd e) s; local.CFG.pred (knd e) s'; V ∈ lift_Def Def Entry Exit H L (src e); s = []⟧ ⟹ local.CFG.state_val (local.CFG.transfer (knd e) s) V = local.CFG.state_val (local.CFG.transfer (knd e) s') V› 2. ‹⋀a list. ⟦e = (NewEntry, (λs. False)⇩√, NewExit); ∀V∈lift_Use Use Entry Exit H L (src e). local.CFG.state_val s V = local.CFG.state_val s' V; intra_kind (knd e); local.CFG.pred (knd e) s; local.CFG.pred (knd e) s'; V ∈ lift_Def Def Entry Exit H L (src e); s = a # list⟧ ⟹ local.CFG.state_val (local.CFG.transfer (knd e) s) V = local.CFG.state_val (local.CFG.transfer (knd e) s') V› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . qed qed next (*goals: 1. ‹⋀a s s'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; local.CFG.pred (knd a) s; snd (hd s) = snd (hd s'); ∀V∈lift_Use Use Entry Exit H L (src a). local.CFG.state_val s V = local.CFG.state_val s' V; length s = length s'⟧ ⟹ local.CFG.pred (knd a) s'› 2. ‹⋀a Q r p fs ins outs. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q:r↪⇘p⇙fs; (p, ins, outs) ∈ set procs⟧ ⟹ length fs = length ins› 3. ‹⋀a Q r p fs a' Q' r' p' fs' s. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q:r↪⇘p⇙fs; lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a'; knd a' = Q':r'↪⇘p'⇙fs'; src a = src a'; local.CFG.pred (knd a) s; local.CFG.pred (knd a') s⟧ ⟹ a = a'› 4. ‹⋀a Q r p fs i ins outs s s'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q:r↪⇘p⇙fs; i < length ins; (p, ins, outs) ∈ set procs; local.CFG.pred (knd a) s; local.CFG.pred (knd a) s'; ∀V∈lift_ParamUses ParamUses (src a) ! i. local.CFG.state_val s V = local.CFG.state_val s' V⟧ ⟹ local.CFG.params fs (local.CFG.state_val s) ! i = local.CFG.params fs (local.CFG.state_val s') ! i› 5. ‹⋀a Q' p f' ins outs vmap vmap'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q'↩⇘p⇙f'; (p, ins, outs) ∈ set procs⟧ ⟹ f' vmap vmap' = vmap'(lift_ParamDefs ParamDefs (trg a) [:=] map vmap outs)› 6. ‹⋀a a'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a'; src a = src a'; trg a ≠ trg a'; intra_kind (knd a); intra_kind (knd a')⟧ ⟹ ∃Q Q'. knd a = (Q)⇩√ ∧ knd a' = (Q')⇩√ ∧ (∀s. (Q s ⟶ ¬ Q' s) ∧ (Q' s ⟶ ¬ Q s))›*) fix a and s and s' assume "lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a" and "pred (knd a) s" and "snd (hd s) = snd (hd s')" and "∀V∈lift_Use Use Entry Exit H L (src a). state_val s V = state_val s' V" and "length s = length s'" (*‹lift_valid_edge (valid_edge::'a ⇒ bool) (sourcenode::'a ⇒ 'b) (targetnode::'a ⇒ 'b) (kind::'a ⇒ ('c, 'd, 'e, 'f) edge_kind) (Entry::'b) (Exit::'b) (a::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node)› ‹local.CFG.pred (knd (a::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node)) (s::(('c ⇒ 'd option) × 'e) list)› ‹snd (hd (s::(('c ⇒ 'd option) × 'e) list)) = snd (hd (s'::(('c ⇒ 'd option) × 'e) list))› ‹∀V::'c∈lift_Use (Use::'b ⇒ 'c set) (Entry::'b) (Exit::'b) (H::'c set) (L::'c set) (src (a::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node)). local.CFG.state_val (s::(('c ⇒ 'd option) × 'e) list) V = local.CFG.state_val (s'::(('c ⇒ 'd option) × 'e) list) V› ‹length (s::(('c ⇒ 'd option) × 'e) list) = length (s'::(('c ⇒ 'd option) × 'e) list)›*) thus "pred (knd a) s'" proof (induct rule:lift_valid_edge.induct (*‹⟦lift_valid_edge ?valid_edge ?src ?trg ?knd ?E ?X ?x; ⋀a e. ⟦?valid_edge a; ?src a ≠ ?E ∨ ?trg a ≠ ?X; e = (Node (?src a), ?knd a, Node (?trg a))⟧ ⟹ ?P e; ⋀e. e = (NewEntry, (λs. True)⇩√, Node ?E) ⟹ ?P e; ⋀e. e = (Node ?X, (λs. True)⇩√, NewExit) ⟹ ?P e; ⋀e. e = (NewEntry, (λs. False)⇩√, NewExit) ⟹ ?P e⟧ ⟹ ?P ?x›*)) (*goals: 1. ‹⋀a e. ⟦valid_edge a; sourcenode a ≠ Entry ∨ targetnode a ≠ Exit; e = (Node (sourcenode a), kind a, Node (targetnode a)); local.CFG.pred (knd e) s; snd (hd s) = snd (hd s'); ∀V∈lift_Use Use Entry Exit H L (src e). local.CFG.state_val s V = local.CFG.state_val s' V; length s = length s'⟧ ⟹ local.CFG.pred (knd e) s'› 2. ‹⋀e. ⟦e = (NewEntry, (λs. True)⇩√, Node Entry); local.CFG.pred (knd e) s; snd (hd s) = snd (hd s'); ∀V∈lift_Use Use Entry Exit H L (src e). local.CFG.state_val s V = local.CFG.state_val s' V; length s = length s'⟧ ⟹ local.CFG.pred (knd e) s'› 3. ‹⋀e. ⟦e = (Node Exit, (λs. True)⇩√, NewExit); local.CFG.pred (knd e) s; snd (hd s) = snd (hd s'); ∀V∈lift_Use Use Entry Exit H L (src e). local.CFG.state_val s V = local.CFG.state_val s' V; length s = length s'⟧ ⟹ local.CFG.pred (knd e) s'› 4. ‹⋀e. ⟦e = (NewEntry, (λs. False)⇩√, NewExit); local.CFG.pred (knd e) s; snd (hd s) = snd (hd s'); ∀V∈lift_Use Use Entry Exit H L (src e). local.CFG.state_val s V = local.CFG.state_val s' V; length s = length s'⟧ ⟹ local.CFG.pred (knd e) s'›*) case (lve_edge a e) (*‹valid_edge a› ‹(sourcenode::'a ⇒ 'b) (a::'a) ≠ (Entry::'b) ∨ (targetnode::'a ⇒ 'b) a ≠ (Exit::'b)› ‹e = (Node (sourcenode a), kind a, Node (targetnode a))› ‹local.CFG.pred (knd e) s› ‹snd (hd s) = snd (hd s')› ‹∀V∈lift_Use Use Entry Exit H L (src e). local.CFG.state_val s V = local.CFG.state_val s' V› ‹length s = length s'›*) from ‹e = (Node (sourcenode a), kind a, Node (targetnode a))› (*‹e = (Node (sourcenode a), kind a, Node (targetnode a))›*) ‹pred (knd e) s› (*‹local.CFG.pred (knd (e::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node)) (s::(('c ⇒ 'd option) × 'e) list)›*) have "pred (kind a) s" and "src e = Node (sourcenode a)" apply - (*goals: 1. ‹⟦e = (Node (sourcenode a), kind a, Node (targetnode a)); local.CFG.pred (knd e) s⟧ ⟹ local.CFG.pred (kind a) s› 2. ‹⟦e = (Node (sourcenode a), kind a, Node (targetnode a)); local.CFG.pred (knd e) s⟧ ⟹ src e = Node (sourcenode a)› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) . from ‹src e = Node (sourcenode a)› (*‹src e = Node (sourcenode a)›*) ‹∀V∈lift_Use Use Entry Exit H L (src e). state_val s V = state_val s' V› (*‹∀V::'c::type∈lift_Use (Use::'b::type ⇒ 'c::type set) (Entry::'b::type) (Exit::'b::type) (H::'c::type set) (L::'c::type set) (src (e::'b::type LDCFG_node × ('c::type, 'd::type, 'e::type, 'f::type) edge_kind × 'b::type LDCFG_node)). local.CFG.state_val (s::(('c::type ⇒ 'd::type option) × 'e::type) list) V = local.CFG.state_val (s'::(('c::type ⇒ 'd::type option) × 'e::type) list) V›*) have "∀V ∈ Use (sourcenode a). state_val s V = state_val s' V" by (auto dest:lift_Use_node (*‹?V ∈ ?Use ?n ⟹ (Node ?n, ?V) ∈ lift_Use_set ?Use ?E ?X ?H ?L›*)) from ‹valid_edge a› (*‹valid_edge a›*) ‹pred (kind a) s› (*‹local.CFG.pred ((kind::'a ⇒ ('c, 'd, 'e, 'f) edge_kind) (a::'a)) (s::(('c ⇒ 'd option) × 'e) list)›*) ‹snd (hd s) = snd (hd s')› (*‹snd (hd (s::(('c ⇒ 'd option) × 'e) list)) = snd (hd (s'::(('c ⇒ 'd option) × 'e) list))›*) this (*‹∀V::'c∈(Use::'b ⇒ 'c set) ((sourcenode::'a ⇒ 'b) (a::'a)). local.CFG.state_val (s::(('c ⇒ 'd option) × 'e) list) V = local.CFG.state_val (s'::(('c ⇒ 'd option) × 'e) list) V›*) ‹length s = length s'› (*‹length s = length s'›*) have "pred (kind a) s'" by (rule CFG_edge_Uses_pred_equal (*‹⟦valid_edge ?a; local.CFG.pred (kind ?a) ?s; snd (hd ?s) = snd (hd ?s'); ∀V∈Use (sourcenode ?a). local.CFG.state_val ?s V = local.CFG.state_val ?s' V; length ?s = length ?s'⟧ ⟹ local.CFG.pred (kind ?a) ?s'›*)) with ‹e = (Node (sourcenode a), kind a, Node (targetnode a))› (*‹e = (Node (sourcenode a), kind a, Node (targetnode a))›*) show "?case" (*goal: ‹local.CFG.pred (knd e) s'›*) by simp next (*goals: 1. ‹⋀e. ⟦e = (NewEntry, (λs. True)⇩√, Node Entry); local.CFG.pred (knd e) s; snd (hd s) = snd (hd s'); ∀V∈lift_Use Use Entry Exit H L (src e). local.CFG.state_val s V = local.CFG.state_val s' V; length s = length s'⟧ ⟹ local.CFG.pred (knd e) s'› 2. ‹⋀e. ⟦e = (Node Exit, (λs. True)⇩√, NewExit); local.CFG.pred (knd e) s; snd (hd s) = snd (hd s'); ∀V∈lift_Use Use Entry Exit H L (src e). local.CFG.state_val s V = local.CFG.state_val s' V; length s = length s'⟧ ⟹ local.CFG.pred (knd e) s'› 3. ‹⋀e. ⟦e = (NewEntry, (λs. False)⇩√, NewExit); local.CFG.pred (knd e) s; snd (hd s) = snd (hd s'); ∀V∈lift_Use Use Entry Exit H L (src e). local.CFG.state_val s V = local.CFG.state_val s' V; length s = length s'⟧ ⟹ local.CFG.pred (knd e) s'›*) case (lve_Entry_edge e) (*‹e = (NewEntry, (λs. True)⇩√, Node Entry)› ‹local.CFG.pred (knd e) s› ‹snd (hd s) = snd (hd s')› ‹∀V∈lift_Use Use Entry Exit H L (src e). local.CFG.state_val s V = local.CFG.state_val s' V› ‹length s = length s'›*) thus "?case" (*goal: ‹local.CFG.pred (knd e) s'›*) apply (cases s') (*goals: 1. ‹⟦e = (NewEntry, (λs. True)⇩√, Node Entry); local.CFG.pred (knd e) s; snd (hd s) = snd (hd s'); ∀V∈lift_Use Use Entry Exit H L (src e). local.CFG.state_val s V = local.CFG.state_val s' V; length s = length s'; s' = []⟧ ⟹ local.CFG.pred (knd e) s'› 2. ‹⋀a list. ⟦e = (NewEntry, (λs. True)⇩√, Node Entry); local.CFG.pred (knd e) s; snd (hd s) = snd (hd s'); ∀V∈lift_Use Use Entry Exit H L (src e). local.CFG.state_val s V = local.CFG.state_val s' V; length s = length s'; s' = a # list⟧ ⟹ local.CFG.pred (knd e) s'› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . next (*goals: 1. ‹⋀e. ⟦e = (Node Exit, (λs. True)⇩√, NewExit); local.CFG.pred (knd e) s; snd (hd s) = snd (hd s'); ∀V∈lift_Use Use Entry Exit H L (src e). local.CFG.state_val s V = local.CFG.state_val s' V; length s = length s'⟧ ⟹ local.CFG.pred (knd e) s'› 2. ‹⋀e. ⟦e = (NewEntry, (λs. False)⇩√, NewExit); local.CFG.pred (knd e) s; snd (hd s) = snd (hd s'); ∀V∈lift_Use Use Entry Exit H L (src e). local.CFG.state_val s V = local.CFG.state_val s' V; length s = length s'⟧ ⟹ local.CFG.pred (knd e) s'›*) case (lve_Exit_edge e) (*‹e = (Node Exit, (λs. True)⇩√, NewExit)› ‹local.CFG.pred (knd e) s› ‹snd (hd s) = snd (hd s')› ‹∀V∈lift_Use Use Entry Exit H L (src e). local.CFG.state_val s V = local.CFG.state_val s' V› ‹length s = length s'›*) thus "?case" (*goal: ‹local.CFG.pred (knd e) s'›*) apply (cases s') (*goals: 1. ‹⟦(e::'b::type LDCFG_node × ('c::type, 'd::type, 'e::type, 'f::type) edge_kind × 'b::type LDCFG_node) = (Node (Exit::'b::type), (λs::'c::type ⇒ 'd::type option. True)⇩√, NewExit); local.CFG.pred (knd e) (s::(('c::type ⇒ 'd::type option) × 'e::type) list); snd (hd s) = snd (hd (s'::(('c::type ⇒ 'd::type option) × 'e::type) list)); ∀V::'c::type∈lift_Use (Use::'b::type ⇒ 'c::type set) (Entry::'b::type) Exit (H::'c::type set) (L::'c::type set) (src e). local.CFG.state_val s V = local.CFG.state_val s' V; length s = length s'; s' = []⟧ ⟹ local.CFG.pred (knd e) s'› 2. ‹⋀(a::('c::type ⇒ 'd::type option) × 'e::type) list::(('c::type ⇒ 'd::type option) × 'e::type) list. ⟦(e::'b::type LDCFG_node × ('c::type, 'd::type, 'e::type, 'f::type) edge_kind × 'b::type LDCFG_node) = (Node (Exit::'b::type), (λs::'c::type ⇒ 'd::type option. True)⇩√, NewExit); local.CFG.pred (knd e) (s::(('c::type ⇒ 'd::type option) × 'e::type) list); snd (hd s) = snd (hd (s'::(('c::type ⇒ 'd::type option) × 'e::type) list)); ∀V::'c::type∈lift_Use (Use::'b::type ⇒ 'c::type set) (Entry::'b::type) Exit (H::'c::type set) (L::'c::type set) (src e). local.CFG.state_val s V = local.CFG.state_val s' V; length s = length s'; s' = a # list⟧ ⟹ local.CFG.pred (knd e) s'› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . next (*goal: ‹⋀e. ⟦e = (NewEntry, (λs. False)⇩√, NewExit); local.CFG.pred (knd e) s; snd (hd s) = snd (hd s'); ∀V∈lift_Use Use Entry Exit H L (src e). local.CFG.state_val s V = local.CFG.state_val s' V; length s = length s'⟧ ⟹ local.CFG.pred (knd e) s'›*) case (lve_Entry_Exit_edge e) (*‹e = (NewEntry, (λs. False)⇩√, NewExit)› ‹local.CFG.pred (knd (e::'b::type LDCFG_node × ('c::type, 'd::type, 'e::type, 'f::type) edge_kind × 'b::type LDCFG_node)) (s::(('c::type ⇒ 'd::type option) × 'e::type) list)› ‹snd (hd s) = snd (hd s')› ‹∀V∈lift_Use Use Entry Exit H L (src e). local.CFG.state_val s V = local.CFG.state_val s' V› ‹length (s::(('c ⇒ 'd option) × 'e) list) = length (s'::(('c ⇒ 'd option) × 'e) list)›*) thus "?case" (*goal: ‹local.CFG.pred (knd (e::'b::type LDCFG_node × ('c::type, 'd::type, 'e::type, 'f::type) edge_kind × 'b::type LDCFG_node)) (s'::(('c::type ⇒ 'd::type option) × 'e::type) list)›*) apply (cases s) (*goals: 1. ‹⟦e = (NewEntry, (λs. False)⇩√, NewExit); local.CFG.pred (knd e) s; snd (hd s) = snd (hd s'); ∀V∈lift_Use Use Entry Exit H L (src e). local.CFG.state_val s V = local.CFG.state_val s' V; length s = length s'; s = []⟧ ⟹ local.CFG.pred (knd e) s'› 2. ‹⋀a list. ⟦e = (NewEntry, (λs. False)⇩√, NewExit); local.CFG.pred (knd e) s; snd (hd s) = snd (hd s'); ∀V∈lift_Use Use Entry Exit H L (src e). local.CFG.state_val s V = local.CFG.state_val s' V; length s = length s'; s = a # list⟧ ⟹ local.CFG.pred (knd e) s'› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . qed next (*goals: 1. ‹⋀a Q r p fs ins outs. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q:r↪⇘p⇙fs; (p, ins, outs) ∈ set procs⟧ ⟹ length fs = length ins› 2. ‹⋀a Q r p fs a' Q' r' p' fs' s. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q:r↪⇘p⇙fs; lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a'; knd a' = Q':r'↪⇘p'⇙fs'; src a = src a'; local.CFG.pred (knd a) s; local.CFG.pred (knd a') s⟧ ⟹ a = a'› 3. ‹⋀a Q r p fs i ins outs s s'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q:r↪⇘p⇙fs; i < length ins; (p, ins, outs) ∈ set procs; local.CFG.pred (knd a) s; local.CFG.pred (knd a) s'; ∀V∈lift_ParamUses ParamUses (src a) ! i. local.CFG.state_val s V = local.CFG.state_val s' V⟧ ⟹ local.CFG.params fs (local.CFG.state_val s) ! i = local.CFG.params fs (local.CFG.state_val s') ! i› 4. ‹⋀a Q' p f' ins outs vmap vmap'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q'↩⇘p⇙f'; (p, ins, outs) ∈ set procs⟧ ⟹ f' vmap vmap' = vmap'(lift_ParamDefs ParamDefs (trg a) [:=] map vmap outs)› 5. ‹⋀a a'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a'; src a = src a'; trg a ≠ trg a'; intra_kind (knd a); intra_kind (knd a')⟧ ⟹ ∃Q Q'. knd a = (Q)⇩√ ∧ knd a' = (Q')⇩√ ∧ (∀s. (Q s ⟶ ¬ Q' s) ∧ (Q' s ⟶ ¬ Q s))›*) fix a and Q and r and p and fs and ins and outs assume "lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a" and "knd a = Q:r↪⇘p⇙fs" and "(p, ins, outs) ∈ set procs" (*‹lift_valid_edge (valid_edge::'a ⇒ bool) (sourcenode::'a ⇒ 'b) (targetnode::'a ⇒ 'b) (kind::'a ⇒ ('c, 'd, 'e, 'f) edge_kind) (Entry::'b) (Exit::'b) (a::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node)› ‹knd (a::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node) = Q::('c ⇒ 'd option) × 'e ⇒ bool:r::'e↪⇘p::'f⇙fs::(('c ⇒ 'd option) ⇒ 'd option) list› ‹(p::'f, ins::'c list, outs::'c list) ∈ set (procs::('f × 'c list × 'c list) list)›*) thus "length fs = length ins" proof (induct rule:lift_valid_edge.induct (*‹⟦lift_valid_edge (?valid_edge::?'edge ⇒ bool) (?src::?'edge ⇒ ?'node) (?trg::?'edge ⇒ ?'node) (?knd::?'edge ⇒ (?'var, ?'val, ?'ret, ?'pname) edge_kind) (?E::?'node) (?X::?'node) (?x::?'node LDCFG_node × (?'var, ?'val, ?'ret, ?'pname) edge_kind × ?'node LDCFG_node); ⋀(a::?'edge) e::?'node LDCFG_node × (?'var, ?'val, ?'ret, ?'pname) edge_kind × ?'node LDCFG_node. ⟦?valid_edge a; ?src a ≠ ?E ∨ ?trg a ≠ ?X; e = (Node (?src a), ?knd a, Node (?trg a))⟧ ⟹ (?P::?'node LDCFG_node × (?'var, ?'val, ?'ret, ?'pname) edge_kind × ?'node LDCFG_node ⇒ bool) e; ⋀e::?'node LDCFG_node × (?'var, ?'val, ?'ret, ?'pname) edge_kind × ?'node LDCFG_node. e = (NewEntry, (λs::?'var ⇒ ?'val option. True)⇩√, Node ?E) ⟹ ?P e; ⋀e::?'node LDCFG_node × (?'var, ?'val, ?'ret, ?'pname) edge_kind × ?'node LDCFG_node. e = (Node ?X, (λs::?'var ⇒ ?'val option. True)⇩√, NewExit) ⟹ ?P e; ⋀e::?'node LDCFG_node × (?'var, ?'val, ?'ret, ?'pname) edge_kind × ?'node LDCFG_node. e = (NewEntry, (λs::?'var ⇒ ?'val option. False)⇩√, NewExit) ⟹ ?P e⟧ ⟹ ?P ?x›*)) (*goals: 1. ‹⋀a e. ⟦valid_edge a; sourcenode a ≠ Entry ∨ targetnode a ≠ Exit; e = (Node (sourcenode a), kind a, Node (targetnode a)); knd e = Q:r↪⇘p⇙fs; (p, ins, outs) ∈ set procs⟧ ⟹ length fs = length ins› 2. ‹⋀e. ⟦e = (NewEntry, (λs. True)⇩√, Node Entry); knd e = Q:r↪⇘p⇙fs; (p, ins, outs) ∈ set procs⟧ ⟹ length fs = length ins› 3. ‹⋀e. ⟦e = (Node Exit, (λs. True)⇩√, NewExit); knd e = Q:r↪⇘p⇙fs; (p, ins, outs) ∈ set procs⟧ ⟹ length fs = length ins› 4. ‹⋀e. ⟦e = (NewEntry, (λs. False)⇩√, NewExit); knd e = Q:r↪⇘p⇙fs; (p, ins, outs) ∈ set procs⟧ ⟹ length fs = length ins›*) case (lve_edge a e) (*‹valid_edge a› ‹sourcenode a ≠ Entry ∨ targetnode a ≠ Exit› ‹e = (Node (sourcenode a), kind a, Node (targetnode a))› ‹knd e = Q:r↪⇘p⇙fs› ‹(p, ins, outs) ∈ set procs›*) from ‹e = (Node (sourcenode a), kind a, Node (targetnode a))› (*‹e = (Node (sourcenode a), kind a, Node (targetnode a))›*) ‹knd e = Q:r↪⇘p⇙fs› (*‹knd e = Q:r↪⇘p⇙fs›*) have "kind a = Q:r↪⇘p⇙fs" by simp from ‹valid_edge a› (*‹valid_edge a›*) ‹kind a = Q:r↪⇘p⇙fs› (*‹kind a = Q:r↪⇘p⇙fs›*) ‹(p, ins, outs) ∈ set procs› (*‹(p, ins, outs) ∈ set procs›*) show "?case" (*goal: ‹length fs = length ins›*) by (rule CFG_call_edge_length (*‹⟦valid_edge ?a; kind ?a = ?Q:?r↪⇘?p⇙?fs; (?p, ?ins, ?outs) ∈ set procs⟧ ⟹ length ?fs = length ?ins›*)) qed (simp_all) (*solves the remaining goals: 1. ‹⋀e. ⟦e = (NewEntry, (λs. True)⇩√, Node Entry); knd e = Q:r↪⇘p⇙fs; (p, ins, outs) ∈ set procs⟧ ⟹ length fs = length ins› 2. ‹⋀e. ⟦e = (Node Exit, (λs. True)⇩√, NewExit); knd e = Q:r↪⇘p⇙fs; (p, ins, outs) ∈ set procs⟧ ⟹ length fs = length ins› 3. ‹⋀e. ⟦e = (NewEntry, (λs. False)⇩√, NewExit); knd e = Q:r↪⇘p⇙fs; (p, ins, outs) ∈ set procs⟧ ⟹ length fs = length ins›*) next (*goals: 1. ‹⋀(a::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node) (Q::('c ⇒ 'd option) × 'e ⇒ bool) (r::'e) (p::'f) (fs::(('c ⇒ 'd option) ⇒ 'd option) list) (a'::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node) (Q'::('c ⇒ 'd option) × 'e ⇒ bool) (r'::'e) (p'::'f) (fs'::(('c ⇒ 'd option) ⇒ 'd option) list) s::(('c ⇒ 'd option) × 'e) list. ⟦lift_valid_edge (valid_edge::'a ⇒ bool) (sourcenode::'a ⇒ 'b) (targetnode::'a ⇒ 'b) (kind::'a ⇒ ('c, 'd, 'e, 'f) edge_kind) (Entry::'b) (Exit::'b) a; knd a = Q:r↪⇘p⇙fs; lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a'; knd a' = Q':r'↪⇘p'⇙fs'; src a = src a'; local.CFG.pred (knd a) s; local.CFG.pred (knd a') s⟧ ⟹ a = a'› 2. ‹⋀(a::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node) (Q::('c ⇒ 'd option) × 'e ⇒ bool) (r::'e) (p::'f) (fs::(('c ⇒ 'd option) ⇒ 'd option) list) (i::nat) (ins::'c list) (outs::'c list) (s::(('c ⇒ 'd option) × 'e) list) s'::(('c ⇒ 'd option) × 'e) list. ⟦lift_valid_edge (valid_edge::'a ⇒ bool) (sourcenode::'a ⇒ 'b) (targetnode::'a ⇒ 'b) (kind::'a ⇒ ('c, 'd, 'e, 'f) edge_kind) (Entry::'b) (Exit::'b) a; knd a = Q:r↪⇘p⇙fs; i < length ins; (p, ins, outs) ∈ set (procs::('f × 'c list × 'c list) list); local.CFG.pred (knd a) s; local.CFG.pred (knd a) s'; ∀V::'c∈lift_ParamUses (ParamUses::'b ⇒ 'c set list) (src a) ! i. local.CFG.state_val s V = local.CFG.state_val s' V⟧ ⟹ local.CFG.params fs (local.CFG.state_val s) ! i = local.CFG.params fs (local.CFG.state_val s') ! i› 3. ‹⋀(a::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node) (Q'::('c ⇒ 'd option) × 'e ⇒ bool) (p::'f) (f'::('c ⇒ 'd option) ⇒ ('c ⇒ 'd option) ⇒ 'c ⇒ 'd option) (ins::'c list) (outs::'c list) (vmap::'c ⇒ 'd option) vmap'::'c ⇒ 'd option. ⟦lift_valid_edge (valid_edge::'a ⇒ bool) (sourcenode::'a ⇒ 'b) (targetnode::'a ⇒ 'b) (kind::'a ⇒ ('c, 'd, 'e, 'f) edge_kind) (Entry::'b) (Exit::'b) a; knd a = Q'↩⇘p⇙f'; (p, ins, outs) ∈ set (procs::('f × 'c list × 'c list) list)⟧ ⟹ f' vmap vmap' = vmap'(lift_ParamDefs (ParamDefs::'b ⇒ 'c list) (trg a) [:=] map vmap outs)› 4. ‹⋀(a::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node) a'::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node. ⟦lift_valid_edge (valid_edge::'a ⇒ bool) (sourcenode::'a ⇒ 'b) (targetnode::'a ⇒ 'b) (kind::'a ⇒ ('c, 'd, 'e, 'f) edge_kind) (Entry::'b) (Exit::'b) a; lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a'; src a = src a'; trg a ≠ trg a'; intra_kind (knd a); intra_kind (knd a')⟧ ⟹ ∃(Q::('c ⇒ 'd option) ⇒ bool) Q'::('c ⇒ 'd option) ⇒ bool. knd a = (Q)⇩√ ∧ knd a' = (Q')⇩√ ∧ (∀s::'c ⇒ 'd option. (Q s ⟶ ¬ Q' s) ∧ (Q' s ⟶ ¬ Q s))›*) fix a and Q and r and p and fs and a' and Q' and r' and p' and fs' and s and s' assume "lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a" and "knd a = Q:r↪⇘p⇙fs" and "knd a' = Q':r'↪⇘p'⇙fs'" and "lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a'" and "src a = src a'" and "pred (knd a) s" and "pred (knd a') s" (*‹lift_valid_edge (valid_edge::'a ⇒ bool) (sourcenode::'a ⇒ 'b) (targetnode::'a ⇒ 'b) (kind::'a ⇒ ('c, 'd, 'e, 'f) edge_kind) (Entry::'b) (Exit::'b) (a::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node)› ‹knd (a::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node) = Q::('c ⇒ 'd option) × 'e ⇒ bool:r::'e↪⇘p::'f⇙fs::(('c ⇒ 'd option) ⇒ 'd option) list› ‹knd (a'::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node) = Q'::('c ⇒ 'd option) × 'e ⇒ bool:r'::'e↪⇘p'::'f⇙fs'::(('c ⇒ 'd option) ⇒ 'd option) list› ‹lift_valid_edge (valid_edge::'a ⇒ bool) (sourcenode::'a ⇒ 'b) (targetnode::'a ⇒ 'b) (kind::'a ⇒ ('c, 'd, 'e, 'f) edge_kind) (Entry::'b) (Exit::'b) (a'::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node)› ‹src (a::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node) = src (a'::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node)› ‹local.CFG.pred (knd (a::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node)) (s::(('c ⇒ 'd option) × 'e) list)› ‹local.CFG.pred (knd (a'::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node)) (s::(('c ⇒ 'd option) × 'e) list)›*) from ‹lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a› (*‹lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a›*) ‹knd a = Q:r↪⇘p⇙fs› (*‹knd a = Q:r↪⇘p⇙fs›*) ‹pred (knd a) s› (*‹local.CFG.pred (knd a) s›*) obtain x where a: "a = (Node (sourcenode x),kind x,Node (targetnode x))" and "valid_edge x" and "src a = Node (sourcenode x)" and "kind x = Q:r↪⇘p⇙fs" and "pred (kind x) s" (*goal: ‹(⋀x. ⟦a = (Node (sourcenode x), kind x, Node (targetnode x)); valid_edge x; src a = Node (sourcenode x); kind x = Q:r↪⇘p⇙fs; local.CFG.pred (kind x) s⟧ ⟹ thesis) ⟹ thesis›*) by (fastforce elim:lift_valid_edge.cases (*‹⟦lift_valid_edge (?valid_edge::?'edge ⇒ bool) (?src::?'edge ⇒ ?'node) (?trg::?'edge ⇒ ?'node) (?knd::?'edge ⇒ (?'var, ?'val, ?'ret, ?'pname) edge_kind) (?E::?'node) (?X::?'node) (?a::?'node LDCFG_node × (?'var, ?'val, ?'ret, ?'pname) edge_kind × ?'node LDCFG_node); ⋀(a::?'edge) e::?'node LDCFG_node × (?'var, ?'val, ?'ret, ?'pname) edge_kind × ?'node LDCFG_node. ⟦?a = e; ?valid_edge a; ?src a ≠ ?E ∨ ?trg a ≠ ?X; e = (Node (?src a), ?knd a, Node (?trg a))⟧ ⟹ ?P::bool; ⋀e::?'node LDCFG_node × (?'var, ?'val, ?'ret, ?'pname) edge_kind × ?'node LDCFG_node. ⟦?a = e; e = (NewEntry, (λs::?'var ⇒ ?'val option. True)⇩√, Node ?E)⟧ ⟹ ?P; ⋀e::?'node LDCFG_node × (?'var, ?'val, ?'ret, ?'pname) edge_kind × ?'node LDCFG_node. ⟦?a = e; e = (Node ?X, (λs::?'var ⇒ ?'val option. True)⇩√, NewExit)⟧ ⟹ ?P; ⋀e::?'node LDCFG_node × (?'var, ?'val, ?'ret, ?'pname) edge_kind × ?'node LDCFG_node. ⟦?a = e; e = (NewEntry, (λs::?'var ⇒ ?'val option. False)⇩√, NewExit)⟧ ⟹ ?P⟧ ⟹ ?P›*)) from ‹lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a'› (*‹lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a'›*) ‹knd a' = Q':r'↪⇘p'⇙fs'› (*‹knd (a'::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node) = Q'::('c ⇒ 'd option) × 'e ⇒ bool:r'::'e↪⇘p'::'f⇙fs'::(('c ⇒ 'd option) ⇒ 'd option) list›*) ‹pred (knd a') s› (*‹local.CFG.pred (knd a') s›*) obtain x' where a': "a' = (Node (sourcenode x'),kind x',Node (targetnode x'))" and "valid_edge x'" and "src a' = Node (sourcenode x')" and "kind x' = Q':r'↪⇘p'⇙fs'" and "pred (kind x') s" (*goal: ‹(⋀x'. ⟦a' = (Node (sourcenode x'), kind x', Node (targetnode x')); valid_edge x'; src a' = Node (sourcenode x'); kind x' = Q':r'↪⇘p'⇙fs'; local.CFG.pred (kind x') s⟧ ⟹ thesis) ⟹ thesis›*) by (fastforce elim:lift_valid_edge.cases (*‹⟦lift_valid_edge ?valid_edge ?src ?trg ?knd ?E ?X ?a; ⋀a e. ⟦?a = e; ?valid_edge a; ?src a ≠ ?E ∨ ?trg a ≠ ?X; e = (Node (?src a), ?knd a, Node (?trg a))⟧ ⟹ ?P; ⋀e. ⟦?a = e; e = (NewEntry, (λs. True)⇩√, Node ?E)⟧ ⟹ ?P; ⋀e. ⟦?a = e; e = (Node ?X, (λs. True)⇩√, NewExit)⟧ ⟹ ?P; ⋀e. ⟦?a = e; e = (NewEntry, (λs. False)⇩√, NewExit)⟧ ⟹ ?P⟧ ⟹ ?P›*)) from ‹src a = Node (sourcenode x)› (*‹src (a::'b::type LDCFG_node × ('c::type, 'd::type, 'e::type, 'f::type) edge_kind × 'b::type LDCFG_node) = Node ((sourcenode::'a::type ⇒ 'b::type) (x::'a::type))›*) ‹src a' = Node (sourcenode x')› (*‹src a' = Node (sourcenode x')›*) ‹src a = src a'› (*‹src a = src a'›*) have "sourcenode x = sourcenode x'" by simp from ‹valid_edge x› (*‹valid_edge x›*) ‹kind x = Q:r↪⇘p⇙fs› (*‹kind x = Q:r↪⇘p⇙fs›*) ‹valid_edge x'› (*‹(valid_edge::'a::type ⇒ bool) (x'::'a::type)›*) ‹kind x' = Q':r'↪⇘p'⇙fs'› (*‹kind x' = Q':r'↪⇘p'⇙fs'›*) ‹sourcenode x = sourcenode x'› (*‹sourcenode x = sourcenode x'›*) ‹pred (kind x) s› (*‹local.CFG.pred (kind x) s›*) ‹pred (kind x') s› (*‹local.CFG.pred (kind x') s›*) have "x = x'" by (rule CFG_call_determ (*‹⟦(valid_edge::'a ⇒ bool) (?a::'a); (kind::'a ⇒ ('c, 'd, 'e, 'f) edge_kind) ?a = ?Q::('c ⇒ 'd option) × 'e ⇒ bool:?r::'e↪⇘?p::'f⇙?fs::(('c ⇒ 'd option) ⇒ 'd option) list; valid_edge (?a'::'a); kind ?a' = ?Q'::('c ⇒ 'd option) × 'e ⇒ bool:?r'::'e↪⇘?p'::'f⇙?fs'::(('c ⇒ 'd option) ⇒ 'd option) list; (sourcenode::'a ⇒ 'b) ?a = sourcenode ?a'; local.CFG.pred (kind ?a) (?s::(('c ⇒ 'd option) × 'e) list); local.CFG.pred (kind ?a') ?s⟧ ⟹ ?a = ?a'›*)) with a (*‹(a::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node) = (Node ((sourcenode::'a ⇒ 'b) (x::'a)), (kind::'a ⇒ ('c, 'd, 'e, 'f) edge_kind) x, Node ((targetnode::'a ⇒ 'b) x))›*) a' (*‹a' = (Node (sourcenode x'), kind x', Node (targetnode x'))›*) show "a = a'" by simp next (*goals: 1. ‹⋀a Q r p fs i ins outs s s'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q:r↪⇘p⇙fs; i < length ins; (p, ins, outs) ∈ set procs; local.CFG.pred (knd a) s; local.CFG.pred (knd a) s'; ∀V∈lift_ParamUses ParamUses (src a) ! i. local.CFG.state_val s V = local.CFG.state_val s' V⟧ ⟹ local.CFG.params fs (local.CFG.state_val s) ! i = local.CFG.params fs (local.CFG.state_val s') ! i› 2. ‹⋀a Q' p f' ins outs vmap vmap'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q'↩⇘p⇙f'; (p, ins, outs) ∈ set procs⟧ ⟹ f' vmap vmap' = vmap'(lift_ParamDefs ParamDefs (trg a) [:=] map vmap outs)› 3. ‹⋀a a'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a'; src a = src a'; trg a ≠ trg a'; intra_kind (knd a); intra_kind (knd a')⟧ ⟹ ∃Q Q'. knd a = (Q)⇩√ ∧ knd a' = (Q')⇩√ ∧ (∀s. (Q s ⟶ ¬ Q' s) ∧ (Q' s ⟶ ¬ Q s))›*) fix a and Q and r and p and fs and i and ins and outs and s and s' assume "lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a" and "knd a = Q:r↪⇘p⇙fs" and "i < length ins" and "(p, ins, outs) ∈ set procs" and "pred (knd a) s" and "pred (knd a) s'" and "∀V∈lift_ParamUses ParamUses (src a) ! i. state_val s V = state_val s' V" (*‹lift_valid_edge (valid_edge::'a ⇒ bool) (sourcenode::'a ⇒ 'b) (targetnode::'a ⇒ 'b) (kind::'a ⇒ ('c, 'd, 'e, 'f) edge_kind) (Entry::'b) (Exit::'b) (a::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node)› ‹knd (a::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node) = Q::('c ⇒ 'd option) × 'e ⇒ bool:r::'e↪⇘p::'f⇙fs::(('c ⇒ 'd option) ⇒ 'd option) list› ‹(i::nat) < length (ins::'c list)› ‹(p::'f, ins::'c list, outs::'c list) ∈ set (procs::('f × 'c list × 'c list) list)› ‹local.CFG.pred (knd (a::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node)) (s::(('c ⇒ 'd option) × 'e) list)› ‹local.CFG.pred (knd (a::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node)) (s'::(('c ⇒ 'd option) × 'e) list)› ‹∀V::'c∈lift_ParamUses (ParamUses::'b ⇒ 'c set list) (src (a::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node)) ! (i::nat). local.CFG.state_val (s::(('c ⇒ 'd option) × 'e) list) V = local.CFG.state_val (s'::(('c ⇒ 'd option) × 'e) list) V›*) thus "params fs (state_val s) ! i = CFG.params fs (state_val s') ! i" proof (induct rule:lift_valid_edge.induct (*‹⟦lift_valid_edge ?valid_edge ?src ?trg ?knd ?E ?X ?x; ⋀a e. ⟦?valid_edge a; ?src a ≠ ?E ∨ ?trg a ≠ ?X; e = (Node (?src a), ?knd a, Node (?trg a))⟧ ⟹ ?P e; ⋀e. e = (NewEntry, (λs. True)⇩√, Node ?E) ⟹ ?P e; ⋀e. e = (Node ?X, (λs. True)⇩√, NewExit) ⟹ ?P e; ⋀e. e = (NewEntry, (λs. False)⇩√, NewExit) ⟹ ?P e⟧ ⟹ ?P ?x›*)) (*goals: 1. ‹⋀a e. ⟦valid_edge a; sourcenode a ≠ Entry ∨ targetnode a ≠ Exit; e = (Node (sourcenode a), kind a, Node (targetnode a)); knd e = Q:r↪⇘p⇙fs; i < length ins; (p, ins, outs) ∈ set procs; local.CFG.pred (knd e) s; local.CFG.pred (knd e) s'; ∀V∈lift_ParamUses ParamUses (src e) ! i. local.CFG.state_val s V = local.CFG.state_val s' V⟧ ⟹ local.CFG.params fs (local.CFG.state_val s) ! i = local.CFG.params fs (local.CFG.state_val s') ! i› 2. ‹⋀e. ⟦e = (NewEntry, (λs. True)⇩√, Node Entry); knd e = Q:r↪⇘p⇙fs; i < length ins; (p, ins, outs) ∈ set procs; local.CFG.pred (knd e) s; local.CFG.pred (knd e) s'; ∀V∈lift_ParamUses ParamUses (src e) ! i. local.CFG.state_val s V = local.CFG.state_val s' V⟧ ⟹ local.CFG.params fs (local.CFG.state_val s) ! i = local.CFG.params fs (local.CFG.state_val s') ! i› 3. ‹⋀e. ⟦e = (Node Exit, (λs. True)⇩√, NewExit); knd e = Q:r↪⇘p⇙fs; i < length ins; (p, ins, outs) ∈ set procs; local.CFG.pred (knd e) s; local.CFG.pred (knd e) s'; ∀V∈lift_ParamUses ParamUses (src e) ! i. local.CFG.state_val s V = local.CFG.state_val s' V⟧ ⟹ local.CFG.params fs (local.CFG.state_val s) ! i = local.CFG.params fs (local.CFG.state_val s') ! i› 4. ‹⋀e. ⟦e = (NewEntry, (λs. False)⇩√, NewExit); knd e = Q:r↪⇘p⇙fs; i < length ins; (p, ins, outs) ∈ set procs; local.CFG.pred (knd e) s; local.CFG.pred (knd e) s'; ∀V∈lift_ParamUses ParamUses (src e) ! i. local.CFG.state_val s V = local.CFG.state_val s' V⟧ ⟹ local.CFG.params fs (local.CFG.state_val s) ! i = local.CFG.params fs (local.CFG.state_val s') ! i›*) case (lve_edge a e) (*‹valid_edge a› ‹(sourcenode::'a ⇒ 'b) (a::'a) ≠ (Entry::'b) ∨ (targetnode::'a ⇒ 'b) a ≠ (Exit::'b)› ‹(e::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node) = (Node ((sourcenode::'a ⇒ 'b) (a::'a)), (kind::'a ⇒ ('c, 'd, 'e, 'f) edge_kind) a, Node ((targetnode::'a ⇒ 'b) a))› ‹knd e = Q:r↪⇘p⇙fs› ‹i < length ins› ‹(p, ins, outs) ∈ set procs› ‹local.CFG.pred (knd e) s› ‹local.CFG.pred (knd e) s'› ‹∀V∈lift_ParamUses ParamUses (src e) ! i. local.CFG.state_val s V = local.CFG.state_val s' V›*) from ‹e = (Node (sourcenode a), kind a, Node (targetnode a))› (*‹e = (Node (sourcenode a), kind a, Node (targetnode a))›*) ‹knd e = Q:r↪⇘p⇙fs› (*‹knd e = Q:r↪⇘p⇙fs›*) ‹pred (knd e) s› (*‹local.CFG.pred (knd e) s›*) ‹pred (knd e) s'› (*‹local.CFG.pred (knd e) s'›*) have "kind a = Q:r↪⇘p⇙fs" and "pred (kind a) s" and "pred (kind a) s'" and "src e = Node (sourcenode a)" apply - (*goals: 1. ‹⟦e = (Node (sourcenode a), kind a, Node (targetnode a)); knd e = Q:r↪⇘p⇙fs; local.CFG.pred (knd e) s; local.CFG.pred (knd e) s'⟧ ⟹ kind a = Q:r↪⇘p⇙fs› 2. ‹⟦e = (Node (sourcenode a), kind a, Node (targetnode a)); knd e = Q:r↪⇘p⇙fs; local.CFG.pred (knd e) s; local.CFG.pred (knd e) s'⟧ ⟹ local.CFG.pred (kind a) s› 3. ‹⟦e = (Node (sourcenode a), kind a, Node (targetnode a)); knd e = Q:r↪⇘p⇙fs; local.CFG.pred (knd e) s; local.CFG.pred (knd e) s'⟧ ⟹ local.CFG.pred (kind a) s'› 4. ‹⟦e = (Node (sourcenode a), kind a, Node (targetnode a)); knd e = Q:r↪⇘p⇙fs; local.CFG.pred (knd e) s; local.CFG.pred (knd e) s'⟧ ⟹ src e = Node (sourcenode a)› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*discuss goal 3*) apply simp (*discuss goal 4*) apply simp (*proven 4 subgoals*) . from ‹∀V∈lift_ParamUses ParamUses (src e) ! i. state_val s V = state_val s' V› (*‹∀V∈lift_ParamUses ParamUses (src e) ! i. local.CFG.state_val s V = local.CFG.state_val s' V›*) ‹src e = Node (sourcenode a)› (*‹src e = Node (sourcenode a)›*) have "∀V ∈ (ParamUses (sourcenode a))!i. state_val s V = state_val s' V" by simp with ‹valid_edge a› (*‹valid_edge a›*) ‹kind a = Q:r↪⇘p⇙fs› (*‹kind a = Q:r↪⇘p⇙fs›*) ‹i < length ins› (*‹i < length ins›*) ‹(p, ins, outs) ∈ set procs› (*‹(p, ins, outs) ∈ set procs›*) ‹pred (kind a) s› (*‹local.CFG.pred (kind a) s›*) ‹pred (kind a) s'› (*‹local.CFG.pred (kind a) s'›*) show "?case" (*goal: ‹local.CFG.params fs (local.CFG.state_val s) ! i = local.CFG.params fs (local.CFG.state_val s') ! i›*) by (rule CFG_call_edge_params (*‹⟦valid_edge ?a; kind ?a = ?Q:?r↪⇘?p⇙?fs; ?i < length ?ins; (?p, ?ins, ?outs) ∈ set procs; local.CFG.pred (kind ?a) ?s; local.CFG.pred (kind ?a) ?s'; ∀V∈ParamUses (sourcenode ?a) ! ?i. local.CFG.state_val ?s V = local.CFG.state_val ?s' V⟧ ⟹ local.CFG.params ?fs (local.CFG.state_val ?s) ! ?i = local.CFG.params ?fs (local.CFG.state_val ?s') ! ?i›*)) qed (simp_all) (*solves the remaining goals: 1. ‹⋀e. ⟦e = (NewEntry, (λs. True)⇩√, Node Entry); knd e = Q:r↪⇘p⇙fs; i < length ins; (p, ins, outs) ∈ set procs; local.CFG.pred (knd e) s; local.CFG.pred (knd e) s'; ∀V∈lift_ParamUses ParamUses (src e) ! i. local.CFG.state_val s V = local.CFG.state_val s' V⟧ ⟹ local.CFG.params fs (local.CFG.state_val s) ! i = local.CFG.params fs (local.CFG.state_val s') ! i› 2. ‹⋀e. ⟦e = (Node Exit, (λs. True)⇩√, NewExit); knd e = Q:r↪⇘p⇙fs; i < length ins; (p, ins, outs) ∈ set procs; local.CFG.pred (knd e) s; local.CFG.pred (knd e) s'; ∀V∈lift_ParamUses ParamUses (src e) ! i. local.CFG.state_val s V = local.CFG.state_val s' V⟧ ⟹ local.CFG.params fs (local.CFG.state_val s) ! i = local.CFG.params fs (local.CFG.state_val s') ! i› 3. ‹⋀e. ⟦e = (NewEntry, (λs. False)⇩√, NewExit); knd e = Q:r↪⇘p⇙fs; i < length ins; (p, ins, outs) ∈ set procs; local.CFG.pred (knd e) s; local.CFG.pred (knd e) s'; ∀V∈lift_ParamUses ParamUses (src e) ! i. local.CFG.state_val s V = local.CFG.state_val s' V⟧ ⟹ local.CFG.params fs (local.CFG.state_val s) ! i = local.CFG.params fs (local.CFG.state_val s') ! i›*) next (*goals: 1. ‹⋀a Q' p f' ins outs vmap vmap'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q'↩⇘p⇙f'; (p, ins, outs) ∈ set procs⟧ ⟹ f' vmap vmap' = vmap'(lift_ParamDefs ParamDefs (trg a) [:=] map vmap outs)› 2. ‹⋀a a'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a'; src a = src a'; trg a ≠ trg a'; intra_kind (knd a); intra_kind (knd a')⟧ ⟹ ∃Q Q'. knd a = (Q)⇩√ ∧ knd a' = (Q')⇩√ ∧ (∀s. (Q s ⟶ ¬ Q' s) ∧ (Q' s ⟶ ¬ Q s))›*) fix a and Q' and p and f' and ins and outs and cf and cf' assume "lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a" and "knd a = Q'↩⇘p⇙f'" and "(p, ins, outs) ∈ set procs" (*‹lift_valid_edge (valid_edge::'a ⇒ bool) (sourcenode::'a ⇒ 'b) (targetnode::'a ⇒ 'b) (kind::'a ⇒ ('c, 'd, 'e, 'f) edge_kind) (Entry::'b) (Exit::'b) (a::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node)› ‹knd (a::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node) = Q'::('c ⇒ 'd option) × 'e ⇒ bool↩⇘p::'f⇙f'::('c ⇒ 'd option) ⇒ ('c ⇒ 'd option) ⇒ 'c ⇒ 'd option› ‹(p::'f, ins::'c list, outs::'c list) ∈ set (procs::('f × 'c list × 'c list) list)›*) thus "f' cf cf' = cf'(lift_ParamDefs ParamDefs (trg a) [:=] map cf outs)" proof (induct rule:lift_valid_edge.induct (*‹⟦lift_valid_edge ?valid_edge ?src ?trg ?knd ?E ?X ?x; ⋀a e. ⟦?valid_edge a; ?src a ≠ ?E ∨ ?trg a ≠ ?X; e = (Node (?src a), ?knd a, Node (?trg a))⟧ ⟹ ?P e; ⋀e. e = (NewEntry, (λs. True)⇩√, Node ?E) ⟹ ?P e; ⋀e. e = (Node ?X, (λs. True)⇩√, NewExit) ⟹ ?P e; ⋀e. e = (NewEntry, (λs. False)⇩√, NewExit) ⟹ ?P e⟧ ⟹ ?P ?x›*)) (*goals: 1. ‹⋀a e. ⟦valid_edge a; sourcenode a ≠ Entry ∨ targetnode a ≠ Exit; e = (Node (sourcenode a), kind a, Node (targetnode a)); knd e = Q'↩⇘p⇙f'; (p, ins, outs) ∈ set procs⟧ ⟹ f' cf cf' = cf'(lift_ParamDefs ParamDefs (trg e) [:=] map cf outs)› 2. ‹⋀e. ⟦e = (NewEntry, (λs. True)⇩√, Node Entry); knd e = Q'↩⇘p⇙f'; (p, ins, outs) ∈ set procs⟧ ⟹ f' cf cf' = cf'(lift_ParamDefs ParamDefs (trg e) [:=] map cf outs)› 3. ‹⋀e. ⟦e = (Node Exit, (λs. True)⇩√, NewExit); knd e = Q'↩⇘p⇙f'; (p, ins, outs) ∈ set procs⟧ ⟹ f' cf cf' = cf'(lift_ParamDefs ParamDefs (trg e) [:=] map cf outs)› 4. ‹⋀e. ⟦e = (NewEntry, (λs. False)⇩√, NewExit); knd e = Q'↩⇘p⇙f'; (p, ins, outs) ∈ set procs⟧ ⟹ f' cf cf' = cf'(lift_ParamDefs ParamDefs (trg e) [:=] map cf outs)›*) case (lve_edge a e) (*‹valid_edge a› ‹sourcenode a ≠ Entry ∨ targetnode a ≠ Exit› ‹(e::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node) = (Node ((sourcenode::'a ⇒ 'b) (a::'a)), (kind::'a ⇒ ('c, 'd, 'e, 'f) edge_kind) a, Node ((targetnode::'a ⇒ 'b) a))› ‹knd (e::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node) = Q'::('c ⇒ 'd option) × 'e ⇒ bool↩⇘p::'f⇙f'::('c ⇒ 'd option) ⇒ ('c ⇒ 'd option) ⇒ 'c ⇒ 'd option› ‹(p, ins, outs) ∈ set procs›*) from ‹e = (Node (sourcenode a), kind a, Node (targetnode a))› (*‹e = (Node (sourcenode a), kind a, Node (targetnode a))›*) ‹knd e = Q'↩⇘p⇙f'› (*‹knd e = Q'↩⇘p⇙f'›*) have "kind a = Q'↩⇘p⇙f'" and "trg e = Node (targetnode a)" apply - (*goals: 1. ‹⟦e = (Node (sourcenode a), kind a, Node (targetnode a)); knd e = Q'↩⇘p⇙f'⟧ ⟹ kind a = Q'↩⇘p⇙f'› 2. ‹⟦e = (Node (sourcenode a), kind a, Node (targetnode a)); knd e = Q'↩⇘p⇙f'⟧ ⟹ trg e = Node (targetnode a)› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) . from ‹valid_edge a› (*‹valid_edge a›*) ‹kind a = Q'↩⇘p⇙f'› (*‹kind a = Q'↩⇘p⇙f'›*) ‹(p, ins, outs) ∈ set procs› (*‹(p, ins, outs) ∈ set procs›*) have "f' cf cf' = cf'(ParamDefs (targetnode a) [:=] map cf outs)" by (rule CFG_return_edge_fun (*‹⟦valid_edge ?a; kind ?a = ?Q'↩⇘?p⇙?f'; (?p, ?ins, ?outs) ∈ set procs⟧ ⟹ ?f' ?vmap ?vmap' = ?vmap'(ParamDefs (targetnode ?a) [:=] map ?vmap ?outs)›*)) with ‹trg e = Node (targetnode a)› (*‹trg (e::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node) = Node ((targetnode::'a ⇒ 'b) (a::'a))›*) show "?case" (*goal: ‹f' cf cf' = cf'(lift_ParamDefs ParamDefs (trg e) [:=] map cf outs)›*) by simp qed (simp_all) (*solves the remaining goals: 1. ‹⋀e. ⟦e = (NewEntry, (λs. True)⇩√, Node Entry); knd e = Q'↩⇘p⇙f'; (p, ins, outs) ∈ set procs⟧ ⟹ f' cf cf' = cf'(lift_ParamDefs ParamDefs (trg e) [:=] map cf outs)› 2. ‹⋀e. ⟦e = (Node Exit, (λs. True)⇩√, NewExit); knd e = Q'↩⇘p⇙f'; (p, ins, outs) ∈ set procs⟧ ⟹ f' cf cf' = cf'(lift_ParamDefs ParamDefs (trg e) [:=] map cf outs)› 3. ‹⋀e. ⟦e = (NewEntry, (λs. False)⇩√, NewExit); knd e = Q'↩⇘p⇙f'; (p, ins, outs) ∈ set procs⟧ ⟹ f' cf cf' = cf'(lift_ParamDefs ParamDefs (trg e) [:=] map cf outs)›*) next (*goal: ‹⋀a a'. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a'; src a = src a'; trg a ≠ trg a'; intra_kind (knd a); intra_kind (knd a')⟧ ⟹ ∃Q Q'. knd a = (Q)⇩√ ∧ knd a' = (Q')⇩√ ∧ (∀s. (Q s ⟶ ¬ Q' s) ∧ (Q' s ⟶ ¬ Q s))›*) fix a and a' assume "lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a" and "lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a'" and "src a = src a'" and "trg a ≠ trg a'" and "intra_kind (knd a)" and "intra_kind (knd a')" (*‹lift_valid_edge (valid_edge::'a ⇒ bool) (sourcenode::'a ⇒ 'b) (targetnode::'a ⇒ 'b) (kind::'a ⇒ ('c, 'd, 'e, 'f) edge_kind) (Entry::'b) (Exit::'b) (a::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node)› ‹lift_valid_edge (valid_edge::'a ⇒ bool) (sourcenode::'a ⇒ 'b) (targetnode::'a ⇒ 'b) (kind::'a ⇒ ('c, 'd, 'e, 'f) edge_kind) (Entry::'b) (Exit::'b) (a'::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node)› ‹src (a::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node) = src (a'::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node)› ‹trg (a::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node) ≠ trg (a'::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node)› ‹intra_kind (knd (a::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node))› ‹intra_kind (knd (a'::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node))›*) thus "∃Q Q'. knd a = (Q)⇩√ ∧ knd a' = (Q')⇩√ ∧ (∀s. (Q s ⟶ ¬ Q' s) ∧ (Q' s ⟶ ¬ Q s))" proof (induct rule:lift_valid_edge.induct (*‹⟦lift_valid_edge (?valid_edge::?'edge ⇒ bool) (?src::?'edge ⇒ ?'node) (?trg::?'edge ⇒ ?'node) (?knd::?'edge ⇒ (?'var, ?'val, ?'ret, ?'pname) edge_kind) (?E::?'node) (?X::?'node) (?x::?'node LDCFG_node × (?'var, ?'val, ?'ret, ?'pname) edge_kind × ?'node LDCFG_node); ⋀(a::?'edge) e::?'node LDCFG_node × (?'var, ?'val, ?'ret, ?'pname) edge_kind × ?'node LDCFG_node. ⟦?valid_edge a; ?src a ≠ ?E ∨ ?trg a ≠ ?X; e = (Node (?src a), ?knd a, Node (?trg a))⟧ ⟹ (?P::?'node LDCFG_node × (?'var, ?'val, ?'ret, ?'pname) edge_kind × ?'node LDCFG_node ⇒ bool) e; ⋀e::?'node LDCFG_node × (?'var, ?'val, ?'ret, ?'pname) edge_kind × ?'node LDCFG_node. e = (NewEntry, (λs::?'var ⇒ ?'val option. True)⇩√, Node ?E) ⟹ ?P e; ⋀e::?'node LDCFG_node × (?'var, ?'val, ?'ret, ?'pname) edge_kind × ?'node LDCFG_node. e = (Node ?X, (λs::?'var ⇒ ?'val option. True)⇩√, NewExit) ⟹ ?P e; ⋀e::?'node LDCFG_node × (?'var, ?'val, ?'ret, ?'pname) edge_kind × ?'node LDCFG_node. e = (NewEntry, (λs::?'var ⇒ ?'val option. False)⇩√, NewExit) ⟹ ?P e⟧ ⟹ ?P ?x›*)) (*goals: 1. ‹⋀(a::'a) e::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node. ⟦(valid_edge::'a ⇒ bool) a; (sourcenode::'a ⇒ 'b) a ≠ (Entry::'b) ∨ (targetnode::'a ⇒ 'b) a ≠ (Exit::'b); e = (Node (sourcenode a), (kind::'a ⇒ ('c, 'd, 'e, 'f) edge_kind) a, Node (targetnode a)); lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit (a'::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node); src e = src a'; trg e ≠ trg a'; intra_kind (knd e); intra_kind (knd a')⟧ ⟹ ∃(Q::('c ⇒ 'd option) ⇒ bool) Q'::('c ⇒ 'd option) ⇒ bool. knd e = (Q)⇩√ ∧ knd a' = (Q')⇩√ ∧ (∀s::'c ⇒ 'd option. (Q s ⟶ ¬ Q' s) ∧ (Q' s ⟶ ¬ Q s))› 2. ‹⋀e::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node. ⟦e = (NewEntry, (λs::'c ⇒ 'd option. True)⇩√, Node (Entry::'b)); lift_valid_edge (valid_edge::'a ⇒ bool) (sourcenode::'a ⇒ 'b) (targetnode::'a ⇒ 'b) (kind::'a ⇒ ('c, 'd, 'e, 'f) edge_kind) Entry (Exit::'b) (a'::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node); src e = src a'; trg e ≠ trg a'; intra_kind (knd e); intra_kind (knd a')⟧ ⟹ ∃(Q::('c ⇒ 'd option) ⇒ bool) Q'::('c ⇒ 'd option) ⇒ bool. knd e = (Q)⇩√ ∧ knd a' = (Q')⇩√ ∧ (∀s::'c ⇒ 'd option. (Q s ⟶ ¬ Q' s) ∧ (Q' s ⟶ ¬ Q s))› 3. ‹⋀e::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node. ⟦e = (Node (Exit::'b), (λs::'c ⇒ 'd option. True)⇩√, NewExit); lift_valid_edge (valid_edge::'a ⇒ bool) (sourcenode::'a ⇒ 'b) (targetnode::'a ⇒ 'b) (kind::'a ⇒ ('c, 'd, 'e, 'f) edge_kind) (Entry::'b) Exit (a'::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node); src e = src a'; trg e ≠ trg a'; intra_kind (knd e); intra_kind (knd a')⟧ ⟹ ∃(Q::('c ⇒ 'd option) ⇒ bool) Q'::('c ⇒ 'd option) ⇒ bool. knd e = (Q)⇩√ ∧ knd a' = (Q')⇩√ ∧ (∀s::'c ⇒ 'd option. (Q s ⟶ ¬ Q' s) ∧ (Q' s ⟶ ¬ Q s))› 4. ‹⋀e::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node. ⟦e = (NewEntry, (λs::'c ⇒ 'd option. False)⇩√, NewExit); lift_valid_edge (valid_edge::'a ⇒ bool) (sourcenode::'a ⇒ 'b) (targetnode::'a ⇒ 'b) (kind::'a ⇒ ('c, 'd, 'e, 'f) edge_kind) (Entry::'b) (Exit::'b) (a'::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node); src e = src a'; trg e ≠ trg a'; intra_kind (knd e); intra_kind (knd a')⟧ ⟹ ∃(Q::('c ⇒ 'd option) ⇒ bool) Q'::('c ⇒ 'd option) ⇒ bool. knd e = (Q)⇩√ ∧ knd a' = (Q')⇩√ ∧ (∀s::'c ⇒ 'd option. (Q s ⟶ ¬ Q' s) ∧ (Q' s ⟶ ¬ Q s))›*) case (lve_edge a e) (*‹valid_edge a› ‹(sourcenode::'a ⇒ 'b) (a::'a) ≠ (Entry::'b) ∨ (targetnode::'a ⇒ 'b) a ≠ (Exit::'b)› ‹e = (Node (sourcenode a), kind a, Node (targetnode a))› ‹lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a'› ‹src e = src a'› ‹trg e ≠ trg a'› ‹intra_kind (knd e)› ‹intra_kind (knd a')›*) from ‹lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a'› (*‹lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a'›*) ‹valid_edge a› (*‹valid_edge a›*) ‹e = (Node (sourcenode a), kind a, Node (targetnode a))› (*‹(e::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node) = (Node ((sourcenode::'a ⇒ 'b) (a::'a)), (kind::'a ⇒ ('c, 'd, 'e, 'f) edge_kind) a, Node ((targetnode::'a ⇒ 'b) a))›*) ‹src e = src a'› (*‹src (e::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node) = src (a'::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node)›*) ‹trg e ≠ trg a'› (*‹trg (e::'b::type LDCFG_node × ('c::type, 'd::type, 'e::type, 'f::type) edge_kind × 'b::type LDCFG_node) ≠ trg (a'::'b::type LDCFG_node × ('c::type, 'd::type, 'e::type, 'f::type) edge_kind × 'b::type LDCFG_node)›*) ‹intra_kind (knd e)› (*‹intra_kind (knd e)›*) ‹intra_kind (knd a')› (*‹intra_kind (knd a')›*) show "?case" (*goal: ‹∃Q Q'. knd e = (Q)⇩√ ∧ knd a' = (Q')⇩√ ∧ (∀s. (Q s ⟶ ¬ Q' s) ∧ (Q' s ⟶ ¬ Q s))›*) proof (induct rule:lift_valid_edge.induct (*‹⟦lift_valid_edge ?valid_edge ?src ?trg ?knd ?E ?X ?x; ⋀a e. ⟦?valid_edge a; ?src a ≠ ?E ∨ ?trg a ≠ ?X; e = (Node (?src a), ?knd a, Node (?trg a))⟧ ⟹ ?P e; ⋀e. e = (NewEntry, (λs. True)⇩√, Node ?E) ⟹ ?P e; ⋀e. e = (Node ?X, (λs. True)⇩√, NewExit) ⟹ ?P e; ⋀e. e = (NewEntry, (λs. False)⇩√, NewExit) ⟹ ?P e⟧ ⟹ ?P ?x›*)) (*goals: 1. ‹⋀a ea. ⟦valid_edge a; sourcenode a ≠ Entry ∨ targetnode a ≠ Exit; ea = (Node (sourcenode a), kind a, Node (targetnode a)); valid_edge a; e = (Node (sourcenode a), kind a, Node (targetnode a)); src e = src ea; trg e ≠ trg ea; intra_kind (knd e); intra_kind (knd ea)⟧ ⟹ ∃Q Q'. knd e = (Q)⇩√ ∧ knd ea = (Q')⇩√ ∧ (∀s. (Q s ⟶ ¬ Q' s) ∧ (Q' s ⟶ ¬ Q s))› 2. ‹⋀ea. ⟦ea = (NewEntry, (λs. True)⇩√, Node Entry); valid_edge a; e = (Node (sourcenode a), kind a, Node (targetnode a)); src e = src ea; trg e ≠ trg ea; intra_kind (knd e); intra_kind (knd ea)⟧ ⟹ ∃Q Q'. knd e = (Q)⇩√ ∧ knd ea = (Q')⇩√ ∧ (∀s. (Q s ⟶ ¬ Q' s) ∧ (Q' s ⟶ ¬ Q s))› 3. ‹⋀ea. ⟦ea = (Node Exit, (λs. True)⇩√, NewExit); valid_edge a; e = (Node (sourcenode a), kind a, Node (targetnode a)); src e = src ea; trg e ≠ trg ea; intra_kind (knd e); intra_kind (knd ea)⟧ ⟹ ∃Q Q'. knd e = (Q)⇩√ ∧ knd ea = (Q')⇩√ ∧ (∀s. (Q s ⟶ ¬ Q' s) ∧ (Q' s ⟶ ¬ Q s))› 4. ‹⋀ea. ⟦ea = (NewEntry, (λs. False)⇩√, NewExit); valid_edge a; e = (Node (sourcenode a), kind a, Node (targetnode a)); src e = src ea; trg e ≠ trg ea; intra_kind (knd e); intra_kind (knd ea)⟧ ⟹ ∃Q Q'. knd e = (Q)⇩√ ∧ knd ea = (Q')⇩√ ∧ (∀s. (Q s ⟶ ¬ Q' s) ∧ (Q' s ⟶ ¬ Q s))›*) case lve_edge (*‹valid_edge a_› ‹sourcenode a_ ≠ Entry ∨ targetnode a_ ≠ Exit› ‹e_ = (Node (sourcenode a_), kind a_, Node (targetnode a_))› ‹valid_edge a› ‹e = (Node (sourcenode a), kind a, Node (targetnode a))› ‹src e = src e_› ‹trg e ≠ trg e_› ‹intra_kind (knd e)› ‹intra_kind (knd (e_::'b::type LDCFG_node × ('c::type, 'd::type, 'e::type, 'f::type) edge_kind × 'b::type LDCFG_node))›*) thus "?case" (*goal: ‹∃Q Q'. knd e = (Q)⇩√ ∧ knd e_ = (Q')⇩√ ∧ (∀s. (Q s ⟶ ¬ Q' s) ∧ (Q' s ⟶ ¬ Q s))›*) by (auto dest:deterministic (*‹⟦valid_edge ?a; valid_edge ?a'; sourcenode ?a = sourcenode ?a'; targetnode ?a ≠ targetnode ?a'; intra_kind (kind ?a); intra_kind (kind ?a')⟧ ⟹ ∃Q Q'. kind ?a = (Q)⇩√ ∧ kind ?a' = (Q')⇩√ ∧ (∀s. (Q s ⟶ ¬ Q' s) ∧ (Q' s ⟶ ¬ Q s))›*)) next (*goals: 1. ‹⋀ea. ⟦ea = (NewEntry, (λs. True)⇩√, Node Entry); valid_edge a; e = (Node (sourcenode a), kind a, Node (targetnode a)); src e = src ea; trg e ≠ trg ea; intra_kind (knd e); intra_kind (knd ea)⟧ ⟹ ∃Q Q'. knd e = (Q)⇩√ ∧ knd ea = (Q')⇩√ ∧ (∀s. (Q s ⟶ ¬ Q' s) ∧ (Q' s ⟶ ¬ Q s))› 2. ‹⋀ea. ⟦ea = (Node Exit, (λs. True)⇩√, NewExit); valid_edge a; e = (Node (sourcenode a), kind a, Node (targetnode a)); src e = src ea; trg e ≠ trg ea; intra_kind (knd e); intra_kind (knd ea)⟧ ⟹ ∃Q Q'. knd e = (Q)⇩√ ∧ knd ea = (Q')⇩√ ∧ (∀s. (Q s ⟶ ¬ Q' s) ∧ (Q' s ⟶ ¬ Q s))› 3. ‹⋀ea. ⟦ea = (NewEntry, (λs. False)⇩√, NewExit); valid_edge a; e = (Node (sourcenode a), kind a, Node (targetnode a)); src e = src ea; trg e ≠ trg ea; intra_kind (knd e); intra_kind (knd ea)⟧ ⟹ ∃Q Q'. knd e = (Q)⇩√ ∧ knd ea = (Q')⇩√ ∧ (∀s. (Q s ⟶ ¬ Q' s) ∧ (Q' s ⟶ ¬ Q s))›*) case (lve_Exit_edge e') (*‹e' = (Node Exit, (λs. True)⇩√, NewExit)› ‹valid_edge a› ‹(e::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node) = (Node ((sourcenode::'a ⇒ 'b) (a::'a)), (kind::'a ⇒ ('c, 'd, 'e, 'f) edge_kind) a, Node ((targetnode::'a ⇒ 'b) a))› ‹src e = src e'› ‹trg (e::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node) ≠ trg (e'::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node)› ‹intra_kind (knd e)› ‹intra_kind (knd e')›*) from ‹e = (Node (sourcenode a), kind a, Node (targetnode a))› (*‹e = (Node (sourcenode a), kind a, Node (targetnode a))›*) ‹e' = (Node Exit, (λs. True)⇩√, NewExit)› (*‹e' = (Node Exit, (λs. True)⇩√, NewExit)›*) ‹src e = src e'› (*‹src e = src e'›*) have "sourcenode a = Exit" by simp with ‹valid_edge a› (*‹valid_edge a›*) have False by (rule Exit_source (*‹⟦valid_edge ?a; sourcenode ?a = Exit⟧ ⟹ False›*)) thus "?case" (*goal: ‹∃(Q::('c ⇒ 'd option) ⇒ bool) Q'::('c ⇒ 'd option) ⇒ bool. knd (e::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node) = (Q)⇩√ ∧ knd (e'::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node) = (Q')⇩√ ∧ (∀s::'c ⇒ 'd option. (Q s ⟶ ¬ Q' s) ∧ (Q' s ⟶ ¬ Q s))›*) by simp qed (auto) (*solves the remaining goals: 1. ‹⋀ea. ⟦ea = (NewEntry, (λs. True)⇩√, Node Entry); valid_edge a; e = (Node (sourcenode a), kind a, Node (targetnode a)); src e = src ea; trg e ≠ trg ea; intra_kind (knd e); intra_kind (knd ea)⟧ ⟹ ∃Q Q'. knd e = (Q)⇩√ ∧ knd ea = (Q')⇩√ ∧ (∀s. (Q s ⟶ ¬ Q' s) ∧ (Q' s ⟶ ¬ Q s))› 2. ‹⋀ea. ⟦ea = (NewEntry, (λs. False)⇩√, NewExit); valid_edge a; e = (Node (sourcenode a), kind a, Node (targetnode a)); src e = src ea; trg e ≠ trg ea; intra_kind (knd e); intra_kind (knd ea)⟧ ⟹ ∃Q Q'. knd e = (Q)⇩√ ∧ knd ea = (Q')⇩√ ∧ (∀s. (Q s ⟶ ¬ Q' s) ∧ (Q' s ⟶ ¬ Q s))›*) qed ((fastforce elim:lift_valid_edge.cases (*‹⟦lift_valid_edge ?valid_edge ?src ?trg ?knd ?E ?X ?a; ⋀a e. ⟦?a = e; ?valid_edge a; ?src a ≠ ?E ∨ ?trg a ≠ ?X; e = (Node (?src a), ?knd a, Node (?trg a))⟧ ⟹ ?P; ⋀e. ⟦?a = e; e = (NewEntry, (λs. True)⇩√, Node ?E)⟧ ⟹ ?P; ⋀e. ⟦?a = e; e = (Node ?X, (λs. True)⇩√, NewExit)⟧ ⟹ ?P; ⋀e. ⟦?a = e; e = (NewEntry, (λs. False)⇩√, NewExit)⟧ ⟹ ?P⟧ ⟹ ?P›*))+) (*solves the remaining goals: 1. ‹⋀e. ⟦e = (NewEntry, (λs. True)⇩√, Node Entry); lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a'; src e = src a'; trg e ≠ trg a'; intra_kind (knd e); intra_kind (knd a')⟧ ⟹ ∃Q Q'. knd e = (Q)⇩√ ∧ knd a' = (Q')⇩√ ∧ (∀s. (Q s ⟶ ¬ Q' s) ∧ (Q' s ⟶ ¬ Q s))› 2. ‹⋀e. ⟦e = (Node Exit, (λs. True)⇩√, NewExit); lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a'; src e = src a'; trg e ≠ trg a'; intra_kind (knd e); intra_kind (knd a')⟧ ⟹ ∃Q Q'. knd e = (Q)⇩√ ∧ knd a' = (Q')⇩√ ∧ (∀s. (Q s ⟶ ¬ Q' s) ∧ (Q' s ⟶ ¬ Q s))› 3. ‹⋀e. ⟦e = (NewEntry, (λs. False)⇩√, NewExit); lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a'; src e = src a'; trg e ≠ trg a'; intra_kind (knd e); intra_kind (knd a')⟧ ⟹ ∃Q Q'. knd e = (Q)⇩√ ∧ knd a' = (Q')⇩√ ∧ (∀s. (Q s ⟶ ¬ Q' s) ∧ (Q' s ⟶ ¬ Q s))›*) qed qed lemma lift_CFGExit: assumes wf:"CFGExit_wf sourcenode targetnode kind valid_edge Entry get_proc get_return_edges procs Main Exit Def Use ParamDefs ParamUses" and pd:"Postdomination sourcenode targetnode kind valid_edge Entry get_proc get_return_edges procs Main Exit" shows "CFGExit src trg knd (lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit) NewEntry (lift_get_proc get_proc Main) (lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind) procs Main NewExit" proof (-) (*goal: ‹CFGExit src trg knd (lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit) NewEntry (lift_get_proc get_proc Main) (lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind) procs Main NewExit›*) interpret CFGExit_wf sourcenode targetnode kind valid_edge Entry get_proc get_return_edges procs Main Exit Def Use ParamDefs ParamUses by (rule wf (*‹CFGExit_wf sourcenode targetnode kind valid_edge Entry get_proc get_return_edges procs Main Exit Def Use ParamDefs ParamUses›*)) interpret Postdomination sourcenode targetnode kind valid_edge Entry get_proc get_return_edges procs Main Exit by (rule pd (*‹Postdomination sourcenode targetnode kind valid_edge Entry get_proc get_return_edges procs Main Exit›*)) interpret CFG: CFG src trg knd "lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit" NewEntry "lift_get_proc get_proc Main" "lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind" procs Main by (fastforce intro:lift_CFG (*‹⟦CFGExit_wf ?sourcenode ?targetnode ?kind ?valid_edge ?Entry ?get_proc ?get_return_edges ?procs ?Main ?Exit ?Def ?Use ?ParamDefs ?ParamUses; Postdomination ?sourcenode ?targetnode ?kind ?valid_edge ?Entry ?get_proc ?get_return_edges ?procs ?Main ?Exit⟧ ⟹ CFG src trg knd (lift_valid_edge ?valid_edge ?sourcenode ?targetnode ?kind ?Entry ?Exit) NewEntry (lift_get_proc ?get_proc ?Main) (lift_get_return_edges ?get_return_edges ?valid_edge ?sourcenode ?targetnode ?kind) ?procs ?Main›*) wf (*‹CFGExit_wf sourcenode targetnode kind valid_edge Entry get_proc get_return_edges procs Main Exit Def Use ParamDefs ParamUses›*) pd (*‹Postdomination sourcenode targetnode kind valid_edge Entry get_proc get_return_edges procs Main Exit›*)) show "?thesis" (*goal: ‹CFGExit src trg knd (lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit) NewEntry (lift_get_proc get_proc Main) (lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind) procs Main NewExit›*) proof (standard) (*goals: 1. ‹⋀a. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; src a = NewExit⟧ ⟹ False› 2. ‹lift_get_proc get_proc Main NewExit = Main› 3. ‹⋀a Q p f. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q↩⇘p⇙f; trg a = NewExit⟧ ⟹ False› 4. ‹∃a. lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a ∧ src a = NewEntry ∧ trg a = NewExit ∧ knd a = (λs. False)⇩√›*) fix a assume "lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a" and "src a = NewExit" (*‹lift_valid_edge (valid_edge::'a ⇒ bool) (sourcenode::'a ⇒ 'b) (targetnode::'a ⇒ 'b) (kind::'a ⇒ ('c, 'd, 'e, 'f) edge_kind) (Entry::'b) (Exit::'b) (a::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node)› ‹src (a::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node) = NewExit›*) thus False by (fastforce elim:lift_valid_edge.cases (*‹⟦lift_valid_edge ?valid_edge ?src ?trg ?knd ?E ?X ?a; ⋀a e. ⟦?a = e; ?valid_edge a; ?src a ≠ ?E ∨ ?trg a ≠ ?X; e = (Node (?src a), ?knd a, Node (?trg a))⟧ ⟹ ?P; ⋀e. ⟦?a = e; e = (NewEntry, (λs. True)⇩√, Node ?E)⟧ ⟹ ?P; ⋀e. ⟦?a = e; e = (Node ?X, (λs. True)⇩√, NewExit)⟧ ⟹ ?P; ⋀e. ⟦?a = e; e = (NewEntry, (λs. False)⇩√, NewExit)⟧ ⟹ ?P⟧ ⟹ ?P›*)) next (*goals: 1. ‹lift_get_proc (get_proc::'b ⇒ 'f) (Main::'f) NewExit = Main› 2. ‹⋀(a::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node) (Q::('c ⇒ 'd option) × 'e ⇒ bool) (p::'f) f::('c ⇒ 'd option) ⇒ ('c ⇒ 'd option) ⇒ 'c ⇒ 'd option. ⟦lift_valid_edge (valid_edge::'a ⇒ bool) (sourcenode::'a ⇒ 'b) (targetnode::'a ⇒ 'b) (kind::'a ⇒ ('c, 'd, 'e, 'f) edge_kind) (Entry::'b) (Exit::'b) a; knd a = Q↩⇘p⇙f; trg a = NewExit⟧ ⟹ False› 3. ‹∃a::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node. lift_valid_edge (valid_edge::'a ⇒ bool) (sourcenode::'a ⇒ 'b) (targetnode::'a ⇒ 'b) (kind::'a ⇒ ('c, 'd, 'e, 'f) edge_kind) (Entry::'b) (Exit::'b) a ∧ src a = NewEntry ∧ trg a = NewExit ∧ knd a = (λs::'c ⇒ 'd option. False)⇩√›*) show "lift_get_proc get_proc Main NewExit = Main" by simp next (*goals: 1. ‹⋀a Q p f. ⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q↩⇘p⇙f; trg a = NewExit⟧ ⟹ False› 2. ‹∃a. lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a ∧ src a = NewEntry ∧ trg a = NewExit ∧ knd a = (λs. False)⇩√›*) fix a and Q and p and f assume "lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a" and "knd a = Q↩⇘p⇙f" and "trg a = NewExit" (*‹lift_valid_edge (valid_edge::'a ⇒ bool) (sourcenode::'a ⇒ 'b) (targetnode::'a ⇒ 'b) (kind::'a ⇒ ('c, 'd, 'e, 'f) edge_kind) (Entry::'b) (Exit::'b) (a::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node)› ‹knd (a::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node) = Q::('c ⇒ 'd option) × 'e ⇒ bool↩⇘p::'f⇙f::('c ⇒ 'd option) ⇒ ('c ⇒ 'd option) ⇒ 'c ⇒ 'd option› ‹trg (a::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node) = NewExit›*) thus False by (fastforce elim:lift_valid_edge.cases (*‹⟦lift_valid_edge ?valid_edge ?src ?trg ?knd ?E ?X ?a; ⋀a e. ⟦?a = e; ?valid_edge a; ?src a ≠ ?E ∨ ?trg a ≠ ?X; e = (Node (?src a), ?knd a, Node (?trg a))⟧ ⟹ ?P; ⋀e. ⟦?a = e; e = (NewEntry, (λs. True)⇩√, Node ?E)⟧ ⟹ ?P; ⋀e. ⟦?a = e; e = (Node ?X, (λs. True)⇩√, NewExit)⟧ ⟹ ?P; ⋀e. ⟦?a = e; e = (NewEntry, (λs. False)⇩√, NewExit)⟧ ⟹ ?P⟧ ⟹ ?P›*)) next (*goal: ‹∃a. lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a ∧ src a = NewEntry ∧ trg a = NewExit ∧ knd a = (λs. False)⇩√›*) show "∃a. lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a ∧ src a = NewEntry ∧ trg a = NewExit ∧ knd a = (λs. False)⇩√" by (fastforce intro:lve_Entry_Exit_edge (*‹(?e::?'node LDCFG_node × (?'var, ?'val, ?'ret, ?'pname) edge_kind × ?'node LDCFG_node) = (NewEntry, (λs::?'var ⇒ ?'val option. False)⇩√, NewExit) ⟹ lift_valid_edge (?valid_edge::?'edge ⇒ bool) (?src::?'edge ⇒ ?'node) (?trg::?'edge ⇒ ?'node) (?knd::?'edge ⇒ (?'var, ?'val, ?'ret, ?'pname) edge_kind) (?E::?'node) (?X::?'node) ?e›*)) qed qed lemma lift_CFGExit_wf: assumes wf:"CFGExit_wf sourcenode targetnode kind valid_edge Entry get_proc get_return_edges procs Main Exit Def Use ParamDefs ParamUses" and pd:"Postdomination sourcenode targetnode kind valid_edge Entry get_proc get_return_edges procs Main Exit" shows "CFGExit_wf src trg knd (lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit) NewEntry (lift_get_proc get_proc Main) (lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind) procs Main NewExit (lift_Def Def Entry Exit H L) (lift_Use Use Entry Exit H L) (lift_ParamDefs ParamDefs) (lift_ParamUses ParamUses)" proof (-) (*goal: ‹CFGExit_wf src trg knd (lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit) NewEntry (lift_get_proc get_proc Main) (lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind) procs Main NewExit (lift_Def Def Entry Exit H L) (lift_Use Use Entry Exit H L) (lift_ParamDefs ParamDefs) (lift_ParamUses ParamUses)›*) interpret CFGExit_wf sourcenode targetnode kind valid_edge Entry get_proc get_return_edges procs Main Exit Def Use ParamDefs ParamUses by (rule wf (*‹CFGExit_wf sourcenode targetnode kind valid_edge Entry get_proc get_return_edges procs Main Exit Def Use ParamDefs ParamUses›*)) interpret Postdomination sourcenode targetnode kind valid_edge Entry get_proc get_return_edges procs Main Exit by (rule pd (*‹Postdomination sourcenode targetnode kind valid_edge Entry get_proc get_return_edges procs Main Exit›*)) interpret CFG_wf: CFG_wf src trg knd "lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit" NewEntry "lift_get_proc get_proc Main" "lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind" procs Main "lift_Def Def Entry Exit H L" "lift_Use Use Entry Exit H L" "lift_ParamDefs ParamDefs" "lift_ParamUses ParamUses" by (fastforce intro:lift_CFG_wf (*‹⟦CFGExit_wf ?sourcenode ?targetnode ?kind ?valid_edge ?Entry ?get_proc ?get_return_edges ?procs ?Main ?Exit ?Def ?Use ?ParamDefs ?ParamUses; Postdomination ?sourcenode ?targetnode ?kind ?valid_edge ?Entry ?get_proc ?get_return_edges ?procs ?Main ?Exit⟧ ⟹ CFG_wf src trg knd (lift_valid_edge ?valid_edge ?sourcenode ?targetnode ?kind ?Entry ?Exit) NewEntry (lift_get_proc ?get_proc ?Main) (lift_get_return_edges ?get_return_edges ?valid_edge ?sourcenode ?targetnode ?kind) ?procs ?Main (lift_Def ?Def ?Entry ?Exit ?H ?L) (lift_Use ?Use ?Entry ?Exit ?H ?L) (lift_ParamDefs ?ParamDefs) (lift_ParamUses ?ParamUses)›*) wf (*‹CFGExit_wf sourcenode targetnode kind valid_edge Entry get_proc get_return_edges procs Main Exit Def Use ParamDefs ParamUses›*) pd (*‹Postdomination sourcenode targetnode kind valid_edge Entry get_proc get_return_edges procs Main Exit›*)) interpret CFGExit: CFGExit src trg knd "lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit" NewEntry "lift_get_proc get_proc Main" "lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind" procs Main NewExit by (fastforce intro:lift_CFGExit (*‹⟦CFGExit_wf (?sourcenode::?'a ⇒ ?'b) (?targetnode::?'a ⇒ ?'b) (?kind::?'a ⇒ (?'c, ?'d, ?'e, ?'f) edge_kind) (?valid_edge::?'a ⇒ bool) (?Entry::?'b) (?get_proc::?'b ⇒ ?'f) (?get_return_edges::?'a ⇒ ?'a set) (?procs::(?'f × ?'c list × ?'c list) list) (?Main::?'f) (?Exit::?'b) (?Def::?'b ⇒ ?'c set) (?Use::?'b ⇒ ?'c set) (?ParamDefs::?'b ⇒ ?'c list) (?ParamUses::?'b ⇒ ?'c set list); Postdomination ?sourcenode ?targetnode ?kind ?valid_edge ?Entry ?get_proc ?get_return_edges ?procs ?Main ?Exit⟧ ⟹ CFGExit src trg knd (lift_valid_edge ?valid_edge ?sourcenode ?targetnode ?kind ?Entry ?Exit) NewEntry (lift_get_proc ?get_proc ?Main) (lift_get_return_edges ?get_return_edges ?valid_edge ?sourcenode ?targetnode ?kind) ?procs ?Main NewExit›*) wf (*‹CFGExit_wf (sourcenode::'a ⇒ 'b) (targetnode::'a ⇒ 'b) (kind::'a ⇒ ('c, 'd, 'e, 'f) edge_kind) (valid_edge::'a ⇒ bool) (Entry::'b) (get_proc::'b ⇒ 'f) (get_return_edges::'a ⇒ 'a set) (procs::('f × 'c list × 'c list) list) (Main::'f) (Exit::'b) (Def::'b ⇒ 'c set) (Use::'b ⇒ 'c set) (ParamDefs::'b ⇒ 'c list) (ParamUses::'b ⇒ 'c set list)›*) pd (*‹Postdomination (sourcenode::'a ⇒ 'b) (targetnode::'a ⇒ 'b) (kind::'a ⇒ ('c, 'd, 'e, 'f) edge_kind) (valid_edge::'a ⇒ bool) (Entry::'b) (get_proc::'b ⇒ 'f) (get_return_edges::'a ⇒ 'a set) (procs::('f × 'c list × 'c list) list) (Main::'f) (Exit::'b)›*)) show "?thesis" (*goal: ‹CFGExit_wf src trg knd (lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit) NewEntry (lift_get_proc get_proc Main) (lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind) procs Main NewExit (lift_Def Def Entry Exit H L) (lift_Use Use Entry Exit H L) (lift_ParamDefs ParamDefs) (lift_ParamUses ParamUses)›*) proof (standard) (*goal: ‹lift_Def Def Entry Exit H L NewExit = {} ∧ lift_Use Use Entry Exit H L NewExit = {}›*) show "lift_Def Def Entry Exit H L NewExit = {} ∧ lift_Use Use Entry Exit H L NewExit = {}" by (fastforce elim:lift_Def_set.cases (*‹⟦(?a1.0, ?a2.0) ∈ lift_Def_set ?Def ?E ?X ?H ?L; ⋀V n. ⟦?a1.0 = Node n; ?a2.0 = V; V ∈ ?Def n⟧ ⟹ ?P; ⋀V. ⟦?a1.0 = Node ?E; ?a2.0 = V; V ∈ ?H⟧ ⟹ ?P⟧ ⟹ ?P›*) lift_Use_set.cases (*‹⟦(?a1.0, ?a2.0) ∈ lift_Use_set ?Use ?E ?X ?H ?L; ⋀V n. ⟦?a1.0 = Node n; ?a2.0 = V; V ∈ ?Use n⟧ ⟹ ?P; ⋀V. ⟦?a1.0 = Node ?E; ?a2.0 = V; V ∈ ?H⟧ ⟹ ?P; ⋀V. ⟦?a1.0 = Node ?X; ?a2.0 = V; V ∈ ?L⟧ ⟹ ?P⟧ ⟹ ?P›*)) qed qed subsubsection ‹Lifting the SDG› lemma lift_Postdomination: assumes wf:"CFGExit_wf sourcenode targetnode kind valid_edge Entry get_proc get_return_edges procs Main Exit Def Use ParamDefs ParamUses" and pd:"Postdomination sourcenode targetnode kind valid_edge Entry get_proc get_return_edges procs Main Exit" and inner:"CFGExit.inner_node sourcenode targetnode valid_edge Entry Exit nx" shows "Postdomination src trg knd (lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit) NewEntry (lift_get_proc get_proc Main) (lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind) procs Main NewExit" proof (-) (*goal: ‹Postdomination src trg knd (lift_valid_edge (valid_edge::'a::type ⇒ bool) (sourcenode::'a::type ⇒ 'b::type) (targetnode::'a::type ⇒ 'b::type) (kind::'a::type ⇒ ('c::type, 'd::type, 'e::type, 'f::type) edge_kind) (Entry::'b::type) (Exit::'b::type)) NewEntry (lift_get_proc (get_proc::'b::type ⇒ 'f::type) (Main::'f::type)) (lift_get_return_edges (get_return_edges::'a::type ⇒ 'a::type set) valid_edge sourcenode targetnode kind) (procs::('f::type × 'c::type list × 'c::type list) list) Main NewExit›*) interpret CFGExit_wf sourcenode targetnode kind valid_edge Entry get_proc get_return_edges procs Main Exit Def Use ParamDefs ParamUses by (rule wf (*‹CFGExit_wf sourcenode targetnode kind valid_edge Entry get_proc get_return_edges procs Main Exit Def Use ParamDefs ParamUses›*)) interpret Postdomination sourcenode targetnode kind valid_edge Entry get_proc get_return_edges procs Main Exit by (rule pd (*‹Postdomination sourcenode targetnode kind valid_edge Entry get_proc get_return_edges procs Main Exit›*)) interpret CFGExit: CFGExit src trg knd "lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit" NewEntry "lift_get_proc get_proc Main" "lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind" procs Main NewExit by (fastforce intro:lift_CFGExit (*‹⟦CFGExit_wf ?sourcenode ?targetnode ?kind ?valid_edge ?Entry ?get_proc ?get_return_edges ?procs ?Main ?Exit ?Def ?Use ?ParamDefs ?ParamUses; Postdomination ?sourcenode ?targetnode ?kind ?valid_edge ?Entry ?get_proc ?get_return_edges ?procs ?Main ?Exit⟧ ⟹ CFGExit src trg knd (lift_valid_edge ?valid_edge ?sourcenode ?targetnode ?kind ?Entry ?Exit) NewEntry (lift_get_proc ?get_proc ?Main) (lift_get_return_edges ?get_return_edges ?valid_edge ?sourcenode ?targetnode ?kind) ?procs ?Main NewExit›*) wf (*‹CFGExit_wf sourcenode targetnode kind valid_edge Entry get_proc get_return_edges procs Main Exit Def Use ParamDefs ParamUses›*) pd (*‹Postdomination sourcenode targetnode kind valid_edge Entry get_proc get_return_edges procs Main Exit›*)) { fix m assume "valid_node m" (*‹valid_node (m::'b)›*) then obtain a where "valid_edge a" and "m = sourcenode a ∨ m = targetnode a" (*goal: ‹(⋀a::'a. ⟦(valid_edge::'a ⇒ bool) a; (m::'b) = (sourcenode::'a ⇒ 'b) a ∨ m = (targetnode::'a ⇒ 'b) a⟧ ⟹ thesis::bool) ⟹ thesis›*) by (auto simp:valid_node_def (*‹valid_node ?n ≡ ∃a. valid_edge a ∧ (?n = sourcenode a ∨ ?n = targetnode a)›*)) from ‹m = sourcenode a ∨ m = targetnode a› (*‹m = sourcenode a ∨ m = targetnode a›*) have "CFG.CFG.valid_node src trg (lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit) (Node m)" proof (standard) (*goals: 1. ‹m = sourcenode a ⟹ CFGExit.valid_node (Node m)› 2. ‹m = targetnode a ⟹ CFGExit.valid_node (Node m)›*) assume "m = sourcenode a" (*‹(m::'b) = (sourcenode::'a ⇒ 'b) (a::'a)›*) show "?thesis" (*goal: ‹CFGExit.valid_node (Node m)›*) proof (cases "m = Entry") (*goals: 1. ‹m = Entry ⟹ CFGExit.valid_node (Node m)› 2. ‹m ≠ Entry ⟹ CFGExit.valid_node (Node m)›*) case True (*‹m = Entry›*) have "lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit (NewEntry,(λs. True)⇩√,Node Entry)" by (fastforce intro:lve_Entry_edge (*‹?e = (NewEntry, (λs. True)⇩√, Node ?E) ⟹ lift_valid_edge ?valid_edge ?src ?trg ?knd ?E ?X ?e›*)) with ‹m = Entry› (*‹m = Entry›*) show "?thesis" (*goal: ‹CFGExit.valid_node (Node m)›*) by (fastforce simp:CFGExit.valid_node_def (*‹CFGExit.valid_node ?n ≡ ∃a. lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a ∧ (?n = src a ∨ ?n = trg a)›*)) next (*goal: ‹m ≠ Entry ⟹ CFGExit.valid_node (Node m)›*) case False (*‹m ≠ Entry›*) with ‹m = sourcenode a› (*‹m = sourcenode a›*) ‹valid_edge a› (*‹valid_edge a›*) have "lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit (Node (sourcenode a),kind a,Node(targetnode a))" by (fastforce intro:lve_edge (*‹⟦?valid_edge ?a; ?src ?a ≠ ?E ∨ ?trg ?a ≠ ?X; ?e = (Node (?src ?a), ?knd ?a, Node (?trg ?a))⟧ ⟹ lift_valid_edge ?valid_edge ?src ?trg ?knd ?E ?X ?e›*)) with ‹m = sourcenode a› (*‹m = sourcenode a›*) show "?thesis" (*goal: ‹CFGExit.valid_node (Node m)›*) by (fastforce simp:CFGExit.valid_node_def (*‹CFGExit.valid_node ?n ≡ ∃a. lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a ∧ (?n = src a ∨ ?n = trg a)›*)) qed next (*goal: ‹m = targetnode a ⟹ CFGExit.valid_node (Node m)›*) assume "m = targetnode a" (*‹(m::'b) = (targetnode::'a ⇒ 'b) (a::'a)›*) show "?thesis" (*goal: ‹CFGExit.valid_node (Node (m::'b))›*) proof (cases "m = Exit") (*goals: 1. ‹m = Exit ⟹ CFGExit.valid_node (Node m)› 2. ‹m ≠ Exit ⟹ CFGExit.valid_node (Node m)›*) case True (*‹m = Exit›*) have "lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit (Node Exit,(λs. True)⇩√,NewExit)" by (fastforce intro:lve_Exit_edge (*‹(?e::?'node LDCFG_node × (?'var, ?'val, ?'ret, ?'pname) edge_kind × ?'node LDCFG_node) = (Node (?X::?'node), (λs::?'var ⇒ ?'val option. True)⇩√, NewExit) ⟹ lift_valid_edge (?valid_edge::?'edge ⇒ bool) (?src::?'edge ⇒ ?'node) (?trg::?'edge ⇒ ?'node) (?knd::?'edge ⇒ (?'var, ?'val, ?'ret, ?'pname) edge_kind) (?E::?'node) ?X ?e›*)) with ‹m = Exit› (*‹m = Exit›*) show "?thesis" (*goal: ‹CFGExit.valid_node (Node m)›*) by (fastforce simp:CFGExit.valid_node_def (*‹CFGExit.valid_node ?n ≡ ∃a. lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a ∧ (?n = src a ∨ ?n = trg a)›*)) next (*goal: ‹(m::'b) ≠ (Exit::'b) ⟹ CFGExit.valid_node (Node m)›*) case False (*‹(m::'b::type) ≠ (Exit::'b::type)›*) with ‹m = targetnode a› (*‹m = targetnode a›*) ‹valid_edge a› (*‹valid_edge a›*) have "lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit (Node (sourcenode a),kind a,Node(targetnode a))" by (fastforce intro:lve_edge (*‹⟦?valid_edge ?a; ?src ?a ≠ ?E ∨ ?trg ?a ≠ ?X; ?e = (Node (?src ?a), ?knd ?a, Node (?trg ?a))⟧ ⟹ lift_valid_edge ?valid_edge ?src ?trg ?knd ?E ?X ?e›*)) with ‹m = targetnode a› (*‹m = targetnode a›*) show "?thesis" (*goal: ‹CFGExit.valid_node (Node m)›*) by (fastforce simp:CFGExit.valid_node_def (*‹CFGExit.valid_node ?n ≡ ∃a. lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a ∧ (?n = src a ∨ ?n = trg a)›*)) qed qed } note lift_valid_node = this (*‹valid_node ?m2 ⟹ CFGExit.valid_node (Node ?m2)›*) { fix n and as and n' and cs and m and m' assume "valid_path_aux cs as" and "m -as→* m'" and "∀c ∈ set cs. valid_edge c" and "m ≠ Entry ∨ m' ≠ Exit" (*‹valid_path_aux (cs::'a list) (as::'a list)› ‹(m::'b) -as::'a list→* m'::'b› ‹∀c::'a∈set (cs::'a list). (valid_edge::'a ⇒ bool) c› ‹(m::'b) ≠ (Entry::'b) ∨ (m'::'b) ≠ (Exit::'b)›*) hence "∃cs' es. CFG.CFG.valid_path_aux knd (lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind) cs' es ∧ list_all2 (λc c'. c' = (Node (sourcenode c),kind c,Node (targetnode c))) cs cs' ∧ CFG.CFG.path src trg (lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit) (Node m) es (Node m')" proof (induct arbitrary:m rule:vpa_induct) (*goals: 1. ‹⋀cs m. ⟦m -[]→* m'; Ball (set cs) valid_edge; m ≠ Entry ∨ m' ≠ Exit⟧ ⟹ ∃cs' es. CFGExit.valid_path_aux cs' es ∧ list_all2 (λc c'. c' = (Node (sourcenode c), kind c, Node (targetnode c))) cs cs' ∧ CFGExit.path (Node m) es (Node m')› 2. ‹⋀cs a as m. ⟦intra_kind (kind a); valid_path_aux cs as; ⋀m. ⟦m -as→* m'; Ball (set cs) valid_edge; m ≠ Entry ∨ m' ≠ Exit⟧ ⟹ ∃cs' es. CFGExit.valid_path_aux cs' es ∧ list_all2 (λc c'. c' = (Node (sourcenode c), kind c, Node (targetnode c))) cs cs' ∧ CFGExit.path (Node m) es (Node m'); m -a # as→* m'; Ball (set cs) valid_edge; m ≠ Entry ∨ m' ≠ Exit⟧ ⟹ ∃cs' es. CFGExit.valid_path_aux cs' es ∧ list_all2 (λc c'. c' = (Node (sourcenode c), kind c, Node (targetnode c))) cs cs' ∧ CFGExit.path (Node m) es (Node m')› 3. ‹⋀cs a as Q r p fs m. ⟦kind a = Q:r↪⇘p⇙fs; valid_path_aux (a # cs) as; ⋀m. ⟦m -as→* m'; Ball (set (a # cs)) valid_edge; m ≠ Entry ∨ m' ≠ Exit⟧ ⟹ ∃cs' es. CFGExit.valid_path_aux cs' es ∧ list_all2 (λc c'. c' = (Node (sourcenode c), kind c, Node (targetnode c))) (a # cs) cs' ∧ CFGExit.path (Node m) es (Node m'); m -a # as→* m'; Ball (set cs) valid_edge; m ≠ Entry ∨ m' ≠ Exit⟧ ⟹ ∃cs' es. CFGExit.valid_path_aux cs' es ∧ list_all2 (λc c'. c' = (Node (sourcenode c), kind c, Node (targetnode c))) cs cs' ∧ CFGExit.path (Node m) es (Node m')› 4. ‹⋀cs a as Q p f m. ⟦kind a = Q↩⇘p⇙f; cs = []; valid_path_aux [] as; ⋀m. ⟦m -as→* m'; Ball (set []) valid_edge; m ≠ Entry ∨ m' ≠ Exit⟧ ⟹ ∃cs' es. CFGExit.valid_path_aux cs' es ∧ list_all2 (λc c'. c' = (Node (sourcenode c), kind c, Node (targetnode c))) [] cs' ∧ CFGExit.path (Node m) es (Node m'); m -a # as→* m'; Ball (set cs) valid_edge; m ≠ Entry ∨ m' ≠ Exit⟧ ⟹ ∃cs' es. CFGExit.valid_path_aux cs' es ∧ list_all2 (λc c'. c' = (Node (sourcenode c), kind c, Node (targetnode c))) cs cs' ∧ CFGExit.path (Node m) es (Node m')› 5. ‹⋀cs a as Q p f c' cs' m. ⟦kind a = Q↩⇘p⇙f; cs = c' # cs'; valid_path_aux cs' as; a ∈ get_return_edges c'; ⋀m. ⟦m -as→* m'; Ball (set cs') valid_edge; m ≠ Entry ∨ m' ≠ Exit⟧ ⟹ ∃cs'a es. CFGExit.valid_path_aux cs'a es ∧ list_all2 (λc c'. c' = (Node (sourcenode c), kind c, Node (targetnode c))) cs' cs'a ∧ CFGExit.path (Node m) es (Node m'); m -a # as→* m'; Ball (set cs) valid_edge; m ≠ Entry ∨ m' ≠ Exit⟧ ⟹ ∃cs' es. CFGExit.valid_path_aux cs' es ∧ list_all2 (λc c'. c' = (Node (sourcenode c), kind c, Node (targetnode c))) cs cs' ∧ CFGExit.path (Node m) es (Node m')›*) case (vpa_empty cs) (*‹m -[]→* m'› ‹∀a∈set cs. valid_edge a› ‹m ≠ Entry ∨ m' ≠ Exit›*) from ‹m -[]→* m'› (*‹m -[]→* m'›*) have [simp]: "m = m'" by fastforce from ‹m -[]→* m'› (*‹m -[]→* m'›*) have "valid_node m" by (rule path_valid_node (*‹(?n::'b) -?as::'a list→* ?n'::'b ⟹ valid_node ?n› ‹(?n::'b) -?as::'a list→* ?n'::'b ⟹ valid_node ?n'›*)) obtain cs' where "cs' = map (λc. (Node (sourcenode c),kind c,Node (targetnode c))) cs" (*goal: ‹(⋀cs'::('b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node) list. cs' = map (λc::'a. (Node ((sourcenode::'a ⇒ 'b) c), (kind::'a ⇒ ('c, 'd, 'e, 'f) edge_kind) c, Node ((targetnode::'a ⇒ 'b) c))) (cs::'a list) ⟹ thesis::bool) ⟹ thesis›*) by simp hence "list_all2 (λc c'. c' = (Node (sourcenode c),kind c,Node (targetnode c))) cs cs'" by (simp add:list_all2_conv_all_nth (*‹list_all2 ?P ?xs ?ys = (length ?xs = length ?ys ∧ (∀i<length ?xs. ?P (?xs ! i) (?ys ! i)))›*)) with ‹valid_node m› (*‹valid_node m›*) show "?case" (*goal: ‹∃cs' es. CFGExit.valid_path_aux cs' es ∧ list_all2 (λc c'. c' = (Node (sourcenode c), kind c, Node (targetnode c))) cs cs' ∧ CFGExit.path (Node m) es (Node m')›*) apply (rule_tac x="cs'" in exI (*‹?P ?x ⟹ ∃x. ?P x›*)) (*goal: ‹∃cs' es. CFGExit.valid_path_aux cs' es ∧ list_all2 (λc c'. c' = (Node (sourcenode c), kind c, Node (targetnode c))) cs cs' ∧ CFGExit.path (Node m) es (Node m')›*) apply (rule_tac x="[]" in exI (*‹?P ?x ⟹ ∃x. ?P x›*)) (*goal: ‹⟦valid_node m; list_all2 (λc c'. c' = (Node (sourcenode c), kind c, Node (targetnode c))) cs cs'⟧ ⟹ ∃es. CFGExit.valid_path_aux cs' es ∧ list_all2 (λc c'. c' = (Node (sourcenode c), kind c, Node (targetnode c))) cs cs' ∧ CFGExit.path (Node m) es (Node m')›*) by (fastforce intro:CFGExit.empty_path (*‹CFGExit.valid_node ?n ⟹ CFGExit.path ?n [] ?n›*) lift_valid_node (*‹valid_node ?m2 ⟹ CFGExit.valid_node (Node ?m2)›*)) next (*goals: 1. ‹⋀cs a as m. ⟦intra_kind (kind a); valid_path_aux cs as; ⋀m. ⟦m -as→* m'; Ball (set cs) valid_edge; m ≠ Entry ∨ m' ≠ Exit⟧ ⟹ ∃cs' es. CFGExit.valid_path_aux cs' es ∧ list_all2 (λc c'. c' = (Node (sourcenode c), kind c, Node (targetnode c))) cs cs' ∧ CFGExit.path (Node m) es (Node m'); m -a # as→* m'; Ball (set cs) valid_edge; m ≠ Entry ∨ m' ≠ Exit⟧ ⟹ ∃cs' es. CFGExit.valid_path_aux cs' es ∧ list_all2 (λc c'. c' = (Node (sourcenode c), kind c, Node (targetnode c))) cs cs' ∧ CFGExit.path (Node m) es (Node m')› 2. ‹⋀cs a as Q r p fs m. ⟦kind a = Q:r↪⇘p⇙fs; valid_path_aux (a # cs) as; ⋀m. ⟦m -as→* m'; Ball (set (a # cs)) valid_edge; m ≠ Entry ∨ m' ≠ Exit⟧ ⟹ ∃cs' es. CFGExit.valid_path_aux cs' es ∧ list_all2 (λc c'. c' = (Node (sourcenode c), kind c, Node (targetnode c))) (a # cs) cs' ∧ CFGExit.path (Node m) es (Node m'); m -a # as→* m'; Ball (set cs) valid_edge; m ≠ Entry ∨ m' ≠ Exit⟧ ⟹ ∃cs' es. CFGExit.valid_path_aux cs' es ∧ list_all2 (λc c'. c' = (Node (sourcenode c), kind c, Node (targetnode c))) cs cs' ∧ CFGExit.path (Node m) es (Node m')› 3. ‹⋀cs a as Q p f m. ⟦kind a = Q↩⇘p⇙f; cs = []; valid_path_aux [] as; ⋀m. ⟦m -as→* m'; Ball (set []) valid_edge; m ≠ Entry ∨ m' ≠ Exit⟧ ⟹ ∃cs' es. CFGExit.valid_path_aux cs' es ∧ list_all2 (λc c'. c' = (Node (sourcenode c), kind c, Node (targetnode c))) [] cs' ∧ CFGExit.path (Node m) es (Node m'); m -a # as→* m'; Ball (set cs) valid_edge; m ≠ Entry ∨ m' ≠ Exit⟧ ⟹ ∃cs' es. CFGExit.valid_path_aux cs' es ∧ list_all2 (λc c'. c' = (Node (sourcenode c), kind c, Node (targetnode c))) cs cs' ∧ CFGExit.path (Node m) es (Node m')› 4. ‹⋀cs a as Q p f c' cs' m. ⟦kind a = Q↩⇘p⇙f; cs = c' # cs'; valid_path_aux cs' as; a ∈ get_return_edges c'; ⋀m. ⟦m -as→* m'; Ball (set cs') valid_edge; m ≠ Entry ∨ m' ≠ Exit⟧ ⟹ ∃cs'a es. CFGExit.valid_path_aux cs'a es ∧ list_all2 (λc c'. c' = (Node (sourcenode c), kind c, Node (targetnode c))) cs' cs'a ∧ CFGExit.path (Node m) es (Node m'); m -a # as→* m'; Ball (set cs) valid_edge; m ≠ Entry ∨ m' ≠ Exit⟧ ⟹ ∃cs' es. CFGExit.valid_path_aux cs' es ∧ list_all2 (λc c'. c' = (Node (sourcenode c), kind c, Node (targetnode c))) cs cs' ∧ CFGExit.path (Node m) es (Node m')›*) case (vpa_intra cs a as) (*‹intra_kind ((kind::'a ⇒ ('c, 'd, 'e, 'f) edge_kind) (a::'a))› ‹valid_path_aux cs as› ‹⟦?m -as→* m'; ∀a∈set cs. valid_edge a; ?m ≠ Entry ∨ m' ≠ Exit⟧ ⟹ ∃cs' es. CFGExit.valid_path_aux cs' es ∧ list_all2 (λc c'. c' = (Node (sourcenode c), kind c, Node (targetnode c))) cs cs' ∧ CFGExit.path (Node ?m) es (Node m')› ‹m -a # as→* m'› ‹∀a∈set cs. valid_edge a› ‹m ≠ Entry ∨ m' ≠ Exit›*) note IH = ‹⋀m. ⟦m -as→* m'; ∀c∈set cs. valid_edge c; m ≠ Entry ∨ m' ≠ Exit⟧ ⟹ ∃cs' es. CFG.valid_path_aux knd (lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind) cs' es ∧ list_all2 (λc c'. c' = (Node (sourcenode c), kind c, Node (targetnode c))) cs cs' ∧ CFG.path src trg (lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit) (Node m) es (Node m')› (*‹⟦?m -as→* m'; ∀c∈set cs. valid_edge c; ?m ≠ Entry ∨ m' ≠ Exit⟧ ⟹ ∃cs' es. CFGExit.valid_path_aux cs' es ∧ list_all2 (λc c'. c' = (Node (sourcenode c), kind c, Node (targetnode c))) cs cs' ∧ CFGExit.path (Node ?m) es (Node m')›*) from ‹m -a # as→* m'› (*‹m -a # as→* m'›*) have "m = sourcenode a" and "valid_edge a" and "targetnode a -as→* m'" apply - (*goals: 1. ‹m -a # as→* m' ⟹ m = sourcenode a› 2. ‹m -a # as→* m' ⟹ valid_edge a› 3. ‹m -a # as→* m' ⟹ targetnode a -as→* m'› discuss goal 1*) apply ((auto elim:path_split_Cons (*‹⟦?n -?as→* ?n'; ?as ≠ []; ⋀a' as'. ⟦?as = a' # as'; ?n = sourcenode a'; valid_edge a'; targetnode a' -as'→* ?n'⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*))[1]) (*discuss goal 2*) apply ((auto elim:path_split_Cons (*‹⟦(?n::'b) -?as::'a list→* ?n'::'b; ?as ≠ []; ⋀(a'::'a) as'::'a list. ⟦?as = a' # as'; ?n = (sourcenode::'a ⇒ 'b) a'; (valid_edge::'a ⇒ bool) a'; (targetnode::'a ⇒ 'b) a' -as'→* ?n'⟧ ⟹ ?thesis::bool⟧ ⟹ ?thesis›*))[1]) (*discuss goal 3*) apply ((auto elim:path_split_Cons (*‹⟦?n -?as→* ?n'; ?as ≠ []; ⋀a' as'. ⟦?as = a' # as'; ?n = sourcenode a'; valid_edge a'; targetnode a' -as'→* ?n'⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*))[1]) (*proven 3 subgoals*) . show "?case" (*goal: ‹∃(cs'::('b::type LDCFG_node × ('c::type, 'd::type, 'e::type, 'f::type) edge_kind × 'b::type LDCFG_node) list) es::('b::type LDCFG_node × ('c::type, 'd::type, 'e::type, 'f::type) edge_kind × 'b::type LDCFG_node) list. CFGExit.valid_path_aux cs' es ∧ list_all2 (λ(c::'a::type) c'::'b::type LDCFG_node × ('c::type, 'd::type, 'e::type, 'f::type) edge_kind × 'b::type LDCFG_node. c' = (Node ((sourcenode::'a::type ⇒ 'b::type) c), (kind::'a::type ⇒ ('c::type, 'd::type, 'e::type, 'f::type) edge_kind) c, Node ((targetnode::'a::type ⇒ 'b::type) c))) (cs::'a::type list) cs' ∧ CFGExit.path (Node (m::'b::type)) es (Node (m'::'b::type))›*) proof (cases "sourcenode a = Entry ∧ targetnode a = Exit") (*goals: 1. ‹(sourcenode::'a::type ⇒ 'b::type) (a::'a::type) = (Entry::'b::type) ∧ (targetnode::'a::type ⇒ 'b::type) a = (Exit::'b::type) ⟹ ∃(cs'::('b::type LDCFG_node × ('c::type, 'd::type, 'e::type, 'f::type) edge_kind × 'b::type LDCFG_node) list) es::('b::type LDCFG_node × ('c::type, 'd::type, 'e::type, 'f::type) edge_kind × 'b::type LDCFG_node) list. CFGExit.valid_path_aux cs' es ∧ list_all2 (λ(c::'a::type) c'::'b::type LDCFG_node × ('c::type, 'd::type, 'e::type, 'f::type) edge_kind × 'b::type LDCFG_node. c' = (Node (sourcenode c), (kind::'a::type ⇒ ('c::type, 'd::type, 'e::type, 'f::type) edge_kind) c, Node (targetnode c))) (cs::'a::type list) cs' ∧ CFGExit.path (Node (m::'b::type)) es (Node (m'::'b::type))› 2. ‹¬ ((sourcenode::'a::type ⇒ 'b::type) (a::'a::type) = (Entry::'b::type) ∧ (targetnode::'a::type ⇒ 'b::type) a = (Exit::'b::type)) ⟹ ∃(cs'::('b::type LDCFG_node × ('c::type, 'd::type, 'e::type, 'f::type) edge_kind × 'b::type LDCFG_node) list) es::('b::type LDCFG_node × ('c::type, 'd::type, 'e::type, 'f::type) edge_kind × 'b::type LDCFG_node) list. CFGExit.valid_path_aux cs' es ∧ list_all2 (λ(c::'a::type) c'::'b::type LDCFG_node × ('c::type, 'd::type, 'e::type, 'f::type) edge_kind × 'b::type LDCFG_node. c' = (Node (sourcenode c), (kind::'a::type ⇒ ('c::type, 'd::type, 'e::type, 'f::type) edge_kind) c, Node (targetnode c))) (cs::'a::type list) cs' ∧ CFGExit.path (Node (m::'b::type)) es (Node (m'::'b::type))›*) case True (*‹sourcenode a = Entry ∧ targetnode a = Exit›*) with ‹m = sourcenode a› (*‹m = sourcenode a›*) ‹m ≠ Entry ∨ m' ≠ Exit› (*‹m ≠ Entry ∨ m' ≠ Exit›*) have "m' ≠ Exit" by simp from True (*‹sourcenode a = Entry ∧ targetnode a = Exit›*) have "targetnode a = Exit" by simp with ‹targetnode a -as→* m'› (*‹targetnode a -as→* m'›*) have "m' = Exit" apply - (*goal: ‹m' = Exit›*) apply (drule path_Exit_source (*‹⟦?n -?as→* ?n'; ?n = Exit⟧ ⟹ ?n' = Exit ∧ ?as = []›*)) (*goals: 1. ‹(targetnode::'a ⇒ 'b) (a::'a) = (Exit::'b) ⟹ targetnode a = Exit› 2. ‹⟦(targetnode::'a ⇒ 'b) (a::'a) = (Exit::'b); (m'::'b) = Exit ∧ (as::'a list) = []⟧ ⟹ m' = Exit› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . with ‹m' ≠ Exit› (*‹m' ≠ Exit›*) have False by simp thus "?thesis" (*goal: ‹∃cs' es. CFGExit.valid_path_aux cs' es ∧ list_all2 (λc c'. c' = (Node (sourcenode c), kind c, Node (targetnode c))) cs cs' ∧ CFGExit.path (Node m) es (Node m')›*) by simp next (*goal: ‹¬ ((sourcenode::'a ⇒ 'b) (a::'a) = (Entry::'b) ∧ (targetnode::'a ⇒ 'b) a = (Exit::'b)) ⟹ ∃(cs'::('b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node) list) es::('b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node) list. CFGExit.valid_path_aux cs' es ∧ list_all2 (λ(c::'a) c'::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node. c' = (Node (sourcenode c), (kind::'a ⇒ ('c, 'd, 'e, 'f) edge_kind) c, Node (targetnode c))) (cs::'a list) cs' ∧ CFGExit.path (Node (m::'b)) es (Node (m'::'b))›*) case False (*‹¬ (sourcenode a = Entry ∧ targetnode a = Exit)›*) let ?e = "(Node (sourcenode a),kind a,Node (targetnode a))" from False (*‹¬ (sourcenode a = Entry ∧ targetnode a = Exit)›*) ‹valid_edge a› (*‹valid_edge a›*) have "lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit ?e" by (fastforce intro:lve_edge (*‹⟦?valid_edge ?a; ?src ?a ≠ ?E ∨ ?trg ?a ≠ ?X; ?e = (Node (?src ?a), ?knd ?a, Node (?trg ?a))⟧ ⟹ lift_valid_edge ?valid_edge ?src ?trg ?knd ?E ?X ?e›*)) have "targetnode a ≠ Entry" proof (standard) (*goal: ‹targetnode a = Entry ⟹ False›*) assume "targetnode a = Entry" (*‹(targetnode::'a ⇒ 'b) (a::'a) = (Entry::'b)›*) with ‹valid_edge a› (*‹valid_edge a›*) show False by (rule Entry_target (*‹⟦valid_edge ?a; targetnode ?a = Entry⟧ ⟹ False›*)) qed hence "targetnode a ≠ Entry ∨ m' ≠ Exit" by simp from IH[OF ‹targetnode a -as→* m'› ‹∀c∈set cs. valid_edge c› this] (*‹∃cs' es. CFGExit.valid_path_aux cs' es ∧ list_all2 (λc c'. c' = (Node (sourcenode c), kind c, Node (targetnode c))) cs cs' ∧ CFGExit.path (Node (targetnode a)) es (Node m')›*) obtain cs' and es where valid_path: "CFG.valid_path_aux knd (lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind) cs' es" and list: "list_all2 (λc c'. c' = (Node (sourcenode c), kind c, Node (targetnode c))) cs cs'" and path: "CFG.path src trg (lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit) (Node (targetnode a)) es (Node m')" (*goal: ‹(⋀cs' es. ⟦CFGExit.valid_path_aux cs' es; list_all2 (λc c'. c' = (Node (sourcenode c), kind c, Node (targetnode c))) cs cs'; CFGExit.path (Node (targetnode a)) es (Node m')⟧ ⟹ thesis) ⟹ thesis›*) by blast from ‹intra_kind (kind a)› (*‹intra_kind (kind a)›*) valid_path (*‹CFGExit.valid_path_aux cs' es›*) have "CFG.valid_path_aux knd (lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind) cs' (?e#es)" by (fastforce simp:intra_kind_def (*‹intra_kind (?et::(?'var, ?'val, ?'ret, ?'pname) edge_kind) ≡ (∃f::(?'var ⇒ ?'val option) ⇒ ?'var ⇒ ?'val option. ?et = ⇑f) ∨ (∃Q::(?'var ⇒ ?'val option) ⇒ bool. ?et = (Q)⇩√)›*)) moreover from path (*‹CFGExit.path (Node (targetnode a)) es (Node m')›*) ‹m = sourcenode a› (*‹m = sourcenode a›*) ‹lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit ?e› (*‹lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit (Node (sourcenode a), kind a, Node (targetnode a))›*) have "CFG.path src trg (lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit) (Node m) (?e#es) (Node m')" by (fastforce intro:CFGExit.Cons_path (*‹⟦CFGExit.path ?n'' ?as ?n'; lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit ?a; src ?a = ?n; trg ?a = ?n''⟧ ⟹ CFGExit.path ?n (?a # ?as) ?n'›*)) ultimately show "?thesis" (*goal: ‹∃(cs'::('b::type LDCFG_node × ('c::type, 'd::type, 'e::type, 'f::type) edge_kind × 'b::type LDCFG_node) list) es::('b::type LDCFG_node × ('c::type, 'd::type, 'e::type, 'f::type) edge_kind × 'b::type LDCFG_node) list. CFGExit.valid_path_aux cs' es ∧ list_all2 (λ(c::'a::type) c'::'b::type LDCFG_node × ('c::type, 'd::type, 'e::type, 'f::type) edge_kind × 'b::type LDCFG_node. c' = (Node ((sourcenode::'a::type ⇒ 'b::type) c), (kind::'a::type ⇒ ('c::type, 'd::type, 'e::type, 'f::type) edge_kind) c, Node ((targetnode::'a::type ⇒ 'b::type) c))) (cs::'a::type list) cs' ∧ CFGExit.path (Node (m::'b::type)) es (Node (m'::'b::type))›*) using list (*‹list_all2 (λc c'. c' = (Node (sourcenode c), kind c, Node (targetnode c))) cs cs'›*) by blast qed next (*goals: 1. ‹⋀cs a as Q r p fs m. ⟦kind a = Q:r↪⇘p⇙fs; valid_path_aux (a # cs) as; ⋀m. ⟦m -as→* m'; Ball (set (a # cs)) valid_edge; m ≠ Entry ∨ m' ≠ Exit⟧ ⟹ ∃cs' es. CFGExit.valid_path_aux cs' es ∧ list_all2 (λc c'. c' = (Node (sourcenode c), kind c, Node (targetnode c))) (a # cs) cs' ∧ CFGExit.path (Node m) es (Node m'); m -a # as→* m'; Ball (set cs) valid_edge; m ≠ Entry ∨ m' ≠ Exit⟧ ⟹ ∃cs' es. CFGExit.valid_path_aux cs' es ∧ list_all2 (λc c'. c' = (Node (sourcenode c), kind c, Node (targetnode c))) cs cs' ∧ CFGExit.path (Node m) es (Node m')› 2. ‹⋀cs a as Q p f m. ⟦kind a = Q↩⇘p⇙f; cs = []; valid_path_aux [] as; ⋀m. ⟦m -as→* m'; Ball (set []) valid_edge; m ≠ Entry ∨ m' ≠ Exit⟧ ⟹ ∃cs' es. CFGExit.valid_path_aux cs' es ∧ list_all2 (λc c'. c' = (Node (sourcenode c), kind c, Node (targetnode c))) [] cs' ∧ CFGExit.path (Node m) es (Node m'); m -a # as→* m'; Ball (set cs) valid_edge; m ≠ Entry ∨ m' ≠ Exit⟧ ⟹ ∃cs' es. CFGExit.valid_path_aux cs' es ∧ list_all2 (λc c'. c' = (Node (sourcenode c), kind c, Node (targetnode c))) cs cs' ∧ CFGExit.path (Node m) es (Node m')› 3. ‹⋀cs a as Q p f c' cs' m. ⟦kind a = Q↩⇘p⇙f; cs = c' # cs'; valid_path_aux cs' as; a ∈ get_return_edges c'; ⋀m. ⟦m -as→* m'; Ball (set cs') valid_edge; m ≠ Entry ∨ m' ≠ Exit⟧ ⟹ ∃cs'a es. CFGExit.valid_path_aux cs'a es ∧ list_all2 (λc c'. c' = (Node (sourcenode c), kind c, Node (targetnode c))) cs' cs'a ∧ CFGExit.path (Node m) es (Node m'); m -a # as→* m'; Ball (set cs) valid_edge; m ≠ Entry ∨ m' ≠ Exit⟧ ⟹ ∃cs' es. CFGExit.valid_path_aux cs' es ∧ list_all2 (λc c'. c' = (Node (sourcenode c), kind c, Node (targetnode c))) cs cs' ∧ CFGExit.path (Node m) es (Node m')›*) case (vpa_Call cs a as Q r p fs) (*‹kind a = Q:r↪⇘p⇙fs› ‹valid_path_aux (a # cs) as› ‹⟦?m -as→* m'; ∀a∈set (a # cs). valid_edge a; ?m ≠ Entry ∨ m' ≠ Exit⟧ ⟹ ∃cs' es. CFGExit.valid_path_aux cs' es ∧ list_all2 (λc c'. c' = (Node (sourcenode c), kind c, Node (targetnode c))) (a # cs) cs' ∧ CFGExit.path (Node ?m) es (Node m')› ‹m -a # as→* m'› ‹∀a∈set cs. valid_edge a› ‹m ≠ Entry ∨ m' ≠ Exit›*) note IH = ‹⋀m. ⟦m -as→* m'; ∀c∈set (a # cs). valid_edge c; m ≠ Entry ∨ m' ≠ Exit⟧ ⟹ ∃cs' es. CFG.valid_path_aux knd (lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind) cs' es ∧ list_all2 (λc c'. c' = (Node (sourcenode c), kind c, Node (targetnode c))) (a#cs) cs' ∧ CFG.path src trg (lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit) (Node m) es (Node m')› (*‹⟦?m -as→* m'; ∀c∈set (a # cs). valid_edge c; ?m ≠ Entry ∨ m' ≠ Exit⟧ ⟹ ∃cs' es. CFGExit.valid_path_aux cs' es ∧ list_all2 (λc c'. c' = (Node (sourcenode c), kind c, Node (targetnode c))) (a # cs) cs' ∧ CFGExit.path (Node ?m) es (Node m')›*) from ‹m -a # as→* m'› (*‹m -a # as→* m'›*) have "m = sourcenode a" and "valid_edge a" and "targetnode a -as→* m'" apply - (*goals: 1. ‹m -a # as→* m' ⟹ m = sourcenode a› 2. ‹m -a # as→* m' ⟹ valid_edge a› 3. ‹m -a # as→* m' ⟹ targetnode a -as→* m'› discuss goal 1*) apply ((auto elim:path_split_Cons (*‹⟦?n -?as→* ?n'; ?as ≠ []; ⋀a' as'. ⟦?as = a' # as'; ?n = sourcenode a'; valid_edge a'; targetnode a' -as'→* ?n'⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*))[1]) (*discuss goal 2*) apply ((auto elim:path_split_Cons (*‹⟦?n -?as→* ?n'; ?as ≠ []; ⋀a' as'. ⟦?as = a' # as'; ?n = sourcenode a'; valid_edge a'; targetnode a' -as'→* ?n'⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*))[1]) (*discuss goal 3*) apply ((auto elim:path_split_Cons (*‹⟦?n -?as→* ?n'; ?as ≠ []; ⋀a' as'. ⟦?as = a' # as'; ?n = sourcenode a'; valid_edge a'; targetnode a' -as'→* ?n'⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*))[1]) (*proven 3 subgoals*) . from ‹∀c∈set cs. valid_edge c› (*‹∀c∈set cs. valid_edge c›*) ‹valid_edge a› (*‹valid_edge a›*) have "∀c∈set (a # cs). valid_edge c" by simp let ?e = "(Node (sourcenode a),kind a,Node (targetnode a))" have "sourcenode a ≠ Entry" proof (standard) (*goal: ‹sourcenode a = Entry ⟹ False›*) assume "sourcenode a = Entry" (*‹(sourcenode::'a ⇒ 'b) (a::'a) = (Entry::'b)›*) with ‹valid_edge a› (*‹(valid_edge::'a ⇒ bool) (a::'a)›*) ‹kind a = Q:r↪⇘p⇙fs› (*‹kind a = Q:r↪⇘p⇙fs›*) show False by (rule Entry_no_call_source (*‹⟦valid_edge ?a; kind ?a = ?Q:?r↪⇘?p⇙?fs; sourcenode ?a = Entry⟧ ⟹ False›*)) qed with ‹valid_edge a› (*‹valid_edge a›*) have "lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit ?e" by (fastforce intro:lve_edge (*‹⟦?valid_edge ?a; ?src ?a ≠ ?E ∨ ?trg ?a ≠ ?X; ?e = (Node (?src ?a), ?knd ?a, Node (?trg ?a))⟧ ⟹ lift_valid_edge ?valid_edge ?src ?trg ?knd ?E ?X ?e›*)) have "targetnode a ≠ Entry" proof (standard) (*goal: ‹targetnode a = Entry ⟹ False›*) assume "targetnode a = Entry" (*‹(targetnode::'a ⇒ 'b) (a::'a) = (Entry::'b)›*) with ‹valid_edge a› (*‹(valid_edge::'a ⇒ bool) (a::'a)›*) show False by (rule Entry_target (*‹⟦valid_edge ?a; targetnode ?a = Entry⟧ ⟹ False›*)) qed hence "targetnode a ≠ Entry ∨ m' ≠ Exit" by simp from IH[OF ‹targetnode a -as→* m'› ‹∀c∈set (a # cs). valid_edge c› this] (*‹∃cs' es. CFGExit.valid_path_aux cs' es ∧ list_all2 (λc c'. c' = (Node (sourcenode c), kind c, Node (targetnode c))) (a # cs) cs' ∧ CFGExit.path (Node (targetnode a)) es (Node m')›*) obtain cs' and es where valid_path: "CFG.valid_path_aux knd (lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind) cs' es" and list: "list_all2 (λc c'. c' = (Node (sourcenode c), kind c, Node (targetnode c))) (a#cs) cs'" and path: "CFG.path src trg (lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit) (Node (targetnode a)) es (Node m')" (*goal: ‹(⋀cs' es. ⟦CFGExit.valid_path_aux cs' es; list_all2 (λc c'. c' = (Node (sourcenode c), kind c, Node (targetnode c))) (a # cs) cs'; CFGExit.path (Node (targetnode a)) es (Node m')⟧ ⟹ thesis) ⟹ thesis›*) by blast from list (*‹list_all2 (λc c'. c' = (Node (sourcenode c), kind c, Node (targetnode c))) (a # cs) cs'›*) obtain cx and csx where "cs' = cx#csx" and cx: "cx = (Node (sourcenode a), kind a, Node (targetnode a))" and list': "list_all2 (λc c'. c' = (Node (sourcenode c), kind c, Node (targetnode c))) cs csx" (*goal: ‹(⋀cx csx. ⟦cs' = cx # csx; cx = (Node (sourcenode a), kind a, Node (targetnode a)); list_all2 (λc c'. c' = (Node (sourcenode c), kind c, Node (targetnode c))) cs csx⟧ ⟹ thesis) ⟹ thesis›*) by (fastforce simp:list_all2_Cons1 (*‹list_all2 ?P (?x # ?xs) ?ys = (∃z zs. ?ys = z # zs ∧ ?P ?x z ∧ list_all2 ?P ?xs zs)›*)) from valid_path (*‹CFGExit.valid_path_aux (cs'::('b::type LDCFG_node × ('c::type, 'd::type, 'e::type, 'f::type) edge_kind × 'b::type LDCFG_node) list) (es::('b::type LDCFG_node × ('c::type, 'd::type, 'e::type, 'f::type) edge_kind × 'b::type LDCFG_node) list)›*) cx (*‹cx = (Node (sourcenode a), kind a, Node (targetnode a))›*) ‹cs' = cx#csx› (*‹cs' = cx # csx›*) ‹kind a = Q:r↪⇘p⇙fs› (*‹kind a = Q:r↪⇘p⇙fs›*) have "CFG.valid_path_aux knd (lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind) csx (?e#es)" by simp moreover from path (*‹CFGExit.path (Node ((targetnode::'a ⇒ 'b) (a::'a))) (es::('b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node) list) (Node (m'::'b))›*) ‹m = sourcenode a› (*‹(m::'b) = (sourcenode::'a ⇒ 'b) (a::'a)›*) ‹lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit ?e› (*‹lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit (Node (sourcenode a), kind a, Node (targetnode a))›*) have "CFG.path src trg (lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit) (Node m) (?e#es) (Node m')" by (fastforce intro:CFGExit.Cons_path (*‹⟦CFGExit.path ?n'' ?as ?n'; lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit ?a; src ?a = ?n; trg ?a = ?n''⟧ ⟹ CFGExit.path ?n (?a # ?as) ?n'›*)) ultimately show "?case" (*goal: ‹∃cs' es. CFGExit.valid_path_aux cs' es ∧ list_all2 (λc c'. c' = (Node (sourcenode c), kind c, Node (targetnode c))) cs cs' ∧ CFGExit.path (Node m) es (Node m')›*) using list' (*‹list_all2 (λ(c::'a) c'::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node. c' = (Node ((sourcenode::'a ⇒ 'b) c), (kind::'a ⇒ ('c, 'd, 'e, 'f) edge_kind) c, Node ((targetnode::'a ⇒ 'b) c))) (cs::'a list) (csx::('b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node) list)›*) by blast next (*goals: 1. ‹⋀cs a as Q p f m. ⟦kind a = Q↩⇘p⇙f; cs = []; valid_path_aux [] as; ⋀m. ⟦m -as→* m'; Ball (set []) valid_edge; m ≠ Entry ∨ m' ≠ Exit⟧ ⟹ ∃cs' es. CFGExit.valid_path_aux cs' es ∧ list_all2 (λc c'. c' = (Node (sourcenode c), kind c, Node (targetnode c))) [] cs' ∧ CFGExit.path (Node m) es (Node m'); m -a # as→* m'; Ball (set cs) valid_edge; m ≠ Entry ∨ m' ≠ Exit⟧ ⟹ ∃cs' es. CFGExit.valid_path_aux cs' es ∧ list_all2 (λc c'. c' = (Node (sourcenode c), kind c, Node (targetnode c))) cs cs' ∧ CFGExit.path (Node m) es (Node m')› 2. ‹⋀cs a as Q p f c' cs' m. ⟦kind a = Q↩⇘p⇙f; cs = c' # cs'; valid_path_aux cs' as; a ∈ get_return_edges c'; ⋀m. ⟦m -as→* m'; Ball (set cs') valid_edge; m ≠ Entry ∨ m' ≠ Exit⟧ ⟹ ∃cs'a es. CFGExit.valid_path_aux cs'a es ∧ list_all2 (λc c'. c' = (Node (sourcenode c), kind c, Node (targetnode c))) cs' cs'a ∧ CFGExit.path (Node m) es (Node m'); m -a # as→* m'; Ball (set cs) valid_edge; m ≠ Entry ∨ m' ≠ Exit⟧ ⟹ ∃cs' es. CFGExit.valid_path_aux cs' es ∧ list_all2 (λc c'. c' = (Node (sourcenode c), kind c, Node (targetnode c))) cs cs' ∧ CFGExit.path (Node m) es (Node m')›*) case (vpa_ReturnEmpty cs a as Q p f) (*‹kind a = Q↩⇘p⇙f› ‹cs = []› ‹valid_path_aux [] as› ‹⟦?m -as→* m'; ∀a∈set []. valid_edge a; ?m ≠ Entry ∨ m' ≠ Exit⟧ ⟹ ∃cs' es. CFGExit.valid_path_aux cs' es ∧ list_all2 (λc c'. c' = (Node (sourcenode c), kind c, Node (targetnode c))) [] cs' ∧ CFGExit.path (Node ?m) es (Node m')› ‹m -a # as→* m'› ‹∀a∈set cs. valid_edge a› ‹m ≠ Entry ∨ m' ≠ Exit›*) note IH = ‹⋀m. ⟦m -as→* m'; ∀c∈set []. valid_edge c; m ≠ Entry ∨ m' ≠ Exit⟧ ⟹ ∃cs' es. CFG.valid_path_aux knd (lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind) cs' es ∧ list_all2 (λc c'. c' = (Node (sourcenode c), kind c, Node (targetnode c))) [] cs' ∧ CFG.path src trg (lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit) (Node m) es (Node m')› (*‹⟦?m -as→* m'; ∀c∈set []. valid_edge c; ?m ≠ Entry ∨ m' ≠ Exit⟧ ⟹ ∃cs' es. CFGExit.valid_path_aux cs' es ∧ list_all2 (λc c'. c' = (Node (sourcenode c), kind c, Node (targetnode c))) [] cs' ∧ CFGExit.path (Node ?m) es (Node m')›*) from ‹m -a # as→* m'› (*‹m -a # as→* m'›*) have "m = sourcenode a" and "valid_edge a" and "targetnode a -as→* m'" apply - (*goals: 1. ‹(m::'b) -(a::'a) # (as::'a list)→* m'::'b ⟹ m = (sourcenode::'a ⇒ 'b) a› 2. ‹(m::'b) -(a::'a) # (as::'a list)→* m'::'b ⟹ (valid_edge::'a ⇒ bool) a› 3. ‹(m::'b) -(a::'a) # (as::'a list)→* m'::'b ⟹ (targetnode::'a ⇒ 'b) a -as→* m'› discuss goal 1*) apply ((auto elim:path_split_Cons (*‹⟦(?n::'b) -?as::'a list→* ?n'::'b; ?as ≠ []; ⋀(a'::'a) as'::'a list. ⟦?as = a' # as'; ?n = (sourcenode::'a ⇒ 'b) a'; (valid_edge::'a ⇒ bool) a'; (targetnode::'a ⇒ 'b) a' -as'→* ?n'⟧ ⟹ ?thesis::bool⟧ ⟹ ?thesis›*))[1]) (*discuss goal 2*) apply ((auto elim:path_split_Cons (*‹⟦?n -?as→* ?n'; ?as ≠ []; ⋀a' as'. ⟦?as = a' # as'; ?n = sourcenode a'; valid_edge a'; targetnode a' -as'→* ?n'⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*))[1]) (*discuss goal 3*) apply ((auto elim:path_split_Cons (*‹⟦?n -?as→* ?n'; ?as ≠ []; ⋀a' as'. ⟦?as = a' # as'; ?n = sourcenode a'; valid_edge a'; targetnode a' -as'→* ?n'⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*))[1]) (*proven 3 subgoals*) . let ?e = "(Node (sourcenode a),kind a,Node (targetnode a))" have "targetnode a ≠ Exit" proof (standard) (*goal: ‹targetnode a = Exit ⟹ False›*) assume "targetnode a = Exit" (*‹(targetnode::'a ⇒ 'b) (a::'a) = (Exit::'b)›*) with ‹valid_edge a› (*‹valid_edge a›*) ‹kind a = Q↩⇘p⇙f› (*‹kind a = Q↩⇘p⇙f›*) show False by (rule Exit_no_return_target (*‹⟦valid_edge ?a; kind ?a = ?Q↩⇘?p⇙?f; targetnode ?a = Exit⟧ ⟹ False›*)) qed with ‹valid_edge a› (*‹valid_edge a›*) have "lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit ?e" by (fastforce intro:lve_edge (*‹⟦?valid_edge ?a; ?src ?a ≠ ?E ∨ ?trg ?a ≠ ?X; ?e = (Node (?src ?a), ?knd ?a, Node (?trg ?a))⟧ ⟹ lift_valid_edge ?valid_edge ?src ?trg ?knd ?E ?X ?e›*)) have "targetnode a ≠ Entry" proof (standard) (*goal: ‹targetnode a = Entry ⟹ False›*) assume "targetnode a = Entry" (*‹(targetnode::'a ⇒ 'b) (a::'a) = (Entry::'b)›*) with ‹valid_edge a› (*‹valid_edge a›*) show False by (rule Entry_target (*‹⟦valid_edge ?a; targetnode ?a = Entry⟧ ⟹ False›*)) qed hence "targetnode a ≠ Entry ∨ m' ≠ Exit" by simp from IH[OF ‹targetnode a -as→* m'› _ this] (*‹∀c∈set []. valid_edge c ⟹ ∃cs' es. CFGExit.valid_path_aux cs' es ∧ list_all2 (λc c'. c' = (Node (sourcenode c), kind c, Node (targetnode c))) [] cs' ∧ CFGExit.path (Node (targetnode a)) es (Node m')›*) obtain es where valid_path: "CFG.valid_path_aux knd (lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind) [] es" and path: "CFG.path src trg (lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit) (Node (targetnode a)) es (Node m')" (*goal: ‹(⋀es. ⟦CFGExit.valid_path_aux [] es; CFGExit.path (Node (targetnode a)) es (Node m')⟧ ⟹ thesis) ⟹ thesis›*) by auto from valid_path (*‹CFGExit.valid_path_aux [] es›*) ‹kind a = Q↩⇘p⇙f› (*‹(kind::'a ⇒ ('c, 'd, 'e, 'f) edge_kind) (a::'a) = Q::('c ⇒ 'd option) × 'e ⇒ bool↩⇘p::'f⇙f::('c ⇒ 'd option) ⇒ ('c ⇒ 'd option) ⇒ 'c ⇒ 'd option›*) have "CFG.valid_path_aux knd (lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind) [] (?e#es)" by simp moreover from path (*‹CFGExit.path (Node (targetnode a)) es (Node m')›*) ‹m = sourcenode a› (*‹m = sourcenode a›*) ‹lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit ?e› (*‹lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit (Node (sourcenode a), kind a, Node (targetnode a))›*) have "CFG.path src trg (lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit) (Node m) (?e#es) (Node m')" by (fastforce intro:CFGExit.Cons_path (*‹⟦CFGExit.path ?n'' ?as ?n'; lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit ?a; src ?a = ?n; trg ?a = ?n''⟧ ⟹ CFGExit.path ?n (?a # ?as) ?n'›*)) ultimately show "?case" (*goal: ‹∃cs' es. CFGExit.valid_path_aux cs' es ∧ list_all2 (λc c'. c' = (Node (sourcenode c), kind c, Node (targetnode c))) cs cs' ∧ CFGExit.path (Node m) es (Node m')›*) using ‹cs = []› (*‹cs = []›*) by blast next (*goal: ‹⋀cs a as Q p f c' cs' m. ⟦kind a = Q↩⇘p⇙f; cs = c' # cs'; valid_path_aux cs' as; a ∈ get_return_edges c'; ⋀m. ⟦m -as→* m'; Ball (set cs') valid_edge; m ≠ Entry ∨ m' ≠ Exit⟧ ⟹ ∃cs'a es. CFGExit.valid_path_aux cs'a es ∧ list_all2 (λc c'. c' = (Node (sourcenode c), kind c, Node (targetnode c))) cs' cs'a ∧ CFGExit.path (Node m) es (Node m'); m -a # as→* m'; Ball (set cs) valid_edge; m ≠ Entry ∨ m' ≠ Exit⟧ ⟹ ∃cs' es. CFGExit.valid_path_aux cs' es ∧ list_all2 (λc c'. c' = (Node (sourcenode c), kind c, Node (targetnode c))) cs cs' ∧ CFGExit.path (Node m) es (Node m')›*) case (vpa_ReturnCons cs a as Q p f c' cs') (*‹kind a = Q↩⇘p⇙f› ‹cs = c' # cs'› ‹valid_path_aux cs' as› ‹a ∈ get_return_edges c'› ‹⟦?m -as→* m'; ∀a∈set cs'. valid_edge a; ?m ≠ Entry ∨ m' ≠ Exit⟧ ⟹ ∃cs'a es. CFGExit.valid_path_aux cs'a es ∧ list_all2 (λc c'. c' = (Node (sourcenode c), kind c, Node (targetnode c))) cs' cs'a ∧ CFGExit.path (Node ?m) es (Node m')› ‹m -a # as→* m'› ‹∀a∈set cs. valid_edge a› ‹m ≠ Entry ∨ m' ≠ Exit›*) note IH = ‹⋀m. ⟦m -as→* m'; ∀c∈set cs'. valid_edge c; m ≠ Entry ∨ m' ≠ Exit⟧ ⟹ ∃csx es. CFG.valid_path_aux knd (lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind) csx es ∧ list_all2 (λc c'. c' = (Node (sourcenode c), kind c, Node (targetnode c))) cs' csx ∧ CFG.path src trg (lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit) (Node m) es (Node m')› (*‹⟦(?m::'b::type) -as::'a::type list→* m'::'b::type; ∀c::'a::type∈set (cs'::'a::type list). (valid_edge::'a::type ⇒ bool) c; ?m ≠ (Entry::'b::type) ∨ m' ≠ (Exit::'b::type)⟧ ⟹ ∃(csx::('b::type LDCFG_node × ('c::type, 'd::type, 'e::type, 'f::type) edge_kind × 'b::type LDCFG_node) list) es::('b::type LDCFG_node × ('c::type, 'd::type, 'e::type, 'f::type) edge_kind × 'b::type LDCFG_node) list. CFGExit.valid_path_aux csx es ∧ list_all2 (λ(c::'a::type) c'::'b::type LDCFG_node × ('c::type, 'd::type, 'e::type, 'f::type) edge_kind × 'b::type LDCFG_node. c' = (Node ((sourcenode::'a::type ⇒ 'b::type) c), (kind::'a::type ⇒ ('c::type, 'd::type, 'e::type, 'f::type) edge_kind) c, Node ((targetnode::'a::type ⇒ 'b::type) c))) cs' csx ∧ CFGExit.path (Node ?m) es (Node m')›*) from ‹m -a # as→* m'› (*‹m -a # as→* m'›*) have "m = sourcenode a" and "valid_edge a" and "targetnode a -as→* m'" apply - (*goals: 1. ‹m -a # as→* m' ⟹ m = sourcenode a› 2. ‹m -a # as→* m' ⟹ valid_edge a› 3. ‹m -a # as→* m' ⟹ targetnode a -as→* m'› discuss goal 1*) apply ((auto elim:path_split_Cons (*‹⟦?n -?as→* ?n'; ?as ≠ []; ⋀a' as'. ⟦?as = a' # as'; ?n = sourcenode a'; valid_edge a'; targetnode a' -as'→* ?n'⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*))[1]) (*discuss goal 2*) apply ((auto elim:path_split_Cons (*‹⟦?n -?as→* ?n'; ?as ≠ []; ⋀a' as'. ⟦?as = a' # as'; ?n = sourcenode a'; valid_edge a'; targetnode a' -as'→* ?n'⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*))[1]) (*discuss goal 3*) apply ((auto elim:path_split_Cons (*‹⟦?n -?as→* ?n'; ?as ≠ []; ⋀a' as'. ⟦?as = a' # as'; ?n = sourcenode a'; valid_edge a'; targetnode a' -as'→* ?n'⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*))[1]) (*proven 3 subgoals*) . from ‹∀c∈set cs. valid_edge c› (*‹∀c∈set cs. valid_edge c›*) ‹cs = c' # cs'› (*‹cs = c' # cs'›*) have "valid_edge c'" and "∀c∈set cs'. valid_edge c" apply - (*goals: 1. ‹⟦∀c::'a::type∈set (cs::'a::type list). (valid_edge::'a::type ⇒ bool) c; cs = (c'::'a::type) # (cs'::'a::type list)⟧ ⟹ valid_edge c'› 2. ‹⟦∀c::'a::type∈set (cs::'a::type list). (valid_edge::'a::type ⇒ bool) c; cs = (c'::'a::type) # (cs'::'a::type list)⟧ ⟹ ∀c::'a::type∈set cs'. valid_edge c› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) . let ?e = "(Node (sourcenode a),kind a,Node (targetnode a))" have "targetnode a ≠ Exit" proof (standard) (*goal: ‹targetnode a = Exit ⟹ False›*) assume "targetnode a = Exit" (*‹(targetnode::'a ⇒ 'b) (a::'a) = (Exit::'b)›*) with ‹valid_edge a› (*‹valid_edge a›*) ‹kind a = Q↩⇘p⇙f› (*‹kind a = Q↩⇘p⇙f›*) show False by (rule Exit_no_return_target (*‹⟦valid_edge ?a; kind ?a = ?Q↩⇘?p⇙?f; targetnode ?a = Exit⟧ ⟹ False›*)) qed with ‹valid_edge a› (*‹valid_edge a›*) have "lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit ?e" by (fastforce intro:lve_edge (*‹⟦(?valid_edge::?'edge ⇒ bool) (?a::?'edge); (?src::?'edge ⇒ ?'node) ?a ≠ (?E::?'node) ∨ (?trg::?'edge ⇒ ?'node) ?a ≠ (?X::?'node); (?e::?'node LDCFG_node × (?'var, ?'val, ?'ret, ?'pname) edge_kind × ?'node LDCFG_node) = (Node (?src ?a), (?knd::?'edge ⇒ (?'var, ?'val, ?'ret, ?'pname) edge_kind) ?a, Node (?trg ?a))⟧ ⟹ lift_valid_edge ?valid_edge ?src ?trg ?knd ?E ?X ?e›*)) have "targetnode a ≠ Entry" proof (standard) (*goal: ‹targetnode a = Entry ⟹ False›*) assume "targetnode a = Entry" (*‹(targetnode::'a ⇒ 'b) (a::'a) = (Entry::'b)›*) with ‹valid_edge a› (*‹valid_edge a›*) show False by (rule Entry_target (*‹⟦valid_edge ?a; targetnode ?a = Entry⟧ ⟹ False›*)) qed hence "targetnode a ≠ Entry ∨ m' ≠ Exit" by simp from IH[OF ‹targetnode a -as→* m'› ‹∀c∈set cs'. valid_edge c› this] (*‹∃csx es. CFGExit.valid_path_aux csx es ∧ list_all2 (λc c'. c' = (Node (sourcenode c), kind c, Node (targetnode c))) cs' csx ∧ CFGExit.path (Node (targetnode a)) es (Node m')›*) obtain csx and es where valid_path: "CFG.valid_path_aux knd (lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind) csx es" and list: "list_all2 (λc c'. c' = (Node (sourcenode c), kind c, Node (targetnode c))) cs' csx" and path: "CFG.path src trg (lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit) (Node (targetnode a)) es (Node m')" (*goal: ‹(⋀(csx::('b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node) list) es::('b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node) list. ⟦CFGExit.valid_path_aux csx es; list_all2 (λ(c::'a) c'::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node. c' = (Node ((sourcenode::'a ⇒ 'b) c), (kind::'a ⇒ ('c, 'd, 'e, 'f) edge_kind) c, Node ((targetnode::'a ⇒ 'b) c))) (cs'::'a list) csx; CFGExit.path (Node (targetnode (a::'a))) es (Node (m'::'b))⟧ ⟹ thesis::bool) ⟹ thesis›*) by blast from ‹valid_edge c'› (*‹valid_edge c'›*) ‹a ∈ get_return_edges c'› (*‹a ∈ get_return_edges c'›*) have "?e ∈ lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind (Node (sourcenode c'),kind c',Node (targetnode c'))" by (fastforce intro:lift_get_return_edgesI (*‹⟦?e = (Node (?src ?a), ?knd ?a, Node (?trg ?a)); ?valid_edge ?a; ?a' ∈ ?get_return_edges ?a; ?e' = (Node (?src ?a'), ?knd ?a', Node (?trg ?a'))⟧ ⟹ ?e' ∈ lift_get_return_edges ?get_return_edges ?valid_edge ?src ?trg ?knd ?e›*)) with valid_path (*‹CFGExit.valid_path_aux csx es›*) ‹kind a = Q↩⇘p⇙f› (*‹kind a = Q↩⇘p⇙f›*) have "CFG.valid_path_aux knd (lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind) ((Node (sourcenode c'),kind c',Node (targetnode c'))#csx) (?e#es)" by simp moreover from list (*‹list_all2 (λc c'. c' = (Node (sourcenode c), kind c, Node (targetnode c))) cs' csx›*) ‹cs = c' # cs'› (*‹cs = c' # cs'›*) have "list_all2 (λc c'. c' = (Node (sourcenode c), kind c, Node (targetnode c))) cs ((Node (sourcenode c'),kind c',Node (targetnode c'))#csx)" by simp moreover from path (*‹CFGExit.path (Node (targetnode a)) es (Node m')›*) ‹m = sourcenode a› (*‹m = sourcenode a›*) ‹lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit ?e› (*‹lift_valid_edge (valid_edge::'a ⇒ bool) (sourcenode::'a ⇒ 'b) (targetnode::'a ⇒ 'b) (kind::'a ⇒ ('c, 'd, 'e, 'f) edge_kind) (Entry::'b) (Exit::'b) (Node (sourcenode (a::'a)), kind a, Node (targetnode a))›*) have "CFG.path src trg (lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit) (Node m) (?e#es) (Node m')" by (fastforce intro:CFGExit.Cons_path (*‹⟦CFGExit.path ?n'' ?as ?n'; lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit ?a; src ?a = ?n; trg ?a = ?n''⟧ ⟹ CFGExit.path ?n (?a # ?as) ?n'›*)) ultimately show "?case" (*goal: ‹∃cs' es. CFGExit.valid_path_aux cs' es ∧ list_all2 (λc c'. c' = (Node (sourcenode c), kind c, Node (targetnode c))) cs cs' ∧ CFGExit.path (Node m) es (Node m')›*) using ‹kind a = Q↩⇘p⇙f› (*‹(kind::'a ⇒ ('c, 'd, 'e, 'f) edge_kind) (a::'a) = Q::('c ⇒ 'd option) × 'e ⇒ bool↩⇘p::'f⇙f::('c ⇒ 'd option) ⇒ ('c ⇒ 'd option) ⇒ 'c ⇒ 'd option›*) by blast qed } hence lift_valid_path: "⋀m as m'. ⟦m -as→⇩√* m'; m ≠ Entry ∨ m' ≠ Exit⟧ ⟹ ∃es. CFG.CFG.valid_path' src trg knd (lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit) (lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind) (Node m) es (Node m')" by (fastforce simp:vp_def (*‹?n -?as→⇩√* ?n' ≡ ?n -?as→* ?n' ∧ valid_path ?as›*) valid_path_def (*‹valid_path ?as ≡ valid_path_aux [] ?as›*) CFGExit.vp_def (*‹CFGExit.valid_path' ?n ?as ?n' ≡ CFGExit.path ?n ?as ?n' ∧ CFGExit.valid_path ?as›*) CFGExit.valid_path_def (*‹CFGExit.valid_path ?as ≡ CFGExit.valid_path_aux [] ?as›*)) show "?thesis" (*goal: ‹Postdomination src trg knd (lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit) NewEntry (lift_get_proc get_proc Main) (lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind) procs Main NewExit›*) proof (standard) (*goals: 1. ‹⋀n::'b::type LDCFG_node. CFGExit.valid_node n ⟹ ∃as::('b::type LDCFG_node × ('c::type, 'd::type, 'e::type, 'f::type) edge_kind × 'b::type LDCFG_node) list. CFGExit.valid_path' NewEntry as n› 2. ‹⋀n::'b::type LDCFG_node. CFGExit.valid_node n ⟹ ∃as::('b::type LDCFG_node × ('c::type, 'd::type, 'e::type, 'f::type) edge_kind × 'b::type LDCFG_node) list. CFGExit.valid_path' n as NewExit› 3. ‹⋀(n::'b::type LDCFG_node) n'::'b::type LDCFG_node. ⟦local.CFGExit.method_exit n; local.CFGExit.method_exit n'; lift_get_proc (get_proc::'b::type ⇒ 'f::type) (Main::'f::type) n = lift_get_proc get_proc Main n'⟧ ⟹ n = n'›*) fix n assume "CFG.CFG.valid_node src trg (lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit) n" (*‹CFGExit.valid_node (n::'b LDCFG_node)›*) hence "((n = NewEntry) ∨ n = NewExit) ∨ (∃m. n = Node m ∧ valid_node m)" by (auto elim:lift_valid_edge.cases (*‹⟦lift_valid_edge (?valid_edge::?'edge ⇒ bool) (?src::?'edge ⇒ ?'node) (?trg::?'edge ⇒ ?'node) (?knd::?'edge ⇒ (?'var, ?'val, ?'ret, ?'pname) edge_kind) (?E::?'node) (?X::?'node) (?a::?'node LDCFG_node × (?'var, ?'val, ?'ret, ?'pname) edge_kind × ?'node LDCFG_node); ⋀(a::?'edge) e::?'node LDCFG_node × (?'var, ?'val, ?'ret, ?'pname) edge_kind × ?'node LDCFG_node. ⟦?a = e; ?valid_edge a; ?src a ≠ ?E ∨ ?trg a ≠ ?X; e = (Node (?src a), ?knd a, Node (?trg a))⟧ ⟹ ?P::bool; ⋀e::?'node LDCFG_node × (?'var, ?'val, ?'ret, ?'pname) edge_kind × ?'node LDCFG_node. ⟦?a = e; e = (NewEntry, (λs::?'var ⇒ ?'val option. True)⇩√, Node ?E)⟧ ⟹ ?P; ⋀e::?'node LDCFG_node × (?'var, ?'val, ?'ret, ?'pname) edge_kind × ?'node LDCFG_node. ⟦?a = e; e = (Node ?X, (λs::?'var ⇒ ?'val option. True)⇩√, NewExit)⟧ ⟹ ?P; ⋀e::?'node LDCFG_node × (?'var, ?'val, ?'ret, ?'pname) edge_kind × ?'node LDCFG_node. ⟦?a = e; e = (NewEntry, (λs::?'var ⇒ ?'val option. False)⇩√, NewExit)⟧ ⟹ ?P⟧ ⟹ ?P›*) simp:CFGExit.valid_node_def (*‹CFGExit.valid_node (?n::'b LDCFG_node) ≡ ∃a::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node. lift_valid_edge (valid_edge::'a ⇒ bool) (sourcenode::'a ⇒ 'b) (targetnode::'a ⇒ 'b) (kind::'a ⇒ ('c, 'd, 'e, 'f) edge_kind) (Entry::'b) (Exit::'b) a ∧ (?n = src a ∨ ?n = trg a)›*)) thus "∃as. CFG.CFG.valid_path' src trg knd (lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit) (lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind) NewEntry as n" apply - (*goal: ‹∃as::('b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node) list. CFGExit.valid_path' NewEntry as (n::'b LDCFG_node)›*) proof ((erule disjE (*‹⟦?P ∨ ?Q; ?P ⟹ ?R; ?Q ⟹ ?R⟧ ⟹ ?R›*))+) (*goals: 1. ‹n = NewEntry ⟹ ∃as. CFGExit.valid_path' NewEntry as n› 2. ‹n = NewExit ⟹ ∃as. CFGExit.valid_path' NewEntry as n› 3. ‹∃m. n = Node m ∧ valid_node m ⟹ ∃as. CFGExit.valid_path' NewEntry as n›*) assume "n = NewEntry" (*‹(n::'b LDCFG_node) = NewEntry›*) hence "CFG.CFG.valid_path' src trg knd (lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit) (lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind) NewEntry [] n" by (fastforce intro:CFGExit.empty_path (*‹CFGExit.valid_node ?n ⟹ CFGExit.path ?n [] ?n›*) simp:CFGExit.vp_def (*‹CFGExit.valid_path' ?n ?as ?n' ≡ CFGExit.path ?n ?as ?n' ∧ CFGExit.valid_path ?as›*) CFGExit.valid_path_def (*‹CFGExit.valid_path ?as ≡ CFGExit.valid_path_aux [] ?as›*)) thus "?thesis" (*goal: ‹∃as. CFGExit.valid_path' NewEntry as n›*) by blast next (*goals: 1. ‹n = NewExit ⟹ ∃as. CFGExit.valid_path' NewEntry as n› 2. ‹∃m. n = Node m ∧ valid_node m ⟹ ∃as. CFGExit.valid_path' NewEntry as n›*) assume "n = NewExit" (*‹(n::'b LDCFG_node) = NewExit›*) have "lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit (NewEntry,(λs. False)⇩√,NewExit)" by (fastforce intro:lve_Entry_Exit_edge (*‹?e = (NewEntry, (λs. False)⇩√, NewExit) ⟹ lift_valid_edge ?valid_edge ?src ?trg ?knd ?E ?X ?e›*)) hence "CFG.CFG.path src trg (lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit) NewEntry [(NewEntry,(λs. False)⇩√,NewExit)] NewExit" by (fastforce dest:CFGExit.path_edge (*‹lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit ?a ⟹ CFGExit.path (src ?a) [?a] (trg ?a)›*)) with ‹n = NewExit› (*‹(n::'b LDCFG_node) = NewExit›*) have "CFG.CFG.valid_path' src trg knd (lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit) (lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind) NewEntry [(NewEntry,(λs. False)⇩√,NewExit)] n" by (fastforce simp:CFGExit.vp_def (*‹CFGExit.valid_path' ?n ?as ?n' ≡ CFGExit.path ?n ?as ?n' ∧ CFGExit.valid_path ?as›*) CFGExit.valid_path_def (*‹CFGExit.valid_path ?as ≡ CFGExit.valid_path_aux [] ?as›*)) thus "?thesis" (*goal: ‹∃as. CFGExit.valid_path' NewEntry as n›*) by blast next (*goal: ‹∃m. n = Node m ∧ valid_node m ⟹ ∃as. CFGExit.valid_path' NewEntry as n›*) assume "∃m. n = Node m ∧ valid_node m" (*‹∃m::'b. (n::'b LDCFG_node) = Node m ∧ valid_node m›*) then obtain m where "n = Node m" and "valid_node m" (*goal: ‹(⋀m. ⟦n = Node m; valid_node m⟧ ⟹ thesis) ⟹ thesis›*) by blast from ‹valid_node m› (*‹valid_node (m::'b)›*) show "?thesis" (*goal: ‹∃as::('b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node) list. CFGExit.valid_path' NewEntry as (n::'b LDCFG_node)›*) proof (cases m rule:valid_node_cases (*‹⟦valid_node ?n; ?n = Entry ⟹ ?Q; ?n = Exit ⟹ ?Q; inner_node ?n ⟹ ?Q⟧ ⟹ ?Q›*)) (*goals: 1. ‹m = Entry ⟹ ∃as. CFGExit.valid_path' NewEntry as n› 2. ‹m = Exit ⟹ ∃as. CFGExit.valid_path' NewEntry as n› 3. ‹inner_node m ⟹ ∃as. CFGExit.valid_path' NewEntry as n›*) case Entry (*‹(m::'b::type) = (Entry::'b::type)›*) have "lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit (NewEntry,(λs. True)⇩√,Node Entry)" by (fastforce intro:lve_Entry_edge (*‹(?e::?'node LDCFG_node × (?'var, ?'val, ?'ret, ?'pname) edge_kind × ?'node LDCFG_node) = (NewEntry, (λs::?'var ⇒ ?'val option. True)⇩√, Node (?E::?'node)) ⟹ lift_valid_edge (?valid_edge::?'edge ⇒ bool) (?src::?'edge ⇒ ?'node) (?trg::?'edge ⇒ ?'node) (?knd::?'edge ⇒ (?'var, ?'val, ?'ret, ?'pname) edge_kind) ?E (?X::?'node) ?e›*)) with ‹m = Entry› (*‹m = Entry›*) ‹n = Node m› (*‹n = Node m›*) have "CFG.CFG.path src trg (lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit) NewEntry [(NewEntry,(λs. True)⇩√,Node Entry)] n" by (fastforce intro:CFGExit.Cons_path (*‹⟦CFGExit.path ?n'' ?as ?n'; lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit ?a; src ?a = ?n; trg ?a = ?n''⟧ ⟹ CFGExit.path ?n (?a # ?as) ?n'›*) CFGExit.empty_path (*‹CFGExit.valid_node ?n ⟹ CFGExit.path ?n [] ?n›*) simp:CFGExit.valid_node_def (*‹CFGExit.valid_node ?n ≡ ∃a. lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a ∧ (?n = src a ∨ ?n = trg a)›*)) thus "?thesis" (*goal: ‹∃as::('b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node) list. CFGExit.valid_path' NewEntry as (n::'b LDCFG_node)›*) by (fastforce simp:CFGExit.vp_def (*‹CFGExit.valid_path' ?n ?as ?n' ≡ CFGExit.path ?n ?as ?n' ∧ CFGExit.valid_path ?as›*) CFGExit.valid_path_def (*‹CFGExit.valid_path ?as ≡ CFGExit.valid_path_aux [] ?as›*)) next (*goals: 1. ‹m = Exit ⟹ ∃as. CFGExit.valid_path' NewEntry as n› 2. ‹inner_node m ⟹ ∃as. CFGExit.valid_path' NewEntry as n›*) case Exit (*‹m = Exit›*) from inner (*‹inner_node nx›*) obtain ax where "valid_edge ax" and "intra_kind (kind ax)" and "inner_node (sourcenode ax)" and "targetnode ax = Exit" (*goal: ‹(⋀ax. ⟦valid_edge ax; intra_kind (kind ax); inner_node (sourcenode ax); targetnode ax = Exit⟧ ⟹ thesis) ⟹ thesis›*) by (erule inner_node_Exit_edge (*‹⟦inner_node ?n; ⋀a. ⟦valid_edge a; intra_kind (kind a); inner_node (sourcenode a); targetnode a = Exit⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*)) hence "lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit (Node (sourcenode ax),kind ax,Node Exit)" by (auto intro:lift_valid_edge.lve_edge (*‹⟦?valid_edge ?a; ?src ?a ≠ ?E ∨ ?trg ?a ≠ ?X; ?e = (Node (?src ?a), ?knd ?a, Node (?trg ?a))⟧ ⟹ lift_valid_edge ?valid_edge ?src ?trg ?knd ?E ?X ?e›*) simp:inner_node_def (*‹inner_node ?n ≡ valid_node ?n ∧ ?n ≠ Entry ∧ ?n ≠ Exit›*)) hence "CFG.path src trg (lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit) (Node (sourcenode ax)) [(Node (sourcenode ax),kind ax,Node Exit)] (Node Exit)" by (fastforce intro:CFGExit.Cons_path (*‹⟦CFGExit.path (?n''::'b::type LDCFG_node) (?as::('b::type LDCFG_node × ('c::type, 'd::type, 'e::type, 'f::type) edge_kind × 'b::type LDCFG_node) list) (?n'::'b::type LDCFG_node); lift_valid_edge (valid_edge::'a::type ⇒ bool) (sourcenode::'a::type ⇒ 'b::type) (targetnode::'a::type ⇒ 'b::type) (kind::'a::type ⇒ ('c::type, 'd::type, 'e::type, 'f::type) edge_kind) (Entry::'b::type) (Exit::'b::type) (?a::'b::type LDCFG_node × ('c::type, 'd::type, 'e::type, 'f::type) edge_kind × 'b::type LDCFG_node); src ?a = (?n::'b::type LDCFG_node); trg ?a = ?n''⟧ ⟹ CFGExit.path ?n (?a # ?as) ?n'›*) CFGExit.empty_path (*‹CFGExit.valid_node (?n::'b::type LDCFG_node) ⟹ CFGExit.path ?n [] ?n›*) simp:CFGExit.valid_node_def (*‹CFGExit.valid_node (?n::'b::type LDCFG_node) ≡ ∃a::'b::type LDCFG_node × ('c::type, 'd::type, 'e::type, 'f::type) edge_kind × 'b::type LDCFG_node. lift_valid_edge (valid_edge::'a::type ⇒ bool) (sourcenode::'a::type ⇒ 'b::type) (targetnode::'a::type ⇒ 'b::type) (kind::'a::type ⇒ ('c::type, 'd::type, 'e::type, 'f::type) edge_kind) (Entry::'b::type) (Exit::'b::type) a ∧ (?n = src a ∨ ?n = trg a)›*)) with ‹intra_kind (kind ax)› (*‹intra_kind (kind ax)›*) have slp_edge: "CFG.CFG.same_level_path' src trg knd (lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit) (lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind) (Node (sourcenode ax)) [(Node (sourcenode ax),kind ax,Node Exit)] (Node Exit)" by (fastforce simp:CFGExit.slp_def (*‹CFGExit.same_level_path' ?n ?as ?n' ≡ CFGExit.path ?n ?as ?n' ∧ CFGExit.same_level_path ?as›*) CFGExit.same_level_path_def (*‹CFGExit.same_level_path ?as ≡ CFGExit.same_level_path_aux [] ?as ∧ CFGExit.upd_cs [] ?as = []›*) intra_kind_def (*‹intra_kind ?et ≡ (∃f. ?et = ⇑f) ∨ (∃Q. ?et = (Q)⇩√)›*)) have "sourcenode ax ≠ Exit" proof (standard) (*goal: ‹sourcenode ax = Exit ⟹ False›*) assume "sourcenode ax = Exit" (*‹(sourcenode::'a ⇒ 'b) (ax::'a) = (Exit::'b)›*) with ‹valid_edge ax› (*‹(valid_edge::'a ⇒ bool) (ax::'a)›*) show False by (rule Exit_source (*‹⟦valid_edge ?a; sourcenode ?a = Exit⟧ ⟹ False›*)) qed have "lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit (NewEntry,(λs. True)⇩√,Node Entry)" by (fastforce intro:lve_Entry_edge (*‹?e = (NewEntry, (λs. True)⇩√, Node ?E) ⟹ lift_valid_edge ?valid_edge ?src ?trg ?knd ?E ?X ?e›*)) hence "CFG.path src trg (lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit) (NewEntry) [(NewEntry,(λs. True)⇩√,Node Entry)] (Node Entry)" by (fastforce intro:CFGExit.Cons_path (*‹⟦CFGExit.path ?n'' ?as ?n'; lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit ?a; src ?a = ?n; trg ?a = ?n''⟧ ⟹ CFGExit.path ?n (?a # ?as) ?n'›*) CFGExit.empty_path (*‹CFGExit.valid_node ?n ⟹ CFGExit.path ?n [] ?n›*) simp:CFGExit.valid_node_def (*‹CFGExit.valid_node ?n ≡ ∃a. lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a ∧ (?n = src a ∨ ?n = trg a)›*)) hence slp_edge': "CFG.CFG.same_level_path' src trg knd (lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit) (lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind) (NewEntry) [(NewEntry,(λs. True)⇩√,Node Entry)] (Node Entry)" by (fastforce simp:CFGExit.slp_def (*‹CFGExit.same_level_path' ?n ?as ?n' ≡ CFGExit.path ?n ?as ?n' ∧ CFGExit.same_level_path ?as›*) CFGExit.same_level_path_def (*‹CFGExit.same_level_path ?as ≡ CFGExit.same_level_path_aux [] ?as ∧ CFGExit.upd_cs [] ?as = []›*)) from ‹inner_node (sourcenode ax)› (*‹inner_node (sourcenode ax)›*) have "valid_node (sourcenode ax)" by (rule inner_is_valid (*‹inner_node ?n ⟹ valid_node ?n›*)) then obtain asx where "Entry -asx→⇩√* sourcenode ax" (*goal: ‹(⋀asx. Entry -asx→⇩√* sourcenode ax ⟹ thesis) ⟹ thesis›*) by (fastforce dest:Entry_path (*‹valid_node (?n::'b) ⟹ ∃as::'a list. (Entry::'b) -as→⇩√* ?n›*)) with ‹sourcenode ax ≠ Exit› (*‹sourcenode ax ≠ Exit›*) have "∃es. CFG.CFG.valid_path' src trg knd (lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit) (lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind) (Node Entry) es (Node (sourcenode ax))" by (fastforce intro:lift_valid_path (*‹⟦?m -?as→⇩√* ?m'; ?m ≠ Entry ∨ ?m' ≠ Exit⟧ ⟹ ∃es. CFGExit.valid_path' (Node ?m) es (Node ?m')›*)) then obtain es where "CFG.CFG.valid_path' src trg knd (lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit) (lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind) (Node Entry) es (Node (sourcenode ax))" (*goal: ‹(⋀es. CFGExit.valid_path' (Node Entry) es (Node (sourcenode ax)) ⟹ thesis) ⟹ thesis›*) by blast with slp_edge (*‹CFGExit.same_level_path' (Node (sourcenode ax)) [(Node (sourcenode ax), kind ax, Node Exit)] (Node Exit)›*) have "CFG.CFG.valid_path' src trg knd (lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit) (lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind) (Node Entry) (es@[(Node (sourcenode ax),kind ax,Node Exit)]) (Node Exit)" apply - (*goal: ‹CFGExit.valid_path' (Node (Entry::'b)) ((es::('b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node) list) @ [(Node ((sourcenode::'a ⇒ 'b) (ax::'a)), (kind::'a ⇒ ('c, 'd, 'e, 'f) edge_kind) ax, Node (Exit::'b))]) (Node Exit)›*) apply (rule CFGExit.vp_slp_Append (*‹⟦CFGExit.valid_path' ?n ?as ?n''; CFGExit.same_level_path' ?n'' ?as' ?n'⟧ ⟹ CFGExit.valid_path' ?n (?as @ ?as') ?n'›*)) (*goals: 1. ‹⟦CFGExit.same_level_path' (Node (sourcenode ax)) [(Node (sourcenode ax), kind ax, Node Exit)] (Node Exit); CFGExit.valid_path' (Node Entry) es (Node (sourcenode ax))⟧ ⟹ CFGExit.valid_path' (Node Entry) es ?n''2› 2. ‹⟦CFGExit.same_level_path' (Node (sourcenode ax)) [(Node (sourcenode ax), kind ax, Node Exit)] (Node Exit); CFGExit.valid_path' (Node Entry) es (Node (sourcenode ax))⟧ ⟹ CFGExit.same_level_path' ?n''2 [(Node (sourcenode ax), kind ax, Node Exit)] (Node Exit)› discuss goal 1*) apply ((assumption)[1]) (*discuss goal 2*) . (*proven 2 subgoals*) with slp_edge' (*‹CFGExit.same_level_path' NewEntry [(NewEntry, (λs::'c::type ⇒ 'd::type option. True)⇩√, Node (Entry::'b::type))] (Node Entry)›*) have "CFG.CFG.valid_path' src trg knd (lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit) (lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind) NewEntry ([(NewEntry,(λs. True)⇩√,Node Entry)]@ (es@[(Node (sourcenode ax),kind ax,Node Exit)])) (Node Exit)" by (rule CFGExit.slp_vp_Append (*‹⟦CFGExit.same_level_path' ?n ?as ?n''; CFGExit.valid_path' ?n'' ?as' ?n'⟧ ⟹ CFGExit.valid_path' ?n (?as @ ?as') ?n'›*)) with ‹m = Exit› (*‹m = Exit›*) ‹n = Node m› (*‹n = Node m›*) show "?thesis" (*goal: ‹∃as. CFGExit.valid_path' NewEntry as n›*) apply simp (*goal: ‹∃as. CFGExit.valid_path' NewEntry as n›*) by blast next (*goal: ‹inner_node (m::'b) ⟹ ∃as::('b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node) list. CFGExit.valid_path' NewEntry as (n::'b LDCFG_node)›*) case inner (*‹inner_node m›*) have "lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit (NewEntry,(λs. True)⇩√,Node Entry)" by (fastforce intro:lve_Entry_edge (*‹?e = (NewEntry, (λs. True)⇩√, Node ?E) ⟹ lift_valid_edge ?valid_edge ?src ?trg ?knd ?E ?X ?e›*)) hence "CFG.path src trg (lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit) (NewEntry) [(NewEntry,(λs. True)⇩√,Node Entry)] (Node Entry)" by (fastforce intro:CFGExit.Cons_path (*‹⟦CFGExit.path ?n'' ?as ?n'; lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit ?a; src ?a = ?n; trg ?a = ?n''⟧ ⟹ CFGExit.path ?n (?a # ?as) ?n'›*) CFGExit.empty_path (*‹CFGExit.valid_node ?n ⟹ CFGExit.path ?n [] ?n›*) simp:CFGExit.valid_node_def (*‹CFGExit.valid_node ?n ≡ ∃a. lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a ∧ (?n = src a ∨ ?n = trg a)›*)) hence slp_edge: "CFG.CFG.same_level_path' src trg knd (lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit) (lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind) (NewEntry) [(NewEntry,(λs. True)⇩√,Node Entry)] (Node Entry)" by (fastforce simp:CFGExit.slp_def (*‹CFGExit.same_level_path' ?n ?as ?n' ≡ CFGExit.path ?n ?as ?n' ∧ CFGExit.same_level_path ?as›*) CFGExit.same_level_path_def (*‹CFGExit.same_level_path ?as ≡ CFGExit.same_level_path_aux [] ?as ∧ CFGExit.upd_cs [] ?as = []›*)) from ‹valid_node m› (*‹valid_node (m::'b::type)›*) obtain as where "Entry -as→⇩√* m" (*goal: ‹(⋀as::'a list. (Entry::'b) -as→⇩√* m::'b ⟹ thesis::bool) ⟹ thesis›*) by (fastforce dest:Entry_path (*‹valid_node ?n ⟹ ∃as. Entry -as→⇩√* ?n›*)) with ‹inner_node m› (*‹inner_node m›*) have "∃es. CFG.CFG.valid_path' src trg knd (lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit) (lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind) (Node Entry) es (Node m)" by (fastforce intro:lift_valid_path (*‹⟦?m -?as→⇩√* ?m'; ?m ≠ Entry ∨ ?m' ≠ Exit⟧ ⟹ ∃es. CFGExit.valid_path' (Node ?m) es (Node ?m')›*) simp:inner_node_def (*‹inner_node ?n ≡ valid_node ?n ∧ ?n ≠ Entry ∧ ?n ≠ Exit›*)) then obtain es where "CFG.CFG.valid_path' src trg knd (lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit) (lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind) (Node Entry) es (Node m)" (*goal: ‹(⋀es. CFGExit.valid_path' (Node Entry) es (Node m) ⟹ thesis) ⟹ thesis›*) by blast with slp_edge (*‹CFGExit.same_level_path' NewEntry [(NewEntry, (λs. True)⇩√, Node Entry)] (Node Entry)›*) have "CFG.CFG.valid_path' src trg knd (lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit) (lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind) NewEntry ([(NewEntry,(λs. True)⇩√,Node Entry)]@es) (Node m)" by (rule CFGExit.slp_vp_Append (*‹⟦CFGExit.same_level_path' ?n ?as ?n''; CFGExit.valid_path' ?n'' ?as' ?n'⟧ ⟹ CFGExit.valid_path' ?n (?as @ ?as') ?n'›*)) with ‹n = Node m› (*‹n = Node m›*) show "?thesis" (*goal: ‹∃as::('b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node) list. CFGExit.valid_path' NewEntry as (n::'b LDCFG_node)›*) apply simp (*goal: ‹∃as. CFGExit.valid_path' NewEntry as n›*) by blast qed qed next (*goals: 1. ‹⋀n. CFGExit.valid_node n ⟹ ∃as. CFGExit.valid_path' n as NewExit› 2. ‹⋀n n'. ⟦local.CFGExit.method_exit n; local.CFGExit.method_exit n'; lift_get_proc get_proc Main n = lift_get_proc get_proc Main n'⟧ ⟹ n = n'›*) fix n assume "CFG.CFG.valid_node src trg (lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit) n" (*‹CFGExit.valid_node (n::'b LDCFG_node)›*) hence "((n = NewEntry) ∨ n = NewExit) ∨ (∃m. n = Node m ∧ valid_node m)" by (auto elim:lift_valid_edge.cases (*‹⟦lift_valid_edge ?valid_edge ?src ?trg ?knd ?E ?X ?a; ⋀a e. ⟦?a = e; ?valid_edge a; ?src a ≠ ?E ∨ ?trg a ≠ ?X; e = (Node (?src a), ?knd a, Node (?trg a))⟧ ⟹ ?P; ⋀e. ⟦?a = e; e = (NewEntry, (λs. True)⇩√, Node ?E)⟧ ⟹ ?P; ⋀e. ⟦?a = e; e = (Node ?X, (λs. True)⇩√, NewExit)⟧ ⟹ ?P; ⋀e. ⟦?a = e; e = (NewEntry, (λs. False)⇩√, NewExit)⟧ ⟹ ?P⟧ ⟹ ?P›*) simp:CFGExit.valid_node_def (*‹CFGExit.valid_node ?n ≡ ∃a. lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a ∧ (?n = src a ∨ ?n = trg a)›*)) thus "∃as. CFG.CFG.valid_path' src trg knd (lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit) (lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind) n as NewExit" apply - (*goal: ‹∃as. CFGExit.valid_path' n as NewExit›*) proof ((erule disjE (*‹⟦(?P::bool) ∨ (?Q::bool); ?P ⟹ ?R::bool; ?Q ⟹ ?R⟧ ⟹ ?R›*))+) (*goals: 1. ‹n = NewEntry ⟹ ∃as. CFGExit.valid_path' n as NewExit› 2. ‹n = NewExit ⟹ ∃as. CFGExit.valid_path' n as NewExit› 3. ‹∃m. n = Node m ∧ valid_node m ⟹ ∃as. CFGExit.valid_path' n as NewExit›*) assume "n = NewEntry" (*‹(n::'b LDCFG_node) = NewEntry›*) have "lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit (NewEntry,(λs. False)⇩√,NewExit)" by (fastforce intro:lve_Entry_Exit_edge (*‹?e = (NewEntry, (λs. False)⇩√, NewExit) ⟹ lift_valid_edge ?valid_edge ?src ?trg ?knd ?E ?X ?e›*)) hence "CFG.CFG.path src trg (lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit) NewEntry [(NewEntry,(λs. False)⇩√,NewExit)] NewExit" by (fastforce dest:CFGExit.path_edge (*‹lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit ?a ⟹ CFGExit.path (src ?a) [?a] (trg ?a)›*)) with ‹n = NewEntry› (*‹n = NewEntry›*) have "CFG.CFG.valid_path' src trg knd (lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit) (lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind) n [(NewEntry,(λs. False)⇩√,NewExit)] NewExit" by (fastforce simp:CFGExit.vp_def (*‹CFGExit.valid_path' ?n ?as ?n' ≡ CFGExit.path ?n ?as ?n' ∧ CFGExit.valid_path ?as›*) CFGExit.valid_path_def (*‹CFGExit.valid_path ?as ≡ CFGExit.valid_path_aux [] ?as›*)) thus "?thesis" (*goal: ‹∃as. CFGExit.valid_path' n as NewExit›*) by blast next (*goals: 1. ‹n = NewExit ⟹ ∃as. CFGExit.valid_path' n as NewExit› 2. ‹∃m. n = Node m ∧ valid_node m ⟹ ∃as. CFGExit.valid_path' n as NewExit›*) assume "n = NewExit" (*‹(n::'b LDCFG_node) = NewExit›*) hence "CFG.CFG.valid_path' src trg knd (lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit) (lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind) n [] NewExit" by (fastforce intro:CFGExit.empty_path (*‹CFGExit.valid_node ?n ⟹ CFGExit.path ?n [] ?n›*) simp:CFGExit.vp_def (*‹CFGExit.valid_path' ?n ?as ?n' ≡ CFGExit.path ?n ?as ?n' ∧ CFGExit.valid_path ?as›*) CFGExit.valid_path_def (*‹CFGExit.valid_path ?as ≡ CFGExit.valid_path_aux [] ?as›*)) thus "?thesis" (*goal: ‹∃as::('b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node) list. CFGExit.valid_path' (n::'b LDCFG_node) as NewExit›*) by blast next (*goal: ‹∃m. n = Node m ∧ valid_node m ⟹ ∃as. CFGExit.valid_path' n as NewExit›*) assume "∃m. n = Node m ∧ valid_node m" (*‹∃m::'b. (n::'b LDCFG_node) = Node m ∧ valid_node m›*) then obtain m where "n = Node m" and "valid_node m" (*goal: ‹(⋀m. ⟦n = Node m; valid_node m⟧ ⟹ thesis) ⟹ thesis›*) by blast from ‹valid_node m› (*‹valid_node m›*) show "?thesis" (*goal: ‹∃as. CFGExit.valid_path' n as NewExit›*) proof (cases m rule:valid_node_cases (*‹⟦valid_node (?n::'b); ?n = (Entry::'b) ⟹ ?Q::bool; ?n = (Exit::'b) ⟹ ?Q; inner_node ?n ⟹ ?Q⟧ ⟹ ?Q›*)) (*goals: 1. ‹m = Entry ⟹ ∃as. CFGExit.valid_path' n as NewExit› 2. ‹m = Exit ⟹ ∃as. CFGExit.valid_path' n as NewExit› 3. ‹inner_node m ⟹ ∃as. CFGExit.valid_path' n as NewExit›*) case Entry (*‹m = Entry›*) from inner (*‹inner_node (nx::'b::type)›*) obtain ax where "valid_edge ax" and "intra_kind (kind ax)" and "inner_node (targetnode ax)" and "sourcenode ax = Entry" (*goal: ‹(⋀ax::'a. ⟦(valid_edge::'a ⇒ bool) ax; intra_kind ((kind::'a ⇒ ('c, 'd, 'e, 'f) edge_kind) ax); inner_node ((targetnode::'a ⇒ 'b) ax); (sourcenode::'a ⇒ 'b) ax = (Entry::'b)⟧ ⟹ thesis::bool) ⟹ thesis›*) by (erule inner_node_Entry_edge (*‹⟦inner_node (?n::'b::type); ⋀a::'a::type. ⟦(valid_edge::'a::type ⇒ bool) a; intra_kind ((kind::'a::type ⇒ ('c::type, 'd::type, 'e::type, 'f::type) edge_kind) a); inner_node ((targetnode::'a::type ⇒ 'b::type) a); (sourcenode::'a::type ⇒ 'b::type) a = (Entry::'b::type)⟧ ⟹ ?thesis::bool⟧ ⟹ ?thesis›*)) hence "lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit (Node Entry,kind ax,Node (targetnode ax))" by (auto intro:lift_valid_edge.lve_edge (*‹⟦?valid_edge ?a; ?src ?a ≠ ?E ∨ ?trg ?a ≠ ?X; ?e = (Node (?src ?a), ?knd ?a, Node (?trg ?a))⟧ ⟹ lift_valid_edge ?valid_edge ?src ?trg ?knd ?E ?X ?e›*) simp:inner_node_def (*‹inner_node ?n ≡ valid_node ?n ∧ ?n ≠ Entry ∧ ?n ≠ Exit›*)) hence "CFG.path src trg (lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit) (Node Entry) [(Node Entry,kind ax,Node (targetnode ax))] (Node (targetnode ax))" by (fastforce intro:CFGExit.Cons_path (*‹⟦CFGExit.path (?n''::'b LDCFG_node) (?as::('b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node) list) (?n'::'b LDCFG_node); lift_valid_edge (valid_edge::'a ⇒ bool) (sourcenode::'a ⇒ 'b) (targetnode::'a ⇒ 'b) (kind::'a ⇒ ('c, 'd, 'e, 'f) edge_kind) (Entry::'b) (Exit::'b) (?a::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node); src ?a = (?n::'b LDCFG_node); trg ?a = ?n''⟧ ⟹ CFGExit.path ?n (?a # ?as) ?n'›*) CFGExit.empty_path (*‹CFGExit.valid_node (?n::'b LDCFG_node) ⟹ CFGExit.path ?n [] ?n›*) simp:CFGExit.valid_node_def (*‹CFGExit.valid_node (?n::'b LDCFG_node) ≡ ∃a::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node. lift_valid_edge (valid_edge::'a ⇒ bool) (sourcenode::'a ⇒ 'b) (targetnode::'a ⇒ 'b) (kind::'a ⇒ ('c, 'd, 'e, 'f) edge_kind) (Entry::'b) (Exit::'b) a ∧ (?n = src a ∨ ?n = trg a)›*)) with ‹intra_kind (kind ax)› (*‹intra_kind (kind ax)›*) have slp_edge: "CFG.CFG.same_level_path' src trg knd (lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit) (lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind) (Node Entry) [(Node Entry,kind ax,Node (targetnode ax))] (Node (targetnode ax))" by (fastforce simp:CFGExit.slp_def (*‹CFGExit.same_level_path' ?n ?as ?n' ≡ CFGExit.path ?n ?as ?n' ∧ CFGExit.same_level_path ?as›*) CFGExit.same_level_path_def (*‹CFGExit.same_level_path ?as ≡ CFGExit.same_level_path_aux [] ?as ∧ CFGExit.upd_cs [] ?as = []›*) intra_kind_def (*‹intra_kind ?et ≡ (∃f. ?et = ⇑f) ∨ (∃Q. ?et = (Q)⇩√)›*)) have "targetnode ax ≠ Entry" proof (standard) (*goal: ‹targetnode ax = Entry ⟹ False›*) assume "targetnode ax = Entry" (*‹(targetnode::'a ⇒ 'b) (ax::'a) = (Entry::'b)›*) with ‹valid_edge ax› (*‹valid_edge ax›*) show False by (rule Entry_target (*‹⟦valid_edge ?a; targetnode ?a = Entry⟧ ⟹ False›*)) qed have "lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit (Node Exit,(λs. True)⇩√,NewExit)" by (fastforce intro:lve_Exit_edge (*‹?e = (Node ?X, (λs. True)⇩√, NewExit) ⟹ lift_valid_edge ?valid_edge ?src ?trg ?knd ?E ?X ?e›*)) hence "CFG.path src trg (lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit) (Node Exit) [(Node Exit,(λs. True)⇩√,NewExit)] NewExit" by (fastforce intro:CFGExit.Cons_path (*‹⟦CFGExit.path (?n''::'b LDCFG_node) (?as::('b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node) list) (?n'::'b LDCFG_node); lift_valid_edge (valid_edge::'a ⇒ bool) (sourcenode::'a ⇒ 'b) (targetnode::'a ⇒ 'b) (kind::'a ⇒ ('c, 'd, 'e, 'f) edge_kind) (Entry::'b) (Exit::'b) (?a::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node); src ?a = (?n::'b LDCFG_node); trg ?a = ?n''⟧ ⟹ CFGExit.path ?n (?a # ?as) ?n'›*) CFGExit.empty_path (*‹CFGExit.valid_node (?n::'b LDCFG_node) ⟹ CFGExit.path ?n [] ?n›*) simp:CFGExit.valid_node_def (*‹CFGExit.valid_node (?n::'b LDCFG_node) ≡ ∃a::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node. lift_valid_edge (valid_edge::'a ⇒ bool) (sourcenode::'a ⇒ 'b) (targetnode::'a ⇒ 'b) (kind::'a ⇒ ('c, 'd, 'e, 'f) edge_kind) (Entry::'b) (Exit::'b) a ∧ (?n = src a ∨ ?n = trg a)›*)) hence slp_edge': "CFG.CFG.same_level_path' src trg knd (lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit) (lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind) (Node Exit) [(Node Exit,(λs. True)⇩√,NewExit)] NewExit" by (fastforce simp:CFGExit.slp_def (*‹CFGExit.same_level_path' ?n ?as ?n' ≡ CFGExit.path ?n ?as ?n' ∧ CFGExit.same_level_path ?as›*) CFGExit.same_level_path_def (*‹CFGExit.same_level_path ?as ≡ CFGExit.same_level_path_aux [] ?as ∧ CFGExit.upd_cs [] ?as = []›*)) from ‹inner_node (targetnode ax)› (*‹inner_node (targetnode ax)›*) have "valid_node (targetnode ax)" by (rule inner_is_valid (*‹inner_node ?n ⟹ valid_node ?n›*)) then obtain asx where "targetnode ax -asx→⇩√* Exit" (*goal: ‹(⋀asx. targetnode ax -asx→⇩√* Exit ⟹ thesis) ⟹ thesis›*) by (fastforce dest:Exit_path (*‹valid_node (?n::'b) ⟹ ∃as::'a list. ?n -as→⇩√* Exit::'b›*)) with ‹targetnode ax ≠ Entry› (*‹targetnode ax ≠ Entry›*) have "∃es. CFG.CFG.valid_path' src trg knd (lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit) (lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind) (Node (targetnode ax)) es (Node Exit)" by (fastforce intro:lift_valid_path (*‹⟦?m -?as→⇩√* ?m'; ?m ≠ Entry ∨ ?m' ≠ Exit⟧ ⟹ ∃es. CFGExit.valid_path' (Node ?m) es (Node ?m')›*)) then obtain es where "CFG.CFG.valid_path' src trg knd (lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit) (lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind) (Node (targetnode ax)) es (Node Exit)" (*goal: ‹(⋀es::('b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node) list. CFGExit.valid_path' (Node ((targetnode::'a ⇒ 'b) (ax::'a))) es (Node (Exit::'b)) ⟹ thesis::bool) ⟹ thesis›*) by blast with slp_edge (*‹CFGExit.same_level_path' (Node Entry) [(Node Entry, kind ax, Node (targetnode ax))] (Node (targetnode ax))›*) have "CFG.CFG.valid_path' src trg knd (lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit) (lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind) (Node Entry) ([(Node Entry,kind ax,Node (targetnode ax))]@es) (Node Exit)" by (rule CFGExit.slp_vp_Append (*‹⟦CFGExit.same_level_path' (?n::'b LDCFG_node) (?as::('b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node) list) (?n''::'b LDCFG_node); CFGExit.valid_path' ?n'' (?as'::('b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node) list) (?n'::'b LDCFG_node)⟧ ⟹ CFGExit.valid_path' ?n (?as @ ?as') ?n'›*)) with slp_edge' (*‹CFGExit.same_level_path' (Node (Exit::'b)) [(Node Exit, (λs::'c ⇒ 'd option. True)⇩√, NewExit)] NewExit›*) have "CFG.CFG.valid_path' src trg knd (lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit) (lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind) (Node Entry) (([(Node Entry,kind ax,Node (targetnode ax))]@es)@ [(Node Exit,(λs. True)⇩√,NewExit)]) NewExit" apply - (*goal: ‹CFGExit.valid_path' (Node Entry) (([(Node Entry, kind ax, Node (targetnode ax))] @ es) @ [(Node Exit, (λs. True)⇩√, NewExit)]) NewExit›*) apply (rule CFGExit.vp_slp_Append (*‹⟦CFGExit.valid_path' ?n ?as ?n''; CFGExit.same_level_path' ?n'' ?as' ?n'⟧ ⟹ CFGExit.valid_path' ?n (?as @ ?as') ?n'›*)) (*goals: 1. ‹⟦CFGExit.same_level_path' (Node Exit) [(Node Exit, (λs. True)⇩√, NewExit)] NewExit; CFGExit.valid_path' (Node Entry) ([(Node Entry, kind ax, Node (targetnode ax))] @ es) (Node Exit)⟧ ⟹ CFGExit.valid_path' (Node Entry) ([(Node Entry, kind ax, Node (targetnode ax))] @ es) ?n''2› 2. ‹⟦CFGExit.same_level_path' (Node Exit) [(Node Exit, (λs. True)⇩√, NewExit)] NewExit; CFGExit.valid_path' (Node Entry) ([(Node Entry, kind ax, Node (targetnode ax))] @ es) (Node Exit)⟧ ⟹ CFGExit.same_level_path' ?n''2 [(Node Exit, (λs. True)⇩√, NewExit)] NewExit› discuss goal 1*) apply ((assumption)[1]) (*discuss goal 2*) . (*proven 2 subgoals*) with ‹m = Entry› (*‹(m::'b) = (Entry::'b)›*) ‹n = Node m› (*‹(n::'b LDCFG_node) = Node (m::'b)›*) show "?thesis" (*goal: ‹∃as. CFGExit.valid_path' n as NewExit›*) apply simp (*goal: ‹∃as. CFGExit.valid_path' n as NewExit›*) by blast next (*goals: 1. ‹m = Exit ⟹ ∃as. CFGExit.valid_path' n as NewExit› 2. ‹inner_node m ⟹ ∃as. CFGExit.valid_path' n as NewExit›*) case Exit (*‹m = Exit›*) have "lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit (Node Exit,(λs. True)⇩√,NewExit)" by (fastforce intro:lve_Exit_edge (*‹?e = (Node ?X, (λs. True)⇩√, NewExit) ⟹ lift_valid_edge ?valid_edge ?src ?trg ?knd ?E ?X ?e›*)) with ‹m = Exit› (*‹m = Exit›*) ‹n = Node m› (*‹n = Node m›*) have "CFG.CFG.path src trg (lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit) n [(Node Exit,(λs. True)⇩√,NewExit)] NewExit" by (fastforce intro:CFGExit.Cons_path (*‹⟦CFGExit.path ?n'' ?as ?n'; lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit ?a; src ?a = ?n; trg ?a = ?n''⟧ ⟹ CFGExit.path ?n (?a # ?as) ?n'›*) CFGExit.empty_path (*‹CFGExit.valid_node ?n ⟹ CFGExit.path ?n [] ?n›*) simp:CFGExit.valid_node_def (*‹CFGExit.valid_node ?n ≡ ∃a. lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a ∧ (?n = src a ∨ ?n = trg a)›*)) thus "?thesis" (*goal: ‹∃as. CFGExit.valid_path' n as NewExit›*) by (fastforce simp:CFGExit.vp_def (*‹CFGExit.valid_path' (?n::'b::type LDCFG_node) (?as::('b::type LDCFG_node × ('c::type, 'd::type, 'e::type, 'f::type) edge_kind × 'b::type LDCFG_node) list) (?n'::'b::type LDCFG_node) ≡ CFGExit.path ?n ?as ?n' ∧ CFGExit.valid_path ?as›*) CFGExit.valid_path_def (*‹CFGExit.valid_path (?as::('b::type LDCFG_node × ('c::type, 'd::type, 'e::type, 'f::type) edge_kind × 'b::type LDCFG_node) list) ≡ CFGExit.valid_path_aux [] ?as›*)) next (*goal: ‹inner_node m ⟹ ∃as. CFGExit.valid_path' n as NewExit›*) case inner (*‹inner_node (m::'b)›*) have "lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit (Node Exit,(λs. True)⇩√,NewExit)" by (fastforce intro:lve_Exit_edge (*‹?e = (Node ?X, (λs. True)⇩√, NewExit) ⟹ lift_valid_edge ?valid_edge ?src ?trg ?knd ?E ?X ?e›*)) hence "CFG.path src trg (lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit) (Node Exit) [(Node Exit,(λs. True)⇩√,NewExit)] NewExit" by (fastforce intro:CFGExit.Cons_path (*‹⟦CFGExit.path ?n'' ?as ?n'; lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit ?a; src ?a = ?n; trg ?a = ?n''⟧ ⟹ CFGExit.path ?n (?a # ?as) ?n'›*) CFGExit.empty_path (*‹CFGExit.valid_node ?n ⟹ CFGExit.path ?n [] ?n›*) simp:CFGExit.valid_node_def (*‹CFGExit.valid_node ?n ≡ ∃a. lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a ∧ (?n = src a ∨ ?n = trg a)›*)) hence slp_edge: "CFG.CFG.same_level_path' src trg knd (lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit) (lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind) (Node Exit) [(Node Exit,(λs. True)⇩√,NewExit)] NewExit" by (fastforce simp:CFGExit.slp_def (*‹CFGExit.same_level_path' ?n ?as ?n' ≡ CFGExit.path ?n ?as ?n' ∧ CFGExit.same_level_path ?as›*) CFGExit.same_level_path_def (*‹CFGExit.same_level_path ?as ≡ CFGExit.same_level_path_aux [] ?as ∧ CFGExit.upd_cs [] ?as = []›*)) from ‹valid_node m› (*‹valid_node m›*) obtain as where "m -as→⇩√* Exit" (*goal: ‹(⋀as. m -as→⇩√* Exit ⟹ thesis) ⟹ thesis›*) by (fastforce dest:Exit_path (*‹valid_node (?n::'b) ⟹ ∃as::'a list. ?n -as→⇩√* Exit::'b›*)) with ‹inner_node m› (*‹inner_node (m::'b::type)›*) have "∃es. CFG.CFG.valid_path' src trg knd (lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit) (lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind) (Node m) es (Node Exit)" by (fastforce intro:lift_valid_path (*‹⟦?m -?as→⇩√* ?m'; ?m ≠ Entry ∨ ?m' ≠ Exit⟧ ⟹ ∃es. CFGExit.valid_path' (Node ?m) es (Node ?m')›*) simp:inner_node_def (*‹inner_node ?n ≡ valid_node ?n ∧ ?n ≠ Entry ∧ ?n ≠ Exit›*)) then obtain es where "CFG.CFG.valid_path' src trg knd (lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit) (lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind) (Node m) es (Node Exit)" (*goal: ‹(⋀es. CFGExit.valid_path' (Node m) es (Node Exit) ⟹ thesis) ⟹ thesis›*) by blast with slp_edge (*‹CFGExit.same_level_path' (Node Exit) [(Node Exit, (λs. True)⇩√, NewExit)] NewExit›*) have "CFG.CFG.valid_path' src trg knd (lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit) (lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind) (Node m) (es@[(Node Exit,(λs. True)⇩√,NewExit)]) NewExit" apply - (*goal: ‹CFGExit.valid_path' (Node m) (es @ [(Node Exit, (λs. True)⇩√, NewExit)]) NewExit›*) apply (rule CFGExit.vp_slp_Append (*‹⟦CFGExit.valid_path' ?n ?as ?n''; CFGExit.same_level_path' ?n'' ?as' ?n'⟧ ⟹ CFGExit.valid_path' ?n (?as @ ?as') ?n'›*)) (*goals: 1. ‹⟦CFGExit.same_level_path' (Node Exit) [(Node Exit, (λs. True)⇩√, NewExit)] NewExit; CFGExit.valid_path' (Node m) es (Node Exit)⟧ ⟹ CFGExit.valid_path' (Node m) es ?n''2› 2. ‹⟦CFGExit.same_level_path' (Node Exit) [(Node Exit, (λs. True)⇩√, NewExit)] NewExit; CFGExit.valid_path' (Node m) es (Node Exit)⟧ ⟹ CFGExit.same_level_path' ?n''2 [(Node Exit, (λs. True)⇩√, NewExit)] NewExit› discuss goal 1*) apply ((assumption)[1]) (*discuss goal 2*) . (*proven 2 subgoals*) with ‹n = Node m› (*‹n = Node m›*) show "?thesis" (*goal: ‹∃as. CFGExit.valid_path' n as NewExit›*) apply simp (*goal: ‹∃as::('b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node) list. CFGExit.valid_path' (n::'b LDCFG_node) as NewExit›*) by blast qed qed next (*goal: ‹⋀n n'. ⟦local.CFGExit.method_exit n; local.CFGExit.method_exit n'; lift_get_proc get_proc Main n = lift_get_proc get_proc Main n'⟧ ⟹ n = n'›*) fix n and n' assume method_exit1: "CFGExit.CFGExit.method_exit src knd (lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit) NewExit n" and method_exit2: "CFGExit.CFGExit.method_exit src knd (lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit) NewExit n'" and lift_eq: "lift_get_proc get_proc Main n = lift_get_proc get_proc Main n'" (*‹local.CFGExit.method_exit (n::'b LDCFG_node)› ‹local.CFGExit.method_exit (n'::'b LDCFG_node)› ‹lift_get_proc (get_proc::'b ⇒ 'f) (Main::'f) (n::'b LDCFG_node) = lift_get_proc get_proc Main (n'::'b LDCFG_node)›*) from method_exit1 (*‹local.CFGExit.method_exit n›*) show "n = n'" proof (rule CFGExit.method_exit_cases (*‹⟦local.CFGExit.method_exit ?n; ?n = NewExit ⟹ ?P; ⋀a Q f p. ⟦?n = src a; lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q↩⇘p⇙f⟧ ⟹ ?P⟧ ⟹ ?P›*)) (*goals: 1. ‹n = NewExit ⟹ n = n'› 2. ‹⋀a Q f p. ⟦n = src a; lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q↩⇘p⇙f⟧ ⟹ n = n'›*) assume "n = NewExit" (*‹(n::'b LDCFG_node) = NewExit›*) from method_exit2 (*‹local.CFGExit.method_exit (n'::'b::type LDCFG_node)›*) show "?thesis" (*goal: ‹n = n'›*) proof (rule CFGExit.method_exit_cases (*‹⟦local.CFGExit.method_exit ?n; ?n = NewExit ⟹ ?P; ⋀a Q f p. ⟦?n = src a; lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q↩⇘p⇙f⟧ ⟹ ?P⟧ ⟹ ?P›*)) (*goals: 1. ‹n' = NewExit ⟹ n = n'› 2. ‹⋀a Q f p. ⟦n' = src a; lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q↩⇘p⇙f⟧ ⟹ n = n'›*) assume "n' = NewExit" (*‹(n'::'b LDCFG_node) = NewExit›*) with ‹n = NewExit› (*‹n = NewExit›*) show "?thesis" (*goal: ‹n = n'›*) by simp next (*goal: ‹⋀a Q f p. ⟦n' = src a; lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q↩⇘p⇙f⟧ ⟹ n = n'›*) fix a and Q and f and p assume "n' = src a" and "lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a" and "knd a = Q↩⇘p⇙f" (*‹(n'::'b LDCFG_node) = src (a::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node)› ‹lift_valid_edge (valid_edge::'a ⇒ bool) (sourcenode::'a ⇒ 'b) (targetnode::'a ⇒ 'b) (kind::'a ⇒ ('c, 'd, 'e, 'f) edge_kind) (Entry::'b) (Exit::'b) (a::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node)› ‹knd (a::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node) = Q::('c ⇒ 'd option) × 'e ⇒ bool↩⇘p::'f⇙f::('c ⇒ 'd option) ⇒ ('c ⇒ 'd option) ⇒ 'c ⇒ 'd option›*) hence "lift_get_proc get_proc Main (src a) = p" apply - (*goal: ‹lift_get_proc get_proc Main (src a) = p›*) apply (rule CFGExit.get_proc_return (*‹⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit ?a; knd ?a = ?Q'↩⇘?p⇙?f'⟧ ⟹ lift_get_proc get_proc Main (src ?a) = ?p›*)) (*goals: 1. ‹⟦n' = src a; lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q↩⇘p⇙f⟧ ⟹ lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a› 2. ‹⟦n' = src a; lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q↩⇘p⇙f⟧ ⟹ knd a = ?Q'3↩⇘p⇙?f'3› discuss goal 1*) apply ((assumption)[1]) (*discuss goal 2*) . (*proven 2 subgoals*) with CFGExit.get_proc_Exit (*‹lift_get_proc get_proc Main NewExit = Main›*) lift_eq (*‹lift_get_proc get_proc Main n = lift_get_proc get_proc Main n'›*) ‹n' = src a› (*‹n' = src a›*) ‹n = NewExit› (*‹n = NewExit›*) have "p = Main" by simp with ‹knd a = Q↩⇘p⇙f› (*‹knd (a::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node) = Q::('c ⇒ 'd option) × 'e ⇒ bool↩⇘p::'f⇙f::('c ⇒ 'd option) ⇒ ('c ⇒ 'd option) ⇒ 'c ⇒ 'd option›*) have "knd a = Q↩⇘Main⇙f" by simp with ‹lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a› (*‹lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a›*) have False by (rule CFGExit.Main_no_return_source (*‹⟦lift_valid_edge (valid_edge::'a ⇒ bool) (sourcenode::'a ⇒ 'b) (targetnode::'a ⇒ 'b) (kind::'a ⇒ ('c, 'd, 'e, 'f) edge_kind) (Entry::'b) (Exit::'b) (?a::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node); knd ?a = ?Q'::('c ⇒ 'd option) × 'e ⇒ bool↩⇘Main::'f⇙?f'::('c ⇒ 'd option) ⇒ ('c ⇒ 'd option) ⇒ 'c ⇒ 'd option⟧ ⟹ False›*)) thus "?thesis" (*goal: ‹n = n'›*) by simp qed next (*goal: ‹⋀(a::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node) (Q::('c ⇒ 'd option) × 'e ⇒ bool) (f::('c ⇒ 'd option) ⇒ ('c ⇒ 'd option) ⇒ 'c ⇒ 'd option) p::'f. ⟦(n::'b LDCFG_node) = src a; lift_valid_edge (valid_edge::'a ⇒ bool) (sourcenode::'a ⇒ 'b) (targetnode::'a ⇒ 'b) (kind::'a ⇒ ('c, 'd, 'e, 'f) edge_kind) (Entry::'b) (Exit::'b) a; knd a = Q↩⇘p⇙f⟧ ⟹ n = (n'::'b LDCFG_node)›*) fix a and Q and f and p assume "n = src a" and "lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a" and "knd a = Q↩⇘p⇙f" (*‹(n::'b LDCFG_node) = src (a::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node)› ‹lift_valid_edge (valid_edge::'a ⇒ bool) (sourcenode::'a ⇒ 'b) (targetnode::'a ⇒ 'b) (kind::'a ⇒ ('c, 'd, 'e, 'f) edge_kind) (Entry::'b) (Exit::'b) (a::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node)› ‹knd (a::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node) = Q::('c ⇒ 'd option) × 'e ⇒ bool↩⇘p::'f⇙f::('c ⇒ 'd option) ⇒ ('c ⇒ 'd option) ⇒ 'c ⇒ 'd option›*) then obtain x where "valid_edge x" and "src a = Node (sourcenode x)" and "kind x = Q↩⇘p⇙f" (*goal: ‹(⋀x. ⟦valid_edge x; src a = Node (sourcenode x); kind x = Q↩⇘p⇙f⟧ ⟹ thesis) ⟹ thesis›*) by (fastforce elim:lift_valid_edge.cases (*‹⟦lift_valid_edge ?valid_edge ?src ?trg ?knd ?E ?X ?a; ⋀a e. ⟦?a = e; ?valid_edge a; ?src a ≠ ?E ∨ ?trg a ≠ ?X; e = (Node (?src a), ?knd a, Node (?trg a))⟧ ⟹ ?P; ⋀e. ⟦?a = e; e = (NewEntry, (λs. True)⇩√, Node ?E)⟧ ⟹ ?P; ⋀e. ⟦?a = e; e = (Node ?X, (λs. True)⇩√, NewExit)⟧ ⟹ ?P; ⋀e. ⟦?a = e; e = (NewEntry, (λs. False)⇩√, NewExit)⟧ ⟹ ?P⟧ ⟹ ?P›*)) hence "method_exit (sourcenode x)" by (fastforce simp:method_exit_def (*‹method_exit ?n ≡ ?n = Exit ∨ (∃a Q p f. ?n = sourcenode a ∧ valid_edge a ∧ kind a = Q↩⇘p⇙f)›*)) from method_exit2 (*‹local.CFGExit.method_exit n'›*) show "?thesis" (*goal: ‹n = n'›*) proof (rule CFGExit.method_exit_cases (*‹⟦local.CFGExit.method_exit ?n; ?n = NewExit ⟹ ?P; ⋀a Q f p. ⟦?n = src a; lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q↩⇘p⇙f⟧ ⟹ ?P⟧ ⟹ ?P›*)) (*goals: 1. ‹(n'::'b::type LDCFG_node) = NewExit ⟹ (n::'b::type LDCFG_node) = n'› 2. ‹⋀(a::'b::type LDCFG_node × ('c::type, 'd::type, 'e::type, 'f::type) edge_kind × 'b::type LDCFG_node) (Q::('c::type ⇒ 'd::type option) × 'e::type ⇒ bool) (f::('c::type ⇒ 'd::type option) ⇒ ('c::type ⇒ 'd::type option) ⇒ 'c::type ⇒ 'd::type option) p::'f::type. ⟦(n'::'b::type LDCFG_node) = src a; lift_valid_edge (valid_edge::'a::type ⇒ bool) (sourcenode::'a::type ⇒ 'b::type) (targetnode::'a::type ⇒ 'b::type) (kind::'a::type ⇒ ('c::type, 'd::type, 'e::type, 'f::type) edge_kind) (Entry::'b::type) (Exit::'b::type) a; knd a = Q↩⇘p⇙f⟧ ⟹ (n::'b::type LDCFG_node) = n'›*) assume "n' = NewExit" (*‹(n'::'b LDCFG_node) = NewExit›*) from ‹lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a› (*‹lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a›*) ‹knd a = Q↩⇘p⇙f› (*‹knd a = Q↩⇘p⇙f›*) have "lift_get_proc get_proc Main (src a) = p" apply - (*goal: ‹lift_get_proc get_proc Main (src a) = p›*) apply (rule CFGExit.get_proc_return (*‹⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit ?a; knd ?a = ?Q'↩⇘?p⇙?f'⟧ ⟹ lift_get_proc get_proc Main (src ?a) = ?p›*)) (*goals: 1. ‹⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q↩⇘p⇙f⟧ ⟹ lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a› 2. ‹⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q↩⇘p⇙f⟧ ⟹ knd a = ?Q'2↩⇘p⇙?f'2› discuss goal 1*) apply ((assumption)[1]) (*discuss goal 2*) . (*proven 2 subgoals*) with CFGExit.get_proc_Exit (*‹lift_get_proc get_proc Main NewExit = Main›*) lift_eq (*‹lift_get_proc get_proc Main n = lift_get_proc get_proc Main n'›*) ‹n = src a› (*‹n = src a›*) ‹n' = NewExit› (*‹(n'::'b LDCFG_node) = NewExit›*) have "p = Main" by simp with ‹knd a = Q↩⇘p⇙f› (*‹knd a = Q↩⇘p⇙f›*) have "knd a = Q↩⇘Main⇙f" by simp with ‹lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a› (*‹lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a›*) have False by (rule CFGExit.Main_no_return_source (*‹⟦lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit ?a; knd ?a = ?Q'↩⇘Main⇙?f'⟧ ⟹ False›*)) thus "?thesis" (*goal: ‹n = n'›*) by simp next (*goal: ‹⋀a Q f p. ⟦n' = src a; lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a; knd a = Q↩⇘p⇙f⟧ ⟹ n = n'›*) fix a' and Q' and f' and p' assume "n' = src a'" and "lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a'" and "knd a' = Q'↩⇘p'⇙f'" (*‹(n'::'b LDCFG_node) = src (a'::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node)› ‹lift_valid_edge (valid_edge::'a ⇒ bool) (sourcenode::'a ⇒ 'b) (targetnode::'a ⇒ 'b) (kind::'a ⇒ ('c, 'd, 'e, 'f) edge_kind) (Entry::'b) (Exit::'b) (a'::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node)› ‹knd (a'::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node) = Q'::('c ⇒ 'd option) × 'e ⇒ bool↩⇘p'::'f⇙f'::('c ⇒ 'd option) ⇒ ('c ⇒ 'd option) ⇒ 'c ⇒ 'd option›*) then obtain x' where "valid_edge x'" and "src a' = Node (sourcenode x')" and "kind x' = Q'↩⇘p'⇙f'" (*goal: ‹(⋀x'::'a. ⟦(valid_edge::'a ⇒ bool) x'; src (a'::'b LDCFG_node × ('c, 'd, 'e, 'f) edge_kind × 'b LDCFG_node) = Node ((sourcenode::'a ⇒ 'b) x'); (kind::'a ⇒ ('c, 'd, 'e, 'f) edge_kind) x' = Q'::('c ⇒ 'd option) × 'e ⇒ bool↩⇘p'::'f⇙f'::('c ⇒ 'd option) ⇒ ('c ⇒ 'd option) ⇒ 'c ⇒ 'd option⟧ ⟹ thesis::bool) ⟹ thesis›*) by (fastforce elim:lift_valid_edge.cases (*‹⟦lift_valid_edge ?valid_edge ?src ?trg ?knd ?E ?X ?a; ⋀a e. ⟦?a = e; ?valid_edge a; ?src a ≠ ?E ∨ ?trg a ≠ ?X; e = (Node (?src a), ?knd a, Node (?trg a))⟧ ⟹ ?P; ⋀e. ⟦?a = e; e = (NewEntry, (λs. True)⇩√, Node ?E)⟧ ⟹ ?P; ⋀e. ⟦?a = e; e = (Node ?X, (λs. True)⇩√, NewExit)⟧ ⟹ ?P; ⋀e. ⟦?a = e; e = (NewEntry, (λs. False)⇩√, NewExit)⟧ ⟹ ?P⟧ ⟹ ?P›*)) hence "method_exit (sourcenode x')" by (fastforce simp:method_exit_def (*‹method_exit ?n ≡ ?n = Exit ∨ (∃a Q p f. ?n = sourcenode a ∧ valid_edge a ∧ kind a = Q↩⇘p⇙f)›*)) with ‹method_exit (sourcenode x)› (*‹method_exit (sourcenode x)›*) lift_eq (*‹lift_get_proc get_proc Main n = lift_get_proc get_proc Main n'›*) ‹n = src a› (*‹n = src a›*) ‹n' = src a'› (*‹n' = src a'›*) ‹src a = Node (sourcenode x)› (*‹src a = Node (sourcenode x)›*) ‹src a' = Node (sourcenode x')› (*‹src a' = Node (sourcenode x')›*) have "sourcenode x = sourcenode x'" by (fastforce intro:method_exit_unique (*‹⟦method_exit (?n::'b); method_exit (?n'::'b); (get_proc::'b ⇒ 'f) ?n = get_proc ?n'⟧ ⟹ ?n = ?n'›*)) with ‹src a = Node (sourcenode x)› (*‹src a = Node (sourcenode x)›*) ‹src a' = Node (sourcenode x')› (*‹src a' = Node (sourcenode x')›*) ‹n = src a› (*‹n = src a›*) ‹n' = src a'› (*‹n' = src a'›*) show "?thesis" (*goal: ‹n = n'›*) by simp qed qed qed qed lemma lift_SDG: assumes SDG:"SDG sourcenode targetnode kind valid_edge Entry get_proc get_return_edges procs Main Exit Def Use ParamDefs ParamUses" and inner:"CFGExit.inner_node sourcenode targetnode valid_edge Entry Exit nx" shows "SDG src trg knd (lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit) NewEntry (lift_get_proc get_proc Main) (lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind) procs Main NewExit (lift_Def Def Entry Exit H L) (lift_Use Use Entry Exit H L) (lift_ParamDefs ParamDefs) (lift_ParamUses ParamUses)" proof (-) (*goal: ‹SDG src trg knd (lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit) NewEntry (lift_get_proc get_proc Main) (lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind) procs Main NewExit (lift_Def Def Entry Exit H L) (lift_Use Use Entry Exit H L) (lift_ParamDefs ParamDefs) (lift_ParamUses ParamUses)›*) interpret SDG sourcenode targetnode kind valid_edge Entry get_proc get_return_edges procs Main Exit Def Use ParamDefs ParamUses by (rule SDG (*‹SDG sourcenode targetnode kind valid_edge Entry get_proc get_return_edges procs Main Exit Def Use ParamDefs ParamUses›*)) have wf: "CFGExit_wf sourcenode targetnode kind valid_edge Entry get_proc get_return_edges procs Main Exit Def Use ParamDefs ParamUses" by unfold_locales have pd: "Postdomination sourcenode targetnode kind valid_edge Entry get_proc get_return_edges procs Main Exit" by unfold_locales interpret wf': CFGExit_wf src trg knd "lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit" NewEntry "lift_get_proc get_proc Main" "lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind" procs Main NewExit "lift_Def Def Entry Exit H L" "lift_Use Use Entry Exit H L" "lift_ParamDefs ParamDefs" "lift_ParamUses ParamUses" by (fastforce intro:lift_CFGExit_wf (*‹⟦CFGExit_wf (?sourcenode::?'a ⇒ ?'b) (?targetnode::?'a ⇒ ?'b) (?kind::?'a ⇒ (?'c, ?'d, ?'e, ?'f) edge_kind) (?valid_edge::?'a ⇒ bool) (?Entry::?'b) (?get_proc::?'b ⇒ ?'f) (?get_return_edges::?'a ⇒ ?'a set) (?procs::(?'f × ?'c list × ?'c list) list) (?Main::?'f) (?Exit::?'b) (?Def::?'b ⇒ ?'c set) (?Use::?'b ⇒ ?'c set) (?ParamDefs::?'b ⇒ ?'c list) (?ParamUses::?'b ⇒ ?'c set list); Postdomination ?sourcenode ?targetnode ?kind ?valid_edge ?Entry ?get_proc ?get_return_edges ?procs ?Main ?Exit⟧ ⟹ CFGExit_wf src trg knd (lift_valid_edge ?valid_edge ?sourcenode ?targetnode ?kind ?Entry ?Exit) NewEntry (lift_get_proc ?get_proc ?Main) (lift_get_return_edges ?get_return_edges ?valid_edge ?sourcenode ?targetnode ?kind) ?procs ?Main NewExit (lift_Def ?Def ?Entry ?Exit (?H::?'c set) (?L::?'c set)) (lift_Use ?Use ?Entry ?Exit ?H ?L) (lift_ParamDefs ?ParamDefs) (lift_ParamUses ?ParamUses)›*) wf (*‹CFGExit_wf (sourcenode::'a ⇒ 'b) (targetnode::'a ⇒ 'b) (kind::'a ⇒ ('c, 'd, 'e, 'f) edge_kind) (valid_edge::'a ⇒ bool) (Entry::'b) (get_proc::'b ⇒ 'f) (get_return_edges::'a ⇒ 'a set) (procs::('f × 'c list × 'c list) list) (Main::'f) (Exit::'b) (Def::'b ⇒ 'c set) (Use::'b ⇒ 'c set) (ParamDefs::'b ⇒ 'c list) (ParamUses::'b ⇒ 'c set list)›*) pd (*‹Postdomination (sourcenode::'a ⇒ 'b) (targetnode::'a ⇒ 'b) (kind::'a ⇒ ('c, 'd, 'e, 'f) edge_kind) (valid_edge::'a ⇒ bool) (Entry::'b) (get_proc::'b ⇒ 'f) (get_return_edges::'a ⇒ 'a set) (procs::('f × 'c list × 'c list) list) (Main::'f) (Exit::'b)›*)) interpret pd': Postdomination src trg knd "lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit" NewEntry "lift_get_proc get_proc Main" "lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind" procs Main NewExit by (fastforce intro:lift_Postdomination (*‹⟦CFGExit_wf ?sourcenode ?targetnode ?kind ?valid_edge ?Entry ?get_proc ?get_return_edges ?procs ?Main ?Exit ?Def ?Use ?ParamDefs ?ParamUses; Postdomination ?sourcenode ?targetnode ?kind ?valid_edge ?Entry ?get_proc ?get_return_edges ?procs ?Main ?Exit; CFGExit.inner_node ?sourcenode ?targetnode ?valid_edge ?Entry ?Exit ?nx⟧ ⟹ Postdomination src trg knd (lift_valid_edge ?valid_edge ?sourcenode ?targetnode ?kind ?Entry ?Exit) NewEntry (lift_get_proc ?get_proc ?Main) (lift_get_return_edges ?get_return_edges ?valid_edge ?sourcenode ?targetnode ?kind) ?procs ?Main NewExit›*) wf (*‹CFGExit_wf sourcenode targetnode kind valid_edge Entry get_proc get_return_edges procs Main Exit Def Use ParamDefs ParamUses›*) pd (*‹Postdomination sourcenode targetnode kind valid_edge Entry get_proc get_return_edges procs Main Exit›*) inner (*‹inner_node nx›*)) show "?thesis" (*goal: ‹SDG src trg knd (lift_valid_edge (valid_edge::'a ⇒ bool) (sourcenode::'a ⇒ 'b) (targetnode::'a ⇒ 'b) (kind::'a ⇒ ('c, 'd, 'e, 'f) edge_kind) (Entry::'b) (Exit::'b)) NewEntry (lift_get_proc (get_proc::'b ⇒ 'f) (Main::'f)) (lift_get_return_edges (get_return_edges::'a ⇒ 'a set) valid_edge sourcenode targetnode kind) (procs::('f × 'c list × 'c list) list) Main NewExit (lift_Def (Def::'b ⇒ 'c set) Entry Exit (H::'c set) (L::'c set)) (lift_Use (Use::'b ⇒ 'c set) Entry Exit H L) (lift_ParamDefs (ParamDefs::'b ⇒ 'c list)) (lift_ParamUses (ParamUses::'b ⇒ 'c set list))›*) by unfold_locales qed subsubsection ‹Low-deterministic security via the lifted graph› lemma Lift_NonInterferenceGraph: fixes valid_edge and sourcenode and targetnode and kind and Entry and Exit and get_proc and get_return_edges and procs and Main and Def and Use and ParamDefs and ParamUses and H and L defines lve:"lve ≡ lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit" and lget_proc:"lget_proc ≡ lift_get_proc get_proc Main" and lget_return_edges:"lget_return_edges ≡ lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind" and lDef:"lDef ≡ lift_Def Def Entry Exit H L" and lUse:"lUse ≡ lift_Use Use Entry Exit H L" and lParamDefs:"lParamDefs ≡ lift_ParamDefs ParamDefs" and lParamUses:"lParamUses ≡ lift_ParamUses ParamUses" assumes SDG:"SDG sourcenode targetnode kind valid_edge Entry get_proc get_return_edges procs Main Exit Def Use ParamDefs ParamUses" and inner:"CFGExit.inner_node sourcenode targetnode valid_edge Entry Exit nx" and "H ∩ L = {}" and "H ∪ L = UNIV" shows "NonInterferenceInterGraph src trg knd lve NewEntry lget_proc lget_return_edges procs Main NewExit lDef lUse lParamDefs lParamUses H L (Node Entry) (Node Exit)" proof (-) (*goal: ‹NonInterferenceInterGraph src trg knd lve NewEntry lget_proc lget_return_edges procs Main NewExit lDef lUse lParamDefs lParamUses H L (Node Entry) (Node Exit)›*) interpret SDG sourcenode targetnode kind valid_edge Entry get_proc get_return_edges procs Main Exit Def Use ParamDefs ParamUses by (rule SDG (*‹SDG sourcenode targetnode kind valid_edge Entry get_proc get_return_edges procs Main Exit Def Use ParamDefs ParamUses›*)) interpret SDG': SDG src trg knd lve NewEntry lget_proc lget_return_edges procs Main NewExit lDef lUse lParamDefs lParamUses by (fastforce intro:lift_SDG (*‹⟦SDG ?sourcenode ?targetnode ?kind ?valid_edge ?Entry ?get_proc ?get_return_edges ?procs ?Main ?Exit ?Def ?Use ?ParamDefs ?ParamUses; CFGExit.inner_node ?sourcenode ?targetnode ?valid_edge ?Entry ?Exit ?nx⟧ ⟹ SDG src trg knd (lift_valid_edge ?valid_edge ?sourcenode ?targetnode ?kind ?Entry ?Exit) NewEntry (lift_get_proc ?get_proc ?Main) (lift_get_return_edges ?get_return_edges ?valid_edge ?sourcenode ?targetnode ?kind) ?procs ?Main NewExit (lift_Def ?Def ?Entry ?Exit ?H ?L) (lift_Use ?Use ?Entry ?Exit ?H ?L) (lift_ParamDefs ?ParamDefs) (lift_ParamUses ?ParamUses)›*) SDG (*‹SDG sourcenode targetnode kind valid_edge Entry get_proc get_return_edges procs Main Exit Def Use ParamDefs ParamUses›*) inner (*‹inner_node nx›*) simp:lve (*‹lve ≡ lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit›*) lget_proc (*‹lget_proc ≡ lift_get_proc get_proc Main›*) lget_return_edges (*‹lget_return_edges ≡ lift_get_return_edges get_return_edges valid_edge sourcenode targetnode kind›*) lDef (*‹lDef ≡ lift_Def Def Entry Exit H L›*) lUse (*‹lUse ≡ lift_Use Use Entry Exit H L›*) lParamDefs (*‹lParamDefs ≡ lift_ParamDefs ParamDefs›*) lParamUses (*‹lParamUses ≡ lift_ParamUses ParamUses›*)) show "?thesis" (*goal: ‹NonInterferenceInterGraph src trg knd lve NewEntry lget_proc lget_return_edges procs Main NewExit lDef lUse lParamDefs lParamUses H L (Node Entry) (Node Exit)›*) proof (standard) (*goals: 1. ‹⋀a. ⟦lve a; src a = NewEntry⟧ ⟹ trg a = NewExit ∨ trg a = Node Entry› 2. ‹∃a. lve a ∧ src a = NewEntry ∧ trg a = Node Entry ∧ knd a = (λs. True)⇩√› 3. ‹⋀a. ⟦lve a; trg a = Node Entry⟧ ⟹ src a = NewEntry› 4. ‹⋀a. ⟦lve a; trg a = NewExit⟧ ⟹ src a = NewEntry ∨ src a = Node Exit› 5. ‹∃a. lve a ∧ src a = Node Exit ∧ trg a = NewExit ∧ knd a = (λs. True)⇩√› 6. ‹⋀a. ⟦lve a; src a = Node Exit⟧ ⟹ trg a = NewExit› 7. ‹lDef (Node Entry) = H› 8. ‹lUse (Node Entry) = H› 9. ‹lUse (Node Exit) = L› 10. ‹H ∩ L = {}› 11. ‹H ∪ L = UNIV›*) fix a assume "lve a" and "src a = NewEntry" (*‹(lve::'a LDCFG_node × ('b, 'c, 'd, 'e) edge_kind × 'a LDCFG_node ⇒ bool) (a::'a LDCFG_node × ('b, 'c, 'd, 'e) edge_kind × 'a LDCFG_node)› ‹src (a::'a LDCFG_node × ('b, 'c, 'd, 'e) edge_kind × 'a LDCFG_node) = NewEntry›*) thus "trg a = NewExit ∨ trg a = Node Entry" by (fastforce elim:lift_valid_edge.cases (*‹⟦lift_valid_edge ?valid_edge ?src ?trg ?knd ?E ?X ?a; ⋀a e. ⟦?a = e; ?valid_edge a; ?src a ≠ ?E ∨ ?trg a ≠ ?X; e = (Node (?src a), ?knd a, Node (?trg a))⟧ ⟹ ?P; ⋀e. ⟦?a = e; e = (NewEntry, (λs. True)⇩√, Node ?E)⟧ ⟹ ?P; ⋀e. ⟦?a = e; e = (Node ?X, (λs. True)⇩√, NewExit)⟧ ⟹ ?P; ⋀e. ⟦?a = e; e = (NewEntry, (λs. False)⇩√, NewExit)⟧ ⟹ ?P⟧ ⟹ ?P›*) simp:lve (*‹lve ≡ lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit›*)) next (*goals: 1. ‹∃a::'a LDCFG_node × ('b, 'c, 'd, 'e) edge_kind × 'a LDCFG_node. (lve::'a LDCFG_node × ('b, 'c, 'd, 'e) edge_kind × 'a LDCFG_node ⇒ bool) a ∧ src a = NewEntry ∧ trg a = Node (Entry::'a) ∧ knd a = (λs::'b ⇒ 'c option. True)⇩√› 2. ‹⋀a::'a LDCFG_node × ('b, 'c, 'd, 'e) edge_kind × 'a LDCFG_node. ⟦(lve::'a LDCFG_node × ('b, 'c, 'd, 'e) edge_kind × 'a LDCFG_node ⇒ bool) a; trg a = Node (Entry::'a)⟧ ⟹ src a = NewEntry› 3. ‹⋀a::'a LDCFG_node × ('b, 'c, 'd, 'e) edge_kind × 'a LDCFG_node. ⟦(lve::'a LDCFG_node × ('b, 'c, 'd, 'e) edge_kind × 'a LDCFG_node ⇒ bool) a; trg a = NewExit⟧ ⟹ src a = NewEntry ∨ src a = Node (Exit::'a)› 4. ‹∃a::'a LDCFG_node × ('b, 'c, 'd, 'e) edge_kind × 'a LDCFG_node. (lve::'a LDCFG_node × ('b, 'c, 'd, 'e) edge_kind × 'a LDCFG_node ⇒ bool) a ∧ src a = Node (Exit::'a) ∧ trg a = NewExit ∧ knd a = (λs::'b ⇒ 'c option. True)⇩√› 5. ‹⋀a::'a LDCFG_node × ('b, 'c, 'd, 'e) edge_kind × 'a LDCFG_node. ⟦(lve::'a LDCFG_node × ('b, 'c, 'd, 'e) edge_kind × 'a LDCFG_node ⇒ bool) a; src a = Node (Exit::'a)⟧ ⟹ trg a = NewExit› 6. ‹(lDef::'a LDCFG_node ⇒ 'b set) (Node (Entry::'a)) = (H::'b set)› 7. ‹(lUse::'a LDCFG_node ⇒ 'b set) (Node (Entry::'a)) = (H::'b set)› 8. ‹(lUse::'a LDCFG_node ⇒ 'b set) (Node (Exit::'a)) = (L::'b set)› 9. ‹(H::'b set) ∩ (L::'b set) = {}› 10. ‹(H::'b set) ∪ (L::'b set) = UNIV›*) show "∃a. lve a ∧ src a = NewEntry ∧ trg a = Node Entry ∧ knd a = (λs. True)⇩√" by (fastforce intro:lve_Entry_edge (*‹(?e::?'node LDCFG_node × (?'var, ?'val, ?'ret, ?'pname) edge_kind × ?'node LDCFG_node) = (NewEntry, (λs::?'var ⇒ ?'val option. True)⇩√, Node (?E::?'node)) ⟹ lift_valid_edge (?valid_edge::?'edge ⇒ bool) (?src::?'edge ⇒ ?'node) (?trg::?'edge ⇒ ?'node) (?knd::?'edge ⇒ (?'var, ?'val, ?'ret, ?'pname) edge_kind) ?E (?X::?'node) ?e›*) simp:lve (*‹lve::'a LDCFG_node × ('b, 'c, 'd, 'e) edge_kind × 'a LDCFG_node ⇒ bool ≡ lift_valid_edge (valid_edge::'f ⇒ bool) (sourcenode::'f ⇒ 'a) (targetnode::'f ⇒ 'a) (kind::'f ⇒ ('b, 'c, 'd, 'e) edge_kind) (Entry::'a) (Exit::'a)›*)) next (*goals: 1. ‹⋀a. ⟦lve a; trg a = Node Entry⟧ ⟹ src a = NewEntry› 2. ‹⋀a. ⟦lve a; trg a = NewExit⟧ ⟹ src a = NewEntry ∨ src a = Node Exit› 3. ‹∃a. lve a ∧ src a = Node Exit ∧ trg a = NewExit ∧ knd a = (λs. True)⇩√› 4. ‹⋀a. ⟦lve a; src a = Node Exit⟧ ⟹ trg a = NewExit› 5. ‹lDef (Node Entry) = H› 6. ‹lUse (Node Entry) = H› 7. ‹lUse (Node Exit) = L› 8. ‹H ∩ L = {}› 9. ‹H ∪ L = UNIV›*) fix a assume "lve a" and "trg a = Node Entry" (*‹(lve::'a LDCFG_node × ('b, 'c, 'd, 'e) edge_kind × 'a LDCFG_node ⇒ bool) (a::'a LDCFG_node × ('b, 'c, 'd, 'e) edge_kind × 'a LDCFG_node)› ‹trg (a::'a LDCFG_node × ('b, 'c, 'd, 'e) edge_kind × 'a LDCFG_node) = Node (Entry::'a)›*) from ‹lve a› (*‹lve a›*) have "lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a" by (simp add:lve (*‹lve ≡ lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit›*)) from this (*‹lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a›*) ‹trg a = Node Entry› (*‹trg a = Node Entry›*) show "src a = NewEntry" proof (induct rule:lift_valid_edge.induct (*‹⟦lift_valid_edge ?valid_edge ?src ?trg ?knd ?E ?X ?x; ⋀a e. ⟦?valid_edge a; ?src a ≠ ?E ∨ ?trg a ≠ ?X; e = (Node (?src a), ?knd a, Node (?trg a))⟧ ⟹ ?P e; ⋀e. e = (NewEntry, (λs. True)⇩√, Node ?E) ⟹ ?P e; ⋀e. e = (Node ?X, (λs. True)⇩√, NewExit) ⟹ ?P e; ⋀e. e = (NewEntry, (λs. False)⇩√, NewExit) ⟹ ?P e⟧ ⟹ ?P ?x›*)) (*goals: 1. ‹⋀a e. ⟦valid_edge a; sourcenode a ≠ Entry ∨ targetnode a ≠ Exit; e = (Node (sourcenode a), kind a, Node (targetnode a)); trg e = Node Entry⟧ ⟹ src e = NewEntry› 2. ‹⋀e. ⟦e = (NewEntry, (λs. True)⇩√, Node Entry); trg e = Node Entry⟧ ⟹ src e = NewEntry› 3. ‹⋀e. ⟦e = (Node Exit, (λs. True)⇩√, NewExit); trg e = Node Entry⟧ ⟹ src e = NewEntry› 4. ‹⋀e. ⟦e = (NewEntry, (λs. False)⇩√, NewExit); trg e = Node Entry⟧ ⟹ src e = NewEntry›*) case (lve_edge a e) (*‹(valid_edge::'f::type ⇒ bool) (a::'f::type)› ‹sourcenode a ≠ Entry ∨ targetnode a ≠ Exit› ‹e = (Node (sourcenode a), kind a, Node (targetnode a))› ‹trg e = Node Entry›*) from ‹e = (Node (sourcenode a), kind a, Node (targetnode a))› (*‹(e::'a LDCFG_node × ('b, 'c, 'd, 'e) edge_kind × 'a LDCFG_node) = (Node ((sourcenode::'f ⇒ 'a) (a::'f)), (kind::'f ⇒ ('b, 'c, 'd, 'e) edge_kind) a, Node ((targetnode::'f ⇒ 'a) a))›*) ‹trg e = Node Entry› (*‹trg e = Node Entry›*) have "targetnode a = Entry" by simp with ‹valid_edge a› (*‹(valid_edge::'f ⇒ bool) (a::'f)›*) have False by (rule Entry_target (*‹⟦(valid_edge::'f ⇒ bool) (?a::'f); (targetnode::'f ⇒ 'a) ?a = (Entry::'a)⟧ ⟹ False›*)) thus "?case" (*goal: ‹src (e::'a LDCFG_node × ('b, 'c, 'd, 'e) edge_kind × 'a LDCFG_node) = NewEntry›*) by simp qed (simp_all) (*solves the remaining goals: 1. ‹⋀e. ⟦e = (NewEntry, (λs. True)⇩√, Node Entry); trg e = Node Entry⟧ ⟹ src e = NewEntry› 2. ‹⋀e. ⟦e = (Node Exit, (λs. True)⇩√, NewExit); trg e = Node Entry⟧ ⟹ src e = NewEntry› 3. ‹⋀e. ⟦e = (NewEntry, (λs. False)⇩√, NewExit); trg e = Node Entry⟧ ⟹ src e = NewEntry›*) next (*goals: 1. ‹⋀a. ⟦lve a; trg a = NewExit⟧ ⟹ src a = NewEntry ∨ src a = Node Exit› 2. ‹∃a. lve a ∧ src a = Node Exit ∧ trg a = NewExit ∧ knd a = (λs. True)⇩√› 3. ‹⋀a. ⟦lve a; src a = Node Exit⟧ ⟹ trg a = NewExit› 4. ‹lDef (Node Entry) = H› 5. ‹lUse (Node Entry) = H› 6. ‹lUse (Node Exit) = L› 7. ‹H ∩ L = {}› 8. ‹H ∪ L = UNIV›*) fix a assume "lve a" and "trg a = NewExit" (*‹(lve::'a LDCFG_node × ('b, 'c, 'd, 'e) edge_kind × 'a LDCFG_node ⇒ bool) (a::'a LDCFG_node × ('b, 'c, 'd, 'e) edge_kind × 'a LDCFG_node)› ‹trg (a::'a LDCFG_node × ('b, 'c, 'd, 'e) edge_kind × 'a LDCFG_node) = NewExit›*) thus "src a = NewEntry ∨ src a = Node Exit" by (fastforce elim:lift_valid_edge.cases (*‹⟦lift_valid_edge ?valid_edge ?src ?trg ?knd ?E ?X ?a; ⋀a e. ⟦?a = e; ?valid_edge a; ?src a ≠ ?E ∨ ?trg a ≠ ?X; e = (Node (?src a), ?knd a, Node (?trg a))⟧ ⟹ ?P; ⋀e. ⟦?a = e; e = (NewEntry, (λs. True)⇩√, Node ?E)⟧ ⟹ ?P; ⋀e. ⟦?a = e; e = (Node ?X, (λs. True)⇩√, NewExit)⟧ ⟹ ?P; ⋀e. ⟦?a = e; e = (NewEntry, (λs. False)⇩√, NewExit)⟧ ⟹ ?P⟧ ⟹ ?P›*) simp:lve (*‹lve ≡ lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit›*)) next (*goals: 1. ‹∃a. lve a ∧ src a = Node Exit ∧ trg a = NewExit ∧ knd a = (λs. True)⇩√› 2. ‹⋀a. ⟦lve a; src a = Node Exit⟧ ⟹ trg a = NewExit› 3. ‹lDef (Node Entry) = H› 4. ‹lUse (Node Entry) = H› 5. ‹lUse (Node Exit) = L› 6. ‹H ∩ L = {}› 7. ‹H ∪ L = UNIV›*) show "∃a. lve a ∧ src a = Node Exit ∧ trg a = NewExit ∧ knd a = (λs. True)⇩√" by (fastforce intro:lve_Exit_edge (*‹?e = (Node ?X, (λs. True)⇩√, NewExit) ⟹ lift_valid_edge ?valid_edge ?src ?trg ?knd ?E ?X ?e›*) simp:lve (*‹lve ≡ lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit›*)) next (*goals: 1. ‹⋀a. ⟦lve a; src a = Node Exit⟧ ⟹ trg a = NewExit› 2. ‹lDef (Node Entry) = H› 3. ‹lUse (Node Entry) = H› 4. ‹lUse (Node Exit) = L› 5. ‹H ∩ L = {}› 6. ‹H ∪ L = UNIV›*) fix a assume "lve a" and "src a = Node Exit" (*‹(lve::'a LDCFG_node × ('b, 'c, 'd, 'e) edge_kind × 'a LDCFG_node ⇒ bool) (a::'a LDCFG_node × ('b, 'c, 'd, 'e) edge_kind × 'a LDCFG_node)› ‹src (a::'a LDCFG_node × ('b, 'c, 'd, 'e) edge_kind × 'a LDCFG_node) = Node (Exit::'a)›*) from ‹lve a› (*‹(lve::'a::type LDCFG_node × ('b::type, 'c::type, 'd::type, 'e::type) edge_kind × 'a::type LDCFG_node ⇒ bool) (a::'a::type LDCFG_node × ('b::type, 'c::type, 'd::type, 'e::type) edge_kind × 'a::type LDCFG_node)›*) have "lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a" by (simp add:lve (*‹lve ≡ lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit›*)) from this (*‹lift_valid_edge valid_edge sourcenode targetnode kind Entry Exit a›*) ‹src a = Node Exit› (*‹src a = Node Exit›*) show "trg a = NewExit" proof (induct rule:lift_valid_edge.induct (*‹⟦lift_valid_edge ?valid_edge ?src ?trg ?knd ?E ?X ?x; ⋀a e. ⟦?valid_edge a; ?src a ≠ ?E ∨ ?trg a ≠ ?X; e = (Node (?src a), ?knd a, Node (?trg a))⟧ ⟹ ?P e; ⋀e. e = (NewEntry, (λs. True)⇩√, Node ?E) ⟹ ?P e; ⋀e. e = (Node ?X, (λs. True)⇩√, NewExit) ⟹ ?P e; ⋀e. e = (NewEntry, (λs. False)⇩√, NewExit) ⟹ ?P e⟧ ⟹ ?P ?x›*)) (*goals: 1. ‹⋀a e. ⟦valid_edge a; sourcenode a ≠ Entry ∨ targetnode a ≠ Exit; e = (Node (sourcenode a), kind a, Node (targetnode a)); src e = Node Exit⟧ ⟹ trg e = NewExit› 2. ‹⋀e. ⟦e = (NewEntry, (λs. True)⇩√, Node Entry); src e = Node Exit⟧ ⟹ trg e = NewExit› 3. ‹⋀e. ⟦e = (Node Exit, (λs. True)⇩√, NewExit); src e = Node Exit⟧ ⟹ trg e = NewExit› 4. ‹⋀e. ⟦e = (NewEntry, (λs. False)⇩√, NewExit); src e = Node Exit⟧ ⟹ trg e = NewExit›*) case (lve_edge a e) (*‹valid_edge a› ‹sourcenode a ≠ Entry ∨ targetnode a ≠ Exit› ‹e = (Node (sourcenode a), kind a, Node (targetnode a))› ‹src (e::'a LDCFG_node × ('b, 'c, 'd, 'e) edge_kind × 'a LDCFG_node) = Node (Exit::'a)›*) from ‹e = (Node (sourcenode a), kind a, Node (targetnode a))› (*‹e = (Node (sourcenode a), kind a, Node (targetnode a))›*) ‹src e = Node Exit› (*‹src e = Node Exit›*) have "sourcenode a = Exit" by simp with ‹valid_edge a› (*‹valid_edge a›*) have False by (rule Exit_source (*‹⟦valid_edge ?a; sourcenode ?a = Exit⟧ ⟹ False›*)) thus "?case" (*goal: ‹trg e = NewExit›*) by simp qed (simp_all) (*solves the remaining goals: 1. ‹⋀e. ⟦e = (NewEntry, (λs. True)⇩√, Node Entry); src e = Node Exit⟧ ⟹ trg e = NewExit› 2. ‹⋀e. ⟦e = (Node Exit, (λs. True)⇩√, NewExit); src e = Node Exit⟧ ⟹ trg e = NewExit› 3. ‹⋀e. ⟦e = (NewEntry, (λs. False)⇩√, NewExit); src e = Node Exit⟧ ⟹ trg e = NewExit›*) next (*goals: 1. ‹lDef (Node Entry) = H› 2. ‹lUse (Node Entry) = H› 3. ‹lUse (Node Exit) = L› 4. ‹H ∩ L = {}› 5. ‹H ∪ L = UNIV›*) from lDef (*‹lDef ≡ lift_Def Def Entry Exit H L›*) show "lDef (Node Entry) = H" by (fastforce elim:lift_Def_set.cases (*‹⟦(?a1.0::?'node::type LDCFG_node, ?a2.0::?'var::type) ∈ lift_Def_set (?Def::?'node::type ⇒ ?'var::type set) (?E::?'node::type) (?X::?'node::type) (?H::?'var::type set) (?L::?'var::type set); ⋀(V::?'var::type) n::?'node::type. ⟦?a1.0 = Node n; ?a2.0 = V; V ∈ ?Def n⟧ ⟹ ?P::bool; ⋀V::?'var::type. ⟦?a1.0 = Node ?E; ?a2.0 = V; V ∈ ?H⟧ ⟹ ?P⟧ ⟹ ?P›*) intro:lift_Def_High (*‹(?V::?'var::type) ∈ (?H::?'var::type set) ⟹ (Node (?E::?'node::type), ?V) ∈ lift_Def_set (?Def::?'node::type ⇒ ?'var::type set) ?E (?X::?'node::type) ?H (?L::?'var::type set)›*)) next (*goals: 1. ‹lUse (Node Entry) = H› 2. ‹lUse (Node Exit) = L› 3. ‹H ∩ L = {}› 4. ‹H ∪ L = UNIV›*) from Entry_noteq_Exit (*‹Entry = Exit ⟹ False›*) lUse (*‹lUse::'a LDCFG_node ⇒ 'b set ≡ lift_Use (Use::'a ⇒ 'b set) (Entry::'a) (Exit::'a) (H::'b set) (L::'b set)›*) show "lUse (Node Entry) = H" by (fastforce elim:lift_Use_set.cases (*‹⟦(?a1.0, ?a2.0) ∈ lift_Use_set ?Use ?E ?X ?H ?L; ⋀V n. ⟦?a1.0 = Node n; ?a2.0 = V; V ∈ ?Use n⟧ ⟹ ?P; ⋀V. ⟦?a1.0 = Node ?E; ?a2.0 = V; V ∈ ?H⟧ ⟹ ?P; ⋀V. ⟦?a1.0 = Node ?X; ?a2.0 = V; V ∈ ?L⟧ ⟹ ?P⟧ ⟹ ?P›*) intro:lift_Use_High (*‹?V ∈ ?H ⟹ (Node ?E, ?V) ∈ lift_Use_set ?Use ?E ?X ?H ?L›*)) next (*goals: 1. ‹lUse (Node Exit) = L› 2. ‹H ∩ L = {}› 3. ‹H ∪ L = UNIV›*) from Entry_noteq_Exit (*‹Entry = Exit ⟹ False›*) lUse (*‹lUse ≡ lift_Use Use Entry Exit H L›*) show "lUse (Node Exit) = L" by (fastforce elim:lift_Use_set.cases (*‹⟦(?a1.0, ?a2.0) ∈ lift_Use_set ?Use ?E ?X ?H ?L; ⋀V n. ⟦?a1.0 = Node n; ?a2.0 = V; V ∈ ?Use n⟧ ⟹ ?P; ⋀V. ⟦?a1.0 = Node ?E; ?a2.0 = V; V ∈ ?H⟧ ⟹ ?P; ⋀V. ⟦?a1.0 = Node ?X; ?a2.0 = V; V ∈ ?L⟧ ⟹ ?P⟧ ⟹ ?P›*) intro:lift_Use_Low (*‹?V ∈ ?L ⟹ (Node ?X, ?V) ∈ lift_Use_set ?Use ?E ?X ?H ?L›*)) next (*goals: 1. ‹(H::'b set) ∩ (L::'b set) = {}› 2. ‹(H::'b set) ∪ (L::'b set) = UNIV›*) from ‹H ∩ L = {}› (*‹H ∩ L = {}›*) show "H ∩ L = {}" . next (*goal: ‹H ∪ L = UNIV›*) from ‹H ∪ L = UNIV› (*‹(H::'b set) ∪ (L::'b set) = UNIV›*) show "H ∪ L = UNIV" . qed qed end
{ "path": "afp-2025-02-12/thys/InformationFlowSlicing_Inter/LiftingInter.thy", "repo": "afp-2025-02-12", "sha": "1fe5c495a3fd478911af53a26606370366bbc5d4c45dfdf7d8aebad04ab9b99c" }
section ‹General Priority Search Trees› theory PST_General imports "HOL-Data_Structures.Tree2" Prio_Map_Specs begin text ‹\noindent We show how to implement priority maps by augmented binary search trees. That is, the basic data structure is some arbitrary binary search tree, e.g.\ a red-black tree, implementing the map from @{typ 'a} to @{typ 'b} by storing pairs ‹(k,p)› in each node. At this point we need to assume that the keys are also linearly ordered. To implement ‹getmin› efficiently we annotate/augment each node with another pair ‹(k',p')›, the intended result of ‹getmin› when applied to that subtree. The specification of ‹getmin› tells us that ‹(k',p')› must be in that subtree and that ‹p'› is the minimal priority in that subtree. Thus the annotation can be computed by passing the ‹(k',p')› with the minimal ‹p'› up the tree. We will now make this more precise for balanced binary trees in general. We assume that our trees are either leaves of the form @{term Leaf} or nodes of the form @{term "Node l (kp, b) r"} where ‹l› and ‹r› are subtrees, ‹kp› is the contents of the node (a key-priority pair) and ‹b› is some additional balance information (e.g.\ colour, height, size, \dots). Augmented nodes are of the form \<^term>‹Node l (kp, (b,kp')) r›. › type_synonym ('k,'p,'c) pstree = "(('k×'p) × ('c × ('k × 'p))) tree" text ‹ The following invariant states that a node annotation is actually a minimal key-priority pair for the node's subtree. › fun invpst :: "('k,'p::linorder,'c) pstree ⇒ bool" where "invpst Leaf = True" | "invpst (Node l (x, _,mkp) r) ⟷ invpst l ∧ invpst r ∧ is_min2 mkp (set (inorder l @ x # inorder r))" text ‹The implementation of ‹getmin› is trivial:› fun pst_getmin where "pst_getmin (Node _ (_, _,a) _) = a" lemma pst_getmin_ismin: "invpst t ⟹ t≠Leaf ⟹ is_min2 (pst_getmin t) (set_tree t)" apply (cases t rule: pst_getmin.cases (*‹⟦⋀uu_ uv_ uw_ a ux_. ?x = ⟨uu_, (uv_, uw_, a), ux_⟩ ⟹ ?P; ?x = ⟨⟩ ⟹ ?P⟧ ⟹ ?P›*)) (*goals: 1. ‹⋀uu_ uv_ uw_ a ux_. ⟦invpst t; t ≠ ⟨⟩; t = ⟨uu_, (uv_, uw_, a), ux_⟩⟧ ⟹ is_min2 (pst_getmin t) (Tree2.set_tree t)› 2. ‹⟦invpst t; t ≠ ⟨⟩; t = ⟨⟩⟧ ⟹ is_min2 (pst_getmin t) (Tree2.set_tree t)› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . text ‹ It remains to upgrade the existing map operations to work with augmented nodes. Therefore we now show how to transform any function definition on un-augmented trees into one on trees augmented with ‹(k',p')› pairs. A defining equation ‹f pats = e› for the original type of nodes is transformed into an equation ‹f pats' = e'› on the augmented type of nodes as follows: ▪ Every pattern @{term "Node l (kp, b) r"} in ‹pats› and ‹e› is replaced by @{term "Node l (kp, (b,DUMMY)) r"} to obtain ‹pats'› and ‹e₂›. ▪ To obtain ‹e'›, every expression @{term "Node l (kp, b) r"} in ‹e₂› is replaced by ‹mkNode l kp b r› where: › definition "min2 ≡ λ(k,p) (k',p'). if p≤p' then (k,p) else (k',p')" definition "min_kp a l r ≡ case (l,r) of (Leaf,Leaf) ⇒ a | (Leaf,Node _ (_, (_,kpr)) _) ⇒ min2 a kpr | (Node _ (_, (_,kpl)) _,Leaf) ⇒ min2 a kpl | (Node _ (_, (_,kpl)) _,Node _ (_, (_,kpr)) _) ⇒ min2 a (min2 kpl kpr)" definition "mkNode c l a r ≡ Node l (a, (c,min_kp a l r)) r" text ‹ Note that this transformation does not affect the asymptotic complexity of ‹f›. Therefore the priority search tree operations have the same complexity as the underlying search tree operations, i.e.\ typically logarithmic (‹update›, ‹delete›, ‹lookup›) and constant time (‹empty›, ‹is_empty›). › text ‹It is straightforward to show that @{const mkNode} preserves the invariant:› lemma is_min2_Empty[simp]: "¬is_min2 x {}" by (auto simp: is_min2_def (*‹is_min2 ?x ?xs ≡ ?x ∈ ?xs ∧ (∀y∈?xs. snd ?x ≤ snd y)›*)) lemma is_min2_singleton[simp]: "is_min2 a {b} ⟷ b=a" by (auto simp: is_min2_def (*‹is_min2 ?x ?xs ≡ ?x ∈ ?xs ∧ (∀y∈?xs. snd ?x ≤ snd y)›*)) lemma is_min2_insert: "is_min2 x (insert y ys) ⟷ (y=x ∧ (∀z∈ys. snd x ≤ snd z)) ∨ (snd x ≤ snd y ∧ is_min2 x ys)" by (auto simp: is_min2_def (*‹is_min2 ?x ?xs ≡ ?x ∈ ?xs ∧ (∀y∈?xs. snd ?x ≤ snd y)›*)) lemma is_min2_union: "is_min2 x (ys ∪ zs) ⟷ (is_min2 x ys ∧ (∀z∈zs. snd x ≤ snd z)) ∨ ((∀y∈ys. snd x ≤ snd y) ∧ is_min2 x zs)" by (auto simp: is_min2_def (*‹is_min2 (?x::?'b × ?'a) (?xs::(?'b × ?'a) set) ≡ ?x ∈ ?xs ∧ (∀y::?'b × ?'a∈?xs. snd ?x ≤ snd y)›*)) lemma is_min2_min2_insI: "is_min2 y ys ⟹ is_min2 (min2 x y) (insert x ys)" by (auto simp: is_min2_def (*‹is_min2 ?x ?xs ≡ ?x ∈ ?xs ∧ (∀y∈?xs. snd ?x ≤ snd y)›*) min2_def (*‹min2 ≡ λ(k, p) (k', p'). if p ≤ p' then (k, p) else (k', p')›*) split: prod.split (*‹?P (case ?prod of (x, xa) ⇒ ?f x xa) = (∀x1 x2. ?prod = (x1, x2) ⟶ ?P (?f x1 x2))›*)) lemma is_min2_mergeI: "is_min2 x xs ⟹ is_min2 y ys ⟹ is_min2 (min2 x y) (xs ∪ ys)" by (auto simp: is_min2_def (*‹is_min2 ?x ?xs ≡ ?x ∈ ?xs ∧ (∀y∈?xs. snd ?x ≤ snd y)›*) min2_def (*‹min2 ≡ λ(k, p) (k', p'). if p ≤ p' then (k, p) else (k', p')›*) split: prod.split (*‹?P (case ?prod of (x, xa) ⇒ ?f x xa) = (∀x1 x2. ?prod = (x1, x2) ⟶ ?P (?f x1 x2))›*)) theorem invpst_mkNode[simp]: "invpst (mkNode c l a r) ⟷ invpst l ∧ invpst r" apply (cases l rule: invpst.cases (*‹⟦?x = ⟨⟩ ⟹ ?P; ⋀l x uu_ mkp r. ?x = ⟨l, (x, uu_, mkp), r⟩ ⟹ ?P⟧ ⟹ ?P›*); cases r rule: invpst.cases (*‹⟦?x = ⟨⟩ ⟹ ?P; ⋀l x uu_ mkp r. ?x = ⟨l, (x, uu_, mkp), r⟩ ⟹ ?P⟧ ⟹ ?P›*); simp add: mkNode_def (*‹mkNode (?c::?'c::type) (?l::((?'a::type × ?'b::ord) × ?'c::type × ?'a::type × ?'b::ord) tree) (?a::?'a::type × ?'b::ord) (?r::((?'a::type × ?'b::ord) × ?'c::type × ?'a::type × ?'b::ord) tree) ≡ ⟨?l, (?a, ?c, min_kp ?a ?l ?r), ?r⟩›*) min_kp_def (*‹min_kp (?a::?'a::type × ?'b::ord) (?l::(?'c::type × ?'d::type × ?'a::type × ?'b::ord) tree) (?r::(?'e::type × ?'f::type × ?'a::type × ?'b::ord) tree) ≡ case (?l, ?r) of (⟨⟩, ⟨⟩) ⇒ ?a | (⟨⟩, ⟨x::(?'e::type × ?'f::type × ?'a::type × ?'b::ord) tree, (xa::?'e::type, xb::?'f::type, kpr::?'a::type × ?'b::ord), xc::(?'e::type × ?'f::type × ?'a::type × ?'b::ord) tree⟩) ⇒ min2 ?a kpr | (⟨x::(?'c::type × ?'d::type × ?'a::type × ?'b::ord) tree, (xa::?'c::type, xb::?'d::type, kpl::?'a::type × ?'b::ord), xc::(?'c::type × ?'d::type × ?'a::type × ?'b::ord) tree⟩, ⟨⟩) ⇒ min2 ?a kpl | (⟨x::(?'c::type × ?'d::type × ?'a::type × ?'b::ord) tree, (xa::?'c::type, xb::?'d::type, kpl::?'a::type × ?'b::ord), xc::(?'c::type × ?'d::type × ?'a::type × ?'b::ord) tree⟩, ⟨xd::(?'e::type × ?'f::type × ?'a::type × ?'b::ord) tree, (xe::?'e::type, xf::?'f::type, kpr::?'a::type × ?'b::ord), xg::(?'e::type × ?'f::type × ?'a::type × ?'b::ord) tree⟩) ⇒ min2 ?a (min2 kpl kpr)›*)) (*goal: ‹invpst (mkNode c l a r) = (invpst l ∧ invpst r)›*) subgoal for using is_min2_min2_insI (*‹is_min2 ?y ?ys ⟹ is_min2 (min2 ?x ?y) (insert ?x ?ys)›*) by blast subgoal for by (auto intro!: is_min2_min2_insI (*‹is_min2 ?y ?ys ⟹ is_min2 (min2 ?x ?y) (insert ?x ?ys)›*) simp: insert_commute (*‹insert ?x (insert ?y ?A) = insert ?y (insert ?x ?A)›*)) subgoal for by (smt Un_insert_left (*‹insert ?a ?B ∪ ?C = insert ?a (?B ∪ ?C)›*) Un_insert_right (*‹?A ∪ insert ?a ?B = insert ?a (?A ∪ ?B)›*) is_min2_mergeI (*‹⟦is_min2 ?x ?xs; is_min2 ?y ?ys⟧ ⟹ is_min2 (min2 ?x ?y) (?xs ∪ ?ys)›*) is_min2_min2_insI (*‹is_min2 ?y ?ys ⟹ is_min2 (min2 ?x ?y) (insert ?x ?ys)›*) sup_assoc (*‹sup (sup ?x ?y) ?z = sup ?x (sup ?y ?z)›*)) . end
{ "path": "afp-2025-02-12/thys/Priority_Search_Trees/PST_General.thy", "repo": "afp-2025-02-12", "sha": "39ccd27b89f9b0102b8f4c5cf791ac8645223d15c79092ef1ba35bb2b2790c47" }
(* Author: René Thiemann Akihisa Yamada License: BSD *) subsection ‹Compare Instance for Complex Numbers› text ‹We define some code equations for complex numbers, provide a comparator for complex numbers, and register complex numbers for the container framework.› theory Compare_Complex imports HOL.Complex Polynomial_Interpolation.Missing_Unsorted Deriving.Compare_Real Containers.Set_Impl begin declare [[code drop: Gcd_fin]] declare [[code drop: Lcm_fin]] definition gcds :: "'a::semiring_gcd list ⇒ 'a" where [simp, code_abbrev]: "gcds xs = gcd_list xs" lemma [code]: "gcds xs = fold gcd xs 0" by (simp add: Gcd_fin.set_eq_fold (*‹gcd_list (?xs::?'a list) = fold gcd ?xs (0::?'a)›*)) definition lcms :: "'a::semiring_gcd list ⇒ 'a" where [simp, code_abbrev]: "lcms xs = lcm_list xs" lemma [code]: "lcms xs = fold lcm xs 1" by (simp add: Lcm_fin.set_eq_fold (*‹lcm_list ?xs = fold lcm ?xs 1›*)) lemma in_reals_code [code_unfold]: "x ∈ ℝ ⟷ Im x = 0" by (fact complex_is_Real_iff (*‹((?z::complex) ∈ ℝ) = (Im ?z = (0::real))›*)) definition is_norm_1 :: "complex ⇒ bool" where "is_norm_1 z = ((Re z)² + (Im z)² = 1)" lemma is_norm_1[simp]: "is_norm_1 x = (norm x = 1)" unfolding is_norm_1_def norm_complex_def (*goal: ‹((Re x)² + (Im x)² = 1) = (sqrt ((Re x)² + (Im x)²) = 1)›*) by simp definition is_norm_le_1 :: "complex ⇒ bool" where "is_norm_le_1 z = ((Re z)² + (Im z)² ≤ 1)" lemma is_norm_le_1[simp]: "is_norm_le_1 x = (norm x ≤ 1)" unfolding is_norm_le_1_def norm_complex_def (*goal: ‹((Re x)² + (Im x)² ≤ 1) = (sqrt ((Re x)² + (Im x)²) ≤ 1)›*) by simp instantiation complex :: finite_UNIV begin definition "finite_UNIV = Phantom(complex) False" instance by (intro_classes, unfold finite_UNIV_complex_def, simp add: infinite_UNIV_char_0) end instantiation complex :: compare begin definition compare_complex :: "complex ⇒ complex ⇒ order" where "compare_complex x y = compare (Re x, Im x) (Re y, Im y)" instance proof (intro_classes, unfold_locales; unfold compare_complex_def) fix x y z :: complex let ?c = "compare :: (real × real) comparator" interpret comparator ?c by (rule comparator_compare) show "invert_order (?c (Re x, Im x) (Re y, Im y)) = ?c (Re y, Im y) (Re x, Im x)" by (rule sym) { assume "?c (Re x, Im x) (Re y, Im y) = Lt" "?c (Re y, Im y) (Re z, Im z) = Lt" thus "?c (Re x, Im x) (Re z, Im z) = Lt" by (rule comp_trans) } { assume "?c (Re x, Im x) (Re y, Im y) = Eq" from weak_eq[OF this] show "x = y" unfolding complex_eq_iff by auto } qed end derive (eq) ceq complex real derive (compare) ccompare complex derive (compare) ccompare real derive (dlist) set_impl complex real end
{ "path": "afp-2025-02-12/thys/Algebraic_Numbers/Compare_Complex.thy", "repo": "afp-2025-02-12", "sha": "a62481e902411d30dd04e568f52de3dbbfaf0062a9aa24ccfc300887dc226b77" }
theory SINVAR_BLPtrusted imports "../TopoS_Helper" begin subsection ‹SecurityInvariant Basic Bell LaPadula with trusted entities› type_synonym security_level = nat record node_config = security_level::security_level trusted::bool definition default_node_properties :: "node_config" where "default_node_properties ≡ ⦇ security_level = 0, trusted = False ⦈" fun sinvar :: "'v graph ⇒ ('v ⇒ node_config) ⇒ bool" where "sinvar G nP = (∀ (e1,e2) ∈ edges G. (if trusted (nP e2) then True else security_level (nP e1) ≤ security_level (nP e2) ))" text‹A simplified version of the Bell LaPadula model was presented in @{file ‹SINVAR_BLPbasic.thy›}. In this theory, we extend this template with a notion of trust by adding a Boolean flag @{const trusted} to the host attributes. This is a refinement to represent real-world scenarios more accurately and analogously happened to the original Bell LaPadula model (see publication ``Looking Back at the Bell-La Padula Model'' A trusted host can receive information of any security level and may declassify it, i.e. distribute the information with its own security level. For example, a @{term "trusted (sc::node_config) = True"} host is allowed to receive any information and with the @{term "0::security_level"} level, it is allowed to reveal it to anyone. › definition receiver_violation :: "bool" where "receiver_violation ≡ True" lemma sinvar_mono: "SecurityInvariant_withOffendingFlows.sinvar_mono sinvar" apply (simp only: SecurityInvariant_withOffendingFlows.sinvar_mono_def (*‹SecurityInvariant_withOffendingFlows.sinvar_mono ?sinvar = (∀nP N E' E. wf_graph ⦇nodes = N, edges = E⦈ ∧ E' ⊆ E ∧ ?sinvar ⦇nodes = N, edges = E⦈ nP ⟶ ?sinvar ⦇nodes = N, edges = E'⦈ nP)›*)) (*goal: ‹SecurityInvariant_withOffendingFlows.sinvar_mono sinvar›*) apply clarify (*goal: ‹∀nP N E' E. wf_graph ⦇nodes = N, edges = E⦈ ∧ E' ⊆ E ∧ sinvar ⦇nodes = N, edges = E⦈ nP ⟶ sinvar ⦇nodes = N, edges = E'⦈ nP›*) apply (simp split: prod.split (*‹(?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))›*) prod.split_asm (*‹(?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))›*)) (*goal: ‹⋀nP N E' E. ⟦wf_graph ⦇nodes = N, edges = E⦈; E' ⊆ E; sinvar ⦇nodes = N, edges = E⦈ nP⟧ ⟹ sinvar ⦇nodes = N, edges = E'⦈ nP›*) by auto interpretation SecurityInvariant_preliminaries where sinvar = sinvar apply unfold_locales (*goals: 1. ‹⋀G nP. ⟦wf_graph G; ¬ sinvar G nP⟧ ⟹ SecurityInvariant_withOffendingFlows.set_offending_flows sinvar G nP ≠ {}› 2. ‹⋀N E E' nP. ⟦wf_graph ⦇nodes = N, edges = E⦈; E' ⊆ E; sinvar ⦇nodes = N, edges = E⦈ nP⟧ ⟹ sinvar ⦇nodes = N, edges = E'⦈ nP› 3. ‹⋀G ff nP f'. ⟦wf_graph G; SecurityInvariant_withOffendingFlows.is_offending_flows sinvar ff G nP⟧ ⟹ SecurityInvariant_withOffendingFlows.is_offending_flows sinvar (ff ∪ f') G nP› discuss goal 1*) apply (frule_tac finite_distinct_list[OF wf_graph.finiteE] (*‹wf_graph (?G1::?'v1 graph) ⟹ ∃xs::(?'v1 × ?'v1) list. set xs = edges ?G1 ∧ distinct xs›*)) (*top goal: ‹⋀G nP. ⟦wf_graph G; ¬ sinvar G nP⟧ ⟹ SecurityInvariant_withOffendingFlows.set_offending_flows sinvar G nP ≠ {}› and 2 goals remain*) apply (erule_tac exE (*‹⟦∃x. ?P x; ⋀x. ?P x ⟹ ?Q⟧ ⟹ ?Q›*)) (*top goal: ‹⋀G nP. ⟦wf_graph G; ¬ sinvar G nP; ∃xs. set xs = edges G ∧ distinct xs⟧ ⟹ SecurityInvariant_withOffendingFlows.set_offending_flows sinvar G nP ≠ {}› and 2 goals remain*) apply (rename_tac list_edges) (*top goal: ‹⋀G nP xs. ⟦wf_graph G; ¬ sinvar G nP; set xs = edges G ∧ distinct xs⟧ ⟹ SecurityInvariant_withOffendingFlows.set_offending_flows sinvar G nP ≠ {}› and 2 goals remain*) apply (rule_tac ff="list_edges" in SecurityInvariant_withOffendingFlows.mono_imp_set_offending_flows_not_empty[OF sinvar_mono] (*‹⟦wf_graph (?G::?'v graph); SecurityInvariant_withOffendingFlows.is_offending_flows sinvar (set (?ff::(?'v::vertex × ?'v::vertex) list)) ?G (?nP::?'v::vertex ⇒ node_config); set ?ff ⊆ edges ?G; distinct ?ff⟧ ⟹ SecurityInvariant_withOffendingFlows.set_offending_flows sinvar ?G ?nP ≠ {}›*)) (*goals: 1. ‹⋀G nP list_edges. ⟦wf_graph G; ¬ sinvar G nP; set list_edges = edges G ∧ distinct list_edges⟧ ⟹ wf_graph G› 2. ‹⋀G nP list_edges. ⟦wf_graph G; ¬ sinvar G nP; set list_edges = edges G ∧ distinct list_edges⟧ ⟹ SecurityInvariant_withOffendingFlows.is_offending_flows sinvar (set list_edges) G nP› 3. ‹⋀G nP list_edges. ⟦wf_graph G; ¬ sinvar G nP; set list_edges = edges G ∧ distinct list_edges⟧ ⟹ set list_edges ⊆ edges G› 4. ‹⋀G nP list_edges. ⟦wf_graph G; ¬ sinvar G nP; set list_edges = edges G ∧ distinct list_edges⟧ ⟹ distinct list_edges› discuss goal 1*) apply ((auto 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))›*) prod.split_asm (*‹(?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 split: prod.split (*‹?P (case ?prod of (x, xa) ⇒ ?f x xa) = (∀x1 x2. ?prod = (x1, x2) ⟶ ?P (?f x1 x2))›*) prod.split_asm (*‹?P (case ?prod of (x, xa) ⇒ ?f x xa) = (∄x1 x2. ?prod = (x1, x2) ∧ ¬ ?P (?f x1 x2))›*))[1]) (*top goal: ‹⋀(G::'a graph) (nP::'a::vertex ⇒ node_config) list_edges::('a::vertex × 'a::vertex) list. ⟦wf_graph G; ¬ sinvar G nP; set list_edges = edges G ∧ distinct list_edges⟧ ⟹ SecurityInvariant_withOffendingFlows.is_offending_flows sinvar (set list_edges) G nP› and 4 goals remain*) apply (simp add: SecurityInvariant_withOffendingFlows.is_offending_flows_def (*‹SecurityInvariant_withOffendingFlows.is_offending_flows ?sinvar ?f ?G ?nP ≡ ¬ ?sinvar ?G ?nP ∧ ?sinvar (delete_edges ?G ?f) ?nP›*) graph_ops (*‹add_node ?v ?G ≡ ⦇nodes = {?v} ∪ nodes ?G, edges = edges ?G⦈› ‹delete_node ?v ?G ≡ ⦇nodes = nodes ?G - {?v}, edges = {(e1, e2). (e1, e2) ∈ edges ?G ∧ e1 ≠ ?v ∧ e2 ≠ ?v}⦈› ‹add_edge ?v ?v' ?G = ⦇nodes = nodes ?G ∪ {?v, ?v'}, edges = {(?v, ?v')} ∪ edges ?G⦈› ‹delete_edge ?v ?v' ?G ≡ ⦇nodes = nodes ?G, edges = {(e1, e2). (e1, e2) ∈ edges ?G ∧ (e1, e2) ≠ (?v, ?v')}⦈› ‹delete_edges ?G ?E = ⦇nodes = nodes ?G, edges = edges ?G - ?E⦈›*) split: prod.split (*‹?P (case ?prod of (x, xa) ⇒ ?f x xa) = (∀x1 x2. ?prod = (x1, x2) ⟶ ?P (?f x1 x2))›*) prod.split_asm (*‹?P (case ?prod of (x, xa) ⇒ ?f x xa) = (∄x1 x2. ?prod = (x1, x2) ∧ ¬ ?P (?f x1 x2))›*)) (*top goal: ‹⋀(G::'a graph) (nP::'a ⇒ node_config) (list_edges::('a × 'a) list) (a::'a) b::'a. ⟦wf_graph G; set list_edges = edges G; distinct list_edges; (a, b) ∈ edges G; ¬ (if trusted (nP b) then True else security_level (nP a) ≤ security_level (nP b))⟧ ⟹ SecurityInvariant_withOffendingFlows.is_offending_flows sinvar (edges G) G nP› and 4 goals remain*) apply (metis prod.inject (*‹((?x1.0, ?x2.0) = (?y1.0, ?y2.0)) = (?x1.0 = ?y1.0 ∧ ?x2.0 = ?y2.0)›*)) (*discuss goal 3*) apply ((auto split: prod.split (*‹?P (case ?prod of (x, xa) ⇒ ?f x xa) = (∀x1 x2. ?prod = (x1, x2) ⟶ ?P (?f x1 x2))›*) prod.split_asm (*‹?P (case ?prod of (x, xa) ⇒ ?f x xa) = (∄x1 x2. ?prod = (x1, x2) ∧ ¬ ?P (?f x1 x2))›*))[1]) (*discuss goal 4*) apply ((auto split: prod.split (*‹?P (case ?prod of (x, xa) ⇒ ?f x xa) = (∀x1 x2. ?prod = (x1, x2) ⟶ ?P (?f x1 x2))›*) prod.split_asm (*‹?P (case ?prod of (x, xa) ⇒ ?f x xa) = (∄x1 x2. ?prod = (x1, x2) ∧ ¬ ?P (?f x1 x2))›*))[1]) (*proven 4 subgoals*) (*discuss goal 2*) apply ((auto split: prod.split (*‹?P (case ?prod of (x, xa) ⇒ ?f x xa) = (∀x1 x2. ?prod = (x1, x2) ⟶ ?P (?f x1 x2))›*) prod.split_asm (*‹?P (case ?prod of (x, xa) ⇒ ?f x xa) = (∄x1 x2. ?prod = (x1, x2) ∧ ¬ ?P (?f x1 x2))›*))[1]) (*discuss goal 3*) apply (fact SecurityInvariant_withOffendingFlows.sinvar_mono_imp_is_offending_flows_mono[OF sinvar_mono] (*‹⟦wf_graph ?G; SecurityInvariant_withOffendingFlows.is_offending_flows sinvar ?FF ?G ?nP⟧ ⟹ SecurityInvariant_withOffendingFlows.is_offending_flows sinvar (?FF ∪ ?F) ?G ?nP›*)) (*proven 3 subgoals*) . lemma "a ≠ b ⟹ ((∃ x. y x)) ⟹ ((∀ x. ¬ y x) ⟹ a = b )" by simp lemma BLP_def_unique: "otherbot ≠ default_node_properties ⟹ ∃G p i f. wf_graph G ∧ ¬ sinvar G p ∧ f ∈ (SecurityInvariant_withOffendingFlows.set_offending_flows sinvar G p) ∧ sinvar (delete_edges G f) p ∧ i ∈ snd ` f ∧ sinvar G (p(i := otherbot)) " apply (simp add:default_node_properties_def (*‹default_node_properties ≡ ⦇security_level = 0, trusted = False⦈›*)) (*goal: ‹otherbot ≠ default_node_properties ⟹ ∃G p i f. wf_graph G ∧ ¬ sinvar G p ∧ f ∈ set_offending_flows G p ∧ sinvar (delete_edges G f) p ∧ i ∈ snd ` f ∧ sinvar G (p(i := otherbot))›*) apply (simp add: SecurityInvariant_withOffendingFlows.set_offending_flows_def (*‹SecurityInvariant_withOffendingFlows.set_offending_flows ?sinvar ?G ?nP = {F. F ⊆ edges ?G ∧ SecurityInvariant_withOffendingFlows.is_offending_flows_min_set ?sinvar F ?G ?nP}›*) SecurityInvariant_withOffendingFlows.is_offending_flows_min_set_def (*‹SecurityInvariant_withOffendingFlows.is_offending_flows_min_set ?sinvar ?f ?G ?nP ≡ SecurityInvariant_withOffendingFlows.is_offending_flows ?sinvar ?f ?G ?nP ∧ (∀(e1, e2)∈?f. ¬ ?sinvar (add_edge e1 e2 (delete_edges ?G ?f)) ?nP)›*) SecurityInvariant_withOffendingFlows.is_offending_flows_def (*‹SecurityInvariant_withOffendingFlows.is_offending_flows ?sinvar ?f ?G ?nP ≡ ¬ ?sinvar ?G ?nP ∧ ?sinvar (delete_edges ?G ?f) ?nP›*)) (*goal: ‹otherbot ≠ ⦇security_level = 0, trusted = False⦈ ⟹ ∃G. wf_graph G ∧ (∃p. (∃x∈edges G. ¬ (case x of (e1, e2) ⇒ ¬ trusted (p e2) ⟶ security_level (p e1) ≤ security_level (p e2))) ∧ (∃i f. f ∈ set_offending_flows G p ∧ (∀x∈edges (delete_edges G f). case x of (e1, e2) ⇒ ¬ trusted (p e2) ⟶ security_level (p e1) ≤ security_level (p e2)) ∧ i ∈ snd ` f ∧ (∀x∈edges G. case x of (e1, e2) ⇒ (e2 = i ⟶ ¬ trusted otherbot ⟶ security_level (if e1 = i then otherbot else p e1) ≤ security_level otherbot) ∧ (e2 ≠ i ⟶ ¬ trusted (p e2) ⟶ security_level (if e1 = i then otherbot else p e1) ≤ security_level (p e2)))))›*) apply (simp add:graph_ops (*‹add_node ?v ?G ≡ ⦇nodes = {?v} ∪ nodes ?G, edges = edges ?G⦈› ‹delete_node ?v ?G ≡ ⦇nodes = nodes ?G - {?v}, edges = {(e1, e2). (e1, e2) ∈ edges ?G ∧ e1 ≠ ?v ∧ e2 ≠ ?v}⦈› ‹add_edge ?v ?v' ?G = ⦇nodes = nodes ?G ∪ {?v, ?v'}, edges = {(?v, ?v')} ∪ edges ?G⦈› ‹delete_edge ?v ?v' ?G ≡ ⦇nodes = nodes ?G, edges = {(e1, e2). (e1, e2) ∈ edges ?G ∧ (e1, e2) ≠ (?v, ?v')}⦈› ‹delete_edges ?G ?E = ⦇nodes = nodes ?G, edges = edges ?G - ?E⦈›*)) (*goal: ‹(otherbot::node_config) ≠ ⦇security_level = 0::nat, trusted = False⦈ ⟹ ∃G::'a graph. wf_graph G ∧ (∃p::'a::vertex ⇒ node_config. (∃x::'a::vertex × 'a::vertex∈edges G. ¬ (case x of (e1::'a::vertex, e2::'a::vertex) ⇒ ¬ trusted (p e2) ⟶ security_level (p e1) ≤ security_level (p e2))) ∧ (∃(i::'a::vertex) f::('a::vertex × 'a::vertex) set. f ⊆ edges G ∧ (∃x::'a::vertex × 'a::vertex∈edges G. ¬ (case x of (e1::'a::vertex, e2::'a::vertex) ⇒ ¬ trusted (p e2) ⟶ security_level (p e1) ≤ security_level (p e2))) ∧ (∀x::'a::vertex × 'a::vertex∈edges (delete_edges G f). case x of (e1::'a::vertex, e2::'a::vertex) ⇒ ¬ trusted (p e2) ⟶ security_level (p e1) ≤ security_level (p e2)) ∧ (∀x::'a::vertex × 'a::vertex∈f. case x of (e1::'a::vertex, e2::'a::vertex) ⇒ ∃x::'a::vertex × 'a::vertex∈edges (add_edge e1 e2 (delete_edges G f)). ¬ (case x of (e1::'a::vertex, e2a::'a::vertex) ⇒ ¬ trusted (p e2a) ⟶ security_level (p e1) ≤ security_level (p e2a))) ∧ (∀x::'a::vertex × 'a::vertex∈edges (delete_edges G f). case x of (e1::'a::vertex, e2::'a::vertex) ⇒ ¬ trusted (p e2) ⟶ security_level (p e1) ≤ security_level (p e2)) ∧ i ∈ snd ` f ∧ (∀x::'a::vertex × 'a::vertex∈edges G. case x of (e1::'a::vertex, e2::'a::vertex) ⇒ (e2 = i ⟶ ¬ trusted otherbot ⟶ security_level (if e1 = i then otherbot else p e1) ≤ security_level otherbot) ∧ (e2 ≠ i ⟶ ¬ trusted (p e2) ⟶ security_level (if e1 = i then otherbot else p e1) ≤ security_level (p e2)))))›*) apply (simp split: prod.split_asm (*‹?P (case ?prod of (x, xa) ⇒ ?f x xa) = (∄x1 x2. ?prod = (x1, x2) ∧ ¬ ?P (?f x1 x2))›*) prod.split (*‹?P (case ?prod of (x, xa) ⇒ ?f x xa) = (∀x1 x2. ?prod = (x1, x2) ⟶ ?P (?f x1 x2))›*)) (*goal: ‹otherbot ≠ ⦇security_level = 0, trusted = False⦈ ⟹ ∃G. wf_graph G ∧ (∃p. (∃x∈edges G. ¬ (case x of (e1, e2) ⇒ ¬ trusted (p e2) ⟶ security_level (p e1) ≤ security_level (p e2))) ∧ (∃i f. f ⊆ edges G ∧ (∃x∈edges G. ¬ (case x of (e1, e2) ⇒ ¬ trusted (p e2) ⟶ security_level (p e1) ≤ security_level (p e2))) ∧ (∀x∈edges G - f. case x of (e1, e2) ⇒ ¬ trusted (p e2) ⟶ security_level (p e1) ≤ security_level (p e2)) ∧ (∀x∈f. case x of (e1, e2) ⇒ ¬ trusted (p e2) ∧ ¬ security_level (p e1) ≤ security_level (p e2) ∨ (∃x∈edges G - f. ¬ (case x of (e1, e2a) ⇒ ¬ trusted (p e2a) ⟶ security_level (p e1) ≤ security_level (p e2a)))) ∧ (∀x∈edges G - f. case x of (e1, e2) ⇒ ¬ trusted (p e2) ⟶ security_level (p e1) ≤ security_level (p e2)) ∧ i ∈ snd ` f ∧ (∀x∈edges G. case x of (e1, e2) ⇒ (e2 = i ⟶ ¬ trusted otherbot ⟶ security_level (if e1 = i then otherbot else p e1) ≤ security_level otherbot) ∧ (e2 ≠ i ⟶ ¬ trusted (p e2) ⟶ security_level (if e1 = i then otherbot else p e1) ≤ security_level (p e2)))))›*) apply (rule_tac x="⦇ nodes={vertex_1, vertex_2}, edges = {(vertex_1,vertex_2)} ⦈" in exI (*‹(?P::?'a ⇒ bool) (?x::?'a) ⟹ ∃x::?'a. ?P x›*)) (*goal: ‹(otherbot::node_config) ≠ ⦇security_level = 0::nat, trusted = False⦈ ⟹ ∃G::'a graph. wf_graph G ∧ (∃p::'a::vertex ⇒ node_config. (∃x::'a::vertex × 'a::vertex∈edges G. ∀(x1::'a::vertex) x2::'a::vertex. x = (x1, x2) ⟶ ¬ trusted (p x2) ∧ ¬ security_level (p x1) ≤ security_level (p x2)) ∧ (∃(i::'a::vertex) f::('a::vertex × 'a::vertex) set. f ⊆ edges G ∧ (∃x::'a::vertex × 'a::vertex∈edges G. ∀(x1::'a::vertex) x2::'a::vertex. x = (x1, x2) ⟶ ¬ trusted (p x2) ∧ ¬ security_level (p x1) ≤ security_level (p x2)) ∧ (∀x::'a::vertex × 'a::vertex∈edges G - f. ∀(x1::'a::vertex) x2::'a::vertex. x = (x1, x2) ⟶ ¬ trusted (p x2) ⟶ security_level (p x1) ≤ security_level (p x2)) ∧ (∀x::'a::vertex × 'a::vertex∈f. ∀(x1::'a::vertex) x2::'a::vertex. x = (x1, x2) ⟶ ¬ trusted (p x2) ∧ ¬ security_level (p x1) ≤ security_level (p x2) ∨ (∃x::'a::vertex × 'a::vertex∈edges G - f. ∀(x1::'a::vertex) x2::'a::vertex. x = (x1, x2) ⟶ ¬ trusted (p x2) ∧ ¬ security_level (p x1) ≤ security_level (p x2))) ∧ (∀x::'a::vertex × 'a::vertex∈edges G - f. ∀(x1::'a::vertex) x2::'a::vertex. x = (x1, x2) ⟶ ¬ trusted (p x2) ⟶ security_level (p x1) ≤ security_level (p x2)) ∧ i ∈ snd ` f ∧ (∀x::'a::vertex × 'a::vertex∈edges G. ∀x1::'a::vertex. (x1 = i ⟶ (∀x2::'a::vertex. x = (i, x2) ⟶ x2 ≠ i ⟶ ¬ trusted (p x2) ⟶ security_level otherbot ≤ security_level (p x2))) ∧ (x1 ≠ i ⟶ (∀x2::'a::vertex. x = (x1, x2) ⟶ (x2 = i ⟶ ¬ trusted otherbot ⟶ security_level (p x1) ≤ security_level otherbot) ∧ (x2 ≠ i ⟶ ¬ trusted (p x2) ⟶ security_level (p x1) ≤ security_level (p x2)))))))›*) apply simp (*goal: ‹otherbot ≠ ⦇security_level = 0, trusted = False⦈ ⟹ wf_graph ⦇nodes = {vertex_1, vertex_2}, edges = {(vertex_1, vertex_2)}⦈ ∧ (∃p. (∃x∈edges ⦇nodes = {vertex_1, vertex_2}, edges = {(vertex_1, vertex_2)}⦈. ∀x1 x2. x = (x1, x2) ⟶ ¬ trusted (p x2) ∧ ¬ security_level (p x1) ≤ security_level (p x2)) ∧ (∃i f. f ⊆ edges ⦇nodes = {vertex_1, vertex_2}, edges = {(vertex_1, vertex_2)}⦈ ∧ (∃x∈edges ⦇nodes = {vertex_1, vertex_2}, edges = {(vertex_1, vertex_2)}⦈. ∀x1 x2. x = (x1, x2) ⟶ ¬ trusted (p x2) ∧ ¬ security_level (p x1) ≤ security_level (p x2)) ∧ (∀x∈edges ⦇nodes = {vertex_1, vertex_2}, edges = {(vertex_1, vertex_2)}⦈ - f. ∀x1 x2. x = (x1, x2) ⟶ ¬ trusted (p x2) ⟶ security_level (p x1) ≤ security_level (p x2)) ∧ (∀x∈f. ∀x1 x2. x = (x1, x2) ⟶ ¬ trusted (p x2) ∧ ¬ security_level (p x1) ≤ security_level (p x2) ∨ (∃x∈edges ⦇nodes = {vertex_1, vertex_2}, edges = {(vertex_1, vertex_2)}⦈ - f. ∀x1 x2. x = (x1, x2) ⟶ ¬ trusted (p x2) ∧ ¬ security_level (p x1) ≤ security_level (p x2))) ∧ (∀x∈edges ⦇nodes = {vertex_1, vertex_2}, edges = {(vertex_1, vertex_2)}⦈ - f. ∀x1 x2. x = (x1, x2) ⟶ ¬ trusted (p x2) ⟶ security_level (p x1) ≤ security_level (p x2)) ∧ i ∈ snd ` f ∧ (∀x∈edges ⦇nodes = {vertex_1, vertex_2}, edges = {(vertex_1, vertex_2)}⦈. ∀x1. (x1 = i ⟶ (∀x2. x = (i, x2) ⟶ x2 ≠ i ⟶ ¬ trusted (p x2) ⟶ security_level otherbot ≤ security_level (p x2))) ∧ (x1 ≠ i ⟶ (∀x2. x = (x1, x2) ⟶ (x2 = i ⟶ ¬ trusted otherbot ⟶ security_level (p x1) ≤ security_level otherbot) ∧ (x2 ≠ i ⟶ ¬ trusted (p x2) ⟶ security_level (p x1) ≤ security_level (p x2)))))))›*) apply (rule conjI (*‹⟦?P::bool; ?Q::bool⟧ ⟹ ?P ∧ ?Q›*)) (*goals: 1. ‹otherbot ≠ ⦇security_level = 0, trusted = False⦈ ⟹ wf_graph ⦇nodes = {vertex_1, vertex_2}, edges = {(vertex_1, vertex_2)}⦈› 2. ‹otherbot ≠ ⦇security_level = 0, trusted = False⦈ ⟹ ∃p. ¬ trusted (p vertex_2) ∧ ¬ security_level (p vertex_1) ≤ security_level (p vertex_2) ∧ (∃i f. f ⊆ {(vertex_1, vertex_2)} ∧ ¬ trusted (p vertex_2) ∧ ¬ security_level (p vertex_1) ≤ security_level (p vertex_2) ∧ ((vertex_1, vertex_2) ∉ f ⟶ ¬ trusted (p vertex_2) ⟶ security_level (p vertex_1) ≤ security_level (p vertex_2)) ∧ (∀x∈f. ∀x1 x2. x = (x1, x2) ⟶ ¬ trusted (p x2) ∧ ¬ security_level (p x1) ≤ security_level (p x2) ∨ (vertex_1, vertex_2) ∉ f ∧ ¬ trusted (p vertex_2) ∧ ¬ security_level (p vertex_1) ≤ security_level (p vertex_2)) ∧ ((vertex_1, vertex_2) ∉ f ⟶ ¬ trusted (p vertex_2) ⟶ security_level (p vertex_1) ≤ security_level (p vertex_2)) ∧ i ∈ snd ` f ∧ (∀x1. (x1 = i ⟶ vertex_1 = i ⟶ ¬ trusted (p vertex_2) ⟶ security_level otherbot ≤ security_level (p vertex_2)) ∧ (x1 ≠ i ⟶ vertex_1 = x1 ⟶ (vertex_2 = i ⟶ ¬ trusted otherbot ⟶ security_level (p vertex_1) ≤ security_level otherbot) ∧ (vertex_2 ≠ i ⟶ ¬ trusted (p vertex_2) ⟶ security_level (p vertex_1) ≤ security_level (p vertex_2)))))› discuss goal 1*) apply (simp add: wf_graph_def (*‹wf_graph ?G ≡ (fst ` edges ?G ⊆ nodes ?G ∧ snd ` edges ?G ⊆ nodes ?G) ∧ finite (edges ?G) ∧ finite (nodes ?G)›*)) (*discuss goal 2*) apply (rule_tac x="(λ x. default_node_properties)(vertex_1 := ⦇security_level = 1, trusted = False ⦈, vertex_2 := ⦇security_level = 0, trusted = False ⦈)" in exI (*‹(?P::?'a ⇒ bool) (?x::?'a) ⟹ ∃x::?'a. ?P x›*)) (*goal: ‹otherbot ≠ ⦇security_level = 0, trusted = False⦈ ⟹ ∃p. ¬ trusted (p vertex_2) ∧ ¬ security_level (p vertex_1) ≤ security_level (p vertex_2) ∧ (∃i f. f ⊆ {(vertex_1, vertex_2)} ∧ ¬ trusted (p vertex_2) ∧ ¬ security_level (p vertex_1) ≤ security_level (p vertex_2) ∧ ((vertex_1, vertex_2) ∉ f ⟶ ¬ trusted (p vertex_2) ⟶ security_level (p vertex_1) ≤ security_level (p vertex_2)) ∧ (∀x∈f. ∀x1 x2. x = (x1, x2) ⟶ ¬ trusted (p x2) ∧ ¬ security_level (p x1) ≤ security_level (p x2) ∨ (vertex_1, vertex_2) ∉ f ∧ ¬ trusted (p vertex_2) ∧ ¬ security_level (p vertex_1) ≤ security_level (p vertex_2)) ∧ ((vertex_1, vertex_2) ∉ f ⟶ ¬ trusted (p vertex_2) ⟶ security_level (p vertex_1) ≤ security_level (p vertex_2)) ∧ i ∈ snd ` f ∧ (∀x1. (x1 = i ⟶ vertex_1 = i ⟶ ¬ trusted (p vertex_2) ⟶ security_level otherbot ≤ security_level (p vertex_2)) ∧ (x1 ≠ i ⟶ vertex_1 = x1 ⟶ (vertex_2 = i ⟶ ¬ trusted otherbot ⟶ security_level (p vertex_1) ≤ security_level otherbot) ∧ (vertex_2 ≠ i ⟶ ¬ trusted (p vertex_2) ⟶ security_level (p vertex_1) ≤ security_level (p vertex_2)))))›*) apply (simp add:default_node_properties_def (*‹default_node_properties ≡ ⦇security_level = 0, trusted = False⦈›*)) (*goal: ‹otherbot ≠ ⦇security_level = 0, trusted = False⦈ ⟹ ¬ trusted (((λx. default_node_properties)(vertex_1 := ⦇security_level = 1, trusted = False⦈, vertex_2 := ⦇security_level = 0, trusted = False⦈)) vertex_2) ∧ ¬ security_level (((λx. default_node_properties)(vertex_1 := ⦇security_level = 1, trusted = False⦈, vertex_2 := ⦇security_level = 0, trusted = False⦈)) vertex_1) ≤ security_level (((λx. default_node_properties)(vertex_1 := ⦇security_level = 1, trusted = False⦈, vertex_2 := ⦇security_level = 0, trusted = False⦈)) vertex_2) ∧ (∃i f. f ⊆ {(vertex_1, vertex_2)} ∧ ¬ trusted (((λx. default_node_properties)(vertex_1 := ⦇security_level = 1, trusted = False⦈, vertex_2 := ⦇security_level = 0, trusted = False⦈)) vertex_2) ∧ ¬ security_level (((λx. default_node_properties)(vertex_1 := ⦇security_level = 1, trusted = False⦈, vertex_2 := ⦇security_level = 0, trusted = False⦈)) vertex_1) ≤ security_level (((λx. default_node_properties)(vertex_1 := ⦇security_level = 1, trusted = False⦈, vertex_2 := ⦇security_level = 0, trusted = False⦈)) vertex_2) ∧ ((vertex_1, vertex_2) ∉ f ⟶ ¬ trusted (((λx. default_node_properties)(vertex_1 := ⦇security_level = 1, trusted = False⦈, vertex_2 := ⦇security_level = 0, trusted = False⦈)) vertex_2) ⟶ security_level (((λx. default_node_properties)(vertex_1 := ⦇security_level = 1, trusted = False⦈, vertex_2 := ⦇security_level = 0, trusted = False⦈)) vertex_1) ≤ security_level (((λx. default_node_properties)(vertex_1 := ⦇security_level = 1, trusted = False⦈, vertex_2 := ⦇security_level = 0, trusted = False⦈)) vertex_2)) ∧ (∀x∈f. ∀x1 x2. x = (x1, x2) ⟶ ¬ trusted (((λx. default_node_properties)(vertex_1 := ⦇security_level = 1, trusted = False⦈, vertex_2 := ⦇security_level = 0, trusted = False⦈)) x2) ∧ ¬ security_level (((λx. default_node_properties)(vertex_1 := ⦇security_level = 1, trusted = False⦈, vertex_2 := ⦇security_level = 0, trusted = False⦈)) x1) ≤ security_level (((λx. default_node_properties)(vertex_1 := ⦇security_level = 1, trusted = False⦈, vertex_2 := ⦇security_level = 0, trusted = False⦈)) x2) ∨ (vertex_1, vertex_2) ∉ f ∧ ¬ trusted (((λx. default_node_properties)(vertex_1 := ⦇security_level = 1, trusted = False⦈, vertex_2 := ⦇security_level = 0, trusted = False⦈)) vertex_2) ∧ ¬ security_level (((λx. default_node_properties)(vertex_1 := ⦇security_level = 1, trusted = False⦈, vertex_2 := ⦇security_level = 0, trusted = False⦈)) vertex_1) ≤ security_level (((λx. default_node_properties)(vertex_1 := ⦇security_level = 1, trusted = False⦈, vertex_2 := ⦇security_level = 0, trusted = False⦈)) vertex_2)) ∧ ((vertex_1, vertex_2) ∉ f ⟶ ¬ trusted (((λx. default_node_properties)(vertex_1 := ⦇security_level = 1, trusted = False⦈, vertex_2 := ⦇security_level = 0, trusted = False⦈)) vertex_2) ⟶ security_level (((λx. default_node_properties)(vertex_1 := ⦇security_level = 1, trusted = False⦈, vertex_2 := ⦇security_level = 0, trusted = False⦈)) vertex_1) ≤ security_level (((λx. default_node_properties)(vertex_1 := ⦇security_level = 1, trusted = False⦈, vertex_2 := ⦇security_level = 0, trusted = False⦈)) vertex_2)) ∧ i ∈ snd ` f ∧ (∀x1. (x1 = i ⟶ vertex_1 = i ⟶ ¬ trusted (((λx. default_node_properties)(vertex_1 := ⦇security_level = 1, trusted = False⦈, vertex_2 := ⦇security_level = 0, trusted = False⦈)) vertex_2) ⟶ security_level otherbot ≤ security_level (((λx. default_node_properties)(vertex_1 := ⦇security_level = 1, trusted = False⦈, vertex_2 := ⦇security_level = 0, trusted = False⦈)) vertex_2)) ∧ (x1 ≠ i ⟶ vertex_1 = x1 ⟶ (vertex_2 = i ⟶ ¬ trusted otherbot ⟶ security_level (((λx. default_node_properties)(vertex_1 := ⦇security_level = 1, trusted = False⦈, vertex_2 := ⦇security_level = 0, trusted = False⦈)) vertex_1) ≤ security_level otherbot) ∧ (vertex_2 ≠ i ⟶ ¬ trusted (((λx. default_node_properties)(vertex_1 := ⦇security_level = 1, trusted = False⦈, vertex_2 := ⦇security_level = 0, trusted = False⦈)) vertex_2) ⟶ security_level (((λx. default_node_properties)(vertex_1 := ⦇security_level = 1, trusted = False⦈, vertex_2 := ⦇security_level = 0, trusted = False⦈)) vertex_1) ≤ security_level (((λx. default_node_properties)(vertex_1 := ⦇security_level = 1, trusted = False⦈, vertex_2 := ⦇security_level = 0, trusted = False⦈)) vertex_2)))))›*) apply (rule_tac x="vertex_2" in exI (*‹?P ?x ⟹ ∃x. ?P x›*)) (*goal: ‹otherbot ≠ ⦇security_level = 0, trusted = False⦈ ⟹ ∃i f. f ⊆ {(vertex_1, vertex_2)} ∧ (vertex_1, vertex_2) ∈ f ∧ (∀x∈f. ∀x1. (x1 = vertex_1 ⟶ x = (vertex_1, vertex_1) ⟶ (vertex_1, vertex_2) ∉ f) ∧ (x1 ≠ vertex_1 ⟶ (x1 = vertex_2 ⟶ (∃x2. x = (vertex_2, x2)) ⟶ (vertex_1, vertex_2) ∉ f) ∧ (x1 ≠ vertex_2 ⟶ (∃x2. x = (x1, x2)) ⟶ (vertex_1, vertex_2) ∉ f))) ∧ (vertex_1, vertex_2) ∈ f ∧ i ∈ snd ` f ∧ (∀x1. (x1 = i ⟶ vertex_1 = i ⟶ security_level otherbot = 0) ∧ (x1 ≠ i ⟶ vertex_1 = x1 ⟶ (vertex_2 = i ⟶ ¬ trusted otherbot ⟶ Suc 0 ≤ security_level otherbot) ∧ vertex_2 = i))›*) apply simp (*goal: ‹otherbot ≠ ⦇security_level = 0, trusted = False⦈ ⟹ ∃f⊆{(vertex_1, vertex_2)}. (vertex_1, vertex_2) ∈ f ∧ (∀x∈f. ∀x1. (x1 = vertex_1 ⟶ x = (vertex_1, vertex_1) ⟶ (vertex_1, vertex_2) ∉ f) ∧ (x1 ≠ vertex_1 ⟶ (x1 = vertex_2 ⟶ (∃x2. x = (vertex_2, x2)) ⟶ (vertex_1, vertex_2) ∉ f) ∧ (x1 ≠ vertex_2 ⟶ (∃x2. x = (x1, x2)) ⟶ (vertex_1, vertex_2) ∉ f))) ∧ (vertex_1, vertex_2) ∈ f ∧ vertex_2 ∈ snd ` f ∧ (∀x1. (x1 = vertex_2 ⟶ vertex_1 = vertex_2 ⟶ security_level otherbot = 0) ∧ (x1 ≠ vertex_2 ⟶ vertex_1 = x1 ⟶ (vertex_2 = vertex_2 ⟶ ¬ trusted otherbot ⟶ Suc 0 ≤ security_level otherbot) ∧ vertex_2 = vertex_2))›*) apply (rule_tac x="{(vertex_1,vertex_2)}" in exI (*‹?P ?x ⟹ ∃x. ?P x›*)) (*goal: ‹otherbot ≠ ⦇security_level = 0, trusted = False⦈ ⟹ ∃f⊆{(vertex_1, vertex_2)}. (vertex_1, vertex_2) ∈ f ∧ (∀x∈f. ∀x1. (x1 = vertex_1 ⟶ x = (vertex_1, vertex_1) ⟶ (vertex_1, vertex_2) ∉ f) ∧ (x1 ≠ vertex_1 ⟶ (x1 = vertex_2 ⟶ (∃x2. x = (vertex_2, x2)) ⟶ (vertex_1, vertex_2) ∉ f) ∧ (x1 ≠ vertex_2 ⟶ (∃x2. x = (x1, x2)) ⟶ (vertex_1, vertex_2) ∉ f))) ∧ (vertex_1, vertex_2) ∈ f ∧ vertex_2 ∈ snd ` f ∧ (¬ trusted otherbot ⟶ Suc 0 ≤ security_level otherbot)›*) apply simp (*goal: ‹otherbot ≠ ⦇security_level = 0, trusted = False⦈ ⟹ {(vertex_1, vertex_2)} ⊆ {(vertex_1, vertex_2)} ∧ (vertex_1, vertex_2) ∈ {(vertex_1, vertex_2)} ∧ (∀x∈{(vertex_1, vertex_2)}. ∀x1. (x1 = vertex_1 ⟶ x = (vertex_1, vertex_1) ⟶ (vertex_1, vertex_2) ∉ {(vertex_1, vertex_2)}) ∧ (x1 ≠ vertex_1 ⟶ (x1 = vertex_2 ⟶ (∃x2. x = (vertex_2, x2)) ⟶ (vertex_1, vertex_2) ∉ {(vertex_1, vertex_2)}) ∧ (x1 ≠ vertex_2 ⟶ (∃x2. x = (x1, x2)) ⟶ (vertex_1, vertex_2) ∉ {(vertex_1, vertex_2)}))) ∧ (vertex_1, vertex_2) ∈ {(vertex_1, vertex_2)} ∧ vertex_2 ∈ snd ` {(vertex_1, vertex_2)} ∧ (¬ trusted otherbot ⟶ Suc 0 ≤ security_level otherbot)›*) apply (case_tac otherbot) (*goal: ‹otherbot ≠ ⦇security_level = 0, trusted = False⦈ ⟹ ¬ trusted otherbot ⟶ Suc 0 ≤ security_level otherbot›*) apply simp (*goal: ‹⋀security_levela trusteda. ⟦otherbot ≠ ⦇security_level = 0, trusted = False⦈; otherbot = ⦇security_level = security_levela, trusted = trusteda⦈⟧ ⟹ ¬ trusted otherbot ⟶ Suc 0 ≤ security_level otherbot›*) apply (erule disjE (*‹⟦?P ∨ ?Q; ?P ⟹ ?R; ?Q ⟹ ?R⟧ ⟹ ?R›*)) (*goals: 1. ‹⋀security_level trusted. ⟦otherbot = ⦇security_level = security_level, trusted = trusted⦈; 0 < security_level⟧ ⟹ ¬ trusted ⟶ Suc 0 ≤ security_level› 2. ‹⋀security_level trusted. ⟦otherbot = ⦇security_level = security_level, trusted = trusted⦈; trusted⟧ ⟹ ¬ trusted ⟶ Suc 0 ≤ security_level› discuss goal 1*) apply force (*discuss goal 2*) apply fast (*proven 2 subgoals*) (*proven 2 subgoals*) . subsubsection ‹ENF› definition BLP_P where "BLP_P ≡ (λn1 n2.(if trusted n2 then True else security_level n1 ≤ security_level n2 ))" lemma zero_default_candidate: "∀nP e1 e2. ¬ BLP_P (nP e1) (nP e2) ⟶ ¬ BLP_P (nP e1) default_node_properties" apply (rule allI (*‹(⋀x. ?P x) ⟹ ∀x. ?P x›*)) (*goal: ‹∀nP e1 e2. ¬ BLP_P (nP e1) (nP e2) ⟶ ¬ BLP_P (nP e1) default_node_properties›*) apply (rule allI (*‹(⋀x. ?P x) ⟹ ∀x. ?P x›*)) (*goal: ‹⋀nP. ∀e1 e2. ¬ BLP_P (nP e1) (nP e2) ⟶ ¬ BLP_P (nP e1) default_node_properties›*) apply (rule allI (*‹(⋀x. ?P x) ⟹ ∀x. ?P x›*)) (*goal: ‹⋀nP e1. ∀e2. ¬ BLP_P (nP e1) (nP e2) ⟶ ¬ BLP_P (nP e1) default_node_properties›*) apply (case_tac "nP e1") (*goal: ‹⋀nP e1 e2. ¬ BLP_P (nP e1) (nP e2) ⟶ ¬ BLP_P (nP e1) default_node_properties›*) apply (case_tac "nP e2") (*goal: ‹⋀nP e1 e2 security_level trusted more. nP e1 = ⦇security_level = security_level, trusted = trusted, … = more⦈ ⟹ ¬ BLP_P (nP e1) (nP e2) ⟶ ¬ BLP_P (nP e1) default_node_properties›*) apply (rename_tac privacy2 trusted2 more2) (*goal: ‹⋀nP e1 e2 security_level trusted more security_levela trusteda morea. ⟦nP e1 = ⦇security_level = security_level, trusted = trusted, … = more⦈; nP e2 = ⦇security_level = security_levela, trusted = trusteda, … = morea⦈⟧ ⟹ ¬ BLP_P (nP e1) (nP e2) ⟶ ¬ BLP_P (nP e1) default_node_properties›*) by (simp add: BLP_P_def (*‹BLP_P ≡ λn1 n2. if trusted n2 then True else security_level n1 ≤ security_level n2›*) default_node_properties_def (*‹default_node_properties ≡ ⦇security_level = 0, trusted = False⦈›*)) lemma privacylevel_refl: "BLP_P e e" by (simp add: BLP_P_def (*‹BLP_P ≡ λn1 n2. if trusted n2 then True else security_level n1 ≤ security_level n2›*)) lemma BLP_ENF: "SecurityInvariant_withOffendingFlows.sinvar_all_edges_normal_form sinvar BLP_P" unfolding SecurityInvariant_withOffendingFlows.sinvar_all_edges_normal_form_def (*goal: ‹∀G nP. sinvar G nP = (∀(e1, e2)∈edges G. BLP_P (nP e1) (nP e2))›*) unfolding BLP_P_def (*goal: ‹∀G nP. sinvar G nP = (∀(e1, e2)∈edges G. if trusted (nP e2) then True else security_level (nP e1) ≤ security_level (nP e2))›*) by simp lemma BLP_ENF_refl: "SecurityInvariant_withOffendingFlows.ENF_refl sinvar BLP_P" unfolding SecurityInvariant_withOffendingFlows.ENF_refl_def (*goal: ‹SecurityInvariant_withOffendingFlows.sinvar_all_edges_normal_form sinvar BLP_P ∧ (∀p1. BLP_P p1 p1)›*) apply (rule conjI (*‹⟦?P; ?Q⟧ ⟹ ?P ∧ ?Q›*)) (*goals: 1. ‹SecurityInvariant_withOffendingFlows.sinvar_all_edges_normal_form sinvar BLP_P› 2. ‹∀p1. BLP_P p1 p1› discuss goal 1*) apply (simp add: BLP_ENF (*‹SecurityInvariant_withOffendingFlows.sinvar_all_edges_normal_form sinvar BLP_P›*)) (*discuss goal 2*) apply (simp add: privacylevel_refl (*‹BLP_P ?e ?e›*)) (*proven 2 subgoals*) . definition BLP_offending_set:: "'v graph ⇒ ('v ⇒ node_config) ⇒ ('v × 'v) set set" where "BLP_offending_set G nP = (if sinvar G nP then {} else { {e ∈ edges G. case e of (e1,e2) ⇒ ¬ BLP_P (nP e1) (nP e2)} })" lemma BLP_offending_set: "SecurityInvariant_withOffendingFlows.set_offending_flows sinvar = BLP_offending_set" apply (simp only: fun_eq_iff (*‹(?f = ?g) = (∀x. ?f x = ?g x)›*) SecurityInvariant_withOffendingFlows.ENF_offending_set[OF BLP_ENF] (*‹set_offending_flows ?G ?nP = (if sinvar ?G ?nP then {} else {{(e1, e2). (e1, e2) ∈ edges ?G ∧ ¬ BLP_P (?nP e1) (?nP e2)}})›*) BLP_offending_set_def (*‹BLP_offending_set ?G ?nP = (if sinvar ?G ?nP then {} else {{e ∈ edges ?G. case e of (e1, e2) ⇒ ¬ BLP_P (?nP e1) (?nP e2)}})›*)) (*goal: ‹set_offending_flows = BLP_offending_set›*) apply (rule allI (*‹(⋀x. ?P x) ⟹ ∀x. ?P x›*)) (*goal: ‹∀x xa. (if sinvar x xa then {} else {{(e1, e2). (e1, e2) ∈ edges x ∧ ¬ BLP_P (xa e1) (xa e2)}}) = (if sinvar x xa then {} else {{e ∈ edges x. case e of (e1, e2) ⇒ ¬ BLP_P (xa e1) (xa e2)}})›*) apply (rule allI (*‹(⋀x. ?P x) ⟹ ∀x. ?P x›*)) (*goal: ‹⋀x. ∀xa. (if sinvar x xa then {} else {{(e1, e2). (e1, e2) ∈ edges x ∧ ¬ BLP_P (xa e1) (xa e2)}}) = (if sinvar x xa then {} else {{e ∈ edges x. case e of (e1, e2) ⇒ ¬ BLP_P (xa e1) (xa e2)}})›*) apply (rename_tac G nP) (*goal: ‹⋀(x::'a graph) xa::'a ⇒ node_config. (if sinvar x xa then {} else {{(e1::'a, e2::'a). (e1, e2) ∈ edges x ∧ ¬ BLP_P (xa e1) (xa e2)}}) = (if sinvar x xa then {} else {{e::'a × 'a ∈ edges x. case e of (e1::'a, e2::'a) ⇒ ¬ BLP_P (xa e1) (xa e2)}})›*) by auto interpretation BLPtrusted: SecurityInvariant_IFS where default_node_properties = default_node_properties and sinvar = sinvar rewrites "SecurityInvariant_withOffendingFlows.set_offending_flows sinvar = BLP_offending_set" (*goals: 1. ‹SecurityInvariant_IFS sinvar default_node_properties› 2. ‹set_offending_flows = BLP_offending_set› discuss goal 1*) apply unfold_locales (*goals: 1. ‹⋀G f nP. ⟦wf_graph G; f ∈ set_offending_flows G nP⟧ ⟹ ∀i∈snd ` f. ¬ sinvar G (nP(i := default_node_properties))› 2. ‹⋀otherbot. ∀G f nP i. wf_graph G ∧ f ∈ set_offending_flows G nP ∧ i ∈ snd ` f ⟶ ¬ sinvar G (nP(i := otherbot)) ⟹ otherbot = default_node_properties› discuss goal 1*) apply (rule ballI (*‹(⋀x. x ∈ ?A ⟹ ?P x) ⟹ ∀x∈?A. ?P x›*)) (*top goal: ‹⋀G f nP. ⟦wf_graph G; f ∈ set_offending_flows G nP⟧ ⟹ ∀i∈snd ` f. ¬ sinvar G (nP(i := default_node_properties))› and 2 goals remain*) apply (rule_tac f=f in SecurityInvariant_withOffendingFlows.ENF_snds_refl_instance[OF BLP_ENF_refl zero_default_candidate] (*‹⟦?f ∈ set_offending_flows ?G ?nP; ?i ∈ snd ` ?f⟧ ⟹ ¬ sinvar ?G (?nP(?i := default_node_properties))›*)) (*goals: 1. ‹⋀G f nP i. ⟦wf_graph G; f ∈ set_offending_flows G nP; i ∈ snd ` f⟧ ⟹ f ∈ set_offending_flows G nP› 2. ‹⋀G f nP i. ⟦wf_graph G; f ∈ set_offending_flows G nP; i ∈ snd ` f⟧ ⟹ i ∈ snd ` f› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) (*discuss goal 2*) apply (erule default_uniqueness_by_counterexample_IFS (*‹⟦∀G F nP i. wf_graph G ∧ F ∈ SecurityInvariant_withOffendingFlows.set_offending_flows ?sinvar G nP ∧ i ∈ snd ` F ⟶ ¬ ?sinvar G (nP(i := ?otherbot)); ?otherbot ≠ ?default_value ⟹ ∃G nP i F. wf_graph G ∧ ¬ ?sinvar G nP ∧ F ∈ SecurityInvariant_withOffendingFlows.set_offending_flows ?sinvar G nP ∧ ?sinvar (delete_edges G F) nP ∧ i ∈ snd ` F ∧ ?sinvar G (nP(i := ?otherbot))⟧ ⟹ ?otherbot = ?default_value›*)) (*top goal: ‹⋀otherbot. ∀G f nP i. wf_graph G ∧ f ∈ set_offending_flows G nP ∧ i ∈ snd ` f ⟶ ¬ sinvar G (nP(i := otherbot)) ⟹ otherbot = default_node_properties› and 1 goal remains*) apply (fact BLP_def_unique (*‹(?otherbot::node_config) ≠ default_node_properties ⟹ ∃(G::?'a graph) (p::?'a::vertex ⇒ node_config) (i::?'a::vertex) f::(?'a::vertex × ?'a::vertex) set. wf_graph G ∧ ¬ sinvar G p ∧ f ∈ set_offending_flows G p ∧ sinvar (delete_edges G f) p ∧ i ∈ snd ` f ∧ sinvar G (p(i := ?otherbot))›*)) (*proven 2 subgoals*) (*discuss goal 2*) apply (fact BLP_offending_set (*‹set_offending_flows = BLP_offending_set›*)) (*proven 2 subgoals*) . lemma TopoS_BLPtrusted: "SecurityInvariant sinvar default_node_properties receiver_violation" unfolding receiver_violation_def (*goal: ‹SecurityInvariant sinvar default_node_properties True›*) by unfold_locales hide_type (open) node_config hide_const (open) sinvar_mono hide_const (open) BLP_P hide_fact BLP_def_unique zero_default_candidate privacylevel_refl BLP_ENF BLP_ENF_refl hide_const (open) sinvar receiver_violation default_node_properties end
{ "path": "afp-2025-02-12/thys/Network_Security_Policy_Verification/Security_Invariants/SINVAR_BLPtrusted.thy", "repo": "afp-2025-02-12", "sha": "24d3c97797a72d59d6b7a45bb0f5ea36f9e43702d9c75a845c0d7eea544706b8" }
(*<*) theory Regex imports "MFOTL_Monitor.Trace" "HOL-Library.Extended_Nat" begin unbundle lattice_syntax (*>*) section ‹Regular expressions› context begin qualified datatype (atms: 'a) regex = Skip nat | Test 'a | Plus "'a regex" "'a regex" | Times "'a regex" "'a regex" | Star "'a regex" lemma finite_atms[simp]: "finite (atms r)" apply (induct r) (*goals: 1. ‹⋀x. finite (atms (Skip x))› 2. ‹⋀x. finite (atms (Test x))› 3. ‹⋀r1 r2. ⟦finite (atms r1); finite (atms r2)⟧ ⟹ finite (atms (Plus r1 r2))› 4. ‹⋀r1 r2. ⟦finite (atms r1); finite (atms r2)⟧ ⟹ finite (atms (Times r1 r2))› 5. ‹⋀r. finite (atms r) ⟹ finite (atms (Star 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]) (*proven 5 subgoals*) . definition "Wild = Skip 1" lemma size_regex_estimation[termination_simp]: "x ∈ atms r ⟹ y < f x ⟹ y < size_regex f r" apply (induct r) (*goals: 1. ‹⋀xa. ⟦x ∈ atms (Skip xa); y < f x⟧ ⟹ y < size_regex f (Skip xa)› 2. ‹⋀xa. ⟦x ∈ atms (Test xa); y < f x⟧ ⟹ y < size_regex f (Test xa)› 3. ‹⋀r1 r2. ⟦⟦x ∈ atms r1; y < f x⟧ ⟹ y < size_regex f r1; ⟦x ∈ atms r2; y < f x⟧ ⟹ y < size_regex f r2; x ∈ atms (Plus r1 r2); y < f x⟧ ⟹ y < size_regex f (Plus r1 r2)› 4. ‹⋀r1 r2. ⟦⟦x ∈ atms r1; y < f x⟧ ⟹ y < size_regex f r1; ⟦x ∈ atms r2; y < f x⟧ ⟹ y < size_regex f r2; x ∈ atms (Times r1 r2); y < f x⟧ ⟹ y < size_regex f (Times r1 r2)› 5. ‹⋀r. ⟦⟦x ∈ atms r; y < f x⟧ ⟹ y < size_regex f r; x ∈ atms (Star r); y < f x⟧ ⟹ y < size_regex f (Star 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]) (*proven 5 subgoals*) . lemma size_regex_estimation'[termination_simp]: "x ∈ atms r ⟹ y ≤ f x ⟹ y ≤ size_regex f r" apply (induct r) (*goals: 1. ‹⋀xa::nat. ⟦(x::'a) ∈ atms (Skip xa); (y::nat) ≤ (f::'a ⇒ nat) x⟧ ⟹ y ≤ size_regex f (Skip xa)› 2. ‹⋀xa::'a. ⟦(x::'a) ∈ atms (Test xa); (y::nat) ≤ (f::'a ⇒ nat) x⟧ ⟹ y ≤ size_regex f (Test xa)› 3. ‹⋀(r1::'a regex) r2::'a regex. ⟦⟦(x::'a) ∈ atms r1; (y::nat) ≤ (f::'a ⇒ nat) x⟧ ⟹ y ≤ size_regex f r1; ⟦x ∈ atms r2; y ≤ f x⟧ ⟹ y ≤ size_regex f r2; x ∈ atms (Plus r1 r2); y ≤ f x⟧ ⟹ y ≤ size_regex f (Plus r1 r2)› 4. ‹⋀(r1::'a regex) r2::'a regex. ⟦⟦(x::'a) ∈ atms r1; (y::nat) ≤ (f::'a ⇒ nat) x⟧ ⟹ y ≤ size_regex f r1; ⟦x ∈ atms r2; y ≤ f x⟧ ⟹ y ≤ size_regex f r2; x ∈ atms (Times r1 r2); y ≤ f x⟧ ⟹ y ≤ size_regex f (Times r1 r2)› 5. ‹⋀r::'a regex. ⟦⟦(x::'a) ∈ atms r; (y::nat) ≤ (f::'a ⇒ nat) x⟧ ⟹ y ≤ size_regex f r; x ∈ atms (Star r); y ≤ f x⟧ ⟹ y ≤ size_regex f (Star 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]) (*proven 5 subgoals*) . qualified definition "TimesL r S = Times r ` S" qualified definition "TimesR R s = (λr. Times r s) ` R" qualified primrec fv_regex where "fv_regex fv (Skip n) = {}" | "fv_regex fv (Test φ) = fv φ" | "fv_regex fv (Plus r s) = fv_regex fv r ∪ fv_regex fv s" | "fv_regex fv (Times r s) = fv_regex fv r ∪ fv_regex fv s" | "fv_regex fv (Star r) = fv_regex fv r" lemma fv_regex_cong[fundef_cong]: "r = r' ⟹ (⋀z. z ∈ atms r ⟹ fv z = fv' z) ⟹ fv_regex fv r = fv_regex fv' r'" apply (induct r arbitrary: r') (*goals: 1. ‹⋀x r'. ⟦Skip x = r'; ⋀z. z ∈ atms (Skip x) ⟹ fv z = fv' z⟧ ⟹ fv_regex fv (Skip x) = fv_regex fv' r'› 2. ‹⋀x r'. ⟦Test x = r'; ⋀z. z ∈ atms (Test x) ⟹ fv z = fv' z⟧ ⟹ fv_regex fv (Test x) = fv_regex fv' r'› 3. ‹⋀r1 r2 r'. ⟦⋀r'. ⟦r1 = r'; ⋀z. z ∈ atms r1 ⟹ fv z = fv' z⟧ ⟹ fv_regex fv r1 = fv_regex fv' r'; ⋀r'. ⟦r2 = r'; ⋀z. z ∈ atms r2 ⟹ fv z = fv' z⟧ ⟹ fv_regex fv r2 = fv_regex fv' r'; Plus r1 r2 = r'; ⋀z. z ∈ atms (Plus r1 r2) ⟹ fv z = fv' z⟧ ⟹ fv_regex fv (Plus r1 r2) = fv_regex fv' r'› 4. ‹⋀r1 r2 r'. ⟦⋀r'. ⟦r1 = r'; ⋀z. z ∈ atms r1 ⟹ fv z = fv' z⟧ ⟹ fv_regex fv r1 = fv_regex fv' r'; ⋀r'. ⟦r2 = r'; ⋀z. z ∈ atms r2 ⟹ fv z = fv' z⟧ ⟹ fv_regex fv r2 = fv_regex fv' r'; Times r1 r2 = r'; ⋀z. z ∈ atms (Times r1 r2) ⟹ fv z = fv' z⟧ ⟹ fv_regex fv (Times r1 r2) = fv_regex fv' r'› 5. ‹⋀r r'. ⟦⋀r'. ⟦r = r'; ⋀z. z ∈ atms r ⟹ fv z = fv' z⟧ ⟹ fv_regex fv r = fv_regex fv' r'; Star r = r'; ⋀z. z ∈ atms (Star r) ⟹ fv z = fv' z⟧ ⟹ fv_regex fv (Star r) = fv_regex fv' 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]) (*proven 5 subgoals*) . lemma finite_fv_regex[simp]: "(⋀z. z ∈ atms r ⟹ finite (fv z)) ⟹ finite (fv_regex fv r)" apply (induct r) (*goals: 1. ‹⋀x::nat. (⋀z::'a. z ∈ atms (Skip x) ⟹ finite ((fv::'a ⇒ 'b set) z)) ⟹ finite (fv_regex fv (Skip x))› 2. ‹⋀x::'a. (⋀z::'a. z ∈ atms (Test x) ⟹ finite ((fv::'a ⇒ 'b set) z)) ⟹ finite (fv_regex fv (Test x))› 3. ‹⋀(r1::'a regex) r2::'a regex. ⟦(⋀z::'a. z ∈ atms r1 ⟹ finite ((fv::'a ⇒ 'b set) z)) ⟹ finite (fv_regex fv r1); (⋀z::'a. z ∈ atms r2 ⟹ finite (fv z)) ⟹ finite (fv_regex fv r2); ⋀z::'a. z ∈ atms (Plus r1 r2) ⟹ finite (fv z)⟧ ⟹ finite (fv_regex fv (Plus r1 r2))› 4. ‹⋀(r1::'a regex) r2::'a regex. ⟦(⋀z::'a. z ∈ atms r1 ⟹ finite ((fv::'a ⇒ 'b set) z)) ⟹ finite (fv_regex fv r1); (⋀z::'a. z ∈ atms r2 ⟹ finite (fv z)) ⟹ finite (fv_regex fv r2); ⋀z::'a. z ∈ atms (Times r1 r2) ⟹ finite (fv z)⟧ ⟹ finite (fv_regex fv (Times r1 r2))› 5. ‹⋀r::'a regex. ⟦(⋀z::'a. z ∈ atms r ⟹ finite ((fv::'a ⇒ 'b set) z)) ⟹ finite (fv_regex fv r); ⋀z::'a. z ∈ atms (Star r) ⟹ finite (fv z)⟧ ⟹ finite (fv_regex fv (Star 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]) (*proven 5 subgoals*) . lemma fv_regex_commute: "(⋀z. z ∈ atms r ⟹ x ∈ fv z ⟷ g x ∈ fv' z) ⟹ x ∈ fv_regex fv r ⟷ g x ∈ fv_regex fv' r" apply (induct r) (*goals: 1. ‹⋀xa::nat. (⋀z::'a. z ∈ atms (Skip xa) ⟹ ((x::'b) ∈ (fv::'a ⇒ 'b set) z) = ((g::'b ⇒ 'c) x ∈ (fv'::'a ⇒ 'c set) z)) ⟹ (x ∈ fv_regex fv (Skip xa)) = (g x ∈ fv_regex fv' (Skip xa))› 2. ‹⋀xa::'a. (⋀z::'a. z ∈ atms (Test xa) ⟹ ((x::'b) ∈ (fv::'a ⇒ 'b set) z) = ((g::'b ⇒ 'c) x ∈ (fv'::'a ⇒ 'c set) z)) ⟹ (x ∈ fv_regex fv (Test xa)) = (g x ∈ fv_regex fv' (Test xa))› 3. ‹⋀(r1::'a regex) r2::'a regex. ⟦(⋀z::'a. z ∈ atms r1 ⟹ ((x::'b) ∈ (fv::'a ⇒ 'b set) z) = ((g::'b ⇒ 'c) x ∈ (fv'::'a ⇒ 'c set) z)) ⟹ (x ∈ fv_regex fv r1) = (g x ∈ fv_regex fv' r1); (⋀z::'a. z ∈ atms r2 ⟹ (x ∈ fv z) = (g x ∈ fv' z)) ⟹ (x ∈ fv_regex fv r2) = (g x ∈ fv_regex fv' r2); ⋀z::'a. z ∈ atms (Plus r1 r2) ⟹ (x ∈ fv z) = (g x ∈ fv' z)⟧ ⟹ (x ∈ fv_regex fv (Plus r1 r2)) = (g x ∈ fv_regex fv' (Plus r1 r2))› 4. ‹⋀(r1::'a regex) r2::'a regex. ⟦(⋀z::'a. z ∈ atms r1 ⟹ ((x::'b) ∈ (fv::'a ⇒ 'b set) z) = ((g::'b ⇒ 'c) x ∈ (fv'::'a ⇒ 'c set) z)) ⟹ (x ∈ fv_regex fv r1) = (g x ∈ fv_regex fv' r1); (⋀z::'a. z ∈ atms r2 ⟹ (x ∈ fv z) = (g x ∈ fv' z)) ⟹ (x ∈ fv_regex fv r2) = (g x ∈ fv_regex fv' r2); ⋀z::'a. z ∈ atms (Times r1 r2) ⟹ (x ∈ fv z) = (g x ∈ fv' z)⟧ ⟹ (x ∈ fv_regex fv (Times r1 r2)) = (g x ∈ fv_regex fv' (Times r1 r2))› 5. ‹⋀r::'a regex. ⟦(⋀z::'a. z ∈ atms r ⟹ ((x::'b) ∈ (fv::'a ⇒ 'b set) z) = ((g::'b ⇒ 'c) x ∈ (fv'::'a ⇒ 'c set) z)) ⟹ (x ∈ fv_regex fv r) = (g x ∈ fv_regex fv' r); ⋀z::'a. z ∈ atms (Star r) ⟹ (x ∈ fv z) = (g x ∈ fv' z)⟧ ⟹ (x ∈ fv_regex fv (Star r)) = (g x ∈ fv_regex fv' (Star 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]) (*proven 5 subgoals*) . lemma fv_regex_alt: "fv_regex fv r = (⋃z ∈ atms r. fv z)" apply (induct r) (*goals: 1. ‹⋀x. fv_regex fv (Skip x) = ⋃ (fv ` atms (Skip x))› 2. ‹⋀x. fv_regex fv (Test x) = ⋃ (fv ` atms (Test x))› 3. ‹⋀r1 r2. ⟦fv_regex fv r1 = ⋃ (fv ` atms r1); fv_regex fv r2 = ⋃ (fv ` atms r2)⟧ ⟹ fv_regex fv (Plus r1 r2) = ⋃ (fv ` atms (Plus r1 r2))› 4. ‹⋀r1 r2. ⟦fv_regex fv r1 = ⋃ (fv ` atms r1); fv_regex fv r2 = ⋃ (fv ` atms r2)⟧ ⟹ fv_regex fv (Times r1 r2) = ⋃ (fv ` atms (Times r1 r2))› 5. ‹⋀r. fv_regex fv r = ⋃ (fv ` atms r) ⟹ fv_regex fv (Star r) = ⋃ (fv ` atms (Star 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]) (*proven 5 subgoals*) . qualified definition nfv_regex where "nfv_regex fv r = Max (insert 0 (Suc ` fv_regex fv r))" lemma insert_Un: "insert x (A ∪ B) = insert x A ∪ insert x B" by auto lemma nfv_regex_simps[simp]: assumes [simp]: "(⋀z. z ∈ atms r ⟹ finite (fv z))" "(⋀z. z ∈ atms s ⟹ finite (fv z))" shows "nfv_regex fv (Skip n) = 0" "nfv_regex fv (Test φ) = Max (insert 0 (Suc ` fv φ))" "nfv_regex fv (Plus r s) = max (nfv_regex fv r) (nfv_regex fv s)" "nfv_regex fv (Times r s) = max (nfv_regex fv r) (nfv_regex fv s)" "nfv_regex fv (Star r) = nfv_regex fv r" unfolding nfv_regex_def (*goals: 1. ‹Max (insert 0 (Suc ` fv_regex fv (Skip n))) = 0› 2. ‹Max (insert 0 (Suc ` fv_regex fv (Test φ))) = Max (insert 0 (Suc ` fv φ))› 3. ‹Max (insert 0 (Suc ` fv_regex fv (Plus r s))) = max (Max (insert 0 (Suc ` fv_regex fv r))) (Max (insert 0 (Suc ` fv_regex fv s)))› 4. ‹Max (insert 0 (Suc ` fv_regex fv (Times r s))) = max (Max (insert 0 (Suc ` fv_regex fv r))) (Max (insert 0 (Suc ` fv_regex fv s)))› 5. ‹Max (insert 0 (Suc ` fv_regex fv (Star r))) = Max (insert 0 (Suc ` fv_regex fv r))›*) (*goals: 1. ‹Max (insert 0 (Suc ` fv_regex fv (Skip n))) = 0› 2. ‹Max (insert 0 (Suc ` fv_regex fv (Test φ))) = Max (insert 0 (Suc ` fv φ))› 3. ‹Max (insert 0 (Suc ` fv_regex fv (Plus r s))) = max (Max (insert 0 (Suc ` fv_regex fv r))) (Max (insert 0 (Suc ` fv_regex fv s)))› 4. ‹Max (insert 0 (Suc ` fv_regex fv (Times r s))) = max (Max (insert 0 (Suc ` fv_regex fv r))) (Max (insert 0 (Suc ` fv_regex fv s)))› 5. ‹Max (insert 0 (Suc ` fv_regex fv (Star r))) = Max (insert 0 (Suc ` fv_regex fv r))› discuss goal 1*) apply ((auto simp add: image_Un (*‹?f ` (?A ∪ ?B) = ?f ` ?A ∪ ?f ` ?B›*) Max_Un (*‹⟦finite ?A; ?A ≠ {}; finite ?B; ?B ≠ {}⟧ ⟹ Max (?A ∪ ?B) = max (Max ?A) (Max ?B)›*) insert_Un (*‹insert ?x (?A ∪ ?B) = insert ?x ?A ∪ insert ?x ?B›*) simp del: Un_insert_right (*‹?A ∪ insert ?a ?B = insert ?a (?A ∪ ?B)›*) Un_insert_left (*‹insert ?a ?B ∪ ?C = insert ?a (?B ∪ ?C)›*))[1]) (*discuss goal 2*) apply ((auto simp add: image_Un (*‹?f ` (?A ∪ ?B) = ?f ` ?A ∪ ?f ` ?B›*) Max_Un (*‹⟦finite ?A; ?A ≠ {}; finite ?B; ?B ≠ {}⟧ ⟹ Max (?A ∪ ?B) = max (Max ?A) (Max ?B)›*) insert_Un (*‹insert ?x (?A ∪ ?B) = insert ?x ?A ∪ insert ?x ?B›*) simp del: Un_insert_right (*‹?A ∪ insert ?a ?B = insert ?a (?A ∪ ?B)›*) Un_insert_left (*‹insert ?a ?B ∪ ?C = insert ?a (?B ∪ ?C)›*))[1]) (*discuss goal 3*) apply ((auto simp add: image_Un (*‹(?f::?'b::type ⇒ ?'a::type) ` ((?A::?'b::type set) ∪ (?B::?'b::type set)) = ?f ` ?A ∪ ?f ` ?B›*) Max_Un (*‹⟦finite (?A::?'a::linorder set); ?A ≠ {}; finite (?B::?'a::linorder set); ?B ≠ {}⟧ ⟹ Max (?A ∪ ?B) = max (Max ?A) (Max ?B)›*) insert_Un (*‹insert (?x::?'a::type) ((?A::?'a::type set) ∪ (?B::?'a::type set)) = insert ?x ?A ∪ insert ?x ?B›*) simp del: Un_insert_right (*‹(?A::?'a::type set) ∪ insert (?a::?'a::type) (?B::?'a::type set) = insert ?a (?A ∪ ?B)›*) Un_insert_left (*‹insert (?a::?'a::type) (?B::?'a::type set) ∪ (?C::?'a::type set) = insert ?a (?B ∪ ?C)›*))[1]) (*discuss goal 4*) apply ((auto simp add: image_Un (*‹(?f::?'b ⇒ ?'a) ` ((?A::?'b set) ∪ (?B::?'b set)) = ?f ` ?A ∪ ?f ` ?B›*) Max_Un (*‹⟦finite (?A::?'a set); ?A ≠ {}; finite (?B::?'a set); ?B ≠ {}⟧ ⟹ Max (?A ∪ ?B) = max (Max ?A) (Max ?B)›*) insert_Un (*‹insert (?x::?'a) ((?A::?'a set) ∪ (?B::?'a set)) = insert ?x ?A ∪ insert ?x ?B›*) simp del: Un_insert_right (*‹(?A::?'a set) ∪ insert (?a::?'a) (?B::?'a set) = insert ?a (?A ∪ ?B)›*) Un_insert_left (*‹insert (?a::?'a) (?B::?'a set) ∪ (?C::?'a set) = insert ?a (?B ∪ ?C)›*))[1]) (*discuss goal 5*) apply ((auto simp add: image_Un (*‹(?f::?'b::type ⇒ ?'a::type) ` ((?A::?'b::type set) ∪ (?B::?'b::type set)) = ?f ` ?A ∪ ?f ` ?B›*) Max_Un (*‹⟦finite (?A::?'a::linorder set); ?A ≠ {}; finite (?B::?'a::linorder set); ?B ≠ {}⟧ ⟹ Max (?A ∪ ?B) = max (Max ?A) (Max ?B)›*) insert_Un (*‹insert (?x::?'a::type) ((?A::?'a::type set) ∪ (?B::?'a::type set)) = insert ?x ?A ∪ insert ?x ?B›*) simp del: Un_insert_right (*‹(?A::?'a::type set) ∪ insert (?a::?'a::type) (?B::?'a::type set) = insert ?a (?A ∪ ?B)›*) Un_insert_left (*‹insert (?a::?'a::type) (?B::?'a::type set) ∪ (?C::?'a::type set) = insert ?a (?B ∪ ?C)›*))[1]) (*proven 5 subgoals*) . abbreviation "min_regex_default f r j ≡ (if atms r = {} then j else Min ((λz. f z j) ` atms r))" qualified primrec match :: "(nat ⇒ 'a ⇒ bool) ⇒ 'a regex ⇒ nat ⇒ nat ⇒ bool" where "match test (Skip n) = (λi j. j = i + n)" | "match test (Test φ) = (λi j. i = j ∧ test i φ)" | "match test (Plus r s) = match test r ⊔ match test s" | "match test (Times r s) = match test r OO match test s" | "match test (Star r) = (match test r)⇧*⇧*" lemma match_cong[fundef_cong]: "r = r' ⟹ (⋀i z. z ∈ atms r ⟹ t i z = t' i z) ⟹ match t r = match t' r'" apply (induct r arbitrary: r') (*goals: 1. ‹⋀(x::nat) r'::'a::type regex. ⟦Skip x = r'; ⋀(i::nat) z::'a::type. z ∈ atms (Skip x) ⟹ (t::nat ⇒ 'a::type ⇒ bool) i z = (t'::nat ⇒ 'a::type ⇒ bool) i z⟧ ⟹ match t (Skip x) = match t' r'› 2. ‹⋀(x::'a::type) r'::'a::type regex. ⟦Test x = r'; ⋀(i::nat) z::'a::type. z ∈ atms (Test x) ⟹ (t::nat ⇒ 'a::type ⇒ bool) i z = (t'::nat ⇒ 'a::type ⇒ bool) i z⟧ ⟹ match t (Test x) = match t' r'› 3. ‹⋀(r1::'a::type regex) (r2::'a::type regex) r'::'a::type regex. ⟦⋀r'::'a::type regex. ⟦r1 = r'; ⋀(i::nat) z::'a::type. z ∈ atms r1 ⟹ (t::nat ⇒ 'a::type ⇒ bool) i z = (t'::nat ⇒ 'a::type ⇒ bool) i z⟧ ⟹ match t r1 = match t' r'; ⋀r'::'a::type regex. ⟦r2 = r'; ⋀(i::nat) z::'a::type. z ∈ atms r2 ⟹ t i z = t' i z⟧ ⟹ match t r2 = match t' r'; Plus r1 r2 = r'; ⋀(i::nat) z::'a::type. z ∈ atms (Plus r1 r2) ⟹ t i z = t' i z⟧ ⟹ match t (Plus r1 r2) = match t' r'› 4. ‹⋀(r1::'a::type regex) (r2::'a::type regex) r'::'a::type regex. ⟦⋀r'::'a::type regex. ⟦r1 = r'; ⋀(i::nat) z::'a::type. z ∈ atms r1 ⟹ (t::nat ⇒ 'a::type ⇒ bool) i z = (t'::nat ⇒ 'a::type ⇒ bool) i z⟧ ⟹ match t r1 = match t' r'; ⋀r'::'a::type regex. ⟦r2 = r'; ⋀(i::nat) z::'a::type. z ∈ atms r2 ⟹ t i z = t' i z⟧ ⟹ match t r2 = match t' r'; Times r1 r2 = r'; ⋀(i::nat) z::'a::type. z ∈ atms (Times r1 r2) ⟹ t i z = t' i z⟧ ⟹ match t (Times r1 r2) = match t' r'› 5. ‹⋀(r::'a::type regex) r'::'a::type regex. ⟦⋀r'::'a::type regex. ⟦r = r'; ⋀(i::nat) z::'a::type. z ∈ atms r ⟹ (t::nat ⇒ 'a::type ⇒ bool) i z = (t'::nat ⇒ 'a::type ⇒ bool) i z⟧ ⟹ match t r = match t' r'; Star r = r'; ⋀(i::nat) z::'a::type. z ∈ atms (Star r) ⟹ t i z = t' i z⟧ ⟹ match t (Star r) = match t' 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]) (*proven 5 subgoals*) . qualified primrec eps where "eps test i (Skip n) = (n = 0)" | "eps test i (Test φ) = test i φ" | "eps test i (Plus r s) = (eps test i r ∨ eps test i s)" | "eps test i (Times r s) = (eps test i r ∧ eps test i s)" | "eps test i (Star r) = True" qualified primrec lpd where "lpd test i (Skip n) = (case n of 0 ⇒ {} | Suc m ⇒ {Skip m})" | "lpd test i (Test φ) = {}" | "lpd test i (Plus r s) = (lpd test i r ∪ lpd test i s)" | "lpd test i (Times r s) = TimesR (lpd test i r) s ∪ (if eps test i r then lpd test i s else {})" | "lpd test i (Star r) = TimesR (lpd test i r) (Star r)" qualified primrec lpdκ where "lpdκ κ test i (Skip n) = (case n of 0 ⇒ {} | Suc m ⇒ {κ (Skip m)})" | "lpdκ κ test i (Test φ) = {}" | "lpdκ κ test i (Plus r s) = lpdκ κ test i r ∪ lpdκ κ test i s" | "lpdκ κ test i (Times r s) = lpdκ (λt. κ (Times t s)) test i r ∪ (if eps test i r then lpdκ κ test i s else {})" | "lpdκ κ test i (Star r) = lpdκ (λt. κ (Times t (Star r))) test i r" qualified primrec rpd where "rpd test i (Skip n) = (case n of 0 ⇒ {} | Suc m ⇒ {Skip m})" | "rpd test i (Test φ) = {}" | "rpd test i (Plus r s) = (rpd test i r ∪ rpd test i s)" | "rpd test i (Times r s) = TimesL r (rpd test i s) ∪ (if eps test i s then rpd test i r else {})" | "rpd test i (Star r) = TimesL (Star r) (rpd test i r)" qualified primrec rpdκ where "rpdκ κ test i (Skip n) = (case n of 0 ⇒ {} | Suc m ⇒ {κ (Skip m)})" | "rpdκ κ test i (Test φ) = {}" | "rpdκ κ test i (Plus r s) = rpdκ κ test i r ∪ rpdκ κ test i s" | "rpdκ κ test i (Times r s) = rpdκ (λt. κ (Times r t)) test i s ∪ (if eps test i s then rpdκ κ test i r else {})" | "rpdκ κ test i (Star r) = rpdκ (λt. κ (Times (Star r) t)) test i r" lemma lpdκ_lpd: "lpdκ κ test i r = κ ` lpd test i r" apply (induct r arbitrary: κ) (*goals: 1. ‹⋀(x::nat) κ::'b regex ⇒ 'a. lpdκ κ (test::'c ⇒ 'b ⇒ bool) (i::'c) (Skip x) = κ ` lpd test i (Skip x)› 2. ‹⋀(x::'b) κ::'b regex ⇒ 'a. lpdκ κ (test::'c ⇒ 'b ⇒ bool) (i::'c) (Test x) = κ ` lpd test i (Test x)› 3. ‹⋀(r1::'b regex) (r2::'b regex) κ::'b regex ⇒ 'a. ⟦⋀κ::'b regex ⇒ 'a. lpdκ κ (test::'c ⇒ 'b ⇒ bool) (i::'c) r1 = κ ` lpd test i r1; ⋀κ::'b regex ⇒ 'a. lpdκ κ test i r2 = κ ` lpd test i r2⟧ ⟹ lpdκ κ test i (Plus r1 r2) = κ ` lpd test i (Plus r1 r2)› 4. ‹⋀(r1::'b regex) (r2::'b regex) κ::'b regex ⇒ 'a. ⟦⋀κ::'b regex ⇒ 'a. lpdκ κ (test::'c ⇒ 'b ⇒ bool) (i::'c) r1 = κ ` lpd test i r1; ⋀κ::'b regex ⇒ 'a. lpdκ κ test i r2 = κ ` lpd test i r2⟧ ⟹ lpdκ κ test i (Times r1 r2) = κ ` lpd test i (Times r1 r2)› 5. ‹⋀(r::'b regex) κ::'b regex ⇒ 'a. (⋀κ::'b regex ⇒ 'a. lpdκ κ (test::'c ⇒ 'b ⇒ bool) (i::'c) r = κ ` lpd test i r) ⟹ lpdκ κ test i (Star r) = κ ` lpd test i (Star r)› discuss goal 1*) apply ((auto simp: TimesR_def (*‹TimesR ?R ?s = (λr. Times r ?s) ` ?R›*) 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: TimesR_def (*‹TimesR ?R ?s = (λr. Times r ?s) ` ?R›*) 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 3*) apply ((auto simp: TimesR_def (*‹TimesR ?R ?s = (λr. Times r ?s) ` ?R›*) 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 4*) apply ((auto simp: TimesR_def (*‹TimesR ?R ?s = (λr. Times r ?s) ` ?R›*) 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 5*) apply ((auto simp: TimesR_def (*‹TimesR ?R ?s = (λr. Times r ?s) ` ?R›*) 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 5 subgoals*) . lemma rpdκ_rpd: "rpdκ κ test i r = κ ` rpd test i r" apply (induct r arbitrary: κ) (*goals: 1. ‹⋀x κ. rpdκ κ test i (Skip x) = κ ` rpd test i (Skip x)› 2. ‹⋀x κ. rpdκ κ test i (Test x) = κ ` rpd test i (Test x)› 3. ‹⋀r1 r2 κ. ⟦⋀κ. rpdκ κ test i r1 = κ ` rpd test i r1; ⋀κ. rpdκ κ test i r2 = κ ` rpd test i r2⟧ ⟹ rpdκ κ test i (Plus r1 r2) = κ ` rpd test i (Plus r1 r2)› 4. ‹⋀r1 r2 κ. ⟦⋀κ. rpdκ κ test i r1 = κ ` rpd test i r1; ⋀κ. rpdκ κ test i r2 = κ ` rpd test i r2⟧ ⟹ rpdκ κ test i (Times r1 r2) = κ ` rpd test i (Times r1 r2)› 5. ‹⋀r κ. (⋀κ. rpdκ κ test i r = κ ` rpd test i r) ⟹ rpdκ κ test i (Star r) = κ ` rpd test i (Star r)› discuss goal 1*) apply ((auto simp: TimesL_def (*‹TimesL ?r ?S = Times ?r ` ?S›*) 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: TimesL_def (*‹TimesL ?r ?S = Times ?r ` ?S›*) 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 3*) apply ((auto simp: TimesL_def (*‹TimesL ?r ?S = Times ?r ` ?S›*) 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 4*) apply ((auto simp: TimesL_def (*‹TimesL (?r::?'a regex) (?S::?'a regex set) = Times ?r ` ?S›*) split: nat.splits (*‹(?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)))› ‹(?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))))›*))[1]) (*discuss goal 5*) apply ((auto simp: TimesL_def (*‹TimesL ?r ?S = Times ?r ` ?S›*) 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 5 subgoals*) . lemma match_le: "match test r i j ⟹ i ≤ j" proof (induction r arbitrary: i j) (*goals: 1. ‹⋀(x::nat) (i::nat) j::nat. match (test::nat ⇒ 'a ⇒ bool) (Skip x) i j ⟹ i ≤ j› 2. ‹⋀(x::'a) (i::nat) j::nat. match (test::nat ⇒ 'a ⇒ bool) (Test x) i j ⟹ i ≤ j› 3. ‹⋀(r1::'a regex) (r2::'a regex) (i::nat) j::nat. ⟦⋀(i::nat) j::nat. match (test::nat ⇒ 'a ⇒ bool) r1 i j ⟹ i ≤ j; ⋀(i::nat) j::nat. match test r2 i j ⟹ i ≤ j; match test (Plus r1 r2) i j⟧ ⟹ i ≤ j› 4. ‹⋀(r1::'a regex) (r2::'a regex) (i::nat) j::nat. ⟦⋀(i::nat) j::nat. match (test::nat ⇒ 'a ⇒ bool) r1 i j ⟹ i ≤ j; ⋀(i::nat) j::nat. match test r2 i j ⟹ i ≤ j; match test (Times r1 r2) i j⟧ ⟹ i ≤ j› 5. ‹⋀(r::'a regex) (i::nat) j::nat. ⟦⋀(i::nat) j::nat. match (test::nat ⇒ 'a ⇒ bool) r i j ⟹ i ≤ j; match test (Star r) i j⟧ ⟹ i ≤ j›*) case (Times r s) (*‹match (test::nat ⇒ 'a ⇒ bool) (r::'a regex) (?i::nat) (?j::nat) ⟹ ?i ≤ ?j› ‹match (test::nat ⇒ 'a ⇒ bool) (s::'a regex) (?i::nat) (?j::nat) ⟹ ?i ≤ ?j› ‹match (test::nat ⇒ 'a ⇒ bool) (Times (r::'a regex) (s::'a regex)) (i::nat) (j::nat)›*) then show "?case" (*goal: ‹(i::nat) ≤ (j::nat)›*) using order.trans (*‹⟦?a ≤ ?b; ?b ≤ ?c⟧ ⟹ ?a ≤ ?c›*) by fastforce next (*goals: 1. ‹⋀x i j. match test (Skip x) i j ⟹ i ≤ j› 2. ‹⋀x i j. match test (Test x) i j ⟹ i ≤ j› 3. ‹⋀r1 r2 i j. ⟦⋀i j. match test r1 i j ⟹ i ≤ j; ⋀i j. match test r2 i j ⟹ i ≤ j; match test (Plus r1 r2) i j⟧ ⟹ i ≤ j› 4. ‹⋀r i j. ⟦⋀i j. match test r i j ⟹ i ≤ j; match test (Star r) i j⟧ ⟹ i ≤ j›*) case (Star r) (*‹match (test::nat ⇒ 'a ⇒ bool) (r::'a regex) (?i::nat) (?j::nat) ⟹ ?i ≤ ?j› ‹match test (Star r) i j›*) from Star.prems (*‹match test (Star r) i j›*) show "?case" (*goal: ‹(i::nat) ≤ (j::nat)›*) unfolding match.simps (*goal: ‹i ≤ j›*) apply (induct i j rule: rtranclp.induct (*‹⟦?r⇧*⇧* ?x1.0 ?x2.0; ⋀a. ?P a a; ⋀a b c. ⟦?r⇧*⇧* a b; ?P a b; ?r b c⟧ ⟹ ?P a c⟧ ⟹ ?P ?x1.0 ?x2.0›*)) (*goals: 1. ‹⋀a. a ≤ a› 2. ‹⋀a b c. ⟦(match test r)⇧*⇧* a b; a ≤ b; match test r b c⟧ ⟹ a ≤ c› discuss goal 1*) apply (force dest: Star.IH (*‹match test r ?i ?j ⟹ ?i ≤ ?j›*)) (*discuss goal 2*) apply (force dest: Star.IH (*‹match (test::nat ⇒ 'a ⇒ bool) (r::'a regex) (?i::nat) (?j::nat) ⟹ ?i ≤ ?j›*)) (*proven 2 subgoals*) . qed (auto) (*solves the remaining goals: 1. ‹⋀x i j. match test (Skip x) i j ⟹ i ≤ j› 2. ‹⋀x i j. match test (Test x) i j ⟹ i ≤ j› 3. ‹⋀r1 r2 i j. ⟦⋀i j. match test r1 i j ⟹ i ≤ j; ⋀i j. match test r2 i j ⟹ i ≤ j; match test (Plus r1 r2) i j⟧ ⟹ i ≤ j›*) lemma match_rtranclp_le: "(match test r)⇧*⇧* i j ⟹ i ≤ j" by (metis match.simps( (*‹match ?test (Star ?r) = (match ?test ?r)⇧*⇧*›*) 5) match_le (*‹match ?test ?r ?i ?j ⟹ ?i ≤ ?j›*)) lemma eps_match: "eps test i r ⟷ match test r i i" apply (induction r) (*goals: 1. ‹⋀x. eps test i (Skip x) = match test (Skip x) i i› 2. ‹⋀x. eps test i (Test x) = match test (Test x) i i› 3. ‹⋀r1 r2. ⟦eps test i r1 = match test r1 i i; eps test i r2 = match test r2 i i⟧ ⟹ eps test i (Plus r1 r2) = match test (Plus r1 r2) i i› 4. ‹⋀r1 r2. ⟦eps test i r1 = match test r1 i i; eps test i r2 = match test r2 i i⟧ ⟹ eps test i (Times r1 r2) = match test (Times r1 r2) i i› 5. ‹⋀r. eps test i r = match test r i i ⟹ eps test i (Star r) = match test (Star r) i i› discuss goal 1*) apply ((auto dest: antisym[OF match_le match_le] (*‹⟦match ?test2 ?r2 ?a ?b; match ?test1 ?r1 ?b ?a⟧ ⟹ ?a = ?b›*))[1]) (*discuss goal 2*) apply ((auto dest: antisym[OF match_le match_le] (*‹⟦match (?test2::nat ⇒ ?'a2 ⇒ bool) (?r2::?'a2 regex) (?a::nat) (?b::nat); match (?test1::nat ⇒ ?'a1 ⇒ bool) (?r1::?'a1 regex) ?b ?a⟧ ⟹ ?a = ?b›*))[1]) (*discuss goal 3*) apply ((auto dest: antisym[OF match_le match_le] (*‹⟦match ?test2 ?r2 ?a ?b; match ?test1 ?r1 ?b ?a⟧ ⟹ ?a = ?b›*))[1]) (*discuss goal 4*) apply ((auto dest: antisym[OF match_le match_le] (*‹⟦match ?test2 ?r2 ?a ?b; match ?test1 ?r1 ?b ?a⟧ ⟹ ?a = ?b›*))[1]) (*discuss goal 5*) apply ((auto dest: antisym[OF match_le match_le] (*‹⟦match ?test2 ?r2 ?a ?b; match ?test1 ?r1 ?b ?a⟧ ⟹ ?a = ?b›*))[1]) (*proven 5 subgoals*) . lemma lpd_match: "i < j ⟹ match test r i j ⟷ (⨆s ∈ lpd test i r. match test s) (i + 1) j" proof (induction r arbitrary: i j) (*goals: 1. ‹⋀x i j. i < j ⟹ match test (Skip x) i j = (⨆ (match test ` lpd test i (Skip x))) (i + 1) j› 2. ‹⋀x i j. i < j ⟹ match test (Test x) i j = (⨆ (match test ` lpd test i (Test x))) (i + 1) j› 3. ‹⋀r1 r2 i j. ⟦⋀i j. i < j ⟹ match test r1 i j = (⨆ (match test ` lpd test i r1)) (i + 1) j; ⋀i j. i < j ⟹ match test r2 i j = (⨆ (match test ` lpd test i r2)) (i + 1) j; i < j⟧ ⟹ match test (Plus r1 r2) i j = (⨆ (match test ` lpd test i (Plus r1 r2))) (i + 1) j› 4. ‹⋀r1 r2 i j. ⟦⋀i j. i < j ⟹ match test r1 i j = (⨆ (match test ` lpd test i r1)) (i + 1) j; ⋀i j. i < j ⟹ match test r2 i j = (⨆ (match test ` lpd test i r2)) (i + 1) j; i < j⟧ ⟹ match test (Times r1 r2) i j = (⨆ (match test ` lpd test i (Times r1 r2))) (i + 1) j› 5. ‹⋀r i j. ⟦⋀i j. i < j ⟹ match test r i j = (⨆ (match test ` lpd test i r)) (i + 1) j; i < j⟧ ⟹ match test (Star r) i j = (⨆ (match test ` lpd test i (Star r))) (i + 1) j›*) case (Times r s) (*‹?i < ?j ⟹ match test r ?i ?j = (⨆ (match test ` lpd test ?i r)) (?i + 1) ?j› ‹?i < ?j ⟹ match test s ?i ?j = (⨆ (match test ` lpd test ?i s)) (?i + 1) ?j› ‹i < j›*) have "match test (Times r s) i j ⟷ (∃k. match test r i k ∧ match test s k j)" by auto also (*calculation: ‹match test (Times r s) i j = (∃k. match test r i k ∧ match test s k j)›*) have "… ⟷ match test r i i ∧ match test s i j ∨ (∃k>i. match test r i k ∧ match test s k j)" using match_le[of test r i] (*‹match test r i ?j ⟹ i ≤ ?j›*) nat_less_le (*‹((?m::nat) < (?n::nat)) = (?m ≤ ?n ∧ ?m ≠ ?n)›*) by auto also (*calculation: ‹match test (Times r s) i j = (match test r i i ∧ match test s i j ∨ (∃k>i. match test r i k ∧ match test s k j))›*) have "… ⟷ match test r i i ∧ (⨆t ∈ lpd test i s. match test t) (i + 1) j ∨ (∃k>i. (⨆t ∈ lpd test i r. match test t) (i + 1) k ∧ match test s k j)" using Times.IH(1) (*‹(?i::nat) < (?j::nat) ⟹ match (test::nat ⇒ 'a::type ⇒ bool) (r::'a::type regex) ?i ?j = (⨆ (match test ` lpd test ?i r)) (?i + (1::nat)) ?j›*) Times.IH(2)[OF Times.prems] (*‹match (test::nat ⇒ 'a::type ⇒ bool) (s::'a::type regex) (i::nat) (j::nat) = (⨆ (match test ` lpd test i s)) (i + (1::nat)) j›*) by metis also (*calculation: ‹match test (Times r s) i j = (match test r i i ∧ (⨆ (match test ` lpd test i s)) (i + 1) j ∨ (∃k>i. (⨆ (match test ` lpd test i r)) (i + 1) k ∧ match test s k j))›*) have "… ⟷ match test r i i ∧ (⨆t ∈ lpd test i s. match test t) (i + 1) j ∨ (∃k. (⨆t ∈ lpd test i r. match test t) (i + 1) k ∧ match test s k j)" using Times.prems (*‹i < j›*) apply (intro disj_cong[OF refl] (*‹(¬ ?P ⟹ ?Q = ?Q') ⟹ (?P ∨ ?Q) = (?P ∨ ?Q')›*) iff_exI (*‹(⋀x. ?P x = ?Q x) ⟹ (∃x. ?P x) = (∃x. ?Q x)›*)) (*goal: ‹(match (test::nat ⇒ 'a ⇒ bool) (r::'a regex) (i::nat) i ∧ (⨆ (match test ` lpd test i (s::'a regex))) (i + (1::nat)) (j::nat) ∨ (∃k>i. (⨆ (match test ` lpd test i r)) (i + (1::nat)) k ∧ match test s k j)) = (match test r i i ∧ (⨆ (match test ` lpd test i s)) (i + (1::nat)) j ∨ (∃k::nat. (⨆ (match test ` lpd test i r)) (i + (1::nat)) k ∧ match test s k j))›*) by (auto dest: match_le (*‹match ?test ?r ?i ?j ⟹ ?i ≤ ?j›*)) also (*calculation: ‹match (test::nat ⇒ 'a ⇒ bool) (Times (r::'a regex) (s::'a regex)) (i::nat) (j::nat) = (match test r i i ∧ (⨆ (match test ` lpd test i s)) (i + (1::nat)) j ∨ (∃k::nat. (⨆ (match test ` lpd test i r)) (i + (1::nat)) k ∧ match test s k j))›*) have "… ⟷ (⨆ (match test ` lpd test i (Times r s))) (i + 1) j" by (force simp: TimesL_def (*‹TimesL ?r ?S = Times ?r ` ?S›*) TimesR_def (*‹TimesR ?R ?s = (λr. Times r ?s) ` ?R›*) eps_match (*‹eps ?test ?i ?r = match ?test ?r ?i ?i›*)) finally (*calculation: ‹match test (Times r s) i j = (⨆ (match test ` lpd test i (Times r s))) (i + 1) j›*) show "?case" (*goal: ‹match test (Times r s) i j = (⨆ (match test ` lpd test i (Times r s))) (i + 1) j›*) . next (*goals: 1. ‹⋀x i j. i < j ⟹ match test (Skip x) i j = (⨆ (match test ` lpd test i (Skip x))) (i + 1) j› 2. ‹⋀x i j. i < j ⟹ match test (Test x) i j = (⨆ (match test ` lpd test i (Test x))) (i + 1) j› 3. ‹⋀r1 r2 i j. ⟦⋀i j. i < j ⟹ match test r1 i j = (⨆ (match test ` lpd test i r1)) (i + 1) j; ⋀i j. i < j ⟹ match test r2 i j = (⨆ (match test ` lpd test i r2)) (i + 1) j; i < j⟧ ⟹ match test (Plus r1 r2) i j = (⨆ (match test ` lpd test i (Plus r1 r2))) (i + 1) j› 4. ‹⋀r i j. ⟦⋀i j. i < j ⟹ match test r i j = (⨆ (match test ` lpd test i r)) (i + 1) j; i < j⟧ ⟹ match test (Star r) i j = (⨆ (match test ` lpd test i (Star r))) (i + 1) j›*) case (Star r) (*‹(?i::nat) < (?j::nat) ⟹ match (test::nat ⇒ 'a ⇒ bool) (r::'a regex) ?i ?j = (⨆ (match test ` lpd test ?i r)) (?i + (1::nat)) ?j› ‹i < j›*) have "∃s∈lpd test i r. (match test s OO (match test r)⇧*⇧*) (i + 1) j" if "(match test r)⇧*⇧* i j" using that (*‹(match (test::nat ⇒ 'a::type ⇒ bool) (r::'a::type regex))⇧*⇧* (i::nat) (j::nat)›*) Star.prems (*‹i < j›*) match_le[of test _ "i + 1"] (*‹match test ?r (i + 1) ?j ⟹ i + 1 ≤ ?j›*) proof (induct rule: converse_rtranclp_induct (*‹⟦?r⇧*⇧* ?a ?b; ?P ?b; ⋀y z. ⟦?r y z; ?r⇧*⇧* z ?b; ?P z⟧ ⟹ ?P y⟧ ⟹ ?P ?a›*)) (*goals: 1. ‹⟦j < j; ⋀r j. match test r (j + 1) j ⟹ j + 1 ≤ j⟧ ⟹ ∃s∈lpd test j r. (match test s OO (match test r)⇧*⇧*) (j + 1) j› 2. ‹⋀y z. ⟦match test r y z; (match test r)⇧*⇧* z j; ⟦z < j; ⋀r j. match test r (z + 1) j ⟹ z + 1 ≤ j⟧ ⟹ ∃s∈lpd test z r. (match test s OO (match test r)⇧*⇧*) (z + 1) j; y < j; ⋀r j. match test r (y + 1) j ⟹ y + 1 ≤ j⟧ ⟹ ∃s∈lpd test y r. (match test s OO (match test r)⇧*⇧*) (y + 1) j›*) case (step i k) (*‹match test r i k› ‹(match (test::nat ⇒ 'a::type ⇒ bool) (r::'a::type regex))⇧*⇧* (k::nat) (j::nat)› ‹⟦k < j; ⋀r j. match test r (k + 1) j ⟹ k + 1 ≤ j⟧ ⟹ ∃s∈lpd test k r. (match test s OO (match test r)⇧*⇧*) (k + 1) j› ‹i < j› ‹match test ?r (i + 1) ?j ⟹ i + 1 ≤ ?j›*) then show "?case" (*goal: ‹∃s∈lpd test i r. (match test s OO (match test r)⇧*⇧*) (i + 1) j›*) apply (cases "i < k") (*goals: 1. ‹⟦match test r i k; (match test r)⇧*⇧* k j; ⟦k < j; ⋀r j. match test r (k + 1) j ⟹ k + 1 ≤ j⟧ ⟹ ∃s∈lpd test k r. (match test s OO (match test r)⇧*⇧*) (k + 1) j; i < j; ⋀r j. match test r (i + 1) j ⟹ i + 1 ≤ j; i < k⟧ ⟹ ∃s∈lpd test i r. (match test s OO (match test r)⇧*⇧*) (i + 1) j› 2. ‹⟦match test r i k; (match test r)⇧*⇧* k j; ⟦k < j; ⋀r j. match test r (k + 1) j ⟹ k + 1 ≤ j⟧ ⟹ ∃s∈lpd test k r. (match test s OO (match test r)⇧*⇧*) (k + 1) j; i < j; ⋀r j. match test r (i + 1) j ⟹ i + 1 ≤ j; ¬ i < k⟧ ⟹ ∃s∈lpd test i r. (match test s OO (match test r)⇧*⇧*) (i + 1) j› discuss goal 1*) apply ((auto simp: not_less (*‹(¬ (?x::?'a) < (?y::?'a)) = (?y ≤ ?x)›*) Star.IH (*‹(?i::nat) < (?j::nat) ⟹ match (test::nat ⇒ 'a ⇒ bool) (r::'a regex) ?i ?j = (⨆ (match test ` lpd test ?i r)) (?i + (1::nat)) ?j›*) dest: match_le (*‹match (?test::nat ⇒ ?'a ⇒ bool) (?r::?'a regex) (?i::nat) (?j::nat) ⟹ ?i ≤ ?j›*))[1]) (*discuss goal 2*) apply ((auto simp: not_less (*‹(¬ ?x < ?y) = (?y ≤ ?x)›*) Star.IH (*‹?i < ?j ⟹ match test r ?i ?j = (⨆ (match test ` lpd test ?i r)) (?i + 1) ?j›*) dest: match_le (*‹match ?test ?r ?i ?j ⟹ ?i ≤ ?j›*))[1]) (*proven 2 subgoals*) . qed (simp) (*solved the remaining goal: ‹⟦j < j; ⋀r j. match test r (j + 1) j ⟹ j + 1 ≤ j⟧ ⟹ ∃s∈lpd test j r. (match test s OO (match test r)⇧*⇧*) (j + 1) j›*) with Star.prems (*‹i < j›*) show "?case" (*goal: ‹match test (Star r) i j = (⨆ (match test ` lpd test i (Star r))) (i + 1) j›*) using match_le[of test _ "i + 1"] (*‹match test ?r (i + 1) ?j ⟹ i + 1 ≤ ?j›*) by (auto simp: TimesL_def (*‹TimesL ?r ?S = Times ?r ` ?S›*) TimesR_def (*‹TimesR ?R ?s = (λr. Times r ?s) ` ?R›*) Suc_le_eq (*‹(Suc ?m ≤ ?n) = (?m < ?n)›*) Star.IH[of i] (*‹i < ?j ⟹ match test r i ?j = (⨆ (match test ` lpd test i r)) (i + 1) ?j›*) elim!: converse_rtranclp_into_rtranclp[rotated] (*‹⟦?r⇧*⇧* ?b ?c; ?r ?a ?b⟧ ⟹ ?r⇧*⇧* ?a ?c›*)) qed (auto 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))))›*)) (*solves the remaining goals: 1. ‹⋀x i j. i < j ⟹ match test (Skip x) i j = (⨆ (match test ` lpd test i (Skip x))) (i + 1) j› 2. ‹⋀x i j. i < j ⟹ match test (Test x) i j = (⨆ (match test ` lpd test i (Test x))) (i + 1) j› 3. ‹⋀r1 r2 i j. ⟦⋀i j. i < j ⟹ match test r1 i j = (⨆ (match test ` lpd test i r1)) (i + 1) j; ⋀i j. i < j ⟹ match test r2 i j = (⨆ (match test ` lpd test i r2)) (i + 1) j; i < j⟧ ⟹ match test (Plus r1 r2) i j = (⨆ (match test ` lpd test i (Plus r1 r2))) (i + 1) j›*) lemma rpd_match: "i < j ⟹ match test r i j ⟷ (⨆s ∈ rpd test j r. match test s) i (j - 1)" proof (induction r arbitrary: i j) (*goals: 1. ‹⋀x i j. i < j ⟹ match test (Skip x) i j = (⨆ (match test ` rpd test j (Skip x))) i (j - 1)› 2. ‹⋀x i j. i < j ⟹ match test (Test x) i j = (⨆ (match test ` rpd test j (Test x))) i (j - 1)› 3. ‹⋀r1 r2 i j. ⟦⋀i j. i < j ⟹ match test r1 i j = (⨆ (match test ` rpd test j r1)) i (j - 1); ⋀i j. i < j ⟹ match test r2 i j = (⨆ (match test ` rpd test j r2)) i (j - 1); i < j⟧ ⟹ match test (Plus r1 r2) i j = (⨆ (match test ` rpd test j (Plus r1 r2))) i (j - 1)› 4. ‹⋀r1 r2 i j. ⟦⋀i j. i < j ⟹ match test r1 i j = (⨆ (match test ` rpd test j r1)) i (j - 1); ⋀i j. i < j ⟹ match test r2 i j = (⨆ (match test ` rpd test j r2)) i (j - 1); i < j⟧ ⟹ match test (Times r1 r2) i j = (⨆ (match test ` rpd test j (Times r1 r2))) i (j - 1)› 5. ‹⋀r i j. ⟦⋀i j. i < j ⟹ match test r i j = (⨆ (match test ` rpd test j r)) i (j - 1); i < j⟧ ⟹ match test (Star r) i j = (⨆ (match test ` rpd test j (Star r))) i (j - 1)›*) case (Times r s) (*‹(?i::nat) < (?j::nat) ⟹ match (test::nat ⇒ 'a::type ⇒ bool) (r::'a::type regex) ?i ?j = (⨆ (match test ` rpd test ?j r)) ?i (?j - (1::nat))› ‹?i < ?j ⟹ match test s ?i ?j = (⨆ (match test ` rpd test ?j s)) ?i (?j - 1)› ‹(i::nat) < (j::nat)›*) have "match test (Times r s) i j ⟷ (∃k. match test r i k ∧ match test s k j)" by auto also (*calculation: ‹match test (Times r s) i j = (∃k. match test r i k ∧ match test s k j)›*) have "… ⟷ match test r i j ∧ match test s j j ∨ (∃k<j. match test r i k ∧ match test s k j)" using match_le[of test s _ j] (*‹match test s ?i j ⟹ ?i ≤ j›*) nat_less_le (*‹(?m < ?n) = (?m ≤ ?n ∧ ?m ≠ ?n)›*) by auto also (*calculation: ‹match test (Times r s) i j = (match test r i j ∧ match test s j j ∨ (∃k<j. match test r i k ∧ match test s k j))›*) have "… ⟷ (⨆t ∈ rpd test j r. match test t) i (j - 1) ∧ match test s j j ∨ (∃k<j. match test r i k ∧ (⨆t ∈ rpd test j s. match test t) k (j - 1))" using Times.IH(1)[OF Times.prems] (*‹match test r i j = (⨆ (match test ` rpd test j r)) i (j - 1)›*) Times.IH(2) (*‹?i < ?j ⟹ match test s ?i ?j = (⨆ (match test ` rpd test ?j s)) ?i (?j - 1)›*) by metis also (*calculation: ‹match test (Times r s) i j = ((⨆ (match test ` rpd test j r)) i (j - 1) ∧ match test s j j ∨ (∃k<j. match test r i k ∧ (⨆ (match test ` rpd test j s)) k (j - 1)))›*) have "… ⟷ (⨆t ∈ rpd test j r. match test t) i (j - 1) ∧ match test s j j ∨ (∃k. match test r i k ∧ (⨆t ∈ rpd test j s. match test t) k (j - 1))" using Times.prems (*‹(i::nat) < (j::nat)›*) apply (intro disj_cong[OF refl] (*‹(¬ ?P ⟹ ?Q = ?Q') ⟹ (?P ∨ ?Q) = (?P ∨ ?Q')›*) iff_exI (*‹(⋀x. ?P x = ?Q x) ⟹ (∃x. ?P x) = (∃x. ?Q x)›*)) (*goal: ‹((⨆ (match test ` rpd test j r)) i (j - 1) ∧ match test s j j ∨ (∃k<j. match test r i k ∧ (⨆ (match test ` rpd test j s)) k (j - 1))) = ((⨆ (match test ` rpd test j r)) i (j - 1) ∧ match test s j j ∨ (∃k. match test r i k ∧ (⨆ (match test ` rpd test j s)) k (j - 1)))›*) by (auto dest: match_le (*‹match ?test ?r ?i ?j ⟹ ?i ≤ ?j›*)) also (*calculation: ‹match test (Times r s) i j = ((⨆ (match test ` rpd test j r)) i (j - 1) ∧ match test s j j ∨ (∃k. match test r i k ∧ (⨆ (match test ` rpd test j s)) k (j - 1)))›*) have "… ⟷ (⨆ (match test ` rpd test j (Times r s))) i (j - 1)" by (force simp: TimesL_def (*‹TimesL ?r ?S = Times ?r ` ?S›*) TimesR_def (*‹TimesR ?R ?s = (λr. Times r ?s) ` ?R›*) eps_match (*‹eps ?test ?i ?r = match ?test ?r ?i ?i›*)) finally (*calculation: ‹match test (Times r s) i j = (⨆ (match test ` rpd test j (Times r s))) i (j - 1)›*) show "?case" (*goal: ‹match test (Times r s) i j = (⨆ (match test ` rpd test j (Times r s))) i (j - 1)›*) . next (*goals: 1. ‹⋀x i j. i < j ⟹ match test (Skip x) i j = (⨆ (match test ` rpd test j (Skip x))) i (j - 1)› 2. ‹⋀x i j. i < j ⟹ match test (Test x) i j = (⨆ (match test ` rpd test j (Test x))) i (j - 1)› 3. ‹⋀r1 r2 i j. ⟦⋀i j. i < j ⟹ match test r1 i j = (⨆ (match test ` rpd test j r1)) i (j - 1); ⋀i j. i < j ⟹ match test r2 i j = (⨆ (match test ` rpd test j r2)) i (j - 1); i < j⟧ ⟹ match test (Plus r1 r2) i j = (⨆ (match test ` rpd test j (Plus r1 r2))) i (j - 1)› 4. ‹⋀r i j. ⟦⋀i j. i < j ⟹ match test r i j = (⨆ (match test ` rpd test j r)) i (j - 1); i < j⟧ ⟹ match test (Star r) i j = (⨆ (match test ` rpd test j (Star r))) i (j - 1)›*) case (Star r) (*‹?i < ?j ⟹ match test r ?i ?j = (⨆ (match test ` rpd test ?j r)) ?i (?j - 1)› ‹i < j›*) have "∃s∈rpd test j r. ((match test r)⇧*⇧* OO match test s) i (j - 1)" if "(match test r)⇧*⇧* i j" using that (*‹(match test r)⇧*⇧* i j›*) Star.prems (*‹i < j›*) match_le[of test _ _ "j - 1"] (*‹match test ?r ?i (j - 1) ⟹ ?i ≤ j - 1›*) proof (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. ‹⟦(i::nat) < i; ⋀(r::'a regex) i::nat. match (test::nat ⇒ 'a ⇒ bool) r i (i - (1::nat)) ⟹ i ≤ i - (1::nat)⟧ ⟹ ∃s::'a regex∈rpd test i (r::'a regex). ((match test r)⇧*⇧* OO match test s) i (i - (1::nat))› 2. ‹⋀(y::nat) z::nat. ⟦(match (test::nat ⇒ 'a ⇒ bool) (r::'a regex))⇧*⇧* (i::nat) y; match test r y z; ⟦i < y; ⋀(r::'a regex) i::nat. match test r i (y - (1::nat)) ⟹ i ≤ y - (1::nat)⟧ ⟹ ∃s::'a regex∈rpd test y r. ((match test r)⇧*⇧* OO match test s) i (y - (1::nat)); i < z; ⋀(r::'a regex) i::nat. match test r i (z - (1::nat)) ⟹ i ≤ z - (1::nat)⟧ ⟹ ∃s::'a regex∈rpd test z r. ((match test r)⇧*⇧* OO match test s) i (z - (1::nat))›*) case (step k j) (*‹(match test r)⇧*⇧* i k› ‹match test r k j› ‹⟦i < k; ⋀r i. match test r i (k - 1) ⟹ i ≤ k - 1⟧ ⟹ ∃s∈rpd test k r. ((match test r)⇧*⇧* OO match test s) i (k - 1)› ‹i < j› ‹match test ?r ?i (j - 1) ⟹ ?i ≤ j - 1›*) then show "?case" (*goal: ‹∃s∈rpd test j r. ((match test r)⇧*⇧* OO match test s) i (j - 1)›*) apply (cases "k < j") (*goals: 1. ‹⟦(match test r)⇧*⇧* i k; match test r k j; ⟦i < k; ⋀r i. match test r i (k - 1) ⟹ i ≤ k - 1⟧ ⟹ ∃s∈rpd test k r. ((match test r)⇧*⇧* OO match test s) i (k - 1); i < j; ⋀r i. match test r i (j - 1) ⟹ i ≤ j - 1; k < j⟧ ⟹ ∃s∈rpd test j r. ((match test r)⇧*⇧* OO match test s) i (j - 1)› 2. ‹⟦(match test r)⇧*⇧* i k; match test r k j; ⟦i < k; ⋀r i. match test r i (k - 1) ⟹ i ≤ k - 1⟧ ⟹ ∃s∈rpd test k r. ((match test r)⇧*⇧* OO match test s) i (k - 1); i < j; ⋀r i. match test r i (j - 1) ⟹ i ≤ j - 1; ¬ k < j⟧ ⟹ ∃s∈rpd test j r. ((match test r)⇧*⇧* OO match test s) i (j - 1)› discuss goal 1*) apply ((auto simp: not_less (*‹(¬ (?x::?'a) < (?y::?'a)) = (?y ≤ ?x)›*) Star.IH (*‹(?i::nat) < (?j::nat) ⟹ match (test::nat ⇒ 'a ⇒ bool) (r::'a regex) ?i ?j = (⨆ (match test ` rpd test ?j r)) ?i (?j - (1::nat))›*) dest: match_le (*‹match (?test::nat ⇒ ?'a ⇒ bool) (?r::?'a regex) (?i::nat) (?j::nat) ⟹ ?i ≤ ?j›*))[1]) (*discuss goal 2*) apply ((auto simp: not_less (*‹(¬ ?x < ?y) = (?y ≤ ?x)›*) Star.IH (*‹?i < ?j ⟹ match test r ?i ?j = (⨆ (match test ` rpd test ?j r)) ?i (?j - 1)›*) dest: match_le (*‹match ?test ?r ?i ?j ⟹ ?i ≤ ?j›*))[1]) (*proven 2 subgoals*) . qed (simp) (*solved the remaining goal: ‹⟦i < i; ⋀r i. match test r i (i - 1) ⟹ i ≤ i - 1⟧ ⟹ ∃s∈rpd test i r. ((match test r)⇧*⇧* OO match test s) i (i - 1)›*) with Star.prems (*‹i < j›*) show "?case" (*goal: ‹match test (Star r) i j = (⨆ (match test ` rpd test j (Star r))) i (j - 1)›*) by (auto 0 3 simp: TimesL_def (*‹TimesL (?r::?'a::type regex) (?S::?'a::type regex set) = Times ?r ` ?S›*) TimesR_def (*‹TimesR (?R::?'a::type regex set) (?s::?'a::type regex) = (λr::?'a::type regex. Times r ?s) ` ?R›*) intro: Star.IH[of _ j, THEN iffD2] (*‹⟦(?i1::nat) < (j::nat); (⨆ (match (test::nat ⇒ 'a::type ⇒ bool) ` rpd test j (r::'a::type regex))) ?i1 (j - (1::nat))⟧ ⟹ match test r ?i1 j›*) elim!: rtranclp.rtrancl_into_rtrancl (*‹⟦(?r::?'a::type ⇒ ?'a::type ⇒ bool)⇧*⇧* (?a::?'a::type) (?b::?'a::type); ?r ?b (?c::?'a::type)⟧ ⟹ ?r⇧*⇧* ?a ?c›*) dest: match_le[of test _ _ "j - 1", unfolded One_nat_def] (*‹match (test::nat ⇒ 'a::type ⇒ bool) (?r::'a::type regex) (?i::nat) ((j::nat) - Suc (0::nat)) ⟹ ?i ≤ j - Suc (0::nat)›*)) qed (auto split: nat.splits (*‹(?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)))› ‹(?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))))›*)) (*solves the remaining goals: 1. ‹⋀x i j. i < j ⟹ match test (Skip x) i j = (⨆ (match test ` rpd test j (Skip x))) i (j - 1)› 2. ‹⋀x i j. i < j ⟹ match test (Test x) i j = (⨆ (match test ` rpd test j (Test x))) i (j - 1)› 3. ‹⋀r1 r2 i j. ⟦⋀i j. i < j ⟹ match test r1 i j = (⨆ (match test ` rpd test j r1)) i (j - 1); ⋀i j. i < j ⟹ match test r2 i j = (⨆ (match test ` rpd test j r2)) i (j - 1); i < j⟧ ⟹ match test (Plus r1 r2) i j = (⨆ (match test ` rpd test j (Plus r1 r2))) i (j - 1)›*) lemma lpd_fv_regex: "s ∈ lpd test i r ⟹ fv_regex fv s ⊆ fv_regex fv r" apply (induct r arbitrary: s) (*goals: 1. ‹⋀x s. s ∈ lpd test i (Skip x) ⟹ fv_regex fv s ⊆ fv_regex fv (Skip x)› 2. ‹⋀x s. s ∈ lpd test i (Test x) ⟹ fv_regex fv s ⊆ fv_regex fv (Test x)› 3. ‹⋀r1 r2 s. ⟦⋀s. s ∈ lpd test i r1 ⟹ fv_regex fv s ⊆ fv_regex fv r1; ⋀s. s ∈ lpd test i r2 ⟹ fv_regex fv s ⊆ fv_regex fv r2; s ∈ lpd test i (Plus r1 r2)⟧ ⟹ fv_regex fv s ⊆ fv_regex fv (Plus r1 r2)› 4. ‹⋀r1 r2 s. ⟦⋀s. s ∈ lpd test i r1 ⟹ fv_regex fv s ⊆ fv_regex fv r1; ⋀s. s ∈ lpd test i r2 ⟹ fv_regex fv s ⊆ fv_regex fv r2; s ∈ lpd test i (Times r1 r2)⟧ ⟹ fv_regex fv s ⊆ fv_regex fv (Times r1 r2)› 5. ‹⋀r s. ⟦⋀s. s ∈ lpd test i r ⟹ fv_regex fv s ⊆ fv_regex fv r; s ∈ lpd test i (Star r)⟧ ⟹ fv_regex fv s ⊆ fv_regex fv (Star r)› discuss goal 1*) apply ((auto simp: TimesR_def (*‹TimesR ?R ?s = (λr. Times r ?s) ` ?R›*) TimesL_def (*‹TimesL ?r ?S = Times ?r ` ?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))›*) 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: TimesR_def (*‹TimesR ?R ?s = (λr. Times r ?s) ` ?R›*) TimesL_def (*‹TimesL ?r ?S = Times ?r ` ?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))›*) 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 3*) apply ((auto simp: TimesR_def (*‹TimesR ?R ?s = (λr. Times r ?s) ` ?R›*) TimesL_def (*‹TimesL ?r ?S = Times ?r ` ?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))›*) 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 4*) apply ((auto simp: TimesR_def (*‹TimesR (?R::?'a::type regex set) (?s::?'a::type regex) = (λr::?'a::type regex. Times r ?s) ` ?R›*) TimesL_def (*‹TimesL (?r::?'a::type regex) (?S::?'a::type regex set) = Times ?r ` ?S›*) 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))›*) 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))))›*))[1]) (*goals: 1. ‹⋀(r1::'a regex) (r2::'a regex) (x::'c) r::'a regex. ⟦⋀s::'a regex. s ∈ lpd (test::'b ⇒ 'a ⇒ bool) (i::'b) r1 ⟹ fv_regex (fv::'a ⇒ 'c set) s ⊆ fv_regex fv r1; ⋀s::'a regex. s ∈ lpd test i r2 ⟹ fv_regex fv s ⊆ fv_regex fv r2; eps test i r1; x ∈ fv_regex fv r; x ∉ fv_regex fv r2; r ∈ lpd test i r1⟧ ⟹ x ∈ fv_regex fv r1› 2. ‹⋀(r1::'a regex) (r2::'a regex) (r::'a regex) x::'c. ⟦⋀s::'a regex. s ∈ lpd (test::'b ⇒ 'a ⇒ bool) (i::'b) r1 ⟹ fv_regex (fv::'a ⇒ 'c set) s ⊆ fv_regex fv r1; ⋀s::'a regex. s ∈ lpd test i r2 ⟹ fv_regex fv s ⊆ fv_regex fv r2; ¬ eps test i r1; r ∈ lpd test i r1; x ∈ fv_regex fv r; x ∉ fv_regex fv r2⟧ ⟹ x ∈ fv_regex fv r1› discuss goal 1*) apply ((auto simp: TimesR_def (*‹TimesR ?R ?s = (λr. Times r ?s) ` ?R›*) TimesL_def (*‹TimesL ?r ?S = Times ?r ` ?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))›*) 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: TimesR_def (*‹TimesR ?R ?s = (λr. Times r ?s) ` ?R›*) TimesL_def (*‹TimesL ?r ?S = Times ?r ` ?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))›*) 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*) (*discuss goal 5*) apply ((auto simp: TimesR_def (*‹TimesR ?R ?s = (λr. Times r ?s) ` ?R›*) TimesL_def (*‹TimesL ?r ?S = Times ?r ` ?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))›*) 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]) (*goal: ‹⋀r s. ⟦⋀s. s ∈ lpd test i r ⟹ fv_regex fv s ⊆ fv_regex fv r; s ∈ lpd test i (Star r)⟧ ⟹ fv_regex fv s ⊆ fv_regex fv (Star r)›*) apply ((auto simp: TimesR_def (*‹TimesR ?R ?s = (λr. Times r ?s) ` ?R›*) TimesL_def (*‹TimesL ?r ?S = Times ?r ` ?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))›*) 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 5 subgoals*) . lemma rpd_fv_regex: "s ∈ rpd test i r ⟹ fv_regex fv s ⊆ fv_regex fv r" apply (induct r arbitrary: s) (*goals: 1. ‹⋀x s. s ∈ rpd test i (Skip x) ⟹ fv_regex fv s ⊆ fv_regex fv (Skip x)› 2. ‹⋀x s. s ∈ rpd test i (Test x) ⟹ fv_regex fv s ⊆ fv_regex fv (Test x)› 3. ‹⋀r1 r2 s. ⟦⋀s. s ∈ rpd test i r1 ⟹ fv_regex fv s ⊆ fv_regex fv r1; ⋀s. s ∈ rpd test i r2 ⟹ fv_regex fv s ⊆ fv_regex fv r2; s ∈ rpd test i (Plus r1 r2)⟧ ⟹ fv_regex fv s ⊆ fv_regex fv (Plus r1 r2)› 4. ‹⋀r1 r2 s. ⟦⋀s. s ∈ rpd test i r1 ⟹ fv_regex fv s ⊆ fv_regex fv r1; ⋀s. s ∈ rpd test i r2 ⟹ fv_regex fv s ⊆ fv_regex fv r2; s ∈ rpd test i (Times r1 r2)⟧ ⟹ fv_regex fv s ⊆ fv_regex fv (Times r1 r2)› 5. ‹⋀r s. ⟦⋀s. s ∈ rpd test i r ⟹ fv_regex fv s ⊆ fv_regex fv r; s ∈ rpd test i (Star r)⟧ ⟹ fv_regex fv s ⊆ fv_regex fv (Star r)› discuss goal 1*) apply ((auto simp: TimesR_def (*‹TimesR ?R ?s = (λr. Times r ?s) ` ?R›*) TimesL_def (*‹TimesL ?r ?S = Times ?r ` ?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))›*) 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: TimesR_def (*‹TimesR ?R ?s = (λr. Times r ?s) ` ?R›*) TimesL_def (*‹TimesL ?r ?S = Times ?r ` ?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))›*) 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 3*) apply ((auto simp: TimesR_def (*‹TimesR ?R ?s = (λr. Times r ?s) ` ?R›*) TimesL_def (*‹TimesL ?r ?S = Times ?r ` ?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))›*) 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 4*) apply ((auto simp: TimesR_def (*‹TimesR ?R ?s = (λr. Times r ?s) ` ?R›*) TimesL_def (*‹TimesL ?r ?S = Times ?r ` ?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))›*) 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]) (*goals: 1. ‹⋀r1 r2 x xa. ⟦⋀s. s ∈ rpd test i r1 ⟹ fv_regex fv s ⊆ fv_regex fv r1; ⋀s. s ∈ rpd test i r2 ⟹ fv_regex fv s ⊆ fv_regex fv r2; eps test i r2; x ∉ fv_regex fv r2; xa ∈ rpd test i r2; x ∈ fv_regex fv xa⟧ ⟹ x ∈ fv_regex fv r1› 2. ‹⋀r1 r2 x xa. ⟦⋀s. s ∈ rpd test i r1 ⟹ fv_regex fv s ⊆ fv_regex fv r1; ⋀s. s ∈ rpd test i r2 ⟹ fv_regex fv s ⊆ fv_regex fv r2; ¬ eps test i r2; x ∈ rpd test i r2; xa ∉ fv_regex fv r2; xa ∈ fv_regex fv x⟧ ⟹ xa ∈ fv_regex fv r1› discuss goal 1*) apply ((auto simp: TimesR_def (*‹TimesR ?R ?s = (λr. Times r ?s) ` ?R›*) TimesL_def (*‹TimesL ?r ?S = Times ?r ` ?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))›*) 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: TimesR_def (*‹TimesR ?R ?s = (λr. Times r ?s) ` ?R›*) TimesL_def (*‹TimesL ?r ?S = Times ?r ` ?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))›*) 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*) (*discuss goal 5*) apply ((auto simp: TimesR_def (*‹TimesR ?R ?s = (λr. Times r ?s) ` ?R›*) TimesL_def (*‹TimesL ?r ?S = Times ?r ` ?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))›*) 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]) (*goal: ‹⋀r s. ⟦⋀s. s ∈ rpd test i r ⟹ fv_regex fv s ⊆ fv_regex fv r; s ∈ rpd test i (Star r)⟧ ⟹ fv_regex fv s ⊆ fv_regex fv (Star r)›*) apply ((auto simp: TimesR_def (*‹TimesR ?R ?s = (λr. Times r ?s) ` ?R›*) TimesL_def (*‹TimesL ?r ?S = Times ?r ` ?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))›*) 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 5 subgoals*) . lemma match_fv_cong: "(⋀i x. x ∈ atms r ⟹ test i x = test' i x) ⟹ match test r = match test' r" apply (induct r) (*goals: 1. ‹⋀x. (⋀i xa. xa ∈ atms (Skip x) ⟹ test i xa = test' i xa) ⟹ match test (Skip x) = match test' (Skip x)› 2. ‹⋀x. (⋀i xa. xa ∈ atms (Test x) ⟹ test i xa = test' i xa) ⟹ match test (Test x) = match test' (Test x)› 3. ‹⋀r1 r2. ⟦(⋀i x. x ∈ atms r1 ⟹ test i x = test' i x) ⟹ match test r1 = match test' r1; (⋀i x. x ∈ atms r2 ⟹ test i x = test' i x) ⟹ match test r2 = match test' r2; ⋀i x. x ∈ atms (Plus r1 r2) ⟹ test i x = test' i x⟧ ⟹ match test (Plus r1 r2) = match test' (Plus r1 r2)› 4. ‹⋀r1 r2. ⟦(⋀i x. x ∈ atms r1 ⟹ test i x = test' i x) ⟹ match test r1 = match test' r1; (⋀i x. x ∈ atms r2 ⟹ test i x = test' i x) ⟹ match test r2 = match test' r2; ⋀i x. x ∈ atms (Times r1 r2) ⟹ test i x = test' i x⟧ ⟹ match test (Times r1 r2) = match test' (Times r1 r2)› 5. ‹⋀r. ⟦(⋀i x. x ∈ atms r ⟹ test i x = test' i x) ⟹ match test r = match test' r; ⋀i x. x ∈ atms (Star r) ⟹ test i x = test' i x⟧ ⟹ match test (Star r) = match test' (Star 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]) (*proven 5 subgoals*) . lemma eps_fv_cong: "(⋀i x. x ∈ atms r ⟹ test i x = test' i x) ⟹ eps test i r = eps test' i r" apply (induct r) (*goals: 1. ‹⋀x. (⋀i xa. xa ∈ atms (Skip x) ⟹ test i xa = test' i xa) ⟹ eps test i (Skip x) = eps test' i (Skip x)› 2. ‹⋀x. (⋀i xa. xa ∈ atms (Test x) ⟹ test i xa = test' i xa) ⟹ eps test i (Test x) = eps test' i (Test x)› 3. ‹⋀r1 r2. ⟦(⋀i x. x ∈ atms r1 ⟹ test i x = test' i x) ⟹ eps test i r1 = eps test' i r1; (⋀i x. x ∈ atms r2 ⟹ test i x = test' i x) ⟹ eps test i r2 = eps test' i r2; ⋀i x. x ∈ atms (Plus r1 r2) ⟹ test i x = test' i x⟧ ⟹ eps test i (Plus r1 r2) = eps test' i (Plus r1 r2)› 4. ‹⋀r1 r2. ⟦(⋀i x. x ∈ atms r1 ⟹ test i x = test' i x) ⟹ eps test i r1 = eps test' i r1; (⋀i x. x ∈ atms r2 ⟹ test i x = test' i x) ⟹ eps test i r2 = eps test' i r2; ⋀i x. x ∈ atms (Times r1 r2) ⟹ test i x = test' i x⟧ ⟹ eps test i (Times r1 r2) = eps test' i (Times r1 r2)› 5. ‹⋀r. ⟦(⋀i x. x ∈ atms r ⟹ test i x = test' i x) ⟹ eps test i r = eps test' i r; ⋀i x. x ∈ atms (Star r) ⟹ test i x = test' i x⟧ ⟹ eps test i (Star r) = eps test' i (Star 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]) (*proven 5 subgoals*) . datatype modality = Past | Futu datatype safety = Strict | Lax context fixes fv :: "'a ⇒ 'b set" and safe :: "safety ⇒ 'a ⇒ bool" begin qualified fun safe_regex :: "modality ⇒ safety ⇒ 'a regex ⇒ bool" where "safe_regex m _ (Skip n) = True" | "safe_regex m g (Test φ) = safe g φ" | "safe_regex m g (Plus r s) = ((g = Lax ∨ fv_regex fv r = fv_regex fv s) ∧ safe_regex m g r ∧ safe_regex m g s)" | "safe_regex Futu g (Times r s) = ((g = Lax ∨ fv_regex fv r ⊆ fv_regex fv s) ∧ safe_regex Futu g s ∧ safe_regex Futu Lax r)" | "safe_regex Past g (Times r s) = ((g = Lax ∨ fv_regex fv s ⊆ fv_regex fv r) ∧ safe_regex Past g r ∧ safe_regex Past Lax s)" | "safe_regex m g (Star r) = ((g = Lax ∨ fv_regex fv r = {}) ∧ safe_regex m g r)" lemmas safe_regex_induct = safe_regex.induct[case_names Skip Test Plus TimesF TimesP Star] lemma safe_cosafe: "(⋀x. x ∈ atms r ⟹ safe Strict x ⟹ safe Lax x) ⟹ safe_regex m Strict r ⟹ safe_regex m Lax r" apply (induct r) (*goals: 1. ‹⋀x. ⟦⋀xa. ⟦xa ∈ atms (Skip x); safe Strict xa⟧ ⟹ safe Lax xa; safe_regex m Strict (Skip x)⟧ ⟹ safe_regex m Lax (Skip x)› 2. ‹⋀x. ⟦⋀xa. ⟦xa ∈ atms (Test x); safe Strict xa⟧ ⟹ safe Lax xa; safe_regex m Strict (Test x)⟧ ⟹ safe_regex m Lax (Test x)› 3. ‹⋀r1 r2. ⟦⟦⋀x. ⟦x ∈ atms r1; safe Strict x⟧ ⟹ safe Lax x; safe_regex m Strict r1⟧ ⟹ safe_regex m Lax r1; ⟦⋀x. ⟦x ∈ atms r2; safe Strict x⟧ ⟹ safe Lax x; safe_regex m Strict r2⟧ ⟹ safe_regex m Lax r2; ⋀x. ⟦x ∈ atms (Plus r1 r2); safe Strict x⟧ ⟹ safe Lax x; safe_regex m Strict (Plus r1 r2)⟧ ⟹ safe_regex m Lax (Plus r1 r2)› 4. ‹⋀r1 r2. ⟦⟦⋀x. ⟦x ∈ atms r1; safe Strict x⟧ ⟹ safe Lax x; safe_regex m Strict r1⟧ ⟹ safe_regex m Lax r1; ⟦⋀x. ⟦x ∈ atms r2; safe Strict x⟧ ⟹ safe Lax x; safe_regex m Strict r2⟧ ⟹ safe_regex m Lax r2; ⋀x. ⟦x ∈ atms (Times r1 r2); safe Strict x⟧ ⟹ safe Lax x; safe_regex m Strict (Times r1 r2)⟧ ⟹ safe_regex m Lax (Times r1 r2)› 5. ‹⋀r. ⟦⟦⋀x. ⟦x ∈ atms r; safe Strict x⟧ ⟹ safe Lax x; safe_regex m Strict r⟧ ⟹ safe_regex m Lax r; ⋀x. ⟦x ∈ atms (Star r); safe Strict x⟧ ⟹ safe Lax x; safe_regex m Strict (Star r)⟧ ⟹ safe_regex m Lax (Star r)› discuss goal 1*) apply (cases m) (*goals: 1. ‹⋀x. ⟦⋀xa. ⟦xa ∈ atms (Skip x); safe Strict xa⟧ ⟹ safe Lax xa; safe_regex m Strict (Skip x); m = Past⟧ ⟹ safe_regex m Lax (Skip x)› 2. ‹⋀x. ⟦⋀xa. ⟦xa ∈ atms (Skip x); safe Strict xa⟧ ⟹ safe Lax xa; safe_regex m Strict (Skip x); m = Futu⟧ ⟹ safe_regex m Lax (Skip x)› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) (*discuss goal 2*) apply (cases m) (*goals: 1. ‹⋀x::'a::type. ⟦⋀xa::'a::type. ⟦xa ∈ atms (Test x); (safe::safety ⇒ 'a::type ⇒ bool) Strict xa⟧ ⟹ safe Lax xa; safe_regex (m::modality) Strict (Test x); m = Past⟧ ⟹ safe_regex m Lax (Test x)› 2. ‹⋀x::'a::type. ⟦⋀xa::'a::type. ⟦xa ∈ atms (Test x); (safe::safety ⇒ 'a::type ⇒ bool) Strict xa⟧ ⟹ safe Lax xa; safe_regex (m::modality) Strict (Test x); m = Futu⟧ ⟹ safe_regex m Lax (Test x)› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) (*discuss goal 3*) apply (cases m) (*goals: 1. ‹⋀(r1::'a::type regex) r2::'a::type regex. ⟦⟦⋀x::'a::type. ⟦x ∈ atms r1; (safe::safety ⇒ 'a::type ⇒ bool) Strict x⟧ ⟹ safe Lax x; safe_regex (m::modality) Strict r1⟧ ⟹ safe_regex m Lax r1; ⟦⋀x::'a::type. ⟦x ∈ atms r2; safe Strict x⟧ ⟹ safe Lax x; safe_regex m Strict r2⟧ ⟹ safe_regex m Lax r2; ⋀x::'a::type. ⟦x ∈ atms (Plus r1 r2); safe Strict x⟧ ⟹ safe Lax x; safe_regex m Strict (Plus r1 r2); m = Past⟧ ⟹ safe_regex m Lax (Plus r1 r2)› 2. ‹⋀(r1::'a::type regex) r2::'a::type regex. ⟦⟦⋀x::'a::type. ⟦x ∈ atms r1; (safe::safety ⇒ 'a::type ⇒ bool) Strict x⟧ ⟹ safe Lax x; safe_regex (m::modality) Strict r1⟧ ⟹ safe_regex m Lax r1; ⟦⋀x::'a::type. ⟦x ∈ atms r2; safe Strict x⟧ ⟹ safe Lax x; safe_regex m Strict r2⟧ ⟹ safe_regex m Lax r2; ⋀x::'a::type. ⟦x ∈ atms (Plus r1 r2); safe Strict x⟧ ⟹ safe Lax x; safe_regex m Strict (Plus r1 r2); m = Futu⟧ ⟹ safe_regex m Lax (Plus r1 r2)› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) (*discuss goal 4*) apply (cases m) (*goals: 1. ‹⋀r1 r2. ⟦⟦⋀x. ⟦x ∈ atms r1; safe Strict x⟧ ⟹ safe Lax x; safe_regex m Strict r1⟧ ⟹ safe_regex m Lax r1; ⟦⋀x. ⟦x ∈ atms r2; safe Strict x⟧ ⟹ safe Lax x; safe_regex m Strict r2⟧ ⟹ safe_regex m Lax r2; ⋀x. ⟦x ∈ atms (Times r1 r2); safe Strict x⟧ ⟹ safe Lax x; safe_regex m Strict (Times r1 r2); m = Past⟧ ⟹ safe_regex m Lax (Times r1 r2)› 2. ‹⋀r1 r2. ⟦⟦⋀x. ⟦x ∈ atms r1; safe Strict x⟧ ⟹ safe Lax x; safe_regex m Strict r1⟧ ⟹ safe_regex m Lax r1; ⟦⋀x. ⟦x ∈ atms r2; safe Strict x⟧ ⟹ safe Lax x; safe_regex m Strict r2⟧ ⟹ safe_regex m Lax r2; ⋀x. ⟦x ∈ atms (Times r1 r2); safe Strict x⟧ ⟹ safe Lax x; safe_regex m Strict (Times r1 r2); m = Futu⟧ ⟹ safe_regex m Lax (Times r1 r2)› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) (*discuss goal 5*) apply (cases m) (*goals: 1. ‹⋀r. ⟦⟦⋀x. ⟦x ∈ atms r; safe Strict x⟧ ⟹ safe Lax x; safe_regex m Strict r⟧ ⟹ safe_regex m Lax r; ⋀x. ⟦x ∈ atms (Star r); safe Strict x⟧ ⟹ safe Lax x; safe_regex m Strict (Star r); m = Past⟧ ⟹ safe_regex m Lax (Star r)› 2. ‹⋀r. ⟦⟦⋀x. ⟦x ∈ atms r; safe Strict x⟧ ⟹ safe Lax x; safe_regex m Strict r⟧ ⟹ safe_regex m Lax r; ⋀x. ⟦x ∈ atms (Star r); safe Strict x⟧ ⟹ safe Lax x; safe_regex m Strict (Star r); m = Futu⟧ ⟹ safe_regex m Lax (Star r)› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) (*proven 5 subgoals*) . lemma safe_lpd_fv_regex_le: "safe_regex Futu Strict r ⟹ s ∈ lpd test i r ⟹ fv_regex fv r ⊆ fv_regex fv s" apply (induct r) (*goals: 1. ‹⋀x::nat. ⟦safe_regex Futu Strict (Skip x); (s::'a regex) ∈ lpd (test::'c ⇒ 'a ⇒ bool) (i::'c) (Skip x)⟧ ⟹ fv_regex (fv::'a ⇒ 'b set) (Skip x) ⊆ fv_regex fv s› 2. ‹⋀x::'a. ⟦safe_regex Futu Strict (Test x); (s::'a regex) ∈ lpd (test::'c ⇒ 'a ⇒ bool) (i::'c) (Test x)⟧ ⟹ fv_regex (fv::'a ⇒ 'b set) (Test x) ⊆ fv_regex fv s› 3. ‹⋀(r1::'a regex) r2::'a regex. ⟦⟦safe_regex Futu Strict r1; (s::'a regex) ∈ lpd (test::'c ⇒ 'a ⇒ bool) (i::'c) r1⟧ ⟹ fv_regex (fv::'a ⇒ 'b set) r1 ⊆ fv_regex fv s; ⟦safe_regex Futu Strict r2; s ∈ lpd test i r2⟧ ⟹ fv_regex fv r2 ⊆ fv_regex fv s; safe_regex Futu Strict (Plus r1 r2); s ∈ lpd test i (Plus r1 r2)⟧ ⟹ fv_regex fv (Plus r1 r2) ⊆ fv_regex fv s› 4. ‹⋀(r1::'a regex) r2::'a regex. ⟦⟦safe_regex Futu Strict r1; (s::'a regex) ∈ lpd (test::'c ⇒ 'a ⇒ bool) (i::'c) r1⟧ ⟹ fv_regex (fv::'a ⇒ 'b set) r1 ⊆ fv_regex fv s; ⟦safe_regex Futu Strict r2; s ∈ lpd test i r2⟧ ⟹ fv_regex fv r2 ⊆ fv_regex fv s; safe_regex Futu Strict (Times r1 r2); s ∈ lpd test i (Times r1 r2)⟧ ⟹ fv_regex fv (Times r1 r2) ⊆ fv_regex fv s› 5. ‹⋀r::'a regex. ⟦⟦safe_regex Futu Strict r; (s::'a regex) ∈ lpd (test::'c ⇒ 'a ⇒ bool) (i::'c) r⟧ ⟹ fv_regex (fv::'a ⇒ 'b set) r ⊆ fv_regex fv s; safe_regex Futu Strict (Star r); s ∈ lpd test i (Star r)⟧ ⟹ fv_regex fv (Star r) ⊆ fv_regex fv s› discuss goal 1*) apply ((auto simp: TimesR_def (*‹TimesR ?R ?s = (λr. Times r ?s) ` ?R›*) 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: TimesR_def (*‹TimesR ?R ?s = (λr. Times r ?s) ` ?R›*) 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: TimesR_def (*‹TimesR ?R ?s = (λr. Times r ?s) ` ?R›*) 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 simp: TimesR_def (*‹TimesR (?R::?'a regex set) (?s::?'a regex) = (λr::?'a regex. Times r ?s) ` ?R›*) 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 5*) apply ((auto simp: TimesR_def (*‹TimesR ?R ?s = (λr. Times r ?s) ` ?R›*) 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 safe_lpd_fv_regex: "safe_regex Futu Strict r ⟹ s ∈ lpd test i r ⟹ fv_regex fv s = fv_regex fv r" by (simp add: eq_iff (*‹(?a = ?b) = (?a ≤ ?b ∧ ?b ≤ ?a)›*) lpd_fv_regex (*‹?s ∈ lpd ?test ?i ?r ⟹ fv_regex ?fv ?s ⊆ fv_regex ?fv ?r›*) safe_lpd_fv_regex_le (*‹⟦safe_regex Futu Strict ?r; ?s ∈ lpd ?test ?i ?r⟧ ⟹ fv_regex fv ?r ⊆ fv_regex fv ?s›*)) lemma cosafe_lpd: "safe_regex Futu Lax r ⟹ s ∈ lpd test i r ⟹ safe_regex Futu Lax s" proof (induct r arbitrary: s) (*goals: 1. ‹⋀x s. ⟦safe_regex Futu Lax (Skip x); s ∈ lpd test i (Skip x)⟧ ⟹ safe_regex Futu Lax s› 2. ‹⋀x s. ⟦safe_regex Futu Lax (Test x); s ∈ lpd test i (Test x)⟧ ⟹ safe_regex Futu Lax s› 3. ‹⋀r1 r2 s. ⟦⋀s. ⟦safe_regex Futu Lax r1; s ∈ lpd test i r1⟧ ⟹ safe_regex Futu Lax s; ⋀s. ⟦safe_regex Futu Lax r2; s ∈ lpd test i r2⟧ ⟹ safe_regex Futu Lax s; safe_regex Futu Lax (Plus r1 r2); s ∈ lpd test i (Plus r1 r2)⟧ ⟹ safe_regex Futu Lax s› 4. ‹⋀r1 r2 s. ⟦⋀s. ⟦safe_regex Futu Lax r1; s ∈ lpd test i r1⟧ ⟹ safe_regex Futu Lax s; ⋀s. ⟦safe_regex Futu Lax r2; s ∈ lpd test i r2⟧ ⟹ safe_regex Futu Lax s; safe_regex Futu Lax (Times r1 r2); s ∈ lpd test i (Times r1 r2)⟧ ⟹ safe_regex Futu Lax s› 5. ‹⋀r s. ⟦⋀s. ⟦safe_regex Futu Lax r; s ∈ lpd test i r⟧ ⟹ safe_regex Futu Lax s; safe_regex Futu Lax (Star r); s ∈ lpd test i (Star r)⟧ ⟹ safe_regex Futu Lax s›*) case (Plus r1 r2) (*‹⟦safe_regex Futu Lax r1; ?s ∈ lpd test i r1⟧ ⟹ safe_regex Futu Lax ?s› ‹⟦safe_regex Futu Lax r2; ?s ∈ lpd test i r2⟧ ⟹ safe_regex Futu Lax ?s› ‹safe_regex Futu Lax (Plus r1 r2)› ‹s ∈ lpd test i (Plus r1 r2)›*) from Plus(3,4) (*‹safe_regex Futu Lax (Plus r1 r2)› ‹s ∈ lpd test i (Plus r1 r2)›*) show "?case" (*goal: ‹safe_regex Futu Lax (s::'a regex)›*) by (auto elim: Plus( (*‹⟦safe_regex Futu Lax r1; ?s ∈ lpd test i r1⟧ ⟹ safe_regex Futu Lax ?s› ‹⟦safe_regex Futu Lax r2; ?s ∈ lpd test i r2⟧ ⟹ safe_regex Futu Lax ?s›*) 1,2)) next (*goals: 1. ‹⋀(x::nat) s::'a regex. ⟦safe_regex Futu Lax (Skip x); s ∈ lpd (test::'c ⇒ 'a ⇒ bool) (i::'c) (Skip x)⟧ ⟹ safe_regex Futu Lax s› 2. ‹⋀(x::'a) s::'a regex. ⟦safe_regex Futu Lax (Test x); s ∈ lpd (test::'c ⇒ 'a ⇒ bool) (i::'c) (Test x)⟧ ⟹ safe_regex Futu Lax s› 3. ‹⋀(r1::'a regex) (r2::'a regex) s::'a regex. ⟦⋀s::'a regex. ⟦safe_regex Futu Lax r1; s ∈ lpd (test::'c ⇒ 'a ⇒ bool) (i::'c) r1⟧ ⟹ safe_regex Futu Lax s; ⋀s::'a regex. ⟦safe_regex Futu Lax r2; s ∈ lpd test i r2⟧ ⟹ safe_regex Futu Lax s; safe_regex Futu Lax (Times r1 r2); s ∈ lpd test i (Times r1 r2)⟧ ⟹ safe_regex Futu Lax s› 4. ‹⋀(r::'a regex) s::'a regex. ⟦⋀s::'a regex. ⟦safe_regex Futu Lax r; s ∈ lpd (test::'c ⇒ 'a ⇒ bool) (i::'c) r⟧ ⟹ safe_regex Futu Lax s; safe_regex Futu Lax (Star r); s ∈ lpd test i (Star r)⟧ ⟹ safe_regex Futu Lax s›*) case (Times r1 r2) (*‹⟦safe_regex Futu Lax r1; ?s ∈ lpd test i r1⟧ ⟹ safe_regex Futu Lax ?s› ‹⟦safe_regex Futu Lax r2; ?s ∈ lpd test i r2⟧ ⟹ safe_regex Futu Lax ?s› ‹safe_regex Futu Lax (Times r1 r2)› ‹(s::'a regex) ∈ lpd (test::'c ⇒ 'a ⇒ bool) (i::'c) (Times (r1::'a regex) (r2::'a regex))›*) from Times(3,4) (*‹safe_regex Futu Lax (Times r1 r2)› ‹(s::'a regex) ∈ lpd (test::'c ⇒ 'a ⇒ bool) (i::'c) (Times (r1::'a regex) (r2::'a regex))›*) show "?case" (*goal: ‹safe_regex Futu Lax (s::'a::type regex)›*) by (auto simp: TimesR_def (*‹TimesR (?R::?'a::type regex set) (?s::?'a::type regex) = (λr::?'a::type regex. Times r ?s) ` ?R›*) elim: Times( (*‹⟦safe_regex Futu Lax (r1::'a::type regex); (?s::'a::type regex) ∈ lpd (test::'c::type ⇒ 'a::type ⇒ bool) (i::'c::type) r1⟧ ⟹ safe_regex Futu Lax ?s› ‹⟦safe_regex Futu Lax (r2::'a::type regex); (?s::'a::type regex) ∈ lpd (test::'c::type ⇒ 'a::type ⇒ bool) (i::'c::type) r2⟧ ⟹ safe_regex Futu Lax ?s›*) 1,2) 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))›*)) qed (auto simp: TimesR_def (*‹TimesR ?R ?s = (λr. Times r ?s) ` ?R›*) 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))))›*)) (*solves the remaining goals: 1. ‹⋀x s. ⟦safe_regex Futu Lax (Skip x); s ∈ lpd test i (Skip x)⟧ ⟹ safe_regex Futu Lax s› 2. ‹⋀x s. ⟦safe_regex Futu Lax (Test x); s ∈ lpd test i (Test x)⟧ ⟹ safe_regex Futu Lax s› 3. ‹⋀r s. ⟦⋀s. ⟦safe_regex Futu Lax r; s ∈ lpd test i r⟧ ⟹ safe_regex Futu Lax s; safe_regex Futu Lax (Star r); s ∈ lpd test i (Star r)⟧ ⟹ safe_regex Futu Lax s›*) lemma safe_lpd: "(∀x ∈ atms r. safe Strict x ⟶ safe Lax x) ⟹ safe_regex Futu Strict r ⟹ s ∈ lpd test i r ⟹ safe_regex Futu Strict s" proof (induct r arbitrary: s) (*goals: 1. ‹⋀x s. ⟦∀x∈atms (Skip x). safe Strict x ⟶ safe Lax x; safe_regex Futu Strict (Skip x); s ∈ lpd test i (Skip x)⟧ ⟹ safe_regex Futu Strict s› 2. ‹⋀x s. ⟦∀x∈atms (Test x). safe Strict x ⟶ safe Lax x; safe_regex Futu Strict (Test x); s ∈ lpd test i (Test x)⟧ ⟹ safe_regex Futu Strict s› 3. ‹⋀r1 r2 s. ⟦⋀s. ⟦∀x∈atms r1. safe Strict x ⟶ safe Lax x; safe_regex Futu Strict r1; s ∈ lpd test i r1⟧ ⟹ safe_regex Futu Strict s; ⋀s. ⟦∀x∈atms r2. safe Strict x ⟶ safe Lax x; safe_regex Futu Strict r2; s ∈ lpd test i r2⟧ ⟹ safe_regex Futu Strict s; ∀x∈atms (Plus r1 r2). safe Strict x ⟶ safe Lax x; safe_regex Futu Strict (Plus r1 r2); s ∈ lpd test i (Plus r1 r2)⟧ ⟹ safe_regex Futu Strict s› 4. ‹⋀r1 r2 s. ⟦⋀s. ⟦∀x∈atms r1. safe Strict x ⟶ safe Lax x; safe_regex Futu Strict r1; s ∈ lpd test i r1⟧ ⟹ safe_regex Futu Strict s; ⋀s. ⟦∀x∈atms r2. safe Strict x ⟶ safe Lax x; safe_regex Futu Strict r2; s ∈ lpd test i r2⟧ ⟹ safe_regex Futu Strict s; ∀x∈atms (Times r1 r2). safe Strict x ⟶ safe Lax x; safe_regex Futu Strict (Times r1 r2); s ∈ lpd test i (Times r1 r2)⟧ ⟹ safe_regex Futu Strict s› 5. ‹⋀r s. ⟦⋀s. ⟦∀x∈atms r. safe Strict x ⟶ safe Lax x; safe_regex Futu Strict r; s ∈ lpd test i r⟧ ⟹ safe_regex Futu Strict s; ∀x∈atms (Star r). safe Strict x ⟶ safe Lax x; safe_regex Futu Strict (Star r); s ∈ lpd test i (Star r)⟧ ⟹ safe_regex Futu Strict s›*) case (Plus r1 r2) (*‹⟦∀x∈atms r1. safe Strict x ⟶ safe Lax x; safe_regex Futu Strict r1; ?s ∈ lpd test i r1⟧ ⟹ safe_regex Futu Strict ?s› ‹⟦∀x∈atms r2. safe Strict x ⟶ safe Lax x; safe_regex Futu Strict r2; ?s ∈ lpd test i r2⟧ ⟹ safe_regex Futu Strict ?s› ‹∀x::'a∈atms (Plus (r1::'a regex) (r2::'a regex)). (safe::safety ⇒ 'a ⇒ bool) Strict x ⟶ safe Lax x› ‹safe_regex Futu Strict (Plus r1 r2)› ‹s ∈ lpd test i (Plus r1 r2)›*) from Plus(3,4,5) (*‹∀x∈atms (Plus r1 r2). safe Strict x ⟶ safe Lax x› ‹safe_regex Futu Strict (Plus r1 r2)› ‹(s::'a::type regex) ∈ lpd (test::'c::type ⇒ 'a::type ⇒ bool) (i::'c::type) (Plus (r1::'a::type regex) (r2::'a::type regex))›*) show "?case" (*goal: ‹safe_regex Futu Strict s›*) by (auto elim: Plus( (*‹⟦∀x∈atms r1. safe Strict x ⟶ safe Lax x; safe_regex Futu Strict r1; ?s ∈ lpd test i r1⟧ ⟹ safe_regex Futu Strict ?s› ‹⟦∀x∈atms r2. safe Strict x ⟶ safe Lax x; safe_regex Futu Strict r2; ?s ∈ lpd test i r2⟧ ⟹ safe_regex Futu Strict ?s›*) 1,2) simp: ball_Un (*‹(∀x∈?A ∪ ?B. ?P x) = ((∀x∈?A. ?P x) ∧ (∀x∈?B. ?P x))›*)) next (*goals: 1. ‹⋀x s. ⟦∀x∈atms (Skip x). safe Strict x ⟶ safe Lax x; safe_regex Futu Strict (Skip x); s ∈ lpd test i (Skip x)⟧ ⟹ safe_regex Futu Strict s› 2. ‹⋀x s. ⟦∀x∈atms (Test x). safe Strict x ⟶ safe Lax x; safe_regex Futu Strict (Test x); s ∈ lpd test i (Test x)⟧ ⟹ safe_regex Futu Strict s› 3. ‹⋀r1 r2 s. ⟦⋀s. ⟦∀x∈atms r1. safe Strict x ⟶ safe Lax x; safe_regex Futu Strict r1; s ∈ lpd test i r1⟧ ⟹ safe_regex Futu Strict s; ⋀s. ⟦∀x∈atms r2. safe Strict x ⟶ safe Lax x; safe_regex Futu Strict r2; s ∈ lpd test i r2⟧ ⟹ safe_regex Futu Strict s; ∀x∈atms (Times r1 r2). safe Strict x ⟶ safe Lax x; safe_regex Futu Strict (Times r1 r2); s ∈ lpd test i (Times r1 r2)⟧ ⟹ safe_regex Futu Strict s› 4. ‹⋀r s. ⟦⋀s. ⟦∀x∈atms r. safe Strict x ⟶ safe Lax x; safe_regex Futu Strict r; s ∈ lpd test i r⟧ ⟹ safe_regex Futu Strict s; ∀x∈atms (Star r). safe Strict x ⟶ safe Lax x; safe_regex Futu Strict (Star r); s ∈ lpd test i (Star r)⟧ ⟹ safe_regex Futu Strict s›*) case (Times r1 r2) (*‹⟦∀x∈atms r1. safe Strict x ⟶ safe Lax x; safe_regex Futu Strict r1; ?s ∈ lpd test i r1⟧ ⟹ safe_regex Futu Strict ?s› ‹⟦∀x::'a∈atms (r2::'a regex). (safe::safety ⇒ 'a ⇒ bool) Strict x ⟶ safe Lax x; safe_regex Futu Strict r2; (?s::'a regex) ∈ lpd (test::'c ⇒ 'a ⇒ bool) (i::'c) r2⟧ ⟹ safe_regex Futu Strict ?s› ‹∀x∈atms (Times r1 r2). safe Strict x ⟶ safe Lax x› ‹safe_regex Futu Strict (Times r1 r2)› ‹s ∈ lpd test i (Times r1 r2)›*) from Times(3,4,5) (*‹∀x∈atms (Times r1 r2). safe Strict x ⟶ safe Lax x› ‹safe_regex Futu Strict (Times r1 r2)› ‹(s::'a regex) ∈ lpd (test::'c ⇒ 'a ⇒ bool) (i::'c) (Times (r1::'a regex) (r2::'a regex))›*) show "?case" (*goal: ‹safe_regex Futu Strict s›*) by (force simp: TimesR_def (*‹TimesR (?R::?'a regex set) (?s::?'a regex) = (λr::?'a regex. Times r ?s) ` ?R›*) ball_Un (*‹(∀x::?'a∈(?A::?'a set) ∪ (?B::?'a set). (?P::?'a ⇒ bool) x) = ((∀x::?'a∈?A. ?P x) ∧ (∀x::?'a∈?B. ?P x))›*) elim: Times( (*‹⟦∀x::'a∈atms (r1::'a regex). (safe::safety ⇒ 'a ⇒ bool) Strict x ⟶ safe Lax x; safe_regex Futu Strict r1; (?s::'a regex) ∈ lpd (test::'c ⇒ 'a ⇒ bool) (i::'c) r1⟧ ⟹ safe_regex Futu Strict ?s› ‹⟦∀x::'a∈atms (r2::'a regex). (safe::safety ⇒ 'a ⇒ bool) Strict x ⟶ safe Lax x; safe_regex Futu Strict r2; (?s::'a regex) ∈ lpd (test::'c ⇒ 'a ⇒ bool) (i::'c) r2⟧ ⟹ safe_regex Futu Strict ?s›*) 1,2) cosafe_lpd (*‹⟦safe_regex Futu Lax (?r::'a regex); (?s::'a regex) ∈ lpd (?test::?'c ⇒ 'a ⇒ bool) (?i::?'c) ?r⟧ ⟹ safe_regex Futu Lax ?s›*) dest: lpd_fv_regex (*‹(?s::?'a regex) ∈ lpd (?test::?'b ⇒ ?'a ⇒ bool) (?i::?'b) (?r::?'a regex) ⟹ fv_regex (?fv::?'a ⇒ ?'c set) ?s ⊆ fv_regex ?fv ?r›*) 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. ‹⋀(x::nat) s::'a regex. ⟦∀x::'a∈atms (Skip x). (safe::safety ⇒ 'a ⇒ bool) Strict x ⟶ safe Lax x; safe_regex Futu Strict (Skip x); s ∈ lpd (test::'c ⇒ 'a ⇒ bool) (i::'c) (Skip x)⟧ ⟹ safe_regex Futu Strict s› 2. ‹⋀(x::'a) s::'a regex. ⟦∀x::'a∈atms (Test x). (safe::safety ⇒ 'a ⇒ bool) Strict x ⟶ safe Lax x; safe_regex Futu Strict (Test x); s ∈ lpd (test::'c ⇒ 'a ⇒ bool) (i::'c) (Test x)⟧ ⟹ safe_regex Futu Strict s› 3. ‹⋀(r::'a regex) s::'a regex. ⟦⋀s::'a regex. ⟦∀x::'a∈atms r. (safe::safety ⇒ 'a ⇒ bool) Strict x ⟶ safe Lax x; safe_regex Futu Strict r; s ∈ lpd (test::'c ⇒ 'a ⇒ bool) (i::'c) r⟧ ⟹ safe_regex Futu Strict s; ∀x::'a∈atms (Star r). safe Strict x ⟶ safe Lax x; safe_regex Futu Strict (Star r); s ∈ lpd test i (Star r)⟧ ⟹ safe_regex Futu Strict s›*) case (Star r) (*‹⟦∀x∈atms r. safe Strict x ⟶ safe Lax x; safe_regex Futu Strict r; ?s ∈ lpd test i r⟧ ⟹ safe_regex Futu Strict ?s› ‹∀x∈atms (Star r). safe Strict x ⟶ safe Lax x› ‹safe_regex Futu Strict (Star r)› ‹s ∈ lpd test i (Star r)›*) from Star(2,3,4) (*‹∀x∈atms (Star r). safe Strict x ⟶ safe Lax x› ‹safe_regex Futu Strict (Star (r::'a regex))› ‹s ∈ lpd test i (Star r)›*) show "?case" (*goal: ‹safe_regex Futu Strict s›*) by (force simp: TimesR_def (*‹TimesR ?R ?s = (λr. Times r ?s) ` ?R›*) elim: Star( (*‹⟦∀x∈atms r. safe Strict x ⟶ safe Lax x; safe_regex Futu Strict r; ?s ∈ lpd test i r⟧ ⟹ safe_regex Futu Strict ?s›*) 1) cosafe_lpd (*‹⟦safe_regex Futu Lax ?r; ?s ∈ lpd ?test ?i ?r⟧ ⟹ safe_regex Futu Lax ?s›*) dest: safe_cosafe[rotated] (*‹⟦safe_regex ?m Strict ?r; ⋀x. ⟦x ∈ atms ?r; safe Strict x⟧ ⟹ safe Lax x⟧ ⟹ safe_regex ?m Lax ?r›*) lpd_fv_regex[where fv=fv] (*‹?s ∈ lpd ?test ?i ?r ⟹ fv_regex fv ?s ⊆ fv_regex fv ?r›*) 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 (auto 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))))›*)) (*solves the remaining goals: 1. ‹⋀x s. ⟦∀x∈atms (Skip x). safe Strict x ⟶ safe Lax x; safe_regex Futu Strict (Skip x); s ∈ lpd test i (Skip x)⟧ ⟹ safe_regex Futu Strict s› 2. ‹⋀x s. ⟦∀x∈atms (Test x). safe Strict x ⟶ safe Lax x; safe_regex Futu Strict (Test x); s ∈ lpd test i (Test x)⟧ ⟹ safe_regex Futu Strict s›*) lemma safe_rpd_fv_regex_le: "safe_regex Past Strict r ⟹ s ∈ rpd test i r ⟹ fv_regex fv r ⊆ fv_regex fv s" apply (induct r) (*goals: 1. ‹⋀x. ⟦safe_regex Past Strict (Skip x); s ∈ rpd test i (Skip x)⟧ ⟹ fv_regex fv (Skip x) ⊆ fv_regex fv s› 2. ‹⋀x. ⟦safe_regex Past Strict (Test x); s ∈ rpd test i (Test x)⟧ ⟹ fv_regex fv (Test x) ⊆ fv_regex fv s› 3. ‹⋀r1 r2. ⟦⟦safe_regex Past Strict r1; s ∈ rpd test i r1⟧ ⟹ fv_regex fv r1 ⊆ fv_regex fv s; ⟦safe_regex Past Strict r2; s ∈ rpd test i r2⟧ ⟹ fv_regex fv r2 ⊆ fv_regex fv s; safe_regex Past Strict (Plus r1 r2); s ∈ rpd test i (Plus r1 r2)⟧ ⟹ fv_regex fv (Plus r1 r2) ⊆ fv_regex fv s› 4. ‹⋀r1 r2. ⟦⟦safe_regex Past Strict r1; s ∈ rpd test i r1⟧ ⟹ fv_regex fv r1 ⊆ fv_regex fv s; ⟦safe_regex Past Strict r2; s ∈ rpd test i r2⟧ ⟹ fv_regex fv r2 ⊆ fv_regex fv s; safe_regex Past Strict (Times r1 r2); s ∈ rpd test i (Times r1 r2)⟧ ⟹ fv_regex fv (Times r1 r2) ⊆ fv_regex fv s› 5. ‹⋀r. ⟦⟦safe_regex Past Strict r; s ∈ rpd test i r⟧ ⟹ fv_regex fv r ⊆ fv_regex fv s; safe_regex Past Strict (Star r); s ∈ rpd test i (Star r)⟧ ⟹ fv_regex fv (Star r) ⊆ fv_regex fv s› discuss goal 1*) apply ((auto simp: TimesL_def (*‹TimesL (?r::?'a regex) (?S::?'a regex set) = Times ?r ` ?S›*) 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 simp: TimesL_def (*‹TimesL ?r ?S = Times ?r ` ?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))›*))[1]) (*discuss goal 3*) apply ((auto simp: TimesL_def (*‹TimesL ?r ?S = Times ?r ` ?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))›*))[1]) (*discuss goal 4*) apply ((auto simp: TimesL_def (*‹TimesL (?r::?'a regex) (?S::?'a regex set) = Times ?r ` ?S›*) 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 5*) apply ((auto simp: TimesL_def (*‹TimesL ?r ?S = Times ?r ` ?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))›*))[1]) (*proven 5 subgoals*) . lemma safe_rpd_fv_regex: "safe_regex Past Strict r ⟹ s ∈ rpd test i r ⟹ fv_regex fv s = fv_regex fv r" by (simp add: eq_iff (*‹(?a = ?b) = (?a ≤ ?b ∧ ?b ≤ ?a)›*) rpd_fv_regex (*‹?s ∈ rpd ?test ?i ?r ⟹ fv_regex ?fv ?s ⊆ fv_regex ?fv ?r›*) safe_rpd_fv_regex_le (*‹⟦safe_regex Past Strict ?r; ?s ∈ rpd ?test ?i ?r⟧ ⟹ fv_regex fv ?r ⊆ fv_regex fv ?s›*)) lemma cosafe_rpd: "safe_regex Past Lax r ⟹ s ∈ rpd test i r ⟹ safe_regex Past Lax s" proof (induct r arbitrary: s) (*goals: 1. ‹⋀x s. ⟦safe_regex Past Lax (Skip x); s ∈ rpd test i (Skip x)⟧ ⟹ safe_regex Past Lax s› 2. ‹⋀x s. ⟦safe_regex Past Lax (Test x); s ∈ rpd test i (Test x)⟧ ⟹ safe_regex Past Lax s› 3. ‹⋀r1 r2 s. ⟦⋀s. ⟦safe_regex Past Lax r1; s ∈ rpd test i r1⟧ ⟹ safe_regex Past Lax s; ⋀s. ⟦safe_regex Past Lax r2; s ∈ rpd test i r2⟧ ⟹ safe_regex Past Lax s; safe_regex Past Lax (Plus r1 r2); s ∈ rpd test i (Plus r1 r2)⟧ ⟹ safe_regex Past Lax s› 4. ‹⋀r1 r2 s. ⟦⋀s. ⟦safe_regex Past Lax r1; s ∈ rpd test i r1⟧ ⟹ safe_regex Past Lax s; ⋀s. ⟦safe_regex Past Lax r2; s ∈ rpd test i r2⟧ ⟹ safe_regex Past Lax s; safe_regex Past Lax (Times r1 r2); s ∈ rpd test i (Times r1 r2)⟧ ⟹ safe_regex Past Lax s› 5. ‹⋀r s. ⟦⋀s. ⟦safe_regex Past Lax r; s ∈ rpd test i r⟧ ⟹ safe_regex Past Lax s; safe_regex Past Lax (Star r); s ∈ rpd test i (Star r)⟧ ⟹ safe_regex Past Lax s›*) case (Plus r1 r2) (*‹⟦safe_regex Past Lax r1; ?s ∈ rpd test i r1⟧ ⟹ safe_regex Past Lax ?s› ‹⟦safe_regex Past Lax r2; ?s ∈ rpd test i r2⟧ ⟹ safe_regex Past Lax ?s› ‹safe_regex Past Lax (Plus r1 r2)› ‹(s::'a::type regex) ∈ rpd (test::'c::type ⇒ 'a::type ⇒ bool) (i::'c::type) (Plus (r1::'a::type regex) (r2::'a::type regex))›*) from Plus(3,4) (*‹safe_regex Past Lax (Plus r1 r2)› ‹s ∈ rpd test i (Plus r1 r2)›*) show "?case" (*goal: ‹safe_regex Past Lax s›*) by (auto elim: Plus( (*‹⟦safe_regex Past Lax r1; ?s ∈ rpd test i r1⟧ ⟹ safe_regex Past Lax ?s› ‹⟦safe_regex Past Lax r2; ?s ∈ rpd test i r2⟧ ⟹ safe_regex Past Lax ?s›*) 1,2)) next (*goals: 1. ‹⋀x s. ⟦safe_regex Past Lax (Skip x); s ∈ rpd test i (Skip x)⟧ ⟹ safe_regex Past Lax s› 2. ‹⋀x s. ⟦safe_regex Past Lax (Test x); s ∈ rpd test i (Test x)⟧ ⟹ safe_regex Past Lax s› 3. ‹⋀r1 r2 s. ⟦⋀s. ⟦safe_regex Past Lax r1; s ∈ rpd test i r1⟧ ⟹ safe_regex Past Lax s; ⋀s. ⟦safe_regex Past Lax r2; s ∈ rpd test i r2⟧ ⟹ safe_regex Past Lax s; safe_regex Past Lax (Times r1 r2); s ∈ rpd test i (Times r1 r2)⟧ ⟹ safe_regex Past Lax s› 4. ‹⋀r s. ⟦⋀s. ⟦safe_regex Past Lax r; s ∈ rpd test i r⟧ ⟹ safe_regex Past Lax s; safe_regex Past Lax (Star r); s ∈ rpd test i (Star r)⟧ ⟹ safe_regex Past Lax s›*) case (Times r1 r2) (*‹⟦safe_regex Past Lax r1; ?s ∈ rpd test i r1⟧ ⟹ safe_regex Past Lax ?s› ‹⟦safe_regex Past Lax r2; ?s ∈ rpd test i r2⟧ ⟹ safe_regex Past Lax ?s› ‹safe_regex Past Lax (Times r1 r2)› ‹(s::'a regex) ∈ rpd (test::'c ⇒ 'a ⇒ bool) (i::'c) (Times (r1::'a regex) (r2::'a regex))›*) from Times(3,4) (*‹safe_regex Past Lax (Times r1 r2)› ‹s ∈ rpd test i (Times r1 r2)›*) show "?case" (*goal: ‹safe_regex Past Lax s›*) by (auto simp: TimesL_def (*‹TimesL ?r ?S = Times ?r ` ?S›*) elim: Times( (*‹⟦safe_regex Past Lax r1; ?s ∈ rpd test i r1⟧ ⟹ safe_regex Past Lax ?s› ‹⟦safe_regex Past Lax r2; ?s ∈ rpd test i r2⟧ ⟹ safe_regex Past Lax ?s›*) 1,2) 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 (auto simp: TimesL_def (*‹TimesL ?r ?S = Times ?r ` ?S›*) 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))))›*)) (*solves the remaining goals: 1. ‹⋀(x::nat) s::'a regex. ⟦safe_regex Past Lax (Skip x); s ∈ rpd (test::'c ⇒ 'a ⇒ bool) (i::'c) (Skip x)⟧ ⟹ safe_regex Past Lax s› 2. ‹⋀(x::'a) s::'a regex. ⟦safe_regex Past Lax (Test x); s ∈ rpd (test::'c ⇒ 'a ⇒ bool) (i::'c) (Test x)⟧ ⟹ safe_regex Past Lax s› 3. ‹⋀(r::'a regex) s::'a regex. ⟦⋀s::'a regex. ⟦safe_regex Past Lax r; s ∈ rpd (test::'c ⇒ 'a ⇒ bool) (i::'c) r⟧ ⟹ safe_regex Past Lax s; safe_regex Past Lax (Star r); s ∈ rpd test i (Star r)⟧ ⟹ safe_regex Past Lax s›*) lemma safe_rpd: "(∀x ∈ atms r. safe Strict x ⟶ safe Lax x) ⟹ safe_regex Past Strict r ⟹ s ∈ rpd test i r ⟹ safe_regex Past Strict s" proof (induct r arbitrary: s) (*goals: 1. ‹⋀x s. ⟦∀x∈atms (Skip x). safe Strict x ⟶ safe Lax x; safe_regex Past Strict (Skip x); s ∈ rpd test i (Skip x)⟧ ⟹ safe_regex Past Strict s› 2. ‹⋀x s. ⟦∀x∈atms (Test x). safe Strict x ⟶ safe Lax x; safe_regex Past Strict (Test x); s ∈ rpd test i (Test x)⟧ ⟹ safe_regex Past Strict s› 3. ‹⋀r1 r2 s. ⟦⋀s. ⟦∀x∈atms r1. safe Strict x ⟶ safe Lax x; safe_regex Past Strict r1; s ∈ rpd test i r1⟧ ⟹ safe_regex Past Strict s; ⋀s. ⟦∀x∈atms r2. safe Strict x ⟶ safe Lax x; safe_regex Past Strict r2; s ∈ rpd test i r2⟧ ⟹ safe_regex Past Strict s; ∀x∈atms (Plus r1 r2). safe Strict x ⟶ safe Lax x; safe_regex Past Strict (Plus r1 r2); s ∈ rpd test i (Plus r1 r2)⟧ ⟹ safe_regex Past Strict s› 4. ‹⋀r1 r2 s. ⟦⋀s. ⟦∀x∈atms r1. safe Strict x ⟶ safe Lax x; safe_regex Past Strict r1; s ∈ rpd test i r1⟧ ⟹ safe_regex Past Strict s; ⋀s. ⟦∀x∈atms r2. safe Strict x ⟶ safe Lax x; safe_regex Past Strict r2; s ∈ rpd test i r2⟧ ⟹ safe_regex Past Strict s; ∀x∈atms (Times r1 r2). safe Strict x ⟶ safe Lax x; safe_regex Past Strict (Times r1 r2); s ∈ rpd test i (Times r1 r2)⟧ ⟹ safe_regex Past Strict s› 5. ‹⋀r s. ⟦⋀s. ⟦∀x∈atms r. safe Strict x ⟶ safe Lax x; safe_regex Past Strict r; s ∈ rpd test i r⟧ ⟹ safe_regex Past Strict s; ∀x∈atms (Star r). safe Strict x ⟶ safe Lax x; safe_regex Past Strict (Star r); s ∈ rpd test i (Star r)⟧ ⟹ safe_regex Past Strict s›*) case (Plus r1 r2) (*‹⟦∀x::'a∈atms (r1::'a regex). (safe::safety ⇒ 'a ⇒ bool) Strict x ⟶ safe Lax x; safe_regex Past Strict r1; (?s::'a regex) ∈ rpd (test::'c ⇒ 'a ⇒ bool) (i::'c) r1⟧ ⟹ safe_regex Past Strict ?s› ‹⟦∀x∈atms r2. safe Strict x ⟶ safe Lax x; safe_regex Past Strict r2; ?s ∈ rpd test i r2⟧ ⟹ safe_regex Past Strict ?s› ‹∀x∈atms (Plus r1 r2). safe Strict x ⟶ safe Lax x› ‹safe_regex Past Strict (Plus r1 r2)› ‹s ∈ rpd test i (Plus r1 r2)›*) from Plus(3,4,5) (*‹∀x∈atms (Plus r1 r2). safe Strict x ⟶ safe Lax x› ‹safe_regex Past Strict (Plus r1 r2)› ‹s ∈ rpd test i (Plus r1 r2)›*) show "?case" (*goal: ‹safe_regex Past Strict (s::'a::type regex)›*) by (auto elim: Plus( (*‹⟦∀x∈atms r1. safe Strict x ⟶ safe Lax x; safe_regex Past Strict r1; ?s ∈ rpd test i r1⟧ ⟹ safe_regex Past Strict ?s› ‹⟦∀x∈atms r2. safe Strict x ⟶ safe Lax x; safe_regex Past Strict r2; ?s ∈ rpd test i r2⟧ ⟹ safe_regex Past Strict ?s›*) 1,2) simp: ball_Un (*‹(∀x∈?A ∪ ?B. ?P x) = ((∀x∈?A. ?P x) ∧ (∀x∈?B. ?P x))›*)) next (*goals: 1. ‹⋀x s. ⟦∀x∈atms (Skip x). safe Strict x ⟶ safe Lax x; safe_regex Past Strict (Skip x); s ∈ rpd test i (Skip x)⟧ ⟹ safe_regex Past Strict s› 2. ‹⋀x s. ⟦∀x∈atms (Test x). safe Strict x ⟶ safe Lax x; safe_regex Past Strict (Test x); s ∈ rpd test i (Test x)⟧ ⟹ safe_regex Past Strict s› 3. ‹⋀r1 r2 s. ⟦⋀s. ⟦∀x∈atms r1. safe Strict x ⟶ safe Lax x; safe_regex Past Strict r1; s ∈ rpd test i r1⟧ ⟹ safe_regex Past Strict s; ⋀s. ⟦∀x∈atms r2. safe Strict x ⟶ safe Lax x; safe_regex Past Strict r2; s ∈ rpd test i r2⟧ ⟹ safe_regex Past Strict s; ∀x∈atms (Times r1 r2). safe Strict x ⟶ safe Lax x; safe_regex Past Strict (Times r1 r2); s ∈ rpd test i (Times r1 r2)⟧ ⟹ safe_regex Past Strict s› 4. ‹⋀r s. ⟦⋀s. ⟦∀x∈atms r. safe Strict x ⟶ safe Lax x; safe_regex Past Strict r; s ∈ rpd test i r⟧ ⟹ safe_regex Past Strict s; ∀x∈atms (Star r). safe Strict x ⟶ safe Lax x; safe_regex Past Strict (Star r); s ∈ rpd test i (Star r)⟧ ⟹ safe_regex Past Strict s›*) case (Times r1 r2) (*‹⟦∀x::'a∈atms (r1::'a regex). (safe::safety ⇒ 'a ⇒ bool) Strict x ⟶ safe Lax x; safe_regex Past Strict r1; (?s::'a regex) ∈ rpd (test::'c ⇒ 'a ⇒ bool) (i::'c) r1⟧ ⟹ safe_regex Past Strict ?s› ‹⟦∀x∈atms r2. safe Strict x ⟶ safe Lax x; safe_regex Past Strict r2; ?s ∈ rpd test i r2⟧ ⟹ safe_regex Past Strict ?s› ‹∀x∈atms (Times r1 r2). safe Strict x ⟶ safe Lax x› ‹safe_regex Past Strict (Times r1 r2)› ‹s ∈ rpd test i (Times r1 r2)›*) from Times(3,4,5) (*‹∀x∈atms (Times r1 r2). safe Strict x ⟶ safe Lax x› ‹safe_regex Past Strict (Times (r1::'a::type regex) (r2::'a::type regex))› ‹s ∈ rpd test i (Times r1 r2)›*) show "?case" (*goal: ‹safe_regex Past Strict (s::'a regex)›*) by (force simp: TimesL_def (*‹TimesL ?r ?S = Times ?r ` ?S›*) ball_Un (*‹(∀x∈?A ∪ ?B. ?P x) = ((∀x∈?A. ?P x) ∧ (∀x∈?B. ?P x))›*) elim: Times( (*‹⟦∀x∈atms r1. safe Strict x ⟶ safe Lax x; safe_regex Past Strict r1; ?s ∈ rpd test i r1⟧ ⟹ safe_regex Past Strict ?s› ‹⟦∀x∈atms r2. safe Strict x ⟶ safe Lax x; safe_regex Past Strict r2; ?s ∈ rpd test i r2⟧ ⟹ safe_regex Past Strict ?s›*) 1,2) cosafe_rpd (*‹⟦safe_regex Past Lax ?r; ?s ∈ rpd ?test ?i ?r⟧ ⟹ safe_regex Past Lax ?s›*) dest: rpd_fv_regex (*‹?s ∈ rpd ?test ?i ?r ⟹ fv_regex ?fv ?s ⊆ fv_regex ?fv ?r›*) 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. ‹⋀x s. ⟦∀x∈atms (Skip x). safe Strict x ⟶ safe Lax x; safe_regex Past Strict (Skip x); s ∈ rpd test i (Skip x)⟧ ⟹ safe_regex Past Strict s› 2. ‹⋀x s. ⟦∀x∈atms (Test x). safe Strict x ⟶ safe Lax x; safe_regex Past Strict (Test x); s ∈ rpd test i (Test x)⟧ ⟹ safe_regex Past Strict s› 3. ‹⋀r s. ⟦⋀s. ⟦∀x∈atms r. safe Strict x ⟶ safe Lax x; safe_regex Past Strict r; s ∈ rpd test i r⟧ ⟹ safe_regex Past Strict s; ∀x∈atms (Star r). safe Strict x ⟶ safe Lax x; safe_regex Past Strict (Star r); s ∈ rpd test i (Star r)⟧ ⟹ safe_regex Past Strict s›*) case (Star r) (*‹⟦∀x∈atms r. safe Strict x ⟶ safe Lax x; safe_regex Past Strict r; ?s ∈ rpd test i r⟧ ⟹ safe_regex Past Strict ?s› ‹∀x::'a∈atms (Star (r::'a regex)). (safe::safety ⇒ 'a ⇒ bool) Strict x ⟶ safe Lax x› ‹safe_regex Past Strict (Star r)› ‹s ∈ rpd test i (Star r)›*) from Star(2,3,4) (*‹∀x::'a∈atms (Star (r::'a regex)). (safe::safety ⇒ 'a ⇒ bool) Strict x ⟶ safe Lax x› ‹safe_regex Past Strict (Star r)› ‹s ∈ rpd test i (Star r)›*) show "?case" (*goal: ‹safe_regex Past Strict s›*) by (force simp: TimesL_def (*‹TimesL ?r ?S = Times ?r ` ?S›*) elim: Star( (*‹⟦∀x∈atms r. safe Strict x ⟶ safe Lax x; safe_regex Past Strict r; ?s ∈ rpd test i r⟧ ⟹ safe_regex Past Strict ?s›*) 1) cosafe_rpd (*‹⟦safe_regex Past Lax ?r; ?s ∈ rpd ?test ?i ?r⟧ ⟹ safe_regex Past Lax ?s›*) dest: safe_cosafe[rotated] (*‹⟦safe_regex ?m Strict ?r; ⋀x. ⟦x ∈ atms ?r; safe Strict x⟧ ⟹ safe Lax x⟧ ⟹ safe_regex ?m Lax ?r›*) rpd_fv_regex[where fv=fv] (*‹?s ∈ rpd ?test ?i ?r ⟹ fv_regex fv ?s ⊆ fv_regex fv ?r›*) 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 (auto split: nat.splits (*‹(?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)))› ‹(?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))))›*)) (*solves the remaining goals: 1. ‹⋀x s. ⟦∀x∈atms (Skip x). safe Strict x ⟶ safe Lax x; safe_regex Past Strict (Skip x); s ∈ rpd test i (Skip x)⟧ ⟹ safe_regex Past Strict s› 2. ‹⋀x s. ⟦∀x∈atms (Test x). safe Strict x ⟶ safe Lax x; safe_regex Past Strict (Test x); s ∈ rpd test i (Test x)⟧ ⟹ safe_regex Past Strict s›*) lemma safe_regex_safe: "(⋀g r. safe g r ⟹ safe Lax r) ⟹ safe_regex m g r ⟹ x ∈ atms r ⟹ safe Lax x" apply (induct m g r rule: safe_regex.induct (*‹⟦⋀m uu_ n. ?P m uu_ (Skip n); ⋀m g φ. ?P m g (Test φ); ⋀m g r s. ⟦?P m g r; ?P m g s⟧ ⟹ ?P m g (Plus r s); ⋀g r s. ⟦?P Futu g s; ?P Futu Lax r⟧ ⟹ ?P Futu g (Times r s); ⋀g r s. ⟦?P Past g r; ?P Past Lax s⟧ ⟹ ?P Past g (Times r s); ⋀m g r. ?P m g r ⟹ ?P m g (Star r)⟧ ⟹ ?P ?a0.0 ?a1.0 ?a2.0›*)) (*goals: 1. ‹⋀m uu_ n. ⟦⋀g r. safe g r ⟹ safe Lax r; safe_regex m uu_ (Skip n); x ∈ atms (Skip n)⟧ ⟹ safe Lax x› 2. ‹⋀m g φ. ⟦⋀g r. safe g r ⟹ safe Lax r; safe_regex m g (Test φ); x ∈ atms (Test φ)⟧ ⟹ safe Lax x› 3. ‹⋀m g r s. ⟦⟦⋀g r. safe g r ⟹ safe Lax r; safe_regex m g r; x ∈ atms r⟧ ⟹ safe Lax x; ⟦⋀g r. safe g r ⟹ safe Lax r; safe_regex m g s; x ∈ atms s⟧ ⟹ safe Lax x; ⋀g r. safe g r ⟹ safe Lax r; safe_regex m g (Plus r s); x ∈ atms (Plus r s)⟧ ⟹ safe Lax x› 4. ‹⋀g r s. ⟦⟦⋀g r. safe g r ⟹ safe Lax r; safe_regex Futu g s; x ∈ atms s⟧ ⟹ safe Lax x; ⟦⋀g r. safe g r ⟹ safe Lax r; safe_regex Futu Lax r; x ∈ atms r⟧ ⟹ safe Lax x; ⋀g r. safe g r ⟹ safe Lax r; safe_regex Futu g (Times r s); x ∈ atms (Times r s)⟧ ⟹ safe Lax x› 5. ‹⋀g r s. ⟦⟦⋀g r. safe g r ⟹ safe Lax r; safe_regex Past g r; x ∈ atms r⟧ ⟹ safe Lax x; ⟦⋀g r. safe g r ⟹ safe Lax r; safe_regex Past Lax s; x ∈ atms s⟧ ⟹ safe Lax x; ⋀g r. safe g r ⟹ safe Lax r; safe_regex Past g (Times r s); x ∈ atms (Times r s)⟧ ⟹ safe Lax x› 6. ‹⋀m g r. ⟦⟦⋀g r. safe g r ⟹ safe Lax r; safe_regex m g r; x ∈ atms r⟧ ⟹ safe Lax x; ⋀g r. safe g r ⟹ safe Lax r; safe_regex m g (Star r); x ∈ atms (Star r)⟧ ⟹ safe Lax 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*) . lemma safe_regex_map_regex: "(⋀g x. x ∈ atms r ⟹ safe g x ⟹ safe g (f x)) ⟹ (⋀x. x ∈ atms r ⟹ fv (f x) = fv x) ⟹ safe_regex m g r ⟹ safe_regex m g (map_regex f r)" apply (induct m g r rule: safe_regex.induct (*‹⟦⋀m uu_ n. ?P m uu_ (Skip n); ⋀m g φ. ?P m g (Test φ); ⋀m g r s. ⟦?P m g r; ?P m g s⟧ ⟹ ?P m g (Plus r s); ⋀g r s. ⟦?P Futu g s; ?P Futu Lax r⟧ ⟹ ?P Futu g (Times r s); ⋀g r s. ⟦?P Past g r; ?P Past Lax s⟧ ⟹ ?P Past g (Times r s); ⋀m g r. ?P m g r ⟹ ?P m g (Star r)⟧ ⟹ ?P ?a0.0 ?a1.0 ?a2.0›*)) (*goals: 1. ‹⋀m uu_ n. ⟦⋀g x. ⟦x ∈ atms (Skip n); safe g x⟧ ⟹ safe g (f x); ⋀x. x ∈ atms (Skip n) ⟹ fv (f x) = fv x; safe_regex m uu_ (Skip n)⟧ ⟹ safe_regex m uu_ (map_regex f (Skip n))› 2. ‹⋀m g φ. ⟦⋀g x. ⟦x ∈ atms (Test φ); safe g x⟧ ⟹ safe g (f x); ⋀x. x ∈ atms (Test φ) ⟹ fv (f x) = fv x; safe_regex m g (Test φ)⟧ ⟹ safe_regex m g (map_regex f (Test φ))› 3. ‹⋀m g r s. ⟦⟦⋀g x. ⟦x ∈ atms r; safe g x⟧ ⟹ safe g (f x); ⋀x. x ∈ atms r ⟹ fv (f x) = fv x; safe_regex m g r⟧ ⟹ safe_regex m g (map_regex f r); ⟦⋀g x. ⟦x ∈ atms s; safe g x⟧ ⟹ safe g (f x); ⋀x. x ∈ atms s ⟹ fv (f x) = fv x; safe_regex m g s⟧ ⟹ safe_regex m g (map_regex f s); ⋀g x. ⟦x ∈ atms (Plus r s); safe g x⟧ ⟹ safe g (f x); ⋀x. x ∈ atms (Plus r s) ⟹ fv (f x) = fv x; safe_regex m g (Plus r s)⟧ ⟹ safe_regex m g (map_regex f (Plus r s))› 4. ‹⋀g r s. ⟦⟦⋀g x. ⟦x ∈ atms s; safe g x⟧ ⟹ safe g (f x); ⋀x. x ∈ atms s ⟹ fv (f x) = fv x; safe_regex Futu g s⟧ ⟹ safe_regex Futu g (map_regex f s); ⟦⋀g x. ⟦x ∈ atms r; safe g x⟧ ⟹ safe g (f x); ⋀x. x ∈ atms r ⟹ fv (f x) = fv x; safe_regex Futu Lax r⟧ ⟹ safe_regex Futu Lax (map_regex f r); ⋀g x. ⟦x ∈ atms (Times r s); safe g x⟧ ⟹ safe g (f x); ⋀x. x ∈ atms (Times r s) ⟹ fv (f x) = fv x; safe_regex Futu g (Times r s)⟧ ⟹ safe_regex Futu g (map_regex f (Times r s))› 5. ‹⋀g r s. ⟦⟦⋀g x. ⟦x ∈ atms r; safe g x⟧ ⟹ safe g (f x); ⋀x. x ∈ atms r ⟹ fv (f x) = fv x; safe_regex Past g r⟧ ⟹ safe_regex Past g (map_regex f r); ⟦⋀g x. ⟦x ∈ atms s; safe g x⟧ ⟹ safe g (f x); ⋀x. x ∈ atms s ⟹ fv (f x) = fv x; safe_regex Past Lax s⟧ ⟹ safe_regex Past Lax (map_regex f s); ⋀g x. ⟦x ∈ atms (Times r s); safe g x⟧ ⟹ safe g (f x); ⋀x. x ∈ atms (Times r s) ⟹ fv (f x) = fv x; safe_regex Past g (Times r s)⟧ ⟹ safe_regex Past g (map_regex f (Times r s))› 6. ‹⋀m g r. ⟦⟦⋀g x. ⟦x ∈ atms r; safe g x⟧ ⟹ safe g (f x); ⋀x. x ∈ atms r ⟹ fv (f x) = fv x; safe_regex m g r⟧ ⟹ safe_regex m g (map_regex f r); ⋀g x. ⟦x ∈ atms (Star r); safe g x⟧ ⟹ safe g (f x); ⋀x. x ∈ atms (Star r) ⟹ fv (f x) = fv x; safe_regex m g (Star r)⟧ ⟹ safe_regex m g (map_regex f (Star r))› discuss goal 1*) apply ((auto simp: fv_regex_alt (*‹fv_regex ?fv ?r = ⋃ (?fv ` atms ?r)›*) regex.set_map (*‹atms (map_regex ?f ?v) = ?f ` atms ?v›*))[1]) (*discuss goal 2*) apply ((auto simp: fv_regex_alt (*‹fv_regex ?fv ?r = ⋃ (?fv ` atms ?r)›*) regex.set_map (*‹atms (map_regex ?f ?v) = ?f ` atms ?v›*))[1]) (*discuss goal 3*) apply ((auto simp: fv_regex_alt (*‹fv_regex ?fv ?r = ⋃ (?fv ` atms ?r)›*) regex.set_map (*‹atms (map_regex ?f ?v) = ?f ` atms ?v›*))[1]) (*discuss goal 4*) apply ((auto simp: fv_regex_alt (*‹fv_regex ?fv ?r = ⋃ (?fv ` atms ?r)›*) regex.set_map (*‹atms (map_regex ?f ?v) = ?f ` atms ?v›*))[1]) (*discuss goal 5*) apply ((auto simp: fv_regex_alt (*‹fv_regex (?fv::?'b::type ⇒ ?'a::type set) (?r::?'b::type regex) = ⋃ (?fv ` atms ?r)›*) regex.set_map (*‹atms (map_regex (?f::?'a::type ⇒ ?'b::type) (?v::?'a::type regex)) = ?f ` atms ?v›*))[1]) (*discuss goal 6*) apply ((auto simp: fv_regex_alt (*‹fv_regex ?fv ?r = ⋃ (?fv ` atms ?r)›*) regex.set_map (*‹atms (map_regex ?f ?v) = ?f ` atms ?v›*))[1]) (*proven 6 subgoals*) . end lemma safe_regex_cong[fundef_cong]: "(⋀g x. x ∈ atms r ⟹ safe g x = safe' g x) ⟹ Regex.safe_regex fv safe m g r = Regex.safe_regex fv safe' m g r" apply (induct m g r rule: safe_regex.induct (*‹⟦⋀m uu_ n. ?P m uu_ (Skip n); ⋀m g φ. ?P m g (Test φ); ⋀m g r s. ⟦?P m g r; ?P m g s⟧ ⟹ ?P m g (Plus r s); ⋀g r s. ⟦?P Futu g s; ?P Futu Lax r⟧ ⟹ ?P Futu g (Times r s); ⋀g r s. ⟦?P Past g r; ?P Past Lax s⟧ ⟹ ?P Past g (Times r s); ⋀m g r. ?P m g r ⟹ ?P m g (Star r)⟧ ⟹ ?P ?a0.0 ?a1.0 ?a2.0›*)) (*goals: 1. ‹⋀m uu_ n. (⋀g x. x ∈ atms (Skip n) ⟹ safe g x = safe' g x) ⟹ Regex.safe_regex fv safe m uu_ (Skip n) = Regex.safe_regex fv safe' m uu_ (Skip n)› 2. ‹⋀m g φ. (⋀g x. x ∈ atms (Test φ) ⟹ safe g x = safe' g x) ⟹ Regex.safe_regex fv safe m g (Test φ) = Regex.safe_regex fv safe' m g (Test φ)› 3. ‹⋀m g r s. ⟦(⋀g x. x ∈ atms r ⟹ safe g x = safe' g x) ⟹ Regex.safe_regex fv safe m g r = Regex.safe_regex fv safe' m g r; (⋀g x. x ∈ atms s ⟹ safe g x = safe' g x) ⟹ Regex.safe_regex fv safe m g s = Regex.safe_regex fv safe' m g s; ⋀g x. x ∈ atms (Plus r s) ⟹ safe g x = safe' g x⟧ ⟹ Regex.safe_regex fv safe m g (Plus r s) = Regex.safe_regex fv safe' m g (Plus r s)› 4. ‹⋀g r s. ⟦(⋀g x. x ∈ atms s ⟹ safe g x = safe' g x) ⟹ Regex.safe_regex fv safe Futu g s = Regex.safe_regex fv safe' Futu g s; (⋀g x. x ∈ atms r ⟹ safe g x = safe' g x) ⟹ Regex.safe_regex fv safe Futu Lax r = Regex.safe_regex fv safe' Futu Lax r; ⋀g x. x ∈ atms (Times r s) ⟹ safe g x = safe' g x⟧ ⟹ Regex.safe_regex fv safe Futu g (Times r s) = Regex.safe_regex fv safe' Futu g (Times r s)› 5. ‹⋀g r s. ⟦(⋀g x. x ∈ atms r ⟹ safe g x = safe' g x) ⟹ Regex.safe_regex fv safe Past g r = Regex.safe_regex fv safe' Past g r; (⋀g x. x ∈ atms s ⟹ safe g x = safe' g x) ⟹ Regex.safe_regex fv safe Past Lax s = Regex.safe_regex fv safe' Past Lax s; ⋀g x. x ∈ atms (Times r s) ⟹ safe g x = safe' g x⟧ ⟹ Regex.safe_regex fv safe Past g (Times r s) = Regex.safe_regex fv safe' Past g (Times r s)› 6. ‹⋀m g r. ⟦(⋀g x. x ∈ atms r ⟹ safe g x = safe' g x) ⟹ Regex.safe_regex fv safe m g r = Regex.safe_regex fv safe' m g r; ⋀g x. x ∈ atms (Star r) ⟹ safe g x = safe' g x⟧ ⟹ Regex.safe_regex fv safe m g (Star r) = Regex.safe_regex fv safe' m g (Star 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]) (*proven 6 subgoals*) . lemma safe_regex_mono: "(⋀g x. x ∈ atms r ⟹ safe g x ⟹ safe' g x) ⟹ Regex.safe_regex fv safe m g r ⟹ Regex.safe_regex fv safe' m g r" apply (induct m g r rule: safe_regex.induct (*‹⟦⋀m uu_ n. ?P m uu_ (Skip n); ⋀m g φ. ?P m g (Test φ); ⋀m g r s. ⟦?P m g r; ?P m g s⟧ ⟹ ?P m g (Plus r s); ⋀g r s. ⟦?P Futu g s; ?P Futu Lax r⟧ ⟹ ?P Futu g (Times r s); ⋀g r s. ⟦?P Past g r; ?P Past Lax s⟧ ⟹ ?P Past g (Times r s); ⋀m g r. ?P m g r ⟹ ?P m g (Star r)⟧ ⟹ ?P ?a0.0 ?a1.0 ?a2.0›*)) (*goals: 1. ‹⋀m uu_ n. ⟦⋀g x. ⟦x ∈ atms (Skip n); safe g x⟧ ⟹ safe' g x; Regex.safe_regex fv safe m uu_ (Skip n)⟧ ⟹ Regex.safe_regex fv safe' m uu_ (Skip n)› 2. ‹⋀m g φ. ⟦⋀g x. ⟦x ∈ atms (Test φ); safe g x⟧ ⟹ safe' g x; Regex.safe_regex fv safe m g (Test φ)⟧ ⟹ Regex.safe_regex fv safe' m g (Test φ)› 3. ‹⋀m g r s. ⟦⟦⋀g x. ⟦x ∈ atms r; safe g x⟧ ⟹ safe' g x; Regex.safe_regex fv safe m g r⟧ ⟹ Regex.safe_regex fv safe' m g r; ⟦⋀g x. ⟦x ∈ atms s; safe g x⟧ ⟹ safe' g x; Regex.safe_regex fv safe m g s⟧ ⟹ Regex.safe_regex fv safe' m g s; ⋀g x. ⟦x ∈ atms (Plus r s); safe g x⟧ ⟹ safe' g x; Regex.safe_regex fv safe m g (Plus r s)⟧ ⟹ Regex.safe_regex fv safe' m g (Plus r s)› 4. ‹⋀g r s. ⟦⟦⋀g x. ⟦x ∈ atms s; safe g x⟧ ⟹ safe' g x; Regex.safe_regex fv safe Futu g s⟧ ⟹ Regex.safe_regex fv safe' Futu g s; ⟦⋀g x. ⟦x ∈ atms r; safe g x⟧ ⟹ safe' g x; Regex.safe_regex fv safe Futu Lax r⟧ ⟹ Regex.safe_regex fv safe' Futu Lax r; ⋀g x. ⟦x ∈ atms (Times r s); safe g x⟧ ⟹ safe' g x; Regex.safe_regex fv safe Futu g (Times r s)⟧ ⟹ Regex.safe_regex fv safe' Futu g (Times r s)› 5. ‹⋀g r s. ⟦⟦⋀g x. ⟦x ∈ atms r; safe g x⟧ ⟹ safe' g x; Regex.safe_regex fv safe Past g r⟧ ⟹ Regex.safe_regex fv safe' Past g r; ⟦⋀g x. ⟦x ∈ atms s; safe g x⟧ ⟹ safe' g x; Regex.safe_regex fv safe Past Lax s⟧ ⟹ Regex.safe_regex fv safe' Past Lax s; ⋀g x. ⟦x ∈ atms (Times r s); safe g x⟧ ⟹ safe' g x; Regex.safe_regex fv safe Past g (Times r s)⟧ ⟹ Regex.safe_regex fv safe' Past g (Times r s)› 6. ‹⋀m g r. ⟦⟦⋀g x. ⟦x ∈ atms r; safe g x⟧ ⟹ safe' g x; Regex.safe_regex fv safe m g r⟧ ⟹ Regex.safe_regex fv safe' m g r; ⋀g x. ⟦x ∈ atms (Star r); safe g x⟧ ⟹ safe' g x; Regex.safe_regex fv safe m g (Star r)⟧ ⟹ Regex.safe_regex fv safe' m g (Star 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]) (*proven 6 subgoals*) . lemma match_map_regex: "match t (map_regex f r) = match (λk z. t k (f z)) r" apply (induct r) (*goals: 1. ‹⋀x. match t (map_regex f (Skip x)) = match (λk z. t k (f z)) (Skip x)› 2. ‹⋀x. match t (map_regex f (Test x)) = match (λk z. t k (f z)) (Test x)› 3. ‹⋀r1 r2. ⟦match t (map_regex f r1) = match (λk z. t k (f z)) r1; match t (map_regex f r2) = match (λk z. t k (f z)) r2⟧ ⟹ match t (map_regex f (Plus r1 r2)) = match (λk z. t k (f z)) (Plus r1 r2)› 4. ‹⋀r1 r2. ⟦match t (map_regex f r1) = match (λk z. t k (f z)) r1; match t (map_regex f r2) = match (λk z. t k (f z)) r2⟧ ⟹ match t (map_regex f (Times r1 r2)) = match (λk z. t k (f z)) (Times r1 r2)› 5. ‹⋀r. match t (map_regex f r) = match (λk z. t k (f z)) r ⟹ match t (map_regex f (Star r)) = match (λk z. t k (f z)) (Star 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]) (*proven 5 subgoals*) . lemma match_cong_strong: "(⋀k z. k ∈ {i ..< j + 1} ⟹ z ∈ atms r ⟹ t k z = t' k z) ⟹ match t r i j = match t' r i j" proof (induction r arbitrary: i j) (*goals: 1. ‹⋀x i j. (⋀k z. ⟦k ∈ {i..<j + 1}; z ∈ atms (Skip x)⟧ ⟹ t k z = t' k z) ⟹ match t (Skip x) i j = match t' (Skip x) i j› 2. ‹⋀x i j. (⋀k z. ⟦k ∈ {i..<j + 1}; z ∈ atms (Test x)⟧ ⟹ t k z = t' k z) ⟹ match t (Test x) i j = match t' (Test x) i j› 3. ‹⋀r1 r2 i j. ⟦⋀i j. (⋀k z. ⟦k ∈ {i..<j + 1}; z ∈ atms r1⟧ ⟹ t k z = t' k z) ⟹ match t r1 i j = match t' r1 i j; ⋀i j. (⋀k z. ⟦k ∈ {i..<j + 1}; z ∈ atms r2⟧ ⟹ t k z = t' k z) ⟹ match t r2 i j = match t' r2 i j; ⋀k z. ⟦k ∈ {i..<j + 1}; z ∈ atms (Plus r1 r2)⟧ ⟹ t k z = t' k z⟧ ⟹ match t (Plus r1 r2) i j = match t' (Plus r1 r2) i j› 4. ‹⋀r1 r2 i j. ⟦⋀i j. (⋀k z. ⟦k ∈ {i..<j + 1}; z ∈ atms r1⟧ ⟹ t k z = t' k z) ⟹ match t r1 i j = match t' r1 i j; ⋀i j. (⋀k z. ⟦k ∈ {i..<j + 1}; z ∈ atms r2⟧ ⟹ t k z = t' k z) ⟹ match t r2 i j = match t' r2 i j; ⋀k z. ⟦k ∈ {i..<j + 1}; z ∈ atms (Times r1 r2)⟧ ⟹ t k z = t' k z⟧ ⟹ match t (Times r1 r2) i j = match t' (Times r1 r2) i j› 5. ‹⋀r i j. ⟦⋀i j. (⋀k z. ⟦k ∈ {i..<j + 1}; z ∈ atms r⟧ ⟹ t k z = t' k z) ⟹ match t r i j = match t' r i j; ⋀k z. ⟦k ∈ {i..<j + 1}; z ∈ atms (Star r)⟧ ⟹ t k z = t' k z⟧ ⟹ match t (Star r) i j = match t' (Star r) i j›*) case (Times r s) (*‹(⋀k z. ⟦k ∈ {?i3..<?j3 + 1}; z ∈ atms r⟧ ⟹ t k z = t' k z) ⟹ match t r ?i3 ?j3 = match t' r ?i3 ?j3› ‹(⋀k z. ⟦k ∈ {?i3..<?j3 + 1}; z ∈ atms s⟧ ⟹ t k z = t' k z) ⟹ match t s ?i3 ?j3 = match t' s ?i3 ?j3› ‹⟦?k3 ∈ {i..<j + 1}; ?z3 ∈ atms (Times r s)⟧ ⟹ t ?k3 ?z3 = t' ?k3 ?z3›*) from Times.prems (*‹⟦?k3 ∈ {i..<j + 1}; ?z3 ∈ atms (Times r s)⟧ ⟹ t ?k3 ?z3 = t' ?k3 ?z3›*) show "?case" (*goal: ‹match t (Times r s) i j = match t' (Times r s) i j›*) by (auto 0 4 simp: relcompp_apply (*‹(?R OO ?S) ?a ?c = (∃b. ?R ?a b ∧ ?S b ?c)›*) intro: le_less_trans (*‹⟦?x ≤ ?y; ?y < ?z⟧ ⟹ ?x < ?z›*) match_le (*‹match ?test ?r ?i ?j ⟹ ?i ≤ ?j›*) less_Suc_eq_le (*‹(?m < Suc ?n) = (?m ≤ ?n)›*) dest: Times.IH[THEN iffD1, rotated -1] (*‹⟦match t r ?i4 ?j4; ⋀k z. ⟦k ∈ {?i4..<?j4 + 1}; z ∈ atms r⟧ ⟹ t k z = t' k z⟧ ⟹ match t' r ?i4 ?j4› ‹⟦match t s ?i4 ?j4; ⋀k z. ⟦k ∈ {?i4..<?j4 + 1}; z ∈ atms s⟧ ⟹ t k z = t' k z⟧ ⟹ match t' s ?i4 ?j4›*) Times.IH[THEN iffD2, rotated -1] (*‹⟦match t' r ?i4 ?j4; ⋀k z. ⟦k ∈ {?i4..<?j4 + 1}; z ∈ atms r⟧ ⟹ t k z = t' k z⟧ ⟹ match t r ?i4 ?j4› ‹⟦match t' s ?i4 ?j4; ⋀k z. ⟦k ∈ {?i4..<?j4 + 1}; z ∈ atms s⟧ ⟹ t k z = t' k z⟧ ⟹ match t s ?i4 ?j4›*) match_le (*‹match ?test ?r ?i ?j ⟹ ?i ≤ ?j›*)) next (*goals: 1. ‹⋀x i j. (⋀k z. ⟦k ∈ {i..<j + 1}; z ∈ atms (Skip x)⟧ ⟹ t k z = t' k z) ⟹ match t (Skip x) i j = match t' (Skip x) i j› 2. ‹⋀x i j. (⋀k z. ⟦k ∈ {i..<j + 1}; z ∈ atms (Test x)⟧ ⟹ t k z = t' k z) ⟹ match t (Test x) i j = match t' (Test x) i j› 3. ‹⋀r1 r2 i j. ⟦⋀i j. (⋀k z. ⟦k ∈ {i..<j + 1}; z ∈ atms r1⟧ ⟹ t k z = t' k z) ⟹ match t r1 i j = match t' r1 i j; ⋀i j. (⋀k z. ⟦k ∈ {i..<j + 1}; z ∈ atms r2⟧ ⟹ t k z = t' k z) ⟹ match t r2 i j = match t' r2 i j; ⋀k z. ⟦k ∈ {i..<j + 1}; z ∈ atms (Plus r1 r2)⟧ ⟹ t k z = t' k z⟧ ⟹ match t (Plus r1 r2) i j = match t' (Plus r1 r2) i j› 4. ‹⋀r i j. ⟦⋀i j. (⋀k z. ⟦k ∈ {i..<j + 1}; z ∈ atms r⟧ ⟹ t k z = t' k z) ⟹ match t r i j = match t' r i j; ⋀k z. ⟦k ∈ {i..<j + 1}; z ∈ atms (Star r)⟧ ⟹ t k z = t' k z⟧ ⟹ match t (Star r) i j = match t' (Star r) i j›*) case (Star r) (*‹(⋀(k::nat) z::'a. ⟦k ∈ {?i3::nat..<(?j3::nat) + (1::nat)}; z ∈ atms (r::'a regex)⟧ ⟹ (t::nat ⇒ 'a ⇒ bool) k z = (t'::nat ⇒ 'a ⇒ bool) k z) ⟹ match t r ?i3 ?j3 = match t' r ?i3 ?j3› ‹⟦?k3 ∈ {i..<j + 1}; ?z3 ∈ atms (Star r)⟧ ⟹ t ?k3 ?z3 = t' ?k3 ?z3›*) show "?case" (*goal: ‹match t (Star r) i j = match t' (Star r) i j›*) unfolding match.simps (*goal: ‹(match t r)⇧*⇧* i j = (match t' r)⇧*⇧* i j›*) proof (rule iffI (*‹⟦?P ⟹ ?Q; ?Q ⟹ ?P⟧ ⟹ ?P = ?Q›*)) (*goals: 1. ‹(match t r)⇧*⇧* i j ⟹ (match t' r)⇧*⇧* i j› 2. ‹(match t' r)⇧*⇧* i j ⟹ (match t r)⇧*⇧* i j›*) assume "*": "(match t r)⇧*⇧* i j" (*‹(match (t::nat ⇒ 'a ⇒ bool) (r::'a regex))⇧*⇧* (i::nat) (j::nat)›*) then have "i ≤ j" unfolding match.simps(5)[symmetric] (*goal: ‹i ≤ j›*) by (rule match_le (*‹match ?test ?r ?i ?j ⟹ ?i ≤ ?j›*)) with "*" (*‹(match t r)⇧*⇧* i j›*) show "(match t' r)⇧*⇧* i j" using Star.prems (*‹⟦?k3 ∈ {i..<j + 1}; ?z3 ∈ atms (Star r)⟧ ⟹ t ?k3 ?z3 = t' ?k3 ?z3›*) proof (induction i j rule: rtranclp.induct (*‹⟦?r⇧*⇧* ?x1.0 ?x2.0; ⋀a. ?P a a; ⋀a b c. ⟦?r⇧*⇧* a b; ?P a b; ?r b c⟧ ⟹ ?P a c⟧ ⟹ ?P ?x1.0 ?x2.0›*)) (*goals: 1. ‹⋀a. ⟦a ≤ a; ⋀k z. ⟦k ∈ {a..<a + 1}; z ∈ atms (Star r)⟧ ⟹ t k z = t' k z⟧ ⟹ (match t' r)⇧*⇧* a a› 2. ‹⋀a b c. ⟦(match t r)⇧*⇧* a b; ⟦a ≤ b; ⋀k z. ⟦k ∈ {a..<b + 1}; z ∈ atms (Star r)⟧ ⟹ t k z = t' k z⟧ ⟹ (match t' r)⇧*⇧* a b; match t r b c; a ≤ c; ⋀k z. ⟦k ∈ {a..<c + 1}; z ∈ atms (Star r)⟧ ⟹ t k z = t' k z⟧ ⟹ (match t' r)⇧*⇧* a c›*) case (rtrancl_into_rtrancl a b c) (*‹(match (t::nat ⇒ 'a ⇒ bool) (r::'a regex))⇧*⇧* (a::nat) (b::nat)› ‹match t r b c› ‹⟦a ≤ b; ⋀k z. ⟦k ∈ {a..<b + 1}; z ∈ atms (Star r)⟧ ⟹ t k z = t' k z⟧ ⟹ (match t' r)⇧*⇧* a b› ‹a ≤ c› ‹⟦(?k3::nat) ∈ {a::nat..<(c::nat) + (1::nat)}; (?z3::'a) ∈ atms (Star (r::'a regex))⟧ ⟹ (t::nat ⇒ 'a ⇒ bool) ?k3 ?z3 = (t'::nat ⇒ 'a ⇒ bool) ?k3 ?z3›*) from rtrancl_into_rtrancl(1,2,4,5) (*‹(match t r)⇧*⇧* a b› ‹match t r b c› ‹a ≤ c› ‹⟦(?k3::nat) ∈ {a::nat..<(c::nat) + (1::nat)}; (?z3::'a) ∈ atms (Star (r::'a regex))⟧ ⟹ (t::nat ⇒ 'a ⇒ bool) ?k3 ?z3 = (t'::nat ⇒ 'a ⇒ bool) ?k3 ?z3›*) show "?case" (*goal: ‹(match t' r)⇧*⇧* a c›*) apply (intro rtranclp.rtrancl_into_rtrancl[OF rtrancl_into_rtrancl.IH] (*‹⟦a ≤ b; ⋀k z. ⟦k ∈ {a..<b + 1}; z ∈ atms (Star r)⟧ ⟹ t k z = t' k z; match t' r b ?c⟧ ⟹ (match t' r)⇧*⇧* a ?c›*)) (*goals: 1. ‹⟦(match t r)⇧*⇧* a b; match t r b c; a ≤ c; ⋀k z. ⟦k ∈ {a..<c + 1}; z ∈ atms (Star r)⟧ ⟹ t k z = t' k z⟧ ⟹ a ≤ b› 2. ‹⋀k z. ⟦(match t r)⇧*⇧* a b; match t r b c; a ≤ c; ⋀k z. ⟦k ∈ {a..<c + 1}; z ∈ atms (Star r)⟧ ⟹ t k z = t' k z; k ∈ {a..<b + 1}; z ∈ atms (Star r)⟧ ⟹ t k z = t' k z› 3. ‹⟦(match t r)⇧*⇧* a b; match t r b c; a ≤ c; ⋀k z. ⟦k ∈ {a..<c + 1}; z ∈ atms (Star r)⟧ ⟹ t k z = t' k z⟧ ⟹ match t' r b c› discuss goal 1*) apply ((auto dest!: Star.IH[THEN iffD1, rotated -1] (*‹⟦match t r ?i4 ?j4; ⋀k z. ⟦k ∈ {?i4..<?j4 + 1}; z ∈ atms r⟧ ⟹ t k z = t' k z⟧ ⟹ match t' r ?i4 ?j4›*) dest: match_le (*‹match ?test ?r ?i ?j ⟹ ?i ≤ ?j›*) match_rtranclp_le (*‹(match ?test ?r)⇧*⇧* ?i ?j ⟹ ?i ≤ ?j›*) simp: less_Suc_eq_le (*‹(?m < Suc ?n) = (?m ≤ ?n)›*))[1]) (*discuss goal 2*) apply ((auto dest!: Star.IH[THEN iffD1, rotated -1] (*‹⟦match t r ?i4 ?j4; ⋀k z. ⟦k ∈ {?i4..<?j4 + 1}; z ∈ atms r⟧ ⟹ t k z = t' k z⟧ ⟹ match t' r ?i4 ?j4›*) dest: match_le (*‹match ?test ?r ?i ?j ⟹ ?i ≤ ?j›*) match_rtranclp_le (*‹(match ?test ?r)⇧*⇧* ?i ?j ⟹ ?i ≤ ?j›*) simp: less_Suc_eq_le (*‹(?m < Suc ?n) = (?m ≤ ?n)›*))[1]) (*discuss goal 3*) apply ((auto dest!: Star.IH[THEN iffD1, rotated -1] (*‹⟦match t r ?i4 ?j4; ⋀k z. ⟦k ∈ {?i4..<?j4 + 1}; z ∈ atms r⟧ ⟹ t k z = t' k z⟧ ⟹ match t' r ?i4 ?j4›*) dest: match_le (*‹match ?test ?r ?i ?j ⟹ ?i ≤ ?j›*) match_rtranclp_le (*‹(match ?test ?r)⇧*⇧* ?i ?j ⟹ ?i ≤ ?j›*) simp: less_Suc_eq_le (*‹(?m < Suc ?n) = (?m ≤ ?n)›*))[1]) (*proven 3 subgoals*) . qed (simp) (*solved the remaining goal: ‹⋀a. ⟦a ≤ a; ⋀k z. ⟦k ∈ {a..<a + 1}; z ∈ atms (Star r)⟧ ⟹ t k z = t' k z⟧ ⟹ (match t' r)⇧*⇧* a a›*) next (*goal: ‹(match t' r)⇧*⇧* i j ⟹ (match t r)⇧*⇧* i j›*) assume "*": "(match t' r)⇧*⇧* i j" (*‹(match (t'::nat ⇒ 'a ⇒ bool) (r::'a regex))⇧*⇧* (i::nat) (j::nat)›*) then have "i ≤ j" unfolding match.simps(5)[symmetric] (*goal: ‹i ≤ j›*) by (rule match_le (*‹match ?test ?r ?i ?j ⟹ ?i ≤ ?j›*)) with "*" (*‹(match t' r)⇧*⇧* i j›*) show "(match t r)⇧*⇧* i j" using Star.prems (*‹⟦?k3 ∈ {i..<j + 1}; ?z3 ∈ atms (Star r)⟧ ⟹ t ?k3 ?z3 = t' ?k3 ?z3›*) proof (induction i j rule: rtranclp.induct (*‹⟦(?r::?'a ⇒ ?'a ⇒ bool)⇧*⇧* (?x1.0::?'a) (?x2.0::?'a); ⋀a::?'a. (?P::?'a ⇒ ?'a ⇒ bool) a a; ⋀(a::?'a) (b::?'a) c::?'a. ⟦?r⇧*⇧* a b; ?P a b; ?r b c⟧ ⟹ ?P a c⟧ ⟹ ?P ?x1.0 ?x2.0›*)) (*goals: 1. ‹⋀a. ⟦a ≤ a; ⋀k z. ⟦k ∈ {a..<a + 1}; z ∈ atms (Star r)⟧ ⟹ t k z = t' k z⟧ ⟹ (match t r)⇧*⇧* a a› 2. ‹⋀a b c. ⟦(match t' r)⇧*⇧* a b; ⟦a ≤ b; ⋀k z. ⟦k ∈ {a..<b + 1}; z ∈ atms (Star r)⟧ ⟹ t k z = t' k z⟧ ⟹ (match t r)⇧*⇧* a b; match t' r b c; a ≤ c; ⋀k z. ⟦k ∈ {a..<c + 1}; z ∈ atms (Star r)⟧ ⟹ t k z = t' k z⟧ ⟹ (match t r)⇧*⇧* a c›*) case (rtrancl_into_rtrancl a b c) (*‹(match t' r)⇧*⇧* a b› ‹match t' r b c› ‹⟦a ≤ b; ⋀k z. ⟦k ∈ {a..<b + 1}; z ∈ atms (Star r)⟧ ⟹ t k z = t' k z⟧ ⟹ (match t r)⇧*⇧* a b› ‹a ≤ c› ‹⟦(?k3::nat) ∈ {a::nat..<(c::nat) + (1::nat)}; (?z3::'a) ∈ atms (Star (r::'a regex))⟧ ⟹ (t::nat ⇒ 'a ⇒ bool) ?k3 ?z3 = (t'::nat ⇒ 'a ⇒ bool) ?k3 ?z3›*) from rtrancl_into_rtrancl(1,2,4,5) (*‹(match (t'::nat ⇒ 'a ⇒ bool) (r::'a regex))⇧*⇧* (a::nat) (b::nat)› ‹match t' r b c› ‹(a::nat) ≤ (c::nat)› ‹⟦?k3 ∈ {a..<c + 1}; ?z3 ∈ atms (Star r)⟧ ⟹ t ?k3 ?z3 = t' ?k3 ?z3›*) show "?case" (*goal: ‹(match t r)⇧*⇧* a c›*) apply (intro rtranclp.rtrancl_into_rtrancl[OF rtrancl_into_rtrancl.IH] (*‹⟦(a::nat) ≤ (b::nat); ⋀(k::nat) z::'a. ⟦k ∈ {a..<b + (1::nat)}; z ∈ atms (Star (r::'a regex))⟧ ⟹ (t::nat ⇒ 'a ⇒ bool) k z = (t'::nat ⇒ 'a ⇒ bool) k z; match t r b (?c::nat)⟧ ⟹ (match t r)⇧*⇧* a ?c›*)) (*goals: 1. ‹⟦(match t' r)⇧*⇧* a b; match t' r b c; a ≤ c; ⋀k z. ⟦k ∈ {a..<c + 1}; z ∈ atms (Star r)⟧ ⟹ t k z = t' k z⟧ ⟹ a ≤ b› 2. ‹⋀k z. ⟦(match t' r)⇧*⇧* a b; match t' r b c; a ≤ c; ⋀k z. ⟦k ∈ {a..<c + 1}; z ∈ atms (Star r)⟧ ⟹ t k z = t' k z; k ∈ {a..<b + 1}; z ∈ atms (Star r)⟧ ⟹ t k z = t' k z› 3. ‹⟦(match t' r)⇧*⇧* a b; match t' r b c; a ≤ c; ⋀k z. ⟦k ∈ {a..<c + 1}; z ∈ atms (Star r)⟧ ⟹ t k z = t' k z⟧ ⟹ match t r b c› discuss goal 1*) apply ((auto dest!: Star.IH[THEN iffD2, rotated -1] (*‹⟦match t' r ?i4 ?j4; ⋀k z. ⟦k ∈ {?i4..<?j4 + 1}; z ∈ atms r⟧ ⟹ t k z = t' k z⟧ ⟹ match t r ?i4 ?j4›*) dest: match_le (*‹match ?test ?r ?i ?j ⟹ ?i ≤ ?j›*) match_rtranclp_le (*‹(match ?test ?r)⇧*⇧* ?i ?j ⟹ ?i ≤ ?j›*) simp: less_Suc_eq_le (*‹(?m < Suc ?n) = (?m ≤ ?n)›*))[1]) (*discuss goal 2*) apply ((auto dest!: Star.IH[THEN iffD2, rotated -1] (*‹⟦match t' r ?i4 ?j4; ⋀k z. ⟦k ∈ {?i4..<?j4 + 1}; z ∈ atms r⟧ ⟹ t k z = t' k z⟧ ⟹ match t r ?i4 ?j4›*) dest: match_le (*‹match ?test ?r ?i ?j ⟹ ?i ≤ ?j›*) match_rtranclp_le (*‹(match ?test ?r)⇧*⇧* ?i ?j ⟹ ?i ≤ ?j›*) simp: less_Suc_eq_le (*‹(?m < Suc ?n) = (?m ≤ ?n)›*))[1]) (*discuss goal 3*) apply ((auto dest!: Star.IH[THEN iffD2, rotated -1] (*‹⟦match t' r ?i4 ?j4; ⋀k z. ⟦k ∈ {?i4..<?j4 + 1}; z ∈ atms r⟧ ⟹ t k z = t' k z⟧ ⟹ match t r ?i4 ?j4›*) dest: match_le (*‹match ?test ?r ?i ?j ⟹ ?i ≤ ?j›*) match_rtranclp_le (*‹(match ?test ?r)⇧*⇧* ?i ?j ⟹ ?i ≤ ?j›*) simp: less_Suc_eq_le (*‹(?m < Suc ?n) = (?m ≤ ?n)›*))[1]) (*proven 3 subgoals*) . qed (simp) (*solved the remaining goal: ‹⋀a::nat. ⟦a ≤ a; ⋀(k::nat) z::'a::type. ⟦k ∈ {a..<a + (1::nat)}; z ∈ atms (Star (r::'a::type regex))⟧ ⟹ (t::nat ⇒ 'a::type ⇒ bool) k z = (t'::nat ⇒ 'a::type ⇒ bool) k z⟧ ⟹ (match t r)⇧*⇧* a a›*) qed qed (auto) (*solves the remaining goals: 1. ‹⋀x i j. (⋀k z. ⟦k ∈ {i..<j + 1}; z ∈ atms (Skip x)⟧ ⟹ t k z = t' k z) ⟹ match t (Skip x) i j = match t' (Skip x) i j› 2. ‹⋀x i j. (⋀k z. ⟦k ∈ {i..<j + 1}; z ∈ atms (Test x)⟧ ⟹ t k z = t' k z) ⟹ match t (Test x) i j = match t' (Test x) i j› 3. ‹⋀r1 r2 i j. ⟦⋀i j. (⋀k z. ⟦k ∈ {i..<j + 1}; z ∈ atms r1⟧ ⟹ t k z = t' k z) ⟹ match t r1 i j = match t' r1 i j; ⋀i j. (⋀k z. ⟦k ∈ {i..<j + 1}; z ∈ atms r2⟧ ⟹ t k z = t' k z) ⟹ match t r2 i j = match t' r2 i j; ⋀k z. ⟦k ∈ {i..<j + 1}; z ∈ atms (Plus r1 r2)⟧ ⟹ t k z = t' k z⟧ ⟹ match t (Plus r1 r2) i j = match t' (Plus r1 r2) i j›*) end (*<*) end (*>*)
{ "path": "afp-2025-02-12/thys/MFODL_Monitor_Optimized/Regex.thy", "repo": "afp-2025-02-12", "sha": "2cd268fb8701097fa021bd42a544774d66df50cb47be77a28ad930d54047a812" }
subsection‹Consistency› text‹We follow the proofs by Melvin Fitting~\<^cite>‹"fitting1990first"›.› theory Consistency imports Sema begin definition "Hintikka S ≡ ( ⊥ ∉ S ∧ (∀k. Atom k ∈ S ⟶ ❙¬ (Atom k) ∈ S ⟶ False) ∧ (∀F G. F ❙∧ G ∈ S ⟶ F ∈ S ∧ G ∈ S) ∧ (∀F G. F ❙∨ G ∈ S ⟶ F ∈ S ∨ G ∈ S) ∧ (∀F G. F ❙→ G ∈ S ⟶ ❙¬F ∈ S ∨ G ∈ S) ∧ (∀F. ❙¬ (❙¬F) ∈ S ⟶ F ∈ S) ∧ (∀F G. ❙¬(F ❙∧ G) ∈ S ⟶ ❙¬ F ∈ S ∨ ❙¬ G ∈ S) ∧ (∀F G. ❙¬(F ❙∨ G) ∈ S ⟶ ❙¬ F ∈ S ∧ ❙¬ G ∈ S) ∧ (∀F G. ❙¬(F ❙→ G) ∈ S ⟶ F ∈ S ∧ ❙¬ G ∈ S) )" lemma "Hintikka {Atom 0 ❙∧ ((❙¬ (Atom 1)) ❙→ Atom 2), ((❙¬ (Atom 1)) ❙→ Atom 2), Atom 0, ❙¬(❙¬ (Atom 1)), Atom 1}" unfolding Hintikka_def (*goal: ‹⊥ ∉ {Atom 0 ❙∧ (❙¬ (Atom 1) ❙→ Atom 2), ❙¬ (Atom 1) ❙→ Atom 2, Atom 0, ❙¬ (❙¬ (Atom 1)), Atom 1} ∧ (∀k. Atom k ∈ {Atom 0 ❙∧ (❙¬ (Atom 1) ❙→ Atom 2), ❙¬ (Atom 1) ❙→ Atom 2, Atom 0, ❙¬ (❙¬ (Atom 1)), Atom 1} ⟶ ❙¬ (Atom k) ∈ {Atom 0 ❙∧ (❙¬ (Atom 1) ❙→ Atom 2), ❙¬ (Atom 1) ❙→ Atom 2, Atom 0, ❙¬ (❙¬ (Atom 1)), Atom 1} ⟶ False) ∧ (∀F G. F ❙∧ G ∈ {Atom 0 ❙∧ (❙¬ (Atom 1) ❙→ Atom 2), ❙¬ (Atom 1) ❙→ Atom 2, Atom 0, ❙¬ (❙¬ (Atom 1)), Atom 1} ⟶ F ∈ {Atom 0 ❙∧ (❙¬ (Atom 1) ❙→ Atom 2), ❙¬ (Atom 1) ❙→ Atom 2, Atom 0, ❙¬ (❙¬ (Atom 1)), Atom 1} ∧ G ∈ {Atom 0 ❙∧ (❙¬ (Atom 1) ❙→ Atom 2), ❙¬ (Atom 1) ❙→ Atom 2, Atom 0, ❙¬ (❙¬ (Atom 1)), Atom 1}) ∧ (∀F G. F ❙∨ G ∈ {Atom 0 ❙∧ (❙¬ (Atom 1) ❙→ Atom 2), ❙¬ (Atom 1) ❙→ Atom 2, Atom 0, ❙¬ (❙¬ (Atom 1)), Atom 1} ⟶ F ∈ {Atom 0 ❙∧ (❙¬ (Atom 1) ❙→ Atom 2), ❙¬ (Atom 1) ❙→ Atom 2, Atom 0, ❙¬ (❙¬ (Atom 1)), Atom 1} ∨ G ∈ {Atom 0 ❙∧ (❙¬ (Atom 1) ❙→ Atom 2), ❙¬ (Atom 1) ❙→ Atom 2, Atom 0, ❙¬ (❙¬ (Atom 1)), Atom 1}) ∧ (∀F G. F ❙→ G ∈ {Atom 0 ❙∧ (❙¬ (Atom 1) ❙→ Atom 2), ❙¬ (Atom 1) ❙→ Atom 2, Atom 0, ❙¬ (❙¬ (Atom 1)), Atom 1} ⟶ ❙¬ F ∈ {Atom 0 ❙∧ (❙¬ (Atom 1) ❙→ Atom 2), ❙¬ (Atom 1) ❙→ Atom 2, Atom 0, ❙¬ (❙¬ (Atom 1)), Atom 1} ∨ G ∈ {Atom 0 ❙∧ (❙¬ (Atom 1) ❙→ Atom 2), ❙¬ (Atom 1) ❙→ Atom 2, Atom 0, ❙¬ (❙¬ (Atom 1)), Atom 1}) ∧ (∀F. ❙¬ (❙¬ F) ∈ {Atom 0 ❙∧ (❙¬ (Atom 1) ❙→ Atom 2), ❙¬ (Atom 1) ❙→ Atom 2, Atom 0, ❙¬ (❙¬ (Atom 1)), Atom 1} ⟶ F ∈ {Atom 0 ❙∧ (❙¬ (Atom 1) ❙→ Atom 2), ❙¬ (Atom 1) ❙→ Atom 2, Atom 0, ❙¬ (❙¬ (Atom 1)), Atom 1}) ∧ (∀F G. ❙¬ (F ❙∧ G) ∈ {Atom 0 ❙∧ (❙¬ (Atom 1) ❙→ Atom 2), ❙¬ (Atom 1) ❙→ Atom 2, Atom 0, ❙¬ (❙¬ (Atom 1)), Atom 1} ⟶ ❙¬ F ∈ {Atom 0 ❙∧ (❙¬ (Atom 1) ❙→ Atom 2), ❙¬ (Atom 1) ❙→ Atom 2, Atom 0, ❙¬ (❙¬ (Atom 1)), Atom 1} ∨ ❙¬ G ∈ {Atom 0 ❙∧ (❙¬ (Atom 1) ❙→ Atom 2), ❙¬ (Atom 1) ❙→ Atom 2, Atom 0, ❙¬ (❙¬ (Atom 1)), Atom 1}) ∧ (∀F G. ❙¬ (F ❙∨ G) ∈ {Atom 0 ❙∧ (❙¬ (Atom 1) ❙→ Atom 2), ❙¬ (Atom 1) ❙→ Atom 2, Atom 0, ❙¬ (❙¬ (Atom 1)), Atom 1} ⟶ ❙¬ F ∈ {Atom 0 ❙∧ (❙¬ (Atom 1) ❙→ Atom 2), ❙¬ (Atom 1) ❙→ Atom 2, Atom 0, ❙¬ (❙¬ (Atom 1)), Atom 1} ∧ ❙¬ G ∈ {Atom 0 ❙∧ (❙¬ (Atom 1) ❙→ Atom 2), ❙¬ (Atom 1) ❙→ Atom 2, Atom 0, ❙¬ (❙¬ (Atom 1)), Atom 1}) ∧ (∀F G. ❙¬ (F ❙→ G) ∈ {Atom 0 ❙∧ (❙¬ (Atom 1) ❙→ Atom 2), ❙¬ (Atom 1) ❙→ Atom 2, Atom 0, ❙¬ (❙¬ (Atom 1)), Atom 1} ⟶ F ∈ {Atom 0 ❙∧ (❙¬ (Atom 1) ❙→ Atom 2), ❙¬ (Atom 1) ❙→ Atom 2, Atom 0, ❙¬ (❙¬ (Atom 1)), Atom 1} ∧ ❙¬ G ∈ {Atom 0 ❙∧ (❙¬ (Atom 1) ❙→ Atom 2), ❙¬ (Atom 1) ❙→ Atom 2, Atom 0, ❙¬ (❙¬ (Atom 1)), Atom 1})›*) by simp theorem Hintikkas_lemma: assumes H: "Hintikka S" shows "sat S" proof (-) (*goal: ‹sat S›*) from H[unfolded Hintikka_def] (*‹⊥ ∉ S ∧ (∀k. Atom k ∈ S ⟶ ❙¬ (Atom k) ∈ S ⟶ False) ∧ (∀F G. F ❙∧ G ∈ S ⟶ F ∈ S ∧ G ∈ S) ∧ (∀F G. F ❙∨ G ∈ S ⟶ F ∈ S ∨ G ∈ S) ∧ (∀F G. F ❙→ G ∈ S ⟶ ❙¬ F ∈ S ∨ G ∈ S) ∧ (∀F. ❙¬ (❙¬ F) ∈ S ⟶ F ∈ S) ∧ (∀F G. ❙¬ (F ❙∧ G) ∈ S ⟶ ❙¬ F ∈ S ∨ ❙¬ G ∈ S) ∧ (∀F G. ❙¬ (F ❙∨ G) ∈ S ⟶ ❙¬ F ∈ S ∧ ❙¬ G ∈ S) ∧ (∀F G. ❙¬ (F ❙→ G) ∈ S ⟶ F ∈ S ∧ ❙¬ G ∈ S)›*) have H': "⊥ ∉ S" "Atom k ∈ S ⟹ ❙¬ (Atom k) ∈ S ⟹ False" "F ❙∧ G ∈ S ⟹ F ∈ S ∧ G ∈ S" "F ❙∨ G ∈ S ⟹ F ∈ S ∨ G ∈ S" "F ❙→ G ∈ S ⟹ ❙¬F ∈ S ∨ G ∈ S" "❙¬ (❙¬ F) ∈ S ⟹ F ∈ S" "❙¬ (F ❙∧ G) ∈ S ⟹ ❙¬ F ∈ S ∨ ❙¬ G ∈ S" "❙¬ (F ❙∨ G) ∈ S ⟹ ❙¬ F ∈ S ∧ ❙¬ G ∈ S" "❙¬ (F ❙→ G) ∈ S ⟹ F ∈ S ∧ ❙¬ G ∈ S" for k and F and G apply - (*goals: 1. ‹⊥ ∉ (S::'a formula set) ∧ (∀k::'a. Atom k ∈ S ⟶ ❙¬ (Atom k) ∈ S ⟶ False) ∧ (∀(F::'a formula) G::'a formula. F ❙∧ G ∈ S ⟶ F ∈ S ∧ G ∈ S) ∧ (∀(F::'a formula) G::'a formula. F ❙∨ G ∈ S ⟶ F ∈ S ∨ G ∈ S) ∧ (∀(F::'a formula) G::'a formula. F ❙→ G ∈ S ⟶ ❙¬ F ∈ S ∨ G ∈ S) ∧ (∀F::'a formula. ❙¬ (❙¬ F) ∈ S ⟶ F ∈ S) ∧ (∀(F::'a formula) G::'a formula. ❙¬ (F ❙∧ G) ∈ S ⟶ ❙¬ F ∈ S ∨ ❙¬ G ∈ S) ∧ (∀(F::'a formula) G::'a formula. ❙¬ (F ❙∨ G) ∈ S ⟶ ❙¬ F ∈ S ∧ ❙¬ G ∈ S) ∧ (∀(F::'a formula) G::'a formula. ❙¬ (F ❙→ G) ∈ S ⟶ F ∈ S ∧ ❙¬ G ∈ S) ⟹ ⊥ ∉ S› 2. ‹⟦Atom (k::'a) ∈ (S::'a formula set); ❙¬ (Atom k) ∈ S; ⊥ ∉ S ∧ (∀k::'a. Atom k ∈ S ⟶ ❙¬ (Atom k) ∈ S ⟶ False) ∧ (∀(F::'a formula) G::'a formula. F ❙∧ G ∈ S ⟶ F ∈ S ∧ G ∈ S) ∧ (∀(F::'a formula) G::'a formula. F ❙∨ G ∈ S ⟶ F ∈ S ∨ G ∈ S) ∧ (∀(F::'a formula) G::'a formula. F ❙→ G ∈ S ⟶ ❙¬ F ∈ S ∨ G ∈ S) ∧ (∀F::'a formula. ❙¬ (❙¬ F) ∈ S ⟶ F ∈ S) ∧ (∀(F::'a formula) G::'a formula. ❙¬ (F ❙∧ G) ∈ S ⟶ ❙¬ F ∈ S ∨ ❙¬ G ∈ S) ∧ (∀(F::'a formula) G::'a formula. ❙¬ (F ❙∨ G) ∈ S ⟶ ❙¬ F ∈ S ∧ ❙¬ G ∈ S) ∧ (∀(F::'a formula) G::'a formula. ❙¬ (F ❙→ G) ∈ S ⟶ F ∈ S ∧ ❙¬ G ∈ S)⟧ ⟹ False› 3. ‹⟦(F::'a formula) ❙∧ (G::'a formula) ∈ (S::'a formula set); ⊥ ∉ S ∧ (∀k::'a. Atom k ∈ S ⟶ ❙¬ (Atom k) ∈ S ⟶ False) ∧ (∀(F::'a formula) G::'a formula. F ❙∧ G ∈ S ⟶ F ∈ S ∧ G ∈ S) ∧ (∀(F::'a formula) G::'a formula. F ❙∨ G ∈ S ⟶ F ∈ S ∨ G ∈ S) ∧ (∀(F::'a formula) G::'a formula. F ❙→ G ∈ S ⟶ ❙¬ F ∈ S ∨ G ∈ S) ∧ (∀F::'a formula. ❙¬ (❙¬ F) ∈ S ⟶ F ∈ S) ∧ (∀(F::'a formula) G::'a formula. ❙¬ (F ❙∧ G) ∈ S ⟶ ❙¬ F ∈ S ∨ ❙¬ G ∈ S) ∧ (∀(F::'a formula) G::'a formula. ❙¬ (F ❙∨ G) ∈ S ⟶ ❙¬ F ∈ S ∧ ❙¬ G ∈ S) ∧ (∀(F::'a formula) G::'a formula. ❙¬ (F ❙→ G) ∈ S ⟶ F ∈ S ∧ ❙¬ G ∈ S)⟧ ⟹ F ∈ S ∧ G ∈ S› 4. ‹⟦(F::'a formula) ❙∨ (G::'a formula) ∈ (S::'a formula set); ⊥ ∉ S ∧ (∀k::'a. Atom k ∈ S ⟶ ❙¬ (Atom k) ∈ S ⟶ False) ∧ (∀(F::'a formula) G::'a formula. F ❙∧ G ∈ S ⟶ F ∈ S ∧ G ∈ S) ∧ (∀(F::'a formula) G::'a formula. F ❙∨ G ∈ S ⟶ F ∈ S ∨ G ∈ S) ∧ (∀(F::'a formula) G::'a formula. F ❙→ G ∈ S ⟶ ❙¬ F ∈ S ∨ G ∈ S) ∧ (∀F::'a formula. ❙¬ (❙¬ F) ∈ S ⟶ F ∈ S) ∧ (∀(F::'a formula) G::'a formula. ❙¬ (F ❙∧ G) ∈ S ⟶ ❙¬ F ∈ S ∨ ❙¬ G ∈ S) ∧ (∀(F::'a formula) G::'a formula. ❙¬ (F ❙∨ G) ∈ S ⟶ ❙¬ F ∈ S ∧ ❙¬ G ∈ S) ∧ (∀(F::'a formula) G::'a formula. ❙¬ (F ❙→ G) ∈ S ⟶ F ∈ S ∧ ❙¬ G ∈ S)⟧ ⟹ F ∈ S ∨ G ∈ S› 5. ‹⟦(F::'a formula) ❙→ (G::'a formula) ∈ (S::'a formula set); ⊥ ∉ S ∧ (∀k::'a. Atom k ∈ S ⟶ ❙¬ (Atom k) ∈ S ⟶ False) ∧ (∀(F::'a formula) G::'a formula. F ❙∧ G ∈ S ⟶ F ∈ S ∧ G ∈ S) ∧ (∀(F::'a formula) G::'a formula. F ❙∨ G ∈ S ⟶ F ∈ S ∨ G ∈ S) ∧ (∀(F::'a formula) G::'a formula. F ❙→ G ∈ S ⟶ ❙¬ F ∈ S ∨ G ∈ S) ∧ (∀F::'a formula. ❙¬ (❙¬ F) ∈ S ⟶ F ∈ S) ∧ (∀(F::'a formula) G::'a formula. ❙¬ (F ❙∧ G) ∈ S ⟶ ❙¬ F ∈ S ∨ ❙¬ G ∈ S) ∧ (∀(F::'a formula) G::'a formula. ❙¬ (F ❙∨ G) ∈ S ⟶ ❙¬ F ∈ S ∧ ❙¬ G ∈ S) ∧ (∀(F::'a formula) G::'a formula. ❙¬ (F ❙→ G) ∈ S ⟶ F ∈ S ∧ ❙¬ G ∈ S)⟧ ⟹ ❙¬ F ∈ S ∨ G ∈ S› 6. ‹⟦❙¬ (❙¬ (F::'a formula)) ∈ (S::'a formula set); ⊥ ∉ S ∧ (∀k::'a. Atom k ∈ S ⟶ ❙¬ (Atom k) ∈ S ⟶ False) ∧ (∀(F::'a formula) G::'a formula. F ❙∧ G ∈ S ⟶ F ∈ S ∧ G ∈ S) ∧ (∀(F::'a formula) G::'a formula. F ❙∨ G ∈ S ⟶ F ∈ S ∨ G ∈ S) ∧ (∀(F::'a formula) G::'a formula. F ❙→ G ∈ S ⟶ ❙¬ F ∈ S ∨ G ∈ S) ∧ (∀F::'a formula. ❙¬ (❙¬ F) ∈ S ⟶ F ∈ S) ∧ (∀(F::'a formula) G::'a formula. ❙¬ (F ❙∧ G) ∈ S ⟶ ❙¬ F ∈ S ∨ ❙¬ G ∈ S) ∧ (∀(F::'a formula) G::'a formula. ❙¬ (F ❙∨ G) ∈ S ⟶ ❙¬ F ∈ S ∧ ❙¬ G ∈ S) ∧ (∀(F::'a formula) G::'a formula. ❙¬ (F ❙→ G) ∈ S ⟶ F ∈ S ∧ ❙¬ G ∈ S)⟧ ⟹ F ∈ S› 7. ‹⟦❙¬ ((F::'a formula) ❙∧ (G::'a formula)) ∈ (S::'a formula set); ⊥ ∉ S ∧ (∀k::'a. Atom k ∈ S ⟶ ❙¬ (Atom k) ∈ S ⟶ False) ∧ (∀(F::'a formula) G::'a formula. F ❙∧ G ∈ S ⟶ F ∈ S ∧ G ∈ S) ∧ (∀(F::'a formula) G::'a formula. F ❙∨ G ∈ S ⟶ F ∈ S ∨ G ∈ S) ∧ (∀(F::'a formula) G::'a formula. F ❙→ G ∈ S ⟶ ❙¬ F ∈ S ∨ G ∈ S) ∧ (∀F::'a formula. ❙¬ (❙¬ F) ∈ S ⟶ F ∈ S) ∧ (∀(F::'a formula) G::'a formula. ❙¬ (F ❙∧ G) ∈ S ⟶ ❙¬ F ∈ S ∨ ❙¬ G ∈ S) ∧ (∀(F::'a formula) G::'a formula. ❙¬ (F ❙∨ G) ∈ S ⟶ ❙¬ F ∈ S ∧ ❙¬ G ∈ S) ∧ (∀(F::'a formula) G::'a formula. ❙¬ (F ❙→ G) ∈ S ⟶ F ∈ S ∧ ❙¬ G ∈ S)⟧ ⟹ ❙¬ F ∈ S ∨ ❙¬ G ∈ S› 8. ‹⟦❙¬ ((F::'a formula) ❙∨ (G::'a formula)) ∈ (S::'a formula set); ⊥ ∉ S ∧ (∀k::'a. Atom k ∈ S ⟶ ❙¬ (Atom k) ∈ S ⟶ False) ∧ (∀(F::'a formula) G::'a formula. F ❙∧ G ∈ S ⟶ F ∈ S ∧ G ∈ S) ∧ (∀(F::'a formula) G::'a formula. F ❙∨ G ∈ S ⟶ F ∈ S ∨ G ∈ S) ∧ (∀(F::'a formula) G::'a formula. F ❙→ G ∈ S ⟶ ❙¬ F ∈ S ∨ G ∈ S) ∧ (∀F::'a formula. ❙¬ (❙¬ F) ∈ S ⟶ F ∈ S) ∧ (∀(F::'a formula) G::'a formula. ❙¬ (F ❙∧ G) ∈ S ⟶ ❙¬ F ∈ S ∨ ❙¬ G ∈ S) ∧ (∀(F::'a formula) G::'a formula. ❙¬ (F ❙∨ G) ∈ S ⟶ ❙¬ F ∈ S ∧ ❙¬ G ∈ S) ∧ (∀(F::'a formula) G::'a formula. ❙¬ (F ❙→ G) ∈ S ⟶ F ∈ S ∧ ❙¬ G ∈ S)⟧ ⟹ ❙¬ F ∈ S ∧ ❙¬ G ∈ S› 9. ‹⟦❙¬ ((F::'a formula) ❙→ (G::'a formula)) ∈ (S::'a formula set); ⊥ ∉ S ∧ (∀k::'a. Atom k ∈ S ⟶ ❙¬ (Atom k) ∈ S ⟶ False) ∧ (∀(F::'a formula) G::'a formula. F ❙∧ G ∈ S ⟶ F ∈ S ∧ G ∈ S) ∧ (∀(F::'a formula) G::'a formula. F ❙∨ G ∈ S ⟶ F ∈ S ∨ G ∈ S) ∧ (∀(F::'a formula) G::'a formula. F ❙→ G ∈ S ⟶ ❙¬ F ∈ S ∨ G ∈ S) ∧ (∀F::'a formula. ❙¬ (❙¬ F) ∈ S ⟶ F ∈ S) ∧ (∀(F::'a formula) G::'a formula. ❙¬ (F ❙∧ G) ∈ S ⟶ ❙¬ F ∈ S ∨ ❙¬ G ∈ S) ∧ (∀(F::'a formula) G::'a formula. ❙¬ (F ❙∨ G) ∈ S ⟶ ❙¬ F ∈ S ∧ ❙¬ G ∈ S) ∧ (∀(F::'a formula) G::'a formula. ❙¬ (F ❙→ G) ∈ S ⟶ F ∈ S ∧ ❙¬ G ∈ S)⟧ ⟹ F ∈ S ∧ ❙¬ G ∈ S› 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 (*discuss goal 7*) apply blast (*discuss goal 8*) apply blast (*discuss goal 9*) apply blast (*proven 9 subgoals*) . let ?M = "λk. Atom k ∈ S" have "(F ∈ S ⟶ (?M ⊨ F)) ∧ (❙¬ F ∈ S ⟶ (¬(?M ⊨ F)))" for F apply (induction F) (*goals: 1. ‹⋀x. (Atom x ∈ S ⟶ (λk. Atom k ∈ S) ⊨ Atom x) ∧ (❙¬ (Atom x) ∈ S ⟶ ¬ (λk. Atom k ∈ S) ⊨ Atom x)› 2. ‹(⊥ ∈ S ⟶ (λk. Atom k ∈ S) ⊨ ⊥) ∧ (❙¬ ⊥ ∈ S ⟶ ¬ (λk. Atom k ∈ S) ⊨ ⊥)› 3. ‹⋀F. (F ∈ S ⟶ (λk. Atom k ∈ S) ⊨ F) ∧ (❙¬ F ∈ S ⟶ ¬ (λk. Atom k ∈ S) ⊨ F) ⟹ (❙¬ F ∈ S ⟶ (λk. Atom k ∈ S) ⊨ ❙¬ F) ∧ (❙¬ (❙¬ F) ∈ S ⟶ ¬ (λk. Atom k ∈ S) ⊨ ❙¬ F)› 4. ‹⋀F1 F2. ⟦(F1 ∈ S ⟶ (λk. Atom k ∈ S) ⊨ F1) ∧ (❙¬ F1 ∈ S ⟶ ¬ (λk. Atom k ∈ S) ⊨ F1); (F2 ∈ S ⟶ (λk. Atom k ∈ S) ⊨ F2) ∧ (❙¬ F2 ∈ S ⟶ ¬ (λk. Atom k ∈ S) ⊨ F2)⟧ ⟹ (F1 ❙∧ F2 ∈ S ⟶ (λk. Atom k ∈ S) ⊨ F1 ❙∧ F2) ∧ (❙¬ (F1 ❙∧ F2) ∈ S ⟶ ¬ (λk. Atom k ∈ S) ⊨ F1 ❙∧ F2)› 5. ‹⋀F1 F2. ⟦(F1 ∈ S ⟶ (λk. Atom k ∈ S) ⊨ F1) ∧ (❙¬ F1 ∈ S ⟶ ¬ (λk. Atom k ∈ S) ⊨ F1); (F2 ∈ S ⟶ (λk. Atom k ∈ S) ⊨ F2) ∧ (❙¬ F2 ∈ S ⟶ ¬ (λk. Atom k ∈ S) ⊨ F2)⟧ ⟹ (F1 ❙∨ F2 ∈ S ⟶ (λk. Atom k ∈ S) ⊨ F1 ❙∨ F2) ∧ (❙¬ (F1 ❙∨ F2) ∈ S ⟶ ¬ (λk. Atom k ∈ S) ⊨ F1 ❙∨ F2)› 6. ‹⋀F1 F2. ⟦(F1 ∈ S ⟶ (λk. Atom k ∈ S) ⊨ F1) ∧ (❙¬ F1 ∈ S ⟶ ¬ (λk. Atom k ∈ S) ⊨ F1); (F2 ∈ S ⟶ (λk. Atom k ∈ S) ⊨ F2) ∧ (❙¬ F2 ∈ S ⟶ ¬ (λk. Atom k ∈ S) ⊨ F2)⟧ ⟹ (F1 ❙→ F2 ∈ S ⟶ (λk. Atom k ∈ S) ⊨ F1 ❙→ F2) ∧ (❙¬ (F1 ❙→ F2) ∈ S ⟶ ¬ (λk. Atom k ∈ S) ⊨ F1 ❙→ F2)› discuss goal 1*) apply ((auto simp: H'( (*‹⊥ ∉ S›*) 1) dest!: H'( (*‹⟦Atom ?k ∈ S; ❙¬ (Atom ?k) ∈ S⟧ ⟹ False› ‹?F ❙∧ ?G ∈ S ⟹ ?F ∈ S ∧ ?G ∈ S› ‹?F ❙∨ ?G ∈ S ⟹ ?F ∈ S ∨ ?G ∈ S› ‹?F ❙→ ?G ∈ S ⟹ ❙¬ ?F ∈ S ∨ ?G ∈ S› ‹❙¬ (❙¬ ?F) ∈ S ⟹ ?F ∈ S› ‹❙¬ (?F ❙∧ ?G) ∈ S ⟹ ❙¬ ?F ∈ S ∨ ❙¬ ?G ∈ S› ‹❙¬ (?F ❙∨ ?G) ∈ S ⟹ ❙¬ ?F ∈ S ∧ ❙¬ ?G ∈ S› ‹❙¬ (?F ❙→ ?G) ∈ S ⟹ ?F ∈ S ∧ ❙¬ ?G ∈ S›*) 2-))[1]) (*discuss goal 2*) apply ((auto simp: H'( (*‹⊥ ∉ (S::'a formula set)›*) 1) dest!: H'( (*‹⟦Atom (?k::'a) ∈ (S::'a formula set); ❙¬ (Atom ?k) ∈ S⟧ ⟹ False› ‹(?F::'a formula) ❙∧ (?G::'a formula) ∈ (S::'a formula set) ⟹ ?F ∈ S ∧ ?G ∈ S› ‹(?F::'a formula) ❙∨ (?G::'a formula) ∈ (S::'a formula set) ⟹ ?F ∈ S ∨ ?G ∈ S› ‹(?F::'a formula) ❙→ (?G::'a formula) ∈ (S::'a formula set) ⟹ ❙¬ ?F ∈ S ∨ ?G ∈ S› ‹❙¬ (❙¬ (?F::'a formula)) ∈ (S::'a formula set) ⟹ ?F ∈ S› ‹❙¬ ((?F::'a formula) ❙∧ (?G::'a formula)) ∈ (S::'a formula set) ⟹ ❙¬ ?F ∈ S ∨ ❙¬ ?G ∈ S› ‹❙¬ ((?F::'a formula) ❙∨ (?G::'a formula)) ∈ (S::'a formula set) ⟹ ❙¬ ?F ∈ S ∧ ❙¬ ?G ∈ S› ‹❙¬ ((?F::'a formula) ❙→ (?G::'a formula)) ∈ (S::'a formula set) ⟹ ?F ∈ S ∧ ❙¬ ?G ∈ S›*) 2-))[1]) (*discuss goal 3*) apply ((auto simp: H'( (*‹⊥ ∉ S›*) 1) dest!: H'( (*‹⟦Atom ?k ∈ S; ❙¬ (Atom ?k) ∈ S⟧ ⟹ False› ‹?F ❙∧ ?G ∈ S ⟹ ?F ∈ S ∧ ?G ∈ S› ‹?F ❙∨ ?G ∈ S ⟹ ?F ∈ S ∨ ?G ∈ S› ‹?F ❙→ ?G ∈ S ⟹ ❙¬ ?F ∈ S ∨ ?G ∈ S› ‹❙¬ (❙¬ ?F) ∈ S ⟹ ?F ∈ S› ‹❙¬ (?F ❙∧ ?G) ∈ S ⟹ ❙¬ ?F ∈ S ∨ ❙¬ ?G ∈ S› ‹❙¬ (?F ❙∨ ?G) ∈ S ⟹ ❙¬ ?F ∈ S ∧ ❙¬ ?G ∈ S› ‹❙¬ (?F ❙→ ?G) ∈ S ⟹ ?F ∈ S ∧ ❙¬ ?G ∈ S›*) 2-))[1]) (*discuss goal 4*) apply ((auto simp: H'( (*‹⊥ ∉ S›*) 1) dest!: H'( (*‹⟦Atom ?k ∈ S; ❙¬ (Atom ?k) ∈ S⟧ ⟹ False› ‹?F ❙∧ ?G ∈ S ⟹ ?F ∈ S ∧ ?G ∈ S› ‹?F ❙∨ ?G ∈ S ⟹ ?F ∈ S ∨ ?G ∈ S› ‹?F ❙→ ?G ∈ S ⟹ ❙¬ ?F ∈ S ∨ ?G ∈ S› ‹❙¬ (❙¬ ?F) ∈ S ⟹ ?F ∈ S› ‹❙¬ (?F ❙∧ ?G) ∈ S ⟹ ❙¬ ?F ∈ S ∨ ❙¬ ?G ∈ S› ‹❙¬ (?F ❙∨ ?G) ∈ S ⟹ ❙¬ ?F ∈ S ∧ ❙¬ ?G ∈ S› ‹❙¬ (?F ❙→ ?G) ∈ S ⟹ ?F ∈ S ∧ ❙¬ ?G ∈ S›*) 2-))[1]) (*discuss goal 5*) apply ((auto simp: H'( (*‹⊥ ∉ S›*) 1) dest!: H'( (*‹⟦Atom ?k ∈ S; ❙¬ (Atom ?k) ∈ S⟧ ⟹ False› ‹?F ❙∧ ?G ∈ S ⟹ ?F ∈ S ∧ ?G ∈ S› ‹?F ❙∨ ?G ∈ S ⟹ ?F ∈ S ∨ ?G ∈ S› ‹?F ❙→ ?G ∈ S ⟹ ❙¬ ?F ∈ S ∨ ?G ∈ S› ‹❙¬ (❙¬ ?F) ∈ S ⟹ ?F ∈ S› ‹❙¬ (?F ❙∧ ?G) ∈ S ⟹ ❙¬ ?F ∈ S ∨ ❙¬ ?G ∈ S› ‹❙¬ (?F ❙∨ ?G) ∈ S ⟹ ❙¬ ?F ∈ S ∧ ❙¬ ?G ∈ S› ‹❙¬ (?F ❙→ ?G) ∈ S ⟹ ?F ∈ S ∧ ❙¬ ?G ∈ S›*) 2-))[1]) (*discuss goal 6*) apply ((auto simp: H'( (*‹⊥ ∉ (S::'a::type formula set)›*) 1) dest!: H'( (*‹⟦Atom (?k::'a::type) ∈ (S::'a::type formula set); ❙¬ (Atom ?k) ∈ S⟧ ⟹ False› ‹(?F::'a::type formula) ❙∧ (?G::'a::type formula) ∈ (S::'a::type formula set) ⟹ ?F ∈ S ∧ ?G ∈ S› ‹(?F::'a::type formula) ❙∨ (?G::'a::type formula) ∈ (S::'a::type formula set) ⟹ ?F ∈ S ∨ ?G ∈ S› ‹(?F::'a::type formula) ❙→ (?G::'a::type formula) ∈ (S::'a::type formula set) ⟹ ❙¬ ?F ∈ S ∨ ?G ∈ S› ‹❙¬ (❙¬ (?F::'a::type formula)) ∈ (S::'a::type formula set) ⟹ ?F ∈ S› ‹❙¬ ((?F::'a::type formula) ❙∧ (?G::'a::type formula)) ∈ (S::'a::type formula set) ⟹ ❙¬ ?F ∈ S ∨ ❙¬ ?G ∈ S› ‹❙¬ ((?F::'a::type formula) ❙∨ (?G::'a::type formula)) ∈ (S::'a::type formula set) ⟹ ❙¬ ?F ∈ S ∧ ❙¬ ?G ∈ S› ‹❙¬ ((?F::'a::type formula) ❙→ (?G::'a::type formula)) ∈ (S::'a::type formula set) ⟹ ?F ∈ S ∧ ❙¬ ?G ∈ S›*) 2-))[1]) (*proven 6 subgoals*) . thus "?thesis" (*goal: ‹sat S›*) unfolding sat_def (*goal: ‹∃𝒜. ∀F∈S. 𝒜 ⊨ F›*) by blast qed definition "pcp C ≡ (∀S ∈ C. ⊥ ∉ S ∧ (∀k. Atom k ∈ S ⟶ ❙¬ (Atom k) ∈ S ⟶ False) ∧ (∀F G. F ❙∧ G ∈ S ⟶ F ▹ G ▹ S ∈ C) ∧ (∀F G. F ❙∨ G ∈ S ⟶ F ▹ S ∈ C ∨ G ▹ S ∈ C) ∧ (∀F G. F ❙→ G ∈ S ⟶ ❙¬F ▹ S ∈ C ∨ G ▹ S ∈ C) ∧ (∀F. ❙¬ (❙¬F) ∈ S ⟶ F ▹ S ∈ C) ∧ (∀F G. ❙¬(F ❙∧ G) ∈ S ⟶ ❙¬ F ▹ S ∈ C ∨ ❙¬ G ▹ S ∈ C) ∧ (∀F G. ❙¬(F ❙∨ G) ∈ S ⟶ ❙¬ F ▹ ❙¬ G ▹ S ∈ C) ∧ (∀F G. ❙¬(F ❙→ G) ∈ S ⟶ F ▹ ❙¬ G ▹ S ∈ C) )" (* just some examples *) lemma "pcp {}" "pcp {{}}" "pcp {{Atom 0}}" (*goals: 1. ‹pcp {}› 2. ‹pcp {{}}› 3. ‹pcp {{Atom 0}}› discuss goal 1*) apply (simp add: pcp_def (*‹pcp (?C::?'a formula set set) ≡ ∀S::?'a formula set∈?C. ⊥ ∉ S ∧ (∀k::?'a. Atom k ∈ S ⟶ ❙¬ (Atom k) ∈ S ⟶ False) ∧ (∀(F::?'a formula) G::?'a formula. F ❙∧ G ∈ S ⟶ F ▹ G ▹ S ∈ ?C) ∧ (∀(F::?'a formula) G::?'a formula. F ❙∨ G ∈ S ⟶ F ▹ S ∈ ?C ∨ G ▹ S ∈ ?C) ∧ (∀(F::?'a formula) G::?'a formula. F ❙→ G ∈ S ⟶ ❙¬ F ▹ S ∈ ?C ∨ G ▹ S ∈ ?C) ∧ (∀F::?'a formula. ❙¬ (❙¬ F) ∈ S ⟶ F ▹ S ∈ ?C) ∧ (∀(F::?'a formula) G::?'a formula. ❙¬ (F ❙∧ G) ∈ S ⟶ ❙¬ F ▹ S ∈ ?C ∨ ❙¬ G ▹ S ∈ ?C) ∧ (∀(F::?'a formula) G::?'a formula. ❙¬ (F ❙∨ G) ∈ S ⟶ ❙¬ F ▹ ❙¬ G ▹ S ∈ ?C) ∧ (∀(F::?'a formula) G::?'a formula. ❙¬ (F ❙→ G) ∈ S ⟶ F ▹ ❙¬ G ▹ S ∈ ?C)›*)) (*discuss goal 2*) apply (simp add: pcp_def (*‹pcp ?C ≡ ∀S∈?C. ⊥ ∉ S ∧ (∀k. Atom k ∈ S ⟶ ❙¬ (Atom k) ∈ S ⟶ False) ∧ (∀F G. F ❙∧ G ∈ S ⟶ F ▹ G ▹ S ∈ ?C) ∧ (∀F G. F ❙∨ G ∈ S ⟶ F ▹ S ∈ ?C ∨ G ▹ S ∈ ?C) ∧ (∀F G. F ❙→ G ∈ S ⟶ ❙¬ F ▹ S ∈ ?C ∨ G ▹ S ∈ ?C) ∧ (∀F. ❙¬ (❙¬ F) ∈ S ⟶ F ▹ S ∈ ?C) ∧ (∀F G. ❙¬ (F ❙∧ G) ∈ S ⟶ ❙¬ F ▹ S ∈ ?C ∨ ❙¬ G ▹ S ∈ ?C) ∧ (∀F G. ❙¬ (F ❙∨ G) ∈ S ⟶ ❙¬ F ▹ ❙¬ G ▹ S ∈ ?C) ∧ (∀F G. ❙¬ (F ❙→ G) ∈ S ⟶ F ▹ ❙¬ G ▹ S ∈ ?C)›*)) (*discuss goal 3*) apply (simp add: pcp_def (*‹pcp ?C ≡ ∀S∈?C. ⊥ ∉ S ∧ (∀k. Atom k ∈ S ⟶ ❙¬ (Atom k) ∈ S ⟶ False) ∧ (∀F G. F ❙∧ G ∈ S ⟶ F ▹ G ▹ S ∈ ?C) ∧ (∀F G. F ❙∨ G ∈ S ⟶ F ▹ S ∈ ?C ∨ G ▹ S ∈ ?C) ∧ (∀F G. F ❙→ G ∈ S ⟶ ❙¬ F ▹ S ∈ ?C ∨ G ▹ S ∈ ?C) ∧ (∀F. ❙¬ (❙¬ F) ∈ S ⟶ F ▹ S ∈ ?C) ∧ (∀F G. ❙¬ (F ❙∧ G) ∈ S ⟶ ❙¬ F ▹ S ∈ ?C ∨ ❙¬ G ▹ S ∈ ?C) ∧ (∀F G. ❙¬ (F ❙∨ G) ∈ S ⟶ ❙¬ F ▹ ❙¬ G ▹ S ∈ ?C) ∧ (∀F G. ❙¬ (F ❙→ G) ∈ S ⟶ F ▹ ❙¬ G ▹ S ∈ ?C)›*)) (*proven 3 subgoals*) . lemma "pcp {{(❙¬ (Atom 1)) ❙→ Atom 2}, {((❙¬ (Atom 1)) ❙→ Atom 2), ❙¬(❙¬ (Atom 1))}, {((❙¬ (Atom 1)) ❙→ Atom 2), ❙¬(❙¬ (Atom 1)), Atom 1}}" by (auto simp add: pcp_def (*‹pcp ?C ≡ ∀S∈?C. ⊥ ∉ S ∧ (∀k. Atom k ∈ S ⟶ ❙¬ (Atom k) ∈ S ⟶ False) ∧ (∀F G. F ❙∧ G ∈ S ⟶ F ▹ G ▹ S ∈ ?C) ∧ (∀F G. F ❙∨ G ∈ S ⟶ F ▹ S ∈ ?C ∨ G ▹ S ∈ ?C) ∧ (∀F G. F ❙→ G ∈ S ⟶ ❙¬ F ▹ S ∈ ?C ∨ G ▹ S ∈ ?C) ∧ (∀F. ❙¬ (❙¬ F) ∈ S ⟶ F ▹ S ∈ ?C) ∧ (∀F G. ❙¬ (F ❙∧ G) ∈ S ⟶ ❙¬ F ▹ S ∈ ?C ∨ ❙¬ G ▹ S ∈ ?C) ∧ (∀F G. ❙¬ (F ❙∨ G) ∈ S ⟶ ❙¬ F ▹ ❙¬ G ▹ S ∈ ?C) ∧ (∀F G. ❙¬ (F ❙→ G) ∈ S ⟶ F ▹ ❙¬ G ▹ S ∈ ?C)›*)) text‹Fitting uses uniform notation~\<^cite>‹"smullyan1963unifying"› for the definition of @{const pcp}. We try to mimic this, more to see whether it works than because it is ultimately necessary.› (* It does help a bit, occasionally. *) inductive Con :: "'a formula => 'a formula => 'a formula => bool" where "Con (And F G) F G" | "Con (Not (Or F G)) (Not F) (Not G)" | "Con (Not (Imp F G)) F (Not G)" | "Con (Not (Not F)) F F" inductive Dis :: "'a formula => 'a formula => 'a formula => bool" where "Dis (Or F G) F G" | "Dis (Imp F G) (Not F) G" | "Dis (Not (And F G)) (Not F) (Not G)" | "Dis (Not (Not F)) F F" (* note that *) lemma "Con (Not (Not F)) F F" "Dis (Not (Not F)) F F" (*goals: 1. ‹Con (❙¬ (❙¬ F)) F F› 2. ‹Dis (❙¬ (❙¬ F)) F F› discuss goal 1*) apply (intro Con.intros (*‹Con (?F ❙∧ ?G) ?F ?G› ‹Con (❙¬ (?F ❙∨ ?G)) (❙¬ ?F) (❙¬ ?G)› ‹Con (❙¬ (?F ❙→ ?G)) ?F (❙¬ ?G)› ‹Con (❙¬ (❙¬ ?F)) ?F ?F›*) Dis.intros (*‹Dis (?F ❙∨ ?G) ?F ?G› ‹Dis (?F ❙→ ?G) (❙¬ ?F) ?G› ‹Dis (❙¬ (?F ❙∧ ?G)) (❙¬ ?F) (❙¬ ?G)› ‹Dis (❙¬ (❙¬ ?F)) ?F ?F›*)) (*discuss goal 2*) apply (intro Con.intros (*‹Con (?F ❙∧ ?G) ?F ?G› ‹Con (❙¬ (?F ❙∨ ?G)) (❙¬ ?F) (❙¬ ?G)› ‹Con (❙¬ (?F ❙→ ?G)) ?F (❙¬ ?G)› ‹Con (❙¬ (❙¬ ?F)) ?F ?F›*) Dis.intros (*‹Dis (?F ❙∨ ?G) ?F ?G› ‹Dis (?F ❙→ ?G) (❙¬ ?F) ?G› ‹Dis (❙¬ (?F ❙∧ ?G)) (❙¬ ?F) (❙¬ ?G)› ‹Dis (❙¬ (❙¬ ?F)) ?F ?F›*)) (*proven 2 subgoals*) . (* i.e. ❙¬❙¬ is both Conjunctive and Disjunctive. I saw no reason to break this symmetry. *) lemma con_dis_simps: "Con a1 a2 a3 = (a1 = a2 ❙∧ a3 ∨ (∃F G. a1 = ❙¬ (F ❙∨ G) ∧ a2 = ❙¬ F ∧ a3 = ❙¬ G) ∨ (∃G. a1 = ❙¬ (a2 ❙→ G) ∧ a3 = ❙¬ G) ∨ a1 = ❙¬ (❙¬ a2) ∧ a3 = a2)" "Dis a1 a2 a3 = (a1 = a2 ❙∨ a3 ∨ (∃F G. a1 = F ❙→ G ∧ a2 = ❙¬ F ∧ a3 = G) ∨ (∃F G. a1 = ❙¬ (F ❙∧ G) ∧ a2 = ❙¬ F ∧ a3 = ❙¬ G) ∨ a1 = ❙¬ (❙¬ a2) ∧ a3 = a2)" (*goals: 1. ‹Con (a1::'a formula) (a2::'a formula) (a3::'a formula) = (a1 = a2 ❙∧ a3 ∨ (∃(F::'a formula) G::'a formula. a1 = ❙¬ (F ❙∨ G) ∧ a2 = ❙¬ F ∧ a3 = ❙¬ G) ∨ (∃G::'a formula. a1 = ❙¬ (a2 ❙→ G) ∧ a3 = ❙¬ G) ∨ a1 = ❙¬ (❙¬ a2) ∧ a3 = a2)› 2. ‹Dis (a1::'a formula) (a2::'a formula) (a3::'a formula) = (a1 = a2 ❙∨ a3 ∨ (∃(F::'a formula) G::'a formula. a1 = F ❙→ G ∧ a2 = ❙¬ F ∧ a3 = G) ∨ (∃(F::'a formula) G::'a formula. a1 = ❙¬ (F ❙∧ G) ∧ a2 = ❙¬ F ∧ a3 = ❙¬ G) ∨ a1 = ❙¬ (❙¬ a2) ∧ a3 = a2)› discuss goal 1*) apply (simp add: Con.simps (*‹Con ?a1.0 ?a2.0 ?a3.0 = ((∃F G. ?a1.0 = F ❙∧ G ∧ ?a2.0 = F ∧ ?a3.0 = G) ∨ (∃F G. ?a1.0 = ❙¬ (F ❙∨ G) ∧ ?a2.0 = ❙¬ F ∧ ?a3.0 = ❙¬ G) ∨ (∃F G. ?a1.0 = ❙¬ (F ❙→ G) ∧ ?a2.0 = F ∧ ?a3.0 = ❙¬ G) ∨ (∃F. ?a1.0 = ❙¬ (❙¬ F) ∧ ?a2.0 = F ∧ ?a3.0 = F))›*) Dis.simps (*‹Dis ?a1.0 ?a2.0 ?a3.0 = ((∃F G. ?a1.0 = F ❙∨ G ∧ ?a2.0 = F ∧ ?a3.0 = G) ∨ (∃F G. ?a1.0 = F ❙→ G ∧ ?a2.0 = ❙¬ F ∧ ?a3.0 = G) ∨ (∃F G. ?a1.0 = ❙¬ (F ❙∧ G) ∧ ?a2.0 = ❙¬ F ∧ ?a3.0 = ❙¬ G) ∨ (∃F. ?a1.0 = ❙¬ (❙¬ F) ∧ ?a2.0 = F ∧ ?a3.0 = F))›*)) (*discuss goal 2*) apply (simp add: Con.simps (*‹Con ?a1.0 ?a2.0 ?a3.0 = ((∃F G. ?a1.0 = F ❙∧ G ∧ ?a2.0 = F ∧ ?a3.0 = G) ∨ (∃F G. ?a1.0 = ❙¬ (F ❙∨ G) ∧ ?a2.0 = ❙¬ F ∧ ?a3.0 = ❙¬ G) ∨ (∃F G. ?a1.0 = ❙¬ (F ❙→ G) ∧ ?a2.0 = F ∧ ?a3.0 = ❙¬ G) ∨ (∃F. ?a1.0 = ❙¬ (❙¬ F) ∧ ?a2.0 = F ∧ ?a3.0 = F))›*) Dis.simps (*‹Dis ?a1.0 ?a2.0 ?a3.0 = ((∃F G. ?a1.0 = F ❙∨ G ∧ ?a2.0 = F ∧ ?a3.0 = G) ∨ (∃F G. ?a1.0 = F ❙→ G ∧ ?a2.0 = ❙¬ F ∧ ?a3.0 = G) ∨ (∃F G. ?a1.0 = ❙¬ (F ❙∧ G) ∧ ?a2.0 = ❙¬ F ∧ ?a3.0 = ❙¬ G) ∨ (∃F. ?a1.0 = ❙¬ (❙¬ F) ∧ ?a2.0 = F ∧ ?a3.0 = F))›*)) (*proven 2 subgoals*) . lemma Hintikka_alt: "Hintikka S = ( ⊥ ∉ S ∧ (∀k. Atom k ∈ S ⟶ ❙¬ (Atom k) ∈ S ⟶ False) ∧ (∀F G H. Con F G H ⟶ F ∈ S ⟶ G ∈ S ∧ H ∈ S) ∧ (∀F G H. Dis F G H ⟶ F ∈ S ⟶ G ∈ S ∨ H ∈ S) )" apply (simp add: Hintikka_def (*‹Hintikka (?S::?'a formula set) ≡ ⊥ ∉ ?S ∧ (∀k::?'a. Atom k ∈ ?S ⟶ ❙¬ (Atom k) ∈ ?S ⟶ False) ∧ (∀(F::?'a formula) G::?'a formula. F ❙∧ G ∈ ?S ⟶ F ∈ ?S ∧ G ∈ ?S) ∧ (∀(F::?'a formula) G::?'a formula. F ❙∨ G ∈ ?S ⟶ F ∈ ?S ∨ G ∈ ?S) ∧ (∀(F::?'a formula) G::?'a formula. F ❙→ G ∈ ?S ⟶ ❙¬ F ∈ ?S ∨ G ∈ ?S) ∧ (∀F::?'a formula. ❙¬ (❙¬ F) ∈ ?S ⟶ F ∈ ?S) ∧ (∀(F::?'a formula) G::?'a formula. ❙¬ (F ❙∧ G) ∈ ?S ⟶ ❙¬ F ∈ ?S ∨ ❙¬ G ∈ ?S) ∧ (∀(F::?'a formula) G::?'a formula. ❙¬ (F ❙∨ G) ∈ ?S ⟶ ❙¬ F ∈ ?S ∧ ❙¬ G ∈ ?S) ∧ (∀(F::?'a formula) G::?'a formula. ❙¬ (F ❙→ G) ∈ ?S ⟶ F ∈ ?S ∧ ❙¬ G ∈ ?S)›*) con_dis_simps (*‹Con (?a1.0::?'a formula) (?a2.0::?'a formula) (?a3.0::?'a formula) = (?a1.0 = ?a2.0 ❙∧ ?a3.0 ∨ (∃(F::?'a formula) G::?'a formula. ?a1.0 = ❙¬ (F ❙∨ G) ∧ ?a2.0 = ❙¬ F ∧ ?a3.0 = ❙¬ G) ∨ (∃G::?'a formula. ?a1.0 = ❙¬ (?a2.0 ❙→ G) ∧ ?a3.0 = ❙¬ G) ∨ ?a1.0 = ❙¬ (❙¬ ?a2.0) ∧ ?a3.0 = ?a2.0)› ‹Dis (?a1.0::?'a formula) (?a2.0::?'a formula) (?a3.0::?'a formula) = (?a1.0 = ?a2.0 ❙∨ ?a3.0 ∨ (∃(F::?'a formula) G::?'a formula. ?a1.0 = F ❙→ G ∧ ?a2.0 = ❙¬ F ∧ ?a3.0 = G) ∨ (∃(F::?'a formula) G::?'a formula. ?a1.0 = ❙¬ (F ❙∧ G) ∧ ?a2.0 = ❙¬ F ∧ ?a3.0 = ❙¬ G) ∨ ?a1.0 = ❙¬ (❙¬ ?a2.0) ∧ ?a3.0 = ?a2.0)›*)) (*goal: ‹Hintikka S = (⊥ ∉ S ∧ (∀k. Atom k ∈ S ⟶ ❙¬ (Atom k) ∈ S ⟶ False) ∧ (∀F G H. Con F G H ⟶ F ∈ S ⟶ G ∈ S ∧ H ∈ S) ∧ (∀F G H. Dis F G H ⟶ F ∈ S ⟶ G ∈ S ∨ H ∈ S))›*) apply (rule iffI (*‹⟦?P ⟹ ?Q; ?Q ⟹ ?P⟧ ⟹ ?P = ?Q›*)) (*goal: ‹(⊥ ∉ S ∧ (∀k. Atom k ∈ S ⟶ ❙¬ (Atom k) ∉ S) ∧ (∀F G. F ❙∧ G ∈ S ⟶ F ∈ S ∧ G ∈ S) ∧ (∀F G. F ❙∨ G ∈ S ⟶ F ∈ S ∨ G ∈ S) ∧ (∀F G. F ❙→ G ∈ S ⟶ ❙¬ F ∈ S ∨ G ∈ S) ∧ (∀F. ❙¬ (❙¬ F) ∈ S ⟶ F ∈ S) ∧ (∀F G. ❙¬ (F ❙∧ G) ∈ S ⟶ ❙¬ F ∈ S ∨ ❙¬ G ∈ S) ∧ (∀F G. ❙¬ (F ❙∨ G) ∈ S ⟶ ❙¬ F ∈ S ∧ ❙¬ G ∈ S) ∧ (∀F G. ❙¬ (F ❙→ G) ∈ S ⟶ F ∈ S ∧ ❙¬ G ∈ S)) = (⊥ ∉ S ∧ (∀k. Atom k ∈ S ⟶ ❙¬ (Atom k) ∉ S) ∧ (∀F G H. (F = G ❙∧ H ⟶ G ❙∧ H ∈ S ⟶ G ∈ S ∧ H ∈ S) ∧ ((∃Fa Ga. F = ❙¬ (Fa ❙∨ Ga) ∧ G = ❙¬ Fa ∧ H = ❙¬ Ga) ⟶ F ∈ S ⟶ G ∈ S ∧ H ∈ S) ∧ ((∃Ga. F = ❙¬ (G ❙→ Ga) ∧ H = ❙¬ Ga) ⟶ F ∈ S ⟶ G ∈ S ∧ H ∈ S) ∧ (F = ❙¬ (❙¬ G) ∧ H = G ⟶ ❙¬ (❙¬ G) ∈ S ⟶ G ∈ S)) ∧ (∀F G H. (F = G ❙∨ H ⟶ G ❙∨ H ∈ S ⟶ G ∈ S ∨ H ∈ S) ∧ ((∃Fa. F = Fa ❙→ H ∧ G = ❙¬ Fa) ⟶ F ∈ S ⟶ G ∈ S ∨ H ∈ S) ∧ ((∃Fa Ga. F = ❙¬ (Fa ❙∧ Ga) ∧ G = ❙¬ Fa ∧ H = ❙¬ Ga) ⟶ F ∈ S ⟶ G ∈ S ∨ H ∈ S) ∧ (F = ❙¬ (❙¬ G) ∧ H = G ⟶ ❙¬ (❙¬ G) ∈ S ⟶ G ∈ S)))›*) subgoal for by blast subgoal for apply safe (*goals: 1. ‹⋀(F::'a formula) G::'a formula. ⟦⊥ ∉ (S::'a formula set); ∀k::'a. Atom k ∈ S ⟶ ❙¬ (Atom k) ∉ S; ∀(F::'a formula) (G::'a formula) H::'a formula. (F = G ❙∧ H ⟶ G ❙∧ H ∈ S ⟶ G ∈ S ∧ H ∈ S) ∧ ((∃(Fa::'a formula) Ga::'a formula. F = ❙¬ (Fa ❙∨ Ga) ∧ G = ❙¬ Fa ∧ H = ❙¬ Ga) ⟶ F ∈ S ⟶ G ∈ S ∧ H ∈ S) ∧ ((∃Ga::'a formula. F = ❙¬ (G ❙→ Ga) ∧ H = ❙¬ Ga) ⟶ F ∈ S ⟶ G ∈ S ∧ H ∈ S) ∧ (F = ❙¬ (❙¬ G) ∧ H = G ⟶ ❙¬ (❙¬ G) ∈ S ⟶ G ∈ S); ∀(F::'a formula) (G::'a formula) H::'a formula. (F = G ❙∨ H ⟶ G ❙∨ H ∈ S ⟶ G ∈ S ∨ H ∈ S) ∧ ((∃Fa::'a formula. F = Fa ❙→ H ∧ G = ❙¬ Fa) ⟶ F ∈ S ⟶ G ∈ S ∨ H ∈ S) ∧ ((∃(Fa::'a formula) Ga::'a formula. F = ❙¬ (Fa ❙∧ Ga) ∧ G = ❙¬ Fa ∧ H = ❙¬ Ga) ⟶ F ∈ S ⟶ G ∈ S ∨ H ∈ S) ∧ (F = ❙¬ (❙¬ G) ∧ H = G ⟶ ❙¬ (❙¬ G) ∈ S ⟶ G ∈ S); F ❙∧ G ∈ S⟧ ⟹ F ∈ S› 2. ‹⋀(F::'a formula) G::'a formula. ⟦⊥ ∉ (S::'a formula set); ∀k::'a. Atom k ∈ S ⟶ ❙¬ (Atom k) ∉ S; ∀(F::'a formula) (G::'a formula) H::'a formula. (F = G ❙∧ H ⟶ G ❙∧ H ∈ S ⟶ G ∈ S ∧ H ∈ S) ∧ ((∃(Fa::'a formula) Ga::'a formula. F = ❙¬ (Fa ❙∨ Ga) ∧ G = ❙¬ Fa ∧ H = ❙¬ Ga) ⟶ F ∈ S ⟶ G ∈ S ∧ H ∈ S) ∧ ((∃Ga::'a formula. F = ❙¬ (G ❙→ Ga) ∧ H = ❙¬ Ga) ⟶ F ∈ S ⟶ G ∈ S ∧ H ∈ S) ∧ (F = ❙¬ (❙¬ G) ∧ H = G ⟶ ❙¬ (❙¬ G) ∈ S ⟶ G ∈ S); ∀(F::'a formula) (G::'a formula) H::'a formula. (F = G ❙∨ H ⟶ G ❙∨ H ∈ S ⟶ G ∈ S ∨ H ∈ S) ∧ ((∃Fa::'a formula. F = Fa ❙→ H ∧ G = ❙¬ Fa) ⟶ F ∈ S ⟶ G ∈ S ∨ H ∈ S) ∧ ((∃(Fa::'a formula) Ga::'a formula. F = ❙¬ (Fa ❙∧ Ga) ∧ G = ❙¬ Fa ∧ H = ❙¬ Ga) ⟶ F ∈ S ⟶ G ∈ S ∨ H ∈ S) ∧ (F = ❙¬ (❙¬ G) ∧ H = G ⟶ ❙¬ (❙¬ G) ∈ S ⟶ G ∈ S); F ❙∧ G ∈ S⟧ ⟹ G ∈ S› 3. ‹⋀(F::'a formula) G::'a formula. ⟦⊥ ∉ (S::'a formula set); ∀k::'a. Atom k ∈ S ⟶ ❙¬ (Atom k) ∉ S; ∀(F::'a formula) (G::'a formula) H::'a formula. (F = G ❙∧ H ⟶ G ❙∧ H ∈ S ⟶ G ∈ S ∧ H ∈ S) ∧ ((∃(Fa::'a formula) Ga::'a formula. F = ❙¬ (Fa ❙∨ Ga) ∧ G = ❙¬ Fa ∧ H = ❙¬ Ga) ⟶ F ∈ S ⟶ G ∈ S ∧ H ∈ S) ∧ ((∃Ga::'a formula. F = ❙¬ (G ❙→ Ga) ∧ H = ❙¬ Ga) ⟶ F ∈ S ⟶ G ∈ S ∧ H ∈ S) ∧ (F = ❙¬ (❙¬ G) ∧ H = G ⟶ ❙¬ (❙¬ G) ∈ S ⟶ G ∈ S); ∀(F::'a formula) (G::'a formula) H::'a formula. (F = G ❙∨ H ⟶ G ❙∨ H ∈ S ⟶ G ∈ S ∨ H ∈ S) ∧ ((∃Fa::'a formula. F = Fa ❙→ H ∧ G = ❙¬ Fa) ⟶ F ∈ S ⟶ G ∈ S ∨ H ∈ S) ∧ ((∃(Fa::'a formula) Ga::'a formula. F = ❙¬ (Fa ❙∧ Ga) ∧ G = ❙¬ Fa ∧ H = ❙¬ Ga) ⟶ F ∈ S ⟶ G ∈ S ∨ H ∈ S) ∧ (F = ❙¬ (❙¬ G) ∧ H = G ⟶ ❙¬ (❙¬ G) ∈ S ⟶ G ∈ S); F ❙∨ G ∈ S; G ∉ S⟧ ⟹ F ∈ S› 4. ‹⋀(F::'a formula) G::'a formula. ⟦⊥ ∉ (S::'a formula set); ∀k::'a. Atom k ∈ S ⟶ ❙¬ (Atom k) ∉ S; ∀(F::'a formula) (G::'a formula) H::'a formula. (F = G ❙∧ H ⟶ G ❙∧ H ∈ S ⟶ G ∈ S ∧ H ∈ S) ∧ ((∃(Fa::'a formula) Ga::'a formula. F = ❙¬ (Fa ❙∨ Ga) ∧ G = ❙¬ Fa ∧ H = ❙¬ Ga) ⟶ F ∈ S ⟶ G ∈ S ∧ H ∈ S) ∧ ((∃Ga::'a formula. F = ❙¬ (G ❙→ Ga) ∧ H = ❙¬ Ga) ⟶ F ∈ S ⟶ G ∈ S ∧ H ∈ S) ∧ (F = ❙¬ (❙¬ G) ∧ H = G ⟶ ❙¬ (❙¬ G) ∈ S ⟶ G ∈ S); ∀(F::'a formula) (G::'a formula) H::'a formula. (F = G ❙∨ H ⟶ G ❙∨ H ∈ S ⟶ G ∈ S ∨ H ∈ S) ∧ ((∃Fa::'a formula. F = Fa ❙→ H ∧ G = ❙¬ Fa) ⟶ F ∈ S ⟶ G ∈ S ∨ H ∈ S) ∧ ((∃(Fa::'a formula) Ga::'a formula. F = ❙¬ (Fa ❙∧ Ga) ∧ G = ❙¬ Fa ∧ H = ❙¬ Ga) ⟶ F ∈ S ⟶ G ∈ S ∨ H ∈ S) ∧ (F = ❙¬ (❙¬ G) ∧ H = G ⟶ ❙¬ (❙¬ G) ∈ S ⟶ G ∈ S); F ❙→ G ∈ S; G ∉ S⟧ ⟹ ❙¬ F ∈ S› 5. ‹⋀F::'a formula. ⟦⊥ ∉ (S::'a formula set); ∀k::'a. Atom k ∈ S ⟶ ❙¬ (Atom k) ∉ S; ∀(F::'a formula) (G::'a formula) H::'a formula. (F = G ❙∧ H ⟶ G ❙∧ H ∈ S ⟶ G ∈ S ∧ H ∈ S) ∧ ((∃(Fa::'a formula) Ga::'a formula. F = ❙¬ (Fa ❙∨ Ga) ∧ G = ❙¬ Fa ∧ H = ❙¬ Ga) ⟶ F ∈ S ⟶ G ∈ S ∧ H ∈ S) ∧ ((∃Ga::'a formula. F = ❙¬ (G ❙→ Ga) ∧ H = ❙¬ Ga) ⟶ F ∈ S ⟶ G ∈ S ∧ H ∈ S) ∧ (F = ❙¬ (❙¬ G) ∧ H = G ⟶ ❙¬ (❙¬ G) ∈ S ⟶ G ∈ S); ∀(F::'a formula) (G::'a formula) H::'a formula. (F = G ❙∨ H ⟶ G ❙∨ H ∈ S ⟶ G ∈ S ∨ H ∈ S) ∧ ((∃Fa::'a formula. F = Fa ❙→ H ∧ G = ❙¬ Fa) ⟶ F ∈ S ⟶ G ∈ S ∨ H ∈ S) ∧ ((∃(Fa::'a formula) Ga::'a formula. F = ❙¬ (Fa ❙∧ Ga) ∧ G = ❙¬ Fa ∧ H = ❙¬ Ga) ⟶ F ∈ S ⟶ G ∈ S ∨ H ∈ S) ∧ (F = ❙¬ (❙¬ G) ∧ H = G ⟶ ❙¬ (❙¬ G) ∈ S ⟶ G ∈ S); ❙¬ (❙¬ F) ∈ S⟧ ⟹ F ∈ S› 6. ‹⋀(F::'a formula) G::'a formula. ⟦⊥ ∉ (S::'a formula set); ∀k::'a. Atom k ∈ S ⟶ ❙¬ (Atom k) ∉ S; ∀(F::'a formula) (G::'a formula) H::'a formula. (F = G ❙∧ H ⟶ G ❙∧ H ∈ S ⟶ G ∈ S ∧ H ∈ S) ∧ ((∃(Fa::'a formula) Ga::'a formula. F = ❙¬ (Fa ❙∨ Ga) ∧ G = ❙¬ Fa ∧ H = ❙¬ Ga) ⟶ F ∈ S ⟶ G ∈ S ∧ H ∈ S) ∧ ((∃Ga::'a formula. F = ❙¬ (G ❙→ Ga) ∧ H = ❙¬ Ga) ⟶ F ∈ S ⟶ G ∈ S ∧ H ∈ S) ∧ (F = ❙¬ (❙¬ G) ∧ H = G ⟶ ❙¬ (❙¬ G) ∈ S ⟶ G ∈ S); ∀(F::'a formula) (G::'a formula) H::'a formula. (F = G ❙∨ H ⟶ G ❙∨ H ∈ S ⟶ G ∈ S ∨ H ∈ S) ∧ ((∃Fa::'a formula. F = Fa ❙→ H ∧ G = ❙¬ Fa) ⟶ F ∈ S ⟶ G ∈ S ∨ H ∈ S) ∧ ((∃(Fa::'a formula) Ga::'a formula. F = ❙¬ (Fa ❙∧ Ga) ∧ G = ❙¬ Fa ∧ H = ❙¬ Ga) ⟶ F ∈ S ⟶ G ∈ S ∨ H ∈ S) ∧ (F = ❙¬ (❙¬ G) ∧ H = G ⟶ ❙¬ (❙¬ G) ∈ S ⟶ G ∈ S); ❙¬ (F ❙∧ G) ∈ S; ❙¬ G ∉ S⟧ ⟹ ❙¬ F ∈ S› 7. ‹⋀(F::'a formula) G::'a formula. ⟦⊥ ∉ (S::'a formula set); ∀k::'a. Atom k ∈ S ⟶ ❙¬ (Atom k) ∉ S; ∀(F::'a formula) (G::'a formula) H::'a formula. (F = G ❙∧ H ⟶ G ❙∧ H ∈ S ⟶ G ∈ S ∧ H ∈ S) ∧ ((∃(Fa::'a formula) Ga::'a formula. F = ❙¬ (Fa ❙∨ Ga) ∧ G = ❙¬ Fa ∧ H = ❙¬ Ga) ⟶ F ∈ S ⟶ G ∈ S ∧ H ∈ S) ∧ ((∃Ga::'a formula. F = ❙¬ (G ❙→ Ga) ∧ H = ❙¬ Ga) ⟶ F ∈ S ⟶ G ∈ S ∧ H ∈ S) ∧ (F = ❙¬ (❙¬ G) ∧ H = G ⟶ ❙¬ (❙¬ G) ∈ S ⟶ G ∈ S); ∀(F::'a formula) (G::'a formula) H::'a formula. (F = G ❙∨ H ⟶ G ❙∨ H ∈ S ⟶ G ∈ S ∨ H ∈ S) ∧ ((∃Fa::'a formula. F = Fa ❙→ H ∧ G = ❙¬ Fa) ⟶ F ∈ S ⟶ G ∈ S ∨ H ∈ S) ∧ ((∃(Fa::'a formula) Ga::'a formula. F = ❙¬ (Fa ❙∧ Ga) ∧ G = ❙¬ Fa ∧ H = ❙¬ Ga) ⟶ F ∈ S ⟶ G ∈ S ∨ H ∈ S) ∧ (F = ❙¬ (❙¬ G) ∧ H = G ⟶ ❙¬ (❙¬ G) ∈ S ⟶ G ∈ S); ❙¬ (F ❙∨ G) ∈ S⟧ ⟹ ❙¬ F ∈ S› 8. ‹⋀(F::'a formula) G::'a formula. ⟦⊥ ∉ (S::'a formula set); ∀k::'a. Atom k ∈ S ⟶ ❙¬ (Atom k) ∉ S; ∀(F::'a formula) (G::'a formula) H::'a formula. (F = G ❙∧ H ⟶ G ❙∧ H ∈ S ⟶ G ∈ S ∧ H ∈ S) ∧ ((∃(Fa::'a formula) Ga::'a formula. F = ❙¬ (Fa ❙∨ Ga) ∧ G = ❙¬ Fa ∧ H = ❙¬ Ga) ⟶ F ∈ S ⟶ G ∈ S ∧ H ∈ S) ∧ ((∃Ga::'a formula. F = ❙¬ (G ❙→ Ga) ∧ H = ❙¬ Ga) ⟶ F ∈ S ⟶ G ∈ S ∧ H ∈ S) ∧ (F = ❙¬ (❙¬ G) ∧ H = G ⟶ ❙¬ (❙¬ G) ∈ S ⟶ G ∈ S); ∀(F::'a formula) (G::'a formula) H::'a formula. (F = G ❙∨ H ⟶ G ❙∨ H ∈ S ⟶ G ∈ S ∨ H ∈ S) ∧ ((∃Fa::'a formula. F = Fa ❙→ H ∧ G = ❙¬ Fa) ⟶ F ∈ S ⟶ G ∈ S ∨ H ∈ S) ∧ ((∃(Fa::'a formula) Ga::'a formula. F = ❙¬ (Fa ❙∧ Ga) ∧ G = ❙¬ Fa ∧ H = ❙¬ Ga) ⟶ F ∈ S ⟶ G ∈ S ∨ H ∈ S) ∧ (F = ❙¬ (❙¬ G) ∧ H = G ⟶ ❙¬ (❙¬ G) ∈ S ⟶ G ∈ S); ❙¬ (F ❙∨ G) ∈ S⟧ ⟹ ❙¬ G ∈ S› 9. ‹⋀(F::'a formula) G::'a formula. ⟦⊥ ∉ (S::'a formula set); ∀k::'a. Atom k ∈ S ⟶ ❙¬ (Atom k) ∉ S; ∀(F::'a formula) (G::'a formula) H::'a formula. (F = G ❙∧ H ⟶ G ❙∧ H ∈ S ⟶ G ∈ S ∧ H ∈ S) ∧ ((∃(Fa::'a formula) Ga::'a formula. F = ❙¬ (Fa ❙∨ Ga) ∧ G = ❙¬ Fa ∧ H = ❙¬ Ga) ⟶ F ∈ S ⟶ G ∈ S ∧ H ∈ S) ∧ ((∃Ga::'a formula. F = ❙¬ (G ❙→ Ga) ∧ H = ❙¬ Ga) ⟶ F ∈ S ⟶ G ∈ S ∧ H ∈ S) ∧ (F = ❙¬ (❙¬ G) ∧ H = G ⟶ ❙¬ (❙¬ G) ∈ S ⟶ G ∈ S); ∀(F::'a formula) (G::'a formula) H::'a formula. (F = G ❙∨ H ⟶ G ❙∨ H ∈ S ⟶ G ∈ S ∨ H ∈ S) ∧ ((∃Fa::'a formula. F = Fa ❙→ H ∧ G = ❙¬ Fa) ⟶ F ∈ S ⟶ G ∈ S ∨ H ∈ S) ∧ ((∃(Fa::'a formula) Ga::'a formula. F = ❙¬ (Fa ❙∧ Ga) ∧ G = ❙¬ Fa ∧ H = ❙¬ Ga) ⟶ F ∈ S ⟶ G ∈ S ∨ H ∈ S) ∧ (F = ❙¬ (❙¬ G) ∧ H = G ⟶ ❙¬ (❙¬ G) ∈ S ⟶ G ∈ S); ❙¬ (F ❙→ G) ∈ S⟧ ⟹ F ∈ S› 10. ‹⋀(F::'a formula) G::'a formula. ⟦⊥ ∉ (S::'a formula set); ∀k::'a. Atom k ∈ S ⟶ ❙¬ (Atom k) ∉ S; ∀(F::'a formula) (G::'a formula) H::'a formula. (F = G ❙∧ H ⟶ G ❙∧ H ∈ S ⟶ G ∈ S ∧ H ∈ S) ∧ ((∃(Fa::'a formula) Ga::'a formula. F = ❙¬ (Fa ❙∨ Ga) ∧ G = ❙¬ Fa ∧ H = ❙¬ Ga) ⟶ F ∈ S ⟶ G ∈ S ∧ H ∈ S) ∧ ((∃Ga::'a formula. F = ❙¬ (G ❙→ Ga) ∧ H = ❙¬ Ga) ⟶ F ∈ S ⟶ G ∈ S ∧ H ∈ S) ∧ (F = ❙¬ (❙¬ G) ∧ H = G ⟶ ❙¬ (❙¬ G) ∈ S ⟶ G ∈ S); ∀(F::'a formula) (G::'a formula) H::'a formula. (F = G ❙∨ H ⟶ G ❙∨ H ∈ S ⟶ G ∈ S ∨ H ∈ S) ∧ ((∃Fa::'a formula. F = Fa ❙→ H ∧ G = ❙¬ Fa) ⟶ F ∈ S ⟶ G ∈ S ∨ H ∈ S) ∧ ((∃(Fa::'a formula) Ga::'a formula. F = ❙¬ (Fa ❙∧ Ga) ∧ G = ❙¬ Fa ∧ H = ❙¬ Ga) ⟶ F ∈ S ⟶ G ∈ S ∨ H ∈ S) ∧ (F = ❙¬ (❙¬ G) ∧ H = G ⟶ ❙¬ (❙¬ G) ∈ S ⟶ G ∈ S); ❙¬ (F ❙→ G) ∈ S⟧ ⟹ ❙¬ G ∈ S› 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 (*discuss goal 6*) apply metis (*discuss goal 7*) apply metis (*discuss goal 8*) apply metis (*discuss goal 9*) apply metis (*discuss goal 10*) apply metis (*proven 10 subgoals*) . . lemma pcp_alt: "pcp C = (∀S ∈ C. ⊥ ∉ S ∧ (∀k. Atom k ∈ S ⟶ ❙¬ (Atom k) ∈ S ⟶ False) ∧ (∀F G H. Con F G H ⟶ F ∈ S ⟶ G ▹ H ▹ S ∈ C) ∧ (∀F G H. Dis F G H ⟶ F ∈ S ⟶ G ▹ S ∈ C ∨ H ▹ S ∈ C) )" apply (simp add: pcp_def (*‹pcp ?C ≡ ∀S∈?C. ⊥ ∉ S ∧ (∀k. Atom k ∈ S ⟶ ❙¬ (Atom k) ∈ S ⟶ False) ∧ (∀F G. F ❙∧ G ∈ S ⟶ F ▹ G ▹ S ∈ ?C) ∧ (∀F G. F ❙∨ G ∈ S ⟶ F ▹ S ∈ ?C ∨ G ▹ S ∈ ?C) ∧ (∀F G. F ❙→ G ∈ S ⟶ ❙¬ F ▹ S ∈ ?C ∨ G ▹ S ∈ ?C) ∧ (∀F. ❙¬ (❙¬ F) ∈ S ⟶ F ▹ S ∈ ?C) ∧ (∀F G. ❙¬ (F ❙∧ G) ∈ S ⟶ ❙¬ F ▹ S ∈ ?C ∨ ❙¬ G ▹ S ∈ ?C) ∧ (∀F G. ❙¬ (F ❙∨ G) ∈ S ⟶ ❙¬ F ▹ ❙¬ G ▹ S ∈ ?C) ∧ (∀F G. ❙¬ (F ❙→ G) ∈ S ⟶ F ▹ ❙¬ G ▹ S ∈ ?C)›*) con_dis_simps (*‹Con ?a1.0 ?a2.0 ?a3.0 = (?a1.0 = ?a2.0 ❙∧ ?a3.0 ∨ (∃F G. ?a1.0 = ❙¬ (F ❙∨ G) ∧ ?a2.0 = ❙¬ F ∧ ?a3.0 = ❙¬ G) ∨ (∃G. ?a1.0 = ❙¬ (?a2.0 ❙→ G) ∧ ?a3.0 = ❙¬ G) ∨ ?a1.0 = ❙¬ (❙¬ ?a2.0) ∧ ?a3.0 = ?a2.0)› ‹Dis ?a1.0 ?a2.0 ?a3.0 = (?a1.0 = ?a2.0 ❙∨ ?a3.0 ∨ (∃F G. ?a1.0 = F ❙→ G ∧ ?a2.0 = ❙¬ F ∧ ?a3.0 = G) ∨ (∃F G. ?a1.0 = ❙¬ (F ❙∧ G) ∧ ?a2.0 = ❙¬ F ∧ ?a3.0 = ❙¬ G) ∨ ?a1.0 = ❙¬ (❙¬ ?a2.0) ∧ ?a3.0 = ?a2.0)›*)) (*goal: ‹pcp C = (∀S∈C. ⊥ ∉ S ∧ (∀k. Atom k ∈ S ⟶ ❙¬ (Atom k) ∈ S ⟶ False) ∧ (∀F G H. Con F G H ⟶ F ∈ S ⟶ G ▹ H ▹ S ∈ C) ∧ (∀F G H. Dis F G H ⟶ F ∈ S ⟶ G ▹ S ∈ C ∨ H ▹ S ∈ C))›*) apply (rule iffI (*‹⟦?P ⟹ ?Q; ?Q ⟹ ?P⟧ ⟹ ?P = ?Q›*)) (*goals: 1. ‹∀S∈C. ⊥ ∉ S ∧ (∀k. Atom k ∈ S ⟶ ❙¬ (Atom k) ∉ S) ∧ (∀F G. F ❙∧ G ∈ S ⟶ F ▹ G ▹ S ∈ C) ∧ (∀F G. F ❙∨ G ∈ S ⟶ F ▹ S ∈ C ∨ G ▹ S ∈ C) ∧ (∀F G. F ❙→ G ∈ S ⟶ ❙¬ F ▹ S ∈ C ∨ G ▹ S ∈ C) ∧ (∀F. ❙¬ (❙¬ F) ∈ S ⟶ F ▹ S ∈ C) ∧ (∀F G. ❙¬ (F ❙∧ G) ∈ S ⟶ ❙¬ F ▹ S ∈ C ∨ ❙¬ G ▹ S ∈ C) ∧ (∀F G. ❙¬ (F ❙∨ G) ∈ S ⟶ ❙¬ F ▹ ❙¬ G ▹ S ∈ C) ∧ (∀F G. ❙¬ (F ❙→ G) ∈ S ⟶ F ▹ ❙¬ G ▹ S ∈ C) ⟹ ∀S∈C. ⊥ ∉ S ∧ (∀k. Atom k ∈ S ⟶ ❙¬ (Atom k) ∉ S) ∧ (∀F G H. (F = G ❙∧ H ⟶ G ❙∧ H ∈ S ⟶ G ▹ H ▹ S ∈ C) ∧ ((∃Fa Ga. F = ❙¬ (Fa ❙∨ Ga) ∧ G = ❙¬ Fa ∧ H = ❙¬ Ga) ⟶ F ∈ S ⟶ G ▹ H ▹ S ∈ C) ∧ ((∃Ga. F = ❙¬ (G ❙→ Ga) ∧ H = ❙¬ Ga) ⟶ F ∈ S ⟶ G ▹ H ▹ S ∈ C) ∧ (F = ❙¬ (❙¬ G) ∧ H = G ⟶ ❙¬ (❙¬ G) ∈ S ⟶ G ▹ S ∈ C)) ∧ (∀F G H. (F = G ❙∨ H ⟶ G ❙∨ H ∈ S ⟶ G ▹ S ∈ C ∨ H ▹ S ∈ C) ∧ ((∃Fa. F = Fa ❙→ H ∧ G = ❙¬ Fa) ⟶ F ∈ S ⟶ G ▹ S ∈ C ∨ H ▹ S ∈ C) ∧ ((∃Fa Ga. F = ❙¬ (Fa ❙∧ Ga) ∧ G = ❙¬ Fa ∧ H = ❙¬ Ga) ⟶ F ∈ S ⟶ G ▹ S ∈ C ∨ H ▹ S ∈ C) ∧ (F = ❙¬ (❙¬ G) ∧ H = G ⟶ ❙¬ (❙¬ G) ∈ S ⟶ G ▹ S ∈ C))› 2. ‹∀S∈C. ⊥ ∉ S ∧ (∀k. Atom k ∈ S ⟶ ❙¬ (Atom k) ∉ S) ∧ (∀F G H. (F = G ❙∧ H ⟶ G ❙∧ H ∈ S ⟶ G ▹ H ▹ S ∈ C) ∧ ((∃Fa Ga. F = ❙¬ (Fa ❙∨ Ga) ∧ G = ❙¬ Fa ∧ H = ❙¬ Ga) ⟶ F ∈ S ⟶ G ▹ H ▹ S ∈ C) ∧ ((∃Ga. F = ❙¬ (G ❙→ Ga) ∧ H = ❙¬ Ga) ⟶ F ∈ S ⟶ G ▹ H ▹ S ∈ C) ∧ (F = ❙¬ (❙¬ G) ∧ H = G ⟶ ❙¬ (❙¬ G) ∈ S ⟶ G ▹ S ∈ C)) ∧ (∀F G H. (F = G ❙∨ H ⟶ G ❙∨ H ∈ S ⟶ G ▹ S ∈ C ∨ H ▹ S ∈ C) ∧ ((∃Fa. F = Fa ❙→ H ∧ G = ❙¬ Fa) ⟶ F ∈ S ⟶ G ▹ S ∈ C ∨ H ▹ S ∈ C) ∧ ((∃Fa Ga. F = ❙¬ (Fa ❙∧ Ga) ∧ G = ❙¬ Fa ∧ H = ❙¬ Ga) ⟶ F ∈ S ⟶ G ▹ S ∈ C ∨ H ▹ S ∈ C) ∧ (F = ❙¬ (❙¬ G) ∧ H = G ⟶ ❙¬ (❙¬ G) ∈ S ⟶ G ▹ S ∈ C)) ⟹ ∀S∈C. ⊥ ∉ S ∧ (∀k. Atom k ∈ S ⟶ ❙¬ (Atom k) ∉ S) ∧ (∀F G. F ❙∧ G ∈ S ⟶ F ▹ G ▹ S ∈ C) ∧ (∀F G. F ❙∨ G ∈ S ⟶ F ▹ S ∈ C ∨ G ▹ S ∈ C) ∧ (∀F G. F ❙→ G ∈ S ⟶ ❙¬ F ▹ S ∈ C ∨ G ▹ S ∈ C) ∧ (∀F. ❙¬ (❙¬ F) ∈ S ⟶ F ▹ S ∈ C) ∧ (∀F G. ❙¬ (F ❙∧ G) ∈ S ⟶ ❙¬ F ▹ S ∈ C ∨ ❙¬ G ▹ S ∈ C) ∧ (∀F G. ❙¬ (F ❙∨ G) ∈ S ⟶ ❙¬ F ▹ ❙¬ G ▹ S ∈ C) ∧ (∀F G. ❙¬ (F ❙→ G) ∈ S ⟶ F ▹ ❙¬ G ▹ S ∈ C)› discuss goal 1*) apply ((unfold Ball_def (*‹Ball ?A ?P = (∀x. x ∈ ?A ⟶ ?P x)›*))[1]) (*top goal: ‹∀S∈C. ⊥ ∉ S ∧ (∀k. Atom k ∈ S ⟶ ❙¬ (Atom k) ∉ S) ∧ (∀F G. F ❙∧ G ∈ S ⟶ F ▹ G ▹ S ∈ C) ∧ (∀F G. F ❙∨ G ∈ S ⟶ F ▹ S ∈ C ∨ G ▹ S ∈ C) ∧ (∀F G. F ❙→ G ∈ S ⟶ ❙¬ F ▹ S ∈ C ∨ G ▹ S ∈ C) ∧ (∀F. ❙¬ (❙¬ F) ∈ S ⟶ F ▹ S ∈ C) ∧ (∀F G. ❙¬ (F ❙∧ G) ∈ S ⟶ ❙¬ F ▹ S ∈ C ∨ ❙¬ G ▹ S ∈ C) ∧ (∀F G. ❙¬ (F ❙∨ G) ∈ S ⟶ ❙¬ F ▹ ❙¬ G ▹ S ∈ C) ∧ (∀F G. ❙¬ (F ❙→ G) ∈ S ⟶ F ▹ ❙¬ G ▹ S ∈ C) ⟹ ∀S∈C. ⊥ ∉ S ∧ (∀k. Atom k ∈ S ⟶ ❙¬ (Atom k) ∉ S) ∧ (∀F G H. (F = G ❙∧ H ⟶ G ❙∧ H ∈ S ⟶ G ▹ H ▹ S ∈ C) ∧ ((∃Fa Ga. F = ❙¬ (Fa ❙∨ Ga) ∧ G = ❙¬ Fa ∧ H = ❙¬ Ga) ⟶ F ∈ S ⟶ G ▹ H ▹ S ∈ C) ∧ ((∃Ga. F = ❙¬ (G ❙→ Ga) ∧ H = ❙¬ Ga) ⟶ F ∈ S ⟶ G ▹ H ▹ S ∈ C) ∧ (F = ❙¬ (❙¬ G) ∧ H = G ⟶ ❙¬ (❙¬ G) ∈ S ⟶ G ▹ S ∈ C)) ∧ (∀F G H. (F = G ❙∨ H ⟶ G ❙∨ H ∈ S ⟶ G ▹ S ∈ C ∨ H ▹ S ∈ C) ∧ ((∃Fa. F = Fa ❙→ H ∧ G = ❙¬ Fa) ⟶ F ∈ S ⟶ G ▹ S ∈ C ∨ H ▹ S ∈ C) ∧ ((∃Fa Ga. F = ❙¬ (Fa ❙∧ Ga) ∧ G = ❙¬ Fa ∧ H = ❙¬ Ga) ⟶ F ∈ S ⟶ G ▹ S ∈ C ∨ H ▹ S ∈ C) ∧ (F = ❙¬ (❙¬ G) ∧ H = G ⟶ ❙¬ (❙¬ G) ∈ S ⟶ G ▹ S ∈ C))› and 1 goal remains*) apply ((elim all_forward (*‹⟦∀x. ?P' x; ⋀x. ?P' x ⟹ ?P x⟧ ⟹ ∀x. ?P x›*))[1]) (*top goal: ‹∀x. x ∈ C ⟶ ⊥ ∉ x ∧ (∀k. Atom k ∈ x ⟶ ❙¬ (Atom k) ∉ x) ∧ (∀F G. F ❙∧ G ∈ x ⟶ F ▹ G ▹ x ∈ C) ∧ (∀F G. F ❙∨ G ∈ x ⟶ F ▹ x ∈ C ∨ G ▹ x ∈ C) ∧ (∀F G. F ❙→ G ∈ x ⟶ ❙¬ F ▹ x ∈ C ∨ G ▹ x ∈ C) ∧ (∀F. ❙¬ (❙¬ F) ∈ x ⟶ F ▹ x ∈ C) ∧ (∀F G. ❙¬ (F ❙∧ G) ∈ x ⟶ ❙¬ F ▹ x ∈ C ∨ ❙¬ G ▹ x ∈ C) ∧ (∀F G. ❙¬ (F ❙∨ G) ∈ x ⟶ ❙¬ F ▹ ❙¬ G ▹ x ∈ C) ∧ (∀F G. ❙¬ (F ❙→ G) ∈ x ⟶ F ▹ ❙¬ G ▹ x ∈ C) ⟹ ∀x. x ∈ C ⟶ ⊥ ∉ x ∧ (∀k. Atom k ∈ x ⟶ ❙¬ (Atom k) ∉ x) ∧ (∀F G H. (F = G ❙∧ H ⟶ G ❙∧ H ∈ x ⟶ G ▹ H ▹ x ∈ C) ∧ ((∃Fa Ga. F = ❙¬ (Fa ❙∨ Ga) ∧ G = ❙¬ Fa ∧ H = ❙¬ Ga) ⟶ F ∈ x ⟶ G ▹ H ▹ x ∈ C) ∧ ((∃Ga. F = ❙¬ (G ❙→ Ga) ∧ H = ❙¬ Ga) ⟶ F ∈ x ⟶ G ▹ H ▹ x ∈ C) ∧ (F = ❙¬ (❙¬ G) ∧ H = G ⟶ ❙¬ (❙¬ G) ∈ x ⟶ G ▹ x ∈ C)) ∧ (∀F G H. (F = G ❙∨ H ⟶ G ❙∨ H ∈ x ⟶ G ▹ x ∈ C ∨ H ▹ x ∈ C) ∧ ((∃Fa. F = Fa ❙→ H ∧ G = ❙¬ Fa) ⟶ F ∈ x ⟶ G ▹ x ∈ C ∨ H ▹ x ∈ C) ∧ ((∃Fa Ga. F = ❙¬ (Fa ❙∧ Ga) ∧ G = ❙¬ Fa ∧ H = ❙¬ Ga) ⟶ F ∈ x ⟶ G ▹ x ∈ C ∨ H ▹ x ∈ C) ∧ (F = ❙¬ (❙¬ G) ∧ H = G ⟶ ❙¬ (❙¬ G) ∈ x ⟶ G ▹ x ∈ C))› and 1 goal remains*) apply ((auto simp add: insert_absorb (*‹?a ∈ ?A ⟹ ?a ▹ ?A = ?A›*) split: formula.splits (*‹?P (case ?formula of Atom x ⇒ ?f1.0 x | ⊥ ⇒ ?f2.0 | ❙¬ x ⇒ ?f3.0 x | x ❙∧ xa ⇒ ?f4.0 x xa | x ❙∨ xa ⇒ ?f5.0 x xa | x ❙→ xa ⇒ ?f6.0 x xa) = ((∀x1. ?formula = Atom x1 ⟶ ?P (?f1.0 x1)) ∧ (?formula = ⊥ ⟶ ?P ?f2.0) ∧ (∀x3. ?formula = ❙¬ x3 ⟶ ?P (?f3.0 x3)) ∧ (∀x41 x42. ?formula = x41 ❙∧ x42 ⟶ ?P (?f4.0 x41 x42)) ∧ (∀x51 x52. ?formula = x51 ❙∨ x52 ⟶ ?P (?f5.0 x51 x52)) ∧ (∀x61 x62. ?formula = x61 ❙→ x62 ⟶ ?P (?f6.0 x61 x62)))› ‹?P (case ?formula of Atom x ⇒ ?f1.0 x | ⊥ ⇒ ?f2.0 | ❙¬ x ⇒ ?f3.0 x | x ❙∧ xa ⇒ ?f4.0 x xa | x ❙∨ xa ⇒ ?f5.0 x xa | x ❙→ xa ⇒ ?f6.0 x xa) = (¬ ((∃x1. ?formula = Atom x1 ∧ ¬ ?P (?f1.0 x1)) ∨ ?formula = ⊥ ∧ ¬ ?P ?f2.0 ∨ (∃x3. ?formula = ❙¬ x3 ∧ ¬ ?P (?f3.0 x3)) ∨ (∃x41 x42. ?formula = x41 ❙∧ x42 ∧ ¬ ?P (?f4.0 x41 x42)) ∨ (∃x51 x52. ?formula = x51 ❙∨ x52 ∧ ¬ ?P (?f5.0 x51 x52)) ∨ (∃x61 x62. ?formula = x61 ❙→ x62 ∧ ¬ ?P (?f6.0 x61 x62))))›*))[1]) (*discuss goal 2*) apply ((unfold Ball_def (*‹Ball ?A ?P = (∀x. x ∈ ?A ⟶ ?P x)›*))[1]) (*goal: ‹∀S∈C. ⊥ ∉ S ∧ (∀k. Atom k ∈ S ⟶ ❙¬ (Atom k) ∉ S) ∧ (∀F G H. (F = G ❙∧ H ⟶ G ❙∧ H ∈ S ⟶ G ▹ H ▹ S ∈ C) ∧ ((∃Fa Ga. F = ❙¬ (Fa ❙∨ Ga) ∧ G = ❙¬ Fa ∧ H = ❙¬ Ga) ⟶ F ∈ S ⟶ G ▹ H ▹ S ∈ C) ∧ ((∃Ga. F = ❙¬ (G ❙→ Ga) ∧ H = ❙¬ Ga) ⟶ F ∈ S ⟶ G ▹ H ▹ S ∈ C) ∧ (F = ❙¬ (❙¬ G) ∧ H = G ⟶ ❙¬ (❙¬ G) ∈ S ⟶ G ▹ S ∈ C)) ∧ (∀F G H. (F = G ❙∨ H ⟶ G ❙∨ H ∈ S ⟶ G ▹ S ∈ C ∨ H ▹ S ∈ C) ∧ ((∃Fa. F = Fa ❙→ H ∧ G = ❙¬ Fa) ⟶ F ∈ S ⟶ G ▹ S ∈ C ∨ H ▹ S ∈ C) ∧ ((∃Fa Ga. F = ❙¬ (Fa ❙∧ Ga) ∧ G = ❙¬ Fa ∧ H = ❙¬ Ga) ⟶ F ∈ S ⟶ G ▹ S ∈ C ∨ H ▹ S ∈ C) ∧ (F = ❙¬ (❙¬ G) ∧ H = G ⟶ ❙¬ (❙¬ G) ∈ S ⟶ G ▹ S ∈ C)) ⟹ ∀S∈C. ⊥ ∉ S ∧ (∀k. Atom k ∈ S ⟶ ❙¬ (Atom k) ∉ S) ∧ (∀F G. F ❙∧ G ∈ S ⟶ F ▹ G ▹ S ∈ C) ∧ (∀F G. F ❙∨ G ∈ S ⟶ F ▹ S ∈ C ∨ G ▹ S ∈ C) ∧ (∀F G. F ❙→ G ∈ S ⟶ ❙¬ F ▹ S ∈ C ∨ G ▹ S ∈ C) ∧ (∀F. ❙¬ (❙¬ F) ∈ S ⟶ F ▹ S ∈ C) ∧ (∀F G. ❙¬ (F ❙∧ G) ∈ S ⟶ ❙¬ F ▹ S ∈ C ∨ ❙¬ G ▹ S ∈ C) ∧ (∀F G. ❙¬ (F ❙∨ G) ∈ S ⟶ ❙¬ F ▹ ❙¬ G ▹ S ∈ C) ∧ (∀F G. ❙¬ (F ❙→ G) ∈ S ⟶ F ▹ ❙¬ G ▹ S ∈ C)›*) apply ((elim all_forward (*‹⟦∀x. ?P' x; ⋀x. ?P' x ⟹ ?P x⟧ ⟹ ∀x. ?P x›*))[1]) (*goal: ‹∀x::'a formula set. x ∈ (C::'a formula set set) ⟶ ⊥ ∉ x ∧ (∀k::'a. Atom k ∈ x ⟶ ❙¬ (Atom k) ∉ x) ∧ (∀(F::'a formula) (G::'a formula) H::'a formula. (F = G ❙∧ H ⟶ G ❙∧ H ∈ x ⟶ G ▹ H ▹ x ∈ C) ∧ ((∃(Fa::'a formula) Ga::'a formula. F = ❙¬ (Fa ❙∨ Ga) ∧ G = ❙¬ Fa ∧ H = ❙¬ Ga) ⟶ F ∈ x ⟶ G ▹ H ▹ x ∈ C) ∧ ((∃Ga::'a formula. F = ❙¬ (G ❙→ Ga) ∧ H = ❙¬ Ga) ⟶ F ∈ x ⟶ G ▹ H ▹ x ∈ C) ∧ (F = ❙¬ (❙¬ G) ∧ H = G ⟶ ❙¬ (❙¬ G) ∈ x ⟶ G ▹ x ∈ C)) ∧ (∀(F::'a formula) (G::'a formula) H::'a formula. (F = G ❙∨ H ⟶ G ❙∨ H ∈ x ⟶ G ▹ x ∈ C ∨ H ▹ x ∈ C) ∧ ((∃Fa::'a formula. F = Fa ❙→ H ∧ G = ❙¬ Fa) ⟶ F ∈ x ⟶ G ▹ x ∈ C ∨ H ▹ x ∈ C) ∧ ((∃(Fa::'a formula) Ga::'a formula. F = ❙¬ (Fa ❙∧ Ga) ∧ G = ❙¬ Fa ∧ H = ❙¬ Ga) ⟶ F ∈ x ⟶ G ▹ x ∈ C ∨ H ▹ x ∈ C) ∧ (F = ❙¬ (❙¬ G) ∧ H = G ⟶ ❙¬ (❙¬ G) ∈ x ⟶ G ▹ x ∈ C)) ⟹ ∀x::'a formula set. x ∈ C ⟶ ⊥ ∉ x ∧ (∀k::'a. Atom k ∈ x ⟶ ❙¬ (Atom k) ∉ x) ∧ (∀(F::'a formula) G::'a formula. F ❙∧ G ∈ x ⟶ F ▹ G ▹ x ∈ C) ∧ (∀(F::'a formula) G::'a formula. F ❙∨ G ∈ x ⟶ F ▹ x ∈ C ∨ G ▹ x ∈ C) ∧ (∀(F::'a formula) G::'a formula. F ❙→ G ∈ x ⟶ ❙¬ F ▹ x ∈ C ∨ G ▹ x ∈ C) ∧ (∀F::'a formula. ❙¬ (❙¬ F) ∈ x ⟶ F ▹ x ∈ C) ∧ (∀(F::'a formula) G::'a formula. ❙¬ (F ❙∧ G) ∈ x ⟶ ❙¬ F ▹ x ∈ C ∨ ❙¬ G ▹ x ∈ C) ∧ (∀(F::'a formula) G::'a formula. ❙¬ (F ❙∨ G) ∈ x ⟶ ❙¬ F ▹ ❙¬ G ▹ x ∈ C) ∧ (∀(F::'a formula) G::'a formula. ❙¬ (F ❙→ G) ∈ x ⟶ F ▹ ❙¬ G ▹ x ∈ C)›*) apply ((auto simp add: insert_absorb (*‹?a ∈ ?A ⟹ ?a ▹ ?A = ?A›*) split: formula.splits (*‹?P (case ?formula of Atom x ⇒ ?f1.0 x | ⊥ ⇒ ?f2.0 | ❙¬ x ⇒ ?f3.0 x | x ❙∧ xa ⇒ ?f4.0 x xa | x ❙∨ xa ⇒ ?f5.0 x xa | x ❙→ xa ⇒ ?f6.0 x xa) = ((∀x1. ?formula = Atom x1 ⟶ ?P (?f1.0 x1)) ∧ (?formula = ⊥ ⟶ ?P ?f2.0) ∧ (∀x3. ?formula = ❙¬ x3 ⟶ ?P (?f3.0 x3)) ∧ (∀x41 x42. ?formula = x41 ❙∧ x42 ⟶ ?P (?f4.0 x41 x42)) ∧ (∀x51 x52. ?formula = x51 ❙∨ x52 ⟶ ?P (?f5.0 x51 x52)) ∧ (∀x61 x62. ?formula = x61 ❙→ x62 ⟶ ?P (?f6.0 x61 x62)))› ‹?P (case ?formula of Atom x ⇒ ?f1.0 x | ⊥ ⇒ ?f2.0 | ❙¬ x ⇒ ?f3.0 x | x ❙∧ xa ⇒ ?f4.0 x xa | x ❙∨ xa ⇒ ?f5.0 x xa | x ❙→ xa ⇒ ?f6.0 x xa) = (¬ ((∃x1. ?formula = Atom x1 ∧ ¬ ?P (?f1.0 x1)) ∨ ?formula = ⊥ ∧ ¬ ?P ?f2.0 ∨ (∃x3. ?formula = ❙¬ x3 ∧ ¬ ?P (?f3.0 x3)) ∨ (∃x41 x42. ?formula = x41 ❙∧ x42 ∧ ¬ ?P (?f4.0 x41 x42)) ∨ (∃x51 x52. ?formula = x51 ❙∨ x52 ∧ ¬ ?P (?f5.0 x51 x52)) ∨ (∃x61 x62. ?formula = x61 ❙→ x62 ∧ ¬ ?P (?f6.0 x61 x62))))›*))[1]) (*proven 2 subgoals*) . definition "subset_closed C ≡ (∀S ∈ C. ∀s⊆S. s ∈ C)" definition "finite_character C ≡ (∀S. S ∈ C ⟷ (∀s ⊆ S. finite s ⟶ s ∈ C))" lemma ex1: "pcp C ⟹ ∃C'. C ⊆ C' ∧ pcp C' ∧ subset_closed C'" proof (intro exI[of _ "{s . ∃S ∈ C. s ⊆ S}"] (*‹?P {s. ∃S∈C. s ⊆ S} ⟹ ∃x. ?P x›*) conjI (*‹⟦?P; ?Q⟧ ⟹ ?P ∧ ?Q›*)) (*goals: 1. ‹pcp C ⟹ C ⊆ {s. ∃S∈C. s ⊆ S}› 2. ‹pcp C ⟹ pcp {s. ∃S∈C. s ⊆ S}› 3. ‹pcp C ⟹ subset_closed {s. ∃S∈C. s ⊆ S}›*) let ?E = "{s. ∃S∈C. s ⊆ S}" show "C ⊆ ?E" by blast show "subset_closed ?E" unfolding subset_closed_def (*goal: ‹∀S∈{s. Bex C ((⊆) s)}. ∀s⊆S. s ∈ {s. Bex C ((⊆) s)}›*) by blast assume C: "pcp C" (*‹pcp (C::'a formula set set)›*) show "pcp ?E" using C (*‹pcp C›*) unfolding pcp_alt (*goal: ‹∀S∈{s. Bex C ((⊆) s)}. ⊥ ∉ S ∧ (∀k. Atom k ∈ S ⟶ ❙¬ (Atom k) ∈ S ⟶ False) ∧ (∀F G H. Con F G H ⟶ F ∈ S ⟶ G ▹ H ▹ S ∈ {s. Bex C ((⊆) s)}) ∧ (∀F G H. Dis F G H ⟶ F ∈ S ⟶ G ▹ S ∈ {s. Bex C ((⊆) s)} ∨ H ▹ S ∈ {s. Bex C ((⊆) s)})›*) apply (intro ballI (*‹(⋀x. x ∈ ?A ⟹ ?P x) ⟹ ∀x∈?A. ?P x›*) conjI (*‹⟦?P; ?Q⟧ ⟹ ?P ∧ ?Q›*)) (*goals: 1. ‹⋀S. ⟦∀S∈C. ⊥ ∉ S ∧ (∀k. Atom k ∈ S ⟶ ❙¬ (Atom k) ∈ S ⟶ False) ∧ (∀F G H. Con F G H ⟶ F ∈ S ⟶ G ▹ H ▹ S ∈ C) ∧ (∀F G H. Dis F G H ⟶ F ∈ S ⟶ G ▹ S ∈ C ∨ H ▹ S ∈ C); S ∈ {s. Bex C ((⊆) s)}⟧ ⟹ ⊥ ∉ S› 2. ‹⋀S. ⟦∀S∈C. ⊥ ∉ S ∧ (∀k. Atom k ∈ S ⟶ ❙¬ (Atom k) ∈ S ⟶ False) ∧ (∀F G H. Con F G H ⟶ F ∈ S ⟶ G ▹ H ▹ S ∈ C) ∧ (∀F G H. Dis F G H ⟶ F ∈ S ⟶ G ▹ S ∈ C ∨ H ▹ S ∈ C); S ∈ {s. Bex C ((⊆) s)}⟧ ⟹ ∀k. Atom k ∈ S ⟶ ❙¬ (Atom k) ∈ S ⟶ False› 3. ‹⋀S. ⟦∀S∈C. ⊥ ∉ S ∧ (∀k. Atom k ∈ S ⟶ ❙¬ (Atom k) ∈ S ⟶ False) ∧ (∀F G H. Con F G H ⟶ F ∈ S ⟶ G ▹ H ▹ S ∈ C) ∧ (∀F G H. Dis F G H ⟶ F ∈ S ⟶ G ▹ S ∈ C ∨ H ▹ S ∈ C); S ∈ {s. Bex C ((⊆) s)}⟧ ⟹ ∀F G H. Con F G H ⟶ F ∈ S ⟶ G ▹ H ▹ S ∈ {s. Bex C ((⊆) s)}› 4. ‹⋀S. ⟦∀S∈C. ⊥ ∉ S ∧ (∀k. Atom k ∈ S ⟶ ❙¬ (Atom k) ∈ S ⟶ False) ∧ (∀F G H. Con F G H ⟶ F ∈ S ⟶ G ▹ H ▹ S ∈ C) ∧ (∀F G H. Dis F G H ⟶ F ∈ S ⟶ G ▹ S ∈ C ∨ H ▹ S ∈ C); S ∈ {s. Bex C ((⊆) s)}⟧ ⟹ ∀F G H. Dis F G H ⟶ F ∈ S ⟶ G ▹ S ∈ {s. Bex C ((⊆) s)} ∨ H ▹ S ∈ {s. Bex C ((⊆) s)}› discuss goal 1*) apply simp (*top goal: ‹⋀S::'a formula set. ⟦∀S::'a formula set∈C::'a formula set set. ⊥ ∉ S ∧ (∀k::'a. Atom k ∈ S ⟶ ❙¬ (Atom k) ∈ S ⟶ False) ∧ (∀(F::'a formula) (G::'a formula) H::'a formula. Con F G H ⟶ F ∈ S ⟶ G ▹ H ▹ S ∈ C) ∧ (∀(F::'a formula) (G::'a formula) H::'a formula. Dis F G H ⟶ F ∈ S ⟶ G ▹ S ∈ C ∨ H ▹ S ∈ C); S ∈ {s::'a formula set. Bex C ((⊆) s)}⟧ ⟹ ⊥ ∉ S› and 3 goals remain*) apply (meson insertI1 (*‹?a ∈ ?a ▹ ?B›*) rev_subsetD (*‹⟦?c ∈ ?A; ?A ⊆ ?B⟧ ⟹ ?c ∈ ?B›*) subset_insertI (*‹?B ⊆ ?a ▹ ?B›*) subset_insertI2 (*‹?A ⊆ ?B ⟹ ?A ⊆ ?b ▹ ?B›*)) (*discuss goal 2*) apply simp (*top goal: ‹⋀S. ⟦∀S∈C. ⊥ ∉ S ∧ (∀k. Atom k ∈ S ⟶ ❙¬ (Atom k) ∈ S ⟶ False) ∧ (∀F G H. Con F G H ⟶ F ∈ S ⟶ G ▹ H ▹ S ∈ C) ∧ (∀F G H. Dis F G H ⟶ F ∈ S ⟶ G ▹ S ∈ C ∨ H ▹ S ∈ C); S ∈ {s. Bex C ((⊆) s)}⟧ ⟹ ∀k. Atom k ∈ S ⟶ ❙¬ (Atom k) ∈ S ⟶ False› and 2 goals remain*) apply (meson insertI1 (*‹?a ∈ ?a ▹ ?B›*) rev_subsetD (*‹⟦?c ∈ ?A; ?A ⊆ ?B⟧ ⟹ ?c ∈ ?B›*) subset_insertI (*‹?B ⊆ ?a ▹ ?B›*) subset_insertI2 (*‹?A ⊆ ?B ⟹ ?A ⊆ ?b ▹ ?B›*)) (*discuss goal 3*) apply simp (*top goal: ‹⋀S::'a::type formula set. ⟦∀S::'a::type formula set∈C::'a::type formula set set. ⊥ ∉ S ∧ (∀k::'a::type. Atom k ∈ S ⟶ ❙¬ (Atom k) ∈ S ⟶ False) ∧ (∀(F::'a::type formula) (G::'a::type formula) H::'a::type formula. Con F G H ⟶ F ∈ S ⟶ G ▹ H ▹ S ∈ C) ∧ (∀(F::'a::type formula) (G::'a::type formula) H::'a::type formula. Dis F G H ⟶ F ∈ S ⟶ G ▹ S ∈ C ∨ H ▹ S ∈ C); S ∈ {s::'a::type formula set. Bex C ((⊆) s)}⟧ ⟹ ∀(F::'a::type formula) (G::'a::type formula) H::'a::type formula. Con F G H ⟶ F ∈ S ⟶ G ▹ H ▹ S ∈ {s::'a::type formula set. Bex C ((⊆) s)}› and 1 goal remains*) apply (meson insertI1 (*‹?a ∈ ?a ▹ ?B›*) rev_subsetD (*‹⟦?c ∈ ?A; ?A ⊆ ?B⟧ ⟹ ?c ∈ ?B›*) subset_insertI (*‹?B ⊆ ?a ▹ ?B›*) subset_insertI2 (*‹?A ⊆ ?B ⟹ ?A ⊆ ?b ▹ ?B›*)) (*discuss goal 4*) apply simp (*goal: ‹⋀S. ⟦∀S∈C. ⊥ ∉ S ∧ (∀k. Atom k ∈ S ⟶ ❙¬ (Atom k) ∈ S ⟶ False) ∧ (∀F G H. Con F G H ⟶ F ∈ S ⟶ G ▹ H ▹ S ∈ C) ∧ (∀F G H. Dis F G H ⟶ F ∈ S ⟶ G ▹ S ∈ C ∨ H ▹ S ∈ C); S ∈ {s. Bex C ((⊆) s)}⟧ ⟹ ∀F G H. Dis F G H ⟶ F ∈ S ⟶ G ▹ S ∈ {s. Bex C ((⊆) s)} ∨ H ▹ S ∈ {s. Bex C ((⊆) s)}›*) apply (meson insertI1 (*‹?a ∈ ?a ▹ ?B›*) rev_subsetD (*‹⟦?c ∈ ?A; ?A ⊆ ?B⟧ ⟹ ?c ∈ ?B›*) subset_insertI (*‹?B ⊆ ?a ▹ ?B›*) subset_insertI2 (*‹?A ⊆ ?B ⟹ ?A ⊆ ?b ▹ ?B›*)) (*proven 4 subgoals*) . qed lemma sallI: "(⋀s. s ⊆ S ⟹ P s) ⟹ ∀s ⊆ S. P s" by simp lemma ex2: assumes fc: "finite_character C" shows "subset_closed C" unfolding subset_closed_def (*goal: ‹∀S∈C. ∀s⊆S. s ∈ C›*) proof (intro ballI (*‹(⋀x. x ∈ ?A ⟹ ?P x) ⟹ ∀x∈?A. ?P x›*) sallI (*‹(⋀s. s ⊆ ?S ⟹ ?P s) ⟹ ∀s⊆?S. ?P s›*)) (*goal: ‹⋀S s. ⟦S ∈ C; s ⊆ S⟧ ⟹ s ∈ C›*) fix s and S assume e: "S ∈ C" and s: "s ⊆ S" (*‹(S::'a set) ∈ (C::'a set set)› ‹(s::'a set) ⊆ (S::'a set)›*) hence "*": "t ⊆ s ⟹ t ⊆ S" for t by simp from fc (*‹finite_character C›*) have "t ⊆ S ⟹ finite t ⟹ t ∈ C" for t unfolding finite_character_def (*goal: ‹⟦t ⊆ S; finite t⟧ ⟹ t ∈ C›*) using e (*‹S ∈ C›*) by blast hence "t ⊆ s ⟹ finite t ⟹ t ∈ C" for t using "*" (*‹?t ⊆ s ⟹ ?t ⊆ S›*) by simp with fc (*‹finite_character (C::'a set set)›*) show "s ∈ C" unfolding finite_character_def (*goal: ‹s ∈ C›*) by blast qed lemma assumes C: "pcp C" assumes S: "subset_closed C" shows ex3: "∃C'. C ⊆ C' ∧ pcp C' ∧ finite_character C'" proof (intro exI[of _ "C ∪ {S. ∀s ⊆ S. finite s ⟶ s ∈ C}"] (*‹?P (C ∪ {S. ∀s⊆S. finite s ⟶ s ∈ C}) ⟹ ∃x. ?P x›*) conjI (*‹⟦?P; ?Q⟧ ⟹ ?P ∧ ?Q›*)) (*goals: 1. ‹C ⊆ C ∪ {S. ∀s⊆S. finite s ⟶ s ∈ C}› 2. ‹pcp (C ∪ {S. ∀s⊆S. finite s ⟶ s ∈ C})› 3. ‹finite_character (C ∪ {S. ∀s⊆S. finite s ⟶ s ∈ C})›*) let ?E = " {S. ∀s ⊆ S. finite s ⟶ s ∈ C}" show "C ⊆ C ∪ ?E" by blast from S (*‹subset_closed C›*) show "finite_character (C ∪ ?E)" unfolding finite_character_def subset_closed_def (*goal: ‹∀S. (S ∈ C ∪ {S. ∀s⊆S. finite s ⟶ s ∈ C}) = (∀s⊆S. finite s ⟶ s ∈ C ∪ {S. ∀s⊆S. finite s ⟶ s ∈ C})›*) by blast note C'' = C[unfolded pcp_alt, THEN bspec] (*‹(?x::'a formula set) ∈ (C::'a formula set set) ⟹ ⊥ ∉ ?x ∧ (∀k::'a. Atom k ∈ ?x ⟶ ❙¬ (Atom k) ∈ ?x ⟶ False) ∧ (∀(F::'a formula) (G::'a formula) H::'a formula. Con F G H ⟶ F ∈ ?x ⟶ G ▹ H ▹ ?x ∈ C) ∧ (∀(F::'a formula) (G::'a formula) H::'a formula. Dis F G H ⟶ F ∈ ?x ⟶ G ▹ ?x ∈ C ∨ H ▹ ?x ∈ C)›*) have CON: "G ▹ H ▹ S ∈ C ∪ {S. ∀s⊆S. finite s ⟶ s ∈ C}" if si: "⋀s. ⟦s⊆S; finite s⟧ ⟹ s ∈ C" and un: "Con F G H" and el: " F ∈ S" for F and G and H and S proof (-) (*goal: ‹G ▹ H ▹ S ∈ C ∪ {S. ∀s⊆S. finite s ⟶ s ∈ C}›*) have k: "∀s ⊆ S. finite s ⟶ F ∈ s ⟶ G ▹ H ▹ s ∈ C" using si (*‹⟦?s ⊆ S; finite ?s⟧ ⟹ ?s ∈ C›*) un (*‹Con F G H›*) C'' (*‹?x ∈ C ⟹ ⊥ ∉ ?x ∧ (∀k. Atom k ∈ ?x ⟶ ❙¬ (Atom k) ∈ ?x ⟶ False) ∧ (∀F G H. Con F G H ⟶ F ∈ ?x ⟶ G ▹ H ▹ ?x ∈ C) ∧ (∀F G H. Dis F G H ⟶ F ∈ ?x ⟶ G ▹ ?x ∈ C ∨ H ▹ ?x ∈ C)›*) by simp have "G ▹ H ▹ S ∈ ?E" unfolding mem_Collect_eq Un_iff (*goal: ‹∀s⊆G ▹ H ▹ S. finite s ⟶ s ∈ C›*) proof (safe) (*goal: ‹⋀s. ⟦s ⊆ G ▹ H ▹ S; finite s⟧ ⟹ s ∈ C›*) fix s assume "s ⊆ G ▹ H ▹ S" and f: "finite s" (*‹(s::'a formula set) ⊆ (G::'a formula) ▹ (H::'a formula) ▹ (S::'a formula set)› ‹finite (s::'a formula set)›*) hence "F ▹ (s - {G,H}) ⊆ S" using el (*‹F ∈ S›*) by blast with k (*‹∀s⊆S::'a::type formula set. finite s ⟶ (F::'a::type formula) ∈ s ⟶ (G::'a::type formula) ▹ (H::'a::type formula) ▹ s ∈ (C::'a::type formula set set)›*) f (*‹finite s›*) have "G ▹ H ▹ F ▹ (s - {G,H}) ∈ C" by simp hence "F ▹ G ▹ H ▹ s ∈ C" using insert_absorb (*‹?a ∈ ?A ⟹ ?a ▹ ?A = ?A›*) by fastforce thus "s ∈ C" using S (*‹subset_closed (C::'a::type formula set set)›*) unfolding subset_closed_def (*goal: ‹s ∈ C›*) by fast qed thus "G ▹ H ▹ S ∈ C ∪ ?E" by simp qed have DIS: "G ▹ S ∈ C ∪ {S. ∀s⊆S. finite s ⟶ s ∈ C} ∨ H ▹ S ∈ C ∪ {S. ∀s⊆S. finite s ⟶ s ∈ C}" if si: "⋀s. s⊆S ⟹ finite s ⟹ s ∈ C" and un: "Dis F G H" and el: "F ∈ S" for F and G and H and S proof (-) (*goal: ‹G ▹ S ∈ C ∪ {S. ∀s⊆S. finite s ⟶ s ∈ C} ∨ H ▹ S ∈ C ∪ {S. ∀s⊆S. finite s ⟶ s ∈ C}›*) have l: "∃I∈{G, H}. I ▹ s1 ∈ C ∧ I ▹ s2 ∈ C" if "s1 ⊆ S" "finite s1" "F ∈ s1" "s2 ⊆ S" "finite s2" "F ∈ s2" for s1 and s2 proof (-) (*goal: ‹∃I∈{G, H}. I ▹ s1 ∈ C ∧ I ▹ s2 ∈ C›*) let ?s = "s1 ∪ s2" have "?s ⊆ S" "finite ?s" using that (*‹s1 ⊆ S› ‹finite s1› ‹(F::'a formula) ∈ (s1::'a formula set)› ‹s2 ⊆ S› ‹finite s2› ‹F ∈ s2›*) apply - (*goals: 1. ‹⟦s1 ⊆ S; finite s1; F ∈ s1; s2 ⊆ S; finite s2; F ∈ s2⟧ ⟹ s1 ∪ s2 ⊆ S› 2. ‹⟦s1 ⊆ S; finite s1; F ∈ s1; s2 ⊆ S; finite s2; F ∈ s2⟧ ⟹ finite (s1 ∪ s2)› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) . with si (*‹⟦?s ⊆ S; finite ?s⟧ ⟹ ?s ∈ C›*) have "?s ∈ C" by simp moreover have "F ∈ ?s" using that (*‹s1 ⊆ S› ‹finite s1› ‹(F::'a formula) ∈ (s1::'a formula set)› ‹s2 ⊆ S› ‹finite s2› ‹(F::'a formula) ∈ (s2::'a formula set)›*) by simp ultimately have "∃I∈{G,H}. I ▹ ?s ∈ C" using C'' (*‹(?x::'a formula set) ∈ (C::'a formula set set) ⟹ ⊥ ∉ ?x ∧ (∀k::'a. Atom k ∈ ?x ⟶ ❙¬ (Atom k) ∈ ?x ⟶ False) ∧ (∀(F::'a formula) (G::'a formula) H::'a formula. Con F G H ⟶ F ∈ ?x ⟶ G ▹ H ▹ ?x ∈ C) ∧ (∀(F::'a formula) (G::'a formula) H::'a formula. Dis F G H ⟶ F ∈ ?x ⟶ G ▹ ?x ∈ C ∨ H ▹ ?x ∈ C)›*) un (*‹Dis F G H›*) by simp thus "∃I∈{G,H}. I ▹ s1 ∈ C ∧ I ▹ s2 ∈ C" by (meson S[unfolded subset_closed_def, THEN bspec] (*‹(?x::'a formula set) ∈ (C::'a formula set set) ⟹ ∀s⊆?x. s ∈ C›*) insert_mono (*‹(?C::?'a set) ⊆ (?D::?'a set) ⟹ (?a::?'a) ▹ ?C ⊆ ?a ▹ ?D›*) sup.cobounded2 (*‹(?b::?'a) ≤ sup (?a::?'a) ?b›*) sup_ge1 (*‹(?x::?'a) ≤ sup ?x (?y::?'a)›*)) qed have m: "⟦s1 ⊆ S; finite s1; F ∈ s1; G ▹ s1 ∉ C; s2 ⊆ S; finite s2; F ∈ s2; H ▹ s2 ∉ C⟧ ⟹ False" for s1 and s2 using l (*‹⟦?s1.0 ⊆ S; finite ?s1.0; F ∈ ?s1.0; ?s2.0 ⊆ S; finite ?s2.0; F ∈ ?s2.0⟧ ⟹ ∃I∈{G, H}. I ▹ ?s1.0 ∈ C ∧ I ▹ ?s2.0 ∈ C›*) by blast have False if "s1 ⊆ S" "finite s1" "G ▹ s1 ∉ C" "s2 ⊆ S" "finite s2" "H ▹ s2 ∉ C" for s1 and s2 proof (-) (*goal: ‹False›*) have "*": "F ▹ s1 ⊆ S" "finite (F ▹ s1)" "F ∈ F ▹ s1" if "s1 ⊆ S" "finite s1" for s1 using that (*‹s1 ⊆ S› ‹finite s1›*) el (*‹F ∈ S›*) apply - (*goals: 1. ‹⟦s1 ⊆ S; finite s1; F ∈ S⟧ ⟹ F ▹ s1 ⊆ S› 2. ‹⟦s1 ⊆ S; finite s1; F ∈ S⟧ ⟹ finite (F ▹ s1)› 3. ‹⟦s1 ⊆ S; finite s1; F ∈ S⟧ ⟹ F ∈ F ▹ s1› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*discuss goal 3*) apply simp (*proven 3 subgoals*) . have "G ▹ F ▹ s1 ∉ C" "H ▹ F ▹ s2 ∉ C" (*goals: 1. ‹G ▹ F ▹ s1 ∉ C› 2. ‹H ▹ F ▹ s2 ∉ C› discuss goal 1*) apply (meson S (*‹subset_closed C›*) insert_mono (*‹?C ⊆ ?D ⟹ ?a ▹ ?C ⊆ ?a ▹ ?D›*) subset_closed_def (*‹subset_closed ?C ≡ ∀S∈?C. ∀s⊆S. s ∈ ?C›*) subset_insertI (*‹?B ⊆ ?a ▹ ?B›*) that( (*‹G ▹ s1 ∉ C› ‹H ▹ s2 ∉ C›*) 3,6)) (*discuss goal 2*) apply (meson S (*‹subset_closed C›*) insert_mono (*‹?C ⊆ ?D ⟹ ?a ▹ ?C ⊆ ?a ▹ ?D›*) subset_closed_def (*‹subset_closed ?C ≡ ∀S∈?C. ∀s⊆S. s ∈ ?C›*) subset_insertI (*‹?B ⊆ ?a ▹ ?B›*) that( (*‹G ▹ s1 ∉ C› ‹H ▹ s2 ∉ C›*) 3,6)) (*proven 2 subgoals*) . from m[OF * [ OF that ( 1 - 2 ) ] this ( 1 ) * [ OF that ( 4 - 5 ) ] this ( 2 )] (*‹False›*) show False . qed hence "G ▹ S ∈ ?E ∨ H ▹ S ∈ ?E" unfolding mem_Collect_eq Un_iff (*goal: ‹(∀s⊆G ▹ S. finite s ⟶ s ∈ C) ∨ (∀s⊆H ▹ S. finite s ⟶ s ∈ C)›*) by (metis (no_types, lifting) finite_Diff (*‹finite ?A ⟹ finite (?A - ?B)›*) insert_Diff (*‹?a ∈ ?A ⟹ ?a ▹ ?A - {?a} = ?A›*) si (*‹⟦?s ⊆ S; finite ?s⟧ ⟹ ?s ∈ C›*) subset_insert_iff (*‹(?A ⊆ ?x ▹ ?B) = (if ?x ∈ ?A then ?A - {?x} ⊆ ?B else ?A ⊆ ?B)›*)) thus "G ▹ S ∈ C ∪ ?E ∨ H ▹ S ∈ C ∪ ?E" by blast qed have CON': "⋀f2 g2 h2 F2 G2 S2. ⟦⋀s. ⟦s ∈ C; h2 F2 G2 ∈ s⟧ ⟹ f2 F2 ▹ s ∈ C ∨ g2 G2 ▹ s ∈ C; ∀s⊆S2. finite s ⟶ s ∈ C; h2 F2 G2 ∈ S2; False⟧ ⟹ f2 F2 ▹ S2 ∈ C ∪ {S. ∀s⊆S. finite s ⟶ s ∈ C} ∨ g2 G2 ▹ S2 ∈ C ∪ {S. ∀s⊆S. finite s ⟶ s ∈ C}" by fast show "pcp (C ∪ ?E)" unfolding pcp_alt (*goal: ‹∀S∈C ∪ {S. ∀s⊆S. finite s ⟶ s ∈ C}. ⊥ ∉ S ∧ (∀k. Atom k ∈ S ⟶ ❙¬ (Atom k) ∈ S ⟶ False) ∧ (∀F G H. Con F G H ⟶ F ∈ S ⟶ G ▹ H ▹ S ∈ C ∪ {S. ∀s⊆S. finite s ⟶ s ∈ C}) ∧ (∀F G H. Dis F G H ⟶ F ∈ S ⟶ G ▹ S ∈ C ∪ {S. ∀s⊆S. finite s ⟶ s ∈ C} ∨ H ▹ S ∈ C ∪ {S. ∀s⊆S. finite s ⟶ s ∈ C})›*) apply (intro ballI (*‹(⋀x. x ∈ ?A ⟹ ?P x) ⟹ ∀x∈?A. ?P x›*) conjI (*‹⟦?P; ?Q⟧ ⟹ ?P ∧ ?Q›*); elim UnE (*‹⟦?c ∈ ?A ∪ ?B; ?c ∈ ?A ⟹ ?P; ?c ∈ ?B ⟹ ?P⟧ ⟹ ?P›*); (unfold mem_Collect_eq (*‹(?a ∈ Collect ?P) = ?P ?a›*))?) (*goal: ‹∀S::'a::type formula set∈(C::'a::type formula set set) ∪ {S::'a::type formula set. ∀s⊆S. finite s ⟶ s ∈ C}. ⊥ ∉ S ∧ (∀k::'a::type. Atom k ∈ S ⟶ ❙¬ (Atom k) ∈ S ⟶ False) ∧ (∀(F::'a::type formula) (G::'a::type formula) H::'a::type formula. Con F G H ⟶ F ∈ S ⟶ G ▹ H ▹ S ∈ C ∪ {S::'a::type formula set. ∀s⊆S. finite s ⟶ s ∈ C}) ∧ (∀(F::'a::type formula) (G::'a::type formula) H::'a::type formula. Dis F G H ⟶ F ∈ S ⟶ G ▹ S ∈ C ∪ {S::'a::type formula set. ∀s⊆S. finite s ⟶ s ∈ C} ∨ H ▹ S ∈ C ∪ {S::'a::type formula set. ∀s⊆S. finite s ⟶ s ∈ C})›*) subgoal for using C'' (*‹(?x::'a formula set) ∈ (C::'a formula set set) ⟹ ⊥ ∉ ?x ∧ (∀k::'a. Atom k ∈ ?x ⟶ ❙¬ (Atom k) ∈ ?x ⟶ False) ∧ (∀(F::'a formula) (G::'a formula) H::'a formula. Con F G H ⟶ F ∈ ?x ⟶ G ▹ H ▹ ?x ∈ C) ∧ (∀(F::'a formula) (G::'a formula) H::'a formula. Dis F G H ⟶ F ∈ ?x ⟶ G ▹ ?x ∈ C ∨ H ▹ ?x ∈ C)›*) by blast subgoal for using C'' (*‹(?x::'a::type formula set) ∈ (C::'a::type formula set set) ⟹ ⊥ ∉ ?x ∧ (∀k::'a::type. Atom k ∈ ?x ⟶ ❙¬ (Atom k) ∈ ?x ⟶ False) ∧ (∀(F::'a::type formula) (G::'a::type formula) H::'a::type formula. Con F G H ⟶ F ∈ ?x ⟶ G ▹ H ▹ ?x ∈ C) ∧ (∀(F::'a::type formula) (G::'a::type formula) H::'a::type formula. Dis F G H ⟶ F ∈ ?x ⟶ G ▹ ?x ∈ C ∨ H ▹ ?x ∈ C)›*) by blast subgoal for using C'' (*‹?x ∈ C ⟹ ⊥ ∉ ?x ∧ (∀k. Atom k ∈ ?x ⟶ ❙¬ (Atom k) ∈ ?x ⟶ False) ∧ (∀F G H. Con F G H ⟶ F ∈ ?x ⟶ G ▹ H ▹ ?x ∈ C) ∧ (∀F G H. Dis F G H ⟶ F ∈ ?x ⟶ G ▹ ?x ∈ C ∨ H ▹ ?x ∈ C)›*) by simp subgoal for by (meson C'' (*‹?x ∈ C ⟹ ⊥ ∉ ?x ∧ (∀k. Atom k ∈ ?x ⟶ ❙¬ (Atom k) ∈ ?x ⟶ False) ∧ (∀F G H. Con F G H ⟶ F ∈ ?x ⟶ G ▹ H ▹ ?x ∈ C) ∧ (∀F G H. Dis F G H ⟶ F ∈ ?x ⟶ G ▹ ?x ∈ C ∨ H ▹ ?x ∈ C)›*) empty_subsetI (*‹{} ⊆ ?A›*) finite.emptyI (*‹finite {}›*) finite_insert (*‹finite (?a ▹ ?A) = finite ?A›*) insert_subset (*‹(?x ▹ ?A ⊆ ?B) = (?x ∈ ?B ∧ ?A ⊆ ?B)›*) subset_insertI (*‹?B ⊆ ?a ▹ ?B›*)) subgoal for using C'' (*‹?x ∈ C ⟹ ⊥ ∉ ?x ∧ (∀k. Atom k ∈ ?x ⟶ ❙¬ (Atom k) ∈ ?x ⟶ False) ∧ (∀F G H. Con F G H ⟶ F ∈ ?x ⟶ G ▹ H ▹ ?x ∈ C) ∧ (∀F G H. Dis F G H ⟶ F ∈ ?x ⟶ G ▹ ?x ∈ C ∨ H ▹ ?x ∈ C)›*) by simp subgoal for using CON (*‹⟦⋀s. ⟦s ⊆ ?S; finite s⟧ ⟹ s ∈ C; Con ?F ?G ?H; ?F ∈ ?S⟧ ⟹ ?G ▹ ?H ▹ ?S ∈ C ∪ {S. ∀s⊆S. finite s ⟶ s ∈ C}›*) by simp subgoal for using C'' (*‹(?x::'a::type formula set) ∈ (C::'a::type formula set set) ⟹ ⊥ ∉ ?x ∧ (∀k::'a::type. Atom k ∈ ?x ⟶ ❙¬ (Atom k) ∈ ?x ⟶ False) ∧ (∀(F::'a::type formula) (G::'a::type formula) H::'a::type formula. Con F G H ⟶ F ∈ ?x ⟶ G ▹ H ▹ ?x ∈ C) ∧ (∀(F::'a::type formula) (G::'a::type formula) H::'a::type formula. Dis F G H ⟶ F ∈ ?x ⟶ G ▹ ?x ∈ C ∨ H ▹ ?x ∈ C)›*) by blast subgoal for using DIS (*‹⟦⋀s. ⟦s ⊆ ?S; finite s⟧ ⟹ s ∈ C; Dis ?F ?G ?H; ?F ∈ ?S⟧ ⟹ ?G ▹ ?S ∈ C ∪ {S. ∀s⊆S. finite s ⟶ s ∈ C} ∨ ?H ▹ ?S ∈ C ∪ {S. ∀s⊆S. finite s ⟶ s ∈ C}›*) by simp . qed primrec pcp_seq where "pcp_seq C S 0 = S" | "pcp_seq C S (Suc n) = ( let Sn = pcp_seq C S n; Sn1 = from_nat n ▹ Sn in if Sn1 ∈ C then Sn1 else Sn )" lemma pcp_seq_in: "pcp C ⟹ S ∈ C ⟹ pcp_seq C S n ∈ C" proof (induction n) (*goals: 1. ‹⟦pcp (C::'a formula set set); (S::'a formula set) ∈ C⟧ ⟹ pcp_seq C S (0::nat) ∈ C› 2. ‹⋀n::nat. ⟦⟦pcp (C::'a formula set set); (S::'a formula set) ∈ C⟧ ⟹ pcp_seq C S n ∈ C; pcp C; S ∈ C⟧ ⟹ pcp_seq C S (Suc n) ∈ C›*) case (Suc n) (*‹⟦pcp (C::'a formula set set); (S::'a formula set) ∈ C⟧ ⟹ pcp_seq C S (n::nat) ∈ C› ‹pcp C› ‹S ∈ C›*) hence "pcp_seq C S n ∈ C" by simp thus "?case" (*goal: ‹pcp_seq C S (Suc n) ∈ C›*) by (simp add: Let_def (*‹Let ?s ?f ≡ ?f ?s›*)) qed (simp) (*solved the remaining goal: ‹⟦pcp C; S ∈ C⟧ ⟹ pcp_seq C S 0 ∈ C›*) lemma pcp_seq_mono: "n ≤ m ⟹ pcp_seq C S n ⊆ pcp_seq C S m" proof (induction m) (*goals: 1. ‹n ≤ 0 ⟹ pcp_seq C S n ⊆ pcp_seq C S 0› 2. ‹⋀m. ⟦n ≤ m ⟹ pcp_seq C S n ⊆ pcp_seq C S m; n ≤ Suc m⟧ ⟹ pcp_seq C S n ⊆ pcp_seq C S (Suc m)›*) case (Suc m) (*‹n ≤ m ⟹ pcp_seq C S n ⊆ pcp_seq C S m› ‹n ≤ Suc m›*) thus "?case" (*goal: ‹pcp_seq (C::'a::countable set set) (S::'a::countable set) (n::nat) ⊆ pcp_seq C S (Suc (m::nat))›*) apply (cases "n = Suc m") (*goals: 1. ‹⟦(n::nat) ≤ (m::nat) ⟹ pcp_seq (C::'a::countable set set) (S::'a::countable set) n ⊆ pcp_seq C S m; n ≤ Suc m; n = Suc m⟧ ⟹ pcp_seq C S n ⊆ pcp_seq C S (Suc m)› 2. ‹⟦(n::nat) ≤ (m::nat) ⟹ pcp_seq (C::'a::countable set set) (S::'a::countable set) n ⊆ pcp_seq C S m; n ≤ Suc m; n ≠ Suc m⟧ ⟹ pcp_seq C S n ⊆ pcp_seq C S (Suc m)› discuss goal 1*) apply (simp add: Let_def (*‹Let ?s ?f ≡ ?f ?s›*)) (*discuss goal 2*) apply (simp add: Let_def (*‹Let (?s::?'a) (?f::?'a ⇒ ?'b) ≡ ?f ?s›*)) (*goal: ‹⟦n ≤ m ⟹ pcp_seq C S n ⊆ pcp_seq C S m; n ≤ Suc m; n ≠ Suc m⟧ ⟹ pcp_seq C S n ⊆ pcp_seq C S (Suc m)›*) apply blast (*proven 2 subgoals*) . qed (simp) (*solved the remaining goal: ‹n ≤ 0 ⟹ pcp_seq C S n ⊆ pcp_seq C S 0›*) lemma pcp_seq_UN: "⋃{pcp_seq C S n|n. n ≤ m} = pcp_seq C S m" proof (induction m) (*goals: 1. ‹⋃ {pcp_seq C S n |n. n ≤ 0} = pcp_seq C S 0› 2. ‹⋀m. ⋃ {pcp_seq C S n |n. n ≤ m} = pcp_seq C S m ⟹ ⋃ {pcp_seq C S n |n. n ≤ Suc m} = pcp_seq C S (Suc m)›*) case (Suc m) (*‹⋃ {pcp_seq C S n |n. n ≤ m} = pcp_seq C S m›*) have "{f n |n. n ≤ Suc m} = f (Suc m) ▹ {f n |n. n ≤ m}" for f using le_Suc_eq (*‹(?m ≤ Suc ?n) = (?m ≤ ?n ∨ ?m = Suc ?n)›*) by auto hence "{pcp_seq C S n |n. n ≤ Suc m} = pcp_seq C S (Suc m) ▹ {pcp_seq C S n |n. n ≤ m}" . hence "⋃{pcp_seq C S n |n. n ≤ Suc m} = ⋃{pcp_seq C S n |n. n ≤ m} ∪ pcp_seq C S (Suc m)" by auto thus "?case" (*goal: ‹⋃ {pcp_seq (C::'a set set) (S::'a set) n |n::nat. n ≤ Suc (m::nat)} = pcp_seq C S (Suc m)›*) using Suc (*‹⋃ {pcp_seq C S n |n. n ≤ m} = pcp_seq C S m›*) pcp_seq_mono (*‹(?n::nat) ≤ (?m::nat) ⟹ pcp_seq (?C::?'a::countable set set) (?S::?'a::countable set) ?n ⊆ pcp_seq ?C ?S ?m›*) by blast qed (simp) (*solved the remaining goal: ‹⋃ {pcp_seq C S n |n. n ≤ 0} = pcp_seq C S 0›*) lemma wont_get_added: "(F :: ('a :: countable) formula) ∉ pcp_seq C S (Suc (to_nat F)) ⟹ F ∉ pcp_seq C S (Suc (to_nat F) + n)" text‹We don't necessarily have @{term "n = to_nat (from_nat n)"}, so this doesn't hold.› oops definition "pcp_lim C S ≡ ⋃{pcp_seq C S n|n. True}" lemma pcp_seq_sub: "pcp_seq C S n ⊆ pcp_lim C S" unfolding pcp_lim_def (*goal: ‹pcp_seq C S n ⊆ ⋃ {pcp_seq C S n |n. True}›*) apply (induction n) (*goals: 1. ‹pcp_seq C S 0 ⊆ ⋃ {pcp_seq C S n |n. True}› 2. ‹⋀n. pcp_seq C S n ⊆ ⋃ {pcp_seq C S n |n. True} ⟹ pcp_seq C S (Suc n) ⊆ ⋃ {pcp_seq C S n |n. True}› discuss goal 1*) apply blast (*discuss goal 2*) apply blast (*proven 2 subgoals*) . lemma pcp_lim_inserted_at_ex: "x ∈ pcp_lim C S ⟹ ∃k. x ∈ pcp_seq C S k" unfolding pcp_lim_def (*goal: ‹x ∈ ⋃ {pcp_seq C S n |n. True} ⟹ ∃k. x ∈ pcp_seq C S k›*) by blast lemma pcp_lim_in: assumes c: "pcp C" and el: "S ∈ C" and sc: "subset_closed C" and fc: "finite_character C" shows "pcp_lim C S ∈ C" (is "?cl ∈ C") sorry lemma cl_max: assumes c: "pcp C" assumes sc: "subset_closed C" assumes el: "K ∈ C" assumes su: "pcp_lim C S ⊆ K" shows "pcp_lim C S = K" (is ?e) proof (rule ccontr (*‹(¬ (?P::bool) ⟹ False) ⟹ ?P›*)) (*goal: ‹pcp_lim C S ≠ K ⟹ False›*) assume "¬?e" (*‹pcp_lim (C::'a formula set set) (S::'a formula set) ≠ (K::'a formula set)›*) with su (*‹pcp_lim C S ⊆ K›*) have "pcp_lim C S ⊂ K" by simp then obtain F where e: "F ∈ K" and ne: "F ∉ pcp_lim C S" (*goal: ‹(⋀F. ⟦F ∈ K; F ∉ pcp_lim C S⟧ ⟹ thesis) ⟹ thesis›*) by blast from ne (*‹F ∉ pcp_lim C S›*) have "F ∉ pcp_seq C S (Suc (to_nat F))" using pcp_seq_sub (*‹pcp_seq ?C ?S ?n ⊆ pcp_lim ?C ?S›*) by fast hence 1: "F ▹ pcp_seq C S (to_nat F) ∉ C" by (simp add: 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))›*)) have "F ▹ pcp_seq C S (to_nat F) ⊆ K" using pcp_seq_sub (*‹pcp_seq (?C::?'a set set) (?S::?'a set) (?n::nat) ⊆ pcp_lim ?C ?S›*) e (*‹F ∈ K›*) su (*‹pcp_lim C S ⊆ K›*) by blast hence "F ▹ pcp_seq C S (to_nat F) ∈ C" using sc (*‹subset_closed (C::'a formula set set)›*) unfolding subset_closed_def (*goal: ‹(F::'a::countable formula) ▹ pcp_seq (C::'a::countable formula set set) (S::'a::countable formula set) (to_nat F) ∈ C›*) using el (*‹K ∈ C›*) by blast with "1" (*‹F ▹ pcp_seq C S (to_nat F) ∉ C›*) show False by standard qed lemma cl_max': assumes c: "pcp C" assumes sc: "subset_closed C" shows "F ▹ pcp_lim C S ∈ C ⟹ F ∈ pcp_lim C S" "F ▹ G ▹ pcp_lim C S ∈ C ⟹ F ∈ pcp_lim C S ∧ G ∈ pcp_lim C S" using cl_max[OF assms] (*‹⟦?K ∈ C; pcp_lim C ?S ⊆ ?K⟧ ⟹ pcp_lim C ?S = ?K›*) apply - (*goals: 1. ‹⟦F ▹ pcp_lim C S ∈ C; ⋀K S. ⟦K ∈ C; pcp_lim C S ⊆ K⟧ ⟹ pcp_lim C S = K⟧ ⟹ F ∈ pcp_lim C S› 2. ‹⟦F ▹ G ▹ pcp_lim C S ∈ C; ⋀K S. ⟦K ∈ C; pcp_lim C S ⊆ K⟧ ⟹ pcp_lim C S = K⟧ ⟹ F ∈ pcp_lim C S ∧ G ∈ pcp_lim C S› discuss goal 1*) apply blast (*discuss goal 2*) apply blast (*proven 2 subgoals*) . lemma pcp_lim_Hintikka: assumes c: "pcp C" assumes sc: "subset_closed C" assumes fc: "finite_character C" assumes el: "S ∈ C" shows "Hintikka (pcp_lim C S)" proof (-) (*goal: ‹Hintikka (pcp_lim (C::'a formula set set) (S::'a formula set))›*) let ?cl = "pcp_lim C S" have "?cl ∈ C" using pcp_lim_in[OF c el sc fc] (*‹pcp_lim C S ∈ C›*) . from c[unfolded pcp_alt, THEN bspec, OF this] (*‹⊥ ∉ pcp_lim C S ∧ (∀k. Atom k ∈ pcp_lim C S ⟶ ❙¬ (Atom k) ∈ pcp_lim C S ⟶ False) ∧ (∀F G H. Con F G H ⟶ F ∈ pcp_lim C S ⟶ G ▹ H ▹ pcp_lim C S ∈ C) ∧ (∀F G H. Dis F G H ⟶ F ∈ pcp_lim C S ⟶ G ▹ pcp_lim C S ∈ C ∨ H ▹ pcp_lim C S ∈ C)›*) have d: "⊥ ∉ ?cl" "Atom k ∈ ?cl ⟹ ❙¬ (Atom k) ∈ ?cl ⟹ False" "Con F G H ⟹ F ∈ ?cl ⟹ G ▹ H ▹ ?cl ∈ C" "Dis F G H ⟹ F ∈ ?cl ⟹ G ▹ ?cl ∈ C ∨ H ▹ ?cl ∈ C" for k and F and G and H apply - (*goals: 1. ‹⊥ ∉ pcp_lim C S ∧ (∀k. Atom k ∈ pcp_lim C S ⟶ ❙¬ (Atom k) ∈ pcp_lim C S ⟶ False) ∧ (∀F G H. Con F G H ⟶ F ∈ pcp_lim C S ⟶ G ▹ H ▹ pcp_lim C S ∈ C) ∧ (∀F G H. Dis F G H ⟶ F ∈ pcp_lim C S ⟶ G ▹ pcp_lim C S ∈ C ∨ H ▹ pcp_lim C S ∈ C) ⟹ ⊥ ∉ pcp_lim C S› 2. ‹⟦Atom k ∈ pcp_lim C S; ❙¬ (Atom k) ∈ pcp_lim C S; ⊥ ∉ pcp_lim C S ∧ (∀k. Atom k ∈ pcp_lim C S ⟶ ❙¬ (Atom k) ∈ pcp_lim C S ⟶ False) ∧ (∀F G H. Con F G H ⟶ F ∈ pcp_lim C S ⟶ G ▹ H ▹ pcp_lim C S ∈ C) ∧ (∀F G H. Dis F G H ⟶ F ∈ pcp_lim C S ⟶ G ▹ pcp_lim C S ∈ C ∨ H ▹ pcp_lim C S ∈ C)⟧ ⟹ False› 3. ‹⟦Con F G H; F ∈ pcp_lim C S; ⊥ ∉ pcp_lim C S ∧ (∀k. Atom k ∈ pcp_lim C S ⟶ ❙¬ (Atom k) ∈ pcp_lim C S ⟶ False) ∧ (∀F G H. Con F G H ⟶ F ∈ pcp_lim C S ⟶ G ▹ H ▹ pcp_lim C S ∈ C) ∧ (∀F G H. Dis F G H ⟶ F ∈ pcp_lim C S ⟶ G ▹ pcp_lim C S ∈ C ∨ H ▹ pcp_lim C S ∈ C)⟧ ⟹ G ▹ H ▹ pcp_lim C S ∈ C› 4. ‹⟦Dis F G H; F ∈ pcp_lim C S; ⊥ ∉ pcp_lim C S ∧ (∀k. Atom k ∈ pcp_lim C S ⟶ ❙¬ (Atom k) ∈ pcp_lim C S ⟶ False) ∧ (∀F G H. Con F G H ⟶ F ∈ pcp_lim C S ⟶ G ▹ H ▹ pcp_lim C S ∈ C) ∧ (∀F G H. Dis F G H ⟶ F ∈ pcp_lim C S ⟶ G ▹ pcp_lim C S ∈ C ∨ H ▹ pcp_lim C S ∈ C)⟧ ⟹ G ▹ pcp_lim C S ∈ C ∨ H ▹ pcp_lim C S ∈ C› discuss goal 1*) apply blast (*discuss goal 2*) apply blast (*discuss goal 3*) apply blast (*discuss goal 4*) apply blast (*proven 4 subgoals*) . have "Con F G H ⟹ F ∈ ?cl ⟹ G ∈ ?cl ∧ H ∈ ?cl" "Dis F G H ⟹ F ∈ ?cl ⟹ G ∈ ?cl ∨ H ∈ ?cl" for F and G and H (*goals: 1. ‹⟦Con F G H; F ∈ pcp_lim C S⟧ ⟹ G ∈ pcp_lim C S ∧ H ∈ pcp_lim C S› 2. ‹⟦Dis F G H; F ∈ pcp_lim C S⟧ ⟹ G ∈ pcp_lim C S ∨ H ∈ pcp_lim C S› discuss goal 1*) apply ((auto dest: d( (*‹⟦Con ?F ?G ?H; ?F ∈ pcp_lim C S⟧ ⟹ ?G ▹ ?H ▹ pcp_lim C S ∈ C› ‹⟦Dis ?F ?G ?H; ?F ∈ pcp_lim C S⟧ ⟹ ?G ▹ pcp_lim C S ∈ C ∨ ?H ▹ pcp_lim C S ∈ C›*) 3-) cl_max'[OF c sc] (*‹?F ▹ pcp_lim C ?S ∈ C ⟹ ?F ∈ pcp_lim C ?S› ‹?F ▹ ?G ▹ pcp_lim C ?S ∈ C ⟹ ?F ∈ pcp_lim C ?S ∧ ?G ∈ pcp_lim C ?S›*))[1]) (*discuss goal 2*) apply ((auto dest: d( (*‹⟦Con ?F ?G ?H; ?F ∈ pcp_lim C S⟧ ⟹ ?G ▹ ?H ▹ pcp_lim C S ∈ C› ‹⟦Dis ?F ?G ?H; ?F ∈ pcp_lim C S⟧ ⟹ ?G ▹ pcp_lim C S ∈ C ∨ ?H ▹ pcp_lim C S ∈ C›*) 3-) cl_max'[OF c sc] (*‹?F ▹ pcp_lim C ?S ∈ C ⟹ ?F ∈ pcp_lim C ?S› ‹?F ▹ ?G ▹ pcp_lim C ?S ∈ C ⟹ ?F ∈ pcp_lim C ?S ∧ ?G ∈ pcp_lim C ?S›*))[1]) (*proven 2 subgoals*) . with d(1,2) (*‹⊥ ∉ pcp_lim C S› ‹⟦Atom ?k ∈ pcp_lim C S; ❙¬ (Atom ?k) ∈ pcp_lim C S⟧ ⟹ False›*) show "?thesis" (*goal: ‹Hintikka (pcp_lim C S)›*) unfolding Hintikka_alt (*goal: ‹⊥ ∉ pcp_lim C S ∧ (∀k. Atom k ∈ pcp_lim C S ⟶ ❙¬ (Atom k) ∈ pcp_lim C S ⟶ False) ∧ (∀F G H. Con F G H ⟶ F ∈ pcp_lim C S ⟶ G ∈ pcp_lim C S ∧ H ∈ pcp_lim C S) ∧ (∀F G H. Dis F G H ⟶ F ∈ pcp_lim C S ⟶ G ∈ pcp_lim C S ∨ H ∈ pcp_lim C S)›*) by fast qed theorem pcp_sat: ― ‹model existence theorem› fixes S :: "'a :: countable formula set" assumes c: "pcp C" assumes el: "S ∈ C" shows "sat S" proof (-) (*goal: ‹sat S›*) note [show_types] (*‹TERM _›*) from c (*‹pcp C›*) obtain Ce where "C ⊆ Ce" "pcp Ce" "subset_closed Ce" "finite_character Ce" (*goal: ‹(⋀Ce. ⟦C ⊆ Ce; pcp Ce; subset_closed Ce; finite_character Ce⟧ ⟹ thesis) ⟹ thesis›*) using ex1[where 'a = 'a] (*‹pcp ?C ⟹ ∃C'. ?C ⊆ C' ∧ pcp C' ∧ subset_closed C'›*) ex2[where 'a = 'a] (*‹finite_character ?C ⟹ subset_closed ?C›*) ex3[where 'a = 'a] (*‹⟦pcp ?C; subset_closed ?C⟧ ⟹ ∃C'. ?C ⊆ C' ∧ pcp C' ∧ finite_character C'›*) by (meson dual_order.trans (*‹⟦?b ≤ ?a; ?c ≤ ?b⟧ ⟹ ?c ≤ ?a›*) ex2 (*‹finite_character ?C ⟹ subset_closed ?C›*)) have "S ∈ Ce" using ‹C ⊆ Ce› (*‹(C::'a formula set set) ⊆ (Ce::'a formula set set)›*) el (*‹(S::'a::countable formula set) ∈ (C::'a::countable formula set set)›*) by standard with pcp_lim_Hintikka (*‹⟦pcp ?C; subset_closed ?C; finite_character ?C; ?S ∈ ?C⟧ ⟹ Hintikka (pcp_lim ?C ?S)›*) ‹pcp Ce› (*‹pcp Ce›*) ‹subset_closed Ce› (*‹subset_closed Ce›*) ‹finite_character Ce› (*‹finite_character (Ce::'a formula set set)›*) have "Hintikka (pcp_lim Ce S)" . with Hintikkas_lemma (*‹Hintikka ?S ⟹ sat ?S›*) have "sat (pcp_lim Ce S)" . moreover have "S ⊆ pcp_lim Ce S" using pcp_seq.simps(1) (*‹pcp_seq ?C ?S 0 = ?S›*) pcp_seq_sub (*‹pcp_seq ?C ?S ?n ⊆ pcp_lim ?C ?S›*) by fast ultimately show "?thesis" (*goal: ‹sat S›*) unfolding sat_def (*goal: ‹∃𝒜. ∀F∈S. 𝒜 ⊨ F›*) by fast qed (* This and Hintikka's lemma are the only two where we need semantics. Still, I don't think it's meaningful to separate those two into an extra theory. *) end
{ "path": "afp-2025-02-12/thys/Propositional_Proof_Systems/Consistency.thy", "repo": "afp-2025-02-12", "sha": "0df5b5641036760e98df7d307a1d51a18ff97737e12659c1f81302d080791f97" }
subsubsection‹Going back: CNFs to formulas› theory CNF_To_Formula imports CNF_Formulas "HOL-Library.List_Lexorder" begin text‹One downside of CNFs is that they cannot be converted back to formulas as-is in full generality. If we assume an order on the atoms, we can convert finite CNFs.› (* This theory was written after the theories that use the CNF, so I don't really know, but I suspect that you won't gain much from using this for the LSC lemmas… *) instantiation literal :: (ord) ord begin definition literal_less_def: "xs < ys ⟷ ( if atoms_of_lit xs = atoms_of_lit ys then (case xs of Neg _ ⇒ (case ys of Pos _ ⇒ True | _ ⇒ False) | _ ⇒ False) else atoms_of_lit xs < atoms_of_lit ys)" (* the how doesn't /really/ matter, but I still wanted something somewhat pretty. *) definition literal_le_def: "(xs :: _ literal) ≤ ys ⟷ xs < ys ∨ xs = ys" instance .. end instance literal :: (linorder) linorder by standard (auto simp add: literal_less_def literal_le_def split: literal.splits if_splits) definition formula_of_cnf where "formula_of_cnf S ≡ form_of_cnf (sorted_list_of_set (sorted_list_of_set ` S))" text‹To use the lexicographic order on lists, we first have to convert the clauses to lists, then the set of lists of literals to a list.› lemma "simplify_consts (formula_of_cnf ({{Pos 0}} :: nat clause set)) = Atom 0" sorry lemma cnf_formula_of_cnf: assumes "finite S" "∀C ∈ S. finite C" shows "cnf (formula_of_cnf S) = S" using assms (*‹finite S› ‹∀C∈S. finite C›*) by (simp add: cnf_BigAnd (*‹cnf ❙⋀?ls::?'a::type formula list = ⋃ (cnf ` set ?ls)›*) formula_of_cnf_def (*‹formula_of_cnf (?S::?'a::linorder literal set set) ≡ form_of_cnf (sorted_list_of_set (sorted_list_of_set ` ?S))›*) form_of_cnf_def (*‹form_of_cnf (?F::?'a::type literal list list) ≡ ❙⋀map disj_of_clause ?F›*) cnf_disj (*‹cnf (disj_of_clause (?R::?'a::type literal list)) = {set ?R}›*)) (* again, formula_of_cnf ∘ cnf is not an identity transformation, not even if the formula is_cnf. (there may be a much stricter definition of is_cnf for which that is the case) *) end
{ "path": "afp-2025-02-12/thys/Propositional_Proof_Systems/CNF_To_Formula.thy", "repo": "afp-2025-02-12", "sha": "4e62b1985487b9c74e39664354559f894c849acf18145f81d787ac929c167477" }
section ‹Cheeger Inequality\label{sec:cheeger_ineq}› text ‹The Cheeger inequality relates edge expansion (a combinatorial property) with the second largest eigenvalue.› theory Expander_Graphs_Cheeger_Inequality imports Expander_Graphs_Eigenvalues begin unbundle intro_cong_syntax hide_const Quantum.T context regular_graph begin lemma edge_expansionD2: assumes "m = card (S ∩ verts G)" "2*m ≤ n" shows "Λ⇩e * m ≤ real (card (edges_betw S (-S)))" proof (-) (*goal: ‹Λ⇩e * real m ≤ real (card (edges_betw S (- S)))›*) define S' where "S' = S ∩ verts G" have "Λ⇩e * m = Λ⇩e * card S'" using assms(1) (*‹m = card (S ∩ verts G)›*) S'_def (*‹S' = S ∩ verts G›*) by simp also (*calculation: ‹Λ⇩e * real m = Λ⇩e * real (card S')›*) have "... ≤ real (card (edges_betw S' (-S')))" using assms (*‹m = card (S ∩ verts G)› ‹2 * m ≤ n›*) unfolding S'_def (*goal: ‹Λ⇩e * real (card (S ∩ verts G)) ≤ real (card (edges_betw (S ∩ verts G) (- (S ∩ verts G))))›*) apply (intro edge_expansionD (*‹⟦?S ⊆ verts G; 2 * card ?S ≤ n⟧ ⟹ Λ⇩e * real (card ?S) ≤ real (card (edges_betw ?S (- ?S)))›*)) (*goals: 1. ‹⟦m = card (S ∩ verts G); 2 * m ≤ n⟧ ⟹ S ∩ verts G ⊆ verts G› 2. ‹⟦m = card (S ∩ verts G); 2 * m ≤ n⟧ ⟹ 2 * card (S ∩ verts G) ≤ n› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . also (*calculation: ‹Λ⇩e * real m ≤ real (card (edges_betw S' (- S')))›*) have "... = real (card (edges_betw S (-S)))" unfolding S'_def edges_betw_def (*goal: ‹real (card {a ∈ arcs G. tail G a ∈ S ∩ verts G ∧ head G a ∈ - (S ∩ verts G)}) = real (card {a ∈ arcs G. tail G a ∈ S ∧ head G a ∈ - S})›*) apply (intro arg_cong[where f="real"] (*‹(?x::nat) = (?y::nat) ⟹ real ?x = real ?y›*) arg_cong[where f="card"] (*‹(?x::?'c3 set) = (?y::?'c3 set) ⟹ card ?x = card ?y›*)) (*goal: ‹real (card {a ∈ arcs G. tail G a ∈ S ∩ verts G ∧ head G a ∈ - (S ∩ verts G)}) = real (card {a ∈ arcs G. tail G a ∈ S ∧ head G a ∈ - S})›*) by auto finally (*calculation: ‹Λ⇩e * real m ≤ real (card (edges_betw S (- S)))›*) show "?thesis" (*goal: ‹Λ⇩e * real m ≤ real (card (edges_betw S (- S)))›*) by simp qed lemma edges_betw_sym: "card (edges_betw S T) = card (edges_betw T S)" (is "?L = ?R") proof (-) (*goal: ‹card (edges_betw S T) = card (edges_betw T S)›*) have "?L = (∑a ∈ arcs G. of_bool (tail G a ∈ S ∧ head G a ∈ T))" unfolding edges_betw_def of_bool_def (*goal: ‹card {a::'b::type ∈ arcs G. tail G a ∈ (S::'a::type set) ∧ head G a ∈ (T::'a::type set)} = (∑a::'b::type∈arcs G. if tail G a ∈ S ∧ head G a ∈ T then 1::nat else (0::nat))›*) by (simp add:sum.If_cases (*‹finite ?A ⟹ (∑x∈?A. if ?P x then ?h x else ?g x) = sum ?h (?A ∩ {x. ?P x}) + sum ?g (?A ∩ - {x. ?P x})›*) Int_def (*‹?A ∩ ?B = {x ∈ ?A. x ∈ ?B}›*)) also (*calculation: ‹card (edges_betw (S::'a set) (T::'a set)) = (∑a::'b∈arcs G. of_bool (tail G a ∈ S ∧ head G a ∈ T))›*) have "... = (∑e ∈# edges G. of_bool (fst e ∈ S ∧ snd e ∈ T))" unfolding sum_unfold_sum_mset edges_def arc_to_ends_def (*goal: ‹(∑a∈#mset_set (arcs G). of_bool (tail G a ∈ S ∧ head G a ∈ T)) = (∑e∈#{#(tail G e, head G e). e ∈# mset_set (arcs G)#}. of_bool (fst e ∈ S ∧ snd e ∈ T))›*) by (simp add:image_mset.compositionality (*‹image_mset ?f (image_mset ?g ?multiset) = image_mset (?f ∘ ?g) ?multiset›*) comp_def (*‹?f ∘ ?g = (λx. ?f (?g x))›*)) also (*calculation: ‹card (edges_betw (S::'a::type set) (T::'a::type set)) = (∑e::'a::type × 'a::type∈#edges G. of_bool (fst e ∈ S ∧ snd e ∈ T))›*) have "... = (∑e ∈# edges G. of_bool (snd e ∈ S ∧ fst e ∈ T))" apply (subst edges_sym[OF sym, symmetric] (*‹edges G = {#(y, x). (x, y) ∈# edges G#}›*)) (*goal: ‹(∑e∈#edges G. of_bool (fst e ∈ S ∧ snd e ∈ T)) = (∑e∈#edges G. of_bool (snd e ∈ S ∧ fst e ∈ T))›*) by (simp add:image_mset.compositionality (*‹image_mset ?f (image_mset ?g ?multiset) = image_mset (?f ∘ ?g) ?multiset›*) comp_def (*‹?f ∘ ?g = (λx. ?f (?g x))›*) case_prod_beta (*‹(case ?p of (x, xa) ⇒ ?f x xa) = ?f (fst ?p) (snd ?p)›*)) also (*calculation: ‹card (edges_betw S T) = (∑e∈#edges G. of_bool (snd e ∈ S ∧ fst e ∈ T))›*) have "... = (∑a ∈ arcs G. of_bool (tail G a ∈ T ∧ head G a ∈ S))" unfolding sum_unfold_sum_mset edges_def arc_to_ends_def (*goal: ‹(∑e∈#{#(tail G e, head G e). e ∈# mset_set (arcs G)#}. of_bool (snd e ∈ S ∧ fst e ∈ T)) = (∑a∈#mset_set (arcs G). of_bool (tail G a ∈ T ∧ head G a ∈ S))›*) by (simp add:image_mset.compositionality (*‹image_mset (?f::?'b::type ⇒ ?'c::type) (image_mset (?g::?'a::type ⇒ ?'b::type) (?multiset::?'a::type multiset)) = image_mset (?f ∘ ?g) ?multiset›*) comp_def (*‹(?f::?'b::type ⇒ ?'c::type) ∘ (?g::?'a::type ⇒ ?'b::type) = (λx::?'a::type. ?f (?g x))›*) conj.commute (*‹((?a::bool) ∧ (?b::bool)) = (?b ∧ ?a)›*)) also (*calculation: ‹card (edges_betw S T) = (∑a∈arcs G. of_bool (tail G a ∈ T ∧ head G a ∈ S))›*) have "... = ?R" unfolding edges_betw_def of_bool_def (*goal: ‹(∑a∈arcs G. if tail G a ∈ T ∧ head G a ∈ S then 1 else 0) = card {a ∈ arcs G. tail G a ∈ T ∧ head G a ∈ S}›*) by (simp add:sum.If_cases (*‹finite ?A ⟹ (∑x∈?A. if ?P x then ?h x else ?g x) = sum ?h (?A ∩ {x. ?P x}) + sum ?g (?A ∩ - {x. ?P x})›*) Int_def (*‹?A ∩ ?B = {x ∈ ?A. x ∈ ?B}›*)) finally (*calculation: ‹card (edges_betw S T) = card (edges_betw T S)›*) show "?thesis" (*goal: ‹card (edges_betw S T) = card (edges_betw T S)›*) by simp qed lemma edges_betw_reg: assumes "S ⊆ verts G" shows "card (edges_betw S UNIV) = card S * d" (is "?L = ?R") proof (-) (*goal: ‹card (edges_betw S UNIV) = card S * d›*) have "?L = card (⋃(out_arcs G ` S))" unfolding edges_betw_def out_arcs_def (*goal: ‹card {a::'b::type ∈ arcs G. tail G a ∈ (S::'a::type set) ∧ head G a ∈ UNIV} = card (⋃v::'a::type∈S. {e::'b::type ∈ arcs G. tail G e = v})›*) apply (intro arg_cong[where f="card"] (*‹?x = ?y ⟹ card ?x = card ?y›*)) (*goal: ‹card {a ∈ arcs G. tail G a ∈ S ∧ head G a ∈ UNIV} = card (⋃v∈S. {e ∈ arcs G. tail G e = v})›*) by auto also (*calculation: ‹card (edges_betw S UNIV) = card (⋃ (out_arcs G ` S))›*) have "... = (∑i∈S. card (out_arcs G i))" using finite_subset[OF assms] (*‹finite (verts G) ⟹ finite S›*) unfolding out_arcs_def (*goal: ‹card (⋃v∈S. {e ∈ arcs G. tail G e = v}) = (∑i∈S. card {e ∈ arcs G. tail G e = i})›*) apply (intro card_UN_disjoint (*‹⟦finite ?I; ∀i∈?I. finite (?A i); ∀i∈?I. ∀j∈?I. i ≠ j ⟶ ?A i ∩ ?A j = {}⟧ ⟹ card (⋃ (?A ` ?I)) = (∑i∈?I. card (?A i))›*)) (*goals: 1. ‹(finite (verts G) ⟹ finite S) ⟹ finite S› 2. ‹(finite (verts G) ⟹ finite S) ⟹ ∀i∈S. finite {e ∈ arcs G. tail G e = i}› 3. ‹(finite (verts G) ⟹ finite S) ⟹ ∀i∈S. ∀j∈S. i ≠ j ⟶ {e ∈ arcs G. tail G e = i} ∩ {e ∈ arcs G. tail G e = j} = {}› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*proven 3 subgoals*) . also (*calculation: ‹card (edges_betw S UNIV) = (∑i∈S. card (out_arcs G i))›*) have "... = (∑i∈S. out_degree G i)" unfolding out_degree_def (*goal: ‹(∑i∈S. card (out_arcs G i)) = (∑i∈S. card (out_arcs G i))›*) by simp also (*calculation: ‹card (edges_betw S UNIV) = sum (out_degree G) S›*) have "... = (∑i∈S. d)" using assms (*‹S ⊆ verts G›*) apply (intro sum.cong (*‹⟦?A = ?B; ⋀x. x ∈ ?B ⟹ ?g x = ?h x⟧ ⟹ sum ?g ?A = sum ?h ?B›*) reg (*‹?v ∈ verts G ⟹ out_degree G ?v = d› ‹?v ∈ verts G ⟹ in_degree G ?v = d›*)) (*goals: 1. ‹S ⊆ verts G ⟹ S = S› 2. ‹⋀x. ⟦S ⊆ verts G; x ∈ S⟧ ⟹ x ∈ verts G› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . also (*calculation: ‹card (edges_betw S UNIV) = (∑i∈S. d)›*) have "... = ?R" by simp finally (*calculation: ‹card (edges_betw S UNIV) = card S * d›*) show "?thesis" (*goal: ‹card (edges_betw S UNIV) = card S * d›*) by simp qed text ‹The following proof follows Hoory et al.~@{cite ‹\S 4.5.1› "hoory2006"}.› lemma cheeger_aux_2: assumes "n > 1" shows "Λ⇩e ≥ d*(1-Λ₂)/2" proof (-) (*goal: ‹real d * (1 - Λ₂) / 2 ≤ Λ⇩e›*) have "real (card (edges_betw S (-S))) ≥ (d * (1 - Λ₂) / 2) * real (card S)" if "S ⊆ verts G" "2 * card S ≤ n" for S proof (-) (*goal: ‹real d * (1 - Λ₂) / 2 * real (card S) ≤ real (card (edges_betw S (- S)))›*) let ?ct = "real (card (verts G - S))" let ?cs = "real (card S)" have "card (edges_betw S S)+card (edges_betw S (-S))=card(edges_betw S S∪edges_betw S (-S))" unfolding edges_betw_def (*goal: ‹card {a::'b ∈ arcs G. tail G a ∈ (S::'a set) ∧ head G a ∈ S} + card {a::'b ∈ arcs G. tail G a ∈ S ∧ head G a ∈ - S} = card ({a::'b ∈ arcs G. tail G a ∈ S ∧ head G a ∈ S} ∪ {a::'b ∈ arcs G. tail G a ∈ S ∧ head G a ∈ - S})›*) apply (intro card_Un_disjoint[symmetric] (*‹⟦finite ?A; finite ?B; ?A ∩ ?B = {}⟧ ⟹ card ?A + card ?B = card (?A ∪ ?B)›*)) (*goals: 1. ‹finite {a ∈ arcs G. tail G a ∈ S ∧ head G a ∈ S}› 2. ‹finite {a ∈ arcs G. tail G a ∈ S ∧ head G a ∈ - S}› 3. ‹{a ∈ arcs G. tail G a ∈ S ∧ head G a ∈ S} ∩ {a ∈ arcs G. tail G a ∈ S ∧ head G a ∈ - S} = {}› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*proven 3 subgoals*) . also (*calculation: ‹card (edges_betw S S) + card (edges_betw S (- S)) = card (edges_betw S S ∪ edges_betw S (- S))›*) have "... = card (edges_betw S UNIV)" unfolding edges_betw_def (*goal: ‹card ({a ∈ arcs G. tail G a ∈ S ∧ head G a ∈ S} ∪ {a ∈ arcs G. tail G a ∈ S ∧ head G a ∈ - S}) = card {a ∈ arcs G. tail G a ∈ S ∧ head G a ∈ UNIV}›*) apply (intro arg_cong[where f="card"] (*‹?x = ?y ⟹ card ?x = card ?y›*)) (*goal: ‹card ({a ∈ arcs G. tail G a ∈ S ∧ head G a ∈ S} ∪ {a ∈ arcs G. tail G a ∈ S ∧ head G a ∈ - S}) = card {a ∈ arcs G. tail G a ∈ S ∧ head G a ∈ UNIV}›*) by auto also (*calculation: ‹card (edges_betw S S) + card (edges_betw S (- S)) = card (edges_betw S UNIV)›*) have "... = d * ?cs" using edges_betw_reg[OF that ( 1 )] (*‹card (edges_betw S UNIV) = card S * d›*) by simp finally (*calculation: ‹real (card (edges_betw S S) + card (edges_betw S (- S))) = real d * real (card S)›*) have "card (edges_betw S S) + card (edges_betw S (-S)) = d * ?cs" by simp hence 4: "card (edges_betw S S) = d * ?cs - card (edges_betw S (-S))" by simp have "card(edges_betw S(-S))+card(edges_betw(-S)(-S))=card(edges_betw S(-S)∪edges_betw(-S)(-S))" unfolding edges_betw_def (*goal: ‹card {a ∈ arcs G. tail G a ∈ S ∧ head G a ∈ - S} + card {a ∈ arcs G. tail G a ∈ - S ∧ head G a ∈ - S} = card ({a ∈ arcs G. tail G a ∈ S ∧ head G a ∈ - S} ∪ {a ∈ arcs G. tail G a ∈ - S ∧ head G a ∈ - S})›*) apply (intro card_Un_disjoint[symmetric] (*‹⟦finite ?A; finite ?B; ?A ∩ ?B = {}⟧ ⟹ card ?A + card ?B = card (?A ∪ ?B)›*)) (*goals: 1. ‹finite {a ∈ arcs G. tail G a ∈ S ∧ head G a ∈ - S}› 2. ‹finite {a ∈ arcs G. tail G a ∈ - S ∧ head G a ∈ - S}› 3. ‹{a ∈ arcs G. tail G a ∈ S ∧ head G a ∈ - S} ∩ {a ∈ arcs G. tail G a ∈ - S ∧ head G a ∈ - S} = {}› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*proven 3 subgoals*) . also (*calculation: ‹card (edges_betw (S::'a::type set) (- S)) + card (edges_betw (- S) (- S)) = card (edges_betw S (- S) ∪ edges_betw (- S) (- S))›*) have "... = card (edges_betw UNIV (verts G - S))" unfolding edges_betw_def (*goal: ‹card ({a ∈ arcs G. tail G a ∈ S ∧ head G a ∈ - S} ∪ {a ∈ arcs G. tail G a ∈ - S ∧ head G a ∈ - S}) = card {a ∈ arcs G. tail G a ∈ UNIV ∧ head G a ∈ verts G - S}›*) apply (intro arg_cong[where f="card"] (*‹?x = ?y ⟹ card ?x = card ?y›*)) (*goal: ‹card ({a ∈ arcs G. tail G a ∈ S ∧ head G a ∈ - S} ∪ {a ∈ arcs G. tail G a ∈ - S ∧ head G a ∈ - S}) = card {a ∈ arcs G. tail G a ∈ UNIV ∧ head G a ∈ verts G - S}›*) by auto also (*calculation: ‹card (edges_betw S (- S)) + card (edges_betw (- S) (- S)) = card (edges_betw UNIV (verts G - S))›*) have "... = card (edges_betw (verts G - S) UNIV)" by (intro edges_betw_sym (*‹card (edges_betw ?S ?T) = card (edges_betw ?T ?S)›*)) also (*calculation: ‹card (edges_betw S (- S)) + card (edges_betw (- S) (- S)) = card (edges_betw (verts G - S) UNIV)›*) have "... = d * ?ct" using edges_betw_reg (*‹?S ⊆ verts G ⟹ card (edges_betw ?S UNIV) = card ?S * d›*) by auto finally (*calculation: ‹real (card (edges_betw (S::'a set) (- S)) + card (edges_betw (- S) (- S))) = real d * real (card (verts G - S))›*) have "card (edges_betw S (-S)) + card (edges_betw (-S) (-S)) = d * ?ct" by simp hence 5: "card (edges_betw (-S) (-S)) = d * ?ct - card (edges_betw S (-S))" by simp have 6: "card (edges_betw (-S) S) = card (edges_betw S (-S))" by (intro edges_betw_sym (*‹card (edges_betw ?S ?T) = card (edges_betw ?T ?S)›*)) have "?cs + ?ct =real (card (S ∪ (verts G- S)))" unfolding of_nat_add[symmetric] (*goal: ‹real (card S + card (verts G - S)) = real (card (S ∪ (verts G - S)))›*) using finite_subset[OF that ( 1 )] (*‹finite (verts G) ⟹ finite S›*) apply (intro_cong "[σ₁ of_nat, σ₁ card]" more:card_Un_disjoint[symmetric]) (*goals: 1. ‹(finite (verts G) ⟹ finite S) ⟹ finite S› 2. ‹(finite (verts G) ⟹ finite S) ⟹ finite (verts G - S)› 3. ‹(finite (verts G) ⟹ finite S) ⟹ S ∩ (verts G - S) = {}› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*proven 3 subgoals*) . also (*calculation: ‹real (card S) + real (card (verts G - S)) = real (card (S ∪ (verts G - S)))›*) have "... = real n" unfolding n_def (*goal: ‹real (card (S ∪ (verts G - S))) = real (card (verts G))›*) using that(1) (*‹S ⊆ verts G›*) apply (intro_cong "[σ₁ of_nat, σ₁ card]") (*goal: ‹real (card (S ∪ (verts G - S))) = real (card (verts G))›*) by auto finally (*calculation: ‹real (card S) + real (card (verts G - S)) = real n›*) have 7: "?cs + ?ct = n" by simp define f where "f x = real (card (verts G - S)) * of_bool (x ∈ S) - card S * of_bool (x ∉ S)" for x have "g_inner f (λ_. 1) = ?cs * ?ct - real (card (verts G ∩ {x. x ∉ S})) * ?cs" unfolding g_inner_def f_def (*goal: ‹(∑x∈verts G. (real (card (verts G - S)) * of_bool (x ∈ S) - real (card S * of_bool (x ∉ S))) * conjugate 1) = real (card S) * real (card (verts G - S)) - real (card (verts G ∩ {x. x ∉ S})) * real (card S)›*) using Int_absorb1[OF that ( 1 )] (*‹verts G ∩ S = S›*) by (simp add:sum_subtractf (*‹(∑x∈?A. ?f x - ?g x) = sum ?f ?A - sum ?g ?A›*)) also (*calculation: ‹g_inner f (λ_. 1) = real (card S) * real (card (verts G - S)) - real (card (verts G ∩ {x. x ∉ S})) * real (card S)›*) have "... = ?cs * ?ct - ?ct * ?cs" apply (intro_cong "[σ₂ (-), σ₂ (*), σ₁ of_nat, σ₁ card]") (*goal: ‹real (card S) * real (card (verts G - S)) - real (card (verts G ∩ {x. x ∉ S})) * real (card S) = real (card S) * real (card (verts G - S)) - real (card (verts G - S)) * real (card S)›*) by auto also (*calculation: ‹g_inner (f::'a ⇒ real) (λ_::'a. 1::real) = real (card (S::'a set)) * real (card (verts G - S)) - real (card (verts G - S)) * real (card S)›*) have "... = 0" by simp finally (*calculation: ‹g_inner f (λ_. 1) = 0›*) have 11: " g_inner f (λ_. 1) = 0" by simp have "g_norm f^2 = (∑v∈verts G. f v^2)" unfolding g_norm_sq g_inner_def conjugate_real_def (*goal: ‹(∑x∈verts G. f x * f x) = (∑v∈verts G. (f v)²)›*) by (simp add:power2_eq_square (*‹?a² = ?a * ?a›*)) also (*calculation: ‹(g_norm f)² = (∑v∈verts G. (f v)²)›*) have "...=(∑v∈verts G. ?ct^2*(of_bool (v ∈ S))²)+(∑v∈verts G. ?cs^2*(of_bool (v ∉ S))²)" unfolding f_def power2_diff (*goal: ‹(∑v∈verts G. (real (card (verts G - S)) * of_bool (v ∈ S))² + (real (card S * of_bool (v ∉ S)))² - 2 * (real (card (verts G - S)) * of_bool (v ∈ S)) * real (card S * of_bool (v ∉ S))) = (∑v∈verts G. (real (card (verts G - S)))² * (of_bool (v ∈ S))²) + (∑v∈verts G. (real (card S))² * (of_bool (v ∉ S))²)›*) by (simp add:sum.distrib (*‹(∑x∈?A. ?g x + ?h x) = sum ?g ?A + sum ?h ?A›*) sum_subtractf (*‹(∑x∈?A. ?f x - ?g x) = sum ?f ?A - sum ?g ?A›*) power_mult_distrib (*‹(?a * ?b) ^ ?n = ?a ^ ?n * ?b ^ ?n›*)) also (*calculation: ‹(g_norm f)² = (∑v∈verts G. (real (card (verts G - S)))² * (of_bool (v ∈ S))²) + (∑v∈verts G. (real (card S))² * (of_bool (v ∉ S))²)›*) have "... = real (card (verts G ∩ S))*?ct^2 + real (card (verts G ∩ {v. v ∉ S})) * ?cs^2" unfolding of_bool_def (*goal: ‹(∑v∈verts G. (real (card (verts G - S)))² * (if v ∈ S then 1 else 0)²) + (∑v∈verts G. (real (card S))² * (if v ∉ S then 1 else 0)²) = real (card (verts G ∩ S)) * (real (card (verts G - S)))² + real (card (verts G ∩ {v. v ∉ S})) * (real (card S))²›*) by (simp add:if_distrib (*‹?f (if ?c then ?x else ?y) = (if ?c then ?f ?x else ?f ?y)›*) if_distribR (*‹(if ?b then ?f else ?g) ?x = (if ?b then ?f ?x else ?g ?x)›*) sum.If_cases (*‹finite ?A ⟹ (∑x∈?A. if ?P x then ?h x else ?g x) = sum ?h (?A ∩ {x. ?P x}) + sum ?g (?A ∩ - {x. ?P x})›*)) also (*calculation: ‹(g_norm f)² = real (card (verts G ∩ S)) * (real (card (verts G - S)))² + real (card (verts G ∩ {v. v ∉ S})) * (real (card S))²›*) have "... = real(card S)*(real(card(verts G-S)))² + real(card(verts G-S))*(real(card S))²" using that(1) (*‹S ⊆ verts G›*) apply (intro_cong "[σ₂(+), σ₂ (*), σ₂ power, σ₁ of_nat, σ₁ card]") (*goals: 1. ‹S ⊆ verts G ⟹ verts G ∩ S = S› 2. ‹S ⊆ verts G ⟹ verts G ∩ {v. v ∉ S} = verts G - S› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . also (*calculation: ‹(g_norm f)² = real (card S) * (real (card (verts G - S)))² + real (card (verts G - S)) * (real (card S))²›*) have "... = real(card S)*real (card (verts G -S))*(?cs + ?ct)" by (simp add:power2_eq_square (*‹?a² = ?a * ?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 42 facts*)) also (*calculation: ‹(g_norm (f::'a ⇒ real))² = real (card (S::'a set)) * real (card (verts G - S)) * (real (card S) + real (card (verts G - S)))›*) have "... = real(card S)*real (card (verts G -S))*n" unfolding "7" (*goal: ‹real (card S) * real (card (verts G - S)) * real n = real (card S) * real (card (verts G - S)) * real n›*) by simp finally (*calculation: ‹(g_norm f)² = real (card S) * real (card (verts G - S)) * real n›*) have 9: " g_norm f^2 = real(card S)*real (card (verts G -S))*real n" by simp have "(∑a ∈ arcs G. f (head G a) * f (tail G a)) = (card (edges_betw S S) * ?ct*?ct) + (card (edges_betw (-S) (-S)) * ?cs*?cs) - (card (edges_betw S (-S)) * ?ct*?cs) - (card (edges_betw (-S) S) * ?cs*?ct)" unfolding f_def (*goal: ‹(∑a∈arcs G. (real (card (verts G - S)) * of_bool (head G a ∈ S) - real (card S * of_bool (head G a ∉ S))) * (real (card (verts G - S)) * of_bool (tail G a ∈ S) - real (card S * of_bool (tail G a ∉ S)))) = real (card (edges_betw S S)) * real (card (verts G - S)) * real (card (verts G - S)) + real (card (edges_betw (- S) (- S))) * real (card S) * real (card S) - real (card (edges_betw S (- S))) * real (card (verts G - S)) * real (card S) - real (card (edges_betw (- S) S)) * real (card S) * real (card (verts G - S))›*) by (simp add:of_bool_def (*‹of_bool ?p = (if ?p then 1 else 0)›*) 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 42 facts*) Int_def (*‹?A ∩ ?B = {x ∈ ?A. x ∈ ?B}›*) if_distrib (*‹?f (if ?c then ?x else ?y) = (if ?c then ?f ?x else ?f ?y)›*) if_distribR (*‹(if ?b then ?f else ?g) ?x = (if ?b then ?f ?x else ?g ?x)›*) edges_betw_def (*‹edges_betw ?S ?T = {a ∈ arcs G. tail G a ∈ ?S ∧ head G a ∈ ?T}›*) sum.If_cases (*‹finite ?A ⟹ (∑x∈?A. if ?P x then ?h x else ?g x) = sum ?h (?A ∩ {x. ?P x}) + sum ?g (?A ∩ - {x. ?P x})›*)) also (*calculation: ‹(∑a::'b::type∈arcs G. (f::'a::type ⇒ real) (head G a) * f (tail G a)) = real (card (edges_betw (S::'a::type set) S)) * real (card (verts G - S)) * real (card (verts G - S)) + real (card (edges_betw (- S) (- S))) * real (card S) * real (card S) - real (card (edges_betw S (- S))) * real (card (verts G - S)) * real (card S) - real (card (edges_betw (- S) S)) * real (card S) * real (card (verts G - S))›*) have "... = d*?cs*?ct*(?cs+?ct) - card (edges_betw S (-S))*(?ct*?ct+2*?ct*?cs+?cs*?cs)" unfolding "4" "5" "6" (*goal: ‹(real d * real (card S) - real (card (edges_betw S (- S)))) * real (card (verts G - S)) * real (card (verts G - S)) + (real d * real (card (verts G - S)) - real (card (edges_betw S (- S)))) * real (card S) * real (card S) - real (card (edges_betw S (- S))) * real (card (verts G - S)) * real (card S) - real (card (edges_betw S (- S))) * real (card S) * real (card (verts G - S)) = real d * real (card S) * real (card (verts G - S)) * (real (card S) + real (card (verts G - S))) - real (card (edges_betw S (- S))) * (real (card (verts G - S)) * real (card (verts G - S)) + 2 * real (card (verts G - S)) * real (card S) + real (card S) * real (card S))›*) 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 42 facts*)) also (*calculation: ‹(∑a∈arcs G. f (head G a) * f (tail G a)) = real d * real (card S) * real (card (verts G - S)) * (real (card S) + real (card (verts G - S))) - real (card (edges_betw S (- S))) * (real (card (verts G - S)) * real (card (verts G - S)) + 2 * real (card (verts G - S)) * real (card S) + real (card S) * real (card S))›*) have "... = d*?cs*?ct*n - (?ct+?cs)^2 * card (edges_betw S (-S))" unfolding power2_diff "7" power2_sum (*goal: ‹real d * real (card (S::'a::type set)) * real (card (verts G - S)) * real n - real (card (edges_betw S (- S))) * (real (card (verts G - S)) * real (card (verts G - S)) + (2::real) * real (card (verts G - S)) * real (card S) + real (card S) * real (card S)) = real d * real (card S) * real (card (verts G - S)) * real n - ((real (card (verts G - S)))² + (real (card S))² + (2::real) * real (card (verts G - S)) * real (card S)) * real (card (edges_betw S (- S)))›*) by (simp add: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 39 facts*) power2_eq_square (*‹?a² = ?a * ?a›*)) also (*calculation: ‹(∑a∈arcs G. f (head G a) * f (tail G a)) = real d * real (card S) * real (card (verts G - S)) * real n - (real (card (verts G - S)) + real (card S))² * real (card (edges_betw S (- S)))›*) have "... = d *?cs*?ct*n - n^2 * card (edges_betw S (-S))" using "7" (*‹real (card S) + real (card (verts G - S)) = real n›*) 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 42 facts*)) finally (*calculation: ‹(∑a∈arcs G. f (head G a) * f (tail G a)) = real d * real (card S) * real (card (verts G - S)) * real n - real (n² * card (edges_betw S (- S)))›*) have 8: "(∑a ∈ arcs G. f(head G a)*f(tail G a))=d*?cs*?ct*n-n^2*card(edges_betw S (-S))" by simp have "d*?cs*?ct*n-n^2*card(edges_betw S (-S)) = (∑a ∈ arcs G. f (head G a) * f (tail G a))" unfolding "8" (*goal: ‹real d * real (card S) * real (card (verts G - S)) * real n - real (n² * card (edges_betw S (- S))) = real d * real (card S) * real (card (verts G - S)) * real n - real (n² * card (edges_betw S (- S)))›*) by simp also (*calculation: ‹real d * real (card S) * real (card (verts G - S)) * real n - real (n² * card (edges_betw S (- S))) = (∑a∈arcs G. f (head G a) * f (tail G a))›*) have "... ≤ d * (g_inner f (g_step f))" unfolding g_inner_step_eq (*goal: ‹(∑a∈arcs G. f (head G a) * f (tail G a)) ≤ real d * ((∑a∈arcs G. f (head G a) * f (tail G a)) / real d)›*) using d_gt_0 (*‹0 < d›*) by simp also (*calculation: ‹real d * real (card S) * real (card (verts G - S)) * real n - real (n² * card (edges_betw S (- S))) ≤ real d * g_inner f (g_step f)›*) have "... ≤ d * (Λ₂ * g_norm f^2)" apply (intro mult_left_mono (*‹⟦?a ≤ ?b; 0 ≤ ?c⟧ ⟹ ?c * ?a ≤ ?c * ?b›*) os_expanderD (*‹g_inner ?f (λ_. 1) = 0 ⟹ g_inner ?f (g_step ?f) ≤ Λ₂ * (g_norm ?f)²›*) 11 (*‹g_inner f (λ_. 1) = 0›*)) (*goal: ‹real d * g_inner f (g_step f) ≤ real d * (Λ₂ * (g_norm f)²)›*) by auto also (*calculation: ‹real d * real (card (S::'a set)) * real (card (verts G - S)) * real n - real (n² * card (edges_betw S (- S))) ≤ real d * (Λ₂ * (g_norm (f::'a ⇒ real))²)›*) have "... = d * Λ₂ * ?cs*?ct*n" unfolding "9" (*goal: ‹real d * (Λ₂ * (real (card S) * real (card (verts G - S)) * real n)) = real d * Λ₂ * real (card S) * real (card (verts G - S)) * real n›*) by simp finally (*calculation: ‹real d * real (card S) * real (card (verts G - S)) * real n - real (n² * card (edges_betw S (- S))) ≤ real d * Λ₂ * real (card S) * real (card (verts G - S)) * real n›*) have "d*?cs*?ct*n-n^2*card(edges_betw S (-S)) ≤ d * Λ₂ * ?cs*?ct*n" by simp hence "n * n * card (edges_betw S (-S)) ≥ n * (d * ?cs * ?ct * (1-Λ₂))" by (simp add:power2_eq_square (*‹?a² = ?a * ?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 42 facts*)) hence 10: "n * card (edges_betw S (-S)) ≥ d * ?cs * ?ct * ( 1-Λ₂)" using n_gt_0 (*‹(0::nat) < n›*) by simp have "(d * (1 - Λ₂) / 2) * ?cs = (d * (1-Λ₂) * (1 - 1 / 2)) * ?cs" by simp also (*calculation: ‹real d * (1 - Λ₂) / 2 * real (card S) = real d * (1 - Λ₂) * (1 - 1 / 2) * real (card S)›*) have "... ≤ d * (1-Λ₂) * ((n - ?cs) / n) * ?cs" using that (*‹(S::'a set) ⊆ verts G› ‹(2::nat) * card (S::'a set) ≤ n›*) n_gt_0 (*‹(0::nat) < n›*) "Λ₂_le_1" (*‹Λ₂ ≤ 1›*) apply (intro mult_left_mono (*‹⟦?a ≤ ?b; 0 ≤ ?c⟧ ⟹ ?c * ?a ≤ ?c * ?b›*) mult_right_mono (*‹⟦?a ≤ ?b; 0 ≤ ?c⟧ ⟹ ?a * ?c ≤ ?b * ?c›*) mult_nonneg_nonneg (*‹⟦0 ≤ ?a; 0 ≤ ?b⟧ ⟹ 0 ≤ ?a * ?b›*)) (*goals: 1. ‹⟦S ⊆ verts G; 2 * card S ≤ n; 0 < n; Λ₂ ≤ 1⟧ ⟹ 1 - 1 / 2 ≤ (real n - real (card S)) / real n› 2. ‹⟦S ⊆ verts G; 2 * card S ≤ n; 0 < n; Λ₂ ≤ 1⟧ ⟹ 0 ≤ real d› 3. ‹⟦S ⊆ verts G; 2 * card S ≤ n; 0 < n; Λ₂ ≤ 1⟧ ⟹ 0 ≤ 1 - Λ₂› 4. ‹⟦S ⊆ verts G; 2 * card S ≤ n; 0 < n; Λ₂ ≤ 1⟧ ⟹ 0 ≤ real (card 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*) . also (*calculation: ‹real d * ((1::real) - Λ₂) / (2::real) * real (card (S::'a set)) ≤ real d * ((1::real) - Λ₂) * ((real n - real (card S)) / real n) * real (card S)›*) have "... = (d * (1-Λ₂) * ?ct / n) * ?cs" using "7" (*‹real (card S) + real (card (verts G - S)) = real n›*) by simp also (*calculation: ‹real d * ((1::real) - Λ₂) / (2::real) * real (card (S::'a::type set)) ≤ real d * ((1::real) - Λ₂) * real (card (verts G - S)) / real n * real (card S)›*) have "... = d * ?cs * ?ct * (1-Λ₂) / n" by simp also (*calculation: ‹real d * (1 - Λ₂) / 2 * real (card S) ≤ real d * real (card S) * real (card (verts G - S)) * (1 - Λ₂) / real n›*) have "... ≤ n * card (edges_betw S (-S)) / n" apply (intro divide_right_mono (*‹⟦?a ≤ ?b; 0 ≤ ?c⟧ ⟹ ?a / ?c ≤ ?b / ?c›*) 10 (*‹real d * real (card S) * real (card (verts G - S)) * (1 - Λ₂) ≤ real (n * card (edges_betw S (- S)))›*)) (*goal: ‹real d * real (card S) * real (card (verts G - S)) * (1 - Λ₂) / real n ≤ real (n * card (edges_betw S (- S))) / real n›*) by auto also (*calculation: ‹real d * (1 - Λ₂) / 2 * real (card S) ≤ real (n * card (edges_betw S (- S))) / real n›*) have "... = card (edges_betw S (-S))" using n_gt_0 (*‹0 < n›*) by simp finally (*calculation: ‹real d * (1 - Λ₂) / 2 * real (card S) ≤ real (card (edges_betw S (- S)))›*) show "?thesis" (*goal: ‹real d * (1 - Λ₂) / 2 * real (card S) ≤ real (card (edges_betw S (- S)))›*) by simp qed thus "?thesis" (*goal: ‹real d * (1 - Λ₂) / 2 ≤ Λ⇩e›*) apply (intro edge_expansionI (*‹⟦1 < n; ⋀S. ⟦S ⊆ verts G; 2 * card S ≤ n; S ≠ {}⟧ ⟹ ?α * real (card S) ≤ real (card (edges_betw S (- S)))⟧ ⟹ ?α ≤ Λ⇩e›*) assms (*‹1 < n›*)) (*goal: ‹real d * (1 - Λ₂) / 2 ≤ Λ⇩e›*) by auto qed end lemma surj_onI: assumes "⋀x. x ∈ B ⟹ g x ∈ A ∧ f (g x) = x" shows "B ⊆ f ` A" using assms (*‹(?x::'a) ∈ (B::'a set) ⟹ (g::'a ⇒ 'b) ?x ∈ (A::'b set) ∧ (f::'b ⇒ 'a) (g ?x) = ?x›*) by force lemma find_sorted_bij_1: fixes g :: "'a ⇒ ('b :: linorder)" assumes "finite S" shows "∃f. bij_betw f {..<card S} S ∧ mono_on {..<card S} (g∘ f)" proof (-) (*goal: ‹∃f. bij_betw f {..<card S} S ∧ mono_on {..<card S} (g ∘ f)›*) define h where "h x = from_nat_into S x" for x have h_bij: "bij_betw h {..<card S} S" unfolding h_def (*goal: ‹bij_betw (from_nat_into S) {..<card S} S›*) using bij_betw_from_nat_into_finite[OF assms] (*‹bij_betw (from_nat_into S) {..<card S} S›*) by simp define xs where "xs = sort_key (g ∘ h) [0..<card S]" define f where "f i = h (xs ! i)" for i have l_xs: "length xs = card S" unfolding xs_def (*goal: ‹length (sort_key (g ∘ h) [0..<card S]) = card S›*) by auto have set_xs: "set xs = {..<card S}" unfolding xs_def (*goal: ‹set (sort_key (g ∘ h) [0..<card S]) = {..<card S}›*) by auto have dist_xs: "distinct xs" using l_xs (*‹length xs = card S›*) set_xs (*‹set xs = {..<card S}›*) apply (intro card_distinct (*‹card (set ?xs) = length ?xs ⟹ distinct ?xs›*)) (*goal: ‹distinct xs›*) by simp have sorted_xs: "sorted (map (g ∘ h) xs)" unfolding xs_def (*goal: ‹sorted (map (g ∘ h) (sort_key (g ∘ h) [0..<card S]))›*) using sorted_sort_key (*‹sorted (map ?f (sort_key ?f ?xs))›*) by simp have "(λi. xs ! i) ` {..<card S} = set xs" using l_xs (*‹length xs = card S›*) by (auto simp:in_set_conv_nth (*‹(?x ∈ set ?xs) = (∃i<length ?xs. ?xs ! i = ?x)›*)) also (*calculation: ‹(!) xs ` {..<card S} = set xs›*) have "... = {..<card S}" unfolding set_xs (*goal: ‹{..<card (S::'a::type set)} = {..<card S}›*) by simp finally (*calculation: ‹(!) xs ` {..<card S} = {..<card S}›*) have set_xs': "(λi. xs ! i) ` {..<card S} = {..<card S}" by simp have "f ` {..<card S} = h ` ((λi. xs ! i) ` {..<card S})" unfolding f_def image_image (*goal: ‹(λi. h (xs ! i)) ` {..<card S} = (λx. h (xs ! x)) ` {..<card S}›*) by simp also (*calculation: ‹f ` {..<card S} = h ` (!) xs ` {..<card S}›*) have "... = h ` {..<card S}" unfolding set_xs' (*goal: ‹h ` {..<card S} = h ` {..<card S}›*) by simp also (*calculation: ‹f ` {..<card S} = h ` {..<card S}›*) have "... = S" using bij_betw_imp_surj_on[OF h_bij] (*‹h ` {..<card S} = S›*) by simp finally (*calculation: ‹f ` {..<card S} = S›*) have 0: "f ` {..<card S} = S" by simp have "inj_on ((!) xs) {..<card S}" using dist_xs (*‹distinct xs›*) l_xs (*‹length xs = card S›*) unfolding distinct_conv_nth (*goal: ‹inj_on ((!) xs) {..<card S}›*) apply (intro inj_onI (*‹(⋀x y. ⟦x ∈ ?A; y ∈ ?A; ?f x = ?f y⟧ ⟹ x = y) ⟹ inj_on ?f ?A›*)) (*goal: ‹inj_on ((!) xs) {..<card S}›*) by auto hence "inj_on (h ∘ (λi. xs ! i)) {..<card S}" using set_xs' (*‹(!) xs ` {..<card S} = {..<card S}›*) bij_betw_imp_inj_on[OF h_bij] (*‹inj_on h {..<card S}›*) apply (intro comp_inj_on (*‹⟦inj_on ?f ?A; inj_on ?g (?f ` ?A)⟧ ⟹ inj_on (?g ∘ ?f) ?A›*)) (*goals: 1. ‹⟦inj_on ((!) (xs::nat list)) {..<card (S::'a set)}; (!) xs ` {..<card S} = {..<card S}; inj_on (h::nat ⇒ 'a) {..<card S}⟧ ⟹ inj_on ((!) xs) {..<card S}› 2. ‹⟦inj_on ((!) (xs::nat list)) {..<card (S::'a set)}; (!) xs ` {..<card S} = {..<card S}; inj_on (h::nat ⇒ 'a) {..<card S}⟧ ⟹ inj_on h ((!) xs ` {..<card S})› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . hence 1: "inj_on f {..<card S}" unfolding f_def comp_def (*goal: ‹inj_on (λi. h (xs ! i)) {..<card S}›*) by simp have 2: "mono_on {..<card S} (g ∘ f)" using sorted_nth_mono[OF sorted_xs] (*‹⟦?i ≤ ?j; ?j < length (map (g ∘ h) xs)⟧ ⟹ map (g ∘ h) xs ! ?i ≤ map (g ∘ h) xs ! ?j›*) l_xs (*‹length (xs::nat list) = card (S::'a set)›*) unfolding f_def (*goal: ‹mono_on {..<card S} (g ∘ (λi. h (xs ! i)))›*) apply (intro mono_onI (*‹(⋀r s. ⟦r ∈ ?A; s ∈ ?A; r ≤ s⟧ ⟹ ?f r ≤ ?f s) ⟹ mono_on ?A ?f›*)) (*goal: ‹mono_on {..<card S} (g ∘ (λi. h (xs ! i)))›*) by simp thus "?thesis" (*goal: ‹∃f. bij_betw f {..<card S} S ∧ mono_on {..<card S} (g ∘ f)›*) using "0" (*‹f ` {..<card S} = S›*) "1" (*‹inj_on f {..<card S}›*) "2" (*‹mono_on {..<card S} (g ∘ f)›*) unfolding bij_betw_def (*goal: ‹∃f::nat ⇒ 'a. (inj_on f {..<card (S::'a set)} ∧ f ` {..<card S} = S) ∧ mono_on {..<card S} ((g::'a ⇒ 'b) ∘ f)›*) by auto qed lemma find_sorted_bij_2: fixes g :: "'a ⇒ ('b :: linorder)" assumes "finite S" shows "∃f. bij_betw f S {..<card S} ∧ (∀x y. x ∈ S ∧ y ∈ S ∧ f x < f y ⟶ g x ≤ g y)" proof (-) (*goal: ‹∃f. bij_betw f S {..<card S} ∧ (∀x y. x ∈ S ∧ y ∈ S ∧ f x < f y ⟶ g x ≤ g y)›*) obtain f where f_def: "bij_betw f {..<card S} S" "mono_on {..<card S} (g ∘ f)" (*goal: ‹(⋀f. ⟦bij_betw f {..<card S} S; mono_on {..<card S} (g ∘ f)⟧ ⟹ thesis) ⟹ thesis›*) using find_sorted_bij_1[OF assms] (*‹∃f. bij_betw f {..<card S} S ∧ mono_on {..<card S} (?g ∘ f)›*) by auto define h where "h = the_inv_into {..<card S} f" have bij_h: "bij_betw h S {..<card S}" unfolding h_def (*goal: ‹bij_betw (the_inv_into {..<card S} f) S {..<card S}›*) by (intro bij_betw_the_inv_into (*‹bij_betw ?f ?A ?B ⟹ bij_betw (the_inv_into ?A ?f) ?B ?A›*) f_def (*‹bij_betw f {..<card S} S› ‹mono_on {..<card S} (g ∘ f)›*)) moreover have "g x ≤ g y" if "h x < h y" "x ∈ S" "y ∈ S" for x and y proof (-) (*goal: ‹g x ≤ g y›*) have "h y < card S" "h x < card S" "h x ≤ h y" using bij_betw_apply[OF bij_h] (*‹?a ∈ S ⟹ h ?a ∈ {..<card S}›*) that (*‹h x < h y› ‹x ∈ S› ‹y ∈ S›*) apply - (*goals: 1. ‹⟦⋀a. a ∈ S ⟹ h a ∈ {..<card S}; h x < h y; x ∈ S; y ∈ S⟧ ⟹ h y < card S› 2. ‹⟦⋀a. a ∈ S ⟹ h a ∈ {..<card S}; h x < h y; x ∈ S; y ∈ S⟧ ⟹ h x < card S› 3. ‹⟦⋀a. a ∈ S ⟹ h a ∈ {..<card S}; h x < h y; x ∈ S; y ∈ S⟧ ⟹ h x ≤ h y› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*proven 3 subgoals*) . hence "g (f (h x)) ≤ g (f (h y))" using f_def(2) (*‹mono_on {..<card S} (g ∘ f)›*) unfolding mono_on_def (*goal: ‹(g::'a ⇒ 'b) ((f::nat ⇒ 'a) ((h::'a ⇒ nat) (x::'a))) ≤ g (f (h (y::'a)))›*) by simp moreover have "f ` {..<card S} = S" using bij_betw_imp_surj_on[OF f_def ( 1 )] (*‹f ` {..<card S} = S›*) by simp ultimately show "g x ≤ g y" unfolding h_def (*goal: ‹(g::'a::type ⇒ 'b::linorder) (x::'a::type) ≤ g (y::'a::type)›*) using that (*‹h x < h y› ‹x ∈ S› ‹(y::'a) ∈ (S::'a set)›*) f_the_inv_into_f[OF bij_betw_imp_inj_on [ OF f_def ( 1 ) ]] (*‹(?y::'a) ∈ (f::nat ⇒ 'a) ` {..<card (S::'a set)} ⟹ f (the_inv_into {..<card S} f ?y) = ?y›*) by auto qed ultimately show "?thesis" (*goal: ‹∃f. bij_betw f S {..<card S} ∧ (∀x y. x ∈ S ∧ y ∈ S ∧ f x < f y ⟶ g x ≤ g y)›*) by auto qed context regular_graph_tts begin text ‹Normalized Laplacian of the graph› definition L where "L = mat 1 - A" lemma L_pos_semidefinite: fixes v :: "real ^'n" shows "v ∙ (L *v v) ≥ 0" proof (-) (*goal: ‹0 ≤ v ∙ (L *v v)›*) have "0 = v ∙ v - norm v^2" unfolding power2_norm_eq_inner (*goal: ‹(0::real) = (v::(real, 'n) Finite_Cartesian_Product.vec) ∙ v - v ∙ v›*) by simp also (*calculation: ‹0 = v ∙ v - (norm v)²›*) have "... ≤ v ∙ v - abs (v ∙ (A *v v))" apply (intro diff_mono (*‹⟦?a ≤ ?b; ?d ≤ ?c⟧ ⟹ ?a - ?c ≤ ?b - ?d›*) rayleigh_bound (*‹¦?v ∙ (A *v ?v)¦ ≤ (norm ?v)²›*)) (*goal: ‹(v::(real, 'n) Finite_Cartesian_Product.vec) ∙ v - (norm v)² ≤ v ∙ v - ¦v ∙ (A *v v)¦›*) by auto also (*calculation: ‹0 ≤ v ∙ v - ¦v ∙ (A *v v)¦›*) have "... ≤ v ∙ v - v ∙ (A *v v)" apply (intro diff_mono (*‹⟦?a ≤ ?b; ?d ≤ ?c⟧ ⟹ ?a - ?c ≤ ?b - ?d›*)) (*goals: 1. ‹v ∙ v ≤ v ∙ v› 2. ‹v ∙ (A *v v) ≤ ¦v ∙ (A *v v)¦› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . also (*calculation: ‹0 ≤ v ∙ v - v ∙ (A *v v)›*) have "... = v ∙ (L *v v)" unfolding L_def (*goal: ‹(v::(real, 'n) Finite_Cartesian_Product.vec) ∙ v - v ∙ (A *v v) = v ∙ ((mat (1::real) - A) *v v)›*) 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 42 facts*)) finally (*calculation: ‹0 ≤ v ∙ (L *v v)›*) show "?thesis" (*goal: ‹0 ≤ v ∙ (L *v v)›*) by simp qed text ‹The following proof follows Hoory et al.~@{cite ‹\S 4.5.2› "hoory2006"}.› lemma cheeger_aux_1: assumes "n > 1" shows "Λ⇩e ≤ d * sqrt (2 * (1-Λ₂))" proof (-) (*goal: ‹Λ⇩e ≤ real d * sqrt (2 * (1 - Λ₂))›*) obtain v where v_def: "v ∙ 1 = 0" "v ≠ 0" "A *v v = Λ₂ *s v" (*goal: ‹(⋀v. ⟦v ∙ 1 = 0; v ≠ 0; A *v v = Λ₂ *s v⟧ ⟹ thesis) ⟹ thesis›*) using "Λ₂_eq_γ₂" (*‹Λ₂ = γ₂ TYPE('n)›*) "γ₂_ev"[OF assms] (*‹∃v. v ∙ 1 = 0 ∧ v ≠ 0 ∧ A *v v = γ₂ TYPE('n) *s v›*) by auto have False if "2*card {i. (1 *s v) $h i > 0} > n" "2*card {i. ((-1) *s v) $h i > 0} > n" proof (-) (*goal: ‹False›*) have "2 * n = n + n" by simp also (*calculation: ‹2 * n = n + n›*) have "... <2 * card {i. (1 *s v) $h i > 0} + 2 * card {i. ((-1) *s v) $h i > 0}" by (intro add_strict_mono (*‹⟦?a < ?b; ?c < ?d⟧ ⟹ ?a + ?c < ?b + ?d›*) that (*‹n < 2 * card {i. 0 < (1 *s v) $h i}› ‹n < 2 * card {i. 0 < (- 1 *s v) $h i}›*)) also (*calculation: ‹2 * n < 2 * card {i. 0 < (1 *s v) $h i} + 2 * card {i. 0 < (- 1 *s v) $h i}›*) have "... = 2 * (card {i. (1 *s v) $h i > 0} + card {i. ((-1) *s v) $h i > 0})" by simp also (*calculation: ‹2 * n < 2 * (card {i. 0 < (1 *s v) $h i} + card {i. 0 < (- 1 *s v) $h i})›*) have "... = 2 * (card ({i. (1 *s v) $h i > 0} ∪ {i. ((-1) *s v) $h i > 0}))" apply (intro arg_cong2[where f="(*)"] (*‹⟦?a = ?b; ?c = ?d⟧ ⟹ ?a * ?c = ?b * ?d›*) card_Un_disjoint[symmetric] (*‹⟦finite ?A; finite ?B; ?A ∩ ?B = {}⟧ ⟹ card ?A + card ?B = card (?A ∪ ?B)›*)) (*goals: 1. ‹(2::nat) = (2::nat)› 2. ‹finite {i::'n. (0::real) < ((1::real) *s (v::(real, 'n) Finite_Cartesian_Product.vec)) $h i}› 3. ‹finite {i::'n. (0::real) < (- (1::real) *s (v::(real, 'n) Finite_Cartesian_Product.vec)) $h i}› 4. ‹{i::'n. (0::real) < ((1::real) *s (v::(real, 'n) Finite_Cartesian_Product.vec)) $h i} ∩ {i::'n. (0::real) < (- (1::real) *s v) $h 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]) (*proven 4 subgoals*) . also (*calculation: ‹2 * n < 2 * card ({i. 0 < (1 *s v) $h i} ∪ {i. 0 < (- 1 *s v) $h i})›*) have "... ≤ 2 * (card (UNIV :: 'n set))" apply (intro mult_left_mono (*‹⟦(?a::?'a) ≤ (?b::?'a); (0::?'a) ≤ (?c::?'a)⟧ ⟹ ?c * ?a ≤ ?c * ?b›*) card_mono (*‹⟦finite (?B::?'a set); (?A::?'a set) ⊆ ?B⟧ ⟹ card ?A ≤ card ?B›*)) (*goals: 1. ‹finite UNIV› 2. ‹{i::'n. (0::real) < ((1::real) *s (v::(real, 'n) Finite_Cartesian_Product.vec)) $h i} ∪ {i::'n. (0::real) < (- (1::real) *s v) $h i} ⊆ UNIV› 3. ‹(0::nat) ≤ (2::nat)› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*proven 3 subgoals*) . finally (*calculation: ‹(2::nat) * n < (2::nat) * CARD('n::finite)›*) have "2 * n < 2 * n" unfolding n_def card_n (*goal: ‹2 * card (verts G) < 2 * card (verts G)›*) by auto thus "?thesis" (*goal: ‹False›*) by simp qed then obtain β :: real where "β_def": "β = 1 ∨ β=(-1)" "2* card {i. (β *s v) $h i > 0 } ≤ n" (*goal: ‹(⋀β. ⟦β = 1 ∨ β = - 1; 2 * card {i. 0 < (β *s v) $h i} ≤ n⟧ ⟹ thesis) ⟹ thesis›*) unfolding not_le[symmetric] (*goal: ‹(⋀β. ⟦β = 1 ∨ β = - 1; 2 * card {i. ¬ (β *s v) $h i ≤ 0} ≤ n⟧ ⟹ thesis) ⟹ thesis›*) by blast define g where "g = β *s v" have g_orth: "g ∙ 1 = 0" unfolding g_def (*goal: ‹((β::real) *s (v::(real, 'n::finite) Finite_Cartesian_Product.vec)) ∙ (1::(real, 'n::finite) Finite_Cartesian_Product.vec) = (0::real)›*) using v_def(1) (*‹v ∙ 1 = 0›*) by (simp add: scalar_mult_eq_scaleR (*‹(*s) ≡ (*⇩R)›*)) have g_nz: "g ≠ 0" unfolding g_def (*goal: ‹β *s v ≠ 0›*) using "β_def"(1) (*‹β = 1 ∨ β = - 1›*) v_def(2) (*‹v ≠ 0›*) by auto have g_ev: "A *v g = Λ₂ *s g" unfolding g_def scalar_mult_eq_scaleR matrix_vector_mult_scaleR v_def(3) (*goal: ‹(β::real) *⇩R Λ₂ *⇩R (v::(real, 'n) Finite_Cartesian_Product.vec) = Λ₂ *⇩R β *⇩R v›*) by auto have g_supp: "2 * card { i. g $h i > 0 } ≤ n" unfolding g_def (*goal: ‹2 * card {i. 0 < (β *s v) $h i} ≤ n›*) using "β_def"(2) (*‹2 * card {i. 0 < (β *s v) $h i} ≤ n›*) by auto define f where "f = (χ i. max (g $h i) 0)" have "(L *v f) $h i ≤ (1-Λ₂) * g $h i" (is "?L ≤ ?R") if "g $h i > 0" for i proof (-) (*goal: ‹(L *v (f::(real, 'n) Finite_Cartesian_Product.vec)) $h (i::'n) ≤ ((1::real) - Λ₂) * (g::(real, 'n) Finite_Cartesian_Product.vec) $h i›*) have "?L = f $h i - (A *v f) $h i" unfolding L_def (*goal: ‹((mat 1 - A) *v f) $h i = f $h i - (A *v f) $h i›*) 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 42 facts*)) also (*calculation: ‹(L *v f) $h i = f $h i - (A *v f) $h i›*) have "... = g $h i - (∑j ∈ UNIV. A $h i $h j * f $h j)" unfolding matrix_vector_mult_def f_def (*goal: ‹(χi. max (g $h i) 0) $h i - (χi. ∑j∈UNIV. A $h i $h j * (χi. max (g $h i) 0) $h j) $h i = g $h i - (∑j∈UNIV. A $h i $h j * (χi. max (g $h i) 0) $h j)›*) using that (*‹0 < g $h i›*) by auto also (*calculation: ‹(L *v f) $h i = g $h i - (∑j∈UNIV. A $h i $h j * f $h j)›*) have "... ≤ g $h i - (∑j ∈ UNIV. A $h i $h j * g $h j)" unfolding f_def A_def (*goal: ‹g $h i - (∑j∈UNIV. (χi j. real (count (edges G) (enum_verts j, enum_verts i)) / real d) $h i $h j * (χi. max (g $h i) 0) $h j) ≤ g $h i - (∑j∈UNIV. (χi j. real (count (edges G) (enum_verts j, enum_verts i)) / real d) $h i $h j * g $h j)›*) apply (intro diff_mono (*‹⟦?a ≤ ?b; ?d ≤ ?c⟧ ⟹ ?a - ?c ≤ ?b - ?d›*) sum_mono (*‹(⋀i. i ∈ ?K ⟹ ?f i ≤ ?g i) ⟹ sum ?f ?K ≤ sum ?g ?K›*) mult_left_mono (*‹⟦?a ≤ ?b; 0 ≤ ?c⟧ ⟹ ?c * ?a ≤ ?c * ?b›*)) (*goals: 1. ‹g $h i ≤ g $h i› 2. ‹⋀j. j ∈ UNIV ⟹ g $h j ≤ (χi. max (g $h i) 0) $h j› 3. ‹⋀j. j ∈ UNIV ⟹ 0 ≤ (χi j. real (count (edges G) (enum_verts j, enum_verts i)) / real d) $h i $h j› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*proven 3 subgoals*) . also (*calculation: ‹(L *v f) $h i ≤ g $h i - (∑j∈UNIV. A $h i $h j * g $h j)›*) have "... = g $h i - (A *v g) $h i" unfolding matrix_vector_mult_def (*goal: ‹g $h i - (∑j∈UNIV. A $h i $h j * g $h j) = g $h i - (χi. ∑j∈UNIV. A $h i $h j * g $h j) $h i›*) by simp also (*calculation: ‹(L *v f) $h i ≤ g $h i - (A *v g) $h i›*) have "... = (1-Λ₂) * g $h i" unfolding g_ev (*goal: ‹g $h i - (Λ₂ *s g) $h i = (1 - Λ₂) * g $h i›*) 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 42 facts*)) finally (*calculation: ‹(L *v f) $h i ≤ (1 - Λ₂) * g $h i›*) show "?thesis" (*goal: ‹(L *v f) $h i ≤ (1 - Λ₂) * g $h i›*) by simp qed moreover have "f $h i ≠ 0 ⟹ g $h i > 0 " for i unfolding f_def (*goal: ‹(χi. max (g $h i) 0) $h i ≠ 0 ⟹ 0 < g $h i›*) by simp ultimately have 0: "(L *v f) $h i ≤ (1-Λ₂) * g $h i ∨ f $h i = 0" for i by auto text ‹Part (i) in Hoory et al. (\S 4.5.2) but the operator L here is normalized.› have "f ∙ (L *v f) = (∑i∈UNIV. (L *v f) $h i * f $h i)" unfolding inner_vec_def (*goal: ‹(∑i∈UNIV. f $h i ∙ (L *v f) $h i) = (∑i∈UNIV. (L *v f) $h i * f $h i)›*) by (simp add: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 39 facts*)) also (*calculation: ‹f ∙ (L *v f) = (∑i∈UNIV. (L *v f) $h i * f $h i)›*) have "... ≤ (∑i∈UNIV. ((1-Λ₂) * g $h i) * f $h i)" apply (intro sum_mono (*‹(⋀i::?'b. i ∈ (?K::?'b set) ⟹ (?f::?'b ⇒ ?'a) i ≤ (?g::?'b ⇒ ?'a) i) ⟹ sum ?f ?K ≤ sum ?g ?K›*) mult_right_mono' (*‹⟦(0::real) ≤ (?y::real); (?x::real) ≤ (?z::real) ∨ ?y = (0::real)⟧ ⟹ ?x * ?y ≤ ?z * ?y›*) 0 (*‹(L *v (f::(real, 'n) Finite_Cartesian_Product.vec)) $h (?i6::'n) ≤ ((1::real) - Λ₂) * (g::(real, 'n) Finite_Cartesian_Product.vec) $h ?i6 ∨ f $h ?i6 = (0::real)›*)) (*goal: ‹(∑i∈UNIV. (L *v f) $h i * f $h i) ≤ (∑i∈UNIV. (1 - Λ₂) * g $h i * f $h i)›*) by (simp add:f_def (*‹f = (χi. max (g $h i) 0)›*)) also (*calculation: ‹f ∙ (L *v f) ≤ (∑i∈UNIV. (1 - Λ₂) * g $h i * f $h i)›*) have "... = (∑i∈UNIV. (1-Λ₂) * f $h i * f $h i)" unfolding f_def (*goal: ‹(∑i∈UNIV. (1 - Λ₂) * g $h i * (χi. max (g $h i) 0) $h i) = (∑i∈UNIV. (1 - Λ₂) * (χi. max (g $h i) 0) $h i * (χi. max (g $h i) 0) $h i)›*) apply (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›*) refl (*‹(?t::?'a) = ?t›*)) (*goal: ‹(∑i∈UNIV. (1 - Λ₂) * g $h i * (χi. max (g $h i) 0) $h i) = (∑i∈UNIV. (1 - Λ₂) * (χi. max (g $h i) 0) $h i * (χi. max (g $h i) 0) $h i)›*) by auto also (*calculation: ‹f ∙ (L *v f) ≤ (∑i∈UNIV. (1 - Λ₂) * f $h i * f $h i)›*) have "... = (1-Λ₂) * (f ∙ f)" unfolding inner_vec_def (*goal: ‹(∑i::'n::finite∈UNIV. ((1::real) - Λ₂) * (f::(real, 'n::finite) Finite_Cartesian_Product.vec) $h i * f $h i) = ((1::real) - Λ₂) * (∑i::'n::finite∈UNIV. f $h i ∙ f $h i)›*) by (simp add:sum_distrib_left (*‹?r * sum ?f ?A = (∑n∈?A. ?r * ?f 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 39 facts*)) also (*calculation: ‹(f::(real, 'n) Finite_Cartesian_Product.vec) ∙ (L *v f) ≤ ((1::real) - Λ₂) * (f ∙ f)›*) have "... = (1 - Λ₂) * norm f^2" by (simp add: power2_norm_eq_inner (*‹(norm ?x)² = ?x ∙ ?x›*)) finally (*calculation: ‹(f::(real, 'n::finite) Finite_Cartesian_Product.vec) ∙ (L *v f) ≤ ((1::real) - Λ₂) * (norm f)²›*) have h_part_i: "f ∙ (L *v f) ≤ (1 - Λ₂) * norm f^2" by simp define f' where "f' x = f $h (enum_verts_inv x)" for x have f'_alt: "f = (χ i. f' (enum_verts i))" unfolding f'_def Rep_inverse (*goal: ‹f = (χi. f $h i)›*) by simp define B⇩f where "B⇩f = (∑a∈arcs G. ¦f' (tail G a)^2-f' (head G a)^2¦)" have "(x + y)^2 ≤ 2 * (x^2 + y^2)" for x :: real and y :: real proof (-) (*goal: ‹((x::real) + (y::real))² ≤ (2::real) * (x² + y²)›*) have "(x + y)^2 = (x^2 + y^2) + 2 * x * y" unfolding power2_sum (*goal: ‹x² + y² + 2 * x * y = x² + y² + 2 * x * y›*) by simp also (*calculation: ‹(x + y)² = x² + y² + 2 * x * y›*) have "... ≤ (x^2 + y^2) + (x^2 + y^2)" apply (intro add_mono (*‹⟦?a ≤ ?b; ?c ≤ ?d⟧ ⟹ ?a + ?c ≤ ?b + ?d›*) sum_squares_bound (*‹2 * ?x * ?y ≤ ?x² + ?y²›*)) (*goals: 1. ‹x² ≤ x²› 2. ‹y² ≤ y²› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . finally (*calculation: ‹(x + y)² ≤ x² + y² + (x² + y²)›*) show "?thesis" (*goal: ‹(x + y)² ≤ 2 * (x² + y²)›*) by simp qed hence "(∑a∈arcs G.(f'(tail G a)+ f'(head G a))²)≤(∑a∈arcs G. 2*(f'(tail G a)^2+f'(head G a)^2))" apply (intro sum_mono (*‹(⋀i. i ∈ ?K ⟹ ?f i ≤ ?g i) ⟹ sum ?f ?K ≤ sum ?g ?K›*)) (*goal: ‹(∑a∈arcs G. (f' (tail G a) + f' (head G a))²) ≤ (∑a∈arcs G. 2 * ((f' (tail G a))² + (f' (head G a))²))›*) by auto also (*calculation: ‹(∑a∈arcs G. (f' (tail G a) + f' (head G a))²) ≤ (∑a∈arcs G. 2 * ((f' (tail G a))² + (f' (head G a))²))›*) have "... = 2*((∑a∈arcs G. f'(tail G a)^2) + (∑a∈arcs G. f'(head G a)^2))" by (simp add:sum_distrib_left (*‹?r * sum ?f ?A = (∑n∈?A. ?r * ?f n)›*)) also (*calculation: ‹(∑a∈arcs G. (f' (tail G a) + f' (head G a))²) ≤ 2 * ((∑a∈arcs G. (f' (tail G a))²) + (∑a∈arcs G. (f' (head G a))²))›*) have "... = 4 * d * g_norm f'^2" unfolding sum_arcs_tail[where f = "λx. f' x^2"] sum_arcs_head[where f = "λx. f' x^2"] g_norm_sq g_inner_def (*goal: ‹(2::real) * (real d * (∑v::'a∈verts G. ((f'::'a ⇒ real) v)²) + real d * (∑v::'a∈verts G. (f' v)²)) = real ((4::nat) * d) * (∑x::'a∈verts G. f' x * conjugate (f' x))›*) by (simp add:power2_eq_square (*‹?a² = ?a * ?a›*)) also (*calculation: ‹(∑a∈arcs G. (f' (tail G a) + f' (head G a))²) ≤ real (4 * d) * (g_norm f')²›*) have "... = 4 * d * norm f^2" unfolding g_norm_conv f'_alt (*goal: ‹real ((4::nat) * d) * (norm (χi::'n. (f'::'a ⇒ real) (enum_verts i)))² = real ((4::nat) * d) * (norm (χi::'n. f' (enum_verts i)))²›*) by simp finally (*calculation: ‹(∑a∈arcs G. (f' (tail G a) + f' (head G a))²) ≤ real (4 * d) * (norm f)²›*) have 1: "(∑i∈arcs G. (f' (tail G i) + f' (head G i))²) ≤ 4*d* norm f^2" by simp have "(∑a∈arcs G. (f' (tail G a) - f' (head G a))²) = (∑a∈arcs G. (f' (tail G a))²) + (∑a∈arcs G. (f' (head G a))²) - 2* (∑a∈arcs G. f' (tail G a) * f' (head G a))" unfolding power2_diff (*goal: ‹(∑a∈arcs G. (f' (tail G a))² + (f' (head G a))² - 2 * f' (tail G a) * f' (head G a)) = (∑a∈arcs G. (f' (tail G a))²) + (∑a∈arcs G. (f' (head G a))²) - 2 * (∑a∈arcs G. f' (tail G a) * f' (head G a))›*) by (simp add:sum_subtractf (*‹(∑x∈?A. ?f x - ?g x) = sum ?f ?A - sum ?g ?A›*) sum_distrib_left (*‹?r * sum ?f ?A = (∑n∈?A. ?r * ?f 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 39 facts*)) also (*calculation: ‹(∑a∈arcs G. (f' (tail G a) - f' (head G a))²) = (∑a∈arcs G. (f' (tail G a))²) + (∑a∈arcs G. (f' (head G a))²) - 2 * (∑a∈arcs G. f' (tail G a) * f' (head G a))›*) have "... = 2 * (d * (∑v∈verts G. (f' v)²) - (∑a∈arcs G. f' (tail G a) * f' (head G a)))" unfolding sum_arcs_tail[where f = "λx. f' x^2"] sum_arcs_head[where f = "λx. f' x^2"] (*goal: ‹real d * (∑v::'a∈verts G. ((f'::'a ⇒ real) v)²) + real d * (∑v::'a∈verts G. (f' v)²) - (2::real) * (∑a::'b∈arcs G. f' (tail G a) * f' (head G a)) = (2::real) * (real d * (∑v::'a∈verts G. (f' v)²) - (∑a::'b∈arcs G. f' (tail G a) * f' (head G a)))›*) by simp also (*calculation: ‹(∑a∈arcs G. (f' (tail G a) - f' (head G a))²) = 2 * (real d * (∑v∈verts G. (f' v)²) - (∑a∈arcs G. f' (tail G a) * f' (head G a)))›*) have "... = 2 * (d * g_inner f' f' - d * g_inner f' (g_step f'))" unfolding g_inner_step_eq (*goal: ‹2 * (real d * (∑v∈verts G. (f' v)²) - (∑a∈arcs G. f' (tail G a) * f' (head G a))) = 2 * (real d * g_inner f' f' - real d * ((∑a∈arcs G. f' (head G a) * f' (tail G a)) / real d))›*) using d_gt_0 (*‹0 < d›*) apply (intro_cong "[σ₂ (*), σ₂ (-)]") (*goals: 1. ‹(0::nat) < d ⟹ (∑v::'a∈verts G. ((f'::'a ⇒ real) v)²) = g_inner f' f'› 2. ‹(0::nat) < d ⟹ (∑a::'b∈arcs G. (f'::'a ⇒ real) (tail G a) * f' (head G a)) = real d * ((∑a::'b∈arcs G. f' (head G a) * f' (tail G a)) / real d)› discuss goal 1*) apply ((auto simp:power2_eq_square (*‹?a² = ?a * ?a›*) g_inner_def (*‹g_inner ?f ?g = (∑x∈verts G. ?f x * conjugate (?g 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 39 facts*))[1]) (*discuss goal 2*) apply ((auto simp:power2_eq_square (*‹?a² = ?a * ?a›*) g_inner_def (*‹g_inner ?f ?g = (∑x∈verts G. ?f x * conjugate (?g 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 39 facts*))[1]) (*proven 2 subgoals*) . also (*calculation: ‹(∑a∈arcs G. (f' (tail G a) - f' (head G a))²) = 2 * (real d * g_inner f' f' - real d * g_inner f' (g_step f'))›*) have "... = 2 * d * (g_inner f' f' -g_inner f' (g_step f'))" 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 42 facts*)) also (*calculation: ‹(∑a∈arcs G. (f' (tail G a) - f' (head G a))²) = real (2 * d) * (g_inner f' f' - g_inner f' (g_step f'))›*) have "... = 2 * d * (f ∙ f - f ∙ (A *v f))" unfolding g_inner_conv g_step_conv f'_alt (*goal: ‹real (2 * d) * ((χi. f' (enum_verts i)) ∙ (χi. f' (enum_verts i)) - (χi. f' (enum_verts i)) ∙ (A *v (χi. f' (enum_verts i)))) = real (2 * d) * ((χi. f' (enum_verts i)) ∙ (χi. f' (enum_verts i)) - (χi. f' (enum_verts i)) ∙ (A *v (χi. f' (enum_verts i))))›*) by simp also (*calculation: ‹(∑a∈arcs G. (f' (tail G a) - f' (head G a))²) = real (2 * d) * (f ∙ f - f ∙ (A *v f))›*) have "... = 2 * d * (f ∙ (L *v f))" unfolding L_def (*goal: ‹real ((2::nat) * d) * ((f::(real, 'n) Finite_Cartesian_Product.vec) ∙ f - f ∙ (A *v f)) = real ((2::nat) * d) * (f ∙ ((mat (1::real) - A) *v f))›*) 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 42 facts*)) finally (*calculation: ‹(∑a∈arcs G. (f' (tail G a) - f' (head G a))²) = real (2 * d) * (f ∙ (L *v f))›*) have 2: "(∑a∈arcs G. (f' (tail G a) - f' (head G a))²) = 2 * d * (f ∙ (L *v f))" by simp have "B⇩f = (∑a∈arcs G. ¦f' (tail G a)+f' (head G a)¦*¦f' (tail G a)-f' (head G a)¦)" unfolding "B⇩f_def" abs_mult[symmetric] (*goal: ‹(∑a∈arcs G. ¦(f' (tail G a))² - (f' (head G a))²¦) = (∑a∈arcs G. ¦(f' (tail G a) + f' (head G a)) * (f' (tail G a) - f' (head G 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 42 facts*) power2_eq_square (*‹?a² = ?a * ?a›*)) also (*calculation: ‹B⇩f = (∑a∈arcs G. ¦f' (tail G a) + f' (head G a)¦ * ¦f' (tail G a) - f' (head G a)¦)›*) have "...≤ L2_set (λa. f'(tail G a) + f'(head G a)) (arcs G) * L2_set (λa. f' (tail G a) - f'(head G a)) (arcs G)" by (intro L2_set_mult_ineq (*‹(∑i∈?A. ¦?f i¦ * ¦?g i¦) ≤ L2_set ?f ?A * L2_set ?g ?A›*)) also (*calculation: ‹B⇩f ≤ L2_set (λa. f' (tail G a) + f' (head G a)) (arcs G) * L2_set (λa. f' (tail G a) - f' (head G a)) (arcs G)›*) have "... ≤ sqrt (4*d* norm f^2) * sqrt (2 * d * (f ∙ (L *v f)))" unfolding L2_set_def "2" (*goal: ‹sqrt (∑i∈arcs G. (f' (tail G i) + f' (head G i))²) * sqrt (real (2 * d) * (f ∙ (L *v f))) ≤ sqrt (real (4 * d) * (norm f)²) * sqrt (real (2 * d) * (f ∙ (L *v f)))›*) apply (intro mult_right_mono (*‹⟦?a ≤ ?b; 0 ≤ ?c⟧ ⟹ ?a * ?c ≤ ?b * ?c›*) iffD2[OF real_sqrt_le_iff] (*‹?x1 ≤ ?y1 ⟹ sqrt ?x1 ≤ sqrt ?y1›*) 1 (*‹(∑i∈arcs G. (f' (tail G i) + f' (head G i))²) ≤ real (4 * d) * (norm f)²›*) real_sqrt_ge_zero (*‹0 ≤ ?x ⟹ 0 ≤ sqrt ?x›*) mult_nonneg_nonneg (*‹⟦0 ≤ ?a; 0 ≤ ?b⟧ ⟹ 0 ≤ ?a * ?b›*) L_pos_semidefinite (*‹0 ≤ ?v ∙ (L *v ?v)›*)) (*goal: ‹sqrt (∑i∈arcs G. (f' (tail G i) + f' (head G i))²) * sqrt (real (2 * d) * (f ∙ (L *v f))) ≤ sqrt (real (4 * d) * (norm f)²) * sqrt (real (2 * d) * (f ∙ (L *v f)))›*) by auto also (*calculation: ‹B⇩f ≤ sqrt (real (4 * d) * (norm f)²) * sqrt (real (2 * d) * (f ∙ (L *v f)))›*) have "... = 2 * sqrt 2 * d * norm f * sqrt (f ∙ (L *v f))" by (simp add:real_sqrt_mult (*‹sqrt (?x * ?y) = sqrt ?x * sqrt ?y›*)) finally (*calculation: ‹(B⇩f::real) ≤ (2::real) * sqrt (2::real) * real d * norm (f::(real, 'n) Finite_Cartesian_Product.vec) * sqrt (f ∙ (L *v f))›*) have hoory_4_12: "B⇩f ≤ 2 * sqrt 2 * d * norm f * sqrt (f ∙ (L *v f))" by simp text ‹The last statement corresponds to Lemma 4.12 in Hoory et al.› obtain ρ :: "'a ⇒ nat" where "ρ_bij": "bij_betw ρ (verts G) {..<n}" and "ρ_dec": "⋀x y. x ∈ verts G ⟹ y ∈ verts G ⟹ ρ x < ρ y ⟹ f' x ≥ f' y" (*goal: ‹(⋀ρ. ⟦bij_betw ρ (verts G) {..<n}; ⋀x y. ⟦x ∈ verts G; y ∈ verts G; ρ x < ρ y⟧ ⟹ f' y ≤ f' x⟧ ⟹ thesis) ⟹ thesis›*) unfolding n_def (*goal: ‹(⋀ρ::'a ⇒ nat. ⟦bij_betw ρ (verts G) {..<card (verts G)}; ⋀(x::'a) y::'a. ⟦x ∈ verts G; y ∈ verts G; ρ x < ρ y⟧ ⟹ (f'::'a ⇒ real) y ≤ f' x⟧ ⟹ thesis::bool) ⟹ thesis›*) using find_sorted_bij_2[where S = "verts G" and g = "(λx. - f' x)"] (*‹finite (verts G) ⟹ ∃f. bij_betw f (verts G) {..<card (verts G)} ∧ (∀x y. x ∈ verts G ∧ y ∈ verts G ∧ f x < f y ⟶ - f' x ≤ - f' y)›*) by auto define φ where "φ = the_inv_into (verts G) ρ" have "φ_bij": "bij_betw φ {..<n} (verts G)" unfolding "φ_def" (*goal: ‹bij_betw (the_inv_into (verts G) ρ) {..<n} (verts G)›*) by (intro bij_betw_the_inv_into (*‹bij_betw ?f ?A ?B ⟹ bij_betw (the_inv_into ?A ?f) ?B ?A›*) ρ_bij (*‹bij_betw ρ (verts G) {..<n}›*)) have "edges G = {# e ∈# edges G . ρ(fst e) ≠ ρ(snd e) ∨ ρ(fst e) = ρ(snd e) #}" by simp also (*calculation: ‹edges G = {#e ∈# edges G. ρ (fst e) ≠ ρ (snd e) ∨ ρ (fst e) = ρ (snd e)#}›*) have "... = {# e ∈# edges G . ρ(fst e) ≠ ρ(snd e) #} + {#e∈#edges G. ρ(fst e)=ρ(snd e)#}" by (simp add:filter_mset_ex_predicates (*‹(⋀x. ¬ ?P x ∨ ¬ ?Q x) ⟹ filter_mset ?P ?M + filter_mset ?Q ?M = {#x ∈# ?M. ?P x ∨ ?Q x#}›*)) also (*calculation: ‹edges G = {#e ∈# edges G. ρ (fst e) ≠ ρ (snd e)#} + {#e ∈# edges G. ρ (fst e) = ρ (snd e)#}›*) have "...={# e∈#edges G. ρ(fst e)<ρ(snd e)∨ρ(fst e)>ρ(snd e)#}+{#e∈#edges G. fst e=snd e#}" using bij_betw_imp_inj_on[OF ρ_bij] (*‹inj_on ρ (verts G)›*) edge_set (*‹?x ∈# edges G ⟹ fst ?x ∈ verts G› ‹?x ∈# edges G ⟹ snd ?x ∈ verts G›*) apply (intro arg_cong2[where f="(+)"] (*‹⟦?a = ?b; ?c = ?d⟧ ⟹ ?a + ?c = ?b + ?d›*) filter_mset_cong (*‹⟦?M = ?M'; ⋀x. x ∈# ?M' ⟹ ?f x = ?g x⟧ ⟹ filter_mset ?f ?M = filter_mset ?g ?M'›*) refl (*‹?t = ?t›*) inj_on_eq_iff[where A="verts G"] (*‹⟦inj_on ?f (verts G); ?x ∈ verts G; ?y ∈ verts G⟧ ⟹ (?f ?x = ?f ?y) = (?x = ?y)›*)) (*goals: 1. ‹⋀x. ⟦inj_on ρ (verts G); ⋀x. x ∈# edges G ⟹ fst x ∈ verts G; ⋀x. x ∈# edges G ⟹ snd x ∈ verts G; x ∈# edges G⟧ ⟹ (ρ (fst x) ≠ ρ (snd x)) = (ρ (fst x) < ρ (snd x) ∨ ρ (snd x) < ρ (fst x))› 2. ‹⋀x. ⟦inj_on ρ (verts G); ⋀x. x ∈# edges G ⟹ fst x ∈ verts G; ⋀x. x ∈# edges G ⟹ snd x ∈ verts G; x ∈# edges G⟧ ⟹ inj_on ρ (verts G)› 3. ‹⋀x. ⟦inj_on ρ (verts G); ⋀x. x ∈# edges G ⟹ fst x ∈ verts G; ⋀x. x ∈# edges G ⟹ snd x ∈ verts G; x ∈# edges G⟧ ⟹ fst x ∈ verts G› 4. ‹⋀x. ⟦inj_on ρ (verts G); ⋀x. x ∈# edges G ⟹ fst x ∈ verts G; ⋀x. x ∈# edges G ⟹ snd x ∈ verts G; x ∈# edges G⟧ ⟹ snd x ∈ verts G› 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*) . also (*calculation: ‹edges G = {#e ∈# edges G. ρ (fst e) < ρ (snd e) ∨ ρ (snd e) < ρ (fst e)#} + {#e ∈# edges G. fst e = snd e#}›*) have "... = {#e ∈# edges G. ρ(fst e) < ρ (snd e) #} + {#e ∈# edges G. ρ(fst e) > ρ (snd e) #} + {#e ∈# edges G. fst e = snd e #}" apply (intro arg_cong2[where f="(+)"] (*‹⟦?a = ?b; ?c = ?d⟧ ⟹ ?a + ?c = ?b + ?d›*) filter_mset_ex_predicates[symmetric] (*‹(⋀x. ¬ ?P x ∨ ¬ ?Q x) ⟹ {#x ∈# ?M. ?P x ∨ ?Q x#} = filter_mset ?P ?M + filter_mset ?Q ?M›*)) (*goals: 1. ‹⋀e::'a::type × 'a::type. ¬ (ρ::'a::type ⇒ nat) (fst e) < ρ (snd e) ∨ ¬ ρ (snd e) < ρ (fst e)› 2. ‹{#e::'a::type × 'a::type ∈# edges G. fst e = snd e#} = {#e::'a::type × 'a::type ∈# edges G. fst e = snd e#}› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . finally (*calculation: ‹edges G = {#e ∈# edges G. ρ (fst e) < ρ (snd e)#} + {#e ∈# edges G. ρ (snd e) < ρ (fst e)#} + {#e ∈# edges G. fst e = snd e#}›*) have edges_split: "edges G = {#e ∈# edges G. ρ(fst e) < ρ (snd e) #} + {#e ∈# edges G. ρ(fst e) > ρ (snd e) #} + {#e ∈# edges G. fst e = snd e #}" by simp have "ρ_lt_n": "ρ x < n" if "x ∈ verts G" for x using bij_betw_apply[OF ρ_bij] (*‹(?a::'a::type) ∈ verts G ⟹ (ρ::'a::type ⇒ nat) ?a ∈ {..<n}›*) that (*‹x ∈ verts G›*) by auto have "φ_ρ_inv": "φ (ρ x) = x" if "x ∈ verts G" for x unfolding "φ_def" (*goal: ‹the_inv_into (verts G) (ρ::'a::type ⇒ nat) (ρ (x::'a::type)) = x›*) using bij_betw_imp_inj_on[OF ρ_bij] (*‹inj_on ρ (verts G)›*) apply (intro the_inv_into_f_f (*‹⟦inj_on ?f ?A; ?x ∈ ?A⟧ ⟹ the_inv_into ?A ?f (?f ?x) = ?x›*) that (*‹x ∈ verts G›*)) (*goal: ‹the_inv_into (verts G) ρ (ρ x) = x›*) by auto have "ρ_φ_inv": "ρ (φ x) = x" if "x < n" for x unfolding "φ_def" (*goal: ‹ρ (the_inv_into (verts G) ρ x) = x›*) using bij_betw_imp_inj_on[OF ρ_bij] (*‹inj_on (ρ::'a ⇒ nat) (verts G)›*) bij_betw_imp_surj_on[OF ρ_bij] (*‹ρ ` verts G = {..<n}›*) that (*‹x < n›*) apply (intro f_the_inv_into_f (*‹⟦inj_on ?f ?A; ?y ∈ ?f ` ?A⟧ ⟹ ?f (the_inv_into ?A ?f ?y) = ?y›*)) (*goals: 1. ‹⟦inj_on ρ (verts G); ρ ` verts G = {..<n}; x < n⟧ ⟹ inj_on ρ (verts G)› 2. ‹⟦inj_on ρ (verts G); ρ ` verts G = {..<n}; x < n⟧ ⟹ x ∈ ρ ` verts G› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . define τ where "τ x = (if x < n then f' (φ x) else 0)" for x have "τ_nonneg": "τ k ≥ 0" for k unfolding "τ_def" f'_def f_def (*goal: ‹(0::real) ≤ (if (k::nat) < n then (χi::'n. max ((g::(real, 'n) Finite_Cartesian_Product.vec) $h i) (0::real)) $h enum_verts_inv ((φ::nat ⇒ 'a) k) else (0::real))›*) by auto have "τ_antimono": "τ k ≥ τ l" if " k < l" for k and l proof (cases "l ≥ n") (*goals: 1. ‹n ≤ l ⟹ τ l ≤ τ k› 2. ‹¬ n ≤ l ⟹ τ l ≤ τ k›*) case True (*‹n ≤ l›*) hence "τ l = 0" unfolding "τ_def" (*goal: ‹(if (l::nat) < n then (f'::'a ⇒ real) ((φ::nat ⇒ 'a) l) else (0::real)) = (0::real)›*) by simp then show "?thesis" (*goal: ‹τ l ≤ τ k›*) using "τ_nonneg" (*‹0 ≤ τ ?k6›*) by simp next (*goal: ‹¬ n ≤ (l::nat) ⟹ (τ::nat ⇒ real) l ≤ τ (k::nat)›*) case False (*‹¬ n ≤ (l::nat)›*) hence "τ l = f' (φ l)" unfolding "τ_def" (*goal: ‹(if l < n then f' (φ l) else 0) = f' (φ l)›*) by simp also (*calculation: ‹τ l = f' (φ l)›*) have "... ≤ f' (φ k)" using "ρ_φ_inv" (*‹?x6 < n ⟹ ρ (φ ?x6) = ?x6›*) False (*‹¬ n ≤ l›*) that (*‹k < l›*) apply (intro ρ_dec (*‹⟦?x6 ∈ verts G; ?y6 ∈ verts G; ρ ?x6 < ρ ?y6⟧ ⟹ f' ?y6 ≤ f' ?x6›*) bij_betw_apply[OF φ_bij] (*‹?a ∈ {..<n} ⟹ φ ?a ∈ verts G›*)) (*goals: 1. ‹⟦⋀x::nat. x < n ⟹ (ρ::'a ⇒ nat) ((φ::nat ⇒ 'a) x) = x; ¬ n ≤ (l::nat); (k::nat) < l⟧ ⟹ k ∈ {..<n}› 2. ‹⟦⋀x::nat. x < n ⟹ (ρ::'a ⇒ nat) ((φ::nat ⇒ 'a) x) = x; ¬ n ≤ (l::nat); (k::nat) < l⟧ ⟹ l ∈ {..<n}› 3. ‹⟦⋀x::nat. x < n ⟹ (ρ::'a ⇒ nat) ((φ::nat ⇒ 'a) x) = x; ¬ n ≤ (l::nat); (k::nat) < l⟧ ⟹ ρ (φ k) < ρ (φ l)› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*proven 3 subgoals*) . also (*calculation: ‹τ l ≤ f' (φ k)›*) have "... = τ k" unfolding "τ_def" (*goal: ‹f' (φ k) = (if k < n then f' (φ k) else 0)›*) using False (*‹¬ n ≤ l›*) that (*‹k < l›*) by simp finally (*calculation: ‹τ l ≤ τ k›*) show "?thesis" (*goal: ‹τ l ≤ τ k›*) by simp qed define m :: nat where "m = Min {i. τ i = 0 ∧ i ≤ n}" have "τ n = 0" unfolding "τ_def" (*goal: ‹(if n < n then f' (φ n) else 0) = 0›*) by simp hence "m ∈ {i. τ i = 0 ∧ i ≤ n}" unfolding m_def (*goal: ‹Min {i. τ i = 0 ∧ i ≤ n} ∈ {i. τ i = 0 ∧ i ≤ n}›*) apply (intro Min_in (*‹⟦finite ?A; ?A ≠ {}⟧ ⟹ Min ?A ∈ ?A›*)) (*goals: 1. ‹(τ::nat ⇒ real) n = (0::real) ⟹ finite {i::nat. τ i = (0::real) ∧ i ≤ n}› 2. ‹(τ::nat ⇒ real) n = (0::real) ⟹ {i::nat. τ i = (0::real) ∧ i ≤ n} ≠ {}› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . hence m_rel_1: "τ m = 0" and m_le_n: "m ≤ n" apply - (*goals: 1. ‹m ∈ {i. τ i = 0 ∧ i ≤ n} ⟹ τ m = 0› 2. ‹m ∈ {i. τ i = 0 ∧ i ≤ n} ⟹ m ≤ n› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . have "τ k > 0" if "k < m" for k proof (rule ccontr (*‹(¬ ?P ⟹ False) ⟹ ?P›*)) (*goal: ‹¬ 0 < τ k ⟹ False›*) assume "¬(τ k > 0)" (*‹¬ (0::real) < (τ::nat ⇒ real) (k::nat)›*) hence "τ k = 0" apply (intro order_antisym (*‹⟦(?x::?'a) ≤ (?y::?'a); ?y ≤ ?x⟧ ⟹ ?x = ?y›*) τ_nonneg (*‹(0::real) ≤ (τ::nat ⇒ real) (?k6::nat)›*)) (*goal: ‹(τ::nat ⇒ real) (k::nat) = (0::real)›*) by simp hence "k ∈ {i. τ i = 0 ∧ i ≤ n}" using that (*‹(k::nat) < (m::nat)›*) m_le_n (*‹m ≤ n›*) by simp hence "m ≤ k" unfolding m_def (*goal: ‹Min {i. τ i = 0 ∧ i ≤ n} ≤ k›*) apply (intro Min_le (*‹⟦finite ?A; ?x ∈ ?A⟧ ⟹ Min ?A ≤ ?x›*)) (*goals: 1. ‹k ∈ {i. τ i = 0 ∧ i ≤ n} ⟹ finite {i. τ i = 0 ∧ i ≤ n}› 2. ‹k ∈ {i. τ i = 0 ∧ i ≤ n} ⟹ k ∈ {i. τ i = 0 ∧ i ≤ n}› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . thus False using that (*‹k < m›*) by simp qed hence m_rel_2: "f' x > 0" if "x ∈ φ ` {..<m}" for x unfolding "τ_def" (*goal: ‹0 < f' x›*) using m_le_n (*‹m ≤ n›*) that (*‹x ∈ φ ` {..<m}›*) by auto have "2 * m = 2 * card {..<m}" by simp also (*calculation: ‹2 * m = 2 * card {..<m}›*) have "... = 2 * card (φ ` {..<m})" using m_le_n (*‹m ≤ n›*) inj_on_subset[OF bij_betw_imp_inj_on [ OF φ_bij ]] (*‹?B ⊆ {..<n} ⟹ inj_on φ ?B›*) apply (intro_cong "[σ₂ (*)]" more:card_image[symmetric]) (*goal: ‹2 * card {..<m} = 2 * card (φ ` {..<m})›*) by auto also (*calculation: ‹(2::nat) * (m::nat) = (2::nat) * card ((φ::nat ⇒ 'a::type) ` {..<m})›*) have "... ≤ 2 * card {x ∈ verts G. f' x > 0}" using m_rel_2 (*‹?x6 ∈ φ ` {..<m} ⟹ 0 < f' ?x6›*) bij_betw_apply[OF φ_bij] (*‹?a ∈ {..<n} ⟹ φ ?a ∈ verts G›*) m_le_n (*‹m ≤ n›*) apply (intro mult_left_mono (*‹⟦(?a::?'a) ≤ (?b::?'a); (0::?'a) ≤ (?c::?'a)⟧ ⟹ ?c * ?a ≤ ?c * ?b›*) card_mono (*‹⟦finite (?B::?'a set); (?A::?'a set) ⊆ ?B⟧ ⟹ card ?A ≤ card ?B›*) subsetI (*‹(⋀x::?'a. x ∈ (?A::?'a set) ⟹ x ∈ (?B::?'a set)) ⟹ ?A ⊆ ?B›*)) (*goals: 1. ‹⟦⋀x::'a. x ∈ (φ::nat ⇒ 'a) ` {..<m::nat} ⟹ (0::real) < (f'::'a ⇒ real) x; ⋀a::nat. a ∈ {..<n} ⟹ φ a ∈ verts G; m ≤ n⟧ ⟹ finite {x::'a ∈ verts G. (0::real) < f' x}› 2. ‹⋀x::'a. ⟦⋀x::'a. x ∈ (φ::nat ⇒ 'a) ` {..<m::nat} ⟹ (0::real) < (f'::'a ⇒ real) x; ⋀a::nat. a ∈ {..<n} ⟹ φ a ∈ verts G; m ≤ n; x ∈ φ ` {..<m}⟧ ⟹ x ∈ {x::'a ∈ verts G. (0::real) < f' x}› 3. ‹⟦⋀x::'a. x ∈ (φ::nat ⇒ 'a) ` {..<m::nat} ⟹ (0::real) < (f'::'a ⇒ real) x; ⋀a::nat. a ∈ {..<n} ⟹ φ a ∈ verts G; m ≤ n⟧ ⟹ (0::nat) ≤ (2::nat)› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*proven 3 subgoals*) . also (*calculation: ‹2 * m ≤ 2 * card {x ∈ verts G. 0 < f' x}›*) have "... = 2 * card (enum_verts_inv ` {x ∈ verts G. f $h (enum_verts_inv x) > 0})" unfolding f'_def (*goal: ‹2 * card {x ∈ verts G. 0 < f $h enum_verts_inv x} = 2 * card (enum_verts_inv ` {x ∈ verts G. 0 < f $h enum_verts_inv x})›*) using Abs_inject (*‹⟦?x ∈ verts G; ?y ∈ verts G⟧ ⟹ (enum_verts_inv ?x = enum_verts_inv ?y) = (?x = ?y)›*) apply (intro arg_cong2[where f="(*)"] (*‹⟦?a = ?b; ?c = ?d⟧ ⟹ ?a * ?c = ?b * ?d›*) card_image[symmetric] (*‹inj_on ?f ?A ⟹ card ?A = card (?f ` ?A)›*) inj_onI (*‹(⋀x y. ⟦x ∈ ?A; y ∈ ?A; ?f x = ?f y⟧ ⟹ x = y) ⟹ inj_on ?f ?A›*)) (*goals: 1. ‹(⋀x y. ⟦x ∈ verts G; y ∈ verts G⟧ ⟹ (enum_verts_inv x = enum_verts_inv y) = (x = y)) ⟹ 2 = 2› 2. ‹⋀x y. ⟦⋀x y. ⟦x ∈ verts G; y ∈ verts G⟧ ⟹ (enum_verts_inv x = enum_verts_inv y) = (x = y); x ∈ {x ∈ verts G. 0 < f $h enum_verts_inv x}; y ∈ {x ∈ verts G. 0 < f $h enum_verts_inv x}; enum_verts_inv x = enum_verts_inv y⟧ ⟹ x = y› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . also (*calculation: ‹2 * m ≤ 2 * card (enum_verts_inv ` {x ∈ verts G. 0 < f $h enum_verts_inv x})›*) have "... = 2 * card {x. f $h x > 0}" using Rep_inverse (*‹enum_verts_inv (enum_verts ?x) = ?x›*) Rep_range (*‹range enum_verts = verts G›*) unfolding f'_def (*goal: ‹(2::nat) * card (enum_verts_inv ` {x::'a ∈ verts G. (0::real) < (f::(real, 'n) Finite_Cartesian_Product.vec) $h enum_verts_inv x}) = (2::nat) * card {x::'n. (0::real) < f $h x}›*) apply (intro_cong "[σ₂ (*), σ₁ card]" more:subset_antisym image_subsetI surj_onI[where g="enum_verts"]) (*goals: 1. ‹⋀x. ⟦⋀x. enum_verts_inv (enum_verts x) = x; range enum_verts = verts G; x ∈ {x ∈ verts G. 0 < f $h enum_verts_inv x}⟧ ⟹ enum_verts_inv x ∈ {x. 0 < f $h x}› 2. ‹⋀x. ⟦⋀x. enum_verts_inv (enum_verts x) = x; range enum_verts = verts G; x ∈ {x. 0 < f $h x}⟧ ⟹ enum_verts x ∈ {x ∈ verts G. 0 < f $h enum_verts_inv x} ∧ enum_verts_inv (enum_verts x) = x› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . also (*calculation: ‹2 * m ≤ 2 * card {x. 0 < f $h x}›*) have "... = 2 * card {x. g $h x > 0}" unfolding f_def (*goal: ‹2 * card {x. 0 < (χi. max (g $h i) 0) $h x} = 2 * card {x. 0 < g $h x}›*) apply (intro_cong "[σ₂ (*), σ₁ card]") (*goal: ‹2 * card {x. 0 < (χi. max (g $h i) 0) $h x} = 2 * card {x. 0 < g $h x}›*) by auto also (*calculation: ‹(2::nat) * (m::nat) ≤ (2::nat) * card {x::'n. (0::real) < (g::(real, 'n) Finite_Cartesian_Product.vec) $h x}›*) have "... ≤ n" by (intro g_supp (*‹2 * card {i. 0 < g $h i} ≤ n›*)) finally (*calculation: ‹2 * m ≤ n›*) have m2_le_n: "2*m ≤ n" by simp have "τ k ≤ 0" if "k > m" for k using m_rel_1 (*‹τ m = 0›*) "τ_antimono" (*‹(?k6::nat) < (?l6::nat) ⟹ (τ::nat ⇒ real) ?l6 ≤ τ ?k6›*) that (*‹m < k›*) by metis hence "τ k ≤ 0" if "k ≥ m" for k using m_rel_1 (*‹τ m = 0›*) that (*‹m ≤ k›*) apply (cases "k > m") (*goals: 1. ‹⟦⋀k. m < k ⟹ τ k ≤ 0; τ m = 0; m ≤ k; m < k⟧ ⟹ τ k ≤ 0› 2. ‹⟦⋀k. m < k ⟹ τ k ≤ 0; τ m = 0; m ≤ k; ¬ m < k⟧ ⟹ τ k ≤ 0› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . hence "τ_supp": "τ k = 0" if "k ≥ m" for k using that (*‹m ≤ k›*) apply (intro order_antisym (*‹⟦?x ≤ ?y; ?y ≤ ?x⟧ ⟹ ?x = ?y›*) τ_nonneg (*‹0 ≤ τ ?k6›*)) (*goal: ‹τ k = 0›*) by auto have 4: "ρ v ≤ x ⟷ v ∈ φ ` {..x}" if "v ∈ verts G" "x < n" for v and x proof (-) (*goal: ‹(ρ v ≤ x) = (v ∈ φ ` {..x})›*) have "ρ v ≤ x ⟷ ρ v ∈ {..x}" by simp also (*calculation: ‹((ρ::'a ⇒ nat) (v::'a) ≤ (x::nat)) = (ρ v ∈ {..x})›*) have "... ⟷ φ (ρ v) ∈ φ ` {..x}" using bij_betw_imp_inj_on[OF φ_bij] (*‹inj_on φ {..<n}›*) bij_betw_apply[OF ρ_bij] (*‹?a ∈ verts G ⟹ ρ ?a ∈ {..<n}›*) that (*‹v ∈ verts G› ‹x < n›*) apply (intro inj_on_image_mem_iff[where B="{..<n}", symmetric] (*‹⟦inj_on ?f {..<n}; ?a ∈ {..<n}; ?A ⊆ {..<n}⟧ ⟹ (?a ∈ ?A) = (?f ?a ∈ ?f ` ?A)›*)) (*goals: 1. ‹⟦inj_on φ {..<n}; ⋀a. a ∈ verts G ⟹ ρ a ∈ {..<n}; v ∈ verts G; x < n⟧ ⟹ inj_on φ {..<n}› 2. ‹⟦inj_on φ {..<n}; ⋀a. a ∈ verts G ⟹ ρ a ∈ {..<n}; v ∈ verts G; x < n⟧ ⟹ ρ v ∈ {..<n}› 3. ‹⟦inj_on φ {..<n}; ⋀a. a ∈ verts G ⟹ ρ a ∈ {..<n}; v ∈ verts G; x < n⟧ ⟹ {..x} ⊆ {..<n}› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*proven 3 subgoals*) . also (*calculation: ‹(ρ v ≤ x) = (φ (ρ v) ∈ φ ` {..x})›*) have "... ⟷ v ∈ φ ` {..x}" unfolding "φ_ρ_inv"[OF that ( 1 )] (*goal: ‹(v ∈ φ ` {..x}) = (v ∈ φ ` {..x})›*) by simp finally (*calculation: ‹(ρ v ≤ x) = (v ∈ φ ` {..x})›*) show "?thesis" (*goal: ‹(ρ v ≤ x) = (v ∈ φ ` {..x})›*) by simp qed have "B⇩f = (∑a∈arcs G. ¦f' (tail G a)^2 - f' (head G a)^2¦)" unfolding "B⇩f_def" (*goal: ‹(∑a∈arcs G. ¦(f' (tail G a))² - (f' (head G a))²¦) = (∑a∈arcs G. ¦(f' (tail G a))² - (f' (head G a))²¦)›*) by simp also (*calculation: ‹(B⇩f::real) = (∑a::'b::type∈arcs G. ¦((f'::'a::type ⇒ real) (tail G a))² - (f' (head G a))²¦)›*) have "... = (∑e ∈# edges G. ¦f' (fst e)^2 - f' (snd e)^2¦)" unfolding edges_def arc_to_ends_def sum_unfold_sum_mset (*goal: ‹(∑a::'b∈#mset_set (arcs G). ¦((f'::'a ⇒ real) (tail G a))² - (f' (head G a))²¦) = (∑e::'a × 'a∈#{#(tail G e, head G e). e::'b ∈# mset_set (arcs G)#}. ¦(f' (fst e))² - (f' (snd e))²¦)›*) by (simp add:image_mset.compositionality (*‹image_mset ?f (image_mset ?g ?multiset) = image_mset (?f ∘ ?g) ?multiset›*) comp_def (*‹?f ∘ ?g = (λx. ?f (?g x))›*)) also (*calculation: ‹(B⇩f::real) = (∑e::'a × 'a∈#edges G. ¦((f'::'a ⇒ real) (fst e))² - (f' (snd e))²¦)›*) have "... = (∑e∈#{#e ∈# edges G. ρ (fst e) < ρ (snd e)#}. ¦(f' (fst e))² - (f' (snd e))²¦) + (∑e∈#{#e ∈# edges G. ρ (snd e) < ρ (fst e)#}. ¦(f' (fst e))² - (f' (snd e))²¦) + (∑e∈#{#e ∈# edges G. fst e = snd e#}. ¦(f' (fst e))² - (f' (snd e))²¦)" apply (subst edges_split (*‹edges G = {#e ∈# edges G. ρ (fst e) < ρ (snd e)#} + {#e ∈# edges G. ρ (snd e) < ρ (fst e)#} + {#e ∈# edges G. fst e = snd e#}›*)) (*goal: ‹(∑e∈#edges G. ¦(f' (fst e))² - (f' (snd e))²¦) = (∑e∈#{#e ∈# edges G. ρ (fst e) < ρ (snd e)#}. ¦(f' (fst e))² - (f' (snd e))²¦) + (∑e∈#{#e ∈# edges G. ρ (snd e) < ρ (fst e)#}. ¦(f' (fst e))² - (f' (snd e))²¦) + (∑e∈#{#e ∈# edges G. fst e = snd e#}. ¦(f' (fst e))² - (f' (snd e))²¦)›*) by simp also (*calculation: ‹B⇩f = (∑e∈#{#e ∈# edges G. ρ (fst e) < ρ (snd e)#}. ¦(f' (fst e))² - (f' (snd e))²¦) + (∑e∈#{#e ∈# edges G. ρ (snd e) < ρ (fst e)#}. ¦(f' (fst e))² - (f' (snd e))²¦) + (∑e∈#{#e ∈# edges G. fst e = snd e#}. ¦(f' (fst e))² - (f' (snd e))²¦)›*) have "... = (∑e∈#{#e ∈# edges G. ρ (snd e) < ρ (fst e)#}. ¦(f' (fst e))² - (f' (snd e))²¦) + (∑e∈#{#e ∈# edges G. ρ (snd e) < ρ (fst e)#}. ¦(f' (snd e))² - (f' (fst e))²¦) + (∑e∈#{#e ∈# edges G. fst e = snd e#}. ¦(f' (fst e))² - (f' (snd e))²¦)" apply (subst edges_sym[OF sym, symmetric] (*‹edges G = {#(y, x). (x, y) ∈# edges G#}›*)) (*goal: ‹(∑e∈#{#e ∈# edges G. ρ (fst e) < ρ (snd e)#}. ¦(f' (fst e))² - (f' (snd e))²¦) + (∑e∈#{#e ∈# edges G. ρ (snd e) < ρ (fst e)#}. ¦(f' (fst e))² - (f' (snd e))²¦) + (∑e∈#{#e ∈# edges G. fst e = snd e#}. ¦(f' (fst e))² - (f' (snd e))²¦) = (∑e∈#{#e ∈# edges G. ρ (snd e) < ρ (fst e)#}. ¦(f' (fst e))² - (f' (snd e))²¦) + (∑e∈#{#e ∈# edges G. ρ (snd e) < ρ (fst e)#}. ¦(f' (snd e))² - (f' (fst e))²¦) + (∑e∈#{#e ∈# edges G. fst e = snd e#}. ¦(f' (fst e))² - (f' (snd e))²¦)›*) by (simp add:image_mset.compositionality (*‹image_mset ?f (image_mset ?g ?multiset) = image_mset (?f ∘ ?g) ?multiset›*) comp_def (*‹?f ∘ ?g = (λx. ?f (?g x))›*) image_mset_filter_mset_swap[symmetric] (*‹filter_mset ?P (image_mset ?f ?M) = image_mset ?f {#x ∈# ?M. ?P (?f x)#}›*) case_prod_beta (*‹(case ?p of (x, xa) ⇒ ?f x xa) = ?f (fst ?p) (snd ?p)›*)) also (*calculation: ‹B⇩f = (∑e∈#{#e ∈# edges G. ρ (snd e) < ρ (fst e)#}. ¦(f' (fst e))² - (f' (snd e))²¦) + (∑e∈#{#e ∈# edges G. ρ (snd e) < ρ (fst e)#}. ¦(f' (snd e))² - (f' (fst e))²¦) + (∑e∈#{#e ∈# edges G. fst e = snd e#}. ¦(f' (fst e))² - (f' (snd e))²¦)›*) have "... = (∑e∈#{#e ∈# edges G. ρ (snd e) < ρ (fst e)#}. ¦(f' (snd e))² - (f' (fst e))²¦) + (∑e∈#{#e ∈# edges G. ρ (snd e) < ρ (fst e)#}. ¦(f' (snd e))² - (f' (fst e))²¦) + (∑e∈#{#e ∈# edges G. fst e = snd e#}. 0)" apply (intro_cong "[σ₂ (+), σ₁ sum_mset]" more:image_mset_cong) (*goals: 1. ‹⋀e. e ∈# {#e ∈# edges G. ρ (snd e) < ρ (fst e)#} ⟹ ¦(f' (fst e))² - (f' (snd e))²¦ = ¦(f' (snd e))² - (f' (fst e))²¦› 2. ‹⋀e. e ∈# {#e ∈# edges G. fst e = snd e#} ⟹ ¦(f' (fst e))² - (f' (snd e))²¦ = 0› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . also (*calculation: ‹B⇩f = (∑e∈#{#e ∈# edges G. ρ (snd e) < ρ (fst e)#}. ¦(f' (snd e))² - (f' (fst e))²¦) + (∑e∈#{#e ∈# edges G. ρ (snd e) < ρ (fst e)#}. ¦(f' (snd e))² - (f' (fst e))²¦) + (∑e∈#{#e ∈# edges G. fst e = snd e#}. 0)›*) have "... = 2 * (∑e∈#{#e∈#edges G. ρ(snd e)<ρ(fst e)#}. ¦(f' (snd e))² - (f' (fst e))²¦)" by simp also (*calculation: ‹B⇩f = 2 * (∑e∈#{#e ∈# edges G. ρ (snd e) < ρ (fst e)#}. ¦(f' (snd e))² - (f' (fst e))²¦)›*) have "... = 2 *(∑a|a∈arcs G∧ρ(tail G a)>ρ(head G a). ¦f'(head G a)^2 - f'(tail G a)^2¦)" unfolding edges_def arc_to_ends_def sum_unfold_sum_mset (*goal: ‹2 * (∑e∈#{#e ∈# {#(tail G e, head G e). e ∈# mset_set (arcs G)#}. ρ (snd e) < ρ (fst e)#}. ¦(f' (snd e))² - (f' (fst e))²¦) = 2 * (∑a∈#mset_set {a ∈ arcs G. ρ (head G a) < ρ (tail G a)}. ¦(f' (head G a))² - (f' (tail G a))²¦)›*) by (simp add:image_mset.compositionality (*‹image_mset ?f (image_mset ?g ?multiset) = image_mset (?f ∘ ?g) ?multiset›*) comp_def (*‹?f ∘ ?g = (λx. ?f (?g x))›*) image_mset_filter_mset_swap[symmetric] (*‹filter_mset ?P (image_mset ?f ?M) = image_mset ?f {#x ∈# ?M. ?P (?f x)#}›*)) also (*calculation: ‹B⇩f = 2 * (∑a | a ∈ arcs G ∧ ρ (head G a) < ρ (tail G a). ¦(f' (head G a))² - (f' (tail G a))²¦)›*) have "... = 2 * (∑a|a∈arcs G∧ρ(tail G a)>ρ(head G a). ¦τ(ρ(head G a))^2 - τ(ρ(tail G a))^2¦)" unfolding "τ_def" (*goal: ‹2 * (∑a | a ∈ arcs G ∧ ρ (head G a) < ρ (tail G a). ¦(f' (head G a))² - (f' (tail G a))²¦) = 2 * (∑a | a ∈ arcs G ∧ ρ (head G a) < ρ (tail G a). ¦(if ρ (head G a) < n then f' (φ (ρ (head G a))) else 0)² - (if ρ (tail G a) < n then f' (φ (ρ (tail G a))) else 0)²¦)›*) using "φ_ρ_inv" (*‹?x6 ∈ verts G ⟹ φ (ρ ?x6) = ?x6›*) "ρ_lt_n" (*‹(?x6::'a) ∈ verts G ⟹ (ρ::'a ⇒ nat) ?x6 < n›*) apply (intro arg_cong2[where f="(*)"] (*‹⟦?a = ?b; ?c = ?d⟧ ⟹ ?a * ?c = ?b * ?d›*) sum.cong (*‹⟦?A = ?B; ⋀x. x ∈ ?B ⟹ ?g x = ?h x⟧ ⟹ sum ?g ?A = sum ?h ?B›*) refl (*‹?t = ?t›*)) (*goal: ‹2 * (∑a | a ∈ arcs G ∧ ρ (head G a) < ρ (tail G a). ¦(f' (head G a))² - (f' (tail G a))²¦) = 2 * (∑a | a ∈ arcs G ∧ ρ (head G a) < ρ (tail G a). ¦(if ρ (head G a) < n then f' (φ (ρ (head G a))) else 0)² - (if ρ (tail G a) < n then f' (φ (ρ (tail G a))) else 0)²¦)›*) by auto also (*calculation: ‹B⇩f = 2 * (∑a | a ∈ arcs G ∧ ρ (head G a) < ρ (tail G a). ¦(τ (ρ (head G a)))² - (τ (ρ (tail G a)))²¦)›*) have "... = 2 * (∑a|a∈arcs G∧ρ(tail G a)>ρ(head G a). τ(ρ(head G a))^2 - τ(ρ(tail G a))^2)" using "τ_antimono" (*‹(?k6::nat) < (?l6::nat) ⟹ (τ::nat ⇒ real) ?l6 ≤ τ ?k6›*) power_mono (*‹⟦?a ≤ ?b; 0 ≤ ?a⟧ ⟹ ?a ^ ?n ≤ ?b ^ ?n›*) "τ_nonneg" (*‹(0::real) ≤ (τ::nat ⇒ real) (?k6::nat)›*) apply (intro arg_cong2[where f="(*)"] (*‹⟦?a = ?b; ?c = ?d⟧ ⟹ ?a * ?c = ?b * ?d›*) sum.cong (*‹⟦?A = ?B; ⋀x. x ∈ ?B ⟹ ?g x = ?h x⟧ ⟹ sum ?g ?A = sum ?h ?B›*) refl (*‹?t = ?t›*) abs_of_nonneg (*‹0 ≤ ?a ⟹ ¦?a¦ = ?a›*)) (*goal: ‹2 * (∑a | a ∈ arcs G ∧ ρ (head G a) < ρ (tail G a). ¦(τ (ρ (head G a)))² - (τ (ρ (tail G a)))²¦) = 2 * (∑a | a ∈ arcs G ∧ ρ (head G a) < ρ (tail G a). (τ (ρ (head G a)))² - (τ (ρ (tail G a)))²)›*) by auto also (*calculation: ‹B⇩f = 2 * (∑a | a ∈ arcs G ∧ ρ (head G a) < ρ (tail G a). (τ (ρ (head G a)))² - (τ (ρ (tail G a)))²)›*) have "... = 2 * (∑a|a∈arcs G∧ρ(tail G a)>ρ(head G a). (-(τ(ρ(tail G a))^2)) - (-(τ(ρ(head G a))^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 42 facts*)) also (*calculation: ‹B⇩f = 2 * (∑a | a ∈ arcs G ∧ ρ (head G a) < ρ (tail G a). - (τ (ρ (tail G a)))² - - (τ (ρ (head G a)))²)›*) have "... = 2 *(∑a|a∈arcs G∧ρ(tail G a)>ρ(head G a). (∑i=ρ(head G a)..<ρ(tail G a). (-(τ (Suc i)^2)) - (-(τ i^2))))" apply (intro arg_cong2[where f="(*)"] (*‹⟦?a = ?b; ?c = ?d⟧ ⟹ ?a * ?c = ?b * ?d›*) sum.cong (*‹⟦?A = ?B; ⋀x. x ∈ ?B ⟹ ?g x = ?h x⟧ ⟹ sum ?g ?A = sum ?h ?B›*) refl (*‹?t = ?t›*) sum_Suc_diff'[symmetric] (*‹?m ≤ ?n ⟹ ?f ?n - ?f ?m = (∑i = ?m..<?n. ?f (Suc i) - ?f i)›*)) (*goal: ‹2 * (∑a | a ∈ arcs G ∧ ρ (head G a) < ρ (tail G a). - (τ (ρ (tail G a)))² - - (τ (ρ (head G a)))²) = 2 * (∑a | a ∈ arcs G ∧ ρ (head G a) < ρ (tail G a). ∑i = ρ (head G a)..<ρ (tail G a). - (τ (Suc i))² - - (τ i)²)›*) by auto also (*calculation: ‹B⇩f = 2 * (∑a | a ∈ arcs G ∧ ρ (head G a) < ρ (tail G a). ∑i = ρ (head G a)..<ρ (tail G a). - (τ (Suc i))² - - (τ i)²)›*) have "...=2*(∑(a, i)∈(SIGMA x:{a ∈ arcs G. ρ (head G a) < ρ (tail G a)}. {ρ (head G x)..<ρ (tail G x)}). τ i^2 - τ (Suc i)^2)" apply (subst sum.Sigma (*‹⟦finite ?A; ∀x∈?A. finite (?B x)⟧ ⟹ (∑x∈?A. sum (?g x) (?B x)) = (∑(x, y)∈Sigma ?A ?B. ?g x y)›*)) (*goals: 1. ‹finite {a::'b ∈ arcs G. (ρ::'a ⇒ nat) (head G a) < ρ (tail G a)}› 2. ‹∀x::'b∈{a::'b ∈ arcs G. (ρ::'a ⇒ nat) (head G a) < ρ (tail G a)}. finite {ρ (head G x)..<ρ (tail G x)}› 3. ‹(2::real) * (∑(a::'b, i::nat)∈(SIGMA x::'b:{a::'b ∈ arcs G. (ρ::'a ⇒ nat) (head G a) < ρ (tail G a)}. {ρ (head G x)..<ρ (tail G x)}). - ((τ::nat ⇒ real) (Suc i))² - - (τ i)²) = (2::real) * (∑(a::'b, i::nat)∈(SIGMA x::'b:{a::'b ∈ arcs G. ρ (head G a) < ρ (tail G a)}. {ρ (head G x)..<ρ (tail G x)}). (τ i)² - (τ (Suc i))²)› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*proven 3 subgoals*) . also (*calculation: ‹B⇩f = 2 * (∑(a, i)∈(SIGMA x:{a ∈ arcs G. ρ (head G a) < ρ (tail G a)}. {ρ (head G x)..<ρ (tail G x)}). (τ i)² - (τ (Suc i))²)›*) have "...=2*(∑p∈{(a,i).a ∈ arcs G∧ρ(head G a)≤i∧i<ρ(tail G a)}. τ(snd p)^2-τ (snd p+1)^2)" apply (intro arg_cong2[where f="(*)"] (*‹⟦?a = ?b; ?c = ?d⟧ ⟹ ?a * ?c = ?b * ?d›*) sum.cong (*‹⟦?A = ?B; ⋀x. x ∈ ?B ⟹ ?g x = ?h x⟧ ⟹ sum ?g ?A = sum ?h ?B›*) refl (*‹?t = ?t›*)) (*goals: 1. ‹(SIGMA x:{a ∈ arcs G. ρ (head G a) < ρ (tail G a)}. {ρ (head G x)..<ρ (tail G x)}) = {(a, i). a ∈ arcs G ∧ ρ (head G a) ≤ i ∧ i < ρ (tail G a)}› 2. ‹⋀x. x ∈ {(a, i). a ∈ arcs G ∧ ρ (head G a) ≤ i ∧ i < ρ (tail G a)} ⟹ (case x of (a, i) ⇒ (τ i)² - (τ (Suc i))²) = (τ (snd x))² - (τ (snd x + 1))²› discuss goal 1*) apply ((auto simp add:Sigma_def (*‹Sigma ?A ?B ≡ ⋃x∈?A. ⋃y∈?B x. {(x, y)}›*))[1]) (*discuss goal 2*) apply ((auto simp add:Sigma_def (*‹Sigma ?A ?B ≡ ⋃x∈?A. ⋃y∈?B x. {(x, y)}›*))[1]) (*proven 2 subgoals*) . also (*calculation: ‹B⇩f = 2 * (∑p∈{(a, i). a ∈ arcs G ∧ ρ (head G a) ≤ i ∧ i < ρ (tail G a)}. (τ (snd p))² - (τ (snd p + 1))²)›*) have "...=2*(∑p∈{(i,a).a ∈ arcs G∧ρ(head G a) ≤ i∧i < ρ(tail G a)}. τ(fst p)^2-τ(fst p+1)^2)" apply (intro sum.reindex_cong[where l="prod.swap"] (*‹⟦inj_on prod.swap ?B; ?A = prod.swap ` ?B; ⋀x. x ∈ ?B ⟹ ?g (prod.swap x) = ?h x⟧ ⟹ sum ?g ?A = sum ?h ?B›*) arg_cong2[where f="(*)"] (*‹⟦?a = ?b; ?c = ?d⟧ ⟹ ?a * ?c = ?b * ?d›*)) (*goals: 1. ‹2 = 2› 2. ‹inj_on prod.swap {(i, a). a ∈ arcs G ∧ ρ (head G a) ≤ i ∧ i < ρ (tail G a)}› 3. ‹{(a, i). a ∈ arcs G ∧ ρ (head G a) ≤ i ∧ i < ρ (tail G a)} = prod.swap ` {(i, a). a ∈ arcs G ∧ ρ (head G a) ≤ i ∧ i < ρ (tail G a)}› 4. ‹⋀x. x ∈ {(i, a). a ∈ arcs G ∧ ρ (head G a) ≤ i ∧ i < ρ (tail G a)} ⟹ (τ (snd (prod.swap x)))² - (τ (snd (prod.swap x) + 1))² = (τ (fst x))² - (τ (fst x + 1))²› 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*) . also (*calculation: ‹B⇩f = 2 * (∑p∈{(i, a). a ∈ arcs G ∧ ρ (head G a) ≤ i ∧ i < ρ (tail G a)}. (τ (fst p))² - (τ (fst p + 1))²)›*) have "...=2* (∑(i, a)∈(SIGMA x:{..<n}. {a ∈ arcs G. ρ (head G a)≤x ∧ x<ρ(tail G a)}). τ i^2-τ (i+1)^2)" using less_trans[OF _ ρ_lt_n] (*‹⟦?x < ρ ?x7; ?x7 ∈ verts G⟧ ⟹ ?x < n›*) apply (intro sum.cong (*‹⟦?A = ?B; ⋀x. x ∈ ?B ⟹ ?g x = ?h x⟧ ⟹ sum ?g ?A = sum ?h ?B›*) arg_cong2[where f="(*)"] (*‹⟦?a = ?b; ?c = ?d⟧ ⟹ ?a * ?c = ?b * ?d›*)) (*goals: 1. ‹(⋀(x::nat) xa::'a::type. ⟦x < (ρ::'a::type ⇒ nat) xa; xa ∈ verts G⟧ ⟹ x < n) ⟹ (2::real) = (2::real)› 2. ‹(⋀(x::nat) xa::'a::type. ⟦x < (ρ::'a::type ⇒ nat) xa; xa ∈ verts G⟧ ⟹ x < n) ⟹ {(i::nat, a::'b::type). a ∈ arcs G ∧ ρ (head G a) ≤ i ∧ i < ρ (tail G a)} = (SIGMA x::nat:{..<n}. {a::'b::type ∈ arcs G. ρ (head G a) ≤ x ∧ x < ρ (tail G a)})› 3. ‹⋀x::nat × 'b::type. ⟦⋀(x::nat) xa::'a::type. ⟦x < (ρ::'a::type ⇒ nat) xa; xa ∈ verts G⟧ ⟹ x < n; x ∈ (SIGMA x::nat:{..<n}. {a::'b::type ∈ arcs G. ρ (head G a) ≤ x ∧ x < ρ (tail G a)})⟧ ⟹ ((τ::nat ⇒ real) (fst x))² - (τ (fst x + (1::nat)))² = (case x of (i::nat, a::'b::type) ⇒ (τ i)² - (τ (i + (1::nat)))²)› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*proven 3 subgoals*) . also (*calculation: ‹B⇩f = 2 * (∑(i, a)∈(SIGMA x:{..<n}. {a ∈ arcs G. ρ (head G a) ≤ x ∧ x < ρ (tail G a)}). (τ i)² - (τ (i + 1))²)›*) have "...=2*(∑i<n. (∑a|a∈arcs G ∧ρ(head G a) ≤ i∧i < ρ(tail G a). τ i^2 - τ (i+1)^2))" apply (subst sum.Sigma (*‹⟦finite ?A; ∀x∈?A. finite (?B x)⟧ ⟹ (∑x∈?A. sum (?g x) (?B x)) = (∑(x, y)∈Sigma ?A ?B. ?g x y)›*)) (*goals: 1. ‹finite {..<n}› 2. ‹∀x∈{..<n}. finite {a ∈ arcs G. ρ (head G a) ≤ x ∧ x < ρ (tail G a)}› 3. ‹2 * (∑(i, a)∈(SIGMA x:{..<n}. {a ∈ arcs G. ρ (head G a) ≤ x ∧ x < ρ (tail G a)}). (τ i)² - (τ (i + 1))²) = 2 * (∑(i, a)∈(SIGMA x:{..<n}. {a ∈ arcs G. ρ (head G a) ≤ x ∧ x < ρ (tail G a)}). (τ i)² - (τ (i + 1))²)› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*proven 3 subgoals*) . also (*calculation: ‹B⇩f = 2 * (∑i<n. ∑a | a ∈ arcs G ∧ ρ (head G a) ≤ i ∧ i < ρ (tail G a). (τ i)² - (τ (i + 1))²)›*) have "...=2*(∑i<n. card {a∈arcs G. ρ(head G a)≤i∧i<ρ(tail G a)} * (τ i^2 - τ (i+1)^2))" by simp also (*calculation: ‹B⇩f = 2 * (∑i<n. real (card {a ∈ arcs G. ρ (head G a) ≤ i ∧ i < ρ (tail G a)}) * ((τ i)² - (τ (i + 1))²))›*) have "...=2*(∑i<n. card {a∈arcs G. ρ(head G a)≤i∧¬(ρ(tail G a)≤i)} * (τ i^2 - τ (i+1)^2))" apply (intro_cong "[σ₂ (*), σ₁ card, σ₁ of_nat]" more:sum.cong Collect_cong) (*goal: ‹2 * (∑i<n. real (card {a ∈ arcs G. ρ (head G a) ≤ i ∧ i < ρ (tail G a)}) * ((τ i)² - (τ (i + 1))²)) = 2 * (∑i<n. real (card {a ∈ arcs G. ρ (head G a) ≤ i ∧ ¬ ρ (tail G a) ≤ i}) * ((τ i)² - (τ (i + 1))²))›*) by auto also (*calculation: ‹B⇩f = 2 * (∑i<n. real (card {a ∈ arcs G. ρ (head G a) ≤ i ∧ ¬ ρ (tail G a) ≤ i}) * ((τ i)² - (τ (i + 1))²))›*) have "...=2*(∑i<n. card {a∈arcs G. head G a∈φ`{..i}∧tail G a∉φ`{..i}} * (τ i^2-τ (i+1)^2))" using "4" (*‹⟦?v6 ∈ verts G; ?x6 < n⟧ ⟹ (ρ ?v6 ≤ ?x6) = (?v6 ∈ φ ` {..?x6})›*) apply (intro_cong "[σ₂ (*), σ₁ card, σ₁ of_nat, σ₂ (∧)]" more:sum.cong restr_Collect_cong) (*goals: 1. ‹⋀x a. ⟦⋀v x. ⟦v ∈ verts G; x < n⟧ ⟹ (ρ v ≤ x) = (v ∈ φ ` {..x}); x ∈ {..<n}; a ∈ arcs G⟧ ⟹ (ρ (head G a) ≤ x) = (head G a ∈ φ ` {..x})› 2. ‹⋀x a. ⟦⋀v x. ⟦v ∈ verts G; x < n⟧ ⟹ (ρ v ≤ x) = (v ∈ φ ` {..x}); x ∈ {..<n}; a ∈ arcs G⟧ ⟹ (¬ ρ (tail G a) ≤ x) = (tail G a ∉ φ ` {..x})› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . also (*calculation: ‹B⇩f = 2 * (∑i<n. real (card {a ∈ arcs G. head G a ∈ φ ` {..i} ∧ tail G a ∉ φ ` {..i}}) * ((τ i)² - (τ (i + 1))²))›*) have "... = 2 * (∑i<n. real (card (edges_betw (-φ`{..i}) (φ`{..i}))) * (τ i^2-τ (i+1)^2))" unfolding edges_betw_def (*goal: ‹(2::real) * (∑i::nat<n. real (card {a::'b ∈ arcs G. head G a ∈ (φ::nat ⇒ 'a) ` {..i} ∧ tail G a ∉ φ ` {..i}}) * (((τ::nat ⇒ real) i)² - (τ (i + (1::nat)))²)) = (2::real) * (∑i::nat<n. real (card {a::'b ∈ arcs G. tail G a ∈ - φ ` {..i} ∧ head G a ∈ φ ` {..i}}) * ((τ i)² - (τ (i + (1::nat)))²))›*) by (auto simp:conj.commute (*‹(?a ∧ ?b) = (?b ∧ ?a)›*)) also (*calculation: ‹(B⇩f::real) = (2::real) * (∑i::nat<n. real (card (edges_betw (- (φ::nat ⇒ 'a) ` {..i}) (φ ` {..i}))) * (((τ::nat ⇒ real) i)² - (τ (i + (1::nat)))²))›*) have "... = 2 * (∑i<n. real (card (edges_betw (φ`{..i}) (-φ`{..i}))) * (τ i^2-τ (i+1)^2))" using edges_betw_sym (*‹card (edges_betw ?S ?T) = card (edges_betw ?T ?S)›*) by simp also (*calculation: ‹B⇩f = 2 * (∑i<n. real (card (edges_betw (φ ` {..i}) (- φ ` {..i}))) * ((τ i)² - (τ (i + 1))²))›*) have "... = 2 * (∑i<m. real (card (edges_betw (φ`{..i}) (-φ`{..i}))) * (τ i^2-τ (i+1)^2))" using "τ_supp" (*‹m ≤ ?k6 ⟹ τ ?k6 = 0›*) m_le_n (*‹m ≤ n›*) apply (intro sum.mono_neutral_right (*‹⟦finite ?T; ?S ⊆ ?T; ∀i∈?T - ?S. ?g i = 0⟧ ⟹ sum ?g ?T = sum ?g ?S›*) arg_cong2[where f="(*)"] (*‹⟦?a = ?b; ?c = ?d⟧ ⟹ ?a * ?c = ?b * ?d›*)) (*goals: 1. ‹⟦⋀k::nat. (m::nat) ≤ k ⟹ (τ::nat ⇒ real) k = (0::real); m ≤ n⟧ ⟹ (2::real) = (2::real)› 2. ‹⟦⋀k::nat. (m::nat) ≤ k ⟹ (τ::nat ⇒ real) k = (0::real); m ≤ n⟧ ⟹ finite {..<n}› 3. ‹⟦⋀k::nat. (m::nat) ≤ k ⟹ (τ::nat ⇒ real) k = (0::real); m ≤ n⟧ ⟹ {..<m} ⊆ {..<n}› 4. ‹⟦⋀k::nat. (m::nat) ≤ k ⟹ (τ::nat ⇒ real) k = (0::real); m ≤ n⟧ ⟹ ∀i::nat∈{..<n} - {..<m}. real (card (edges_betw ((φ::nat ⇒ 'a) ` {..i}) (- φ ` {..i}))) * ((τ i)² - (τ (i + (1::nat)))²) = (0::real)› 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*) . finally (*calculation: ‹(B⇩f::real) = (2::real) * (∑i::nat<m::nat. real (card (edges_betw ((φ::nat ⇒ 'a) ` {..i}) (- φ ` {..i}))) * (((τ::nat ⇒ real) i)² - (τ (i + (1::nat)))²))›*) have Bf_eq: "B⇩f = 2 * (∑i<m. real (card (edges_betw (φ`{..i}) (-φ`{..i}))) * (τ i^2-τ (i+1)^2))" by simp have 3: "card (φ ` {..i} ∩ verts G) = i + 1" if "i < m" for i proof (-) (*goal: ‹card (φ ` {..i} ∩ verts G) = i + 1›*) have "card (φ ` {..i} ∩ verts G) = card (φ ` {..i})" using m_le_n (*‹m ≤ n›*) that (*‹i < m›*) apply (intro arg_cong[where f="card"] (*‹?x = ?y ⟹ card ?x = card ?y›*) Int_absorb2 (*‹?A ⊆ ?B ⟹ ?A ∩ ?B = ?A›*) image_subsetI (*‹(⋀x. x ∈ ?A ⟹ ?f x ∈ ?B) ⟹ ?f ` ?A ⊆ ?B›*) bij_betw_apply[OF φ_bij] (*‹?a ∈ {..<n} ⟹ φ ?a ∈ verts G›*)) (*goal: ‹card (φ ` {..i} ∩ verts G) = card (φ ` {..i})›*) by auto also (*calculation: ‹card (φ ` {..i} ∩ verts G) = card (φ ` {..i})›*) have "... = card {..i}" using m_le_n (*‹m ≤ n›*) that (*‹i < m›*) apply (intro card_image (*‹inj_on ?f ?A ⟹ card (?f ` ?A) = card ?A›*) inj_on_subset[OF bij_betw_imp_inj_on[OF φ_bij]] (*‹?B ⊆ {..<n} ⟹ inj_on φ ?B›*)) (*goal: ‹card (φ ` {..i}) = card {..i}›*) by auto also (*calculation: ‹card (φ ` {..i} ∩ verts G) = card {..i}›*) have "... = i+1" by simp finally (*calculation: ‹card (φ ` {..i} ∩ verts G) = i + 1›*) show "?thesis" (*goal: ‹card (φ ` {..i} ∩ verts G) = i + 1›*) by simp qed have "2 * Λ⇩e * norm f^2 = 2 * Λ⇩e * (g_norm f'^2)" unfolding g_norm_conv f'_alt (*goal: ‹2 * Λ⇩e * (norm (χi. f' (enum_verts i)))² = 2 * Λ⇩e * (norm (χi. f' (enum_verts i)))²›*) by simp also (*calculation: ‹2 * Λ⇩e * (norm f)² = 2 * Λ⇩e * (g_norm f')²›*) have "... ≤ 2 * Λ⇩e * (∑v∈ verts G. f' v^2)" unfolding g_norm_sq g_inner_def (*goal: ‹(2::real) * Λ⇩e * (∑x::'a::type∈verts G. (f'::'a::type ⇒ real) x * conjugate (f' x)) ≤ (2::real) * Λ⇩e * (∑v::'a::type∈verts G. (f' v)²)›*) by (simp add:power2_eq_square (*‹?a² = ?a * ?a›*)) also (*calculation: ‹2 * Λ⇩e * (norm f)² ≤ 2 * Λ⇩e * (∑v∈verts G. (f' v)²)›*) have "... = 2 * Λ⇩e * (∑i<n. f' (φ i)^2)" by (intro arg_cong2[where f="(*)"] (*‹⟦?a = ?b; ?c = ?d⟧ ⟹ ?a * ?c = ?b * ?d›*) refl (*‹?t = ?t›*) sum.reindex_bij_betw[symmetric] (*‹bij_betw ?h ?S ?T ⟹ sum ?g ?T = (∑x∈?S. ?g (?h x))›*) φ_bij (*‹bij_betw φ {..<n} (verts G)›*)) also (*calculation: ‹2 * Λ⇩e * (norm f)² ≤ 2 * Λ⇩e * (∑i<n. (f' (φ i))²)›*) have "... = 2 * Λ⇩e * (∑i<n. τ i^2)" unfolding "τ_def" (*goal: ‹(2::real) * Λ⇩e * (∑i::nat<n. ((f'::'a ⇒ real) ((φ::nat ⇒ 'a) i))²) = (2::real) * Λ⇩e * (∑i::nat<n. (if i < n then f' (φ i) else (0::real))²)›*) apply (intro arg_cong2[where f="(*)"] (*‹⟦?a = ?b; ?c = ?d⟧ ⟹ ?a * ?c = ?b * ?d›*) refl (*‹?t = ?t›*) sum.cong (*‹⟦?A = ?B; ⋀x. x ∈ ?B ⟹ ?g x = ?h x⟧ ⟹ sum ?g ?A = sum ?h ?B›*)) (*goal: ‹(2::real) * Λ⇩e * (∑i::nat<n. ((f'::'a ⇒ real) ((φ::nat ⇒ 'a) i))²) = (2::real) * Λ⇩e * (∑i::nat<n. (if i < n then f' (φ i) else (0::real))²)›*) by auto also (*calculation: ‹2 * Λ⇩e * (norm f)² ≤ 2 * Λ⇩e * (∑i<n. (τ i)²)›*) have "... = 2 * Λ⇩e * (∑i<m. τ i^2)" using "τ_supp" (*‹m ≤ ?k6 ⟹ τ ?k6 = 0›*) m_le_n (*‹(m::nat) ≤ n›*) apply (intro 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›*) arg_cong2[where f="(*)"] (*‹⟦?a = ?b; ?c = ?d⟧ ⟹ ?a * ?c = ?b * ?d›*) refl (*‹?t = ?t›*)) (*goals: 1. ‹⟦⋀k. m ≤ k ⟹ τ k = 0; m ≤ n⟧ ⟹ finite {..<n}› 2. ‹⟦⋀k. m ≤ k ⟹ τ k = 0; m ≤ n⟧ ⟹ {..<m} ⊆ {..<n}› 3. ‹⟦⋀k. m ≤ k ⟹ τ k = 0; m ≤ n⟧ ⟹ ∀i∈{..<n} - {..<m}. (τ i)² = 0› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*proven 3 subgoals*) . also (*calculation: ‹2 * Λ⇩e * (norm f)² ≤ 2 * Λ⇩e * (∑i<m. (τ i)²)›*) have "... ≤ 2 * Λ⇩e * ((∑i<m. τ i^2) + (real 0 * τ 0^2 - m * τ m^2))" using "τ_supp"[of "m"] (*‹m ≤ m ⟹ τ m = 0›*) by simp also (*calculation: ‹(2::real) * Λ⇩e * (norm (f::(real, 'n) Finite_Cartesian_Product.vec))² ≤ (2::real) * Λ⇩e * ((∑i::nat<m::nat. ((τ::nat ⇒ real) i)²) + (real (0::nat) * (τ (0::nat))² - real m * (τ m)²))›*) have "... ≤ 2 * Λ⇩e * ((∑i<m. τ i^2) + (∑i<m. i*τ i^2-(Suc i)*τ (Suc i)^2))" apply (subst sum_lessThan_telescope'[symmetric] (*‹?f 0 - ?f ?m = (∑n<?m. ?f n - ?f (Suc n))›*)) (*goal: ‹2 * Λ⇩e * ((∑i<m. (τ i)²) + (real 0 * (τ 0)² - real m * (τ m)²)) ≤ 2 * Λ⇩e * ((∑i<m. (τ i)²) + (∑i<m. real i * (τ i)² - real (Suc i) * (τ (Suc i))²))›*) by simp also (*calculation: ‹(2::real) * Λ⇩e * (norm (f::(real, 'n) Finite_Cartesian_Product.vec))² ≤ (2::real) * Λ⇩e * ((∑i::nat<m::nat. ((τ::nat ⇒ real) i)²) + (∑i::nat<m. real i * (τ i)² - real (Suc i) * (τ (Suc i))²))›*) have "... ≤ 2 * (∑i<m. (Λ⇩e * (i+1)) * (τ i^2-τ (i+1)^2))" by (simp add:sum_distrib_left (*‹?r * sum ?f ?A = (∑n∈?A. ?r * ?f n)›*) 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 42 facts*) sum.distrib[symmetric] (*‹sum ?g ?A + sum ?h ?A = (∑x∈?A. ?g x + ?h x)›*)) also (*calculation: ‹2 * Λ⇩e * (norm f)² ≤ 2 * (∑i<m. Λ⇩e * real (i + 1) * ((τ i)² - (τ (i + 1))²))›*) have "... ≤ 2 * (∑i<m. real (card (edges_betw (φ`{..i}) (-φ`{..i}))) * (τ i^2-τ (i+1)^2))" using "τ_nonneg" (*‹0 ≤ τ ?k6›*) "τ_antimono" (*‹(?k6::nat) < (?l6::nat) ⟹ (τ::nat ⇒ real) ?l6 ≤ τ ?k6›*) power_mono (*‹⟦?a ≤ ?b; 0 ≤ ?a⟧ ⟹ ?a ^ ?n ≤ ?b ^ ?n›*) "3" (*‹?i6 < m ⟹ card (φ ` {..?i6} ∩ verts G) = ?i6 + 1›*) m2_le_n (*‹(2::nat) * (m::nat) ≤ n›*) apply (intro mult_left_mono (*‹⟦?a ≤ ?b; 0 ≤ ?c⟧ ⟹ ?c * ?a ≤ ?c * ?b›*) 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›*) edge_expansionD2 (*‹⟦?m = card (?S ∩ verts G); 2 * ?m ≤ n⟧ ⟹ Λ⇩e * real ?m ≤ real (card (edges_betw ?S (- ?S)))›*)) (*goals: 1. ‹⋀i. ⟦⋀k. 0 ≤ τ k; ⋀k l. k < l ⟹ τ l ≤ τ k; ⋀a b n. ⟦a ≤ b; 0 ≤ a⟧ ⟹ a ^ n ≤ b ^ n; ⋀i. i < m ⟹ card (φ ` {..i} ∩ verts G) = i + 1; 2 * m ≤ n; i ∈ {..<m}⟧ ⟹ i + 1 = card (φ ` {..i} ∩ verts G)› 2. ‹⋀i. ⟦⋀k. 0 ≤ τ k; ⋀k l. k < l ⟹ τ l ≤ τ k; ⋀a b n. ⟦a ≤ b; 0 ≤ a⟧ ⟹ a ^ n ≤ b ^ n; ⋀i. i < m ⟹ card (φ ` {..i} ∩ verts G) = i + 1; 2 * m ≤ n; i ∈ {..<m}⟧ ⟹ 2 * (i + 1) ≤ n› 3. ‹⋀i. ⟦⋀k. 0 ≤ τ k; ⋀k l. k < l ⟹ τ l ≤ τ k; ⋀a b n. ⟦a ≤ b; 0 ≤ a⟧ ⟹ a ^ n ≤ b ^ n; ⋀i. i < m ⟹ card (φ ` {..i} ∩ verts G) = i + 1; 2 * m ≤ n; i ∈ {..<m}⟧ ⟹ 0 ≤ (τ i)² - (τ (i + 1))²› 4. ‹⟦⋀k. 0 ≤ τ k; ⋀k l. k < l ⟹ τ l ≤ τ k; ⋀a b n. ⟦a ≤ b; 0 ≤ a⟧ ⟹ a ^ n ≤ b ^ n; ⋀i. i < m ⟹ card (φ ` {..i} ∩ verts G) = i + 1; 2 * m ≤ n⟧ ⟹ 0 ≤ 2› 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*) . also (*calculation: ‹2 * Λ⇩e * (norm f)² ≤ 2 * (∑i<m. real (card (edges_betw (φ ` {..i}) (- φ ` {..i}))) * ((τ i)² - (τ (i + 1))²))›*) have "... = B⇩f" unfolding Bf_eq (*goal: ‹2 * (∑i<m. real (card (edges_betw (φ ` {..i}) (- φ ` {..i}))) * ((τ i)² - (τ (i + 1))²)) = 2 * (∑i<m. real (card (edges_betw (φ ` {..i}) (- φ ` {..i}))) * ((τ i)² - (τ (i + 1))²))›*) by simp finally (*calculation: ‹2 * Λ⇩e * (norm f)² ≤ B⇩f›*) have hoory_4_13: "2 * Λ⇩e * norm f^2 ≤ B⇩f" by simp text ‹Corresponds to Lemma 4.13 in Hoory et al.› have f_nz: "f ≠ 0" proof (rule ccontr (*‹(¬ ?P ⟹ False) ⟹ ?P›*)) (*goal: ‹¬ f ≠ 0 ⟹ False›*) assume f_nz_assms: "¬ (f ≠ 0)" (*‹¬ (f::(real, 'n) Finite_Cartesian_Product.vec) ≠ (0::(real, 'n) Finite_Cartesian_Product.vec)›*) have "g $h i ≤ 0" for i proof (-) (*goal: ‹g $h i ≤ 0›*) have "g $h i ≤ max (g $h i) 0" by simp also (*calculation: ‹g $h i ≤ max (g $h i) 0›*) have "... = 0" using f_nz_assms (*‹¬ f ≠ 0›*) unfolding f_def vec_eq_iff (*goal: ‹max (g $h i) 0 = 0›*) by auto finally (*calculation: ‹g $h i ≤ 0›*) show "?thesis" (*goal: ‹g $h i ≤ 0›*) by simp qed moreover have "(∑i ∈ UNIV. 0-g $h i) = 0" using g_orth (*‹g ∙ 1 = 0›*) unfolding sum_subtractf inner_vec_def (*goal: ‹(∑i∈UNIV. 0) - sum (($h) g) UNIV = 0›*) by auto ultimately have "∀x∈UNIV. -(g $h x) = 0" apply (intro iffD1[OF sum_nonneg_eq_0_iff] (*‹⟦finite ?A1; ⋀x. x ∈ ?A1 ⟹ 0 ≤ ?f1 x; sum ?f1 ?A1 = 0⟧ ⟹ ∀x∈?A1. ?f1 x = 0›*)) (*goals: 1. ‹⟦⋀i::'n. (g::(real, 'n) Finite_Cartesian_Product.vec) $h i ≤ (0::real); (∑i::'n∈UNIV. (0::real) - g $h i) = (0::real)⟧ ⟹ finite UNIV› 2. ‹⋀x::'n. ⟦⋀i::'n. (g::(real, 'n) Finite_Cartesian_Product.vec) $h i ≤ (0::real); (∑i::'n∈UNIV. (0::real) - g $h i) = (0::real); x ∈ UNIV⟧ ⟹ (0::real) ≤ - g $h x› 3. ‹⟦⋀i::'n. (g::(real, 'n) Finite_Cartesian_Product.vec) $h i ≤ (0::real); (∑i::'n∈UNIV. (0::real) - g $h i) = (0::real)⟧ ⟹ (∑x::'n∈UNIV. - g $h x) = (0::real)› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*proven 3 subgoals*) . thus False using g_nz (*‹g ≠ 0›*) unfolding vec_eq_iff (*goal: ‹False›*) by simp qed hence norm_f_gt_0: "norm f> 0" by simp have "Λ⇩e * norm f * norm f ≤ sqrt 2 * real d * norm f * sqrt (f ∙ (L *v f))" using order_trans[OF hoory_4_13 hoory_4_12] (*‹2 * Λ⇩e * (norm f)² ≤ 2 * sqrt 2 * real d * norm f * sqrt (f ∙ (L *v f))›*) by (simp add:power2_eq_square (*‹?a² = ?a * ?a›*)) hence "Λ⇩e ≤ real d * sqrt 2 * sqrt (f ∙ (L *v f)) / norm f" using norm_f_gt_0 (*‹0 < norm f›*) by (simp add: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 39 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*)) also (*calculation: ‹Λ⇩e ≤ real d * sqrt (2::real) * sqrt ((f::(real, 'n::finite) Finite_Cartesian_Product.vec) ∙ (L *v f)) / norm f›*) have "... ≤ real d * sqrt 2 * sqrt ((1 - Λ₂) * (norm f)²) / norm f" apply (intro mult_left_mono (*‹⟦?a ≤ ?b; 0 ≤ ?c⟧ ⟹ ?c * ?a ≤ ?c * ?b›*) divide_right_mono (*‹⟦?a ≤ ?b; 0 ≤ ?c⟧ ⟹ ?a / ?c ≤ ?b / ?c›*) real_sqrt_le_mono (*‹?x ≤ ?y ⟹ sqrt ?x ≤ sqrt ?y›*) h_part_i (*‹f ∙ (L *v f) ≤ (1 - Λ₂) * (norm f)²›*)) (*goals: 1. ‹(0::real) ≤ real d * sqrt (2::real)› 2. ‹(0::real) ≤ norm (f::(real, 'n::finite) Finite_Cartesian_Product.vec)› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . also (*calculation: ‹Λ⇩e ≤ real d * sqrt 2 * sqrt ((1 - Λ₂) * (norm f)²) / norm f›*) have "... = real d * sqrt 2 * sqrt (1- Λ₂)" using f_nz (*‹f ≠ 0›*) by (simp add:real_sqrt_mult (*‹sqrt ((?x::real) * (?y::real)) = sqrt ?x * sqrt ?y›*)) also (*calculation: ‹Λ⇩e ≤ real d * sqrt 2 * sqrt (1 - Λ₂)›*) have "... = d * sqrt (2 * (1-Λ₂))" by (simp add:real_sqrt_mult[symmetric] (*‹sqrt ?x * sqrt ?y = sqrt (?x * ?y)›*)) finally (*calculation: ‹Λ⇩e ≤ real d * sqrt (2 * (1 - Λ₂))›*) show "?thesis" (*goal: ‹Λ⇩e ≤ real d * sqrt (2 * (1 - Λ₂))›*) by simp qed end context regular_graph begin lemmas (in regular_graph) cheeger_aux_1 = regular_graph_tts.cheeger_aux_1[OF eg_tts_1, internalize_sort "'n :: finite", OF _ regular_graph_axioms, unfolded remove_finite_premise, cancel_type_definition, OF verts_non_empty] theorem cheeger_inequality: assumes "n > 1" shows "Λ⇩e ∈ {d * (1 - Λ₂) / 2.. d * sqrt (2 * (1 - Λ₂))}" using cheeger_aux_1 (*‹1 < n ⟹ Λ⇩e ≤ real d * sqrt (2 * (1 - Λ₂))›*) cheeger_aux_2 (*‹1 < n ⟹ real d * (1 - Λ₂) / 2 ≤ Λ⇩e›*) assms (*‹1 < n›*) by auto unbundle no_intro_cong_syntax end end
{ "path": "afp-2025-02-12/thys/Expander_Graphs/Expander_Graphs_Cheeger_Inequality.thy", "repo": "afp-2025-02-12", "sha": "dbeb6bc4183a5cca61d70dbfc452d42c18032230781120d03f03287c7f95de80" }
theory Lib imports Ordinary_Differential_Equations.ODE_Analysis begin section ‹Generic Mathematical Lemmas› text‹General lemmas that don't have anything to do with dL specifically and could be fit for general-purpose libraries, mostly dealing with derivatives, ODEs and vectors.› lemma vec_extensionality:"(⋀i. v$i = w$i) ⟹ (v = w)" by (simp add: vec_eq_iff (*‹(?x = ?y) = (∀i. ?x $ i = ?y $ i)›*)) lemma norm_axis: "norm (axis i x) = norm x" unfolding axis_def norm_vec_def (*goal: ‹L2_set (λia. norm ((χia. if ia = i then x else 0) $ ia)) UNIV = norm x›*) unfolding L2_set_def (*goal: ‹sqrt (∑ia::'b∈UNIV. (norm ((χia::'b. if ia = (i::'b) then x::'a else (0::'a)) $ ia))²) = norm x›*) by (clarsimp simp add: if_distrib[where f=norm] (*‹norm (if ?c then ?x else ?y) = (if ?c then norm ?x else norm ?y)›*) if_distrib[where f="λx. x²"] (*‹(if ?c then ?x else ?y)² = (if ?c then ?x² else ?y²)›*) sum.If_cases (*‹finite ?A ⟹ (∑x∈?A. if ?P x then ?h x else ?g x) = sum ?h (?A ∩ {x. ?P x}) + sum ?g (?A ∩ - {x. ?P x})›*)) lemma bounded_linear_axis: "bounded_linear (axis i)" proof (standard) (*goals: 1. ‹⋀(b1::'a) b2::'a. axis (i::'b) (b1 + b2) = axis i b1 + axis i b2› 2. ‹⋀(r::real) b::'a. axis (i::'b) (r *⇩R b) = r *⇩R axis i b› 3. ‹∃K::real. ∀x::'a. norm (axis (i::'b) x) ≤ norm x * K›*) show "axis i (x + y) = axis i x + axis i y" "axis i (r *⇩R x) = r *⇩R axis i x" for x :: 'a and y :: 'a and r (*goals: 1. ‹axis i (x + y) = axis i x + axis i y› 2. ‹axis i (r *⇩R x) = r *⇩R axis i x› discuss goal 1*) apply ((auto simp: vec_eq_iff (*‹(?x = ?y) = (∀i. ?x $ i = ?y $ i)›*) axis_def (*‹axis ?k ?x = (χi. if i = ?k then ?x else 0)›*))[1]) (*discuss goal 2*) apply ((auto simp: vec_eq_iff (*‹((?x::(?'a, ?'b) vec) = (?y::(?'a, ?'b) vec)) = (∀i::?'b. ?x $ i = ?y $ i)›*) axis_def (*‹axis (?k::?'b) (?x::?'a) = (χi::?'b. if i = ?k then ?x else (0::?'a))›*))[1]) (*proven 2 subgoals*) . show "∃K. ∀x::'a. norm (axis i x) ≤ norm x * K" by (auto simp add: norm_axis (*‹norm (axis ?i ?x) = norm ?x›*) intro!: exI[of _ 1] (*‹?P 1 ⟹ ∃x. ?P x›*)) qed lemma bounded_linear_vec: fixes f::"('a::finite) ⇒ 'b::real_normed_vector ⇒ 'c::real_normed_vector" assumes bounds:"⋀i. bounded_linear (f i)" shows "bounded_linear (λx. χ i. f i x)" proof (unfold_locales) (*goals: 1. ‹⋀(b1::'b) b2::'b. (χi::'a. (f::'a ⇒ 'b ⇒ 'c) i (b1 + b2)) = (χi::'a. f i b1) + (χi::'a. f i b2)› 2. ‹⋀(r::real) b::'b. (χi::'a. (f::'a ⇒ 'b ⇒ 'c) i (r *⇩R b)) = r *⇩R (χi::'a. f i b)› 3. ‹∃K::real. ∀x::'b. norm (χi::'a. (f::'a ⇒ 'b ⇒ 'c) i x) ≤ norm x * K›*) fix r and x and y interpret bounded_linear "f i" for i by fact show "(χ i. f i (x + y)) = (χ i. f i x) + (χ i. f i y)" by (vector add) show "(χ i. f i (r *⇩R x)) = r *⇩R (χ i. f i x)" by (vector scaleR) obtain K where "norm (f i x) ≤ norm x * K i" for x and i (*goal: ‹(⋀K::'a ⇒ real. (⋀(x::'b) i::'a. norm ((f::'a ⇒ 'b ⇒ 'c) i x) ≤ norm x * K i) ⟹ thesis::bool) ⟹ thesis›*) using bounded (*‹∃K. ∀x. norm (f ?i x) ≤ norm x * K›*) by metis then have "norm (χ i. f i x) ≤ norm x * (∑i∈UNIV. K i)" (is "?lhs ≤ ?rhs") for x unfolding sum_distrib_left (*goal: ‹norm (χi. f i x) ≤ (∑n∈UNIV. norm x * K n)›*) unfolding norm_vec_def (*goal: ‹L2_set (λi. norm ((χi. f i x) $ i)) UNIV ≤ (∑n∈UNIV. norm x * K n)›*) by (auto intro!: L2_set_le_sum_abs[THEN order_trans] (*‹(∑i∈?A1. ¦?f1 i¦) ≤ ?z ⟹ L2_set ?f1 ?A1 ≤ ?z›*) sum_mono (*‹(⋀i. i ∈ ?K ⟹ ?f i ≤ ?g i) ⟹ sum ?f ?K ≤ sum ?g ?K›*) simp: abs_mult (*‹¦?a * ?b¦ = ¦?a¦ * ¦?b¦›*)) then show "∃K. ∀x. norm (χ i. f i x) ≤ norm x * K" by blast qed lift_definition blinfun_vec::"('a::finite ⇒ 'b::real_normed_vector ⇒⇩L real) ⇒ 'b ⇒⇩L (real ^ 'a)" is "(λ(f::('a ⇒ 'b ⇒ real)) (x::'b). χ (i::'a). f i x)" by(rule bounded_linear_vec, simp) lemmas blinfun_vec_simps[simp] = blinfun_vec.rep_eq lemma continuous_blinfun_vec:"(⋀i. continuous_on UNIV (blinfun_apply (g i))) ⟹ continuous_on UNIV (blinfun_vec g)" by (simp add: continuous_on_vec_lambda (*‹(⋀i. continuous_on ?S (?f i)) ⟹ continuous_on ?S (λx. χi. ?f i x)›*)) lemma blinfun_elim:"⋀g. (blinfun_apply (blinfun_vec g)) = (λx. χ i. g i x)" using blinfun_vec.rep_eq (*‹blinfun_apply (blinfun_vec ?x) = (λx. χi. blinfun_apply (?x i) x)›*) by auto lemma sup_plus: fixes f g::"('b::metric_space) ⇒ real" assumes nonempty:"R ≠ {}" assumes bddf:"bdd_above (f ` R)" assumes bddg:"bdd_above (g ` R)" shows "(SUP x∈R. f x + g x) ≤ (SUP x∈R. f x) + (SUP x∈R. g x)" proof (-) (*goal: ‹(SUP x∈R. f x + g x) ≤ Sup (f ` R) + Sup (g ` R)›*) have bddfg: "bdd_above((λx. f x + g x ) ` R)" using bddf (*‹bdd_above (f ` R)›*) bddg (*‹bdd_above (g ` R)›*) apply (auto simp add: bdd_above_def (*‹bdd_above (?A::?'a set) = (∃M::?'a. ∀x::?'a∈?A. x ≤ M)›*)) (*goal: ‹bdd_above ((λx. f x + g x) ` R)›*) using add_mono_thms_linordered_semiring(1) (*‹?i ≤ ?j ∧ ?k ≤ ?l ⟹ ?i + ?k ≤ ?j + ?l›*) by blast have eq: "(SUP x∈R. f x + g x) ≤ (SUP x∈R. f x) + (SUP x∈R. g x) ⟷ (∀x∈R. (f x + g x) ≤ (SUP x∈R. f x) + (SUP x∈R. g x))" apply (rule cSUP_le_iff (*‹⟦?A ≠ {}; bdd_above (?f ` ?A)⟧ ⟹ (Sup (?f ` ?A) ≤ ?u) = (∀x∈?A. ?f x ≤ ?u)›*)) (*goal: ‹((SUP x∈R. f x + g x) ≤ Sup (f ` R) + Sup (g ` R)) = (∀x∈R. f x + g x ≤ Sup (f ` R) + Sup (g ` R))›*) subgoal for by (rule nonempty (*‹(R::'b set) ≠ {}›*)) subgoal for by (rule bddfg (*‹bdd_above ((λx. f x + g x) ` R)›*)) . have fs: "⋀x. x ∈ R ⟹ f x ≤ (SUP x∈R. f x)" using bddf (*‹bdd_above (f ` R)›*) by (simp add: cSUP_upper (*‹⟦(?x::?'b) ∈ (?A::?'b set); bdd_above ((?f::?'b ⇒ ?'a) ` ?A)⟧ ⟹ ?f ?x ≤ Sup (?f ` ?A)›*)) have gs: "⋀x. x ∈ R ⟹ g x ≤ (SUP x∈R. g x)" using bddg (*‹bdd_above ((g::'b::metric_space ⇒ real) ` (R::'b::metric_space set))›*) by (simp add: cSUP_upper (*‹⟦?x ∈ ?A; bdd_above (?f ` ?A)⟧ ⟹ ?f ?x ≤ Sup (?f ` ?A)›*)) have "(∀x∈R. (f x + g x) ≤ (SUP x∈R. f x) + (SUP x∈R. g x))" apply auto (*goal: ‹∀x::'b∈R::'b set. (f::'b ⇒ real) x + (g::'b ⇒ real) x ≤ Sup (f ` R) + Sup (g ` R)›*) subgoal for x using fs[of x] (*‹x ∈ R ⟹ f x ≤ Sup (f ` R)›*) gs[of x] (*‹x ∈ R ⟹ g x ≤ Sup (g ` R)›*) by auto . then show "?thesis" (*goal: ‹(SUP x∈R. f x + g x) ≤ Sup (f ` R) + Sup (g ` R)›*) by (auto simp add: eq (*‹((SUP x∈R. f x + g x) ≤ Sup (f ` R) + Sup (g ` R)) = (∀x∈R. f x + g x ≤ Sup (f ` R) + Sup (g ` R))›*)) qed lemma continuous_blinfun_vec': fixes f::"'a::{finite,linorder} ⇒ 'b::{metric_space, real_normed_vector,abs} ⇒ 'b ⇒⇩L real" fixes S::"'b set" assumes conts:"⋀i. continuous_on UNIV (f i)" shows "continuous_on UNIV (λx. blinfun_vec (λ i. f i x))" proof (auto simp add: LIM_def (*‹(?f::?'a ⇒ ?'b) ─?a::?'a→ (?L::?'b) = (∀r>0::real. ∃s>0::real. ∀x::?'a. x ≠ ?a ∧ dist x ?a < s ⟶ dist (?f x) ?L < r)›*) continuous_on_def (*‹continuous_on (?s::?'a set) (?f::?'a ⇒ ?'b) = (∀x::?'a∈?s. (?f ⤏ ?f x) (at x within ?s))›*)) (*goal: ‹⋀x r. 0 < r ⟹ ∃s>0. ∀xa. xa ≠ x ∧ dist xa x < s ⟶ dist (blinfun_vec (λi. f i xa)) (blinfun_vec (λi. f i x)) < r›*) fix x1 and ε :: real assume "ε": "0 < ε" (*‹(0::real) < (ε::real)›*) let ?n = "card (UNIV::'a set)" have conts': " ⋀i x1 ε. 0 < ε ⟹ ∃δ>0. ∀x2. x2 ≠ x1 ∧ dist x2 x1 < δ ⟶ dist (f i x2) (f i x1) < ε" using conts (*‹continuous_on UNIV (f ?i)›*) by (auto simp add: LIM_def (*‹?f ─?a→ ?L = (∀r>0. ∃s>0. ∀x. x ≠ ?a ∧ dist x ?a < s ⟶ dist (?f x) ?L < r)›*) continuous_on_def (*‹continuous_on ?s ?f = (∀x∈?s. (?f ⤏ ?f x) (at x within ?s))›*)) have conts'': "⋀i. ∃δ>0. ∀x2. x2 ≠ x1 ∧ dist x2 x1 < δ ⟶ dist (f i x2) (f i x1) < (ε/?n)" subgoal for i using conts'[of "ε / ?n" x1 i] (*‹(0::real) < (ε::real) / real CARD('a) ⟹ ∃δ>0::real. ∀x2::'b. x2 ≠ (x1::'b) ∧ dist x2 x1 < δ ⟶ dist ((f::'a ⇒ 'b ⇒ 'b ⇒⇩L real) (i::'a) x2) (f i x1) < ε / real CARD('a)›*) "ε" (*‹0 < ε›*) by auto . let ?f = "(λx. blinfun_vec (λ i. f i x))" let ?Pδ = "(λ i δ. (δ>0 ∧ (∀x2. x2 ≠ x1 ∧ dist x2 x1 < δ ⟶ dist (f i x2) (f i x1) < (ε/?n))))" let ?δi = "(λi. SOME δ. ?Pδ i δ)" have Ps: "⋀i. ∃δ. ?Pδ i δ" using conts'' (*‹∃δ>0. ∀x2. x2 ≠ x1 ∧ dist x2 x1 < δ ⟶ dist (f ?i x2) (f ?i x1) < ε / real CARD('a)›*) by auto have "Pδi": "⋀i. ?Pδ i (?δi i)" subgoal for i using someI[of "?Pδ i"] (*‹0 < ?x ∧ (∀x2. x2 ≠ x1 ∧ dist x2 x1 < ?x ⟶ dist (f i x2) (f i x1) < ε / real CARD('a)) ⟹ 0 < (SOME δ. 0 < δ ∧ (∀x2. x2 ≠ x1 ∧ dist x2 x1 < δ ⟶ dist (f i x2) (f i x1) < ε / real CARD('a))) ∧ (∀x2. x2 ≠ x1 ∧ dist x2 x1 < (SOME δ. 0 < δ ∧ (∀x2. x2 ≠ x1 ∧ dist x2 x1 < δ ⟶ dist (f i x2) (f i x1) < ε / real CARD('a))) ⟶ dist (f i x2) (f i x1) < ε / real CARD('a))›*) Ps[of i] (*‹∃δ>0. ∀x2. x2 ≠ x1 ∧ dist x2 x1 < δ ⟶ dist (f i x2) (f i x1) < ε / real CARD('a)›*) by auto . have finU: "finite (UNIV::'a set)" by auto let ?δ = "linorder_class.Min (?δi ` UNIV)" have "δ0s": "⋀i. ?δi i > 0" using "Pδi" (*‹(0::real) < (SOME δ::real. (0::real) < δ ∧ (∀x2::'b. x2 ≠ (x1::'b) ∧ dist x2 x1 < δ ⟶ dist ((f::'a ⇒ 'b ⇒ 'b ⇒⇩L real) (?i::'a) x2) (f ?i x1) < (ε::real) / real CARD('a))) ∧ (∀x2::'b. x2 ≠ x1 ∧ dist x2 x1 < (SOME δ::real. (0::real) < δ ∧ (∀x2::'b. x2 ≠ x1 ∧ dist x2 x1 < δ ⟶ dist (f ?i x2) (f ?i x1) < ε / real CARD('a))) ⟶ dist (f ?i x2) (f ?i x1) < ε / real CARD('a))›*) by blast then have "δ0s'": "⋀i. 0 < ?δi i" by auto have bounds: "bdd_below (?δi ` UNIV)" unfolding bdd_below_def (*goal: ‹∃M. Ball (range (λi. SOME δ. 0 < δ ∧ (∀x2. x2 ≠ x1 ∧ dist x2 x1 < δ ⟶ dist (f i x2) (f i x1) < ε / real CARD('a)))) ((≤) M)›*) using "δ0s" (*‹0 < (SOME δ. 0 < δ ∧ (∀x2. x2 ≠ x1 ∧ dist x2 x1 < δ ⟶ dist (f ?i x2) (f ?i x1) < ε / real CARD('a)))›*) less_eq_real_def (*‹(?x ≤ ?y) = (?x < ?y ∨ ?x = ?y)›*) by blast have "δs": "⋀i. ?δ ≤ ?δi i" using bounds (*‹bdd_below (range (λi. SOME δ. 0 < δ ∧ (∀x2. x2 ≠ x1 ∧ dist x2 x1 < δ ⟶ dist (f i x2) (f i x1) < ε / real CARD('a))))›*) cINF_lower[of ?δi] (*‹⟦bdd_below ((λi. SOME δ. 0 < δ ∧ (∀x2. x2 ≠ x1 ∧ dist x2 x1 < δ ⟶ dist (f i x2) (f i x1) < ε / real CARD('a))) ` ?A); ?x ∈ ?A⟧ ⟹ (INF i∈?A. SOME δ. 0 < δ ∧ (∀x2. x2 ≠ x1 ∧ dist x2 x1 < δ ⟶ dist (f i x2) (f i x1) < ε / real CARD('a))) ≤ (SOME δ. 0 < δ ∧ (∀x2. x2 ≠ x1 ∧ dist x2 x1 < δ ⟶ dist (f ?x x2) (f ?x x1) < ε / real CARD('a)))›*) by auto have finite: "finite ((?δi ` UNIV))" by auto have nonempty: "((?δi ` UNIV)) ≠ {}" by auto have "δ": "?δ > 0 " using Min_gr_iff[OF finite nonempty] (*‹(?x < (MIN i. SOME δ. 0 < δ ∧ (∀x2. x2 ≠ x1 ∧ dist x2 x1 < δ ⟶ dist (f i x2) (f i x1) < ε / real CARD('a)))) = (∀a∈range (λi. SOME δ. 0 < δ ∧ (∀x2. x2 ≠ x1 ∧ dist x2 x1 < δ ⟶ dist (f i x2) (f i x1) < ε / real CARD('a))). ?x < a)›*) "δ0s'" (*‹(0::real) < (SOME δ::real. (0::real) < δ ∧ (∀x2::'b::{abs,real_normed_vector}. x2 ≠ (x1::'b::{abs,real_normed_vector}) ∧ dist x2 x1 < δ ⟶ dist ((f::'a::{finite,linorder} ⇒ 'b::{abs,real_normed_vector} ⇒ 'b::{abs,real_normed_vector} ⇒⇩L real) (?i::'a::{finite,linorder}) x2) (f ?i x1) < (ε::real) / real CARD('a::{finite,linorder})))›*) by blast have conts''': "⋀i x2. x2 ≠ x1 ⟹ dist x2 x1 < ?δi i ⟹ dist (f i x2) (f i x1) < (ε/?n)" subgoal for i and x2 using conts''[of i] (*‹∃δ>0. ∀x2. x2 ≠ x1 ∧ dist x2 x1 < δ ⟶ dist (f i x2) (f i x1) < ε / real CARD('a)›*) apply auto (*goal: ‹⟦x2 ≠ x1; dist x2 x1 < (SOME δ. 0 < δ ∧ (∀x2. x2 ≠ x1 ∧ dist x2 x1 < δ ⟶ dist (f i x2) (f i x1) < ε / real CARD('a)))⟧ ⟹ dist (f i x2) (f i x1) < ε / real CARD('a)›*) subgoal for δ apply (erule allE[where x=x2] (*‹⟦∀x. ?P x; ?P x2 ⟹ ?R⟧ ⟹ ?R›*)) (*goal: ‹⟦x2 ≠ x1; dist x2 x1 < (SOME δ. 0 < δ ∧ (∀x2. x2 ≠ x1 ∧ dist x2 x1 < δ ⟶ dist (f i x2) (f i x1) < ε / real CARD('a))); 0 < δ; ∀x2. x2 ≠ x1 ∧ dist x2 x1 < δ ⟶ dist (f i x2) (f i x1) < ε / real CARD('a)⟧ ⟹ dist (f i x2) (f i x1) < ε / real CARD('a)›*) using "Pδi" (*‹0 < (SOME δ. 0 < δ ∧ (∀x2. x2 ≠ x1 ∧ dist x2 x1 < δ ⟶ dist (f ?i x2) (f ?i x1) < ε / real CARD('a))) ∧ (∀x2. x2 ≠ x1 ∧ dist x2 x1 < (SOME δ. 0 < δ ∧ (∀x2. x2 ≠ x1 ∧ dist x2 x1 < δ ⟶ dist (f ?i x2) (f ?i x1) < ε / real CARD('a))) ⟶ dist (f ?i x2) (f ?i x1) < ε / real CARD('a))›*) "δs"[of i] (*‹(MIN i::'a::{finite,linorder}. SOME δ::real. (0::real) < δ ∧ (∀x2::'b::{abs,real_normed_vector}. x2 ≠ (x1::'b::{abs,real_normed_vector}) ∧ dist x2 x1 < δ ⟶ dist ((f::'a::{finite,linorder} ⇒ 'b::{abs,real_normed_vector} ⇒ 'b::{abs,real_normed_vector} ⇒⇩L real) i x2) (f i x1) < (ε::real) / real CARD('a::{finite,linorder}))) ≤ (SOME δ::real. (0::real) < δ ∧ (∀x2::'b::{abs,real_normed_vector}. x2 ≠ x1 ∧ dist x2 x1 < δ ⟶ dist (f (i::'a::{finite,linorder}) x2) (f i x1) < ε / real CARD('a::{finite,linorder})))›*) by (auto simp add: δs[of i] (*‹(MIN i. SOME δ. 0 < δ ∧ (∀x2. x2 ≠ x1 ∧ dist x2 x1 < δ ⟶ dist (f i x2) (f i x1) < ε / real CARD('a))) ≤ (SOME δ. 0 < δ ∧ (∀x2. x2 ≠ x1 ∧ dist x2 x1 < δ ⟶ dist (f i x2) (f i x1) < ε / real CARD('a)))›*)) . . have "⋀x2. x2 ≠ x1 ∧ dist x2 x1 < ?δ ⟹ dist (blinfun_vec (λi. f i x2)) (blinfun_vec (λi. f i x1)) < ε" proof (auto) (*goal: ‹⋀x2. ⟦x2 ≠ x1; ∀x. dist x2 x1 < (SOME δ. 0 < δ ∧ (∀x2. x2 ≠ x1 ∧ dist x2 x1 < δ ⟶ dist (f x x2) (f x x1) < ε / real CARD('a)))⟧ ⟹ dist (blinfun_vec (λi. f i x2)) (blinfun_vec (λi. f i x1)) < ε›*) fix x2 assume ne: "x2 ≠ x1" (*‹(x2::'b) ≠ (x1::'b)›*) assume dist: "∀i. dist x2 x1 < ?δi i" (*‹∀i::'a. dist (x2::'b) (x1::'b) < (SOME δ::real. (0::real) < δ ∧ (∀x2::'b. x2 ≠ x1 ∧ dist x2 x1 < δ ⟶ dist ((f::'a ⇒ 'b ⇒ 'b ⇒⇩L real) i x2) (f i x1) < (ε::real) / real CARD('a)))›*) have dists: "⋀i. dist x2 x1 < ?δi i" subgoal for i using dist (*‹∀i::'a. dist (x2::'b) (x1::'b) < (SOME δ::real. (0::real) < δ ∧ (∀x2::'b. x2 ≠ x1 ∧ dist x2 x1 < δ ⟶ dist ((f::'a ⇒ 'b ⇒ 'b ⇒⇩L real) i x2) (f i x1) < (ε::real) / real CARD('a)))›*) "δs"[of i] (*‹(MIN i. SOME δ. 0 < δ ∧ (∀x2. x2 ≠ x1 ∧ dist x2 x1 < δ ⟶ dist (f i x2) (f i x1) < ε / real CARD('a))) ≤ (SOME δ. 0 < δ ∧ (∀x2. x2 ≠ x1 ∧ dist x2 x1 < δ ⟶ dist (f i x2) (f i x1) < ε / real CARD('a)))›*) by auto . have euclid: "⋀y. norm(?f x1 y - ?f x2 y) = (L2_set (λi. norm(f i x1 y - f i x2 y)) UNIV)" by (simp add: norm_vec_def (*‹norm ?x = L2_set (λi. norm (?x $ i)) UNIV›*)) have finite: "finite (UNIV::'a set)" by auto have nonempty: "(UNIV::'a set) ≠ {}" by auto have nonemptyB: "(UNIV::'b set) ≠ {}" by auto have nonemptyR: "(UNIV::real set) ≠ {}" by auto have SUP_leq: "⋀f::('b ⇒ real). ⋀ g::('b ⇒ real). ⋀ S::'b set. S ≠ {} ⟹ bdd_above (g ` S) ⟹ (⋀x. x ∈ (S::'b set) ⟹ ((f x)::real) ≤ ((g x)::real)) ⟹ (SUP x∈S. f x) ≤ (SUP x∈S. g x)" apply (rule cSup_mono (*‹⟦?B ≠ {}; bdd_above ?A; ⋀b. b ∈ ?B ⟹ ∃a∈?A. b ≤ a⟧ ⟹ Sup ?B ≤ Sup ?A›*)) (*goals: 1. ‹⋀(f::'b ⇒ real) (g::'b ⇒ real) S::'b set. ⟦S ≠ {}; bdd_above (g ` S); ⋀x::'b. x ∈ S ⟹ f x ≤ g x⟧ ⟹ f ` S ≠ {}› 2. ‹⋀(f::'b ⇒ real) (g::'b ⇒ real) S::'b set. ⟦S ≠ {}; bdd_above (g ` S); ⋀x::'b. x ∈ S ⟹ f x ≤ g x⟧ ⟹ bdd_above (g ` S)› 3. ‹⋀(f::'b ⇒ real) (g::'b ⇒ real) (S::'b set) b::real. ⟦S ≠ {}; bdd_above (g ` S); ⋀x::'b. x ∈ S ⟹ f x ≤ g x; b ∈ f ` S⟧ ⟹ ∃a::real∈g ` S. b ≤ a› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*proven 3 subgoals*) . have SUP_sum_comm': "⋀R S f . finite (S::'a set) ⟹ (R::'d::metric_space set) ≠ {} ⟹ (⋀i x. ((f i x)::real) ≥ 0) ⟹ (⋀i. bdd_above (f i ` R)) ⟹ (SUP x∈R . (∑i ∈ S. f i x)) ≤ (∑i ∈ S. (SUP x∈R. f i x))" proof (-) (*goal: ‹⋀(R::'d set) (S::'a set) f::'a ⇒ 'd ⇒ real. ⟦finite S; R ≠ {}; ⋀(i::'a) x::'d. (0::real) ≤ f i x; ⋀i::'a. bdd_above (f i ` R)⟧ ⟹ (SUP x::'d∈R. ∑i::'a∈S. f i x) ≤ (∑i::'a∈S. Sup (f i ` R))›*) fix R :: "'d set" and S :: "('a)set" and f :: "'a ⇒ 'd ⇒ real" assume non: "R ≠ {} " (*‹(R::'d set) ≠ {}›*) assume fin: "finite S" (*‹finite (S::'a set)›*) assume every: "(⋀i x. 0 ≤ f i x)" (*‹(0::real) ≤ (f::'a ⇒ 'd ⇒ real) (?i::'a) (?x::'d)›*) assume bddF: "⋀i. bdd_above (f i ` R)" (*‹bdd_above ((f::'a ⇒ 'd ⇒ real) (?i::'a) ` (R::'d set))›*) then have bddF': "⋀i. ∃M. ∀x ∈R. f i x ≤ M " unfolding bdd_above_def (*goal: ‹⋀i. ∃M. ∀x∈R. f i x ≤ M›*) by auto let ?boundP = "(λi M. ∀x ∈R. f i x ≤ M)" let ?bound = "(λi::'a. SOME M. ∀x ∈R. f i x ≤ M)" have "⋀i. ∃M. ?boundP i M" using bddF' (*‹∃M. ∀x∈R. f ?i x ≤ M›*) by auto then have each_bound: "⋀i. ?boundP i (?bound i)" subgoal for i using someI[of "?boundP i"] (*‹∀x∈R. f i x ≤ ?x ⟹ ∀x∈R. f i x ≤ (SOME M. ∀x∈R. f i x ≤ M)›*) by blast . let ?bigBound = "(λF. ∑i∈F. (?bound i))" have bddG: "⋀i::'a. ⋀F. bdd_above ((λx. ∑i∈F. f i x) ` R)" subgoal for i and F using bddF[of i] (*‹bdd_above (f i ` R)›*) unfolding bdd_above_def (*goal: ‹∃M. ∀x∈(λx. ∑i∈F. f i x) ` R. x ≤ M›*) apply auto (*goal: ‹∃M. ∀x∈(λx. ∑i∈F. f i x) ` R. x ≤ M›*) apply (rule exI[where x="?bigBound F"] (*‹(?P::real ⇒ bool) (∑i::'a∈(F::'a set). SOME M::real. ∀x::'d∈R::'d set. (f::'a ⇒ 'd ⇒ real) i x ≤ M) ⟹ ∃x::real. ?P x›*)) (*goal: ‹⋀M::real. ∀x::'d∈R::'d set. (f::'a ⇒ 'd ⇒ real) (i::'a) x ≤ M ⟹ ∃M::real. ∀x::'d∈R. (∑i::'a∈(F::'a set). f i x) ≤ M›*) subgoal for M apply auto (*goal: ‹∀x∈R. f i x ≤ M ⟹ ∀x∈R. (∑i∈F. f i x) ≤ (∑i∈F. SOME M. ∀Ma∈R. f i Ma ≤ M)›*) subgoal for x using each_bound (*‹∀x∈R. f ?i x ≤ (SOME M. ∀x∈R. f ?i x ≤ M)›*) by (simp add: sum_mono (*‹(⋀i::?'b. i ∈ (?K::?'b set) ⟹ (?f::?'b ⇒ ?'a) i ≤ (?g::?'b ⇒ ?'a) i) ⟹ sum ?f ?K ≤ sum ?g ?K›*)) . . . show "?thesis R S f" (*goal: ‹(SUP x∈R. ∑i∈S. f i x) ≤ (∑i∈S. Sup (f i ` R))›*) using fin (*‹finite S›*) assms (*‹continuous_on UNIV (f ?i)›*) proof (induct) (*goals: 1. ‹(⋀i. continuous_on UNIV (f i)) ⟹ (SUP x∈R. ∑i∈{}. f i x) ≤ (∑i∈{}. Sup (f i ` R))› 2. ‹⋀x F. ⟦finite F; x ∉ F; (⋀i. continuous_on UNIV (f i)) ⟹ (SUP x∈R. ∑i∈F. f i x) ≤ (∑i∈F. Sup (f i ` R)); ⋀i. continuous_on UNIV (f i)⟧ ⟹ (SUP xa∈R. ∑i∈insert x F. f i xa) ≤ (∑i∈insert x F. Sup (f i ` R))›*) case empty (*‹continuous_on UNIV (f ?i)›*) have "((SUP x∈R. ∑i∈{}. f i x)::real) ≤ (∑i∈{}. SUP a∈R. f i a)" by (simp add: non (*‹R ≠ {}›*)) then show "?case" (*goal: ‹(SUP x::'d∈R::'d set. ∑i::'a∈{}. (f::'a ⇒ 'd ⇒ real) i x) ≤ (∑i::'a∈{}. Sup (f i ` R))›*) by auto next (*goal: ‹⋀x F. ⟦finite F; x ∉ F; (⋀i. continuous_on UNIV (f i)) ⟹ (SUP x∈R. ∑i∈F. f i x) ≤ (∑i∈F. Sup (f i ` R)); ⋀i. continuous_on UNIV (f i)⟧ ⟹ (SUP xa∈R. ∑i∈insert x F. f i xa) ≤ (∑i∈insert x F. Sup (f i ` R))›*) case (insert x F) (*‹finite F› ‹x ∉ F› ‹(⋀i. continuous_on UNIV (f i)) ⟹ (SUP x∈R. ∑i∈F. f i x) ≤ (∑i∈F. Sup (f i ` R))› ‹continuous_on UNIV (f ?i)›*) have "((SUP xa∈R. ∑i∈insert x F. f i xa)::real) ≤ (SUP xa∈R. f x xa + (∑i∈F. f i xa))" using insert.hyps(2) (*‹x ∉ F›*) by auto moreover have "... ≤ (SUP xa∈ R. f x xa) + (SUP xa∈R. (∑i∈F. f i xa))" apply (rule sup_plus (*‹⟦?R ≠ {}; bdd_above (?f ` ?R); bdd_above (?g ` ?R)⟧ ⟹ (SUP x∈?R. ?f x + ?g x) ≤ Sup (?f ` ?R) + Sup (?g ` ?R)›*)) (*goals: 1. ‹R ≠ {}› 2. ‹bdd_above (f x ` R)› 3. ‹bdd_above ((λx. ∑i∈F. f i x) ` R)› discuss goal 1*) apply (rule non (*‹R ≠ {}›*)) (*discuss goal 2*) apply (rule bddF (*‹bdd_above ((f::'a::{finite,linorder} ⇒ 'd::metric_space ⇒ real) (?i::'a::{finite,linorder}) ` (R::'d::metric_space set))›*)) (*discuss goal 3*) apply (rule bddG (*‹bdd_above ((λx. ∑i∈?F. f i x) ` R)›*)) (*proven 3 subgoals*) . moreover have "... ≤ (SUP xa∈ R. f x xa) + (∑i∈F. SUP a∈R. f i a)" using add_le_cancel_left (*‹(?c + ?a ≤ ?c + ?b) = (?a ≤ ?b)›*) conts (*‹continuous_on UNIV (f ?i)›*) insert.hyps(3) (*‹(⋀i. continuous_on UNIV (f i)) ⟹ (SUP x∈R. ∑i∈F. f i x) ≤ (∑i∈F. Sup (f i ` R))›*) by blast moreover have "... ≤ (∑i∈(insert x F). SUP a∈R. f i a)" by (simp add: insert.hyps( (*‹x ∉ F›*) 2)) ultimately have "((SUP xa∈R. ∑i∈insert x F. f i xa)::real) ≤ (∑i∈(insert x F). SUP a∈R. f i a)" by linarith then show "?case" (*goal: ‹(SUP xa::'d∈R::'d set. ∑i::'a∈insert (x::'a) (F::'a set). (f::'a ⇒ 'd ⇒ real) i xa) ≤ (∑i::'a∈insert x F. Sup (f i ` R))›*) by auto qed qed have SUP_sum_comm: "⋀R S y1 y2 . finite (S::'a set) ⟹ (R::'b set) ≠ {} ⟹ (SUP x∈R . (∑i ∈ S. norm(f i y1 x - f i y2 x)/norm(x))) ≤ (∑i ∈ S. (SUP x∈R. norm(f i y1 x - f i y2 x)/norm(x)))" apply (rule SUP_sum_comm' (*‹⟦finite (?S::'a::{finite,linorder} set); (?R::?'d1::metric_space set) ≠ {}; ⋀(i::'a::{finite,linorder}) x::?'d1::metric_space. (0::real) ≤ (?f::'a::{finite,linorder} ⇒ ?'d1::metric_space ⇒ real) i x; ⋀i::'a::{finite,linorder}. bdd_above (?f i ` ?R)⟧ ⟹ (SUP x::?'d1::metric_space∈?R. ∑i::'a::{finite,linorder}∈?S. ?f i x) ≤ (∑i::'a::{finite,linorder}∈?S. Sup (?f i ` ?R))›*)) (*goal: ‹⋀(R::'b set) (S::'a set) (y1::'b) y2::'b. ⟦finite S; R ≠ {}⟧ ⟹ (SUP x::'b∈R. ∑i::'a∈S. norm (blinfun_apply ((f::'a ⇒ 'b ⇒ 'b ⇒⇩L real) i y1) x - blinfun_apply (f i y2) x) / norm x) ≤ (∑i::'a∈S. SUP x::'b∈R. norm (blinfun_apply (f i y1) x - blinfun_apply (f i y2) x) / norm x)›*) apply ((auto)[3]) (*top goal: ‹⋀R S y1 y2. ⟦finite S; R ≠ {}⟧ ⟹ finite S› and 3 goals remain*) proof (unfold bdd_above_def (*‹bdd_above ?A = (∃M. ∀x∈?A. x ≤ M)›*)) (*goal: ‹⋀R S y1 y2 i. ⟦finite S; R ≠ {}⟧ ⟹ ∃M. ∀x∈(λx. norm (blinfun_apply (f i y1) x - blinfun_apply (f i y2) x) / norm x) ` R. x ≤ M›*) fix R and S and y1 and y2 and i { fix rr :: "real ⇒ real" obtain bb :: "real ⇒ ('b ⇒ real) ⇒ 'b set ⇒ 'b" where ff1: "⋀r f B. r ∉ f ` B ∨ f (bb r f B) = r" (*goal: ‹(⋀bb. (⋀r f B. r ∉ f ` B ∨ f (bb r f B) = r) ⟹ thesis) ⟹ thesis›*) unfolding image_iff (*goal: ‹(⋀bb. (⋀r f B. ¬ (∃x∈B. r = f x) ∨ f (bb r f B) = r) ⟹ thesis) ⟹ thesis›*) by moura { assume "∃r. ¬ rr r ≤ norm (f i y1 - f i y2)" (*‹∃r::real. ¬ (rr::real ⇒ real) r ≤ norm ((f::'a ⇒ 'b ⇒ 'b ⇒⇩L real) (i::'a) (y1::'b) - f i (y2::'b))›*) then have "∃r. norm (blinfun_apply (f i y1) (bb (rr r) (λb. norm (blinfun_apply (f i y1) b - blinfun_apply (f i y2) b) / norm b) R) - blinfun_apply (f i y2) (bb (rr r) (λb. norm (blinfun_apply (f i y1) b - blinfun_apply (f i y2) b) / norm b) R)) / norm (bb (rr r) (λb. norm (blinfun_apply (f i y1) b - blinfun_apply (f i y2) b) / norm b) R) ≠ rr r" by (metis (no_types) le_norm_blinfun (*‹norm (blinfun_apply (?f::?'b::real_normed_vector ⇒⇩L ?'a::real_normed_vector) (?x::?'b::real_normed_vector)) / norm ?x ≤ norm ?f›*) minus_blinfun.rep_eq (*‹blinfun_apply ((?x::?'a::real_normed_vector ⇒⇩L ?'b::real_normed_vector) - (?xa::?'a::real_normed_vector ⇒⇩L ?'b::real_normed_vector)) = (λx::?'a::real_normed_vector. blinfun_apply ?x x - blinfun_apply ?xa x)›*)) then have "∃r. rr r ≤ r ∨ rr r ∉ (λb. norm (blinfun_apply (f i y1) b - blinfun_apply (f i y2) b) / norm b) ` R" using ff1 (*‹?r1 ∉ ?f1 ` ?B1 ∨ ?f1 (bb ?r1 ?f1 ?B1) = ?r1›*) by meson } then have "∃r. rr r ≤ r ∨ rr r ∉ (λb. norm (blinfun_apply (f i y1) b - blinfun_apply (f i y2) b) / norm b) ` R" by blast } then show "∃r. ∀ra∈(λb. norm (blinfun_apply (f i y1) b - blinfun_apply (f i y2) b) / norm b) ` R. ra ≤ r" by meson qed have SUM_leq: "⋀S::('a) set. ⋀ f g ::('a ⇒ real). S ≠ {} ⟹ finite S ⟹ (⋀x. x ∈ S ⟹ f x < g x) ⟹ (∑x∈S. f x) < (∑x∈S. g x)" apply (rule sum_strict_mono (*‹⟦finite ?A; ?A ≠ {}; ⋀x. x ∈ ?A ⟹ ?f x < ?g x⟧ ⟹ sum ?f ?A < sum ?g ?A›*)) (*goals: 1. ‹⋀S f g. ⟦S ≠ {}; finite S; ⋀x. x ∈ S ⟹ f x < g x⟧ ⟹ finite S› 2. ‹⋀S f g. ⟦S ≠ {}; finite S; ⋀x. x ∈ S ⟹ f x < g x⟧ ⟹ S ≠ {}› 3. ‹⋀S f g x. ⟦S ≠ {}; finite S; ⋀x. x ∈ S ⟹ f x < g x; x ∈ S⟧ ⟹ f x < g x› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*proven 3 subgoals*) . have L2: "⋀f S. L2_set (λx. norm(f x)) S ≤ (∑x ∈ S. norm(f x))" using L2_set_le_sum (*‹(⋀i. i ∈ ?A ⟹ 0 ≤ ?f i) ⟹ L2_set ?f ?A ≤ sum ?f ?A›*) norm_ge_zero (*‹0 ≤ norm ?x›*) by metis have L2': "⋀y. (L2_set (λi. norm(f i x1 y - f i x2 y)) UNIV)/norm(y) ≤ (∑i∈UNIV. norm(f i x1 y - f i x2 y))/norm(y)" subgoal for y using L2[of "(λ x. f x x1 y - f x x2 y)" UNIV] (*‹L2_set (λx. norm (blinfun_apply (f x x1) y - blinfun_apply (f x x2) y)) UNIV ≤ (∑x∈UNIV. norm (blinfun_apply (f x x1) y - blinfun_apply (f x x2) y))›*) by (auto simp add: divide_right_mono (*‹⟦?a ≤ ?b; 0 ≤ ?c⟧ ⟹ ?a / ?c ≤ ?b / ?c›*)) . have "⋀i. (SUP y∈UNIV. norm((f i x1 - f i x2) y)/norm(y)) = norm(f i x1 - f i x2)" by (simp add: onorm_def (*‹onorm ?f = (SUP x. norm (?f x) / norm x)›*) norm_blinfun.rep_eq (*‹norm ?x = onorm (blinfun_apply ?x)›*)) then have each_norm: "⋀i. (SUP y∈UNIV. norm(f i x1 y - f i x2 y)/norm(y)) = norm(f i x1 - f i x2)" by (metis (no_types, lifting) SUP_cong (*‹⟦?A = ?B; ⋀x. x ∈ ?B ⟹ ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) blinfun.diff_left (*‹blinfun_apply (?a - ?a') ?b = blinfun_apply ?a ?b - blinfun_apply ?a' ?b›*)) have bounded_linear: "⋀i. bounded_linear (λy. f i x1 y - f i x2 y)" by (simp add: blinfun.bounded_linear_right (*‹bounded_linear (blinfun_apply ?a)›*) bounded_linear_sub (*‹⟦bounded_linear ?f; bounded_linear ?g⟧ ⟹ bounded_linear (λx. ?f x - ?g x)›*)) have each_bound: "⋀i. bdd_above ((λy. norm(f i x1 y - f i x2 y)/norm(y)) ` UNIV)" using bounded_linear (*‹bounded_linear (λy::'b. blinfun_apply ((f::'a ⇒ 'b ⇒ 'b ⇒⇩L real) (?i2::'a) (x1::'b)) y - blinfun_apply (f ?i2 (x2::'b)) y)›*) unfolding bdd_above_def (*goal: ‹⋀i. ∃M. ∀x∈range (λy. norm (blinfun_apply (f i x1) y - blinfun_apply (f i x2) y) / norm y). x ≤ M›*) proof (-) (*goal: ‹⋀i. (⋀i. bounded_linear (λy. blinfun_apply (f i x1) y - blinfun_apply (f i x2) y)) ⟹ ∃M. ∀x∈range (λy. norm (blinfun_apply (f i x1) y - blinfun_apply (f i x2) y) / norm y). x ≤ M›*) fix i :: 'a { fix rr :: "real ⇒ real" have "⋀a r. norm (blinfun_apply (f a x1) r - blinfun_apply (f a x2) r) / norm r ≤ norm (f a x1 - f a x2)" by (metis le_norm_blinfun (*‹norm (blinfun_apply ?f ?x) / norm ?x ≤ norm ?f›*) minus_blinfun.rep_eq (*‹blinfun_apply (?x - ?xa) = (λx. blinfun_apply ?x x - blinfun_apply ?xa x)›*)) then have "⋀r R. r ∉ (λr. norm (blinfun_apply (f i x1) r - blinfun_apply (f i x2) r) / norm r) ` R ∨ r ≤ norm (f i x1 - f i x2)" by blast then have "∃r. rr r ≤ r ∨ rr r ∉ range (λr. norm (blinfun_apply (f i x1) r - blinfun_apply (f i x2) r) / norm r)" by blast } then show "∃r. ∀ra∈range (λr. norm (blinfun_apply (f i x1) r - blinfun_apply (f i x2) r) / norm r). ra ≤ r" by meson qed have bdd_above: "(bdd_above ((λy. (∑i∈UNIV. norm(f i x1 y - f i x2 y)/norm(y))) ` UNIV))" using each_bound (*‹bdd_above (range (λy. norm (blinfun_apply (f ?i2 x1) y - blinfun_apply (f ?i2 x2) y) / norm y))›*) unfolding bdd_above_def (*goal: ‹∃M. ∀x∈range (λy. ∑i∈UNIV. norm (blinfun_apply (f i x1) y - blinfun_apply (f i x2) y) / norm y). x ≤ M›*) proof (auto) (*goal: ‹(⋀i. ∃M. ∀x. ¦blinfun_apply (f i x1) x - blinfun_apply (f i x2) x¦ / norm x ≤ M) ⟹ ∃M. ∀x. (∑i∈UNIV. ¦blinfun_apply (f i x1) x - blinfun_apply (f i x2) x¦ / norm x) ≤ M›*) assume each: "(⋀i. ∃M. ∀x. ¦blinfun_apply (f i x1) x - blinfun_apply (f i x2) x¦ / norm x ≤ M)" (*‹∃M::real. ∀x::'b. ¦blinfun_apply ((f::'a ⇒ 'b ⇒ 'b ⇒⇩L real) (?i2::'a) (x1::'b)) x - blinfun_apply (f ?i2 (x2::'b)) x¦ / norm x ≤ M›*) let ?boundP = "(λi M. ∀x. ¦blinfun_apply (f i x1) x - blinfun_apply (f i x2) x¦ / norm x ≤ M)" let ?bound = "(λi. SOME x. ?boundP i x)" have bounds: "⋀i. ?boundP i (?bound i)" subgoal for i using each (*‹∃M. ∀x. ¦blinfun_apply (f ?i2 x1) x - blinfun_apply (f ?i2 x2) x¦ / norm x ≤ M›*) someI[of "?boundP i"] (*‹∀x. ¦blinfun_apply (f i x1) x - blinfun_apply (f i x2) x¦ / norm x ≤ ?x ⟹ ∀x. ¦blinfun_apply (f i x1) x - blinfun_apply (f i x2) x¦ / norm x ≤ (SOME M. ∀x. ¦blinfun_apply (f i x1) x - blinfun_apply (f i x2) x¦ / norm x ≤ M)›*) by blast . let ?bigBound = "∑i∈(UNIV::'a set). ?bound i" show "∃M. ∀x. (∑i∈UNIV. ¦blinfun_apply (f i x1) x - blinfun_apply (f i x2) x¦ / norm x) ≤ M" apply (rule exI[where x= ?bigBound] (*‹?P (∑i∈UNIV. SOME x. ∀xa. ¦blinfun_apply (f i x1) xa - blinfun_apply (f i x2) xa¦ / norm xa ≤ x) ⟹ ∃x. ?P x›*)) (*goal: ‹∃M. ∀x. (∑i∈UNIV. ¦blinfun_apply (f i x1) x - blinfun_apply (f i x2) x¦ / norm x) ≤ M›*) by (auto simp add: bounds (*‹∀x. ¦blinfun_apply (f ?i2 x1) x - blinfun_apply (f ?i2 x2) x¦ / norm x ≤ (SOME x. ∀xa. ¦blinfun_apply (f ?i2 x1) xa - blinfun_apply (f ?i2 x2) xa¦ / norm xa ≤ x)›*) sum_mono (*‹(⋀i. i ∈ ?K ⟹ ?f i ≤ ?g i) ⟹ sum ?f ?K ≤ sum ?g ?K›*)) qed have bdd_above: "(bdd_above ((λy. (∑i∈UNIV. norm(f i x1 y - f i x2 y))/norm(y)) ` UNIV))" using bdd_above (*‹bdd_above (range (λy. ∑i∈UNIV. norm (blinfun_apply (f i x1) y - blinfun_apply (f i x2) y) / norm y))›*) unfolding bdd_above_def (*goal: ‹∃M. ∀x∈range (λy. (∑i∈UNIV. norm (blinfun_apply (f i x1) y - blinfun_apply (f i x2) y)) / norm y). x ≤ M›*) proof (auto) (*goal: ‹⋀M. ∀x. (∑i∈UNIV. ¦blinfun_apply (f i x1) x - blinfun_apply (f i x2) x¦ / norm x) ≤ M ⟹ ∃M. ∀x. (∑i∈UNIV. ¦blinfun_apply (f i x1) x - blinfun_apply (f i x2) x¦) / norm x ≤ M›*) fix M :: real assume a1: "∀x. (∑i∈UNIV. ¦blinfun_apply (f i x1) x - blinfun_apply (f i x2) x¦ / norm x) ≤ M" (*‹∀x::'b. (∑i::'a∈UNIV. ¦blinfun_apply ((f::'a ⇒ 'b ⇒ 'b ⇒⇩L real) i (x1::'b)) x - blinfun_apply (f i (x2::'b)) x¦ / norm x) ≤ (M::real)›*) { fix bb :: "real ⇒ 'b" have "⋀b. (∑a∈UNIV. ¦blinfun_apply (f a x1) b - blinfun_apply (f a x2) b¦) / norm b ≤ M" using a1 (*‹∀x. (∑i∈UNIV. ¦blinfun_apply (f i x1) x - blinfun_apply (f i x2) x¦ / norm x) ≤ M›*) by (simp add: sum_divide_distrib (*‹sum (?f::?'b ⇒ ?'a) (?A::?'b set) / (?r::?'a) = (∑n::?'b∈?A. ?f n / ?r)›*)) then have "∃r. (∑a∈UNIV. ¦blinfun_apply (f a x1) (bb r) - blinfun_apply (f a x2) (bb r)¦) / norm (bb r) ≤ r" by blast } then show "∃r. ∀b. (∑a∈UNIV. ¦blinfun_apply (f a x1) b - blinfun_apply (f a x2) b¦) / norm b ≤ r" by meson qed have "dist (?f x2) (?f x1) = norm((?f x2) - (?f x1))" by (simp add: dist_blinfun_def (*‹dist ?a ?b = norm (?a - ?b)›*)) moreover have "... = (SUP y∈UNIV. norm(?f x1 y - ?f x2 y)/norm(y))" by (metis (no_types, lifting) SUP_cong (*‹⟦(?A::?'b set) = (?B::?'b set); ⋀x::?'b. x ∈ ?B ⟹ (?C::?'b ⇒ ?'a) x = (?D::?'b ⇒ ?'a) x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) blinfun.diff_left (*‹blinfun_apply ((?a::?'a ⇒⇩L ?'b) - (?a'::?'a ⇒⇩L ?'b)) (?b::?'a) = blinfun_apply ?a ?b - blinfun_apply ?a' ?b›*) norm_blinfun.rep_eq (*‹norm (?x::?'a ⇒⇩L ?'b) = onorm (blinfun_apply ?x)›*) norm_minus_commute (*‹norm ((?a::?'a) - (?b::?'a)) = norm (?b - ?a)›*) onorm_def (*‹onorm (?f::?'a ⇒ ?'b) = (SUP x::?'a. norm (?f x) / norm x)›*)) moreover have "... = (SUP y∈UNIV. (L2_set (λi. norm(f i x1 y - f i x2 y)) UNIV)/norm(y))" using euclid (*‹norm (blinfun_apply (blinfun_vec (λi. f i x1)) ?y - blinfun_apply (blinfun_vec (λi. f i x2)) ?y) = L2_set (λi. norm (blinfun_apply (f i x1) ?y - blinfun_apply (f i x2) ?y)) UNIV›*) by auto moreover have "... ≤ (SUP y∈UNIV. (∑i∈UNIV. norm(f i x1 y - f i x2 y))/norm(y))" using L2' (*‹L2_set (λi. norm (blinfun_apply (f i x1) ?y2 - blinfun_apply (f i x2) ?y2)) UNIV / norm ?y2 ≤ (∑i∈UNIV. norm (blinfun_apply (f i x1) ?y2 - blinfun_apply (f i x2) ?y2)) / norm ?y2›*) SUP_cong (*‹⟦?A = ?B; ⋀x. x ∈ ?B ⟹ ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) SUP_leq (*‹⟦?S ≠ {}; bdd_above (?g ` ?S); ⋀x. x ∈ ?S ⟹ ?f x ≤ ?g x⟧ ⟹ Sup (?f ` ?S) ≤ Sup (?g ` ?S)›*) bdd_above (*‹bdd_above (range (λy::'b::{abs,real_normed_vector}. (∑i::'a::{finite,linorder}∈UNIV. norm (blinfun_apply ((f::'a::{finite,linorder} ⇒ 'b::{abs,real_normed_vector} ⇒ 'b::{abs,real_normed_vector} ⇒⇩L real) i (x1::'b::{abs,real_normed_vector})) y - blinfun_apply (f i (x2::'b::{abs,real_normed_vector})) y)) / norm y))›*) by auto moreover have "... = (SUP y∈UNIV. (∑i∈UNIV. norm(f i x1 y - f i x2 y)/norm(y)))" by (simp add: sum_divide_distrib (*‹sum (?f::?'b ⇒ ?'a) (?A::?'b set) / (?r::?'a) = (∑n::?'b∈?A. ?f n / ?r)›*)) moreover have "... ≤ (∑i∈UNIV. (SUP y∈UNIV. norm(f i x1 y - f i x2 y)/norm(y)))" by (rule SUP_sum_comm[OF finite nonemptyB, of x1 x2] (*‹(SUP x. ∑i∈UNIV. norm (blinfun_apply (f i x1) x - blinfun_apply (f i x2) x) / norm x) ≤ (∑i∈UNIV. SUP x. norm (blinfun_apply (f i x1) x - blinfun_apply (f i x2) x) / norm x)›*)) moreover have "... = (∑i∈UNIV. norm(f i x1 - f i x2))" using each_norm (*‹(SUP y. norm (blinfun_apply (f ?i2 x1) y - blinfun_apply (f ?i2 x2) y) / norm y) = norm (f ?i2 x1 - f ?i2 x2)›*) by simp moreover have "... = (∑i∈UNIV. dist(f i x1) (f i x2))" by (simp add: dist_blinfun_def (*‹dist ?a ?b = norm (?a - ?b)›*)) moreover have "... < (∑i∈(UNIV::'a set). ε / ?n)" using conts'''[OF ne dists] (*‹dist (f ?i x2) (f ?i x1) < ε / real CARD('a)›*) using SUM_leq[OF nonempty, of "(λi. dist (f i x1) (f i x2))" "(λi. ε / ?n)"] (*‹⟦finite UNIV; ⋀x. x ∈ UNIV ⟹ dist (f x x1) (f x x2) < ε / real CARD('a)⟧ ⟹ (∑x∈UNIV. dist (f x x1) (f x x2)) < (∑x∈UNIV. ε / real CARD('a))›*) by (simp add: dist_commute (*‹dist ?x ?y = dist ?y ?x›*)) moreover have "... = ε" by auto ultimately show "dist (?f x2) (?f x1) < ε" by linarith qed then show "∃s>0. ∀x2. x2 ≠ x1 ∧ dist x2 x1 < s ⟶ dist (blinfun_vec (λi. f i x2)) (blinfun_vec (λi. f i x1)) < ε" using "δ" (*‹0 < (MIN i. SOME δ. 0 < δ ∧ (∀x2. x2 ≠ x1 ∧ dist x2 x1 < δ ⟶ dist (f i x2) (f i x1) < ε / real CARD('a)))›*) by blast qed lemma has_derivative_vec[derivative_intros]: assumes "⋀i. ((λx. f i x) has_derivative (λh. f' i h)) F" shows "((λx. χ i. f i x) has_derivative (λh. χ i. f' i h)) F" proof (-) (*goal: ‹((λx. χi. f i x) has_derivative (λh. χi. f' i h)) F›*) have "*": "(χ i. f i x) = (∑i∈UNIV. axis i (f i x))" "(χ i. f' i x) = (∑i∈UNIV. axis i (f' i x))" for x (*goals: 1. ‹(χi. f i x) = (∑i∈UNIV. axis i (f i x))› 2. ‹(χi. f' i x) = (∑i∈UNIV. axis i (f' i x))› discuss goal 1*) apply (simp add: axis_def (*‹axis (?k::?'b) (?x::?'a) = (χi::?'b. if i = ?k then ?x else (0::?'a))›*) sum.If_cases (*‹finite (?A::?'b set) ⟹ (∑x::?'b∈?A. if (?P::?'b ⇒ bool) x then (?h::?'b ⇒ ?'a) x else (?g::?'b ⇒ ?'a) x) = sum ?h (?A ∩ {x::?'b. ?P x}) + sum ?g (?A ∩ - {x::?'b. ?P x})›*) vec_eq_iff (*‹((?x::(?'a, ?'b) vec) = (?y::(?'a, ?'b) vec)) = (∀i::?'b. ?x $ i = ?y $ i)›*)) (*discuss goal 2*) apply (simp add: axis_def (*‹axis ?k ?x = (χi. if i = ?k then ?x else 0)›*) sum.If_cases (*‹finite ?A ⟹ (∑x∈?A. if ?P x then ?h x else ?g x) = sum ?h (?A ∩ {x. ?P x}) + sum ?g (?A ∩ - {x. ?P x})›*) vec_eq_iff (*‹(?x = ?y) = (∀i. ?x $ i = ?y $ i)›*)) (*proven 2 subgoals*) . show "?thesis" (*goal: ‹((λx. χi. f i x) has_derivative (λh. χi. f' i h)) F›*) unfolding "*" (*goal: ‹((λx. ∑i∈UNIV. axis i (f i x)) has_derivative (λh. ∑i∈UNIV. axis i (f' i h))) F›*) by (intro has_derivative_sum (*‹(⋀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›*) bounded_linear.has_derivative[OF bounded_linear_axis] (*‹(?g has_derivative ?g') ?F ⟹ ((λx. axis ?i1 (?g x)) has_derivative (λx. axis ?i1 (?g' x))) ?F›*) assms (*‹(f ?i has_derivative f' ?i) F›*)) qed lemma has_derivative_proj: fixes j::"('a::finite)" fixes f::"'a ⇒ real ⇒ real" assumes assm:"((λx. χ i. f i x) has_derivative (λh. χ i. f' i h)) F" shows "((λx. f j x) has_derivative (λh. f' j h)) F" proof (-) (*goal: ‹(f j has_derivative f' j) F›*) have bounded_proj: "bounded_linear (λ x::(real^'a). x $ j)" by (simp add: bounded_linear_vec_nth (*‹bounded_linear (λx. x $ ?i)›*)) show "?thesis" (*goal: ‹(f j has_derivative f' j) F›*) using bounded_linear.has_derivative[OF bounded_proj, of "(λx. χ i. f i x)" "(λh. χ i. f' i h)", OF assm] (*‹((λx. (χi. f i x) $ j) has_derivative (λx. (χi. f' i x) $ j)) F›*) by auto qed lemma has_derivative_proj': fixes i::"'a::finite" shows "∀x. ((λ x. x $ i) has_derivative (λx::(real^'a). x $ i)) (at x)" proof (-) (*goal: ‹∀x. ((λx. x $ i) has_derivative (λx. x $ i)) (at x)›*) have bounded_proj: "bounded_linear (λ x::(real^'a). x $ i)" by (simp add: bounded_linear_vec_nth (*‹bounded_linear (λx. x $ ?i)›*)) show "?thesis" (*goal: ‹∀x. ((λx. x $ i) has_derivative (λx. x $ i)) (at x)›*) using bounded_proj (*‹bounded_linear (λx. x $ i)›*) unfolding has_derivative_def (*goal: ‹∀x. bounded_linear (λx. x $ i) ∧ (λy. (y $ i - netlimit (at x) $ i - (y - netlimit (at x)) $ i) /⇩R norm (y - netlimit (at x))) ─x→ 0›*) by auto qed lemma constant_when_zero: fixes v::"real ⇒ (real, 'i::finite) vec" assumes x0: "(v t0) $ i = x0" assumes sol: "(v solves_ode f) T S" assumes f0: "⋀s x. s ∈ T ⟹ f s x $ i = 0" assumes t0:"t0 ∈ T" assumes t:"t ∈ T" assumes convex:"convex T" shows "v t $ i = x0" proof (-) (*goal: ‹v t $ i = x0›*) from solves_odeD[OF sol] (*‹(v has_vderiv_on (λt. f t (v t))) T› ‹?t ∈ T ⟹ v ?t ∈ S›*) have deriv: "(v has_vderiv_on (λt. f t (v t))) T" by simp then have "((λt. v t $ i) has_vderiv_on (λt. 0)) T" using f0 (*‹?s ∈ T ⟹ f ?s ?x $ i = 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›*) cart_eq_inner_axis (*‹?a $ ?i = ?a ∙ axis ?i 1›*) 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 137 facts*)) from has_vderiv_on_zero_constant[OF convex this] (*‹(⋀c::real. (⋀x::real. x ∈ (T::real set) ⟹ (v::real ⇒ (real, 'i) vec) x $ (i::'i) = c) ⟹ ?thesis::bool) ⟹ ?thesis›*) obtain c where c: "⋀x. x ∈ T ⟹ v x $ i = c" (*goal: ‹(⋀c. (⋀x. x ∈ T ⟹ v x $ i = c) ⟹ thesis) ⟹ thesis›*) by blast with x0 (*‹v t0 $ i = x0›*) have "c = x0" "v t $ i = c" using t (*‹(t::real) ∈ (T::real set)›*) t0 (*‹t0 ∈ T›*) c (*‹?x ∈ T ⟹ v ?x $ i = c›*) x0 (*‹v t0 $ i = x0›*) apply - (*goals: 1. ‹⟦v t0 $ i = x0; ⋀x. x ∈ T ⟹ v x $ i = c; t ∈ T; t0 ∈ T; ⋀x. x ∈ T ⟹ v x $ i = c; v t0 $ i = x0⟧ ⟹ c = x0› 2. ‹⟦v t0 $ i = x0; ⋀x. x ∈ T ⟹ v x $ i = c; t ∈ T; t0 ∈ T; ⋀x. x ∈ T ⟹ v x $ i = c; v t0 $ i = x0⟧ ⟹ v t $ i = c› discuss goal 1*) apply blast (*discuss goal 2*) apply blast (*proven 2 subgoals*) . then show "?thesis" (*goal: ‹v t $ i = x0›*) by simp qed lemma solves_ode_subset: assumes x: "(x solves_ode f) T X" assumes s: "S ⊆ T" shows "(x solves_ode f) S X" 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: ‹((x::real ⇒ 'a) solves_ode (f::real ⇒ 'a ⇒ 'a)) (S::real set) (X::'a set)›*) using has_vderiv_on_subset (*‹⟦(?f has_vderiv_on ?f') ?S; ?T ⊆ ?S⟧ ⟹ (?f has_vderiv_on ?f') ?T›*) s (*‹S ⊆ T›*) solves_ode_vderivD (*‹(?y solves_ode ?f) ?T ?X ⟹ (?y has_vderiv_on (λt. ?f t (?y t))) ?T›*) x (*‹((x::real ⇒ 'a) solves_ode (f::real ⇒ 'a ⇒ 'a)) (T::real set) (X::'a set)›*) apply force (*top goal: ‹(x has_vderiv_on (λt. f t (x t))) S› and 1 goal remains*) using assms (*‹(x solves_ode f) T X› ‹S ⊆ T›*) 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›*) dest!: solves_ode_domainD (*‹⟦(?y solves_ode ?f) ?T ?X; ?t ∈ ?T⟧ ⟹ ?y ?t ∈ ?X›*)) lemma solves_ode_supset_range: assumes x: "(x solves_ode f) T X" assumes y: "X ⊆ Y" shows "(x solves_ode f) T Y" 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: ‹((x::real ⇒ 'a) solves_ode (f::real ⇒ 'a ⇒ 'a)) (T::real set) (Y::'a set)›*) using has_vderiv_on_subset (*‹⟦(?f has_vderiv_on ?f') ?S; ?T ⊆ ?S⟧ ⟹ (?f has_vderiv_on ?f') ?T›*) y (*‹X ⊆ Y›*) solves_ode_vderivD (*‹(?y solves_ode ?f) ?T ?X ⟹ (?y has_vderiv_on (λt. ?f t (?y t))) ?T›*) x (*‹(x solves_ode f) T X›*) apply force (*top goal: ‹(x has_vderiv_on (λt. f t (x t))) T› and 1 goal remains*) using assms (*‹(x solves_ode f) T X› ‹X ⊆ Y›*) by (auto intro!: 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›*) dest!: solves_ode_domainD (*‹⟦((?y::real ⇒ ?'a) solves_ode (?f::real ⇒ ?'a ⇒ ?'a)) (?T::real set) (?X::?'a set); (?t::real) ∈ ?T⟧ ⟹ ?y ?t ∈ ?X›*)) lemma usolves_ode_subset: assumes x: "(x usolves_ode f from t0) T X" assumes s: "S ⊆ T" assumes t0: "t0 ∈ S" assumes S: "is_interval S" shows "(x usolves_ode f from t0) S X" proof (rule usolves_odeI (*‹⟦(?y solves_ode ?f) ?T ?X; ?t0.0 ∈ ?T; is_interval ?T; ⋀z t. ⟦{?t0.0--t} ⊆ ?T; (z solves_ode ?f) {?t0.0--t} ?X; z ?t0.0 = ?y ?t0.0⟧ ⟹ z t = ?y t⟧ ⟹ (?y usolves_ode ?f from ?t0.0) ?T ?X›*)) (*goals: 1. ‹(x solves_ode f) S X› 2. ‹t0 ∈ S› 3. ‹is_interval S› 4. ‹⋀z t. ⟦{t0--t} ⊆ S; (z solves_ode f) {t0--t} X; z t0 = x t0⟧ ⟹ z t = x t›*) note usolves_odeD[OF x] (*‹((x::real ⇒ 'a) solves_ode (f::real ⇒ 'a ⇒ 'a)) (T::real set) (X::'a set)› ‹t0 ∈ T› ‹is_interval T› ‹⟦t0 ∈ ?T'; is_interval ?T'; ?T' ⊆ T; (?z solves_ode f) ?T' X; ?z t0 = x t0; ?t ∈ ?T'⟧ ⟹ ?z ?t = x ?t›*) show "(x solves_ode f) S X" apply (rule solves_ode_subset (*‹⟦(?x solves_ode ?f) ?T ?X; ?S ⊆ ?T⟧ ⟹ (?x solves_ode ?f) ?S ?X›*)) (*goals: 1. ‹(x solves_ode f) ?T X› 2. ‹S ⊆ ?T› discuss goal 1*) apply fact (*discuss goal 2*) apply fact (*proven 2 subgoals*) . show "t0 ∈ S" "is_interval S" (*goals: 1. ‹t0 ∈ S› 2. ‹is_interval S› discuss goal 1*) apply fact (*discuss goal 2*) apply fact (*proven 2 subgoals*) . fix z and t assume s: "{t0 -- t} ⊆ S" and z: "(z solves_ode f) {t0 -- t} X" and z0: "z t0 = x t0" (*‹{t0::real--t::real} ⊆ (S::real set)› ‹((z::real ⇒ 'a) solves_ode (f::real ⇒ 'a ⇒ 'a)) {t0::real--t::real} (X::'a set)› ‹(z::real ⇒ 'a) (t0::real) = (x::real ⇒ 'a) t0›*) then have "t0 ∈ {t0 -- t}" "is_interval {t0 -- t}" (*goals: 1. ‹t0 ∈ {t0--t}› 2. ‹is_interval {t0--t}› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . moreover note s (*‹{t0--t} ⊆ S›*) moreover have "(z solves_ode f) {t0--t} X" using solves_odeD[OF z] (*‹(z has_vderiv_on (λt. f t (z t))) {t0--t}› ‹?t ∈ {t0--t} ⟹ z ?t ∈ X›*) ‹S ⊆ T› (*‹S ⊆ T›*) apply (intro solves_ode_subset_range[OF z] (*‹z ` {t0--t} ⊆ ?Y ⟹ (z solves_ode f) {t0--t} ?Y›*)) (*goal: ‹(z solves_ode f) {t0--t} X›*) by force moreover note z0 (*‹z t0 = x t0›*) moreover have "t ∈ {t0 -- t}" by simp ultimately show "z t = x t" by (meson ‹⋀z ta T'. ⟦t0 ∈ T'; is_interval T'; T' ⊆ T; (z solves_ode f) T' X; z t0 = x t0; ta ∈ T'⟧ ⟹ z ta = x ta› assms( (*‹S ⊆ T›*) 2) dual_order.trans (*‹⟦?b ≤ ?a; ?c ≤ ?b⟧ ⟹ ?c ≤ ?a›*)) qed<close> lemma example: fixes x t::real and i::"('sz::finite)" assumes "t > 0" shows "x = (ll_on_open.flow UNIV (λt. λx. χ (i::('sz::finite)). 0) UNIV 0 (χ i. x) t) $ i" proof (-) (*goal: ‹x = ll_on_open.flow UNIV (λt x. χi. 0) UNIV 0 (χi. x) t $ i›*) let ?T = UNIV let ?f = "(λt. λx. χ i::('sz::finite). 0)" let ?X = UNIV let ?t0.0 = 0 let ?x0.0 = "χ i::('sz::finite). x" interpret ll: ll_on_open UNIV "(λt x. χ i::('sz::finite). 0)" UNIV using gt_ex (*‹∃y. ?x < y›*) apply unfold_locales (*goals: 1. ‹(⋀x. ∃y. x < y) ⟹ is_interval UNIV› 2. ‹(⋀x. ∃y. x < y) ⟹ local_lipschitz UNIV UNIV (λt x. χi. 0)› 3. ‹⋀x. ⟦⋀x. ∃y. x < y; x ∈ UNIV⟧ ⟹ continuous_on UNIV (λt. χi. 0)› 4. ‹(⋀x. ∃y. x < y) ⟹ open UNIV› 5. ‹(⋀x. ∃y. x < y) ⟹ open UNIV› discuss goal 1*) apply ((auto simp: interval_def (*‹interval ?T ≡ is_interval ?T›*) continuous_on_def (*‹continuous_on ?s ?f = (∀x∈?s. (?f ⤏ ?f x) (at x within ?s))›*) local_lipschitz_def (*‹local_lipschitz ?T ?X ?f ≡ ∀x∈?X. ∀t∈?T. ∃u>0. ∃L. ∀t∈cball t u ∩ ?T. L-lipschitz_on (cball x u ∩ ?X) (?f t)›*) intro!: lipschitz_intros (*‹⟦?C-lipschitz_on ?U ?f; ?D-lipschitz_on (?f ` ?U) ?g⟧ ⟹ (?D * ?C)-lipschitz_on ?U (?g ∘ ?f)› ‹0 ≤ ?C ⟹ ?C-lipschitz_on {?x} ?f› ‹0 ≤ ?C ⟹ ?C-lipschitz_on {} ?f› ‹1-lipschitz_on ?U (λx. x)› ‹0-lipschitz_on ?U (λx. ?c)› ‹⟦?C-lipschitz_on ?U ?f; ?D-lipschitz_on ?U ?g⟧ ⟹ (?C + ?D)-lipschitz_on ?U (λx. ?f x + ?g x)› ‹?C-lipschitz_on ?U ?f ⟹ (¦?a¦ * ?C)-lipschitz_on ?U (λx. ?a *⇩R ?f x)› ‹?C-lipschitz_on ?U ?f ⟹ (¦?a¦ * ?C)-lipschitz_on ?U (λx. ?a * ?f x)› ‹⟦?C-lipschitz_on ?U ?f; 0 ≤ ?a⟧ ⟹ (?a * ?C)-lipschitz_on ?U (λx. ?a *⇩R ?f x)› ‹⟦?C-lipschitz_on ?U ?f; 0 ≤ ?a⟧ ⟹ (?a * ?C)-lipschitz_on ?U (λx. ?a * ?f x)› ‹⟦?C-lipschitz_on ?U ?f; ¦?a¦ ≤ ?D⟧ ⟹ (?D * ?C)-lipschitz_on ?U (λx. ?a *⇩R ?f x)› ‹⟦?C-lipschitz_on ?U ?f; ¦?a¦ ≤ ?D⟧ ⟹ (?D * ?C)-lipschitz_on ?U (λx. ?a * ?f x)› and more 4 facts*))[1]) (*discuss goal 2*) apply ((auto simp: interval_def (*‹interval ?T ≡ is_interval ?T›*) continuous_on_def (*‹continuous_on ?s ?f = (∀x∈?s. (?f ⤏ ?f x) (at x within ?s))›*) local_lipschitz_def (*‹local_lipschitz ?T ?X ?f ≡ ∀x∈?X. ∀t∈?T. ∃u>0. ∃L. ∀t∈cball t u ∩ ?T. L-lipschitz_on (cball x u ∩ ?X) (?f t)›*) intro!: lipschitz_intros (*‹⟦?C-lipschitz_on ?U ?f; ?D-lipschitz_on (?f ` ?U) ?g⟧ ⟹ (?D * ?C)-lipschitz_on ?U (?g ∘ ?f)› ‹0 ≤ ?C ⟹ ?C-lipschitz_on {?x} ?f› ‹0 ≤ ?C ⟹ ?C-lipschitz_on {} ?f› ‹1-lipschitz_on ?U (λx. x)› ‹0-lipschitz_on ?U (λx. ?c)› ‹⟦?C-lipschitz_on ?U ?f; ?D-lipschitz_on ?U ?g⟧ ⟹ (?C + ?D)-lipschitz_on ?U (λx. ?f x + ?g x)› ‹?C-lipschitz_on ?U ?f ⟹ (¦?a¦ * ?C)-lipschitz_on ?U (λx. ?a *⇩R ?f x)› ‹?C-lipschitz_on ?U ?f ⟹ (¦?a¦ * ?C)-lipschitz_on ?U (λx. ?a * ?f x)› ‹⟦?C-lipschitz_on ?U ?f; 0 ≤ ?a⟧ ⟹ (?a * ?C)-lipschitz_on ?U (λx. ?a *⇩R ?f x)› ‹⟦?C-lipschitz_on ?U ?f; 0 ≤ ?a⟧ ⟹ (?a * ?C)-lipschitz_on ?U (λx. ?a * ?f x)› ‹⟦?C-lipschitz_on ?U ?f; ¦?a¦ ≤ ?D⟧ ⟹ (?D * ?C)-lipschitz_on ?U (λx. ?a *⇩R ?f x)› ‹⟦?C-lipschitz_on ?U ?f; ¦?a¦ ≤ ?D⟧ ⟹ (?D * ?C)-lipschitz_on ?U (λx. ?a * ?f x)› and more 4 facts*))[1]) (*discuss goal 3*) apply ((auto simp: interval_def (*‹interval ?T ≡ is_interval ?T›*) continuous_on_def (*‹continuous_on ?s ?f = (∀x∈?s. (?f ⤏ ?f x) (at x within ?s))›*) local_lipschitz_def (*‹local_lipschitz ?T ?X ?f ≡ ∀x∈?X. ∀t∈?T. ∃u>0. ∃L. ∀t∈cball t u ∩ ?T. L-lipschitz_on (cball x u ∩ ?X) (?f t)›*) intro!: lipschitz_intros (*‹⟦?C-lipschitz_on ?U ?f; ?D-lipschitz_on (?f ` ?U) ?g⟧ ⟹ (?D * ?C)-lipschitz_on ?U (?g ∘ ?f)› ‹0 ≤ ?C ⟹ ?C-lipschitz_on {?x} ?f› ‹0 ≤ ?C ⟹ ?C-lipschitz_on {} ?f› ‹1-lipschitz_on ?U (λx. x)› ‹0-lipschitz_on ?U (λx. ?c)› ‹⟦?C-lipschitz_on ?U ?f; ?D-lipschitz_on ?U ?g⟧ ⟹ (?C + ?D)-lipschitz_on ?U (λx. ?f x + ?g x)› ‹?C-lipschitz_on ?U ?f ⟹ (¦?a¦ * ?C)-lipschitz_on ?U (λx. ?a *⇩R ?f x)› ‹?C-lipschitz_on ?U ?f ⟹ (¦?a¦ * ?C)-lipschitz_on ?U (λx. ?a * ?f x)› ‹⟦?C-lipschitz_on ?U ?f; 0 ≤ ?a⟧ ⟹ (?a * ?C)-lipschitz_on ?U (λx. ?a *⇩R ?f x)› ‹⟦?C-lipschitz_on ?U ?f; 0 ≤ ?a⟧ ⟹ (?a * ?C)-lipschitz_on ?U (λx. ?a * ?f x)› ‹⟦?C-lipschitz_on ?U ?f; ¦?a¦ ≤ ?D⟧ ⟹ (?D * ?C)-lipschitz_on ?U (λx. ?a *⇩R ?f x)› ‹⟦?C-lipschitz_on ?U ?f; ¦?a¦ ≤ ?D⟧ ⟹ (?D * ?C)-lipschitz_on ?U (λx. ?a * ?f x)› and more 4 facts*))[1]) (*discuss goal 4*) apply ((auto simp: interval_def (*‹interval ?T ≡ is_interval ?T›*) continuous_on_def (*‹continuous_on ?s ?f = (∀x∈?s. (?f ⤏ ?f x) (at x within ?s))›*) local_lipschitz_def (*‹local_lipschitz ?T ?X ?f ≡ ∀x∈?X. ∀t∈?T. ∃u>0. ∃L. ∀t∈cball t u ∩ ?T. L-lipschitz_on (cball x u ∩ ?X) (?f t)›*) intro!: lipschitz_intros (*‹⟦?C-lipschitz_on ?U ?f; ?D-lipschitz_on (?f ` ?U) ?g⟧ ⟹ (?D * ?C)-lipschitz_on ?U (?g ∘ ?f)› ‹0 ≤ ?C ⟹ ?C-lipschitz_on {?x} ?f› ‹0 ≤ ?C ⟹ ?C-lipschitz_on {} ?f› ‹1-lipschitz_on ?U (λx. x)› ‹0-lipschitz_on ?U (λx. ?c)› ‹⟦?C-lipschitz_on ?U ?f; ?D-lipschitz_on ?U ?g⟧ ⟹ (?C + ?D)-lipschitz_on ?U (λx. ?f x + ?g x)› ‹?C-lipschitz_on ?U ?f ⟹ (¦?a¦ * ?C)-lipschitz_on ?U (λx. ?a *⇩R ?f x)› ‹?C-lipschitz_on ?U ?f ⟹ (¦?a¦ * ?C)-lipschitz_on ?U (λx. ?a * ?f x)› ‹⟦?C-lipschitz_on ?U ?f; 0 ≤ ?a⟧ ⟹ (?a * ?C)-lipschitz_on ?U (λx. ?a *⇩R ?f x)› ‹⟦?C-lipschitz_on ?U ?f; 0 ≤ ?a⟧ ⟹ (?a * ?C)-lipschitz_on ?U (λx. ?a * ?f x)› ‹⟦?C-lipschitz_on ?U ?f; ¦?a¦ ≤ ?D⟧ ⟹ (?D * ?C)-lipschitz_on ?U (λx. ?a *⇩R ?f x)› ‹⟦?C-lipschitz_on ?U ?f; ¦?a¦ ≤ ?D⟧ ⟹ (?D * ?C)-lipschitz_on ?U (λx. ?a * ?f x)› and more 4 facts*))[1]) (*discuss goal 5*) apply ((auto simp: interval_def (*‹interval ?T ≡ is_interval ?T›*) continuous_on_def (*‹continuous_on ?s ?f = (∀x∈?s. (?f ⤏ ?f x) (at x within ?s))›*) local_lipschitz_def (*‹local_lipschitz ?T ?X ?f ≡ ∀x∈?X. ∀t∈?T. ∃u>0. ∃L. ∀t∈cball t u ∩ ?T. L-lipschitz_on (cball x u ∩ ?X) (?f t)›*) intro!: lipschitz_intros (*‹⟦?C-lipschitz_on ?U ?f; ?D-lipschitz_on (?f ` ?U) ?g⟧ ⟹ (?D * ?C)-lipschitz_on ?U (?g ∘ ?f)› ‹0 ≤ ?C ⟹ ?C-lipschitz_on {?x} ?f› ‹0 ≤ ?C ⟹ ?C-lipschitz_on {} ?f› ‹1-lipschitz_on ?U (λx. x)› ‹0-lipschitz_on ?U (λx. ?c)› ‹⟦?C-lipschitz_on ?U ?f; ?D-lipschitz_on ?U ?g⟧ ⟹ (?C + ?D)-lipschitz_on ?U (λx. ?f x + ?g x)› ‹?C-lipschitz_on ?U ?f ⟹ (¦?a¦ * ?C)-lipschitz_on ?U (λx. ?a *⇩R ?f x)› ‹?C-lipschitz_on ?U ?f ⟹ (¦?a¦ * ?C)-lipschitz_on ?U (λx. ?a * ?f x)› ‹⟦?C-lipschitz_on ?U ?f; 0 ≤ ?a⟧ ⟹ (?a * ?C)-lipschitz_on ?U (λx. ?a *⇩R ?f x)› ‹⟦?C-lipschitz_on ?U ?f; 0 ≤ ?a⟧ ⟹ (?a * ?C)-lipschitz_on ?U (λx. ?a * ?f x)› ‹⟦?C-lipschitz_on ?U ?f; ¦?a¦ ≤ ?D⟧ ⟹ (?D * ?C)-lipschitz_on ?U (λx. ?a *⇩R ?f x)› ‹⟦?C-lipschitz_on ?U ?f; ¦?a¦ ≤ ?D⟧ ⟹ (?D * ?C)-lipschitz_on ?U (λx. ?a * ?f x)› and more 4 facts*))[1]) (*proven 5 subgoals*) . have foo1: "?t0.0 ∈ ?T" by auto have foo2: "?x0.0 ∈ ?X" by auto let ?v = "ll.flow ?t0.0 ?x0.0" from ll.flow_solves_ode[OF foo1 foo2] (*‹(ll.flow (0::real) (χi::'sz. (x::real)) solves_ode (λ(t::real) x::(real, 'sz) vec. χi::'sz. (0::real))) (ll.existence_ivl (0::real) (χi::'sz. x)) UNIV›*) have solves: "(ll.flow ?t0.0 ?x0.0 solves_ode ?f) (ll.existence_ivl ?t0.0 ?x0.0) ?X" by auto then have solves: "(?v solves_ode ?f) (ll.existence_ivl ?t0.0 ?x0.0) ?X" by auto have thex0: "(?v ?t0.0) $ (i::('sz::finite)) = x" by auto have sol_help: "(?v solves_ode ?f) (ll.existence_ivl ?t0.0 ?x0.0) ?X" using solves (*‹(ll.flow 0 (χi. x) solves_ode (λt x. χi. 0)) (ll.existence_ivl 0 (χi. x)) UNIV›*) by auto have ivl: "ll.existence_ivl ?t0.0 ?x0.0 = UNIV" apply (rule ll.existence_ivl_eq_domain (*‹⟦?t0.0 ∈ UNIV; ?x0.0 ∈ UNIV; ⋀tm tM t x. ⟦tm ∈ UNIV; tM ∈ UNIV⟧ ⟹ ∃M L. ∀t∈{tm..tM}. ∀x∈UNIV. norm (χi. 0) ≤ M + L * norm x; is_interval UNIV; UNIV = UNIV⟧ ⟹ ll.existence_ivl ?t0.0 ?x0.0 = UNIV›*)) (*goals: 1. ‹(0::real) ∈ UNIV› 2. ‹(χi::'sz. (x::real)) ∈ UNIV› 3. ‹⋀(tm::real) (tM::real) (t::?'b) x::?'c. ⟦tm ∈ UNIV; tM ∈ UNIV⟧ ⟹ ∃(M::real) L::real. ∀t::real∈{tm..tM}. ∀x::(real, 'sz) vec∈UNIV. norm (χi::'sz. (0::real)) ≤ M + L * norm x› 4. ‹is_interval UNIV› 5. ‹UNIV = UNIV› discuss goal 1*) apply ((auto intro!: exI[where x=0] (*‹?P 0 ⟹ ∃x. ?P x›*) simp: vec_eq_iff (*‹(?x = ?y) = (∀i. ?x $ i = ?y $ i)›*))[1]) (*discuss goal 2*) apply ((auto intro!: exI[where x=0] (*‹(?P::?'b5 ⇒ bool) (0::?'b5) ⟹ ∃x::?'b5. ?P x›*) simp: vec_eq_iff (*‹((?x::(?'a, ?'b) vec) = (?y::(?'a, ?'b) vec)) = (∀i::?'b. ?x $ i = ?y $ i)›*))[1]) (*discuss goal 3*) apply ((auto intro!: exI[where x=0] (*‹?P 0 ⟹ ∃x. ?P x›*) simp: vec_eq_iff (*‹(?x = ?y) = (∀i. ?x $ i = ?y $ i)›*))[1]) (*discuss goal 4*) apply ((auto intro!: exI[where x=0] (*‹?P 0 ⟹ ∃x. ?P x›*) simp: vec_eq_iff (*‹(?x = ?y) = (∀i. ?x $ i = ?y $ i)›*))[1]) (*discuss goal 5*) apply ((auto intro!: exI[where x=0] (*‹?P 0 ⟹ ∃x. ?P x›*) simp: vec_eq_iff (*‹(?x = ?y) = (∀i. ?x $ i = ?y $ i)›*))[1]) (*proven 5 subgoals*) . have sol: "(?v solves_ode ?f) UNIV ?X" using solves (*‹(ll.flow 0 (χi. x) solves_ode (λt x. χi. 0)) (ll.existence_ivl 0 (χi. x)) UNIV›*) ivl (*‹ll.existence_ivl (0::real) (χi::'sz. (x::real)) = UNIV›*) by auto have thef0: "⋀t x. ?f t x $ i = 0" by auto from constant_when_zero[OF thex0 sol thef0] (*‹⟦0 ∈ UNIV; ?t ∈ UNIV; convex UNIV⟧ ⟹ ll.flow 0 (χi. x) ?t $ i = x›*) have "?v t $ i = x" by auto thus "?thesis" (*goal: ‹x = ll.flow 0 (χi. x) t $ i›*) by auto qed lemma MVT_ivl: fixes f::"'a::ordered_euclidean_space⇒'b::ordered_euclidean_space" assumes fderiv: "⋀x. x ∈ D ⟹ (f has_derivative J x) (at x within D)" assumes J_ivl: "⋀x. x ∈ D ⟹ J x u ≥ J0" assumes line_in: "⋀x. x ∈ {0..1} ⟹ a + x *⇩R u ∈ D" shows "f (a + u) - f a ≥ J0" proof (-) (*goal: ‹J0 ≤ f (a + u) - f a›*) from MVT_corrected[OF fderiv line_in] (*‹⟦⋀x. x ∈ D ⟹ x ∈ D; ⋀x. ⟦0 ≤ x; x ≤ 1⟧ ⟹ x ∈ {0..1}⟧ ⟹ ∃t∈Basis → {0<..<1}. f (a + u) - f a = (∑i∈Basis. (J (a + t i *⇩R u) u ∙ i) *⇩R i)›*) obtain t where t: "t∈Basis → {0<..<1}" and mvt: "f (a + u) - f a = (∑i∈Basis. (J (a + t i *⇩R u) u ∙ i) *⇩R i)" (*goal: ‹(⋀t. ⟦t ∈ Basis → {0<..<1}; f (a + u) - f a = (∑i∈Basis. (J (a + t i *⇩R u) u ∙ i) *⇩R i)⟧ ⟹ thesis) ⟹ thesis›*) by auto note mvt (*‹f (a + u) - f a = (∑i∈Basis. (J (a + t i *⇩R u) u ∙ i) *⇩R i)›*) also (*calculation: ‹f (a + u) - f a = (∑i∈Basis. (J (a + t i *⇩R u) u ∙ i) *⇩R i)›*) have "… ≥ J0" proof (-) (*goal: ‹J0 ≤ (∑i∈Basis. (J (a + t i *⇩R u) u ∙ i) *⇩R i)›*) have J: "⋀i. i ∈ Basis ⟹ J0 ≤ J (a + t i *⇩R u) u" using J_ivl (*‹?x ∈ D ⟹ J0 ≤ J ?x u›*) t (*‹t ∈ Basis → {0<..<1}›*) line_in (*‹?x ∈ {0..1} ⟹ a + ?x *⇩R u ∈ D›*) by (auto simp: Pi_iff (*‹(?f ∈ Pi ?I ?X) = (∀i∈?I. ?f i ∈ ?X i)›*)) show "?thesis" (*goal: ‹J0 ≤ (∑i∈Basis. (J (a + t i *⇩R u) u ∙ i) *⇩R i)›*) using J (*‹?i ∈ Basis ⟹ J0 ≤ J (a + t ?i *⇩R u) u›*) unfolding atLeastAtMost_iff eucl_le[where 'a = 'b] (*goal: ‹∀i∈Basis. J0 ∙ i ≤ (∑i∈Basis. (J (a + t i *⇩R u) u ∙ i) *⇩R i) ∙ i›*) by auto qed finally (*calculation: ‹J0 ≤ f (a + u) - f a›*) show "?thesis" (*goal: ‹J0 ≤ f (a + u) - f a›*) . qed lemma MVT_ivl': fixes f::"'a::ordered_euclidean_space⇒'b::ordered_euclidean_space" assumes fderiv: "(⋀x. x ∈ D ⟹ (f has_derivative J x) (at x within D))" assumes J_ivl: "⋀x. x ∈ D ⟹ J x (a - b) ≥ J0" assumes line_in: "⋀x. x ∈ {0..1} ⟹ b + x *⇩R (a - b) ∈ D" shows "f a ≥ f b + J0" proof (-) (*goal: ‹f b + J0 ≤ f a›*) have "f (b + (a - b)) - f b ≥ J0" apply (rule MVT_ivl[OF fderiv (*‹⟦⋀x. x ∈ D ⟹ x ∈ D; ⋀x. x ∈ D ⟹ ?J0.0 ≤ J x ?u; ⋀x. x ∈ {0..1} ⟹ ?a + x *⇩R ?u ∈ D⟧ ⟹ ?J0.0 ≤ f (?a + ?u) - f ?a›*) ]) (*goal: ‹(J0::'b::ordered_euclidean_space) ≤ (f::'a::ordered_euclidean_space ⇒ 'b::ordered_euclidean_space) ((b::'a::ordered_euclidean_space) + ((a::'a::ordered_euclidean_space) - b)) - f b›*) apply assumption (*top goal: ‹⋀x. x ∈ D ⟹ x ∈ D› and 2 goals remain*) apply (rule J_ivl (*‹?x ∈ D ⟹ J0 ≤ J ?x (a - b)›*)) (*top goal: ‹⋀x. x ∈ D ⟹ J0 ≤ J x (a - b)› and 1 goal remains*) apply assumption (*top goal: ‹⋀x. x ∈ D ⟹ x ∈ D› and 1 goal remains*) using line_in (*‹?x ∈ {0..1} ⟹ b + ?x *⇩R (a - b) ∈ D›*) by (auto simp: diff_le_eq (*‹((?a::?'a) - (?b::?'a) ≤ (?c::?'a)) = (?a ≤ ?c + ?b)›*) le_diff_eq (*‹((?a::?'a) ≤ (?c::?'a) - (?b::?'a)) = (?a + ?b ≤ ?c)›*) 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 44 facts*)) thus "?thesis" (*goal: ‹f b + J0 ≤ f a›*) by (auto simp: diff_le_eq (*‹(?a - ?b ≤ ?c) = (?a ≤ ?c + ?b)›*) le_diff_eq (*‹(?a ≤ ?c - ?b) = (?a + ?b ≤ ?c)›*) 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 44 facts*)) qed end
{ "path": "afp-2025-02-12/thys/Differential_Dynamic_Logic/Lib.thy", "repo": "afp-2025-02-12", "sha": "f18524b348d58cd550a9856aa159a9629db16ccd00e7e49c2ca9a5e777fd617b" }
(* Title: Example Completeness Proof for a Natural Deduction Calculus for Basic Hybrid Logic Author: Asta Halkjær From *) chapter ‹Example: Hybrid Logic› theory Example_Hybrid_Logic imports Derivations begin section ‹Syntax› datatype (nominals_fm: 'i, 'p) fm = Fls (‹❙⊥›) | Pro 'p (‹❙‡›) | Nom 'i (‹❙⋅›) | Imp ‹('i, 'p) fm› ‹('i, 'p) fm› (infixr ‹❙⟶› 55) | Dia ‹('i, 'p) fm› (‹❙◇›) | Sat 'i ‹('i, 'p) fm› (‹❙@›) abbreviation Neg (‹❙¬ _› [70] 70) where ‹❙¬ p ≡ p ❙⟶ ❙⊥› type_synonym ('i, 'p) lbd = ‹'i × ('i, 'p) fm› primrec nominals_lbd :: ‹('i, 'p) lbd ⇒ 'i set› where ‹nominals_lbd (i, p) = {i} ∪ nominals_fm p› abbreviation nominals :: ‹('i, 'p) lbd set ⇒ 'i set› where ‹nominals S ≡ ⋃ip ∈ S. nominals_lbd ip› lemma finite_nominals_fm: ‹finite (nominals_fm p)› apply (induct p) (*goals: 1. ‹finite (nominals_fm ❙⊥)› 2. ‹⋀x. finite (nominals_fm (❙‡ x))› 3. ‹⋀x. finite (nominals_fm (❙⋅ x))› 4. ‹⋀p1 p2. ⟦finite (nominals_fm p1); finite (nominals_fm p2)⟧ ⟹ finite (nominals_fm (p1 ❙⟶ p2))› 5. ‹⋀p. finite (nominals_fm p) ⟹ finite (nominals_fm (❙◇ p))› 6. ‹⋀x1 p. finite (nominals_fm p) ⟹ finite (nominals_fm (❙@ x1 p))› 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*) . lemma finite_nominals_lbd: ‹finite (nominals_lbd p)› apply (cases p) (*goal: ‹finite (nominals_lbd p)›*) by (simp add: finite_nominals_fm (*‹finite (nominals_fm (?p::(?'a, ?'b) fm))›*)) section ‹Semantics› datatype ('w, 'p) model = Model (R: ‹'w ⇒ 'w set›) (V: ‹'w ⇒ 'p ⇒ bool›) type_synonym ('i, 'p, 'w) ctx = ‹('w, 'p) model × ('i ⇒ 'w) × 'w› fun semantics :: ‹('i, 'p, 'w) ctx ⇒ ('i, 'p) fm ⇒ bool› (‹_ ⊨ _› [50, 50] 50) where ‹(M, g, w) ⊨ ❙⊥ ⟷ False› | ‹(M, _, w) ⊨ ❙‡P ⟷ V M w P› | ‹(_, g, w) ⊨ ❙⋅i ⟷ w = g i› | ‹(M, g, w) ⊨ (p ❙⟶ q) ⟷ (M, g, w) ⊨ p ⟶ (M, g, w) ⊨ q› | ‹(M, g, w) ⊨ ❙◇ p ⟷ (∃v ∈ R M w. (M, g, v) ⊨ p)› | ‹(M, g, _) ⊨ ❙@i p ⟷ (M, g, g i) ⊨ p› lemma semantics_fresh: ‹i ∉ nominals_fm p ⟹ ((M, g, w) ⊨ p) = ((M, g(i := v), w) ⊨ p)› apply (induct p arbitrary: w) (*goals: 1. ‹⋀w. i ∉ nominals_fm ❙⊥ ⟹ ((M, g, w) ⊨ ❙⊥) = ((M, g(i := v), w) ⊨ ❙⊥)› 2. ‹⋀x w. i ∉ nominals_fm (❙‡ x) ⟹ ((M, g, w) ⊨ ❙‡ x) = ((M, g(i := v), w) ⊨ ❙‡ x)› 3. ‹⋀x w. i ∉ nominals_fm (❙⋅ x) ⟹ ((M, g, w) ⊨ ❙⋅ x) = ((M, g(i := v), w) ⊨ ❙⋅ x)› 4. ‹⋀p1 p2 w. ⟦⋀w. i ∉ nominals_fm p1 ⟹ ((M, g, w) ⊨ p1) = ((M, g(i := v), w) ⊨ p1); ⋀w. i ∉ nominals_fm p2 ⟹ ((M, g, w) ⊨ p2) = ((M, g(i := v), w) ⊨ p2); i ∉ nominals_fm (p1 ❙⟶ p2)⟧ ⟹ ((M, g, w) ⊨ p1 ❙⟶ p2) = ((M, g(i := v), w) ⊨ p1 ❙⟶ p2)› 5. ‹⋀p w. ⟦⋀w. i ∉ nominals_fm p ⟹ ((M, g, w) ⊨ p) = ((M, g(i := v), w) ⊨ p); i ∉ nominals_fm (❙◇ p)⟧ ⟹ ((M, g, w) ⊨ ❙◇ p) = ((M, g(i := v), w) ⊨ ❙◇ p)› 6. ‹⋀x1 p w. ⟦⋀w. i ∉ nominals_fm p ⟹ ((M, g, w) ⊨ p) = ((M, g(i := v), w) ⊨ p); i ∉ nominals_fm (❙@ x1 p)⟧ ⟹ ((M, g, w) ⊨ ❙@ x1 p) = ((M, g(i := v), w) ⊨ ❙@ x1 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]) (*proven 6 subgoals*) . lemma semantics_fresh_lbd: ‹k ∉ nominals_lbd (i, p) ⟹ ((M, g, w) ⊨ p) = ((M, g(k := v), w) ⊨ p)› apply (induct p arbitrary: w) (*goals: 1. ‹⋀w::'c. (k::'a) ∉ nominals_lbd (i::'a, ❙⊥) ⟹ ((M::('c, 'b) model, g::'a ⇒ 'c, w) ⊨ ❙⊥) = ((M, g(k := v::'c), w) ⊨ ❙⊥)› 2. ‹⋀(x::'b) w::'c. (k::'a) ∉ nominals_lbd (i::'a, ❙‡ x) ⟹ ((M::('c, 'b) model, g::'a ⇒ 'c, w) ⊨ ❙‡ x) = ((M, g(k := v::'c), w) ⊨ ❙‡ x)› 3. ‹⋀(x::'a) w::'c. (k::'a) ∉ nominals_lbd (i::'a, ❙⋅ x) ⟹ ((M::('c, 'b) model, g::'a ⇒ 'c, w) ⊨ ❙⋅ x) = ((M, g(k := v::'c), w) ⊨ ❙⋅ x)› 4. ‹⋀(p1::('a, 'b) fm) (p2::('a, 'b) fm) w::'c. ⟦⋀w::'c. (k::'a) ∉ nominals_lbd (i::'a, p1) ⟹ ((M::('c, 'b) model, g::'a ⇒ 'c, w) ⊨ p1) = ((M, g(k := v::'c), w) ⊨ p1); ⋀w::'c. k ∉ nominals_lbd (i, p2) ⟹ ((M, g, w) ⊨ p2) = ((M, g(k := v), w) ⊨ p2); k ∉ nominals_lbd (i, p1 ❙⟶ p2)⟧ ⟹ ((M, g, w) ⊨ p1 ❙⟶ p2) = ((M, g(k := v), w) ⊨ p1 ❙⟶ p2)› 5. ‹⋀(p::('a, 'b) fm) w::'c. ⟦⋀w::'c. (k::'a) ∉ nominals_lbd (i::'a, p) ⟹ ((M::('c, 'b) model, g::'a ⇒ 'c, w) ⊨ p) = ((M, g(k := v::'c), w) ⊨ p); k ∉ nominals_lbd (i, ❙◇ p)⟧ ⟹ ((M, g, w) ⊨ ❙◇ p) = ((M, g(k := v), w) ⊨ ❙◇ p)› 6. ‹⋀(x1::'a) (p::('a, 'b) fm) w::'c. ⟦⋀w::'c. (k::'a) ∉ nominals_lbd (i::'a, p) ⟹ ((M::('c, 'b) model, g::'a ⇒ 'c, w) ⊨ p) = ((M, g(k := v::'c), w) ⊨ p); k ∉ nominals_lbd (i, ❙@ x1 p)⟧ ⟹ ((M, g, w) ⊨ ❙@ x1 p) = ((M, g(k := v), w) ⊨ ❙@ x1 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]) (*proven 6 subgoals*) . section ‹Calculus› inductive Calculus :: ‹('i, 'p) lbd list ⇒ ('i, 'p) lbd ⇒ bool› (‹_ ⊢⇩@ _› [50, 50] 50) where Assm [intro]: ‹(i, p) ∈ set A ⟹ A ⊢⇩@ (i, p)› | Ref [intro]: ‹A ⊢⇩@ (i, ❙⋅i)› | Nom [intro]: ‹A ⊢⇩@ (i, ❙⋅k) ⟹ A ⊢⇩@ (i, p) ⟹ A ⊢⇩@ (k, p)› | FlsE [elim]: ‹A ⊢⇩@ (i, ❙⊥) ⟹ A ⊢⇩@ (k, p)› | ImpI [intro]: ‹(i, p) # A ⊢⇩@ (i, q) ⟹ A ⊢⇩@ (i, p ❙⟶ q)› | ImpE [elim]: ‹A ⊢⇩@ (i, p ❙⟶ q) ⟹ A ⊢⇩@ (i, p) ⟹ A ⊢⇩@ (i, q)› | SatI [intro]: ‹A ⊢⇩@ (i, p) ⟹ A ⊢⇩@ (k, ❙@i p)› | SatE [elim]: ‹A ⊢⇩@ (i, ❙@k p) ⟹ A ⊢⇩@ (k, p)› | DiaI [intro]: ‹A ⊢⇩@ (i, ❙◇ (❙⋅k)) ⟹ A ⊢⇩@ (k, p) ⟹ A ⊢⇩@ (i, ❙◇ p)› | DiaE [elim]: ‹A ⊢⇩@ (i, ❙◇ p) ⟹ k ∉ nominals ({(i, p), (j, q)} ∪ set A) ⟹ (k, p) # (i, ❙◇ (❙⋅k)) # A ⊢⇩@ (j, q) ⟹ A ⊢⇩@ (j, q)› | Clas: ‹(i, p ❙⟶ q) # A ⊢⇩@ (i, p) ⟹ A ⊢⇩@ (i, p)› | Weak: ‹A ⊢⇩@ (i, p) ⟹ (k, q) # A ⊢⇩@ (i, p)› section ‹Soundness› theorem soundness: ‹A ⊢⇩@ (i, p) ⟹ list_all (λ(i, p). (M, g, g i) ⊨ p) A ⟹ (M, g, g i) ⊨ p› proof (induct ‹(i, p)› arbitrary: i p g rule: Calculus.induct) (*goals: 1. ‹⋀i p A g. ⟦(i, p) ∈ set A; list_all (λ(i, y). (M, g, g i) ⊨ y) A⟧ ⟹ (M, g, g i) ⊨ p› 2. ‹⋀A i g. list_all (λ(i, y). (M, g, g i) ⊨ y) A ⟹ (M, g, g i) ⊨ ❙⋅ i› 3. ‹⋀A i k p g. ⟦A ⊢⇩@ (i, ❙⋅ k); ⋀g. list_all (λ(i, y). (M, g, g i) ⊨ y) A ⟹ (M, g, g i) ⊨ ❙⋅ k; A ⊢⇩@ (i, p); ⋀g. list_all (λ(i, y). (M, g, g i) ⊨ y) A ⟹ (M, g, g i) ⊨ p; list_all (λ(i, y). (M, g, g i) ⊨ y) A⟧ ⟹ (M, g, g k) ⊨ p› 4. ‹⋀A i k p g. ⟦A ⊢⇩@ (i, ❙⊥); ⋀g. list_all (λ(i, y). (M, g, g i) ⊨ y) A ⟹ (M, g, g i) ⊨ ❙⊥; list_all (λ(i, y). (M, g, g i) ⊨ y) A⟧ ⟹ (M, g, g k) ⊨ p› 5. ‹⋀i p A q g. ⟦(i, p) # A ⊢⇩@ (i, q); ⋀g. list_all (λ(i, y). (M, g, g i) ⊨ y) ((i, p) # A) ⟹ (M, g, g i) ⊨ q; list_all (λ(i, y). (M, g, g i) ⊨ y) A⟧ ⟹ (M, g, g i) ⊨ p ❙⟶ q› 6. ‹⋀A i p q g. ⟦A ⊢⇩@ (i, p ❙⟶ q); ⋀g. list_all (λ(i, y). (M, g, g i) ⊨ y) A ⟹ (M, g, g i) ⊨ p ❙⟶ q; A ⊢⇩@ (i, p); ⋀g. list_all (λ(i, y). (M, g, g i) ⊨ y) A ⟹ (M, g, g i) ⊨ p; list_all (λ(i, y). (M, g, g i) ⊨ y) A⟧ ⟹ (M, g, g i) ⊨ q› 7. ‹⋀A i p k g. ⟦A ⊢⇩@ (i, p); ⋀g. list_all (λ(i, y). (M, g, g i) ⊨ y) A ⟹ (M, g, g i) ⊨ p; list_all (λ(i, y). (M, g, g i) ⊨ y) A⟧ ⟹ (M, g, g k) ⊨ ❙@ i p› 8. ‹⋀A i k p g. ⟦A ⊢⇩@ (i, ❙@ k p); ⋀g. list_all (λ(i, y). (M, g, g i) ⊨ y) A ⟹ (M, g, g i) ⊨ ❙@ k p; list_all (λ(i, y). (M, g, g i) ⊨ y) A⟧ ⟹ (M, g, g k) ⊨ p› 9. ‹⋀A i k p g. ⟦A ⊢⇩@ (i, ❙◇ (❙⋅ k)); ⋀g. list_all (λ(i, y). (M, g, g i) ⊨ y) A ⟹ (M, g, g i) ⊨ ❙◇ (❙⋅ k); A ⊢⇩@ (k, p); ⋀g. list_all (λ(i, y). (M, g, g i) ⊨ y) A ⟹ (M, g, g k) ⊨ p; list_all (λ(i, y). (M, g, g i) ⊨ y) A⟧ ⟹ (M, g, g i) ⊨ ❙◇ p› 10. ‹⋀A i p k j q g. ⟦A ⊢⇩@ (i, ❙◇ p); ⋀g. list_all (λ(i, y). (M, g, g i) ⊨ y) A ⟹ (M, g, g i) ⊨ ❙◇ p; k ∉ nominals ({(i, p), (j, q)} ∪ set A); (k, p) # (i, ❙◇ (❙⋅ k)) # A ⊢⇩@ (j, q); ⋀g. list_all (λ(i, y). (M, g, g i) ⊨ y) ((k, p) # (i, ❙◇ (❙⋅ k)) # A) ⟹ (M, g, g j) ⊨ q; list_all (λ(i, y). (M, g, g i) ⊨ y) A⟧ ⟹ (M, g, g j) ⊨ q› 11. ‹⋀i p q A g. ⟦(i, p ❙⟶ q) # A ⊢⇩@ (i, p); ⋀g. list_all (λ(i, y). (M, g, g i) ⊨ y) ((i, p ❙⟶ q) # A) ⟹ (M, g, g i) ⊨ p; list_all (λ(i, y). (M, g, g i) ⊨ y) A⟧ ⟹ (M, g, g i) ⊨ p› 12. ‹⋀A i p k q g. ⟦A ⊢⇩@ (i, p); ⋀g. list_all (λ(i, y). (M, g, g i) ⊨ y) A ⟹ (M, g, g i) ⊨ p; list_all (λ(i, y). (M, g, g i) ⊨ y) ((k, q) # A)⟧ ⟹ (M, g, g i) ⊨ p›*) case (Nom A i k p) (*‹(A::('a::type × ('a::type, 'b::type) fm) list) ⊢⇩@ (i::'a::type, ❙⋅ (k::'a::type))› ‹list_all (λ(i, y). (M, ?g, ?g i) ⊨ y) A ⟹ (M, ?g, ?g i) ⊨ ❙⋅ k› ‹A ⊢⇩@ (i, p)› ‹list_all (λ(i, y). (M, ?g, ?g i) ⊨ y) A ⟹ (M, ?g, ?g i) ⊨ p› ‹list_all (λ(i, y). (M, g, g i) ⊨ y) A›*) then show "?case" (*goal: ‹(M, g, g k) ⊨ p›*) by fastforce next (*goals: 1. ‹⋀(i::'a) (p::('a, 'b) fm) (A::('a × ('a, 'b) fm) list) g::'a ⇒ 'c. ⟦(i, p) ∈ set A; list_all (λ(i::'a, y::('a, 'b) fm). (M::('c, 'b) model, g, g i) ⊨ y) A⟧ ⟹ (M, g, g i) ⊨ p› 2. ‹⋀(A::('a × ('a, 'b) fm) list) (i::'a) g::'a ⇒ 'c. list_all (λ(i::'a, y::('a, 'b) fm). (M::('c, 'b) model, g, g i) ⊨ y) A ⟹ (M, g, g i) ⊨ ❙⋅ i› 3. ‹⋀(A::('a × ('a, 'b) fm) list) (i::'a) (k::'a) (p::('a, 'b) fm) g::'a ⇒ 'c. ⟦A ⊢⇩@ (i, ❙⊥); ⋀g::'a ⇒ 'c. list_all (λ(i::'a, y::('a, 'b) fm). (M::('c, 'b) model, g, g i) ⊨ y) A ⟹ (M, g, g i) ⊨ ❙⊥; list_all (λ(i::'a, y::('a, 'b) fm). (M, g, g i) ⊨ y) A⟧ ⟹ (M, g, g k) ⊨ p› 4. ‹⋀(i::'a) (p::('a, 'b) fm) (A::('a × ('a, 'b) fm) list) (q::('a, 'b) fm) g::'a ⇒ 'c. ⟦(i, p) # A ⊢⇩@ (i, q); ⋀g::'a ⇒ 'c. list_all (λ(i::'a, y::('a, 'b) fm). (M::('c, 'b) model, g, g i) ⊨ y) ((i, p) # A) ⟹ (M, g, g i) ⊨ q; list_all (λ(i::'a, y::('a, 'b) fm). (M, g, g i) ⊨ y) A⟧ ⟹ (M, g, g i) ⊨ p ❙⟶ q› 5. ‹⋀(A::('a × ('a, 'b) fm) list) (i::'a) (p::('a, 'b) fm) (q::('a, 'b) fm) g::'a ⇒ 'c. ⟦A ⊢⇩@ (i, p ❙⟶ q); ⋀g::'a ⇒ 'c. list_all (λ(i::'a, y::('a, 'b) fm). (M::('c, 'b) model, g, g i) ⊨ y) A ⟹ (M, g, g i) ⊨ p ❙⟶ q; A ⊢⇩@ (i, p); ⋀g::'a ⇒ 'c. list_all (λ(i::'a, y::('a, 'b) fm). (M, g, g i) ⊨ y) A ⟹ (M, g, g i) ⊨ p; list_all (λ(i::'a, y::('a, 'b) fm). (M, g, g i) ⊨ y) A⟧ ⟹ (M, g, g i) ⊨ q› 6. ‹⋀(A::('a × ('a, 'b) fm) list) (i::'a) (p::('a, 'b) fm) (k::'a) g::'a ⇒ 'c. ⟦A ⊢⇩@ (i, p); ⋀g::'a ⇒ 'c. list_all (λ(i::'a, y::('a, 'b) fm). (M::('c, 'b) model, g, g i) ⊨ y) A ⟹ (M, g, g i) ⊨ p; list_all (λ(i::'a, y::('a, 'b) fm). (M, g, g i) ⊨ y) A⟧ ⟹ (M, g, g k) ⊨ ❙@ i p› 7. ‹⋀(A::('a × ('a, 'b) fm) list) (i::'a) (k::'a) (p::('a, 'b) fm) g::'a ⇒ 'c. ⟦A ⊢⇩@ (i, ❙@ k p); ⋀g::'a ⇒ 'c. list_all (λ(i::'a, y::('a, 'b) fm). (M::('c, 'b) model, g, g i) ⊨ y) A ⟹ (M, g, g i) ⊨ ❙@ k p; list_all (λ(i::'a, y::('a, 'b) fm). (M, g, g i) ⊨ y) A⟧ ⟹ (M, g, g k) ⊨ p› 8. ‹⋀(A::('a × ('a, 'b) fm) list) (i::'a) (k::'a) (p::('a, 'b) fm) g::'a ⇒ 'c. ⟦A ⊢⇩@ (i, ❙◇ (❙⋅ k)); ⋀g::'a ⇒ 'c. list_all (λ(i::'a, y::('a, 'b) fm). (M::('c, 'b) model, g, g i) ⊨ y) A ⟹ (M, g, g i) ⊨ ❙◇ (❙⋅ k); A ⊢⇩@ (k, p); ⋀g::'a ⇒ 'c. list_all (λ(i::'a, y::('a, 'b) fm). (M, g, g i) ⊨ y) A ⟹ (M, g, g k) ⊨ p; list_all (λ(i::'a, y::('a, 'b) fm). (M, g, g i) ⊨ y) A⟧ ⟹ (M, g, g i) ⊨ ❙◇ p› 9. ‹⋀(A::('a × ('a, 'b) fm) list) (i::'a) (p::('a, 'b) fm) (k::'a) (j::'a) (q::('a, 'b) fm) g::'a ⇒ 'c. ⟦A ⊢⇩@ (i, ❙◇ p); ⋀g::'a ⇒ 'c. list_all (λ(i::'a, y::('a, 'b) fm). (M::('c, 'b) model, g, g i) ⊨ y) A ⟹ (M, g, g i) ⊨ ❙◇ p; k ∉ nominals ({(i, p), (j, q)} ∪ set A); (k, p) # (i, ❙◇ (❙⋅ k)) # A ⊢⇩@ (j, q); ⋀g::'a ⇒ 'c. list_all (λ(i::'a, y::('a, 'b) fm). (M, g, g i) ⊨ y) ((k, p) # (i, ❙◇ (❙⋅ k)) # A) ⟹ (M, g, g j) ⊨ q; list_all (λ(i::'a, y::('a, 'b) fm). (M, g, g i) ⊨ y) A⟧ ⟹ (M, g, g j) ⊨ q› 10. ‹⋀(i::'a) (p::('a, 'b) fm) (q::('a, 'b) fm) (A::('a × ('a, 'b) fm) list) g::'a ⇒ 'c. ⟦(i, p ❙⟶ q) # A ⊢⇩@ (i, p); ⋀g::'a ⇒ 'c. list_all (λ(i::'a, y::('a, 'b) fm). (M::('c, 'b) model, g, g i) ⊨ y) ((i, p ❙⟶ q) # A) ⟹ (M, g, g i) ⊨ p; list_all (λ(i::'a, y::('a, 'b) fm). (M, g, g i) ⊨ y) A⟧ ⟹ (M, g, g i) ⊨ p› 11. ‹⋀(A::('a × ('a, 'b) fm) list) (i::'a) (p::('a, 'b) fm) (k::'a) (q::('a, 'b) fm) g::'a ⇒ 'c. ⟦A ⊢⇩@ (i, p); ⋀g::'a ⇒ 'c. list_all (λ(i::'a, y::('a, 'b) fm). (M::('c, 'b) model, g, g i) ⊨ y) A ⟹ (M, g, g i) ⊨ p; list_all (λ(i::'a, y::('a, 'b) fm). (M, g, g i) ⊨ y) ((k, q) # A)⟧ ⟹ (M, g, g i) ⊨ p›*) case (DiaE A i p k j q) (*‹A ⊢⇩@ (i, ❙◇ p)› ‹list_all (λ(i, y). (M, ?g, ?g i) ⊨ y) A ⟹ (M, ?g, ?g i) ⊨ ❙◇ p› ‹k ∉ nominals ({(i, p), (j, q)} ∪ set A)› ‹(k, p) # (i, ❙◇ (❙⋅ k)) # A ⊢⇩@ (j, q)› ‹list_all (λ(i, y). (M, ?g, ?g i) ⊨ y) ((k, p) # (i, ❙◇ (❙⋅ k)) # A) ⟹ (M, ?g, ?g j) ⊨ q› ‹list_all (λ(i, y). (M, g, g i) ⊨ y) A›*) then have "(M, g, g i) ⊨ ❙◇ p" by blast then obtain v where v: "v ∈ R M (g i)" "(M, g, v) ⊨ p" (*goal: ‹(⋀v::'c. ⟦v ∈ R (M::('c, 'b) model) ((g::'a ⇒ 'c) (i::'a)); (M, g, v) ⊨ (p::('a, 'b) fm)⟧ ⟹ thesis::bool) ⟹ thesis›*) by auto let ?g = "g(k := v)" have "(M, ?g, ?g k) ⊨ p" "(M, ?g, ?g i) ⊨ ❙◇ (❙⋅k)" using v (*‹(v::'c::type) ∈ R (M::('c::type, 'b::type) model) ((g::'a::type ⇒ 'c::type) (i::'a::type))› ‹(M, g, v) ⊨ p›*) fun_upd_same (*‹(?f(?x := ?y)) ?x = ?y›*) DiaE(3) (*‹k ∉ nominals ({(i, p), (j, q)} ∪ set A)›*) semantics_fresh_lbd (*‹?k ∉ nominals_lbd (?i, ?p) ⟹ ((?M, ?g, ?w) ⊨ ?p) = ((?M, ?g(?k := ?v), ?w) ⊨ ?p)›*) apply - (*goals: 1. ‹⟦v ∈ R M (g i); (M, g, v) ⊨ p; ⋀f x y. (f(x := y)) x = y; k ∉ nominals ({(i, p), (j, q)} ∪ set A); ⋀k i p M g w v. k ∉ nominals_lbd (i, p) ⟹ ((M, g, w) ⊨ p) = ((M, g(k := v), w) ⊨ p)⟧ ⟹ (M, g(k := v), (g(k := v)) k) ⊨ p› 2. ‹⟦v ∈ R M (g i); (M, g, v) ⊨ p; ⋀f x y. (f(x := y)) x = y; k ∉ nominals ({(i, p), (j, q)} ∪ set A); ⋀k i p M g w v. k ∉ nominals_lbd (i, p) ⟹ ((M, g, w) ⊨ p) = ((M, g(k := v), w) ⊨ p)⟧ ⟹ (M, g(k := v), (g(k := v)) i) ⊨ ❙◇ (❙⋅ k)› discuss goal 1*) apply fastforce (*discuss goal 2*) apply fastforce (*proven 2 subgoals*) . moreover have "list_all (λ(i, p). (M, ?g, ?g i) ⊨ p) A" using DiaE.prems (*‹list_all (λ(i, y). (M, g, g i) ⊨ y) A›*) DiaE.hyps(3) (*‹(k::'a) ∉ nominals ({(i::'a, p::('a, 'b) fm), (j::'a, q::('a, 'b) fm)} ∪ set (A::('a × ('a, 'b) fm) list))›*) semantics_fresh_lbd (*‹?k ∉ nominals_lbd (?i, ?p) ⟹ ((?M, ?g, ?w) ⊨ ?p) = ((?M, ?g(?k := ?v), ?w) ⊨ ?p)›*) apply (induct A) (*goals: 1. ‹⟦list_all (λ(i, y). (M, g, g i) ⊨ y) []; k ∉ nominals ({(i, p), (j, q)} ∪ set []); ⋀k i p M g w v. k ∉ nominals_lbd (i, p) ⟹ ((M, g, w) ⊨ p) = ((M, g(k := v), w) ⊨ p)⟧ ⟹ list_all (λ(i, y). (M, g(k := v), (g(k := v)) i) ⊨ y) []› 2. ‹⋀a A. ⟦⟦list_all (λ(i, y). (M, g, g i) ⊨ y) A; k ∉ nominals ({(i, p), (j, q)} ∪ set A); ⋀k i p M g w v. k ∉ nominals_lbd (i, p) ⟹ ((M, g, w) ⊨ p) = ((M, g(k := v), w) ⊨ p)⟧ ⟹ list_all (λ(i, y). (M, g(k := v), (g(k := v)) i) ⊨ y) A; list_all (λ(i, y). (M, g, g i) ⊨ y) (a # A); k ∉ nominals ({(i, p), (j, q)} ∪ set (a # A)); ⋀k i p M g w v. k ∉ nominals_lbd (i, p) ⟹ ((M, g, w) ⊨ p) = ((M, g(k := v), w) ⊨ p)⟧ ⟹ list_all (λ(i, y). (M, g(k := v), (g(k := v)) i) ⊨ y) (a # A)› discuss goal 1*) apply fastforce (*discuss goal 2*) apply fastforce (*proven 2 subgoals*) . ultimately have "list_all (λ(i, p). (M, ?g, ?g i) ⊨ p) ((k, p) # (i, ❙◇ (❙⋅k)) # A)" by simp then have "(M, ?g, ?g j) ⊨ q" using DiaE.hyps (*‹(A::('a × ('a, 'b) fm) list) ⊢⇩@ (i::'a, ❙◇ (p::('a, 'b) fm))› ‹list_all (λ(i, y). (M, ?g, ?g i) ⊨ y) A ⟹ (M, ?g, ?g i) ⊨ ❙◇ p› ‹k ∉ nominals ({(i, p), (j, q)} ∪ set A)› ‹(k, p) # (i, ❙◇ (❙⋅ k)) # A ⊢⇩@ (j, q)› ‹list_all (λ(i, y). (M, ?g, ?g i) ⊨ y) ((k, p) # (i, ❙◇ (❙⋅ k)) # A) ⟹ (M, ?g, ?g j) ⊨ q›*) by fast then show "?case" (*goal: ‹(M::('c, 'b) model, g::'a ⇒ 'c, g (j::'a)) ⊨ (q::('a, 'b) fm)›*) using DiaE.hyps(3) (*‹k ∉ nominals ({(i, p), (j, q)} ∪ set A)›*) semantics_fresh_lbd (*‹?k ∉ nominals_lbd (?i, ?p) ⟹ ((?M, ?g, ?w) ⊨ ?p) = ((?M, ?g(?k := ?v), ?w) ⊨ ?p)›*) by fastforce qed (auto simp: list_all_iff (*‹list_all ?P ?x = Ball (set ?x) ?P›*)) (*solves the remaining goals: 1. ‹⋀i p A g. ⟦(i, p) ∈ set A; list_all (λ(i, y). (M, g, g i) ⊨ y) A⟧ ⟹ (M, g, g i) ⊨ p› 2. ‹⋀A i g. list_all (λ(i, y). (M, g, g i) ⊨ y) A ⟹ (M, g, g i) ⊨ ❙⋅ i› 3. ‹⋀A i k p g. ⟦A ⊢⇩@ (i, ❙⊥); ⋀g. list_all (λ(i, y). (M, g, g i) ⊨ y) A ⟹ (M, g, g i) ⊨ ❙⊥; list_all (λ(i, y). (M, g, g i) ⊨ y) A⟧ ⟹ (M, g, g k) ⊨ p› 4. ‹⋀i p A q g. ⟦(i, p) # A ⊢⇩@ (i, q); ⋀g. list_all (λ(i, y). (M, g, g i) ⊨ y) ((i, p) # A) ⟹ (M, g, g i) ⊨ q; list_all (λ(i, y). (M, g, g i) ⊨ y) A⟧ ⟹ (M, g, g i) ⊨ p ❙⟶ q› 5. ‹⋀A i p q g. ⟦A ⊢⇩@ (i, p ❙⟶ q); ⋀g. list_all (λ(i, y). (M, g, g i) ⊨ y) A ⟹ (M, g, g i) ⊨ p ❙⟶ q; A ⊢⇩@ (i, p); ⋀g. list_all (λ(i, y). (M, g, g i) ⊨ y) A ⟹ (M, g, g i) ⊨ p; list_all (λ(i, y). (M, g, g i) ⊨ y) A⟧ ⟹ (M, g, g i) ⊨ q› 6. ‹⋀A i p k g. ⟦A ⊢⇩@ (i, p); ⋀g. list_all (λ(i, y). (M, g, g i) ⊨ y) A ⟹ (M, g, g i) ⊨ p; list_all (λ(i, y). (M, g, g i) ⊨ y) A⟧ ⟹ (M, g, g k) ⊨ ❙@ i p› 7. ‹⋀A i k p g. ⟦A ⊢⇩@ (i, ❙@ k p); ⋀g. list_all (λ(i, y). (M, g, g i) ⊨ y) A ⟹ (M, g, g i) ⊨ ❙@ k p; list_all (λ(i, y). (M, g, g i) ⊨ y) A⟧ ⟹ (M, g, g k) ⊨ p› 8. ‹⋀A i k p g. ⟦A ⊢⇩@ (i, ❙◇ (❙⋅ k)); ⋀g. list_all (λ(i, y). (M, g, g i) ⊨ y) A ⟹ (M, g, g i) ⊨ ❙◇ (❙⋅ k); A ⊢⇩@ (k, p); ⋀g. list_all (λ(i, y). (M, g, g i) ⊨ y) A ⟹ (M, g, g k) ⊨ p; list_all (λ(i, y). (M, g, g i) ⊨ y) A⟧ ⟹ (M, g, g i) ⊨ ❙◇ p› 9. ‹⋀i p q A g. ⟦(i, p ❙⟶ q) # A ⊢⇩@ (i, p); ⋀g. list_all (λ(i, y). (M, g, g i) ⊨ y) ((i, p ❙⟶ q) # A) ⟹ (M, g, g i) ⊨ p; list_all (λ(i, y). (M, g, g i) ⊨ y) A⟧ ⟹ (M, g, g i) ⊨ p› 10. ‹⋀A i p k q g. ⟦A ⊢⇩@ (i, p); ⋀g. list_all (λ(i, y). (M, g, g i) ⊨ y) A ⟹ (M, g, g i) ⊨ p; list_all (λ(i, y). (M, g, g i) ⊨ y) ((k, q) # A)⟧ ⟹ (M, g, g i) ⊨ p›*) corollary soundness': ‹[] ⊢⇩@ (i, p) ⟹ i ∉ nominals_fm p ⟹ (M, g, w) ⊨ p› using soundness (*‹⟦(?A::(?'a::type × (?'a::type, ?'b::type) fm) list) ⊢⇩@ (?i::?'a::type, ?p::(?'a::type, ?'b::type) fm); list_all (λ(i::?'a::type, p::(?'a::type, ?'b::type) fm). (?M::(?'c::type, ?'b::type) model, ?g::?'a::type ⇒ ?'c::type, ?g i) ⊨ p) ?A⟧ ⟹ (?M, ?g, ?g ?i) ⊨ ?p›*) semantics_fresh (*‹?i ∉ nominals_fm ?p ⟹ ((?M, ?g, ?w) ⊨ ?p) = ((?M, ?g(?i := ?v), ?w) ⊨ ?p)›*) by (metis fun_upd_same (*‹(?f(?x := ?y)) ?x = ?y›*) list.pred_inject( (*‹list_all ?P []›*) 1)) corollary ‹¬ ([] ⊢⇩@ (i, ❙⊥))› using soundness' (*‹⟦[] ⊢⇩@ (?i, ?p); ?i ∉ nominals_fm ?p⟧ ⟹ (?M, ?g, ?w) ⊨ ?p›*) by fastforce section ‹Admissible Rules› lemma Assm_head: ‹(p, i) # A ⊢⇩@ (p, i)› by auto lemma deduct1: ‹A ⊢⇩@ (i, p ❙⟶ q) ⟹ (i, p) # A ⊢⇩@ (i, q)› by (meson ImpE (*‹⟦(?A::(?'i × (?'i, ?'p) fm) list) ⊢⇩@ (?i::?'i, (?p::(?'i, ?'p) fm) ❙⟶ (?q::(?'i, ?'p) fm)); ?A ⊢⇩@ (?i, ?p)⟧ ⟹ ?A ⊢⇩@ (?i, ?q)›*) Weak (*‹(?A::(?'i × (?'i, ?'p) fm) list) ⊢⇩@ (?i::?'i, ?p::(?'i, ?'p) fm) ⟹ (?k::?'i, ?q::(?'i, ?'p) fm) # ?A ⊢⇩@ (?i, ?p)›*) Assm_head (*‹(?p::?'a, ?i::(?'a, ?'b) fm) # (?A::(?'a × (?'a, ?'b) fm) list) ⊢⇩@ (?p, ?i)›*)) lemma Boole: ‹(i, ❙¬ p) # A ⊢⇩@ (i, ❙⊥) ⟹ A ⊢⇩@ (i, p)› using Clas (*‹(?i, ?p ❙⟶ ?q) # ?A ⊢⇩@ (?i, ?p) ⟹ ?A ⊢⇩@ (?i, ?p)›*) FlsE (*‹?A ⊢⇩@ (?i, ❙⊥) ⟹ ?A ⊢⇩@ (?k, ?p)›*) by meson lemma Weak': ‹A ⊢⇩@ (i, p) ⟹ B @ A ⊢⇩@ (i, p)› proof (induct B) (*goals: 1. ‹A ⊢⇩@ (i, p) ⟹ [] @ A ⊢⇩@ (i, p)› 2. ‹⋀a B. ⟦A ⊢⇩@ (i, p) ⟹ B @ A ⊢⇩@ (i, p); A ⊢⇩@ (i, p)⟧ ⟹ (a # B) @ A ⊢⇩@ (i, p)›*) case (Cons b B) (*‹A ⊢⇩@ (i, p) ⟹ B @ A ⊢⇩@ (i, p)› ‹A ⊢⇩@ (i, p)›*) then show "?case" (*goal: ‹(b # B) @ A ⊢⇩@ (i, p)›*) apply (cases b) (*goal: ‹((b::'a::type × ('a::type, 'b::type) fm) # (B::('a::type × ('a::type, 'b::type) fm) list)) @ (A::('a::type × ('a::type, 'b::type) fm) list) ⊢⇩@ (i::'a::type, p::('a::type, 'b::type) fm)›*) by (metis Cons (*‹A ⊢⇩@ (i, p) ⟹ B @ A ⊢⇩@ (i, p)› ‹A ⊢⇩@ (i, p)›*) Weak (*‹?A ⊢⇩@ (?i, ?p) ⟹ (?k, ?q) # ?A ⊢⇩@ (?i, ?p)›*) append_Cons (*‹(?x # ?xs) @ ?ys = ?x # ?xs @ ?ys›*)) qed (simp) (*solved the remaining goal: ‹A ⊢⇩@ (i, p) ⟹ [] @ A ⊢⇩@ (i, p)›*) lemma ImpI': assumes ‹(k, q) # A ⊢⇩@ (i, p)› shows ‹A ⊢⇩@ (i, (❙@k q) ❙⟶ p)› using assms (*‹(k, q) # A ⊢⇩@ (i, p)›*) proof (-) (*goal: ‹(k, q) # A ⊢⇩@ (i, p) ⟹ A ⊢⇩@ (i, ❙@ k q ❙⟶ p)›*) have "(k, q) # A ⊢⇩@ (k, ❙@i p)" using assms (*‹(k::'a, q::('a, 'b) fm) # (A::('a × ('a, 'b) fm) list) ⊢⇩@ (i::'a, p::('a, 'b) fm)›*) by fast then show "?thesis" (*goal: ‹A ⊢⇩@ (i, ❙@ k q ❙⟶ p)›*) by (meson Assm_head (*‹(?p, ?i) # ?A ⊢⇩@ (?p, ?i)›*) ImpE (*‹⟦?A ⊢⇩@ (?i, ?p ❙⟶ ?q); ?A ⊢⇩@ (?i, ?p)⟧ ⟹ ?A ⊢⇩@ (?i, ?q)›*) ImpI (*‹(?i, ?p) # ?A ⊢⇩@ (?i, ?q) ⟹ ?A ⊢⇩@ (?i, ?p ❙⟶ ?q)›*) SatE (*‹?A ⊢⇩@ (?i, ❙@ ?k ?p) ⟹ ?A ⊢⇩@ (?k, ?p)›*) Weak (*‹?A ⊢⇩@ (?i, ?p) ⟹ (?k, ?q) # ?A ⊢⇩@ (?i, ?p)›*)) qed lemma Weaken: ‹A ⊢⇩@ (i, p) ⟹ set A ⊆ set B ⟹ B ⊢⇩@ (i, p)› proof (induct A arbitrary: i p) (*goals: 1. ‹⋀i p. ⟦[] ⊢⇩@ (i, p); set [] ⊆ set B⟧ ⟹ B ⊢⇩@ (i, p)› 2. ‹⋀a A i p. ⟦⋀i p. ⟦A ⊢⇩@ (i, p); set A ⊆ set B⟧ ⟹ B ⊢⇩@ (i, p); a # A ⊢⇩@ (i, p); set (a # A) ⊆ set B⟧ ⟹ B ⊢⇩@ (i, p)›*) case Nil (*‹[] ⊢⇩@ (i, p)› ‹set [] ⊆ set B›*) then show "?case" (*goal: ‹B ⊢⇩@ (i, p)›*) using Weak' (*‹?A ⊢⇩@ (?i, ?p) ⟹ ?B @ ?A ⊢⇩@ (?i, ?p)›*) by fastforce next (*goal: ‹⋀a A i p. ⟦⋀i p. ⟦A ⊢⇩@ (i, p); set A ⊆ set B⟧ ⟹ B ⊢⇩@ (i, p); a # A ⊢⇩@ (i, p); set (a # A) ⊆ set B⟧ ⟹ B ⊢⇩@ (i, p)›*) case (Cons kq A) (*‹⟦A ⊢⇩@ (?i, ?p); set A ⊆ set B⟧ ⟹ B ⊢⇩@ (?i, ?p)› ‹kq # A ⊢⇩@ (i, p)› ‹set (kq # A) ⊆ set B›*) then show "?case" (*goal: ‹B ⊢⇩@ (i, p)›*) proof (cases kq) (*goal: ‹⋀a b. ⟦⋀i p. ⟦A ⊢⇩@ (i, p); set A ⊆ set B⟧ ⟹ B ⊢⇩@ (i, p); kq # A ⊢⇩@ (i, p); set (kq # A) ⊆ set B; kq = (a, b)⟧ ⟹ B ⊢⇩@ (i, p)›*) case (Pair k q) (*‹(kq::'a × ('a, 'b) fm) = (k::'a, q::('a, 'b) fm)›*) then show "?thesis" (*goal: ‹(B::('a × ('a, 'b) fm) list) ⊢⇩@ (i::'a, p::('a, 'b) fm)›*) using Cons (*‹⟦A ⊢⇩@ (?i, ?p); set A ⊆ set B⟧ ⟹ B ⊢⇩@ (?i, ?p)› ‹kq # A ⊢⇩@ (i, p)› ‹set (kq # A) ⊆ set B›*) by (meson Assm (*‹(?i, ?p) ∈ set ?A ⟹ ?A ⊢⇩@ (?i, ?p)›*) ImpI' (*‹(?k, ?q) # ?A ⊢⇩@ (?i, ?p) ⟹ ?A ⊢⇩@ (?i, ❙@ ?k ?q ❙⟶ ?p)›*) ImpE (*‹⟦?A ⊢⇩@ (?i, ?p ❙⟶ ?q); ?A ⊢⇩@ (?i, ?p)⟧ ⟹ ?A ⊢⇩@ (?i, ?q)›*) SatI (*‹?A ⊢⇩@ (?i, ?p) ⟹ ?A ⊢⇩@ (?k, ❙@ ?i ?p)›*) list.set_intros( (*‹?x21.0 ∈ set (?x21.0 # ?x22.0)›*) 1) set_subset_Cons (*‹set ?xs ⊆ set (?x # ?xs)›*) subset_eq (*‹(?A ⊆ ?B) = (∀x∈?A. x ∈ ?B)›*)) qed qed interpretation Derivations Calculus proof (standard) (*goal: ‹⋀(A::('a × ('a, 'b) fm) list) (B::('a × ('a, 'b) fm) list) p::'a × ('a, 'b) fm. ⟦A ⊢⇩@ p; set A ⊆ set B⟧ ⟹ B ⊢⇩@ p›*) fix A and B and p :: "('i, 'p) lbd" assume "A ⊢⇩@ p" "set A ⊆ set B" (*‹(A::('i × ('i, 'p) fm) list) ⊢⇩@ (p::'i × ('i, 'p) fm)› ‹set (A::('i × ('i, 'p) fm) list) ⊆ set (B::('i × ('i, 'p) fm) list)›*) then show "B ⊢⇩@ p" apply (cases p) (*goal: ‹B ⊢⇩@ p›*) by (metis Weaken (*‹⟦?A ⊢⇩@ (?i, ?p); set ?A ⊆ set ?B⟧ ⟹ ?B ⊢⇩@ (?i, ?p)›*)) qed section ‹Maximal Consistent Sets› definition consistent :: ‹('i, 'p) lbd set ⇒ bool› where ‹consistent S ≡ ∄S' a. set S' ⊆ S ∧ S' ⊢⇩@ (a, ❙⊥)› lemma consistent_add_witness: assumes ‹consistent S› ‹(i, ❙◇ p) ∈ S› ‹k ∉ nominals S› shows ‹consistent ({(k, p), (i, ❙◇ (❙⋅k))} ∪ S)› unfolding consistent_def (*goal: ‹∄(S'::('a × ('a, 'b) fm) list) a::'a. set S' ⊆ {(k::'a, p::('a, 'b) fm), (i::'a, ❙◇ (❙⋅ k))} ∪ (S::('a × ('a, 'b) fm) set) ∧ S' ⊢⇩@ (a, ❙⊥)›*) proof (standard) (*goal: ‹∃(S'::('a × ('a, 'b) fm) list) a::'a. set S' ⊆ {(k::'a, p::('a, 'b) fm), (i::'a, ❙◇ (❙⋅ k))} ∪ (S::('a × ('a, 'b) fm) set) ∧ S' ⊢⇩@ (a, ❙⊥) ⟹ False›*) assume "∃S' a. set S' ⊆ {(k, p), (i, ❙◇ (❙⋅k))} ∪ S ∧ S' ⊢⇩@ (a, ❙⊥)" (*‹∃(S'::('a × ('a, 'b) fm) list) a::'a. set S' ⊆ {(k::'a, p::('a, 'b) fm), (i::'a, ❙◇ (❙⋅ k))} ∪ (S::('a × ('a, 'b) fm) set) ∧ S' ⊢⇩@ (a, ❙⊥)›*) then obtain S' and a where "set S' ⊆ S" "(k, p) # (i, ❙◇ (❙⋅k)) # S' ⊢⇩@ (a, ❙⊥)" (*goal: ‹(⋀S' a. ⟦set S' ⊆ S; (k, p) # (i, ❙◇ (❙⋅ k)) # S' ⊢⇩@ (a, ❙⊥)⟧ ⟹ thesis) ⟹ thesis›*) using assms (*‹consistent S› ‹(i::'a, ❙◇ (p::('a, 'b) fm)) ∈ (S::('a × ('a, 'b) fm) set)› ‹(k::'a) ∉ nominals (S::('a × ('a, 'b) fm) set)›*) derive_split[where X = S and B = ‹[(k, p), (i, ❙◇ (❙⋅k))]›] (*‹⟦set ?A ⊆ set [(k, p), (i, ❙◇ (❙⋅ k))] ∪ S; ?A ⊢⇩@ ?p⟧ ⟹ ∃C. set C ⊆ S ∧ [(k, p), (i, ❙◇ (❙⋅ k))] @ C ⊢⇩@ ?p›*) by (metis append_Cons (*‹((?x::?'a) # (?xs::?'a list)) @ (?ys::?'a list) = ?x # ?xs @ ?ys›*) append_Nil (*‹[] @ (?ys::?'a list) = ?ys›*) list.simps( (*‹set ((?x21.0::?'a) # (?x22.0::?'a list)) = insert ?x21.0 (set ?x22.0)›*) 15) set_empty (*‹(set (?xs::?'a list) = {}) = (?xs = [])›*)) then have "(k, p) # (i, ❙◇ (❙⋅k)) # S' ⊢⇩@ (i, ❙⊥)" by fast then have "(k, p) # (i, ❙◇ (❙⋅k)) # (i, ❙◇ p) # S' ⊢⇩@ (i, ❙⊥)" by (fastforce intro: Weaken (*‹⟦?A ⊢⇩@ (?i, ?p); set ?A ⊆ set ?B⟧ ⟹ ?B ⊢⇩@ (?i, ?p)›*)) moreover have "k ∉ nominals ({(i, p), (i, ❙⊥)} ∪ set ((i, ❙◇ p) # S'))" using ‹set S' ⊆ S› (*‹set S' ⊆ S›*) assms(2-3) (*‹(i, ❙◇ p) ∈ S› ‹k ∉ nominals S›*) by auto moreover have "(i, ❙◇ p) # S' ⊢⇩@ (i, ❙◇ p)" by auto ultimately have "(i, ❙◇ p) # S' ⊢⇩@ (i, ❙⊥)" by fastforce moreover have "set ((i, ❙◇ p) # S') ⊆ S" using ‹set S' ⊆ S› (*‹set S' ⊆ S›*) assms(2) (*‹(i, ❙◇ p) ∈ S›*) by simp ultimately show False using assms(1) (*‹consistent S›*) unfolding consistent_def (*goal: ‹False›*) by blast qed fun witness :: ‹('i, 'p) lbd ⇒ ('i, 'p) lbd set ⇒ ('i, 'p) lbd set› where ‹witness (i, ❙◇ p) S = (let k = (SOME k. k ∉ nominals ({(i, p)} ∪ S)) in {(k, p), (i, ❙◇ (❙⋅k))})› | ‹witness (_, _) _ = {}› lemma consistent_witness': assumes ‹consistent ({(i, p)} ∪ S)› ‹infinite (UNIV - nominals S)› shows ‹consistent (witness (i, p) S ∪ {(i, p)} ∪ S)› using assms (*‹consistent ({(i, p)} ∪ S)› ‹infinite (UNIV - nominals S)›*) proof (induct ‹(i, p)› S arbitrary: i p rule: witness.induct) (*goals: 1. ‹⋀i p S. ⟦consistent ({(i, ❙◇ p)} ∪ S); infinite (UNIV - nominals S)⟧ ⟹ consistent (witness (i, ❙◇ p) S ∪ {(i, ❙◇ p)} ∪ S)› 2. ‹⋀uu_ uw_. ⟦consistent ({(uu_, ❙⊥)} ∪ uw_); infinite (UNIV - nominals uw_)⟧ ⟹ consistent (witness (uu_, ❙⊥) uw_ ∪ {(uu_, ❙⊥)} ∪ uw_)› 3. ‹⋀uu_ v uw_. ⟦consistent ({(uu_, ❙‡ v)} ∪ uw_); infinite (UNIV - nominals uw_)⟧ ⟹ consistent (witness (uu_, ❙‡ v) uw_ ∪ {(uu_, ❙‡ v)} ∪ uw_)› 4. ‹⋀uu_ v uw_. ⟦consistent ({(uu_, ❙⋅ v)} ∪ uw_); infinite (UNIV - nominals uw_)⟧ ⟹ consistent (witness (uu_, ❙⋅ v) uw_ ∪ {(uu_, ❙⋅ v)} ∪ uw_)› 5. ‹⋀uu_ v va uw_. ⟦consistent ({(uu_, v ❙⟶ va)} ∪ uw_); infinite (UNIV - nominals uw_)⟧ ⟹ consistent (witness (uu_, v ❙⟶ va) uw_ ∪ {(uu_, v ❙⟶ va)} ∪ uw_)› 6. ‹⋀uu_ v va uw_. ⟦consistent ({(uu_, ❙@ v va)} ∪ uw_); infinite (UNIV - nominals uw_)⟧ ⟹ consistent (witness (uu_, ❙@ v va) uw_ ∪ {(uu_, ❙@ v va)} ∪ uw_)›*) case (1 i p S) (*‹consistent ({(i, ❙◇ p)} ∪ S)› ‹infinite (UNIV - nominals S)›*) have "infinite (UNIV - nominals ({(i, p)} ∪ S))" using "1"(2) (*‹infinite (UNIV - nominals S)›*) finite_nominals_lbd (*‹finite (nominals_lbd ?p)›*) by (metis UN_Un (*‹⋃ (?M ` (?A ∪ ?B)) = ⋃ (?M ` ?A) ∪ ⋃ (?M ` ?B)›*) finite.emptyI (*‹finite {}›*) finite.insertI (*‹finite ?A ⟹ finite (insert ?a ?A)›*) finite_UN_I (*‹⟦finite ?A; ⋀a. a ∈ ?A ⟹ finite (?B a)⟧ ⟹ finite (⋃ (?B ` ?A))›*) infinite_Diff_fin_Un (*‹⟦infinite (?X - ?Y); finite ?Z⟧ ⟹ infinite (?X - (?Z ∪ ?Y))›*)) then have "∃k. k ∉ nominals ({(i, p)} ∪ S)" by (simp add: not_finite_existsD (*‹infinite {a::?'a::type. (?P::?'a::type ⇒ bool) a} ⟹ ∃a::?'a::type. ?P a›*) set_diff_eq (*‹(?A::?'a::type set) - (?B::?'a::type set) = {x::?'a::type ∈ ?A. x ∉ ?B}›*)) then have "(SOME k. k ∉ nominals ({(i, p)} ∪ S)) ∉ nominals ({(i, p)} ∪ S)" by (rule someI_ex (*‹∃x. ?P x ⟹ ?P (SOME x. ?P x)›*)) then obtain k where "witness (i, ❙◇ p) S = {(k, p), (i, ❙◇ (❙⋅k))}" "k ∉ nominals ({(i, ❙◇ p)} ∪ S)" (*goal: ‹(⋀k. ⟦witness (i, ❙◇ p) S = {(k, p), (i, ❙◇ (❙⋅ k))}; k ∉ nominals ({(i, ❙◇ p)} ∪ S)⟧ ⟹ thesis) ⟹ thesis›*) by (simp add: Let_def (*‹Let ?s ?f ≡ ?f ?s›*)) then show "?case" (*goal: ‹consistent (witness (i, ❙◇ p) S ∪ {(i, ❙◇ p)} ∪ S)›*) using "1"(1-2) (*‹consistent ({(i, ❙◇ p)} ∪ S)› ‹infinite (UNIV - nominals S)›*) consistent_add_witness[where S = ‹{(i, ❙◇ p)} ∪ S›] (*‹⟦consistent ({(i, ❙◇ p)} ∪ S); (?i, ❙◇ ?p) ∈ {(i, ❙◇ p)} ∪ S; ?k ∉ nominals ({(i, ❙◇ p)} ∪ S)⟧ ⟹ consistent ({(?k, ?p), (?i, ❙◇ (❙⋅ ?k))} ∪ ({(i, ❙◇ p)} ∪ S))›*) by simp qed (auto simp: assms (*‹consistent ({(i, p)} ∪ S)› ‹infinite (UNIV - nominals S)›*)) (*solves the remaining goals: 1. ‹⋀uu_ uw_. ⟦consistent ({(uu_, ❙⊥)} ∪ uw_); infinite (UNIV - nominals uw_)⟧ ⟹ consistent (witness (uu_, ❙⊥) uw_ ∪ {(uu_, ❙⊥)} ∪ uw_)› 2. ‹⋀uu_ v uw_. ⟦consistent ({(uu_, ❙‡ v)} ∪ uw_); infinite (UNIV - nominals uw_)⟧ ⟹ consistent (witness (uu_, ❙‡ v) uw_ ∪ {(uu_, ❙‡ v)} ∪ uw_)› 3. ‹⋀uu_ v uw_. ⟦consistent ({(uu_, ❙⋅ v)} ∪ uw_); infinite (UNIV - nominals uw_)⟧ ⟹ consistent (witness (uu_, ❙⋅ v) uw_ ∪ {(uu_, ❙⋅ v)} ∪ uw_)› 4. ‹⋀uu_ v va uw_. ⟦consistent ({(uu_, v ❙⟶ va)} ∪ uw_); infinite (UNIV - nominals uw_)⟧ ⟹ consistent (witness (uu_, v ❙⟶ va) uw_ ∪ {(uu_, v ❙⟶ va)} ∪ uw_)› 5. ‹⋀uu_ v va uw_. ⟦consistent ({(uu_, ❙@ v va)} ∪ uw_); infinite (UNIV - nominals uw_)⟧ ⟹ consistent (witness (uu_, ❙@ v va) uw_ ∪ {(uu_, ❙@ v va)} ∪ uw_)›*) interpretation MCS_Saturation consistent nominals_lbd witness proof (standard) (*goals: 1. ‹⋀S S'. ⟦consistent S; S' ⊆ S⟧ ⟹ consistent S'› 2. ‹⋀S. ¬ consistent S ⟹ ∃S'⊆S. finite S' ∧ ¬ consistent S'› 3. ‹infinite UNIV› 4. ‹⋀p. finite (nominals_lbd p)› 5. ‹⋀p S. finite (nominals (witness p S))› 6. ‹⋀p S. ⟦consistent ({p} ∪ S); infinite (UNIV - nominals S)⟧ ⟹ consistent (witness p S ∪ {p} ∪ S)›*) fix S :: "('i, 'p) lbd set" and S' :: "('i, 'p) lbd set" assume "consistent S" "S' ⊆ S" (*‹consistent (S::('i × ('i, 'p) fm) set)› ‹(S'::('i × ('i, 'p) fm) set) ⊆ (S::('i × ('i, 'p) fm) set)›*) then show "consistent S'" unfolding consistent_def (*goal: ‹∄S'a a. set S'a ⊆ S' ∧ S'a ⊢⇩@ (a, ❙⊥)›*) by fast next (*goals: 1. ‹⋀S. ¬ consistent S ⟹ ∃S'⊆S. finite S' ∧ ¬ consistent S'› 2. ‹infinite UNIV› 3. ‹⋀p. finite (nominals_lbd p)› 4. ‹⋀p S. finite (nominals (witness p S))› 5. ‹⋀p S. ⟦consistent ({p} ∪ S); infinite (UNIV - nominals S)⟧ ⟹ consistent (witness p S ∪ {p} ∪ S)›*) fix S :: "('i, 'p) lbd set" assume "¬ consistent S" (*‹¬ consistent (S::('i × ('i, 'p) fm) set)›*) then show "∃S'⊆S. finite S' ∧ ¬ consistent S'" unfolding consistent_def (*goal: ‹∃S'⊆S. finite S' ∧ ¬ (∄S'a a. set S'a ⊆ S' ∧ S'a ⊢⇩@ (a, ❙⊥))›*) by blast next (*goals: 1. ‹infinite UNIV› 2. ‹⋀p::'a × ('a, 'b) fm. finite (nominals_lbd p)› 3. ‹⋀(p::'a × ('a, 'b) fm) S::('a × ('a, 'b) fm) set. finite (nominals (witness p S))› 4. ‹⋀(p::'a × ('a, 'b) fm) S::('a × ('a, 'b) fm) set. ⟦consistent ({p} ∪ S); infinite (UNIV - nominals S)⟧ ⟹ consistent (witness p S ∪ {p} ∪ S)›*) fix ip :: "('i, 'p) lbd" show "finite (nominals_lbd ip)" using finite_nominals_fm (*‹finite (nominals_fm ?p)›*) apply (cases ip) (*goal: ‹finite (nominals_lbd ip)›*) by simp next (*goals: 1. ‹infinite UNIV› 2. ‹⋀p S. finite (nominals (witness p S))› 3. ‹⋀p S. ⟦consistent ({p} ∪ S); infinite (UNIV - nominals S)⟧ ⟹ consistent (witness p S ∪ {p} ∪ S)›*) fix ip :: "('i, 'p) lbd" and S :: "('i, 'p) lbd set" show "finite (nominals (witness ip S))" apply (induct ip S rule: witness.induct (*‹⟦⋀i p S. ?P (i, ❙◇ p) S; ⋀uu_ uw_. ?P (uu_, ❙⊥) uw_; ⋀uu_ v uw_. ?P (uu_, ❙‡ v) uw_; ⋀uu_ v uw_. ?P (uu_, ❙⋅ v) uw_; ⋀uu_ v va uw_. ?P (uu_, v ❙⟶ va) uw_; ⋀uu_ v va uw_. ?P (uu_, ❙@ v va) uw_⟧ ⟹ ?P ?a0.0 ?a1.0›*)) (*goals: 1. ‹⋀(i::'i) (p::('i, 'p) fm) S::('i × ('i, 'p) fm) set. finite (nominals (witness (i, ❙◇ p) S))› 2. ‹⋀(uu_::'i) uw_::('i × ('i, 'p) fm) set. finite (nominals (witness (uu_, ❙⊥) uw_))› 3. ‹⋀(uu_::'i) (v::'p) uw_::('i × ('i, 'p) fm) set. finite (nominals (witness (uu_, ❙‡ v) uw_))› 4. ‹⋀(uu_::'i) (v::'i) uw_::('i × ('i, 'p) fm) set. finite (nominals (witness (uu_, ❙⋅ v) uw_))› 5. ‹⋀(uu_::'i) (v::('i, 'p) fm) (va::('i, 'p) fm) uw_::('i × ('i, 'p) fm) set. finite (nominals (witness (uu_, v ❙⟶ va) uw_))› 6. ‹⋀(uu_::'i) (v::'i) (va::('i, 'p) fm) uw_::('i × ('i, 'p) fm) set. finite (nominals (witness (uu_, ❙@ v va) uw_))› discuss goal 1*) apply ((auto simp: finite_nominals_fm (*‹finite (nominals_fm (?p::(?'a::type, ?'b::type) fm))›*) Let_def (*‹Let (?s::?'a::type) (?f::?'a::type ⇒ ?'b::type) ≡ ?f ?s›*))[1]) (*discuss goal 2*) apply ((auto simp: finite_nominals_fm (*‹finite (nominals_fm ?p)›*) Let_def (*‹Let ?s ?f ≡ ?f ?s›*))[1]) (*discuss goal 3*) apply ((auto simp: finite_nominals_fm (*‹finite (nominals_fm (?p::(?'a::type, ?'b::type) fm))›*) Let_def (*‹Let (?s::?'a::type) (?f::?'a::type ⇒ ?'b::type) ≡ ?f ?s›*))[1]) (*discuss goal 4*) apply ((auto simp: finite_nominals_fm (*‹finite (nominals_fm ?p)›*) Let_def (*‹Let ?s ?f ≡ ?f ?s›*))[1]) (*discuss goal 5*) apply ((auto simp: finite_nominals_fm (*‹finite (nominals_fm ?p)›*) Let_def (*‹Let ?s ?f ≡ ?f ?s›*))[1]) (*discuss goal 6*) apply ((auto simp: finite_nominals_fm (*‹finite (nominals_fm ?p)›*) Let_def (*‹Let ?s ?f ≡ ?f ?s›*))[1]) (*proven 6 subgoals*) . next (*goals: 1. ‹infinite UNIV› 2. ‹⋀(p::'a::type × ('a::type, 'b::type) fm) S::('a::type × ('a::type, 'b::type) fm) set. ⟦consistent ({p} ∪ S); infinite (UNIV - nominals S)⟧ ⟹ consistent (witness p S ∪ {p} ∪ S)›*) fix ip and S :: "('i, 'p) lbd set" assume "consistent ({ip} ∪ S)" "infinite (UNIV - nominals S)" (*‹consistent ({ip::'i × ('i, 'p) fm} ∪ (S::('i × ('i, 'p) fm) set))› ‹infinite (UNIV - nominals (S::('i × ('i, 'p) fm) set))›*) then show "consistent (witness ip S ∪ {ip} ∪ S)" using consistent_witness' (*‹⟦consistent ({(?i, ?p)} ∪ ?S); infinite (UNIV - nominals ?S)⟧ ⟹ consistent (witness (?i, ?p) ?S ∪ {(?i, ?p)} ∪ ?S)›*) apply (cases ip) (*goal: ‹consistent (witness ip S ∪ {ip} ∪ S)›*) by simp next (*goal: ‹infinite UNIV›*) have "infinite (UNIV :: ('i, 'p) fm set)" using infinite_UNIV_size[of ‹❙◇›] (*‹(⋀x::(?'c1, ?'d1) fm. size x < size (❙◇ x)) ⟹ infinite UNIV›*) by simp then show "infinite (UNIV :: ('i, 'p) lbd set)" using finite_prod (*‹finite UNIV = (finite UNIV ∧ finite UNIV)›*) by blast qed interpretation Derivations_MCS_Cut Calculus consistent ‹(undefined, ❙⊥)› proof (standard) (*goals: 1. ‹⋀S. consistent S = (∄S'. set S' ⊆ S ∧ S' ⊢⇩@ (undefined, ❙⊥))› 2. ‹⋀A p. p ∈ set A ⟹ A ⊢⇩@ p› 3. ‹⋀A B p q. ⟦A ⊢⇩@ p; p # B ⊢⇩@ q⟧ ⟹ A @ B ⊢⇩@ q›*) fix S :: "('i, 'p) lbd set" show "consistent S = (∄S'. set S' ⊆ S ∧ S' ⊢⇩@ (undefined, ❙⊥))" unfolding consistent_def (*goal: ‹(∄S' a. set S' ⊆ S ∧ S' ⊢⇩@ (a, ❙⊥)) = (∄S'. set S' ⊆ S ∧ S' ⊢⇩@ (undefined, ❙⊥))›*) by fast next (*goals: 1. ‹⋀(A::('a × ('a, 'b) fm) list) p::'a × ('a, 'b) fm. p ∈ set A ⟹ A ⊢⇩@ p› 2. ‹⋀(A::('a × ('a, 'b) fm) list) (B::('a × ('a, 'b) fm) list) (p::'a × ('a, 'b) fm) q::'a × ('a, 'b) fm. ⟦A ⊢⇩@ p; p # B ⊢⇩@ q⟧ ⟹ A @ B ⊢⇩@ q›*) fix A and p :: "('i, 'p) lbd" assume "p ∈ set A" (*‹(p::'i × ('i, 'p) fm) ∈ set (A::('i × ('i, 'p) fm) list)›*) then show "A ⊢⇩@ p" by (metis Assm (*‹(?i::?'i::type, ?p::(?'i::type, ?'p::type) fm) ∈ set (?A::(?'i::type × (?'i::type, ?'p::type) fm) list) ⟹ ?A ⊢⇩@ (?i, ?p)›*) surj_pair (*‹∃(x::?'a::type) y::?'b::type. (?p::?'a::type × ?'b::type) = (x, y)›*)) next (*goal: ‹⋀A B p q. ⟦A ⊢⇩@ p; p # B ⊢⇩@ q⟧ ⟹ A @ B ⊢⇩@ q›*) fix A and B and p :: "('i, 'p) lbd" and q :: "('i, 'p) lbd" assume "A ⊢⇩@ p" "p # B ⊢⇩@ q" (*‹(A::('i × ('i, 'p) fm) list) ⊢⇩@ (p::'i × ('i, 'p) fm)› ‹(p::'i × ('i, 'p) fm) # (B::('i × ('i, 'p) fm) list) ⊢⇩@ (q::'i × ('i, 'p) fm)›*) then have "A @ B ⊢⇩@ p" "p # A @ B ⊢⇩@ q" apply - (*goals: 1. ‹⟦A ⊢⇩@ p; p # B ⊢⇩@ q⟧ ⟹ A @ B ⊢⇩@ p› 2. ‹⟦A ⊢⇩@ p; p # B ⊢⇩@ q⟧ ⟹ p # A @ B ⊢⇩@ q› discuss goal 1*) apply (simp add: derive_struct (*‹⟦?A ⊢⇩@ ?p; set ?A ⊆ set ?B⟧ ⟹ ?B ⊢⇩@ ?p›*) subsetI (*‹(⋀x. x ∈ ?A ⟹ x ∈ ?B) ⟹ ?A ⊆ ?B›*)) (*discuss goal 2*) apply (simp add: derive_struct (*‹⟦?A ⊢⇩@ ?p; set ?A ⊆ set ?B⟧ ⟹ ?B ⊢⇩@ ?p›*) subsetI (*‹(⋀x. x ∈ ?A ⟹ x ∈ ?B) ⟹ ?A ⊆ ?B›*)) (*proven 2 subgoals*) . then show "A @ B ⊢⇩@ q" apply (cases p) (*goal: ‹A @ B ⊢⇩@ q›*) apply (cases q) (*goal: ‹⋀a b. ⟦A @ B ⊢⇩@ p; p # A @ B ⊢⇩@ q; p = (a, b)⟧ ⟹ A @ B ⊢⇩@ q›*) by (meson ImpE (*‹⟦?A ⊢⇩@ (?i, ?p ❙⟶ ?q); ?A ⊢⇩@ (?i, ?p)⟧ ⟹ ?A ⊢⇩@ (?i, ?q)›*) ImpI' (*‹(?k, ?q) # ?A ⊢⇩@ (?i, ?p) ⟹ ?A ⊢⇩@ (?i, ❙@ ?k ?q ❙⟶ ?p)›*) SatI (*‹?A ⊢⇩@ (?i, ?p) ⟹ ?A ⊢⇩@ (?k, ❙@ ?i ?p)›*)) qed lemma saturated: ‹saturated H ⟹ (i, ❙◇p) ∈ H ⟹ ∃k. (i, ❙◇ (❙⋅k)) ∈ H ∧ (k, p) ∈ H› unfolding saturated_def (*goal: ‹⟦∀p∈H. ∃S'. witness p S' ⊆ H; (i, ❙◇ p) ∈ H⟧ ⟹ ∃k. (i, ❙◇ (❙⋅ k)) ∈ H ∧ (k, p) ∈ H›*) by (metis insert_subset (*‹(insert (?x::?'a::type) (?A::?'a::type set) ⊆ (?B::?'a::type set)) = (?x ∈ ?B ∧ ?A ⊆ ?B)›*) witness.simps( (*‹witness (?i::?'i::type, ❙◇ (?p::(?'i::type, ?'p::type) fm)) (?S::(?'i::type × (?'i::type, ?'p::type) fm) set) = (let k::?'i::type = SOME k::?'i::type. k ∉ paramss ({(?i, ?p)} ∪ ?S) in {(k, ?p), (?i, ❙◇ (❙⋅ k))})›*) 1)) section ‹Nominals› lemma MCS_Nom_refl: assumes ‹consistent S› ‹maximal S› shows ‹(i, ❙⋅i) ∈ S› using assms (*‹consistent S› ‹maximal S›*) Ref (*‹?A ⊢⇩@ (?i, ❙⋅ ?i)›*) by (metis MCS_derive (*‹⟦consistent ?S; maximal ?S⟧ ⟹ (?p ∈ ?S) = (∃S'. set S' ⊆ ?S ∧ S' ⊢⇩@ ?p)›*) MCS_derive_fls (*‹⟦consistent ?S; maximal ?S⟧ ⟹ (?p ∉ ?S) = (∃S'. set S' ⊆ ?S ∧ ?p # S' ⊢⇩@ (undefined, ❙⊥))›*)) lemma MCS_Nom_sym: assumes ‹consistent S› ‹maximal S› ‹(i, ❙⋅k) ∈ S› shows ‹(k, ❙⋅i) ∈ S› using assms (*‹consistent S› ‹maximal S› ‹(i, ❙⋅ k) ∈ S›*) Nom (*‹⟦?A ⊢⇩@ (?i, ❙⋅ ?k); ?A ⊢⇩@ (?i, ?p)⟧ ⟹ ?A ⊢⇩@ (?k, ?p)›*) Ref (*‹(?A::(?'i × (?'i, ?'p) fm) list) ⊢⇩@ (?i::?'i, ❙⋅ ?i)›*) by (metis MCS_derive (*‹⟦consistent ?S; maximal ?S⟧ ⟹ (?p ∈ ?S) = (∃S'. set S' ⊆ ?S ∧ S' ⊢⇩@ ?p)›*)) lemma MCS_Nom_trans: assumes ‹consistent S› ‹maximal S› ‹(i, ❙⋅j) ∈ S› ‹(j, ❙⋅k) ∈ S› shows ‹(i, ❙⋅k) ∈ S› proof (-) (*goal: ‹(i, ❙⋅ k) ∈ S›*) have "∃S'. set S' ⊆ S ∧ S' ⊢⇩@ (i, ❙⋅j)" using assms (*‹consistent S› ‹maximal S› ‹(i, ❙⋅ j) ∈ S› ‹(j, ❙⋅ k) ∈ S›*) MCS_derive (*‹⟦consistent ?S; maximal ?S⟧ ⟹ (?p ∈ ?S) = (∃S'. set S' ⊆ ?S ∧ S' ⊢⇩@ ?p)›*) by blast then have "∃S'. set S' ⊆ S ∧ S' ⊢⇩@ (i, ❙⋅j) ∧ S' ⊢⇩@ (j, ❙⋅k)" by (metis Assm_head (*‹(?p, ?i) # ?A ⊢⇩@ (?p, ?i)›*) Calculus.intros( (*‹?A ⊢⇩@ (?i, ?p) ⟹ (?k, ?q) # ?A ⊢⇩@ (?i, ?p)›*) 12) assms( (*‹(j, ❙⋅ k) ∈ S›*) 4) insert_subset (*‹(insert ?x ?A ⊆ ?B) = (?x ∈ ?B ∧ ?A ⊆ ?B)›*) list.set( (*‹set (?x21.0 # ?x22.0) = insert ?x21.0 (set ?x22.0)›*) 2)) then have "∃S'. set S' ⊆ S ∧ S' ⊢⇩@ (i, ❙⋅k)" using Nom (*‹⟦?A ⊢⇩@ (?i, ❙⋅ ?k); ?A ⊢⇩@ (?i, ?p)⟧ ⟹ ?A ⊢⇩@ (?k, ?p)›*) Ref (*‹?A ⊢⇩@ (?i, ❙⋅ ?i)›*) by metis then show "?thesis" (*goal: ‹(i, ❙⋅ k) ∈ S›*) using assms (*‹consistent (S::('a::type × ('a::type, 'b::type) fm) set)› ‹maximal S› ‹(i, ❙⋅ j) ∈ S› ‹(j::'a, ❙⋅ (k::'a)) ∈ (S::('a × ('a, 'b) fm) set)›*) MCS_derive (*‹⟦consistent ?S; maximal ?S⟧ ⟹ (?p ∈ ?S) = (∃S'. set S' ⊆ ?S ∧ S' ⊢⇩@ ?p)›*) by blast qed section ‹Truth Lemma› fun semics :: ‹('i, 'p, 'w) ctx ⇒ (('i, 'p, 'w) ctx ⇒ ('i, 'p) fm ⇒ bool) ⇒ ('i, 'p) fm ⇒ bool› where ‹semics _ _ ❙⊥ ⟷ False› | ‹semics (M, _, w) _ (❙‡P) ⟷ V M w P› | ‹semics (_, g, w) _ (❙⋅i) ⟷ w = g i› | ‹semics (M, g, w) rel (p ❙⟶ q) ⟷ rel (M, g, w) p ⟶ rel (M, g, w) q› | ‹semics (M, g, w) rel (❙◇ p) ⟷ (∃v ∈ R M w. rel (M, g, v) p)› | ‹semics (M, g, _) rel (❙@ i p) ⟷ rel (M, g, g i) p› fun rel :: ‹('i, 'p) lbd set ⇒ ('i, 'p, 'i) ctx ⇒ ('i, 'p) fm ⇒ bool› where ‹rel H (_, _, i) p = ((i, p) ∈ H)› definition val :: ‹('i, 'p) lbd set ⇒ 'i ⇒ 'p ⇒ bool› where ‹val H i P ≡ (i, ❙‡P) ∈ H› definition hequiv :: ‹('i, 'p) lbd set ⇒ 'i ⇒ 'i ⇒ bool› where ‹hequiv H i k ≡ (i, ❙⋅k) ∈ H› lemma hequiv_reflp: assumes ‹consistent H› ‹maximal H› shows ‹reflp (hequiv H)› unfolding hequiv_def reflp_def (*goal: ‹∀x::'a. (x, ❙⋅ x) ∈ (H::('a × ('a, 'b) fm) set)›*) using assms (*‹consistent H› ‹maximal (H::('a::type × ('a::type, 'b::type) fm) set)›*) MCS_Nom_refl (*‹⟦consistent ?S; maximal ?S⟧ ⟹ (?i, ❙⋅ ?i) ∈ ?S›*) by fast lemma hequiv_symp: assumes ‹consistent H› ‹maximal H› shows ‹symp (hequiv H)› unfolding hequiv_def symp_def (*goal: ‹∀x y. (x, ❙⋅ y) ∈ H ⟶ (y, ❙⋅ x) ∈ H›*) using assms (*‹consistent (H::('a::type × ('a::type, 'b::type) fm) set)› ‹maximal H›*) MCS_Nom_sym (*‹⟦consistent ?S; maximal ?S; (?i, ❙⋅ ?k) ∈ ?S⟧ ⟹ (?k, ❙⋅ ?i) ∈ ?S›*) by fast lemma hequiv_transp: assumes ‹consistent H› ‹maximal H› shows ‹transp (hequiv H)› unfolding hequiv_def transp_def (*goal: ‹∀x y z. (x, ❙⋅ y) ∈ H ⟶ (y, ❙⋅ z) ∈ H ⟶ (x, ❙⋅ z) ∈ H›*) using assms (*‹consistent H› ‹maximal H›*) MCS_Nom_trans (*‹⟦consistent ?S; maximal ?S; (?i, ❙⋅ ?j) ∈ ?S; (?j, ❙⋅ ?k) ∈ ?S⟧ ⟹ (?i, ❙⋅ ?k) ∈ ?S›*) by fast lemma hequiv_equivp: assumes ‹consistent H› ‹maximal H› shows ‹equivp (hequiv H)› using assms (*‹consistent (H::('a::type × ('a::type, 'b::type) fm) set)› ‹maximal H›*) by (simp add: equivpI (*‹⟦reflp ?R; symp ?R; transp ?R⟧ ⟹ equivp ?R›*) hequiv_reflp (*‹⟦consistent ?H; maximal ?H⟧ ⟹ reflp (hequiv ?H)›*) hequiv_symp (*‹⟦consistent ?H; maximal ?H⟧ ⟹ symp (hequiv ?H)›*) hequiv_transp (*‹⟦consistent ?H; maximal ?H⟧ ⟹ transp (hequiv ?H)›*)) definition assign :: ‹('i, 'p) lbd set ⇒ 'i ⇒ 'i› where ‹assign H i ≡ minim ( |UNIV| ) {k. hequiv H i k}› lemma hequiv_ne: assumes ‹consistent H› ‹maximal H› shows ‹{k. hequiv H i k} ≠ {}› unfolding hequiv_def (*goal: ‹{k. (i, ❙⋅ k) ∈ H} ≠ {}›*) using assms (*‹consistent (H::('a × ('a, 'b) fm) set)› ‹maximal (H::('a × ('a, 'b) fm) set)›*) MCS_Nom_refl (*‹⟦consistent ?S; maximal ?S⟧ ⟹ (?i, ❙⋅ ?i) ∈ ?S›*) by fast lemma hequiv_assign: assumes ‹consistent H› ‹maximal H› shows ‹hequiv H i (assign H i)› unfolding assign_def (*goal: ‹hequiv H i (minim |UNIV| {k. hequiv H i k})›*) using assms (*‹consistent H› ‹maximal H›*) hequiv_ne (*‹⟦consistent ?H; maximal ?H⟧ ⟹ {k. hequiv ?H ?i k} ≠ {}›*) wo_rel.minim_in (*‹⟦wo_rel ?r; ?B ⊆ Field ?r; ?B ≠ {}⟧ ⟹ minim ?r ?B ∈ ?B›*) by (metis Field_card_of (*‹Field |?A| = ?A›*) card_of_well_order_on (*‹well_order_on ?A |?A|›*) mem_Collect_eq (*‹(?a ∈ Collect ?P) = ?P ?a›*) top.extremum (*‹?a ≤ top›*) wo_rel_def (*‹wo_rel ?r ≡ Well_order ?r›*)) lemma hequiv_Nom: assumes ‹consistent H› ‹maximal H› ‹hequiv H i k› ‹(i, p) ∈ H› shows ‹(k, p) ∈ H› proof (-) (*goal: ‹(k, p) ∈ H›*) have "∃A. set A ⊆ H ∧ A ⊢⇩@ (i, p)" using assms (*‹consistent H› ‹maximal (H::('a × ('a, 'b) fm) set)› ‹hequiv H i k› ‹(i, p) ∈ H›*) MCS_derive (*‹⟦consistent ?S; maximal ?S⟧ ⟹ (?p ∈ ?S) = (∃S'. set S' ⊆ ?S ∧ S' ⊢⇩@ ?p)›*) by fast then have "∃A. set A ⊆ H ∧ A ⊢⇩@ (i, p) ∧ A ⊢⇩@ (i, ❙⋅k)" using assms(3) (*‹hequiv H i k›*) unfolding hequiv_def (*goal: ‹∃A. set A ⊆ H ∧ A ⊢⇩@ (i, p) ∧ A ⊢⇩@ (i, ❙⋅ k)›*) by (metis Assm_head (*‹(?p, ?i) # ?A ⊢⇩@ (?p, ?i)›*) Weak (*‹?A ⊢⇩@ (?i, ?p) ⟹ (?k, ?q) # ?A ⊢⇩@ (?i, ?p)›*) insert_subset (*‹(insert ?x ?A ⊆ ?B) = (?x ∈ ?B ∧ ?A ⊆ ?B)›*) list.simps( (*‹set (?x21.0 # ?x22.0) = insert ?x21.0 (set ?x22.0)›*) 15)) then have "∃A. set A ⊆ H ∧ A ⊢⇩@ (k, p)" using Nom (*‹⟦?A ⊢⇩@ (?i, ❙⋅ ?k); ?A ⊢⇩@ (?i, ?p)⟧ ⟹ ?A ⊢⇩@ (?k, ?p)›*) by fast then show "?thesis" (*goal: ‹(k, p) ∈ H›*) using assms (*‹consistent H› ‹maximal H› ‹hequiv H i k› ‹(i, p) ∈ H›*) MCS_derive (*‹⟦consistent (?S::(?'a × (?'a, ?'b) fm) set); maximal ?S⟧ ⟹ ((?p::?'a × (?'a, ?'b) fm) ∈ ?S) = (∃S'::(?'a × (?'a, ?'b) fm) list. set S' ⊆ ?S ∧ S' ⊢⇩@ ?p)›*) by fast qed definition reach :: ‹('i, 'p) lbd set ⇒ 'i ⇒ 'i set› where ‹reach H i ≡ {assign H k |k. (i, ❙◇ (❙⋅k)) ∈ H}› abbreviation canonical :: ‹('i × ('i, 'p) fm) set ⇒ 'i ⇒ ('i, 'p, 'i) ctx› where ‹canonical H i ≡ (Model (reach H) (val H), assign H, assign H i)› lemma Hintikka_model': assumes ‹⋀i p. semics (canonical H i) (rel H) p ⟷ rel H (canonical H i) p› shows ‹(canonical H i ⊨ p) ⟷ rel H (canonical H i) p› proof (induct p arbitrary: i rule: wf_induct[where r=‹measure size›]) (*goals: 1. ‹wf (measure size)› 2. ‹⋀x i. ∀y. (y, x) ∈ measure size ⟶ (∀x. (canonical H x ⊨ y) = rel H (canonical H x) y) ⟹ (canonical H i ⊨ x) = rel H (canonical H i) x›*) case 1 (*no hyothesis introduced yet*) then show "?case" (*goal: ‹wf (measure size)›*) by standard next (*goal: ‹⋀x i. ∀y. (y, x) ∈ measure size ⟶ (∀x. (canonical H x ⊨ y) = rel H (canonical H x) y) ⟹ (canonical H i ⊨ x) = rel H (canonical H i) x›*) case (2 x) (*‹∀y. (y, x) ∈ measure size ⟶ (∀x. (canonical H x ⊨ y) = rel H (canonical H x) y)›*) then show "?case" (*goal: ‹(canonical H i ⊨ x) = rel H (canonical H i) x›*) using assms[of i x] (*‹semics (canonical H i) (rel H) x = rel H (canonical H i) x›*) apply (cases x) (*goals: 1. ‹⟦∀y. (y, x) ∈ measure size ⟶ (∀x. (canonical H x ⊨ y) = rel H (canonical H x) y); semics (canonical H i) (rel H) x = rel H (canonical H i) x; x = ❙⊥⟧ ⟹ (canonical H i ⊨ x) = rel H (canonical H i) x› 2. ‹⋀x2. ⟦∀y. (y, x) ∈ measure size ⟶ (∀x. (canonical H x ⊨ y) = rel H (canonical H x) y); semics (canonical H i) (rel H) x = rel H (canonical H i) x; x = ❙‡ x2⟧ ⟹ (canonical H i ⊨ x) = rel H (canonical H i) x› 3. ‹⋀x3. ⟦∀y. (y, x) ∈ measure size ⟶ (∀x. (canonical H x ⊨ y) = rel H (canonical H x) y); semics (canonical H i) (rel H) x = rel H (canonical H i) x; x = ❙⋅ x3⟧ ⟹ (canonical H i ⊨ x) = rel H (canonical H i) x› 4. ‹⋀x41 x42. ⟦∀y. (y, x) ∈ measure size ⟶ (∀x. (canonical H x ⊨ y) = rel H (canonical H x) y); semics (canonical H i) (rel H) x = rel H (canonical H i) x; x = x41 ❙⟶ x42⟧ ⟹ (canonical H i ⊨ x) = rel H (canonical H i) x› 5. ‹⋀x5. ⟦∀y. (y, x) ∈ measure size ⟶ (∀x. (canonical H x ⊨ y) = rel H (canonical H x) y); semics (canonical H i) (rel H) x = rel H (canonical H i) x; x = ❙◇ x5⟧ ⟹ (canonical H i ⊨ x) = rel H (canonical H i) x› 6. ‹⋀x61 x62. ⟦∀y. (y, x) ∈ measure size ⟶ (∀x. (canonical H x ⊨ y) = rel H (canonical H x) y); semics (canonical H i) (rel H) x = rel H (canonical H i) x; x = ❙@ x61 x62⟧ ⟹ (canonical H i ⊨ x) = rel H (canonical H i) x› discuss goal 1*) apply ((auto simp: reach_def (*‹reach ?H ?i ≡ {assign ?H k |k. (?i, ❙◇ (❙⋅ k)) ∈ ?H}›*))[1]) (*discuss goal 2*) apply ((auto simp: reach_def (*‹reach ?H ?i ≡ {assign ?H k |k. (?i, ❙◇ (❙⋅ k)) ∈ ?H}›*))[1]) (*discuss goal 3*) apply ((auto simp: reach_def (*‹reach (?H::(?'i × (?'i, ?'p) fm) set) (?i::?'i) ≡ {assign ?H k |k::?'i. (?i, ❙◇ (❙⋅ k)) ∈ ?H}›*))[1]) (*discuss goal 4*) apply ((auto simp: reach_def (*‹reach ?H ?i ≡ {assign ?H k |k. (?i, ❙◇ (❙⋅ k)) ∈ ?H}›*))[1]) (*discuss goal 5*) apply ((auto simp: reach_def (*‹reach (?H::(?'i × (?'i, ?'p) fm) set) (?i::?'i) ≡ {assign ?H k |k::?'i. (?i, ❙◇ (❙⋅ k)) ∈ ?H}›*))[1]) (*discuss goal 6*) apply ((auto simp: reach_def (*‹reach ?H ?i ≡ {assign ?H k |k. (?i, ❙◇ (❙⋅ k)) ∈ ?H}›*))[1]) (*proven 6 subgoals*) . qed lemma Hintikka_Extend': assumes ‹consistent H› ‹maximal H› ‹saturated H› shows ‹semics (canonical H i) (rel H) p ⟷ rel H (canonical H i) p› proof (cases p) (*goals: 1. ‹p = ❙⊥ ⟹ semics (canonical H i) (rel H) p = rel H (canonical H i) p› 2. ‹⋀x2. p = ❙‡ x2 ⟹ semics (canonical H i) (rel H) p = rel H (canonical H i) p› 3. ‹⋀x3. p = ❙⋅ x3 ⟹ semics (canonical H i) (rel H) p = rel H (canonical H i) p› 4. ‹⋀x41 x42. p = x41 ❙⟶ x42 ⟹ semics (canonical H i) (rel H) p = rel H (canonical H i) p› 5. ‹⋀x5. p = ❙◇ x5 ⟹ semics (canonical H i) (rel H) p = rel H (canonical H i) p› 6. ‹⋀x61 x62. p = ❙@ x61 x62 ⟹ semics (canonical H i) (rel H) p = rel H (canonical H i) p›*) case Fls (*‹(p::('a, 'b) fm) = ❙⊥›*) have "(assign H i, ❙⊥) ∉ H" using assms(1-2) (*‹consistent H› ‹maximal H›*) MCS_derive (*‹⟦consistent (?S::(?'a × (?'a, ?'b) fm) set); maximal ?S⟧ ⟹ ((?p::?'a × (?'a, ?'b) fm) ∈ ?S) = (∃S'::(?'a × (?'a, ?'b) fm) list. set S' ⊆ ?S ∧ S' ⊢⇩@ ?p)›*) unfolding consistent_def (*goal: ‹(assign (H::('a × ('a, 'b) fm) set) (i::'a), ❙⊥) ∉ H›*) by fast then show "?thesis" (*goal: ‹semics (canonical H i) (rel H) p = rel H (canonical H i) p›*) using Fls (*‹p = ❙⊥›*) by simp next (*goals: 1. ‹⋀x2. p = ❙‡ x2 ⟹ semics (canonical H i) (rel H) p = rel H (canonical H i) p› 2. ‹⋀x3. p = ❙⋅ x3 ⟹ semics (canonical H i) (rel H) p = rel H (canonical H i) p› 3. ‹⋀x41 x42. p = x41 ❙⟶ x42 ⟹ semics (canonical H i) (rel H) p = rel H (canonical H i) p› 4. ‹⋀x5. p = ❙◇ x5 ⟹ semics (canonical H i) (rel H) p = rel H (canonical H i) p› 5. ‹⋀x61 x62. p = ❙@ x61 x62 ⟹ semics (canonical H i) (rel H) p = rel H (canonical H i) p›*) case (Pro P) (*‹p = ❙‡ P›*) have "val H (assign H i) P ⟷ (assign H i, ❙‡P) ∈ H" unfolding val_def (*goal: ‹((assign H i, ❙‡ P) ∈ H) = ((assign H i, ❙‡ P) ∈ H)›*) by standard then show "?thesis" (*goal: ‹semics (canonical H i) (rel H) p = rel H (canonical H i) p›*) using Pro (*‹p = ❙‡ P›*) by simp next (*goals: 1. ‹⋀x3. p = ❙⋅ x3 ⟹ semics (canonical H i) (rel H) p = rel H (canonical H i) p› 2. ‹⋀x41 x42. p = x41 ❙⟶ x42 ⟹ semics (canonical H i) (rel H) p = rel H (canonical H i) p› 3. ‹⋀x5. p = ❙◇ x5 ⟹ semics (canonical H i) (rel H) p = rel H (canonical H i) p› 4. ‹⋀x61 x62. p = ❙@ x61 x62 ⟹ semics (canonical H i) (rel H) p = rel H (canonical H i) p›*) case (Nom k) (*‹p = ❙⋅ k›*) have "assign H i = assign H k ⟷ (assign H i, ❙⋅k) ∈ H" using assms(1-2) (*‹consistent H› ‹maximal H›*) hequiv_equivp (*‹⟦consistent ?H; maximal ?H⟧ ⟹ equivp (hequiv ?H)›*) hequiv_assign (*‹⟦consistent (?H::(?'a × (?'a, ?'b) fm) set); maximal ?H⟧ ⟹ hequiv ?H (?i::?'a) (assign ?H ?i)›*) by (metis assign_def (*‹assign ?H ?i ≡ minim |UNIV| {k. hequiv ?H ?i k}›*) equivp_def (*‹equivp ?R = (∀x y. ?R x y = (?R x = ?R y))›*) hequiv_def (*‹hequiv ?H ?i ?k ≡ (?i, ❙⋅ ?k) ∈ ?H›*)) then show "?thesis" (*goal: ‹semics (canonical H i) (rel H) p = rel H (canonical H i) p›*) using Nom (*‹p = ❙⋅ k›*) by simp next (*goals: 1. ‹⋀x41 x42. p = x41 ❙⟶ x42 ⟹ semics (canonical H i) (rel H) p = rel H (canonical H i) p› 2. ‹⋀x5. p = ❙◇ x5 ⟹ semics (canonical H i) (rel H) p = rel H (canonical H i) p› 3. ‹⋀x61 x62. p = ❙@ x61 x62 ⟹ semics (canonical H i) (rel H) p = rel H (canonical H i) p›*) case (Imp p q) (*‹(p::('a, 'b) fm) = (p::('a, 'b) fm) ❙⟶ (q::('a, 'b) fm)›*) have "(i, p) # A ⊢⇩@ (a, ❙⊥) ⟹ A ⊢⇩@ (i, p ❙⟶ q)" "A ⊢⇩@ (i, q) ⟹ A ⊢⇩@ (i, p ❙⟶ q)" for A and a and i (*goals: 1. ‹(i, p) # A ⊢⇩@ (a, ❙⊥) ⟹ A ⊢⇩@ (i, p ❙⟶ q)› 2. ‹A ⊢⇩@ (i, q) ⟹ A ⊢⇩@ (i, p ❙⟶ q)› discuss goal 1*) apply ((auto simp: Weak (*‹?A ⊢⇩@ (?i, ?p) ⟹ (?k, ?q) # ?A ⊢⇩@ (?i, ?p)›*))[1]) (*discuss goal 2*) apply ((auto simp: Weak (*‹?A ⊢⇩@ (?i, ?p) ⟹ (?k, ?q) # ?A ⊢⇩@ (?i, ?p)›*))[1]) (*proven 2 subgoals*) . moreover have "A ⊢⇩@ (i, p ❙⟶ q) ⟹ (i, p) # A ⊢⇩@ (i, q)" for A and i using deduct1 (*‹?A ⊢⇩@ (?i, ?p ❙⟶ ?q) ⟹ (?i, ?p) # ?A ⊢⇩@ (?i, ?q)›*) . ultimately have "((assign H i, p) ∈ H ⟶ (assign H i, q) ∈ H) ⟷ (assign H i, p ❙⟶ q) ∈ H" using assms(1-2) (*‹consistent H› ‹maximal H›*) MCS_derive (*‹⟦consistent (?S::(?'a × (?'a, ?'b) fm) set); maximal ?S⟧ ⟹ ((?p::?'a × (?'a, ?'b) fm) ∈ ?S) = (∃S'::(?'a × (?'a, ?'b) fm) list. set S' ⊆ ?S ∧ S' ⊢⇩@ ?p)›*) MCS_derive_fls (*‹⟦consistent (?S::(?'a::type × (?'a::type, ?'b::type) fm) set); maximal ?S⟧ ⟹ ((?p::?'a::type × (?'a::type, ?'b::type) fm) ∉ ?S) = (∃S'::(?'a::type × (?'a::type, ?'b::type) fm) list. set S' ⊆ ?S ∧ ?p # S' ⊢⇩@ (undefined, ❙⊥))›*) by (metis insert_subset (*‹(insert ?x ?A ⊆ ?B) = (?x ∈ ?B ∧ ?A ⊆ ?B)›*) list.simps( (*‹set (?x21.0 # ?x22.0) = insert ?x21.0 (set ?x22.0)›*) 15)) then show "?thesis" (*goal: ‹semics (canonical H i) (rel H) p = rel H (canonical H i) p›*) using Imp (*‹(p::('a, 'b) fm) = (p::('a, 'b) fm) ❙⟶ (q::('a, 'b) fm)›*) by simp next (*goals: 1. ‹⋀x5::('a::type, 'b::type) fm. (p::('a::type, 'b::type) fm) = ❙◇ x5 ⟹ semics (canonical (H::('a::type × ('a::type, 'b::type) fm) set) (i::'a::type)) (rel H) p = rel H (canonical H i) p› 2. ‹⋀(x61::'a::type) x62::('a::type, 'b::type) fm. (p::('a::type, 'b::type) fm) = ❙@ x61 x62 ⟹ semics (canonical (H::('a::type × ('a::type, 'b::type) fm) set) (i::'a::type)) (rel H) p = rel H (canonical H i) p›*) case (Dia p) (*‹(p::('a, 'b) fm) = ❙◇ (p::('a, 'b) fm)›*) have "(∃k ∈ reach H (assign H i). (k, p) ∈ H) ⟷ (assign H i, ❙◇ p) ∈ H" proof (standard) (*goals: 1. ‹∃k::'a∈reach (H::('a × ('a, 'b) fm) set) (assign H (i::'a)). (k, p::('a, 'b) fm) ∈ H ⟹ (assign H i, ❙◇ p) ∈ H› 2. ‹(assign (H::('a × ('a, 'b) fm) set) (i::'a), ❙◇ (p::('a, 'b) fm)) ∈ H ⟹ ∃k::'a∈reach H (assign H i). (k, p) ∈ H›*) assume "∃k ∈ reach H (assign H i). (k, p) ∈ H" (*‹∃k::'a∈reach (H::('a × ('a, 'b) fm) set) (assign H (i::'a)). (k, p::('a, 'b) fm) ∈ H›*) then have "∃k. (assign H i, ❙◇ (❙⋅k)) ∈ H ∧ (assign H k, p) ∈ H" unfolding reach_def (*goal: ‹∃k::'a. (assign (H::('a × ('a, 'b) fm) set) (i::'a), ❙◇ (❙⋅ k)) ∈ H ∧ (assign H k, p::('a, 'b) fm) ∈ H›*) by fast then have "∃k. (assign H i, ❙◇ (❙⋅k)) ∈ H ∧ (k, p) ∈ H" by (metis assms( (*‹consistent H› ‹maximal H›*) 1-2) hequiv_Nom (*‹⟦consistent ?H; maximal ?H; hequiv ?H ?i ?k; (?i, ?p) ∈ ?H⟧ ⟹ (?k, ?p) ∈ ?H›*) hequiv_assign (*‹⟦consistent ?H; maximal ?H⟧ ⟹ hequiv ?H ?i (assign ?H ?i)›*) hequiv_symp (*‹⟦consistent ?H; maximal ?H⟧ ⟹ symp (hequiv ?H)›*) sympD (*‹⟦symp ?R; ?R ?x ?y⟧ ⟹ ?R ?y ?x›*)) then have "∃k. ∃A. set A ⊆ H ∧ A ⊢⇩@ (assign H i, ❙◇ (❙⋅k)) ∧ A ⊢⇩@ (k, p)" by (metis Assm_head (*‹(?p, ?i) # ?A ⊢⇩@ (?p, ?i)›*) Weak (*‹?A ⊢⇩@ (?i, ?p) ⟹ (?k, ?q) # ?A ⊢⇩@ (?i, ?p)›*) assms( (*‹consistent H› ‹maximal H›*) 1-2) MCS_derive (*‹⟦consistent ?S; maximal ?S⟧ ⟹ (?p ∈ ?S) = (∃S'. set S' ⊆ ?S ∧ S' ⊢⇩@ ?p)›*) insert_subset (*‹(insert ?x ?A ⊆ ?B) = (?x ∈ ?B ∧ ?A ⊆ ?B)›*) list.simps( (*‹set (?x21.0 # ?x22.0) = insert ?x21.0 (set ?x22.0)›*) 15)) then have "∃A. set A ⊆ H ∧ A ⊢⇩@ (assign H i, ❙◇ p)" by fast then show "(assign H i, ❙◇ p) ∈ H" by (simp add: assms( (*‹consistent H› ‹maximal H›*) 1-2) MCS_derive (*‹⟦consistent ?S; maximal ?S⟧ ⟹ (?p ∈ ?S) = (∃S'. set S' ⊆ ?S ∧ S' ⊢⇩@ ?p)›*)) next (*goal: ‹(assign (H::('a::type × ('a::type, 'b::type) fm) set) (i::'a::type), ❙◇ (p::('a::type, 'b::type) fm)) ∈ H ⟹ ∃k::'a::type∈reach H (assign H i). (k, p) ∈ H›*) assume "(assign H i, ❙◇ p) ∈ H" (*‹(assign (H::('a × ('a, 'b) fm) set) (i::'a), ❙◇ (p::('a, 'b) fm)) ∈ H›*) then have "∃k. (assign H i, ❙◇ (❙⋅k)) ∈ H ∧ (k, p) ∈ H" using assms(3) (*‹saturated H›*) saturated (*‹⟦saturated ?H; (?i, ❙◇ ?p) ∈ ?H⟧ ⟹ ∃k. (?i, ❙◇ (❙⋅ k)) ∈ ?H ∧ (k, ?p) ∈ ?H›*) by fast then have "∃k. (assign H i, ❙◇ (❙⋅k)) ∈ H ∧ (assign H k, p) ∈ H" by (meson assms( (*‹consistent H› ‹maximal H›*) 1-2) hequiv_Nom (*‹⟦consistent ?H; maximal ?H; hequiv ?H ?i ?k; (?i, ?p) ∈ ?H⟧ ⟹ (?k, ?p) ∈ ?H›*) hequiv_assign (*‹⟦consistent ?H; maximal ?H⟧ ⟹ hequiv ?H ?i (assign ?H ?i)›*)) then show "∃k ∈ reach H (assign H i). (k, p) ∈ H" unfolding reach_def (*goal: ‹∃k∈{assign H k |k. (assign H i, ❙◇ (❙⋅ k)) ∈ H}. (k, p) ∈ H›*) by fast qed then show "?thesis" (*goal: ‹semics (canonical (H::('a × ('a, 'b) fm) set) (i::'a)) (rel H) (p::('a, 'b) fm) = rel H (canonical H i) p›*) using Dia (*‹(p::('a, 'b) fm) = ❙◇ (p::('a, 'b) fm)›*) by simp next (*goal: ‹⋀x61 x62. p = ❙@ x61 x62 ⟹ semics (canonical H i) (rel H) p = rel H (canonical H i) p›*) case (Sat k p) (*‹p = ❙@ k p›*) have "(assign H k, p) ∈ H ⟷ (assign H i, ❙@k p) ∈ H" by (metis SatE (*‹?A ⊢⇩@ (?i, ❙@ ?k ?p) ⟹ ?A ⊢⇩@ (?k, ?p)›*) SatI (*‹?A ⊢⇩@ (?i, ?p) ⟹ ?A ⊢⇩@ (?k, ❙@ ?i ?p)›*) assms( (*‹consistent H› ‹maximal H›*) 1-2) MCS_derive (*‹⟦consistent ?S; maximal ?S⟧ ⟹ (?p ∈ ?S) = (∃S'. set S' ⊆ ?S ∧ S' ⊢⇩@ ?p)›*) hequiv_Nom (*‹⟦consistent ?H; maximal ?H; hequiv ?H ?i ?k; (?i, ?p) ∈ ?H⟧ ⟹ (?k, ?p) ∈ ?H›*) hequiv_assign (*‹⟦consistent ?H; maximal ?H⟧ ⟹ hequiv ?H ?i (assign ?H ?i)›*) hequiv_symp (*‹⟦consistent ?H; maximal ?H⟧ ⟹ symp (hequiv ?H)›*) sympD (*‹⟦symp ?R; ?R ?x ?y⟧ ⟹ ?R ?y ?x›*)) then show "?thesis" (*goal: ‹semics (canonical H i) (rel H) p = rel H (canonical H i) p›*) using Sat (*‹(p::('a::type, 'b::type) fm) = ❙@ (k::'a::type) (p::('a::type, 'b::type) fm)›*) by simp qed interpretation Truth_Saturation consistent nominals_lbd witness semics semantics ‹λH. {canonical H i |i. True}› rel proof (unfold_locales) (*goals: 1. ‹⋀M p. (M ⊨ p) = semics M semantics p› 2. ‹⋀H M p. ⟦∀M∈{canonical H i |i. True}. ∀p. semics M (rel H) p = rel H M p; M ∈ {canonical H i |i. True}⟧ ⟹ (M ⊨ p) = rel H M p› 3. ‹⋀H. ⟦consistent H; maximal H; saturated H⟧ ⟹ ∀M∈{canonical H i |i. True}. ∀p. semics M (rel H) p = rel H M p›*) fix p and M :: "('i, 'p, 'w) ctx" show "(M ⊨ p) = semics M semantics p" apply (cases M) (*goal: ‹(M ⊨ p) = semics M semantics p›*) apply (induct p) (*goals: 1. ‹⋀a b c. M = (a, b, c) ⟹ (M ⊨ ❙⊥) = semics M semantics ❙⊥› 2. ‹⋀x a b c. M = (a, b, c) ⟹ (M ⊨ ❙‡ x) = semics M semantics (❙‡ x)› 3. ‹⋀x a b c. M = (a, b, c) ⟹ (M ⊨ ❙⋅ x) = semics M semantics (❙⋅ x)› 4. ‹⋀p1 p2 a b c. ⟦⋀a b c. M = (a, b, c) ⟹ (M ⊨ p1) = semics M semantics p1; ⋀a b c. M = (a, b, c) ⟹ (M ⊨ p2) = semics M semantics p2; M = (a, b, c)⟧ ⟹ (M ⊨ p1 ❙⟶ p2) = semics M semantics (p1 ❙⟶ p2)› 5. ‹⋀p a b c. ⟦⋀a b c. M = (a, b, c) ⟹ (M ⊨ p) = semics M semantics p; M = (a, b, c)⟧ ⟹ (M ⊨ ❙◇ p) = semics M semantics (❙◇ p)› 6. ‹⋀x1 p a b c. ⟦⋀a b c. M = (a, b, c) ⟹ (M ⊨ p) = semics M semantics p; M = (a, b, c)⟧ ⟹ (M ⊨ ❙@ x1 p) = semics M semantics (❙@ x1 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]) (*proven 6 subgoals*) . next (*goals: 1. ‹⋀H M p. ⟦∀M∈{canonical H i |i. True}. ∀p. semics M (rel H) p = rel H M p; M ∈ {canonical H i |i. True}⟧ ⟹ (M ⊨ p) = rel H M p› 2. ‹⋀H. ⟦consistent H; maximal H; saturated H⟧ ⟹ ∀M∈{canonical H i |i. True}. ∀p. semics M (rel H) p = rel H M p›*) fix p and H and M :: "('i, 'p, 'i) ctx" assume "∀M ∈ {canonical H i |i. True}. ∀p. semics M (rel H) p = rel H M p" "M ∈ {canonical H i |i. True}" (*‹∀M::('i, 'p) model × ('i ⇒ 'i) × 'i∈{canonical (H::('i × ('i, 'p) fm) set) i |i::'i. True}. ∀p::('i, 'p) fm. semics M (rel H) p = rel H M p› ‹(M::('i, 'p) model × ('i ⇒ 'i) × 'i) ∈ {canonical (H::('i × ('i, 'p) fm) set) i |i::'i. True}›*) then show "(M ⊨ p) = rel H M p" using Hintikka_model' (*‹(⋀(i::?'a) p::(?'a, ?'b) fm. semics (canonical (?H::(?'a × (?'a, ?'b) fm) set) i) (rel ?H) p = rel ?H (canonical ?H i) p) ⟹ (canonical ?H (?i::?'a) ⊨ (?p::(?'a, ?'b) fm)) = rel ?H (canonical ?H ?i) ?p›*) by fast next (*goal: ‹⋀H. ⟦consistent H; maximal H; saturated H⟧ ⟹ ∀M∈{canonical H i |i. True}. ∀p. semics M (rel H) p = rel H M p›*) fix H :: "('i, 'p) lbd set" assume "consistent H" "maximal H" "saturated H" (*‹consistent (H::('i × ('i, 'p) fm) set)› ‹maximal (H::('i × ('i, 'p) fm) set)› ‹saturated (H::('i × ('i, 'p) fm) set)›*) then show "∀M∈{canonical H i |i. True}. ∀p. semics M (rel H) p = rel H M p" using Hintikka_Extend' (*‹⟦consistent ?H; maximal ?H; saturated ?H⟧ ⟹ semics (canonical ?H ?i) (rel ?H) ?p = rel ?H (canonical ?H ?i) ?p›*) by fast qed lemma Truth_lemma: assumes ‹consistent H› ‹maximal H› ‹saturated H› shows ‹(canonical H i ⊨ p) ⟷ (i, p) ∈ H› proof (-) (*goal: ‹(canonical (H::('a × ('a, 'b) fm) set) (i::'a) ⊨ (p::('a, 'b) fm)) = ((i, p) ∈ H)›*) have "(canonical H i ⊨ p) ⟷ (assign H i, p) ∈ H" using truth_lemma_saturation (*‹⟦consistent (?H::(?'a × (?'a, ?'b) fm) set); maximal ?H; saturated ?H; (?M::(?'a, ?'b) model × (?'a ⇒ ?'a) × ?'a) ∈ {canonical ?H i |i::?'a. True}⟧ ⟹ (?M ⊨ (?p::(?'a, ?'b) fm)) = rel ?H ?M ?p›*) assms (*‹consistent H› ‹maximal H› ‹saturated H›*) by fastforce then show "?thesis" (*goal: ‹(canonical H i ⊨ p) = ((i, p) ∈ H)›*) using assms (*‹consistent H› ‹maximal H› ‹saturated H›*) by (meson MCS_Nom_sym (*‹⟦consistent ?S; maximal ?S; (?i, ❙⋅ ?k) ∈ ?S⟧ ⟹ (?k, ❙⋅ ?i) ∈ ?S›*) hequiv_Nom (*‹⟦consistent ?H; maximal ?H; hequiv ?H ?i ?k; (?i, ?p) ∈ ?H⟧ ⟹ (?k, ?p) ∈ ?H›*) hequiv_assign (*‹⟦consistent ?H; maximal ?H⟧ ⟹ hequiv ?H ?i (assign ?H ?i)›*) hequiv_def (*‹hequiv ?H ?i ?k ≡ (?i, ❙⋅ ?k) ∈ ?H›*)) qed section ‹Cardinalities› datatype marker = FlsM | ImpM | DiaM | SatM type_synonym ('i, 'p) enc = ‹('i + 'p) + marker × nat› abbreviation ‹NOM i ≡ Inl (Inl i)› abbreviation ‹PRO x ≡ Inl (Inr x)› abbreviation ‹FLS ≡ Inr (FlsM, 0)› abbreviation ‹IMP n ≡ Inr (FlsM, n)› abbreviation ‹DIA ≡ Inr (DiaM, 0)› abbreviation ‹SAT ≡ Inr (SatM, 0)› primrec encode :: ‹('i, 'p) fm ⇒ ('i, 'p) enc list› where ‹encode ❙⊥ = [FLS]› | ‹encode (❙‡P) = [PRO P]› | ‹encode (❙⋅i) = [NOM i]› | ‹encode (p ❙⟶ q) = IMP (length (encode p)) # encode p @ encode q› | ‹encode (❙◇ p) = DIA # encode p› | ‹encode (❙@ i p) = SAT # NOM i # encode p› lemma encode_ne [simp]: ‹encode p ≠ []› apply (induct p) (*goals: 1. ‹encode ❙⊥ ≠ []› 2. ‹⋀x. encode (❙‡ x) ≠ []› 3. ‹⋀x. encode (❙⋅ x) ≠ []› 4. ‹⋀p1 p2. ⟦encode p1 ≠ []; encode p2 ≠ []⟧ ⟹ encode (p1 ❙⟶ p2) ≠ []› 5. ‹⋀p. encode p ≠ [] ⟹ encode (❙◇ p) ≠ []› 6. ‹⋀x1 p. encode p ≠ [] ⟹ encode (❙@ x1 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]) (*proven 6 subgoals*) . lemma inj_encode': ‹encode p = encode q ⟹ p = q› proof (induct p arbitrary: q) (*goals: 1. ‹⋀q. encode ❙⊥ = encode q ⟹ ❙⊥ = q› 2. ‹⋀x q. encode (❙‡ x) = encode q ⟹ ❙‡ x = q› 3. ‹⋀x q. encode (❙⋅ x) = encode q ⟹ ❙⋅ x = q› 4. ‹⋀p1 p2 q. ⟦⋀q. encode p1 = encode q ⟹ p1 = q; ⋀q. encode p2 = encode q ⟹ p2 = q; encode (p1 ❙⟶ p2) = encode q⟧ ⟹ p1 ❙⟶ p2 = q› 5. ‹⋀p q. ⟦⋀q. encode p = encode q ⟹ p = q; encode (❙◇ p) = encode q⟧ ⟹ ❙◇ p = q› 6. ‹⋀x1 p q. ⟦⋀q. encode p = encode q ⟹ p = q; encode (❙@ x1 p) = encode q⟧ ⟹ ❙@ x1 p = q›*) case Fls (*‹encode ❙⊥ = encode (q::('a, 'b) fm)›*) then show "?case" (*goal: ‹❙⊥ = (q::('a::type, 'b::type) fm)›*) apply (cases q) (*goals: 1. ‹⟦encode ❙⊥ = encode (q::('a, 'b) fm); q = ❙⊥⟧ ⟹ ❙⊥ = q› 2. ‹⋀x2::'b. ⟦encode ❙⊥ = encode (q::('a, 'b) fm); q = ❙‡ x2⟧ ⟹ ❙⊥ = q› 3. ‹⋀x3::'a. ⟦encode ❙⊥ = encode (q::('a, 'b) fm); q = ❙⋅ x3⟧ ⟹ ❙⊥ = q› 4. ‹⋀(x41::('a, 'b) fm) x42::('a, 'b) fm. ⟦encode ❙⊥ = encode (q::('a, 'b) fm); q = x41 ❙⟶ x42⟧ ⟹ ❙⊥ = q› 5. ‹⋀x5::('a, 'b) fm. ⟦encode ❙⊥ = encode (q::('a, 'b) fm); q = ❙◇ x5⟧ ⟹ ❙⊥ = q› 6. ‹⋀(x61::'a) x62::('a, 'b) fm. ⟦encode ❙⊥ = encode (q::('a, 'b) fm); q = ❙@ x61 x62⟧ ⟹ ❙⊥ = 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]) (*discuss goal 5*) apply ((auto)[1]) (*discuss goal 6*) apply ((auto)[1]) (*proven 6 subgoals*) . next (*goals: 1. ‹⋀x q. encode (❙‡ x) = encode q ⟹ ❙‡ x = q› 2. ‹⋀x q. encode (❙⋅ x) = encode q ⟹ ❙⋅ x = q› 3. ‹⋀p1 p2 q. ⟦⋀q. encode p1 = encode q ⟹ p1 = q; ⋀q. encode p2 = encode q ⟹ p2 = q; encode (p1 ❙⟶ p2) = encode q⟧ ⟹ p1 ❙⟶ p2 = q› 4. ‹⋀p q. ⟦⋀q. encode p = encode q ⟹ p = q; encode (❙◇ p) = encode q⟧ ⟹ ❙◇ p = q› 5. ‹⋀x1 p q. ⟦⋀q. encode p = encode q ⟹ p = q; encode (❙@ x1 p) = encode q⟧ ⟹ ❙@ x1 p = q›*) case (Pro P) (*‹encode (❙‡ P) = encode q›*) then show "?case" (*goal: ‹❙‡ P = q›*) apply (cases q) (*goals: 1. ‹⟦encode (❙‡ P) = encode q; q = ❙⊥⟧ ⟹ ❙‡ P = q› 2. ‹⋀x2. ⟦encode (❙‡ P) = encode q; q = ❙‡ x2⟧ ⟹ ❙‡ P = q› 3. ‹⋀x3. ⟦encode (❙‡ P) = encode q; q = ❙⋅ x3⟧ ⟹ ❙‡ P = q› 4. ‹⋀x41 x42. ⟦encode (❙‡ P) = encode q; q = x41 ❙⟶ x42⟧ ⟹ ❙‡ P = q› 5. ‹⋀x5. ⟦encode (❙‡ P) = encode q; q = ❙◇ x5⟧ ⟹ ❙‡ P = q› 6. ‹⋀x61 x62. ⟦encode (❙‡ P) = encode q; q = ❙@ x61 x62⟧ ⟹ ❙‡ P = 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]) (*discuss goal 5*) apply ((auto)[1]) (*discuss goal 6*) apply ((auto)[1]) (*proven 6 subgoals*) . next (*goals: 1. ‹⋀x q. encode (❙⋅ x) = encode q ⟹ ❙⋅ x = q› 2. ‹⋀p1 p2 q. ⟦⋀q. encode p1 = encode q ⟹ p1 = q; ⋀q. encode p2 = encode q ⟹ p2 = q; encode (p1 ❙⟶ p2) = encode q⟧ ⟹ p1 ❙⟶ p2 = q› 3. ‹⋀p q. ⟦⋀q. encode p = encode q ⟹ p = q; encode (❙◇ p) = encode q⟧ ⟹ ❙◇ p = q› 4. ‹⋀x1 p q. ⟦⋀q. encode p = encode q ⟹ p = q; encode (❙@ x1 p) = encode q⟧ ⟹ ❙@ x1 p = q›*) case (Nom i) (*‹encode (❙⋅ i) = encode q›*) then show "?case" (*goal: ‹❙⋅ i = q›*) apply (cases q) (*goals: 1. ‹⟦encode (❙⋅ i) = encode q; q = ❙⊥⟧ ⟹ ❙⋅ i = q› 2. ‹⋀x2. ⟦encode (❙⋅ i) = encode q; q = ❙‡ x2⟧ ⟹ ❙⋅ i = q› 3. ‹⋀x3. ⟦encode (❙⋅ i) = encode q; q = ❙⋅ x3⟧ ⟹ ❙⋅ i = q› 4. ‹⋀x41 x42. ⟦encode (❙⋅ i) = encode q; q = x41 ❙⟶ x42⟧ ⟹ ❙⋅ i = q› 5. ‹⋀x5. ⟦encode (❙⋅ i) = encode q; q = ❙◇ x5⟧ ⟹ ❙⋅ i = q› 6. ‹⋀x61 x62. ⟦encode (❙⋅ i) = encode q; q = ❙@ x61 x62⟧ ⟹ ❙⋅ i = 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]) (*discuss goal 5*) apply ((auto)[1]) (*discuss goal 6*) apply ((auto)[1]) (*proven 6 subgoals*) . next (*goals: 1. ‹⋀p1 p2 q. ⟦⋀q. encode p1 = encode q ⟹ p1 = q; ⋀q. encode p2 = encode q ⟹ p2 = q; encode (p1 ❙⟶ p2) = encode q⟧ ⟹ p1 ❙⟶ p2 = q› 2. ‹⋀p q. ⟦⋀q. encode p = encode q ⟹ p = q; encode (❙◇ p) = encode q⟧ ⟹ ❙◇ p = q› 3. ‹⋀x1 p q. ⟦⋀q. encode p = encode q ⟹ p = q; encode (❙@ x1 p) = encode q⟧ ⟹ ❙@ x1 p = q›*) case (Imp p1 p2) (*‹encode p1 = encode ?q ⟹ p1 = ?q› ‹encode p2 = encode ?q ⟹ p2 = ?q› ‹encode (p1 ❙⟶ p2) = encode q›*) then show "?case" (*goal: ‹p1 ❙⟶ p2 = q›*) apply (cases q) (*goals: 1. ‹⟦⋀q::('a::type, 'b::type) fm. encode (p1::('a::type, 'b::type) fm) = encode q ⟹ p1 = q; ⋀q::('a::type, 'b::type) fm. encode (p2::('a::type, 'b::type) fm) = encode q ⟹ p2 = q; encode (p1 ❙⟶ p2) = encode (q::('a::type, 'b::type) fm); q = ❙⊥⟧ ⟹ p1 ❙⟶ p2 = q› 2. ‹⋀x2::'b::type. ⟦⋀q::('a::type, 'b::type) fm. encode (p1::('a::type, 'b::type) fm) = encode q ⟹ p1 = q; ⋀q::('a::type, 'b::type) fm. encode (p2::('a::type, 'b::type) fm) = encode q ⟹ p2 = q; encode (p1 ❙⟶ p2) = encode (q::('a::type, 'b::type) fm); q = ❙‡ x2⟧ ⟹ p1 ❙⟶ p2 = q› 3. ‹⋀x3::'a::type. ⟦⋀q::('a::type, 'b::type) fm. encode (p1::('a::type, 'b::type) fm) = encode q ⟹ p1 = q; ⋀q::('a::type, 'b::type) fm. encode (p2::('a::type, 'b::type) fm) = encode q ⟹ p2 = q; encode (p1 ❙⟶ p2) = encode (q::('a::type, 'b::type) fm); q = ❙⋅ x3⟧ ⟹ p1 ❙⟶ p2 = q› 4. ‹⋀(x41::('a::type, 'b::type) fm) x42::('a::type, 'b::type) fm. ⟦⋀q::('a::type, 'b::type) fm. encode (p1::('a::type, 'b::type) fm) = encode q ⟹ p1 = q; ⋀q::('a::type, 'b::type) fm. encode (p2::('a::type, 'b::type) fm) = encode q ⟹ p2 = q; encode (p1 ❙⟶ p2) = encode (q::('a::type, 'b::type) fm); q = x41 ❙⟶ x42⟧ ⟹ p1 ❙⟶ p2 = q› 5. ‹⋀x5::('a::type, 'b::type) fm. ⟦⋀q::('a::type, 'b::type) fm. encode (p1::('a::type, 'b::type) fm) = encode q ⟹ p1 = q; ⋀q::('a::type, 'b::type) fm. encode (p2::('a::type, 'b::type) fm) = encode q ⟹ p2 = q; encode (p1 ❙⟶ p2) = encode (q::('a::type, 'b::type) fm); q = ❙◇ x5⟧ ⟹ p1 ❙⟶ p2 = q› 6. ‹⋀(x61::'a::type) x62::('a::type, 'b::type) fm. ⟦⋀q::('a::type, 'b::type) fm. encode (p1::('a::type, 'b::type) fm) = encode q ⟹ p1 = q; ⋀q::('a::type, 'b::type) fm. encode (p2::('a::type, 'b::type) fm) = encode q ⟹ p2 = q; encode (p1 ❙⟶ p2) = encode (q::('a::type, 'b::type) fm); q = ❙@ x61 x62⟧ ⟹ p1 ❙⟶ p2 = 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]) (*discuss goal 5*) apply ((auto)[1]) (*discuss goal 6*) apply ((auto)[1]) (*proven 6 subgoals*) . next (*goals: 1. ‹⋀p q. ⟦⋀q. encode p = encode q ⟹ p = q; encode (❙◇ p) = encode q⟧ ⟹ ❙◇ p = q› 2. ‹⋀x1 p q. ⟦⋀q. encode p = encode q ⟹ p = q; encode (❙@ x1 p) = encode q⟧ ⟹ ❙@ x1 p = q›*) case (Dia p) (*‹encode p = encode ?q ⟹ p = ?q› ‹encode (❙◇ p) = encode q›*) then show "?case" (*goal: ‹❙◇ p = q›*) apply (cases q) (*goals: 1. ‹⟦⋀q. encode p = encode q ⟹ p = q; encode (❙◇ p) = encode q; q = ❙⊥⟧ ⟹ ❙◇ p = q› 2. ‹⋀x2. ⟦⋀q. encode p = encode q ⟹ p = q; encode (❙◇ p) = encode q; q = ❙‡ x2⟧ ⟹ ❙◇ p = q› 3. ‹⋀x3. ⟦⋀q. encode p = encode q ⟹ p = q; encode (❙◇ p) = encode q; q = ❙⋅ x3⟧ ⟹ ❙◇ p = q› 4. ‹⋀x41 x42. ⟦⋀q. encode p = encode q ⟹ p = q; encode (❙◇ p) = encode q; q = x41 ❙⟶ x42⟧ ⟹ ❙◇ p = q› 5. ‹⋀x5. ⟦⋀q. encode p = encode q ⟹ p = q; encode (❙◇ p) = encode q; q = ❙◇ x5⟧ ⟹ ❙◇ p = q› 6. ‹⋀x61 x62. ⟦⋀q. encode p = encode q ⟹ p = q; encode (❙◇ p) = encode q; q = ❙@ x61 x62⟧ ⟹ ❙◇ p = 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]) (*discuss goal 5*) apply ((auto)[1]) (*discuss goal 6*) apply ((auto)[1]) (*proven 6 subgoals*) . next (*goal: ‹⋀(x1::'a) (p::('a, 'b) fm) q::('a, 'b) fm. ⟦⋀q::('a, 'b) fm. encode p = encode q ⟹ p = q; encode (❙@ x1 p) = encode q⟧ ⟹ ❙@ x1 p = q›*) case (Sat x1a p) (*‹encode (p::('a, 'b) fm) = encode (?q::('a, 'b) fm) ⟹ p = ?q› ‹encode (❙@ x1a p) = encode q›*) then show "?case" (*goal: ‹❙@ (x1a::'a) (p::('a, 'b) fm) = (q::('a, 'b) fm)›*) apply (cases q) (*goals: 1. ‹⟦⋀q::('a::type, 'b::type) fm. encode (p::('a::type, 'b::type) fm) = encode q ⟹ p = q; encode (❙@ (x1a::'a::type) p) = encode (q::('a::type, 'b::type) fm); q = ❙⊥⟧ ⟹ ❙@ x1a p = q› 2. ‹⋀x2::'b::type. ⟦⋀q::('a::type, 'b::type) fm. encode (p::('a::type, 'b::type) fm) = encode q ⟹ p = q; encode (❙@ (x1a::'a::type) p) = encode (q::('a::type, 'b::type) fm); q = ❙‡ x2⟧ ⟹ ❙@ x1a p = q› 3. ‹⋀x3::'a::type. ⟦⋀q::('a::type, 'b::type) fm. encode (p::('a::type, 'b::type) fm) = encode q ⟹ p = q; encode (❙@ (x1a::'a::type) p) = encode (q::('a::type, 'b::type) fm); q = ❙⋅ x3⟧ ⟹ ❙@ x1a p = q› 4. ‹⋀(x41::('a::type, 'b::type) fm) x42::('a::type, 'b::type) fm. ⟦⋀q::('a::type, 'b::type) fm. encode (p::('a::type, 'b::type) fm) = encode q ⟹ p = q; encode (❙@ (x1a::'a::type) p) = encode (q::('a::type, 'b::type) fm); q = x41 ❙⟶ x42⟧ ⟹ ❙@ x1a p = q› 5. ‹⋀x5::('a::type, 'b::type) fm. ⟦⋀q::('a::type, 'b::type) fm. encode (p::('a::type, 'b::type) fm) = encode q ⟹ p = q; encode (❙@ (x1a::'a::type) p) = encode (q::('a::type, 'b::type) fm); q = ❙◇ x5⟧ ⟹ ❙@ x1a p = q› 6. ‹⋀(x61::'a::type) x62::('a::type, 'b::type) fm. ⟦⋀q::('a::type, 'b::type) fm. encode (p::('a::type, 'b::type) fm) = encode q ⟹ p = q; encode (❙@ (x1a::'a::type) p) = encode (q::('a::type, 'b::type) fm); q = ❙@ x61 x62⟧ ⟹ ❙@ x1a p = 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]) (*discuss goal 5*) apply ((auto)[1]) (*discuss goal 6*) apply ((auto)[1]) (*proven 6 subgoals*) . qed lemma inj_encode: ‹inj encode› unfolding inj_def (*goal: ‹∀x y. encode x = encode y ⟶ x = y›*) using inj_encode' (*‹encode (?p::(?'a::type, ?'b::type) fm) = encode (?q::(?'a::type, ?'b::type) fm) ⟹ ?p = ?q›*) by blast primrec encode_lbd :: ‹('i, 'p) lbd ⇒ ('i, 'p) enc list› where ‹encode_lbd (i, p) = NOM i # encode p› lemma inj_encode_lbd': ‹encode_lbd (i, p) = encode_lbd (k, q) ⟹ i = k ∧ p = q› using inj_encode' (*‹encode ?p = encode ?q ⟹ ?p = ?q›*) by auto lemma inj_encode_lbd: ‹inj encode_lbd› unfolding inj_def (*goal: ‹∀x y. encode_lbd x = encode_lbd y ⟶ x = y›*) using inj_encode_lbd' (*‹encode_lbd (?i, ?p) = encode_lbd (?k, ?q) ⟹ ?i = ?k ∧ ?p = ?q›*) by auto lemma finite_marker: ‹finite (UNIV :: marker set)› proof (-) (*goal: ‹finite UNIV›*) have "p ∈ {FlsM, ImpM, DiaM, SatM}" for p apply (cases p) (*goals: 1. ‹p = FlsM ⟹ p ∈ {FlsM, ImpM, DiaM, SatM}› 2. ‹p = ImpM ⟹ p ∈ {FlsM, ImpM, DiaM, SatM}› 3. ‹p = DiaM ⟹ p ∈ {FlsM, ImpM, DiaM, SatM}› 4. ‹p = SatM ⟹ p ∈ {FlsM, ImpM, DiaM, SatM}› 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 show "?thesis" (*goal: ‹finite UNIV›*) by (meson ex_new_if_finite (*‹⟦infinite UNIV; finite ?A⟧ ⟹ ∃a. a ∉ ?A›*) finite.emptyI (*‹finite {}›*) finite_insert (*‹finite (insert ?a ?A) = finite ?A›*)) qed lemma card_of_lbd: assumes ‹infinite (UNIV :: 'i set)› shows ‹|UNIV :: ('i, 'p) lbd set| ≤o |UNIV :: 'i set| +c |UNIV :: 'p set|› proof (-) (*goal: ‹|UNIV| ≤o |UNIV| +c |UNIV|›*) have "|UNIV :: marker set| ≤o |UNIV :: nat set|" using finite_marker (*‹finite UNIV›*) by (simp add: ordLess_imp_ordLeq (*‹?r <o ?r' ⟹ ?r ≤o ?r'›*)) moreover have "infinite (UNIV :: ('i + 'p) set)" using assms (*‹infinite UNIV›*) by simp ultimately have "|UNIV :: ('i, 'p) enc list set| ≤o |UNIV :: ('i + 'p) set|" using card_of_params_marker_lists (*‹⟦infinite UNIV; |UNIV| ≤o |UNIV|⟧ ⟹ |UNIV| ≤o |UNIV|›*) by blast moreover have "|UNIV :: ('i, 'p) lbd set| ≤o |UNIV :: ('i, 'p) enc list set|" using card_of_ordLeq (*‹(∃f. inj_on f ?A ∧ f ` ?A ⊆ ?B) = (|?A| ≤o |?B|)›*) inj_encode_lbd (*‹inj encode_lbd›*) by blast ultimately have "|UNIV :: ('i, 'p) lbd set| ≤o |UNIV :: ('i + 'p) set|" using ordLeq_transitive (*‹⟦?r ≤o ?r'; ?r' ≤o ?r''⟧ ⟹ ?r ≤o ?r''›*) by blast then show "?thesis" (*goal: ‹|UNIV| ≤o |UNIV| +c |UNIV|›*) unfolding csum_def (*goal: ‹|UNIV| ≤o |Field |UNIV| <+> Field |UNIV||›*) by simp qed section ‹Completeness› theorem strong_completeness: fixes p :: ‹('i, 'p) fm› assumes ‹∀M :: ('i, 'p) model. ∀g w. (∀(k, q) ∈ X. (M, g, g k) ⊨ q) ⟶ (M, g, w) ⊨ p› ‹infinite (UNIV :: 'i set)› ‹|UNIV :: 'i set| +c |UNIV :: 'p set| ≤o |UNIV - nominals X|› shows ‹∃A. set A ⊆ X ∧ A ⊢⇩@ (i, p)› proof (rule ccontr (*‹(¬ (?P::bool) ⟹ False) ⟹ ?P›*)) (*goal: ‹∄A. set A ⊆ X ∧ A ⊢⇩@ (i, p) ⟹ False›*) assume "∄A. set A ⊆ X ∧ A ⊢⇩@ (i, p)" (*‹∄A::('i × ('i, 'p) fm) list. set A ⊆ (X::('i × ('i, 'p) fm) set) ∧ A ⊢⇩@ (i::'i, p::('i, 'p) fm)›*) then have "*": "∄A. ∃a. set A ⊆ X ∧ ((i, ❙¬ p) # A ⊢⇩@ (a, ❙⊥))" using Boole (*‹(?i, ❙¬ ?p) # ?A ⊢⇩@ (?i, ❙⊥) ⟹ ?A ⊢⇩@ (?i, ?p)›*) FlsE (*‹?A ⊢⇩@ (?i, ❙⊥) ⟹ ?A ⊢⇩@ (?k, ?p)›*) by metis let ?S = "{(i, ❙¬ p)} ∪ X" let ?H = "Extend ?S" have "consistent ?S" unfolding consistent_def (*goal: ‹∄(S'::('i::type × ('i::type, 'p::type) fm) list) a::'i::type. set S' ⊆ {(i::'i::type, ❙¬ (p::('i::type, 'p::type) fm))} ∪ (X::('i::type × ('i::type, 'p::type) fm) set) ∧ S' ⊢⇩@ (a, ❙⊥)›*) using "*" (*‹∄(A::('i × ('i, 'p) fm) list) a::'i. set A ⊆ (X::('i × ('i, 'p) fm) set) ∧ (i::'i, ❙¬ (p::('i, 'p) fm)) # A ⊢⇩@ (a, ❙⊥)›*) derive_split1 (*‹⟦set ?A ⊆ {?q} ∪ ?X; ?A ⊢⇩@ ?p⟧ ⟹ ∃C. set C ⊆ ?X ∧ ?q # C ⊢⇩@ ?p›*) by metis moreover have "infinite (UNIV - nominals X)" using assms(2-3) (*‹infinite UNIV› ‹|UNIV| +c |UNIV| ≤o |UNIV - paramss X|›*) by (metis Cinfinite_csum (*‹Cinfinite ?r1.0 ∨ Cinfinite ?r2.0 ⟹ Cinfinite (?r1.0 +c ?r2.0)›*) Cnotzero_UNIV (*‹(|UNIV|, czero) ∉ ordIso ∧ Card_order |UNIV|›*) Field_card_of (*‹Field |?A| = ?A›*) cinfinite_def (*‹cinfinite ?r ≡ infinite (Field ?r)›*) cinfinite_mono (*‹⟦?r1.0 ≤o ?r2.0; cinfinite ?r1.0⟧ ⟹ cinfinite ?r2.0›*)) then have "|UNIV :: 'i set| +c |UNIV :: 'p set| ≤o |UNIV - nominals X - nominals_lbd (i, ❙¬ p)|" using assms(3) (*‹|UNIV| +c |UNIV| ≤o |UNIV - paramss X|›*) finite_nominals_lbd (*‹finite (nominals_lbd (?p::?'a × (?'a, ?'b) fm))›*) card_of_infinite_diff_finite (*‹⟦infinite ?A; finite ?B⟧ ⟹ |?A - ?B| =o |?A|›*) by (metis ordIso_iff_ordLeq (*‹(?r =o ?r') = (?r ≤o ?r' ∧ ?r' ≤o ?r)›*) ordLeq_transitive (*‹⟦?r ≤o ?r'; ?r' ≤o ?r''⟧ ⟹ ?r ≤o ?r''›*)) then have "|UNIV :: 'i set| +c |UNIV :: 'p set| ≤o |UNIV - (nominals X ∪ nominals_lbd (i, ❙¬ p))|" by (metis Set_Diff_Un (*‹?X - (?Y ∪ ?Z) = ?X - ?Y - ?Z›*)) then have "|UNIV :: 'i set| +c |UNIV :: 'p set| ≤o |UNIV - nominals ?S|" by (metis UN_insert (*‹⋃ (?B ` insert ?a ?A) = ?B ?a ∪ ⋃ (?B ` ?A)›*) insert_is_Un (*‹insert ?a ?A = {?a} ∪ ?A›*) sup_commute (*‹sup ?x ?y = sup ?y ?x›*)) then have "|UNIV :: ('i, 'p) lbd set| ≤o |UNIV - nominals ?S|" using assms (*‹∀M g w. (∀(k, q)∈X. (M, g, g k) ⊨ q) ⟶ (M, g, w) ⊨ p› ‹infinite UNIV› ‹|UNIV| +c |UNIV| ≤o |UNIV - paramss X|›*) card_of_lbd (*‹infinite UNIV ⟹ |UNIV| ≤o |UNIV| +c |UNIV|›*) ordLeq_transitive (*‹⟦?r ≤o ?r'; ?r' ≤o ?r''⟧ ⟹ ?r ≤o ?r''›*) by blast ultimately have "consistent ?H" "maximal ?H" "saturated ?H" using MCS_Extend (*‹⟦consistent (?S::(?'a × (?'a, ?'b) fm) set); |UNIV| ≤o |UNIV - paramss ?S|⟧ ⟹ consistent (Extend ?S)› ‹⟦consistent ?S; |UNIV| ≤o |UNIV - paramss ?S|⟧ ⟹ maximal (Extend ?S)› ‹⟦consistent ?S; |UNIV| ≤o |UNIV - paramss ?S|⟧ ⟹ saturated (Extend ?S)›*) apply - (*goals: 1. ‹⟦consistent ({(i::'i::type, ❙¬ (p::('i::type, 'p::type) fm))} ∪ (X::('i::type × ('i::type, 'p::type) fm) set)); |UNIV| ≤o |UNIV - paramss ({(i, ❙¬ p)} ∪ X)|; ⋀S::(?'a18::type × (?'a18::type, ?'b18::type) fm) set. ⟦consistent S; |UNIV| ≤o |UNIV - paramss S|⟧ ⟹ consistent (Extend S); ⋀S::(?'a20::type × (?'a20::type, ?'b20::type) fm) set. ⟦consistent S; |UNIV| ≤o |UNIV - paramss S|⟧ ⟹ maximal (Extend S); ⋀S::(?'a22::type × (?'a22::type, ?'b22::type) fm) set. ⟦consistent S; |UNIV| ≤o |UNIV - paramss S|⟧ ⟹ saturated (Extend S)⟧ ⟹ consistent (Extend ({(i, ❙¬ p)} ∪ X))› 2. ‹⟦consistent ({(i::'i::type, ❙¬ (p::('i::type, 'p::type) fm))} ∪ (X::('i::type × ('i::type, 'p::type) fm) set)); |UNIV| ≤o |UNIV - paramss ({(i, ❙¬ p)} ∪ X)|; ⋀S::(?'a10::type × (?'a10::type, ?'b10::type) fm) set. ⟦consistent S; |UNIV| ≤o |UNIV - paramss S|⟧ ⟹ consistent (Extend S); ⋀S::(?'a12::type × (?'a12::type, ?'b12::type) fm) set. ⟦consistent S; |UNIV| ≤o |UNIV - paramss S|⟧ ⟹ maximal (Extend S); ⋀S::(?'a14::type × (?'a14::type, ?'b14::type) fm) set. ⟦consistent S; |UNIV| ≤o |UNIV - paramss S|⟧ ⟹ saturated (Extend S)⟧ ⟹ maximal (Extend ({(i, ❙¬ p)} ∪ X))› 3. ‹⟦consistent ({(i::'i::type, ❙¬ (p::('i::type, 'p::type) fm))} ∪ (X::('i::type × ('i::type, 'p::type) fm) set)); |UNIV| ≤o |UNIV - paramss ({(i, ❙¬ p)} ∪ X)|; ⋀S::(?'a2::type × (?'a2::type, ?'b2::type) fm) set. ⟦consistent S; |UNIV| ≤o |UNIV - paramss S|⟧ ⟹ consistent (Extend S); ⋀S::(?'a4::type × (?'a4::type, ?'b4::type) fm) set. ⟦consistent S; |UNIV| ≤o |UNIV - paramss S|⟧ ⟹ maximal (Extend S); ⋀S::(?'a6::type × (?'a6::type, ?'b6::type) fm) set. ⟦consistent S; |UNIV| ≤o |UNIV - paramss S|⟧ ⟹ saturated (Extend S)⟧ ⟹ saturated (Extend ({(i, ❙¬ p)} ∪ X))› discuss goal 1*) apply fast (*discuss goal 2*) apply fast (*discuss goal 3*) apply fast (*proven 3 subgoals*) . then have "canonical ?H i ⊨ p ⟷ (i, p) ∈ ?H" for i and p using Truth_lemma (*‹⟦consistent (?H::(?'a × (?'a, ?'b) fm) set); maximal ?H; saturated ?H⟧ ⟹ (canonical ?H (?i::?'a) ⊨ (?p::(?'a, ?'b) fm)) = ((?i, ?p) ∈ ?H)›*) by fast then have "(i, p) ∈ ?S ⟹ canonical ?H i ⊨ p" for i and p using Extend_subset (*‹?S ⊆ Extend ?S›*) by blast then have "canonical ?H i ⊨ ❙¬ p" "∀(k, q) ∈ X. canonical ?H k ⊨ q" apply - (*goals: 1. ‹(⋀ia pa. (ia, pa) ∈ {(i, ❙¬ p)} ∪ X ⟹ canonical (Extend ({(i, ❙¬ p)} ∪ X)) ia ⊨ pa) ⟹ canonical (Extend ({(i, ❙¬ p)} ∪ X)) i ⊨ ❙¬ p› 2. ‹(⋀ia pa. (ia, pa) ∈ {(i, ❙¬ p)} ∪ X ⟹ canonical (Extend ({(i, ❙¬ p)} ∪ X)) ia ⊨ pa) ⟹ ∀(k, q)∈X. canonical (Extend ({(i, ❙¬ p)} ∪ X)) k ⊨ q› discuss goal 1*) apply blast (*discuss goal 2*) apply blast (*proven 2 subgoals*) . moreover from this (*‹canonical (Extend ({(i, ❙¬ p)} ∪ X)) i ⊨ ❙¬ p› ‹∀(k::'i, q::('i, 'p) fm)∈X::('i × ('i, 'p) fm) set. canonical (Extend ({(i::'i, ❙¬ (p::('i, 'p) fm))} ∪ X)) k ⊨ q›*) have "canonical ?H i ⊨ p" using assms(1) (*‹∀M g w. (∀(k, q)∈X. (M, g, g k) ⊨ q) ⟶ (M, g, w) ⊨ p›*) by blast ultimately show False by simp qed abbreviation valid :: ‹('i, 'p) fm ⇒ bool› where ‹valid p ≡ ∀(M :: ('i, 'p) model) g w. (M, g, w) ⊨ p› theorem completeness: fixes p :: ‹('i, 'p) fm› assumes ‹valid p› ‹infinite (UNIV :: 'i set)› ‹|UNIV :: 'p set| ≤o |UNIV :: 'i set|› shows ‹[] ⊢⇩@ (i, p)› proof (-) (*goal: ‹[] ⊢⇩@ (i, p)›*) have "|UNIV :: 'i set| +c |UNIV :: 'p set| ≤o |UNIV :: 'i set|" using assms(2-3) (*‹infinite UNIV› ‹|UNIV| ≤o |UNIV|›*) by (simp add: cinfinite_def (*‹cinfinite ?r ≡ infinite (Field ?r)›*) csum_absorb1 (*‹⟦Cinfinite ?r2.0; ?r1.0 ≤o ?r2.0⟧ ⟹ ?r2.0 +c ?r1.0 =o ?r2.0›*) ordIso_imp_ordLeq (*‹?r =o ?r' ⟹ ?r ≤o ?r'›*)) then show "?thesis" (*goal: ‹[] ⊢⇩@ (i, p)›*) using assms (*‹valid (p::('i, 'p) fm)› ‹infinite UNIV› ‹|UNIV| ≤o |UNIV|›*) strong_completeness[where X = ‹{}› and p = p] (*‹⟦∀(M::('i, 'p) model) (g::'i ⇒ 'i) w::'i. (∀(k::'i, q::('i, 'p) fm)∈{}. (M, g, g k) ⊨ q) ⟶ (M, g, w) ⊨ (p::('i, 'p) fm); infinite UNIV; |UNIV| +c |UNIV| ≤o |UNIV - paramss {}|⟧ ⟹ ∃A::('i × ('i, 'p) fm) list. set A ⊆ {} ∧ A ⊢⇩@ (?i::'i, p)›*) infinite_UNIV_listI (*‹infinite UNIV›*) by auto qed corollary completeness': fixes p :: ‹('i, 'i) fm› assumes ‹valid p› ‹infinite (UNIV :: 'i set)› shows ‹[] ⊢⇩@ (i, p)› using assms (*‹valid (p::('i, 'i) fm)› ‹infinite UNIV›*) completeness[of p] (*‹⟦valid p; infinite UNIV; |UNIV| ≤o |UNIV|⟧ ⟹ [] ⊢⇩@ (?i, p)›*) by simp theorem main: fixes p :: ‹('i, 'p) fm› assumes ‹i ∉ nominals_fm p› ‹infinite (UNIV :: 'i set)› ‹|UNIV :: 'p set| ≤o |UNIV :: 'i set|› shows ‹valid p ⟷ [] ⊢⇩@ (i, p)› using assms (*‹i ∉ nominals_fm p› ‹infinite UNIV› ‹|UNIV| ≤o |UNIV|›*) completeness (*‹⟦valid (?p::(?'i::type, ?'p::type) fm); infinite UNIV; |UNIV| ≤o |UNIV|⟧ ⟹ [] ⊢⇩@ (?i::?'i::type, ?p)›*) soundness' (*‹⟦[] ⊢⇩@ (?i, ?p); ?i ∉ nominals_fm ?p⟧ ⟹ (?M, ?g, ?w) ⊨ ?p›*) by metis corollary main': fixes p :: ‹('i, 'i) fm› assumes ‹i ∉ nominals_fm p› ‹infinite (UNIV :: 'i set)› shows ‹valid p ⟷ [] ⊢⇩@ (i, p)› using assms (*‹i ∉ nominals_fm p› ‹infinite UNIV›*) completeness' (*‹⟦valid ?p; infinite UNIV⟧ ⟹ [] ⊢⇩@ (?i, ?p)›*) soundness' (*‹⟦[] ⊢⇩@ (?i, ?p); ?i ∉ nominals_fm ?p⟧ ⟹ (?M, ?g, ?w) ⊨ ?p›*) by metis end
{ "path": "afp-2025-02-12/thys/Synthetic_Completeness/Example_Hybrid_Logic.thy", "repo": "afp-2025-02-12", "sha": "796aaacbcbe334c96da37feeae622ef92172275c15219e547028e8a01a35015a" }
(* Title: Countable Ordinals Author: Brian Huffman, 2005 Maintainer: Brian Huffman <brianh at cse.ogi.edu> *) section ‹Ordinal Arithmetic› theory OrdinalArith imports OrdinalRec begin subsection ‹Addition› instantiation ordinal :: plus begin definition "(+) = (λx. ordinal_rec x (λp. oSuc))" instance .. end lemma normal_plus: "normal ((+) x)" sorry lemma ordinal_plus_0 [simp]: "x + 0 = (x::ordinal)" by (simp add: plus_ordinal_def (*‹(+) = (λx. ordinal_rec x (λp. oSuc))›*)) lemma ordinal_plus_oSuc [simp]: "x + oSuc y = oSuc (x + y)" by (simp add: plus_ordinal_def (*‹(+) = (λx. ordinal_rec x (λp. oSuc))›*)) lemma ordinal_plus_oLimit [simp]: "x + oLimit f = oLimit (λn. x + f n)" by (simp add: normal.oLimit (*‹normal ?F ⟹ ?F (oLimit ?f) = oLimit (λn. ?F (?f n))›*) normal_plus (*‹normal ((+) ?x)›*)) lemma ordinal_0_plus [simp]: "0 + x = (x::ordinal)" apply (rule_tac a=x in oLimit_induct (*‹⟦?P 0; ⋀x. ?P x ⟹ ?P (oSuc x); ⋀f. ⟦OrdinalInduct.strict_mono f; ∀n. ?P (f n)⟧ ⟹ ?P (oLimit f)⟧ ⟹ ?P ?a›*)) (*goals: 1. ‹0 + 0 = 0› 2. ‹⋀x. 0 + x = x ⟹ 0 + oSuc x = oSuc x› 3. ‹⋀f. ⟦OrdinalInduct.strict_mono f; ∀n. 0 + f n = f n⟧ ⟹ 0 + oLimit f = oLimit f› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*discuss goal 3*) apply simp (*proven 3 subgoals*) . lemma ordinal_plus_assoc: "(x + y) + z = x + (y + z::ordinal)" apply (rule_tac a=z in oLimit_induct (*‹⟦(?P::ordinal ⇒ bool) (0::ordinal); ⋀x::ordinal. ?P x ⟹ ?P (oSuc x); ⋀f::nat ⇒ ordinal. ⟦OrdinalInduct.strict_mono f; ∀n::nat. ?P (f n)⟧ ⟹ ?P (oLimit f)⟧ ⟹ ?P (?a::ordinal)›*)) (*goals: 1. ‹x + y + 0 = x + (y + 0)› 2. ‹⋀xa. x + y + xa = x + (y + xa) ⟹ x + y + oSuc xa = x + (y + oSuc xa)› 3. ‹⋀f. ⟦OrdinalInduct.strict_mono f; ∀n. x + y + f n = x + (y + f n)⟧ ⟹ x + y + oLimit f = x + (y + oLimit f)› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*discuss goal 3*) apply simp (*proven 3 subgoals*) . lemma ordinal_plus_monoL [rule_format]: "∀x x'. x ≤ x' ⟶ x + y ≤ x' + (y::ordinal)" apply (rule_tac a=y in oLimit_induct (*‹⟦?P 0; ⋀x. ?P x ⟹ ?P (oSuc x); ⋀f. ⟦OrdinalInduct.strict_mono f; ∀n. ?P (f n)⟧ ⟹ ?P (oLimit f)⟧ ⟹ ?P ?a›*)) (*goals: 1. ‹∀(x::ordinal) x'::ordinal. x ≤ x' ⟶ x + (0::ordinal) ≤ x' + (0::ordinal)› 2. ‹⋀x::ordinal. ∀(xa::ordinal) x'::ordinal. xa ≤ x' ⟶ xa + x ≤ x' + x ⟹ ∀(xa::ordinal) x'::ordinal. xa ≤ x' ⟶ xa + oSuc x ≤ x' + oSuc x› 3. ‹⋀f::nat ⇒ ordinal. ⟦OrdinalInduct.strict_mono f; ∀(n::nat) (x::ordinal) x'::ordinal. x ≤ x' ⟶ x + f n ≤ x' + f n⟧ ⟹ ∀(x::ordinal) x'::ordinal. x ≤ x' ⟶ x + oLimit f ≤ x' + oLimit f› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*discuss goal 3*) apply simp (*goal: ‹⋀f. ⟦OrdinalInduct.strict_mono f; ∀n x x'. x ≤ x' ⟶ x + f n ≤ x' + f n⟧ ⟹ ∀x x'. x ≤ x' ⟶ x + oLimit f ≤ x' + oLimit f›*) apply clarify (*goal: ‹⋀f::nat ⇒ ordinal. ⟦OrdinalInduct.strict_mono f; ∀(n::nat) (x::ordinal) x'::ordinal. x ≤ x' ⟶ x + f n ≤ x' + f n⟧ ⟹ ∀(x::ordinal) x'::ordinal. x ≤ x' ⟶ oLimit (λn::nat. x + f n) ≤ oLimit (λn::nat. x' + f n)›*) apply (rule oLimit_leI (*‹∀n::nat. (?f::nat ⇒ ordinal) n ≤ (?x::ordinal) ⟹ oLimit ?f ≤ ?x›*)) (*goal: ‹⋀f x x'. ⟦OrdinalInduct.strict_mono f; ∀n x x'. x ≤ x' ⟶ x + f n ≤ x' + f n; x ≤ x'⟧ ⟹ oLimit (λn. x + f n) ≤ oLimit (λn. x' + f n)›*) apply clarify (*goal: ‹⋀f x x'. ⟦OrdinalInduct.strict_mono f; ∀n x x'. x ≤ x' ⟶ x + f n ≤ x' + f n; x ≤ x'⟧ ⟹ ∀n. x + f n ≤ oLimit (λn. x' + f n)›*) apply (rule_tac n=n in le_oLimitI (*‹(?x::ordinal) ≤ (?f::nat ⇒ ordinal) (?n::nat) ⟹ ?x ≤ oLimit ?f›*)) (*goal: ‹⋀(f::nat ⇒ ordinal) (x::ordinal) (x'::ordinal) n::nat. ⟦OrdinalInduct.strict_mono f; ∀(n::nat) (x::ordinal) x'::ordinal. x ≤ x' ⟶ x + f n ≤ x' + f n; x ≤ x'⟧ ⟹ x + f n ≤ oLimit (λn::nat. x' + f n)›*) apply simp (*proven 3 subgoals*) . lemma ordinal_plus_monoR: "y ≤ y' ⟹ x + y ≤ x + (y'::ordinal)" by (rule normal.monoD[OF normal_plus] (*‹?x ≤ ?y ⟹ ?x1 + ?x ≤ ?x1 + ?y›*)) lemma ordinal_plus_mono: "⟦x ≤ x'; y ≤ y'⟧ ⟹ x + y ≤ x' + (y'::ordinal)" apply (rule order_trans[OF ordinal_plus_monoL ordinal_plus_monoR] (*‹⟦?x2 ≤ ?x1; ?y1 ≤ ?y'1⟧ ⟹ ?x2 + ?y1 ≤ ?x1 + ?y'1›*)) (*goals: 1. ‹⟦x ≤ x'; y ≤ y'⟧ ⟹ x ≤ x'› 2. ‹⟦x ≤ x'; y ≤ y'⟧ ⟹ y ≤ y'› discuss goal 1*) apply ((assumption)[1]) (*discuss goal 2*) . (*proven 2 subgoals*) lemma ordinal_plus_strict_monoR: "y < y' ⟹ x + y < x + (y'::ordinal)" by (rule normal.strict_monoD[OF normal_plus] (*‹?x < ?y ⟹ ?x1 + ?x < ?x1 + ?y›*)) lemma ordinal_le_plusL [simp]: "y ≤ x + (y::ordinal)" apply (cut_tac ordinal_plus_monoL[OF ordinal_0_le] (*‹0 + ?y ≤ ?x' + ?y›*)) (*goal: ‹y ≤ x + y›*) by simp lemma ordinal_le_plusR [simp]: "x ≤ x + (y::ordinal)" apply (cut_tac ordinal_plus_monoR[OF ordinal_0_le] (*‹?x + 0 ≤ ?x + ?y'›*)) (*goal: ‹x ≤ x + y›*) by simp lemma ordinal_less_plusR: "0 < y ⟹ x < x + (y::ordinal)" apply (drule_tac ordinal_plus_strict_monoR (*‹?y < ?y' ⟹ ?x + ?y < ?x + ?y'›*)) (*goal: ‹0 < y ⟹ x < x + y›*) by simp lemma ordinal_plus_left_cancel [simp]: "(w + x = w + y) = (x = (y::ordinal))" by (rule normal.cancel_eq[OF normal_plus] (*‹(?x1 + ?x = ?x1 + ?y) = (?x = ?y)›*)) lemma ordinal_plus_left_cancel_le [simp]: "(w + x ≤ w + y) = (x ≤ (y::ordinal))" by (rule normal.cancel_le[OF normal_plus] (*‹(?x1 + ?x ≤ ?x1 + ?y) = (?x ≤ ?y)›*)) lemma ordinal_plus_left_cancel_less [simp]: "(w + x < w + y) = (x < (y::ordinal))" by (rule normal.cancel_less[OF normal_plus] (*‹(?x1 + ?x < ?x1 + ?y) = (?x < ?y)›*)) lemma ordinal_plus_not_0: "(0 < x + y) = (0 < x ∨ 0 < (y::ordinal))" by (metis ordinal_le_0 (*‹(?x ≤ 0) = (?x = 0)›*) ordinal_le_plusL (*‹?y ≤ ?x + ?y›*) ordinal_neq_0 (*‹(?x ≠ 0) = (0 < ?x)›*) ordinal_plus_0 (*‹?x + 0 = ?x›*)) lemma not_inject: "(¬ P) = (¬ Q) ⟹ P = Q" by auto lemma ordinal_plus_eq_0: "((x::ordinal) + y = 0) = (x = 0 ∧ y = 0)" apply (rule not_inject (*‹(¬ ?P) = (¬ ?Q) ⟹ ?P = ?Q›*)) (*goal: ‹(x + y = 0) = (x = 0 ∧ y = 0)›*) by (simp add: ordinal_plus_not_0 (*‹((0::ordinal) < (?x::ordinal) + (?y::ordinal)) = ((0::ordinal) < ?x ∨ (0::ordinal) < ?y)›*)) subsection ‹Subtraction› instantiation ordinal :: minus begin definition minus_ordinal_def: "x - y = ordinal_rec 0 (λp w. if y ≤ p then oSuc w else w) x" instance .. end lemma continuous_minus: "continuous (λx. x - y)" unfolding minus_ordinal_def (*goal: ‹continuous (ordinal_rec 0 (λp w. if y ≤ p then oSuc w else w))›*) by (simp add: continuous_ordinal_rec (*‹∀p x. x ≤ ?s p x ⟹ continuous (ordinal_rec ?z ?s)›*) order_less_imp_le (*‹?x < ?y ⟹ ?x ≤ ?y›*)) lemma ordinal_0_minus [simp]: "0 - x = (0::ordinal)" by (simp add: minus_ordinal_def (*‹?x - ?y = ordinal_rec 0 (λp w. if ?y ≤ p then oSuc w else w) ?x›*)) lemma ordinal_oSuc_minus [simp]: "y ≤ x ⟹ oSuc x - y = oSuc (x - y)" by (simp add: minus_ordinal_def (*‹?x - ?y = ordinal_rec 0 (λp w. if ?y ≤ p then oSuc w else w) ?x›*)) lemma ordinal_oLimit_minus [simp]: "oLimit f - y = oLimit (λn. f n - y)" by (rule continuousD[OF continuous_minus] (*‹oLimit (?f::nat ⇒ ordinal) - (?y1::ordinal) = oLimit (λn::nat. ?f n - ?y1)›*)) lemma ordinal_minus_0 [simp]: "x - 0 = (x::ordinal)" apply (rule_tac a=x in oLimit_induct (*‹⟦?P 0; ⋀x. ?P x ⟹ ?P (oSuc x); ⋀f. ⟦OrdinalInduct.strict_mono f; ∀n. ?P (f n)⟧ ⟹ ?P (oLimit f)⟧ ⟹ ?P ?a›*)) (*goals: 1. ‹(0::ordinal) - (0::ordinal) = (0::ordinal)› 2. ‹⋀x::ordinal. x - (0::ordinal) = x ⟹ oSuc x - (0::ordinal) = oSuc x› 3. ‹⋀f::nat ⇒ ordinal. ⟦OrdinalInduct.strict_mono f; ∀n::nat. f n - (0::ordinal) = f n⟧ ⟹ oLimit f - (0::ordinal) = oLimit f› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*discuss goal 3*) apply simp (*proven 3 subgoals*) . lemma ordinal_oSuc_minus2: "x < y ⟹ oSuc x - y = x - y" by (simp add: minus_ordinal_def (*‹?x - ?y = ordinal_rec 0 (λp w. if ?y ≤ p then oSuc w else w) ?x›*) linorder_not_le[symmetric] (*‹(?y < ?x) = (¬ ?x ≤ ?y)›*)) lemma ordinal_minus_eq_0 [rule_format, simp]: "x ≤ y ⟶ x - y = (0::ordinal)" apply (rule_tac a=x in oLimit_induct (*‹⟦?P 0; ⋀x. ?P x ⟹ ?P (oSuc x); ⋀f. ⟦OrdinalInduct.strict_mono f; ∀n. ?P (f n)⟧ ⟹ ?P (oLimit f)⟧ ⟹ ?P ?a›*)) (*goals: 1. ‹0 ≤ y ⟶ 0 - y = 0› 2. ‹⋀x. x ≤ y ⟶ x - y = 0 ⟹ oSuc x ≤ y ⟶ oSuc x - y = 0› 3. ‹⋀f. ⟦OrdinalInduct.strict_mono f; ∀n. f n ≤ y ⟶ f n - y = 0⟧ ⟹ oLimit f ≤ y ⟶ oLimit f - y = 0› discuss goal 1*) apply simp (*discuss goal 2*) apply (simp add: ordinal_oSuc_minus2 (*‹(?x::ordinal) < (?y::ordinal) ⟹ oSuc ?x - ?y = ?x - ?y›*) order_less_imp_le (*‹(?x::?'a::preorder) < (?y::?'a::preorder) ⟹ ?x ≤ ?y›*) oSuc_le_eq_less (*‹(oSuc (?x::ordinal) ≤ (?y::ordinal)) = (?x < ?y)›*)) (*discuss goal 3*) apply (simp add: order_trans[OF le_oLimit] (*‹oLimit ?f1 ≤ ?z ⟹ ?f1 ?n1 ≤ ?z›*)) (*proven 3 subgoals*) . lemma ordinal_plus_minus1 [simp]: "(x + y) - x = (y::ordinal)" apply (rule_tac a=y in oLimit_induct (*‹⟦(?P::ordinal ⇒ bool) (0::ordinal); ⋀x::ordinal. ?P x ⟹ ?P (oSuc x); ⋀f::nat ⇒ ordinal. ⟦OrdinalInduct.strict_mono f; ∀n::nat. ?P (f n)⟧ ⟹ ?P (oLimit f)⟧ ⟹ ?P (?a::ordinal)›*)) (*goals: 1. ‹x + 0 - x = 0› 2. ‹⋀xa. x + xa - x = xa ⟹ x + oSuc xa - x = oSuc xa› 3. ‹⋀f. ⟦OrdinalInduct.strict_mono f; ∀n. x + f n - x = f n⟧ ⟹ x + oLimit f - x = oLimit f› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*discuss goal 3*) apply simp (*proven 3 subgoals*) . lemma ordinal_plus_minus2 [simp]: "x ≤ y ⟹ x + (y - x) = (y::ordinal)" apply (subgoal_tac "∀z. y < x + z ⟶ x + (y - x) = y") (*goals: 1. ‹⟦x ≤ y; ∀z. y < x + z ⟶ x + (y - x) = y⟧ ⟹ x + (y - x) = y› 2. ‹x ≤ y ⟹ ∀z. y < x + z ⟶ x + (y - x) = y› discuss goal 1*) apply (drule_tac x="oSuc y" in spec (*‹∀x. ?P x ⟹ ?P ?x›*)) (*top goal: ‹⟦(x::ordinal) ≤ (y::ordinal); ∀z::ordinal. y < x + z ⟶ x + (y - x) = y⟧ ⟹ x + (y - x) = y› and 1 goal remains*) apply (erule mp (*‹⟦?P ⟶ ?Q; ?P⟧ ⟹ ?Q›*)) (*top goal: ‹⟦x ≤ y; y < x + oSuc y ⟶ x + (y - x) = y⟧ ⟹ x + (y - x) = y› and 1 goal remains*) apply (rule order_less_le_trans[OF less_oSuc] (*‹oSuc ?x ≤ ?z ⟹ ?x < ?z›*)) (*top goal: ‹x ≤ y ⟹ y < x + oSuc y› and 1 goal remains*) apply simp (*discuss goal 2*) apply (rule allI (*‹(⋀x::?'a. (?P::?'a ⇒ bool) x) ⟹ ∀x::?'a. ?P x›*)) (*goal: ‹x ≤ y ⟹ ∀z. y < x + z ⟶ x + (y - x) = y›*) apply (rule_tac a=z in oLimit_induct (*‹⟦?P 0; ⋀x. ?P x ⟹ ?P (oSuc x); ⋀f. ⟦OrdinalInduct.strict_mono f; ∀n. ?P (f n)⟧ ⟹ ?P (oLimit f)⟧ ⟹ ?P ?a›*)) (*goals: 1. ‹⋀z. x ≤ y ⟹ y < x + 0 ⟶ x + (y - x) = y› 2. ‹⋀z xa. ⟦x ≤ y; y < x + xa ⟶ x + (y - x) = y⟧ ⟹ y < x + oSuc xa ⟶ x + (y - x) = y› 3. ‹⋀z f. ⟦x ≤ y; OrdinalInduct.strict_mono f; ∀n. y < x + f n ⟶ x + (y - x) = y⟧ ⟹ y < x + oLimit f ⟶ x + (y - x) = y› discuss goal 1*) apply (simp add: linorder_not_less[symmetric] (*‹(?y ≤ ?x) = (¬ ?x < ?y)›*)) (*discuss goal 2*) apply (clarsimp simp add: less_oSuc_eq_le (*‹(?x < oSuc ?y) = (?x ≤ ?y)›*)) (*discuss goal 3*) apply clarsimp (*goal: ‹⋀z f. ⟦x ≤ y; OrdinalInduct.strict_mono f; ∀n. y < x + f n ⟶ x + (y - x) = y⟧ ⟹ y < x + oLimit f ⟶ x + (y - x) = y›*) apply (drule less_oLimitD (*‹?x < oLimit ?f ⟹ ∃n. ?x < ?f n›*)) (*goal: ‹⋀f. ⟦x ≤ y; OrdinalInduct.strict_mono f; y < oLimit (λn. x + f n); ∀n. ¬ y < x + f n⟧ ⟹ x + (y - x) = y›*) apply clarsimp (*proven 3 subgoals*) (*proven 2 subgoals*) . lemma ordinal_minusI: "x = y + z ⟹ x - y = (z::ordinal)" by simp lemma ordinal_minus_less_eq [simp]: "(y::ordinal) ≤ x ⟹ (x - y < z) = (x < y + z)" by (metis ordinal_plus_left_cancel_less (*‹(?w + ?x < ?w + ?y) = (?x < ?y)›*) ordinal_plus_minus2 (*‹?x ≤ ?y ⟹ ?x + (?y - ?x) = ?y›*)) lemma ordinal_minus_le_eq [simp]: "(x - y ≤ z) = (x ≤ y + (z::ordinal))" proof (rule linorder_le_cases (*‹⟦?x ≤ ?y ⟹ ?P; ?y ≤ ?x ⟹ ?P⟧ ⟹ ?P›*)) (*goals: 1. ‹?x ≤ ?y ⟹ (x - y ≤ z) = (x ≤ y + z)› 2. ‹?y ≤ ?x ⟹ (x - y ≤ z) = (x ≤ y + z)›*) assume "x ≤ y" (*‹(x::ordinal) ≤ (y::ordinal)›*) then show "?thesis" (*goal: ‹(x - y ≤ z) = (x ≤ y + z)›*) using order_trans (*‹⟦?x ≤ ?y; ?y ≤ ?z⟧ ⟹ ?x ≤ ?z›*) by force next (*goal: ‹y ≤ x ⟹ (x - y ≤ z) = (x ≤ y + z)›*) assume "y ≤ x" (*‹(y::ordinal) ≤ (x::ordinal)›*) then show "?thesis" (*goal: ‹(x - y ≤ z) = (x ≤ y + z)›*) by (metis ordinal_plus_left_cancel_le (*‹(?w + ?x ≤ ?w + ?y) = (?x ≤ ?y)›*) ordinal_plus_minus2 (*‹?x ≤ ?y ⟹ ?x + (?y - ?x) = ?y›*)) qed lemma ordinal_minus_monoL: "x ≤ y ⟹ x - z ≤ y - (z::ordinal)" by (erule continuous.monoD[OF continuous_minus] (*‹?x ≤ ?y ⟹ ?x - ?y1 ≤ ?y - ?y1›*)) lemma ordinal_minus_monoR: "x ≤ y ⟹ z - y ≤ z - (x::ordinal)" by (metis linorder_le_cases (*‹⟦?x ≤ ?y ⟹ ?P; ?y ≤ ?x ⟹ ?P⟧ ⟹ ?P›*) order_trans (*‹⟦?x ≤ ?y; ?y ≤ ?z⟧ ⟹ ?x ≤ ?z›*) ordinal_minus_le_eq (*‹(?x - ?y ≤ ?z) = (?x ≤ ?y + ?z)›*) ordinal_plus_monoL (*‹?x ≤ ?x' ⟹ ?x + ?y ≤ ?x' + ?y›*)) subsection ‹Multiplication› instantiation ordinal :: times begin definition times_ordinal_def: "(*) = (λx. ordinal_rec 0 (λp w. w + x))" instance .. end lemma continuous_times: "continuous ((*) x)" by (simp add: times_ordinal_def (*‹(*) = (λx. ordinal_rec 0 (λp w. w + x))›*) continuous_ordinal_rec (*‹∀p x. x ≤ ?s p x ⟹ continuous (ordinal_rec ?z ?s)›*)) lemma normal_times: "0 < x ⟹ normal ((*) x)" unfolding times_ordinal_def (*goal: ‹0 < x ⟹ normal (ordinal_rec 0 (λp w. w + x))›*) by (simp add: normal_ordinal_rec (*‹∀(p::ordinal) x::ordinal. x < (?s::ordinal ⇒ ordinal ⇒ ordinal) p x ⟹ normal (ordinal_rec (?z::ordinal) ?s)›*) ordinal_less_plusR (*‹(0::ordinal) < (?y::ordinal) ⟹ (?x::ordinal) < ?x + ?y›*)) lemma ordinal_times_0 [simp]: "x * 0 = (0::ordinal)" by (simp add: times_ordinal_def (*‹(*) = (λx. ordinal_rec 0 (λp w. w + x))›*)) lemma ordinal_times_oSuc [simp]: "x * oSuc y = (x * y) + x" by (simp add: times_ordinal_def (*‹(*) = (λx. ordinal_rec 0 (λp w. w + x))›*)) lemma ordinal_times_oLimit [simp]: "x * oLimit f = oLimit (λn. x * f n)" by (simp add: times_ordinal_def (*‹(*) = (λx. ordinal_rec 0 (λp w. w + x))›*) ordinal_rec_oLimit (*‹∀p x. x ≤ ?s p x ⟹ ordinal_rec ?z ?s (oLimit ?f) = oLimit (λn. ordinal_rec ?z ?s (?f n))›*)) lemma ordinal_0_times [simp]: "0 * x = (0::ordinal)" apply (rule_tac a=x in oLimit_induct (*‹⟦?P 0; ⋀x. ?P x ⟹ ?P (oSuc x); ⋀f. ⟦OrdinalInduct.strict_mono f; ∀n. ?P (f n)⟧ ⟹ ?P (oLimit f)⟧ ⟹ ?P ?a›*)) (*goals: 1. ‹0 * 0 = 0› 2. ‹⋀x. 0 * x = 0 ⟹ 0 * oSuc x = 0› 3. ‹⋀f. ⟦OrdinalInduct.strict_mono f; ∀n. 0 * f n = 0⟧ ⟹ 0 * oLimit f = 0› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*discuss goal 3*) apply simp (*proven 3 subgoals*) . lemma ordinal_1_times [simp]: "oSuc 0 * x = (x::ordinal)" apply (rule_tac a=x in oLimit_induct (*‹⟦?P 0; ⋀x. ?P x ⟹ ?P (oSuc x); ⋀f. ⟦OrdinalInduct.strict_mono f; ∀n. ?P (f n)⟧ ⟹ ?P (oLimit f)⟧ ⟹ ?P ?a›*)) (*goals: 1. ‹oSuc 0 * 0 = 0› 2. ‹⋀x. oSuc 0 * x = x ⟹ oSuc 0 * oSuc x = oSuc x› 3. ‹⋀f. ⟦OrdinalInduct.strict_mono f; ∀n. oSuc 0 * f n = f n⟧ ⟹ oSuc 0 * oLimit f = oLimit f› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*discuss goal 3*) apply simp (*proven 3 subgoals*) . lemma ordinal_times_1 [simp]: "x * oSuc 0 = (x::ordinal)" by simp lemma ordinal_times_distrib: "x * (y + z) = (x * y) + (x * z::ordinal)" apply (rule_tac a=z in oLimit_induct (*‹⟦(?P::ordinal ⇒ bool) (0::ordinal); ⋀x::ordinal. ?P x ⟹ ?P (oSuc x); ⋀f::nat ⇒ ordinal. ⟦OrdinalInduct.strict_mono f; ∀n::nat. ?P (f n)⟧ ⟹ ?P (oLimit f)⟧ ⟹ ?P (?a::ordinal)›*)) (*goals: 1. ‹x * (y + 0) = x * y + x * 0› 2. ‹⋀xa. x * (y + xa) = x * y + x * xa ⟹ x * (y + oSuc xa) = x * y + x * oSuc xa› 3. ‹⋀f. ⟦OrdinalInduct.strict_mono f; ∀n. x * (y + f n) = x * y + x * f n⟧ ⟹ x * (y + oLimit f) = x * y + x * oLimit f› discuss goal 1*) apply (simp add: ordinal_plus_assoc (*‹?x + ?y + ?z = ?x + (?y + ?z)›*)) (*discuss goal 2*) apply (simp add: ordinal_plus_assoc (*‹?x + ?y + ?z = ?x + (?y + ?z)›*)) (*discuss goal 3*) apply (simp add: ordinal_plus_assoc (*‹(?x::ordinal) + (?y::ordinal) + (?z::ordinal) = ?x + (?y + ?z)›*)) (*proven 3 subgoals*) . lemma ordinal_times_assoc: "(x * y::ordinal) * z = x * (y * z)" apply (rule_tac a=z in oLimit_induct (*‹⟦(?P::ordinal ⇒ bool) (0::ordinal); ⋀x::ordinal. ?P x ⟹ ?P (oSuc x); ⋀f::nat ⇒ ordinal. ⟦OrdinalInduct.strict_mono f; ∀n::nat. ?P (f n)⟧ ⟹ ?P (oLimit f)⟧ ⟹ ?P (?a::ordinal)›*)) (*goals: 1. ‹x * y * 0 = x * (y * 0)› 2. ‹⋀xa. x * y * xa = x * (y * xa) ⟹ x * y * oSuc xa = x * (y * oSuc xa)› 3. ‹⋀f. ⟦OrdinalInduct.strict_mono f; ∀n. x * y * f n = x * (y * f n)⟧ ⟹ x * y * oLimit f = x * (y * oLimit f)› discuss goal 1*) apply (simp add: ordinal_times_distrib (*‹?x * (?y + ?z) = ?x * ?y + ?x * ?z›*)) (*discuss goal 2*) apply (simp add: ordinal_times_distrib (*‹(?x::ordinal) * ((?y::ordinal) + (?z::ordinal)) = ?x * ?y + ?x * ?z›*)) (*discuss goal 3*) apply (simp add: ordinal_times_distrib (*‹?x * (?y + ?z) = ?x * ?y + ?x * ?z›*)) (*proven 3 subgoals*) . lemma ordinal_times_monoL [rule_format]: "∀x x'. x ≤ x' ⟶ x * y ≤ x' * (y::ordinal)" apply (rule_tac a=y in oLimit_induct (*‹⟦?P 0; ⋀x. ?P x ⟹ ?P (oSuc x); ⋀f. ⟦OrdinalInduct.strict_mono f; ∀n. ?P (f n)⟧ ⟹ ?P (oLimit f)⟧ ⟹ ?P ?a›*)) (*goals: 1. ‹∀(x::ordinal) x'::ordinal. x ≤ x' ⟶ x * (0::ordinal) ≤ x' * (0::ordinal)› 2. ‹⋀x::ordinal. ∀(xa::ordinal) x'::ordinal. xa ≤ x' ⟶ xa * x ≤ x' * x ⟹ ∀(xa::ordinal) x'::ordinal. xa ≤ x' ⟶ xa * oSuc x ≤ x' * oSuc x› 3. ‹⋀f::nat ⇒ ordinal. ⟦OrdinalInduct.strict_mono f; ∀(n::nat) (x::ordinal) x'::ordinal. x ≤ x' ⟶ x * f n ≤ x' * f n⟧ ⟹ ∀(x::ordinal) x'::ordinal. x ≤ x' ⟶ x * oLimit f ≤ x' * oLimit f› discuss goal 1*) apply simp (*discuss goal 2*) apply clarify (*top goal: ‹⋀x. ∀xa x'. xa ≤ x' ⟶ xa * x ≤ x' * x ⟹ ∀xa x'. xa ≤ x' ⟶ xa * oSuc x ≤ x' * oSuc x› and 1 goal remains*) apply (simp add: ordinal_plus_mono (*‹⟦?x ≤ ?x'; ?y ≤ ?y'⟧ ⟹ ?x + ?y ≤ ?x' + ?y'›*)) (*discuss goal 3*) apply clarsimp (*goal: ‹⋀f. ⟦OrdinalInduct.strict_mono f; ∀n x x'. x ≤ x' ⟶ x * f n ≤ x' * f n⟧ ⟹ ∀x x'. x ≤ x' ⟶ x * oLimit f ≤ x' * oLimit f›*) apply (rule oLimit_leI (*‹∀n. ?f n ≤ ?x ⟹ oLimit ?f ≤ ?x›*)) (*goal: ‹⋀f x x'. ⟦OrdinalInduct.strict_mono f; ∀n x x'. x ≤ x' ⟶ x * f n ≤ x' * f n; x ≤ x'⟧ ⟹ oLimit (λn. x * f n) ≤ oLimit (λn. x' * f n)›*) apply clarify (*goal: ‹⋀f x x'. ⟦OrdinalInduct.strict_mono f; ∀n x x'. x ≤ x' ⟶ x * f n ≤ x' * f n; x ≤ x'⟧ ⟹ ∀n. x * f n ≤ oLimit (λn. x' * f n)›*) apply (rule_tac n=n in le_oLimitI (*‹?x ≤ ?f ?n ⟹ ?x ≤ oLimit ?f›*)) (*goal: ‹⋀(f::nat ⇒ ordinal) (x::ordinal) (x'::ordinal) n::nat. ⟦OrdinalInduct.strict_mono f; ∀(n::nat) (x::ordinal) x'::ordinal. x ≤ x' ⟶ x * f n ≤ x' * f n; x ≤ x'⟧ ⟹ x * f n ≤ oLimit (λn::nat. x' * f n)›*) apply simp (*proven 3 subgoals*) . lemma ordinal_times_monoR: "y ≤ y' ⟹ x * y ≤ x * (y'::ordinal)" by (rule continuous.monoD[OF continuous_times] (*‹(?x::ordinal) ≤ (?y::ordinal) ⟹ (?x1::ordinal) * ?x ≤ ?x1 * ?y›*)) lemma ordinal_times_mono: "⟦x ≤ x'; y ≤ y'⟧ ⟹ x * y ≤ x' * (y'::ordinal)" apply (rule order_trans[OF ordinal_times_monoL ordinal_times_monoR] (*‹⟦?x2 ≤ ?x1; ?y1 ≤ ?y'1⟧ ⟹ ?x2 * ?y1 ≤ ?x1 * ?y'1›*)) (*goals: 1. ‹⟦x ≤ x'; y ≤ y'⟧ ⟹ x ≤ x'› 2. ‹⟦x ≤ x'; y ≤ y'⟧ ⟹ y ≤ y'› discuss goal 1*) apply ((assumption)[1]) (*discuss goal 2*) . (*proven 2 subgoals*) lemma ordinal_times_strict_monoR: "⟦y < y'; 0 < x⟧ ⟹ x * y < x * (y'::ordinal)" apply (rule normal.strict_monoD[OF normal_times] (*‹⟦0 < ?x1; ?x < ?y⟧ ⟹ ?x1 * ?x < ?x1 * ?y›*)) (*goals: 1. ‹⟦(y::ordinal) < (y'::ordinal); (0::ordinal) < (x::ordinal)⟧ ⟹ (0::ordinal) < x› 2. ‹⟦(y::ordinal) < (y'::ordinal); (0::ordinal) < (x::ordinal)⟧ ⟹ y < y'› discuss goal 1*) apply ((assumption)[1]) (*discuss goal 2*) . (*proven 2 subgoals*) lemma ordinal_le_timesL [simp]: "0 < x ⟹ y ≤ x * (y::ordinal)" apply (drule ordinal_times_monoL[OF oSuc_leI] (*‹?x1 < ?x' ⟹ oSuc ?x1 * ?y ≤ ?x' * ?y›*)) (*goal: ‹0 < x ⟹ y ≤ x * y›*) by simp lemma ordinal_le_timesR [simp]: "0 < y ⟹ x ≤ x * (y::ordinal)" apply (drule ordinal_times_monoR[OF oSuc_leI] (*‹?x1 < ?y' ⟹ ?x * oSuc ?x1 ≤ ?x * ?y'›*)) (*goal: ‹0 < y ⟹ x ≤ x * y›*) by simp lemma ordinal_less_timesR: "⟦0 < x; oSuc 0 < y⟧ ⟹ x < x * (y::ordinal)" by (drule ordinal_times_strict_monoR (*‹⟦?y < ?y'; 0 < ?x⟧ ⟹ ?x * ?y < ?x * ?y'›*), assumption, simp) lemma ordinal_times_left_cancel [simp]: "0 < w ⟹ (w * x = w * y) = (x = (y::ordinal))" by (rule normal.cancel_eq[OF normal_times] (*‹0 < ?x1 ⟹ (?x1 * ?x = ?x1 * ?y) = (?x = ?y)›*)) lemma ordinal_times_left_cancel_le [simp]: "0 < w ⟹ (w * x ≤ w * y) = (x ≤ (y::ordinal))" by (rule normal.cancel_le[OF normal_times] (*‹0 < ?x1 ⟹ (?x1 * ?x ≤ ?x1 * ?y) = (?x ≤ ?y)›*)) lemma ordinal_times_left_cancel_less [simp]: "0 < w ⟹ (w * x < w * y) = (x < (y::ordinal))" by (rule normal.cancel_less[OF normal_times] (*‹0 < ?x1 ⟹ (?x1 * ?x < ?x1 * ?y) = (?x < ?y)›*)) lemma ordinal_times_eq_0: "((x::ordinal) * y = 0) = (x = 0 ∨ y = 0)" by (metis ordinal_0_times (*‹0 * ?x = 0›*) ordinal_neq_0 (*‹(?x ≠ 0) = (0 < ?x)›*) ordinal_times_0 (*‹?x * 0 = 0›*) ordinal_times_strict_monoR (*‹⟦?y < ?y'; 0 < ?x⟧ ⟹ ?x * ?y < ?x * ?y'›*)) lemma ordinal_times_not_0 [simp]: "((0::ordinal) < x * y) = (0 < x ∧ 0 < y)" by (metis ordinal_neq_0 (*‹(?x ≠ 0) = (0 < ?x)›*) ordinal_times_eq_0 (*‹(?x * ?y = 0) = (?x = 0 ∨ ?y = 0)›*)) subsection ‹Exponentiation› definition exp_ordinal :: "[ordinal, ordinal] ⇒ ordinal" (infixr "**" 75) where "(**) = (λx. if 0 < x then ordinal_rec 1 (λp w. w * x) else (λy. if y = 0 then 1 else 0))" lemma continuous_exp: "0 < x ⟹ continuous ((**) x)" by (simp add: exp_ordinal_def (*‹(**) = (λx. if 0 < x then ordinal_rec 1 (λp w. w * x) else (λy. if y = 0 then 1 else 0))›*) continuous_ordinal_rec (*‹∀p x. x ≤ ?s p x ⟹ continuous (ordinal_rec ?z ?s)›*)) lemma ordinal_exp_0 [simp]: "x ** 0 = (1::ordinal)" by (simp add: exp_ordinal_def (*‹(**) = (λx. if 0 < x then ordinal_rec 1 (λp w. w * x) else (λy. if y = 0 then 1 else 0))›*)) lemma ordinal_exp_oSuc [simp]: "x ** oSuc y = (x ** y) * x" by (simp add: exp_ordinal_def (*‹(**) = (λx. if 0 < x then ordinal_rec 1 (λp w. w * x) else (λy. if y = 0 then 1 else 0))›*)) lemma ordinal_exp_oLimit [simp]: "0 < x ⟹ x ** oLimit f = oLimit (λn. x ** f n)" by (rule continuousD[OF continuous_exp] (*‹0 < ?x1 ⟹ ?x1 ** oLimit ?f = oLimit (λn. ?x1 ** ?f n)›*)) lemma ordinal_0_exp [simp]: "0 ** x = (if x = 0 then 1 else 0)" by (simp add: exp_ordinal_def (*‹(**) = (λx. if 0 < x then ordinal_rec 1 (λp w. w * x) else (λy. if y = 0 then 1 else 0))›*)) lemma ordinal_1_exp [simp]: "oSuc 0 ** x = oSuc 0" apply (rule_tac a=x in oLimit_induct (*‹⟦?P 0; ⋀x. ?P x ⟹ ?P (oSuc x); ⋀f. ⟦OrdinalInduct.strict_mono f; ∀n. ?P (f n)⟧ ⟹ ?P (oLimit f)⟧ ⟹ ?P ?a›*)) (*goals: 1. ‹oSuc (0::ordinal) ** (0::ordinal) = oSuc (0::ordinal)› 2. ‹⋀x::ordinal. oSuc (0::ordinal) ** x = oSuc (0::ordinal) ⟹ oSuc (0::ordinal) ** oSuc x = oSuc (0::ordinal)› 3. ‹⋀f::nat ⇒ ordinal. ⟦OrdinalInduct.strict_mono f; ∀n::nat. oSuc (0::ordinal) ** f n = oSuc (0::ordinal)⟧ ⟹ oSuc (0::ordinal) ** oLimit f = oSuc (0::ordinal)› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*discuss goal 3*) apply simp (*proven 3 subgoals*) . lemma ordinal_exp_1 [simp]: "x ** oSuc 0 = x" by simp lemma ordinal_exp_distrib: "x ** (y + z) = (x ** y) * (x ** (z::ordinal))" apply (case_tac "x = 0") (*goals: 1. ‹(x::ordinal) = (0::ordinal) ⟹ x ** ((y::ordinal) + (z::ordinal)) = x ** y * x ** z› 2. ‹(x::ordinal) ≠ (0::ordinal) ⟹ x ** ((y::ordinal) + (z::ordinal)) = x ** y * x ** z› discuss goal 1*) apply (simp add: ordinal_plus_not_0 (*‹(0 < ?x + ?y) = (0 < ?x ∨ 0 < ?y)›*)) (*discuss goal 2*) apply (simp add: ordinal_plus_not_0 (*‹(0 < ?x + ?y) = (0 < ?x ∨ 0 < ?y)›*)) (*goal: ‹x ≠ 0 ⟹ x ** (y + z) = x ** y * x ** z›*) apply (rule_tac a=z in oLimit_induct (*‹⟦?P 0; ⋀x. ?P x ⟹ ?P (oSuc x); ⋀f. ⟦OrdinalInduct.strict_mono f; ∀n. ?P (f n)⟧ ⟹ ?P (oLimit f)⟧ ⟹ ?P ?a›*)) (*goals: 1. ‹0 < x ⟹ x ** (y + 0) = x ** y * x ** 0› 2. ‹⋀xa. ⟦0 < x; x ** (y + xa) = x ** y * x ** xa⟧ ⟹ x ** (y + oSuc xa) = x ** y * x ** oSuc xa› 3. ‹⋀f. ⟦0 < x; OrdinalInduct.strict_mono f; ∀n. x ** (y + f n) = x ** y * x ** f n⟧ ⟹ x ** (y + oLimit f) = x ** y * x ** oLimit f› discuss goal 1*) apply (simp add: ordinal_times_assoc (*‹?x * ?y * ?z = ?x * (?y * ?z)›*)) (*discuss goal 2*) apply (simp add: ordinal_times_assoc (*‹?x * ?y * ?z = ?x * (?y * ?z)›*)) (*discuss goal 3*) apply (simp add: ordinal_times_assoc (*‹?x * ?y * ?z = ?x * (?y * ?z)›*)) (*proven 3 subgoals*) (*proven 2 subgoals*) . lemma ordinal_exp_not_0 [simp]: "(0 < x ** y) = (0 < x ∨ y = 0)" apply auto (*goals: 1. ‹⟦0 < x ** y; 0 < y⟧ ⟹ 0 < x› 2. ‹0 < x ⟹ 0 < x ** y› discuss goal 1*) apply (erule contrapos_pp (*‹⟦?Q; ¬ ?P ⟹ ¬ ?Q⟧ ⟹ ?P›*)) (*top goal: ‹⟦0 < x ** y; 0 < y⟧ ⟹ 0 < x› and 1 goal remains*) apply simp (*discuss goal 2*) apply (rule_tac a=y in oLimit_induct (*‹⟦?P 0; ⋀x. ?P x ⟹ ?P (oSuc x); ⋀f. ⟦OrdinalInduct.strict_mono f; ∀n. ?P (f n)⟧ ⟹ ?P (oLimit f)⟧ ⟹ ?P ?a›*)) (*goals: 1. ‹0 < x ⟹ 0 < x ** 0› 2. ‹⋀xa. ⟦0 < x; 0 < x ** xa⟧ ⟹ 0 < x ** oSuc xa› 3. ‹⋀f. ⟦0 < x; OrdinalInduct.strict_mono f; ∀n. 0 < x ** f n⟧ ⟹ 0 < x ** oLimit f› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*discuss goal 3*) apply simp (*goal: ‹⋀f. ⟦0 < x; OrdinalInduct.strict_mono f; ∀n. 0 < x ** f n⟧ ⟹ 0 < x ** oLimit f›*) apply (rule less_oLimitI (*‹?x < ?f ?n ⟹ ?x < oLimit ?f›*)) (*goal: ‹⋀f. ⟦0 < x; OrdinalInduct.strict_mono f; ∀n. 0 < x ** f n⟧ ⟹ 0 < oLimit (λn. x ** f n)›*) apply (erule spec (*‹∀x. ?P x ⟹ ?P ?x›*)) (*proven 3 subgoals*) (*proven 2 subgoals*) . lemma ordinal_exp_eq_0 [simp]: "(x ** y = 0) = (x = 0 ∧ 0 < y)" apply (rule not_inject (*‹(¬ ?P) = (¬ ?Q) ⟹ ?P = ?Q›*)) (*goal: ‹(x ** y = 0) = (x = 0 ∧ 0 < y)›*) by simp lemma ordinal_exp_assoc: "(x ** y) ** z = x ** (y * z)" apply (case_tac "x = 0") (*goals: 1. ‹x = 0 ⟹ (x ** y) ** z = x ** (y * z)› 2. ‹x ≠ 0 ⟹ (x ** y) ** z = x ** (y * z)› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*goal: ‹x ≠ 0 ⟹ (x ** y) ** z = x ** (y * z)›*) apply (rule_tac a=z in oLimit_induct (*‹⟦?P 0; ⋀x. ?P x ⟹ ?P (oSuc x); ⋀f. ⟦OrdinalInduct.strict_mono f; ∀n. ?P (f n)⟧ ⟹ ?P (oLimit f)⟧ ⟹ ?P ?a›*)) (*goals: 1. ‹0 < x ⟹ (x ** y) ** 0 = x ** (y * 0)› 2. ‹⋀xa. ⟦0 < x; (x ** y) ** xa = x ** (y * xa)⟧ ⟹ (x ** y) ** oSuc xa = x ** (y * oSuc xa)› 3. ‹⋀f. ⟦0 < x; OrdinalInduct.strict_mono f; ∀n. (x ** y) ** f n = x ** (y * f n)⟧ ⟹ (x ** y) ** oLimit f = x ** (y * oLimit f)› discuss goal 1*) apply (simp add: ordinal_exp_distrib (*‹?x ** (?y + ?z) = ?x ** ?y * ?x ** ?z›*)) (*discuss goal 2*) apply (simp add: ordinal_exp_distrib (*‹(?x::ordinal) ** ((?y::ordinal) + (?z::ordinal)) = ?x ** ?y * ?x ** ?z›*)) (*discuss goal 3*) apply (simp add: ordinal_exp_distrib (*‹?x ** (?y + ?z) = ?x ** ?y * ?x ** ?z›*)) (*proven 3 subgoals*) (*proven 2 subgoals*) . lemma ordinal_exp_monoL [rule_format]: "∀x x'. x ≤ x' ⟶ x ** y ≤ x' ** (y::ordinal)" apply (rule_tac a=y in oLimit_induct (*‹⟦(?P::ordinal ⇒ bool) (0::ordinal); ⋀x::ordinal. ?P x ⟹ ?P (oSuc x); ⋀f::nat ⇒ ordinal. ⟦OrdinalInduct.strict_mono f; ∀n::nat. ?P (f n)⟧ ⟹ ?P (oLimit f)⟧ ⟹ ?P (?a::ordinal)›*)) (*goals: 1. ‹∀x x'. x ≤ x' ⟶ x ** 0 ≤ x' ** 0› 2. ‹⋀x. ∀xa x'. xa ≤ x' ⟶ xa ** x ≤ x' ** x ⟹ ∀xa x'. xa ≤ x' ⟶ xa ** oSuc x ≤ x' ** oSuc x› 3. ‹⋀f. ⟦OrdinalInduct.strict_mono f; ∀n x x'. x ≤ x' ⟶ x ** f n ≤ x' ** f n⟧ ⟹ ∀x x'. x ≤ x' ⟶ x ** oLimit f ≤ x' ** oLimit f› discuss goal 1*) apply simp (*discuss goal 2*) apply (simp add: ordinal_times_mono (*‹⟦(?x::ordinal) ≤ (?x'::ordinal); (?y::ordinal) ≤ (?y'::ordinal)⟧ ⟹ ?x * ?y ≤ ?x' * ?y'›*)) (*discuss goal 3*) apply clarsimp (*goal: ‹⋀f. ⟦OrdinalInduct.strict_mono f; ∀n x x'. x ≤ x' ⟶ x ** f n ≤ x' ** f n⟧ ⟹ ∀x x'. x ≤ x' ⟶ x ** oLimit f ≤ x' ** oLimit f›*) apply (case_tac "x = 0") (*goals: 1. ‹⋀f x x'. ⟦OrdinalInduct.strict_mono f; ∀n x x'. x ≤ x' ⟶ x ** f n ≤ x' ** f n; x ≤ x'; x = 0⟧ ⟹ x ** oLimit f ≤ x' ** oLimit f› 2. ‹⋀f x x'. ⟦OrdinalInduct.strict_mono f; ∀n x x'. x ≤ x' ⟶ x ** f n ≤ x' ** f n; x ≤ x'; x ≠ 0⟧ ⟹ x ** oLimit f ≤ x' ** oLimit f› discuss goal 1*) apply simp (*discuss goal 2*) apply (case_tac "x' = 0") (*goals: 1. ‹⋀f x x'. ⟦OrdinalInduct.strict_mono f; ∀n x x'. x ≤ x' ⟶ x ** f n ≤ x' ** f n; x ≤ x'; x ≠ 0; x' = 0⟧ ⟹ x ** oLimit f ≤ x' ** oLimit f› 2. ‹⋀f x x'. ⟦OrdinalInduct.strict_mono f; ∀n x x'. x ≤ x' ⟶ x ** f n ≤ x' ** f n; x ≤ x'; x ≠ 0; x' ≠ 0⟧ ⟹ x ** oLimit f ≤ x' ** oLimit f› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*goal: ‹⋀(f::nat ⇒ ordinal) (x::ordinal) x'::ordinal. ⟦OrdinalInduct.strict_mono f; ∀(n::nat) (x::ordinal) x'::ordinal. x ≤ x' ⟶ x ** f n ≤ x' ** f n; x ≤ x'; x ≠ (0::ordinal); x' ≠ (0::ordinal)⟧ ⟹ x ** oLimit f ≤ x' ** oLimit f›*) apply (rule oLimit_leI (*‹∀n. ?f n ≤ ?x ⟹ oLimit ?f ≤ ?x›*)) (*goal: ‹⋀f x x'. ⟦OrdinalInduct.strict_mono f; ∀n x x'. x ≤ x' ⟶ x ** f n ≤ x' ** f n; x ≤ x'; 0 < x; 0 < x'⟧ ⟹ oLimit (λn. x ** f n) ≤ oLimit (λn. x' ** f n)›*) apply clarify (*goal: ‹⋀f x x'. ⟦OrdinalInduct.strict_mono f; ∀n x x'. x ≤ x' ⟶ x ** f n ≤ x' ** f n; x ≤ x'; 0 < x; 0 < x'⟧ ⟹ ∀n. x ** f n ≤ oLimit (λn. x' ** f n)›*) apply (rule_tac n=n in le_oLimitI (*‹(?x::ordinal) ≤ (?f::nat ⇒ ordinal) (?n::nat) ⟹ ?x ≤ oLimit ?f›*)) (*goal: ‹⋀(f::nat ⇒ ordinal) (x::ordinal) (x'::ordinal) n::nat. ⟦OrdinalInduct.strict_mono f; ∀(n::nat) (x::ordinal) x'::ordinal. x ≤ x' ⟶ x ** f n ≤ x' ** f n; x ≤ x'; (0::ordinal) < x; (0::ordinal) < x'⟧ ⟹ x ** f n ≤ oLimit (λn::nat. x' ** f n)›*) apply simp (*proven 2 subgoals*) (*proven 2 subgoals*) (*proven 3 subgoals*) . lemma normal_exp: "oSuc 0 < x ⟹ normal ((**) x)" using order_less_trans[OF less_oSuc] (*‹oSuc ?x < ?z ⟹ ?x < ?z›*) by (simp add: normalI (*‹⟦⋀f. OrdinalInduct.strict_mono f ⟹ ?F (oLimit f) = oLimit (λn. ?F (f n)); ⋀x. ?F x < ?F (oSuc x)⟧ ⟹ normal ?F›*) ordinal_less_timesR (*‹⟦0 < ?x; oSuc 0 < ?y⟧ ⟹ ?x < ?x * ?y›*)) lemma ordinal_exp_monoR: "⟦0 < x; y ≤ y'⟧ ⟹ x ** y ≤ x ** (y'::ordinal)" apply (rule continuous.monoD[OF continuous_exp] (*‹⟦0 < ?x1; ?x ≤ ?y⟧ ⟹ ?x1 ** ?x ≤ ?x1 ** ?y›*)) (*goals: 1. ‹⟦0 < x; y ≤ y'⟧ ⟹ 0 < x› 2. ‹⟦0 < x; y ≤ y'⟧ ⟹ y ≤ y'› discuss goal 1*) apply ((assumption)[1]) (*discuss goal 2*) . (*proven 2 subgoals*) lemma ordinal_exp_mono: "⟦0 < x'; x ≤ x'; y ≤ y'⟧ ⟹ x ** y ≤ x' ** (y'::ordinal)" apply (rule order_trans[OF ordinal_exp_monoL ordinal_exp_monoR] (*‹⟦?x2 ≤ ?x1; 0 < ?x1; ?y1 ≤ ?y'1⟧ ⟹ ?x2 ** ?y1 ≤ ?x1 ** ?y'1›*)) (*goals: 1. ‹⟦(0::ordinal) < (x'::ordinal); (x::ordinal) ≤ x'; (y::ordinal) ≤ (y'::ordinal)⟧ ⟹ x ≤ x'› 2. ‹⟦(0::ordinal) < (x'::ordinal); (x::ordinal) ≤ x'; (y::ordinal) ≤ (y'::ordinal)⟧ ⟹ (0::ordinal) < x'› 3. ‹⟦(0::ordinal) < (x'::ordinal); (x::ordinal) ≤ x'; (y::ordinal) ≤ (y'::ordinal)⟧ ⟹ y ≤ y'› discuss goal 1*) apply ((assumption)[1]) (*discuss goal 2*) apply ((assumption)[1]) (*discuss goal 3*) . (*proven 3 subgoals*) lemma ordinal_exp_strict_monoR: "⟦oSuc 0 < x; y < y'⟧ ⟹ x ** y < x ** (y'::ordinal)" apply (rule normal.strict_monoD[OF normal_exp] (*‹⟦oSuc 0 < ?x1; ?x < ?y⟧ ⟹ ?x1 ** ?x < ?x1 ** ?y›*)) (*goals: 1. ‹⟦oSuc 0 < x; y < y'⟧ ⟹ oSuc 0 < x› 2. ‹⟦oSuc 0 < x; y < y'⟧ ⟹ y < y'› discuss goal 1*) apply ((assumption)[1]) (*discuss goal 2*) . (*proven 2 subgoals*) lemma ordinal_le_expR [simp]: "0 < y ⟹ x ≤ x ** (y::ordinal)" by (metis leI (*‹¬ (?x::?'a::linorder) < (?y::?'a::linorder) ⟹ ?y ≤ ?x›*) nless_le (*‹(¬ (?a::?'a::order) < (?b::?'a::order)) = (¬ ?a ≤ ?b ∨ ?a = ?b)›*) oSuc_le_eq_less (*‹(oSuc (?x::ordinal) ≤ (?y::ordinal)) = (?x < ?y)›*) ordinal_exp_1 (*‹(?x::ordinal) ** oSuc (0::ordinal) = ?x›*) ordinal_exp_mono (*‹⟦(0::ordinal) < (?x'::ordinal); (?x::ordinal) ≤ ?x'; (?y::ordinal) ≤ (?y'::ordinal)⟧ ⟹ ?x ** ?y ≤ ?x' ** ?y'›*) ordinal_le_0 (*‹((?x::ordinal) ≤ (0::ordinal)) = (?x = (0::ordinal))›*)) lemma ordinal_exp_left_cancel [simp]: "oSuc 0 < w ⟹ (w ** x = w ** y) = (x = y)" by (rule normal.cancel_eq[OF normal_exp] (*‹oSuc 0 < ?x1 ⟹ (?x1 ** ?x = ?x1 ** ?y) = (?x = ?y)›*)) lemma ordinal_exp_left_cancel_le [simp]: "oSuc 0 < w ⟹ (w ** x ≤ w ** y) = (x ≤ y)" by (rule normal.cancel_le[OF normal_exp] (*‹oSuc 0 < ?x1 ⟹ (?x1 ** ?x ≤ ?x1 ** ?y) = (?x ≤ ?y)›*)) lemma ordinal_exp_left_cancel_less [simp]: "oSuc 0 < w ⟹ (w ** x < w ** y) = (x < y)" by (rule normal.cancel_less[OF normal_exp] (*‹oSuc 0 < ?x1 ⟹ (?x1 ** ?x < ?x1 ** ?y) = (?x < ?y)›*)) end
{ "path": "afp-2025-02-12/thys/Ordinal/OrdinalArith.thy", "repo": "afp-2025-02-12", "sha": "a3598b8dabe9d4a738618a245c247e1c031fc1ae7791047ba0f4d54df17b780d" }
section ‹Uniqueness of Laplace Transform› theory Uniqueness imports "Existence" "Lerch_Lemma" begin text ‹We show uniqueness of the Laplace transform for continuous functions.› lemma laplace_transform_zero:― ‹should also work for piecewise continuous› assumes cont_f: "continuous_on {0..} f" assumes eo: "exponential_order M a f" assumes laplace: "⋀s. Re s > a ⟹ (f has_laplace 0) s" assumes "t ≥ 0" shows "f t = 0" proof (-) (*goal: ‹(f::real ⇒ complex) (t::real) = (0::complex)›*) define I where "I ≡ λs k. integral {0..k} (laplace_integrand f s)" have bounded_image: "bounded (f ` {0..b})" for b by (auto intro!: compact_imp_bounded (*‹compact ?U ⟹ bounded ?U›*) compact_continuous_image (*‹⟦continuous_on ?s ?f; compact ?s⟧ ⟹ compact (?f ` ?s)›*) cont_f (*‹continuous_on {0..} f›*) intro: continuous_on_subset (*‹⟦continuous_on ?s ?f; ?t ⊆ ?s⟧ ⟹ continuous_on ?t ?f›*)) obtain B where B: "∀x∈{0..b}. cmod (f x) ≤ B b" for b (*goal: ‹(⋀B. (⋀b. ∀x∈{0..b}. cmod (f x) ≤ B b) ⟹ thesis) ⟹ thesis›*) apply atomize_elim (*goal: ‹(⋀B. (⋀b. ∀x∈{0..b}. cmod (f x) ≤ B b) ⟹ thesis) ⟹ thesis›*) apply (rule choice (*‹∀x::?'a. ∃y::?'b. (?Q::?'a ⇒ ?'b ⇒ bool) x y ⟹ ∃f::?'a ⇒ ?'b. ∀x::?'a. ?Q x (f x)›*)) (*goal: ‹∃B. ∀b. ∀x∈{0..b}. cmod (f x) ≤ B b›*) using bounded_image[unfolded bounded_iff] (*‹∃a. ∀x∈f ` {0..?b}. cmod x ≤ a›*) by auto have fi: "f integrable_on {0..b}" for b by (auto intro!: integrable_continuous_interval (*‹continuous_on {?a..?b} ?f ⟹ ?f integrable_on {?a..?b}›*) intro: continuous_on_subset (*‹⟦continuous_on ?s ?f; ?t ⊆ ?s⟧ ⟹ continuous_on ?t ?f›*) cont_f (*‹continuous_on {0..} f›*)) have aint: "complex_set_integrable lebesgue {0..b} (laplace_integrand f s)" for b and s by (rule laplace_integrand_absolutely_integrable_on_Icc[OF AE_BallI[OF bounded_le_Sup[OF bounded_image]] fi] (*‹complex_set_integrable lebesgue {0..?b5} (laplace_integrand f ?s)›*)) have int: "((λt. exp (t *⇩R - s) * f t) has_integral I s b) {0 .. b}" for s and b using aint[of b s] (*‹complex_set_integrable lebesgue {0..b} (laplace_integrand f s)›*) unfolding laplace_integrand_def[symmetric] I_def absolutely_integrable_on_def (*goal: ‹(laplace_integrand f s has_integral integral {0..b} (laplace_integrand f s)) {0..b}›*) by blast have I_integral: "Re s > a ⟹ (I s ⤏ integral {0..} (laplace_integrand f s)) at_top" for s unfolding I_def (*goal: ‹(a::real) < Re (s::complex) ⟹ ((λk::real. integral {0::real..k} (laplace_integrand (f::real ⇒ complex) s)) ⤏ integral {0::real..} (laplace_integrand f s)) at_top›*) by (metis aint (*‹complex_set_integrable lebesgue {0..?b} (laplace_integrand f ?s)›*) eo (*‹exponential_order M a f›*) improper_integral_at_top (*‹?f absolutely_integrable_on {?a..} ⟹ ((λx. integral {?a..x} ?f) ⤏ integral {?a..} ?f) at_top›*) laplace_integrand_absolutely_integrable_on_Ici_iff (*‹⟦exponential_order ?M ?c ?f; ?c < Re ?s⟧ ⟹ complex_set_integrable lebesgue {?a..} (laplace_integrand ?f ?s) = (∀k>?a. complex_set_integrable lebesgue {?a..k} (laplace_integrand ?f ?s))›*)) have imp: "(I s ⤏ 0) at_top" if s: "Re s > a" for s using I_integral[of s] (*‹a < Re s ⟹ (I s ⤏ integral {0..} (laplace_integrand f s)) at_top›*) laplace[unfolded has_laplace_def, rule_format, OF s] (*‹((λt. exp (t *⇩R - s) * f t) has_integral 0) {0..}›*) s (*‹a < Re s›*) unfolding has_laplace_def I_def laplace_integrand_def (*goal: ‹((λk. integral {0..k} (λt. exp (t *⇩R - s) * f t)) ⤏ 0) at_top›*) by (simp add: integral_unique (*‹((?f::?'a ⇒ ?'b) has_integral (?y::?'b)) (?k::?'a set) ⟹ integral ?k ?f = ?y›*)) define s0 where "s0 = a + 1" then have "s0 > a" by auto have "∀⇩F x in at_right (0::real). 0 < x ∧ x < 1" by (auto intro!: eventually_at_rightI (*‹⟦⋀x::?'a. x ∈ {?a::?'a<..<?b::?'a} ⟹ (?P::?'a ⇒ bool) x; ?a < ?b⟧ ⟹ eventually ?P (at_right ?a)›*)) moreover from exponential_orderD(2)[OF eo] (*‹∀⇩F t in at_top. cmod (f t) ≤ M * exp (a * t)›*) have "∀⇩F t in at_right 0. cmod (f (- ln t)) ≤ M * exp (a * (- ln t))" unfolding at_top_mirror filtermap_ln_at_right[symmetric] eventually_filtermap (*goal: ‹∀⇩F t::real in at_right (0::real). cmod ((f::real ⇒ complex) (- ln t)) ≤ (M::real) * exp ((a::real) * - ln t)›*) . ultimately have "∀⇩F x in at_right 0. cmod ((x powr s0) * f (- ln x)) ≤ M * x powr (s0 - a)" (is "∀⇩F x in _. ?l x ≤ ?r x") proof (eventually_elim) (*goal: ‹⋀x. ⟦0 < x ∧ x < 1; cmod (f (- ln x)) ≤ M * exp (a * - ln x)⟧ ⟹ cmod (complex_of_real (x powr s0) * f (- ln x)) ≤ M * x powr (s0 - a)›*) case x: (elim x) (*‹0 < x ∧ x < 1› ‹cmod (f (- ln x)) ≤ M * exp (a * - ln x)›*) then have "cmod ((x powr s0) * f (- ln x)) ≤ x powr s0 * (M * exp (a * (- ln x)))" apply (intro norm_mult_ineq[THEN order_trans] (*‹norm ?x1 * norm ?y1 ≤ ?z ⟹ norm (?x1 * ?y1) ≤ ?z›*)) (*goal: ‹cmod (complex_of_real ((x::real) powr (s0::real)) * (f::real ⇒ complex) (- ln x)) ≤ x powr s0 * ((M::real) * exp ((a::real) * - ln x))›*) by (auto intro!: x(2)[THEN order_trans] (*‹(M::real) * exp ((a::real) * - ln (x::real)) ≤ (?z::real) ⟹ cmod ((f::real ⇒ complex) (- ln x)) ≤ ?z›*)) also (*calculation: ‹cmod (complex_of_real (x powr s0) * f (- ln x)) ≤ x powr s0 * (M * exp (a * - ln x))›*) have "… = M * x powr (s0 - a)" by (simp add: exp_minus (*‹exp (- ?x) = inverse (exp ?x)›*) ln_inverse (*‹0 < ?x ⟹ ln (inverse ?x) = - ln ?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*) powr_def (*‹?x powr ?a ≡ if ?x = 0 then 0 else exp (?a * ln ?x)›*) mult_exp_exp (*‹exp ?x * exp ?y = exp (?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*)) finally (*calculation: ‹cmod (complex_of_real (x powr s0) * f (- ln x)) ≤ M * x powr (s0 - a)›*) show "?case" (*goal: ‹cmod (complex_of_real (x powr s0) * f (- ln x)) ≤ M * x powr (s0 - a)›*) . qed then have "((λx. x powr s0 * f (- ln x)) ⤏ 0) (at_right 0)" apply (rule Lim_null_comparison (*‹⟦∀⇩F x in ?net. norm (?f x) ≤ ?g x; (?g ⤏ 0) ?net⟧ ⟹ (?f ⤏ 0) ?net›*)) (*goal: ‹((λx. complex_of_real (x powr s0) * f (- ln x)) ⤏ 0) (at_right 0)›*) by (auto 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 93 facts*) ‹a < s0› eventually_at_rightI (*‹⟦⋀x. x ∈ {?a<..<?b} ⟹ ?P x; ?a < ?b⟧ ⟹ eventually ?P (at_right ?a)›*) zero_less_one (*‹0 < 1›*)) moreover have "∀⇩F x in at x. ln x ≤ 0" if "0 < x" "x < 1" for x :: real using order_tendstoD(1)[OF tendsto_ident_at ‹0 < x›, of UNIV] (*‹eventually ((<) 0) (at x)›*) order_tendstoD(2)[OF tendsto_ident_at ‹x < 1›, of UNIV] (*‹∀⇩F x in at x. x < 1›*) apply eventually_elim (*goal: ‹∀⇩F x in at x. ln x ≤ 0›*) by simp ultimately have [continuous_intros]: "continuous_on {0..1} (λx. x powr s0 * f (- ln x))" apply (intro continuous_on_IccI (*‹⟦(?f ⤏ ?f ?a) (at_right ?a); (?f ⤏ ?f ?b) (at_left ?b); ⋀x. ⟦?a < x; x < ?b⟧ ⟹ ?f ─x→ ?f x; ?a < ?b⟧ ⟹ continuous_on {?a..?b} ?f›*)) (*goals: 1. ‹⟦((λx. complex_of_real (x powr s0) * f (- ln x)) ⤏ 0) (at_right 0); ⋀x. ⟦0 < x; x < 1⟧ ⟹ ∀⇩F x in at x. ln x ≤ 0⟧ ⟹ ((λx. complex_of_real (x powr s0) * f (- ln x)) ⤏ complex_of_real (0 powr s0) * f (- ln 0)) (at_right 0)› 2. ‹⟦((λx. complex_of_real (x powr s0) * f (- ln x)) ⤏ 0) (at_right 0); ⋀x. ⟦0 < x; x < 1⟧ ⟹ ∀⇩F x in at x. ln x ≤ 0⟧ ⟹ ((λx. complex_of_real (x powr s0) * f (- ln x)) ⤏ complex_of_real (1 powr s0) * f (- ln 1)) (at_left 1)› 3. ‹⋀x. ⟦((λx. complex_of_real (x powr s0) * f (- ln x)) ⤏ 0) (at_right 0); ⋀x. ⟦0 < x; x < 1⟧ ⟹ ∀⇩F x in at x. ln x ≤ 0; 0 < x; x < 1⟧ ⟹ (λx. complex_of_real (x powr s0) * f (- ln x)) ─x→ complex_of_real (x powr s0) * f (- ln x)› 4. ‹⟦((λx. complex_of_real (x powr s0) * f (- ln x)) ⤏ 0) (at_right 0); ⋀x. ⟦0 < x; x < 1⟧ ⟹ ∀⇩F x in at x. ln x ≤ 0⟧ ⟹ 0 < 1› discuss goal 1*) apply (force intro!: continuous_on_tendsto_compose[OF cont_f] (*‹⟦((?g::?'c ⇒ real) ⤏ (?l::real)) (?F::?'c filter); ?l ∈ {0::real..}; ∀⇩F x::?'c in ?F. ?g x ∈ {0::real..}⟧ ⟹ ((λx::?'c. (f::real ⇒ complex) (?g x)) ⤏ f ?l) ?F›*) 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 93 facts*) eventually_at_leftI (*‹⟦⋀x::?'a. x ∈ {?a::?'a<..<?b::?'a} ⟹ (?P::?'a ⇒ bool) x; ?a < ?b⟧ ⟹ eventually ?P (at_left ?b)›*) zero_less_one (*‹(0::?'a) < (1::?'a)›*)) (*discuss goal 2*) apply (force intro!: continuous_on_tendsto_compose[OF cont_f] (*‹⟦(?g ⤏ ?l) ?F; ?l ∈ {0..}; ∀⇩F x in ?F. ?g x ∈ {0..}⟧ ⟹ ((λx. f (?g x)) ⤏ f ?l) ?F›*) 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 93 facts*) eventually_at_leftI (*‹⟦⋀x. x ∈ {?a<..<?b} ⟹ ?P x; ?a < ?b⟧ ⟹ eventually ?P (at_left ?b)›*) zero_less_one (*‹0 < 1›*)) (*discuss goal 3*) apply (force intro!: continuous_on_tendsto_compose[OF cont_f] (*‹⟦(?g ⤏ ?l) ?F; ?l ∈ {0..}; ∀⇩F x in ?F. ?g x ∈ {0..}⟧ ⟹ ((λx. f (?g x)) ⤏ f ?l) ?F›*) 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 93 facts*) eventually_at_leftI (*‹⟦⋀x. x ∈ {?a<..<?b} ⟹ ?P x; ?a < ?b⟧ ⟹ eventually ?P (at_left ?b)›*) zero_less_one (*‹0 < 1›*)) (*discuss goal 4*) apply (force intro!: continuous_on_tendsto_compose[OF cont_f] (*‹⟦((?g::?'c::type ⇒ real) ⤏ (?l::real)) (?F::?'c::type filter); ?l ∈ {0::real..}; ∀⇩F x::?'c::type in ?F. ?g x ∈ {0::real..}⟧ ⟹ ((λx::?'c::type. (f::real ⇒ complex) (?g x)) ⤏ f ?l) ?F›*) 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 93 facts*) eventually_at_leftI (*‹⟦⋀x::?'a::order_topology. x ∈ {?a::?'a::order_topology<..<?b::?'a::order_topology} ⟹ (?P::?'a::order_topology ⇒ bool) x; ?a < ?b⟧ ⟹ eventually ?P (at_left ?b)›*) zero_less_one (*‹(0::?'a::zero_less_one) < (1::?'a::zero_less_one)›*)) (*proven 4 subgoals*) . { fix n :: nat let ?i = "(λu. u ^ n *⇩R (u powr s0 * f (- ln u)))" let ?I = "λn b. integral {exp (- b).. 1} ?i" have "∀⇩F (b::real) in at_top. b > 0" by (simp add: eventually_gt_at_top (*‹eventually ((<) ?c) at_top›*)) then have "∀⇩F b in at_top. I (s0 + Suc n) b = ?I n b" proof (eventually_elim) (*goal: ‹⋀b. 0 < b ⟹ I (complex_of_real (s0 + real (Suc n))) b = integral {exp (- b)..1} (λu. u ^ n *⇩R (complex_of_real (u powr s0) * f (- ln u)))›*) case (elim b) (*‹0 < b›*) have eq: "exp (t *⇩R - complex_of_real (s0 + real (Suc n))) * f t = complex_of_real (exp (- (real n * t)) * exp (- t) * exp (- (s0 * t))) * f t" for t by (auto simp: Euler (*‹exp (?z::complex) = complex_of_real (exp (Re ?z)) * (complex_of_real (cos (Im ?z)) + 𝗂 * complex_of_real (sin (Im ?z)))›*) mult_exp_exp (*‹exp (?x::?'a) * exp (?y::?'a) = exp (?x + ?y)›*) 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*) simp del: of_real_mult (*‹of_real ((?x::real) * (?y::real)) = of_real ?x * of_real ?y›*)) from int[of "s0 + Suc n" b] (*‹((λt. exp (t *⇩R - complex_of_real (s0 + real (Suc n))) * f t) has_integral I (complex_of_real (s0 + real (Suc n))) b) {0..b}›*) have int': "((λt. exp (- (n * t)) * exp (-t) * exp (- (s0 * t)) * f t) has_integral I (s0 + Suc n) b) {0..b}" (is "(?fe has_integral _) _") unfolding eq (*goal: ‹((λt. complex_of_real (exp (- (real n * t)) * exp (- t) * exp (- (s0 * t))) * f t) has_integral I (complex_of_real (s0 + real (Suc n))) b) {0..b}›*) . have "((λx. - exp (- x) *⇩R exp (- x) ^ n *⇩R (exp (- x) powr s0 * f (- ln (exp (- x))))) has_integral integral {exp (- 0)..exp (- b)} ?i - integral {exp (- b)..exp (- 0)} ?i) {0..b}" apply (rule has_integral_substitution_general[of "{}" 0 b "λt. exp(-t)" 0 1 ?i "λx. -exp(-x)"] (*‹⟦finite {}; 0 ≤ b; (λt. exp (- t)) ` {0..b} ⊆ {0..1}; continuous_on {0..1} (λu. u ^ n *⇩R (complex_of_real (u powr s0) * f (- ln u))); continuous_on {0..b} (λt. exp (- t)); ⋀x. x ∈ {0..b} - {} ⟹ ((λt. exp (- t)) has_real_derivative - exp (- x)) (at x within {0..b})⟧ ⟹ ((λx. - exp (- x) *⇩R exp (- x) ^ n *⇩R (complex_of_real (exp (- x) powr s0) * f (- ln (exp (- x))))) has_integral integral {exp (- 0)..exp (- b)} (λu. u ^ n *⇩R (complex_of_real (u powr s0) * f (- ln u))) - integral {exp (- b)..exp (- 0)} (λu. u ^ n *⇩R (complex_of_real (u powr s0) * f (- ln u)))) {0..b}›*)) (*goals: 1. ‹finite {}› 2. ‹0 ≤ b› 3. ‹(λt. exp (- t)) ` {0..b} ⊆ {0..1}› 4. ‹continuous_on {0..1} (λu. u ^ n *⇩R (complex_of_real (u powr s0) * f (- ln u)))› 5. ‹continuous_on {0..b} (λt. exp (- t))› 6. ‹⋀x. x ∈ {0..b} - {} ⟹ ((λt. exp (- t)) has_real_derivative - exp (- x)) (at x within {0..b})› discuss goal 1*) apply ((auto intro!: less_imp_le[OF ‹b > 0›] (*‹0 ≤ 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 260 facts*) integrable_continuous_real (*‹continuous_on {?a..?b} ?f ⟹ ?f integrable_on {?a..?b}›*) 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 133 facts*))[1]) (*discuss goal 2*) apply ((auto intro!: less_imp_le[OF ‹b > 0›] (*‹0 ≤ 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 260 facts*) integrable_continuous_real (*‹continuous_on {?a..?b} ?f ⟹ ?f integrable_on {?a..?b}›*) 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 133 facts*))[1]) (*discuss goal 3*) apply ((auto intro!: less_imp_le[OF ‹b > 0›] (*‹(0::real) ≤ (b::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 260 facts*) integrable_continuous_real (*‹continuous_on {?a::real..?b::real} (?f::real ⇒ ?'a::banach) ⟹ ?f integrable_on {?a..?b}›*) 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 133 facts*))[1]) (*discuss goal 4*) apply ((auto intro!: less_imp_le[OF ‹b > 0›] (*‹0 ≤ 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 260 facts*) integrable_continuous_real (*‹continuous_on {?a..?b} ?f ⟹ ?f integrable_on {?a..?b}›*) 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 133 facts*))[1]) (*discuss goal 5*) apply ((auto intro!: less_imp_le[OF ‹b > 0›] (*‹(0::real) ≤ (b::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 260 facts*) integrable_continuous_real (*‹continuous_on {?a::real..?b::real} (?f::real ⇒ ?'a::banach) ⟹ ?f integrable_on {?a..?b}›*) 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 133 facts*))[1]) (*discuss goal 6*) apply ((auto intro!: less_imp_le[OF ‹b > 0›] (*‹0 ≤ 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 260 facts*) integrable_continuous_real (*‹continuous_on {?a..?b} ?f ⟹ ?f integrable_on {?a..?b}›*) 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 133 facts*))[1]) (*proven 6 subgoals*) . then have "(?fe has_integral ?I n b) {0..b}" using ‹b > 0› (*‹0 < b›*) 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*) mult_exp_exp (*‹exp ?x * exp ?y = exp (?x + ?y)›*) exp_of_nat_mult[symmetric] (*‹exp ?x ^ ?n = exp (of_nat ?n * ?x)›*) scaleR_conv_of_real (*‹?r *⇩R ?x = of_real ?r * ?x›*) exp_add (*‹exp (?x + ?y) = exp ?x * exp ?y›*) powr_def (*‹?x powr ?a ≡ if ?x = 0 then 0 else exp (?a * ln ?x)›*) of_real_exp (*‹of_real (exp ?x) = exp (of_real ?x)›*) has_integral_neg_iff (*‹((λx. - ?f x) has_integral ?k) ?S = (?f has_integral - ?k) ?S›*)) with int' (*‹((λt::real. complex_of_real (exp (- (real (n::nat) * t)) * exp (- t) * exp (- ((s0::real) * t))) * (f::real ⇒ complex) t) has_integral (I::complex ⇒ real ⇒ complex) (complex_of_real (s0 + real (Suc n))) (b::real)) {0::real..b}›*) show "?case" (*goal: ‹(I::complex ⇒ real ⇒ complex) (complex_of_real ((s0::real) + real (Suc (n::nat)))) (b::real) = integral {exp (- b)..1::real} (λu::real. u ^ n *⇩R (complex_of_real (u powr s0) * (f::real ⇒ complex) (- ln u)))›*) by (rule has_integral_unique (*‹⟦(?f has_integral ?k1.0) ?i; (?f has_integral ?k2.0) ?i⟧ ⟹ ?k1.0 = ?k2.0›*)) qed moreover have "(I (s0 + Suc n) ⤏ 0) at_top" apply (rule imp (*‹a < Re ?s ⟹ (I ?s ⤏ 0) at_top›*)) (*goal: ‹(I (complex_of_real (s0 + real (Suc n))) ⤏ 0) at_top›*) by (use ‹s0 > a› in auto) ultimately have "(?I n ⤏ 0) at_top" by (rule Lim_transform_eventually[rotated] (*‹⟦∀⇩F x in ?F. ?f x = ?g x; (?f ⤏ ?l) ?F⟧ ⟹ (?g ⤏ ?l) ?F›*)) then have 1: "((λx. integral {exp (ln x)..1} ?i) ⤏ 0) (at_right 0)" unfolding at_top_mirror filtermap_ln_at_right[symmetric] filtermap_filtermap filterlim_filtermap (*goal: ‹((λx. integral {exp (ln x)..1} (λu. u ^ n *⇩R (complex_of_real (u powr s0) * f (- ln u)))) ⤏ 0) (at_right 0)›*) by simp have "∀⇩F x in at_right 0. x > 0" by (simp add: eventually_at_filter (*‹eventually ?P (at ?a within ?s) = (∀⇩F x in nhds ?a. x ≠ ?a ⟶ x ∈ ?s ⟶ ?P x)›*)) then have "∀⇩F x in at_right 0. integral {exp (ln x)..1} ?i = integral {x .. 1} ?i" apply eventually_elim (*goal: ‹∀⇩F x in at_right 0. integral {exp (ln x)..1} (λu. u ^ n *⇩R (complex_of_real (u powr s0) * f (- ln u))) = integral {x..1} (λu. u ^ n *⇩R (complex_of_real (u powr s0) * f (- ln u)))›*) by (auto simp:) from Lim_transform_eventually[OF 1 this] (*‹((λx. integral {x..1} (λu. u ^ n *⇩R (complex_of_real (u powr s0) * f (- ln u)))) ⤏ 0) (at_right 0)›*) have "((λx. integral {x..1} ?i) ⤏ 0) (at_right 0)" by simp moreover have "?i integrable_on {0..1}" 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 260 facts*) integrable_continuous_real (*‹continuous_on {?a..?b} ?f ⟹ ?f integrable_on {?a..?b}›*)) from continuous_on_Icc_at_rightD[OF indefinite_integral_continuous_1' [ OF this ] zero_less_one] (*‹((λx. integral {x..1} (λu. u ^ n *⇩R (complex_of_real (u powr s0) * f (- ln u)))) ⤏ integral {0..1} (λu. u ^ n *⇩R (complex_of_real (u powr s0) * f (- ln u)))) (at_right 0)›*) have "((λx. integral {x..1} ?i) ⤏ integral {0 .. 1} ?i) (at_right 0)" by simp ultimately have "integral {0 .. 1} ?i = 0" apply (rule tendsto_unique[symmetric, rotated] (*‹⟦(?f ⤏ ?s) ?F; (?f ⤏ ?t) ?F; ?F ≠ bot⟧ ⟹ ?t = ?s›*)) (*goal: ‹integral {0..1} (λu. u ^ n *⇩R (complex_of_real (u powr s0) * f (- ln u))) = 0›*) by simp then have "(?i has_integral 0) {0 .. 1}" using integrable_integral (*‹(?f::?'a ⇒ ?'b) integrable_on (?i::?'a set) ⟹ (?f has_integral integral ?i ?f) ?i›*) ‹?i integrable_on {0..1}› (*‹(λu. u ^ n *⇩R (complex_of_real (u powr s0) * f (- ln u))) integrable_on {0..1}›*) by (metis (full_types)) } from lerch_lemma[OF _ this, of "exp (- t)"] (*‹⟦continuous_on {0::real..1::real} (λu::real. complex_of_real (u powr (s0::real)) * (f::real ⇒ complex) (- ln u)); (0::real) ≤ exp (- (t::real)); exp (- t) ≤ (1::real)⟧ ⟹ complex_of_real (exp (- t) powr s0) * f (- ln (exp (- t))) = (0::complex)›*) show "f t = 0" using ‹t ≥ 0› (*‹0 ≤ t›*) 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 260 facts*)) qed lemma exponential_order_eventually_eq: "exponential_order M a f" if "exponential_order M a g" "⋀t. t ≥ k ⟹ f t = g t" proof (-) (*goal: ‹exponential_order (M::real) (a::real) (f::real ⇒ 'a)›*) have "∀⇩F t in at_top. f t = g t" using that (*‹exponential_order M a g› ‹k ≤ ?t ⟹ f ?t = g ?t›*) unfolding eventually_at_top_linorder (*goal: ‹∃N. ∀n≥N. f n = g n›*) by blast with exponential_orderD(2)[OF that ( 1 )] (*‹∀⇩F t in at_top. norm (g t) ≤ M * exp (a * t)›*) have "(∀⇩F t in at_top. norm (f t) ≤ M * exp (a * t))" apply eventually_elim (*goal: ‹∀⇩F t in at_top. norm (f t) ≤ M * exp (a * t)›*) by auto with exponential_orderD(1)[OF that ( 1 )] (*‹0 < M›*) show "?thesis" (*goal: ‹exponential_order M a f›*) by (rule exponential_orderI (*‹⟦(0::real) < (?M::real); ∀⇩F t::real in at_top. norm ((?f::real ⇒ ?'a::real_normed_vector) t) ≤ ?M * exp ((?c::real) * t)⟧ ⟹ exponential_order ?M ?c ?f›*)) qed lemma exponential_order_mono: assumes eo: "exponential_order M a f" assumes "a ≤ b" "M ≤ N" shows "exponential_order N b f" sorry lemma exponential_order_uminus_iff: "exponential_order M a (λx. - f x) = exponential_order M a f" by (auto simp: exponential_order_def (*‹exponential_order ?M ?c ?f = (0 < ?M ∧ (∀⇩F t in at_top. norm (?f t) ≤ ?M * exp (?c * t)))›*)) lemma exponential_order_add: assumes "exponential_order M a f" "exponential_order M a g" shows "exponential_order (2 * M) a (λx. f x + g x)" using assms (*‹exponential_order (M::real) (a::real) (f::real ⇒ 'a)› ‹exponential_order M a g›*) apply (auto simp: exponential_order_def (*‹exponential_order ?M ?c ?f = (0 < ?M ∧ (∀⇩F t in at_top. norm (?f t) ≤ ?M * exp (?c * t)))›*)) (*goal: ‹exponential_order (2 * M) a (λx. f x + g x)›*) subgoalpremises prems for using prems(1,3) (*‹∀⇩F t in at_top. norm (g t) ≤ M * exp (a * t)› ‹∀⇩F t in at_top. norm (f t) ≤ M * exp (a * t)›*) apply eventually_elim (*goal: ‹∀⇩F t in at_top. norm (f t + g t) ≤ 2 * M * exp (a * t)›*) apply (rule norm_triangle_le (*‹norm ?x + norm ?y ≤ ?e ⟹ norm (?x + ?y) ≤ ?e›*)) (*goal: ‹⋀t. ⟦norm (g t) ≤ M * exp (a * t); norm (f t) ≤ M * exp (a * t)⟧ ⟹ norm (f t + g t) ≤ 2 * M * exp (a * t)›*) by linarith . theorem laplace_transform_unique: assumes f: "⋀s. Re s > a ⟹ (f has_laplace F) s" assumes g: "⋀s. Re s > b ⟹ (g has_laplace F) s" assumes [continuous_intros]: "continuous_on {0..} f" assumes [continuous_intros]: "continuous_on {0..} g" assumes eof: "exponential_order M a f" assumes eog: "exponential_order N b g" assumes "t ≥ 0" shows "f t = g t" proof (-) (*goal: ‹f t = g t›*) define c where "c = max a b" define L where "L = max M N" from eof (*‹exponential_order M a f›*) have eof: "exponential_order L c f" apply (rule exponential_order_mono (*‹⟦exponential_order ?M ?a ?f; ?a ≤ ?b; ?M ≤ ?N⟧ ⟹ exponential_order ?N ?b ?f›*)) (*goals: 1. ‹a ≤ c› 2. ‹M ≤ L› discuss goal 1*) apply ((auto simp: L_def (*‹L = max M N›*) c_def (*‹c = max a b›*))[1]) (*discuss goal 2*) apply ((auto simp: L_def (*‹L = max M N›*) c_def (*‹c = max a b›*))[1]) (*proven 2 subgoals*) . from eog (*‹exponential_order N b g›*) have eog: "exponential_order L c (λx. - g x)" unfolding exponential_order_uminus_iff (*goal: ‹exponential_order (L::real) (c::real) (g::real ⇒ complex)›*) apply (rule exponential_order_mono (*‹⟦exponential_order ?M ?a ?f; ?a ≤ ?b; ?M ≤ ?N⟧ ⟹ exponential_order ?N ?b ?f›*)) (*goals: 1. ‹b ≤ c› 2. ‹N ≤ L› discuss goal 1*) apply ((auto simp: L_def (*‹L = max M N›*) c_def (*‹c = max a b›*))[1]) (*discuss goal 2*) apply ((auto simp: L_def (*‹L = max M N›*) c_def (*‹c = max a b›*))[1]) (*proven 2 subgoals*) . from exponential_order_add[OF eof eog] (*‹exponential_order ((2::real) * (L::real)) (c::real) (λx::real. (f::real ⇒ complex) x + - (g::real ⇒ complex) x)›*) have eom: "exponential_order (2 * L) c (λx. f x - g x)" by simp have l0: "((λx. f x - g x) has_laplace 0) s" if "Re s > c" for s using has_laplace_minus[OF f g, of s] (*‹⟦a < Re s; b < Re s⟧ ⟹ ((λx. f x - g x) has_laplace F - F) s›*) that (*‹c < Re s›*) by (simp add: c_def (*‹c = max a b›*) 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))›*)) have "f t - g t = 0" apply (rule laplace_transform_zero[OF _ eom l0 ‹t ≥ 0›] (*‹⟦continuous_on {0..} (λx. f x - g x); ⋀s. c < Re s ⟹ c < Re s⟧ ⟹ f t - g t = 0›*)) (*goals: 1. ‹continuous_on {0..} (λx. f x - g x)› 2. ‹⋀s. c < Re s ⟹ c < Re 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 261 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 261 facts*))[1]) (*proven 2 subgoals*) . then show "?thesis" (*goal: ‹f t = g t›*) by simp qed end
{ "path": "afp-2025-02-12/thys/Laplace_Transform/Uniqueness.thy", "repo": "afp-2025-02-12", "sha": "3c828a630f34db5f69f1fede7f383d8dce443d03e916f748b2e53025c9b74a7f" }
subsubsection ‹States› theory SingleStepState imports RegisterMachineSimulation begin lemma lm04_07_one_step_relation_state: fixes d :: state and c :: configuration and p :: program and t :: nat and a :: nat defines "r ≡ R c p" defines "s ≡ S c p" defines "z ≡ Z c p" defines "cs ≡ fst (steps c p t)" assumes is_val: "is_valid_initial c p a" and "d < length p" shows "s d (Suc t) = (∑S+ p d (λk. s k t)) + (∑S- p d (λk. z (modifies (p!k)) t * s k t)) + (∑S0 p d (λk. (1 - z (modifies (p!k)) t) * s k t)) + (if ishalt (p!cs) ∧ d = cs then Suc 0 else 0)" proof (-) (*goal: ‹s d (Suc t) = ∑S+ p d (λk. s k t) + ∑S- p d (λk. z (modifies (p ! k)) t * s k t) + ∑S0 p d (λk. (1 - z (modifies (p ! k)) t) * s k t) + (if ishalt (p ! cs) ∧ d = cs then Suc 0 else 0)›*) have ic: "c = (0, snd c)" using is_val (*‹is_valid_initial c p a›*) apply (auto simp add: is_valid_initial_def (*‹is_valid_initial ?c ?p ?a = (is_valid ?c ?p ∧ tape_check_initial (snd ?c) ?a ∧ fst ?c = 0)›*)) (*goal: ‹c = (0, snd c)›*) by (metis prod.collapse (*‹(fst ?prod, snd ?prod) = ?prod›*)) have cs_bound: "cs < length p" using ic (*‹(c::nat × nat list) = (0::nat, snd c)›*) is_val (*‹is_valid_initial c p a›*) p_contains[of "c" "p" "a" "t"] (*‹is_valid_initial c p a ⟹ fst (steps c p t) < length p›*) cs_def (*‹cs::nat ≡ fst (steps (c::nat × nat list) (p::instruction list) (t::nat))›*) by auto have "(∑k = 0..length p-1. if isadd (p ! k) ∧ goes_to (p ! fst (steps c p t)) = goes_to (p ! k) then if fst (steps c p t) = k then Suc 0 else 0 else 0) =(∑k = 0..length p-1. if fst (steps c p t) = k then if isadd (p ! k) ∧ goes_to (p ! fst (steps c p t)) = goes_to (p ! k) then Suc 0 else 0 else 0)" apply (rule sum.cong (*‹⟦?A = ?B; ⋀x. x ∈ ?B ⟹ ?g x = ?h x⟧ ⟹ sum ?g ?A = sum ?h ?B›*)) (*goals: 1. ‹{0..length p - 1} = {0..length p - 1}› 2. ‹⋀x. x ∈ {0..length p - 1} ⟹ (if isadd (p ! x) ∧ goes_to (p ! fst (steps c p t)) = goes_to (p ! x) then if fst (steps c p t) = x then Suc 0 else 0 else 0) = (if fst (steps c p t) = x then if isadd (p ! x) ∧ goes_to (p ! fst (steps c p t)) = goes_to (p ! x) then Suc 0 else 0 else 0)› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . hence add: "(∑S+ p d (λk. s k t)) = (if isadd (p!cs) ∧ d = goes_to (p!cs) then Suc 0 else 0)" apply (auto simp add: sum_sadd.simps (*‹∑S+ ?p ?d ?f = (∑k = 0..length ?p - 1. if isadd (?p ! k) ∧ ?d = goes_to (?p ! k) then ?f k else 0)›*) s_def (*‹s ≡ S c p›*) S_def (*‹S ?c ?p ?k ?t = (if fst (steps ?c ?p ?t) = ?k then Suc 0 else 0)›*) cs_def (*‹cs ≡ fst (steps c p t)›*)) (*goal: ‹∑S+ p d (λk. s k t) = (if isadd (p ! cs) ∧ d = goes_to (p ! cs) then Suc 0 else 0)›*) using cs_bound (*‹cs < length p›*) cs_def (*‹cs ≡ fst (steps c p t)›*) by auto have "(∑k = 0..length p-1. if issub (p ! k) ∧ goes_to (p ! fst (steps c p t)) = goes_to (p ! k) then z (modifies (p ! k)) t * (if fst (steps c p t) = k then Suc 0 else 0) else 0) = (∑k = 0..length p-1. if k=cs then if issub (p ! k) ∧ goes_to (p ! fst (steps c p t)) = goes_to (p ! k) then z (modifies (p ! k)) t else 0 else 0)" apply (rule sum.cong (*‹⟦?A = ?B; ⋀x. x ∈ ?B ⟹ ?g x = ?h x⟧ ⟹ sum ?g ?A = sum ?h ?B›*)) (*goal: ‹(∑k = 0..length p - 1. if issub (p ! k) ∧ goes_to (p ! fst (steps c p t)) = goes_to (p ! k) then z (modifies (p ! k)) t * (if fst (steps c p t) = k then Suc 0 else 0) else 0) = (∑k = 0..length p - 1. if k = cs then if issub (p ! k) ∧ goes_to (p ! fst (steps c p t)) = goes_to (p ! k) then z (modifies (p ! k)) t else 0 else 0)›*) using z_def (*‹z ≡ Z c p›*) Z_def (*‹Z ?c ?p ?n ?t = (if 0 < R ?c ?p ?n ?t then 1 else 0)›*) cs_def (*‹cs ≡ fst (steps c p t)›*) apply - (*goals: 1. ‹⟦z ≡ Z c p; ⋀c p n t. Z c p n t = (if 0 < R c p n t then 1 else 0); cs ≡ fst (steps c p t)⟧ ⟹ {0..length p - 1} = {0..length p - 1}› 2. ‹⋀x. ⟦x ∈ {0..length p - 1}; z ≡ Z c p; ⋀c p n t. Z c p n t = (if 0 < R c p n t then 1 else 0); cs ≡ fst (steps c p t)⟧ ⟹ (if issub (p ! x) ∧ goes_to (p ! fst (steps c p t)) = goes_to (p ! x) then z (modifies (p ! x)) t * (if fst (steps c p t) = x then Suc 0 else 0) else 0) = (if x = cs then if issub (p ! x) ∧ goes_to (p ! fst (steps c p t)) = goes_to (p ! x) then z (modifies (p ! x)) t else 0 else 0)› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . hence sub_zero: "(∑S- p d (λk. z (modifies (p!k)) t * s k t)) = (if issub (p!cs) ∧ d = goes_to (p!cs) then z (modifies (p!cs)) t else 0)" apply (auto simp add: sum_ssub_nzero.simps (*‹∑S- ?p ?d ?f = (∑k = 0..length ?p - 1. if issub (?p ! k) ∧ ?d = goes_to (?p ! k) then ?f k else 0)›*) s_def (*‹s ≡ S c p›*) S_def (*‹S ?c ?p ?k ?t = (if fst (steps ?c ?p ?t) = ?k then Suc 0 else 0)›*) cs_def (*‹cs ≡ fst (steps c p t)›*)) (*goal: ‹∑S- p d (λk. z (modifies (p ! k)) t * s k t) = (if issub (p ! cs) ∧ d = goes_to (p ! cs) then z (modifies (p ! cs)) t else 0)›*) using cs_bound (*‹(cs::nat) < length (p::instruction list)›*) cs_def (*‹cs ≡ fst (steps c p t)›*) by auto have "(∑k = 0..length p-1. if issub (p ! k) ∧ goes_to_alt (p ! fst (steps c p t)) = goes_to_alt (p ! k) then (Suc 0 - z (modifies (p ! k)) t) * (if fst (steps c p t) = k then Suc 0 else 0) else 0) = (∑k = 0..length p-1. if k=cs then if issub (p ! k) ∧ goes_to_alt (p ! fst (steps c p t)) = goes_to_alt (p ! k) then (Suc 0 - z (modifies (p ! k)) t) else 0 else 0)" apply (rule sum.cong (*‹⟦?A = ?B; ⋀x. x ∈ ?B ⟹ ?g x = ?h x⟧ ⟹ sum ?g ?A = sum ?h ?B›*)) (*goal: ‹(∑k::nat = 0::nat..length p - (1::nat). if issub ((p::instruction list) ! k) ∧ goes_to_alt (p ! fst (steps (c::nat × nat list) p (t::nat))) = goes_to_alt (p ! k) then (Suc (0::nat) - (z::nat ⇒ nat ⇒ nat) (modifies (p ! k)) t) * (if fst (steps c p t) = k then Suc (0::nat) else (0::nat)) else (0::nat)) = (∑k::nat = 0::nat..length p - (1::nat). if k = (cs::nat) then if issub (p ! k) ∧ goes_to_alt (p ! fst (steps c p t)) = goes_to_alt (p ! k) then Suc (0::nat) - z (modifies (p ! k)) t else (0::nat) else (0::nat))›*) using z_def (*‹z ≡ Z c p›*) Z_def (*‹Z ?c ?p ?n ?t = (if 0 < R ?c ?p ?n ?t then 1 else 0)›*) cs_def (*‹cs ≡ fst (steps c p t)›*) apply - (*goals: 1. ‹⟦z::nat ⇒ nat ⇒ nat ≡ Z (c::nat × nat list) (p::instruction list); ⋀(c::nat × nat list) (p::instruction list) (n::nat) t::nat. Z c p n t = (if (0::nat) < R c p n t then 1::nat else (0::nat)); cs::nat ≡ fst (steps c p (t::nat))⟧ ⟹ {0::nat..length p - (1::nat)} = {0::nat..length p - (1::nat)}› 2. ‹⋀x::nat. ⟦x ∈ {0::nat..length (p::instruction list) - (1::nat)}; z::nat ⇒ nat ⇒ nat ≡ Z (c::nat × nat list) p; ⋀(c::nat × nat list) (p::instruction list) (n::nat) t::nat. Z c p n t = (if (0::nat) < R c p n t then 1::nat else (0::nat)); cs::nat ≡ fst (steps c p (t::nat))⟧ ⟹ (if issub (p ! x) ∧ goes_to_alt (p ! fst (steps c p t)) = goes_to_alt (p ! x) then (Suc (0::nat) - z (modifies (p ! x)) t) * (if fst (steps c p t) = x then Suc (0::nat) else (0::nat)) else (0::nat)) = (if x = cs then if issub (p ! x) ∧ goes_to_alt (p ! fst (steps c p t)) = goes_to_alt (p ! x) then Suc (0::nat) - z (modifies (p ! x)) t else (0::nat) else (0::nat))› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . hence sub_nzero: "(∑S0 p d (λk. (1 - z (modifies (p!k)) t) * s k t)) = (if issub (p!cs) ∧ d = goes_to_alt (p!cs) then (1 - z (modifies (p!cs)) t) else 0)" apply (auto simp: sum_ssub_zero.simps (*‹∑S0 ?p ?d ?f = (∑k = 0..length ?p - 1. if issub (?p ! k) ∧ ?d = goes_to_alt (?p ! k) then ?f k else 0)›*) s_def (*‹s ≡ S c p›*) S_def (*‹S ?c ?p ?k ?t = (if fst (steps ?c ?p ?t) = ?k then Suc 0 else 0)›*) cs_def (*‹cs ≡ fst (steps c p t)›*)) (*goal: ‹∑S0 p d (λk. (1 - z (modifies (p ! k)) t) * s k t) = (if issub (p ! cs) ∧ d = goes_to_alt (p ! cs) then 1 - z (modifies (p ! cs)) t else 0)›*) using cs_bound (*‹(cs::nat) < length (p::instruction list)›*) cs_def (*‹cs::nat ≡ fst (steps (c::nat × nat list) (p::instruction list) (t::nat))›*) by auto have "s d (Suc t) = (if isadd (p!cs) ∧ d = goes_to (p!cs) then Suc 0 else 0) + (if issub (p!cs) ∧ d = goes_to (p!cs) then z (modifies (p!cs)) t else 0) + (if issub (p!cs) ∧ d = goes_to_alt (p!cs) then (1 - z (modifies (p!cs)) t) else 0) + (if ishalt (p!cs) ∧ d = cs then Suc 0 else 0)" apply (cases "p!cs") (*goals: 1. ‹⋀x11 x12. p ! cs = Add x11 x12 ⟹ s d (Suc t) = (if isadd (p ! cs) ∧ d = goes_to (p ! cs) then Suc 0 else 0) + (if issub (p ! cs) ∧ d = goes_to (p ! cs) then z (modifies (p ! cs)) t else 0) + (if issub (p ! cs) ∧ d = goes_to_alt (p ! cs) then 1 - z (modifies (p ! cs)) t else 0) + (if ishalt (p ! cs) ∧ d = cs then Suc 0 else 0)› 2. ‹⋀x21 x22 x23. p ! cs = Sub x21 x22 x23 ⟹ s d (Suc t) = (if isadd (p ! cs) ∧ d = goes_to (p ! cs) then Suc 0 else 0) + (if issub (p ! cs) ∧ d = goes_to (p ! cs) then z (modifies (p ! cs)) t else 0) + (if issub (p ! cs) ∧ d = goes_to_alt (p ! cs) then 1 - z (modifies (p ! cs)) t else 0) + (if ishalt (p ! cs) ∧ d = cs then Suc 0 else 0)› 3. ‹p ! cs = Halt ⟹ s d (Suc t) = (if isadd (p ! cs) ∧ d = goes_to (p ! cs) then Suc 0 else 0) + (if issub (p ! cs) ∧ d = goes_to (p ! cs) then z (modifies (p ! cs)) t else 0) + (if issub (p ! cs) ∧ d = goes_to_alt (p ! cs) then 1 - z (modifies (p ! cs)) t else 0) + (if ishalt (p ! cs) ∧ d = cs then Suc 0 else 0)› discuss goal 1*) apply ((auto simp: s_def (*‹s::nat ⇒ nat ⇒ nat ≡ S (c::nat × nat list) (p::instruction list)›*) S_def (*‹S (?c::nat × nat list) (?p::instruction list) (?k::nat) (?t::nat) = (if fst (steps ?c ?p ?t) = ?k then Suc (0::nat) else (0::nat))›*) step_def (*‹step (?ic::nat × nat list) (?p::instruction list) = (let nexts::nat = fetch (fst ?ic) ?p (read (snd ?ic) ?p (fst ?ic)) in Let (update (snd ?ic) (?p ! fst ?ic)) (Pair nexts))›*) fetch_def (*‹fetch (?s::nat) (?p::instruction list) (?v::nat) = (if issub (?p ! ?s) ∧ ?v = (0::nat) then goes_to_alt (?p ! ?s) else if ishalt (?p ! ?s) then ?s else goes_to (?p ! ?s))›*) cs_def (*‹cs::nat ≡ fst (steps (c::nat × nat list) (p::instruction list) (t::nat))›*) z_def (*‹z::nat ⇒ nat ⇒ nat ≡ Z (c::nat × nat list) (p::instruction list)›*) Z_def (*‹Z (?c::nat × nat list) (?p::instruction list) (?n::nat) (?t::nat) = (if (0::nat) < R ?c ?p ?n ?t then 1::nat else (0::nat))›*) Z_bounded (*‹Z (?c::nat × nat list) (?p::instruction list) (?l::nat) (?t::nat) ≤ (1::nat)›*) R_def (*‹R (?c::nat × nat list) (?p::instruction list) (?n::nat) (?t::nat) = snd (steps ?c ?p ?t) ! ?n›*) read_def (*‹read (?t::nat list) (?p::instruction list) (?s::nat) = ?t ! modifies (?p ! ?s)›*))[1]) (*discuss goal 2*) apply ((auto simp: s_def (*‹s::nat ⇒ nat ⇒ nat ≡ S (c::nat × nat list) (p::instruction list)›*) S_def (*‹S (?c::nat × nat list) (?p::instruction list) (?k::nat) (?t::nat) = (if fst (steps ?c ?p ?t) = ?k then Suc (0::nat) else (0::nat))›*) step_def (*‹step (?ic::nat × nat list) (?p::instruction list) = (let nexts::nat = fetch (fst ?ic) ?p (read (snd ?ic) ?p (fst ?ic)) in Let (update (snd ?ic) (?p ! fst ?ic)) (Pair nexts))›*) fetch_def (*‹fetch (?s::nat) (?p::instruction list) (?v::nat) = (if issub (?p ! ?s) ∧ ?v = (0::nat) then goes_to_alt (?p ! ?s) else if ishalt (?p ! ?s) then ?s else goes_to (?p ! ?s))›*) cs_def (*‹cs::nat ≡ fst (steps (c::nat × nat list) (p::instruction list) (t::nat))›*) z_def (*‹z::nat ⇒ nat ⇒ nat ≡ Z (c::nat × nat list) (p::instruction list)›*) Z_def (*‹Z (?c::nat × nat list) (?p::instruction list) (?n::nat) (?t::nat) = (if (0::nat) < R ?c ?p ?n ?t then 1::nat else (0::nat))›*) Z_bounded (*‹Z (?c::nat × nat list) (?p::instruction list) (?l::nat) (?t::nat) ≤ (1::nat)›*) R_def (*‹R (?c::nat × nat list) (?p::instruction list) (?n::nat) (?t::nat) = snd (steps ?c ?p ?t) ! ?n›*) read_def (*‹read (?t::nat list) (?p::instruction list) (?s::nat) = ?t ! modifies (?p ! ?s)›*))[1]) (*discuss goal 3*) apply ((auto simp: s_def (*‹s::nat ⇒ nat ⇒ nat ≡ S (c::nat × nat list) (p::instruction list)›*) S_def (*‹S (?c::nat × nat list) (?p::instruction list) (?k::nat) (?t::nat) = (if fst (steps ?c ?p ?t) = ?k then Suc (0::nat) else (0::nat))›*) step_def (*‹step (?ic::nat × nat list) (?p::instruction list) = (let nexts::nat = fetch (fst ?ic) ?p (read (snd ?ic) ?p (fst ?ic)) in Let (update (snd ?ic) (?p ! fst ?ic)) (Pair nexts))›*) fetch_def (*‹fetch (?s::nat) (?p::instruction list) (?v::nat) = (if issub (?p ! ?s) ∧ ?v = (0::nat) then goes_to_alt (?p ! ?s) else if ishalt (?p ! ?s) then ?s else goes_to (?p ! ?s))›*) cs_def (*‹cs::nat ≡ fst (steps (c::nat × nat list) (p::instruction list) (t::nat))›*) z_def (*‹z::nat ⇒ nat ⇒ nat ≡ Z (c::nat × nat list) (p::instruction list)›*) Z_def (*‹Z (?c::nat × nat list) (?p::instruction list) (?n::nat) (?t::nat) = (if (0::nat) < R ?c ?p ?n ?t then 1::nat else (0::nat))›*) Z_bounded (*‹Z (?c::nat × nat list) (?p::instruction list) (?l::nat) (?t::nat) ≤ (1::nat)›*) R_def (*‹R (?c::nat × nat list) (?p::instruction list) (?n::nat) (?t::nat) = snd (steps ?c ?p ?t) ! ?n›*) read_def (*‹read (?t::nat list) (?p::instruction list) (?s::nat) = ?t ! modifies (?p ! ?s)›*))[1]) (*proven 3 subgoals*) . thus "?thesis" (*goal: ‹(s::nat ⇒ nat ⇒ nat) (d::nat) (Suc (t::nat)) = ∑S+ (p::instruction list) d (λk::nat. s k t) + ∑S- p d (λk::nat. (z::nat ⇒ nat ⇒ nat) (modifies (p ! k)) t * s k t) + ∑S0 p d (λk::nat. ((1::nat) - z (modifies (p ! k)) t) * s k t) + (if ishalt (p ! (cs::nat)) ∧ d = cs then Suc (0::nat) else (0::nat))›*) using add (*‹∑S+ p d (λk. s k t) = (if isadd (p ! cs) ∧ d = goes_to (p ! cs) then Suc 0 else 0)›*) sub_zero (*‹∑S- (p::instruction list) (d::nat) (λk::nat. (z::nat ⇒ nat ⇒ nat) (modifies (p ! k)) (t::nat) * (s::nat ⇒ nat ⇒ nat) k t) = (if issub (p ! (cs::nat)) ∧ d = goes_to (p ! cs) then z (modifies (p ! cs)) t else (0::nat))›*) sub_nzero (*‹∑S0 (p::instruction list) (d::nat) (λk::nat. ((1::nat) - (z::nat ⇒ nat ⇒ nat) (modifies (p ! k)) (t::nat)) * (s::nat ⇒ nat ⇒ nat) k t) = (if issub (p ! (cs::nat)) ∧ d = goes_to_alt (p ! cs) then (1::nat) - z (modifies (p ! cs)) t else (0::nat))›*) by auto qed end
{ "path": "afp-2025-02-12/thys/DPRM_Theorem/Register_Machine/SingleStepState.thy", "repo": "afp-2025-02-12", "sha": "f2d78ea3b0fda7dcc52e9c3cb2a826ae2a8b28eaf10134c25a074b98ddd66368" }